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

2    BlueZ - Bluetooth protocol stack for Linux
3 Copyright (c) 2000-2001, 2010, Code Aurora Forum. All rights reserved.
59 bt_dev_err(hdev, "Malformed Event: 0x%2.2x", ev); in hci_ev_skb_pull()
71 bt_dev_err(hdev, "Malformed Command Complete: 0x%4.4x", op); in hci_cc_skb_pull()
83 bt_dev_err(hdev, "Malformed LE Event: 0x%2.2x", ev); in hci_le_ev_skb_pull()
91 struct hci_ev_status *rp = data; in hci_cc_inquiry_cancel() local
93 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_inquiry_cancel()
102 if (rp->status == 0x0c && !test_bit(HCI_INQUIRY, &hdev->flags)) { in hci_cc_inquiry_cancel()
104 rp->status = 0x00; in hci_cc_inquiry_cancel()
107 if (rp->status) in hci_cc_inquiry_cancel()
108 return rp->status; in hci_cc_inquiry_cancel()
110 clear_bit(HCI_INQUIRY, &hdev->flags); in hci_cc_inquiry_cancel()
112 wake_up_bit(&hdev->flags, HCI_INQUIRY); in hci_cc_inquiry_cancel()
119 hdev->le_scan_type != LE_SCAN_ACTIVE) in hci_cc_inquiry_cancel()
125 return rp->status; in hci_cc_inquiry_cancel()
131 struct hci_ev_status *rp = data; in hci_cc_periodic_inq() local
133 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_periodic_inq()
135 if (rp->status) in hci_cc_periodic_inq()
136 return rp->status; in hci_cc_periodic_inq()
140 return rp->status; in hci_cc_periodic_inq()
146 struct hci_ev_status *rp = data; in hci_cc_exit_periodic_inq() local
148 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_exit_periodic_inq()
150 if (rp->status) in hci_cc_exit_periodic_inq()
151 return rp->status; in hci_cc_exit_periodic_inq()
157 return rp->status; in hci_cc_exit_periodic_inq()
163 struct hci_ev_status *rp = data; in hci_cc_remote_name_req_cancel() local
165 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_remote_name_req_cancel()
167 return rp->status; in hci_cc_remote_name_req_cancel()
173 struct hci_rp_role_discovery *rp = data; in hci_cc_role_discovery() local
176 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_role_discovery()
178 if (rp->status) in hci_cc_role_discovery()
179 return rp->status; in hci_cc_role_discovery()
183 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_role_discovery()
185 conn->role = rp->role; in hci_cc_role_discovery()
189 return rp->status; in hci_cc_role_discovery()
195 struct hci_rp_read_link_policy *rp = data; in hci_cc_read_link_policy() local
198 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_link_policy()
200 if (rp->status) in hci_cc_read_link_policy()
201 return rp->status; in hci_cc_read_link_policy()
205 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_link_policy()
207 conn->link_policy = __le16_to_cpu(rp->policy); in hci_cc_read_link_policy()
211 return rp->status; in hci_cc_read_link_policy()
217 struct hci_rp_write_link_policy *rp = data; in hci_cc_write_link_policy() local
221 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_link_policy()
223 if (rp->status) in hci_cc_write_link_policy()
224 return rp->status; in hci_cc_write_link_policy()
228 return rp->status; in hci_cc_write_link_policy()
232 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_write_link_policy()
234 conn->link_policy = get_unaligned_le16(sent + 2); in hci_cc_write_link_policy()
238 return rp->status; in hci_cc_write_link_policy()
244 struct hci_rp_read_def_link_policy *rp = data; in hci_cc_read_def_link_policy() local
246 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_def_link_policy()
248 if (rp->status) in hci_cc_read_def_link_policy()
249 return rp->status; in hci_cc_read_def_link_policy()
251 hdev->link_policy = __le16_to_cpu(rp->policy); in hci_cc_read_def_link_policy()
253 return rp->status; in hci_cc_read_def_link_policy()
259 struct hci_ev_status *rp = data; in hci_cc_write_def_link_policy() local
262 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_def_link_policy()
264 if (rp->status) in hci_cc_write_def_link_policy()
265 return rp->status; in hci_cc_write_def_link_policy()
269 return rp->status; in hci_cc_write_def_link_policy()
271 hdev->link_policy = get_unaligned_le16(sent); in hci_cc_write_def_link_policy()
273 return rp->status; in hci_cc_write_def_link_policy()
278 struct hci_ev_status *rp = data; in hci_cc_reset() local
280 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_reset()
282 clear_bit(HCI_RESET, &hdev->flags); in hci_cc_reset()
284 if (rp->status) in hci_cc_reset()
285 return rp->status; in hci_cc_reset()
287 /* Reset all non-persistent flags */ in hci_cc_reset()
292 hdev->inq_tx_power = HCI_TX_POWER_INVALID; in hci_cc_reset()
293 hdev->adv_tx_power = HCI_TX_POWER_INVALID; in hci_cc_reset()
295 memset(hdev->adv_data, 0, sizeof(hdev->adv_data)); in hci_cc_reset()
296 hdev->adv_data_len = 0; in hci_cc_reset()
298 memset(hdev->scan_rsp_data, 0, sizeof(hdev->scan_rsp_data)); in hci_cc_reset()
299 hdev->scan_rsp_data_len = 0; in hci_cc_reset()
301 hdev->le_scan_type = LE_SCAN_PASSIVE; in hci_cc_reset()
303 hdev->ssp_debug_mode = 0; in hci_cc_reset()
305 hci_bdaddr_list_clear(&hdev->le_accept_list); in hci_cc_reset()
306 hci_bdaddr_list_clear(&hdev->le_resolv_list); in hci_cc_reset()
308 return rp->status; in hci_cc_reset()
314 struct hci_rp_read_stored_link_key *rp = data; in hci_cc_read_stored_link_key() local
317 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_stored_link_key()
321 return rp->status; in hci_cc_read_stored_link_key()
323 if (!rp->status && sent->read_all == 0x01) { in hci_cc_read_stored_link_key()
324 hdev->stored_max_keys = le16_to_cpu(rp->max_keys); in hci_cc_read_stored_link_key()
325 hdev->stored_num_keys = le16_to_cpu(rp->num_keys); in hci_cc_read_stored_link_key()
328 return rp->status; in hci_cc_read_stored_link_key()
334 struct hci_rp_delete_stored_link_key *rp = data; in hci_cc_delete_stored_link_key() local
337 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_delete_stored_link_key()
339 if (rp->status) in hci_cc_delete_stored_link_key()
340 return rp->status; in hci_cc_delete_stored_link_key()
342 num_keys = le16_to_cpu(rp->num_keys); in hci_cc_delete_stored_link_key()
344 if (num_keys <= hdev->stored_num_keys) in hci_cc_delete_stored_link_key()
345 hdev->stored_num_keys -= num_keys; in hci_cc_delete_stored_link_key()
347 hdev->stored_num_keys = 0; in hci_cc_delete_stored_link_key()
349 return rp->status; in hci_cc_delete_stored_link_key()
355 struct hci_ev_status *rp = data; in hci_cc_write_local_name() local
358 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_local_name()
362 return rp->status; in hci_cc_write_local_name()
367 mgmt_set_local_name_complete(hdev, sent, rp->status); in hci_cc_write_local_name()
368 else if (!rp->status) in hci_cc_write_local_name()
369 memcpy(hdev->dev_name, sent, HCI_MAX_NAME_LENGTH); in hci_cc_write_local_name()
373 return rp->status; in hci_cc_write_local_name()
379 struct hci_rp_read_local_name *rp = data; in hci_cc_read_local_name() local
381 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_name()
383 if (rp->status) in hci_cc_read_local_name()
384 return rp->status; in hci_cc_read_local_name()
388 memcpy(hdev->dev_name, rp->name, HCI_MAX_NAME_LENGTH); in hci_cc_read_local_name()
390 return rp->status; in hci_cc_read_local_name()
396 struct hci_ev_status *rp = data; in hci_cc_write_auth_enable() local
399 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_auth_enable()
403 return rp->status; in hci_cc_write_auth_enable()
407 if (!rp->status) { in hci_cc_write_auth_enable()
411 set_bit(HCI_AUTH, &hdev->flags); in hci_cc_write_auth_enable()
413 clear_bit(HCI_AUTH, &hdev->flags); in hci_cc_write_auth_enable()
417 mgmt_auth_enable_complete(hdev, rp->status); in hci_cc_write_auth_enable()
421 return rp->status; in hci_cc_write_auth_enable()
427 struct hci_ev_status *rp = data; in hci_cc_write_encrypt_mode() local
431 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_encrypt_mode()
433 if (rp->status) in hci_cc_write_encrypt_mode()
434 return rp->status; in hci_cc_write_encrypt_mode()
438 return rp->status; in hci_cc_write_encrypt_mode()
443 set_bit(HCI_ENCRYPT, &hdev->flags); in hci_cc_write_encrypt_mode()
445 clear_bit(HCI_ENCRYPT, &hdev->flags); in hci_cc_write_encrypt_mode()
447 return rp->status; in hci_cc_write_encrypt_mode()
453 struct hci_ev_status *rp = data; in hci_cc_write_scan_enable() local
457 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_scan_enable()
461 return rp->status; in hci_cc_write_scan_enable()
467 if (rp->status) { in hci_cc_write_scan_enable()
468 hdev->discov_timeout = 0; in hci_cc_write_scan_enable()
473 set_bit(HCI_ISCAN, &hdev->flags); in hci_cc_write_scan_enable()
475 clear_bit(HCI_ISCAN, &hdev->flags); in hci_cc_write_scan_enable()
478 set_bit(HCI_PSCAN, &hdev->flags); in hci_cc_write_scan_enable()
480 clear_bit(HCI_PSCAN, &hdev->flags); in hci_cc_write_scan_enable()
485 return rp->status; in hci_cc_write_scan_enable()
491 struct hci_ev_status *rp = data; in hci_cc_set_event_filter() local
495 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_set_event_filter()
497 if (rp->status) in hci_cc_set_event_filter()
498 return rp->status; in hci_cc_set_event_filter()
502 return rp->status; in hci_cc_set_event_filter()
506 if (cp->flt_type == HCI_FLT_CLEAR_ALL) in hci_cc_set_event_filter()
511 return rp->status; in hci_cc_set_event_filter()
517 struct hci_rp_read_class_of_dev *rp = data; in hci_cc_read_class_of_dev() local
519 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_class_of_dev()
521 if (rp->status) in hci_cc_read_class_of_dev()
522 return rp->status; in hci_cc_read_class_of_dev()
524 memcpy(hdev->dev_class, rp->dev_class, 3); in hci_cc_read_class_of_dev()
526 bt_dev_dbg(hdev, "class 0x%.2x%.2x%.2x", hdev->dev_class[2], in hci_cc_read_class_of_dev()
527 hdev->dev_class[1], hdev->dev_class[0]); in hci_cc_read_class_of_dev()
529 return rp->status; in hci_cc_read_class_of_dev()
535 struct hci_ev_status *rp = data; in hci_cc_write_class_of_dev() local
538 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_class_of_dev()
542 return rp->status; in hci_cc_write_class_of_dev()
546 if (!rp->status) in hci_cc_write_class_of_dev()
547 memcpy(hdev->dev_class, sent, 3); in hci_cc_write_class_of_dev()
550 mgmt_set_class_of_dev_complete(hdev, sent, rp->status); in hci_cc_write_class_of_dev()
554 return rp->status; in hci_cc_write_class_of_dev()
560 struct hci_rp_read_voice_setting *rp = data; in hci_cc_read_voice_setting() local
563 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_voice_setting()
565 if (rp->status) in hci_cc_read_voice_setting()
566 return rp->status; in hci_cc_read_voice_setting()
568 setting = __le16_to_cpu(rp->voice_setting); in hci_cc_read_voice_setting()
570 if (hdev->voice_setting == setting) in hci_cc_read_voice_setting()
571 return rp->status; in hci_cc_read_voice_setting()
573 hdev->voice_setting = setting; in hci_cc_read_voice_setting()
575 bt_dev_dbg(hdev, "voice setting 0x%4.4x", setting); in hci_cc_read_voice_setting()
577 if (hdev->notify) in hci_cc_read_voice_setting()
578 hdev->notify(hdev, HCI_NOTIFY_VOICE_SETTING); in hci_cc_read_voice_setting()
580 return rp->status; in hci_cc_read_voice_setting()
586 struct hci_ev_status *rp = data; in hci_cc_write_voice_setting() local
590 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_voice_setting()
592 if (rp->status) in hci_cc_write_voice_setting()
593 return rp->status; in hci_cc_write_voice_setting()
597 return rp->status; in hci_cc_write_voice_setting()
601 if (hdev->voice_setting == setting) in hci_cc_write_voice_setting()
602 return rp->status; in hci_cc_write_voice_setting()
604 hdev->voice_setting = setting; in hci_cc_write_voice_setting()
606 bt_dev_dbg(hdev, "voice setting 0x%4.4x", setting); in hci_cc_write_voice_setting()
608 if (hdev->notify) in hci_cc_write_voice_setting()
609 hdev->notify(hdev, HCI_NOTIFY_VOICE_SETTING); in hci_cc_write_voice_setting()
611 return rp->status; in hci_cc_write_voice_setting()
617 struct hci_rp_read_num_supported_iac *rp = data; in hci_cc_read_num_supported_iac() local
619 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_num_supported_iac()
621 if (rp->status) in hci_cc_read_num_supported_iac()
622 return rp->status; in hci_cc_read_num_supported_iac()
624 hdev->num_iac = rp->num_iac; in hci_cc_read_num_supported_iac()
626 bt_dev_dbg(hdev, "num iac %d", hdev->num_iac); in hci_cc_read_num_supported_iac()
628 return rp->status; in hci_cc_read_num_supported_iac()
634 struct hci_ev_status *rp = data; in hci_cc_write_ssp_mode() local
637 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_ssp_mode()
641 return rp->status; in hci_cc_write_ssp_mode()
645 if (!rp->status) { in hci_cc_write_ssp_mode()
646 if (sent->mode) in hci_cc_write_ssp_mode()
647 hdev->features[1][0] |= LMP_HOST_SSP; in hci_cc_write_ssp_mode()
649 hdev->features[1][0] &= ~LMP_HOST_SSP; in hci_cc_write_ssp_mode()
652 if (!rp->status) { in hci_cc_write_ssp_mode()
653 if (sent->mode) in hci_cc_write_ssp_mode()
661 return rp->status; in hci_cc_write_ssp_mode()
667 struct hci_ev_status *rp = data; in hci_cc_write_sc_support() local
670 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_sc_support()
674 return rp->status; in hci_cc_write_sc_support()
678 if (!rp->status) { in hci_cc_write_sc_support()
679 if (sent->support) in hci_cc_write_sc_support()
680 hdev->features[1][0] |= LMP_HOST_SC; in hci_cc_write_sc_support()
682 hdev->features[1][0] &= ~LMP_HOST_SC; in hci_cc_write_sc_support()
685 if (!hci_dev_test_flag(hdev, HCI_MGMT) && !rp->status) { in hci_cc_write_sc_support()
686 if (sent->support) in hci_cc_write_sc_support()
694 return rp->status; in hci_cc_write_sc_support()
700 struct hci_rp_read_local_version *rp = data; in hci_cc_read_local_version() local
702 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_version()
704 if (rp->status) in hci_cc_read_local_version()
705 return rp->status; in hci_cc_read_local_version()
709 hdev->hci_ver = rp->hci_ver; in hci_cc_read_local_version()
710 hdev->hci_rev = __le16_to_cpu(rp->hci_rev); in hci_cc_read_local_version()
711 hdev->lmp_ver = rp->lmp_ver; in hci_cc_read_local_version()
712 hdev->manufacturer = __le16_to_cpu(rp->manufacturer); in hci_cc_read_local_version()
713 hdev->lmp_subver = __le16_to_cpu(rp->lmp_subver); in hci_cc_read_local_version()
716 return rp->status; in hci_cc_read_local_version()
722 struct hci_rp_read_enc_key_size *rp = data; in hci_cc_read_enc_key_size() local
725 u8 status = rp->status; in hci_cc_read_enc_key_size()
727 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cc_read_enc_key_size()
729 handle = le16_to_cpu(rp->handle); in hci_cc_read_enc_key_size()
746 conn->enc_key_size = 0; in hci_cc_read_enc_key_size()
748 conn->enc_key_size = rp->key_size; in hci_cc_read_enc_key_size()
763 struct hci_rp_read_local_commands *rp = data; in hci_cc_read_local_commands() local
765 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_commands()
767 if (rp->status) in hci_cc_read_local_commands()
768 return rp->status; in hci_cc_read_local_commands()
772 memcpy(hdev->commands, rp->commands, sizeof(hdev->commands)); in hci_cc_read_local_commands()
774 return rp->status; in hci_cc_read_local_commands()
780 struct hci_rp_read_auth_payload_to *rp = data; in hci_cc_read_auth_payload_timeout() local
783 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_auth_payload_timeout()
785 if (rp->status) in hci_cc_read_auth_payload_timeout()
786 return rp->status; in hci_cc_read_auth_payload_timeout()
790 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_auth_payload_timeout()
792 conn->auth_payload_timeout = __le16_to_cpu(rp->timeout); in hci_cc_read_auth_payload_timeout()
796 return rp->status; in hci_cc_read_auth_payload_timeout()
802 struct hci_rp_write_auth_payload_to *rp = data; in hci_cc_write_auth_payload_timeout() local
806 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_auth_payload_timeout()
810 return rp->status; in hci_cc_write_auth_payload_timeout()
814 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_write_auth_payload_timeout()
816 rp->status = 0xff; in hci_cc_write_auth_payload_timeout()
820 if (!rp->status) in hci_cc_write_auth_payload_timeout()
821 conn->auth_payload_timeout = get_unaligned_le16(sent + 2); in hci_cc_write_auth_payload_timeout()
828 return rp->status; in hci_cc_write_auth_payload_timeout()
834 struct hci_rp_read_local_features *rp = data; in hci_cc_read_local_features() local
836 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_features()
838 if (rp->status) in hci_cc_read_local_features()
839 return rp->status; in hci_cc_read_local_features()
841 memcpy(hdev->features, rp->features, 8); in hci_cc_read_local_features()
846 if (hdev->features[0][0] & LMP_3SLOT) in hci_cc_read_local_features()
847 hdev->pkt_type |= (HCI_DM3 | HCI_DH3); in hci_cc_read_local_features()
849 if (hdev->features[0][0] & LMP_5SLOT) in hci_cc_read_local_features()
850 hdev->pkt_type |= (HCI_DM5 | HCI_DH5); in hci_cc_read_local_features()
852 if (hdev->features[0][1] & LMP_HV2) { in hci_cc_read_local_features()
853 hdev->pkt_type |= (HCI_HV2); in hci_cc_read_local_features()
854 hdev->esco_type |= (ESCO_HV2); in hci_cc_read_local_features()
857 if (hdev->features[0][1] & LMP_HV3) { in hci_cc_read_local_features()
858 hdev->pkt_type |= (HCI_HV3); in hci_cc_read_local_features()
859 hdev->esco_type |= (ESCO_HV3); in hci_cc_read_local_features()
863 hdev->esco_type |= (ESCO_EV3); in hci_cc_read_local_features()
865 if (hdev->features[0][4] & LMP_EV4) in hci_cc_read_local_features()
866 hdev->esco_type |= (ESCO_EV4); in hci_cc_read_local_features()
868 if (hdev->features[0][4] & LMP_EV5) in hci_cc_read_local_features()
869 hdev->esco_type |= (ESCO_EV5); in hci_cc_read_local_features()
871 if (hdev->features[0][5] & LMP_EDR_ESCO_2M) in hci_cc_read_local_features()
872 hdev->esco_type |= (ESCO_2EV3); in hci_cc_read_local_features()
874 if (hdev->features[0][5] & LMP_EDR_ESCO_3M) in hci_cc_read_local_features()
875 hdev->esco_type |= (ESCO_3EV3); in hci_cc_read_local_features()
877 if (hdev->features[0][5] & LMP_EDR_3S_ESCO) in hci_cc_read_local_features()
878 hdev->esco_type |= (ESCO_2EV5 | ESCO_3EV5); in hci_cc_read_local_features()
880 return rp->status; in hci_cc_read_local_features()
886 struct hci_rp_read_local_ext_features *rp = data; in hci_cc_read_local_ext_features() local
888 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_ext_features()
890 if (rp->status) in hci_cc_read_local_ext_features()
891 return rp->status; in hci_cc_read_local_ext_features()
893 if (hdev->max_page < rp->max_page) { in hci_cc_read_local_ext_features()
895 &hdev->quirks)) in hci_cc_read_local_ext_features()
898 hdev->max_page = rp->max_page; in hci_cc_read_local_ext_features()
901 if (rp->page < HCI_MAX_PAGES) in hci_cc_read_local_ext_features()
902 memcpy(hdev->features[rp->page], rp->features, 8); in hci_cc_read_local_ext_features()
904 return rp->status; in hci_cc_read_local_ext_features()
910 struct hci_rp_read_flow_control_mode *rp = data; in hci_cc_read_flow_control_mode() local
912 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_flow_control_mode()
914 if (rp->status) in hci_cc_read_flow_control_mode()
915 return rp->status; in hci_cc_read_flow_control_mode()
917 hdev->flow_ctl_mode = rp->mode; in hci_cc_read_flow_control_mode()
919 return rp->status; in hci_cc_read_flow_control_mode()
925 struct hci_rp_read_buffer_size *rp = data; in hci_cc_read_buffer_size() local
927 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_buffer_size()
929 if (rp->status) in hci_cc_read_buffer_size()
930 return rp->status; in hci_cc_read_buffer_size()
932 hdev->acl_mtu = __le16_to_cpu(rp->acl_mtu); in hci_cc_read_buffer_size()
933 hdev->sco_mtu = rp->sco_mtu; in hci_cc_read_buffer_size()
934 hdev->acl_pkts = __le16_to_cpu(rp->acl_max_pkt); in hci_cc_read_buffer_size()
935 hdev->sco_pkts = __le16_to_cpu(rp->sco_max_pkt); in hci_cc_read_buffer_size()
937 if (test_bit(HCI_QUIRK_FIXUP_BUFFER_SIZE, &hdev->quirks)) { in hci_cc_read_buffer_size()
938 hdev->sco_mtu = 64; in hci_cc_read_buffer_size()
939 hdev->sco_pkts = 8; in hci_cc_read_buffer_size()
942 hdev->acl_cnt = hdev->acl_pkts; in hci_cc_read_buffer_size()
943 hdev->sco_cnt = hdev->sco_pkts; in hci_cc_read_buffer_size()
945 BT_DBG("%s acl mtu %d:%d sco mtu %d:%d", hdev->name, hdev->acl_mtu, in hci_cc_read_buffer_size()
946 hdev->acl_pkts, hdev->sco_mtu, hdev->sco_pkts); in hci_cc_read_buffer_size()
948 return rp->status; in hci_cc_read_buffer_size()
954 struct hci_rp_read_bd_addr *rp = data; in hci_cc_read_bd_addr() local
956 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_bd_addr()
958 if (rp->status) in hci_cc_read_bd_addr()
959 return rp->status; in hci_cc_read_bd_addr()
961 if (test_bit(HCI_INIT, &hdev->flags)) in hci_cc_read_bd_addr()
962 bacpy(&hdev->bdaddr, &rp->bdaddr); in hci_cc_read_bd_addr()
965 bacpy(&hdev->setup_addr, &rp->bdaddr); in hci_cc_read_bd_addr()
967 return rp->status; in hci_cc_read_bd_addr()
973 struct hci_rp_read_local_pairing_opts *rp = data; in hci_cc_read_local_pairing_opts() local
975 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_pairing_opts()
977 if (rp->status) in hci_cc_read_local_pairing_opts()
978 return rp->status; in hci_cc_read_local_pairing_opts()
982 hdev->pairing_opts = rp->pairing_opts; in hci_cc_read_local_pairing_opts()
983 hdev->max_enc_key_size = rp->max_key_size; in hci_cc_read_local_pairing_opts()
986 return rp->status; in hci_cc_read_local_pairing_opts()
992 struct hci_rp_read_page_scan_activity *rp = data; in hci_cc_read_page_scan_activity() local
994 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_page_scan_activity()
996 if (rp->status) in hci_cc_read_page_scan_activity()
997 return rp->status; in hci_cc_read_page_scan_activity()
999 if (test_bit(HCI_INIT, &hdev->flags)) { in hci_cc_read_page_scan_activity()
1000 hdev->page_scan_interval = __le16_to_cpu(rp->interval); in hci_cc_read_page_scan_activity()
1001 hdev->page_scan_window = __le16_to_cpu(rp->window); in hci_cc_read_page_scan_activity()
1004 return rp->status; in hci_cc_read_page_scan_activity()
1010 struct hci_ev_status *rp = data; in hci_cc_write_page_scan_activity() local
1013 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_page_scan_activity()
1015 if (rp->status) in hci_cc_write_page_scan_activity()
1016 return rp->status; in hci_cc_write_page_scan_activity()
1020 return rp->status; in hci_cc_write_page_scan_activity()
1022 hdev->page_scan_interval = __le16_to_cpu(sent->interval); in hci_cc_write_page_scan_activity()
1023 hdev->page_scan_window = __le16_to_cpu(sent->window); in hci_cc_write_page_scan_activity()
1025 return rp->status; in hci_cc_write_page_scan_activity()
1031 struct hci_rp_read_page_scan_type *rp = data; in hci_cc_read_page_scan_type() local
1033 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_page_scan_type()
1035 if (rp->status) in hci_cc_read_page_scan_type()
1036 return rp->status; in hci_cc_read_page_scan_type()
1038 if (test_bit(HCI_INIT, &hdev->flags)) in hci_cc_read_page_scan_type()
1039 hdev->page_scan_type = rp->type; in hci_cc_read_page_scan_type()
1041 return rp->status; in hci_cc_read_page_scan_type()
1047 struct hci_ev_status *rp = data; in hci_cc_write_page_scan_type() local
1050 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_page_scan_type()
1052 if (rp->status) in hci_cc_write_page_scan_type()
1053 return rp->status; in hci_cc_write_page_scan_type()
1057 hdev->page_scan_type = *type; in hci_cc_write_page_scan_type()
1059 return rp->status; in hci_cc_write_page_scan_type()
1065 struct hci_rp_read_data_block_size *rp = data; in hci_cc_read_data_block_size() local
1067 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_data_block_size()
1069 if (rp->status) in hci_cc_read_data_block_size()
1070 return rp->status; in hci_cc_read_data_block_size()
1072 hdev->block_mtu = __le16_to_cpu(rp->max_acl_len); in hci_cc_read_data_block_size()
1073 hdev->block_len = __le16_to_cpu(rp->block_len); in hci_cc_read_data_block_size()
1074 hdev->num_blocks = __le16_to_cpu(rp->num_blocks); in hci_cc_read_data_block_size()
1076 hdev->block_cnt = hdev->num_blocks; in hci_cc_read_data_block_size()
1078 BT_DBG("%s blk mtu %d cnt %d len %d", hdev->name, hdev->block_mtu, in hci_cc_read_data_block_size()
1079 hdev->block_cnt, hdev->block_len); in hci_cc_read_data_block_size()
1081 return rp->status; in hci_cc_read_data_block_size()
1087 struct hci_rp_read_clock *rp = data; in hci_cc_read_clock() local
1091 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_clock()
1093 if (rp->status) in hci_cc_read_clock()
1094 return rp->status; in hci_cc_read_clock()
1102 if (cp->which == 0x00) { in hci_cc_read_clock()
1103 hdev->clock = le32_to_cpu(rp->clock); in hci_cc_read_clock()
1107 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_clock()
1109 conn->clock = le32_to_cpu(rp->clock); in hci_cc_read_clock()
1110 conn->clock_accuracy = le16_to_cpu(rp->accuracy); in hci_cc_read_clock()
1115 return rp->status; in hci_cc_read_clock()
1121 struct hci_rp_read_local_amp_info *rp = data; in hci_cc_read_local_amp_info() local
1123 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_amp_info()
1125 if (rp->status) in hci_cc_read_local_amp_info()
1126 return rp->status; in hci_cc_read_local_amp_info()
1128 hdev->amp_status = rp->amp_status; in hci_cc_read_local_amp_info()
1129 hdev->amp_total_bw = __le32_to_cpu(rp->total_bw); in hci_cc_read_local_amp_info()
1130 hdev->amp_max_bw = __le32_to_cpu(rp->max_bw); in hci_cc_read_local_amp_info()
1131 hdev->amp_min_latency = __le32_to_cpu(rp->min_latency); in hci_cc_read_local_amp_info()
1132 hdev->amp_max_pdu = __le32_to_cpu(rp->max_pdu); in hci_cc_read_local_amp_info()
1133 hdev->amp_type = rp->amp_type; in hci_cc_read_local_amp_info()
1134 hdev->amp_pal_cap = __le16_to_cpu(rp->pal_cap); in hci_cc_read_local_amp_info()
1135 hdev->amp_assoc_size = __le16_to_cpu(rp->max_assoc_size); in hci_cc_read_local_amp_info()
1136 hdev->amp_be_flush_to = __le32_to_cpu(rp->be_flush_to); in hci_cc_read_local_amp_info()
1137 hdev->amp_max_flush_to = __le32_to_cpu(rp->max_flush_to); in hci_cc_read_local_amp_info()
1139 return rp->status; in hci_cc_read_local_amp_info()
1145 struct hci_rp_read_inq_rsp_tx_power *rp = data; in hci_cc_read_inq_rsp_tx_power() local
1147 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_inq_rsp_tx_power()
1149 if (rp->status) in hci_cc_read_inq_rsp_tx_power()
1150 return rp->status; in hci_cc_read_inq_rsp_tx_power()
1152 hdev->inq_tx_power = rp->tx_power; in hci_cc_read_inq_rsp_tx_power()
1154 return rp->status; in hci_cc_read_inq_rsp_tx_power()
1160 struct hci_rp_read_def_err_data_reporting *rp = data; in hci_cc_read_def_err_data_reporting() local
1162 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_def_err_data_reporting()
1164 if (rp->status) in hci_cc_read_def_err_data_reporting()
1165 return rp->status; in hci_cc_read_def_err_data_reporting()
1167 hdev->err_data_reporting = rp->err_data_reporting; in hci_cc_read_def_err_data_reporting()
1169 return rp->status; in hci_cc_read_def_err_data_reporting()
1175 struct hci_ev_status *rp = data; in hci_cc_write_def_err_data_reporting() local
1178 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_def_err_data_reporting()
1180 if (rp->status) in hci_cc_write_def_err_data_reporting()
1181 return rp->status; in hci_cc_write_def_err_data_reporting()
1185 return rp->status; in hci_cc_write_def_err_data_reporting()
1187 hdev->err_data_reporting = cp->err_data_reporting; in hci_cc_write_def_err_data_reporting()
1189 return rp->status; in hci_cc_write_def_err_data_reporting()
1195 struct hci_rp_pin_code_reply *rp = data; in hci_cc_pin_code_reply() local
1199 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_pin_code_reply()
1204 mgmt_pin_code_reply_complete(hdev, &rp->bdaddr, rp->status); in hci_cc_pin_code_reply()
1206 if (rp->status) in hci_cc_pin_code_reply()
1213 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cc_pin_code_reply()
1215 conn->pin_length = cp->pin_len; in hci_cc_pin_code_reply()
1219 return rp->status; in hci_cc_pin_code_reply()
1225 struct hci_rp_pin_code_neg_reply *rp = data; in hci_cc_pin_code_neg_reply() local
1227 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_pin_code_neg_reply()
1232 mgmt_pin_code_neg_reply_complete(hdev, &rp->bdaddr, in hci_cc_pin_code_neg_reply()
1233 rp->status); in hci_cc_pin_code_neg_reply()
1237 return rp->status; in hci_cc_pin_code_neg_reply()
1243 struct hci_rp_le_read_buffer_size *rp = data; in hci_cc_le_read_buffer_size() local
1245 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_read_buffer_size()
1247 if (rp->status) in hci_cc_le_read_buffer_size()
1248 return rp->status; in hci_cc_le_read_buffer_size()
1250 hdev->le_mtu = __le16_to_cpu(rp->le_mtu); in hci_cc_le_read_buffer_size()
1251 hdev->le_pkts = rp->le_max_pkt; in hci_cc_le_read_buffer_size()
1253 hdev->le_cnt = hdev->le_pkts; in hci_cc_le_read_buffer_size()
1255 BT_DBG("%s le mtu %d:%d", hdev->name, hdev->le_mtu, hdev->le_pkts); in hci_cc_le_read_buffer_size()
1257 return rp->status; in hci_cc_le_read_buffer_size()
1263 struct hci_rp_le_read_local_features *rp = data; in hci_cc_le_read_local_features() local
1265 BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); in hci_cc_le_read_local_features()
1267 if (rp->status) in hci_cc_le_read_local_features()
1268 return rp->status; in hci_cc_le_read_local_features()
1270 memcpy(hdev->le_features, rp->features, 8); in hci_cc_le_read_local_features()
1272 return rp->status; in hci_cc_le_read_local_features()
1278 struct hci_rp_le_read_adv_tx_power *rp = data; in hci_cc_le_read_adv_tx_power() local
1280 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_read_adv_tx_power()
1282 if (rp->status) in hci_cc_le_read_adv_tx_power()
1283 return rp->status; in hci_cc_le_read_adv_tx_power()
1285 hdev->adv_tx_power = rp->tx_power; in hci_cc_le_read_adv_tx_power()
1287 return rp->status; in hci_cc_le_read_adv_tx_power()
1293 struct hci_rp_user_confirm_reply *rp = data; in hci_cc_user_confirm_reply() local
1295 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_user_confirm_reply()
1300 mgmt_user_confirm_reply_complete(hdev, &rp->bdaddr, ACL_LINK, 0, in hci_cc_user_confirm_reply()
1301 rp->status); in hci_cc_user_confirm_reply()
1305 return rp->status; in hci_cc_user_confirm_reply()
1311 struct hci_rp_user_confirm_reply *rp = data; in hci_cc_user_confirm_neg_reply() local
1313 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_user_confirm_neg_reply()
1318 mgmt_user_confirm_neg_reply_complete(hdev, &rp->bdaddr, in hci_cc_user_confirm_neg_reply()
1319 ACL_LINK, 0, rp->status); in hci_cc_user_confirm_neg_reply()
1323 return rp->status; in hci_cc_user_confirm_neg_reply()
1329 struct hci_rp_user_confirm_reply *rp = data; in hci_cc_user_passkey_reply() local
1331 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_user_passkey_reply()
1336 mgmt_user_passkey_reply_complete(hdev, &rp->bdaddr, ACL_LINK, in hci_cc_user_passkey_reply()
1337 0, rp->status); in hci_cc_user_passkey_reply()
1341 return rp->status; in hci_cc_user_passkey_reply()
1347 struct hci_rp_user_confirm_reply *rp = data; in hci_cc_user_passkey_neg_reply() local
1349 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_user_passkey_neg_reply()
1354 mgmt_user_passkey_neg_reply_complete(hdev, &rp->bdaddr, in hci_cc_user_passkey_neg_reply()
1355 ACL_LINK, 0, rp->status); in hci_cc_user_passkey_neg_reply()
1359 return rp->status; in hci_cc_user_passkey_neg_reply()
1365 struct hci_rp_read_local_oob_data *rp = data; in hci_cc_read_local_oob_data() local
1367 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_oob_data()
1369 return rp->status; in hci_cc_read_local_oob_data()
1375 struct hci_rp_read_local_oob_ext_data *rp = data; in hci_cc_read_local_oob_ext_data() local
1377 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_oob_ext_data()
1379 return rp->status; in hci_cc_read_local_oob_ext_data()
1385 struct hci_ev_status *rp = data; in hci_cc_le_set_random_addr() local
1388 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_random_addr()
1390 if (rp->status) in hci_cc_le_set_random_addr()
1391 return rp->status; in hci_cc_le_set_random_addr()
1395 return rp->status; in hci_cc_le_set_random_addr()
1399 bacpy(&hdev->random_addr, sent); in hci_cc_le_set_random_addr()
1401 if (!bacmp(&hdev->rpa, sent)) { in hci_cc_le_set_random_addr()
1403 queue_delayed_work(hdev->workqueue, &hdev->rpa_expired, in hci_cc_le_set_random_addr()
1404 secs_to_jiffies(hdev->rpa_timeout)); in hci_cc_le_set_random_addr()
1409 return rp->status; in hci_cc_le_set_random_addr()
1415 struct hci_ev_status *rp = data; in hci_cc_le_set_default_phy() local
1418 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_default_phy()
1420 if (rp->status) in hci_cc_le_set_default_phy()
1421 return rp->status; in hci_cc_le_set_default_phy()
1425 return rp->status; in hci_cc_le_set_default_phy()
1429 hdev->le_tx_def_phys = cp->tx_phys; in hci_cc_le_set_default_phy()
1430 hdev->le_rx_def_phys = cp->rx_phys; in hci_cc_le_set_default_phy()
1434 return rp->status; in hci_cc_le_set_default_phy()
1440 struct hci_ev_status *rp = data; in hci_cc_le_set_adv_set_random_addr() local
1444 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_adv_set_random_addr()
1446 if (rp->status) in hci_cc_le_set_adv_set_random_addr()
1447 return rp->status; in hci_cc_le_set_adv_set_random_addr()
1452 * non-extended adverting. in hci_cc_le_set_adv_set_random_addr()
1454 if (!cp || !cp->handle) in hci_cc_le_set_adv_set_random_addr()
1455 return rp->status; in hci_cc_le_set_adv_set_random_addr()
1459 adv = hci_find_adv_instance(hdev, cp->handle); in hci_cc_le_set_adv_set_random_addr()
1461 bacpy(&adv->random_addr, &cp->bdaddr); in hci_cc_le_set_adv_set_random_addr()
1462 if (!bacmp(&hdev->rpa, &cp->bdaddr)) { in hci_cc_le_set_adv_set_random_addr()
1463 adv->rpa_expired = false; in hci_cc_le_set_adv_set_random_addr()
1464 queue_delayed_work(hdev->workqueue, in hci_cc_le_set_adv_set_random_addr()
1465 &adv->rpa_expired_cb, in hci_cc_le_set_adv_set_random_addr()
1466 secs_to_jiffies(hdev->rpa_timeout)); in hci_cc_le_set_adv_set_random_addr()
1472 return rp->status; in hci_cc_le_set_adv_set_random_addr()
1478 struct hci_ev_status *rp = data; in hci_cc_le_remove_adv_set() local
1482 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_remove_adv_set()
1484 if (rp->status) in hci_cc_le_remove_adv_set()
1485 return rp->status; in hci_cc_le_remove_adv_set()
1489 return rp->status; in hci_cc_le_remove_adv_set()
1495 mgmt_advertising_removed(hci_skb_sk(hdev->sent_cmd), hdev, in hci_cc_le_remove_adv_set()
1500 return rp->status; in hci_cc_le_remove_adv_set()
1506 struct hci_ev_status *rp = data; in hci_cc_le_clear_adv_sets() local
1510 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_clear_adv_sets()
1512 if (rp->status) in hci_cc_le_clear_adv_sets()
1513 return rp->status; in hci_cc_le_clear_adv_sets()
1516 return rp->status; in hci_cc_le_clear_adv_sets()
1520 list_for_each_entry_safe(adv, n, &hdev->adv_instances, list) { in hci_cc_le_clear_adv_sets()
1521 u8 instance = adv->instance; in hci_cc_le_clear_adv_sets()
1525 mgmt_advertising_removed(hci_skb_sk(hdev->sent_cmd), in hci_cc_le_clear_adv_sets()
1531 return rp->status; in hci_cc_le_clear_adv_sets()
1537 struct hci_rp_le_read_transmit_power *rp = data; in hci_cc_le_read_transmit_power() local
1539 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_read_transmit_power()
1541 if (rp->status) in hci_cc_le_read_transmit_power()
1542 return rp->status; in hci_cc_le_read_transmit_power()
1544 hdev->min_le_tx_power = rp->min_le_tx_power; in hci_cc_le_read_transmit_power()
1545 hdev->max_le_tx_power = rp->max_le_tx_power; in hci_cc_le_read_transmit_power()
1547 return rp->status; in hci_cc_le_read_transmit_power()
1553 struct hci_ev_status *rp = data; in hci_cc_le_set_privacy_mode() local
1557 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_privacy_mode()
1559 if (rp->status) in hci_cc_le_set_privacy_mode()
1560 return rp->status; in hci_cc_le_set_privacy_mode()
1564 return rp->status; in hci_cc_le_set_privacy_mode()
1568 params = hci_conn_params_lookup(hdev, &cp->bdaddr, cp->bdaddr_type); in hci_cc_le_set_privacy_mode()
1570 WRITE_ONCE(params->privacy_mode, cp->mode); in hci_cc_le_set_privacy_mode()
1574 return rp->status; in hci_cc_le_set_privacy_mode()
1580 struct hci_ev_status *rp = data; in hci_cc_le_set_adv_enable() local
1583 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_adv_enable()
1585 if (rp->status) in hci_cc_le_set_adv_enable()
1586 return rp->status; in hci_cc_le_set_adv_enable()
1590 return rp->status; in hci_cc_le_set_adv_enable()
1604 queue_delayed_work(hdev->workqueue, in hci_cc_le_set_adv_enable()
1605 &conn->le_conn_timeout, in hci_cc_le_set_adv_enable()
1606 conn->conn_timeout); in hci_cc_le_set_adv_enable()
1613 return rp->status; in hci_cc_le_set_adv_enable()
1622 struct hci_ev_status *rp = data; in hci_cc_le_set_ext_adv_enable() local
1624 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_ext_adv_enable()
1626 if (rp->status) in hci_cc_le_set_ext_adv_enable()
1627 return rp->status; in hci_cc_le_set_ext_adv_enable()
1631 return rp->status; in hci_cc_le_set_ext_adv_enable()
1633 set = (void *)cp->data; in hci_cc_le_set_ext_adv_enable()
1637 if (cp->num_of_sets) in hci_cc_le_set_ext_adv_enable()
1638 adv = hci_find_adv_instance(hdev, set->handle); in hci_cc_le_set_ext_adv_enable()
1640 if (cp->enable) { in hci_cc_le_set_ext_adv_enable()
1645 if (adv && !adv->periodic) in hci_cc_le_set_ext_adv_enable()
1646 adv->enabled = true; in hci_cc_le_set_ext_adv_enable()
1650 queue_delayed_work(hdev->workqueue, in hci_cc_le_set_ext_adv_enable()
1651 &conn->le_conn_timeout, in hci_cc_le_set_ext_adv_enable()
1652 conn->conn_timeout); in hci_cc_le_set_ext_adv_enable()
1654 if (cp->num_of_sets) { in hci_cc_le_set_ext_adv_enable()
1656 adv->enabled = false; in hci_cc_le_set_ext_adv_enable()
1661 list_for_each_entry_safe(adv, n, &hdev->adv_instances, in hci_cc_le_set_ext_adv_enable()
1663 if (adv->enabled) in hci_cc_le_set_ext_adv_enable()
1668 list_for_each_entry_safe(adv, n, &hdev->adv_instances, in hci_cc_le_set_ext_adv_enable()
1670 adv->enabled = false; in hci_cc_le_set_ext_adv_enable()
1678 return rp->status; in hci_cc_le_set_ext_adv_enable()
1685 struct hci_ev_status *rp = data; in hci_cc_le_set_scan_param() local
1687 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_scan_param()
1689 if (rp->status) in hci_cc_le_set_scan_param()
1690 return rp->status; in hci_cc_le_set_scan_param()
1694 return rp->status; in hci_cc_le_set_scan_param()
1698 hdev->le_scan_type = cp->type; in hci_cc_le_set_scan_param()
1702 return rp->status; in hci_cc_le_set_scan_param()
1709 struct hci_ev_status *rp = data; in hci_cc_le_set_ext_scan_param() local
1712 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_ext_scan_param()
1714 if (rp->status) in hci_cc_le_set_ext_scan_param()
1715 return rp->status; in hci_cc_le_set_ext_scan_param()
1719 return rp->status; in hci_cc_le_set_ext_scan_param()
1721 phy_param = (void *)cp->data; in hci_cc_le_set_ext_scan_param()
1725 hdev->le_scan_type = phy_param->type; in hci_cc_le_set_ext_scan_param()
1729 return rp->status; in hci_cc_le_set_ext_scan_param()
1734 struct discovery_state *d = &hdev->discovery; in has_pending_adv_report()
1736 return bacmp(&d->last_adv_addr, BDADDR_ANY); in has_pending_adv_report()
1741 struct discovery_state *d = &hdev->discovery; in clear_pending_adv_report()
1743 bacpy(&d->last_adv_addr, BDADDR_ANY); in clear_pending_adv_report()
1744 d->last_adv_data_len = 0; in clear_pending_adv_report()
1751 struct discovery_state *d = &hdev->discovery; in store_pending_adv_report()
1756 bacpy(&d->last_adv_addr, bdaddr); in store_pending_adv_report()
1757 d->last_adv_addr_type = bdaddr_type; in store_pending_adv_report()
1758 d->last_adv_rssi = rssi; in store_pending_adv_report()
1759 d->last_adv_flags = flags; in store_pending_adv_report()
1760 memcpy(d->last_adv_data, data, len); in store_pending_adv_report()
1761 d->last_adv_data_len = len; in store_pending_adv_report()
1771 if (hdev->le_scan_type == LE_SCAN_ACTIVE) in le_set_scan_enable_complete()
1783 struct discovery_state *d = &hdev->discovery; in le_set_scan_enable_complete()
1785 mgmt_device_found(hdev, &d->last_adv_addr, LE_LINK, in le_set_scan_enable_complete()
1786 d->last_adv_addr_type, NULL, in le_set_scan_enable_complete()
1787 d->last_adv_rssi, d->last_adv_flags, in le_set_scan_enable_complete()
1788 d->last_adv_data, in le_set_scan_enable_complete()
1789 d->last_adv_data_len, NULL, 0, 0); in le_set_scan_enable_complete()
1795 cancel_delayed_work(&hdev->le_scan_disable); in le_set_scan_enable_complete()
1806 hdev->discovery.state == DISCOVERY_FINDING) in le_set_scan_enable_complete()
1807 queue_work(hdev->workqueue, &hdev->reenable_adv_work); in le_set_scan_enable_complete()
1824 struct hci_ev_status *rp = data; in hci_cc_le_set_scan_enable() local
1826 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_scan_enable()
1828 if (rp->status) in hci_cc_le_set_scan_enable()
1829 return rp->status; in hci_cc_le_set_scan_enable()
1833 return rp->status; in hci_cc_le_set_scan_enable()
1835 le_set_scan_enable_complete(hdev, cp->enable); in hci_cc_le_set_scan_enable()
1837 return rp->status; in hci_cc_le_set_scan_enable()
1844 struct hci_ev_status *rp = data; in hci_cc_le_set_ext_scan_enable() local
1846 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_ext_scan_enable()
1848 if (rp->status) in hci_cc_le_set_ext_scan_enable()
1849 return rp->status; in hci_cc_le_set_ext_scan_enable()
1853 return rp->status; in hci_cc_le_set_ext_scan_enable()
1855 le_set_scan_enable_complete(hdev, cp->enable); in hci_cc_le_set_ext_scan_enable()
1857 return rp->status; in hci_cc_le_set_ext_scan_enable()
1863 struct hci_rp_le_read_num_supported_adv_sets *rp = data; in hci_cc_le_read_num_adv_sets() local
1865 bt_dev_dbg(hdev, "status 0x%2.2x No of Adv sets %u", rp->status, in hci_cc_le_read_num_adv_sets()
1866 rp->num_of_sets); in hci_cc_le_read_num_adv_sets()
1868 if (rp->status) in hci_cc_le_read_num_adv_sets()
1869 return rp->status; in hci_cc_le_read_num_adv_sets()
1871 hdev->le_num_of_adv_sets = rp->num_of_sets; in hci_cc_le_read_num_adv_sets()
1873 return rp->status; in hci_cc_le_read_num_adv_sets()
1879 struct hci_rp_le_read_accept_list_size *rp = data; in hci_cc_le_read_accept_list_size() local
1881 bt_dev_dbg(hdev, "status 0x%2.2x size %u", rp->status, rp->size); in hci_cc_le_read_accept_list_size()
1883 if (rp->status) in hci_cc_le_read_accept_list_size()
1884 return rp->status; in hci_cc_le_read_accept_list_size()
1886 hdev->le_accept_list_size = rp->size; in hci_cc_le_read_accept_list_size()
1888 return rp->status; in hci_cc_le_read_accept_list_size()
1894 struct hci_ev_status *rp = data; in hci_cc_le_clear_accept_list() local
1896 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_clear_accept_list()
1898 if (rp->status) in hci_cc_le_clear_accept_list()
1899 return rp->status; in hci_cc_le_clear_accept_list()
1902 hci_bdaddr_list_clear(&hdev->le_accept_list); in hci_cc_le_clear_accept_list()
1905 return rp->status; in hci_cc_le_clear_accept_list()
1912 struct hci_ev_status *rp = data; in hci_cc_le_add_to_accept_list() local
1914 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_add_to_accept_list()
1916 if (rp->status) in hci_cc_le_add_to_accept_list()
1917 return rp->status; in hci_cc_le_add_to_accept_list()
1921 return rp->status; in hci_cc_le_add_to_accept_list()
1924 hci_bdaddr_list_add(&hdev->le_accept_list, &sent->bdaddr, in hci_cc_le_add_to_accept_list()
1925 sent->bdaddr_type); in hci_cc_le_add_to_accept_list()
1928 return rp->status; in hci_cc_le_add_to_accept_list()
1935 struct hci_ev_status *rp = data; in hci_cc_le_del_from_accept_list() local
1937 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_del_from_accept_list()
1939 if (rp->status) in hci_cc_le_del_from_accept_list()
1940 return rp->status; in hci_cc_le_del_from_accept_list()
1944 return rp->status; in hci_cc_le_del_from_accept_list()
1947 hci_bdaddr_list_del(&hdev->le_accept_list, &sent->bdaddr, in hci_cc_le_del_from_accept_list()
1948 sent->bdaddr_type); in hci_cc_le_del_from_accept_list()
1951 return rp->status; in hci_cc_le_del_from_accept_list()
1957 struct hci_rp_le_read_supported_states *rp = data; in hci_cc_le_read_supported_states() local
1959 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_read_supported_states()
1961 if (rp->status) in hci_cc_le_read_supported_states()
1962 return rp->status; in hci_cc_le_read_supported_states()
1964 memcpy(hdev->le_states, rp->le_states, 8); in hci_cc_le_read_supported_states()
1966 return rp->status; in hci_cc_le_read_supported_states()
1972 struct hci_rp_le_read_def_data_len *rp = data; in hci_cc_le_read_def_data_len() local
1974 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_read_def_data_len()
1976 if (rp->status) in hci_cc_le_read_def_data_len()
1977 return rp->status; in hci_cc_le_read_def_data_len()
1979 hdev->le_def_tx_len = le16_to_cpu(rp->tx_len); in hci_cc_le_read_def_data_len()
1980 hdev->le_def_tx_time = le16_to_cpu(rp->tx_time); in hci_cc_le_read_def_data_len()
1982 return rp->status; in hci_cc_le_read_def_data_len()
1989 struct hci_ev_status *rp = data; in hci_cc_le_write_def_data_len() local
1991 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_write_def_data_len()
1993 if (rp->status) in hci_cc_le_write_def_data_len()
1994 return rp->status; in hci_cc_le_write_def_data_len()
1998 return rp->status; in hci_cc_le_write_def_data_len()
2000 hdev->le_def_tx_len = le16_to_cpu(sent->tx_len); in hci_cc_le_write_def_data_len()
2001 hdev->le_def_tx_time = le16_to_cpu(sent->tx_time); in hci_cc_le_write_def_data_len()
2003 return rp->status; in hci_cc_le_write_def_data_len()
2010 struct hci_ev_status *rp = data; in hci_cc_le_add_to_resolv_list() local
2012 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_add_to_resolv_list()
2014 if (rp->status) in hci_cc_le_add_to_resolv_list()
2015 return rp->status; in hci_cc_le_add_to_resolv_list()
2019 return rp->status; in hci_cc_le_add_to_resolv_list()
2022 hci_bdaddr_list_add_with_irk(&hdev->le_resolv_list, &sent->bdaddr, in hci_cc_le_add_to_resolv_list()
2023 sent->bdaddr_type, sent->peer_irk, in hci_cc_le_add_to_resolv_list()
2024 sent->local_irk); in hci_cc_le_add_to_resolv_list()
2027 return rp->status; in hci_cc_le_add_to_resolv_list()
2034 struct hci_ev_status *rp = data; in hci_cc_le_del_from_resolv_list() local
2036 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_del_from_resolv_list()
2038 if (rp->status) in hci_cc_le_del_from_resolv_list()
2039 return rp->status; in hci_cc_le_del_from_resolv_list()
2043 return rp->status; in hci_cc_le_del_from_resolv_list()
2046 hci_bdaddr_list_del_with_irk(&hdev->le_resolv_list, &sent->bdaddr, in hci_cc_le_del_from_resolv_list()
2047 sent->bdaddr_type); in hci_cc_le_del_from_resolv_list()
2050 return rp->status; in hci_cc_le_del_from_resolv_list()
2056 struct hci_ev_status *rp = data; in hci_cc_le_clear_resolv_list() local
2058 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_clear_resolv_list()
2060 if (rp->status) in hci_cc_le_clear_resolv_list()
2061 return rp->status; in hci_cc_le_clear_resolv_list()
2064 hci_bdaddr_list_clear(&hdev->le_resolv_list); in hci_cc_le_clear_resolv_list()
2067 return rp->status; in hci_cc_le_clear_resolv_list()
2073 struct hci_rp_le_read_resolv_list_size *rp = data; in hci_cc_le_read_resolv_list_size() local
2075 bt_dev_dbg(hdev, "status 0x%2.2x size %u", rp->status, rp->size); in hci_cc_le_read_resolv_list_size()
2077 if (rp->status) in hci_cc_le_read_resolv_list_size()
2078 return rp->status; in hci_cc_le_read_resolv_list_size()
2080 hdev->le_resolv_list_size = rp->size; in hci_cc_le_read_resolv_list_size()
2082 return rp->status; in hci_cc_le_read_resolv_list_size()
2088 struct hci_ev_status *rp = data; in hci_cc_le_set_addr_resolution_enable() local
2091 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_addr_resolution_enable()
2093 if (rp->status) in hci_cc_le_set_addr_resolution_enable()
2094 return rp->status; in hci_cc_le_set_addr_resolution_enable()
2098 return rp->status; in hci_cc_le_set_addr_resolution_enable()
2109 return rp->status; in hci_cc_le_set_addr_resolution_enable()
2115 struct hci_rp_le_read_max_data_len *rp = data; in hci_cc_le_read_max_data_len() local
2117 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_read_max_data_len()
2119 if (rp->status) in hci_cc_le_read_max_data_len()
2120 return rp->status; in hci_cc_le_read_max_data_len()
2122 hdev->le_max_tx_len = le16_to_cpu(rp->tx_len); in hci_cc_le_read_max_data_len()
2123 hdev->le_max_tx_time = le16_to_cpu(rp->tx_time); in hci_cc_le_read_max_data_len()
2124 hdev->le_max_rx_len = le16_to_cpu(rp->rx_len); in hci_cc_le_read_max_data_len()
2125 hdev->le_max_rx_time = le16_to_cpu(rp->rx_time); in hci_cc_le_read_max_data_len()
2127 return rp->status; in hci_cc_le_read_max_data_len()
2134 struct hci_ev_status *rp = data; in hci_cc_write_le_host_supported() local
2136 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_le_host_supported()
2138 if (rp->status) in hci_cc_write_le_host_supported()
2139 return rp->status; in hci_cc_write_le_host_supported()
2143 return rp->status; in hci_cc_write_le_host_supported()
2147 if (sent->le) { in hci_cc_write_le_host_supported()
2148 hdev->features[1][0] |= LMP_HOST_LE; in hci_cc_write_le_host_supported()
2151 hdev->features[1][0] &= ~LMP_HOST_LE; in hci_cc_write_le_host_supported()
2156 if (sent->simul) in hci_cc_write_le_host_supported()
2157 hdev->features[1][0] |= LMP_HOST_LE_BREDR; in hci_cc_write_le_host_supported()
2159 hdev->features[1][0] &= ~LMP_HOST_LE_BREDR; in hci_cc_write_le_host_supported()
2163 return rp->status; in hci_cc_write_le_host_supported()
2170 struct hci_ev_status *rp = data; in hci_cc_set_adv_param() local
2172 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_set_adv_param()
2174 if (rp->status) in hci_cc_set_adv_param()
2175 return rp->status; in hci_cc_set_adv_param()
2179 return rp->status; in hci_cc_set_adv_param()
2182 hdev->adv_addr_type = cp->own_address_type; in hci_cc_set_adv_param()
2185 return rp->status; in hci_cc_set_adv_param()
2191 struct hci_rp_le_set_ext_adv_params *rp = data; in hci_cc_set_ext_adv_param() local
2195 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_set_ext_adv_param()
2197 if (rp->status) in hci_cc_set_ext_adv_param()
2198 return rp->status; in hci_cc_set_ext_adv_param()
2202 return rp->status; in hci_cc_set_ext_adv_param()
2205 hdev->adv_addr_type = cp->own_addr_type; in hci_cc_set_ext_adv_param()
2206 if (!cp->handle) { in hci_cc_set_ext_adv_param()
2208 hdev->adv_tx_power = rp->tx_power; in hci_cc_set_ext_adv_param()
2210 adv_instance = hci_find_adv_instance(hdev, cp->handle); in hci_cc_set_ext_adv_param()
2212 adv_instance->tx_power = rp->tx_power; in hci_cc_set_ext_adv_param()
2215 hci_update_adv_data(hdev, cp->handle); in hci_cc_set_ext_adv_param()
2219 return rp->status; in hci_cc_set_ext_adv_param()
2225 struct hci_rp_read_rssi *rp = data; in hci_cc_read_rssi() local
2228 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_rssi()
2230 if (rp->status) in hci_cc_read_rssi()
2231 return rp->status; in hci_cc_read_rssi()
2235 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_rssi()
2237 conn->rssi = rp->rssi; in hci_cc_read_rssi()
2241 return rp->status; in hci_cc_read_rssi()
2248 struct hci_rp_read_tx_power *rp = data; in hci_cc_read_tx_power() local
2251 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_tx_power()
2253 if (rp->status) in hci_cc_read_tx_power()
2254 return rp->status; in hci_cc_read_tx_power()
2258 return rp->status; in hci_cc_read_tx_power()
2262 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_tx_power()
2266 switch (sent->type) { in hci_cc_read_tx_power()
2268 conn->tx_power = rp->tx_power; in hci_cc_read_tx_power()
2271 conn->max_tx_power = rp->tx_power; in hci_cc_read_tx_power()
2277 return rp->status; in hci_cc_read_tx_power()
2283 struct hci_ev_status *rp = data; in hci_cc_write_ssp_debug_mode() local
2286 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_ssp_debug_mode()
2288 if (rp->status) in hci_cc_write_ssp_debug_mode()
2289 return rp->status; in hci_cc_write_ssp_debug_mode()
2293 hdev->ssp_debug_mode = *mode; in hci_cc_write_ssp_debug_mode()
2295 return rp->status; in hci_cc_write_ssp_debug_mode()
2300 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_inquiry()
2307 set_bit(HCI_INQUIRY, &hdev->flags); in hci_cs_inquiry()
2315 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_create_conn()
2323 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cs_create_conn()
2325 bt_dev_dbg(hdev, "bdaddr %pMR hcon %p", &cp->bdaddr, conn); in hci_cs_create_conn()
2328 if (conn && conn->state == BT_CONNECT) { in hci_cs_create_conn()
2329 if (status != 0x0c || conn->attempt > 2) { in hci_cs_create_conn()
2330 conn->state = BT_CLOSED; in hci_cs_create_conn()
2334 conn->state = BT_CONNECT2; in hci_cs_create_conn()
2338 conn = hci_conn_add(hdev, ACL_LINK, &cp->bdaddr, in hci_cs_create_conn()
2355 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_add_sco()
2364 handle = __le16_to_cpu(cp->handle); in hci_cs_add_sco()
2366 bt_dev_dbg(hdev, "handle 0x%4.4x", handle); in hci_cs_add_sco()
2372 link = list_first_entry_or_null(&acl->link_list, in hci_cs_add_sco()
2374 if (link && link->conn) { in hci_cs_add_sco()
2375 link->conn->state = BT_CLOSED; in hci_cs_add_sco()
2377 hci_connect_cfm(link->conn, status); in hci_cs_add_sco()
2378 hci_conn_del(link->conn); in hci_cs_add_sco()
2390 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_auth_requested()
2401 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_auth_requested()
2403 if (conn->state == BT_CONFIG) { in hci_cs_auth_requested()
2417 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_set_conn_encrypt()
2428 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_set_conn_encrypt()
2430 if (conn->state == BT_CONFIG) { in hci_cs_set_conn_encrypt()
2442 if (conn->state != BT_CONFIG || !conn->out) in hci_outgoing_auth_needed()
2445 if (conn->pending_sec_level == BT_SECURITY_SDP) in hci_outgoing_auth_needed()
2448 /* Only request authentication for SSP connections or non-SSP in hci_outgoing_auth_needed()
2452 if (!hci_conn_ssp_enabled(conn) && !(conn->auth_type & 0x01) && in hci_outgoing_auth_needed()
2453 conn->pending_sec_level != BT_SECURITY_FIPS && in hci_outgoing_auth_needed()
2454 conn->pending_sec_level != BT_SECURITY_HIGH && in hci_outgoing_auth_needed()
2455 conn->pending_sec_level != BT_SECURITY_MEDIUM) in hci_outgoing_auth_needed()
2468 bacpy(&cp.bdaddr, &e->data.bdaddr); in hci_resolve_name()
2469 cp.pscan_rep_mode = e->data.pscan_rep_mode; in hci_resolve_name()
2470 cp.pscan_mode = e->data.pscan_mode; in hci_resolve_name()
2471 cp.clock_offset = e->data.clock_offset; in hci_resolve_name()
2478 struct discovery_state *discov = &hdev->discovery; in hci_resolve_next_name()
2481 if (list_empty(&discov->resolve)) in hci_resolve_next_name()
2485 if (time_after(jiffies, discov->name_resolve_timeout)) { in hci_resolve_next_name()
2495 e->name_state = NAME_PENDING; in hci_resolve_next_name()
2505 struct discovery_state *discov = &hdev->discovery; in hci_check_pending_name()
2514 (conn->state == BT_CONFIG || conn->state == BT_CONNECTED) && in hci_check_pending_name()
2515 !test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) in hci_check_pending_name()
2518 if (discov->state == DISCOVERY_STOPPED) in hci_check_pending_name()
2521 if (discov->state == DISCOVERY_STOPPING) in hci_check_pending_name()
2524 if (discov->state != DISCOVERY_RESOLVING) in hci_check_pending_name()
2535 list_del(&e->list); in hci_check_pending_name()
2537 e->name_state = name ? NAME_KNOWN : NAME_NOT_KNOWN; in hci_check_pending_name()
2538 mgmt_remote_name(hdev, bdaddr, ACL_LINK, 0x00, e->data.rssi, in hci_check_pending_name()
2553 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_remote_name_req()
2566 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cs_remote_name_req()
2569 hci_check_pending_name(hdev, conn, &cp->bdaddr, NULL, 0); in hci_cs_remote_name_req()
2577 if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->flags)) { in hci_cs_remote_name_req()
2580 set_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags); in hci_cs_remote_name_req()
2582 auth_cp.handle = __cpu_to_le16(conn->handle); in hci_cs_remote_name_req()
2596 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_read_remote_features()
2607 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_read_remote_features()
2609 if (conn->state == BT_CONFIG) { in hci_cs_read_remote_features()
2623 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_read_remote_ext_features()
2634 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_read_remote_ext_features()
2636 if (conn->state == BT_CONFIG) { in hci_cs_read_remote_ext_features()
2651 bt_dev_dbg(hdev, "handle 0x%4.4x status 0x%2.2x", handle, status); in hci_setup_sync_conn_status()
2657 link = list_first_entry_or_null(&acl->link_list, in hci_setup_sync_conn_status()
2659 if (link && link->conn) { in hci_setup_sync_conn_status()
2660 link->conn->state = BT_CLOSED; in hci_setup_sync_conn_status()
2662 hci_connect_cfm(link->conn, status); in hci_setup_sync_conn_status()
2663 hci_conn_del(link->conn); in hci_setup_sync_conn_status()
2674 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_setup_sync_conn()
2683 hci_setup_sync_conn_status(hdev, __le16_to_cpu(cp->handle), status); in hci_cs_setup_sync_conn()
2690 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_enhanced_setup_sync_conn()
2699 hci_setup_sync_conn_status(hdev, __le16_to_cpu(cp->handle), status); in hci_cs_enhanced_setup_sync_conn()
2707 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_sniff_mode()
2718 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_sniff_mode()
2720 clear_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->flags); in hci_cs_sniff_mode()
2722 if (test_and_clear_bit(HCI_CONN_SCO_SETUP_PEND, &conn->flags)) in hci_cs_sniff_mode()
2734 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_exit_sniff_mode()
2745 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_exit_sniff_mode()
2747 clear_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->flags); in hci_cs_exit_sniff_mode()
2749 if (test_and_clear_bit(HCI_CONN_SCO_SETUP_PEND, &conn->flags)) in hci_cs_exit_sniff_mode()
2763 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_disconnect()
2768 if (!status && !hdev->suspended) in hci_cs_disconnect()
2777 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_disconnect()
2782 mgmt_disconnect_failed(hdev, &conn->dst, conn->type, in hci_cs_disconnect()
2783 conn->dst_type, status); in hci_cs_disconnect()
2785 if (conn->type == LE_LINK && conn->role == HCI_ROLE_SLAVE) { in hci_cs_disconnect()
2786 hdev->cur_adv_instance = conn->adv_instance; in hci_cs_disconnect()
2796 mgmt_conn = test_and_clear_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags); in hci_cs_disconnect()
2798 if (conn->type == ACL_LINK) { in hci_cs_disconnect()
2799 if (test_and_clear_bit(HCI_CONN_FLUSH_KEY, &conn->flags)) in hci_cs_disconnect()
2800 hci_remove_link_key(hdev, &conn->dst); in hci_cs_disconnect()
2803 params = hci_conn_params_lookup(hdev, &conn->dst, conn->dst_type); in hci_cs_disconnect()
2805 switch (params->auto_connect) { in hci_cs_disconnect()
2807 if (cp->reason != HCI_ERROR_CONNECTION_TIMEOUT) in hci_cs_disconnect()
2814 hci_pend_le_list_add(params, &hdev->pend_le_conns); in hci_cs_disconnect()
2822 mgmt_device_disconnected(hdev, &conn->dst, conn->type, conn->dst_type, in hci_cs_disconnect()
2823 cp->reason, mgmt_conn); in hci_cs_disconnect()
2825 hci_disconn_cfm(conn, cp->reason); in hci_cs_disconnect()
2830 * Hence, we need to do some basic cleanup here and re-enable in hci_cs_disconnect()
2877 conn->init_addr_type = own_address_type; in cs_le_create_conn()
2879 bacpy(&conn->init_addr, &hdev->random_addr); in cs_le_create_conn()
2881 bacpy(&conn->init_addr, &hdev->bdaddr); in cs_le_create_conn()
2883 conn->resp_addr_type = peer_addr_type; in cs_le_create_conn()
2884 bacpy(&conn->resp_addr, peer_addr); in cs_le_create_conn()
2891 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_le_create_conn()
2906 cs_le_create_conn(hdev, &cp->peer_addr, cp->peer_addr_type, in hci_cs_le_create_conn()
2907 cp->own_address_type, cp->filter_policy); in hci_cs_le_create_conn()
2916 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_le_ext_create_conn()
2931 cs_le_create_conn(hdev, &cp->peer_addr, cp->peer_addr_type, in hci_cs_le_ext_create_conn()
2932 cp->own_addr_type, cp->filter_policy); in hci_cs_le_ext_create_conn()
2942 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_le_read_remote_features()
2953 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_le_read_remote_features()
2955 if (conn->state == BT_CONFIG) { in hci_cs_le_read_remote_features()
2969 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_le_start_enc()
2980 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_le_start_enc()
2984 if (conn->state != BT_CONNECTED) in hci_cs_le_start_enc()
2999 BT_DBG("%s status 0x%2.2x", hdev->name, status); in hci_cs_switch_role()
3010 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cs_switch_role()
3012 clear_bit(HCI_CONN_RSWITCH_PEND, &conn->flags); in hci_cs_switch_role()
3021 struct discovery_state *discov = &hdev->discovery; in hci_inquiry_complete_evt()
3024 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_inquiry_complete_evt()
3028 if (!test_and_clear_bit(HCI_INQUIRY, &hdev->flags)) in hci_inquiry_complete_evt()
3032 wake_up_bit(&hdev->flags, HCI_INQUIRY); in hci_inquiry_complete_evt()
3039 if (discov->state != DISCOVERY_FINDING) in hci_inquiry_complete_evt()
3042 if (list_empty(&discov->resolve)) { in hci_inquiry_complete_evt()
3051 !test_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks)) in hci_inquiry_complete_evt()
3058 e->name_state = NAME_PENDING; in hci_inquiry_complete_evt()
3060 discov->name_resolve_timeout = jiffies + NAME_RESOLVE_DURATION; in hci_inquiry_complete_evt()
3070 !test_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks)) in hci_inquiry_complete_evt()
3086 flex_array_size(ev, info, ev->num))) in hci_inquiry_result_evt()
3089 bt_dev_dbg(hdev, "num %d", ev->num); in hci_inquiry_result_evt()
3091 if (!ev->num) in hci_inquiry_result_evt()
3099 for (i = 0; i < ev->num; i++) { in hci_inquiry_result_evt()
3100 struct inquiry_info *info = &ev->info[i]; in hci_inquiry_result_evt()
3103 bacpy(&data.bdaddr, &info->bdaddr); in hci_inquiry_result_evt()
3104 data.pscan_rep_mode = info->pscan_rep_mode; in hci_inquiry_result_evt()
3105 data.pscan_period_mode = info->pscan_period_mode; in hci_inquiry_result_evt()
3106 data.pscan_mode = info->pscan_mode; in hci_inquiry_result_evt()
3107 memcpy(data.dev_class, info->dev_class, 3); in hci_inquiry_result_evt()
3108 data.clock_offset = info->clock_offset; in hci_inquiry_result_evt()
3114 mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, in hci_inquiry_result_evt()
3115 info->dev_class, HCI_RSSI_INVALID, in hci_inquiry_result_evt()
3127 u8 status = ev->status; in hci_conn_complete_evt()
3129 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_conn_complete_evt()
3133 conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, &ev->bdaddr); in hci_conn_complete_evt()
3138 if (ev->status) in hci_conn_complete_evt()
3141 /* Connection may not exist if auto-connected. Check the bredr in hci_conn_complete_evt()
3146 * Auto-connect will only occur if the event filter is in hci_conn_complete_evt()
3150 if (ev->link_type == ACL_LINK && in hci_conn_complete_evt()
3151 hci_bdaddr_list_lookup_with_flags(&hdev->accept_list, in hci_conn_complete_evt()
3152 &ev->bdaddr, in hci_conn_complete_evt()
3154 conn = hci_conn_add(hdev, ev->link_type, &ev->bdaddr, in hci_conn_complete_evt()
3161 if (ev->link_type != SCO_LINK) in hci_conn_complete_evt()
3165 &ev->bdaddr); in hci_conn_complete_evt()
3169 conn->type = SCO_LINK; in hci_conn_complete_evt()
3179 if (!HCI_CONN_HANDLE_UNSET(conn->handle)) { in hci_conn_complete_evt()
3185 status = hci_conn_set_handle(conn, __le16_to_cpu(ev->handle)); in hci_conn_complete_evt()
3189 if (conn->type == ACL_LINK) { in hci_conn_complete_evt()
3190 conn->state = BT_CONFIG; in hci_conn_complete_evt()
3193 if (!conn->out && !hci_conn_ssp_enabled(conn) && in hci_conn_complete_evt()
3194 !hci_find_link_key(hdev, &ev->bdaddr)) in hci_conn_complete_evt()
3195 conn->disc_timeout = HCI_PAIRING_TIMEOUT; in hci_conn_complete_evt()
3197 conn->disc_timeout = HCI_DISCONN_TIMEOUT; in hci_conn_complete_evt()
3199 conn->state = BT_CONNECTED; in hci_conn_complete_evt()
3204 if (test_bit(HCI_AUTH, &hdev->flags)) in hci_conn_complete_evt()
3205 set_bit(HCI_CONN_AUTH, &conn->flags); in hci_conn_complete_evt()
3207 if (test_bit(HCI_ENCRYPT, &hdev->flags)) in hci_conn_complete_evt()
3208 set_bit(HCI_CONN_ENCRYPT, &conn->flags); in hci_conn_complete_evt()
3211 if (conn->type == ACL_LINK) { in hci_conn_complete_evt()
3213 cp.handle = ev->handle; in hci_conn_complete_evt()
3221 if (!conn->out && hdev->hci_ver < BLUETOOTH_VER_2_0) { in hci_conn_complete_evt()
3223 cp.handle = ev->handle; in hci_conn_complete_evt()
3224 cp.pkt_type = cpu_to_le16(conn->pkt_type); in hci_conn_complete_evt()
3230 if (conn->type == ACL_LINK) in hci_conn_complete_evt()
3231 hci_sco_setup(conn, ev->status); in hci_conn_complete_evt()
3236 } else if (ev->link_type == SCO_LINK) { in hci_conn_complete_evt()
3237 switch (conn->setting & SCO_AIRMODE_MASK) { in hci_conn_complete_evt()
3239 if (hdev->notify) in hci_conn_complete_evt()
3240 hdev->notify(hdev, HCI_NOTIFY_ENABLE_SCO_CVSD); in hci_conn_complete_evt()
3266 int mask = hdev->link_mode; in hci_conn_request_evt()
3271 bt_dev_dbg(hdev, "bdaddr %pMR type 0x%x", &ev->bdaddr, ev->link_type); in hci_conn_request_evt()
3274 * CVE-2020-26555 in hci_conn_request_evt()
3276 if (hdev && !bacmp(&hdev->bdaddr, &ev->bdaddr)) { in hci_conn_request_evt()
3278 &ev->bdaddr); in hci_conn_request_evt()
3279 hci_reject_conn(hdev, &ev->bdaddr); in hci_conn_request_evt()
3283 mask |= hci_proto_connect_ind(hdev, &ev->bdaddr, ev->link_type, in hci_conn_request_evt()
3287 hci_reject_conn(hdev, &ev->bdaddr); in hci_conn_request_evt()
3293 if (hci_bdaddr_list_lookup(&hdev->reject_list, &ev->bdaddr, in hci_conn_request_evt()
3295 hci_reject_conn(hdev, &ev->bdaddr); in hci_conn_request_evt()
3305 !hci_bdaddr_list_lookup_with_flags(&hdev->accept_list, &ev->bdaddr, in hci_conn_request_evt()
3307 hci_reject_conn(hdev, &ev->bdaddr); in hci_conn_request_evt()
3313 ie = hci_inquiry_cache_lookup(hdev, &ev->bdaddr); in hci_conn_request_evt()
3315 memcpy(ie->data.dev_class, ev->dev_class, 3); in hci_conn_request_evt()
3317 conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, in hci_conn_request_evt()
3318 &ev->bdaddr); in hci_conn_request_evt()
3320 conn = hci_conn_add(hdev, ev->link_type, &ev->bdaddr, in hci_conn_request_evt()
3328 memcpy(conn->dev_class, ev->dev_class, 3); in hci_conn_request_evt()
3332 if (ev->link_type == ACL_LINK || in hci_conn_request_evt()
3335 conn->state = BT_CONNECT; in hci_conn_request_evt()
3337 bacpy(&cp.bdaddr, &ev->bdaddr); in hci_conn_request_evt()
3347 conn->state = BT_CONNECT; in hci_conn_request_evt()
3349 bacpy(&cp.bdaddr, &ev->bdaddr); in hci_conn_request_evt()
3350 cp.pkt_type = cpu_to_le16(conn->pkt_type); in hci_conn_request_evt()
3355 cp.content_format = cpu_to_le16(hdev->voice_setting); in hci_conn_request_evt()
3361 conn->state = BT_CONNECT2; in hci_conn_request_evt()
3395 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_disconn_complete_evt()
3399 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_disconn_complete_evt()
3403 if (ev->status) { in hci_disconn_complete_evt()
3404 mgmt_disconnect_failed(hdev, &conn->dst, conn->type, in hci_disconn_complete_evt()
3405 conn->dst_type, ev->status); in hci_disconn_complete_evt()
3409 conn->state = BT_CLOSED; in hci_disconn_complete_evt()
3411 mgmt_connected = test_and_clear_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags); in hci_disconn_complete_evt()
3413 if (test_bit(HCI_CONN_AUTH_FAILURE, &conn->flags)) in hci_disconn_complete_evt()
3416 reason = hci_to_mgmt_reason(ev->reason); in hci_disconn_complete_evt()
3418 mgmt_device_disconnected(hdev, &conn->dst, conn->type, conn->dst_type, in hci_disconn_complete_evt()
3421 if (conn->type == ACL_LINK) { in hci_disconn_complete_evt()
3422 if (test_and_clear_bit(HCI_CONN_FLUSH_KEY, &conn->flags)) in hci_disconn_complete_evt()
3423 hci_remove_link_key(hdev, &conn->dst); in hci_disconn_complete_evt()
3428 params = hci_conn_params_lookup(hdev, &conn->dst, conn->dst_type); in hci_disconn_complete_evt()
3430 switch (params->auto_connect) { in hci_disconn_complete_evt()
3432 if (ev->reason != HCI_ERROR_CONNECTION_TIMEOUT) in hci_disconn_complete_evt()
3439 hci_pend_le_list_add(params, &hdev->pend_le_conns); in hci_disconn_complete_evt()
3448 hci_disconn_cfm(conn, ev->reason); in hci_disconn_complete_evt()
3450 /* Re-enable advertising if necessary, since it might in hci_disconn_complete_evt()
3460 if (conn->type == LE_LINK && conn->role == HCI_ROLE_SLAVE) { in hci_disconn_complete_evt()
3461 hdev->cur_adv_instance = conn->adv_instance; in hci_disconn_complete_evt()
3477 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_auth_complete_evt()
3481 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_auth_complete_evt()
3485 if (!ev->status) { in hci_auth_complete_evt()
3486 clear_bit(HCI_CONN_AUTH_FAILURE, &conn->flags); in hci_auth_complete_evt()
3489 test_bit(HCI_CONN_REAUTH_PEND, &conn->flags)) { in hci_auth_complete_evt()
3490 bt_dev_info(hdev, "re-auth of legacy device is not possible."); in hci_auth_complete_evt()
3492 set_bit(HCI_CONN_AUTH, &conn->flags); in hci_auth_complete_evt()
3493 conn->sec_level = conn->pending_sec_level; in hci_auth_complete_evt()
3496 if (ev->status == HCI_ERROR_PIN_OR_KEY_MISSING) in hci_auth_complete_evt()
3497 set_bit(HCI_CONN_AUTH_FAILURE, &conn->flags); in hci_auth_complete_evt()
3499 mgmt_auth_failed(conn, ev->status); in hci_auth_complete_evt()
3502 clear_bit(HCI_CONN_AUTH_PEND, &conn->flags); in hci_auth_complete_evt()
3503 clear_bit(HCI_CONN_REAUTH_PEND, &conn->flags); in hci_auth_complete_evt()
3505 if (conn->state == BT_CONFIG) { in hci_auth_complete_evt()
3506 if (!ev->status && hci_conn_ssp_enabled(conn)) { in hci_auth_complete_evt()
3508 cp.handle = ev->handle; in hci_auth_complete_evt()
3513 conn->state = BT_CONNECTED; in hci_auth_complete_evt()
3514 hci_connect_cfm(conn, ev->status); in hci_auth_complete_evt()
3518 hci_auth_cfm(conn, ev->status); in hci_auth_complete_evt()
3521 conn->disc_timeout = HCI_DISCONN_TIMEOUT; in hci_auth_complete_evt()
3525 if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags)) { in hci_auth_complete_evt()
3526 if (!ev->status) { in hci_auth_complete_evt()
3528 cp.handle = ev->handle; in hci_auth_complete_evt()
3533 clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags); in hci_auth_complete_evt()
3534 hci_encrypt_cfm(conn, ev->status); in hci_auth_complete_evt()
3548 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_remote_name_evt()
3554 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_remote_name_evt()
3559 if (ev->status == 0) in hci_remote_name_evt()
3560 hci_check_pending_name(hdev, conn, &ev->bdaddr, ev->name, in hci_remote_name_evt()
3561 strnlen(ev->name, HCI_MAX_NAME_LENGTH)); in hci_remote_name_evt()
3563 hci_check_pending_name(hdev, conn, &ev->bdaddr, NULL, 0); in hci_remote_name_evt()
3572 if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->flags)) { in hci_remote_name_evt()
3575 set_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags); in hci_remote_name_evt()
3577 cp.handle = __cpu_to_le16(conn->handle); in hci_remote_name_evt()
3591 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_encrypt_change_evt()
3595 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_encrypt_change_evt()
3599 if (!ev->status) { in hci_encrypt_change_evt()
3600 if (ev->encrypt) { in hci_encrypt_change_evt()
3602 set_bit(HCI_CONN_AUTH, &conn->flags); in hci_encrypt_change_evt()
3603 set_bit(HCI_CONN_ENCRYPT, &conn->flags); in hci_encrypt_change_evt()
3604 conn->sec_level = conn->pending_sec_level; in hci_encrypt_change_evt()
3606 /* P-256 authentication key implies FIPS */ in hci_encrypt_change_evt()
3607 if (conn->key_type == HCI_LK_AUTH_COMBINATION_P256) in hci_encrypt_change_evt()
3608 set_bit(HCI_CONN_FIPS, &conn->flags); in hci_encrypt_change_evt()
3610 if ((conn->type == ACL_LINK && ev->encrypt == 0x02) || in hci_encrypt_change_evt()
3611 conn->type == LE_LINK) in hci_encrypt_change_evt()
3612 set_bit(HCI_CONN_AES_CCM, &conn->flags); in hci_encrypt_change_evt()
3614 clear_bit(HCI_CONN_ENCRYPT, &conn->flags); in hci_encrypt_change_evt()
3615 clear_bit(HCI_CONN_AES_CCM, &conn->flags); in hci_encrypt_change_evt()
3622 if (ev->status && conn->type == LE_LINK) { in hci_encrypt_change_evt()
3627 clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags); in hci_encrypt_change_evt()
3631 ev->status = HCI_ERROR_AUTH_FAILURE; in hci_encrypt_change_evt()
3633 if (ev->status && conn->state == BT_CONNECTED) { in hci_encrypt_change_evt()
3634 if (ev->status == HCI_ERROR_PIN_OR_KEY_MISSING) in hci_encrypt_change_evt()
3635 set_bit(HCI_CONN_AUTH_FAILURE, &conn->flags); in hci_encrypt_change_evt()
3640 hci_encrypt_cfm(conn, ev->status); in hci_encrypt_change_evt()
3647 if (!ev->status && ev->encrypt && conn->type == ACL_LINK) { in hci_encrypt_change_evt()
3654 if (!(hdev->commands[20] & 0x10)) { in hci_encrypt_change_evt()
3655 conn->enc_key_size = HCI_LINK_KEY_SIZE; in hci_encrypt_change_evt()
3659 cp.handle = cpu_to_le16(conn->handle); in hci_encrypt_change_evt()
3663 conn->enc_key_size = HCI_LINK_KEY_SIZE; in hci_encrypt_change_evt()
3675 * Ensure for AES-CCM encryption as well. in hci_encrypt_change_evt()
3677 if (test_bit(HCI_CONN_ENCRYPT, &conn->flags) && in hci_encrypt_change_evt()
3678 test_bit(HCI_CONN_AES_CCM, &conn->flags) && in hci_encrypt_change_evt()
3679 ((conn->type == ACL_LINK && lmp_ping_capable(hdev)) || in hci_encrypt_change_evt()
3680 (conn->type == LE_LINK && (hdev->le_features[0] & HCI_LE_PING)))) { in hci_encrypt_change_evt()
3683 cp.handle = cpu_to_le16(conn->handle); in hci_encrypt_change_evt()
3684 cp.timeout = cpu_to_le16(hdev->auth_payload_timeout); in hci_encrypt_change_evt()
3685 if (hci_send_cmd(conn->hdev, HCI_OP_WRITE_AUTH_PAYLOAD_TO, in hci_encrypt_change_evt()
3695 hci_encrypt_cfm(conn, ev->status); in hci_encrypt_change_evt()
3707 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_change_link_key_complete_evt()
3711 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_change_link_key_complete_evt()
3713 if (!ev->status) in hci_change_link_key_complete_evt()
3714 set_bit(HCI_CONN_SECURE, &conn->flags); in hci_change_link_key_complete_evt()
3716 clear_bit(HCI_CONN_AUTH_PEND, &conn->flags); in hci_change_link_key_complete_evt()
3718 hci_key_change_cfm(conn, ev->status); in hci_change_link_key_complete_evt()
3730 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_remote_features_evt()
3734 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_remote_features_evt()
3738 if (!ev->status) in hci_remote_features_evt()
3739 memcpy(conn->features[0], ev->features, 8); in hci_remote_features_evt()
3741 if (conn->state != BT_CONFIG) in hci_remote_features_evt()
3744 if (!ev->status && lmp_ext_feat_capable(hdev) && in hci_remote_features_evt()
3747 cp.handle = ev->handle; in hci_remote_features_evt()
3754 if (!ev->status && !test_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) { in hci_remote_features_evt()
3757 bacpy(&cp.bdaddr, &conn->dst); in hci_remote_features_evt()
3760 } else if (!test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) in hci_remote_features_evt()
3764 conn->state = BT_CONNECTED; in hci_remote_features_evt()
3765 hci_connect_cfm(conn, ev->status); in hci_remote_features_evt()
3775 cancel_delayed_work(&hdev->cmd_timer); in handle_cmd_cnt_and_timer()
3778 if (!test_bit(HCI_RESET, &hdev->flags)) { in handle_cmd_cnt_and_timer()
3780 cancel_delayed_work(&hdev->ncmd_timer); in handle_cmd_cnt_and_timer()
3781 atomic_set(&hdev->cmd_cnt, 1); in handle_cmd_cnt_and_timer()
3784 queue_delayed_work(hdev->workqueue, &hdev->ncmd_timer, in handle_cmd_cnt_and_timer()
3794 struct hci_rp_le_read_buffer_size_v2 *rp = data; in hci_cc_le_read_buffer_size_v2() local
3796 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_read_buffer_size_v2()
3798 if (rp->status) in hci_cc_le_read_buffer_size_v2()
3799 return rp->status; in hci_cc_le_read_buffer_size_v2()
3801 hdev->le_mtu = __le16_to_cpu(rp->acl_mtu); in hci_cc_le_read_buffer_size_v2()
3802 hdev->le_pkts = rp->acl_max_pkt; in hci_cc_le_read_buffer_size_v2()
3803 hdev->iso_mtu = __le16_to_cpu(rp->iso_mtu); in hci_cc_le_read_buffer_size_v2()
3804 hdev->iso_pkts = rp->iso_max_pkt; in hci_cc_le_read_buffer_size_v2()
3806 hdev->le_cnt = hdev->le_pkts; in hci_cc_le_read_buffer_size_v2()
3807 hdev->iso_cnt = hdev->iso_pkts; in hci_cc_le_read_buffer_size_v2()
3809 BT_DBG("%s acl mtu %d:%d iso mtu %d:%d", hdev->name, hdev->acl_mtu, in hci_cc_le_read_buffer_size_v2()
3810 hdev->acl_pkts, hdev->iso_mtu, hdev->iso_pkts); in hci_cc_le_read_buffer_size_v2()
3812 return rp->status; in hci_cc_le_read_buffer_size_v2()
3819 lockdep_assert_held(&hdev->lock); in hci_unbound_cis_failed()
3821 list_for_each_entry_safe(conn, tmp, &hdev->conn_hash.list, list) { in hci_unbound_cis_failed()
3822 if (conn->type != ISO_LINK || !bacmp(&conn->dst, BDADDR_ANY) || in hci_unbound_cis_failed()
3823 conn->state == BT_OPEN || conn->iso_qos.ucast.cig != cig) in hci_unbound_cis_failed()
3826 if (HCI_CONN_HANDLE_UNSET(conn->handle)) in hci_unbound_cis_failed()
3834 struct hci_rp_le_set_cig_params *rp = data; in hci_cc_le_set_cig_params() local
3837 u8 status = rp->status; in hci_cc_le_set_cig_params()
3841 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_cig_params()
3844 if (!rp->status && (!cp || rp->num_handles != cp->num_cis || in hci_cc_le_set_cig_params()
3845 rp->cig_id != cp->cig_id)) { in hci_cc_le_set_cig_params()
3854 * If the Status return parameter is non-zero, then the state of the CIG in hci_cc_le_set_cig_params()
3860 hci_unbound_cis_failed(hdev, rp->cig_id, status); in hci_cc_le_set_cig_params()
3871 for (i = 0; i < rp->num_handles; ++i) { in hci_cc_le_set_cig_params()
3872 conn = hci_conn_hash_lookup_cis(hdev, NULL, 0, rp->cig_id, in hci_cc_le_set_cig_params()
3873 cp->cis[i].cis_id); in hci_cc_le_set_cig_params()
3874 if (!conn || !bacmp(&conn->dst, BDADDR_ANY)) in hci_cc_le_set_cig_params()
3877 if (conn->state != BT_BOUND && conn->state != BT_CONNECT) in hci_cc_le_set_cig_params()
3880 if (hci_conn_set_handle(conn, __le16_to_cpu(rp->handle[i]))) in hci_cc_le_set_cig_params()
3883 if (conn->state == BT_CONNECT) in hci_cc_le_set_cig_params()
3893 return rp->status; in hci_cc_le_set_cig_params()
3899 struct hci_rp_le_setup_iso_path *rp = data; in hci_cc_le_setup_iso_path() local
3903 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_setup_iso_path()
3907 return rp->status; in hci_cc_le_setup_iso_path()
3911 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cc_le_setup_iso_path()
3915 if (rp->status) { in hci_cc_le_setup_iso_path()
3916 hci_connect_cfm(conn, rp->status); in hci_cc_le_setup_iso_path()
3921 switch (cp->direction) { in hci_cc_le_setup_iso_path()
3925 if (conn->iso_qos.ucast.out.sdu && !conn->iso_qos.ucast.in.sdu) in hci_cc_le_setup_iso_path()
3926 hci_connect_cfm(conn, rp->status); in hci_cc_le_setup_iso_path()
3930 /* Confirm connection since conn->iso_qos is always configured in hci_cc_le_setup_iso_path()
3933 hci_connect_cfm(conn, rp->status); in hci_cc_le_setup_iso_path()
3939 return rp->status; in hci_cc_le_setup_iso_path()
3944 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_le_create_big()
3950 struct hci_ev_status *rp = data; in hci_cc_set_per_adv_param() local
3953 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_set_per_adv_param()
3955 if (rp->status) in hci_cc_set_per_adv_param()
3956 return rp->status; in hci_cc_set_per_adv_param()
3960 return rp->status; in hci_cc_set_per_adv_param()
3963 return rp->status; in hci_cc_set_per_adv_param()
3969 struct hci_ev_status *rp = data; in hci_cc_le_set_per_adv_enable() local
3974 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_per_adv_enable()
3976 if (rp->status) in hci_cc_le_set_per_adv_enable()
3977 return rp->status; in hci_cc_le_set_per_adv_enable()
3981 return rp->status; in hci_cc_le_set_per_adv_enable()
3985 adv = hci_find_adv_instance(hdev, cp->handle); in hci_cc_le_set_per_adv_enable()
3987 if (cp->enable) { in hci_cc_le_set_per_adv_enable()
3991 adv->enabled = true; in hci_cc_le_set_per_adv_enable()
3998 list_for_each_entry_safe(adv, n, &hdev->adv_instances, in hci_cc_le_set_per_adv_enable()
4000 if (adv->periodic && adv->enabled) in hci_cc_le_set_per_adv_enable()
4013 return rp->status; in hci_cc_le_set_per_adv_enable()
4210 if (skb->len < cc->min_len) { in hci_cc_func()
4211 bt_dev_err(hdev, "unexpected cc 0x%4.4x length: %u < %u", in hci_cc_func()
4212 cc->op, skb->len, cc->min_len); in hci_cc_func()
4220 if (skb->len > cc->max_len) in hci_cc_func()
4221 bt_dev_warn(hdev, "unexpected cc 0x%4.4x length: %u > %u", in hci_cc_func()
4222 cc->op, skb->len, cc->max_len); in hci_cc_func()
4224 data = hci_cc_skb_pull(hdev, skb, cc->op, cc->min_len); in hci_cc_func()
4228 return cc->func(hdev, data, skb); in hci_cc_func()
4239 *opcode = __le16_to_cpu(ev->opcode); in hci_cmd_complete_evt()
4241 bt_dev_dbg(hdev, "opcode 0x%4.4x", *opcode); in hci_cmd_complete_evt()
4258 *status = skb->data[0]; in hci_cmd_complete_evt()
4261 handle_cmd_cnt_and_timer(hdev, ev->ncmd); in hci_cmd_complete_evt()
4268 "unexpected event for opcode 0x%4.4x", *opcode); in hci_cmd_complete_evt()
4272 if (atomic_read(&hdev->cmd_cnt) && !skb_queue_empty(&hdev->cmd_q)) in hci_cmd_complete_evt()
4273 queue_work(hdev->workqueue, &hdev->cmd_work); in hci_cmd_complete_evt()
4282 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_le_create_cis()
4294 for (i = 0; cp->num_cis; cp->num_cis--, i++) { in hci_cs_le_create_cis()
4298 handle = __le16_to_cpu(cp->cis[i].cis_handle); in hci_cs_le_create_cis()
4303 &conn->flags)) in hci_cs_le_create_cis()
4305 conn->state = BT_CLOSED; in hci_cs_le_create_cis()
4359 *opcode = __le16_to_cpu(ev->opcode); in hci_cmd_status_evt()
4360 *status = ev->status; in hci_cmd_status_evt()
4362 bt_dev_dbg(hdev, "opcode 0x%4.4x", *opcode); in hci_cmd_status_evt()
4366 hci_cs_table[i].func(hdev, ev->status); in hci_cmd_status_evt()
4371 handle_cmd_cnt_and_timer(hdev, ev->ncmd); in hci_cmd_status_evt()
4379 if (ev->status || (hdev->sent_cmd && !hci_skb_event(hdev->sent_cmd))) { in hci_cmd_status_evt()
4380 hci_req_cmd_complete(hdev, *opcode, ev->status, req_complete, in hci_cmd_status_evt()
4383 bt_dev_err(hdev, "unexpected event for opcode 0x%4.4x", in hci_cmd_status_evt()
4389 if (atomic_read(&hdev->cmd_cnt) && !skb_queue_empty(&hdev->cmd_q)) in hci_cmd_status_evt()
4390 queue_work(hdev->workqueue, &hdev->cmd_work); in hci_cmd_status_evt()
4398 bt_dev_dbg(hdev, "code 0x%2.2x", ev->code); in hci_hardware_error_evt()
4400 hdev->hw_error_code = ev->code; in hci_hardware_error_evt()
4402 queue_work(hdev->req_workqueue, &hdev->error_reset); in hci_hardware_error_evt()
4411 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_role_change_evt()
4415 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_role_change_evt()
4417 if (!ev->status) in hci_role_change_evt()
4418 conn->role = ev->role; in hci_role_change_evt()
4420 clear_bit(HCI_CONN_RSWITCH_PEND, &conn->flags); in hci_role_change_evt()
4422 hci_role_switch_cfm(conn, ev->status, ev->role); in hci_role_change_evt()
4435 flex_array_size(ev, handles, ev->num))) in hci_num_comp_pkts_evt()
4438 if (hdev->flow_ctl_mode != HCI_FLOW_CTL_MODE_PACKET_BASED) { in hci_num_comp_pkts_evt()
4439 bt_dev_err(hdev, "wrong event for mode %d", hdev->flow_ctl_mode); in hci_num_comp_pkts_evt()
4443 bt_dev_dbg(hdev, "num %d", ev->num); in hci_num_comp_pkts_evt()
4445 for (i = 0; i < ev->num; i++) { in hci_num_comp_pkts_evt()
4446 struct hci_comp_pkts_info *info = &ev->handles[i]; in hci_num_comp_pkts_evt()
4450 handle = __le16_to_cpu(info->handle); in hci_num_comp_pkts_evt()
4451 count = __le16_to_cpu(info->count); in hci_num_comp_pkts_evt()
4457 conn->sent -= count; in hci_num_comp_pkts_evt()
4459 switch (conn->type) { in hci_num_comp_pkts_evt()
4461 hdev->acl_cnt += count; in hci_num_comp_pkts_evt()
4462 if (hdev->acl_cnt > hdev->acl_pkts) in hci_num_comp_pkts_evt()
4463 hdev->acl_cnt = hdev->acl_pkts; in hci_num_comp_pkts_evt()
4467 if (hdev->le_pkts) { in hci_num_comp_pkts_evt()
4468 hdev->le_cnt += count; in hci_num_comp_pkts_evt()
4469 if (hdev->le_cnt > hdev->le_pkts) in hci_num_comp_pkts_evt()
4470 hdev->le_cnt = hdev->le_pkts; in hci_num_comp_pkts_evt()
4472 hdev->acl_cnt += count; in hci_num_comp_pkts_evt()
4473 if (hdev->acl_cnt > hdev->acl_pkts) in hci_num_comp_pkts_evt()
4474 hdev->acl_cnt = hdev->acl_pkts; in hci_num_comp_pkts_evt()
4479 hdev->sco_cnt += count; in hci_num_comp_pkts_evt()
4480 if (hdev->sco_cnt > hdev->sco_pkts) in hci_num_comp_pkts_evt()
4481 hdev->sco_cnt = hdev->sco_pkts; in hci_num_comp_pkts_evt()
4485 if (hdev->iso_pkts) { in hci_num_comp_pkts_evt()
4486 hdev->iso_cnt += count; in hci_num_comp_pkts_evt()
4487 if (hdev->iso_cnt > hdev->iso_pkts) in hci_num_comp_pkts_evt()
4488 hdev->iso_cnt = hdev->iso_pkts; in hci_num_comp_pkts_evt()
4489 } else if (hdev->le_pkts) { in hci_num_comp_pkts_evt()
4490 hdev->le_cnt += count; in hci_num_comp_pkts_evt()
4491 if (hdev->le_cnt > hdev->le_pkts) in hci_num_comp_pkts_evt()
4492 hdev->le_cnt = hdev->le_pkts; in hci_num_comp_pkts_evt()
4494 hdev->acl_cnt += count; in hci_num_comp_pkts_evt()
4495 if (hdev->acl_cnt > hdev->acl_pkts) in hci_num_comp_pkts_evt()
4496 hdev->acl_cnt = hdev->acl_pkts; in hci_num_comp_pkts_evt()
4502 conn->type, conn); in hci_num_comp_pkts_evt()
4507 queue_work(hdev->workqueue, &hdev->tx_work); in hci_num_comp_pkts_evt()
4515 switch (hdev->dev_type) { in __hci_conn_lookup_handle()
4521 return chan->conn; in __hci_conn_lookup_handle()
4524 bt_dev_err(hdev, "unknown dev_type %d", hdev->dev_type); in __hci_conn_lookup_handle()
4538 flex_array_size(ev, handles, ev->num_hndl))) in hci_num_comp_blocks_evt()
4541 if (hdev->flow_ctl_mode != HCI_FLOW_CTL_MODE_BLOCK_BASED) { in hci_num_comp_blocks_evt()
4543 hdev->flow_ctl_mode); in hci_num_comp_blocks_evt()
4547 bt_dev_dbg(hdev, "num_blocks %d num_hndl %d", ev->num_blocks, in hci_num_comp_blocks_evt()
4548 ev->num_hndl); in hci_num_comp_blocks_evt()
4550 for (i = 0; i < ev->num_hndl; i++) { in hci_num_comp_blocks_evt()
4551 struct hci_comp_blocks_info *info = &ev->handles[i]; in hci_num_comp_blocks_evt()
4555 handle = __le16_to_cpu(info->handle); in hci_num_comp_blocks_evt()
4556 block_count = __le16_to_cpu(info->blocks); in hci_num_comp_blocks_evt()
4562 conn->sent -= block_count; in hci_num_comp_blocks_evt()
4564 switch (conn->type) { in hci_num_comp_blocks_evt()
4567 hdev->block_cnt += block_count; in hci_num_comp_blocks_evt()
4568 if (hdev->block_cnt > hdev->num_blocks) in hci_num_comp_blocks_evt()
4569 hdev->block_cnt = hdev->num_blocks; in hci_num_comp_blocks_evt()
4574 conn->type, conn); in hci_num_comp_blocks_evt()
4579 queue_work(hdev->workqueue, &hdev->tx_work); in hci_num_comp_blocks_evt()
4588 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_mode_change_evt()
4592 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_mode_change_evt()
4594 conn->mode = ev->mode; in hci_mode_change_evt()
4597 &conn->flags)) { in hci_mode_change_evt()
4598 if (conn->mode == HCI_CM_ACTIVE) in hci_mode_change_evt()
4599 set_bit(HCI_CONN_POWER_SAVE, &conn->flags); in hci_mode_change_evt()
4601 clear_bit(HCI_CONN_POWER_SAVE, &conn->flags); in hci_mode_change_evt()
4604 if (test_and_clear_bit(HCI_CONN_SCO_SETUP_PEND, &conn->flags)) in hci_mode_change_evt()
4605 hci_sco_setup(conn, ev->status); in hci_mode_change_evt()
4621 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_pin_code_request_evt()
4625 if (conn->state == BT_CONNECTED) { in hci_pin_code_request_evt()
4627 conn->disc_timeout = HCI_PAIRING_TIMEOUT; in hci_pin_code_request_evt()
4632 !test_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags)) { in hci_pin_code_request_evt()
4634 sizeof(ev->bdaddr), &ev->bdaddr); in hci_pin_code_request_evt()
4638 if (conn->pending_sec_level == BT_SECURITY_HIGH) in hci_pin_code_request_evt()
4643 mgmt_pin_code_request(hdev, &ev->bdaddr, secure); in hci_pin_code_request_evt()
4655 conn->pin_length = pin_len; in conn_set_key()
4656 conn->key_type = key_type; in conn_set_key()
4665 conn->pending_sec_level = BT_SECURITY_HIGH; in conn_set_key()
4667 conn->pending_sec_level = BT_SECURITY_MEDIUM; in conn_set_key()
4671 conn->pending_sec_level = BT_SECURITY_MEDIUM; in conn_set_key()
4674 conn->pending_sec_level = BT_SECURITY_HIGH; in conn_set_key()
4677 conn->pending_sec_level = BT_SECURITY_FIPS; in conn_set_key()
4697 key = hci_find_link_key(hdev, &ev->bdaddr); in hci_link_key_request_evt()
4699 bt_dev_dbg(hdev, "link key not found for %pMR", &ev->bdaddr); in hci_link_key_request_evt()
4703 bt_dev_dbg(hdev, "found key type %u for %pMR", key->type, &ev->bdaddr); in hci_link_key_request_evt()
4705 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_link_key_request_evt()
4707 clear_bit(HCI_CONN_NEW_LINK_KEY, &conn->flags); in hci_link_key_request_evt()
4709 if ((key->type == HCI_LK_UNAUTH_COMBINATION_P192 || in hci_link_key_request_evt()
4710 key->type == HCI_LK_UNAUTH_COMBINATION_P256) && in hci_link_key_request_evt()
4711 conn->auth_type != 0xff && (conn->auth_type & 0x01)) { in hci_link_key_request_evt()
4716 if (key->type == HCI_LK_COMBINATION && key->pin_len < 16 && in hci_link_key_request_evt()
4717 (conn->pending_sec_level == BT_SECURITY_HIGH || in hci_link_key_request_evt()
4718 conn->pending_sec_level == BT_SECURITY_FIPS)) { in hci_link_key_request_evt()
4723 conn_set_key(conn, key->type, key->pin_len); in hci_link_key_request_evt()
4726 bacpy(&cp.bdaddr, &ev->bdaddr); in hci_link_key_request_evt()
4727 memcpy(cp.link_key, key->val, HCI_LINK_KEY_SIZE); in hci_link_key_request_evt()
4736 hci_send_cmd(hdev, HCI_OP_LINK_KEY_NEG_REPLY, 6, &ev->bdaddr); in hci_link_key_request_evt()
4753 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_link_key_notify_evt()
4757 /* Ignore NULL link key against CVE-2020-26555 */ in hci_link_key_notify_evt()
4758 if (!crypto_memneq(ev->link_key, ZERO_KEY, HCI_LINK_KEY_SIZE)) { in hci_link_key_notify_evt()
4760 &ev->bdaddr); in hci_link_key_notify_evt()
4767 conn->disc_timeout = HCI_DISCONN_TIMEOUT; in hci_link_key_notify_evt()
4770 set_bit(HCI_CONN_NEW_LINK_KEY, &conn->flags); in hci_link_key_notify_evt()
4771 conn_set_key(conn, ev->key_type, conn->pin_length); in hci_link_key_notify_evt()
4776 key = hci_add_link_key(hdev, conn, &ev->bdaddr, ev->link_key, in hci_link_key_notify_evt()
4777 ev->key_type, pin_len, &persistent); in hci_link_key_notify_evt()
4784 if (ev->key_type == HCI_LK_CHANGED_COMBINATION) in hci_link_key_notify_evt()
4785 conn_set_key(conn, key->type, key->pin_len); in hci_link_key_notify_evt()
4794 if (key->type == HCI_LK_DEBUG_COMBINATION && in hci_link_key_notify_evt()
4796 list_del_rcu(&key->list); in hci_link_key_notify_evt()
4802 clear_bit(HCI_CONN_FLUSH_KEY, &conn->flags); in hci_link_key_notify_evt()
4804 set_bit(HCI_CONN_FLUSH_KEY, &conn->flags); in hci_link_key_notify_evt()
4816 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_clock_offset_evt()
4820 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_clock_offset_evt()
4821 if (conn && !ev->status) { in hci_clock_offset_evt()
4824 ie = hci_inquiry_cache_lookup(hdev, &conn->dst); in hci_clock_offset_evt()
4826 ie->data.clock_offset = ev->clock_offset; in hci_clock_offset_evt()
4827 ie->timestamp = jiffies; in hci_clock_offset_evt()
4840 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_pkt_type_change_evt()
4844 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_pkt_type_change_evt()
4845 if (conn && !ev->status) in hci_pkt_type_change_evt()
4846 conn->pkt_type = __le16_to_cpu(ev->pkt_type); in hci_pkt_type_change_evt()
4861 ie = hci_inquiry_cache_lookup(hdev, &ev->bdaddr); in hci_pscan_rep_mode_evt()
4863 ie->data.pscan_rep_mode = ev->pscan_rep_mode; in hci_pscan_rep_mode_evt()
4864 ie->timestamp = jiffies; in hci_pscan_rep_mode_evt()
4877 bt_dev_dbg(hdev, "num_rsp %d", ev->num); in hci_inquiry_result_with_rssi_evt()
4879 if (!ev->num) in hci_inquiry_result_with_rssi_evt()
4887 if (skb->len == array_size(ev->num, in hci_inquiry_result_with_rssi_evt()
4891 for (i = 0; i < ev->num; i++) { in hci_inquiry_result_with_rssi_evt()
4898 bt_dev_err(hdev, "Malformed HCI Event: 0x%2.2x", in hci_inquiry_result_with_rssi_evt()
4903 bacpy(&data.bdaddr, &info->bdaddr); in hci_inquiry_result_with_rssi_evt()
4904 data.pscan_rep_mode = info->pscan_rep_mode; in hci_inquiry_result_with_rssi_evt()
4905 data.pscan_period_mode = info->pscan_period_mode; in hci_inquiry_result_with_rssi_evt()
4906 data.pscan_mode = info->pscan_mode; in hci_inquiry_result_with_rssi_evt()
4907 memcpy(data.dev_class, info->dev_class, 3); in hci_inquiry_result_with_rssi_evt()
4908 data.clock_offset = info->clock_offset; in hci_inquiry_result_with_rssi_evt()
4909 data.rssi = info->rssi; in hci_inquiry_result_with_rssi_evt()
4914 mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, in hci_inquiry_result_with_rssi_evt()
4915 info->dev_class, info->rssi, in hci_inquiry_result_with_rssi_evt()
4918 } else if (skb->len == array_size(ev->num, in hci_inquiry_result_with_rssi_evt()
4922 for (i = 0; i < ev->num; i++) { in hci_inquiry_result_with_rssi_evt()
4929 bt_dev_err(hdev, "Malformed HCI Event: 0x%2.2x", in hci_inquiry_result_with_rssi_evt()
4934 bacpy(&data.bdaddr, &info->bdaddr); in hci_inquiry_result_with_rssi_evt()
4935 data.pscan_rep_mode = info->pscan_rep_mode; in hci_inquiry_result_with_rssi_evt()
4936 data.pscan_period_mode = info->pscan_period_mode; in hci_inquiry_result_with_rssi_evt()
4938 memcpy(data.dev_class, info->dev_class, 3); in hci_inquiry_result_with_rssi_evt()
4939 data.clock_offset = info->clock_offset; in hci_inquiry_result_with_rssi_evt()
4940 data.rssi = info->rssi; in hci_inquiry_result_with_rssi_evt()
4945 mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, in hci_inquiry_result_with_rssi_evt()
4946 info->dev_class, info->rssi, in hci_inquiry_result_with_rssi_evt()
4950 bt_dev_err(hdev, "Malformed HCI Event: 0x%2.2x", in hci_inquiry_result_with_rssi_evt()
4963 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_remote_ext_features_evt()
4967 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_remote_ext_features_evt()
4971 if (ev->page < HCI_MAX_PAGES) in hci_remote_ext_features_evt()
4972 memcpy(conn->features[ev->page], ev->features, 8); in hci_remote_ext_features_evt()
4974 if (!ev->status && ev->page == 0x01) { in hci_remote_ext_features_evt()
4977 ie = hci_inquiry_cache_lookup(hdev, &conn->dst); in hci_remote_ext_features_evt()
4979 ie->data.ssp_mode = (ev->features[0] & LMP_HOST_SSP); in hci_remote_ext_features_evt()
4981 if (ev->features[0] & LMP_HOST_SSP) { in hci_remote_ext_features_evt()
4982 set_bit(HCI_CONN_SSP_ENABLED, &conn->flags); in hci_remote_ext_features_evt()
4992 clear_bit(HCI_CONN_SSP_ENABLED, &conn->flags); in hci_remote_ext_features_evt()
4995 if (ev->features[0] & LMP_HOST_SC) in hci_remote_ext_features_evt()
4996 set_bit(HCI_CONN_SC_ENABLED, &conn->flags); in hci_remote_ext_features_evt()
4999 if (conn->state != BT_CONFIG) in hci_remote_ext_features_evt()
5002 if (!ev->status && !test_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) { in hci_remote_ext_features_evt()
5005 bacpy(&cp.bdaddr, &conn->dst); in hci_remote_ext_features_evt()
5008 } else if (!test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) in hci_remote_ext_features_evt()
5012 conn->state = BT_CONNECTED; in hci_remote_ext_features_evt()
5013 hci_connect_cfm(conn, ev->status); in hci_remote_ext_features_evt()
5026 u8 status = ev->status; in hci_sync_conn_complete_evt()
5028 switch (ev->link_type) { in hci_sync_conn_complete_evt()
5041 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_sync_conn_complete_evt()
5045 conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, &ev->bdaddr); in hci_sync_conn_complete_evt()
5047 if (ev->link_type == ESCO_LINK) in hci_sync_conn_complete_evt()
5059 conn = hci_conn_hash_lookup_ba(hdev, ESCO_LINK, &ev->bdaddr); in hci_sync_conn_complete_evt()
5070 if (!HCI_CONN_HANDLE_UNSET(conn->handle)) { in hci_sync_conn_complete_evt()
5077 status = hci_conn_set_handle(conn, __le16_to_cpu(ev->handle)); in hci_sync_conn_complete_evt()
5079 conn->state = BT_CLOSED; in hci_sync_conn_complete_evt()
5083 conn->state = BT_CONNECTED; in hci_sync_conn_complete_evt()
5084 conn->type = ev->link_type; in hci_sync_conn_complete_evt()
5098 if (conn->out) { in hci_sync_conn_complete_evt()
5099 conn->pkt_type = (hdev->esco_type & SCO_ESCO_MASK) | in hci_sync_conn_complete_evt()
5100 (hdev->esco_type & EDR_ESCO_MASK); in hci_sync_conn_complete_evt()
5101 if (hci_setup_sync(conn, conn->parent->handle)) in hci_sync_conn_complete_evt()
5107 conn->state = BT_CLOSED; in hci_sync_conn_complete_evt()
5111 bt_dev_dbg(hdev, "SCO connected with air mode: %02x", ev->air_mode); in hci_sync_conn_complete_evt()
5113 * is zero and non-zero value shall be non-HCI transport data path in hci_sync_conn_complete_evt()
5115 if (conn->codec.data_path == 0 && hdev->notify) { in hci_sync_conn_complete_evt()
5116 switch (ev->air_mode) { in hci_sync_conn_complete_evt()
5118 hdev->notify(hdev, HCI_NOTIFY_ENABLE_SCO_CVSD); in hci_sync_conn_complete_evt()
5121 hdev->notify(hdev, HCI_NOTIFY_ENABLE_SCO_TRANSP); in hci_sync_conn_complete_evt()
5160 flex_array_size(ev, info, ev->num))) in hci_extended_inquiry_result_evt()
5163 bt_dev_dbg(hdev, "num %d", ev->num); in hci_extended_inquiry_result_evt()
5165 if (!ev->num) in hci_extended_inquiry_result_evt()
5173 for (i = 0; i < ev->num; i++) { in hci_extended_inquiry_result_evt()
5174 struct extended_inquiry_info *info = &ev->info[i]; in hci_extended_inquiry_result_evt()
5178 bacpy(&data.bdaddr, &info->bdaddr); in hci_extended_inquiry_result_evt()
5179 data.pscan_rep_mode = info->pscan_rep_mode; in hci_extended_inquiry_result_evt()
5180 data.pscan_period_mode = info->pscan_period_mode; in hci_extended_inquiry_result_evt()
5182 memcpy(data.dev_class, info->dev_class, 3); in hci_extended_inquiry_result_evt()
5183 data.clock_offset = info->clock_offset; in hci_extended_inquiry_result_evt()
5184 data.rssi = info->rssi; in hci_extended_inquiry_result_evt()
5188 name_known = eir_get_data(info->data, in hci_extended_inquiry_result_evt()
5189 sizeof(info->data), in hci_extended_inquiry_result_evt()
5196 eir_len = eir_get_length(info->data, sizeof(info->data)); in hci_extended_inquiry_result_evt()
5198 mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, in hci_extended_inquiry_result_evt()
5199 info->dev_class, info->rssi, in hci_extended_inquiry_result_evt()
5200 flags, info->data, eir_len, NULL, 0, 0); in hci_extended_inquiry_result_evt()
5212 bt_dev_dbg(hdev, "status 0x%2.2x handle 0x%4.4x", ev->status, in hci_key_refresh_complete_evt()
5213 __le16_to_cpu(ev->handle)); in hci_key_refresh_complete_evt()
5217 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_key_refresh_complete_evt()
5224 if (conn->type != LE_LINK) in hci_key_refresh_complete_evt()
5227 if (!ev->status) in hci_key_refresh_complete_evt()
5228 conn->sec_level = conn->pending_sec_level; in hci_key_refresh_complete_evt()
5230 clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags); in hci_key_refresh_complete_evt()
5232 if (ev->status && conn->state == BT_CONNECTED) { in hci_key_refresh_complete_evt()
5238 if (conn->state == BT_CONFIG) { in hci_key_refresh_complete_evt()
5239 if (!ev->status) in hci_key_refresh_complete_evt()
5240 conn->state = BT_CONNECTED; in hci_key_refresh_complete_evt()
5242 hci_connect_cfm(conn, ev->status); in hci_key_refresh_complete_evt()
5245 hci_auth_cfm(conn, ev->status); in hci_key_refresh_complete_evt()
5248 conn->disc_timeout = HCI_DISCONN_TIMEOUT; in hci_key_refresh_complete_evt()
5258 /* If remote requests no-bonding follow that lead */ in hci_get_auth_req()
5259 if (conn->remote_auth == HCI_AT_NO_BONDING || in hci_get_auth_req()
5260 conn->remote_auth == HCI_AT_NO_BONDING_MITM) in hci_get_auth_req()
5261 return conn->remote_auth | (conn->auth_type & 0x01); in hci_get_auth_req()
5266 if (conn->remote_cap != HCI_IO_NO_INPUT_OUTPUT && in hci_get_auth_req()
5267 conn->io_capability != HCI_IO_NO_INPUT_OUTPUT) in hci_get_auth_req()
5268 return conn->remote_auth | 0x01; in hci_get_auth_req()
5271 return (conn->remote_auth & ~0x01) | (conn->auth_type & 0x01); in hci_get_auth_req()
5276 struct hci_dev *hdev = conn->hdev; in bredr_oob_data_present()
5279 data = hci_find_remote_oob_data(hdev, &conn->dst, BDADDR_BREDR); in bredr_oob_data_present()
5291 return data->present; in bredr_oob_data_present()
5294 * the P-256 values are required. If they are not in bredr_oob_data_present()
5298 if (!crypto_memneq(data->rand256, ZERO_KEY, 16) || in bredr_oob_data_present()
5299 !crypto_memneq(data->hash256, ZERO_KEY, 16)) in bredr_oob_data_present()
5307 * P-192 data values are present. in bredr_oob_data_present()
5309 if (!crypto_memneq(data->rand192, ZERO_KEY, 16) || in bredr_oob_data_present()
5310 !crypto_memneq(data->hash192, ZERO_KEY, 16)) in bredr_oob_data_present()
5326 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_io_capa_request_evt()
5339 test_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags) || in hci_io_capa_request_evt()
5340 (conn->remote_auth & ~0x01) == HCI_AT_NO_BONDING) { in hci_io_capa_request_evt()
5343 bacpy(&cp.bdaddr, &ev->bdaddr); in hci_io_capa_request_evt()
5346 cp.capability = (conn->io_capability == 0x04) ? in hci_io_capa_request_evt()
5347 HCI_IO_DISPLAY_YESNO : conn->io_capability; in hci_io_capa_request_evt()
5350 if (conn->remote_auth == 0xff) { in hci_io_capa_request_evt()
5352 * except for the no-bonding case. in hci_io_capa_request_evt()
5354 if (conn->io_capability != HCI_IO_NO_INPUT_OUTPUT && in hci_io_capa_request_evt()
5355 conn->auth_type != HCI_AT_NO_BONDING) in hci_io_capa_request_evt()
5356 conn->auth_type |= 0x01; in hci_io_capa_request_evt()
5358 conn->auth_type = hci_get_auth_req(conn); in hci_io_capa_request_evt()
5361 /* If we're not bondable, force one of the non-bondable in hci_io_capa_request_evt()
5365 conn->auth_type &= HCI_AT_NO_BONDING_MITM; in hci_io_capa_request_evt()
5367 cp.authentication = conn->auth_type; in hci_io_capa_request_evt()
5375 bacpy(&cp.bdaddr, &ev->bdaddr); in hci_io_capa_request_evt()
5396 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_io_capa_reply_evt()
5400 conn->remote_cap = ev->capability; in hci_io_capa_reply_evt()
5401 conn->remote_auth = ev->authentication; in hci_io_capa_reply_evt()
5421 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_user_confirm_request_evt()
5425 loc_mitm = (conn->auth_type & 0x01); in hci_user_confirm_request_evt()
5426 rem_mitm = (conn->remote_auth & 0x01); in hci_user_confirm_request_evt()
5431 * necessarily match conn->auth_type. in hci_user_confirm_request_evt()
5433 if (conn->pending_sec_level > BT_SECURITY_MEDIUM && in hci_user_confirm_request_evt()
5434 conn->remote_cap == HCI_IO_NO_INPUT_OUTPUT) { in hci_user_confirm_request_evt()
5437 sizeof(ev->bdaddr), &ev->bdaddr); in hci_user_confirm_request_evt()
5441 /* If no side requires MITM protection; auto-accept */ in hci_user_confirm_request_evt()
5442 if ((!loc_mitm || conn->remote_cap == HCI_IO_NO_INPUT_OUTPUT) && in hci_user_confirm_request_evt()
5443 (!rem_mitm || conn->io_capability == HCI_IO_NO_INPUT_OUTPUT)) { in hci_user_confirm_request_evt()
5449 * NoInputNoOutput, in which case we do auto-accept in hci_user_confirm_request_evt()
5451 if (!test_bit(HCI_CONN_AUTH_PEND, &conn->flags) && in hci_user_confirm_request_evt()
5452 conn->io_capability != HCI_IO_NO_INPUT_OUTPUT && in hci_user_confirm_request_evt()
5454 bt_dev_dbg(hdev, "Confirming auto-accept as acceptor"); in hci_user_confirm_request_evt()
5463 if (hci_find_link_key(hdev, &ev->bdaddr)) { in hci_user_confirm_request_evt()
5469 BT_DBG("Auto-accept of user confirmation with %ums delay", in hci_user_confirm_request_evt()
5470 hdev->auto_accept_delay); in hci_user_confirm_request_evt()
5472 if (hdev->auto_accept_delay > 0) { in hci_user_confirm_request_evt()
5473 int delay = msecs_to_jiffies(hdev->auto_accept_delay); in hci_user_confirm_request_evt()
5474 queue_delayed_work(conn->hdev->workqueue, in hci_user_confirm_request_evt()
5475 &conn->auto_accept_work, delay); in hci_user_confirm_request_evt()
5480 sizeof(ev->bdaddr), &ev->bdaddr); in hci_user_confirm_request_evt()
5485 mgmt_user_confirm_request(hdev, &ev->bdaddr, ACL_LINK, 0, in hci_user_confirm_request_evt()
5486 le32_to_cpu(ev->passkey), confirm_hint); in hci_user_confirm_request_evt()
5500 mgmt_user_passkey_request(hdev, &ev->bdaddr, ACL_LINK, 0); in hci_user_passkey_request_evt()
5511 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_user_passkey_notify_evt()
5515 conn->passkey_notify = __le32_to_cpu(ev->passkey); in hci_user_passkey_notify_evt()
5516 conn->passkey_entered = 0; in hci_user_passkey_notify_evt()
5519 mgmt_user_passkey_notify(hdev, &conn->dst, conn->type, in hci_user_passkey_notify_evt()
5520 conn->dst_type, conn->passkey_notify, in hci_user_passkey_notify_evt()
5521 conn->passkey_entered); in hci_user_passkey_notify_evt()
5532 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_keypress_notify_evt()
5536 switch (ev->type) { in hci_keypress_notify_evt()
5538 conn->passkey_entered = 0; in hci_keypress_notify_evt()
5542 conn->passkey_entered++; in hci_keypress_notify_evt()
5546 conn->passkey_entered--; in hci_keypress_notify_evt()
5550 conn->passkey_entered = 0; in hci_keypress_notify_evt()
5558 mgmt_user_passkey_notify(hdev, &conn->dst, conn->type, in hci_keypress_notify_evt()
5559 conn->dst_type, conn->passkey_notify, in hci_keypress_notify_evt()
5560 conn->passkey_entered); in hci_keypress_notify_evt()
5573 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_simple_pair_complete_evt()
5578 conn->remote_auth = 0xff; in hci_simple_pair_complete_evt()
5585 if (!test_bit(HCI_CONN_AUTH_PEND, &conn->flags) && ev->status) in hci_simple_pair_complete_evt()
5586 mgmt_auth_failed(conn, ev->status); in hci_simple_pair_complete_evt()
5605 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_remote_host_features_evt()
5607 memcpy(conn->features[1], ev->features, 8); in hci_remote_host_features_evt()
5609 ie = hci_inquiry_cache_lookup(hdev, &ev->bdaddr); in hci_remote_host_features_evt()
5611 ie->data.ssp_mode = (ev->features[0] & LMP_HOST_SSP); in hci_remote_host_features_evt()
5629 data = hci_find_remote_oob_data(hdev, &ev->bdaddr, BDADDR_BREDR); in hci_remote_oob_data_request_evt()
5633 bacpy(&cp.bdaddr, &ev->bdaddr); in hci_remote_oob_data_request_evt()
5642 bacpy(&cp.bdaddr, &ev->bdaddr); in hci_remote_oob_data_request_evt()
5647 memcpy(cp.hash192, data->hash192, sizeof(cp.hash192)); in hci_remote_oob_data_request_evt()
5648 memcpy(cp.rand192, data->rand192, sizeof(cp.rand192)); in hci_remote_oob_data_request_evt()
5650 memcpy(cp.hash256, data->hash256, sizeof(cp.hash256)); in hci_remote_oob_data_request_evt()
5651 memcpy(cp.rand256, data->rand256, sizeof(cp.rand256)); in hci_remote_oob_data_request_evt()
5658 bacpy(&cp.bdaddr, &ev->bdaddr); in hci_remote_oob_data_request_evt()
5659 memcpy(cp.hash, data->hash192, sizeof(cp.hash)); in hci_remote_oob_data_request_evt()
5660 memcpy(cp.rand, data->rand192, sizeof(cp.rand)); in hci_remote_oob_data_request_evt()
5677 bt_dev_dbg(hdev, "handle 0x%2.2x", ev->phy_handle); in hci_chan_selected_evt()
5679 hcon = hci_conn_hash_lookup_handle(hdev, ev->phy_handle); in hci_chan_selected_evt()
5692 bt_dev_dbg(hdev, "handle 0x%2.2x status 0x%2.2x", ev->phy_handle, in hci_phy_link_complete_evt()
5693 ev->status); in hci_phy_link_complete_evt()
5697 hcon = hci_conn_hash_lookup_handle(hdev, ev->phy_handle); in hci_phy_link_complete_evt()
5701 if (!hcon->amp_mgr) in hci_phy_link_complete_evt()
5704 if (ev->status) { in hci_phy_link_complete_evt()
5709 bredr_hcon = hcon->amp_mgr->l2cap_conn->hcon; in hci_phy_link_complete_evt()
5711 hcon->state = BT_CONNECTED; in hci_phy_link_complete_evt()
5712 bacpy(&hcon->dst, &bredr_hcon->dst); in hci_phy_link_complete_evt()
5715 hcon->disc_timeout = HCI_DISCONN_TIMEOUT; in hci_phy_link_complete_evt()
5735 bt_dev_dbg(hdev, "log_handle 0x%4.4x phy_handle 0x%2.2x status 0x%2.2x", in hci_loglink_complete_evt()
5736 le16_to_cpu(ev->handle), ev->phy_handle, ev->status); in hci_loglink_complete_evt()
5738 hcon = hci_conn_hash_lookup_handle(hdev, ev->phy_handle); in hci_loglink_complete_evt()
5747 hchan->handle = le16_to_cpu(ev->handle); in hci_loglink_complete_evt()
5748 hchan->amp = true; in hci_loglink_complete_evt()
5750 BT_DBG("hcon %p mgr %p hchan %p", hcon, hcon->amp_mgr, hchan); in hci_loglink_complete_evt()
5752 mgr = hcon->amp_mgr; in hci_loglink_complete_evt()
5753 if (mgr && mgr->bredr_chan) { in hci_loglink_complete_evt()
5754 struct l2cap_chan *bredr_chan = mgr->bredr_chan; in hci_loglink_complete_evt()
5758 bredr_chan->conn->mtu = hdev->block_mtu; in hci_loglink_complete_evt()
5772 bt_dev_dbg(hdev, "handle 0x%4.4x status 0x%2.2x", in hci_disconn_loglink_complete_evt()
5773 le16_to_cpu(ev->handle), ev->status); in hci_disconn_loglink_complete_evt()
5775 if (ev->status) in hci_disconn_loglink_complete_evt()
5780 hchan = hci_chan_lookup_handle(hdev, le16_to_cpu(ev->handle)); in hci_disconn_loglink_complete_evt()
5781 if (!hchan || !hchan->amp) in hci_disconn_loglink_complete_evt()
5784 amp_destroy_logical_link(hchan, ev->reason); in hci_disconn_loglink_complete_evt()
5796 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_disconn_phylink_complete_evt()
5798 if (ev->status) in hci_disconn_phylink_complete_evt()
5803 hcon = hci_conn_hash_lookup_handle(hdev, ev->phy_handle); in hci_disconn_phylink_complete_evt()
5804 if (hcon && hcon->type == AMP_LINK) { in hci_disconn_phylink_complete_evt()
5805 hcon->state = BT_CLOSED; in hci_disconn_phylink_complete_evt()
5806 hci_disconn_cfm(hcon, ev->reason); in hci_disconn_phylink_complete_evt()
5817 if (conn->out) { in le_conn_update_addr()
5818 conn->dst_type = bdaddr_type; in le_conn_update_addr()
5819 conn->resp_addr_type = bdaddr_type; in le_conn_update_addr()
5820 bacpy(&conn->resp_addr, bdaddr); in le_conn_update_addr()
5823 * used instead or hdev->rpa. in le_conn_update_addr()
5826 conn->init_addr_type = ADDR_LE_DEV_RANDOM; in le_conn_update_addr()
5827 bacpy(&conn->init_addr, local_rpa); in le_conn_update_addr()
5828 } else if (hci_dev_test_flag(conn->hdev, HCI_PRIVACY)) { in le_conn_update_addr()
5829 conn->init_addr_type = ADDR_LE_DEV_RANDOM; in le_conn_update_addr()
5830 bacpy(&conn->init_addr, &conn->hdev->rpa); in le_conn_update_addr()
5832 hci_copy_identity_address(conn->hdev, &conn->init_addr, in le_conn_update_addr()
5833 &conn->init_addr_type); in le_conn_update_addr()
5836 conn->resp_addr_type = conn->hdev->adv_addr_type; in le_conn_update_addr()
5838 * used instead or hdev->rpa. in le_conn_update_addr()
5841 conn->resp_addr_type = ADDR_LE_DEV_RANDOM; in le_conn_update_addr()
5842 bacpy(&conn->resp_addr, local_rpa); in le_conn_update_addr()
5843 } else if (conn->hdev->adv_addr_type == ADDR_LE_DEV_RANDOM) { in le_conn_update_addr()
5847 if (!ext_adv_capable(conn->hdev)) in le_conn_update_addr()
5848 bacpy(&conn->resp_addr, in le_conn_update_addr()
5849 &conn->hdev->random_addr); in le_conn_update_addr()
5851 bacpy(&conn->resp_addr, &conn->hdev->bdaddr); in le_conn_update_addr()
5854 conn->init_addr_type = bdaddr_type; in le_conn_update_addr()
5855 bacpy(&conn->init_addr, bdaddr); in le_conn_update_addr()
5862 conn->le_conn_min_interval = conn->hdev->le_conn_min_interval; in le_conn_update_addr()
5863 conn->le_conn_max_interval = conn->hdev->le_conn_max_interval; in le_conn_update_addr()
5899 conn->dst_type = bdaddr_type; in le_conn_complete_evt()
5909 if (conn->out) { in le_conn_complete_evt()
5910 conn->resp_addr_type = bdaddr_type; in le_conn_complete_evt()
5911 bacpy(&conn->resp_addr, bdaddr); in le_conn_complete_evt()
5913 conn->init_addr_type = ADDR_LE_DEV_RANDOM; in le_conn_complete_evt()
5914 bacpy(&conn->init_addr, &hdev->rpa); in le_conn_complete_evt()
5917 &conn->init_addr, in le_conn_complete_evt()
5918 &conn->init_addr_type); in le_conn_complete_evt()
5922 cancel_delayed_work(&conn->le_conn_timeout); in le_conn_complete_evt()
5931 if (!HCI_CONN_HANDLE_UNSET(conn->handle)) { in le_conn_complete_evt()
5947 irk = hci_get_irk(hdev, &conn->dst, conn->dst_type); in le_conn_complete_evt()
5949 bacpy(&conn->dst, &irk->bdaddr); in le_conn_complete_evt()
5950 conn->dst_type = irk->addr_type; in le_conn_complete_evt()
5953 conn->dst_type = ev_bdaddr_type(hdev, conn->dst_type, NULL); in le_conn_complete_evt()
5956 bt_dev_err(hdev, "Invalid handle: 0x%4.4x > 0x%4.4x", handle, in le_conn_complete_evt()
5969 if (test_bit(HCI_CONN_CANCEL, &conn->flags)) { in le_conn_complete_evt()
5974 if (conn->dst_type == ADDR_LE_DEV_PUBLIC) in le_conn_complete_evt()
5980 if (hci_bdaddr_list_lookup(&hdev->reject_list, &conn->dst, addr_type)) { in le_conn_complete_evt()
5985 if (!test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) in le_conn_complete_evt()
5988 conn->sec_level = BT_SECURITY_LOW; in le_conn_complete_evt()
5989 conn->handle = handle; in le_conn_complete_evt()
5990 conn->state = BT_CONFIG; in le_conn_complete_evt()
5993 * when sotfware rotation is in use so it can be re-enabled when in le_conn_complete_evt()
5997 conn->adv_instance = hdev->cur_adv_instance; in le_conn_complete_evt()
5999 conn->le_conn_interval = interval; in le_conn_complete_evt()
6000 conn->le_conn_latency = latency; in le_conn_complete_evt()
6001 conn->le_supv_timeout = supervision_timeout; in le_conn_complete_evt()
6010 * If the local controller supports peripheral-initiated features in le_conn_complete_evt()
6015 if (conn->out || in le_conn_complete_evt()
6016 (hdev->le_features[0] & HCI_LE_PERIPHERAL_FEATURES)) { in le_conn_complete_evt()
6019 cp.handle = __cpu_to_le16(conn->handle); in le_conn_complete_evt()
6026 conn->state = BT_CONNECTED; in le_conn_complete_evt()
6030 params = hci_pend_le_action_lookup(&hdev->pend_le_conns, &conn->dst, in le_conn_complete_evt()
6031 conn->dst_type); in le_conn_complete_evt()
6034 if (params->conn) { in le_conn_complete_evt()
6035 hci_conn_drop(params->conn); in le_conn_complete_evt()
6036 hci_conn_put(params->conn); in le_conn_complete_evt()
6037 params->conn = NULL; in le_conn_complete_evt()
6051 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_conn_complete_evt()
6053 le_conn_complete_evt(hdev, ev->status, &ev->bdaddr, ev->bdaddr_type, in hci_le_conn_complete_evt()
6054 NULL, ev->role, le16_to_cpu(ev->handle), in hci_le_conn_complete_evt()
6055 le16_to_cpu(ev->interval), in hci_le_conn_complete_evt()
6056 le16_to_cpu(ev->latency), in hci_le_conn_complete_evt()
6057 le16_to_cpu(ev->supervision_timeout)); in hci_le_conn_complete_evt()
6065 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_enh_conn_complete_evt()
6067 le_conn_complete_evt(hdev, ev->status, &ev->bdaddr, ev->bdaddr_type, in hci_le_enh_conn_complete_evt()
6068 &ev->local_rpa, ev->role, le16_to_cpu(ev->handle), in hci_le_enh_conn_complete_evt()
6069 le16_to_cpu(ev->interval), in hci_le_enh_conn_complete_evt()
6070 le16_to_cpu(ev->latency), in hci_le_enh_conn_complete_evt()
6071 le16_to_cpu(ev->supervision_timeout)); in hci_le_enh_conn_complete_evt()
6081 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_ext_adv_term_evt()
6090 if (ev->status == HCI_ERROR_CANCELLED_BY_HOST) { in hci_le_ext_adv_term_evt()
6097 adv = hci_find_adv_instance(hdev, ev->handle); in hci_le_ext_adv_term_evt()
6099 if (ev->status) { in hci_le_ext_adv_term_evt()
6104 hci_remove_adv_instance(hdev, ev->handle); in hci_le_ext_adv_term_evt()
6105 mgmt_advertising_removed(NULL, hdev, ev->handle); in hci_le_ext_adv_term_evt()
6107 list_for_each_entry_safe(adv, n, &hdev->adv_instances, list) { in hci_le_ext_adv_term_evt()
6108 if (adv->enabled) in hci_le_ext_adv_term_evt()
6118 adv->enabled = false; in hci_le_ext_adv_term_evt()
6120 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->conn_handle)); in hci_le_ext_adv_term_evt()
6123 * instance can be re-enabled when disconnected. in hci_le_ext_adv_term_evt()
6125 conn->adv_instance = ev->handle; in hci_le_ext_adv_term_evt()
6127 if (hdev->adv_addr_type != ADDR_LE_DEV_RANDOM || in hci_le_ext_adv_term_evt()
6128 bacmp(&conn->resp_addr, BDADDR_ANY)) in hci_le_ext_adv_term_evt()
6131 if (!ev->handle) { in hci_le_ext_adv_term_evt()
6132 bacpy(&conn->resp_addr, &hdev->random_addr); in hci_le_ext_adv_term_evt()
6137 bacpy(&conn->resp_addr, &adv->random_addr); in hci_le_ext_adv_term_evt()
6150 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_conn_update_complete_evt()
6152 if (ev->status) in hci_le_conn_update_complete_evt()
6157 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_conn_update_complete_evt()
6159 conn->le_conn_interval = le16_to_cpu(ev->interval); in hci_le_conn_update_complete_evt()
6160 conn->le_conn_latency = le16_to_cpu(ev->latency); in hci_le_conn_update_complete_evt()
6161 conn->le_supv_timeout = le16_to_cpu(ev->supervision_timeout); in hci_le_conn_update_complete_evt()
6167 /* This function requires the caller holds hdev->lock */
6181 if (hci_bdaddr_list_lookup(&hdev->reject_list, addr, addr_type) || in check_pending_le_conn()
6182 hdev->suspended) in check_pending_le_conn()
6188 if (hdev->conn_hash.le_num_peripheral > 0 && in check_pending_le_conn()
6189 (!test_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks) || in check_pending_le_conn()
6190 !(hdev->le_states[3] & 0x10))) in check_pending_le_conn()
6196 params = hci_pend_le_action_lookup(&hdev->pend_le_conns, addr, in check_pending_le_conn()
6201 if (!params->explicit_connect) { in check_pending_le_conn()
6202 switch (params->auto_connect) { in check_pending_le_conn()
6225 BT_SECURITY_LOW, hdev->def_le_autoconnect_timeout, in check_pending_le_conn()
6237 if (!params->explicit_connect) in check_pending_le_conn()
6238 params->conn = hci_conn_get(conn); in check_pending_le_conn()
6244 case -EBUSY: in check_pending_le_conn()
6245 /* If hci_connect() returns -EBUSY it means there is already in check_pending_le_conn()
6264 struct discovery_state *d = &hdev->discovery; in process_adv_report()
6280 "type: 0x%02x", type); in process_adv_report()
6304 len = ptr - data; in process_adv_report()
6331 if (!smp_irk_matches(hdev, hdev->irk, direct_addr)) in process_adv_report()
6338 bdaddr = &irk->bdaddr; in process_adv_report()
6339 bdaddr_type = irk->addr_type; in process_adv_report()
6356 memcpy(conn->le_adv_data, data, len); in process_adv_report()
6357 conn->le_adv_data_len = len; in process_adv_report()
6376 if (hdev->le_scan_type == LE_SCAN_PASSIVE) { in process_adv_report()
6380 if (!hci_pend_le_action_lookup(&hdev->pend_le_reports, in process_adv_report()
6382 idr_is_empty(&hdev->adv_monitors_idr)) in process_adv_report()
6423 match = (!bacmp(bdaddr, &d->last_adv_addr) && in process_adv_report()
6424 bdaddr_type == d->last_adv_addr_type); in process_adv_report()
6433 mgmt_device_found(hdev, &d->last_adv_addr, LE_LINK, in process_adv_report()
6434 d->last_adv_addr_type, NULL, in process_adv_report()
6435 d->last_adv_rssi, d->last_adv_flags, in process_adv_report()
6436 d->last_adv_data, in process_adv_report()
6437 d->last_adv_data_len, NULL, 0, 0); in process_adv_report()
6462 mgmt_device_found(hdev, &d->last_adv_addr, LE_LINK, in process_adv_report()
6463 d->last_adv_addr_type, NULL, rssi, d->last_adv_flags, in process_adv_report()
6464 d->last_adv_data, d->last_adv_data_len, data, len, 0); in process_adv_report()
6474 if (!ev->num) in hci_le_adv_report_evt()
6479 while (ev->num--) { in hci_le_adv_report_evt()
6490 info->length + 1)) in hci_le_adv_report_evt()
6493 if (info->length <= max_adv_len(hdev)) { in hci_le_adv_report_evt()
6494 rssi = info->data[info->length]; in hci_le_adv_report_evt()
6495 process_adv_report(hdev, info->type, &info->bdaddr, in hci_le_adv_report_evt()
6496 info->bdaddr_type, NULL, 0, rssi, in hci_le_adv_report_evt()
6497 info->data, info->length, false, in hci_le_adv_report_evt()
6545 bt_dev_err_ratelimited(hdev, "Unknown advertising packet type: 0x%02x", in ext_evt_type_to_legacy()
6557 if (!ev->num) in hci_le_ext_adv_report_evt()
6562 while (ev->num--) { in hci_le_ext_adv_report_evt()
6573 info->length)) in hci_le_ext_adv_report_evt()
6576 evt_type = __le16_to_cpu(info->type) & LE_EXT_ADV_EVT_TYPE_MASK; in hci_le_ext_adv_report_evt()
6579 process_adv_report(hdev, legacy_evt_type, &info->bdaddr, in hci_le_ext_adv_report_evt()
6580 info->bdaddr_type, NULL, 0, in hci_le_ext_adv_report_evt()
6581 info->rssi, info->data, info->length, in hci_le_ext_adv_report_evt()
6604 int mask = hdev->link_mode; in hci_le_pa_sync_estabilished_evt()
6608 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_pa_sync_estabilished_evt()
6614 mask |= hci_proto_connect_ind(hdev, &ev->bdaddr, ISO_LINK, &flags); in hci_le_pa_sync_estabilished_evt()
6616 hci_le_pa_term_sync(hdev, ev->handle); in hci_le_pa_sync_estabilished_evt()
6630 if (ev->status) in hci_le_pa_sync_estabilished_evt()
6631 set_bit(HCI_CONN_PA_SYNC_FAILED, &bis->flags); in hci_le_pa_sync_estabilished_evt()
6633 set_bit(HCI_CONN_PA_SYNC, &bis->flags); in hci_le_pa_sync_estabilished_evt()
6636 hci_connect_cfm(bis, ev->status); in hci_le_pa_sync_estabilished_evt()
6646 int mask = hdev->link_mode; in hci_le_per_adv_report_evt()
6649 bt_dev_dbg(hdev, "sync_handle 0x%4.4x", le16_to_cpu(ev->sync_handle)); in hci_le_per_adv_report_evt()
6655 hci_le_pa_term_sync(hdev, ev->sync_handle); in hci_le_per_adv_report_evt()
6666 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_remote_feat_complete_evt()
6670 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_remote_feat_complete_evt()
6672 if (!ev->status) in hci_le_remote_feat_complete_evt()
6673 memcpy(conn->features[0], ev->features, 8); in hci_le_remote_feat_complete_evt()
6675 if (conn->state == BT_CONFIG) { in hci_le_remote_feat_complete_evt()
6678 /* If the local controller supports peripheral-initiated in hci_le_remote_feat_complete_evt()
6687 if (!conn->out && ev->status == 0x1a && in hci_le_remote_feat_complete_evt()
6688 (hdev->le_features[0] & HCI_LE_PERIPHERAL_FEATURES)) in hci_le_remote_feat_complete_evt()
6691 status = ev->status; in hci_le_remote_feat_complete_evt()
6693 conn->state = BT_CONNECTED; in hci_le_remote_feat_complete_evt()
6711 bt_dev_dbg(hdev, "handle 0x%4.4x", __le16_to_cpu(ev->handle)); in hci_le_ltk_request_evt()
6715 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_ltk_request_evt()
6719 ltk = hci_find_ltk(hdev, &conn->dst, conn->dst_type, conn->role); in hci_le_ltk_request_evt()
6725 if (ev->ediv || ev->rand) in hci_le_ltk_request_evt()
6728 /* For non-SC keys check that EDiv and Rand match */ in hci_le_ltk_request_evt()
6729 if (ev->ediv != ltk->ediv || ev->rand != ltk->rand) in hci_le_ltk_request_evt()
6733 memcpy(cp.ltk, ltk->val, ltk->enc_size); in hci_le_ltk_request_evt()
6734 memset(cp.ltk + ltk->enc_size, 0, sizeof(cp.ltk) - ltk->enc_size); in hci_le_ltk_request_evt()
6735 cp.handle = cpu_to_le16(conn->handle); in hci_le_ltk_request_evt()
6737 conn->pending_sec_level = smp_ltk_sec_level(ltk); in hci_le_ltk_request_evt()
6739 conn->enc_key_size = ltk->enc_size; in hci_le_ltk_request_evt()
6746 * distribute the keys. Later, security can be re-established in hci_le_ltk_request_evt()
6749 if (ltk->type == SMP_STK) { in hci_le_ltk_request_evt()
6750 set_bit(HCI_CONN_STK_ENCRYPT, &conn->flags); in hci_le_ltk_request_evt()
6751 list_del_rcu(&ltk->list); in hci_le_ltk_request_evt()
6754 clear_bit(HCI_CONN_STK_ENCRYPT, &conn->flags); in hci_le_ltk_request_evt()
6762 neg.handle = ev->handle; in hci_le_ltk_request_evt()
6787 bt_dev_dbg(hdev, "handle 0x%4.4x", __le16_to_cpu(ev->handle)); in hci_le_remote_conn_param_req_evt()
6789 handle = le16_to_cpu(ev->handle); in hci_le_remote_conn_param_req_evt()
6790 min = le16_to_cpu(ev->interval_min); in hci_le_remote_conn_param_req_evt()
6791 max = le16_to_cpu(ev->interval_max); in hci_le_remote_conn_param_req_evt()
6792 latency = le16_to_cpu(ev->latency); in hci_le_remote_conn_param_req_evt()
6793 timeout = le16_to_cpu(ev->timeout); in hci_le_remote_conn_param_req_evt()
6796 if (!hcon || hcon->state != BT_CONNECTED) in hci_le_remote_conn_param_req_evt()
6804 if (hcon->role == HCI_ROLE_MASTER) { in hci_le_remote_conn_param_req_evt()
6810 params = hci_conn_params_lookup(hdev, &hcon->dst, in hci_le_remote_conn_param_req_evt()
6811 hcon->dst_type); in hci_le_remote_conn_param_req_evt()
6813 params->conn_min_interval = min; in hci_le_remote_conn_param_req_evt()
6814 params->conn_max_interval = max; in hci_le_remote_conn_param_req_evt()
6815 params->conn_latency = latency; in hci_le_remote_conn_param_req_evt()
6816 params->supervision_timeout = timeout; in hci_le_remote_conn_param_req_evt()
6824 mgmt_new_conn_param(hdev, &hcon->dst, hcon->dst_type, in hci_le_remote_conn_param_req_evt()
6828 cp.handle = ev->handle; in hci_le_remote_conn_param_req_evt()
6829 cp.interval_min = ev->interval_min; in hci_le_remote_conn_param_req_evt()
6830 cp.interval_max = ev->interval_max; in hci_le_remote_conn_param_req_evt()
6831 cp.latency = ev->latency; in hci_le_remote_conn_param_req_evt()
6832 cp.timeout = ev->timeout; in hci_le_remote_conn_param_req_evt()
6847 flex_array_size(ev, info, ev->num))) in hci_le_direct_adv_report_evt()
6850 if (!ev->num) in hci_le_direct_adv_report_evt()
6855 for (i = 0; i < ev->num; i++) { in hci_le_direct_adv_report_evt()
6856 struct hci_ev_le_direct_adv_info *info = &ev->info[i]; in hci_le_direct_adv_report_evt()
6858 process_adv_report(hdev, info->type, &info->bdaddr, in hci_le_direct_adv_report_evt()
6859 info->bdaddr_type, &info->direct_addr, in hci_le_direct_adv_report_evt()
6860 info->direct_addr_type, info->rssi, NULL, 0, in hci_le_direct_adv_report_evt()
6873 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_phy_update_evt()
6875 if (ev->status) in hci_le_phy_update_evt()
6880 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_phy_update_evt()
6884 conn->le_tx_phy = ev->tx_phy; in hci_le_phy_update_evt()
6885 conn->le_rx_phy = ev->rx_phy; in hci_le_phy_update_evt()
6898 u16 handle = __le16_to_cpu(ev->handle); in hci_le_cis_estabilished_evt()
6900 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_cis_estabilished_evt()
6907 "Unable to find connection with handle 0x%4.4x", in hci_le_cis_estabilished_evt()
6912 if (conn->type != ISO_LINK) { in hci_le_cis_estabilished_evt()
6914 "Invalid connection link type handle 0x%4.4x", in hci_le_cis_estabilished_evt()
6919 qos = &conn->iso_qos; in hci_le_cis_estabilished_evt()
6921 pending = test_and_clear_bit(HCI_CONN_CREATE_CIS, &conn->flags); in hci_le_cis_estabilished_evt()
6924 qos->ucast.in.interval = le16_to_cpu(ev->interval) * 1250; in hci_le_cis_estabilished_evt()
6925 qos->ucast.out.interval = qos->ucast.in.interval; in hci_le_cis_estabilished_evt()
6927 switch (conn->role) { in hci_le_cis_estabilished_evt()
6930 qos->ucast.in.latency = in hci_le_cis_estabilished_evt()
6931 DIV_ROUND_CLOSEST(get_unaligned_le24(ev->c_latency), in hci_le_cis_estabilished_evt()
6933 qos->ucast.out.latency = in hci_le_cis_estabilished_evt()
6934 DIV_ROUND_CLOSEST(get_unaligned_le24(ev->p_latency), in hci_le_cis_estabilished_evt()
6936 qos->ucast.in.sdu = le16_to_cpu(ev->c_mtu); in hci_le_cis_estabilished_evt()
6937 qos->ucast.out.sdu = le16_to_cpu(ev->p_mtu); in hci_le_cis_estabilished_evt()
6938 qos->ucast.in.phy = ev->c_phy; in hci_le_cis_estabilished_evt()
6939 qos->ucast.out.phy = ev->p_phy; in hci_le_cis_estabilished_evt()
6943 qos->ucast.out.latency = in hci_le_cis_estabilished_evt()
6944 DIV_ROUND_CLOSEST(get_unaligned_le24(ev->c_latency), in hci_le_cis_estabilished_evt()
6946 qos->ucast.in.latency = in hci_le_cis_estabilished_evt()
6947 DIV_ROUND_CLOSEST(get_unaligned_le24(ev->p_latency), in hci_le_cis_estabilished_evt()
6949 qos->ucast.out.sdu = le16_to_cpu(ev->c_mtu); in hci_le_cis_estabilished_evt()
6950 qos->ucast.in.sdu = le16_to_cpu(ev->p_mtu); in hci_le_cis_estabilished_evt()
6951 qos->ucast.out.phy = ev->c_phy; in hci_le_cis_estabilished_evt()
6952 qos->ucast.in.phy = ev->p_phy; in hci_le_cis_estabilished_evt()
6956 if (!ev->status) { in hci_le_cis_estabilished_evt()
6957 conn->state = BT_CONNECTED; in hci_le_cis_estabilished_evt()
6964 conn->state = BT_CLOSED; in hci_le_cis_estabilished_evt()
6965 hci_connect_cfm(conn, ev->status); in hci_le_cis_estabilished_evt()
7003 acl_handle = __le16_to_cpu(ev->acl_handle); in hci_le_cis_req_evt()
7004 cis_handle = __le16_to_cpu(ev->cis_handle); in hci_le_cis_req_evt()
7006 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()
7007 acl_handle, cis_handle, ev->cig_id, ev->cis_id); in hci_le_cis_req_evt()
7015 mask = hci_proto_connect_ind(hdev, &acl->dst, ISO_LINK, &flags); in hci_le_cis_req_evt()
7017 hci_le_reject_cis(hdev, ev->cis_handle); in hci_le_cis_req_evt()
7023 cis = hci_conn_add(hdev, ISO_LINK, &acl->dst, HCI_ROLE_SLAVE); in hci_le_cis_req_evt()
7025 hci_le_reject_cis(hdev, ev->cis_handle); in hci_le_cis_req_evt()
7028 cis->handle = cis_handle; in hci_le_cis_req_evt()
7031 cis->iso_qos.ucast.cig = ev->cig_id; in hci_le_cis_req_evt()
7032 cis->iso_qos.ucast.cis = ev->cis_id; in hci_le_cis_req_evt()
7035 hci_le_accept_cis(hdev, ev->cis_handle); in hci_le_cis_req_evt()
7037 cis->state = BT_CONNECT2; in hci_le_cis_req_evt()
7060 BT_DBG("%s status 0x%2.2x", hdev->name, ev->status); in hci_le_create_big_complete_evt()
7063 flex_array_size(ev, bis_handle, ev->num_bis))) in hci_le_create_big_complete_evt()
7070 list_for_each_entry_rcu(conn, &hdev->conn_hash.list, list) { in hci_le_create_big_complete_evt()
7071 if (bacmp(&conn->dst, BDADDR_ANY) || in hci_le_create_big_complete_evt()
7072 conn->type != ISO_LINK || in hci_le_create_big_complete_evt()
7073 conn->iso_qos.bcast.big != ev->handle) in hci_le_create_big_complete_evt()
7077 __le16_to_cpu(ev->bis_handle[i++]))) in hci_le_create_big_complete_evt()
7080 if (!ev->status) { in hci_le_create_big_complete_evt()
7081 conn->state = BT_CONNECTED; in hci_le_create_big_complete_evt()
7082 set_bit(HCI_CONN_BIG_CREATED, &conn->flags); in hci_le_create_big_complete_evt()
7091 hci_connect_cfm(conn, ev->status); in hci_le_create_big_complete_evt()
7099 if (!ev->status && !i) in hci_le_create_big_complete_evt()
7106 UINT_PTR(ev->handle), NULL); in hci_le_create_big_complete_evt()
7119 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_big_sync_established_evt()
7122 flex_array_size(ev, bis, ev->num_bis))) in hci_le_big_sync_established_evt()
7127 if (!ev->status) { in hci_le_big_sync_established_evt()
7128 pa_sync = hci_conn_hash_lookup_pa_sync(hdev, ev->handle); in hci_le_big_sync_established_evt()
7133 set_bit(HCI_CONN_BIG_SYNC, &pa_sync->flags); in hci_le_big_sync_established_evt()
7136 for (i = 0; i < ev->num_bis; i++) { in hci_le_big_sync_established_evt()
7137 u16 handle = le16_to_cpu(ev->bis[i]); in hci_le_big_sync_established_evt()
7146 bis->handle = handle; in hci_le_big_sync_established_evt()
7149 if (ev->status != 0x42) in hci_le_big_sync_established_evt()
7151 set_bit(HCI_CONN_PA_SYNC, &bis->flags); in hci_le_big_sync_established_evt()
7153 bis->iso_qos.bcast.big = ev->handle; in hci_le_big_sync_established_evt()
7155 memcpy(&interval, ev->latency, sizeof(ev->latency)); in hci_le_big_sync_established_evt()
7156 bis->iso_qos.bcast.in.interval = le32_to_cpu(interval); in hci_le_big_sync_established_evt()
7158 bis->iso_qos.bcast.in.latency = le16_to_cpu(ev->interval) * 125 / 100; in hci_le_big_sync_established_evt()
7159 bis->iso_qos.bcast.in.sdu = le16_to_cpu(ev->max_pdu); in hci_le_big_sync_established_evt()
7161 if (!ev->status) { in hci_le_big_sync_established_evt()
7162 set_bit(HCI_CONN_BIG_SYNC, &bis->flags); in hci_le_big_sync_established_evt()
7170 if (ev->status) in hci_le_big_sync_established_evt()
7171 for (i = 0; i < ev->num_bis; i++) { in hci_le_big_sync_established_evt()
7172 u16 handle = le16_to_cpu(ev->bis[i]); in hci_le_big_sync_established_evt()
7176 set_bit(HCI_CONN_BIG_SYNC_FAILED, &bis->flags); in hci_le_big_sync_established_evt()
7177 hci_connect_cfm(bis, ev->status); in hci_le_big_sync_established_evt()
7187 int mask = hdev->link_mode; in hci_le_big_info_adv_report_evt()
7190 bt_dev_dbg(hdev, "sync_handle 0x%4.4x", le16_to_cpu(ev->sync_handle)); in hci_le_big_info_adv_report_evt()
7196 hci_le_pa_term_sync(hdev, ev->sync_handle); in hci_le_big_info_adv_report_evt()
7304 bt_dev_dbg(hdev, "subevent 0x%2.2x", ev->subevent); in hci_le_meta_evt()
7307 if (hdev->sent_cmd && in hci_le_meta_evt()
7308 hci_opcode_ogf(hci_skb_opcode(hdev->sent_cmd)) == 0x08 && in hci_le_meta_evt()
7309 hci_skb_event(hdev->sent_cmd) == ev->subevent) { in hci_le_meta_evt()
7310 *opcode = hci_skb_opcode(hdev->sent_cmd); in hci_le_meta_evt()
7315 subev = &hci_le_ev_table[ev->subevent]; in hci_le_meta_evt()
7316 if (!subev->func) in hci_le_meta_evt()
7319 if (skb->len < subev->min_len) { in hci_le_meta_evt()
7320 bt_dev_err(hdev, "unexpected subevent 0x%2.2x length: %u < %u", in hci_le_meta_evt()
7321 ev->subevent, skb->len, subev->min_len); in hci_le_meta_evt()
7329 if (skb->len > subev->max_len) in hci_le_meta_evt()
7330 bt_dev_warn(hdev, "unexpected subevent 0x%2.2x length: %u > %u", in hci_le_meta_evt()
7331 ev->subevent, skb->len, subev->max_len); in hci_le_meta_evt()
7332 data = hci_le_ev_skb_pull(hdev, skb, ev->subevent, subev->min_len); in hci_le_meta_evt()
7336 subev->func(hdev, data, skb); in hci_le_meta_evt()
7353 if (hdr->evt != event) in hci_get_cmd_complete()
7358 /* Check if request ended in Command Status - no way to retrieve in hci_get_cmd_complete()
7361 if (hdr->evt == HCI_EV_CMD_STATUS) in hci_get_cmd_complete()
7364 if (hdr->evt != HCI_EV_CMD_COMPLETE) { in hci_get_cmd_complete()
7365 bt_dev_err(hdev, "last event is not cmd complete (0x%2.2x)", in hci_get_cmd_complete()
7366 hdr->evt); in hci_get_cmd_complete()
7374 if (opcode != __le16_to_cpu(ev->opcode)) { in hci_get_cmd_complete()
7375 BT_DBG("opcode doesn't match (0x%2.2x != 0x%2.2x)", opcode, in hci_get_cmd_complete()
7376 __le16_to_cpu(ev->opcode)); in hci_get_cmd_complete()
7389 const struct hci_ev_conn_complete *conn_complete = (void *)skb->data; in hci_store_wake_reason()
7390 const struct hci_ev_conn_request *conn_request = (void *)skb->data; in hci_store_wake_reason()
7397 if (!hdev->suspended || hdev->wake_reason) in hci_store_wake_reason()
7403 hdev->wake_reason = MGMT_WAKE_REASON_REMOTE_WAKE; in hci_store_wake_reason()
7410 bacpy(&hdev->wake_addr, &conn_complete->bdaddr); in hci_store_wake_reason()
7411 hdev->wake_addr_type = BDADDR_BREDR; in hci_store_wake_reason()
7413 bacpy(&hdev->wake_addr, &conn_request->bdaddr); in hci_store_wake_reason()
7414 hdev->wake_addr_type = BDADDR_BREDR; in hci_store_wake_reason()
7416 struct hci_ev_le_meta *le_ev = (void *)skb->data; in hci_store_wake_reason()
7417 u8 subevent = le_ev->subevent; in hci_store_wake_reason()
7418 u8 *ptr = &skb->data[sizeof(*le_ev)]; in hci_store_wake_reason()
7431 bacpy(&hdev->wake_addr, &adv->bdaddr); in hci_store_wake_reason()
7432 hdev->wake_addr_type = adv->bdaddr_type; in hci_store_wake_reason()
7435 bacpy(&hdev->wake_addr, &direct_adv->bdaddr); in hci_store_wake_reason()
7436 hdev->wake_addr_type = direct_adv->bdaddr_type; in hci_store_wake_reason()
7439 bacpy(&hdev->wake_addr, &ext_adv->bdaddr); in hci_store_wake_reason()
7440 hdev->wake_addr_type = ext_adv->bdaddr_type; in hci_store_wake_reason()
7445 hdev->wake_reason = MGMT_WAKE_REASON_UNEXPECTED; in hci_store_wake_reason()
7643 if (!ev->func) in hci_event_func()
7646 if (skb->len < ev->min_len) { in hci_event_func()
7647 bt_dev_err(hdev, "unexpected event 0x%2.2x length: %u < %u", in hci_event_func()
7648 event, skb->len, ev->min_len); in hci_event_func()
7656 if (skb->len > ev->max_len) in hci_event_func()
7658 "unexpected event 0x%2.2x length: %u > %u", in hci_event_func()
7659 event, skb->len, ev->max_len); in hci_event_func()
7661 data = hci_ev_skb_pull(hdev, skb, event, ev->min_len); in hci_event_func()
7665 if (ev->req) in hci_event_func()
7666 ev->func_req(hdev, data, skb, opcode, status, req_complete, in hci_event_func()
7669 ev->func(hdev, data, skb); in hci_event_func()
7674 struct hci_event_hdr *hdr = (void *) skb->data; in hci_event_packet()
7681 if (skb->len < sizeof(*hdr)) { in hci_event_packet()
7686 kfree_skb(hdev->recv_event); in hci_event_packet()
7687 hdev->recv_event = skb_clone(skb, GFP_KERNEL); in hci_event_packet()
7689 event = hdr->evt; in hci_event_packet()
7691 bt_dev_warn(hdev, "Received unexpected HCI Event 0x%2.2x", in hci_event_packet()
7697 if (hdev->sent_cmd && in hci_event_packet()
7698 hci_opcode_ogf(hci_skb_opcode(hdev->sent_cmd)) != 0x08 && in hci_event_packet()
7699 hci_skb_event(hdev->sent_cmd) == event) { in hci_event_packet()
7700 hci_req_cmd_complete(hdev, hci_skb_opcode(hdev->sent_cmd), in hci_event_packet()
7719 bt_dev_dbg(hdev, "event 0x%2.2x", event); in hci_event_packet()
7737 hdev->stat.evt_rx++; in hci_event_packet()