Lines Matching +full:adv +full:- +full:extra +full:- +full:delay
2 BlueZ - Bluetooth protocol stack for Linux
3 Copyright (c) 2000-2001, 2010, Code Aurora Forum. All rights reserved.
91 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_inquiry_cancel()
100 if (rp->status == 0x0c && !test_bit(HCI_INQUIRY, &hdev->flags)) { in hci_cc_inquiry_cancel()
102 rp->status = 0x00; in hci_cc_inquiry_cancel()
105 if (rp->status) in hci_cc_inquiry_cancel()
106 return rp->status; in hci_cc_inquiry_cancel()
108 clear_bit(HCI_INQUIRY, &hdev->flags); in hci_cc_inquiry_cancel()
110 wake_up_bit(&hdev->flags, HCI_INQUIRY); in hci_cc_inquiry_cancel()
117 hdev->le_scan_type != LE_SCAN_ACTIVE) in hci_cc_inquiry_cancel()
123 return rp->status; in hci_cc_inquiry_cancel()
131 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_periodic_inq()
133 if (rp->status) in hci_cc_periodic_inq()
134 return rp->status; in hci_cc_periodic_inq()
138 return rp->status; in hci_cc_periodic_inq()
146 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_exit_periodic_inq()
148 if (rp->status) in hci_cc_exit_periodic_inq()
149 return rp->status; in hci_cc_exit_periodic_inq()
155 return rp->status; in hci_cc_exit_periodic_inq()
163 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_remote_name_req_cancel()
165 return rp->status; in hci_cc_remote_name_req_cancel()
174 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_role_discovery()
176 if (rp->status) in hci_cc_role_discovery()
177 return rp->status; in hci_cc_role_discovery()
181 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_role_discovery()
183 conn->role = rp->role; in hci_cc_role_discovery()
187 return rp->status; in hci_cc_role_discovery()
196 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_link_policy()
198 if (rp->status) in hci_cc_read_link_policy()
199 return rp->status; in hci_cc_read_link_policy()
203 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_link_policy()
205 conn->link_policy = __le16_to_cpu(rp->policy); in hci_cc_read_link_policy()
209 return rp->status; in hci_cc_read_link_policy()
219 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_link_policy()
221 if (rp->status) in hci_cc_write_link_policy()
222 return rp->status; in hci_cc_write_link_policy()
226 return rp->status; in hci_cc_write_link_policy()
230 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_write_link_policy()
232 conn->link_policy = get_unaligned_le16(sent + 2); in hci_cc_write_link_policy()
236 return rp->status; in hci_cc_write_link_policy()
244 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_def_link_policy()
246 if (rp->status) in hci_cc_read_def_link_policy()
247 return rp->status; in hci_cc_read_def_link_policy()
249 hdev->link_policy = __le16_to_cpu(rp->policy); in hci_cc_read_def_link_policy()
251 return rp->status; in hci_cc_read_def_link_policy()
260 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_def_link_policy()
262 if (rp->status) in hci_cc_write_def_link_policy()
263 return rp->status; in hci_cc_write_def_link_policy()
267 return rp->status; in hci_cc_write_def_link_policy()
269 hdev->link_policy = get_unaligned_le16(sent); in hci_cc_write_def_link_policy()
271 return rp->status; in hci_cc_write_def_link_policy()
278 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_reset()
280 clear_bit(HCI_RESET, &hdev->flags); in hci_cc_reset()
282 if (rp->status) in hci_cc_reset()
283 return rp->status; in hci_cc_reset()
285 /* Reset all non-persistent flags */ in hci_cc_reset()
290 hdev->inq_tx_power = HCI_TX_POWER_INVALID; in hci_cc_reset()
291 hdev->adv_tx_power = HCI_TX_POWER_INVALID; in hci_cc_reset()
293 memset(hdev->adv_data, 0, sizeof(hdev->adv_data)); in hci_cc_reset()
294 hdev->adv_data_len = 0; in hci_cc_reset()
296 memset(hdev->scan_rsp_data, 0, sizeof(hdev->scan_rsp_data)); in hci_cc_reset()
297 hdev->scan_rsp_data_len = 0; in hci_cc_reset()
299 hdev->le_scan_type = LE_SCAN_PASSIVE; in hci_cc_reset()
301 hdev->ssp_debug_mode = 0; in hci_cc_reset()
303 hci_bdaddr_list_clear(&hdev->le_accept_list); in hci_cc_reset()
304 hci_bdaddr_list_clear(&hdev->le_resolv_list); in hci_cc_reset()
306 return rp->status; in hci_cc_reset()
315 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_stored_link_key()
319 return rp->status; in hci_cc_read_stored_link_key()
321 if (!rp->status && sent->read_all == 0x01) { in hci_cc_read_stored_link_key()
322 hdev->stored_max_keys = le16_to_cpu(rp->max_keys); in hci_cc_read_stored_link_key()
323 hdev->stored_num_keys = le16_to_cpu(rp->num_keys); in hci_cc_read_stored_link_key()
326 return rp->status; in hci_cc_read_stored_link_key()
335 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_delete_stored_link_key()
337 if (rp->status) in hci_cc_delete_stored_link_key()
338 return rp->status; in hci_cc_delete_stored_link_key()
340 num_keys = le16_to_cpu(rp->num_keys); in hci_cc_delete_stored_link_key()
342 if (num_keys <= hdev->stored_num_keys) in hci_cc_delete_stored_link_key()
343 hdev->stored_num_keys -= num_keys; in hci_cc_delete_stored_link_key()
345 hdev->stored_num_keys = 0; in hci_cc_delete_stored_link_key()
347 return rp->status; in hci_cc_delete_stored_link_key()
356 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_local_name()
360 return rp->status; in hci_cc_write_local_name()
365 mgmt_set_local_name_complete(hdev, sent, rp->status); in hci_cc_write_local_name()
366 else if (!rp->status) in hci_cc_write_local_name()
367 memcpy(hdev->dev_name, sent, HCI_MAX_NAME_LENGTH); in hci_cc_write_local_name()
371 return rp->status; in hci_cc_write_local_name()
379 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_name()
381 if (rp->status) in hci_cc_read_local_name()
382 return rp->status; in hci_cc_read_local_name()
386 memcpy(hdev->dev_name, rp->name, HCI_MAX_NAME_LENGTH); in hci_cc_read_local_name()
388 return rp->status; in hci_cc_read_local_name()
397 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_auth_enable()
401 return rp->status; in hci_cc_write_auth_enable()
405 if (!rp->status) { in hci_cc_write_auth_enable()
409 set_bit(HCI_AUTH, &hdev->flags); in hci_cc_write_auth_enable()
411 clear_bit(HCI_AUTH, &hdev->flags); in hci_cc_write_auth_enable()
415 mgmt_auth_enable_complete(hdev, rp->status); in hci_cc_write_auth_enable()
419 return rp->status; in hci_cc_write_auth_enable()
429 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_encrypt_mode()
431 if (rp->status) in hci_cc_write_encrypt_mode()
432 return rp->status; in hci_cc_write_encrypt_mode()
436 return rp->status; in hci_cc_write_encrypt_mode()
441 set_bit(HCI_ENCRYPT, &hdev->flags); in hci_cc_write_encrypt_mode()
443 clear_bit(HCI_ENCRYPT, &hdev->flags); in hci_cc_write_encrypt_mode()
445 return rp->status; in hci_cc_write_encrypt_mode()
455 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_scan_enable()
459 return rp->status; in hci_cc_write_scan_enable()
465 if (rp->status) { in hci_cc_write_scan_enable()
466 hdev->discov_timeout = 0; in hci_cc_write_scan_enable()
471 set_bit(HCI_ISCAN, &hdev->flags); in hci_cc_write_scan_enable()
473 clear_bit(HCI_ISCAN, &hdev->flags); in hci_cc_write_scan_enable()
476 set_bit(HCI_PSCAN, &hdev->flags); in hci_cc_write_scan_enable()
478 clear_bit(HCI_PSCAN, &hdev->flags); in hci_cc_write_scan_enable()
483 return rp->status; in hci_cc_write_scan_enable()
493 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_set_event_filter()
495 if (rp->status) in hci_cc_set_event_filter()
496 return rp->status; in hci_cc_set_event_filter()
500 return rp->status; in hci_cc_set_event_filter()
504 if (cp->flt_type == HCI_FLT_CLEAR_ALL) in hci_cc_set_event_filter()
509 return rp->status; in hci_cc_set_event_filter()
520 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_class_of_dev()
522 if (rp->status) in hci_cc_read_class_of_dev()
523 return rp->status; in hci_cc_read_class_of_dev()
525 memcpy(hdev->dev_class, rp->dev_class, 3); in hci_cc_read_class_of_dev()
527 bt_dev_dbg(hdev, "class 0x%.2x%.2x%.2x", hdev->dev_class[2], in hci_cc_read_class_of_dev()
528 hdev->dev_class[1], hdev->dev_class[0]); in hci_cc_read_class_of_dev()
530 return rp->status; in hci_cc_read_class_of_dev()
539 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_class_of_dev()
543 return rp->status; in hci_cc_write_class_of_dev()
547 if (!rp->status) in hci_cc_write_class_of_dev()
548 memcpy(hdev->dev_class, sent, 3); in hci_cc_write_class_of_dev()
551 mgmt_set_class_of_dev_complete(hdev, sent, rp->status); in hci_cc_write_class_of_dev()
555 return rp->status; in hci_cc_write_class_of_dev()
564 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_voice_setting()
566 if (rp->status) in hci_cc_read_voice_setting()
567 return rp->status; in hci_cc_read_voice_setting()
569 setting = __le16_to_cpu(rp->voice_setting); in hci_cc_read_voice_setting()
571 if (hdev->voice_setting == setting) in hci_cc_read_voice_setting()
572 return rp->status; in hci_cc_read_voice_setting()
574 hdev->voice_setting = setting; in hci_cc_read_voice_setting()
578 if (hdev->notify) in hci_cc_read_voice_setting()
579 hdev->notify(hdev, HCI_NOTIFY_VOICE_SETTING); in hci_cc_read_voice_setting()
581 return rp->status; in hci_cc_read_voice_setting()
591 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_voice_setting()
593 if (rp->status) in hci_cc_write_voice_setting()
594 return rp->status; in hci_cc_write_voice_setting()
598 return rp->status; in hci_cc_write_voice_setting()
602 if (hdev->voice_setting == setting) in hci_cc_write_voice_setting()
603 return rp->status; in hci_cc_write_voice_setting()
605 hdev->voice_setting = setting; in hci_cc_write_voice_setting()
609 if (hdev->notify) in hci_cc_write_voice_setting()
610 hdev->notify(hdev, HCI_NOTIFY_VOICE_SETTING); in hci_cc_write_voice_setting()
612 return rp->status; in hci_cc_write_voice_setting()
620 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_num_supported_iac()
622 if (rp->status) in hci_cc_read_num_supported_iac()
623 return rp->status; in hci_cc_read_num_supported_iac()
625 hdev->num_iac = rp->num_iac; in hci_cc_read_num_supported_iac()
627 bt_dev_dbg(hdev, "num iac %d", hdev->num_iac); in hci_cc_read_num_supported_iac()
629 return rp->status; in hci_cc_read_num_supported_iac()
638 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_ssp_mode()
642 return rp->status; 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()
648 hdev->features[1][0] |= LMP_HOST_SSP; in hci_cc_write_ssp_mode()
650 hdev->features[1][0] &= ~LMP_HOST_SSP; in hci_cc_write_ssp_mode()
653 if (!rp->status) { in hci_cc_write_ssp_mode()
654 if (sent->mode) in hci_cc_write_ssp_mode()
662 return rp->status; in hci_cc_write_ssp_mode()
671 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_sc_support()
675 return rp->status; in hci_cc_write_sc_support()
679 if (!rp->status) { in hci_cc_write_sc_support()
680 if (sent->support) in hci_cc_write_sc_support()
681 hdev->features[1][0] |= LMP_HOST_SC; in hci_cc_write_sc_support()
683 hdev->features[1][0] &= ~LMP_HOST_SC; in hci_cc_write_sc_support()
686 if (!hci_dev_test_flag(hdev, HCI_MGMT) && !rp->status) { in hci_cc_write_sc_support()
687 if (sent->support) in hci_cc_write_sc_support()
695 return rp->status; in hci_cc_write_sc_support()
703 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_version()
705 if (rp->status) in hci_cc_read_local_version()
706 return rp->status; in hci_cc_read_local_version()
710 hdev->hci_ver = rp->hci_ver; in hci_cc_read_local_version()
711 hdev->hci_rev = __le16_to_cpu(rp->hci_rev); in hci_cc_read_local_version()
712 hdev->lmp_ver = rp->lmp_ver; in hci_cc_read_local_version()
713 hdev->manufacturer = __le16_to_cpu(rp->manufacturer); in hci_cc_read_local_version()
714 hdev->lmp_subver = __le16_to_cpu(rp->lmp_subver); in hci_cc_read_local_version()
717 return rp->status; in hci_cc_read_local_version()
726 u8 status = rp->status; in hci_cc_read_enc_key_size()
730 handle = le16_to_cpu(rp->handle); in hci_cc_read_enc_key_size()
747 conn->enc_key_size = 0; in hci_cc_read_enc_key_size()
749 conn->enc_key_size = rp->key_size; in hci_cc_read_enc_key_size()
752 if (conn->enc_key_size < hdev->min_enc_key_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()
780 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_commands()
782 if (rp->status) in hci_cc_read_local_commands()
783 return rp->status; in hci_cc_read_local_commands()
787 memcpy(hdev->commands, rp->commands, sizeof(hdev->commands)); in hci_cc_read_local_commands()
789 return rp->status; in hci_cc_read_local_commands()
798 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_auth_payload_timeout()
800 if (rp->status) in hci_cc_read_auth_payload_timeout()
801 return rp->status; in hci_cc_read_auth_payload_timeout()
805 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_auth_payload_timeout()
807 conn->auth_payload_timeout = __le16_to_cpu(rp->timeout); in hci_cc_read_auth_payload_timeout()
811 return rp->status; in hci_cc_read_auth_payload_timeout()
821 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_auth_payload_timeout()
825 return rp->status; in hci_cc_write_auth_payload_timeout()
829 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_write_auth_payload_timeout()
831 rp->status = 0xff; in hci_cc_write_auth_payload_timeout()
835 if (!rp->status) in hci_cc_write_auth_payload_timeout()
836 conn->auth_payload_timeout = get_unaligned_le16(sent + 2); in hci_cc_write_auth_payload_timeout()
841 return rp->status; in hci_cc_write_auth_payload_timeout()
849 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_features()
851 if (rp->status) in hci_cc_read_local_features()
852 return rp->status; in hci_cc_read_local_features()
854 memcpy(hdev->features, rp->features, 8); in hci_cc_read_local_features()
859 if (hdev->features[0][0] & LMP_3SLOT) in hci_cc_read_local_features()
860 hdev->pkt_type |= (HCI_DM3 | HCI_DH3); in hci_cc_read_local_features()
862 if (hdev->features[0][0] & LMP_5SLOT) in hci_cc_read_local_features()
863 hdev->pkt_type |= (HCI_DM5 | HCI_DH5); in hci_cc_read_local_features()
865 if (hdev->features[0][1] & LMP_HV2) { in hci_cc_read_local_features()
866 hdev->pkt_type |= (HCI_HV2); in hci_cc_read_local_features()
867 hdev->esco_type |= (ESCO_HV2); in hci_cc_read_local_features()
870 if (hdev->features[0][1] & LMP_HV3) { in hci_cc_read_local_features()
871 hdev->pkt_type |= (HCI_HV3); in hci_cc_read_local_features()
872 hdev->esco_type |= (ESCO_HV3); in hci_cc_read_local_features()
876 hdev->esco_type |= (ESCO_EV3); in hci_cc_read_local_features()
878 if (hdev->features[0][4] & LMP_EV4) in hci_cc_read_local_features()
879 hdev->esco_type |= (ESCO_EV4); in hci_cc_read_local_features()
881 if (hdev->features[0][4] & LMP_EV5) in hci_cc_read_local_features()
882 hdev->esco_type |= (ESCO_EV5); in hci_cc_read_local_features()
884 if (hdev->features[0][5] & LMP_EDR_ESCO_2M) in hci_cc_read_local_features()
885 hdev->esco_type |= (ESCO_2EV3); in hci_cc_read_local_features()
887 if (hdev->features[0][5] & LMP_EDR_ESCO_3M) in hci_cc_read_local_features()
888 hdev->esco_type |= (ESCO_3EV3); in hci_cc_read_local_features()
890 if (hdev->features[0][5] & LMP_EDR_3S_ESCO) in hci_cc_read_local_features()
891 hdev->esco_type |= (ESCO_2EV5 | ESCO_3EV5); in hci_cc_read_local_features()
893 return rp->status; in hci_cc_read_local_features()
901 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_ext_features()
903 if (rp->status) in hci_cc_read_local_ext_features()
904 return rp->status; in hci_cc_read_local_ext_features()
906 if (hdev->max_page < rp->max_page) { in hci_cc_read_local_ext_features()
908 &hdev->quirks)) in hci_cc_read_local_ext_features()
911 hdev->max_page = rp->max_page; in hci_cc_read_local_ext_features()
914 if (rp->page < HCI_MAX_PAGES) in hci_cc_read_local_ext_features()
915 memcpy(hdev->features[rp->page], rp->features, 8); in hci_cc_read_local_ext_features()
917 return rp->status; in hci_cc_read_local_ext_features()
925 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_flow_control_mode()
927 if (rp->status) in hci_cc_read_flow_control_mode()
928 return rp->status; in hci_cc_read_flow_control_mode()
930 hdev->flow_ctl_mode = rp->mode; in hci_cc_read_flow_control_mode()
932 return rp->status; in hci_cc_read_flow_control_mode()
940 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_buffer_size()
942 if (rp->status) in hci_cc_read_buffer_size()
943 return rp->status; in hci_cc_read_buffer_size()
945 hdev->acl_mtu = __le16_to_cpu(rp->acl_mtu); in hci_cc_read_buffer_size()
946 hdev->sco_mtu = rp->sco_mtu; in hci_cc_read_buffer_size()
947 hdev->acl_pkts = __le16_to_cpu(rp->acl_max_pkt); in hci_cc_read_buffer_size()
948 hdev->sco_pkts = __le16_to_cpu(rp->sco_max_pkt); in hci_cc_read_buffer_size()
950 if (test_bit(HCI_QUIRK_FIXUP_BUFFER_SIZE, &hdev->quirks)) { in hci_cc_read_buffer_size()
951 hdev->sco_mtu = 64; in hci_cc_read_buffer_size()
952 hdev->sco_pkts = 8; in hci_cc_read_buffer_size()
955 hdev->acl_cnt = hdev->acl_pkts; in hci_cc_read_buffer_size()
956 hdev->sco_cnt = hdev->sco_pkts; in hci_cc_read_buffer_size()
958 BT_DBG("%s acl mtu %d:%d sco mtu %d:%d", hdev->name, hdev->acl_mtu, in hci_cc_read_buffer_size()
959 hdev->acl_pkts, hdev->sco_mtu, hdev->sco_pkts); in hci_cc_read_buffer_size()
961 return rp->status; in hci_cc_read_buffer_size()
969 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_bd_addr()
971 if (rp->status) in hci_cc_read_bd_addr()
972 return rp->status; in hci_cc_read_bd_addr()
974 if (test_bit(HCI_INIT, &hdev->flags)) in hci_cc_read_bd_addr()
975 bacpy(&hdev->bdaddr, &rp->bdaddr); in hci_cc_read_bd_addr()
978 bacpy(&hdev->setup_addr, &rp->bdaddr); in hci_cc_read_bd_addr()
980 return rp->status; in hci_cc_read_bd_addr()
988 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_pairing_opts()
990 if (rp->status) in hci_cc_read_local_pairing_opts()
991 return rp->status; in hci_cc_read_local_pairing_opts()
995 hdev->pairing_opts = rp->pairing_opts; in hci_cc_read_local_pairing_opts()
996 hdev->max_enc_key_size = rp->max_key_size; in hci_cc_read_local_pairing_opts()
999 return rp->status; in hci_cc_read_local_pairing_opts()
1007 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_page_scan_activity()
1009 if (rp->status) in hci_cc_read_page_scan_activity()
1010 return rp->status; in hci_cc_read_page_scan_activity()
1012 if (test_bit(HCI_INIT, &hdev->flags)) { in hci_cc_read_page_scan_activity()
1013 hdev->page_scan_interval = __le16_to_cpu(rp->interval); in hci_cc_read_page_scan_activity()
1014 hdev->page_scan_window = __le16_to_cpu(rp->window); in hci_cc_read_page_scan_activity()
1017 return rp->status; in hci_cc_read_page_scan_activity()
1026 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_page_scan_activity()
1028 if (rp->status) in hci_cc_write_page_scan_activity()
1029 return rp->status; in hci_cc_write_page_scan_activity()
1033 return rp->status; in hci_cc_write_page_scan_activity()
1035 hdev->page_scan_interval = __le16_to_cpu(sent->interval); in hci_cc_write_page_scan_activity()
1036 hdev->page_scan_window = __le16_to_cpu(sent->window); in hci_cc_write_page_scan_activity()
1038 return rp->status; in hci_cc_write_page_scan_activity()
1046 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_page_scan_type()
1048 if (rp->status) in hci_cc_read_page_scan_type()
1049 return rp->status; in hci_cc_read_page_scan_type()
1051 if (test_bit(HCI_INIT, &hdev->flags)) in hci_cc_read_page_scan_type()
1052 hdev->page_scan_type = rp->type; in hci_cc_read_page_scan_type()
1054 return rp->status; in hci_cc_read_page_scan_type()
1063 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_page_scan_type()
1065 if (rp->status) in hci_cc_write_page_scan_type()
1066 return rp->status; in hci_cc_write_page_scan_type()
1070 hdev->page_scan_type = *type; in hci_cc_write_page_scan_type()
1072 return rp->status; in hci_cc_write_page_scan_type()
1080 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_data_block_size()
1082 if (rp->status) in hci_cc_read_data_block_size()
1083 return rp->status; in hci_cc_read_data_block_size()
1085 hdev->block_mtu = __le16_to_cpu(rp->max_acl_len); in hci_cc_read_data_block_size()
1086 hdev->block_len = __le16_to_cpu(rp->block_len); in hci_cc_read_data_block_size()
1087 hdev->num_blocks = __le16_to_cpu(rp->num_blocks); in hci_cc_read_data_block_size()
1089 hdev->block_cnt = hdev->num_blocks; in hci_cc_read_data_block_size()
1091 BT_DBG("%s blk mtu %d cnt %d len %d", hdev->name, hdev->block_mtu, in hci_cc_read_data_block_size()
1092 hdev->block_cnt, hdev->block_len); in hci_cc_read_data_block_size()
1094 return rp->status; in hci_cc_read_data_block_size()
1104 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_clock()
1106 if (rp->status) in hci_cc_read_clock()
1107 return rp->status; in hci_cc_read_clock()
1115 if (cp->which == 0x00) { in hci_cc_read_clock()
1116 hdev->clock = le32_to_cpu(rp->clock); in hci_cc_read_clock()
1120 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_clock()
1122 conn->clock = le32_to_cpu(rp->clock); in hci_cc_read_clock()
1123 conn->clock_accuracy = le16_to_cpu(rp->accuracy); in hci_cc_read_clock()
1128 return rp->status; in hci_cc_read_clock()
1136 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_amp_info()
1138 if (rp->status) in hci_cc_read_local_amp_info()
1139 return rp->status; in hci_cc_read_local_amp_info()
1141 hdev->amp_status = rp->amp_status; in hci_cc_read_local_amp_info()
1142 hdev->amp_total_bw = __le32_to_cpu(rp->total_bw); in hci_cc_read_local_amp_info()
1143 hdev->amp_max_bw = __le32_to_cpu(rp->max_bw); in hci_cc_read_local_amp_info()
1144 hdev->amp_min_latency = __le32_to_cpu(rp->min_latency); in hci_cc_read_local_amp_info()
1145 hdev->amp_max_pdu = __le32_to_cpu(rp->max_pdu); in hci_cc_read_local_amp_info()
1146 hdev->amp_type = rp->amp_type; in hci_cc_read_local_amp_info()
1147 hdev->amp_pal_cap = __le16_to_cpu(rp->pal_cap); in hci_cc_read_local_amp_info()
1148 hdev->amp_assoc_size = __le16_to_cpu(rp->max_assoc_size); in hci_cc_read_local_amp_info()
1149 hdev->amp_be_flush_to = __le32_to_cpu(rp->be_flush_to); in hci_cc_read_local_amp_info()
1150 hdev->amp_max_flush_to = __le32_to_cpu(rp->max_flush_to); in hci_cc_read_local_amp_info()
1152 return rp->status; in hci_cc_read_local_amp_info()
1160 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_inq_rsp_tx_power()
1162 if (rp->status) in hci_cc_read_inq_rsp_tx_power()
1163 return rp->status; in hci_cc_read_inq_rsp_tx_power()
1165 hdev->inq_tx_power = rp->tx_power; in hci_cc_read_inq_rsp_tx_power()
1167 return rp->status; in hci_cc_read_inq_rsp_tx_power()
1175 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_def_err_data_reporting()
1177 if (rp->status) in hci_cc_read_def_err_data_reporting()
1178 return rp->status; in hci_cc_read_def_err_data_reporting()
1180 hdev->err_data_reporting = rp->err_data_reporting; in hci_cc_read_def_err_data_reporting()
1182 return rp->status; in hci_cc_read_def_err_data_reporting()
1191 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_def_err_data_reporting()
1193 if (rp->status) in hci_cc_write_def_err_data_reporting()
1194 return rp->status; in hci_cc_write_def_err_data_reporting()
1198 return rp->status; in hci_cc_write_def_err_data_reporting()
1200 hdev->err_data_reporting = cp->err_data_reporting; in hci_cc_write_def_err_data_reporting()
1202 return rp->status; in hci_cc_write_def_err_data_reporting()
1212 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_pin_code_reply()
1217 mgmt_pin_code_reply_complete(hdev, &rp->bdaddr, rp->status); in hci_cc_pin_code_reply()
1219 if (rp->status) in hci_cc_pin_code_reply()
1226 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cc_pin_code_reply()
1228 conn->pin_length = cp->pin_len; in hci_cc_pin_code_reply()
1232 return rp->status; in hci_cc_pin_code_reply()
1240 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_pin_code_neg_reply()
1245 mgmt_pin_code_neg_reply_complete(hdev, &rp->bdaddr, in hci_cc_pin_code_neg_reply()
1246 rp->status); in hci_cc_pin_code_neg_reply()
1250 return rp->status; in hci_cc_pin_code_neg_reply()
1258 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_read_buffer_size()
1260 if (rp->status) in hci_cc_le_read_buffer_size()
1261 return rp->status; in hci_cc_le_read_buffer_size()
1263 hdev->le_mtu = __le16_to_cpu(rp->le_mtu); in hci_cc_le_read_buffer_size()
1264 hdev->le_pkts = rp->le_max_pkt; in hci_cc_le_read_buffer_size()
1266 hdev->le_cnt = hdev->le_pkts; in hci_cc_le_read_buffer_size()
1268 BT_DBG("%s le mtu %d:%d", hdev->name, hdev->le_mtu, hdev->le_pkts); in hci_cc_le_read_buffer_size()
1270 return rp->status; in hci_cc_le_read_buffer_size()
1278 BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); in hci_cc_le_read_local_features()
1280 if (rp->status) in hci_cc_le_read_local_features()
1281 return rp->status; in hci_cc_le_read_local_features()
1283 memcpy(hdev->le_features, rp->features, 8); in hci_cc_le_read_local_features()
1285 return rp->status; in hci_cc_le_read_local_features()
1293 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_read_adv_tx_power()
1295 if (rp->status) in hci_cc_le_read_adv_tx_power()
1296 return rp->status; in hci_cc_le_read_adv_tx_power()
1298 hdev->adv_tx_power = rp->tx_power; in hci_cc_le_read_adv_tx_power()
1300 return rp->status; in hci_cc_le_read_adv_tx_power()
1308 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_user_confirm_reply()
1313 mgmt_user_confirm_reply_complete(hdev, &rp->bdaddr, ACL_LINK, 0, in hci_cc_user_confirm_reply()
1314 rp->status); in hci_cc_user_confirm_reply()
1318 return rp->status; in hci_cc_user_confirm_reply()
1326 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_user_confirm_neg_reply()
1331 mgmt_user_confirm_neg_reply_complete(hdev, &rp->bdaddr, in hci_cc_user_confirm_neg_reply()
1332 ACL_LINK, 0, rp->status); in hci_cc_user_confirm_neg_reply()
1336 return rp->status; in hci_cc_user_confirm_neg_reply()
1344 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_user_passkey_reply()
1349 mgmt_user_passkey_reply_complete(hdev, &rp->bdaddr, ACL_LINK, in hci_cc_user_passkey_reply()
1350 0, rp->status); in hci_cc_user_passkey_reply()
1354 return rp->status; in hci_cc_user_passkey_reply()
1362 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_user_passkey_neg_reply()
1367 mgmt_user_passkey_neg_reply_complete(hdev, &rp->bdaddr, in hci_cc_user_passkey_neg_reply()
1368 ACL_LINK, 0, rp->status); in hci_cc_user_passkey_neg_reply()
1372 return rp->status; in hci_cc_user_passkey_neg_reply()
1380 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_oob_data()
1382 return rp->status; in hci_cc_read_local_oob_data()
1390 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_oob_ext_data()
1392 return rp->status; in hci_cc_read_local_oob_ext_data()
1401 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_random_addr()
1403 if (rp->status) in hci_cc_le_set_random_addr()
1404 return rp->status; in hci_cc_le_set_random_addr()
1408 return rp->status; in hci_cc_le_set_random_addr()
1412 bacpy(&hdev->random_addr, sent); in hci_cc_le_set_random_addr()
1414 if (!bacmp(&hdev->rpa, sent)) { in hci_cc_le_set_random_addr()
1416 queue_delayed_work(hdev->workqueue, &hdev->rpa_expired, in hci_cc_le_set_random_addr()
1417 secs_to_jiffies(hdev->rpa_timeout)); in hci_cc_le_set_random_addr()
1422 return rp->status; in hci_cc_le_set_random_addr()
1431 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_default_phy()
1433 if (rp->status) in hci_cc_le_set_default_phy()
1434 return rp->status; in hci_cc_le_set_default_phy()
1438 return rp->status; in hci_cc_le_set_default_phy()
1442 hdev->le_tx_def_phys = cp->tx_phys; in hci_cc_le_set_default_phy()
1443 hdev->le_rx_def_phys = cp->rx_phys; in hci_cc_le_set_default_phy()
1447 return rp->status; in hci_cc_le_set_default_phy()
1455 struct adv_info *adv; in hci_cc_le_set_adv_set_random_addr() local
1457 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_adv_set_random_addr()
1459 if (rp->status) in hci_cc_le_set_adv_set_random_addr()
1460 return rp->status; in hci_cc_le_set_adv_set_random_addr()
1463 /* Update only in case the adv instance since handle 0x00 shall be using in hci_cc_le_set_adv_set_random_addr()
1465 * non-extended adverting. in hci_cc_le_set_adv_set_random_addr()
1467 if (!cp || !cp->handle) in hci_cc_le_set_adv_set_random_addr()
1468 return rp->status; in hci_cc_le_set_adv_set_random_addr()
1472 adv = hci_find_adv_instance(hdev, cp->handle); in hci_cc_le_set_adv_set_random_addr()
1473 if (adv) { in hci_cc_le_set_adv_set_random_addr()
1474 bacpy(&adv->random_addr, &cp->bdaddr); in hci_cc_le_set_adv_set_random_addr()
1475 if (!bacmp(&hdev->rpa, &cp->bdaddr)) { in hci_cc_le_set_adv_set_random_addr()
1476 adv->rpa_expired = false; in hci_cc_le_set_adv_set_random_addr()
1477 queue_delayed_work(hdev->workqueue, in hci_cc_le_set_adv_set_random_addr()
1478 &adv->rpa_expired_cb, in hci_cc_le_set_adv_set_random_addr()
1479 secs_to_jiffies(hdev->rpa_timeout)); in hci_cc_le_set_adv_set_random_addr()
1485 return rp->status; in hci_cc_le_set_adv_set_random_addr()
1495 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_remove_adv_set()
1497 if (rp->status) in hci_cc_le_remove_adv_set()
1498 return rp->status; in hci_cc_le_remove_adv_set()
1502 return rp->status; in hci_cc_le_remove_adv_set()
1508 mgmt_advertising_removed(hci_skb_sk(hdev->sent_cmd), hdev, in hci_cc_le_remove_adv_set()
1513 return rp->status; in hci_cc_le_remove_adv_set()
1520 struct adv_info *adv, *n; in hci_cc_le_clear_adv_sets() local
1523 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_clear_adv_sets()
1525 if (rp->status) in hci_cc_le_clear_adv_sets()
1526 return rp->status; in hci_cc_le_clear_adv_sets()
1529 return rp->status; in hci_cc_le_clear_adv_sets()
1533 list_for_each_entry_safe(adv, n, &hdev->adv_instances, list) { in hci_cc_le_clear_adv_sets()
1534 u8 instance = adv->instance; in hci_cc_le_clear_adv_sets()
1538 mgmt_advertising_removed(hci_skb_sk(hdev->sent_cmd), in hci_cc_le_clear_adv_sets()
1544 return rp->status; in hci_cc_le_clear_adv_sets()
1552 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_read_transmit_power()
1554 if (rp->status) in hci_cc_le_read_transmit_power()
1555 return rp->status; in hci_cc_le_read_transmit_power()
1557 hdev->min_le_tx_power = rp->min_le_tx_power; in hci_cc_le_read_transmit_power()
1558 hdev->max_le_tx_power = rp->max_le_tx_power; in hci_cc_le_read_transmit_power()
1560 return rp->status; in hci_cc_le_read_transmit_power()
1570 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_privacy_mode()
1572 if (rp->status) in hci_cc_le_set_privacy_mode()
1573 return rp->status; in hci_cc_le_set_privacy_mode()
1577 return rp->status; in hci_cc_le_set_privacy_mode()
1581 params = hci_conn_params_lookup(hdev, &cp->bdaddr, cp->bdaddr_type); in hci_cc_le_set_privacy_mode()
1583 WRITE_ONCE(params->privacy_mode, cp->mode); in hci_cc_le_set_privacy_mode()
1587 return rp->status; in hci_cc_le_set_privacy_mode()
1596 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_adv_enable()
1598 if (rp->status) in hci_cc_le_set_adv_enable()
1599 return rp->status; in hci_cc_le_set_adv_enable()
1603 return rp->status; in hci_cc_le_set_adv_enable()
1617 queue_delayed_work(hdev->workqueue, in hci_cc_le_set_adv_enable()
1618 &conn->le_conn_timeout, in hci_cc_le_set_adv_enable()
1619 conn->conn_timeout); in hci_cc_le_set_adv_enable()
1626 return rp->status; in hci_cc_le_set_adv_enable()
1634 struct adv_info *adv = NULL, *n; in hci_cc_le_set_ext_adv_enable() local
1637 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_ext_adv_enable()
1639 if (rp->status) in hci_cc_le_set_ext_adv_enable()
1640 return rp->status; in hci_cc_le_set_ext_adv_enable()
1644 return rp->status; in hci_cc_le_set_ext_adv_enable()
1646 set = (void *)cp->data; in hci_cc_le_set_ext_adv_enable()
1650 if (cp->num_of_sets) in hci_cc_le_set_ext_adv_enable()
1651 adv = hci_find_adv_instance(hdev, set->handle); in hci_cc_le_set_ext_adv_enable()
1653 if (cp->enable) { in hci_cc_le_set_ext_adv_enable()
1658 if (adv && !adv->periodic) in hci_cc_le_set_ext_adv_enable()
1659 adv->enabled = true; in hci_cc_le_set_ext_adv_enable()
1663 queue_delayed_work(hdev->workqueue, in hci_cc_le_set_ext_adv_enable()
1664 &conn->le_conn_timeout, in hci_cc_le_set_ext_adv_enable()
1665 conn->conn_timeout); in hci_cc_le_set_ext_adv_enable()
1667 if (cp->num_of_sets) { in hci_cc_le_set_ext_adv_enable()
1668 if (adv) in hci_cc_le_set_ext_adv_enable()
1669 adv->enabled = false; in hci_cc_le_set_ext_adv_enable()
1674 list_for_each_entry_safe(adv, n, &hdev->adv_instances, in hci_cc_le_set_ext_adv_enable()
1676 if (adv->enabled) in hci_cc_le_set_ext_adv_enable()
1681 list_for_each_entry_safe(adv, n, &hdev->adv_instances, in hci_cc_le_set_ext_adv_enable()
1683 adv->enabled = false; in hci_cc_le_set_ext_adv_enable()
1691 return rp->status; in hci_cc_le_set_ext_adv_enable()
1700 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_scan_param()
1702 if (rp->status) in hci_cc_le_set_scan_param()
1703 return rp->status; in hci_cc_le_set_scan_param()
1707 return rp->status; in hci_cc_le_set_scan_param()
1711 hdev->le_scan_type = cp->type; in hci_cc_le_set_scan_param()
1715 return rp->status; in hci_cc_le_set_scan_param()
1725 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_ext_scan_param()
1727 if (rp->status) in hci_cc_le_set_ext_scan_param()
1728 return rp->status; in hci_cc_le_set_ext_scan_param()
1732 return rp->status; in hci_cc_le_set_ext_scan_param()
1734 phy_param = (void *)cp->data; in hci_cc_le_set_ext_scan_param()
1738 hdev->le_scan_type = phy_param->type; in hci_cc_le_set_ext_scan_param()
1742 return rp->status; in hci_cc_le_set_ext_scan_param()
1747 struct discovery_state *d = &hdev->discovery; in has_pending_adv_report()
1749 return bacmp(&d->last_adv_addr, BDADDR_ANY); in has_pending_adv_report()
1754 struct discovery_state *d = &hdev->discovery; in clear_pending_adv_report()
1756 bacpy(&d->last_adv_addr, BDADDR_ANY); in clear_pending_adv_report()
1757 d->last_adv_data_len = 0; in clear_pending_adv_report()
1764 struct discovery_state *d = &hdev->discovery; in store_pending_adv_report()
1769 bacpy(&d->last_adv_addr, bdaddr); in store_pending_adv_report()
1770 d->last_adv_addr_type = bdaddr_type; in store_pending_adv_report()
1771 d->last_adv_rssi = rssi; in store_pending_adv_report()
1772 d->last_adv_flags = flags; in store_pending_adv_report()
1773 memcpy(d->last_adv_data, data, len); in store_pending_adv_report()
1774 d->last_adv_data_len = len; in store_pending_adv_report()
1784 if (hdev->le_scan_type == LE_SCAN_ACTIVE) in le_set_scan_enable_complete()
1796 struct discovery_state *d = &hdev->discovery; in le_set_scan_enable_complete()
1798 mgmt_device_found(hdev, &d->last_adv_addr, LE_LINK, in le_set_scan_enable_complete()
1799 d->last_adv_addr_type, NULL, in le_set_scan_enable_complete()
1800 d->last_adv_rssi, d->last_adv_flags, in le_set_scan_enable_complete()
1801 d->last_adv_data, in le_set_scan_enable_complete()
1802 d->last_adv_data_len, NULL, 0, 0); in le_set_scan_enable_complete()
1808 cancel_delayed_work(&hdev->le_scan_disable); in le_set_scan_enable_complete()
1819 hdev->discovery.state == DISCOVERY_FINDING) in le_set_scan_enable_complete()
1820 queue_work(hdev->workqueue, &hdev->reenable_adv_work); in le_set_scan_enable_complete()
1839 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_scan_enable()
1841 if (rp->status) in hci_cc_le_set_scan_enable()
1842 return rp->status; in hci_cc_le_set_scan_enable()
1846 return rp->status; in hci_cc_le_set_scan_enable()
1848 le_set_scan_enable_complete(hdev, cp->enable); in hci_cc_le_set_scan_enable()
1850 return rp->status; in hci_cc_le_set_scan_enable()
1859 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_ext_scan_enable()
1861 if (rp->status) in hci_cc_le_set_ext_scan_enable()
1862 return rp->status; in hci_cc_le_set_ext_scan_enable()
1866 return rp->status; in hci_cc_le_set_ext_scan_enable()
1868 le_set_scan_enable_complete(hdev, cp->enable); in hci_cc_le_set_ext_scan_enable()
1870 return rp->status; in hci_cc_le_set_ext_scan_enable()
1878 bt_dev_dbg(hdev, "status 0x%2.2x No of Adv sets %u", rp->status, in hci_cc_le_read_num_adv_sets()
1879 rp->num_of_sets); in hci_cc_le_read_num_adv_sets()
1881 if (rp->status) in hci_cc_le_read_num_adv_sets()
1882 return rp->status; in hci_cc_le_read_num_adv_sets()
1884 hdev->le_num_of_adv_sets = rp->num_of_sets; in hci_cc_le_read_num_adv_sets()
1886 return rp->status; in hci_cc_le_read_num_adv_sets()
1894 bt_dev_dbg(hdev, "status 0x%2.2x size %u", rp->status, rp->size); in hci_cc_le_read_accept_list_size()
1896 if (rp->status) in hci_cc_le_read_accept_list_size()
1897 return rp->status; in hci_cc_le_read_accept_list_size()
1899 hdev->le_accept_list_size = rp->size; in hci_cc_le_read_accept_list_size()
1901 return rp->status; in hci_cc_le_read_accept_list_size()
1909 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_clear_accept_list()
1911 if (rp->status) in hci_cc_le_clear_accept_list()
1912 return rp->status; in hci_cc_le_clear_accept_list()
1915 hci_bdaddr_list_clear(&hdev->le_accept_list); in hci_cc_le_clear_accept_list()
1918 return rp->status; in hci_cc_le_clear_accept_list()
1927 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_add_to_accept_list()
1929 if (rp->status) in hci_cc_le_add_to_accept_list()
1930 return rp->status; in hci_cc_le_add_to_accept_list()
1934 return rp->status; in hci_cc_le_add_to_accept_list()
1937 hci_bdaddr_list_add(&hdev->le_accept_list, &sent->bdaddr, in hci_cc_le_add_to_accept_list()
1938 sent->bdaddr_type); in hci_cc_le_add_to_accept_list()
1941 return rp->status; in hci_cc_le_add_to_accept_list()
1950 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_del_from_accept_list()
1952 if (rp->status) in hci_cc_le_del_from_accept_list()
1953 return rp->status; in hci_cc_le_del_from_accept_list()
1957 return rp->status; in hci_cc_le_del_from_accept_list()
1960 hci_bdaddr_list_del(&hdev->le_accept_list, &sent->bdaddr, in hci_cc_le_del_from_accept_list()
1961 sent->bdaddr_type); in hci_cc_le_del_from_accept_list()
1964 return rp->status; in hci_cc_le_del_from_accept_list()
1972 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_read_supported_states()
1974 if (rp->status) in hci_cc_le_read_supported_states()
1975 return rp->status; in hci_cc_le_read_supported_states()
1977 memcpy(hdev->le_states, rp->le_states, 8); in hci_cc_le_read_supported_states()
1979 return rp->status; in hci_cc_le_read_supported_states()
1987 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_read_def_data_len()
1989 if (rp->status) in hci_cc_le_read_def_data_len()
1990 return rp->status; in hci_cc_le_read_def_data_len()
1992 hdev->le_def_tx_len = le16_to_cpu(rp->tx_len); in hci_cc_le_read_def_data_len()
1993 hdev->le_def_tx_time = le16_to_cpu(rp->tx_time); in hci_cc_le_read_def_data_len()
1995 return rp->status; in hci_cc_le_read_def_data_len()
2004 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_write_def_data_len()
2006 if (rp->status) in hci_cc_le_write_def_data_len()
2007 return rp->status; in hci_cc_le_write_def_data_len()
2011 return rp->status; in hci_cc_le_write_def_data_len()
2013 hdev->le_def_tx_len = le16_to_cpu(sent->tx_len); in hci_cc_le_write_def_data_len()
2014 hdev->le_def_tx_time = le16_to_cpu(sent->tx_time); in hci_cc_le_write_def_data_len()
2016 return rp->status; in hci_cc_le_write_def_data_len()
2025 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_add_to_resolv_list()
2027 if (rp->status) in hci_cc_le_add_to_resolv_list()
2028 return rp->status; in hci_cc_le_add_to_resolv_list()
2032 return rp->status; in hci_cc_le_add_to_resolv_list()
2035 hci_bdaddr_list_add_with_irk(&hdev->le_resolv_list, &sent->bdaddr, in hci_cc_le_add_to_resolv_list()
2036 sent->bdaddr_type, sent->peer_irk, in hci_cc_le_add_to_resolv_list()
2037 sent->local_irk); in hci_cc_le_add_to_resolv_list()
2040 return rp->status; in hci_cc_le_add_to_resolv_list()
2049 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_del_from_resolv_list()
2051 if (rp->status) in hci_cc_le_del_from_resolv_list()
2052 return rp->status; in hci_cc_le_del_from_resolv_list()
2056 return rp->status; in hci_cc_le_del_from_resolv_list()
2059 hci_bdaddr_list_del_with_irk(&hdev->le_resolv_list, &sent->bdaddr, in hci_cc_le_del_from_resolv_list()
2060 sent->bdaddr_type); in hci_cc_le_del_from_resolv_list()
2063 return rp->status; in hci_cc_le_del_from_resolv_list()
2071 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_clear_resolv_list()
2073 if (rp->status) in hci_cc_le_clear_resolv_list()
2074 return rp->status; in hci_cc_le_clear_resolv_list()
2077 hci_bdaddr_list_clear(&hdev->le_resolv_list); in hci_cc_le_clear_resolv_list()
2080 return rp->status; in hci_cc_le_clear_resolv_list()
2088 bt_dev_dbg(hdev, "status 0x%2.2x size %u", rp->status, rp->size); in hci_cc_le_read_resolv_list_size()
2090 if (rp->status) in hci_cc_le_read_resolv_list_size()
2091 return rp->status; in hci_cc_le_read_resolv_list_size()
2093 hdev->le_resolv_list_size = rp->size; in hci_cc_le_read_resolv_list_size()
2095 return rp->status; in hci_cc_le_read_resolv_list_size()
2104 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_addr_resolution_enable()
2106 if (rp->status) in hci_cc_le_set_addr_resolution_enable()
2107 return rp->status; in hci_cc_le_set_addr_resolution_enable()
2111 return rp->status; in hci_cc_le_set_addr_resolution_enable()
2122 return rp->status; in hci_cc_le_set_addr_resolution_enable()
2130 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_read_max_data_len()
2132 if (rp->status) in hci_cc_le_read_max_data_len()
2133 return rp->status; in hci_cc_le_read_max_data_len()
2135 hdev->le_max_tx_len = le16_to_cpu(rp->tx_len); in hci_cc_le_read_max_data_len()
2136 hdev->le_max_tx_time = le16_to_cpu(rp->tx_time); in hci_cc_le_read_max_data_len()
2137 hdev->le_max_rx_len = le16_to_cpu(rp->rx_len); in hci_cc_le_read_max_data_len()
2138 hdev->le_max_rx_time = le16_to_cpu(rp->rx_time); in hci_cc_le_read_max_data_len()
2140 return rp->status; in hci_cc_le_read_max_data_len()
2149 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_le_host_supported()
2151 if (rp->status) in hci_cc_write_le_host_supported()
2152 return rp->status; in hci_cc_write_le_host_supported()
2156 return rp->status; in hci_cc_write_le_host_supported()
2160 if (sent->le) { in hci_cc_write_le_host_supported()
2161 hdev->features[1][0] |= LMP_HOST_LE; in hci_cc_write_le_host_supported()
2164 hdev->features[1][0] &= ~LMP_HOST_LE; in hci_cc_write_le_host_supported()
2169 if (sent->simul) in hci_cc_write_le_host_supported()
2170 hdev->features[1][0] |= LMP_HOST_LE_BREDR; in hci_cc_write_le_host_supported()
2172 hdev->features[1][0] &= ~LMP_HOST_LE_BREDR; in hci_cc_write_le_host_supported()
2176 return rp->status; in hci_cc_write_le_host_supported()
2185 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_set_adv_param()
2187 if (rp->status) in hci_cc_set_adv_param()
2188 return rp->status; in hci_cc_set_adv_param()
2192 return rp->status; in hci_cc_set_adv_param()
2195 hdev->adv_addr_type = cp->own_address_type; in hci_cc_set_adv_param()
2198 return rp->status; in hci_cc_set_adv_param()
2208 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_set_ext_adv_param()
2210 if (rp->status) in hci_cc_set_ext_adv_param()
2211 return rp->status; in hci_cc_set_ext_adv_param()
2215 return rp->status; in hci_cc_set_ext_adv_param()
2218 hdev->adv_addr_type = cp->own_addr_type; in hci_cc_set_ext_adv_param()
2219 if (!cp->handle) { in hci_cc_set_ext_adv_param()
2221 hdev->adv_tx_power = rp->tx_power; in hci_cc_set_ext_adv_param()
2223 adv_instance = hci_find_adv_instance(hdev, cp->handle); in hci_cc_set_ext_adv_param()
2225 adv_instance->tx_power = rp->tx_power; in hci_cc_set_ext_adv_param()
2227 /* Update adv data as tx power is known now */ in hci_cc_set_ext_adv_param()
2228 hci_update_adv_data(hdev, cp->handle); in hci_cc_set_ext_adv_param()
2232 return rp->status; in hci_cc_set_ext_adv_param()
2241 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_rssi()
2243 if (rp->status) in hci_cc_read_rssi()
2244 return rp->status; in hci_cc_read_rssi()
2248 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_rssi()
2250 conn->rssi = rp->rssi; in hci_cc_read_rssi()
2254 return rp->status; in hci_cc_read_rssi()
2264 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_tx_power()
2266 if (rp->status) in hci_cc_read_tx_power()
2267 return rp->status; in hci_cc_read_tx_power()
2271 return rp->status; in hci_cc_read_tx_power()
2275 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_tx_power()
2279 switch (sent->type) { in hci_cc_read_tx_power()
2281 conn->tx_power = rp->tx_power; in hci_cc_read_tx_power()
2284 conn->max_tx_power = rp->tx_power; in hci_cc_read_tx_power()
2290 return rp->status; in hci_cc_read_tx_power()
2299 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_ssp_debug_mode()
2301 if (rp->status) in hci_cc_write_ssp_debug_mode()
2302 return rp->status; in hci_cc_write_ssp_debug_mode()
2306 hdev->ssp_debug_mode = *mode; in hci_cc_write_ssp_debug_mode()
2308 return rp->status; in hci_cc_write_ssp_debug_mode()
2321 set_bit(HCI_INQUIRY, &hdev->flags); in hci_cs_inquiry()
2337 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cs_create_conn()
2339 bt_dev_dbg(hdev, "bdaddr %pMR hcon %p", &cp->bdaddr, conn); in hci_cs_create_conn()
2342 if (conn && conn->state == BT_CONNECT) { in hci_cs_create_conn()
2343 if (status != 0x0c || conn->attempt > 2) { in hci_cs_create_conn()
2344 conn->state = BT_CLOSED; in hci_cs_create_conn()
2348 conn->state = BT_CONNECT2; in hci_cs_create_conn()
2352 conn = hci_conn_add_unset(hdev, ACL_LINK, &cp->bdaddr, in hci_cs_create_conn()
2378 handle = __le16_to_cpu(cp->handle); in hci_cs_add_sco()
2386 link = list_first_entry_or_null(&acl->link_list, in hci_cs_add_sco()
2388 if (link && link->conn) { in hci_cs_add_sco()
2389 link->conn->state = BT_CLOSED; in hci_cs_add_sco()
2391 hci_connect_cfm(link->conn, status); in hci_cs_add_sco()
2392 hci_conn_del(link->conn); in hci_cs_add_sco()
2415 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_auth_requested()
2417 if (conn->state == BT_CONFIG) { in hci_cs_auth_requested()
2442 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_set_conn_encrypt()
2444 if (conn->state == BT_CONFIG) { in hci_cs_set_conn_encrypt()
2456 if (conn->state != BT_CONFIG || !conn->out) in hci_outgoing_auth_needed()
2459 if (conn->pending_sec_level == BT_SECURITY_SDP) in hci_outgoing_auth_needed()
2462 /* Only request authentication for SSP connections or non-SSP in hci_outgoing_auth_needed()
2466 if (!hci_conn_ssp_enabled(conn) && !(conn->auth_type & 0x01) && in hci_outgoing_auth_needed()
2467 conn->pending_sec_level != BT_SECURITY_FIPS && in hci_outgoing_auth_needed()
2468 conn->pending_sec_level != BT_SECURITY_HIGH && in hci_outgoing_auth_needed()
2469 conn->pending_sec_level != BT_SECURITY_MEDIUM) in hci_outgoing_auth_needed()
2482 bacpy(&cp.bdaddr, &e->data.bdaddr); in hci_resolve_name()
2483 cp.pscan_rep_mode = e->data.pscan_rep_mode; in hci_resolve_name()
2484 cp.pscan_mode = e->data.pscan_mode; in hci_resolve_name()
2485 cp.clock_offset = e->data.clock_offset; in hci_resolve_name()
2492 struct discovery_state *discov = &hdev->discovery; in hci_resolve_next_name()
2495 if (list_empty(&discov->resolve)) in hci_resolve_next_name()
2499 if (time_after(jiffies, discov->name_resolve_timeout)) { in hci_resolve_next_name()
2509 e->name_state = NAME_PENDING; in hci_resolve_next_name()
2519 struct discovery_state *discov = &hdev->discovery; in hci_check_pending_name()
2527 if (conn && (conn->state == BT_CONFIG || conn->state == BT_CONNECTED)) in hci_check_pending_name()
2530 if (discov->state == DISCOVERY_STOPPED) in hci_check_pending_name()
2533 if (discov->state == DISCOVERY_STOPPING) in hci_check_pending_name()
2536 if (discov->state != DISCOVERY_RESOLVING) in hci_check_pending_name()
2547 list_del(&e->list); in hci_check_pending_name()
2549 e->name_state = name ? NAME_KNOWN : NAME_NOT_KNOWN; in hci_check_pending_name()
2550 mgmt_remote_name(hdev, bdaddr, ACL_LINK, 0x00, e->data.rssi, in hci_check_pending_name()
2578 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cs_remote_name_req()
2581 hci_check_pending_name(hdev, conn, &cp->bdaddr, NULL, 0); in hci_cs_remote_name_req()
2589 if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->flags)) { in hci_cs_remote_name_req()
2592 set_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags); in hci_cs_remote_name_req()
2594 auth_cp.handle = __cpu_to_le16(conn->handle); in hci_cs_remote_name_req()
2619 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_read_remote_features()
2621 if (conn->state == BT_CONFIG) { in hci_cs_read_remote_features()
2646 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_read_remote_ext_features()
2648 if (conn->state == BT_CONFIG) { in hci_cs_read_remote_ext_features()
2669 link = list_first_entry_or_null(&acl->link_list, in hci_setup_sync_conn_status()
2671 if (link && link->conn) { in hci_setup_sync_conn_status()
2672 link->conn->state = BT_CLOSED; in hci_setup_sync_conn_status()
2674 hci_connect_cfm(link->conn, status); in hci_setup_sync_conn_status()
2675 hci_conn_del(link->conn); in hci_setup_sync_conn_status()
2695 hci_setup_sync_conn_status(hdev, __le16_to_cpu(cp->handle), status); in hci_cs_setup_sync_conn()
2711 hci_setup_sync_conn_status(hdev, __le16_to_cpu(cp->handle), status); in hci_cs_enhanced_setup_sync_conn()
2730 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_sniff_mode()
2732 clear_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->flags); in hci_cs_sniff_mode()
2734 if (test_and_clear_bit(HCI_CONN_SCO_SETUP_PEND, &conn->flags)) in hci_cs_sniff_mode()
2757 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_exit_sniff_mode()
2759 clear_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->flags); in hci_cs_exit_sniff_mode()
2761 if (test_and_clear_bit(HCI_CONN_SCO_SETUP_PEND, &conn->flags)) in hci_cs_exit_sniff_mode()
2780 if (!status && !hdev->suspended) in hci_cs_disconnect()
2789 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_disconnect()
2794 mgmt_disconnect_failed(hdev, &conn->dst, conn->type, in hci_cs_disconnect()
2795 conn->dst_type, status); in hci_cs_disconnect()
2797 if (conn->type == LE_LINK && conn->role == HCI_ROLE_SLAVE) { in hci_cs_disconnect()
2798 hdev->cur_adv_instance = conn->adv_instance; in hci_cs_disconnect()
2808 mgmt_conn = test_and_clear_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags); in hci_cs_disconnect()
2810 if (conn->type == ACL_LINK) { in hci_cs_disconnect()
2811 if (test_and_clear_bit(HCI_CONN_FLUSH_KEY, &conn->flags)) in hci_cs_disconnect()
2812 hci_remove_link_key(hdev, &conn->dst); in hci_cs_disconnect()
2815 params = hci_conn_params_lookup(hdev, &conn->dst, conn->dst_type); in hci_cs_disconnect()
2817 switch (params->auto_connect) { in hci_cs_disconnect()
2819 if (cp->reason != HCI_ERROR_CONNECTION_TIMEOUT) in hci_cs_disconnect()
2826 hci_pend_le_list_add(params, &hdev->pend_le_conns); in hci_cs_disconnect()
2834 mgmt_device_disconnected(hdev, &conn->dst, conn->type, conn->dst_type, in hci_cs_disconnect()
2835 cp->reason, mgmt_conn); in hci_cs_disconnect()
2837 hci_disconn_cfm(conn, cp->reason); in hci_cs_disconnect()
2842 * Hence, we need to do some basic cleanup here and re-enable in hci_cs_disconnect()
2889 conn->init_addr_type = own_address_type; in cs_le_create_conn()
2891 bacpy(&conn->init_addr, &hdev->random_addr); in cs_le_create_conn()
2893 bacpy(&conn->init_addr, &hdev->bdaddr); in cs_le_create_conn()
2895 conn->resp_addr_type = peer_addr_type; in cs_le_create_conn()
2896 bacpy(&conn->resp_addr, peer_addr); in cs_le_create_conn()
2918 cs_le_create_conn(hdev, &cp->peer_addr, cp->peer_addr_type, in hci_cs_le_create_conn()
2919 cp->own_address_type, cp->filter_policy); in hci_cs_le_create_conn()
2943 cs_le_create_conn(hdev, &cp->peer_addr, cp->peer_addr_type, in hci_cs_le_ext_create_conn()
2944 cp->own_addr_type, cp->filter_policy); in hci_cs_le_ext_create_conn()
2965 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_le_read_remote_features()
2967 if (conn->state == BT_CONFIG) { in hci_cs_le_read_remote_features()
2992 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_le_start_enc()
2996 if (conn->state != BT_CONNECTED) in hci_cs_le_start_enc()
3011 BT_DBG("%s status 0x%2.2x", hdev->name, status); in hci_cs_switch_role()
3022 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cs_switch_role()
3024 clear_bit(HCI_CONN_RSWITCH_PEND, &conn->flags); in hci_cs_switch_role()
3033 struct discovery_state *discov = &hdev->discovery; in hci_inquiry_complete_evt()
3036 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_inquiry_complete_evt()
3040 if (!test_and_clear_bit(HCI_INQUIRY, &hdev->flags)) in hci_inquiry_complete_evt()
3044 wake_up_bit(&hdev->flags, HCI_INQUIRY); in hci_inquiry_complete_evt()
3051 if (discov->state != DISCOVERY_FINDING) in hci_inquiry_complete_evt()
3054 if (list_empty(&discov->resolve)) { in hci_inquiry_complete_evt()
3063 !test_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks)) in hci_inquiry_complete_evt()
3070 e->name_state = NAME_PENDING; in hci_inquiry_complete_evt()
3072 discov->name_resolve_timeout = jiffies + NAME_RESOLVE_DURATION; in hci_inquiry_complete_evt()
3082 !test_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks)) in hci_inquiry_complete_evt()
3098 flex_array_size(ev, info, ev->num))) in hci_inquiry_result_evt()
3101 bt_dev_dbg(hdev, "num %d", ev->num); in hci_inquiry_result_evt()
3103 if (!ev->num) in hci_inquiry_result_evt()
3111 for (i = 0; i < ev->num; i++) { in hci_inquiry_result_evt()
3112 struct inquiry_info *info = &ev->info[i]; in hci_inquiry_result_evt()
3115 bacpy(&data.bdaddr, &info->bdaddr); in hci_inquiry_result_evt()
3116 data.pscan_rep_mode = info->pscan_rep_mode; in hci_inquiry_result_evt()
3117 data.pscan_period_mode = info->pscan_period_mode; in hci_inquiry_result_evt()
3118 data.pscan_mode = info->pscan_mode; in hci_inquiry_result_evt()
3119 memcpy(data.dev_class, info->dev_class, 3); in hci_inquiry_result_evt()
3120 data.clock_offset = info->clock_offset; in hci_inquiry_result_evt()
3126 mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, in hci_inquiry_result_evt()
3127 info->dev_class, HCI_RSSI_INVALID, in hci_inquiry_result_evt()
3139 u8 status = ev->status; in hci_conn_complete_evt()
3145 conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, &ev->bdaddr); in hci_conn_complete_evt()
3150 if (ev->status) in hci_conn_complete_evt()
3153 /* Connection may not exist if auto-connected. Check the bredr in hci_conn_complete_evt()
3158 * Auto-connect will only occur if the event filter is in hci_conn_complete_evt()
3162 if (ev->link_type == ACL_LINK && in hci_conn_complete_evt()
3163 hci_bdaddr_list_lookup_with_flags(&hdev->accept_list, in hci_conn_complete_evt()
3164 &ev->bdaddr, in hci_conn_complete_evt()
3166 conn = hci_conn_add_unset(hdev, ev->link_type, in hci_conn_complete_evt()
3167 &ev->bdaddr, HCI_ROLE_SLAVE); in hci_conn_complete_evt()
3173 if (ev->link_type != SCO_LINK) in hci_conn_complete_evt()
3177 &ev->bdaddr); in hci_conn_complete_evt()
3181 conn->type = SCO_LINK; in hci_conn_complete_evt()
3191 if (!HCI_CONN_HANDLE_UNSET(conn->handle)) { in hci_conn_complete_evt()
3197 status = hci_conn_set_handle(conn, __le16_to_cpu(ev->handle)); in hci_conn_complete_evt()
3201 if (conn->type == ACL_LINK) { in hci_conn_complete_evt()
3202 conn->state = BT_CONFIG; in hci_conn_complete_evt()
3205 if (!conn->out && !hci_conn_ssp_enabled(conn) && in hci_conn_complete_evt()
3206 !hci_find_link_key(hdev, &ev->bdaddr)) in hci_conn_complete_evt()
3207 conn->disc_timeout = HCI_PAIRING_TIMEOUT; in hci_conn_complete_evt()
3209 conn->disc_timeout = HCI_DISCONN_TIMEOUT; in hci_conn_complete_evt()
3211 conn->state = BT_CONNECTED; in hci_conn_complete_evt()
3216 if (test_bit(HCI_AUTH, &hdev->flags)) in hci_conn_complete_evt()
3217 set_bit(HCI_CONN_AUTH, &conn->flags); in hci_conn_complete_evt()
3219 if (test_bit(HCI_ENCRYPT, &hdev->flags)) in hci_conn_complete_evt()
3220 set_bit(HCI_CONN_ENCRYPT, &conn->flags); in hci_conn_complete_evt()
3223 if (conn->type == ACL_LINK) { in hci_conn_complete_evt()
3225 cp.handle = ev->handle; in hci_conn_complete_evt()
3233 if (!conn->out && hdev->hci_ver < BLUETOOTH_VER_2_0) { in hci_conn_complete_evt()
3235 cp.handle = ev->handle; in hci_conn_complete_evt()
3236 cp.pkt_type = cpu_to_le16(conn->pkt_type); in hci_conn_complete_evt()
3242 if (conn->type == ACL_LINK) in hci_conn_complete_evt()
3243 hci_sco_setup(conn, ev->status); in hci_conn_complete_evt()
3248 } else if (ev->link_type == SCO_LINK) { in hci_conn_complete_evt()
3249 switch (conn->setting & SCO_AIRMODE_MASK) { in hci_conn_complete_evt()
3251 if (hdev->notify) in hci_conn_complete_evt()
3252 hdev->notify(hdev, HCI_NOTIFY_ENABLE_SCO_CVSD); in hci_conn_complete_evt()
3278 int mask = hdev->link_mode; in hci_conn_request_evt()
3283 bt_dev_dbg(hdev, "bdaddr %pMR type 0x%x", &ev->bdaddr, ev->link_type); in hci_conn_request_evt()
3286 * CVE-2020-26555 in hci_conn_request_evt()
3288 if (hdev && !bacmp(&hdev->bdaddr, &ev->bdaddr)) { in hci_conn_request_evt()
3290 &ev->bdaddr); in hci_conn_request_evt()
3291 hci_reject_conn(hdev, &ev->bdaddr); in hci_conn_request_evt()
3295 mask |= hci_proto_connect_ind(hdev, &ev->bdaddr, ev->link_type, in hci_conn_request_evt()
3299 hci_reject_conn(hdev, &ev->bdaddr); in hci_conn_request_evt()
3305 if (hci_bdaddr_list_lookup(&hdev->reject_list, &ev->bdaddr, in hci_conn_request_evt()
3307 hci_reject_conn(hdev, &ev->bdaddr); in hci_conn_request_evt()
3317 !hci_bdaddr_list_lookup_with_flags(&hdev->accept_list, &ev->bdaddr, in hci_conn_request_evt()
3319 hci_reject_conn(hdev, &ev->bdaddr); in hci_conn_request_evt()
3325 ie = hci_inquiry_cache_lookup(hdev, &ev->bdaddr); in hci_conn_request_evt()
3327 memcpy(ie->data.dev_class, ev->dev_class, 3); in hci_conn_request_evt()
3329 conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, in hci_conn_request_evt()
3330 &ev->bdaddr); in hci_conn_request_evt()
3332 conn = hci_conn_add_unset(hdev, ev->link_type, &ev->bdaddr, in hci_conn_request_evt()
3340 memcpy(conn->dev_class, ev->dev_class, 3); in hci_conn_request_evt()
3344 if (ev->link_type == ACL_LINK || in hci_conn_request_evt()
3347 conn->state = BT_CONNECT; in hci_conn_request_evt()
3349 bacpy(&cp.bdaddr, &ev->bdaddr); in hci_conn_request_evt()
3359 conn->state = BT_CONNECT; in hci_conn_request_evt()
3361 bacpy(&cp.bdaddr, &ev->bdaddr); in hci_conn_request_evt()
3362 cp.pkt_type = cpu_to_le16(conn->pkt_type); in hci_conn_request_evt()
3367 cp.content_format = cpu_to_le16(hdev->voice_setting); in hci_conn_request_evt()
3373 conn->state = BT_CONNECT2; in hci_conn_request_evt()
3407 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_disconn_complete_evt()
3411 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_disconn_complete_evt()
3415 if (ev->status) { in hci_disconn_complete_evt()
3416 mgmt_disconnect_failed(hdev, &conn->dst, conn->type, in hci_disconn_complete_evt()
3417 conn->dst_type, ev->status); in hci_disconn_complete_evt()
3421 conn->state = BT_CLOSED; in hci_disconn_complete_evt()
3423 mgmt_connected = test_and_clear_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags); in hci_disconn_complete_evt()
3425 if (test_bit(HCI_CONN_AUTH_FAILURE, &conn->flags)) in hci_disconn_complete_evt()
3428 reason = hci_to_mgmt_reason(ev->reason); in hci_disconn_complete_evt()
3430 mgmt_device_disconnected(hdev, &conn->dst, conn->type, conn->dst_type, in hci_disconn_complete_evt()
3433 if (conn->type == ACL_LINK) { in hci_disconn_complete_evt()
3434 if (test_and_clear_bit(HCI_CONN_FLUSH_KEY, &conn->flags)) in hci_disconn_complete_evt()
3435 hci_remove_link_key(hdev, &conn->dst); in hci_disconn_complete_evt()
3440 params = hci_conn_params_lookup(hdev, &conn->dst, conn->dst_type); in hci_disconn_complete_evt()
3442 switch (params->auto_connect) { in hci_disconn_complete_evt()
3444 if (ev->reason != HCI_ERROR_CONNECTION_TIMEOUT) in hci_disconn_complete_evt()
3451 hci_pend_le_list_add(params, &hdev->pend_le_conns); in hci_disconn_complete_evt()
3460 hci_disconn_cfm(conn, ev->reason); in hci_disconn_complete_evt()
3462 /* Re-enable advertising if necessary, since it might in hci_disconn_complete_evt()
3472 if (conn->type == LE_LINK && conn->role == HCI_ROLE_SLAVE) { in hci_disconn_complete_evt()
3473 hdev->cur_adv_instance = conn->adv_instance; in hci_disconn_complete_evt()
3489 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_auth_complete_evt()
3493 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_auth_complete_evt()
3497 if (!ev->status) { in hci_auth_complete_evt()
3498 clear_bit(HCI_CONN_AUTH_FAILURE, &conn->flags); in hci_auth_complete_evt()
3499 set_bit(HCI_CONN_AUTH, &conn->flags); in hci_auth_complete_evt()
3500 conn->sec_level = conn->pending_sec_level; in hci_auth_complete_evt()
3502 if (ev->status == HCI_ERROR_PIN_OR_KEY_MISSING) in hci_auth_complete_evt()
3503 set_bit(HCI_CONN_AUTH_FAILURE, &conn->flags); in hci_auth_complete_evt()
3505 mgmt_auth_failed(conn, ev->status); in hci_auth_complete_evt()
3508 clear_bit(HCI_CONN_AUTH_PEND, &conn->flags); in hci_auth_complete_evt()
3510 if (conn->state == BT_CONFIG) { in hci_auth_complete_evt()
3511 if (!ev->status && hci_conn_ssp_enabled(conn)) { in hci_auth_complete_evt()
3513 cp.handle = ev->handle; in hci_auth_complete_evt()
3518 conn->state = BT_CONNECTED; in hci_auth_complete_evt()
3519 hci_connect_cfm(conn, ev->status); in hci_auth_complete_evt()
3523 hci_auth_cfm(conn, ev->status); in hci_auth_complete_evt()
3526 conn->disc_timeout = HCI_DISCONN_TIMEOUT; in hci_auth_complete_evt()
3530 if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags)) { in hci_auth_complete_evt()
3531 if (!ev->status) { in hci_auth_complete_evt()
3533 cp.handle = ev->handle; in hci_auth_complete_evt()
3538 clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags); in hci_auth_complete_evt()
3539 hci_encrypt_cfm(conn, ev->status); in hci_auth_complete_evt()
3553 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_remote_name_evt()
3557 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_remote_name_evt()
3562 if (ev->status == 0) in hci_remote_name_evt()
3563 hci_check_pending_name(hdev, conn, &ev->bdaddr, ev->name, in hci_remote_name_evt()
3564 strnlen(ev->name, HCI_MAX_NAME_LENGTH)); in hci_remote_name_evt()
3566 hci_check_pending_name(hdev, conn, &ev->bdaddr, NULL, 0); in hci_remote_name_evt()
3575 if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->flags)) { in hci_remote_name_evt()
3578 set_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags); in hci_remote_name_evt()
3580 cp.handle = __cpu_to_le16(conn->handle); in hci_remote_name_evt()
3594 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_encrypt_change_evt()
3598 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_encrypt_change_evt()
3602 if (!ev->status) { in hci_encrypt_change_evt()
3603 if (ev->encrypt) { in hci_encrypt_change_evt()
3605 set_bit(HCI_CONN_AUTH, &conn->flags); in hci_encrypt_change_evt()
3606 set_bit(HCI_CONN_ENCRYPT, &conn->flags); in hci_encrypt_change_evt()
3607 conn->sec_level = conn->pending_sec_level; in hci_encrypt_change_evt()
3609 /* P-256 authentication key implies FIPS */ in hci_encrypt_change_evt()
3610 if (conn->key_type == HCI_LK_AUTH_COMBINATION_P256) in hci_encrypt_change_evt()
3611 set_bit(HCI_CONN_FIPS, &conn->flags); in hci_encrypt_change_evt()
3613 if ((conn->type == ACL_LINK && ev->encrypt == 0x02) || in hci_encrypt_change_evt()
3614 conn->type == LE_LINK) in hci_encrypt_change_evt()
3615 set_bit(HCI_CONN_AES_CCM, &conn->flags); in hci_encrypt_change_evt()
3617 clear_bit(HCI_CONN_ENCRYPT, &conn->flags); in hci_encrypt_change_evt()
3618 clear_bit(HCI_CONN_AES_CCM, &conn->flags); in hci_encrypt_change_evt()
3625 if (ev->status && conn->type == LE_LINK) { in hci_encrypt_change_evt()
3630 clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags); in hci_encrypt_change_evt()
3634 ev->status = HCI_ERROR_AUTH_FAILURE; in hci_encrypt_change_evt()
3636 if (ev->status && conn->state == BT_CONNECTED) { in hci_encrypt_change_evt()
3637 if (ev->status == HCI_ERROR_PIN_OR_KEY_MISSING) in hci_encrypt_change_evt()
3638 set_bit(HCI_CONN_AUTH_FAILURE, &conn->flags); in hci_encrypt_change_evt()
3643 hci_encrypt_cfm(conn, ev->status); in hci_encrypt_change_evt()
3650 if (!ev->status && ev->encrypt && conn->type == ACL_LINK) { in hci_encrypt_change_evt()
3657 if (!(hdev->commands[20] & 0x10)) { in hci_encrypt_change_evt()
3658 conn->enc_key_size = HCI_LINK_KEY_SIZE; in hci_encrypt_change_evt()
3662 cp.handle = cpu_to_le16(conn->handle); in hci_encrypt_change_evt()
3666 conn->enc_key_size = HCI_LINK_KEY_SIZE; in hci_encrypt_change_evt()
3678 * Ensure for AES-CCM encryption as well. in hci_encrypt_change_evt()
3680 if (test_bit(HCI_CONN_ENCRYPT, &conn->flags) && in hci_encrypt_change_evt()
3681 test_bit(HCI_CONN_AES_CCM, &conn->flags) && in hci_encrypt_change_evt()
3682 ((conn->type == ACL_LINK && lmp_ping_capable(hdev)) || in hci_encrypt_change_evt()
3683 (conn->type == LE_LINK && (hdev->le_features[0] & HCI_LE_PING)))) { in hci_encrypt_change_evt()
3686 cp.handle = cpu_to_le16(conn->handle); in hci_encrypt_change_evt()
3687 cp.timeout = cpu_to_le16(hdev->auth_payload_timeout); in hci_encrypt_change_evt()
3688 if (hci_send_cmd(conn->hdev, HCI_OP_WRITE_AUTH_PAYLOAD_TO, in hci_encrypt_change_evt()
3694 hci_encrypt_cfm(conn, ev->status); in hci_encrypt_change_evt()
3706 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_change_link_key_complete_evt()
3710 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_change_link_key_complete_evt()
3712 if (!ev->status) in hci_change_link_key_complete_evt()
3713 set_bit(HCI_CONN_SECURE, &conn->flags); in hci_change_link_key_complete_evt()
3715 clear_bit(HCI_CONN_AUTH_PEND, &conn->flags); in hci_change_link_key_complete_evt()
3717 hci_key_change_cfm(conn, ev->status); in hci_change_link_key_complete_evt()
3729 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_remote_features_evt()
3733 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_remote_features_evt()
3737 if (!ev->status) in hci_remote_features_evt()
3738 memcpy(conn->features[0], ev->features, 8); in hci_remote_features_evt()
3740 if (conn->state != BT_CONFIG) in hci_remote_features_evt()
3743 if (!ev->status && lmp_ext_feat_capable(hdev) && in hci_remote_features_evt()
3746 cp.handle = ev->handle; in hci_remote_features_evt()
3753 if (!ev->status && !test_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) { in hci_remote_features_evt()
3756 bacpy(&cp.bdaddr, &conn->dst); in hci_remote_features_evt()
3764 conn->state = BT_CONNECTED; in hci_remote_features_evt()
3765 hci_connect_cfm(conn, ev->status); in hci_remote_features_evt()
3775 cancel_delayed_work(&hdev->cmd_timer); in handle_cmd_cnt_and_timer()
3778 if (!test_bit(HCI_RESET, &hdev->flags)) { in handle_cmd_cnt_and_timer()
3780 cancel_delayed_work(&hdev->ncmd_timer); in handle_cmd_cnt_and_timer()
3781 atomic_set(&hdev->cmd_cnt, 1); in handle_cmd_cnt_and_timer()
3784 queue_delayed_work(hdev->workqueue, &hdev->ncmd_timer, in handle_cmd_cnt_and_timer()
3796 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_read_buffer_size_v2()
3798 if (rp->status) in hci_cc_le_read_buffer_size_v2()
3799 return rp->status; in hci_cc_le_read_buffer_size_v2()
3801 hdev->le_mtu = __le16_to_cpu(rp->acl_mtu); in hci_cc_le_read_buffer_size_v2()
3802 hdev->le_pkts = rp->acl_max_pkt; in hci_cc_le_read_buffer_size_v2()
3803 hdev->iso_mtu = __le16_to_cpu(rp->iso_mtu); in hci_cc_le_read_buffer_size_v2()
3804 hdev->iso_pkts = rp->iso_max_pkt; in hci_cc_le_read_buffer_size_v2()
3806 hdev->le_cnt = hdev->le_pkts; in hci_cc_le_read_buffer_size_v2()
3807 hdev->iso_cnt = hdev->iso_pkts; in hci_cc_le_read_buffer_size_v2()
3809 BT_DBG("%s acl mtu %d:%d iso mtu %d:%d", hdev->name, hdev->acl_mtu, in hci_cc_le_read_buffer_size_v2()
3810 hdev->acl_pkts, hdev->iso_mtu, hdev->iso_pkts); in hci_cc_le_read_buffer_size_v2()
3812 return rp->status; in hci_cc_le_read_buffer_size_v2()
3819 lockdep_assert_held(&hdev->lock); in hci_unbound_cis_failed()
3821 list_for_each_entry_safe(conn, tmp, &hdev->conn_hash.list, list) { in hci_unbound_cis_failed()
3822 if (conn->type != ISO_LINK || !bacmp(&conn->dst, BDADDR_ANY) || in hci_unbound_cis_failed()
3823 conn->state == BT_OPEN || conn->iso_qos.ucast.cig != cig) in hci_unbound_cis_failed()
3826 if (HCI_CONN_HANDLE_UNSET(conn->handle)) in hci_unbound_cis_failed()
3837 u8 status = rp->status; in hci_cc_le_set_cig_params()
3841 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_cig_params()
3844 if (!rp->status && (!cp || rp->num_handles != cp->num_cis || in hci_cc_le_set_cig_params()
3845 rp->cig_id != cp->cig_id)) { in hci_cc_le_set_cig_params()
3854 * If the Status return parameter is non-zero, then the state of the CIG in hci_cc_le_set_cig_params()
3860 hci_unbound_cis_failed(hdev, rp->cig_id, status); in hci_cc_le_set_cig_params()
3871 for (i = 0; i < rp->num_handles; ++i) { in hci_cc_le_set_cig_params()
3872 conn = hci_conn_hash_lookup_cis(hdev, NULL, 0, rp->cig_id, in hci_cc_le_set_cig_params()
3873 cp->cis[i].cis_id); in hci_cc_le_set_cig_params()
3874 if (!conn || !bacmp(&conn->dst, BDADDR_ANY)) in hci_cc_le_set_cig_params()
3877 if (conn->state != BT_BOUND && conn->state != BT_CONNECT) in hci_cc_le_set_cig_params()
3880 if (hci_conn_set_handle(conn, __le16_to_cpu(rp->handle[i]))) in hci_cc_le_set_cig_params()
3883 if (conn->state == BT_CONNECT) in hci_cc_le_set_cig_params()
3893 return rp->status; in hci_cc_le_set_cig_params()
3903 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_setup_iso_path()
3907 return rp->status; in hci_cc_le_setup_iso_path()
3911 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cc_le_setup_iso_path()
3915 if (rp->status) { in hci_cc_le_setup_iso_path()
3916 hci_connect_cfm(conn, rp->status); in hci_cc_le_setup_iso_path()
3921 switch (cp->direction) { in hci_cc_le_setup_iso_path()
3925 if (conn->iso_qos.ucast.out.sdu && !conn->iso_qos.ucast.in.sdu) in hci_cc_le_setup_iso_path()
3926 hci_connect_cfm(conn, rp->status); in hci_cc_le_setup_iso_path()
3930 /* Confirm connection since conn->iso_qos is always configured in hci_cc_le_setup_iso_path()
3933 hci_connect_cfm(conn, rp->status); in hci_cc_le_setup_iso_path()
3936 if (!rp->status && test_bit(HCI_CONN_BIG_SYNC, &conn->flags)) in hci_cc_le_setup_iso_path()
3944 return rp->status; in hci_cc_le_setup_iso_path()
3958 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_set_per_adv_param()
3960 if (rp->status) in hci_cc_set_per_adv_param()
3961 return rp->status; in hci_cc_set_per_adv_param()
3965 return rp->status; in hci_cc_set_per_adv_param()
3968 return rp->status; in hci_cc_set_per_adv_param()
3976 struct adv_info *adv = NULL, *n; in hci_cc_le_set_per_adv_enable() local
3979 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_per_adv_enable()
3981 if (rp->status) in hci_cc_le_set_per_adv_enable()
3982 return rp->status; in hci_cc_le_set_per_adv_enable()
3986 return rp->status; in hci_cc_le_set_per_adv_enable()
3990 adv = hci_find_adv_instance(hdev, cp->handle); in hci_cc_le_set_per_adv_enable()
3992 if (cp->enable) { in hci_cc_le_set_per_adv_enable()
3995 if (adv) in hci_cc_le_set_per_adv_enable()
3996 adv->enabled = true; in hci_cc_le_set_per_adv_enable()
4000 * The current periodic adv instance will be marked as in hci_cc_le_set_per_adv_enable()
4003 list_for_each_entry_safe(adv, n, &hdev->adv_instances, in hci_cc_le_set_per_adv_enable()
4005 if (adv->periodic && adv->enabled) in hci_cc_le_set_per_adv_enable()
4018 return rp->status; in hci_cc_le_set_per_adv_enable()
4215 if (skb->len < cc->min_len) { in hci_cc_func()
4217 cc->op, skb->len, cc->min_len); in hci_cc_func()
4225 if (skb->len > cc->max_len) in hci_cc_func()
4227 cc->op, skb->len, cc->max_len); in hci_cc_func()
4229 data = hci_cc_skb_pull(hdev, skb, cc->op, cc->min_len); in hci_cc_func()
4233 return cc->func(hdev, data, skb); in hci_cc_func()
4244 *opcode = __le16_to_cpu(ev->opcode); in hci_cmd_complete_evt()
4263 *status = skb->data[0]; in hci_cmd_complete_evt()
4266 handle_cmd_cnt_and_timer(hdev, ev->ncmd); in hci_cmd_complete_evt()
4277 if (atomic_read(&hdev->cmd_cnt) && !skb_queue_empty(&hdev->cmd_q)) in hci_cmd_complete_evt()
4278 queue_work(hdev->workqueue, &hdev->cmd_work); in hci_cmd_complete_evt()
4299 for (i = 0; cp->num_cis; cp->num_cis--, i++) { in hci_cs_le_create_cis()
4303 handle = __le16_to_cpu(cp->cis[i].cis_handle); in hci_cs_le_create_cis()
4308 &conn->flags)) in hci_cs_le_create_cis()
4310 conn->state = BT_CLOSED; in hci_cs_le_create_cis()
4364 *opcode = __le16_to_cpu(ev->opcode); in hci_cmd_status_evt()
4365 *status = ev->status; in hci_cmd_status_evt()
4371 hci_cs_table[i].func(hdev, ev->status); in hci_cmd_status_evt()
4376 handle_cmd_cnt_and_timer(hdev, ev->ncmd); in hci_cmd_status_evt()
4384 if (ev->status || (hdev->req_skb && !hci_skb_event(hdev->req_skb))) { in hci_cmd_status_evt()
4385 hci_req_cmd_complete(hdev, *opcode, ev->status, req_complete, in hci_cmd_status_evt()
4394 if (atomic_read(&hdev->cmd_cnt) && !skb_queue_empty(&hdev->cmd_q)) in hci_cmd_status_evt()
4395 queue_work(hdev->workqueue, &hdev->cmd_work); in hci_cmd_status_evt()
4403 bt_dev_dbg(hdev, "code 0x%2.2x", ev->code); in hci_hardware_error_evt()
4405 hdev->hw_error_code = ev->code; in hci_hardware_error_evt()
4407 queue_work(hdev->req_workqueue, &hdev->error_reset); in hci_hardware_error_evt()
4416 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_role_change_evt()
4420 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_role_change_evt()
4422 if (!ev->status) in hci_role_change_evt()
4423 conn->role = ev->role; in hci_role_change_evt()
4425 clear_bit(HCI_CONN_RSWITCH_PEND, &conn->flags); in hci_role_change_evt()
4427 hci_role_switch_cfm(conn, ev->status, ev->role); in hci_role_change_evt()
4440 flex_array_size(ev, handles, ev->num))) in hci_num_comp_pkts_evt()
4443 if (hdev->flow_ctl_mode != HCI_FLOW_CTL_MODE_PACKET_BASED) { in hci_num_comp_pkts_evt()
4444 bt_dev_err(hdev, "wrong event for mode %d", hdev->flow_ctl_mode); in hci_num_comp_pkts_evt()
4448 bt_dev_dbg(hdev, "num %d", ev->num); in hci_num_comp_pkts_evt()
4450 for (i = 0; i < ev->num; i++) { in hci_num_comp_pkts_evt()
4451 struct hci_comp_pkts_info *info = &ev->handles[i]; in hci_num_comp_pkts_evt()
4455 handle = __le16_to_cpu(info->handle); in hci_num_comp_pkts_evt()
4456 count = __le16_to_cpu(info->count); in hci_num_comp_pkts_evt()
4462 conn->sent -= count; in hci_num_comp_pkts_evt()
4464 switch (conn->type) { in hci_num_comp_pkts_evt()
4466 hdev->acl_cnt += count; in hci_num_comp_pkts_evt()
4467 if (hdev->acl_cnt > hdev->acl_pkts) in hci_num_comp_pkts_evt()
4468 hdev->acl_cnt = hdev->acl_pkts; in hci_num_comp_pkts_evt()
4472 if (hdev->le_pkts) { in hci_num_comp_pkts_evt()
4473 hdev->le_cnt += count; in hci_num_comp_pkts_evt()
4474 if (hdev->le_cnt > hdev->le_pkts) in hci_num_comp_pkts_evt()
4475 hdev->le_cnt = hdev->le_pkts; in hci_num_comp_pkts_evt()
4477 hdev->acl_cnt += count; in hci_num_comp_pkts_evt()
4478 if (hdev->acl_cnt > hdev->acl_pkts) in hci_num_comp_pkts_evt()
4479 hdev->acl_cnt = hdev->acl_pkts; in hci_num_comp_pkts_evt()
4484 hdev->sco_cnt += count; in hci_num_comp_pkts_evt()
4485 if (hdev->sco_cnt > hdev->sco_pkts) in hci_num_comp_pkts_evt()
4486 hdev->sco_cnt = hdev->sco_pkts; in hci_num_comp_pkts_evt()
4490 if (hdev->iso_pkts) { in hci_num_comp_pkts_evt()
4491 hdev->iso_cnt += count; in hci_num_comp_pkts_evt()
4492 if (hdev->iso_cnt > hdev->iso_pkts) in hci_num_comp_pkts_evt()
4493 hdev->iso_cnt = hdev->iso_pkts; in hci_num_comp_pkts_evt()
4494 } else if (hdev->le_pkts) { in hci_num_comp_pkts_evt()
4495 hdev->le_cnt += count; in hci_num_comp_pkts_evt()
4496 if (hdev->le_cnt > hdev->le_pkts) in hci_num_comp_pkts_evt()
4497 hdev->le_cnt = hdev->le_pkts; in hci_num_comp_pkts_evt()
4499 hdev->acl_cnt += count; in hci_num_comp_pkts_evt()
4500 if (hdev->acl_cnt > hdev->acl_pkts) in hci_num_comp_pkts_evt()
4501 hdev->acl_cnt = hdev->acl_pkts; in hci_num_comp_pkts_evt()
4507 conn->type, conn); in hci_num_comp_pkts_evt()
4512 queue_work(hdev->workqueue, &hdev->tx_work); in hci_num_comp_pkts_evt()
4520 switch (hdev->dev_type) { in __hci_conn_lookup_handle()
4526 return chan->conn; in __hci_conn_lookup_handle()
4529 bt_dev_err(hdev, "unknown dev_type %d", hdev->dev_type); in __hci_conn_lookup_handle()
4543 flex_array_size(ev, handles, ev->num_hndl))) in hci_num_comp_blocks_evt()
4546 if (hdev->flow_ctl_mode != HCI_FLOW_CTL_MODE_BLOCK_BASED) { in hci_num_comp_blocks_evt()
4548 hdev->flow_ctl_mode); in hci_num_comp_blocks_evt()
4552 bt_dev_dbg(hdev, "num_blocks %d num_hndl %d", ev->num_blocks, in hci_num_comp_blocks_evt()
4553 ev->num_hndl); in hci_num_comp_blocks_evt()
4555 for (i = 0; i < ev->num_hndl; i++) { in hci_num_comp_blocks_evt()
4556 struct hci_comp_blocks_info *info = &ev->handles[i]; in hci_num_comp_blocks_evt()
4560 handle = __le16_to_cpu(info->handle); in hci_num_comp_blocks_evt()
4561 block_count = __le16_to_cpu(info->blocks); in hci_num_comp_blocks_evt()
4567 conn->sent -= block_count; in hci_num_comp_blocks_evt()
4569 switch (conn->type) { in hci_num_comp_blocks_evt()
4572 hdev->block_cnt += block_count; in hci_num_comp_blocks_evt()
4573 if (hdev->block_cnt > hdev->num_blocks) in hci_num_comp_blocks_evt()
4574 hdev->block_cnt = hdev->num_blocks; in hci_num_comp_blocks_evt()
4579 conn->type, conn); in hci_num_comp_blocks_evt()
4584 queue_work(hdev->workqueue, &hdev->tx_work); in hci_num_comp_blocks_evt()
4593 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_mode_change_evt()
4597 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_mode_change_evt()
4599 conn->mode = ev->mode; in hci_mode_change_evt()
4602 &conn->flags)) { in hci_mode_change_evt()
4603 if (conn->mode == HCI_CM_ACTIVE) in hci_mode_change_evt()
4604 set_bit(HCI_CONN_POWER_SAVE, &conn->flags); in hci_mode_change_evt()
4606 clear_bit(HCI_CONN_POWER_SAVE, &conn->flags); in hci_mode_change_evt()
4609 if (test_and_clear_bit(HCI_CONN_SCO_SETUP_PEND, &conn->flags)) in hci_mode_change_evt()
4610 hci_sco_setup(conn, ev->status); in hci_mode_change_evt()
4626 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_pin_code_request_evt()
4630 if (conn->state == BT_CONNECTED) { in hci_pin_code_request_evt()
4632 conn->disc_timeout = HCI_PAIRING_TIMEOUT; in hci_pin_code_request_evt()
4637 !test_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags)) { in hci_pin_code_request_evt()
4639 sizeof(ev->bdaddr), &ev->bdaddr); in hci_pin_code_request_evt()
4643 if (conn->pending_sec_level == BT_SECURITY_HIGH) in hci_pin_code_request_evt()
4648 mgmt_pin_code_request(hdev, &ev->bdaddr, secure); in hci_pin_code_request_evt()
4660 conn->pin_length = pin_len; in conn_set_key()
4661 conn->key_type = key_type; in conn_set_key()
4670 conn->pending_sec_level = BT_SECURITY_HIGH; in conn_set_key()
4672 conn->pending_sec_level = BT_SECURITY_MEDIUM; in conn_set_key()
4676 conn->pending_sec_level = BT_SECURITY_MEDIUM; in conn_set_key()
4679 conn->pending_sec_level = BT_SECURITY_HIGH; in conn_set_key()
4682 conn->pending_sec_level = BT_SECURITY_FIPS; in conn_set_key()
4702 key = hci_find_link_key(hdev, &ev->bdaddr); in hci_link_key_request_evt()
4704 bt_dev_dbg(hdev, "link key not found for %pMR", &ev->bdaddr); in hci_link_key_request_evt()
4708 bt_dev_dbg(hdev, "found key type %u for %pMR", key->type, &ev->bdaddr); in hci_link_key_request_evt()
4710 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_link_key_request_evt()
4712 clear_bit(HCI_CONN_NEW_LINK_KEY, &conn->flags); in hci_link_key_request_evt()
4714 if ((key->type == HCI_LK_UNAUTH_COMBINATION_P192 || in hci_link_key_request_evt()
4715 key->type == HCI_LK_UNAUTH_COMBINATION_P256) && in hci_link_key_request_evt()
4716 conn->auth_type != 0xff && (conn->auth_type & 0x01)) { in hci_link_key_request_evt()
4721 if (key->type == HCI_LK_COMBINATION && key->pin_len < 16 && in hci_link_key_request_evt()
4722 (conn->pending_sec_level == BT_SECURITY_HIGH || in hci_link_key_request_evt()
4723 conn->pending_sec_level == BT_SECURITY_FIPS)) { in hci_link_key_request_evt()
4728 conn_set_key(conn, key->type, key->pin_len); in hci_link_key_request_evt()
4731 bacpy(&cp.bdaddr, &ev->bdaddr); in hci_link_key_request_evt()
4732 memcpy(cp.link_key, key->val, HCI_LINK_KEY_SIZE); in hci_link_key_request_evt()
4741 hci_send_cmd(hdev, HCI_OP_LINK_KEY_NEG_REPLY, 6, &ev->bdaddr); in hci_link_key_request_evt()
4758 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_link_key_notify_evt()
4762 /* Ignore NULL link key against CVE-2020-26555 */ in hci_link_key_notify_evt()
4763 if (!crypto_memneq(ev->link_key, ZERO_KEY, HCI_LINK_KEY_SIZE)) { in hci_link_key_notify_evt()
4765 &ev->bdaddr); in hci_link_key_notify_evt()
4772 conn->disc_timeout = HCI_DISCONN_TIMEOUT; in hci_link_key_notify_evt()
4775 set_bit(HCI_CONN_NEW_LINK_KEY, &conn->flags); in hci_link_key_notify_evt()
4776 conn_set_key(conn, ev->key_type, conn->pin_length); in hci_link_key_notify_evt()
4781 key = hci_add_link_key(hdev, conn, &ev->bdaddr, ev->link_key, in hci_link_key_notify_evt()
4782 ev->key_type, pin_len, &persistent); in hci_link_key_notify_evt()
4789 if (ev->key_type == HCI_LK_CHANGED_COMBINATION) in hci_link_key_notify_evt()
4790 conn_set_key(conn, key->type, key->pin_len); in hci_link_key_notify_evt()
4799 if (key->type == HCI_LK_DEBUG_COMBINATION && in hci_link_key_notify_evt()
4801 list_del_rcu(&key->list); in hci_link_key_notify_evt()
4807 clear_bit(HCI_CONN_FLUSH_KEY, &conn->flags); in hci_link_key_notify_evt()
4809 set_bit(HCI_CONN_FLUSH_KEY, &conn->flags); in hci_link_key_notify_evt()
4821 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_clock_offset_evt()
4825 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_clock_offset_evt()
4826 if (conn && !ev->status) { in hci_clock_offset_evt()
4829 ie = hci_inquiry_cache_lookup(hdev, &conn->dst); in hci_clock_offset_evt()
4831 ie->data.clock_offset = ev->clock_offset; in hci_clock_offset_evt()
4832 ie->timestamp = jiffies; in hci_clock_offset_evt()
4845 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_pkt_type_change_evt()
4849 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_pkt_type_change_evt()
4850 if (conn && !ev->status) in hci_pkt_type_change_evt()
4851 conn->pkt_type = __le16_to_cpu(ev->pkt_type); in hci_pkt_type_change_evt()
4866 ie = hci_inquiry_cache_lookup(hdev, &ev->bdaddr); in hci_pscan_rep_mode_evt()
4868 ie->data.pscan_rep_mode = ev->pscan_rep_mode; in hci_pscan_rep_mode_evt()
4869 ie->timestamp = jiffies; in hci_pscan_rep_mode_evt()
4882 bt_dev_dbg(hdev, "num_rsp %d", ev->num); in hci_inquiry_result_with_rssi_evt()
4884 if (!ev->num) in hci_inquiry_result_with_rssi_evt()
4892 if (skb->len == array_size(ev->num, in hci_inquiry_result_with_rssi_evt()
4896 for (i = 0; i < ev->num; i++) { in hci_inquiry_result_with_rssi_evt()
4908 bacpy(&data.bdaddr, &info->bdaddr); in hci_inquiry_result_with_rssi_evt()
4909 data.pscan_rep_mode = info->pscan_rep_mode; in hci_inquiry_result_with_rssi_evt()
4910 data.pscan_period_mode = info->pscan_period_mode; in hci_inquiry_result_with_rssi_evt()
4911 data.pscan_mode = info->pscan_mode; in hci_inquiry_result_with_rssi_evt()
4912 memcpy(data.dev_class, info->dev_class, 3); in hci_inquiry_result_with_rssi_evt()
4913 data.clock_offset = info->clock_offset; in hci_inquiry_result_with_rssi_evt()
4914 data.rssi = info->rssi; in hci_inquiry_result_with_rssi_evt()
4919 mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, in hci_inquiry_result_with_rssi_evt()
4920 info->dev_class, info->rssi, in hci_inquiry_result_with_rssi_evt()
4923 } else if (skb->len == array_size(ev->num, in hci_inquiry_result_with_rssi_evt()
4927 for (i = 0; i < ev->num; i++) { in hci_inquiry_result_with_rssi_evt()
4939 bacpy(&data.bdaddr, &info->bdaddr); in hci_inquiry_result_with_rssi_evt()
4940 data.pscan_rep_mode = info->pscan_rep_mode; in hci_inquiry_result_with_rssi_evt()
4941 data.pscan_period_mode = info->pscan_period_mode; in hci_inquiry_result_with_rssi_evt()
4943 memcpy(data.dev_class, info->dev_class, 3); in hci_inquiry_result_with_rssi_evt()
4944 data.clock_offset = info->clock_offset; in hci_inquiry_result_with_rssi_evt()
4945 data.rssi = info->rssi; in hci_inquiry_result_with_rssi_evt()
4950 mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, in hci_inquiry_result_with_rssi_evt()
4951 info->dev_class, info->rssi, in hci_inquiry_result_with_rssi_evt()
4968 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_remote_ext_features_evt()
4972 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_remote_ext_features_evt()
4976 if (ev->page < HCI_MAX_PAGES) in hci_remote_ext_features_evt()
4977 memcpy(conn->features[ev->page], ev->features, 8); in hci_remote_ext_features_evt()
4979 if (!ev->status && ev->page == 0x01) { in hci_remote_ext_features_evt()
4982 ie = hci_inquiry_cache_lookup(hdev, &conn->dst); in hci_remote_ext_features_evt()
4984 ie->data.ssp_mode = (ev->features[0] & LMP_HOST_SSP); in hci_remote_ext_features_evt()
4986 if (ev->features[0] & LMP_HOST_SSP) { in hci_remote_ext_features_evt()
4987 set_bit(HCI_CONN_SSP_ENABLED, &conn->flags); in hci_remote_ext_features_evt()
4997 clear_bit(HCI_CONN_SSP_ENABLED, &conn->flags); in hci_remote_ext_features_evt()
5000 if (ev->features[0] & LMP_HOST_SC) in hci_remote_ext_features_evt()
5001 set_bit(HCI_CONN_SC_ENABLED, &conn->flags); in hci_remote_ext_features_evt()
5004 if (conn->state != BT_CONFIG) in hci_remote_ext_features_evt()
5007 if (!ev->status && !test_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) { in hci_remote_ext_features_evt()
5010 bacpy(&cp.bdaddr, &conn->dst); in hci_remote_ext_features_evt()
5018 conn->state = BT_CONNECTED; in hci_remote_ext_features_evt()
5019 hci_connect_cfm(conn, ev->status); in hci_remote_ext_features_evt()
5032 u8 status = ev->status; in hci_sync_conn_complete_evt()
5034 switch (ev->link_type) { in hci_sync_conn_complete_evt()
5051 conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, &ev->bdaddr); in hci_sync_conn_complete_evt()
5053 if (ev->link_type == ESCO_LINK) in hci_sync_conn_complete_evt()
5065 conn = hci_conn_hash_lookup_ba(hdev, ESCO_LINK, &ev->bdaddr); in hci_sync_conn_complete_evt()
5076 if (!HCI_CONN_HANDLE_UNSET(conn->handle)) { in hci_sync_conn_complete_evt()
5083 status = hci_conn_set_handle(conn, __le16_to_cpu(ev->handle)); in hci_sync_conn_complete_evt()
5085 conn->state = BT_CLOSED; in hci_sync_conn_complete_evt()
5089 conn->state = BT_CONNECTED; in hci_sync_conn_complete_evt()
5090 conn->type = ev->link_type; in hci_sync_conn_complete_evt()
5104 if (conn->out) { in hci_sync_conn_complete_evt()
5105 conn->pkt_type = (hdev->esco_type & SCO_ESCO_MASK) | in hci_sync_conn_complete_evt()
5106 (hdev->esco_type & EDR_ESCO_MASK); in hci_sync_conn_complete_evt()
5107 if (hci_setup_sync(conn, conn->parent->handle)) in hci_sync_conn_complete_evt()
5113 conn->state = BT_CLOSED; in hci_sync_conn_complete_evt()
5117 bt_dev_dbg(hdev, "SCO connected with air mode: %02x", ev->air_mode); in hci_sync_conn_complete_evt()
5119 * is zero and non-zero value shall be non-HCI transport data path in hci_sync_conn_complete_evt()
5121 if (conn->codec.data_path == 0 && hdev->notify) { in hci_sync_conn_complete_evt()
5122 switch (ev->air_mode) { in hci_sync_conn_complete_evt()
5124 hdev->notify(hdev, HCI_NOTIFY_ENABLE_SCO_CVSD); in hci_sync_conn_complete_evt()
5127 hdev->notify(hdev, HCI_NOTIFY_ENABLE_SCO_TRANSP); in hci_sync_conn_complete_evt()
5166 flex_array_size(ev, info, ev->num))) in hci_extended_inquiry_result_evt()
5169 bt_dev_dbg(hdev, "num %d", ev->num); in hci_extended_inquiry_result_evt()
5171 if (!ev->num) in hci_extended_inquiry_result_evt()
5179 for (i = 0; i < ev->num; i++) { in hci_extended_inquiry_result_evt()
5180 struct extended_inquiry_info *info = &ev->info[i]; in hci_extended_inquiry_result_evt()
5184 bacpy(&data.bdaddr, &info->bdaddr); in hci_extended_inquiry_result_evt()
5185 data.pscan_rep_mode = info->pscan_rep_mode; in hci_extended_inquiry_result_evt()
5186 data.pscan_period_mode = info->pscan_period_mode; in hci_extended_inquiry_result_evt()
5188 memcpy(data.dev_class, info->dev_class, 3); in hci_extended_inquiry_result_evt()
5189 data.clock_offset = info->clock_offset; in hci_extended_inquiry_result_evt()
5190 data.rssi = info->rssi; in hci_extended_inquiry_result_evt()
5194 name_known = eir_get_data(info->data, in hci_extended_inquiry_result_evt()
5195 sizeof(info->data), in hci_extended_inquiry_result_evt()
5202 eir_len = eir_get_length(info->data, sizeof(info->data)); in hci_extended_inquiry_result_evt()
5204 mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, in hci_extended_inquiry_result_evt()
5205 info->dev_class, info->rssi, in hci_extended_inquiry_result_evt()
5206 flags, info->data, eir_len, NULL, 0, 0); in hci_extended_inquiry_result_evt()
5218 bt_dev_dbg(hdev, "status 0x%2.2x handle 0x%4.4x", ev->status, in hci_key_refresh_complete_evt()
5219 __le16_to_cpu(ev->handle)); in hci_key_refresh_complete_evt()
5223 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_key_refresh_complete_evt()
5230 if (conn->type != LE_LINK) in hci_key_refresh_complete_evt()
5233 if (!ev->status) in hci_key_refresh_complete_evt()
5234 conn->sec_level = conn->pending_sec_level; in hci_key_refresh_complete_evt()
5236 clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags); in hci_key_refresh_complete_evt()
5238 if (ev->status && conn->state == BT_CONNECTED) { in hci_key_refresh_complete_evt()
5244 if (conn->state == BT_CONFIG) { in hci_key_refresh_complete_evt()
5245 if (!ev->status) in hci_key_refresh_complete_evt()
5246 conn->state = BT_CONNECTED; in hci_key_refresh_complete_evt()
5248 hci_connect_cfm(conn, ev->status); in hci_key_refresh_complete_evt()
5251 hci_auth_cfm(conn, ev->status); in hci_key_refresh_complete_evt()
5254 conn->disc_timeout = HCI_DISCONN_TIMEOUT; in hci_key_refresh_complete_evt()
5264 /* If remote requests no-bonding follow that lead */ in hci_get_auth_req()
5265 if (conn->remote_auth == HCI_AT_NO_BONDING || in hci_get_auth_req()
5266 conn->remote_auth == HCI_AT_NO_BONDING_MITM) in hci_get_auth_req()
5267 return conn->remote_auth | (conn->auth_type & 0x01); in hci_get_auth_req()
5272 if (conn->remote_cap != HCI_IO_NO_INPUT_OUTPUT && in hci_get_auth_req()
5273 conn->io_capability != HCI_IO_NO_INPUT_OUTPUT) in hci_get_auth_req()
5274 return conn->remote_auth | 0x01; in hci_get_auth_req()
5277 return (conn->remote_auth & ~0x01) | (conn->auth_type & 0x01); in hci_get_auth_req()
5282 struct hci_dev *hdev = conn->hdev; in bredr_oob_data_present()
5285 data = hci_find_remote_oob_data(hdev, &conn->dst, BDADDR_BREDR); in bredr_oob_data_present()
5297 return data->present; in bredr_oob_data_present()
5300 * the P-256 values are required. If they are not in bredr_oob_data_present()
5304 if (!crypto_memneq(data->rand256, ZERO_KEY, 16) || in bredr_oob_data_present()
5305 !crypto_memneq(data->hash256, ZERO_KEY, 16)) in bredr_oob_data_present()
5313 * P-192 data values are present. in bredr_oob_data_present()
5315 if (!crypto_memneq(data->rand192, ZERO_KEY, 16) || in bredr_oob_data_present()
5316 !crypto_memneq(data->hash192, ZERO_KEY, 16)) in bredr_oob_data_present()
5332 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_io_capa_request_evt()
5337 set_bit(HCI_CONN_SSP_ENABLED, &conn->flags); in hci_io_capa_request_evt()
5348 test_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags) || in hci_io_capa_request_evt()
5349 (conn->remote_auth & ~0x01) == HCI_AT_NO_BONDING) { in hci_io_capa_request_evt()
5352 bacpy(&cp.bdaddr, &ev->bdaddr); in hci_io_capa_request_evt()
5355 cp.capability = (conn->io_capability == 0x04) ? in hci_io_capa_request_evt()
5356 HCI_IO_DISPLAY_YESNO : conn->io_capability; in hci_io_capa_request_evt()
5359 if (conn->remote_auth == 0xff) { in hci_io_capa_request_evt()
5361 * except for the no-bonding case. in hci_io_capa_request_evt()
5363 if (conn->io_capability != HCI_IO_NO_INPUT_OUTPUT && in hci_io_capa_request_evt()
5364 conn->auth_type != HCI_AT_NO_BONDING) in hci_io_capa_request_evt()
5365 conn->auth_type |= 0x01; in hci_io_capa_request_evt()
5367 conn->auth_type = hci_get_auth_req(conn); in hci_io_capa_request_evt()
5370 /* If we're not bondable, force one of the non-bondable in hci_io_capa_request_evt()
5374 conn->auth_type &= HCI_AT_NO_BONDING_MITM; in hci_io_capa_request_evt()
5376 cp.authentication = conn->auth_type; in hci_io_capa_request_evt()
5384 bacpy(&cp.bdaddr, &ev->bdaddr); in hci_io_capa_request_evt()
5405 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_io_capa_reply_evt()
5409 conn->remote_cap = ev->capability; in hci_io_capa_reply_evt()
5410 conn->remote_auth = ev->authentication; in hci_io_capa_reply_evt()
5430 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_user_confirm_request_evt()
5434 loc_mitm = (conn->auth_type & 0x01); in hci_user_confirm_request_evt()
5435 rem_mitm = (conn->remote_auth & 0x01); in hci_user_confirm_request_evt()
5440 * necessarily match conn->auth_type. in hci_user_confirm_request_evt()
5442 if (conn->pending_sec_level > BT_SECURITY_MEDIUM && in hci_user_confirm_request_evt()
5443 conn->remote_cap == HCI_IO_NO_INPUT_OUTPUT) { in hci_user_confirm_request_evt()
5446 sizeof(ev->bdaddr), &ev->bdaddr); in hci_user_confirm_request_evt()
5450 /* If no side requires MITM protection; auto-accept */ in hci_user_confirm_request_evt()
5451 if ((!loc_mitm || conn->remote_cap == HCI_IO_NO_INPUT_OUTPUT) && in hci_user_confirm_request_evt()
5452 (!rem_mitm || conn->io_capability == HCI_IO_NO_INPUT_OUTPUT)) { in hci_user_confirm_request_evt()
5458 * NoInputNoOutput, in which case we do auto-accept in hci_user_confirm_request_evt()
5460 if (!test_bit(HCI_CONN_AUTH_PEND, &conn->flags) && in hci_user_confirm_request_evt()
5461 conn->io_capability != HCI_IO_NO_INPUT_OUTPUT && in hci_user_confirm_request_evt()
5463 bt_dev_dbg(hdev, "Confirming auto-accept as acceptor"); in hci_user_confirm_request_evt()
5472 if (hci_find_link_key(hdev, &ev->bdaddr)) { in hci_user_confirm_request_evt()
5478 BT_DBG("Auto-accept of user confirmation with %ums delay", in hci_user_confirm_request_evt()
5479 hdev->auto_accept_delay); in hci_user_confirm_request_evt()
5481 if (hdev->auto_accept_delay > 0) { in hci_user_confirm_request_evt()
5482 int delay = msecs_to_jiffies(hdev->auto_accept_delay); in hci_user_confirm_request_evt() local
5483 queue_delayed_work(conn->hdev->workqueue, in hci_user_confirm_request_evt()
5484 &conn->auto_accept_work, delay); in hci_user_confirm_request_evt()
5489 sizeof(ev->bdaddr), &ev->bdaddr); in hci_user_confirm_request_evt()
5494 mgmt_user_confirm_request(hdev, &ev->bdaddr, ACL_LINK, 0, in hci_user_confirm_request_evt()
5495 le32_to_cpu(ev->passkey), confirm_hint); in hci_user_confirm_request_evt()
5509 mgmt_user_passkey_request(hdev, &ev->bdaddr, ACL_LINK, 0); in hci_user_passkey_request_evt()
5520 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_user_passkey_notify_evt()
5524 conn->passkey_notify = __le32_to_cpu(ev->passkey); in hci_user_passkey_notify_evt()
5525 conn->passkey_entered = 0; in hci_user_passkey_notify_evt()
5528 mgmt_user_passkey_notify(hdev, &conn->dst, conn->type, in hci_user_passkey_notify_evt()
5529 conn->dst_type, conn->passkey_notify, in hci_user_passkey_notify_evt()
5530 conn->passkey_entered); in hci_user_passkey_notify_evt()
5541 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_keypress_notify_evt()
5545 switch (ev->type) { in hci_keypress_notify_evt()
5547 conn->passkey_entered = 0; in hci_keypress_notify_evt()
5551 conn->passkey_entered++; in hci_keypress_notify_evt()
5555 conn->passkey_entered--; in hci_keypress_notify_evt()
5559 conn->passkey_entered = 0; in hci_keypress_notify_evt()
5567 mgmt_user_passkey_notify(hdev, &conn->dst, conn->type, in hci_keypress_notify_evt()
5568 conn->dst_type, conn->passkey_notify, in hci_keypress_notify_evt()
5569 conn->passkey_entered); in hci_keypress_notify_evt()
5582 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_simple_pair_complete_evt()
5587 conn->remote_auth = 0xff; in hci_simple_pair_complete_evt()
5594 if (!test_bit(HCI_CONN_AUTH_PEND, &conn->flags) && ev->status) in hci_simple_pair_complete_evt()
5595 mgmt_auth_failed(conn, ev->status); in hci_simple_pair_complete_evt()
5614 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_remote_host_features_evt()
5616 memcpy(conn->features[1], ev->features, 8); in hci_remote_host_features_evt()
5618 ie = hci_inquiry_cache_lookup(hdev, &ev->bdaddr); in hci_remote_host_features_evt()
5620 ie->data.ssp_mode = (ev->features[0] & LMP_HOST_SSP); in hci_remote_host_features_evt()
5638 data = hci_find_remote_oob_data(hdev, &ev->bdaddr, BDADDR_BREDR); in hci_remote_oob_data_request_evt()
5642 bacpy(&cp.bdaddr, &ev->bdaddr); in hci_remote_oob_data_request_evt()
5651 bacpy(&cp.bdaddr, &ev->bdaddr); in hci_remote_oob_data_request_evt()
5656 memcpy(cp.hash192, data->hash192, sizeof(cp.hash192)); in hci_remote_oob_data_request_evt()
5657 memcpy(cp.rand192, data->rand192, sizeof(cp.rand192)); in hci_remote_oob_data_request_evt()
5659 memcpy(cp.hash256, data->hash256, sizeof(cp.hash256)); in hci_remote_oob_data_request_evt()
5660 memcpy(cp.rand256, data->rand256, sizeof(cp.rand256)); in hci_remote_oob_data_request_evt()
5667 bacpy(&cp.bdaddr, &ev->bdaddr); in hci_remote_oob_data_request_evt()
5668 memcpy(cp.hash, data->hash192, sizeof(cp.hash)); in hci_remote_oob_data_request_evt()
5669 memcpy(cp.rand, data->rand192, sizeof(cp.rand)); in hci_remote_oob_data_request_evt()
5686 bt_dev_dbg(hdev, "handle 0x%2.2x", ev->phy_handle); in hci_chan_selected_evt()
5688 hcon = hci_conn_hash_lookup_handle(hdev, ev->phy_handle); in hci_chan_selected_evt()
5701 bt_dev_dbg(hdev, "handle 0x%2.2x status 0x%2.2x", ev->phy_handle, in hci_phy_link_complete_evt()
5702 ev->status); in hci_phy_link_complete_evt()
5706 hcon = hci_conn_hash_lookup_handle(hdev, ev->phy_handle); in hci_phy_link_complete_evt()
5710 if (!hcon->amp_mgr) in hci_phy_link_complete_evt()
5713 if (ev->status) { in hci_phy_link_complete_evt()
5718 bredr_hcon = hcon->amp_mgr->l2cap_conn->hcon; in hci_phy_link_complete_evt()
5720 hcon->state = BT_CONNECTED; in hci_phy_link_complete_evt()
5721 bacpy(&hcon->dst, &bredr_hcon->dst); in hci_phy_link_complete_evt()
5724 hcon->disc_timeout = HCI_DISCONN_TIMEOUT; in hci_phy_link_complete_evt()
5745 le16_to_cpu(ev->handle), ev->phy_handle, ev->status); in hci_loglink_complete_evt()
5747 hcon = hci_conn_hash_lookup_handle(hdev, ev->phy_handle); in hci_loglink_complete_evt()
5756 hchan->handle = le16_to_cpu(ev->handle); in hci_loglink_complete_evt()
5757 hchan->amp = true; in hci_loglink_complete_evt()
5759 BT_DBG("hcon %p mgr %p hchan %p", hcon, hcon->amp_mgr, hchan); in hci_loglink_complete_evt()
5761 mgr = hcon->amp_mgr; in hci_loglink_complete_evt()
5762 if (mgr && mgr->bredr_chan) { in hci_loglink_complete_evt()
5763 struct l2cap_chan *bredr_chan = mgr->bredr_chan; in hci_loglink_complete_evt()
5767 bredr_chan->conn->mtu = hdev->block_mtu; in hci_loglink_complete_evt()
5782 le16_to_cpu(ev->handle), ev->status); in hci_disconn_loglink_complete_evt()
5784 if (ev->status) in hci_disconn_loglink_complete_evt()
5789 hchan = hci_chan_lookup_handle(hdev, le16_to_cpu(ev->handle)); in hci_disconn_loglink_complete_evt()
5790 if (!hchan || !hchan->amp) in hci_disconn_loglink_complete_evt()
5793 amp_destroy_logical_link(hchan, ev->reason); in hci_disconn_loglink_complete_evt()
5805 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_disconn_phylink_complete_evt()
5807 if (ev->status) in hci_disconn_phylink_complete_evt()
5812 hcon = hci_conn_hash_lookup_handle(hdev, ev->phy_handle); in hci_disconn_phylink_complete_evt()
5813 if (hcon && hcon->type == AMP_LINK) { in hci_disconn_phylink_complete_evt()
5814 hcon->state = BT_CLOSED; in hci_disconn_phylink_complete_evt()
5815 hci_disconn_cfm(hcon, ev->reason); in hci_disconn_phylink_complete_evt()
5826 if (conn->out) { in le_conn_update_addr()
5827 conn->dst_type = bdaddr_type; in le_conn_update_addr()
5828 conn->resp_addr_type = bdaddr_type; in le_conn_update_addr()
5829 bacpy(&conn->resp_addr, bdaddr); in le_conn_update_addr()
5832 * used instead or hdev->rpa. in le_conn_update_addr()
5835 conn->init_addr_type = ADDR_LE_DEV_RANDOM; in le_conn_update_addr()
5836 bacpy(&conn->init_addr, local_rpa); in le_conn_update_addr()
5837 } else if (hci_dev_test_flag(conn->hdev, HCI_PRIVACY)) { in le_conn_update_addr()
5838 conn->init_addr_type = ADDR_LE_DEV_RANDOM; in le_conn_update_addr()
5839 bacpy(&conn->init_addr, &conn->hdev->rpa); in le_conn_update_addr()
5841 hci_copy_identity_address(conn->hdev, &conn->init_addr, in le_conn_update_addr()
5842 &conn->init_addr_type); in le_conn_update_addr()
5845 conn->resp_addr_type = conn->hdev->adv_addr_type; in le_conn_update_addr()
5847 * used instead or hdev->rpa. in le_conn_update_addr()
5850 conn->resp_addr_type = ADDR_LE_DEV_RANDOM; in le_conn_update_addr()
5851 bacpy(&conn->resp_addr, local_rpa); in le_conn_update_addr()
5852 } else if (conn->hdev->adv_addr_type == ADDR_LE_DEV_RANDOM) { in le_conn_update_addr()
5853 /* In case of ext adv, resp_addr will be updated in in le_conn_update_addr()
5854 * Adv Terminated event. in le_conn_update_addr()
5856 if (!ext_adv_capable(conn->hdev)) in le_conn_update_addr()
5857 bacpy(&conn->resp_addr, in le_conn_update_addr()
5858 &conn->hdev->random_addr); in le_conn_update_addr()
5860 bacpy(&conn->resp_addr, &conn->hdev->bdaddr); in le_conn_update_addr()
5863 conn->init_addr_type = bdaddr_type; in le_conn_update_addr()
5864 bacpy(&conn->init_addr, bdaddr); in le_conn_update_addr()
5871 conn->le_conn_min_interval = conn->hdev->le_conn_min_interval; in le_conn_update_addr()
5872 conn->le_conn_max_interval = conn->hdev->le_conn_max_interval; in le_conn_update_addr()
5908 conn->dst_type = bdaddr_type; in le_conn_complete_evt()
5918 if (conn->out) { in le_conn_complete_evt()
5919 conn->resp_addr_type = bdaddr_type; in le_conn_complete_evt()
5920 bacpy(&conn->resp_addr, bdaddr); in le_conn_complete_evt()
5922 conn->init_addr_type = ADDR_LE_DEV_RANDOM; in le_conn_complete_evt()
5923 bacpy(&conn->init_addr, &hdev->rpa); in le_conn_complete_evt()
5926 &conn->init_addr, in le_conn_complete_evt()
5927 &conn->init_addr_type); in le_conn_complete_evt()
5931 cancel_delayed_work(&conn->le_conn_timeout); in le_conn_complete_evt()
5940 if (!HCI_CONN_HANDLE_UNSET(conn->handle)) { in le_conn_complete_evt()
5956 irk = hci_get_irk(hdev, &conn->dst, conn->dst_type); in le_conn_complete_evt()
5958 bacpy(&conn->dst, &irk->bdaddr); in le_conn_complete_evt()
5959 conn->dst_type = irk->addr_type; in le_conn_complete_evt()
5962 conn->dst_type = ev_bdaddr_type(hdev, conn->dst_type, NULL); in le_conn_complete_evt()
5972 if (test_bit(HCI_CONN_CANCEL, &conn->flags)) { in le_conn_complete_evt()
5977 if (conn->dst_type == ADDR_LE_DEV_PUBLIC) in le_conn_complete_evt()
5983 if (hci_bdaddr_list_lookup(&hdev->reject_list, &conn->dst, addr_type)) { in le_conn_complete_evt()
5990 conn->sec_level = BT_SECURITY_LOW; in le_conn_complete_evt()
5991 conn->state = BT_CONFIG; in le_conn_complete_evt()
5994 * when sotfware rotation is in use so it can be re-enabled when in le_conn_complete_evt()
5998 conn->adv_instance = hdev->cur_adv_instance; in le_conn_complete_evt()
6000 conn->le_conn_interval = interval; in le_conn_complete_evt()
6001 conn->le_conn_latency = latency; in le_conn_complete_evt()
6002 conn->le_supv_timeout = supervision_timeout; in le_conn_complete_evt()
6011 * If the local controller supports peripheral-initiated features in le_conn_complete_evt()
6016 if (conn->out || in le_conn_complete_evt()
6017 (hdev->le_features[0] & HCI_LE_PERIPHERAL_FEATURES)) { in le_conn_complete_evt()
6020 cp.handle = __cpu_to_le16(conn->handle); in le_conn_complete_evt()
6027 conn->state = BT_CONNECTED; in le_conn_complete_evt()
6031 params = hci_pend_le_action_lookup(&hdev->pend_le_conns, &conn->dst, in le_conn_complete_evt()
6032 conn->dst_type); in le_conn_complete_evt()
6035 if (params->conn) { in le_conn_complete_evt()
6036 hci_conn_drop(params->conn); in le_conn_complete_evt()
6037 hci_conn_put(params->conn); in le_conn_complete_evt()
6038 params->conn = NULL; in le_conn_complete_evt()
6052 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_conn_complete_evt()
6054 le_conn_complete_evt(hdev, ev->status, &ev->bdaddr, ev->bdaddr_type, in hci_le_conn_complete_evt()
6055 NULL, ev->role, le16_to_cpu(ev->handle), in hci_le_conn_complete_evt()
6056 le16_to_cpu(ev->interval), in hci_le_conn_complete_evt()
6057 le16_to_cpu(ev->latency), in hci_le_conn_complete_evt()
6058 le16_to_cpu(ev->supervision_timeout)); in hci_le_conn_complete_evt()
6066 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_enh_conn_complete_evt()
6068 le_conn_complete_evt(hdev, ev->status, &ev->bdaddr, ev->bdaddr_type, in hci_le_enh_conn_complete_evt()
6069 &ev->local_rpa, ev->role, le16_to_cpu(ev->handle), in hci_le_enh_conn_complete_evt()
6070 le16_to_cpu(ev->interval), in hci_le_enh_conn_complete_evt()
6071 le16_to_cpu(ev->latency), in hci_le_enh_conn_complete_evt()
6072 le16_to_cpu(ev->supervision_timeout)); in hci_le_enh_conn_complete_evt()
6080 struct adv_info *adv, *n; in hci_le_ext_adv_term_evt() local
6082 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_ext_adv_term_evt()
6091 if (ev->status == HCI_ERROR_CANCELLED_BY_HOST) { in hci_le_ext_adv_term_evt()
6098 adv = hci_find_adv_instance(hdev, ev->handle); in hci_le_ext_adv_term_evt()
6100 if (ev->status) { in hci_le_ext_adv_term_evt()
6101 if (!adv) in hci_le_ext_adv_term_evt()
6105 hci_remove_adv_instance(hdev, ev->handle); in hci_le_ext_adv_term_evt()
6106 mgmt_advertising_removed(NULL, hdev, ev->handle); in hci_le_ext_adv_term_evt()
6108 list_for_each_entry_safe(adv, n, &hdev->adv_instances, list) { in hci_le_ext_adv_term_evt()
6109 if (adv->enabled) in hci_le_ext_adv_term_evt()
6118 if (adv) in hci_le_ext_adv_term_evt()
6119 adv->enabled = false; in hci_le_ext_adv_term_evt()
6121 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->conn_handle)); in hci_le_ext_adv_term_evt()
6124 * instance can be re-enabled when disconnected. in hci_le_ext_adv_term_evt()
6126 conn->adv_instance = ev->handle; in hci_le_ext_adv_term_evt()
6128 if (hdev->adv_addr_type != ADDR_LE_DEV_RANDOM || in hci_le_ext_adv_term_evt()
6129 bacmp(&conn->resp_addr, BDADDR_ANY)) in hci_le_ext_adv_term_evt()
6132 if (!ev->handle) { in hci_le_ext_adv_term_evt()
6133 bacpy(&conn->resp_addr, &hdev->random_addr); in hci_le_ext_adv_term_evt()
6137 if (adv) in hci_le_ext_adv_term_evt()
6138 bacpy(&conn->resp_addr, &adv->random_addr); in hci_le_ext_adv_term_evt()
6151 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_conn_update_complete_evt()
6153 if (ev->status) in hci_le_conn_update_complete_evt()
6158 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_conn_update_complete_evt()
6160 conn->le_conn_interval = le16_to_cpu(ev->interval); in hci_le_conn_update_complete_evt()
6161 conn->le_conn_latency = le16_to_cpu(ev->latency); in hci_le_conn_update_complete_evt()
6162 conn->le_supv_timeout = le16_to_cpu(ev->supervision_timeout); in hci_le_conn_update_complete_evt()
6168 /* This function requires the caller holds hdev->lock */
6182 if (hci_bdaddr_list_lookup(&hdev->reject_list, addr, addr_type) || in check_pending_le_conn()
6183 hdev->suspended) in check_pending_le_conn()
6189 if (hdev->conn_hash.le_num_peripheral > 0 && in check_pending_le_conn()
6190 (!test_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks) || in check_pending_le_conn()
6191 !(hdev->le_states[3] & 0x10))) in check_pending_le_conn()
6197 params = hci_pend_le_action_lookup(&hdev->pend_le_conns, addr, in check_pending_le_conn()
6202 if (!params->explicit_connect) { in check_pending_le_conn()
6203 switch (params->auto_connect) { in check_pending_le_conn()
6226 BT_SECURITY_LOW, hdev->def_le_autoconnect_timeout, in check_pending_le_conn()
6238 if (!params->explicit_connect) in check_pending_le_conn()
6239 params->conn = hci_conn_get(conn); in check_pending_le_conn()
6245 case -EBUSY: in check_pending_le_conn()
6246 /* If hci_connect() returns -EBUSY it means there is already in check_pending_le_conn()
6265 struct discovery_state *d = &hdev->discovery; in process_adv_report()
6287 "adv larger than maximum supported"); in process_adv_report()
6294 * When data is NULL, len is 0 so there is no need for extra ptr in process_adv_report()
6305 len = ptr - data; in process_adv_report()
6332 if (!smp_irk_matches(hdev, hdev->irk, direct_addr)) in process_adv_report()
6339 bdaddr = &irk->bdaddr; in process_adv_report()
6340 bdaddr_type = irk->addr_type; in process_adv_report()
6357 memcpy(conn->le_adv_data, data, len); in process_adv_report()
6358 conn->le_adv_data_len = len; in process_adv_report()
6377 if (hdev->le_scan_type == LE_SCAN_PASSIVE) { in process_adv_report()
6381 if (!hci_pend_le_action_lookup(&hdev->pend_le_reports, in process_adv_report()
6383 idr_is_empty(&hdev->adv_monitors_idr)) in process_adv_report()
6424 match = (!bacmp(bdaddr, &d->last_adv_addr) && in process_adv_report()
6425 bdaddr_type == d->last_adv_addr_type); in process_adv_report()
6434 mgmt_device_found(hdev, &d->last_adv_addr, LE_LINK, in process_adv_report()
6435 d->last_adv_addr_type, NULL, in process_adv_report()
6436 d->last_adv_rssi, d->last_adv_flags, in process_adv_report()
6437 d->last_adv_data, in process_adv_report()
6438 d->last_adv_data_len, NULL, 0, 0); in process_adv_report()
6463 mgmt_device_found(hdev, &d->last_adv_addr, LE_LINK, in process_adv_report()
6464 d->last_adv_addr_type, NULL, rssi, d->last_adv_flags, in process_adv_report()
6465 d->last_adv_data, d->last_adv_data_len, data, len, 0); in process_adv_report()
6475 if (!ev->num) in hci_le_adv_report_evt()
6480 while (ev->num--) { in hci_le_adv_report_evt()
6491 info->length + 1)) in hci_le_adv_report_evt()
6494 if (info->length <= max_adv_len(hdev)) { in hci_le_adv_report_evt()
6495 rssi = info->data[info->length]; in hci_le_adv_report_evt()
6496 process_adv_report(hdev, info->type, &info->bdaddr, in hci_le_adv_report_evt()
6497 info->bdaddr_type, NULL, 0, rssi, in hci_le_adv_report_evt()
6498 info->data, info->length, false, in hci_le_adv_report_evt()
6558 if (!ev->num) in hci_le_ext_adv_report_evt()
6563 while (ev->num--) { in hci_le_ext_adv_report_evt()
6574 info->length)) in hci_le_ext_adv_report_evt()
6577 evt_type = __le16_to_cpu(info->type) & LE_EXT_ADV_EVT_TYPE_MASK; in hci_le_ext_adv_report_evt()
6580 process_adv_report(hdev, legacy_evt_type, &info->bdaddr, in hci_le_ext_adv_report_evt()
6581 info->bdaddr_type, NULL, 0, in hci_le_ext_adv_report_evt()
6582 info->rssi, info->data, info->length, in hci_le_ext_adv_report_evt()
6605 int mask = hdev->link_mode; in hci_le_pa_sync_estabilished_evt()
6609 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_pa_sync_estabilished_evt()
6615 mask |= hci_proto_connect_ind(hdev, &ev->bdaddr, ISO_LINK, &flags); in hci_le_pa_sync_estabilished_evt()
6617 hci_le_pa_term_sync(hdev, ev->handle); in hci_le_pa_sync_estabilished_evt()
6624 if (ev->status) { in hci_le_pa_sync_estabilished_evt()
6632 set_bit(HCI_CONN_PA_SYNC_FAILED, &pa_sync->flags); in hci_le_pa_sync_estabilished_evt()
6635 hci_connect_cfm(pa_sync, ev->status); in hci_le_pa_sync_estabilished_evt()
6646 int mask = hdev->link_mode; in hci_le_per_adv_report_evt()
6649 bt_dev_dbg(hdev, "sync_handle 0x%4.4x", le16_to_cpu(ev->sync_handle)); in hci_le_per_adv_report_evt()
6655 hci_le_pa_term_sync(hdev, ev->sync_handle); in hci_le_per_adv_report_evt()
6666 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_remote_feat_complete_evt()
6670 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_remote_feat_complete_evt()
6672 if (!ev->status) in hci_le_remote_feat_complete_evt()
6673 memcpy(conn->features[0], ev->features, 8); in hci_le_remote_feat_complete_evt()
6675 if (conn->state == BT_CONFIG) { in hci_le_remote_feat_complete_evt()
6678 /* If the local controller supports peripheral-initiated in hci_le_remote_feat_complete_evt()
6687 if (!conn->out && ev->status == 0x1a && in hci_le_remote_feat_complete_evt()
6688 (hdev->le_features[0] & HCI_LE_PERIPHERAL_FEATURES)) in hci_le_remote_feat_complete_evt()
6691 status = ev->status; in hci_le_remote_feat_complete_evt()
6693 conn->state = BT_CONNECTED; in hci_le_remote_feat_complete_evt()
6711 bt_dev_dbg(hdev, "handle 0x%4.4x", __le16_to_cpu(ev->handle)); in hci_le_ltk_request_evt()
6715 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_ltk_request_evt()
6719 ltk = hci_find_ltk(hdev, &conn->dst, conn->dst_type, conn->role); in hci_le_ltk_request_evt()
6725 if (ev->ediv || ev->rand) in hci_le_ltk_request_evt()
6728 /* For non-SC keys check that EDiv and Rand match */ in hci_le_ltk_request_evt()
6729 if (ev->ediv != ltk->ediv || ev->rand != ltk->rand) in hci_le_ltk_request_evt()
6733 memcpy(cp.ltk, ltk->val, ltk->enc_size); in hci_le_ltk_request_evt()
6734 memset(cp.ltk + ltk->enc_size, 0, sizeof(cp.ltk) - ltk->enc_size); in hci_le_ltk_request_evt()
6735 cp.handle = cpu_to_le16(conn->handle); in hci_le_ltk_request_evt()
6737 conn->pending_sec_level = smp_ltk_sec_level(ltk); in hci_le_ltk_request_evt()
6739 conn->enc_key_size = ltk->enc_size; in hci_le_ltk_request_evt()
6746 * distribute the keys. Later, security can be re-established in hci_le_ltk_request_evt()
6749 if (ltk->type == SMP_STK) { in hci_le_ltk_request_evt()
6750 set_bit(HCI_CONN_STK_ENCRYPT, &conn->flags); in hci_le_ltk_request_evt()
6751 list_del_rcu(<k->list); in hci_le_ltk_request_evt()
6754 clear_bit(HCI_CONN_STK_ENCRYPT, &conn->flags); in hci_le_ltk_request_evt()
6762 neg.handle = ev->handle; in hci_le_ltk_request_evt()
6787 bt_dev_dbg(hdev, "handle 0x%4.4x", __le16_to_cpu(ev->handle)); in hci_le_remote_conn_param_req_evt()
6789 handle = le16_to_cpu(ev->handle); in hci_le_remote_conn_param_req_evt()
6790 min = le16_to_cpu(ev->interval_min); in hci_le_remote_conn_param_req_evt()
6791 max = le16_to_cpu(ev->interval_max); in hci_le_remote_conn_param_req_evt()
6792 latency = le16_to_cpu(ev->latency); in hci_le_remote_conn_param_req_evt()
6793 timeout = le16_to_cpu(ev->timeout); in hci_le_remote_conn_param_req_evt()
6796 if (!hcon || hcon->state != BT_CONNECTED) in hci_le_remote_conn_param_req_evt()
6800 if (max > hcon->le_conn_max_interval) in hci_le_remote_conn_param_req_evt()
6808 if (hcon->role == HCI_ROLE_MASTER) { in hci_le_remote_conn_param_req_evt()
6814 params = hci_conn_params_lookup(hdev, &hcon->dst, in hci_le_remote_conn_param_req_evt()
6815 hcon->dst_type); in hci_le_remote_conn_param_req_evt()
6817 params->conn_min_interval = min; in hci_le_remote_conn_param_req_evt()
6818 params->conn_max_interval = max; in hci_le_remote_conn_param_req_evt()
6819 params->conn_latency = latency; in hci_le_remote_conn_param_req_evt()
6820 params->supervision_timeout = timeout; in hci_le_remote_conn_param_req_evt()
6828 mgmt_new_conn_param(hdev, &hcon->dst, hcon->dst_type, in hci_le_remote_conn_param_req_evt()
6832 cp.handle = ev->handle; in hci_le_remote_conn_param_req_evt()
6833 cp.interval_min = ev->interval_min; in hci_le_remote_conn_param_req_evt()
6834 cp.interval_max = ev->interval_max; in hci_le_remote_conn_param_req_evt()
6835 cp.latency = ev->latency; in hci_le_remote_conn_param_req_evt()
6836 cp.timeout = ev->timeout; in hci_le_remote_conn_param_req_evt()
6851 flex_array_size(ev, info, ev->num))) in hci_le_direct_adv_report_evt()
6854 if (!ev->num) in hci_le_direct_adv_report_evt()
6859 for (i = 0; i < ev->num; i++) { in hci_le_direct_adv_report_evt()
6860 struct hci_ev_le_direct_adv_info *info = &ev->info[i]; in hci_le_direct_adv_report_evt()
6862 process_adv_report(hdev, info->type, &info->bdaddr, in hci_le_direct_adv_report_evt()
6863 info->bdaddr_type, &info->direct_addr, in hci_le_direct_adv_report_evt()
6864 info->direct_addr_type, info->rssi, NULL, 0, in hci_le_direct_adv_report_evt()
6877 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_phy_update_evt()
6879 if (ev->status) in hci_le_phy_update_evt()
6884 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_phy_update_evt()
6888 conn->le_tx_phy = ev->tx_phy; in hci_le_phy_update_evt()
6889 conn->le_rx_phy = ev->rx_phy; in hci_le_phy_update_evt()
6902 u16 handle = __le16_to_cpu(ev->handle); in hci_le_cis_estabilished_evt()
6904 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_cis_estabilished_evt()
6916 if (conn->type != ISO_LINK) { in hci_le_cis_estabilished_evt()
6923 qos = &conn->iso_qos; in hci_le_cis_estabilished_evt()
6925 pending = test_and_clear_bit(HCI_CONN_CREATE_CIS, &conn->flags); in hci_le_cis_estabilished_evt()
6928 qos->ucast.in.interval = le16_to_cpu(ev->interval) * 1250; in hci_le_cis_estabilished_evt()
6929 qos->ucast.out.interval = qos->ucast.in.interval; in hci_le_cis_estabilished_evt()
6931 switch (conn->role) { in hci_le_cis_estabilished_evt()
6934 qos->ucast.in.latency = in hci_le_cis_estabilished_evt()
6935 DIV_ROUND_CLOSEST(get_unaligned_le24(ev->c_latency), in hci_le_cis_estabilished_evt()
6937 qos->ucast.out.latency = in hci_le_cis_estabilished_evt()
6938 DIV_ROUND_CLOSEST(get_unaligned_le24(ev->p_latency), in hci_le_cis_estabilished_evt()
6940 qos->ucast.in.sdu = le16_to_cpu(ev->c_mtu); in hci_le_cis_estabilished_evt()
6941 qos->ucast.out.sdu = le16_to_cpu(ev->p_mtu); in hci_le_cis_estabilished_evt()
6942 qos->ucast.in.phy = ev->c_phy; in hci_le_cis_estabilished_evt()
6943 qos->ucast.out.phy = ev->p_phy; in hci_le_cis_estabilished_evt()
6947 qos->ucast.out.latency = in hci_le_cis_estabilished_evt()
6948 DIV_ROUND_CLOSEST(get_unaligned_le24(ev->c_latency), in hci_le_cis_estabilished_evt()
6950 qos->ucast.in.latency = in hci_le_cis_estabilished_evt()
6951 DIV_ROUND_CLOSEST(get_unaligned_le24(ev->p_latency), in hci_le_cis_estabilished_evt()
6953 qos->ucast.out.sdu = le16_to_cpu(ev->c_mtu); in hci_le_cis_estabilished_evt()
6954 qos->ucast.in.sdu = le16_to_cpu(ev->p_mtu); in hci_le_cis_estabilished_evt()
6955 qos->ucast.out.phy = ev->c_phy; in hci_le_cis_estabilished_evt()
6956 qos->ucast.in.phy = ev->p_phy; in hci_le_cis_estabilished_evt()
6960 if (!ev->status) { in hci_le_cis_estabilished_evt()
6961 conn->state = BT_CONNECTED; in hci_le_cis_estabilished_evt()
6968 conn->state = BT_CLOSED; in hci_le_cis_estabilished_evt()
6969 hci_connect_cfm(conn, ev->status); in hci_le_cis_estabilished_evt()
7007 acl_handle = __le16_to_cpu(ev->acl_handle); in hci_le_cis_req_evt()
7008 cis_handle = __le16_to_cpu(ev->cis_handle); in hci_le_cis_req_evt()
7011 acl_handle, cis_handle, ev->cig_id, ev->cis_id); in hci_le_cis_req_evt()
7019 mask = hci_proto_connect_ind(hdev, &acl->dst, ISO_LINK, &flags); in hci_le_cis_req_evt()
7021 hci_le_reject_cis(hdev, ev->cis_handle); in hci_le_cis_req_evt()
7027 cis = hci_conn_add(hdev, ISO_LINK, &acl->dst, HCI_ROLE_SLAVE, in hci_le_cis_req_evt()
7030 hci_le_reject_cis(hdev, ev->cis_handle); in hci_le_cis_req_evt()
7035 cis->iso_qos.ucast.cig = ev->cig_id; in hci_le_cis_req_evt()
7036 cis->iso_qos.ucast.cis = ev->cis_id; in hci_le_cis_req_evt()
7039 hci_le_accept_cis(hdev, ev->cis_handle); in hci_le_cis_req_evt()
7041 cis->state = BT_CONNECT2; in hci_le_cis_req_evt()
7064 BT_DBG("%s status 0x%2.2x", hdev->name, ev->status); in hci_le_create_big_complete_evt()
7067 flex_array_size(ev, bis_handle, ev->num_bis))) in hci_le_create_big_complete_evt()
7074 list_for_each_entry_rcu(conn, &hdev->conn_hash.list, list) { in hci_le_create_big_complete_evt()
7075 if (bacmp(&conn->dst, BDADDR_ANY) || in hci_le_create_big_complete_evt()
7076 conn->type != ISO_LINK || in hci_le_create_big_complete_evt()
7077 conn->iso_qos.bcast.big != ev->handle) in hci_le_create_big_complete_evt()
7081 __le16_to_cpu(ev->bis_handle[i++]))) in hci_le_create_big_complete_evt()
7084 if (!ev->status) { in hci_le_create_big_complete_evt()
7085 conn->state = BT_CONNECTED; in hci_le_create_big_complete_evt()
7086 set_bit(HCI_CONN_BIG_CREATED, &conn->flags); in hci_le_create_big_complete_evt()
7095 hci_connect_cfm(conn, ev->status); in hci_le_create_big_complete_evt()
7103 if (!ev->status && !i) in hci_le_create_big_complete_evt()
7110 UINT_PTR(ev->handle), NULL); in hci_le_create_big_complete_evt()
7123 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_big_sync_established_evt()
7126 flex_array_size(ev, bis, ev->num_bis))) in hci_le_big_sync_established_evt()
7131 if (!ev->status) { in hci_le_big_sync_established_evt()
7132 pa_sync = hci_conn_hash_lookup_pa_sync_big_handle(hdev, ev->handle); in hci_le_big_sync_established_evt()
7137 set_bit(HCI_CONN_BIG_SYNC, &pa_sync->flags); in hci_le_big_sync_established_evt()
7140 for (i = 0; i < ev->num_bis; i++) { in hci_le_big_sync_established_evt()
7141 u16 handle = le16_to_cpu(ev->bis[i]); in hci_le_big_sync_established_evt()
7152 if (ev->status != 0x42) in hci_le_big_sync_established_evt()
7154 set_bit(HCI_CONN_PA_SYNC, &bis->flags); in hci_le_big_sync_established_evt()
7156 bis->iso_qos.bcast.big = ev->handle; in hci_le_big_sync_established_evt()
7158 memcpy(&interval, ev->latency, sizeof(ev->latency)); in hci_le_big_sync_established_evt()
7159 bis->iso_qos.bcast.in.interval = le32_to_cpu(interval); in hci_le_big_sync_established_evt()
7161 bis->iso_qos.bcast.in.latency = le16_to_cpu(ev->interval) * 125 / 100; in hci_le_big_sync_established_evt()
7162 bis->iso_qos.bcast.in.sdu = le16_to_cpu(ev->max_pdu); in hci_le_big_sync_established_evt()
7164 if (!ev->status) { in hci_le_big_sync_established_evt()
7165 set_bit(HCI_CONN_BIG_SYNC, &bis->flags); in hci_le_big_sync_established_evt()
7173 if (ev->status) in hci_le_big_sync_established_evt()
7174 for (i = 0; i < ev->num_bis; i++) { in hci_le_big_sync_established_evt()
7175 u16 handle = le16_to_cpu(ev->bis[i]); in hci_le_big_sync_established_evt()
7179 set_bit(HCI_CONN_BIG_SYNC_FAILED, &bis->flags); in hci_le_big_sync_established_evt()
7180 hci_connect_cfm(bis, ev->status); in hci_le_big_sync_established_evt()
7190 int mask = hdev->link_mode; in hci_le_big_info_adv_report_evt()
7194 bt_dev_dbg(hdev, "sync_handle 0x%4.4x", le16_to_cpu(ev->sync_handle)); in hci_le_big_info_adv_report_evt()
7200 hci_le_pa_term_sync(hdev, ev->sync_handle); in hci_le_big_info_adv_report_evt()
7209 le16_to_cpu(ev->sync_handle)); in hci_le_big_info_adv_report_evt()
7221 pa_sync->sync_handle = le16_to_cpu(ev->sync_handle); in hci_le_big_info_adv_report_evt()
7222 set_bit(HCI_CONN_PA_SYNC, &pa_sync->flags); in hci_le_big_info_adv_report_evt()
7337 bt_dev_dbg(hdev, "subevent 0x%2.2x", ev->subevent); in hci_le_meta_evt()
7340 if (hdev->req_skb && in hci_le_meta_evt()
7341 hci_opcode_ogf(hci_skb_opcode(hdev->req_skb)) == 0x08 && in hci_le_meta_evt()
7342 hci_skb_event(hdev->req_skb) == ev->subevent) { in hci_le_meta_evt()
7343 *opcode = hci_skb_opcode(hdev->req_skb); in hci_le_meta_evt()
7348 subev = &hci_le_ev_table[ev->subevent]; in hci_le_meta_evt()
7349 if (!subev->func) in hci_le_meta_evt()
7352 if (skb->len < subev->min_len) { in hci_le_meta_evt()
7354 ev->subevent, skb->len, subev->min_len); in hci_le_meta_evt()
7362 if (skb->len > subev->max_len) in hci_le_meta_evt()
7364 ev->subevent, skb->len, subev->max_len); in hci_le_meta_evt()
7365 data = hci_le_ev_skb_pull(hdev, skb, ev->subevent, subev->min_len); in hci_le_meta_evt()
7369 subev->func(hdev, data, skb); in hci_le_meta_evt()
7386 if (hdr->evt != event) in hci_get_cmd_complete()
7391 /* Check if request ended in Command Status - no way to retrieve in hci_get_cmd_complete()
7392 * any extra parameters in this case. in hci_get_cmd_complete()
7394 if (hdr->evt == HCI_EV_CMD_STATUS) in hci_get_cmd_complete()
7397 if (hdr->evt != HCI_EV_CMD_COMPLETE) { in hci_get_cmd_complete()
7399 hdr->evt); in hci_get_cmd_complete()
7407 if (opcode != __le16_to_cpu(ev->opcode)) { in hci_get_cmd_complete()
7409 __le16_to_cpu(ev->opcode)); in hci_get_cmd_complete()
7419 struct hci_ev_le_advertising_info *adv; in hci_store_wake_reason() local
7422 const struct hci_ev_conn_complete *conn_complete = (void *)skb->data; in hci_store_wake_reason()
7423 const struct hci_ev_conn_request *conn_request = (void *)skb->data; in hci_store_wake_reason()
7430 if (!hdev->suspended || hdev->wake_reason) in hci_store_wake_reason()
7436 hdev->wake_reason = MGMT_WAKE_REASON_REMOTE_WAKE; in hci_store_wake_reason()
7443 bacpy(&hdev->wake_addr, &conn_request->bdaddr); in hci_store_wake_reason()
7444 hdev->wake_addr_type = BDADDR_BREDR; in hci_store_wake_reason()
7446 bacpy(&hdev->wake_addr, &conn_complete->bdaddr); in hci_store_wake_reason()
7447 hdev->wake_addr_type = BDADDR_BREDR; in hci_store_wake_reason()
7449 struct hci_ev_le_meta *le_ev = (void *)skb->data; in hci_store_wake_reason()
7450 u8 subevent = le_ev->subevent; in hci_store_wake_reason()
7451 u8 *ptr = &skb->data[sizeof(*le_ev)]; in hci_store_wake_reason()
7458 adv = (void *)(ptr + 1); in hci_store_wake_reason()
7464 bacpy(&hdev->wake_addr, &adv->bdaddr); in hci_store_wake_reason()
7465 hdev->wake_addr_type = adv->bdaddr_type; in hci_store_wake_reason()
7468 bacpy(&hdev->wake_addr, &direct_adv->bdaddr); in hci_store_wake_reason()
7469 hdev->wake_addr_type = direct_adv->bdaddr_type; in hci_store_wake_reason()
7472 bacpy(&hdev->wake_addr, &ext_adv->bdaddr); in hci_store_wake_reason()
7473 hdev->wake_addr_type = ext_adv->bdaddr_type; in hci_store_wake_reason()
7478 hdev->wake_reason = MGMT_WAKE_REASON_UNEXPECTED; in hci_store_wake_reason()
7676 if (!ev->func) in hci_event_func()
7679 if (skb->len < ev->min_len) { in hci_event_func()
7681 event, skb->len, ev->min_len); in hci_event_func()
7689 if (skb->len > ev->max_len) in hci_event_func()
7692 event, skb->len, ev->max_len); in hci_event_func()
7694 data = hci_ev_skb_pull(hdev, skb, event, ev->min_len); in hci_event_func()
7698 if (ev->req) in hci_event_func()
7699 ev->func_req(hdev, data, skb, opcode, status, req_complete, in hci_event_func()
7702 ev->func(hdev, data, skb); in hci_event_func()
7707 struct hci_event_hdr *hdr = (void *) skb->data; in hci_event_packet()
7714 if (skb->len < sizeof(*hdr)) { in hci_event_packet()
7719 kfree_skb(hdev->recv_event); in hci_event_packet()
7720 hdev->recv_event = skb_clone(skb, GFP_KERNEL); in hci_event_packet()
7722 event = hdr->evt; in hci_event_packet()
7730 if (hdev->req_skb && in hci_event_packet()
7731 hci_opcode_ogf(hci_skb_opcode(hdev->req_skb)) != 0x08 && in hci_event_packet()
7732 hci_skb_event(hdev->req_skb) == event) { in hci_event_packet()
7733 hci_req_cmd_complete(hdev, hci_skb_opcode(hdev->req_skb), in hci_event_packet()
7770 hdev->stat.evt_rx++; in hci_event_packet()