Skip to contentSkip to conversation

net: mana: Expose hardware diagnostic info via debugfs

PATCH Superseded Erni Sri Satya Vennela 2 participants 3 messages Mar 5 – Mar 9

Subsystems (5)

v1 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: mana: Expose hardware diagnostic info via debugfs

Add debugfs entries to expose hardware configuration and diagnostic information that aids in debugging driver initialization and runtime operations without adding noise to dmesg.

Device-level entries (under /sys/kernel/debug/mana/<slot>/):
- num_msix_usable, max_num_queues: Max resources from hardware
- gdma_protocol_ver, pf_cap_flags1: VF version negotiation results
- num_vports, bm_hostmode: Device configuration

- port_handle: Hardware vPort handle
- max_sq, max_rq: Max queues from vPort config
- indir_table_sz: Indirection table size
- steer_rx, steer_rss, steer_update_tab, steer_cqe_coalescing:
Last applied steering configuration parameters

---
 .../net/ethernet/microsoft/mana/gdma_main.c   | 12 +++++++
 drivers/net/ethernet/microsoft/mana/mana_en.c | 31 +++++++++++++++++++
 include/net/mana/gdma.h                       |  1 +
 include/net/mana/mana.h                       |  8 +++++
 4 files changed, 52 insertions(+)
drivers/net/ethernet/microsoft/mana/gdma_main.c +12 -0
index 0055c231acf6..2ba8d224fd26 100644
@@ -152,6 +152,11 @@ static int mana_gd_query_max_resources(struct pci_dev *pdev)
 	if (gc->max_num_queues > gc->num_msix_usable - 1)
 		gc->max_num_queues = gc->num_msix_usable - 1;
 
+	debugfs_create_u32("num_msix_usable", 0400, gc->mana_pci_debugfs,
+			   &gc->num_msix_usable);
+	debugfs_create_u32("max_num_queues", 0400, gc->mana_pci_debugfs,
+			   &gc->max_num_queues);
+
 	return 0;
 }
 
@@ -1221,6 +1226,13 @@ int mana_gd_verify_vf_version(struct pci_dev *pdev)
 		return err ? err : -EPROTO;
 	}
 	gc->pf_cap_flags1 = resp.pf_cap_flags1;
