Lines Matching refs:hdev
48 static void *hci_ev_skb_pull(struct hci_dev *hdev, struct sk_buff *skb, in hci_ev_skb_pull() argument
55 bt_dev_err(hdev, "Malformed Event: 0x%2.2x", ev); in hci_ev_skb_pull()
60 static void *hci_cc_skb_pull(struct hci_dev *hdev, struct sk_buff *skb, in hci_cc_skb_pull() argument
67 bt_dev_err(hdev, "Malformed Command Complete: 0x%4.4x", op); in hci_cc_skb_pull()
72 static void *hci_le_ev_skb_pull(struct hci_dev *hdev, struct sk_buff *skb, in hci_le_ev_skb_pull() argument
79 bt_dev_err(hdev, "Malformed LE Event: 0x%2.2x", ev); in hci_le_ev_skb_pull()
84 static u8 hci_cc_inquiry_cancel(struct hci_dev *hdev, void *data, in hci_cc_inquiry_cancel() argument
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()
99 bt_dev_warn(hdev, "Ignoring error of Inquiry Cancel command"); 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()
110 hci_dev_lock(hdev); in hci_cc_inquiry_cancel()
114 if (!hci_dev_test_flag(hdev, HCI_LE_SCAN) || in hci_cc_inquiry_cancel()
115 hdev->le_scan_type != LE_SCAN_ACTIVE) in hci_cc_inquiry_cancel()
116 hci_discovery_set_state(hdev, DISCOVERY_STOPPED); in hci_cc_inquiry_cancel()
117 hci_dev_unlock(hdev); in hci_cc_inquiry_cancel()
119 hci_conn_check_pending(hdev); in hci_cc_inquiry_cancel()
124 static u8 hci_cc_periodic_inq(struct hci_dev *hdev, void *data, in hci_cc_periodic_inq() argument
129 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_periodic_inq()
134 hci_dev_set_flag(hdev, HCI_PERIODIC_INQ); in hci_cc_periodic_inq()
139 static u8 hci_cc_exit_periodic_inq(struct hci_dev *hdev, void *data, in hci_cc_exit_periodic_inq() argument
144 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_exit_periodic_inq()
149 hci_dev_clear_flag(hdev, HCI_PERIODIC_INQ); in hci_cc_exit_periodic_inq()
151 hci_conn_check_pending(hdev); in hci_cc_exit_periodic_inq()
156 static u8 hci_cc_remote_name_req_cancel(struct hci_dev *hdev, void *data, in hci_cc_remote_name_req_cancel() argument
161 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_remote_name_req_cancel()
166 static u8 hci_cc_role_discovery(struct hci_dev *hdev, void *data, in hci_cc_role_discovery() argument
172 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_role_discovery()
177 hci_dev_lock(hdev); in hci_cc_role_discovery()
179 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_role_discovery()
183 hci_dev_unlock(hdev); in hci_cc_role_discovery()
188 static u8 hci_cc_read_link_policy(struct hci_dev *hdev, void *data, in hci_cc_read_link_policy() argument
194 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_link_policy()
199 hci_dev_lock(hdev); 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()
205 hci_dev_unlock(hdev); in hci_cc_read_link_policy()
210 static u8 hci_cc_write_link_policy(struct hci_dev *hdev, void *data, in hci_cc_write_link_policy() argument
217 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_link_policy()
222 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_LINK_POLICY); in hci_cc_write_link_policy()
226 hci_dev_lock(hdev); 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()
232 hci_dev_unlock(hdev); in hci_cc_write_link_policy()
237 static u8 hci_cc_read_def_link_policy(struct hci_dev *hdev, void *data, in hci_cc_read_def_link_policy() argument
242 bt_dev_dbg(hdev, "status 0x%2.2x", 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()
252 static u8 hci_cc_write_def_link_policy(struct hci_dev *hdev, void *data, in hci_cc_write_def_link_policy() argument
258 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_def_link_policy()
263 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_DEF_LINK_POLICY); in hci_cc_write_def_link_policy()
267 hdev->link_policy = get_unaligned_le16(sent); in hci_cc_write_def_link_policy()
272 static u8 hci_cc_reset(struct hci_dev *hdev, void *data, struct sk_buff *skb) in hci_cc_reset() argument
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()
284 hci_dev_clear_volatile_flags(hdev); in hci_cc_reset()
286 hci_discovery_set_state(hdev, DISCOVERY_STOPPED); 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()
307 static u8 hci_cc_read_stored_link_key(struct hci_dev *hdev, void *data, in hci_cc_read_stored_link_key() argument
313 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_stored_link_key()
315 sent = hci_sent_cmd_data(hdev, HCI_OP_READ_STORED_LINK_KEY); 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()
327 static u8 hci_cc_delete_stored_link_key(struct hci_dev *hdev, void *data, in hci_cc_delete_stored_link_key() argument
333 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); 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()
348 static u8 hci_cc_write_local_name(struct hci_dev *hdev, void *data, in hci_cc_write_local_name() argument
354 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_local_name()
356 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_LOCAL_NAME); in hci_cc_write_local_name()
360 hci_dev_lock(hdev); in hci_cc_write_local_name()
362 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_cc_write_local_name()
363 mgmt_set_local_name_complete(hdev, sent, rp->status); in hci_cc_write_local_name()
365 memcpy(hdev->dev_name, sent, HCI_MAX_NAME_LENGTH); in hci_cc_write_local_name()
367 hci_dev_unlock(hdev); in hci_cc_write_local_name()
372 static u8 hci_cc_read_local_name(struct hci_dev *hdev, void *data, in hci_cc_read_local_name() argument
377 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_name()
382 if (hci_dev_test_flag(hdev, HCI_SETUP) || in hci_cc_read_local_name()
383 hci_dev_test_flag(hdev, HCI_CONFIG)) in hci_cc_read_local_name()
384 memcpy(hdev->dev_name, rp->name, HCI_MAX_NAME_LENGTH); in hci_cc_read_local_name()
389 static u8 hci_cc_write_auth_enable(struct hci_dev *hdev, void *data, in hci_cc_write_auth_enable() argument
395 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_auth_enable()
397 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_AUTH_ENABLE); in hci_cc_write_auth_enable()
401 hci_dev_lock(hdev); 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()
412 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_cc_write_auth_enable()
413 mgmt_auth_enable_complete(hdev, rp->status); in hci_cc_write_auth_enable()
415 hci_dev_unlock(hdev); in hci_cc_write_auth_enable()
420 static u8 hci_cc_write_encrypt_mode(struct hci_dev *hdev, void *data, in hci_cc_write_encrypt_mode() argument
427 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_encrypt_mode()
432 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_ENCRYPT_MODE); 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()
446 static u8 hci_cc_write_scan_enable(struct hci_dev *hdev, void *data, in hci_cc_write_scan_enable() argument
453 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_scan_enable()
455 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_SCAN_ENABLE); in hci_cc_write_scan_enable()
461 hci_dev_lock(hdev); 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()
479 hci_dev_unlock(hdev); in hci_cc_write_scan_enable()
484 static u8 hci_cc_set_event_filter(struct hci_dev *hdev, void *data, in hci_cc_set_event_filter() argument
491 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_set_event_filter()
496 sent = hci_sent_cmd_data(hdev, HCI_OP_SET_EVENT_FLT); in hci_cc_set_event_filter()
503 hci_dev_clear_flag(hdev, HCI_EVENT_FILTER_CONFIGURED); in hci_cc_set_event_filter()
505 hci_dev_set_flag(hdev, HCI_EVENT_FILTER_CONFIGURED); in hci_cc_set_event_filter()
510 static u8 hci_cc_read_class_of_dev(struct hci_dev *hdev, void *data, in hci_cc_read_class_of_dev() argument
515 bt_dev_dbg(hdev, "status 0x%2.2x", 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()
528 static u8 hci_cc_write_class_of_dev(struct hci_dev *hdev, void *data, in hci_cc_write_class_of_dev() argument
534 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_class_of_dev()
536 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_CLASS_OF_DEV); in hci_cc_write_class_of_dev()
540 hci_dev_lock(hdev); in hci_cc_write_class_of_dev()
543 memcpy(hdev->dev_class, sent, 3); in hci_cc_write_class_of_dev()
545 if (hci_dev_test_flag(hdev, HCI_MGMT)) 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()
548 hci_dev_unlock(hdev); in hci_cc_write_class_of_dev()
553 static u8 hci_cc_read_voice_setting(struct hci_dev *hdev, void *data, in hci_cc_read_voice_setting() argument
559 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_voice_setting()
566 if (hdev->voice_setting == setting) 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()
579 static u8 hci_cc_write_voice_setting(struct hci_dev *hdev, void *data, in hci_cc_write_voice_setting() argument
586 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_voice_setting()
591 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_VOICE_SETTING); in hci_cc_write_voice_setting()
597 if (hdev->voice_setting == setting) 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()
610 static u8 hci_cc_read_num_supported_iac(struct hci_dev *hdev, void *data, in hci_cc_read_num_supported_iac() argument
615 bt_dev_dbg(hdev, "status 0x%2.2x", 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()
627 static u8 hci_cc_write_ssp_mode(struct hci_dev *hdev, void *data, in hci_cc_write_ssp_mode() argument
633 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_ssp_mode()
635 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_SSP_MODE); in hci_cc_write_ssp_mode()
639 hci_dev_lock(hdev); 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()
650 hci_dev_set_flag(hdev, HCI_SSP_ENABLED); in hci_cc_write_ssp_mode()
652 hci_dev_clear_flag(hdev, HCI_SSP_ENABLED); in hci_cc_write_ssp_mode()
655 hci_dev_unlock(hdev); in hci_cc_write_ssp_mode()
660 static u8 hci_cc_write_sc_support(struct hci_dev *hdev, void *data, in hci_cc_write_sc_support() argument
666 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_sc_support()
668 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_SC_SUPPORT); in hci_cc_write_sc_support()
672 hci_dev_lock(hdev); 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()
683 hci_dev_set_flag(hdev, HCI_SC_ENABLED); in hci_cc_write_sc_support()
685 hci_dev_clear_flag(hdev, HCI_SC_ENABLED); in hci_cc_write_sc_support()
688 hci_dev_unlock(hdev); in hci_cc_write_sc_support()
693 static u8 hci_cc_read_local_version(struct hci_dev *hdev, void *data, in hci_cc_read_local_version() argument
698 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_version()
703 if (hci_dev_test_flag(hdev, HCI_SETUP) || in hci_cc_read_local_version()
704 hci_dev_test_flag(hdev, HCI_CONFIG)) { 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()
715 static u8 hci_cc_read_enc_key_size(struct hci_dev *hdev, void *data, in hci_cc_read_enc_key_size() argument
723 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cc_read_enc_key_size()
727 hci_dev_lock(hdev); in hci_cc_read_enc_key_size()
729 conn = hci_conn_hash_lookup_handle(hdev, handle); in hci_cc_read_enc_key_size()
740 bt_dev_err(hdev, "failed to read key size for handle %u", in hci_cc_read_enc_key_size()
751 hci_dev_unlock(hdev); in hci_cc_read_enc_key_size()
756 static u8 hci_cc_read_local_commands(struct hci_dev *hdev, void *data, in hci_cc_read_local_commands() argument
761 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_commands()
766 if (hci_dev_test_flag(hdev, HCI_SETUP) || in hci_cc_read_local_commands()
767 hci_dev_test_flag(hdev, HCI_CONFIG)) in hci_cc_read_local_commands()
768 memcpy(hdev->commands, rp->commands, sizeof(hdev->commands)); in hci_cc_read_local_commands()
773 static u8 hci_cc_read_auth_payload_timeout(struct hci_dev *hdev, void *data, in hci_cc_read_auth_payload_timeout() argument
779 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_auth_payload_timeout()
784 hci_dev_lock(hdev); 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()
790 hci_dev_unlock(hdev); in hci_cc_read_auth_payload_timeout()
795 static u8 hci_cc_write_auth_payload_timeout(struct hci_dev *hdev, void *data, in hci_cc_write_auth_payload_timeout() argument
802 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_auth_payload_timeout()
807 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_AUTH_PAYLOAD_TO); in hci_cc_write_auth_payload_timeout()
811 hci_dev_lock(hdev); 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()
817 hci_dev_unlock(hdev); in hci_cc_write_auth_payload_timeout()
822 static u8 hci_cc_read_local_features(struct hci_dev *hdev, void *data, in hci_cc_read_local_features() argument
827 bt_dev_dbg(hdev, "status 0x%2.2x", 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()
853 if (lmp_esco_capable(hdev)) 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()
874 static u8 hci_cc_read_local_ext_features(struct hci_dev *hdev, void *data, in hci_cc_read_local_ext_features() argument
879 bt_dev_dbg(hdev, "status 0x%2.2x", 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()
888 memcpy(hdev->features[rp->page], rp->features, 8); in hci_cc_read_local_ext_features()
893 static u8 hci_cc_read_flow_control_mode(struct hci_dev *hdev, void *data, in hci_cc_read_flow_control_mode() argument
898 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_flow_control_mode()
903 hdev->flow_ctl_mode = rp->mode; in hci_cc_read_flow_control_mode()
908 static u8 hci_cc_read_buffer_size(struct hci_dev *hdev, void *data, in hci_cc_read_buffer_size() argument
913 bt_dev_dbg(hdev, "status 0x%2.2x", 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()
937 static u8 hci_cc_read_bd_addr(struct hci_dev *hdev, void *data, in hci_cc_read_bd_addr() argument
942 bt_dev_dbg(hdev, "status 0x%2.2x", 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()
950 if (hci_dev_test_flag(hdev, HCI_SETUP)) in hci_cc_read_bd_addr()
951 bacpy(&hdev->setup_addr, &rp->bdaddr); in hci_cc_read_bd_addr()
956 static u8 hci_cc_read_local_pairing_opts(struct hci_dev *hdev, void *data, in hci_cc_read_local_pairing_opts() argument
961 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_pairing_opts()
966 if (hci_dev_test_flag(hdev, HCI_SETUP) || in hci_cc_read_local_pairing_opts()
967 hci_dev_test_flag(hdev, HCI_CONFIG)) { 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()
975 static u8 hci_cc_read_page_scan_activity(struct hci_dev *hdev, void *data, in hci_cc_read_page_scan_activity() argument
980 bt_dev_dbg(hdev, "status 0x%2.2x", 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()
993 static u8 hci_cc_write_page_scan_activity(struct hci_dev *hdev, void *data, in hci_cc_write_page_scan_activity() argument
999 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_page_scan_activity()
1004 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_PAGE_SCAN_ACTIVITY); 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()
1014 static u8 hci_cc_read_page_scan_type(struct hci_dev *hdev, void *data, in hci_cc_read_page_scan_type() argument
1019 bt_dev_dbg(hdev, "status 0x%2.2x", 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()
1030 static u8 hci_cc_write_page_scan_type(struct hci_dev *hdev, void *data, in hci_cc_write_page_scan_type() argument
1036 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_page_scan_type()
1041 type = hci_sent_cmd_data(hdev, HCI_OP_WRITE_PAGE_SCAN_TYPE); in hci_cc_write_page_scan_type()
1043 hdev->page_scan_type = *type; in hci_cc_write_page_scan_type()
1048 static u8 hci_cc_read_data_block_size(struct hci_dev *hdev, void *data, in hci_cc_read_data_block_size() argument
1053 bt_dev_dbg(hdev, "status 0x%2.2x", 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()
1070 static u8 hci_cc_read_clock(struct hci_dev *hdev, void *data, in hci_cc_read_clock() argument
1077 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_clock()
1082 hci_dev_lock(hdev); in hci_cc_read_clock()
1084 cp = hci_sent_cmd_data(hdev, HCI_OP_READ_CLOCK); 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()
1100 hci_dev_unlock(hdev); in hci_cc_read_clock()
1104 static u8 hci_cc_read_local_amp_info(struct hci_dev *hdev, void *data, in hci_cc_read_local_amp_info() argument
1109 bt_dev_dbg(hdev, "status 0x%2.2x", 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()
1128 static u8 hci_cc_read_inq_rsp_tx_power(struct hci_dev *hdev, void *data, in hci_cc_read_inq_rsp_tx_power() argument
1133 bt_dev_dbg(hdev, "status 0x%2.2x", 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()
1143 static u8 hci_cc_read_def_err_data_reporting(struct hci_dev *hdev, void *data, in hci_cc_read_def_err_data_reporting() argument
1148 bt_dev_dbg(hdev, "status 0x%2.2x", 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()
1158 static u8 hci_cc_write_def_err_data_reporting(struct hci_dev *hdev, void *data, in hci_cc_write_def_err_data_reporting() argument
1164 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_def_err_data_reporting()
1169 cp = hci_sent_cmd_data(hdev, HCI_OP_WRITE_DEF_ERR_DATA_REPORTING); 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()
1178 static u8 hci_cc_pin_code_reply(struct hci_dev *hdev, void *data, in hci_cc_pin_code_reply() argument
1185 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_pin_code_reply()
1187 hci_dev_lock(hdev); in hci_cc_pin_code_reply()
1189 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_cc_pin_code_reply()
1190 mgmt_pin_code_reply_complete(hdev, &rp->bdaddr, rp->status); in hci_cc_pin_code_reply()
1195 cp = hci_sent_cmd_data(hdev, HCI_OP_PIN_CODE_REPLY); in hci_cc_pin_code_reply()
1199 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cc_pin_code_reply()
1204 hci_dev_unlock(hdev); in hci_cc_pin_code_reply()
1208 static u8 hci_cc_pin_code_neg_reply(struct hci_dev *hdev, void *data, in hci_cc_pin_code_neg_reply() argument
1213 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_pin_code_neg_reply()
1215 hci_dev_lock(hdev); in hci_cc_pin_code_neg_reply()
1217 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_cc_pin_code_neg_reply()
1218 mgmt_pin_code_neg_reply_complete(hdev, &rp->bdaddr, in hci_cc_pin_code_neg_reply()
1221 hci_dev_unlock(hdev); in hci_cc_pin_code_neg_reply()
1226 static u8 hci_cc_le_read_buffer_size(struct hci_dev *hdev, void *data, in hci_cc_le_read_buffer_size() argument
1231 bt_dev_dbg(hdev, "status 0x%2.2x", 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()
1246 static u8 hci_cc_le_read_local_features(struct hci_dev *hdev, void *data, in hci_cc_le_read_local_features() argument
1251 BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); in hci_cc_le_read_local_features()
1256 memcpy(hdev->le_features, rp->features, 8); in hci_cc_le_read_local_features()
1261 static u8 hci_cc_le_read_adv_tx_power(struct hci_dev *hdev, void *data, in hci_cc_le_read_adv_tx_power() argument
1266 bt_dev_dbg(hdev, "status 0x%2.2x", 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()
1276 static u8 hci_cc_user_confirm_reply(struct hci_dev *hdev, void *data, in hci_cc_user_confirm_reply() argument
1281 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_user_confirm_reply()
1283 hci_dev_lock(hdev); in hci_cc_user_confirm_reply()
1285 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_cc_user_confirm_reply()
1286 mgmt_user_confirm_reply_complete(hdev, &rp->bdaddr, ACL_LINK, 0, in hci_cc_user_confirm_reply()
1289 hci_dev_unlock(hdev); in hci_cc_user_confirm_reply()
1294 static u8 hci_cc_user_confirm_neg_reply(struct hci_dev *hdev, void *data, in hci_cc_user_confirm_neg_reply() argument
1299 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_user_confirm_neg_reply()
1301 hci_dev_lock(hdev); in hci_cc_user_confirm_neg_reply()
1303 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_cc_user_confirm_neg_reply()
1304 mgmt_user_confirm_neg_reply_complete(hdev, &rp->bdaddr, in hci_cc_user_confirm_neg_reply()
1307 hci_dev_unlock(hdev); in hci_cc_user_confirm_neg_reply()
1312 static u8 hci_cc_user_passkey_reply(struct hci_dev *hdev, void *data, in hci_cc_user_passkey_reply() argument
1317 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_user_passkey_reply()
1319 hci_dev_lock(hdev); in hci_cc_user_passkey_reply()
1321 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_cc_user_passkey_reply()
1322 mgmt_user_passkey_reply_complete(hdev, &rp->bdaddr, ACL_LINK, in hci_cc_user_passkey_reply()
1325 hci_dev_unlock(hdev); in hci_cc_user_passkey_reply()
1330 static u8 hci_cc_user_passkey_neg_reply(struct hci_dev *hdev, void *data, in hci_cc_user_passkey_neg_reply() argument
1335 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_user_passkey_neg_reply()
1337 hci_dev_lock(hdev); in hci_cc_user_passkey_neg_reply()
1339 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_cc_user_passkey_neg_reply()
1340 mgmt_user_passkey_neg_reply_complete(hdev, &rp->bdaddr, in hci_cc_user_passkey_neg_reply()
1343 hci_dev_unlock(hdev); in hci_cc_user_passkey_neg_reply()
1348 static u8 hci_cc_read_local_oob_data(struct hci_dev *hdev, void *data, in hci_cc_read_local_oob_data() argument
1353 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_oob_data()
1358 static u8 hci_cc_read_local_oob_ext_data(struct hci_dev *hdev, void *data, in hci_cc_read_local_oob_ext_data() argument
1363 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_oob_ext_data()
1368 static u8 hci_cc_le_set_random_addr(struct hci_dev *hdev, void *data, in hci_cc_le_set_random_addr() argument
1374 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_random_addr()
1379 sent = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_RANDOM_ADDR); in hci_cc_le_set_random_addr()
1383 hci_dev_lock(hdev); 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()
1388 hci_dev_clear_flag(hdev, HCI_RPA_EXPIRED); 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()
1393 hci_dev_unlock(hdev); in hci_cc_le_set_random_addr()
1398 static u8 hci_cc_le_set_default_phy(struct hci_dev *hdev, void *data, in hci_cc_le_set_default_phy() argument
1404 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_default_phy()
1409 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_DEFAULT_PHY); in hci_cc_le_set_default_phy()
1413 hci_dev_lock(hdev); 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()
1418 hci_dev_unlock(hdev); in hci_cc_le_set_default_phy()
1423 static u8 hci_cc_le_set_adv_set_random_addr(struct hci_dev *hdev, void *data, in hci_cc_le_set_adv_set_random_addr() argument
1430 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_adv_set_random_addr()
1435 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_ADV_SET_RAND_ADDR); in hci_cc_le_set_adv_set_random_addr()
1443 hci_dev_lock(hdev); 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()
1448 if (!bacmp(&hdev->rpa, &cp->bdaddr)) { in hci_cc_le_set_adv_set_random_addr()
1450 queue_delayed_work(hdev->workqueue, 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()
1456 hci_dev_unlock(hdev); in hci_cc_le_set_adv_set_random_addr()
1461 static u8 hci_cc_le_remove_adv_set(struct hci_dev *hdev, void *data, in hci_cc_le_remove_adv_set() argument
1468 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_remove_adv_set()
1473 instance = hci_sent_cmd_data(hdev, HCI_OP_LE_REMOVE_ADV_SET); in hci_cc_le_remove_adv_set()
1477 hci_dev_lock(hdev); in hci_cc_le_remove_adv_set()
1479 err = hci_remove_adv_instance(hdev, *instance); 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()
1484 hci_dev_unlock(hdev); in hci_cc_le_remove_adv_set()
1489 static u8 hci_cc_le_clear_adv_sets(struct hci_dev *hdev, void *data, in hci_cc_le_clear_adv_sets() argument
1496 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_clear_adv_sets()
1501 if (!hci_sent_cmd_data(hdev, HCI_OP_LE_CLEAR_ADV_SETS)) in hci_cc_le_clear_adv_sets()
1504 hci_dev_lock(hdev); 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()
1509 err = hci_remove_adv_instance(hdev, 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()
1512 hdev, instance); in hci_cc_le_clear_adv_sets()
1515 hci_dev_unlock(hdev); in hci_cc_le_clear_adv_sets()
1520 static u8 hci_cc_le_read_transmit_power(struct hci_dev *hdev, void *data, in hci_cc_le_read_transmit_power() argument
1525 bt_dev_dbg(hdev, "status 0x%2.2x", 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()
1536 static u8 hci_cc_le_set_privacy_mode(struct hci_dev *hdev, void *data, in hci_cc_le_set_privacy_mode() argument
1543 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_privacy_mode()
1548 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_PRIVACY_MODE); in hci_cc_le_set_privacy_mode()
1552 hci_dev_lock(hdev); 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()
1558 hci_dev_unlock(hdev); in hci_cc_le_set_privacy_mode()
1563 static u8 hci_cc_le_set_adv_enable(struct hci_dev *hdev, void *data, in hci_cc_le_set_adv_enable() argument
1569 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_adv_enable()
1574 sent = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_ADV_ENABLE); in hci_cc_le_set_adv_enable()
1578 hci_dev_lock(hdev); in hci_cc_le_set_adv_enable()
1586 hci_dev_set_flag(hdev, HCI_LE_ADV); in hci_cc_le_set_adv_enable()
1588 conn = hci_lookup_le_connect(hdev); in hci_cc_le_set_adv_enable()
1590 queue_delayed_work(hdev->workqueue, in hci_cc_le_set_adv_enable()
1594 hci_dev_clear_flag(hdev, HCI_LE_ADV); in hci_cc_le_set_adv_enable()
1597 hci_dev_unlock(hdev); in hci_cc_le_set_adv_enable()
1602 static u8 hci_cc_le_set_ext_adv_enable(struct hci_dev *hdev, void *data, in hci_cc_le_set_ext_adv_enable() argument
1610 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_ext_adv_enable()
1615 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_EXT_ADV_ENABLE); in hci_cc_le_set_ext_adv_enable()
1621 hci_dev_lock(hdev); 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()
1629 hci_dev_set_flag(hdev, HCI_LE_ADV); in hci_cc_le_set_ext_adv_enable()
1634 conn = hci_lookup_le_connect(hdev); in hci_cc_le_set_ext_adv_enable()
1636 queue_delayed_work(hdev->workqueue, 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()
1654 list_for_each_entry_safe(adv, n, &hdev->adv_instances, in hci_cc_le_set_ext_adv_enable()
1659 hci_dev_clear_flag(hdev, HCI_LE_ADV); in hci_cc_le_set_ext_adv_enable()
1663 hci_dev_unlock(hdev); in hci_cc_le_set_ext_adv_enable()
1667 static u8 hci_cc_le_set_scan_param(struct hci_dev *hdev, void *data, in hci_cc_le_set_scan_param() argument
1673 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_scan_param()
1678 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_SCAN_PARAM); in hci_cc_le_set_scan_param()
1682 hci_dev_lock(hdev); in hci_cc_le_set_scan_param()
1684 hdev->le_scan_type = cp->type; in hci_cc_le_set_scan_param()
1686 hci_dev_unlock(hdev); in hci_cc_le_set_scan_param()
1691 static u8 hci_cc_le_set_ext_scan_param(struct hci_dev *hdev, void *data, in hci_cc_le_set_ext_scan_param() argument
1698 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_ext_scan_param()
1703 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_EXT_SCAN_PARAMS); in hci_cc_le_set_ext_scan_param()
1709 hci_dev_lock(hdev); in hci_cc_le_set_ext_scan_param()
1711 hdev->le_scan_type = phy_param->type; in hci_cc_le_set_ext_scan_param()
1713 hci_dev_unlock(hdev); in hci_cc_le_set_ext_scan_param()
1718 static bool has_pending_adv_report(struct hci_dev *hdev) in has_pending_adv_report() argument
1720 struct discovery_state *d = &hdev->discovery; in has_pending_adv_report()
1725 static void clear_pending_adv_report(struct hci_dev *hdev) in clear_pending_adv_report() argument
1727 struct discovery_state *d = &hdev->discovery; in clear_pending_adv_report()
1733 static void store_pending_adv_report(struct hci_dev *hdev, bdaddr_t *bdaddr, in store_pending_adv_report() argument
1737 struct discovery_state *d = &hdev->discovery; in store_pending_adv_report()
1750 static void le_set_scan_enable_complete(struct hci_dev *hdev, u8 enable) in le_set_scan_enable_complete() argument
1752 hci_dev_lock(hdev); in le_set_scan_enable_complete()
1756 hci_dev_set_flag(hdev, HCI_LE_SCAN); in le_set_scan_enable_complete()
1757 if (hdev->le_scan_type == LE_SCAN_ACTIVE) in le_set_scan_enable_complete()
1758 clear_pending_adv_report(hdev); in le_set_scan_enable_complete()
1759 if (hci_dev_test_flag(hdev, HCI_MESH)) in le_set_scan_enable_complete()
1760 hci_discovery_set_state(hdev, DISCOVERY_FINDING); in le_set_scan_enable_complete()
1768 if (has_pending_adv_report(hdev)) { 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()
1781 cancel_delayed_work(&hdev->le_scan_disable); in le_set_scan_enable_complete()
1783 hci_dev_clear_flag(hdev, HCI_LE_SCAN); in le_set_scan_enable_complete()
1789 if (hci_dev_test_and_clear_flag(hdev, HCI_LE_SCAN_INTERRUPTED)) in le_set_scan_enable_complete()
1790 hci_discovery_set_state(hdev, DISCOVERY_STOPPED); in le_set_scan_enable_complete()
1791 else if (!hci_dev_test_flag(hdev, HCI_LE_ADV) && 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()
1798 bt_dev_err(hdev, "use of reserved LE_Scan_Enable param %d", in le_set_scan_enable_complete()
1803 hci_dev_unlock(hdev); in le_set_scan_enable_complete()
1806 static u8 hci_cc_le_set_scan_enable(struct hci_dev *hdev, void *data, in hci_cc_le_set_scan_enable() argument
1812 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_scan_enable()
1817 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_SCAN_ENABLE); in hci_cc_le_set_scan_enable()
1821 le_set_scan_enable_complete(hdev, cp->enable); in hci_cc_le_set_scan_enable()
1826 static u8 hci_cc_le_set_ext_scan_enable(struct hci_dev *hdev, void *data, in hci_cc_le_set_ext_scan_enable() argument
1832 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_ext_scan_enable()
1837 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_EXT_SCAN_ENABLE); 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()
1846 static u8 hci_cc_le_read_num_adv_sets(struct hci_dev *hdev, void *data, in hci_cc_le_read_num_adv_sets() argument
1851 bt_dev_dbg(hdev, "status 0x%2.2x No of Adv sets %u", 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()
1862 static u8 hci_cc_le_read_accept_list_size(struct hci_dev *hdev, void *data, in hci_cc_le_read_accept_list_size() argument
1867 bt_dev_dbg(hdev, "status 0x%2.2x size %u", rp->status, rp->size); in hci_cc_le_read_accept_list_size()
1872 hdev->le_accept_list_size = rp->size; in hci_cc_le_read_accept_list_size()
1877 static u8 hci_cc_le_clear_accept_list(struct hci_dev *hdev, void *data, in hci_cc_le_clear_accept_list() argument
1882 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_clear_accept_list()
1887 hci_dev_lock(hdev); in hci_cc_le_clear_accept_list()
1888 hci_bdaddr_list_clear(&hdev->le_accept_list); in hci_cc_le_clear_accept_list()
1889 hci_dev_unlock(hdev); in hci_cc_le_clear_accept_list()
1894 static u8 hci_cc_le_add_to_accept_list(struct hci_dev *hdev, void *data, in hci_cc_le_add_to_accept_list() argument
1900 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_add_to_accept_list()
1905 sent = hci_sent_cmd_data(hdev, HCI_OP_LE_ADD_TO_ACCEPT_LIST); in hci_cc_le_add_to_accept_list()
1909 hci_dev_lock(hdev); 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()
1912 hci_dev_unlock(hdev); in hci_cc_le_add_to_accept_list()
1917 static u8 hci_cc_le_del_from_accept_list(struct hci_dev *hdev, void *data, in hci_cc_le_del_from_accept_list() argument
1923 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_del_from_accept_list()
1928 sent = hci_sent_cmd_data(hdev, HCI_OP_LE_DEL_FROM_ACCEPT_LIST); in hci_cc_le_del_from_accept_list()
1932 hci_dev_lock(hdev); 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()
1935 hci_dev_unlock(hdev); in hci_cc_le_del_from_accept_list()
1940 static u8 hci_cc_le_read_supported_states(struct hci_dev *hdev, void *data, in hci_cc_le_read_supported_states() argument
1945 bt_dev_dbg(hdev, "status 0x%2.2x", 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()
1955 static u8 hci_cc_le_read_def_data_len(struct hci_dev *hdev, void *data, in hci_cc_le_read_def_data_len() argument
1960 bt_dev_dbg(hdev, "status 0x%2.2x", 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()
1971 static u8 hci_cc_le_write_def_data_len(struct hci_dev *hdev, void *data, in hci_cc_le_write_def_data_len() argument
1977 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_write_def_data_len()
1982 sent = hci_sent_cmd_data(hdev, HCI_OP_LE_WRITE_DEF_DATA_LEN); 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()
1992 static u8 hci_cc_le_add_to_resolv_list(struct hci_dev *hdev, void *data, in hci_cc_le_add_to_resolv_list() argument
1998 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_add_to_resolv_list()
2003 sent = hci_sent_cmd_data(hdev, HCI_OP_LE_ADD_TO_RESOLV_LIST); in hci_cc_le_add_to_resolv_list()
2007 hci_dev_lock(hdev); 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()
2011 hci_dev_unlock(hdev); in hci_cc_le_add_to_resolv_list()
2016 static u8 hci_cc_le_del_from_resolv_list(struct hci_dev *hdev, void *data, in hci_cc_le_del_from_resolv_list() argument
2022 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_del_from_resolv_list()
2027 sent = hci_sent_cmd_data(hdev, HCI_OP_LE_DEL_FROM_RESOLV_LIST); in hci_cc_le_del_from_resolv_list()
2031 hci_dev_lock(hdev); 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()
2034 hci_dev_unlock(hdev); in hci_cc_le_del_from_resolv_list()
2039 static u8 hci_cc_le_clear_resolv_list(struct hci_dev *hdev, void *data, in hci_cc_le_clear_resolv_list() argument
2044 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_clear_resolv_list()
2049 hci_dev_lock(hdev); in hci_cc_le_clear_resolv_list()
2050 hci_bdaddr_list_clear(&hdev->le_resolv_list); in hci_cc_le_clear_resolv_list()
2051 hci_dev_unlock(hdev); in hci_cc_le_clear_resolv_list()
2056 static u8 hci_cc_le_read_resolv_list_size(struct hci_dev *hdev, void *data, in hci_cc_le_read_resolv_list_size() argument
2061 bt_dev_dbg(hdev, "status 0x%2.2x size %u", rp->status, rp->size); in hci_cc_le_read_resolv_list_size()
2066 hdev->le_resolv_list_size = rp->size; in hci_cc_le_read_resolv_list_size()
2071 static u8 hci_cc_le_set_addr_resolution_enable(struct hci_dev *hdev, void *data, in hci_cc_le_set_addr_resolution_enable() argument
2077 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_addr_resolution_enable()
2082 sent = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE); in hci_cc_le_set_addr_resolution_enable()
2086 hci_dev_lock(hdev); in hci_cc_le_set_addr_resolution_enable()
2089 hci_dev_set_flag(hdev, HCI_LL_RPA_RESOLUTION); in hci_cc_le_set_addr_resolution_enable()
2091 hci_dev_clear_flag(hdev, HCI_LL_RPA_RESOLUTION); in hci_cc_le_set_addr_resolution_enable()
2093 hci_dev_unlock(hdev); in hci_cc_le_set_addr_resolution_enable()
2098 static u8 hci_cc_le_read_max_data_len(struct hci_dev *hdev, void *data, in hci_cc_le_read_max_data_len() argument
2103 bt_dev_dbg(hdev, "status 0x%2.2x", 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()
2116 static u8 hci_cc_write_le_host_supported(struct hci_dev *hdev, void *data, in hci_cc_write_le_host_supported() argument
2122 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_le_host_supported()
2127 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_LE_HOST_SUPPORTED); in hci_cc_write_le_host_supported()
2131 hci_dev_lock(hdev); in hci_cc_write_le_host_supported()
2134 hdev->features[1][0] |= LMP_HOST_LE; in hci_cc_write_le_host_supported()
2135 hci_dev_set_flag(hdev, HCI_LE_ENABLED); in hci_cc_write_le_host_supported()
2137 hdev->features[1][0] &= ~LMP_HOST_LE; in hci_cc_write_le_host_supported()
2138 hci_dev_clear_flag(hdev, HCI_LE_ENABLED); in hci_cc_write_le_host_supported()
2139 hci_dev_clear_flag(hdev, HCI_ADVERTISING); 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()
2147 hci_dev_unlock(hdev); in hci_cc_write_le_host_supported()
2152 static u8 hci_cc_set_adv_param(struct hci_dev *hdev, void *data, in hci_cc_set_adv_param() argument
2158 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_set_adv_param()
2163 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_ADV_PARAM); in hci_cc_set_adv_param()
2167 hci_dev_lock(hdev); in hci_cc_set_adv_param()
2168 hdev->adv_addr_type = cp->own_address_type; in hci_cc_set_adv_param()
2169 hci_dev_unlock(hdev); in hci_cc_set_adv_param()
2174 static u8 hci_cc_set_ext_adv_param(struct hci_dev *hdev, void *data, in hci_cc_set_ext_adv_param() argument
2181 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_set_ext_adv_param()
2186 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_EXT_ADV_PARAMS); in hci_cc_set_ext_adv_param()
2190 hci_dev_lock(hdev); in hci_cc_set_ext_adv_param()
2191 hdev->adv_addr_type = cp->own_addr_type; 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()
2201 hci_update_adv_data(hdev, cp->handle); in hci_cc_set_ext_adv_param()
2203 hci_dev_unlock(hdev); in hci_cc_set_ext_adv_param()
2208 static u8 hci_cc_read_rssi(struct hci_dev *hdev, void *data, in hci_cc_read_rssi() argument
2214 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_rssi()
2219 hci_dev_lock(hdev); in hci_cc_read_rssi()
2221 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_rssi()
2225 hci_dev_unlock(hdev); in hci_cc_read_rssi()
2230 static u8 hci_cc_read_tx_power(struct hci_dev *hdev, void *data, in hci_cc_read_tx_power() argument
2237 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_tx_power()
2242 sent = hci_sent_cmd_data(hdev, HCI_OP_READ_TX_POWER); in hci_cc_read_tx_power()
2246 hci_dev_lock(hdev); 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()
2262 hci_dev_unlock(hdev); in hci_cc_read_tx_power()
2266 static u8 hci_cc_write_ssp_debug_mode(struct hci_dev *hdev, void *data, in hci_cc_write_ssp_debug_mode() argument
2272 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_ssp_debug_mode()
2277 mode = hci_sent_cmd_data(hdev, HCI_OP_WRITE_SSP_DEBUG_MODE); in hci_cc_write_ssp_debug_mode()
2279 hdev->ssp_debug_mode = *mode; in hci_cc_write_ssp_debug_mode()
2284 static void hci_cs_inquiry(struct hci_dev *hdev, __u8 status) in hci_cs_inquiry() argument
2286 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_inquiry()
2289 hci_conn_check_pending(hdev); in hci_cs_inquiry()
2293 set_bit(HCI_INQUIRY, &hdev->flags); in hci_cs_inquiry()
2296 static void hci_cs_create_conn(struct hci_dev *hdev, __u8 status) in hci_cs_create_conn() argument
2301 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_create_conn()
2303 cp = hci_sent_cmd_data(hdev, HCI_OP_CREATE_CONN); in hci_cs_create_conn()
2307 hci_dev_lock(hdev); 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()
2324 conn = hci_conn_add(hdev, ACL_LINK, &cp->bdaddr, in hci_cs_create_conn()
2327 bt_dev_err(hdev, "no memory for new connection"); in hci_cs_create_conn()
2331 hci_dev_unlock(hdev); in hci_cs_create_conn()
2334 static void hci_cs_add_sco(struct hci_dev *hdev, __u8 status) in hci_cs_add_sco() argument
2340 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_add_sco()
2345 cp = hci_sent_cmd_data(hdev, HCI_OP_ADD_SCO); in hci_cs_add_sco()
2351 bt_dev_dbg(hdev, "handle 0x%4.4x", handle); in hci_cs_add_sco()
2353 hci_dev_lock(hdev); in hci_cs_add_sco()
2355 acl = hci_conn_hash_lookup_handle(hdev, handle); in hci_cs_add_sco()
2366 hci_dev_unlock(hdev); in hci_cs_add_sco()
2369 static void hci_cs_auth_requested(struct hci_dev *hdev, __u8 status) in hci_cs_auth_requested() argument
2374 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_auth_requested()
2379 cp = hci_sent_cmd_data(hdev, HCI_OP_AUTH_REQUESTED); in hci_cs_auth_requested()
2383 hci_dev_lock(hdev); in hci_cs_auth_requested()
2385 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_auth_requested()
2393 hci_dev_unlock(hdev); in hci_cs_auth_requested()
2396 static void hci_cs_set_conn_encrypt(struct hci_dev *hdev, __u8 status) in hci_cs_set_conn_encrypt() argument
2401 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_set_conn_encrypt()
2406 cp = hci_sent_cmd_data(hdev, HCI_OP_SET_CONN_ENCRYPT); in hci_cs_set_conn_encrypt()
2410 hci_dev_lock(hdev); 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()
2420 hci_dev_unlock(hdev); in hci_cs_set_conn_encrypt()
2423 static int hci_outgoing_auth_needed(struct hci_dev *hdev, in hci_outgoing_auth_needed() argument
2445 static int hci_resolve_name(struct hci_dev *hdev, in hci_resolve_name() argument
2457 return hci_send_cmd(hdev, HCI_OP_REMOTE_NAME_REQ, sizeof(cp), &cp); in hci_resolve_name()
2460 static bool hci_resolve_next_name(struct hci_dev *hdev) in hci_resolve_next_name() argument
2462 struct discovery_state *discov = &hdev->discovery; in hci_resolve_next_name()
2470 bt_dev_warn_ratelimited(hdev, "Name resolve takes too long."); in hci_resolve_next_name()
2474 e = hci_inquiry_cache_lookup_resolve(hdev, BDADDR_ANY, NAME_NEEDED); in hci_resolve_next_name()
2478 if (hci_resolve_name(hdev, e) == 0) { in hci_resolve_next_name()
2486 static void hci_check_pending_name(struct hci_dev *hdev, struct hci_conn *conn, in hci_check_pending_name() argument
2489 struct discovery_state *discov = &hdev->discovery; in hci_check_pending_name()
2500 mgmt_device_connected(hdev, conn, name, name_len); in hci_check_pending_name()
2511 e = hci_inquiry_cache_lookup_resolve(hdev, bdaddr, NAME_PENDING); in hci_check_pending_name()
2522 mgmt_remote_name(hdev, bdaddr, ACL_LINK, 0x00, e->data.rssi, in hci_check_pending_name()
2525 if (hci_resolve_next_name(hdev)) in hci_check_pending_name()
2529 hci_discovery_set_state(hdev, DISCOVERY_STOPPED); in hci_check_pending_name()
2532 static void hci_cs_remote_name_req(struct hci_dev *hdev, __u8 status) in hci_cs_remote_name_req() argument
2537 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_remote_name_req()
2544 cp = hci_sent_cmd_data(hdev, HCI_OP_REMOTE_NAME_REQ); in hci_cs_remote_name_req()
2548 hci_dev_lock(hdev); in hci_cs_remote_name_req()
2550 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cs_remote_name_req()
2552 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_cs_remote_name_req()
2553 hci_check_pending_name(hdev, conn, &cp->bdaddr, NULL, 0); in hci_cs_remote_name_req()
2558 if (!hci_outgoing_auth_needed(hdev, conn)) in hci_cs_remote_name_req()
2567 hci_send_cmd(hdev, HCI_OP_AUTH_REQUESTED, in hci_cs_remote_name_req()
2572 hci_dev_unlock(hdev); in hci_cs_remote_name_req()
2575 static void hci_cs_read_remote_features(struct hci_dev *hdev, __u8 status) in hci_cs_read_remote_features() argument
2580 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_read_remote_features()
2585 cp = hci_sent_cmd_data(hdev, HCI_OP_READ_REMOTE_FEATURES); in hci_cs_read_remote_features()
2589 hci_dev_lock(hdev); 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()
2599 hci_dev_unlock(hdev); in hci_cs_read_remote_features()
2602 static void hci_cs_read_remote_ext_features(struct hci_dev *hdev, __u8 status) in hci_cs_read_remote_ext_features() argument
2607 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_read_remote_ext_features()
2612 cp = hci_sent_cmd_data(hdev, HCI_OP_READ_REMOTE_EXT_FEATURES); in hci_cs_read_remote_ext_features()
2616 hci_dev_lock(hdev); 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()
2626 hci_dev_unlock(hdev); in hci_cs_read_remote_ext_features()
2629 static void hci_cs_setup_sync_conn(struct hci_dev *hdev, __u8 status) in hci_cs_setup_sync_conn() argument
2635 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_setup_sync_conn()
2640 cp = hci_sent_cmd_data(hdev, HCI_OP_SETUP_SYNC_CONN); in hci_cs_setup_sync_conn()
2646 bt_dev_dbg(hdev, "handle 0x%4.4x", handle); in hci_cs_setup_sync_conn()
2648 hci_dev_lock(hdev); in hci_cs_setup_sync_conn()
2650 acl = hci_conn_hash_lookup_handle(hdev, handle); in hci_cs_setup_sync_conn()
2661 hci_dev_unlock(hdev); in hci_cs_setup_sync_conn()
2664 static void hci_cs_enhanced_setup_sync_conn(struct hci_dev *hdev, __u8 status) in hci_cs_enhanced_setup_sync_conn() argument
2670 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_enhanced_setup_sync_conn()
2675 cp = hci_sent_cmd_data(hdev, HCI_OP_ENHANCED_SETUP_SYNC_CONN); in hci_cs_enhanced_setup_sync_conn()
2681 bt_dev_dbg(hdev, "handle 0x%4.4x", handle); in hci_cs_enhanced_setup_sync_conn()
2683 hci_dev_lock(hdev); in hci_cs_enhanced_setup_sync_conn()
2685 acl = hci_conn_hash_lookup_handle(hdev, handle); in hci_cs_enhanced_setup_sync_conn()
2696 hci_dev_unlock(hdev); in hci_cs_enhanced_setup_sync_conn()
2699 static void hci_cs_sniff_mode(struct hci_dev *hdev, __u8 status) in hci_cs_sniff_mode() argument
2704 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_sniff_mode()
2709 cp = hci_sent_cmd_data(hdev, HCI_OP_SNIFF_MODE); in hci_cs_sniff_mode()
2713 hci_dev_lock(hdev); in hci_cs_sniff_mode()
2715 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_sniff_mode()
2723 hci_dev_unlock(hdev); in hci_cs_sniff_mode()
2726 static void hci_cs_exit_sniff_mode(struct hci_dev *hdev, __u8 status) in hci_cs_exit_sniff_mode() argument
2731 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_exit_sniff_mode()
2736 cp = hci_sent_cmd_data(hdev, HCI_OP_EXIT_SNIFF_MODE); in hci_cs_exit_sniff_mode()
2740 hci_dev_lock(hdev); 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()
2750 hci_dev_unlock(hdev); in hci_cs_exit_sniff_mode()
2753 static void hci_cs_disconnect(struct hci_dev *hdev, u8 status) in hci_cs_disconnect() argument
2760 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_disconnect()
2765 if (!status && !hdev->suspended) in hci_cs_disconnect()
2768 cp = hci_sent_cmd_data(hdev, HCI_OP_DISCONNECT); in hci_cs_disconnect()
2772 hci_dev_lock(hdev); 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()
2783 hdev->cur_adv_instance = conn->adv_instance; in hci_cs_disconnect()
2784 hci_enable_advertising(hdev); 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()
2808 list_add(¶ms->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()
2829 hci_dev_unlock(hdev); in hci_cs_disconnect()
2832 static u8 ev_bdaddr_type(struct hci_dev *hdev, u8 type, bool *resolved) in ev_bdaddr_type() argument
2854 static void cs_le_create_conn(struct hci_dev *hdev, bdaddr_t *peer_addr, in cs_le_create_conn() argument
2860 conn = hci_conn_hash_lookup_le(hdev, peer_addr, in cs_le_create_conn()
2865 own_address_type = ev_bdaddr_type(hdev, own_address_type, NULL); 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()
2886 queue_delayed_work(conn->hdev->workqueue, in cs_le_create_conn()
2891 static void hci_cs_le_create_conn(struct hci_dev *hdev, u8 status) in hci_cs_le_create_conn() argument
2895 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_le_create_conn()
2904 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_CREATE_CONN); in hci_cs_le_create_conn()
2908 hci_dev_lock(hdev); 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()
2913 hci_dev_unlock(hdev); in hci_cs_le_create_conn()
2916 static void hci_cs_le_ext_create_conn(struct hci_dev *hdev, u8 status) in hci_cs_le_ext_create_conn() argument
2920 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_le_ext_create_conn()
2929 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_EXT_CREATE_CONN); in hci_cs_le_ext_create_conn()
2933 hci_dev_lock(hdev); 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()
2938 hci_dev_unlock(hdev); in hci_cs_le_ext_create_conn()
2941 static void hci_cs_le_read_remote_features(struct hci_dev *hdev, u8 status) in hci_cs_le_read_remote_features() argument
2946 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_le_read_remote_features()
2951 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_READ_REMOTE_FEATURES); in hci_cs_le_read_remote_features()
2955 hci_dev_lock(hdev); 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()
2965 hci_dev_unlock(hdev); in hci_cs_le_read_remote_features()
2968 static void hci_cs_le_start_enc(struct hci_dev *hdev, u8 status) in hci_cs_le_start_enc() argument
2973 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_le_start_enc()
2978 hci_dev_lock(hdev); in hci_cs_le_start_enc()
2980 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_START_ENC); 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()
2995 hci_dev_unlock(hdev); in hci_cs_le_start_enc()
2998 static void hci_cs_switch_role(struct hci_dev *hdev, u8 status) in hci_cs_switch_role() argument
3003 BT_DBG("%s status 0x%2.2x", hdev->name, status); in hci_cs_switch_role()
3008 cp = hci_sent_cmd_data(hdev, HCI_OP_SWITCH_ROLE); in hci_cs_switch_role()
3012 hci_dev_lock(hdev); in hci_cs_switch_role()
3014 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cs_switch_role()
3018 hci_dev_unlock(hdev); in hci_cs_switch_role()
3021 static void hci_inquiry_complete_evt(struct hci_dev *hdev, void *data, in hci_inquiry_complete_evt() argument
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()
3030 hci_conn_check_pending(hdev); 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()
3038 if (!hci_dev_test_flag(hdev, HCI_MGMT)) in hci_inquiry_complete_evt()
3041 hci_dev_lock(hdev); in hci_inquiry_complete_evt()
3054 if (!hci_dev_test_flag(hdev, HCI_LE_SCAN) || in hci_inquiry_complete_evt()
3055 !test_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks)) in hci_inquiry_complete_evt()
3056 hci_discovery_set_state(hdev, DISCOVERY_STOPPED); in hci_inquiry_complete_evt()
3060 e = hci_inquiry_cache_lookup_resolve(hdev, BDADDR_ANY, NAME_NEEDED); in hci_inquiry_complete_evt()
3061 if (e && hci_resolve_name(hdev, e) == 0) { in hci_inquiry_complete_evt()
3063 hci_discovery_set_state(hdev, DISCOVERY_RESOLVING); in hci_inquiry_complete_evt()
3073 if (!hci_dev_test_flag(hdev, HCI_LE_SCAN) || in hci_inquiry_complete_evt()
3074 !test_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks)) in hci_inquiry_complete_evt()
3075 hci_discovery_set_state(hdev, DISCOVERY_STOPPED); in hci_inquiry_complete_evt()
3079 hci_dev_unlock(hdev); in hci_inquiry_complete_evt()
3082 static void hci_inquiry_result_evt(struct hci_dev *hdev, void *edata, in hci_inquiry_result_evt() argument
3089 if (!hci_ev_skb_pull(hdev, skb, HCI_EV_INQUIRY_RESULT, in hci_inquiry_result_evt()
3093 bt_dev_dbg(hdev, "num %d", ev->num); in hci_inquiry_result_evt()
3098 if (hci_dev_test_flag(hdev, HCI_PERIODIC_INQ)) in hci_inquiry_result_evt()
3101 hci_dev_lock(hdev); in hci_inquiry_result_evt()
3116 flags = hci_inquiry_cache_update(hdev, &data, false); in hci_inquiry_result_evt()
3118 mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, in hci_inquiry_result_evt()
3123 hci_dev_unlock(hdev); in hci_inquiry_result_evt()
3126 static void hci_conn_complete_evt(struct hci_dev *hdev, void *data, in hci_conn_complete_evt() argument
3133 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_conn_complete_evt()
3135 hci_dev_lock(hdev); in hci_conn_complete_evt()
3137 conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, &ev->bdaddr); in hci_conn_complete_evt()
3155 hci_bdaddr_list_lookup_with_flags(&hdev->accept_list, in hci_conn_complete_evt()
3158 conn = hci_conn_add(hdev, ev->link_type, &ev->bdaddr, in hci_conn_complete_evt()
3161 bt_dev_err(hdev, "no memory for new conn"); in hci_conn_complete_evt()
3168 conn = hci_conn_hash_lookup_ba(hdev, ESCO_LINK, in hci_conn_complete_evt()
3184 bt_dev_err(hdev, "Ignoring HCI_Connection_Complete for existing connection"); in hci_conn_complete_evt()
3191 bt_dev_err(hdev, "Invalid handle: 0x%4.4x > 0x%4.4x", in hci_conn_complete_evt()
3202 !hci_find_link_key(hdev, &ev->bdaddr)) in hci_conn_complete_evt()
3212 if (test_bit(HCI_AUTH, &hdev->flags)) in hci_conn_complete_evt()
3215 if (test_bit(HCI_ENCRYPT, &hdev->flags)) in hci_conn_complete_evt()
3222 hci_send_cmd(hdev, HCI_OP_READ_REMOTE_FEATURES, in hci_conn_complete_evt()
3225 hci_update_scan(hdev); in hci_conn_complete_evt()
3229 if (!conn->out && hdev->hci_ver < BLUETOOTH_VER_2_0) { in hci_conn_complete_evt()
3233 hci_send_cmd(hdev, HCI_OP_CHANGE_CONN_PTYPE, sizeof(cp), 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()
3256 hci_dev_unlock(hdev); in hci_conn_complete_evt()
3258 hci_conn_check_pending(hdev); in hci_conn_complete_evt()
3261 static void hci_reject_conn(struct hci_dev *hdev, bdaddr_t *bdaddr) in hci_reject_conn() argument
3267 hci_send_cmd(hdev, HCI_OP_REJECT_CONN_REQ, sizeof(cp), &cp); in hci_reject_conn()
3270 static void hci_conn_request_evt(struct hci_dev *hdev, void *data, in hci_conn_request_evt() argument
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()
3289 hci_dev_lock(hdev); 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()
3301 if (hci_dev_test_flag(hdev, HCI_MGMT) && in hci_conn_request_evt()
3302 !hci_dev_test_flag(hdev, HCI_CONNECTABLE) && 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()
3315 conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, in hci_conn_request_evt()
3318 conn = hci_conn_add(hdev, ev->link_type, &ev->bdaddr, in hci_conn_request_evt()
3321 bt_dev_err(hdev, "no memory for new connection"); in hci_conn_request_evt()
3328 hci_dev_unlock(hdev); in hci_conn_request_evt()
3331 (!(flags & HCI_PROTO_DEFER) && !lmp_esco_capable(hdev))) { in hci_conn_request_evt()
3337 if (lmp_rswitch_capable(hdev) && (mask & HCI_LM_MASTER)) in hci_conn_request_evt()
3342 hci_send_cmd(hdev, HCI_OP_ACCEPT_CONN_REQ, sizeof(cp), &cp); in hci_conn_request_evt()
3353 cp.content_format = cpu_to_le16(hdev->voice_setting); in hci_conn_request_evt()
3356 hci_send_cmd(hdev, HCI_OP_ACCEPT_SYNC_CONN_REQ, sizeof(cp), in hci_conn_request_evt()
3365 hci_dev_unlock(hdev); in hci_conn_request_evt()
3384 static void hci_disconn_complete_evt(struct hci_dev *hdev, void *data, in hci_disconn_complete_evt() argument
3393 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_disconn_complete_evt()
3395 hci_dev_lock(hdev); in hci_disconn_complete_evt()
3397 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_disconn_complete_evt()
3402 mgmt_disconnect_failed(hdev, &conn->dst, conn->type, in hci_disconn_complete_evt()
3416 mgmt_device_disconnected(hdev, &conn->dst, conn->type, conn->dst_type, in hci_disconn_complete_evt()
3421 hci_remove_link_key(hdev, &conn->dst); in hci_disconn_complete_evt()
3423 hci_update_scan(hdev); in hci_disconn_complete_evt()
3426 params = hci_conn_params_lookup(hdev, &conn->dst, conn->dst_type); in hci_disconn_complete_evt()
3437 list_add(¶ms->action, &hdev->pend_le_conns); in hci_disconn_complete_evt()
3438 hci_update_passive_scan(hdev); in hci_disconn_complete_evt()
3459 hdev->cur_adv_instance = conn->adv_instance; in hci_disconn_complete_evt()
3460 hci_enable_advertising(hdev); in hci_disconn_complete_evt()
3466 hci_dev_unlock(hdev); in hci_disconn_complete_evt()
3469 static void hci_auth_complete_evt(struct hci_dev *hdev, void *data, in hci_auth_complete_evt() argument
3475 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_auth_complete_evt()
3477 hci_dev_lock(hdev); in hci_auth_complete_evt()
3479 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_auth_complete_evt()
3488 bt_dev_info(hdev, "re-auth of legacy device is not possible."); in hci_auth_complete_evt()
3508 hci_send_cmd(hdev, HCI_OP_SET_CONN_ENCRYPT, sizeof(cp), in hci_auth_complete_evt()
3528 hci_send_cmd(hdev, HCI_OP_SET_CONN_ENCRYPT, sizeof(cp), in hci_auth_complete_evt()
3537 hci_dev_unlock(hdev); in hci_auth_complete_evt()
3540 static void hci_remote_name_evt(struct hci_dev *hdev, void *data, in hci_remote_name_evt() argument
3546 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_remote_name_evt()
3548 hci_conn_check_pending(hdev); in hci_remote_name_evt()
3550 hci_dev_lock(hdev); in hci_remote_name_evt()
3552 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_remote_name_evt()
3554 if (!hci_dev_test_flag(hdev, HCI_MGMT)) in hci_remote_name_evt()
3558 hci_check_pending_name(hdev, conn, &ev->bdaddr, ev->name, in hci_remote_name_evt()
3561 hci_check_pending_name(hdev, conn, &ev->bdaddr, NULL, 0); in hci_remote_name_evt()
3567 if (!hci_outgoing_auth_needed(hdev, conn)) in hci_remote_name_evt()
3576 hci_send_cmd(hdev, HCI_OP_AUTH_REQUESTED, sizeof(cp), &cp); in hci_remote_name_evt()
3580 hci_dev_unlock(hdev); in hci_remote_name_evt()
3583 static void hci_encrypt_change_evt(struct hci_dev *hdev, void *data, in hci_encrypt_change_evt() argument
3589 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_encrypt_change_evt()
3591 hci_dev_lock(hdev); in hci_encrypt_change_evt()
3593 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_encrypt_change_evt()
3621 hci_dev_set_flag(hdev, HCI_RPA_EXPIRED); in hci_encrypt_change_evt()
3622 hci_adv_instances_set_rpa_expired(hdev, true); in hci_encrypt_change_evt()
3652 if (!(hdev->commands[20] & 0x10)) { in hci_encrypt_change_evt()
3658 if (hci_send_cmd(hdev, HCI_OP_READ_ENC_KEY_SIZE, in hci_encrypt_change_evt()
3660 bt_dev_err(hdev, "sending read key size failed"); 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()
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()
3691 hci_dev_unlock(hdev); in hci_encrypt_change_evt()
3694 static void hci_change_link_key_complete_evt(struct hci_dev *hdev, void *data, in hci_change_link_key_complete_evt() argument
3700 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_change_link_key_complete_evt()
3702 hci_dev_lock(hdev); 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()
3714 hci_dev_unlock(hdev); in hci_change_link_key_complete_evt()
3717 static void hci_remote_features_evt(struct hci_dev *hdev, void *data, in hci_remote_features_evt() argument
3723 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_remote_features_evt()
3725 hci_dev_lock(hdev); in hci_remote_features_evt()
3727 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_remote_features_evt()
3737 if (!ev->status && lmp_ext_feat_capable(hdev) && in hci_remote_features_evt()
3742 hci_send_cmd(hdev, HCI_OP_READ_REMOTE_EXT_FEATURES, in hci_remote_features_evt()
3752 hci_send_cmd(hdev, HCI_OP_REMOTE_NAME_REQ, sizeof(cp), &cp); in hci_remote_features_evt()
3754 mgmt_device_connected(hdev, conn, NULL, 0); in hci_remote_features_evt()
3756 if (!hci_outgoing_auth_needed(hdev, conn)) { in hci_remote_features_evt()
3763 hci_dev_unlock(hdev); in hci_remote_features_evt()
3766 static inline void handle_cmd_cnt_and_timer(struct hci_dev *hdev, u8 ncmd) in handle_cmd_cnt_and_timer() argument
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()
3776 if (!hci_dev_test_flag(hdev, HCI_CMD_DRAIN_WORKQUEUE)) in handle_cmd_cnt_and_timer()
3777 queue_delayed_work(hdev->workqueue, &hdev->ncmd_timer, in handle_cmd_cnt_and_timer()
3784 static u8 hci_cc_le_read_buffer_size_v2(struct hci_dev *hdev, void *data, in hci_cc_le_read_buffer_size_v2() argument
3789 bt_dev_dbg(hdev, "status 0x%2.2x", 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()
3808 static u8 hci_cc_le_set_cig_params(struct hci_dev *hdev, void *data, in hci_cc_le_set_cig_params() argument
3815 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_cig_params()
3817 hci_dev_lock(hdev); 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()
3830 list_for_each_entry_rcu(conn, &hdev->conn_hash.list, list) { 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()
3851 hci_dev_unlock(hdev); in hci_cc_le_set_cig_params()
3856 static u8 hci_cc_le_setup_iso_path(struct hci_dev *hdev, void *data, in hci_cc_le_setup_iso_path() argument
3863 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_setup_iso_path()
3865 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SETUP_ISO_PATH); in hci_cc_le_setup_iso_path()
3869 hci_dev_lock(hdev); 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()
3898 hci_dev_unlock(hdev); in hci_cc_le_setup_iso_path()
3902 static void hci_cs_le_create_big(struct hci_dev *hdev, u8 status) in hci_cs_le_create_big() argument
3904 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_le_create_big()
3907 static u8 hci_cc_set_per_adv_param(struct hci_dev *hdev, void *data, in hci_cc_set_per_adv_param() argument
3913 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_set_per_adv_param()
3918 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_PER_ADV_PARAMS); in hci_cc_set_per_adv_param()
3926 static u8 hci_cc_le_set_per_adv_enable(struct hci_dev *hdev, void *data, in hci_cc_le_set_per_adv_enable() argument
3932 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_per_adv_enable()
3937 sent = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_PER_ADV_ENABLE); in hci_cc_le_set_per_adv_enable()
3941 hci_dev_lock(hdev); in hci_cc_le_set_per_adv_enable()
3944 hci_dev_set_flag(hdev, HCI_LE_PER_ADV); in hci_cc_le_set_per_adv_enable()
3946 hci_dev_clear_flag(hdev, HCI_LE_PER_ADV); in hci_cc_le_set_per_adv_enable()
3948 hci_dev_unlock(hdev); in hci_cc_le_set_per_adv_enable()
3969 u8 (*func)(struct hci_dev *hdev, void *data, struct sk_buff *skb);
4142 static u8 hci_cc_func(struct hci_dev *hdev, const struct hci_cc *cc, in hci_cc_func() argument
4148 bt_dev_err(hdev, "unexpected cc 0x%4.4x length: %u < %u", in hci_cc_func()
4158 bt_dev_warn(hdev, "unexpected cc 0x%4.4x length: %u > %u", 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()
4168 static void hci_cmd_complete_evt(struct hci_dev *hdev, void *data, in hci_cmd_complete_evt() argument
4178 bt_dev_dbg(hdev, "opcode 0x%4.4x", *opcode); in hci_cmd_complete_evt()
4182 *status = hci_cc_func(hdev, &hci_cc_table[i], skb); in hci_cmd_complete_evt()
4198 handle_cmd_cnt_and_timer(hdev, ev->ncmd); in hci_cmd_complete_evt()
4200 hci_req_cmd_complete(hdev, *opcode, *status, req_complete, in hci_cmd_complete_evt()
4203 if (hci_dev_test_flag(hdev, HCI_CMD_PENDING)) { in hci_cmd_complete_evt()
4204 bt_dev_err(hdev, 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()
4213 static void hci_cs_le_create_cis(struct hci_dev *hdev, u8 status) in hci_cs_le_create_cis() argument
4218 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_le_create_cis()
4223 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_CREATE_CIS); in hci_cs_le_create_cis()
4227 hci_dev_lock(hdev); in hci_cs_le_create_cis()
4236 conn = hci_conn_hash_lookup_handle(hdev, handle); in hci_cs_le_create_cis()
4244 hci_dev_unlock(hdev); in hci_cs_le_create_cis()
4255 void (*func)(struct hci_dev *hdev, __u8 status);
4281 static void hci_cmd_status_evt(struct hci_dev *hdev, void *data, in hci_cmd_status_evt() argument
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()
4312 if (hci_dev_test_flag(hdev, HCI_CMD_PENDING)) { 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()
4323 static void hci_hardware_error_evt(struct hci_dev *hdev, void *data, in hci_hardware_error_evt() argument
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()
4335 static void hci_role_change_evt(struct hci_dev *hdev, void *data, in hci_role_change_evt() argument
4341 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_role_change_evt()
4343 hci_dev_lock(hdev); in hci_role_change_evt()
4345 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_role_change_evt()
4355 hci_dev_unlock(hdev); in hci_role_change_evt()
4358 static void hci_num_comp_pkts_evt(struct hci_dev *hdev, void *data, in hci_num_comp_pkts_evt() argument
4364 if (!hci_ev_skb_pull(hdev, skb, HCI_EV_NUM_COMP_PKTS, 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()
4383 conn = hci_conn_hash_lookup_handle(hdev, handle); 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()
4431 bt_dev_err(hdev, "unknown type %d conn %p", in hci_num_comp_pkts_evt()
4437 queue_work(hdev->workqueue, &hdev->tx_work); in hci_num_comp_pkts_evt()
4440 static struct hci_conn *__hci_conn_lookup_handle(struct hci_dev *hdev, in __hci_conn_lookup_handle() argument
4445 switch (hdev->dev_type) { in __hci_conn_lookup_handle()
4447 return hci_conn_hash_lookup_handle(hdev, handle); in __hci_conn_lookup_handle()
4449 chan = hci_chan_lookup_handle(hdev, handle); in __hci_conn_lookup_handle()
4454 bt_dev_err(hdev, "unknown dev_type %d", hdev->dev_type); in __hci_conn_lookup_handle()
4461 static void hci_num_comp_blocks_evt(struct hci_dev *hdev, void *data, in hci_num_comp_blocks_evt() argument
4467 if (!hci_ev_skb_pull(hdev, skb, HCI_EV_NUM_COMP_BLOCKS, in hci_num_comp_blocks_evt()
4471 if (hdev->flow_ctl_mode != HCI_FLOW_CTL_MODE_BLOCK_BASED) { in hci_num_comp_blocks_evt()
4472 bt_dev_err(hdev, "wrong event for mode %d", 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()
4488 conn = __hci_conn_lookup_handle(hdev, handle); 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()
4503 bt_dev_err(hdev, "unknown type %d conn %p", in hci_num_comp_blocks_evt()
4509 queue_work(hdev->workqueue, &hdev->tx_work); in hci_num_comp_blocks_evt()
4512 static void hci_mode_change_evt(struct hci_dev *hdev, void *data, in hci_mode_change_evt() argument
4518 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_mode_change_evt()
4520 hci_dev_lock(hdev); in hci_mode_change_evt()
4522 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_mode_change_evt()
4538 hci_dev_unlock(hdev); in hci_mode_change_evt()
4541 static void hci_pin_code_request_evt(struct hci_dev *hdev, void *data, in hci_pin_code_request_evt() argument
4547 bt_dev_dbg(hdev, ""); in hci_pin_code_request_evt()
4549 hci_dev_lock(hdev); in hci_pin_code_request_evt()
4551 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_pin_code_request_evt()
4561 if (!hci_dev_test_flag(hdev, HCI_BONDABLE) && in hci_pin_code_request_evt()
4563 hci_send_cmd(hdev, HCI_OP_PIN_CODE_NEG_REPLY, in hci_pin_code_request_evt()
4565 } else if (hci_dev_test_flag(hdev, HCI_MGMT)) { in hci_pin_code_request_evt()
4573 mgmt_pin_code_request(hdev, &ev->bdaddr, secure); in hci_pin_code_request_evt()
4577 hci_dev_unlock(hdev); in hci_pin_code_request_evt()
4612 static void hci_link_key_request_evt(struct hci_dev *hdev, void *data, in hci_link_key_request_evt() argument
4620 bt_dev_dbg(hdev, ""); in hci_link_key_request_evt()
4622 if (!hci_dev_test_flag(hdev, HCI_MGMT)) in hci_link_key_request_evt()
4625 hci_dev_lock(hdev); in hci_link_key_request_evt()
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()
4642 bt_dev_dbg(hdev, "ignoring unauthenticated key"); in hci_link_key_request_evt()
4649 bt_dev_dbg(hdev, "ignoring key unauthenticated for high security"); in hci_link_key_request_evt()
4659 hci_send_cmd(hdev, HCI_OP_LINK_KEY_REPLY, sizeof(cp), &cp); in hci_link_key_request_evt()
4661 hci_dev_unlock(hdev); 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()
4667 hci_dev_unlock(hdev); in hci_link_key_request_evt()
4670 static void hci_link_key_notify_evt(struct hci_dev *hdev, void *data, in hci_link_key_notify_evt() argument
4679 bt_dev_dbg(hdev, ""); in hci_link_key_notify_evt()
4681 hci_dev_lock(hdev); in hci_link_key_notify_evt()
4683 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_link_key_notify_evt()
4694 if (!hci_dev_test_flag(hdev, HCI_MGMT)) 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()
4708 mgmt_new_link_key(hdev, key, persistent); in hci_link_key_notify_evt()
4716 !hci_dev_test_flag(hdev, HCI_KEEP_DEBUG_KEYS)) { in hci_link_key_notify_evt()
4728 hci_dev_unlock(hdev); in hci_link_key_notify_evt()
4731 static void hci_clock_offset_evt(struct hci_dev *hdev, void *data, in hci_clock_offset_evt() argument
4737 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_clock_offset_evt()
4739 hci_dev_lock(hdev); in hci_clock_offset_evt()
4741 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_clock_offset_evt()
4745 ie = hci_inquiry_cache_lookup(hdev, &conn->dst); in hci_clock_offset_evt()
4752 hci_dev_unlock(hdev); in hci_clock_offset_evt()
4755 static void hci_pkt_type_change_evt(struct hci_dev *hdev, void *data, in hci_pkt_type_change_evt() argument
4761 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_pkt_type_change_evt()
4763 hci_dev_lock(hdev); 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()
4769 hci_dev_unlock(hdev); in hci_pkt_type_change_evt()
4772 static void hci_pscan_rep_mode_evt(struct hci_dev *hdev, void *data, in hci_pscan_rep_mode_evt() argument
4778 bt_dev_dbg(hdev, ""); in hci_pscan_rep_mode_evt()
4780 hci_dev_lock(hdev); in hci_pscan_rep_mode_evt()
4782 ie = hci_inquiry_cache_lookup(hdev, &ev->bdaddr); in hci_pscan_rep_mode_evt()
4788 hci_dev_unlock(hdev); in hci_pscan_rep_mode_evt()
4791 static void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, void *edata, in hci_inquiry_result_with_rssi_evt() argument
4798 bt_dev_dbg(hdev, "num_rsp %d", ev->num); in hci_inquiry_result_with_rssi_evt()
4803 if (hci_dev_test_flag(hdev, HCI_PERIODIC_INQ)) in hci_inquiry_result_with_rssi_evt()
4806 hci_dev_lock(hdev); in hci_inquiry_result_with_rssi_evt()
4815 info = hci_ev_skb_pull(hdev, skb, 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()
4833 flags = hci_inquiry_cache_update(hdev, &data, false); in hci_inquiry_result_with_rssi_evt()
4835 mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, in hci_inquiry_result_with_rssi_evt()
4846 info = hci_ev_skb_pull(hdev, skb, 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()
4864 flags = hci_inquiry_cache_update(hdev, &data, false); in hci_inquiry_result_with_rssi_evt()
4866 mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, 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()
4875 hci_dev_unlock(hdev); in hci_inquiry_result_with_rssi_evt()
4878 static void hci_remote_ext_features_evt(struct hci_dev *hdev, void *data, in hci_remote_ext_features_evt() argument
4884 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_remote_ext_features_evt()
4886 hci_dev_lock(hdev); 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()
4898 ie = hci_inquiry_cache_lookup(hdev, &conn->dst); in hci_remote_ext_features_evt()
4928 hci_send_cmd(hdev, HCI_OP_REMOTE_NAME_REQ, sizeof(cp), &cp); in hci_remote_ext_features_evt()
4930 mgmt_device_connected(hdev, conn, NULL, 0); in hci_remote_ext_features_evt()
4932 if (!hci_outgoing_auth_needed(hdev, conn)) { in hci_remote_ext_features_evt()
4939 hci_dev_unlock(hdev); in hci_remote_ext_features_evt()
4942 static void hci_sync_conn_complete_evt(struct hci_dev *hdev, void *data, in hci_sync_conn_complete_evt() argument
4958 bt_dev_err(hdev, "Ignoring connect complete event for invalid link type"); in hci_sync_conn_complete_evt()
4962 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_sync_conn_complete_evt()
4964 hci_dev_lock(hdev); 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()
4980 conn = hci_conn_hash_lookup_ba(hdev, ESCO_LINK, &ev->bdaddr); in hci_sync_conn_complete_evt()
4992 bt_dev_err(hdev, "Ignoring HCI_Sync_Conn_Complete event for existing connection"); 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()
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()
5035 bt_dev_dbg(hdev, "SCO connected with air mode: %02x", ev->air_mode); in hci_sync_conn_complete_evt()
5039 if (conn->codec.data_path == 0 && hdev->notify) { 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()
5055 hci_dev_unlock(hdev); in hci_sync_conn_complete_evt()
5075 static void hci_extended_inquiry_result_evt(struct hci_dev *hdev, void *edata, in hci_extended_inquiry_result_evt() argument
5083 if (!hci_ev_skb_pull(hdev, skb, HCI_EV_EXTENDED_INQUIRY_RESULT, in hci_extended_inquiry_result_evt()
5087 bt_dev_dbg(hdev, "num %d", ev->num); in hci_extended_inquiry_result_evt()
5092 if (hci_dev_test_flag(hdev, HCI_PERIODIC_INQ)) in hci_extended_inquiry_result_evt()
5095 hci_dev_lock(hdev); in hci_extended_inquiry_result_evt()
5111 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_extended_inquiry_result_evt()
5118 flags = hci_inquiry_cache_update(hdev, &data, name_known); in hci_extended_inquiry_result_evt()
5122 mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, in hci_extended_inquiry_result_evt()
5127 hci_dev_unlock(hdev); in hci_extended_inquiry_result_evt()
5130 static void hci_key_refresh_complete_evt(struct hci_dev *hdev, void *data, in hci_key_refresh_complete_evt() argument
5136 bt_dev_dbg(hdev, "status 0x%2.2x handle 0x%4.4x", ev->status, in hci_key_refresh_complete_evt()
5139 hci_dev_lock(hdev); 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()
5177 hci_dev_unlock(hdev); in hci_key_refresh_complete_evt()
5200 struct hci_dev *hdev = conn->hdev; in bredr_oob_data_present() local
5203 data = hci_find_remote_oob_data(hdev, &conn->dst, BDADDR_BREDR); in bredr_oob_data_present()
5207 if (bredr_sc_enabled(hdev)) { in bredr_oob_data_present()
5214 if (!hci_dev_test_flag(hdev, HCI_SC_ONLY)) in bredr_oob_data_present()
5240 static void hci_io_capa_request_evt(struct hci_dev *hdev, void *data, in hci_io_capa_request_evt() argument
5246 bt_dev_dbg(hdev, ""); in hci_io_capa_request_evt()
5248 hci_dev_lock(hdev); in hci_io_capa_request_evt()
5250 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_io_capa_request_evt()
5256 if (!hci_dev_test_flag(hdev, HCI_MGMT)) in hci_io_capa_request_evt()
5262 if (hci_dev_test_flag(hdev, HCI_BONDABLE) || in hci_io_capa_request_evt()
5288 if (!hci_dev_test_flag(hdev, HCI_BONDABLE)) in hci_io_capa_request_evt()
5294 hci_send_cmd(hdev, HCI_OP_IO_CAPABILITY_REPLY, in hci_io_capa_request_evt()
5302 hci_send_cmd(hdev, HCI_OP_IO_CAPABILITY_NEG_REPLY, in hci_io_capa_request_evt()
5307 hci_dev_unlock(hdev); in hci_io_capa_request_evt()
5310 static void hci_io_capa_reply_evt(struct hci_dev *hdev, void *data, in hci_io_capa_reply_evt() argument
5316 bt_dev_dbg(hdev, ""); in hci_io_capa_reply_evt()
5318 hci_dev_lock(hdev); in hci_io_capa_reply_evt()
5320 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_io_capa_reply_evt()
5328 hci_dev_unlock(hdev); in hci_io_capa_reply_evt()
5331 static void hci_user_confirm_request_evt(struct hci_dev *hdev, void *data, in hci_user_confirm_request_evt() argument
5338 bt_dev_dbg(hdev, ""); in hci_user_confirm_request_evt()
5340 hci_dev_lock(hdev); in hci_user_confirm_request_evt()
5342 if (!hci_dev_test_flag(hdev, HCI_MGMT)) in hci_user_confirm_request_evt()
5345 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_user_confirm_request_evt()
5359 bt_dev_dbg(hdev, "Rejecting request: remote device can't provide MITM"); in hci_user_confirm_request_evt()
5360 hci_send_cmd(hdev, HCI_OP_USER_CONFIRM_NEG_REPLY, 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()
5388 bt_dev_dbg(hdev, "Local host already has link key"); 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()
5403 hci_send_cmd(hdev, HCI_OP_USER_CONFIRM_REPLY, in hci_user_confirm_request_evt()
5409 mgmt_user_confirm_request(hdev, &ev->bdaddr, ACL_LINK, 0, in hci_user_confirm_request_evt()
5413 hci_dev_unlock(hdev); in hci_user_confirm_request_evt()
5416 static void hci_user_passkey_request_evt(struct hci_dev *hdev, void *data, in hci_user_passkey_request_evt() argument
5421 bt_dev_dbg(hdev, ""); in hci_user_passkey_request_evt()
5423 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_user_passkey_request_evt()
5424 mgmt_user_passkey_request(hdev, &ev->bdaddr, ACL_LINK, 0); in hci_user_passkey_request_evt()
5427 static void hci_user_passkey_notify_evt(struct hci_dev *hdev, void *data, in hci_user_passkey_notify_evt() argument
5433 bt_dev_dbg(hdev, ""); in hci_user_passkey_notify_evt()
5435 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_user_passkey_notify_evt()
5442 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_user_passkey_notify_evt()
5443 mgmt_user_passkey_notify(hdev, &conn->dst, conn->type, in hci_user_passkey_notify_evt()
5448 static void hci_keypress_notify_evt(struct hci_dev *hdev, void *data, in hci_keypress_notify_evt() argument
5454 bt_dev_dbg(hdev, ""); in hci_keypress_notify_evt()
5456 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_keypress_notify_evt()
5481 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_keypress_notify_evt()
5482 mgmt_user_passkey_notify(hdev, &conn->dst, conn->type, in hci_keypress_notify_evt()
5487 static void hci_simple_pair_complete_evt(struct hci_dev *hdev, void *data, in hci_simple_pair_complete_evt() argument
5493 bt_dev_dbg(hdev, ""); in hci_simple_pair_complete_evt()
5495 hci_dev_lock(hdev); in hci_simple_pair_complete_evt()
5497 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_simple_pair_complete_evt()
5515 hci_dev_unlock(hdev); in hci_simple_pair_complete_evt()
5518 static void hci_remote_host_features_evt(struct hci_dev *hdev, void *data, in hci_remote_host_features_evt() argument
5525 bt_dev_dbg(hdev, ""); in hci_remote_host_features_evt()
5527 hci_dev_lock(hdev); in hci_remote_host_features_evt()
5529 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_remote_host_features_evt()
5533 ie = hci_inquiry_cache_lookup(hdev, &ev->bdaddr); in hci_remote_host_features_evt()
5537 hci_dev_unlock(hdev); in hci_remote_host_features_evt()
5540 static void hci_remote_oob_data_request_evt(struct hci_dev *hdev, void *edata, in hci_remote_oob_data_request_evt() argument
5546 bt_dev_dbg(hdev, ""); in hci_remote_oob_data_request_evt()
5548 hci_dev_lock(hdev); in hci_remote_oob_data_request_evt()
5550 if (!hci_dev_test_flag(hdev, HCI_MGMT)) in hci_remote_oob_data_request_evt()
5553 data = hci_find_remote_oob_data(hdev, &ev->bdaddr, BDADDR_BREDR); in hci_remote_oob_data_request_evt()
5558 hci_send_cmd(hdev, HCI_OP_REMOTE_OOB_DATA_NEG_REPLY, in hci_remote_oob_data_request_evt()
5563 if (bredr_sc_enabled(hdev)) { in hci_remote_oob_data_request_evt()
5567 if (hci_dev_test_flag(hdev, HCI_SC_ONLY)) { in hci_remote_oob_data_request_evt()
5577 hci_send_cmd(hdev, HCI_OP_REMOTE_OOB_EXT_DATA_REPLY, in hci_remote_oob_data_request_evt()
5586 hci_send_cmd(hdev, HCI_OP_REMOTE_OOB_DATA_REPLY, in hci_remote_oob_data_request_evt()
5591 hci_dev_unlock(hdev); in hci_remote_oob_data_request_evt()
5595 static void hci_chan_selected_evt(struct hci_dev *hdev, void *data, in hci_chan_selected_evt() argument
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()
5607 amp_read_loc_assoc_final_data(hdev, hcon); in hci_chan_selected_evt()
5610 static void hci_phy_link_complete_evt(struct hci_dev *hdev, void *data, in hci_phy_link_complete_evt() argument
5616 bt_dev_dbg(hdev, "handle 0x%2.2x status 0x%2.2x", ev->phy_handle, in hci_phy_link_complete_evt()
5619 hci_dev_lock(hdev); in hci_phy_link_complete_evt()
5621 hcon = hci_conn_hash_lookup_handle(hdev, ev->phy_handle); in hci_phy_link_complete_evt()
5648 hci_dev_unlock(hdev); in hci_phy_link_complete_evt()
5651 static void hci_loglink_complete_evt(struct hci_dev *hdev, void *data, in hci_loglink_complete_evt() argument
5659 bt_dev_dbg(hdev, "log_handle 0x%4.4x phy_handle 0x%2.2x status 0x%2.2x", in hci_loglink_complete_evt()
5662 hcon = hci_conn_hash_lookup_handle(hdev, ev->phy_handle); in hci_loglink_complete_evt()
5682 bredr_chan->conn->mtu = hdev->block_mtu; in hci_loglink_complete_evt()
5690 static void hci_disconn_loglink_complete_evt(struct hci_dev *hdev, void *data, in hci_disconn_loglink_complete_evt() argument
5696 bt_dev_dbg(hdev, "handle 0x%4.4x status 0x%2.2x", in hci_disconn_loglink_complete_evt()
5702 hci_dev_lock(hdev); in hci_disconn_loglink_complete_evt()
5704 hchan = hci_chan_lookup_handle(hdev, le16_to_cpu(ev->handle)); in hci_disconn_loglink_complete_evt()
5711 hci_dev_unlock(hdev); in hci_disconn_loglink_complete_evt()
5714 static void hci_disconn_phylink_complete_evt(struct hci_dev *hdev, void *data, in hci_disconn_phylink_complete_evt() argument
5720 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_disconn_phylink_complete_evt()
5725 hci_dev_lock(hdev); in hci_disconn_phylink_complete_evt()
5727 hcon = hci_conn_hash_lookup_handle(hdev, ev->phy_handle); in hci_disconn_phylink_complete_evt()
5734 hci_dev_unlock(hdev); in hci_disconn_phylink_complete_evt()
5752 } else if (hci_dev_test_flag(conn->hdev, HCI_PRIVACY)) { 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()
5760 conn->resp_addr_type = conn->hdev->adv_addr_type; 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()
5773 &conn->hdev->random_addr); in le_conn_update_addr()
5775 bacpy(&conn->resp_addr, &conn->hdev->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()
5791 static void le_conn_complete_evt(struct hci_dev *hdev, u8 status, in le_conn_complete_evt() argument
5802 hci_dev_lock(hdev); in le_conn_complete_evt()
5807 hci_dev_clear_flag(hdev, HCI_LE_ADV); in le_conn_complete_evt()
5809 conn = hci_conn_hash_lookup_ba(hdev, LE_LINK, bdaddr); in le_conn_complete_evt()
5817 conn = hci_conn_add(hdev, LE_LINK, bdaddr, role); in le_conn_complete_evt()
5819 bt_dev_err(hdev, "no memory for new connection"); in le_conn_complete_evt()
5836 if (hci_dev_test_flag(hdev, HCI_PRIVACY)) { in le_conn_complete_evt()
5838 bacpy(&conn->init_addr, &hdev->rpa); in le_conn_complete_evt()
5840 hci_copy_identity_address(hdev, in le_conn_complete_evt()
5856 bt_dev_err(hdev, "Ignoring HCI_Connection_Complete for existing connection"); in le_conn_complete_evt()
5871 irk = hci_get_irk(hdev, &conn->dst, conn->dst_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()
5898 if (hci_bdaddr_list_lookup(&hdev->reject_list, &conn->dst, addr_type)) { in le_conn_complete_evt()
5904 mgmt_device_connected(hdev, conn, NULL, 0); in le_conn_complete_evt()
5914 if (!ext_adv_capable(hdev)) in le_conn_complete_evt()
5915 conn->adv_instance = hdev->cur_adv_instance; in le_conn_complete_evt()
5934 (hdev->le_features[0] & HCI_LE_PERIPHERAL_FEATURES)) { in le_conn_complete_evt()
5939 hci_send_cmd(hdev, HCI_OP_LE_READ_REMOTE_FEATURES, in le_conn_complete_evt()
5948 params = hci_pend_le_action_lookup(&hdev->pend_le_conns, &conn->dst, in le_conn_complete_evt()
5960 hci_update_passive_scan(hdev); in le_conn_complete_evt()
5961 hci_dev_unlock(hdev); in le_conn_complete_evt()
5964 static void hci_le_conn_complete_evt(struct hci_dev *hdev, void *data, in hci_le_conn_complete_evt() argument
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()
5978 static void hci_le_enh_conn_complete_evt(struct hci_dev *hdev, void *data, in hci_le_enh_conn_complete_evt() argument
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()
5992 static void hci_le_ext_adv_term_evt(struct hci_dev *hdev, void *data, in hci_le_ext_adv_term_evt() argument
5999 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_ext_adv_term_evt()
6009 bt_dev_warn_ratelimited(hdev, "Unexpected advertising set terminated event"); in hci_le_ext_adv_term_evt()
6013 hci_dev_lock(hdev); in hci_le_ext_adv_term_evt()
6015 adv = hci_find_adv_instance(hdev, ev->handle); 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()
6031 hci_dev_clear_flag(hdev, HCI_LE_ADV); 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()
6045 if (hdev->adv_addr_type != ADDR_LE_DEV_RANDOM || in hci_le_ext_adv_term_evt()
6050 bacpy(&conn->resp_addr, &hdev->random_addr); in hci_le_ext_adv_term_evt()
6059 hci_dev_unlock(hdev); in hci_le_ext_adv_term_evt()
6062 static void hci_le_conn_update_complete_evt(struct hci_dev *hdev, void *data, in hci_le_conn_update_complete_evt() argument
6068 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_conn_update_complete_evt()
6073 hci_dev_lock(hdev); 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()
6082 hci_dev_unlock(hdev); in hci_le_conn_update_complete_evt()
6086 static struct hci_conn *check_pending_le_conn(struct hci_dev *hdev, in check_pending_le_conn() argument
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()
6142 conn = hci_connect_le(hdev, addr, addr_type, addr_resolved, in check_pending_le_conn()
6143 BT_SECURITY_LOW, hdev->def_le_autoconnect_timeout, in check_pending_le_conn()
6177 static void process_adv_report(struct hci_dev *hdev, u8 type, bdaddr_t *bdaddr, in process_adv_report() argument
6182 struct discovery_state *d = &hdev->discovery; in process_adv_report()
6197 bt_dev_err_ratelimited(hdev, "unknown advertising packet " in process_adv_report()
6203 bt_dev_err_ratelimited(hdev, "legacy adv larger than 31 bytes"); in process_adv_report()
6228 if (!hci_dev_test_flag(hdev, HCI_MESH) && direct_addr) { in process_adv_report()
6229 direct_addr_type = ev_bdaddr_type(hdev, direct_addr_type, in process_adv_report()
6241 if (!hci_dev_test_flag(hdev, HCI_PRIVACY)) in process_adv_report()
6248 if (!smp_irk_matches(hdev, hdev->irk, direct_addr)) in process_adv_report()
6253 irk = hci_get_irk(hdev, bdaddr, bdaddr_type); in process_adv_report()
6259 bdaddr_type = ev_bdaddr_type(hdev, bdaddr_type, &bdaddr_resolved); in process_adv_report()
6266 conn = check_pending_le_conn(hdev, bdaddr, bdaddr_type, bdaddr_resolved, in process_adv_report()
6282 if (hci_dev_test_flag(hdev, HCI_MESH)) { in process_adv_report()
6283 mgmt_device_found(hdev, bdaddr, LE_LINK, bdaddr_type, NULL, 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()
6301 mgmt_device_found(hdev, bdaddr, LE_LINK, bdaddr_type, NULL, in process_adv_report()
6328 if (!ext_adv && !has_pending_adv_report(hdev)) { in process_adv_report()
6333 store_pending_adv_report(hdev, bdaddr, bdaddr_type, in process_adv_report()
6338 mgmt_device_found(hdev, bdaddr, LE_LINK, bdaddr_type, NULL, in process_adv_report()
6354 mgmt_device_found(hdev, &d->last_adv_addr, LE_LINK, in process_adv_report()
6365 store_pending_adv_report(hdev, bdaddr, bdaddr_type, in process_adv_report()
6373 clear_pending_adv_report(hdev); in process_adv_report()
6374 mgmt_device_found(hdev, bdaddr, LE_LINK, bdaddr_type, NULL, in process_adv_report()
6383 mgmt_device_found(hdev, &d->last_adv_addr, LE_LINK, in process_adv_report()
6386 clear_pending_adv_report(hdev); in process_adv_report()
6389 static void hci_le_adv_report_evt(struct hci_dev *hdev, void *data, in hci_le_adv_report_evt() argument
6398 hci_dev_lock(hdev); in hci_le_adv_report_evt()
6404 info = hci_le_ev_skb_pull(hdev, skb, in hci_le_adv_report_evt()
6410 if (!hci_le_ev_skb_pull(hdev, skb, HCI_EV_LE_ADVERTISING_REPORT, in hci_le_adv_report_evt()
6416 process_adv_report(hdev, info->type, &info->bdaddr, in hci_le_adv_report_evt()
6421 bt_dev_err(hdev, "Dropping invalid advertising data"); in hci_le_adv_report_evt()
6425 hci_dev_unlock(hdev); in hci_le_adv_report_evt()
6428 static u8 ext_evt_type_to_legacy(struct hci_dev *hdev, u16 evt_type) in ext_evt_type_to_legacy() argument
6466 bt_dev_err_ratelimited(hdev, "Unknown advertising packet type: 0x%02x", in ext_evt_type_to_legacy()
6472 static void hci_le_ext_adv_report_evt(struct hci_dev *hdev, void *data, in hci_le_ext_adv_report_evt() argument
6481 hci_dev_lock(hdev); in hci_le_ext_adv_report_evt()
6488 info = hci_le_ev_skb_pull(hdev, skb, HCI_EV_LE_EXT_ADV_REPORT, in hci_le_ext_adv_report_evt()
6493 if (!hci_le_ev_skb_pull(hdev, skb, HCI_EV_LE_EXT_ADV_REPORT, in hci_le_ext_adv_report_evt()
6498 legacy_evt_type = ext_evt_type_to_legacy(hdev, evt_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()
6508 hci_dev_unlock(hdev); in hci_le_ext_adv_report_evt()
6511 static int hci_le_pa_term_sync(struct hci_dev *hdev, __le16 handle) in hci_le_pa_term_sync() argument
6518 return hci_send_cmd(hdev, HCI_OP_LE_PA_TERM_SYNC, sizeof(cp), &cp); in hci_le_pa_term_sync()
6521 static void hci_le_pa_sync_estabilished_evt(struct hci_dev *hdev, void *data, in hci_le_pa_sync_estabilished_evt() argument
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()
6533 hci_dev_lock(hdev); in hci_le_pa_sync_estabilished_evt()
6535 hci_dev_clear_flag(hdev, HCI_PA_SYNC); 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()
6541 hci_dev_unlock(hdev); in hci_le_pa_sync_estabilished_evt()
6544 static void hci_le_remote_feat_complete_evt(struct hci_dev *hdev, void *data, in hci_le_remote_feat_complete_evt() argument
6550 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_remote_feat_complete_evt()
6552 hci_dev_lock(hdev); 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()
6572 (hdev->le_features[0] & HCI_LE_PERIPHERAL_FEATURES)) in hci_le_remote_feat_complete_evt()
6583 hci_dev_unlock(hdev); in hci_le_remote_feat_complete_evt()
6586 static void hci_le_ltk_request_evt(struct hci_dev *hdev, void *data, in hci_le_ltk_request_evt() argument
6595 bt_dev_dbg(hdev, "handle 0x%4.4x", __le16_to_cpu(ev->handle)); in hci_le_ltk_request_evt()
6597 hci_dev_lock(hdev); 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()
6625 hci_send_cmd(hdev, HCI_OP_LE_LTK_REPLY, sizeof(cp), &cp); in hci_le_ltk_request_evt()
6641 hci_dev_unlock(hdev); in hci_le_ltk_request_evt()
6647 hci_send_cmd(hdev, HCI_OP_LE_LTK_NEG_REPLY, sizeof(neg), &neg); in hci_le_ltk_request_evt()
6648 hci_dev_unlock(hdev); in hci_le_ltk_request_evt()
6651 static void send_conn_param_neg_reply(struct hci_dev *hdev, u16 handle, in send_conn_param_neg_reply() argument
6659 hci_send_cmd(hdev, HCI_OP_LE_CONN_PARAM_REQ_NEG_REPLY, sizeof(cp), in send_conn_param_neg_reply()
6663 static void hci_le_remote_conn_param_req_evt(struct hci_dev *hdev, void *data, in hci_le_remote_conn_param_req_evt() argument
6671 bt_dev_dbg(hdev, "handle 0x%4.4x", __le16_to_cpu(ev->handle)); in hci_le_remote_conn_param_req_evt()
6679 hcon = hci_conn_hash_lookup_handle(hdev, handle); in hci_le_remote_conn_param_req_evt()
6681 return send_conn_param_neg_reply(hdev, handle, in hci_le_remote_conn_param_req_evt()
6685 return send_conn_param_neg_reply(hdev, handle, in hci_le_remote_conn_param_req_evt()
6692 hci_dev_lock(hdev); 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()
6706 hci_dev_unlock(hdev); 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()
6720 hci_send_cmd(hdev, HCI_OP_LE_CONN_PARAM_REQ_REPLY, sizeof(cp), &cp); in hci_le_remote_conn_param_req_evt()
6723 static void hci_le_direct_adv_report_evt(struct hci_dev *hdev, void *data, in hci_le_direct_adv_report_evt() argument
6730 if (!hci_le_ev_skb_pull(hdev, skb, HCI_EV_LE_DIRECT_ADV_REPORT, in hci_le_direct_adv_report_evt()
6737 hci_dev_lock(hdev); in hci_le_direct_adv_report_evt()
6742 process_adv_report(hdev, info->type, &info->bdaddr, in hci_le_direct_adv_report_evt()
6748 hci_dev_unlock(hdev); in hci_le_direct_adv_report_evt()
6751 static void hci_le_phy_update_evt(struct hci_dev *hdev, void *data, in hci_le_phy_update_evt() argument
6757 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_phy_update_evt()
6762 hci_dev_lock(hdev); 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()
6772 hci_dev_unlock(hdev); in hci_le_phy_update_evt()
6775 static void hci_le_cis_estabilished_evt(struct hci_dev *hdev, void *data, in hci_le_cis_estabilished_evt() argument
6782 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_cis_estabilished_evt()
6784 hci_dev_lock(hdev); in hci_le_cis_estabilished_evt()
6786 conn = hci_conn_hash_lookup_handle(hdev, handle); in hci_le_cis_estabilished_evt()
6788 bt_dev_err(hdev, in hci_le_cis_estabilished_evt()
6795 bt_dev_err(hdev, in hci_le_cis_estabilished_evt()
6830 hci_dev_unlock(hdev); in hci_le_cis_estabilished_evt()
6833 static void hci_le_reject_cis(struct hci_dev *hdev, __le16 handle) in hci_le_reject_cis() argument
6840 hci_send_cmd(hdev, HCI_OP_LE_REJECT_CIS, sizeof(cp), &cp); in hci_le_reject_cis()
6843 static void hci_le_accept_cis(struct hci_dev *hdev, __le16 handle) in hci_le_accept_cis() argument
6849 hci_send_cmd(hdev, HCI_OP_LE_ACCEPT_CIS, sizeof(cp), &cp); in hci_le_accept_cis()
6852 static void hci_le_cis_req_evt(struct hci_dev *hdev, void *data, in hci_le_cis_req_evt() argument
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()
6867 hci_dev_lock(hdev); in hci_le_cis_req_evt()
6869 acl = hci_conn_hash_lookup_handle(hdev, acl_handle); 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()
6879 cis = hci_conn_hash_lookup_handle(hdev, 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()
6893 hci_le_accept_cis(hdev, ev->cis_handle); in hci_le_cis_req_evt()
6900 hci_dev_unlock(hdev); in hci_le_cis_req_evt()
6903 static void hci_le_create_big_complete_evt(struct hci_dev *hdev, void *data, in hci_le_create_big_complete_evt() argument
6909 BT_DBG("%s status 0x%2.2x", hdev->name, ev->status); in hci_le_create_big_complete_evt()
6911 if (!hci_le_ev_skb_pull(hdev, skb, HCI_EVT_LE_CREATE_BIG_COMPLETE, in hci_le_create_big_complete_evt()
6915 hci_dev_lock(hdev); in hci_le_create_big_complete_evt()
6917 conn = hci_conn_hash_lookup_big(hdev, ev->handle); in hci_le_create_big_complete_evt()
6922 bt_dev_err(hdev, in hci_le_create_big_complete_evt()
6943 hci_dev_unlock(hdev); in hci_le_create_big_complete_evt()
6946 static void hci_le_big_sync_established_evt(struct hci_dev *hdev, void *data, in hci_le_big_sync_established_evt() argument
6953 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_big_sync_established_evt()
6955 if (!hci_le_ev_skb_pull(hdev, skb, HCI_EVT_LE_BIG_SYNC_ESTABILISHED, in hci_le_big_sync_established_evt()
6962 hci_dev_lock(hdev); in hci_le_big_sync_established_evt()
6968 bis = hci_conn_hash_lookup_handle(hdev, handle); in hci_le_big_sync_established_evt()
6970 bis = hci_conn_add(hdev, ISO_LINK, BDADDR_ANY, in hci_le_big_sync_established_evt()
6988 hci_dev_unlock(hdev); in hci_le_big_sync_established_evt()
6991 static void hci_le_big_info_adv_report_evt(struct hci_dev *hdev, void *data, in hci_le_big_info_adv_report_evt() argument
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()
7000 hci_dev_lock(hdev); in hci_le_big_info_adv_report_evt()
7002 mask |= hci_proto_connect_ind(hdev, BDADDR_ANY, ISO_LINK, &flags); 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()
7006 hci_dev_unlock(hdev); in hci_le_big_info_adv_report_evt()
7028 void (*func)(struct hci_dev *hdev, void *data, struct sk_buff *skb);
7099 static void hci_le_meta_evt(struct hci_dev *hdev, void *data, in hci_le_meta_evt() argument
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()
7114 hci_req_cmd_complete(hdev, *opcode, 0x00, req_complete, in hci_le_meta_evt()
7123 bt_dev_err(hdev, "unexpected subevent 0x%2.2x length: %u < %u", in hci_le_meta_evt()
7133 bt_dev_warn(hdev, "unexpected subevent 0x%2.2x length: %u > %u", 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()
7142 static bool hci_get_cmd_complete(struct hci_dev *hdev, u16 opcode, in hci_get_cmd_complete() argument
7151 hdr = hci_ev_skb_pull(hdev, skb, event, sizeof(*hdr)); in hci_get_cmd_complete()
7168 bt_dev_err(hdev, "last event is not cmd complete (0x%2.2x)", in hci_get_cmd_complete()
7173 ev = hci_cc_skb_pull(hdev, skb, opcode, sizeof(*ev)); in hci_get_cmd_complete()
7186 static void hci_store_wake_reason(struct hci_dev *hdev, u8 event, in hci_store_wake_reason() argument
7195 hci_dev_lock(hdev); 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()
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()
7252 hci_dev_unlock(hdev); in hci_store_wake_reason()
7288 void (*func)(struct hci_dev *hdev, void *data,
7290 void (*func_req)(struct hci_dev *hdev, void *data,
7438 static void hci_event_func(struct hci_dev *hdev, u8 event, struct sk_buff *skb, in hci_event_func() argument
7450 bt_dev_err(hdev, "unexpected event 0x%2.2x length: %u < %u", in hci_event_func()
7460 bt_dev_warn_ratelimited(hdev, in hci_event_func()
7464 data = hci_ev_skb_pull(hdev, skb, event, ev->min_len); 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()
7475 void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb) in hci_event_packet() argument
7485 bt_dev_err(hdev, "Malformed HCI Event"); 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()
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()
7520 hci_store_wake_reason(hdev, event, skb); in hci_event_packet()
7522 bt_dev_dbg(hdev, "event 0x%2.2x", event); in hci_event_packet()
7524 hci_event_func(hdev, event, skb, &opcode, &status, &req_complete, in hci_event_packet()
7528 req_complete(hdev, status, opcode); in hci_event_packet()
7530 if (!hci_get_cmd_complete(hdev, opcode, req_evt, orig_skb)) { in hci_event_packet()
7534 req_complete_skb(hdev, status, opcode, orig_skb); in hci_event_packet()
7540 hdev->stat.evt_rx++; in hci_event_packet()