netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/5] eth: fbnic: cleanup and add a few stats
@ 2024-11-15  1:53 Jakub Kicinski
  2024-11-15  1:53 ` [PATCH net-next 1/5] eth: fbnic: add missing SPDX headers Jakub Kicinski
                   ` (5 more replies)
  0 siblings, 6 replies; 17+ messages in thread
From: Jakub Kicinski @ 2024-11-15  1:53 UTC (permalink / raw)
  To: davem; +Cc: netdev, edumazet, pabeni, alexanderduyck, Jakub Kicinski

Cleanup trival problems with fbnic and add the PCIe and RPC (Rx parser)
stats.

All stats are read under rtnl_lock for now, so the code is pretty
trivial. We'll need to add more locking when we start gathering
drops used by .ndo_get_stats64.

Jakub Kicinski (3):
  eth: fbnic: add missing SPDX headers
  eth: fbnic: add missing header guards
  eth: fbnic: add basic debugfs structure

Sanman Pradhan (2):
  eth: fbnic: add PCIe hardware statistics
  eth: fbnic: add RPC hardware statistics

 .../device_drivers/ethernet/meta/fbnic.rst    |  43 ++++
 drivers/net/ethernet/meta/fbnic/Makefile      |   1 +
 drivers/net/ethernet/meta/fbnic/fbnic.h       |   6 +
 drivers/net/ethernet/meta/fbnic/fbnic_csr.h   |  47 +++++
 .../net/ethernet/meta/fbnic/fbnic_debugfs.c   |  68 ++++++
 .../net/ethernet/meta/fbnic/fbnic_ethtool.c   |  74 +++++++
 .../net/ethernet/meta/fbnic/fbnic_hw_stats.c  | 193 ++++++++++++++++++
 .../net/ethernet/meta/fbnic/fbnic_hw_stats.h  |  28 +++
 drivers/net/ethernet/meta/fbnic/fbnic_pci.c   |  16 +-
 9 files changed, 475 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/ethernet/meta/fbnic/fbnic_debugfs.c

-- 
2.47.0


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

* [PATCH net-next 1/5] eth: fbnic: add missing SPDX headers
  2024-11-15  1:53 [PATCH net-next 0/5] eth: fbnic: cleanup and add a few stats Jakub Kicinski
@ 2024-11-15  1:53 ` Jakub Kicinski
  2024-11-17 20:09   ` Andrew Lunn
  2024-11-18  3:55   ` Kalesh Anakkur Purayil
  2024-11-15  1:53 ` [PATCH net-next 2/5] eth: fbnic: add missing header guards Jakub Kicinski
                   ` (4 subsequent siblings)
  5 siblings, 2 replies; 17+ messages in thread
From: Jakub Kicinski @ 2024-11-15  1:53 UTC (permalink / raw)
  To: davem; +Cc: netdev, edumazet, pabeni, alexanderduyck, Jakub Kicinski

Paolo noticed that we are missing SPDX headers, add them.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c  | 3 +++
 drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.c | 3 +++
 drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.h | 3 +++
 3 files changed, 9 insertions(+)

diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c b/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c
index 354b5397815f..589cc7c2ee52 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c
@@ -1,3 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (c) Meta Platforms, Inc. and affiliates. */
+
 #include <linux/ethtool.h>
 #include <linux/netdevice.h>
 #include <linux/pci.h>
diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.c b/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.c
index a0acc7606aa1..b3f8dc299b29 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.c
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.c
@@ -1,3 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (c) Meta Platforms, Inc. and affiliates. */
+
 #include "fbnic.h"
 
 u64 fbnic_stat_rd64(struct fbnic_dev *fbd, u32 reg, u32 offset)
diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.h b/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.h
index 30348904b510..a2b6e88fc113 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.h
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.h
@@ -1,3 +1,6 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (c) Meta Platforms, Inc. and affiliates. */
+
 #include <linux/ethtool.h>
 
 #include "fbnic_csr.h"
-- 
2.47.0


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

* [PATCH net-next 2/5] eth: fbnic: add missing header guards
  2024-11-15  1:53 [PATCH net-next 0/5] eth: fbnic: cleanup and add a few stats Jakub Kicinski
  2024-11-15  1:53 ` [PATCH net-next 1/5] eth: fbnic: add missing SPDX headers Jakub Kicinski
@ 2024-11-15  1:53 ` Jakub Kicinski
  2024-11-17 20:10   ` Andrew Lunn
  2024-11-18  3:55   ` Kalesh Anakkur Purayil
  2024-11-15  1:53 ` [PATCH net-next 3/5] eth: fbnic: add basic debugfs structure Jakub Kicinski
                   ` (3 subsequent siblings)
  5 siblings, 2 replies; 17+ messages in thread
From: Jakub Kicinski @ 2024-11-15  1:53 UTC (permalink / raw)
  To: davem; +Cc: netdev, edumazet, pabeni, alexanderduyck, Jakub Kicinski

While adding the SPDX headers I noticed we're also missing
a header guard.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.h b/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.h
index a2b6e88fc113..199ad2228ee9 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.h
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.h
@@ -1,6 +1,9 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 /* Copyright (c) Meta Platforms, Inc. and affiliates. */
 
+#ifndef _FBNIC_HW_STATS_H_
+#define _FBNIC_HW_STATS_H_
+
 #include <linux/ethtool.h>
 
 #include "fbnic_csr.h"
@@ -41,3 +44,5 @@ struct fbnic_hw_stats {
 u64 fbnic_stat_rd64(struct fbnic_dev *fbd, u32 reg, u32 offset);
 
 void fbnic_get_hw_stats(struct fbnic_dev *fbd);
+
+#endif /* _FBNIC_HW_STATS_H_ */
-- 
2.47.0


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

* [PATCH net-next 3/5] eth: fbnic: add basic debugfs structure
  2024-11-15  1:53 [PATCH net-next 0/5] eth: fbnic: cleanup and add a few stats Jakub Kicinski
  2024-11-15  1:53 ` [PATCH net-next 1/5] eth: fbnic: add missing SPDX headers Jakub Kicinski
  2024-11-15  1:53 ` [PATCH net-next 2/5] eth: fbnic: add missing header guards Jakub Kicinski
@ 2024-11-15  1:53 ` Jakub Kicinski
  2024-11-17 20:09   ` Andrew Lunn
  2024-11-18  3:56   ` Kalesh Anakkur Purayil
  2024-11-15  1:53 ` [PATCH net-next 4/5] eth: fbnic: add PCIe hardware statistics Jakub Kicinski
                   ` (2 subsequent siblings)
  5 siblings, 2 replies; 17+ messages in thread
From: Jakub Kicinski @ 2024-11-15  1:53 UTC (permalink / raw)
  To: davem; +Cc: netdev, edumazet, pabeni, alexanderduyck, Jakub Kicinski

Add the usual debugfs structure:

 fbnic/
   $pci-id/
     device-fileA
     device-fileB

This patch only adds the directories, subsequent changes
will add files.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 drivers/net/ethernet/meta/fbnic/Makefile      |  1 +
 drivers/net/ethernet/meta/fbnic/fbnic.h       |  6 ++++
 .../net/ethernet/meta/fbnic/fbnic_debugfs.c   | 34 +++++++++++++++++++
 drivers/net/ethernet/meta/fbnic/fbnic_pci.c   | 10 +++++-
 4 files changed, 50 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/ethernet/meta/fbnic/fbnic_debugfs.c

diff --git a/drivers/net/ethernet/meta/fbnic/Makefile b/drivers/net/ethernet/meta/fbnic/Makefile
index 425e8b801265..239b2258ec65 100644
--- a/drivers/net/ethernet/meta/fbnic/Makefile
+++ b/drivers/net/ethernet/meta/fbnic/Makefile
@@ -8,6 +8,7 @@
 obj-$(CONFIG_FBNIC) += fbnic.o
 
 fbnic-y := fbnic_csr.o \
