]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
eth: fbnic: add support for TMI stats
authorMohsin Bashir <mohsin.bashr@gmail.com>
Thu, 10 Apr 2025 07:08:58 +0000 (00:08 -0700)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 15 Apr 2025 09:23:13 +0000 (11:23 +0200)
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 <kuba@kernel.org>
Signed-off-by: Mohsin Bashir <mohsin.bashr@gmail.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20250410070859.4160768-5-mohsin.bashr@gmail.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Documentation/networking/device_drivers/ethernet/meta/fbnic.rst
drivers/net/ethernet/meta/fbnic/fbnic_csr.h
drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c
drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.c
drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.h
drivers/net/ethernet/meta/fbnic/fbnic_netdev.c

index 8ba94ae95db9ccd456a9e1720e6165fc0997b9d7..02339818cb8d63f033f24ee59f64e0b0d3e05841 100644 (file)
@@ -31,6 +31,13 @@ separate entry.
 Statistics
 ----------
 
+TX MAC Interface
+~~~~~~~~~~~~~~~~
+
+ - ``ptp_illegal_req``: packets sent to the NIC with PTP request bit set but routed to BMC/FW
+ - ``ptp_good_ts``: packets successfully routed to MAC with PTP request bit set
+ - ``ptp_bad_ts``: packets destined for MAC with PTP request bit set but aborted because of some error (e.g., DMA read error)
+
 RXB (RX Buffer) Enqueue
 ~~~~~~~~~~~~~~~~~~~~~~~
 
