1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-12 09:58:36 +00:00

cxgbe(4): Break up t4_read_chip_settings.

Read the PF-only hardware settings directly in get_params__post_init.
Split the rest into two routines used by both the PF and VF drivers: one
that reads the SGE rx buffer configuration and another that verifies
miscellaneous hardware configuration.

MFC after:	1 week
Sponsored by:	Chelsio Communications
This commit is contained in:
Navdeep Parhar 2021-02-18 01:15:46 -08:00
parent 2ed689a674
commit fae028dd97
6 changed files with 62 additions and 44 deletions

View File

@ -1262,7 +1262,8 @@ void t4_sge_modload(void);
void t4_sge_modunload(void);
uint64_t t4_sge_extfree_refs(void);
void t4_tweak_chip_settings(struct adapter *);
int t4_read_chip_settings(struct adapter *);
int t4_verify_chip_settings(struct adapter *);
void t4_init_rx_buf_info(struct adapter *);
int t4_create_dma_tag(struct adapter *);
void t4_sge_sysctls(struct adapter *, struct sysctl_ctx_list *,
struct sysctl_oid_list *);

View File

@ -643,7 +643,7 @@ int t4_prep_adapter(struct adapter *adapter, u32 *buf);
int t4_shutdown_adapter(struct adapter *adapter);
int t4_init_devlog_params(struct adapter *adapter, int fw_attach);
int t4_init_sge_params(struct adapter *adapter);
int t4_init_tp_params(struct adapter *adap, bool sleep_ok);
int t4_init_tp_params(struct adapter *adap);
int t4_filter_field_shift(const struct adapter *adap, int filter_sel);
int t4_port_init(struct adapter *adap, int mbox, int pf, int vf, int port_id);
void t4_fatal_err(struct adapter *adapter, bool fw_error);

View File

