Lines Matching +full:local +full:- +full:bd +full:- +full:address +full:- +full:broken

2    BlueZ - Bluetooth protocol stack for Linux
3 Copyright (c) 2000-2001, 2010, Code Aurora Forum. All rights reserved.
4 Copyright 2023-2024 NXP
88 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_inquiry_cancel()
97 if (rp->status == HCI_ERROR_COMMAND_DISALLOWED && !test_bit(HCI_INQUIRY, &hdev->flags)) { in hci_cc_inquiry_cancel()
99 rp->status = 0x00; in hci_cc_inquiry_cancel()
102 if (rp->status) in hci_cc_inquiry_cancel()
103 return rp->status; in hci_cc_inquiry_cancel()
105 clear_bit(HCI_INQUIRY, &hdev->flags); in hci_cc_inquiry_cancel()
107 wake_up_bit(&hdev->flags, HCI_INQUIRY); in hci_cc_inquiry_cancel()
114 hdev->le_scan_type != LE_SCAN_ACTIVE) in hci_cc_inquiry_cancel()
118 return rp->status; in hci_cc_inquiry_cancel()
126 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_periodic_inq()
128 if (rp->status) in hci_cc_periodic_inq()
129 return rp->status; in hci_cc_periodic_inq()
133 return rp->status; in hci_cc_periodic_inq()
141 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_exit_periodic_inq()
143 if (rp->status) in hci_cc_exit_periodic_inq()
144 return rp->status; in hci_cc_exit_periodic_inq()
148 return rp->status; in hci_cc_exit_periodic_inq()
156 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_remote_name_req_cancel()
158 return rp->status; in hci_cc_remote_name_req_cancel()
167 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_role_discovery()
169 if (rp->status) in hci_cc_role_discovery()
170 return rp->status; in hci_cc_role_discovery()
174 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_role_discovery()
176 conn->role = rp->role; in hci_cc_role_discovery()
180 return rp->status; in hci_cc_role_discovery()
189 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_link_policy()
191 if (rp->status) in hci_cc_read_link_policy()
192 return rp->status; in hci_cc_read_link_policy()
196 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_link_policy()
198 conn->link_policy = __le16_to_cpu(rp->policy); in hci_cc_read_link_policy()
202 return rp->status; in hci_cc_read_link_policy()
212 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_link_policy()
214 if (rp->status) in hci_cc_write_link_policy()
215 return rp->status; in hci_cc_write_link_policy()
219 return rp->status; in hci_cc_write_link_policy()
223 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_write_link_policy()
225 conn->link_policy = get_unaligned_le16(sent + 2); in hci_cc_write_link_policy()
229 return rp->status; in hci_cc_write_link_policy()
237 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_def_link_policy()
239 if (rp->status) in hci_cc_read_def_link_policy()
240 return rp->status; in hci_cc_read_def_link_policy()
242 hdev->link_policy = __le16_to_cpu(rp->policy); in hci_cc_read_def_link_policy()
244 return rp->status; in hci_cc_read_def_link_policy()
253 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_def_link_policy()
255 if (rp->status) in hci_cc_write_def_link_policy()
256 return rp->status; in hci_cc_write_def_link_policy()
260 return rp->status; in hci_cc_write_def_link_policy()
262 hdev->link_policy = get_unaligned_le16(sent); in hci_cc_write_def_link_policy()
264 return rp->status; in hci_cc_write_def_link_policy()
271 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_reset()
273 clear_bit(HCI_RESET, &hdev->flags); in hci_cc_reset()
275 if (rp->status) in hci_cc_reset()
276 return rp->status; in hci_cc_reset()
278 /* Reset all non-persistent flags */ in hci_cc_reset()
283 hdev->inq_tx_power = HCI_TX_POWER_INVALID; in hci_cc_reset()
284 hdev->adv_tx_power = HCI_TX_POWER_INVALID; in hci_cc_reset()
286 memset(hdev->adv_data, 0, sizeof(hdev->adv_data)); in hci_cc_reset()
287 hdev->adv_data_len = 0; in hci_cc_reset()
289 memset(hdev->scan_rsp_data, 0, sizeof(hdev->scan_rsp_data)); in hci_cc_reset()
290 hdev->scan_rsp_data_len = 0; in hci_cc_reset()
292 hdev->le_scan_type = LE_SCAN_PASSIVE; in hci_cc_reset()
294 hdev->ssp_debug_mode = 0; in hci_cc_reset()
296 hci_bdaddr_list_clear(&hdev->le_accept_list); in hci_cc_reset()
297 hci_bdaddr_list_clear(&hdev->le_resolv_list); in hci_cc_reset()
299 return rp->status; in hci_cc_reset()
308 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_stored_link_key()
312 return rp->status; in hci_cc_read_stored_link_key()
314 if (!rp->status && sent->read_all == 0x01) { in hci_cc_read_stored_link_key()
315 hdev->stored_max_keys = le16_to_cpu(rp->max_keys); in hci_cc_read_stored_link_key()
316 hdev->stored_num_keys = le16_to_cpu(rp->num_keys); in hci_cc_read_stored_link_key()
319 return rp->status; in hci_cc_read_stored_link_key()
328 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_delete_stored_link_key()
330 if (rp->status) in hci_cc_delete_stored_link_key()
331 return rp->status; in hci_cc_delete_stored_link_key()
333 num_keys = le16_to_cpu(rp->num_keys); in hci_cc_delete_stored_link_key()
335 if (num_keys <= hdev->stored_num_keys) in hci_cc_delete_stored_link_key()
336 hdev->stored_num_keys -= num_keys; in hci_cc_delete_stored_link_key()
338 hdev->stored_num_keys = 0; in hci_cc_delete_stored_link_key()
340 return rp->status; in hci_cc_delete_stored_link_key()
349 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_local_name()
353 return rp->status; in hci_cc_write_local_name()
358 mgmt_set_local_name_complete(hdev, sent, rp->status); in hci_cc_write_local_name()
359 else if (!rp->status) in hci_cc_write_local_name()
360 memcpy(hdev->dev_name, sent, HCI_MAX_NAME_LENGTH); in hci_cc_write_local_name()
364 return rp->status; in hci_cc_write_local_name()
372 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_name()
374 if (rp->status) in hci_cc_read_local_name()
375 return rp->status; in hci_cc_read_local_name()
379 memcpy(hdev->dev_name, rp->name, HCI_MAX_NAME_LENGTH); in hci_cc_read_local_name()
381 return rp->status; in hci_cc_read_local_name()
390 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_auth_enable()
394 return rp->status; in hci_cc_write_auth_enable()
398 if (!rp->status) { in hci_cc_write_auth_enable()
402 set_bit(HCI_AUTH, &hdev->flags); in hci_cc_write_auth_enable()
404 clear_bit(HCI_AUTH, &hdev->flags); in hci_cc_write_auth_enable()
408 mgmt_auth_enable_complete(hdev, rp->status); in hci_cc_write_auth_enable()
412 return rp->status; in hci_cc_write_auth_enable()
422 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_encrypt_mode()
424 if (rp->status) in hci_cc_write_encrypt_mode()
425 return rp->status; in hci_cc_write_encrypt_mode()
429 return rp->status; in hci_cc_write_encrypt_mode()
434 set_bit(HCI_ENCRYPT, &hdev->flags); in hci_cc_write_encrypt_mode()
436 clear_bit(HCI_ENCRYPT, &hdev->flags); in hci_cc_write_encrypt_mode()
438 return rp->status; in hci_cc_write_encrypt_mode()
448 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_scan_enable()
452 return rp->status; in hci_cc_write_scan_enable()
458 if (rp->status) { in hci_cc_write_scan_enable()
459 hdev->discov_timeout = 0; in hci_cc_write_scan_enable()
464 set_bit(HCI_ISCAN, &hdev->flags); in hci_cc_write_scan_enable()
466 clear_bit(HCI_ISCAN, &hdev->flags); in hci_cc_write_scan_enable()
469 set_bit(HCI_PSCAN, &hdev->flags); in hci_cc_write_scan_enable()
471 clear_bit(HCI_PSCAN, &hdev->flags); in hci_cc_write_scan_enable()
476 return rp->status; in hci_cc_write_scan_enable()
486 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_set_event_filter()
488 if (rp->status) in hci_cc_set_event_filter()
489 return rp->status; in hci_cc_set_event_filter()
493 return rp->status; in hci_cc_set_event_filter()
497 if (cp->flt_type == HCI_FLT_CLEAR_ALL) in hci_cc_set_event_filter()
502 return rp->status; in hci_cc_set_event_filter()
513 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_class_of_dev()
515 if (rp->status) in hci_cc_read_class_of_dev()
516 return rp->status; in hci_cc_read_class_of_dev()
518 memcpy(hdev->dev_class, rp->dev_class, 3); in hci_cc_read_class_of_dev()
520 bt_dev_dbg(hdev, "class 0x%.2x%.2x%.2x", hdev->dev_class[2], in hci_cc_read_class_of_dev()
521 hdev->dev_class[1], hdev->dev_class[0]); in hci_cc_read_class_of_dev()
523 return rp->status; in hci_cc_read_class_of_dev()
532 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_class_of_dev()
536 return rp->status; in hci_cc_write_class_of_dev()
540 if (!rp->status) in hci_cc_write_class_of_dev()
541 memcpy(hdev->dev_class, sent, 3); in hci_cc_write_class_of_dev()
544 mgmt_set_class_of_dev_complete(hdev, sent, rp->status); in hci_cc_write_class_of_dev()
548 return rp->status; in hci_cc_write_class_of_dev()
557 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_voice_setting()
559 if (rp->status) in hci_cc_read_voice_setting()
560 return rp->status; in hci_cc_read_voice_setting()
562 setting = __le16_to_cpu(rp->voice_setting); in hci_cc_read_voice_setting()
564 if (hdev->voice_setting == setting) in hci_cc_read_voice_setting()
565 return rp->status; in hci_cc_read_voice_setting()
567 hdev->voice_setting = setting; in hci_cc_read_voice_setting()
571 if (hdev->notify) in hci_cc_read_voice_setting()
572 hdev->notify(hdev, HCI_NOTIFY_VOICE_SETTING); in hci_cc_read_voice_setting()
574 return rp->status; in hci_cc_read_voice_setting()
584 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_voice_setting()
586 if (rp->status) in hci_cc_write_voice_setting()
587 return rp->status; in hci_cc_write_voice_setting()
591 return rp->status; in hci_cc_write_voice_setting()
595 if (hdev->voice_setting == setting) in hci_cc_write_voice_setting()
596 return rp->status; in hci_cc_write_voice_setting()
598 hdev->voice_setting = setting; in hci_cc_write_voice_setting()
602 if (hdev->notify) in hci_cc_write_voice_setting()
603 hdev->notify(hdev, HCI_NOTIFY_VOICE_SETTING); in hci_cc_write_voice_setting()
605 return rp->status; in hci_cc_write_voice_setting()
613 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_num_supported_iac()
615 if (rp->status) in hci_cc_read_num_supported_iac()
616 return rp->status; in hci_cc_read_num_supported_iac()
618 hdev->num_iac = rp->num_iac; in hci_cc_read_num_supported_iac()
620 bt_dev_dbg(hdev, "num iac %d", hdev->num_iac); in hci_cc_read_num_supported_iac()
622 return rp->status; in hci_cc_read_num_supported_iac()
631 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_ssp_mode()
635 return rp->status; in hci_cc_write_ssp_mode()
639 if (!rp->status) { in hci_cc_write_ssp_mode()
640 if (sent->mode) in hci_cc_write_ssp_mode()
641 hdev->features[1][0] |= LMP_HOST_SSP; in hci_cc_write_ssp_mode()
643 hdev->features[1][0] &= ~LMP_HOST_SSP; in hci_cc_write_ssp_mode()
646 if (!rp->status) { in hci_cc_write_ssp_mode()
647 if (sent->mode) in hci_cc_write_ssp_mode()
655 return rp->status; in hci_cc_write_ssp_mode()
664 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_sc_support()
668 return rp->status; in hci_cc_write_sc_support()
672 if (!rp->status) { in hci_cc_write_sc_support()
673 if (sent->support) in hci_cc_write_sc_support()
674 hdev->features[1][0] |= LMP_HOST_SC; in hci_cc_write_sc_support()
676 hdev->features[1][0] &= ~LMP_HOST_SC; in hci_cc_write_sc_support()
679 if (!hci_dev_test_flag(hdev, HCI_MGMT) && !rp->status) { in hci_cc_write_sc_support()
680 if (sent->support) in hci_cc_write_sc_support()
688 return rp->status; in hci_cc_write_sc_support()
696 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_version()
698 if (rp->status) in hci_cc_read_local_version()
699 return rp->status; in hci_cc_read_local_version()
703 hdev->hci_ver = rp->hci_ver; in hci_cc_read_local_version()
704 hdev->hci_rev = __le16_to_cpu(rp->hci_rev); in hci_cc_read_local_version()
705 hdev->lmp_ver = rp->lmp_ver; in hci_cc_read_local_version()
706 hdev->manufacturer = __le16_to_cpu(rp->manufacturer); in hci_cc_read_local_version()
707 hdev->lmp_subver = __le16_to_cpu(rp->lmp_subver); in hci_cc_read_local_version()
710 return rp->status; in hci_cc_read_local_version()
719 u8 status = rp->status; in hci_cc_read_enc_key_size()
723 handle = le16_to_cpu(rp->handle); in hci_cc_read_enc_key_size()
740 conn->enc_key_size = 0; in hci_cc_read_enc_key_size()
744 conn->enc_key_size = rp->key_size; in hci_cc_read_enc_key_size()
751 if (conn->enc_key_size < hdev->min_enc_key_size || in hci_cc_read_enc_key_size()
752 (key_enc_size && conn->enc_key_size < *key_enc_size)) { in hci_cc_read_enc_key_size()
753 /* As slave role, the conn->state has been set to in hci_cc_read_enc_key_size()
756 * nothing with the non-zero status. in hci_cc_read_enc_key_size()
762 clear_bit(HCI_CONN_ENCRYPT, &conn->flags); in hci_cc_read_enc_key_size()
763 clear_bit(HCI_CONN_AES_CCM, &conn->flags); in hci_cc_read_enc_key_size()
767 if (key_enc_size && *key_enc_size != conn->enc_key_size) in hci_cc_read_enc_key_size()
768 *key_enc_size = conn->enc_key_size; in hci_cc_read_enc_key_size()
784 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_commands()
786 if (rp->status) in hci_cc_read_local_commands()
787 return rp->status; in hci_cc_read_local_commands()
791 memcpy(hdev->commands, rp->commands, sizeof(hdev->commands)); in hci_cc_read_local_commands()
793 return rp->status; in hci_cc_read_local_commands()
802 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_auth_payload_timeout()
804 if (rp->status) in hci_cc_read_auth_payload_timeout()
805 return rp->status; in hci_cc_read_auth_payload_timeout()
809 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_auth_payload_timeout()
811 conn->auth_payload_timeout = __le16_to_cpu(rp->timeout); in hci_cc_read_auth_payload_timeout()
815 return rp->status; in hci_cc_read_auth_payload_timeout()
825 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_auth_payload_timeout()
829 return rp->status; in hci_cc_write_auth_payload_timeout()
833 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_write_auth_payload_timeout()
835 rp->status = 0xff; in hci_cc_write_auth_payload_timeout()
839 if (!rp->status) in hci_cc_write_auth_payload_timeout()
840 conn->auth_payload_timeout = get_unaligned_le16(sent + 2); in hci_cc_write_auth_payload_timeout()
845 return rp->status; in hci_cc_write_auth_payload_timeout()
853 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_features()
855 if (rp->status) in hci_cc_read_local_features()
856 return rp->status; in hci_cc_read_local_features()
858 memcpy(hdev->features, rp->features, 8); in hci_cc_read_local_features()
863 if (hdev->features[0][0] & LMP_3SLOT) in hci_cc_read_local_features()
864 hdev->pkt_type |= (HCI_DM3 | HCI_DH3); in hci_cc_read_local_features()
866 if (hdev->features[0][0] & LMP_5SLOT) in hci_cc_read_local_features()
867 hdev->pkt_type |= (HCI_DM5 | HCI_DH5); in hci_cc_read_local_features()
869 if (hdev->features[0][1] & LMP_HV2) { in hci_cc_read_local_features()
870 hdev->pkt_type |= (HCI_HV2); in hci_cc_read_local_features()
871 hdev->esco_type |= (ESCO_HV2); in hci_cc_read_local_features()
874 if (hdev->features[0][1] & LMP_HV3) { in hci_cc_read_local_features()
875 hdev->pkt_type |= (HCI_HV3); in hci_cc_read_local_features()
876 hdev->esco_type |= (ESCO_HV3); in hci_cc_read_local_features()
880 hdev->esco_type |= (ESCO_EV3); in hci_cc_read_local_features()
882 if (hdev->features[0][4] & LMP_EV4) in hci_cc_read_local_features()
883 hdev->esco_type |= (ESCO_EV4); in hci_cc_read_local_features()
885 if (hdev->features[0][4] & LMP_EV5) in hci_cc_read_local_features()
886 hdev->esco_type |= (ESCO_EV5); in hci_cc_read_local_features()
888 if (hdev->features[0][5] & LMP_EDR_ESCO_2M) in hci_cc_read_local_features()
889 hdev->esco_type |= (ESCO_2EV3); in hci_cc_read_local_features()
891 if (hdev->features[0][5] & LMP_EDR_ESCO_3M) in hci_cc_read_local_features()
892 hdev->esco_type |= (ESCO_3EV3); in hci_cc_read_local_features()
894 if (hdev->features[0][5] & LMP_EDR_3S_ESCO) in hci_cc_read_local_features()
895 hdev->esco_type |= (ESCO_2EV5 | ESCO_3EV5); in hci_cc_read_local_features()
897 return rp->status; in hci_cc_read_local_features()
905 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_ext_features()
907 if (rp->status) in hci_cc_read_local_ext_features()
908 return rp->status; in hci_cc_read_local_ext_features()
910 if (hdev->max_page < rp->max_page) { in hci_cc_read_local_ext_features()
912 &hdev->quirks)) in hci_cc_read_local_ext_features()
913 bt_dev_warn(hdev, "broken local ext features page 2"); in hci_cc_read_local_ext_features()
915 hdev->max_page = rp->max_page; in hci_cc_read_local_ext_features()
918 if (rp->page < HCI_MAX_PAGES) in hci_cc_read_local_ext_features()
919 memcpy(hdev->features[rp->page], rp->features, 8); in hci_cc_read_local_ext_features()
921 return rp->status; in hci_cc_read_local_ext_features()
929 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_buffer_size()
931 if (rp->status) in hci_cc_read_buffer_size()
932 return rp->status; in hci_cc_read_buffer_size()
934 hdev->acl_mtu = __le16_to_cpu(rp->acl_mtu); in hci_cc_read_buffer_size()
935 hdev->sco_mtu = rp->sco_mtu; in hci_cc_read_buffer_size()
936 hdev->acl_pkts = __le16_to_cpu(rp->acl_max_pkt); in hci_cc_read_buffer_size()
937 hdev->sco_pkts = __le16_to_cpu(rp->sco_max_pkt); in hci_cc_read_buffer_size()
939 if (test_bit(HCI_QUIRK_FIXUP_BUFFER_SIZE, &hdev->quirks)) { in hci_cc_read_buffer_size()
940 hdev->sco_mtu = 64; in hci_cc_read_buffer_size()
941 hdev->sco_pkts = 8; in hci_cc_read_buffer_size()
945 hdev->sco_pkts = 0; in hci_cc_read_buffer_size()
947 hdev->acl_cnt = hdev->acl_pkts; in hci_cc_read_buffer_size()
948 hdev->sco_cnt = hdev->sco_pkts; in hci_cc_read_buffer_size()
950 BT_DBG("%s acl mtu %d:%d sco mtu %d:%d", hdev->name, hdev->acl_mtu, in hci_cc_read_buffer_size()
951 hdev->acl_pkts, hdev->sco_mtu, hdev->sco_pkts); in hci_cc_read_buffer_size()
953 if (!hdev->acl_mtu || !hdev->acl_pkts) in hci_cc_read_buffer_size()
956 return rp->status; in hci_cc_read_buffer_size()
964 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_bd_addr()
966 if (rp->status) in hci_cc_read_bd_addr()
967 return rp->status; in hci_cc_read_bd_addr()
969 if (test_bit(HCI_INIT, &hdev->flags)) in hci_cc_read_bd_addr()
970 bacpy(&hdev->bdaddr, &rp->bdaddr); in hci_cc_read_bd_addr()
973 bacpy(&hdev->setup_addr, &rp->bdaddr); in hci_cc_read_bd_addr()
975 return rp->status; in hci_cc_read_bd_addr()
983 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_pairing_opts()
985 if (rp->status) in hci_cc_read_local_pairing_opts()
986 return rp->status; in hci_cc_read_local_pairing_opts()
990 hdev->pairing_opts = rp->pairing_opts; in hci_cc_read_local_pairing_opts()
991 hdev->max_enc_key_size = rp->max_key_size; in hci_cc_read_local_pairing_opts()
994 return rp->status; in hci_cc_read_local_pairing_opts()
1002 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_page_scan_activity()
1004 if (rp->status) in hci_cc_read_page_scan_activity()
1005 return rp->status; in hci_cc_read_page_scan_activity()
1007 if (test_bit(HCI_INIT, &hdev->flags)) { in hci_cc_read_page_scan_activity()
1008 hdev->page_scan_interval = __le16_to_cpu(rp->interval); in hci_cc_read_page_scan_activity()
1009 hdev->page_scan_window = __le16_to_cpu(rp->window); in hci_cc_read_page_scan_activity()
1012 return rp->status; in hci_cc_read_page_scan_activity()
1021 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_page_scan_activity()
1023 if (rp->status) in hci_cc_write_page_scan_activity()
1024 return rp->status; in hci_cc_write_page_scan_activity()
1028 return rp->status; in hci_cc_write_page_scan_activity()
1030 hdev->page_scan_interval = __le16_to_cpu(sent->interval); in hci_cc_write_page_scan_activity()
1031 hdev->page_scan_window = __le16_to_cpu(sent->window); in hci_cc_write_page_scan_activity()
1033 return rp->status; in hci_cc_write_page_scan_activity()
1041 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_page_scan_type()
1043 if (rp->status) in hci_cc_read_page_scan_type()
1044 return rp->status; in hci_cc_read_page_scan_type()
1046 if (test_bit(HCI_INIT, &hdev->flags)) in hci_cc_read_page_scan_type()
1047 hdev->page_scan_type = rp->type; in hci_cc_read_page_scan_type()
1049 return rp->status; in hci_cc_read_page_scan_type()
1058 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_page_scan_type()
1060 if (rp->status) in hci_cc_write_page_scan_type()
1061 return rp->status; in hci_cc_write_page_scan_type()
1065 hdev->page_scan_type = *type; in hci_cc_write_page_scan_type()
1067 return rp->status; in hci_cc_write_page_scan_type()
1077 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_clock()
1079 if (rp->status) in hci_cc_read_clock()
1080 return rp->status; in hci_cc_read_clock()
1088 if (cp->which == 0x00) { in hci_cc_read_clock()
1089 hdev->clock = le32_to_cpu(rp->clock); in hci_cc_read_clock()
1093 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_clock()
1095 conn->clock = le32_to_cpu(rp->clock); in hci_cc_read_clock()
1096 conn->clock_accuracy = le16_to_cpu(rp->accuracy); in hci_cc_read_clock()
1101 return rp->status; in hci_cc_read_clock()
1109 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_inq_rsp_tx_power()
1111 if (rp->status) in hci_cc_read_inq_rsp_tx_power()
1112 return rp->status; in hci_cc_read_inq_rsp_tx_power()
1114 hdev->inq_tx_power = rp->tx_power; in hci_cc_read_inq_rsp_tx_power()
1116 return rp->status; in hci_cc_read_inq_rsp_tx_power()
1124 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_def_err_data_reporting()
1126 if (rp->status) in hci_cc_read_def_err_data_reporting()
1127 return rp->status; in hci_cc_read_def_err_data_reporting()
1129 hdev->err_data_reporting = rp->err_data_reporting; in hci_cc_read_def_err_data_reporting()
1131 return rp->status; in hci_cc_read_def_err_data_reporting()
1140 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_def_err_data_reporting()
1142 if (rp->status) in hci_cc_write_def_err_data_reporting()
1143 return rp->status; in hci_cc_write_def_err_data_reporting()
1147 return rp->status; in hci_cc_write_def_err_data_reporting()
1149 hdev->err_data_reporting = cp->err_data_reporting; in hci_cc_write_def_err_data_reporting()
1151 return rp->status; in hci_cc_write_def_err_data_reporting()
1161 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_pin_code_reply()
1166 mgmt_pin_code_reply_complete(hdev, &rp->bdaddr, rp->status); in hci_cc_pin_code_reply()
1168 if (rp->status) in hci_cc_pin_code_reply()
1175 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cc_pin_code_reply()
1177 conn->pin_length = cp->pin_len; in hci_cc_pin_code_reply()
1181 return rp->status; in hci_cc_pin_code_reply()
1189 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_pin_code_neg_reply()
1194 mgmt_pin_code_neg_reply_complete(hdev, &rp->bdaddr, in hci_cc_pin_code_neg_reply()
1195 rp->status); in hci_cc_pin_code_neg_reply()
1199 return rp->status; in hci_cc_pin_code_neg_reply()
1207 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_read_buffer_size()
1209 if (rp->status) in hci_cc_le_read_buffer_size()
1210 return rp->status; in hci_cc_le_read_buffer_size()
1212 hdev->le_mtu = __le16_to_cpu(rp->le_mtu); in hci_cc_le_read_buffer_size()
1213 hdev->le_pkts = rp->le_max_pkt; in hci_cc_le_read_buffer_size()
1215 hdev->le_cnt = hdev->le_pkts; in hci_cc_le_read_buffer_size()
1217 BT_DBG("%s le mtu %d:%d", hdev->name, hdev->le_mtu, hdev->le_pkts); in hci_cc_le_read_buffer_size()
1219 if (hdev->le_mtu && hdev->le_mtu < HCI_MIN_LE_MTU) in hci_cc_le_read_buffer_size()
1222 return rp->status; in hci_cc_le_read_buffer_size()
1230 BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); in hci_cc_le_read_local_features()
1232 if (rp->status) in hci_cc_le_read_local_features()
1233 return rp->status; in hci_cc_le_read_local_features()
1235 memcpy(hdev->le_features, rp->features, 8); in hci_cc_le_read_local_features()
1237 return rp->status; in hci_cc_le_read_local_features()
1245 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_read_adv_tx_power()
1247 if (rp->status) in hci_cc_le_read_adv_tx_power()
1248 return rp->status; in hci_cc_le_read_adv_tx_power()
1250 hdev->adv_tx_power = rp->tx_power; in hci_cc_le_read_adv_tx_power()
1252 return rp->status; in hci_cc_le_read_adv_tx_power()
1260 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_user_confirm_reply()
1265 mgmt_user_confirm_reply_complete(hdev, &rp->bdaddr, ACL_LINK, 0, in hci_cc_user_confirm_reply()
1266 rp->status); in hci_cc_user_confirm_reply()
1270 return rp->status; in hci_cc_user_confirm_reply()
1278 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_user_confirm_neg_reply()
1283 mgmt_user_confirm_neg_reply_complete(hdev, &rp->bdaddr, in hci_cc_user_confirm_neg_reply()
1284 ACL_LINK, 0, rp->status); in hci_cc_user_confirm_neg_reply()
1288 return rp->status; in hci_cc_user_confirm_neg_reply()
1296 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_user_passkey_reply()
1301 mgmt_user_passkey_reply_complete(hdev, &rp->bdaddr, ACL_LINK, in hci_cc_user_passkey_reply()
1302 0, rp->status); in hci_cc_user_passkey_reply()
1306 return rp->status; in hci_cc_user_passkey_reply()
1314 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_user_passkey_neg_reply()
1319 mgmt_user_passkey_neg_reply_complete(hdev, &rp->bdaddr, in hci_cc_user_passkey_neg_reply()
1320 ACL_LINK, 0, rp->status); in hci_cc_user_passkey_neg_reply()
1324 return rp->status; in hci_cc_user_passkey_neg_reply()
1332 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_oob_data()
1334 return rp->status; in hci_cc_read_local_oob_data()
1342 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_oob_ext_data()
1344 return rp->status; in hci_cc_read_local_oob_ext_data()
1353 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_random_addr()
1355 if (rp->status) in hci_cc_le_set_random_addr()
1356 return rp->status; in hci_cc_le_set_random_addr()
1360 return rp->status; in hci_cc_le_set_random_addr()
1364 bacpy(&hdev->random_addr, sent); in hci_cc_le_set_random_addr()
1366 if (!bacmp(&hdev->rpa, sent)) { in hci_cc_le_set_random_addr()
1368 queue_delayed_work(hdev->workqueue, &hdev->rpa_expired, in hci_cc_le_set_random_addr()
1369 secs_to_jiffies(hdev->rpa_timeout)); in hci_cc_le_set_random_addr()
1374 return rp->status; in hci_cc_le_set_random_addr()
1383 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_default_phy()
1385 if (rp->status) in hci_cc_le_set_default_phy()
1386 return rp->status; in hci_cc_le_set_default_phy()
1390 return rp->status; in hci_cc_le_set_default_phy()
1394 hdev->le_tx_def_phys = cp->tx_phys; in hci_cc_le_set_default_phy()
1395 hdev->le_rx_def_phys = cp->rx_phys; in hci_cc_le_set_default_phy()
1399 return rp->status; in hci_cc_le_set_default_phy()
1409 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_adv_set_random_addr()
1411 if (rp->status) in hci_cc_le_set_adv_set_random_addr()
1412 return rp->status; in hci_cc_le_set_adv_set_random_addr()
1417 * non-extended adverting. in hci_cc_le_set_adv_set_random_addr()
1419 if (!cp || !cp->handle) in hci_cc_le_set_adv_set_random_addr()
1420 return rp->status; in hci_cc_le_set_adv_set_random_addr()
1424 adv = hci_find_adv_instance(hdev, cp->handle); in hci_cc_le_set_adv_set_random_addr()
1426 bacpy(&adv->random_addr, &cp->bdaddr); in hci_cc_le_set_adv_set_random_addr()
1427 if (!bacmp(&hdev->rpa, &cp->bdaddr)) { in hci_cc_le_set_adv_set_random_addr()
1428 adv->rpa_expired = false; in hci_cc_le_set_adv_set_random_addr()
1429 queue_delayed_work(hdev->workqueue, in hci_cc_le_set_adv_set_random_addr()
1430 &adv->rpa_expired_cb, in hci_cc_le_set_adv_set_random_addr()
1431 secs_to_jiffies(hdev->rpa_timeout)); in hci_cc_le_set_adv_set_random_addr()
1437 return rp->status; in hci_cc_le_set_adv_set_random_addr()
1447 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_remove_adv_set()
1449 if (rp->status) in hci_cc_le_remove_adv_set()
1450 return rp->status; in hci_cc_le_remove_adv_set()
1454 return rp->status; in hci_cc_le_remove_adv_set()
1460 mgmt_advertising_removed(hci_skb_sk(hdev->sent_cmd), hdev, in hci_cc_le_remove_adv_set()
1465 return rp->status; in hci_cc_le_remove_adv_set()
1475 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_clear_adv_sets()
1477 if (rp->status) in hci_cc_le_clear_adv_sets()
1478 return rp->status; in hci_cc_le_clear_adv_sets()
1481 return rp->status; in hci_cc_le_clear_adv_sets()
1485 list_for_each_entry_safe(adv, n, &hdev->adv_instances, list) { in hci_cc_le_clear_adv_sets()
1486 u8 instance = adv->instance; in hci_cc_le_clear_adv_sets()
1490 mgmt_advertising_removed(hci_skb_sk(hdev->sent_cmd), in hci_cc_le_clear_adv_sets()
1496 return rp->status; in hci_cc_le_clear_adv_sets()
1504 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_read_transmit_power()
1506 if (rp->status) in hci_cc_le_read_transmit_power()
1507 return rp->status; in hci_cc_le_read_transmit_power()
1509 hdev->min_le_tx_power = rp->min_le_tx_power; in hci_cc_le_read_transmit_power()
1510 hdev->max_le_tx_power = rp->max_le_tx_power; in hci_cc_le_read_transmit_power()
1512 return rp->status; in hci_cc_le_read_transmit_power()
1522 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_privacy_mode()
1524 if (rp->status) in hci_cc_le_set_privacy_mode()
1525 return rp->status; in hci_cc_le_set_privacy_mode()
1529 return rp->status; in hci_cc_le_set_privacy_mode()
1533 params = hci_conn_params_lookup(hdev, &cp->bdaddr, cp->bdaddr_type); in hci_cc_le_set_privacy_mode()
1535 WRITE_ONCE(params->privacy_mode, cp->mode); in hci_cc_le_set_privacy_mode()
1539 return rp->status; in hci_cc_le_set_privacy_mode()
1548 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_adv_enable()
1550 if (rp->status) in hci_cc_le_set_adv_enable()
1551 return rp->status; in hci_cc_le_set_adv_enable()
1555 return rp->status; in hci_cc_le_set_adv_enable()
1569 queue_delayed_work(hdev->workqueue, in hci_cc_le_set_adv_enable()
1570 &conn->le_conn_timeout, in hci_cc_le_set_adv_enable()
1571 conn->conn_timeout); in hci_cc_le_set_adv_enable()
1578 return rp->status; in hci_cc_le_set_adv_enable()
1589 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_ext_adv_enable()
1591 if (rp->status) in hci_cc_le_set_ext_adv_enable()
1592 return rp->status; in hci_cc_le_set_ext_adv_enable()
1596 return rp->status; in hci_cc_le_set_ext_adv_enable()
1598 set = (void *)cp->data; in hci_cc_le_set_ext_adv_enable()
1602 if (cp->num_of_sets) in hci_cc_le_set_ext_adv_enable()
1603 adv = hci_find_adv_instance(hdev, set->handle); in hci_cc_le_set_ext_adv_enable()
1605 if (cp->enable) { in hci_cc_le_set_ext_adv_enable()
1610 if (adv && !adv->periodic) in hci_cc_le_set_ext_adv_enable()
1611 adv->enabled = true; in hci_cc_le_set_ext_adv_enable()
1615 queue_delayed_work(hdev->workqueue, in hci_cc_le_set_ext_adv_enable()
1616 &conn->le_conn_timeout, in hci_cc_le_set_ext_adv_enable()
1617 conn->conn_timeout); in hci_cc_le_set_ext_adv_enable()
1619 if (cp->num_of_sets) { in hci_cc_le_set_ext_adv_enable()
1621 adv->enabled = false; in hci_cc_le_set_ext_adv_enable()
1626 list_for_each_entry_safe(adv, n, &hdev->adv_instances, in hci_cc_le_set_ext_adv_enable()
1628 if (adv->enabled) in hci_cc_le_set_ext_adv_enable()
1633 list_for_each_entry_safe(adv, n, &hdev->adv_instances, in hci_cc_le_set_ext_adv_enable()
1635 adv->enabled = false; in hci_cc_le_set_ext_adv_enable()
1643 return rp->status; in hci_cc_le_set_ext_adv_enable()
1652 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_scan_param()
1654 if (rp->status) in hci_cc_le_set_scan_param()
1655 return rp->status; in hci_cc_le_set_scan_param()
1659 return rp->status; in hci_cc_le_set_scan_param()
1663 hdev->le_scan_type = cp->type; in hci_cc_le_set_scan_param()
1667 return rp->status; in hci_cc_le_set_scan_param()
1677 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_ext_scan_param()
1679 if (rp->status) in hci_cc_le_set_ext_scan_param()
1680 return rp->status; in hci_cc_le_set_ext_scan_param()
1684 return rp->status; in hci_cc_le_set_ext_scan_param()
1686 phy_param = (void *)cp->data; in hci_cc_le_set_ext_scan_param()
1690 hdev->le_scan_type = phy_param->type; in hci_cc_le_set_ext_scan_param()
1694 return rp->status; in hci_cc_le_set_ext_scan_param()
1699 struct discovery_state *d = &hdev->discovery; in has_pending_adv_report()
1701 return bacmp(&d->last_adv_addr, BDADDR_ANY); in has_pending_adv_report()
1706 struct discovery_state *d = &hdev->discovery; in clear_pending_adv_report()
1708 bacpy(&d->last_adv_addr, BDADDR_ANY); in clear_pending_adv_report()
1709 d->last_adv_data_len = 0; in clear_pending_adv_report()
1716 struct discovery_state *d = &hdev->discovery; in store_pending_adv_report()
1721 bacpy(&d->last_adv_addr, bdaddr); in store_pending_adv_report()
1722 d->last_adv_addr_type = bdaddr_type; in store_pending_adv_report()
1723 d->last_adv_rssi = rssi; in store_pending_adv_report()
1724 d->last_adv_flags = flags; in store_pending_adv_report()
1725 memcpy(d->last_adv_data, data, len); in store_pending_adv_report()
1726 d->last_adv_data_len = len; in store_pending_adv_report()
1736 if (hdev->le_scan_type == LE_SCAN_ACTIVE) { in le_set_scan_enable_complete()
1748 struct discovery_state *d = &hdev->discovery; in le_set_scan_enable_complete()
1750 mgmt_device_found(hdev, &d->last_adv_addr, LE_LINK, in le_set_scan_enable_complete()
1751 d->last_adv_addr_type, NULL, in le_set_scan_enable_complete()
1752 d->last_adv_rssi, d->last_adv_flags, in le_set_scan_enable_complete()
1753 d->last_adv_data, in le_set_scan_enable_complete()
1754 d->last_adv_data_len, NULL, 0, 0); in le_set_scan_enable_complete()
1760 cancel_delayed_work(&hdev->le_scan_disable); in le_set_scan_enable_complete()
1771 hdev->discovery.state == DISCOVERY_FINDING) in le_set_scan_enable_complete()
1772 queue_work(hdev->workqueue, &hdev->reenable_adv_work); in le_set_scan_enable_complete()
1791 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_scan_enable()
1793 if (rp->status) in hci_cc_le_set_scan_enable()
1794 return rp->status; in hci_cc_le_set_scan_enable()
1798 return rp->status; in hci_cc_le_set_scan_enable()
1800 le_set_scan_enable_complete(hdev, cp->enable); in hci_cc_le_set_scan_enable()
1802 return rp->status; in hci_cc_le_set_scan_enable()
1811 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_ext_scan_enable()
1813 if (rp->status) in hci_cc_le_set_ext_scan_enable()
1814 return rp->status; in hci_cc_le_set_ext_scan_enable()
1818 return rp->status; in hci_cc_le_set_ext_scan_enable()
1820 le_set_scan_enable_complete(hdev, cp->enable); in hci_cc_le_set_ext_scan_enable()
1822 return rp->status; in hci_cc_le_set_ext_scan_enable()
1830 bt_dev_dbg(hdev, "status 0x%2.2x No of Adv sets %u", rp->status, in hci_cc_le_read_num_adv_sets()
1831 rp->num_of_sets); in hci_cc_le_read_num_adv_sets()
1833 if (rp->status) in hci_cc_le_read_num_adv_sets()
1834 return rp->status; in hci_cc_le_read_num_adv_sets()
1836 hdev->le_num_of_adv_sets = rp->num_of_sets; in hci_cc_le_read_num_adv_sets()
1838 return rp->status; in hci_cc_le_read_num_adv_sets()
1846 bt_dev_dbg(hdev, "status 0x%2.2x size %u", rp->status, rp->size); in hci_cc_le_read_accept_list_size()
1848 if (rp->status) in hci_cc_le_read_accept_list_size()
1849 return rp->status; in hci_cc_le_read_accept_list_size()
1851 hdev->le_accept_list_size = rp->size; in hci_cc_le_read_accept_list_size()
1853 return rp->status; in hci_cc_le_read_accept_list_size()
1861 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_clear_accept_list()
1863 if (rp->status) in hci_cc_le_clear_accept_list()
1864 return rp->status; in hci_cc_le_clear_accept_list()
1867 hci_bdaddr_list_clear(&hdev->le_accept_list); in hci_cc_le_clear_accept_list()
1870 return rp->status; in hci_cc_le_clear_accept_list()
1879 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_add_to_accept_list()
1881 if (rp->status) in hci_cc_le_add_to_accept_list()
1882 return rp->status; in hci_cc_le_add_to_accept_list()
1886 return rp->status; in hci_cc_le_add_to_accept_list()
1889 hci_bdaddr_list_add(&hdev->le_accept_list, &sent->bdaddr, in hci_cc_le_add_to_accept_list()
1890 sent->bdaddr_type); in hci_cc_le_add_to_accept_list()
1893 return rp->status; in hci_cc_le_add_to_accept_list()
1902 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_del_from_accept_list()
1904 if (rp->status) in hci_cc_le_del_from_accept_list()
1905 return rp->status; in hci_cc_le_del_from_accept_list()
1909 return rp->status; in hci_cc_le_del_from_accept_list()
1912 hci_bdaddr_list_del(&hdev->le_accept_list, &sent->bdaddr, in hci_cc_le_del_from_accept_list()
1913 sent->bdaddr_type); in hci_cc_le_del_from_accept_list()
1916 return rp->status; in hci_cc_le_del_from_accept_list()
1924 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_read_supported_states()
1926 if (rp->status) in hci_cc_le_read_supported_states()
1927 return rp->status; in hci_cc_le_read_supported_states()
1929 memcpy(hdev->le_states, rp->le_states, 8); in hci_cc_le_read_supported_states()
1931 return rp->status; in hci_cc_le_read_supported_states()
1939 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_read_def_data_len()
1941 if (rp->status) in hci_cc_le_read_def_data_len()
1942 return rp->status; in hci_cc_le_read_def_data_len()
1944 hdev->le_def_tx_len = le16_to_cpu(rp->tx_len); in hci_cc_le_read_def_data_len()
1945 hdev->le_def_tx_time = le16_to_cpu(rp->tx_time); in hci_cc_le_read_def_data_len()
1947 return rp->status; in hci_cc_le_read_def_data_len()
1956 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_write_def_data_len()
1958 if (rp->status) in hci_cc_le_write_def_data_len()
1959 return rp->status; in hci_cc_le_write_def_data_len()
1963 return rp->status; in hci_cc_le_write_def_data_len()
1965 hdev->le_def_tx_len = le16_to_cpu(sent->tx_len); in hci_cc_le_write_def_data_len()
1966 hdev->le_def_tx_time = le16_to_cpu(sent->tx_time); in hci_cc_le_write_def_data_len()
1968 return rp->status; in hci_cc_le_write_def_data_len()
1977 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_add_to_resolv_list()
1979 if (rp->status) in hci_cc_le_add_to_resolv_list()
1980 return rp->status; in hci_cc_le_add_to_resolv_list()
1984 return rp->status; in hci_cc_le_add_to_resolv_list()
1987 hci_bdaddr_list_add_with_irk(&hdev->le_resolv_list, &sent->bdaddr, in hci_cc_le_add_to_resolv_list()
1988 sent->bdaddr_type, sent->peer_irk, in hci_cc_le_add_to_resolv_list()
1989 sent->local_irk); in hci_cc_le_add_to_resolv_list()
1992 return rp->status; in hci_cc_le_add_to_resolv_list()
2001 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_del_from_resolv_list()
2003 if (rp->status) in hci_cc_le_del_from_resolv_list()
2004 return rp->status; in hci_cc_le_del_from_resolv_list()
2008 return rp->status; in hci_cc_le_del_from_resolv_list()
2011 hci_bdaddr_list_del_with_irk(&hdev->le_resolv_list, &sent->bdaddr, in hci_cc_le_del_from_resolv_list()
2012 sent->bdaddr_type); in hci_cc_le_del_from_resolv_list()
2015 return rp->status; in hci_cc_le_del_from_resolv_list()
2023 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_clear_resolv_list()
2025 if (rp->status) in hci_cc_le_clear_resolv_list()
2026 return rp->status; in hci_cc_le_clear_resolv_list()
2029 hci_bdaddr_list_clear(&hdev->le_resolv_list); in hci_cc_le_clear_resolv_list()
2032 return rp->status; in hci_cc_le_clear_resolv_list()
2040 bt_dev_dbg(hdev, "status 0x%2.2x size %u", rp->status, rp->size); in hci_cc_le_read_resolv_list_size()
2042 if (rp->status) in hci_cc_le_read_resolv_list_size()
2043 return rp->status; in hci_cc_le_read_resolv_list_size()
2045 hdev->le_resolv_list_size = rp->size; in hci_cc_le_read_resolv_list_size()
2047 return rp->status; in hci_cc_le_read_resolv_list_size()
2056 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_addr_resolution_enable()
2058 if (rp->status) in hci_cc_le_set_addr_resolution_enable()
2059 return rp->status; in hci_cc_le_set_addr_resolution_enable()
2063 return rp->status; in hci_cc_le_set_addr_resolution_enable()
2074 return rp->status; in hci_cc_le_set_addr_resolution_enable()
2082 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_read_max_data_len()
2084 if (rp->status) in hci_cc_le_read_max_data_len()
2085 return rp->status; in hci_cc_le_read_max_data_len()
2087 hdev->le_max_tx_len = le16_to_cpu(rp->tx_len); in hci_cc_le_read_max_data_len()
2088 hdev->le_max_tx_time = le16_to_cpu(rp->tx_time); in hci_cc_le_read_max_data_len()
2089 hdev->le_max_rx_len = le16_to_cpu(rp->rx_len); in hci_cc_le_read_max_data_len()
2090 hdev->le_max_rx_time = le16_to_cpu(rp->rx_time); in hci_cc_le_read_max_data_len()
2092 return rp->status; in hci_cc_le_read_max_data_len()
2101 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_le_host_supported()
2103 if (rp->status) in hci_cc_write_le_host_supported()
2104 return rp->status; in hci_cc_write_le_host_supported()
2108 return rp->status; in hci_cc_write_le_host_supported()
2112 if (sent->le) { in hci_cc_write_le_host_supported()
2113 hdev->features[1][0] |= LMP_HOST_LE; in hci_cc_write_le_host_supported()
2116 hdev->features[1][0] &= ~LMP_HOST_LE; in hci_cc_write_le_host_supported()
2121 if (sent->simul) in hci_cc_write_le_host_supported()
2122 hdev->features[1][0] |= LMP_HOST_LE_BREDR; in hci_cc_write_le_host_supported()
2124 hdev->features[1][0] &= ~LMP_HOST_LE_BREDR; in hci_cc_write_le_host_supported()
2128 return rp->status; in hci_cc_write_le_host_supported()
2137 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_set_adv_param()
2139 if (rp->status) in hci_cc_set_adv_param()
2140 return rp->status; in hci_cc_set_adv_param()
2144 return rp->status; in hci_cc_set_adv_param()
2147 hdev->adv_addr_type = cp->own_address_type; in hci_cc_set_adv_param()
2150 return rp->status; in hci_cc_set_adv_param()
2160 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_set_ext_adv_param()
2162 if (rp->status) in hci_cc_set_ext_adv_param()
2163 return rp->status; in hci_cc_set_ext_adv_param()
2167 return rp->status; in hci_cc_set_ext_adv_param()
2170 hdev->adv_addr_type = cp->own_addr_type; in hci_cc_set_ext_adv_param()
2171 if (!cp->handle) { in hci_cc_set_ext_adv_param()
2173 hdev->adv_tx_power = rp->tx_power; in hci_cc_set_ext_adv_param()
2175 adv_instance = hci_find_adv_instance(hdev, cp->handle); in hci_cc_set_ext_adv_param()
2177 adv_instance->tx_power = rp->tx_power; in hci_cc_set_ext_adv_param()
2180 hci_update_adv_data(hdev, cp->handle); in hci_cc_set_ext_adv_param()
2184 return rp->status; in hci_cc_set_ext_adv_param()
2193 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_rssi()
2195 if (rp->status) in hci_cc_read_rssi()
2196 return rp->status; in hci_cc_read_rssi()
2200 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_rssi()
2202 conn->rssi = rp->rssi; in hci_cc_read_rssi()
2206 return rp->status; in hci_cc_read_rssi()
2216 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_tx_power()
2218 if (rp->status) in hci_cc_read_tx_power()
2219 return rp->status; in hci_cc_read_tx_power()
2223 return rp->status; in hci_cc_read_tx_power()
2227 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_tx_power()
2231 switch (sent->type) { in hci_cc_read_tx_power()
2233 conn->tx_power = rp->tx_power; in hci_cc_read_tx_power()
2236 conn->max_tx_power = rp->tx_power; in hci_cc_read_tx_power()
2242 return rp->status; in hci_cc_read_tx_power()
2251 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_ssp_debug_mode()
2253 if (rp->status) in hci_cc_write_ssp_debug_mode()
2254 return rp->status; in hci_cc_write_ssp_debug_mode()
2258 hdev->ssp_debug_mode = *mode; in hci_cc_write_ssp_debug_mode()
2260 return rp->status; in hci_cc_write_ssp_debug_mode()
2271 set_bit(HCI_INQUIRY, &hdev->flags); in hci_cs_inquiry()
2287 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cs_create_conn()
2289 bt_dev_dbg(hdev, "bdaddr %pMR hcon %p", &cp->bdaddr, conn); in hci_cs_create_conn()
2292 if (conn && conn->state == BT_CONNECT) { in hci_cs_create_conn()
2293 conn->state = BT_CLOSED; in hci_cs_create_conn()
2299 conn = hci_conn_add_unset(hdev, ACL_LINK, &cp->bdaddr, in hci_cs_create_conn()
2325 handle = __le16_to_cpu(cp->handle); in hci_cs_add_sco()
2333 link = list_first_entry_or_null(&acl->link_list, in hci_cs_add_sco()
2335 if (link && link->conn) { in hci_cs_add_sco()
2336 link->conn->state = BT_CLOSED; in hci_cs_add_sco()
2338 hci_connect_cfm(link->conn, status); in hci_cs_add_sco()
2339 hci_conn_del(link->conn); in hci_cs_add_sco()
2362 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_auth_requested()
2364 if (conn->state == BT_CONFIG) { in hci_cs_auth_requested()
2389 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_set_conn_encrypt()
2391 if (conn->state == BT_CONFIG) { in hci_cs_set_conn_encrypt()
2403 if (conn->state != BT_CONFIG || !conn->out) in hci_outgoing_auth_needed()
2406 if (conn->pending_sec_level == BT_SECURITY_SDP) in hci_outgoing_auth_needed()
2409 /* Only request authentication for SSP connections or non-SSP in hci_outgoing_auth_needed()
2413 if (!hci_conn_ssp_enabled(conn) && !(conn->auth_type & 0x01) && in hci_outgoing_auth_needed()
2414 conn->pending_sec_level != BT_SECURITY_FIPS && in hci_outgoing_auth_needed()
2415 conn->pending_sec_level != BT_SECURITY_HIGH && in hci_outgoing_auth_needed()
2416 conn->pending_sec_level != BT_SECURITY_MEDIUM) in hci_outgoing_auth_needed()
2429 bacpy(&cp.bdaddr, &e->data.bdaddr); in hci_resolve_name()
2430 cp.pscan_rep_mode = e->data.pscan_rep_mode; in hci_resolve_name()
2431 cp.pscan_mode = e->data.pscan_mode; in hci_resolve_name()
2432 cp.clock_offset = e->data.clock_offset; in hci_resolve_name()
2439 struct discovery_state *discov = &hdev->discovery; in hci_resolve_next_name()
2442 if (list_empty(&discov->resolve)) in hci_resolve_next_name()
2446 if (time_after(jiffies, discov->name_resolve_timeout)) { in hci_resolve_next_name()
2456 e->name_state = NAME_PENDING; in hci_resolve_next_name()
2466 struct discovery_state *discov = &hdev->discovery; in hci_check_pending_name()
2474 if (conn && (conn->state == BT_CONFIG || conn->state == BT_CONNECTED)) in hci_check_pending_name()
2477 if (discov->state == DISCOVERY_STOPPED) in hci_check_pending_name()
2480 if (discov->state == DISCOVERY_STOPPING) in hci_check_pending_name()
2483 if (discov->state != DISCOVERY_RESOLVING) in hci_check_pending_name()
2494 list_del(&e->list); in hci_check_pending_name()
2496 e->name_state = name ? NAME_KNOWN : NAME_NOT_KNOWN; in hci_check_pending_name()
2497 mgmt_remote_name(hdev, bdaddr, ACL_LINK, 0x00, e->data.rssi, in hci_check_pending_name()
2525 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cs_remote_name_req()
2528 hci_check_pending_name(hdev, conn, &cp->bdaddr, NULL, 0); in hci_cs_remote_name_req()
2536 if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->flags)) { in hci_cs_remote_name_req()
2539 set_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags); in hci_cs_remote_name_req()
2541 auth_cp.handle = __cpu_to_le16(conn->handle); in hci_cs_remote_name_req()
2566 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_read_remote_features()
2568 if (conn->state == BT_CONFIG) { in hci_cs_read_remote_features()
2593 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_read_remote_ext_features()
2595 if (conn->state == BT_CONFIG) { in hci_cs_read_remote_ext_features()
2616 link = list_first_entry_or_null(&acl->link_list, in hci_setup_sync_conn_status()
2618 if (link && link->conn) { in hci_setup_sync_conn_status()
2619 link->conn->state = BT_CLOSED; in hci_setup_sync_conn_status()
2621 hci_connect_cfm(link->conn, status); in hci_setup_sync_conn_status()
2622 hci_conn_del(link->conn); in hci_setup_sync_conn_status()
2642 hci_setup_sync_conn_status(hdev, __le16_to_cpu(cp->handle), status); in hci_cs_setup_sync_conn()
2658 hci_setup_sync_conn_status(hdev, __le16_to_cpu(cp->handle), status); in hci_cs_enhanced_setup_sync_conn()
2677 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_sniff_mode()
2679 clear_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->flags); in hci_cs_sniff_mode()
2681 if (test_and_clear_bit(HCI_CONN_SCO_SETUP_PEND, &conn->flags)) in hci_cs_sniff_mode()
2704 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_exit_sniff_mode()
2706 clear_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->flags); in hci_cs_exit_sniff_mode()
2708 if (test_and_clear_bit(HCI_CONN_SCO_SETUP_PEND, &conn->flags)) in hci_cs_exit_sniff_mode()
2727 if (!status && !hdev->suspended) in hci_cs_disconnect()
2736 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_disconnect()
2741 mgmt_disconnect_failed(hdev, &conn->dst, conn->type, in hci_cs_disconnect()
2742 conn->dst_type, status); in hci_cs_disconnect()
2744 if (conn->type == LE_LINK && conn->role == HCI_ROLE_SLAVE) { in hci_cs_disconnect()
2745 hdev->cur_adv_instance = conn->adv_instance; in hci_cs_disconnect()
2755 mgmt_conn = test_and_clear_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags); in hci_cs_disconnect()
2757 if (conn->type == ACL_LINK) { in hci_cs_disconnect()
2758 if (test_and_clear_bit(HCI_CONN_FLUSH_KEY, &conn->flags)) in hci_cs_disconnect()
2759 hci_remove_link_key(hdev, &conn->dst); in hci_cs_disconnect()
2762 params = hci_conn_params_lookup(hdev, &conn->dst, conn->dst_type); in hci_cs_disconnect()
2764 switch (params->auto_connect) { in hci_cs_disconnect()
2766 if (cp->reason != HCI_ERROR_CONNECTION_TIMEOUT) in hci_cs_disconnect()
2773 hci_pend_le_list_add(params, &hdev->pend_le_conns); in hci_cs_disconnect()
2781 mgmt_device_disconnected(hdev, &conn->dst, conn->type, conn->dst_type, in hci_cs_disconnect()
2782 cp->reason, mgmt_conn); in hci_cs_disconnect()
2784 hci_disconn_cfm(conn, cp->reason); in hci_cs_disconnect()
2789 * Hence, we need to do some basic cleanup here and re-enable in hci_cs_disconnect()
2799 /* When using controller based address resolution, then the new in ev_bdaddr_type()
2800 * address types 0x02 and 0x03 are used. These types need to be in ev_bdaddr_type()
2801 * converted back into either public address or random address type in ev_bdaddr_type()
2832 /* Store the initiator and responder address information which in cs_le_create_conn()
2836 conn->init_addr_type = own_address_type; in cs_le_create_conn()
2838 bacpy(&conn->init_addr, &hdev->random_addr); in cs_le_create_conn()
2840 bacpy(&conn->init_addr, &hdev->bdaddr); in cs_le_create_conn()
2842 conn->resp_addr_type = peer_addr_type; in cs_le_create_conn()
2843 bacpy(&conn->resp_addr, peer_addr); in cs_le_create_conn()
2865 cs_le_create_conn(hdev, &cp->peer_addr, cp->peer_addr_type, in hci_cs_le_create_conn()
2866 cp->own_address_type, cp->filter_policy); in hci_cs_le_create_conn()
2890 cs_le_create_conn(hdev, &cp->peer_addr, cp->peer_addr_type, in hci_cs_le_ext_create_conn()
2891 cp->own_addr_type, cp->filter_policy); in hci_cs_le_ext_create_conn()
2912 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_le_read_remote_features()
2914 if (conn->state == BT_CONFIG) { in hci_cs_le_read_remote_features()
2939 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_le_start_enc()
2943 if (conn->state != BT_CONNECTED) in hci_cs_le_start_enc()
2958 BT_DBG("%s status 0x%2.2x", hdev->name, status); in hci_cs_switch_role()
2969 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cs_switch_role()
2971 clear_bit(HCI_CONN_RSWITCH_PEND, &conn->flags); in hci_cs_switch_role()
2980 struct discovery_state *discov = &hdev->discovery; in hci_inquiry_complete_evt()
2983 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_inquiry_complete_evt()
2985 if (!test_and_clear_bit(HCI_INQUIRY, &hdev->flags)) in hci_inquiry_complete_evt()
2989 wake_up_bit(&hdev->flags, HCI_INQUIRY); in hci_inquiry_complete_evt()
2996 if (discov->state != DISCOVERY_FINDING) in hci_inquiry_complete_evt()
2999 if (list_empty(&discov->resolve)) { in hci_inquiry_complete_evt()
3008 !test_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks)) in hci_inquiry_complete_evt()
3015 e->name_state = NAME_PENDING; in hci_inquiry_complete_evt()
3017 discov->name_resolve_timeout = jiffies + NAME_RESOLVE_DURATION; in hci_inquiry_complete_evt()
3027 !test_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks)) in hci_inquiry_complete_evt()
3043 flex_array_size(ev, info, ev->num))) in hci_inquiry_result_evt()
3046 bt_dev_dbg(hdev, "num %d", ev->num); in hci_inquiry_result_evt()
3048 if (!ev->num) in hci_inquiry_result_evt()
3056 for (i = 0; i < ev->num; i++) { in hci_inquiry_result_evt()
3057 struct inquiry_info *info = &ev->info[i]; in hci_inquiry_result_evt()
3060 bacpy(&data.bdaddr, &info->bdaddr); in hci_inquiry_result_evt()
3061 data.pscan_rep_mode = info->pscan_rep_mode; in hci_inquiry_result_evt()
3062 data.pscan_period_mode = info->pscan_period_mode; in hci_inquiry_result_evt()
3063 data.pscan_mode = info->pscan_mode; in hci_inquiry_result_evt()
3064 memcpy(data.dev_class, info->dev_class, 3); in hci_inquiry_result_evt()
3065 data.clock_offset = info->clock_offset; in hci_inquiry_result_evt()
3071 mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, in hci_inquiry_result_evt()
3072 info->dev_class, HCI_RSSI_INVALID, in hci_inquiry_result_evt()
3085 conn->enc_key_size = HCI_LINK_KEY_SIZE; in hci_read_enc_key_size()
3086 return -EOPNOTSUPP; in hci_read_enc_key_size()
3092 cp.handle = cpu_to_le16(conn->handle); in hci_read_enc_key_size()
3094 /* If the key enc_size is already known, use it as conn->enc_key_size, in hci_read_enc_key_size()
3095 * otherwise use hdev->min_enc_key_size so the likes of in hci_read_enc_key_size()
3100 conn->enc_key_size = *key_enc_size; in hci_read_enc_key_size()
3102 conn->enc_key_size = hdev->min_enc_key_size; in hci_read_enc_key_size()
3112 u8 status = ev->status; in hci_conn_complete_evt()
3118 conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, &ev->bdaddr); in hci_conn_complete_evt()
3123 if (ev->status) in hci_conn_complete_evt()
3126 /* Connection may not exist if auto-connected. Check the bredr in hci_conn_complete_evt()
3131 * Auto-connect will only occur if the event filter is in hci_conn_complete_evt()
3132 * programmed with a given address. Right now, event filter is in hci_conn_complete_evt()
3135 if (ev->link_type == ACL_LINK && in hci_conn_complete_evt()
3136 hci_bdaddr_list_lookup_with_flags(&hdev->accept_list, in hci_conn_complete_evt()
3137 &ev->bdaddr, in hci_conn_complete_evt()
3139 conn = hci_conn_add_unset(hdev, ev->link_type, in hci_conn_complete_evt()
3140 &ev->bdaddr, HCI_ROLE_SLAVE); in hci_conn_complete_evt()
3146 if (ev->link_type != SCO_LINK) in hci_conn_complete_evt()
3150 &ev->bdaddr); in hci_conn_complete_evt()
3154 conn->type = SCO_LINK; in hci_conn_complete_evt()
3164 if (!HCI_CONN_HANDLE_UNSET(conn->handle)) { in hci_conn_complete_evt()
3170 status = hci_conn_set_handle(conn, __le16_to_cpu(ev->handle)); in hci_conn_complete_evt()
3174 if (conn->type == ACL_LINK) { in hci_conn_complete_evt()
3175 conn->state = BT_CONFIG; in hci_conn_complete_evt()
3178 if (!conn->out && !hci_conn_ssp_enabled(conn) && in hci_conn_complete_evt()
3179 !hci_find_link_key(hdev, &ev->bdaddr)) in hci_conn_complete_evt()
3180 conn->disc_timeout = HCI_PAIRING_TIMEOUT; in hci_conn_complete_evt()
3182 conn->disc_timeout = HCI_DISCONN_TIMEOUT; in hci_conn_complete_evt()
3184 conn->state = BT_CONNECTED; in hci_conn_complete_evt()
3189 if (test_bit(HCI_AUTH, &hdev->flags)) in hci_conn_complete_evt()
3190 set_bit(HCI_CONN_AUTH, &conn->flags); in hci_conn_complete_evt()
3192 if (test_bit(HCI_ENCRYPT, &hdev->flags)) in hci_conn_complete_evt()
3193 set_bit(HCI_CONN_ENCRYPT, &conn->flags); in hci_conn_complete_evt()
3196 if (ev->encr_mode == 1 && !test_bit(HCI_CONN_ENCRYPT, &conn->flags) && in hci_conn_complete_evt()
3197 ev->link_type == ACL_LINK) { in hci_conn_complete_evt()
3200 key = hci_find_link_key(hdev, &ev->bdaddr); in hci_conn_complete_evt()
3202 set_bit(HCI_CONN_ENCRYPT, &conn->flags); in hci_conn_complete_evt()
3204 hci_encrypt_cfm(conn, ev->status); in hci_conn_complete_evt()
3209 if (conn->type == ACL_LINK) { in hci_conn_complete_evt()
3211 cp.handle = ev->handle; in hci_conn_complete_evt()
3219 if (!conn->out && hdev->hci_ver < BLUETOOTH_VER_2_0) { in hci_conn_complete_evt()
3221 cp.handle = ev->handle; in hci_conn_complete_evt()
3222 cp.pkt_type = cpu_to_le16(conn->pkt_type); in hci_conn_complete_evt()
3228 if (conn->type == ACL_LINK) in hci_conn_complete_evt()
3229 hci_sco_setup(conn, ev->status); in hci_conn_complete_evt()
3234 } else if (ev->link_type == SCO_LINK) { in hci_conn_complete_evt()
3235 switch (conn->setting & SCO_AIRMODE_MASK) { in hci_conn_complete_evt()
3237 if (hdev->notify) in hci_conn_complete_evt()
3238 hdev->notify(hdev, HCI_NOTIFY_ENABLE_SCO_CVSD); in hci_conn_complete_evt()
3262 int mask = hdev->link_mode; in hci_conn_request_evt()
3267 bt_dev_dbg(hdev, "bdaddr %pMR type 0x%x", &ev->bdaddr, ev->link_type); in hci_conn_request_evt()
3269 /* Reject incoming connection from device with same BD ADDR against in hci_conn_request_evt()
3270 * CVE-2020-26555 in hci_conn_request_evt()
3272 if (hdev && !bacmp(&hdev->bdaddr, &ev->bdaddr)) { in hci_conn_request_evt()
3274 &ev->bdaddr); in hci_conn_request_evt()
3275 hci_reject_conn(hdev, &ev->bdaddr); in hci_conn_request_evt()
3279 mask |= hci_proto_connect_ind(hdev, &ev->bdaddr, ev->link_type, in hci_conn_request_evt()
3283 hci_reject_conn(hdev, &ev->bdaddr); in hci_conn_request_evt()
3289 if (hci_bdaddr_list_lookup(&hdev->reject_list, &ev->bdaddr, in hci_conn_request_evt()
3291 hci_reject_conn(hdev, &ev->bdaddr); in hci_conn_request_evt()
3301 !hci_bdaddr_list_lookup_with_flags(&hdev->accept_list, &ev->bdaddr, in hci_conn_request_evt()
3303 hci_reject_conn(hdev, &ev->bdaddr); in hci_conn_request_evt()
3309 ie = hci_inquiry_cache_lookup(hdev, &ev->bdaddr); in hci_conn_request_evt()
3311 memcpy(ie->data.dev_class, ev->dev_class, 3); in hci_conn_request_evt()
3313 conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, in hci_conn_request_evt()
3314 &ev->bdaddr); in hci_conn_request_evt()
3316 conn = hci_conn_add_unset(hdev, ev->link_type, &ev->bdaddr, in hci_conn_request_evt()
3324 memcpy(conn->dev_class, ev->dev_class, 3); in hci_conn_request_evt()
3328 if (ev->link_type == ACL_LINK || in hci_conn_request_evt()
3331 conn->state = BT_CONNECT; in hci_conn_request_evt()
3333 bacpy(&cp.bdaddr, &ev->bdaddr); in hci_conn_request_evt()
3343 conn->state = BT_CONNECT; in hci_conn_request_evt()
3345 bacpy(&cp.bdaddr, &ev->bdaddr); in hci_conn_request_evt()
3346 cp.pkt_type = cpu_to_le16(conn->pkt_type); in hci_conn_request_evt()
3351 cp.content_format = cpu_to_le16(hdev->voice_setting); in hci_conn_request_evt()
3357 conn->state = BT_CONNECT2; in hci_conn_request_evt()
3391 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_disconn_complete_evt()
3395 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_disconn_complete_evt()
3399 if (ev->status) { in hci_disconn_complete_evt()
3400 mgmt_disconnect_failed(hdev, &conn->dst, conn->type, in hci_disconn_complete_evt()
3401 conn->dst_type, ev->status); in hci_disconn_complete_evt()
3405 conn->state = BT_CLOSED; in hci_disconn_complete_evt()
3407 mgmt_connected = test_and_clear_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags); in hci_disconn_complete_evt()
3409 if (test_bit(HCI_CONN_AUTH_FAILURE, &conn->flags)) in hci_disconn_complete_evt()
3412 reason = hci_to_mgmt_reason(ev->reason); in hci_disconn_complete_evt()
3414 mgmt_device_disconnected(hdev, &conn->dst, conn->type, conn->dst_type, in hci_disconn_complete_evt()
3417 if (conn->type == ACL_LINK) { in hci_disconn_complete_evt()
3418 if (test_and_clear_bit(HCI_CONN_FLUSH_KEY, &conn->flags)) in hci_disconn_complete_evt()
3419 hci_remove_link_key(hdev, &conn->dst); in hci_disconn_complete_evt()
3424 /* Re-enable passive scanning if disconnected device is marked in hci_disconn_complete_evt()
3425 * as auto-connectable. in hci_disconn_complete_evt()
3427 if (conn->type == LE_LINK) { in hci_disconn_complete_evt()
3428 params = hci_conn_params_lookup(hdev, &conn->dst, in hci_disconn_complete_evt()
3429 conn->dst_type); in hci_disconn_complete_evt()
3431 switch (params->auto_connect) { in hci_disconn_complete_evt()
3433 if (ev->reason != HCI_ERROR_CONNECTION_TIMEOUT) in hci_disconn_complete_evt()
3441 &hdev->pend_le_conns); in hci_disconn_complete_evt()
3451 hci_disconn_cfm(conn, ev->reason); in hci_disconn_complete_evt()
3453 /* Re-enable advertising if necessary, since it might in hci_disconn_complete_evt()
3463 if (conn->type == LE_LINK && conn->role == HCI_ROLE_SLAVE) { in hci_disconn_complete_evt()
3464 hdev->cur_adv_instance = conn->adv_instance; in hci_disconn_complete_evt()
3480 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_auth_complete_evt()
3484 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_auth_complete_evt()
3488 if (!ev->status) { in hci_auth_complete_evt()
3489 clear_bit(HCI_CONN_AUTH_FAILURE, &conn->flags); in hci_auth_complete_evt()
3490 set_bit(HCI_CONN_AUTH, &conn->flags); in hci_auth_complete_evt()
3491 conn->sec_level = conn->pending_sec_level; in hci_auth_complete_evt()
3493 if (ev->status == HCI_ERROR_PIN_OR_KEY_MISSING) in hci_auth_complete_evt()
3494 set_bit(HCI_CONN_AUTH_FAILURE, &conn->flags); in hci_auth_complete_evt()
3496 mgmt_auth_failed(conn, ev->status); in hci_auth_complete_evt()
3499 clear_bit(HCI_CONN_AUTH_PEND, &conn->flags); in hci_auth_complete_evt()
3501 if (conn->state == BT_CONFIG) { in hci_auth_complete_evt()
3502 if (!ev->status && hci_conn_ssp_enabled(conn)) { in hci_auth_complete_evt()
3504 cp.handle = ev->handle; in hci_auth_complete_evt()
3509 conn->state = BT_CONNECTED; in hci_auth_complete_evt()
3510 hci_connect_cfm(conn, ev->status); in hci_auth_complete_evt()
3514 hci_auth_cfm(conn, ev->status); in hci_auth_complete_evt()
3517 conn->disc_timeout = HCI_DISCONN_TIMEOUT; in hci_auth_complete_evt()
3521 if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags)) { in hci_auth_complete_evt()
3522 if (!ev->status) { in hci_auth_complete_evt()
3524 cp.handle = ev->handle; in hci_auth_complete_evt()
3529 clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags); in hci_auth_complete_evt()
3530 hci_encrypt_cfm(conn, ev->status); in hci_auth_complete_evt()
3544 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_remote_name_evt()
3548 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_remote_name_evt()
3553 if (ev->status == 0) in hci_remote_name_evt()
3554 hci_check_pending_name(hdev, conn, &ev->bdaddr, ev->name, in hci_remote_name_evt()
3555 strnlen(ev->name, HCI_MAX_NAME_LENGTH)); in hci_remote_name_evt()
3557 hci_check_pending_name(hdev, conn, &ev->bdaddr, NULL, 0); in hci_remote_name_evt()
3566 if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->flags)) { in hci_remote_name_evt()
3569 set_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags); in hci_remote_name_evt()
3571 cp.handle = __cpu_to_le16(conn->handle); in hci_remote_name_evt()
3585 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_encrypt_change_evt()
3589 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_encrypt_change_evt()
3593 if (!ev->status) { in hci_encrypt_change_evt()
3594 if (ev->encrypt) { in hci_encrypt_change_evt()
3596 set_bit(HCI_CONN_AUTH, &conn->flags); in hci_encrypt_change_evt()
3597 set_bit(HCI_CONN_ENCRYPT, &conn->flags); in hci_encrypt_change_evt()
3598 conn->sec_level = conn->pending_sec_level; in hci_encrypt_change_evt()
3600 /* P-256 authentication key implies FIPS */ in hci_encrypt_change_evt()
3601 if (conn->key_type == HCI_LK_AUTH_COMBINATION_P256) in hci_encrypt_change_evt()
3602 set_bit(HCI_CONN_FIPS, &conn->flags); in hci_encrypt_change_evt()
3604 if ((conn->type == ACL_LINK && ev->encrypt == 0x02) || in hci_encrypt_change_evt()
3605 conn->type == LE_LINK) in hci_encrypt_change_evt()
3606 set_bit(HCI_CONN_AES_CCM, &conn->flags); in hci_encrypt_change_evt()
3608 clear_bit(HCI_CONN_ENCRYPT, &conn->flags); in hci_encrypt_change_evt()
3609 clear_bit(HCI_CONN_AES_CCM, &conn->flags); in hci_encrypt_change_evt()
3616 if (ev->status && conn->type == LE_LINK) { in hci_encrypt_change_evt()
3621 clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags); in hci_encrypt_change_evt()
3625 ev->status = HCI_ERROR_AUTH_FAILURE; in hci_encrypt_change_evt()
3627 if (ev->status && conn->state == BT_CONNECTED) { in hci_encrypt_change_evt()
3628 if (ev->status == HCI_ERROR_PIN_OR_KEY_MISSING) in hci_encrypt_change_evt()
3629 set_bit(HCI_CONN_AUTH_FAILURE, &conn->flags); in hci_encrypt_change_evt()
3634 hci_encrypt_cfm(conn, ev->status); in hci_encrypt_change_evt()
3641 if (!ev->status && ev->encrypt && conn->type == ACL_LINK) { in hci_encrypt_change_evt()
3652 &hdev->quirks)) in hci_encrypt_change_evt()
3660 * Ensure for AES-CCM encryption as well. in hci_encrypt_change_evt()
3662 if (test_bit(HCI_CONN_ENCRYPT, &conn->flags) && in hci_encrypt_change_evt()
3663 test_bit(HCI_CONN_AES_CCM, &conn->flags) && in hci_encrypt_change_evt()
3664 ((conn->type == ACL_LINK && lmp_ping_capable(hdev)) || in hci_encrypt_change_evt()
3665 (conn->type == LE_LINK && (hdev->le_features[0] & HCI_LE_PING)))) { in hci_encrypt_change_evt()
3668 cp.handle = cpu_to_le16(conn->handle); in hci_encrypt_change_evt()
3669 cp.timeout = cpu_to_le16(hdev->auth_payload_timeout); in hci_encrypt_change_evt()
3670 if (hci_send_cmd(conn->hdev, HCI_OP_WRITE_AUTH_PAYLOAD_TO, in hci_encrypt_change_evt()
3676 hci_encrypt_cfm(conn, ev->status); in hci_encrypt_change_evt()
3688 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_change_link_key_complete_evt()
3692 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_change_link_key_complete_evt()
3694 if (!ev->status) in hci_change_link_key_complete_evt()
3695 set_bit(HCI_CONN_SECURE, &conn->flags); in hci_change_link_key_complete_evt()
3697 clear_bit(HCI_CONN_AUTH_PEND, &conn->flags); in hci_change_link_key_complete_evt()
3699 hci_key_change_cfm(conn, ev->status); in hci_change_link_key_complete_evt()
3711 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_remote_features_evt()
3715 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_remote_features_evt()
3719 if (!ev->status) in hci_remote_features_evt()
3720 memcpy(conn->features[0], ev->features, 8); in hci_remote_features_evt()
3722 if (conn->state != BT_CONFIG) in hci_remote_features_evt()
3725 if (!ev->status && lmp_ext_feat_capable(hdev) && in hci_remote_features_evt()
3728 cp.handle = ev->handle; in hci_remote_features_evt()
3735 if (!ev->status) { in hci_remote_features_evt()
3738 bacpy(&cp.bdaddr, &conn->dst); in hci_remote_features_evt()
3746 conn->state = BT_CONNECTED; in hci_remote_features_evt()
3747 hci_connect_cfm(conn, ev->status); in hci_remote_features_evt()
3757 cancel_delayed_work(&hdev->cmd_timer); in handle_cmd_cnt_and_timer()
3760 if (!test_bit(HCI_RESET, &hdev->flags)) { in handle_cmd_cnt_and_timer()
3762 cancel_delayed_work(&hdev->ncmd_timer); in handle_cmd_cnt_and_timer()
3763 atomic_set(&hdev->cmd_cnt, 1); in handle_cmd_cnt_and_timer()
3766 queue_delayed_work(hdev->workqueue, &hdev->ncmd_timer, in handle_cmd_cnt_and_timer()
3778 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_read_buffer_size_v2()
3780 if (rp->status) in hci_cc_le_read_buffer_size_v2()
3781 return rp->status; in hci_cc_le_read_buffer_size_v2()
3783 hdev->le_mtu = __le16_to_cpu(rp->acl_mtu); in hci_cc_le_read_buffer_size_v2()
3784 hdev->le_pkts = rp->acl_max_pkt; in hci_cc_le_read_buffer_size_v2()
3785 hdev->iso_mtu = __le16_to_cpu(rp->iso_mtu); in hci_cc_le_read_buffer_size_v2()
3786 hdev->iso_pkts = rp->iso_max_pkt; in hci_cc_le_read_buffer_size_v2()
3788 hdev->le_cnt = hdev->le_pkts; in hci_cc_le_read_buffer_size_v2()
3789 hdev->iso_cnt = hdev->iso_pkts; in hci_cc_le_read_buffer_size_v2()
3791 BT_DBG("%s acl mtu %d:%d iso mtu %d:%d", hdev->name, hdev->acl_mtu, in hci_cc_le_read_buffer_size_v2()
3792 hdev->acl_pkts, hdev->iso_mtu, hdev->iso_pkts); in hci_cc_le_read_buffer_size_v2()
3794 if (hdev->le_mtu && hdev->le_mtu < HCI_MIN_LE_MTU) in hci_cc_le_read_buffer_size_v2()
3797 return rp->status; in hci_cc_le_read_buffer_size_v2()
3804 lockdep_assert_held(&hdev->lock); in hci_unbound_cis_failed()
3806 list_for_each_entry_safe(conn, tmp, &hdev->conn_hash.list, list) { in hci_unbound_cis_failed()
3807 if (conn->type != ISO_LINK || !bacmp(&conn->dst, BDADDR_ANY) || in hci_unbound_cis_failed()
3808 conn->state == BT_OPEN || conn->iso_qos.ucast.cig != cig) in hci_unbound_cis_failed()
3811 if (HCI_CONN_HANDLE_UNSET(conn->handle)) in hci_unbound_cis_failed()
3822 u8 status = rp->status; in hci_cc_le_set_cig_params()
3826 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_cig_params()
3829 if (!rp->status && (!cp || rp->num_handles != cp->num_cis || in hci_cc_le_set_cig_params()
3830 rp->cig_id != cp->cig_id)) { in hci_cc_le_set_cig_params()
3839 * If the Status return parameter is non-zero, then the state of the CIG in hci_cc_le_set_cig_params()
3845 hci_unbound_cis_failed(hdev, rp->cig_id, status); in hci_cc_le_set_cig_params()
3856 for (i = 0; i < rp->num_handles; ++i) { in hci_cc_le_set_cig_params()
3857 conn = hci_conn_hash_lookup_cis(hdev, NULL, 0, rp->cig_id, in hci_cc_le_set_cig_params()
3858 cp->cis[i].cis_id); in hci_cc_le_set_cig_params()
3859 if (!conn || !bacmp(&conn->dst, BDADDR_ANY)) in hci_cc_le_set_cig_params()
3862 if (conn->state != BT_BOUND && conn->state != BT_CONNECT) in hci_cc_le_set_cig_params()
3865 if (hci_conn_set_handle(conn, __le16_to_cpu(rp->handle[i]))) in hci_cc_le_set_cig_params()
3868 if (conn->state == BT_CONNECT) in hci_cc_le_set_cig_params()
3878 return rp->status; in hci_cc_le_set_cig_params()
3888 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_setup_iso_path()
3892 return rp->status; in hci_cc_le_setup_iso_path()
3896 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cc_le_setup_iso_path()
3900 if (rp->status) { in hci_cc_le_setup_iso_path()
3901 hci_connect_cfm(conn, rp->status); in hci_cc_le_setup_iso_path()
3906 switch (cp->direction) { in hci_cc_le_setup_iso_path()
3910 if (conn->iso_qos.ucast.out.sdu && !conn->iso_qos.ucast.in.sdu) in hci_cc_le_setup_iso_path()
3911 hci_connect_cfm(conn, rp->status); in hci_cc_le_setup_iso_path()
3915 /* Confirm connection since conn->iso_qos is always configured in hci_cc_le_setup_iso_path()
3918 hci_connect_cfm(conn, rp->status); in hci_cc_le_setup_iso_path()
3921 if (!rp->status && test_bit(HCI_CONN_BIG_SYNC, &conn->flags)) in hci_cc_le_setup_iso_path()
3929 return rp->status; in hci_cc_le_setup_iso_path()
3943 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_set_per_adv_param()
3945 if (rp->status) in hci_cc_set_per_adv_param()
3946 return rp->status; in hci_cc_set_per_adv_param()
3950 return rp->status; in hci_cc_set_per_adv_param()
3953 return rp->status; in hci_cc_set_per_adv_param()
3964 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_per_adv_enable()
3966 if (rp->status) in hci_cc_le_set_per_adv_enable()
3967 return rp->status; in hci_cc_le_set_per_adv_enable()
3971 return rp->status; in hci_cc_le_set_per_adv_enable()
3975 adv = hci_find_adv_instance(hdev, cp->handle); in hci_cc_le_set_per_adv_enable()
3977 if (cp->enable) { in hci_cc_le_set_per_adv_enable()
3981 adv->enabled = true; in hci_cc_le_set_per_adv_enable()
3988 list_for_each_entry_safe(adv, n, &hdev->adv_instances, in hci_cc_le_set_per_adv_enable()
3990 if (adv->periodic && adv->enabled) in hci_cc_le_set_per_adv_enable()
4003 return rp->status; in hci_cc_le_set_per_adv_enable()
4194 if (skb->len < cc->min_len) { in hci_cc_func()
4196 cc->op, skb->len, cc->min_len); in hci_cc_func()
4204 if (skb->len > cc->max_len) in hci_cc_func()
4206 cc->op, skb->len, cc->max_len); in hci_cc_func()
4208 data = hci_cc_skb_pull(hdev, skb, cc->op, cc->min_len); in hci_cc_func()
4212 return cc->func(hdev, data, skb); in hci_cc_func()
4223 *opcode = __le16_to_cpu(ev->opcode); in hci_cmd_complete_evt()
4242 *status = skb->data[0]; in hci_cmd_complete_evt()
4245 handle_cmd_cnt_and_timer(hdev, ev->ncmd); in hci_cmd_complete_evt()
4256 if (atomic_read(&hdev->cmd_cnt) && !skb_queue_empty(&hdev->cmd_q)) in hci_cmd_complete_evt()
4257 queue_work(hdev->workqueue, &hdev->cmd_work); in hci_cmd_complete_evt()
4278 for (i = 0; i < cp->num_cis; i++) { in hci_cs_le_create_cis()
4282 handle = __le16_to_cpu(cp->cis[i].cis_handle); in hci_cs_le_create_cis()
4287 &conn->flags)) in hci_cs_le_create_cis()
4289 conn->state = BT_CLOSED; in hci_cs_le_create_cis()
4294 cp->num_cis = 0; in hci_cs_le_create_cis()
4344 *opcode = __le16_to_cpu(ev->opcode); in hci_cmd_status_evt()
4345 *status = ev->status; in hci_cmd_status_evt()
4351 hci_cs_table[i].func(hdev, ev->status); in hci_cmd_status_evt()
4356 handle_cmd_cnt_and_timer(hdev, ev->ncmd); in hci_cmd_status_evt()
4364 if (ev->status || (hdev->req_skb && !hci_skb_event(hdev->req_skb))) { in hci_cmd_status_evt()
4365 hci_req_cmd_complete(hdev, *opcode, ev->status, req_complete, in hci_cmd_status_evt()
4374 if (atomic_read(&hdev->cmd_cnt) && !skb_queue_empty(&hdev->cmd_q)) in hci_cmd_status_evt()
4375 queue_work(hdev->workqueue, &hdev->cmd_work); in hci_cmd_status_evt()
4383 bt_dev_dbg(hdev, "code 0x%2.2x", ev->code); in hci_hardware_error_evt()
4385 hdev->hw_error_code = ev->code; in hci_hardware_error_evt()
4387 queue_work(hdev->req_workqueue, &hdev->error_reset); in hci_hardware_error_evt()
4396 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_role_change_evt()
4400 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_role_change_evt()
4402 if (!ev->status) in hci_role_change_evt()
4403 conn->role = ev->role; in hci_role_change_evt()
4405 clear_bit(HCI_CONN_RSWITCH_PEND, &conn->flags); in hci_role_change_evt()
4407 hci_role_switch_cfm(conn, ev->status, ev->role); in hci_role_change_evt()
4420 flex_array_size(ev, handles, ev->num))) in hci_num_comp_pkts_evt()
4423 bt_dev_dbg(hdev, "num %d", ev->num); in hci_num_comp_pkts_evt()
4425 for (i = 0; i < ev->num; i++) { in hci_num_comp_pkts_evt()
4426 struct hci_comp_pkts_info *info = &ev->handles[i]; in hci_num_comp_pkts_evt()
4431 handle = __le16_to_cpu(info->handle); in hci_num_comp_pkts_evt()
4432 count = __le16_to_cpu(info->count); in hci_num_comp_pkts_evt()
4438 conn->sent -= count; in hci_num_comp_pkts_evt()
4443 switch (conn->type) { in hci_num_comp_pkts_evt()
4445 hdev->acl_cnt += count; in hci_num_comp_pkts_evt()
4446 if (hdev->acl_cnt > hdev->acl_pkts) in hci_num_comp_pkts_evt()
4447 hdev->acl_cnt = hdev->acl_pkts; in hci_num_comp_pkts_evt()
4451 if (hdev->le_pkts) { in hci_num_comp_pkts_evt()
4452 hdev->le_cnt += count; in hci_num_comp_pkts_evt()
4453 if (hdev->le_cnt > hdev->le_pkts) in hci_num_comp_pkts_evt()
4454 hdev->le_cnt = hdev->le_pkts; in hci_num_comp_pkts_evt()
4456 hdev->acl_cnt += count; in hci_num_comp_pkts_evt()
4457 if (hdev->acl_cnt > hdev->acl_pkts) in hci_num_comp_pkts_evt()
4458 hdev->acl_cnt = hdev->acl_pkts; in hci_num_comp_pkts_evt()
4464 hdev->sco_cnt += count; in hci_num_comp_pkts_evt()
4465 if (hdev->sco_cnt > hdev->sco_pkts) in hci_num_comp_pkts_evt()
4466 hdev->sco_cnt = hdev->sco_pkts; in hci_num_comp_pkts_evt()
4471 if (hdev->iso_pkts) { in hci_num_comp_pkts_evt()
4472 hdev->iso_cnt += count; in hci_num_comp_pkts_evt()
4473 if (hdev->iso_cnt > hdev->iso_pkts) in hci_num_comp_pkts_evt()
4474 hdev->iso_cnt = hdev->iso_pkts; in hci_num_comp_pkts_evt()
4475 } else if (hdev->le_pkts) { in hci_num_comp_pkts_evt()
4476 hdev->le_cnt += count; in hci_num_comp_pkts_evt()
4477 if (hdev->le_cnt > hdev->le_pkts) in hci_num_comp_pkts_evt()
4478 hdev->le_cnt = hdev->le_pkts; in hci_num_comp_pkts_evt()
4480 hdev->acl_cnt += count; in hci_num_comp_pkts_evt()
4481 if (hdev->acl_cnt > hdev->acl_pkts) in hci_num_comp_pkts_evt()
4482 hdev->acl_cnt = hdev->acl_pkts; in hci_num_comp_pkts_evt()
4488 conn->type, conn); in hci_num_comp_pkts_evt()
4493 queue_work(hdev->workqueue, &hdev->tx_work); in hci_num_comp_pkts_evt()
4502 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_mode_change_evt()
4506 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_mode_change_evt()
4508 conn->mode = ev->mode; in hci_mode_change_evt()
4511 &conn->flags)) { in hci_mode_change_evt()
4512 if (conn->mode == HCI_CM_ACTIVE) in hci_mode_change_evt()
4513 set_bit(HCI_CONN_POWER_SAVE, &conn->flags); in hci_mode_change_evt()
4515 clear_bit(HCI_CONN_POWER_SAVE, &conn->flags); in hci_mode_change_evt()
4518 if (test_and_clear_bit(HCI_CONN_SCO_SETUP_PEND, &conn->flags)) in hci_mode_change_evt()
4519 hci_sco_setup(conn, ev->status); in hci_mode_change_evt()
4535 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_pin_code_request_evt()
4539 if (conn->state == BT_CONNECTED) { in hci_pin_code_request_evt()
4541 conn->disc_timeout = HCI_PAIRING_TIMEOUT; in hci_pin_code_request_evt()
4546 !test_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags)) { in hci_pin_code_request_evt()
4548 sizeof(ev->bdaddr), &ev->bdaddr); in hci_pin_code_request_evt()
4552 if (conn->pending_sec_level == BT_SECURITY_HIGH) in hci_pin_code_request_evt()
4557 mgmt_pin_code_request(hdev, &ev->bdaddr, secure); in hci_pin_code_request_evt()
4569 conn->pin_length = pin_len; in conn_set_key()
4570 conn->key_type = key_type; in conn_set_key()
4579 conn->pending_sec_level = BT_SECURITY_HIGH; in conn_set_key()
4581 conn->pending_sec_level = BT_SECURITY_MEDIUM; in conn_set_key()
4585 conn->pending_sec_level = BT_SECURITY_MEDIUM; in conn_set_key()
4588 conn->pending_sec_level = BT_SECURITY_HIGH; in conn_set_key()
4591 conn->pending_sec_level = BT_SECURITY_FIPS; in conn_set_key()
4611 key = hci_find_link_key(hdev, &ev->bdaddr); in hci_link_key_request_evt()
4613 bt_dev_dbg(hdev, "link key not found for %pMR", &ev->bdaddr); in hci_link_key_request_evt()
4617 bt_dev_dbg(hdev, "found key type %u for %pMR", key->type, &ev->bdaddr); in hci_link_key_request_evt()
4619 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_link_key_request_evt()
4621 clear_bit(HCI_CONN_NEW_LINK_KEY, &conn->flags); in hci_link_key_request_evt()
4623 if ((key->type == HCI_LK_UNAUTH_COMBINATION_P192 || in hci_link_key_request_evt()
4624 key->type == HCI_LK_UNAUTH_COMBINATION_P256) && in hci_link_key_request_evt()
4625 conn->auth_type != 0xff && (conn->auth_type & 0x01)) { in hci_link_key_request_evt()
4630 if (key->type == HCI_LK_COMBINATION && key->pin_len < 16 && in hci_link_key_request_evt()
4631 (conn->pending_sec_level == BT_SECURITY_HIGH || in hci_link_key_request_evt()
4632 conn->pending_sec_level == BT_SECURITY_FIPS)) { in hci_link_key_request_evt()
4637 conn_set_key(conn, key->type, key->pin_len); in hci_link_key_request_evt()
4640 bacpy(&cp.bdaddr, &ev->bdaddr); in hci_link_key_request_evt()
4641 memcpy(cp.link_key, key->val, HCI_LINK_KEY_SIZE); in hci_link_key_request_evt()
4650 hci_send_cmd(hdev, HCI_OP_LINK_KEY_NEG_REPLY, 6, &ev->bdaddr); in hci_link_key_request_evt()
4667 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_link_key_notify_evt()
4671 /* Ignore NULL link key against CVE-2020-26555 */ in hci_link_key_notify_evt()
4672 if (!crypto_memneq(ev->link_key, ZERO_KEY, HCI_LINK_KEY_SIZE)) { in hci_link_key_notify_evt()
4674 &ev->bdaddr); in hci_link_key_notify_evt()
4681 conn->disc_timeout = HCI_DISCONN_TIMEOUT; in hci_link_key_notify_evt()
4684 set_bit(HCI_CONN_NEW_LINK_KEY, &conn->flags); in hci_link_key_notify_evt()
4685 conn_set_key(conn, ev->key_type, conn->pin_length); in hci_link_key_notify_evt()
4690 key = hci_add_link_key(hdev, conn, &ev->bdaddr, ev->link_key, in hci_link_key_notify_evt()
4691 ev->key_type, pin_len, &persistent); in hci_link_key_notify_evt()
4698 if (ev->key_type == HCI_LK_CHANGED_COMBINATION) in hci_link_key_notify_evt()
4699 conn_set_key(conn, key->type, key->pin_len); in hci_link_key_notify_evt()
4708 if (key->type == HCI_LK_DEBUG_COMBINATION && in hci_link_key_notify_evt()
4710 list_del_rcu(&key->list); in hci_link_key_notify_evt()
4716 clear_bit(HCI_CONN_FLUSH_KEY, &conn->flags); in hci_link_key_notify_evt()
4718 set_bit(HCI_CONN_FLUSH_KEY, &conn->flags); in hci_link_key_notify_evt()
4730 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_clock_offset_evt()
4734 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_clock_offset_evt()
4735 if (conn && !ev->status) { in hci_clock_offset_evt()
4738 ie = hci_inquiry_cache_lookup(hdev, &conn->dst); in hci_clock_offset_evt()
4740 ie->data.clock_offset = ev->clock_offset; in hci_clock_offset_evt()
4741 ie->timestamp = jiffies; in hci_clock_offset_evt()
4754 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_pkt_type_change_evt()
4758 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_pkt_type_change_evt()
4759 if (conn && !ev->status) in hci_pkt_type_change_evt()
4760 conn->pkt_type = __le16_to_cpu(ev->pkt_type); in hci_pkt_type_change_evt()
4775 ie = hci_inquiry_cache_lookup(hdev, &ev->bdaddr); in hci_pscan_rep_mode_evt()
4777 ie->data.pscan_rep_mode = ev->pscan_rep_mode; in hci_pscan_rep_mode_evt()
4778 ie->timestamp = jiffies; in hci_pscan_rep_mode_evt()
4791 bt_dev_dbg(hdev, "num_rsp %d", ev->num); in hci_inquiry_result_with_rssi_evt()
4793 if (!ev->num) in hci_inquiry_result_with_rssi_evt()
4801 if (skb->len == array_size(ev->num, in hci_inquiry_result_with_rssi_evt()
4805 for (i = 0; i < ev->num; i++) { in hci_inquiry_result_with_rssi_evt()
4817 bacpy(&data.bdaddr, &info->bdaddr); in hci_inquiry_result_with_rssi_evt()
4818 data.pscan_rep_mode = info->pscan_rep_mode; in hci_inquiry_result_with_rssi_evt()
4819 data.pscan_period_mode = info->pscan_period_mode; in hci_inquiry_result_with_rssi_evt()
4820 data.pscan_mode = info->pscan_mode; in hci_inquiry_result_with_rssi_evt()
4821 memcpy(data.dev_class, info->dev_class, 3); in hci_inquiry_result_with_rssi_evt()
4822 data.clock_offset = info->clock_offset; in hci_inquiry_result_with_rssi_evt()
4823 data.rssi = info->rssi; in hci_inquiry_result_with_rssi_evt()
4828 mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, in hci_inquiry_result_with_rssi_evt()
4829 info->dev_class, info->rssi, in hci_inquiry_result_with_rssi_evt()
4832 } else if (skb->len == array_size(ev->num, in hci_inquiry_result_with_rssi_evt()
4836 for (i = 0; i < ev->num; i++) { in hci_inquiry_result_with_rssi_evt()
4848 bacpy(&data.bdaddr, &info->bdaddr); in hci_inquiry_result_with_rssi_evt()
4849 data.pscan_rep_mode = info->pscan_rep_mode; in hci_inquiry_result_with_rssi_evt()
4850 data.pscan_period_mode = info->pscan_period_mode; in hci_inquiry_result_with_rssi_evt()
4852 memcpy(data.dev_class, info->dev_class, 3); in hci_inquiry_result_with_rssi_evt()
4853 data.clock_offset = info->clock_offset; in hci_inquiry_result_with_rssi_evt()
4854 data.rssi = info->rssi; in hci_inquiry_result_with_rssi_evt()
4859 mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, in hci_inquiry_result_with_rssi_evt()
4860 info->dev_class, info->rssi, in hci_inquiry_result_with_rssi_evt()
4877 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_remote_ext_features_evt()
4881 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_remote_ext_features_evt()
4885 if (ev->page < HCI_MAX_PAGES) in hci_remote_ext_features_evt()
4886 memcpy(conn->features[ev->page], ev->features, 8); in hci_remote_ext_features_evt()
4888 if (!ev->status && ev->page == 0x01) { in hci_remote_ext_features_evt()
4891 ie = hci_inquiry_cache_lookup(hdev, &conn->dst); in hci_remote_ext_features_evt()
4893 ie->data.ssp_mode = (ev->features[0] & LMP_HOST_SSP); in hci_remote_ext_features_evt()
4895 if (ev->features[0] & LMP_HOST_SSP) { in hci_remote_ext_features_evt()
4896 set_bit(HCI_CONN_SSP_ENABLED, &conn->flags); in hci_remote_ext_features_evt()
4906 clear_bit(HCI_CONN_SSP_ENABLED, &conn->flags); in hci_remote_ext_features_evt()
4909 if (ev->features[0] & LMP_HOST_SC) in hci_remote_ext_features_evt()
4910 set_bit(HCI_CONN_SC_ENABLED, &conn->flags); in hci_remote_ext_features_evt()
4913 if (conn->state != BT_CONFIG) in hci_remote_ext_features_evt()
4916 if (!ev->status && !test_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) { in hci_remote_ext_features_evt()
4919 bacpy(&cp.bdaddr, &conn->dst); in hci_remote_ext_features_evt()
4927 conn->state = BT_CONNECTED; in hci_remote_ext_features_evt()
4928 hci_connect_cfm(conn, ev->status); in hci_remote_ext_features_evt()
4941 u8 status = ev->status; in hci_sync_conn_complete_evt()
4943 switch (ev->link_type) { in hci_sync_conn_complete_evt()
4960 conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, &ev->bdaddr); in hci_sync_conn_complete_evt()
4962 if (ev->link_type == ESCO_LINK) in hci_sync_conn_complete_evt()
4974 conn = hci_conn_hash_lookup_ba(hdev, ESCO_LINK, &ev->bdaddr); in hci_sync_conn_complete_evt()
4985 if (!HCI_CONN_HANDLE_UNSET(conn->handle)) { in hci_sync_conn_complete_evt()
4992 status = hci_conn_set_handle(conn, __le16_to_cpu(ev->handle)); in hci_sync_conn_complete_evt()
4994 conn->state = BT_CLOSED; in hci_sync_conn_complete_evt()
4998 conn->state = BT_CONNECTED; in hci_sync_conn_complete_evt()
4999 conn->type = ev->link_type; in hci_sync_conn_complete_evt()
5013 if (conn->out) { in hci_sync_conn_complete_evt()
5014 conn->pkt_type = (hdev->esco_type & SCO_ESCO_MASK) | in hci_sync_conn_complete_evt()
5015 (hdev->esco_type & EDR_ESCO_MASK); in hci_sync_conn_complete_evt()
5016 if (hci_setup_sync(conn, conn->parent->handle)) in hci_sync_conn_complete_evt()
5022 conn->state = BT_CLOSED; in hci_sync_conn_complete_evt()
5026 bt_dev_dbg(hdev, "SCO connected with air mode: %02x", ev->air_mode); in hci_sync_conn_complete_evt()
5028 * is zero and non-zero value shall be non-HCI transport data path in hci_sync_conn_complete_evt()
5030 if (conn->codec.data_path == 0 && hdev->notify) { in hci_sync_conn_complete_evt()
5031 switch (ev->air_mode) { in hci_sync_conn_complete_evt()
5033 hdev->notify(hdev, HCI_NOTIFY_ENABLE_SCO_CVSD); in hci_sync_conn_complete_evt()
5036 hdev->notify(hdev, HCI_NOTIFY_ENABLE_SCO_TRANSP); in hci_sync_conn_complete_evt()
5075 flex_array_size(ev, info, ev->num))) in hci_extended_inquiry_result_evt()
5078 bt_dev_dbg(hdev, "num %d", ev->num); in hci_extended_inquiry_result_evt()
5080 if (!ev->num) in hci_extended_inquiry_result_evt()
5088 for (i = 0; i < ev->num; i++) { in hci_extended_inquiry_result_evt()
5089 struct extended_inquiry_info *info = &ev->info[i]; in hci_extended_inquiry_result_evt()
5093 bacpy(&data.bdaddr, &info->bdaddr); in hci_extended_inquiry_result_evt()
5094 data.pscan_rep_mode = info->pscan_rep_mode; in hci_extended_inquiry_result_evt()
5095 data.pscan_period_mode = info->pscan_period_mode; in hci_extended_inquiry_result_evt()
5097 memcpy(data.dev_class, info->dev_class, 3); in hci_extended_inquiry_result_evt()
5098 data.clock_offset = info->clock_offset; in hci_extended_inquiry_result_evt()
5099 data.rssi = info->rssi; in hci_extended_inquiry_result_evt()
5103 name_known = eir_get_data(info->data, in hci_extended_inquiry_result_evt()
5104 sizeof(info->data), in hci_extended_inquiry_result_evt()
5111 eir_len = eir_get_length(info->data, sizeof(info->data)); in hci_extended_inquiry_result_evt()
5113 mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, in hci_extended_inquiry_result_evt()
5114 info->dev_class, info->rssi, in hci_extended_inquiry_result_evt()
5115 flags, info->data, eir_len, NULL, 0, 0); in hci_extended_inquiry_result_evt()
5127 bt_dev_dbg(hdev, "status 0x%2.2x handle 0x%4.4x", ev->status, in hci_key_refresh_complete_evt()
5128 __le16_to_cpu(ev->handle)); in hci_key_refresh_complete_evt()
5132 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_key_refresh_complete_evt()
5139 if (conn->type != LE_LINK) in hci_key_refresh_complete_evt()
5142 if (!ev->status) in hci_key_refresh_complete_evt()
5143 conn->sec_level = conn->pending_sec_level; in hci_key_refresh_complete_evt()
5145 clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags); in hci_key_refresh_complete_evt()
5147 if (ev->status && conn->state == BT_CONNECTED) { in hci_key_refresh_complete_evt()
5153 if (conn->state == BT_CONFIG) { in hci_key_refresh_complete_evt()
5154 if (!ev->status) in hci_key_refresh_complete_evt()
5155 conn->state = BT_CONNECTED; in hci_key_refresh_complete_evt()
5157 hci_connect_cfm(conn, ev->status); in hci_key_refresh_complete_evt()
5160 hci_auth_cfm(conn, ev->status); in hci_key_refresh_complete_evt()
5163 conn->disc_timeout = HCI_DISCONN_TIMEOUT; in hci_key_refresh_complete_evt()
5173 /* If remote requests no-bonding follow that lead */ in hci_get_auth_req()
5174 if (conn->remote_auth == HCI_AT_NO_BONDING || in hci_get_auth_req()
5175 conn->remote_auth == HCI_AT_NO_BONDING_MITM) in hci_get_auth_req()
5176 return conn->remote_auth | (conn->auth_type & 0x01); in hci_get_auth_req()
5178 /* If both remote and local have enough IO capabilities, require in hci_get_auth_req()
5181 if (conn->remote_cap != HCI_IO_NO_INPUT_OUTPUT && in hci_get_auth_req()
5182 conn->io_capability != HCI_IO_NO_INPUT_OUTPUT) in hci_get_auth_req()
5183 return conn->remote_auth | 0x01; in hci_get_auth_req()
5186 return (conn->remote_auth & ~0x01) | (conn->auth_type & 0x01); in hci_get_auth_req()
5191 struct hci_dev *hdev = conn->hdev; in bredr_oob_data_present()
5194 data = hci_find_remote_oob_data(hdev, &conn->dst, BDADDR_BREDR); in bredr_oob_data_present()
5206 return data->present; in bredr_oob_data_present()
5209 * the P-256 values are required. If they are not in bredr_oob_data_present()
5213 if (!crypto_memneq(data->rand256, ZERO_KEY, 16) || in bredr_oob_data_present()
5214 !crypto_memneq(data->hash256, ZERO_KEY, 16)) in bredr_oob_data_present()
5222 * P-192 data values are present. in bredr_oob_data_present()
5224 if (!crypto_memneq(data->rand192, ZERO_KEY, 16) || in bredr_oob_data_present()
5225 !crypto_memneq(data->hash192, ZERO_KEY, 16)) in bredr_oob_data_present()
5241 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_io_capa_request_evt()
5246 set_bit(HCI_CONN_SSP_ENABLED, &conn->flags); in hci_io_capa_request_evt()
5257 test_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags) || in hci_io_capa_request_evt()
5258 (conn->remote_auth & ~0x01) == HCI_AT_NO_BONDING) { in hci_io_capa_request_evt()
5261 bacpy(&cp.bdaddr, &ev->bdaddr); in hci_io_capa_request_evt()
5264 cp.capability = (conn->io_capability == 0x04) ? in hci_io_capa_request_evt()
5265 HCI_IO_DISPLAY_YESNO : conn->io_capability; in hci_io_capa_request_evt()
5268 if (conn->remote_auth == 0xff) { in hci_io_capa_request_evt()
5270 * except for the no-bonding case. in hci_io_capa_request_evt()
5272 if (conn->io_capability != HCI_IO_NO_INPUT_OUTPUT && in hci_io_capa_request_evt()
5273 conn->auth_type != HCI_AT_NO_BONDING) in hci_io_capa_request_evt()
5274 conn->auth_type |= 0x01; in hci_io_capa_request_evt()
5276 conn->auth_type = hci_get_auth_req(conn); in hci_io_capa_request_evt()
5279 /* If we're not bondable, force one of the non-bondable in hci_io_capa_request_evt()
5283 conn->auth_type &= HCI_AT_NO_BONDING_MITM; in hci_io_capa_request_evt()
5285 cp.authentication = conn->auth_type; in hci_io_capa_request_evt()
5293 bacpy(&cp.bdaddr, &ev->bdaddr); in hci_io_capa_request_evt()
5314 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_io_capa_reply_evt()
5318 conn->remote_cap = ev->capability; in hci_io_capa_reply_evt()
5319 conn->remote_auth = ev->authentication; in hci_io_capa_reply_evt()
5339 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_user_confirm_request_evt()
5343 loc_mitm = (conn->auth_type & 0x01); in hci_user_confirm_request_evt()
5344 rem_mitm = (conn->remote_auth & 0x01); in hci_user_confirm_request_evt()
5349 * necessarily match conn->auth_type. in hci_user_confirm_request_evt()
5351 if (conn->pending_sec_level > BT_SECURITY_MEDIUM && in hci_user_confirm_request_evt()
5352 conn->remote_cap == HCI_IO_NO_INPUT_OUTPUT) { in hci_user_confirm_request_evt()
5355 sizeof(ev->bdaddr), &ev->bdaddr); in hci_user_confirm_request_evt()
5360 if ((!loc_mitm || conn->remote_cap == HCI_IO_NO_INPUT_OUTPUT) && in hci_user_confirm_request_evt()
5361 (!rem_mitm || conn->io_capability == HCI_IO_NO_INPUT_OUTPUT)) { in hci_user_confirm_request_evt()
5364 * local IO capability is not NoInputNoOutput, use JUST_WORKS in hci_user_confirm_request_evt()
5367 if (!test_bit(HCI_CONN_AUTH_PEND, &conn->flags) && in hci_user_confirm_request_evt()
5368 conn->io_capability != HCI_IO_NO_INPUT_OUTPUT) { in hci_user_confirm_request_evt()
5369 bt_dev_dbg(hdev, "Confirming auto-accept as acceptor"); in hci_user_confirm_request_evt()
5374 /* If there already exists link key in local host, leave the in hci_user_confirm_request_evt()
5378 if (hci_find_link_key(hdev, &ev->bdaddr)) { in hci_user_confirm_request_evt()
5379 bt_dev_dbg(hdev, "Local host already has link key"); in hci_user_confirm_request_evt()
5384 BT_DBG("Auto-accept of user confirmation with %ums delay", in hci_user_confirm_request_evt()
5385 hdev->auto_accept_delay); in hci_user_confirm_request_evt()
5387 if (hdev->auto_accept_delay > 0) { in hci_user_confirm_request_evt()
5388 int delay = msecs_to_jiffies(hdev->auto_accept_delay); in hci_user_confirm_request_evt()
5389 queue_delayed_work(conn->hdev->workqueue, in hci_user_confirm_request_evt()
5390 &conn->auto_accept_work, delay); in hci_user_confirm_request_evt()
5395 sizeof(ev->bdaddr), &ev->bdaddr); in hci_user_confirm_request_evt()
5400 mgmt_user_confirm_request(hdev, &ev->bdaddr, ACL_LINK, 0, in hci_user_confirm_request_evt()
5401 le32_to_cpu(ev->passkey), confirm_hint); in hci_user_confirm_request_evt()
5415 mgmt_user_passkey_request(hdev, &ev->bdaddr, ACL_LINK, 0); in hci_user_passkey_request_evt()
5426 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_user_passkey_notify_evt()
5430 conn->passkey_notify = __le32_to_cpu(ev->passkey); in hci_user_passkey_notify_evt()
5431 conn->passkey_entered = 0; in hci_user_passkey_notify_evt()
5434 mgmt_user_passkey_notify(hdev, &conn->dst, conn->type, in hci_user_passkey_notify_evt()
5435 conn->dst_type, conn->passkey_notify, in hci_user_passkey_notify_evt()
5436 conn->passkey_entered); in hci_user_passkey_notify_evt()
5447 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_keypress_notify_evt()
5451 switch (ev->type) { in hci_keypress_notify_evt()
5453 conn->passkey_entered = 0; in hci_keypress_notify_evt()
5457 conn->passkey_entered++; in hci_keypress_notify_evt()
5461 conn->passkey_entered--; in hci_keypress_notify_evt()
5465 conn->passkey_entered = 0; in hci_keypress_notify_evt()
5473 mgmt_user_passkey_notify(hdev, &conn->dst, conn->type, in hci_keypress_notify_evt()
5474 conn->dst_type, conn->passkey_notify, in hci_keypress_notify_evt()
5475 conn->passkey_entered); in hci_keypress_notify_evt()
5488 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_simple_pair_complete_evt()
5493 conn->remote_auth = 0xff; in hci_simple_pair_complete_evt()
5500 if (!test_bit(HCI_CONN_AUTH_PEND, &conn->flags) && ev->status) in hci_simple_pair_complete_evt()
5501 mgmt_auth_failed(conn, ev->status); in hci_simple_pair_complete_evt()
5520 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_remote_host_features_evt()
5522 memcpy(conn->features[1], ev->features, 8); in hci_remote_host_features_evt()
5524 ie = hci_inquiry_cache_lookup(hdev, &ev->bdaddr); in hci_remote_host_features_evt()
5526 ie->data.ssp_mode = (ev->features[0] & LMP_HOST_SSP); in hci_remote_host_features_evt()
5544 data = hci_find_remote_oob_data(hdev, &ev->bdaddr, BDADDR_BREDR); in hci_remote_oob_data_request_evt()
5548 bacpy(&cp.bdaddr, &ev->bdaddr); in hci_remote_oob_data_request_evt()
5557 bacpy(&cp.bdaddr, &ev->bdaddr); in hci_remote_oob_data_request_evt()
5562 memcpy(cp.hash192, data->hash192, sizeof(cp.hash192)); in hci_remote_oob_data_request_evt()
5563 memcpy(cp.rand192, data->rand192, sizeof(cp.rand192)); in hci_remote_oob_data_request_evt()
5565 memcpy(cp.hash256, data->hash256, sizeof(cp.hash256)); in hci_remote_oob_data_request_evt()
5566 memcpy(cp.rand256, data->rand256, sizeof(cp.rand256)); in hci_remote_oob_data_request_evt()
5573 bacpy(&cp.bdaddr, &ev->bdaddr); in hci_remote_oob_data_request_evt()
5574 memcpy(cp.hash, data->hash192, sizeof(cp.hash)); in hci_remote_oob_data_request_evt()
5575 memcpy(cp.rand, data->rand192, sizeof(cp.rand)); in hci_remote_oob_data_request_evt()
5588 if (conn->out) { in le_conn_update_addr()
5589 conn->dst_type = bdaddr_type; in le_conn_update_addr()
5590 conn->resp_addr_type = bdaddr_type; in le_conn_update_addr()
5591 bacpy(&conn->resp_addr, bdaddr); in le_conn_update_addr()
5593 /* Check if the controller has set a Local RPA then it must be in le_conn_update_addr()
5594 * used instead or hdev->rpa. in le_conn_update_addr()
5597 conn->init_addr_type = ADDR_LE_DEV_RANDOM; in le_conn_update_addr()
5598 bacpy(&conn->init_addr, local_rpa); in le_conn_update_addr()
5599 } else if (hci_dev_test_flag(conn->hdev, HCI_PRIVACY)) { in le_conn_update_addr()
5600 conn->init_addr_type = ADDR_LE_DEV_RANDOM; in le_conn_update_addr()
5601 bacpy(&conn->init_addr, &conn->hdev->rpa); in le_conn_update_addr()
5603 hci_copy_identity_address(conn->hdev, &conn->init_addr, in le_conn_update_addr()
5604 &conn->init_addr_type); in le_conn_update_addr()
5607 conn->resp_addr_type = conn->hdev->adv_addr_type; in le_conn_update_addr()
5608 /* Check if the controller has set a Local RPA then it must be in le_conn_update_addr()
5609 * used instead or hdev->rpa. in le_conn_update_addr()
5612 conn->resp_addr_type = ADDR_LE_DEV_RANDOM; in le_conn_update_addr()
5613 bacpy(&conn->resp_addr, local_rpa); in le_conn_update_addr()
5614 } else if (conn->hdev->adv_addr_type == ADDR_LE_DEV_RANDOM) { in le_conn_update_addr()
5618 if (!ext_adv_capable(conn->hdev)) in le_conn_update_addr()
5619 bacpy(&conn->resp_addr, in le_conn_update_addr()
5620 &conn->hdev->random_addr); in le_conn_update_addr()
5622 bacpy(&conn->resp_addr, &conn->hdev->bdaddr); in le_conn_update_addr()
5625 conn->init_addr_type = bdaddr_type; in le_conn_update_addr()
5626 bacpy(&conn->init_addr, bdaddr); in le_conn_update_addr()
5633 conn->le_conn_min_interval = conn->hdev->le_conn_min_interval; in le_conn_update_addr()
5634 conn->le_conn_max_interval = conn->hdev->le_conn_max_interval; in le_conn_update_addr()
5670 conn->dst_type = bdaddr_type; in le_conn_complete_evt()
5678 * initiator address based on the HCI_PRIVACY flag. in le_conn_complete_evt()
5680 if (conn->out) { in le_conn_complete_evt()
5681 conn->resp_addr_type = bdaddr_type; in le_conn_complete_evt()
5682 bacpy(&conn->resp_addr, bdaddr); in le_conn_complete_evt()
5684 conn->init_addr_type = ADDR_LE_DEV_RANDOM; in le_conn_complete_evt()
5685 bacpy(&conn->init_addr, &hdev->rpa); in le_conn_complete_evt()
5688 &conn->init_addr, in le_conn_complete_evt()
5689 &conn->init_addr_type); in le_conn_complete_evt()
5693 cancel_delayed_work(&conn->le_conn_timeout); in le_conn_complete_evt()
5702 if (!HCI_CONN_HANDLE_UNSET(conn->handle)) { in le_conn_complete_evt()
5709 /* Lookup the identity address from the stored connection in le_conn_complete_evt()
5710 * address and address type. in le_conn_complete_evt()
5712 * When establishing connections to an identity address, the in le_conn_complete_evt()
5714 * address first. Now if it can be converted back into the in le_conn_complete_evt()
5715 * identity address, start using the identity address from in le_conn_complete_evt()
5718 irk = hci_get_irk(hdev, &conn->dst, conn->dst_type); in le_conn_complete_evt()
5720 bacpy(&conn->dst, &irk->bdaddr); in le_conn_complete_evt()
5721 conn->dst_type = irk->addr_type; in le_conn_complete_evt()
5724 conn->dst_type = ev_bdaddr_type(hdev, conn->dst_type, NULL); in le_conn_complete_evt()
5734 if (test_bit(HCI_CONN_CANCEL, &conn->flags)) { in le_conn_complete_evt()
5739 if (conn->dst_type == ADDR_LE_DEV_PUBLIC) in le_conn_complete_evt()
5745 if (hci_bdaddr_list_lookup(&hdev->reject_list, &conn->dst, addr_type)) { in le_conn_complete_evt()
5752 conn->sec_level = BT_SECURITY_LOW; in le_conn_complete_evt()
5753 conn->state = BT_CONFIG; in le_conn_complete_evt()
5756 * when sotfware rotation is in use so it can be re-enabled when in le_conn_complete_evt()
5760 conn->adv_instance = hdev->cur_adv_instance; in le_conn_complete_evt()
5762 conn->le_conn_interval = interval; in le_conn_complete_evt()
5763 conn->le_conn_latency = latency; in le_conn_complete_evt()
5764 conn->le_supv_timeout = supervision_timeout; in le_conn_complete_evt()
5773 * If the local controller supports peripheral-initiated features in le_conn_complete_evt()
5778 if (conn->out || in le_conn_complete_evt()
5779 (hdev->le_features[0] & HCI_LE_PERIPHERAL_FEATURES)) { in le_conn_complete_evt()
5782 cp.handle = __cpu_to_le16(conn->handle); in le_conn_complete_evt()
5789 conn->state = BT_CONNECTED; in le_conn_complete_evt()
5793 params = hci_pend_le_action_lookup(&hdev->pend_le_conns, &conn->dst, in le_conn_complete_evt()
5794 conn->dst_type); in le_conn_complete_evt()
5797 if (params->conn) { in le_conn_complete_evt()
5798 hci_conn_drop(params->conn); in le_conn_complete_evt()
5799 hci_conn_put(params->conn); in le_conn_complete_evt()
5800 params->conn = NULL; in le_conn_complete_evt()
5814 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_conn_complete_evt()
5816 le_conn_complete_evt(hdev, ev->status, &ev->bdaddr, ev->bdaddr_type, in hci_le_conn_complete_evt()
5817 NULL, ev->role, le16_to_cpu(ev->handle), in hci_le_conn_complete_evt()
5818 le16_to_cpu(ev->interval), in hci_le_conn_complete_evt()
5819 le16_to_cpu(ev->latency), in hci_le_conn_complete_evt()
5820 le16_to_cpu(ev->supervision_timeout)); in hci_le_conn_complete_evt()
5828 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_enh_conn_complete_evt()
5830 le_conn_complete_evt(hdev, ev->status, &ev->bdaddr, ev->bdaddr_type, in hci_le_enh_conn_complete_evt()
5831 &ev->local_rpa, ev->role, le16_to_cpu(ev->handle), in hci_le_enh_conn_complete_evt()
5832 le16_to_cpu(ev->interval), in hci_le_enh_conn_complete_evt()
5833 le16_to_cpu(ev->latency), in hci_le_enh_conn_complete_evt()
5834 le16_to_cpu(ev->supervision_timeout)); in hci_le_enh_conn_complete_evt()
5844 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_ext_adv_term_evt()
5853 if (ev->status == HCI_ERROR_CANCELLED_BY_HOST) { in hci_le_ext_adv_term_evt()
5860 adv = hci_find_adv_instance(hdev, ev->handle); in hci_le_ext_adv_term_evt()
5862 if (ev->status) { in hci_le_ext_adv_term_evt()
5867 hci_remove_adv_instance(hdev, ev->handle); in hci_le_ext_adv_term_evt()
5868 mgmt_advertising_removed(NULL, hdev, ev->handle); in hci_le_ext_adv_term_evt()
5870 list_for_each_entry_safe(adv, n, &hdev->adv_instances, list) { in hci_le_ext_adv_term_evt()
5871 if (adv->enabled) in hci_le_ext_adv_term_evt()
5881 adv->enabled = false; in hci_le_ext_adv_term_evt()
5883 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->conn_handle)); in hci_le_ext_adv_term_evt()
5886 * instance can be re-enabled when disconnected. in hci_le_ext_adv_term_evt()
5888 conn->adv_instance = ev->handle; in hci_le_ext_adv_term_evt()
5890 if (hdev->adv_addr_type != ADDR_LE_DEV_RANDOM || in hci_le_ext_adv_term_evt()
5891 bacmp(&conn->resp_addr, BDADDR_ANY)) in hci_le_ext_adv_term_evt()
5894 if (!ev->handle) { in hci_le_ext_adv_term_evt()
5895 bacpy(&conn->resp_addr, &hdev->random_addr); in hci_le_ext_adv_term_evt()
5900 bacpy(&conn->resp_addr, &adv->random_addr); in hci_le_ext_adv_term_evt()
5913 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_conn_update_complete_evt()
5915 if (ev->status) in hci_le_conn_update_complete_evt()
5920 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_conn_update_complete_evt()
5922 conn->le_conn_interval = le16_to_cpu(ev->interval); in hci_le_conn_update_complete_evt()
5923 conn->le_conn_latency = le16_to_cpu(ev->latency); in hci_le_conn_update_complete_evt()
5924 conn->le_supv_timeout = le16_to_cpu(ev->supervision_timeout); in hci_le_conn_update_complete_evt()
5930 /* This function requires the caller holds hdev->lock */
5944 if (hci_bdaddr_list_lookup(&hdev->reject_list, addr, addr_type) || in check_pending_le_conn()
5945 hdev->suspended) in check_pending_le_conn()
5951 if (hdev->conn_hash.le_num_peripheral > 0 && in check_pending_le_conn()
5952 (test_bit(HCI_QUIRK_BROKEN_LE_STATES, &hdev->quirks) || in check_pending_le_conn()
5953 !(hdev->le_states[3] & 0x10))) in check_pending_le_conn()
5959 params = hci_pend_le_action_lookup(&hdev->pend_le_conns, addr, in check_pending_le_conn()
5964 if (!params->explicit_connect) { in check_pending_le_conn()
5965 switch (params->auto_connect) { in check_pending_le_conn()
5988 BT_SECURITY_LOW, hdev->def_le_autoconnect_timeout, in check_pending_le_conn()
6000 if (!params->explicit_connect) in check_pending_le_conn()
6001 params->conn = hci_conn_get(conn); in check_pending_le_conn()
6007 case -EBUSY: in check_pending_le_conn()
6008 /* If hci_connect() returns -EBUSY it means there is already in check_pending_le_conn()
6028 struct discovery_state *d = &hdev->discovery; in process_adv_report()
6068 len = ptr - data; in process_adv_report()
6070 /* If the direct address is present, then this report is from in process_adv_report()
6072 * important to see if the address is matching the local in process_adv_report()
6073 * controller address. in process_adv_report()
6075 * If local privacy is not enable the controller shall not be in process_adv_report()
6078 * generate LE Direct Advertising Report means it is probably broken and in process_adv_report()
6080 * auto-connect logic so in case local privacy is not enable this in process_adv_report()
6094 /* If the local IRK of the controller does not match in process_adv_report()
6095 * with the resolvable random address provided, then in process_adv_report()
6098 if (!smp_irk_matches(hdev, hdev->irk, direct_addr)) in process_adv_report()
6102 /* Check if we need to convert to identity address */ in process_adv_report()
6105 bdaddr = &irk->bdaddr; in process_adv_report()
6106 bdaddr_type = irk->addr_type; in process_adv_report()
6123 memcpy(conn->le_adv_data, data, len); in process_adv_report()
6124 conn->le_adv_data_len = len; in process_adv_report()
6143 if (hdev->le_scan_type == LE_SCAN_PASSIVE) { in process_adv_report()
6147 if (!hci_pend_le_action_lookup(&hdev->pend_le_reports, in process_adv_report()
6149 idr_is_empty(&hdev->adv_monitors_idr)) in process_adv_report()
6191 match = (!bacmp(bdaddr, &d->last_adv_addr) && in process_adv_report()
6192 bdaddr_type == d->last_adv_addr_type); in process_adv_report()
6201 mgmt_device_found(hdev, &d->last_adv_addr, LE_LINK, in process_adv_report()
6202 d->last_adv_addr_type, NULL, in process_adv_report()
6203 d->last_adv_rssi, d->last_adv_flags, in process_adv_report()
6204 d->last_adv_data, in process_adv_report()
6205 d->last_adv_data_len, NULL, 0, 0); in process_adv_report()
6230 mgmt_device_found(hdev, &d->last_adv_addr, LE_LINK, in process_adv_report()
6231 d->last_adv_addr_type, NULL, rssi, d->last_adv_flags, in process_adv_report()
6232 d->last_adv_data, d->last_adv_data_len, data, len, 0); in process_adv_report()
6242 if (!ev->num) in hci_le_adv_report_evt()
6247 while (ev->num--) { in hci_le_adv_report_evt()
6258 info->length + 1)) in hci_le_adv_report_evt()
6261 if (info->length <= max_adv_len(hdev)) { in hci_le_adv_report_evt()
6262 rssi = info->data[info->length]; in hci_le_adv_report_evt()
6263 process_adv_report(hdev, info->type, &info->bdaddr, in hci_le_adv_report_evt()
6264 info->bdaddr_type, NULL, 0, in hci_le_adv_report_evt()
6266 info->data, info->length, false, in hci_le_adv_report_evt()
6326 if (!ev->num) in hci_le_ext_adv_report_evt()
6331 while (ev->num--) { in hci_le_ext_adv_report_evt()
6342 info->length)) in hci_le_ext_adv_report_evt()
6345 evt_type = __le16_to_cpu(info->type) & LE_EXT_ADV_EVT_TYPE_MASK; in hci_le_ext_adv_report_evt()
6349 &hdev->quirks)) { in hci_le_ext_adv_report_evt()
6350 info->primary_phy &= 0x1f; in hci_le_ext_adv_report_evt()
6351 info->secondary_phy &= 0x1f; in hci_le_ext_adv_report_evt()
6355 process_adv_report(hdev, legacy_evt_type, &info->bdaddr, in hci_le_ext_adv_report_evt()
6356 info->bdaddr_type, NULL, 0, in hci_le_ext_adv_report_evt()
6357 info->primary_phy, in hci_le_ext_adv_report_evt()
6358 info->secondary_phy, in hci_le_ext_adv_report_evt()
6359 info->rssi, info->data, info->length, in hci_le_ext_adv_report_evt()
6382 int mask = hdev->link_mode; in hci_le_pa_sync_estabilished_evt()
6386 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_pa_sync_estabilished_evt()
6396 &ev->bdaddr, ev->sid); in hci_le_pa_sync_estabilished_evt()
6400 clear_bit(HCI_CONN_CREATE_PA_SYNC, &conn->flags); in hci_le_pa_sync_estabilished_evt()
6402 conn->sync_handle = le16_to_cpu(ev->handle); in hci_le_pa_sync_estabilished_evt()
6403 conn->sid = HCI_SID_INVALID; in hci_le_pa_sync_estabilished_evt()
6405 mask |= hci_proto_connect_ind(hdev, &ev->bdaddr, ISO_LINK, &flags); in hci_le_pa_sync_estabilished_evt()
6407 hci_le_pa_term_sync(hdev, ev->handle); in hci_le_pa_sync_estabilished_evt()
6421 pa_sync->sync_handle = le16_to_cpu(ev->handle); in hci_le_pa_sync_estabilished_evt()
6423 if (ev->status) { in hci_le_pa_sync_estabilished_evt()
6424 set_bit(HCI_CONN_PA_SYNC_FAILED, &pa_sync->flags); in hci_le_pa_sync_estabilished_evt()
6427 hci_connect_cfm(pa_sync, ev->status); in hci_le_pa_sync_estabilished_evt()
6438 int mask = hdev->link_mode; in hci_le_per_adv_report_evt()
6442 bt_dev_dbg(hdev, "sync_handle 0x%4.4x", le16_to_cpu(ev->sync_handle)); in hci_le_per_adv_report_evt()
6455 le16_to_cpu(ev->sync_handle)); in hci_le_per_adv_report_evt()
6460 if (ev->data_status == LE_PA_DATA_COMPLETE && in hci_le_per_adv_report_evt()
6461 !test_and_set_bit(HCI_CONN_PA_SYNC, &pa_sync->flags)) { in hci_le_per_adv_report_evt()
6479 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_remote_feat_complete_evt()
6483 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_remote_feat_complete_evt()
6485 if (!ev->status) in hci_le_remote_feat_complete_evt()
6486 memcpy(conn->features[0], ev->features, 8); in hci_le_remote_feat_complete_evt()
6488 if (conn->state == BT_CONFIG) { in hci_le_remote_feat_complete_evt()
6491 /* If the local controller supports peripheral-initiated in hci_le_remote_feat_complete_evt()
6500 if (!conn->out && ev->status == HCI_ERROR_UNSUPPORTED_REMOTE_FEATURE && in hci_le_remote_feat_complete_evt()
6501 (hdev->le_features[0] & HCI_LE_PERIPHERAL_FEATURES)) in hci_le_remote_feat_complete_evt()
6504 status = ev->status; in hci_le_remote_feat_complete_evt()
6506 conn->state = BT_CONNECTED; in hci_le_remote_feat_complete_evt()
6524 bt_dev_dbg(hdev, "handle 0x%4.4x", __le16_to_cpu(ev->handle)); in hci_le_ltk_request_evt()
6528 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_ltk_request_evt()
6532 ltk = hci_find_ltk(hdev, &conn->dst, conn->dst_type, conn->role); in hci_le_ltk_request_evt()
6538 if (ev->ediv || ev->rand) in hci_le_ltk_request_evt()
6541 /* For non-SC keys check that EDiv and Rand match */ in hci_le_ltk_request_evt()
6542 if (ev->ediv != ltk->ediv || ev->rand != ltk->rand) in hci_le_ltk_request_evt()
6546 memcpy(cp.ltk, ltk->val, ltk->enc_size); in hci_le_ltk_request_evt()
6547 memset(cp.ltk + ltk->enc_size, 0, sizeof(cp.ltk) - ltk->enc_size); in hci_le_ltk_request_evt()
6548 cp.handle = cpu_to_le16(conn->handle); in hci_le_ltk_request_evt()
6550 conn->pending_sec_level = smp_ltk_sec_level(ltk); in hci_le_ltk_request_evt()
6552 conn->enc_key_size = ltk->enc_size; in hci_le_ltk_request_evt()
6559 * distribute the keys. Later, security can be re-established in hci_le_ltk_request_evt()
6562 if (ltk->type == SMP_STK) { in hci_le_ltk_request_evt()
6563 set_bit(HCI_CONN_STK_ENCRYPT, &conn->flags); in hci_le_ltk_request_evt()
6564 list_del_rcu(&ltk->list); in hci_le_ltk_request_evt()
6567 clear_bit(HCI_CONN_STK_ENCRYPT, &conn->flags); in hci_le_ltk_request_evt()
6575 neg.handle = ev->handle; in hci_le_ltk_request_evt()
6600 bt_dev_dbg(hdev, "handle 0x%4.4x", __le16_to_cpu(ev->handle)); in hci_le_remote_conn_param_req_evt()
6602 handle = le16_to_cpu(ev->handle); in hci_le_remote_conn_param_req_evt()
6603 min = le16_to_cpu(ev->interval_min); in hci_le_remote_conn_param_req_evt()
6604 max = le16_to_cpu(ev->interval_max); in hci_le_remote_conn_param_req_evt()
6605 latency = le16_to_cpu(ev->latency); in hci_le_remote_conn_param_req_evt()
6606 timeout = le16_to_cpu(ev->timeout); in hci_le_remote_conn_param_req_evt()
6609 if (!hcon || hcon->state != BT_CONNECTED) in hci_le_remote_conn_param_req_evt()
6613 if (max > hcon->le_conn_max_interval) in hci_le_remote_conn_param_req_evt()
6621 if (hcon->role == HCI_ROLE_MASTER) { in hci_le_remote_conn_param_req_evt()
6627 params = hci_conn_params_lookup(hdev, &hcon->dst, in hci_le_remote_conn_param_req_evt()
6628 hcon->dst_type); in hci_le_remote_conn_param_req_evt()
6630 params->conn_min_interval = min; in hci_le_remote_conn_param_req_evt()
6631 params->conn_max_interval = max; in hci_le_remote_conn_param_req_evt()
6632 params->conn_latency = latency; in hci_le_remote_conn_param_req_evt()
6633 params->supervision_timeout = timeout; in hci_le_remote_conn_param_req_evt()
6641 mgmt_new_conn_param(hdev, &hcon->dst, hcon->dst_type, in hci_le_remote_conn_param_req_evt()
6645 cp.handle = ev->handle; in hci_le_remote_conn_param_req_evt()
6646 cp.interval_min = ev->interval_min; in hci_le_remote_conn_param_req_evt()
6647 cp.interval_max = ev->interval_max; in hci_le_remote_conn_param_req_evt()
6648 cp.latency = ev->latency; in hci_le_remote_conn_param_req_evt()
6649 cp.timeout = ev->timeout; in hci_le_remote_conn_param_req_evt()
6664 flex_array_size(ev, info, ev->num))) in hci_le_direct_adv_report_evt()
6667 if (!ev->num) in hci_le_direct_adv_report_evt()
6672 for (i = 0; i < ev->num; i++) { in hci_le_direct_adv_report_evt()
6673 struct hci_ev_le_direct_adv_info *info = &ev->info[i]; in hci_le_direct_adv_report_evt()
6675 process_adv_report(hdev, info->type, &info->bdaddr, in hci_le_direct_adv_report_evt()
6676 info->bdaddr_type, &info->direct_addr, in hci_le_direct_adv_report_evt()
6677 info->direct_addr_type, HCI_ADV_PHY_1M, 0, in hci_le_direct_adv_report_evt()
6678 info->rssi, NULL, 0, false, false, instant); in hci_le_direct_adv_report_evt()
6690 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_phy_update_evt()
6692 if (ev->status) in hci_le_phy_update_evt()
6697 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_phy_update_evt()
6701 conn->le_tx_phy = ev->tx_phy; in hci_le_phy_update_evt()
6702 conn->le_rx_phy = ev->rx_phy; in hci_le_phy_update_evt()
6715 u16 handle = __le16_to_cpu(ev->handle); in hci_le_cis_estabilished_evt()
6718 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_cis_estabilished_evt()
6730 if (conn->type != ISO_LINK) { in hci_le_cis_estabilished_evt()
6737 qos = &conn->iso_qos; in hci_le_cis_estabilished_evt()
6739 pending = test_and_clear_bit(HCI_CONN_CREATE_CIS, &conn->flags); in hci_le_cis_estabilished_evt()
6746 * SDU_Interval = (CIG_Sync_Delay + (FT) x ISO_Interval) - in hci_le_cis_estabilished_evt()
6749 c_sdu_interval = (get_unaligned_le24(ev->cig_sync_delay) + in hci_le_cis_estabilished_evt()
6750 (ev->c_ft * le16_to_cpu(ev->interval) * 1250)) - in hci_le_cis_estabilished_evt()
6751 get_unaligned_le24(ev->c_latency); in hci_le_cis_estabilished_evt()
6752 p_sdu_interval = (get_unaligned_le24(ev->cig_sync_delay) + in hci_le_cis_estabilished_evt()
6753 (ev->p_ft * le16_to_cpu(ev->interval) * 1250)) - in hci_le_cis_estabilished_evt()
6754 get_unaligned_le24(ev->p_latency); in hci_le_cis_estabilished_evt()
6756 switch (conn->role) { in hci_le_cis_estabilished_evt()
6758 qos->ucast.in.interval = c_sdu_interval; in hci_le_cis_estabilished_evt()
6759 qos->ucast.out.interval = p_sdu_interval; in hci_le_cis_estabilished_evt()
6761 qos->ucast.in.latency = in hci_le_cis_estabilished_evt()
6762 DIV_ROUND_CLOSEST(get_unaligned_le24(ev->c_latency), in hci_le_cis_estabilished_evt()
6764 qos->ucast.out.latency = in hci_le_cis_estabilished_evt()
6765 DIV_ROUND_CLOSEST(get_unaligned_le24(ev->p_latency), in hci_le_cis_estabilished_evt()
6767 qos->ucast.in.sdu = le16_to_cpu(ev->c_mtu); in hci_le_cis_estabilished_evt()
6768 qos->ucast.out.sdu = le16_to_cpu(ev->p_mtu); in hci_le_cis_estabilished_evt()
6769 qos->ucast.in.phy = ev->c_phy; in hci_le_cis_estabilished_evt()
6770 qos->ucast.out.phy = ev->p_phy; in hci_le_cis_estabilished_evt()
6773 qos->ucast.in.interval = p_sdu_interval; in hci_le_cis_estabilished_evt()
6774 qos->ucast.out.interval = c_sdu_interval; in hci_le_cis_estabilished_evt()
6776 qos->ucast.out.latency = in hci_le_cis_estabilished_evt()
6777 DIV_ROUND_CLOSEST(get_unaligned_le24(ev->c_latency), in hci_le_cis_estabilished_evt()
6779 qos->ucast.in.latency = in hci_le_cis_estabilished_evt()
6780 DIV_ROUND_CLOSEST(get_unaligned_le24(ev->p_latency), in hci_le_cis_estabilished_evt()
6782 qos->ucast.out.sdu = le16_to_cpu(ev->c_mtu); in hci_le_cis_estabilished_evt()
6783 qos->ucast.in.sdu = le16_to_cpu(ev->p_mtu); in hci_le_cis_estabilished_evt()
6784 qos->ucast.out.phy = ev->c_phy; in hci_le_cis_estabilished_evt()
6785 qos->ucast.in.phy = ev->p_phy; in hci_le_cis_estabilished_evt()
6789 if (!ev->status) { in hci_le_cis_estabilished_evt()
6790 conn->state = BT_CONNECTED; in hci_le_cis_estabilished_evt()
6797 conn->state = BT_CLOSED; in hci_le_cis_estabilished_evt()
6798 hci_connect_cfm(conn, ev->status); in hci_le_cis_estabilished_evt()
6836 acl_handle = __le16_to_cpu(ev->acl_handle); in hci_le_cis_req_evt()
6837 cis_handle = __le16_to_cpu(ev->cis_handle); in hci_le_cis_req_evt()
6840 acl_handle, cis_handle, ev->cig_id, ev->cis_id); in hci_le_cis_req_evt()
6848 mask = hci_proto_connect_ind(hdev, &acl->dst, ISO_LINK, &flags); in hci_le_cis_req_evt()
6850 hci_le_reject_cis(hdev, ev->cis_handle); in hci_le_cis_req_evt()
6856 cis = hci_conn_add(hdev, ISO_LINK, &acl->dst, HCI_ROLE_SLAVE, in hci_le_cis_req_evt()
6859 hci_le_reject_cis(hdev, ev->cis_handle); in hci_le_cis_req_evt()
6864 cis->iso_qos.ucast.cig = ev->cig_id; in hci_le_cis_req_evt()
6865 cis->iso_qos.ucast.cis = ev->cis_id; in hci_le_cis_req_evt()
6868 hci_le_accept_cis(hdev, ev->cis_handle); in hci_le_cis_req_evt()
6870 cis->state = BT_CONNECT2; in hci_le_cis_req_evt()
6893 BT_DBG("%s status 0x%2.2x", hdev->name, ev->status); in hci_le_create_big_complete_evt()
6896 flex_array_size(ev, bis_handle, ev->num_bis))) in hci_le_create_big_complete_evt()
6902 while ((conn = hci_conn_hash_lookup_big_state(hdev, ev->handle, in hci_le_create_big_complete_evt()
6904 if (ev->status) { in hci_le_create_big_complete_evt()
6905 hci_connect_cfm(conn, ev->status); in hci_le_create_big_complete_evt()
6911 __le16_to_cpu(ev->bis_handle[i++]))) in hci_le_create_big_complete_evt()
6914 conn->state = BT_CONNECTED; in hci_le_create_big_complete_evt()
6915 set_bit(HCI_CONN_BIG_CREATED, &conn->flags); in hci_le_create_big_complete_evt()
6921 if (!ev->status && !i) in hci_le_create_big_complete_evt()
6928 UINT_PTR(ev->handle), NULL); in hci_le_create_big_complete_evt()
6940 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_big_sync_established_evt()
6943 flex_array_size(ev, bis, ev->num_bis))) in hci_le_big_sync_established_evt()
6948 conn = hci_conn_hash_lookup_big_sync_pend(hdev, ev->handle, in hci_le_big_sync_established_evt()
6949 ev->num_bis); in hci_le_big_sync_established_evt()
6953 ev->handle); in hci_le_big_sync_established_evt()
6957 clear_bit(HCI_CONN_CREATE_BIG_SYNC, &conn->flags); in hci_le_big_sync_established_evt()
6959 conn->num_bis = 0; in hci_le_big_sync_established_evt()
6960 memset(conn->bis, 0, sizeof(conn->num_bis)); in hci_le_big_sync_established_evt()
6962 for (i = 0; i < ev->num_bis; i++) { in hci_le_big_sync_established_evt()
6963 u16 handle = le16_to_cpu(ev->bis[i]); in hci_le_big_sync_established_evt()
6978 if (ev->status != 0x42) in hci_le_big_sync_established_evt()
6980 set_bit(HCI_CONN_PA_SYNC, &bis->flags); in hci_le_big_sync_established_evt()
6982 bis->sync_handle = conn->sync_handle; in hci_le_big_sync_established_evt()
6983 bis->iso_qos.bcast.big = ev->handle; in hci_le_big_sync_established_evt()
6985 memcpy(&interval, ev->latency, sizeof(ev->latency)); in hci_le_big_sync_established_evt()
6986 bis->iso_qos.bcast.in.interval = le32_to_cpu(interval); in hci_le_big_sync_established_evt()
6988 bis->iso_qos.bcast.in.latency = le16_to_cpu(ev->interval) * 125 / 100; in hci_le_big_sync_established_evt()
6989 bis->iso_qos.bcast.in.sdu = le16_to_cpu(ev->max_pdu); in hci_le_big_sync_established_evt()
6991 if (!ev->status) { in hci_le_big_sync_established_evt()
6992 set_bit(HCI_CONN_BIG_SYNC, &bis->flags); in hci_le_big_sync_established_evt()
7000 if (ev->status) in hci_le_big_sync_established_evt()
7001 for (i = 0; i < ev->num_bis; i++) { in hci_le_big_sync_established_evt()
7002 u16 handle = le16_to_cpu(ev->bis[i]); in hci_le_big_sync_established_evt()
7008 set_bit(HCI_CONN_BIG_SYNC_FAILED, &bis->flags); in hci_le_big_sync_established_evt()
7009 hci_connect_cfm(bis, ev->status); in hci_le_big_sync_established_evt()
7020 int mask = hdev->link_mode; in hci_le_big_info_adv_report_evt()
7024 bt_dev_dbg(hdev, "sync_handle 0x%4.4x", le16_to_cpu(ev->sync_handle)); in hci_le_big_info_adv_report_evt()
7037 le16_to_cpu(ev->sync_handle)); in hci_le_big_info_adv_report_evt()
7042 pa_sync->iso_qos.bcast.encryption = ev->encryption; in hci_le_big_info_adv_report_evt()
7154 bt_dev_dbg(hdev, "subevent 0x%2.2x", ev->subevent); in hci_le_meta_evt()
7157 if (hdev->req_skb && in hci_le_meta_evt()
7158 hci_opcode_ogf(hci_skb_opcode(hdev->req_skb)) == 0x08 && in hci_le_meta_evt()
7159 hci_skb_event(hdev->req_skb) == ev->subevent) { in hci_le_meta_evt()
7160 *opcode = hci_skb_opcode(hdev->req_skb); in hci_le_meta_evt()
7165 subev = &hci_le_ev_table[ev->subevent]; in hci_le_meta_evt()
7166 if (!subev->func) in hci_le_meta_evt()
7169 if (skb->len < subev->min_len) { in hci_le_meta_evt()
7171 ev->subevent, skb->len, subev->min_len); in hci_le_meta_evt()
7179 if (skb->len > subev->max_len) in hci_le_meta_evt()
7181 ev->subevent, skb->len, subev->max_len); in hci_le_meta_evt()
7182 data = hci_le_ev_skb_pull(hdev, skb, ev->subevent, subev->min_len); in hci_le_meta_evt()
7186 subev->func(hdev, data, skb); in hci_le_meta_evt()
7203 if (hdr->evt != event) in hci_get_cmd_complete()
7208 /* Check if request ended in Command Status - no way to retrieve in hci_get_cmd_complete()
7211 if (hdr->evt == HCI_EV_CMD_STATUS) in hci_get_cmd_complete()
7214 if (hdr->evt != HCI_EV_CMD_COMPLETE) { in hci_get_cmd_complete()
7216 hdr->evt); in hci_get_cmd_complete()
7224 if (opcode != __le16_to_cpu(ev->opcode)) { in hci_get_cmd_complete()
7226 __le16_to_cpu(ev->opcode)); in hci_get_cmd_complete()
7239 const struct hci_ev_conn_complete *conn_complete = (void *)skb->data; in hci_store_wake_reason()
7240 const struct hci_ev_conn_request *conn_request = (void *)skb->data; in hci_store_wake_reason()
7247 if (!hdev->suspended || hdev->wake_reason) in hci_store_wake_reason()
7253 hdev->wake_reason = MGMT_WAKE_REASON_REMOTE_WAKE; in hci_store_wake_reason()
7260 bacpy(&hdev->wake_addr, &conn_request->bdaddr); in hci_store_wake_reason()
7261 hdev->wake_addr_type = BDADDR_BREDR; in hci_store_wake_reason()
7263 bacpy(&hdev->wake_addr, &conn_complete->bdaddr); in hci_store_wake_reason()
7264 hdev->wake_addr_type = BDADDR_BREDR; in hci_store_wake_reason()
7266 struct hci_ev_le_meta *le_ev = (void *)skb->data; in hci_store_wake_reason()
7267 u8 subevent = le_ev->subevent; in hci_store_wake_reason()
7268 u8 *ptr = &skb->data[sizeof(*le_ev)]; in hci_store_wake_reason()
7281 bacpy(&hdev->wake_addr, &adv->bdaddr); in hci_store_wake_reason()
7282 hdev->wake_addr_type = adv->bdaddr_type; in hci_store_wake_reason()
7285 bacpy(&hdev->wake_addr, &direct_adv->bdaddr); in hci_store_wake_reason()
7286 hdev->wake_addr_type = direct_adv->bdaddr_type; in hci_store_wake_reason()
7289 bacpy(&hdev->wake_addr, &ext_adv->bdaddr); in hci_store_wake_reason()
7290 hdev->wake_addr_type = ext_adv->bdaddr_type; in hci_store_wake_reason()
7295 hdev->wake_reason = MGMT_WAKE_REASON_UNEXPECTED; in hci_store_wake_reason()
7471 if (!ev->func) in hci_event_func()
7474 if (skb->len < ev->min_len) { in hci_event_func()
7476 event, skb->len, ev->min_len); in hci_event_func()
7484 if (skb->len > ev->max_len) in hci_event_func()
7487 event, skb->len, ev->max_len); in hci_event_func()
7489 data = hci_ev_skb_pull(hdev, skb, event, ev->min_len); in hci_event_func()
7493 if (ev->req) in hci_event_func()
7494 ev->func_req(hdev, data, skb, opcode, status, req_complete, in hci_event_func()
7497 ev->func(hdev, data, skb); in hci_event_func()
7502 struct hci_event_hdr *hdr = (void *) skb->data; in hci_event_packet()
7509 if (skb->len < sizeof(*hdr)) { in hci_event_packet()
7514 kfree_skb(hdev->recv_event); in hci_event_packet()
7515 hdev->recv_event = skb_clone(skb, GFP_KERNEL); in hci_event_packet()
7517 event = hdr->evt; in hci_event_packet()
7525 if (hdev->req_skb && in hci_event_packet()
7526 hci_opcode_ogf(hci_skb_opcode(hdev->req_skb)) != 0x08 && in hci_event_packet()
7527 hci_skb_event(hdev->req_skb) == event) { in hci_event_packet()
7528 hci_req_cmd_complete(hdev, hci_skb_opcode(hdev->req_skb), in hci_event_packet()
7565 hdev->stat.evt_rx++; in hci_event_packet()