drivers/infiniband/hw/ocrdma/ocrdma_stats.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/hw/ocrdma/ocrdma_stats.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/hw/ocrdma/ocrdma_stats.c- Extension
.c- Size
- 29628 bytes
- Lines
- 839
- Domain
- Driver Families
- Bucket
- drivers/infiniband
- 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.
- 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.
- 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
rdma/ib_addr.hrdma/ib_pma.hocrdma_stats.h
Detected Declarations
function ocrdma_add_statfunction ocrdma_alloc_stats_resourcesfunction ocrdma_release_stats_resourcesfunction ocrdma_sysfs_rcv_pktsfunction ocrdma_sysfs_rcv_datafunction ocrdma_sysfs_xmit_pktsfunction ocrdma_sysfs_xmit_datafunction ocrdma_update_statsfunction ocrdma_dbgfs_ops_writefunction ocrdma_pma_countersfunction ocrdma_dbgfs_ops_readfunction ocrdma_add_port_statsfunction ocrdma_rem_port_statsfunction ocrdma_init_debugfsfunction ocrdma_rem_debugfs
Annotated Snippet
static const struct file_operations ocrdma_dbg_ops = {
.owner = THIS_MODULE,
.open = simple_open,
.read = ocrdma_dbgfs_ops_read,
.write = ocrdma_dbgfs_ops_write,
};
void ocrdma_add_port_stats(struct ocrdma_dev *dev)
{
const struct pci_dev *pdev = dev->nic_info.pdev;
if (!ocrdma_dbgfs_dir)
return;
/* Create post stats base dir */
dev->dir = debugfs_create_dir(pci_name(pdev), ocrdma_dbgfs_dir);
dev->rsrc_stats.type = OCRDMA_RSRC_STATS;
dev->rsrc_stats.dev = dev;
debugfs_create_file("resource_stats", S_IRUSR, dev->dir,
&dev->rsrc_stats, &ocrdma_dbg_ops);
dev->rx_stats.type = OCRDMA_RXSTATS;
dev->rx_stats.dev = dev;
debugfs_create_file("rx_stats", S_IRUSR, dev->dir, &dev->rx_stats,
&ocrdma_dbg_ops);
dev->wqe_stats.type = OCRDMA_WQESTATS;
dev->wqe_stats.dev = dev;
debugfs_create_file("wqe_stats", S_IRUSR, dev->dir, &dev->wqe_stats,
&ocrdma_dbg_ops);
dev->tx_stats.type = OCRDMA_TXSTATS;
dev->tx_stats.dev = dev;
debugfs_create_file("tx_stats", S_IRUSR, dev->dir, &dev->tx_stats,
&ocrdma_dbg_ops);
dev->db_err_stats.type = OCRDMA_DB_ERRSTATS;
dev->db_err_stats.dev = dev;
debugfs_create_file("db_err_stats", S_IRUSR, dev->dir,
&dev->db_err_stats, &ocrdma_dbg_ops);
dev->tx_qp_err_stats.type = OCRDMA_TXQP_ERRSTATS;
dev->tx_qp_err_stats.dev = dev;
debugfs_create_file("tx_qp_err_stats", S_IRUSR, dev->dir,
&dev->tx_qp_err_stats, &ocrdma_dbg_ops);
dev->rx_qp_err_stats.type = OCRDMA_RXQP_ERRSTATS;
dev->rx_qp_err_stats.dev = dev;
debugfs_create_file("rx_qp_err_stats", S_IRUSR, dev->dir,
&dev->rx_qp_err_stats, &ocrdma_dbg_ops);
dev->tx_dbg_stats.type = OCRDMA_TX_DBG_STATS;
dev->tx_dbg_stats.dev = dev;
debugfs_create_file("tx_dbg_stats", S_IRUSR, dev->dir,
&dev->tx_dbg_stats, &ocrdma_dbg_ops);
dev->rx_dbg_stats.type = OCRDMA_RX_DBG_STATS;
dev->rx_dbg_stats.dev = dev;
debugfs_create_file("rx_dbg_stats", S_IRUSR, dev->dir,
&dev->rx_dbg_stats, &ocrdma_dbg_ops);
dev->driver_stats.type = OCRDMA_DRV_STATS;
dev->driver_stats.dev = dev;
debugfs_create_file("driver_dbg_stats", S_IRUSR, dev->dir,
&dev->driver_stats, &ocrdma_dbg_ops);
dev->reset_stats.type = OCRDMA_RESET_STATS;
dev->reset_stats.dev = dev;
debugfs_create_file("reset_stats", 0200, dev->dir, &dev->reset_stats,
&ocrdma_dbg_ops);
}
void ocrdma_rem_port_stats(struct ocrdma_dev *dev)
{
debugfs_remove_recursive(dev->dir);
}
void ocrdma_init_debugfs(void)
{
/* Create base dir in debugfs root dir */
ocrdma_dbgfs_dir = debugfs_create_dir("ocrdma", NULL);
}
void ocrdma_rem_debugfs(void)
{
debugfs_remove_recursive(ocrdma_dbgfs_dir);
}
Annotation
- Immediate include surface: `rdma/ib_addr.h`, `rdma/ib_pma.h`, `ocrdma_stats.h`.
- Detected declarations: `function ocrdma_add_stat`, `function ocrdma_alloc_stats_resources`, `function ocrdma_release_stats_resources`, `function ocrdma_sysfs_rcv_pkts`, `function ocrdma_sysfs_rcv_data`, `function ocrdma_sysfs_xmit_pkts`, `function ocrdma_sysfs_xmit_data`, `function ocrdma_update_stats`, `function ocrdma_dbgfs_ops_write`, `function ocrdma_pma_counters`.
- Atlas domain: Driver Families / drivers/infiniband.
- Implementation status: pattern 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.
- 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.