lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250429000627.1654039-1-dw@davidwei.uk>
Date: Mon, 28 Apr 2025 17:06:27 -0700
From: David Wei <dw@...idwei.uk>
To: netdev@...r.kernel.org,
	Michael Chan <michael.chan@...adcom.com>,
	Pavan Chebbi <pavan.chebbi@...adcom.com>,
	Somnath Kotur <somnath.kotur@...adcom.com>
Cc: Andrew Lunn <andrew+netdev@...n.ch>,
	"David S. Miller" <davem@...emloft.net>,
	Eric Dumazet <edumazet@...gle.com>,
	Jakub Kicinski <kuba@...nel.org>,
	Paolo Abeni <pabeni@...hat.com>
Subject: [PATCH net-next v1] bnxt_en: add debugfs file for restarting rx queues

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@...idwei.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


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