eth: fbnic: cleanup and add a few stats
Subsystems (4)
Jakub Kicinski
maintainercover eth: fbnic: cleanup and add a few stats
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
Signature · 1 line
2.47.0
Jakub Kicinski
maintainerPATCH 1/5 eth: fbnic: add missing SPDX headers
Paolo noticed that we are missing SPDX headers, add them.
--- 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(+)
drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c +3 -0
@@ -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>
drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.c +3 -0
@@ -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)
drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.h +3 -0
@@ -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"
Signature · 1 line
2.47.0
Re: [PATCH net-next 1/5] eth: fbnic: add missing SPDX headers
Quoted 3 lines · Jakub Kicinski
Paolo noticed that we are missing SPDX headers, add them.
Signed-off-by Jakub Kicinski <[email protected]>
Andrew
Re: [PATCH net-next 1/5] eth: fbnic: add missing SPDX headers
In reply to Jakub KicinskiQuoted 4 lines · Jakub Kicinski
Paolo noticed that we are missing SPDX headers, add them.
Signed-off-by Jakub Kicinski <[email protected]>
LGTM,
Signature · 2 lines
Regards, Kalesh A P
Jakub Kicinski
maintainerPATCH 2/5 eth: fbnic: add missing header guards
In reply to Jakub KicinskiWhile adding the SPDX headers I noticed we're also missing a header guard.
--- drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.h | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.h +5 -0
@@ -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_ */
Signature · 1 line
2.47.0
Re: [PATCH net-next 2/5] eth: fbnic: add missing header guards
Quoted 4 lines · Jakub Kicinski
While adding the SPDX headers I noticed we're also missing a header guard.
Signed-off-by Jakub Kicinski <[email protected]>
Andrew
Re: [PATCH net-next 2/5] eth: fbnic: add missing header guards
In reply to Jakub KicinskiQuoted 5 lines · Jakub Kicinski
While adding the SPDX headers I noticed we're also missing a header guard.
Signed-off-by Jakub Kicinski <[email protected]>
LGTM,
Signature · 2 lines
Regards, Kalesh A P
Jakub Kicinski
maintainerPATCH 3/5 eth: fbnic: add basic debugfs structure
In reply to Jakub KicinskiAdd the usual debugfs structure:
fbnic/
$pci-id/
device-fileA
device-fileB
This patch only adds the directories, subsequent changes will add files.
--- 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
drivers/net/ethernet/meta/fbnic/Makefile +1 -0
@@ -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 \
drivers/net/ethernet/meta/fbnic/fbnic.h +6 -0
@@ -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);
drivers/net/ethernet/meta/fbnic/fbnic_debugfs.c new file +34 -0
@@ -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 ; +}
drivers/net/ethernet/meta/fbnic/fbnic_pci.c +9 -1
@@ -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);
Signature · 1 line
2.47.0
Re: [PATCH net-next 3/5] eth: fbnic: add basic debugfs structure
Quoted 11 lines · Jakub Kicinski
Add the usual debugfs structure:
fbnic/
$pci-id/
device-fileA
device-fileBThis patch only adds the directories, subsequent changes will add files.
Signed-off-by Jakub Kicinski <[email protected]>
This looks a lot better than previous attempts. Thanks.
Andrew
Re: [PATCH net-next 3/5] eth: fbnic: add basic debugfs structure
In reply to Jakub KicinskiQuoted 8 lines · Jakub Kicinski
Add the usual debugfs structure:
fbnic/
$pci-id/
device-fileA
device-fileB
Quoted 4 lines
This patch only adds the directories, subsequent changes will add files.
Signed-off-by Jakub Kicinski <[email protected]>
LGTM,
Signature · 2 lines
Regards, Kalesh A P
Jakub Kicinski
maintainerPATCH 4/5 eth: fbnic: add PCIe hardware statistics
In reply to Jakub KicinskiFrom: Sanman Pradhan <[email protected]>
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.
--- .../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(+)
Documentation/networking/device_drivers/ethernet/meta/fbnic.rst +30 -0
@@ -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
drivers/net/ethernet/meta/fbnic/fbnic_csr.h +37 -0
@@ -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
drivers/net/ethernet/meta/fbnic/fbnic_debugfs.c +34 -0
@@ -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)
drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.c +114 -0
117 lines not on this page · raw message
drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.h +12 -0
@@ -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_ */
drivers/net/ethernet/meta/fbnic/fbnic_pci.c +4 -0
@@ -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) {
Signature · 1 line
2.47.0
Re: [PATCH net-next 4/5] eth: fbnic: add PCIe hardware statistics
drivers/net/ethernet/meta/fbnic/fbnic_csr.h enum { · line 923
Quoted 3 lines
drivers/net/ethernet/meta/fbnic/fbnic_csr.h +3
-0+/* 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.
drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.c u64 fbnic_stat_rd64(struct fbnic_dev *fbd, u32 reg, u32 offset) · line 39
Quoted 8 lines
drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.c +8
-0+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
Jakub Kicinski
maintainerRe: [PATCH net-next 4/5] eth: fbnic: add PCIe hardware statistics
Quoted 6 lines · On Sun, 17 Nov 2024 21:19:00 +0100 Andrew Lunn wrote:
drivers/net/ethernet/meta/fbnic/fbnic_csr.h enum { · line 923
Quoted 3 lines
drivers/net/ethernet/meta/fbnic/fbnic_csr.h +3
-0+/* 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.
Quoted 7 lines
Quoted 7 lines
drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.c +7
-0+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. +*/
Quoted 8 lines
drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.c u64 fbnic_stat_rd64(struct fbnic_dev *fbd, u32 reg, u32 offset) · line 39
Quoted 1 line
drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.c +1
-0+ 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.
Andrew Lunn
Reviewed-byRe: [PATCH net-next 4/5] eth: fbnic: add PCIe hardware statistics
Quoted 11 lines · Jakub Kicinski
Quoted 6 lines · On Sun, 17 Nov 2024 21:19:00 +0100 Andrew Lunn wrote:
drivers/net/ethernet/meta/fbnic/fbnic_csr.h enum { · line 923
Quoted 3 lines
drivers/net/ethernet/meta/fbnic/fbnic_csr.h +3
-0+/* 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.
Quoted 16 lines
Quoted 7 lines
Quoted 7 lines
drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.c +7
-0+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. +*/ Quoted 8 lines
drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.c u64 fbnic_stat_rd64(struct fbnic_dev *fbd, u32 reg, u32 offset) · line 39
Quoted 1 line
drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.c +1
-0+ 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?
Quoted 6 lines
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.
Andrew
Jakub Kicinski
maintainerPATCH 5/5 eth: fbnic: add RPC hardware statistics
In reply to Jakub KicinskiFrom: Sanman Pradhan <[email protected]>
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.
--- .../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(+)
Documentation/networking/device_drivers/ethernet/meta/fbnic.rst +13 -0
@@ -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 ~~~~
drivers/net/ethernet/meta/fbnic/fbnic_csr.h +10 -0
@@ -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 */
drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c +71 -0
89 lines not on this page · raw message
drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.c +76 -0
98 lines not on this page · raw message
drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.h +8 -0
@@ -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_ */
drivers/net/ethernet/meta/fbnic/fbnic_pci.c +2 -0
@@ -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);
Signature · 1 line
2.47.0
Re: [PATCH net-next 5/5] eth: fbnic: add RPC hardware statistics
Quoted 9 lines · Jakub Kicinski
From: Sanman Pradhan <[email protected]>
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 <[email protected]>Signed-off-by Jakub Kicinski <[email protected]>
Andrew
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 8 lines · 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_lockfor 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!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html