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 4d1362cdc7)
This commit is contained in:
Navdeep Parhar 2024-04-30 12:42:14 -07:00
parent e5efc8cf5d
commit 92383a2c84

View file

@ -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;
}