Some NICs may not be able to support interrupts on all queues that are
advertised, which will cause the test to fail if the queues supporting
interrupts are fewer than 64. We can work around this by retrying the
NIC configuration multiple times with fewer queues in case of failure.
This allows the test to pass with NICs using ixgbe driver, for example.

Signed-off-by: Bruce Richardson <[email protected]>
---
 app/test/test_event_eth_rx_adapter.c | 52 +++++++++++++++++-----------
 1 file changed, 32 insertions(+), 20 deletions(-)

diff --git a/app/test/test_event_eth_rx_adapter.c 
b/app/test/test_event_eth_rx_adapter.c
index ae428b3333..7b38935bec 100644
--- a/app/test/test_event_eth_rx_adapter.c
+++ b/app/test/test_event_eth_rx_adapter.c
@@ -60,6 +60,7 @@ port_init_common(uint16_t port, const struct rte_eth_conf 
*port_conf,
 {
        const uint16_t rx_ring_size = 512, tx_ring_size = 512;
        int retval;
+       bool started = false;
        uint16_t q;
        struct rte_eth_dev_info dev_info;
 
@@ -76,32 +77,43 @@ port_init_common(uint16_t port, const struct rte_eth_conf 
*port_conf,
                                        MAX_NUM_RX_QUEUE);
        default_params.tx_rings = 1;
 
-       /* Configure the Ethernet device. */
-       retval = rte_eth_dev_configure(port, default_params.rx_rings,
+       while (!started) {
+               /* Configure the Ethernet device. */
+               retval = rte_eth_dev_configure(port, default_params.rx_rings,
                                default_params.tx_rings, port_conf);
-       if (retval != 0)
-               return retval;
-
-       for (q = 0; q < default_params.rx_rings; q++) {
-               retval = rte_eth_rx_queue_setup(port, q, rx_ring_size,
-                               rte_eth_dev_socket_id(port), NULL, mp);
-               if (retval < 0)
+               if (retval != 0)
                        return retval;
-       }
 
-       /* Allocate and set up 1 TX queue per Ethernet port. */
-       for (q = 0; q < default_params.tx_rings; q++) {
-               retval = rte_eth_tx_queue_setup(port, q, tx_ring_size,
-                               rte_eth_dev_socket_id(port), NULL);
-               if (retval < 0)
+               for (q = 0; q < default_params.rx_rings; q++) {
+                       retval = rte_eth_rx_queue_setup(port, q, rx_ring_size,
+                                       rte_eth_dev_socket_id(port), NULL, mp);
+                       if (retval < 0)
+                               return retval;
+               }
+
+               /* Allocate and set up 1 TX queue per Ethernet port. */
+               for (q = 0; q < default_params.tx_rings; q++) {
+                       retval = rte_eth_tx_queue_setup(port, q, tx_ring_size,
+                                       rte_eth_dev_socket_id(port), NULL);
+                       if (retval < 0)
+                               return retval;
+               }
+
+               /* Start the Ethernet port. */
+               retval = rte_eth_dev_start(port);
+               if (retval < 0) {
+                       /* Some NICs may not support interrupts on all reported 
queues.
+                        * Therefore try to reconfigure and start with fewer 
queues
+                        */
+                       if (default_params.rx_rings > 2) {
+                               default_params.rx_rings /= 2;
+                               continue;
+                       }
                        return retval;
+               }
+               started = true;
        }
 
-       /* Start the Ethernet port. */
-       retval = rte_eth_dev_start(port);
-       if (retval < 0)
-               return retval;
-
        /* Display the port MAC address. */
        struct rte_ether_addr addr;
        retval = rte_eth_macaddr_get(port, &addr);
-- 
2.51.0

Reply via email to