Commit 1c6a5b0e authored by Hariprasad Shenai's avatar Hariprasad Shenai Committed by David S. Miller

cxgb4: Move offload Rx queue allocation to separate function

Adds a common function for all Rx queue allocation.
Signed-off-by: default avatarHariprasad Shenai <hariprasad@chelsio.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 842a9ae0
...@@ -957,6 +957,28 @@ static void enable_rx(struct adapter *adap) ...@@ -957,6 +957,28 @@ static void enable_rx(struct adapter *adap)
} }
} }
static int alloc_ofld_rxqs(struct adapter *adap, struct sge_ofld_rxq *q,
unsigned int nq, unsigned int per_chan, int msi_idx,
u16 *ids)
{
int i, err;
for (i = 0; i < nq; i++, q++) {
if (msi_idx > 0)
msi_idx++;
err = t4_sge_alloc_rxq(adap, &q->rspq, false,
adap->port[i / per_chan],
msi_idx, q->fl.size ? &q->fl : NULL,
uldrx_handler);
if (err)
return err;
memset(&q->stats, 0, sizeof(q->stats));
if (ids)
ids[i] = q->rspq.abs_id;
}
return 0;
}
/** /**
* setup_sge_queues - configure SGE Tx/Rx/response queues * setup_sge_queues - configure SGE Tx/Rx/response queues
* @adap: the adapter * @adap: the adapter
...@@ -1018,51 +1040,26 @@ freeout: t4_free_sge_resources(adap); ...@@ -1018,51 +1040,26 @@ freeout: t4_free_sge_resources(adap);
j = s->ofldqsets / adap->params.nports; /* ofld queues per channel */ j = s->ofldqsets / adap->params.nports; /* ofld queues per channel */
for_each_ofldrxq(s, i) { for_each_ofldrxq(s, i) {
struct sge_ofld_rxq *q = &s->ofldrxq[i]; err = t4_sge_alloc_ofld_txq(adap, &s->ofldtxq[i],
struct net_device *dev = adap->port[i / j]; adap->port[i / j],
if (msi_idx > 0)
msi_idx++;
err = t4_sge_alloc_rxq(adap, &q->rspq, false, dev, msi_idx,
q->fl.size ? &q->fl : NULL,
uldrx_handler);
if (err)
goto freeout;
memset(&q->stats, 0, sizeof(q->stats));
s->ofld_rxq[i] = q->rspq.abs_id;
err = t4_sge_alloc_ofld_txq(adap, &s->ofldtxq[i], dev,
s->fw_evtq.cntxt_id); s->fw_evtq.cntxt_id);
if (err) if (err)
goto freeout; goto freeout;
} }
for_each_rdmarxq(s, i) { #define ALLOC_OFLD_RXQS(firstq, nq, per_chan, ids) do { \
struct sge_ofld_rxq *q = &s->rdmarxq[i]; err = alloc_ofld_rxqs(adap, firstq, nq, per_chan, msi_idx, ids); \
if (err) \
goto freeout; \
if (msi_idx > 0) \
msi_idx += nq; \
} while (0)
if (msi_idx > 0) ALLOC_OFLD_RXQS(s->ofldrxq, s->ofldqsets, j, s->ofld_rxq);
msi_idx++; ALLOC_OFLD_RXQS(s->rdmarxq, s->rdmaqs, 1, s->rdma_rxq);
err = t4_sge_alloc_rxq(adap, &q->rspq, false, adap->port[i], ALLOC_OFLD_RXQS(s->rdmaciq, s->rdmaciqs, 1, s->rdma_ciq);
msi_idx, q->fl.size ? &q->fl : NULL,
uldrx_handler);
if (err)
goto freeout;
memset(&q->stats, 0, sizeof(q->stats));
s->rdma_rxq[i] = q->rspq.abs_id;
}
for_each_rdmaciq(s, i) { #undef ALLOC_OFLD_RXQS
struct sge_ofld_rxq *q = &s->rdmaciq[i];
if (msi_idx > 0)
msi_idx++;
err = t4_sge_alloc_rxq(adap, &q->rspq, false, adap->port[i],
msi_idx, q->fl.size ? &q->fl : NULL,
uldrx_handler);
if (err)
goto freeout;
memset(&q->stats, 0, sizeof(q->stats));
s->rdma_ciq[i] = q->rspq.abs_id;
}
for_each_port(adap, i) { for_each_port(adap, i) {
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment