]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
eth: fbnic: add support for TTI HW stats
authorMohsin Bashir <mohsin.bashr@gmail.com>
Thu, 10 Apr 2025 07:08:59 +0000 (00:08 -0700)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 15 Apr 2025 09:23:13 +0000 (11:23 +0200)
Add coverage for the TX Extension (TEI) Interface (TTI) stats. We are
tracking packets and control message drops because of credit exhaustion
on the TX interface.

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-6-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 02339818cb8d63f033f24ee59f64e0b0d3e05841..3483e498c08ebcb6d4a0cd42bc800417e1301cb6 100644 (file)
@@ -38,6 +38,13 @@ TX MAC Interface
  - ``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)
 
+TX Extension (TEI) Interface (TTI)
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ - ``tti_cm_drop``: control messages dropped at the TX Extension (TEI) Interface because of credit starvation
+ - ``tti_frame_drop``: packets dropped at the TX Extension (TEI) Interface because of credit starvation
+ - ``tti_tbi_drop``: packets dropped at the TX BMC Interface (TBI) because of credit starvation
+
 RXB (RX Buffer) Enqueue
 ~~~~~~~~~~~~~~~~~~~~~~~
 
index 9426f7f2e611e1c44a330d73fdbf7592c41efd62..0c217c195c6a346ddde3b4a0cac4ba7fd294d468 100644 (file)
@@ -397,6 +397,15 @@ enum {
 #define FBNIC_TCE_DROP_CTRL_TTI_FRM_DROP_EN    CSR_BIT(1)
 #define FBNIC_TCE_DROP_CTRL_TTI_TBI_DROP_EN    CSR_BIT(2)
 
+#define FBNIC_TCE_TTI_CM_DROP_PKTS     0x0403e         /* 0x100f8 */
+#define FBNIC_TCE_TTI_CM_DROP_BYTE_L   0x0403f         /* 0x100fc */
+#define FBNIC_TCE_TTI_CM_DROP_BYTE_H   0x04040         /* 0x10100 */
+#define FBNIC_TCE_TTI_FRAME_DROP_PKTS  0x04041         /* 0x10104 */
+#define FBNIC_TCE_TTI_FRAME_DROP_BYTE_L        0x04042         /* 0x10108 */
+#define FBNIC_TCE_TTI_FRAME_DROP_BYTE_H        0x04043         /* 0x1010c */
+#define FBNIC_TCE_TBI_DROP_PKTS                0x04044         /* 0x10110 */
+#define FBNIC_TCE_TBI_DROP_BYTE_L      0x04045         /* 0x10114 */
+
 #define FBNIC_TCE_TCAM_IDX2DEST_MAP    0x0404A         /* 0x10128 */
 #define FBNIC_TCE_TCAM_IDX2DEST_MAP_DEST_ID_0  CSR_GENMASK(3, 0)
 enum {
index 7d421791033e4e64d453f2fb52359d4eef37344b..5c7556c8c4c5f546cfae783d09003374fe24ab09 100644 (file)
@@ -27,6 +27,14 @@ struct fbnic_stat {
        FBNIC_STAT_FIELDS(fbnic_hw_stats, name, stat)
 
 static const struct fbnic_stat fbnic_gstrings_hw_stats[] = {
+       /* TTI */
+       FBNIC_HW_STAT("tti_cm_drop_frames", tti.cm_drop.frames),
+       FBNIC_HW_STAT("tti_cm_drop_bytes", tti.cm_drop.bytes),
+       FBNIC_HW_STAT("tti_frame_drop_frames", tti.frame_drop.frames),
+       FBNIC_HW_STAT("tti_frame_drop_bytes", tti.frame_drop.bytes),
+       FBNIC_HW_STAT("tti_tbi_drop_frames", tti.tbi_drop.frames),
+       FBNIC_HW_STAT("tti_tbi_drop_bytes", tti.tbi_drop.bytes),
+
        /* TMI */
        FBNIC_HW_STAT("ptp_illegal_req", tmi.ptp_illegal_req),
        FBNIC_HW_STAT("ptp_good_ts", tmi.ptp_good_ts),
index 80157f38997568ebaa1c97172a697431c01fbd64..4223d8100e64ee3cebb965363650ef659a0dafe8 100644 (file)
@@ -101,6 +101,69 @@ static void fbnic_get_tmi_stats(struct fbnic_dev *fbd,
        fbnic_hw_stat_rd64(fbd, FBNIC_TMI_DROP_BYTE_L, 1, &tmi->drop.bytes);
 }
 
+static void fbnic_reset_tti_stats(struct fbnic_dev *fbd,
+                                 struct fbnic_tti_stats *tti)
+{
+       fbnic_hw_stat_rst32(fbd,
+                           FBNIC_TCE_TTI_CM_DROP_PKTS,
+                           &tti->cm_drop.frames);
+       fbnic_hw_stat_rst64(fbd,
+                           FBNIC_TCE_TTI_CM_DROP_BYTE_L,
+                           1,
+                           &tti->cm_drop.bytes);
+
+       fbnic_hw_stat_rst32(fbd,
+                           FBNIC_TCE_TTI_FRAME_DROP_PKTS,
+                           &tti->frame_drop.frames);
+       fbnic_hw_stat_rst64(fbd,
+                           FBNIC_TCE_TTI_FRAME_DROP_BYTE_L,
+                           1,
+                           &tti->frame_drop.bytes);
+
+       fbnic_hw_stat_rst32(fbd,
+                           FBNIC_TCE_TBI_DROP_PKTS,
+                           &tti->tbi_drop.frames);
+       fbnic_hw_stat_rst64(fbd,
+                           FBNIC_TCE_TBI_DROP_BYTE_L,
+                           1,
+                           &tti->tbi_drop.bytes);
+}
+
+static void fbnic_get_tti_stats32(struct fbnic_dev *fbd,
+                                 struct fbnic_tti_stats *tti)
+{
+       fbnic_hw_stat_rd32(fbd,
+                          FBNIC_TCE_TTI_CM_DROP_PKTS,
+                          &tti->cm_drop.frames);
+
+       fbnic_hw_stat_rd32(fbd,
+                          FBNIC_TCE_TTI_FRAME_DROP_PKTS,
+                          &tti->frame_drop.frames);
+
+       fbnic_hw_stat_rd32(fbd,
+                          FBNIC_TCE_TBI_DROP_PKTS,
+                          &tti->tbi_drop.frames);
+}
+
+static void fbnic_get_tti_stats(struct fbnic_dev *fbd,
+                               struct fbnic_tti_stats *tti)
+{
+       fbnic_hw_stat_rd64(fbd,
+                          FBNIC_TCE_TTI_CM_DROP_BYTE_L,
+                          1,
+                          &tti->cm_drop.bytes);
+
+       fbnic_hw_stat_rd64(fbd,
+                          FBNIC_TCE_TTI_FRAME_DROP_BYTE_L,
+                          1,
+                          &tti->frame_drop.bytes);
+
+       fbnic_hw_stat_rd64(fbd,
+                          FBNIC_TCE_TBI_DROP_BYTE_L,
+                          1,
+                          &tti->tbi_drop.bytes);
+}
+
 static void fbnic_reset_rpc_stats(struct fbnic_dev *fbd,
                                  struct fbnic_rpc_stats *rpc)
 {
@@ -451,6 +514,7 @@ 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_tti_stats(fbd, &fbd->hw_stats.tti);
        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);
@@ -461,6 +525,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_tti_stats32(fbd, &fbd->hw_stats.tti);
        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);
@@ -479,6 +544,7 @@ void fbnic_get_hw_stats(struct fbnic_dev *fbd)
        __fbnic_get_hw_stats32(fbd);
 
        fbnic_get_tmi_stats(fbd, &fbd->hw_stats.tmi);
+       fbnic_get_tti_stats(fbd, &fbd->hw_stats.tti);
        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 abb0957a5ac0c1f2cd988ee466e66ef1613ee3fd..07e54bb75bf3ba6e3bc280334141433436b68fda 100644 (file)
@@ -47,6 +47,10 @@ struct fbnic_tmi_stats {
        struct fbnic_stat_counter ptp_illegal_req, ptp_good_ts, ptp_bad_ts;
 };
 
+struct fbnic_tti_stats {
+       struct fbnic_hw_stat cm_drop, frame_drop, tbi_drop;
+};
+
 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;
@@ -94,6 +98,7 @@ struct fbnic_pcie_stats {
 struct fbnic_hw_stats {
        struct fbnic_mac_stats mac;
        struct fbnic_tmi_stats tmi;
+       struct fbnic_tti_stats tti;
        struct fbnic_rpc_stats rpc;
        struct fbnic_rxb_stats rxb;
        struct fbnic_hw_q_stats hw_q[FBNIC_MAX_QUEUES];
index a0f93bd27113450b7042d617b784e892e1536124..d699f58dda211482952074c67104ba440d12d24e 100644 (file)
@@ -424,7 +424,10 @@ static void fbnic_get_stats64(struct net_device *dev,
        stats64->tx_dropped = tx_dropped;
 
        /* Record drops from Tx HW Datapath */
-       tx_dropped += fbd->hw_stats.tmi.drop.frames.value;
+       tx_dropped += fbd->hw_stats.tmi.drop.frames.value +
+                     fbd->hw_stats.tti.frame_drop.frames.value +
+                     fbd->hw_stats.tti.tbi_drop.frames.value +
+                     fbd->hw_stats.tmi.drop.frames.value;
 
        for (i = 0; i < fbn->num_tx_queues; i++) {
                struct fbnic_ring *txr = fbn->tx[i];