drivers/net/ethernet/broadcom/bnxt/bnxt_coredump.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/broadcom/bnxt/bnxt_coredump.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/broadcom/bnxt/bnxt_coredump.c- Extension
.c- Size
- 18526 bytes
- Lines
- 678
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/types.hlinux/errno.hlinux/pci.hlinux/bnxt/hsi.hbnxt.hbnxt_hwrm.hbnxt_coredump.h
Detected Declarations
function bnxt_dbg_hwrm_log_buffer_flushfunction bnxt_hwrm_dbg_dma_datafunction bnxt_hwrm_dbg_coredump_listfunction bnxt_hwrm_dbg_coredump_initiatefunction bnxt_hwrm_dbg_coredump_retrievefunction bnxt_fill_coredump_seg_hdrfunction bnxt_fill_cmdlinefunction bnxt_fill_coredump_recordfunction bnxt_fill_drv_seg_recordfunction bnxt_get_ctx_coredumpfunction __bnxt_get_coredumpfunction bnxt_copy_crash_datafunction bnxt_copy_crash_dumpfunction bnxt_crash_dump_availfunction bnxt_get_coredumpfunction bnxt_hwrm_get_dump_lenfunction bnxt_get_coredump_length
Annotated Snippet
if (!info->segs) {
rc = -EIO;
break;
}
info->dest_buf_size = info->segs *
sizeof(struct coredump_segment_record);
info->dest_buf = kmalloc(info->dest_buf_size,
GFP_KERNEL);
if (!info->dest_buf) {
rc = -ENOMEM;
break;
}
}
if (cmn_req->req_type ==
cpu_to_le16(HWRM_DBG_COREDUMP_RETRIEVE))
info->dest_buf_size += len;
if (info->dest_buf) {
if ((info->seg_start + off + len) <=
BNXT_COREDUMP_BUF_LEN(info->buf_len)) {
u16 copylen = min_t(u16, len,
info->dest_buf_size - off);
memcpy(info->dest_buf + off, dma_buf, copylen);
if (copylen < len)
break;
} else {
rc = -ENOBUFS;
if (cmn_req->req_type ==
cpu_to_le16(HWRM_DBG_COREDUMP_LIST)) {
kfree(info->dest_buf);
info->dest_buf = NULL;
}
break;
}
}
if (!(cmn_resp->flags & HWRM_DBG_CMN_FLAGS_MORE))
break;
seq++;
off += len;
}
hwrm_req_drop(bp, msg);
return rc;
}
static int bnxt_hwrm_dbg_coredump_list(struct bnxt *bp,
struct bnxt_coredump *coredump)
{
struct bnxt_hwrm_dbg_dma_info info = {NULL};
struct hwrm_dbg_coredump_list_input *req;
int rc;
rc = hwrm_req_init(bp, req, HWRM_DBG_COREDUMP_LIST);
if (rc)
return rc;
info.dma_len = COREDUMP_LIST_BUF_LEN;
info.seq_off = offsetof(struct hwrm_dbg_coredump_list_input, seq_no);
info.data_len_off = offsetof(struct hwrm_dbg_coredump_list_output,
data_len);
rc = bnxt_hwrm_dbg_dma_data(bp, req, &info);
if (!rc) {
coredump->data = info.dest_buf;
coredump->data_size = info.dest_buf_size;
coredump->total_segs = info.segs;
}
return rc;
}
static int bnxt_hwrm_dbg_coredump_initiate(struct bnxt *bp, u16 dump_type,
u16 component_id, u16 segment_id)
{
struct hwrm_dbg_coredump_initiate_input *req;
int rc;
rc = hwrm_req_init(bp, req, HWRM_DBG_COREDUMP_INITIATE);
if (rc)
return rc;
hwrm_req_timeout(bp, req, bp->hwrm_cmd_max_timeout);
req->component_id = cpu_to_le16(component_id);
req->segment_id = cpu_to_le16(segment_id);
if (dump_type == BNXT_DUMP_LIVE_WITH_CTX_L1_CACHE)
req->seg_flags = DBG_COREDUMP_INITIATE_REQ_SEG_FLAGS_COLLECT_CTX_L1_CACHE;
Annotation
- Immediate include surface: `linux/types.h`, `linux/errno.h`, `linux/pci.h`, `linux/bnxt/hsi.h`, `bnxt.h`, `bnxt_hwrm.h`, `bnxt_coredump.h`.
- Detected declarations: `function bnxt_dbg_hwrm_log_buffer_flush`, `function bnxt_hwrm_dbg_dma_data`, `function bnxt_hwrm_dbg_coredump_list`, `function bnxt_hwrm_dbg_coredump_initiate`, `function bnxt_hwrm_dbg_coredump_retrieve`, `function bnxt_fill_coredump_seg_hdr`, `function bnxt_fill_cmdline`, `function bnxt_fill_coredump_record`, `function bnxt_fill_drv_seg_record`, `function bnxt_get_ctx_coredump`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
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.