+	   fbnic_debugfs.o \
 	   fbnic_devlink.o \
 	   fbnic_ethtool.o \
 	   fbnic_fw.o \
diff --git a/drivers/net/ethernet/meta/fbnic/fbnic.h b/drivers/net/ethernet/meta/fbnic/fbnic.h
index 98870cb2b689..706ae6104c8e 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic.h
+++ b/drivers/net/ethernet/meta/fbnic/fbnic.h
@@ -19,6 +19,7 @@
 struct fbnic_dev {
 	struct device *dev;
 	struct net_device *netdev;
+	struct dentry *dbg_fbd;
 	struct device *hwmon;
 
 	u32 __iomem *uc_addr0;
@@ -156,6 +157,11 @@ int fbnic_alloc_irqs(struct fbnic_dev *fbd);
 void fbnic_get_fw_ver_commit_str(struct fbnic_dev *fbd, char *fw_version,
 				 const size_t str_sz);
 
+void fbnic_dbg_fbd_init(struct fbnic_dev *fbd);
+void fbnic_dbg_fbd_exit(struct fbnic_dev *fbd);
+void fbnic_dbg_init(void);
+void fbnic_dbg_exit(void);
+
 void fbnic_csr_get_regs(struct fbnic_dev *fbd, u32 *data, u32 *regs_version);
 int fbnic_csr_regs_len(struct fbnic_dev *fbd);
 
diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_debugfs.c b/drivers/net/ethernet/meta/fbnic/fbnic_debugfs.c
new file mode 100644
index 000000000000..183c7c4914dc
--- /dev/null
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_debugfs.c
@@ -0,0 +1,34 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (c) Meta Platforms, Inc. and affiliates. */
+
+#include <linux/debugfs.h>
+#include <linux/pci.h>
+
+#include "fbnic.h"
+
+static struct dentry *fbnic_dbg_root;
+
+void fbnic_dbg_fbd_init(struct fbnic_dev *fbd)
+{
+	struct pci_dev *pdev = to_pci_dev(fbd->dev);
+	const char *name = pci_name(pdev);
+
+	fbd->dbg_fbd = debugfs_create_dir(name, fbnic_dbg_root);
+}
+
+void fbnic_dbg_fbd_exit(struct fbnic_dev *fbd)
+{
+	debugfs_remove_recursive(fbd->dbg_fbd);
+	fbd->dbg_fbd = NULL;
+}
+
+void fbnic_dbg_init(void)
+{
+	fbnic_dbg_root = debugfs_create_dir(fbnic_driver_name, NULL);
+}
+
+void fbnic_dbg_exit(void)
+{
+	debugfs_remove_recursive(fbnic_dbg_root);
+	fbnic_dbg_root = NULL;
+}
diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_pci.c b/drivers/net/ethernet/meta/fbnic/fbnic_pci.c
index f1e9aaaf66fc..877c45e6dcae 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_pci.c
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_pci.c
@@ -288,6 +288,7 @@ static int fbnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	}
 
 	fbnic_devlink_register(fbd);
+	fbnic_dbg_fbd_init(fbd);
 
 	fbnic_hwmon_register(fbd);
 
@@ -354,6 +355,7 @@ static void fbnic_remove(struct pci_dev *pdev)
 	}
 
 	fbnic_hwmon_unregister(fbd);
+	fbnic_dbg_fbd_exit(fbd);
 	fbnic_devlink_unregister(fbd);
 	fbnic_fw_disable_mbx(fbd);
 	fbnic_free_irqs(fbd);
