Skip to content

Commit 4be4a91

Browse files
committed
Merge branch 'eth-fbnic-cleanup-and-add-a-few-stats'
Jakub Kicinski says: ==================== 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. ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 357c52f + 79da2aa commit 4be4a91

File tree

9 files changed

+475
-1
lines changed

9 files changed

+475
-1
lines changed

Documentation/networking/device_drivers/ethernet/meta/fbnic.rst

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,46 @@ driver takes over.
2727
devlink dev info provides version information for all three components. In
2828
addition to the version the hg commit hash of the build is included as a
2929
separate entry.
30+
31+
Statistics
32+
----------
33+
34+
RPC (Rx parser)
35+
~~~~~~~~~~~~~~~
36+
37+
- ``rpc_unkn_etype``: frames containing unknown EtherType
38+
- ``rpc_unkn_ext_hdr``: frames containing unknown IPv6 extension header
39+
- ``rpc_ipv4_frag``: frames containing IPv4 fragment
40+
- ``rpc_ipv6_frag``: frames containing IPv6 fragment
41+
- ``rpc_ipv4_esp``: frames with IPv4 ESP encapsulation
42+
- ``rpc_ipv6_esp``: frames with IPv6 ESP encapsulation
43+
- ``rpc_tcp_opt_err``: frames which encountered TCP option parsing error
44+
- ``rpc_out_of_hdr_err``: frames where header was larger than parsable region
45+
- ``ovr_size_err``: oversized frames
46+
47+
PCIe
48+
~~~~
49+
50+
The fbnic driver exposes PCIe hardware performance statistics through debugfs
51+
(``pcie_stats``). These statistics provide insights into PCIe transaction
52+
behavior and potential performance bottlenecks.
53+
54+
1. PCIe Transaction Counters:
55+
56+
These counters track PCIe transaction activity:
57+
- ``pcie_ob_rd_tlp``: Outbound read Transaction Layer Packets count
58+
- ``pcie_ob_rd_dword``: DWORDs transferred in outbound read transactions
59+
- ``pcie_ob_wr_tlp``: Outbound write Transaction Layer Packets count
60+
- ``pcie_ob_wr_dword``: DWORDs transferred in outbound write
61+
transactions
62+
- ``pcie_ob_cpl_tlp``: Outbound completion TLP count
63+
- ``pcie_ob_cpl_dword``: DWORDs transferred in outbound completion TLPs
64+
65+
2. PCIe Resource Monitoring:
66+
67+
These counters indicate PCIe resource exhaustion events:
68+
- ``pcie_ob_rd_no_tag``: Read requests dropped due to tag unavailability
69+
- ``pcie_ob_rd_no_cpl_cred``: Read requests dropped due to completion
70+
credit exhaustion
71+
- ``pcie_ob_rd_no_np_cred``: Read requests dropped due to non-posted
72+
credit exhaustion

drivers/net/ethernet/meta/fbnic/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
obj-$(CONFIG_FBNIC) += fbnic.o
99

1010
fbnic-y := fbnic_csr.o \
11+
fbnic_debugfs.o \
1112
fbnic_devlink.o \
1213
fbnic_ethtool.o \
1314
fbnic_fw.o \

