examples: adjust Rx and Tx descriptors to device limits
authorRoman Zhukov <roman.zhukov@oktetlabs.ru>
Thu, 25 May 2017 15:57:54 +0000 (16:57 +0100)
committerThomas Monjalon <thomas@monjalon.net>
Sat, 8 Jul 2017 16:47:00 +0000 (18:47 +0200)
Signed-off-by: Roman Zhukov <roman.zhukov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
39 files changed:
examples/bond/main.c
examples/distributor/main.c
examples/ethtool/ethtool-app/main.c
examples/exception_path/main.c
examples/ip_fragmentation/main.c
examples/ip_pipeline/init.c
examples/ip_reassembly/main.c
examples/ipsec-secgw/ipsec-secgw.c
examples/ipv4_multicast/main.c
examples/kni/main.c
examples/l2fwd-cat/l2fwd-cat.c
examples/l2fwd-crypto/main.c
examples/l2fwd-jobstats/main.c
examples/l2fwd-keepalive/main.c
examples/l2fwd/main.c
examples/l3fwd-acl/main.c
examples/l3fwd-power/main.c
examples/l3fwd-vf/main.c
examples/l3fwd/main.c
examples/link_status_interrupt/main.c
examples/load_balancer/init.c
examples/multi_process/client_server_mp/mp_server/init.c
examples/multi_process/l2fwd_fork/main.c
examples/multi_process/symmetric_mp/main.c
examples/netmap_compat/lib/compat_netmap.c
examples/packet_ordering/main.c
examples/performance-thread/l3fwd-thread/main.c
examples/ptpclient/ptpclient.c
examples/qos_meter/main.c
examples/qos_sched/init.c
examples/quota_watermark/qw/init.c
examples/rxtx_callbacks/main.c
examples/server_node_efd/server/init.c
examples/skeleton/basicfwd.c
examples/tep_termination/vxlan_setup.c
examples/vhost/main.c
examples/vhost_xen/main.c
examples/vmdq/main.c
examples/vmdq_dcb/main.c

