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.

Dependency Surface

Detected Declarations

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

Implementation Notes