From 92383a2c844b102f6d65efbc2755ae21c656163b Mon Sep 17 00:00:00 2001 From: Navdeep Parhar Date: Tue, 30 Apr 2024 12:42:14 -0700 Subject: [PATCH] cxgbe(4): Do not read hardware registers to determine the number of ports. PORTVEC obtained from the firmware is the authoritative source of this information, and nports (calculated from PORTVEC) is available by the time t4_port_init runs. Sponsored by: Chelsio Communications (cherry picked from commit 4d1362cdc7375984a48f5f0048b1fe909524d21d) --- sys/dev/cxgbe/common/t4_hw.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/sys/dev/cxgbe/common/t4_hw.c b/sys/dev/cxgbe/common/t4_hw.c index 8a225849930..8d109b389f0 100644 --- a/sys/dev/cxgbe/common/t4_hw.c +++ b/sys/dev/cxgbe/common/t4_hw.c @@ -6745,10 +6745,11 @@ static unsigned int t4_get_mps_bg_map(struct adapter *adap, int idx) if (adap->params.mps_bg_map) return ((adap->params.mps_bg_map >> (idx << 3)) & 0xff); - n = G_NUMPORTS(t4_read_reg(adap, A_MPS_CMN_CTL)); - if (n == 0) + n = adap->params.nports; + MPASS(n > 0 && n <= MAX_NPORTS); + if (n == 1) return idx == 0 ? 0xf : 0; - if (n == 1 && chip_id(adap) <= CHELSIO_T5) + if (n == 2 && chip_id(adap) <= CHELSIO_T5) return idx < 2 ? (3 << (2 * idx)) : 0; return 1 << idx; } @@ -6758,12 +6759,12 @@ 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 n = adap->params.nports; const u32 all_chan = (1 << adap->chip_params->nchan) - 1; - if (n == 0) + if (n == 1) return idx == 0 ? all_chan : 0; - if (n == 1 && chip_id(adap) <= CHELSIO_T5) + if (n == 2 && chip_id(adap) <= CHELSIO_T5) return idx < 2 ? (3 << (2 * idx)) : 0; return 1 << idx; }