index dc60676..ecc6292 100644 (file)
@@ -177,6 +177,8 @@ static void
 slave_port_init(uint8_t portid, struct rte_mempool *mbuf_pool)
 {
        int retval;
+       uint16_t nb_rxd = RTE_RX_DESC_DEFAULT;
+       uint16_t nb_txd = RTE_TX_DESC_DEFAULT;
 
        if (portid >= rte_eth_dev_count())
                rte_exit(EXIT_FAILURE, "Invalid port\n");
@@ -186,8 +188,13 @@ slave_port_init(uint8_t portid, struct rte_mempool *mbuf_pool)
                rte_exit(EXIT_FAILURE, "port %u: configuration failed (res=%d)\n",
                                portid, retval);
 
+       retval = rte_eth_dev_adjust_nb_rx_tx_desc(portid, &nb_rxd, &nb_txd);
+       if (retval != 0)
+               rte_exit(EXIT_FAILURE, "port %u: rte_eth_dev_adjust_nb_rx_tx_desc "
+                               "failed (res=%d)\n", portid, retval);
+
        /* RX setup */
-       retval = rte_eth_rx_queue_setup(portid, 0, RTE_RX_DESC_DEFAULT,
+       retval = rte_eth_rx_queue_setup(portid, 0, nb_rxd,
                                        rte_eth_dev_socket_id(portid), NULL,
                                        mbuf_pool);
        if (retval < 0)
@@ -195,7 +202,7 @@ slave_port_init(uint8_t portid, struct rte_mempool *mbuf_pool)
                                portid, retval);
 
        /* TX setup */
-       retval = rte_eth_tx_queue_setup(portid, 0, RTE_TX_DESC_DEFAULT,
+       retval = rte_eth_tx_queue_setup(portid, 0, nb_txd,
                                rte_eth_dev_socket_id(portid), NULL);
 
        if (retval < 0)
@@ -221,6 +228,8 @@ bond_port_init(struct rte_mempool *mbuf_pool)
 {
        int retval;
        uint8_t i;
+       uint16_t nb_rxd = RTE_RX_DESC_DEFAULT;
+       uint16_t nb_txd = RTE_TX_DESC_DEFAULT;
 
        retval = rte_eth_bond_create("bond0", BONDING_MODE_ALB,
                        0 /*SOCKET_ID_ANY*/);
@@ -235,8 +244,13 @@ bond_port_init(struct rte_mempool *mbuf_pool)
                rte_exit(EXIT_FAILURE, "port %u: configuration failed (res=%d)\n",
                                BOND_PORT, retval);
 
+       retval = rte_eth_dev_adjust_nb_rx_tx_desc(BOND_PORT, &nb_rxd, &nb_txd);
+       if (retval != 0)
+               rte_exit(EXIT_FAILURE, "port %u: rte_eth_dev_adjust_nb_rx_tx_desc "
+                               "failed (res=%d)\n", BOND_PORT, retval);
+
        /* RX setup */
-       retval = rte_eth_rx_queue_setup(BOND_PORT, 0, RTE_RX_DESC_DEFAULT,
+       retval = rte_eth_rx_queue_setup(BOND_PORT, 0, nb_rxd,
                                        rte_eth_dev_socket_id(BOND_PORT), NULL,
                                        mbuf_pool);
        if (retval < 0)
@@ -244,7 +258,7 @@ bond_port_init(struct rte_mempool *mbuf_pool)
                                BOND_PORT, retval);
 
        /* TX setup */
-       retval = rte_eth_tx_queue_setup(BOND_PORT, 0, RTE_TX_DESC_DEFAULT,
+       retval = rte_eth_tx_queue_setup(BOND_PORT, 0, nb_txd,
                                rte_eth_dev_socket_id(BOND_PORT), NULL);
 
        if (retval < 0)
index cf8982a..87603d0 100644 (file)
@@ -138,6 +138,8 @@ port_init(uint8_t port, struct rte_mempool *mbuf_pool)
        const uint16_t rxRings = 1, txRings = rte_lcore_count() - 1;
        int retval;
        uint16_t q;
+       uint16_t nb_rxd = RX_RING_SIZE;
+       uint16_t nb_txd = TX_RING_SIZE;
 
        if (port >= rte_eth_dev_count())
                return -1;
@@ -146,8 +148,12 @@ port_init(uint8_t port, struct rte_mempool *mbuf_pool)
        if (retval != 0)
                return retval;
 
+       retval = rte_eth_dev_adjust_nb_rx_tx_desc(port, &nb_rxd, &nb_txd);
+       if (retval != 0)
+               return retval;
+
        for (q = 0; q < rxRings; q++) {
-               retval = rte_eth_rx_queue_setup(port, q, RX_RING_SIZE,
+               retval = rte_eth_rx_queue_setup(port, q, nb_rxd,
                                                rte_eth_dev_socket_id(port),
                                                NULL, mbuf_pool);
                if (retval < 0)
@@ -155,7 +161,7 @@ port_init(uint8_t port, struct rte_mempool *mbuf_pool)
        }
 
        for (q = 0; q < txRings; q++) {
-               retval = rte_eth_tx_queue_setup(port, q, TX_RING_SIZE,
+               retval = rte_eth_tx_queue_setup(port, q, nb_txd,
                                                rte_eth_dev_socket_id(port),
                                                NULL);
                if (retval < 0)
index f79b962..bbab2f6 100644 (file)
@@ -122,6 +122,8 @@ static void setup_ports(struct app_config *app_cfg, int cnt_ports)
        struct rte_eth_conf cfg_port;
        struct rte_eth_dev_info dev_info;
        char str_name[16];
+       uint16_t nb_rxd = PORT_RX_QUEUE_SIZE;
+       uint16_t nb_txd = PORT_TX_QUEUE_SIZE;
 
        memset(&cfg_port, 0, sizeof(cfg_port));
        cfg_port.txmode.mq_mode = ETH_MQ_TX_NONE;
@@ -154,15 +156,19 @@ static void setup_ports(struct app_config *app_cfg, int cnt_ports)
                if (rte_eth_dev_configure(idx_port, 1, 1, &cfg_port) < 0)
                        rte_exit(EXIT_FAILURE,
                                 "rte_eth_dev_configure failed");
+               if (rte_eth_dev_adjust_nb_rx_tx_desc(idx_port, &nb_rxd,
+                                                    &nb_txd) < 0)
+                       rte_exit(EXIT_FAILURE,
+                                "rte_eth_dev_adjust_nb_rx_tx_desc failed");
                if (rte_eth_rx_queue_setup(
-                           idx_port, 0, PORT_RX_QUEUE_SIZE,
+                           idx_port, 0, nb_rxd,
                            rte_eth_dev_socket_id(idx_port), NULL,
                            ptr_port->pkt_pool) < 0)
                        rte_exit(EXIT_FAILURE,
                                 "rte_eth_rx_queue_setup failed"
                                );
                if (rte_eth_tx_queue_setup(
-                           idx_port, 0, PORT_TX_QUEUE_SIZE,
+                           idx_port, 0, nb_txd,
                            rte_eth_dev_socket_id(idx_port), NULL) < 0)
                        rte_exit(EXIT_FAILURE,
                                 "rte_eth_tx_queue_setup failed"
index fe30e07..229b7de 100644 (file)
@@ -448,6 +448,8 @@ static void
 init_port(uint8_t port)
 {
        int ret;
+       uint16_t nb_rxd = NB_RXD;
+       uint16_t nb_txd = NB_TXD;
 
        /* Initialise device and RX/TX queues */
        PRINT_INFO("Initialising port %u ...", (unsigned)port);
@@ -457,14 +459,21 @@ init_port(uint8_t port)
                FATAL_ERROR("Could not configure port%u (%d)",
                            (unsigned)port, ret);
 
-       ret = rte_eth_rx_queue_setup(port, 0, NB_RXD, rte_eth_dev_socket_id(port),
+       ret = rte_eth_dev_adjust_nb_rx_tx_desc(port, &nb_rxd, &nb_txd);
+       if (ret < 0)
+               FATAL_ERROR("Could not adjust number of descriptors for port%u (%d)",
+                           (unsigned)port, ret);
+
+       ret = rte_eth_rx_queue_setup(port, 0, nb_rxd,
+                               rte_eth_dev_socket_id(port),
                                NULL,
                                pktmbuf_pool);
        if (ret < 0)
                FATAL_ERROR("Could not setup up RX queue for port%u (%d)",
                            (unsigned)port, ret);
 
-       ret = rte_eth_tx_queue_setup(port, 0, NB_TXD, rte_eth_dev_socket_id(port),
+       ret = rte_eth_tx_queue_setup(port, 0, nb_txd,
+                               rte_eth_dev_socket_id(port),
                                NULL);
        if (ret < 0)
                FATAL_ERROR("Could not setup up TX queue for port%u (%d)",
index 654b315..00aefc7 100644 (file)
@@ -960,6 +960,14 @@ main(int argc, char **argv)
                                ret, portid);
                }
 
+               ret = rte_eth_dev_adjust_nb_rx_tx_desc(portid, &nb_rxd,
+                                           &nb_txd);
+               if (ret < 0) {
+                       printf("\n");
+                       rte_exit(EXIT_FAILURE, "Cannot adjust number of "
+                               "descriptors: err=%d, port=%d\n", ret, portid);
+               }
+
                /* init one RX queue */
                ret = rte_eth_rx_queue_setup(portid, 0, nb_rxd,
                                             socket, NULL,
index be148fc..7cde49a 100644 (file)
@@ -1003,16 +1003,30 @@ app_init_link(struct app_params *app)
                        struct app_pktq_hwq_in_params *p_rxq =
                                &app->hwq_in_params[j];
                        uint32_t rxq_link_id, rxq_queue_id;
+                       uint16_t nb_rxd = p_rxq->size;
 
                        sscanf(p_rxq->name, "RXQ%" PRIu32 ".%" PRIu32,
                                &rxq_link_id, &rxq_queue_id);
                        if (rxq_link_id != link_id)
                                continue;
 
+                       status = rte_eth_dev_adjust_nb_rx_tx_desc(
+                               p_link->pmd_id,
+                               &nb_rxd,
+                               NULL);
+                       if (status < 0)
+                               rte_panic("%s (%" PRIu32 "): "
+                                       "%s adjust number of Rx descriptors "
+                                       "error (%" PRId32 ")\n",
+                                       p_link->name,
+                                       p_link->pmd_id,
+                                       p_rxq->name,
+                                       status);
+
                        status = rte_eth_rx_queue_setup(
                                p_link->pmd_id,
                                rxq_queue_id,
-                               p_rxq->size,
+                               nb_rxd,
                                app_get_cpu_socket_id(p_link->pmd_id),
                                &p_rxq->conf,
                                app->mempool[p_rxq->mempool_id]);
@@ -1030,16 +1044,30 @@ app_init_link(struct app_params *app)
                        struct app_pktq_hwq_out_params *p_txq =
                                &app->hwq_out_params[j];
                        uint32_t txq_link_id, txq_queue_id;
+                       uint16_t nb_txd = p_txq->size;
 
                        sscanf(p_txq->name, "TXQ%" PRIu32 ".%" PRIu32,
                                &txq_link_id, &txq_queue_id);
                        if (txq_link_id != link_id)
                                continue;
 
+                       status = rte_eth_dev_adjust_nb_rx_tx_desc(
+                               p_link->pmd_id,
+                               NULL,
+                               &nb_txd);
+                       if (status < 0)
+                               rte_panic("%s (%" PRIu32 "): "
+                                       "%s adjust number of Tx descriptors "
+                                       "error (%" PRId32 ")\n",
+                                       p_link->name,
+                                       p_link->pmd_id,
+                                       p_txq->name,
+                                       status);
+
                        status = rte_eth_tx_queue_setup(
                                p_link->pmd_id,
                                txq_queue_id,
-                               p_txq->size,
+                               nb_txd,
                                app_get_cpu_socket_id(p_link->pmd_id),
                                &p_txq->conf);
                        if (status < 0)
index c0f3ced..4032a69 100644 (file)
@@ -904,7 +904,7 @@ setup_queue_tbl(struct rx_queue *rxq, uint32_t lcore, uint32_t queue)
        nb_mbuf = RTE_MAX(max_flow_num, 2UL * MAX_PKT_BURST) * MAX_FRAG_NUM;
        nb_mbuf *= (port_conf.rxmode.max_rx_pkt_len + BUF_SIZE - 1) / BUF_SIZE;
        nb_mbuf *= 2; /* ipv4 and ipv6 */
-       nb_mbuf += RTE_TEST_RX_DESC_DEFAULT + RTE_TEST_TX_DESC_DEFAULT;
+       nb_mbuf += nb_rxd + nb_txd;
 
        nb_mbuf = RTE_MAX(nb_mbuf, (uint32_t)NB_MBUF);
 
@@ -1088,6 +1088,14 @@ main(int argc, char **argv)
                rxq->portid = portid;
                rxq->lpm = socket_lpm[socket];
                rxq->lpm6 = socket_lpm6[socket];
+
+               ret = rte_eth_dev_adjust_nb_rx_tx_desc(portid, &nb_rxd,
+                                                      &nb_txd);
+               if (ret < 0)
+                       rte_exit(EXIT_FAILURE,
+                                "Cannot adjust number of descriptors: err=%d, port=%d\n",
+                                ret, portid);
+
                if (setup_queue_tbl(rxq, rx_lcore_id, queueid) < 0)
                        rte_exit(EXIT_FAILURE, "Failed to set up queue table\n");
                qconf->n_rx_queue++;
index 11f0966..99dc270 100644 (file)
@@ -1363,6 +1363,11 @@ port_init(uint8_t portid)
                rte_exit(EXIT_FAILURE, "Cannot configure device: "
                                "err=%d, port=%d\n", ret, portid);
 
+       ret = rte_eth_dev_adjust_nb_rx_tx_desc(portid, &nb_rxd, &nb_txd);
+       if (ret < 0)
+               rte_exit(EXIT_FAILURE, "Cannot adjust number of descriptors: "
+                               "err=%d, port=%d\n", ret, portid);
+
        /* init one TX queue per lcore */
        tx_queueid = 0;
        for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {
index 96a4ab6..ba4ab09 100644 (file)
@@ -757,6 +757,13 @@ main(int argc, char **argv)
                        rte_exit(EXIT_FAILURE, "Cannot configure device: err=%d, port=%d\n",
                                  ret, portid);
 
+               ret = rte_eth_dev_adjust_nb_rx_tx_desc(portid, &nb_rxd,
+                                                      &nb_txd);
+               if (ret < 0)
+                       rte_exit(EXIT_FAILURE,
+                                "Cannot adjust number of descriptors: err=%d, port=%d\n",
+                                ret, portid);
+
                rte_eth_macaddr_get(portid, &ports_eth_addr[portid]);
                print_ethaddr(" Address:", &ports_eth_addr[portid]);
                printf(", ");
index 0be57d8..dd6c0c3 100644 (file)
@@ -605,6 +605,8 @@ static void
 init_port(uint8_t port)
 {
        int ret;
+       uint16_t nb_rxd = NB_RXD;
+       uint16_t nb_txd = NB_TXD;
 
        /* Initialise device and RX/TX queues */
        RTE_LOG(INFO, APP, "Initialising port %u ...\n", (unsigned)port);
@@ -614,13 +616,18 @@ init_port(uint8_t port)
                rte_exit(EXIT_FAILURE, "Could not configure port%u (%d)\n",
                            (unsigned)port, ret);
 
-       ret = rte_eth_rx_queue_setup(port, 0, NB_RXD,
+       ret = rte_eth_dev_adjust_nb_rx_tx_desc(port, &nb_rxd, &nb_txd);
+       if (ret < 0)
+               rte_exit(EXIT_FAILURE, "Could not adjust number of descriptors "
+                               "for port%u (%d)\n", (unsigned)port, ret);
+
+       ret = rte_eth_rx_queue_setup(port, 0, nb_rxd,
                rte_eth_dev_socket_id(port), NULL, pktmbuf_pool);
        if (ret < 0)
                rte_exit(EXIT_FAILURE, "Could not setup up RX queue for "
                                "port%u (%d)\n", (unsigned)port, ret);
 
-       ret = rte_eth_tx_queue_setup(port, 0, NB_TXD,
+       ret = rte_eth_tx_queue_setup(port, 0, nb_txd,
                rte_eth_dev_socket_id(port), NULL);
        if (ret < 0)
                rte_exit(EXIT_FAILURE, "Could not setup up TX queue for "
index 8cce33b..c293bd9 100644 (file)
@@ -65,6 +65,8 @@ port_init(uint8_t port, struct rte_mempool *mbuf_pool)
        const uint16_t rx_rings = 1, tx_rings = 1;
        int retval;
        uint16_t q;
+       uint16_t nb_rxd = RX_RING_SIZE;
+       uint16_t nb_txd = TX_RING_SIZE;
 
        if (port >= rte_eth_dev_count())
                return -1;
@@ -74,9 +76,13 @@ port_init(uint8_t port, struct rte_mempool *mbuf_pool)
        if (retval != 0)
                return retval;
 
+       retval = rte_eth_dev_adjust_nb_rx_tx_desc(port, &nb_rxd, &nb_txd);
+       if (retval != 0)
+               return retval;
+
        /* Allocate and set up 1 RX queue per Ethernet port. */
        for (q = 0; q < rx_rings; q++) {
-               retval = rte_eth_rx_queue_setup(port, q, RX_RING_SIZE,
+               retval = rte_eth_rx_queue_setup(port, q, nb_rxd,
                                rte_eth_dev_socket_id(port), NULL, mbuf_pool);
                if (retval < 0)
                        return retval;
@@ -84,7 +90,7 @@ port_init(uint8_t port, struct rte_mempool *mbuf_pool)
 
        /* Allocate and set up 1 TX queue per Ethernet port. */
        for (q = 0; q < tx_rings; q++) {
-               retval = rte_eth_tx_queue_setup(port, q, TX_RING_SIZE,
+               retval = rte_eth_tx_queue_setup(port, q, nb_txd,
                                rte_eth_dev_socket_id(port), NULL);
                if (retval < 0)
                        return retval;
index 2a71feb..71cb133 100644 (file)
@@ -2297,6 +2297,14 @@ initialize_ports(struct l2fwd_crypto_options *options)
                        return -1;
                }
 
+               retval = rte_eth_dev_adjust_nb_rx_tx_desc(portid, &nb_rxd,
+                                                         &nb_txd);
+               if (retval < 0) {
+                       printf("Cannot adjust number of descriptors: err=%d, port=%u\n",
+                               retval, (unsigned) portid);
+                       return -1;
+               }
+
                /* init one RX queue */
                fflush(stdout);
                retval = rte_eth_rx_queue_setup(portid, 0, nb_rxd,
index d21e833..0fdfaa4 100644 (file)
@@ -884,6 +884,13 @@ main(int argc, char **argv)
                        rte_exit(EXIT_FAILURE, "Cannot configure device: err=%d, port=%u\n",
                                  ret, (unsigned) portid);
 
+               ret = rte_eth_dev_adjust_nb_rx_tx_desc(portid, &nb_rxd,
+                                                      &nb_txd);
+               if (ret < 0)
+                       rte_exit(EXIT_FAILURE,
+                                "Cannot adjust number of descriptors: err=%d, port=%u\n",
+                                ret, (unsigned) portid);
+
                rte_eth_macaddr_get(portid, &l2fwd_ports_eth_addr[portid]);
 
                /* init one RX queue */
index 3745348..3c6a9d3 100644 (file)
@@ -677,6 +677,13 @@ main(int argc, char **argv)
                                "Cannot configure device: err=%d, port=%u\n",
                                ret, (unsigned) portid);
 
+               ret = rte_eth_dev_adjust_nb_rx_tx_desc(portid, &nb_rxd,
+                                                      &nb_txd);
+               if (ret < 0)
+                       rte_exit(EXIT_FAILURE,
+                               "Cannot adjust number of descriptors: err=%d, port=%u\n",
+                               ret, (unsigned) portid);
+
                rte_eth_macaddr_get(portid, &l2fwd_ports_eth_addr[portid]);
 
                /* init one RX queue */
index f966727..00759b9 100644 (file)
@@ -666,6 +666,13 @@ main(int argc, char **argv)
                        rte_exit(EXIT_FAILURE, "Cannot configure device: err=%d, port=%u\n",
                                  ret, (unsigned) portid);
 
+               ret = rte_eth_dev_adjust_nb_rx_tx_desc(portid, &nb_rxd,
+                                                      &nb_txd);
+               if (ret < 0)
+                       rte_exit(EXIT_FAILURE,
+                                "Cannot adjust number of descriptors: err=%d, port=%u\n",
+                                ret, (unsigned) portid);
+
                rte_eth_macaddr_get(portid,&l2fwd_ports_eth_addr[portid]);
 
                /* init one RX queue */
index ea0b5b1..1563884 100644 (file)
  */
 
 #define NB_MBUF        RTE_MAX(\
-       (nb_ports * nb_rx_queue*RTE_TEST_RX_DESC_DEFAULT +      \
-       nb_ports * nb_lcores * MAX_PKT_BURST +                  \
-       nb_ports * n_tx_queue * RTE_TEST_TX_DESC_DEFAULT +      \
-       nb_lcores * MEMPOOL_CACHE_SIZE),                        \
+       (nb_ports * nb_rx_queue * nb_rxd +      \
+       nb_ports * nb_lcores * MAX_PKT_BURST +  \
+       nb_ports * n_tx_queue * nb_txd +        \
+       nb_lcores * MEMPOOL_CACHE_SIZE),        \
        (unsigned)8192)
 
 #define MAX_PKT_BURST 32
@@ -1951,6 +1951,13 @@ main(int argc, char **argv)
                                "Cannot configure device: err=%d, port=%d\n",
                                ret, portid);
 
+               ret = rte_eth_dev_adjust_nb_rx_tx_desc(portid, &nb_rxd,
+                                                      &nb_txd);
+               if (ret < 0)
+                       rte_exit(EXIT_FAILURE,
+                               "rte_eth_dev_adjust_nb_rx_tx_desc: err=%d, port=%d\n",
+                               ret, portid);
+
                rte_eth_macaddr_get(portid, &ports_eth_addr[portid]);
                print_ethaddr(" Address:", &ports_eth_addr[portid]);
                printf(", ");
index 52eb835..bfd1ce0 100644 (file)
  */
 
 #define NB_MBUF RTE_MAX        ( \
-       (nb_ports*nb_rx_queue*RTE_TEST_RX_DESC_DEFAULT + \
+       (nb_ports*nb_rx_queue*nb_rxd + \
        nb_ports*nb_lcores*MAX_PKT_BURST + \
-       nb_ports*n_tx_queue*RTE_TEST_TX_DESC_DEFAULT + \
+       nb_ports*n_tx_queue*nb_txd + \
        nb_lcores*MEMPOOL_CACHE_SIZE), \
        (unsigned)8192)
 
@@ -1726,6 +1726,13 @@ main(int argc, char **argv)
                        rte_exit(EXIT_FAILURE, "Cannot configure device: "
                                        "err=%d, port=%d\n", ret, portid);
 
+               ret = rte_eth_dev_adjust_nb_rx_tx_desc(portid, &nb_rxd,
+                                                      &nb_txd);
+               if (ret < 0)
+                       rte_exit(EXIT_FAILURE,
+                                "Cannot adjust number of descriptors: err=%d, port=%d\n",
+                                ret, portid);
+
                rte_eth_macaddr_get(portid, &ports_eth_addr[portid]);
                print_ethaddr(" Address:", &ports_eth_addr[portid]);
                printf(", ");
index 5ac30b7..fcd83b8 100644 (file)
  *  RTE_MAX is used to ensure that NB_MBUF never goes below a minimum value of 8192
  */
 
-#define NB_MBUF RTE_MAX        (                                                                                                                                       \
-                               (nb_ports*nb_rx_queue*RTE_TEST_RX_DESC_DEFAULT +                                                        \
-                               nb_ports*nb_lcores*MAX_PKT_BURST +                                                                                      \
-                               nb_ports*n_tx_queue*RTE_TEST_TX_DESC_DEFAULT +                                                          \
-                               nb_lcores*MEMPOOL_CACHE_SIZE),                                                                                          \
+#define NB_MBUF RTE_MAX        (                                               \
+                               (nb_ports*nb_rx_queue*nb_rxd +          \
+                               nb_ports*nb_lcores*MAX_PKT_BURST +      \
+                               nb_ports*n_tx_queue*nb_txd +            \
+                               nb_lcores*MEMPOOL_CACHE_SIZE),          \
                                (unsigned)8192)
 
 /*
@@ -1010,6 +1010,13 @@ main(int argc, char **argv)
                        rte_exit(EXIT_FAILURE, "Cannot configure device: err=%d, port=%d\n",
                                ret, portid);
 
+               ret = rte_eth_dev_adjust_nb_rx_tx_desc(portid, &nb_rxd,
+                                                      &nb_txd);
+               if (ret < 0)
+                       rte_exit(EXIT_FAILURE,
+                                "Cannot adjust number of descriptors: err=%d, port=%d\n",
+                                ret, portid);
+
                rte_eth_macaddr_get(portid, &ports_eth_addr[portid]);
                print_ethaddr(" Address:", &ports_eth_addr[portid]);
                printf(", ");
index fd6605b..7094197 100644 (file)
@@ -522,10 +522,10 @@ static const struct option lgopts[] = {
  * value of 8192
  */
 #define NB_MBUF RTE_MAX(       \
-       (nb_ports*nb_rx_queue*RTE_TEST_RX_DESC_DEFAULT +        \
-       nb_ports*nb_lcores*MAX_PKT_BURST +                      \
-       nb_ports*n_tx_queue*RTE_TEST_TX_DESC_DEFAULT +          \
-       nb_lcores*MEMPOOL_CACHE_SIZE),                          \
+       (nb_ports*nb_rx_queue*nb_rxd +          \
+       nb_ports*nb_lcores*MAX_PKT_BURST +      \
+       nb_ports*n_tx_queue*nb_txd +            \
+       nb_lcores*MEMPOOL_CACHE_SIZE),          \
        (unsigned)8192)
 
 /* Parse the argument given in the command line of the application */
@@ -918,6 +918,13 @@ main(int argc, char **argv)
                                "Cannot configure device: err=%d, port=%d\n",
                                ret, portid);
 
+               ret = rte_eth_dev_adjust_nb_rx_tx_desc(portid, &nb_rxd,
+                                                      &nb_txd);
+               if (ret < 0)
+                       rte_exit(EXIT_FAILURE,
+                                "Cannot adjust number of descriptors: err=%d, "
+                                "port=%d\n", ret, portid);
+
                rte_eth_macaddr_get(portid, &ports_eth_addr[portid]);
                print_ethaddr(" Address:", &ports_eth_addr[portid]);
                printf(", ");
index d585789..0eab042 100644 (file)
@@ -650,6 +650,13 @@ main(int argc, char **argv)
                        rte_exit(EXIT_FAILURE, "Cannot configure device: err=%d, port=%u\n",
                                  ret, (unsigned) portid);
 
+               ret = rte_eth_dev_adjust_nb_rx_tx_desc(portid, &nb_rxd,
+                                                      &nb_txd);
+               if (ret < 0)
+                       rte_exit(EXIT_FAILURE,
+                                "rte_eth_dev_adjust_nb_rx_tx_desc: err=%d, port=%u\n",
+                                ret, (unsigned) portid);
+
                /* register lsi interrupt callback, need to be after
                 * rte_eth_dev_configure(). if (intr_conf.lsc == 0), no
                 * lsc interrupt will be present, and below callback to
index abd05a3..8fe7db4 100644 (file)
@@ -430,6 +430,8 @@ app_init_nics(void)
        /* Init NIC ports and queues, then start the ports */
        for (port = 0; port < APP_MAX_NIC_PORTS; port ++) {
                struct rte_mempool *pool;
+               uint16_t nic_rx_ring_size;
+               uint16_t nic_tx_ring_size;
 
                n_rx_queues = app_get_nic_rx_queues_per_port(port);
                n_tx_queues = app.nic_tx_port_mask[port];
@@ -450,6 +452,17 @@ app_init_nics(void)
                }
                rte_eth_promiscuous_enable(port);
 
+               nic_rx_ring_size = app.nic_rx_ring_size;
+               nic_tx_ring_size = app.nic_tx_ring_size;
+               ret = rte_eth_dev_adjust_nb_rx_tx_desc(
+                       port, &nic_rx_ring_size, &nic_tx_ring_size);
+               if (ret < 0) {
+                       rte_panic("Cannot adjust number of descriptors for port %u (%d)\n",
+                               (unsigned) port, ret);
+               }
+               app.nic_rx_ring_size = nic_rx_ring_size;
+               app.nic_tx_ring_size = nic_tx_ring_size;
+
                /* Init RX queues */
                for (queue = 0; queue < APP_MAX_RX_QUEUES_PER_NIC_PORT; queue ++) {
                        if (app.nic_rx_queue_mask[port][queue] == 0) {
index ad941a7..0bc9292 100644 (file)
@@ -123,8 +123,8 @@ init_port(uint8_t port_num)
                }
        };
        const uint16_t rx_rings = 1, tx_rings = num_clients;
-       const uint16_t rx_ring_size = RTE_MP_RX_DESC_DEFAULT;
-       const uint16_t tx_ring_size = RTE_MP_TX_DESC_DEFAULT;
+       uint16_t rx_ring_size = RTE_MP_RX_DESC_DEFAULT;
+       uint16_t tx_ring_size = RTE_MP_TX_DESC_DEFAULT;
 
        uint16_t q;
        int retval;
@@ -138,6 +138,11 @@ init_port(uint8_t port_num)
                &port_conf)) != 0)
                return retval;
 
+       retval = rte_eth_dev_adjust_nb_rx_tx_desc(port_num, &rx_ring_size,
+                       &tx_ring_size);
+       if (retval != 0)
+               return retval;
+
        for (q = 0; q < rx_rings; q++) {
                retval = rte_eth_rx_queue_setup(port_num, q, rx_ring_size,
                                rte_eth_dev_socket_id(port_num),
index 59c1024..9ef9a7b 100644 (file)
@@ -1080,6 +1080,13 @@ main(int argc, char **argv)
                        rte_exit(EXIT_FAILURE, "Cannot configure device: err=%d, port=%u\n",
                                  ret, (unsigned) portid);
 
+               ret = rte_eth_dev_adjust_nb_rx_tx_desc(portid, &nb_rxd,
+                                                      &nb_txd);
+               if (ret < 0)
+                       rte_exit(EXIT_FAILURE,
+                                "rte_eth_dev_adjust_nb_rx_tx_desc: err=%d, port=%u\n",
+                                ret, (unsigned) portid);
+
                rte_eth_macaddr_get(portid,&l2fwd_ports_eth_addr[portid]);
 
                /* init one RX queue */
index 0990d96..208e356 100644 (file)
@@ -229,6 +229,8 @@ smp_port_init(uint8_t port, struct rte_mempool *mbuf_pool, uint16_t num_queues)
        struct rte_eth_dev_info info;
        int retval;
        uint16_t q;
+       uint16_t nb_rxd = RX_RING_SIZE;
+       uint16_t nb_txd = TX_RING_SIZE;
 
        if (rte_eal_process_type() == RTE_PROC_SECONDARY)
                return 0;
@@ -246,8 +248,12 @@ smp_port_init(uint8_t port, struct rte_mempool *mbuf_pool, uint16_t num_queues)
        if (retval < 0)
                return retval;
 
+       retval = rte_eth_dev_adjust_nb_rx_tx_desc(port, &nb_rxd, &nb_txd);
+       if (retval < 0)
+               return retval;
+
        for (q = 0; q < rx_rings; q ++) {
-               retval = rte_eth_rx_queue_setup(port, q, RX_RING_SIZE,
+               retval = rte_eth_rx_queue_setup(port, q, nb_rxd,
                                rte_eth_dev_socket_id(port),
                                &info.default_rxconf,
                                mbuf_pool);
@@ -256,7 +262,7 @@ smp_port_init(uint8_t port, struct rte_mempool *mbuf_pool, uint16_t num_queues)
        }
 
        for (q = 0; q < tx_rings; q ++) {
-               retval = rte_eth_tx_queue_setup(port, q, TX_RING_SIZE,
+               retval = rte_eth_tx_queue_setup(port, q, nb_txd,
                                rte_eth_dev_socket_id(port),
                                NULL);
                if (retval < 0)
index d9b4051..af2d9f3 100644 (file)
@@ -719,6 +719,15 @@ rte_netmap_init_port(uint8_t portid, const struct rte_netmap_port_conf *conf)
            return ret;
        }
 
+       ret = rte_eth_dev_adjust_nb_rx_tx_desc(portid, &rx_slots, &tx_slots);
+
+       if (ret < 0) {
+               RTE_LOG(ERR, USER1,
+                       "Couldn't ot adjust number of descriptors for port %hhu\n",
+                       portid);
+               return ret;
+       }
+
        for (i = 0; i < conf->nr_tx_rings; i++) {
                ret = rte_eth_tx_queue_setup(portid, i, tx_slots,
                        conf->socket_id, NULL);
index 49ae35b..b26c33d 100644 (file)
@@ -290,6 +290,8 @@ configure_eth_port(uint8_t port_id)
        const uint8_t nb_ports = rte_eth_dev_count();
        int ret;
        uint16_t q;
+       uint16_t nb_rxd = RX_DESC_PER_QUEUE;
+       uint16_t nb_txd = TX_DESC_PER_QUEUE;
 
        if (port_id > nb_ports)
                return -1;
@@ -298,8 +300,12 @@ configure_eth_port(uint8_t port_id)
        if (ret != 0)
                return ret;
 
+       ret = rte_eth_dev_adjust_nb_rx_tx_desc(port_id, &nb_rxd, &nb_txd);
+       if (ret != 0)
+               return ret;
+
        for (q = 0; q < rxRings; q++) {
-               ret = rte_eth_rx_queue_setup(port_id, q, RX_DESC_PER_QUEUE,
+               ret = rte_eth_rx_queue_setup(port_id, q, nb_rxd,
                                rte_eth_dev_socket_id(port_id), NULL,
                                mbuf_pool);
                if (ret < 0)
@@ -307,7 +313,7 @@ configure_eth_port(uint8_t port_id)
        }
 
        for (q = 0; q < txRings; q++) {
-               ret = rte_eth_tx_queue_setup(port_id, q, TX_DESC_PER_QUEUE,
+               ret = rte_eth_tx_queue_setup(port_id, q, nb_txd,
                                rte_eth_dev_socket_id(port_id), NULL);
                if (ret < 0)
                        return ret;
index 2d28a0f..c790ff9 100644 (file)
@@ -185,10 +185,10 @@ cb_parse_ptype(__rte_unused uint8_t port, __rte_unused uint16_t queue,
  */
 
 #define NB_MBUF RTE_MAX(\
-               (nb_ports*nb_rx_queue*RTE_TEST_RX_DESC_DEFAULT +       \
-               nb_ports*nb_lcores*MAX_PKT_BURST +                     \
-               nb_ports*n_tx_queue*RTE_TEST_TX_DESC_DEFAULT +         \
-               nb_lcores*MEMPOOL_CACHE_SIZE),                         \
+               (nb_ports*nb_rx_queue*nb_rxd +      \
+               nb_ports*nb_lcores*MAX_PKT_BURST +  \
+               nb_ports*n_tx_queue*nb_txd +        \
+               nb_lcores*MEMPOOL_CACHE_SIZE),      \
                (unsigned)8192)
 
 #define MAX_PKT_BURST     32
@@ -3571,6 +3571,13 @@ main(int argc, char **argv)
                        rte_exit(EXIT_FAILURE, "Cannot configure device: err=%d, port=%d\n",
                                ret, portid);
 
+               ret = rte_eth_dev_adjust_nb_rx_tx_desc(portid, &nb_rxd,
+                                                      &nb_txd);
+               if (ret < 0)
+                       rte_exit(EXIT_FAILURE,
+                                "rte_eth_dev_adjust_nb_rx_tx_desc: err=%d, port=%d\n",
+                                ret, portid);
+
                rte_eth_macaddr_get(portid, &ports_eth_addr[portid]);
                print_ethaddr(" Address:", &ports_eth_addr[portid]);
                printf(", ");
index a80961d..ddfcdb8 100644 (file)
@@ -210,6 +210,8 @@ port_init(uint8_t port, struct rte_mempool *mbuf_pool)
        const uint16_t tx_rings = 1;
        int retval;
        uint16_t q;
+       uint16_t nb_rxd = RX_RING_SIZE;
+       uint16_t nb_txd = TX_RING_SIZE;
 
        if (port >= rte_eth_dev_count())
                return -1;
@@ -219,9 +221,13 @@ port_init(uint8_t port, struct rte_mempool *mbuf_pool)
        if (retval != 0)
                return retval;
 
+       retval = rte_eth_dev_adjust_nb_rx_tx_desc(port, &nb_rxd, &nb_txd);
+       if (retval != 0)
+               return retval;
+
        /* Allocate and set up 1 RX queue per Ethernet port. */
        for (q = 0; q < rx_rings; q++) {
-               retval = rte_eth_rx_queue_setup(port, q, RX_RING_SIZE,
+               retval = rte_eth_rx_queue_setup(port, q, nb_rxd,
                                rte_eth_dev_socket_id(port), NULL, mbuf_pool);
 
                if (retval < 0)
@@ -237,7 +243,7 @@ port_init(uint8_t port, struct rte_mempool *mbuf_pool)
                txconf = &dev_info.default_txconf;
                txconf->txq_flags = 0;
 
-               retval = rte_eth_tx_queue_setup(port, q, TX_RING_SIZE,
+               retval = rte_eth_tx_queue_setup(port, q, nb_txd,
                                rte_eth_dev_socket_id(port), txconf);
                if (retval < 0)
                        return retval;
index d8a2107..b0909f6 100644 (file)
@@ -308,6 +308,8 @@ int
 main(int argc, char **argv)
 {
        uint32_t lcore_id;
+       uint16_t nb_rxd = NIC_RX_QUEUE_DESC;
+       uint16_t nb_txd = NIC_TX_QUEUE_DESC;
        int ret;
 
        /* EAL init */
@@ -337,13 +339,18 @@ main(int argc, char **argv)
        if (ret < 0)
                rte_exit(EXIT_FAILURE, "Port %d configuration error (%d)\n", port_rx, ret);
 
-       ret = rte_eth_rx_queue_setup(port_rx, NIC_RX_QUEUE, NIC_RX_QUEUE_DESC,
+       ret = rte_eth_dev_adjust_nb_rx_tx_desc(port_rx, &nb_rxd, &nb_txd);
+       if (ret < 0)
+               rte_exit(EXIT_FAILURE, "Port %d adjust number of descriptors error (%d)\n",
+                               port_rx, ret);
+
+       ret = rte_eth_rx_queue_setup(port_rx, NIC_RX_QUEUE, nb_rxd,
                                rte_eth_dev_socket_id(port_rx),
                                NULL, pool);
        if (ret < 0)
                rte_exit(EXIT_FAILURE, "Port %d RX queue setup error (%d)\n", port_rx, ret);
 
-       ret = rte_eth_tx_queue_setup(port_rx, NIC_TX_QUEUE, NIC_TX_QUEUE_DESC,
+       ret = rte_eth_tx_queue_setup(port_rx, NIC_TX_QUEUE, nb_txd,
                                rte_eth_dev_socket_id(port_rx),
                                NULL);
        if (ret < 0)
@@ -353,13 +360,20 @@ main(int argc, char **argv)
        if (ret < 0)
                rte_exit(EXIT_FAILURE, "Port %d configuration error (%d)\n", port_tx, ret);
 
-       ret = rte_eth_rx_queue_setup(port_tx, NIC_RX_QUEUE, NIC_RX_QUEUE_DESC,
+       nb_rxd = NIC_RX_QUEUE_DESC;
+       nb_txd = NIC_TX_QUEUE_DESC;
+       ret = rte_eth_dev_adjust_nb_rx_tx_desc(port_tx, &nb_rxd, &nb_txd);
+       if (ret < 0)
+               rte_exit(EXIT_FAILURE, "Port %d adjust number of descriptors error (%d)\n",
+                               port_tx, ret);
+
+       ret = rte_eth_rx_queue_setup(port_tx, NIC_RX_QUEUE, nb_rxd,
                                rte_eth_dev_socket_id(port_tx),
                                NULL, pool);
        if (ret < 0)
                rte_exit(EXIT_FAILURE, "Port %d RX queue setup error (%d)\n", port_tx, ret);
 
-       ret = rte_eth_tx_queue_setup(port_tx, NIC_TX_QUEUE, NIC_TX_QUEUE_DESC,
+       ret = rte_eth_tx_queue_setup(port_tx, NIC_TX_QUEUE, nb_txd,
                                rte_eth_dev_socket_id(port_tx),
                                NULL);
        if (ret < 0)
index fe0221c..a82cbd7 100644 (file)
@@ -106,6 +106,8 @@ app_init_port(uint8_t portid, struct rte_mempool *mp)
        struct rte_eth_link link;
        struct rte_eth_rxconf rx_conf;
        struct rte_eth_txconf tx_conf;
+       uint16_t rx_size;
+       uint16_t tx_size;
 
        /* check if port already initialized (multistream configuration) */
        if (app_inited_port_mask & (1u << portid))
@@ -132,6 +134,15 @@ app_init_port(uint8_t portid, struct rte_mempool *mp)
                rte_exit(EXIT_FAILURE, "Cannot configure device: "
                                "err=%d, port=%"PRIu8"\n", ret, portid);
 
+       rx_size = ring_conf.rx_size;
+       tx_size = ring_conf.tx_size;
+       ret = rte_eth_dev_adjust_nb_rx_tx_desc(portid, &rx_size, &tx_size);
+       if (ret < 0)
+               rte_exit(EXIT_FAILURE, "rte_eth_dev_adjust_nb_rx_tx_desc: "
+                               "err=%d, port=%"PRIu8"\n", ret, portid);
+       ring_conf.rx_size = rx_size;
+       ring_conf.tx_size = tx_size;
+
        /* init one RX queue */
        fflush(stdout);
        ret = rte_eth_rx_queue_setup(portid, 0, (uint16_t)ring_conf.rx_size,
index b6264fc..083a37a 100644 (file)
@@ -76,6 +76,8 @@ static struct rte_eth_fc_conf fc_conf = {
 void configure_eth_port(uint8_t port_id)
 {
        int ret;
+       uint16_t nb_rxd = RX_DESC_PER_QUEUE;
+       uint16_t nb_txd = TX_DESC_PER_QUEUE;
 
        rte_eth_dev_stop(port_id);
 
@@ -84,8 +86,14 @@ void configure_eth_port(uint8_t port_id)
                rte_exit(EXIT_FAILURE, "Cannot configure port %u (error %d)\n",
                                (unsigned int) port_id, ret);
 
+       ret = rte_eth_dev_adjust_nb_rx_tx_desc(port_id, &nb_rxd, &nb_txd);
+       if (ret < 0)
+               rte_exit(EXIT_FAILURE,
+                               "Cannot adjust number of descriptors for port %u (error %d)\n",
+                               (unsigned int) port_id, ret);
+
        /* Initialize the port's RX queue */
-       ret = rte_eth_rx_queue_setup(port_id, 0, RX_DESC_PER_QUEUE,
+       ret = rte_eth_rx_queue_setup(port_id, 0, nb_rxd,
                        rte_eth_dev_socket_id(port_id),
                        NULL,
                        mbuf_pool);
@@ -95,7 +103,7 @@ void configure_eth_port(uint8_t port_id)
                                (unsigned int) port_id, ret);
 
        /* Initialize the port's TX queue */
-       ret = rte_eth_tx_queue_setup(port_id, 0, TX_DESC_PER_QUEUE,
+       ret = rte_eth_tx_queue_setup(port_id, 0, nb_txd,
                        rte_eth_dev_socket_id(port_id),
                        NULL);
        if (ret < 0)
index 048b23f..6699240 100644 (file)
@@ -101,6 +101,8 @@ port_init(uint8_t port, struct rte_mempool *mbuf_pool)
 {
        struct rte_eth_conf port_conf = port_conf_default;
        const uint16_t rx_rings = 1, tx_rings = 1;
+       uint16_t nb_rxd = RX_RING_SIZE;
+       uint16_t nb_txd = TX_RING_SIZE;
        int retval;
        uint16_t q;
 
@@ -111,15 +113,19 @@ port_init(uint8_t port, struct rte_mempool *mbuf_pool)
        if (retval != 0)
                return retval;
 
+       retval = rte_eth_dev_adjust_nb_rx_tx_desc(port, &nb_rxd, &nb_txd);
+       if (retval != 0)
+               return retval;
+
        for (q = 0; q < rx_rings; q++) {
-               retval = rte_eth_rx_queue_setup(port, q, RX_RING_SIZE,
+               retval = rte_eth_rx_queue_setup(port, q, nb_rxd,
                                rte_eth_dev_socket_id(port), NULL, mbuf_pool);
                if (retval < 0)
                        return retval;
        }
 
        for (q = 0; q < tx_rings; q++) {
-               retval = rte_eth_tx_queue_setup(port, q, TX_RING_SIZE,
+               retval = rte_eth_tx_queue_setup(port, q, nb_txd,
                                rte_eth_dev_socket_id(port), NULL);
                if (retval < 0)
                        return retval;
index 82457b4..d114e5b 100644 (file)
@@ -130,8 +130,8 @@ init_port(uint8_t port_num)
                }
        };
        const uint16_t rx_rings = 1, tx_rings = num_nodes;
-       const uint16_t rx_ring_size = RTE_MP_RX_DESC_DEFAULT;
-       const uint16_t tx_ring_size = RTE_MP_TX_DESC_DEFAULT;
+       uint16_t rx_ring_size = RTE_MP_RX_DESC_DEFAULT;
+       uint16_t tx_ring_size = RTE_MP_TX_DESC_DEFAULT;
 
        uint16_t q;
        int retval;
@@ -147,6 +147,11 @@ init_port(uint8_t port_num)
        if (retval != 0)
                return retval;
 
+       retval = rte_eth_dev_adjust_nb_rx_tx_desc(port_num, &rx_ring_size,
+                       &tx_ring_size);
+       if (retval != 0)
+               return retval;
+
        for (q = 0; q < rx_rings; q++) {
                retval = rte_eth_rx_queue_setup(port_num, q, rx_ring_size,
                                rte_eth_dev_socket_id(port_num),
index c89822c..b4d50de 100644 (file)
@@ -61,6 +61,8 @@ port_init(uint8_t port, struct rte_mempool *mbuf_pool)
 {
        struct rte_eth_conf port_conf = port_conf_default;
        const uint16_t rx_rings = 1, tx_rings = 1;
+       uint16_t nb_rxd = RX_RING_SIZE;
+       uint16_t nb_txd = TX_RING_SIZE;
        int retval;
        uint16_t q;
 
@@ -72,9 +74,13 @@ port_init(uint8_t port, struct rte_mempool *mbuf_pool)
        if (retval != 0)
                return retval;
 
+       retval = rte_eth_dev_adjust_nb_rx_tx_desc(port, &nb_rxd, &nb_txd);
+       if (retval != 0)
+               return retval;
+
        /* Allocate and set up 1 RX queue per Ethernet port. */
        for (q = 0; q < rx_rings; q++) {
-               retval = rte_eth_rx_queue_setup(port, q, RX_RING_SIZE,
+               retval = rte_eth_rx_queue_setup(port, q, nb_rxd,
                                rte_eth_dev_socket_id(port), NULL, mbuf_pool);
                if (retval < 0)
                        return retval;
@@ -82,7 +88,7 @@ port_init(uint8_t port, struct rte_mempool *mbuf_pool)
 
        /* Allocate and set up 1 TX queue per Ethernet port. */
        for (q = 0; q < tx_rings; q++) {
-               retval = rte_eth_tx_queue_setup(port, q, TX_RING_SIZE,
+               retval = rte_eth_tx_queue_setup(port, q, nb_txd,
                                rte_eth_dev_socket_id(port), NULL);
                if (retval < 0)
                        return retval;
index b57c045..050bb32 100644 (file)
@@ -135,8 +135,8 @@ vxlan_port_init(uint8_t port, struct rte_mempool *mbuf_pool)
        uint16_t q;
        struct rte_eth_dev_info dev_info;
        uint16_t rx_rings, tx_rings = (uint16_t)rte_lcore_count();
-       const uint16_t rx_ring_size = RTE_TEST_RX_DESC_DEFAULT;
-       const uint16_t tx_ring_size = RTE_TEST_TX_DESC_DEFAULT;
+       uint16_t rx_ring_size = RTE_TEST_RX_DESC_DEFAULT;
+       uint16_t tx_ring_size = RTE_TEST_TX_DESC_DEFAULT;
        struct rte_eth_udp_tunnel tunnel_udp;
        struct rte_eth_rxconf *rxconf;
        struct rte_eth_txconf *txconf;
@@ -166,6 +166,11 @@ vxlan_port_init(uint8_t port, struct rte_mempool *mbuf_pool)
        if (retval != 0)
                return retval;
 
+       retval = rte_eth_dev_adjust_nb_rx_tx_desc(port, &rx_ring_size,
+                       &tx_ring_size);
+       if (retval != 0)
+               return retval;
+
        /* Setup the queues. */
        for (q = 0; q < rx_rings; q++) {
                retval = rte_eth_rx_queue_setup(port, q, rx_ring_size,
index 30abaec..4d1589d 100644 (file)
@@ -339,6 +339,19 @@ port_init(uint8_t port)
                return retval;
        }
 
+       retval = rte_eth_dev_adjust_nb_rx_tx_desc(port, &rx_ring_size,
+               &tx_ring_size);
+       if (retval != 0) {
+               RTE_LOG(ERR, VHOST_PORT, "Failed to adjust number of descriptors "
+                       "for port %u: %s.\n", port, strerror(-retval));
+               return retval;
+       }
+       if (rx_ring_size > RTE_TEST_RX_DESC_DEFAULT) {
+               RTE_LOG(ERR, VHOST_PORT, "Mbuf pool has an insufficient size "
+                       "for Rx queues on port %u.\n", port);
+               return -1;
+       }
+
        /* Setup the queues. */
        for (q = 0; q < rx_rings; q ++) {
                retval = rte_eth_rx_queue_setup(port, q, rx_ring_size,
index 69213a4..eba4d35 100644 (file)
@@ -279,7 +279,8 @@ port_init(uint8_t port, struct rte_mempool *mbuf_pool)
        struct rte_eth_rxconf *rxconf;
        struct rte_eth_conf port_conf;
        uint16_t rx_rings, tx_rings = (uint16_t)rte_lcore_count();
-       const uint16_t rx_ring_size = RTE_TEST_RX_DESC_DEFAULT, tx_ring_size = RTE_TEST_TX_DESC_DEFAULT;
+       uint16_t rx_ring_size = RTE_TEST_RX_DESC_DEFAULT;
+       uint16_t tx_ring_size = RTE_TEST_TX_DESC_DEFAULT;
        int retval;
        uint16_t q;
 
@@ -307,6 +308,17 @@ port_init(uint8_t port, struct rte_mempool *mbuf_pool)
        if (retval != 0)
                return retval;
 
+       retval = rte_eth_dev_adjust_nb_rx_tx_desc(port, &rx_ring_size,
+               &tx_ring_size);
+       if (retval != 0)
+               return retval;
+       if (rx_ring_size > RTE_TEST_RX_DESC_DEFAULT ||
+               tx_ring_size > RTE_TEST_TX_DESC_DEFAULT) {
+               RTE_LOG(ERR, VHOST_PORT, "Mbuf pool has an insufficient size for "
+                       "port %u.\n", port);
+               return -1;
+       }
+
        rte_eth_dev_info_get(port, &dev_info);
        rxconf = &dev_info.default_rxconf;
        rxconf->rx_drop_en = 1;
index f639355..d096831 100644 (file)
@@ -195,7 +195,8 @@ port_init(uint8_t port, struct rte_mempool *mbuf_pool)
        struct rte_eth_rxconf *rxconf;
        struct rte_eth_conf port_conf;
        uint16_t rxRings, txRings;
-       const uint16_t rxRingSize = RTE_TEST_RX_DESC_DEFAULT, txRingSize = RTE_TEST_TX_DESC_DEFAULT;
+       uint16_t rxRingSize = RTE_TEST_RX_DESC_DEFAULT;
+       uint16_t txRingSize = RTE_TEST_TX_DESC_DEFAULT;
        int retval;
        uint16_t q;
        uint16_t queues_per_pool;
@@ -253,6 +254,17 @@ port_init(uint8_t port, struct rte_mempool *mbuf_pool)
        if (retval != 0)
                return retval;
 
+       retval = rte_eth_dev_adjust_nb_rx_tx_desc(port, &rxRingSize,
+                               &txRingSize);
+       if (retval != 0)
+               return retval;
+       if (RTE_MAX(rxRingSize, txRingSize) > RTE_MAX(RTE_TEST_RX_DESC_DEFAULT,
+                       RTE_TEST_TX_DESC_DEFAULT)) {
+               printf("Mbuf pool has an insufficient size for port %u.\n",
+                       port);
+               return -1;
+       }
+
        rte_eth_dev_info_get(port, &dev_info);
        rxconf = &dev_info.default_rxconf;
        rxconf->rx_drop_en = 1;
index 35ffffa..4f6d47e 100644 (file)
@@ -227,8 +227,8 @@ port_init(uint8_t port, struct rte_mempool *mbuf_pool)
 {
        struct rte_eth_dev_info dev_info;
        struct rte_eth_conf port_conf = {0};
-       const uint16_t rxRingSize = RTE_TEST_RX_DESC_DEFAULT;
-       const uint16_t txRingSize = RTE_TEST_TX_DESC_DEFAULT;
+       uint16_t rxRingSize = RTE_TEST_RX_DESC_DEFAULT;
+       uint16_t txRingSize = RTE_TEST_TX_DESC_DEFAULT;
        int retval;
        uint16_t q;
        uint16_t queues_per_pool;
@@ -299,6 +299,17 @@ port_init(uint8_t port, struct rte_mempool *mbuf_pool)
        if (retval != 0)
                return retval;
 
+       retval = rte_eth_dev_adjust_nb_rx_tx_desc(port, &rxRingSize,
+                               &txRingSize);
+       if (retval != 0)
+               return retval;
+       if (RTE_MAX(rxRingSize, txRingSize) >
+           RTE_MAX(RTE_TEST_RX_DESC_DEFAULT, RTE_TEST_TX_DESC_DEFAULT)) {
+               printf("Mbuf pool has an insufficient size for port %u.\n",
+                       port);
+               return -1;
+       }
+
        for (q = 0; q < num_queues; q++) {
                retval = rte_eth_rx_queue_setup(port, q, rxRingSize,
                                        rte_eth_dev_socket_id(port),