Lines Matching +full:local +full:- +full:bd +full:- +full:address

1 // SPDX-License-Identifier: GPL-2.0
3 * BlueZ - Bluetooth protocol stack for Linux
29 if (hdev->req_status != HCI_REQ_PEND) in hci_cmd_sync_complete()
32 hdev->req_result = result; in hci_cmd_sync_complete()
33 hdev->req_status = HCI_REQ_DONE; in hci_cmd_sync_complete()
42 hdev->req_skb = skb_get(skb); in hci_cmd_sync_complete()
45 wake_up_interruptible(&hdev->req_wait_q); in hci_cmd_sync_complete()
61 hdr->opcode = cpu_to_le16(opcode); in hci_cmd_sync_alloc()
62 hdr->plen = plen; in hci_cmd_sync_alloc()
67 bt_dev_dbg(hdev, "skb len %d", skb->len); in hci_cmd_sync_alloc()
86 struct hci_dev *hdev = req->hdev; in hci_cmd_sync_add()
94 if (req->err) in hci_cmd_sync_add()
101 req->err = -ENOMEM; in hci_cmd_sync_add()
105 if (skb_queue_empty(&req->cmd_q)) in hci_cmd_sync_add()
106 bt_cb(skb)->hci.req_flags |= HCI_REQ_START; in hci_cmd_sync_add()
110 skb_queue_tail(&req->cmd_q, skb); in hci_cmd_sync_add()
115 struct hci_dev *hdev = req->hdev; in hci_cmd_sync_run()
119 bt_dev_dbg(hdev, "length %u", skb_queue_len(&req->cmd_q)); in hci_cmd_sync_run()
124 if (req->err) { in hci_cmd_sync_run()
125 skb_queue_purge(&req->cmd_q); in hci_cmd_sync_run()
126 return req->err; in hci_cmd_sync_run()
130 if (skb_queue_empty(&req->cmd_q)) in hci_cmd_sync_run()
131 return -ENODATA; in hci_cmd_sync_run()
133 skb = skb_peek_tail(&req->cmd_q); in hci_cmd_sync_run()
134 bt_cb(skb)->hci.req_complete_skb = hci_cmd_sync_complete; in hci_cmd_sync_run()
135 bt_cb(skb)->hci.req_flags |= HCI_REQ_SKB; in hci_cmd_sync_run()
137 spin_lock_irqsave(&hdev->cmd_q.lock, flags); in hci_cmd_sync_run()
138 skb_queue_splice_tail(&req->cmd_q, &hdev->cmd_q); in hci_cmd_sync_run()
139 spin_unlock_irqrestore(&hdev->cmd_q.lock, flags); in hci_cmd_sync_run()
141 queue_work(hdev->workqueue, &hdev->cmd_work); in hci_cmd_sync_run()
146 /* This function requires the caller holds hdev->req_lock. */
161 hdev->req_status = HCI_REQ_PEND; in __hci_cmd_sync_sk()
167 err = wait_event_interruptible_timeout(hdev->req_wait_q, in __hci_cmd_sync_sk()
168 hdev->req_status != HCI_REQ_PEND, in __hci_cmd_sync_sk()
171 if (err == -ERESTARTSYS) in __hci_cmd_sync_sk()
172 return ERR_PTR(-EINTR); in __hci_cmd_sync_sk()
174 switch (hdev->req_status) { in __hci_cmd_sync_sk()
176 err = -bt_to_errno(hdev->req_result); in __hci_cmd_sync_sk()
180 err = -hdev->req_result; in __hci_cmd_sync_sk()
184 err = -ETIMEDOUT; in __hci_cmd_sync_sk()
188 hdev->req_status = 0; in __hci_cmd_sync_sk()
189 hdev->req_result = 0; in __hci_cmd_sync_sk()
190 skb = hdev->req_skb; in __hci_cmd_sync_sk()
191 hdev->req_skb = NULL; in __hci_cmd_sync_sk()
204 /* This function requires the caller holds hdev->req_lock. */
218 if (!test_bit(HCI_UP, &hdev->flags)) in hci_cmd_sync()
219 return ERR_PTR(-ENETDOWN); in hci_cmd_sync()
231 /* This function requires the caller holds hdev->req_lock. */
240 /* This function requires the caller holds hdev->req_lock. */
263 status = skb->data[0]; in __hci_cmd_sync_status_sk()
289 mutex_lock(&hdev->cmd_sync_work_lock); in hci_cmd_sync_work()
290 entry = list_first_entry_or_null(&hdev->cmd_sync_work_list, in hci_cmd_sync_work()
294 list_del(&entry->list); in hci_cmd_sync_work()
295 mutex_unlock(&hdev->cmd_sync_work_lock); in hci_cmd_sync_work()
302 if (entry->func) { in hci_cmd_sync_work()
306 err = entry->func(hdev, entry->data); in hci_cmd_sync_work()
307 if (entry->destroy) in hci_cmd_sync_work()
308 entry->destroy(hdev, entry->data, err); in hci_cmd_sync_work()
320 cancel_delayed_work_sync(&hdev->cmd_timer); in hci_cmd_sync_cancel_work()
321 cancel_delayed_work_sync(&hdev->ncmd_timer); in hci_cmd_sync_cancel_work()
322 atomic_set(&hdev->cmd_cnt, 1); in hci_cmd_sync_cancel_work()
324 wake_up_interruptible(&hdev->req_wait_q); in hci_cmd_sync_cancel_work()
357 hdev->discovery.scan_start = 0; in le_scan_disable()
367 if (hdev->discovery.type == DISCOV_TYPE_LE) in le_scan_disable()
370 if (hdev->discovery.type != DISCOV_TYPE_INTERLEAVED) in le_scan_disable()
373 if (test_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks)) { in le_scan_disable()
374 if (!test_bit(HCI_INQUIRY, &hdev->flags) && in le_scan_disable()
375 hdev->discovery.state != DISCOVERY_RESOLVING) in le_scan_disable()
404 list_empty(&hdev->adv_instances)) in reenable_adv_sync()
407 if (hdev->cur_adv_instance) { in reenable_adv_sync()
409 hdev->cur_adv_instance, in reenable_adv_sync()
443 if (hdev->adv_instance_timeout) { in cancel_adv_timeout()
444 hdev->adv_instance_timeout = 0; in cancel_adv_timeout()
445 cancel_delayed_work(&hdev->adv_instance_expire); in cancel_adv_timeout()
450 * - force == true: The instance will be removed even when its remaining
452 * - force == false: the instance will be deactivated but kept stored unless
456 * - force == true: All instances will be removed regardless of their timeout
458 * - force == false: Only instances that have a timeout will be removed.
468 if (!instance || hdev->cur_adv_instance == instance) in hci_clear_adv_instance_sync()
475 if (instance && hdev->cur_adv_instance == instance) in hci_clear_adv_instance_sync()
479 list_for_each_entry_safe(adv_instance, n, &hdev->adv_instances, in hci_clear_adv_instance_sync()
481 if (!(force || adv_instance->timeout)) in hci_clear_adv_instance_sync()
484 rem_inst = adv_instance->instance; in hci_clear_adv_instance_sync()
492 if (force || (adv_instance && adv_instance->timeout && in hci_clear_adv_instance_sync()
493 !adv_instance->remaining_time)) { in hci_clear_adv_instance_sync()
496 next_instance->instance == instance) in hci_clear_adv_instance_sync()
510 next_instance->instance, in hci_clear_adv_instance_sync()
524 if (list_empty(&hdev->adv_instances)) in adv_timeout_expire_sync()
540 hdev->adv_instance_timeout = 0; in adv_timeout_expire()
542 if (hdev->cur_adv_instance == 0x00) in adv_timeout_expire()
549 *inst_ptr = hdev->cur_adv_instance; in adv_timeout_expire()
558 INIT_WORK(&hdev->cmd_sync_work, hci_cmd_sync_work); in hci_cmd_sync_init()
559 INIT_LIST_HEAD(&hdev->cmd_sync_work_list); in hci_cmd_sync_init()
560 mutex_init(&hdev->cmd_sync_work_lock); in hci_cmd_sync_init()
561 mutex_init(&hdev->unregister_lock); in hci_cmd_sync_init()
563 INIT_WORK(&hdev->cmd_sync_cancel_work, hci_cmd_sync_cancel_work); in hci_cmd_sync_init()
564 INIT_WORK(&hdev->reenable_adv_work, reenable_adv); in hci_cmd_sync_init()
565 INIT_DELAYED_WORK(&hdev->le_scan_disable, le_scan_disable); in hci_cmd_sync_init()
566 INIT_DELAYED_WORK(&hdev->adv_instance_expire, adv_timeout_expire); in hci_cmd_sync_init()
573 cancel_work_sync(&hdev->cmd_sync_work); in hci_cmd_sync_clear()
574 cancel_work_sync(&hdev->reenable_adv_work); in hci_cmd_sync_clear()
576 mutex_lock(&hdev->cmd_sync_work_lock); in hci_cmd_sync_clear()
577 list_for_each_entry_safe(entry, tmp, &hdev->cmd_sync_work_list, list) { in hci_cmd_sync_clear()
578 if (entry->destroy) in hci_cmd_sync_clear()
579 entry->destroy(hdev, entry->data, -ECANCELED); in hci_cmd_sync_clear()
581 list_del(&entry->list); in hci_cmd_sync_clear()
584 mutex_unlock(&hdev->cmd_sync_work_lock); in hci_cmd_sync_clear()
591 if (hdev->req_status == HCI_REQ_PEND) { in __hci_cmd_sync_cancel()
592 hdev->req_result = err; in __hci_cmd_sync_cancel()
593 hdev->req_status = HCI_REQ_CANCELED; in __hci_cmd_sync_cancel()
595 cancel_delayed_work_sync(&hdev->cmd_timer); in __hci_cmd_sync_cancel()
596 cancel_delayed_work_sync(&hdev->ncmd_timer); in __hci_cmd_sync_cancel()
597 atomic_set(&hdev->cmd_cnt, 1); in __hci_cmd_sync_cancel()
599 wake_up_interruptible(&hdev->req_wait_q); in __hci_cmd_sync_cancel()
607 if (hdev->req_status == HCI_REQ_PEND) { in hci_cmd_sync_cancel()
608 hdev->req_result = err; in hci_cmd_sync_cancel()
609 hdev->req_status = HCI_REQ_CANCELED; in hci_cmd_sync_cancel()
611 queue_work(hdev->workqueue, &hdev->cmd_sync_cancel_work); in hci_cmd_sync_cancel()
618 * - hdev must _not_ be unregistered
626 mutex_lock(&hdev->unregister_lock); in hci_cmd_sync_submit()
628 err = -ENODEV; in hci_cmd_sync_submit()
634 err = -ENOMEM; in hci_cmd_sync_submit()
637 entry->func = func; in hci_cmd_sync_submit()
638 entry->data = data; in hci_cmd_sync_submit()
639 entry->destroy = destroy; in hci_cmd_sync_submit()
641 mutex_lock(&hdev->cmd_sync_work_lock); in hci_cmd_sync_submit()
642 list_add_tail(&entry->list, &hdev->cmd_sync_work_list); in hci_cmd_sync_submit()
643 mutex_unlock(&hdev->cmd_sync_work_lock); in hci_cmd_sync_submit()
645 queue_work(hdev->req_workqueue, &hdev->cmd_sync_work); in hci_cmd_sync_submit()
648 mutex_unlock(&hdev->unregister_lock); in hci_cmd_sync_submit()
655 * - hdev must be running
663 if (!test_bit(HCI_RUNNING, &hdev->flags)) in hci_cmd_sync_queue()
664 return -ENETDOWN; in hci_cmd_sync_queue()
692 if (memcmp(cp.data, hdev->eir, sizeof(cp.data)) == 0) in hci_update_eir_sync()
695 memcpy(hdev->eir, cp.data, sizeof(cp.data)); in hci_update_eir_sync()
706 list_for_each_entry(uuid, &hdev->uuids, list) in get_service_classes()
707 val |= uuid->svc_hint; in get_service_classes()
727 cod[0] = hdev->minor_class; in hci_update_class_sync()
728 cod[1] = hdev->major_class; in hci_update_class_sync()
734 if (memcmp(cod, hdev->dev_class, 3) == 0) in hci_update_class_sync()
748 if (hdev->conn_hash.le_num_peripheral > 0) { in is_advertising_allowed()
752 if (!connectable && !(hdev->le_states[2] & 0x10)) in is_advertising_allowed()
758 if (connectable && (!(hdev->le_states[4] & 0x40) || in is_advertising_allowed()
759 !(hdev->le_states[2] & 0x20))) in is_advertising_allowed()
764 if (hci_conn_num(hdev, LE_LINK) != hdev->conn_hash.le_num_peripheral) { in is_advertising_allowed()
766 if (!connectable && !(hdev->le_states[2] & 0x02)) in is_advertising_allowed()
772 if (connectable && (!(hdev->le_states[4] & 0x08) || in is_advertising_allowed()
773 !(hdev->le_states[2] & 0x08))) in is_advertising_allowed()
806 * go ahead and change the random address at this time. This is in hci_set_random_addr_sync()
807 * because the eventual initiator address used for the in hci_set_random_addr_sync()
809 * controllers use the new address and others the one we had in hci_set_random_addr_sync()
813 * address be updated at the next cycle. in hci_set_random_addr_sync()
817 bt_dev_dbg(hdev, "Deferring random address update"); in hci_set_random_addr_sync()
831 /* If privacy is enabled use a resolvable private address. If in hci_update_random_address_sync()
836 /* If Controller supports LL Privacy use own address type is in hci_update_random_address_sync()
848 err = smp_generate_rpa(hdev, hdev->irk, &hdev->rpa); in hci_update_random_address_sync()
854 err = hci_set_random_addr_sync(hdev, &hdev->rpa); in hci_update_random_address_sync()
861 /* In case of required privacy without resolvable private address, in hci_update_random_address_sync()
862 * use an non-resolvable private address. This is useful for active in hci_update_random_address_sync()
863 * scanning and non-connectable advertising. in hci_update_random_address_sync()
869 /* The non-resolvable private address is generated in hci_update_random_address_sync()
876 /* The non-resolvable private address shall not be in hci_update_random_address_sync()
877 * equal to the public address. in hci_update_random_address_sync()
879 if (bacmp(&hdev->bdaddr, &nrpa)) in hci_update_random_address_sync()
888 /* If forcing static address is in use or there is no public in hci_update_random_address_sync()
889 * address use the static address as random address (but skip in hci_update_random_address_sync()
890 * the HCI command if the current random address is already the in hci_update_random_address_sync()
893 * In case BR/EDR has been disabled on a dual-mode controller in hci_update_random_address_sync()
894 * and a static address has been configured, then use that in hci_update_random_address_sync()
895 * address instead of the public BR/EDR address. in hci_update_random_address_sync()
898 !bacmp(&hdev->bdaddr, BDADDR_ANY) || in hci_update_random_address_sync()
900 bacmp(&hdev->static_addr, BDADDR_ANY))) { in hci_update_random_address_sync()
902 if (bacmp(&hdev->static_addr, &hdev->random_addr)) in hci_update_random_address_sync()
904 &hdev->static_addr); in hci_update_random_address_sync()
908 /* Neither privacy nor static address is being used so use a in hci_update_random_address_sync()
909 * public address. in hci_update_random_address_sync()
929 return -EINVAL; in hci_disable_ext_adv_instance_sync()
932 if (!adv->enabled) in hci_disable_ext_adv_instance_sync()
939 set = (void *)cp->data; in hci_disable_ext_adv_instance_sync()
942 cp->num_of_sets = !!instance; in hci_disable_ext_adv_instance_sync()
943 cp->enable = 0x00; in hci_disable_ext_adv_instance_sync()
945 set->handle = instance; in hci_disable_ext_adv_instance_sync()
947 size = sizeof(*cp) + sizeof(*set) * cp->num_of_sets; in hci_disable_ext_adv_instance_sync()
961 * hdev->random_addr to track its address so whenever it needs in hci_set_adv_set_random_addr_sync()
962 * to be updated this also set the random address since in hci_set_adv_set_random_addr_sync()
963 * hdev->random_addr is shared with scan state machine. in hci_set_adv_set_random_addr_sync()
993 return -EINVAL; in hci_setup_ext_adv_instance_sync()
1002 if (adv && !adv->pending) { in hci_setup_ext_adv_instance_sync()
1017 return -EPERM; in hci_setup_ext_adv_instance_sync()
1019 /* Set require_privacy to true only when non-connectable in hci_setup_ext_adv_instance_sync()
1021 * non-resolvable private address. in hci_setup_ext_adv_instance_sync()
1032 hci_cpu_to_le24(adv->min_interval, cp.min_interval); in hci_setup_ext_adv_instance_sync()
1033 hci_cpu_to_le24(adv->max_interval, cp.max_interval); in hci_setup_ext_adv_instance_sync()
1034 cp.tx_power = adv->tx_power; in hci_setup_ext_adv_instance_sync()
1036 hci_cpu_to_le24(hdev->le_adv_min_interval, cp.min_interval); in hci_setup_ext_adv_instance_sync()
1037 hci_cpu_to_le24(hdev->le_adv_max_interval, cp.max_interval); in hci_setup_ext_adv_instance_sync()
1062 * contains the peer’s Identity Address and the Peer_Address_Type in hci_setup_ext_adv_instance_sync()
1064 * These parameters are used to locate the corresponding local IRK in in hci_setup_ext_adv_instance_sync()
1065 * the resolving list; this IRK is used to generate their own address in hci_setup_ext_adv_instance_sync()
1073 cp.channel_map = hdev->le_adv_channel_map; in hci_setup_ext_adv_instance_sync()
1096 /* Check if random address need to be updated */ in hci_setup_ext_adv_instance_sync()
1098 if (!bacmp(&random_addr, &adv->random_addr)) in hci_setup_ext_adv_instance_sync()
1101 if (!bacmp(&random_addr, &hdev->random_addr)) in hci_setup_ext_adv_instance_sync()
1126 if (!adv || !adv->scan_rsp_changed) in hci_set_ext_scan_rsp_data_sync()
1144 adv->scan_rsp_changed = false; in hci_set_ext_scan_rsp_data_sync()
1146 memcpy(hdev->scan_rsp_data, pdu.data, len); in hci_set_ext_scan_rsp_data_sync()
1147 hdev->scan_rsp_data_len = len; in hci_set_ext_scan_rsp_data_sync()
1162 if (hdev->scan_rsp_data_len == len && in __hci_set_scan_rsp_data_sync()
1163 !memcmp(cp.data, hdev->scan_rsp_data, len)) in __hci_set_scan_rsp_data_sync()
1166 memcpy(hdev->scan_rsp_data, cp.data, sizeof(cp.data)); in __hci_set_scan_rsp_data_sync()
1167 hdev->scan_rsp_data_len = len; in __hci_set_scan_rsp_data_sync()
1196 return -EINVAL; in hci_enable_ext_advertising_sync()
1198 if (adv->enabled) in hci_enable_ext_advertising_sync()
1205 set = (void *)cp->data; in hci_enable_ext_advertising_sync()
1209 cp->enable = 0x01; in hci_enable_ext_advertising_sync()
1210 cp->num_of_sets = 0x01; in hci_enable_ext_advertising_sync()
1214 set->handle = instance; in hci_enable_ext_advertising_sync()
1219 if (adv && adv->timeout) { in hci_enable_ext_advertising_sync()
1220 u16 duration = adv->timeout * MSEC_PER_SEC; in hci_enable_ext_advertising_sync()
1223 set->duration = cpu_to_le16(duration / 10); in hci_enable_ext_advertising_sync()
1228 sizeof(*set) * cp->num_of_sets, in hci_enable_ext_advertising_sync()
1254 if (!adv || !adv->periodic || !adv->enabled) in hci_disable_per_advertising_sync()
1301 if (!adv || !adv->periodic) in hci_set_per_adv_data_sync()
1323 if (adv && adv->periodic && adv->enabled) in hci_enable_per_advertising_sync()
1353 if (!eir_get_service_data(adv->per_adv_data, adv->per_adv_data_len, in hci_adv_bcast_annoucement()
1361 if (eir_get_service_data(adv->adv_data, adv->adv_data_len, 0x1852, in hci_adv_bcast_annoucement()
1368 hci_set_adv_instance_data(hdev, adv->instance, sizeof(ad), ad, 0, NULL); in hci_adv_bcast_annoucement()
1370 return hci_update_adv_data_sync(hdev, adv->instance); in hci_adv_bcast_annoucement()
1393 adv->pending = false; in hci_start_per_adv_sync()
1459 hdev->cur_adv_instance); in hci_enable_advertising_sync()
1461 flags = hci_adv_instance_flags(hdev, hdev->cur_adv_instance); in hci_enable_advertising_sync()
1462 adv_instance = hci_find_adv_instance(hdev, hdev->cur_adv_instance); in hci_enable_advertising_sync()
1471 return -EINVAL; in hci_enable_advertising_sync()
1479 * and write a new random address. The flag will be set back on in hci_enable_advertising_sync()
1484 /* Set require_privacy to true only when non-connectable in hci_enable_advertising_sync()
1486 * non-resolvable private address. in hci_enable_advertising_sync()
1497 adv_min_interval = adv_instance->min_interval; in hci_enable_advertising_sync()
1498 adv_max_interval = adv_instance->max_interval; in hci_enable_advertising_sync()
1500 adv_min_interval = hdev->le_adv_min_interval; in hci_enable_advertising_sync()
1501 adv_max_interval = hdev->le_adv_max_interval; in hci_enable_advertising_sync()
1507 if (hci_adv_instance_is_scannable(hdev, hdev->cur_adv_instance)) in hci_enable_advertising_sync()
1522 cp.channel_map = hdev->le_adv_channel_map; in hci_enable_advertising_sync()
1541 list_empty(&hdev->adv_instances)) in hci_enable_advertising()
1561 return -EINVAL; in hci_remove_ext_adv_instance_sync()
1574 instance = adv->instance; in remove_ext_adv_sync()
1586 return -EINVAL; in hci_remove_ext_adv_instance()
1618 if (!adv || !adv->adv_data_changed) in hci_set_ext_adv_data_sync()
1637 adv->adv_data_changed = false; in hci_set_ext_adv_data_sync()
1639 memcpy(hdev->adv_data, pdu.data, len); in hci_set_ext_adv_data_sync()
1640 hdev->adv_data_len = len; in hci_set_ext_adv_data_sync()
1656 if (hdev->adv_data_len == len && in hci_set_adv_data_sync()
1657 memcmp(cp.data, hdev->adv_data, len) == 0) in hci_set_adv_data_sync()
1660 memcpy(hdev->adv_data, cp.data, sizeof(cp.data)); in hci_set_adv_data_sync()
1661 hdev->adv_data_len = len; in hci_set_adv_data_sync()
1687 return -EPERM; in hci_schedule_adv_instance_sync()
1689 if (hdev->adv_instance_timeout) in hci_schedule_adv_instance_sync()
1690 return -EBUSY; in hci_schedule_adv_instance_sync()
1694 return -ENOENT; in hci_schedule_adv_instance_sync()
1704 if (adv->timeout == 0 || adv->duration <= adv->remaining_time) in hci_schedule_adv_instance_sync()
1705 timeout = adv->duration; in hci_schedule_adv_instance_sync()
1707 timeout = adv->remaining_time; in hci_schedule_adv_instance_sync()
1712 if (adv->timeout) in hci_schedule_adv_instance_sync()
1713 adv->remaining_time = adv->remaining_time - timeout; in hci_schedule_adv_instance_sync()
1717 hdev->adv_instance_timeout = timeout; in hci_schedule_adv_instance_sync()
1718 queue_delayed_work(hdev->req_workqueue, in hci_schedule_adv_instance_sync()
1719 &hdev->adv_instance_expire, in hci_schedule_adv_instance_sync()
1723 /* If we're just re-scheduling the same instance again then do not in hci_schedule_adv_instance_sync()
1727 if (!force && hdev->cur_adv_instance == instance && in hci_schedule_adv_instance_sync()
1731 hdev->cur_adv_instance = instance; in hci_schedule_adv_instance_sync()
1768 /* Cleanup non-ext instances */ in hci_clear_adv_sync()
1769 list_for_each_entry_safe(adv, n, &hdev->adv_instances, list) { in hci_clear_adv_sync()
1770 u8 instance = adv->instance; in hci_clear_adv_sync()
1773 if (!(force || adv->timeout)) in hci_clear_adv_sync()
1812 * - force == true: The instance will be removed even when its remaining
1814 * - force == false: the instance will be deactivated but kept stored unless
1818 * - force == true: All instances will be removed regardless of their timeout
1820 * - force == false: Only instances that have a timeout will be removed.
1829 if (!instance || hdev->cur_adv_instance == instance) in hci_remove_advertising_sync()
1836 if (hdev->cur_adv_instance == instance) in hci_remove_advertising_sync()
1846 if (force || (adv && adv->timeout && !adv->remaining_time)) { in hci_remove_advertising_sync()
1848 if (next && next->instance == instance) in hci_remove_advertising_sync()
1861 hci_schedule_adv_instance_sync(hdev, next->instance, false); in hci_remove_advertising_sync()
1967 if (hdev->scanning_paused) { in hci_scan_disable_sync()
1988 hdev->interleave_scan_state = INTERLEAVE_SCAN_NO_FILTER; in hci_start_interleave_scan()
1989 queue_delayed_work(hdev->req_workqueue, in hci_start_interleave_scan()
1990 &hdev->interleave_scan, 0); in hci_start_interleave_scan()
1995 return hdev->interleave_scan_state != INTERLEAVE_SCAN_NONE; in is_interleave_scanning()
2002 cancel_delayed_work_sync(&hdev->interleave_scan); in cancel_interleave_scan()
2004 hdev->interleave_scan_state = INTERLEAVE_SCAN_NONE; in cancel_interleave_scan()
2013 * - There is at least one ADV monitor in hci_update_interleaved_scan_sync()
2014 * - At least one pending LE connection or one device to be scanned for in hci_update_interleaved_scan_sync()
2015 * - Monitor offloading is not supported in hci_update_interleaved_scan_sync()
2020 !(list_empty(&hdev->pend_le_conns) && in hci_update_interleaved_scan_sync()
2021 list_empty(&hdev->pend_le_reports)) && in hci_update_interleaved_scan_sync()
2049 entry = hci_bdaddr_list_lookup_with_irk(&hdev->le_resolv_list, bdaddr, in hci_le_del_resolve_list_sync()
2068 if (!hci_bdaddr_list_lookup(&hdev->le_accept_list, bdaddr, bdaddr_type)) in hci_le_del_accept_list_sync()
2100 * Setting params to NULL programs local hdev->irk
2113 /* Attempt to program local identity address, type and irk if params is in hci_le_add_resolve_list_sync()
2121 memcpy(cp.peer_irk, hdev->irk, 16); in hci_le_add_resolve_list_sync()
2125 irk = hci_find_irk_by_addr(hdev, &params->addr, params->addr_type); in hci_le_add_resolve_list_sync()
2130 entry = hci_bdaddr_list_lookup_with_irk(&hdev->le_resolv_list, in hci_le_add_resolve_list_sync()
2131 &params->addr, in hci_le_add_resolve_list_sync()
2132 params->addr_type); in hci_le_add_resolve_list_sync()
2136 cp.bdaddr_type = params->addr_type; in hci_le_add_resolve_list_sync()
2137 bacpy(&cp.bdaddr, &params->addr); in hci_le_add_resolve_list_sync()
2138 memcpy(cp.peer_irk, irk->val, 16); in hci_le_add_resolve_list_sync()
2141 params->privacy_mode = HCI_NETWORK_PRIVACY; in hci_le_add_resolve_list_sync()
2144 p = hci_pend_le_action_lookup(&hdev->pend_le_conns, in hci_le_add_resolve_list_sync()
2145 &params->addr, params->addr_type); in hci_le_add_resolve_list_sync()
2147 p = hci_pend_le_action_lookup(&hdev->pend_le_reports, in hci_le_add_resolve_list_sync()
2148 &params->addr, params->addr_type); in hci_le_add_resolve_list_sync()
2150 WRITE_ONCE(p->privacy_mode, HCI_NETWORK_PRIVACY); in hci_le_add_resolve_list_sync()
2155 memcpy(cp.local_irk, hdev->irk, 16); in hci_le_add_resolve_list_sync()
2171 if (params->privacy_mode == HCI_DEVICE_PRIVACY) in hci_le_set_privacy_mode_sync()
2178 if (!(params->flags & HCI_CONN_FLAG_DEVICE_PRIVACY)) in hci_le_set_privacy_mode_sync()
2181 irk = hci_find_irk_by_addr(hdev, &params->addr, params->addr_type); in hci_le_set_privacy_mode_sync()
2186 cp.bdaddr_type = irk->addr_type; in hci_le_set_privacy_mode_sync()
2187 bacpy(&cp.bdaddr, &irk->bdaddr); in hci_le_set_privacy_mode_sync()
2190 /* Note: params->privacy_mode is not updated since it is a copy */ in hci_le_set_privacy_mode_sync()
2208 if (hdev->suspended && in hci_le_add_accept_list_sync()
2209 !(params->flags & HCI_CONN_FLAG_REMOTE_WAKEUP)) { in hci_le_add_accept_list_sync()
2210 hci_le_del_accept_list_sync(hdev, &params->addr, in hci_le_add_accept_list_sync()
2211 params->addr_type); in hci_le_add_accept_list_sync()
2216 if (*num_entries >= hdev->le_accept_list_size) in hci_le_add_accept_list_sync()
2217 return -ENOSPC; in hci_le_add_accept_list_sync()
2221 hci_find_irk_by_addr(hdev, &params->addr, params->addr_type)) in hci_le_add_accept_list_sync()
2222 return -EINVAL; in hci_le_add_accept_list_sync()
2242 if (hci_bdaddr_list_lookup(&hdev->le_accept_list, &params->addr, in hci_le_add_accept_list_sync()
2243 params->addr_type)) in hci_le_add_accept_list_sync()
2247 cp.bdaddr_type = params->addr_type; in hci_le_add_accept_list_sync()
2248 bacpy(&cp.bdaddr, &params->addr); in hci_le_add_accept_list_sync()
2272 if (hdev->advertising_paused) in hci_pause_advertising_sync()
2287 hdev->discov_timeout = 0; in hci_pause_advertising_sync()
2303 hdev->advertising_paused = true; in hci_pause_advertising_sync()
2304 hdev->advertising_old_state = old_state; in hci_pause_advertising_sync()
2316 if (!hdev->advertising_paused) in hci_resume_advertising_sync()
2320 hdev->advertising_paused = false; in hci_resume_advertising_sync()
2321 if (hdev->advertising_old_state) { in hci_resume_advertising_sync()
2323 hdev->advertising_old_state = 0; in hci_resume_advertising_sync()
2329 /* Call for each tracked instance to be re-enabled */ in hci_resume_advertising_sync()
2330 list_for_each_entry_safe(adv, tmp, &hdev->adv_instances, list) { in hci_resume_advertising_sync()
2332 adv->instance); in hci_resume_advertising_sync()
2337 hci_remove_ext_adv_instance_sync(hdev, adv->instance, in hci_resume_advertising_sync()
2345 hdev->cur_adv_instance, in hci_resume_advertising_sync()
2349 hdev->advertising_paused = false; in hci_resume_advertising_sync()
2370 return -EPERM; in hci_pause_addr_resolution()
2382 bt_dev_err(hdev, "Unable to disable Address Resolution: %d", in hci_pause_addr_resolution()
2385 /* Return if address resolution is disabled and RPA is not used. */ in hci_pause_addr_resolution()
2429 /* No hdev->lock, but: addr, addr_type are immutable. in conn_params_copy()
2435 bacpy(&p[i].addr, &params->addr); in conn_params_copy()
2436 p[i].addr_type = params->addr_type; in conn_params_copy()
2437 p[i].flags = READ_ONCE(params->flags); in conn_params_copy()
2438 p[i].privacy_mode = READ_ONCE(params->privacy_mode); in conn_params_copy()
2452 * use_ll_privacy((Disable Advertising) -> Disable Resolving List) ->
2453 * Remove Devices From Accept List ->
2454 * (has IRK && use_ll_privacy(Remove Devices From Resolving List))->
2455 * Add Devices to Accept List ->
2456 * (has IRK && use_ll_privacy(Remove Devices From Resolving List)) ->
2457 * use_ll_privacy(Enable Resolving List -> (Enable Advertising)) ->
2486 /* Disable address resolution while reprogramming accept list since in hci_update_accept_list_sync()
2497 * controller one by one and check if that address is connected or is in hci_update_accept_list_sync()
2502 list_for_each_entry_safe(b, t, &hdev->le_accept_list, list) { in hci_update_accept_list_sync()
2503 if (hci_conn_hash_lookup_le(hdev, &b->bdaddr, b->bdaddr_type)) in hci_update_accept_list_sync()
2507 pend_conn = hci_pend_le_action_lookup(&hdev->pend_le_conns, in hci_update_accept_list_sync()
2508 &b->bdaddr, in hci_update_accept_list_sync()
2509 b->bdaddr_type); in hci_update_accept_list_sync()
2510 pend_report = hci_pend_le_action_lookup(&hdev->pend_le_reports, in hci_update_accept_list_sync()
2511 &b->bdaddr, in hci_update_accept_list_sync()
2512 b->bdaddr_type); in hci_update_accept_list_sync()
2518 hci_le_del_accept_list_sync(hdev, &b->bdaddr, in hci_update_accept_list_sync()
2519 b->bdaddr_type); in hci_update_accept_list_sync()
2540 params = conn_params_copy(&hdev->pend_le_conns, &n); in hci_update_accept_list_sync()
2542 err = -ENOMEM; in hci_update_accept_list_sync()
2562 params = conn_params_copy(&hdev->pend_le_reports, &n); in hci_update_accept_list_sync()
2564 err = -ENOMEM; in hci_update_accept_list_sync()
2580 * - We are not currently suspending in hci_update_accept_list_sync()
2581 * - There are 1 or more ADV monitors registered and it's not offloaded in hci_update_accept_list_sync()
2582 * - Interleaved scanning is not currently using the allowlist in hci_update_accept_list_sync()
2584 if (!idr_is_empty(&hdev->adv_monitors_idr) && !hdev->suspended && in hci_update_accept_list_sync()
2586 hdev->interleave_scan_state != INTERLEAVE_SCAN_ALLOWLIST) in hci_update_accept_list_sync()
2587 err = -EINVAL; in hci_update_accept_list_sync()
2592 /* Enable address resolution when LL Privacy is enabled. */ in hci_update_accept_list_sync()
2615 phy = (void *)cp->data; in hci_le_set_ext_scan_param_sync()
2619 cp->own_addr_type = own_addr_type; in hci_le_set_ext_scan_param_sync()
2620 cp->filter_policy = filter_policy; in hci_le_set_ext_scan_param_sync()
2623 cp->scanning_phys |= LE_SCAN_PHY_1M; in hci_le_set_ext_scan_param_sync()
2625 phy->type = type; in hci_le_set_ext_scan_param_sync()
2626 phy->interval = cpu_to_le16(interval); in hci_le_set_ext_scan_param_sync()
2627 phy->window = cpu_to_le16(window); in hci_le_set_ext_scan_param_sync()
2634 cp->scanning_phys |= LE_SCAN_PHY_CODED; in hci_le_set_ext_scan_param_sync()
2636 phy->type = type; in hci_le_set_ext_scan_param_sync()
2637 phy->interval = cpu_to_le16(interval); in hci_le_set_ext_scan_param_sync()
2638 phy->window = cpu_to_le16(window); in hci_le_set_ext_scan_param_sync()
2677 if (hdev->scanning_paused) { in hci_start_scan_sync()
2698 if (hdev->scanning_paused) { in hci_passive_scan_sync()
2710 * during passive scanning. Not using an non-resolvable address in hci_passive_scan_sync()
2712 * advertising with our address will be correctly reported in hci_passive_scan_sync()
2719 if (hdev->enable_advmon_interleave_scan && in hci_passive_scan_sync()
2723 bt_dev_dbg(hdev, "interleave state %d", hdev->interleave_scan_state); in hci_passive_scan_sync()
2741 (hdev->le_features[0] & HCI_LE_EXT_SCAN_POLICY)) in hci_passive_scan_sync()
2744 if (hdev->suspended) { in hci_passive_scan_sync()
2745 window = hdev->le_scan_window_suspend; in hci_passive_scan_sync()
2746 interval = hdev->le_scan_int_suspend; in hci_passive_scan_sync()
2748 window = hdev->le_scan_window_connect; in hci_passive_scan_sync()
2749 interval = hdev->le_scan_int_connect; in hci_passive_scan_sync()
2751 window = hdev->le_scan_window_adv_monitor; in hci_passive_scan_sync()
2752 interval = hdev->le_scan_int_adv_monitor; in hci_passive_scan_sync()
2754 window = hdev->le_scan_window; in hci_passive_scan_sync()
2755 interval = hdev->le_scan_interval; in hci_passive_scan_sync()
2770 /* This function controls the passive scanning based on hdev->pend_le_conns
2776 * Disable Scanning -> Update Accept List ->
2777 * use_ll_privacy((Disable Advertising) -> Disable Resolving List ->
2778 * Update Resolving List -> Enable Resolving List -> (Enable Advertising)) ->
2789 if (!test_bit(HCI_UP, &hdev->flags) || in hci_update_passive_scan_sync()
2790 test_bit(HCI_INIT, &hdev->flags) || in hci_update_passive_scan_sync()
2802 if (hdev->discovery.state != DISCOVERY_STOPPED) in hci_update_passive_scan_sync()
2818 list_empty(&hdev->pend_le_conns) && in hci_update_passive_scan_sync()
2819 list_empty(&hdev->pend_le_reports) && in hci_update_passive_scan_sync()
2874 if (!test_bit(HCI_UP, &hdev->flags) || in hci_update_passive_scan()
2875 test_bit(HCI_INIT, &hdev->flags) || in hci_update_passive_scan()
2897 hdev->features[1][0] |= LMP_HOST_SC; in hci_write_sc_support_sync()
2900 hdev->features[1][0] &= ~LMP_HOST_SC; in hci_write_sc_support_sync()
2963 * local IRK in order to support using own_addr_type in hci_powered_update_adv_sync()
2976 list_empty(&hdev->adv_instances)) { in hci_powered_update_adv_sync()
2992 list_for_each_entry_safe(adv, tmp, &hdev->adv_instances, list) in hci_powered_update_adv_sync()
2993 hci_schedule_adv_instance_sync(hdev, adv->instance, true); in hci_powered_update_adv_sync()
3003 if (link_sec == test_bit(HCI_AUTH, &hdev->flags)) in hci_write_auth_enable_sync()
3020 if (hdev->hci_ver < BLUETOOTH_VER_1_2) in hci_write_fast_connectable_sync()
3031 type = hdev->def_page_scan_type; in hci_write_fast_connectable_sync()
3032 cp.interval = cpu_to_le16(hdev->def_page_scan_int); in hci_write_fast_connectable_sync()
3035 cp.window = cpu_to_le16(hdev->def_page_scan_window); in hci_write_fast_connectable_sync()
3037 if (__cpu_to_le16(hdev->page_scan_interval) != cp.interval || in hci_write_fast_connectable_sync()
3038 __cpu_to_le16(hdev->page_scan_window) != cp.window) { in hci_write_fast_connectable_sync()
3046 if (hdev->page_scan_type != type) in hci_write_fast_connectable_sync()
3059 list_for_each_entry(b, &hdev->accept_list, list) { in disconnected_accept_list_entries()
3062 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &b->bdaddr); in disconnected_accept_list_entries()
3066 if (conn->state != BT_CONNECTED && conn->state != BT_CONFIG) in disconnected_accept_list_entries()
3093 if (hdev->scanning_paused) in hci_update_scan_sync()
3105 if (test_bit(HCI_PSCAN, &hdev->flags) == !!(scan & SCAN_PAGE) && in hci_update_scan_sync()
3106 test_bit(HCI_ISCAN, &hdev->flags) == !!(scan & SCAN_INQUIRY)) in hci_update_scan_sync()
3118 memcpy(cp.name, hdev->dev_name, sizeof(cp.name)); in hci_update_name_sync()
3130 * HCI_LE_ENABLED(use_ll_privacy(Add local IRK to Resolving List) ->
3133 * lmp_bredr_capable(Set Fast Connectable -> Set Scan Type -> Set Class ->
3134 * Set Name -> Set EIR)
3135 * HCI_FORCE_STATIC_ADDR | BDADDR_ANY && !HCI_BREDR_ENABLED (Set Static Address)
3144 * the public address or static address is used. in hci_powered_update_sync()
3175 /* If forcing static address is in use or there is no public in hci_powered_update_sync()
3176 * address use the static address as random address (but skip in hci_powered_update_sync()
3177 * the HCI command if the current random address is already the in hci_powered_update_sync()
3180 * In case BR/EDR has been disabled on a dual-mode controller in hci_powered_update_sync()
3181 * and a static address has been configured, then use that in hci_powered_update_sync()
3182 * address instead of the public BR/EDR address. in hci_powered_update_sync()
3185 (!bacmp(&hdev->bdaddr, BDADDR_ANY) && in hci_powered_update_sync()
3187 if (bacmp(&hdev->static_addr, BDADDR_ANY)) in hci_powered_update_sync()
3189 &hdev->static_addr); in hci_powered_update_sync()
3196 * hci_dev_get_bd_addr_from_property - Get the Bluetooth Device Address
3201 * Search the firmware node for 'local-bd-address'.
3203 * All-zero BD addresses are rejected, because those could be properties
3205 * example, the DTS could define 'local-bd-address', with zero BD addresses.
3209 struct fwnode_handle *fwnode = dev_fwnode(hdev->dev.parent); in hci_dev_get_bd_addr_from_property()
3213 ret = fwnode_property_read_u8_array(fwnode, "local-bd-address", in hci_dev_get_bd_addr_from_property()
3218 bacpy(&hdev->public_addr, &ba); in hci_dev_get_bd_addr_from_property()
3242 /* Read Local Version */
3249 /* Read BD Address */
3273 set_bit(HCI_RESET, &hdev->flags); in hci_reset_sync()
3290 if (!test_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks)) { in hci_init0_sync()
3303 if (test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks)) in hci_unconf_init_sync()
3316 /* Read Local Supported Features. */
3320 if (hdev->dev_type == HCI_AMP && !(hdev->commands[14] & 0x20)) in hci_read_local_features_sync()
3338 /* Read Local Commands */
3342 * HCI command for reading the local supported commands. in hci_read_local_cmds_sync()
3346 * the driver can quirk the behavior and skip reading the local in hci_read_local_cmds_sync()
3349 if (hdev->hci_ver > BLUETOOTH_VER_1_1 && in hci_read_local_cmds_sync()
3350 !test_bit(HCI_QUIRK_BROKEN_LOCAL_COMMANDS, &hdev->quirks)) in hci_read_local_cmds_sync()
3357 /* Read Local AMP Info */
3409 if (!test_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks)) { in hci_init1_sync()
3415 switch (hdev->dev_type) { in hci_init1_sync()
3417 hdev->flow_ctl_mode = HCI_FLOW_CTL_MODE_PACKET_BASED; in hci_init1_sync()
3420 hdev->flow_ctl_mode = HCI_FLOW_CTL_MODE_BLOCK_BASED; in hci_init1_sync()
3423 bt_dev_err(hdev, "Unknown device type %d", hdev->dev_type); in hci_init1_sync()
3451 /* Read Local Name */
3488 if (test_bit(HCI_QUIRK_BROKEN_FILTER_CLEAR_ALL, &hdev->quirks)) in hci_set_event_filter_sync()
3515 if (test_bit(HCI_QUIRK_BROKEN_FILTER_CLEAR_ALL, &hdev->quirks)) in hci_clear_event_filter_sync()
3565 hdev->max_page = 0x01; in hci_write_ssp_mode_1_sync()
3578 memset(hdev->eir, 0, sizeof(hdev->eir)); in hci_write_eir_sync()
3590 !test_bit(HCI_QUIRK_FIXUP_INQUIRY_MODE, &hdev->quirks)) in hci_write_inquiry_mode_sync()
3654 if (iso_capable(hdev) && hdev->commands[41] & 0x20) in hci_le_read_buffer_size_sync()
3663 /* Read LE Local Supported Features */
3694 if (hdev->dev_type == HCI_AMP) in hci_init2_sync()
3713 /* LE-only controllers have LE implicitly enabled */ in hci_init2_sync()
3732 if (hdev->hci_ver < BLUETOOTH_VER_1_2) in hci_set_event_mask_sync()
3742 if (hdev->suspended) { in hci_set_event_mask_sync()
3747 /* Use a different default for LE-only devices */ in hci_set_event_mask_sync()
3757 if (hdev->commands[0] & 0x20) { in hci_set_event_mask_sync()
3762 if (!hdev->suspended) in hci_set_event_mask_sync()
3771 if (hdev->commands[2] & 0x80) in hci_set_event_mask_sync()
3776 if (hdev->le_features[0] & HCI_LE_ENCRYPTION) { in hci_set_event_mask_sync()
3783 test_bit(HCI_QUIRK_FIXUP_INQUIRY_MODE, &hdev->quirks)) in hci_set_event_mask_sync()
3824 events[7] |= 0x20; /* LE Meta-Event */ in hci_set_event_mask_sync()
3834 if (!(hdev->commands[6] & 0x20) || in hci_read_stored_link_key_sync()
3835 test_bit(HCI_QUIRK_BROKEN_STORED_LINK_KEY, &hdev->quirks)) in hci_read_stored_link_key_sync()
3851 if (!(hdev->commands[5] & 0x10)) in hci_setup_link_policy_sync()
3873 if (!(hdev->commands[8] & 0x01)) in hci_read_page_scan_activity_sync()
3882 if (!(hdev->commands[18] & 0x04) || in hci_read_def_err_data_reporting_sync()
3883 !(hdev->features[0][6] & LMP_ERR_DATA_REPORTING) || in hci_read_def_err_data_reporting_sync()
3884 test_bit(HCI_QUIRK_BROKEN_ERR_DATA_REPORTING, &hdev->quirks)) in hci_read_def_err_data_reporting_sync()
3897 if (!(hdev->commands[13] & 0x01)) in hci_read_page_scan_type_sync()
3913 for (page = 2; page < HCI_MAX_PAGES && page <= hdev->max_page; in hci_read_local_ext_features_all_sync()
3951 if (hdev->le_features[0] & HCI_LE_ENCRYPTION) in hci_le_set_event_mask_sync()
3957 if (hdev->le_features[0] & HCI_LE_CONN_PARAM_REQ_PROC) in hci_le_set_event_mask_sync()
3964 if (hdev->le_features[0] & HCI_LE_DATA_LEN_EXT) in hci_le_set_event_mask_sync()
3976 if (hdev->le_features[0] & HCI_LE_EXT_SCAN_POLICY) in hci_le_set_event_mask_sync()
3982 if (hdev->le_features[1] & HCI_LE_CHAN_SEL_ALG2) in hci_le_set_event_mask_sync()
3988 if (hdev->commands[26] & 0x08) in hci_le_set_event_mask_sync()
3994 if (hdev->commands[26] & 0x10) in hci_le_set_event_mask_sync()
4000 if (hdev->commands[27] & 0x04) in hci_le_set_event_mask_sync()
4006 if (hdev->commands[27] & 0x20) in hci_le_set_event_mask_sync()
4010 /* If the controller supports the LE Read Local P-256 in hci_le_set_event_mask_sync()
4013 if (hdev->commands[34] & 0x02) in hci_le_set_event_mask_sync()
4014 /* LE Read Local P-256 Public Key Complete */ in hci_le_set_event_mask_sync()
4020 if (hdev->commands[34] & 0x04) in hci_le_set_event_mask_sync()
4026 if (hdev->commands[35] & (0x20 | 0x40)) in hci_le_set_event_mask_sync()
4065 if ((hdev->commands[25] & 0x40) && !ext_adv_capable(hdev)) { in hci_le_read_adv_tx_power_sync()
4083 if (!(hdev->commands[38] & 0x80) || in hci_le_read_tx_power_sync()
4084 test_bit(HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER, &hdev->quirks)) in hci_le_read_tx_power_sync()
4094 if (!(hdev->commands[26] & 0x40)) in hci_le_read_accept_list_size_sync()
4104 if (!(hdev->commands[26] & 0x80)) in hci_le_clear_accept_list_sync()
4114 if (!(hdev->commands[34] & 0x40)) in hci_le_read_resolv_list_size_sync()
4124 if (!(hdev->commands[34] & 0x20)) in hci_le_clear_resolv_list_sync()
4134 __le16 timeout = cpu_to_le16(hdev->rpa_timeout); in hci_le_set_rpa_timeout_sync()
4136 if (!(hdev->commands[35] & 0x04) || in hci_le_set_rpa_timeout_sync()
4137 test_bit(HCI_QUIRK_BROKEN_SET_RPA_TIMEOUT, &hdev->quirks)) in hci_le_set_rpa_timeout_sync()
4148 if (!(hdev->le_features[0] & HCI_LE_DATA_LEN_EXT)) in hci_le_read_max_data_len_sync()
4158 if (!(hdev->le_features[0] & HCI_LE_DATA_LEN_EXT)) in hci_le_read_def_data_len_sync()
4181 /* LE-only devices do not support explicit enablement */ in hci_set_le_support_sync()
4281 if (!(hdev->commands[6] & 0x80) || in hci_delete_stored_link_key_sync()
4282 test_bit(HCI_QUIRK_BROKEN_STORED_LINK_KEY, &hdev->quirks)) in hci_delete_stored_link_key_sync()
4299 if (!(hdev->commands[22] & 0x04)) in hci_set_event_mask_page_2_sync()
4325 if (lmp_ping_capable(hdev) || hdev->le_features[0] & HCI_LE_PING) { in hci_set_event_mask_page_2_sync()
4343 /* Read local codec list if the HCI command is supported */
4346 if (hdev->commands[45] & 0x04) in hci_read_local_codecs_sync()
4348 else if (hdev->commands[29] & 0x20) in hci_read_local_codecs_sync()
4354 /* Read local pairing options if the HCI command is supported */
4357 if (!(hdev->commands[41] & 0x08)) in hci_read_local_pairing_opts_sync()
4406 if (!(hdev->commands[18] & 0x08) || in hci_set_err_data_report_sync()
4407 !(hdev->features[0][6] & LMP_ERR_DATA_REPORTING) || in hci_set_err_data_report_sync()
4408 test_bit(HCI_QUIRK_BROKEN_ERR_DATA_REPORTING, &hdev->quirks)) in hci_set_err_data_report_sync()
4411 if (enabled == hdev->err_data_reporting) in hci_set_err_data_report_sync()
4447 if (!(hdev->le_features[0] & HCI_LE_DATA_LEN_EXT)) in hci_le_set_write_def_data_len_sync()
4451 cp.tx_len = cpu_to_le16(hdev->le_max_tx_len); in hci_le_set_write_def_data_len_sync()
4452 cp.tx_time = cpu_to_le16(hdev->le_max_tx_time); in hci_le_set_write_def_data_len_sync()
4465 if (!(hdev->commands[35] & 0x20)) { in hci_le_set_default_phy_sync()
4469 hdev->le_tx_def_phys = HCI_LE_SET_PHY_1M; in hci_le_set_default_phy_sync()
4470 hdev->le_rx_def_phys = HCI_LE_SET_PHY_1M; in hci_le_set_default_phy_sync()
4534 /* HCI_PRIMARY covers both single-mode LE, BR/EDR and dual-mode in hci_init_sync()
4538 if (hdev->dev_type != HCI_PRIMARY) in hci_init_sync()
4586 "HCI Read Local Supported Commands not supported"),
4602 "HCI LE Set Random Private Address Timeout command is "
4611 * Calls hdev->setup
4612 * Setup address if HCI_QUIRK_USE_BDADDR_PROPERTY is set.
4621 !test_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks)) in hci_dev_setup_sync()
4628 if (hdev->setup) in hci_dev_setup_sync()
4629 ret = hdev->setup(hdev); in hci_dev_setup_sync()
4632 if (test_bit(hci_broken_table[i].quirk, &hdev->quirks)) in hci_dev_setup_sync()
4640 invalid_bdaddr = test_bit(HCI_QUIRK_INVALID_BDADDR, &hdev->quirks) || in hci_dev_setup_sync()
4641 test_bit(HCI_QUIRK_USE_BDADDR_PROPERTY, &hdev->quirks); in hci_dev_setup_sync()
4643 if (test_bit(HCI_QUIRK_USE_BDADDR_PROPERTY, &hdev->quirks) && in hci_dev_setup_sync()
4644 !bacmp(&hdev->public_addr, BDADDR_ANY)) in hci_dev_setup_sync()
4647 if (invalid_bdaddr && bacmp(&hdev->public_addr, BDADDR_ANY) && in hci_dev_setup_sync()
4648 hdev->set_bdaddr) { in hci_dev_setup_sync()
4649 ret = hdev->set_bdaddr(hdev, &hdev->public_addr); in hci_dev_setup_sync()
4659 * it becomes a valid address if the bootloader does in hci_dev_setup_sync()
4665 if (test_bit(HCI_QUIRK_EXTERNAL_CONFIG, &hdev->quirks) || in hci_dev_setup_sync()
4671 * the Read Local Version Information command. in hci_dev_setup_sync()
4674 * also the original Bluetooth public device address in hci_dev_setup_sync()
4675 * will be read using the Read BD Address command. in hci_dev_setup_sync()
4694 atomic_set(&hdev->cmd_cnt, 1); in hci_dev_init_sync()
4695 set_bit(HCI_INIT, &hdev->flags); in hci_dev_init_sync()
4700 /* If public address change is configured, ensure that in hci_dev_init_sync()
4701 * the address gets programmed. If the driver does not in hci_dev_init_sync()
4702 * support changing the public address, fail the power in hci_dev_init_sync()
4705 if (bacmp(&hdev->public_addr, BDADDR_ANY) && in hci_dev_init_sync()
4706 hdev->set_bdaddr) in hci_dev_init_sync()
4707 ret = hdev->set_bdaddr(hdev, &hdev->public_addr); in hci_dev_init_sync()
4709 ret = -EADDRNOTAVAIL; in hci_dev_init_sync()
4716 if (!ret && hdev->post_init) in hci_dev_init_sync()
4717 ret = hdev->post_init(hdev); in hci_dev_init_sync()
4725 if (test_bit(HCI_QUIRK_NON_PERSISTENT_DIAG, &hdev->quirks) && in hci_dev_init_sync()
4727 hci_dev_test_flag(hdev, HCI_VENDOR_DIAG) && hdev->set_diag) in hci_dev_init_sync()
4728 ret = hdev->set_diag(hdev, true); in hci_dev_init_sync()
4735 clear_bit(HCI_INIT, &hdev->flags); in hci_dev_init_sync()
4747 ret = -ENODEV; in hci_dev_open_sync()
4757 ret = -ERFKILL; in hci_dev_open_sync()
4761 /* Check for valid public address or a configured static in hci_dev_open_sync()
4762 * random address, but let the HCI setup proceed to in hci_dev_open_sync()
4763 * be able to determine if there is a public address in hci_dev_open_sync()
4767 * if a public address or static random address is in hci_dev_open_sync()
4771 * since AMP controllers do not have an address. in hci_dev_open_sync()
4774 hdev->dev_type == HCI_PRIMARY && in hci_dev_open_sync()
4775 !bacmp(&hdev->bdaddr, BDADDR_ANY) && in hci_dev_open_sync()
4776 !bacmp(&hdev->static_addr, BDADDR_ANY)) { in hci_dev_open_sync()
4777 ret = -EADDRNOTAVAIL; in hci_dev_open_sync()
4782 if (test_bit(HCI_UP, &hdev->flags)) { in hci_dev_open_sync()
4783 ret = -EALREADY; in hci_dev_open_sync()
4787 if (hdev->open(hdev)) { in hci_dev_open_sync()
4788 ret = -EIO; in hci_dev_open_sync()
4794 set_bit(HCI_RUNNING, &hdev->flags); in hci_dev_open_sync()
4802 set_bit(HCI_UP, &hdev->flags); in hci_dev_open_sync()
4810 hdev->dev_type == HCI_PRIMARY) { in hci_dev_open_sync()
4816 flush_work(&hdev->tx_work); in hci_dev_open_sync()
4822 flush_work(&hdev->rx_work); in hci_dev_open_sync()
4823 flush_work(&hdev->cmd_work); in hci_dev_open_sync()
4825 skb_queue_purge(&hdev->cmd_q); in hci_dev_open_sync()
4826 skb_queue_purge(&hdev->rx_q); in hci_dev_open_sync()
4828 if (hdev->flush) in hci_dev_open_sync()
4829 hdev->flush(hdev); in hci_dev_open_sync()
4831 if (hdev->sent_cmd) { in hci_dev_open_sync()
4832 cancel_delayed_work_sync(&hdev->cmd_timer); in hci_dev_open_sync()
4833 kfree_skb(hdev->sent_cmd); in hci_dev_open_sync()
4834 hdev->sent_cmd = NULL; in hci_dev_open_sync()
4837 clear_bit(HCI_RUNNING, &hdev->flags); in hci_dev_open_sync()
4840 hdev->close(hdev); in hci_dev_open_sync()
4841 hdev->flags &= BIT(HCI_RAW); in hci_dev_open_sync()
4848 /* This function requires the caller holds hdev->lock */
4853 list_for_each_entry(p, &hdev->le_conn_params, list) { in hci_pend_le_actions_clear()
4855 if (p->conn) { in hci_pend_le_actions_clear()
4856 hci_conn_drop(p->conn); in hci_pend_le_actions_clear()
4857 hci_conn_put(p->conn); in hci_pend_le_actions_clear()
4858 p->conn = NULL; in hci_pend_le_actions_clear()
4878 test_bit(HCI_UP, &hdev->flags)) { in hci_dev_shutdown()
4880 if (hdev->shutdown) in hci_dev_shutdown()
4881 err = hdev->shutdown(hdev); in hci_dev_shutdown()
4897 cancel_delayed_work(&hdev->power_off); in hci_dev_close_sync()
4898 cancel_delayed_work(&hdev->ncmd_timer); in hci_dev_close_sync()
4899 cancel_delayed_work(&hdev->le_scan_disable); in hci_dev_close_sync()
4903 if (hdev->adv_instance_timeout) { in hci_dev_close_sync()
4904 cancel_delayed_work_sync(&hdev->adv_instance_expire); in hci_dev_close_sync()
4905 hdev->adv_instance_timeout = 0; in hci_dev_close_sync()
4910 if (!test_and_clear_bit(HCI_UP, &hdev->flags)) { in hci_dev_close_sync()
4911 cancel_delayed_work_sync(&hdev->cmd_timer); in hci_dev_close_sync()
4918 flush_work(&hdev->tx_work); in hci_dev_close_sync()
4919 flush_work(&hdev->rx_work); in hci_dev_close_sync()
4921 if (hdev->discov_timeout > 0) { in hci_dev_close_sync()
4922 hdev->discov_timeout = 0; in hci_dev_close_sync()
4928 cancel_delayed_work(&hdev->service_cache); in hci_dev_close_sync()
4933 cancel_delayed_work_sync(&hdev->rpa_expired); in hci_dev_close_sync()
4935 list_for_each_entry(adv_instance, &hdev->adv_instances, list) in hci_dev_close_sync()
4936 cancel_delayed_work_sync(&adv_instance->rpa_expired_cb); in hci_dev_close_sync()
4942 drain_workqueue(hdev->workqueue); in hci_dev_close_sync()
4950 if (!auto_off && hdev->dev_type == HCI_PRIMARY && in hci_dev_close_sync()
4958 /* Prevent data races on hdev->smp_data or hdev->smp_bredr_data */ in hci_dev_close_sync()
4969 if (hdev->flush) in hci_dev_close_sync()
4970 hdev->flush(hdev); in hci_dev_close_sync()
4973 skb_queue_purge(&hdev->cmd_q); in hci_dev_close_sync()
4974 atomic_set(&hdev->cmd_cnt, 1); in hci_dev_close_sync()
4975 if (test_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks) && in hci_dev_close_sync()
4977 set_bit(HCI_INIT, &hdev->flags); in hci_dev_close_sync()
4979 clear_bit(HCI_INIT, &hdev->flags); in hci_dev_close_sync()
4983 flush_work(&hdev->cmd_work); in hci_dev_close_sync()
4986 skb_queue_purge(&hdev->rx_q); in hci_dev_close_sync()
4987 skb_queue_purge(&hdev->cmd_q); in hci_dev_close_sync()
4988 skb_queue_purge(&hdev->raw_q); in hci_dev_close_sync()
4991 if (hdev->sent_cmd) { in hci_dev_close_sync()
4992 cancel_delayed_work_sync(&hdev->cmd_timer); in hci_dev_close_sync()
4993 kfree_skb(hdev->sent_cmd); in hci_dev_close_sync()
4994 hdev->sent_cmd = NULL; in hci_dev_close_sync()
4997 clear_bit(HCI_RUNNING, &hdev->flags); in hci_dev_close_sync()
5001 hdev->close(hdev); in hci_dev_close_sync()
5004 hdev->flags &= BIT(HCI_RAW); in hci_dev_close_sync()
5008 hdev->amp_status = AMP_STATUS_POWERED_DOWN; in hci_dev_close_sync()
5010 memset(hdev->eir, 0, sizeof(hdev->eir)); in hci_dev_close_sync()
5011 memset(hdev->dev_class, 0, sizeof(hdev->dev_class)); in hci_dev_close_sync()
5012 bacpy(&hdev->random_addr, BDADDR_ANY); in hci_dev_close_sync()
5013 hci_codec_list_clear(&hdev->local_codecs); in hci_dev_close_sync()
5029 if (test_bit(HCI_UP, &hdev->flags) && in hci_power_on_sync()
5032 cancel_delayed_work(&hdev->power_off); in hci_power_on_sync()
5046 (hdev->dev_type == HCI_PRIMARY && in hci_power_on_sync()
5047 !bacmp(&hdev->bdaddr, BDADDR_ANY) && in hci_power_on_sync()
5048 !bacmp(&hdev->static_addr, BDADDR_ANY))) { in hci_power_on_sync()
5052 queue_delayed_work(hdev->req_workqueue, &hdev->power_off, in hci_power_on_sync()
5061 set_bit(HCI_RAW, &hdev->flags); in hci_power_on_sync()
5076 clear_bit(HCI_RAW, &hdev->flags); in hci_power_on_sync()
5101 struct discovery_state *d = &hdev->discovery; in hci_stop_discovery_sync()
5105 bt_dev_dbg(hdev, "state %u", hdev->discovery.state); in hci_stop_discovery_sync()
5107 if (d->state == DISCOVERY_FINDING || d->state == DISCOVERY_STOPPING) { in hci_stop_discovery_sync()
5108 if (test_bit(HCI_INQUIRY, &hdev->flags)) { in hci_stop_discovery_sync()
5116 cancel_delayed_work(&hdev->le_scan_disable); in hci_stop_discovery_sync()
5133 /* No further actions needed for LE-only discovery */ in hci_stop_discovery_sync()
5134 if (d->type == DISCOV_TYPE_LE) in hci_stop_discovery_sync()
5137 if (d->state == DISCOVERY_RESOLVING || d->state == DISCOVERY_STOPPING) { in hci_stop_discovery_sync()
5143 return hci_remote_name_cancel_sync(hdev, &e->data.bdaddr); in hci_stop_discovery_sync()
5167 if (conn->type == AMP_LINK) in hci_disconnect_sync()
5168 return hci_disconnect_phy_link_sync(hdev, conn->handle, reason); in hci_disconnect_sync()
5170 if (test_bit(HCI_CONN_BIG_CREATED, &conn->flags)) { in hci_disconnect_sync()
5182 cp.handle = cpu_to_le16(conn->handle); in hci_disconnect_sync()
5206 if (test_bit(HCI_CONN_SCANNING, &conn->flags)) in hci_le_connect_cancel_sync()
5209 if (conn->role == HCI_ROLE_SLAVE || in hci_le_connect_cancel_sync()
5210 test_and_set_bit(HCI_CONN_CANCEL, &conn->flags)) in hci_le_connect_cancel_sync()
5220 if (conn->type == LE_LINK) in hci_connect_cancel_sync()
5223 if (conn->type == ISO_LINK) { in hci_connect_cancel_sync()
5232 if (test_bit(HCI_CONN_CREATE_CIS, &conn->flags)) in hci_connect_cancel_sync()
5236 if (bacmp(&conn->dst, BDADDR_ANY)) in hci_connect_cancel_sync()
5245 if (hdev->hci_ver < BLUETOOTH_VER_1_2) in hci_connect_cancel_sync()
5255 6, &conn->dst, in hci_connect_cancel_sync()
5260 6, &conn->dst, HCI_CMD_TIMEOUT); in hci_connect_cancel_sync()
5269 bacpy(&cp.bdaddr, &conn->dst); in hci_reject_sco_sync()
5273 * allowed error values (0x0D-0x0F). in hci_reject_sco_sync()
5288 cp.handle = cpu_to_le16(conn->handle); in hci_le_reject_cis_sync()
5300 if (conn->type == ISO_LINK) in hci_reject_conn_sync()
5303 if (conn->type == SCO_LINK || conn->type == ESCO_LINK) in hci_reject_conn_sync()
5307 bacpy(&cp.bdaddr, &conn->dst); in hci_reject_conn_sync()
5317 u16 handle = conn->handle; in hci_abort_conn_sync()
5321 switch (conn->state) { in hci_abort_conn_sync()
5355 conn->state = BT_CLOSED; in hci_abort_conn_sync()
5369 struct list_head *head = &hdev->conn_hash.list; in hci_disconnect_all_sync()
5403 if (!test_bit(HCI_UP, &hdev->flags)) in hci_power_off_sync()
5406 if (test_bit(HCI_ISCAN, &hdev->flags) || in hci_power_off_sync()
5407 test_bit(HCI_PSCAN, &hdev->flags)) { in hci_power_off_sync()
5448 cp.num_iac = min_t(u8, hdev->num_iac, 2); in hci_write_iac_sync()
5494 /* Discoverable mode affects the local advertising in hci_update_discoverable_sync()
5495 * address in limited privacy mode. in hci_update_discoverable_sync()
5535 * by-product of disabling connectable, we need to update the in hci_update_connectable_sync()
5539 err = hci_update_adv_data_sync(hdev, hdev->cur_adv_instance); in hci_update_connectable_sync()
5543 !list_empty(&hdev->adv_instances)) { in hci_update_connectable_sync()
5546 hdev->cur_adv_instance); in hci_update_connectable_sync()
5565 if (test_bit(HCI_INQUIRY, &hdev->flags)) in hci_inquiry_sync()
5574 if (hdev->discovery.limited) in hci_inquiry_sync()
5608 /* Pause address resolution for active scan and stop advertising if in hci_active_scan_sync()
5616 * address (when privacy feature has been enabled) or non-resolvable in hci_active_scan_sync()
5617 * private address. in hci_active_scan_sync()
5625 (test_bit(HCI_QUIRK_STRICT_DUPLICATE_FILTER, &hdev->quirks) && in hci_active_scan_sync()
5626 hdev->discovery.result_filtering)) { in hci_active_scan_sync()
5641 hdev->le_scan_window_discovery, in hci_active_scan_sync()
5662 err = hci_active_scan_sync(hdev, hdev->le_scan_int_discovery * 2); in hci_start_interleaved_discovery_sync()
5674 bt_dev_dbg(hdev, "type %u", hdev->discovery.type); in hci_start_discovery_sync()
5676 switch (hdev->discovery.type) { in hci_start_discovery_sync()
5689 &hdev->quirks)) { in hci_start_discovery_sync()
5699 timeout = msecs_to_jiffies(hdev->discov_interleaved_timeout); in hci_start_discovery_sync()
5700 err = hci_active_scan_sync(hdev, hdev->le_scan_int_discovery); in hci_start_discovery_sync()
5704 err = hci_active_scan_sync(hdev, hdev->le_scan_int_discovery); in hci_start_discovery_sync()
5707 return -EINVAL; in hci_start_discovery_sync()
5715 queue_delayed_work(hdev->req_workqueue, &hdev->le_scan_disable, in hci_start_discovery_sync()
5734 int old_state = hdev->discovery.state; in hci_pause_discovery_sync()
5739 hdev->discovery_paused) in hci_pause_discovery_sync()
5747 hdev->discovery_paused = true; in hci_pause_discovery_sync()
5748 hdev->discovery_old_state = old_state; in hci_pause_discovery_sync()
5758 bool scanning = test_bit(HCI_PSCAN, &hdev->flags); in hci_update_event_filter_sync()
5767 if (test_bit(HCI_QUIRK_BROKEN_FILTER_CLEAR_ALL, &hdev->quirks)) in hci_update_event_filter_sync()
5773 list_for_each_entry(b, &hdev->accept_list, list) { in hci_update_event_filter_sync()
5774 if (!(b->flags & HCI_CONN_FLAG_REMOTE_WAKEUP)) in hci_update_event_filter_sync()
5777 bt_dev_dbg(hdev, "Adding event filters for %pMR", &b->bdaddr); in hci_update_event_filter_sync()
5781 &b->bdaddr, in hci_update_event_filter_sync()
5785 &b->bdaddr); in hci_update_event_filter_sync()
5801 if (hdev->scanning_paused) in hci_pause_scan_sync()
5805 if (test_bit(HCI_PSCAN, &hdev->flags)) in hci_pause_scan_sync()
5810 hdev->scanning_paused = true; in hci_pause_scan_sync()
5833 if (hdev->suspended) in hci_suspend_sync()
5837 hdev->suspended = true; in hci_suspend_sync()
5848 /* Prevent disconnects from causing scanning to be re-enabled */ in hci_suspend_sync()
5856 hdev->suspend_state = BT_RUNNING; in hci_suspend_sync()
5870 if (!hdev->wakeup || !hdev->wakeup(hdev)) { in hci_suspend_sync()
5871 hdev->suspend_state = BT_SUSPEND_DISCONNECT; in hci_suspend_sync()
5876 hdev->scanning_paused = false; in hci_suspend_sync()
5885 hdev->scanning_paused = true; in hci_suspend_sync()
5887 hdev->suspend_state = BT_SUSPEND_CONFIGURE_WAKE; in hci_suspend_sync()
5898 if (!hdev->discovery_paused) in hci_resume_discovery_sync()
5901 hdev->discovery_paused = false; in hci_resume_discovery_sync()
5927 if (!hdev->scanning_paused) in hci_resume_scan_sync()
5930 hdev->scanning_paused = false; in hci_resume_scan_sync()
5951 if (!hdev->suspended) in hci_resume_sync()
5954 hdev->suspended = false; in hci_resume_sync()
5979 struct hci_dev *hdev = conn->hdev; in conn_use_rpa()
6008 cp.channel_map = hdev->le_adv_channel_map; in hci_le_ext_directed_advertising_sync()
6014 cp.peer_addr_type = conn->dst_type; in hci_le_ext_directed_advertising_sync()
6015 bacpy(&cp.peer_addr, &conn->dst); in hci_le_ext_directed_advertising_sync()
6034 /* Check if random address need to be updated */ in hci_le_ext_directed_advertising_sync()
6037 bacmp(&random_addr, &hdev->random_addr)) { in hci_le_ext_directed_advertising_sync()
6060 * and write a new random address. The flag will be set back on in hci_le_directed_advertising_sync()
6084 cp.direct_addr_type = conn->dst_type; in hci_le_directed_advertising_sync()
6085 bacpy(&cp.direct_addr, &conn->dst); in hci_le_directed_advertising_sync()
6086 cp.channel_map = hdev->le_adv_channel_map; in hci_le_directed_advertising_sync()
6102 struct hci_dev *hdev = conn->hdev; in set_ext_conn_params()
6106 p->scan_interval = cpu_to_le16(hdev->le_scan_int_connect); in set_ext_conn_params()
6107 p->scan_window = cpu_to_le16(hdev->le_scan_window_connect); in set_ext_conn_params()
6108 p->conn_interval_min = cpu_to_le16(conn->le_conn_min_interval); in set_ext_conn_params()
6109 p->conn_interval_max = cpu_to_le16(conn->le_conn_max_interval); in set_ext_conn_params()
6110 p->conn_latency = cpu_to_le16(conn->le_conn_latency); in set_ext_conn_params()
6111 p->supervision_timeout = cpu_to_le16(conn->le_supv_timeout); in set_ext_conn_params()
6112 p->min_ce_len = cpu_to_le16(0x0000); in set_ext_conn_params()
6113 p->max_ce_len = cpu_to_le16(0x0000); in set_ext_conn_params()
6125 p = (void *)cp->data; in hci_le_ext_create_conn_sync()
6129 bacpy(&cp->peer_addr, &conn->dst); in hci_le_ext_create_conn_sync()
6130 cp->peer_addr_type = conn->dst_type; in hci_le_ext_create_conn_sync()
6131 cp->own_addr_type = own_addr_type; in hci_le_ext_create_conn_sync()
6136 cp->phys |= LE_SCAN_PHY_1M; in hci_le_ext_create_conn_sync()
6144 cp->phys |= LE_SCAN_PHY_2M; in hci_le_ext_create_conn_sync()
6152 cp->phys |= LE_SCAN_PHY_CODED; in hci_le_ext_create_conn_sync()
6161 conn->conn_timeout, NULL); in hci_le_ext_create_conn_sync()
6172 if (conn->role == HCI_ROLE_SLAVE) { in hci_le_create_conn_sync()
6177 hdev->le_scan_type == LE_SCAN_ACTIVE && in hci_le_create_conn_sync()
6180 return -EBUSY; in hci_le_create_conn_sync()
6194 params = hci_conn_params_lookup(hdev, &conn->dst, conn->dst_type); in hci_le_create_conn_sync()
6196 conn->le_conn_min_interval = params->conn_min_interval; in hci_le_create_conn_sync()
6197 conn->le_conn_max_interval = params->conn_max_interval; in hci_le_create_conn_sync()
6198 conn->le_conn_latency = params->conn_latency; in hci_le_create_conn_sync()
6199 conn->le_supv_timeout = params->supervision_timeout; in hci_le_create_conn_sync()
6201 conn->le_conn_min_interval = hdev->le_conn_min_interval; in hci_le_create_conn_sync()
6202 conn->le_conn_max_interval = hdev->le_conn_max_interval; in hci_le_create_conn_sync()
6203 conn->le_conn_latency = hdev->le_conn_latency; in hci_le_create_conn_sync()
6204 conn->le_supv_timeout = hdev->le_supv_timeout; in hci_le_create_conn_sync()
6218 /* Update random address, but set require_privacy to false so in hci_le_create_conn_sync()
6219 * that we never connect with an non-resolvable address. in hci_le_create_conn_sync()
6233 cp.scan_interval = cpu_to_le16(hdev->le_scan_int_connect); in hci_le_create_conn_sync()
6234 cp.scan_window = cpu_to_le16(hdev->le_scan_window_connect); in hci_le_create_conn_sync()
6236 bacpy(&cp.peer_addr, &conn->dst); in hci_le_create_conn_sync()
6237 cp.peer_addr_type = conn->dst_type; in hci_le_create_conn_sync()
6239 cp.conn_interval_min = cpu_to_le16(conn->le_conn_min_interval); in hci_le_create_conn_sync()
6240 cp.conn_interval_max = cpu_to_le16(conn->le_conn_max_interval); in hci_le_create_conn_sync()
6241 cp.conn_latency = cpu_to_le16(conn->le_conn_latency); in hci_le_create_conn_sync()
6242 cp.supervision_timeout = cpu_to_le16(conn->le_supv_timeout); in hci_le_create_conn_sync()
6257 conn->conn_timeout, NULL); in hci_le_create_conn_sync()
6260 if (err == -ETIMEDOUT) in hci_le_create_conn_sync()
6263 /* Re-enable advertising after the connection attempt is finished. */ in hci_le_create_conn_sync()
6307 list_for_each_entry_rcu(conn, &hdev->conn_hash.list, list) { in hci_le_create_cis_sync()
6308 if (test_bit(HCI_CONN_CREATE_CIS, &conn->flags)) in hci_le_create_cis_sync()
6313 list_for_each_entry_rcu(conn, &hdev->conn_hash.list, list) { in hci_le_create_cis_sync()
6319 cig = conn->iso_qos.ucast.cig; in hci_le_create_cis_sync()
6321 list_for_each_entry_rcu(link, &hdev->conn_hash.list, list) { in hci_le_create_cis_sync()
6323 link->iso_qos.ucast.cig == cig && in hci_le_create_cis_sync()
6324 link->state != BT_CONNECTED) { in hci_le_create_cis_sync()
6337 list_for_each_entry_rcu(conn, &hdev->conn_hash.list, list) { in hci_le_create_cis_sync()
6341 conn->iso_qos.ucast.cig != cig) in hci_le_create_cis_sync()
6344 set_bit(HCI_CONN_CREATE_CIS, &conn->flags); in hci_le_create_cis_sync()
6345 cis->acl_handle = cpu_to_le16(conn->parent->handle); in hci_le_create_cis_sync()
6346 cis->cis_handle = cpu_to_le16(conn->handle); in hci_le_create_cis_sync()
6366 conn->conn_timeout, NULL); in hci_le_create_cis_sync()
6410 /* If privacy is enabled use a resolvable private address. If in hci_get_random_address()
6414 /* If Controller supports LL Privacy use own address type is in hci_get_random_address()
6430 err = smp_generate_rpa(hdev, hdev->irk, &hdev->rpa); in hci_get_random_address()
6436 bacpy(rand_addr, &hdev->rpa); in hci_get_random_address()
6441 /* In case of required privacy without resolvable private address, in hci_get_random_address()
6442 * use an non-resolvable private address. This is useful for in hci_get_random_address()
6443 * non-connectable advertising. in hci_get_random_address()
6449 /* The non-resolvable private address is generated in hci_get_random_address()
6456 /* The non-resolvable private address shall not be in hci_get_random_address()
6457 * equal to the public address. in hci_get_random_address()
6459 if (bacmp(&hdev->bdaddr, &nrpa)) in hci_get_random_address()
6469 /* No privacy so use a public address. */ in hci_get_random_address()