+	gc->gdma_protocol_ver = resp.gdma_protocol_ver;
+
+	debugfs_create_x64("gdma_protocol_ver", 0400, gc->mana_pci_debugfs,
+			   &gc->gdma_protocol_ver);
+	debugfs_create_x64("pf_cap_flags1", 0400, gc->mana_pci_debugfs,
+			   &gc->pf_cap_flags1);
+
 	if (resp.pf_cap_flags1 & GDMA_DRV_CAP_FLAG_1_HWC_TIMEOUT_RECONFIG) {
 		err = mana_gd_query_hwc_timeout(pdev, &hwc->hwc_timeout);
 		if (err) {
drivers/net/ethernet/microsoft/mana/mana_en.c +31 -0
index 53f24244de75..25ce81283e92 100644
@@ -1265,6 +1265,9 @@ static int mana_query_vport_cfg(struct mana_port_context *apc, u32 vport_index,
 	apc->port_handle = resp.vport;
 	ether_addr_copy(apc->mac_addr, resp.mac_addr);
 
+	apc->vport_max_sq = *max_sq;
+	apc->vport_max_rq = *max_rq;
+
 	return 0;
 }
 
@@ -1411,6 +1414,11 @@ static int mana_cfg_vport_steering(struct mana_port_context *apc,
 
 	netdev_info(ndev, "Configured steering vPort %llu entries %u\n",
 		    apc->port_handle, apc->indir_table_sz);
+
+	apc->steer_rx = rx;
+	apc->steer_rss = apc->rss_state;
+	apc->steer_update_tab = update_tab;
+	apc->steer_cqe_coalescing = req->cqe_coalescing_enable;
 out:
 	kfree(req);
 	return err;
@@ -3102,6 +3110,24 @@ static int mana_init_port(struct net_device *ndev)
 	eth_hw_addr_set(ndev, apc->mac_addr);
 	sprintf(vport, "vport%d", port_idx);
 	apc->mana_port_debugfs = debugfs_create_dir(vport, gc->mana_pci_debugfs);
+
+	debugfs_create_u64("port_handle", 0400, apc->mana_port_debugfs,
+			   &apc->port_handle);
+	debugfs_create_u32("max_sq", 0400, apc->mana_port_debugfs,
+			   &apc->vport_max_sq);
+	debugfs_create_u32("max_rq", 0400, apc->mana_port_debugfs,
+			   &apc->vport_max_rq);
+	debugfs_create_u32("indir_table_sz", 0400, apc->mana_port_debugfs,
+			   &apc->indir_table_sz);
+	debugfs_create_u32("steer_rx", 0400, apc->mana_port_debugfs,
+			   &apc->steer_rx);
+	debugfs_create_u32("steer_rss", 0400, apc->mana_port_debugfs,
+			   &apc->steer_rss);
+	debugfs_create_u32("steer_update_tab", 0400, apc->mana_port_debugfs,
+			   &apc->steer_update_tab);
+	debugfs_create_u32("steer_cqe_coalescing", 0400, apc->mana_port_debugfs,
+			   &apc->steer_cqe_coalescing);
+
 	return 0;
 
 reset_apc:
@@ -3587,6 +3613,11 @@ int mana_probe(struct gdma_dev *gd, bool resuming)
 		ac->num_ports = num_ports;
 
 		INIT_WORK(&ac->link_change_work, mana_link_state_handle);
+
+		debugfs_create_u16("num_vports", 0400, gc->mana_pci_debugfs,
+				   &ac->num_ports);
+		debugfs_create_u8("bm_hostmode", 0400, gc->mana_pci_debugfs,
+				  &ac->bm_hostmode);
 	} else {
 		if (ac->num_ports != num_ports) {
 			dev_err(dev, "The number of vPorts changed: %d->%d\n",
include/net/mana/gdma.h +1 -0
index 766f4fb25e26..9bbb7fb0c964 100644
@@ -434,6 +434,7 @@ struct gdma_context {
 	struct gdma_dev		mana_ib;
 
 	u64 pf_cap_flags1;
+	u64 gdma_protocol_ver;
 
 	struct workqueue_struct *service_wq;
 
include/net/mana/mana.h +8 -0
index a078af283bdd..83f6de67c0cc 100644
@@ -563,6 +563,14 @@ struct mana_port_context {
 
 	/* Debugfs */
 	struct dentry *mana_port_debugfs;
+
+	/* Cached vport/steering config for debugfs */
+	u32 vport_max_sq;
+	u32 vport_max_rq;
+	u32 steer_rx;
+	u32 steer_rss;
+	u32 steer_update_tab;
+	u32 steer_cqe_coalescing;
 };
 
 netdev_tx_t mana_start_xmit(struct sk_buff *skb, struct net_device *ndev);
Signature · 1 line
2.34.1
maintainer
#1 lore raw

This is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible.

For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
---
net: mana: Expose hardware diagnostic info via debugfs

This commit adds debugfs entries to expose hardware configuration and diagnostic information for the MANA driver. It creates device-level and port-level debugfs entries to aid in debugging initialization and runtime operations.

Quoted 17 lines
drivers/net/ethernet/microsoft/mana/gdma_main.c +5 -0
index aef8612b73cb..fb513d7802cb 100644
@@ -152,6 +152,11 @@ static int mana_gd_query_max_resources(struct pci_dev *pdev)
 	if (gc->max_num_queues > gc->num_msix_usable - 1)
 		gc->max_num_queues = gc->num_msix_usable - 1;
 
+	debugfs_create_u32("num_msix_usable", 0400, gc->mana_pci_debugfs,
+			   &gc->num_msix_usable);
+	debugfs_create_u32("max_num_queues", 0400, gc->mana_pci_debugfs,
+			   &gc->max_num_queues);
+
 	return 0;
 }
 

drivers/net/ethernet/microsoft/mana/gdma_main.c int mana_gd_verify_vf_version(struct pci_dev *pdev) · line 1236

Quoted 10 lines
drivers/net/ethernet/microsoft/mana/gdma_main.c +7 -0
@@ -1222,6 +1227,13 @@ int mana_gd_verify_vf_version(struct pci_dev *pdev)
 		return err ? err : -EPROTO;
 	}
 	gc->pf_cap_flags1 = resp.pf_cap_flags1;
+	gc->gdma_protocol_ver = resp.gdma_protocol_ver;
+
+	debugfs_create_x64("gdma_protocol_ver", 0400, gc->mana_pci_debugfs,
+			   &gc->gdma_protocol_ver);
+	debugfs_create_x64("pf_cap_flags1", 0400, gc->mana_pci_debugfs,
+			   &gc->pf_cap_flags1);
+

Do these debugfs entries get recreated on every suspend/resume cycle?

Both mana_gd_query_max_resources() and mana_gd_verify_vf_version() are called from mana_gd_setup() during device initialization. On suspend, mana_gd_suspend() calls mana_gd_cleanup() which doesn't remove these debugfs entries. When mana_gd_resume() calls mana_gd_setup() again, it attempts to create the same debugfs entries a second time.

This means debugfs_start_creating() in fs/debugfs/inode.c will print an error for each duplicate file:

"'num_msix_usable' already exists in 'mana/<slot>/'" "'max_num_queues' already exists in 'mana/<slot>/'" "'gdma_protocol_ver' already exists in 'mana/<slot>/'" "'pf_cap_flags1' already exists in 'mana/<slot>/'"

This produces 4 error messages in dmesg on every suspend/resume cycle, contradicting the commit message's goal of operating "without adding noise to dmesg."

Should these device-level entries be removed during suspend (in mana_gd_cleanup or mana_gd_suspend), or should their creation be moved to mana_gd_probe where they're only created once?

[ ... ]

Signature · 1 line
pw-bot: cr
#2 lore raw
Quoted 7 lines · Jakub Kicinski

This is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible.

For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
---
net: mana: Expose hardware diagnostic info via debugfs

Quoted 6 lines

This commit adds debugfs entries to expose hardware configuration and diagnostic information for the MANA driver. It creates device-level and port-level debugfs entries to aid in debugging initialization and runtime operations.

Do these debugfs entries get recreated on every suspend/resume cycle?

No. Thankyou for pointing out Jakub.
I'll make this change in next version.

Quoted 15 lines

Both mana_gd_query_max_resources() and mana_gd_verify_vf_version() are called from mana_gd_setup() during device initialization. On suspend, mana_gd_suspend() calls mana_gd_cleanup() which doesn't remove these debugfs entries. When mana_gd_resume() calls mana_gd_setup() again, it attempts to create the same debugfs entries a second time.

This means debugfs_start_creating() in fs/debugfs/inode.c will print an error for each duplicate file:

"'num_msix_usable' already exists in 'mana/<slot>/'" "'max_num_queues' already exists in 'mana/<slot>/'" "'gdma_protocol_ver' already exists in 'mana/<slot>/'" "'pf_cap_flags1' already exists in 'mana/<slot>/'"

Quoted 7 lines

This produces 4 error messages in dmesg on every suspend/resume cycle, contradicting the commit message's goal of operating "without adding noise to dmesg."

Should these device-level entries be removed during suspend (in mana_gd_cleanup or mana_gd_suspend), or should their creation be moved to mana_gd_probe where they're only created once?

Right. I will remove the entries during suspend and re-create them in resume.

Quoted 4 lines

[ ... ]

Signature · 1 line
pw-bot: cr