Lines Matching refs:hdev
44 static void hci_cc_inquiry_cancel(struct hci_dev *hdev, struct sk_buff *skb) in hci_cc_inquiry_cancel() argument
48 BT_DBG("%s status 0x%2.2x", hdev->name, status); in hci_cc_inquiry_cancel()
53 clear_bit(HCI_INQUIRY, &hdev->flags); in hci_cc_inquiry_cancel()
55 wake_up_bit(&hdev->flags, HCI_INQUIRY); in hci_cc_inquiry_cancel()
57 hci_dev_lock(hdev); in hci_cc_inquiry_cancel()
61 if (!hci_dev_test_flag(hdev, HCI_LE_SCAN) || in hci_cc_inquiry_cancel()
62 hdev->le_scan_type != LE_SCAN_ACTIVE) in hci_cc_inquiry_cancel()
63 hci_discovery_set_state(hdev, DISCOVERY_STOPPED); in hci_cc_inquiry_cancel()
64 hci_dev_unlock(hdev); in hci_cc_inquiry_cancel()
66 hci_conn_check_pending(hdev); in hci_cc_inquiry_cancel()
69 static void hci_cc_periodic_inq(struct hci_dev *hdev, struct sk_buff *skb) in hci_cc_periodic_inq() argument
73 BT_DBG("%s status 0x%2.2x", hdev->name, status); in hci_cc_periodic_inq()
78 hci_dev_set_flag(hdev, HCI_PERIODIC_INQ); in hci_cc_periodic_inq()
81 static void hci_cc_exit_periodic_inq(struct hci_dev *hdev, struct sk_buff *skb) in hci_cc_exit_periodic_inq() argument
85 BT_DBG("%s status 0x%2.2x", hdev->name, status); in hci_cc_exit_periodic_inq()
90 hci_dev_clear_flag(hdev, HCI_PERIODIC_INQ); in hci_cc_exit_periodic_inq()
92 hci_conn_check_pending(hdev); in hci_cc_exit_periodic_inq()
95 static void hci_cc_remote_name_req_cancel(struct hci_dev *hdev, in hci_cc_remote_name_req_cancel() argument
98 BT_DBG("%s", hdev->name); in hci_cc_remote_name_req_cancel()
101 static void hci_cc_role_discovery(struct hci_dev *hdev, struct sk_buff *skb) in hci_cc_role_discovery() argument
106 BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); in hci_cc_role_discovery()
111 hci_dev_lock(hdev); in hci_cc_role_discovery()
113 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_role_discovery()
117 hci_dev_unlock(hdev); in hci_cc_role_discovery()
120 static void hci_cc_read_link_policy(struct hci_dev *hdev, struct sk_buff *skb) in hci_cc_read_link_policy() argument
125 BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); in hci_cc_read_link_policy()
130 hci_dev_lock(hdev); in hci_cc_read_link_policy()
132 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_link_policy()
136 hci_dev_unlock(hdev); in hci_cc_read_link_policy()
139 static void hci_cc_write_link_policy(struct hci_dev *hdev, struct sk_buff *skb) in hci_cc_write_link_policy() argument
145 BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); in hci_cc_write_link_policy()
150 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_LINK_POLICY); in hci_cc_write_link_policy()
154 hci_dev_lock(hdev); in hci_cc_write_link_policy()
156 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_write_link_policy()
160 hci_dev_unlock(hdev); in hci_cc_write_link_policy()
163 static void hci_cc_read_def_link_policy(struct hci_dev *hdev, in hci_cc_read_def_link_policy() argument
168 BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); in hci_cc_read_def_link_policy()
173 hdev->link_policy = __le16_to_cpu(rp->policy); in hci_cc_read_def_link_policy()
176 static void hci_cc_write_def_link_policy(struct hci_dev *hdev, in hci_cc_write_def_link_policy() argument
182 BT_DBG("%s status 0x%2.2x", hdev->name, status); in hci_cc_write_def_link_policy()
187 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_DEF_LINK_POLICY); in hci_cc_write_def_link_policy()
191 hdev->link_policy = get_unaligned_le16(sent); in hci_cc_write_def_link_policy()
194 static void hci_cc_reset(struct hci_dev *hdev, struct sk_buff *skb) in hci_cc_reset() argument
198 BT_DBG("%s status 0x%2.2x", hdev->name, status); in hci_cc_reset()
200 clear_bit(HCI_RESET, &hdev->flags); in hci_cc_reset()
206 hci_dev_clear_volatile_flags(hdev); in hci_cc_reset()
208 hci_discovery_set_state(hdev, DISCOVERY_STOPPED); in hci_cc_reset()
210 hdev->inq_tx_power = HCI_TX_POWER_INVALID; in hci_cc_reset()
211 hdev->adv_tx_power = HCI_TX_POWER_INVALID; in hci_cc_reset()
213 memset(hdev->adv_data, 0, sizeof(hdev->adv_data)); in hci_cc_reset()
214 hdev->adv_data_len = 0; in hci_cc_reset()
216 memset(hdev->scan_rsp_data, 0, sizeof(hdev->scan_rsp_data)); in hci_cc_reset()
217 hdev->scan_rsp_data_len = 0; in hci_cc_reset()
219 hdev->le_scan_type = LE_SCAN_PASSIVE; in hci_cc_reset()
221 hdev->ssp_debug_mode = 0; in hci_cc_reset()
223 hci_bdaddr_list_clear(&hdev->le_white_list); in hci_cc_reset()
224 hci_bdaddr_list_clear(&hdev->le_resolv_list); in hci_cc_reset()
227 static void hci_cc_read_stored_link_key(struct hci_dev *hdev, in hci_cc_read_stored_link_key() argument
233 BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); in hci_cc_read_stored_link_key()
235 sent = hci_sent_cmd_data(hdev, HCI_OP_READ_STORED_LINK_KEY); in hci_cc_read_stored_link_key()
240 hdev->stored_max_keys = rp->max_keys; in hci_cc_read_stored_link_key()
241 hdev->stored_num_keys = rp->num_keys; in hci_cc_read_stored_link_key()
245 static void hci_cc_delete_stored_link_key(struct hci_dev *hdev, in hci_cc_delete_stored_link_key() argument
250 BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); in hci_cc_delete_stored_link_key()
255 if (rp->num_keys <= hdev->stored_num_keys) in hci_cc_delete_stored_link_key()
256 hdev->stored_num_keys -= rp->num_keys; in hci_cc_delete_stored_link_key()
258 hdev->stored_num_keys = 0; in hci_cc_delete_stored_link_key()
261 static void hci_cc_write_local_name(struct hci_dev *hdev, struct sk_buff *skb) in hci_cc_write_local_name() argument
266 BT_DBG("%s status 0x%2.2x", hdev->name, status); in hci_cc_write_local_name()
268 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_LOCAL_NAME); in hci_cc_write_local_name()
272 hci_dev_lock(hdev); in hci_cc_write_local_name()
274 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_cc_write_local_name()
275 mgmt_set_local_name_complete(hdev, sent, status); in hci_cc_write_local_name()
277 memcpy(hdev->dev_name, sent, HCI_MAX_NAME_LENGTH); in hci_cc_write_local_name()
279 hci_dev_unlock(hdev); in hci_cc_write_local_name()
282 static void hci_cc_read_local_name(struct hci_dev *hdev, struct sk_buff *skb) in hci_cc_read_local_name() argument
286 BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); in hci_cc_read_local_name()
291 if (hci_dev_test_flag(hdev, HCI_SETUP) || in hci_cc_read_local_name()
292 hci_dev_test_flag(hdev, HCI_CONFIG)) in hci_cc_read_local_name()
293 memcpy(hdev->dev_name, rp->name, HCI_MAX_NAME_LENGTH); in hci_cc_read_local_name()
296 static void hci_cc_write_auth_enable(struct hci_dev *hdev, struct sk_buff *skb) in hci_cc_write_auth_enable() argument
301 BT_DBG("%s status 0x%2.2x", hdev->name, status); in hci_cc_write_auth_enable()
303 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_AUTH_ENABLE); in hci_cc_write_auth_enable()
307 hci_dev_lock(hdev); in hci_cc_write_auth_enable()
313 set_bit(HCI_AUTH, &hdev->flags); in hci_cc_write_auth_enable()
315 clear_bit(HCI_AUTH, &hdev->flags); in hci_cc_write_auth_enable()
318 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_cc_write_auth_enable()
319 mgmt_auth_enable_complete(hdev, status); in hci_cc_write_auth_enable()
321 hci_dev_unlock(hdev); in hci_cc_write_auth_enable()
324 static void hci_cc_write_encrypt_mode(struct hci_dev *hdev, struct sk_buff *skb) in hci_cc_write_encrypt_mode() argument
330 BT_DBG("%s status 0x%2.2x", hdev->name, status); in hci_cc_write_encrypt_mode()
335 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_ENCRYPT_MODE); in hci_cc_write_encrypt_mode()
342 set_bit(HCI_ENCRYPT, &hdev->flags); in hci_cc_write_encrypt_mode()
344 clear_bit(HCI_ENCRYPT, &hdev->flags); in hci_cc_write_encrypt_mode()
347 static void hci_cc_write_scan_enable(struct hci_dev *hdev, struct sk_buff *skb) in hci_cc_write_scan_enable() argument
353 BT_DBG("%s status 0x%2.2x", hdev->name, status); in hci_cc_write_scan_enable()
355 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_SCAN_ENABLE); in hci_cc_write_scan_enable()
361 hci_dev_lock(hdev); in hci_cc_write_scan_enable()
364 hdev->discov_timeout = 0; in hci_cc_write_scan_enable()
369 set_bit(HCI_ISCAN, &hdev->flags); in hci_cc_write_scan_enable()
371 clear_bit(HCI_ISCAN, &hdev->flags); in hci_cc_write_scan_enable()
374 set_bit(HCI_PSCAN, &hdev->flags); in hci_cc_write_scan_enable()
376 clear_bit(HCI_PSCAN, &hdev->flags); in hci_cc_write_scan_enable()
379 hci_dev_unlock(hdev); in hci_cc_write_scan_enable()
382 static void hci_cc_read_class_of_dev(struct hci_dev *hdev, struct sk_buff *skb) in hci_cc_read_class_of_dev() argument
386 BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); in hci_cc_read_class_of_dev()
391 memcpy(hdev->dev_class, rp->dev_class, 3); in hci_cc_read_class_of_dev()
393 BT_DBG("%s class 0x%.2x%.2x%.2x", hdev->name, in hci_cc_read_class_of_dev()
394 hdev->dev_class[2], hdev->dev_class[1], hdev->dev_class[0]); in hci_cc_read_class_of_dev()
397 static void hci_cc_write_class_of_dev(struct hci_dev *hdev, struct sk_buff *skb) in hci_cc_write_class_of_dev() argument
402 BT_DBG("%s status 0x%2.2x", hdev->name, status); in hci_cc_write_class_of_dev()
404 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_CLASS_OF_DEV); in hci_cc_write_class_of_dev()
408 hci_dev_lock(hdev); in hci_cc_write_class_of_dev()
411 memcpy(hdev->dev_class, sent, 3); in hci_cc_write_class_of_dev()
413 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_cc_write_class_of_dev()
414 mgmt_set_class_of_dev_complete(hdev, sent, status); in hci_cc_write_class_of_dev()
416 hci_dev_unlock(hdev); in hci_cc_write_class_of_dev()
419 static void hci_cc_read_voice_setting(struct hci_dev *hdev, struct sk_buff *skb) in hci_cc_read_voice_setting() argument
424 BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); in hci_cc_read_voice_setting()
431 if (hdev->voice_setting == setting) in hci_cc_read_voice_setting()
434 hdev->voice_setting = setting; in hci_cc_read_voice_setting()
436 BT_DBG("%s voice setting 0x%4.4x", hdev->name, setting); in hci_cc_read_voice_setting()
438 if (hdev->notify) in hci_cc_read_voice_setting()
439 hdev->notify(hdev, HCI_NOTIFY_VOICE_SETTING); in hci_cc_read_voice_setting()
442 static void hci_cc_write_voice_setting(struct hci_dev *hdev, in hci_cc_write_voice_setting() argument
449 BT_DBG("%s status 0x%2.2x", hdev->name, status); in hci_cc_write_voice_setting()
454 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_VOICE_SETTING); in hci_cc_write_voice_setting()
460 if (hdev->voice_setting == setting) in hci_cc_write_voice_setting()
463 hdev->voice_setting = setting; in hci_cc_write_voice_setting()
465 BT_DBG("%s voice setting 0x%4.4x", hdev->name, setting); in hci_cc_write_voice_setting()
467 if (hdev->notify) in hci_cc_write_voice_setting()
468 hdev->notify(hdev, HCI_NOTIFY_VOICE_SETTING); in hci_cc_write_voice_setting()
471 static void hci_cc_read_num_supported_iac(struct hci_dev *hdev, in hci_cc_read_num_supported_iac() argument
476 BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); in hci_cc_read_num_supported_iac()
481 hdev->num_iac = rp->num_iac; in hci_cc_read_num_supported_iac()
483 BT_DBG("%s num iac %d", hdev->name, hdev->num_iac); in hci_cc_read_num_supported_iac()
486 static void hci_cc_write_ssp_mode(struct hci_dev *hdev, struct sk_buff *skb) in hci_cc_write_ssp_mode() argument
491 BT_DBG("%s status 0x%2.2x", hdev->name, status); in hci_cc_write_ssp_mode()
493 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_SSP_MODE); in hci_cc_write_ssp_mode()
497 hci_dev_lock(hdev); in hci_cc_write_ssp_mode()
501 hdev->features[1][0] |= LMP_HOST_SSP; in hci_cc_write_ssp_mode()
503 hdev->features[1][0] &= ~LMP_HOST_SSP; in hci_cc_write_ssp_mode()
506 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_cc_write_ssp_mode()
507 mgmt_ssp_enable_complete(hdev, sent->mode, status); in hci_cc_write_ssp_mode()
510 hci_dev_set_flag(hdev, HCI_SSP_ENABLED); in hci_cc_write_ssp_mode()
512 hci_dev_clear_flag(hdev, HCI_SSP_ENABLED); in hci_cc_write_ssp_mode()
515 hci_dev_unlock(hdev); in hci_cc_write_ssp_mode()
518 static void hci_cc_write_sc_support(struct hci_dev *hdev, struct sk_buff *skb) in hci_cc_write_sc_support() argument
523 BT_DBG("%s status 0x%2.2x", hdev->name, status); in hci_cc_write_sc_support()
525 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_SC_SUPPORT); in hci_cc_write_sc_support()
529 hci_dev_lock(hdev); in hci_cc_write_sc_support()
533 hdev->features[1][0] |= LMP_HOST_SC; in hci_cc_write_sc_support()
535 hdev->features[1][0] &= ~LMP_HOST_SC; in hci_cc_write_sc_support()
538 if (!hci_dev_test_flag(hdev, HCI_MGMT) && !status) { in hci_cc_write_sc_support()
540 hci_dev_set_flag(hdev, HCI_SC_ENABLED); in hci_cc_write_sc_support()
542 hci_dev_clear_flag(hdev, HCI_SC_ENABLED); in hci_cc_write_sc_support()
545 hci_dev_unlock(hdev); in hci_cc_write_sc_support()
548 static void hci_cc_read_local_version(struct hci_dev *hdev, struct sk_buff *skb) in hci_cc_read_local_version() argument
552 BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); in hci_cc_read_local_version()
557 if (hci_dev_test_flag(hdev, HCI_SETUP) || in hci_cc_read_local_version()
558 hci_dev_test_flag(hdev, HCI_CONFIG)) { in hci_cc_read_local_version()
559 hdev->hci_ver = rp->hci_ver; in hci_cc_read_local_version()
560 hdev->hci_rev = __le16_to_cpu(rp->hci_rev); in hci_cc_read_local_version()
561 hdev->lmp_ver = rp->lmp_ver; in hci_cc_read_local_version()
562 hdev->manufacturer = __le16_to_cpu(rp->manufacturer); in hci_cc_read_local_version()
563 hdev->lmp_subver = __le16_to_cpu(rp->lmp_subver); in hci_cc_read_local_version()
567 static void hci_cc_read_local_commands(struct hci_dev *hdev, in hci_cc_read_local_commands() argument
572 BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); in hci_cc_read_local_commands()
577 if (hci_dev_test_flag(hdev, HCI_SETUP) || in hci_cc_read_local_commands()
578 hci_dev_test_flag(hdev, HCI_CONFIG)) in hci_cc_read_local_commands()
579 memcpy(hdev->commands, rp->commands, sizeof(hdev->commands)); in hci_cc_read_local_commands()
582 static void hci_cc_read_local_features(struct hci_dev *hdev, in hci_cc_read_local_features() argument
587 BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); in hci_cc_read_local_features()
592 memcpy(hdev->features, rp->features, 8); in hci_cc_read_local_features()
597 if (hdev->features[0][0] & LMP_3SLOT) in hci_cc_read_local_features()
598 hdev->pkt_type |= (HCI_DM3 | HCI_DH3); in hci_cc_read_local_features()
600 if (hdev->features[0][0] & LMP_5SLOT) in hci_cc_read_local_features()
601 hdev->pkt_type |= (HCI_DM5 | HCI_DH5); in hci_cc_read_local_features()
603 if (hdev->features[0][1] & LMP_HV2) { in hci_cc_read_local_features()
604 hdev->pkt_type |= (HCI_HV2); in hci_cc_read_local_features()
605 hdev->esco_type |= (ESCO_HV2); in hci_cc_read_local_features()
608 if (hdev->features[0][1] & LMP_HV3) { in hci_cc_read_local_features()
609 hdev->pkt_type |= (HCI_HV3); in hci_cc_read_local_features()
610 hdev->esco_type |= (ESCO_HV3); in hci_cc_read_local_features()
613 if (lmp_esco_capable(hdev)) in hci_cc_read_local_features()
614 hdev->esco_type |= (ESCO_EV3); in hci_cc_read_local_features()
616 if (hdev->features[0][4] & LMP_EV4) in hci_cc_read_local_features()
617 hdev->esco_type |= (ESCO_EV4); in hci_cc_read_local_features()
619 if (hdev->features[0][4] & LMP_EV5) in hci_cc_read_local_features()
620 hdev->esco_type |= (ESCO_EV5); in hci_cc_read_local_features()
622 if (hdev->features[0][5] & LMP_EDR_ESCO_2M) in hci_cc_read_local_features()
623 hdev->esco_type |= (ESCO_2EV3); in hci_cc_read_local_features()
625 if (hdev->features[0][5] & LMP_EDR_ESCO_3M) in hci_cc_read_local_features()
626 hdev->esco_type |= (ESCO_3EV3); in hci_cc_read_local_features()
628 if (hdev->features[0][5] & LMP_EDR_3S_ESCO) in hci_cc_read_local_features()
629 hdev->esco_type |= (ESCO_2EV5 | ESCO_3EV5); in hci_cc_read_local_features()
632 static void hci_cc_read_local_ext_features(struct hci_dev *hdev, in hci_cc_read_local_ext_features() argument
637 BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); in hci_cc_read_local_ext_features()
642 if (hdev->max_page < rp->max_page) in hci_cc_read_local_ext_features()
643 hdev->max_page = rp->max_page; in hci_cc_read_local_ext_features()
646 memcpy(hdev->features[rp->page], rp->features, 8); in hci_cc_read_local_ext_features()
649 static void hci_cc_read_flow_control_mode(struct hci_dev *hdev, in hci_cc_read_flow_control_mode() argument
654 BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); in hci_cc_read_flow_control_mode()
659 hdev->flow_ctl_mode = rp->mode; in hci_cc_read_flow_control_mode()
662 static void hci_cc_read_buffer_size(struct hci_dev *hdev, struct sk_buff *skb) in hci_cc_read_buffer_size() argument
666 BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); in hci_cc_read_buffer_size()
671 hdev->acl_mtu = __le16_to_cpu(rp->acl_mtu); in hci_cc_read_buffer_size()
672 hdev->sco_mtu = rp->sco_mtu; in hci_cc_read_buffer_size()
673 hdev->acl_pkts = __le16_to_cpu(rp->acl_max_pkt); in hci_cc_read_buffer_size()
674 hdev->sco_pkts = __le16_to_cpu(rp->sco_max_pkt); in hci_cc_read_buffer_size()
676 if (test_bit(HCI_QUIRK_FIXUP_BUFFER_SIZE, &hdev->quirks)) { in hci_cc_read_buffer_size()
677 hdev->sco_mtu = 64; in hci_cc_read_buffer_size()
678 hdev->sco_pkts = 8; in hci_cc_read_buffer_size()
681 hdev->acl_cnt = hdev->acl_pkts; in hci_cc_read_buffer_size()
682 hdev->sco_cnt = hdev->sco_pkts; in hci_cc_read_buffer_size()
684 BT_DBG("%s acl mtu %d:%d sco mtu %d:%d", hdev->name, hdev->acl_mtu, in hci_cc_read_buffer_size()
685 hdev->acl_pkts, hdev->sco_mtu, hdev->sco_pkts); in hci_cc_read_buffer_size()
688 static void hci_cc_read_bd_addr(struct hci_dev *hdev, struct sk_buff *skb) in hci_cc_read_bd_addr() argument
692 BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); in hci_cc_read_bd_addr()
697 if (test_bit(HCI_INIT, &hdev->flags)) in hci_cc_read_bd_addr()
698 bacpy(&hdev->bdaddr, &rp->bdaddr); in hci_cc_read_bd_addr()
700 if (hci_dev_test_flag(hdev, HCI_SETUP)) in hci_cc_read_bd_addr()
701 bacpy(&hdev->setup_addr, &rp->bdaddr); in hci_cc_read_bd_addr()
704 static void hci_cc_read_page_scan_activity(struct hci_dev *hdev, in hci_cc_read_page_scan_activity() argument
709 BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); in hci_cc_read_page_scan_activity()
714 if (test_bit(HCI_INIT, &hdev->flags)) { in hci_cc_read_page_scan_activity()
715 hdev->page_scan_interval = __le16_to_cpu(rp->interval); in hci_cc_read_page_scan_activity()
716 hdev->page_scan_window = __le16_to_cpu(rp->window); in hci_cc_read_page_scan_activity()
720 static void hci_cc_write_page_scan_activity(struct hci_dev *hdev, in hci_cc_write_page_scan_activity() argument
726 BT_DBG("%s status 0x%2.2x", hdev->name, status); in hci_cc_write_page_scan_activity()
731 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_PAGE_SCAN_ACTIVITY); in hci_cc_write_page_scan_activity()
735 hdev->page_scan_interval = __le16_to_cpu(sent->interval); in hci_cc_write_page_scan_activity()
736 hdev->page_scan_window = __le16_to_cpu(sent->window); in hci_cc_write_page_scan_activity()
739 static void hci_cc_read_page_scan_type(struct hci_dev *hdev, in hci_cc_read_page_scan_type() argument
744 BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); in hci_cc_read_page_scan_type()
749 if (test_bit(HCI_INIT, &hdev->flags)) in hci_cc_read_page_scan_type()
750 hdev->page_scan_type = rp->type; in hci_cc_read_page_scan_type()
753 static void hci_cc_write_page_scan_type(struct hci_dev *hdev, in hci_cc_write_page_scan_type() argument
759 BT_DBG("%s status 0x%2.2x", hdev->name, status); in hci_cc_write_page_scan_type()
764 type = hci_sent_cmd_data(hdev, HCI_OP_WRITE_PAGE_SCAN_TYPE); in hci_cc_write_page_scan_type()
766 hdev->page_scan_type = *type; in hci_cc_write_page_scan_type()
769 static void hci_cc_read_data_block_size(struct hci_dev *hdev, in hci_cc_read_data_block_size() argument
774 BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); in hci_cc_read_data_block_size()
779 hdev->block_mtu = __le16_to_cpu(rp->max_acl_len); in hci_cc_read_data_block_size()
780 hdev->block_len = __le16_to_cpu(rp->block_len); in hci_cc_read_data_block_size()
781 hdev->num_blocks = __le16_to_cpu(rp->num_blocks); in hci_cc_read_data_block_size()
783 hdev->block_cnt = hdev->num_blocks; in hci_cc_read_data_block_size()
785 BT_DBG("%s blk mtu %d cnt %d len %d", hdev->name, hdev->block_mtu, in hci_cc_read_data_block_size()
786 hdev->block_cnt, hdev->block_len); in hci_cc_read_data_block_size()
789 static void hci_cc_read_clock(struct hci_dev *hdev, struct sk_buff *skb) in hci_cc_read_clock() argument
795 BT_DBG("%s", hdev->name); in hci_cc_read_clock()
803 hci_dev_lock(hdev); in hci_cc_read_clock()
805 cp = hci_sent_cmd_data(hdev, HCI_OP_READ_CLOCK); in hci_cc_read_clock()
810 hdev->clock = le32_to_cpu(rp->clock); in hci_cc_read_clock()
814 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_clock()
821 hci_dev_unlock(hdev); in hci_cc_read_clock()
824 static void hci_cc_read_local_amp_info(struct hci_dev *hdev, in hci_cc_read_local_amp_info() argument
829 BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); in hci_cc_read_local_amp_info()
834 hdev->amp_status = rp->amp_status; in hci_cc_read_local_amp_info()
835 hdev->amp_total_bw = __le32_to_cpu(rp->total_bw); in hci_cc_read_local_amp_info()
836 hdev->amp_max_bw = __le32_to_cpu(rp->max_bw); in hci_cc_read_local_amp_info()
837 hdev->amp_min_latency = __le32_to_cpu(rp->min_latency); in hci_cc_read_local_amp_info()
838 hdev->amp_max_pdu = __le32_to_cpu(rp->max_pdu); in hci_cc_read_local_amp_info()
839 hdev->amp_type = rp->amp_type; in hci_cc_read_local_amp_info()
840 hdev->amp_pal_cap = __le16_to_cpu(rp->pal_cap); in hci_cc_read_local_amp_info()
841 hdev->amp_assoc_size = __le16_to_cpu(rp->max_assoc_size); in hci_cc_read_local_amp_info()
842 hdev->amp_be_flush_to = __le32_to_cpu(rp->be_flush_to); in hci_cc_read_local_amp_info()
843 hdev->amp_max_flush_to = __le32_to_cpu(rp->max_flush_to); in hci_cc_read_local_amp_info()
846 static void hci_cc_read_inq_rsp_tx_power(struct hci_dev *hdev, in hci_cc_read_inq_rsp_tx_power() argument
851 BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); in hci_cc_read_inq_rsp_tx_power()
856 hdev->inq_tx_power = rp->tx_power; in hci_cc_read_inq_rsp_tx_power()
859 static void hci_cc_pin_code_reply(struct hci_dev *hdev, struct sk_buff *skb) in hci_cc_pin_code_reply() argument
865 BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); in hci_cc_pin_code_reply()
867 hci_dev_lock(hdev); in hci_cc_pin_code_reply()
869 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_cc_pin_code_reply()
870 mgmt_pin_code_reply_complete(hdev, &rp->bdaddr, rp->status); in hci_cc_pin_code_reply()
875 cp = hci_sent_cmd_data(hdev, HCI_OP_PIN_CODE_REPLY); in hci_cc_pin_code_reply()
879 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cc_pin_code_reply()
884 hci_dev_unlock(hdev); in hci_cc_pin_code_reply()
887 static void hci_cc_pin_code_neg_reply(struct hci_dev *hdev, struct sk_buff *skb) in hci_cc_pin_code_neg_reply() argument
891 BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); in hci_cc_pin_code_neg_reply()
893 hci_dev_lock(hdev); in hci_cc_pin_code_neg_reply()
895 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_cc_pin_code_neg_reply()
896 mgmt_pin_code_neg_reply_complete(hdev, &rp->bdaddr, in hci_cc_pin_code_neg_reply()
899 hci_dev_unlock(hdev); in hci_cc_pin_code_neg_reply()
902 static void hci_cc_le_read_buffer_size(struct hci_dev *hdev, in hci_cc_le_read_buffer_size() argument
907 BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); in hci_cc_le_read_buffer_size()
912 hdev->le_mtu = __le16_to_cpu(rp->le_mtu); in hci_cc_le_read_buffer_size()
913 hdev->le_pkts = rp->le_max_pkt; in hci_cc_le_read_buffer_size()
915 hdev->le_cnt = hdev->le_pkts; in hci_cc_le_read_buffer_size()
917 BT_DBG("%s le mtu %d:%d", hdev->name, hdev->le_mtu, hdev->le_pkts); in hci_cc_le_read_buffer_size()
920 static void hci_cc_le_read_local_features(struct hci_dev *hdev, in hci_cc_le_read_local_features() argument
925 BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); in hci_cc_le_read_local_features()
930 memcpy(hdev->le_features, rp->features, 8); in hci_cc_le_read_local_features()
933 static void hci_cc_le_read_adv_tx_power(struct hci_dev *hdev, in hci_cc_le_read_adv_tx_power() argument
938 BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); in hci_cc_le_read_adv_tx_power()
943 hdev->adv_tx_power = rp->tx_power; in hci_cc_le_read_adv_tx_power()
946 static void hci_cc_user_confirm_reply(struct hci_dev *hdev, struct sk_buff *skb) in hci_cc_user_confirm_reply() argument
950 BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); in hci_cc_user_confirm_reply()
952 hci_dev_lock(hdev); in hci_cc_user_confirm_reply()
954 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_cc_user_confirm_reply()
955 mgmt_user_confirm_reply_complete(hdev, &rp->bdaddr, ACL_LINK, 0, in hci_cc_user_confirm_reply()
958 hci_dev_unlock(hdev); in hci_cc_user_confirm_reply()
961 static void hci_cc_user_confirm_neg_reply(struct hci_dev *hdev, in hci_cc_user_confirm_neg_reply() argument
966 BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); in hci_cc_user_confirm_neg_reply()
968 hci_dev_lock(hdev); in hci_cc_user_confirm_neg_reply()
970 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_cc_user_confirm_neg_reply()
971 mgmt_user_confirm_neg_reply_complete(hdev, &rp->bdaddr, in hci_cc_user_confirm_neg_reply()
974 hci_dev_unlock(hdev); in hci_cc_user_confirm_neg_reply()
977 static void hci_cc_user_passkey_reply(struct hci_dev *hdev, struct sk_buff *skb) in hci_cc_user_passkey_reply() argument
981 BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); in hci_cc_user_passkey_reply()
983 hci_dev_lock(hdev); in hci_cc_user_passkey_reply()
985 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_cc_user_passkey_reply()
986 mgmt_user_passkey_reply_complete(hdev, &rp->bdaddr, ACL_LINK, in hci_cc_user_passkey_reply()
989 hci_dev_unlock(hdev); in hci_cc_user_passkey_reply()
992 static void hci_cc_user_passkey_neg_reply(struct hci_dev *hdev, in hci_cc_user_passkey_neg_reply() argument
997 BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); in hci_cc_user_passkey_neg_reply()
999 hci_dev_lock(hdev); in hci_cc_user_passkey_neg_reply()
1001 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_cc_user_passkey_neg_reply()
1002 mgmt_user_passkey_neg_reply_complete(hdev, &rp->bdaddr, in hci_cc_user_passkey_neg_reply()
1005 hci_dev_unlock(hdev); in hci_cc_user_passkey_neg_reply()
1008 static void hci_cc_read_local_oob_data(struct hci_dev *hdev, in hci_cc_read_local_oob_data() argument
1013 BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); in hci_cc_read_local_oob_data()
1016 static void hci_cc_read_local_oob_ext_data(struct hci_dev *hdev, in hci_cc_read_local_oob_ext_data() argument
1021 BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); in hci_cc_read_local_oob_ext_data()
1024 static void hci_cc_le_set_random_addr(struct hci_dev *hdev, struct sk_buff *skb) in hci_cc_le_set_random_addr() argument
1029 BT_DBG("%s status 0x%2.2x", hdev->name, status); in hci_cc_le_set_random_addr()
1034 sent = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_RANDOM_ADDR); in hci_cc_le_set_random_addr()
1038 hci_dev_lock(hdev); in hci_cc_le_set_random_addr()
1040 bacpy(&hdev->random_addr, sent); in hci_cc_le_set_random_addr()
1042 hci_dev_unlock(hdev); in hci_cc_le_set_random_addr()
1045 static void hci_cc_le_set_default_phy(struct hci_dev *hdev, struct sk_buff *skb) in hci_cc_le_set_default_phy() argument
1050 BT_DBG("%s status 0x%2.2x", hdev->name, status); in hci_cc_le_set_default_phy()
1055 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_DEFAULT_PHY); in hci_cc_le_set_default_phy()
1059 hci_dev_lock(hdev); in hci_cc_le_set_default_phy()
1061 hdev->le_tx_def_phys = cp->tx_phys; in hci_cc_le_set_default_phy()
1062 hdev->le_rx_def_phys = cp->rx_phys; in hci_cc_le_set_default_phy()
1064 hci_dev_unlock(hdev); in hci_cc_le_set_default_phy()
1067 static void hci_cc_le_set_adv_set_random_addr(struct hci_dev *hdev, in hci_cc_le_set_adv_set_random_addr() argument
1077 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_ADV_SET_RAND_ADDR); in hci_cc_le_set_adv_set_random_addr()
1081 hci_dev_lock(hdev); in hci_cc_le_set_adv_set_random_addr()
1083 if (!hdev->cur_adv_instance) { in hci_cc_le_set_adv_set_random_addr()
1085 bacpy(&hdev->random_addr, &cp->bdaddr); in hci_cc_le_set_adv_set_random_addr()
1087 adv_instance = hci_find_adv_instance(hdev, in hci_cc_le_set_adv_set_random_addr()
1088 hdev->cur_adv_instance); in hci_cc_le_set_adv_set_random_addr()
1093 hci_dev_unlock(hdev); in hci_cc_le_set_adv_set_random_addr()
1096 static void hci_cc_le_set_adv_enable(struct hci_dev *hdev, struct sk_buff *skb) in hci_cc_le_set_adv_enable() argument
1100 BT_DBG("%s status 0x%2.2x", hdev->name, status); in hci_cc_le_set_adv_enable()
1105 sent = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_ADV_ENABLE); in hci_cc_le_set_adv_enable()
1109 hci_dev_lock(hdev); in hci_cc_le_set_adv_enable()
1117 hci_dev_set_flag(hdev, HCI_LE_ADV); in hci_cc_le_set_adv_enable()
1119 conn = hci_lookup_le_connect(hdev); in hci_cc_le_set_adv_enable()
1121 queue_delayed_work(hdev->workqueue, in hci_cc_le_set_adv_enable()
1125 hci_dev_clear_flag(hdev, HCI_LE_ADV); in hci_cc_le_set_adv_enable()
1128 hci_dev_unlock(hdev); in hci_cc_le_set_adv_enable()
1131 static void hci_cc_le_set_ext_adv_enable(struct hci_dev *hdev, in hci_cc_le_set_ext_adv_enable() argument
1137 BT_DBG("%s status 0x%2.2x", hdev->name, status); in hci_cc_le_set_ext_adv_enable()
1142 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_EXT_ADV_ENABLE); in hci_cc_le_set_ext_adv_enable()
1146 hci_dev_lock(hdev); in hci_cc_le_set_ext_adv_enable()
1151 hci_dev_set_flag(hdev, HCI_LE_ADV); in hci_cc_le_set_ext_adv_enable()
1153 conn = hci_lookup_le_connect(hdev); in hci_cc_le_set_ext_adv_enable()
1155 queue_delayed_work(hdev->workqueue, in hci_cc_le_set_ext_adv_enable()
1159 hci_dev_clear_flag(hdev, HCI_LE_ADV); in hci_cc_le_set_ext_adv_enable()
1162 hci_dev_unlock(hdev); in hci_cc_le_set_ext_adv_enable()
1165 static void hci_cc_le_set_scan_param(struct hci_dev *hdev, struct sk_buff *skb) in hci_cc_le_set_scan_param() argument
1170 BT_DBG("%s status 0x%2.2x", hdev->name, status); in hci_cc_le_set_scan_param()
1175 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_SCAN_PARAM); in hci_cc_le_set_scan_param()
1179 hci_dev_lock(hdev); in hci_cc_le_set_scan_param()
1181 hdev->le_scan_type = cp->type; in hci_cc_le_set_scan_param()
1183 hci_dev_unlock(hdev); in hci_cc_le_set_scan_param()
1186 static void hci_cc_le_set_ext_scan_param(struct hci_dev *hdev, in hci_cc_le_set_ext_scan_param() argument
1193 BT_DBG("%s status 0x%2.2x", hdev->name, status); in hci_cc_le_set_ext_scan_param()
1198 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_EXT_SCAN_PARAMS); in hci_cc_le_set_ext_scan_param()
1204 hci_dev_lock(hdev); in hci_cc_le_set_ext_scan_param()
1206 hdev->le_scan_type = phy_param->type; in hci_cc_le_set_ext_scan_param()
1208 hci_dev_unlock(hdev); in hci_cc_le_set_ext_scan_param()
1211 static bool has_pending_adv_report(struct hci_dev *hdev) in has_pending_adv_report() argument
1213 struct discovery_state *d = &hdev->discovery; in has_pending_adv_report()
1218 static void clear_pending_adv_report(struct hci_dev *hdev) in clear_pending_adv_report() argument
1220 struct discovery_state *d = &hdev->discovery; in clear_pending_adv_report()
1226 static void store_pending_adv_report(struct hci_dev *hdev, bdaddr_t *bdaddr, in store_pending_adv_report() argument
1230 struct discovery_state *d = &hdev->discovery; in store_pending_adv_report()
1240 static void le_set_scan_enable_complete(struct hci_dev *hdev, u8 enable) in le_set_scan_enable_complete() argument
1242 hci_dev_lock(hdev); in le_set_scan_enable_complete()
1246 hci_dev_set_flag(hdev, HCI_LE_SCAN); in le_set_scan_enable_complete()
1247 if (hdev->le_scan_type == LE_SCAN_ACTIVE) in le_set_scan_enable_complete()
1248 clear_pending_adv_report(hdev); in le_set_scan_enable_complete()
1256 if (has_pending_adv_report(hdev)) { in le_set_scan_enable_complete()
1257 struct discovery_state *d = &hdev->discovery; in le_set_scan_enable_complete()
1259 mgmt_device_found(hdev, &d->last_adv_addr, LE_LINK, in le_set_scan_enable_complete()
1269 cancel_delayed_work(&hdev->le_scan_disable); in le_set_scan_enable_complete()
1271 hci_dev_clear_flag(hdev, HCI_LE_SCAN); in le_set_scan_enable_complete()
1280 if (hci_dev_test_and_clear_flag(hdev, HCI_LE_SCAN_INTERRUPTED)) in le_set_scan_enable_complete()
1281 hci_discovery_set_state(hdev, DISCOVERY_STOPPED); in le_set_scan_enable_complete()
1282 else if (!hci_dev_test_flag(hdev, HCI_LE_ADV) && in le_set_scan_enable_complete()
1283 hdev->discovery.state == DISCOVERY_FINDING) in le_set_scan_enable_complete()
1284 hci_req_reenable_advertising(hdev); in le_set_scan_enable_complete()
1289 bt_dev_err(hdev, "use of reserved LE_Scan_Enable param %d", in le_set_scan_enable_complete()
1294 hci_dev_unlock(hdev); in le_set_scan_enable_complete()
1297 static void hci_cc_le_set_scan_enable(struct hci_dev *hdev, in hci_cc_le_set_scan_enable() argument
1303 BT_DBG("%s status 0x%2.2x", hdev->name, status); in hci_cc_le_set_scan_enable()
1308 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_SCAN_ENABLE); in hci_cc_le_set_scan_enable()
1312 le_set_scan_enable_complete(hdev, cp->enable); in hci_cc_le_set_scan_enable()
1315 static void hci_cc_le_set_ext_scan_enable(struct hci_dev *hdev, in hci_cc_le_set_ext_scan_enable() argument
1321 BT_DBG("%s status 0x%2.2x", hdev->name, status); in hci_cc_le_set_ext_scan_enable()
1326 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_EXT_SCAN_ENABLE); in hci_cc_le_set_ext_scan_enable()
1330 le_set_scan_enable_complete(hdev, cp->enable); in hci_cc_le_set_ext_scan_enable()
1333 static void hci_cc_le_read_num_adv_sets(struct hci_dev *hdev, in hci_cc_le_read_num_adv_sets() argument
1338 BT_DBG("%s status 0x%2.2x No of Adv sets %u", hdev->name, rp->status, in hci_cc_le_read_num_adv_sets()
1344 hdev->le_num_of_adv_sets = rp->num_of_sets; in hci_cc_le_read_num_adv_sets()
1347 static void hci_cc_le_read_white_list_size(struct hci_dev *hdev, in hci_cc_le_read_white_list_size() argument
1352 BT_DBG("%s status 0x%2.2x size %u", hdev->name, rp->status, rp->size); in hci_cc_le_read_white_list_size()
1357 hdev->le_white_list_size = rp->size; in hci_cc_le_read_white_list_size()
1360 static void hci_cc_le_clear_white_list(struct hci_dev *hdev, in hci_cc_le_clear_white_list() argument
1365 BT_DBG("%s status 0x%2.2x", hdev->name, status); in hci_cc_le_clear_white_list()
1370 hci_bdaddr_list_clear(&hdev->le_white_list); in hci_cc_le_clear_white_list()
1373 static void hci_cc_le_add_to_white_list(struct hci_dev *hdev, in hci_cc_le_add_to_white_list() argument
1379 BT_DBG("%s status 0x%2.2x", hdev->name, status); in hci_cc_le_add_to_white_list()
1384 sent = hci_sent_cmd_data(hdev, HCI_OP_LE_ADD_TO_WHITE_LIST); in hci_cc_le_add_to_white_list()
1388 hci_bdaddr_list_add(&hdev->le_white_list, &sent->bdaddr, in hci_cc_le_add_to_white_list()
1392 static void hci_cc_le_del_from_white_list(struct hci_dev *hdev, in hci_cc_le_del_from_white_list() argument
1398 BT_DBG("%s status 0x%2.2x", hdev->name, status); in hci_cc_le_del_from_white_list()
1403 sent = hci_sent_cmd_data(hdev, HCI_OP_LE_DEL_FROM_WHITE_LIST); in hci_cc_le_del_from_white_list()
1407 hci_bdaddr_list_del(&hdev->le_white_list, &sent->bdaddr, in hci_cc_le_del_from_white_list()
1411 static void hci_cc_le_read_supported_states(struct hci_dev *hdev, in hci_cc_le_read_supported_states() argument
1416 BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); in hci_cc_le_read_supported_states()
1421 memcpy(hdev->le_states, rp->le_states, 8); in hci_cc_le_read_supported_states()
1424 static void hci_cc_le_read_def_data_len(struct hci_dev *hdev, in hci_cc_le_read_def_data_len() argument
1429 BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); in hci_cc_le_read_def_data_len()
1434 hdev->le_def_tx_len = le16_to_cpu(rp->tx_len); in hci_cc_le_read_def_data_len()
1435 hdev->le_def_tx_time = le16_to_cpu(rp->tx_time); in hci_cc_le_read_def_data_len()
1438 static void hci_cc_le_write_def_data_len(struct hci_dev *hdev, in hci_cc_le_write_def_data_len() argument
1444 BT_DBG("%s status 0x%2.2x", hdev->name, status); in hci_cc_le_write_def_data_len()
1449 sent = hci_sent_cmd_data(hdev, HCI_OP_LE_WRITE_DEF_DATA_LEN); in hci_cc_le_write_def_data_len()
1453 hdev->le_def_tx_len = le16_to_cpu(sent->tx_len); in hci_cc_le_write_def_data_len()
1454 hdev->le_def_tx_time = le16_to_cpu(sent->tx_time); in hci_cc_le_write_def_data_len()
1457 static void hci_cc_le_clear_resolv_list(struct hci_dev *hdev, in hci_cc_le_clear_resolv_list() argument
1462 BT_DBG("%s status 0x%2.2x", hdev->name, status); in hci_cc_le_clear_resolv_list()
1467 hci_bdaddr_list_clear(&hdev->le_resolv_list); in hci_cc_le_clear_resolv_list()
1470 static void hci_cc_le_read_resolv_list_size(struct hci_dev *hdev, in hci_cc_le_read_resolv_list_size() argument
1475 BT_DBG("%s status 0x%2.2x size %u", hdev->name, rp->status, rp->size); in hci_cc_le_read_resolv_list_size()
1480 hdev->le_resolv_list_size = rp->size; in hci_cc_le_read_resolv_list_size()
1483 static void hci_cc_le_set_addr_resolution_enable(struct hci_dev *hdev, in hci_cc_le_set_addr_resolution_enable() argument
1488 BT_DBG("%s status 0x%2.2x", hdev->name, status); in hci_cc_le_set_addr_resolution_enable()
1493 sent = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE); in hci_cc_le_set_addr_resolution_enable()
1497 hci_dev_lock(hdev); in hci_cc_le_set_addr_resolution_enable()
1500 hci_dev_set_flag(hdev, HCI_LL_RPA_RESOLUTION); in hci_cc_le_set_addr_resolution_enable()
1502 hci_dev_clear_flag(hdev, HCI_LL_RPA_RESOLUTION); in hci_cc_le_set_addr_resolution_enable()
1504 hci_dev_unlock(hdev); in hci_cc_le_set_addr_resolution_enable()
1507 static void hci_cc_le_read_max_data_len(struct hci_dev *hdev, in hci_cc_le_read_max_data_len() argument
1512 BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); in hci_cc_le_read_max_data_len()
1517 hdev->le_max_tx_len = le16_to_cpu(rp->tx_len); in hci_cc_le_read_max_data_len()
1518 hdev->le_max_tx_time = le16_to_cpu(rp->tx_time); in hci_cc_le_read_max_data_len()
1519 hdev->le_max_rx_len = le16_to_cpu(rp->rx_len); in hci_cc_le_read_max_data_len()
1520 hdev->le_max_rx_time = le16_to_cpu(rp->rx_time); in hci_cc_le_read_max_data_len()
1523 static void hci_cc_write_le_host_supported(struct hci_dev *hdev, in hci_cc_write_le_host_supported() argument
1529 BT_DBG("%s status 0x%2.2x", hdev->name, status); in hci_cc_write_le_host_supported()
1534 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_LE_HOST_SUPPORTED); in hci_cc_write_le_host_supported()
1538 hci_dev_lock(hdev); in hci_cc_write_le_host_supported()
1541 hdev->features[1][0] |= LMP_HOST_LE; in hci_cc_write_le_host_supported()
1542 hci_dev_set_flag(hdev, HCI_LE_ENABLED); in hci_cc_write_le_host_supported()
1544 hdev->features[1][0] &= ~LMP_HOST_LE; in hci_cc_write_le_host_supported()
1545 hci_dev_clear_flag(hdev, HCI_LE_ENABLED); in hci_cc_write_le_host_supported()
1546 hci_dev_clear_flag(hdev, HCI_ADVERTISING); in hci_cc_write_le_host_supported()
1550 hdev->features[1][0] |= LMP_HOST_LE_BREDR; in hci_cc_write_le_host_supported()
1552 hdev->features[1][0] &= ~LMP_HOST_LE_BREDR; in hci_cc_write_le_host_supported()
1554 hci_dev_unlock(hdev); in hci_cc_write_le_host_supported()
1557 static void hci_cc_set_adv_param(struct hci_dev *hdev, struct sk_buff *skb) in hci_cc_set_adv_param() argument
1562 BT_DBG("%s status 0x%2.2x", hdev->name, status); in hci_cc_set_adv_param()
1567 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_ADV_PARAM); in hci_cc_set_adv_param()
1571 hci_dev_lock(hdev); in hci_cc_set_adv_param()
1572 hdev->adv_addr_type = cp->own_address_type; in hci_cc_set_adv_param()
1573 hci_dev_unlock(hdev); in hci_cc_set_adv_param()
1576 static void hci_cc_set_ext_adv_param(struct hci_dev *hdev, struct sk_buff *skb) in hci_cc_set_ext_adv_param() argument
1582 BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); in hci_cc_set_ext_adv_param()
1587 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_EXT_ADV_PARAMS); in hci_cc_set_ext_adv_param()
1591 hci_dev_lock(hdev); in hci_cc_set_ext_adv_param()
1592 hdev->adv_addr_type = cp->own_addr_type; in hci_cc_set_ext_adv_param()
1593 if (!hdev->cur_adv_instance) { in hci_cc_set_ext_adv_param()
1595 hdev->adv_tx_power = rp->tx_power; in hci_cc_set_ext_adv_param()
1597 adv_instance = hci_find_adv_instance(hdev, in hci_cc_set_ext_adv_param()
1598 hdev->cur_adv_instance); in hci_cc_set_ext_adv_param()
1603 hci_req_update_adv_data(hdev, hdev->cur_adv_instance); in hci_cc_set_ext_adv_param()
1604 hci_dev_unlock(hdev); in hci_cc_set_ext_adv_param()
1607 static void hci_cc_read_rssi(struct hci_dev *hdev, struct sk_buff *skb) in hci_cc_read_rssi() argument
1612 BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); in hci_cc_read_rssi()
1617 hci_dev_lock(hdev); in hci_cc_read_rssi()
1619 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_rssi()
1623 hci_dev_unlock(hdev); in hci_cc_read_rssi()
1626 static void hci_cc_read_tx_power(struct hci_dev *hdev, struct sk_buff *skb) in hci_cc_read_tx_power() argument
1632 BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); in hci_cc_read_tx_power()
1637 sent = hci_sent_cmd_data(hdev, HCI_OP_READ_TX_POWER); in hci_cc_read_tx_power()
1641 hci_dev_lock(hdev); in hci_cc_read_tx_power()
1643 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); in hci_cc_read_tx_power()
1657 hci_dev_unlock(hdev); in hci_cc_read_tx_power()
1660 static void hci_cc_write_ssp_debug_mode(struct hci_dev *hdev, struct sk_buff *skb) in hci_cc_write_ssp_debug_mode() argument
1665 BT_DBG("%s status 0x%2.2x", hdev->name, status); in hci_cc_write_ssp_debug_mode()
1670 mode = hci_sent_cmd_data(hdev, HCI_OP_WRITE_SSP_DEBUG_MODE); in hci_cc_write_ssp_debug_mode()
1672 hdev->ssp_debug_mode = *mode; in hci_cc_write_ssp_debug_mode()
1675 static void hci_cs_inquiry(struct hci_dev *hdev, __u8 status) in hci_cs_inquiry() argument
1677 BT_DBG("%s status 0x%2.2x", hdev->name, status); in hci_cs_inquiry()
1680 hci_conn_check_pending(hdev); in hci_cs_inquiry()
1684 set_bit(HCI_INQUIRY, &hdev->flags); in hci_cs_inquiry()
1687 static void hci_cs_create_conn(struct hci_dev *hdev, __u8 status) in hci_cs_create_conn() argument
1692 BT_DBG("%s status 0x%2.2x", hdev->name, status); in hci_cs_create_conn()
1694 cp = hci_sent_cmd_data(hdev, HCI_OP_CREATE_CONN); in hci_cs_create_conn()
1698 hci_dev_lock(hdev); in hci_cs_create_conn()
1700 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cs_create_conn()
1702 BT_DBG("%s bdaddr %pMR hcon %p", hdev->name, &cp->bdaddr, conn); in hci_cs_create_conn()
1715 conn = hci_conn_add(hdev, ACL_LINK, &cp->bdaddr, in hci_cs_create_conn()
1718 bt_dev_err(hdev, "no memory for new connection"); in hci_cs_create_conn()
1722 hci_dev_unlock(hdev); in hci_cs_create_conn()
1725 static void hci_cs_add_sco(struct hci_dev *hdev, __u8 status) in hci_cs_add_sco() argument
1731 BT_DBG("%s status 0x%2.2x", hdev->name, status); in hci_cs_add_sco()
1736 cp = hci_sent_cmd_data(hdev, HCI_OP_ADD_SCO); in hci_cs_add_sco()
1742 BT_DBG("%s handle 0x%4.4x", hdev->name, handle); in hci_cs_add_sco()
1744 hci_dev_lock(hdev); in hci_cs_add_sco()
1746 acl = hci_conn_hash_lookup_handle(hdev, handle); in hci_cs_add_sco()
1757 hci_dev_unlock(hdev); in hci_cs_add_sco()
1760 static void hci_cs_auth_requested(struct hci_dev *hdev, __u8 status) in hci_cs_auth_requested() argument
1765 BT_DBG("%s status 0x%2.2x", hdev->name, status); in hci_cs_auth_requested()
1770 cp = hci_sent_cmd_data(hdev, HCI_OP_AUTH_REQUESTED); in hci_cs_auth_requested()
1774 hci_dev_lock(hdev); in hci_cs_auth_requested()
1776 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_auth_requested()
1784 hci_dev_unlock(hdev); in hci_cs_auth_requested()
1787 static void hci_cs_set_conn_encrypt(struct hci_dev *hdev, __u8 status) in hci_cs_set_conn_encrypt() argument
1792 BT_DBG("%s status 0x%2.2x", hdev->name, status); in hci_cs_set_conn_encrypt()
1797 cp = hci_sent_cmd_data(hdev, HCI_OP_SET_CONN_ENCRYPT); in hci_cs_set_conn_encrypt()
1801 hci_dev_lock(hdev); in hci_cs_set_conn_encrypt()
1803 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_set_conn_encrypt()
1811 hci_dev_unlock(hdev); in hci_cs_set_conn_encrypt()
1814 static int hci_outgoing_auth_needed(struct hci_dev *hdev, in hci_outgoing_auth_needed() argument
1836 static int hci_resolve_name(struct hci_dev *hdev, in hci_resolve_name() argument
1848 return hci_send_cmd(hdev, HCI_OP_REMOTE_NAME_REQ, sizeof(cp), &cp); in hci_resolve_name()
1851 static bool hci_resolve_next_name(struct hci_dev *hdev) in hci_resolve_next_name() argument
1853 struct discovery_state *discov = &hdev->discovery; in hci_resolve_next_name()
1859 e = hci_inquiry_cache_lookup_resolve(hdev, BDADDR_ANY, NAME_NEEDED); in hci_resolve_next_name()
1863 if (hci_resolve_name(hdev, e) == 0) { in hci_resolve_next_name()
1871 static void hci_check_pending_name(struct hci_dev *hdev, struct hci_conn *conn, in hci_check_pending_name() argument
1874 struct discovery_state *discov = &hdev->discovery; in hci_check_pending_name()
1885 mgmt_device_connected(hdev, conn, 0, name, name_len); in hci_check_pending_name()
1896 e = hci_inquiry_cache_lookup_resolve(hdev, bdaddr, NAME_PENDING); in hci_check_pending_name()
1907 mgmt_remote_name(hdev, bdaddr, ACL_LINK, 0x00, in hci_check_pending_name()
1913 if (hci_resolve_next_name(hdev)) in hci_check_pending_name()
1917 hci_discovery_set_state(hdev, DISCOVERY_STOPPED); in hci_check_pending_name()
1920 static void hci_cs_remote_name_req(struct hci_dev *hdev, __u8 status) in hci_cs_remote_name_req() argument
1925 BT_DBG("%s status 0x%2.2x", hdev->name, status); in hci_cs_remote_name_req()
1932 cp = hci_sent_cmd_data(hdev, HCI_OP_REMOTE_NAME_REQ); in hci_cs_remote_name_req()
1936 hci_dev_lock(hdev); in hci_cs_remote_name_req()
1938 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cs_remote_name_req()
1940 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_cs_remote_name_req()
1941 hci_check_pending_name(hdev, conn, &cp->bdaddr, NULL, 0); in hci_cs_remote_name_req()
1946 if (!hci_outgoing_auth_needed(hdev, conn)) in hci_cs_remote_name_req()
1955 hci_send_cmd(hdev, HCI_OP_AUTH_REQUESTED, in hci_cs_remote_name_req()
1960 hci_dev_unlock(hdev); in hci_cs_remote_name_req()
1963 static void hci_cs_read_remote_features(struct hci_dev *hdev, __u8 status) in hci_cs_read_remote_features() argument
1968 BT_DBG("%s status 0x%2.2x", hdev->name, status); in hci_cs_read_remote_features()
1973 cp = hci_sent_cmd_data(hdev, HCI_OP_READ_REMOTE_FEATURES); in hci_cs_read_remote_features()
1977 hci_dev_lock(hdev); in hci_cs_read_remote_features()
1979 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_read_remote_features()
1987 hci_dev_unlock(hdev); in hci_cs_read_remote_features()
1990 static void hci_cs_read_remote_ext_features(struct hci_dev *hdev, __u8 status) in hci_cs_read_remote_ext_features() argument
1995 BT_DBG("%s status 0x%2.2x", hdev->name, status); in hci_cs_read_remote_ext_features()
2000 cp = hci_sent_cmd_data(hdev, HCI_OP_READ_REMOTE_EXT_FEATURES); in hci_cs_read_remote_ext_features()
2004 hci_dev_lock(hdev); in hci_cs_read_remote_ext_features()
2006 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_read_remote_ext_features()
2014 hci_dev_unlock(hdev); in hci_cs_read_remote_ext_features()
2017 static void hci_cs_setup_sync_conn(struct hci_dev *hdev, __u8 status) in hci_cs_setup_sync_conn() argument
2023 BT_DBG("%s status 0x%2.2x", hdev->name, status); in hci_cs_setup_sync_conn()
2028 cp = hci_sent_cmd_data(hdev, HCI_OP_SETUP_SYNC_CONN); in hci_cs_setup_sync_conn()
2034 BT_DBG("%s handle 0x%4.4x", hdev->name, handle); in hci_cs_setup_sync_conn()
2036 hci_dev_lock(hdev); in hci_cs_setup_sync_conn()
2038 acl = hci_conn_hash_lookup_handle(hdev, handle); in hci_cs_setup_sync_conn()
2049 hci_dev_unlock(hdev); in hci_cs_setup_sync_conn()
2052 static void hci_cs_sniff_mode(struct hci_dev *hdev, __u8 status) in hci_cs_sniff_mode() argument
2057 BT_DBG("%s status 0x%2.2x", hdev->name, status); in hci_cs_sniff_mode()
2062 cp = hci_sent_cmd_data(hdev, HCI_OP_SNIFF_MODE); in hci_cs_sniff_mode()
2066 hci_dev_lock(hdev); in hci_cs_sniff_mode()
2068 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_sniff_mode()
2076 hci_dev_unlock(hdev); in hci_cs_sniff_mode()
2079 static void hci_cs_exit_sniff_mode(struct hci_dev *hdev, __u8 status) in hci_cs_exit_sniff_mode() argument
2084 BT_DBG("%s status 0x%2.2x", hdev->name, status); in hci_cs_exit_sniff_mode()
2089 cp = hci_sent_cmd_data(hdev, HCI_OP_EXIT_SNIFF_MODE); in hci_cs_exit_sniff_mode()
2093 hci_dev_lock(hdev); in hci_cs_exit_sniff_mode()
2095 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_exit_sniff_mode()
2103 hci_dev_unlock(hdev); in hci_cs_exit_sniff_mode()
2106 static void hci_cs_disconnect(struct hci_dev *hdev, u8 status) in hci_cs_disconnect() argument
2114 cp = hci_sent_cmd_data(hdev, HCI_OP_DISCONNECT); in hci_cs_disconnect()
2118 hci_dev_lock(hdev); in hci_cs_disconnect()
2120 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_disconnect()
2122 mgmt_disconnect_failed(hdev, &conn->dst, conn->type, in hci_cs_disconnect()
2125 hci_dev_unlock(hdev); in hci_cs_disconnect()
2128 static void cs_le_create_conn(struct hci_dev *hdev, bdaddr_t *peer_addr, in cs_le_create_conn() argument
2134 conn = hci_conn_hash_lookup_le(hdev, peer_addr, in cs_le_create_conn()
2145 bacpy(&conn->init_addr, &hdev->random_addr); in cs_le_create_conn()
2147 bacpy(&conn->init_addr, &hdev->bdaddr); in cs_le_create_conn()
2158 queue_delayed_work(conn->hdev->workqueue, in cs_le_create_conn()
2163 static void hci_cs_le_create_conn(struct hci_dev *hdev, u8 status) in hci_cs_le_create_conn() argument
2167 BT_DBG("%s status 0x%2.2x", hdev->name, status); in hci_cs_le_create_conn()
2176 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_CREATE_CONN); in hci_cs_le_create_conn()
2180 hci_dev_lock(hdev); in hci_cs_le_create_conn()
2182 cs_le_create_conn(hdev, &cp->peer_addr, cp->peer_addr_type, in hci_cs_le_create_conn()
2185 hci_dev_unlock(hdev); in hci_cs_le_create_conn()
2188 static void hci_cs_le_ext_create_conn(struct hci_dev *hdev, u8 status) in hci_cs_le_ext_create_conn() argument
2192 BT_DBG("%s status 0x%2.2x", hdev->name, status); in hci_cs_le_ext_create_conn()
2201 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_EXT_CREATE_CONN); in hci_cs_le_ext_create_conn()
2205 hci_dev_lock(hdev); in hci_cs_le_ext_create_conn()
2207 cs_le_create_conn(hdev, &cp->peer_addr, cp->peer_addr_type, in hci_cs_le_ext_create_conn()
2210 hci_dev_unlock(hdev); in hci_cs_le_ext_create_conn()
2213 static void hci_cs_le_read_remote_features(struct hci_dev *hdev, u8 status) in hci_cs_le_read_remote_features() argument
2218 BT_DBG("%s status 0x%2.2x", hdev->name, status); in hci_cs_le_read_remote_features()
2223 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_READ_REMOTE_FEATURES); in hci_cs_le_read_remote_features()
2227 hci_dev_lock(hdev); in hci_cs_le_read_remote_features()
2229 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_le_read_remote_features()
2237 hci_dev_unlock(hdev); in hci_cs_le_read_remote_features()
2240 static void hci_cs_le_start_enc(struct hci_dev *hdev, u8 status) in hci_cs_le_start_enc() argument
2245 BT_DBG("%s status 0x%2.2x", hdev->name, status); in hci_cs_le_start_enc()
2250 hci_dev_lock(hdev); in hci_cs_le_start_enc()
2252 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_START_ENC); in hci_cs_le_start_enc()
2256 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); in hci_cs_le_start_enc()
2267 hci_dev_unlock(hdev); in hci_cs_le_start_enc()
2270 static void hci_cs_switch_role(struct hci_dev *hdev, u8 status) in hci_cs_switch_role() argument
2275 BT_DBG("%s status 0x%2.2x", hdev->name, status); in hci_cs_switch_role()
2280 cp = hci_sent_cmd_data(hdev, HCI_OP_SWITCH_ROLE); in hci_cs_switch_role()
2284 hci_dev_lock(hdev); in hci_cs_switch_role()
2286 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); in hci_cs_switch_role()
2290 hci_dev_unlock(hdev); in hci_cs_switch_role()
2293 static void hci_inquiry_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) in hci_inquiry_complete_evt() argument
2296 struct discovery_state *discov = &hdev->discovery; in hci_inquiry_complete_evt()
2299 BT_DBG("%s status 0x%2.2x", hdev->name, status); in hci_inquiry_complete_evt()
2301 hci_conn_check_pending(hdev); in hci_inquiry_complete_evt()
2303 if (!test_and_clear_bit(HCI_INQUIRY, &hdev->flags)) in hci_inquiry_complete_evt()
2307 wake_up_bit(&hdev->flags, HCI_INQUIRY); in hci_inquiry_complete_evt()
2309 if (!hci_dev_test_flag(hdev, HCI_MGMT)) in hci_inquiry_complete_evt()
2312 hci_dev_lock(hdev); in hci_inquiry_complete_evt()
2325 if (!hci_dev_test_flag(hdev, HCI_LE_SCAN) || in hci_inquiry_complete_evt()
2326 !test_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks)) in hci_inquiry_complete_evt()
2327 hci_discovery_set_state(hdev, DISCOVERY_STOPPED); in hci_inquiry_complete_evt()
2331 e = hci_inquiry_cache_lookup_resolve(hdev, BDADDR_ANY, NAME_NEEDED); in hci_inquiry_complete_evt()
2332 if (e && hci_resolve_name(hdev, e) == 0) { in hci_inquiry_complete_evt()
2334 hci_discovery_set_state(hdev, DISCOVERY_RESOLVING); in hci_inquiry_complete_evt()
2343 if (!hci_dev_test_flag(hdev, HCI_LE_SCAN) || in hci_inquiry_complete_evt()
2344 !test_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks)) in hci_inquiry_complete_evt()
2345 hci_discovery_set_state(hdev, DISCOVERY_STOPPED); in hci_inquiry_complete_evt()
2349 hci_dev_unlock(hdev); in hci_inquiry_complete_evt()
2352 static void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff *skb) in hci_inquiry_result_evt() argument
2358 BT_DBG("%s num_rsp %d", hdev->name, num_rsp); in hci_inquiry_result_evt()
2363 if (hci_dev_test_flag(hdev, HCI_PERIODIC_INQ)) in hci_inquiry_result_evt()
2366 hci_dev_lock(hdev); in hci_inquiry_result_evt()
2380 flags = hci_inquiry_cache_update(hdev, &data, false); in hci_inquiry_result_evt()
2382 mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, in hci_inquiry_result_evt()
2387 hci_dev_unlock(hdev); in hci_inquiry_result_evt()
2390 static void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) in hci_conn_complete_evt() argument
2395 BT_DBG("%s", hdev->name); in hci_conn_complete_evt()
2397 hci_dev_lock(hdev); in hci_conn_complete_evt()
2399 conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, &ev->bdaddr); in hci_conn_complete_evt()
2404 conn = hci_conn_hash_lookup_ba(hdev, ESCO_LINK, &ev->bdaddr); in hci_conn_complete_evt()
2419 !hci_find_link_key(hdev, &ev->bdaddr)) in hci_conn_complete_evt()
2429 if (test_bit(HCI_AUTH, &hdev->flags)) in hci_conn_complete_evt()
2432 if (test_bit(HCI_ENCRYPT, &hdev->flags)) in hci_conn_complete_evt()
2439 hci_send_cmd(hdev, HCI_OP_READ_REMOTE_FEATURES, in hci_conn_complete_evt()
2442 hci_req_update_scan(hdev); in hci_conn_complete_evt()
2446 if (!conn->out && hdev->hci_ver < BLUETOOTH_VER_2_0) { in hci_conn_complete_evt()
2450 hci_send_cmd(hdev, HCI_OP_CHANGE_CONN_PTYPE, sizeof(cp), in hci_conn_complete_evt()
2456 mgmt_connect_failed(hdev, &conn->dst, conn->type, in hci_conn_complete_evt()
2470 hci_dev_unlock(hdev); in hci_conn_complete_evt()
2472 hci_conn_check_pending(hdev); in hci_conn_complete_evt()
2475 static void hci_reject_conn(struct hci_dev *hdev, bdaddr_t *bdaddr) in hci_reject_conn() argument
2481 hci_send_cmd(hdev, HCI_OP_REJECT_CONN_REQ, sizeof(cp), &cp); in hci_reject_conn()
2484 static void hci_conn_request_evt(struct hci_dev *hdev, struct sk_buff *skb) in hci_conn_request_evt() argument
2487 int mask = hdev->link_mode; in hci_conn_request_evt()
2492 BT_DBG("%s bdaddr %pMR type 0x%x", hdev->name, &ev->bdaddr, in hci_conn_request_evt()
2495 mask |= hci_proto_connect_ind(hdev, &ev->bdaddr, ev->link_type, in hci_conn_request_evt()
2499 hci_reject_conn(hdev, &ev->bdaddr); in hci_conn_request_evt()
2503 if (hci_bdaddr_list_lookup(&hdev->blacklist, &ev->bdaddr, in hci_conn_request_evt()
2505 hci_reject_conn(hdev, &ev->bdaddr); in hci_conn_request_evt()
2513 if (hci_dev_test_flag(hdev, HCI_MGMT) && in hci_conn_request_evt()
2514 !hci_dev_test_flag(hdev, HCI_CONNECTABLE) && in hci_conn_request_evt()
2515 !hci_bdaddr_list_lookup(&hdev->whitelist, &ev->bdaddr, in hci_conn_request_evt()
2517 hci_reject_conn(hdev, &ev->bdaddr); in hci_conn_request_evt()
2523 hci_dev_lock(hdev); in hci_conn_request_evt()
2525 ie = hci_inquiry_cache_lookup(hdev, &ev->bdaddr); in hci_conn_request_evt()
2529 conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, in hci_conn_request_evt()
2532 conn = hci_conn_add(hdev, ev->link_type, &ev->bdaddr, in hci_conn_request_evt()
2535 bt_dev_err(hdev, "no memory for new connection"); in hci_conn_request_evt()
2536 hci_dev_unlock(hdev); in hci_conn_request_evt()
2543 hci_dev_unlock(hdev); in hci_conn_request_evt()
2546 (!(flags & HCI_PROTO_DEFER) && !lmp_esco_capable(hdev))) { in hci_conn_request_evt()
2552 if (lmp_rswitch_capable(hdev) && (mask & HCI_LM_MASTER)) in hci_conn_request_evt()
2557 hci_send_cmd(hdev, HCI_OP_ACCEPT_CONN_REQ, sizeof(cp), &cp); in hci_conn_request_evt()
2568 cp.content_format = cpu_to_le16(hdev->voice_setting); in hci_conn_request_evt()
2571 hci_send_cmd(hdev, HCI_OP_ACCEPT_SYNC_CONN_REQ, sizeof(cp), in hci_conn_request_evt()
2595 static void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) in hci_disconn_complete_evt() argument
2604 BT_DBG("%s status 0x%2.2x", hdev->name, ev->status); in hci_disconn_complete_evt()
2606 hci_dev_lock(hdev); in hci_disconn_complete_evt()
2608 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_disconn_complete_evt()
2613 mgmt_disconnect_failed(hdev, &conn->dst, conn->type, in hci_disconn_complete_evt()
2627 mgmt_device_disconnected(hdev, &conn->dst, conn->type, conn->dst_type, in hci_disconn_complete_evt()
2632 hci_remove_link_key(hdev, &conn->dst); in hci_disconn_complete_evt()
2634 hci_req_update_scan(hdev); in hci_disconn_complete_evt()
2637 params = hci_conn_params_lookup(hdev, &conn->dst, conn->dst_type); in hci_disconn_complete_evt()
2648 list_add(¶ms->action, &hdev->pend_le_conns); in hci_disconn_complete_evt()
2649 hci_update_background_scan(hdev); in hci_disconn_complete_evt()
2673 hci_req_reenable_advertising(hdev); in hci_disconn_complete_evt()
2676 hci_dev_unlock(hdev); in hci_disconn_complete_evt()
2679 static void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) in hci_auth_complete_evt() argument
2684 BT_DBG("%s status 0x%2.2x", hdev->name, ev->status); in hci_auth_complete_evt()
2686 hci_dev_lock(hdev); in hci_auth_complete_evt()
2688 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_auth_complete_evt()
2697 bt_dev_info(hdev, "re-auth of legacy device is not possible."); in hci_auth_complete_evt()
2717 hci_send_cmd(hdev, HCI_OP_SET_CONN_ENCRYPT, sizeof(cp), in hci_auth_complete_evt()
2737 hci_send_cmd(hdev, HCI_OP_SET_CONN_ENCRYPT, sizeof(cp), in hci_auth_complete_evt()
2746 hci_dev_unlock(hdev); in hci_auth_complete_evt()
2749 static void hci_remote_name_evt(struct hci_dev *hdev, struct sk_buff *skb) in hci_remote_name_evt() argument
2754 BT_DBG("%s", hdev->name); in hci_remote_name_evt()
2756 hci_conn_check_pending(hdev); in hci_remote_name_evt()
2758 hci_dev_lock(hdev); in hci_remote_name_evt()
2760 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_remote_name_evt()
2762 if (!hci_dev_test_flag(hdev, HCI_MGMT)) in hci_remote_name_evt()
2766 hci_check_pending_name(hdev, conn, &ev->bdaddr, ev->name, in hci_remote_name_evt()
2769 hci_check_pending_name(hdev, conn, &ev->bdaddr, NULL, 0); in hci_remote_name_evt()
2775 if (!hci_outgoing_auth_needed(hdev, conn)) in hci_remote_name_evt()
2784 hci_send_cmd(hdev, HCI_OP_AUTH_REQUESTED, sizeof(cp), &cp); in hci_remote_name_evt()
2788 hci_dev_unlock(hdev); in hci_remote_name_evt()
2791 static void read_enc_key_size_complete(struct hci_dev *hdev, u8 status, in read_enc_key_size_complete() argument
2798 BT_DBG("%s status 0x%02x", hdev->name, status); in read_enc_key_size_complete()
2801 bt_dev_err(hdev, "invalid read key size response"); in read_enc_key_size_complete()
2808 hci_dev_lock(hdev); in read_enc_key_size_complete()
2810 conn = hci_conn_hash_lookup_handle(hdev, handle); in read_enc_key_size_complete()
2819 bt_dev_err(hdev, "failed to read key size for handle %u", in read_enc_key_size_complete()
2844 hci_dev_unlock(hdev); in read_enc_key_size_complete()
2847 static void hci_encrypt_change_evt(struct hci_dev *hdev, struct sk_buff *skb) in hci_encrypt_change_evt() argument
2852 BT_DBG("%s status 0x%2.2x", hdev->name, ev->status); in hci_encrypt_change_evt()
2854 hci_dev_lock(hdev); in hci_encrypt_change_evt()
2856 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_encrypt_change_evt()
2884 hci_dev_set_flag(hdev, HCI_RPA_EXPIRED); in hci_encrypt_change_evt()
2885 hci_adv_instances_set_rpa_expired(hdev, true); in hci_encrypt_change_evt()
2903 if (hci_dev_test_flag(hdev, HCI_SC_ONLY) && in hci_encrypt_change_evt()
2920 if (!(hdev->commands[20] & 0x10)) { in hci_encrypt_change_evt()
2925 hci_req_init(&req, hdev); in hci_encrypt_change_evt()
2931 bt_dev_err(hdev, "sending read key size failed"); in hci_encrypt_change_evt()
2950 hci_dev_unlock(hdev); in hci_encrypt_change_evt()
2953 static void hci_change_link_key_complete_evt(struct hci_dev *hdev, in hci_change_link_key_complete_evt() argument
2959 BT_DBG("%s status 0x%2.2x", hdev->name, ev->status); in hci_change_link_key_complete_evt()
2961 hci_dev_lock(hdev); in hci_change_link_key_complete_evt()
2963 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_change_link_key_complete_evt()
2973 hci_dev_unlock(hdev); in hci_change_link_key_complete_evt()
2976 static void hci_remote_features_evt(struct hci_dev *hdev, in hci_remote_features_evt() argument
2982 BT_DBG("%s status 0x%2.2x", hdev->name, ev->status); in hci_remote_features_evt()
2984 hci_dev_lock(hdev); in hci_remote_features_evt()
2986 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_remote_features_evt()
2996 if (!ev->status && lmp_ext_feat_capable(hdev) && in hci_remote_features_evt()
3001 hci_send_cmd(hdev, HCI_OP_READ_REMOTE_EXT_FEATURES, in hci_remote_features_evt()
3011 hci_send_cmd(hdev, HCI_OP_REMOTE_NAME_REQ, sizeof(cp), &cp); in hci_remote_features_evt()
3013 mgmt_device_connected(hdev, conn, 0, NULL, 0); in hci_remote_features_evt()
3015 if (!hci_outgoing_auth_needed(hdev, conn)) { in hci_remote_features_evt()
3022 hci_dev_unlock(hdev); in hci_remote_features_evt()
3025 static void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *skb, in hci_cmd_complete_evt() argument
3039 hci_cc_inquiry_cancel(hdev, skb); in hci_cmd_complete_evt()
3043 hci_cc_periodic_inq(hdev, skb); in hci_cmd_complete_evt()
3047 hci_cc_exit_periodic_inq(hdev, skb); in hci_cmd_complete_evt()
3051 hci_cc_remote_name_req_cancel(hdev, skb); in hci_cmd_complete_evt()
3055 hci_cc_role_discovery(hdev, skb); in hci_cmd_complete_evt()
3059 hci_cc_read_link_policy(hdev, skb); in hci_cmd_complete_evt()
3063 hci_cc_write_link_policy(hdev, skb); in hci_cmd_complete_evt()
3067 hci_cc_read_def_link_policy(hdev, skb); in hci_cmd_complete_evt()
3071 hci_cc_write_def_link_policy(hdev, skb); in hci_cmd_complete_evt()
3075 hci_cc_reset(hdev, skb); in hci_cmd_complete_evt()
3079 hci_cc_read_stored_link_key(hdev, skb); in hci_cmd_complete_evt()
3083 hci_cc_delete_stored_link_key(hdev, skb); in hci_cmd_complete_evt()
3087 hci_cc_write_local_name(hdev, skb); in hci_cmd_complete_evt()
3091 hci_cc_read_local_name(hdev, skb); in hci_cmd_complete_evt()
3095 hci_cc_write_auth_enable(hdev, skb); in hci_cmd_complete_evt()
3099 hci_cc_write_encrypt_mode(hdev, skb); in hci_cmd_complete_evt()
3103 hci_cc_write_scan_enable(hdev, skb); in hci_cmd_complete_evt()
3107 hci_cc_read_class_of_dev(hdev, skb); in hci_cmd_complete_evt()
3111 hci_cc_write_class_of_dev(hdev, skb); in hci_cmd_complete_evt()
3115 hci_cc_read_voice_setting(hdev, skb); in hci_cmd_complete_evt()
3119 hci_cc_write_voice_setting(hdev, skb); in hci_cmd_complete_evt()
3123 hci_cc_read_num_supported_iac(hdev, skb); in hci_cmd_complete_evt()
3127 hci_cc_write_ssp_mode(hdev, skb); in hci_cmd_complete_evt()
3131 hci_cc_write_sc_support(hdev, skb); in hci_cmd_complete_evt()
3135 hci_cc_read_local_version(hdev, skb); in hci_cmd_complete_evt()
3139 hci_cc_read_local_commands(hdev, skb); in hci_cmd_complete_evt()
3143 hci_cc_read_local_features(hdev, skb); in hci_cmd_complete_evt()
3147 hci_cc_read_local_ext_features(hdev, skb); in hci_cmd_complete_evt()
3151 hci_cc_read_buffer_size(hdev, skb); in hci_cmd_complete_evt()
3155 hci_cc_read_bd_addr(hdev, skb); in hci_cmd_complete_evt()
3159 hci_cc_read_page_scan_activity(hdev, skb); in hci_cmd_complete_evt()
3163 hci_cc_write_page_scan_activity(hdev, skb); in hci_cmd_complete_evt()
3167 hci_cc_read_page_scan_type(hdev, skb); in hci_cmd_complete_evt()
3171 hci_cc_write_page_scan_type(hdev, skb); in hci_cmd_complete_evt()
3175 hci_cc_read_data_block_size(hdev, skb); in hci_cmd_complete_evt()
3179 hci_cc_read_flow_control_mode(hdev, skb); in hci_cmd_complete_evt()
3183 hci_cc_read_local_amp_info(hdev, skb); in hci_cmd_complete_evt()
3187 hci_cc_read_clock(hdev, skb); in hci_cmd_complete_evt()
3191 hci_cc_read_inq_rsp_tx_power(hdev, skb); in hci_cmd_complete_evt()
3195 hci_cc_pin_code_reply(hdev, skb); in hci_cmd_complete_evt()
3199 hci_cc_pin_code_neg_reply(hdev, skb); in hci_cmd_complete_evt()
3203 hci_cc_read_local_oob_data(hdev, skb); in hci_cmd_complete_evt()
3207 hci_cc_read_local_oob_ext_data(hdev, skb); in hci_cmd_complete_evt()
3211 hci_cc_le_read_buffer_size(hdev, skb); in hci_cmd_complete_evt()
3215 hci_cc_le_read_local_features(hdev, skb); in hci_cmd_complete_evt()
3219 hci_cc_le_read_adv_tx_power(hdev, skb); in hci_cmd_complete_evt()
3223 hci_cc_user_confirm_reply(hdev, skb); in hci_cmd_complete_evt()
3227 hci_cc_user_confirm_neg_reply(hdev, skb); in hci_cmd_complete_evt()
3231 hci_cc_user_passkey_reply(hdev, skb); in hci_cmd_complete_evt()
3235 hci_cc_user_passkey_neg_reply(hdev, skb); in hci_cmd_complete_evt()
3239 hci_cc_le_set_random_addr(hdev, skb); in hci_cmd_complete_evt()
3243 hci_cc_le_set_adv_enable(hdev, skb); in hci_cmd_complete_evt()
3247 hci_cc_le_set_scan_param(hdev, skb); in hci_cmd_complete_evt()
3251 hci_cc_le_set_scan_enable(hdev, skb); in hci_cmd_complete_evt()
3255 hci_cc_le_read_white_list_size(hdev, skb); in hci_cmd_complete_evt()
3259 hci_cc_le_clear_white_list(hdev, skb); in hci_cmd_complete_evt()
3263 hci_cc_le_add_to_white_list(hdev, skb); in hci_cmd_complete_evt()
3267 hci_cc_le_del_from_white_list(hdev, skb); in hci_cmd_complete_evt()
3271 hci_cc_le_read_supported_states(hdev, skb); in hci_cmd_complete_evt()
3275 hci_cc_le_read_def_data_len(hdev, skb); in hci_cmd_complete_evt()
3279 hci_cc_le_write_def_data_len(hdev, skb); in hci_cmd_complete_evt()
3283 hci_cc_le_clear_resolv_list(hdev, skb); in hci_cmd_complete_evt()
3287 hci_cc_le_read_resolv_list_size(hdev, skb); in hci_cmd_complete_evt()
3291 hci_cc_le_set_addr_resolution_enable(hdev, skb); in hci_cmd_complete_evt()
3295 hci_cc_le_read_max_data_len(hdev, skb); in hci_cmd_complete_evt()
3299 hci_cc_write_le_host_supported(hdev, skb); in hci_cmd_complete_evt()
3303 hci_cc_set_adv_param(hdev, skb); in hci_cmd_complete_evt()
3307 hci_cc_read_rssi(hdev, skb); in hci_cmd_complete_evt()
3311 hci_cc_read_tx_power(hdev, skb); in hci_cmd_complete_evt()
3315 hci_cc_write_ssp_debug_mode(hdev, skb); in hci_cmd_complete_evt()
3319 hci_cc_le_set_ext_scan_param(hdev, skb); in hci_cmd_complete_evt()
3323 hci_cc_le_set_ext_scan_enable(hdev, skb); in hci_cmd_complete_evt()
3327 hci_cc_le_set_default_phy(hdev, skb); in hci_cmd_complete_evt()
3331 hci_cc_le_read_num_adv_sets(hdev, skb); in hci_cmd_complete_evt()
3335 hci_cc_set_ext_adv_param(hdev, skb); in hci_cmd_complete_evt()
3339 hci_cc_le_set_ext_adv_enable(hdev, skb); in hci_cmd_complete_evt()
3343 hci_cc_le_set_adv_set_random_addr(hdev, skb); in hci_cmd_complete_evt()
3347 BT_DBG("%s opcode 0x%4.4x", hdev->name, *opcode); in hci_cmd_complete_evt()
3352 cancel_delayed_work(&hdev->cmd_timer); in hci_cmd_complete_evt()
3354 if (ev->ncmd && !test_bit(HCI_RESET, &hdev->flags)) in hci_cmd_complete_evt()
3355 atomic_set(&hdev->cmd_cnt, 1); in hci_cmd_complete_evt()
3357 hci_req_cmd_complete(hdev, *opcode, *status, req_complete, in hci_cmd_complete_evt()
3360 if (atomic_read(&hdev->cmd_cnt) && !skb_queue_empty(&hdev->cmd_q)) in hci_cmd_complete_evt()
3361 queue_work(hdev->workqueue, &hdev->cmd_work); in hci_cmd_complete_evt()
3364 static void hci_cmd_status_evt(struct hci_dev *hdev, struct sk_buff *skb, in hci_cmd_status_evt() argument
3378 hci_cs_inquiry(hdev, ev->status); in hci_cmd_status_evt()
3382 hci_cs_create_conn(hdev, ev->status); in hci_cmd_status_evt()
3386 hci_cs_disconnect(hdev, ev->status); in hci_cmd_status_evt()
3390 hci_cs_add_sco(hdev, ev->status); in hci_cmd_status_evt()
3394 hci_cs_auth_requested(hdev, ev->status); in hci_cmd_status_evt()
3398 hci_cs_set_conn_encrypt(hdev, ev->status); in hci_cmd_status_evt()
3402 hci_cs_remote_name_req(hdev, ev->status); in hci_cmd_status_evt()
3406 hci_cs_read_remote_features(hdev, ev->status); in hci_cmd_status_evt()
3410 hci_cs_read_remote_ext_features(hdev, ev->status); in hci_cmd_status_evt()
3414 hci_cs_setup_sync_conn(hdev, ev->status); in hci_cmd_status_evt()
3418 hci_cs_sniff_mode(hdev, ev->status); in hci_cmd_status_evt()
3422 hci_cs_exit_sniff_mode(hdev, ev->status); in hci_cmd_status_evt()
3426 hci_cs_switch_role(hdev, ev->status); in hci_cmd_status_evt()
3430 hci_cs_le_create_conn(hdev, ev->status); in hci_cmd_status_evt()
3434 hci_cs_le_read_remote_features(hdev, ev->status); in hci_cmd_status_evt()
3438 hci_cs_le_start_enc(hdev, ev->status); in hci_cmd_status_evt()
3442 hci_cs_le_ext_create_conn(hdev, ev->status); in hci_cmd_status_evt()
3446 BT_DBG("%s opcode 0x%4.4x", hdev->name, *opcode); in hci_cmd_status_evt()
3451 cancel_delayed_work(&hdev->cmd_timer); in hci_cmd_status_evt()
3453 if (ev->ncmd && !test_bit(HCI_RESET, &hdev->flags)) in hci_cmd_status_evt()
3454 atomic_set(&hdev->cmd_cnt, 1); in hci_cmd_status_evt()
3463 (hdev->sent_cmd && !bt_cb(hdev->sent_cmd)->hci.req_event)) in hci_cmd_status_evt()
3464 hci_req_cmd_complete(hdev, *opcode, ev->status, req_complete, in hci_cmd_status_evt()
3467 if (atomic_read(&hdev->cmd_cnt) && !skb_queue_empty(&hdev->cmd_q)) in hci_cmd_status_evt()
3468 queue_work(hdev->workqueue, &hdev->cmd_work); in hci_cmd_status_evt()
3471 static void hci_hardware_error_evt(struct hci_dev *hdev, struct sk_buff *skb) in hci_hardware_error_evt() argument
3475 hdev->hw_error_code = ev->code; in hci_hardware_error_evt()
3477 queue_work(hdev->req_workqueue, &hdev->error_reset); in hci_hardware_error_evt()
3480 static void hci_role_change_evt(struct hci_dev *hdev, struct sk_buff *skb) in hci_role_change_evt() argument
3485 BT_DBG("%s status 0x%2.2x", hdev->name, ev->status); in hci_role_change_evt()
3487 hci_dev_lock(hdev); in hci_role_change_evt()
3489 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_role_change_evt()
3499 hci_dev_unlock(hdev); in hci_role_change_evt()
3502 static void hci_num_comp_pkts_evt(struct hci_dev *hdev, struct sk_buff *skb) in hci_num_comp_pkts_evt() argument
3507 if (hdev->flow_ctl_mode != HCI_FLOW_CTL_MODE_PACKET_BASED) { in hci_num_comp_pkts_evt()
3508 bt_dev_err(hdev, "wrong event for mode %d", hdev->flow_ctl_mode); in hci_num_comp_pkts_evt()
3514 BT_DBG("%s bad parameters", hdev->name); in hci_num_comp_pkts_evt()
3518 BT_DBG("%s num_hndl %d", hdev->name, ev->num_hndl); in hci_num_comp_pkts_evt()
3528 conn = hci_conn_hash_lookup_handle(hdev, handle); in hci_num_comp_pkts_evt()
3536 hdev->acl_cnt += count; in hci_num_comp_pkts_evt()
3537 if (hdev->acl_cnt > hdev->acl_pkts) in hci_num_comp_pkts_evt()
3538 hdev->acl_cnt = hdev->acl_pkts; in hci_num_comp_pkts_evt()
3542 if (hdev->le_pkts) { in hci_num_comp_pkts_evt()
3543 hdev->le_cnt += count; in hci_num_comp_pkts_evt()
3544 if (hdev->le_cnt > hdev->le_pkts) in hci_num_comp_pkts_evt()
3545 hdev->le_cnt = hdev->le_pkts; in hci_num_comp_pkts_evt()
3547 hdev->acl_cnt += count; in hci_num_comp_pkts_evt()
3548 if (hdev->acl_cnt > hdev->acl_pkts) in hci_num_comp_pkts_evt()
3549 hdev->acl_cnt = hdev->acl_pkts; in hci_num_comp_pkts_evt()
3554 hdev->sco_cnt += count; in hci_num_comp_pkts_evt()
3555 if (hdev->sco_cnt > hdev->sco_pkts) in hci_num_comp_pkts_evt()
3556 hdev->sco_cnt = hdev->sco_pkts; in hci_num_comp_pkts_evt()
3560 bt_dev_err(hdev, "unknown type %d conn %p", in hci_num_comp_pkts_evt()
3566 queue_work(hdev->workqueue, &hdev->tx_work); in hci_num_comp_pkts_evt()
3569 static struct hci_conn *__hci_conn_lookup_handle(struct hci_dev *hdev, in __hci_conn_lookup_handle() argument
3574 switch (hdev->dev_type) { in __hci_conn_lookup_handle()
3576 return hci_conn_hash_lookup_handle(hdev, handle); in __hci_conn_lookup_handle()
3578 chan = hci_chan_lookup_handle(hdev, handle); in __hci_conn_lookup_handle()
3583 bt_dev_err(hdev, "unknown dev_type %d", hdev->dev_type); in __hci_conn_lookup_handle()
3590 static void hci_num_comp_blocks_evt(struct hci_dev *hdev, struct sk_buff *skb) in hci_num_comp_blocks_evt() argument
3595 if (hdev->flow_ctl_mode != HCI_FLOW_CTL_MODE_BLOCK_BASED) { in hci_num_comp_blocks_evt()
3596 bt_dev_err(hdev, "wrong event for mode %d", hdev->flow_ctl_mode); in hci_num_comp_blocks_evt()
3602 BT_DBG("%s bad parameters", hdev->name); in hci_num_comp_blocks_evt()
3606 BT_DBG("%s num_blocks %d num_hndl %d", hdev->name, ev->num_blocks, in hci_num_comp_blocks_evt()
3617 conn = __hci_conn_lookup_handle(hdev, handle); in hci_num_comp_blocks_evt()
3626 hdev->block_cnt += block_count; in hci_num_comp_blocks_evt()
3627 if (hdev->block_cnt > hdev->num_blocks) in hci_num_comp_blocks_evt()
3628 hdev->block_cnt = hdev->num_blocks; in hci_num_comp_blocks_evt()
3632 bt_dev_err(hdev, "unknown type %d conn %p", in hci_num_comp_blocks_evt()
3638 queue_work(hdev->workqueue, &hdev->tx_work); in hci_num_comp_blocks_evt()
3641 static void hci_mode_change_evt(struct hci_dev *hdev, struct sk_buff *skb) in hci_mode_change_evt() argument
3646 BT_DBG("%s status 0x%2.2x", hdev->name, ev->status); in hci_mode_change_evt()
3648 hci_dev_lock(hdev); in hci_mode_change_evt()
3650 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_mode_change_evt()
3666 hci_dev_unlock(hdev); in hci_mode_change_evt()
3669 static void hci_pin_code_request_evt(struct hci_dev *hdev, struct sk_buff *skb) in hci_pin_code_request_evt() argument
3674 BT_DBG("%s", hdev->name); in hci_pin_code_request_evt()
3676 hci_dev_lock(hdev); in hci_pin_code_request_evt()
3678 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_pin_code_request_evt()
3688 if (!hci_dev_test_flag(hdev, HCI_BONDABLE) && in hci_pin_code_request_evt()
3690 hci_send_cmd(hdev, HCI_OP_PIN_CODE_NEG_REPLY, in hci_pin_code_request_evt()
3692 } else if (hci_dev_test_flag(hdev, HCI_MGMT)) { in hci_pin_code_request_evt()
3700 mgmt_pin_code_request(hdev, &ev->bdaddr, secure); in hci_pin_code_request_evt()
3704 hci_dev_unlock(hdev); in hci_pin_code_request_evt()
3739 static void hci_link_key_request_evt(struct hci_dev *hdev, struct sk_buff *skb) in hci_link_key_request_evt() argument
3746 BT_DBG("%s", hdev->name); in hci_link_key_request_evt()
3748 if (!hci_dev_test_flag(hdev, HCI_MGMT)) in hci_link_key_request_evt()
3751 hci_dev_lock(hdev); in hci_link_key_request_evt()
3753 key = hci_find_link_key(hdev, &ev->bdaddr); in hci_link_key_request_evt()
3755 BT_DBG("%s link key not found for %pMR", hdev->name, in hci_link_key_request_evt()
3760 BT_DBG("%s found key type %u for %pMR", hdev->name, key->type, in hci_link_key_request_evt()
3763 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_link_key_request_evt()
3770 BT_DBG("%s ignoring unauthenticated key", hdev->name); in hci_link_key_request_evt()
3778 hdev->name); in hci_link_key_request_evt()
3788 hci_send_cmd(hdev, HCI_OP_LINK_KEY_REPLY, sizeof(cp), &cp); in hci_link_key_request_evt()
3790 hci_dev_unlock(hdev); in hci_link_key_request_evt()
3795 hci_send_cmd(hdev, HCI_OP_LINK_KEY_NEG_REPLY, 6, &ev->bdaddr); in hci_link_key_request_evt()
3796 hci_dev_unlock(hdev); in hci_link_key_request_evt()
3799 static void hci_link_key_notify_evt(struct hci_dev *hdev, struct sk_buff *skb) in hci_link_key_notify_evt() argument
3807 BT_DBG("%s", hdev->name); in hci_link_key_notify_evt()
3809 hci_dev_lock(hdev); in hci_link_key_notify_evt()
3811 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_link_key_notify_evt()
3822 if (!hci_dev_test_flag(hdev, HCI_MGMT)) in hci_link_key_notify_evt()
3825 key = hci_add_link_key(hdev, conn, &ev->bdaddr, ev->link_key, in hci_link_key_notify_evt()
3836 mgmt_new_link_key(hdev, key, persistent); in hci_link_key_notify_evt()
3844 !hci_dev_test_flag(hdev, HCI_KEEP_DEBUG_KEYS)) { in hci_link_key_notify_evt()
3856 hci_dev_unlock(hdev); in hci_link_key_notify_evt()
3859 static void hci_clock_offset_evt(struct hci_dev *hdev, struct sk_buff *skb) in hci_clock_offset_evt() argument
3864 BT_DBG("%s status 0x%2.2x", hdev->name, ev->status); in hci_clock_offset_evt()
3866 hci_dev_lock(hdev); in hci_clock_offset_evt()
3868 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_clock_offset_evt()
3872 ie = hci_inquiry_cache_lookup(hdev, &conn->dst); in hci_clock_offset_evt()
3879 hci_dev_unlock(hdev); in hci_clock_offset_evt()
3882 static void hci_pkt_type_change_evt(struct hci_dev *hdev, struct sk_buff *skb) in hci_pkt_type_change_evt() argument
3887 BT_DBG("%s status 0x%2.2x", hdev->name, ev->status); in hci_pkt_type_change_evt()
3889 hci_dev_lock(hdev); in hci_pkt_type_change_evt()
3891 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_pkt_type_change_evt()
3895 hci_dev_unlock(hdev); in hci_pkt_type_change_evt()
3898 static void hci_pscan_rep_mode_evt(struct hci_dev *hdev, struct sk_buff *skb) in hci_pscan_rep_mode_evt() argument
3903 BT_DBG("%s", hdev->name); in hci_pscan_rep_mode_evt()
3905 hci_dev_lock(hdev); in hci_pscan_rep_mode_evt()
3907 ie = hci_inquiry_cache_lookup(hdev, &ev->bdaddr); in hci_pscan_rep_mode_evt()
3913 hci_dev_unlock(hdev); in hci_pscan_rep_mode_evt()
3916 static void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, in hci_inquiry_result_with_rssi_evt() argument
3922 BT_DBG("%s num_rsp %d", hdev->name, num_rsp); in hci_inquiry_result_with_rssi_evt()
3927 if (hci_dev_test_flag(hdev, HCI_PERIODIC_INQ)) in hci_inquiry_result_with_rssi_evt()
3930 hci_dev_lock(hdev); in hci_inquiry_result_with_rssi_evt()
3948 flags = hci_inquiry_cache_update(hdev, &data, false); in hci_inquiry_result_with_rssi_evt()
3950 mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, in hci_inquiry_result_with_rssi_evt()
3969 flags = hci_inquiry_cache_update(hdev, &data, false); in hci_inquiry_result_with_rssi_evt()
3971 mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, in hci_inquiry_result_with_rssi_evt()
3977 hci_dev_unlock(hdev); in hci_inquiry_result_with_rssi_evt()
3980 static void hci_remote_ext_features_evt(struct hci_dev *hdev, in hci_remote_ext_features_evt() argument
3986 BT_DBG("%s", hdev->name); in hci_remote_ext_features_evt()
3988 hci_dev_lock(hdev); in hci_remote_ext_features_evt()
3990 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_remote_ext_features_evt()
4000 ie = hci_inquiry_cache_lookup(hdev, &conn->dst); in hci_remote_ext_features_evt()
4030 hci_send_cmd(hdev, HCI_OP_REMOTE_NAME_REQ, sizeof(cp), &cp); in hci_remote_ext_features_evt()
4032 mgmt_device_connected(hdev, conn, 0, NULL, 0); in hci_remote_ext_features_evt()
4034 if (!hci_outgoing_auth_needed(hdev, conn)) { in hci_remote_ext_features_evt()
4041 hci_dev_unlock(hdev); in hci_remote_ext_features_evt()
4044 static void hci_sync_conn_complete_evt(struct hci_dev *hdev, in hci_sync_conn_complete_evt() argument
4050 BT_DBG("%s status 0x%2.2x", hdev->name, ev->status); in hci_sync_conn_complete_evt()
4052 hci_dev_lock(hdev); in hci_sync_conn_complete_evt()
4054 conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, &ev->bdaddr); in hci_sync_conn_complete_evt()
4068 conn = hci_conn_hash_lookup_ba(hdev, ESCO_LINK, &ev->bdaddr); in hci_sync_conn_complete_evt()
4091 conn->pkt_type = (hdev->esco_type & SCO_ESCO_MASK) | in hci_sync_conn_complete_evt()
4092 (hdev->esco_type & EDR_ESCO_MASK); in hci_sync_conn_complete_evt()
4108 hci_dev_unlock(hdev); in hci_sync_conn_complete_evt()
4128 static void hci_extended_inquiry_result_evt(struct hci_dev *hdev, in hci_extended_inquiry_result_evt() argument
4136 BT_DBG("%s num_rsp %d", hdev->name, num_rsp); in hci_extended_inquiry_result_evt()
4141 if (hci_dev_test_flag(hdev, HCI_PERIODIC_INQ)) in hci_extended_inquiry_result_evt()
4144 hci_dev_lock(hdev); in hci_extended_inquiry_result_evt()
4159 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_extended_inquiry_result_evt()
4166 flags = hci_inquiry_cache_update(hdev, &data, name_known); in hci_extended_inquiry_result_evt()
4170 mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, in hci_extended_inquiry_result_evt()
4175 hci_dev_unlock(hdev); in hci_extended_inquiry_result_evt()
4178 static void hci_key_refresh_complete_evt(struct hci_dev *hdev, in hci_key_refresh_complete_evt() argument
4184 BT_DBG("%s status 0x%2.2x handle 0x%4.4x", hdev->name, ev->status, in hci_key_refresh_complete_evt()
4187 hci_dev_lock(hdev); in hci_key_refresh_complete_evt()
4189 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_key_refresh_complete_evt()
4225 hci_dev_unlock(hdev); in hci_key_refresh_complete_evt()
4248 struct hci_dev *hdev = conn->hdev; in bredr_oob_data_present() local
4251 data = hci_find_remote_oob_data(hdev, &conn->dst, BDADDR_BREDR); in bredr_oob_data_present()
4255 if (bredr_sc_enabled(hdev)) { in bredr_oob_data_present()
4262 if (!hci_dev_test_flag(hdev, HCI_SC_ONLY)) in bredr_oob_data_present()
4288 static void hci_io_capa_request_evt(struct hci_dev *hdev, struct sk_buff *skb) in hci_io_capa_request_evt() argument
4293 BT_DBG("%s", hdev->name); in hci_io_capa_request_evt()
4295 hci_dev_lock(hdev); in hci_io_capa_request_evt()
4297 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_io_capa_request_evt()
4303 if (!hci_dev_test_flag(hdev, HCI_MGMT)) in hci_io_capa_request_evt()
4309 if (hci_dev_test_flag(hdev, HCI_BONDABLE) || in hci_io_capa_request_evt()
4335 if (!hci_dev_test_flag(hdev, HCI_BONDABLE)) in hci_io_capa_request_evt()
4341 hci_send_cmd(hdev, HCI_OP_IO_CAPABILITY_REPLY, in hci_io_capa_request_evt()
4349 hci_send_cmd(hdev, HCI_OP_IO_CAPABILITY_NEG_REPLY, in hci_io_capa_request_evt()
4354 hci_dev_unlock(hdev); in hci_io_capa_request_evt()
4357 static void hci_io_capa_reply_evt(struct hci_dev *hdev, struct sk_buff *skb) in hci_io_capa_reply_evt() argument
4362 BT_DBG("%s", hdev->name); in hci_io_capa_reply_evt()
4364 hci_dev_lock(hdev); in hci_io_capa_reply_evt()
4366 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_io_capa_reply_evt()
4374 hci_dev_unlock(hdev); in hci_io_capa_reply_evt()
4377 static void hci_user_confirm_request_evt(struct hci_dev *hdev, in hci_user_confirm_request_evt() argument
4384 BT_DBG("%s", hdev->name); in hci_user_confirm_request_evt()
4386 hci_dev_lock(hdev); in hci_user_confirm_request_evt()
4388 if (!hci_dev_test_flag(hdev, HCI_MGMT)) in hci_user_confirm_request_evt()
4391 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_user_confirm_request_evt()
4406 hci_send_cmd(hdev, HCI_OP_USER_CONFIRM_NEG_REPLY, in hci_user_confirm_request_evt()
4430 hdev->auto_accept_delay); in hci_user_confirm_request_evt()
4432 if (hdev->auto_accept_delay > 0) { in hci_user_confirm_request_evt()
4433 int delay = msecs_to_jiffies(hdev->auto_accept_delay); in hci_user_confirm_request_evt()
4434 queue_delayed_work(conn->hdev->workqueue, in hci_user_confirm_request_evt()
4439 hci_send_cmd(hdev, HCI_OP_USER_CONFIRM_REPLY, in hci_user_confirm_request_evt()
4445 mgmt_user_confirm_request(hdev, &ev->bdaddr, ACL_LINK, 0, in hci_user_confirm_request_evt()
4449 hci_dev_unlock(hdev); in hci_user_confirm_request_evt()
4452 static void hci_user_passkey_request_evt(struct hci_dev *hdev, in hci_user_passkey_request_evt() argument
4457 BT_DBG("%s", hdev->name); in hci_user_passkey_request_evt()
4459 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_user_passkey_request_evt()
4460 mgmt_user_passkey_request(hdev, &ev->bdaddr, ACL_LINK, 0); in hci_user_passkey_request_evt()
4463 static void hci_user_passkey_notify_evt(struct hci_dev *hdev, in hci_user_passkey_notify_evt() argument
4469 BT_DBG("%s", hdev->name); in hci_user_passkey_notify_evt()
4471 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_user_passkey_notify_evt()
4478 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_user_passkey_notify_evt()
4479 mgmt_user_passkey_notify(hdev, &conn->dst, conn->type, in hci_user_passkey_notify_evt()
4484 static void hci_keypress_notify_evt(struct hci_dev *hdev, struct sk_buff *skb) in hci_keypress_notify_evt() argument
4489 BT_DBG("%s", hdev->name); in hci_keypress_notify_evt()
4491 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_keypress_notify_evt()
4516 if (hci_dev_test_flag(hdev, HCI_MGMT)) in hci_keypress_notify_evt()
4517 mgmt_user_passkey_notify(hdev, &conn->dst, conn->type, in hci_keypress_notify_evt()
4522 static void hci_simple_pair_complete_evt(struct hci_dev *hdev, in hci_simple_pair_complete_evt() argument
4528 BT_DBG("%s", hdev->name); in hci_simple_pair_complete_evt()
4530 hci_dev_lock(hdev); in hci_simple_pair_complete_evt()
4532 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_simple_pair_complete_evt()
4550 hci_dev_unlock(hdev); in hci_simple_pair_complete_evt()
4553 static void hci_remote_host_features_evt(struct hci_dev *hdev, in hci_remote_host_features_evt() argument
4560 BT_DBG("%s", hdev->name); in hci_remote_host_features_evt()
4562 hci_dev_lock(hdev); in hci_remote_host_features_evt()
4564 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); in hci_remote_host_features_evt()
4568 ie = hci_inquiry_cache_lookup(hdev, &ev->bdaddr); in hci_remote_host_features_evt()
4572 hci_dev_unlock(hdev); in hci_remote_host_features_evt()
4575 static void hci_remote_oob_data_request_evt(struct hci_dev *hdev, in hci_remote_oob_data_request_evt() argument
4581 BT_DBG("%s", hdev->name); in hci_remote_oob_data_request_evt()
4583 hci_dev_lock(hdev); in hci_remote_oob_data_request_evt()
4585 if (!hci_dev_test_flag(hdev, HCI_MGMT)) in hci_remote_oob_data_request_evt()
4588 data = hci_find_remote_oob_data(hdev, &ev->bdaddr, BDADDR_BREDR); in hci_remote_oob_data_request_evt()
4593 hci_send_cmd(hdev, HCI_OP_REMOTE_OOB_DATA_NEG_REPLY, in hci_remote_oob_data_request_evt()
4598 if (bredr_sc_enabled(hdev)) { in hci_remote_oob_data_request_evt()
4602 if (hci_dev_test_flag(hdev, HCI_SC_ONLY)) { in hci_remote_oob_data_request_evt()
4612 hci_send_cmd(hdev, HCI_OP_REMOTE_OOB_EXT_DATA_REPLY, in hci_remote_oob_data_request_evt()
4621 hci_send_cmd(hdev, HCI_OP_REMOTE_OOB_DATA_REPLY, in hci_remote_oob_data_request_evt()
4626 hci_dev_unlock(hdev); in hci_remote_oob_data_request_evt()
4630 static void hci_chan_selected_evt(struct hci_dev *hdev, struct sk_buff *skb) in hci_chan_selected_evt() argument
4635 BT_DBG("%s handle 0x%2.2x", hdev->name, ev->phy_handle); in hci_chan_selected_evt()
4639 hcon = hci_conn_hash_lookup_handle(hdev, ev->phy_handle); in hci_chan_selected_evt()
4643 amp_read_loc_assoc_final_data(hdev, hcon); in hci_chan_selected_evt()
4646 static void hci_phy_link_complete_evt(struct hci_dev *hdev, in hci_phy_link_complete_evt() argument
4652 BT_DBG("%s handle 0x%2.2x status 0x%2.2x", hdev->name, ev->phy_handle, in hci_phy_link_complete_evt()
4655 hci_dev_lock(hdev); in hci_phy_link_complete_evt()
4657 hcon = hci_conn_hash_lookup_handle(hdev, ev->phy_handle); in hci_phy_link_complete_evt()
4659 hci_dev_unlock(hdev); in hci_phy_link_complete_evt()
4665 hci_dev_unlock(hdev); in hci_phy_link_complete_evt()
4683 hci_dev_unlock(hdev); in hci_phy_link_complete_evt()
4686 static void hci_loglink_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) in hci_loglink_complete_evt() argument
4694 hdev->name, le16_to_cpu(ev->handle), ev->phy_handle, in hci_loglink_complete_evt()
4697 hcon = hci_conn_hash_lookup_handle(hdev, ev->phy_handle); in hci_loglink_complete_evt()
4716 bredr_chan->conn->mtu = hdev->block_mtu; in hci_loglink_complete_evt()
4724 static void hci_disconn_loglink_complete_evt(struct hci_dev *hdev, in hci_disconn_loglink_complete_evt() argument
4730 BT_DBG("%s log handle 0x%4.4x status 0x%2.2x", hdev->name, in hci_disconn_loglink_complete_evt()
4736 hci_dev_lock(hdev); in hci_disconn_loglink_complete_evt()
4738 hchan = hci_chan_lookup_handle(hdev, le16_to_cpu(ev->handle)); in hci_disconn_loglink_complete_evt()
4745 hci_dev_unlock(hdev); in hci_disconn_loglink_complete_evt()
4748 static void hci_disconn_phylink_complete_evt(struct hci_dev *hdev, in hci_disconn_phylink_complete_evt() argument
4754 BT_DBG("%s status 0x%2.2x", hdev->name, ev->status); in hci_disconn_phylink_complete_evt()
4759 hci_dev_lock(hdev); in hci_disconn_phylink_complete_evt()
4761 hcon = hci_conn_hash_lookup_handle(hdev, ev->phy_handle); in hci_disconn_phylink_complete_evt()
4767 hci_dev_unlock(hdev); in hci_disconn_phylink_complete_evt()
4771 static void le_conn_complete_evt(struct hci_dev *hdev, u8 status, in le_conn_complete_evt() argument
4780 hci_dev_lock(hdev); in le_conn_complete_evt()
4785 hci_dev_clear_flag(hdev, HCI_LE_ADV); in le_conn_complete_evt()
4787 conn = hci_lookup_le_connect(hdev); in le_conn_complete_evt()
4789 conn = hci_conn_add(hdev, LE_LINK, bdaddr, role); in le_conn_complete_evt()
4791 bt_dev_err(hdev, "no memory for new connection"); in le_conn_complete_evt()
4808 if (hci_dev_test_flag(hdev, HCI_PRIVACY)) { in le_conn_complete_evt()
4810 bacpy(&conn->init_addr, &hdev->rpa); in le_conn_complete_evt()
4812 hci_copy_identity_address(hdev, in le_conn_complete_evt()
4825 conn->resp_addr_type = hdev->adv_addr_type; in le_conn_complete_evt()
4826 if (hdev->adv_addr_type == ADDR_LE_DEV_RANDOM) { in le_conn_complete_evt()
4830 if (!ext_adv_capable(hdev)) in le_conn_complete_evt()
4831 bacpy(&conn->resp_addr, &hdev->random_addr); in le_conn_complete_evt()
4833 bacpy(&conn->resp_addr, &hdev->bdaddr); in le_conn_complete_evt()
4844 conn->le_conn_min_interval = hdev->le_conn_min_interval; in le_conn_complete_evt()
4845 conn->le_conn_max_interval = hdev->le_conn_max_interval; in le_conn_complete_evt()
4857 irk = hci_get_irk(hdev, &conn->dst, conn->dst_type); in le_conn_complete_evt()
4874 if (hci_bdaddr_list_lookup(&hdev->blacklist, &conn->dst, addr_type)) { in le_conn_complete_evt()
4880 mgmt_device_connected(hdev, conn, 0, NULL, 0); in le_conn_complete_evt()
4904 (hdev->le_features[0] & HCI_LE_SLAVE_FEATURES)) { in le_conn_complete_evt()
4909 hci_send_cmd(hdev, HCI_OP_LE_READ_REMOTE_FEATURES, in le_conn_complete_evt()
4921 params = hci_pend_le_action_lookup(&hdev->pend_le_conns, &conn->dst, in le_conn_complete_evt()
4933 hci_update_background_scan(hdev); in le_conn_complete_evt()
4934 hci_dev_unlock(hdev); in le_conn_complete_evt()
4937 static void hci_le_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) in hci_le_conn_complete_evt() argument
4941 BT_DBG("%s status 0x%2.2x", hdev->name, ev->status); in hci_le_conn_complete_evt()
4943 le_conn_complete_evt(hdev, ev->status, &ev->bdaddr, ev->bdaddr_type, in hci_le_conn_complete_evt()
4950 static void hci_le_enh_conn_complete_evt(struct hci_dev *hdev, in hci_le_enh_conn_complete_evt() argument
4955 BT_DBG("%s status 0x%2.2x", hdev->name, ev->status); in hci_le_enh_conn_complete_evt()
4957 le_conn_complete_evt(hdev, ev->status, &ev->bdaddr, ev->bdaddr_type, in hci_le_enh_conn_complete_evt()
4964 static void hci_le_ext_adv_term_evt(struct hci_dev *hdev, struct sk_buff *skb) in hci_le_ext_adv_term_evt() argument
4969 BT_DBG("%s status 0x%2.2x", hdev->name, ev->status); in hci_le_ext_adv_term_evt()
4974 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->conn_handle)); in hci_le_ext_adv_term_evt()
4978 if (hdev->adv_addr_type != ADDR_LE_DEV_RANDOM) in hci_le_ext_adv_term_evt()
4981 if (!hdev->cur_adv_instance) { in hci_le_ext_adv_term_evt()
4982 bacpy(&conn->resp_addr, &hdev->random_addr); in hci_le_ext_adv_term_evt()
4986 adv_instance = hci_find_adv_instance(hdev, hdev->cur_adv_instance); in hci_le_ext_adv_term_evt()
4992 static void hci_le_conn_update_complete_evt(struct hci_dev *hdev, in hci_le_conn_update_complete_evt() argument
4998 BT_DBG("%s status 0x%2.2x", hdev->name, ev->status); in hci_le_conn_update_complete_evt()
5003 hci_dev_lock(hdev); in hci_le_conn_update_complete_evt()
5005 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_conn_update_complete_evt()
5012 hci_dev_unlock(hdev); in hci_le_conn_update_complete_evt()
5016 static struct hci_conn *check_pending_le_conn(struct hci_dev *hdev, in check_pending_le_conn() argument
5029 if (hci_bdaddr_list_lookup(&hdev->blacklist, addr, addr_type)) in check_pending_le_conn()
5035 if (hdev->conn_hash.le_num_slave > 0) in check_pending_le_conn()
5041 params = hci_pend_le_action_lookup(&hdev->pend_le_conns, addr, in check_pending_le_conn()
5069 conn = hci_connect_le(hdev, addr, addr_type, BT_SECURITY_LOW, in check_pending_le_conn()
5104 static void process_adv_report(struct hci_dev *hdev, u8 type, bdaddr_t *bdaddr, in process_adv_report() argument
5108 struct discovery_state *d = &hdev->discovery; in process_adv_report()
5123 bt_dev_err_ratelimited(hdev, "unknown advertising packet " in process_adv_report()
5143 bt_dev_err_ratelimited(hdev, "advertising data len corrected"); in process_adv_report()
5162 if (!hci_dev_test_flag(hdev, HCI_PRIVACY)) in process_adv_report()
5169 if (!smp_irk_matches(hdev, hdev->irk, direct_addr)) in process_adv_report()
5174 irk = hci_get_irk(hdev, bdaddr, bdaddr_type); in process_adv_report()
5185 conn = check_pending_le_conn(hdev, bdaddr, bdaddr_type, type, in process_adv_report()
5199 if (hdev->le_scan_type == LE_SCAN_PASSIVE) { in process_adv_report()
5203 if (!hci_pend_le_action_lookup(&hdev->pend_le_reports, in process_adv_report()
5211 mgmt_device_found(hdev, bdaddr, LE_LINK, bdaddr_type, NULL, in process_adv_report()
5241 if (!has_pending_adv_report(hdev)) { in process_adv_report()
5246 store_pending_adv_report(hdev, bdaddr, bdaddr_type, in process_adv_report()
5251 mgmt_device_found(hdev, bdaddr, LE_LINK, bdaddr_type, NULL, in process_adv_report()
5267 mgmt_device_found(hdev, &d->last_adv_addr, LE_LINK, in process_adv_report()
5277 store_pending_adv_report(hdev, bdaddr, bdaddr_type, in process_adv_report()
5285 clear_pending_adv_report(hdev); in process_adv_report()
5286 mgmt_device_found(hdev, bdaddr, LE_LINK, bdaddr_type, NULL, in process_adv_report()
5295 mgmt_device_found(hdev, &d->last_adv_addr, LE_LINK, in process_adv_report()
5298 clear_pending_adv_report(hdev); in process_adv_report()
5301 static void hci_le_adv_report_evt(struct hci_dev *hdev, struct sk_buff *skb) in hci_le_adv_report_evt() argument
5306 hci_dev_lock(hdev); in hci_le_adv_report_evt()
5314 process_adv_report(hdev, ev->evt_type, &ev->bdaddr, in hci_le_adv_report_evt()
5318 bt_dev_err(hdev, "Dropping invalid advertising data"); in hci_le_adv_report_evt()
5324 hci_dev_unlock(hdev); in hci_le_adv_report_evt()
5373 static void hci_le_ext_adv_report_evt(struct hci_dev *hdev, struct sk_buff *skb) in hci_le_ext_adv_report_evt() argument
5378 hci_dev_lock(hdev); in hci_le_ext_adv_report_evt()
5388 process_adv_report(hdev, legacy_evt_type, &ev->bdaddr, in hci_le_ext_adv_report_evt()
5396 hci_dev_unlock(hdev); in hci_le_ext_adv_report_evt()
5399 static void hci_le_remote_feat_complete_evt(struct hci_dev *hdev, in hci_le_remote_feat_complete_evt() argument
5405 BT_DBG("%s status 0x%2.2x", hdev->name, ev->status); in hci_le_remote_feat_complete_evt()
5407 hci_dev_lock(hdev); in hci_le_remote_feat_complete_evt()
5409 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_remote_feat_complete_evt()
5426 if ((hdev->le_features[0] & HCI_LE_SLAVE_FEATURES) && in hci_le_remote_feat_complete_evt()
5438 hci_dev_unlock(hdev); in hci_le_remote_feat_complete_evt()
5441 static void hci_le_ltk_request_evt(struct hci_dev *hdev, struct sk_buff *skb) in hci_le_ltk_request_evt() argument
5449 BT_DBG("%s handle 0x%4.4x", hdev->name, __le16_to_cpu(ev->handle)); in hci_le_ltk_request_evt()
5451 hci_dev_lock(hdev); in hci_le_ltk_request_evt()
5453 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); in hci_le_ltk_request_evt()
5457 ltk = hci_find_ltk(hdev, &conn->dst, conn->dst_type, conn->role); in hci_le_ltk_request_evt()
5479 hci_send_cmd(hdev, HCI_OP_LE_LTK_REPLY, sizeof(cp), &cp); in hci_le_ltk_request_evt()
5495 hci_dev_unlock(hdev); in hci_le_ltk_request_evt()
5501 hci_send_cmd(hdev, HCI_OP_LE_LTK_NEG_REPLY, sizeof(neg), &neg); in hci_le_ltk_request_evt()
5502 hci_dev_unlock(hdev); in hci_le_ltk_request_evt()
5505 static void send_conn_param_neg_reply(struct hci_dev *hdev, u16 handle, in send_conn_param_neg_reply() argument
5513 hci_send_cmd(hdev, HCI_OP_LE_CONN_PARAM_REQ_NEG_REPLY, sizeof(cp), in send_conn_param_neg_reply()
5517 static void hci_le_remote_conn_param_req_evt(struct hci_dev *hdev, in hci_le_remote_conn_param_req_evt() argument
5531 hcon = hci_conn_hash_lookup_handle(hdev, handle); in hci_le_remote_conn_param_req_evt()
5533 return send_conn_param_neg_reply(hdev, handle, in hci_le_remote_conn_param_req_evt()
5537 return send_conn_param_neg_reply(hdev, handle, in hci_le_remote_conn_param_req_evt()
5544 hci_dev_lock(hdev); in hci_le_remote_conn_param_req_evt()
5546 params = hci_conn_params_lookup(hdev, &hcon->dst, in hci_le_remote_conn_param_req_evt()
5558 hci_dev_unlock(hdev); in hci_le_remote_conn_param_req_evt()
5560 mgmt_new_conn_param(hdev, &hcon->dst, hcon->dst_type, in hci_le_remote_conn_param_req_evt()
5572 hci_send_cmd(hdev, HCI_OP_LE_CONN_PARAM_REQ_REPLY, sizeof(cp), &cp); in hci_le_remote_conn_param_req_evt()
5575 static void hci_le_direct_adv_report_evt(struct hci_dev *hdev, in hci_le_direct_adv_report_evt() argument
5581 hci_dev_lock(hdev); in hci_le_direct_adv_report_evt()
5586 process_adv_report(hdev, ev->evt_type, &ev->bdaddr, in hci_le_direct_adv_report_evt()
5593 hci_dev_unlock(hdev); in hci_le_direct_adv_report_evt()
5596 static void hci_le_meta_evt(struct hci_dev *hdev, struct sk_buff *skb) in hci_le_meta_evt() argument
5604 hci_le_conn_complete_evt(hdev, skb); in hci_le_meta_evt()
5608 hci_le_conn_update_complete_evt(hdev, skb); in hci_le_meta_evt()
5612 hci_le_adv_report_evt(hdev, skb); in hci_le_meta_evt()
5616 hci_le_remote_feat_complete_evt(hdev, skb); in hci_le_meta_evt()
5620 hci_le_ltk_request_evt(hdev, skb); in hci_le_meta_evt()
5624 hci_le_remote_conn_param_req_evt(hdev, skb); in hci_le_meta_evt()
5628 hci_le_direct_adv_report_evt(hdev, skb); in hci_le_meta_evt()
5632 hci_le_ext_adv_report_evt(hdev, skb); in hci_le_meta_evt()
5636 hci_le_enh_conn_complete_evt(hdev, skb); in hci_le_meta_evt()
5640 hci_le_ext_adv_term_evt(hdev, skb); in hci_le_meta_evt()
5648 static bool hci_get_cmd_complete(struct hci_dev *hdev, u16 opcode, in hci_get_cmd_complete() argument
5658 bt_dev_err(hdev, "too short HCI event"); in hci_get_cmd_complete()
5672 bt_dev_err(hdev, "last event is not cmd complete (0x%2.2x)", in hci_get_cmd_complete()
5678 bt_dev_err(hdev, "too short cmd_complete event"); in hci_get_cmd_complete()
5694 void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb) in hci_event_packet() argument
5703 if (hdev->sent_cmd && bt_cb(hdev->sent_cmd)->hci.req_event == event) { in hci_event_packet()
5704 struct hci_command_hdr *cmd_hdr = (void *) hdev->sent_cmd->data; in hci_event_packet()
5706 hci_req_cmd_complete(hdev, opcode, status, &req_complete, in hci_event_packet()
5724 hci_inquiry_complete_evt(hdev, skb); in hci_event_packet()
5728 hci_inquiry_result_evt(hdev, skb); in hci_event_packet()
5732 hci_conn_complete_evt(hdev, skb); in hci_event_packet()
5736 hci_conn_request_evt(hdev, skb); in hci_event_packet()
5740 hci_disconn_complete_evt(hdev, skb); in hci_event_packet()
5744 hci_auth_complete_evt(hdev, skb); in hci_event_packet()
5748 hci_remote_name_evt(hdev, skb); in hci_event_packet()
5752 hci_encrypt_change_evt(hdev, skb); in hci_event_packet()
5756 hci_change_link_key_complete_evt(hdev, skb); in hci_event_packet()
5760 hci_remote_features_evt(hdev, skb); in hci_event_packet()
5764 hci_cmd_complete_evt(hdev, skb, &opcode, &status, in hci_event_packet()
5769 hci_cmd_status_evt(hdev, skb, &opcode, &status, &req_complete, in hci_event_packet()
5774 hci_hardware_error_evt(hdev, skb); in hci_event_packet()
5778 hci_role_change_evt(hdev, skb); in hci_event_packet()
5782 hci_num_comp_pkts_evt(hdev, skb); in hci_event_packet()
5786 hci_mode_change_evt(hdev, skb); in hci_event_packet()
5790 hci_pin_code_request_evt(hdev, skb); in hci_event_packet()
5794 hci_link_key_request_evt(hdev, skb); in hci_event_packet()
5798 hci_link_key_notify_evt(hdev, skb); in hci_event_packet()
5802 hci_clock_offset_evt(hdev, skb); in hci_event_packet()
5806 hci_pkt_type_change_evt(hdev, skb); in hci_event_packet()
5810 hci_pscan_rep_mode_evt(hdev, skb); in hci_event_packet()
5814 hci_inquiry_result_with_rssi_evt(hdev, skb); in hci_event_packet()
5818 hci_remote_ext_features_evt(hdev, skb); in hci_event_packet()
5822 hci_sync_conn_complete_evt(hdev, skb); in hci_event_packet()
5826 hci_extended_inquiry_result_evt(hdev, skb); in hci_event_packet()
5830 hci_key_refresh_complete_evt(hdev, skb); in hci_event_packet()
5834 hci_io_capa_request_evt(hdev, skb); in hci_event_packet()
5838 hci_io_capa_reply_evt(hdev, skb); in hci_event_packet()
5842 hci_user_confirm_request_evt(hdev, skb); in hci_event_packet()
5846 hci_user_passkey_request_evt(hdev, skb); in hci_event_packet()
5850 hci_user_passkey_notify_evt(hdev, skb); in hci_event_packet()
5854 hci_keypress_notify_evt(hdev, skb); in hci_event_packet()
5858 hci_simple_pair_complete_evt(hdev, skb); in hci_event_packet()
5862 hci_remote_host_features_evt(hdev, skb); in hci_event_packet()
5866 hci_le_meta_evt(hdev, skb); in hci_event_packet()
5870 hci_remote_oob_data_request_evt(hdev, skb); in hci_event_packet()
5875 hci_chan_selected_evt(hdev, skb); in hci_event_packet()
5879 hci_phy_link_complete_evt(hdev, skb); in hci_event_packet()
5883 hci_loglink_complete_evt(hdev, skb); in hci_event_packet()
5887 hci_disconn_loglink_complete_evt(hdev, skb); in hci_event_packet()
5891 hci_disconn_phylink_complete_evt(hdev, skb); in hci_event_packet()
5896 hci_num_comp_blocks_evt(hdev, skb); in hci_event_packet()
5900 BT_DBG("%s event 0x%2.2x", hdev->name, event); in hci_event_packet()
5905 req_complete(hdev, status, opcode); in hci_event_packet()
5907 if (!hci_get_cmd_complete(hdev, opcode, req_evt, orig_skb)) { in hci_event_packet()
5911 req_complete_skb(hdev, status, opcode, orig_skb); in hci_event_packet()
5916 hdev->stat.evt_rx++; in hci_event_packet()