net/bluetooth/hci_sync.c
Source file repositories/reference/linux-study-clean/net/bluetooth/hci_sync.c
File Facts
- System
- Linux kernel
- Corpus path
net/bluetooth/hci_sync.c- Extension
.c- Size
- 203095 bytes
- Lines
- 7600
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/property.hnet/bluetooth/bluetooth.hnet/bluetooth/hci_core.hnet/bluetooth/mgmt.hhci_codec.hhci_debugfs.hsmp.heir.hmsft.haosp.hleds.h
Detected Declarations
struct conn_paramsstruct hci_init_stagestruct past_datafunction Copyrightfunction hci_cmd_sync_addfunction hci_req_sync_runfunction hci_request_initfunction __hci_cmd_sync_status_skfunction __hci_cmd_sync_statusfunction hci_cmd_sync_statusfunction hci_cmd_sync_workfunction hci_cmd_sync_cancel_workfunction scan_disable_syncfunction interleaved_inquiry_syncfunction le_scan_disablefunction reenable_adv_syncfunction reenable_advfunction cancel_adv_timeoutfunction hci_clear_adv_instance_syncfunction adv_timeout_expire_syncfunction adv_timeout_expirefunction is_interleave_scanningfunction interleave_scan_workfunction hci_cmd_sync_initfunction _hci_cmd_sync_cancel_entryfunction hci_cmd_sync_clearfunction hci_cmd_sync_cancelfunction hci_cmd_sync_cancel_syncfunction hci_cmd_sync_submitfunction hci_cmd_sync_queuefunction _hci_cmd_sync_lookup_entryfunction list_for_each_entry_safefunction hci_cmd_sync_queue_oncefunction hci_cmd_sync_runfunction hci_cmd_sync_run_oncefunction hci_cmd_sync_lookup_entryfunction hci_cmd_sync_cancel_entryfunction hci_cmd_sync_dequeue_oncefunction hci_cmd_sync_dequeuefunction hci_update_eir_syncfunction get_service_classesfunction hci_update_class_syncfunction is_advertising_allowedfunction adv_use_rpafunction hci_set_random_addr_syncfunction hci_update_random_address_syncfunction addressfunction hci_disable_ext_adv_instance_sync
Annotated Snippet
struct conn_params {
bdaddr_t addr;
u8 addr_type;
hci_conn_flags_t flags;
u8 privacy_mode;
};
/* Adds connection to resolve list if needed.
* Setting params to NULL programs local hdev->irk
*/
static int hci_le_add_resolve_list_sync(struct hci_dev *hdev,
struct conn_params *params)
{
struct hci_cp_le_add_to_resolv_list cp;
struct smp_irk *irk;
struct bdaddr_list_with_irk *entry;
struct hci_conn_params *p;
if (!ll_privacy_capable(hdev))
return 0;
/* Attempt to program local identity address, type and irk if params is
* NULL.
*/
if (!params) {
if (!hci_dev_test_flag(hdev, HCI_PRIVACY))
return 0;
hci_copy_identity_address(hdev, &cp.bdaddr, &cp.bdaddr_type);
memcpy(cp.peer_irk, hdev->irk, 16);
goto done;
} else if (!(params->flags & HCI_CONN_FLAG_ADDRESS_RESOLUTION))
return 0;
irk = hci_find_irk_by_addr(hdev, ¶ms->addr, params->addr_type);
if (!irk)
return 0;
/* Check if the IK has _not_ been programmed yet. */
entry = hci_bdaddr_list_lookup_with_irk(&hdev->le_resolv_list,
¶ms->addr,
params->addr_type);
if (entry)
return 0;
cp.bdaddr_type = params->addr_type;
bacpy(&cp.bdaddr, ¶ms->addr);
memcpy(cp.peer_irk, irk->val, 16);
/* Default privacy mode is always Network */
params->privacy_mode = HCI_NETWORK_PRIVACY;
rcu_read_lock();
p = hci_pend_le_action_lookup(&hdev->pend_le_conns,
¶ms->addr, params->addr_type);
if (!p)
p = hci_pend_le_action_lookup(&hdev->pend_le_reports,
¶ms->addr, params->addr_type);
if (p)
WRITE_ONCE(p->privacy_mode, HCI_NETWORK_PRIVACY);
rcu_read_unlock();
done:
if (hci_dev_test_flag(hdev, HCI_PRIVACY))
memcpy(cp.local_irk, hdev->irk, 16);
else
memset(cp.local_irk, 0, 16);
return __hci_cmd_sync_status(hdev, HCI_OP_LE_ADD_TO_RESOLV_LIST,
sizeof(cp), &cp, HCI_CMD_TIMEOUT);
}
/* Set Device Privacy Mode. */
static int hci_le_set_privacy_mode_sync(struct hci_dev *hdev,
struct conn_params *params)
{
struct hci_cp_le_set_privacy_mode cp;
struct smp_irk *irk;
if (!ll_privacy_capable(hdev) ||
!(params->flags & HCI_CONN_FLAG_ADDRESS_RESOLUTION))
return 0;
/* If device privacy mode has already been set there is nothing to do */
if (params->privacy_mode == HCI_DEVICE_PRIVACY)
return 0;
/* Check if HCI_CONN_FLAG_DEVICE_PRIVACY has been set as it also
* indicates that LL Privacy has been enabled and
* HCI_OP_LE_SET_PRIVACY_MODE is supported.
Annotation
- Immediate include surface: `linux/property.h`, `net/bluetooth/bluetooth.h`, `net/bluetooth/hci_core.h`, `net/bluetooth/mgmt.h`, `hci_codec.h`, `hci_debugfs.h`, `smp.h`, `eir.h`.
- Detected declarations: `struct conn_params`, `struct hci_init_stage`, `struct past_data`, `function Copyright`, `function hci_cmd_sync_add`, `function hci_req_sync_run`, `function hci_request_init`, `function __hci_cmd_sync_status_sk`, `function __hci_cmd_sync_status`, `function hci_cmd_sync_status`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.