bnxt_en: Refactor the software ring counters.
authorMichael Chan <michael.chan@broadcom.com>
Mon, 4 May 2020 08:50:39 +0000 (04:50 -0400)
committerDavid S. Miller <davem@davemloft.net>
Mon, 4 May 2020 17:44:11 +0000 (10:44 -0700)
We currently have 3 software ring counters, rx_l4_csum_errors,
rx_buf_errors, and missed_irqs.  The 1st two are RX counters and the
last one is a common counter.  Organize them into 2 structures
bnxt_rx_sw_stats and bnxt_cmn_sw_stats.

Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/broadcom/bnxt/bnxt.c
drivers/net/ethernet/broadcom/bnxt/bnxt.h
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c

index 8f11344b80553f87ca9035230b2281d1375103e1..4bbfea147d98344fab8f5619e2ba8a015cb1e7da 100644 (file)
@@ -1766,7 +1766,7 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
 
                rc = -EIO;
                if (rx_err & RX_CMPL_ERRORS_BUFFER_ERROR_MASK) {
-                       bnapi->cp_ring.rx_buf_errors++;
+                       bnapi->cp_ring.sw_stats.rx.rx_buf_errors++;
                        if (!(bp->flags & BNXT_FLAG_CHIP_P5)) {
                                netdev_warn(bp->dev, "RX buffer error %x\n",
                                            rx_err);
@@ -1849,7 +1849,7 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
        } else {
                if (rxcmp1->rx_cmp_cfa_code_errors_v2 & RX_CMP_L4_CS_ERR_BITS) {
                        if (dev->features & NETIF_F_RXCSUM)
-                               bnapi->cp_ring.rx_l4_csum_errors++;
+                               bnapi->cp_ring.sw_stats.rx.rx_l4_csum_errors++;
                }
        }
 
@@ -10285,7 +10285,7 @@ static void bnxt_chk_missed_irq(struct bnxt *bp)
                        bnxt_dbg_hwrm_ring_info_get(bp,
                                DBG_RING_INFO_GET_REQ_RING_TYPE_L2_CMPL,
                                fw_ring_id, &val[0], &val[1]);
-                       cpr->missed_irqs++;
+                       cpr->sw_stats.cmn.missed_irqs++;
                }
        }
 }
index 6114b0a576ff6b81d58154a83098f951e9cb121e..c15517ff7ff6191eeab5a15411602fdc2c089688 100644 (file)
@@ -910,6 +910,20 @@ struct bnxt_rx_ring_info {
        struct page_pool        *page_pool;
 };
 
+struct bnxt_rx_sw_stats {
+       u64                     rx_l4_csum_errors;
+       u64                     rx_buf_errors;
+};
+
+struct bnxt_cmn_sw_stats {
+       u64                     missed_irqs;
+};
+
+struct bnxt_sw_stats {
+       struct bnxt_rx_sw_stats rx;
+       struct bnxt_cmn_sw_stats cmn;
+};
+
 struct bnxt_cp_ring_info {
        struct bnxt_napi        *bnapi;
        u32                     cp_raw_cons;
@@ -937,9 +951,8 @@ struct bnxt_cp_ring_info {
        struct ctx_hw_stats     *hw_stats;
        dma_addr_t              hw_stats_map;
        u32                     hw_stats_ctx_id;
-       u64                     rx_l4_csum_errors;
-       u64                     rx_buf_errors;
-       u64                     missed_irqs;
+
+       struct bnxt_sw_stats    sw_stats;
 
        struct bnxt_ring_struct cp_ring_struct;
 
index ad68bc393cc752e13ed192dfba7236e7571a3814..b2b43a7a9abb02fec7480c45cb46ace652e33cf5 100644 (file)
@@ -171,9 +171,12 @@ static const char * const bnxt_ring_tpa2_stats_str[] = {
        "rx_tpa_errors",
 };
 
-static const char * const bnxt_ring_sw_stats_str[] = {
+static const char * const bnxt_rx_sw_stats_str[] = {
        "rx_l4_csum_errors",
        "rx_buf_errors",
+};
+
+static const char * const bnxt_cmn_sw_stats_str[] = {
        "missed_irqs",
 };
 
@@ -485,7 +488,8 @@ static int bnxt_get_num_ring_stats(struct bnxt *bp)
        int num_stats;
 
        num_stats = ARRAY_SIZE(bnxt_ring_stats_str) +
-                   ARRAY_SIZE(bnxt_ring_sw_stats_str) +
+                   ARRAY_SIZE(bnxt_rx_sw_stats_str) +
+                   ARRAY_SIZE(bnxt_cmn_sw_stats_str) +
                    bnxt_get_num_tpa_ring_stats(bp);
        return num_stats * bp->cp_nr_rings;
 }
@@ -548,13 +552,19 @@ static void bnxt_get_ethtool_stats(struct net_device *dev,
                struct bnxt_napi *bnapi = bp->bnapi[i];
                struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring;
                __le64 *hw_stats = (__le64 *)cpr->hw_stats;
+               u64 *sw;
                int k;
 
                for (k = 0; k < stat_fields; j++, k++)
                        buf[j] = le64_to_cpu(hw_stats[k]);
-               buf[j++] = cpr->rx_l4_csum_errors;
-               buf[j++] = cpr->rx_buf_errors;
-               buf[j++] = cpr->missed_irqs;
+
+               sw = (u64 *)&cpr->sw_stats.rx;
+               for (k = 0; k < ARRAY_SIZE(bnxt_rx_sw_stats_str); j++, k++)
+                       buf[j] = sw[k];
+
+               sw = (u64 *)&cpr->sw_stats.cmn;
+               for (k = 0; k < ARRAY_SIZE(bnxt_cmn_sw_stats_str); j++, k++)
+                       buf[j] = sw[k];
 
                bnxt_sw_func_stats[RX_TOTAL_DISCARDS].counter +=
                        le64_to_cpu(cpr->hw_stats->rx_discard_pkts);
@@ -653,10 +663,16 @@ static void bnxt_get_strings(struct net_device *dev, u32 stringset, u8 *buf)
                                buf += ETH_GSTRING_LEN;
                        }
 skip_tpa_stats:
-                       num_str = ARRAY_SIZE(bnxt_ring_sw_stats_str);
+                       num_str = ARRAY_SIZE(bnxt_rx_sw_stats_str);
+                       for (j = 0; j < num_str; j++) {
+                               sprintf(buf, "[%d]: %s", i,
+                                       bnxt_rx_sw_stats_str[j]);
+                               buf += ETH_GSTRING_LEN;
+                       }
+                       num_str = ARRAY_SIZE(bnxt_cmn_sw_stats_str);
                        for (j = 0; j < num_str; j++) {
                                sprintf(buf, "[%d]: %s", i,
-                                       bnxt_ring_sw_stats_str[j]);
+                                       bnxt_cmn_sw_stats_str[j]);
                                buf += ETH_GSTRING_LEN;
                        }
                }