Lines Matching refs:hdev
47 static void *hci_ev_skb_pull(struct hci_dev *hdev, struct sk_buff *skb, in hci_ev_skb_pull() argument
54 bt_dev_err(hdev, "Malformed Event: 0x%2.2x", ev); in hci_ev_skb_pull()
59 static void *hci_cc_skb_pull(struct hci_dev *hdev, struct sk_buff *skb, in hci_cc_skb_pull() argument
66 bt_dev_err(hdev, "Malformed Command Complete: 0x%4.4x", op); in hci_cc_skb_pull()
71 static void *hci_le_ev_skb_pull(struct hci_dev *hdev, struct sk_buff *skb, in hci_le_ev_skb_pull() argument
78 bt_dev_err(hdev, "Malformed LE Event: 0x%2.2x", ev); in hci_le_ev_skb_pull()
83 static u8 hci_cc_inquiry_cancel(struct hci_dev *hdev, void *data, in hci_cc_inquiry_cancel() argument
88 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_inquiry_cancel()
97 if (rp->status == HCI_ERROR_COMMAND_DISALLOWED && !test_bit(HCI_INQUIRY, &hdev->flags)) { in hci_cc_inquiry_cancel()
98 bt_dev_warn(hdev, "Ignoring error of Inquiry Cancel command"); in hci_cc_inquiry_cancel()
105 clear_bit(HCI_INQUIRY, &hdev->flags); in hci_cc_inquiry_cancel()
107 wake_up_bit(&hdev->flags, HCI_INQUIRY); in hci_cc_inquiry_cancel()
109 hci_dev_lock(hdev); in hci_cc_inquiry_cancel()
113 if (!hci_dev_test_flag(hdev, HCI_LE_SCAN) || in hci_cc_inquiry_cancel()
114 hdev->le_scan_type != LE_SCAN_ACTIVE) in hci_cc_inquiry_cancel()
115 hci_discovery_set_state(hdev, DISCOVERY_STOPPED); in hci_cc_inquiry_cancel()
116 hci_dev_unlock(hdev); in hci_cc_inquiry_cancel()
121 static u8 hci_cc_periodic_inq(struct hci_dev *hdev, void *data, in hci_cc_periodic_inq() argument
126 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_periodic_inq()
131 hci_dev_set_flag(hdev, HCI_PERIODIC_INQ); in hci_cc_periodic_inq()
136 static u8 hci_cc_exit_periodic_inq(struct hci_dev *hdev, void *data, in hci_cc_exit_periodic_inq() argument
141 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_exit_periodic_inq()
146 hci_dev_clear_flag(hdev, HCI_PERIODIC_INQ); in hci_cc_exit_periodic_inq()
151 static u8 hci_cc_remote_name_req_cancel(struct hci_dev *hdev, void *data, in hci_cc_remote_name_req_cancel() argument
156 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_remote_name_req_cancel()
161 static u8 hci_cc_role_discovery(struct hci_dev *hdev, void *data, in hci_cc_role_discovery() argument
167 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_role_discovery()
172 hci_dev_lock(hdev); in hci_cc_role_discovery()
174 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_role_discovery()
178 hci_dev_unlock(hdev); in hci_cc_role_discovery()
183 static u8 hci_cc_read_link_policy(struct hci_dev *hdev, void *data, in hci_cc_read_link_policy() argument
189 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_link_policy()
194 hci_dev_lock(hdev); in hci_cc_read_link_policy()
196 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_link_policy()
200 hci_dev_unlock(hdev); in hci_cc_read_link_policy()
205 static u8 hci_cc_write_link_policy(struct hci_dev *hdev, void *data, in hci_cc_write_link_policy() argument
212 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_link_policy()
217 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_LINK_POLICY); in hci_cc_write_link_policy()
221 hci_dev_lock(hdev); in hci_cc_write_link_policy()
223 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_write_link_policy()
227 hci_dev_unlock(hdev); in hci_cc_write_link_policy()
232 static u8 hci_cc_read_def_link_policy(struct hci_dev *hdev, void *data, in hci_cc_read_def_link_policy() argument
237 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_def_link_policy()
242 hdev->link_policy = __le16_to_cpu(rp->policy); in hci_cc_read_def_link_policy()
247 static u8 hci_cc_write_def_link_policy(struct hci_dev *hdev, void *data, in hci_cc_write_def_link_policy() argument
253 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_def_link_policy()
258 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_DEF_LINK_POLICY); in hci_cc_write_def_link_policy()
262 hdev->link_policy = get_unaligned_le16(sent); in hci_cc_write_def_link_policy()
267 static u8 hci_cc_reset(struct hci_dev *hdev, void *data, struct sk_buff *skb) in hci_cc_reset() argument
271 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_reset()
273 clear_bit(HCI_RESET, &hdev->flags); in hci_cc_reset()
279 hci_dev_clear_volatile_flags(hdev); in hci_cc_reset()
281 hci_discovery_set_state(hdev, DISCOVERY_STOPPED); in hci_cc_reset()
283 hdev->inq_tx_power = HCI_TX_POWER_INVALID; in hci_cc_reset()
284 hdev->adv_tx_power = HCI_TX_POWER_INVALID; in hci_cc_reset()
286 memset(hdev->adv_data, 0, sizeof(hdev->adv_data)); in hci_cc_reset()
287 hdev->adv_data_len = 0; in hci_cc_reset()
289 memset(hdev->scan_rsp_data, 0, sizeof(hdev->scan_rsp_data)); in hci_cc_reset()
290 hdev->scan_rsp_data_len = 0; in hci_cc_reset()
292 hdev->le_scan_type = LE_SCAN_PASSIVE; in hci_cc_reset()
294 hdev->ssp_debug_mode = 0; in hci_cc_reset()
296 hci_bdaddr_list_clear(&hdev->le_accept_list); in hci_cc_reset()
297 hci_bdaddr_list_clear(&hdev->le_resolv_list); in hci_cc_reset()
302 static u8 hci_cc_read_stored_link_key(struct hci_dev *hdev, void *data, in hci_cc_read_stored_link_key() argument
308 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_stored_link_key()
310 sent = hci_sent_cmd_data(hdev, HCI_OP_READ_STORED_LINK_KEY); in hci_cc_read_stored_link_key()
315 hdev->stored_max_keys = le16_to_cpu(rp->max_keys); in hci_cc_read_stored_link_key()
316 hdev->stored_num_keys = le16_to_cpu(rp->num_keys); in hci_cc_read_stored_link_key()
322 static u8 hci_cc_delete_stored_link_key(struct hci_dev *hdev, void *data, in hci_cc_delete_stored_link_key() argument
328 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_delete_stored_link_key()
335 if (num_keys <= hdev->stored_num_keys) in hci_cc_delete_stored_link_key()
336 hdev->stored_num_keys -= num_keys; in hci_cc_delete_stored_link_key()
338 hdev->stored_num_keys = 0; in hci_cc_delete_stored_link_key()
343 static u8 hci_cc_write_local_name(struct hci_dev *hdev, void *data, in hci_cc_write_local_name() argument
349 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_local_name()
351 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_LOCAL_NAME); in hci_cc_write_local_name()
355 hci_dev_lock(hdev); in hci_cc_write_local_name()
357 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_cc_write_local_name()
358 mgmt_set_local_name_complete(hdev, sent, rp->status); in hci_cc_write_local_name()
360 memcpy(hdev->dev_name, sent, HCI_MAX_NAME_LENGTH); in hci_cc_write_local_name()
362 hci_dev_unlock(hdev); in hci_cc_write_local_name()
367 static u8 hci_cc_read_local_name(struct hci_dev *hdev, void *data, in hci_cc_read_local_name() argument
372 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_name()
377 if (hci_dev_test_flag(hdev, HCI_SETUP) || in hci_cc_read_local_name()
378 hci_dev_test_flag(hdev, HCI_CONFIG)) in hci_cc_read_local_name()
379 memcpy(hdev->dev_name, rp->name, HCI_MAX_NAME_LENGTH); in hci_cc_read_local_name()
384 static u8 hci_cc_write_auth_enable(struct hci_dev *hdev, void *data, in hci_cc_write_auth_enable() argument
390 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_auth_enable()
392 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_AUTH_ENABLE); in hci_cc_write_auth_enable()
396 hci_dev_lock(hdev); in hci_cc_write_auth_enable()
402 set_bit(HCI_AUTH, &hdev->flags); in hci_cc_write_auth_enable()
404 clear_bit(HCI_AUTH, &hdev->flags); in hci_cc_write_auth_enable()
407 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_cc_write_auth_enable()
408 mgmt_auth_enable_complete(hdev, rp->status); in hci_cc_write_auth_enable()
410 hci_dev_unlock(hdev); in hci_cc_write_auth_enable()
415 static u8 hci_cc_write_encrypt_mode(struct hci_dev *hdev, void *data, in hci_cc_write_encrypt_mode() argument
422 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_encrypt_mode()
427 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_ENCRYPT_MODE); in hci_cc_write_encrypt_mode()
434 set_bit(HCI_ENCRYPT, &hdev->flags); in hci_cc_write_encrypt_mode()
436 clear_bit(HCI_ENCRYPT, &hdev->flags); in hci_cc_write_encrypt_mode()
441 static u8 hci_cc_write_scan_enable(struct hci_dev *hdev, void *data, in hci_cc_write_scan_enable() argument
448 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_scan_enable()
450 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_SCAN_ENABLE); in hci_cc_write_scan_enable()
456 hci_dev_lock(hdev); in hci_cc_write_scan_enable()
459 hdev->discov_timeout = 0; in hci_cc_write_scan_enable()
464 set_bit(HCI_ISCAN, &hdev->flags); in hci_cc_write_scan_enable()
466 clear_bit(HCI_ISCAN, &hdev->flags); in hci_cc_write_scan_enable()
469 set_bit(HCI_PSCAN, &hdev->flags); in hci_cc_write_scan_enable()
471 clear_bit(HCI_PSCAN, &hdev->flags); in hci_cc_write_scan_enable()
474 hci_dev_unlock(hdev); in hci_cc_write_scan_enable()
479 static u8 hci_cc_set_event_filter(struct hci_dev *hdev, void *data, in hci_cc_set_event_filter() argument
486 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_set_event_filter()
491 sent = hci_sent_cmd_data(hdev, HCI_OP_SET_EVENT_FLT); in hci_cc_set_event_filter()
498 hci_dev_clear_flag(hdev, HCI_EVENT_FILTER_CONFIGURED); in hci_cc_set_event_filter()
500 hci_dev_set_flag(hdev, HCI_EVENT_FILTER_CONFIGURED); in hci_cc_set_event_filter()
505 static u8 hci_cc_read_class_of_dev(struct hci_dev *hdev, void *data, in hci_cc_read_class_of_dev() argument
510 if (WARN_ON(!hdev)) in hci_cc_read_class_of_dev()
513 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_class_of_dev()
518 memcpy(hdev->dev_class, rp->dev_class, 3); in hci_cc_read_class_of_dev()
520 bt_dev_dbg(hdev, "class 0x%.2x%.2x%.2x", hdev->dev_class[2], in hci_cc_read_class_of_dev()
521 hdev->dev_class[1], hdev->dev_class[0]); in hci_cc_read_class_of_dev()
526 static u8 hci_cc_write_class_of_dev(struct hci_dev *hdev, void *data, in hci_cc_write_class_of_dev() argument
532 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_class_of_dev()
534 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_CLASS_OF_DEV); in hci_cc_write_class_of_dev()
538 hci_dev_lock(hdev); in hci_cc_write_class_of_dev()
541 memcpy(hdev->dev_class, sent, 3); in hci_cc_write_class_of_dev()
543 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_cc_write_class_of_dev()
544 mgmt_set_class_of_dev_complete(hdev, sent, rp->status); in hci_cc_write_class_of_dev()
546 hci_dev_unlock(hdev); in hci_cc_write_class_of_dev()
551 static u8 hci_cc_read_voice_setting(struct hci_dev *hdev, void *data, in hci_cc_read_voice_setting() argument
557 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_voice_setting()
564 if (hdev->voice_setting == setting) in hci_cc_read_voice_setting()
567 hdev->voice_setting = setting; in hci_cc_read_voice_setting()
569 bt_dev_dbg(hdev, "voice setting 0x%4.4x", setting); in hci_cc_read_voice_setting()
571 if (hdev->notify) in hci_cc_read_voice_setting()
572 hdev->notify(hdev, HCI_NOTIFY_VOICE_SETTING); in hci_cc_read_voice_setting()
577 static u8 hci_cc_write_voice_setting(struct hci_dev *hdev, void *data, in hci_cc_write_voice_setting() argument
584 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_voice_setting()
589 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_VOICE_SETTING); in hci_cc_write_voice_setting()
595 if (hdev->voice_setting == setting) in hci_cc_write_voice_setting()
598 hdev->voice_setting = setting; in hci_cc_write_voice_setting()
600 bt_dev_dbg(hdev, "voice setting 0x%4.4x", setting); in hci_cc_write_voice_setting()
602 if (hdev->notify) in hci_cc_write_voice_setting()
603 hdev->notify(hdev, HCI_NOTIFY_VOICE_SETTING); in hci_cc_write_voice_setting()
608 static u8 hci_cc_read_num_supported_iac(struct hci_dev *hdev, void *data, in hci_cc_read_num_supported_iac() argument
613 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_num_supported_iac()
618 hdev->num_iac = rp->num_iac; in hci_cc_read_num_supported_iac()
620 bt_dev_dbg(hdev, "num iac %d", hdev->num_iac); in hci_cc_read_num_supported_iac()
625 static u8 hci_cc_write_ssp_mode(struct hci_dev *hdev, void *data, in hci_cc_write_ssp_mode() argument
631 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_ssp_mode()
633 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_SSP_MODE); in hci_cc_write_ssp_mode()
637 hci_dev_lock(hdev); in hci_cc_write_ssp_mode()
641 hdev->features[1][0] |= LMP_HOST_SSP; in hci_cc_write_ssp_mode()
643 hdev->features[1][0] &= ~LMP_HOST_SSP; in hci_cc_write_ssp_mode()
648 hci_dev_set_flag(hdev, HCI_SSP_ENABLED); in hci_cc_write_ssp_mode()
650 hci_dev_clear_flag(hdev, HCI_SSP_ENABLED); in hci_cc_write_ssp_mode()
653 hci_dev_unlock(hdev); in hci_cc_write_ssp_mode()
658 static u8 hci_cc_write_sc_support(struct hci_dev *hdev, void *data, in hci_cc_write_sc_support() argument
664 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_sc_support()
666 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_SC_SUPPORT); in hci_cc_write_sc_support()
670 hci_dev_lock(hdev); in hci_cc_write_sc_support()
674 hdev->features[1][0] |= LMP_HOST_SC; in hci_cc_write_sc_support()
676 hdev->features[1][0] &= ~LMP_HOST_SC; in hci_cc_write_sc_support()
679 if (!hci_dev_test_flag(hdev, HCI_MGMT) && !rp->status) { in hci_cc_write_sc_support()
681 hci_dev_set_flag(hdev, HCI_SC_ENABLED); in hci_cc_write_sc_support()
683 hci_dev_clear_flag(hdev, HCI_SC_ENABLED); in hci_cc_write_sc_support()
686 hci_dev_unlock(hdev); in hci_cc_write_sc_support()
691 static u8 hci_cc_read_local_version(struct hci_dev *hdev, void *data, in hci_cc_read_local_version() argument
696 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_version()
701 if (hci_dev_test_flag(hdev, HCI_SETUP) || in hci_cc_read_local_version()
702 hci_dev_test_flag(hdev, HCI_CONFIG)) { in hci_cc_read_local_version()
703 hdev->hci_ver = rp->hci_ver; in hci_cc_read_local_version()
704 hdev->hci_rev = __le16_to_cpu(rp->hci_rev); in hci_cc_read_local_version()
705 hdev->lmp_ver = rp->lmp_ver; in hci_cc_read_local_version()
706 hdev->manufacturer = __le16_to_cpu(rp->manufacturer); in hci_cc_read_local_version()
707 hdev->lmp_subver = __le16_to_cpu(rp->lmp_subver); in hci_cc_read_local_version()
713 static u8 hci_cc_read_enc_key_size(struct hci_dev *hdev, void *data, in hci_cc_read_enc_key_size() argument
721 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cc_read_enc_key_size()
725 hci_dev_lock(hdev); in hci_cc_read_enc_key_size()
727 conn = hci_conn_hash_lookup_handle(hdev, handle); in hci_cc_read_enc_key_size()
738 bt_dev_err(hdev, "failed to read key size for handle %u", in hci_cc_read_enc_key_size()
745 if (conn->enc_key_size < hdev->min_enc_key_size) { in hci_cc_read_enc_key_size()
763 hci_dev_unlock(hdev); in hci_cc_read_enc_key_size()
768 static u8 hci_cc_read_local_commands(struct hci_dev *hdev, void *data, in hci_cc_read_local_commands() argument
773 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_commands()
778 if (hci_dev_test_flag(hdev, HCI_SETUP) || in hci_cc_read_local_commands()
779 hci_dev_test_flag(hdev, HCI_CONFIG)) in hci_cc_read_local_commands()
780 memcpy(hdev->commands, rp->commands, sizeof(hdev->commands)); in hci_cc_read_local_commands()
785 static u8 hci_cc_read_auth_payload_timeout(struct hci_dev *hdev, void *data, in hci_cc_read_auth_payload_timeout() argument
791 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_auth_payload_timeout()
796 hci_dev_lock(hdev); in hci_cc_read_auth_payload_timeout()
798 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_auth_payload_timeout()
802 hci_dev_unlock(hdev); in hci_cc_read_auth_payload_timeout()
807 static u8 hci_cc_write_auth_payload_timeout(struct hci_dev *hdev, void *data, in hci_cc_write_auth_payload_timeout() argument
814 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_auth_payload_timeout()
816 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_AUTH_PAYLOAD_TO); in hci_cc_write_auth_payload_timeout()
820 hci_dev_lock(hdev); in hci_cc_write_auth_payload_timeout()
822 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_write_auth_payload_timeout()
832 hci_dev_unlock(hdev); in hci_cc_write_auth_payload_timeout()
837 static u8 hci_cc_read_local_features(struct hci_dev *hdev, void *data, in hci_cc_read_local_features() argument
842 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_features()
847 memcpy(hdev->features, rp->features, 8); in hci_cc_read_local_features()
852 if (hdev->features[0][0] & LMP_3SLOT) in hci_cc_read_local_features()
853 hdev->pkt_type |= (HCI_DM3 | HCI_DH3); in hci_cc_read_local_features()
855 if (hdev->features[0][0] & LMP_5SLOT) in hci_cc_read_local_features()
856 hdev->pkt_type |= (HCI_DM5 | HCI_DH5); in hci_cc_read_local_features()
858 if (hdev->features[0][1] & LMP_HV2) { in hci_cc_read_local_features()
859 hdev->pkt_type |= (HCI_HV2); in hci_cc_read_local_features()
860 hdev->esco_type |= (ESCO_HV2); in hci_cc_read_local_features()
863 if (hdev->features[0][1] & LMP_HV3) { in hci_cc_read_local_features()
864 hdev->pkt_type |= (HCI_HV3); in hci_cc_read_local_features()
865 hdev->esco_type |= (ESCO_HV3); in hci_cc_read_local_features()
868 if (lmp_esco_capable(hdev)) in hci_cc_read_local_features()
869 hdev->esco_type |= (ESCO_EV3); in hci_cc_read_local_features()
871 if (hdev->features[0][4] & LMP_EV4) in hci_cc_read_local_features()
872 hdev->esco_type |= (ESCO_EV4); in hci_cc_read_local_features()
874 if (hdev->features[0][4] & LMP_EV5) in hci_cc_read_local_features()
875 hdev->esco_type |= (ESCO_EV5); in hci_cc_read_local_features()
877 if (hdev->features[0][5] & LMP_EDR_ESCO_2M) in hci_cc_read_local_features()
878 hdev->esco_type |= (ESCO_2EV3); in hci_cc_read_local_features()
880 if (hdev->features[0][5] & LMP_EDR_ESCO_3M) in hci_cc_read_local_features()
881 hdev->esco_type |= (ESCO_3EV3); in hci_cc_read_local_features()
883 if (hdev->features[0][5] & LMP_EDR_3S_ESCO) in hci_cc_read_local_features()
884 hdev->esco_type |= (ESCO_2EV5 | ESCO_3EV5); in hci_cc_read_local_features()
889 static u8 hci_cc_read_local_ext_features(struct hci_dev *hdev, void *data, in hci_cc_read_local_ext_features() argument
894 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_ext_features()
899 if (hdev->max_page < rp->max_page) { in hci_cc_read_local_ext_features()
901 &hdev->quirks)) in hci_cc_read_local_ext_features()
902 bt_dev_warn(hdev, "broken local ext features page 2"); in hci_cc_read_local_ext_features()
904 hdev->max_page = rp->max_page; in hci_cc_read_local_ext_features()
908 memcpy(hdev->features[rp->page], rp->features, 8); in hci_cc_read_local_ext_features()
913 static u8 hci_cc_read_buffer_size(struct hci_dev *hdev, void *data, in hci_cc_read_buffer_size() argument
918 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_buffer_size()
923 hdev->acl_mtu = __le16_to_cpu(rp->acl_mtu); in hci_cc_read_buffer_size()
924 hdev->sco_mtu = rp->sco_mtu; in hci_cc_read_buffer_size()
925 hdev->acl_pkts = __le16_to_cpu(rp->acl_max_pkt); in hci_cc_read_buffer_size()
926 hdev->sco_pkts = __le16_to_cpu(rp->sco_max_pkt); in hci_cc_read_buffer_size()
928 if (test_bit(HCI_QUIRK_FIXUP_BUFFER_SIZE, &hdev->quirks)) { in hci_cc_read_buffer_size()
929 hdev->sco_mtu = 64; in hci_cc_read_buffer_size()
930 hdev->sco_pkts = 8; in hci_cc_read_buffer_size()
933 hdev->acl_cnt = hdev->acl_pkts; in hci_cc_read_buffer_size()
934 hdev->sco_cnt = hdev->sco_pkts; in hci_cc_read_buffer_size()
936 BT_DBG("%s acl mtu %d:%d sco mtu %d:%d", hdev->name, hdev->acl_mtu, in hci_cc_read_buffer_size()
937 hdev->acl_pkts, hdev->sco_mtu, hdev->sco_pkts); in hci_cc_read_buffer_size()
939 if (!hdev->acl_mtu || !hdev->acl_pkts) in hci_cc_read_buffer_size()
945 static u8 hci_cc_read_bd_addr(struct hci_dev *hdev, void *data, in hci_cc_read_bd_addr() argument
950 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_bd_addr()
955 if (test_bit(HCI_INIT, &hdev->flags)) in hci_cc_read_bd_addr()
956 bacpy(&hdev->bdaddr, &rp->bdaddr); in hci_cc_read_bd_addr()
958 if (hci_dev_test_flag(hdev, HCI_SETUP)) in hci_cc_read_bd_addr()
959 bacpy(&hdev->setup_addr, &rp->bdaddr); in hci_cc_read_bd_addr()
964 static u8 hci_cc_read_local_pairing_opts(struct hci_dev *hdev, void *data, in hci_cc_read_local_pairing_opts() argument
969 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_pairing_opts()
974 if (hci_dev_test_flag(hdev, HCI_SETUP) || in hci_cc_read_local_pairing_opts()
975 hci_dev_test_flag(hdev, HCI_CONFIG)) { in hci_cc_read_local_pairing_opts()
976 hdev->pairing_opts = rp->pairing_opts; in hci_cc_read_local_pairing_opts()
977 hdev->max_enc_key_size = rp->max_key_size; in hci_cc_read_local_pairing_opts()
983 static u8 hci_cc_read_page_scan_activity(struct hci_dev *hdev, void *data, in hci_cc_read_page_scan_activity() argument
988 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_page_scan_activity()
993 if (test_bit(HCI_INIT, &hdev->flags)) { in hci_cc_read_page_scan_activity()
994 hdev->page_scan_interval = __le16_to_cpu(rp->interval); in hci_cc_read_page_scan_activity()
995 hdev->page_scan_window = __le16_to_cpu(rp->window); in hci_cc_read_page_scan_activity()
1001 static u8 hci_cc_write_page_scan_activity(struct hci_dev *hdev, void *data, in hci_cc_write_page_scan_activity() argument
1007 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_page_scan_activity()
1012 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_PAGE_SCAN_ACTIVITY); in hci_cc_write_page_scan_activity()
1016 hdev->page_scan_interval = __le16_to_cpu(sent->interval); in hci_cc_write_page_scan_activity()
1017 hdev->page_scan_window = __le16_to_cpu(sent->window); in hci_cc_write_page_scan_activity()
1022 static u8 hci_cc_read_page_scan_type(struct hci_dev *hdev, void *data, in hci_cc_read_page_scan_type() argument
1027 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_page_scan_type()
1032 if (test_bit(HCI_INIT, &hdev->flags)) in hci_cc_read_page_scan_type()
1033 hdev->page_scan_type = rp->type; in hci_cc_read_page_scan_type()
1038 static u8 hci_cc_write_page_scan_type(struct hci_dev *hdev, void *data, in hci_cc_write_page_scan_type() argument
1044 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_page_scan_type()
1049 type = hci_sent_cmd_data(hdev, HCI_OP_WRITE_PAGE_SCAN_TYPE); in hci_cc_write_page_scan_type()
1051 hdev->page_scan_type = *type; in hci_cc_write_page_scan_type()
1056 static u8 hci_cc_read_clock(struct hci_dev *hdev, void *data, in hci_cc_read_clock() argument
1063 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_clock()
1068 hci_dev_lock(hdev); in hci_cc_read_clock()
1070 cp = hci_sent_cmd_data(hdev, HCI_OP_READ_CLOCK); in hci_cc_read_clock()
1075 hdev->clock = le32_to_cpu(rp->clock); in hci_cc_read_clock()
1079 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_clock()
1086 hci_dev_unlock(hdev); in hci_cc_read_clock()
1090 static u8 hci_cc_read_inq_rsp_tx_power(struct hci_dev *hdev, void *data, in hci_cc_read_inq_rsp_tx_power() argument
1095 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_inq_rsp_tx_power()
1100 hdev->inq_tx_power = rp->tx_power; in hci_cc_read_inq_rsp_tx_power()
1105 static u8 hci_cc_read_def_err_data_reporting(struct hci_dev *hdev, void *data, in hci_cc_read_def_err_data_reporting() argument
1110 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_def_err_data_reporting()
1115 hdev->err_data_reporting = rp->err_data_reporting; in hci_cc_read_def_err_data_reporting()
1120 static u8 hci_cc_write_def_err_data_reporting(struct hci_dev *hdev, void *data, in hci_cc_write_def_err_data_reporting() argument
1126 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_def_err_data_reporting()
1131 cp = hci_sent_cmd_data(hdev, HCI_OP_WRITE_DEF_ERR_DATA_REPORTING); in hci_cc_write_def_err_data_reporting()
1135 hdev->err_data_reporting = cp->err_data_reporting; in hci_cc_write_def_err_data_reporting()
1140 static u8 hci_cc_pin_code_reply(struct hci_dev *hdev, void *data, in hci_cc_pin_code_reply() argument
1147 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_pin_code_reply()
1149 hci_dev_lock(hdev); in hci_cc_pin_code_reply()
1151 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_cc_pin_code_reply()
1152 mgmt_pin_code_reply_complete(hdev, &rp->bdaddr, rp->status); in hci_cc_pin_code_reply()
1157 cp = hci_sent_cmd_data(hdev, HCI_OP_PIN_CODE_REPLY); in hci_cc_pin_code_reply()
1161 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cc_pin_code_reply()
1166 hci_dev_unlock(hdev); in hci_cc_pin_code_reply()
1170 static u8 hci_cc_pin_code_neg_reply(struct hci_dev *hdev, void *data, in hci_cc_pin_code_neg_reply() argument
1175 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_pin_code_neg_reply()
1177 hci_dev_lock(hdev); in hci_cc_pin_code_neg_reply()
1179 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_cc_pin_code_neg_reply()
1180 mgmt_pin_code_neg_reply_complete(hdev, &rp->bdaddr, in hci_cc_pin_code_neg_reply()
1183 hci_dev_unlock(hdev); in hci_cc_pin_code_neg_reply()
1188 static u8 hci_cc_le_read_buffer_size(struct hci_dev *hdev, void *data, in hci_cc_le_read_buffer_size() argument
1193 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_read_buffer_size()
1198 hdev->le_mtu = __le16_to_cpu(rp->le_mtu); in hci_cc_le_read_buffer_size()
1199 hdev->le_pkts = rp->le_max_pkt; in hci_cc_le_read_buffer_size()
1201 hdev->le_cnt = hdev->le_pkts; in hci_cc_le_read_buffer_size()
1203 BT_DBG("%s le mtu %d:%d", hdev->name, hdev->le_mtu, hdev->le_pkts); in hci_cc_le_read_buffer_size()
1205 if (hdev->le_mtu && hdev->le_mtu < HCI_MIN_LE_MTU) in hci_cc_le_read_buffer_size()
1211 static u8 hci_cc_le_read_local_features(struct hci_dev *hdev, void *data, in hci_cc_le_read_local_features() argument
1216 BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); in hci_cc_le_read_local_features()
1221 memcpy(hdev->le_features, rp->features, 8); in hci_cc_le_read_local_features()
1226 static u8 hci_cc_le_read_adv_tx_power(struct hci_dev *hdev, void *data, in hci_cc_le_read_adv_tx_power() argument
1231 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_read_adv_tx_power()
1236 hdev->adv_tx_power = rp->tx_power; in hci_cc_le_read_adv_tx_power()
1241 static u8 hci_cc_user_confirm_reply(struct hci_dev *hdev, void *data, in hci_cc_user_confirm_reply() argument
1246 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_user_confirm_reply()
1248 hci_dev_lock(hdev); in hci_cc_user_confirm_reply()
1250 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_cc_user_confirm_reply()
1251 mgmt_user_confirm_reply_complete(hdev, &rp->bdaddr, ACL_LINK, 0, in hci_cc_user_confirm_reply()
1254 hci_dev_unlock(hdev); in hci_cc_user_confirm_reply()
1259 static u8 hci_cc_user_confirm_neg_reply(struct hci_dev *hdev, void *data, in hci_cc_user_confirm_neg_reply() argument
1264 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_user_confirm_neg_reply()
1266 hci_dev_lock(hdev); in hci_cc_user_confirm_neg_reply()
1268 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_cc_user_confirm_neg_reply()
1269 mgmt_user_confirm_neg_reply_complete(hdev, &rp->bdaddr, in hci_cc_user_confirm_neg_reply()
1272 hci_dev_unlock(hdev); in hci_cc_user_confirm_neg_reply()
1277 static u8 hci_cc_user_passkey_reply(struct hci_dev *hdev, void *data, in hci_cc_user_passkey_reply() argument
1282 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_user_passkey_reply()
1284 hci_dev_lock(hdev); in hci_cc_user_passkey_reply()
1286 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_cc_user_passkey_reply()
1287 mgmt_user_passkey_reply_complete(hdev, &rp->bdaddr, ACL_LINK, in hci_cc_user_passkey_reply()
1290 hci_dev_unlock(hdev); in hci_cc_user_passkey_reply()
1295 static u8 hci_cc_user_passkey_neg_reply(struct hci_dev *hdev, void *data, in hci_cc_user_passkey_neg_reply() argument
1300 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_user_passkey_neg_reply()
1302 hci_dev_lock(hdev); in hci_cc_user_passkey_neg_reply()
1304 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_cc_user_passkey_neg_reply()
1305 mgmt_user_passkey_neg_reply_complete(hdev, &rp->bdaddr, in hci_cc_user_passkey_neg_reply()
1308 hci_dev_unlock(hdev); in hci_cc_user_passkey_neg_reply()
1313 static u8 hci_cc_read_local_oob_data(struct hci_dev *hdev, void *data, in hci_cc_read_local_oob_data() argument
1318 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_oob_data()
1323 static u8 hci_cc_read_local_oob_ext_data(struct hci_dev *hdev, void *data, in hci_cc_read_local_oob_ext_data() argument
1328 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_local_oob_ext_data()
1333 static u8 hci_cc_le_set_random_addr(struct hci_dev *hdev, void *data, in hci_cc_le_set_random_addr() argument
1339 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_random_addr()
1344 sent = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_RANDOM_ADDR); in hci_cc_le_set_random_addr()
1348 hci_dev_lock(hdev); in hci_cc_le_set_random_addr()
1350 bacpy(&hdev->random_addr, sent); in hci_cc_le_set_random_addr()
1352 if (!bacmp(&hdev->rpa, sent)) { in hci_cc_le_set_random_addr()
1353 hci_dev_clear_flag(hdev, HCI_RPA_EXPIRED); in hci_cc_le_set_random_addr()
1354 queue_delayed_work(hdev->workqueue, &hdev->rpa_expired, in hci_cc_le_set_random_addr()
1355 secs_to_jiffies(hdev->rpa_timeout)); in hci_cc_le_set_random_addr()
1358 hci_dev_unlock(hdev); in hci_cc_le_set_random_addr()
1363 static u8 hci_cc_le_set_default_phy(struct hci_dev *hdev, void *data, in hci_cc_le_set_default_phy() argument
1369 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_default_phy()
1374 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_DEFAULT_PHY); in hci_cc_le_set_default_phy()
1378 hci_dev_lock(hdev); in hci_cc_le_set_default_phy()
1380 hdev->le_tx_def_phys = cp->tx_phys; in hci_cc_le_set_default_phy()
1381 hdev->le_rx_def_phys = cp->rx_phys; in hci_cc_le_set_default_phy()
1383 hci_dev_unlock(hdev); in hci_cc_le_set_default_phy()
1388 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
1395 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_adv_set_random_addr()
1400 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_ADV_SET_RAND_ADDR); in hci_cc_le_set_adv_set_random_addr()
1408 hci_dev_lock(hdev); in hci_cc_le_set_adv_set_random_addr()
1410 adv = hci_find_adv_instance(hdev, cp->handle); in hci_cc_le_set_adv_set_random_addr()
1413 if (!bacmp(&hdev->rpa, &cp->bdaddr)) { in hci_cc_le_set_adv_set_random_addr()
1415 queue_delayed_work(hdev->workqueue, in hci_cc_le_set_adv_set_random_addr()
1417 secs_to_jiffies(hdev->rpa_timeout)); in hci_cc_le_set_adv_set_random_addr()
1421 hci_dev_unlock(hdev); in hci_cc_le_set_adv_set_random_addr()
1426 static u8 hci_cc_le_remove_adv_set(struct hci_dev *hdev, void *data, in hci_cc_le_remove_adv_set() argument
1433 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_remove_adv_set()
1438 instance = hci_sent_cmd_data(hdev, HCI_OP_LE_REMOVE_ADV_SET); in hci_cc_le_remove_adv_set()
1442 hci_dev_lock(hdev); in hci_cc_le_remove_adv_set()
1444 err = hci_remove_adv_instance(hdev, *instance); in hci_cc_le_remove_adv_set()
1446 mgmt_advertising_removed(hci_skb_sk(hdev->sent_cmd), hdev, in hci_cc_le_remove_adv_set()
1449 hci_dev_unlock(hdev); in hci_cc_le_remove_adv_set()
1454 static u8 hci_cc_le_clear_adv_sets(struct hci_dev *hdev, void *data, in hci_cc_le_clear_adv_sets() argument
1461 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_clear_adv_sets()
1466 if (!hci_sent_cmd_data(hdev, HCI_OP_LE_CLEAR_ADV_SETS)) in hci_cc_le_clear_adv_sets()
1469 hci_dev_lock(hdev); in hci_cc_le_clear_adv_sets()
1471 list_for_each_entry_safe(adv, n, &hdev->adv_instances, list) { in hci_cc_le_clear_adv_sets()
1474 err = hci_remove_adv_instance(hdev, instance); in hci_cc_le_clear_adv_sets()
1476 mgmt_advertising_removed(hci_skb_sk(hdev->sent_cmd), in hci_cc_le_clear_adv_sets()
1477 hdev, instance); in hci_cc_le_clear_adv_sets()
1480 hci_dev_unlock(hdev); in hci_cc_le_clear_adv_sets()
1485 static u8 hci_cc_le_read_transmit_power(struct hci_dev *hdev, void *data, in hci_cc_le_read_transmit_power() argument
1490 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_read_transmit_power()
1495 hdev->min_le_tx_power = rp->min_le_tx_power; in hci_cc_le_read_transmit_power()
1496 hdev->max_le_tx_power = rp->max_le_tx_power; in hci_cc_le_read_transmit_power()
1501 static u8 hci_cc_le_set_privacy_mode(struct hci_dev *hdev, void *data, in hci_cc_le_set_privacy_mode() argument
1508 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_privacy_mode()
1513 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_PRIVACY_MODE); in hci_cc_le_set_privacy_mode()
1517 hci_dev_lock(hdev); in hci_cc_le_set_privacy_mode()
1519 params = hci_conn_params_lookup(hdev, &cp->bdaddr, cp->bdaddr_type); in hci_cc_le_set_privacy_mode()
1523 hci_dev_unlock(hdev); in hci_cc_le_set_privacy_mode()
1528 static u8 hci_cc_le_set_adv_enable(struct hci_dev *hdev, void *data, in hci_cc_le_set_adv_enable() argument
1534 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_adv_enable()
1539 sent = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_ADV_ENABLE); in hci_cc_le_set_adv_enable()
1543 hci_dev_lock(hdev); in hci_cc_le_set_adv_enable()
1551 hci_dev_set_flag(hdev, HCI_LE_ADV); in hci_cc_le_set_adv_enable()
1553 conn = hci_lookup_le_connect(hdev); in hci_cc_le_set_adv_enable()
1555 queue_delayed_work(hdev->workqueue, in hci_cc_le_set_adv_enable()
1559 hci_dev_clear_flag(hdev, HCI_LE_ADV); in hci_cc_le_set_adv_enable()
1562 hci_dev_unlock(hdev); in hci_cc_le_set_adv_enable()
1567 static u8 hci_cc_le_set_ext_adv_enable(struct hci_dev *hdev, void *data, in hci_cc_le_set_ext_adv_enable() argument
1575 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_ext_adv_enable()
1580 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_EXT_ADV_ENABLE); in hci_cc_le_set_ext_adv_enable()
1586 hci_dev_lock(hdev); in hci_cc_le_set_ext_adv_enable()
1589 adv = hci_find_adv_instance(hdev, set->handle); in hci_cc_le_set_ext_adv_enable()
1594 hci_dev_set_flag(hdev, HCI_LE_ADV); in hci_cc_le_set_ext_adv_enable()
1599 conn = hci_lookup_le_connect(hdev); in hci_cc_le_set_ext_adv_enable()
1601 queue_delayed_work(hdev->workqueue, in hci_cc_le_set_ext_adv_enable()
1612 list_for_each_entry_safe(adv, n, &hdev->adv_instances, in hci_cc_le_set_ext_adv_enable()
1619 list_for_each_entry_safe(adv, n, &hdev->adv_instances, in hci_cc_le_set_ext_adv_enable()
1624 hci_dev_clear_flag(hdev, HCI_LE_ADV); in hci_cc_le_set_ext_adv_enable()
1628 hci_dev_unlock(hdev); in hci_cc_le_set_ext_adv_enable()
1632 static u8 hci_cc_le_set_scan_param(struct hci_dev *hdev, void *data, in hci_cc_le_set_scan_param() argument
1638 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_scan_param()
1643 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_SCAN_PARAM); in hci_cc_le_set_scan_param()
1647 hci_dev_lock(hdev); in hci_cc_le_set_scan_param()
1649 hdev->le_scan_type = cp->type; in hci_cc_le_set_scan_param()
1651 hci_dev_unlock(hdev); in hci_cc_le_set_scan_param()
1656 static u8 hci_cc_le_set_ext_scan_param(struct hci_dev *hdev, void *data, in hci_cc_le_set_ext_scan_param() argument
1663 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_ext_scan_param()
1668 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_EXT_SCAN_PARAMS); in hci_cc_le_set_ext_scan_param()
1674 hci_dev_lock(hdev); in hci_cc_le_set_ext_scan_param()
1676 hdev->le_scan_type = phy_param->type; in hci_cc_le_set_ext_scan_param()
1678 hci_dev_unlock(hdev); in hci_cc_le_set_ext_scan_param()
1683 static bool has_pending_adv_report(struct hci_dev *hdev) in has_pending_adv_report() argument
1685 struct discovery_state *d = &hdev->discovery; in has_pending_adv_report()
1690 static void clear_pending_adv_report(struct hci_dev *hdev) in clear_pending_adv_report() argument
1692 struct discovery_state *d = &hdev->discovery; in clear_pending_adv_report()
1698 static void store_pending_adv_report(struct hci_dev *hdev, bdaddr_t *bdaddr, in store_pending_adv_report() argument
1702 struct discovery_state *d = &hdev->discovery; in store_pending_adv_report()
1704 if (len > max_adv_len(hdev)) in store_pending_adv_report()
1715 static void le_set_scan_enable_complete(struct hci_dev *hdev, u8 enable) in le_set_scan_enable_complete() argument
1717 hci_dev_lock(hdev); in le_set_scan_enable_complete()
1721 hci_dev_set_flag(hdev, HCI_LE_SCAN); in le_set_scan_enable_complete()
1722 if (hdev->le_scan_type == LE_SCAN_ACTIVE) { in le_set_scan_enable_complete()
1723 clear_pending_adv_report(hdev); in le_set_scan_enable_complete()
1724 hci_discovery_set_state(hdev, DISCOVERY_FINDING); in le_set_scan_enable_complete()
1733 if (has_pending_adv_report(hdev)) { in le_set_scan_enable_complete()
1734 struct discovery_state *d = &hdev->discovery; in le_set_scan_enable_complete()
1736 mgmt_device_found(hdev, &d->last_adv_addr, LE_LINK, in le_set_scan_enable_complete()
1746 cancel_delayed_work(&hdev->le_scan_disable); in le_set_scan_enable_complete()
1748 hci_dev_clear_flag(hdev, HCI_LE_SCAN); in le_set_scan_enable_complete()
1754 if (hci_dev_test_and_clear_flag(hdev, HCI_LE_SCAN_INTERRUPTED)) in le_set_scan_enable_complete()
1755 hci_discovery_set_state(hdev, DISCOVERY_STOPPED); in le_set_scan_enable_complete()
1756 else if (!hci_dev_test_flag(hdev, HCI_LE_ADV) && in le_set_scan_enable_complete()
1757 hdev->discovery.state == DISCOVERY_FINDING) in le_set_scan_enable_complete()
1758 queue_work(hdev->workqueue, &hdev->reenable_adv_work); in le_set_scan_enable_complete()
1763 bt_dev_err(hdev, "use of reserved LE_Scan_Enable param %d", in le_set_scan_enable_complete()
1768 hci_dev_unlock(hdev); in le_set_scan_enable_complete()
1771 static u8 hci_cc_le_set_scan_enable(struct hci_dev *hdev, void *data, in hci_cc_le_set_scan_enable() argument
1777 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_scan_enable()
1782 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_SCAN_ENABLE); in hci_cc_le_set_scan_enable()
1786 le_set_scan_enable_complete(hdev, cp->enable); in hci_cc_le_set_scan_enable()
1791 static u8 hci_cc_le_set_ext_scan_enable(struct hci_dev *hdev, void *data, in hci_cc_le_set_ext_scan_enable() argument
1797 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_ext_scan_enable()
1802 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_EXT_SCAN_ENABLE); in hci_cc_le_set_ext_scan_enable()
1806 le_set_scan_enable_complete(hdev, cp->enable); in hci_cc_le_set_ext_scan_enable()
1811 static u8 hci_cc_le_read_num_adv_sets(struct hci_dev *hdev, void *data, in hci_cc_le_read_num_adv_sets() argument
1816 bt_dev_dbg(hdev, "status 0x%2.2x No of Adv sets %u", rp->status, in hci_cc_le_read_num_adv_sets()
1822 hdev->le_num_of_adv_sets = rp->num_of_sets; in hci_cc_le_read_num_adv_sets()
1827 static u8 hci_cc_le_read_accept_list_size(struct hci_dev *hdev, void *data, in hci_cc_le_read_accept_list_size() argument
1832 bt_dev_dbg(hdev, "status 0x%2.2x size %u", rp->status, rp->size); in hci_cc_le_read_accept_list_size()
1837 hdev->le_accept_list_size = rp->size; in hci_cc_le_read_accept_list_size()
1842 static u8 hci_cc_le_clear_accept_list(struct hci_dev *hdev, void *data, in hci_cc_le_clear_accept_list() argument
1847 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_clear_accept_list()
1852 hci_dev_lock(hdev); in hci_cc_le_clear_accept_list()
1853 hci_bdaddr_list_clear(&hdev->le_accept_list); in hci_cc_le_clear_accept_list()
1854 hci_dev_unlock(hdev); in hci_cc_le_clear_accept_list()
1859 static u8 hci_cc_le_add_to_accept_list(struct hci_dev *hdev, void *data, in hci_cc_le_add_to_accept_list() argument
1865 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_add_to_accept_list()
1870 sent = hci_sent_cmd_data(hdev, HCI_OP_LE_ADD_TO_ACCEPT_LIST); in hci_cc_le_add_to_accept_list()
1874 hci_dev_lock(hdev); in hci_cc_le_add_to_accept_list()
1875 hci_bdaddr_list_add(&hdev->le_accept_list, &sent->bdaddr, in hci_cc_le_add_to_accept_list()
1877 hci_dev_unlock(hdev); in hci_cc_le_add_to_accept_list()
1882 static u8 hci_cc_le_del_from_accept_list(struct hci_dev *hdev, void *data, in hci_cc_le_del_from_accept_list() argument
1888 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_del_from_accept_list()
1893 sent = hci_sent_cmd_data(hdev, HCI_OP_LE_DEL_FROM_ACCEPT_LIST); in hci_cc_le_del_from_accept_list()
1897 hci_dev_lock(hdev); in hci_cc_le_del_from_accept_list()
1898 hci_bdaddr_list_del(&hdev->le_accept_list, &sent->bdaddr, in hci_cc_le_del_from_accept_list()
1900 hci_dev_unlock(hdev); in hci_cc_le_del_from_accept_list()
1905 static u8 hci_cc_le_read_supported_states(struct hci_dev *hdev, void *data, in hci_cc_le_read_supported_states() argument
1910 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_read_supported_states()
1915 memcpy(hdev->le_states, rp->le_states, 8); in hci_cc_le_read_supported_states()
1920 static u8 hci_cc_le_read_def_data_len(struct hci_dev *hdev, void *data, in hci_cc_le_read_def_data_len() argument
1925 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_read_def_data_len()
1930 hdev->le_def_tx_len = le16_to_cpu(rp->tx_len); in hci_cc_le_read_def_data_len()
1931 hdev->le_def_tx_time = le16_to_cpu(rp->tx_time); in hci_cc_le_read_def_data_len()
1936 static u8 hci_cc_le_write_def_data_len(struct hci_dev *hdev, void *data, in hci_cc_le_write_def_data_len() argument
1942 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_write_def_data_len()
1947 sent = hci_sent_cmd_data(hdev, HCI_OP_LE_WRITE_DEF_DATA_LEN); in hci_cc_le_write_def_data_len()
1951 hdev->le_def_tx_len = le16_to_cpu(sent->tx_len); in hci_cc_le_write_def_data_len()
1952 hdev->le_def_tx_time = le16_to_cpu(sent->tx_time); in hci_cc_le_write_def_data_len()
1957 static u8 hci_cc_le_add_to_resolv_list(struct hci_dev *hdev, void *data, in hci_cc_le_add_to_resolv_list() argument
1963 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_add_to_resolv_list()
1968 sent = hci_sent_cmd_data(hdev, HCI_OP_LE_ADD_TO_RESOLV_LIST); in hci_cc_le_add_to_resolv_list()
1972 hci_dev_lock(hdev); in hci_cc_le_add_to_resolv_list()
1973 hci_bdaddr_list_add_with_irk(&hdev->le_resolv_list, &sent->bdaddr, in hci_cc_le_add_to_resolv_list()
1976 hci_dev_unlock(hdev); in hci_cc_le_add_to_resolv_list()
1981 static u8 hci_cc_le_del_from_resolv_list(struct hci_dev *hdev, void *data, in hci_cc_le_del_from_resolv_list() argument
1987 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_del_from_resolv_list()
1992 sent = hci_sent_cmd_data(hdev, HCI_OP_LE_DEL_FROM_RESOLV_LIST); in hci_cc_le_del_from_resolv_list()
1996 hci_dev_lock(hdev); in hci_cc_le_del_from_resolv_list()
1997 hci_bdaddr_list_del_with_irk(&hdev->le_resolv_list, &sent->bdaddr, in hci_cc_le_del_from_resolv_list()
1999 hci_dev_unlock(hdev); in hci_cc_le_del_from_resolv_list()
2004 static u8 hci_cc_le_clear_resolv_list(struct hci_dev *hdev, void *data, in hci_cc_le_clear_resolv_list() argument
2009 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_clear_resolv_list()
2014 hci_dev_lock(hdev); in hci_cc_le_clear_resolv_list()
2015 hci_bdaddr_list_clear(&hdev->le_resolv_list); in hci_cc_le_clear_resolv_list()
2016 hci_dev_unlock(hdev); in hci_cc_le_clear_resolv_list()
2021 static u8 hci_cc_le_read_resolv_list_size(struct hci_dev *hdev, void *data, in hci_cc_le_read_resolv_list_size() argument
2026 bt_dev_dbg(hdev, "status 0x%2.2x size %u", rp->status, rp->size); in hci_cc_le_read_resolv_list_size()
2031 hdev->le_resolv_list_size = rp->size; in hci_cc_le_read_resolv_list_size()
2036 static u8 hci_cc_le_set_addr_resolution_enable(struct hci_dev *hdev, void *data, in hci_cc_le_set_addr_resolution_enable() argument
2042 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_addr_resolution_enable()
2047 sent = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE); in hci_cc_le_set_addr_resolution_enable()
2051 hci_dev_lock(hdev); in hci_cc_le_set_addr_resolution_enable()
2054 hci_dev_set_flag(hdev, HCI_LL_RPA_RESOLUTION); in hci_cc_le_set_addr_resolution_enable()
2056 hci_dev_clear_flag(hdev, HCI_LL_RPA_RESOLUTION); in hci_cc_le_set_addr_resolution_enable()
2058 hci_dev_unlock(hdev); in hci_cc_le_set_addr_resolution_enable()
2063 static u8 hci_cc_le_read_max_data_len(struct hci_dev *hdev, void *data, in hci_cc_le_read_max_data_len() argument
2068 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_read_max_data_len()
2073 hdev->le_max_tx_len = le16_to_cpu(rp->tx_len); in hci_cc_le_read_max_data_len()
2074 hdev->le_max_tx_time = le16_to_cpu(rp->tx_time); in hci_cc_le_read_max_data_len()
2075 hdev->le_max_rx_len = le16_to_cpu(rp->rx_len); in hci_cc_le_read_max_data_len()
2076 hdev->le_max_rx_time = le16_to_cpu(rp->rx_time); in hci_cc_le_read_max_data_len()
2081 static u8 hci_cc_write_le_host_supported(struct hci_dev *hdev, void *data, in hci_cc_write_le_host_supported() argument
2087 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_le_host_supported()
2092 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_LE_HOST_SUPPORTED); in hci_cc_write_le_host_supported()
2096 hci_dev_lock(hdev); in hci_cc_write_le_host_supported()
2099 hdev->features[1][0] |= LMP_HOST_LE; in hci_cc_write_le_host_supported()
2100 hci_dev_set_flag(hdev, HCI_LE_ENABLED); in hci_cc_write_le_host_supported()
2102 hdev->features[1][0] &= ~LMP_HOST_LE; in hci_cc_write_le_host_supported()
2103 hci_dev_clear_flag(hdev, HCI_LE_ENABLED); in hci_cc_write_le_host_supported()
2104 hci_dev_clear_flag(hdev, HCI_ADVERTISING); in hci_cc_write_le_host_supported()
2108 hdev->features[1][0] |= LMP_HOST_LE_BREDR; in hci_cc_write_le_host_supported()
2110 hdev->features[1][0] &= ~LMP_HOST_LE_BREDR; in hci_cc_write_le_host_supported()
2112 hci_dev_unlock(hdev); in hci_cc_write_le_host_supported()
2117 static u8 hci_cc_set_adv_param(struct hci_dev *hdev, void *data, in hci_cc_set_adv_param() argument
2123 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_set_adv_param()
2128 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_ADV_PARAM); in hci_cc_set_adv_param()
2132 hci_dev_lock(hdev); in hci_cc_set_adv_param()
2133 hdev->adv_addr_type = cp->own_address_type; in hci_cc_set_adv_param()
2134 hci_dev_unlock(hdev); in hci_cc_set_adv_param()
2139 static u8 hci_cc_set_ext_adv_param(struct hci_dev *hdev, void *data, in hci_cc_set_ext_adv_param() argument
2146 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_set_ext_adv_param()
2151 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_EXT_ADV_PARAMS); in hci_cc_set_ext_adv_param()
2155 hci_dev_lock(hdev); in hci_cc_set_ext_adv_param()
2156 hdev->adv_addr_type = cp->own_addr_type; in hci_cc_set_ext_adv_param()
2159 hdev->adv_tx_power = rp->tx_power; in hci_cc_set_ext_adv_param()
2161 adv_instance = hci_find_adv_instance(hdev, cp->handle); in hci_cc_set_ext_adv_param()
2166 hci_update_adv_data(hdev, cp->handle); in hci_cc_set_ext_adv_param()
2168 hci_dev_unlock(hdev); in hci_cc_set_ext_adv_param()
2173 static u8 hci_cc_read_rssi(struct hci_dev *hdev, void *data, in hci_cc_read_rssi() argument
2179 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_rssi()
2184 hci_dev_lock(hdev); in hci_cc_read_rssi()
2186 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_rssi()
2190 hci_dev_unlock(hdev); in hci_cc_read_rssi()
2195 static u8 hci_cc_read_tx_power(struct hci_dev *hdev, void *data, in hci_cc_read_tx_power() argument
2202 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_read_tx_power()
2207 sent = hci_sent_cmd_data(hdev, HCI_OP_READ_TX_POWER); in hci_cc_read_tx_power()
2211 hci_dev_lock(hdev); in hci_cc_read_tx_power()
2213 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_tx_power()
2227 hci_dev_unlock(hdev); in hci_cc_read_tx_power()
2231 static u8 hci_cc_write_ssp_debug_mode(struct hci_dev *hdev, void *data, in hci_cc_write_ssp_debug_mode() argument
2237 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_write_ssp_debug_mode()
2242 mode = hci_sent_cmd_data(hdev, HCI_OP_WRITE_SSP_DEBUG_MODE); in hci_cc_write_ssp_debug_mode()
2244 hdev->ssp_debug_mode = *mode; in hci_cc_write_ssp_debug_mode()
2249 static void hci_cs_inquiry(struct hci_dev *hdev, __u8 status) in hci_cs_inquiry() argument
2251 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_inquiry()
2256 if (hci_sent_cmd_data(hdev, HCI_OP_INQUIRY)) in hci_cs_inquiry()
2257 set_bit(HCI_INQUIRY, &hdev->flags); in hci_cs_inquiry()
2260 static void hci_cs_create_conn(struct hci_dev *hdev, __u8 status) in hci_cs_create_conn() argument
2265 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_create_conn()
2267 cp = hci_sent_cmd_data(hdev, HCI_OP_CREATE_CONN); in hci_cs_create_conn()
2271 hci_dev_lock(hdev); in hci_cs_create_conn()
2273 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cs_create_conn()
2275 bt_dev_dbg(hdev, "bdaddr %pMR hcon %p", &cp->bdaddr, conn); in hci_cs_create_conn()
2285 conn = hci_conn_add_unset(hdev, ACL_LINK, &cp->bdaddr, in hci_cs_create_conn()
2288 bt_dev_err(hdev, "connection err: %ld", PTR_ERR(conn)); in hci_cs_create_conn()
2292 hci_dev_unlock(hdev); in hci_cs_create_conn()
2295 static void hci_cs_add_sco(struct hci_dev *hdev, __u8 status) in hci_cs_add_sco() argument
2302 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_add_sco()
2307 cp = hci_sent_cmd_data(hdev, HCI_OP_ADD_SCO); in hci_cs_add_sco()
2313 bt_dev_dbg(hdev, "handle 0x%4.4x", handle); in hci_cs_add_sco()
2315 hci_dev_lock(hdev); in hci_cs_add_sco()
2317 acl = hci_conn_hash_lookup_handle(hdev, handle); in hci_cs_add_sco()
2329 hci_dev_unlock(hdev); in hci_cs_add_sco()
2332 static void hci_cs_auth_requested(struct hci_dev *hdev, __u8 status) in hci_cs_auth_requested() argument
2337 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_auth_requested()
2342 cp = hci_sent_cmd_data(hdev, HCI_OP_AUTH_REQUESTED); in hci_cs_auth_requested()
2346 hci_dev_lock(hdev); in hci_cs_auth_requested()
2348 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_auth_requested()
2356 hci_dev_unlock(hdev); in hci_cs_auth_requested()
2359 static void hci_cs_set_conn_encrypt(struct hci_dev *hdev, __u8 status) in hci_cs_set_conn_encrypt() argument
2364 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_set_conn_encrypt()
2369 cp = hci_sent_cmd_data(hdev, HCI_OP_SET_CONN_ENCRYPT); in hci_cs_set_conn_encrypt()
2373 hci_dev_lock(hdev); in hci_cs_set_conn_encrypt()
2375 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_set_conn_encrypt()
2383 hci_dev_unlock(hdev); in hci_cs_set_conn_encrypt()
2386 static int hci_outgoing_auth_needed(struct hci_dev *hdev, in hci_outgoing_auth_needed() argument
2408 static int hci_resolve_name(struct hci_dev *hdev, in hci_resolve_name() argument
2420 return hci_send_cmd(hdev, HCI_OP_REMOTE_NAME_REQ, sizeof(cp), &cp); in hci_resolve_name()
2423 static bool hci_resolve_next_name(struct hci_dev *hdev) in hci_resolve_next_name() argument
2425 struct discovery_state *discov = &hdev->discovery; in hci_resolve_next_name()
2433 bt_dev_warn_ratelimited(hdev, "Name resolve takes too long."); in hci_resolve_next_name()
2437 e = hci_inquiry_cache_lookup_resolve(hdev, BDADDR_ANY, NAME_NEEDED); in hci_resolve_next_name()
2441 if (hci_resolve_name(hdev, e) == 0) { in hci_resolve_next_name()
2449 static void hci_check_pending_name(struct hci_dev *hdev, struct hci_conn *conn, in hci_check_pending_name() argument
2452 struct discovery_state *discov = &hdev->discovery; in hci_check_pending_name()
2461 mgmt_device_connected(hdev, conn, name, name_len); in hci_check_pending_name()
2472 e = hci_inquiry_cache_lookup_resolve(hdev, bdaddr, NAME_PENDING); in hci_check_pending_name()
2483 mgmt_remote_name(hdev, bdaddr, ACL_LINK, 0x00, e->data.rssi, in hci_check_pending_name()
2486 if (hci_resolve_next_name(hdev)) in hci_check_pending_name()
2490 hci_discovery_set_state(hdev, DISCOVERY_STOPPED); in hci_check_pending_name()
2493 static void hci_cs_remote_name_req(struct hci_dev *hdev, __u8 status) in hci_cs_remote_name_req() argument
2498 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_remote_name_req()
2505 cp = hci_sent_cmd_data(hdev, HCI_OP_REMOTE_NAME_REQ); in hci_cs_remote_name_req()
2509 hci_dev_lock(hdev); in hci_cs_remote_name_req()
2511 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cs_remote_name_req()
2513 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_cs_remote_name_req()
2514 hci_check_pending_name(hdev, conn, &cp->bdaddr, NULL, 0); in hci_cs_remote_name_req()
2519 if (!hci_outgoing_auth_needed(hdev, conn)) in hci_cs_remote_name_req()
2528 hci_send_cmd(hdev, HCI_OP_AUTH_REQUESTED, in hci_cs_remote_name_req()
2533 hci_dev_unlock(hdev); in hci_cs_remote_name_req()
2536 static void hci_cs_read_remote_features(struct hci_dev *hdev, __u8 status) in hci_cs_read_remote_features() argument
2541 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_read_remote_features()
2546 cp = hci_sent_cmd_data(hdev, HCI_OP_READ_REMOTE_FEATURES); in hci_cs_read_remote_features()
2550 hci_dev_lock(hdev); in hci_cs_read_remote_features()
2552 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_read_remote_features()
2560 hci_dev_unlock(hdev); in hci_cs_read_remote_features()
2563 static void hci_cs_read_remote_ext_features(struct hci_dev *hdev, __u8 status) in hci_cs_read_remote_ext_features() argument
2568 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_read_remote_ext_features()
2573 cp = hci_sent_cmd_data(hdev, HCI_OP_READ_REMOTE_EXT_FEATURES); in hci_cs_read_remote_ext_features()
2577 hci_dev_lock(hdev); in hci_cs_read_remote_ext_features()
2579 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_read_remote_ext_features()
2587 hci_dev_unlock(hdev); in hci_cs_read_remote_ext_features()
2590 static void hci_setup_sync_conn_status(struct hci_dev *hdev, __u16 handle, in hci_setup_sync_conn_status() argument
2596 bt_dev_dbg(hdev, "handle 0x%4.4x status 0x%2.2x", handle, status); in hci_setup_sync_conn_status()
2598 hci_dev_lock(hdev); in hci_setup_sync_conn_status()
2600 acl = hci_conn_hash_lookup_handle(hdev, handle); in hci_setup_sync_conn_status()
2612 hci_dev_unlock(hdev); in hci_setup_sync_conn_status()
2615 static void hci_cs_setup_sync_conn(struct hci_dev *hdev, __u8 status) in hci_cs_setup_sync_conn() argument
2619 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_setup_sync_conn()
2624 cp = hci_sent_cmd_data(hdev, HCI_OP_SETUP_SYNC_CONN); in hci_cs_setup_sync_conn()
2628 hci_setup_sync_conn_status(hdev, __le16_to_cpu(cp->handle), status); in hci_cs_setup_sync_conn()
2631 static void hci_cs_enhanced_setup_sync_conn(struct hci_dev *hdev, __u8 status) in hci_cs_enhanced_setup_sync_conn() argument
2635 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_enhanced_setup_sync_conn()
2640 cp = hci_sent_cmd_data(hdev, HCI_OP_ENHANCED_SETUP_SYNC_CONN); in hci_cs_enhanced_setup_sync_conn()
2644 hci_setup_sync_conn_status(hdev, __le16_to_cpu(cp->handle), status); in hci_cs_enhanced_setup_sync_conn()
2647 static void hci_cs_sniff_mode(struct hci_dev *hdev, __u8 status) in hci_cs_sniff_mode() argument
2652 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_sniff_mode()
2657 cp = hci_sent_cmd_data(hdev, HCI_OP_SNIFF_MODE); in hci_cs_sniff_mode()
2661 hci_dev_lock(hdev); in hci_cs_sniff_mode()
2663 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_sniff_mode()
2671 hci_dev_unlock(hdev); in hci_cs_sniff_mode()
2674 static void hci_cs_exit_sniff_mode(struct hci_dev *hdev, __u8 status) in hci_cs_exit_sniff_mode() argument
2679 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_exit_sniff_mode()
2684 cp = hci_sent_cmd_data(hdev, HCI_OP_EXIT_SNIFF_MODE); in hci_cs_exit_sniff_mode()
2688 hci_dev_lock(hdev); in hci_cs_exit_sniff_mode()
2690 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_exit_sniff_mode()
2698 hci_dev_unlock(hdev); in hci_cs_exit_sniff_mode()
2701 static void hci_cs_disconnect(struct hci_dev *hdev, u8 status) in hci_cs_disconnect() argument
2708 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_disconnect()
2713 if (!status && !hdev->suspended) in hci_cs_disconnect()
2716 cp = hci_sent_cmd_data(hdev, HCI_OP_DISCONNECT); in hci_cs_disconnect()
2720 hci_dev_lock(hdev); in hci_cs_disconnect()
2722 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_disconnect()
2727 mgmt_disconnect_failed(hdev, &conn->dst, conn->type, in hci_cs_disconnect()
2731 hdev->cur_adv_instance = conn->adv_instance; in hci_cs_disconnect()
2732 hci_enable_advertising(hdev); in hci_cs_disconnect()
2745 hci_remove_link_key(hdev, &conn->dst); in hci_cs_disconnect()
2748 params = hci_conn_params_lookup(hdev, &conn->dst, conn->dst_type); in hci_cs_disconnect()
2759 hci_pend_le_list_add(params, &hdev->pend_le_conns); in hci_cs_disconnect()
2767 mgmt_device_disconnected(hdev, &conn->dst, conn->type, conn->dst_type, in hci_cs_disconnect()
2780 hci_dev_unlock(hdev); in hci_cs_disconnect()
2783 static u8 ev_bdaddr_type(struct hci_dev *hdev, u8 type, bool *resolved) in ev_bdaddr_type() argument
2805 static void cs_le_create_conn(struct hci_dev *hdev, bdaddr_t *peer_addr, in cs_le_create_conn() argument
2811 conn = hci_conn_hash_lookup_le(hdev, peer_addr, in cs_le_create_conn()
2816 own_address_type = ev_bdaddr_type(hdev, own_address_type, NULL); in cs_le_create_conn()
2824 bacpy(&conn->init_addr, &hdev->random_addr); in cs_le_create_conn()
2826 bacpy(&conn->init_addr, &hdev->bdaddr); in cs_le_create_conn()
2832 static void hci_cs_le_create_conn(struct hci_dev *hdev, u8 status) in hci_cs_le_create_conn() argument
2836 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_le_create_conn()
2845 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_CREATE_CONN); in hci_cs_le_create_conn()
2849 hci_dev_lock(hdev); in hci_cs_le_create_conn()
2851 cs_le_create_conn(hdev, &cp->peer_addr, cp->peer_addr_type, in hci_cs_le_create_conn()
2854 hci_dev_unlock(hdev); in hci_cs_le_create_conn()
2857 static void hci_cs_le_ext_create_conn(struct hci_dev *hdev, u8 status) in hci_cs_le_ext_create_conn() argument
2861 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_le_ext_create_conn()
2870 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_EXT_CREATE_CONN); in hci_cs_le_ext_create_conn()
2874 hci_dev_lock(hdev); in hci_cs_le_ext_create_conn()
2876 cs_le_create_conn(hdev, &cp->peer_addr, cp->peer_addr_type, in hci_cs_le_ext_create_conn()
2879 hci_dev_unlock(hdev); in hci_cs_le_ext_create_conn()
2882 static void hci_cs_le_read_remote_features(struct hci_dev *hdev, u8 status) in hci_cs_le_read_remote_features() argument
2887 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_le_read_remote_features()
2892 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_READ_REMOTE_FEATURES); in hci_cs_le_read_remote_features()
2896 hci_dev_lock(hdev); in hci_cs_le_read_remote_features()
2898 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_le_read_remote_features()
2906 hci_dev_unlock(hdev); in hci_cs_le_read_remote_features()
2909 static void hci_cs_le_start_enc(struct hci_dev *hdev, u8 status) in hci_cs_le_start_enc() argument
2914 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_le_start_enc()
2919 hci_dev_lock(hdev); in hci_cs_le_start_enc()
2921 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_START_ENC); in hci_cs_le_start_enc()
2925 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_le_start_enc()
2936 hci_dev_unlock(hdev); in hci_cs_le_start_enc()
2939 static void hci_cs_switch_role(struct hci_dev *hdev, u8 status) in hci_cs_switch_role() argument
2944 BT_DBG("%s status 0x%2.2x", hdev->name, status); in hci_cs_switch_role()
2949 cp = hci_sent_cmd_data(hdev, HCI_OP_SWITCH_ROLE); in hci_cs_switch_role()
2953 hci_dev_lock(hdev); in hci_cs_switch_role()
2955 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cs_switch_role()
2959 hci_dev_unlock(hdev); in hci_cs_switch_role()
2962 static void hci_inquiry_complete_evt(struct hci_dev *hdev, void *data, in hci_inquiry_complete_evt() argument
2966 struct discovery_state *discov = &hdev->discovery; in hci_inquiry_complete_evt()
2969 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_inquiry_complete_evt()
2971 if (!test_and_clear_bit(HCI_INQUIRY, &hdev->flags)) in hci_inquiry_complete_evt()
2975 wake_up_bit(&hdev->flags, HCI_INQUIRY); in hci_inquiry_complete_evt()
2977 if (!hci_dev_test_flag(hdev, HCI_MGMT)) in hci_inquiry_complete_evt()
2980 hci_dev_lock(hdev); in hci_inquiry_complete_evt()
2993 if (!hci_dev_test_flag(hdev, HCI_LE_SCAN) || in hci_inquiry_complete_evt()
2994 !test_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks)) in hci_inquiry_complete_evt()
2995 hci_discovery_set_state(hdev, DISCOVERY_STOPPED); in hci_inquiry_complete_evt()
2999 e = hci_inquiry_cache_lookup_resolve(hdev, BDADDR_ANY, NAME_NEEDED); in hci_inquiry_complete_evt()
3000 if (e && hci_resolve_name(hdev, e) == 0) { in hci_inquiry_complete_evt()
3002 hci_discovery_set_state(hdev, DISCOVERY_RESOLVING); in hci_inquiry_complete_evt()
3012 if (!hci_dev_test_flag(hdev, HCI_LE_SCAN) || in hci_inquiry_complete_evt()
3013 !test_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks)) in hci_inquiry_complete_evt()
3014 hci_discovery_set_state(hdev, DISCOVERY_STOPPED); in hci_inquiry_complete_evt()
3018 hci_dev_unlock(hdev); in hci_inquiry_complete_evt()
3021 static void hci_inquiry_result_evt(struct hci_dev *hdev, void *edata, in hci_inquiry_result_evt() argument
3028 if (!hci_ev_skb_pull(hdev, skb, HCI_EV_INQUIRY_RESULT, in hci_inquiry_result_evt()
3032 bt_dev_dbg(hdev, "num %d", ev->num); in hci_inquiry_result_evt()
3037 if (hci_dev_test_flag(hdev, HCI_PERIODIC_INQ)) in hci_inquiry_result_evt()
3040 hci_dev_lock(hdev); in hci_inquiry_result_evt()
3055 flags = hci_inquiry_cache_update(hdev, &data, false); in hci_inquiry_result_evt()
3057 mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, in hci_inquiry_result_evt()
3062 hci_dev_unlock(hdev); in hci_inquiry_result_evt()
3065 static void hci_conn_complete_evt(struct hci_dev *hdev, void *data, in hci_conn_complete_evt() argument
3072 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_conn_complete_evt()
3074 hci_dev_lock(hdev); in hci_conn_complete_evt()
3076 conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, &ev->bdaddr); in hci_conn_complete_evt()
3094 hci_bdaddr_list_lookup_with_flags(&hdev->accept_list, in hci_conn_complete_evt()
3097 conn = hci_conn_add_unset(hdev, ev->link_type, in hci_conn_complete_evt()
3100 bt_dev_err(hdev, "connection err: %ld", PTR_ERR(conn)); in hci_conn_complete_evt()
3107 conn = hci_conn_hash_lookup_ba(hdev, ESCO_LINK, in hci_conn_complete_evt()
3123 bt_dev_err(hdev, "Ignoring HCI_Connection_Complete for existing connection"); in hci_conn_complete_evt()
3137 !hci_find_link_key(hdev, &ev->bdaddr)) in hci_conn_complete_evt()
3147 if (test_bit(HCI_AUTH, &hdev->flags)) in hci_conn_complete_evt()
3150 if (test_bit(HCI_ENCRYPT, &hdev->flags)) in hci_conn_complete_evt()
3159 key = hci_find_link_key(hdev, &ev->bdaddr); in hci_conn_complete_evt()
3163 if (!read_key_size_capable(hdev)) { in hci_conn_complete_evt()
3167 if (hci_send_cmd(hdev, HCI_OP_READ_ENC_KEY_SIZE, in hci_conn_complete_evt()
3169 bt_dev_err(hdev, "sending read key size failed"); in hci_conn_complete_evt()
3182 hci_send_cmd(hdev, HCI_OP_READ_REMOTE_FEATURES, in hci_conn_complete_evt()
3185 hci_update_scan(hdev); in hci_conn_complete_evt()
3189 if (!conn->out && hdev->hci_ver < BLUETOOTH_VER_2_0) { in hci_conn_complete_evt()
3193 hci_send_cmd(hdev, HCI_OP_CHANGE_CONN_PTYPE, sizeof(cp), in hci_conn_complete_evt()
3207 if (hdev->notify) in hci_conn_complete_evt()
3208 hdev->notify(hdev, HCI_NOTIFY_ENABLE_SCO_CVSD); in hci_conn_complete_evt()
3216 hci_dev_unlock(hdev); in hci_conn_complete_evt()
3219 static void hci_reject_conn(struct hci_dev *hdev, bdaddr_t *bdaddr) in hci_reject_conn() argument
3225 hci_send_cmd(hdev, HCI_OP_REJECT_CONN_REQ, sizeof(cp), &cp); in hci_reject_conn()
3228 static void hci_conn_request_evt(struct hci_dev *hdev, void *data, in hci_conn_request_evt() argument
3232 int mask = hdev->link_mode; in hci_conn_request_evt()
3237 bt_dev_dbg(hdev, "bdaddr %pMR type 0x%x", &ev->bdaddr, ev->link_type); in hci_conn_request_evt()
3242 if (hdev && !bacmp(&hdev->bdaddr, &ev->bdaddr)) { in hci_conn_request_evt()
3243 bt_dev_dbg(hdev, "Reject connection with same BD_ADDR %pMR\n", in hci_conn_request_evt()
3245 hci_reject_conn(hdev, &ev->bdaddr); in hci_conn_request_evt()
3249 mask |= hci_proto_connect_ind(hdev, &ev->bdaddr, ev->link_type, in hci_conn_request_evt()
3253 hci_reject_conn(hdev, &ev->bdaddr); in hci_conn_request_evt()
3257 hci_dev_lock(hdev); in hci_conn_request_evt()
3259 if (hci_bdaddr_list_lookup(&hdev->reject_list, &ev->bdaddr, in hci_conn_request_evt()
3261 hci_reject_conn(hdev, &ev->bdaddr); in hci_conn_request_evt()
3269 if (hci_dev_test_flag(hdev, HCI_MGMT) && in hci_conn_request_evt()
3270 !hci_dev_test_flag(hdev, HCI_CONNECTABLE) && in hci_conn_request_evt()
3271 !hci_bdaddr_list_lookup_with_flags(&hdev->accept_list, &ev->bdaddr, in hci_conn_request_evt()
3273 hci_reject_conn(hdev, &ev->bdaddr); in hci_conn_request_evt()
3279 ie = hci_inquiry_cache_lookup(hdev, &ev->bdaddr); in hci_conn_request_evt()
3283 conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, in hci_conn_request_evt()
3286 conn = hci_conn_add_unset(hdev, ev->link_type, &ev->bdaddr, in hci_conn_request_evt()
3289 bt_dev_err(hdev, "connection err: %ld", PTR_ERR(conn)); in hci_conn_request_evt()
3296 hci_dev_unlock(hdev); in hci_conn_request_evt()
3299 (!(flags & HCI_PROTO_DEFER) && !lmp_esco_capable(hdev))) { in hci_conn_request_evt()
3305 if (lmp_rswitch_capable(hdev) && (mask & HCI_LM_MASTER)) in hci_conn_request_evt()
3310 hci_send_cmd(hdev, HCI_OP_ACCEPT_CONN_REQ, sizeof(cp), &cp); in hci_conn_request_evt()
3321 cp.content_format = cpu_to_le16(hdev->voice_setting); in hci_conn_request_evt()
3324 hci_send_cmd(hdev, HCI_OP_ACCEPT_SYNC_CONN_REQ, sizeof(cp), in hci_conn_request_evt()
3333 hci_dev_unlock(hdev); in hci_conn_request_evt()
3352 static void hci_disconn_complete_evt(struct hci_dev *hdev, void *data, in hci_disconn_complete_evt() argument
3361 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_disconn_complete_evt()
3363 hci_dev_lock(hdev); in hci_disconn_complete_evt()
3365 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_disconn_complete_evt()
3370 mgmt_disconnect_failed(hdev, &conn->dst, conn->type, in hci_disconn_complete_evt()
3384 mgmt_device_disconnected(hdev, &conn->dst, conn->type, conn->dst_type, in hci_disconn_complete_evt()
3389 hci_remove_link_key(hdev, &conn->dst); in hci_disconn_complete_evt()
3391 hci_update_scan(hdev); in hci_disconn_complete_evt()
3398 params = hci_conn_params_lookup(hdev, &conn->dst, in hci_disconn_complete_evt()
3411 &hdev->pend_le_conns); in hci_disconn_complete_evt()
3412 hci_update_passive_scan(hdev); in hci_disconn_complete_evt()
3434 hdev->cur_adv_instance = conn->adv_instance; in hci_disconn_complete_evt()
3435 hci_enable_advertising(hdev); in hci_disconn_complete_evt()
3441 hci_dev_unlock(hdev); in hci_disconn_complete_evt()
3444 static void hci_auth_complete_evt(struct hci_dev *hdev, void *data, in hci_auth_complete_evt() argument
3450 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_auth_complete_evt()
3452 hci_dev_lock(hdev); in hci_auth_complete_evt()
3454 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_auth_complete_evt()
3476 hci_send_cmd(hdev, HCI_OP_SET_CONN_ENCRYPT, sizeof(cp), in hci_auth_complete_evt()
3496 hci_send_cmd(hdev, HCI_OP_SET_CONN_ENCRYPT, sizeof(cp), in hci_auth_complete_evt()
3505 hci_dev_unlock(hdev); in hci_auth_complete_evt()
3508 static void hci_remote_name_evt(struct hci_dev *hdev, void *data, in hci_remote_name_evt() argument
3514 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_remote_name_evt()
3516 hci_dev_lock(hdev); in hci_remote_name_evt()
3518 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_remote_name_evt()
3520 if (!hci_dev_test_flag(hdev, HCI_MGMT)) in hci_remote_name_evt()
3524 hci_check_pending_name(hdev, conn, &ev->bdaddr, ev->name, in hci_remote_name_evt()
3527 hci_check_pending_name(hdev, conn, &ev->bdaddr, NULL, 0); in hci_remote_name_evt()
3533 if (!hci_outgoing_auth_needed(hdev, conn)) in hci_remote_name_evt()
3542 hci_send_cmd(hdev, HCI_OP_AUTH_REQUESTED, sizeof(cp), &cp); in hci_remote_name_evt()
3546 hci_dev_unlock(hdev); in hci_remote_name_evt()
3549 static void hci_encrypt_change_evt(struct hci_dev *hdev, void *data, in hci_encrypt_change_evt() argument
3555 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_encrypt_change_evt()
3557 hci_dev_lock(hdev); in hci_encrypt_change_evt()
3559 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_encrypt_change_evt()
3587 hci_dev_set_flag(hdev, HCI_RPA_EXPIRED); in hci_encrypt_change_evt()
3588 hci_adv_instances_set_rpa_expired(hdev, true); in hci_encrypt_change_evt()
3618 if (!read_key_size_capable(hdev)) { in hci_encrypt_change_evt()
3624 if (hci_send_cmd(hdev, HCI_OP_READ_ENC_KEY_SIZE, in hci_encrypt_change_evt()
3626 bt_dev_err(hdev, "sending read key size failed"); in hci_encrypt_change_evt()
3638 &hdev->quirks)) in hci_encrypt_change_evt()
3650 ((conn->type == ACL_LINK && lmp_ping_capable(hdev)) || in hci_encrypt_change_evt()
3651 (conn->type == LE_LINK && (hdev->le_features[0] & HCI_LE_PING)))) { in hci_encrypt_change_evt()
3655 cp.timeout = cpu_to_le16(hdev->auth_payload_timeout); in hci_encrypt_change_evt()
3656 if (hci_send_cmd(conn->hdev, HCI_OP_WRITE_AUTH_PAYLOAD_TO, in hci_encrypt_change_evt()
3658 bt_dev_err(hdev, "write auth payload timeout failed"); in hci_encrypt_change_evt()
3665 hci_dev_unlock(hdev); in hci_encrypt_change_evt()
3668 static void hci_change_link_key_complete_evt(struct hci_dev *hdev, void *data, in hci_change_link_key_complete_evt() argument
3674 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_change_link_key_complete_evt()
3676 hci_dev_lock(hdev); in hci_change_link_key_complete_evt()
3678 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_change_link_key_complete_evt()
3688 hci_dev_unlock(hdev); in hci_change_link_key_complete_evt()
3691 static void hci_remote_features_evt(struct hci_dev *hdev, void *data, in hci_remote_features_evt() argument
3697 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_remote_features_evt()
3699 hci_dev_lock(hdev); in hci_remote_features_evt()
3701 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_remote_features_evt()
3711 if (!ev->status && lmp_ext_feat_capable(hdev) && in hci_remote_features_evt()
3716 hci_send_cmd(hdev, HCI_OP_READ_REMOTE_EXT_FEATURES, in hci_remote_features_evt()
3726 hci_send_cmd(hdev, HCI_OP_REMOTE_NAME_REQ, sizeof(cp), &cp); in hci_remote_features_evt()
3728 mgmt_device_connected(hdev, conn, NULL, 0); in hci_remote_features_evt()
3731 if (!hci_outgoing_auth_needed(hdev, conn)) { in hci_remote_features_evt()
3738 hci_dev_unlock(hdev); in hci_remote_features_evt()
3741 static inline void handle_cmd_cnt_and_timer(struct hci_dev *hdev, u8 ncmd) in handle_cmd_cnt_and_timer() argument
3743 cancel_delayed_work(&hdev->cmd_timer); in handle_cmd_cnt_and_timer()
3746 if (!test_bit(HCI_RESET, &hdev->flags)) { in handle_cmd_cnt_and_timer()
3748 cancel_delayed_work(&hdev->ncmd_timer); in handle_cmd_cnt_and_timer()
3749 atomic_set(&hdev->cmd_cnt, 1); in handle_cmd_cnt_and_timer()
3751 if (!hci_dev_test_flag(hdev, HCI_CMD_DRAIN_WORKQUEUE)) in handle_cmd_cnt_and_timer()
3752 queue_delayed_work(hdev->workqueue, &hdev->ncmd_timer, in handle_cmd_cnt_and_timer()
3759 static u8 hci_cc_le_read_buffer_size_v2(struct hci_dev *hdev, void *data, in hci_cc_le_read_buffer_size_v2() argument
3764 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_read_buffer_size_v2()
3769 hdev->le_mtu = __le16_to_cpu(rp->acl_mtu); in hci_cc_le_read_buffer_size_v2()
3770 hdev->le_pkts = rp->acl_max_pkt; in hci_cc_le_read_buffer_size_v2()
3771 hdev->iso_mtu = __le16_to_cpu(rp->iso_mtu); in hci_cc_le_read_buffer_size_v2()
3772 hdev->iso_pkts = rp->iso_max_pkt; in hci_cc_le_read_buffer_size_v2()
3774 hdev->le_cnt = hdev->le_pkts; in hci_cc_le_read_buffer_size_v2()
3775 hdev->iso_cnt = hdev->iso_pkts; in hci_cc_le_read_buffer_size_v2()
3777 BT_DBG("%s acl mtu %d:%d iso mtu %d:%d", hdev->name, hdev->acl_mtu, in hci_cc_le_read_buffer_size_v2()
3778 hdev->acl_pkts, hdev->iso_mtu, hdev->iso_pkts); in hci_cc_le_read_buffer_size_v2()
3780 if (hdev->le_mtu && hdev->le_mtu < HCI_MIN_LE_MTU) in hci_cc_le_read_buffer_size_v2()
3786 static void hci_unbound_cis_failed(struct hci_dev *hdev, u8 cig, u8 status) in hci_unbound_cis_failed() argument
3790 lockdep_assert_held(&hdev->lock); in hci_unbound_cis_failed()
3792 list_for_each_entry_safe(conn, tmp, &hdev->conn_hash.list, list) { in hci_unbound_cis_failed()
3802 static u8 hci_cc_le_set_cig_params(struct hci_dev *hdev, void *data, in hci_cc_le_set_cig_params() argument
3812 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_cig_params()
3814 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_CIG_PARAMS); in hci_cc_le_set_cig_params()
3817 bt_dev_err(hdev, "unexpected Set CIG Parameters response data"); in hci_cc_le_set_cig_params()
3821 hci_dev_lock(hdev); in hci_cc_le_set_cig_params()
3831 hci_unbound_cis_failed(hdev, rp->cig_id, status); in hci_cc_le_set_cig_params()
3843 conn = hci_conn_hash_lookup_cis(hdev, NULL, 0, rp->cig_id, in hci_cc_le_set_cig_params()
3860 hci_le_create_cis_pending(hdev); in hci_cc_le_set_cig_params()
3862 hci_dev_unlock(hdev); in hci_cc_le_set_cig_params()
3867 static u8 hci_cc_le_setup_iso_path(struct hci_dev *hdev, void *data, in hci_cc_le_setup_iso_path() argument
3874 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_setup_iso_path()
3876 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SETUP_ISO_PATH); in hci_cc_le_setup_iso_path()
3880 hci_dev_lock(hdev); in hci_cc_le_setup_iso_path()
3882 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cc_le_setup_iso_path()
3908 mgmt_device_connected(hdev, conn, NULL, 0); in hci_cc_le_setup_iso_path()
3914 hci_dev_unlock(hdev); in hci_cc_le_setup_iso_path()
3918 static void hci_cs_le_create_big(struct hci_dev *hdev, u8 status) in hci_cs_le_create_big() argument
3920 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_le_create_big()
3923 static u8 hci_cc_set_per_adv_param(struct hci_dev *hdev, void *data, in hci_cc_set_per_adv_param() argument
3929 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_set_per_adv_param()
3934 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_PER_ADV_PARAMS); in hci_cc_set_per_adv_param()
3942 static u8 hci_cc_le_set_per_adv_enable(struct hci_dev *hdev, void *data, in hci_cc_le_set_per_adv_enable() argument
3950 bt_dev_dbg(hdev, "status 0x%2.2x", rp->status); in hci_cc_le_set_per_adv_enable()
3955 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_PER_ADV_ENABLE); in hci_cc_le_set_per_adv_enable()
3959 hci_dev_lock(hdev); in hci_cc_le_set_per_adv_enable()
3961 adv = hci_find_adv_instance(hdev, cp->handle); in hci_cc_le_set_per_adv_enable()
3964 hci_dev_set_flag(hdev, HCI_LE_PER_ADV); in hci_cc_le_set_per_adv_enable()
3974 list_for_each_entry_safe(adv, n, &hdev->adv_instances, in hci_cc_le_set_per_adv_enable()
3983 hci_dev_clear_flag(hdev, HCI_LE_PER_ADV); in hci_cc_le_set_per_adv_enable()
3987 hci_dev_unlock(hdev); in hci_cc_le_set_per_adv_enable()
4008 u8 (*func)(struct hci_dev *hdev, void *data, struct sk_buff *skb);
4175 static u8 hci_cc_func(struct hci_dev *hdev, const struct hci_cc *cc, in hci_cc_func() argument
4181 bt_dev_err(hdev, "unexpected cc 0x%4.4x length: %u < %u", in hci_cc_func()
4191 bt_dev_warn(hdev, "unexpected cc 0x%4.4x length: %u > %u", in hci_cc_func()
4194 data = hci_cc_skb_pull(hdev, skb, cc->op, cc->min_len); in hci_cc_func()
4198 return cc->func(hdev, data, skb); in hci_cc_func()
4201 static void hci_cmd_complete_evt(struct hci_dev *hdev, void *data, in hci_cmd_complete_evt() argument
4211 bt_dev_dbg(hdev, "opcode 0x%4.4x", *opcode); in hci_cmd_complete_evt()
4215 *status = hci_cc_func(hdev, &hci_cc_table[i], skb); in hci_cmd_complete_evt()
4231 handle_cmd_cnt_and_timer(hdev, ev->ncmd); in hci_cmd_complete_evt()
4233 hci_req_cmd_complete(hdev, *opcode, *status, req_complete, in hci_cmd_complete_evt()
4236 if (hci_dev_test_flag(hdev, HCI_CMD_PENDING)) { in hci_cmd_complete_evt()
4237 bt_dev_err(hdev, in hci_cmd_complete_evt()
4242 if (atomic_read(&hdev->cmd_cnt) && !skb_queue_empty(&hdev->cmd_q)) in hci_cmd_complete_evt()
4243 queue_work(hdev->workqueue, &hdev->cmd_work); in hci_cmd_complete_evt()
4246 static void hci_cs_le_create_cis(struct hci_dev *hdev, u8 status) in hci_cs_le_create_cis() argument
4252 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_cs_le_create_cis()
4257 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_CREATE_CIS); in hci_cs_le_create_cis()
4261 hci_dev_lock(hdev); in hci_cs_le_create_cis()
4270 conn = hci_conn_hash_lookup_handle(hdev, handle); in hci_cs_le_create_cis()
4283 hci_le_create_cis_pending(hdev); in hci_cs_le_create_cis()
4285 hci_dev_unlock(hdev); in hci_cs_le_create_cis()
4296 void (*func)(struct hci_dev *hdev, __u8 status);
4322 static void hci_cmd_status_evt(struct hci_dev *hdev, void *data, in hci_cmd_status_evt() argument
4333 bt_dev_dbg(hdev, "opcode 0x%4.4x", *opcode); in hci_cmd_status_evt()
4337 hci_cs_table[i].func(hdev, ev->status); in hci_cmd_status_evt()
4342 handle_cmd_cnt_and_timer(hdev, ev->ncmd); in hci_cmd_status_evt()
4350 if (ev->status || (hdev->req_skb && !hci_skb_event(hdev->req_skb))) { in hci_cmd_status_evt()
4351 hci_req_cmd_complete(hdev, *opcode, ev->status, req_complete, in hci_cmd_status_evt()
4353 if (hci_dev_test_flag(hdev, HCI_CMD_PENDING)) { in hci_cmd_status_evt()
4354 bt_dev_err(hdev, "unexpected event for opcode 0x%4.4x", in hci_cmd_status_evt()
4360 if (atomic_read(&hdev->cmd_cnt) && !skb_queue_empty(&hdev->cmd_q)) in hci_cmd_status_evt()
4361 queue_work(hdev->workqueue, &hdev->cmd_work); in hci_cmd_status_evt()
4364 static void hci_hardware_error_evt(struct hci_dev *hdev, void *data, in hci_hardware_error_evt() argument
4369 bt_dev_dbg(hdev, "code 0x%2.2x", ev->code); in hci_hardware_error_evt()
4371 hdev->hw_error_code = ev->code; in hci_hardware_error_evt()
4373 queue_work(hdev->req_workqueue, &hdev->error_reset); in hci_hardware_error_evt()
4376 static void hci_role_change_evt(struct hci_dev *hdev, void *data, in hci_role_change_evt() argument
4382 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_role_change_evt()
4384 hci_dev_lock(hdev); in hci_role_change_evt()
4386 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_role_change_evt()
4396 hci_dev_unlock(hdev); in hci_role_change_evt()
4399 static void hci_num_comp_pkts_evt(struct hci_dev *hdev, void *data, in hci_num_comp_pkts_evt() argument
4405 if (!hci_ev_skb_pull(hdev, skb, HCI_EV_NUM_COMP_PKTS, in hci_num_comp_pkts_evt()
4409 bt_dev_dbg(hdev, "num %d", ev->num); in hci_num_comp_pkts_evt()
4419 conn = hci_conn_hash_lookup_handle(hdev, handle); in hci_num_comp_pkts_evt()
4427 hdev->acl_cnt += count; in hci_num_comp_pkts_evt()
4428 if (hdev->acl_cnt > hdev->acl_pkts) in hci_num_comp_pkts_evt()
4429 hdev->acl_cnt = hdev->acl_pkts; in hci_num_comp_pkts_evt()
4433 if (hdev->le_pkts) { in hci_num_comp_pkts_evt()
4434 hdev->le_cnt += count; in hci_num_comp_pkts_evt()
4435 if (hdev->le_cnt > hdev->le_pkts) in hci_num_comp_pkts_evt()
4436 hdev->le_cnt = hdev->le_pkts; in hci_num_comp_pkts_evt()
4438 hdev->acl_cnt += count; in hci_num_comp_pkts_evt()
4439 if (hdev->acl_cnt > hdev->acl_pkts) in hci_num_comp_pkts_evt()
4440 hdev->acl_cnt = hdev->acl_pkts; in hci_num_comp_pkts_evt()
4445 hdev->sco_cnt += count; in hci_num_comp_pkts_evt()
4446 if (hdev->sco_cnt > hdev->sco_pkts) in hci_num_comp_pkts_evt()
4447 hdev->sco_cnt = hdev->sco_pkts; in hci_num_comp_pkts_evt()
4451 if (hdev->iso_pkts) { in hci_num_comp_pkts_evt()
4452 hdev->iso_cnt += count; in hci_num_comp_pkts_evt()
4453 if (hdev->iso_cnt > hdev->iso_pkts) in hci_num_comp_pkts_evt()
4454 hdev->iso_cnt = hdev->iso_pkts; in hci_num_comp_pkts_evt()
4455 } else if (hdev->le_pkts) { in hci_num_comp_pkts_evt()
4456 hdev->le_cnt += count; in hci_num_comp_pkts_evt()
4457 if (hdev->le_cnt > hdev->le_pkts) in hci_num_comp_pkts_evt()
4458 hdev->le_cnt = hdev->le_pkts; in hci_num_comp_pkts_evt()
4460 hdev->acl_cnt += count; in hci_num_comp_pkts_evt()
4461 if (hdev->acl_cnt > hdev->acl_pkts) in hci_num_comp_pkts_evt()
4462 hdev->acl_cnt = hdev->acl_pkts; in hci_num_comp_pkts_evt()
4467 bt_dev_err(hdev, "unknown type %d conn %p", in hci_num_comp_pkts_evt()
4473 queue_work(hdev->workqueue, &hdev->tx_work); in hci_num_comp_pkts_evt()
4476 static void hci_mode_change_evt(struct hci_dev *hdev, void *data, in hci_mode_change_evt() argument
4482 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_mode_change_evt()
4484 hci_dev_lock(hdev); in hci_mode_change_evt()
4486 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_mode_change_evt()
4502 hci_dev_unlock(hdev); in hci_mode_change_evt()
4505 static void hci_pin_code_request_evt(struct hci_dev *hdev, void *data, in hci_pin_code_request_evt() argument
4511 bt_dev_dbg(hdev, ""); in hci_pin_code_request_evt()
4513 hci_dev_lock(hdev); in hci_pin_code_request_evt()
4515 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_pin_code_request_evt()
4525 if (!hci_dev_test_flag(hdev, HCI_BONDABLE) && in hci_pin_code_request_evt()
4527 hci_send_cmd(hdev, HCI_OP_PIN_CODE_NEG_REPLY, in hci_pin_code_request_evt()
4529 } else if (hci_dev_test_flag(hdev, HCI_MGMT)) { in hci_pin_code_request_evt()
4537 mgmt_pin_code_request(hdev, &ev->bdaddr, secure); in hci_pin_code_request_evt()
4541 hci_dev_unlock(hdev); in hci_pin_code_request_evt()
4576 static void hci_link_key_request_evt(struct hci_dev *hdev, void *data, in hci_link_key_request_evt() argument
4584 bt_dev_dbg(hdev, ""); in hci_link_key_request_evt()
4586 if (!hci_dev_test_flag(hdev, HCI_MGMT)) in hci_link_key_request_evt()
4589 hci_dev_lock(hdev); in hci_link_key_request_evt()
4591 key = hci_find_link_key(hdev, &ev->bdaddr); in hci_link_key_request_evt()
4593 bt_dev_dbg(hdev, "link key not found for %pMR", &ev->bdaddr); in hci_link_key_request_evt()
4597 bt_dev_dbg(hdev, "found key type %u for %pMR", key->type, &ev->bdaddr); in hci_link_key_request_evt()
4599 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_link_key_request_evt()
4606 bt_dev_dbg(hdev, "ignoring unauthenticated key"); in hci_link_key_request_evt()
4613 bt_dev_dbg(hdev, "ignoring key unauthenticated for high security"); in hci_link_key_request_evt()
4623 hci_send_cmd(hdev, HCI_OP_LINK_KEY_REPLY, sizeof(cp), &cp); in hci_link_key_request_evt()
4625 hci_dev_unlock(hdev); in hci_link_key_request_evt()
4630 hci_send_cmd(hdev, HCI_OP_LINK_KEY_NEG_REPLY, 6, &ev->bdaddr); in hci_link_key_request_evt()
4631 hci_dev_unlock(hdev); in hci_link_key_request_evt()
4634 static void hci_link_key_notify_evt(struct hci_dev *hdev, void *data, in hci_link_key_notify_evt() argument
4643 bt_dev_dbg(hdev, ""); in hci_link_key_notify_evt()
4645 hci_dev_lock(hdev); in hci_link_key_notify_evt()
4647 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_link_key_notify_evt()
4653 bt_dev_dbg(hdev, "Ignore NULL link key (ZERO KEY) for %pMR", in hci_link_key_notify_evt()
4667 if (!hci_dev_test_flag(hdev, HCI_MGMT)) in hci_link_key_notify_evt()
4670 key = hci_add_link_key(hdev, conn, &ev->bdaddr, ev->link_key, in hci_link_key_notify_evt()
4681 mgmt_new_link_key(hdev, key, persistent); in hci_link_key_notify_evt()
4689 !hci_dev_test_flag(hdev, HCI_KEEP_DEBUG_KEYS)) { in hci_link_key_notify_evt()
4701 hci_dev_unlock(hdev); in hci_link_key_notify_evt()
4704 static void hci_clock_offset_evt(struct hci_dev *hdev, void *data, in hci_clock_offset_evt() argument
4710 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_clock_offset_evt()
4712 hci_dev_lock(hdev); in hci_clock_offset_evt()
4714 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_clock_offset_evt()
4718 ie = hci_inquiry_cache_lookup(hdev, &conn->dst); in hci_clock_offset_evt()
4725 hci_dev_unlock(hdev); in hci_clock_offset_evt()
4728 static void hci_pkt_type_change_evt(struct hci_dev *hdev, void *data, in hci_pkt_type_change_evt() argument
4734 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_pkt_type_change_evt()
4736 hci_dev_lock(hdev); in hci_pkt_type_change_evt()
4738 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_pkt_type_change_evt()
4742 hci_dev_unlock(hdev); in hci_pkt_type_change_evt()
4745 static void hci_pscan_rep_mode_evt(struct hci_dev *hdev, void *data, in hci_pscan_rep_mode_evt() argument
4751 bt_dev_dbg(hdev, ""); in hci_pscan_rep_mode_evt()
4753 hci_dev_lock(hdev); in hci_pscan_rep_mode_evt()
4755 ie = hci_inquiry_cache_lookup(hdev, &ev->bdaddr); in hci_pscan_rep_mode_evt()
4761 hci_dev_unlock(hdev); in hci_pscan_rep_mode_evt()
4764 static void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, void *edata, in hci_inquiry_result_with_rssi_evt() argument
4771 bt_dev_dbg(hdev, "num_rsp %d", ev->num); in hci_inquiry_result_with_rssi_evt()
4776 if (hci_dev_test_flag(hdev, HCI_PERIODIC_INQ)) in hci_inquiry_result_with_rssi_evt()
4779 hci_dev_lock(hdev); in hci_inquiry_result_with_rssi_evt()
4788 info = hci_ev_skb_pull(hdev, skb, in hci_inquiry_result_with_rssi_evt()
4792 bt_dev_err(hdev, "Malformed HCI Event: 0x%2.2x", in hci_inquiry_result_with_rssi_evt()
4806 flags = hci_inquiry_cache_update(hdev, &data, false); in hci_inquiry_result_with_rssi_evt()
4808 mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, in hci_inquiry_result_with_rssi_evt()
4819 info = hci_ev_skb_pull(hdev, skb, in hci_inquiry_result_with_rssi_evt()
4823 bt_dev_err(hdev, "Malformed HCI Event: 0x%2.2x", in hci_inquiry_result_with_rssi_evt()
4837 flags = hci_inquiry_cache_update(hdev, &data, false); in hci_inquiry_result_with_rssi_evt()
4839 mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, in hci_inquiry_result_with_rssi_evt()
4844 bt_dev_err(hdev, "Malformed HCI Event: 0x%2.2x", in hci_inquiry_result_with_rssi_evt()
4848 hci_dev_unlock(hdev); in hci_inquiry_result_with_rssi_evt()
4851 static void hci_remote_ext_features_evt(struct hci_dev *hdev, void *data, in hci_remote_ext_features_evt() argument
4857 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_remote_ext_features_evt()
4859 hci_dev_lock(hdev); in hci_remote_ext_features_evt()
4861 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_remote_ext_features_evt()
4871 ie = hci_inquiry_cache_lookup(hdev, &conn->dst); in hci_remote_ext_features_evt()
4901 hci_send_cmd(hdev, HCI_OP_REMOTE_NAME_REQ, sizeof(cp), &cp); in hci_remote_ext_features_evt()
4903 mgmt_device_connected(hdev, conn, NULL, 0); in hci_remote_ext_features_evt()
4906 if (!hci_outgoing_auth_needed(hdev, conn)) { in hci_remote_ext_features_evt()
4913 hci_dev_unlock(hdev); in hci_remote_ext_features_evt()
4916 static void hci_sync_conn_complete_evt(struct hci_dev *hdev, void *data, in hci_sync_conn_complete_evt() argument
4932 bt_dev_err(hdev, "Ignoring connect complete event for invalid link type"); in hci_sync_conn_complete_evt()
4936 bt_dev_dbg(hdev, "status 0x%2.2x", status); in hci_sync_conn_complete_evt()
4938 hci_dev_lock(hdev); in hci_sync_conn_complete_evt()
4940 conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, &ev->bdaddr); in hci_sync_conn_complete_evt()
4954 conn = hci_conn_hash_lookup_ba(hdev, ESCO_LINK, &ev->bdaddr); in hci_sync_conn_complete_evt()
4966 bt_dev_err(hdev, "Ignoring HCI_Sync_Conn_Complete event for existing connection"); in hci_sync_conn_complete_evt()
4994 conn->pkt_type = (hdev->esco_type & SCO_ESCO_MASK) | in hci_sync_conn_complete_evt()
4995 (hdev->esco_type & EDR_ESCO_MASK); in hci_sync_conn_complete_evt()
5006 bt_dev_dbg(hdev, "SCO connected with air mode: %02x", ev->air_mode); in hci_sync_conn_complete_evt()
5010 if (conn->codec.data_path == 0 && hdev->notify) { in hci_sync_conn_complete_evt()
5013 hdev->notify(hdev, HCI_NOTIFY_ENABLE_SCO_CVSD); in hci_sync_conn_complete_evt()
5016 hdev->notify(hdev, HCI_NOTIFY_ENABLE_SCO_TRANSP); in hci_sync_conn_complete_evt()
5026 hci_dev_unlock(hdev); in hci_sync_conn_complete_evt()
5046 static void hci_extended_inquiry_result_evt(struct hci_dev *hdev, void *edata, in hci_extended_inquiry_result_evt() argument
5054 if (!hci_ev_skb_pull(hdev, skb, HCI_EV_EXTENDED_INQUIRY_RESULT, in hci_extended_inquiry_result_evt()
5058 bt_dev_dbg(hdev, "num %d", ev->num); in hci_extended_inquiry_result_evt()
5063 if (hci_dev_test_flag(hdev, HCI_PERIODIC_INQ)) in hci_extended_inquiry_result_evt()
5066 hci_dev_lock(hdev); in hci_extended_inquiry_result_evt()
5082 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_extended_inquiry_result_evt()
5089 flags = hci_inquiry_cache_update(hdev, &data, name_known); in hci_extended_inquiry_result_evt()
5093 mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, in hci_extended_inquiry_result_evt()
5098 hci_dev_unlock(hdev); in hci_extended_inquiry_result_evt()
5101 static void hci_key_refresh_complete_evt(struct hci_dev *hdev, void *data, in hci_key_refresh_complete_evt() argument
5107 bt_dev_dbg(hdev, "status 0x%2.2x handle 0x%4.4x", ev->status, in hci_key_refresh_complete_evt()
5110 hci_dev_lock(hdev); in hci_key_refresh_complete_evt()
5112 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_key_refresh_complete_evt()
5148 hci_dev_unlock(hdev); in hci_key_refresh_complete_evt()
5171 struct hci_dev *hdev = conn->hdev; in bredr_oob_data_present() local
5174 data = hci_find_remote_oob_data(hdev, &conn->dst, BDADDR_BREDR); in bredr_oob_data_present()
5178 if (bredr_sc_enabled(hdev)) { in bredr_oob_data_present()
5185 if (!hci_dev_test_flag(hdev, HCI_SC_ONLY)) in bredr_oob_data_present()
5211 static void hci_io_capa_request_evt(struct hci_dev *hdev, void *data, in hci_io_capa_request_evt() argument
5217 bt_dev_dbg(hdev, ""); in hci_io_capa_request_evt()
5219 hci_dev_lock(hdev); in hci_io_capa_request_evt()
5221 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_io_capa_request_evt()
5222 if (!conn || !hci_dev_test_flag(hdev, HCI_SSP_ENABLED)) in hci_io_capa_request_evt()
5230 if (!hci_dev_test_flag(hdev, HCI_MGMT)) in hci_io_capa_request_evt()
5236 if (hci_dev_test_flag(hdev, HCI_BONDABLE) || in hci_io_capa_request_evt()
5262 if (!hci_dev_test_flag(hdev, HCI_BONDABLE)) in hci_io_capa_request_evt()
5268 hci_send_cmd(hdev, HCI_OP_IO_CAPABILITY_REPLY, in hci_io_capa_request_evt()
5276 hci_send_cmd(hdev, HCI_OP_IO_CAPABILITY_NEG_REPLY, in hci_io_capa_request_evt()
5281 hci_dev_unlock(hdev); in hci_io_capa_request_evt()
5284 static void hci_io_capa_reply_evt(struct hci_dev *hdev, void *data, in hci_io_capa_reply_evt() argument
5290 bt_dev_dbg(hdev, ""); in hci_io_capa_reply_evt()
5292 hci_dev_lock(hdev); in hci_io_capa_reply_evt()
5294 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_io_capa_reply_evt()
5302 hci_dev_unlock(hdev); in hci_io_capa_reply_evt()
5305 static void hci_user_confirm_request_evt(struct hci_dev *hdev, void *data, in hci_user_confirm_request_evt() argument
5312 bt_dev_dbg(hdev, ""); in hci_user_confirm_request_evt()
5314 hci_dev_lock(hdev); in hci_user_confirm_request_evt()
5316 if (!hci_dev_test_flag(hdev, HCI_MGMT)) in hci_user_confirm_request_evt()
5319 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_user_confirm_request_evt()
5333 bt_dev_dbg(hdev, "Rejecting request: remote device can't provide MITM"); in hci_user_confirm_request_evt()
5334 hci_send_cmd(hdev, HCI_OP_USER_CONFIRM_NEG_REPLY, in hci_user_confirm_request_evt()
5349 bt_dev_dbg(hdev, "Confirming auto-accept as acceptor"); in hci_user_confirm_request_evt()
5358 if (hci_find_link_key(hdev, &ev->bdaddr)) { in hci_user_confirm_request_evt()
5359 bt_dev_dbg(hdev, "Local host already has link key"); in hci_user_confirm_request_evt()
5365 hdev->auto_accept_delay); in hci_user_confirm_request_evt()
5367 if (hdev->auto_accept_delay > 0) { in hci_user_confirm_request_evt()
5368 int delay = msecs_to_jiffies(hdev->auto_accept_delay); in hci_user_confirm_request_evt()
5369 queue_delayed_work(conn->hdev->workqueue, in hci_user_confirm_request_evt()
5374 hci_send_cmd(hdev, HCI_OP_USER_CONFIRM_REPLY, in hci_user_confirm_request_evt()
5380 mgmt_user_confirm_request(hdev, &ev->bdaddr, ACL_LINK, 0, in hci_user_confirm_request_evt()
5384 hci_dev_unlock(hdev); in hci_user_confirm_request_evt()
5387 static void hci_user_passkey_request_evt(struct hci_dev *hdev, void *data, in hci_user_passkey_request_evt() argument
5392 bt_dev_dbg(hdev, ""); in hci_user_passkey_request_evt()
5394 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_user_passkey_request_evt()
5395 mgmt_user_passkey_request(hdev, &ev->bdaddr, ACL_LINK, 0); in hci_user_passkey_request_evt()
5398 static void hci_user_passkey_notify_evt(struct hci_dev *hdev, void *data, in hci_user_passkey_notify_evt() argument
5404 bt_dev_dbg(hdev, ""); in hci_user_passkey_notify_evt()
5406 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_user_passkey_notify_evt()
5413 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_user_passkey_notify_evt()
5414 mgmt_user_passkey_notify(hdev, &conn->dst, conn->type, in hci_user_passkey_notify_evt()
5419 static void hci_keypress_notify_evt(struct hci_dev *hdev, void *data, in hci_keypress_notify_evt() argument
5425 bt_dev_dbg(hdev, ""); in hci_keypress_notify_evt()
5427 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_keypress_notify_evt()
5452 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_keypress_notify_evt()
5453 mgmt_user_passkey_notify(hdev, &conn->dst, conn->type, in hci_keypress_notify_evt()
5458 static void hci_simple_pair_complete_evt(struct hci_dev *hdev, void *data, in hci_simple_pair_complete_evt() argument
5464 bt_dev_dbg(hdev, ""); in hci_simple_pair_complete_evt()
5466 hci_dev_lock(hdev); in hci_simple_pair_complete_evt()
5468 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_simple_pair_complete_evt()
5486 hci_dev_unlock(hdev); in hci_simple_pair_complete_evt()
5489 static void hci_remote_host_features_evt(struct hci_dev *hdev, void *data, in hci_remote_host_features_evt() argument
5496 bt_dev_dbg(hdev, ""); in hci_remote_host_features_evt()
5498 hci_dev_lock(hdev); in hci_remote_host_features_evt()
5500 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_remote_host_features_evt()
5504 ie = hci_inquiry_cache_lookup(hdev, &ev->bdaddr); in hci_remote_host_features_evt()
5508 hci_dev_unlock(hdev); in hci_remote_host_features_evt()
5511 static void hci_remote_oob_data_request_evt(struct hci_dev *hdev, void *edata, in hci_remote_oob_data_request_evt() argument
5517 bt_dev_dbg(hdev, ""); in hci_remote_oob_data_request_evt()
5519 hci_dev_lock(hdev); in hci_remote_oob_data_request_evt()
5521 if (!hci_dev_test_flag(hdev, HCI_MGMT)) in hci_remote_oob_data_request_evt()
5524 data = hci_find_remote_oob_data(hdev, &ev->bdaddr, BDADDR_BREDR); in hci_remote_oob_data_request_evt()
5529 hci_send_cmd(hdev, HCI_OP_REMOTE_OOB_DATA_NEG_REPLY, in hci_remote_oob_data_request_evt()
5534 if (bredr_sc_enabled(hdev)) { in hci_remote_oob_data_request_evt()
5538 if (hci_dev_test_flag(hdev, HCI_SC_ONLY)) { in hci_remote_oob_data_request_evt()
5548 hci_send_cmd(hdev, HCI_OP_REMOTE_OOB_EXT_DATA_REPLY, in hci_remote_oob_data_request_evt()
5557 hci_send_cmd(hdev, HCI_OP_REMOTE_OOB_DATA_REPLY, in hci_remote_oob_data_request_evt()
5562 hci_dev_unlock(hdev); in hci_remote_oob_data_request_evt()
5579 } else if (hci_dev_test_flag(conn->hdev, HCI_PRIVACY)) { in le_conn_update_addr()
5581 bacpy(&conn->init_addr, &conn->hdev->rpa); in le_conn_update_addr()
5583 hci_copy_identity_address(conn->hdev, &conn->init_addr, in le_conn_update_addr()
5587 conn->resp_addr_type = conn->hdev->adv_addr_type; in le_conn_update_addr()
5594 } else if (conn->hdev->adv_addr_type == ADDR_LE_DEV_RANDOM) { in le_conn_update_addr()
5598 if (!ext_adv_capable(conn->hdev)) in le_conn_update_addr()
5600 &conn->hdev->random_addr); in le_conn_update_addr()
5602 bacpy(&conn->resp_addr, &conn->hdev->bdaddr); in le_conn_update_addr()
5613 conn->le_conn_min_interval = conn->hdev->le_conn_min_interval; in le_conn_update_addr()
5614 conn->le_conn_max_interval = conn->hdev->le_conn_max_interval; in le_conn_update_addr()
5618 static void le_conn_complete_evt(struct hci_dev *hdev, u8 status, in le_conn_complete_evt() argument
5629 hci_dev_lock(hdev); in le_conn_complete_evt()
5634 hci_dev_clear_flag(hdev, HCI_LE_ADV); in le_conn_complete_evt()
5636 conn = hci_conn_hash_lookup_ba(hdev, LE_LINK, bdaddr); in le_conn_complete_evt()
5644 conn = hci_conn_add_unset(hdev, LE_LINK, bdaddr, role); in le_conn_complete_evt()
5646 bt_dev_err(hdev, "connection err: %ld", PTR_ERR(conn)); in le_conn_complete_evt()
5663 if (hci_dev_test_flag(hdev, HCI_PRIVACY)) { in le_conn_complete_evt()
5665 bacpy(&conn->init_addr, &hdev->rpa); in le_conn_complete_evt()
5667 hci_copy_identity_address(hdev, in le_conn_complete_evt()
5683 bt_dev_err(hdev, "Ignoring HCI_Connection_Complete for existing connection"); in le_conn_complete_evt()
5698 irk = hci_get_irk(hdev, &conn->dst, conn->dst_type); in le_conn_complete_evt()
5704 conn->dst_type = ev_bdaddr_type(hdev, conn->dst_type, NULL); in le_conn_complete_evt()
5725 if (hci_bdaddr_list_lookup(&hdev->reject_list, &conn->dst, addr_type)) { in le_conn_complete_evt()
5730 mgmt_device_connected(hdev, conn, NULL, 0); in le_conn_complete_evt()
5739 if (!ext_adv_capable(hdev)) in le_conn_complete_evt()
5740 conn->adv_instance = hdev->cur_adv_instance; in le_conn_complete_evt()
5759 (hdev->le_features[0] & HCI_LE_PERIPHERAL_FEATURES)) { in le_conn_complete_evt()
5764 hci_send_cmd(hdev, HCI_OP_LE_READ_REMOTE_FEATURES, in le_conn_complete_evt()
5773 params = hci_pend_le_action_lookup(&hdev->pend_le_conns, &conn->dst, in le_conn_complete_evt()
5785 hci_update_passive_scan(hdev); in le_conn_complete_evt()
5786 hci_dev_unlock(hdev); in le_conn_complete_evt()
5789 static void hci_le_conn_complete_evt(struct hci_dev *hdev, void *data, in hci_le_conn_complete_evt() argument
5794 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_conn_complete_evt()
5796 le_conn_complete_evt(hdev, ev->status, &ev->bdaddr, ev->bdaddr_type, in hci_le_conn_complete_evt()
5803 static void hci_le_enh_conn_complete_evt(struct hci_dev *hdev, void *data, in hci_le_enh_conn_complete_evt() argument
5808 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_enh_conn_complete_evt()
5810 le_conn_complete_evt(hdev, ev->status, &ev->bdaddr, ev->bdaddr_type, in hci_le_enh_conn_complete_evt()
5817 static void hci_le_ext_adv_term_evt(struct hci_dev *hdev, void *data, in hci_le_ext_adv_term_evt() argument
5824 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_ext_adv_term_evt()
5834 bt_dev_warn_ratelimited(hdev, "Unexpected advertising set terminated event"); in hci_le_ext_adv_term_evt()
5838 hci_dev_lock(hdev); in hci_le_ext_adv_term_evt()
5840 adv = hci_find_adv_instance(hdev, ev->handle); in hci_le_ext_adv_term_evt()
5847 hci_remove_adv_instance(hdev, ev->handle); in hci_le_ext_adv_term_evt()
5848 mgmt_advertising_removed(NULL, hdev, ev->handle); in hci_le_ext_adv_term_evt()
5850 list_for_each_entry_safe(adv, n, &hdev->adv_instances, list) { in hci_le_ext_adv_term_evt()
5856 hci_dev_clear_flag(hdev, HCI_LE_ADV); in hci_le_ext_adv_term_evt()
5863 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->conn_handle)); in hci_le_ext_adv_term_evt()
5870 if (hdev->adv_addr_type != ADDR_LE_DEV_RANDOM || in hci_le_ext_adv_term_evt()
5875 bacpy(&conn->resp_addr, &hdev->random_addr); in hci_le_ext_adv_term_evt()
5884 hci_dev_unlock(hdev); in hci_le_ext_adv_term_evt()
5887 static void hci_le_conn_update_complete_evt(struct hci_dev *hdev, void *data, in hci_le_conn_update_complete_evt() argument
5893 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_conn_update_complete_evt()
5898 hci_dev_lock(hdev); in hci_le_conn_update_complete_evt()
5900 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_conn_update_complete_evt()
5907 hci_dev_unlock(hdev); in hci_le_conn_update_complete_evt()
5911 static struct hci_conn *check_pending_le_conn(struct hci_dev *hdev, in check_pending_le_conn() argument
5924 if (hci_bdaddr_list_lookup(&hdev->reject_list, addr, addr_type) || in check_pending_le_conn()
5925 hdev->suspended) in check_pending_le_conn()
5931 if (hdev->conn_hash.le_num_peripheral > 0 && in check_pending_le_conn()
5932 (test_bit(HCI_QUIRK_BROKEN_LE_STATES, &hdev->quirks) || in check_pending_le_conn()
5933 !(hdev->le_states[3] & 0x10))) in check_pending_le_conn()
5939 params = hci_pend_le_action_lookup(&hdev->pend_le_conns, addr, in check_pending_le_conn()
5967 conn = hci_connect_le(hdev, addr, addr_type, addr_resolved, in check_pending_le_conn()
5968 BT_SECURITY_LOW, hdev->def_le_autoconnect_timeout, in check_pending_le_conn()
6002 static void process_adv_report(struct hci_dev *hdev, u8 type, bdaddr_t *bdaddr, in process_adv_report() argument
6008 struct discovery_state *d = &hdev->discovery; in process_adv_report()
6023 bt_dev_err_ratelimited(hdev, "unknown advertising packet " in process_adv_report()
6028 if (len > max_adv_len(hdev)) { in process_adv_report()
6029 bt_dev_err_ratelimited(hdev, in process_adv_report()
6055 if (!hci_dev_test_flag(hdev, HCI_MESH) && direct_addr) { in process_adv_report()
6056 direct_addr_type = ev_bdaddr_type(hdev, direct_addr_type, in process_adv_report()
6068 if (!hci_dev_test_flag(hdev, HCI_PRIVACY)) in process_adv_report()
6075 if (!smp_irk_matches(hdev, hdev->irk, direct_addr)) in process_adv_report()
6080 irk = hci_get_irk(hdev, bdaddr, bdaddr_type); in process_adv_report()
6086 bdaddr_type = ev_bdaddr_type(hdev, bdaddr_type, &bdaddr_resolved); in process_adv_report()
6093 conn = check_pending_le_conn(hdev, bdaddr, bdaddr_type, bdaddr_resolved, in process_adv_report()
6096 len <= max_adv_len(hdev)) { in process_adv_report()
6110 if (hci_dev_test_flag(hdev, HCI_MESH)) { in process_adv_report()
6111 mgmt_device_found(hdev, bdaddr, LE_LINK, bdaddr_type, NULL, in process_adv_report()
6120 if (hdev->le_scan_type == LE_SCAN_PASSIVE) { in process_adv_report()
6124 if (!hci_pend_le_action_lookup(&hdev->pend_le_reports, in process_adv_report()
6126 idr_is_empty(&hdev->adv_monitors_idr)) in process_adv_report()
6129 mgmt_device_found(hdev, bdaddr, LE_LINK, bdaddr_type, NULL, in process_adv_report()
6151 if (!ext_adv && !has_pending_adv_report(hdev)) { in process_adv_report()
6156 store_pending_adv_report(hdev, bdaddr, bdaddr_type, in process_adv_report()
6161 mgmt_device_found(hdev, bdaddr, LE_LINK, bdaddr_type, NULL, in process_adv_report()
6177 mgmt_device_found(hdev, &d->last_adv_addr, LE_LINK, in process_adv_report()
6188 store_pending_adv_report(hdev, bdaddr, bdaddr_type, in process_adv_report()
6196 clear_pending_adv_report(hdev); in process_adv_report()
6197 mgmt_device_found(hdev, bdaddr, LE_LINK, bdaddr_type, NULL, in process_adv_report()
6206 mgmt_device_found(hdev, &d->last_adv_addr, LE_LINK, in process_adv_report()
6209 clear_pending_adv_report(hdev); in process_adv_report()
6212 static void hci_le_adv_report_evt(struct hci_dev *hdev, void *data, in hci_le_adv_report_evt() argument
6221 hci_dev_lock(hdev); in hci_le_adv_report_evt()
6227 info = hci_le_ev_skb_pull(hdev, skb, in hci_le_adv_report_evt()
6233 if (!hci_le_ev_skb_pull(hdev, skb, HCI_EV_LE_ADVERTISING_REPORT, in hci_le_adv_report_evt()
6237 if (info->length <= max_adv_len(hdev)) { in hci_le_adv_report_evt()
6239 process_adv_report(hdev, info->type, &info->bdaddr, in hci_le_adv_report_evt()
6245 bt_dev_err(hdev, "Dropping invalid advertising data"); in hci_le_adv_report_evt()
6249 hci_dev_unlock(hdev); in hci_le_adv_report_evt()
6252 static u8 ext_evt_type_to_legacy(struct hci_dev *hdev, u16 evt_type) in ext_evt_type_to_legacy() argument
6290 bt_dev_err_ratelimited(hdev, "Unknown advertising packet type: 0x%02x", in ext_evt_type_to_legacy()
6296 static void hci_le_ext_adv_report_evt(struct hci_dev *hdev, void *data, in hci_le_ext_adv_report_evt() argument
6305 hci_dev_lock(hdev); in hci_le_ext_adv_report_evt()
6312 info = hci_le_ev_skb_pull(hdev, skb, HCI_EV_LE_EXT_ADV_REPORT, in hci_le_ext_adv_report_evt()
6317 if (!hci_le_ev_skb_pull(hdev, skb, HCI_EV_LE_EXT_ADV_REPORT, in hci_le_ext_adv_report_evt()
6322 legacy_evt_type = ext_evt_type_to_legacy(hdev, evt_type); in hci_le_ext_adv_report_evt()
6325 &hdev->quirks)) { in hci_le_ext_adv_report_evt()
6331 process_adv_report(hdev, legacy_evt_type, &info->bdaddr, in hci_le_ext_adv_report_evt()
6341 hci_dev_unlock(hdev); in hci_le_ext_adv_report_evt()
6344 static int hci_le_pa_term_sync(struct hci_dev *hdev, __le16 handle) in hci_le_pa_term_sync() argument
6351 return hci_send_cmd(hdev, HCI_OP_LE_PA_TERM_SYNC, sizeof(cp), &cp); in hci_le_pa_term_sync()
6354 static void hci_le_pa_sync_estabilished_evt(struct hci_dev *hdev, void *data, in hci_le_pa_sync_estabilished_evt() argument
6358 int mask = hdev->link_mode; in hci_le_pa_sync_estabilished_evt()
6362 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_pa_sync_estabilished_evt()
6364 hci_dev_lock(hdev); in hci_le_pa_sync_estabilished_evt()
6366 hci_dev_clear_flag(hdev, HCI_PA_SYNC); in hci_le_pa_sync_estabilished_evt()
6368 conn = hci_conn_hash_lookup_sid(hdev, ev->sid, &ev->bdaddr, in hci_le_pa_sync_estabilished_evt()
6371 bt_dev_err(hdev, in hci_le_pa_sync_estabilished_evt()
6382 mask |= hci_proto_connect_ind(hdev, &ev->bdaddr, ISO_LINK, &flags); in hci_le_pa_sync_estabilished_evt()
6384 hci_le_pa_term_sync(hdev, ev->handle); in hci_le_pa_sync_estabilished_evt()
6392 pa_sync = hci_conn_add_unset(hdev, ISO_LINK, BDADDR_ANY, in hci_le_pa_sync_estabilished_evt()
6409 hci_pa_create_sync_pending(hdev); in hci_le_pa_sync_estabilished_evt()
6411 hci_dev_unlock(hdev); in hci_le_pa_sync_estabilished_evt()
6414 static void hci_le_per_adv_report_evt(struct hci_dev *hdev, void *data, in hci_le_per_adv_report_evt() argument
6418 int mask = hdev->link_mode; in hci_le_per_adv_report_evt()
6422 bt_dev_dbg(hdev, "sync_handle 0x%4.4x", le16_to_cpu(ev->sync_handle)); in hci_le_per_adv_report_evt()
6424 hci_dev_lock(hdev); in hci_le_per_adv_report_evt()
6426 mask |= hci_proto_connect_ind(hdev, BDADDR_ANY, ISO_LINK, &flags); in hci_le_per_adv_report_evt()
6434 (hdev, in hci_le_per_adv_report_evt()
6446 mgmt_device_connected(hdev, pa_sync, NULL, 0); in hci_le_per_adv_report_evt()
6450 hci_dev_unlock(hdev); in hci_le_per_adv_report_evt()
6453 static void hci_le_remote_feat_complete_evt(struct hci_dev *hdev, void *data, in hci_le_remote_feat_complete_evt() argument
6459 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_remote_feat_complete_evt()
6461 hci_dev_lock(hdev); in hci_le_remote_feat_complete_evt()
6463 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_remote_feat_complete_evt()
6481 (hdev->le_features[0] & HCI_LE_PERIPHERAL_FEATURES)) in hci_le_remote_feat_complete_evt()
6492 hci_dev_unlock(hdev); in hci_le_remote_feat_complete_evt()
6495 static void hci_le_ltk_request_evt(struct hci_dev *hdev, void *data, in hci_le_ltk_request_evt() argument
6504 bt_dev_dbg(hdev, "handle 0x%4.4x", __le16_to_cpu(ev->handle)); in hci_le_ltk_request_evt()
6506 hci_dev_lock(hdev); in hci_le_ltk_request_evt()
6508 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_ltk_request_evt()
6512 ltk = hci_find_ltk(hdev, &conn->dst, conn->dst_type, conn->role); in hci_le_ltk_request_evt()
6534 hci_send_cmd(hdev, HCI_OP_LE_LTK_REPLY, sizeof(cp), &cp); in hci_le_ltk_request_evt()
6550 hci_dev_unlock(hdev); in hci_le_ltk_request_evt()
6556 hci_send_cmd(hdev, HCI_OP_LE_LTK_NEG_REPLY, sizeof(neg), &neg); in hci_le_ltk_request_evt()
6557 hci_dev_unlock(hdev); in hci_le_ltk_request_evt()
6560 static void send_conn_param_neg_reply(struct hci_dev *hdev, u16 handle, in send_conn_param_neg_reply() argument
6568 hci_send_cmd(hdev, HCI_OP_LE_CONN_PARAM_REQ_NEG_REPLY, sizeof(cp), in send_conn_param_neg_reply()
6572 static void hci_le_remote_conn_param_req_evt(struct hci_dev *hdev, void *data, in hci_le_remote_conn_param_req_evt() argument
6580 bt_dev_dbg(hdev, "handle 0x%4.4x", __le16_to_cpu(ev->handle)); in hci_le_remote_conn_param_req_evt()
6588 hcon = hci_conn_hash_lookup_handle(hdev, handle); in hci_le_remote_conn_param_req_evt()
6590 return send_conn_param_neg_reply(hdev, handle, in hci_le_remote_conn_param_req_evt()
6594 return send_conn_param_neg_reply(hdev, handle, in hci_le_remote_conn_param_req_evt()
6598 return send_conn_param_neg_reply(hdev, handle, in hci_le_remote_conn_param_req_evt()
6605 hci_dev_lock(hdev); in hci_le_remote_conn_param_req_evt()
6607 params = hci_conn_params_lookup(hdev, &hcon->dst, in hci_le_remote_conn_param_req_evt()
6619 hci_dev_unlock(hdev); in hci_le_remote_conn_param_req_evt()
6621 mgmt_new_conn_param(hdev, &hcon->dst, hcon->dst_type, in hci_le_remote_conn_param_req_evt()
6633 hci_send_cmd(hdev, HCI_OP_LE_CONN_PARAM_REQ_REPLY, sizeof(cp), &cp); in hci_le_remote_conn_param_req_evt()
6636 static void hci_le_direct_adv_report_evt(struct hci_dev *hdev, void *data, in hci_le_direct_adv_report_evt() argument
6643 if (!hci_le_ev_skb_pull(hdev, skb, HCI_EV_LE_DIRECT_ADV_REPORT, in hci_le_direct_adv_report_evt()
6650 hci_dev_lock(hdev); in hci_le_direct_adv_report_evt()
6655 process_adv_report(hdev, info->type, &info->bdaddr, in hci_le_direct_adv_report_evt()
6661 hci_dev_unlock(hdev); in hci_le_direct_adv_report_evt()
6664 static void hci_le_phy_update_evt(struct hci_dev *hdev, void *data, in hci_le_phy_update_evt() argument
6670 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_phy_update_evt()
6675 hci_dev_lock(hdev); in hci_le_phy_update_evt()
6677 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_phy_update_evt()
6685 hci_dev_unlock(hdev); in hci_le_phy_update_evt()
6688 static void hci_le_cis_estabilished_evt(struct hci_dev *hdev, void *data, in hci_le_cis_estabilished_evt() argument
6698 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_cis_estabilished_evt()
6700 hci_dev_lock(hdev); in hci_le_cis_estabilished_evt()
6702 conn = hci_conn_hash_lookup_handle(hdev, handle); in hci_le_cis_estabilished_evt()
6704 bt_dev_err(hdev, in hci_le_cis_estabilished_evt()
6711 bt_dev_err(hdev, in hci_le_cis_estabilished_evt()
6783 hci_le_create_cis_pending(hdev); in hci_le_cis_estabilished_evt()
6785 hci_dev_unlock(hdev); in hci_le_cis_estabilished_evt()
6788 static void hci_le_reject_cis(struct hci_dev *hdev, __le16 handle) in hci_le_reject_cis() argument
6795 hci_send_cmd(hdev, HCI_OP_LE_REJECT_CIS, sizeof(cp), &cp); in hci_le_reject_cis()
6798 static void hci_le_accept_cis(struct hci_dev *hdev, __le16 handle) in hci_le_accept_cis() argument
6804 hci_send_cmd(hdev, HCI_OP_LE_ACCEPT_CIS, sizeof(cp), &cp); in hci_le_accept_cis()
6807 static void hci_le_cis_req_evt(struct hci_dev *hdev, void *data, in hci_le_cis_req_evt() argument
6819 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()
6822 hci_dev_lock(hdev); in hci_le_cis_req_evt()
6824 acl = hci_conn_hash_lookup_handle(hdev, acl_handle); in hci_le_cis_req_evt()
6828 mask = hci_proto_connect_ind(hdev, &acl->dst, ISO_LINK, &flags); in hci_le_cis_req_evt()
6830 hci_le_reject_cis(hdev, ev->cis_handle); in hci_le_cis_req_evt()
6834 cis = hci_conn_hash_lookup_handle(hdev, cis_handle); in hci_le_cis_req_evt()
6836 cis = hci_conn_add(hdev, ISO_LINK, &acl->dst, HCI_ROLE_SLAVE, in hci_le_cis_req_evt()
6839 hci_le_reject_cis(hdev, ev->cis_handle); in hci_le_cis_req_evt()
6848 hci_le_accept_cis(hdev, ev->cis_handle); in hci_le_cis_req_evt()
6855 hci_dev_unlock(hdev); in hci_le_cis_req_evt()
6858 static int hci_iso_term_big_sync(struct hci_dev *hdev, void *data) in hci_iso_term_big_sync() argument
6862 return hci_le_terminate_big_sync(hdev, handle, in hci_iso_term_big_sync()
6866 static void hci_le_create_big_complete_evt(struct hci_dev *hdev, void *data, in hci_le_create_big_complete_evt() argument
6873 BT_DBG("%s status 0x%2.2x", hdev->name, ev->status); in hci_le_create_big_complete_evt()
6875 if (!hci_le_ev_skb_pull(hdev, skb, HCI_EVT_LE_CREATE_BIG_COMPLETE, in hci_le_create_big_complete_evt()
6879 hci_dev_lock(hdev); in hci_le_create_big_complete_evt()
6882 while ((conn = hci_conn_hash_lookup_big_state(hdev, ev->handle, in hci_le_create_big_complete_evt()
6907 hci_cmd_sync_queue(hdev, hci_iso_term_big_sync, in hci_le_create_big_complete_evt()
6910 hci_dev_unlock(hdev); in hci_le_create_big_complete_evt()
6913 static void hci_le_big_sync_established_evt(struct hci_dev *hdev, void *data, in hci_le_big_sync_established_evt() argument
6920 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); in hci_le_big_sync_established_evt()
6922 if (!hci_le_ev_skb_pull(hdev, skb, HCI_EVT_LE_BIG_SYNC_ESTABILISHED, in hci_le_big_sync_established_evt()
6926 hci_dev_lock(hdev); in hci_le_big_sync_established_evt()
6928 conn = hci_conn_hash_lookup_big_sync_pend(hdev, ev->handle, in hci_le_big_sync_established_evt()
6931 bt_dev_err(hdev, in hci_le_big_sync_established_evt()
6946 bis = hci_conn_hash_lookup_handle(hdev, handle); in hci_le_big_sync_established_evt()
6949 bt_dev_dbg(hdev, "ignore too large handle %u", handle); in hci_le_big_sync_established_evt()
6952 bis = hci_conn_add(hdev, ISO_LINK, BDADDR_ANY, in hci_le_big_sync_established_evt()
6984 bis = hci_conn_hash_lookup_handle(hdev, handle); in hci_le_big_sync_established_evt()
6994 hci_le_big_create_sync_pending(hdev); in hci_le_big_sync_established_evt()
6996 hci_dev_unlock(hdev); in hci_le_big_sync_established_evt()
6999 static void hci_le_big_info_adv_report_evt(struct hci_dev *hdev, void *data, in hci_le_big_info_adv_report_evt() argument
7003 int mask = hdev->link_mode; in hci_le_big_info_adv_report_evt()
7007 bt_dev_dbg(hdev, "sync_handle 0x%4.4x", le16_to_cpu(ev->sync_handle)); in hci_le_big_info_adv_report_evt()
7009 hci_dev_lock(hdev); in hci_le_big_info_adv_report_evt()
7011 mask |= hci_proto_connect_ind(hdev, BDADDR_ANY, ISO_LINK, &flags); in hci_le_big_info_adv_report_evt()
7019 (hdev, in hci_le_big_info_adv_report_evt()
7031 hci_dev_unlock(hdev); in hci_le_big_info_adv_report_evt()
7053 void (*func)(struct hci_dev *hdev, void *data, struct sk_buff *skb);
7129 static void hci_le_meta_evt(struct hci_dev *hdev, void *data, in hci_le_meta_evt() argument
7137 bt_dev_dbg(hdev, "subevent 0x%2.2x", ev->subevent); in hci_le_meta_evt()
7140 if (hdev->req_skb && in hci_le_meta_evt()
7141 hci_opcode_ogf(hci_skb_opcode(hdev->req_skb)) == 0x08 && in hci_le_meta_evt()
7142 hci_skb_event(hdev->req_skb) == ev->subevent) { in hci_le_meta_evt()
7143 *opcode = hci_skb_opcode(hdev->req_skb); in hci_le_meta_evt()
7144 hci_req_cmd_complete(hdev, *opcode, 0x00, req_complete, in hci_le_meta_evt()
7153 bt_dev_err(hdev, "unexpected subevent 0x%2.2x length: %u < %u", in hci_le_meta_evt()
7163 bt_dev_warn(hdev, "unexpected subevent 0x%2.2x length: %u > %u", in hci_le_meta_evt()
7165 data = hci_le_ev_skb_pull(hdev, skb, ev->subevent, subev->min_len); in hci_le_meta_evt()
7169 subev->func(hdev, data, skb); in hci_le_meta_evt()
7172 static bool hci_get_cmd_complete(struct hci_dev *hdev, u16 opcode, in hci_get_cmd_complete() argument
7181 hdr = hci_ev_skb_pull(hdev, skb, event, sizeof(*hdr)); in hci_get_cmd_complete()
7198 bt_dev_err(hdev, "last event is not cmd complete (0x%2.2x)", in hci_get_cmd_complete()
7203 ev = hci_cc_skb_pull(hdev, skb, opcode, sizeof(*ev)); in hci_get_cmd_complete()
7216 static void hci_store_wake_reason(struct hci_dev *hdev, u8 event, in hci_store_wake_reason() argument
7225 hci_dev_lock(hdev); in hci_store_wake_reason()
7230 if (!hdev->suspended || hdev->wake_reason) in hci_store_wake_reason()
7236 hdev->wake_reason = MGMT_WAKE_REASON_REMOTE_WAKE; in hci_store_wake_reason()
7243 bacpy(&hdev->wake_addr, &conn_request->bdaddr); in hci_store_wake_reason()
7244 hdev->wake_addr_type = BDADDR_BREDR; in hci_store_wake_reason()
7246 bacpy(&hdev->wake_addr, &conn_complete->bdaddr); in hci_store_wake_reason()
7247 hdev->wake_addr_type = BDADDR_BREDR; in hci_store_wake_reason()
7264 bacpy(&hdev->wake_addr, &adv->bdaddr); in hci_store_wake_reason()
7265 hdev->wake_addr_type = adv->bdaddr_type; in hci_store_wake_reason()
7268 bacpy(&hdev->wake_addr, &direct_adv->bdaddr); in hci_store_wake_reason()
7269 hdev->wake_addr_type = direct_adv->bdaddr_type; in hci_store_wake_reason()
7272 bacpy(&hdev->wake_addr, &ext_adv->bdaddr); in hci_store_wake_reason()
7273 hdev->wake_addr_type = ext_adv->bdaddr_type; in hci_store_wake_reason()
7278 hdev->wake_reason = MGMT_WAKE_REASON_UNEXPECTED; in hci_store_wake_reason()
7282 hci_dev_unlock(hdev); in hci_store_wake_reason()
7318 void (*func)(struct hci_dev *hdev, void *data,
7320 void (*func_req)(struct hci_dev *hdev, void *data,
7446 static void hci_event_func(struct hci_dev *hdev, u8 event, struct sk_buff *skb, in hci_event_func() argument
7458 bt_dev_err(hdev, "unexpected event 0x%2.2x length: %u < %u", in hci_event_func()
7468 bt_dev_warn_ratelimited(hdev, in hci_event_func()
7472 data = hci_ev_skb_pull(hdev, skb, event, ev->min_len); in hci_event_func()
7477 ev->func_req(hdev, data, skb, opcode, status, req_complete, in hci_event_func()
7480 ev->func(hdev, data, skb); in hci_event_func()
7483 void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb) in hci_event_packet() argument
7493 bt_dev_err(hdev, "Malformed HCI Event"); in hci_event_packet()
7497 kfree_skb(hdev->recv_event); in hci_event_packet()
7498 hdev->recv_event = skb_clone(skb, GFP_KERNEL); in hci_event_packet()
7502 bt_dev_warn(hdev, "Received unexpected HCI Event 0x%2.2x", in hci_event_packet()
7508 if (hdev->req_skb && in hci_event_packet()
7509 hci_opcode_ogf(hci_skb_opcode(hdev->req_skb)) != 0x08 && in hci_event_packet()
7510 hci_skb_event(hdev->req_skb) == event) { in hci_event_packet()
7511 hci_req_cmd_complete(hdev, hci_skb_opcode(hdev->req_skb), in hci_event_packet()
7528 hci_store_wake_reason(hdev, event, skb); in hci_event_packet()
7530 bt_dev_dbg(hdev, "event 0x%2.2x", event); in hci_event_packet()
7532 hci_event_func(hdev, event, skb, &opcode, &status, &req_complete, in hci_event_packet()
7536 req_complete(hdev, status, opcode); in hci_event_packet()
7538 if (!hci_get_cmd_complete(hdev, opcode, req_evt, orig_skb)) { in hci_event_packet()
7542 req_complete_skb(hdev, status, opcode, orig_skb); in hci_event_packet()
7548 hdev->stat.evt_rx++; in hci_event_packet()