Skip to content

Commit 67eb5b7

Browse files
authored
Merge pull request #538 from intel-go/ifilippov/fix
Fix problem with allocating to much TX queues
2 parents 1477f58 + 27f4aa0 commit 67eb5b7

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

examples/ipsec/perf/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ FROM ${USER_NAME}/nff-go-base
88
LABEL RUN docker run -it --privileged -v /sys/bus/pci/drivers:/sys/bus/pci/drivers -v /sys/kernel/mm/hugepages:/sys/kernel/mm/hugepages -v /sys/devices/system/node:/sys/devices/system/node -v /dev:/dev --name NAME -e NAME=NAME -e IMAGE=IMAGE IMAGE
99

1010
WORKDIR /workdir
11-
COPY perf .
11+
COPY ipsec .

low/low.h

+16-10
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,13 @@ int check_port_rss(uint16_t port) {
172172
return dev_info.max_rx_queues;
173173
}
174174

175+
int check_port_tx(uint16_t port) {
176+
struct rte_eth_dev_info dev_info;
177+
memset(&dev_info, 0, sizeof(dev_info));
178+
rte_eth_dev_info_get(port, &dev_info);
179+
return dev_info.max_tx_queues;
180+
}
181+
175182
// Initializes a given port using global settings and with the RX buffers
176183
// coming from the mbuf_pool passed as a parameter.
177184
int port_init(uint16_t port, bool willReceive, struct rte_mempool **mbuf_pools, bool promiscuous, bool hwtxchecksum, int32_t inIndex) {
@@ -181,17 +188,15 @@ int port_init(uint16_t port, bool willReceive, struct rte_mempool **mbuf_pools,
181188
memset(&dev_info, 0, sizeof(dev_info));
182189
rte_eth_dev_info_get(port, &dev_info);
183190

191+
if (tx_rings > dev_info.max_tx_queues) {
192+
tx_rings = check_port_tx(port);
193+
}
194+
184195
if (willReceive) {
185196
rx_rings = inIndex;
186-
if (tx_rings == 0) {
187-
// All receive ports should have at least one send queue to handle ARP
188-
tx_rings = 1;
189-
}
190197
} else {
191198
rx_rings = 0;
192199
}
193-
int retval;
194-
uint16_t q;
195200

196201
if (port >= rte_eth_dev_count())
197202
return -1;
@@ -210,20 +215,20 @@ int port_init(uint16_t port, bool willReceive, struct rte_mempool **mbuf_pools,
210215
}
211216

212217
/* Configure the Ethernet device. */
213-
retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf_default);
218+
int retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf_default);
214219
if (retval != 0)
215220
return retval;
216221

217222
/* Allocate and set up RX queues per Ethernet port. */
218-
for (q = 0; q < rx_rings; q++) {
223+
for (uint16_t q = 0; q < rx_rings; q++) {
219224
retval = rte_eth_rx_queue_setup(port, q, RX_RING_SIZE,
220225
rte_eth_dev_socket_id(port), NULL, mbuf_pools[q]);
221226
if (retval < 0)
222227
return retval;
223228
}
224229

225230
/* Allocate and set up TX queues per Ethernet port. */
226-
for (q = 0; q < tx_rings; q++) {
231+
for (uint16_t q = 0; q < tx_rings; q++) {
227232
retval = rte_eth_tx_queue_setup(port, q, TX_RING_SIZE,
228233
rte_eth_dev_socket_id(port), &dev_info.default_txconf);
229234
if (retval < 0)
@@ -409,6 +414,7 @@ void nff_go_send(uint16_t port, struct rte_ring **in_rings, int32_t inIndexNumbe
409414
uint16_t buf;
410415
uint16_t tx_pkts_number;
411416
int16_t queue = 0;
417+
bool switchQueue = (check_port_tx(port) > 1) && (anyway || inIndexNumber > 1);
412418
while (*flag == process) {
413419
for (int q = 0; q < inIndexNumber; q++) {
414420
// Get packets for TX from ring
@@ -420,7 +426,7 @@ void nff_go_send(uint16_t port, struct rte_ring **in_rings, int32_t inIndexNumbe
420426
tx_pkts_number = rte_eth_tx_burst(port, queue, bufs, pkts_for_tx_number);
421427
// inIndexNumber must be "1" or even. This prevents any reordering.
422428
// anyway allows reordering explicitly
423-
if (anyway || inIndexNumber > 1) {
429+
if (switchQueue) {
424430
queue = !queue;
425431
}
426432
// Free any unsent packets

0 commit comments

Comments
 (0)