Skip to content

Commit f36e58e

Browse files
Hariprasad Shenaidavem330
authored andcommitted
cxgb4: Try and provide an RDMA CIQ per cpu
To allow for better scalability on systems with large core counts, we will try and allocate enough RDMA Concentrator IQs and MSI/X vectors as we have cores. If we cannot get enough MSI/X vectors, fall back to the minimum required: 1 per adapter rx channel. Also clean up cxgb_enable_msix() to make it readable and correct a bug where the vectors are not correctly assigned if the driver doesn't get the full amount requested. Signed-off-by: Steve Wise <[email protected]> Signed-off-by: Hariprasad Shenai <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 1c6a5b0 commit f36e58e

File tree

3 files changed

+46
-17
lines changed

3 files changed

+46
-17
lines changed

drivers/net/ethernet/chelsio/cxgb4/cxgb4.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ enum {
369369
MAX_OFLD_QSETS = 16, /* # of offload Tx/Rx queue sets */
370370
MAX_CTRL_QUEUES = NCHAN, /* # of control Tx queues */
371371
MAX_RDMA_QUEUES = NCHAN, /* # of streaming RDMA Rx queues */
372-
MAX_RDMA_CIQS = NCHAN, /* # of RDMA concentrator IQs */
372+
MAX_RDMA_CIQS = 32, /* # of RDMA concentrator IQs */
373373
MAX_ISCSI_QUEUES = NCHAN, /* # of streaming iSCSI Rx queues */
374374
};
375375

