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(&params->action, &hdev->pend_le_conns); in hci_cs_disconnect()
2816 mgmt_device_disconnected(hdev, &conn->dst, conn->type, conn->dst_type, in hci_cs_disconnect()
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(&params->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()
3854 hci_dev_unlock(hdev); in hci_cc_le_set_cig_params()
3859 static u8 hci_cc_le_setup_iso_path(struct hci_dev *hdev, void *data, in hci_cc_le_setup_iso_path() argument
3866 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_setup_iso_path()
3868 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SETUP_ISO_PATH); in hci_cc_le_setup_iso_path()
3872 hci_dev_lock(hdev); in hci_cc_le_setup_iso_path()
3874 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cc_le_setup_iso_path()
3901 hci_dev_unlock(hdev); in hci_cc_le_setup_iso_path()
3905 static void hci_cs_le_create_big(struct hci_dev *hdev, u8 status) in hci_cs_le_create_big() argument
3907 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_le_create_big()
3910 static u8 hci_cc_set_per_adv_param(struct hci_dev *hdev, void *data, in hci_cc_set_per_adv_param() argument
3916 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_set_per_adv_param()
3921 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_PER_ADV_PARAMS); in hci_cc_set_per_adv_param()
3929 static u8 hci_cc_le_set_per_adv_enable(struct hci_dev *hdev, void *data, in hci_cc_le_set_per_adv_enable() argument
3935 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_per_adv_enable()
3940 sent = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_PER_ADV_ENABLE); in hci_cc_le_set_per_adv_enable()
3944 hci_dev_lock(hdev); in hci_cc_le_set_per_adv_enable()
3947 hci_dev_set_flag(hdev, HCI_LE_PER_ADV); in hci_cc_le_set_per_adv_enable()
3949 hci_dev_clear_flag(hdev, HCI_LE_PER_ADV); in hci_cc_le_set_per_adv_enable()
3951 hci_dev_unlock(hdev); in hci_cc_le_set_per_adv_enable()
3972 u8 (*func)(struct hci_dev *hdev, void *data, struct sk_buff *skb);
4145 static u8 hci_cc_func(struct hci_dev *hdev, const struct hci_cc *cc, in hci_cc_func() argument
4151 bt_dev_err(hdev, "unexpected cc 0x%4.4x length: %u < %u", in hci_cc_func()
4161 bt_dev_warn(hdev, "unexpected cc 0x%4.4x length: %u > %u", in hci_cc_func()
4164 data = hci_cc_skb_pull(hdev, skb, cc->op, cc->min_len); in hci_cc_func()
4168 return cc->func(hdev, data, skb); in hci_cc_func()
4171 static void hci_cmd_complete_evt(struct hci_dev *hdev, void *data, in hci_cmd_complete_evt() argument
4181 bt_dev_dbg(hdev, "opcode 0x%4.4x", *opcode); in hci_cmd_complete_evt()
4185 *status = hci_cc_func(hdev, &hci_cc_table[i], skb); in hci_cmd_complete_evt()
4201 handle_cmd_cnt_and_timer(hdev, ev->ncmd); in hci_cmd_complete_evt()
4203 hci_req_cmd_complete(hdev, *opcode, *status, req_complete, in hci_cmd_complete_evt()
4206 if (hci_dev_test_flag(hdev, HCI_CMD_PENDING)) { in hci_cmd_complete_evt()
4207 bt_dev_err(hdev, in hci_cmd_complete_evt()
4212 if (atomic_read(&hdev->cmd_cnt) && !skb_queue_empty(&hdev->cmd_q)) in hci_cmd_complete_evt()
4213 queue_work(hdev->workqueue, &hdev->cmd_work); in hci_cmd_complete_evt()
4216 static void hci_cs_le_create_cis(struct hci_dev *hdev, u8 status) in hci_cs_le_create_cis() argument
4221 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_le_create_cis()
4226 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_CREATE_CIS); in hci_cs_le_create_cis()
4230 hci_dev_lock(hdev); in hci_cs_le_create_cis()
4239 conn = hci_conn_hash_lookup_handle(hdev, handle); in hci_cs_le_create_cis()
4247 hci_dev_unlock(hdev); in hci_cs_le_create_cis()
4258 void (*func)(struct hci_dev *hdev, __u8 status);
4284 static void hci_cmd_status_evt(struct hci_dev *hdev, void *data, in hci_cmd_status_evt() argument
4295 bt_dev_dbg(hdev, "opcode 0x%4.4x", *opcode); in hci_cmd_status_evt()
4299 hci_cs_table[i].func(hdev, ev->status); in hci_cmd_status_evt()
4304 handle_cmd_cnt_and_timer(hdev, ev->ncmd); in hci_cmd_status_evt()
4312 if (ev->status || (hdev->sent_cmd && !hci_skb_event(hdev->sent_cmd))) { in hci_cmd_status_evt()
4313 hci_req_cmd_complete(hdev, *opcode, ev->status, req_complete, in hci_cmd_status_evt()
4315 if (hci_dev_test_flag(hdev, HCI_CMD_PENDING)) { in hci_cmd_status_evt()
4316 bt_dev_err(hdev, "unexpected event for opcode 0x%4.4x", in hci_cmd_status_evt()
4322 if (atomic_read(&hdev->cmd_cnt) && !skb_queue_empty(&hdev->cmd_q)) in hci_cmd_status_evt()
4323 queue_work(hdev->workqueue, &hdev->cmd_work); in hci_cmd_status_evt()
4326 static void hci_hardware_error_evt(struct hci_dev *hdev, void *data, in hci_hardware_error_evt() argument
4331 bt_dev_dbg(hdev, "code 0x%2.2x", ev->code); in hci_hardware_error_evt()
4333 hdev->hw_error_code = ev->code; in hci_hardware_error_evt()
4335 queue_work(hdev->req_workqueue, &hdev->error_reset); in hci_hardware_error_evt()
4338 static void hci_role_change_evt(struct hci_dev *hdev, void *data, in hci_role_change_evt() argument
4344 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_role_change_evt()
4346 hci_dev_lock(hdev); in hci_role_change_evt()
4348 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_role_change_evt()
4358 hci_dev_unlock(hdev); in hci_role_change_evt()
4361 static void hci_num_comp_pkts_evt(struct hci_dev *hdev, void *data, in hci_num_comp_pkts_evt() argument
4367 if (!hci_ev_skb_pull(hdev, skb, HCI_EV_NUM_COMP_PKTS, in hci_num_comp_pkts_evt()
4371 if (hdev->flow_ctl_mode != HCI_FLOW_CTL_MODE_PACKET_BASED) { in hci_num_comp_pkts_evt()
4372 bt_dev_err(hdev, "wrong event for mode %d", hdev->flow_ctl_mode); in hci_num_comp_pkts_evt()
4376 bt_dev_dbg(hdev, "num %d", ev->num); in hci_num_comp_pkts_evt()
4386 conn = hci_conn_hash_lookup_handle(hdev, handle); in hci_num_comp_pkts_evt()
4394 hdev->acl_cnt += count; in hci_num_comp_pkts_evt()
4395 if (hdev->acl_cnt > hdev->acl_pkts) in hci_num_comp_pkts_evt()
4396 hdev->acl_cnt = hdev->acl_pkts; in hci_num_comp_pkts_evt()
4400 if (hdev->le_pkts) { in hci_num_comp_pkts_evt()
4401 hdev->le_cnt += count; in hci_num_comp_pkts_evt()
4402 if (hdev->le_cnt > hdev->le_pkts) in hci_num_comp_pkts_evt()
4403 hdev->le_cnt = hdev->le_pkts; in hci_num_comp_pkts_evt()
4405 hdev->acl_cnt += count; in hci_num_comp_pkts_evt()
4406 if (hdev->acl_cnt > hdev->acl_pkts) in hci_num_comp_pkts_evt()
4407 hdev->acl_cnt = hdev->acl_pkts; in hci_num_comp_pkts_evt()
4412 hdev->sco_cnt += count; in hci_num_comp_pkts_evt()
4413 if (hdev->sco_cnt > hdev->sco_pkts) in hci_num_comp_pkts_evt()
4414 hdev->sco_cnt = hdev->sco_pkts; in hci_num_comp_pkts_evt()
4418 if (hdev->iso_pkts) { in hci_num_comp_pkts_evt()
4419 hdev->iso_cnt += count; in hci_num_comp_pkts_evt()
4420 if (hdev->iso_cnt > hdev->iso_pkts) in hci_num_comp_pkts_evt()
4421 hdev->iso_cnt = hdev->iso_pkts; in hci_num_comp_pkts_evt()
4422 } else if (hdev->le_pkts) { in hci_num_comp_pkts_evt()
4423 hdev->le_cnt += count; in hci_num_comp_pkts_evt()
4424 if (hdev->le_cnt > hdev->le_pkts) in hci_num_comp_pkts_evt()
4425 hdev->le_cnt = hdev->le_pkts; in hci_num_comp_pkts_evt()
4427 hdev->acl_cnt += count; in hci_num_comp_pkts_evt()
4428 if (hdev->acl_cnt > hdev->acl_pkts) in hci_num_comp_pkts_evt()
4429 hdev->acl_cnt = hdev->acl_pkts; in hci_num_comp_pkts_evt()
4434 bt_dev_err(hdev, "unknown type %d conn %p", in hci_num_comp_pkts_evt()
4440 queue_work(hdev->workqueue, &hdev->tx_work); in hci_num_comp_pkts_evt()
4443 static struct hci_conn *__hci_conn_lookup_handle(struct hci_dev *hdev, in __hci_conn_lookup_handle() argument
4448 switch (hdev->dev_type) { in __hci_conn_lookup_handle()
4450 return hci_conn_hash_lookup_handle(hdev, handle); in __hci_conn_lookup_handle()
4452 chan = hci_chan_lookup_handle(hdev, handle); in __hci_conn_lookup_handle()
4457 bt_dev_err(hdev, "unknown dev_type %d", hdev->dev_type); in __hci_conn_lookup_handle()
4464 static void hci_num_comp_blocks_evt(struct hci_dev *hdev, void *data, in hci_num_comp_blocks_evt() argument
4470 if (!hci_ev_skb_pull(hdev, skb, HCI_EV_NUM_COMP_BLOCKS, in hci_num_comp_blocks_evt()
4474 if (hdev->flow_ctl_mode != HCI_FLOW_CTL_MODE_BLOCK_BASED) { in hci_num_comp_blocks_evt()
4475 bt_dev_err(hdev, "wrong event for mode %d", in hci_num_comp_blocks_evt()
4476 hdev->flow_ctl_mode); in hci_num_comp_blocks_evt()
4480 bt_dev_dbg(hdev, "num_blocks %d num_hndl %d", ev->num_blocks, in hci_num_comp_blocks_evt()
4491 conn = __hci_conn_lookup_handle(hdev, handle); in hci_num_comp_blocks_evt()
4500 hdev->block_cnt += block_count; in hci_num_comp_blocks_evt()
4501 if (hdev->block_cnt > hdev->num_blocks) in hci_num_comp_blocks_evt()
4502 hdev->block_cnt = hdev->num_blocks; in hci_num_comp_blocks_evt()
4506 bt_dev_err(hdev, "unknown type %d conn %p", in hci_num_comp_blocks_evt()
4512 queue_work(hdev->workqueue, &hdev->tx_work); in hci_num_comp_blocks_evt()
4515 static void hci_mode_change_evt(struct hci_dev *hdev, void *data, in hci_mode_change_evt() argument
4521 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_mode_change_evt()
4523 hci_dev_lock(hdev); in hci_mode_change_evt()
4525 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_mode_change_evt()
4541 hci_dev_unlock(hdev); in hci_mode_change_evt()
4544 static void hci_pin_code_request_evt(struct hci_dev *hdev, void *data, in hci_pin_code_request_evt() argument
4550 bt_dev_dbg(hdev, ""); in hci_pin_code_request_evt()
4552 hci_dev_lock(hdev); in hci_pin_code_request_evt()
4554 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_pin_code_request_evt()
4564 if (!hci_dev_test_flag(hdev, HCI_BONDABLE) && in hci_pin_code_request_evt()
4566 hci_send_cmd(hdev, HCI_OP_PIN_CODE_NEG_REPLY, in hci_pin_code_request_evt()
4568 } else if (hci_dev_test_flag(hdev, HCI_MGMT)) { in hci_pin_code_request_evt()
4576 mgmt_pin_code_request(hdev, &ev->bdaddr, secure); in hci_pin_code_request_evt()
4580 hci_dev_unlock(hdev); in hci_pin_code_request_evt()
4615 static void hci_link_key_request_evt(struct hci_dev *hdev, void *data, in hci_link_key_request_evt() argument
4623 bt_dev_dbg(hdev, ""); in hci_link_key_request_evt()
4625 if (!hci_dev_test_flag(hdev, HCI_MGMT)) in hci_link_key_request_evt()
4628 hci_dev_lock(hdev); in hci_link_key_request_evt()
4630 key = hci_find_link_key(hdev, &ev->bdaddr); in hci_link_key_request_evt()
4632 bt_dev_dbg(hdev, "link key not found for %pMR", &ev->bdaddr); in hci_link_key_request_evt()
4636 bt_dev_dbg(hdev, "found key type %u for %pMR", key->type, &ev->bdaddr); in hci_link_key_request_evt()
4638 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_link_key_request_evt()
4645 bt_dev_dbg(hdev, "ignoring unauthenticated key"); in hci_link_key_request_evt()
4652 bt_dev_dbg(hdev, "ignoring key unauthenticated for high security"); in hci_link_key_request_evt()
4662 hci_send_cmd(hdev, HCI_OP_LINK_KEY_REPLY, sizeof(cp), &cp); in hci_link_key_request_evt()
4664 hci_dev_unlock(hdev); in hci_link_key_request_evt()
4669 hci_send_cmd(hdev, HCI_OP_LINK_KEY_NEG_REPLY, 6, &ev->bdaddr); in hci_link_key_request_evt()
4670 hci_dev_unlock(hdev); in hci_link_key_request_evt()
4673 static void hci_link_key_notify_evt(struct hci_dev *hdev, void *data, in hci_link_key_notify_evt() argument
4682 bt_dev_dbg(hdev, ""); in hci_link_key_notify_evt()
4684 hci_dev_lock(hdev); in hci_link_key_notify_evt()
4686 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_link_key_notify_evt()
4697 if (!hci_dev_test_flag(hdev, HCI_MGMT)) in hci_link_key_notify_evt()
4700 key = hci_add_link_key(hdev, conn, &ev->bdaddr, ev->link_key, in hci_link_key_notify_evt()
4711 mgmt_new_link_key(hdev, key, persistent); in hci_link_key_notify_evt()
4719 !hci_dev_test_flag(hdev, HCI_KEEP_DEBUG_KEYS)) { in hci_link_key_notify_evt()
4731 hci_dev_unlock(hdev); in hci_link_key_notify_evt()
4734 static void hci_clock_offset_evt(struct hci_dev *hdev, void *data, in hci_clock_offset_evt() argument
4740 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_clock_offset_evt()
4742 hci_dev_lock(hdev); in hci_clock_offset_evt()
4744 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_clock_offset_evt()
4748 ie = hci_inquiry_cache_lookup(hdev, &conn->dst); in hci_clock_offset_evt()
4755 hci_dev_unlock(hdev); in hci_clock_offset_evt()
4758 static void hci_pkt_type_change_evt(struct hci_dev *hdev, void *data, in hci_pkt_type_change_evt() argument
4764 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_pkt_type_change_evt()
4766 hci_dev_lock(hdev); in hci_pkt_type_change_evt()
4768 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_pkt_type_change_evt()
4772 hci_dev_unlock(hdev); in hci_pkt_type_change_evt()
4775 static void hci_pscan_rep_mode_evt(struct hci_dev *hdev, void *data, in hci_pscan_rep_mode_evt() argument
4781 bt_dev_dbg(hdev, ""); in hci_pscan_rep_mode_evt()
4783 hci_dev_lock(hdev); in hci_pscan_rep_mode_evt()
4785 ie = hci_inquiry_cache_lookup(hdev, &ev->bdaddr); in hci_pscan_rep_mode_evt()
4791 hci_dev_unlock(hdev); in hci_pscan_rep_mode_evt()
4794 static void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, void *edata, in hci_inquiry_result_with_rssi_evt() argument
4801 bt_dev_dbg(hdev, "num_rsp %d", ev->num); in hci_inquiry_result_with_rssi_evt()
4806 if (hci_dev_test_flag(hdev, HCI_PERIODIC_INQ)) in hci_inquiry_result_with_rssi_evt()
4809 hci_dev_lock(hdev); in hci_inquiry_result_with_rssi_evt()
4818 info = hci_ev_skb_pull(hdev, skb, in hci_inquiry_result_with_rssi_evt()
4822 bt_dev_err(hdev, "Malformed HCI Event: 0x%2.2x", in hci_inquiry_result_with_rssi_evt()
4836 flags = hci_inquiry_cache_update(hdev, &data, false); in hci_inquiry_result_with_rssi_evt()
4838 mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, in hci_inquiry_result_with_rssi_evt()
4849 info = hci_ev_skb_pull(hdev, skb, in hci_inquiry_result_with_rssi_evt()
4853 bt_dev_err(hdev, "Malformed HCI Event: 0x%2.2x", in hci_inquiry_result_with_rssi_evt()
4867 flags = hci_inquiry_cache_update(hdev, &data, false); in hci_inquiry_result_with_rssi_evt()
4869 mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, in hci_inquiry_result_with_rssi_evt()
4874 bt_dev_err(hdev, "Malformed HCI Event: 0x%2.2x", in hci_inquiry_result_with_rssi_evt()
4878 hci_dev_unlock(hdev); in hci_inquiry_result_with_rssi_evt()
4881 static void hci_remote_ext_features_evt(struct hci_dev *hdev, void *data, in hci_remote_ext_features_evt() argument
4887 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_remote_ext_features_evt()
4889 hci_dev_lock(hdev); in hci_remote_ext_features_evt()
4891 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_remote_ext_features_evt()
4901 ie = hci_inquiry_cache_lookup(hdev, &conn->dst); in hci_remote_ext_features_evt()
4931 hci_send_cmd(hdev, HCI_OP_REMOTE_NAME_REQ, sizeof(cp), &cp); in hci_remote_ext_features_evt()
4933 mgmt_device_connected(hdev, conn, NULL, 0); in hci_remote_ext_features_evt()
4935 if (!hci_outgoing_auth_needed(hdev, conn)) { in hci_remote_ext_features_evt()
4942 hci_dev_unlock(hdev); in hci_remote_ext_features_evt()
4945 static void hci_sync_conn_complete_evt(struct hci_dev *hdev, void *data, in hci_sync_conn_complete_evt() argument
4961 bt_dev_err(hdev, "Ignoring connect complete event for invalid link type"); in hci_sync_conn_complete_evt()
4965 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_sync_conn_complete_evt()
4967 hci_dev_lock(hdev); in hci_sync_conn_complete_evt()
4969 conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, &ev->bdaddr); in hci_sync_conn_complete_evt()
4983 conn = hci_conn_hash_lookup_ba(hdev, ESCO_LINK, &ev->bdaddr); in hci_sync_conn_complete_evt()
4995 bt_dev_err(hdev, "Ignoring HCI_Sync_Conn_Complete event for existing connection"); in hci_sync_conn_complete_evt()
5003 bt_dev_err(hdev, "Invalid handle: 0x%4.4x > 0x%4.4x", in hci_sync_conn_complete_evt()
5026 conn->pkt_type = (hdev->esco_type & SCO_ESCO_MASK) | in hci_sync_conn_complete_evt()
5027 (hdev->esco_type & EDR_ESCO_MASK); in hci_sync_conn_complete_evt()
5038 bt_dev_dbg(hdev, "SCO connected with air mode: %02x", ev->air_mode); in hci_sync_conn_complete_evt()
5042 if (conn->codec.data_path == 0 && hdev->notify) { in hci_sync_conn_complete_evt()
5045 hdev->notify(hdev, HCI_NOTIFY_ENABLE_SCO_CVSD); in hci_sync_conn_complete_evt()
5048 hdev->notify(hdev, HCI_NOTIFY_ENABLE_SCO_TRANSP); in hci_sync_conn_complete_evt()
5058 hci_dev_unlock(hdev); in hci_sync_conn_complete_evt()
5078 static void hci_extended_inquiry_result_evt(struct hci_dev *hdev, void *edata, in hci_extended_inquiry_result_evt() argument
5086 if (!hci_ev_skb_pull(hdev, skb, HCI_EV_EXTENDED_INQUIRY_RESULT, in hci_extended_inquiry_result_evt()
5090 bt_dev_dbg(hdev, "num %d", ev->num); in hci_extended_inquiry_result_evt()
5095 if (hci_dev_test_flag(hdev, HCI_PERIODIC_INQ)) in hci_extended_inquiry_result_evt()
5098 hci_dev_lock(hdev); in hci_extended_inquiry_result_evt()
5114 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_extended_inquiry_result_evt()
5121 flags = hci_inquiry_cache_update(hdev, &data, name_known); in hci_extended_inquiry_result_evt()
5125 mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, in hci_extended_inquiry_result_evt()
5130 hci_dev_unlock(hdev); in hci_extended_inquiry_result_evt()
5133 static void hci_key_refresh_complete_evt(struct hci_dev *hdev, void *data, in hci_key_refresh_complete_evt() argument
5139 bt_dev_dbg(hdev, "status 0x%2.2x handle 0x%4.4x", ev->status, in hci_key_refresh_complete_evt()
5142 hci_dev_lock(hdev); in hci_key_refresh_complete_evt()
5144 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_key_refresh_complete_evt()
5180 hci_dev_unlock(hdev); in hci_key_refresh_complete_evt()
5203 struct hci_dev *hdev = conn->hdev; in bredr_oob_data_present() local
5206 data = hci_find_remote_oob_data(hdev, &conn->dst, BDADDR_BREDR); in bredr_oob_data_present()
5210 if (bredr_sc_enabled(hdev)) { in bredr_oob_data_present()
5217 if (!hci_dev_test_flag(hdev, HCI_SC_ONLY)) in bredr_oob_data_present()
5243 static void hci_io_capa_request_evt(struct hci_dev *hdev, void *data, in hci_io_capa_request_evt() argument
5249 bt_dev_dbg(hdev, ""); in hci_io_capa_request_evt()
5251 hci_dev_lock(hdev); in hci_io_capa_request_evt()
5253 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_io_capa_request_evt()
5259 if (!hci_dev_test_flag(hdev, HCI_MGMT)) in hci_io_capa_request_evt()
5265 if (hci_dev_test_flag(hdev, HCI_BONDABLE) || in hci_io_capa_request_evt()
5291 if (!hci_dev_test_flag(hdev, HCI_BONDABLE)) in hci_io_capa_request_evt()
5297 hci_send_cmd(hdev, HCI_OP_IO_CAPABILITY_REPLY, in hci_io_capa_request_evt()
5305 hci_send_cmd(hdev, HCI_OP_IO_CAPABILITY_NEG_REPLY, in hci_io_capa_request_evt()
5310 hci_dev_unlock(hdev); in hci_io_capa_request_evt()
5313 static void hci_io_capa_reply_evt(struct hci_dev *hdev, void *data, in hci_io_capa_reply_evt() argument
5319 bt_dev_dbg(hdev, ""); in hci_io_capa_reply_evt()
5321 hci_dev_lock(hdev); in hci_io_capa_reply_evt()
5323 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_io_capa_reply_evt()
5331 hci_dev_unlock(hdev); in hci_io_capa_reply_evt()
5334 static void hci_user_confirm_request_evt(struct hci_dev *hdev, void *data, in hci_user_confirm_request_evt() argument
5341 bt_dev_dbg(hdev, ""); in hci_user_confirm_request_evt()
5343 hci_dev_lock(hdev); in hci_user_confirm_request_evt()
5345 if (!hci_dev_test_flag(hdev, HCI_MGMT)) in hci_user_confirm_request_evt()
5348 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_user_confirm_request_evt()
5362 bt_dev_dbg(hdev, "Rejecting request: remote device can't provide MITM"); in hci_user_confirm_request_evt()
5363 hci_send_cmd(hdev, HCI_OP_USER_CONFIRM_NEG_REPLY, in hci_user_confirm_request_evt()
5381 bt_dev_dbg(hdev, "Confirming auto-accept as acceptor"); in hci_user_confirm_request_evt()
5390 if (hci_find_link_key(hdev, &ev->bdaddr)) { in hci_user_confirm_request_evt()
5391 bt_dev_dbg(hdev, "Local host already has link key"); in hci_user_confirm_request_evt()
5397 hdev->auto_accept_delay); in hci_user_confirm_request_evt()
5399 if (hdev->auto_accept_delay > 0) { in hci_user_confirm_request_evt()
5400 int delay = msecs_to_jiffies(hdev->auto_accept_delay); in hci_user_confirm_request_evt()
5401 queue_delayed_work(conn->hdev->workqueue, in hci_user_confirm_request_evt()
5406 hci_send_cmd(hdev, HCI_OP_USER_CONFIRM_REPLY, in hci_user_confirm_request_evt()
5412 mgmt_user_confirm_request(hdev, &ev->bdaddr, ACL_LINK, 0, in hci_user_confirm_request_evt()
5416 hci_dev_unlock(hdev); in hci_user_confirm_request_evt()
5419 static void hci_user_passkey_request_evt(struct hci_dev *hdev, void *data, in hci_user_passkey_request_evt() argument
5424 bt_dev_dbg(hdev, ""); in hci_user_passkey_request_evt()
5426 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_user_passkey_request_evt()
5427 mgmt_user_passkey_request(hdev, &ev->bdaddr, ACL_LINK, 0); in hci_user_passkey_request_evt()
5430 static void hci_user_passkey_notify_evt(struct hci_dev *hdev, void *data, in hci_user_passkey_notify_evt() argument
5436 bt_dev_dbg(hdev, ""); in hci_user_passkey_notify_evt()
5438 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_user_passkey_notify_evt()
5445 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_user_passkey_notify_evt()
5446 mgmt_user_passkey_notify(hdev, &conn->dst, conn->type, in hci_user_passkey_notify_evt()
5451 static void hci_keypress_notify_evt(struct hci_dev *hdev, void *data, in hci_keypress_notify_evt() argument
5457 bt_dev_dbg(hdev, ""); in hci_keypress_notify_evt()
5459 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_keypress_notify_evt()
5484 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_keypress_notify_evt()
5485 mgmt_user_passkey_notify(hdev, &conn->dst, conn->type, in hci_keypress_notify_evt()
5490 static void hci_simple_pair_complete_evt(struct hci_dev *hdev, void *data, in hci_simple_pair_complete_evt() argument
5496 bt_dev_dbg(hdev, ""); in hci_simple_pair_complete_evt()
5498 hci_dev_lock(hdev); in hci_simple_pair_complete_evt()
5500 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_simple_pair_complete_evt()
5518 hci_dev_unlock(hdev); in hci_simple_pair_complete_evt()
5521 static void hci_remote_host_features_evt(struct hci_dev *hdev, void *data, in hci_remote_host_features_evt() argument
5528 bt_dev_dbg(hdev, ""); in hci_remote_host_features_evt()
5530 hci_dev_lock(hdev); in hci_remote_host_features_evt()
5532 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_remote_host_features_evt()
5536 ie = hci_inquiry_cache_lookup(hdev, &ev->bdaddr); in hci_remote_host_features_evt()
5540 hci_dev_unlock(hdev); in hci_remote_host_features_evt()
5543 static void hci_remote_oob_data_request_evt(struct hci_dev *hdev, void *edata, in hci_remote_oob_data_request_evt() argument
5549 bt_dev_dbg(hdev, ""); in hci_remote_oob_data_request_evt()
5551 hci_dev_lock(hdev); in hci_remote_oob_data_request_evt()
5553 if (!hci_dev_test_flag(hdev, HCI_MGMT)) in hci_remote_oob_data_request_evt()
5556 data = hci_find_remote_oob_data(hdev, &ev->bdaddr, BDADDR_BREDR); in hci_remote_oob_data_request_evt()
5561 hci_send_cmd(hdev, HCI_OP_REMOTE_OOB_DATA_NEG_REPLY, in hci_remote_oob_data_request_evt()
5566 if (bredr_sc_enabled(hdev)) { in hci_remote_oob_data_request_evt()
5570 if (hci_dev_test_flag(hdev, HCI_SC_ONLY)) { in hci_remote_oob_data_request_evt()
5580 hci_send_cmd(hdev, HCI_OP_REMOTE_OOB_EXT_DATA_REPLY, in hci_remote_oob_data_request_evt()
5589 hci_send_cmd(hdev, HCI_OP_REMOTE_OOB_DATA_REPLY, in hci_remote_oob_data_request_evt()
5594 hci_dev_unlock(hdev); in hci_remote_oob_data_request_evt()
5598 static void hci_chan_selected_evt(struct hci_dev *hdev, void *data, in hci_chan_selected_evt() argument
5604 bt_dev_dbg(hdev, "handle 0x%2.2x", ev->phy_handle); in hci_chan_selected_evt()
5606 hcon = hci_conn_hash_lookup_handle(hdev, ev->phy_handle); in hci_chan_selected_evt()
5610 amp_read_loc_assoc_final_data(hdev, hcon); in hci_chan_selected_evt()
5613 static void hci_phy_link_complete_evt(struct hci_dev *hdev, void *data, in hci_phy_link_complete_evt() argument
5619 bt_dev_dbg(hdev, "handle 0x%2.2x status 0x%2.2x", ev->phy_handle, in hci_phy_link_complete_evt()
5622 hci_dev_lock(hdev); in hci_phy_link_complete_evt()
5624 hcon = hci_conn_hash_lookup_handle(hdev, ev->phy_handle); in hci_phy_link_complete_evt()
5651 hci_dev_unlock(hdev); in hci_phy_link_complete_evt()
5654 static void hci_loglink_complete_evt(struct hci_dev *hdev, void *data, in hci_loglink_complete_evt() argument
5662 bt_dev_dbg(hdev, "log_handle 0x%4.4x phy_handle 0x%2.2x status 0x%2.2x", in hci_loglink_complete_evt()
5665 hcon = hci_conn_hash_lookup_handle(hdev, ev->phy_handle); in hci_loglink_complete_evt()
5685 bredr_chan->conn->mtu = hdev->block_mtu; in hci_loglink_complete_evt()
5693 static void hci_disconn_loglink_complete_evt(struct hci_dev *hdev, void *data, in hci_disconn_loglink_complete_evt() argument
5699 bt_dev_dbg(hdev, "handle 0x%4.4x status 0x%2.2x", in hci_disconn_loglink_complete_evt()
5705 hci_dev_lock(hdev); in hci_disconn_loglink_complete_evt()
5707 hchan = hci_chan_lookup_handle(hdev, le16_to_cpu(ev->handle)); in hci_disconn_loglink_complete_evt()
5714 hci_dev_unlock(hdev); in hci_disconn_loglink_complete_evt()
5717 static void hci_disconn_phylink_complete_evt(struct hci_dev *hdev, void *data, in hci_disconn_phylink_complete_evt() argument
5723 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_disconn_phylink_complete_evt()
5728 hci_dev_lock(hdev); in hci_disconn_phylink_complete_evt()
5730 hcon = hci_conn_hash_lookup_handle(hdev, ev->phy_handle); in hci_disconn_phylink_complete_evt()
5737 hci_dev_unlock(hdev); in hci_disconn_phylink_complete_evt()
5755 } else if (hci_dev_test_flag(conn->hdev, HCI_PRIVACY)) { in le_conn_update_addr()
5757 bacpy(&conn->init_addr, &conn->hdev->rpa); in le_conn_update_addr()
5759 hci_copy_identity_address(conn->hdev, &conn->init_addr, in le_conn_update_addr()
5763 conn->resp_addr_type = conn->hdev->adv_addr_type; in le_conn_update_addr()
5770 } else if (conn->hdev->adv_addr_type == ADDR_LE_DEV_RANDOM) { in le_conn_update_addr()
5774 if (!ext_adv_capable(conn->hdev)) in le_conn_update_addr()
5776 &conn->hdev->random_addr); in le_conn_update_addr()
5778 bacpy(&conn->resp_addr, &conn->hdev->bdaddr); in le_conn_update_addr()
5789 conn->le_conn_min_interval = conn->hdev->le_conn_min_interval; in le_conn_update_addr()
5790 conn->le_conn_max_interval = conn->hdev->le_conn_max_interval; in le_conn_update_addr()
5794 static void le_conn_complete_evt(struct hci_dev *hdev, u8 status, in le_conn_complete_evt() argument
5805 hci_dev_lock(hdev); in le_conn_complete_evt()
5810 hci_dev_clear_flag(hdev, HCI_LE_ADV); in le_conn_complete_evt()
5812 conn = hci_conn_hash_lookup_ba(hdev, LE_LINK, bdaddr); in le_conn_complete_evt()
5820 conn = hci_conn_add(hdev, LE_LINK, bdaddr, role); in le_conn_complete_evt()
5822 bt_dev_err(hdev, "no memory for new connection"); in le_conn_complete_evt()
5839 if (hci_dev_test_flag(hdev, HCI_PRIVACY)) { in le_conn_complete_evt()
5841 bacpy(&conn->init_addr, &hdev->rpa); in le_conn_complete_evt()
5843 hci_copy_identity_address(hdev, in le_conn_complete_evt()
5859 bt_dev_err(hdev, "Ignoring HCI_Connection_Complete for existing connection"); in le_conn_complete_evt()
5874 irk = hci_get_irk(hdev, &conn->dst, conn->dst_type); in le_conn_complete_evt()
5880 conn->dst_type = ev_bdaddr_type(hdev, conn->dst_type, NULL); in le_conn_complete_evt()
5883 bt_dev_err(hdev, "Invalid handle: 0x%4.4x > 0x%4.4x", handle, in le_conn_complete_evt()
5901 if (hci_bdaddr_list_lookup(&hdev->reject_list, &conn->dst, addr_type)) { in le_conn_complete_evt()
5907 mgmt_device_connected(hdev, conn, NULL, 0); in le_conn_complete_evt()
5917 if (!ext_adv_capable(hdev)) in le_conn_complete_evt()
5918 conn->adv_instance = hdev->cur_adv_instance; in le_conn_complete_evt()
5937 (hdev->le_features[0] & HCI_LE_PERIPHERAL_FEATURES)) { in le_conn_complete_evt()
5942 hci_send_cmd(hdev, HCI_OP_LE_READ_REMOTE_FEATURES, in le_conn_complete_evt()
5951 params = hci_pend_le_action_lookup(&hdev->pend_le_conns, &conn->dst, in le_conn_complete_evt()
5963 hci_update_passive_scan(hdev); in le_conn_complete_evt()
5964 hci_dev_unlock(hdev); in le_conn_complete_evt()
5967 static void hci_le_conn_complete_evt(struct hci_dev *hdev, void *data, in hci_le_conn_complete_evt() argument
5972 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_conn_complete_evt()
5974 le_conn_complete_evt(hdev, ev->status, &ev->bdaddr, ev->bdaddr_type, in hci_le_conn_complete_evt()
5981 static void hci_le_enh_conn_complete_evt(struct hci_dev *hdev, void *data, in hci_le_enh_conn_complete_evt() argument
5986 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_enh_conn_complete_evt()
5988 le_conn_complete_evt(hdev, ev->status, &ev->bdaddr, ev->bdaddr_type, in hci_le_enh_conn_complete_evt()
5995 static void hci_le_ext_adv_term_evt(struct hci_dev *hdev, void *data, in hci_le_ext_adv_term_evt() argument
6002 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_ext_adv_term_evt()
6012 bt_dev_warn_ratelimited(hdev, "Unexpected advertising set terminated event"); in hci_le_ext_adv_term_evt()
6016 hci_dev_lock(hdev); in hci_le_ext_adv_term_evt()
6018 adv = hci_find_adv_instance(hdev, ev->handle); in hci_le_ext_adv_term_evt()
6025 hci_remove_adv_instance(hdev, ev->handle); in hci_le_ext_adv_term_evt()
6026 mgmt_advertising_removed(NULL, hdev, ev->handle); in hci_le_ext_adv_term_evt()
6028 list_for_each_entry_safe(adv, n, &hdev->adv_instances, list) { in hci_le_ext_adv_term_evt()
6034 hci_dev_clear_flag(hdev, HCI_LE_ADV); in hci_le_ext_adv_term_evt()
6041 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->conn_handle)); in hci_le_ext_adv_term_evt()
6048 if (hdev->adv_addr_type != ADDR_LE_DEV_RANDOM || in hci_le_ext_adv_term_evt()
6053 bacpy(&conn->resp_addr, &hdev->random_addr); in hci_le_ext_adv_term_evt()
6062 hci_dev_unlock(hdev); in hci_le_ext_adv_term_evt()
6065 static void hci_le_conn_update_complete_evt(struct hci_dev *hdev, void *data, in hci_le_conn_update_complete_evt() argument
6071 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_conn_update_complete_evt()
6076 hci_dev_lock(hdev); in hci_le_conn_update_complete_evt()
6078 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_conn_update_complete_evt()
6085 hci_dev_unlock(hdev); in hci_le_conn_update_complete_evt()
6089 static struct hci_conn *check_pending_le_conn(struct hci_dev *hdev, in check_pending_le_conn() argument
6102 if (hci_bdaddr_list_lookup(&hdev->reject_list, addr, addr_type) || in check_pending_le_conn()
6103 hdev->suspended) in check_pending_le_conn()
6109 if (hdev->conn_hash.le_num_peripheral > 0 && in check_pending_le_conn()
6110 (!test_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks) || in check_pending_le_conn()
6111 !(hdev->le_states[3] & 0x10))) in check_pending_le_conn()
6117 params = hci_pend_le_action_lookup(&hdev->pend_le_conns, addr, in check_pending_le_conn()
6145 conn = hci_connect_le(hdev, addr, addr_type, addr_resolved, in check_pending_le_conn()
6146 BT_SECURITY_LOW, hdev->def_le_autoconnect_timeout, in check_pending_le_conn()
6180 static void process_adv_report(struct hci_dev *hdev, u8 type, bdaddr_t *bdaddr, in process_adv_report() argument
6185 struct discovery_state *d = &hdev->discovery; in process_adv_report()
6200 bt_dev_err_ratelimited(hdev, "unknown advertising packet " in process_adv_report()
6206 bt_dev_err_ratelimited(hdev, "legacy adv larger than 31 bytes"); in process_adv_report()
6231 if (!hci_dev_test_flag(hdev, HCI_MESH) && direct_addr) { in process_adv_report()
6232 direct_addr_type = ev_bdaddr_type(hdev, direct_addr_type, in process_adv_report()
6244 if (!hci_dev_test_flag(hdev, HCI_PRIVACY)) in process_adv_report()
6251 if (!smp_irk_matches(hdev, hdev->irk, direct_addr)) in process_adv_report()
6256 irk = hci_get_irk(hdev, bdaddr, bdaddr_type); in process_adv_report()
6262 bdaddr_type = ev_bdaddr_type(hdev, bdaddr_type, &bdaddr_resolved); in process_adv_report()
6269 conn = check_pending_le_conn(hdev, bdaddr, bdaddr_type, bdaddr_resolved, in process_adv_report()
6285 if (hci_dev_test_flag(hdev, HCI_MESH)) { in process_adv_report()
6286 mgmt_device_found(hdev, bdaddr, LE_LINK, bdaddr_type, NULL, in process_adv_report()
6295 if (hdev->le_scan_type == LE_SCAN_PASSIVE) { in process_adv_report()
6299 if (!hci_pend_le_action_lookup(&hdev->pend_le_reports, in process_adv_report()
6301 idr_is_empty(&hdev->adv_monitors_idr)) in process_adv_report()
6304 mgmt_device_found(hdev, bdaddr, LE_LINK, bdaddr_type, NULL, in process_adv_report()
6331 if (!ext_adv && !has_pending_adv_report(hdev)) { in process_adv_report()
6336 store_pending_adv_report(hdev, bdaddr, bdaddr_type, in process_adv_report()
6341 mgmt_device_found(hdev, bdaddr, LE_LINK, bdaddr_type, NULL, in process_adv_report()
6357 mgmt_device_found(hdev, &d->last_adv_addr, LE_LINK, in process_adv_report()
6368 store_pending_adv_report(hdev, bdaddr, bdaddr_type, in process_adv_report()
6376 clear_pending_adv_report(hdev); in process_adv_report()
6377 mgmt_device_found(hdev, bdaddr, LE_LINK, bdaddr_type, NULL, in process_adv_report()
6386 mgmt_device_found(hdev, &d->last_adv_addr, LE_LINK, in process_adv_report()
6389 clear_pending_adv_report(hdev); in process_adv_report()
6392 static void hci_le_adv_report_evt(struct hci_dev *hdev, void *data, in hci_le_adv_report_evt() argument
6401 hci_dev_lock(hdev); in hci_le_adv_report_evt()
6407 info = hci_le_ev_skb_pull(hdev, skb, in hci_le_adv_report_evt()
6413 if (!hci_le_ev_skb_pull(hdev, skb, HCI_EV_LE_ADVERTISING_REPORT, in hci_le_adv_report_evt()
6419 process_adv_report(hdev, info->type, &info->bdaddr, in hci_le_adv_report_evt()
6424 bt_dev_err(hdev, "Dropping invalid advertising data"); in hci_le_adv_report_evt()
6428 hci_dev_unlock(hdev); in hci_le_adv_report_evt()
6431 static u8 ext_evt_type_to_legacy(struct hci_dev *hdev, u16 evt_type) in ext_evt_type_to_legacy() argument
6469 bt_dev_err_ratelimited(hdev, "Unknown advertising packet type: 0x%02x", in ext_evt_type_to_legacy()
6475 static void hci_le_ext_adv_report_evt(struct hci_dev *hdev, void *data, in hci_le_ext_adv_report_evt() argument
6484 hci_dev_lock(hdev); in hci_le_ext_adv_report_evt()
6491 info = hci_le_ev_skb_pull(hdev, skb, HCI_EV_LE_EXT_ADV_REPORT, in hci_le_ext_adv_report_evt()
6496 if (!hci_le_ev_skb_pull(hdev, skb, HCI_EV_LE_EXT_ADV_REPORT, in hci_le_ext_adv_report_evt()
6501 legacy_evt_type = ext_evt_type_to_legacy(hdev, evt_type); in hci_le_ext_adv_report_evt()
6503 process_adv_report(hdev, legacy_evt_type, &info->bdaddr, in hci_le_ext_adv_report_evt()
6511 hci_dev_unlock(hdev); in hci_le_ext_adv_report_evt()
6514 static int hci_le_pa_term_sync(struct hci_dev *hdev, __le16 handle) in hci_le_pa_term_sync() argument
6521 return hci_send_cmd(hdev, HCI_OP_LE_PA_TERM_SYNC, sizeof(cp), &cp); in hci_le_pa_term_sync()
6524 static void hci_le_pa_sync_estabilished_evt(struct hci_dev *hdev, void *data, in hci_le_pa_sync_estabilished_evt() argument
6528 int mask = hdev->link_mode; in hci_le_pa_sync_estabilished_evt()
6531 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_pa_sync_estabilished_evt()
6536 hci_dev_lock(hdev); in hci_le_pa_sync_estabilished_evt()
6538 hci_dev_clear_flag(hdev, HCI_PA_SYNC); in hci_le_pa_sync_estabilished_evt()
6540 mask |= hci_proto_connect_ind(hdev, &ev->bdaddr, ISO_LINK, &flags); in hci_le_pa_sync_estabilished_evt()
6542 hci_le_pa_term_sync(hdev, ev->handle); in hci_le_pa_sync_estabilished_evt()
6544 hci_dev_unlock(hdev); in hci_le_pa_sync_estabilished_evt()
6547 static void hci_le_remote_feat_complete_evt(struct hci_dev *hdev, void *data, in hci_le_remote_feat_complete_evt() argument
6553 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_remote_feat_complete_evt()
6555 hci_dev_lock(hdev); in hci_le_remote_feat_complete_evt()
6557 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_remote_feat_complete_evt()
6575 (hdev->le_features[0] & HCI_LE_PERIPHERAL_FEATURES)) in hci_le_remote_feat_complete_evt()
6586 hci_dev_unlock(hdev); in hci_le_remote_feat_complete_evt()
6589 static void hci_le_ltk_request_evt(struct hci_dev *hdev, void *data, in hci_le_ltk_request_evt() argument
6598 bt_dev_dbg(hdev, "handle 0x%4.4x", __le16_to_cpu(ev->handle)); in hci_le_ltk_request_evt()
6600 hci_dev_lock(hdev); in hci_le_ltk_request_evt()
6602 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_ltk_request_evt()
6606 ltk = hci_find_ltk(hdev, &conn->dst, conn->dst_type, conn->role); in hci_le_ltk_request_evt()
6628 hci_send_cmd(hdev, HCI_OP_LE_LTK_REPLY, sizeof(cp), &cp); in hci_le_ltk_request_evt()
6644 hci_dev_unlock(hdev); in hci_le_ltk_request_evt()
6650 hci_send_cmd(hdev, HCI_OP_LE_LTK_NEG_REPLY, sizeof(neg), &neg); in hci_le_ltk_request_evt()
6651 hci_dev_unlock(hdev); in hci_le_ltk_request_evt()
6654 static void send_conn_param_neg_reply(struct hci_dev *hdev, u16 handle, in send_conn_param_neg_reply() argument
6662 hci_send_cmd(hdev, HCI_OP_LE_CONN_PARAM_REQ_NEG_REPLY, sizeof(cp), in send_conn_param_neg_reply()
6666 static void hci_le_remote_conn_param_req_evt(struct hci_dev *hdev, void *data, in hci_le_remote_conn_param_req_evt() argument
6674 bt_dev_dbg(hdev, "handle 0x%4.4x", __le16_to_cpu(ev->handle)); in hci_le_remote_conn_param_req_evt()
6682 hcon = hci_conn_hash_lookup_handle(hdev, handle); in hci_le_remote_conn_param_req_evt()
6684 return send_conn_param_neg_reply(hdev, handle, in hci_le_remote_conn_param_req_evt()
6688 return send_conn_param_neg_reply(hdev, handle, in hci_le_remote_conn_param_req_evt()
6695 hci_dev_lock(hdev); in hci_le_remote_conn_param_req_evt()
6697 params = hci_conn_params_lookup(hdev, &hcon->dst, in hci_le_remote_conn_param_req_evt()
6709 hci_dev_unlock(hdev); in hci_le_remote_conn_param_req_evt()
6711 mgmt_new_conn_param(hdev, &hcon->dst, hcon->dst_type, in hci_le_remote_conn_param_req_evt()
6723 hci_send_cmd(hdev, HCI_OP_LE_CONN_PARAM_REQ_REPLY, sizeof(cp), &cp); in hci_le_remote_conn_param_req_evt()
6726 static void hci_le_direct_adv_report_evt(struct hci_dev *hdev, void *data, in hci_le_direct_adv_report_evt() argument
6733 if (!hci_le_ev_skb_pull(hdev, skb, HCI_EV_LE_DIRECT_ADV_REPORT, in hci_le_direct_adv_report_evt()
6740 hci_dev_lock(hdev); in hci_le_direct_adv_report_evt()
6745 process_adv_report(hdev, info->type, &info->bdaddr, in hci_le_direct_adv_report_evt()
6751 hci_dev_unlock(hdev); in hci_le_direct_adv_report_evt()
6754 static void hci_le_phy_update_evt(struct hci_dev *hdev, void *data, in hci_le_phy_update_evt() argument
6760 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_phy_update_evt()
6765 hci_dev_lock(hdev); in hci_le_phy_update_evt()
6767 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_phy_update_evt()
6775 hci_dev_unlock(hdev); in hci_le_phy_update_evt()
6778 static void hci_le_cis_estabilished_evt(struct hci_dev *hdev, void *data, in hci_le_cis_estabilished_evt() argument
6785 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_cis_estabilished_evt()
6787 hci_dev_lock(hdev); in hci_le_cis_estabilished_evt()
6789 conn = hci_conn_hash_lookup_handle(hdev, handle); in hci_le_cis_estabilished_evt()
6791 bt_dev_err(hdev, in hci_le_cis_estabilished_evt()
6798 bt_dev_err(hdev, in hci_le_cis_estabilished_evt()
6833 hci_dev_unlock(hdev); in hci_le_cis_estabilished_evt()
6836 static void hci_le_reject_cis(struct hci_dev *hdev, __le16 handle) in hci_le_reject_cis() argument
6843 hci_send_cmd(hdev, HCI_OP_LE_REJECT_CIS, sizeof(cp), &cp); in hci_le_reject_cis()
6846 static void hci_le_accept_cis(struct hci_dev *hdev, __le16 handle) in hci_le_accept_cis() argument
6852 hci_send_cmd(hdev, HCI_OP_LE_ACCEPT_CIS, sizeof(cp), &cp); in hci_le_accept_cis()
6855 static void hci_le_cis_req_evt(struct hci_dev *hdev, void *data, in hci_le_cis_req_evt() argument
6867 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()
6870 hci_dev_lock(hdev); in hci_le_cis_req_evt()
6872 acl = hci_conn_hash_lookup_handle(hdev, acl_handle); in hci_le_cis_req_evt()
6876 mask = hci_proto_connect_ind(hdev, &acl->dst, ISO_LINK, &flags); in hci_le_cis_req_evt()
6878 hci_le_reject_cis(hdev, ev->cis_handle); in hci_le_cis_req_evt()
6882 cis = hci_conn_hash_lookup_handle(hdev, cis_handle); in hci_le_cis_req_evt()
6884 cis = hci_conn_add(hdev, ISO_LINK, &acl->dst, HCI_ROLE_SLAVE); in hci_le_cis_req_evt()
6886 hci_le_reject_cis(hdev, ev->cis_handle); in hci_le_cis_req_evt()
6896 hci_le_accept_cis(hdev, ev->cis_handle); in hci_le_cis_req_evt()
6903 hci_dev_unlock(hdev); in hci_le_cis_req_evt()
6906 static void hci_le_create_big_complete_evt(struct hci_dev *hdev, void *data, in hci_le_create_big_complete_evt() argument
6912 BT_DBG("%s status 0x%2.2x", hdev->name, ev->status); in hci_le_create_big_complete_evt()
6914 if (!hci_le_ev_skb_pull(hdev, skb, HCI_EVT_LE_CREATE_BIG_COMPLETE, in hci_le_create_big_complete_evt()
6918 hci_dev_lock(hdev); in hci_le_create_big_complete_evt()
6920 conn = hci_conn_hash_lookup_big(hdev, ev->handle); in hci_le_create_big_complete_evt()
6925 bt_dev_err(hdev, in hci_le_create_big_complete_evt()
6946 hci_dev_unlock(hdev); in hci_le_create_big_complete_evt()
6949 static void hci_le_big_sync_established_evt(struct hci_dev *hdev, void *data, in hci_le_big_sync_established_evt() argument
6956 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_big_sync_established_evt()
6958 if (!hci_le_ev_skb_pull(hdev, skb, HCI_EVT_LE_BIG_SYNC_ESTABILISHED, in hci_le_big_sync_established_evt()
6965 hci_dev_lock(hdev); in hci_le_big_sync_established_evt()
6971 bis = hci_conn_hash_lookup_handle(hdev, handle); in hci_le_big_sync_established_evt()
6973 bis = hci_conn_add(hdev, ISO_LINK, BDADDR_ANY, in hci_le_big_sync_established_evt()
6991 hci_dev_unlock(hdev); in hci_le_big_sync_established_evt()
6994 static void hci_le_big_info_adv_report_evt(struct hci_dev *hdev, void *data, in hci_le_big_info_adv_report_evt() argument
6998 int mask = hdev->link_mode; in hci_le_big_info_adv_report_evt()
7001 bt_dev_dbg(hdev, "sync_handle 0x%4.4x", le16_to_cpu(ev->sync_handle)); in hci_le_big_info_adv_report_evt()
7003 hci_dev_lock(hdev); in hci_le_big_info_adv_report_evt()
7005 mask |= hci_proto_connect_ind(hdev, BDADDR_ANY, ISO_LINK, &flags); in hci_le_big_info_adv_report_evt()
7007 hci_le_pa_term_sync(hdev, ev->sync_handle); in hci_le_big_info_adv_report_evt()
7009 hci_dev_unlock(hdev); in hci_le_big_info_adv_report_evt()
7031 void (*func)(struct hci_dev *hdev, void *data, struct sk_buff *skb);
7102 static void hci_le_meta_evt(struct hci_dev *hdev, void *data, in hci_le_meta_evt() argument
7110 bt_dev_dbg(hdev, "subevent 0x%2.2x", ev->subevent); in hci_le_meta_evt()
7113 if (hdev->sent_cmd && in hci_le_meta_evt()
7114 hci_opcode_ogf(hci_skb_opcode(hdev->sent_cmd)) == 0x08 && in hci_le_meta_evt()
7115 hci_skb_event(hdev->sent_cmd) == ev->subevent) { in hci_le_meta_evt()
7116 *opcode = hci_skb_opcode(hdev->sent_cmd); in hci_le_meta_evt()
7117 hci_req_cmd_complete(hdev, *opcode, 0x00, req_complete, in hci_le_meta_evt()
7126 bt_dev_err(hdev, "unexpected subevent 0x%2.2x length: %u < %u", in hci_le_meta_evt()
7136 bt_dev_warn(hdev, "unexpected subevent 0x%2.2x length: %u > %u", in hci_le_meta_evt()
7138 data = hci_le_ev_skb_pull(hdev, skb, ev->subevent, subev->min_len); in hci_le_meta_evt()
7142 subev->func(hdev, data, skb); in hci_le_meta_evt()
7145 static bool hci_get_cmd_complete(struct hci_dev *hdev, u16 opcode, in hci_get_cmd_complete() argument
7154 hdr = hci_ev_skb_pull(hdev, skb, event, sizeof(*hdr)); in hci_get_cmd_complete()
7171 bt_dev_err(hdev, "last event is not cmd complete (0x%2.2x)", in hci_get_cmd_complete()
7176 ev = hci_cc_skb_pull(hdev, skb, opcode, sizeof(*ev)); in hci_get_cmd_complete()
7189 static void hci_store_wake_reason(struct hci_dev *hdev, u8 event, in hci_store_wake_reason() argument
7198 hci_dev_lock(hdev); in hci_store_wake_reason()
7203 if (!hdev->suspended || hdev->wake_reason) in hci_store_wake_reason()
7209 hdev->wake_reason = MGMT_WAKE_REASON_REMOTE_WAKE; in hci_store_wake_reason()
7216 bacpy(&hdev->wake_addr, &conn_complete->bdaddr); in hci_store_wake_reason()
7217 hdev->wake_addr_type = BDADDR_BREDR; in hci_store_wake_reason()
7219 bacpy(&hdev->wake_addr, &conn_request->bdaddr); in hci_store_wake_reason()
7220 hdev->wake_addr_type = BDADDR_BREDR; in hci_store_wake_reason()
7237 bacpy(&hdev->wake_addr, &adv->bdaddr); in hci_store_wake_reason()
7238 hdev->wake_addr_type = adv->bdaddr_type; in hci_store_wake_reason()
7241 bacpy(&hdev->wake_addr, &direct_adv->bdaddr); in hci_store_wake_reason()
7242 hdev->wake_addr_type = direct_adv->bdaddr_type; in hci_store_wake_reason()
7245 bacpy(&hdev->wake_addr, &ext_adv->bdaddr); in hci_store_wake_reason()
7246 hdev->wake_addr_type = ext_adv->bdaddr_type; in hci_store_wake_reason()
7251 hdev->wake_reason = MGMT_WAKE_REASON_UNEXPECTED; in hci_store_wake_reason()
7255 hci_dev_unlock(hdev); in hci_store_wake_reason()
7291 void (*func)(struct hci_dev *hdev, void *data,
7293 void (*func_req)(struct hci_dev *hdev, void *data,
7441 static void hci_event_func(struct hci_dev *hdev, u8 event, struct sk_buff *skb, in hci_event_func() argument
7453 bt_dev_err(hdev, "unexpected event 0x%2.2x length: %u < %u", in hci_event_func()
7463 bt_dev_warn_ratelimited(hdev, in hci_event_func()
7467 data = hci_ev_skb_pull(hdev, skb, event, ev->min_len); in hci_event_func()
7472 ev->func_req(hdev, data, skb, opcode, status, req_complete, in hci_event_func()
7475 ev->func(hdev, data, skb); in hci_event_func()
7478 void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb) in hci_event_packet() argument
7488 bt_dev_err(hdev, "Malformed HCI Event"); in hci_event_packet()
7492 kfree_skb(hdev->recv_event); in hci_event_packet()
7493 hdev->recv_event = skb_clone(skb, GFP_KERNEL); in hci_event_packet()
7497 bt_dev_warn(hdev, "Received unexpected HCI Event 0x%2.2x", in hci_event_packet()
7503 if (hdev->sent_cmd && in hci_event_packet()
7504 hci_opcode_ogf(hci_skb_opcode(hdev->sent_cmd)) != 0x08 && in hci_event_packet()
7505 hci_skb_event(hdev->sent_cmd) == event) { in hci_event_packet()
7506 hci_req_cmd_complete(hdev, hci_skb_opcode(hdev->sent_cmd), in hci_event_packet()
7523 hci_store_wake_reason(hdev, event, skb); in hci_event_packet()
7525 bt_dev_dbg(hdev, "event 0x%2.2x", event); in hci_event_packet()
7527 hci_event_func(hdev, event, skb, &opcode, &status, &req_complete, in hci_event_packet()
7531 req_complete(hdev, status, opcode); in hci_event_packet()
7533 if (!hci_get_cmd_complete(hdev, opcode, req_evt, orig_skb)) { in hci_event_packet()
7537 req_complete_skb(hdev, status, opcode, orig_skb); in hci_event_packet()
7543 hdev->stat.evt_rx++; in hci_event_packet()