index a554e0b2cfffda4b2ff38a05788988407b0143af..9426f7f2e611e1c44a330d73fdbf7592c41efd62 100644 (file)
@@ -432,6 +432,11 @@ enum {
 #define FBNIC_TMI_SOP_PROT_CTRL                0x04400         /* 0x11000 */
 #define FBNIC_TMI_DROP_CTRL            0x04401         /* 0x11004 */
 #define FBNIC_TMI_DROP_CTRL_EN                 CSR_BIT(0)
+#define FBNIC_TMI_DROP_PKTS            0x04402         /* 0x11008 */
+#define FBNIC_TMI_DROP_BYTE_L          0x04403         /* 0x1100c */
+#define FBNIC_TMI_ILLEGAL_PTP_REQS     0x04409         /* 0x11024 */
+#define FBNIC_TMI_GOOD_PTP_TS          0x0440a         /* 0x11028 */
+#define FBNIC_TMI_BAD_PTP_TS           0x0440b         /* 0x1102c */
 #define FBNIC_CSR_END_TMI              0x0443f /* CSR section delimiter */
 
 /* Precision Time Protocol Registers */
index 816af96a5d5fc6b1162108f8289c0409b9bc65ba..7d421791033e4e64d453f2fb52359d4eef37344b 100644 (file)
@@ -27,6 +27,11 @@ struct fbnic_stat {
        FBNIC_STAT_FIELDS(fbnic_hw_stats, name, stat)
 
 static const struct fbnic_stat fbnic_gstrings_hw_stats[] = {
+       /* TMI */
+       FBNIC_HW_STAT("ptp_illegal_req", tmi.ptp_illegal_req),
+       FBNIC_HW_STAT("ptp_good_ts", tmi.ptp_good_ts),
+       FBNIC_HW_STAT("ptp_bad_ts", tmi.ptp_bad_ts),
+
        /* RPC */
        FBNIC_HW_STAT("rpc_unkn_etype", rpc.unkn_etype),
        FBNIC_HW_STAT("rpc_unkn_ext_hdr", rpc.unkn_ext_hdr),
index 1c5ccaf397277aaa0cf9324e4a40111713e48007..80157f38997568ebaa1c97172a697431c01fbd64 100644 (file)
@@ -70,6 +70,37 @@ 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_tmi_stats(struct fbnic_dev *fbd,
+                                 struct fbnic_tmi_stats *tmi)
+{
+       fbnic_hw_stat_rst32(fbd, FBNIC_TMI_DROP_PKTS, &tmi->drop.frames);
+       fbnic_hw_stat_rst64(fbd, FBNIC_TMI_DROP_BYTE_L, 1, &tmi->drop.bytes);
+
+       fbnic_hw_stat_rst32(fbd,
+                           FBNIC_TMI_ILLEGAL_PTP_REQS,
+                           &tmi->ptp_illegal_req);
+       fbnic_hw_stat_rst32(fbd, FBNIC_TMI_GOOD_PTP_TS, &tmi->ptp_good_ts);
+       fbnic_hw_stat_rst32(fbd, FBNIC_TMI_BAD_PTP_TS, &tmi->ptp_bad_ts);
+}
+
+static void fbnic_get_tmi_stats32(struct fbnic_dev *fbd,
+                                 struct fbnic_tmi_stats *tmi)
+{
+       fbnic_hw_stat_rd32(fbd, FBNIC_TMI_DROP_PKTS, &tmi->drop.frames);
+
+       fbnic_hw_stat_rd32(fbd,
+                          FBNIC_TMI_ILLEGAL_PTP_REQS,
+                          &tmi->ptp_illegal_req);
+       fbnic_hw_stat_rd32(fbd, FBNIC_TMI_GOOD_PTP_TS, &tmi->ptp_good_ts);
+       fbnic_hw_stat_rd32(fbd, FBNIC_TMI_BAD_PTP_TS, &tmi->ptp_bad_ts);
+}
+
+static void fbnic_get_tmi_stats(struct fbnic_dev *fbd,
+                               struct fbnic_tmi_stats *tmi)
+{
+       fbnic_hw_stat_rd64(fbd, FBNIC_TMI_DROP_BYTE_L, 1, &tmi->drop.bytes);
+}
+
 static void fbnic_reset_rpc_stats(struct fbnic_dev *fbd,
                                  struct fbnic_rpc_stats *rpc)
 {
@@ -419,6 +450,7 @@ static void fbnic_get_pcie_stats_asic64(struct fbnic_dev *fbd,
 void fbnic_reset_hw_stats(struct fbnic_dev *fbd)
 {
        spin_lock(&fbd->hw_stats_lock);
+       fbnic_reset_tmi_stats(fbd, &fbd->hw_stats.tmi);
        fbnic_reset_rpc_stats(fbd, &fbd->hw_stats.rpc);
        fbnic_reset_rxb_stats(fbd, &fbd->hw_stats.rxb);
        fbnic_reset_hw_rxq_stats(fbd, fbd->hw_stats.hw_q);
@@ -428,6 +460,7 @@ void fbnic_reset_hw_stats(struct fbnic_dev *fbd)
 
 static void __fbnic_get_hw_stats32(struct fbnic_dev *fbd)
 {
+       fbnic_get_tmi_stats32(fbd, &fbd->hw_stats.tmi);
        fbnic_get_rpc_stats32(fbd, &fbd->hw_stats.rpc);
        fbnic_get_rxb_stats32(fbd, &fbd->hw_stats.rxb);
        fbnic_get_hw_rxq_stats32(fbd, fbd->hw_stats.hw_q);
@@ -445,6 +478,7 @@ void fbnic_get_hw_stats(struct fbnic_dev *fbd)
        spin_lock(&fbd->hw_stats_lock);
        __fbnic_get_hw_stats32(fbd);
 
+       fbnic_get_tmi_stats(fbd, &fbd->hw_stats.tmi);
        fbnic_get_rxb_stats(fbd, &fbd->hw_stats.rxb);
        fbnic_get_pcie_stats_asic64(fbd, &fbd->hw_stats.pcie);
        spin_unlock(&fbd->hw_stats_lock);
index ec03e6253ba5a8c3d9eaf0e1e8802694a5ea3606..abb0957a5ac0c1f2cd988ee466e66ef1613ee3fd 100644 (file)
@@ -42,6 +42,11 @@ struct fbnic_mac_stats {
        struct fbnic_eth_mac_stats eth_mac;
 };
 
+struct fbnic_tmi_stats {
+       struct fbnic_hw_stat drop;
+       struct fbnic_stat_counter ptp_illegal_req, ptp_good_ts, ptp_bad_ts;
+};
+
 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;
@@ -88,6 +93,7 @@ struct fbnic_pcie_stats {
 
 struct fbnic_hw_stats {
        struct fbnic_mac_stats mac;
+       struct fbnic_tmi_stats tmi;
        struct fbnic_rpc_stats rpc;
        struct fbnic_rxb_stats rxb;
        struct fbnic_hw_q_stats hw_q[FBNIC_MAX_QUEUES];
index dff485511301420219557acf445b85de6d3f409d..a0f93bd27113450b7042d617b784e892e1536124 100644 (file)
@@ -423,6 +423,9 @@ static void fbnic_get_stats64(struct net_device *dev,
        stats64->tx_packets = tx_packets;
        stats64->tx_dropped = tx_dropped;
 
+       /* Record drops from Tx HW Datapath */
+       tx_dropped += fbd->hw_stats.tmi.drop.frames.value;
+
        for (i = 0; i < fbn->num_tx_queues; i++) {
                struct fbnic_ring *txr = fbn->tx[i];