drivers/net/ethernet/meta/fbnic/fbnic_debugfs.c

Source file repositories/reference/linux-study-clean/drivers/net/ethernet/meta/fbnic/fbnic_debugfs.c

File Facts

System
Linux kernel
Corpus path
drivers/net/ethernet/meta/fbnic/fbnic_debugfs.c
Extension
.c
Size
19746 bytes
Lines
679
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.

Dependency Surface

Detected Declarations

Annotated Snippet

static const struct file_operations fbnic_dbg_desc_fops = {
	.owner		= THIS_MODULE,
	.open		= fbnic_dbg_desc_open,
	.read		= seq_read,
	.llseek		= seq_lseek,
	.release	= single_release,
};

void fbnic_dbg_nv_init(struct fbnic_napi_vector *nv)
{
	struct fbnic_dev *fbd = nv->fbd;
	char name[16];
	int i, j;

	/* Generate a folder for each napi vector */
	snprintf(name, sizeof(name), "nv.%03d", nv->v_idx);

	nv->dbg_nv = debugfs_create_dir(name, fbd->dbg_fbd);

	/* Generate a file for each Tx ring in the napi vector */
	for (i = 0; i < nv->txt_count; i++) {
		struct fbnic_q_triad *qt = &nv->qt[i];
		unsigned int hw_idx;

		hw_idx = fbnic_ring_csr_base(&qt->cmpl) -
			  &fbd->uc_addr0[FBNIC_QUEUE(0)];
		hw_idx /= FBNIC_QUEUE_STRIDE;

		snprintf(name, sizeof(name), "twq0.%03d", hw_idx);
		debugfs_create_file(name, 0400, nv->dbg_nv, &qt->sub0,
				    &fbnic_dbg_desc_fops);

		snprintf(name, sizeof(name), "twq1.%03d", hw_idx);
		debugfs_create_file(name, 0400, nv->dbg_nv, &qt->sub1,
				    &fbnic_dbg_desc_fops);

		snprintf(name, sizeof(name), "tcq.%03d", hw_idx);
		debugfs_create_file(name, 0400, nv->dbg_nv, &qt->cmpl,
				    &fbnic_dbg_desc_fops);
	}

	/* Generate a file for each Rx ring in the napi vector */
	for (j = 0; j < nv->rxt_count; j++, i++) {
		struct fbnic_q_triad *qt = &nv->qt[i];
		unsigned int hw_idx;

		hw_idx = fbnic_ring_csr_base(&qt->cmpl) -
			  &fbd->uc_addr0[FBNIC_QUEUE(0)];
		hw_idx /= FBNIC_QUEUE_STRIDE;

		snprintf(name, sizeof(name), "hpq.%03d", hw_idx);
		debugfs_create_file(name, 0400, nv->dbg_nv, &qt->sub0,
				    &fbnic_dbg_desc_fops);

		snprintf(name, sizeof(name), "ppq.%03d", hw_idx);
		debugfs_create_file(name, 0400, nv->dbg_nv, &qt->sub1,
				    &fbnic_dbg_desc_fops);

		snprintf(name, sizeof(name), "rcq.%03d", hw_idx);
		debugfs_create_file(name, 0400, nv->dbg_nv, &qt->cmpl,
				    &fbnic_dbg_desc_fops);
	}
}

void fbnic_dbg_nv_exit(struct fbnic_napi_vector *nv)
{
	debugfs_remove_recursive(nv->dbg_nv);
	nv->dbg_nv = NULL;
}

static int fbnic_dbg_mac_addr_show(struct seq_file *s, void *v)
{
	struct fbnic_dev *fbd = s->private;
	char hdr[80];
	int i;

	/* Generate Header */
	snprintf(hdr, sizeof(hdr), "%3s %s %-17s %s\n",
		 "Idx", "S", "TCAM Bitmap", "Addr/Mask");
	seq_puts(s, hdr);
	fbnic_dbg_desc_break(s, strnlen(hdr, sizeof(hdr)));

	for (i = 0; i < FBNIC_RPC_TCAM_MACDA_NUM_ENTRIES; i++) {
		struct fbnic_mac_addr *mac_addr = &fbd->mac_addr[i];

		seq_printf(s, "%02d  %d %64pb %pm\n",
			   i, mac_addr->state, mac_addr->act_tcam,
			   mac_addr->value.addr8);
		seq_printf(s, "                        %pm\n",
			   mac_addr->mask.addr8);

Annotation

Implementation Notes