@@ -550,9 +552,13 @@ static int __init fbnic_init_module(void)
 {
 	int err;
 
+	fbnic_dbg_init();
+
 	err = pci_register_driver(&fbnic_driver);
-	if (err)
+	if (err) {
+		fbnic_dbg_exit();
 		goto out;
+	}
 
 	pr_info(DRV_SUMMARY " (%s)", fbnic_driver.name);
 out:
@@ -568,5 +574,7 @@ module_init(fbnic_init_module);
 static void __exit fbnic_exit_module(void)
 {
 	pci_unregister_driver(&fbnic_driver);
+
+	fbnic_dbg_exit();
 }
 module_exit(fbnic_exit_module);
-- 
2.47.0


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

* [PATCH net-next 4/5] eth: fbnic: add PCIe hardware statistics
  2024-11-15  1:53 [PATCH net-next 0/5] eth: fbnic: cleanup and add a few stats Jakub Kicinski
                   ` (2 preceding siblings ...)
  2024-11-15  1:53 ` [PATCH net-next 3/5] eth: fbnic: add basic debugfs structure Jakub Kicinski
@ 2024-11-15  1:53 ` Jakub Kicinski
  2024-11-17 20:19   ` Andrew Lunn
  2024-11-15  1:53 ` [PATCH net-next 5/5] eth: fbnic: add RPC " Jakub Kicinski
  2024-11-19  3:00 ` [PATCH net-next 0/5] eth: fbnic: cleanup and add a few stats patchwork-bot+netdevbpf
  5 siblings, 1 reply; 17+ messages in thread
From: Jakub Kicinski @ 2024-11-15  1:53 UTC (permalink / raw)
  To: davem
  Cc: netdev, edumazet, pabeni, alexanderduyck, Sanman Pradhan,
	Jakub Kicinski

From: Sanman Pradhan <sanman.p211993@gmail.com>

Add PCIe hardware statistics support to the fbnic driver. These stats
provide insight into PCIe transaction performance and error conditions.

Which includes, read/write and completion TLP counts and DWORD counts and
debug counters for tag, completion credit and NP credit exhaustion

The stats are exposed via debugfs and can be used to monitor PCIe
performance and debug PCIe issues.

Signed-off-by: Sanman Pradhan <sanman.p211993@gmail.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 .../device_drivers/ethernet/meta/fbnic.rst    |  30 +++++
 drivers/net/ethernet/meta/fbnic/fbnic_csr.h   |  37 ++++++
 .../net/ethernet/meta/fbnic/fbnic_debugfs.c   |  34 ++++++
 .../net/ethernet/meta/fbnic/fbnic_hw_stats.c  | 114 ++++++++++++++++++
 .../net/ethernet/meta/fbnic/fbnic_hw_stats.h  |  12 ++
 drivers/net/ethernet/meta/fbnic/fbnic_pci.c   |   4 +
 6 files changed, 231 insertions(+)

diff --git a/Documentation/networking/device_drivers/ethernet/meta/fbnic.rst b/Documentation/networking/device_drivers/ethernet/meta/fbnic.rst
index 32ff114f5c26..14f2834d86d1 100644
--- a/Documentation/networking/device_drivers/ethernet/meta/fbnic.rst
+++ b/Documentation/networking/device_drivers/ethernet/meta/fbnic.rst
@@ -27,3 +27,33 @@ driver takes over.
 devlink dev info provides version information for all three components. In
 addition to the version the hg commit hash of the build is included as a
 separate entry.
+
+Statistics
+----------
+
+PCIe
+~~~~
+
+The fbnic driver exposes PCIe hardware performance statistics through debugfs
+(``pcie_stats``). These statistics provide insights into PCIe transaction
+behavior and potential performance bottlenecks.
+
+1. PCIe Transaction Counters:
+
+   These counters track PCIe transaction activity:
+        - ``pcie_ob_rd_tlp``: Outbound read Transaction Layer Packets count
+        - ``pcie_ob_rd_dword``: DWORDs transferred in outbound read transactions
+        - ``pcie_ob_wr_tlp``: Outbound write Transaction Layer Packets count
+        - ``pcie_ob_wr_dword``: DWORDs transferred in outbound write
+	  transactions
+        - ``pcie_ob_cpl_tlp``: Outbound completion TLP count
+        - ``pcie_ob_cpl_dword``: DWORDs transferred in outbound completion TLPs
+
+2. PCIe Resource Monitoring:
+
+   These counters indicate PCIe resource exhaustion events:
+        - ``pcie_ob_rd_no_tag``: Read requests dropped due to tag unavailability
+        - ``pcie_ob_rd_no_cpl_cred``: Read requests dropped due to completion
+	  credit exhaustion
+        - ``pcie_ob_rd_no_np_cred``: Read requests dropped due to non-posted
+	  credit exhaustion
diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_csr.h b/drivers/net/ethernet/meta/fbnic/fbnic_csr.h
index f9a531ce9e17..dac9a4879e52 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_csr.h
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_csr.h
@@ -918,6 +918,43 @@ enum {
 #define FBNIC_MAX_QUEUES		128
 #define FBNIC_CSR_END_QUEUE	(0x40000 + 0x400 * FBNIC_MAX_QUEUES - 1)
 
+/* PUL User Registers*/
+#define FBNIC_PUL_USER_OB_RD_TLP_CNT_31_0 \
+					0x3106e		/* 0xc41b8 */
+#define FBNIC_PUL_USER_OB_RD_DWORD_CNT_31_0 \
+					0x31070		/* 0xc41c0 */
+#define FBNIC_PUL_USER_OB_RD_DWORD_CNT_63_32 \
+					0x31071		/* 0xc41c4 */
+#define FBNIC_PUL_USER_OB_WR_TLP_CNT_31_0 \
+					0x31072		/* 0xc41c8 */
+#define FBNIC_PUL_USER_OB_WR_TLP_CNT_63_32 \
+					0x31073		/* 0xc41cc */
+#define FBNIC_PUL_USER_OB_WR_DWORD_CNT_31_0 \
+					0x31074		/* 0xc41d0 */
+#define FBNIC_PUL_USER_OB_WR_DWORD_CNT_63_32 \
+					0x31075		/* 0xc41d4 */
+#define FBNIC_PUL_USER_OB_CPL_TLP_CNT_31_0 \
+					0x31076		/* 0xc41d8 */
+#define FBNIC_PUL_USER_OB_CPL_TLP_CNT_63_32 \
+					0x31077		/* 0xc41dc */
+#define FBNIC_PUL_USER_OB_CPL_DWORD_CNT_31_0 \
+					0x31078		/* 0xc41e0 */
+#define FBNIC_PUL_USER_OB_CPL_DWORD_CNT_63_32 \
+					0x31079		/* 0xc41e4 */
+#define FBNIC_PUL_USER_OB_RD_DBG_CNT_CPL_CRED_31_0 \
+					0x3107a		/* 0xc41e8 */
+#define FBNIC_PUL_USER_OB_RD_DBG_CNT_CPL_CRED_63_32 \
+					0x3107b		/* 0xc41ec */
+#define FBNIC_PUL_USER_OB_RD_DBG_CNT_TAG_31_0 \
+					0x3107c		/* 0xc41f0 */
+#define FBNIC_PUL_USER_OB_RD_DBG_CNT_TAG_63_32 \
+					0x3107d		/* 0xc41f4 */
+#define FBNIC_PUL_USER_OB_RD_DBG_CNT_NP_CRED_31_0 \
+					0x3107e		/* 0xc41f8 */
+#define FBNIC_PUL_USER_OB_RD_DBG_CNT_NP_CRED_63_32 \
+					0x3107f		/* 0xc41fc */
+#define FBNIC_CSR_END_PUL_USER	0x31080	/* CSR section delimiter */
+
 /* BAR 4 CSRs */
 
 /* The IPC mailbox consists of 32 mailboxes, with each mailbox consisting
diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_debugfs.c b/drivers/net/ethernet/meta/fbnic/fbnic_debugfs.c
index 183c7c4914dc..59951b5abdb7 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_debugfs.c
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_debugfs.c
@@ -3,17 +3,51 @@
 
 #include <linux/debugfs.h>
 #include <linux/pci.h>
+#include <linux/rtnetlink.h>
+#include <linux/seq_file.h>
 
 #include "fbnic.h"
 
 static struct dentry *fbnic_dbg_root;
 
+static int fbnic_dbg_pcie_stats_show(struct seq_file *s, void *v)
+{
+	struct fbnic_dev *fbd = s->private;
+
+	rtnl_lock();
+	fbnic_get_hw_stats(fbd);
+
+	seq_printf(s, "ob_rd_tlp: %llu\n", fbd->hw_stats.pcie.ob_rd_tlp.value);
+	seq_printf(s, "ob_rd_dword: %llu\n",
+		   fbd->hw_stats.pcie.ob_rd_dword.value);
+	seq_printf(s, "ob_wr_tlp: %llu\n", fbd->hw_stats.pcie.ob_wr_tlp.value);
+	seq_printf(s, "ob_wr_dword: %llu\n",
+		   fbd->hw_stats.pcie.ob_wr_dword.value);
+	seq_printf(s, "ob_cpl_tlp: %llu\n",
+		   fbd->hw_stats.pcie.ob_cpl_tlp.value);
+	seq_printf(s, "ob_cpl_dword: %llu\n",
+		   fbd->hw_stats.pcie.ob_cpl_dword.value);
+	seq_printf(s, "ob_rd_no_tag: %llu\n",
+		   fbd->hw_stats.pcie.ob_rd_no_tag.value);
+	seq_printf(s, "ob_rd_no_cpl_cred: %llu\n",
+		   fbd->hw_stats.pcie.ob_rd_no_cpl_cred.value);
+	seq_printf(s, "ob_rd_no_np_cred: %llu\n",
+		   fbd->hw_stats.pcie.ob_rd_no_np_cred.value);
+	rtnl_unlock();
+
+	return 0;
+}
+
+DEFINE_SHOW_ATTRIBUTE(fbnic_dbg_pcie_stats);
+
 void fbnic_dbg_fbd_init(struct fbnic_dev *fbd)
 {
 	struct pci_dev *pdev = to_pci_dev(fbd->dev);
 	const char *name = pci_name(pdev);
 
 	fbd->dbg_fbd = debugfs_create_dir(name, fbnic_dbg_root);
+	debugfs_create_file("pcie_stats", 0400, fbd->dbg_fbd, fbd,
+			    &fbnic_dbg_pcie_stats_fops);
 }
 
 void fbnic_dbg_fbd_exit(struct fbnic_dev *fbd)
diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.c b/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.c
index b3f8dc299b29..c391f2155054 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.c
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.c
@@ -28,3 +28,117 @@ u64 fbnic_stat_rd64(struct fbnic_dev *fbd, u32 reg, u32 offset)
 	 */
 	return ((u64)upper << 32);
 }
+
+static void fbnic_hw_stat_rst64(struct fbnic_dev *fbd, u32 reg, s32 offset,
+				struct fbnic_stat_counter *stat)
+{
+	/* Record initial counter values and compute deltas from there to ensure
+	 * stats start at 0 after reboot/reset. This avoids exposing absolute
+	 * hardware counter values to userspace.
+	 */
+	stat->u.old_reg_value_64 = fbnic_stat_rd64(fbd, reg, offset);
+}
+
+static void fbnic_hw_stat_rd64(struct fbnic_dev *fbd, u32 reg, s32 offset,
+			       struct fbnic_stat_counter *stat)
+{
+	u64 new_reg_value;
+
+	new_reg_value = fbnic_stat_rd64(fbd, reg, offset);
+	stat->value += new_reg_value - stat->u.old_reg_value_64;
+	stat->u.old_reg_value_64 = new_reg_value;
+}
+
+static void fbnic_reset_pcie_stats_asic(struct fbnic_dev *fbd,
+					struct fbnic_pcie_stats *pcie)
+{
+	fbnic_hw_stat_rst64(fbd,
+			    FBNIC_PUL_USER_OB_RD_TLP_CNT_31_0,
+			    1,
+			    &pcie->ob_rd_tlp);
+	fbnic_hw_stat_rst64(fbd,
+			    FBNIC_PUL_USER_OB_RD_DWORD_CNT_31_0,
+			    1,
+			    &pcie->ob_rd_dword);
+	fbnic_hw_stat_rst64(fbd,
+			    FBNIC_PUL_USER_OB_CPL_TLP_CNT_31_0,
+			    1,
+			    &pcie->ob_cpl_tlp);
+	fbnic_hw_stat_rst64(fbd,
+			    FBNIC_PUL_USER_OB_CPL_DWORD_CNT_31_0,
+			    1,
+			    &pcie->ob_cpl_dword);
+	fbnic_hw_stat_rst64(fbd,
+			    FBNIC_PUL_USER_OB_WR_TLP_CNT_31_0,
+			    1,
+			    &pcie->ob_wr_tlp);
+	fbnic_hw_stat_rst64(fbd,
+			    FBNIC_PUL_USER_OB_WR_DWORD_CNT_31_0,
+			    1,
+			    &pcie->ob_wr_dword);
+
+	fbnic_hw_stat_rst64(fbd,
+			    FBNIC_PUL_USER_OB_RD_DBG_CNT_TAG_31_0,
+			    1,
+			    &pcie->ob_rd_no_tag);
+	fbnic_hw_stat_rst64(fbd,
+			    FBNIC_PUL_USER_OB_RD_DBG_CNT_CPL_CRED_31_0,
+			    1,
+			    &pcie->ob_rd_no_cpl_cred);
+	fbnic_hw_stat_rst64(fbd,
+			    FBNIC_PUL_USER_OB_RD_DBG_CNT_NP_CRED_31_0,
+			    1,
+			    &pcie->ob_rd_no_np_cred);
+}
+
+static void fbnic_get_pcie_stats_asic64(struct fbnic_dev *fbd,
+					struct fbnic_pcie_stats *pcie)
+{
+	fbnic_hw_stat_rd64(fbd,
+			   FBNIC_PUL_USER_OB_RD_TLP_CNT_31_0,
+			   1,
+			   &pcie->ob_rd_tlp);
+	fbnic_hw_stat_rd64(fbd,
+			   FBNIC_PUL_USER_OB_RD_DWORD_CNT_31_0,
+			   1,
+			   &pcie->ob_rd_dword);
+	fbnic_hw_stat_rd64(fbd,
+			   FBNIC_PUL_USER_OB_WR_TLP_CNT_31_0,
+			   1,
+			   &pcie->ob_wr_tlp);
+	fbnic_hw_stat_rd64(fbd,
+			   FBNIC_PUL_USER_OB_WR_DWORD_CNT_31_0,
+			   1,
+			   &pcie->ob_wr_dword);
+	fbnic_hw_stat_rd64(fbd,
+			   FBNIC_PUL_USER_OB_CPL_TLP_CNT_31_0,
+			   1,
+			   &pcie->ob_cpl_tlp);
+	fbnic_hw_stat_rd64(fbd,
+			   FBNIC_PUL_USER_OB_CPL_DWORD_CNT_31_0,
+			   1,
+			   &pcie->ob_cpl_dword);
+
+	fbnic_hw_stat_rd64(fbd,
+			   FBNIC_PUL_USER_OB_RD_DBG_CNT_TAG_31_0,
+			   1,
+			   &pcie->ob_rd_no_tag);
+	fbnic_hw_stat_rd64(fbd,
+			   FBNIC_PUL_USER_OB_RD_DBG_CNT_CPL_CRED_31_0,
+			   1,
+			   &pcie->ob_rd_no_cpl_cred);
+	fbnic_hw_stat_rd64(fbd,
+			   FBNIC_PUL_USER_OB_RD_DBG_CNT_NP_CRED_31_0,
+			   1,
+			   &pcie->ob_rd_no_np_cred);
+}
+
+void fbnic_reset_hw_stats(struct fbnic_dev *fbd)
+{
+	fbnic_reset_pcie_stats_asic(fbd, &fbd->hw_stats.pcie);
+}
+
+void fbnic_get_hw_stats(struct fbnic_dev *fbd)
+{
+	fbnic_get_pcie_stats_asic64(fbd, &fbd->hw_stats.pcie);
+}
diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.h b/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.h
index 199ad2228ee9..b152c6b1b4ab 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.h
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.h
@@ -37,12 +37,24 @@ struct fbnic_mac_stats {
 	struct fbnic_eth_mac_stats eth_mac;
 };
 
+struct fbnic_pcie_stats {
+	struct fbnic_stat_counter ob_rd_tlp, ob_rd_dword;
+	struct fbnic_stat_counter ob_wr_tlp, ob_wr_dword;
+	struct fbnic_stat_counter ob_cpl_tlp, ob_cpl_dword;
+
+	struct fbnic_stat_counter ob_rd_no_tag;
+	struct fbnic_stat_counter ob_rd_no_cpl_cred;
+	struct fbnic_stat_counter ob_rd_no_np_cred;
+};
+
 struct fbnic_hw_stats {
 	struct fbnic_mac_stats mac;
+	struct fbnic_pcie_stats pcie;
 };
 
 u64 fbnic_stat_rd64(struct fbnic_dev *fbd, u32 reg, u32 offset);
 
+void fbnic_reset_hw_stats(struct fbnic_dev *fbd);
 void fbnic_get_hw_stats(struct fbnic_dev *fbd);
 
 #endif /* _FBNIC_HW_STATS_H_ */
diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_pci.c b/drivers/net/ethernet/meta/fbnic/fbnic_pci.c
index 877c45e6dcae..0aa95160f006 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_pci.c
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_pci.c
@@ -9,6 +9,7 @@
 
 #include "fbnic.h"
 #include "fbnic_drvinfo.h"
+#include "fbnic_hw_stats.h"
 #include "fbnic_netdev.h"
 
 char fbnic_driver_name[] = DRV_NAME;
@@ -290,6 +291,9 @@ static int fbnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	fbnic_devlink_register(fbd);
 	fbnic_dbg_fbd_init(fbd);
 
+	/* Capture snapshot of hardware stats so netdev can calculate delta */
+	fbnic_reset_hw_stats(fbd);
+
 	fbnic_hwmon_register(fbd);
 
 	if (!fbd->dsn) {
-- 
2.47.0


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

* [PATCH net-next 5/5] eth: fbnic: add RPC hardware statistics
  2024-11-15  1:53 [PATCH net-next 0/5] eth: fbnic: cleanup and add a few stats Jakub Kicinski
                   ` (3 preceding siblings ...)
  2024-11-15  1:53 ` [PATCH net-next 4/5] eth: fbnic: add PCIe hardware statistics Jakub Kicinski
@ 2024-11-15  1:53 ` Jakub Kicinski
  2024-11-17 20:24   ` Andrew Lunn
  2024-11-19  3:00 ` [PATCH net-next 0/5] eth: fbnic: cleanup and add a few stats patchwork-bot+netdevbpf
  5 siblings, 1 reply; 17+ messages in thread
From: Jakub Kicinski @ 2024-11-15  1:53 UTC (permalink / raw)
  To: davem
  Cc: netdev, edumazet, pabeni, alexanderduyck, Sanman Pradhan,
	Jakub Kicinski

From: Sanman Pradhan <sanman.p211993@gmail.com>

Report Rx parser statistics via ethtool -S.

The parser stats are 32b, so we need to add refresh to the service
task to make sure we don't miss overflows.

Signed-off-by: Sanman Pradhan <sanman.p211993@gmail.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 .../device_drivers/ethernet/meta/fbnic.rst    | 13 ++++
 drivers/net/ethernet/meta/fbnic/fbnic_csr.h   | 10 +++
 .../net/ethernet/meta/fbnic/fbnic_ethtool.c   | 71 +++++++++++++++++
 .../net/ethernet/meta/fbnic/fbnic_hw_stats.c  | 76 +++++++++++++++++++
 .../net/ethernet/meta/fbnic/fbnic_hw_stats.h  |  8 ++
 drivers/net/ethernet/meta/fbnic/fbnic_pci.c   |  2 +
 6 files changed, 180 insertions(+)

diff --git a/Documentation/networking/device_drivers/ethernet/meta/fbnic.rst b/Documentation/networking/device_drivers/ethernet/meta/fbnic.rst
index 14f2834d86d1..04e0595bb0a7 100644
--- a/Documentation/networking/device_drivers/ethernet/meta/fbnic.rst
+++ b/Documentation/networking/device_drivers/ethernet/meta/fbnic.rst
@@ -31,6 +31,19 @@ separate entry.
 Statistics
 ----------
 
+RPC (Rx parser)
+~~~~~~~~~~~~~~~
+
+ - ``rpc_unkn_etype``: frames containing unknown EtherType
+ - ``rpc_unkn_ext_hdr``: frames containing unknown IPv6 extension header
+ - ``rpc_ipv4_frag``: frames containing IPv4 fragment
+ - ``rpc_ipv6_frag``: frames containing IPv6 fragment
+ - ``rpc_ipv4_esp``: frames with IPv4 ESP encapsulation
+ - ``rpc_ipv6_esp``: frames with IPv6 ESP encapsulation
+ - ``rpc_tcp_opt_err``: frames which encountered TCP option parsing error
+ - ``rpc_out_of_hdr_err``: frames where header was larger than parsable region
+ - ``ovr_size_err``: oversized frames
+
 PCIe
 ~~~~
 
diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_csr.h b/drivers/net/ethernet/meta/fbnic/fbnic_csr.h
index dac9a4879e52..02bb81b3c506 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_csr.h
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_csr.h
@@ -638,6 +638,16 @@ enum {
 		    FBNIC_RPC_RSS_KEY_DWORD_LEN * 32 - \
 		    FBNIC_RPC_RSS_KEY_BIT_LEN)
 
+#define FBNIC_RPC_CNTR_TCP_OPT_ERR	0x0849e		/* 0x21278 */
+#define FBNIC_RPC_CNTR_UNKN_ETYPE	0x0849f		/* 0x2127c */
+#define FBNIC_RPC_CNTR_IPV4_FRAG	0x084a0		/* 0x21280 */
+#define FBNIC_RPC_CNTR_IPV6_FRAG	0x084a1		/* 0x21284 */
+#define FBNIC_RPC_CNTR_IPV4_ESP		0x084a2		/* 0x21288 */
+#define FBNIC_RPC_CNTR_IPV6_ESP		0x084a3		/* 0x2128c */
+#define FBNIC_RPC_CNTR_UNKN_EXT_HDR	0x084a4		/* 0x21290 */
+#define FBNIC_RPC_CNTR_OUT_OF_HDR_ERR	0x084a5		/* 0x21294 */
+#define FBNIC_RPC_CNTR_OVR_SIZE_ERR	0x084a6		/* 0x21298 */
+
 #define FBNIC_RPC_TCAM_MACDA_VALIDATE	0x0852d		/* 0x214b4 */
 #define FBNIC_CSR_END_RPC		0x0856b	/* CSR section delimiter */
 
diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c b/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c
index 589cc7c2ee52..cc8ca94529ca 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c
@@ -9,6 +9,37 @@
 #include "fbnic_netdev.h"
 #include "fbnic_tlv.h"
 
+struct fbnic_stat {
+	u8 string[ETH_GSTRING_LEN];
+	unsigned int size;
+	unsigned int offset;
+};
+
+#define FBNIC_STAT_FIELDS(type, name, stat) { \
+	.string = name, \
+	.size = sizeof_field(struct type, stat), \
+	.offset = offsetof(struct type, stat), \
+}
+
+/* Hardware statistics not captured in rtnl_link_stats */
+#define FBNIC_HW_STAT(name, stat) \
+	FBNIC_STAT_FIELDS(fbnic_hw_stats, name, stat)
+
+static const struct fbnic_stat fbnic_gstrings_hw_stats[] = {
+	/* RPC */
+	FBNIC_HW_STAT("rpc_unkn_etype", rpc.unkn_etype),
+	FBNIC_HW_STAT("rpc_unkn_ext_hdr", rpc.unkn_ext_hdr),
+	FBNIC_HW_STAT("rpc_ipv4_frag", rpc.ipv4_frag),
+	FBNIC_HW_STAT("rpc_ipv6_frag", rpc.ipv6_frag),
+	FBNIC_HW_STAT("rpc_ipv4_esp", rpc.ipv4_esp),
+	FBNIC_HW_STAT("rpc_ipv6_esp", rpc.ipv6_esp),
+	FBNIC_HW_STAT("rpc_tcp_opt_err", rpc.tcp_opt_err),
+	FBNIC_HW_STAT("rpc_out_of_hdr_err", rpc.out_of_hdr_err),
+};
+
+#define FBNIC_HW_FIXED_STATS_LEN ARRAY_SIZE(fbnic_gstrings_hw_stats)
+#define FBNIC_HW_STATS_LEN	FBNIC_HW_FIXED_STATS_LEN
+
 static int
 fbnic_get_ts_info(struct net_device *netdev,
 		  struct kernel_ethtool_ts_info *tsinfo)
@@ -54,6 +85,43 @@ static void fbnic_set_counter(u64 *stat, struct fbnic_stat_counter *counter)
 		*stat = counter->value;
 }
 
+static void fbnic_get_strings(struct net_device *dev, u32 sset, u8 *data)
+{
+	int i;
+
+	switch (sset) {
+	case ETH_SS_STATS:
+		for (i = 0; i < FBNIC_HW_STATS_LEN; i++)
+			ethtool_puts(&data, fbnic_gstrings_hw_stats[i].string);
+		break;
+	}
+}
+
+static int fbnic_get_sset_count(struct net_device *dev, int sset)
+{
+	switch (sset) {
+	case ETH_SS_STATS:
+		return FBNIC_HW_STATS_LEN;
+	default:
+		return -EOPNOTSUPP;
+	}
+}
+
+static void fbnic_get_ethtool_stats(struct net_device *dev,
+				    struct ethtool_stats *stats, u64 *data)
+{
+	struct fbnic_net *fbn = netdev_priv(dev);
+	const struct fbnic_stat *stat;
+	int i;
+
+	fbnic_get_hw_stats(fbn->fbd);
+
+	for (i = 0; i < FBNIC_HW_STATS_LEN; i++) {
+		stat = &fbnic_gstrings_hw_stats[i];
+		data[i] = *(u64 *)((u8 *)&fbn->fbd->hw_stats + stat->offset);
+	}
+}
+
 static void
 fbnic_get_eth_mac_stats(struct net_device *netdev,
 			struct ethtool_eth_mac_stats *eth_mac_stats)
@@ -138,6 +206,9 @@ static const struct ethtool_ops fbnic_ethtool_ops = {
 	.get_drvinfo		= fbnic_get_drvinfo,
 	.get_regs_len		= fbnic_get_regs_len,
 	.get_regs		= fbnic_get_regs,
+	.get_strings		= fbnic_get_strings,
+	.get_ethtool_stats	= fbnic_get_ethtool_stats,
+	.get_sset_count		= fbnic_get_sset_count,
 	.get_ts_info		= fbnic_get_ts_info,
 	.get_ts_stats		= fbnic_get_ts_stats,
 	.get_eth_mac_stats	= fbnic_get_eth_mac_stats,
diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.c b/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.c
index c391f2155054..89ac6bc8c7fc 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.c
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.c
@@ -3,6 +3,27 @@
 
 #include "fbnic.h"
 
+static void fbnic_hw_stat_rst32(struct fbnic_dev *fbd, u32 reg,
+				struct fbnic_stat_counter *stat)
+{
+	/* We do not touch the "value" field here.
+	 * It gets zeroed out on fbd structure allocation.
+	 * After that we want it to grow continuously
+	 * through device resets and power state changes.
+	 */
+	stat->u.old_reg_value_32 = rd32(fbd, reg);
+}
+
+static void fbnic_hw_stat_rd32(struct fbnic_dev *fbd, u32 reg,
+			       struct fbnic_stat_counter *stat)
+{
+	u32 new_reg_value;
+
+	new_reg_value = rd32(fbd, reg);
+	stat->value += new_reg_value - stat->u.old_reg_value_32;
+	stat->u.old_reg_value_32 = new_reg_value;
+}
+
 u64 fbnic_stat_rd64(struct fbnic_dev *fbd, u32 reg, u32 offset)
 {
 	u32 prev_upper, upper, lower, diff;
@@ -49,6 +70,53 @@ static void fbnic_hw_stat_rd64(struct fbnic_dev *fbd, u32 reg, s32 offset,
 	stat->u.old_reg_value_64 = new_reg_value;
 }
 
+static void fbnic_reset_rpc_stats(struct fbnic_dev *fbd,
+				  struct fbnic_rpc_stats *rpc)
+{
+	fbnic_hw_stat_rst32(fbd,
+			    FBNIC_RPC_CNTR_UNKN_ETYPE,
+			    &rpc->unkn_etype);
+	fbnic_hw_stat_rst32(fbd,
+			    FBNIC_RPC_CNTR_UNKN_EXT_HDR,
+			    &rpc->unkn_ext_hdr);
+	fbnic_hw_stat_rst32(fbd, FBNIC_RPC_CNTR_IPV4_FRAG, &rpc->ipv4_frag);
+	fbnic_hw_stat_rst32(fbd, FBNIC_RPC_CNTR_IPV6_FRAG, &rpc->ipv6_frag);
+	fbnic_hw_stat_rst32(fbd, FBNIC_RPC_CNTR_IPV4_ESP, &rpc->ipv4_esp);
+	fbnic_hw_stat_rst32(fbd, FBNIC_RPC_CNTR_IPV6_ESP, &rpc->ipv6_esp);
+	fbnic_hw_stat_rst32(fbd, FBNIC_RPC_CNTR_TCP_OPT_ERR, &rpc->tcp_opt_err);
+	fbnic_hw_stat_rst32(fbd,
+			    FBNIC_RPC_CNTR_OUT_OF_HDR_ERR,
+			    &rpc->out_of_hdr_err);
+	fbnic_hw_stat_rst32(fbd,
+			    FBNIC_RPC_CNTR_OVR_SIZE_ERR,
+			    &rpc->ovr_size_err);
+}
+
+static void fbnic_get_rpc_stats32(struct fbnic_dev *fbd,
+				  struct fbnic_rpc_stats *rpc)
+{
+	fbnic_hw_stat_rd32(fbd,
+			   FBNIC_RPC_CNTR_UNKN_ETYPE,
+			   &rpc->unkn_etype);
+	fbnic_hw_stat_rd32(fbd,
+			   FBNIC_RPC_CNTR_UNKN_EXT_HDR,
+			   &rpc->unkn_ext_hdr);
+
+	fbnic_hw_stat_rd32(fbd, FBNIC_RPC_CNTR_IPV4_FRAG, &rpc->ipv4_frag);
+	fbnic_hw_stat_rd32(fbd, FBNIC_RPC_CNTR_IPV6_FRAG, &rpc->ipv6_frag);
+
+	fbnic_hw_stat_rd32(fbd, FBNIC_RPC_CNTR_IPV4_ESP, &rpc->ipv4_esp);
+	fbnic_hw_stat_rd32(fbd, FBNIC_RPC_CNTR_IPV6_ESP, &rpc->ipv6_esp);
+
+	fbnic_hw_stat_rd32(fbd, FBNIC_RPC_CNTR_TCP_OPT_ERR, &rpc->tcp_opt_err);
+	fbnic_hw_stat_rd32(fbd,
+			   FBNIC_RPC_CNTR_OUT_OF_HDR_ERR,
+			   &rpc->out_of_hdr_err);
+	fbnic_hw_stat_rd32(fbd,
+			   FBNIC_RPC_CNTR_OVR_SIZE_ERR,
+			   &rpc->ovr_size_err);
+}
+
 static void fbnic_reset_pcie_stats_asic(struct fbnic_dev *fbd,
 					struct fbnic_pcie_stats *pcie)
 {
@@ -135,10 +203,18 @@ static void fbnic_get_pcie_stats_asic64(struct fbnic_dev *fbd,
 
 void fbnic_reset_hw_stats(struct fbnic_dev *fbd)
 {
+	fbnic_reset_rpc_stats(fbd, &fbd->hw_stats.rpc);
 	fbnic_reset_pcie_stats_asic(fbd, &fbd->hw_stats.pcie);
 }
 
+void fbnic_get_hw_stats32(struct fbnic_dev *fbd)
+{
+	fbnic_get_rpc_stats32(fbd, &fbd->hw_stats.rpc);
+}
+
 void fbnic_get_hw_stats(struct fbnic_dev *fbd)
 {
+	fbnic_get_hw_stats32(fbd);
+
 	fbnic_get_pcie_stats_asic64(fbd, &fbd->hw_stats.pcie);
 }
diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.h b/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.h
index b152c6b1b4ab..78df56b87745 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.h
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.h
@@ -37,6 +37,12 @@ struct fbnic_mac_stats {
 	struct fbnic_eth_mac_stats eth_mac;
 };
 
+struct fbnic_rpc_stats {
+	struct fbnic_stat_counter unkn_etype, unkn_ext_hdr;
+	struct fbnic_stat_counter ipv4_frag, ipv6_frag, ipv4_esp, ipv6_esp;
+	struct fbnic_stat_counter tcp_opt_err, out_of_hdr_err, ovr_size_err;
+};
+
 struct fbnic_pcie_stats {
 	struct fbnic_stat_counter ob_rd_tlp, ob_rd_dword;
 	struct fbnic_stat_counter ob_wr_tlp, ob_wr_dword;
@@ -49,12 +55,14 @@ struct fbnic_pcie_stats {
 
 struct fbnic_hw_stats {
 	struct fbnic_mac_stats mac;
+	struct fbnic_rpc_stats rpc;
 	struct fbnic_pcie_stats pcie;
 };
 
 u64 fbnic_stat_rd64(struct fbnic_dev *fbd, u32 reg, u32 offset);
 
 void fbnic_reset_hw_stats(struct fbnic_dev *fbd);
+void fbnic_get_hw_stats32(struct fbnic_dev *fbd);
 void fbnic_get_hw_stats(struct fbnic_dev *fbd);
 
 #endif /* _FBNIC_HW_STATS_H_ */
diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_pci.c b/drivers/net/ethernet/meta/fbnic/fbnic_pci.c
index 0aa95160f006..32702dc4a066 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_pci.c
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_pci.c
@@ -199,6 +199,8 @@ static void fbnic_service_task(struct work_struct *work)
 
 	rtnl_lock();
 
+	fbnic_get_hw_stats32(fbd);
+
 	fbnic_fw_check_heartbeat(fbd);
 
 	fbnic_health_check(fbd);
-- 
2.47.0


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

* Re: [PATCH net-next 3/5] eth: fbnic: add basic debugfs structure
  2024-11-15  1:53 ` [PATCH net-next 3/5] eth: fbnic: add basic debugfs structure Jakub Kicinski
@ 2024-11-17 20:09   ` Andrew Lunn
  2024-11-18  3:56   ` Kalesh Anakkur Purayil
  1 sibling, 0 replies; 17+ messages in thread
From: Andrew Lunn @ 2024-11-17 20:09 UTC (permalink / raw)
  To: Jakub Kicinski; +Cc: davem, netdev, edumazet, pabeni, alexanderduyck

On Thu, Nov 14, 2024 at 05:53:42PM -0800, Jakub Kicinski wrote:
> Add the usual debugfs structure:
> 
>  fbnic/
>    $pci-id/
>      device-fileA
>      device-fileB
> 
> This patch only adds the directories, subsequent changes
> will add files.
> 
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>

This looks a lot better than previous attempts. Thanks.

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

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

* Re: [PATCH net-next 1/5] eth: fbnic: add missing SPDX headers
  2024-11-15  1:53 ` [PATCH net-next 1/5] eth: fbnic: add missing SPDX headers Jakub Kicinski
@ 2024-11-17 20:09   ` Andrew Lunn
  2024-11-18  3:55   ` Kalesh Anakkur Purayil
  1 sibling, 0 replies; 17+ messages in thread
From: Andrew Lunn @ 2024-11-17 20:09 UTC (permalink / raw)
  To: Jakub Kicinski; +Cc: davem, netdev, edumazet, pabeni, alexanderduyck

On Thu, Nov 14, 2024 at 05:53:40PM -0800, Jakub Kicinski wrote:
> Paolo noticed that we are missing SPDX headers, add them.
> 
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

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

* Re: [PATCH net-next 2/5] eth: fbnic: add missing header guards
  2024-11-15  1:53 ` [PATCH net-next 2/5] eth: fbnic: add missing header guards Jakub Kicinski
@ 2024-11-17 20:10   ` Andrew Lunn
  2024-11-18  3:55   ` Kalesh Anakkur Purayil
  1 sibling, 0 replies; 17+ messages in thread
From: Andrew Lunn @ 2024-11-17 20:10 UTC (permalink / raw)
  To: Jakub Kicinski; +Cc: davem, netdev, edumazet, pabeni, alexanderduyck

On Thu, Nov 14, 2024 at 05:53:41PM -0800, Jakub Kicinski wrote:
> While adding the SPDX headers I noticed we're also missing
> a header guard.
> 
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

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

* Re: [PATCH net-next 4/5] eth: fbnic: add PCIe hardware statistics
  2024-11-15  1:53 ` [PATCH net-next 4/5] eth: fbnic: add PCIe hardware statistics Jakub Kicinski
@ 2024-11-17 20:19   ` Andrew Lunn
  2024-11-18 15:35     ` Jakub Kicinski
  0 siblings, 1 reply; 17+ messages in thread
From: Andrew Lunn @ 2024-11-17 20:19 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: davem, netdev, edumazet, pabeni, alexanderduyck, Sanman Pradhan

> +/* PUL User Registers*/
> +#define FBNIC_PUL_USER_OB_RD_TLP_CNT_31_0 \
> +					0x3106e		/* 0xc41b8 */

Is there a comment somewhere which explains what these comments mean?
Otherwise they appear to be useless magic numbers.

> +static void fbnic_hw_stat_rst64(struct fbnic_dev *fbd, u32 reg, s32 offset,
> +				struct fbnic_stat_counter *stat)
> +{
> +	/* Record initial counter values and compute deltas from there to ensure
> +	 * stats start at 0 after reboot/reset. This avoids exposing absolute
> +	 * hardware counter values to userspace.
> +	 */
> +	stat->u.old_reg_value_64 = fbnic_stat_rd64(fbd, reg, offset);

I don't know how you use these stats, but now they are in debugfs, do
they actually need to be 0 after reboot/reset? For most debugging
performance issues with statistics, i want to know how much a counter
goes up per second, so userspace will be reading the values twice with
a sleep, and doing a subtractions anyway. So why not make the kernel
code simpler?

     Andrew

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

* Re: [PATCH net-next 5/5] eth: fbnic: add RPC hardware statistics
  2024-11-15  1:53 ` [PATCH net-next 5/5] eth: fbnic: add RPC " Jakub Kicinski
@ 2024-11-17 20:24   ` Andrew Lunn
  0 siblings, 0 replies; 17+ messages in thread
From: Andrew Lunn @ 2024-11-17 20:24 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: davem, netdev, edumazet, pabeni, alexanderduyck, Sanman Pradhan

On Thu, Nov 14, 2024 at 05:53:44PM -0800, Jakub Kicinski wrote:
> From: Sanman Pradhan <sanman.p211993@gmail.com>
> 
> Report Rx parser statistics via ethtool -S.
> 
> The parser stats are 32b, so we need to add refresh to the service
> task to make sure we don't miss overflows.
> 
> Signed-off-by: Sanman Pradhan <sanman.p211993@gmail.com>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

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

* Re: [PATCH net-next 2/5] eth: fbnic: add missing header guards
  2024-11-15  1:53 ` [PATCH net-next 2/5] eth: fbnic: add missing header guards Jakub Kicinski
  2024-11-17 20:10   ` Andrew Lunn
@ 2024-11-18  3:55   ` Kalesh Anakkur Purayil
  1 sibling, 0 replies; 17+ messages in thread
From: Kalesh Anakkur Purayil @ 2024-11-18  3:55 UTC (permalink / raw)
  To: Jakub Kicinski; +Cc: davem, netdev, edumazet, pabeni, alexanderduyck

[-- Attachment #1: Type: text/plain, Size: 315 bytes --]

On Fri, Nov 15, 2024 at 7:24 AM Jakub Kicinski <kuba@kernel.org> wrote:
>
> While adding the SPDX headers I noticed we're also missing
> a header guard.
>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>

LGTM,
Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>


-- 
Regards,
Kalesh A P

[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4239 bytes --]

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

* Re: [PATCH net-next 1/5] eth: fbnic: add missing SPDX headers
  2024-11-15  1:53 ` [PATCH net-next 1/5] eth: fbnic: add missing SPDX headers Jakub Kicinski
  2024-11-17 20:09   ` Andrew Lunn
@ 2024-11-18  3:55   ` Kalesh Anakkur Purayil
  1 sibling, 0 replies; 17+ messages in thread
From: Kalesh Anakkur Purayil @ 2024-11-18  3:55 UTC (permalink / raw)
  To: Jakub Kicinski; +Cc: davem, netdev, edumazet, pabeni, alexanderduyck

[-- Attachment #1: Type: text/plain, Size: 295 bytes --]

On Fri, Nov 15, 2024 at 7:24 AM Jakub Kicinski <kuba@kernel.org> wrote:
>
> Paolo noticed that we are missing SPDX headers, add them.
>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>

LGTM,
Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>


-- 
Regards,
Kalesh A P

[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4239 bytes --]

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

* Re: [PATCH net-next 3/5] eth: fbnic: add basic debugfs structure
  2024-11-15  1:53 ` [PATCH net-next 3/5] eth: fbnic: add basic debugfs structure Jakub Kicinski
  2024-11-17 20:09   ` Andrew Lunn
@ 2024-11-18  3:56   ` Kalesh Anakkur Purayil
  1 sibling, 0 replies; 17+ messages in thread
From: Kalesh Anakkur Purayil @ 2024-11-18  3:56 UTC (permalink / raw)
  To: Jakub Kicinski; +Cc: davem, netdev, edumazet, pabeni, alexanderduyck

[-- Attachment #1: Type: text/plain, Size: 423 bytes --]

On Fri, Nov 15, 2024 at 7:24 AM Jakub Kicinski <kuba@kernel.org> wrote:
>
> Add the usual debugfs structure:
>
>  fbnic/
>    $pci-id/
>      device-fileA
>      device-fileB
>
> This patch only adds the directories, subsequent changes
> will add files.
>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>

LGTM,
Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>


-- 
Regards,
Kalesh A P

[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4239 bytes --]

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

* Re: [PATCH net-next 4/5] eth: fbnic: add PCIe hardware statistics
  2024-11-17 20:19   ` Andrew Lunn
@ 2024-11-18 15:35     ` Jakub Kicinski
  2024-11-18 15:40       ` Andrew Lunn
  0 siblings, 1 reply; 17+ messages in thread
From: Jakub Kicinski @ 2024-11-18 15:35 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: davem, netdev, edumazet, pabeni, alexanderduyck, Sanman Pradhan

On Sun, 17 Nov 2024 21:19:00 +0100 Andrew Lunn wrote:
> > +/* PUL User Registers*/
> > +#define FBNIC_PUL_USER_OB_RD_TLP_CNT_31_0 \
> > +					0x3106e		/* 0xc41b8 */  
> 
> Is there a comment somewhere which explains what these comments mean?
> Otherwise they appear to be useless magic numbers.

The number on the left is the number on the right divided by 4.
We index the registers as an array of u32s so the define is an index,
but for grep-ability we add the absolute address in the comment.

> > +static void fbnic_hw_stat_rst64(struct fbnic_dev *fbd, u32 reg, s32 offset,
> > +				struct fbnic_stat_counter *stat)
> > +{
> > +	/* Record initial counter values and compute deltas from there to ensure
> > +	 * stats start at 0 after reboot/reset. This avoids exposing absolute
> > +	 * hardware counter values to userspace.
> > +	 */
> > +	stat->u.old_reg_value_64 = fbnic_stat_rd64(fbd, reg, offset);  
> 
> I don't know how you use these stats, but now they are in debugfs, do
> they actually need to be 0 after reboot/reset? For most debugging
> performance issues with statistics, i want to know how much a counter
> goes up per second, so userspace will be reading the values twice with
> a sleep, and doing a subtractions anyway. So why not make the kernel
> code simpler?

Right, there is no strong reason to reset debugfs stats. OTOH
consistent behavior across all stats is nice (from rtnl stats 
to debugfs). And we will need the reset helpers for other stats.
Meta uses a lot of multi-host systems, the NIC is reset much
less often than the machines. Starting at 0 is convenient for 
manual debug.

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

* Re: [PATCH net-next 4/5] eth: fbnic: add PCIe hardware statistics
  2024-11-18 15:35     ` Jakub Kicinski
@ 2024-11-18 15:40       ` Andrew Lunn
  0 siblings, 0 replies; 17+ messages in thread
From: Andrew Lunn @ 2024-11-18 15:40 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: davem, netdev, edumazet, pabeni, alexanderduyck, Sanman Pradhan

On Mon, Nov 18, 2024 at 07:35:01AM -0800, Jakub Kicinski wrote:
> On Sun, 17 Nov 2024 21:19:00 +0100 Andrew Lunn wrote:
> > > +/* PUL User Registers*/
> > > +#define FBNIC_PUL_USER_OB_RD_TLP_CNT_31_0 \
> > > +					0x3106e		/* 0xc41b8 */  
> > 
> > Is there a comment somewhere which explains what these comments mean?
> > Otherwise they appear to be useless magic numbers.
> 
> The number on the left is the number on the right divided by 4.
> We index the registers as an array of u32s so the define is an index,
> but for grep-ability we add the absolute address in the comment.

Ah, O.K. Maybe a comment about this would be nice.

> > > +static void fbnic_hw_stat_rst64(struct fbnic_dev *fbd, u32 reg, s32 offset,
> > > +				struct fbnic_stat_counter *stat)
> > > +{
> > > +	/* Record initial counter values and compute deltas from there to ensure
> > > +	 * stats start at 0 after reboot/reset. This avoids exposing absolute
> > > +	 * hardware counter values to userspace.
> > > +	 */
> > > +	stat->u.old_reg_value_64 = fbnic_stat_rd64(fbd, reg, offset);  
> > 
> > I don't know how you use these stats, but now they are in debugfs, do
> > they actually need to be 0 after reboot/reset? For most debugging
> > performance issues with statistics, i want to know how much a counter
> > goes up per second, so userspace will be reading the values twice with
> > a sleep, and doing a subtractions anyway. So why not make the kernel
> > code simpler?
> 
> Right, there is no strong reason to reset debugfs stats. OTOH
> consistent behavior across all stats is nice (from rtnl stats 
> to debugfs). And we will need the reset helpers for other stats.
> Meta uses a lot of multi-host systems, the NIC is reset much
> less often than the machines. Starting at 0 is convenient for 
> manual debug.

If the code is being reused, then O.K.

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

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

* Re: [PATCH net-next 0/5] eth: fbnic: cleanup and add a few stats
  2024-11-15  1:53 [PATCH net-next 0/5] eth: fbnic: cleanup and add a few stats Jakub Kicinski
                   ` (4 preceding siblings ...)
  2024-11-15  1:53 ` [PATCH net-next 5/5] eth: fbnic: add RPC " Jakub Kicinski
@ 2024-11-19  3:00 ` patchwork-bot+netdevbpf
  5 siblings, 0 replies; 17+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-11-19  3:00 UTC (permalink / raw)
  To: Jakub Kicinski; +Cc: davem, netdev, edumazet, pabeni, alexanderduyck

Hello:

This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Thu, 14 Nov 2024 17:53:39 -0800 you wrote:
> Cleanup trival problems with fbnic and add the PCIe and RPC (Rx parser)
> stats.
> 
> All stats are read under rtnl_lock for now, so the code is pretty
> trivial. We'll need to add more locking when we start gathering
> drops used by .ndo_get_stats64.
> 
> [...]

Here is the summary with links:
  - [net-next,1/5] eth: fbnic: add missing SPDX headers
    https://git.kernel.org/netdev/net-next/c/e1a897ef4e9e
  - [net-next,2/5] eth: fbnic: add missing header guards
    https://git.kernel.org/netdev/net-next/c/2a0d6c1705c4
  - [net-next,3/5] eth: fbnic: add basic debugfs structure
    https://git.kernel.org/netdev/net-next/c/08606cb528be
  - [net-next,4/5] eth: fbnic: add PCIe hardware statistics
    https://git.kernel.org/netdev/net-next/c/25ba596d137d
  - [net-next,5/5] eth: fbnic: add RPC hardware statistics
    https://git.kernel.org/netdev/net-next/c/79da2aaa08ee

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2024-11-19  3:00 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-15  1:53 [PATCH net-next 0/5] eth: fbnic: cleanup and add a few stats Jakub Kicinski
2024-11-15  1:53 ` [PATCH net-next 1/5] eth: fbnic: add missing SPDX headers Jakub Kicinski
2024-11-17 20:09   ` Andrew Lunn
2024-11-18  3:55   ` Kalesh Anakkur Purayil
2024-11-15  1:53 ` [PATCH net-next 2/5] eth: fbnic: add missing header guards Jakub Kicinski
2024-11-17 20:10   ` Andrew Lunn
2024-11-18  3:55   ` Kalesh Anakkur Purayil
2024-11-15  1:53 ` [PATCH net-next 3/5] eth: fbnic: add basic debugfs structure Jakub Kicinski
2024-11-17 20:09   ` Andrew Lunn
2024-11-18  3:56   ` Kalesh Anakkur Purayil
2024-11-15  1:53 ` [PATCH net-next 4/5] eth: fbnic: add PCIe hardware statistics Jakub Kicinski
2024-11-17 20:19   ` Andrew Lunn
2024-11-18 15:35     ` Jakub Kicinski
2024-11-18 15:40       ` Andrew Lunn
2024-11-15  1:53 ` [PATCH net-next 5/5] eth: fbnic: add RPC " Jakub Kicinski
2024-11-17 20:24   ` Andrew Lunn
2024-11-19  3:00 ` [PATCH net-next 0/5] eth: fbnic: cleanup and add a few stats patchwork-bot+netdevbpf

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).