drivers/net/ethernet/meta/fbnic/fbnic.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
struct fbnic_dev {
2020
struct device *dev;
2121
struct net_device *netdev;
22+
struct dentry *dbg_fbd;
2223
struct device *hwmon;
2324

2425
u32 __iomem *uc_addr0;
@@ -156,6 +157,11 @@ int fbnic_alloc_irqs(struct fbnic_dev *fbd);
156157
void fbnic_get_fw_ver_commit_str(struct fbnic_dev *fbd, char *fw_version,
157158
const size_t str_sz);
158159

160+
void fbnic_dbg_fbd_init(struct fbnic_dev *fbd);
161+
void fbnic_dbg_fbd_exit(struct fbnic_dev *fbd);
162+
void fbnic_dbg_init(void);
163+
void fbnic_dbg_exit(void);
164+
159165
void fbnic_csr_get_regs(struct fbnic_dev *fbd, u32 *data, u32 *regs_version);
160166
int fbnic_csr_regs_len(struct fbnic_dev *fbd);
161167

drivers/net/ethernet/meta/fbnic/fbnic_csr.h

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,16 @@ enum {
638638
FBNIC_RPC_RSS_KEY_DWORD_LEN * 32 - \
639639
FBNIC_RPC_RSS_KEY_BIT_LEN)
640640

641+
#define FBNIC_RPC_CNTR_TCP_OPT_ERR 0x0849e /* 0x21278 */
642+
#define FBNIC_RPC_CNTR_UNKN_ETYPE 0x0849f /* 0x2127c */
643+
#define FBNIC_RPC_CNTR_IPV4_FRAG 0x084a0 /* 0x21280 */
644+
#define FBNIC_RPC_CNTR_IPV6_FRAG 0x084a1 /* 0x21284 */
645+
#define FBNIC_RPC_CNTR_IPV4_ESP 0x084a2 /* 0x21288 */
646+
#define FBNIC_RPC_CNTR_IPV6_ESP 0x084a3 /* 0x2128c */
647+
#define FBNIC_RPC_CNTR_UNKN_EXT_HDR 0x084a4 /* 0x21290 */
648+
#define FBNIC_RPC_CNTR_OUT_OF_HDR_ERR 0x084a5 /* 0x21294 */
649+
#define FBNIC_RPC_CNTR_OVR_SIZE_ERR 0x084a6 /* 0x21298 */
650+
641651
#define FBNIC_RPC_TCAM_MACDA_VALIDATE 0x0852d /* 0x214b4 */
642652
#define FBNIC_CSR_END_RPC 0x0856b /* CSR section delimiter */
643653

@@ -918,6 +928,43 @@ enum {
918928
#define FBNIC_MAX_QUEUES 128
919929
#define FBNIC_CSR_END_QUEUE (0x40000 + 0x400 * FBNIC_MAX_QUEUES - 1)
920930

931+
/* PUL User Registers*/
932+
#define FBNIC_PUL_USER_OB_RD_TLP_CNT_31_0 \
933+
0x3106e /* 0xc41b8 */
934+
#define FBNIC_PUL_USER_OB_RD_DWORD_CNT_31_0 \
935+
0x31070 /* 0xc41c0 */
936+
#define FBNIC_PUL_USER_OB_RD_DWORD_CNT_63_32 \
937+
0x31071 /* 0xc41c4 */
938+
#define FBNIC_PUL_USER_OB_WR_TLP_CNT_31_0 \
939+
0x31072 /* 0xc41c8 */
940+
#define FBNIC_PUL_USER_OB_WR_TLP_CNT_63_32 \
941+
0x31073 /* 0xc41cc */
942+
#define FBNIC_PUL_USER_OB_WR_DWORD_CNT_31_0 \
943+
0x31074 /* 0xc41d0 */
944+
#define FBNIC_PUL_USER_OB_WR_DWORD_CNT_63_32 \
945+
0x31075 /* 0xc41d4 */
946+
#define FBNIC_PUL_USER_OB_CPL_TLP_CNT_31_0 \
947+
0x31076 /* 0xc41d8 */
948+
#define FBNIC_PUL_USER_OB_CPL_TLP_CNT_63_32 \
949+
0x31077 /* 0xc41dc */
950+
#define FBNIC_PUL_USER_OB_CPL_DWORD_CNT_31_0 \
951+
0x31078 /* 0xc41e0 */
952+
#define FBNIC_PUL_USER_OB_CPL_DWORD_CNT_63_32 \
953+
0x31079 /* 0xc41e4 */
954+
#define FBNIC_PUL_USER_OB_RD_DBG_CNT_CPL_CRED_31_0 \
955+
0x3107a /* 0xc41e8 */
956+
#define FBNIC_PUL_USER_OB_RD_DBG_CNT_CPL_CRED_63_32 \
957+
0x3107b /* 0xc41ec */
958+
#define FBNIC_PUL_USER_OB_RD_DBG_CNT_TAG_31_0 \
959+
0x3107c /* 0xc41f0 */
960+
#define FBNIC_PUL_USER_OB_RD_DBG_CNT_TAG_63_32 \
961+
0x3107d /* 0xc41f4 */
962+
#define FBNIC_PUL_USER_OB_RD_DBG_CNT_NP_CRED_31_0 \
963+
0x3107e /* 0xc41f8 */
964+
#define FBNIC_PUL_USER_OB_RD_DBG_CNT_NP_CRED_63_32 \
965+
0x3107f /* 0xc41fc */
966+
#define FBNIC_CSR_END_PUL_USER 0x31080 /* CSR section delimiter */
967+
921968
/* BAR 4 CSRs */
922969

923970
/* The IPC mailbox consists of 32 mailboxes, with each mailbox consisting
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/* Copyright (c) Meta Platforms, Inc. and affiliates. */
3+
4+
#include <linux/debugfs.h>
5+
#include <linux/pci.h>
6+
#include <linux/rtnetlink.h>
7+
#include <linux/seq_file.h>
8+
9+
#include "fbnic.h"
10+
11+
static struct dentry *fbnic_dbg_root;
12+
13+
static int fbnic_dbg_pcie_stats_show(struct seq_file *s, void *v)
14+
{
15+
struct fbnic_dev *fbd = s->private;
16+
17+
rtnl_lock();
18+
fbnic_get_hw_stats(fbd);
19+
20+
seq_printf(s, "ob_rd_tlp: %llu\n", fbd->hw_stats.pcie.ob_rd_tlp.value);
21+
seq_printf(s, "ob_rd_dword: %llu\n",
22+
fbd->hw_stats.pcie.ob_rd_dword.value);
23+
seq_printf(s, "ob_wr_tlp: %llu\n", fbd->hw_stats.pcie.ob_wr_tlp.value);
24+
seq_printf(s, "ob_wr_dword: %llu\n",
25+
fbd->hw_stats.pcie.ob_wr_dword.value);
26+
seq_printf(s, "ob_cpl_tlp: %llu\n",
27+
fbd->hw_stats.pcie.ob_cpl_tlp.value);
28+
seq_printf(s, "ob_cpl_dword: %llu\n",
29+
fbd->hw_stats.pcie.ob_cpl_dword.value);
30+
seq_printf(s, "ob_rd_no_tag: %llu\n",
31+
fbd->hw_stats.pcie.ob_rd_no_tag.value);
32+
seq_printf(s, "ob_rd_no_cpl_cred: %llu\n",
33+
fbd->hw_stats.pcie.ob_rd_no_cpl_cred.value);
34+
seq_printf(s, "ob_rd_no_np_cred: %llu\n",
35+
fbd->hw_stats.pcie.ob_rd_no_np_cred.value);
36+
rtnl_unlock();
37+
38+
return 0;
39+
}
40+
41+
DEFINE_SHOW_ATTRIBUTE(fbnic_dbg_pcie_stats);
42+
43+
void fbnic_dbg_fbd_init(struct fbnic_dev *fbd)
44+
{
45+
struct pci_dev *pdev = to_pci_dev(fbd->dev);
46+
const char *name = pci_name(pdev);
47+
48+
fbd->dbg_fbd = debugfs_create_dir(name, fbnic_dbg_root);
49+
debugfs_create_file("pcie_stats", 0400, fbd->dbg_fbd, fbd,
50+
&fbnic_dbg_pcie_stats_fops);
51+
}
52+
53+
void fbnic_dbg_fbd_exit(struct fbnic_dev *fbd)
54+
{
55+
debugfs_remove_recursive(fbd->dbg_fbd);
56+
fbd->dbg_fbd = NULL;
57+
}
58+
59+
void fbnic_dbg_init(void)
60+
{
61+
fbnic_dbg_root = debugfs_create_dir(fbnic_driver_name, NULL);
62+
}
63+
64+
void fbnic_dbg_exit(void)
65+
{
66+
debugfs_remove_recursive(fbnic_dbg_root);
67+
fbnic_dbg_root = NULL;
68+
}

drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/* Copyright (c) Meta Platforms, Inc. and affiliates. */
3+
14
#include <linux/ethtool.h>
25
#include <linux/netdevice.h>
36
#include <linux/pci.h>
@@ -6,6 +9,37 @@
69
#include "fbnic_netdev.h"
710
#include "fbnic_tlv.h"
811

12+
struct fbnic_stat {
13+
u8 string[ETH_GSTRING_LEN];
14+
unsigned int size;
15+
unsigned int offset;
16+
};
17+
18+
#define FBNIC_STAT_FIELDS(type, name, stat) { \
19+
.string = name, \
20+
.size = sizeof_field(struct type, stat), \
21+
.offset = offsetof(struct type, stat), \
22+
}
23+
24+
/* Hardware statistics not captured in rtnl_link_stats */
25+
#define FBNIC_HW_STAT(name, stat) \
26+
FBNIC_STAT_FIELDS(fbnic_hw_stats, name, stat)
27+
28+
static const struct fbnic_stat fbnic_gstrings_hw_stats[] = {
29+
/* RPC */
30+
FBNIC_HW_STAT("rpc_unkn_etype", rpc.unkn_etype),
31+
FBNIC_HW_STAT("rpc_unkn_ext_hdr", rpc.unkn_ext_hdr),
32+
FBNIC_HW_STAT("rpc_ipv4_frag", rpc.ipv4_frag),
33+
FBNIC_HW_STAT("rpc_ipv6_frag", rpc.ipv6_frag),
34+
FBNIC_HW_STAT("rpc_ipv4_esp", rpc.ipv4_esp),
35+
FBNIC_HW_STAT("rpc_ipv6_esp", rpc.ipv6_esp),
36+
FBNIC_HW_STAT("rpc_tcp_opt_err", rpc.tcp_opt_err),
37+
FBNIC_HW_STAT("rpc_out_of_hdr_err", rpc.out_of_hdr_err),
38+
};
39+
40+
#define FBNIC_HW_FIXED_STATS_LEN ARRAY_SIZE(fbnic_gstrings_hw_stats)
41+
#define FBNIC_HW_STATS_LEN FBNIC_HW_FIXED_STATS_LEN
42+
943
static int
1044
fbnic_get_ts_info(struct net_device *netdev,
1145
struct kernel_ethtool_ts_info *tsinfo)
@@ -51,6 +85,43 @@ static void fbnic_set_counter(u64 *stat, struct fbnic_stat_counter *counter)
5185
*stat = counter->value;
5286
}
5387

