Skip to content

Commit 3d0edd9

Browse files
committed
Propagate number of TX queues from app to port init
1 parent 6d9cce5 commit 3d0edd9

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

internal/low/low.go

+4
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,10 @@ func CheckPortRSS(port uint16) int32 {
600600
return int32(C.check_max_port_rx_queues(C.uint16_t(port)))
601601
}
602602

603+
func CheckPortMaxTXQueues(port uint16) int32 {
604+
return int32(C.check_max_port_tx_queues(C.uint16_t(port)))
605+
}
606+
603607
// CreatePort initializes a new port using global settings and parameters.
604608
func CreatePort(port uint16, willReceive bool, promiscuous bool, hwtxchecksum,
605609
hwrxpacketstimestamp bool, inIndex int32, tXQueuesNumberPerPort int) error {

internal/low/low.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040

4141
// 2 queues are enough for handling 40GBits. Should be checked for other NICs.
4242
// TODO This macro should be a function that will dynamically return the needed number of cores.
43-
#define TX_QUEUE_NUMBER 16
4443
#define TX_QUEUE_CORES 2
4544
#define TX_ATTEMPTS 3
4645

@@ -274,14 +273,15 @@ uint16_t check_current_port_tx_queues(uint16_t port) {
274273
// Initializes a given port using global settings and with the RX buffers
275274
// coming from the mbuf_pool passed as a parameter.
276275
int port_init(uint16_t port, bool willReceive, struct rte_mempool **mbuf_pools, bool promiscuous, bool hwtxchecksum, bool hwrxpacketstimestamp, int32_t inIndex, int32_t tx_queues) {
277-
uint16_t rx_rings, tx_rings = TX_QUEUE_NUMBER;
276+
uint16_t rx_rings, tx_rings = tx_queues;
278277

279278
struct rte_eth_dev_info dev_info;
280279
memset(&dev_info, 0, sizeof(dev_info));
281280
rte_eth_dev_info_get(port, &dev_info);
282281

283282
if (tx_rings > dev_info.max_tx_queues) {
284-
tx_rings = check_max_port_tx_queues(port);
283+
printf("Warning! Port %d does not support requested number of TX queues %d. Setting number of TX queues to %d\n", port, tx_rings, dev_info.max_tx_queues);
284+
tx_rings = dev_info.max_tx_queues;
285285
}
286286

287287
if (willReceive) {
@@ -563,9 +563,9 @@ void nff_go_send(uint16_t port, struct rte_ring **in_rings, int32_t inIndexNumbe
563563
struct rte_mbuf *bufs[BURST_SIZE];
564564
uint16_t buf;
565565
uint16_t tx_pkts_number;
566-
int16_t port_tx_queues = check_current_port_tx_queues(port);
567-
int16_t tx_qstart = port_tx_queues / totalSendTreads * sendThreadIndex;
568-
int16_t tx_qend = port_tx_queues / totalSendTreads * (sendThreadIndex + 1);
566+
int16_t port_tx_queues = check_current_port_tx_queues(port);
567+
int16_t tx_qstart = port_tx_queues / totalSendTreads * sendThreadIndex;
568+
int16_t tx_qend = sendThreadIndex + 1 == totalSendTreads ? port_tx_queues : port_tx_queues / totalSendTreads * (sendThreadIndex + 1);
569569
int16_t tx_queue_counter = tx_qstart;
570570
int rx_qstart = inIndexNumber / totalSendTreads * sendThreadIndex;
571571
int rx_qend = inIndexNumber / totalSendTreads * (sendThreadIndex + 1);

0 commit comments

Comments
 (0)