git: b52a25051796 - stable/13 - cxgbe(4): Allocate a taskqueue per port instead of per channel.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 17 Jul 2024 14:24:38 UTC
The branch stable/13 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=b52a25051796a930b2eb8985180744bb676df928 commit b52a25051796a930b2eb8985180744bb676df928 Author: Navdeep Parhar <np@FreeBSD.org> AuthorDate: 2024-04-30 17:51:45 +0000 Commit: Navdeep Parhar <np@FreeBSD.org> CommitDate: 2024-07-17 07:14:27 +0000 cxgbe(4): Allocate a taskqueue per port instead of per channel. All the channels are not used on all boards and there's no point allocating taskqueues that will never be used. Sponsored by: Chelsio Communications (cherry picked from commit 857d74b6340e418396d79a46b264ce0eedd760e4) --- sys/dev/cxgbe/adapter.h | 3 ++- sys/dev/cxgbe/t4_main.c | 7 +++++-- sys/dev/cxgbe/t4_sge.c | 19 ++++++++++--------- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/sys/dev/cxgbe/adapter.h b/sys/dev/cxgbe/adapter.h index 648182fe31c4..8d70e840d3f2 100644 --- a/sys/dev/cxgbe/adapter.h +++ b/sys/dev/cxgbe/adapter.h @@ -475,6 +475,7 @@ struct sge_eq { unsigned int abs_id; /* absolute SGE id for the eq */ uint8_t type; /* EQ_CTRL/EQ_ETH/EQ_OFLD */ uint8_t doorbells; + uint8_t port_id; /* port_id of the port associated with the eq */ uint8_t tx_chan; /* tx channel used by the eq */ struct mtx eq_lock; @@ -930,7 +931,7 @@ struct adapter { int nrawf; u_int vlan_id; - struct taskqueue *tq[MAX_NCHAN]; /* General purpose taskqueues */ + struct taskqueue *tq[MAX_NPORTS]; /* General purpose taskqueues */ struct port_info *port[MAX_NPORTS]; uint8_t chan_map[MAX_NCHAN]; /* channel -> port */ diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c index dd7552a50e4f..8895e22d18ac 100644 --- a/sys/dev/cxgbe/t4_main.c +++ b/sys/dev/cxgbe/t4_main.c @@ -6745,7 +6745,8 @@ adapter_full_init(struct adapter *sc) if (rc != 0) return (rc); - for (i = 0; i < nitems(sc->tq); i++) { + MPASS(sc->params.nports <= nitems(sc->tq)); + for (i = 0; i < sc->params.nports; i++) { if (sc->tq[i] != NULL) continue; sc->tq[i] = taskqueue_create("t4 taskq", M_NOWAIT, @@ -6794,7 +6795,9 @@ adapter_full_uninit(struct adapter *sc) t4_teardown_adapter_queues(sc); - for (i = 0; i < nitems(sc->tq) && sc->tq[i]; i++) { + for (i = 0; i < nitems(sc->tq); i++) { + if (sc->tq[i] == NULL) + continue; taskqueue_free(sc->tq[i]); sc->tq[i] = NULL; } diff --git a/sys/dev/cxgbe/t4_sge.c b/sys/dev/cxgbe/t4_sge.c index 93f914c3e2c5..cc8a0cc652b2 100644 --- a/sys/dev/cxgbe/t4_sge.c +++ b/sys/dev/cxgbe/t4_sge.c @@ -3462,13 +3462,14 @@ init_fl(struct adapter *sc, struct sge_fl *fl, int qsize, int maxp, char *name) static inline void init_eq(struct adapter *sc, struct sge_eq *eq, int eqtype, int qsize, - uint8_t tx_chan, struct sge_iq *iq, char *name) + uint8_t port_id, struct sge_iq *iq, char *name) { KASSERT(eqtype >= EQ_CTRL && eqtype <= EQ_OFLD, ("%s: bad qtype %d", __func__, eqtype)); eq->type = eqtype; - eq->tx_chan = tx_chan; + eq->port_id = port_id; + eq->tx_chan = sc->port[port_id]->tx_chan; eq->iq = iq; eq->sidx = qsize - sc->params.sge.spg_len / EQ_ESIZE; strlcpy(eq->lockname, name, sizeof(eq->lockname)); @@ -3909,8 +3910,8 @@ alloc_ctrlq(struct adapter *sc, int idx) snprintf(name, sizeof(name), "%s ctrlq%d", device_get_nameunit(sc->dev), idx); - init_eq(sc, &ctrlq->eq, EQ_CTRL, CTRL_EQ_QSIZE, - sc->port[idx]->tx_chan, &sc->sge.fwq, name); + init_eq(sc, &ctrlq->eq, EQ_CTRL, CTRL_EQ_QSIZE, idx, + &sc->sge.fwq, name); rc = alloc_wrq(sc, NULL, ctrlq, &sc->ctx, oid); if (rc != 0) { CH_ERR(sc, "failed to allocate ctrlq%d: %d\n", idx, rc); @@ -4656,7 +4657,7 @@ alloc_txq(struct vi_info *vi, struct sge_txq *txq, int idx) iqidx = vi->first_rxq + (idx % vi->nrxq); snprintf(name, sizeof(name), "%s txq%d", device_get_nameunit(vi->dev), idx); - init_eq(sc, &txq->eq, EQ_ETH, vi->qsize_txq, pi->tx_chan, + init_eq(sc, &txq->eq, EQ_ETH, vi->qsize_txq, pi->port_id, &sc->sge.rxq[iqidx].iq, name); rc = mp_ring_alloc(&txq->r, eq->sidx, txq, eth_tx, @@ -4873,11 +4874,11 @@ alloc_ofld_txq(struct vi_info *vi, struct sge_ofld_txq *ofld_txq, int idx) device_get_nameunit(vi->dev), idx); if (vi->nofldrxq > 0) { iqidx = vi->first_ofld_rxq + (idx % vi->nofldrxq); - init_eq(sc, eq, EQ_OFLD, vi->qsize_txq, pi->tx_chan, + init_eq(sc, eq, EQ_OFLD, vi->qsize_txq, pi->port_id, &sc->sge.ofld_rxq[iqidx].iq, name); } else { iqidx = vi->first_rxq + (idx % vi->nrxq); - init_eq(sc, eq, EQ_OFLD, vi->qsize_txq, pi->tx_chan, + init_eq(sc, eq, EQ_OFLD, vi->qsize_txq, pi->port_id, &sc->sge.rxq[iqidx].iq, name); } @@ -6392,7 +6393,7 @@ handle_wrq_egr_update(struct adapter *sc, struct sge_eq *eq) struct sge_wrq *wrq = (void *)eq; atomic_readandclear_int(&eq->equiq); - taskqueue_enqueue(sc->tq[eq->tx_chan], &wrq->wrq_tx_task); + taskqueue_enqueue(sc->tq[eq->port_id], &wrq->wrq_tx_task); } static void @@ -6404,7 +6405,7 @@ handle_eth_egr_update(struct adapter *sc, struct sge_eq *eq) atomic_readandclear_int(&eq->equiq); if (mp_ring_is_idle(txq->r)) - taskqueue_enqueue(sc->tq[eq->tx_chan], &txq->tx_reclaim_task); + taskqueue_enqueue(sc->tq[eq->port_id], &txq->tx_reclaim_task); else mp_ring_check_drainage(txq->r, 64); }