88+
static void fbnic_get_strings(struct net_device *dev, u32 sset, u8 *data)
89+
{
90+
int i;
91+
92+
switch (sset) {
93+
case ETH_SS_STATS:
94+
for (i = 0; i < FBNIC_HW_STATS_LEN; i++)
95+
ethtool_puts(&data, fbnic_gstrings_hw_stats[i].string);
96+
break;
97+
}
98+
}
99+
100+
static int fbnic_get_sset_count(struct net_device *dev, int sset)
101+
{
102+
switch (sset) {
103+
case ETH_SS_STATS:
104+
return FBNIC_HW_STATS_LEN;
105+
default:
106+
return -EOPNOTSUPP;
107+
}
108+
}
109+
110+
static void fbnic_get_ethtool_stats(struct net_device *dev,
111+
struct ethtool_stats *stats, u64 *data)
112+
{
113+
struct fbnic_net *fbn = netdev_priv(dev);
114+
const struct fbnic_stat *stat;
115+
int i;
116+
117+
fbnic_get_hw_stats(fbn->fbd);
118+
119+
for (i = 0; i < FBNIC_HW_STATS_LEN; i++) {
120+
stat = &fbnic_gstrings_hw_stats[i];
121+
data[i] = *(u64 *)((u8 *)&fbn->fbd->hw_stats + stat->offset);
122+
}
123+
}
124+
54125
static void
55126
fbnic_get_eth_mac_stats(struct net_device *netdev,
56127
struct ethtool_eth_mac_stats *eth_mac_stats)
@@ -135,6 +206,9 @@ static const struct ethtool_ops fbnic_ethtool_ops = {
135206
.get_drvinfo = fbnic_get_drvinfo,
136207
.get_regs_len = fbnic_get_regs_len,
137208
.get_regs = fbnic_get_regs,
209+
.get_strings = fbnic_get_strings,
210+
.get_ethtool_stats = fbnic_get_ethtool_stats,
211+
.get_sset_count = fbnic_get_sset_count,
138212
.get_ts_info = fbnic_get_ts_info,
139213
.get_ts_stats = fbnic_get_ts_stats,
140214
.get_eth_mac_stats = fbnic_get_eth_mac_stats,

0 commit comments

Comments
 (0)