net/bluetooth/hci_conn.c
Source file repositories/reference/linux-study-clean/net/bluetooth/hci_conn.c
File Facts
- System
- Linux kernel
- Corpus path
net/bluetooth/hci_conn.c- Extension
.c- Size
- 84084 bytes
- Lines
- 3391
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/export.hlinux/debugfs.hlinux/errqueue.hnet/bluetooth/bluetooth.hnet/bluetooth/hci_core.hnet/bluetooth/l2cap.hnet/bluetooth/iso.hnet/bluetooth/mgmt.hsmp.heir.h
Detected Declarations
struct sco_paramstruct conn_handle_tstruct le_conn_update_datastruct iso_list_datafunction hci_connect_le_scan_cleanupfunction hci_conn_cleanupfunction hci_disconnectfunction hci_add_scofunction find_next_esco_paramfunction configure_datapath_syncfunction hci_enhanced_setup_syncfunction hci_setup_sync_connfunction hci_setup_syncfunction le_conn_update_syncfunction le_conn_update_completefunction hci_le_conn_updatefunction hci_le_start_encfunction hci_sco_setupfunction hci_conn_timeoutfunction hci_conn_idlefunction hci_conn_auto_acceptfunction le_disable_advertisingfunction le_conn_timeoutfunction bis_listfunction terminate_big_syncfunction terminate_big_destroyfunction hci_le_terminate_bigfunction big_terminate_syncfunction find_bisfunction hci_le_big_terminatefunction bis_cleanupfunction remove_cig_syncfunction hci_le_remove_cigfunction find_cisfunction cis_cleanupfunction hci_conn_hash_alloc_unsetfunction hci_conn_cleanup_childfunction hci_conn_unlinkfunction list_for_each_entry_safefunction hci_conn_delfunction list_for_each_entryfunction hci_le_conn_failedfunction hci_conn_failedfunction hci_conn_set_handlefunction is_connectedfunction hci_explicit_conn_params_setfunction qos_set_bigfunction qos_set_bis
Annotated Snippet
struct sco_param {
u16 pkt_type;
u16 max_latency;
u8 retrans_effort;
};
struct conn_handle_t {
struct hci_conn *conn;
__u16 handle;
};
static const struct sco_param esco_param_cvsd[] = {
{ EDR_ESCO_MASK & ~ESCO_2EV3, 0x000a, 0x01 }, /* S3 */
{ EDR_ESCO_MASK & ~ESCO_2EV3, 0x0007, 0x01 }, /* S2 */
{ EDR_ESCO_MASK | ESCO_EV3, 0x0007, 0x01 }, /* S1 */
{ EDR_ESCO_MASK | ESCO_HV3, 0xffff, 0x01 }, /* D1 */
{ EDR_ESCO_MASK | ESCO_HV1, 0xffff, 0x01 }, /* D0 */
};
static const struct sco_param sco_param_cvsd[] = {
{ EDR_ESCO_MASK | ESCO_HV3, 0xffff, 0xff }, /* D1 */
{ EDR_ESCO_MASK | ESCO_HV1, 0xffff, 0xff }, /* D0 */
};
static const struct sco_param esco_param_msbc[] = {
{ EDR_ESCO_MASK & ~ESCO_2EV3, 0x000d, 0x02 }, /* T2 */
{ EDR_ESCO_MASK | ESCO_EV3, 0x0008, 0x02 }, /* T1 */
};
/* This function requires the caller holds hdev->lock */
void hci_connect_le_scan_cleanup(struct hci_conn *conn, u8 status)
{
struct hci_conn_params *params;
struct hci_dev *hdev = conn->hdev;
struct smp_irk *irk;
bdaddr_t *bdaddr;
u8 bdaddr_type;
bdaddr = &conn->dst;
bdaddr_type = conn->dst_type;
/* Check if we need to convert to identity address */
irk = hci_get_irk(hdev, bdaddr, bdaddr_type);
if (irk) {
bdaddr = &irk->bdaddr;
bdaddr_type = irk->addr_type;
}
params = hci_pend_le_action_lookup(&hdev->pend_le_conns, bdaddr,
bdaddr_type);
if (!params)
return;
if (params->conn) {
hci_conn_drop(params->conn);
hci_conn_put(params->conn);
params->conn = NULL;
}
if (!params->explicit_connect)
return;
/* If the status indicates successful cancellation of
* the attempt (i.e. Unknown Connection Id) there's no point of
* notifying failure since we'll go back to keep trying to
* connect. The only exception is explicit connect requests
* where a timeout + cancel does indicate an actual failure.
*/
if (status && status != HCI_ERROR_UNKNOWN_CONN_ID)
mgmt_connect_failed(hdev, conn, status);
/* The connection attempt was doing scan for new RPA, and is
* in scan phase. If params are not associated with any other
* autoconnect action, remove them completely. If they are, just unmark
* them as waiting for connection, by clearing explicit_connect field.
*/
params->explicit_connect = false;
hci_pend_le_list_del_init(params);
switch (params->auto_connect) {
case HCI_AUTO_CONN_EXPLICIT:
hci_conn_params_del(hdev, bdaddr, bdaddr_type);
/* return instead of break to avoid duplicate scan update */
return;
case HCI_AUTO_CONN_DIRECT:
case HCI_AUTO_CONN_ALWAYS:
hci_pend_le_list_add(params, &hdev->pend_le_conns);
break;
case HCI_AUTO_CONN_REPORT:
Annotation
- Immediate include surface: `linux/export.h`, `linux/debugfs.h`, `linux/errqueue.h`, `net/bluetooth/bluetooth.h`, `net/bluetooth/hci_core.h`, `net/bluetooth/l2cap.h`, `net/bluetooth/iso.h`, `net/bluetooth/mgmt.h`.
- Detected declarations: `struct sco_param`, `struct conn_handle_t`, `struct le_conn_update_data`, `struct iso_list_data`, `function hci_connect_le_scan_cleanup`, `function hci_conn_cleanup`, `function hci_disconnect`, `function hci_add_sco`, `function find_next_esco_param`, `function configure_datapath_sync`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: integration implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.