@@ -599,8 +599,8 @@ struct sge {
599599
u16 rdmaqs; /* # of available RDMA Rx queues */
600600
u16 rdmaciqs; /* # of available RDMA concentrator IQs */
601601
u16 ofld_rxq[MAX_OFLD_QSETS];
602-
u16 rdma_rxq[NCHAN];
603-
u16 rdma_ciq[NCHAN];
602+
u16 rdma_rxq[MAX_RDMA_QUEUES];
603+
u16 rdma_ciq[MAX_RDMA_CIQS];
604604
u16 timer_val[SGE_NTIMERS];
605605
u8 counter_val[SGE_NCOUNTERS];
606606
u32 fl_pg_order; /* large page allocation size */

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1769,6 +1769,8 @@ do { \
17691769
int n = min(4, adap->sge.rdmaqs - 4 * rdma_idx);
17701770

17711771
S("QType:", "RDMA-CPL");
1772+
S("Interface:",
1773+
rx[i].rspq.netdev ? rx[i].rspq.netdev->name : "N/A");
17721774
R("RspQ ID:", rspq.abs_id);
17731775
R("RspQ size:", rspq.size);
17741776
R("RspQE size:", rspq.iqe_len);
@@ -1788,6 +1790,8 @@ do { \
17881790
int n = min(4, adap->sge.rdmaciqs - 4 * ciq_idx);
17891791

17901792
S("QType:", "RDMA-CIQ");
1793+
S("Interface:",
1794+
rx[i].rspq.netdev ? rx[i].rspq.netdev->name : "N/A");
17911795
R("RspQ ID:", rspq.abs_id);
17921796
R("RspQ size:", rspq.size);
17931797
R("RspQE size:", rspq.iqe_len);

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

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,7 +1057,8 @@ freeout: t4_free_sge_resources(adap);
10571057

10581058
ALLOC_OFLD_RXQS(s->ofldrxq, s->ofldqsets, j, s->ofld_rxq);
10591059
ALLOC_OFLD_RXQS(s->rdmarxq, s->rdmaqs, 1, s->rdma_rxq);
1060-
ALLOC_OFLD_RXQS(s->rdmaciq, s->rdmaciqs, 1, s->rdma_ciq);
1060+
j = s->rdmaciqs / adap->params.nports; /* rdmaq queues per channel */
1061+
ALLOC_OFLD_RXQS(s->rdmaciq, s->rdmaciqs, j, s->rdma_ciq);
10611062

10621063
#undef ALLOC_OFLD_RXQS
10631064

@@ -5702,7 +5703,16 @@ static void cfg_queues(struct adapter *adap)
57025703
s->ofldqsets = adap->params.nports;
57035704
/* For RDMA one Rx queue per channel suffices */
57045705
s->rdmaqs = adap->params.nports;
5705-
s->rdmaciqs = adap->params.nports;
5706+
/* Try and allow at least 1 CIQ per cpu rounding down
5707+
* to the number of ports, with a minimum of 1 per port.
5708+
* A 2 port card in a 6 cpu system: 6 CIQs, 3 / port.
5709+
* A 4 port card in a 6 cpu system: 4 CIQs, 1 / port.
5710+
* A 4 port card in a 2 cpu system: 4 CIQs, 1 / port.
5711+
*/
5712+
s->rdmaciqs = min_t(int, MAX_RDMA_CIQS, num_online_cpus());
5713+
s->rdmaciqs = (s->rdmaciqs / adap->params.nports) *
5714+
adap->params.nports;
5715+
s->rdmaciqs = max_t(int, s->rdmaciqs, adap->params.nports);
57065716
}
57075717

57085718
for (i = 0; i < ARRAY_SIZE(s->ethrxq); i++) {
@@ -5788,12 +5798,17 @@ static void reduce_ethqs(struct adapter *adap, int n)
57885798
static int enable_msix(struct adapter *adap)
57895799
{
57905800
int ofld_need = 0;
5791-
int i, want, need;
5801+
int i, want, need, allocated;
57925802
struct sge *s = &adap->sge;
57935803
unsigned int nchan = adap->params.nports;
5794-
struct msix_entry entries[MAX_INGQ + 1];
5804+
struct msix_entry *entries;
5805+
5806+
entries = kmalloc(sizeof(*entries) * (MAX_INGQ + 1),
5807+
GFP_KERNEL);
5808+
if (!entries)
5809+
return -ENOMEM;
57955810

5796-
for (i = 0; i < ARRAY_SIZE(entries); ++i)
5811+
for (i = 0; i < MAX_INGQ + 1; ++i)
57975812
entries[i].entry = i;
57985813

57995814
want = s->max_ethqsets + EXTRA_VECS;
@@ -5810,29 +5825,39 @@ static int enable_msix(struct adapter *adap)
58105825
#else
58115826
need = adap->params.nports + EXTRA_VECS + ofld_need;
58125827
#endif
5813-
want = pci_enable_msix_range(adap->pdev, entries, need, want);
5814-
if (want < 0)
5815-
return want;
5828+
allocated = pci_enable_msix_range(adap->pdev, entries, need, want);
5829+
if (allocated < 0) {
5830+
dev_info(adap->pdev_dev, "not enough MSI-X vectors left,"
5831+
" not using MSI-X\n");
5832+
kfree(entries);
5833+
return allocated;
5834+
}
58165835

5817-
/*
5818-
* Distribute available vectors to the various queue groups.
5836+
/* Distribute available vectors to the various queue groups.
58195837
* Every group gets its minimum requirement and NIC gets top
58205838
* priority for leftovers.
58215839
*/
5822-
i = want - EXTRA_VECS - ofld_need;
5840+
i = allocated - EXTRA_VECS - ofld_need;
58235841
if (i < s->max_ethqsets) {
58245842
s->max_ethqsets = i;
58255843
if (i < s->ethqsets)
58265844
reduce_ethqs(adap, i);
58275845
}
58285846
if (is_offload(adap)) {
5829-
i = want - EXTRA_VECS - s->max_ethqsets;
5830-
i -= ofld_need - nchan;
5847+
if (allocated < want) {
5848+
s->rdmaqs = nchan;
5849+
s->rdmaciqs = nchan;
5850+
}
5851+
5852+
/* leftovers go to OFLD */
5853+
i = allocated - EXTRA_VECS - s->max_ethqsets -
5854+
s->rdmaqs - s->rdmaciqs;
58315855
s->ofldqsets = (i / nchan) * nchan; /* round down */
58325856
}
5833-
for (i = 0; i < want; ++i)
5857+
for (i = 0; i < allocated; ++i)
58345858
adap->msix_info[i].vec = entries[i].vector;
58355859

5860+
kfree(entries);
58365861
return 0;
58375862
}
58385863

0 commit comments

Comments
 (0)