net/bluetooth/hci_drv.c
Source file repositories/reference/linux-study-clean/net/bluetooth/hci_drv.c
File Facts
- System
- Linux kernel
- Corpus path
net/bluetooth/hci_drv.c- Extension
.c- Size
- 2629 bytes
- Lines
- 106
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/skbuff.hlinux/types.hnet/bluetooth/bluetooth.hnet/bluetooth/hci.hnet/bluetooth/hci_core.hnet/bluetooth/hci_drv.h
Detected Declarations
function Copyrightfunction hci_drv_cmd_completefunction hci_drv_process_cmdexport hci_drv_cmd_statusexport hci_drv_cmd_completeexport hci_drv_process_cmd
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (C) 2025 Google Corporation
*/
#include <linux/skbuff.h>
#include <linux/types.h>
#include <net/bluetooth/bluetooth.h>
#include <net/bluetooth/hci.h>
#include <net/bluetooth/hci_core.h>
#include <net/bluetooth/hci_drv.h>
int hci_drv_cmd_status(struct hci_dev *hdev, u16 cmd, u8 status)
{
struct hci_drv_ev_hdr *hdr;
struct hci_drv_ev_cmd_status *ev;
struct sk_buff *skb;
skb = bt_skb_alloc(sizeof(*hdr) + sizeof(*ev), GFP_KERNEL);
if (!skb)
return -ENOMEM;
hdr = skb_put(skb, sizeof(*hdr));
hdr->opcode = __cpu_to_le16(HCI_DRV_EV_CMD_STATUS);
hdr->len = __cpu_to_le16(sizeof(*ev));
ev = skb_put(skb, sizeof(*ev));
ev->opcode = __cpu_to_le16(cmd);
ev->status = status;
hci_skb_pkt_type(skb) = HCI_DRV_PKT;
return hci_recv_frame(hdev, skb);
}
EXPORT_SYMBOL(hci_drv_cmd_status);
int hci_drv_cmd_complete(struct hci_dev *hdev, u16 cmd, u8 status, void *rp,
size_t rp_len)
{
struct hci_drv_ev_hdr *hdr;
struct hci_drv_ev_cmd_complete *ev;
struct sk_buff *skb;
skb = bt_skb_alloc(sizeof(*hdr) + sizeof(*ev) + rp_len, GFP_KERNEL);
if (!skb)
return -ENOMEM;
hdr = skb_put(skb, sizeof(*hdr));
hdr->opcode = __cpu_to_le16(HCI_DRV_EV_CMD_COMPLETE);
hdr->len = __cpu_to_le16(sizeof(*ev) + rp_len);
ev = skb_put(skb, sizeof(*ev));
ev->opcode = __cpu_to_le16(cmd);
ev->status = status;
skb_put_data(skb, rp, rp_len);
hci_skb_pkt_type(skb) = HCI_DRV_PKT;
return hci_recv_frame(hdev, skb);
}
EXPORT_SYMBOL(hci_drv_cmd_complete);
int hci_drv_process_cmd(struct hci_dev *hdev, struct sk_buff *skb)
{
struct hci_drv_cmd_hdr *hdr;
const struct hci_drv_handler *handler = NULL;
u16 opcode, len, ogf, ocf;
hdr = skb_pull_data(skb, sizeof(*hdr));
if (!hdr)
return -EILSEQ;
opcode = __le16_to_cpu(hdr->opcode);
len = __le16_to_cpu(hdr->len);
if (len != skb->len)
return -EILSEQ;
ogf = hci_opcode_ogf(opcode);
ocf = hci_opcode_ocf(opcode);
if (!hdev->hci_drv)
return hci_drv_cmd_status(hdev, opcode,
HCI_DRV_STATUS_UNKNOWN_COMMAND);
if (ogf != HCI_DRV_OGF_DRIVER_SPECIFIC) {
if (opcode < hdev->hci_drv->common_handler_count)
handler = &hdev->hci_drv->common_handlers[opcode];
} else {
Annotation
- Immediate include surface: `linux/skbuff.h`, `linux/types.h`, `net/bluetooth/bluetooth.h`, `net/bluetooth/hci.h`, `net/bluetooth/hci_core.h`, `net/bluetooth/hci_drv.h`.
- Detected declarations: `function Copyright`, `function hci_drv_cmd_complete`, `function hci_drv_process_cmd`, `export hci_drv_cmd_status`, `export hci_drv_cmd_complete`, `export hci_drv_process_cmd`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: integration implementation candidate.
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.