netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v1] bnxt_en: add debugfs file for restarting rx queues
@ 2025-04-29  0:06 David Wei
  2025-04-29 15:28 ` Joe Damato
  2025-04-29 22:18 ` Jakub Kicinski
  0 siblings, 2 replies; 5+ messages in thread
From: David Wei @ 2025-04-29  0:06 UTC (permalink / raw)
  To: netdev, Michael Chan, Pavan Chebbi, Somnath Kotur
  Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni

Add a debugfs file that resets an Rx queue using
netdev_rx_queue_restart(). Useful for testing and debugging.

Signed-off-by: David Wei <dw@davidwei.uk>
---
 .../net/ethernet/broadcom/bnxt/bnxt_debugfs.c | 45 +++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_debugfs.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_debugfs.c
index 127b7015f676..e62a3ff2ffdd 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_debugfs.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_debugfs.c
@@ -10,6 +10,7 @@
 #include <linux/debugfs.h>
 #include <linux/module.h>
 #include <linux/pci.h>
+#include <net/netdev_rx_queue.h>
 #include "bnxt_hsi.h"
 #include <linux/dim.h>
 #include "bnxt.h"
@@ -61,6 +62,48 @@ static const struct file_operations debugfs_dim_fops = {
 	.read = debugfs_dim_read,
 };
 
+static ssize_t debugfs_reset_rx_write(struct file *filep,
+				      const char __user *buffer,
+				      size_t count, loff_t *ppos)
+{
+	unsigned int ring_nr;
+	struct bnxt *bp;
+	char buf[10];
+	ssize_t ret;
+	int rc;
+
+	if (*ppos != 0)
+		return 0;
+
+	if (count >= sizeof(buf))
+		return -ENOSPC;
+
+	ret = copy_from_user(buf, buffer, count);
+	if (ret)
+		return -EFAULT;
+	buf[count] = '\0';
+
+	sscanf(buf, "%u", &ring_nr);
+
+	bp = filep->private_data;
+	if (ring_nr > bp->rx_nr_rings)
+		return -EINVAL;
+
+	netdev_lock(bp->dev);
+	rc = netdev_rx_queue_restart(bp->dev, ring_nr);
+	netdev_unlock(bp->dev);
+	if (rc)
+		return rc;
+
+	return count;
+}
+
+static const struct file_operations debugfs_reset_rx_fops = {
+	.owner = THIS_MODULE,
+	.open = simple_open,
+	.write = debugfs_reset_rx_write,
+};
+
 static void debugfs_dim_ring_init(struct dim *dim, int ring_idx,
 				  struct dentry *dd)
 {
@@ -86,6 +129,8 @@ void bnxt_debug_dev_init(struct bnxt *bp)
 		if (cpr && bp->bnapi[i]->rx_ring)
 			debugfs_dim_ring_init(&cpr->dim, i, dir);
 	}
+
+	debugfs_create_file("reset_rx", 0600, bp->debugfs_pdev, bp, &debugfs_reset_rx_fops);
 }
 
 void bnxt_debug_dev_exit(struct bnxt *bp)
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-04-29 22:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-29  0:06 [PATCH net-next v1] bnxt_en: add debugfs file for restarting rx queues David Wei
2025-04-29 15:28 ` Joe Damato
2025-04-29 18:44   ` David Wei
2025-04-29 22:18 ` Jakub Kicinski
2025-04-29 22:26   ` David Wei

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).