Skip to content

Commit 5f8bd2c

Browse files
Mohsin BashirPaolo Abeni
authored andcommitted
eth: fbnic: add support for TMI stats
This patch add coverage for TMI stats including PTP stats and drop stats. PTP stats include illegal requests, bad timestamp and good timestamps. The bad timestamp and illegal request counters are reported under as `error` via `ethtool -T` Both these counters are individually being reported via `ethtool -S` The good timestamp stats are being reported as `pkts` via `ethtool -T` ethtool -S eth0 | grep "ptp" ptp_illegal_req: 0 ptp_good_ts: 0 ptp_bad_ts: 0 Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: Mohsin Bashir <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent 986c63a commit 5f8bd2c

File tree

6 files changed

+60
-0
lines changed

6 files changed

+60
-0
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ separate entry.
3131
Statistics
3232
----------
3333

34+
TX MAC Interface
35+
~~~~~~~~~~~~~~~~
36+
37+
- ``ptp_illegal_req``: packets sent to the NIC with PTP request bit set but routed to BMC/FW
38+
- ``ptp_good_ts``: packets successfully routed to MAC with PTP request bit set
39+
- ``ptp_bad_ts``: packets destined for MAC with PTP request bit set but aborted because of some error (e.g., DMA read error)
40+
3441
RXB (RX Buffer) Enqueue
3542
~~~~~~~~~~~~~~~~~~~~~~~
3643

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,11 @@ enum {
432432
#define FBNIC_TMI_SOP_PROT_CTRL 0x04400 /* 0x11000 */
433433
#define FBNIC_TMI_DROP_CTRL 0x04401 /* 0x11004 */
434434
#define FBNIC_TMI_DROP_CTRL_EN CSR_BIT(0)
435+
#define FBNIC_TMI_DROP_PKTS 0x04402 /* 0x11008 */
436+
#define FBNIC_TMI_DROP_BYTE_L 0x04403 /* 0x1100c */
437+
#define FBNIC_TMI_ILLEGAL_PTP_REQS 0x04409 /* 0x11024 */
438+
#define FBNIC_TMI_GOOD_PTP_TS 0x0440a /* 0x11028 */
439+
#define FBNIC_TMI_BAD_PTP_TS 0x0440b /* 0x1102c */
435440
#define FBNIC_CSR_END_TMI 0x0443f /* CSR section delimiter */
436441

437442
/* Precision Time Protocol Registers */

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ struct fbnic_stat {
2727
FBNIC_STAT_FIELDS(fbnic_hw_stats, name, stat)
2828

2929
static const struct fbnic_stat fbnic_gstrings_hw_stats[] = {
30+
/* TMI */
31+
FBNIC_HW_STAT("ptp_illegal_req", tmi.ptp_illegal_req),
32+
FBNIC_HW_STAT("ptp_good_ts", tmi.ptp_good_ts),
33+
FBNIC_HW_STAT("ptp_bad_ts", tmi.ptp_bad_ts),
34+
3035
/* RPC */
3136
FBNIC_HW_STAT("rpc_unkn_etype", rpc.unkn_etype),
3237
FBNIC_HW_STAT("rpc_unkn_ext_hdr", rpc.unkn_ext_hdr),

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

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,37 @@ static void fbnic_hw_stat_rd64(struct fbnic_dev *fbd, u32 reg, s32 offset,
7070
stat->u.old_reg_value_64 = new_reg_value;
7171
}
7272

73+
static void fbnic_reset_tmi_stats(struct fbnic_dev *fbd,
74+
struct fbnic_tmi_stats *tmi)
75+
{
76+
fbnic_hw_stat_rst32(fbd, FBNIC_TMI_DROP_PKTS, &tmi->drop.frames);
77+
fbnic_hw_stat_rst64(fbd, FBNIC_TMI_DROP_BYTE_L, 1, &tmi->drop.bytes);
78+
79+
fbnic_hw_stat_rst32(fbd,
80+
FBNIC_TMI_ILLEGAL_PTP_REQS,
81+
&tmi->ptp_illegal_req);
82+
fbnic_hw_stat_rst32(fbd, FBNIC_TMI_GOOD_PTP_TS, &tmi->ptp_good_ts);
83+
fbnic_hw_stat_rst32(fbd, FBNIC_TMI_BAD_PTP_TS, &tmi->ptp_bad_ts);
84+
}
85+
86+
static void fbnic_get_tmi_stats32(struct fbnic_dev *fbd,
87+
struct fbnic_tmi_stats *tmi)
88+
{
89+
fbnic_hw_stat_rd32(fbd, FBNIC_TMI_DROP_PKTS, &tmi->drop.frames);
90+
91+
fbnic_hw_stat_rd32(fbd,
92+
FBNIC_TMI_ILLEGAL_PTP_REQS,
93+
&tmi->ptp_illegal_req);
94+
fbnic_hw_stat_rd32(fbd, FBNIC_TMI_GOOD_PTP_TS, &tmi->ptp_good_ts);
95+
fbnic_hw_stat_rd32(fbd, FBNIC_TMI_BAD_PTP_TS, &tmi->ptp_bad_ts);
96+
}
97+
98+
static void fbnic_get_tmi_stats(struct fbnic_dev *fbd,
99+
struct fbnic_tmi_stats *tmi)
100+
{
101+
fbnic_hw_stat_rd64(fbd, FBNIC_TMI_DROP_BYTE_L, 1, &tmi->drop.bytes);
102+
}
103+
73104
static void fbnic_reset_rpc_stats(struct fbnic_dev *fbd,
74105
struct fbnic_rpc_stats *rpc)
75106
{
@@ -419,6 +450,7 @@ static void fbnic_get_pcie_stats_asic64(struct fbnic_dev *fbd,
419450
void fbnic_reset_hw_stats(struct fbnic_dev *fbd)
420451
{
421452
spin_lock(&fbd->hw_stats_lock);
453+
fbnic_reset_tmi_stats(fbd, &fbd->hw_stats.tmi);
422454
fbnic_reset_rpc_stats(fbd, &fbd->hw_stats.rpc);
423455
fbnic_reset_rxb_stats(fbd, &fbd->hw_stats.rxb);
424456
fbnic_reset_hw_rxq_stats(fbd, fbd->hw_stats.hw_q);
@@ -428,6 +460,7 @@ void fbnic_reset_hw_stats(struct fbnic_dev *fbd)
428460

429461
static void __fbnic_get_hw_stats32(struct fbnic_dev *fbd)
430462
{
463+
fbnic_get_tmi_stats32(fbd, &fbd->hw_stats.tmi);
431464
fbnic_get_rpc_stats32(fbd, &fbd->hw_stats.rpc);
432465
fbnic_get_rxb_stats32(fbd, &fbd->hw_stats.rxb);
433466
fbnic_get_hw_rxq_stats32(fbd, fbd->hw_stats.hw_q);
@@ -445,6 +478,7 @@ void fbnic_get_hw_stats(struct fbnic_dev *fbd)
445478
spin_lock(&fbd->hw_stats_lock);
446479
__fbnic_get_hw_stats32(fbd);
447480

481+
fbnic_get_tmi_stats(fbd, &fbd->hw_stats.tmi);
448482
fbnic_get_rxb_stats(fbd, &fbd->hw_stats.rxb);
449483
fbnic_get_pcie_stats_asic64(fbd, &fbd->hw_stats.pcie);
450484
spin_unlock(&fbd->hw_stats_lock);

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ struct fbnic_mac_stats {
4242
struct fbnic_eth_mac_stats eth_mac;
4343
};
4444

45+
struct fbnic_tmi_stats {
46+
struct fbnic_hw_stat drop;
47+
struct fbnic_stat_counter ptp_illegal_req, ptp_good_ts, ptp_bad_ts;
48+
};
49+
4550
struct fbnic_rpc_stats {
4651
struct fbnic_stat_counter unkn_etype, unkn_ext_hdr;
4752
struct fbnic_stat_counter ipv4_frag, ipv6_frag, ipv4_esp, ipv6_esp;
@@ -88,6 +93,7 @@ struct fbnic_pcie_stats {
8893

8994
struct fbnic_hw_stats {
9095
struct fbnic_mac_stats mac;
96+
struct fbnic_tmi_stats tmi;
9197
struct fbnic_rpc_stats rpc;
9298
struct fbnic_rxb_stats rxb;
9399
struct fbnic_hw_q_stats hw_q[FBNIC_MAX_QUEUES];

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,9 @@ static void fbnic_get_stats64(struct net_device *dev,
423423
stats64->tx_packets = tx_packets;
424424
stats64->tx_dropped = tx_dropped;
425425

426+
/* Record drops from Tx HW Datapath */
427+
tx_dropped += fbd->hw_stats.tmi.drop.frames.value;
428+
426429
for (i = 0; i < fbn->num_tx_queues; i++) {
427430
struct fbnic_ring *txr = fbn->tx[i];
428431

0 commit comments

Comments
 (0)