Skip to content

Commit 3a397eb

Browse files
Sunil Gouthamdavem330
authored andcommitted
net: thunderx: Set queue count based on number of CPUs
81xx has only 4 CPUs, so it doesn't make sense to initialize entire Qset i.e 8 queues by default. Made changes to queue initialization to init queues equal to number of CPUs or 8 queues whichever is lesser. Also this will be applicable to VMs with VNIC VF attached and having less VCPUs Signed-off-by: Sunil Goutham <sgoutham@cavium.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 0025d93 commit 3a397eb

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

drivers/net/ethernet/cavium/thunder/nic_main.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,6 +1009,12 @@ static int nic_num_sqs_en(struct nicpf *nic, int vf_en)
10091009
int pos, sqs_per_vf = MAX_SQS_PER_VF_SINGLE_NODE;
10101010
u16 total_vf;
10111011

1012+
/* Secondary Qsets are needed only if CPU count is
1013+
* morethan MAX_QUEUES_PER_QSET.
1014+
*/
1015+
if (num_online_cpus() <= MAX_QUEUES_PER_QSET)
1016+
return 0;
1017+
10121018
/* Check if its a multi-node environment */
10131019
if (nr_node_ids > 1)
10141020
sqs_per_vf = MAX_SQS_PER_VF;

drivers/net/ethernet/cavium/thunder/nicvf_main.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1537,14 +1537,13 @@ static int nicvf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
15371537
goto err_release_regions;
15381538
}
15391539

1540-
qcount = MAX_CMP_QUEUES_PER_QS;
1540+
qcount = netif_get_num_default_rss_queues();
15411541

15421542
/* Restrict multiqset support only for host bound VFs */
15431543
if (pdev->is_virtfn) {
15441544
/* Set max number of queues per VF */
1545-
qcount = roundup(num_online_cpus(), MAX_CMP_QUEUES_PER_QS);
1546-
qcount = min(qcount,
1547-
(MAX_SQS_PER_VF + 1) * MAX_CMP_QUEUES_PER_QS);
1545+
qcount = min_t(int, num_online_cpus(),
1546+
(MAX_SQS_PER_VF + 1) * MAX_CMP_QUEUES_PER_QS);
15481547
}
15491548

15501549
netdev = alloc_etherdev_mqs(sizeof(struct nicvf), qcount, qcount);

drivers/net/ethernet/cavium/thunder/nicvf_queues.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -762,10 +762,10 @@ int nicvf_set_qset_resources(struct nicvf *nic)
762762
nic->qs = qs;
763763

764764
/* Set count of each queue */
765-
qs->rbdr_cnt = RBDR_CNT;
766-
qs->rq_cnt = RCV_QUEUE_CNT;
767-
qs->sq_cnt = SND_QUEUE_CNT;
768-
qs->cq_cnt = CMP_QUEUE_CNT;
765+
qs->rbdr_cnt = DEFAULT_RBDR_CNT;
766+
qs->rq_cnt = min_t(u8, MAX_RCV_QUEUES_PER_QS, num_online_cpus());
767+
qs->sq_cnt = min_t(u8, MAX_SND_QUEUES_PER_QS, num_online_cpus());
768+
qs->cq_cnt = max_t(u8, qs->rq_cnt, qs->sq_cnt);
769769

770770
/* Set queue lengths */
771771
qs->rbdr_len = RCV_BUF_COUNT;

drivers/net/ethernet/cavium/thunder/nicvf_queues.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,7 @@
5757
#define CMP_QUEUE_SIZE6 6ULL /* 64K entries */
5858

5959
/* Default queue count per QS, its lengths and threshold values */
60-
#define RBDR_CNT 1
61-
#define RCV_QUEUE_CNT 8
62-
#define SND_QUEUE_CNT 8
63-
#define CMP_QUEUE_CNT 8 /* Max of RCV and SND qcount */
60+
#define DEFAULT_RBDR_CNT 1
6461

6562
#define SND_QSIZE SND_QUEUE_SIZE2
6663
#define SND_QUEUE_LEN (1ULL << (SND_QSIZE + 10))

0 commit comments

Comments
 (0)