net/bluetooth/coredump.c
Source file repositories/reference/linux-study-clean/net/bluetooth/coredump.c
File Facts
- System
- Linux kernel
- Corpus path
net/bluetooth/coredump.c- Extension
.c- Size
- 13356 bytes
- Lines
- 554
- 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.
- 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/devcoredump.hlinux/unaligned.hnet/bluetooth/bluetooth.hnet/bluetooth/hci_core.h
Detected Declarations
struct hci_devcoredump_skb_cbstruct hci_devcoredump_skb_patternenum hci_devcoredump_pkt_typefunction hci_dmp_cbfunction hci_devcd_update_statefunction hci_devcd_mkheaderfunction hci_devcd_notifyfunction hci_devcd_resetfunction hci_devcd_freefunction hci_devcd_allocfunction hci_devcd_copyfunction hci_devcd_memsetfunction hci_devcd_preparefunction hci_devcd_handle_pkt_initfunction hci_devcd_handle_pkt_skbfunction hci_devcd_handle_pkt_patternfunction hci_devcd_dumpfunction hci_devcd_handle_pkt_completefunction hci_devcd_handle_pkt_abortfunction hci_devcd_initfunction hci_devcd_timeoutfunction hci_devcd_registerfunction hci_devcd_enabledfunction hci_devcd_initfunction hci_devcd_appendfunction hci_devcd_append_patternfunction hci_devcd_completefunction hci_devcd_abortexport hci_devcd_rxexport hci_devcd_timeoutexport hci_devcd_registerexport hci_devcd_initexport hci_devcd_appendexport hci_devcd_append_patternexport hci_devcd_completeexport hci_devcd_abort
Annotated Snippet
struct hci_devcoredump_skb_cb {
u16 pkt_type;
};
struct hci_devcoredump_skb_pattern {
u8 pattern;
u32 len;
} __packed;
#define hci_dmp_cb(skb) ((struct hci_devcoredump_skb_cb *)((skb)->cb))
#define DBG_UNEXPECTED_STATE() \
bt_dev_dbg(hdev, \
"Unexpected packet (%d) for state (%d). ", \
hci_dmp_cb(skb)->pkt_type, hdev->dump.state)
#define MAX_DEVCOREDUMP_HDR_SIZE 512 /* bytes */
static int hci_devcd_update_hdr_state(char *buf, size_t size, int state)
{
int len = 0;
if (!buf)
return 0;
len = scnprintf(buf, size, "Bluetooth devcoredump\nState: %d\n", state);
return len + 1; /* scnprintf adds \0 at the end upon state rewrite */
}
/* Call with hci_dev_lock only. */
static int hci_devcd_update_state(struct hci_dev *hdev, int state)
{
bt_dev_dbg(hdev, "Updating devcoredump state from %d to %d.",
hdev->dump.state, state);
hdev->dump.state = state;
return hci_devcd_update_hdr_state(hdev->dump.head,
hdev->dump.alloc_size, state);
}
static int hci_devcd_mkheader(struct hci_dev *hdev, struct sk_buff *skb)
{
char dump_start[] = "--- Start dump ---\n";
char hdr[80];
int hdr_len;
hdr_len = hci_devcd_update_hdr_state(hdr, sizeof(hdr),
HCI_DEVCOREDUMP_IDLE);
skb_put_data(skb, hdr, hdr_len);
if (hdev->dump.dmp_hdr)
hdev->dump.dmp_hdr(hdev, skb);
skb_put_data(skb, dump_start, strlen(dump_start));
return skb->len;
}
/* Do not call with hci_dev_lock since this calls driver code. */
static void hci_devcd_notify(struct hci_dev *hdev, int state)
{
if (hdev->dump.notify_change)
hdev->dump.notify_change(hdev, state);
}
/* Call with hci_dev_lock only. */
void hci_devcd_reset(struct hci_dev *hdev)
{
hdev->dump.head = NULL;
hdev->dump.tail = NULL;
hdev->dump.alloc_size = 0;
hci_devcd_update_state(hdev, HCI_DEVCOREDUMP_IDLE);
cancel_delayed_work(&hdev->dump.dump_timeout);
skb_queue_purge(&hdev->dump.dump_q);
}
/* Call with hci_dev_lock only. */
static void hci_devcd_free(struct hci_dev *hdev)
{
vfree(hdev->dump.head);
hci_devcd_reset(hdev);
}
/* Call with hci_dev_lock only. */
static int hci_devcd_alloc(struct hci_dev *hdev, u32 size)
Annotation
- Immediate include surface: `linux/devcoredump.h`, `linux/unaligned.h`, `net/bluetooth/bluetooth.h`, `net/bluetooth/hci_core.h`.
- Detected declarations: `struct hci_devcoredump_skb_cb`, `struct hci_devcoredump_skb_pattern`, `enum hci_devcoredump_pkt_type`, `function hci_dmp_cb`, `function hci_devcd_update_state`, `function hci_devcd_mkheader`, `function hci_devcd_notify`, `function hci_devcd_reset`, `function hci_devcd_free`, `function hci_devcd_alloc`.
- 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.