Lines Matching +full:x +full:- +full:rp

2    BlueZ - Bluetooth protocol stack for Linux
3 Copyright (c) 2000-2001, 2010, Code Aurora Forum. All rights reserved.
59 bt_dev_err(hdev, "Malformed Event: 0x%2.2x", ev); in hci_ev_skb_pull()
71 bt_dev_err(hdev, "Malformed Command Complete: 0x%4.4x", op); in hci_cc_skb_pull()
83 bt_dev_err(hdev, "Malformed LE Event: 0x%2.2x", ev); in hci_le_ev_skb_pull()
91 struct hci_ev_status *rp = data; in hci_cc_inquiry_cancel() local
93 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_inquiry_cancel()
102 if (rp->status == 0x0c && !test_bit(HCI_INQUIRY, &hdev->flags)) { in hci_cc_inquiry_cancel()
104 rp->status = 0x00; in hci_cc_inquiry_cancel()
107 if (rp->status) in hci_cc_inquiry_cancel()
108 return rp->status; in hci_cc_inquiry_cancel()
110 clear_bit(HCI_INQUIRY, &hdev->flags); in hci_cc_inquiry_cancel()
112 wake_up_bit(&hdev->flags, HCI_INQUIRY); in hci_cc_inquiry_cancel()
119 hdev->le_scan_type != LE_SCAN_ACTIVE) in hci_cc_inquiry_cancel()
125 return rp->status; in hci_cc_inquiry_cancel()
131 struct hci_ev_status *rp = data; in hci_cc_periodic_inq() local
133 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_periodic_inq()
135 if (rp->status) in hci_cc_periodic_inq()
136 return rp->status; in hci_cc_periodic_inq()
140 return rp->status; in hci_cc_periodic_inq()
146 struct hci_ev_status *rp = data; in hci_cc_exit_periodic_inq() local
148 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_exit_periodic_inq()
150 if (rp->status) in hci_cc_exit_periodic_inq()
151 return rp->status; in hci_cc_exit_periodic_inq()
157 return rp->status; in hci_cc_exit_periodic_inq()
163 struct hci_ev_status *rp = data; in hci_cc_remote_name_req_cancel() local
165 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_remote_name_req_cancel()
167 return rp->status; in hci_cc_remote_name_req_cancel()
173 struct hci_rp_role_discovery *rp = data; in hci_cc_role_discovery() local
176 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_role_discovery()
178 if (rp->status) in hci_cc_role_discovery()
179 return rp->status; in hci_cc_role_discovery()
183 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_role_discovery()
185 conn->role = rp->role; in hci_cc_role_discovery()
189 return rp->status; in hci_cc_role_discovery()
195 struct hci_rp_read_link_policy *rp = data; in hci_cc_read_link_policy() local
198 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_link_policy()
200 if (rp->status) in hci_cc_read_link_policy()
201 return rp->status; in hci_cc_read_link_policy()
205 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_link_policy()
207 conn->link_policy = __le16_to_cpu(rp->policy); in hci_cc_read_link_policy()
211 return rp->status; in hci_cc_read_link_policy()
217 struct hci_rp_write_link_policy *rp = data; in hci_cc_write_link_policy() local
221 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_link_policy()
223 if (rp->status) in hci_cc_write_link_policy()
224 return rp->status; in hci_cc_write_link_policy()
228 return rp->status; in hci_cc_write_link_policy()
232 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_write_link_policy()
234 conn->link_policy = get_unaligned_le16(sent + 2); in hci_cc_write_link_policy()
238 return rp->status; in hci_cc_write_link_policy()
244 struct hci_rp_read_def_link_policy *rp = data; in hci_cc_read_def_link_policy() local
246 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_def_link_policy()
248 if (rp->status) in hci_cc_read_def_link_policy()
249 return rp->status; in hci_cc_read_def_link_policy()
251 hdev->link_policy = __le16_to_cpu(rp->policy); in hci_cc_read_def_link_policy()
253 return rp->status; in hci_cc_read_def_link_policy()
259 struct hci_ev_status *rp = data; in hci_cc_write_def_link_policy() local
262 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_def_link_policy()
264 if (rp->status) in hci_cc_write_def_link_policy()
265 return rp->status; in hci_cc_write_def_link_policy()
269 return rp->status; in hci_cc_write_def_link_policy()
271 hdev->link_policy = get_unaligned_le16(sent); in hci_cc_write_def_link_policy()
273 return rp->status; in hci_cc_write_def_link_policy()
278 struct hci_ev_status *rp = data; in hci_cc_reset() local
280 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_reset()
282 clear_bit(HCI_RESET, &hdev->flags); in hci_cc_reset()
284 if (rp->status) in hci_cc_reset()
285 return rp->status; in hci_cc_reset()
287 /* Reset all non-persistent flags */ in hci_cc_reset()
292 hdev->inq_tx_power = HCI_TX_POWER_INVALID; in hci_cc_reset()
293 hdev->adv_tx_power = HCI_TX_POWER_INVALID; in hci_cc_reset()
295 memset(hdev->adv_data, 0, sizeof(hdev->adv_data)); in hci_cc_reset()
296 hdev->adv_data_len = 0; in hci_cc_reset()
298 memset(hdev->scan_rsp_data, 0, sizeof(hdev->scan_rsp_data)); in hci_cc_reset()
299 hdev->scan_rsp_data_len = 0; in hci_cc_reset()
301 hdev->le_scan_type = LE_SCAN_PASSIVE; in hci_cc_reset()
303 hdev->ssp_debug_mode = 0; in hci_cc_reset()
305 hci_bdaddr_list_clear(&hdev->le_accept_list); in hci_cc_reset()
306 hci_bdaddr_list_clear(&hdev->le_resolv_list); in hci_cc_reset()
308 return rp->status; in hci_cc_reset()
314 struct hci_rp_read_stored_link_key *rp = data; in hci_cc_read_stored_link_key() local
317 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_stored_link_key()
321 return rp->status; in hci_cc_read_stored_link_key()
323 if (!rp->status && sent->read_all == 0x01) { in hci_cc_read_stored_link_key()
324 hdev->stored_max_keys = le16_to_cpu(rp->max_keys); in hci_cc_read_stored_link_key()
325 hdev->stored_num_keys = le16_to_cpu(rp->num_keys); in hci_cc_read_stored_link_key()
328 return rp->status; in hci_cc_read_stored_link_key()
334 struct hci_rp_delete_stored_link_key *rp = data; in hci_cc_delete_stored_link_key() local
337 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_delete_stored_link_key()
339 if (rp->status) in hci_cc_delete_stored_link_key()
340 return rp->status; in hci_cc_delete_stored_link_key()
342 num_keys = le16_to_cpu(rp->num_keys); in hci_cc_delete_stored_link_key()
344 if (num_keys <= hdev->stored_num_keys) in hci_cc_delete_stored_link_key()
345 hdev->stored_num_keys -= num_keys; in hci_cc_delete_stored_link_key()
347 hdev->stored_num_keys = 0; in hci_cc_delete_stored_link_key()
349 return rp->status; in hci_cc_delete_stored_link_key()
355 struct hci_ev_status *rp = data; in hci_cc_write_local_name() local
358 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_local_name()
362 return rp->status; in hci_cc_write_local_name()
367 mgmt_set_local_name_complete(hdev, sent, rp->status); in hci_cc_write_local_name()
368 else if (!rp->status) in hci_cc_write_local_name()
369 memcpy(hdev->dev_name, sent, HCI_MAX_NAME_LENGTH); in hci_cc_write_local_name()
373 return rp->status; in hci_cc_write_local_name()
379 struct hci_rp_read_local_name *rp = data; in hci_cc_read_local_name() local
381 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_name()
383 if (rp->status) in hci_cc_read_local_name()
384 return rp->status; in hci_cc_read_local_name()
388 memcpy(hdev->dev_name, rp->name, HCI_MAX_NAME_LENGTH); in hci_cc_read_local_name()
390 return rp->status; in hci_cc_read_local_name()
396 struct hci_ev_status *rp = data; in hci_cc_write_auth_enable() local
399 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_auth_enable()
403 return rp->status; in hci_cc_write_auth_enable()
407 if (!rp->status) { in hci_cc_write_auth_enable()
411 set_bit(HCI_AUTH, &hdev->flags); in hci_cc_write_auth_enable()
413 clear_bit(HCI_AUTH, &hdev->flags); in hci_cc_write_auth_enable()
417 mgmt_auth_enable_complete(hdev, rp->status); in hci_cc_write_auth_enable()
421 return rp->status; in hci_cc_write_auth_enable()
427 struct hci_ev_status *rp = data; in hci_cc_write_encrypt_mode() local
431 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_encrypt_mode()
433 if (rp->status) in hci_cc_write_encrypt_mode()
434 return rp->status; in hci_cc_write_encrypt_mode()
438 return rp->status; in hci_cc_write_encrypt_mode()
443 set_bit(HCI_ENCRYPT, &hdev->flags); in hci_cc_write_encrypt_mode()
445 clear_bit(HCI_ENCRYPT, &hdev->flags); in hci_cc_write_encrypt_mode()
447 return rp->status; in hci_cc_write_encrypt_mode()
453 struct hci_ev_status *rp = data; in hci_cc_write_scan_enable() local
457 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_scan_enable()
461 return rp->status; in hci_cc_write_scan_enable()
467 if (rp->status) { in hci_cc_write_scan_enable()
468 hdev->discov_timeout = 0; in hci_cc_write_scan_enable()
473 set_bit(HCI_ISCAN, &hdev->flags); in hci_cc_write_scan_enable()
475 clear_bit(HCI_ISCAN, &hdev->flags); in hci_cc_write_scan_enable()
478 set_bit(HCI_PSCAN, &hdev->flags); in hci_cc_write_scan_enable()
480 clear_bit(HCI_PSCAN, &hdev->flags); in hci_cc_write_scan_enable()
485 return rp->status; in hci_cc_write_scan_enable()
491 struct hci_ev_status *rp = data; in hci_cc_set_event_filter() local
495 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_set_event_filter()
497 if (rp->status) in hci_cc_set_event_filter()
498 return rp->status; in hci_cc_set_event_filter()
502 return rp->status; in hci_cc_set_event_filter()
506 if (cp->flt_type == HCI_FLT_CLEAR_ALL) in hci_cc_set_event_filter()
511 return rp->status; in hci_cc_set_event_filter()
517 struct hci_rp_read_class_of_dev *rp = data; in hci_cc_read_class_of_dev() local
522 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_class_of_dev()
524 if (rp->status) in hci_cc_read_class_of_dev()
525 return rp->status; in hci_cc_read_class_of_dev()
527 memcpy(hdev->dev_class, rp->dev_class, 3); in hci_cc_read_class_of_dev()
529 bt_dev_dbg(hdev, "class 0x%.2x%.2x%.2x", hdev->dev_class[2], in hci_cc_read_class_of_dev()
530 hdev->dev_class[1], hdev->dev_class[0]); in hci_cc_read_class_of_dev()
532 return rp->status; in hci_cc_read_class_of_dev()
538 struct hci_ev_status *rp = data; in hci_cc_write_class_of_dev() local
541 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_class_of_dev()
545 return rp->status; in hci_cc_write_class_of_dev()
549 if (!rp->status) in hci_cc_write_class_of_dev()
550 memcpy(hdev->dev_class, sent, 3); in hci_cc_write_class_of_dev()
553 mgmt_set_class_of_dev_complete(hdev, sent, rp->status); in hci_cc_write_class_of_dev()
557 return rp->status; in hci_cc_write_class_of_dev()
563 struct hci_rp_read_voice_setting *rp = data; in hci_cc_read_voice_setting() local
566 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_voice_setting()
568 if (rp->status) in hci_cc_read_voice_setting()
569 return rp->status; in hci_cc_read_voice_setting()
571 setting = __le16_to_cpu(rp->voice_setting); in hci_cc_read_voice_setting()
573 if (hdev->voice_setting == setting) in hci_cc_read_voice_setting()
574 return rp->status; in hci_cc_read_voice_setting()
576 hdev->voice_setting = setting; in hci_cc_read_voice_setting()
578 bt_dev_dbg(hdev, "voice setting 0x%4.4x", setting); in hci_cc_read_voice_setting()
580 if (hdev->notify) in hci_cc_read_voice_setting()
581 hdev->notify(hdev, HCI_NOTIFY_VOICE_SETTING); in hci_cc_read_voice_setting()
583 return rp->status; in hci_cc_read_voice_setting()
589 struct hci_ev_status *rp = data; in hci_cc_write_voice_setting() local
593 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_voice_setting()
595 if (rp->status) in hci_cc_write_voice_setting()
596 return rp->status; in hci_cc_write_voice_setting()
600 return rp->status; in hci_cc_write_voice_setting()
604 if (hdev->voice_setting == setting) in hci_cc_write_voice_setting()
605 return rp->status; in hci_cc_write_voice_setting()
607 hdev->voice_setting = setting; in hci_cc_write_voice_setting()
609 bt_dev_dbg(hdev, "voice setting 0x%4.4x", setting); in hci_cc_write_voice_setting()
611 if (hdev->notify) in hci_cc_write_voice_setting()
612 hdev->notify(hdev, HCI_NOTIFY_VOICE_SETTING); in hci_cc_write_voice_setting()
614 return rp->status; in hci_cc_write_voice_setting()
620 struct hci_rp_read_num_supported_iac *rp = data; in hci_cc_read_num_supported_iac() local
622 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_num_supported_iac()
624 if (rp->status) in hci_cc_read_num_supported_iac()
625 return rp->status; in hci_cc_read_num_supported_iac()
627 hdev->num_iac = rp->num_iac; in hci_cc_read_num_supported_iac()
629 bt_dev_dbg(hdev, "num iac %d", hdev->num_iac); in hci_cc_read_num_supported_iac()
631 return rp->status; in hci_cc_read_num_supported_iac()
637 struct hci_ev_status *rp = data; in hci_cc_write_ssp_mode() local
640 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_ssp_mode()
644 return rp->status; in hci_cc_write_ssp_mode()
648 if (!rp->status) { in hci_cc_write_ssp_mode()
649 if (sent->mode) in hci_cc_write_ssp_mode()
650 hdev->features[1][0] |= LMP_HOST_SSP; in hci_cc_write_ssp_mode()
652 hdev->features[1][0] &= ~LMP_HOST_SSP; in hci_cc_write_ssp_mode()
655 if (!rp->status) { in hci_cc_write_ssp_mode()
656 if (sent->mode) in hci_cc_write_ssp_mode()
664 return rp->status; in hci_cc_write_ssp_mode()
670 struct hci_ev_status *rp = data; in hci_cc_write_sc_support() local
673 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_sc_support()
677 return rp->status; in hci_cc_write_sc_support()
681 if (!rp->status) { in hci_cc_write_sc_support()
682 if (sent->support) in hci_cc_write_sc_support()
683 hdev->features[1][0] |= LMP_HOST_SC; in hci_cc_write_sc_support()
685 hdev->features[1][0] &= ~LMP_HOST_SC; in hci_cc_write_sc_support()
688 if (!hci_dev_test_flag(hdev, HCI_MGMT) && !rp->status) { in hci_cc_write_sc_support()
689 if (sent->support) in hci_cc_write_sc_support()
697 return rp->status; in hci_cc_write_sc_support()
703 struct hci_rp_read_local_version *rp = data; in hci_cc_read_local_version() local
705 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_version()
707 if (rp->status) in hci_cc_read_local_version()
708 return rp->status; in hci_cc_read_local_version()
712 hdev->hci_ver = rp->hci_ver; in hci_cc_read_local_version()
713 hdev->hci_rev = __le16_to_cpu(rp->hci_rev); in hci_cc_read_local_version()
714 hdev->lmp_ver = rp->lmp_ver; in hci_cc_read_local_version()
715 hdev->manufacturer = __le16_to_cpu(rp->manufacturer); in hci_cc_read_local_version()
716 hdev->lmp_subver = __le16_to_cpu(rp->lmp_subver); in hci_cc_read_local_version()
719 return rp->status; in hci_cc_read_local_version()
725 struct hci_rp_read_enc_key_size *rp = data; in hci_cc_read_enc_key_size() local
728 u8 status = rp->status; in hci_cc_read_enc_key_size()
730 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cc_read_enc_key_size()
732 handle = le16_to_cpu(rp->handle); in hci_cc_read_enc_key_size()
749 conn->enc_key_size = 0; in hci_cc_read_enc_key_size()
751 conn->enc_key_size = rp->key_size; in hci_cc_read_enc_key_size()
754 if (conn->enc_key_size < hdev->min_enc_key_size) { in hci_cc_read_enc_key_size()
755 /* As slave role, the conn->state has been set to in hci_cc_read_enc_key_size()
758 * nothing with the non-zero status. in hci_cc_read_enc_key_size()
764 clear_bit(HCI_CONN_ENCRYPT, &conn->flags); in hci_cc_read_enc_key_size()
765 clear_bit(HCI_CONN_AES_CCM, &conn->flags); in hci_cc_read_enc_key_size()
780 struct hci_rp_read_local_commands *rp = data; in hci_cc_read_local_commands() local
782 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_commands()
784 if (rp->status) in hci_cc_read_local_commands()
785 return rp->status; in hci_cc_read_local_commands()
789 memcpy(hdev->commands, rp->commands, sizeof(hdev->commands)); in hci_cc_read_local_commands()
791 return rp->status; in hci_cc_read_local_commands()
797 struct hci_rp_read_auth_payload_to *rp = data; in hci_cc_read_auth_payload_timeout() local
800 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_auth_payload_timeout()
802 if (rp->status) in hci_cc_read_auth_payload_timeout()
803 return rp->status; in hci_cc_read_auth_payload_timeout()
807 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_auth_payload_timeout()
809 conn->auth_payload_timeout = __le16_to_cpu(rp->timeout); in hci_cc_read_auth_payload_timeout()
813 return rp->status; in hci_cc_read_auth_payload_timeout()
819 struct hci_rp_write_auth_payload_to *rp = data; in hci_cc_write_auth_payload_timeout() local
823 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_auth_payload_timeout()
827 return rp->status; in hci_cc_write_auth_payload_timeout()
831 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_write_auth_payload_timeout()
833 rp->status = 0xff; in hci_cc_write_auth_payload_timeout()
837 if (!rp->status) in hci_cc_write_auth_payload_timeout()
838 conn->auth_payload_timeout = get_unaligned_le16(sent + 2); in hci_cc_write_auth_payload_timeout()
843 return rp->status; in hci_cc_write_auth_payload_timeout()
849 struct hci_rp_read_local_features *rp = data; in hci_cc_read_local_features() local
851 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_features()
853 if (rp->status) in hci_cc_read_local_features()
854 return rp->status; in hci_cc_read_local_features()
856 memcpy(hdev->features, rp->features, 8); in hci_cc_read_local_features()
861 if (hdev->features[0][0] & LMP_3SLOT) in hci_cc_read_local_features()
862 hdev->pkt_type |= (HCI_DM3 | HCI_DH3); in hci_cc_read_local_features()
864 if (hdev->features[0][0] & LMP_5SLOT) in hci_cc_read_local_features()
865 hdev->pkt_type |= (HCI_DM5 | HCI_DH5); in hci_cc_read_local_features()
867 if (hdev->features[0][1] & LMP_HV2) { in hci_cc_read_local_features()
868 hdev->pkt_type |= (HCI_HV2); in hci_cc_read_local_features()
869 hdev->esco_type |= (ESCO_HV2); in hci_cc_read_local_features()
872 if (hdev->features[0][1] & LMP_HV3) { in hci_cc_read_local_features()
873 hdev->pkt_type |= (HCI_HV3); in hci_cc_read_local_features()
874 hdev->esco_type |= (ESCO_HV3); in hci_cc_read_local_features()
878 hdev->esco_type |= (ESCO_EV3); in hci_cc_read_local_features()
880 if (hdev->features[0][4] & LMP_EV4) in hci_cc_read_local_features()
881 hdev->esco_type |= (ESCO_EV4); in hci_cc_read_local_features()
883 if (hdev->features[0][4] & LMP_EV5) in hci_cc_read_local_features()
884 hdev->esco_type |= (ESCO_EV5); in hci_cc_read_local_features()
886 if (hdev->features[0][5] & LMP_EDR_ESCO_2M) in hci_cc_read_local_features()
887 hdev->esco_type |= (ESCO_2EV3); in hci_cc_read_local_features()
889 if (hdev->features[0][5] & LMP_EDR_ESCO_3M) in hci_cc_read_local_features()
890 hdev->esco_type |= (ESCO_3EV3); in hci_cc_read_local_features()
892 if (hdev->features[0][5] & LMP_EDR_3S_ESCO) in hci_cc_read_local_features()
893 hdev->esco_type |= (ESCO_2EV5 | ESCO_3EV5); in hci_cc_read_local_features()
895 return rp->status; in hci_cc_read_local_features()
901 struct hci_rp_read_local_ext_features *rp = data; in hci_cc_read_local_ext_features() local
903 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_ext_features()
905 if (rp->status) in hci_cc_read_local_ext_features()
906 return rp->status; in hci_cc_read_local_ext_features()
908 if (hdev->max_page < rp->max_page) { in hci_cc_read_local_ext_features()
910 &hdev->quirks)) in hci_cc_read_local_ext_features()
913 hdev->max_page = rp->max_page; in hci_cc_read_local_ext_features()
916 if (rp->page < HCI_MAX_PAGES) in hci_cc_read_local_ext_features()
917 memcpy(hdev->features[rp->page], rp->features, 8); in hci_cc_read_local_ext_features()
919 return rp->status; in hci_cc_read_local_ext_features()
925 struct hci_rp_read_flow_control_mode *rp = data; in hci_cc_read_flow_control_mode() local
927 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_flow_control_mode()
929 if (rp->status) in hci_cc_read_flow_control_mode()
930 return rp->status; in hci_cc_read_flow_control_mode()
932 hdev->flow_ctl_mode = rp->mode; in hci_cc_read_flow_control_mode()
934 return rp->status; in hci_cc_read_flow_control_mode()
940 struct hci_rp_read_buffer_size *rp = data; in hci_cc_read_buffer_size() local
942 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_buffer_size()
944 if (rp->status) in hci_cc_read_buffer_size()
945 return rp->status; in hci_cc_read_buffer_size()
947 hdev->acl_mtu = __le16_to_cpu(rp->acl_mtu); in hci_cc_read_buffer_size()
948 hdev->sco_mtu = rp->sco_mtu; in hci_cc_read_buffer_size()
949 hdev->acl_pkts = __le16_to_cpu(rp->acl_max_pkt); in hci_cc_read_buffer_size()
950 hdev->sco_pkts = __le16_to_cpu(rp->sco_max_pkt); in hci_cc_read_buffer_size()
952 if (test_bit(HCI_QUIRK_FIXUP_BUFFER_SIZE, &hdev->quirks)) { in hci_cc_read_buffer_size()
953 hdev->sco_mtu = 64; in hci_cc_read_buffer_size()
954 hdev->sco_pkts = 8; in hci_cc_read_buffer_size()
957 hdev->acl_cnt = hdev->acl_pkts; in hci_cc_read_buffer_size()
958 hdev->sco_cnt = hdev->sco_pkts; in hci_cc_read_buffer_size()
960 BT_DBG("%s acl mtu %d:%d sco mtu %d:%d", hdev->name, hdev->acl_mtu, in hci_cc_read_buffer_size()
961 hdev->acl_pkts, hdev->sco_mtu, hdev->sco_pkts); in hci_cc_read_buffer_size()
963 return rp->status; in hci_cc_read_buffer_size()
969 struct hci_rp_read_bd_addr *rp = data; in hci_cc_read_bd_addr() local
971 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_bd_addr()
973 if (rp->status) in hci_cc_read_bd_addr()
974 return rp->status; in hci_cc_read_bd_addr()
976 if (test_bit(HCI_INIT, &hdev->flags)) in hci_cc_read_bd_addr()
977 bacpy(&hdev->bdaddr, &rp->bdaddr); in hci_cc_read_bd_addr()
980 bacpy(&hdev->setup_addr, &rp->bdaddr); in hci_cc_read_bd_addr()
982 return rp->status; in hci_cc_read_bd_addr()
988 struct hci_rp_read_local_pairing_opts *rp = data; in hci_cc_read_local_pairing_opts() local
990 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_pairing_opts()
992 if (rp->status) in hci_cc_read_local_pairing_opts()
993 return rp->status; in hci_cc_read_local_pairing_opts()
997 hdev->pairing_opts = rp->pairing_opts; in hci_cc_read_local_pairing_opts()
998 hdev->max_enc_key_size = rp->max_key_size; in hci_cc_read_local_pairing_opts()
1001 return rp->status; in hci_cc_read_local_pairing_opts()
1007 struct hci_rp_read_page_scan_activity *rp = data; in hci_cc_read_page_scan_activity() local
1009 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_page_scan_activity()
1011 if (rp->status) in hci_cc_read_page_scan_activity()
1012 return rp->status; in hci_cc_read_page_scan_activity()
1014 if (test_bit(HCI_INIT, &hdev->flags)) { in hci_cc_read_page_scan_activity()
1015 hdev->page_scan_interval = __le16_to_cpu(rp->interval); in hci_cc_read_page_scan_activity()
1016 hdev->page_scan_window = __le16_to_cpu(rp->window); in hci_cc_read_page_scan_activity()
1019 return rp->status; in hci_cc_read_page_scan_activity()
1025 struct hci_ev_status *rp = data; in hci_cc_write_page_scan_activity() local
1028 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_page_scan_activity()
1030 if (rp->status) in hci_cc_write_page_scan_activity()
1031 return rp->status; in hci_cc_write_page_scan_activity()
1035 return rp->status; in hci_cc_write_page_scan_activity()
1037 hdev->page_scan_interval = __le16_to_cpu(sent->interval); in hci_cc_write_page_scan_activity()
1038 hdev->page_scan_window = __le16_to_cpu(sent->window); in hci_cc_write_page_scan_activity()
1040 return rp->status; in hci_cc_write_page_scan_activity()
1046 struct hci_rp_read_page_scan_type *rp = data; in hci_cc_read_page_scan_type() local
1048 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_page_scan_type()
1050 if (rp->status) in hci_cc_read_page_scan_type()
1051 return rp->status; in hci_cc_read_page_scan_type()
1053 if (test_bit(HCI_INIT, &hdev->flags)) in hci_cc_read_page_scan_type()
1054 hdev->page_scan_type = rp->type; in hci_cc_read_page_scan_type()
1056 return rp->status; in hci_cc_read_page_scan_type()
1062 struct hci_ev_status *rp = data; in hci_cc_write_page_scan_type() local
1065 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_page_scan_type()
1067 if (rp->status) in hci_cc_write_page_scan_type()
1068 return rp->status; in hci_cc_write_page_scan_type()
1072 hdev->page_scan_type = *type; in hci_cc_write_page_scan_type()
1074 return rp->status; in hci_cc_write_page_scan_type()
1080 struct hci_rp_read_data_block_size *rp = data; in hci_cc_read_data_block_size() local
1082 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_data_block_size()
1084 if (rp->status) in hci_cc_read_data_block_size()
1085 return rp->status; in hci_cc_read_data_block_size()
1087 hdev->block_mtu = __le16_to_cpu(rp->max_acl_len); in hci_cc_read_data_block_size()
1088 hdev->block_len = __le16_to_cpu(rp->block_len); in hci_cc_read_data_block_size()
1089 hdev->num_blocks = __le16_to_cpu(rp->num_blocks); in hci_cc_read_data_block_size()
1091 hdev->block_cnt = hdev->num_blocks; in hci_cc_read_data_block_size()
1093 BT_DBG("%s blk mtu %d cnt %d len %d", hdev->name, hdev->block_mtu, in hci_cc_read_data_block_size()
1094 hdev->block_cnt, hdev->block_len); in hci_cc_read_data_block_size()
1096 return rp->status; in hci_cc_read_data_block_size()
1102 struct hci_rp_read_clock *rp = data; in hci_cc_read_clock() local
1106 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_clock()
1108 if (rp->status) in hci_cc_read_clock()
1109 return rp->status; in hci_cc_read_clock()
1117 if (cp->which == 0x00) { in hci_cc_read_clock()
1118 hdev->clock = le32_to_cpu(rp->clock); in hci_cc_read_clock()
1122 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_clock()
1124 conn->clock = le32_to_cpu(rp->clock); in hci_cc_read_clock()
1125 conn->clock_accuracy = le16_to_cpu(rp->accuracy); in hci_cc_read_clock()
1130 return rp->status; in hci_cc_read_clock()
1136 struct hci_rp_read_local_amp_info *rp = data; in hci_cc_read_local_amp_info() local
1138 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_amp_info()
1140 if (rp->status) in hci_cc_read_local_amp_info()
1141 return rp->status; in hci_cc_read_local_amp_info()
1143 hdev->amp_status = rp->amp_status; in hci_cc_read_local_amp_info()
1144 hdev->amp_total_bw = __le32_to_cpu(rp->total_bw); in hci_cc_read_local_amp_info()
1145 hdev->amp_max_bw = __le32_to_cpu(rp->max_bw); in hci_cc_read_local_amp_info()
1146 hdev->amp_min_latency = __le32_to_cpu(rp->min_latency); in hci_cc_read_local_amp_info()
1147 hdev->amp_max_pdu = __le32_to_cpu(rp->max_pdu); in hci_cc_read_local_amp_info()
1148 hdev->amp_type = rp->amp_type; in hci_cc_read_local_amp_info()
1149 hdev->amp_pal_cap = __le16_to_cpu(rp->pal_cap); in hci_cc_read_local_amp_info()
1150 hdev->amp_assoc_size = __le16_to_cpu(rp->max_assoc_size); in hci_cc_read_local_amp_info()
1151 hdev->amp_be_flush_to = __le32_to_cpu(rp->be_flush_to); in hci_cc_read_local_amp_info()
1152 hdev->amp_max_flush_to = __le32_to_cpu(rp->max_flush_to); in hci_cc_read_local_amp_info()
1154 return rp->status; in hci_cc_read_local_amp_info()
1160 struct hci_rp_read_inq_rsp_tx_power *rp = data; in hci_cc_read_inq_rsp_tx_power() local
1162 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_inq_rsp_tx_power()
1164 if (rp->status) in hci_cc_read_inq_rsp_tx_power()
1165 return rp->status; in hci_cc_read_inq_rsp_tx_power()
1167 hdev->inq_tx_power = rp->tx_power; in hci_cc_read_inq_rsp_tx_power()
1169 return rp->status; in hci_cc_read_inq_rsp_tx_power()
1175 struct hci_rp_read_def_err_data_reporting *rp = data; in hci_cc_read_def_err_data_reporting() local
1177 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_def_err_data_reporting()
1179 if (rp->status) in hci_cc_read_def_err_data_reporting()
1180 return rp->status; in hci_cc_read_def_err_data_reporting()
1182 hdev->err_data_reporting = rp->err_data_reporting; in hci_cc_read_def_err_data_reporting()
1184 return rp->status; in hci_cc_read_def_err_data_reporting()
1190 struct hci_ev_status *rp = data; in hci_cc_write_def_err_data_reporting() local
1193 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_def_err_data_reporting()
1195 if (rp->status) in hci_cc_write_def_err_data_reporting()
1196 return rp->status; in hci_cc_write_def_err_data_reporting()
1200 return rp->status; in hci_cc_write_def_err_data_reporting()
1202 hdev->err_data_reporting = cp->err_data_reporting; in hci_cc_write_def_err_data_reporting()
1204 return rp->status; in hci_cc_write_def_err_data_reporting()
1210 struct hci_rp_pin_code_reply *rp = data; in hci_cc_pin_code_reply() local
1214 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_pin_code_reply()
1219 mgmt_pin_code_reply_complete(hdev, &rp->bdaddr, rp->status); in hci_cc_pin_code_reply()
1221 if (rp->status) in hci_cc_pin_code_reply()
1228 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cc_pin_code_reply()
1230 conn->pin_length = cp->pin_len; in hci_cc_pin_code_reply()
1234 return rp->status; in hci_cc_pin_code_reply()
1240 struct hci_rp_pin_code_neg_reply *rp = data; in hci_cc_pin_code_neg_reply() local
1242 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_pin_code_neg_reply()
1247 mgmt_pin_code_neg_reply_complete(hdev, &rp->bdaddr, in hci_cc_pin_code_neg_reply()
1248 rp->status); in hci_cc_pin_code_neg_reply()
1252 return rp->status; in hci_cc_pin_code_neg_reply()
1258 struct hci_rp_le_read_buffer_size *rp = data; in hci_cc_le_read_buffer_size() local
1260 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_read_buffer_size()
1262 if (rp->status) in hci_cc_le_read_buffer_size()
1263 return rp->status; in hci_cc_le_read_buffer_size()
1265 hdev->le_mtu = __le16_to_cpu(rp->le_mtu); in hci_cc_le_read_buffer_size()
1266 hdev->le_pkts = rp->le_max_pkt; in hci_cc_le_read_buffer_size()
1268 hdev->le_cnt = hdev->le_pkts; in hci_cc_le_read_buffer_size()
1270 BT_DBG("%s le mtu %d:%d", hdev->name, hdev->le_mtu, hdev->le_pkts); in hci_cc_le_read_buffer_size()
1272 return rp->status; in hci_cc_le_read_buffer_size()
1278 struct hci_rp_le_read_local_features *rp = data; in hci_cc_le_read_local_features() local
1280 BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); in hci_cc_le_read_local_features()
1282 if (rp->status) in hci_cc_le_read_local_features()
1283 return rp->status; in hci_cc_le_read_local_features()
1285 memcpy(hdev->le_features, rp->features, 8); in hci_cc_le_read_local_features()
1287 return rp->status; in hci_cc_le_read_local_features()
1293 struct hci_rp_le_read_adv_tx_power *rp = data; in hci_cc_le_read_adv_tx_power() local
1295 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_read_adv_tx_power()
1297 if (rp->status) in hci_cc_le_read_adv_tx_power()
1298 return rp->status; in hci_cc_le_read_adv_tx_power()
1300 hdev->adv_tx_power = rp->tx_power; in hci_cc_le_read_adv_tx_power()
1302 return rp->status; in hci_cc_le_read_adv_tx_power()
1308 struct hci_rp_user_confirm_reply *rp = data; in hci_cc_user_confirm_reply() local
1310 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_user_confirm_reply()
1315 mgmt_user_confirm_reply_complete(hdev, &rp->bdaddr, ACL_LINK, 0, in hci_cc_user_confirm_reply()
1316 rp->status); in hci_cc_user_confirm_reply()
1320 return rp->status; in hci_cc_user_confirm_reply()
1326 struct hci_rp_user_confirm_reply *rp = data; in hci_cc_user_confirm_neg_reply() local
1328 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_user_confirm_neg_reply()
1333 mgmt_user_confirm_neg_reply_complete(hdev, &rp->bdaddr, in hci_cc_user_confirm_neg_reply()
1334 ACL_LINK, 0, rp->status); in hci_cc_user_confirm_neg_reply()
1338 return rp->status; in hci_cc_user_confirm_neg_reply()
1344 struct hci_rp_user_confirm_reply *rp = data; in hci_cc_user_passkey_reply() local
1346 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_user_passkey_reply()
1351 mgmt_user_passkey_reply_complete(hdev, &rp->bdaddr, ACL_LINK, in hci_cc_user_passkey_reply()
1352 0, rp->status); in hci_cc_user_passkey_reply()
1356 return rp->status; in hci_cc_user_passkey_reply()
1362 struct hci_rp_user_confirm_reply *rp = data; in hci_cc_user_passkey_neg_reply() local
1364 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_user_passkey_neg_reply()
1369 mgmt_user_passkey_neg_reply_complete(hdev, &rp->bdaddr, in hci_cc_user_passkey_neg_reply()
1370 ACL_LINK, 0, rp->status); in hci_cc_user_passkey_neg_reply()
1374 return rp->status; in hci_cc_user_passkey_neg_reply()
1380 struct hci_rp_read_local_oob_data *rp = data; in hci_cc_read_local_oob_data() local
1382 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_oob_data()
1384 return rp->status; in hci_cc_read_local_oob_data()
1390 struct hci_rp_read_local_oob_ext_data *rp = data; in hci_cc_read_local_oob_ext_data() local
1392 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_oob_ext_data()
1394 return rp->status; in hci_cc_read_local_oob_ext_data()
1400 struct hci_ev_status *rp = data; in hci_cc_le_set_random_addr() local
1403 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_random_addr()
1405 if (rp->status) in hci_cc_le_set_random_addr()
1406 return rp->status; in hci_cc_le_set_random_addr()
1410 return rp->status; in hci_cc_le_set_random_addr()
1414 bacpy(&hdev->random_addr, sent); in hci_cc_le_set_random_addr()
1416 if (!bacmp(&hdev->rpa, sent)) { in hci_cc_le_set_random_addr()
1418 queue_delayed_work(hdev->workqueue, &hdev->rpa_expired, in hci_cc_le_set_random_addr()
1419 secs_to_jiffies(hdev->rpa_timeout)); in hci_cc_le_set_random_addr()
1424 return rp->status; in hci_cc_le_set_random_addr()
1430 struct hci_ev_status *rp = data; in hci_cc_le_set_default_phy() local
1433 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_default_phy()
1435 if (rp->status) in hci_cc_le_set_default_phy()
1436 return rp->status; in hci_cc_le_set_default_phy()
1440 return rp->status; in hci_cc_le_set_default_phy()
1444 hdev->le_tx_def_phys = cp->tx_phys; in hci_cc_le_set_default_phy()
1445 hdev->le_rx_def_phys = cp->rx_phys; in hci_cc_le_set_default_phy()
1449 return rp->status; in hci_cc_le_set_default_phy()
1455 struct hci_ev_status *rp = data; in hci_cc_le_set_adv_set_random_addr() local
1459 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_adv_set_random_addr()
1461 if (rp->status) in hci_cc_le_set_adv_set_random_addr()
1462 return rp->status; in hci_cc_le_set_adv_set_random_addr()
1467 * non-extended adverting. in hci_cc_le_set_adv_set_random_addr()
1469 if (!cp || !cp->handle) in hci_cc_le_set_adv_set_random_addr()
1470 return rp->status; in hci_cc_le_set_adv_set_random_addr()
1474 adv = hci_find_adv_instance(hdev, cp->handle); in hci_cc_le_set_adv_set_random_addr()
1476 bacpy(&adv->random_addr, &cp->bdaddr); in hci_cc_le_set_adv_set_random_addr()
1477 if (!bacmp(&hdev->rpa, &cp->bdaddr)) { in hci_cc_le_set_adv_set_random_addr()
1478 adv->rpa_expired = false; in hci_cc_le_set_adv_set_random_addr()
1479 queue_delayed_work(hdev->workqueue, in hci_cc_le_set_adv_set_random_addr()
1480 &adv->rpa_expired_cb, in hci_cc_le_set_adv_set_random_addr()
1481 secs_to_jiffies(hdev->rpa_timeout)); in hci_cc_le_set_adv_set_random_addr()
1487 return rp->status; in hci_cc_le_set_adv_set_random_addr()
1493 struct hci_ev_status *rp = data; in hci_cc_le_remove_adv_set() local
1497 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_remove_adv_set()
1499 if (rp->status) in hci_cc_le_remove_adv_set()
1500 return rp->status; in hci_cc_le_remove_adv_set()
1504 return rp->status; in hci_cc_le_remove_adv_set()
1510 mgmt_advertising_removed(hci_skb_sk(hdev->sent_cmd), hdev, in hci_cc_le_remove_adv_set()
1515 return rp->status; in hci_cc_le_remove_adv_set()
1521 struct hci_ev_status *rp = data; in hci_cc_le_clear_adv_sets() local
1525 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_clear_adv_sets()
1527 if (rp->status) in hci_cc_le_clear_adv_sets()
1528 return rp->status; in hci_cc_le_clear_adv_sets()
1531 return rp->status; in hci_cc_le_clear_adv_sets()
1535 list_for_each_entry_safe(adv, n, &hdev->adv_instances, list) { in hci_cc_le_clear_adv_sets()
1536 u8 instance = adv->instance; in hci_cc_le_clear_adv_sets()
1540 mgmt_advertising_removed(hci_skb_sk(hdev->sent_cmd), in hci_cc_le_clear_adv_sets()
1546 return rp->status; in hci_cc_le_clear_adv_sets()
1552 struct hci_rp_le_read_transmit_power *rp = data; in hci_cc_le_read_transmit_power() local
1554 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_read_transmit_power()
1556 if (rp->status) in hci_cc_le_read_transmit_power()
1557 return rp->status; in hci_cc_le_read_transmit_power()
1559 hdev->min_le_tx_power = rp->min_le_tx_power; in hci_cc_le_read_transmit_power()
1560 hdev->max_le_tx_power = rp->max_le_tx_power; in hci_cc_le_read_transmit_power()
1562 return rp->status; in hci_cc_le_read_transmit_power()
1568 struct hci_ev_status *rp = data; in hci_cc_le_set_privacy_mode() local
1572 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_privacy_mode()
1574 if (rp->status) in hci_cc_le_set_privacy_mode()
1575 return rp->status; in hci_cc_le_set_privacy_mode()
1579 return rp->status; in hci_cc_le_set_privacy_mode()
1583 params = hci_conn_params_lookup(hdev, &cp->bdaddr, cp->bdaddr_type); in hci_cc_le_set_privacy_mode()
1585 WRITE_ONCE(params->privacy_mode, cp->mode); in hci_cc_le_set_privacy_mode()
1589 return rp->status; in hci_cc_le_set_privacy_mode()
1595 struct hci_ev_status *rp = data; in hci_cc_le_set_adv_enable() local
1598 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_adv_enable()
1600 if (rp->status) in hci_cc_le_set_adv_enable()
1601 return rp->status; in hci_cc_le_set_adv_enable()
1605 return rp->status; in hci_cc_le_set_adv_enable()
1619 queue_delayed_work(hdev->workqueue, in hci_cc_le_set_adv_enable()
1620 &conn->le_conn_timeout, in hci_cc_le_set_adv_enable()
1621 conn->conn_timeout); in hci_cc_le_set_adv_enable()
1628 return rp->status; in hci_cc_le_set_adv_enable()
1637 struct hci_ev_status *rp = data; in hci_cc_le_set_ext_adv_enable() local
1639 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_ext_adv_enable()
1641 if (rp->status) in hci_cc_le_set_ext_adv_enable()
1642 return rp->status; in hci_cc_le_set_ext_adv_enable()
1646 return rp->status; in hci_cc_le_set_ext_adv_enable()
1648 set = (void *)cp->data; in hci_cc_le_set_ext_adv_enable()
1652 if (cp->num_of_sets) in hci_cc_le_set_ext_adv_enable()
1653 adv = hci_find_adv_instance(hdev, set->handle); in hci_cc_le_set_ext_adv_enable()
1655 if (cp->enable) { in hci_cc_le_set_ext_adv_enable()
1660 if (adv && !adv->periodic) in hci_cc_le_set_ext_adv_enable()
1661 adv->enabled = true; in hci_cc_le_set_ext_adv_enable()
1665 queue_delayed_work(hdev->workqueue, in hci_cc_le_set_ext_adv_enable()
1666 &conn->le_conn_timeout, in hci_cc_le_set_ext_adv_enable()
1667 conn->conn_timeout); in hci_cc_le_set_ext_adv_enable()
1669 if (cp->num_of_sets) { in hci_cc_le_set_ext_adv_enable()
1671 adv->enabled = false; in hci_cc_le_set_ext_adv_enable()
1676 list_for_each_entry_safe(adv, n, &hdev->adv_instances, in hci_cc_le_set_ext_adv_enable()
1678 if (adv->enabled) in hci_cc_le_set_ext_adv_enable()
1683 list_for_each_entry_safe(adv, n, &hdev->adv_instances, in hci_cc_le_set_ext_adv_enable()
1685 adv->enabled = false; in hci_cc_le_set_ext_adv_enable()
1693 return rp->status; in hci_cc_le_set_ext_adv_enable()
1700 struct hci_ev_status *rp = data; in hci_cc_le_set_scan_param() local
1702 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_scan_param()
1704 if (rp->status) in hci_cc_le_set_scan_param()
1705 return rp->status; in hci_cc_le_set_scan_param()
1709 return rp->status; in hci_cc_le_set_scan_param()
1713 hdev->le_scan_type = cp->type; in hci_cc_le_set_scan_param()
1717 return rp->status; in hci_cc_le_set_scan_param()
1724 struct hci_ev_status *rp = data; in hci_cc_le_set_ext_scan_param() local
1727 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_ext_scan_param()
1729 if (rp->status) in hci_cc_le_set_ext_scan_param()
1730 return rp->status; in hci_cc_le_set_ext_scan_param()
1734 return rp->status; in hci_cc_le_set_ext_scan_param()
1736 phy_param = (void *)cp->data; in hci_cc_le_set_ext_scan_param()
1740 hdev->le_scan_type = phy_param->type; in hci_cc_le_set_ext_scan_param()
1744 return rp->status; in hci_cc_le_set_ext_scan_param()
1749 struct discovery_state *d = &hdev->discovery; in has_pending_adv_report()
1751 return bacmp(&d->last_adv_addr, BDADDR_ANY); in has_pending_adv_report()
1756 struct discovery_state *d = &hdev->discovery; in clear_pending_adv_report()
1758 bacpy(&d->last_adv_addr, BDADDR_ANY); in clear_pending_adv_report()
1759 d->last_adv_data_len = 0; in clear_pending_adv_report()
1766 struct discovery_state *d = &hdev->discovery; in store_pending_adv_report()
1771 bacpy(&d->last_adv_addr, bdaddr); in store_pending_adv_report()
1772 d->last_adv_addr_type = bdaddr_type; in store_pending_adv_report()
1773 d->last_adv_rssi = rssi; in store_pending_adv_report()
1774 d->last_adv_flags = flags; in store_pending_adv_report()
1775 memcpy(d->last_adv_data, data, len); in store_pending_adv_report()
1776 d->last_adv_data_len = len; in store_pending_adv_report()
1786 if (hdev->le_scan_type == LE_SCAN_ACTIVE) in le_set_scan_enable_complete()
1798 struct discovery_state *d = &hdev->discovery; in le_set_scan_enable_complete()
1800 mgmt_device_found(hdev, &d->last_adv_addr, LE_LINK, in le_set_scan_enable_complete()
1801 d->last_adv_addr_type, NULL, in le_set_scan_enable_complete()
1802 d->last_adv_rssi, d->last_adv_flags, in le_set_scan_enable_complete()
1803 d->last_adv_data, in le_set_scan_enable_complete()
1804 d->last_adv_data_len, NULL, 0, 0); in le_set_scan_enable_complete()
1810 cancel_delayed_work(&hdev->le_scan_disable); in le_set_scan_enable_complete()
1821 hdev->discovery.state == DISCOVERY_FINDING) in le_set_scan_enable_complete()
1822 queue_work(hdev->workqueue, &hdev->reenable_adv_work); in le_set_scan_enable_complete()
1839 struct hci_ev_status *rp = data; in hci_cc_le_set_scan_enable() local
1841 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_scan_enable()
1843 if (rp->status) in hci_cc_le_set_scan_enable()
1844 return rp->status; in hci_cc_le_set_scan_enable()
1848 return rp->status; in hci_cc_le_set_scan_enable()
1850 le_set_scan_enable_complete(hdev, cp->enable); in hci_cc_le_set_scan_enable()
1852 return rp->status; in hci_cc_le_set_scan_enable()
1859 struct hci_ev_status *rp = data; in hci_cc_le_set_ext_scan_enable() local
1861 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_ext_scan_enable()
1863 if (rp->status) in hci_cc_le_set_ext_scan_enable()
1864 return rp->status; in hci_cc_le_set_ext_scan_enable()
1868 return rp->status; in hci_cc_le_set_ext_scan_enable()
1870 le_set_scan_enable_complete(hdev, cp->enable); in hci_cc_le_set_ext_scan_enable()
1872 return rp->status; in hci_cc_le_set_ext_scan_enable()
1878 struct hci_rp_le_read_num_supported_adv_sets *rp = data; in hci_cc_le_read_num_adv_sets() local
1880 bt_dev_dbg(hdev, "status 0x%2.2x No of Adv sets %u", rp->status, in hci_cc_le_read_num_adv_sets()
1881 rp->num_of_sets); in hci_cc_le_read_num_adv_sets()
1883 if (rp->status) in hci_cc_le_read_num_adv_sets()
1884 return rp->status; in hci_cc_le_read_num_adv_sets()
1886 hdev->le_num_of_adv_sets = rp->num_of_sets; in hci_cc_le_read_num_adv_sets()
1888 return rp->status; in hci_cc_le_read_num_adv_sets()
1894 struct hci_rp_le_read_accept_list_size *rp = data; in hci_cc_le_read_accept_list_size() local
1896 bt_dev_dbg(hdev, "status 0x%2.2x size %u", rp->status, rp->size); in hci_cc_le_read_accept_list_size()
1898 if (rp->status) in hci_cc_le_read_accept_list_size()
1899 return rp->status; in hci_cc_le_read_accept_list_size()
1901 hdev->le_accept_list_size = rp->size; in hci_cc_le_read_accept_list_size()
1903 return rp->status; in hci_cc_le_read_accept_list_size()
1909 struct hci_ev_status *rp = data; in hci_cc_le_clear_accept_list() local
1911 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_clear_accept_list()
1913 if (rp->status) in hci_cc_le_clear_accept_list()
1914 return rp->status; in hci_cc_le_clear_accept_list()
1917 hci_bdaddr_list_clear(&hdev->le_accept_list); in hci_cc_le_clear_accept_list()
1920 return rp->status; in hci_cc_le_clear_accept_list()
1927 struct hci_ev_status *rp = data; in hci_cc_le_add_to_accept_list() local
1929 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_add_to_accept_list()
1931 if (rp->status) in hci_cc_le_add_to_accept_list()
1932 return rp->status; in hci_cc_le_add_to_accept_list()
1936 return rp->status; in hci_cc_le_add_to_accept_list()
1939 hci_bdaddr_list_add(&hdev->le_accept_list, &sent->bdaddr, in hci_cc_le_add_to_accept_list()
1940 sent->bdaddr_type); in hci_cc_le_add_to_accept_list()
1943 return rp->status; in hci_cc_le_add_to_accept_list()
1950 struct hci_ev_status *rp = data; in hci_cc_le_del_from_accept_list() local
1952 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_del_from_accept_list()
1954 if (rp->status) in hci_cc_le_del_from_accept_list()
1955 return rp->status; in hci_cc_le_del_from_accept_list()
1959 return rp->status; in hci_cc_le_del_from_accept_list()
1962 hci_bdaddr_list_del(&hdev->le_accept_list, &sent->bdaddr, in hci_cc_le_del_from_accept_list()
1963 sent->bdaddr_type); in hci_cc_le_del_from_accept_list()
1966 return rp->status; in hci_cc_le_del_from_accept_list()
1972 struct hci_rp_le_read_supported_states *rp = data; in hci_cc_le_read_supported_states() local
1974 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_read_supported_states()
1976 if (rp->status) in hci_cc_le_read_supported_states()
1977 return rp->status; in hci_cc_le_read_supported_states()
1979 memcpy(hdev->le_states, rp->le_states, 8); in hci_cc_le_read_supported_states()
1981 return rp->status; in hci_cc_le_read_supported_states()
1987 struct hci_rp_le_read_def_data_len *rp = data; in hci_cc_le_read_def_data_len() local
1989 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_read_def_data_len()
1991 if (rp->status) in hci_cc_le_read_def_data_len()
1992 return rp->status; in hci_cc_le_read_def_data_len()
1994 hdev->le_def_tx_len = le16_to_cpu(rp->tx_len); in hci_cc_le_read_def_data_len()
1995 hdev->le_def_tx_time = le16_to_cpu(rp->tx_time); in hci_cc_le_read_def_data_len()
1997 return rp->status; in hci_cc_le_read_def_data_len()
2004 struct hci_ev_status *rp = data; in hci_cc_le_write_def_data_len() local
2006 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_write_def_data_len()
2008 if (rp->status) in hci_cc_le_write_def_data_len()
2009 return rp->status; in hci_cc_le_write_def_data_len()
2013 return rp->status; in hci_cc_le_write_def_data_len()
2015 hdev->le_def_tx_len = le16_to_cpu(sent->tx_len); in hci_cc_le_write_def_data_len()
2016 hdev->le_def_tx_time = le16_to_cpu(sent->tx_time); in hci_cc_le_write_def_data_len()
2018 return rp->status; in hci_cc_le_write_def_data_len()
2025 struct hci_ev_status *rp = data; in hci_cc_le_add_to_resolv_list() local
2027 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_add_to_resolv_list()
2029 if (rp->status) in hci_cc_le_add_to_resolv_list()
2030 return rp->status; in hci_cc_le_add_to_resolv_list()
2034 return rp->status; in hci_cc_le_add_to_resolv_list()
2037 hci_bdaddr_list_add_with_irk(&hdev->le_resolv_list, &sent->bdaddr, in hci_cc_le_add_to_resolv_list()
2038 sent->bdaddr_type, sent->peer_irk, in hci_cc_le_add_to_resolv_list()
2039 sent->local_irk); in hci_cc_le_add_to_resolv_list()
2042 return rp->status; in hci_cc_le_add_to_resolv_list()
2049 struct hci_ev_status *rp = data; in hci_cc_le_del_from_resolv_list() local
2051 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_del_from_resolv_list()
2053 if (rp->status) in hci_cc_le_del_from_resolv_list()
2054 return rp->status; in hci_cc_le_del_from_resolv_list()
2058 return rp->status; in hci_cc_le_del_from_resolv_list()
2061 hci_bdaddr_list_del_with_irk(&hdev->le_resolv_list, &sent->bdaddr, in hci_cc_le_del_from_resolv_list()
2062 sent->bdaddr_type); in hci_cc_le_del_from_resolv_list()
2065 return rp->status; in hci_cc_le_del_from_resolv_list()
2071 struct hci_ev_status *rp = data; in hci_cc_le_clear_resolv_list() local
2073 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_clear_resolv_list()
2075 if (rp->status) in hci_cc_le_clear_resolv_list()
2076 return rp->status; in hci_cc_le_clear_resolv_list()
2079 hci_bdaddr_list_clear(&hdev->le_resolv_list); in hci_cc_le_clear_resolv_list()
2082 return rp->status; in hci_cc_le_clear_resolv_list()
2088 struct hci_rp_le_read_resolv_list_size *rp = data; in hci_cc_le_read_resolv_list_size() local
2090 bt_dev_dbg(hdev, "status 0x%2.2x size %u", rp->status, rp->size); in hci_cc_le_read_resolv_list_size()
2092 if (rp->status) in hci_cc_le_read_resolv_list_size()
2093 return rp->status; in hci_cc_le_read_resolv_list_size()
2095 hdev->le_resolv_list_size = rp->size; in hci_cc_le_read_resolv_list_size()
2097 return rp->status; in hci_cc_le_read_resolv_list_size()
2103 struct hci_ev_status *rp = data; in hci_cc_le_set_addr_resolution_enable() local
2106 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_addr_resolution_enable()
2108 if (rp->status) in hci_cc_le_set_addr_resolution_enable()
2109 return rp->status; in hci_cc_le_set_addr_resolution_enable()
2113 return rp->status; in hci_cc_le_set_addr_resolution_enable()
2124 return rp->status; in hci_cc_le_set_addr_resolution_enable()
2130 struct hci_rp_le_read_max_data_len *rp = data; in hci_cc_le_read_max_data_len() local
2132 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_read_max_data_len()
2134 if (rp->status) in hci_cc_le_read_max_data_len()
2135 return rp->status; in hci_cc_le_read_max_data_len()
2137 hdev->le_max_tx_len = le16_to_cpu(rp->tx_len); in hci_cc_le_read_max_data_len()
2138 hdev->le_max_tx_time = le16_to_cpu(rp->tx_time); in hci_cc_le_read_max_data_len()
2139 hdev->le_max_rx_len = le16_to_cpu(rp->rx_len); in hci_cc_le_read_max_data_len()
2140 hdev->le_max_rx_time = le16_to_cpu(rp->rx_time); in hci_cc_le_read_max_data_len()
2142 return rp->status; in hci_cc_le_read_max_data_len()
2149 struct hci_ev_status *rp = data; in hci_cc_write_le_host_supported() local
2151 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_le_host_supported()
2153 if (rp->status) in hci_cc_write_le_host_supported()
2154 return rp->status; in hci_cc_write_le_host_supported()
2158 return rp->status; in hci_cc_write_le_host_supported()
2162 if (sent->le) { in hci_cc_write_le_host_supported()
2163 hdev->features[1][0] |= LMP_HOST_LE; in hci_cc_write_le_host_supported()
2166 hdev->features[1][0] &= ~LMP_HOST_LE; in hci_cc_write_le_host_supported()
2171 if (sent->simul) in hci_cc_write_le_host_supported()
2172 hdev->features[1][0] |= LMP_HOST_LE_BREDR; in hci_cc_write_le_host_supported()
2174 hdev->features[1][0] &= ~LMP_HOST_LE_BREDR; in hci_cc_write_le_host_supported()
2178 return rp->status; in hci_cc_write_le_host_supported()
2185 struct hci_ev_status *rp = data; in hci_cc_set_adv_param() local
2187 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_set_adv_param()
2189 if (rp->status) in hci_cc_set_adv_param()
2190 return rp->status; in hci_cc_set_adv_param()
2194 return rp->status; in hci_cc_set_adv_param()
2197 hdev->adv_addr_type = cp->own_address_type; in hci_cc_set_adv_param()
2200 return rp->status; in hci_cc_set_adv_param()
2206 struct hci_rp_le_set_ext_adv_params *rp = data; in hci_cc_set_ext_adv_param() local
2210 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_set_ext_adv_param()
2212 if (rp->status) in hci_cc_set_ext_adv_param()
2213 return rp->status; in hci_cc_set_ext_adv_param()
2217 return rp->status; in hci_cc_set_ext_adv_param()
2220 hdev->adv_addr_type = cp->own_addr_type; in hci_cc_set_ext_adv_param()
2221 if (!cp->handle) { in hci_cc_set_ext_adv_param()
2223 hdev->adv_tx_power = rp->tx_power; in hci_cc_set_ext_adv_param()
2225 adv_instance = hci_find_adv_instance(hdev, cp->handle); in hci_cc_set_ext_adv_param()
2227 adv_instance->tx_power = rp->tx_power; in hci_cc_set_ext_adv_param()
2230 hci_update_adv_data(hdev, cp->handle); in hci_cc_set_ext_adv_param()
2234 return rp->status; in hci_cc_set_ext_adv_param()
2240 struct hci_rp_read_rssi *rp = data; in hci_cc_read_rssi() local
2243 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_rssi()
2245 if (rp->status) in hci_cc_read_rssi()
2246 return rp->status; in hci_cc_read_rssi()
2250 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_rssi()
2252 conn->rssi = rp->rssi; in hci_cc_read_rssi()
2256 return rp->status; in hci_cc_read_rssi()
2263 struct hci_rp_read_tx_power *rp = data; in hci_cc_read_tx_power() local
2266 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_tx_power()
2268 if (rp->status) in hci_cc_read_tx_power()
2269 return rp->status; in hci_cc_read_tx_power()
2273 return rp->status; in hci_cc_read_tx_power()
2277 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_tx_power()
2281 switch (sent->type) { in hci_cc_read_tx_power()
2283 conn->tx_power = rp->tx_power; in hci_cc_read_tx_power()
2286 conn->max_tx_power = rp->tx_power; in hci_cc_read_tx_power()
2292 return rp->status; in hci_cc_read_tx_power()
2298 struct hci_ev_status *rp = data; in hci_cc_write_ssp_debug_mode() local
2301 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_ssp_debug_mode()
2303 if (rp->status) in hci_cc_write_ssp_debug_mode()
2304 return rp->status; in hci_cc_write_ssp_debug_mode()
2308 hdev->ssp_debug_mode = *mode; in hci_cc_write_ssp_debug_mode()
2310 return rp->status; in hci_cc_write_ssp_debug_mode()
2315 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_inquiry()
2323 set_bit(HCI_INQUIRY, &hdev->flags); in hci_cs_inquiry()
2331 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_create_conn()
2339 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cs_create_conn()
2341 bt_dev_dbg(hdev, "bdaddr %pMR hcon %p", &cp->bdaddr, conn); in hci_cs_create_conn()
2344 if (conn && conn->state == BT_CONNECT) { in hci_cs_create_conn()
2345 if (status != 0x0c || conn->attempt > 2) { in hci_cs_create_conn()
2346 conn->state = BT_CLOSED; in hci_cs_create_conn()
2350 conn->state = BT_CONNECT2; in hci_cs_create_conn()
2354 conn = hci_conn_add_unset(hdev, ACL_LINK, &cp->bdaddr, in hci_cs_create_conn()
2371 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_add_sco()
2380 handle = __le16_to_cpu(cp->handle); in hci_cs_add_sco()
2382 bt_dev_dbg(hdev, "handle 0x%4.4x", handle); in hci_cs_add_sco()
2388 link = list_first_entry_or_null(&acl->link_list, in hci_cs_add_sco()
2390 if (link && link->conn) { in hci_cs_add_sco()
2391 link->conn->state = BT_CLOSED; in hci_cs_add_sco()
2393 hci_connect_cfm(link->conn, status); in hci_cs_add_sco()
2394 hci_conn_del(link->conn); in hci_cs_add_sco()
2406 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_auth_requested()
2417 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_auth_requested()
2419 if (conn->state == BT_CONFIG) { in hci_cs_auth_requested()
2433 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_set_conn_encrypt()
2444 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_set_conn_encrypt()
2446 if (conn->state == BT_CONFIG) { in hci_cs_set_conn_encrypt()
2458 if (conn->state != BT_CONFIG || !conn->out) in hci_outgoing_auth_needed()
2461 if (conn->pending_sec_level == BT_SECURITY_SDP) in hci_outgoing_auth_needed()
2464 /* Only request authentication for SSP connections or non-SSP in hci_outgoing_auth_needed()
2468 if (!hci_conn_ssp_enabled(conn) && !(conn->auth_type & 0x01) && in hci_outgoing_auth_needed()
2469 conn->pending_sec_level != BT_SECURITY_FIPS && in hci_outgoing_auth_needed()
2470 conn->pending_sec_level != BT_SECURITY_HIGH && in hci_outgoing_auth_needed()
2471 conn->pending_sec_level != BT_SECURITY_MEDIUM) in hci_outgoing_auth_needed()
2484 bacpy(&cp.bdaddr, &e->data.bdaddr); in hci_resolve_name()
2485 cp.pscan_rep_mode = e->data.pscan_rep_mode; in hci_resolve_name()
2486 cp.pscan_mode = e->data.pscan_mode; in hci_resolve_name()
2487 cp.clock_offset = e->data.clock_offset; in hci_resolve_name()
2494 struct discovery_state *discov = &hdev->discovery; in hci_resolve_next_name()
2497 if (list_empty(&discov->resolve)) in hci_resolve_next_name()
2501 if (time_after(jiffies, discov->name_resolve_timeout)) { in hci_resolve_next_name()
2511 e->name_state = NAME_PENDING; in hci_resolve_next_name()
2521 struct discovery_state *discov = &hdev->discovery; in hci_check_pending_name()
2530 (conn->state == BT_CONFIG || conn->state == BT_CONNECTED) && in hci_check_pending_name()
2531 !test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) in hci_check_pending_name()
2534 if (discov->state == DISCOVERY_STOPPED) in hci_check_pending_name()
2537 if (discov->state == DISCOVERY_STOPPING) in hci_check_pending_name()
2540 if (discov->state != DISCOVERY_RESOLVING) in hci_check_pending_name()
2551 list_del(&e->list); in hci_check_pending_name()
2553 e->name_state = name ? NAME_KNOWN : NAME_NOT_KNOWN; in hci_check_pending_name()
2554 mgmt_remote_name(hdev, bdaddr, ACL_LINK, 0x00, e->data.rssi, in hci_check_pending_name()
2569 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_remote_name_req()
2582 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cs_remote_name_req()
2585 hci_check_pending_name(hdev, conn, &cp->bdaddr, NULL, 0); in hci_cs_remote_name_req()
2593 if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->flags)) { in hci_cs_remote_name_req()
2596 set_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags); in hci_cs_remote_name_req()
2598 auth_cp.handle = __cpu_to_le16(conn->handle); in hci_cs_remote_name_req()
2612 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_read_remote_features()
2623 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_read_remote_features()
2625 if (conn->state == BT_CONFIG) { in hci_cs_read_remote_features()
2639 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_read_remote_ext_features()
2650 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_read_remote_ext_features()
2652 if (conn->state == BT_CONFIG) { in hci_cs_read_remote_ext_features()
2667 bt_dev_dbg(hdev, "handle 0x%4.4x status 0x%2.2x", handle, status); in hci_setup_sync_conn_status()
2673 link = list_first_entry_or_null(&acl->link_list, in hci_setup_sync_conn_status()
2675 if (link && link->conn) { in hci_setup_sync_conn_status()
2676 link->conn->state = BT_CLOSED; in hci_setup_sync_conn_status()
2678 hci_connect_cfm(link->conn, status); in hci_setup_sync_conn_status()
2679 hci_conn_del(link->conn); in hci_setup_sync_conn_status()
2690 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_setup_sync_conn()
2699 hci_setup_sync_conn_status(hdev, __le16_to_cpu(cp->handle), status); in hci_cs_setup_sync_conn()
2706 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_enhanced_setup_sync_conn()
2715 hci_setup_sync_conn_status(hdev, __le16_to_cpu(cp->handle), status); in hci_cs_enhanced_setup_sync_conn()
2723 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_sniff_mode()
2734 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_sniff_mode()
2736 clear_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->flags); in hci_cs_sniff_mode()
2738 if (test_and_clear_bit(HCI_CONN_SCO_SETUP_PEND, &conn->flags)) in hci_cs_sniff_mode()
2750 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_exit_sniff_mode()
2761 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_exit_sniff_mode()
2763 clear_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->flags); in hci_cs_exit_sniff_mode()
2765 if (test_and_clear_bit(HCI_CONN_SCO_SETUP_PEND, &conn->flags)) in hci_cs_exit_sniff_mode()
2779 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_disconnect()
2784 if (!status && !hdev->suspended) in hci_cs_disconnect()
2793 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_disconnect()
2798 mgmt_disconnect_failed(hdev, &conn->dst, conn->type, in hci_cs_disconnect()
2799 conn->dst_type, status); in hci_cs_disconnect()
2801 if (conn->type == LE_LINK && conn->role == HCI_ROLE_SLAVE) { in hci_cs_disconnect()
2802 hdev->cur_adv_instance = conn->adv_instance; in hci_cs_disconnect()
2812 mgmt_conn = test_and_clear_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags); in hci_cs_disconnect()
2814 if (conn->type == ACL_LINK) { in hci_cs_disconnect()
2815 if (test_and_clear_bit(HCI_CONN_FLUSH_KEY, &conn->flags)) in hci_cs_disconnect()
2816 hci_remove_link_key(hdev, &conn->dst); in hci_cs_disconnect()
2819 params = hci_conn_params_lookup(hdev, &conn->dst, conn->dst_type); in hci_cs_disconnect()
2821 switch (params->auto_connect) { in hci_cs_disconnect()
2823 if (cp->reason != HCI_ERROR_CONNECTION_TIMEOUT) in hci_cs_disconnect()
2830 hci_pend_le_list_add(params, &hdev->pend_le_conns); in hci_cs_disconnect()
2838 mgmt_device_disconnected(hdev, &conn->dst, conn->type, conn->dst_type, in hci_cs_disconnect()
2839 cp->reason, mgmt_conn); in hci_cs_disconnect()
2841 hci_disconn_cfm(conn, cp->reason); in hci_cs_disconnect()
2846 * Hence, we need to do some basic cleanup here and re-enable in hci_cs_disconnect()
2893 conn->init_addr_type = own_address_type; in cs_le_create_conn()
2895 bacpy(&conn->init_addr, &hdev->random_addr); in cs_le_create_conn()
2897 bacpy(&conn->init_addr, &hdev->bdaddr); in cs_le_create_conn()
2899 conn->resp_addr_type = peer_addr_type; in cs_le_create_conn()
2900 bacpy(&conn->resp_addr, peer_addr); in cs_le_create_conn()
2907 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_le_create_conn()
2922 cs_le_create_conn(hdev, &cp->peer_addr, cp->peer_addr_type, in hci_cs_le_create_conn()
2923 cp->own_address_type, cp->filter_policy); in hci_cs_le_create_conn()
2932 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_le_ext_create_conn()
2947 cs_le_create_conn(hdev, &cp->peer_addr, cp->peer_addr_type, in hci_cs_le_ext_create_conn()
2948 cp->own_addr_type, cp->filter_policy); in hci_cs_le_ext_create_conn()
2958 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_le_read_remote_features()
2969 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_le_read_remote_features()
2971 if (conn->state == BT_CONFIG) { in hci_cs_le_read_remote_features()
2985 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_le_start_enc()
2996 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_le_start_enc()
3000 if (conn->state != BT_CONNECTED) in hci_cs_le_start_enc()
3015 BT_DBG("%s status 0x%2.2x", hdev->name, status); in hci_cs_switch_role()
3026 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cs_switch_role()
3028 clear_bit(HCI_CONN_RSWITCH_PEND, &conn->flags); in hci_cs_switch_role()
3037 struct discovery_state *discov = &hdev->discovery; in hci_inquiry_complete_evt()
3040 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_inquiry_complete_evt()
3044 if (!test_and_clear_bit(HCI_INQUIRY, &hdev->flags)) in hci_inquiry_complete_evt()
3048 wake_up_bit(&hdev->flags, HCI_INQUIRY); in hci_inquiry_complete_evt()
3055 if (discov->state != DISCOVERY_FINDING) in hci_inquiry_complete_evt()
3058 if (list_empty(&discov->resolve)) { in hci_inquiry_complete_evt()
3067 !test_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks)) in hci_inquiry_complete_evt()
3074 e->name_state = NAME_PENDING; in hci_inquiry_complete_evt()
3076 discov->name_resolve_timeout = jiffies + NAME_RESOLVE_DURATION; in hci_inquiry_complete_evt()
3086 !test_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks)) in hci_inquiry_complete_evt()
3102 flex_array_size(ev, info, ev->num))) in hci_inquiry_result_evt()
3105 bt_dev_dbg(hdev, "num %d", ev->num); in hci_inquiry_result_evt()
3107 if (!ev->num) in hci_inquiry_result_evt()
3115 for (i = 0; i < ev->num; i++) { in hci_inquiry_result_evt()
3116 struct inquiry_info *info = &ev->info[i]; in hci_inquiry_result_evt()
3119 bacpy(&data.bdaddr, &info->bdaddr); in hci_inquiry_result_evt()
3120 data.pscan_rep_mode = info->pscan_rep_mode; in hci_inquiry_result_evt()
3121 data.pscan_period_mode = info->pscan_period_mode; in hci_inquiry_result_evt()
3122 data.pscan_mode = info->pscan_mode; in hci_inquiry_result_evt()
3123 memcpy(data.dev_class, info->dev_class, 3); in hci_inquiry_result_evt()
3124 data.clock_offset = info->clock_offset; in hci_inquiry_result_evt()
3130 mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, in hci_inquiry_result_evt()
3131 info->dev_class, HCI_RSSI_INVALID, in hci_inquiry_result_evt()
3143 u8 status = ev->status; in hci_conn_complete_evt()
3145 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_conn_complete_evt()
3149 conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, &ev->bdaddr); in hci_conn_complete_evt()
3154 if (ev->status) in hci_conn_complete_evt()
3157 /* Connection may not exist if auto-connected. Check the bredr in hci_conn_complete_evt()
3162 * Auto-connect will only occur if the event filter is in hci_conn_complete_evt()
3166 if (ev->link_type == ACL_LINK && in hci_conn_complete_evt()
3167 hci_bdaddr_list_lookup_with_flags(&hdev->accept_list, in hci_conn_complete_evt()
3168 &ev->bdaddr, in hci_conn_complete_evt()
3170 conn = hci_conn_add_unset(hdev, ev->link_type, in hci_conn_complete_evt()
3171 &ev->bdaddr, HCI_ROLE_SLAVE); in hci_conn_complete_evt()
3177 if (ev->link_type != SCO_LINK) in hci_conn_complete_evt()
3181 &ev->bdaddr); in hci_conn_complete_evt()
3185 conn->type = SCO_LINK; in hci_conn_complete_evt()
3195 if (!HCI_CONN_HANDLE_UNSET(conn->handle)) { in hci_conn_complete_evt()
3201 status = hci_conn_set_handle(conn, __le16_to_cpu(ev->handle)); in hci_conn_complete_evt()
3205 if (conn->type == ACL_LINK) { in hci_conn_complete_evt()
3206 conn->state = BT_CONFIG; in hci_conn_complete_evt()
3209 if (!conn->out && !hci_conn_ssp_enabled(conn) && in hci_conn_complete_evt()
3210 !hci_find_link_key(hdev, &ev->bdaddr)) in hci_conn_complete_evt()
3211 conn->disc_timeout = HCI_PAIRING_TIMEOUT; in hci_conn_complete_evt()
3213 conn->disc_timeout = HCI_DISCONN_TIMEOUT; in hci_conn_complete_evt()
3215 conn->state = BT_CONNECTED; in hci_conn_complete_evt()
3220 if (test_bit(HCI_AUTH, &hdev->flags)) in hci_conn_complete_evt()
3221 set_bit(HCI_CONN_AUTH, &conn->flags); in hci_conn_complete_evt()
3223 if (test_bit(HCI_ENCRYPT, &hdev->flags)) in hci_conn_complete_evt()
3224 set_bit(HCI_CONN_ENCRYPT, &conn->flags); in hci_conn_complete_evt()
3227 if (conn->type == ACL_LINK) { in hci_conn_complete_evt()
3229 cp.handle = ev->handle; in hci_conn_complete_evt()
3237 if (!conn->out && hdev->hci_ver < BLUETOOTH_VER_2_0) { in hci_conn_complete_evt()
3239 cp.handle = ev->handle; in hci_conn_complete_evt()
3240 cp.pkt_type = cpu_to_le16(conn->pkt_type); in hci_conn_complete_evt()
3246 if (conn->type == ACL_LINK) in hci_conn_complete_evt()
3247 hci_sco_setup(conn, ev->status); in hci_conn_complete_evt()
3252 } else if (ev->link_type == SCO_LINK) { in hci_conn_complete_evt()
3253 switch (conn->setting & SCO_AIRMODE_MASK) { in hci_conn_complete_evt()
3255 if (hdev->notify) in hci_conn_complete_evt()
3256 hdev->notify(hdev, HCI_NOTIFY_ENABLE_SCO_CVSD); in hci_conn_complete_evt()
3282 int mask = hdev->link_mode; in hci_conn_request_evt()
3287 bt_dev_dbg(hdev, "bdaddr %pMR type 0x%x", &ev->bdaddr, ev->link_type); in hci_conn_request_evt()
3290 * CVE-2020-26555 in hci_conn_request_evt()
3292 if (hdev && !bacmp(&hdev->bdaddr, &ev->bdaddr)) { in hci_conn_request_evt()
3294 &ev->bdaddr); in hci_conn_request_evt()
3295 hci_reject_conn(hdev, &ev->bdaddr); in hci_conn_request_evt()
3299 mask |= hci_proto_connect_ind(hdev, &ev->bdaddr, ev->link_type, in hci_conn_request_evt()
3303 hci_reject_conn(hdev, &ev->bdaddr); in hci_conn_request_evt()
3309 if (hci_bdaddr_list_lookup(&hdev->reject_list, &ev->bdaddr, in hci_conn_request_evt()
3311 hci_reject_conn(hdev, &ev->bdaddr); in hci_conn_request_evt()
3321 !hci_bdaddr_list_lookup_with_flags(&hdev->accept_list, &ev->bdaddr, in hci_conn_request_evt()
3323 hci_reject_conn(hdev, &ev->bdaddr); in hci_conn_request_evt()
3329 ie = hci_inquiry_cache_lookup(hdev, &ev->bdaddr); in hci_conn_request_evt()
3331 memcpy(ie->data.dev_class, ev->dev_class, 3); in hci_conn_request_evt()
3333 conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, in hci_conn_request_evt()
3334 &ev->bdaddr); in hci_conn_request_evt()
3336 conn = hci_conn_add_unset(hdev, ev->link_type, &ev->bdaddr, in hci_conn_request_evt()
3344 memcpy(conn->dev_class, ev->dev_class, 3); in hci_conn_request_evt()
3348 if (ev->link_type == ACL_LINK || in hci_conn_request_evt()
3351 conn->state = BT_CONNECT; in hci_conn_request_evt()
3353 bacpy(&cp.bdaddr, &ev->bdaddr); in hci_conn_request_evt()
3363 conn->state = BT_CONNECT; in hci_conn_request_evt()
3365 bacpy(&cp.bdaddr, &ev->bdaddr); in hci_conn_request_evt()
3366 cp.pkt_type = cpu_to_le16(conn->pkt_type); in hci_conn_request_evt()
3371 cp.content_format = cpu_to_le16(hdev->voice_setting); in hci_conn_request_evt()
3377 conn->state = BT_CONNECT2; in hci_conn_request_evt()
3411 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_disconn_complete_evt()
3415 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_disconn_complete_evt()
3419 if (ev->status) { in hci_disconn_complete_evt()
3420 mgmt_disconnect_failed(hdev, &conn->dst, conn->type, in hci_disconn_complete_evt()
3421 conn->dst_type, ev->status); in hci_disconn_complete_evt()
3425 conn->state = BT_CLOSED; in hci_disconn_complete_evt()
3427 mgmt_connected = test_and_clear_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags); in hci_disconn_complete_evt()
3429 if (test_bit(HCI_CONN_AUTH_FAILURE, &conn->flags)) in hci_disconn_complete_evt()
3432 reason = hci_to_mgmt_reason(ev->reason); in hci_disconn_complete_evt()
3434 mgmt_device_disconnected(hdev, &conn->dst, conn->type, conn->dst_type, in hci_disconn_complete_evt()
3437 if (conn->type == ACL_LINK) { in hci_disconn_complete_evt()
3438 if (test_and_clear_bit(HCI_CONN_FLUSH_KEY, &conn->flags)) in hci_disconn_complete_evt()
3439 hci_remove_link_key(hdev, &conn->dst); in hci_disconn_complete_evt()
3444 params = hci_conn_params_lookup(hdev, &conn->dst, conn->dst_type); in hci_disconn_complete_evt()
3446 switch (params->auto_connect) { in hci_disconn_complete_evt()
3448 if (ev->reason != HCI_ERROR_CONNECTION_TIMEOUT) in hci_disconn_complete_evt()
3455 hci_pend_le_list_add(params, &hdev->pend_le_conns); in hci_disconn_complete_evt()
3464 hci_disconn_cfm(conn, ev->reason); in hci_disconn_complete_evt()
3466 /* Re-enable advertising if necessary, since it might in hci_disconn_complete_evt()
3476 if (conn->type == LE_LINK && conn->role == HCI_ROLE_SLAVE) { in hci_disconn_complete_evt()
3477 hdev->cur_adv_instance = conn->adv_instance; in hci_disconn_complete_evt()
3493 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_auth_complete_evt()
3497 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_auth_complete_evt()
3501 if (!ev->status) { in hci_auth_complete_evt()
3502 clear_bit(HCI_CONN_AUTH_FAILURE, &conn->flags); in hci_auth_complete_evt()
3503 set_bit(HCI_CONN_AUTH, &conn->flags); in hci_auth_complete_evt()
3504 conn->sec_level = conn->pending_sec_level; in hci_auth_complete_evt()
3506 if (ev->status == HCI_ERROR_PIN_OR_KEY_MISSING) in hci_auth_complete_evt()
3507 set_bit(HCI_CONN_AUTH_FAILURE, &conn->flags); in hci_auth_complete_evt()
3509 mgmt_auth_failed(conn, ev->status); in hci_auth_complete_evt()
3512 clear_bit(HCI_CONN_AUTH_PEND, &conn->flags); in hci_auth_complete_evt()
3514 if (conn->state == BT_CONFIG) { in hci_auth_complete_evt()
3515 if (!ev->status && hci_conn_ssp_enabled(conn)) { in hci_auth_complete_evt()
3517 cp.handle = ev->handle; in hci_auth_complete_evt()
3522 conn->state = BT_CONNECTED; in hci_auth_complete_evt()
3523 hci_connect_cfm(conn, ev->status); in hci_auth_complete_evt()
3527 hci_auth_cfm(conn, ev->status); in hci_auth_complete_evt()
3530 conn->disc_timeout = HCI_DISCONN_TIMEOUT; in hci_auth_complete_evt()
3534 if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags)) { in hci_auth_complete_evt()
3535 if (!ev->status) { in hci_auth_complete_evt()
3537 cp.handle = ev->handle; in hci_auth_complete_evt()
3542 clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags); in hci_auth_complete_evt()
3543 hci_encrypt_cfm(conn, ev->status); in hci_auth_complete_evt()
3557 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_remote_name_evt()
3563 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_remote_name_evt()
3568 if (ev->status == 0) in hci_remote_name_evt()
3569 hci_check_pending_name(hdev, conn, &ev->bdaddr, ev->name, in hci_remote_name_evt()
3570 strnlen(ev->name, HCI_MAX_NAME_LENGTH)); in hci_remote_name_evt()
3572 hci_check_pending_name(hdev, conn, &ev->bdaddr, NULL, 0); in hci_remote_name_evt()
3581 if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->flags)) { in hci_remote_name_evt()
3584 set_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags); in hci_remote_name_evt()
3586 cp.handle = __cpu_to_le16(conn->handle); in hci_remote_name_evt()
3600 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_encrypt_change_evt()
3604 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_encrypt_change_evt()
3608 if (!ev->status) { in hci_encrypt_change_evt()
3609 if (ev->encrypt) { in hci_encrypt_change_evt()
3611 set_bit(HCI_CONN_AUTH, &conn->flags); in hci_encrypt_change_evt()
3612 set_bit(HCI_CONN_ENCRYPT, &conn->flags); in hci_encrypt_change_evt()
3613 conn->sec_level = conn->pending_sec_level; in hci_encrypt_change_evt()
3615 /* P-256 authentication key implies FIPS */ in hci_encrypt_change_evt()
3616 if (conn->key_type == HCI_LK_AUTH_COMBINATION_P256) in hci_encrypt_change_evt()
3617 set_bit(HCI_CONN_FIPS, &conn->flags); in hci_encrypt_change_evt()
3619 if ((conn->type == ACL_LINK && ev->encrypt == 0x02) || in hci_encrypt_change_evt()
3620 conn->type == LE_LINK) in hci_encrypt_change_evt()
3621 set_bit(HCI_CONN_AES_CCM, &conn->flags); in hci_encrypt_change_evt()
3623 clear_bit(HCI_CONN_ENCRYPT, &conn->flags); in hci_encrypt_change_evt()
3624 clear_bit(HCI_CONN_AES_CCM, &conn->flags); in hci_encrypt_change_evt()
3631 if (ev->status && conn->type == LE_LINK) { in hci_encrypt_change_evt()
3636 clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags); in hci_encrypt_change_evt()
3640 ev->status = HCI_ERROR_AUTH_FAILURE; in hci_encrypt_change_evt()
3642 if (ev->status && conn->state == BT_CONNECTED) { in hci_encrypt_change_evt()
3643 if (ev->status == HCI_ERROR_PIN_OR_KEY_MISSING) in hci_encrypt_change_evt()
3644 set_bit(HCI_CONN_AUTH_FAILURE, &conn->flags); in hci_encrypt_change_evt()
3649 hci_encrypt_cfm(conn, ev->status); in hci_encrypt_change_evt()
3656 if (!ev->status && ev->encrypt && conn->type == ACL_LINK) { in hci_encrypt_change_evt()
3663 if (!(hdev->commands[20] & 0x10)) { in hci_encrypt_change_evt()
3664 conn->enc_key_size = HCI_LINK_KEY_SIZE; in hci_encrypt_change_evt()
3668 cp.handle = cpu_to_le16(conn->handle); in hci_encrypt_change_evt()
3672 conn->enc_key_size = HCI_LINK_KEY_SIZE; in hci_encrypt_change_evt()
3684 * Ensure for AES-CCM encryption as well. in hci_encrypt_change_evt()
3686 if (test_bit(HCI_CONN_ENCRYPT, &conn->flags) && in hci_encrypt_change_evt()
3687 test_bit(HCI_CONN_AES_CCM, &conn->flags) && in hci_encrypt_change_evt()
3688 ((conn->type == ACL_LINK && lmp_ping_capable(hdev)) || in hci_encrypt_change_evt()
3689 (conn->type == LE_LINK && (hdev->le_features[0] & HCI_LE_PING)))) { in hci_encrypt_change_evt()
3692 cp.handle = cpu_to_le16(conn->handle); in hci_encrypt_change_evt()
3693 cp.timeout = cpu_to_le16(hdev->auth_payload_timeout); in hci_encrypt_change_evt()
3694 if (hci_send_cmd(conn->hdev, HCI_OP_WRITE_AUTH_PAYLOAD_TO, in hci_encrypt_change_evt()
3700 hci_encrypt_cfm(conn, ev->status); in hci_encrypt_change_evt()
3712 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_change_link_key_complete_evt()
3716 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_change_link_key_complete_evt()
3718 if (!ev->status) in hci_change_link_key_complete_evt()
3719 set_bit(HCI_CONN_SECURE, &conn->flags); in hci_change_link_key_complete_evt()
3721 clear_bit(HCI_CONN_AUTH_PEND, &conn->flags); in hci_change_link_key_complete_evt()
3723 hci_key_change_cfm(conn, ev->status); in hci_change_link_key_complete_evt()
3735 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_remote_features_evt()
3739 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_remote_features_evt()
3743 if (!ev->status) in hci_remote_features_evt()
3744 memcpy(conn->features[0], ev->features, 8); in hci_remote_features_evt()
3746 if (conn->state != BT_CONFIG) in hci_remote_features_evt()
3749 if (!ev->status && lmp_ext_feat_capable(hdev) && in hci_remote_features_evt()
3752 cp.handle = ev->handle; in hci_remote_features_evt()
3759 if (!ev->status && !test_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) { in hci_remote_features_evt()
3762 bacpy(&cp.bdaddr, &conn->dst); in hci_remote_features_evt()
3765 } else if (!test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) in hci_remote_features_evt()
3769 conn->state = BT_CONNECTED; in hci_remote_features_evt()
3770 hci_connect_cfm(conn, ev->status); in hci_remote_features_evt()
3780 cancel_delayed_work(&hdev->cmd_timer); in handle_cmd_cnt_and_timer()
3783 if (!test_bit(HCI_RESET, &hdev->flags)) { in handle_cmd_cnt_and_timer()
3785 cancel_delayed_work(&hdev->ncmd_timer); in handle_cmd_cnt_and_timer()
3786 atomic_set(&hdev->cmd_cnt, 1); in handle_cmd_cnt_and_timer()
3789 queue_delayed_work(hdev->workqueue, &hdev->ncmd_timer, in handle_cmd_cnt_and_timer()
3799 struct hci_rp_le_read_buffer_size_v2 *rp = data; in hci_cc_le_read_buffer_size_v2() local
3801 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_read_buffer_size_v2()
3803 if (rp->status) in hci_cc_le_read_buffer_size_v2()
3804 return rp->status; in hci_cc_le_read_buffer_size_v2()
3806 hdev->le_mtu = __le16_to_cpu(rp->acl_mtu); in hci_cc_le_read_buffer_size_v2()
3807 hdev->le_pkts = rp->acl_max_pkt; in hci_cc_le_read_buffer_size_v2()
3808 hdev->iso_mtu = __le16_to_cpu(rp->iso_mtu); in hci_cc_le_read_buffer_size_v2()
3809 hdev->iso_pkts = rp->iso_max_pkt; in hci_cc_le_read_buffer_size_v2()
3811 hdev->le_cnt = hdev->le_pkts; in hci_cc_le_read_buffer_size_v2()
3812 hdev->iso_cnt = hdev->iso_pkts; in hci_cc_le_read_buffer_size_v2()
3814 BT_DBG("%s acl mtu %d:%d iso mtu %d:%d", hdev->name, hdev->acl_mtu, in hci_cc_le_read_buffer_size_v2()
3815 hdev->acl_pkts, hdev->iso_mtu, hdev->iso_pkts); in hci_cc_le_read_buffer_size_v2()
3817 return rp->status; in hci_cc_le_read_buffer_size_v2()
3824 lockdep_assert_held(&hdev->lock); in hci_unbound_cis_failed()
3826 list_for_each_entry_safe(conn, tmp, &hdev->conn_hash.list, list) { in hci_unbound_cis_failed()
3827 if (conn->type != ISO_LINK || !bacmp(&conn->dst, BDADDR_ANY) || in hci_unbound_cis_failed()
3828 conn->state == BT_OPEN || conn->iso_qos.ucast.cig != cig) in hci_unbound_cis_failed()
3831 if (HCI_CONN_HANDLE_UNSET(conn->handle)) in hci_unbound_cis_failed()
3839 struct hci_rp_le_set_cig_params *rp = data; in hci_cc_le_set_cig_params() local
3842 u8 status = rp->status; in hci_cc_le_set_cig_params()
3846 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_cig_params()
3849 if (!rp->status && (!cp || rp->num_handles != cp->num_cis || in hci_cc_le_set_cig_params()
3850 rp->cig_id != cp->cig_id)) { in hci_cc_le_set_cig_params()
3859 * If the Status return parameter is non-zero, then the state of the CIG in hci_cc_le_set_cig_params()
3865 hci_unbound_cis_failed(hdev, rp->cig_id, status); in hci_cc_le_set_cig_params()
3876 for (i = 0; i < rp->num_handles; ++i) { in hci_cc_le_set_cig_params()
3877 conn = hci_conn_hash_lookup_cis(hdev, NULL, 0, rp->cig_id, in hci_cc_le_set_cig_params()
3878 cp->cis[i].cis_id); in hci_cc_le_set_cig_params()
3879 if (!conn || !bacmp(&conn->dst, BDADDR_ANY)) in hci_cc_le_set_cig_params()
3882 if (conn->state != BT_BOUND && conn->state != BT_CONNECT) in hci_cc_le_set_cig_params()
3885 if (hci_conn_set_handle(conn, __le16_to_cpu(rp->handle[i]))) in hci_cc_le_set_cig_params()
3888 if (conn->state == BT_CONNECT) in hci_cc_le_set_cig_params()
3898 return rp->status; in hci_cc_le_set_cig_params()
3904 struct hci_rp_le_setup_iso_path *rp = data; in hci_cc_le_setup_iso_path() local
3908 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_setup_iso_path()
3912 return rp->status; in hci_cc_le_setup_iso_path()
3916 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cc_le_setup_iso_path()
3920 if (rp->status) { in hci_cc_le_setup_iso_path()
3921 hci_connect_cfm(conn, rp->status); in hci_cc_le_setup_iso_path()
3926 switch (cp->direction) { in hci_cc_le_setup_iso_path()
3930 if (conn->iso_qos.ucast.out.sdu && !conn->iso_qos.ucast.in.sdu) in hci_cc_le_setup_iso_path()
3931 hci_connect_cfm(conn, rp->status); in hci_cc_le_setup_iso_path()
3935 /* Confirm connection since conn->iso_qos is always configured in hci_cc_le_setup_iso_path()
3938 hci_connect_cfm(conn, rp->status); in hci_cc_le_setup_iso_path()
3944 return rp->status; in hci_cc_le_setup_iso_path()
3949 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_le_create_big()
3955 struct hci_ev_status *rp = data; in hci_cc_set_per_adv_param() local
3958 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_set_per_adv_param()
3960 if (rp->status) in hci_cc_set_per_adv_param()
3961 return rp->status; in hci_cc_set_per_adv_param()
3965 return rp->status; in hci_cc_set_per_adv_param()
3968 return rp->status; in hci_cc_set_per_adv_param()
3974 struct hci_ev_status *rp = data; in hci_cc_le_set_per_adv_enable() local
3979 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_per_adv_enable()
3981 if (rp->status) in hci_cc_le_set_per_adv_enable()
3982 return rp->status; in hci_cc_le_set_per_adv_enable()
3986 return rp->status; in hci_cc_le_set_per_adv_enable()
3990 adv = hci_find_adv_instance(hdev, cp->handle); in hci_cc_le_set_per_adv_enable()
3992 if (cp->enable) { in hci_cc_le_set_per_adv_enable()
3996 adv->enabled = true; in hci_cc_le_set_per_adv_enable()
4003 list_for_each_entry_safe(adv, n, &hdev->adv_instances, in hci_cc_le_set_per_adv_enable()
4005 if (adv->periodic && adv->enabled) in hci_cc_le_set_per_adv_enable()
4018 return rp->status; in hci_cc_le_set_per_adv_enable()
4215 if (skb->len < cc->min_len) { in hci_cc_func()
4216 bt_dev_err(hdev, "unexpected cc 0x%4.4x length: %u < %u", in hci_cc_func()
4217 cc->op, skb->len, cc->min_len); in hci_cc_func()
4225 if (skb->len > cc->max_len) in hci_cc_func()
4226 bt_dev_warn(hdev, "unexpected cc 0x%4.4x length: %u > %u", in hci_cc_func()
4227 cc->op, skb->len, cc->max_len); in hci_cc_func()
4229 data = hci_cc_skb_pull(hdev, skb, cc->op, cc->min_len); in hci_cc_func()
4233 return cc->func(hdev, data, skb); in hci_cc_func()
4244 *opcode = __le16_to_cpu(ev->opcode); in hci_cmd_complete_evt()
4246 bt_dev_dbg(hdev, "opcode 0x%4.4x", *opcode); in hci_cmd_complete_evt()
4263 *status = skb->data[0]; in hci_cmd_complete_evt()
4266 handle_cmd_cnt_and_timer(hdev, ev->ncmd); in hci_cmd_complete_evt()
4273 "unexpected event for opcode 0x%4.4x", *opcode); in hci_cmd_complete_evt()
4277 if (atomic_read(&hdev->cmd_cnt) && !skb_queue_empty(&hdev->cmd_q)) in hci_cmd_complete_evt()
4278 queue_work(hdev->workqueue, &hdev->cmd_work); in hci_cmd_complete_evt()
4287 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_le_create_cis()
4299 for (i = 0; cp->num_cis; cp->num_cis--, i++) { in hci_cs_le_create_cis()
4303 handle = __le16_to_cpu(cp->cis[i].cis_handle); in hci_cs_le_create_cis()
4308 &conn->flags)) in hci_cs_le_create_cis()
4310 conn->state = BT_CLOSED; in hci_cs_le_create_cis()
4364 *opcode = __le16_to_cpu(ev->opcode); in hci_cmd_status_evt()
4365 *status = ev->status; in hci_cmd_status_evt()
4367 bt_dev_dbg(hdev, "opcode 0x%4.4x", *opcode); in hci_cmd_status_evt()
4371 hci_cs_table[i].func(hdev, ev->status); in hci_cmd_status_evt()
4376 handle_cmd_cnt_and_timer(hdev, ev->ncmd); in hci_cmd_status_evt()
4384 if (ev->status || (hdev->sent_cmd && !hci_skb_event(hdev->sent_cmd))) { in hci_cmd_status_evt()
4385 hci_req_cmd_complete(hdev, *opcode, ev->status, req_complete, in hci_cmd_status_evt()
4388 bt_dev_err(hdev, "unexpected event for opcode 0x%4.4x", in hci_cmd_status_evt()
4394 if (atomic_read(&hdev->cmd_cnt) && !skb_queue_empty(&hdev->cmd_q)) in hci_cmd_status_evt()
4395 queue_work(hdev->workqueue, &hdev->cmd_work); in hci_cmd_status_evt()
4403 bt_dev_dbg(hdev, "code 0x%2.2x", ev->code); in hci_hardware_error_evt()
4405 hdev->hw_error_code = ev->code; in hci_hardware_error_evt()
4407 queue_work(hdev->req_workqueue, &hdev->error_reset); in hci_hardware_error_evt()
4416 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_role_change_evt()
4420 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_role_change_evt()
4422 if (!ev->status) in hci_role_change_evt()
4423 conn->role = ev->role; in hci_role_change_evt()
4425 clear_bit(HCI_CONN_RSWITCH_PEND, &conn->flags); in hci_role_change_evt()
4427 hci_role_switch_cfm(conn, ev->status, ev->role); in hci_role_change_evt()
4440 flex_array_size(ev, handles, ev->num))) in hci_num_comp_pkts_evt()
4443 if (hdev->flow_ctl_mode != HCI_FLOW_CTL_MODE_PACKET_BASED) { in hci_num_comp_pkts_evt()
4444 bt_dev_err(hdev, "wrong event for mode %d", hdev->flow_ctl_mode); in hci_num_comp_pkts_evt()
4448 bt_dev_dbg(hdev, "num %d", ev->num); in hci_num_comp_pkts_evt()
4450 for (i = 0; i < ev->num; i++) { in hci_num_comp_pkts_evt()
4451 struct hci_comp_pkts_info *info = &ev->handles[i]; in hci_num_comp_pkts_evt()
4455 handle = __le16_to_cpu(info->handle); in hci_num_comp_pkts_evt()
4456 count = __le16_to_cpu(info->count); in hci_num_comp_pkts_evt()
4462 conn->sent -= count; in hci_num_comp_pkts_evt()
4464 switch (conn->type) { in hci_num_comp_pkts_evt()
4466 hdev->acl_cnt += count; in hci_num_comp_pkts_evt()
4467 if (hdev->acl_cnt > hdev->acl_pkts) in hci_num_comp_pkts_evt()
4468 hdev->acl_cnt = hdev->acl_pkts; in hci_num_comp_pkts_evt()
4472 if (hdev->le_pkts) { in hci_num_comp_pkts_evt()
4473 hdev->le_cnt += count; in hci_num_comp_pkts_evt()
4474 if (hdev->le_cnt > hdev->le_pkts) in hci_num_comp_pkts_evt()
4475 hdev->le_cnt = hdev->le_pkts; in hci_num_comp_pkts_evt()
4477 hdev->acl_cnt += count; in hci_num_comp_pkts_evt()
4478 if (hdev->acl_cnt > hdev->acl_pkts) in hci_num_comp_pkts_evt()
4479 hdev->acl_cnt = hdev->acl_pkts; in hci_num_comp_pkts_evt()
4484 hdev->sco_cnt += count; in hci_num_comp_pkts_evt()
4485 if (hdev->sco_cnt > hdev->sco_pkts) in hci_num_comp_pkts_evt()
4486 hdev->sco_cnt = hdev->sco_pkts; in hci_num_comp_pkts_evt()
4490 if (hdev->iso_pkts) { in hci_num_comp_pkts_evt()
4491 hdev->iso_cnt += count; in hci_num_comp_pkts_evt()
4492 if (hdev->iso_cnt > hdev->iso_pkts) in hci_num_comp_pkts_evt()
4493 hdev->iso_cnt = hdev->iso_pkts; in hci_num_comp_pkts_evt()
4494 } else if (hdev->le_pkts) { in hci_num_comp_pkts_evt()
4495 hdev->le_cnt += count; in hci_num_comp_pkts_evt()
4496 if (hdev->le_cnt > hdev->le_pkts) in hci_num_comp_pkts_evt()
4497 hdev->le_cnt = hdev->le_pkts; in hci_num_comp_pkts_evt()
4499 hdev->acl_cnt += count; in hci_num_comp_pkts_evt()
4500 if (hdev->acl_cnt > hdev->acl_pkts) in hci_num_comp_pkts_evt()
4501 hdev->acl_cnt = hdev->acl_pkts; in hci_num_comp_pkts_evt()
4507 conn->type, conn); in hci_num_comp_pkts_evt()
4512 queue_work(hdev->workqueue, &hdev->tx_work); in hci_num_comp_pkts_evt()
4520 switch (hdev->dev_type) { in __hci_conn_lookup_handle()
4526 return chan->conn; in __hci_conn_lookup_handle()
4529 bt_dev_err(hdev, "unknown dev_type %d", hdev->dev_type); in __hci_conn_lookup_handle()
4543 flex_array_size(ev, handles, ev->num_hndl))) in hci_num_comp_blocks_evt()
4546 if (hdev->flow_ctl_mode != HCI_FLOW_CTL_MODE_BLOCK_BASED) { in hci_num_comp_blocks_evt()
4548 hdev->flow_ctl_mode); in hci_num_comp_blocks_evt()
4552 bt_dev_dbg(hdev, "num_blocks %d num_hndl %d", ev->num_blocks, in hci_num_comp_blocks_evt()
4553 ev->num_hndl); in hci_num_comp_blocks_evt()
4555 for (i = 0; i < ev->num_hndl; i++) { in hci_num_comp_blocks_evt()
4556 struct hci_comp_blocks_info *info = &ev->handles[i]; in hci_num_comp_blocks_evt()
4560 handle = __le16_to_cpu(info->handle); in hci_num_comp_blocks_evt()
4561 block_count = __le16_to_cpu(info->blocks); in hci_num_comp_blocks_evt()
4567 conn->sent -= block_count; in hci_num_comp_blocks_evt()
4569 switch (conn->type) { in hci_num_comp_blocks_evt()
4572 hdev->block_cnt += block_count; in hci_num_comp_blocks_evt()
4573 if (hdev->block_cnt > hdev->num_blocks) in hci_num_comp_blocks_evt()
4574 hdev->block_cnt = hdev->num_blocks; in hci_num_comp_blocks_evt()
4579 conn->type, conn); in hci_num_comp_blocks_evt()
4584 queue_work(hdev->workqueue, &hdev->tx_work); in hci_num_comp_blocks_evt()
4593 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_mode_change_evt()
4597 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_mode_change_evt()
4599 conn->mode = ev->mode; in hci_mode_change_evt()
4602 &conn->flags)) { in hci_mode_change_evt()
4603 if (conn->mode == HCI_CM_ACTIVE) in hci_mode_change_evt()
4604 set_bit(HCI_CONN_POWER_SAVE, &conn->flags); in hci_mode_change_evt()
4606 clear_bit(HCI_CONN_POWER_SAVE, &conn->flags); in hci_mode_change_evt()
4609 if (test_and_clear_bit(HCI_CONN_SCO_SETUP_PEND, &conn->flags)) in hci_mode_change_evt()
4610 hci_sco_setup(conn, ev->status); in hci_mode_change_evt()
4626 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_pin_code_request_evt()
4630 if (conn->state == BT_CONNECTED) { in hci_pin_code_request_evt()
4632 conn->disc_timeout = HCI_PAIRING_TIMEOUT; in hci_pin_code_request_evt()
4637 !test_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags)) { in hci_pin_code_request_evt()
4639 sizeof(ev->bdaddr), &ev->bdaddr); in hci_pin_code_request_evt()
4643 if (conn->pending_sec_level == BT_SECURITY_HIGH) in hci_pin_code_request_evt()
4648 mgmt_pin_code_request(hdev, &ev->bdaddr, secure); in hci_pin_code_request_evt()
4660 conn->pin_length = pin_len; in conn_set_key()
4661 conn->key_type = key_type; in conn_set_key()
4670 conn->pending_sec_level = BT_SECURITY_HIGH; in conn_set_key()
4672 conn->pending_sec_level = BT_SECURITY_MEDIUM; in conn_set_key()
4676 conn->pending_sec_level = BT_SECURITY_MEDIUM; in conn_set_key()
4679 conn->pending_sec_level = BT_SECURITY_HIGH; in conn_set_key()
4682 conn->pending_sec_level = BT_SECURITY_FIPS; in conn_set_key()
4702 key = hci_find_link_key(hdev, &ev->bdaddr); in hci_link_key_request_evt()
4704 bt_dev_dbg(hdev, "link key not found for %pMR", &ev->bdaddr); in hci_link_key_request_evt()
4708 bt_dev_dbg(hdev, "found key type %u for %pMR", key->type, &ev->bdaddr); in hci_link_key_request_evt()
4710 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_link_key_request_evt()
4712 clear_bit(HCI_CONN_NEW_LINK_KEY, &conn->flags); in hci_link_key_request_evt()
4714 if ((key->type == HCI_LK_UNAUTH_COMBINATION_P192 || in hci_link_key_request_evt()
4715 key->type == HCI_LK_UNAUTH_COMBINATION_P256) && in hci_link_key_request_evt()
4716 conn->auth_type != 0xff && (conn->auth_type & 0x01)) { in hci_link_key_request_evt()
4721 if (key->type == HCI_LK_COMBINATION && key->pin_len < 16 && in hci_link_key_request_evt()
4722 (conn->pending_sec_level == BT_SECURITY_HIGH || in hci_link_key_request_evt()
4723 conn->pending_sec_level == BT_SECURITY_FIPS)) { in hci_link_key_request_evt()
4728 conn_set_key(conn, key->type, key->pin_len); in hci_link_key_request_evt()
4731 bacpy(&cp.bdaddr, &ev->bdaddr); in hci_link_key_request_evt()
4732 memcpy(cp.link_key, key->val, HCI_LINK_KEY_SIZE); in hci_link_key_request_evt()
4741 hci_send_cmd(hdev, HCI_OP_LINK_KEY_NEG_REPLY, 6, &ev->bdaddr); in hci_link_key_request_evt()
4758 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_link_key_notify_evt()
4762 /* Ignore NULL link key against CVE-2020-26555 */ in hci_link_key_notify_evt()
4763 if (!crypto_memneq(ev->link_key, ZERO_KEY, HCI_LINK_KEY_SIZE)) { in hci_link_key_notify_evt()
4765 &ev->bdaddr); in hci_link_key_notify_evt()
4772 conn->disc_timeout = HCI_DISCONN_TIMEOUT; in hci_link_key_notify_evt()
4775 set_bit(HCI_CONN_NEW_LINK_KEY, &conn->flags); in hci_link_key_notify_evt()
4776 conn_set_key(conn, ev->key_type, conn->pin_length); in hci_link_key_notify_evt()
4781 key = hci_add_link_key(hdev, conn, &ev->bdaddr, ev->link_key, in hci_link_key_notify_evt()
4782 ev->key_type, pin_len, &persistent); in hci_link_key_notify_evt()
4789 if (ev->key_type == HCI_LK_CHANGED_COMBINATION) in hci_link_key_notify_evt()
4790 conn_set_key(conn, key->type, key->pin_len); in hci_link_key_notify_evt()
4799 if (key->type == HCI_LK_DEBUG_COMBINATION && in hci_link_key_notify_evt()
4801 list_del_rcu(&key->list); in hci_link_key_notify_evt()
4807 clear_bit(HCI_CONN_FLUSH_KEY, &conn->flags); in hci_link_key_notify_evt()
4809 set_bit(HCI_CONN_FLUSH_KEY, &conn->flags); in hci_link_key_notify_evt()
4821 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_clock_offset_evt()
4825 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_clock_offset_evt()
4826 if (conn && !ev->status) { in hci_clock_offset_evt()
4829 ie = hci_inquiry_cache_lookup(hdev, &conn->dst); in hci_clock_offset_evt()
4831 ie->data.clock_offset = ev->clock_offset; in hci_clock_offset_evt()
4832 ie->timestamp = jiffies; in hci_clock_offset_evt()
4845 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_pkt_type_change_evt()
4849 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_pkt_type_change_evt()
4850 if (conn && !ev->status) in hci_pkt_type_change_evt()
4851 conn->pkt_type = __le16_to_cpu(ev->pkt_type); in hci_pkt_type_change_evt()
4866 ie = hci_inquiry_cache_lookup(hdev, &ev->bdaddr); in hci_pscan_rep_mode_evt()
4868 ie->data.pscan_rep_mode = ev->pscan_rep_mode; in hci_pscan_rep_mode_evt()
4869 ie->timestamp = jiffies; in hci_pscan_rep_mode_evt()
4882 bt_dev_dbg(hdev, "num_rsp %d", ev->num); in hci_inquiry_result_with_rssi_evt()
4884 if (!ev->num) in hci_inquiry_result_with_rssi_evt()
4892 if (skb->len == array_size(ev->num, in hci_inquiry_result_with_rssi_evt()
4896 for (i = 0; i < ev->num; i++) { in hci_inquiry_result_with_rssi_evt()
4903 bt_dev_err(hdev, "Malformed HCI Event: 0x%2.2x", in hci_inquiry_result_with_rssi_evt()
4908 bacpy(&data.bdaddr, &info->bdaddr); in hci_inquiry_result_with_rssi_evt()
4909 data.pscan_rep_mode = info->pscan_rep_mode; in hci_inquiry_result_with_rssi_evt()
4910 data.pscan_period_mode = info->pscan_period_mode; in hci_inquiry_result_with_rssi_evt()
4911 data.pscan_mode = info->pscan_mode; in hci_inquiry_result_with_rssi_evt()
4912 memcpy(data.dev_class, info->dev_class, 3); in hci_inquiry_result_with_rssi_evt()
4913 data.clock_offset = info->clock_offset; in hci_inquiry_result_with_rssi_evt()
4914 data.rssi = info->rssi; in hci_inquiry_result_with_rssi_evt()
4919 mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, in hci_inquiry_result_with_rssi_evt()
4920 info->dev_class, info->rssi, in hci_inquiry_result_with_rssi_evt()
4923 } else if (skb->len == array_size(ev->num, in hci_inquiry_result_with_rssi_evt()
4927 for (i = 0; i < ev->num; i++) { in hci_inquiry_result_with_rssi_evt()
4934 bt_dev_err(hdev, "Malformed HCI Event: 0x%2.2x", in hci_inquiry_result_with_rssi_evt()
4939 bacpy(&data.bdaddr, &info->bdaddr); in hci_inquiry_result_with_rssi_evt()
4940 data.pscan_rep_mode = info->pscan_rep_mode; in hci_inquiry_result_with_rssi_evt()
4941 data.pscan_period_mode = info->pscan_period_mode; in hci_inquiry_result_with_rssi_evt()
4943 memcpy(data.dev_class, info->dev_class, 3); in hci_inquiry_result_with_rssi_evt()
4944 data.clock_offset = info->clock_offset; in hci_inquiry_result_with_rssi_evt()
4945 data.rssi = info->rssi; in hci_inquiry_result_with_rssi_evt()
4950 mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, in hci_inquiry_result_with_rssi_evt()
4951 info->dev_class, info->rssi, in hci_inquiry_result_with_rssi_evt()
4955 bt_dev_err(hdev, "Malformed HCI Event: 0x%2.2x", in hci_inquiry_result_with_rssi_evt()
4968 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_remote_ext_features_evt()
4972 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_remote_ext_features_evt()
4976 if (ev->page < HCI_MAX_PAGES) in hci_remote_ext_features_evt()
4977 memcpy(conn->features[ev->page], ev->features, 8); in hci_remote_ext_features_evt()
4979 if (!ev->status && ev->page == 0x01) { in hci_remote_ext_features_evt()
4982 ie = hci_inquiry_cache_lookup(hdev, &conn->dst); in hci_remote_ext_features_evt()
4984 ie->data.ssp_mode = (ev->features[0] & LMP_HOST_SSP); in hci_remote_ext_features_evt()
4986 if (ev->features[0] & LMP_HOST_SSP) { in hci_remote_ext_features_evt()
4987 set_bit(HCI_CONN_SSP_ENABLED, &conn->flags); in hci_remote_ext_features_evt()
4997 clear_bit(HCI_CONN_SSP_ENABLED, &conn->flags); in hci_remote_ext_features_evt()
5000 if (ev->features[0] & LMP_HOST_SC) in hci_remote_ext_features_evt()
5001 set_bit(HCI_CONN_SC_ENABLED, &conn->flags); in hci_remote_ext_features_evt()
5004 if (conn->state != BT_CONFIG) in hci_remote_ext_features_evt()
5007 if (!ev->status && !test_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) { in hci_remote_ext_features_evt()
5010 bacpy(&cp.bdaddr, &conn->dst); in hci_remote_ext_features_evt()
5013 } else if (!test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) in hci_remote_ext_features_evt()
5017 conn->state = BT_CONNECTED; in hci_remote_ext_features_evt()
5018 hci_connect_cfm(conn, ev->status); in hci_remote_ext_features_evt()
5031 u8 status = ev->status; in hci_sync_conn_complete_evt()
5033 switch (ev->link_type) { in hci_sync_conn_complete_evt()
5046 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_sync_conn_complete_evt()
5050 conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, &ev->bdaddr); in hci_sync_conn_complete_evt()
5052 if (ev->link_type == ESCO_LINK) in hci_sync_conn_complete_evt()
5064 conn = hci_conn_hash_lookup_ba(hdev, ESCO_LINK, &ev->bdaddr); in hci_sync_conn_complete_evt()
5075 if (!HCI_CONN_HANDLE_UNSET(conn->handle)) { in hci_sync_conn_complete_evt()
5082 status = hci_conn_set_handle(conn, __le16_to_cpu(ev->handle)); in hci_sync_conn_complete_evt()
5084 conn->state = BT_CLOSED; in hci_sync_conn_complete_evt()
5088 conn->state = BT_CONNECTED; in hci_sync_conn_complete_evt()
5089 conn->type = ev->link_type; in hci_sync_conn_complete_evt()
5103 if (conn->out) { in hci_sync_conn_complete_evt()
5104 conn->pkt_type = (hdev->esco_type & SCO_ESCO_MASK) | in hci_sync_conn_complete_evt()
5105 (hdev->esco_type & EDR_ESCO_MASK); in hci_sync_conn_complete_evt()
5106 if (hci_setup_sync(conn, conn->parent->handle)) in hci_sync_conn_complete_evt()
5112 conn->state = BT_CLOSED; in hci_sync_conn_complete_evt()
5116 bt_dev_dbg(hdev, "SCO connected with air mode: %02x", ev->air_mode); in hci_sync_conn_complete_evt()
5118 * is zero and non-zero value shall be non-HCI transport data path in hci_sync_conn_complete_evt()
5120 if (conn->codec.data_path == 0 && hdev->notify) { in hci_sync_conn_complete_evt()
5121 switch (ev->air_mode) { in hci_sync_conn_complete_evt()
5123 hdev->notify(hdev, HCI_NOTIFY_ENABLE_SCO_CVSD); in hci_sync_conn_complete_evt()
5126 hdev->notify(hdev, HCI_NOTIFY_ENABLE_SCO_TRANSP); in hci_sync_conn_complete_evt()
5165 flex_array_size(ev, info, ev->num))) in hci_extended_inquiry_result_evt()
5168 bt_dev_dbg(hdev, "num %d", ev->num); in hci_extended_inquiry_result_evt()
5170 if (!ev->num) in hci_extended_inquiry_result_evt()
5178 for (i = 0; i < ev->num; i++) { in hci_extended_inquiry_result_evt()
5179 struct extended_inquiry_info *info = &ev->info[i]; in hci_extended_inquiry_result_evt()
5183 bacpy(&data.bdaddr, &info->bdaddr); in hci_extended_inquiry_result_evt()
5184 data.pscan_rep_mode = info->pscan_rep_mode; in hci_extended_inquiry_result_evt()
5185 data.pscan_period_mode = info->pscan_period_mode; in hci_extended_inquiry_result_evt()
5187 memcpy(data.dev_class, info->dev_class, 3); in hci_extended_inquiry_result_evt()
5188 data.clock_offset = info->clock_offset; in hci_extended_inquiry_result_evt()
5189 data.rssi = info->rssi; in hci_extended_inquiry_result_evt()
5193 name_known = eir_get_data(info->data, in hci_extended_inquiry_result_evt()
5194 sizeof(info->data), in hci_extended_inquiry_result_evt()
5201 eir_len = eir_get_length(info->data, sizeof(info->data)); in hci_extended_inquiry_result_evt()
5203 mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, in hci_extended_inquiry_result_evt()
5204 info->dev_class, info->rssi, in hci_extended_inquiry_result_evt()
5205 flags, info->data, eir_len, NULL, 0, 0); in hci_extended_inquiry_result_evt()
5217 bt_dev_dbg(hdev, "status 0x%2.2x handle 0x%4.4x", ev->status, in hci_key_refresh_complete_evt()
5218 __le16_to_cpu(ev->handle)); in hci_key_refresh_complete_evt()
5222 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_key_refresh_complete_evt()
5229 if (conn->type != LE_LINK) in hci_key_refresh_complete_evt()
5232 if (!ev->status) in hci_key_refresh_complete_evt()
5233 conn->sec_level = conn->pending_sec_level; in hci_key_refresh_complete_evt()
5235 clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags); in hci_key_refresh_complete_evt()
5237 if (ev->status && conn->state == BT_CONNECTED) { in hci_key_refresh_complete_evt()
5243 if (conn->state == BT_CONFIG) { in hci_key_refresh_complete_evt()
5244 if (!ev->status) in hci_key_refresh_complete_evt()
5245 conn->state = BT_CONNECTED; in hci_key_refresh_complete_evt()
5247 hci_connect_cfm(conn, ev->status); in hci_key_refresh_complete_evt()
5250 hci_auth_cfm(conn, ev->status); in hci_key_refresh_complete_evt()
5253 conn->disc_timeout = HCI_DISCONN_TIMEOUT; in hci_key_refresh_complete_evt()
5263 /* If remote requests no-bonding follow that lead */ in hci_get_auth_req()
5264 if (conn->remote_auth == HCI_AT_NO_BONDING || in hci_get_auth_req()
5265 conn->remote_auth == HCI_AT_NO_BONDING_MITM) in hci_get_auth_req()
5266 return conn->remote_auth | (conn->auth_type & 0x01); in hci_get_auth_req()
5271 if (conn->remote_cap != HCI_IO_NO_INPUT_OUTPUT && in hci_get_auth_req()
5272 conn->io_capability != HCI_IO_NO_INPUT_OUTPUT) in hci_get_auth_req()
5273 return conn->remote_auth | 0x01; in hci_get_auth_req()
5276 return (conn->remote_auth & ~0x01) | (conn->auth_type & 0x01); in hci_get_auth_req()
5281 struct hci_dev *hdev = conn->hdev; in bredr_oob_data_present()
5284 data = hci_find_remote_oob_data(hdev, &conn->dst, BDADDR_BREDR); in bredr_oob_data_present()
5296 return data->present; in bredr_oob_data_present()
5299 * the P-256 values are required. If they are not in bredr_oob_data_present()
5303 if (!crypto_memneq(data->rand256, ZERO_KEY, 16) || in bredr_oob_data_present()
5304 !crypto_memneq(data->hash256, ZERO_KEY, 16)) in bredr_oob_data_present()
5312 * P-192 data values are present. in bredr_oob_data_present()
5314 if (!crypto_memneq(data->rand192, ZERO_KEY, 16) || in bredr_oob_data_present()
5315 !crypto_memneq(data->hash192, ZERO_KEY, 16)) in bredr_oob_data_present()
5331 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_io_capa_request_evt()
5336 set_bit(HCI_CONN_SSP_ENABLED, &conn->flags); in hci_io_capa_request_evt()
5347 test_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags) || in hci_io_capa_request_evt()
5348 (conn->remote_auth & ~0x01) == HCI_AT_NO_BONDING) { in hci_io_capa_request_evt()
5351 bacpy(&cp.bdaddr, &ev->bdaddr); in hci_io_capa_request_evt()
5354 cp.capability = (conn->io_capability == 0x04) ? in hci_io_capa_request_evt()
5355 HCI_IO_DISPLAY_YESNO : conn->io_capability; in hci_io_capa_request_evt()
5358 if (conn->remote_auth == 0xff) { in hci_io_capa_request_evt()
5360 * except for the no-bonding case. in hci_io_capa_request_evt()
5362 if (conn->io_capability != HCI_IO_NO_INPUT_OUTPUT && in hci_io_capa_request_evt()
5363 conn->auth_type != HCI_AT_NO_BONDING) in hci_io_capa_request_evt()
5364 conn->auth_type |= 0x01; in hci_io_capa_request_evt()
5366 conn->auth_type = hci_get_auth_req(conn); in hci_io_capa_request_evt()
5369 /* If we're not bondable, force one of the non-bondable in hci_io_capa_request_evt()
5373 conn->auth_type &= HCI_AT_NO_BONDING_MITM; in hci_io_capa_request_evt()
5375 cp.authentication = conn->auth_type; in hci_io_capa_request_evt()
5383 bacpy(&cp.bdaddr, &ev->bdaddr); in hci_io_capa_request_evt()
5404 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_io_capa_reply_evt()
5408 conn->remote_cap = ev->capability; in hci_io_capa_reply_evt()
5409 conn->remote_auth = ev->authentication; in hci_io_capa_reply_evt()
5429 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_user_confirm_request_evt()
5433 loc_mitm = (conn->auth_type & 0x01); in hci_user_confirm_request_evt()
5434 rem_mitm = (conn->remote_auth & 0x01); in hci_user_confirm_request_evt()
5439 * necessarily match conn->auth_type. in hci_user_confirm_request_evt()
5441 if (conn->pending_sec_level > BT_SECURITY_MEDIUM && in hci_user_confirm_request_evt()
5442 conn->remote_cap == HCI_IO_NO_INPUT_OUTPUT) { in hci_user_confirm_request_evt()
5445 sizeof(ev->bdaddr), &ev->bdaddr); in hci_user_confirm_request_evt()
5449 /* If no side requires MITM protection; auto-accept */ in hci_user_confirm_request_evt()
5450 if ((!loc_mitm || conn->remote_cap == HCI_IO_NO_INPUT_OUTPUT) && in hci_user_confirm_request_evt()
5451 (!rem_mitm || conn->io_capability == HCI_IO_NO_INPUT_OUTPUT)) { in hci_user_confirm_request_evt()
5457 * NoInputNoOutput, in which case we do auto-accept in hci_user_confirm_request_evt()
5459 if (!test_bit(HCI_CONN_AUTH_PEND, &conn->flags) && in hci_user_confirm_request_evt()
5460 conn->io_capability != HCI_IO_NO_INPUT_OUTPUT && in hci_user_confirm_request_evt()
5462 bt_dev_dbg(hdev, "Confirming auto-accept as acceptor"); in hci_user_confirm_request_evt()
5471 if (hci_find_link_key(hdev, &ev->bdaddr)) { in hci_user_confirm_request_evt()
5477 BT_DBG("Auto-accept of user confirmation with %ums delay", in hci_user_confirm_request_evt()
5478 hdev->auto_accept_delay); in hci_user_confirm_request_evt()
5480 if (hdev->auto_accept_delay > 0) { in hci_user_confirm_request_evt()
5481 int delay = msecs_to_jiffies(hdev->auto_accept_delay); in hci_user_confirm_request_evt()
5482 queue_delayed_work(conn->hdev->workqueue, in hci_user_confirm_request_evt()
5483 &conn->auto_accept_work, delay); in hci_user_confirm_request_evt()
5488 sizeof(ev->bdaddr), &ev->bdaddr); in hci_user_confirm_request_evt()
5493 mgmt_user_confirm_request(hdev, &ev->bdaddr, ACL_LINK, 0, in hci_user_confirm_request_evt()
5494 le32_to_cpu(ev->passkey), confirm_hint); in hci_user_confirm_request_evt()
5508 mgmt_user_passkey_request(hdev, &ev->bdaddr, ACL_LINK, 0); in hci_user_passkey_request_evt()
5519 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_user_passkey_notify_evt()
5523 conn->passkey_notify = __le32_to_cpu(ev->passkey); in hci_user_passkey_notify_evt()
5524 conn->passkey_entered = 0; in hci_user_passkey_notify_evt()
5527 mgmt_user_passkey_notify(hdev, &conn->dst, conn->type, in hci_user_passkey_notify_evt()
5528 conn->dst_type, conn->passkey_notify, in hci_user_passkey_notify_evt()
5529 conn->passkey_entered); in hci_user_passkey_notify_evt()
5540 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_keypress_notify_evt()
5544 switch (ev->type) { in hci_keypress_notify_evt()
5546 conn->passkey_entered = 0; in hci_keypress_notify_evt()
5550 conn->passkey_entered++; in hci_keypress_notify_evt()
5554 conn->passkey_entered--; in hci_keypress_notify_evt()
5558 conn->passkey_entered = 0; in hci_keypress_notify_evt()
5566 mgmt_user_passkey_notify(hdev, &conn->dst, conn->type, in hci_keypress_notify_evt()
5567 conn->dst_type, conn->passkey_notify, in hci_keypress_notify_evt()
5568 conn->passkey_entered); in hci_keypress_notify_evt()
5581 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_simple_pair_complete_evt()
5586 conn->remote_auth = 0xff; in hci_simple_pair_complete_evt()
5593 if (!test_bit(HCI_CONN_AUTH_PEND, &conn->flags) && ev->status) in hci_simple_pair_complete_evt()
5594 mgmt_auth_failed(conn, ev->status); in hci_simple_pair_complete_evt()
5613 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_remote_host_features_evt()
5615 memcpy(conn->features[1], ev->features, 8); in hci_remote_host_features_evt()
5617 ie = hci_inquiry_cache_lookup(hdev, &ev->bdaddr); in hci_remote_host_features_evt()
5619 ie->data.ssp_mode = (ev->features[0] & LMP_HOST_SSP); in hci_remote_host_features_evt()
5637 data = hci_find_remote_oob_data(hdev, &ev->bdaddr, BDADDR_BREDR); in hci_remote_oob_data_request_evt()
5641 bacpy(&cp.bdaddr, &ev->bdaddr); in hci_remote_oob_data_request_evt()
5650 bacpy(&cp.bdaddr, &ev->bdaddr); in hci_remote_oob_data_request_evt()
5655 memcpy(cp.hash192, data->hash192, sizeof(cp.hash192)); in hci_remote_oob_data_request_evt()
5656 memcpy(cp.rand192, data->rand192, sizeof(cp.rand192)); in hci_remote_oob_data_request_evt()
5658 memcpy(cp.hash256, data->hash256, sizeof(cp.hash256)); in hci_remote_oob_data_request_evt()
5659 memcpy(cp.rand256, data->rand256, sizeof(cp.rand256)); in hci_remote_oob_data_request_evt()
5666 bacpy(&cp.bdaddr, &ev->bdaddr); in hci_remote_oob_data_request_evt()
5667 memcpy(cp.hash, data->hash192, sizeof(cp.hash)); in hci_remote_oob_data_request_evt()
5668 memcpy(cp.rand, data->rand192, sizeof(cp.rand)); in hci_remote_oob_data_request_evt()
5685 bt_dev_dbg(hdev, "handle 0x%2.2x", ev->phy_handle); in hci_chan_selected_evt()
5687 hcon = hci_conn_hash_lookup_handle(hdev, ev->phy_handle); in hci_chan_selected_evt()
5700 bt_dev_dbg(hdev, "handle 0x%2.2x status 0x%2.2x", ev->phy_handle, in hci_phy_link_complete_evt()
5701 ev->status); in hci_phy_link_complete_evt()
5705 hcon = hci_conn_hash_lookup_handle(hdev, ev->phy_handle); in hci_phy_link_complete_evt()
5709 if (!hcon->amp_mgr) in hci_phy_link_complete_evt()
5712 if (ev->status) { in hci_phy_link_complete_evt()
5717 bredr_hcon = hcon->amp_mgr->l2cap_conn->hcon; in hci_phy_link_complete_evt()
5719 hcon->state = BT_CONNECTED; in hci_phy_link_complete_evt()
5720 bacpy(&hcon->dst, &bredr_hcon->dst); in hci_phy_link_complete_evt()
5723 hcon->disc_timeout = HCI_DISCONN_TIMEOUT; in hci_phy_link_complete_evt()
5743 bt_dev_dbg(hdev, "log_handle 0x%4.4x phy_handle 0x%2.2x status 0x%2.2x", in hci_loglink_complete_evt()
5744 le16_to_cpu(ev->handle), ev->phy_handle, ev->status); in hci_loglink_complete_evt()
5746 hcon = hci_conn_hash_lookup_handle(hdev, ev->phy_handle); in hci_loglink_complete_evt()
5755 hchan->handle = le16_to_cpu(ev->handle); in hci_loglink_complete_evt()
5756 hchan->amp = true; in hci_loglink_complete_evt()
5758 BT_DBG("hcon %p mgr %p hchan %p", hcon, hcon->amp_mgr, hchan); in hci_loglink_complete_evt()
5760 mgr = hcon->amp_mgr; in hci_loglink_complete_evt()
5761 if (mgr && mgr->bredr_chan) { in hci_loglink_complete_evt()
5762 struct l2cap_chan *bredr_chan = mgr->bredr_chan; in hci_loglink_complete_evt()
5766 bredr_chan->conn->mtu = hdev->block_mtu; in hci_loglink_complete_evt()
5780 bt_dev_dbg(hdev, "handle 0x%4.4x status 0x%2.2x", in hci_disconn_loglink_complete_evt()
5781 le16_to_cpu(ev->handle), ev->status); in hci_disconn_loglink_complete_evt()
5783 if (ev->status) in hci_disconn_loglink_complete_evt()
5788 hchan = hci_chan_lookup_handle(hdev, le16_to_cpu(ev->handle)); in hci_disconn_loglink_complete_evt()
5789 if (!hchan || !hchan->amp) in hci_disconn_loglink_complete_evt()
5792 amp_destroy_logical_link(hchan, ev->reason); in hci_disconn_loglink_complete_evt()
5804 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_disconn_phylink_complete_evt()
5806 if (ev->status) in hci_disconn_phylink_complete_evt()
5811 hcon = hci_conn_hash_lookup_handle(hdev, ev->phy_handle); in hci_disconn_phylink_complete_evt()
5812 if (hcon && hcon->type == AMP_LINK) { in hci_disconn_phylink_complete_evt()
5813 hcon->state = BT_CLOSED; in hci_disconn_phylink_complete_evt()
5814 hci_disconn_cfm(hcon, ev->reason); in hci_disconn_phylink_complete_evt()
5825 if (conn->out) { in le_conn_update_addr()
5826 conn->dst_type = bdaddr_type; in le_conn_update_addr()
5827 conn->resp_addr_type = bdaddr_type; in le_conn_update_addr()
5828 bacpy(&conn->resp_addr, bdaddr); in le_conn_update_addr()
5831 * used instead or hdev->rpa. in le_conn_update_addr()
5834 conn->init_addr_type = ADDR_LE_DEV_RANDOM; in le_conn_update_addr()
5835 bacpy(&conn->init_addr, local_rpa); in le_conn_update_addr()
5836 } else if (hci_dev_test_flag(conn->hdev, HCI_PRIVACY)) { in le_conn_update_addr()
5837 conn->init_addr_type = ADDR_LE_DEV_RANDOM; in le_conn_update_addr()
5838 bacpy(&conn->init_addr, &conn->hdev->rpa); in le_conn_update_addr()
5840 hci_copy_identity_address(conn->hdev, &conn->init_addr, in le_conn_update_addr()
5841 &conn->init_addr_type); in le_conn_update_addr()
5844 conn->resp_addr_type = conn->hdev->adv_addr_type; in le_conn_update_addr()
5846 * used instead or hdev->rpa. in le_conn_update_addr()
5849 conn->resp_addr_type = ADDR_LE_DEV_RANDOM; in le_conn_update_addr()
5850 bacpy(&conn->resp_addr, local_rpa); in le_conn_update_addr()
5851 } else if (conn->hdev->adv_addr_type == ADDR_LE_DEV_RANDOM) { in le_conn_update_addr()
5855 if (!ext_adv_capable(conn->hdev)) in le_conn_update_addr()
5856 bacpy(&conn->resp_addr, in le_conn_update_addr()
5857 &conn->hdev->random_addr); in le_conn_update_addr()
5859 bacpy(&conn->resp_addr, &conn->hdev->bdaddr); in le_conn_update_addr()
5862 conn->init_addr_type = bdaddr_type; in le_conn_update_addr()
5863 bacpy(&conn->init_addr, bdaddr); in le_conn_update_addr()
5870 conn->le_conn_min_interval = conn->hdev->le_conn_min_interval; in le_conn_update_addr()
5871 conn->le_conn_max_interval = conn->hdev->le_conn_max_interval; in le_conn_update_addr()
5907 conn->dst_type = bdaddr_type; in le_conn_complete_evt()
5917 if (conn->out) { in le_conn_complete_evt()
5918 conn->resp_addr_type = bdaddr_type; in le_conn_complete_evt()
5919 bacpy(&conn->resp_addr, bdaddr); in le_conn_complete_evt()
5921 conn->init_addr_type = ADDR_LE_DEV_RANDOM; in le_conn_complete_evt()
5922 bacpy(&conn->init_addr, &hdev->rpa); in le_conn_complete_evt()
5925 &conn->init_addr, in le_conn_complete_evt()
5926 &conn->init_addr_type); in le_conn_complete_evt()
5930 cancel_delayed_work(&conn->le_conn_timeout); in le_conn_complete_evt()
5939 if (!HCI_CONN_HANDLE_UNSET(conn->handle)) { in le_conn_complete_evt()
5955 irk = hci_get_irk(hdev, &conn->dst, conn->dst_type); in le_conn_complete_evt()
5957 bacpy(&conn->dst, &irk->bdaddr); in le_conn_complete_evt()
5958 conn->dst_type = irk->addr_type; in le_conn_complete_evt()
5961 conn->dst_type = ev_bdaddr_type(hdev, conn->dst_type, NULL); in le_conn_complete_evt()
5971 if (test_bit(HCI_CONN_CANCEL, &conn->flags)) { in le_conn_complete_evt()
5976 if (conn->dst_type == ADDR_LE_DEV_PUBLIC) in le_conn_complete_evt()
5982 if (hci_bdaddr_list_lookup(&hdev->reject_list, &conn->dst, addr_type)) { in le_conn_complete_evt()
5987 if (!test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) in le_conn_complete_evt()
5990 conn->sec_level = BT_SECURITY_LOW; in le_conn_complete_evt()
5991 conn->state = BT_CONFIG; in le_conn_complete_evt()
5994 * when sotfware rotation is in use so it can be re-enabled when in le_conn_complete_evt()
5998 conn->adv_instance = hdev->cur_adv_instance; in le_conn_complete_evt()
6000 conn->le_conn_interval = interval; in le_conn_complete_evt()
6001 conn->le_conn_latency = latency; in le_conn_complete_evt()
6002 conn->le_supv_timeout = supervision_timeout; in le_conn_complete_evt()
6011 * If the local controller supports peripheral-initiated features in le_conn_complete_evt()
6016 if (conn->out || in le_conn_complete_evt()
6017 (hdev->le_features[0] & HCI_LE_PERIPHERAL_FEATURES)) { in le_conn_complete_evt()
6020 cp.handle = __cpu_to_le16(conn->handle); in le_conn_complete_evt()
6027 conn->state = BT_CONNECTED; in le_conn_complete_evt()
6031 params = hci_pend_le_action_lookup(&hdev->pend_le_conns, &conn->dst, in le_conn_complete_evt()
6032 conn->dst_type); in le_conn_complete_evt()
6035 if (params->conn) { in le_conn_complete_evt()
6036 hci_conn_drop(params->conn); in le_conn_complete_evt()
6037 hci_conn_put(params->conn); in le_conn_complete_evt()
6038 params->conn = NULL; in le_conn_complete_evt()
6052 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_conn_complete_evt()
6054 le_conn_complete_evt(hdev, ev->status, &ev->bdaddr, ev->bdaddr_type, in hci_le_conn_complete_evt()
6055 NULL, ev->role, le16_to_cpu(ev->handle), in hci_le_conn_complete_evt()
6056 le16_to_cpu(ev->interval), in hci_le_conn_complete_evt()
6057 le16_to_cpu(ev->latency), in hci_le_conn_complete_evt()
6058 le16_to_cpu(ev->supervision_timeout)); in hci_le_conn_complete_evt()
6066 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_enh_conn_complete_evt()
6068 le_conn_complete_evt(hdev, ev->status, &ev->bdaddr, ev->bdaddr_type, in hci_le_enh_conn_complete_evt()
6069 &ev->local_rpa, ev->role, le16_to_cpu(ev->handle), in hci_le_enh_conn_complete_evt()
6070 le16_to_cpu(ev->interval), in hci_le_enh_conn_complete_evt()
6071 le16_to_cpu(ev->latency), in hci_le_enh_conn_complete_evt()
6072 le16_to_cpu(ev->supervision_timeout)); in hci_le_enh_conn_complete_evt()
6082 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_ext_adv_term_evt()
6091 if (ev->status == HCI_ERROR_CANCELLED_BY_HOST) { in hci_le_ext_adv_term_evt()
6098 adv = hci_find_adv_instance(hdev, ev->handle); in hci_le_ext_adv_term_evt()
6100 if (ev->status) { in hci_le_ext_adv_term_evt()
6105 hci_remove_adv_instance(hdev, ev->handle); in hci_le_ext_adv_term_evt()
6106 mgmt_advertising_removed(NULL, hdev, ev->handle); in hci_le_ext_adv_term_evt()
6108 list_for_each_entry_safe(adv, n, &hdev->adv_instances, list) { in hci_le_ext_adv_term_evt()
6109 if (adv->enabled) in hci_le_ext_adv_term_evt()
6119 adv->enabled = false; in hci_le_ext_adv_term_evt()
6121 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->conn_handle)); in hci_le_ext_adv_term_evt()
6124 * instance can be re-enabled when disconnected. in hci_le_ext_adv_term_evt()
6126 conn->adv_instance = ev->handle; in hci_le_ext_adv_term_evt()
6128 if (hdev->adv_addr_type != ADDR_LE_DEV_RANDOM || in hci_le_ext_adv_term_evt()
6129 bacmp(&conn->resp_addr, BDADDR_ANY)) in hci_le_ext_adv_term_evt()
6132 if (!ev->handle) { in hci_le_ext_adv_term_evt()
6133 bacpy(&conn->resp_addr, &hdev->random_addr); in hci_le_ext_adv_term_evt()
6138 bacpy(&conn->resp_addr, &adv->random_addr); in hci_le_ext_adv_term_evt()
6151 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_conn_update_complete_evt()
6153 if (ev->status) in hci_le_conn_update_complete_evt()
6158 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_conn_update_complete_evt()
6160 conn->le_conn_interval = le16_to_cpu(ev->interval); in hci_le_conn_update_complete_evt()
6161 conn->le_conn_latency = le16_to_cpu(ev->latency); in hci_le_conn_update_complete_evt()
6162 conn->le_supv_timeout = le16_to_cpu(ev->supervision_timeout); in hci_le_conn_update_complete_evt()
6168 /* This function requires the caller holds hdev->lock */
6182 if (hci_bdaddr_list_lookup(&hdev->reject_list, addr, addr_type) || in check_pending_le_conn()
6183 hdev->suspended) in check_pending_le_conn()
6189 if (hdev->conn_hash.le_num_peripheral > 0 && in check_pending_le_conn()
6190 (!test_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks) || in check_pending_le_conn()
6191 !(hdev->le_states[3] & 0x10))) in check_pending_le_conn()
6197 params = hci_pend_le_action_lookup(&hdev->pend_le_conns, addr, in check_pending_le_conn()
6202 if (!params->explicit_connect) { in check_pending_le_conn()
6203 switch (params->auto_connect) { in check_pending_le_conn()
6226 BT_SECURITY_LOW, hdev->def_le_autoconnect_timeout, in check_pending_le_conn()
6238 if (!params->explicit_connect) in check_pending_le_conn()
6239 params->conn = hci_conn_get(conn); in check_pending_le_conn()
6245 case -EBUSY: in check_pending_le_conn()
6246 /* If hci_connect() returns -EBUSY it means there is already in check_pending_le_conn()
6265 struct discovery_state *d = &hdev->discovery; in process_adv_report()
6281 "type: 0x%02x", type); in process_adv_report()
6305 len = ptr - data; in process_adv_report()
6332 if (!smp_irk_matches(hdev, hdev->irk, direct_addr)) in process_adv_report()
6339 bdaddr = &irk->bdaddr; in process_adv_report()
6340 bdaddr_type = irk->addr_type; in process_adv_report()
6357 memcpy(conn->le_adv_data, data, len); in process_adv_report()
6358 conn->le_adv_data_len = len; in process_adv_report()
6377 if (hdev->le_scan_type == LE_SCAN_PASSIVE) { in process_adv_report()
6381 if (!hci_pend_le_action_lookup(&hdev->pend_le_reports, in process_adv_report()
6383 idr_is_empty(&hdev->adv_monitors_idr)) in process_adv_report()
6424 match = (!bacmp(bdaddr, &d->last_adv_addr) && in process_adv_report()
6425 bdaddr_type == d->last_adv_addr_type); in process_adv_report()
6434 mgmt_device_found(hdev, &d->last_adv_addr, LE_LINK, in process_adv_report()
6435 d->last_adv_addr_type, NULL, in process_adv_report()
6436 d->last_adv_rssi, d->last_adv_flags, in process_adv_report()
6437 d->last_adv_data, in process_adv_report()
6438 d->last_adv_data_len, NULL, 0, 0); in process_adv_report()
6463 mgmt_device_found(hdev, &d->last_adv_addr, LE_LINK, in process_adv_report()
6464 d->last_adv_addr_type, NULL, rssi, d->last_adv_flags, in process_adv_report()
6465 d->last_adv_data, d->last_adv_data_len, data, len, 0); in process_adv_report()
6475 if (!ev->num) in hci_le_adv_report_evt()
6480 while (ev->num--) { in hci_le_adv_report_evt()
6491 info->length + 1)) in hci_le_adv_report_evt()
6494 if (info->length <= max_adv_len(hdev)) { in hci_le_adv_report_evt()
6495 rssi = info->data[info->length]; in hci_le_adv_report_evt()
6496 process_adv_report(hdev, info->type, &info->bdaddr, in hci_le_adv_report_evt()
6497 info->bdaddr_type, NULL, 0, rssi, in hci_le_adv_report_evt()
6498 info->data, info->length, false, in hci_le_adv_report_evt()
6546 bt_dev_err_ratelimited(hdev, "Unknown advertising packet type: 0x%02x", in ext_evt_type_to_legacy()
6558 if (!ev->num) in hci_le_ext_adv_report_evt()
6563 while (ev->num--) { in hci_le_ext_adv_report_evt()
6574 info->length)) in hci_le_ext_adv_report_evt()
6577 evt_type = __le16_to_cpu(info->type) & LE_EXT_ADV_EVT_TYPE_MASK; in hci_le_ext_adv_report_evt()
6580 process_adv_report(hdev, legacy_evt_type, &info->bdaddr, in hci_le_ext_adv_report_evt()
6581 info->bdaddr_type, NULL, 0, in hci_le_ext_adv_report_evt()
6582 info->rssi, info->data, info->length, in hci_le_ext_adv_report_evt()
6605 int mask = hdev->link_mode; in hci_le_pa_sync_estabilished_evt()
6609 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_pa_sync_estabilished_evt()
6615 mask |= hci_proto_connect_ind(hdev, &ev->bdaddr, ISO_LINK, &flags); in hci_le_pa_sync_estabilished_evt()
6617 hci_le_pa_term_sync(hdev, ev->handle); in hci_le_pa_sync_estabilished_evt()
6624 if (ev->status) { in hci_le_pa_sync_estabilished_evt()
6632 set_bit(HCI_CONN_PA_SYNC_FAILED, &pa_sync->flags); in hci_le_pa_sync_estabilished_evt()
6635 hci_connect_cfm(pa_sync, ev->status); in hci_le_pa_sync_estabilished_evt()
6646 int mask = hdev->link_mode; in hci_le_per_adv_report_evt()
6649 bt_dev_dbg(hdev, "sync_handle 0x%4.4x", le16_to_cpu(ev->sync_handle)); in hci_le_per_adv_report_evt()
6655 hci_le_pa_term_sync(hdev, ev->sync_handle); in hci_le_per_adv_report_evt()
6666 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_remote_feat_complete_evt()
6670 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_remote_feat_complete_evt()
6672 if (!ev->status) in hci_le_remote_feat_complete_evt()
6673 memcpy(conn->features[0], ev->features, 8); in hci_le_remote_feat_complete_evt()
6675 if (conn->state == BT_CONFIG) { in hci_le_remote_feat_complete_evt()
6678 /* If the local controller supports peripheral-initiated in hci_le_remote_feat_complete_evt()
6687 if (!conn->out && ev->status == 0x1a && in hci_le_remote_feat_complete_evt()
6688 (hdev->le_features[0] & HCI_LE_PERIPHERAL_FEATURES)) in hci_le_remote_feat_complete_evt()
6691 status = ev->status; in hci_le_remote_feat_complete_evt()
6693 conn->state = BT_CONNECTED; in hci_le_remote_feat_complete_evt()
6711 bt_dev_dbg(hdev, "handle 0x%4.4x", __le16_to_cpu(ev->handle)); in hci_le_ltk_request_evt()
6715 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_ltk_request_evt()
6719 ltk = hci_find_ltk(hdev, &conn->dst, conn->dst_type, conn->role); in hci_le_ltk_request_evt()
6725 if (ev->ediv || ev->rand) in hci_le_ltk_request_evt()
6728 /* For non-SC keys check that EDiv and Rand match */ in hci_le_ltk_request_evt()
6729 if (ev->ediv != ltk->ediv || ev->rand != ltk->rand) in hci_le_ltk_request_evt()
6733 memcpy(cp.ltk, ltk->val, ltk->enc_size); in hci_le_ltk_request_evt()
6734 memset(cp.ltk + ltk->enc_size, 0, sizeof(cp.ltk) - ltk->enc_size); in hci_le_ltk_request_evt()
6735 cp.handle = cpu_to_le16(conn->handle); in hci_le_ltk_request_evt()
6737 conn->pending_sec_level = smp_ltk_sec_level(ltk); in hci_le_ltk_request_evt()
6739 conn->enc_key_size = ltk->enc_size; in hci_le_ltk_request_evt()
6746 * distribute the keys. Later, security can be re-established in hci_le_ltk_request_evt()
6749 if (ltk->type == SMP_STK) { in hci_le_ltk_request_evt()
6750 set_bit(HCI_CONN_STK_ENCRYPT, &conn->flags); in hci_le_ltk_request_evt()
6751 list_del_rcu(&ltk->list); in hci_le_ltk_request_evt()
6754 clear_bit(HCI_CONN_STK_ENCRYPT, &conn->flags); in hci_le_ltk_request_evt()
6762 neg.handle = ev->handle; in hci_le_ltk_request_evt()
6787 bt_dev_dbg(hdev, "handle 0x%4.4x", __le16_to_cpu(ev->handle)); in hci_le_remote_conn_param_req_evt()
6789 handle = le16_to_cpu(ev->handle); in hci_le_remote_conn_param_req_evt()
6790 min = le16_to_cpu(ev->interval_min); in hci_le_remote_conn_param_req_evt()
6791 max = le16_to_cpu(ev->interval_max); in hci_le_remote_conn_param_req_evt()
6792 latency = le16_to_cpu(ev->latency); in hci_le_remote_conn_param_req_evt()
6793 timeout = le16_to_cpu(ev->timeout); in hci_le_remote_conn_param_req_evt()
6796 if (!hcon || hcon->state != BT_CONNECTED) in hci_le_remote_conn_param_req_evt()
6800 if (max > hcon->le_conn_max_interval) in hci_le_remote_conn_param_req_evt()
6808 if (hcon->role == HCI_ROLE_MASTER) { in hci_le_remote_conn_param_req_evt()
6814 params = hci_conn_params_lookup(hdev, &hcon->dst, in hci_le_remote_conn_param_req_evt()
6815 hcon->dst_type); in hci_le_remote_conn_param_req_evt()
6817 params->conn_min_interval = min; in hci_le_remote_conn_param_req_evt()
6818 params->conn_max_interval = max; in hci_le_remote_conn_param_req_evt()
6819 params->conn_latency = latency; in hci_le_remote_conn_param_req_evt()
6820 params->supervision_timeout = timeout; in hci_le_remote_conn_param_req_evt()
6828 mgmt_new_conn_param(hdev, &hcon->dst, hcon->dst_type, in hci_le_remote_conn_param_req_evt()
6832 cp.handle = ev->handle; in hci_le_remote_conn_param_req_evt()
6833 cp.interval_min = ev->interval_min; in hci_le_remote_conn_param_req_evt()
6834 cp.interval_max = ev->interval_max; in hci_le_remote_conn_param_req_evt()
6835 cp.latency = ev->latency; in hci_le_remote_conn_param_req_evt()
6836 cp.timeout = ev->timeout; in hci_le_remote_conn_param_req_evt()
6851 flex_array_size(ev, info, ev->num))) in hci_le_direct_adv_report_evt()
6854 if (!ev->num) in hci_le_direct_adv_report_evt()
6859 for (i = 0; i < ev->num; i++) { in hci_le_direct_adv_report_evt()
6860 struct hci_ev_le_direct_adv_info *info = &ev->info[i]; in hci_le_direct_adv_report_evt()
6862 process_adv_report(hdev, info->type, &info->bdaddr, in hci_le_direct_adv_report_evt()
6863 info->bdaddr_type, &info->direct_addr, in hci_le_direct_adv_report_evt()
6864 info->direct_addr_type, info->rssi, NULL, 0, in hci_le_direct_adv_report_evt()
6877 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_phy_update_evt()
6879 if (ev->status) in hci_le_phy_update_evt()
6884 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_phy_update_evt()
6888 conn->le_tx_phy = ev->tx_phy; in hci_le_phy_update_evt()
6889 conn->le_rx_phy = ev->rx_phy; in hci_le_phy_update_evt()
6902 u16 handle = __le16_to_cpu(ev->handle); in hci_le_cis_estabilished_evt()
6904 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_cis_estabilished_evt()
6911 "Unable to find connection with handle 0x%4.4x", in hci_le_cis_estabilished_evt()
6916 if (conn->type != ISO_LINK) { in hci_le_cis_estabilished_evt()
6918 "Invalid connection link type handle 0x%4.4x", in hci_le_cis_estabilished_evt()
6923 qos = &conn->iso_qos; in hci_le_cis_estabilished_evt()
6925 pending = test_and_clear_bit(HCI_CONN_CREATE_CIS, &conn->flags); in hci_le_cis_estabilished_evt()
6928 qos->ucast.in.interval = le16_to_cpu(ev->interval) * 1250; in hci_le_cis_estabilished_evt()
6929 qos->ucast.out.interval = qos->ucast.in.interval; in hci_le_cis_estabilished_evt()
6931 switch (conn->role) { in hci_le_cis_estabilished_evt()
6934 qos->ucast.in.latency = in hci_le_cis_estabilished_evt()
6935 DIV_ROUND_CLOSEST(get_unaligned_le24(ev->c_latency), in hci_le_cis_estabilished_evt()
6937 qos->ucast.out.latency = in hci_le_cis_estabilished_evt()
6938 DIV_ROUND_CLOSEST(get_unaligned_le24(ev->p_latency), in hci_le_cis_estabilished_evt()
6940 qos->ucast.in.sdu = le16_to_cpu(ev->c_mtu); in hci_le_cis_estabilished_evt()
6941 qos->ucast.out.sdu = le16_to_cpu(ev->p_mtu); in hci_le_cis_estabilished_evt()
6942 qos->ucast.in.phy = ev->c_phy; in hci_le_cis_estabilished_evt()
6943 qos->ucast.out.phy = ev->p_phy; in hci_le_cis_estabilished_evt()
6947 qos->ucast.out.latency = in hci_le_cis_estabilished_evt()
6948 DIV_ROUND_CLOSEST(get_unaligned_le24(ev->c_latency), in hci_le_cis_estabilished_evt()
6950 qos->ucast.in.latency = in hci_le_cis_estabilished_evt()
6951 DIV_ROUND_CLOSEST(get_unaligned_le24(ev->p_latency), in hci_le_cis_estabilished_evt()
6953 qos->ucast.out.sdu = le16_to_cpu(ev->c_mtu); in hci_le_cis_estabilished_evt()
6954 qos->ucast.in.sdu = le16_to_cpu(ev->p_mtu); in hci_le_cis_estabilished_evt()
6955 qos->ucast.out.phy = ev->c_phy; in hci_le_cis_estabilished_evt()
6956 qos->ucast.in.phy = ev->p_phy; in hci_le_cis_estabilished_evt()
6960 if (!ev->status) { in hci_le_cis_estabilished_evt()
6961 conn->state = BT_CONNECTED; in hci_le_cis_estabilished_evt()
6968 conn->state = BT_CLOSED; in hci_le_cis_estabilished_evt()
6969 hci_connect_cfm(conn, ev->status); in hci_le_cis_estabilished_evt()
7007 acl_handle = __le16_to_cpu(ev->acl_handle); in hci_le_cis_req_evt()
7008 cis_handle = __le16_to_cpu(ev->cis_handle); in hci_le_cis_req_evt()
7010 bt_dev_dbg(hdev, "acl 0x%4.4x handle 0x%4.4x cig 0x%2.2x cis 0x%2.2x", in hci_le_cis_req_evt()
7011 acl_handle, cis_handle, ev->cig_id, ev->cis_id); in hci_le_cis_req_evt()
7019 mask = hci_proto_connect_ind(hdev, &acl->dst, ISO_LINK, &flags); in hci_le_cis_req_evt()
7021 hci_le_reject_cis(hdev, ev->cis_handle); in hci_le_cis_req_evt()
7027 cis = hci_conn_add(hdev, ISO_LINK, &acl->dst, HCI_ROLE_SLAVE, in hci_le_cis_req_evt()
7030 hci_le_reject_cis(hdev, ev->cis_handle); in hci_le_cis_req_evt()
7035 cis->iso_qos.ucast.cig = ev->cig_id; in hci_le_cis_req_evt()
7036 cis->iso_qos.ucast.cis = ev->cis_id; in hci_le_cis_req_evt()
7039 hci_le_accept_cis(hdev, ev->cis_handle); in hci_le_cis_req_evt()
7041 cis->state = BT_CONNECT2; in hci_le_cis_req_evt()
7064 BT_DBG("%s status 0x%2.2x", hdev->name, ev->status); in hci_le_create_big_complete_evt()
7067 flex_array_size(ev, bis_handle, ev->num_bis))) in hci_le_create_big_complete_evt()
7074 list_for_each_entry_rcu(conn, &hdev->conn_hash.list, list) { in hci_le_create_big_complete_evt()
7075 if (bacmp(&conn->dst, BDADDR_ANY) || in hci_le_create_big_complete_evt()
7076 conn->type != ISO_LINK || in hci_le_create_big_complete_evt()
7077 conn->iso_qos.bcast.big != ev->handle) in hci_le_create_big_complete_evt()
7081 __le16_to_cpu(ev->bis_handle[i++]))) in hci_le_create_big_complete_evt()
7084 if (!ev->status) { in hci_le_create_big_complete_evt()
7085 conn->state = BT_CONNECTED; in hci_le_create_big_complete_evt()
7086 set_bit(HCI_CONN_BIG_CREATED, &conn->flags); in hci_le_create_big_complete_evt()
7095 hci_connect_cfm(conn, ev->status); in hci_le_create_big_complete_evt()
7103 if (!ev->status && !i) in hci_le_create_big_complete_evt()
7110 UINT_PTR(ev->handle), NULL); in hci_le_create_big_complete_evt()
7122 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_big_sync_established_evt()
7125 flex_array_size(ev, bis, ev->num_bis))) in hci_le_big_sync_established_evt()
7130 for (i = 0; i < ev->num_bis; i++) { in hci_le_big_sync_established_evt()
7131 u16 handle = le16_to_cpu(ev->bis[i]); in hci_le_big_sync_established_evt()
7142 if (ev->status != 0x42) in hci_le_big_sync_established_evt()
7144 set_bit(HCI_CONN_PA_SYNC, &bis->flags); in hci_le_big_sync_established_evt()
7146 bis->iso_qos.bcast.big = ev->handle; in hci_le_big_sync_established_evt()
7148 memcpy(&interval, ev->latency, sizeof(ev->latency)); in hci_le_big_sync_established_evt()
7149 bis->iso_qos.bcast.in.interval = le32_to_cpu(interval); in hci_le_big_sync_established_evt()
7151 bis->iso_qos.bcast.in.latency = le16_to_cpu(ev->interval) * 125 / 100; in hci_le_big_sync_established_evt()
7152 bis->iso_qos.bcast.in.sdu = le16_to_cpu(ev->max_pdu); in hci_le_big_sync_established_evt()
7154 if (!ev->status) { in hci_le_big_sync_established_evt()
7155 set_bit(HCI_CONN_BIG_SYNC, &bis->flags); in hci_le_big_sync_established_evt()
7163 if (ev->status) in hci_le_big_sync_established_evt()
7164 for (i = 0; i < ev->num_bis; i++) { in hci_le_big_sync_established_evt()
7165 u16 handle = le16_to_cpu(ev->bis[i]); in hci_le_big_sync_established_evt()
7169 set_bit(HCI_CONN_BIG_SYNC_FAILED, &bis->flags); in hci_le_big_sync_established_evt()
7170 hci_connect_cfm(bis, ev->status); in hci_le_big_sync_established_evt()
7180 int mask = hdev->link_mode; in hci_le_big_info_adv_report_evt()
7184 bt_dev_dbg(hdev, "sync_handle 0x%4.4x", le16_to_cpu(ev->sync_handle)); in hci_le_big_info_adv_report_evt()
7190 hci_le_pa_term_sync(hdev, ev->sync_handle); in hci_le_big_info_adv_report_evt()
7199 le16_to_cpu(ev->sync_handle)); in hci_le_big_info_adv_report_evt()
7211 pa_sync->sync_handle = le16_to_cpu(ev->sync_handle); in hci_le_big_info_adv_report_evt()
7212 set_bit(HCI_CONN_PA_SYNC, &pa_sync->flags); in hci_le_big_info_adv_report_evt()
7324 bt_dev_dbg(hdev, "subevent 0x%2.2x", ev->subevent); in hci_le_meta_evt()
7327 if (hdev->sent_cmd && in hci_le_meta_evt()
7328 hci_opcode_ogf(hci_skb_opcode(hdev->sent_cmd)) == 0x08 && in hci_le_meta_evt()
7329 hci_skb_event(hdev->sent_cmd) == ev->subevent) { in hci_le_meta_evt()
7330 *opcode = hci_skb_opcode(hdev->sent_cmd); in hci_le_meta_evt()
7335 subev = &hci_le_ev_table[ev->subevent]; in hci_le_meta_evt()
7336 if (!subev->func) in hci_le_meta_evt()
7339 if (skb->len < subev->min_len) { in hci_le_meta_evt()
7340 bt_dev_err(hdev, "unexpected subevent 0x%2.2x length: %u < %u", in hci_le_meta_evt()
7341 ev->subevent, skb->len, subev->min_len); in hci_le_meta_evt()
7349 if (skb->len > subev->max_len) in hci_le_meta_evt()
7350 bt_dev_warn(hdev, "unexpected subevent 0x%2.2x length: %u > %u", in hci_le_meta_evt()
7351 ev->subevent, skb->len, subev->max_len); in hci_le_meta_evt()
7352 data = hci_le_ev_skb_pull(hdev, skb, ev->subevent, subev->min_len); in hci_le_meta_evt()
7356 subev->func(hdev, data, skb); in hci_le_meta_evt()
7373 if (hdr->evt != event) in hci_get_cmd_complete()
7378 /* Check if request ended in Command Status - no way to retrieve in hci_get_cmd_complete()
7381 if (hdr->evt == HCI_EV_CMD_STATUS) in hci_get_cmd_complete()
7384 if (hdr->evt != HCI_EV_CMD_COMPLETE) { in hci_get_cmd_complete()
7385 bt_dev_err(hdev, "last event is not cmd complete (0x%2.2x)", in hci_get_cmd_complete()
7386 hdr->evt); in hci_get_cmd_complete()
7394 if (opcode != __le16_to_cpu(ev->opcode)) { in hci_get_cmd_complete()
7395 BT_DBG("opcode doesn't match (0x%2.2x != 0x%2.2x)", opcode, in hci_get_cmd_complete()
7396 __le16_to_cpu(ev->opcode)); in hci_get_cmd_complete()
7409 const struct hci_ev_conn_complete *conn_complete = (void *)skb->data; in hci_store_wake_reason()
7410 const struct hci_ev_conn_request *conn_request = (void *)skb->data; in hci_store_wake_reason()
7417 if (!hdev->suspended || hdev->wake_reason) in hci_store_wake_reason()
7423 hdev->wake_reason = MGMT_WAKE_REASON_REMOTE_WAKE; in hci_store_wake_reason()
7430 bacpy(&hdev->wake_addr, &conn_request->bdaddr); in hci_store_wake_reason()
7431 hdev->wake_addr_type = BDADDR_BREDR; in hci_store_wake_reason()
7433 bacpy(&hdev->wake_addr, &conn_complete->bdaddr); in hci_store_wake_reason()
7434 hdev->wake_addr_type = BDADDR_BREDR; in hci_store_wake_reason()
7436 struct hci_ev_le_meta *le_ev = (void *)skb->data; in hci_store_wake_reason()
7437 u8 subevent = le_ev->subevent; in hci_store_wake_reason()
7438 u8 *ptr = &skb->data[sizeof(*le_ev)]; in hci_store_wake_reason()
7451 bacpy(&hdev->wake_addr, &adv->bdaddr); in hci_store_wake_reason()
7452 hdev->wake_addr_type = adv->bdaddr_type; in hci_store_wake_reason()
7455 bacpy(&hdev->wake_addr, &direct_adv->bdaddr); in hci_store_wake_reason()
7456 hdev->wake_addr_type = direct_adv->bdaddr_type; in hci_store_wake_reason()
7459 bacpy(&hdev->wake_addr, &ext_adv->bdaddr); in hci_store_wake_reason()
7460 hdev->wake_addr_type = ext_adv->bdaddr_type; in hci_store_wake_reason()
7465 hdev->wake_reason = MGMT_WAKE_REASON_UNEXPECTED; in hci_store_wake_reason()
7663 if (!ev->func) in hci_event_func()
7666 if (skb->len < ev->min_len) { in hci_event_func()
7667 bt_dev_err(hdev, "unexpected event 0x%2.2x length: %u < %u", in hci_event_func()
7668 event, skb->len, ev->min_len); in hci_event_func()
7676 if (skb->len > ev->max_len) in hci_event_func()
7678 "unexpected event 0x%2.2x length: %u > %u", in hci_event_func()
7679 event, skb->len, ev->max_len); in hci_event_func()
7681 data = hci_ev_skb_pull(hdev, skb, event, ev->min_len); in hci_event_func()
7685 if (ev->req) in hci_event_func()
7686 ev->func_req(hdev, data, skb, opcode, status, req_complete, in hci_event_func()
7689 ev->func(hdev, data, skb); in hci_event_func()
7694 struct hci_event_hdr *hdr = (void *) skb->data; in hci_event_packet()
7701 if (skb->len < sizeof(*hdr)) { in hci_event_packet()
7706 kfree_skb(hdev->recv_event); in hci_event_packet()
7707 hdev->recv_event = skb_clone(skb, GFP_KERNEL); in hci_event_packet()
7709 event = hdr->evt; in hci_event_packet()
7711 bt_dev_warn(hdev, "Received unexpected HCI Event 0x%2.2x", in hci_event_packet()
7717 if (hdev->sent_cmd && in hci_event_packet()
7718 hci_opcode_ogf(hci_skb_opcode(hdev->sent_cmd)) != 0x08 && in hci_event_packet()
7719 hci_skb_event(hdev->sent_cmd) == event) { in hci_event_packet()
7720 hci_req_cmd_complete(hdev, hci_skb_opcode(hdev->sent_cmd), in hci_event_packet()
7739 bt_dev_dbg(hdev, "event 0x%2.2x", event); in hci_event_packet()
7757 hdev->stat.evt_rx++; in hci_event_packet()