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.
55 bt_dev_err(hdev, "Malformed Event: 0x%2.2x", ev); in hci_ev_skb_pull()
67 bt_dev_err(hdev, "Malformed Command Complete: 0x%4.4x", op); in hci_cc_skb_pull()
79 bt_dev_err(hdev, "Malformed LE Event: 0x%2.2x", ev); in hci_le_ev_skb_pull()
87 struct hci_ev_status *rp = data; in hci_cc_inquiry_cancel() local
89 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_inquiry_cancel()
98 if (rp->status == 0x0c && !test_bit(HCI_INQUIRY, &hdev->flags)) { in hci_cc_inquiry_cancel()
100 rp->status = 0x00; in hci_cc_inquiry_cancel()
103 if (rp->status) in hci_cc_inquiry_cancel()
104 return rp->status; in hci_cc_inquiry_cancel()
106 clear_bit(HCI_INQUIRY, &hdev->flags); in hci_cc_inquiry_cancel()
108 wake_up_bit(&hdev->flags, HCI_INQUIRY); in hci_cc_inquiry_cancel()
115 hdev->le_scan_type != LE_SCAN_ACTIVE) in hci_cc_inquiry_cancel()
121 return rp->status; in hci_cc_inquiry_cancel()
127 struct hci_ev_status *rp = data; in hci_cc_periodic_inq() local
129 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_periodic_inq()
131 if (rp->status) in hci_cc_periodic_inq()
132 return rp->status; in hci_cc_periodic_inq()
136 return rp->status; in hci_cc_periodic_inq()
142 struct hci_ev_status *rp = data; in hci_cc_exit_periodic_inq() local
144 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_exit_periodic_inq()
146 if (rp->status) in hci_cc_exit_periodic_inq()
147 return rp->status; in hci_cc_exit_periodic_inq()
153 return rp->status; in hci_cc_exit_periodic_inq()
159 struct hci_ev_status *rp = data; in hci_cc_remote_name_req_cancel() local
161 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_remote_name_req_cancel()
163 return rp->status; in hci_cc_remote_name_req_cancel()
169 struct hci_rp_role_discovery *rp = data; in hci_cc_role_discovery() local
172 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_role_discovery()
174 if (rp->status) in hci_cc_role_discovery()
175 return rp->status; in hci_cc_role_discovery()
179 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_role_discovery()
181 conn->role = rp->role; in hci_cc_role_discovery()
185 return rp->status; in hci_cc_role_discovery()
191 struct hci_rp_read_link_policy *rp = data; in hci_cc_read_link_policy() local
194 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_link_policy()
196 if (rp->status) in hci_cc_read_link_policy()
197 return rp->status; in hci_cc_read_link_policy()
201 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_link_policy()
203 conn->link_policy = __le16_to_cpu(rp->policy); in hci_cc_read_link_policy()
207 return rp->status; in hci_cc_read_link_policy()
213 struct hci_rp_write_link_policy *rp = data; in hci_cc_write_link_policy() local
217 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_link_policy()
219 if (rp->status) in hci_cc_write_link_policy()
220 return rp->status; in hci_cc_write_link_policy()
224 return rp->status; in hci_cc_write_link_policy()
228 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_write_link_policy()
230 conn->link_policy = get_unaligned_le16(sent + 2); in hci_cc_write_link_policy()
234 return rp->status; in hci_cc_write_link_policy()
240 struct hci_rp_read_def_link_policy *rp = data; in hci_cc_read_def_link_policy() local
242 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_def_link_policy()
244 if (rp->status) in hci_cc_read_def_link_policy()
245 return rp->status; in hci_cc_read_def_link_policy()
247 hdev->link_policy = __le16_to_cpu(rp->policy); in hci_cc_read_def_link_policy()
249 return rp->status; in hci_cc_read_def_link_policy()
255 struct hci_ev_status *rp = data; in hci_cc_write_def_link_policy() local
258 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_def_link_policy()
260 if (rp->status) in hci_cc_write_def_link_policy()
261 return rp->status; in hci_cc_write_def_link_policy()
265 return rp->status; in hci_cc_write_def_link_policy()
267 hdev->link_policy = get_unaligned_le16(sent); in hci_cc_write_def_link_policy()
269 return rp->status; in hci_cc_write_def_link_policy()
274 struct hci_ev_status *rp = data; in hci_cc_reset() local
276 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_reset()
278 clear_bit(HCI_RESET, &hdev->flags); in hci_cc_reset()
280 if (rp->status) in hci_cc_reset()
281 return rp->status; in hci_cc_reset()
283 /* Reset all non-persistent flags */ in hci_cc_reset()
288 hdev->inq_tx_power = HCI_TX_POWER_INVALID; in hci_cc_reset()
289 hdev->adv_tx_power = HCI_TX_POWER_INVALID; in hci_cc_reset()
291 memset(hdev->adv_data, 0, sizeof(hdev->adv_data)); in hci_cc_reset()
292 hdev->adv_data_len = 0; in hci_cc_reset()
294 memset(hdev->scan_rsp_data, 0, sizeof(hdev->scan_rsp_data)); in hci_cc_reset()
295 hdev->scan_rsp_data_len = 0; in hci_cc_reset()
297 hdev->le_scan_type = LE_SCAN_PASSIVE; in hci_cc_reset()
299 hdev->ssp_debug_mode = 0; in hci_cc_reset()
301 hci_bdaddr_list_clear(&hdev->le_accept_list); in hci_cc_reset()
302 hci_bdaddr_list_clear(&hdev->le_resolv_list); in hci_cc_reset()
304 return rp->status; in hci_cc_reset()
310 struct hci_rp_read_stored_link_key *rp = data; in hci_cc_read_stored_link_key() local
313 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_stored_link_key()
317 return rp->status; in hci_cc_read_stored_link_key()
319 if (!rp->status && sent->read_all == 0x01) { in hci_cc_read_stored_link_key()
320 hdev->stored_max_keys = le16_to_cpu(rp->max_keys); in hci_cc_read_stored_link_key()
321 hdev->stored_num_keys = le16_to_cpu(rp->num_keys); in hci_cc_read_stored_link_key()
324 return rp->status; in hci_cc_read_stored_link_key()
330 struct hci_rp_delete_stored_link_key *rp = data; in hci_cc_delete_stored_link_key() local
333 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_delete_stored_link_key()
335 if (rp->status) in hci_cc_delete_stored_link_key()
336 return rp->status; in hci_cc_delete_stored_link_key()
338 num_keys = le16_to_cpu(rp->num_keys); in hci_cc_delete_stored_link_key()
340 if (num_keys <= hdev->stored_num_keys) in hci_cc_delete_stored_link_key()
341 hdev->stored_num_keys -= num_keys; in hci_cc_delete_stored_link_key()
343 hdev->stored_num_keys = 0; in hci_cc_delete_stored_link_key()
345 return rp->status; in hci_cc_delete_stored_link_key()
351 struct hci_ev_status *rp = data; in hci_cc_write_local_name() local
354 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_local_name()
358 return rp->status; in hci_cc_write_local_name()
363 mgmt_set_local_name_complete(hdev, sent, rp->status); in hci_cc_write_local_name()
364 else if (!rp->status) in hci_cc_write_local_name()
365 memcpy(hdev->dev_name, sent, HCI_MAX_NAME_LENGTH); in hci_cc_write_local_name()
369 return rp->status; in hci_cc_write_local_name()
375 struct hci_rp_read_local_name *rp = data; in hci_cc_read_local_name() local
377 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_name()
379 if (rp->status) in hci_cc_read_local_name()
380 return rp->status; in hci_cc_read_local_name()
384 memcpy(hdev->dev_name, rp->name, HCI_MAX_NAME_LENGTH); in hci_cc_read_local_name()
386 return rp->status; in hci_cc_read_local_name()
392 struct hci_ev_status *rp = data; in hci_cc_write_auth_enable() local
395 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_auth_enable()
399 return rp->status; in hci_cc_write_auth_enable()
403 if (!rp->status) { in hci_cc_write_auth_enable()
407 set_bit(HCI_AUTH, &hdev->flags); in hci_cc_write_auth_enable()
409 clear_bit(HCI_AUTH, &hdev->flags); in hci_cc_write_auth_enable()
413 mgmt_auth_enable_complete(hdev, rp->status); in hci_cc_write_auth_enable()
417 return rp->status; in hci_cc_write_auth_enable()
423 struct hci_ev_status *rp = data; in hci_cc_write_encrypt_mode() local
427 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_encrypt_mode()
429 if (rp->status) in hci_cc_write_encrypt_mode()
430 return rp->status; in hci_cc_write_encrypt_mode()
434 return rp->status; in hci_cc_write_encrypt_mode()
439 set_bit(HCI_ENCRYPT, &hdev->flags); in hci_cc_write_encrypt_mode()
441 clear_bit(HCI_ENCRYPT, &hdev->flags); in hci_cc_write_encrypt_mode()
443 return rp->status; in hci_cc_write_encrypt_mode()
449 struct hci_ev_status *rp = data; in hci_cc_write_scan_enable() local
453 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_scan_enable()
457 return rp->status; in hci_cc_write_scan_enable()
463 if (rp->status) { in hci_cc_write_scan_enable()
464 hdev->discov_timeout = 0; in hci_cc_write_scan_enable()
469 set_bit(HCI_ISCAN, &hdev->flags); in hci_cc_write_scan_enable()
471 clear_bit(HCI_ISCAN, &hdev->flags); in hci_cc_write_scan_enable()
474 set_bit(HCI_PSCAN, &hdev->flags); in hci_cc_write_scan_enable()
476 clear_bit(HCI_PSCAN, &hdev->flags); in hci_cc_write_scan_enable()
481 return rp->status; in hci_cc_write_scan_enable()
487 struct hci_ev_status *rp = data; in hci_cc_set_event_filter() local
491 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_set_event_filter()
493 if (rp->status) in hci_cc_set_event_filter()
494 return rp->status; in hci_cc_set_event_filter()
498 return rp->status; in hci_cc_set_event_filter()
502 if (cp->flt_type == HCI_FLT_CLEAR_ALL) in hci_cc_set_event_filter()
507 return rp->status; in hci_cc_set_event_filter()
513 struct hci_rp_read_class_of_dev *rp = data; in hci_cc_read_class_of_dev() local
515 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_class_of_dev()
517 if (rp->status) in hci_cc_read_class_of_dev()
518 return rp->status; in hci_cc_read_class_of_dev()
520 memcpy(hdev->dev_class, rp->dev_class, 3); in hci_cc_read_class_of_dev()
522 bt_dev_dbg(hdev, "class 0x%.2x%.2x%.2x", hdev->dev_class[2], in hci_cc_read_class_of_dev()
523 hdev->dev_class[1], hdev->dev_class[0]); in hci_cc_read_class_of_dev()
525 return rp->status; in hci_cc_read_class_of_dev()
531 struct hci_ev_status *rp = data; in hci_cc_write_class_of_dev() local
534 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_class_of_dev()
538 return rp->status; in hci_cc_write_class_of_dev()
542 if (!rp->status) in hci_cc_write_class_of_dev()
543 memcpy(hdev->dev_class, sent, 3); in hci_cc_write_class_of_dev()
546 mgmt_set_class_of_dev_complete(hdev, sent, rp->status); in hci_cc_write_class_of_dev()
550 return rp->status; in hci_cc_write_class_of_dev()
556 struct hci_rp_read_voice_setting *rp = data; in hci_cc_read_voice_setting() local
559 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_voice_setting()
561 if (rp->status) in hci_cc_read_voice_setting()
562 return rp->status; in hci_cc_read_voice_setting()
564 setting = __le16_to_cpu(rp->voice_setting); in hci_cc_read_voice_setting()
566 if (hdev->voice_setting == setting) in hci_cc_read_voice_setting()
567 return rp->status; in hci_cc_read_voice_setting()
569 hdev->voice_setting = setting; in hci_cc_read_voice_setting()
571 bt_dev_dbg(hdev, "voice setting 0x%4.4x", setting); in hci_cc_read_voice_setting()
573 if (hdev->notify) in hci_cc_read_voice_setting()
574 hdev->notify(hdev, HCI_NOTIFY_VOICE_SETTING); in hci_cc_read_voice_setting()
576 return rp->status; in hci_cc_read_voice_setting()
582 struct hci_ev_status *rp = data; in hci_cc_write_voice_setting() local
586 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_voice_setting()
588 if (rp->status) in hci_cc_write_voice_setting()
589 return rp->status; in hci_cc_write_voice_setting()
593 return rp->status; in hci_cc_write_voice_setting()
597 if (hdev->voice_setting == setting) in hci_cc_write_voice_setting()
598 return rp->status; in hci_cc_write_voice_setting()
600 hdev->voice_setting = setting; in hci_cc_write_voice_setting()
602 bt_dev_dbg(hdev, "voice setting 0x%4.4x", setting); in hci_cc_write_voice_setting()
604 if (hdev->notify) in hci_cc_write_voice_setting()
605 hdev->notify(hdev, HCI_NOTIFY_VOICE_SETTING); in hci_cc_write_voice_setting()
607 return rp->status; in hci_cc_write_voice_setting()
613 struct hci_rp_read_num_supported_iac *rp = data; in hci_cc_read_num_supported_iac() local
615 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_num_supported_iac()
617 if (rp->status) in hci_cc_read_num_supported_iac()
618 return rp->status; in hci_cc_read_num_supported_iac()
620 hdev->num_iac = rp->num_iac; in hci_cc_read_num_supported_iac()
622 bt_dev_dbg(hdev, "num iac %d", hdev->num_iac); in hci_cc_read_num_supported_iac()
624 return rp->status; in hci_cc_read_num_supported_iac()
630 struct hci_ev_status *rp = data; in hci_cc_write_ssp_mode() local
633 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_ssp_mode()
637 return rp->status; in hci_cc_write_ssp_mode()
641 if (!rp->status) { in hci_cc_write_ssp_mode()
642 if (sent->mode) in hci_cc_write_ssp_mode()
643 hdev->features[1][0] |= LMP_HOST_SSP; in hci_cc_write_ssp_mode()
645 hdev->features[1][0] &= ~LMP_HOST_SSP; in hci_cc_write_ssp_mode()
648 if (!rp->status) { in hci_cc_write_ssp_mode()
649 if (sent->mode) in hci_cc_write_ssp_mode()
657 return rp->status; in hci_cc_write_ssp_mode()
663 struct hci_ev_status *rp = data; in hci_cc_write_sc_support() local
666 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_sc_support()
670 return rp->status; in hci_cc_write_sc_support()
674 if (!rp->status) { in hci_cc_write_sc_support()
675 if (sent->support) in hci_cc_write_sc_support()
676 hdev->features[1][0] |= LMP_HOST_SC; in hci_cc_write_sc_support()
678 hdev->features[1][0] &= ~LMP_HOST_SC; in hci_cc_write_sc_support()
681 if (!hci_dev_test_flag(hdev, HCI_MGMT) && !rp->status) { in hci_cc_write_sc_support()
682 if (sent->support) in hci_cc_write_sc_support()
690 return rp->status; in hci_cc_write_sc_support()
696 struct hci_rp_read_local_version *rp = data; in hci_cc_read_local_version() local
698 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_version()
700 if (rp->status) in hci_cc_read_local_version()
701 return rp->status; in hci_cc_read_local_version()
705 hdev->hci_ver = rp->hci_ver; in hci_cc_read_local_version()
706 hdev->hci_rev = __le16_to_cpu(rp->hci_rev); in hci_cc_read_local_version()
707 hdev->lmp_ver = rp->lmp_ver; in hci_cc_read_local_version()
708 hdev->manufacturer = __le16_to_cpu(rp->manufacturer); in hci_cc_read_local_version()
709 hdev->lmp_subver = __le16_to_cpu(rp->lmp_subver); in hci_cc_read_local_version()
712 return rp->status; in hci_cc_read_local_version()
718 struct hci_rp_read_enc_key_size *rp = data; in hci_cc_read_enc_key_size() local
721 u8 status = rp->status; in hci_cc_read_enc_key_size()
723 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cc_read_enc_key_size()
725 handle = le16_to_cpu(rp->handle); in hci_cc_read_enc_key_size()
742 conn->enc_key_size = 0; in hci_cc_read_enc_key_size()
744 conn->enc_key_size = rp->key_size; in hci_cc_read_enc_key_size()
759 struct hci_rp_read_local_commands *rp = data; in hci_cc_read_local_commands() local
761 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_commands()
763 if (rp->status) in hci_cc_read_local_commands()
764 return rp->status; in hci_cc_read_local_commands()
768 memcpy(hdev->commands, rp->commands, sizeof(hdev->commands)); in hci_cc_read_local_commands()
770 return rp->status; in hci_cc_read_local_commands()
776 struct hci_rp_read_auth_payload_to *rp = data; in hci_cc_read_auth_payload_timeout() local
779 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_auth_payload_timeout()
781 if (rp->status) in hci_cc_read_auth_payload_timeout()
782 return rp->status; in hci_cc_read_auth_payload_timeout()
786 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_auth_payload_timeout()
788 conn->auth_payload_timeout = __le16_to_cpu(rp->timeout); in hci_cc_read_auth_payload_timeout()
792 return rp->status; in hci_cc_read_auth_payload_timeout()
798 struct hci_rp_write_auth_payload_to *rp = data; in hci_cc_write_auth_payload_timeout() local
802 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_auth_payload_timeout()
804 if (rp->status) in hci_cc_write_auth_payload_timeout()
805 return rp->status; in hci_cc_write_auth_payload_timeout()
809 return rp->status; in hci_cc_write_auth_payload_timeout()
813 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_write_auth_payload_timeout()
815 conn->auth_payload_timeout = get_unaligned_le16(sent + 2); in hci_cc_write_auth_payload_timeout()
819 return rp->status; in hci_cc_write_auth_payload_timeout()
825 struct hci_rp_read_local_features *rp = data; in hci_cc_read_local_features() local
827 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_features()
829 if (rp->status) in hci_cc_read_local_features()
830 return rp->status; in hci_cc_read_local_features()
832 memcpy(hdev->features, rp->features, 8); in hci_cc_read_local_features()
837 if (hdev->features[0][0] & LMP_3SLOT) in hci_cc_read_local_features()
838 hdev->pkt_type |= (HCI_DM3 | HCI_DH3); in hci_cc_read_local_features()
840 if (hdev->features[0][0] & LMP_5SLOT) in hci_cc_read_local_features()
841 hdev->pkt_type |= (HCI_DM5 | HCI_DH5); in hci_cc_read_local_features()
843 if (hdev->features[0][1] & LMP_HV2) { in hci_cc_read_local_features()
844 hdev->pkt_type |= (HCI_HV2); in hci_cc_read_local_features()
845 hdev->esco_type |= (ESCO_HV2); in hci_cc_read_local_features()
848 if (hdev->features[0][1] & LMP_HV3) { in hci_cc_read_local_features()
849 hdev->pkt_type |= (HCI_HV3); in hci_cc_read_local_features()
850 hdev->esco_type |= (ESCO_HV3); in hci_cc_read_local_features()
854 hdev->esco_type |= (ESCO_EV3); in hci_cc_read_local_features()
856 if (hdev->features[0][4] & LMP_EV4) in hci_cc_read_local_features()
857 hdev->esco_type |= (ESCO_EV4); in hci_cc_read_local_features()
859 if (hdev->features[0][4] & LMP_EV5) in hci_cc_read_local_features()
860 hdev->esco_type |= (ESCO_EV5); in hci_cc_read_local_features()
862 if (hdev->features[0][5] & LMP_EDR_ESCO_2M) in hci_cc_read_local_features()
863 hdev->esco_type |= (ESCO_2EV3); in hci_cc_read_local_features()
865 if (hdev->features[0][5] & LMP_EDR_ESCO_3M) in hci_cc_read_local_features()
866 hdev->esco_type |= (ESCO_3EV3); in hci_cc_read_local_features()
868 if (hdev->features[0][5] & LMP_EDR_3S_ESCO) in hci_cc_read_local_features()
869 hdev->esco_type |= (ESCO_2EV5 | ESCO_3EV5); in hci_cc_read_local_features()
871 return rp->status; in hci_cc_read_local_features()
877 struct hci_rp_read_local_ext_features *rp = data; in hci_cc_read_local_ext_features() local
879 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_ext_features()
881 if (rp->status) in hci_cc_read_local_ext_features()
882 return rp->status; in hci_cc_read_local_ext_features()
884 if (hdev->max_page < rp->max_page) in hci_cc_read_local_ext_features()
885 hdev->max_page = rp->max_page; in hci_cc_read_local_ext_features()
887 if (rp->page < HCI_MAX_PAGES) in hci_cc_read_local_ext_features()
888 memcpy(hdev->features[rp->page], rp->features, 8); in hci_cc_read_local_ext_features()
890 return rp->status; in hci_cc_read_local_ext_features()
896 struct hci_rp_read_flow_control_mode *rp = data; in hci_cc_read_flow_control_mode() local
898 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_flow_control_mode()
900 if (rp->status) in hci_cc_read_flow_control_mode()
901 return rp->status; in hci_cc_read_flow_control_mode()
903 hdev->flow_ctl_mode = rp->mode; in hci_cc_read_flow_control_mode()
905 return rp->status; in hci_cc_read_flow_control_mode()
911 struct hci_rp_read_buffer_size *rp = data; in hci_cc_read_buffer_size() local
913 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_buffer_size()
915 if (rp->status) in hci_cc_read_buffer_size()
916 return rp->status; in hci_cc_read_buffer_size()
918 hdev->acl_mtu = __le16_to_cpu(rp->acl_mtu); in hci_cc_read_buffer_size()
919 hdev->sco_mtu = rp->sco_mtu; in hci_cc_read_buffer_size()
920 hdev->acl_pkts = __le16_to_cpu(rp->acl_max_pkt); in hci_cc_read_buffer_size()
921 hdev->sco_pkts = __le16_to_cpu(rp->sco_max_pkt); in hci_cc_read_buffer_size()
923 if (test_bit(HCI_QUIRK_FIXUP_BUFFER_SIZE, &hdev->quirks)) { in hci_cc_read_buffer_size()
924 hdev->sco_mtu = 64; in hci_cc_read_buffer_size()
925 hdev->sco_pkts = 8; in hci_cc_read_buffer_size()
928 hdev->acl_cnt = hdev->acl_pkts; in hci_cc_read_buffer_size()
929 hdev->sco_cnt = hdev->sco_pkts; in hci_cc_read_buffer_size()
931 BT_DBG("%s acl mtu %d:%d sco mtu %d:%d", hdev->name, hdev->acl_mtu, in hci_cc_read_buffer_size()
932 hdev->acl_pkts, hdev->sco_mtu, hdev->sco_pkts); in hci_cc_read_buffer_size()
934 return rp->status; in hci_cc_read_buffer_size()
940 struct hci_rp_read_bd_addr *rp = data; in hci_cc_read_bd_addr() local
942 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_bd_addr()
944 if (rp->status) in hci_cc_read_bd_addr()
945 return rp->status; in hci_cc_read_bd_addr()
947 if (test_bit(HCI_INIT, &hdev->flags)) in hci_cc_read_bd_addr()
948 bacpy(&hdev->bdaddr, &rp->bdaddr); in hci_cc_read_bd_addr()
951 bacpy(&hdev->setup_addr, &rp->bdaddr); in hci_cc_read_bd_addr()
953 return rp->status; in hci_cc_read_bd_addr()
959 struct hci_rp_read_local_pairing_opts *rp = data; in hci_cc_read_local_pairing_opts() local
961 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_pairing_opts()
963 if (rp->status) in hci_cc_read_local_pairing_opts()
964 return rp->status; in hci_cc_read_local_pairing_opts()
968 hdev->pairing_opts = rp->pairing_opts; in hci_cc_read_local_pairing_opts()
969 hdev->max_enc_key_size = rp->max_key_size; in hci_cc_read_local_pairing_opts()
972 return rp->status; in hci_cc_read_local_pairing_opts()
978 struct hci_rp_read_page_scan_activity *rp = data; in hci_cc_read_page_scan_activity() local
980 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_page_scan_activity()
982 if (rp->status) in hci_cc_read_page_scan_activity()
983 return rp->status; in hci_cc_read_page_scan_activity()
985 if (test_bit(HCI_INIT, &hdev->flags)) { in hci_cc_read_page_scan_activity()
986 hdev->page_scan_interval = __le16_to_cpu(rp->interval); in hci_cc_read_page_scan_activity()
987 hdev->page_scan_window = __le16_to_cpu(rp->window); in hci_cc_read_page_scan_activity()
990 return rp->status; in hci_cc_read_page_scan_activity()
996 struct hci_ev_status *rp = data; in hci_cc_write_page_scan_activity() local
999 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_page_scan_activity()
1001 if (rp->status) in hci_cc_write_page_scan_activity()
1002 return rp->status; in hci_cc_write_page_scan_activity()
1006 return rp->status; in hci_cc_write_page_scan_activity()
1008 hdev->page_scan_interval = __le16_to_cpu(sent->interval); in hci_cc_write_page_scan_activity()
1009 hdev->page_scan_window = __le16_to_cpu(sent->window); in hci_cc_write_page_scan_activity()
1011 return rp->status; in hci_cc_write_page_scan_activity()
1017 struct hci_rp_read_page_scan_type *rp = data; in hci_cc_read_page_scan_type() local
1019 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_page_scan_type()
1021 if (rp->status) in hci_cc_read_page_scan_type()
1022 return rp->status; in hci_cc_read_page_scan_type()
1024 if (test_bit(HCI_INIT, &hdev->flags)) in hci_cc_read_page_scan_type()
1025 hdev->page_scan_type = rp->type; in hci_cc_read_page_scan_type()
1027 return rp->status; in hci_cc_read_page_scan_type()
1033 struct hci_ev_status *rp = data; in hci_cc_write_page_scan_type() local
1036 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_page_scan_type()
1038 if (rp->status) in hci_cc_write_page_scan_type()
1039 return rp->status; in hci_cc_write_page_scan_type()
1043 hdev->page_scan_type = *type; in hci_cc_write_page_scan_type()
1045 return rp->status; in hci_cc_write_page_scan_type()
1051 struct hci_rp_read_data_block_size *rp = data; in hci_cc_read_data_block_size() local
1053 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_data_block_size()
1055 if (rp->status) in hci_cc_read_data_block_size()
1056 return rp->status; in hci_cc_read_data_block_size()
1058 hdev->block_mtu = __le16_to_cpu(rp->max_acl_len); in hci_cc_read_data_block_size()
1059 hdev->block_len = __le16_to_cpu(rp->block_len); in hci_cc_read_data_block_size()
1060 hdev->num_blocks = __le16_to_cpu(rp->num_blocks); in hci_cc_read_data_block_size()
1062 hdev->block_cnt = hdev->num_blocks; in hci_cc_read_data_block_size()
1064 BT_DBG("%s blk mtu %d cnt %d len %d", hdev->name, hdev->block_mtu, in hci_cc_read_data_block_size()
1065 hdev->block_cnt, hdev->block_len); in hci_cc_read_data_block_size()
1067 return rp->status; in hci_cc_read_data_block_size()
1073 struct hci_rp_read_clock *rp = data; in hci_cc_read_clock() local
1077 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_clock()
1079 if (rp->status) in hci_cc_read_clock()
1080 return rp->status; in hci_cc_read_clock()
1088 if (cp->which == 0x00) { in hci_cc_read_clock()
1089 hdev->clock = le32_to_cpu(rp->clock); in hci_cc_read_clock()
1093 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_clock()
1095 conn->clock = le32_to_cpu(rp->clock); in hci_cc_read_clock()
1096 conn->clock_accuracy = le16_to_cpu(rp->accuracy); in hci_cc_read_clock()
1101 return rp->status; in hci_cc_read_clock()
1107 struct hci_rp_read_local_amp_info *rp = data; in hci_cc_read_local_amp_info() local
1109 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_amp_info()
1111 if (rp->status) in hci_cc_read_local_amp_info()
1112 return rp->status; in hci_cc_read_local_amp_info()
1114 hdev->amp_status = rp->amp_status; in hci_cc_read_local_amp_info()
1115 hdev->amp_total_bw = __le32_to_cpu(rp->total_bw); in hci_cc_read_local_amp_info()
1116 hdev->amp_max_bw = __le32_to_cpu(rp->max_bw); in hci_cc_read_local_amp_info()
1117 hdev->amp_min_latency = __le32_to_cpu(rp->min_latency); in hci_cc_read_local_amp_info()
1118 hdev->amp_max_pdu = __le32_to_cpu(rp->max_pdu); in hci_cc_read_local_amp_info()
1119 hdev->amp_type = rp->amp_type; in hci_cc_read_local_amp_info()
1120 hdev->amp_pal_cap = __le16_to_cpu(rp->pal_cap); in hci_cc_read_local_amp_info()
1121 hdev->amp_assoc_size = __le16_to_cpu(rp->max_assoc_size); in hci_cc_read_local_amp_info()
1122 hdev->amp_be_flush_to = __le32_to_cpu(rp->be_flush_to); in hci_cc_read_local_amp_info()
1123 hdev->amp_max_flush_to = __le32_to_cpu(rp->max_flush_to); in hci_cc_read_local_amp_info()
1125 return rp->status; in hci_cc_read_local_amp_info()
1131 struct hci_rp_read_inq_rsp_tx_power *rp = data; in hci_cc_read_inq_rsp_tx_power() local
1133 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_inq_rsp_tx_power()
1135 if (rp->status) in hci_cc_read_inq_rsp_tx_power()
1136 return rp->status; in hci_cc_read_inq_rsp_tx_power()
1138 hdev->inq_tx_power = rp->tx_power; in hci_cc_read_inq_rsp_tx_power()
1140 return rp->status; in hci_cc_read_inq_rsp_tx_power()
1146 struct hci_rp_read_def_err_data_reporting *rp = data; in hci_cc_read_def_err_data_reporting() local
1148 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_def_err_data_reporting()
1150 if (rp->status) in hci_cc_read_def_err_data_reporting()
1151 return rp->status; in hci_cc_read_def_err_data_reporting()
1153 hdev->err_data_reporting = rp->err_data_reporting; in hci_cc_read_def_err_data_reporting()
1155 return rp->status; in hci_cc_read_def_err_data_reporting()
1161 struct hci_ev_status *rp = data; in hci_cc_write_def_err_data_reporting() local
1164 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_def_err_data_reporting()
1166 if (rp->status) in hci_cc_write_def_err_data_reporting()
1167 return rp->status; in hci_cc_write_def_err_data_reporting()
1171 return rp->status; in hci_cc_write_def_err_data_reporting()
1173 hdev->err_data_reporting = cp->err_data_reporting; in hci_cc_write_def_err_data_reporting()
1175 return rp->status; in hci_cc_write_def_err_data_reporting()
1181 struct hci_rp_pin_code_reply *rp = data; in hci_cc_pin_code_reply() local
1185 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_pin_code_reply()
1190 mgmt_pin_code_reply_complete(hdev, &rp->bdaddr, rp->status); in hci_cc_pin_code_reply()
1192 if (rp->status) in hci_cc_pin_code_reply()
1199 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cc_pin_code_reply()
1201 conn->pin_length = cp->pin_len; in hci_cc_pin_code_reply()
1205 return rp->status; in hci_cc_pin_code_reply()
1211 struct hci_rp_pin_code_neg_reply *rp = data; in hci_cc_pin_code_neg_reply() local
1213 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_pin_code_neg_reply()
1218 mgmt_pin_code_neg_reply_complete(hdev, &rp->bdaddr, in hci_cc_pin_code_neg_reply()
1219 rp->status); in hci_cc_pin_code_neg_reply()
1223 return rp->status; in hci_cc_pin_code_neg_reply()
1229 struct hci_rp_le_read_buffer_size *rp = data; in hci_cc_le_read_buffer_size() local
1231 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_read_buffer_size()
1233 if (rp->status) in hci_cc_le_read_buffer_size()
1234 return rp->status; in hci_cc_le_read_buffer_size()
1236 hdev->le_mtu = __le16_to_cpu(rp->le_mtu); in hci_cc_le_read_buffer_size()
1237 hdev->le_pkts = rp->le_max_pkt; in hci_cc_le_read_buffer_size()
1239 hdev->le_cnt = hdev->le_pkts; in hci_cc_le_read_buffer_size()
1241 BT_DBG("%s le mtu %d:%d", hdev->name, hdev->le_mtu, hdev->le_pkts); in hci_cc_le_read_buffer_size()
1243 return rp->status; in hci_cc_le_read_buffer_size()
1249 struct hci_rp_le_read_local_features *rp = data; in hci_cc_le_read_local_features() local
1251 BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); in hci_cc_le_read_local_features()
1253 if (rp->status) in hci_cc_le_read_local_features()
1254 return rp->status; in hci_cc_le_read_local_features()
1256 memcpy(hdev->le_features, rp->features, 8); in hci_cc_le_read_local_features()
1258 return rp->status; in hci_cc_le_read_local_features()
1264 struct hci_rp_le_read_adv_tx_power *rp = data; in hci_cc_le_read_adv_tx_power() local
1266 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_read_adv_tx_power()
1268 if (rp->status) in hci_cc_le_read_adv_tx_power()
1269 return rp->status; in hci_cc_le_read_adv_tx_power()
1271 hdev->adv_tx_power = rp->tx_power; in hci_cc_le_read_adv_tx_power()
1273 return rp->status; in hci_cc_le_read_adv_tx_power()
1279 struct hci_rp_user_confirm_reply *rp = data; in hci_cc_user_confirm_reply() local
1281 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_user_confirm_reply()
1286 mgmt_user_confirm_reply_complete(hdev, &rp->bdaddr, ACL_LINK, 0, in hci_cc_user_confirm_reply()
1287 rp->status); in hci_cc_user_confirm_reply()
1291 return rp->status; in hci_cc_user_confirm_reply()
1297 struct hci_rp_user_confirm_reply *rp = data; in hci_cc_user_confirm_neg_reply() local
1299 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_user_confirm_neg_reply()
1304 mgmt_user_confirm_neg_reply_complete(hdev, &rp->bdaddr, in hci_cc_user_confirm_neg_reply()
1305 ACL_LINK, 0, rp->status); in hci_cc_user_confirm_neg_reply()
1309 return rp->status; in hci_cc_user_confirm_neg_reply()
1315 struct hci_rp_user_confirm_reply *rp = data; in hci_cc_user_passkey_reply() local
1317 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_user_passkey_reply()
1322 mgmt_user_passkey_reply_complete(hdev, &rp->bdaddr, ACL_LINK, in hci_cc_user_passkey_reply()
1323 0, rp->status); in hci_cc_user_passkey_reply()
1327 return rp->status; in hci_cc_user_passkey_reply()
1333 struct hci_rp_user_confirm_reply *rp = data; in hci_cc_user_passkey_neg_reply() local
1335 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_user_passkey_neg_reply()
1340 mgmt_user_passkey_neg_reply_complete(hdev, &rp->bdaddr, in hci_cc_user_passkey_neg_reply()
1341 ACL_LINK, 0, rp->status); in hci_cc_user_passkey_neg_reply()
1345 return rp->status; in hci_cc_user_passkey_neg_reply()
1351 struct hci_rp_read_local_oob_data *rp = data; in hci_cc_read_local_oob_data() local
1353 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_oob_data()
1355 return rp->status; in hci_cc_read_local_oob_data()
1361 struct hci_rp_read_local_oob_ext_data *rp = data; in hci_cc_read_local_oob_ext_data() local
1363 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_oob_ext_data()
1365 return rp->status; in hci_cc_read_local_oob_ext_data()
1371 struct hci_ev_status *rp = data; in hci_cc_le_set_random_addr() local
1374 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_random_addr()
1376 if (rp->status) in hci_cc_le_set_random_addr()
1377 return rp->status; in hci_cc_le_set_random_addr()
1381 return rp->status; in hci_cc_le_set_random_addr()
1385 bacpy(&hdev->random_addr, sent); in hci_cc_le_set_random_addr()
1387 if (!bacmp(&hdev->rpa, sent)) { in hci_cc_le_set_random_addr()
1389 queue_delayed_work(hdev->workqueue, &hdev->rpa_expired, in hci_cc_le_set_random_addr()
1390 secs_to_jiffies(hdev->rpa_timeout)); in hci_cc_le_set_random_addr()
1395 return rp->status; in hci_cc_le_set_random_addr()
1401 struct hci_ev_status *rp = data; in hci_cc_le_set_default_phy() local
1404 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_default_phy()
1406 if (rp->status) in hci_cc_le_set_default_phy()
1407 return rp->status; in hci_cc_le_set_default_phy()
1411 return rp->status; in hci_cc_le_set_default_phy()
1415 hdev->le_tx_def_phys = cp->tx_phys; in hci_cc_le_set_default_phy()
1416 hdev->le_rx_def_phys = cp->rx_phys; in hci_cc_le_set_default_phy()
1420 return rp->status; in hci_cc_le_set_default_phy()
1426 struct hci_ev_status *rp = data; in hci_cc_le_set_adv_set_random_addr() local
1430 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_adv_set_random_addr()
1432 if (rp->status) in hci_cc_le_set_adv_set_random_addr()
1433 return rp->status; in hci_cc_le_set_adv_set_random_addr()
1438 * non-extended adverting. in hci_cc_le_set_adv_set_random_addr()
1440 if (!cp || !cp->handle) in hci_cc_le_set_adv_set_random_addr()
1441 return rp->status; in hci_cc_le_set_adv_set_random_addr()
1445 adv = hci_find_adv_instance(hdev, cp->handle); in hci_cc_le_set_adv_set_random_addr()
1447 bacpy(&adv->random_addr, &cp->bdaddr); in hci_cc_le_set_adv_set_random_addr()
1448 if (!bacmp(&hdev->rpa, &cp->bdaddr)) { in hci_cc_le_set_adv_set_random_addr()
1449 adv->rpa_expired = false; in hci_cc_le_set_adv_set_random_addr()
1450 queue_delayed_work(hdev->workqueue, in hci_cc_le_set_adv_set_random_addr()
1451 &adv->rpa_expired_cb, in hci_cc_le_set_adv_set_random_addr()
1452 secs_to_jiffies(hdev->rpa_timeout)); in hci_cc_le_set_adv_set_random_addr()
1458 return rp->status; in hci_cc_le_set_adv_set_random_addr()
1464 struct hci_ev_status *rp = data; in hci_cc_le_remove_adv_set() local
1468 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_remove_adv_set()
1470 if (rp->status) in hci_cc_le_remove_adv_set()
1471 return rp->status; in hci_cc_le_remove_adv_set()
1475 return rp->status; in hci_cc_le_remove_adv_set()
1481 mgmt_advertising_removed(hci_skb_sk(hdev->sent_cmd), hdev, in hci_cc_le_remove_adv_set()
1486 return rp->status; in hci_cc_le_remove_adv_set()
1492 struct hci_ev_status *rp = data; in hci_cc_le_clear_adv_sets() local
1496 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_clear_adv_sets()
1498 if (rp->status) in hci_cc_le_clear_adv_sets()
1499 return rp->status; in hci_cc_le_clear_adv_sets()
1502 return rp->status; in hci_cc_le_clear_adv_sets()
1506 list_for_each_entry_safe(adv, n, &hdev->adv_instances, list) { in hci_cc_le_clear_adv_sets()
1507 u8 instance = adv->instance; in hci_cc_le_clear_adv_sets()
1511 mgmt_advertising_removed(hci_skb_sk(hdev->sent_cmd), in hci_cc_le_clear_adv_sets()
1517 return rp->status; in hci_cc_le_clear_adv_sets()
1523 struct hci_rp_le_read_transmit_power *rp = data; in hci_cc_le_read_transmit_power() local
1525 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_read_transmit_power()
1527 if (rp->status) in hci_cc_le_read_transmit_power()
1528 return rp->status; in hci_cc_le_read_transmit_power()
1530 hdev->min_le_tx_power = rp->min_le_tx_power; in hci_cc_le_read_transmit_power()
1531 hdev->max_le_tx_power = rp->max_le_tx_power; in hci_cc_le_read_transmit_power()
1533 return rp->status; in hci_cc_le_read_transmit_power()
1539 struct hci_ev_status *rp = data; in hci_cc_le_set_privacy_mode() local
1543 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_privacy_mode()
1545 if (rp->status) in hci_cc_le_set_privacy_mode()
1546 return rp->status; in hci_cc_le_set_privacy_mode()
1550 return rp->status; in hci_cc_le_set_privacy_mode()
1554 params = hci_conn_params_lookup(hdev, &cp->bdaddr, cp->bdaddr_type); in hci_cc_le_set_privacy_mode()
1556 params->privacy_mode = cp->mode; in hci_cc_le_set_privacy_mode()
1560 return rp->status; in hci_cc_le_set_privacy_mode()
1566 struct hci_ev_status *rp = data; in hci_cc_le_set_adv_enable() local
1569 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_adv_enable()
1571 if (rp->status) in hci_cc_le_set_adv_enable()
1572 return rp->status; in hci_cc_le_set_adv_enable()
1576 return rp->status; in hci_cc_le_set_adv_enable()
1590 queue_delayed_work(hdev->workqueue, in hci_cc_le_set_adv_enable()
1591 &conn->le_conn_timeout, in hci_cc_le_set_adv_enable()
1592 conn->conn_timeout); in hci_cc_le_set_adv_enable()
1599 return rp->status; in hci_cc_le_set_adv_enable()
1608 struct hci_ev_status *rp = data; in hci_cc_le_set_ext_adv_enable() local
1610 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_ext_adv_enable()
1612 if (rp->status) in hci_cc_le_set_ext_adv_enable()
1613 return rp->status; in hci_cc_le_set_ext_adv_enable()
1617 return rp->status; in hci_cc_le_set_ext_adv_enable()
1619 set = (void *)cp->data; in hci_cc_le_set_ext_adv_enable()
1623 if (cp->num_of_sets) in hci_cc_le_set_ext_adv_enable()
1624 adv = hci_find_adv_instance(hdev, set->handle); in hci_cc_le_set_ext_adv_enable()
1626 if (cp->enable) { in hci_cc_le_set_ext_adv_enable()
1632 adv->enabled = true; in hci_cc_le_set_ext_adv_enable()
1636 queue_delayed_work(hdev->workqueue, in hci_cc_le_set_ext_adv_enable()
1637 &conn->le_conn_timeout, in hci_cc_le_set_ext_adv_enable()
1638 conn->conn_timeout); in hci_cc_le_set_ext_adv_enable()
1640 if (cp->num_of_sets) { in hci_cc_le_set_ext_adv_enable()
1642 adv->enabled = false; in hci_cc_le_set_ext_adv_enable()
1647 list_for_each_entry_safe(adv, n, &hdev->adv_instances, in hci_cc_le_set_ext_adv_enable()
1649 if (adv->enabled) in hci_cc_le_set_ext_adv_enable()
1654 list_for_each_entry_safe(adv, n, &hdev->adv_instances, in hci_cc_le_set_ext_adv_enable()
1656 adv->enabled = false; in hci_cc_le_set_ext_adv_enable()
1664 return rp->status; in hci_cc_le_set_ext_adv_enable()
1671 struct hci_ev_status *rp = data; in hci_cc_le_set_scan_param() local
1673 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_scan_param()
1675 if (rp->status) in hci_cc_le_set_scan_param()
1676 return rp->status; in hci_cc_le_set_scan_param()
1680 return rp->status; in hci_cc_le_set_scan_param()
1684 hdev->le_scan_type = cp->type; in hci_cc_le_set_scan_param()
1688 return rp->status; in hci_cc_le_set_scan_param()
1695 struct hci_ev_status *rp = data; in hci_cc_le_set_ext_scan_param() local
1698 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_ext_scan_param()
1700 if (rp->status) in hci_cc_le_set_ext_scan_param()
1701 return rp->status; in hci_cc_le_set_ext_scan_param()
1705 return rp->status; in hci_cc_le_set_ext_scan_param()
1707 phy_param = (void *)cp->data; in hci_cc_le_set_ext_scan_param()
1711 hdev->le_scan_type = phy_param->type; in hci_cc_le_set_ext_scan_param()
1715 return rp->status; in hci_cc_le_set_ext_scan_param()
1720 struct discovery_state *d = &hdev->discovery; in has_pending_adv_report()
1722 return bacmp(&d->last_adv_addr, BDADDR_ANY); in has_pending_adv_report()
1727 struct discovery_state *d = &hdev->discovery; in clear_pending_adv_report()
1729 bacpy(&d->last_adv_addr, BDADDR_ANY); in clear_pending_adv_report()
1730 d->last_adv_data_len = 0; in clear_pending_adv_report()
1737 struct discovery_state *d = &hdev->discovery; in store_pending_adv_report()
1742 bacpy(&d->last_adv_addr, bdaddr); in store_pending_adv_report()
1743 d->last_adv_addr_type = bdaddr_type; in store_pending_adv_report()
1744 d->last_adv_rssi = rssi; in store_pending_adv_report()
1745 d->last_adv_flags = flags; in store_pending_adv_report()
1746 memcpy(d->last_adv_data, data, len); in store_pending_adv_report()
1747 d->last_adv_data_len = len; in store_pending_adv_report()
1757 if (hdev->le_scan_type == LE_SCAN_ACTIVE) in le_set_scan_enable_complete()
1769 struct discovery_state *d = &hdev->discovery; in le_set_scan_enable_complete()
1771 mgmt_device_found(hdev, &d->last_adv_addr, LE_LINK, in le_set_scan_enable_complete()
1772 d->last_adv_addr_type, NULL, in le_set_scan_enable_complete()
1773 d->last_adv_rssi, d->last_adv_flags, in le_set_scan_enable_complete()
1774 d->last_adv_data, in le_set_scan_enable_complete()
1775 d->last_adv_data_len, NULL, 0, 0); in le_set_scan_enable_complete()
1781 cancel_delayed_work(&hdev->le_scan_disable); in le_set_scan_enable_complete()
1792 hdev->discovery.state == DISCOVERY_FINDING) in le_set_scan_enable_complete()
1793 queue_work(hdev->workqueue, &hdev->reenable_adv_work); in le_set_scan_enable_complete()
1810 struct hci_ev_status *rp = data; in hci_cc_le_set_scan_enable() local
1812 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_scan_enable()
1814 if (rp->status) in hci_cc_le_set_scan_enable()
1815 return rp->status; in hci_cc_le_set_scan_enable()
1819 return rp->status; in hci_cc_le_set_scan_enable()
1821 le_set_scan_enable_complete(hdev, cp->enable); in hci_cc_le_set_scan_enable()
1823 return rp->status; in hci_cc_le_set_scan_enable()
1830 struct hci_ev_status *rp = data; in hci_cc_le_set_ext_scan_enable() local
1832 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_ext_scan_enable()
1834 if (rp->status) in hci_cc_le_set_ext_scan_enable()
1835 return rp->status; in hci_cc_le_set_ext_scan_enable()
1839 return rp->status; in hci_cc_le_set_ext_scan_enable()
1841 le_set_scan_enable_complete(hdev, cp->enable); in hci_cc_le_set_ext_scan_enable()
1843 return rp->status; in hci_cc_le_set_ext_scan_enable()
1849 struct hci_rp_le_read_num_supported_adv_sets *rp = data; in hci_cc_le_read_num_adv_sets() local
1851 bt_dev_dbg(hdev, "status 0x%2.2x No of Adv sets %u", rp->status, in hci_cc_le_read_num_adv_sets()
1852 rp->num_of_sets); in hci_cc_le_read_num_adv_sets()
1854 if (rp->status) in hci_cc_le_read_num_adv_sets()
1855 return rp->status; in hci_cc_le_read_num_adv_sets()
1857 hdev->le_num_of_adv_sets = rp->num_of_sets; in hci_cc_le_read_num_adv_sets()
1859 return rp->status; in hci_cc_le_read_num_adv_sets()
1865 struct hci_rp_le_read_accept_list_size *rp = data; in hci_cc_le_read_accept_list_size() local
1867 bt_dev_dbg(hdev, "status 0x%2.2x size %u", rp->status, rp->size); in hci_cc_le_read_accept_list_size()
1869 if (rp->status) in hci_cc_le_read_accept_list_size()
1870 return rp->status; in hci_cc_le_read_accept_list_size()
1872 hdev->le_accept_list_size = rp->size; in hci_cc_le_read_accept_list_size()
1874 return rp->status; in hci_cc_le_read_accept_list_size()
1880 struct hci_ev_status *rp = data; in hci_cc_le_clear_accept_list() local
1882 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_clear_accept_list()
1884 if (rp->status) in hci_cc_le_clear_accept_list()
1885 return rp->status; in hci_cc_le_clear_accept_list()
1888 hci_bdaddr_list_clear(&hdev->le_accept_list); in hci_cc_le_clear_accept_list()
1891 return rp->status; in hci_cc_le_clear_accept_list()
1898 struct hci_ev_status *rp = data; in hci_cc_le_add_to_accept_list() local
1900 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_add_to_accept_list()
1902 if (rp->status) in hci_cc_le_add_to_accept_list()
1903 return rp->status; in hci_cc_le_add_to_accept_list()
1907 return rp->status; in hci_cc_le_add_to_accept_list()
1910 hci_bdaddr_list_add(&hdev->le_accept_list, &sent->bdaddr, in hci_cc_le_add_to_accept_list()
1911 sent->bdaddr_type); in hci_cc_le_add_to_accept_list()
1914 return rp->status; in hci_cc_le_add_to_accept_list()
1921 struct hci_ev_status *rp = data; in hci_cc_le_del_from_accept_list() local
1923 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_del_from_accept_list()
1925 if (rp->status) in hci_cc_le_del_from_accept_list()
1926 return rp->status; in hci_cc_le_del_from_accept_list()
1930 return rp->status; in hci_cc_le_del_from_accept_list()
1933 hci_bdaddr_list_del(&hdev->le_accept_list, &sent->bdaddr, in hci_cc_le_del_from_accept_list()
1934 sent->bdaddr_type); in hci_cc_le_del_from_accept_list()
1937 return rp->status; in hci_cc_le_del_from_accept_list()
1943 struct hci_rp_le_read_supported_states *rp = data; in hci_cc_le_read_supported_states() local
1945 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_read_supported_states()
1947 if (rp->status) in hci_cc_le_read_supported_states()
1948 return rp->status; in hci_cc_le_read_supported_states()
1950 memcpy(hdev->le_states, rp->le_states, 8); in hci_cc_le_read_supported_states()
1952 return rp->status; in hci_cc_le_read_supported_states()
1958 struct hci_rp_le_read_def_data_len *rp = data; in hci_cc_le_read_def_data_len() local
1960 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_read_def_data_len()
1962 if (rp->status) in hci_cc_le_read_def_data_len()
1963 return rp->status; in hci_cc_le_read_def_data_len()
1965 hdev->le_def_tx_len = le16_to_cpu(rp->tx_len); in hci_cc_le_read_def_data_len()
1966 hdev->le_def_tx_time = le16_to_cpu(rp->tx_time); in hci_cc_le_read_def_data_len()
1968 return rp->status; in hci_cc_le_read_def_data_len()
1975 struct hci_ev_status *rp = data; in hci_cc_le_write_def_data_len() local
1977 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_write_def_data_len()
1979 if (rp->status) in hci_cc_le_write_def_data_len()
1980 return rp->status; in hci_cc_le_write_def_data_len()
1984 return rp->status; in hci_cc_le_write_def_data_len()
1986 hdev->le_def_tx_len = le16_to_cpu(sent->tx_len); in hci_cc_le_write_def_data_len()
1987 hdev->le_def_tx_time = le16_to_cpu(sent->tx_time); in hci_cc_le_write_def_data_len()
1989 return rp->status; in hci_cc_le_write_def_data_len()
1996 struct hci_ev_status *rp = data; in hci_cc_le_add_to_resolv_list() local
1998 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_add_to_resolv_list()
2000 if (rp->status) in hci_cc_le_add_to_resolv_list()
2001 return rp->status; in hci_cc_le_add_to_resolv_list()
2005 return rp->status; in hci_cc_le_add_to_resolv_list()
2008 hci_bdaddr_list_add_with_irk(&hdev->le_resolv_list, &sent->bdaddr, in hci_cc_le_add_to_resolv_list()
2009 sent->bdaddr_type, sent->peer_irk, in hci_cc_le_add_to_resolv_list()
2010 sent->local_irk); in hci_cc_le_add_to_resolv_list()
2013 return rp->status; in hci_cc_le_add_to_resolv_list()
2020 struct hci_ev_status *rp = data; in hci_cc_le_del_from_resolv_list() local
2022 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_del_from_resolv_list()
2024 if (rp->status) in hci_cc_le_del_from_resolv_list()
2025 return rp->status; in hci_cc_le_del_from_resolv_list()
2029 return rp->status; in hci_cc_le_del_from_resolv_list()
2032 hci_bdaddr_list_del_with_irk(&hdev->le_resolv_list, &sent->bdaddr, in hci_cc_le_del_from_resolv_list()
2033 sent->bdaddr_type); in hci_cc_le_del_from_resolv_list()
2036 return rp->status; in hci_cc_le_del_from_resolv_list()
2042 struct hci_ev_status *rp = data; in hci_cc_le_clear_resolv_list() local
2044 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_clear_resolv_list()
2046 if (rp->status) in hci_cc_le_clear_resolv_list()
2047 return rp->status; in hci_cc_le_clear_resolv_list()
2050 hci_bdaddr_list_clear(&hdev->le_resolv_list); in hci_cc_le_clear_resolv_list()
2053 return rp->status; in hci_cc_le_clear_resolv_list()
2059 struct hci_rp_le_read_resolv_list_size *rp = data; in hci_cc_le_read_resolv_list_size() local
2061 bt_dev_dbg(hdev, "status 0x%2.2x size %u", rp->status, rp->size); in hci_cc_le_read_resolv_list_size()
2063 if (rp->status) in hci_cc_le_read_resolv_list_size()
2064 return rp->status; in hci_cc_le_read_resolv_list_size()
2066 hdev->le_resolv_list_size = rp->size; in hci_cc_le_read_resolv_list_size()
2068 return rp->status; in hci_cc_le_read_resolv_list_size()
2074 struct hci_ev_status *rp = data; in hci_cc_le_set_addr_resolution_enable() local
2077 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_addr_resolution_enable()
2079 if (rp->status) in hci_cc_le_set_addr_resolution_enable()
2080 return rp->status; in hci_cc_le_set_addr_resolution_enable()
2084 return rp->status; in hci_cc_le_set_addr_resolution_enable()
2095 return rp->status; in hci_cc_le_set_addr_resolution_enable()
2101 struct hci_rp_le_read_max_data_len *rp = data; in hci_cc_le_read_max_data_len() local
2103 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_read_max_data_len()
2105 if (rp->status) in hci_cc_le_read_max_data_len()
2106 return rp->status; in hci_cc_le_read_max_data_len()
2108 hdev->le_max_tx_len = le16_to_cpu(rp->tx_len); in hci_cc_le_read_max_data_len()
2109 hdev->le_max_tx_time = le16_to_cpu(rp->tx_time); in hci_cc_le_read_max_data_len()
2110 hdev->le_max_rx_len = le16_to_cpu(rp->rx_len); in hci_cc_le_read_max_data_len()
2111 hdev->le_max_rx_time = le16_to_cpu(rp->rx_time); in hci_cc_le_read_max_data_len()
2113 return rp->status; in hci_cc_le_read_max_data_len()
2120 struct hci_ev_status *rp = data; in hci_cc_write_le_host_supported() local
2122 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_le_host_supported()
2124 if (rp->status) in hci_cc_write_le_host_supported()
2125 return rp->status; in hci_cc_write_le_host_supported()
2129 return rp->status; in hci_cc_write_le_host_supported()
2133 if (sent->le) { in hci_cc_write_le_host_supported()
2134 hdev->features[1][0] |= LMP_HOST_LE; in hci_cc_write_le_host_supported()
2137 hdev->features[1][0] &= ~LMP_HOST_LE; in hci_cc_write_le_host_supported()
2142 if (sent->simul) in hci_cc_write_le_host_supported()
2143 hdev->features[1][0] |= LMP_HOST_LE_BREDR; in hci_cc_write_le_host_supported()
2145 hdev->features[1][0] &= ~LMP_HOST_LE_BREDR; in hci_cc_write_le_host_supported()
2149 return rp->status; in hci_cc_write_le_host_supported()
2156 struct hci_ev_status *rp = data; in hci_cc_set_adv_param() local
2158 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_set_adv_param()
2160 if (rp->status) in hci_cc_set_adv_param()
2161 return rp->status; in hci_cc_set_adv_param()
2165 return rp->status; in hci_cc_set_adv_param()
2168 hdev->adv_addr_type = cp->own_address_type; in hci_cc_set_adv_param()
2171 return rp->status; in hci_cc_set_adv_param()
2177 struct hci_rp_le_set_ext_adv_params *rp = data; in hci_cc_set_ext_adv_param() local
2181 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_set_ext_adv_param()
2183 if (rp->status) in hci_cc_set_ext_adv_param()
2184 return rp->status; in hci_cc_set_ext_adv_param()
2188 return rp->status; in hci_cc_set_ext_adv_param()
2191 hdev->adv_addr_type = cp->own_addr_type; in hci_cc_set_ext_adv_param()
2192 if (!cp->handle) { in hci_cc_set_ext_adv_param()
2194 hdev->adv_tx_power = rp->tx_power; in hci_cc_set_ext_adv_param()
2196 adv_instance = hci_find_adv_instance(hdev, cp->handle); in hci_cc_set_ext_adv_param()
2198 adv_instance->tx_power = rp->tx_power; in hci_cc_set_ext_adv_param()
2201 hci_update_adv_data(hdev, cp->handle); in hci_cc_set_ext_adv_param()
2205 return rp->status; in hci_cc_set_ext_adv_param()
2211 struct hci_rp_read_rssi *rp = data; in hci_cc_read_rssi() local
2214 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_rssi()
2216 if (rp->status) in hci_cc_read_rssi()
2217 return rp->status; in hci_cc_read_rssi()
2221 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_rssi()
2223 conn->rssi = rp->rssi; in hci_cc_read_rssi()
2227 return rp->status; in hci_cc_read_rssi()
2234 struct hci_rp_read_tx_power *rp = data; in hci_cc_read_tx_power() local
2237 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_tx_power()
2239 if (rp->status) in hci_cc_read_tx_power()
2240 return rp->status; in hci_cc_read_tx_power()
2244 return rp->status; in hci_cc_read_tx_power()
2248 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_tx_power()
2252 switch (sent->type) { in hci_cc_read_tx_power()
2254 conn->tx_power = rp->tx_power; in hci_cc_read_tx_power()
2257 conn->max_tx_power = rp->tx_power; in hci_cc_read_tx_power()
2263 return rp->status; in hci_cc_read_tx_power()
2269 struct hci_ev_status *rp = data; in hci_cc_write_ssp_debug_mode() local
2272 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_ssp_debug_mode()
2274 if (rp->status) in hci_cc_write_ssp_debug_mode()
2275 return rp->status; in hci_cc_write_ssp_debug_mode()
2279 hdev->ssp_debug_mode = *mode; in hci_cc_write_ssp_debug_mode()
2281 return rp->status; in hci_cc_write_ssp_debug_mode()
2286 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_inquiry()
2293 set_bit(HCI_INQUIRY, &hdev->flags); in hci_cs_inquiry()
2301 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_create_conn()
2309 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cs_create_conn()
2311 bt_dev_dbg(hdev, "bdaddr %pMR hcon %p", &cp->bdaddr, conn); in hci_cs_create_conn()
2314 if (conn && conn->state == BT_CONNECT) { in hci_cs_create_conn()
2315 if (status != 0x0c || conn->attempt > 2) { in hci_cs_create_conn()
2316 conn->state = BT_CLOSED; in hci_cs_create_conn()
2320 conn->state = BT_CONNECT2; in hci_cs_create_conn()
2324 conn = hci_conn_add(hdev, ACL_LINK, &cp->bdaddr, in hci_cs_create_conn()
2340 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_add_sco()
2349 handle = __le16_to_cpu(cp->handle); in hci_cs_add_sco()
2351 bt_dev_dbg(hdev, "handle 0x%4.4x", handle); in hci_cs_add_sco()
2357 sco = acl->link; in hci_cs_add_sco()
2359 sco->state = BT_CLOSED; in hci_cs_add_sco()
2374 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_auth_requested()
2385 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_auth_requested()
2387 if (conn->state == BT_CONFIG) { in hci_cs_auth_requested()
2401 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_set_conn_encrypt()
2412 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_set_conn_encrypt()
2414 if (conn->state == BT_CONFIG) { in hci_cs_set_conn_encrypt()
2426 if (conn->state != BT_CONFIG || !conn->out) in hci_outgoing_auth_needed()
2429 if (conn->pending_sec_level == BT_SECURITY_SDP) in hci_outgoing_auth_needed()
2432 /* Only request authentication for SSP connections or non-SSP in hci_outgoing_auth_needed()
2436 if (!hci_conn_ssp_enabled(conn) && !(conn->auth_type & 0x01) && in hci_outgoing_auth_needed()
2437 conn->pending_sec_level != BT_SECURITY_FIPS && in hci_outgoing_auth_needed()
2438 conn->pending_sec_level != BT_SECURITY_HIGH && in hci_outgoing_auth_needed()
2439 conn->pending_sec_level != BT_SECURITY_MEDIUM) in hci_outgoing_auth_needed()
2452 bacpy(&cp.bdaddr, &e->data.bdaddr); in hci_resolve_name()
2453 cp.pscan_rep_mode = e->data.pscan_rep_mode; in hci_resolve_name()
2454 cp.pscan_mode = e->data.pscan_mode; in hci_resolve_name()
2455 cp.clock_offset = e->data.clock_offset; in hci_resolve_name()
2462 struct discovery_state *discov = &hdev->discovery; in hci_resolve_next_name()
2465 if (list_empty(&discov->resolve)) in hci_resolve_next_name()
2469 if (time_after(jiffies, discov->name_resolve_timeout)) { in hci_resolve_next_name()
2479 e->name_state = NAME_PENDING; in hci_resolve_next_name()
2489 struct discovery_state *discov = &hdev->discovery; in hci_check_pending_name()
2498 (conn->state == BT_CONFIG || conn->state == BT_CONNECTED) && in hci_check_pending_name()
2499 !test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) in hci_check_pending_name()
2502 if (discov->state == DISCOVERY_STOPPED) in hci_check_pending_name()
2505 if (discov->state == DISCOVERY_STOPPING) in hci_check_pending_name()
2508 if (discov->state != DISCOVERY_RESOLVING) in hci_check_pending_name()
2519 list_del(&e->list); in hci_check_pending_name()
2521 e->name_state = name ? NAME_KNOWN : NAME_NOT_KNOWN; in hci_check_pending_name()
2522 mgmt_remote_name(hdev, bdaddr, ACL_LINK, 0x00, e->data.rssi, in hci_check_pending_name()
2537 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_remote_name_req()
2550 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cs_remote_name_req()
2553 hci_check_pending_name(hdev, conn, &cp->bdaddr, NULL, 0); in hci_cs_remote_name_req()
2561 if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->flags)) { in hci_cs_remote_name_req()
2564 set_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags); in hci_cs_remote_name_req()
2566 auth_cp.handle = __cpu_to_le16(conn->handle); in hci_cs_remote_name_req()
2580 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_read_remote_features()
2591 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_read_remote_features()
2593 if (conn->state == BT_CONFIG) { in hci_cs_read_remote_features()
2607 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_read_remote_ext_features()
2618 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_read_remote_ext_features()
2620 if (conn->state == BT_CONFIG) { in hci_cs_read_remote_ext_features()
2635 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_setup_sync_conn()
2644 handle = __le16_to_cpu(cp->handle); in hci_cs_setup_sync_conn()
2646 bt_dev_dbg(hdev, "handle 0x%4.4x", handle); in hci_cs_setup_sync_conn()
2652 sco = acl->link; in hci_cs_setup_sync_conn()
2654 sco->state = BT_CLOSED; in hci_cs_setup_sync_conn()
2670 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_enhanced_setup_sync_conn()
2679 handle = __le16_to_cpu(cp->handle); in hci_cs_enhanced_setup_sync_conn()
2681 bt_dev_dbg(hdev, "handle 0x%4.4x", handle); in hci_cs_enhanced_setup_sync_conn()
2687 sco = acl->link; in hci_cs_enhanced_setup_sync_conn()
2689 sco->state = BT_CLOSED; in hci_cs_enhanced_setup_sync_conn()
2704 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_sniff_mode()
2715 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_sniff_mode()
2717 clear_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->flags); in hci_cs_sniff_mode()
2719 if (test_and_clear_bit(HCI_CONN_SCO_SETUP_PEND, &conn->flags)) in hci_cs_sniff_mode()
2731 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_exit_sniff_mode()
2742 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_exit_sniff_mode()
2744 clear_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->flags); in hci_cs_exit_sniff_mode()
2746 if (test_and_clear_bit(HCI_CONN_SCO_SETUP_PEND, &conn->flags)) in hci_cs_exit_sniff_mode()
2760 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_disconnect()
2765 if (!status && !hdev->suspended) in hci_cs_disconnect()
2774 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_disconnect()
2779 mgmt_disconnect_failed(hdev, &conn->dst, conn->type, in hci_cs_disconnect()
2780 conn->dst_type, status); in hci_cs_disconnect()
2782 if (conn->type == LE_LINK && conn->role == HCI_ROLE_SLAVE) { in hci_cs_disconnect()
2783 hdev->cur_adv_instance = conn->adv_instance; in hci_cs_disconnect()
2790 mgmt_conn = test_and_clear_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags); in hci_cs_disconnect()
2792 if (conn->type == ACL_LINK) { in hci_cs_disconnect()
2793 if (test_and_clear_bit(HCI_CONN_FLUSH_KEY, &conn->flags)) in hci_cs_disconnect()
2794 hci_remove_link_key(hdev, &conn->dst); in hci_cs_disconnect()
2797 params = hci_conn_params_lookup(hdev, &conn->dst, conn->dst_type); in hci_cs_disconnect()
2799 switch (params->auto_connect) { in hci_cs_disconnect()
2801 if (cp->reason != HCI_ERROR_CONNECTION_TIMEOUT) in hci_cs_disconnect()
2807 list_del_init(&params->action); in hci_cs_disconnect()
2808 list_add(&params->action, &hdev->pend_le_conns); in hci_cs_disconnect()
2816 mgmt_device_disconnected(hdev, &conn->dst, conn->type, conn->dst_type, in hci_cs_disconnect()
2817 cp->reason, mgmt_conn); in hci_cs_disconnect()
2819 hci_disconn_cfm(conn, cp->reason); in hci_cs_disconnect()
2824 * Hence, we need to do some basic cleanup here and re-enable in hci_cs_disconnect()
2871 conn->init_addr_type = own_address_type; in cs_le_create_conn()
2873 bacpy(&conn->init_addr, &hdev->random_addr); in cs_le_create_conn()
2875 bacpy(&conn->init_addr, &hdev->bdaddr); in cs_le_create_conn()
2877 conn->resp_addr_type = peer_addr_type; in cs_le_create_conn()
2878 bacpy(&conn->resp_addr, peer_addr); in cs_le_create_conn()
2886 queue_delayed_work(conn->hdev->workqueue, in cs_le_create_conn()
2887 &conn->le_conn_timeout, in cs_le_create_conn()
2888 conn->conn_timeout); in cs_le_create_conn()
2895 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_le_create_conn()
2910 cs_le_create_conn(hdev, &cp->peer_addr, cp->peer_addr_type, in hci_cs_le_create_conn()
2911 cp->own_address_type, cp->filter_policy); in hci_cs_le_create_conn()
2920 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_le_ext_create_conn()
2935 cs_le_create_conn(hdev, &cp->peer_addr, cp->peer_addr_type, in hci_cs_le_ext_create_conn()
2936 cp->own_addr_type, cp->filter_policy); in hci_cs_le_ext_create_conn()
2946 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_le_read_remote_features()
2957 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_le_read_remote_features()
2959 if (conn->state == BT_CONFIG) { in hci_cs_le_read_remote_features()
2973 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_le_start_enc()
2984 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_le_start_enc()
2988 if (conn->state != BT_CONNECTED) in hci_cs_le_start_enc()
3003 BT_DBG("%s status 0x%2.2x", hdev->name, status); in hci_cs_switch_role()
3014 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cs_switch_role()
3016 clear_bit(HCI_CONN_RSWITCH_PEND, &conn->flags); in hci_cs_switch_role()
3025 struct discovery_state *discov = &hdev->discovery; in hci_inquiry_complete_evt()
3028 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_inquiry_complete_evt()
3032 if (!test_and_clear_bit(HCI_INQUIRY, &hdev->flags)) in hci_inquiry_complete_evt()
3036 wake_up_bit(&hdev->flags, HCI_INQUIRY); in hci_inquiry_complete_evt()
3043 if (discov->state != DISCOVERY_FINDING) in hci_inquiry_complete_evt()
3046 if (list_empty(&discov->resolve)) { in hci_inquiry_complete_evt()
3055 !test_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks)) in hci_inquiry_complete_evt()
3062 e->name_state = NAME_PENDING; in hci_inquiry_complete_evt()
3064 discov->name_resolve_timeout = jiffies + NAME_RESOLVE_DURATION; in hci_inquiry_complete_evt()
3074 !test_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks)) in hci_inquiry_complete_evt()
3090 flex_array_size(ev, info, ev->num))) in hci_inquiry_result_evt()
3093 bt_dev_dbg(hdev, "num %d", ev->num); in hci_inquiry_result_evt()
3095 if (!ev->num) in hci_inquiry_result_evt()
3103 for (i = 0; i < ev->num; i++) { in hci_inquiry_result_evt()
3104 struct inquiry_info *info = &ev->info[i]; in hci_inquiry_result_evt()
3107 bacpy(&data.bdaddr, &info->bdaddr); in hci_inquiry_result_evt()
3108 data.pscan_rep_mode = info->pscan_rep_mode; in hci_inquiry_result_evt()
3109 data.pscan_period_mode = info->pscan_period_mode; in hci_inquiry_result_evt()
3110 data.pscan_mode = info->pscan_mode; in hci_inquiry_result_evt()
3111 memcpy(data.dev_class, info->dev_class, 3); in hci_inquiry_result_evt()
3112 data.clock_offset = info->clock_offset; in hci_inquiry_result_evt()
3118 mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, in hci_inquiry_result_evt()
3119 info->dev_class, HCI_RSSI_INVALID, in hci_inquiry_result_evt()
3131 u8 status = ev->status; in hci_conn_complete_evt()
3133 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_conn_complete_evt()
3137 conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, &ev->bdaddr); in hci_conn_complete_evt()
3142 if (ev->status) in hci_conn_complete_evt()
3145 /* Connection may not exist if auto-connected. Check the bredr in hci_conn_complete_evt()
3150 * Auto-connect will only occur if the event filter is in hci_conn_complete_evt()
3154 if (ev->link_type == ACL_LINK && in hci_conn_complete_evt()
3155 hci_bdaddr_list_lookup_with_flags(&hdev->accept_list, in hci_conn_complete_evt()
3156 &ev->bdaddr, in hci_conn_complete_evt()
3158 conn = hci_conn_add(hdev, ev->link_type, &ev->bdaddr, in hci_conn_complete_evt()
3165 if (ev->link_type != SCO_LINK) in hci_conn_complete_evt()
3169 &ev->bdaddr); in hci_conn_complete_evt()
3173 conn->type = SCO_LINK; in hci_conn_complete_evt()
3183 if (conn->handle != HCI_CONN_HANDLE_UNSET) { in hci_conn_complete_evt()
3189 conn->handle = __le16_to_cpu(ev->handle); in hci_conn_complete_evt()
3190 if (conn->handle > HCI_CONN_HANDLE_MAX) { in hci_conn_complete_evt()
3191 bt_dev_err(hdev, "Invalid handle: 0x%4.4x > 0x%4.4x", in hci_conn_complete_evt()
3192 conn->handle, HCI_CONN_HANDLE_MAX); in hci_conn_complete_evt()
3197 if (conn->type == ACL_LINK) { in hci_conn_complete_evt()
3198 conn->state = BT_CONFIG; in hci_conn_complete_evt()
3201 if (!conn->out && !hci_conn_ssp_enabled(conn) && in hci_conn_complete_evt()
3202 !hci_find_link_key(hdev, &ev->bdaddr)) in hci_conn_complete_evt()
3203 conn->disc_timeout = HCI_PAIRING_TIMEOUT; in hci_conn_complete_evt()
3205 conn->disc_timeout = HCI_DISCONN_TIMEOUT; in hci_conn_complete_evt()
3207 conn->state = BT_CONNECTED; in hci_conn_complete_evt()
3212 if (test_bit(HCI_AUTH, &hdev->flags)) in hci_conn_complete_evt()
3213 set_bit(HCI_CONN_AUTH, &conn->flags); in hci_conn_complete_evt()
3215 if (test_bit(HCI_ENCRYPT, &hdev->flags)) in hci_conn_complete_evt()
3216 set_bit(HCI_CONN_ENCRYPT, &conn->flags); in hci_conn_complete_evt()
3219 if (conn->type == ACL_LINK) { in hci_conn_complete_evt()
3221 cp.handle = ev->handle; in hci_conn_complete_evt()
3229 if (!conn->out && hdev->hci_ver < BLUETOOTH_VER_2_0) { in hci_conn_complete_evt()
3231 cp.handle = ev->handle; in hci_conn_complete_evt()
3232 cp.pkt_type = cpu_to_le16(conn->pkt_type); in hci_conn_complete_evt()
3238 if (conn->type == ACL_LINK) in hci_conn_complete_evt()
3239 hci_sco_setup(conn, ev->status); in hci_conn_complete_evt()
3244 } else if (ev->link_type == SCO_LINK) { in hci_conn_complete_evt()
3245 switch (conn->setting & SCO_AIRMODE_MASK) { in hci_conn_complete_evt()
3247 if (hdev->notify) in hci_conn_complete_evt()
3248 hdev->notify(hdev, HCI_NOTIFY_ENABLE_SCO_CVSD); in hci_conn_complete_evt()
3274 int mask = hdev->link_mode; in hci_conn_request_evt()
3279 bt_dev_dbg(hdev, "bdaddr %pMR type 0x%x", &ev->bdaddr, ev->link_type); in hci_conn_request_evt()
3281 mask |= hci_proto_connect_ind(hdev, &ev->bdaddr, ev->link_type, in hci_conn_request_evt()
3285 hci_reject_conn(hdev, &ev->bdaddr); in hci_conn_request_evt()
3291 if (hci_bdaddr_list_lookup(&hdev->reject_list, &ev->bdaddr, in hci_conn_request_evt()
3293 hci_reject_conn(hdev, &ev->bdaddr); in hci_conn_request_evt()
3303 !hci_bdaddr_list_lookup_with_flags(&hdev->accept_list, &ev->bdaddr, in hci_conn_request_evt()
3305 hci_reject_conn(hdev, &ev->bdaddr); in hci_conn_request_evt()
3311 ie = hci_inquiry_cache_lookup(hdev, &ev->bdaddr); in hci_conn_request_evt()
3313 memcpy(ie->data.dev_class, ev->dev_class, 3); in hci_conn_request_evt()
3315 conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, in hci_conn_request_evt()
3316 &ev->bdaddr); in hci_conn_request_evt()
3318 conn = hci_conn_add(hdev, ev->link_type, &ev->bdaddr, in hci_conn_request_evt()
3326 memcpy(conn->dev_class, ev->dev_class, 3); in hci_conn_request_evt()
3330 if (ev->link_type == ACL_LINK || in hci_conn_request_evt()
3333 conn->state = BT_CONNECT; in hci_conn_request_evt()
3335 bacpy(&cp.bdaddr, &ev->bdaddr); in hci_conn_request_evt()
3345 conn->state = BT_CONNECT; in hci_conn_request_evt()
3347 bacpy(&cp.bdaddr, &ev->bdaddr); in hci_conn_request_evt()
3348 cp.pkt_type = cpu_to_le16(conn->pkt_type); in hci_conn_request_evt()
3353 cp.content_format = cpu_to_le16(hdev->voice_setting); in hci_conn_request_evt()
3359 conn->state = BT_CONNECT2; in hci_conn_request_evt()
3393 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_disconn_complete_evt()
3397 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_disconn_complete_evt()
3401 if (ev->status) { in hci_disconn_complete_evt()
3402 mgmt_disconnect_failed(hdev, &conn->dst, conn->type, in hci_disconn_complete_evt()
3403 conn->dst_type, ev->status); in hci_disconn_complete_evt()
3407 conn->state = BT_CLOSED; in hci_disconn_complete_evt()
3409 mgmt_connected = test_and_clear_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags); in hci_disconn_complete_evt()
3411 if (test_bit(HCI_CONN_AUTH_FAILURE, &conn->flags)) in hci_disconn_complete_evt()
3414 reason = hci_to_mgmt_reason(ev->reason); in hci_disconn_complete_evt()
3416 mgmt_device_disconnected(hdev, &conn->dst, conn->type, conn->dst_type, in hci_disconn_complete_evt()
3419 if (conn->type == ACL_LINK) { in hci_disconn_complete_evt()
3420 if (test_and_clear_bit(HCI_CONN_FLUSH_KEY, &conn->flags)) in hci_disconn_complete_evt()
3421 hci_remove_link_key(hdev, &conn->dst); in hci_disconn_complete_evt()
3426 params = hci_conn_params_lookup(hdev, &conn->dst, conn->dst_type); in hci_disconn_complete_evt()
3428 switch (params->auto_connect) { in hci_disconn_complete_evt()
3430 if (ev->reason != HCI_ERROR_CONNECTION_TIMEOUT) in hci_disconn_complete_evt()
3436 list_del_init(&params->action); in hci_disconn_complete_evt()
3437 list_add(&params->action, &hdev->pend_le_conns); in hci_disconn_complete_evt()
3446 hci_disconn_cfm(conn, ev->reason); in hci_disconn_complete_evt()
3448 /* Re-enable advertising if necessary, since it might in hci_disconn_complete_evt()
3458 if (conn->type == LE_LINK && conn->role == HCI_ROLE_SLAVE) { in hci_disconn_complete_evt()
3459 hdev->cur_adv_instance = conn->adv_instance; in hci_disconn_complete_evt()
3475 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_auth_complete_evt()
3479 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_auth_complete_evt()
3483 if (!ev->status) { in hci_auth_complete_evt()
3484 clear_bit(HCI_CONN_AUTH_FAILURE, &conn->flags); in hci_auth_complete_evt()
3487 test_bit(HCI_CONN_REAUTH_PEND, &conn->flags)) { in hci_auth_complete_evt()
3488 bt_dev_info(hdev, "re-auth of legacy device is not possible."); in hci_auth_complete_evt()
3490 set_bit(HCI_CONN_AUTH, &conn->flags); in hci_auth_complete_evt()
3491 conn->sec_level = conn->pending_sec_level; in hci_auth_complete_evt()
3494 if (ev->status == HCI_ERROR_PIN_OR_KEY_MISSING) in hci_auth_complete_evt()
3495 set_bit(HCI_CONN_AUTH_FAILURE, &conn->flags); in hci_auth_complete_evt()
3497 mgmt_auth_failed(conn, ev->status); in hci_auth_complete_evt()
3500 clear_bit(HCI_CONN_AUTH_PEND, &conn->flags); in hci_auth_complete_evt()
3501 clear_bit(HCI_CONN_REAUTH_PEND, &conn->flags); in hci_auth_complete_evt()
3503 if (conn->state == BT_CONFIG) { in hci_auth_complete_evt()
3504 if (!ev->status && hci_conn_ssp_enabled(conn)) { in hci_auth_complete_evt()
3506 cp.handle = ev->handle; in hci_auth_complete_evt()
3511 conn->state = BT_CONNECTED; in hci_auth_complete_evt()
3512 hci_connect_cfm(conn, ev->status); in hci_auth_complete_evt()
3516 hci_auth_cfm(conn, ev->status); in hci_auth_complete_evt()
3519 conn->disc_timeout = HCI_DISCONN_TIMEOUT; in hci_auth_complete_evt()
3523 if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags)) { in hci_auth_complete_evt()
3524 if (!ev->status) { in hci_auth_complete_evt()
3526 cp.handle = ev->handle; in hci_auth_complete_evt()
3531 clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags); in hci_auth_complete_evt()
3532 hci_encrypt_cfm(conn, ev->status); in hci_auth_complete_evt()
3546 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_remote_name_evt()
3552 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_remote_name_evt()
3557 if (ev->status == 0) in hci_remote_name_evt()
3558 hci_check_pending_name(hdev, conn, &ev->bdaddr, ev->name, in hci_remote_name_evt()
3559 strnlen(ev->name, HCI_MAX_NAME_LENGTH)); in hci_remote_name_evt()
3561 hci_check_pending_name(hdev, conn, &ev->bdaddr, NULL, 0); in hci_remote_name_evt()
3570 if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->flags)) { in hci_remote_name_evt()
3573 set_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags); in hci_remote_name_evt()
3575 cp.handle = __cpu_to_le16(conn->handle); in hci_remote_name_evt()
3589 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_encrypt_change_evt()
3593 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_encrypt_change_evt()
3597 if (!ev->status) { in hci_encrypt_change_evt()
3598 if (ev->encrypt) { in hci_encrypt_change_evt()
3600 set_bit(HCI_CONN_AUTH, &conn->flags); in hci_encrypt_change_evt()
3601 set_bit(HCI_CONN_ENCRYPT, &conn->flags); in hci_encrypt_change_evt()
3602 conn->sec_level = conn->pending_sec_level; in hci_encrypt_change_evt()
3604 /* P-256 authentication key implies FIPS */ in hci_encrypt_change_evt()
3605 if (conn->key_type == HCI_LK_AUTH_COMBINATION_P256) in hci_encrypt_change_evt()
3606 set_bit(HCI_CONN_FIPS, &conn->flags); in hci_encrypt_change_evt()
3608 if ((conn->type == ACL_LINK && ev->encrypt == 0x02) || in hci_encrypt_change_evt()
3609 conn->type == LE_LINK) in hci_encrypt_change_evt()
3610 set_bit(HCI_CONN_AES_CCM, &conn->flags); in hci_encrypt_change_evt()
3612 clear_bit(HCI_CONN_ENCRYPT, &conn->flags); in hci_encrypt_change_evt()
3613 clear_bit(HCI_CONN_AES_CCM, &conn->flags); in hci_encrypt_change_evt()
3620 if (ev->status && conn->type == LE_LINK) { in hci_encrypt_change_evt()
3625 clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags); in hci_encrypt_change_evt()
3629 ev->status = HCI_ERROR_AUTH_FAILURE; in hci_encrypt_change_evt()
3631 if (ev->status && conn->state == BT_CONNECTED) { in hci_encrypt_change_evt()
3632 if (ev->status == HCI_ERROR_PIN_OR_KEY_MISSING) in hci_encrypt_change_evt()
3633 set_bit(HCI_CONN_AUTH_FAILURE, &conn->flags); in hci_encrypt_change_evt()
3638 hci_encrypt_cfm(conn, ev->status); in hci_encrypt_change_evt()
3645 if (!ev->status && ev->encrypt && conn->type == ACL_LINK) { in hci_encrypt_change_evt()
3652 if (!(hdev->commands[20] & 0x10)) { in hci_encrypt_change_evt()
3653 conn->enc_key_size = HCI_LINK_KEY_SIZE; in hci_encrypt_change_evt()
3657 cp.handle = cpu_to_le16(conn->handle); in hci_encrypt_change_evt()
3661 conn->enc_key_size = HCI_LINK_KEY_SIZE; in hci_encrypt_change_evt()
3673 * Ensure for AES-CCM encryption as well. in hci_encrypt_change_evt()
3675 if (test_bit(HCI_CONN_ENCRYPT, &conn->flags) && in hci_encrypt_change_evt()
3676 test_bit(HCI_CONN_AES_CCM, &conn->flags) && in hci_encrypt_change_evt()
3677 ((conn->type == ACL_LINK && lmp_ping_capable(hdev)) || in hci_encrypt_change_evt()
3678 (conn->type == LE_LINK && (hdev->le_features[0] & HCI_LE_PING)))) { in hci_encrypt_change_evt()
3681 cp.handle = cpu_to_le16(conn->handle); in hci_encrypt_change_evt()
3682 cp.timeout = cpu_to_le16(hdev->auth_payload_timeout); in hci_encrypt_change_evt()
3683 hci_send_cmd(conn->hdev, HCI_OP_WRITE_AUTH_PAYLOAD_TO, in hci_encrypt_change_evt()
3688 hci_encrypt_cfm(conn, ev->status); in hci_encrypt_change_evt()
3700 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_change_link_key_complete_evt()
3704 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_change_link_key_complete_evt()
3706 if (!ev->status) in hci_change_link_key_complete_evt()
3707 set_bit(HCI_CONN_SECURE, &conn->flags); in hci_change_link_key_complete_evt()
3709 clear_bit(HCI_CONN_AUTH_PEND, &conn->flags); in hci_change_link_key_complete_evt()
3711 hci_key_change_cfm(conn, ev->status); in hci_change_link_key_complete_evt()
3723 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_remote_features_evt()
3727 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_remote_features_evt()
3731 if (!ev->status) in hci_remote_features_evt()
3732 memcpy(conn->features[0], ev->features, 8); in hci_remote_features_evt()
3734 if (conn->state != BT_CONFIG) in hci_remote_features_evt()
3737 if (!ev->status && lmp_ext_feat_capable(hdev) && in hci_remote_features_evt()
3740 cp.handle = ev->handle; in hci_remote_features_evt()
3747 if (!ev->status && !test_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) { in hci_remote_features_evt()
3750 bacpy(&cp.bdaddr, &conn->dst); in hci_remote_features_evt()
3753 } else if (!test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) in hci_remote_features_evt()
3757 conn->state = BT_CONNECTED; in hci_remote_features_evt()
3758 hci_connect_cfm(conn, ev->status); in hci_remote_features_evt()
3768 cancel_delayed_work(&hdev->cmd_timer); in handle_cmd_cnt_and_timer()
3771 if (!test_bit(HCI_RESET, &hdev->flags)) { in handle_cmd_cnt_and_timer()
3773 cancel_delayed_work(&hdev->ncmd_timer); in handle_cmd_cnt_and_timer()
3774 atomic_set(&hdev->cmd_cnt, 1); in handle_cmd_cnt_and_timer()
3777 queue_delayed_work(hdev->workqueue, &hdev->ncmd_timer, in handle_cmd_cnt_and_timer()
3787 struct hci_rp_le_read_buffer_size_v2 *rp = data; in hci_cc_le_read_buffer_size_v2() local
3789 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_read_buffer_size_v2()
3791 if (rp->status) in hci_cc_le_read_buffer_size_v2()
3792 return rp->status; in hci_cc_le_read_buffer_size_v2()
3794 hdev->le_mtu = __le16_to_cpu(rp->acl_mtu); in hci_cc_le_read_buffer_size_v2()
3795 hdev->le_pkts = rp->acl_max_pkt; in hci_cc_le_read_buffer_size_v2()
3796 hdev->iso_mtu = __le16_to_cpu(rp->iso_mtu); in hci_cc_le_read_buffer_size_v2()
3797 hdev->iso_pkts = rp->iso_max_pkt; in hci_cc_le_read_buffer_size_v2()
3799 hdev->le_cnt = hdev->le_pkts; in hci_cc_le_read_buffer_size_v2()
3800 hdev->iso_cnt = hdev->iso_pkts; in hci_cc_le_read_buffer_size_v2()
3802 BT_DBG("%s acl mtu %d:%d iso mtu %d:%d", hdev->name, hdev->acl_mtu, in hci_cc_le_read_buffer_size_v2()
3803 hdev->acl_pkts, hdev->iso_mtu, hdev->iso_pkts); in hci_cc_le_read_buffer_size_v2()
3805 return rp->status; in hci_cc_le_read_buffer_size_v2()
3811 struct hci_rp_le_set_cig_params *rp = data; in hci_cc_le_set_cig_params() local
3815 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_cig_params()
3819 if (rp->status) { in hci_cc_le_set_cig_params()
3820 while ((conn = hci_conn_hash_lookup_cig(hdev, rp->cig_id))) { in hci_cc_le_set_cig_params()
3821 conn->state = BT_CLOSED; in hci_cc_le_set_cig_params()
3822 hci_connect_cfm(conn, rp->status); in hci_cc_le_set_cig_params()
3830 list_for_each_entry_rcu(conn, &hdev->conn_hash.list, list) { in hci_cc_le_set_cig_params()
3831 if (conn->type != ISO_LINK || conn->iso_qos.cig != rp->cig_id || in hci_cc_le_set_cig_params()
3832 conn->state == BT_CONNECTED) in hci_cc_le_set_cig_params()
3835 conn->handle = __le16_to_cpu(rp->handle[i++]); in hci_cc_le_set_cig_params()
3837 bt_dev_dbg(hdev, "%p handle 0x%4.4x link %p", conn, in hci_cc_le_set_cig_params()
3838 conn->handle, conn->link); in hci_cc_le_set_cig_params()
3841 if (conn->link && conn->link->state == BT_CONNECTED) in hci_cc_le_set_cig_params()
3842 hci_le_create_cis(conn->link); in hci_cc_le_set_cig_params()
3844 if (i == rp->num_handles) in hci_cc_le_set_cig_params()
3853 return rp->status; in hci_cc_le_set_cig_params()
3859 struct hci_rp_le_setup_iso_path *rp = data; in hci_cc_le_setup_iso_path() local
3863 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_setup_iso_path()
3867 return rp->status; in hci_cc_le_setup_iso_path()
3871 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cc_le_setup_iso_path()
3875 if (rp->status) { in hci_cc_le_setup_iso_path()
3876 hci_connect_cfm(conn, rp->status); in hci_cc_le_setup_iso_path()
3881 switch (cp->direction) { in hci_cc_le_setup_iso_path()
3885 if (conn->iso_qos.out.sdu && !conn->iso_qos.in.sdu) in hci_cc_le_setup_iso_path()
3886 hci_connect_cfm(conn, rp->status); in hci_cc_le_setup_iso_path()
3890 /* Confirm connection since conn->iso_qos is always configured in hci_cc_le_setup_iso_path()
3893 hci_connect_cfm(conn, rp->status); in hci_cc_le_setup_iso_path()
3899 return rp->status; in hci_cc_le_setup_iso_path()
3904 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_le_create_big()
3910 struct hci_ev_status *rp = data; in hci_cc_set_per_adv_param() local
3913 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_set_per_adv_param()
3915 if (rp->status) in hci_cc_set_per_adv_param()
3916 return rp->status; in hci_cc_set_per_adv_param()
3920 return rp->status; in hci_cc_set_per_adv_param()
3923 return rp->status; in hci_cc_set_per_adv_param()
3929 struct hci_ev_status *rp = data; in hci_cc_le_set_per_adv_enable() local
3932 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_per_adv_enable()
3934 if (rp->status) in hci_cc_le_set_per_adv_enable()
3935 return rp->status; in hci_cc_le_set_per_adv_enable()
3939 return rp->status; in hci_cc_le_set_per_adv_enable()
3950 return rp->status; in hci_cc_le_set_per_adv_enable()
4147 if (skb->len < cc->min_len) { in hci_cc_func()
4148 bt_dev_err(hdev, "unexpected cc 0x%4.4x length: %u < %u", in hci_cc_func()
4149 cc->op, skb->len, cc->min_len); in hci_cc_func()
4157 if (skb->len > cc->max_len) in hci_cc_func()
4158 bt_dev_warn(hdev, "unexpected cc 0x%4.4x length: %u > %u", in hci_cc_func()
4159 cc->op, skb->len, cc->max_len); in hci_cc_func()
4161 data = hci_cc_skb_pull(hdev, skb, cc->op, cc->min_len); in hci_cc_func()
4165 return cc->func(hdev, data, skb); in hci_cc_func()
4176 *opcode = __le16_to_cpu(ev->opcode); in hci_cmd_complete_evt()
4178 bt_dev_dbg(hdev, "opcode 0x%4.4x", *opcode); in hci_cmd_complete_evt()
4195 *status = skb->data[0]; in hci_cmd_complete_evt()
4198 handle_cmd_cnt_and_timer(hdev, ev->ncmd); in hci_cmd_complete_evt()
4205 "unexpected event for opcode 0x%4.4x", *opcode); in hci_cmd_complete_evt()
4209 if (atomic_read(&hdev->cmd_cnt) && !skb_queue_empty(&hdev->cmd_q)) in hci_cmd_complete_evt()
4210 queue_work(hdev->workqueue, &hdev->cmd_work); in hci_cmd_complete_evt()
4218 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_le_create_cis()
4230 for (i = 0; cp->num_cis; cp->num_cis--, i++) { in hci_cs_le_create_cis()
4234 handle = __le16_to_cpu(cp->cis[i].cis_handle); in hci_cs_le_create_cis()
4238 conn->state = BT_CLOSED; in hci_cs_le_create_cis()
4289 *opcode = __le16_to_cpu(ev->opcode); in hci_cmd_status_evt()
4290 *status = ev->status; in hci_cmd_status_evt()
4292 bt_dev_dbg(hdev, "opcode 0x%4.4x", *opcode); in hci_cmd_status_evt()
4296 hci_cs_table[i].func(hdev, ev->status); in hci_cmd_status_evt()
4301 handle_cmd_cnt_and_timer(hdev, ev->ncmd); in hci_cmd_status_evt()
4309 if (ev->status || (hdev->sent_cmd && !hci_skb_event(hdev->sent_cmd))) { in hci_cmd_status_evt()
4310 hci_req_cmd_complete(hdev, *opcode, ev->status, req_complete, in hci_cmd_status_evt()
4313 bt_dev_err(hdev, "unexpected event for opcode 0x%4.4x", in hci_cmd_status_evt()
4319 if (atomic_read(&hdev->cmd_cnt) && !skb_queue_empty(&hdev->cmd_q)) in hci_cmd_status_evt()
4320 queue_work(hdev->workqueue, &hdev->cmd_work); in hci_cmd_status_evt()
4328 bt_dev_dbg(hdev, "code 0x%2.2x", ev->code); in hci_hardware_error_evt()
4330 hdev->hw_error_code = ev->code; in hci_hardware_error_evt()
4332 queue_work(hdev->req_workqueue, &hdev->error_reset); in hci_hardware_error_evt()
4341 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_role_change_evt()
4345 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_role_change_evt()
4347 if (!ev->status) in hci_role_change_evt()
4348 conn->role = ev->role; in hci_role_change_evt()
4350 clear_bit(HCI_CONN_RSWITCH_PEND, &conn->flags); in hci_role_change_evt()
4352 hci_role_switch_cfm(conn, ev->status, ev->role); in hci_role_change_evt()
4365 flex_array_size(ev, handles, ev->num))) in hci_num_comp_pkts_evt()
4368 if (hdev->flow_ctl_mode != HCI_FLOW_CTL_MODE_PACKET_BASED) { in hci_num_comp_pkts_evt()
4369 bt_dev_err(hdev, "wrong event for mode %d", hdev->flow_ctl_mode); in hci_num_comp_pkts_evt()
4373 bt_dev_dbg(hdev, "num %d", ev->num); in hci_num_comp_pkts_evt()
4375 for (i = 0; i < ev->num; i++) { in hci_num_comp_pkts_evt()
4376 struct hci_comp_pkts_info *info = &ev->handles[i]; in hci_num_comp_pkts_evt()
4380 handle = __le16_to_cpu(info->handle); in hci_num_comp_pkts_evt()
4381 count = __le16_to_cpu(info->count); in hci_num_comp_pkts_evt()
4387 conn->sent -= count; in hci_num_comp_pkts_evt()
4389 switch (conn->type) { in hci_num_comp_pkts_evt()
4391 hdev->acl_cnt += count; in hci_num_comp_pkts_evt()
4392 if (hdev->acl_cnt > hdev->acl_pkts) in hci_num_comp_pkts_evt()
4393 hdev->acl_cnt = hdev->acl_pkts; in hci_num_comp_pkts_evt()
4397 if (hdev->le_pkts) { in hci_num_comp_pkts_evt()
4398 hdev->le_cnt += count; in hci_num_comp_pkts_evt()
4399 if (hdev->le_cnt > hdev->le_pkts) in hci_num_comp_pkts_evt()
4400 hdev->le_cnt = hdev->le_pkts; in hci_num_comp_pkts_evt()
4402 hdev->acl_cnt += count; in hci_num_comp_pkts_evt()
4403 if (hdev->acl_cnt > hdev->acl_pkts) in hci_num_comp_pkts_evt()
4404 hdev->acl_cnt = hdev->acl_pkts; in hci_num_comp_pkts_evt()
4409 hdev->sco_cnt += count; in hci_num_comp_pkts_evt()
4410 if (hdev->sco_cnt > hdev->sco_pkts) in hci_num_comp_pkts_evt()
4411 hdev->sco_cnt = hdev->sco_pkts; in hci_num_comp_pkts_evt()
4415 if (hdev->iso_pkts) { in hci_num_comp_pkts_evt()
4416 hdev->iso_cnt += count; in hci_num_comp_pkts_evt()
4417 if (hdev->iso_cnt > hdev->iso_pkts) in hci_num_comp_pkts_evt()
4418 hdev->iso_cnt = hdev->iso_pkts; in hci_num_comp_pkts_evt()
4419 } else if (hdev->le_pkts) { in hci_num_comp_pkts_evt()
4420 hdev->le_cnt += count; in hci_num_comp_pkts_evt()
4421 if (hdev->le_cnt > hdev->le_pkts) in hci_num_comp_pkts_evt()
4422 hdev->le_cnt = hdev->le_pkts; in hci_num_comp_pkts_evt()
4424 hdev->acl_cnt += count; in hci_num_comp_pkts_evt()
4425 if (hdev->acl_cnt > hdev->acl_pkts) in hci_num_comp_pkts_evt()
4426 hdev->acl_cnt = hdev->acl_pkts; in hci_num_comp_pkts_evt()
4432 conn->type, conn); in hci_num_comp_pkts_evt()
4437 queue_work(hdev->workqueue, &hdev->tx_work); in hci_num_comp_pkts_evt()
4445 switch (hdev->dev_type) { in __hci_conn_lookup_handle()
4451 return chan->conn; in __hci_conn_lookup_handle()
4454 bt_dev_err(hdev, "unknown dev_type %d", hdev->dev_type); in __hci_conn_lookup_handle()
4468 flex_array_size(ev, handles, ev->num_hndl))) in hci_num_comp_blocks_evt()
4471 if (hdev->flow_ctl_mode != HCI_FLOW_CTL_MODE_BLOCK_BASED) { in hci_num_comp_blocks_evt()
4473 hdev->flow_ctl_mode); in hci_num_comp_blocks_evt()
4477 bt_dev_dbg(hdev, "num_blocks %d num_hndl %d", ev->num_blocks, in hci_num_comp_blocks_evt()
4478 ev->num_hndl); in hci_num_comp_blocks_evt()
4480 for (i = 0; i < ev->num_hndl; i++) { in hci_num_comp_blocks_evt()
4481 struct hci_comp_blocks_info *info = &ev->handles[i]; in hci_num_comp_blocks_evt()
4485 handle = __le16_to_cpu(info->handle); in hci_num_comp_blocks_evt()
4486 block_count = __le16_to_cpu(info->blocks); in hci_num_comp_blocks_evt()
4492 conn->sent -= block_count; in hci_num_comp_blocks_evt()
4494 switch (conn->type) { in hci_num_comp_blocks_evt()
4497 hdev->block_cnt += block_count; in hci_num_comp_blocks_evt()
4498 if (hdev->block_cnt > hdev->num_blocks) in hci_num_comp_blocks_evt()
4499 hdev->block_cnt = hdev->num_blocks; in hci_num_comp_blocks_evt()
4504 conn->type, conn); in hci_num_comp_blocks_evt()
4509 queue_work(hdev->workqueue, &hdev->tx_work); in hci_num_comp_blocks_evt()
4518 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_mode_change_evt()
4522 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_mode_change_evt()
4524 conn->mode = ev->mode; in hci_mode_change_evt()
4527 &conn->flags)) { in hci_mode_change_evt()
4528 if (conn->mode == HCI_CM_ACTIVE) in hci_mode_change_evt()
4529 set_bit(HCI_CONN_POWER_SAVE, &conn->flags); in hci_mode_change_evt()
4531 clear_bit(HCI_CONN_POWER_SAVE, &conn->flags); in hci_mode_change_evt()
4534 if (test_and_clear_bit(HCI_CONN_SCO_SETUP_PEND, &conn->flags)) in hci_mode_change_evt()
4535 hci_sco_setup(conn, ev->status); in hci_mode_change_evt()
4551 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_pin_code_request_evt()
4555 if (conn->state == BT_CONNECTED) { in hci_pin_code_request_evt()
4557 conn->disc_timeout = HCI_PAIRING_TIMEOUT; in hci_pin_code_request_evt()
4562 !test_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags)) { in hci_pin_code_request_evt()
4564 sizeof(ev->bdaddr), &ev->bdaddr); in hci_pin_code_request_evt()
4568 if (conn->pending_sec_level == BT_SECURITY_HIGH) in hci_pin_code_request_evt()
4573 mgmt_pin_code_request(hdev, &ev->bdaddr, secure); in hci_pin_code_request_evt()
4585 conn->pin_length = pin_len; in conn_set_key()
4586 conn->key_type = key_type; in conn_set_key()
4595 conn->pending_sec_level = BT_SECURITY_HIGH; in conn_set_key()
4597 conn->pending_sec_level = BT_SECURITY_MEDIUM; in conn_set_key()
4601 conn->pending_sec_level = BT_SECURITY_MEDIUM; in conn_set_key()
4604 conn->pending_sec_level = BT_SECURITY_HIGH; in conn_set_key()
4607 conn->pending_sec_level = BT_SECURITY_FIPS; in conn_set_key()
4627 key = hci_find_link_key(hdev, &ev->bdaddr); in hci_link_key_request_evt()
4629 bt_dev_dbg(hdev, "link key not found for %pMR", &ev->bdaddr); in hci_link_key_request_evt()
4633 bt_dev_dbg(hdev, "found key type %u for %pMR", key->type, &ev->bdaddr); in hci_link_key_request_evt()
4635 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_link_key_request_evt()
4637 clear_bit(HCI_CONN_NEW_LINK_KEY, &conn->flags); in hci_link_key_request_evt()
4639 if ((key->type == HCI_LK_UNAUTH_COMBINATION_P192 || in hci_link_key_request_evt()
4640 key->type == HCI_LK_UNAUTH_COMBINATION_P256) && in hci_link_key_request_evt()
4641 conn->auth_type != 0xff && (conn->auth_type & 0x01)) { in hci_link_key_request_evt()
4646 if (key->type == HCI_LK_COMBINATION && key->pin_len < 16 && in hci_link_key_request_evt()
4647 (conn->pending_sec_level == BT_SECURITY_HIGH || in hci_link_key_request_evt()
4648 conn->pending_sec_level == BT_SECURITY_FIPS)) { in hci_link_key_request_evt()
4653 conn_set_key(conn, key->type, key->pin_len); in hci_link_key_request_evt()
4656 bacpy(&cp.bdaddr, &ev->bdaddr); in hci_link_key_request_evt()
4657 memcpy(cp.link_key, key->val, HCI_LINK_KEY_SIZE); in hci_link_key_request_evt()
4666 hci_send_cmd(hdev, HCI_OP_LINK_KEY_NEG_REPLY, 6, &ev->bdaddr); in hci_link_key_request_evt()
4683 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_link_key_notify_evt()
4688 conn->disc_timeout = HCI_DISCONN_TIMEOUT; in hci_link_key_notify_evt()
4691 set_bit(HCI_CONN_NEW_LINK_KEY, &conn->flags); in hci_link_key_notify_evt()
4692 conn_set_key(conn, ev->key_type, conn->pin_length); in hci_link_key_notify_evt()
4697 key = hci_add_link_key(hdev, conn, &ev->bdaddr, ev->link_key, in hci_link_key_notify_evt()
4698 ev->key_type, pin_len, &persistent); in hci_link_key_notify_evt()
4705 if (ev->key_type == HCI_LK_CHANGED_COMBINATION) in hci_link_key_notify_evt()
4706 conn_set_key(conn, key->type, key->pin_len); in hci_link_key_notify_evt()
4715 if (key->type == HCI_LK_DEBUG_COMBINATION && in hci_link_key_notify_evt()
4717 list_del_rcu(&key->list); in hci_link_key_notify_evt()
4723 clear_bit(HCI_CONN_FLUSH_KEY, &conn->flags); in hci_link_key_notify_evt()
4725 set_bit(HCI_CONN_FLUSH_KEY, &conn->flags); in hci_link_key_notify_evt()
4737 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_clock_offset_evt()
4741 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_clock_offset_evt()
4742 if (conn && !ev->status) { in hci_clock_offset_evt()
4745 ie = hci_inquiry_cache_lookup(hdev, &conn->dst); in hci_clock_offset_evt()
4747 ie->data.clock_offset = ev->clock_offset; in hci_clock_offset_evt()
4748 ie->timestamp = jiffies; in hci_clock_offset_evt()
4761 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_pkt_type_change_evt()
4765 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_pkt_type_change_evt()
4766 if (conn && !ev->status) in hci_pkt_type_change_evt()
4767 conn->pkt_type = __le16_to_cpu(ev->pkt_type); in hci_pkt_type_change_evt()
4782 ie = hci_inquiry_cache_lookup(hdev, &ev->bdaddr); in hci_pscan_rep_mode_evt()
4784 ie->data.pscan_rep_mode = ev->pscan_rep_mode; in hci_pscan_rep_mode_evt()
4785 ie->timestamp = jiffies; in hci_pscan_rep_mode_evt()
4798 bt_dev_dbg(hdev, "num_rsp %d", ev->num); in hci_inquiry_result_with_rssi_evt()
4800 if (!ev->num) in hci_inquiry_result_with_rssi_evt()
4808 if (skb->len == array_size(ev->num, in hci_inquiry_result_with_rssi_evt()
4812 for (i = 0; i < ev->num; i++) { in hci_inquiry_result_with_rssi_evt()
4819 bt_dev_err(hdev, "Malformed HCI Event: 0x%2.2x", in hci_inquiry_result_with_rssi_evt()
4824 bacpy(&data.bdaddr, &info->bdaddr); in hci_inquiry_result_with_rssi_evt()
4825 data.pscan_rep_mode = info->pscan_rep_mode; in hci_inquiry_result_with_rssi_evt()
4826 data.pscan_period_mode = info->pscan_period_mode; in hci_inquiry_result_with_rssi_evt()
4827 data.pscan_mode = info->pscan_mode; in hci_inquiry_result_with_rssi_evt()
4828 memcpy(data.dev_class, info->dev_class, 3); in hci_inquiry_result_with_rssi_evt()
4829 data.clock_offset = info->clock_offset; in hci_inquiry_result_with_rssi_evt()
4830 data.rssi = info->rssi; in hci_inquiry_result_with_rssi_evt()
4835 mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, in hci_inquiry_result_with_rssi_evt()
4836 info->dev_class, info->rssi, in hci_inquiry_result_with_rssi_evt()
4839 } else if (skb->len == array_size(ev->num, in hci_inquiry_result_with_rssi_evt()
4843 for (i = 0; i < ev->num; i++) { in hci_inquiry_result_with_rssi_evt()
4850 bt_dev_err(hdev, "Malformed HCI Event: 0x%2.2x", in hci_inquiry_result_with_rssi_evt()
4855 bacpy(&data.bdaddr, &info->bdaddr); in hci_inquiry_result_with_rssi_evt()
4856 data.pscan_rep_mode = info->pscan_rep_mode; in hci_inquiry_result_with_rssi_evt()
4857 data.pscan_period_mode = info->pscan_period_mode; in hci_inquiry_result_with_rssi_evt()
4859 memcpy(data.dev_class, info->dev_class, 3); in hci_inquiry_result_with_rssi_evt()
4860 data.clock_offset = info->clock_offset; in hci_inquiry_result_with_rssi_evt()
4861 data.rssi = info->rssi; in hci_inquiry_result_with_rssi_evt()
4866 mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, in hci_inquiry_result_with_rssi_evt()
4867 info->dev_class, info->rssi, in hci_inquiry_result_with_rssi_evt()
4871 bt_dev_err(hdev, "Malformed HCI Event: 0x%2.2x", in hci_inquiry_result_with_rssi_evt()
4884 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_remote_ext_features_evt()
4888 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_remote_ext_features_evt()
4892 if (ev->page < HCI_MAX_PAGES) in hci_remote_ext_features_evt()
4893 memcpy(conn->features[ev->page], ev->features, 8); in hci_remote_ext_features_evt()
4895 if (!ev->status && ev->page == 0x01) { in hci_remote_ext_features_evt()
4898 ie = hci_inquiry_cache_lookup(hdev, &conn->dst); in hci_remote_ext_features_evt()
4900 ie->data.ssp_mode = (ev->features[0] & LMP_HOST_SSP); in hci_remote_ext_features_evt()
4902 if (ev->features[0] & LMP_HOST_SSP) { in hci_remote_ext_features_evt()
4903 set_bit(HCI_CONN_SSP_ENABLED, &conn->flags); in hci_remote_ext_features_evt()
4913 clear_bit(HCI_CONN_SSP_ENABLED, &conn->flags); in hci_remote_ext_features_evt()
4916 if (ev->features[0] & LMP_HOST_SC) in hci_remote_ext_features_evt()
4917 set_bit(HCI_CONN_SC_ENABLED, &conn->flags); in hci_remote_ext_features_evt()
4920 if (conn->state != BT_CONFIG) in hci_remote_ext_features_evt()
4923 if (!ev->status && !test_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) { in hci_remote_ext_features_evt()
4926 bacpy(&cp.bdaddr, &conn->dst); in hci_remote_ext_features_evt()
4929 } else if (!test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) in hci_remote_ext_features_evt()
4933 conn->state = BT_CONNECTED; in hci_remote_ext_features_evt()
4934 hci_connect_cfm(conn, ev->status); in hci_remote_ext_features_evt()
4947 u8 status = ev->status; in hci_sync_conn_complete_evt()
4949 switch (ev->link_type) { in hci_sync_conn_complete_evt()
4962 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_sync_conn_complete_evt()
4966 conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, &ev->bdaddr); in hci_sync_conn_complete_evt()
4968 if (ev->link_type == ESCO_LINK) in hci_sync_conn_complete_evt()
4980 conn = hci_conn_hash_lookup_ba(hdev, ESCO_LINK, &ev->bdaddr); in hci_sync_conn_complete_evt()
4991 if (conn->handle != HCI_CONN_HANDLE_UNSET) { in hci_sync_conn_complete_evt()
4998 conn->handle = __le16_to_cpu(ev->handle); in hci_sync_conn_complete_evt()
4999 if (conn->handle > HCI_CONN_HANDLE_MAX) { in hci_sync_conn_complete_evt()
5000 bt_dev_err(hdev, "Invalid handle: 0x%4.4x > 0x%4.4x", in hci_sync_conn_complete_evt()
5001 conn->handle, HCI_CONN_HANDLE_MAX); in hci_sync_conn_complete_evt()
5003 conn->state = BT_CLOSED; in hci_sync_conn_complete_evt()
5007 conn->state = BT_CONNECTED; in hci_sync_conn_complete_evt()
5008 conn->type = ev->link_type; in hci_sync_conn_complete_evt()
5022 if (conn->out) { in hci_sync_conn_complete_evt()
5023 conn->pkt_type = (hdev->esco_type & SCO_ESCO_MASK) | in hci_sync_conn_complete_evt()
5024 (hdev->esco_type & EDR_ESCO_MASK); in hci_sync_conn_complete_evt()
5025 if (hci_setup_sync(conn, conn->link->handle)) in hci_sync_conn_complete_evt()
5031 conn->state = BT_CLOSED; in hci_sync_conn_complete_evt()
5035 bt_dev_dbg(hdev, "SCO connected with air mode: %02x", ev->air_mode); in hci_sync_conn_complete_evt()
5037 * is zero and non-zero value shall be non-HCI transport data path in hci_sync_conn_complete_evt()
5039 if (conn->codec.data_path == 0 && hdev->notify) { in hci_sync_conn_complete_evt()
5040 switch (ev->air_mode) { in hci_sync_conn_complete_evt()
5042 hdev->notify(hdev, HCI_NOTIFY_ENABLE_SCO_CVSD); in hci_sync_conn_complete_evt()
5045 hdev->notify(hdev, HCI_NOTIFY_ENABLE_SCO_TRANSP); in hci_sync_conn_complete_evt()
5084 flex_array_size(ev, info, ev->num))) in hci_extended_inquiry_result_evt()
5087 bt_dev_dbg(hdev, "num %d", ev->num); in hci_extended_inquiry_result_evt()
5089 if (!ev->num) in hci_extended_inquiry_result_evt()
5097 for (i = 0; i < ev->num; i++) { in hci_extended_inquiry_result_evt()
5098 struct extended_inquiry_info *info = &ev->info[i]; in hci_extended_inquiry_result_evt()
5102 bacpy(&data.bdaddr, &info->bdaddr); in hci_extended_inquiry_result_evt()
5103 data.pscan_rep_mode = info->pscan_rep_mode; in hci_extended_inquiry_result_evt()
5104 data.pscan_period_mode = info->pscan_period_mode; in hci_extended_inquiry_result_evt()
5106 memcpy(data.dev_class, info->dev_class, 3); in hci_extended_inquiry_result_evt()
5107 data.clock_offset = info->clock_offset; in hci_extended_inquiry_result_evt()
5108 data.rssi = info->rssi; in hci_extended_inquiry_result_evt()
5112 name_known = eir_get_data(info->data, in hci_extended_inquiry_result_evt()
5113 sizeof(info->data), in hci_extended_inquiry_result_evt()
5120 eir_len = eir_get_length(info->data, sizeof(info->data)); in hci_extended_inquiry_result_evt()
5122 mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, in hci_extended_inquiry_result_evt()
5123 info->dev_class, info->rssi, in hci_extended_inquiry_result_evt()
5124 flags, info->data, eir_len, NULL, 0, 0); in hci_extended_inquiry_result_evt()
5136 bt_dev_dbg(hdev, "status 0x%2.2x handle 0x%4.4x", ev->status, in hci_key_refresh_complete_evt()
5137 __le16_to_cpu(ev->handle)); in hci_key_refresh_complete_evt()
5141 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_key_refresh_complete_evt()
5148 if (conn->type != LE_LINK) in hci_key_refresh_complete_evt()
5151 if (!ev->status) in hci_key_refresh_complete_evt()
5152 conn->sec_level = conn->pending_sec_level; in hci_key_refresh_complete_evt()
5154 clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags); in hci_key_refresh_complete_evt()
5156 if (ev->status && conn->state == BT_CONNECTED) { in hci_key_refresh_complete_evt()
5162 if (conn->state == BT_CONFIG) { in hci_key_refresh_complete_evt()
5163 if (!ev->status) in hci_key_refresh_complete_evt()
5164 conn->state = BT_CONNECTED; in hci_key_refresh_complete_evt()
5166 hci_connect_cfm(conn, ev->status); in hci_key_refresh_complete_evt()
5169 hci_auth_cfm(conn, ev->status); in hci_key_refresh_complete_evt()
5172 conn->disc_timeout = HCI_DISCONN_TIMEOUT; in hci_key_refresh_complete_evt()
5182 /* If remote requests no-bonding follow that lead */ in hci_get_auth_req()
5183 if (conn->remote_auth == HCI_AT_NO_BONDING || in hci_get_auth_req()
5184 conn->remote_auth == HCI_AT_NO_BONDING_MITM) in hci_get_auth_req()
5185 return conn->remote_auth | (conn->auth_type & 0x01); in hci_get_auth_req()
5190 if (conn->remote_cap != HCI_IO_NO_INPUT_OUTPUT && in hci_get_auth_req()
5191 conn->io_capability != HCI_IO_NO_INPUT_OUTPUT) in hci_get_auth_req()
5192 return conn->remote_auth | 0x01; in hci_get_auth_req()
5195 return (conn->remote_auth & ~0x01) | (conn->auth_type & 0x01); in hci_get_auth_req()
5200 struct hci_dev *hdev = conn->hdev; in bredr_oob_data_present()
5203 data = hci_find_remote_oob_data(hdev, &conn->dst, BDADDR_BREDR); in bredr_oob_data_present()
5215 return data->present; in bredr_oob_data_present()
5218 * the P-256 values are required. If they are not in bredr_oob_data_present()
5222 if (!memcmp(data->rand256, ZERO_KEY, 16) || in bredr_oob_data_present()
5223 !memcmp(data->hash256, ZERO_KEY, 16)) in bredr_oob_data_present()
5231 * P-192 data values are present. in bredr_oob_data_present()
5233 if (!memcmp(data->rand192, ZERO_KEY, 16) || in bredr_oob_data_present()
5234 !memcmp(data->hash192, ZERO_KEY, 16)) in bredr_oob_data_present()
5250 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_io_capa_request_evt()
5263 test_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags) || in hci_io_capa_request_evt()
5264 (conn->remote_auth & ~0x01) == HCI_AT_NO_BONDING) { in hci_io_capa_request_evt()
5267 bacpy(&cp.bdaddr, &ev->bdaddr); in hci_io_capa_request_evt()
5270 cp.capability = (conn->io_capability == 0x04) ? in hci_io_capa_request_evt()
5271 HCI_IO_DISPLAY_YESNO : conn->io_capability; in hci_io_capa_request_evt()
5274 if (conn->remote_auth == 0xff) { in hci_io_capa_request_evt()
5276 * except for the no-bonding case. in hci_io_capa_request_evt()
5278 if (conn->io_capability != HCI_IO_NO_INPUT_OUTPUT && in hci_io_capa_request_evt()
5279 conn->auth_type != HCI_AT_NO_BONDING) in hci_io_capa_request_evt()
5280 conn->auth_type |= 0x01; in hci_io_capa_request_evt()
5282 conn->auth_type = hci_get_auth_req(conn); in hci_io_capa_request_evt()
5285 /* If we're not bondable, force one of the non-bondable in hci_io_capa_request_evt()
5289 conn->auth_type &= HCI_AT_NO_BONDING_MITM; in hci_io_capa_request_evt()
5291 cp.authentication = conn->auth_type; in hci_io_capa_request_evt()
5299 bacpy(&cp.bdaddr, &ev->bdaddr); in hci_io_capa_request_evt()
5320 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_io_capa_reply_evt()
5324 conn->remote_cap = ev->capability; in hci_io_capa_reply_evt()
5325 conn->remote_auth = ev->authentication; in hci_io_capa_reply_evt()
5345 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_user_confirm_request_evt()
5349 loc_mitm = (conn->auth_type & 0x01); in hci_user_confirm_request_evt()
5350 rem_mitm = (conn->remote_auth & 0x01); in hci_user_confirm_request_evt()
5355 * necessarily match conn->auth_type. in hci_user_confirm_request_evt()
5357 if (conn->pending_sec_level > BT_SECURITY_MEDIUM && in hci_user_confirm_request_evt()
5358 conn->remote_cap == HCI_IO_NO_INPUT_OUTPUT) { in hci_user_confirm_request_evt()
5361 sizeof(ev->bdaddr), &ev->bdaddr); in hci_user_confirm_request_evt()
5365 /* If no side requires MITM protection; auto-accept */ in hci_user_confirm_request_evt()
5366 if ((!loc_mitm || conn->remote_cap == HCI_IO_NO_INPUT_OUTPUT) && in hci_user_confirm_request_evt()
5367 (!rem_mitm || conn->io_capability == HCI_IO_NO_INPUT_OUTPUT)) { in hci_user_confirm_request_evt()
5373 * NoInputNoOutput, in which case we do auto-accept in hci_user_confirm_request_evt()
5375 if (!test_bit(HCI_CONN_AUTH_PEND, &conn->flags) && in hci_user_confirm_request_evt()
5376 conn->io_capability != HCI_IO_NO_INPUT_OUTPUT && in hci_user_confirm_request_evt()
5378 bt_dev_dbg(hdev, "Confirming auto-accept as acceptor"); in hci_user_confirm_request_evt()
5387 if (hci_find_link_key(hdev, &ev->bdaddr)) { in hci_user_confirm_request_evt()
5393 BT_DBG("Auto-accept of user confirmation with %ums delay", in hci_user_confirm_request_evt()
5394 hdev->auto_accept_delay); in hci_user_confirm_request_evt()
5396 if (hdev->auto_accept_delay > 0) { in hci_user_confirm_request_evt()
5397 int delay = msecs_to_jiffies(hdev->auto_accept_delay); in hci_user_confirm_request_evt()
5398 queue_delayed_work(conn->hdev->workqueue, in hci_user_confirm_request_evt()
5399 &conn->auto_accept_work, delay); in hci_user_confirm_request_evt()
5404 sizeof(ev->bdaddr), &ev->bdaddr); in hci_user_confirm_request_evt()
5409 mgmt_user_confirm_request(hdev, &ev->bdaddr, ACL_LINK, 0, in hci_user_confirm_request_evt()
5410 le32_to_cpu(ev->passkey), confirm_hint); in hci_user_confirm_request_evt()
5424 mgmt_user_passkey_request(hdev, &ev->bdaddr, ACL_LINK, 0); in hci_user_passkey_request_evt()
5435 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_user_passkey_notify_evt()
5439 conn->passkey_notify = __le32_to_cpu(ev->passkey); in hci_user_passkey_notify_evt()
5440 conn->passkey_entered = 0; in hci_user_passkey_notify_evt()
5443 mgmt_user_passkey_notify(hdev, &conn->dst, conn->type, in hci_user_passkey_notify_evt()
5444 conn->dst_type, conn->passkey_notify, in hci_user_passkey_notify_evt()
5445 conn->passkey_entered); in hci_user_passkey_notify_evt()
5456 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_keypress_notify_evt()
5460 switch (ev->type) { in hci_keypress_notify_evt()
5462 conn->passkey_entered = 0; in hci_keypress_notify_evt()
5466 conn->passkey_entered++; in hci_keypress_notify_evt()
5470 conn->passkey_entered--; in hci_keypress_notify_evt()
5474 conn->passkey_entered = 0; in hci_keypress_notify_evt()
5482 mgmt_user_passkey_notify(hdev, &conn->dst, conn->type, in hci_keypress_notify_evt()
5483 conn->dst_type, conn->passkey_notify, in hci_keypress_notify_evt()
5484 conn->passkey_entered); in hci_keypress_notify_evt()
5497 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_simple_pair_complete_evt()
5502 conn->remote_auth = 0xff; in hci_simple_pair_complete_evt()
5509 if (!test_bit(HCI_CONN_AUTH_PEND, &conn->flags) && ev->status) in hci_simple_pair_complete_evt()
5510 mgmt_auth_failed(conn, ev->status); in hci_simple_pair_complete_evt()
5529 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_remote_host_features_evt()
5531 memcpy(conn->features[1], ev->features, 8); in hci_remote_host_features_evt()
5533 ie = hci_inquiry_cache_lookup(hdev, &ev->bdaddr); in hci_remote_host_features_evt()
5535 ie->data.ssp_mode = (ev->features[0] & LMP_HOST_SSP); in hci_remote_host_features_evt()
5553 data = hci_find_remote_oob_data(hdev, &ev->bdaddr, BDADDR_BREDR); in hci_remote_oob_data_request_evt()
5557 bacpy(&cp.bdaddr, &ev->bdaddr); in hci_remote_oob_data_request_evt()
5566 bacpy(&cp.bdaddr, &ev->bdaddr); in hci_remote_oob_data_request_evt()
5571 memcpy(cp.hash192, data->hash192, sizeof(cp.hash192)); in hci_remote_oob_data_request_evt()
5572 memcpy(cp.rand192, data->rand192, sizeof(cp.rand192)); in hci_remote_oob_data_request_evt()
5574 memcpy(cp.hash256, data->hash256, sizeof(cp.hash256)); in hci_remote_oob_data_request_evt()
5575 memcpy(cp.rand256, data->rand256, sizeof(cp.rand256)); in hci_remote_oob_data_request_evt()
5582 bacpy(&cp.bdaddr, &ev->bdaddr); in hci_remote_oob_data_request_evt()
5583 memcpy(cp.hash, data->hash192, sizeof(cp.hash)); in hci_remote_oob_data_request_evt()
5584 memcpy(cp.rand, data->rand192, sizeof(cp.rand)); in hci_remote_oob_data_request_evt()
5601 bt_dev_dbg(hdev, "handle 0x%2.2x", ev->phy_handle); in hci_chan_selected_evt()
5603 hcon = hci_conn_hash_lookup_handle(hdev, ev->phy_handle); in hci_chan_selected_evt()
5616 bt_dev_dbg(hdev, "handle 0x%2.2x status 0x%2.2x", ev->phy_handle, in hci_phy_link_complete_evt()
5617 ev->status); in hci_phy_link_complete_evt()
5621 hcon = hci_conn_hash_lookup_handle(hdev, ev->phy_handle); in hci_phy_link_complete_evt()
5625 if (!hcon->amp_mgr) in hci_phy_link_complete_evt()
5628 if (ev->status) { in hci_phy_link_complete_evt()
5633 bredr_hcon = hcon->amp_mgr->l2cap_conn->hcon; in hci_phy_link_complete_evt()
5635 hcon->state = BT_CONNECTED; in hci_phy_link_complete_evt()
5636 bacpy(&hcon->dst, &bredr_hcon->dst); in hci_phy_link_complete_evt()
5639 hcon->disc_timeout = HCI_DISCONN_TIMEOUT; in hci_phy_link_complete_evt()
5659 bt_dev_dbg(hdev, "log_handle 0x%4.4x phy_handle 0x%2.2x status 0x%2.2x", in hci_loglink_complete_evt()
5660 le16_to_cpu(ev->handle), ev->phy_handle, ev->status); in hci_loglink_complete_evt()
5662 hcon = hci_conn_hash_lookup_handle(hdev, ev->phy_handle); in hci_loglink_complete_evt()
5671 hchan->handle = le16_to_cpu(ev->handle); in hci_loglink_complete_evt()
5672 hchan->amp = true; in hci_loglink_complete_evt()
5674 BT_DBG("hcon %p mgr %p hchan %p", hcon, hcon->amp_mgr, hchan); in hci_loglink_complete_evt()
5676 mgr = hcon->amp_mgr; in hci_loglink_complete_evt()
5677 if (mgr && mgr->bredr_chan) { in hci_loglink_complete_evt()
5678 struct l2cap_chan *bredr_chan = mgr->bredr_chan; in hci_loglink_complete_evt()
5682 bredr_chan->conn->mtu = hdev->block_mtu; in hci_loglink_complete_evt()
5696 bt_dev_dbg(hdev, "handle 0x%4.4x status 0x%2.2x", in hci_disconn_loglink_complete_evt()
5697 le16_to_cpu(ev->handle), ev->status); in hci_disconn_loglink_complete_evt()
5699 if (ev->status) in hci_disconn_loglink_complete_evt()
5704 hchan = hci_chan_lookup_handle(hdev, le16_to_cpu(ev->handle)); in hci_disconn_loglink_complete_evt()
5705 if (!hchan || !hchan->amp) in hci_disconn_loglink_complete_evt()
5708 amp_destroy_logical_link(hchan, ev->reason); in hci_disconn_loglink_complete_evt()
5720 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_disconn_phylink_complete_evt()
5722 if (ev->status) in hci_disconn_phylink_complete_evt()
5727 hcon = hci_conn_hash_lookup_handle(hdev, ev->phy_handle); in hci_disconn_phylink_complete_evt()
5728 if (hcon && hcon->type == AMP_LINK) { in hci_disconn_phylink_complete_evt()
5729 hcon->state = BT_CLOSED; in hci_disconn_phylink_complete_evt()
5730 hci_disconn_cfm(hcon, ev->reason); in hci_disconn_phylink_complete_evt()
5741 if (conn->out) { in le_conn_update_addr()
5742 conn->dst_type = bdaddr_type; in le_conn_update_addr()
5743 conn->resp_addr_type = bdaddr_type; in le_conn_update_addr()
5744 bacpy(&conn->resp_addr, bdaddr); in le_conn_update_addr()
5747 * used instead or hdev->rpa. in le_conn_update_addr()
5750 conn->init_addr_type = ADDR_LE_DEV_RANDOM; in le_conn_update_addr()
5751 bacpy(&conn->init_addr, local_rpa); in le_conn_update_addr()
5752 } else if (hci_dev_test_flag(conn->hdev, HCI_PRIVACY)) { in le_conn_update_addr()
5753 conn->init_addr_type = ADDR_LE_DEV_RANDOM; in le_conn_update_addr()
5754 bacpy(&conn->init_addr, &conn->hdev->rpa); in le_conn_update_addr()
5756 hci_copy_identity_address(conn->hdev, &conn->init_addr, in le_conn_update_addr()
5757 &conn->init_addr_type); in le_conn_update_addr()
5760 conn->resp_addr_type = conn->hdev->adv_addr_type; in le_conn_update_addr()
5762 * used instead or hdev->rpa. in le_conn_update_addr()
5765 conn->resp_addr_type = ADDR_LE_DEV_RANDOM; in le_conn_update_addr()
5766 bacpy(&conn->resp_addr, local_rpa); in le_conn_update_addr()
5767 } else if (conn->hdev->adv_addr_type == ADDR_LE_DEV_RANDOM) { in le_conn_update_addr()
5771 if (!ext_adv_capable(conn->hdev)) in le_conn_update_addr()
5772 bacpy(&conn->resp_addr, in le_conn_update_addr()
5773 &conn->hdev->random_addr); in le_conn_update_addr()
5775 bacpy(&conn->resp_addr, &conn->hdev->bdaddr); in le_conn_update_addr()
5778 conn->init_addr_type = bdaddr_type; in le_conn_update_addr()
5779 bacpy(&conn->init_addr, bdaddr); in le_conn_update_addr()
5786 conn->le_conn_min_interval = conn->hdev->le_conn_min_interval; in le_conn_update_addr()
5787 conn->le_conn_max_interval = conn->hdev->le_conn_max_interval; in le_conn_update_addr()
5823 conn->dst_type = bdaddr_type; in le_conn_complete_evt()
5833 if (conn->out) { in le_conn_complete_evt()
5834 conn->resp_addr_type = bdaddr_type; in le_conn_complete_evt()
5835 bacpy(&conn->resp_addr, bdaddr); in le_conn_complete_evt()
5837 conn->init_addr_type = ADDR_LE_DEV_RANDOM; in le_conn_complete_evt()
5838 bacpy(&conn->init_addr, &hdev->rpa); in le_conn_complete_evt()
5841 &conn->init_addr, in le_conn_complete_evt()
5842 &conn->init_addr_type); in le_conn_complete_evt()
5846 cancel_delayed_work(&conn->le_conn_timeout); in le_conn_complete_evt()
5855 if (conn->handle != HCI_CONN_HANDLE_UNSET) { in le_conn_complete_evt()
5871 irk = hci_get_irk(hdev, &conn->dst, conn->dst_type); in le_conn_complete_evt()
5873 bacpy(&conn->dst, &irk->bdaddr); in le_conn_complete_evt()
5874 conn->dst_type = irk->addr_type; in le_conn_complete_evt()
5877 conn->dst_type = ev_bdaddr_type(hdev, conn->dst_type, NULL); in le_conn_complete_evt()
5880 bt_dev_err(hdev, "Invalid handle: 0x%4.4x > 0x%4.4x", handle, in le_conn_complete_evt()
5892 if (conn->dst_type == ADDR_LE_DEV_PUBLIC) in le_conn_complete_evt()
5898 if (hci_bdaddr_list_lookup(&hdev->reject_list, &conn->dst, addr_type)) { in le_conn_complete_evt()
5903 if (!test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) in le_conn_complete_evt()
5906 conn->sec_level = BT_SECURITY_LOW; in le_conn_complete_evt()
5907 conn->handle = handle; in le_conn_complete_evt()
5908 conn->state = BT_CONFIG; in le_conn_complete_evt()
5911 * when sotfware rotation is in use so it can be re-enabled when in le_conn_complete_evt()
5915 conn->adv_instance = hdev->cur_adv_instance; in le_conn_complete_evt()
5917 conn->le_conn_interval = interval; in le_conn_complete_evt()
5918 conn->le_conn_latency = latency; in le_conn_complete_evt()
5919 conn->le_supv_timeout = supervision_timeout; in le_conn_complete_evt()
5928 * If the local controller supports peripheral-initiated features in le_conn_complete_evt()
5933 if (conn->out || in le_conn_complete_evt()
5934 (hdev->le_features[0] & HCI_LE_PERIPHERAL_FEATURES)) { in le_conn_complete_evt()
5937 cp.handle = __cpu_to_le16(conn->handle); in le_conn_complete_evt()
5944 conn->state = BT_CONNECTED; in le_conn_complete_evt()
5948 params = hci_pend_le_action_lookup(&hdev->pend_le_conns, &conn->dst, in le_conn_complete_evt()
5949 conn->dst_type); in le_conn_complete_evt()
5951 list_del_init(&params->action); in le_conn_complete_evt()
5952 if (params->conn) { in le_conn_complete_evt()
5953 hci_conn_drop(params->conn); in le_conn_complete_evt()
5954 hci_conn_put(params->conn); in le_conn_complete_evt()
5955 params->conn = NULL; in le_conn_complete_evt()
5969 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_conn_complete_evt()
5971 le_conn_complete_evt(hdev, ev->status, &ev->bdaddr, ev->bdaddr_type, in hci_le_conn_complete_evt()
5972 NULL, ev->role, le16_to_cpu(ev->handle), in hci_le_conn_complete_evt()
5973 le16_to_cpu(ev->interval), in hci_le_conn_complete_evt()
5974 le16_to_cpu(ev->latency), in hci_le_conn_complete_evt()
5975 le16_to_cpu(ev->supervision_timeout)); in hci_le_conn_complete_evt()
5983 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_enh_conn_complete_evt()
5985 le_conn_complete_evt(hdev, ev->status, &ev->bdaddr, ev->bdaddr_type, in hci_le_enh_conn_complete_evt()
5986 &ev->local_rpa, ev->role, le16_to_cpu(ev->handle), in hci_le_enh_conn_complete_evt()
5987 le16_to_cpu(ev->interval), in hci_le_enh_conn_complete_evt()
5988 le16_to_cpu(ev->latency), in hci_le_enh_conn_complete_evt()
5989 le16_to_cpu(ev->supervision_timeout)); in hci_le_enh_conn_complete_evt()
5999 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_ext_adv_term_evt()
6008 if (ev->status == HCI_ERROR_CANCELLED_BY_HOST) { in hci_le_ext_adv_term_evt()
6015 adv = hci_find_adv_instance(hdev, ev->handle); in hci_le_ext_adv_term_evt()
6017 if (ev->status) { in hci_le_ext_adv_term_evt()
6022 hci_remove_adv_instance(hdev, ev->handle); in hci_le_ext_adv_term_evt()
6023 mgmt_advertising_removed(NULL, hdev, ev->handle); in hci_le_ext_adv_term_evt()
6025 list_for_each_entry_safe(adv, n, &hdev->adv_instances, list) { in hci_le_ext_adv_term_evt()
6026 if (adv->enabled) in hci_le_ext_adv_term_evt()
6036 adv->enabled = false; in hci_le_ext_adv_term_evt()
6038 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->conn_handle)); in hci_le_ext_adv_term_evt()
6041 * instance can be re-enabled when disconnected. in hci_le_ext_adv_term_evt()
6043 conn->adv_instance = ev->handle; in hci_le_ext_adv_term_evt()
6045 if (hdev->adv_addr_type != ADDR_LE_DEV_RANDOM || in hci_le_ext_adv_term_evt()
6046 bacmp(&conn->resp_addr, BDADDR_ANY)) in hci_le_ext_adv_term_evt()
6049 if (!ev->handle) { in hci_le_ext_adv_term_evt()
6050 bacpy(&conn->resp_addr, &hdev->random_addr); in hci_le_ext_adv_term_evt()
6055 bacpy(&conn->resp_addr, &adv->random_addr); in hci_le_ext_adv_term_evt()
6068 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_conn_update_complete_evt()
6070 if (ev->status) in hci_le_conn_update_complete_evt()
6075 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_conn_update_complete_evt()
6077 conn->le_conn_interval = le16_to_cpu(ev->interval); in hci_le_conn_update_complete_evt()
6078 conn->le_conn_latency = le16_to_cpu(ev->latency); in hci_le_conn_update_complete_evt()
6079 conn->le_supv_timeout = le16_to_cpu(ev->supervision_timeout); in hci_le_conn_update_complete_evt()
6085 /* This function requires the caller holds hdev->lock */
6099 if (hci_bdaddr_list_lookup(&hdev->reject_list, addr, addr_type) || in check_pending_le_conn()
6100 hdev->suspended) in check_pending_le_conn()
6106 if (hdev->conn_hash.le_num_peripheral > 0 && in check_pending_le_conn()
6107 (!test_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks) || in check_pending_le_conn()
6108 !(hdev->le_states[3] & 0x10))) in check_pending_le_conn()
6114 params = hci_pend_le_action_lookup(&hdev->pend_le_conns, addr, in check_pending_le_conn()
6119 if (!params->explicit_connect) { in check_pending_le_conn()
6120 switch (params->auto_connect) { in check_pending_le_conn()
6143 BT_SECURITY_LOW, hdev->def_le_autoconnect_timeout, in check_pending_le_conn()
6155 if (!params->explicit_connect) in check_pending_le_conn()
6156 params->conn = hci_conn_get(conn); in check_pending_le_conn()
6162 case -EBUSY: in check_pending_le_conn()
6163 /* If hci_connect() returns -EBUSY it means there is already in check_pending_le_conn()
6182 struct discovery_state *d = &hdev->discovery; in process_adv_report()
6198 "type: 0x%02x", type); in process_adv_report()
6221 len = ptr - data; in process_adv_report()
6248 if (!smp_irk_matches(hdev, hdev->irk, direct_addr)) in process_adv_report()
6255 bdaddr = &irk->bdaddr; in process_adv_report()
6256 bdaddr_type = irk->addr_type; in process_adv_report()
6272 memcpy(conn->le_adv_data, data, len); in process_adv_report()
6273 conn->le_adv_data_len = len; in process_adv_report()
6292 if (hdev->le_scan_type == LE_SCAN_PASSIVE) { in process_adv_report()
6296 if (!hci_pend_le_action_lookup(&hdev->pend_le_reports, in process_adv_report()
6298 idr_is_empty(&hdev->adv_monitors_idr)) in process_adv_report()
6306 /* When receiving non-connectable or scannable undirected in process_adv_report()
6344 match = (!bacmp(bdaddr, &d->last_adv_addr) && in process_adv_report()
6345 bdaddr_type == d->last_adv_addr_type); in process_adv_report()
6354 mgmt_device_found(hdev, &d->last_adv_addr, LE_LINK, in process_adv_report()
6355 d->last_adv_addr_type, NULL, in process_adv_report()
6356 d->last_adv_rssi, d->last_adv_flags, in process_adv_report()
6357 d->last_adv_data, in process_adv_report()
6358 d->last_adv_data_len, NULL, 0, 0); in process_adv_report()
6383 mgmt_device_found(hdev, &d->last_adv_addr, LE_LINK, in process_adv_report()
6384 d->last_adv_addr_type, NULL, rssi, d->last_adv_flags, in process_adv_report()
6385 d->last_adv_data, d->last_adv_data_len, data, len, 0); in process_adv_report()
6395 if (!ev->num) in hci_le_adv_report_evt()
6400 while (ev->num--) { in hci_le_adv_report_evt()
6411 info->length + 1)) in hci_le_adv_report_evt()
6414 if (info->length <= HCI_MAX_AD_LENGTH) { in hci_le_adv_report_evt()
6415 rssi = info->data[info->length]; in hci_le_adv_report_evt()
6416 process_adv_report(hdev, info->type, &info->bdaddr, in hci_le_adv_report_evt()
6417 info->bdaddr_type, NULL, 0, rssi, in hci_le_adv_report_evt()
6418 info->data, info->length, false, in hci_le_adv_report_evt()
6466 bt_dev_err_ratelimited(hdev, "Unknown advertising packet type: 0x%02x", in ext_evt_type_to_legacy()
6478 if (!ev->num) in hci_le_ext_adv_report_evt()
6483 while (ev->num--) { in hci_le_ext_adv_report_evt()
6494 info->length)) in hci_le_ext_adv_report_evt()
6497 evt_type = __le16_to_cpu(info->type); in hci_le_ext_adv_report_evt()
6500 process_adv_report(hdev, legacy_evt_type, &info->bdaddr, in hci_le_ext_adv_report_evt()
6501 info->bdaddr_type, NULL, 0, in hci_le_ext_adv_report_evt()
6502 info->rssi, info->data, info->length, in hci_le_ext_adv_report_evt()
6525 int mask = hdev->link_mode; in hci_le_pa_sync_estabilished_evt()
6528 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_pa_sync_estabilished_evt()
6530 if (ev->status) in hci_le_pa_sync_estabilished_evt()
6537 mask |= hci_proto_connect_ind(hdev, &ev->bdaddr, ISO_LINK, &flags); in hci_le_pa_sync_estabilished_evt()
6539 hci_le_pa_term_sync(hdev, ev->handle); in hci_le_pa_sync_estabilished_evt()
6550 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_remote_feat_complete_evt()
6554 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_remote_feat_complete_evt()
6556 if (!ev->status) in hci_le_remote_feat_complete_evt()
6557 memcpy(conn->features[0], ev->features, 8); in hci_le_remote_feat_complete_evt()
6559 if (conn->state == BT_CONFIG) { in hci_le_remote_feat_complete_evt()
6562 /* If the local controller supports peripheral-initiated in hci_le_remote_feat_complete_evt()
6571 if (!conn->out && ev->status == 0x1a && in hci_le_remote_feat_complete_evt()
6572 (hdev->le_features[0] & HCI_LE_PERIPHERAL_FEATURES)) in hci_le_remote_feat_complete_evt()
6575 status = ev->status; in hci_le_remote_feat_complete_evt()
6577 conn->state = BT_CONNECTED; in hci_le_remote_feat_complete_evt()
6595 bt_dev_dbg(hdev, "handle 0x%4.4x", __le16_to_cpu(ev->handle)); in hci_le_ltk_request_evt()
6599 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_ltk_request_evt()
6603 ltk = hci_find_ltk(hdev, &conn->dst, conn->dst_type, conn->role); in hci_le_ltk_request_evt()
6609 if (ev->ediv || ev->rand) in hci_le_ltk_request_evt()
6612 /* For non-SC keys check that EDiv and Rand match */ in hci_le_ltk_request_evt()
6613 if (ev->ediv != ltk->ediv || ev->rand != ltk->rand) in hci_le_ltk_request_evt()
6617 memcpy(cp.ltk, ltk->val, ltk->enc_size); in hci_le_ltk_request_evt()
6618 memset(cp.ltk + ltk->enc_size, 0, sizeof(cp.ltk) - ltk->enc_size); in hci_le_ltk_request_evt()
6619 cp.handle = cpu_to_le16(conn->handle); in hci_le_ltk_request_evt()
6621 conn->pending_sec_level = smp_ltk_sec_level(ltk); in hci_le_ltk_request_evt()
6623 conn->enc_key_size = ltk->enc_size; in hci_le_ltk_request_evt()
6630 * distribute the keys. Later, security can be re-established in hci_le_ltk_request_evt()
6633 if (ltk->type == SMP_STK) { in hci_le_ltk_request_evt()
6634 set_bit(HCI_CONN_STK_ENCRYPT, &conn->flags); in hci_le_ltk_request_evt()
6635 list_del_rcu(&ltk->list); in hci_le_ltk_request_evt()
6638 clear_bit(HCI_CONN_STK_ENCRYPT, &conn->flags); in hci_le_ltk_request_evt()
6646 neg.handle = ev->handle; in hci_le_ltk_request_evt()
6671 bt_dev_dbg(hdev, "handle 0x%4.4x", __le16_to_cpu(ev->handle)); in hci_le_remote_conn_param_req_evt()
6673 handle = le16_to_cpu(ev->handle); in hci_le_remote_conn_param_req_evt()
6674 min = le16_to_cpu(ev->interval_min); in hci_le_remote_conn_param_req_evt()
6675 max = le16_to_cpu(ev->interval_max); in hci_le_remote_conn_param_req_evt()
6676 latency = le16_to_cpu(ev->latency); in hci_le_remote_conn_param_req_evt()
6677 timeout = le16_to_cpu(ev->timeout); in hci_le_remote_conn_param_req_evt()
6680 if (!hcon || hcon->state != BT_CONNECTED) in hci_le_remote_conn_param_req_evt()
6688 if (hcon->role == HCI_ROLE_MASTER) { in hci_le_remote_conn_param_req_evt()
6694 params = hci_conn_params_lookup(hdev, &hcon->dst, in hci_le_remote_conn_param_req_evt()
6695 hcon->dst_type); in hci_le_remote_conn_param_req_evt()
6697 params->conn_min_interval = min; in hci_le_remote_conn_param_req_evt()
6698 params->conn_max_interval = max; in hci_le_remote_conn_param_req_evt()
6699 params->conn_latency = latency; in hci_le_remote_conn_param_req_evt()
6700 params->supervision_timeout = timeout; in hci_le_remote_conn_param_req_evt()
6708 mgmt_new_conn_param(hdev, &hcon->dst, hcon->dst_type, in hci_le_remote_conn_param_req_evt()
6712 cp.handle = ev->handle; in hci_le_remote_conn_param_req_evt()
6713 cp.interval_min = ev->interval_min; in hci_le_remote_conn_param_req_evt()
6714 cp.interval_max = ev->interval_max; in hci_le_remote_conn_param_req_evt()
6715 cp.latency = ev->latency; in hci_le_remote_conn_param_req_evt()
6716 cp.timeout = ev->timeout; in hci_le_remote_conn_param_req_evt()
6731 flex_array_size(ev, info, ev->num))) in hci_le_direct_adv_report_evt()
6734 if (!ev->num) in hci_le_direct_adv_report_evt()
6739 for (i = 0; i < ev->num; i++) { in hci_le_direct_adv_report_evt()
6740 struct hci_ev_le_direct_adv_info *info = &ev->info[i]; in hci_le_direct_adv_report_evt()
6742 process_adv_report(hdev, info->type, &info->bdaddr, in hci_le_direct_adv_report_evt()
6743 info->bdaddr_type, &info->direct_addr, in hci_le_direct_adv_report_evt()
6744 info->direct_addr_type, info->rssi, NULL, 0, in hci_le_direct_adv_report_evt()
6757 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_phy_update_evt()
6759 if (ev->status) in hci_le_phy_update_evt()
6764 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_phy_update_evt()
6768 conn->le_tx_phy = ev->tx_phy; in hci_le_phy_update_evt()
6769 conn->le_rx_phy = ev->rx_phy; in hci_le_phy_update_evt()
6780 u16 handle = __le16_to_cpu(ev->handle); in hci_le_cis_estabilished_evt()
6782 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_cis_estabilished_evt()
6789 "Unable to find connection with handle 0x%4.4x", in hci_le_cis_estabilished_evt()
6794 if (conn->type != ISO_LINK) { in hci_le_cis_estabilished_evt()
6796 "Invalid connection link type handle 0x%4.4x", in hci_le_cis_estabilished_evt()
6801 if (conn->role == HCI_ROLE_SLAVE) { in hci_le_cis_estabilished_evt()
6806 memcpy(&interval, ev->c_latency, sizeof(ev->c_latency)); in hci_le_cis_estabilished_evt()
6807 conn->iso_qos.in.interval = le32_to_cpu(interval); in hci_le_cis_estabilished_evt()
6808 memcpy(&interval, ev->p_latency, sizeof(ev->p_latency)); in hci_le_cis_estabilished_evt()
6809 conn->iso_qos.out.interval = le32_to_cpu(interval); in hci_le_cis_estabilished_evt()
6810 conn->iso_qos.in.latency = le16_to_cpu(ev->interval); in hci_le_cis_estabilished_evt()
6811 conn->iso_qos.out.latency = le16_to_cpu(ev->interval); in hci_le_cis_estabilished_evt()
6812 conn->iso_qos.in.sdu = le16_to_cpu(ev->c_mtu); in hci_le_cis_estabilished_evt()
6813 conn->iso_qos.out.sdu = le16_to_cpu(ev->p_mtu); in hci_le_cis_estabilished_evt()
6814 conn->iso_qos.in.phy = ev->c_phy; in hci_le_cis_estabilished_evt()
6815 conn->iso_qos.out.phy = ev->p_phy; in hci_le_cis_estabilished_evt()
6818 if (!ev->status) { in hci_le_cis_estabilished_evt()
6819 conn->state = BT_CONNECTED; in hci_le_cis_estabilished_evt()
6826 hci_connect_cfm(conn, ev->status); in hci_le_cis_estabilished_evt()
6861 acl_handle = __le16_to_cpu(ev->acl_handle); in hci_le_cis_req_evt()
6862 cis_handle = __le16_to_cpu(ev->cis_handle); in hci_le_cis_req_evt()
6864 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()
6865 acl_handle, cis_handle, ev->cig_id, ev->cis_id); in hci_le_cis_req_evt()
6873 mask = hci_proto_connect_ind(hdev, &acl->dst, ISO_LINK, &flags); in hci_le_cis_req_evt()
6875 hci_le_reject_cis(hdev, ev->cis_handle); in hci_le_cis_req_evt()
6881 cis = hci_conn_add(hdev, ISO_LINK, &acl->dst, HCI_ROLE_SLAVE); in hci_le_cis_req_evt()
6883 hci_le_reject_cis(hdev, ev->cis_handle); in hci_le_cis_req_evt()
6886 cis->handle = cis_handle; in hci_le_cis_req_evt()
6889 cis->iso_qos.cig = ev->cig_id; in hci_le_cis_req_evt()
6890 cis->iso_qos.cis = ev->cis_id; in hci_le_cis_req_evt()
6893 hci_le_accept_cis(hdev, ev->cis_handle); in hci_le_cis_req_evt()
6895 cis->state = BT_CONNECT2; in hci_le_cis_req_evt()
6909 BT_DBG("%s status 0x%2.2x", hdev->name, ev->status); in hci_le_create_big_complete_evt()
6912 flex_array_size(ev, bis_handle, ev->num_bis))) in hci_le_create_big_complete_evt()
6917 conn = hci_conn_hash_lookup_big(hdev, ev->handle); in hci_le_create_big_complete_evt()
6921 if (conn->type != ISO_LINK) { in hci_le_create_big_complete_evt()
6923 "Invalid connection link type handle 0x%2.2x", in hci_le_create_big_complete_evt()
6924 ev->handle); in hci_le_create_big_complete_evt()
6928 if (ev->num_bis) in hci_le_create_big_complete_evt()
6929 conn->handle = __le16_to_cpu(ev->bis_handle[0]); in hci_le_create_big_complete_evt()
6931 if (!ev->status) { in hci_le_create_big_complete_evt()
6932 conn->state = BT_CONNECTED; in hci_le_create_big_complete_evt()
6939 hci_connect_cfm(conn, ev->status); in hci_le_create_big_complete_evt()
6953 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_big_sync_established_evt()
6956 flex_array_size(ev, bis, ev->num_bis))) in hci_le_big_sync_established_evt()
6959 if (ev->status) in hci_le_big_sync_established_evt()
6964 for (i = 0; i < ev->num_bis; i++) { in hci_le_big_sync_established_evt()
6965 u16 handle = le16_to_cpu(ev->bis[i]); in hci_le_big_sync_established_evt()
6974 bis->handle = handle; in hci_le_big_sync_established_evt()
6977 bis->iso_qos.big = ev->handle; in hci_le_big_sync_established_evt()
6979 memcpy(&interval, ev->latency, sizeof(ev->latency)); in hci_le_big_sync_established_evt()
6980 bis->iso_qos.in.interval = le32_to_cpu(interval); in hci_le_big_sync_established_evt()
6982 bis->iso_qos.in.latency = le16_to_cpu(ev->interval) * 125 / 100; in hci_le_big_sync_established_evt()
6983 bis->iso_qos.in.sdu = le16_to_cpu(ev->max_pdu); in hci_le_big_sync_established_evt()
6985 hci_connect_cfm(bis, ev->status); in hci_le_big_sync_established_evt()
6995 int mask = hdev->link_mode; in hci_le_big_info_adv_report_evt()
6998 bt_dev_dbg(hdev, "sync_handle 0x%4.4x", le16_to_cpu(ev->sync_handle)); in hci_le_big_info_adv_report_evt()
7004 hci_le_pa_term_sync(hdev, ev->sync_handle); in hci_le_big_info_adv_report_evt()
7107 bt_dev_dbg(hdev, "subevent 0x%2.2x", ev->subevent); in hci_le_meta_evt()
7110 if (hdev->sent_cmd && in hci_le_meta_evt()
7111 hci_opcode_ogf(hci_skb_opcode(hdev->sent_cmd)) == 0x08 && in hci_le_meta_evt()
7112 hci_skb_event(hdev->sent_cmd) == ev->subevent) { in hci_le_meta_evt()
7113 *opcode = hci_skb_opcode(hdev->sent_cmd); in hci_le_meta_evt()
7118 subev = &hci_le_ev_table[ev->subevent]; in hci_le_meta_evt()
7119 if (!subev->func) in hci_le_meta_evt()
7122 if (skb->len < subev->min_len) { in hci_le_meta_evt()
7123 bt_dev_err(hdev, "unexpected subevent 0x%2.2x length: %u < %u", in hci_le_meta_evt()
7124 ev->subevent, skb->len, subev->min_len); in hci_le_meta_evt()
7132 if (skb->len > subev->max_len) in hci_le_meta_evt()
7133 bt_dev_warn(hdev, "unexpected subevent 0x%2.2x length: %u > %u", in hci_le_meta_evt()
7134 ev->subevent, skb->len, subev->max_len); in hci_le_meta_evt()
7135 data = hci_le_ev_skb_pull(hdev, skb, ev->subevent, subev->min_len); in hci_le_meta_evt()
7139 subev->func(hdev, data, skb); in hci_le_meta_evt()
7156 if (hdr->evt != event) in hci_get_cmd_complete()
7161 /* Check if request ended in Command Status - no way to retrieve in hci_get_cmd_complete()
7164 if (hdr->evt == HCI_EV_CMD_STATUS) in hci_get_cmd_complete()
7167 if (hdr->evt != HCI_EV_CMD_COMPLETE) { in hci_get_cmd_complete()
7168 bt_dev_err(hdev, "last event is not cmd complete (0x%2.2x)", in hci_get_cmd_complete()
7169 hdr->evt); in hci_get_cmd_complete()
7177 if (opcode != __le16_to_cpu(ev->opcode)) { in hci_get_cmd_complete()
7178 BT_DBG("opcode doesn't match (0x%2.2x != 0x%2.2x)", opcode, in hci_get_cmd_complete()
7179 __le16_to_cpu(ev->opcode)); in hci_get_cmd_complete()
7192 const struct hci_ev_conn_complete *conn_complete = (void *)skb->data; in hci_store_wake_reason()
7193 const struct hci_ev_conn_request *conn_request = (void *)skb->data; in hci_store_wake_reason()
7200 if (!hdev->suspended || hdev->wake_reason) in hci_store_wake_reason()
7206 hdev->wake_reason = MGMT_WAKE_REASON_REMOTE_WAKE; in hci_store_wake_reason()
7213 bacpy(&hdev->wake_addr, &conn_complete->bdaddr); in hci_store_wake_reason()
7214 hdev->wake_addr_type = BDADDR_BREDR; in hci_store_wake_reason()
7216 bacpy(&hdev->wake_addr, &conn_request->bdaddr); in hci_store_wake_reason()
7217 hdev->wake_addr_type = BDADDR_BREDR; in hci_store_wake_reason()
7219 struct hci_ev_le_meta *le_ev = (void *)skb->data; in hci_store_wake_reason()
7220 u8 subevent = le_ev->subevent; in hci_store_wake_reason()
7221 u8 *ptr = &skb->data[sizeof(*le_ev)]; in hci_store_wake_reason()
7234 bacpy(&hdev->wake_addr, &adv->bdaddr); in hci_store_wake_reason()
7235 hdev->wake_addr_type = adv->bdaddr_type; in hci_store_wake_reason()
7238 bacpy(&hdev->wake_addr, &direct_adv->bdaddr); in hci_store_wake_reason()
7239 hdev->wake_addr_type = direct_adv->bdaddr_type; in hci_store_wake_reason()
7242 bacpy(&hdev->wake_addr, &ext_adv->bdaddr); in hci_store_wake_reason()
7243 hdev->wake_addr_type = ext_adv->bdaddr_type; in hci_store_wake_reason()
7248 hdev->wake_reason = MGMT_WAKE_REASON_UNEXPECTED; in hci_store_wake_reason()
7446 if (!ev->func) in hci_event_func()
7449 if (skb->len < ev->min_len) { in hci_event_func()
7450 bt_dev_err(hdev, "unexpected event 0x%2.2x length: %u < %u", in hci_event_func()
7451 event, skb->len, ev->min_len); in hci_event_func()
7459 if (skb->len > ev->max_len) in hci_event_func()
7461 "unexpected event 0x%2.2x length: %u > %u", in hci_event_func()
7462 event, skb->len, ev->max_len); in hci_event_func()
7464 data = hci_ev_skb_pull(hdev, skb, event, ev->min_len); in hci_event_func()
7468 if (ev->req) in hci_event_func()
7469 ev->func_req(hdev, data, skb, opcode, status, req_complete, in hci_event_func()
7472 ev->func(hdev, data, skb); in hci_event_func()
7477 struct hci_event_hdr *hdr = (void *) skb->data; in hci_event_packet()
7484 if (skb->len < sizeof(*hdr)) { in hci_event_packet()
7489 kfree_skb(hdev->recv_event); in hci_event_packet()
7490 hdev->recv_event = skb_clone(skb, GFP_KERNEL); in hci_event_packet()
7492 event = hdr->evt; in hci_event_packet()
7494 bt_dev_warn(hdev, "Received unexpected HCI Event 0x%2.2x", in hci_event_packet()
7500 if (hdev->sent_cmd && in hci_event_packet()
7501 hci_opcode_ogf(hci_skb_opcode(hdev->sent_cmd)) != 0x08 && in hci_event_packet()
7502 hci_skb_event(hdev->sent_cmd) == event) { in hci_event_packet()
7503 hci_req_cmd_complete(hdev, hci_skb_opcode(hdev->sent_cmd), in hci_event_packet()
7522 bt_dev_dbg(hdev, "event 0x%2.2x", event); in hci_event_packet()
7540 hdev->stat.evt_rx++; in hci_event_packet()