Lines Matching refs:hdev

52 static void *hci_ev_skb_pull(struct hci_dev *hdev, struct sk_buff *skb,  in hci_ev_skb_pull()  argument
59 bt_dev_err(hdev, "Malformed Event: 0x%2.2x", ev); in hci_ev_skb_pull()
64 static void *hci_cc_skb_pull(struct hci_dev *hdev, struct sk_buff *skb, in hci_cc_skb_pull() argument
71 bt_dev_err(hdev, "Malformed Command Complete: 0x%4.4x", op); in hci_cc_skb_pull()
76 static void *hci_le_ev_skb_pull(struct hci_dev *hdev, struct sk_buff *skb, in hci_le_ev_skb_pull() argument
83 bt_dev_err(hdev, "Malformed LE Event: 0x%2.2x", ev); in hci_le_ev_skb_pull()
88 static u8 hci_cc_inquiry_cancel(struct hci_dev *hdev, void *data, in hci_cc_inquiry_cancel() argument
93 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_inquiry_cancel()
102 if (rp->status == 0x0c && !test_bit(HCI_INQUIRY, &hdev->flags)) { in hci_cc_inquiry_cancel()
103 bt_dev_warn(hdev, "Ignoring error of Inquiry Cancel command"); in hci_cc_inquiry_cancel()
110 clear_bit(HCI_INQUIRY, &hdev->flags); in hci_cc_inquiry_cancel()
112 wake_up_bit(&hdev->flags, HCI_INQUIRY); in hci_cc_inquiry_cancel()
114 hci_dev_lock(hdev); in hci_cc_inquiry_cancel()
118 if (!hci_dev_test_flag(hdev, HCI_LE_SCAN) || in hci_cc_inquiry_cancel()
119 hdev->le_scan_type != LE_SCAN_ACTIVE) in hci_cc_inquiry_cancel()
120 hci_discovery_set_state(hdev, DISCOVERY_STOPPED); in hci_cc_inquiry_cancel()
121 hci_dev_unlock(hdev); in hci_cc_inquiry_cancel()
123 hci_conn_check_pending(hdev); in hci_cc_inquiry_cancel()
128 static u8 hci_cc_periodic_inq(struct hci_dev *hdev, void *data, in hci_cc_periodic_inq() argument
133 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_periodic_inq()
138 hci_dev_set_flag(hdev, HCI_PERIODIC_INQ); in hci_cc_periodic_inq()
143 static u8 hci_cc_exit_periodic_inq(struct hci_dev *hdev, void *data, in hci_cc_exit_periodic_inq() argument
148 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_exit_periodic_inq()
153 hci_dev_clear_flag(hdev, HCI_PERIODIC_INQ); in hci_cc_exit_periodic_inq()
155 hci_conn_check_pending(hdev); in hci_cc_exit_periodic_inq()
160 static u8 hci_cc_remote_name_req_cancel(struct hci_dev *hdev, void *data, in hci_cc_remote_name_req_cancel() argument
165 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_remote_name_req_cancel()
170 static u8 hci_cc_role_discovery(struct hci_dev *hdev, void *data, in hci_cc_role_discovery() argument
176 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_role_discovery()
181 hci_dev_lock(hdev); in hci_cc_role_discovery()
183 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_role_discovery()
187 hci_dev_unlock(hdev); in hci_cc_role_discovery()
192 static u8 hci_cc_read_link_policy(struct hci_dev *hdev, void *data, in hci_cc_read_link_policy() argument
198 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_link_policy()
203 hci_dev_lock(hdev); in hci_cc_read_link_policy()
205 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_link_policy()
209 hci_dev_unlock(hdev); in hci_cc_read_link_policy()
214 static u8 hci_cc_write_link_policy(struct hci_dev *hdev, void *data, in hci_cc_write_link_policy() argument
221 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_link_policy()
226 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_LINK_POLICY); in hci_cc_write_link_policy()
230 hci_dev_lock(hdev); in hci_cc_write_link_policy()
232 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_write_link_policy()
236 hci_dev_unlock(hdev); in hci_cc_write_link_policy()
241 static u8 hci_cc_read_def_link_policy(struct hci_dev *hdev, void *data, in hci_cc_read_def_link_policy() argument
246 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_def_link_policy()
251 hdev->link_policy = __le16_to_cpu(rp->policy); in hci_cc_read_def_link_policy()
256 static u8 hci_cc_write_def_link_policy(struct hci_dev *hdev, void *data, in hci_cc_write_def_link_policy() argument
262 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_def_link_policy()
267 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_DEF_LINK_POLICY); in hci_cc_write_def_link_policy()
271 hdev->link_policy = get_unaligned_le16(sent); in hci_cc_write_def_link_policy()
276 static u8 hci_cc_reset(struct hci_dev *hdev, void *data, struct sk_buff *skb) in hci_cc_reset() argument
280 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_reset()
282 clear_bit(HCI_RESET, &hdev->flags); in hci_cc_reset()
288 hci_dev_clear_volatile_flags(hdev); in hci_cc_reset()
290 hci_discovery_set_state(hdev, DISCOVERY_STOPPED); in hci_cc_reset()
292 hdev->inq_tx_power = HCI_TX_POWER_INVALID; in hci_cc_reset()
293 hdev->adv_tx_power = HCI_TX_POWER_INVALID; in hci_cc_reset()
295 memset(hdev->adv_data, 0, sizeof(hdev->adv_data)); in hci_cc_reset()
296 hdev->adv_data_len = 0; in hci_cc_reset()
298 memset(hdev->scan_rsp_data, 0, sizeof(hdev->scan_rsp_data)); in hci_cc_reset()
299 hdev->scan_rsp_data_len = 0; in hci_cc_reset()
301 hdev->le_scan_type = LE_SCAN_PASSIVE; in hci_cc_reset()
303 hdev->ssp_debug_mode = 0; in hci_cc_reset()
305 hci_bdaddr_list_clear(&hdev->le_accept_list); in hci_cc_reset()
306 hci_bdaddr_list_clear(&hdev->le_resolv_list); in hci_cc_reset()
311 static u8 hci_cc_read_stored_link_key(struct hci_dev *hdev, void *data, in hci_cc_read_stored_link_key() argument
317 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_stored_link_key()
319 sent = hci_sent_cmd_data(hdev, HCI_OP_READ_STORED_LINK_KEY); in hci_cc_read_stored_link_key()
324 hdev->stored_max_keys = le16_to_cpu(rp->max_keys); in hci_cc_read_stored_link_key()
325 hdev->stored_num_keys = le16_to_cpu(rp->num_keys); in hci_cc_read_stored_link_key()
331 static u8 hci_cc_delete_stored_link_key(struct hci_dev *hdev, void *data, in hci_cc_delete_stored_link_key() argument
337 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_delete_stored_link_key()
344 if (num_keys <= hdev->stored_num_keys) in hci_cc_delete_stored_link_key()
345 hdev->stored_num_keys -= num_keys; in hci_cc_delete_stored_link_key()
347 hdev->stored_num_keys = 0; in hci_cc_delete_stored_link_key()
352 static u8 hci_cc_write_local_name(struct hci_dev *hdev, void *data, in hci_cc_write_local_name() argument
358 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_local_name()
360 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_LOCAL_NAME); in hci_cc_write_local_name()
364 hci_dev_lock(hdev); in hci_cc_write_local_name()
366 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_cc_write_local_name()
367 mgmt_set_local_name_complete(hdev, sent, rp->status); in hci_cc_write_local_name()
369 memcpy(hdev->dev_name, sent, HCI_MAX_NAME_LENGTH); in hci_cc_write_local_name()
371 hci_dev_unlock(hdev); in hci_cc_write_local_name()
376 static u8 hci_cc_read_local_name(struct hci_dev *hdev, void *data, in hci_cc_read_local_name() argument
381 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_name()
386 if (hci_dev_test_flag(hdev, HCI_SETUP) || in hci_cc_read_local_name()
387 hci_dev_test_flag(hdev, HCI_CONFIG)) in hci_cc_read_local_name()
388 memcpy(hdev->dev_name, rp->name, HCI_MAX_NAME_LENGTH); in hci_cc_read_local_name()
393 static u8 hci_cc_write_auth_enable(struct hci_dev *hdev, void *data, in hci_cc_write_auth_enable() argument
399 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_auth_enable()
401 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_AUTH_ENABLE); in hci_cc_write_auth_enable()
405 hci_dev_lock(hdev); in hci_cc_write_auth_enable()
411 set_bit(HCI_AUTH, &hdev->flags); in hci_cc_write_auth_enable()
413 clear_bit(HCI_AUTH, &hdev->flags); in hci_cc_write_auth_enable()
416 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_cc_write_auth_enable()
417 mgmt_auth_enable_complete(hdev, rp->status); in hci_cc_write_auth_enable()
419 hci_dev_unlock(hdev); in hci_cc_write_auth_enable()
424 static u8 hci_cc_write_encrypt_mode(struct hci_dev *hdev, void *data, in hci_cc_write_encrypt_mode() argument
431 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_encrypt_mode()
436 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_ENCRYPT_MODE); in hci_cc_write_encrypt_mode()
443 set_bit(HCI_ENCRYPT, &hdev->flags); in hci_cc_write_encrypt_mode()
445 clear_bit(HCI_ENCRYPT, &hdev->flags); in hci_cc_write_encrypt_mode()
450 static u8 hci_cc_write_scan_enable(struct hci_dev *hdev, void *data, in hci_cc_write_scan_enable() argument
457 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_scan_enable()
459 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_SCAN_ENABLE); in hci_cc_write_scan_enable()
465 hci_dev_lock(hdev); in hci_cc_write_scan_enable()
468 hdev->discov_timeout = 0; in hci_cc_write_scan_enable()
473 set_bit(HCI_ISCAN, &hdev->flags); in hci_cc_write_scan_enable()
475 clear_bit(HCI_ISCAN, &hdev->flags); in hci_cc_write_scan_enable()
478 set_bit(HCI_PSCAN, &hdev->flags); in hci_cc_write_scan_enable()
480 clear_bit(HCI_PSCAN, &hdev->flags); in hci_cc_write_scan_enable()
483 hci_dev_unlock(hdev); in hci_cc_write_scan_enable()
488 static u8 hci_cc_set_event_filter(struct hci_dev *hdev, void *data, in hci_cc_set_event_filter() argument
495 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_set_event_filter()
500 sent = hci_sent_cmd_data(hdev, HCI_OP_SET_EVENT_FLT); in hci_cc_set_event_filter()
507 hci_dev_clear_flag(hdev, HCI_EVENT_FILTER_CONFIGURED); in hci_cc_set_event_filter()
509 hci_dev_set_flag(hdev, HCI_EVENT_FILTER_CONFIGURED); in hci_cc_set_event_filter()
514 static u8 hci_cc_read_class_of_dev(struct hci_dev *hdev, void *data, in hci_cc_read_class_of_dev() argument
519 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_class_of_dev()
524 memcpy(hdev->dev_class, rp->dev_class, 3); in hci_cc_read_class_of_dev()
526 bt_dev_dbg(hdev, "class 0x%.2x%.2x%.2x", hdev->dev_class[2], in hci_cc_read_class_of_dev()
527 hdev->dev_class[1], hdev->dev_class[0]); in hci_cc_read_class_of_dev()
532 static u8 hci_cc_write_class_of_dev(struct hci_dev *hdev, void *data, in hci_cc_write_class_of_dev() argument
538 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_class_of_dev()
540 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_CLASS_OF_DEV); in hci_cc_write_class_of_dev()
544 hci_dev_lock(hdev); in hci_cc_write_class_of_dev()
547 memcpy(hdev->dev_class, sent, 3); in hci_cc_write_class_of_dev()
549 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_cc_write_class_of_dev()
550 mgmt_set_class_of_dev_complete(hdev, sent, rp->status); in hci_cc_write_class_of_dev()
552 hci_dev_unlock(hdev); in hci_cc_write_class_of_dev()
557 static u8 hci_cc_read_voice_setting(struct hci_dev *hdev, void *data, in hci_cc_read_voice_setting() argument
563 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_voice_setting()
570 if (hdev->voice_setting == setting) in hci_cc_read_voice_setting()
573 hdev->voice_setting = setting; in hci_cc_read_voice_setting()
575 bt_dev_dbg(hdev, "voice setting 0x%4.4x", setting); in hci_cc_read_voice_setting()
577 if (hdev->notify) in hci_cc_read_voice_setting()
578 hdev->notify(hdev, HCI_NOTIFY_VOICE_SETTING); in hci_cc_read_voice_setting()
583 static u8 hci_cc_write_voice_setting(struct hci_dev *hdev, void *data, in hci_cc_write_voice_setting() argument
590 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_voice_setting()
595 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_VOICE_SETTING); in hci_cc_write_voice_setting()
601 if (hdev->voice_setting == setting) in hci_cc_write_voice_setting()
604 hdev->voice_setting = setting; in hci_cc_write_voice_setting()
606 bt_dev_dbg(hdev, "voice setting 0x%4.4x", setting); in hci_cc_write_voice_setting()
608 if (hdev->notify) in hci_cc_write_voice_setting()
609 hdev->notify(hdev, HCI_NOTIFY_VOICE_SETTING); in hci_cc_write_voice_setting()
614 static u8 hci_cc_read_num_supported_iac(struct hci_dev *hdev, void *data, in hci_cc_read_num_supported_iac() argument
619 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_num_supported_iac()
624 hdev->num_iac = rp->num_iac; in hci_cc_read_num_supported_iac()
626 bt_dev_dbg(hdev, "num iac %d", hdev->num_iac); in hci_cc_read_num_supported_iac()
631 static u8 hci_cc_write_ssp_mode(struct hci_dev *hdev, void *data, in hci_cc_write_ssp_mode() argument
637 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_ssp_mode()
639 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_SSP_MODE); in hci_cc_write_ssp_mode()
643 hci_dev_lock(hdev); in hci_cc_write_ssp_mode()
647 hdev->features[1][0] |= LMP_HOST_SSP; in hci_cc_write_ssp_mode()
649 hdev->features[1][0] &= ~LMP_HOST_SSP; in hci_cc_write_ssp_mode()
654 hci_dev_set_flag(hdev, HCI_SSP_ENABLED); in hci_cc_write_ssp_mode()
656 hci_dev_clear_flag(hdev, HCI_SSP_ENABLED); in hci_cc_write_ssp_mode()
659 hci_dev_unlock(hdev); in hci_cc_write_ssp_mode()
664 static u8 hci_cc_write_sc_support(struct hci_dev *hdev, void *data, in hci_cc_write_sc_support() argument
670 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_sc_support()
672 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_SC_SUPPORT); in hci_cc_write_sc_support()
676 hci_dev_lock(hdev); in hci_cc_write_sc_support()
680 hdev->features[1][0] |= LMP_HOST_SC; in hci_cc_write_sc_support()
682 hdev->features[1][0] &= ~LMP_HOST_SC; in hci_cc_write_sc_support()
685 if (!hci_dev_test_flag(hdev, HCI_MGMT) && !rp->status) { in hci_cc_write_sc_support()
687 hci_dev_set_flag(hdev, HCI_SC_ENABLED); in hci_cc_write_sc_support()
689 hci_dev_clear_flag(hdev, HCI_SC_ENABLED); in hci_cc_write_sc_support()
692 hci_dev_unlock(hdev); in hci_cc_write_sc_support()
697 static u8 hci_cc_read_local_version(struct hci_dev *hdev, void *data, in hci_cc_read_local_version() argument
702 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_version()
707 if (hci_dev_test_flag(hdev, HCI_SETUP) || in hci_cc_read_local_version()
708 hci_dev_test_flag(hdev, HCI_CONFIG)) { in hci_cc_read_local_version()
709 hdev->hci_ver = rp->hci_ver; in hci_cc_read_local_version()
710 hdev->hci_rev = __le16_to_cpu(rp->hci_rev); in hci_cc_read_local_version()
711 hdev->lmp_ver = rp->lmp_ver; in hci_cc_read_local_version()
712 hdev->manufacturer = __le16_to_cpu(rp->manufacturer); in hci_cc_read_local_version()
713 hdev->lmp_subver = __le16_to_cpu(rp->lmp_subver); in hci_cc_read_local_version()
719 static u8 hci_cc_read_enc_key_size(struct hci_dev *hdev, void *data, in hci_cc_read_enc_key_size() argument
727 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cc_read_enc_key_size()
731 hci_dev_lock(hdev); in hci_cc_read_enc_key_size()
733 conn = hci_conn_hash_lookup_handle(hdev, handle); in hci_cc_read_enc_key_size()
744 bt_dev_err(hdev, "failed to read key size for handle %u", in hci_cc_read_enc_key_size()
755 hci_dev_unlock(hdev); in hci_cc_read_enc_key_size()
760 static u8 hci_cc_read_local_commands(struct hci_dev *hdev, void *data, in hci_cc_read_local_commands() argument
765 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_commands()
770 if (hci_dev_test_flag(hdev, HCI_SETUP) || in hci_cc_read_local_commands()
771 hci_dev_test_flag(hdev, HCI_CONFIG)) in hci_cc_read_local_commands()
772 memcpy(hdev->commands, rp->commands, sizeof(hdev->commands)); in hci_cc_read_local_commands()
777 static u8 hci_cc_read_auth_payload_timeout(struct hci_dev *hdev, void *data, in hci_cc_read_auth_payload_timeout() argument
783 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_auth_payload_timeout()
788 hci_dev_lock(hdev); in hci_cc_read_auth_payload_timeout()
790 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_auth_payload_timeout()
794 hci_dev_unlock(hdev); in hci_cc_read_auth_payload_timeout()
799 static u8 hci_cc_write_auth_payload_timeout(struct hci_dev *hdev, void *data, in hci_cc_write_auth_payload_timeout() argument
806 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_auth_payload_timeout()
808 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_AUTH_PAYLOAD_TO); in hci_cc_write_auth_payload_timeout()
812 hci_dev_lock(hdev); in hci_cc_write_auth_payload_timeout()
814 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_write_auth_payload_timeout()
826 hci_dev_unlock(hdev); in hci_cc_write_auth_payload_timeout()
831 static u8 hci_cc_read_local_features(struct hci_dev *hdev, void *data, in hci_cc_read_local_features() argument
836 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_features()
841 memcpy(hdev->features, rp->features, 8); in hci_cc_read_local_features()
846 if (hdev->features[0][0] & LMP_3SLOT) in hci_cc_read_local_features()
847 hdev->pkt_type |= (HCI_DM3 | HCI_DH3); in hci_cc_read_local_features()
849 if (hdev->features[0][0] & LMP_5SLOT) in hci_cc_read_local_features()
850 hdev->pkt_type |= (HCI_DM5 | HCI_DH5); in hci_cc_read_local_features()
852 if (hdev->features[0][1] & LMP_HV2) { in hci_cc_read_local_features()
853 hdev->pkt_type |= (HCI_HV2); in hci_cc_read_local_features()
854 hdev->esco_type |= (ESCO_HV2); in hci_cc_read_local_features()
857 if (hdev->features[0][1] & LMP_HV3) { in hci_cc_read_local_features()
858 hdev->pkt_type |= (HCI_HV3); in hci_cc_read_local_features()
859 hdev->esco_type |= (ESCO_HV3); in hci_cc_read_local_features()
862 if (lmp_esco_capable(hdev)) in hci_cc_read_local_features()
863 hdev->esco_type |= (ESCO_EV3); in hci_cc_read_local_features()
865 if (hdev->features[0][4] & LMP_EV4) in hci_cc_read_local_features()
866 hdev->esco_type |= (ESCO_EV4); in hci_cc_read_local_features()
868 if (hdev->features[0][4] & LMP_EV5) in hci_cc_read_local_features()
869 hdev->esco_type |= (ESCO_EV5); in hci_cc_read_local_features()
871 if (hdev->features[0][5] & LMP_EDR_ESCO_2M) in hci_cc_read_local_features()
872 hdev->esco_type |= (ESCO_2EV3); in hci_cc_read_local_features()
874 if (hdev->features[0][5] & LMP_EDR_ESCO_3M) in hci_cc_read_local_features()
875 hdev->esco_type |= (ESCO_3EV3); in hci_cc_read_local_features()
877 if (hdev->features[0][5] & LMP_EDR_3S_ESCO) in hci_cc_read_local_features()
878 hdev->esco_type |= (ESCO_2EV5 | ESCO_3EV5); in hci_cc_read_local_features()
883 static u8 hci_cc_read_local_ext_features(struct hci_dev *hdev, void *data, in hci_cc_read_local_ext_features() argument
888 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_ext_features()
893 if (hdev->max_page < rp->max_page) { in hci_cc_read_local_ext_features()
895 &hdev->quirks)) in hci_cc_read_local_ext_features()
896 bt_dev_warn(hdev, "broken local ext features page 2"); in hci_cc_read_local_ext_features()
898 hdev->max_page = rp->max_page; in hci_cc_read_local_ext_features()
902 memcpy(hdev->features[rp->page], rp->features, 8); in hci_cc_read_local_ext_features()
907 static u8 hci_cc_read_flow_control_mode(struct hci_dev *hdev, void *data, in hci_cc_read_flow_control_mode() argument
912 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_flow_control_mode()
917 hdev->flow_ctl_mode = rp->mode; in hci_cc_read_flow_control_mode()
922 static u8 hci_cc_read_buffer_size(struct hci_dev *hdev, void *data, in hci_cc_read_buffer_size() argument
927 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_buffer_size()
932 hdev->acl_mtu = __le16_to_cpu(rp->acl_mtu); in hci_cc_read_buffer_size()
933 hdev->sco_mtu = rp->sco_mtu; in hci_cc_read_buffer_size()
934 hdev->acl_pkts = __le16_to_cpu(rp->acl_max_pkt); in hci_cc_read_buffer_size()
935 hdev->sco_pkts = __le16_to_cpu(rp->sco_max_pkt); in hci_cc_read_buffer_size()
937 if (test_bit(HCI_QUIRK_FIXUP_BUFFER_SIZE, &hdev->quirks)) { in hci_cc_read_buffer_size()
938 hdev->sco_mtu = 64; in hci_cc_read_buffer_size()
939 hdev->sco_pkts = 8; in hci_cc_read_buffer_size()
942 hdev->acl_cnt = hdev->acl_pkts; in hci_cc_read_buffer_size()
943 hdev->sco_cnt = hdev->sco_pkts; in hci_cc_read_buffer_size()
945 BT_DBG("%s acl mtu %d:%d sco mtu %d:%d", hdev->name, hdev->acl_mtu, in hci_cc_read_buffer_size()
946 hdev->acl_pkts, hdev->sco_mtu, hdev->sco_pkts); in hci_cc_read_buffer_size()
951 static u8 hci_cc_read_bd_addr(struct hci_dev *hdev, void *data, in hci_cc_read_bd_addr() argument
956 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_bd_addr()
961 if (test_bit(HCI_INIT, &hdev->flags)) in hci_cc_read_bd_addr()
962 bacpy(&hdev->bdaddr, &rp->bdaddr); in hci_cc_read_bd_addr()
964 if (hci_dev_test_flag(hdev, HCI_SETUP)) in hci_cc_read_bd_addr()
965 bacpy(&hdev->setup_addr, &rp->bdaddr); in hci_cc_read_bd_addr()
970 static u8 hci_cc_read_local_pairing_opts(struct hci_dev *hdev, void *data, in hci_cc_read_local_pairing_opts() argument
975 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_pairing_opts()
980 if (hci_dev_test_flag(hdev, HCI_SETUP) || in hci_cc_read_local_pairing_opts()
981 hci_dev_test_flag(hdev, HCI_CONFIG)) { in hci_cc_read_local_pairing_opts()
982 hdev->pairing_opts = rp->pairing_opts; in hci_cc_read_local_pairing_opts()
983 hdev->max_enc_key_size = rp->max_key_size; in hci_cc_read_local_pairing_opts()
989 static u8 hci_cc_read_page_scan_activity(struct hci_dev *hdev, void *data, in hci_cc_read_page_scan_activity() argument
994 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_page_scan_activity()
999 if (test_bit(HCI_INIT, &hdev->flags)) { in hci_cc_read_page_scan_activity()
1000 hdev->page_scan_interval = __le16_to_cpu(rp->interval); in hci_cc_read_page_scan_activity()
1001 hdev->page_scan_window = __le16_to_cpu(rp->window); in hci_cc_read_page_scan_activity()
1007 static u8 hci_cc_write_page_scan_activity(struct hci_dev *hdev, void *data, in hci_cc_write_page_scan_activity() argument
1013 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_page_scan_activity()
1018 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_PAGE_SCAN_ACTIVITY); in hci_cc_write_page_scan_activity()
1022 hdev->page_scan_interval = __le16_to_cpu(sent->interval); in hci_cc_write_page_scan_activity()
1023 hdev->page_scan_window = __le16_to_cpu(sent->window); in hci_cc_write_page_scan_activity()
1028 static u8 hci_cc_read_page_scan_type(struct hci_dev *hdev, void *data, in hci_cc_read_page_scan_type() argument
1033 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_page_scan_type()
1038 if (test_bit(HCI_INIT, &hdev->flags)) in hci_cc_read_page_scan_type()
1039 hdev->page_scan_type = rp->type; in hci_cc_read_page_scan_type()
1044 static u8 hci_cc_write_page_scan_type(struct hci_dev *hdev, void *data, in hci_cc_write_page_scan_type() argument
1050 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_page_scan_type()
1055 type = hci_sent_cmd_data(hdev, HCI_OP_WRITE_PAGE_SCAN_TYPE); in hci_cc_write_page_scan_type()
1057 hdev->page_scan_type = *type; in hci_cc_write_page_scan_type()
1062 static u8 hci_cc_read_data_block_size(struct hci_dev *hdev, void *data, in hci_cc_read_data_block_size() argument
1067 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_data_block_size()
1072 hdev->block_mtu = __le16_to_cpu(rp->max_acl_len); in hci_cc_read_data_block_size()
1073 hdev->block_len = __le16_to_cpu(rp->block_len); in hci_cc_read_data_block_size()
1074 hdev->num_blocks = __le16_to_cpu(rp->num_blocks); in hci_cc_read_data_block_size()
1076 hdev->block_cnt = hdev->num_blocks; in hci_cc_read_data_block_size()
1078 BT_DBG("%s blk mtu %d cnt %d len %d", hdev->name, hdev->block_mtu, in hci_cc_read_data_block_size()
1079 hdev->block_cnt, hdev->block_len); in hci_cc_read_data_block_size()
1084 static u8 hci_cc_read_clock(struct hci_dev *hdev, void *data, in hci_cc_read_clock() argument
1091 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_clock()
1096 hci_dev_lock(hdev); in hci_cc_read_clock()
1098 cp = hci_sent_cmd_data(hdev, HCI_OP_READ_CLOCK); in hci_cc_read_clock()
1103 hdev->clock = le32_to_cpu(rp->clock); in hci_cc_read_clock()
1107 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_clock()
1114 hci_dev_unlock(hdev); in hci_cc_read_clock()
1118 static u8 hci_cc_read_local_amp_info(struct hci_dev *hdev, void *data, in hci_cc_read_local_amp_info() argument
1123 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_amp_info()
1128 hdev->amp_status = rp->amp_status; in hci_cc_read_local_amp_info()
1129 hdev->amp_total_bw = __le32_to_cpu(rp->total_bw); in hci_cc_read_local_amp_info()
1130 hdev->amp_max_bw = __le32_to_cpu(rp->max_bw); in hci_cc_read_local_amp_info()
1131 hdev->amp_min_latency = __le32_to_cpu(rp->min_latency); in hci_cc_read_local_amp_info()
1132 hdev->amp_max_pdu = __le32_to_cpu(rp->max_pdu); in hci_cc_read_local_amp_info()
1133 hdev->amp_type = rp->amp_type; in hci_cc_read_local_amp_info()
1134 hdev->amp_pal_cap = __le16_to_cpu(rp->pal_cap); in hci_cc_read_local_amp_info()
1135 hdev->amp_assoc_size = __le16_to_cpu(rp->max_assoc_size); in hci_cc_read_local_amp_info()
1136 hdev->amp_be_flush_to = __le32_to_cpu(rp->be_flush_to); in hci_cc_read_local_amp_info()
1137 hdev->amp_max_flush_to = __le32_to_cpu(rp->max_flush_to); in hci_cc_read_local_amp_info()
1142 static u8 hci_cc_read_inq_rsp_tx_power(struct hci_dev *hdev, void *data, in hci_cc_read_inq_rsp_tx_power() argument
1147 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_inq_rsp_tx_power()
1152 hdev->inq_tx_power = rp->tx_power; in hci_cc_read_inq_rsp_tx_power()
1157 static u8 hci_cc_read_def_err_data_reporting(struct hci_dev *hdev, void *data, in hci_cc_read_def_err_data_reporting() argument
1162 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_def_err_data_reporting()
1167 hdev->err_data_reporting = rp->err_data_reporting; in hci_cc_read_def_err_data_reporting()
1172 static u8 hci_cc_write_def_err_data_reporting(struct hci_dev *hdev, void *data, in hci_cc_write_def_err_data_reporting() argument
1178 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_def_err_data_reporting()
1183 cp = hci_sent_cmd_data(hdev, HCI_OP_WRITE_DEF_ERR_DATA_REPORTING); in hci_cc_write_def_err_data_reporting()
1187 hdev->err_data_reporting = cp->err_data_reporting; in hci_cc_write_def_err_data_reporting()
1192 static u8 hci_cc_pin_code_reply(struct hci_dev *hdev, void *data, in hci_cc_pin_code_reply() argument
1199 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_pin_code_reply()
1201 hci_dev_lock(hdev); in hci_cc_pin_code_reply()
1203 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_cc_pin_code_reply()
1204 mgmt_pin_code_reply_complete(hdev, &rp->bdaddr, rp->status); in hci_cc_pin_code_reply()
1209 cp = hci_sent_cmd_data(hdev, HCI_OP_PIN_CODE_REPLY); in hci_cc_pin_code_reply()
1213 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cc_pin_code_reply()
1218 hci_dev_unlock(hdev); in hci_cc_pin_code_reply()
1222 static u8 hci_cc_pin_code_neg_reply(struct hci_dev *hdev, void *data, in hci_cc_pin_code_neg_reply() argument
1227 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_pin_code_neg_reply()
1229 hci_dev_lock(hdev); in hci_cc_pin_code_neg_reply()
1231 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_cc_pin_code_neg_reply()
1232 mgmt_pin_code_neg_reply_complete(hdev, &rp->bdaddr, in hci_cc_pin_code_neg_reply()
1235 hci_dev_unlock(hdev); in hci_cc_pin_code_neg_reply()
1240 static u8 hci_cc_le_read_buffer_size(struct hci_dev *hdev, void *data, in hci_cc_le_read_buffer_size() argument
1245 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_read_buffer_size()
1250 hdev->le_mtu = __le16_to_cpu(rp->le_mtu); in hci_cc_le_read_buffer_size()
1251 hdev->le_pkts = rp->le_max_pkt; in hci_cc_le_read_buffer_size()
1253 hdev->le_cnt = hdev->le_pkts; in hci_cc_le_read_buffer_size()
1255 BT_DBG("%s le mtu %d:%d", hdev->name, hdev->le_mtu, hdev->le_pkts); in hci_cc_le_read_buffer_size()
1260 static u8 hci_cc_le_read_local_features(struct hci_dev *hdev, void *data, in hci_cc_le_read_local_features() argument
1265 BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); in hci_cc_le_read_local_features()
1270 memcpy(hdev->le_features, rp->features, 8); in hci_cc_le_read_local_features()
1275 static u8 hci_cc_le_read_adv_tx_power(struct hci_dev *hdev, void *data, in hci_cc_le_read_adv_tx_power() argument
1280 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_read_adv_tx_power()
1285 hdev->adv_tx_power = rp->tx_power; in hci_cc_le_read_adv_tx_power()
1290 static u8 hci_cc_user_confirm_reply(struct hci_dev *hdev, void *data, in hci_cc_user_confirm_reply() argument
1295 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_user_confirm_reply()
1297 hci_dev_lock(hdev); in hci_cc_user_confirm_reply()
1299 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_cc_user_confirm_reply()
1300 mgmt_user_confirm_reply_complete(hdev, &rp->bdaddr, ACL_LINK, 0, in hci_cc_user_confirm_reply()
1303 hci_dev_unlock(hdev); in hci_cc_user_confirm_reply()
1308 static u8 hci_cc_user_confirm_neg_reply(struct hci_dev *hdev, void *data, in hci_cc_user_confirm_neg_reply() argument
1313 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_user_confirm_neg_reply()
1315 hci_dev_lock(hdev); in hci_cc_user_confirm_neg_reply()
1317 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_cc_user_confirm_neg_reply()
1318 mgmt_user_confirm_neg_reply_complete(hdev, &rp->bdaddr, in hci_cc_user_confirm_neg_reply()
1321 hci_dev_unlock(hdev); in hci_cc_user_confirm_neg_reply()
1326 static u8 hci_cc_user_passkey_reply(struct hci_dev *hdev, void *data, in hci_cc_user_passkey_reply() argument
1331 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_user_passkey_reply()
1333 hci_dev_lock(hdev); in hci_cc_user_passkey_reply()
1335 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_cc_user_passkey_reply()
1336 mgmt_user_passkey_reply_complete(hdev, &rp->bdaddr, ACL_LINK, in hci_cc_user_passkey_reply()
1339 hci_dev_unlock(hdev); in hci_cc_user_passkey_reply()
1344 static u8 hci_cc_user_passkey_neg_reply(struct hci_dev *hdev, void *data, in hci_cc_user_passkey_neg_reply() argument
1349 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_user_passkey_neg_reply()
1351 hci_dev_lock(hdev); in hci_cc_user_passkey_neg_reply()
1353 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_cc_user_passkey_neg_reply()
1354 mgmt_user_passkey_neg_reply_complete(hdev, &rp->bdaddr, in hci_cc_user_passkey_neg_reply()
1357 hci_dev_unlock(hdev); in hci_cc_user_passkey_neg_reply()
1362 static u8 hci_cc_read_local_oob_data(struct hci_dev *hdev, void *data, in hci_cc_read_local_oob_data() argument
1367 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_oob_data()
1372 static u8 hci_cc_read_local_oob_ext_data(struct hci_dev *hdev, void *data, in hci_cc_read_local_oob_ext_data() argument
1377 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_oob_ext_data()
1382 static u8 hci_cc_le_set_random_addr(struct hci_dev *hdev, void *data, in hci_cc_le_set_random_addr() argument
1388 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_random_addr()
1393 sent = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_RANDOM_ADDR); in hci_cc_le_set_random_addr()
1397 hci_dev_lock(hdev); in hci_cc_le_set_random_addr()
1399 bacpy(&hdev->random_addr, sent); in hci_cc_le_set_random_addr()
1401 if (!bacmp(&hdev->rpa, sent)) { in hci_cc_le_set_random_addr()
1402 hci_dev_clear_flag(hdev, HCI_RPA_EXPIRED); in hci_cc_le_set_random_addr()
1403 queue_delayed_work(hdev->workqueue, &hdev->rpa_expired, in hci_cc_le_set_random_addr()
1404 secs_to_jiffies(hdev->rpa_timeout)); in hci_cc_le_set_random_addr()
1407 hci_dev_unlock(hdev); in hci_cc_le_set_random_addr()
1412 static u8 hci_cc_le_set_default_phy(struct hci_dev *hdev, void *data, in hci_cc_le_set_default_phy() argument
1418 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_default_phy()
1423 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_DEFAULT_PHY); in hci_cc_le_set_default_phy()
1427 hci_dev_lock(hdev); in hci_cc_le_set_default_phy()
1429 hdev->le_tx_def_phys = cp->tx_phys; in hci_cc_le_set_default_phy()
1430 hdev->le_rx_def_phys = cp->rx_phys; in hci_cc_le_set_default_phy()
1432 hci_dev_unlock(hdev); in hci_cc_le_set_default_phy()
1437 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
1444 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_adv_set_random_addr()
1449 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_ADV_SET_RAND_ADDR); in hci_cc_le_set_adv_set_random_addr()
1457 hci_dev_lock(hdev); in hci_cc_le_set_adv_set_random_addr()
1459 adv = hci_find_adv_instance(hdev, cp->handle); in hci_cc_le_set_adv_set_random_addr()
1462 if (!bacmp(&hdev->rpa, &cp->bdaddr)) { in hci_cc_le_set_adv_set_random_addr()
1464 queue_delayed_work(hdev->workqueue, in hci_cc_le_set_adv_set_random_addr()
1466 secs_to_jiffies(hdev->rpa_timeout)); in hci_cc_le_set_adv_set_random_addr()
1470 hci_dev_unlock(hdev); in hci_cc_le_set_adv_set_random_addr()
1475 static u8 hci_cc_le_remove_adv_set(struct hci_dev *hdev, void *data, in hci_cc_le_remove_adv_set() argument
1482 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_remove_adv_set()
1487 instance = hci_sent_cmd_data(hdev, HCI_OP_LE_REMOVE_ADV_SET); in hci_cc_le_remove_adv_set()
1491 hci_dev_lock(hdev); in hci_cc_le_remove_adv_set()
1493 err = hci_remove_adv_instance(hdev, *instance); in hci_cc_le_remove_adv_set()
1495 mgmt_advertising_removed(hci_skb_sk(hdev->sent_cmd), hdev, in hci_cc_le_remove_adv_set()
1498 hci_dev_unlock(hdev); in hci_cc_le_remove_adv_set()
1503 static u8 hci_cc_le_clear_adv_sets(struct hci_dev *hdev, void *data, in hci_cc_le_clear_adv_sets() argument
1510 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_clear_adv_sets()
1515 if (!hci_sent_cmd_data(hdev, HCI_OP_LE_CLEAR_ADV_SETS)) in hci_cc_le_clear_adv_sets()
1518 hci_dev_lock(hdev); in hci_cc_le_clear_adv_sets()
1520 list_for_each_entry_safe(adv, n, &hdev->adv_instances, list) { in hci_cc_le_clear_adv_sets()
1523 err = hci_remove_adv_instance(hdev, instance); in hci_cc_le_clear_adv_sets()
1525 mgmt_advertising_removed(hci_skb_sk(hdev->sent_cmd), in hci_cc_le_clear_adv_sets()
1526 hdev, instance); in hci_cc_le_clear_adv_sets()
1529 hci_dev_unlock(hdev); in hci_cc_le_clear_adv_sets()
1534 static u8 hci_cc_le_read_transmit_power(struct hci_dev *hdev, void *data, in hci_cc_le_read_transmit_power() argument
1539 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_read_transmit_power()
1544 hdev->min_le_tx_power = rp->min_le_tx_power; in hci_cc_le_read_transmit_power()
1545 hdev->max_le_tx_power = rp->max_le_tx_power; in hci_cc_le_read_transmit_power()
1550 static u8 hci_cc_le_set_privacy_mode(struct hci_dev *hdev, void *data, in hci_cc_le_set_privacy_mode() argument
1557 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_privacy_mode()
1562 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_PRIVACY_MODE); in hci_cc_le_set_privacy_mode()
1566 hci_dev_lock(hdev); in hci_cc_le_set_privacy_mode()
1568 params = hci_conn_params_lookup(hdev, &cp->bdaddr, cp->bdaddr_type); in hci_cc_le_set_privacy_mode()
1572 hci_dev_unlock(hdev); in hci_cc_le_set_privacy_mode()
1577 static u8 hci_cc_le_set_adv_enable(struct hci_dev *hdev, void *data, in hci_cc_le_set_adv_enable() argument
1583 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_adv_enable()
1588 sent = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_ADV_ENABLE); in hci_cc_le_set_adv_enable()
1592 hci_dev_lock(hdev); in hci_cc_le_set_adv_enable()
1600 hci_dev_set_flag(hdev, HCI_LE_ADV); in hci_cc_le_set_adv_enable()
1602 conn = hci_lookup_le_connect(hdev); in hci_cc_le_set_adv_enable()
1604 queue_delayed_work(hdev->workqueue, in hci_cc_le_set_adv_enable()
1608 hci_dev_clear_flag(hdev, HCI_LE_ADV); in hci_cc_le_set_adv_enable()
1611 hci_dev_unlock(hdev); in hci_cc_le_set_adv_enable()
1616 static u8 hci_cc_le_set_ext_adv_enable(struct hci_dev *hdev, void *data, in hci_cc_le_set_ext_adv_enable() argument
1624 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_ext_adv_enable()
1629 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_EXT_ADV_ENABLE); in hci_cc_le_set_ext_adv_enable()
1635 hci_dev_lock(hdev); in hci_cc_le_set_ext_adv_enable()
1638 adv = hci_find_adv_instance(hdev, set->handle); in hci_cc_le_set_ext_adv_enable()
1643 hci_dev_set_flag(hdev, HCI_LE_ADV); in hci_cc_le_set_ext_adv_enable()
1648 conn = hci_lookup_le_connect(hdev); in hci_cc_le_set_ext_adv_enable()
1650 queue_delayed_work(hdev->workqueue, in hci_cc_le_set_ext_adv_enable()
1661 list_for_each_entry_safe(adv, n, &hdev->adv_instances, in hci_cc_le_set_ext_adv_enable()
1668 list_for_each_entry_safe(adv, n, &hdev->adv_instances, in hci_cc_le_set_ext_adv_enable()
1673 hci_dev_clear_flag(hdev, HCI_LE_ADV); in hci_cc_le_set_ext_adv_enable()
1677 hci_dev_unlock(hdev); in hci_cc_le_set_ext_adv_enable()
1681 static u8 hci_cc_le_set_scan_param(struct hci_dev *hdev, void *data, in hci_cc_le_set_scan_param() argument
1687 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_scan_param()
1692 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_SCAN_PARAM); in hci_cc_le_set_scan_param()
1696 hci_dev_lock(hdev); in hci_cc_le_set_scan_param()
1698 hdev->le_scan_type = cp->type; in hci_cc_le_set_scan_param()
1700 hci_dev_unlock(hdev); in hci_cc_le_set_scan_param()
1705 static u8 hci_cc_le_set_ext_scan_param(struct hci_dev *hdev, void *data, in hci_cc_le_set_ext_scan_param() argument
1712 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_ext_scan_param()
1717 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_EXT_SCAN_PARAMS); in hci_cc_le_set_ext_scan_param()
1723 hci_dev_lock(hdev); in hci_cc_le_set_ext_scan_param()
1725 hdev->le_scan_type = phy_param->type; in hci_cc_le_set_ext_scan_param()
1727 hci_dev_unlock(hdev); in hci_cc_le_set_ext_scan_param()
1732 static bool has_pending_adv_report(struct hci_dev *hdev) in has_pending_adv_report() argument
1734 struct discovery_state *d = &hdev->discovery; in has_pending_adv_report()
1739 static void clear_pending_adv_report(struct hci_dev *hdev) in clear_pending_adv_report() argument
1741 struct discovery_state *d = &hdev->discovery; in clear_pending_adv_report()
1747 static void store_pending_adv_report(struct hci_dev *hdev, bdaddr_t *bdaddr, in store_pending_adv_report() argument
1751 struct discovery_state *d = &hdev->discovery; in store_pending_adv_report()
1753 if (len > max_adv_len(hdev)) in store_pending_adv_report()
1764 static void le_set_scan_enable_complete(struct hci_dev *hdev, u8 enable) in le_set_scan_enable_complete() argument
1766 hci_dev_lock(hdev); in le_set_scan_enable_complete()
1770 hci_dev_set_flag(hdev, HCI_LE_SCAN); in le_set_scan_enable_complete()
1771 if (hdev->le_scan_type == LE_SCAN_ACTIVE) in le_set_scan_enable_complete()
1772 clear_pending_adv_report(hdev); in le_set_scan_enable_complete()
1773 if (hci_dev_test_flag(hdev, HCI_MESH)) in le_set_scan_enable_complete()
1774 hci_discovery_set_state(hdev, DISCOVERY_FINDING); in le_set_scan_enable_complete()
1782 if (has_pending_adv_report(hdev)) { in le_set_scan_enable_complete()
1783 struct discovery_state *d = &hdev->discovery; in le_set_scan_enable_complete()
1785 mgmt_device_found(hdev, &d->last_adv_addr, LE_LINK, in le_set_scan_enable_complete()
1795 cancel_delayed_work(&hdev->le_scan_disable); in le_set_scan_enable_complete()
1797 hci_dev_clear_flag(hdev, HCI_LE_SCAN); in le_set_scan_enable_complete()
1803 if (hci_dev_test_and_clear_flag(hdev, HCI_LE_SCAN_INTERRUPTED)) in le_set_scan_enable_complete()
1804 hci_discovery_set_state(hdev, DISCOVERY_STOPPED); in le_set_scan_enable_complete()
1805 else if (!hci_dev_test_flag(hdev, HCI_LE_ADV) && in le_set_scan_enable_complete()
1806 hdev->discovery.state == DISCOVERY_FINDING) in le_set_scan_enable_complete()
1807 queue_work(hdev->workqueue, &hdev->reenable_adv_work); in le_set_scan_enable_complete()
1812 bt_dev_err(hdev, "use of reserved LE_Scan_Enable param %d", in le_set_scan_enable_complete()
1817 hci_dev_unlock(hdev); in le_set_scan_enable_complete()
1820 static u8 hci_cc_le_set_scan_enable(struct hci_dev *hdev, void *data, in hci_cc_le_set_scan_enable() argument
1826 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_scan_enable()
1831 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_SCAN_ENABLE); in hci_cc_le_set_scan_enable()
1835 le_set_scan_enable_complete(hdev, cp->enable); in hci_cc_le_set_scan_enable()
1840 static u8 hci_cc_le_set_ext_scan_enable(struct hci_dev *hdev, void *data, in hci_cc_le_set_ext_scan_enable() argument
1846 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_ext_scan_enable()
1851 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_EXT_SCAN_ENABLE); in hci_cc_le_set_ext_scan_enable()
1855 le_set_scan_enable_complete(hdev, cp->enable); in hci_cc_le_set_ext_scan_enable()
1860 static u8 hci_cc_le_read_num_adv_sets(struct hci_dev *hdev, void *data, in hci_cc_le_read_num_adv_sets() argument
1865 bt_dev_dbg(hdev, "status 0x%2.2x No of Adv sets %u", rp->status, in hci_cc_le_read_num_adv_sets()
1871 hdev->le_num_of_adv_sets = rp->num_of_sets; in hci_cc_le_read_num_adv_sets()
1876 static u8 hci_cc_le_read_accept_list_size(struct hci_dev *hdev, void *data, in hci_cc_le_read_accept_list_size() argument
1881 bt_dev_dbg(hdev, "status 0x%2.2x size %u", rp->status, rp->size); in hci_cc_le_read_accept_list_size()
1886 hdev->le_accept_list_size = rp->size; in hci_cc_le_read_accept_list_size()
1891 static u8 hci_cc_le_clear_accept_list(struct hci_dev *hdev, void *data, in hci_cc_le_clear_accept_list() argument
1896 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_clear_accept_list()
1901 hci_dev_lock(hdev); in hci_cc_le_clear_accept_list()
1902 hci_bdaddr_list_clear(&hdev->le_accept_list); in hci_cc_le_clear_accept_list()
1903 hci_dev_unlock(hdev); in hci_cc_le_clear_accept_list()
1908 static u8 hci_cc_le_add_to_accept_list(struct hci_dev *hdev, void *data, in hci_cc_le_add_to_accept_list() argument
1914 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_add_to_accept_list()
1919 sent = hci_sent_cmd_data(hdev, HCI_OP_LE_ADD_TO_ACCEPT_LIST); in hci_cc_le_add_to_accept_list()
1923 hci_dev_lock(hdev); in hci_cc_le_add_to_accept_list()
1924 hci_bdaddr_list_add(&hdev->le_accept_list, &sent->bdaddr, in hci_cc_le_add_to_accept_list()
1926 hci_dev_unlock(hdev); in hci_cc_le_add_to_accept_list()
1931 static u8 hci_cc_le_del_from_accept_list(struct hci_dev *hdev, void *data, in hci_cc_le_del_from_accept_list() argument
1937 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_del_from_accept_list()
1942 sent = hci_sent_cmd_data(hdev, HCI_OP_LE_DEL_FROM_ACCEPT_LIST); in hci_cc_le_del_from_accept_list()
1946 hci_dev_lock(hdev); in hci_cc_le_del_from_accept_list()
1947 hci_bdaddr_list_del(&hdev->le_accept_list, &sent->bdaddr, in hci_cc_le_del_from_accept_list()
1949 hci_dev_unlock(hdev); in hci_cc_le_del_from_accept_list()
1954 static u8 hci_cc_le_read_supported_states(struct hci_dev *hdev, void *data, in hci_cc_le_read_supported_states() argument
1959 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_read_supported_states()
1964 memcpy(hdev->le_states, rp->le_states, 8); in hci_cc_le_read_supported_states()
1969 static u8 hci_cc_le_read_def_data_len(struct hci_dev *hdev, void *data, in hci_cc_le_read_def_data_len() argument
1974 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_read_def_data_len()
1979 hdev->le_def_tx_len = le16_to_cpu(rp->tx_len); in hci_cc_le_read_def_data_len()
1980 hdev->le_def_tx_time = le16_to_cpu(rp->tx_time); in hci_cc_le_read_def_data_len()
1985 static u8 hci_cc_le_write_def_data_len(struct hci_dev *hdev, void *data, in hci_cc_le_write_def_data_len() argument
1991 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_write_def_data_len()
1996 sent = hci_sent_cmd_data(hdev, HCI_OP_LE_WRITE_DEF_DATA_LEN); in hci_cc_le_write_def_data_len()
2000 hdev->le_def_tx_len = le16_to_cpu(sent->tx_len); in hci_cc_le_write_def_data_len()
2001 hdev->le_def_tx_time = le16_to_cpu(sent->tx_time); in hci_cc_le_write_def_data_len()
2006 static u8 hci_cc_le_add_to_resolv_list(struct hci_dev *hdev, void *data, in hci_cc_le_add_to_resolv_list() argument
2012 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_add_to_resolv_list()
2017 sent = hci_sent_cmd_data(hdev, HCI_OP_LE_ADD_TO_RESOLV_LIST); in hci_cc_le_add_to_resolv_list()
2021 hci_dev_lock(hdev); in hci_cc_le_add_to_resolv_list()
2022 hci_bdaddr_list_add_with_irk(&hdev->le_resolv_list, &sent->bdaddr, in hci_cc_le_add_to_resolv_list()
2025 hci_dev_unlock(hdev); in hci_cc_le_add_to_resolv_list()
2030 static u8 hci_cc_le_del_from_resolv_list(struct hci_dev *hdev, void *data, in hci_cc_le_del_from_resolv_list() argument
2036 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_del_from_resolv_list()
2041 sent = hci_sent_cmd_data(hdev, HCI_OP_LE_DEL_FROM_RESOLV_LIST); in hci_cc_le_del_from_resolv_list()
2045 hci_dev_lock(hdev); in hci_cc_le_del_from_resolv_list()
2046 hci_bdaddr_list_del_with_irk(&hdev->le_resolv_list, &sent->bdaddr, in hci_cc_le_del_from_resolv_list()
2048 hci_dev_unlock(hdev); in hci_cc_le_del_from_resolv_list()
2053 static u8 hci_cc_le_clear_resolv_list(struct hci_dev *hdev, void *data, in hci_cc_le_clear_resolv_list() argument
2058 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_clear_resolv_list()
2063 hci_dev_lock(hdev); in hci_cc_le_clear_resolv_list()
2064 hci_bdaddr_list_clear(&hdev->le_resolv_list); in hci_cc_le_clear_resolv_list()
2065 hci_dev_unlock(hdev); in hci_cc_le_clear_resolv_list()
2070 static u8 hci_cc_le_read_resolv_list_size(struct hci_dev *hdev, void *data, in hci_cc_le_read_resolv_list_size() argument
2075 bt_dev_dbg(hdev, "status 0x%2.2x size %u", rp->status, rp->size); in hci_cc_le_read_resolv_list_size()
2080 hdev->le_resolv_list_size = rp->size; in hci_cc_le_read_resolv_list_size()
2085 static u8 hci_cc_le_set_addr_resolution_enable(struct hci_dev *hdev, void *data, in hci_cc_le_set_addr_resolution_enable() argument
2091 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_addr_resolution_enable()
2096 sent = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE); in hci_cc_le_set_addr_resolution_enable()
2100 hci_dev_lock(hdev); in hci_cc_le_set_addr_resolution_enable()
2103 hci_dev_set_flag(hdev, HCI_LL_RPA_RESOLUTION); in hci_cc_le_set_addr_resolution_enable()
2105 hci_dev_clear_flag(hdev, HCI_LL_RPA_RESOLUTION); in hci_cc_le_set_addr_resolution_enable()
2107 hci_dev_unlock(hdev); in hci_cc_le_set_addr_resolution_enable()
2112 static u8 hci_cc_le_read_max_data_len(struct hci_dev *hdev, void *data, in hci_cc_le_read_max_data_len() argument
2117 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_read_max_data_len()
2122 hdev->le_max_tx_len = le16_to_cpu(rp->tx_len); in hci_cc_le_read_max_data_len()
2123 hdev->le_max_tx_time = le16_to_cpu(rp->tx_time); in hci_cc_le_read_max_data_len()
2124 hdev->le_max_rx_len = le16_to_cpu(rp->rx_len); in hci_cc_le_read_max_data_len()
2125 hdev->le_max_rx_time = le16_to_cpu(rp->rx_time); in hci_cc_le_read_max_data_len()
2130 static u8 hci_cc_write_le_host_supported(struct hci_dev *hdev, void *data, in hci_cc_write_le_host_supported() argument
2136 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_le_host_supported()
2141 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_LE_HOST_SUPPORTED); in hci_cc_write_le_host_supported()
2145 hci_dev_lock(hdev); in hci_cc_write_le_host_supported()
2148 hdev->features[1][0] |= LMP_HOST_LE; in hci_cc_write_le_host_supported()
2149 hci_dev_set_flag(hdev, HCI_LE_ENABLED); in hci_cc_write_le_host_supported()
2151 hdev->features[1][0] &= ~LMP_HOST_LE; in hci_cc_write_le_host_supported()
2152 hci_dev_clear_flag(hdev, HCI_LE_ENABLED); in hci_cc_write_le_host_supported()
2153 hci_dev_clear_flag(hdev, HCI_ADVERTISING); in hci_cc_write_le_host_supported()
2157 hdev->features[1][0] |= LMP_HOST_LE_BREDR; in hci_cc_write_le_host_supported()
2159 hdev->features[1][0] &= ~LMP_HOST_LE_BREDR; in hci_cc_write_le_host_supported()
2161 hci_dev_unlock(hdev); in hci_cc_write_le_host_supported()
2166 static u8 hci_cc_set_adv_param(struct hci_dev *hdev, void *data, in hci_cc_set_adv_param() argument
2172 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_set_adv_param()
2177 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_ADV_PARAM); in hci_cc_set_adv_param()
2181 hci_dev_lock(hdev); in hci_cc_set_adv_param()
2182 hdev->adv_addr_type = cp->own_address_type; in hci_cc_set_adv_param()
2183 hci_dev_unlock(hdev); in hci_cc_set_adv_param()
2188 static u8 hci_cc_set_ext_adv_param(struct hci_dev *hdev, void *data, in hci_cc_set_ext_adv_param() argument
2195 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_set_ext_adv_param()
2200 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_EXT_ADV_PARAMS); in hci_cc_set_ext_adv_param()
2204 hci_dev_lock(hdev); in hci_cc_set_ext_adv_param()
2205 hdev->adv_addr_type = cp->own_addr_type; in hci_cc_set_ext_adv_param()
2208 hdev->adv_tx_power = rp->tx_power; in hci_cc_set_ext_adv_param()
2210 adv_instance = hci_find_adv_instance(hdev, cp->handle); in hci_cc_set_ext_adv_param()
2215 hci_update_adv_data(hdev, cp->handle); in hci_cc_set_ext_adv_param()
2217 hci_dev_unlock(hdev); in hci_cc_set_ext_adv_param()
2222 static u8 hci_cc_read_rssi(struct hci_dev *hdev, void *data, in hci_cc_read_rssi() argument
2228 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_rssi()
2233 hci_dev_lock(hdev); in hci_cc_read_rssi()
2235 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_rssi()
2239 hci_dev_unlock(hdev); in hci_cc_read_rssi()
2244 static u8 hci_cc_read_tx_power(struct hci_dev *hdev, void *data, in hci_cc_read_tx_power() argument
2251 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_tx_power()
2256 sent = hci_sent_cmd_data(hdev, HCI_OP_READ_TX_POWER); in hci_cc_read_tx_power()
2260 hci_dev_lock(hdev); in hci_cc_read_tx_power()
2262 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_tx_power()
2276 hci_dev_unlock(hdev); in hci_cc_read_tx_power()
2280 static u8 hci_cc_write_ssp_debug_mode(struct hci_dev *hdev, void *data, in hci_cc_write_ssp_debug_mode() argument
2286 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_ssp_debug_mode()
2291 mode = hci_sent_cmd_data(hdev, HCI_OP_WRITE_SSP_DEBUG_MODE); in hci_cc_write_ssp_debug_mode()
2293 hdev->ssp_debug_mode = *mode; in hci_cc_write_ssp_debug_mode()
2298 static void hci_cs_inquiry(struct hci_dev *hdev, __u8 status) in hci_cs_inquiry() argument
2300 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_inquiry()
2303 hci_conn_check_pending(hdev); in hci_cs_inquiry()
2307 set_bit(HCI_INQUIRY, &hdev->flags); in hci_cs_inquiry()
2310 static void hci_cs_create_conn(struct hci_dev *hdev, __u8 status) in hci_cs_create_conn() argument
2315 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_create_conn()
2317 cp = hci_sent_cmd_data(hdev, HCI_OP_CREATE_CONN); in hci_cs_create_conn()
2321 hci_dev_lock(hdev); in hci_cs_create_conn()
2323 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cs_create_conn()
2325 bt_dev_dbg(hdev, "bdaddr %pMR hcon %p", &cp->bdaddr, conn); in hci_cs_create_conn()
2338 conn = hci_conn_add(hdev, ACL_LINK, &cp->bdaddr, in hci_cs_create_conn()
2341 bt_dev_err(hdev, "no memory for new connection"); in hci_cs_create_conn()
2345 hci_dev_unlock(hdev); in hci_cs_create_conn()
2348 static void hci_cs_add_sco(struct hci_dev *hdev, __u8 status) in hci_cs_add_sco() argument
2355 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_add_sco()
2360 cp = hci_sent_cmd_data(hdev, HCI_OP_ADD_SCO); in hci_cs_add_sco()
2366 bt_dev_dbg(hdev, "handle 0x%4.4x", handle); in hci_cs_add_sco()
2368 hci_dev_lock(hdev); in hci_cs_add_sco()
2370 acl = hci_conn_hash_lookup_handle(hdev, handle); in hci_cs_add_sco()
2382 hci_dev_unlock(hdev); in hci_cs_add_sco()
2385 static void hci_cs_auth_requested(struct hci_dev *hdev, __u8 status) in hci_cs_auth_requested() argument
2390 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_auth_requested()
2395 cp = hci_sent_cmd_data(hdev, HCI_OP_AUTH_REQUESTED); in hci_cs_auth_requested()
2399 hci_dev_lock(hdev); in hci_cs_auth_requested()
2401 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_auth_requested()
2409 hci_dev_unlock(hdev); in hci_cs_auth_requested()
2412 static void hci_cs_set_conn_encrypt(struct hci_dev *hdev, __u8 status) in hci_cs_set_conn_encrypt() argument
2417 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_set_conn_encrypt()
2422 cp = hci_sent_cmd_data(hdev, HCI_OP_SET_CONN_ENCRYPT); in hci_cs_set_conn_encrypt()
2426 hci_dev_lock(hdev); in hci_cs_set_conn_encrypt()
2428 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_set_conn_encrypt()
2436 hci_dev_unlock(hdev); in hci_cs_set_conn_encrypt()
2439 static int hci_outgoing_auth_needed(struct hci_dev *hdev, in hci_outgoing_auth_needed() argument
2461 static int hci_resolve_name(struct hci_dev *hdev, in hci_resolve_name() argument
2473 return hci_send_cmd(hdev, HCI_OP_REMOTE_NAME_REQ, sizeof(cp), &cp); in hci_resolve_name()
2476 static bool hci_resolve_next_name(struct hci_dev *hdev) in hci_resolve_next_name() argument
2478 struct discovery_state *discov = &hdev->discovery; in hci_resolve_next_name()
2486 bt_dev_warn_ratelimited(hdev, "Name resolve takes too long."); in hci_resolve_next_name()
2490 e = hci_inquiry_cache_lookup_resolve(hdev, BDADDR_ANY, NAME_NEEDED); in hci_resolve_next_name()
2494 if (hci_resolve_name(hdev, e) == 0) { in hci_resolve_next_name()
2502 static void hci_check_pending_name(struct hci_dev *hdev, struct hci_conn *conn, in hci_check_pending_name() argument
2505 struct discovery_state *discov = &hdev->discovery; in hci_check_pending_name()
2516 mgmt_device_connected(hdev, conn, name, name_len); in hci_check_pending_name()
2527 e = hci_inquiry_cache_lookup_resolve(hdev, bdaddr, NAME_PENDING); in hci_check_pending_name()
2538 mgmt_remote_name(hdev, bdaddr, ACL_LINK, 0x00, e->data.rssi, in hci_check_pending_name()
2541 if (hci_resolve_next_name(hdev)) in hci_check_pending_name()
2545 hci_discovery_set_state(hdev, DISCOVERY_STOPPED); in hci_check_pending_name()
2548 static void hci_cs_remote_name_req(struct hci_dev *hdev, __u8 status) in hci_cs_remote_name_req() argument
2553 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_remote_name_req()
2560 cp = hci_sent_cmd_data(hdev, HCI_OP_REMOTE_NAME_REQ); in hci_cs_remote_name_req()
2564 hci_dev_lock(hdev); in hci_cs_remote_name_req()
2566 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cs_remote_name_req()
2568 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_cs_remote_name_req()
2569 hci_check_pending_name(hdev, conn, &cp->bdaddr, NULL, 0); in hci_cs_remote_name_req()
2574 if (!hci_outgoing_auth_needed(hdev, conn)) in hci_cs_remote_name_req()
2583 hci_send_cmd(hdev, HCI_OP_AUTH_REQUESTED, in hci_cs_remote_name_req()
2588 hci_dev_unlock(hdev); in hci_cs_remote_name_req()
2591 static void hci_cs_read_remote_features(struct hci_dev *hdev, __u8 status) in hci_cs_read_remote_features() argument
2596 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_read_remote_features()
2601 cp = hci_sent_cmd_data(hdev, HCI_OP_READ_REMOTE_FEATURES); in hci_cs_read_remote_features()
2605 hci_dev_lock(hdev); in hci_cs_read_remote_features()
2607 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_read_remote_features()
2615 hci_dev_unlock(hdev); in hci_cs_read_remote_features()
2618 static void hci_cs_read_remote_ext_features(struct hci_dev *hdev, __u8 status) in hci_cs_read_remote_ext_features() argument
2623 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_read_remote_ext_features()
2628 cp = hci_sent_cmd_data(hdev, HCI_OP_READ_REMOTE_EXT_FEATURES); in hci_cs_read_remote_ext_features()
2632 hci_dev_lock(hdev); in hci_cs_read_remote_ext_features()
2634 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_read_remote_ext_features()
2642 hci_dev_unlock(hdev); in hci_cs_read_remote_ext_features()
2645 static void hci_setup_sync_conn_status(struct hci_dev *hdev, __u16 handle, in hci_setup_sync_conn_status() argument
2651 bt_dev_dbg(hdev, "handle 0x%4.4x status 0x%2.2x", handle, status); in hci_setup_sync_conn_status()
2653 hci_dev_lock(hdev); in hci_setup_sync_conn_status()
2655 acl = hci_conn_hash_lookup_handle(hdev, handle); in hci_setup_sync_conn_status()
2667 hci_dev_unlock(hdev); in hci_setup_sync_conn_status()
2670 static void hci_cs_setup_sync_conn(struct hci_dev *hdev, __u8 status) in hci_cs_setup_sync_conn() argument
2674 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_setup_sync_conn()
2679 cp = hci_sent_cmd_data(hdev, HCI_OP_SETUP_SYNC_CONN); in hci_cs_setup_sync_conn()
2683 hci_setup_sync_conn_status(hdev, __le16_to_cpu(cp->handle), status); in hci_cs_setup_sync_conn()
2686 static void hci_cs_enhanced_setup_sync_conn(struct hci_dev *hdev, __u8 status) in hci_cs_enhanced_setup_sync_conn() argument
2690 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_enhanced_setup_sync_conn()
2695 cp = hci_sent_cmd_data(hdev, HCI_OP_ENHANCED_SETUP_SYNC_CONN); in hci_cs_enhanced_setup_sync_conn()
2699 hci_setup_sync_conn_status(hdev, __le16_to_cpu(cp->handle), status); in hci_cs_enhanced_setup_sync_conn()
2702 static void hci_cs_sniff_mode(struct hci_dev *hdev, __u8 status) in hci_cs_sniff_mode() argument
2707 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_sniff_mode()
2712 cp = hci_sent_cmd_data(hdev, HCI_OP_SNIFF_MODE); in hci_cs_sniff_mode()
2716 hci_dev_lock(hdev); in hci_cs_sniff_mode()
2718 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_sniff_mode()
2726 hci_dev_unlock(hdev); in hci_cs_sniff_mode()
2729 static void hci_cs_exit_sniff_mode(struct hci_dev *hdev, __u8 status) in hci_cs_exit_sniff_mode() argument
2734 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_exit_sniff_mode()
2739 cp = hci_sent_cmd_data(hdev, HCI_OP_EXIT_SNIFF_MODE); in hci_cs_exit_sniff_mode()
2743 hci_dev_lock(hdev); in hci_cs_exit_sniff_mode()
2745 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_exit_sniff_mode()
2753 hci_dev_unlock(hdev); in hci_cs_exit_sniff_mode()
2756 static void hci_cs_disconnect(struct hci_dev *hdev, u8 status) in hci_cs_disconnect() argument
2763 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_disconnect()
2768 if (!status && !hdev->suspended) in hci_cs_disconnect()
2771 cp = hci_sent_cmd_data(hdev, HCI_OP_DISCONNECT); in hci_cs_disconnect()
2775 hci_dev_lock(hdev); in hci_cs_disconnect()
2777 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_disconnect()
2782 mgmt_disconnect_failed(hdev, &conn->dst, conn->type, in hci_cs_disconnect()
2786 hdev->cur_adv_instance = conn->adv_instance; in hci_cs_disconnect()
2787 hci_enable_advertising(hdev); in hci_cs_disconnect()
2800 hci_remove_link_key(hdev, &conn->dst); in hci_cs_disconnect()
2803 params = hci_conn_params_lookup(hdev, &conn->dst, conn->dst_type); in hci_cs_disconnect()
2814 hci_pend_le_list_add(params, &hdev->pend_le_conns); in hci_cs_disconnect()
2822 mgmt_device_disconnected(hdev, &conn->dst, conn->type, conn->dst_type, in hci_cs_disconnect()
2835 hci_dev_unlock(hdev); in hci_cs_disconnect()
2838 static u8 ev_bdaddr_type(struct hci_dev *hdev, u8 type, bool *resolved) in ev_bdaddr_type() argument
2860 static void cs_le_create_conn(struct hci_dev *hdev, bdaddr_t *peer_addr, in cs_le_create_conn() argument
2866 conn = hci_conn_hash_lookup_le(hdev, peer_addr, in cs_le_create_conn()
2871 own_address_type = ev_bdaddr_type(hdev, own_address_type, NULL); in cs_le_create_conn()
2879 bacpy(&conn->init_addr, &hdev->random_addr); in cs_le_create_conn()
2881 bacpy(&conn->init_addr, &hdev->bdaddr); in cs_le_create_conn()
2887 static void hci_cs_le_create_conn(struct hci_dev *hdev, u8 status) in hci_cs_le_create_conn() argument
2891 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_le_create_conn()
2900 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_CREATE_CONN); in hci_cs_le_create_conn()
2904 hci_dev_lock(hdev); in hci_cs_le_create_conn()
2906 cs_le_create_conn(hdev, &cp->peer_addr, cp->peer_addr_type, in hci_cs_le_create_conn()
2909 hci_dev_unlock(hdev); in hci_cs_le_create_conn()
2912 static void hci_cs_le_ext_create_conn(struct hci_dev *hdev, u8 status) in hci_cs_le_ext_create_conn() argument
2916 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_le_ext_create_conn()
2925 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_EXT_CREATE_CONN); in hci_cs_le_ext_create_conn()
2929 hci_dev_lock(hdev); in hci_cs_le_ext_create_conn()
2931 cs_le_create_conn(hdev, &cp->peer_addr, cp->peer_addr_type, in hci_cs_le_ext_create_conn()
2934 hci_dev_unlock(hdev); in hci_cs_le_ext_create_conn()
2937 static void hci_cs_le_read_remote_features(struct hci_dev *hdev, u8 status) in hci_cs_le_read_remote_features() argument
2942 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_le_read_remote_features()
2947 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_READ_REMOTE_FEATURES); in hci_cs_le_read_remote_features()
2951 hci_dev_lock(hdev); in hci_cs_le_read_remote_features()
2953 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_le_read_remote_features()
2961 hci_dev_unlock(hdev); in hci_cs_le_read_remote_features()
2964 static void hci_cs_le_start_enc(struct hci_dev *hdev, u8 status) in hci_cs_le_start_enc() argument
2969 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_le_start_enc()
2974 hci_dev_lock(hdev); in hci_cs_le_start_enc()
2976 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_START_ENC); in hci_cs_le_start_enc()
2980 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_le_start_enc()
2991 hci_dev_unlock(hdev); in hci_cs_le_start_enc()
2994 static void hci_cs_switch_role(struct hci_dev *hdev, u8 status) in hci_cs_switch_role() argument
2999 BT_DBG("%s status 0x%2.2x", hdev->name, status); in hci_cs_switch_role()
3004 cp = hci_sent_cmd_data(hdev, HCI_OP_SWITCH_ROLE); in hci_cs_switch_role()
3008 hci_dev_lock(hdev); in hci_cs_switch_role()
3010 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cs_switch_role()
3014 hci_dev_unlock(hdev); in hci_cs_switch_role()
3017 static void hci_inquiry_complete_evt(struct hci_dev *hdev, void *data, in hci_inquiry_complete_evt() argument
3021 struct discovery_state *discov = &hdev->discovery; in hci_inquiry_complete_evt()
3024 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_inquiry_complete_evt()
3026 hci_conn_check_pending(hdev); in hci_inquiry_complete_evt()
3028 if (!test_and_clear_bit(HCI_INQUIRY, &hdev->flags)) in hci_inquiry_complete_evt()
3032 wake_up_bit(&hdev->flags, HCI_INQUIRY); in hci_inquiry_complete_evt()
3034 if (!hci_dev_test_flag(hdev, HCI_MGMT)) in hci_inquiry_complete_evt()
3037 hci_dev_lock(hdev); in hci_inquiry_complete_evt()
3050 if (!hci_dev_test_flag(hdev, HCI_LE_SCAN) || in hci_inquiry_complete_evt()
3051 !test_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks)) in hci_inquiry_complete_evt()
3052 hci_discovery_set_state(hdev, DISCOVERY_STOPPED); in hci_inquiry_complete_evt()
3056 e = hci_inquiry_cache_lookup_resolve(hdev, BDADDR_ANY, NAME_NEEDED); in hci_inquiry_complete_evt()
3057 if (e && hci_resolve_name(hdev, e) == 0) { in hci_inquiry_complete_evt()
3059 hci_discovery_set_state(hdev, DISCOVERY_RESOLVING); in hci_inquiry_complete_evt()
3069 if (!hci_dev_test_flag(hdev, HCI_LE_SCAN) || in hci_inquiry_complete_evt()
3070 !test_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks)) in hci_inquiry_complete_evt()
3071 hci_discovery_set_state(hdev, DISCOVERY_STOPPED); in hci_inquiry_complete_evt()
3075 hci_dev_unlock(hdev); in hci_inquiry_complete_evt()
3078 static void hci_inquiry_result_evt(struct hci_dev *hdev, void *edata, in hci_inquiry_result_evt() argument
3085 if (!hci_ev_skb_pull(hdev, skb, HCI_EV_INQUIRY_RESULT, in hci_inquiry_result_evt()
3089 bt_dev_dbg(hdev, "num %d", ev->num); in hci_inquiry_result_evt()
3094 if (hci_dev_test_flag(hdev, HCI_PERIODIC_INQ)) in hci_inquiry_result_evt()
3097 hci_dev_lock(hdev); in hci_inquiry_result_evt()
3112 flags = hci_inquiry_cache_update(hdev, &data, false); in hci_inquiry_result_evt()
3114 mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, in hci_inquiry_result_evt()
3119 hci_dev_unlock(hdev); in hci_inquiry_result_evt()
3122 static void hci_conn_complete_evt(struct hci_dev *hdev, void *data, in hci_conn_complete_evt() argument
3129 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_conn_complete_evt()
3131 hci_dev_lock(hdev); in hci_conn_complete_evt()
3133 conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, &ev->bdaddr); in hci_conn_complete_evt()
3151 hci_bdaddr_list_lookup_with_flags(&hdev->accept_list, in hci_conn_complete_evt()
3154 conn = hci_conn_add(hdev, ev->link_type, &ev->bdaddr, in hci_conn_complete_evt()
3157 bt_dev_err(hdev, "no memory for new conn"); in hci_conn_complete_evt()
3164 conn = hci_conn_hash_lookup_ba(hdev, ESCO_LINK, in hci_conn_complete_evt()
3180 bt_dev_err(hdev, "Ignoring HCI_Connection_Complete for existing connection"); in hci_conn_complete_evt()
3194 !hci_find_link_key(hdev, &ev->bdaddr)) in hci_conn_complete_evt()
3204 if (test_bit(HCI_AUTH, &hdev->flags)) in hci_conn_complete_evt()
3207 if (test_bit(HCI_ENCRYPT, &hdev->flags)) in hci_conn_complete_evt()
3214 hci_send_cmd(hdev, HCI_OP_READ_REMOTE_FEATURES, in hci_conn_complete_evt()
3217 hci_update_scan(hdev); in hci_conn_complete_evt()
3221 if (!conn->out && hdev->hci_ver < BLUETOOTH_VER_2_0) { in hci_conn_complete_evt()
3225 hci_send_cmd(hdev, HCI_OP_CHANGE_CONN_PTYPE, sizeof(cp), in hci_conn_complete_evt()
3239 if (hdev->notify) in hci_conn_complete_evt()
3240 hdev->notify(hdev, HCI_NOTIFY_ENABLE_SCO_CVSD); in hci_conn_complete_evt()
3248 hci_dev_unlock(hdev); in hci_conn_complete_evt()
3250 hci_conn_check_pending(hdev); in hci_conn_complete_evt()
3253 static void hci_reject_conn(struct hci_dev *hdev, bdaddr_t *bdaddr) in hci_reject_conn() argument
3259 hci_send_cmd(hdev, HCI_OP_REJECT_CONN_REQ, sizeof(cp), &cp); in hci_reject_conn()
3262 static void hci_conn_request_evt(struct hci_dev *hdev, void *data, in hci_conn_request_evt() argument
3266 int mask = hdev->link_mode; in hci_conn_request_evt()
3271 bt_dev_dbg(hdev, "bdaddr %pMR type 0x%x", &ev->bdaddr, ev->link_type); in hci_conn_request_evt()
3276 if (hdev && !bacmp(&hdev->bdaddr, &ev->bdaddr)) { in hci_conn_request_evt()
3277 bt_dev_dbg(hdev, "Reject connection with same BD_ADDR %pMR\n", in hci_conn_request_evt()
3279 hci_reject_conn(hdev, &ev->bdaddr); in hci_conn_request_evt()
3283 mask |= hci_proto_connect_ind(hdev, &ev->bdaddr, ev->link_type, in hci_conn_request_evt()
3287 hci_reject_conn(hdev, &ev->bdaddr); in hci_conn_request_evt()
3291 hci_dev_lock(hdev); in hci_conn_request_evt()
3293 if (hci_bdaddr_list_lookup(&hdev->reject_list, &ev->bdaddr, in hci_conn_request_evt()
3295 hci_reject_conn(hdev, &ev->bdaddr); in hci_conn_request_evt()
3303 if (hci_dev_test_flag(hdev, HCI_MGMT) && in hci_conn_request_evt()
3304 !hci_dev_test_flag(hdev, HCI_CONNECTABLE) && in hci_conn_request_evt()
3305 !hci_bdaddr_list_lookup_with_flags(&hdev->accept_list, &ev->bdaddr, in hci_conn_request_evt()
3307 hci_reject_conn(hdev, &ev->bdaddr); in hci_conn_request_evt()
3313 ie = hci_inquiry_cache_lookup(hdev, &ev->bdaddr); in hci_conn_request_evt()
3317 conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, in hci_conn_request_evt()
3320 conn = hci_conn_add(hdev, ev->link_type, &ev->bdaddr, in hci_conn_request_evt()
3323 bt_dev_err(hdev, "no memory for new connection"); in hci_conn_request_evt()
3330 hci_dev_unlock(hdev); in hci_conn_request_evt()
3333 (!(flags & HCI_PROTO_DEFER) && !lmp_esco_capable(hdev))) { in hci_conn_request_evt()
3339 if (lmp_rswitch_capable(hdev) && (mask & HCI_LM_MASTER)) in hci_conn_request_evt()
3344 hci_send_cmd(hdev, HCI_OP_ACCEPT_CONN_REQ, sizeof(cp), &cp); in hci_conn_request_evt()
3355 cp.content_format = cpu_to_le16(hdev->voice_setting); in hci_conn_request_evt()
3358 hci_send_cmd(hdev, HCI_OP_ACCEPT_SYNC_CONN_REQ, sizeof(cp), in hci_conn_request_evt()
3367 hci_dev_unlock(hdev); in hci_conn_request_evt()
3386 static void hci_disconn_complete_evt(struct hci_dev *hdev, void *data, in hci_disconn_complete_evt() argument
3395 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_disconn_complete_evt()
3397 hci_dev_lock(hdev); in hci_disconn_complete_evt()
3399 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_disconn_complete_evt()
3404 mgmt_disconnect_failed(hdev, &conn->dst, conn->type, in hci_disconn_complete_evt()
3418 mgmt_device_disconnected(hdev, &conn->dst, conn->type, conn->dst_type, in hci_disconn_complete_evt()
3423 hci_remove_link_key(hdev, &conn->dst); in hci_disconn_complete_evt()
3425 hci_update_scan(hdev); in hci_disconn_complete_evt()
3428 params = hci_conn_params_lookup(hdev, &conn->dst, conn->dst_type); in hci_disconn_complete_evt()
3439 hci_pend_le_list_add(params, &hdev->pend_le_conns); in hci_disconn_complete_evt()
3440 hci_update_passive_scan(hdev); in hci_disconn_complete_evt()
3461 hdev->cur_adv_instance = conn->adv_instance; in hci_disconn_complete_evt()
3462 hci_enable_advertising(hdev); in hci_disconn_complete_evt()
3468 hci_dev_unlock(hdev); in hci_disconn_complete_evt()
3471 static void hci_auth_complete_evt(struct hci_dev *hdev, void *data, in hci_auth_complete_evt() argument
3477 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_auth_complete_evt()
3479 hci_dev_lock(hdev); in hci_auth_complete_evt()
3481 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_auth_complete_evt()
3490 bt_dev_info(hdev, "re-auth of legacy device is not possible."); in hci_auth_complete_evt()
3510 hci_send_cmd(hdev, HCI_OP_SET_CONN_ENCRYPT, sizeof(cp), in hci_auth_complete_evt()
3530 hci_send_cmd(hdev, HCI_OP_SET_CONN_ENCRYPT, sizeof(cp), in hci_auth_complete_evt()
3539 hci_dev_unlock(hdev); in hci_auth_complete_evt()
3542 static void hci_remote_name_evt(struct hci_dev *hdev, void *data, in hci_remote_name_evt() argument
3548 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_remote_name_evt()
3550 hci_conn_check_pending(hdev); in hci_remote_name_evt()
3552 hci_dev_lock(hdev); in hci_remote_name_evt()
3554 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_remote_name_evt()
3556 if (!hci_dev_test_flag(hdev, HCI_MGMT)) in hci_remote_name_evt()
3560 hci_check_pending_name(hdev, conn, &ev->bdaddr, ev->name, in hci_remote_name_evt()
3563 hci_check_pending_name(hdev, conn, &ev->bdaddr, NULL, 0); in hci_remote_name_evt()
3569 if (!hci_outgoing_auth_needed(hdev, conn)) in hci_remote_name_evt()
3578 hci_send_cmd(hdev, HCI_OP_AUTH_REQUESTED, sizeof(cp), &cp); in hci_remote_name_evt()
3582 hci_dev_unlock(hdev); in hci_remote_name_evt()
3585 static void hci_encrypt_change_evt(struct hci_dev *hdev, void *data, in hci_encrypt_change_evt() argument
3591 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_encrypt_change_evt()
3593 hci_dev_lock(hdev); in hci_encrypt_change_evt()
3595 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_encrypt_change_evt()
3623 hci_dev_set_flag(hdev, HCI_RPA_EXPIRED); in hci_encrypt_change_evt()
3624 hci_adv_instances_set_rpa_expired(hdev, true); in hci_encrypt_change_evt()
3654 if (!(hdev->commands[20] & 0x10)) { in hci_encrypt_change_evt()
3660 if (hci_send_cmd(hdev, HCI_OP_READ_ENC_KEY_SIZE, in hci_encrypt_change_evt()
3662 bt_dev_err(hdev, "sending read key size failed"); in hci_encrypt_change_evt()
3679 ((conn->type == ACL_LINK && lmp_ping_capable(hdev)) || in hci_encrypt_change_evt()
3680 (conn->type == LE_LINK && (hdev->le_features[0] & HCI_LE_PING)))) { in hci_encrypt_change_evt()
3684 cp.timeout = cpu_to_le16(hdev->auth_payload_timeout); in hci_encrypt_change_evt()
3685 if (hci_send_cmd(conn->hdev, HCI_OP_WRITE_AUTH_PAYLOAD_TO, in hci_encrypt_change_evt()
3687 bt_dev_err(hdev, "write auth payload timeout failed"); in hci_encrypt_change_evt()
3698 hci_dev_unlock(hdev); in hci_encrypt_change_evt()
3701 static void hci_change_link_key_complete_evt(struct hci_dev *hdev, void *data, in hci_change_link_key_complete_evt() argument
3707 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_change_link_key_complete_evt()
3709 hci_dev_lock(hdev); in hci_change_link_key_complete_evt()
3711 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_change_link_key_complete_evt()
3721 hci_dev_unlock(hdev); in hci_change_link_key_complete_evt()
3724 static void hci_remote_features_evt(struct hci_dev *hdev, void *data, in hci_remote_features_evt() argument
3730 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_remote_features_evt()
3732 hci_dev_lock(hdev); in hci_remote_features_evt()
3734 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_remote_features_evt()
3744 if (!ev->status && lmp_ext_feat_capable(hdev) && in hci_remote_features_evt()
3749 hci_send_cmd(hdev, HCI_OP_READ_REMOTE_EXT_FEATURES, in hci_remote_features_evt()
3759 hci_send_cmd(hdev, HCI_OP_REMOTE_NAME_REQ, sizeof(cp), &cp); in hci_remote_features_evt()
3761 mgmt_device_connected(hdev, conn, NULL, 0); in hci_remote_features_evt()
3763 if (!hci_outgoing_auth_needed(hdev, conn)) { in hci_remote_features_evt()
3770 hci_dev_unlock(hdev); in hci_remote_features_evt()
3773 static inline void handle_cmd_cnt_and_timer(struct hci_dev *hdev, u8 ncmd) in handle_cmd_cnt_and_timer() argument
3775 cancel_delayed_work(&hdev->cmd_timer); in handle_cmd_cnt_and_timer()
3778 if (!test_bit(HCI_RESET, &hdev->flags)) { in handle_cmd_cnt_and_timer()
3780 cancel_delayed_work(&hdev->ncmd_timer); in handle_cmd_cnt_and_timer()
3781 atomic_set(&hdev->cmd_cnt, 1); in handle_cmd_cnt_and_timer()
3783 if (!hci_dev_test_flag(hdev, HCI_CMD_DRAIN_WORKQUEUE)) in handle_cmd_cnt_and_timer()
3784 queue_delayed_work(hdev->workqueue, &hdev->ncmd_timer, in handle_cmd_cnt_and_timer()
3791 static u8 hci_cc_le_read_buffer_size_v2(struct hci_dev *hdev, void *data, in hci_cc_le_read_buffer_size_v2() argument
3796 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_read_buffer_size_v2()
3801 hdev->le_mtu = __le16_to_cpu(rp->acl_mtu); in hci_cc_le_read_buffer_size_v2()
3802 hdev->le_pkts = rp->acl_max_pkt; in hci_cc_le_read_buffer_size_v2()
3803 hdev->iso_mtu = __le16_to_cpu(rp->iso_mtu); in hci_cc_le_read_buffer_size_v2()
3804 hdev->iso_pkts = rp->iso_max_pkt; in hci_cc_le_read_buffer_size_v2()
3806 hdev->le_cnt = hdev->le_pkts; in hci_cc_le_read_buffer_size_v2()
3807 hdev->iso_cnt = hdev->iso_pkts; in hci_cc_le_read_buffer_size_v2()
3809 BT_DBG("%s acl mtu %d:%d iso mtu %d:%d", hdev->name, hdev->acl_mtu, in hci_cc_le_read_buffer_size_v2()
3810 hdev->acl_pkts, hdev->iso_mtu, hdev->iso_pkts); in hci_cc_le_read_buffer_size_v2()
3815 static void hci_unbound_cis_failed(struct hci_dev *hdev, u8 cig, u8 status) in hci_unbound_cis_failed() argument
3819 lockdep_assert_held(&hdev->lock); in hci_unbound_cis_failed()
3821 list_for_each_entry_safe(conn, tmp, &hdev->conn_hash.list, list) { in hci_unbound_cis_failed()
3831 static u8 hci_cc_le_set_cig_params(struct hci_dev *hdev, void *data, in hci_cc_le_set_cig_params() argument
3841 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_cig_params()
3843 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_CIG_PARAMS); in hci_cc_le_set_cig_params()
3846 bt_dev_err(hdev, "unexpected Set CIG Parameters response data"); in hci_cc_le_set_cig_params()
3850 hci_dev_lock(hdev); in hci_cc_le_set_cig_params()
3860 hci_unbound_cis_failed(hdev, rp->cig_id, status); in hci_cc_le_set_cig_params()
3872 conn = hci_conn_hash_lookup_cis(hdev, NULL, 0, rp->cig_id, in hci_cc_le_set_cig_params()
3889 hci_le_create_cis_pending(hdev); in hci_cc_le_set_cig_params()
3891 hci_dev_unlock(hdev); in hci_cc_le_set_cig_params()
3896 static u8 hci_cc_le_setup_iso_path(struct hci_dev *hdev, void *data, in hci_cc_le_setup_iso_path() argument
3903 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_setup_iso_path()
3905 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SETUP_ISO_PATH); in hci_cc_le_setup_iso_path()
3909 hci_dev_lock(hdev); in hci_cc_le_setup_iso_path()
3911 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cc_le_setup_iso_path()
3938 hci_dev_unlock(hdev); in hci_cc_le_setup_iso_path()
3942 static void hci_cs_le_create_big(struct hci_dev *hdev, u8 status) in hci_cs_le_create_big() argument
3944 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_le_create_big()
3947 static u8 hci_cc_set_per_adv_param(struct hci_dev *hdev, void *data, in hci_cc_set_per_adv_param() argument
3953 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_set_per_adv_param()
3958 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_PER_ADV_PARAMS); in hci_cc_set_per_adv_param()
3966 static u8 hci_cc_le_set_per_adv_enable(struct hci_dev *hdev, void *data, in hci_cc_le_set_per_adv_enable() argument
3974 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_per_adv_enable()
3979 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_PER_ADV_ENABLE); in hci_cc_le_set_per_adv_enable()
3983 hci_dev_lock(hdev); in hci_cc_le_set_per_adv_enable()
3985 adv = hci_find_adv_instance(hdev, cp->handle); in hci_cc_le_set_per_adv_enable()
3988 hci_dev_set_flag(hdev, HCI_LE_PER_ADV); in hci_cc_le_set_per_adv_enable()
3998 list_for_each_entry_safe(adv, n, &hdev->adv_instances, in hci_cc_le_set_per_adv_enable()
4007 hci_dev_clear_flag(hdev, HCI_LE_PER_ADV); in hci_cc_le_set_per_adv_enable()
4011 hci_dev_unlock(hdev); in hci_cc_le_set_per_adv_enable()
4032 u8 (*func)(struct hci_dev *hdev, void *data, struct sk_buff *skb);
4205 static u8 hci_cc_func(struct hci_dev *hdev, const struct hci_cc *cc, in hci_cc_func() argument
4211 bt_dev_err(hdev, "unexpected cc 0x%4.4x length: %u < %u", in hci_cc_func()
4221 bt_dev_warn(hdev, "unexpected cc 0x%4.4x length: %u > %u", in hci_cc_func()
4224 data = hci_cc_skb_pull(hdev, skb, cc->op, cc->min_len); in hci_cc_func()
4228 return cc->func(hdev, data, skb); in hci_cc_func()
4231 static void hci_cmd_complete_evt(struct hci_dev *hdev, void *data, in hci_cmd_complete_evt() argument
4241 bt_dev_dbg(hdev, "opcode 0x%4.4x", *opcode); in hci_cmd_complete_evt()
4245 *status = hci_cc_func(hdev, &hci_cc_table[i], skb); in hci_cmd_complete_evt()
4261 handle_cmd_cnt_and_timer(hdev, ev->ncmd); in hci_cmd_complete_evt()
4263 hci_req_cmd_complete(hdev, *opcode, *status, req_complete, in hci_cmd_complete_evt()
4266 if (hci_dev_test_flag(hdev, HCI_CMD_PENDING)) { in hci_cmd_complete_evt()
4267 bt_dev_err(hdev, in hci_cmd_complete_evt()
4272 if (atomic_read(&hdev->cmd_cnt) && !skb_queue_empty(&hdev->cmd_q)) in hci_cmd_complete_evt()
4273 queue_work(hdev->workqueue, &hdev->cmd_work); in hci_cmd_complete_evt()
4276 static void hci_cs_le_create_cis(struct hci_dev *hdev, u8 status) in hci_cs_le_create_cis() argument
4282 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_le_create_cis()
4287 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_CREATE_CIS); in hci_cs_le_create_cis()
4291 hci_dev_lock(hdev); in hci_cs_le_create_cis()
4300 conn = hci_conn_hash_lookup_handle(hdev, handle); in hci_cs_le_create_cis()
4312 hci_le_create_cis_pending(hdev); in hci_cs_le_create_cis()
4314 hci_dev_unlock(hdev); in hci_cs_le_create_cis()
4325 void (*func)(struct hci_dev *hdev, __u8 status);
4351 static void hci_cmd_status_evt(struct hci_dev *hdev, void *data, in hci_cmd_status_evt() argument
4362 bt_dev_dbg(hdev, "opcode 0x%4.4x", *opcode); in hci_cmd_status_evt()
4366 hci_cs_table[i].func(hdev, ev->status); in hci_cmd_status_evt()
4371 handle_cmd_cnt_and_timer(hdev, ev->ncmd); in hci_cmd_status_evt()
4379 if (ev->status || (hdev->sent_cmd && !hci_skb_event(hdev->sent_cmd))) { in hci_cmd_status_evt()
4380 hci_req_cmd_complete(hdev, *opcode, ev->status, req_complete, in hci_cmd_status_evt()
4382 if (hci_dev_test_flag(hdev, HCI_CMD_PENDING)) { in hci_cmd_status_evt()
4383 bt_dev_err(hdev, "unexpected event for opcode 0x%4.4x", in hci_cmd_status_evt()
4389 if (atomic_read(&hdev->cmd_cnt) && !skb_queue_empty(&hdev->cmd_q)) in hci_cmd_status_evt()
4390 queue_work(hdev->workqueue, &hdev->cmd_work); in hci_cmd_status_evt()
4393 static void hci_hardware_error_evt(struct hci_dev *hdev, void *data, in hci_hardware_error_evt() argument
4398 bt_dev_dbg(hdev, "code 0x%2.2x", ev->code); in hci_hardware_error_evt()
4400 hdev->hw_error_code = ev->code; in hci_hardware_error_evt()
4402 queue_work(hdev->req_workqueue, &hdev->error_reset); in hci_hardware_error_evt()
4405 static void hci_role_change_evt(struct hci_dev *hdev, void *data, in hci_role_change_evt() argument
4411 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_role_change_evt()
4413 hci_dev_lock(hdev); in hci_role_change_evt()
4415 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_role_change_evt()
4425 hci_dev_unlock(hdev); in hci_role_change_evt()
4428 static void hci_num_comp_pkts_evt(struct hci_dev *hdev, void *data, in hci_num_comp_pkts_evt() argument
4434 if (!hci_ev_skb_pull(hdev, skb, HCI_EV_NUM_COMP_PKTS, in hci_num_comp_pkts_evt()
4438 if (hdev->flow_ctl_mode != HCI_FLOW_CTL_MODE_PACKET_BASED) { in hci_num_comp_pkts_evt()
4439 bt_dev_err(hdev, "wrong event for mode %d", hdev->flow_ctl_mode); in hci_num_comp_pkts_evt()
4443 bt_dev_dbg(hdev, "num %d", ev->num); in hci_num_comp_pkts_evt()
4453 conn = hci_conn_hash_lookup_handle(hdev, handle); in hci_num_comp_pkts_evt()
4461 hdev->acl_cnt += count; in hci_num_comp_pkts_evt()
4462 if (hdev->acl_cnt > hdev->acl_pkts) in hci_num_comp_pkts_evt()
4463 hdev->acl_cnt = hdev->acl_pkts; in hci_num_comp_pkts_evt()
4467 if (hdev->le_pkts) { in hci_num_comp_pkts_evt()
4468 hdev->le_cnt += count; in hci_num_comp_pkts_evt()
4469 if (hdev->le_cnt > hdev->le_pkts) in hci_num_comp_pkts_evt()
4470 hdev->le_cnt = hdev->le_pkts; in hci_num_comp_pkts_evt()
4472 hdev->acl_cnt += count; in hci_num_comp_pkts_evt()
4473 if (hdev->acl_cnt > hdev->acl_pkts) in hci_num_comp_pkts_evt()
4474 hdev->acl_cnt = hdev->acl_pkts; in hci_num_comp_pkts_evt()
4479 hdev->sco_cnt += count; in hci_num_comp_pkts_evt()
4480 if (hdev->sco_cnt > hdev->sco_pkts) in hci_num_comp_pkts_evt()
4481 hdev->sco_cnt = hdev->sco_pkts; in hci_num_comp_pkts_evt()
4485 if (hdev->iso_pkts) { in hci_num_comp_pkts_evt()
4486 hdev->iso_cnt += count; in hci_num_comp_pkts_evt()
4487 if (hdev->iso_cnt > hdev->iso_pkts) in hci_num_comp_pkts_evt()
4488 hdev->iso_cnt = hdev->iso_pkts; in hci_num_comp_pkts_evt()
4489 } else if (hdev->le_pkts) { in hci_num_comp_pkts_evt()
4490 hdev->le_cnt += count; in hci_num_comp_pkts_evt()
4491 if (hdev->le_cnt > hdev->le_pkts) in hci_num_comp_pkts_evt()
4492 hdev->le_cnt = hdev->le_pkts; in hci_num_comp_pkts_evt()
4494 hdev->acl_cnt += count; in hci_num_comp_pkts_evt()
4495 if (hdev->acl_cnt > hdev->acl_pkts) in hci_num_comp_pkts_evt()
4496 hdev->acl_cnt = hdev->acl_pkts; in hci_num_comp_pkts_evt()
4501 bt_dev_err(hdev, "unknown type %d conn %p", in hci_num_comp_pkts_evt()
4507 queue_work(hdev->workqueue, &hdev->tx_work); in hci_num_comp_pkts_evt()
4510 static struct hci_conn *__hci_conn_lookup_handle(struct hci_dev *hdev, in __hci_conn_lookup_handle() argument
4515 switch (hdev->dev_type) { in __hci_conn_lookup_handle()
4517 return hci_conn_hash_lookup_handle(hdev, handle); in __hci_conn_lookup_handle()
4519 chan = hci_chan_lookup_handle(hdev, handle); in __hci_conn_lookup_handle()
4524 bt_dev_err(hdev, "unknown dev_type %d", hdev->dev_type); in __hci_conn_lookup_handle()
4531 static void hci_num_comp_blocks_evt(struct hci_dev *hdev, void *data, in hci_num_comp_blocks_evt() argument
4537 if (!hci_ev_skb_pull(hdev, skb, HCI_EV_NUM_COMP_BLOCKS, in hci_num_comp_blocks_evt()
4541 if (hdev->flow_ctl_mode != HCI_FLOW_CTL_MODE_BLOCK_BASED) { in hci_num_comp_blocks_evt()
4542 bt_dev_err(hdev, "wrong event for mode %d", in hci_num_comp_blocks_evt()
4543 hdev->flow_ctl_mode); in hci_num_comp_blocks_evt()
4547 bt_dev_dbg(hdev, "num_blocks %d num_hndl %d", ev->num_blocks, in hci_num_comp_blocks_evt()
4558 conn = __hci_conn_lookup_handle(hdev, handle); in hci_num_comp_blocks_evt()
4567 hdev->block_cnt += block_count; in hci_num_comp_blocks_evt()
4568 if (hdev->block_cnt > hdev->num_blocks) in hci_num_comp_blocks_evt()
4569 hdev->block_cnt = hdev->num_blocks; in hci_num_comp_blocks_evt()
4573 bt_dev_err(hdev, "unknown type %d conn %p", in hci_num_comp_blocks_evt()
4579 queue_work(hdev->workqueue, &hdev->tx_work); in hci_num_comp_blocks_evt()
4582 static void hci_mode_change_evt(struct hci_dev *hdev, void *data, in hci_mode_change_evt() argument
4588 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_mode_change_evt()
4590 hci_dev_lock(hdev); in hci_mode_change_evt()
4592 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_mode_change_evt()
4608 hci_dev_unlock(hdev); in hci_mode_change_evt()
4611 static void hci_pin_code_request_evt(struct hci_dev *hdev, void *data, in hci_pin_code_request_evt() argument
4617 bt_dev_dbg(hdev, ""); in hci_pin_code_request_evt()
4619 hci_dev_lock(hdev); in hci_pin_code_request_evt()
4621 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_pin_code_request_evt()
4631 if (!hci_dev_test_flag(hdev, HCI_BONDABLE) && in hci_pin_code_request_evt()
4633 hci_send_cmd(hdev, HCI_OP_PIN_CODE_NEG_REPLY, in hci_pin_code_request_evt()
4635 } else if (hci_dev_test_flag(hdev, HCI_MGMT)) { in hci_pin_code_request_evt()
4643 mgmt_pin_code_request(hdev, &ev->bdaddr, secure); in hci_pin_code_request_evt()
4647 hci_dev_unlock(hdev); in hci_pin_code_request_evt()
4682 static void hci_link_key_request_evt(struct hci_dev *hdev, void *data, in hci_link_key_request_evt() argument
4690 bt_dev_dbg(hdev, ""); in hci_link_key_request_evt()
4692 if (!hci_dev_test_flag(hdev, HCI_MGMT)) in hci_link_key_request_evt()
4695 hci_dev_lock(hdev); in hci_link_key_request_evt()
4697 key = hci_find_link_key(hdev, &ev->bdaddr); in hci_link_key_request_evt()
4699 bt_dev_dbg(hdev, "link key not found for %pMR", &ev->bdaddr); in hci_link_key_request_evt()
4703 bt_dev_dbg(hdev, "found key type %u for %pMR", key->type, &ev->bdaddr); in hci_link_key_request_evt()
4705 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_link_key_request_evt()
4712 bt_dev_dbg(hdev, "ignoring unauthenticated key"); in hci_link_key_request_evt()
4719 bt_dev_dbg(hdev, "ignoring key unauthenticated for high security"); in hci_link_key_request_evt()
4729 hci_send_cmd(hdev, HCI_OP_LINK_KEY_REPLY, sizeof(cp), &cp); in hci_link_key_request_evt()
4731 hci_dev_unlock(hdev); in hci_link_key_request_evt()
4736 hci_send_cmd(hdev, HCI_OP_LINK_KEY_NEG_REPLY, 6, &ev->bdaddr); in hci_link_key_request_evt()
4737 hci_dev_unlock(hdev); in hci_link_key_request_evt()
4740 static void hci_link_key_notify_evt(struct hci_dev *hdev, void *data, in hci_link_key_notify_evt() argument
4749 bt_dev_dbg(hdev, ""); in hci_link_key_notify_evt()
4751 hci_dev_lock(hdev); in hci_link_key_notify_evt()
4753 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_link_key_notify_evt()
4759 bt_dev_dbg(hdev, "Ignore NULL link key (ZERO KEY) for %pMR", in hci_link_key_notify_evt()
4773 if (!hci_dev_test_flag(hdev, HCI_MGMT)) in hci_link_key_notify_evt()
4776 key = hci_add_link_key(hdev, conn, &ev->bdaddr, ev->link_key, in hci_link_key_notify_evt()
4787 mgmt_new_link_key(hdev, key, persistent); in hci_link_key_notify_evt()
4795 !hci_dev_test_flag(hdev, HCI_KEEP_DEBUG_KEYS)) { in hci_link_key_notify_evt()
4807 hci_dev_unlock(hdev); in hci_link_key_notify_evt()
4810 static void hci_clock_offset_evt(struct hci_dev *hdev, void *data, in hci_clock_offset_evt() argument
4816 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_clock_offset_evt()
4818 hci_dev_lock(hdev); in hci_clock_offset_evt()
4820 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_clock_offset_evt()
4824 ie = hci_inquiry_cache_lookup(hdev, &conn->dst); in hci_clock_offset_evt()
4831 hci_dev_unlock(hdev); in hci_clock_offset_evt()
4834 static void hci_pkt_type_change_evt(struct hci_dev *hdev, void *data, in hci_pkt_type_change_evt() argument
4840 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_pkt_type_change_evt()
4842 hci_dev_lock(hdev); in hci_pkt_type_change_evt()
4844 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_pkt_type_change_evt()
4848 hci_dev_unlock(hdev); in hci_pkt_type_change_evt()
4851 static void hci_pscan_rep_mode_evt(struct hci_dev *hdev, void *data, in hci_pscan_rep_mode_evt() argument
4857 bt_dev_dbg(hdev, ""); in hci_pscan_rep_mode_evt()
4859 hci_dev_lock(hdev); in hci_pscan_rep_mode_evt()
4861 ie = hci_inquiry_cache_lookup(hdev, &ev->bdaddr); in hci_pscan_rep_mode_evt()
4867 hci_dev_unlock(hdev); in hci_pscan_rep_mode_evt()
4870 static void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, void *edata, in hci_inquiry_result_with_rssi_evt() argument
4877 bt_dev_dbg(hdev, "num_rsp %d", ev->num); in hci_inquiry_result_with_rssi_evt()
4882 if (hci_dev_test_flag(hdev, HCI_PERIODIC_INQ)) in hci_inquiry_result_with_rssi_evt()
4885 hci_dev_lock(hdev); in hci_inquiry_result_with_rssi_evt()
4894 info = hci_ev_skb_pull(hdev, skb, in hci_inquiry_result_with_rssi_evt()
4898 bt_dev_err(hdev, "Malformed HCI Event: 0x%2.2x", in hci_inquiry_result_with_rssi_evt()
4912 flags = hci_inquiry_cache_update(hdev, &data, false); in hci_inquiry_result_with_rssi_evt()
4914 mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, in hci_inquiry_result_with_rssi_evt()
4925 info = hci_ev_skb_pull(hdev, skb, in hci_inquiry_result_with_rssi_evt()
4929 bt_dev_err(hdev, "Malformed HCI Event: 0x%2.2x", in hci_inquiry_result_with_rssi_evt()
4943 flags = hci_inquiry_cache_update(hdev, &data, false); in hci_inquiry_result_with_rssi_evt()
4945 mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, in hci_inquiry_result_with_rssi_evt()
4950 bt_dev_err(hdev, "Malformed HCI Event: 0x%2.2x", in hci_inquiry_result_with_rssi_evt()
4954 hci_dev_unlock(hdev); in hci_inquiry_result_with_rssi_evt()
4957 static void hci_remote_ext_features_evt(struct hci_dev *hdev, void *data, in hci_remote_ext_features_evt() argument
4963 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_remote_ext_features_evt()
4965 hci_dev_lock(hdev); in hci_remote_ext_features_evt()
4967 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_remote_ext_features_evt()
4977 ie = hci_inquiry_cache_lookup(hdev, &conn->dst); in hci_remote_ext_features_evt()
5007 hci_send_cmd(hdev, HCI_OP_REMOTE_NAME_REQ, sizeof(cp), &cp); in hci_remote_ext_features_evt()
5009 mgmt_device_connected(hdev, conn, NULL, 0); in hci_remote_ext_features_evt()
5011 if (!hci_outgoing_auth_needed(hdev, conn)) { in hci_remote_ext_features_evt()
5018 hci_dev_unlock(hdev); in hci_remote_ext_features_evt()
5021 static void hci_sync_conn_complete_evt(struct hci_dev *hdev, void *data, in hci_sync_conn_complete_evt() argument
5037 bt_dev_err(hdev, "Ignoring connect complete event for invalid link type"); in hci_sync_conn_complete_evt()
5041 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_sync_conn_complete_evt()
5043 hci_dev_lock(hdev); in hci_sync_conn_complete_evt()
5045 conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, &ev->bdaddr); in hci_sync_conn_complete_evt()
5059 conn = hci_conn_hash_lookup_ba(hdev, ESCO_LINK, &ev->bdaddr); in hci_sync_conn_complete_evt()
5071 bt_dev_err(hdev, "Ignoring HCI_Sync_Conn_Complete event for existing connection"); in hci_sync_conn_complete_evt()
5099 conn->pkt_type = (hdev->esco_type & SCO_ESCO_MASK) | in hci_sync_conn_complete_evt()
5100 (hdev->esco_type & EDR_ESCO_MASK); in hci_sync_conn_complete_evt()
5111 bt_dev_dbg(hdev, "SCO connected with air mode: %02x", ev->air_mode); in hci_sync_conn_complete_evt()
5115 if (conn->codec.data_path == 0 && hdev->notify) { in hci_sync_conn_complete_evt()
5118 hdev->notify(hdev, HCI_NOTIFY_ENABLE_SCO_CVSD); in hci_sync_conn_complete_evt()
5121 hdev->notify(hdev, HCI_NOTIFY_ENABLE_SCO_TRANSP); in hci_sync_conn_complete_evt()
5131 hci_dev_unlock(hdev); in hci_sync_conn_complete_evt()
5151 static void hci_extended_inquiry_result_evt(struct hci_dev *hdev, void *edata, in hci_extended_inquiry_result_evt() argument
5159 if (!hci_ev_skb_pull(hdev, skb, HCI_EV_EXTENDED_INQUIRY_RESULT, in hci_extended_inquiry_result_evt()
5163 bt_dev_dbg(hdev, "num %d", ev->num); in hci_extended_inquiry_result_evt()
5168 if (hci_dev_test_flag(hdev, HCI_PERIODIC_INQ)) in hci_extended_inquiry_result_evt()
5171 hci_dev_lock(hdev); in hci_extended_inquiry_result_evt()
5187 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_extended_inquiry_result_evt()
5194 flags = hci_inquiry_cache_update(hdev, &data, name_known); in hci_extended_inquiry_result_evt()
5198 mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, in hci_extended_inquiry_result_evt()
5203 hci_dev_unlock(hdev); in hci_extended_inquiry_result_evt()
5206 static void hci_key_refresh_complete_evt(struct hci_dev *hdev, void *data, in hci_key_refresh_complete_evt() argument
5212 bt_dev_dbg(hdev, "status 0x%2.2x handle 0x%4.4x", ev->status, in hci_key_refresh_complete_evt()
5215 hci_dev_lock(hdev); in hci_key_refresh_complete_evt()
5217 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_key_refresh_complete_evt()
5253 hci_dev_unlock(hdev); in hci_key_refresh_complete_evt()
5276 struct hci_dev *hdev = conn->hdev; in bredr_oob_data_present() local
5279 data = hci_find_remote_oob_data(hdev, &conn->dst, BDADDR_BREDR); in bredr_oob_data_present()
5283 if (bredr_sc_enabled(hdev)) { in bredr_oob_data_present()
5290 if (!hci_dev_test_flag(hdev, HCI_SC_ONLY)) in bredr_oob_data_present()
5316 static void hci_io_capa_request_evt(struct hci_dev *hdev, void *data, in hci_io_capa_request_evt() argument
5322 bt_dev_dbg(hdev, ""); in hci_io_capa_request_evt()
5324 hci_dev_lock(hdev); in hci_io_capa_request_evt()
5326 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_io_capa_request_evt()
5332 if (!hci_dev_test_flag(hdev, HCI_MGMT)) in hci_io_capa_request_evt()
5338 if (hci_dev_test_flag(hdev, HCI_BONDABLE) || in hci_io_capa_request_evt()
5364 if (!hci_dev_test_flag(hdev, HCI_BONDABLE)) in hci_io_capa_request_evt()
5370 hci_send_cmd(hdev, HCI_OP_IO_CAPABILITY_REPLY, in hci_io_capa_request_evt()
5378 hci_send_cmd(hdev, HCI_OP_IO_CAPABILITY_NEG_REPLY, in hci_io_capa_request_evt()
5383 hci_dev_unlock(hdev); in hci_io_capa_request_evt()
5386 static void hci_io_capa_reply_evt(struct hci_dev *hdev, void *data, in hci_io_capa_reply_evt() argument
5392 bt_dev_dbg(hdev, ""); in hci_io_capa_reply_evt()
5394 hci_dev_lock(hdev); in hci_io_capa_reply_evt()
5396 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_io_capa_reply_evt()
5404 hci_dev_unlock(hdev); in hci_io_capa_reply_evt()
5407 static void hci_user_confirm_request_evt(struct hci_dev *hdev, void *data, in hci_user_confirm_request_evt() argument
5414 bt_dev_dbg(hdev, ""); in hci_user_confirm_request_evt()
5416 hci_dev_lock(hdev); in hci_user_confirm_request_evt()
5418 if (!hci_dev_test_flag(hdev, HCI_MGMT)) in hci_user_confirm_request_evt()
5421 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_user_confirm_request_evt()
5435 bt_dev_dbg(hdev, "Rejecting request: remote device can't provide MITM"); in hci_user_confirm_request_evt()
5436 hci_send_cmd(hdev, HCI_OP_USER_CONFIRM_NEG_REPLY, in hci_user_confirm_request_evt()
5454 bt_dev_dbg(hdev, "Confirming auto-accept as acceptor"); in hci_user_confirm_request_evt()
5463 if (hci_find_link_key(hdev, &ev->bdaddr)) { in hci_user_confirm_request_evt()
5464 bt_dev_dbg(hdev, "Local host already has link key"); in hci_user_confirm_request_evt()
5470 hdev->auto_accept_delay); in hci_user_confirm_request_evt()
5472 if (hdev->auto_accept_delay > 0) { in hci_user_confirm_request_evt()
5473 int delay = msecs_to_jiffies(hdev->auto_accept_delay); in hci_user_confirm_request_evt()
5474 queue_delayed_work(conn->hdev->workqueue, in hci_user_confirm_request_evt()
5479 hci_send_cmd(hdev, HCI_OP_USER_CONFIRM_REPLY, in hci_user_confirm_request_evt()
5485 mgmt_user_confirm_request(hdev, &ev->bdaddr, ACL_LINK, 0, in hci_user_confirm_request_evt()
5489 hci_dev_unlock(hdev); in hci_user_confirm_request_evt()
5492 static void hci_user_passkey_request_evt(struct hci_dev *hdev, void *data, in hci_user_passkey_request_evt() argument
5497 bt_dev_dbg(hdev, ""); in hci_user_passkey_request_evt()
5499 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_user_passkey_request_evt()
5500 mgmt_user_passkey_request(hdev, &ev->bdaddr, ACL_LINK, 0); in hci_user_passkey_request_evt()
5503 static void hci_user_passkey_notify_evt(struct hci_dev *hdev, void *data, in hci_user_passkey_notify_evt() argument
5509 bt_dev_dbg(hdev, ""); in hci_user_passkey_notify_evt()
5511 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_user_passkey_notify_evt()
5518 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_user_passkey_notify_evt()
5519 mgmt_user_passkey_notify(hdev, &conn->dst, conn->type, in hci_user_passkey_notify_evt()
5524 static void hci_keypress_notify_evt(struct hci_dev *hdev, void *data, in hci_keypress_notify_evt() argument
5530 bt_dev_dbg(hdev, ""); in hci_keypress_notify_evt()
5532 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_keypress_notify_evt()
5557 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_keypress_notify_evt()
5558 mgmt_user_passkey_notify(hdev, &conn->dst, conn->type, in hci_keypress_notify_evt()
5563 static void hci_simple_pair_complete_evt(struct hci_dev *hdev, void *data, in hci_simple_pair_complete_evt() argument
5569 bt_dev_dbg(hdev, ""); in hci_simple_pair_complete_evt()
5571 hci_dev_lock(hdev); in hci_simple_pair_complete_evt()
5573 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_simple_pair_complete_evt()
5591 hci_dev_unlock(hdev); in hci_simple_pair_complete_evt()
5594 static void hci_remote_host_features_evt(struct hci_dev *hdev, void *data, in hci_remote_host_features_evt() argument
5601 bt_dev_dbg(hdev, ""); in hci_remote_host_features_evt()
5603 hci_dev_lock(hdev); in hci_remote_host_features_evt()
5605 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_remote_host_features_evt()
5609 ie = hci_inquiry_cache_lookup(hdev, &ev->bdaddr); in hci_remote_host_features_evt()
5613 hci_dev_unlock(hdev); in hci_remote_host_features_evt()
5616 static void hci_remote_oob_data_request_evt(struct hci_dev *hdev, void *edata, in hci_remote_oob_data_request_evt() argument
5622 bt_dev_dbg(hdev, ""); in hci_remote_oob_data_request_evt()
5624 hci_dev_lock(hdev); in hci_remote_oob_data_request_evt()
5626 if (!hci_dev_test_flag(hdev, HCI_MGMT)) in hci_remote_oob_data_request_evt()
5629 data = hci_find_remote_oob_data(hdev, &ev->bdaddr, BDADDR_BREDR); in hci_remote_oob_data_request_evt()
5634 hci_send_cmd(hdev, HCI_OP_REMOTE_OOB_DATA_NEG_REPLY, in hci_remote_oob_data_request_evt()
5639 if (bredr_sc_enabled(hdev)) { in hci_remote_oob_data_request_evt()
5643 if (hci_dev_test_flag(hdev, HCI_SC_ONLY)) { in hci_remote_oob_data_request_evt()
5653 hci_send_cmd(hdev, HCI_OP_REMOTE_OOB_EXT_DATA_REPLY, in hci_remote_oob_data_request_evt()
5662 hci_send_cmd(hdev, HCI_OP_REMOTE_OOB_DATA_REPLY, in hci_remote_oob_data_request_evt()
5667 hci_dev_unlock(hdev); in hci_remote_oob_data_request_evt()
5671 static void hci_chan_selected_evt(struct hci_dev *hdev, void *data, in hci_chan_selected_evt() argument
5677 bt_dev_dbg(hdev, "handle 0x%2.2x", ev->phy_handle); in hci_chan_selected_evt()
5679 hcon = hci_conn_hash_lookup_handle(hdev, ev->phy_handle); in hci_chan_selected_evt()
5683 amp_read_loc_assoc_final_data(hdev, hcon); in hci_chan_selected_evt()
5686 static void hci_phy_link_complete_evt(struct hci_dev *hdev, void *data, in hci_phy_link_complete_evt() argument
5692 bt_dev_dbg(hdev, "handle 0x%2.2x status 0x%2.2x", ev->phy_handle, in hci_phy_link_complete_evt()
5695 hci_dev_lock(hdev); in hci_phy_link_complete_evt()
5697 hcon = hci_conn_hash_lookup_handle(hdev, ev->phy_handle); in hci_phy_link_complete_evt()
5724 hci_dev_unlock(hdev); in hci_phy_link_complete_evt()
5727 static void hci_loglink_complete_evt(struct hci_dev *hdev, void *data, in hci_loglink_complete_evt() argument
5735 bt_dev_dbg(hdev, "log_handle 0x%4.4x phy_handle 0x%2.2x status 0x%2.2x", in hci_loglink_complete_evt()
5738 hcon = hci_conn_hash_lookup_handle(hdev, ev->phy_handle); in hci_loglink_complete_evt()
5758 bredr_chan->conn->mtu = hdev->block_mtu; in hci_loglink_complete_evt()
5766 static void hci_disconn_loglink_complete_evt(struct hci_dev *hdev, void *data, in hci_disconn_loglink_complete_evt() argument
5772 bt_dev_dbg(hdev, "handle 0x%4.4x status 0x%2.2x", in hci_disconn_loglink_complete_evt()
5778 hci_dev_lock(hdev); in hci_disconn_loglink_complete_evt()
5780 hchan = hci_chan_lookup_handle(hdev, le16_to_cpu(ev->handle)); in hci_disconn_loglink_complete_evt()
5787 hci_dev_unlock(hdev); in hci_disconn_loglink_complete_evt()
5790 static void hci_disconn_phylink_complete_evt(struct hci_dev *hdev, void *data, in hci_disconn_phylink_complete_evt() argument
5796 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_disconn_phylink_complete_evt()
5801 hci_dev_lock(hdev); in hci_disconn_phylink_complete_evt()
5803 hcon = hci_conn_hash_lookup_handle(hdev, ev->phy_handle); in hci_disconn_phylink_complete_evt()
5810 hci_dev_unlock(hdev); in hci_disconn_phylink_complete_evt()
5828 } else if (hci_dev_test_flag(conn->hdev, HCI_PRIVACY)) { in le_conn_update_addr()
5830 bacpy(&conn->init_addr, &conn->hdev->rpa); in le_conn_update_addr()
5832 hci_copy_identity_address(conn->hdev, &conn->init_addr, in le_conn_update_addr()
5836 conn->resp_addr_type = conn->hdev->adv_addr_type; in le_conn_update_addr()
5843 } else if (conn->hdev->adv_addr_type == ADDR_LE_DEV_RANDOM) { in le_conn_update_addr()
5847 if (!ext_adv_capable(conn->hdev)) in le_conn_update_addr()
5849 &conn->hdev->random_addr); in le_conn_update_addr()
5851 bacpy(&conn->resp_addr, &conn->hdev->bdaddr); in le_conn_update_addr()
5862 conn->le_conn_min_interval = conn->hdev->le_conn_min_interval; in le_conn_update_addr()
5863 conn->le_conn_max_interval = conn->hdev->le_conn_max_interval; in le_conn_update_addr()
5867 static void le_conn_complete_evt(struct hci_dev *hdev, u8 status, in le_conn_complete_evt() argument
5878 hci_dev_lock(hdev); in le_conn_complete_evt()
5883 hci_dev_clear_flag(hdev, HCI_LE_ADV); in le_conn_complete_evt()
5885 conn = hci_conn_hash_lookup_ba(hdev, LE_LINK, bdaddr); in le_conn_complete_evt()
5893 conn = hci_conn_add(hdev, LE_LINK, bdaddr, role); in le_conn_complete_evt()
5895 bt_dev_err(hdev, "no memory for new connection"); in le_conn_complete_evt()
5912 if (hci_dev_test_flag(hdev, HCI_PRIVACY)) { in le_conn_complete_evt()
5914 bacpy(&conn->init_addr, &hdev->rpa); in le_conn_complete_evt()
5916 hci_copy_identity_address(hdev, in le_conn_complete_evt()
5932 bt_dev_err(hdev, "Ignoring HCI_Connection_Complete for existing connection"); in le_conn_complete_evt()
5947 irk = hci_get_irk(hdev, &conn->dst, conn->dst_type); in le_conn_complete_evt()
5953 conn->dst_type = ev_bdaddr_type(hdev, conn->dst_type, NULL); in le_conn_complete_evt()
5956 bt_dev_err(hdev, "Invalid handle: 0x%4.4x > 0x%4.4x", handle, in le_conn_complete_evt()
5980 if (hci_bdaddr_list_lookup(&hdev->reject_list, &conn->dst, addr_type)) { in le_conn_complete_evt()
5986 mgmt_device_connected(hdev, conn, NULL, 0); in le_conn_complete_evt()
5996 if (!ext_adv_capable(hdev)) in le_conn_complete_evt()
5997 conn->adv_instance = hdev->cur_adv_instance; in le_conn_complete_evt()
6016 (hdev->le_features[0] & HCI_LE_PERIPHERAL_FEATURES)) { in le_conn_complete_evt()
6021 hci_send_cmd(hdev, HCI_OP_LE_READ_REMOTE_FEATURES, in le_conn_complete_evt()
6030 params = hci_pend_le_action_lookup(&hdev->pend_le_conns, &conn->dst, in le_conn_complete_evt()
6042 hci_update_passive_scan(hdev); in le_conn_complete_evt()
6043 hci_dev_unlock(hdev); in le_conn_complete_evt()
6046 static void hci_le_conn_complete_evt(struct hci_dev *hdev, void *data, in hci_le_conn_complete_evt() argument
6051 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_conn_complete_evt()
6053 le_conn_complete_evt(hdev, ev->status, &ev->bdaddr, ev->bdaddr_type, in hci_le_conn_complete_evt()
6060 static void hci_le_enh_conn_complete_evt(struct hci_dev *hdev, void *data, in hci_le_enh_conn_complete_evt() argument
6065 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_enh_conn_complete_evt()
6067 le_conn_complete_evt(hdev, ev->status, &ev->bdaddr, ev->bdaddr_type, in hci_le_enh_conn_complete_evt()
6074 static void hci_le_ext_adv_term_evt(struct hci_dev *hdev, void *data, in hci_le_ext_adv_term_evt() argument
6081 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_ext_adv_term_evt()
6091 bt_dev_warn_ratelimited(hdev, "Unexpected advertising set terminated event"); in hci_le_ext_adv_term_evt()
6095 hci_dev_lock(hdev); in hci_le_ext_adv_term_evt()
6097 adv = hci_find_adv_instance(hdev, ev->handle); in hci_le_ext_adv_term_evt()
6104 hci_remove_adv_instance(hdev, ev->handle); in hci_le_ext_adv_term_evt()
6105 mgmt_advertising_removed(NULL, hdev, ev->handle); in hci_le_ext_adv_term_evt()
6107 list_for_each_entry_safe(adv, n, &hdev->adv_instances, list) { in hci_le_ext_adv_term_evt()
6113 hci_dev_clear_flag(hdev, HCI_LE_ADV); in hci_le_ext_adv_term_evt()
6120 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->conn_handle)); in hci_le_ext_adv_term_evt()
6127 if (hdev->adv_addr_type != ADDR_LE_DEV_RANDOM || in hci_le_ext_adv_term_evt()
6132 bacpy(&conn->resp_addr, &hdev->random_addr); in hci_le_ext_adv_term_evt()
6141 hci_dev_unlock(hdev); in hci_le_ext_adv_term_evt()
6144 static void hci_le_conn_update_complete_evt(struct hci_dev *hdev, void *data, in hci_le_conn_update_complete_evt() argument
6150 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_conn_update_complete_evt()
6155 hci_dev_lock(hdev); in hci_le_conn_update_complete_evt()
6157 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_conn_update_complete_evt()
6164 hci_dev_unlock(hdev); in hci_le_conn_update_complete_evt()
6168 static struct hci_conn *check_pending_le_conn(struct hci_dev *hdev, in check_pending_le_conn() argument
6181 if (hci_bdaddr_list_lookup(&hdev->reject_list, addr, addr_type) || in check_pending_le_conn()
6182 hdev->suspended) in check_pending_le_conn()
6188 if (hdev->conn_hash.le_num_peripheral > 0 && in check_pending_le_conn()
6189 (!test_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks) || in check_pending_le_conn()
6190 !(hdev->le_states[3] & 0x10))) in check_pending_le_conn()
6196 params = hci_pend_le_action_lookup(&hdev->pend_le_conns, addr, in check_pending_le_conn()
6224 conn = hci_connect_le(hdev, addr, addr_type, addr_resolved, in check_pending_le_conn()
6225 BT_SECURITY_LOW, hdev->def_le_autoconnect_timeout, in check_pending_le_conn()
6259 static void process_adv_report(struct hci_dev *hdev, u8 type, bdaddr_t *bdaddr, in process_adv_report() argument
6264 struct discovery_state *d = &hdev->discovery; in process_adv_report()
6279 bt_dev_err_ratelimited(hdev, "unknown advertising packet " in process_adv_report()
6284 if (len > max_adv_len(hdev)) { in process_adv_report()
6285 bt_dev_err_ratelimited(hdev, in process_adv_report()
6311 if (!hci_dev_test_flag(hdev, HCI_MESH) && direct_addr) { in process_adv_report()
6312 direct_addr_type = ev_bdaddr_type(hdev, direct_addr_type, in process_adv_report()
6324 if (!hci_dev_test_flag(hdev, HCI_PRIVACY)) in process_adv_report()
6331 if (!smp_irk_matches(hdev, hdev->irk, direct_addr)) in process_adv_report()
6336 irk = hci_get_irk(hdev, bdaddr, bdaddr_type); in process_adv_report()
6342 bdaddr_type = ev_bdaddr_type(hdev, bdaddr_type, &bdaddr_resolved); in process_adv_report()
6349 conn = check_pending_le_conn(hdev, bdaddr, bdaddr_type, bdaddr_resolved, in process_adv_report()
6352 len <= max_adv_len(hdev)) { in process_adv_report()
6366 if (hci_dev_test_flag(hdev, HCI_MESH)) { in process_adv_report()
6367 mgmt_device_found(hdev, bdaddr, LE_LINK, bdaddr_type, NULL, in process_adv_report()
6376 if (hdev->le_scan_type == LE_SCAN_PASSIVE) { in process_adv_report()
6380 if (!hci_pend_le_action_lookup(&hdev->pend_le_reports, in process_adv_report()
6382 idr_is_empty(&hdev->adv_monitors_idr)) in process_adv_report()
6385 mgmt_device_found(hdev, bdaddr, LE_LINK, bdaddr_type, NULL, in process_adv_report()
6407 if (!ext_adv && !has_pending_adv_report(hdev)) { in process_adv_report()
6412 store_pending_adv_report(hdev, bdaddr, bdaddr_type, in process_adv_report()
6417 mgmt_device_found(hdev, bdaddr, LE_LINK, bdaddr_type, NULL, in process_adv_report()
6433 mgmt_device_found(hdev, &d->last_adv_addr, LE_LINK, in process_adv_report()
6444 store_pending_adv_report(hdev, bdaddr, bdaddr_type, in process_adv_report()
6452 clear_pending_adv_report(hdev); in process_adv_report()
6453 mgmt_device_found(hdev, bdaddr, LE_LINK, bdaddr_type, NULL, in process_adv_report()
6462 mgmt_device_found(hdev, &d->last_adv_addr, LE_LINK, in process_adv_report()
6465 clear_pending_adv_report(hdev); in process_adv_report()
6468 static void hci_le_adv_report_evt(struct hci_dev *hdev, void *data, in hci_le_adv_report_evt() argument
6477 hci_dev_lock(hdev); in hci_le_adv_report_evt()
6483 info = hci_le_ev_skb_pull(hdev, skb, in hci_le_adv_report_evt()
6489 if (!hci_le_ev_skb_pull(hdev, skb, HCI_EV_LE_ADVERTISING_REPORT, in hci_le_adv_report_evt()
6493 if (info->length <= max_adv_len(hdev)) { in hci_le_adv_report_evt()
6495 process_adv_report(hdev, info->type, &info->bdaddr, in hci_le_adv_report_evt()
6500 bt_dev_err(hdev, "Dropping invalid advertising data"); in hci_le_adv_report_evt()
6504 hci_dev_unlock(hdev); in hci_le_adv_report_evt()
6507 static u8 ext_evt_type_to_legacy(struct hci_dev *hdev, u16 evt_type) in ext_evt_type_to_legacy() argument
6545 bt_dev_err_ratelimited(hdev, "Unknown advertising packet type: 0x%02x", in ext_evt_type_to_legacy()
6551 static void hci_le_ext_adv_report_evt(struct hci_dev *hdev, void *data, in hci_le_ext_adv_report_evt() argument
6560 hci_dev_lock(hdev); in hci_le_ext_adv_report_evt()
6567 info = hci_le_ev_skb_pull(hdev, skb, HCI_EV_LE_EXT_ADV_REPORT, in hci_le_ext_adv_report_evt()
6572 if (!hci_le_ev_skb_pull(hdev, skb, HCI_EV_LE_EXT_ADV_REPORT, in hci_le_ext_adv_report_evt()
6577 legacy_evt_type = ext_evt_type_to_legacy(hdev, evt_type); in hci_le_ext_adv_report_evt()
6579 process_adv_report(hdev, legacy_evt_type, &info->bdaddr, in hci_le_ext_adv_report_evt()
6587 hci_dev_unlock(hdev); in hci_le_ext_adv_report_evt()
6590 static int hci_le_pa_term_sync(struct hci_dev *hdev, __le16 handle) in hci_le_pa_term_sync() argument
6597 return hci_send_cmd(hdev, HCI_OP_LE_PA_TERM_SYNC, sizeof(cp), &cp); in hci_le_pa_term_sync()
6600 static void hci_le_pa_sync_estabilished_evt(struct hci_dev *hdev, void *data, in hci_le_pa_sync_estabilished_evt() argument
6604 int mask = hdev->link_mode; in hci_le_pa_sync_estabilished_evt()
6608 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_pa_sync_estabilished_evt()
6610 hci_dev_lock(hdev); in hci_le_pa_sync_estabilished_evt()
6612 hci_dev_clear_flag(hdev, HCI_PA_SYNC); in hci_le_pa_sync_estabilished_evt()
6614 mask |= hci_proto_connect_ind(hdev, &ev->bdaddr, ISO_LINK, &flags); in hci_le_pa_sync_estabilished_evt()
6616 hci_le_pa_term_sync(hdev, ev->handle); in hci_le_pa_sync_estabilished_evt()
6624 bis = hci_conn_add(hdev, ISO_LINK, BDADDR_ANY, in hci_le_pa_sync_estabilished_evt()
6639 hci_dev_unlock(hdev); in hci_le_pa_sync_estabilished_evt()
6642 static void hci_le_per_adv_report_evt(struct hci_dev *hdev, void *data, in hci_le_per_adv_report_evt() argument
6646 int mask = hdev->link_mode; in hci_le_per_adv_report_evt()
6649 bt_dev_dbg(hdev, "sync_handle 0x%4.4x", le16_to_cpu(ev->sync_handle)); in hci_le_per_adv_report_evt()
6651 hci_dev_lock(hdev); in hci_le_per_adv_report_evt()
6653 mask |= hci_proto_connect_ind(hdev, BDADDR_ANY, ISO_LINK, &flags); in hci_le_per_adv_report_evt()
6655 hci_le_pa_term_sync(hdev, ev->sync_handle); in hci_le_per_adv_report_evt()
6657 hci_dev_unlock(hdev); in hci_le_per_adv_report_evt()
6660 static void hci_le_remote_feat_complete_evt(struct hci_dev *hdev, void *data, in hci_le_remote_feat_complete_evt() argument
6666 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_remote_feat_complete_evt()
6668 hci_dev_lock(hdev); in hci_le_remote_feat_complete_evt()
6670 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_remote_feat_complete_evt()
6688 (hdev->le_features[0] & HCI_LE_PERIPHERAL_FEATURES)) in hci_le_remote_feat_complete_evt()
6699 hci_dev_unlock(hdev); in hci_le_remote_feat_complete_evt()
6702 static void hci_le_ltk_request_evt(struct hci_dev *hdev, void *data, in hci_le_ltk_request_evt() argument
6711 bt_dev_dbg(hdev, "handle 0x%4.4x", __le16_to_cpu(ev->handle)); in hci_le_ltk_request_evt()
6713 hci_dev_lock(hdev); in hci_le_ltk_request_evt()
6715 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_ltk_request_evt()
6719 ltk = hci_find_ltk(hdev, &conn->dst, conn->dst_type, conn->role); in hci_le_ltk_request_evt()
6741 hci_send_cmd(hdev, HCI_OP_LE_LTK_REPLY, sizeof(cp), &cp); in hci_le_ltk_request_evt()
6757 hci_dev_unlock(hdev); in hci_le_ltk_request_evt()
6763 hci_send_cmd(hdev, HCI_OP_LE_LTK_NEG_REPLY, sizeof(neg), &neg); in hci_le_ltk_request_evt()
6764 hci_dev_unlock(hdev); in hci_le_ltk_request_evt()
6767 static void send_conn_param_neg_reply(struct hci_dev *hdev, u16 handle, in send_conn_param_neg_reply() argument
6775 hci_send_cmd(hdev, HCI_OP_LE_CONN_PARAM_REQ_NEG_REPLY, sizeof(cp), in send_conn_param_neg_reply()
6779 static void hci_le_remote_conn_param_req_evt(struct hci_dev *hdev, void *data, in hci_le_remote_conn_param_req_evt() argument
6787 bt_dev_dbg(hdev, "handle 0x%4.4x", __le16_to_cpu(ev->handle)); in hci_le_remote_conn_param_req_evt()
6795 hcon = hci_conn_hash_lookup_handle(hdev, handle); in hci_le_remote_conn_param_req_evt()
6797 return send_conn_param_neg_reply(hdev, handle, in hci_le_remote_conn_param_req_evt()
6801 return send_conn_param_neg_reply(hdev, handle, in hci_le_remote_conn_param_req_evt()
6808 hci_dev_lock(hdev); in hci_le_remote_conn_param_req_evt()
6810 params = hci_conn_params_lookup(hdev, &hcon->dst, in hci_le_remote_conn_param_req_evt()
6822 hci_dev_unlock(hdev); in hci_le_remote_conn_param_req_evt()
6824 mgmt_new_conn_param(hdev, &hcon->dst, hcon->dst_type, in hci_le_remote_conn_param_req_evt()
6836 hci_send_cmd(hdev, HCI_OP_LE_CONN_PARAM_REQ_REPLY, sizeof(cp), &cp); in hci_le_remote_conn_param_req_evt()
6839 static void hci_le_direct_adv_report_evt(struct hci_dev *hdev, void *data, in hci_le_direct_adv_report_evt() argument
6846 if (!hci_le_ev_skb_pull(hdev, skb, HCI_EV_LE_DIRECT_ADV_REPORT, in hci_le_direct_adv_report_evt()
6853 hci_dev_lock(hdev); in hci_le_direct_adv_report_evt()
6858 process_adv_report(hdev, info->type, &info->bdaddr, in hci_le_direct_adv_report_evt()
6864 hci_dev_unlock(hdev); in hci_le_direct_adv_report_evt()
6867 static void hci_le_phy_update_evt(struct hci_dev *hdev, void *data, in hci_le_phy_update_evt() argument
6873 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_phy_update_evt()
6878 hci_dev_lock(hdev); in hci_le_phy_update_evt()
6880 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_phy_update_evt()
6888 hci_dev_unlock(hdev); in hci_le_phy_update_evt()
6891 static void hci_le_cis_estabilished_evt(struct hci_dev *hdev, void *data, in hci_le_cis_estabilished_evt() argument
6900 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_cis_estabilished_evt()
6902 hci_dev_lock(hdev); in hci_le_cis_estabilished_evt()
6904 conn = hci_conn_hash_lookup_handle(hdev, handle); in hci_le_cis_estabilished_evt()
6906 bt_dev_err(hdev, in hci_le_cis_estabilished_evt()
6913 bt_dev_err(hdev, in hci_le_cis_estabilished_evt()
6970 hci_le_create_cis_pending(hdev); in hci_le_cis_estabilished_evt()
6972 hci_dev_unlock(hdev); in hci_le_cis_estabilished_evt()
6975 static void hci_le_reject_cis(struct hci_dev *hdev, __le16 handle) in hci_le_reject_cis() argument
6982 hci_send_cmd(hdev, HCI_OP_LE_REJECT_CIS, sizeof(cp), &cp); in hci_le_reject_cis()
6985 static void hci_le_accept_cis(struct hci_dev *hdev, __le16 handle) in hci_le_accept_cis() argument
6991 hci_send_cmd(hdev, HCI_OP_LE_ACCEPT_CIS, sizeof(cp), &cp); in hci_le_accept_cis()
6994 static void hci_le_cis_req_evt(struct hci_dev *hdev, void *data, in hci_le_cis_req_evt() argument
7006 bt_dev_dbg(hdev, "acl 0x%4.4x handle 0x%4.4x cig 0x%2.2x cis 0x%2.2x", in hci_le_cis_req_evt()
7009 hci_dev_lock(hdev); in hci_le_cis_req_evt()
7011 acl = hci_conn_hash_lookup_handle(hdev, acl_handle); in hci_le_cis_req_evt()
7015 mask = hci_proto_connect_ind(hdev, &acl->dst, ISO_LINK, &flags); in hci_le_cis_req_evt()
7017 hci_le_reject_cis(hdev, ev->cis_handle); in hci_le_cis_req_evt()
7021 cis = hci_conn_hash_lookup_handle(hdev, cis_handle); in hci_le_cis_req_evt()
7023 cis = hci_conn_add(hdev, ISO_LINK, &acl->dst, HCI_ROLE_SLAVE); in hci_le_cis_req_evt()
7025 hci_le_reject_cis(hdev, ev->cis_handle); in hci_le_cis_req_evt()
7035 hci_le_accept_cis(hdev, ev->cis_handle); in hci_le_cis_req_evt()
7042 hci_dev_unlock(hdev); in hci_le_cis_req_evt()
7045 static int hci_iso_term_big_sync(struct hci_dev *hdev, void *data) in hci_iso_term_big_sync() argument
7049 return hci_le_terminate_big_sync(hdev, handle, in hci_iso_term_big_sync()
7053 static void hci_le_create_big_complete_evt(struct hci_dev *hdev, void *data, in hci_le_create_big_complete_evt() argument
7060 BT_DBG("%s status 0x%2.2x", hdev->name, ev->status); in hci_le_create_big_complete_evt()
7062 if (!hci_le_ev_skb_pull(hdev, skb, HCI_EVT_LE_CREATE_BIG_COMPLETE, in hci_le_create_big_complete_evt()
7066 hci_dev_lock(hdev); in hci_le_create_big_complete_evt()
7070 list_for_each_entry_rcu(conn, &hdev->conn_hash.list, list) { in hci_le_create_big_complete_evt()
7105 hci_cmd_sync_queue(hdev, hci_iso_term_big_sync, in hci_le_create_big_complete_evt()
7108 hci_dev_unlock(hdev); in hci_le_create_big_complete_evt()
7111 static void hci_le_big_sync_established_evt(struct hci_dev *hdev, void *data, in hci_le_big_sync_established_evt() argument
7119 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_big_sync_established_evt()
7121 if (!hci_le_ev_skb_pull(hdev, skb, HCI_EVT_LE_BIG_SYNC_ESTABILISHED, in hci_le_big_sync_established_evt()
7125 hci_dev_lock(hdev); in hci_le_big_sync_established_evt()
7128 pa_sync = hci_conn_hash_lookup_pa_sync(hdev, ev->handle); in hci_le_big_sync_established_evt()
7140 bis = hci_conn_hash_lookup_handle(hdev, handle); in hci_le_big_sync_established_evt()
7142 bis = hci_conn_add(hdev, ISO_LINK, BDADDR_ANY, in hci_le_big_sync_established_evt()
7174 bis = hci_conn_hash_lookup_handle(hdev, handle); in hci_le_big_sync_established_evt()
7180 hci_dev_unlock(hdev); in hci_le_big_sync_established_evt()
7183 static void hci_le_big_info_adv_report_evt(struct hci_dev *hdev, void *data, in hci_le_big_info_adv_report_evt() argument
7187 int mask = hdev->link_mode; in hci_le_big_info_adv_report_evt()
7190 bt_dev_dbg(hdev, "sync_handle 0x%4.4x", le16_to_cpu(ev->sync_handle)); in hci_le_big_info_adv_report_evt()
7192 hci_dev_lock(hdev); in hci_le_big_info_adv_report_evt()
7194 mask |= hci_proto_connect_ind(hdev, BDADDR_ANY, ISO_LINK, &flags); in hci_le_big_info_adv_report_evt()
7196 hci_le_pa_term_sync(hdev, ev->sync_handle); in hci_le_big_info_adv_report_evt()
7198 hci_dev_unlock(hdev); in hci_le_big_info_adv_report_evt()
7220 void (*func)(struct hci_dev *hdev, void *data, struct sk_buff *skb);
7296 static void hci_le_meta_evt(struct hci_dev *hdev, void *data, in hci_le_meta_evt() argument
7304 bt_dev_dbg(hdev, "subevent 0x%2.2x", ev->subevent); in hci_le_meta_evt()
7307 if (hdev->sent_cmd && in hci_le_meta_evt()
7308 hci_opcode_ogf(hci_skb_opcode(hdev->sent_cmd)) == 0x08 && in hci_le_meta_evt()
7309 hci_skb_event(hdev->sent_cmd) == ev->subevent) { in hci_le_meta_evt()
7310 *opcode = hci_skb_opcode(hdev->sent_cmd); in hci_le_meta_evt()
7311 hci_req_cmd_complete(hdev, *opcode, 0x00, req_complete, in hci_le_meta_evt()
7320 bt_dev_err(hdev, "unexpected subevent 0x%2.2x length: %u < %u", in hci_le_meta_evt()
7330 bt_dev_warn(hdev, "unexpected subevent 0x%2.2x length: %u > %u", in hci_le_meta_evt()
7332 data = hci_le_ev_skb_pull(hdev, skb, ev->subevent, subev->min_len); in hci_le_meta_evt()
7336 subev->func(hdev, data, skb); in hci_le_meta_evt()
7339 static bool hci_get_cmd_complete(struct hci_dev *hdev, u16 opcode, in hci_get_cmd_complete() argument
7348 hdr = hci_ev_skb_pull(hdev, skb, event, sizeof(*hdr)); in hci_get_cmd_complete()
7365 bt_dev_err(hdev, "last event is not cmd complete (0x%2.2x)", in hci_get_cmd_complete()
7370 ev = hci_cc_skb_pull(hdev, skb, opcode, sizeof(*ev)); in hci_get_cmd_complete()
7383 static void hci_store_wake_reason(struct hci_dev *hdev, u8 event, in hci_store_wake_reason() argument
7392 hci_dev_lock(hdev); in hci_store_wake_reason()
7397 if (!hdev->suspended || hdev->wake_reason) in hci_store_wake_reason()
7403 hdev->wake_reason = MGMT_WAKE_REASON_REMOTE_WAKE; in hci_store_wake_reason()
7410 bacpy(&hdev->wake_addr, &conn_complete->bdaddr); in hci_store_wake_reason()
7411 hdev->wake_addr_type = BDADDR_BREDR; in hci_store_wake_reason()
7413 bacpy(&hdev->wake_addr, &conn_request->bdaddr); in hci_store_wake_reason()
7414 hdev->wake_addr_type = BDADDR_BREDR; in hci_store_wake_reason()
7431 bacpy(&hdev->wake_addr, &adv->bdaddr); in hci_store_wake_reason()
7432 hdev->wake_addr_type = adv->bdaddr_type; in hci_store_wake_reason()
7435 bacpy(&hdev->wake_addr, &direct_adv->bdaddr); in hci_store_wake_reason()
7436 hdev->wake_addr_type = direct_adv->bdaddr_type; in hci_store_wake_reason()
7439 bacpy(&hdev->wake_addr, &ext_adv->bdaddr); in hci_store_wake_reason()
7440 hdev->wake_addr_type = ext_adv->bdaddr_type; in hci_store_wake_reason()
7445 hdev->wake_reason = MGMT_WAKE_REASON_UNEXPECTED; in hci_store_wake_reason()
7449 hci_dev_unlock(hdev); in hci_store_wake_reason()
7485 void (*func)(struct hci_dev *hdev, void *data,
7487 void (*func_req)(struct hci_dev *hdev, void *data,
7635 static void hci_event_func(struct hci_dev *hdev, u8 event, struct sk_buff *skb, in hci_event_func() argument
7647 bt_dev_err(hdev, "unexpected event 0x%2.2x length: %u < %u", in hci_event_func()
7657 bt_dev_warn_ratelimited(hdev, in hci_event_func()
7661 data = hci_ev_skb_pull(hdev, skb, event, ev->min_len); in hci_event_func()
7666 ev->func_req(hdev, data, skb, opcode, status, req_complete, in hci_event_func()
7669 ev->func(hdev, data, skb); in hci_event_func()
7672 void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb) in hci_event_packet() argument
7682 bt_dev_err(hdev, "Malformed HCI Event"); in hci_event_packet()
7686 kfree_skb(hdev->recv_event); in hci_event_packet()
7687 hdev->recv_event = skb_clone(skb, GFP_KERNEL); in hci_event_packet()
7691 bt_dev_warn(hdev, "Received unexpected HCI Event 0x%2.2x", in hci_event_packet()
7697 if (hdev->sent_cmd && in hci_event_packet()
7698 hci_opcode_ogf(hci_skb_opcode(hdev->sent_cmd)) != 0x08 && in hci_event_packet()
7699 hci_skb_event(hdev->sent_cmd) == event) { in hci_event_packet()
7700 hci_req_cmd_complete(hdev, hci_skb_opcode(hdev->sent_cmd), in hci_event_packet()
7717 hci_store_wake_reason(hdev, event, skb); in hci_event_packet()
7719 bt_dev_dbg(hdev, "event 0x%2.2x", event); in hci_event_packet()
7721 hci_event_func(hdev, event, skb, &opcode, &status, &req_complete, in hci_event_packet()
7725 req_complete(hdev, status, opcode); in hci_event_packet()
7727 if (!hci_get_cmd_complete(hdev, opcode, req_evt, orig_skb)) { in hci_event_packet()
7731 req_complete_skb(hdev, status, opcode, orig_skb); in hci_event_packet()
7737 hdev->stat.evt_rx++; in hci_event_packet()