Skip to content

Commit 116ca92

Browse files
vishalsdkdavem330
authored andcommitted
cxgb4: fix checks for max queues to allocate
Hardware can support more than 8 queues currently limited by netif_get_num_default_rss_queues(). So, rework and fix checks for max number of queues to allocate. The checks should be based on how many are actually supported by hardware, OR the number of online cpus; whichever is lower. Fixes: 5952dde ("cxgb4: set maximal number of default RSS queues") Signed-off-by: Vishal Kulkarni <[email protected]>" Signed-off-by: David S. Miller <[email protected]>
1 parent 20d8bb0 commit 116ca92

File tree

1 file changed

+27
-22
lines changed

1 file changed

+27
-22
lines changed

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

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5381,12 +5381,11 @@ static inline bool is_x_10g_port(const struct link_config *lc)
53815381
static int cfg_queues(struct adapter *adap)
53825382
{
53835383
u32 avail_qsets, avail_eth_qsets, avail_uld_qsets;
5384+
u32 i, n10g = 0, qidx = 0, n1g = 0;
5385+
u32 ncpus = num_online_cpus();
53845386
u32 niqflint, neq, num_ulds;
53855387
struct sge *s = &adap->sge;
5386-
u32 i, n10g = 0, qidx = 0;
5387-
#ifndef CONFIG_CHELSIO_T4_DCB
5388-
int q10g = 0;
5389-
#endif
5388+
u32 q10g = 0, q1g;
53905389

53915390
/* Reduce memory usage in kdump environment, disable all offload. */
53925391
if (is_kdump_kernel() || (is_uld(adap) && t4_uld_mem_alloc(adap))) {
@@ -5424,44 +5423,50 @@ static int cfg_queues(struct adapter *adap)
54245423
n10g += is_x_10g_port(&adap2pinfo(adap, i)->link_cfg);
54255424

54265425
avail_eth_qsets = min_t(u32, avail_qsets, MAX_ETH_QSETS);
5426+
5427+
/* We default to 1 queue per non-10G port and up to # of cores queues
5428+
* per 10G port.
5429+
*/
5430+
if (n10g)
5431+
q10g = (avail_eth_qsets - (adap->params.nports - n10g)) / n10g;
5432+
5433+
n1g = adap->params.nports - n10g;
54275434
#ifdef CONFIG_CHELSIO_T4_DCB
54285435
/* For Data Center Bridging support we need to be able to support up
54295436
* to 8 Traffic Priorities; each of which will be assigned to its
54305437
* own TX Queue in order to prevent Head-Of-Line Blocking.
54315438
*/
5439+
q1g = 8;
54325440
if (adap->params.nports * 8 > avail_eth_qsets) {
54335441
dev_err(adap->pdev_dev, "DCB avail_eth_qsets=%d < %d!\n",
54345442
avail_eth_qsets, adap->params.nports * 8);
54355443
return -ENOMEM;
54365444
}
54375445

5438-
for_each_port(adap, i) {
5439-
struct port_info *pi = adap2pinfo(adap, i);
5446+
if (adap->params.nports * ncpus < avail_eth_qsets)
5447+
q10g = max(8U, ncpus);
5448+
else
5449+
q10g = max(8U, q10g);
54405450

5441-
pi->first_qset = qidx;
5442-
pi->nqsets = is_kdump_kernel() ? 1 : 8;
5443-
qidx += pi->nqsets;
5444-
}
5445-
#else /* !CONFIG_CHELSIO_T4_DCB */
5446-
/* We default to 1 queue per non-10G port and up to # of cores queues
5447-
* per 10G port.
5448-
*/
5449-
if (n10g)
5450-
q10g = (avail_eth_qsets - (adap->params.nports - n10g)) / n10g;
5451-
if (q10g > netif_get_num_default_rss_queues())
5452-
q10g = netif_get_num_default_rss_queues();
5451+
while ((q10g * n10g) > (avail_eth_qsets - n1g * q1g))
5452+
q10g--;
54535453

5454-
if (is_kdump_kernel())
5454+
#else /* !CONFIG_CHELSIO_T4_DCB */
5455+
q1g = 1;
5456+
q10g = min(q10g, ncpus);
5457+
#endif /* !CONFIG_CHELSIO_T4_DCB */
5458+
if (is_kdump_kernel()) {
54555459
q10g = 1;
5460+
q1g = 1;
5461+
}
54565462

54575463
for_each_port(adap, i) {
54585464
struct port_info *pi = adap2pinfo(adap, i);
54595465

54605466
pi->first_qset = qidx;
5461-
pi->nqsets = is_x_10g_port(&pi->link_cfg) ? q10g : 1;
5467+
pi->nqsets = is_x_10g_port(&pi->link_cfg) ? q10g : q1g;
54625468
qidx += pi->nqsets;
54635469
}
5464-
#endif /* !CONFIG_CHELSIO_T4_DCB */
54655470

54665471
s->ethqsets = qidx;
54675472
s->max_ethqsets = qidx; /* MSI-X may lower it later */
@@ -5473,7 +5478,7 @@ static int cfg_queues(struct adapter *adap)
54735478
* capped by the number of available cores.
54745479
*/
54755480
num_ulds = adap->num_uld + adap->num_ofld_uld;
5476-
i = min_t(u32, MAX_OFLD_QSETS, num_online_cpus());
5481+
i = min_t(u32, MAX_OFLD_QSETS, ncpus);
54775482
avail_uld_qsets = roundup(i, adap->params.nports);
54785483
if (avail_qsets < num_ulds * adap->params.nports) {
54795484
adap->params.offload = 0;

0 commit comments

Comments
 (0)