From 02cd7739168ed9b4f4abdd592f429f6027973a4d Mon Sep 17 00:00:00 2001 From: Navdeep Parhar Date: Wed, 19 Feb 2020 00:48:58 +0000 Subject: [PATCH] cxgbe(4): Congestion drops are maintained per E-channel and not per buffer group. This fixes a bug where congestion drops on port 1 of a T6 card would incorrectly be counted as drops on port 0. MFC after: 1 week Sponsored by: Chelsio Communications --- sys/dev/cxgbe/common/t4_hw.c | 3 ++- sys/dev/cxgbe/t4_main.c | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/sys/dev/cxgbe/common/t4_hw.c b/sys/dev/cxgbe/common/t4_hw.c index 03d5b7557e13..b7750f619710 100644 --- a/sys/dev/cxgbe/common/t4_hw.c +++ b/sys/dev/cxgbe/common/t4_hw.c @@ -6781,9 +6781,10 @@ static unsigned int t4_get_mps_bg_map(struct adapter *adap, int idx) static unsigned int t4_get_rx_e_chan_map(struct adapter *adap, int idx) { u32 n = G_NUMPORTS(t4_read_reg(adap, A_MPS_CMN_CTL)); + const u32 all_chan = (1 << adap->chip_params->nchan) - 1; if (n == 0) - return idx == 0 ? 0xf : 0; + return idx == 0 ? all_chan : 0; if (n == 1 && chip_id(adap) <= CHELSIO_T5) return idx < 2 ? (3 << (2 * idx)) : 0; return 1 << idx; diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c index f0de51aa1580..49c8b5efb735 100644 --- a/sys/dev/cxgbe/t4_main.c +++ b/sys/dev/cxgbe/t4_main.c @@ -6137,7 +6137,7 @@ vi_refresh_stats(struct adapter *sc, struct vi_info *vi) static void cxgbe_refresh_stats(struct adapter *sc, struct port_info *pi) { - u_int i, v, tnl_cong_drops, bg_map; + u_int i, v, tnl_cong_drops, chan_map; struct timeval tv; const struct timeval interval = {0, 250000}; /* 250ms */ @@ -6148,15 +6148,15 @@ cxgbe_refresh_stats(struct adapter *sc, struct port_info *pi) tnl_cong_drops = 0; t4_get_port_stats(sc, pi->tx_chan, &pi->stats); - bg_map = pi->mps_bg_map; - while (bg_map) { - i = ffs(bg_map) - 1; + chan_map = pi->rx_e_chan_map; + while (chan_map) { + i = ffs(chan_map) - 1; mtx_lock(&sc->reg_lock); t4_read_indirect(sc, A_TP_MIB_INDEX, A_TP_MIB_DATA, &v, 1, A_TP_MIB_TNL_CNG_DROP_0 + i); mtx_unlock(&sc->reg_lock); tnl_cong_drops += v; - bg_map &= ~(1 << i); + chan_map &= ~(1 << i); } pi->tnl_cong_drops = tnl_cong_drops; getmicrotime(&pi->last_refreshed); @@ -10292,7 +10292,7 @@ read_i2c(struct adapter *sc, struct t4_i2c_data *i2cd) static int clear_stats(struct adapter *sc, u_int port_id) { - int i, v, bg_map; + int i, v, chan_map; struct port_info *pi; struct vi_info *vi; struct sge_rxq *rxq; @@ -10317,13 +10317,13 @@ clear_stats(struct adapter *sc, u_int port_id) if (vi->flags & VI_INIT_DONE) t4_clr_vi_stats(sc, vi->vin); } - bg_map = pi->mps_bg_map; + chan_map = pi->rx_e_chan_map; v = 0; /* reuse */ - while (bg_map) { - i = ffs(bg_map) - 1; + while (chan_map) { + i = ffs(chan_map) - 1; t4_write_indirect(sc, A_TP_MIB_INDEX, A_TP_MIB_DATA, &v, 1, A_TP_MIB_TNL_CNG_DROP_0 + i); - bg_map &= ~(1 << i); + chan_map &= ~(1 << i); } mtx_unlock(&sc->reg_lock);