drivers/net/ethernet/huawei/hinic/hinic_debugfs.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/huawei/hinic/hinic_debugfs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/huawei/hinic/hinic_debugfs.c- Extension
.c- Size
- 7426 bytes
- Lines
- 325
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/debugfs.hlinux/device.hhinic_debugfs.h
Detected Declarations
enum sq_dbg_infoenum rq_dbg_infoenum func_tbl_infofunction hinic_dbg_get_sq_infofunction hinic_dbg_get_rq_infofunction hinic_dbg_get_func_tablefunction hinic_dbg_cmd_readfunction create_dbg_filesfunction rem_dbg_filesfunction hinic_sq_debug_addfunction hinic_sq_debug_remfunction hinic_rq_debug_addfunction hinic_rq_debug_remfunction hinic_func_table_debug_addfunction hinic_func_table_debug_remfunction hinic_sq_dbgfs_initfunction hinic_sq_dbgfs_uninitfunction hinic_rq_dbgfs_initfunction hinic_rq_dbgfs_uninitfunction hinic_func_tbl_dbgfs_initfunction hinic_func_tbl_dbgfs_uninitfunction hinic_dbg_initfunction hinic_dbg_uninitfunction hinic_dbg_register_debugfsfunction hinic_dbg_unregister_debugfs
Annotated Snippet
static const struct file_operations hinic_dbg_cmd_fops = {
.owner = THIS_MODULE,
.open = simple_open,
.read = hinic_dbg_cmd_read,
};
static int create_dbg_files(struct hinic_dev *dev, enum hinic_dbg_type type, void *data,
struct dentry *root, struct hinic_debug_priv **dbg, char **field,
int nfile)
{
struct hinic_debug_priv *tmp;
int i;
tmp = kzalloc_obj(*tmp);
if (!tmp)
return -ENOMEM;
tmp->dev = dev;
tmp->object = data;
tmp->type = type;
tmp->root = root;
for (i = 0; i < nfile; i++) {
tmp->field_id[i] = i;
debugfs_create_file(field[i], 0400, root, &tmp->field_id[i], &hinic_dbg_cmd_fops);
}
*dbg = tmp;
return 0;
}
static void rem_dbg_files(struct hinic_debug_priv *dbg)
{
if (dbg->type != HINIC_DBG_FUNC_TABLE)
debugfs_remove_recursive(dbg->root);
kfree(dbg);
}
int hinic_sq_debug_add(struct hinic_dev *dev, u16 sq_id)
{
struct hinic_sq *sq;
struct dentry *root;
char sub_dir[16];
sq = dev->txqs[sq_id].sq;
sprintf(sub_dir, "0x%x", sq_id);
root = debugfs_create_dir(sub_dir, dev->sq_dbgfs);
return create_dbg_files(dev, HINIC_DBG_SQ_INFO, sq, root, &sq->dbg, sq_fields,
ARRAY_SIZE(sq_fields));
}
void hinic_sq_debug_rem(struct hinic_sq *sq)
{
if (sq->dbg)
rem_dbg_files(sq->dbg);
}
int hinic_rq_debug_add(struct hinic_dev *dev, u16 rq_id)
{
struct hinic_rq *rq;
struct dentry *root;
char sub_dir[16];
rq = dev->rxqs[rq_id].rq;
sprintf(sub_dir, "0x%x", rq_id);
root = debugfs_create_dir(sub_dir, dev->rq_dbgfs);
return create_dbg_files(dev, HINIC_DBG_RQ_INFO, rq, root, &rq->dbg, rq_fields,
ARRAY_SIZE(rq_fields));
}
void hinic_rq_debug_rem(struct hinic_rq *rq)
{
if (rq->dbg)
rem_dbg_files(rq->dbg);
}
int hinic_func_table_debug_add(struct hinic_dev *dev)
{
if (HINIC_IS_VF(dev->hwdev->hwif))
return 0;
return create_dbg_files(dev, HINIC_DBG_FUNC_TABLE, dev, dev->func_tbl_dbgfs, &dev->dbg,
Annotation
- Immediate include surface: `linux/debugfs.h`, `linux/device.h`, `hinic_debugfs.h`.
- Detected declarations: `enum sq_dbg_info`, `enum rq_dbg_info`, `enum func_tbl_info`, `function hinic_dbg_get_sq_info`, `function hinic_dbg_get_rq_info`, `function hinic_dbg_get_func_table`, `function hinic_dbg_cmd_read`, `function create_dbg_files`, `function rem_dbg_files`, `function hinic_sq_debug_add`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: pattern implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.