]> git.droids-corp.org - dpdk.git/commitdiff
net/cxgbe: track packets dropped by TP due to congestion
authorRahul Lakkireddy <rahul.lakkireddy@chelsio.com>
Fri, 6 May 2022 13:18:46 +0000 (18:48 +0530)
committerFerruh Yigit <ferruh.yigit@xilinx.com>
Tue, 17 May 2022 16:50:50 +0000 (18:50 +0200)
Transport Processor (TP) on the NIC delivers the incoming packets
from the wire to NIC's DMA engine to place the packets in Rx buffers.
TP sends signal towards the Multi-Port Switch (MPS) near the MAC when
the Rxqs run out of Rx buffers posted by driver. These MPS buffer drop
stats are already accounted for in imissed counters. However, if a
large number of Rxqs run out of Rx buffers simultaneously, then the
TP can start dropping packets by itself when there is heavy congestion
on the channel and hence could not inform to the MPS. So, track these
packets dropped by TP in imissed counters. Also add xstats for these
counters.

Signed-off-by: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
drivers/net/cxgbe/base/common.h
drivers/net/cxgbe/base/t4_hw.c
drivers/net/cxgbe/base/t4_regs.h
drivers/net/cxgbe/cxgbe_ethdev.c

index 980d78e4a4ee957a92af93e17515083af1754ef0..4482ddbf569ad5442f43b6d36d0629ff40c948dd 100644 (file)
@@ -101,6 +101,8 @@ struct port_stats {
        u64 rx_trunc1;            /* buffer-group 1 truncated packets */
        u64 rx_trunc2;            /* buffer-group 2 truncated packets */
        u64 rx_trunc3;            /* buffer-group 3 truncated packets */
+
+       u64 rx_tp_tnl_cong_drops[NCHAN]; /* TP frame drops due to congestion */
 };
 
 struct sge_params {
index 84c4316e684a3a64502b2fd405d5d11467b6825a..384080e6d300a7b03973d7230f0542df5165ef67 100644 (file)
@@ -3040,8 +3040,10 @@ unsigned int t4_get_tp_ch_map(struct adapter *adapter, unsigned int pidx)
  */
 void t4_get_port_stats(struct adapter *adap, int idx, struct port_stats *p)
 {
-       u32 bgmap = t4_get_mps_bg_map(adap, idx);
        u32 stat_ctl = t4_read_reg(adap, A_MPS_STAT_CTL);
+       u32 bgmap = t4_get_mps_bg_map(adap, idx);
+       u32 val[NCHAN] = { 0 };
+       u8 i;
 
 #define GET_STAT(name) \
        t4_read_reg64(adap, \
@@ -3129,6 +3131,11 @@ void t4_get_port_stats(struct adapter *adap, int idx, struct port_stats *p)
        p->rx_trunc2 = (bgmap & 4) ? GET_STAT_COM(RX_BG_2_MAC_TRUNC_FRAME) : 0;
        p->rx_trunc3 = (bgmap & 8) ? GET_STAT_COM(RX_BG_3_MAC_TRUNC_FRAME) : 0;
 
+       t4_read_indirect(adap, A_TP_MIB_INDEX, A_TP_MIB_DATA, &val[idx], 1,
+                        A_TP_MIB_TNL_CNG_DROP_0 + idx);
+
+       for (i = 0; i < NCHAN; i++)
+               p->rx_tp_tnl_cong_drops[i] = val[i];
 #undef GET_STAT
 #undef GET_STAT_COM
 }
@@ -3163,9 +3170,10 @@ void t4_get_port_stats_offset(struct adapter *adap, int idx,
  */
 void t4_clr_port_stats(struct adapter *adap, int idx)
 {
-       unsigned int i;
        u32 bgmap = t4_get_mps_bg_map(adap, idx);
        u32 port_base_addr;
+       unsigned int i;
+       u32 val = 0;
 
        if (is_t4(adap->params.chip))
                port_base_addr = PORT_BASE(idx);
@@ -3187,6 +3195,8 @@ void t4_clr_port_stats(struct adapter *adap, int idx)
                                     A_MPS_STAT_RX_BG_0_MAC_TRUNC_FRAME_L +
                                     i * 8, 0);
                }
+       t4_write_indirect(adap, A_TP_MIB_INDEX, A_TP_MIB_DATA,
+                         &val, 1, A_TP_MIB_TNL_CNG_DROP_0 + idx);
 }
 
 /**
index 8a14d09a15c17e549dc11e3062e09bc940c05435..ff60dc1bb3aa346913dda700885e3039b00c73bf 100644 (file)
 
 #define A_TP_PIO_ADDR 0x7e40
 #define A_TP_PIO_DATA 0x7e44
+#define A_TP_MIB_INDEX 0x7e50
+#define A_TP_MIB_DATA 0x7e54
 
 #define A_TP_RSS_SECRET_KEY0 0x40
 
 #define S_RM_OVLAN     9
 #define V_RM_OVLAN(x)  ((x) << S_RM_OVLAN)
 
+#define A_TP_MIB_TNL_CNG_DROP_0 0x18
+
 /* registers for module MA */
 #define A_MA_EDRAM0_BAR 0x77c0
 
index e7ea76180f36caca1315076c3d2c2c2f60f81c93..cf9a2fdc19518c7af084a355cc9dad72457d00db 100644 (file)
@@ -709,6 +709,9 @@ static int cxgbe_dev_stats_get(struct rte_eth_dev *eth_dev,
                              ps.rx_ovflow2 + ps.rx_ovflow3 +
                              ps.rx_trunc0 + ps.rx_trunc1 +
                              ps.rx_trunc2 + ps.rx_trunc3;
+       for (i = 0; i < NCHAN; i++)
+               eth_stats->imissed += ps.rx_tp_tnl_cong_drops[i];
+
        eth_stats->ierrors  = ps.rx_symbol_err + ps.rx_fcs_err +
                              ps.rx_jabber + ps.rx_too_long + ps.rx_runt +
                              ps.rx_len_err;
@@ -851,6 +854,14 @@ static const struct cxgbe_dev_xstats_name_off cxgbe_dev_port_stats_strings[] = {
        {"rx_bg1_truncated_packets", offsetof(struct port_stats, rx_trunc1)},
        {"rx_bg2_truncated_packets", offsetof(struct port_stats, rx_trunc2)},
        {"rx_bg3_truncated_packets", offsetof(struct port_stats, rx_trunc3)},
+       {"rx_tp_tnl_cong_drops0",
+        offsetof(struct port_stats, rx_tp_tnl_cong_drops[0])},
+       {"rx_tp_tnl_cong_drops1",
+        offsetof(struct port_stats, rx_tp_tnl_cong_drops[1])},
+       {"rx_tp_tnl_cong_drops2",
+        offsetof(struct port_stats, rx_tp_tnl_cong_drops[2])},
+       {"rx_tp_tnl_cong_drops3",
+        offsetof(struct port_stats, rx_tp_tnl_cong_drops[3])},
 };
 
 static const struct cxgbe_dev_xstats_name_off