Lines Matching +full:x +full:- +full:rp
2 BlueZ - Bluetooth protocol stack for Linux
3 Copyright (c) 2000-2001, 2010, Code Aurora Forum. All rights reserved.
4 Copyright 2023-2024 NXP
54 bt_dev_err(hdev, "Malformed Event: 0x%2.2x", ev); in hci_ev_skb_pull()
66 bt_dev_err(hdev, "Malformed Command Complete: 0x%4.4x", op); in hci_cc_skb_pull()
78 bt_dev_err(hdev, "Malformed LE Event: 0x%2.2x", ev); in hci_le_ev_skb_pull()
86 struct hci_ev_status *rp = data; in hci_cc_inquiry_cancel() local
88 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_inquiry_cancel()
97 if (rp->status == HCI_ERROR_COMMAND_DISALLOWED && !test_bit(HCI_INQUIRY, &hdev->flags)) { in hci_cc_inquiry_cancel()
99 rp->status = 0x00; in hci_cc_inquiry_cancel()
102 if (rp->status) in hci_cc_inquiry_cancel()
103 return rp->status; in hci_cc_inquiry_cancel()
105 clear_bit(HCI_INQUIRY, &hdev->flags); in hci_cc_inquiry_cancel()
107 wake_up_bit(&hdev->flags, HCI_INQUIRY); in hci_cc_inquiry_cancel()
114 hdev->le_scan_type != LE_SCAN_ACTIVE) in hci_cc_inquiry_cancel()
118 return rp->status; in hci_cc_inquiry_cancel()
124 struct hci_ev_status *rp = data; in hci_cc_periodic_inq() local
126 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_periodic_inq()
128 if (rp->status) in hci_cc_periodic_inq()
129 return rp->status; in hci_cc_periodic_inq()
133 return rp->status; in hci_cc_periodic_inq()
139 struct hci_ev_status *rp = data; in hci_cc_exit_periodic_inq() local
141 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_exit_periodic_inq()
143 if (rp->status) in hci_cc_exit_periodic_inq()
144 return rp->status; in hci_cc_exit_periodic_inq()
148 return rp->status; in hci_cc_exit_periodic_inq()
154 struct hci_ev_status *rp = data; in hci_cc_remote_name_req_cancel() local
156 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_remote_name_req_cancel()
158 return rp->status; in hci_cc_remote_name_req_cancel()
164 struct hci_rp_role_discovery *rp = data; in hci_cc_role_discovery() local
167 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_role_discovery()
169 if (rp->status) in hci_cc_role_discovery()
170 return rp->status; in hci_cc_role_discovery()
174 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_role_discovery()
176 conn->role = rp->role; in hci_cc_role_discovery()
180 return rp->status; in hci_cc_role_discovery()
186 struct hci_rp_read_link_policy *rp = data; in hci_cc_read_link_policy() local
189 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_link_policy()
191 if (rp->status) in hci_cc_read_link_policy()
192 return rp->status; in hci_cc_read_link_policy()
196 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_link_policy()
198 conn->link_policy = __le16_to_cpu(rp->policy); in hci_cc_read_link_policy()
202 return rp->status; in hci_cc_read_link_policy()
208 struct hci_rp_write_link_policy *rp = data; in hci_cc_write_link_policy() local
212 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_link_policy()
214 if (rp->status) in hci_cc_write_link_policy()
215 return rp->status; in hci_cc_write_link_policy()
219 return rp->status; in hci_cc_write_link_policy()
223 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_write_link_policy()
225 conn->link_policy = get_unaligned_le16(sent + 2); in hci_cc_write_link_policy()
229 return rp->status; in hci_cc_write_link_policy()
235 struct hci_rp_read_def_link_policy *rp = data; in hci_cc_read_def_link_policy() local
237 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_def_link_policy()
239 if (rp->status) in hci_cc_read_def_link_policy()
240 return rp->status; in hci_cc_read_def_link_policy()
242 hdev->link_policy = __le16_to_cpu(rp->policy); in hci_cc_read_def_link_policy()
244 return rp->status; in hci_cc_read_def_link_policy()
250 struct hci_ev_status *rp = data; in hci_cc_write_def_link_policy() local
253 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_def_link_policy()
255 if (rp->status) in hci_cc_write_def_link_policy()
256 return rp->status; in hci_cc_write_def_link_policy()
260 return rp->status; in hci_cc_write_def_link_policy()
262 hdev->link_policy = get_unaligned_le16(sent); in hci_cc_write_def_link_policy()
264 return rp->status; in hci_cc_write_def_link_policy()
269 struct hci_ev_status *rp = data; in hci_cc_reset() local
271 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_reset()
273 clear_bit(HCI_RESET, &hdev->flags); in hci_cc_reset()
275 if (rp->status) in hci_cc_reset()
276 return rp->status; in hci_cc_reset()
278 /* Reset all non-persistent flags */ in hci_cc_reset()
283 hdev->inq_tx_power = HCI_TX_POWER_INVALID; in hci_cc_reset()
284 hdev->adv_tx_power = HCI_TX_POWER_INVALID; in hci_cc_reset()
286 memset(hdev->adv_data, 0, sizeof(hdev->adv_data)); in hci_cc_reset()
287 hdev->adv_data_len = 0; in hci_cc_reset()
289 memset(hdev->scan_rsp_data, 0, sizeof(hdev->scan_rsp_data)); in hci_cc_reset()
290 hdev->scan_rsp_data_len = 0; in hci_cc_reset()
292 hdev->le_scan_type = LE_SCAN_PASSIVE; in hci_cc_reset()
294 hdev->ssp_debug_mode = 0; in hci_cc_reset()
296 hci_bdaddr_list_clear(&hdev->le_accept_list); in hci_cc_reset()
297 hci_bdaddr_list_clear(&hdev->le_resolv_list); in hci_cc_reset()
299 return rp->status; in hci_cc_reset()
305 struct hci_rp_read_stored_link_key *rp = data; in hci_cc_read_stored_link_key() local
308 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_stored_link_key()
312 return rp->status; in hci_cc_read_stored_link_key()
314 if (!rp->status && sent->read_all == 0x01) { in hci_cc_read_stored_link_key()
315 hdev->stored_max_keys = le16_to_cpu(rp->max_keys); in hci_cc_read_stored_link_key()
316 hdev->stored_num_keys = le16_to_cpu(rp->num_keys); in hci_cc_read_stored_link_key()
319 return rp->status; in hci_cc_read_stored_link_key()
325 struct hci_rp_delete_stored_link_key *rp = data; in hci_cc_delete_stored_link_key() local
328 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_delete_stored_link_key()
330 if (rp->status) in hci_cc_delete_stored_link_key()
331 return rp->status; in hci_cc_delete_stored_link_key()
333 num_keys = le16_to_cpu(rp->num_keys); in hci_cc_delete_stored_link_key()
335 if (num_keys <= hdev->stored_num_keys) in hci_cc_delete_stored_link_key()
336 hdev->stored_num_keys -= num_keys; in hci_cc_delete_stored_link_key()
338 hdev->stored_num_keys = 0; in hci_cc_delete_stored_link_key()
340 return rp->status; in hci_cc_delete_stored_link_key()
346 struct hci_ev_status *rp = data; in hci_cc_write_local_name() local
349 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_local_name()
353 return rp->status; in hci_cc_write_local_name()
358 mgmt_set_local_name_complete(hdev, sent, rp->status); in hci_cc_write_local_name()
359 else if (!rp->status) in hci_cc_write_local_name()
360 memcpy(hdev->dev_name, sent, HCI_MAX_NAME_LENGTH); in hci_cc_write_local_name()
364 return rp->status; in hci_cc_write_local_name()
370 struct hci_rp_read_local_name *rp = data; in hci_cc_read_local_name() local
372 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_name()
374 if (rp->status) in hci_cc_read_local_name()
375 return rp->status; in hci_cc_read_local_name()
379 memcpy(hdev->dev_name, rp->name, HCI_MAX_NAME_LENGTH); in hci_cc_read_local_name()
381 return rp->status; in hci_cc_read_local_name()
387 struct hci_ev_status *rp = data; in hci_cc_write_auth_enable() local
390 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_auth_enable()
394 return rp->status; in hci_cc_write_auth_enable()
398 if (!rp->status) { in hci_cc_write_auth_enable()
402 set_bit(HCI_AUTH, &hdev->flags); in hci_cc_write_auth_enable()
404 clear_bit(HCI_AUTH, &hdev->flags); in hci_cc_write_auth_enable()
408 mgmt_auth_enable_complete(hdev, rp->status); in hci_cc_write_auth_enable()
412 return rp->status; in hci_cc_write_auth_enable()
418 struct hci_ev_status *rp = data; in hci_cc_write_encrypt_mode() local
422 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_encrypt_mode()
424 if (rp->status) in hci_cc_write_encrypt_mode()
425 return rp->status; in hci_cc_write_encrypt_mode()
429 return rp->status; in hci_cc_write_encrypt_mode()
434 set_bit(HCI_ENCRYPT, &hdev->flags); in hci_cc_write_encrypt_mode()
436 clear_bit(HCI_ENCRYPT, &hdev->flags); in hci_cc_write_encrypt_mode()
438 return rp->status; in hci_cc_write_encrypt_mode()
444 struct hci_ev_status *rp = data; in hci_cc_write_scan_enable() local
448 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_scan_enable()
452 return rp->status; in hci_cc_write_scan_enable()
458 if (rp->status) { in hci_cc_write_scan_enable()
459 hdev->discov_timeout = 0; in hci_cc_write_scan_enable()
464 set_bit(HCI_ISCAN, &hdev->flags); in hci_cc_write_scan_enable()
466 clear_bit(HCI_ISCAN, &hdev->flags); in hci_cc_write_scan_enable()
469 set_bit(HCI_PSCAN, &hdev->flags); in hci_cc_write_scan_enable()
471 clear_bit(HCI_PSCAN, &hdev->flags); in hci_cc_write_scan_enable()
476 return rp->status; in hci_cc_write_scan_enable()
482 struct hci_ev_status *rp = data; in hci_cc_set_event_filter() local
486 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_set_event_filter()
488 if (rp->status) in hci_cc_set_event_filter()
489 return rp->status; in hci_cc_set_event_filter()
493 return rp->status; in hci_cc_set_event_filter()
497 if (cp->flt_type == HCI_FLT_CLEAR_ALL) in hci_cc_set_event_filter()
502 return rp->status; in hci_cc_set_event_filter()
508 struct hci_rp_read_class_of_dev *rp = data; in hci_cc_read_class_of_dev() local
513 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_class_of_dev()
515 if (rp->status) in hci_cc_read_class_of_dev()
516 return rp->status; in hci_cc_read_class_of_dev()
518 memcpy(hdev->dev_class, rp->dev_class, 3); in hci_cc_read_class_of_dev()
520 bt_dev_dbg(hdev, "class 0x%.2x%.2x%.2x", hdev->dev_class[2], in hci_cc_read_class_of_dev()
521 hdev->dev_class[1], hdev->dev_class[0]); in hci_cc_read_class_of_dev()
523 return rp->status; in hci_cc_read_class_of_dev()
529 struct hci_ev_status *rp = data; in hci_cc_write_class_of_dev() local
532 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_class_of_dev()
536 return rp->status; in hci_cc_write_class_of_dev()
540 if (!rp->status) in hci_cc_write_class_of_dev()
541 memcpy(hdev->dev_class, sent, 3); in hci_cc_write_class_of_dev()
544 mgmt_set_class_of_dev_complete(hdev, sent, rp->status); in hci_cc_write_class_of_dev()
548 return rp->status; in hci_cc_write_class_of_dev()
554 struct hci_rp_read_voice_setting *rp = data; in hci_cc_read_voice_setting() local
557 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_voice_setting()
559 if (rp->status) in hci_cc_read_voice_setting()
560 return rp->status; in hci_cc_read_voice_setting()
562 setting = __le16_to_cpu(rp->voice_setting); in hci_cc_read_voice_setting()
564 if (hdev->voice_setting == setting) in hci_cc_read_voice_setting()
565 return rp->status; in hci_cc_read_voice_setting()
567 hdev->voice_setting = setting; in hci_cc_read_voice_setting()
569 bt_dev_dbg(hdev, "voice setting 0x%4.4x", setting); in hci_cc_read_voice_setting()
571 if (hdev->notify) in hci_cc_read_voice_setting()
572 hdev->notify(hdev, HCI_NOTIFY_VOICE_SETTING); in hci_cc_read_voice_setting()
574 return rp->status; in hci_cc_read_voice_setting()
580 struct hci_ev_status *rp = data; in hci_cc_write_voice_setting() local
584 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_voice_setting()
586 if (rp->status) in hci_cc_write_voice_setting()
587 return rp->status; in hci_cc_write_voice_setting()
591 return rp->status; in hci_cc_write_voice_setting()
595 if (hdev->voice_setting == setting) in hci_cc_write_voice_setting()
596 return rp->status; in hci_cc_write_voice_setting()
598 hdev->voice_setting = setting; in hci_cc_write_voice_setting()
600 bt_dev_dbg(hdev, "voice setting 0x%4.4x", setting); in hci_cc_write_voice_setting()
602 if (hdev->notify) in hci_cc_write_voice_setting()
603 hdev->notify(hdev, HCI_NOTIFY_VOICE_SETTING); in hci_cc_write_voice_setting()
605 return rp->status; in hci_cc_write_voice_setting()
611 struct hci_rp_read_num_supported_iac *rp = data; in hci_cc_read_num_supported_iac() local
613 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_num_supported_iac()
615 if (rp->status) in hci_cc_read_num_supported_iac()
616 return rp->status; in hci_cc_read_num_supported_iac()
618 hdev->num_iac = rp->num_iac; in hci_cc_read_num_supported_iac()
620 bt_dev_dbg(hdev, "num iac %d", hdev->num_iac); in hci_cc_read_num_supported_iac()
622 return rp->status; in hci_cc_read_num_supported_iac()
628 struct hci_ev_status *rp = data; in hci_cc_write_ssp_mode() local
631 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_ssp_mode()
635 return rp->status; in hci_cc_write_ssp_mode()
639 if (!rp->status) { in hci_cc_write_ssp_mode()
640 if (sent->mode) in hci_cc_write_ssp_mode()
641 hdev->features[1][0] |= LMP_HOST_SSP; in hci_cc_write_ssp_mode()
643 hdev->features[1][0] &= ~LMP_HOST_SSP; in hci_cc_write_ssp_mode()
646 if (!rp->status) { in hci_cc_write_ssp_mode()
647 if (sent->mode) in hci_cc_write_ssp_mode()
655 return rp->status; in hci_cc_write_ssp_mode()
661 struct hci_ev_status *rp = data; in hci_cc_write_sc_support() local
664 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_sc_support()
668 return rp->status; in hci_cc_write_sc_support()
672 if (!rp->status) { in hci_cc_write_sc_support()
673 if (sent->support) in hci_cc_write_sc_support()
674 hdev->features[1][0] |= LMP_HOST_SC; in hci_cc_write_sc_support()
676 hdev->features[1][0] &= ~LMP_HOST_SC; in hci_cc_write_sc_support()
679 if (!hci_dev_test_flag(hdev, HCI_MGMT) && !rp->status) { in hci_cc_write_sc_support()
680 if (sent->support) in hci_cc_write_sc_support()
688 return rp->status; in hci_cc_write_sc_support()
694 struct hci_rp_read_local_version *rp = data; in hci_cc_read_local_version() local
696 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_version()
698 if (rp->status) in hci_cc_read_local_version()
699 return rp->status; in hci_cc_read_local_version()
703 hdev->hci_ver = rp->hci_ver; in hci_cc_read_local_version()
704 hdev->hci_rev = __le16_to_cpu(rp->hci_rev); in hci_cc_read_local_version()
705 hdev->lmp_ver = rp->lmp_ver; in hci_cc_read_local_version()
706 hdev->manufacturer = __le16_to_cpu(rp->manufacturer); in hci_cc_read_local_version()
707 hdev->lmp_subver = __le16_to_cpu(rp->lmp_subver); in hci_cc_read_local_version()
710 return rp->status; in hci_cc_read_local_version()
716 struct hci_rp_read_enc_key_size *rp = data; in hci_cc_read_enc_key_size() local
719 u8 status = rp->status; in hci_cc_read_enc_key_size()
721 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cc_read_enc_key_size()
723 handle = le16_to_cpu(rp->handle); in hci_cc_read_enc_key_size()
740 conn->enc_key_size = 0; in hci_cc_read_enc_key_size()
742 conn->enc_key_size = rp->key_size; in hci_cc_read_enc_key_size()
745 if (conn->enc_key_size < hdev->min_enc_key_size) { in hci_cc_read_enc_key_size()
746 /* As slave role, the conn->state has been set to in hci_cc_read_enc_key_size()
749 * nothing with the non-zero status. in hci_cc_read_enc_key_size()
755 clear_bit(HCI_CONN_ENCRYPT, &conn->flags); in hci_cc_read_enc_key_size()
756 clear_bit(HCI_CONN_AES_CCM, &conn->flags); in hci_cc_read_enc_key_size()
771 struct hci_rp_read_local_commands *rp = data; in hci_cc_read_local_commands() local
773 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_commands()
775 if (rp->status) in hci_cc_read_local_commands()
776 return rp->status; in hci_cc_read_local_commands()
780 memcpy(hdev->commands, rp->commands, sizeof(hdev->commands)); in hci_cc_read_local_commands()
782 return rp->status; in hci_cc_read_local_commands()
788 struct hci_rp_read_auth_payload_to *rp = data; in hci_cc_read_auth_payload_timeout() local
791 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_auth_payload_timeout()
793 if (rp->status) in hci_cc_read_auth_payload_timeout()
794 return rp->status; in hci_cc_read_auth_payload_timeout()
798 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_auth_payload_timeout()
800 conn->auth_payload_timeout = __le16_to_cpu(rp->timeout); in hci_cc_read_auth_payload_timeout()
804 return rp->status; in hci_cc_read_auth_payload_timeout()
810 struct hci_rp_write_auth_payload_to *rp = data; in hci_cc_write_auth_payload_timeout() local
814 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_auth_payload_timeout()
818 return rp->status; in hci_cc_write_auth_payload_timeout()
822 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_write_auth_payload_timeout()
824 rp->status = 0xff; in hci_cc_write_auth_payload_timeout()
828 if (!rp->status) in hci_cc_write_auth_payload_timeout()
829 conn->auth_payload_timeout = get_unaligned_le16(sent + 2); in hci_cc_write_auth_payload_timeout()
834 return rp->status; in hci_cc_write_auth_payload_timeout()
840 struct hci_rp_read_local_features *rp = data; in hci_cc_read_local_features() local
842 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_features()
844 if (rp->status) in hci_cc_read_local_features()
845 return rp->status; in hci_cc_read_local_features()
847 memcpy(hdev->features, rp->features, 8); in hci_cc_read_local_features()
852 if (hdev->features[0][0] & LMP_3SLOT) in hci_cc_read_local_features()
853 hdev->pkt_type |= (HCI_DM3 | HCI_DH3); in hci_cc_read_local_features()
855 if (hdev->features[0][0] & LMP_5SLOT) in hci_cc_read_local_features()
856 hdev->pkt_type |= (HCI_DM5 | HCI_DH5); in hci_cc_read_local_features()
858 if (hdev->features[0][1] & LMP_HV2) { in hci_cc_read_local_features()
859 hdev->pkt_type |= (HCI_HV2); in hci_cc_read_local_features()
860 hdev->esco_type |= (ESCO_HV2); in hci_cc_read_local_features()
863 if (hdev->features[0][1] & LMP_HV3) { in hci_cc_read_local_features()
864 hdev->pkt_type |= (HCI_HV3); in hci_cc_read_local_features()
865 hdev->esco_type |= (ESCO_HV3); in hci_cc_read_local_features()
869 hdev->esco_type |= (ESCO_EV3); in hci_cc_read_local_features()
871 if (hdev->features[0][4] & LMP_EV4) in hci_cc_read_local_features()
872 hdev->esco_type |= (ESCO_EV4); in hci_cc_read_local_features()
874 if (hdev->features[0][4] & LMP_EV5) in hci_cc_read_local_features()
875 hdev->esco_type |= (ESCO_EV5); in hci_cc_read_local_features()
877 if (hdev->features[0][5] & LMP_EDR_ESCO_2M) in hci_cc_read_local_features()
878 hdev->esco_type |= (ESCO_2EV3); in hci_cc_read_local_features()
880 if (hdev->features[0][5] & LMP_EDR_ESCO_3M) in hci_cc_read_local_features()
881 hdev->esco_type |= (ESCO_3EV3); in hci_cc_read_local_features()
883 if (hdev->features[0][5] & LMP_EDR_3S_ESCO) in hci_cc_read_local_features()
884 hdev->esco_type |= (ESCO_2EV5 | ESCO_3EV5); in hci_cc_read_local_features()
886 return rp->status; in hci_cc_read_local_features()
892 struct hci_rp_read_local_ext_features *rp = data; in hci_cc_read_local_ext_features() local
894 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_ext_features()
896 if (rp->status) in hci_cc_read_local_ext_features()
897 return rp->status; in hci_cc_read_local_ext_features()
899 if (hdev->max_page < rp->max_page) { in hci_cc_read_local_ext_features()
901 &hdev->quirks)) in hci_cc_read_local_ext_features()
904 hdev->max_page = rp->max_page; in hci_cc_read_local_ext_features()
907 if (rp->page < HCI_MAX_PAGES) in hci_cc_read_local_ext_features()
908 memcpy(hdev->features[rp->page], rp->features, 8); in hci_cc_read_local_ext_features()
910 return rp->status; in hci_cc_read_local_ext_features()
916 struct hci_rp_read_buffer_size *rp = data; in hci_cc_read_buffer_size() local
918 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_buffer_size()
920 if (rp->status) in hci_cc_read_buffer_size()
921 return rp->status; in hci_cc_read_buffer_size()
923 hdev->acl_mtu = __le16_to_cpu(rp->acl_mtu); in hci_cc_read_buffer_size()
924 hdev->sco_mtu = rp->sco_mtu; in hci_cc_read_buffer_size()
925 hdev->acl_pkts = __le16_to_cpu(rp->acl_max_pkt); in hci_cc_read_buffer_size()
926 hdev->sco_pkts = __le16_to_cpu(rp->sco_max_pkt); in hci_cc_read_buffer_size()
928 if (test_bit(HCI_QUIRK_FIXUP_BUFFER_SIZE, &hdev->quirks)) { in hci_cc_read_buffer_size()
929 hdev->sco_mtu = 64; in hci_cc_read_buffer_size()
930 hdev->sco_pkts = 8; in hci_cc_read_buffer_size()
933 hdev->acl_cnt = hdev->acl_pkts; in hci_cc_read_buffer_size()
934 hdev->sco_cnt = hdev->sco_pkts; in hci_cc_read_buffer_size()
936 BT_DBG("%s acl mtu %d:%d sco mtu %d:%d", hdev->name, hdev->acl_mtu, in hci_cc_read_buffer_size()
937 hdev->acl_pkts, hdev->sco_mtu, hdev->sco_pkts); in hci_cc_read_buffer_size()
939 if (!hdev->acl_mtu || !hdev->acl_pkts) in hci_cc_read_buffer_size()
942 return rp->status; in hci_cc_read_buffer_size()
948 struct hci_rp_read_bd_addr *rp = data; in hci_cc_read_bd_addr() local
950 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_bd_addr()
952 if (rp->status) in hci_cc_read_bd_addr()
953 return rp->status; in hci_cc_read_bd_addr()
955 if (test_bit(HCI_INIT, &hdev->flags)) in hci_cc_read_bd_addr()
956 bacpy(&hdev->bdaddr, &rp->bdaddr); in hci_cc_read_bd_addr()
959 bacpy(&hdev->setup_addr, &rp->bdaddr); in hci_cc_read_bd_addr()
961 return rp->status; in hci_cc_read_bd_addr()
967 struct hci_rp_read_local_pairing_opts *rp = data; in hci_cc_read_local_pairing_opts() local
969 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_pairing_opts()
971 if (rp->status) in hci_cc_read_local_pairing_opts()
972 return rp->status; in hci_cc_read_local_pairing_opts()
976 hdev->pairing_opts = rp->pairing_opts; in hci_cc_read_local_pairing_opts()
977 hdev->max_enc_key_size = rp->max_key_size; in hci_cc_read_local_pairing_opts()
980 return rp->status; in hci_cc_read_local_pairing_opts()
986 struct hci_rp_read_page_scan_activity *rp = data; in hci_cc_read_page_scan_activity() local
988 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_page_scan_activity()
990 if (rp->status) in hci_cc_read_page_scan_activity()
991 return rp->status; in hci_cc_read_page_scan_activity()
993 if (test_bit(HCI_INIT, &hdev->flags)) { in hci_cc_read_page_scan_activity()
994 hdev->page_scan_interval = __le16_to_cpu(rp->interval); in hci_cc_read_page_scan_activity()
995 hdev->page_scan_window = __le16_to_cpu(rp->window); in hci_cc_read_page_scan_activity()
998 return rp->status; in hci_cc_read_page_scan_activity()
1004 struct hci_ev_status *rp = data; in hci_cc_write_page_scan_activity() local
1007 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_page_scan_activity()
1009 if (rp->status) in hci_cc_write_page_scan_activity()
1010 return rp->status; in hci_cc_write_page_scan_activity()
1014 return rp->status; in hci_cc_write_page_scan_activity()
1016 hdev->page_scan_interval = __le16_to_cpu(sent->interval); in hci_cc_write_page_scan_activity()
1017 hdev->page_scan_window = __le16_to_cpu(sent->window); in hci_cc_write_page_scan_activity()
1019 return rp->status; in hci_cc_write_page_scan_activity()
1025 struct hci_rp_read_page_scan_type *rp = data; in hci_cc_read_page_scan_type() local
1027 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_page_scan_type()
1029 if (rp->status) in hci_cc_read_page_scan_type()
1030 return rp->status; in hci_cc_read_page_scan_type()
1032 if (test_bit(HCI_INIT, &hdev->flags)) in hci_cc_read_page_scan_type()
1033 hdev->page_scan_type = rp->type; in hci_cc_read_page_scan_type()
1035 return rp->status; in hci_cc_read_page_scan_type()
1041 struct hci_ev_status *rp = data; in hci_cc_write_page_scan_type() local
1044 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_page_scan_type()
1046 if (rp->status) in hci_cc_write_page_scan_type()
1047 return rp->status; in hci_cc_write_page_scan_type()
1051 hdev->page_scan_type = *type; in hci_cc_write_page_scan_type()
1053 return rp->status; in hci_cc_write_page_scan_type()
1059 struct hci_rp_read_clock *rp = data; in hci_cc_read_clock() local
1063 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_clock()
1065 if (rp->status) in hci_cc_read_clock()
1066 return rp->status; in hci_cc_read_clock()
1074 if (cp->which == 0x00) { in hci_cc_read_clock()
1075 hdev->clock = le32_to_cpu(rp->clock); in hci_cc_read_clock()
1079 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_clock()
1081 conn->clock = le32_to_cpu(rp->clock); in hci_cc_read_clock()
1082 conn->clock_accuracy = le16_to_cpu(rp->accuracy); in hci_cc_read_clock()
1087 return rp->status; in hci_cc_read_clock()
1093 struct hci_rp_read_inq_rsp_tx_power *rp = data; in hci_cc_read_inq_rsp_tx_power() local
1095 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_inq_rsp_tx_power()
1097 if (rp->status) in hci_cc_read_inq_rsp_tx_power()
1098 return rp->status; in hci_cc_read_inq_rsp_tx_power()
1100 hdev->inq_tx_power = rp->tx_power; in hci_cc_read_inq_rsp_tx_power()
1102 return rp->status; in hci_cc_read_inq_rsp_tx_power()
1108 struct hci_rp_read_def_err_data_reporting *rp = data; in hci_cc_read_def_err_data_reporting() local
1110 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_def_err_data_reporting()
1112 if (rp->status) in hci_cc_read_def_err_data_reporting()
1113 return rp->status; in hci_cc_read_def_err_data_reporting()
1115 hdev->err_data_reporting = rp->err_data_reporting; in hci_cc_read_def_err_data_reporting()
1117 return rp->status; in hci_cc_read_def_err_data_reporting()
1123 struct hci_ev_status *rp = data; in hci_cc_write_def_err_data_reporting() local
1126 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_def_err_data_reporting()
1128 if (rp->status) in hci_cc_write_def_err_data_reporting()
1129 return rp->status; in hci_cc_write_def_err_data_reporting()
1133 return rp->status; in hci_cc_write_def_err_data_reporting()
1135 hdev->err_data_reporting = cp->err_data_reporting; in hci_cc_write_def_err_data_reporting()
1137 return rp->status; in hci_cc_write_def_err_data_reporting()
1143 struct hci_rp_pin_code_reply *rp = data; in hci_cc_pin_code_reply() local
1147 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_pin_code_reply()
1152 mgmt_pin_code_reply_complete(hdev, &rp->bdaddr, rp->status); in hci_cc_pin_code_reply()
1154 if (rp->status) in hci_cc_pin_code_reply()
1161 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cc_pin_code_reply()
1163 conn->pin_length = cp->pin_len; in hci_cc_pin_code_reply()
1167 return rp->status; in hci_cc_pin_code_reply()
1173 struct hci_rp_pin_code_neg_reply *rp = data; in hci_cc_pin_code_neg_reply() local
1175 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_pin_code_neg_reply()
1180 mgmt_pin_code_neg_reply_complete(hdev, &rp->bdaddr, in hci_cc_pin_code_neg_reply()
1181 rp->status); in hci_cc_pin_code_neg_reply()
1185 return rp->status; in hci_cc_pin_code_neg_reply()
1191 struct hci_rp_le_read_buffer_size *rp = data; in hci_cc_le_read_buffer_size() local
1193 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_read_buffer_size()
1195 if (rp->status) in hci_cc_le_read_buffer_size()
1196 return rp->status; in hci_cc_le_read_buffer_size()
1198 hdev->le_mtu = __le16_to_cpu(rp->le_mtu); in hci_cc_le_read_buffer_size()
1199 hdev->le_pkts = rp->le_max_pkt; in hci_cc_le_read_buffer_size()
1201 hdev->le_cnt = hdev->le_pkts; in hci_cc_le_read_buffer_size()
1203 BT_DBG("%s le mtu %d:%d", hdev->name, hdev->le_mtu, hdev->le_pkts); in hci_cc_le_read_buffer_size()
1205 if (hdev->le_mtu && hdev->le_mtu < HCI_MIN_LE_MTU) in hci_cc_le_read_buffer_size()
1208 return rp->status; in hci_cc_le_read_buffer_size()
1214 struct hci_rp_le_read_local_features *rp = data; in hci_cc_le_read_local_features() local
1216 BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); in hci_cc_le_read_local_features()
1218 if (rp->status) in hci_cc_le_read_local_features()
1219 return rp->status; in hci_cc_le_read_local_features()
1221 memcpy(hdev->le_features, rp->features, 8); in hci_cc_le_read_local_features()
1223 return rp->status; in hci_cc_le_read_local_features()
1229 struct hci_rp_le_read_adv_tx_power *rp = data; in hci_cc_le_read_adv_tx_power() local
1231 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_read_adv_tx_power()
1233 if (rp->status) in hci_cc_le_read_adv_tx_power()
1234 return rp->status; in hci_cc_le_read_adv_tx_power()
1236 hdev->adv_tx_power = rp->tx_power; in hci_cc_le_read_adv_tx_power()
1238 return rp->status; in hci_cc_le_read_adv_tx_power()
1244 struct hci_rp_user_confirm_reply *rp = data; in hci_cc_user_confirm_reply() local
1246 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_user_confirm_reply()
1251 mgmt_user_confirm_reply_complete(hdev, &rp->bdaddr, ACL_LINK, 0, in hci_cc_user_confirm_reply()
1252 rp->status); in hci_cc_user_confirm_reply()
1256 return rp->status; in hci_cc_user_confirm_reply()
1262 struct hci_rp_user_confirm_reply *rp = data; in hci_cc_user_confirm_neg_reply() local
1264 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_user_confirm_neg_reply()
1269 mgmt_user_confirm_neg_reply_complete(hdev, &rp->bdaddr, in hci_cc_user_confirm_neg_reply()
1270 ACL_LINK, 0, rp->status); in hci_cc_user_confirm_neg_reply()
1274 return rp->status; in hci_cc_user_confirm_neg_reply()
1280 struct hci_rp_user_confirm_reply *rp = data; in hci_cc_user_passkey_reply() local
1282 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_user_passkey_reply()
1287 mgmt_user_passkey_reply_complete(hdev, &rp->bdaddr, ACL_LINK, in hci_cc_user_passkey_reply()
1288 0, rp->status); in hci_cc_user_passkey_reply()
1292 return rp->status; in hci_cc_user_passkey_reply()
1298 struct hci_rp_user_confirm_reply *rp = data; in hci_cc_user_passkey_neg_reply() local
1300 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_user_passkey_neg_reply()
1305 mgmt_user_passkey_neg_reply_complete(hdev, &rp->bdaddr, in hci_cc_user_passkey_neg_reply()
1306 ACL_LINK, 0, rp->status); in hci_cc_user_passkey_neg_reply()
1310 return rp->status; in hci_cc_user_passkey_neg_reply()
1316 struct hci_rp_read_local_oob_data *rp = data; in hci_cc_read_local_oob_data() local
1318 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_oob_data()
1320 return rp->status; in hci_cc_read_local_oob_data()
1326 struct hci_rp_read_local_oob_ext_data *rp = data; in hci_cc_read_local_oob_ext_data() local
1328 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_oob_ext_data()
1330 return rp->status; in hci_cc_read_local_oob_ext_data()
1336 struct hci_ev_status *rp = data; in hci_cc_le_set_random_addr() local
1339 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_random_addr()
1341 if (rp->status) in hci_cc_le_set_random_addr()
1342 return rp->status; in hci_cc_le_set_random_addr()
1346 return rp->status; in hci_cc_le_set_random_addr()
1350 bacpy(&hdev->random_addr, sent); in hci_cc_le_set_random_addr()
1352 if (!bacmp(&hdev->rpa, sent)) { in hci_cc_le_set_random_addr()
1354 queue_delayed_work(hdev->workqueue, &hdev->rpa_expired, in hci_cc_le_set_random_addr()
1355 secs_to_jiffies(hdev->rpa_timeout)); in hci_cc_le_set_random_addr()
1360 return rp->status; in hci_cc_le_set_random_addr()
1366 struct hci_ev_status *rp = data; in hci_cc_le_set_default_phy() local
1369 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_default_phy()
1371 if (rp->status) in hci_cc_le_set_default_phy()
1372 return rp->status; in hci_cc_le_set_default_phy()
1376 return rp->status; in hci_cc_le_set_default_phy()
1380 hdev->le_tx_def_phys = cp->tx_phys; in hci_cc_le_set_default_phy()
1381 hdev->le_rx_def_phys = cp->rx_phys; in hci_cc_le_set_default_phy()
1385 return rp->status; in hci_cc_le_set_default_phy()
1391 struct hci_ev_status *rp = data; in hci_cc_le_set_adv_set_random_addr() local
1395 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_adv_set_random_addr()
1397 if (rp->status) in hci_cc_le_set_adv_set_random_addr()
1398 return rp->status; in hci_cc_le_set_adv_set_random_addr()
1403 * non-extended adverting. in hci_cc_le_set_adv_set_random_addr()
1405 if (!cp || !cp->handle) in hci_cc_le_set_adv_set_random_addr()
1406 return rp->status; in hci_cc_le_set_adv_set_random_addr()
1410 adv = hci_find_adv_instance(hdev, cp->handle); in hci_cc_le_set_adv_set_random_addr()
1412 bacpy(&adv->random_addr, &cp->bdaddr); in hci_cc_le_set_adv_set_random_addr()
1413 if (!bacmp(&hdev->rpa, &cp->bdaddr)) { in hci_cc_le_set_adv_set_random_addr()
1414 adv->rpa_expired = false; in hci_cc_le_set_adv_set_random_addr()
1415 queue_delayed_work(hdev->workqueue, in hci_cc_le_set_adv_set_random_addr()
1416 &adv->rpa_expired_cb, in hci_cc_le_set_adv_set_random_addr()
1417 secs_to_jiffies(hdev->rpa_timeout)); in hci_cc_le_set_adv_set_random_addr()
1423 return rp->status; in hci_cc_le_set_adv_set_random_addr()
1429 struct hci_ev_status *rp = data; in hci_cc_le_remove_adv_set() local
1433 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_remove_adv_set()
1435 if (rp->status) in hci_cc_le_remove_adv_set()
1436 return rp->status; in hci_cc_le_remove_adv_set()
1440 return rp->status; in hci_cc_le_remove_adv_set()
1446 mgmt_advertising_removed(hci_skb_sk(hdev->sent_cmd), hdev, in hci_cc_le_remove_adv_set()
1451 return rp->status; in hci_cc_le_remove_adv_set()
1457 struct hci_ev_status *rp = data; in hci_cc_le_clear_adv_sets() local
1461 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_clear_adv_sets()
1463 if (rp->status) in hci_cc_le_clear_adv_sets()
1464 return rp->status; in hci_cc_le_clear_adv_sets()
1467 return rp->status; in hci_cc_le_clear_adv_sets()
1471 list_for_each_entry_safe(adv, n, &hdev->adv_instances, list) { in hci_cc_le_clear_adv_sets()
1472 u8 instance = adv->instance; in hci_cc_le_clear_adv_sets()
1476 mgmt_advertising_removed(hci_skb_sk(hdev->sent_cmd), in hci_cc_le_clear_adv_sets()
1482 return rp->status; in hci_cc_le_clear_adv_sets()
1488 struct hci_rp_le_read_transmit_power *rp = data; in hci_cc_le_read_transmit_power() local
1490 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_read_transmit_power()
1492 if (rp->status) in hci_cc_le_read_transmit_power()
1493 return rp->status; in hci_cc_le_read_transmit_power()
1495 hdev->min_le_tx_power = rp->min_le_tx_power; in hci_cc_le_read_transmit_power()
1496 hdev->max_le_tx_power = rp->max_le_tx_power; in hci_cc_le_read_transmit_power()
1498 return rp->status; in hci_cc_le_read_transmit_power()
1504 struct hci_ev_status *rp = data; in hci_cc_le_set_privacy_mode() local
1508 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_privacy_mode()
1510 if (rp->status) in hci_cc_le_set_privacy_mode()
1511 return rp->status; in hci_cc_le_set_privacy_mode()
1515 return rp->status; in hci_cc_le_set_privacy_mode()
1519 params = hci_conn_params_lookup(hdev, &cp->bdaddr, cp->bdaddr_type); in hci_cc_le_set_privacy_mode()
1521 WRITE_ONCE(params->privacy_mode, cp->mode); in hci_cc_le_set_privacy_mode()
1525 return rp->status; in hci_cc_le_set_privacy_mode()
1531 struct hci_ev_status *rp = data; in hci_cc_le_set_adv_enable() local
1534 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_adv_enable()
1536 if (rp->status) in hci_cc_le_set_adv_enable()
1537 return rp->status; in hci_cc_le_set_adv_enable()
1541 return rp->status; in hci_cc_le_set_adv_enable()
1555 queue_delayed_work(hdev->workqueue, in hci_cc_le_set_adv_enable()
1556 &conn->le_conn_timeout, in hci_cc_le_set_adv_enable()
1557 conn->conn_timeout); in hci_cc_le_set_adv_enable()
1564 return rp->status; in hci_cc_le_set_adv_enable()
1573 struct hci_ev_status *rp = data; in hci_cc_le_set_ext_adv_enable() local
1575 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_ext_adv_enable()
1577 if (rp->status) in hci_cc_le_set_ext_adv_enable()
1578 return rp->status; in hci_cc_le_set_ext_adv_enable()
1582 return rp->status; in hci_cc_le_set_ext_adv_enable()
1584 set = (void *)cp->data; in hci_cc_le_set_ext_adv_enable()
1588 if (cp->num_of_sets) in hci_cc_le_set_ext_adv_enable()
1589 adv = hci_find_adv_instance(hdev, set->handle); in hci_cc_le_set_ext_adv_enable()
1591 if (cp->enable) { in hci_cc_le_set_ext_adv_enable()
1596 if (adv && !adv->periodic) in hci_cc_le_set_ext_adv_enable()
1597 adv->enabled = true; in hci_cc_le_set_ext_adv_enable()
1601 queue_delayed_work(hdev->workqueue, in hci_cc_le_set_ext_adv_enable()
1602 &conn->le_conn_timeout, in hci_cc_le_set_ext_adv_enable()
1603 conn->conn_timeout); in hci_cc_le_set_ext_adv_enable()
1605 if (cp->num_of_sets) { in hci_cc_le_set_ext_adv_enable()
1607 adv->enabled = false; in hci_cc_le_set_ext_adv_enable()
1612 list_for_each_entry_safe(adv, n, &hdev->adv_instances, in hci_cc_le_set_ext_adv_enable()
1614 if (adv->enabled) in hci_cc_le_set_ext_adv_enable()
1619 list_for_each_entry_safe(adv, n, &hdev->adv_instances, in hci_cc_le_set_ext_adv_enable()
1621 adv->enabled = false; in hci_cc_le_set_ext_adv_enable()
1629 return rp->status; in hci_cc_le_set_ext_adv_enable()
1636 struct hci_ev_status *rp = data; in hci_cc_le_set_scan_param() local
1638 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_scan_param()
1640 if (rp->status) in hci_cc_le_set_scan_param()
1641 return rp->status; in hci_cc_le_set_scan_param()
1645 return rp->status; in hci_cc_le_set_scan_param()
1649 hdev->le_scan_type = cp->type; in hci_cc_le_set_scan_param()
1653 return rp->status; in hci_cc_le_set_scan_param()
1660 struct hci_ev_status *rp = data; in hci_cc_le_set_ext_scan_param() local
1663 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_ext_scan_param()
1665 if (rp->status) in hci_cc_le_set_ext_scan_param()
1666 return rp->status; in hci_cc_le_set_ext_scan_param()
1670 return rp->status; in hci_cc_le_set_ext_scan_param()
1672 phy_param = (void *)cp->data; in hci_cc_le_set_ext_scan_param()
1676 hdev->le_scan_type = phy_param->type; in hci_cc_le_set_ext_scan_param()
1680 return rp->status; in hci_cc_le_set_ext_scan_param()
1685 struct discovery_state *d = &hdev->discovery; in has_pending_adv_report()
1687 return bacmp(&d->last_adv_addr, BDADDR_ANY); in has_pending_adv_report()
1692 struct discovery_state *d = &hdev->discovery; in clear_pending_adv_report()
1694 bacpy(&d->last_adv_addr, BDADDR_ANY); in clear_pending_adv_report()
1695 d->last_adv_data_len = 0; in clear_pending_adv_report()
1702 struct discovery_state *d = &hdev->discovery; in store_pending_adv_report()
1707 bacpy(&d->last_adv_addr, bdaddr); in store_pending_adv_report()
1708 d->last_adv_addr_type = bdaddr_type; in store_pending_adv_report()
1709 d->last_adv_rssi = rssi; in store_pending_adv_report()
1710 d->last_adv_flags = flags; in store_pending_adv_report()
1711 memcpy(d->last_adv_data, data, len); in store_pending_adv_report()
1712 d->last_adv_data_len = len; in store_pending_adv_report()
1722 if (hdev->le_scan_type == LE_SCAN_ACTIVE) { in le_set_scan_enable_complete()
1734 struct discovery_state *d = &hdev->discovery; in le_set_scan_enable_complete()
1736 mgmt_device_found(hdev, &d->last_adv_addr, LE_LINK, in le_set_scan_enable_complete()
1737 d->last_adv_addr_type, NULL, in le_set_scan_enable_complete()
1738 d->last_adv_rssi, d->last_adv_flags, in le_set_scan_enable_complete()
1739 d->last_adv_data, in le_set_scan_enable_complete()
1740 d->last_adv_data_len, NULL, 0, 0); in le_set_scan_enable_complete()
1746 cancel_delayed_work(&hdev->le_scan_disable); in le_set_scan_enable_complete()
1757 hdev->discovery.state == DISCOVERY_FINDING) in le_set_scan_enable_complete()
1758 queue_work(hdev->workqueue, &hdev->reenable_adv_work); in le_set_scan_enable_complete()
1775 struct hci_ev_status *rp = data; in hci_cc_le_set_scan_enable() local
1777 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_scan_enable()
1779 if (rp->status) in hci_cc_le_set_scan_enable()
1780 return rp->status; in hci_cc_le_set_scan_enable()
1784 return rp->status; in hci_cc_le_set_scan_enable()
1786 le_set_scan_enable_complete(hdev, cp->enable); in hci_cc_le_set_scan_enable()
1788 return rp->status; in hci_cc_le_set_scan_enable()
1795 struct hci_ev_status *rp = data; in hci_cc_le_set_ext_scan_enable() local
1797 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_ext_scan_enable()
1799 if (rp->status) in hci_cc_le_set_ext_scan_enable()
1800 return rp->status; in hci_cc_le_set_ext_scan_enable()
1804 return rp->status; in hci_cc_le_set_ext_scan_enable()
1806 le_set_scan_enable_complete(hdev, cp->enable); in hci_cc_le_set_ext_scan_enable()
1808 return rp->status; in hci_cc_le_set_ext_scan_enable()
1814 struct hci_rp_le_read_num_supported_adv_sets *rp = data; in hci_cc_le_read_num_adv_sets() local
1816 bt_dev_dbg(hdev, "status 0x%2.2x No of Adv sets %u", rp->status, in hci_cc_le_read_num_adv_sets()
1817 rp->num_of_sets); in hci_cc_le_read_num_adv_sets()
1819 if (rp->status) in hci_cc_le_read_num_adv_sets()
1820 return rp->status; in hci_cc_le_read_num_adv_sets()
1822 hdev->le_num_of_adv_sets = rp->num_of_sets; in hci_cc_le_read_num_adv_sets()
1824 return rp->status; in hci_cc_le_read_num_adv_sets()
1830 struct hci_rp_le_read_accept_list_size *rp = data; in hci_cc_le_read_accept_list_size() local
1832 bt_dev_dbg(hdev, "status 0x%2.2x size %u", rp->status, rp->size); in hci_cc_le_read_accept_list_size()
1834 if (rp->status) in hci_cc_le_read_accept_list_size()
1835 return rp->status; in hci_cc_le_read_accept_list_size()
1837 hdev->le_accept_list_size = rp->size; in hci_cc_le_read_accept_list_size()
1839 return rp->status; in hci_cc_le_read_accept_list_size()
1845 struct hci_ev_status *rp = data; in hci_cc_le_clear_accept_list() local
1847 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_clear_accept_list()
1849 if (rp->status) in hci_cc_le_clear_accept_list()
1850 return rp->status; in hci_cc_le_clear_accept_list()
1853 hci_bdaddr_list_clear(&hdev->le_accept_list); in hci_cc_le_clear_accept_list()
1856 return rp->status; in hci_cc_le_clear_accept_list()
1863 struct hci_ev_status *rp = data; in hci_cc_le_add_to_accept_list() local
1865 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_add_to_accept_list()
1867 if (rp->status) in hci_cc_le_add_to_accept_list()
1868 return rp->status; in hci_cc_le_add_to_accept_list()
1872 return rp->status; in hci_cc_le_add_to_accept_list()
1875 hci_bdaddr_list_add(&hdev->le_accept_list, &sent->bdaddr, in hci_cc_le_add_to_accept_list()
1876 sent->bdaddr_type); in hci_cc_le_add_to_accept_list()
1879 return rp->status; in hci_cc_le_add_to_accept_list()
1886 struct hci_ev_status *rp = data; in hci_cc_le_del_from_accept_list() local
1888 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_del_from_accept_list()
1890 if (rp->status) in hci_cc_le_del_from_accept_list()
1891 return rp->status; in hci_cc_le_del_from_accept_list()
1895 return rp->status; in hci_cc_le_del_from_accept_list()
1898 hci_bdaddr_list_del(&hdev->le_accept_list, &sent->bdaddr, in hci_cc_le_del_from_accept_list()
1899 sent->bdaddr_type); in hci_cc_le_del_from_accept_list()
1902 return rp->status; in hci_cc_le_del_from_accept_list()
1908 struct hci_rp_le_read_supported_states *rp = data; in hci_cc_le_read_supported_states() local
1910 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_read_supported_states()
1912 if (rp->status) in hci_cc_le_read_supported_states()
1913 return rp->status; in hci_cc_le_read_supported_states()
1915 memcpy(hdev->le_states, rp->le_states, 8); in hci_cc_le_read_supported_states()
1917 return rp->status; in hci_cc_le_read_supported_states()
1923 struct hci_rp_le_read_def_data_len *rp = data; in hci_cc_le_read_def_data_len() local
1925 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_read_def_data_len()
1927 if (rp->status) in hci_cc_le_read_def_data_len()
1928 return rp->status; in hci_cc_le_read_def_data_len()
1930 hdev->le_def_tx_len = le16_to_cpu(rp->tx_len); in hci_cc_le_read_def_data_len()
1931 hdev->le_def_tx_time = le16_to_cpu(rp->tx_time); in hci_cc_le_read_def_data_len()
1933 return rp->status; in hci_cc_le_read_def_data_len()
1940 struct hci_ev_status *rp = data; in hci_cc_le_write_def_data_len() local
1942 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_write_def_data_len()
1944 if (rp->status) in hci_cc_le_write_def_data_len()
1945 return rp->status; in hci_cc_le_write_def_data_len()
1949 return rp->status; in hci_cc_le_write_def_data_len()
1951 hdev->le_def_tx_len = le16_to_cpu(sent->tx_len); in hci_cc_le_write_def_data_len()
1952 hdev->le_def_tx_time = le16_to_cpu(sent->tx_time); in hci_cc_le_write_def_data_len()
1954 return rp->status; in hci_cc_le_write_def_data_len()
1961 struct hci_ev_status *rp = data; in hci_cc_le_add_to_resolv_list() local
1963 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_add_to_resolv_list()
1965 if (rp->status) in hci_cc_le_add_to_resolv_list()
1966 return rp->status; in hci_cc_le_add_to_resolv_list()
1970 return rp->status; in hci_cc_le_add_to_resolv_list()
1973 hci_bdaddr_list_add_with_irk(&hdev->le_resolv_list, &sent->bdaddr, in hci_cc_le_add_to_resolv_list()
1974 sent->bdaddr_type, sent->peer_irk, in hci_cc_le_add_to_resolv_list()
1975 sent->local_irk); in hci_cc_le_add_to_resolv_list()
1978 return rp->status; in hci_cc_le_add_to_resolv_list()
1985 struct hci_ev_status *rp = data; in hci_cc_le_del_from_resolv_list() local
1987 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_del_from_resolv_list()
1989 if (rp->status) in hci_cc_le_del_from_resolv_list()
1990 return rp->status; in hci_cc_le_del_from_resolv_list()
1994 return rp->status; in hci_cc_le_del_from_resolv_list()
1997 hci_bdaddr_list_del_with_irk(&hdev->le_resolv_list, &sent->bdaddr, in hci_cc_le_del_from_resolv_list()
1998 sent->bdaddr_type); in hci_cc_le_del_from_resolv_list()
2001 return rp->status; in hci_cc_le_del_from_resolv_list()
2007 struct hci_ev_status *rp = data; in hci_cc_le_clear_resolv_list() local
2009 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_clear_resolv_list()
2011 if (rp->status) in hci_cc_le_clear_resolv_list()
2012 return rp->status; in hci_cc_le_clear_resolv_list()
2015 hci_bdaddr_list_clear(&hdev->le_resolv_list); in hci_cc_le_clear_resolv_list()
2018 return rp->status; in hci_cc_le_clear_resolv_list()
2024 struct hci_rp_le_read_resolv_list_size *rp = data; in hci_cc_le_read_resolv_list_size() local
2026 bt_dev_dbg(hdev, "status 0x%2.2x size %u", rp->status, rp->size); in hci_cc_le_read_resolv_list_size()
2028 if (rp->status) in hci_cc_le_read_resolv_list_size()
2029 return rp->status; in hci_cc_le_read_resolv_list_size()
2031 hdev->le_resolv_list_size = rp->size; in hci_cc_le_read_resolv_list_size()
2033 return rp->status; in hci_cc_le_read_resolv_list_size()
2039 struct hci_ev_status *rp = data; in hci_cc_le_set_addr_resolution_enable() local
2042 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_addr_resolution_enable()
2044 if (rp->status) in hci_cc_le_set_addr_resolution_enable()
2045 return rp->status; in hci_cc_le_set_addr_resolution_enable()
2049 return rp->status; in hci_cc_le_set_addr_resolution_enable()
2060 return rp->status; in hci_cc_le_set_addr_resolution_enable()
2066 struct hci_rp_le_read_max_data_len *rp = data; in hci_cc_le_read_max_data_len() local
2068 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_read_max_data_len()
2070 if (rp->status) in hci_cc_le_read_max_data_len()
2071 return rp->status; in hci_cc_le_read_max_data_len()
2073 hdev->le_max_tx_len = le16_to_cpu(rp->tx_len); in hci_cc_le_read_max_data_len()
2074 hdev->le_max_tx_time = le16_to_cpu(rp->tx_time); in hci_cc_le_read_max_data_len()
2075 hdev->le_max_rx_len = le16_to_cpu(rp->rx_len); in hci_cc_le_read_max_data_len()
2076 hdev->le_max_rx_time = le16_to_cpu(rp->rx_time); in hci_cc_le_read_max_data_len()
2078 return rp->status; in hci_cc_le_read_max_data_len()
2085 struct hci_ev_status *rp = data; in hci_cc_write_le_host_supported() local
2087 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_le_host_supported()
2089 if (rp->status) in hci_cc_write_le_host_supported()
2090 return rp->status; in hci_cc_write_le_host_supported()
2094 return rp->status; in hci_cc_write_le_host_supported()
2098 if (sent->le) { in hci_cc_write_le_host_supported()
2099 hdev->features[1][0] |= LMP_HOST_LE; in hci_cc_write_le_host_supported()
2102 hdev->features[1][0] &= ~LMP_HOST_LE; in hci_cc_write_le_host_supported()
2107 if (sent->simul) in hci_cc_write_le_host_supported()
2108 hdev->features[1][0] |= LMP_HOST_LE_BREDR; in hci_cc_write_le_host_supported()
2110 hdev->features[1][0] &= ~LMP_HOST_LE_BREDR; in hci_cc_write_le_host_supported()
2114 return rp->status; in hci_cc_write_le_host_supported()
2121 struct hci_ev_status *rp = data; in hci_cc_set_adv_param() local
2123 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_set_adv_param()
2125 if (rp->status) in hci_cc_set_adv_param()
2126 return rp->status; in hci_cc_set_adv_param()
2130 return rp->status; in hci_cc_set_adv_param()
2133 hdev->adv_addr_type = cp->own_address_type; in hci_cc_set_adv_param()
2136 return rp->status; in hci_cc_set_adv_param()
2142 struct hci_rp_le_set_ext_adv_params *rp = data; in hci_cc_set_ext_adv_param() local
2146 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_set_ext_adv_param()
2148 if (rp->status) in hci_cc_set_ext_adv_param()
2149 return rp->status; in hci_cc_set_ext_adv_param()
2153 return rp->status; in hci_cc_set_ext_adv_param()
2156 hdev->adv_addr_type = cp->own_addr_type; in hci_cc_set_ext_adv_param()
2157 if (!cp->handle) { in hci_cc_set_ext_adv_param()
2159 hdev->adv_tx_power = rp->tx_power; in hci_cc_set_ext_adv_param()
2161 adv_instance = hci_find_adv_instance(hdev, cp->handle); in hci_cc_set_ext_adv_param()
2163 adv_instance->tx_power = rp->tx_power; in hci_cc_set_ext_adv_param()
2166 hci_update_adv_data(hdev, cp->handle); in hci_cc_set_ext_adv_param()
2170 return rp->status; in hci_cc_set_ext_adv_param()
2176 struct hci_rp_read_rssi *rp = data; in hci_cc_read_rssi() local
2179 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_rssi()
2181 if (rp->status) in hci_cc_read_rssi()
2182 return rp->status; in hci_cc_read_rssi()
2186 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_rssi()
2188 conn->rssi = rp->rssi; in hci_cc_read_rssi()
2192 return rp->status; in hci_cc_read_rssi()
2199 struct hci_rp_read_tx_power *rp = data; in hci_cc_read_tx_power() local
2202 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_tx_power()
2204 if (rp->status) in hci_cc_read_tx_power()
2205 return rp->status; in hci_cc_read_tx_power()
2209 return rp->status; in hci_cc_read_tx_power()
2213 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_tx_power()
2217 switch (sent->type) { in hci_cc_read_tx_power()
2219 conn->tx_power = rp->tx_power; in hci_cc_read_tx_power()
2222 conn->max_tx_power = rp->tx_power; in hci_cc_read_tx_power()
2228 return rp->status; in hci_cc_read_tx_power()
2234 struct hci_ev_status *rp = data; in hci_cc_write_ssp_debug_mode() local
2237 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_ssp_debug_mode()
2239 if (rp->status) in hci_cc_write_ssp_debug_mode()
2240 return rp->status; in hci_cc_write_ssp_debug_mode()
2244 hdev->ssp_debug_mode = *mode; in hci_cc_write_ssp_debug_mode()
2246 return rp->status; in hci_cc_write_ssp_debug_mode()
2251 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_inquiry()
2257 set_bit(HCI_INQUIRY, &hdev->flags); in hci_cs_inquiry()
2265 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_create_conn()
2273 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cs_create_conn()
2275 bt_dev_dbg(hdev, "bdaddr %pMR hcon %p", &cp->bdaddr, conn); in hci_cs_create_conn()
2278 if (conn && conn->state == BT_CONNECT) { in hci_cs_create_conn()
2279 conn->state = BT_CLOSED; in hci_cs_create_conn()
2285 conn = hci_conn_add_unset(hdev, ACL_LINK, &cp->bdaddr, in hci_cs_create_conn()
2302 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_add_sco()
2311 handle = __le16_to_cpu(cp->handle); in hci_cs_add_sco()
2313 bt_dev_dbg(hdev, "handle 0x%4.4x", handle); in hci_cs_add_sco()
2319 link = list_first_entry_or_null(&acl->link_list, in hci_cs_add_sco()
2321 if (link && link->conn) { in hci_cs_add_sco()
2322 link->conn->state = BT_CLOSED; in hci_cs_add_sco()
2324 hci_connect_cfm(link->conn, status); in hci_cs_add_sco()
2325 hci_conn_del(link->conn); in hci_cs_add_sco()
2337 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_auth_requested()
2348 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_auth_requested()
2350 if (conn->state == BT_CONFIG) { in hci_cs_auth_requested()
2364 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_set_conn_encrypt()
2375 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_set_conn_encrypt()
2377 if (conn->state == BT_CONFIG) { in hci_cs_set_conn_encrypt()
2389 if (conn->state != BT_CONFIG || !conn->out) in hci_outgoing_auth_needed()
2392 if (conn->pending_sec_level == BT_SECURITY_SDP) in hci_outgoing_auth_needed()
2395 /* Only request authentication for SSP connections or non-SSP in hci_outgoing_auth_needed()
2399 if (!hci_conn_ssp_enabled(conn) && !(conn->auth_type & 0x01) && in hci_outgoing_auth_needed()
2400 conn->pending_sec_level != BT_SECURITY_FIPS && in hci_outgoing_auth_needed()
2401 conn->pending_sec_level != BT_SECURITY_HIGH && in hci_outgoing_auth_needed()
2402 conn->pending_sec_level != BT_SECURITY_MEDIUM) in hci_outgoing_auth_needed()
2415 bacpy(&cp.bdaddr, &e->data.bdaddr); in hci_resolve_name()
2416 cp.pscan_rep_mode = e->data.pscan_rep_mode; in hci_resolve_name()
2417 cp.pscan_mode = e->data.pscan_mode; in hci_resolve_name()
2418 cp.clock_offset = e->data.clock_offset; in hci_resolve_name()
2425 struct discovery_state *discov = &hdev->discovery; in hci_resolve_next_name()
2428 if (list_empty(&discov->resolve)) in hci_resolve_next_name()
2432 if (time_after(jiffies, discov->name_resolve_timeout)) { in hci_resolve_next_name()
2442 e->name_state = NAME_PENDING; in hci_resolve_next_name()
2452 struct discovery_state *discov = &hdev->discovery; in hci_check_pending_name()
2460 if (conn && (conn->state == BT_CONFIG || conn->state == BT_CONNECTED)) in hci_check_pending_name()
2463 if (discov->state == DISCOVERY_STOPPED) in hci_check_pending_name()
2466 if (discov->state == DISCOVERY_STOPPING) in hci_check_pending_name()
2469 if (discov->state != DISCOVERY_RESOLVING) in hci_check_pending_name()
2480 list_del(&e->list); in hci_check_pending_name()
2482 e->name_state = name ? NAME_KNOWN : NAME_NOT_KNOWN; in hci_check_pending_name()
2483 mgmt_remote_name(hdev, bdaddr, ACL_LINK, 0x00, e->data.rssi, in hci_check_pending_name()
2498 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_remote_name_req()
2511 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cs_remote_name_req()
2514 hci_check_pending_name(hdev, conn, &cp->bdaddr, NULL, 0); in hci_cs_remote_name_req()
2522 if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->flags)) { in hci_cs_remote_name_req()
2525 set_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags); in hci_cs_remote_name_req()
2527 auth_cp.handle = __cpu_to_le16(conn->handle); in hci_cs_remote_name_req()
2541 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_read_remote_features()
2552 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_read_remote_features()
2554 if (conn->state == BT_CONFIG) { in hci_cs_read_remote_features()
2568 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_read_remote_ext_features()
2579 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_read_remote_ext_features()
2581 if (conn->state == BT_CONFIG) { in hci_cs_read_remote_ext_features()
2596 bt_dev_dbg(hdev, "handle 0x%4.4x status 0x%2.2x", handle, status); in hci_setup_sync_conn_status()
2602 link = list_first_entry_or_null(&acl->link_list, in hci_setup_sync_conn_status()
2604 if (link && link->conn) { in hci_setup_sync_conn_status()
2605 link->conn->state = BT_CLOSED; in hci_setup_sync_conn_status()
2607 hci_connect_cfm(link->conn, status); in hci_setup_sync_conn_status()
2608 hci_conn_del(link->conn); in hci_setup_sync_conn_status()
2619 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_setup_sync_conn()
2628 hci_setup_sync_conn_status(hdev, __le16_to_cpu(cp->handle), status); in hci_cs_setup_sync_conn()
2635 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_enhanced_setup_sync_conn()
2644 hci_setup_sync_conn_status(hdev, __le16_to_cpu(cp->handle), status); in hci_cs_enhanced_setup_sync_conn()
2652 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_sniff_mode()
2663 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_sniff_mode()
2665 clear_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->flags); in hci_cs_sniff_mode()
2667 if (test_and_clear_bit(HCI_CONN_SCO_SETUP_PEND, &conn->flags)) in hci_cs_sniff_mode()
2679 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_exit_sniff_mode()
2690 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_exit_sniff_mode()
2692 clear_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->flags); in hci_cs_exit_sniff_mode()
2694 if (test_and_clear_bit(HCI_CONN_SCO_SETUP_PEND, &conn->flags)) in hci_cs_exit_sniff_mode()
2708 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_disconnect()
2713 if (!status && !hdev->suspended) in hci_cs_disconnect()
2722 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_disconnect()
2727 mgmt_disconnect_failed(hdev, &conn->dst, conn->type, in hci_cs_disconnect()
2728 conn->dst_type, status); in hci_cs_disconnect()
2730 if (conn->type == LE_LINK && conn->role == HCI_ROLE_SLAVE) { in hci_cs_disconnect()
2731 hdev->cur_adv_instance = conn->adv_instance; in hci_cs_disconnect()
2741 mgmt_conn = test_and_clear_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags); in hci_cs_disconnect()
2743 if (conn->type == ACL_LINK) { in hci_cs_disconnect()
2744 if (test_and_clear_bit(HCI_CONN_FLUSH_KEY, &conn->flags)) in hci_cs_disconnect()
2745 hci_remove_link_key(hdev, &conn->dst); in hci_cs_disconnect()
2748 params = hci_conn_params_lookup(hdev, &conn->dst, conn->dst_type); in hci_cs_disconnect()
2750 switch (params->auto_connect) { in hci_cs_disconnect()
2752 if (cp->reason != HCI_ERROR_CONNECTION_TIMEOUT) in hci_cs_disconnect()
2759 hci_pend_le_list_add(params, &hdev->pend_le_conns); in hci_cs_disconnect()
2767 mgmt_device_disconnected(hdev, &conn->dst, conn->type, conn->dst_type, in hci_cs_disconnect()
2768 cp->reason, mgmt_conn); in hci_cs_disconnect()
2770 hci_disconn_cfm(conn, cp->reason); in hci_cs_disconnect()
2775 * Hence, we need to do some basic cleanup here and re-enable in hci_cs_disconnect()
2822 conn->init_addr_type = own_address_type; in cs_le_create_conn()
2824 bacpy(&conn->init_addr, &hdev->random_addr); in cs_le_create_conn()
2826 bacpy(&conn->init_addr, &hdev->bdaddr); in cs_le_create_conn()
2828 conn->resp_addr_type = peer_addr_type; in cs_le_create_conn()
2829 bacpy(&conn->resp_addr, peer_addr); in cs_le_create_conn()
2836 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_le_create_conn()
2851 cs_le_create_conn(hdev, &cp->peer_addr, cp->peer_addr_type, in hci_cs_le_create_conn()
2852 cp->own_address_type, cp->filter_policy); in hci_cs_le_create_conn()
2861 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_le_ext_create_conn()
2876 cs_le_create_conn(hdev, &cp->peer_addr, cp->peer_addr_type, in hci_cs_le_ext_create_conn()
2877 cp->own_addr_type, cp->filter_policy); in hci_cs_le_ext_create_conn()
2887 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_le_read_remote_features()
2898 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_le_read_remote_features()
2900 if (conn->state == BT_CONFIG) { in hci_cs_le_read_remote_features()
2914 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_le_start_enc()
2925 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_le_start_enc()
2929 if (conn->state != BT_CONNECTED) in hci_cs_le_start_enc()
2944 BT_DBG("%s status 0x%2.2x", hdev->name, status); in hci_cs_switch_role()
2955 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cs_switch_role()
2957 clear_bit(HCI_CONN_RSWITCH_PEND, &conn->flags); in hci_cs_switch_role()
2966 struct discovery_state *discov = &hdev->discovery; in hci_inquiry_complete_evt()
2969 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_inquiry_complete_evt()
2971 if (!test_and_clear_bit(HCI_INQUIRY, &hdev->flags)) in hci_inquiry_complete_evt()
2975 wake_up_bit(&hdev->flags, HCI_INQUIRY); in hci_inquiry_complete_evt()
2982 if (discov->state != DISCOVERY_FINDING) in hci_inquiry_complete_evt()
2985 if (list_empty(&discov->resolve)) { in hci_inquiry_complete_evt()
2994 !test_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks)) in hci_inquiry_complete_evt()
3001 e->name_state = NAME_PENDING; in hci_inquiry_complete_evt()
3003 discov->name_resolve_timeout = jiffies + NAME_RESOLVE_DURATION; in hci_inquiry_complete_evt()
3013 !test_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks)) in hci_inquiry_complete_evt()
3029 flex_array_size(ev, info, ev->num))) in hci_inquiry_result_evt()
3032 bt_dev_dbg(hdev, "num %d", ev->num); in hci_inquiry_result_evt()
3034 if (!ev->num) in hci_inquiry_result_evt()
3042 for (i = 0; i < ev->num; i++) { in hci_inquiry_result_evt()
3043 struct inquiry_info *info = &ev->info[i]; in hci_inquiry_result_evt()
3046 bacpy(&data.bdaddr, &info->bdaddr); in hci_inquiry_result_evt()
3047 data.pscan_rep_mode = info->pscan_rep_mode; in hci_inquiry_result_evt()
3048 data.pscan_period_mode = info->pscan_period_mode; in hci_inquiry_result_evt()
3049 data.pscan_mode = info->pscan_mode; in hci_inquiry_result_evt()
3050 memcpy(data.dev_class, info->dev_class, 3); in hci_inquiry_result_evt()
3051 data.clock_offset = info->clock_offset; in hci_inquiry_result_evt()
3057 mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, in hci_inquiry_result_evt()
3058 info->dev_class, HCI_RSSI_INVALID, in hci_inquiry_result_evt()
3070 u8 status = ev->status; in hci_conn_complete_evt()
3072 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_conn_complete_evt()
3076 conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, &ev->bdaddr); in hci_conn_complete_evt()
3081 if (ev->status) in hci_conn_complete_evt()
3084 /* Connection may not exist if auto-connected. Check the bredr in hci_conn_complete_evt()
3089 * Auto-connect will only occur if the event filter is in hci_conn_complete_evt()
3093 if (ev->link_type == ACL_LINK && in hci_conn_complete_evt()
3094 hci_bdaddr_list_lookup_with_flags(&hdev->accept_list, in hci_conn_complete_evt()
3095 &ev->bdaddr, in hci_conn_complete_evt()
3097 conn = hci_conn_add_unset(hdev, ev->link_type, in hci_conn_complete_evt()
3098 &ev->bdaddr, HCI_ROLE_SLAVE); in hci_conn_complete_evt()
3104 if (ev->link_type != SCO_LINK) in hci_conn_complete_evt()
3108 &ev->bdaddr); in hci_conn_complete_evt()
3112 conn->type = SCO_LINK; in hci_conn_complete_evt()
3122 if (!HCI_CONN_HANDLE_UNSET(conn->handle)) { in hci_conn_complete_evt()
3128 status = hci_conn_set_handle(conn, __le16_to_cpu(ev->handle)); in hci_conn_complete_evt()
3132 if (conn->type == ACL_LINK) { in hci_conn_complete_evt()
3133 conn->state = BT_CONFIG; in hci_conn_complete_evt()
3136 if (!conn->out && !hci_conn_ssp_enabled(conn) && in hci_conn_complete_evt()
3137 !hci_find_link_key(hdev, &ev->bdaddr)) in hci_conn_complete_evt()
3138 conn->disc_timeout = HCI_PAIRING_TIMEOUT; in hci_conn_complete_evt()
3140 conn->disc_timeout = HCI_DISCONN_TIMEOUT; in hci_conn_complete_evt()
3142 conn->state = BT_CONNECTED; in hci_conn_complete_evt()
3147 if (test_bit(HCI_AUTH, &hdev->flags)) in hci_conn_complete_evt()
3148 set_bit(HCI_CONN_AUTH, &conn->flags); in hci_conn_complete_evt()
3150 if (test_bit(HCI_ENCRYPT, &hdev->flags)) in hci_conn_complete_evt()
3151 set_bit(HCI_CONN_ENCRYPT, &conn->flags); in hci_conn_complete_evt()
3154 if (ev->encr_mode == 1 && !test_bit(HCI_CONN_ENCRYPT, &conn->flags) && in hci_conn_complete_evt()
3155 ev->link_type == ACL_LINK) { in hci_conn_complete_evt()
3159 key = hci_find_link_key(hdev, &ev->bdaddr); in hci_conn_complete_evt()
3161 set_bit(HCI_CONN_ENCRYPT, &conn->flags); in hci_conn_complete_evt()
3164 conn->enc_key_size = HCI_LINK_KEY_SIZE; in hci_conn_complete_evt()
3166 cp.handle = cpu_to_le16(conn->handle); in hci_conn_complete_evt()
3170 conn->enc_key_size = HCI_LINK_KEY_SIZE; in hci_conn_complete_evt()
3174 hci_encrypt_cfm(conn, ev->status); in hci_conn_complete_evt()
3179 if (conn->type == ACL_LINK) { in hci_conn_complete_evt()
3181 cp.handle = ev->handle; in hci_conn_complete_evt()
3189 if (!conn->out && hdev->hci_ver < BLUETOOTH_VER_2_0) { in hci_conn_complete_evt()
3191 cp.handle = ev->handle; in hci_conn_complete_evt()
3192 cp.pkt_type = cpu_to_le16(conn->pkt_type); in hci_conn_complete_evt()
3198 if (conn->type == ACL_LINK) in hci_conn_complete_evt()
3199 hci_sco_setup(conn, ev->status); in hci_conn_complete_evt()
3204 } else if (ev->link_type == SCO_LINK) { in hci_conn_complete_evt()
3205 switch (conn->setting & SCO_AIRMODE_MASK) { in hci_conn_complete_evt()
3207 if (hdev->notify) in hci_conn_complete_evt()
3208 hdev->notify(hdev, HCI_NOTIFY_ENABLE_SCO_CVSD); in hci_conn_complete_evt()
3232 int mask = hdev->link_mode; in hci_conn_request_evt()
3237 bt_dev_dbg(hdev, "bdaddr %pMR type 0x%x", &ev->bdaddr, ev->link_type); in hci_conn_request_evt()
3240 * CVE-2020-26555 in hci_conn_request_evt()
3242 if (hdev && !bacmp(&hdev->bdaddr, &ev->bdaddr)) { in hci_conn_request_evt()
3244 &ev->bdaddr); in hci_conn_request_evt()
3245 hci_reject_conn(hdev, &ev->bdaddr); in hci_conn_request_evt()
3249 mask |= hci_proto_connect_ind(hdev, &ev->bdaddr, ev->link_type, in hci_conn_request_evt()
3253 hci_reject_conn(hdev, &ev->bdaddr); in hci_conn_request_evt()
3259 if (hci_bdaddr_list_lookup(&hdev->reject_list, &ev->bdaddr, in hci_conn_request_evt()
3261 hci_reject_conn(hdev, &ev->bdaddr); in hci_conn_request_evt()
3271 !hci_bdaddr_list_lookup_with_flags(&hdev->accept_list, &ev->bdaddr, in hci_conn_request_evt()
3273 hci_reject_conn(hdev, &ev->bdaddr); in hci_conn_request_evt()
3279 ie = hci_inquiry_cache_lookup(hdev, &ev->bdaddr); in hci_conn_request_evt()
3281 memcpy(ie->data.dev_class, ev->dev_class, 3); in hci_conn_request_evt()
3283 conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, in hci_conn_request_evt()
3284 &ev->bdaddr); in hci_conn_request_evt()
3286 conn = hci_conn_add_unset(hdev, ev->link_type, &ev->bdaddr, in hci_conn_request_evt()
3294 memcpy(conn->dev_class, ev->dev_class, 3); in hci_conn_request_evt()
3298 if (ev->link_type == ACL_LINK || in hci_conn_request_evt()
3301 conn->state = BT_CONNECT; in hci_conn_request_evt()
3303 bacpy(&cp.bdaddr, &ev->bdaddr); in hci_conn_request_evt()
3313 conn->state = BT_CONNECT; in hci_conn_request_evt()
3315 bacpy(&cp.bdaddr, &ev->bdaddr); in hci_conn_request_evt()
3316 cp.pkt_type = cpu_to_le16(conn->pkt_type); in hci_conn_request_evt()
3321 cp.content_format = cpu_to_le16(hdev->voice_setting); in hci_conn_request_evt()
3327 conn->state = BT_CONNECT2; in hci_conn_request_evt()
3361 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_disconn_complete_evt()
3365 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_disconn_complete_evt()
3369 if (ev->status) { in hci_disconn_complete_evt()
3370 mgmt_disconnect_failed(hdev, &conn->dst, conn->type, in hci_disconn_complete_evt()
3371 conn->dst_type, ev->status); in hci_disconn_complete_evt()
3375 conn->state = BT_CLOSED; in hci_disconn_complete_evt()
3377 mgmt_connected = test_and_clear_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags); in hci_disconn_complete_evt()
3379 if (test_bit(HCI_CONN_AUTH_FAILURE, &conn->flags)) in hci_disconn_complete_evt()
3382 reason = hci_to_mgmt_reason(ev->reason); in hci_disconn_complete_evt()
3384 mgmt_device_disconnected(hdev, &conn->dst, conn->type, conn->dst_type, in hci_disconn_complete_evt()
3387 if (conn->type == ACL_LINK) { in hci_disconn_complete_evt()
3388 if (test_and_clear_bit(HCI_CONN_FLUSH_KEY, &conn->flags)) in hci_disconn_complete_evt()
3389 hci_remove_link_key(hdev, &conn->dst); in hci_disconn_complete_evt()
3394 /* Re-enable passive scanning if disconnected device is marked in hci_disconn_complete_evt()
3395 * as auto-connectable. in hci_disconn_complete_evt()
3397 if (conn->type == LE_LINK) { in hci_disconn_complete_evt()
3398 params = hci_conn_params_lookup(hdev, &conn->dst, in hci_disconn_complete_evt()
3399 conn->dst_type); in hci_disconn_complete_evt()
3401 switch (params->auto_connect) { in hci_disconn_complete_evt()
3403 if (ev->reason != HCI_ERROR_CONNECTION_TIMEOUT) in hci_disconn_complete_evt()
3411 &hdev->pend_le_conns); in hci_disconn_complete_evt()
3421 hci_disconn_cfm(conn, ev->reason); in hci_disconn_complete_evt()
3423 /* Re-enable advertising if necessary, since it might in hci_disconn_complete_evt()
3433 if (conn->type == LE_LINK && conn->role == HCI_ROLE_SLAVE) { in hci_disconn_complete_evt()
3434 hdev->cur_adv_instance = conn->adv_instance; in hci_disconn_complete_evt()
3450 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_auth_complete_evt()
3454 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_auth_complete_evt()
3458 if (!ev->status) { in hci_auth_complete_evt()
3459 clear_bit(HCI_CONN_AUTH_FAILURE, &conn->flags); in hci_auth_complete_evt()
3460 set_bit(HCI_CONN_AUTH, &conn->flags); in hci_auth_complete_evt()
3461 conn->sec_level = conn->pending_sec_level; in hci_auth_complete_evt()
3463 if (ev->status == HCI_ERROR_PIN_OR_KEY_MISSING) in hci_auth_complete_evt()
3464 set_bit(HCI_CONN_AUTH_FAILURE, &conn->flags); in hci_auth_complete_evt()
3466 mgmt_auth_failed(conn, ev->status); in hci_auth_complete_evt()
3469 clear_bit(HCI_CONN_AUTH_PEND, &conn->flags); in hci_auth_complete_evt()
3471 if (conn->state == BT_CONFIG) { in hci_auth_complete_evt()
3472 if (!ev->status && hci_conn_ssp_enabled(conn)) { in hci_auth_complete_evt()
3474 cp.handle = ev->handle; in hci_auth_complete_evt()
3479 conn->state = BT_CONNECTED; in hci_auth_complete_evt()
3480 hci_connect_cfm(conn, ev->status); in hci_auth_complete_evt()
3484 hci_auth_cfm(conn, ev->status); in hci_auth_complete_evt()
3487 conn->disc_timeout = HCI_DISCONN_TIMEOUT; in hci_auth_complete_evt()
3491 if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags)) { in hci_auth_complete_evt()
3492 if (!ev->status) { in hci_auth_complete_evt()
3494 cp.handle = ev->handle; in hci_auth_complete_evt()
3499 clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags); in hci_auth_complete_evt()
3500 hci_encrypt_cfm(conn, ev->status); in hci_auth_complete_evt()
3514 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_remote_name_evt()
3518 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_remote_name_evt()
3523 if (ev->status == 0) in hci_remote_name_evt()
3524 hci_check_pending_name(hdev, conn, &ev->bdaddr, ev->name, in hci_remote_name_evt()
3525 strnlen(ev->name, HCI_MAX_NAME_LENGTH)); in hci_remote_name_evt()
3527 hci_check_pending_name(hdev, conn, &ev->bdaddr, NULL, 0); in hci_remote_name_evt()
3536 if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->flags)) { in hci_remote_name_evt()
3539 set_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags); in hci_remote_name_evt()
3541 cp.handle = __cpu_to_le16(conn->handle); in hci_remote_name_evt()
3555 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_encrypt_change_evt()
3559 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_encrypt_change_evt()
3563 if (!ev->status) { in hci_encrypt_change_evt()
3564 if (ev->encrypt) { in hci_encrypt_change_evt()
3566 set_bit(HCI_CONN_AUTH, &conn->flags); in hci_encrypt_change_evt()
3567 set_bit(HCI_CONN_ENCRYPT, &conn->flags); in hci_encrypt_change_evt()
3568 conn->sec_level = conn->pending_sec_level; in hci_encrypt_change_evt()
3570 /* P-256 authentication key implies FIPS */ in hci_encrypt_change_evt()
3571 if (conn->key_type == HCI_LK_AUTH_COMBINATION_P256) in hci_encrypt_change_evt()
3572 set_bit(HCI_CONN_FIPS, &conn->flags); in hci_encrypt_change_evt()
3574 if ((conn->type == ACL_LINK && ev->encrypt == 0x02) || in hci_encrypt_change_evt()
3575 conn->type == LE_LINK) in hci_encrypt_change_evt()
3576 set_bit(HCI_CONN_AES_CCM, &conn->flags); in hci_encrypt_change_evt()
3578 clear_bit(HCI_CONN_ENCRYPT, &conn->flags); in hci_encrypt_change_evt()
3579 clear_bit(HCI_CONN_AES_CCM, &conn->flags); in hci_encrypt_change_evt()
3586 if (ev->status && conn->type == LE_LINK) { in hci_encrypt_change_evt()
3591 clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags); in hci_encrypt_change_evt()
3595 ev->status = HCI_ERROR_AUTH_FAILURE; in hci_encrypt_change_evt()
3597 if (ev->status && conn->state == BT_CONNECTED) { in hci_encrypt_change_evt()
3598 if (ev->status == HCI_ERROR_PIN_OR_KEY_MISSING) in hci_encrypt_change_evt()
3599 set_bit(HCI_CONN_AUTH_FAILURE, &conn->flags); in hci_encrypt_change_evt()
3604 hci_encrypt_cfm(conn, ev->status); in hci_encrypt_change_evt()
3611 if (!ev->status && ev->encrypt && conn->type == ACL_LINK) { in hci_encrypt_change_evt()
3619 conn->enc_key_size = HCI_LINK_KEY_SIZE; in hci_encrypt_change_evt()
3623 cp.handle = cpu_to_le16(conn->handle); in hci_encrypt_change_evt()
3627 conn->enc_key_size = HCI_LINK_KEY_SIZE; in hci_encrypt_change_evt()
3638 &hdev->quirks)) in hci_encrypt_change_evt()
3646 * Ensure for AES-CCM encryption as well. in hci_encrypt_change_evt()
3648 if (test_bit(HCI_CONN_ENCRYPT, &conn->flags) && in hci_encrypt_change_evt()
3649 test_bit(HCI_CONN_AES_CCM, &conn->flags) && in hci_encrypt_change_evt()
3650 ((conn->type == ACL_LINK && lmp_ping_capable(hdev)) || in hci_encrypt_change_evt()
3651 (conn->type == LE_LINK && (hdev->le_features[0] & HCI_LE_PING)))) { in hci_encrypt_change_evt()
3654 cp.handle = cpu_to_le16(conn->handle); in hci_encrypt_change_evt()
3655 cp.timeout = cpu_to_le16(hdev->auth_payload_timeout); in hci_encrypt_change_evt()
3656 if (hci_send_cmd(conn->hdev, HCI_OP_WRITE_AUTH_PAYLOAD_TO, in hci_encrypt_change_evt()
3662 hci_encrypt_cfm(conn, ev->status); in hci_encrypt_change_evt()
3674 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_change_link_key_complete_evt()
3678 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_change_link_key_complete_evt()
3680 if (!ev->status) in hci_change_link_key_complete_evt()
3681 set_bit(HCI_CONN_SECURE, &conn->flags); in hci_change_link_key_complete_evt()
3683 clear_bit(HCI_CONN_AUTH_PEND, &conn->flags); in hci_change_link_key_complete_evt()
3685 hci_key_change_cfm(conn, ev->status); in hci_change_link_key_complete_evt()
3697 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_remote_features_evt()
3701 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_remote_features_evt()
3705 if (!ev->status) in hci_remote_features_evt()
3706 memcpy(conn->features[0], ev->features, 8); in hci_remote_features_evt()
3708 if (conn->state != BT_CONFIG) in hci_remote_features_evt()
3711 if (!ev->status && lmp_ext_feat_capable(hdev) && in hci_remote_features_evt()
3714 cp.handle = ev->handle; in hci_remote_features_evt()
3721 if (!ev->status) { in hci_remote_features_evt()
3724 bacpy(&cp.bdaddr, &conn->dst); in hci_remote_features_evt()
3732 conn->state = BT_CONNECTED; in hci_remote_features_evt()
3733 hci_connect_cfm(conn, ev->status); in hci_remote_features_evt()
3743 cancel_delayed_work(&hdev->cmd_timer); in handle_cmd_cnt_and_timer()
3746 if (!test_bit(HCI_RESET, &hdev->flags)) { in handle_cmd_cnt_and_timer()
3748 cancel_delayed_work(&hdev->ncmd_timer); in handle_cmd_cnt_and_timer()
3749 atomic_set(&hdev->cmd_cnt, 1); in handle_cmd_cnt_and_timer()
3752 queue_delayed_work(hdev->workqueue, &hdev->ncmd_timer, in handle_cmd_cnt_and_timer()
3762 struct hci_rp_le_read_buffer_size_v2 *rp = data; in hci_cc_le_read_buffer_size_v2() local
3764 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_read_buffer_size_v2()
3766 if (rp->status) in hci_cc_le_read_buffer_size_v2()
3767 return rp->status; in hci_cc_le_read_buffer_size_v2()
3769 hdev->le_mtu = __le16_to_cpu(rp->acl_mtu); in hci_cc_le_read_buffer_size_v2()
3770 hdev->le_pkts = rp->acl_max_pkt; in hci_cc_le_read_buffer_size_v2()
3771 hdev->iso_mtu = __le16_to_cpu(rp->iso_mtu); in hci_cc_le_read_buffer_size_v2()
3772 hdev->iso_pkts = rp->iso_max_pkt; in hci_cc_le_read_buffer_size_v2()
3774 hdev->le_cnt = hdev->le_pkts; in hci_cc_le_read_buffer_size_v2()
3775 hdev->iso_cnt = hdev->iso_pkts; in hci_cc_le_read_buffer_size_v2()
3777 BT_DBG("%s acl mtu %d:%d iso mtu %d:%d", hdev->name, hdev->acl_mtu, in hci_cc_le_read_buffer_size_v2()
3778 hdev->acl_pkts, hdev->iso_mtu, hdev->iso_pkts); in hci_cc_le_read_buffer_size_v2()
3780 if (hdev->le_mtu && hdev->le_mtu < HCI_MIN_LE_MTU) in hci_cc_le_read_buffer_size_v2()
3783 return rp->status; in hci_cc_le_read_buffer_size_v2()
3790 lockdep_assert_held(&hdev->lock); in hci_unbound_cis_failed()
3792 list_for_each_entry_safe(conn, tmp, &hdev->conn_hash.list, list) { in hci_unbound_cis_failed()
3793 if (conn->type != ISO_LINK || !bacmp(&conn->dst, BDADDR_ANY) || in hci_unbound_cis_failed()
3794 conn->state == BT_OPEN || conn->iso_qos.ucast.cig != cig) in hci_unbound_cis_failed()
3797 if (HCI_CONN_HANDLE_UNSET(conn->handle)) in hci_unbound_cis_failed()
3805 struct hci_rp_le_set_cig_params *rp = data; in hci_cc_le_set_cig_params() local
3808 u8 status = rp->status; in hci_cc_le_set_cig_params()
3812 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_cig_params()
3815 if (!rp->status && (!cp || rp->num_handles != cp->num_cis || in hci_cc_le_set_cig_params()
3816 rp->cig_id != cp->cig_id)) { in hci_cc_le_set_cig_params()
3825 * If the Status return parameter is non-zero, then the state of the CIG in hci_cc_le_set_cig_params()
3831 hci_unbound_cis_failed(hdev, rp->cig_id, status); in hci_cc_le_set_cig_params()
3842 for (i = 0; i < rp->num_handles; ++i) { in hci_cc_le_set_cig_params()
3843 conn = hci_conn_hash_lookup_cis(hdev, NULL, 0, rp->cig_id, in hci_cc_le_set_cig_params()
3844 cp->cis[i].cis_id); in hci_cc_le_set_cig_params()
3845 if (!conn || !bacmp(&conn->dst, BDADDR_ANY)) in hci_cc_le_set_cig_params()
3848 if (conn->state != BT_BOUND && conn->state != BT_CONNECT) in hci_cc_le_set_cig_params()
3851 if (hci_conn_set_handle(conn, __le16_to_cpu(rp->handle[i]))) in hci_cc_le_set_cig_params()
3854 if (conn->state == BT_CONNECT) in hci_cc_le_set_cig_params()
3864 return rp->status; in hci_cc_le_set_cig_params()
3870 struct hci_rp_le_setup_iso_path *rp = data; in hci_cc_le_setup_iso_path() local
3874 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_setup_iso_path()
3878 return rp->status; in hci_cc_le_setup_iso_path()
3882 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cc_le_setup_iso_path()
3886 if (rp->status) { in hci_cc_le_setup_iso_path()
3887 hci_connect_cfm(conn, rp->status); in hci_cc_le_setup_iso_path()
3892 switch (cp->direction) { in hci_cc_le_setup_iso_path()
3896 if (conn->iso_qos.ucast.out.sdu && !conn->iso_qos.ucast.in.sdu) in hci_cc_le_setup_iso_path()
3897 hci_connect_cfm(conn, rp->status); in hci_cc_le_setup_iso_path()
3901 /* Confirm connection since conn->iso_qos is always configured in hci_cc_le_setup_iso_path()
3904 hci_connect_cfm(conn, rp->status); in hci_cc_le_setup_iso_path()
3907 if (!rp->status && test_bit(HCI_CONN_BIG_SYNC, &conn->flags)) in hci_cc_le_setup_iso_path()
3915 return rp->status; in hci_cc_le_setup_iso_path()
3920 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_le_create_big()
3926 struct hci_ev_status *rp = data; in hci_cc_set_per_adv_param() local
3929 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_set_per_adv_param()
3931 if (rp->status) in hci_cc_set_per_adv_param()
3932 return rp->status; in hci_cc_set_per_adv_param()
3936 return rp->status; in hci_cc_set_per_adv_param()
3939 return rp->status; in hci_cc_set_per_adv_param()
3945 struct hci_ev_status *rp = data; in hci_cc_le_set_per_adv_enable() local
3950 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_per_adv_enable()
3952 if (rp->status) in hci_cc_le_set_per_adv_enable()
3953 return rp->status; in hci_cc_le_set_per_adv_enable()
3957 return rp->status; in hci_cc_le_set_per_adv_enable()
3961 adv = hci_find_adv_instance(hdev, cp->handle); in hci_cc_le_set_per_adv_enable()
3963 if (cp->enable) { in hci_cc_le_set_per_adv_enable()
3967 adv->enabled = true; in hci_cc_le_set_per_adv_enable()
3974 list_for_each_entry_safe(adv, n, &hdev->adv_instances, in hci_cc_le_set_per_adv_enable()
3976 if (adv->periodic && adv->enabled) in hci_cc_le_set_per_adv_enable()
3989 return rp->status; in hci_cc_le_set_per_adv_enable()
4180 if (skb->len < cc->min_len) { in hci_cc_func()
4181 bt_dev_err(hdev, "unexpected cc 0x%4.4x length: %u < %u", in hci_cc_func()
4182 cc->op, skb->len, cc->min_len); in hci_cc_func()
4190 if (skb->len > cc->max_len) in hci_cc_func()
4191 bt_dev_warn(hdev, "unexpected cc 0x%4.4x length: %u > %u", in hci_cc_func()
4192 cc->op, skb->len, cc->max_len); in hci_cc_func()
4194 data = hci_cc_skb_pull(hdev, skb, cc->op, cc->min_len); in hci_cc_func()
4198 return cc->func(hdev, data, skb); in hci_cc_func()
4209 *opcode = __le16_to_cpu(ev->opcode); in hci_cmd_complete_evt()
4211 bt_dev_dbg(hdev, "opcode 0x%4.4x", *opcode); in hci_cmd_complete_evt()
4228 *status = skb->data[0]; in hci_cmd_complete_evt()
4231 handle_cmd_cnt_and_timer(hdev, ev->ncmd); in hci_cmd_complete_evt()
4238 "unexpected event for opcode 0x%4.4x", *opcode); in hci_cmd_complete_evt()
4242 if (atomic_read(&hdev->cmd_cnt) && !skb_queue_empty(&hdev->cmd_q)) in hci_cmd_complete_evt()
4243 queue_work(hdev->workqueue, &hdev->cmd_work); in hci_cmd_complete_evt()
4252 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_le_create_cis()
4264 for (i = 0; i < cp->num_cis; i++) { in hci_cs_le_create_cis()
4268 handle = __le16_to_cpu(cp->cis[i].cis_handle); in hci_cs_le_create_cis()
4273 &conn->flags)) in hci_cs_le_create_cis()
4275 conn->state = BT_CLOSED; in hci_cs_le_create_cis()
4280 cp->num_cis = 0; in hci_cs_le_create_cis()
4330 *opcode = __le16_to_cpu(ev->opcode); in hci_cmd_status_evt()
4331 *status = ev->status; in hci_cmd_status_evt()
4333 bt_dev_dbg(hdev, "opcode 0x%4.4x", *opcode); in hci_cmd_status_evt()
4337 hci_cs_table[i].func(hdev, ev->status); in hci_cmd_status_evt()
4342 handle_cmd_cnt_and_timer(hdev, ev->ncmd); in hci_cmd_status_evt()
4350 if (ev->status || (hdev->req_skb && !hci_skb_event(hdev->req_skb))) { in hci_cmd_status_evt()
4351 hci_req_cmd_complete(hdev, *opcode, ev->status, req_complete, in hci_cmd_status_evt()
4354 bt_dev_err(hdev, "unexpected event for opcode 0x%4.4x", in hci_cmd_status_evt()
4360 if (atomic_read(&hdev->cmd_cnt) && !skb_queue_empty(&hdev->cmd_q)) in hci_cmd_status_evt()
4361 queue_work(hdev->workqueue, &hdev->cmd_work); in hci_cmd_status_evt()
4369 bt_dev_dbg(hdev, "code 0x%2.2x", ev->code); in hci_hardware_error_evt()
4371 hdev->hw_error_code = ev->code; in hci_hardware_error_evt()
4373 queue_work(hdev->req_workqueue, &hdev->error_reset); in hci_hardware_error_evt()
4382 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_role_change_evt()
4386 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_role_change_evt()
4388 if (!ev->status) in hci_role_change_evt()
4389 conn->role = ev->role; in hci_role_change_evt()
4391 clear_bit(HCI_CONN_RSWITCH_PEND, &conn->flags); in hci_role_change_evt()
4393 hci_role_switch_cfm(conn, ev->status, ev->role); in hci_role_change_evt()
4406 flex_array_size(ev, handles, ev->num))) in hci_num_comp_pkts_evt()
4409 bt_dev_dbg(hdev, "num %d", ev->num); in hci_num_comp_pkts_evt()
4411 for (i = 0; i < ev->num; i++) { in hci_num_comp_pkts_evt()
4412 struct hci_comp_pkts_info *info = &ev->handles[i]; in hci_num_comp_pkts_evt()
4416 handle = __le16_to_cpu(info->handle); in hci_num_comp_pkts_evt()
4417 count = __le16_to_cpu(info->count); in hci_num_comp_pkts_evt()
4423 conn->sent -= count; in hci_num_comp_pkts_evt()
4425 switch (conn->type) { in hci_num_comp_pkts_evt()
4427 hdev->acl_cnt += count; in hci_num_comp_pkts_evt()
4428 if (hdev->acl_cnt > hdev->acl_pkts) in hci_num_comp_pkts_evt()
4429 hdev->acl_cnt = hdev->acl_pkts; in hci_num_comp_pkts_evt()
4433 if (hdev->le_pkts) { in hci_num_comp_pkts_evt()
4434 hdev->le_cnt += count; in hci_num_comp_pkts_evt()
4435 if (hdev->le_cnt > hdev->le_pkts) in hci_num_comp_pkts_evt()
4436 hdev->le_cnt = hdev->le_pkts; in hci_num_comp_pkts_evt()
4438 hdev->acl_cnt += count; in hci_num_comp_pkts_evt()
4439 if (hdev->acl_cnt > hdev->acl_pkts) in hci_num_comp_pkts_evt()
4440 hdev->acl_cnt = hdev->acl_pkts; in hci_num_comp_pkts_evt()
4445 hdev->sco_cnt += count; in hci_num_comp_pkts_evt()
4446 if (hdev->sco_cnt > hdev->sco_pkts) in hci_num_comp_pkts_evt()
4447 hdev->sco_cnt = hdev->sco_pkts; in hci_num_comp_pkts_evt()
4451 if (hdev->iso_pkts) { in hci_num_comp_pkts_evt()
4452 hdev->iso_cnt += count; in hci_num_comp_pkts_evt()
4453 if (hdev->iso_cnt > hdev->iso_pkts) in hci_num_comp_pkts_evt()
4454 hdev->iso_cnt = hdev->iso_pkts; in hci_num_comp_pkts_evt()
4455 } else if (hdev->le_pkts) { in hci_num_comp_pkts_evt()
4456 hdev->le_cnt += count; in hci_num_comp_pkts_evt()
4457 if (hdev->le_cnt > hdev->le_pkts) in hci_num_comp_pkts_evt()
4458 hdev->le_cnt = hdev->le_pkts; in hci_num_comp_pkts_evt()
4460 hdev->acl_cnt += count; in hci_num_comp_pkts_evt()
4461 if (hdev->acl_cnt > hdev->acl_pkts) in hci_num_comp_pkts_evt()
4462 hdev->acl_cnt = hdev->acl_pkts; in hci_num_comp_pkts_evt()
4468 conn->type, conn); in hci_num_comp_pkts_evt()
4473 queue_work(hdev->workqueue, &hdev->tx_work); in hci_num_comp_pkts_evt()
4482 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_mode_change_evt()
4486 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_mode_change_evt()
4488 conn->mode = ev->mode; in hci_mode_change_evt()
4491 &conn->flags)) { in hci_mode_change_evt()
4492 if (conn->mode == HCI_CM_ACTIVE) in hci_mode_change_evt()
4493 set_bit(HCI_CONN_POWER_SAVE, &conn->flags); in hci_mode_change_evt()
4495 clear_bit(HCI_CONN_POWER_SAVE, &conn->flags); in hci_mode_change_evt()
4498 if (test_and_clear_bit(HCI_CONN_SCO_SETUP_PEND, &conn->flags)) in hci_mode_change_evt()
4499 hci_sco_setup(conn, ev->status); in hci_mode_change_evt()
4515 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_pin_code_request_evt()
4519 if (conn->state == BT_CONNECTED) { in hci_pin_code_request_evt()
4521 conn->disc_timeout = HCI_PAIRING_TIMEOUT; in hci_pin_code_request_evt()
4526 !test_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags)) { in hci_pin_code_request_evt()
4528 sizeof(ev->bdaddr), &ev->bdaddr); in hci_pin_code_request_evt()
4532 if (conn->pending_sec_level == BT_SECURITY_HIGH) in hci_pin_code_request_evt()
4537 mgmt_pin_code_request(hdev, &ev->bdaddr, secure); in hci_pin_code_request_evt()
4549 conn->pin_length = pin_len; in conn_set_key()
4550 conn->key_type = key_type; in conn_set_key()
4559 conn->pending_sec_level = BT_SECURITY_HIGH; in conn_set_key()
4561 conn->pending_sec_level = BT_SECURITY_MEDIUM; in conn_set_key()
4565 conn->pending_sec_level = BT_SECURITY_MEDIUM; in conn_set_key()
4568 conn->pending_sec_level = BT_SECURITY_HIGH; in conn_set_key()
4571 conn->pending_sec_level = BT_SECURITY_FIPS; in conn_set_key()
4591 key = hci_find_link_key(hdev, &ev->bdaddr); in hci_link_key_request_evt()
4593 bt_dev_dbg(hdev, "link key not found for %pMR", &ev->bdaddr); in hci_link_key_request_evt()
4597 bt_dev_dbg(hdev, "found key type %u for %pMR", key->type, &ev->bdaddr); in hci_link_key_request_evt()
4599 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_link_key_request_evt()
4601 clear_bit(HCI_CONN_NEW_LINK_KEY, &conn->flags); in hci_link_key_request_evt()
4603 if ((key->type == HCI_LK_UNAUTH_COMBINATION_P192 || in hci_link_key_request_evt()
4604 key->type == HCI_LK_UNAUTH_COMBINATION_P256) && in hci_link_key_request_evt()
4605 conn->auth_type != 0xff && (conn->auth_type & 0x01)) { in hci_link_key_request_evt()
4610 if (key->type == HCI_LK_COMBINATION && key->pin_len < 16 && in hci_link_key_request_evt()
4611 (conn->pending_sec_level == BT_SECURITY_HIGH || in hci_link_key_request_evt()
4612 conn->pending_sec_level == BT_SECURITY_FIPS)) { in hci_link_key_request_evt()
4617 conn_set_key(conn, key->type, key->pin_len); in hci_link_key_request_evt()
4620 bacpy(&cp.bdaddr, &ev->bdaddr); in hci_link_key_request_evt()
4621 memcpy(cp.link_key, key->val, HCI_LINK_KEY_SIZE); in hci_link_key_request_evt()
4630 hci_send_cmd(hdev, HCI_OP_LINK_KEY_NEG_REPLY, 6, &ev->bdaddr); in hci_link_key_request_evt()
4647 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_link_key_notify_evt()
4651 /* Ignore NULL link key against CVE-2020-26555 */ in hci_link_key_notify_evt()
4652 if (!crypto_memneq(ev->link_key, ZERO_KEY, HCI_LINK_KEY_SIZE)) { in hci_link_key_notify_evt()
4654 &ev->bdaddr); in hci_link_key_notify_evt()
4661 conn->disc_timeout = HCI_DISCONN_TIMEOUT; in hci_link_key_notify_evt()
4664 set_bit(HCI_CONN_NEW_LINK_KEY, &conn->flags); in hci_link_key_notify_evt()
4665 conn_set_key(conn, ev->key_type, conn->pin_length); in hci_link_key_notify_evt()
4670 key = hci_add_link_key(hdev, conn, &ev->bdaddr, ev->link_key, in hci_link_key_notify_evt()
4671 ev->key_type, pin_len, &persistent); in hci_link_key_notify_evt()
4678 if (ev->key_type == HCI_LK_CHANGED_COMBINATION) in hci_link_key_notify_evt()
4679 conn_set_key(conn, key->type, key->pin_len); in hci_link_key_notify_evt()
4688 if (key->type == HCI_LK_DEBUG_COMBINATION && in hci_link_key_notify_evt()
4690 list_del_rcu(&key->list); in hci_link_key_notify_evt()
4696 clear_bit(HCI_CONN_FLUSH_KEY, &conn->flags); in hci_link_key_notify_evt()
4698 set_bit(HCI_CONN_FLUSH_KEY, &conn->flags); in hci_link_key_notify_evt()
4710 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_clock_offset_evt()
4714 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_clock_offset_evt()
4715 if (conn && !ev->status) { in hci_clock_offset_evt()
4718 ie = hci_inquiry_cache_lookup(hdev, &conn->dst); in hci_clock_offset_evt()
4720 ie->data.clock_offset = ev->clock_offset; in hci_clock_offset_evt()
4721 ie->timestamp = jiffies; in hci_clock_offset_evt()
4734 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_pkt_type_change_evt()
4738 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_pkt_type_change_evt()
4739 if (conn && !ev->status) in hci_pkt_type_change_evt()
4740 conn->pkt_type = __le16_to_cpu(ev->pkt_type); in hci_pkt_type_change_evt()
4755 ie = hci_inquiry_cache_lookup(hdev, &ev->bdaddr); in hci_pscan_rep_mode_evt()
4757 ie->data.pscan_rep_mode = ev->pscan_rep_mode; in hci_pscan_rep_mode_evt()
4758 ie->timestamp = jiffies; in hci_pscan_rep_mode_evt()
4771 bt_dev_dbg(hdev, "num_rsp %d", ev->num); in hci_inquiry_result_with_rssi_evt()
4773 if (!ev->num) in hci_inquiry_result_with_rssi_evt()
4781 if (skb->len == array_size(ev->num, in hci_inquiry_result_with_rssi_evt()
4785 for (i = 0; i < ev->num; i++) { in hci_inquiry_result_with_rssi_evt()
4792 bt_dev_err(hdev, "Malformed HCI Event: 0x%2.2x", in hci_inquiry_result_with_rssi_evt()
4797 bacpy(&data.bdaddr, &info->bdaddr); in hci_inquiry_result_with_rssi_evt()
4798 data.pscan_rep_mode = info->pscan_rep_mode; in hci_inquiry_result_with_rssi_evt()
4799 data.pscan_period_mode = info->pscan_period_mode; in hci_inquiry_result_with_rssi_evt()
4800 data.pscan_mode = info->pscan_mode; in hci_inquiry_result_with_rssi_evt()
4801 memcpy(data.dev_class, info->dev_class, 3); in hci_inquiry_result_with_rssi_evt()
4802 data.clock_offset = info->clock_offset; in hci_inquiry_result_with_rssi_evt()
4803 data.rssi = info->rssi; in hci_inquiry_result_with_rssi_evt()
4808 mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, in hci_inquiry_result_with_rssi_evt()
4809 info->dev_class, info->rssi, in hci_inquiry_result_with_rssi_evt()
4812 } else if (skb->len == array_size(ev->num, in hci_inquiry_result_with_rssi_evt()
4816 for (i = 0; i < ev->num; i++) { in hci_inquiry_result_with_rssi_evt()
4823 bt_dev_err(hdev, "Malformed HCI Event: 0x%2.2x", in hci_inquiry_result_with_rssi_evt()
4828 bacpy(&data.bdaddr, &info->bdaddr); in hci_inquiry_result_with_rssi_evt()
4829 data.pscan_rep_mode = info->pscan_rep_mode; in hci_inquiry_result_with_rssi_evt()
4830 data.pscan_period_mode = info->pscan_period_mode; in hci_inquiry_result_with_rssi_evt()
4832 memcpy(data.dev_class, info->dev_class, 3); in hci_inquiry_result_with_rssi_evt()
4833 data.clock_offset = info->clock_offset; in hci_inquiry_result_with_rssi_evt()
4834 data.rssi = info->rssi; in hci_inquiry_result_with_rssi_evt()
4839 mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, in hci_inquiry_result_with_rssi_evt()
4840 info->dev_class, info->rssi, in hci_inquiry_result_with_rssi_evt()
4844 bt_dev_err(hdev, "Malformed HCI Event: 0x%2.2x", in hci_inquiry_result_with_rssi_evt()
4857 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_remote_ext_features_evt()
4861 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_remote_ext_features_evt()
4865 if (ev->page < HCI_MAX_PAGES) in hci_remote_ext_features_evt()
4866 memcpy(conn->features[ev->page], ev->features, 8); in hci_remote_ext_features_evt()
4868 if (!ev->status && ev->page == 0x01) { in hci_remote_ext_features_evt()
4871 ie = hci_inquiry_cache_lookup(hdev, &conn->dst); in hci_remote_ext_features_evt()
4873 ie->data.ssp_mode = (ev->features[0] & LMP_HOST_SSP); in hci_remote_ext_features_evt()
4875 if (ev->features[0] & LMP_HOST_SSP) { in hci_remote_ext_features_evt()
4876 set_bit(HCI_CONN_SSP_ENABLED, &conn->flags); in hci_remote_ext_features_evt()
4886 clear_bit(HCI_CONN_SSP_ENABLED, &conn->flags); in hci_remote_ext_features_evt()
4889 if (ev->features[0] & LMP_HOST_SC) in hci_remote_ext_features_evt()
4890 set_bit(HCI_CONN_SC_ENABLED, &conn->flags); in hci_remote_ext_features_evt()
4893 if (conn->state != BT_CONFIG) in hci_remote_ext_features_evt()
4896 if (!ev->status && !test_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) { in hci_remote_ext_features_evt()
4899 bacpy(&cp.bdaddr, &conn->dst); in hci_remote_ext_features_evt()
4907 conn->state = BT_CONNECTED; in hci_remote_ext_features_evt()
4908 hci_connect_cfm(conn, ev->status); in hci_remote_ext_features_evt()
4921 u8 status = ev->status; in hci_sync_conn_complete_evt()
4923 switch (ev->link_type) { in hci_sync_conn_complete_evt()
4936 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_sync_conn_complete_evt()
4940 conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, &ev->bdaddr); in hci_sync_conn_complete_evt()
4942 if (ev->link_type == ESCO_LINK) in hci_sync_conn_complete_evt()
4954 conn = hci_conn_hash_lookup_ba(hdev, ESCO_LINK, &ev->bdaddr); in hci_sync_conn_complete_evt()
4965 if (!HCI_CONN_HANDLE_UNSET(conn->handle)) { in hci_sync_conn_complete_evt()
4972 status = hci_conn_set_handle(conn, __le16_to_cpu(ev->handle)); in hci_sync_conn_complete_evt()
4974 conn->state = BT_CLOSED; in hci_sync_conn_complete_evt()
4978 conn->state = BT_CONNECTED; in hci_sync_conn_complete_evt()
4979 conn->type = ev->link_type; in hci_sync_conn_complete_evt()
4993 if (conn->out) { in hci_sync_conn_complete_evt()
4994 conn->pkt_type = (hdev->esco_type & SCO_ESCO_MASK) | in hci_sync_conn_complete_evt()
4995 (hdev->esco_type & EDR_ESCO_MASK); in hci_sync_conn_complete_evt()
4996 if (hci_setup_sync(conn, conn->parent->handle)) in hci_sync_conn_complete_evt()
5002 conn->state = BT_CLOSED; in hci_sync_conn_complete_evt()
5006 bt_dev_dbg(hdev, "SCO connected with air mode: %02x", ev->air_mode); in hci_sync_conn_complete_evt()
5008 * is zero and non-zero value shall be non-HCI transport data path in hci_sync_conn_complete_evt()
5010 if (conn->codec.data_path == 0 && hdev->notify) { in hci_sync_conn_complete_evt()
5011 switch (ev->air_mode) { in hci_sync_conn_complete_evt()
5013 hdev->notify(hdev, HCI_NOTIFY_ENABLE_SCO_CVSD); in hci_sync_conn_complete_evt()
5016 hdev->notify(hdev, HCI_NOTIFY_ENABLE_SCO_TRANSP); in hci_sync_conn_complete_evt()
5055 flex_array_size(ev, info, ev->num))) in hci_extended_inquiry_result_evt()
5058 bt_dev_dbg(hdev, "num %d", ev->num); in hci_extended_inquiry_result_evt()
5060 if (!ev->num) in hci_extended_inquiry_result_evt()
5068 for (i = 0; i < ev->num; i++) { in hci_extended_inquiry_result_evt()
5069 struct extended_inquiry_info *info = &ev->info[i]; in hci_extended_inquiry_result_evt()
5073 bacpy(&data.bdaddr, &info->bdaddr); in hci_extended_inquiry_result_evt()
5074 data.pscan_rep_mode = info->pscan_rep_mode; in hci_extended_inquiry_result_evt()
5075 data.pscan_period_mode = info->pscan_period_mode; in hci_extended_inquiry_result_evt()
5077 memcpy(data.dev_class, info->dev_class, 3); in hci_extended_inquiry_result_evt()
5078 data.clock_offset = info->clock_offset; in hci_extended_inquiry_result_evt()
5079 data.rssi = info->rssi; in hci_extended_inquiry_result_evt()
5083 name_known = eir_get_data(info->data, in hci_extended_inquiry_result_evt()
5084 sizeof(info->data), in hci_extended_inquiry_result_evt()
5091 eir_len = eir_get_length(info->data, sizeof(info->data)); in hci_extended_inquiry_result_evt()
5093 mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, in hci_extended_inquiry_result_evt()
5094 info->dev_class, info->rssi, in hci_extended_inquiry_result_evt()
5095 flags, info->data, eir_len, NULL, 0, 0); in hci_extended_inquiry_result_evt()
5107 bt_dev_dbg(hdev, "status 0x%2.2x handle 0x%4.4x", ev->status, in hci_key_refresh_complete_evt()
5108 __le16_to_cpu(ev->handle)); in hci_key_refresh_complete_evt()
5112 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_key_refresh_complete_evt()
5119 if (conn->type != LE_LINK) in hci_key_refresh_complete_evt()
5122 if (!ev->status) in hci_key_refresh_complete_evt()
5123 conn->sec_level = conn->pending_sec_level; in hci_key_refresh_complete_evt()
5125 clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags); in hci_key_refresh_complete_evt()
5127 if (ev->status && conn->state == BT_CONNECTED) { in hci_key_refresh_complete_evt()
5133 if (conn->state == BT_CONFIG) { in hci_key_refresh_complete_evt()
5134 if (!ev->status) in hci_key_refresh_complete_evt()
5135 conn->state = BT_CONNECTED; in hci_key_refresh_complete_evt()
5137 hci_connect_cfm(conn, ev->status); in hci_key_refresh_complete_evt()
5140 hci_auth_cfm(conn, ev->status); in hci_key_refresh_complete_evt()
5143 conn->disc_timeout = HCI_DISCONN_TIMEOUT; in hci_key_refresh_complete_evt()
5153 /* If remote requests no-bonding follow that lead */ in hci_get_auth_req()
5154 if (conn->remote_auth == HCI_AT_NO_BONDING || in hci_get_auth_req()
5155 conn->remote_auth == HCI_AT_NO_BONDING_MITM) in hci_get_auth_req()
5156 return conn->remote_auth | (conn->auth_type & 0x01); in hci_get_auth_req()
5161 if (conn->remote_cap != HCI_IO_NO_INPUT_OUTPUT && in hci_get_auth_req()
5162 conn->io_capability != HCI_IO_NO_INPUT_OUTPUT) in hci_get_auth_req()
5163 return conn->remote_auth | 0x01; in hci_get_auth_req()
5166 return (conn->remote_auth & ~0x01) | (conn->auth_type & 0x01); in hci_get_auth_req()
5171 struct hci_dev *hdev = conn->hdev; in bredr_oob_data_present()
5174 data = hci_find_remote_oob_data(hdev, &conn->dst, BDADDR_BREDR); in bredr_oob_data_present()
5186 return data->present; in bredr_oob_data_present()
5189 * the P-256 values are required. If they are not in bredr_oob_data_present()
5193 if (!crypto_memneq(data->rand256, ZERO_KEY, 16) || in bredr_oob_data_present()
5194 !crypto_memneq(data->hash256, ZERO_KEY, 16)) in bredr_oob_data_present()
5202 * P-192 data values are present. in bredr_oob_data_present()
5204 if (!crypto_memneq(data->rand192, ZERO_KEY, 16) || in bredr_oob_data_present()
5205 !crypto_memneq(data->hash192, ZERO_KEY, 16)) in bredr_oob_data_present()
5221 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_io_capa_request_evt()
5226 set_bit(HCI_CONN_SSP_ENABLED, &conn->flags); in hci_io_capa_request_evt()
5237 test_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags) || in hci_io_capa_request_evt()
5238 (conn->remote_auth & ~0x01) == HCI_AT_NO_BONDING) { in hci_io_capa_request_evt()
5241 bacpy(&cp.bdaddr, &ev->bdaddr); in hci_io_capa_request_evt()
5244 cp.capability = (conn->io_capability == 0x04) ? in hci_io_capa_request_evt()
5245 HCI_IO_DISPLAY_YESNO : conn->io_capability; in hci_io_capa_request_evt()
5248 if (conn->remote_auth == 0xff) { in hci_io_capa_request_evt()
5250 * except for the no-bonding case. in hci_io_capa_request_evt()
5252 if (conn->io_capability != HCI_IO_NO_INPUT_OUTPUT && in hci_io_capa_request_evt()
5253 conn->auth_type != HCI_AT_NO_BONDING) in hci_io_capa_request_evt()
5254 conn->auth_type |= 0x01; in hci_io_capa_request_evt()
5256 conn->auth_type = hci_get_auth_req(conn); in hci_io_capa_request_evt()
5259 /* If we're not bondable, force one of the non-bondable in hci_io_capa_request_evt()
5263 conn->auth_type &= HCI_AT_NO_BONDING_MITM; in hci_io_capa_request_evt()
5265 cp.authentication = conn->auth_type; in hci_io_capa_request_evt()
5273 bacpy(&cp.bdaddr, &ev->bdaddr); in hci_io_capa_request_evt()
5294 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_io_capa_reply_evt()
5298 conn->remote_cap = ev->capability; in hci_io_capa_reply_evt()
5299 conn->remote_auth = ev->authentication; in hci_io_capa_reply_evt()
5319 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_user_confirm_request_evt()
5323 loc_mitm = (conn->auth_type & 0x01); in hci_user_confirm_request_evt()
5324 rem_mitm = (conn->remote_auth & 0x01); in hci_user_confirm_request_evt()
5329 * necessarily match conn->auth_type. in hci_user_confirm_request_evt()
5331 if (conn->pending_sec_level > BT_SECURITY_MEDIUM && in hci_user_confirm_request_evt()
5332 conn->remote_cap == HCI_IO_NO_INPUT_OUTPUT) { in hci_user_confirm_request_evt()
5335 sizeof(ev->bdaddr), &ev->bdaddr); in hci_user_confirm_request_evt()
5340 if ((!loc_mitm || conn->remote_cap == HCI_IO_NO_INPUT_OUTPUT) && in hci_user_confirm_request_evt()
5341 (!rem_mitm || conn->io_capability == HCI_IO_NO_INPUT_OUTPUT)) { in hci_user_confirm_request_evt()
5347 if (!test_bit(HCI_CONN_AUTH_PEND, &conn->flags) && in hci_user_confirm_request_evt()
5348 conn->io_capability != HCI_IO_NO_INPUT_OUTPUT) { in hci_user_confirm_request_evt()
5349 bt_dev_dbg(hdev, "Confirming auto-accept as acceptor"); in hci_user_confirm_request_evt()
5358 if (hci_find_link_key(hdev, &ev->bdaddr)) { in hci_user_confirm_request_evt()
5364 BT_DBG("Auto-accept of user confirmation with %ums delay", in hci_user_confirm_request_evt()
5365 hdev->auto_accept_delay); in hci_user_confirm_request_evt()
5367 if (hdev->auto_accept_delay > 0) { in hci_user_confirm_request_evt()
5368 int delay = msecs_to_jiffies(hdev->auto_accept_delay); in hci_user_confirm_request_evt()
5369 queue_delayed_work(conn->hdev->workqueue, in hci_user_confirm_request_evt()
5370 &conn->auto_accept_work, delay); in hci_user_confirm_request_evt()
5375 sizeof(ev->bdaddr), &ev->bdaddr); in hci_user_confirm_request_evt()
5380 mgmt_user_confirm_request(hdev, &ev->bdaddr, ACL_LINK, 0, in hci_user_confirm_request_evt()
5381 le32_to_cpu(ev->passkey), confirm_hint); in hci_user_confirm_request_evt()
5395 mgmt_user_passkey_request(hdev, &ev->bdaddr, ACL_LINK, 0); in hci_user_passkey_request_evt()
5406 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_user_passkey_notify_evt()
5410 conn->passkey_notify = __le32_to_cpu(ev->passkey); in hci_user_passkey_notify_evt()
5411 conn->passkey_entered = 0; in hci_user_passkey_notify_evt()
5414 mgmt_user_passkey_notify(hdev, &conn->dst, conn->type, in hci_user_passkey_notify_evt()
5415 conn->dst_type, conn->passkey_notify, in hci_user_passkey_notify_evt()
5416 conn->passkey_entered); in hci_user_passkey_notify_evt()
5427 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_keypress_notify_evt()
5431 switch (ev->type) { in hci_keypress_notify_evt()
5433 conn->passkey_entered = 0; in hci_keypress_notify_evt()
5437 conn->passkey_entered++; in hci_keypress_notify_evt()
5441 conn->passkey_entered--; in hci_keypress_notify_evt()
5445 conn->passkey_entered = 0; in hci_keypress_notify_evt()
5453 mgmt_user_passkey_notify(hdev, &conn->dst, conn->type, in hci_keypress_notify_evt()
5454 conn->dst_type, conn->passkey_notify, in hci_keypress_notify_evt()
5455 conn->passkey_entered); in hci_keypress_notify_evt()
5468 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_simple_pair_complete_evt()
5473 conn->remote_auth = 0xff; in hci_simple_pair_complete_evt()
5480 if (!test_bit(HCI_CONN_AUTH_PEND, &conn->flags) && ev->status) in hci_simple_pair_complete_evt()
5481 mgmt_auth_failed(conn, ev->status); in hci_simple_pair_complete_evt()
5500 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_remote_host_features_evt()
5502 memcpy(conn->features[1], ev->features, 8); in hci_remote_host_features_evt()
5504 ie = hci_inquiry_cache_lookup(hdev, &ev->bdaddr); in hci_remote_host_features_evt()
5506 ie->data.ssp_mode = (ev->features[0] & LMP_HOST_SSP); in hci_remote_host_features_evt()
5524 data = hci_find_remote_oob_data(hdev, &ev->bdaddr, BDADDR_BREDR); in hci_remote_oob_data_request_evt()
5528 bacpy(&cp.bdaddr, &ev->bdaddr); in hci_remote_oob_data_request_evt()
5537 bacpy(&cp.bdaddr, &ev->bdaddr); in hci_remote_oob_data_request_evt()
5542 memcpy(cp.hash192, data->hash192, sizeof(cp.hash192)); in hci_remote_oob_data_request_evt()
5543 memcpy(cp.rand192, data->rand192, sizeof(cp.rand192)); in hci_remote_oob_data_request_evt()
5545 memcpy(cp.hash256, data->hash256, sizeof(cp.hash256)); in hci_remote_oob_data_request_evt()
5546 memcpy(cp.rand256, data->rand256, sizeof(cp.rand256)); in hci_remote_oob_data_request_evt()
5553 bacpy(&cp.bdaddr, &ev->bdaddr); in hci_remote_oob_data_request_evt()
5554 memcpy(cp.hash, data->hash192, sizeof(cp.hash)); in hci_remote_oob_data_request_evt()
5555 memcpy(cp.rand, data->rand192, sizeof(cp.rand)); in hci_remote_oob_data_request_evt()
5568 if (conn->out) { in le_conn_update_addr()
5569 conn->dst_type = bdaddr_type; in le_conn_update_addr()
5570 conn->resp_addr_type = bdaddr_type; in le_conn_update_addr()
5571 bacpy(&conn->resp_addr, bdaddr); in le_conn_update_addr()
5574 * used instead or hdev->rpa. in le_conn_update_addr()
5577 conn->init_addr_type = ADDR_LE_DEV_RANDOM; in le_conn_update_addr()
5578 bacpy(&conn->init_addr, local_rpa); in le_conn_update_addr()
5579 } else if (hci_dev_test_flag(conn->hdev, HCI_PRIVACY)) { in le_conn_update_addr()
5580 conn->init_addr_type = ADDR_LE_DEV_RANDOM; in le_conn_update_addr()
5581 bacpy(&conn->init_addr, &conn->hdev->rpa); in le_conn_update_addr()
5583 hci_copy_identity_address(conn->hdev, &conn->init_addr, in le_conn_update_addr()
5584 &conn->init_addr_type); in le_conn_update_addr()
5587 conn->resp_addr_type = conn->hdev->adv_addr_type; in le_conn_update_addr()
5589 * used instead or hdev->rpa. in le_conn_update_addr()
5592 conn->resp_addr_type = ADDR_LE_DEV_RANDOM; in le_conn_update_addr()
5593 bacpy(&conn->resp_addr, local_rpa); in le_conn_update_addr()
5594 } else if (conn->hdev->adv_addr_type == ADDR_LE_DEV_RANDOM) { in le_conn_update_addr()
5598 if (!ext_adv_capable(conn->hdev)) in le_conn_update_addr()
5599 bacpy(&conn->resp_addr, in le_conn_update_addr()
5600 &conn->hdev->random_addr); in le_conn_update_addr()
5602 bacpy(&conn->resp_addr, &conn->hdev->bdaddr); in le_conn_update_addr()
5605 conn->init_addr_type = bdaddr_type; in le_conn_update_addr()
5606 bacpy(&conn->init_addr, bdaddr); in le_conn_update_addr()
5613 conn->le_conn_min_interval = conn->hdev->le_conn_min_interval; in le_conn_update_addr()
5614 conn->le_conn_max_interval = conn->hdev->le_conn_max_interval; in le_conn_update_addr()
5650 conn->dst_type = bdaddr_type; in le_conn_complete_evt()
5660 if (conn->out) { in le_conn_complete_evt()
5661 conn->resp_addr_type = bdaddr_type; in le_conn_complete_evt()
5662 bacpy(&conn->resp_addr, bdaddr); in le_conn_complete_evt()
5664 conn->init_addr_type = ADDR_LE_DEV_RANDOM; in le_conn_complete_evt()
5665 bacpy(&conn->init_addr, &hdev->rpa); in le_conn_complete_evt()
5668 &conn->init_addr, in le_conn_complete_evt()
5669 &conn->init_addr_type); in le_conn_complete_evt()
5673 cancel_delayed_work(&conn->le_conn_timeout); in le_conn_complete_evt()
5682 if (!HCI_CONN_HANDLE_UNSET(conn->handle)) { in le_conn_complete_evt()
5698 irk = hci_get_irk(hdev, &conn->dst, conn->dst_type); in le_conn_complete_evt()
5700 bacpy(&conn->dst, &irk->bdaddr); in le_conn_complete_evt()
5701 conn->dst_type = irk->addr_type; in le_conn_complete_evt()
5704 conn->dst_type = ev_bdaddr_type(hdev, conn->dst_type, NULL); in le_conn_complete_evt()
5714 if (test_bit(HCI_CONN_CANCEL, &conn->flags)) { in le_conn_complete_evt()
5719 if (conn->dst_type == ADDR_LE_DEV_PUBLIC) in le_conn_complete_evt()
5725 if (hci_bdaddr_list_lookup(&hdev->reject_list, &conn->dst, addr_type)) { in le_conn_complete_evt()
5732 conn->sec_level = BT_SECURITY_LOW; in le_conn_complete_evt()
5733 conn->state = BT_CONFIG; in le_conn_complete_evt()
5736 * when sotfware rotation is in use so it can be re-enabled when in le_conn_complete_evt()
5740 conn->adv_instance = hdev->cur_adv_instance; in le_conn_complete_evt()
5742 conn->le_conn_interval = interval; in le_conn_complete_evt()
5743 conn->le_conn_latency = latency; in le_conn_complete_evt()
5744 conn->le_supv_timeout = supervision_timeout; in le_conn_complete_evt()
5753 * If the local controller supports peripheral-initiated features in le_conn_complete_evt()
5758 if (conn->out || in le_conn_complete_evt()
5759 (hdev->le_features[0] & HCI_LE_PERIPHERAL_FEATURES)) { in le_conn_complete_evt()
5762 cp.handle = __cpu_to_le16(conn->handle); in le_conn_complete_evt()
5769 conn->state = BT_CONNECTED; in le_conn_complete_evt()
5773 params = hci_pend_le_action_lookup(&hdev->pend_le_conns, &conn->dst, in le_conn_complete_evt()
5774 conn->dst_type); in le_conn_complete_evt()
5777 if (params->conn) { in le_conn_complete_evt()
5778 hci_conn_drop(params->conn); in le_conn_complete_evt()
5779 hci_conn_put(params->conn); in le_conn_complete_evt()
5780 params->conn = NULL; in le_conn_complete_evt()
5794 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_conn_complete_evt()
5796 le_conn_complete_evt(hdev, ev->status, &ev->bdaddr, ev->bdaddr_type, in hci_le_conn_complete_evt()
5797 NULL, ev->role, le16_to_cpu(ev->handle), in hci_le_conn_complete_evt()
5798 le16_to_cpu(ev->interval), in hci_le_conn_complete_evt()
5799 le16_to_cpu(ev->latency), in hci_le_conn_complete_evt()
5800 le16_to_cpu(ev->supervision_timeout)); in hci_le_conn_complete_evt()
5808 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_enh_conn_complete_evt()
5810 le_conn_complete_evt(hdev, ev->status, &ev->bdaddr, ev->bdaddr_type, in hci_le_enh_conn_complete_evt()
5811 &ev->local_rpa, ev->role, le16_to_cpu(ev->handle), in hci_le_enh_conn_complete_evt()
5812 le16_to_cpu(ev->interval), in hci_le_enh_conn_complete_evt()
5813 le16_to_cpu(ev->latency), in hci_le_enh_conn_complete_evt()
5814 le16_to_cpu(ev->supervision_timeout)); in hci_le_enh_conn_complete_evt()
5824 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_ext_adv_term_evt()
5833 if (ev->status == HCI_ERROR_CANCELLED_BY_HOST) { in hci_le_ext_adv_term_evt()
5840 adv = hci_find_adv_instance(hdev, ev->handle); in hci_le_ext_adv_term_evt()
5842 if (ev->status) { in hci_le_ext_adv_term_evt()
5847 hci_remove_adv_instance(hdev, ev->handle); in hci_le_ext_adv_term_evt()
5848 mgmt_advertising_removed(NULL, hdev, ev->handle); in hci_le_ext_adv_term_evt()
5850 list_for_each_entry_safe(adv, n, &hdev->adv_instances, list) { in hci_le_ext_adv_term_evt()
5851 if (adv->enabled) in hci_le_ext_adv_term_evt()
5861 adv->enabled = false; in hci_le_ext_adv_term_evt()
5863 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->conn_handle)); in hci_le_ext_adv_term_evt()
5866 * instance can be re-enabled when disconnected. in hci_le_ext_adv_term_evt()
5868 conn->adv_instance = ev->handle; in hci_le_ext_adv_term_evt()
5870 if (hdev->adv_addr_type != ADDR_LE_DEV_RANDOM || in hci_le_ext_adv_term_evt()
5871 bacmp(&conn->resp_addr, BDADDR_ANY)) in hci_le_ext_adv_term_evt()
5874 if (!ev->handle) { in hci_le_ext_adv_term_evt()
5875 bacpy(&conn->resp_addr, &hdev->random_addr); in hci_le_ext_adv_term_evt()
5880 bacpy(&conn->resp_addr, &adv->random_addr); in hci_le_ext_adv_term_evt()
5893 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_conn_update_complete_evt()
5895 if (ev->status) in hci_le_conn_update_complete_evt()
5900 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_conn_update_complete_evt()
5902 conn->le_conn_interval = le16_to_cpu(ev->interval); in hci_le_conn_update_complete_evt()
5903 conn->le_conn_latency = le16_to_cpu(ev->latency); in hci_le_conn_update_complete_evt()
5904 conn->le_supv_timeout = le16_to_cpu(ev->supervision_timeout); in hci_le_conn_update_complete_evt()
5910 /* This function requires the caller holds hdev->lock */
5924 if (hci_bdaddr_list_lookup(&hdev->reject_list, addr, addr_type) || in check_pending_le_conn()
5925 hdev->suspended) in check_pending_le_conn()
5931 if (hdev->conn_hash.le_num_peripheral > 0 && in check_pending_le_conn()
5932 (test_bit(HCI_QUIRK_BROKEN_LE_STATES, &hdev->quirks) || in check_pending_le_conn()
5933 !(hdev->le_states[3] & 0x10))) in check_pending_le_conn()
5939 params = hci_pend_le_action_lookup(&hdev->pend_le_conns, addr, in check_pending_le_conn()
5944 if (!params->explicit_connect) { in check_pending_le_conn()
5945 switch (params->auto_connect) { in check_pending_le_conn()
5968 BT_SECURITY_LOW, hdev->def_le_autoconnect_timeout, in check_pending_le_conn()
5980 if (!params->explicit_connect) in check_pending_le_conn()
5981 params->conn = hci_conn_get(conn); in check_pending_le_conn()
5987 case -EBUSY: in check_pending_le_conn()
5988 /* If hci_connect() returns -EBUSY it means there is already in check_pending_le_conn()
6008 struct discovery_state *d = &hdev->discovery; in process_adv_report()
6024 "type: 0x%02x", type); in process_adv_report()
6048 len = ptr - data; in process_adv_report()
6075 if (!smp_irk_matches(hdev, hdev->irk, direct_addr)) in process_adv_report()
6082 bdaddr = &irk->bdaddr; in process_adv_report()
6083 bdaddr_type = irk->addr_type; in process_adv_report()
6100 memcpy(conn->le_adv_data, data, len); in process_adv_report()
6101 conn->le_adv_data_len = len; in process_adv_report()
6120 if (hdev->le_scan_type == LE_SCAN_PASSIVE) { in process_adv_report()
6124 if (!hci_pend_le_action_lookup(&hdev->pend_le_reports, in process_adv_report()
6126 idr_is_empty(&hdev->adv_monitors_idr)) in process_adv_report()
6167 match = (!bacmp(bdaddr, &d->last_adv_addr) && in process_adv_report()
6168 bdaddr_type == d->last_adv_addr_type); in process_adv_report()
6177 mgmt_device_found(hdev, &d->last_adv_addr, LE_LINK, in process_adv_report()
6178 d->last_adv_addr_type, NULL, in process_adv_report()
6179 d->last_adv_rssi, d->last_adv_flags, in process_adv_report()
6180 d->last_adv_data, in process_adv_report()
6181 d->last_adv_data_len, NULL, 0, 0); in process_adv_report()
6206 mgmt_device_found(hdev, &d->last_adv_addr, LE_LINK, in process_adv_report()
6207 d->last_adv_addr_type, NULL, rssi, d->last_adv_flags, in process_adv_report()
6208 d->last_adv_data, d->last_adv_data_len, data, len, 0); in process_adv_report()
6218 if (!ev->num) in hci_le_adv_report_evt()
6223 while (ev->num--) { in hci_le_adv_report_evt()
6234 info->length + 1)) in hci_le_adv_report_evt()
6237 if (info->length <= max_adv_len(hdev)) { in hci_le_adv_report_evt()
6238 rssi = info->data[info->length]; in hci_le_adv_report_evt()
6239 process_adv_report(hdev, info->type, &info->bdaddr, in hci_le_adv_report_evt()
6240 info->bdaddr_type, NULL, 0, in hci_le_adv_report_evt()
6242 info->data, info->length, false, in hci_le_adv_report_evt()
6290 bt_dev_err_ratelimited(hdev, "Unknown advertising packet type: 0x%02x", in ext_evt_type_to_legacy()
6302 if (!ev->num) in hci_le_ext_adv_report_evt()
6307 while (ev->num--) { in hci_le_ext_adv_report_evt()
6318 info->length)) in hci_le_ext_adv_report_evt()
6321 evt_type = __le16_to_cpu(info->type) & LE_EXT_ADV_EVT_TYPE_MASK; in hci_le_ext_adv_report_evt()
6325 &hdev->quirks)) { in hci_le_ext_adv_report_evt()
6326 info->primary_phy &= 0x1f; in hci_le_ext_adv_report_evt()
6327 info->secondary_phy &= 0x1f; in hci_le_ext_adv_report_evt()
6331 process_adv_report(hdev, legacy_evt_type, &info->bdaddr, in hci_le_ext_adv_report_evt()
6332 info->bdaddr_type, NULL, 0, in hci_le_ext_adv_report_evt()
6333 info->primary_phy, in hci_le_ext_adv_report_evt()
6334 info->secondary_phy, in hci_le_ext_adv_report_evt()
6335 info->rssi, info->data, info->length, in hci_le_ext_adv_report_evt()
6358 int mask = hdev->link_mode; in hci_le_pa_sync_estabilished_evt()
6362 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_pa_sync_estabilished_evt()
6368 conn = hci_conn_hash_lookup_sid(hdev, ev->sid, &ev->bdaddr, in hci_le_pa_sync_estabilished_evt()
6369 ev->bdaddr_type); in hci_le_pa_sync_estabilished_evt()
6372 "Unable to find connection for dst %pMR sid 0x%2.2x", in hci_le_pa_sync_estabilished_evt()
6373 &ev->bdaddr, ev->sid); in hci_le_pa_sync_estabilished_evt()
6377 clear_bit(HCI_CONN_CREATE_PA_SYNC, &conn->flags); in hci_le_pa_sync_estabilished_evt()
6379 conn->sync_handle = le16_to_cpu(ev->handle); in hci_le_pa_sync_estabilished_evt()
6380 conn->sid = HCI_SID_INVALID; in hci_le_pa_sync_estabilished_evt()
6382 mask |= hci_proto_connect_ind(hdev, &ev->bdaddr, ISO_LINK, &flags); in hci_le_pa_sync_estabilished_evt()
6384 hci_le_pa_term_sync(hdev, ev->handle); in hci_le_pa_sync_estabilished_evt()
6398 pa_sync->sync_handle = le16_to_cpu(ev->handle); in hci_le_pa_sync_estabilished_evt()
6400 if (ev->status) { in hci_le_pa_sync_estabilished_evt()
6401 set_bit(HCI_CONN_PA_SYNC_FAILED, &pa_sync->flags); in hci_le_pa_sync_estabilished_evt()
6404 hci_connect_cfm(pa_sync, ev->status); in hci_le_pa_sync_estabilished_evt()
6418 int mask = hdev->link_mode; in hci_le_per_adv_report_evt()
6422 bt_dev_dbg(hdev, "sync_handle 0x%4.4x", le16_to_cpu(ev->sync_handle)); in hci_le_per_adv_report_evt()
6435 le16_to_cpu(ev->sync_handle)); in hci_le_per_adv_report_evt()
6440 if (ev->data_status == LE_PA_DATA_COMPLETE && in hci_le_per_adv_report_evt()
6441 !test_and_set_bit(HCI_CONN_PA_SYNC, &pa_sync->flags)) { in hci_le_per_adv_report_evt()
6459 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_remote_feat_complete_evt()
6463 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_remote_feat_complete_evt()
6465 if (!ev->status) in hci_le_remote_feat_complete_evt()
6466 memcpy(conn->features[0], ev->features, 8); in hci_le_remote_feat_complete_evt()
6468 if (conn->state == BT_CONFIG) { in hci_le_remote_feat_complete_evt()
6471 /* If the local controller supports peripheral-initiated in hci_le_remote_feat_complete_evt()
6480 if (!conn->out && ev->status == HCI_ERROR_UNSUPPORTED_REMOTE_FEATURE && in hci_le_remote_feat_complete_evt()
6481 (hdev->le_features[0] & HCI_LE_PERIPHERAL_FEATURES)) in hci_le_remote_feat_complete_evt()
6484 status = ev->status; in hci_le_remote_feat_complete_evt()
6486 conn->state = BT_CONNECTED; in hci_le_remote_feat_complete_evt()
6504 bt_dev_dbg(hdev, "handle 0x%4.4x", __le16_to_cpu(ev->handle)); in hci_le_ltk_request_evt()
6508 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_ltk_request_evt()
6512 ltk = hci_find_ltk(hdev, &conn->dst, conn->dst_type, conn->role); in hci_le_ltk_request_evt()
6518 if (ev->ediv || ev->rand) in hci_le_ltk_request_evt()
6521 /* For non-SC keys check that EDiv and Rand match */ in hci_le_ltk_request_evt()
6522 if (ev->ediv != ltk->ediv || ev->rand != ltk->rand) in hci_le_ltk_request_evt()
6526 memcpy(cp.ltk, ltk->val, ltk->enc_size); in hci_le_ltk_request_evt()
6527 memset(cp.ltk + ltk->enc_size, 0, sizeof(cp.ltk) - ltk->enc_size); in hci_le_ltk_request_evt()
6528 cp.handle = cpu_to_le16(conn->handle); in hci_le_ltk_request_evt()
6530 conn->pending_sec_level = smp_ltk_sec_level(ltk); in hci_le_ltk_request_evt()
6532 conn->enc_key_size = ltk->enc_size; in hci_le_ltk_request_evt()
6539 * distribute the keys. Later, security can be re-established in hci_le_ltk_request_evt()
6542 if (ltk->type == SMP_STK) { in hci_le_ltk_request_evt()
6543 set_bit(HCI_CONN_STK_ENCRYPT, &conn->flags); in hci_le_ltk_request_evt()
6544 list_del_rcu(<k->list); in hci_le_ltk_request_evt()
6547 clear_bit(HCI_CONN_STK_ENCRYPT, &conn->flags); in hci_le_ltk_request_evt()
6555 neg.handle = ev->handle; in hci_le_ltk_request_evt()
6580 bt_dev_dbg(hdev, "handle 0x%4.4x", __le16_to_cpu(ev->handle)); in hci_le_remote_conn_param_req_evt()
6582 handle = le16_to_cpu(ev->handle); in hci_le_remote_conn_param_req_evt()
6583 min = le16_to_cpu(ev->interval_min); in hci_le_remote_conn_param_req_evt()
6584 max = le16_to_cpu(ev->interval_max); in hci_le_remote_conn_param_req_evt()
6585 latency = le16_to_cpu(ev->latency); in hci_le_remote_conn_param_req_evt()
6586 timeout = le16_to_cpu(ev->timeout); in hci_le_remote_conn_param_req_evt()
6589 if (!hcon || hcon->state != BT_CONNECTED) in hci_le_remote_conn_param_req_evt()
6593 if (max > hcon->le_conn_max_interval) in hci_le_remote_conn_param_req_evt()
6601 if (hcon->role == HCI_ROLE_MASTER) { in hci_le_remote_conn_param_req_evt()
6607 params = hci_conn_params_lookup(hdev, &hcon->dst, in hci_le_remote_conn_param_req_evt()
6608 hcon->dst_type); in hci_le_remote_conn_param_req_evt()
6610 params->conn_min_interval = min; in hci_le_remote_conn_param_req_evt()
6611 params->conn_max_interval = max; in hci_le_remote_conn_param_req_evt()
6612 params->conn_latency = latency; in hci_le_remote_conn_param_req_evt()
6613 params->supervision_timeout = timeout; in hci_le_remote_conn_param_req_evt()
6621 mgmt_new_conn_param(hdev, &hcon->dst, hcon->dst_type, in hci_le_remote_conn_param_req_evt()
6625 cp.handle = ev->handle; in hci_le_remote_conn_param_req_evt()
6626 cp.interval_min = ev->interval_min; in hci_le_remote_conn_param_req_evt()
6627 cp.interval_max = ev->interval_max; in hci_le_remote_conn_param_req_evt()
6628 cp.latency = ev->latency; in hci_le_remote_conn_param_req_evt()
6629 cp.timeout = ev->timeout; in hci_le_remote_conn_param_req_evt()
6644 flex_array_size(ev, info, ev->num))) in hci_le_direct_adv_report_evt()
6647 if (!ev->num) in hci_le_direct_adv_report_evt()
6652 for (i = 0; i < ev->num; i++) { in hci_le_direct_adv_report_evt()
6653 struct hci_ev_le_direct_adv_info *info = &ev->info[i]; in hci_le_direct_adv_report_evt()
6655 process_adv_report(hdev, info->type, &info->bdaddr, in hci_le_direct_adv_report_evt()
6656 info->bdaddr_type, &info->direct_addr, in hci_le_direct_adv_report_evt()
6657 info->direct_addr_type, HCI_ADV_PHY_1M, 0, in hci_le_direct_adv_report_evt()
6658 info->rssi, NULL, 0, false, false, instant); in hci_le_direct_adv_report_evt()
6670 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_phy_update_evt()
6672 if (ev->status) in hci_le_phy_update_evt()
6677 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_phy_update_evt()
6681 conn->le_tx_phy = ev->tx_phy; in hci_le_phy_update_evt()
6682 conn->le_rx_phy = ev->rx_phy; in hci_le_phy_update_evt()
6695 u16 handle = __le16_to_cpu(ev->handle); in hci_le_cis_estabilished_evt()
6698 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_cis_estabilished_evt()
6705 "Unable to find connection with handle 0x%4.4x", in hci_le_cis_estabilished_evt()
6710 if (conn->type != ISO_LINK) { in hci_le_cis_estabilished_evt()
6712 "Invalid connection link type handle 0x%4.4x", in hci_le_cis_estabilished_evt()
6717 qos = &conn->iso_qos; in hci_le_cis_estabilished_evt()
6719 pending = test_and_clear_bit(HCI_CONN_CREATE_CIS, &conn->flags); in hci_le_cis_estabilished_evt()
6726 * SDU_Interval = (CIG_Sync_Delay + (FT) x ISO_Interval) - in hci_le_cis_estabilished_evt()
6729 c_sdu_interval = (get_unaligned_le24(ev->cig_sync_delay) + in hci_le_cis_estabilished_evt()
6730 (ev->c_ft * le16_to_cpu(ev->interval) * 1250)) - in hci_le_cis_estabilished_evt()
6731 get_unaligned_le24(ev->c_latency); in hci_le_cis_estabilished_evt()
6732 p_sdu_interval = (get_unaligned_le24(ev->cig_sync_delay) + in hci_le_cis_estabilished_evt()
6733 (ev->p_ft * le16_to_cpu(ev->interval) * 1250)) - in hci_le_cis_estabilished_evt()
6734 get_unaligned_le24(ev->p_latency); in hci_le_cis_estabilished_evt()
6736 switch (conn->role) { in hci_le_cis_estabilished_evt()
6738 qos->ucast.in.interval = c_sdu_interval; in hci_le_cis_estabilished_evt()
6739 qos->ucast.out.interval = p_sdu_interval; in hci_le_cis_estabilished_evt()
6741 qos->ucast.in.latency = in hci_le_cis_estabilished_evt()
6742 DIV_ROUND_CLOSEST(get_unaligned_le24(ev->c_latency), in hci_le_cis_estabilished_evt()
6744 qos->ucast.out.latency = in hci_le_cis_estabilished_evt()
6745 DIV_ROUND_CLOSEST(get_unaligned_le24(ev->p_latency), in hci_le_cis_estabilished_evt()
6747 qos->ucast.in.sdu = le16_to_cpu(ev->c_mtu); in hci_le_cis_estabilished_evt()
6748 qos->ucast.out.sdu = le16_to_cpu(ev->p_mtu); in hci_le_cis_estabilished_evt()
6749 qos->ucast.in.phy = ev->c_phy; in hci_le_cis_estabilished_evt()
6750 qos->ucast.out.phy = ev->p_phy; in hci_le_cis_estabilished_evt()
6753 qos->ucast.in.interval = p_sdu_interval; in hci_le_cis_estabilished_evt()
6754 qos->ucast.out.interval = c_sdu_interval; in hci_le_cis_estabilished_evt()
6756 qos->ucast.out.latency = in hci_le_cis_estabilished_evt()
6757 DIV_ROUND_CLOSEST(get_unaligned_le24(ev->c_latency), in hci_le_cis_estabilished_evt()
6759 qos->ucast.in.latency = in hci_le_cis_estabilished_evt()
6760 DIV_ROUND_CLOSEST(get_unaligned_le24(ev->p_latency), in hci_le_cis_estabilished_evt()
6762 qos->ucast.out.sdu = le16_to_cpu(ev->c_mtu); in hci_le_cis_estabilished_evt()
6763 qos->ucast.in.sdu = le16_to_cpu(ev->p_mtu); in hci_le_cis_estabilished_evt()
6764 qos->ucast.out.phy = ev->c_phy; in hci_le_cis_estabilished_evt()
6765 qos->ucast.in.phy = ev->p_phy; in hci_le_cis_estabilished_evt()
6769 if (!ev->status) { in hci_le_cis_estabilished_evt()
6770 conn->state = BT_CONNECTED; in hci_le_cis_estabilished_evt()
6777 conn->state = BT_CLOSED; in hci_le_cis_estabilished_evt()
6778 hci_connect_cfm(conn, ev->status); in hci_le_cis_estabilished_evt()
6816 acl_handle = __le16_to_cpu(ev->acl_handle); in hci_le_cis_req_evt()
6817 cis_handle = __le16_to_cpu(ev->cis_handle); in hci_le_cis_req_evt()
6819 bt_dev_dbg(hdev, "acl 0x%4.4x handle 0x%4.4x cig 0x%2.2x cis 0x%2.2x", in hci_le_cis_req_evt()
6820 acl_handle, cis_handle, ev->cig_id, ev->cis_id); in hci_le_cis_req_evt()
6828 mask = hci_proto_connect_ind(hdev, &acl->dst, ISO_LINK, &flags); in hci_le_cis_req_evt()
6830 hci_le_reject_cis(hdev, ev->cis_handle); in hci_le_cis_req_evt()
6836 cis = hci_conn_add(hdev, ISO_LINK, &acl->dst, HCI_ROLE_SLAVE, in hci_le_cis_req_evt()
6839 hci_le_reject_cis(hdev, ev->cis_handle); in hci_le_cis_req_evt()
6844 cis->iso_qos.ucast.cig = ev->cig_id; in hci_le_cis_req_evt()
6845 cis->iso_qos.ucast.cis = ev->cis_id; in hci_le_cis_req_evt()
6848 hci_le_accept_cis(hdev, ev->cis_handle); in hci_le_cis_req_evt()
6850 cis->state = BT_CONNECT2; in hci_le_cis_req_evt()
6873 BT_DBG("%s status 0x%2.2x", hdev->name, ev->status); in hci_le_create_big_complete_evt()
6876 flex_array_size(ev, bis_handle, ev->num_bis))) in hci_le_create_big_complete_evt()
6882 while ((conn = hci_conn_hash_lookup_big_state(hdev, ev->handle, in hci_le_create_big_complete_evt()
6884 if (ev->status) { in hci_le_create_big_complete_evt()
6885 hci_connect_cfm(conn, ev->status); in hci_le_create_big_complete_evt()
6891 __le16_to_cpu(ev->bis_handle[i++]))) in hci_le_create_big_complete_evt()
6894 conn->state = BT_CONNECTED; in hci_le_create_big_complete_evt()
6895 set_bit(HCI_CONN_BIG_CREATED, &conn->flags); in hci_le_create_big_complete_evt()
6901 if (!ev->status && !i) in hci_le_create_big_complete_evt()
6908 UINT_PTR(ev->handle), NULL); in hci_le_create_big_complete_evt()
6920 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_big_sync_established_evt()
6923 flex_array_size(ev, bis, ev->num_bis))) in hci_le_big_sync_established_evt()
6928 conn = hci_conn_hash_lookup_big_sync_pend(hdev, ev->handle, in hci_le_big_sync_established_evt()
6929 ev->num_bis); in hci_le_big_sync_established_evt()
6932 "Unable to find connection for big 0x%2.2x", in hci_le_big_sync_established_evt()
6933 ev->handle); in hci_le_big_sync_established_evt()
6937 clear_bit(HCI_CONN_CREATE_BIG_SYNC, &conn->flags); in hci_le_big_sync_established_evt()
6939 conn->num_bis = 0; in hci_le_big_sync_established_evt()
6940 memset(conn->bis, 0, sizeof(conn->num_bis)); in hci_le_big_sync_established_evt()
6942 for (i = 0; i < ev->num_bis; i++) { in hci_le_big_sync_established_evt()
6943 u16 handle = le16_to_cpu(ev->bis[i]); in hci_le_big_sync_established_evt()
6958 if (ev->status != 0x42) in hci_le_big_sync_established_evt()
6960 set_bit(HCI_CONN_PA_SYNC, &bis->flags); in hci_le_big_sync_established_evt()
6962 bis->sync_handle = conn->sync_handle; in hci_le_big_sync_established_evt()
6963 bis->iso_qos.bcast.big = ev->handle; in hci_le_big_sync_established_evt()
6965 memcpy(&interval, ev->latency, sizeof(ev->latency)); in hci_le_big_sync_established_evt()
6966 bis->iso_qos.bcast.in.interval = le32_to_cpu(interval); in hci_le_big_sync_established_evt()
6968 bis->iso_qos.bcast.in.latency = le16_to_cpu(ev->interval) * 125 / 100; in hci_le_big_sync_established_evt()
6969 bis->iso_qos.bcast.in.sdu = le16_to_cpu(ev->max_pdu); in hci_le_big_sync_established_evt()
6971 if (!ev->status) { in hci_le_big_sync_established_evt()
6972 set_bit(HCI_CONN_BIG_SYNC, &bis->flags); in hci_le_big_sync_established_evt()
6980 if (ev->status) in hci_le_big_sync_established_evt()
6981 for (i = 0; i < ev->num_bis; i++) { in hci_le_big_sync_established_evt()
6982 u16 handle = le16_to_cpu(ev->bis[i]); in hci_le_big_sync_established_evt()
6988 set_bit(HCI_CONN_BIG_SYNC_FAILED, &bis->flags); in hci_le_big_sync_established_evt()
6989 hci_connect_cfm(bis, ev->status); in hci_le_big_sync_established_evt()
7003 int mask = hdev->link_mode; in hci_le_big_info_adv_report_evt()
7007 bt_dev_dbg(hdev, "sync_handle 0x%4.4x", le16_to_cpu(ev->sync_handle)); in hci_le_big_info_adv_report_evt()
7020 le16_to_cpu(ev->sync_handle)); in hci_le_big_info_adv_report_evt()
7025 pa_sync->iso_qos.bcast.encryption = ev->encryption; in hci_le_big_info_adv_report_evt()
7137 bt_dev_dbg(hdev, "subevent 0x%2.2x", ev->subevent); in hci_le_meta_evt()
7140 if (hdev->req_skb && in hci_le_meta_evt()
7141 hci_opcode_ogf(hci_skb_opcode(hdev->req_skb)) == 0x08 && in hci_le_meta_evt()
7142 hci_skb_event(hdev->req_skb) == ev->subevent) { in hci_le_meta_evt()
7143 *opcode = hci_skb_opcode(hdev->req_skb); in hci_le_meta_evt()
7148 subev = &hci_le_ev_table[ev->subevent]; in hci_le_meta_evt()
7149 if (!subev->func) in hci_le_meta_evt()
7152 if (skb->len < subev->min_len) { in hci_le_meta_evt()
7153 bt_dev_err(hdev, "unexpected subevent 0x%2.2x length: %u < %u", in hci_le_meta_evt()
7154 ev->subevent, skb->len, subev->min_len); in hci_le_meta_evt()
7162 if (skb->len > subev->max_len) in hci_le_meta_evt()
7163 bt_dev_warn(hdev, "unexpected subevent 0x%2.2x length: %u > %u", in hci_le_meta_evt()
7164 ev->subevent, skb->len, subev->max_len); in hci_le_meta_evt()
7165 data = hci_le_ev_skb_pull(hdev, skb, ev->subevent, subev->min_len); in hci_le_meta_evt()
7169 subev->func(hdev, data, skb); in hci_le_meta_evt()
7186 if (hdr->evt != event) in hci_get_cmd_complete()
7191 /* Check if request ended in Command Status - no way to retrieve in hci_get_cmd_complete()
7194 if (hdr->evt == HCI_EV_CMD_STATUS) in hci_get_cmd_complete()
7197 if (hdr->evt != HCI_EV_CMD_COMPLETE) { in hci_get_cmd_complete()
7198 bt_dev_err(hdev, "last event is not cmd complete (0x%2.2x)", in hci_get_cmd_complete()
7199 hdr->evt); in hci_get_cmd_complete()
7207 if (opcode != __le16_to_cpu(ev->opcode)) { in hci_get_cmd_complete()
7208 BT_DBG("opcode doesn't match (0x%2.2x != 0x%2.2x)", opcode, in hci_get_cmd_complete()
7209 __le16_to_cpu(ev->opcode)); in hci_get_cmd_complete()
7222 const struct hci_ev_conn_complete *conn_complete = (void *)skb->data; in hci_store_wake_reason()
7223 const struct hci_ev_conn_request *conn_request = (void *)skb->data; in hci_store_wake_reason()
7230 if (!hdev->suspended || hdev->wake_reason) in hci_store_wake_reason()
7236 hdev->wake_reason = MGMT_WAKE_REASON_REMOTE_WAKE; in hci_store_wake_reason()
7243 bacpy(&hdev->wake_addr, &conn_request->bdaddr); in hci_store_wake_reason()
7244 hdev->wake_addr_type = BDADDR_BREDR; in hci_store_wake_reason()
7246 bacpy(&hdev->wake_addr, &conn_complete->bdaddr); in hci_store_wake_reason()
7247 hdev->wake_addr_type = BDADDR_BREDR; in hci_store_wake_reason()
7249 struct hci_ev_le_meta *le_ev = (void *)skb->data; in hci_store_wake_reason()
7250 u8 subevent = le_ev->subevent; in hci_store_wake_reason()
7251 u8 *ptr = &skb->data[sizeof(*le_ev)]; in hci_store_wake_reason()
7264 bacpy(&hdev->wake_addr, &adv->bdaddr); in hci_store_wake_reason()
7265 hdev->wake_addr_type = adv->bdaddr_type; in hci_store_wake_reason()
7268 bacpy(&hdev->wake_addr, &direct_adv->bdaddr); in hci_store_wake_reason()
7269 hdev->wake_addr_type = direct_adv->bdaddr_type; in hci_store_wake_reason()
7272 bacpy(&hdev->wake_addr, &ext_adv->bdaddr); in hci_store_wake_reason()
7273 hdev->wake_addr_type = ext_adv->bdaddr_type; in hci_store_wake_reason()
7278 hdev->wake_reason = MGMT_WAKE_REASON_UNEXPECTED; in hci_store_wake_reason()
7454 if (!ev->func) in hci_event_func()
7457 if (skb->len < ev->min_len) { in hci_event_func()
7458 bt_dev_err(hdev, "unexpected event 0x%2.2x length: %u < %u", in hci_event_func()
7459 event, skb->len, ev->min_len); in hci_event_func()
7467 if (skb->len > ev->max_len) in hci_event_func()
7469 "unexpected event 0x%2.2x length: %u > %u", in hci_event_func()
7470 event, skb->len, ev->max_len); in hci_event_func()
7472 data = hci_ev_skb_pull(hdev, skb, event, ev->min_len); in hci_event_func()
7476 if (ev->req) in hci_event_func()
7477 ev->func_req(hdev, data, skb, opcode, status, req_complete, in hci_event_func()
7480 ev->func(hdev, data, skb); in hci_event_func()
7485 struct hci_event_hdr *hdr = (void *) skb->data; in hci_event_packet()
7492 if (skb->len < sizeof(*hdr)) { in hci_event_packet()
7497 kfree_skb(hdev->recv_event); in hci_event_packet()
7498 hdev->recv_event = skb_clone(skb, GFP_KERNEL); in hci_event_packet()
7500 event = hdr->evt; in hci_event_packet()
7502 bt_dev_warn(hdev, "Received unexpected HCI Event 0x%2.2x", in hci_event_packet()
7508 if (hdev->req_skb && in hci_event_packet()
7509 hci_opcode_ogf(hci_skb_opcode(hdev->req_skb)) != 0x08 && in hci_event_packet()
7510 hci_skb_event(hdev->req_skb) == event) { in hci_event_packet()
7511 hci_req_cmd_complete(hdev, hci_skb_opcode(hdev->req_skb), in hci_event_packet()
7530 bt_dev_dbg(hdev, "event 0x%2.2x", event); in hci_event_packet()
7548 hdev->stat.evt_rx++; in hci_event_packet()