@@ -172,6 +172,13 @@ int check_port_rss(uint16_t port) {
172
172
return dev_info .max_rx_queues ;
173
173
}
174
174
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
+
175
182
// Initializes a given port using global settings and with the RX buffers
176
183
// coming from the mbuf_pool passed as a parameter.
177
184
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,
181
188
memset (& dev_info , 0 , sizeof (dev_info ));
182
189
rte_eth_dev_info_get (port , & dev_info );
183
190
191
+ if (tx_rings > dev_info .max_tx_queues ) {
192
+ tx_rings = check_port_tx (port );
193
+ }
194
+
184
195
if (willReceive ) {
185
196
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
- }
190
197
} else {
191
198
rx_rings = 0 ;
192
199
}
193
- int retval ;
194
- uint16_t q ;
195
200
196
201
if (port >= rte_eth_dev_count ())
197
202
return -1 ;
@@ -210,20 +215,20 @@ int port_init(uint16_t port, bool willReceive, struct rte_mempool **mbuf_pools,
210
215
}
211
216
212
217
/* 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 );
214
219
if (retval != 0 )
215
220
return retval ;
216
221
217
222
/* 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 ++ ) {
219
224
retval = rte_eth_rx_queue_setup (port , q , RX_RING_SIZE ,
220
225
rte_eth_dev_socket_id (port ), NULL , mbuf_pools [q ]);
221
226
if (retval < 0 )
222
227
return retval ;
223
228
}
224
229
225
230
/* 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 ++ ) {
227
232
retval = rte_eth_tx_queue_setup (port , q , TX_RING_SIZE ,
228
233
rte_eth_dev_socket_id (port ), & dev_info .default_txconf );
229
234
if (retval < 0 )
@@ -409,6 +414,7 @@ void nff_go_send(uint16_t port, struct rte_ring **in_rings, int32_t inIndexNumbe
409
414
uint16_t buf ;
410
415
uint16_t tx_pkts_number ;
411
416
int16_t queue = 0 ;
417
+ bool switchQueue = (check_port_tx (port ) > 1 ) && (anyway || inIndexNumber > 1 );
412
418
while (* flag == process ) {
413
419
for (int q = 0 ; q < inIndexNumber ; q ++ ) {
414
420
// 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
420
426
tx_pkts_number = rte_eth_tx_burst (port , queue , bufs , pkts_for_tx_number );
421
427
// inIndexNumber must be "1" or even. This prevents any reordering.
422
428
// anyway allows reordering explicitly
423
- if (anyway || inIndexNumber > 1 ) {
429
+ if (switchQueue ) {
424
430
queue = !queue ;
425
431
}
426
432
// Free any unsent packets
0 commit comments