@ -9677,7 +9677,7 @@ static void read_filter_mode_and_ingress_config(struct adapter *adap,
*
* Initialize various fields of the adapter's TP Parameters structure.
*/
int t4_init_tp_params(struct adapter *adap, bool sleep_ok)
int t4_init_tp_params(struct adapter *adap)
{
int chan;
u32 tx_len, rx_len, r, v;
@ -9691,7 +9691,7 @@ int t4_init_tp_params(struct adapter *adap, bool sleep_ok)
for (chan = 0; chan < MAX_NCHAN; chan++)
tpp->tx_modq[chan] = chan;
read_filter_mode_and_ingress_config(adap, sleep_ok);
read_filter_mode_and_ingress_config(adap, true);
if (chip_id(adap) > CHELSIO_T5) {
v = t4_read_reg(adap, A_TP_OUT_CONFIG);

View File

@ -4754,13 +4754,19 @@ get_params__post_init(struct adapter *sc)
sc->vres.key.size = val[1] - val[0] + 1;
}
t4_init_sge_params(sc);
/*
* We've got the params we wanted to query via the firmware. Now grab
* some others directly from the chip.
* We've got the params we wanted to query directly from the firmware.
* Grab some others via other means.
*/
rc = t4_read_chip_settings(sc);
t4_init_sge_params(sc);
t4_init_tp_params(sc);
t4_read_mtu_tbl(sc, sc->params.mtus, NULL);
t4_load_mtus(sc, sc->params.mtus, sc->params.a_wnd, sc->params.b_wnd);
rc = t4_verify_chip_settings(sc);
if (rc != 0)
return (rc);
t4_init_rx_buf_info(sc);
return (rc);
}

View File

@ -826,16 +826,15 @@ hwsz_ok(struct adapter *sc, int hwsz)
}
/*
* XXX: driver really should be able to deal with unexpected settings.
* Initialize the rx buffer sizes and figure out which zones the buffers will
* be allocated from.
*/
int
t4_read_chip_settings(struct adapter *sc)
void
t4_init_rx_buf_info(struct adapter *sc)
{
struct sge *s = &sc->sge;
struct sge_params *sp = &sc->params.sge;
int i, j, n, rc = 0;
uint32_t m, v, r;
uint16_t indsz = min(RX_COPY_THRESHOLD - 1, M_INDICATESIZE);
int i, j, n;
static int sw_buf_sizes[] = { /* Sorted by size */
MCLBYTES,
#if MJUMPAGESIZE != MCLBYTES
@ -846,23 +845,6 @@ t4_read_chip_settings(struct adapter *sc)
};
struct rx_buf_info *rxb;
m = F_RXPKTCPLMODE;
v = F_RXPKTCPLMODE;
r = sc->params.sge.sge_control;
if ((r & m) != v) {
device_printf(sc->dev, "invalid SGE_CONTROL(0x%x)\n", r);
rc = EINVAL;
}
/*
* If this changes then every single use of PAGE_SHIFT in the driver
* needs to be carefully reviewed for PAGE_SHIFT vs sp->page_shift.
*/
if (sp->page_shift != PAGE_SHIFT) {
device_printf(sc->dev, "invalid SGE_HOST_PAGE_SIZE(0x%x)\n", r);
rc = EINVAL;
}
s->safe_zidx = -1;
rxb = &s->rx_buf_info[0];
for (i = 0; i < SW_ZONE_SIZES; i++, rxb++) {
@ -907,6 +889,36 @@ t4_read_chip_settings(struct adapter *sc)
if (s->safe_zidx == -1 && rxb->size1 == safest_rx_cluster)
s->safe_zidx = i;
}
}
/*
* Verify some basic SGE settings for the PF and VF driver, and other
* miscellaneous settings for the PF driver.
*/
int
t4_verify_chip_settings(struct adapter *sc)
{
struct sge_params *sp = &sc->params.sge;
uint32_t m, v, r;
int rc = 0;
const uint16_t indsz = min(RX_COPY_THRESHOLD - 1, M_INDICATESIZE);
m = F_RXPKTCPLMODE;
v = F_RXPKTCPLMODE;
r = sp->sge_control;
if ((r & m) != v) {
device_printf(sc->dev, "invalid SGE_CONTROL(0x%x)\n", r);
rc = EINVAL;
}
/*
* If this changes then every single use of PAGE_SHIFT in the driver
* needs to be carefully reviewed for PAGE_SHIFT vs sp->page_shift.
*/
if (sp->page_shift != PAGE_SHIFT) {
device_printf(sc->dev, "invalid SGE_HOST_PAGE_SIZE(0x%x)\n", r);
rc = EINVAL;
}
if (sc->flags & IS_VF)
return (0);
@ -915,14 +927,16 @@ t4_read_chip_settings(struct adapter *sc)
r = t4_read_reg(sc, A_ULP_RX_TDDP_PSZ);
if (r != v) {
device_printf(sc->dev, "invalid ULP_RX_TDDP_PSZ(0x%x)\n", r);
rc = EINVAL;
if (sc->vres.ddp.size != 0)
rc = EINVAL;
}
m = v = F_TDDPTAGTCB;
r = t4_read_reg(sc, A_ULP_RX_CTL);
if ((r & m) != v) {
device_printf(sc->dev, "invalid ULP_RX_CTL(0x%x)\n", r);
rc = EINVAL;
if (sc->vres.ddp.size != 0)
rc = EINVAL;
}
m = V_INDICATESIZE(M_INDICATESIZE) | F_REARMDDPOFFSET |
@ -931,14 +945,10 @@ t4_read_chip_settings(struct adapter *sc)
r = t4_read_reg(sc, A_TP_PARA_REG5);
if ((r & m) != v) {
device_printf(sc->dev, "invalid TP_PARA_REG5(0x%x)\n", r);
rc = EINVAL;
if (sc->vres.ddp.size != 0)
rc = EINVAL;
}
t4_init_tp_params(sc, 1);
t4_read_mtu_tbl(sc, sc->params.mtus, NULL);
t4_load_mtus(sc, sc->params.mtus, sc->params.a_wnd, sc->params.b_wnd);
return (rc);
}

View File

@ -253,10 +253,6 @@ get_params__post_init(struct adapter *sc)
return (EINVAL);
}
rc = t4_read_chip_settings(sc);
if (rc != 0)
return (rc);
/*
* Grab our Virtual Interface resource allocation, extract the
* features that we're interested in and do a bit of sanity testing on
@ -290,6 +286,11 @@ get_params__post_init(struct adapter *sc)
else
sc->params.max_pkts_per_eth_tx_pkts_wr = 14;
rc = t4_verify_chip_settings(sc);
if (rc != 0)
return (rc);
t4_init_rx_buf_info(sc);
return (0);
}