Skip to content

Commit 1c6a5b0

Browse files
Hariprasad Shenaidavem330
authored andcommitted
cxgb4: Move offload Rx queue allocation to separate function
Adds a common function for all Rx queue allocation. Signed-off-by: Hariprasad Shenai <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 842a9ae commit 1c6a5b0

File tree

1 file changed

+35
-38
lines changed

1 file changed

+35
-38
lines changed

drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c

Lines changed: 35 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -957,6 +957,28 @@ static void enable_rx(struct adapter *adap)
957957
}
958958
}
959959

960+
static int alloc_ofld_rxqs(struct adapter *adap, struct sge_ofld_rxq *q,
961+
unsigned int nq, unsigned int per_chan, int msi_idx,
962+
u16 *ids)
963+
{
964+
int i, err;
965+
966+
for (i = 0; i < nq; i++, q++) {
967+
if (msi_idx > 0)
968+
msi_idx++;
969+
err = t4_sge_alloc_rxq(adap, &q->rspq, false,
970+
adap->port[i / per_chan],
971+
msi_idx, q->fl.size ? &q->fl : NULL,
972+
uldrx_handler);
973+
if (err)
974+
return err;
975+
memset(&q->stats, 0, sizeof(q->stats));
976+
if (ids)
977+
ids[i] = q->rspq.abs_id;
978+
}
979+
return 0;
980+
}
981+
960982
/**
961983
* setup_sge_queues - configure SGE Tx/Rx/response queues
962984
* @adap: the adapter
@@ -1018,51 +1040,26 @@ freeout: t4_free_sge_resources(adap);
10181040

10191041
j = s->ofldqsets / adap->params.nports; /* ofld queues per channel */
10201042
for_each_ofldrxq(s, i) {
1021-
struct sge_ofld_rxq *q = &s->ofldrxq[i];
1022-
struct net_device *dev = adap->port[i / j];
1023-
1024-
if (msi_idx > 0)
1025-
msi_idx++;
1026-
err = t4_sge_alloc_rxq(adap, &q->rspq, false, dev, msi_idx,
1027-
q->fl.size ? &q->fl : NULL,
1028-
uldrx_handler);
1029-
if (err)
1030-
goto freeout;
1031-
memset(&q->stats, 0, sizeof(q->stats));
1032-
s->ofld_rxq[i] = q->rspq.abs_id;
1033-
err = t4_sge_alloc_ofld_txq(adap, &s->ofldtxq[i], dev,
1043+
err = t4_sge_alloc_ofld_txq(adap, &s->ofldtxq[i],
1044+
adap->port[i / j],
10341045
s->fw_evtq.cntxt_id);
10351046
if (err)
10361047
goto freeout;
10371048
}
10381049

1039-
for_each_rdmarxq(s, i) {
1040-
struct sge_ofld_rxq *q = &s->rdmarxq[i];
1050+
#define ALLOC_OFLD_RXQS(firstq, nq, per_chan, ids) do { \
1051+
err = alloc_ofld_rxqs(adap, firstq, nq, per_chan, msi_idx, ids); \
1052+
if (err) \
1053+
goto freeout; \
1054+
if (msi_idx > 0) \
1055+
msi_idx += nq; \
1056+
} while (0)
10411057

1042-
if (msi_idx > 0)
1043-
msi_idx++;
1044-
err = t4_sge_alloc_rxq(adap, &q->rspq, false, adap->port[i],
1045-
msi_idx, q->fl.size ? &q->fl : NULL,
1046-
uldrx_handler);
1047-
if (err)
1048-
goto freeout;
1049-
memset(&q->stats, 0, sizeof(q->stats));
1050-
s->rdma_rxq[i] = q->rspq.abs_id;
1051-
}
1058+
ALLOC_OFLD_RXQS(s->ofldrxq, s->ofldqsets, j, s->ofld_rxq);
1059+
ALLOC_OFLD_RXQS(s->rdmarxq, s->rdmaqs, 1, s->rdma_rxq);
1060+
ALLOC_OFLD_RXQS(s->rdmaciq, s->rdmaciqs, 1, s->rdma_ciq);
10521061

1053-
for_each_rdmaciq(s, i) {
1054-
struct sge_ofld_rxq *q = &s->rdmaciq[i];
1055-
1056-
if (msi_idx > 0)
1057-
msi_idx++;
1058-
err = t4_sge_alloc_rxq(adap, &q->rspq, false, adap->port[i],
1059-
msi_idx, q->fl.size ? &q->fl : NULL,
1060-
uldrx_handler);
1061-
if (err)
1062-
goto freeout;
1063-
memset(&q->stats, 0, sizeof(q->stats));
1064-
s->rdma_ciq[i] = q->rspq.abs_id;
1065-
}
1062+
#undef ALLOC_OFLD_RXQS
10661063

10671064
for_each_port(adap, i) {
10681065
/*

0 commit comments

Comments
 (0)