From patchwork Thu May 25 15:57:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Rybchenko X-Patchwork-Id: 24588 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id D05BC999E; Thu, 25 May 2017 17:58:58 +0200 (CEST) Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [67.231.154.164]) by dpdk.org (Postfix) with ESMTP id 5801C999D for ; Thu, 25 May 2017 17:58:57 +0200 (CEST) Received: from pure.maildistiller.com (unknown [10.110.50.29]) by dispatch1-us1.ppe-hosted.com (Proofpoint Essentials ESMTP Server) with ESMTP id 78DBC60054; Thu, 25 May 2017 15:58:57 +0000 (UTC) X-Virus-Scanned: Proofpoint Essentials engine Received: from mx1-us1.ppe-hosted.com (unknown [10.110.49.251]) by pure.maildistiller.com (Proofpoint Essentials ESMTP Server) with ESMTPS id E16CF60051; Thu, 25 May 2017 15:58:55 +0000 (UTC) Received: from webmail.solarflare.com (webmail.solarflare.com [12.187.104.26]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1-us1.ppe-hosted.com (Proofpoint Essentials ESMTP Server) with ESMTPS id 547B72007C; Thu, 25 May 2017 15:58:37 +0000 (UTC) Received: from ocex03.SolarFlarecom.com (10.20.40.36) by ocex03.SolarFlarecom.com (10.20.40.36) with Microsoft SMTP Server (TLS) id 15.0.1044.25; Thu, 25 May 2017 08:58:15 -0700 Received: from opal.uk.solarflarecom.com (10.17.10.1) by ocex03.SolarFlarecom.com (10.20.40.36) with Microsoft SMTP Server (TLS) id 15.0.1044.25 via Frontend Transport; Thu, 25 May 2017 08:58:14 -0700 Received: from uklogin.uk.solarflarecom.com (uklogin.uk.solarflarecom.com [10.17.10.10]) by opal.uk.solarflarecom.com (8.13.8/8.13.8) with ESMTP id v4PFwDVs010307; Thu, 25 May 2017 16:58:13 +0100 Received: from uklogin.uk.solarflarecom.com (localhost.localdomain [127.0.0.1]) by uklogin.uk.solarflarecom.com (8.13.8/8.13.8) with ESMTP id v4PFwCK2010930; Thu, 25 May 2017 16:58:13 +0100 From: Andrew Rybchenko To: CC: Sergio Gonzalez Monroy , Remy Horton , Jianfeng Tan , Declan Doherty , Ferruh Yigit , Yuanhan Liu , Maxime Coquelin , Konstantin Ananyev , Bruce Richardson , Reshma Pattan , Cristian Dumitrescu , Byron Marohn , Pablo de Lara Guarch , Pawel Wodkowski , Tomasz Kantecki , John McNamara , Daniel Mrzyglod , Roman Zhukov Date: Thu, 25 May 2017 16:57:54 +0100 Message-ID: <1495727874-10892-2-git-send-email-arybchenko@solarflare.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: <1495727874-10892-1-git-send-email-arybchenko@solarflare.com> References: <1488459935-13273-2-git-send-email-arybchenko@solarflare.com> <1495727874-10892-1-git-send-email-arybchenko@solarflare.com> MIME-Version: 1.0 X-MDID: 1495727936-Zmm89E1gjt64 Subject: [dpdk-dev] [PATCH 2/2] examples: adjust Rx and Tx descriptors to device limits X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Roman Zhukov Signed-off-by: Roman Zhukov Signed-off-by: Andrew Rybchenko --- examples/bond/main.c | 22 ++++++++++++--- examples/distributor/main.c | 10 +++++-- examples/ethtool/ethtool-app/main.c | 10 +++++-- examples/exception_path/main.c | 13 +++++++-- examples/ip_fragmentation/main.c | 8 ++++++ examples/ip_pipeline/init.c | 32 ++++++++++++++++++++-- examples/ip_reassembly/main.c | 10 ++++++- examples/ipsec-secgw/ipsec-secgw.c | 5 ++++ examples/ipv4_multicast/main.c | 7 +++++ examples/kni/main.c | 11 ++++++-- examples/l2fwd-cat/l2fwd-cat.c | 10 +++++-- examples/l2fwd-crypto/main.c | 8 ++++++ examples/l2fwd-jobstats/main.c | 7 +++++ examples/l2fwd-keepalive/main.c | 7 +++++ examples/l2fwd/main.c | 7 +++++ examples/l3fwd-acl/main.c | 15 +++++++--- examples/l3fwd-power/main.c | 11 ++++++-- examples/l3fwd-vf/main.c | 17 ++++++++---- examples/l3fwd/main.c | 15 +++++++--- examples/link_status_interrupt/main.c | 7 +++++ examples/load_balancer/init.c | 13 +++++++++ .../client_server_mp/mp_server/init.c | 9 ++++-- examples/multi_process/l2fwd_fork/main.c | 7 +++++ examples/multi_process/symmetric_mp/main.c | 10 +++++-- examples/netmap_compat/lib/compat_netmap.c | 9 ++++++ examples/packet_ordering/main.c | 10 +++++-- examples/performance-thread/l3fwd-thread/main.c | 15 +++++++--- examples/ptpclient/ptpclient.c | 10 +++++-- examples/qos_meter/main.c | 22 ++++++++++++--- examples/qos_sched/init.c | 11 ++++++++ examples/quota_watermark/qw/init.c | 12 ++++++-- examples/rxtx_callbacks/main.c | 10 +++++-- examples/server_node_efd/server/init.c | 9 ++++-- examples/skeleton/basicfwd.c | 10 +++++-- examples/tep_termination/vxlan_setup.c | 9 ++++-- examples/vhost/main.c | 13 +++++++++ examples/vhost_xen/main.c | 14 +++++++++- examples/vmdq/main.c | 14 +++++++++- examples/vmdq_dcb/main.c | 15 ++++++++-- 39 files changed, 392 insertions(+), 62 deletions(-) diff --git a/examples/bond/main.c b/examples/bond/main.c index 9a4ec80..6859e13 100644 --- a/examples/bond/main.c +++ b/examples/bond/main.c @@ -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) diff --git a/examples/distributor/main.c b/examples/distributor/main.c index 8071f91..7496853 100644 --- a/examples/distributor/main.c +++ b/examples/distributor/main.c @@ -137,6 +137,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; @@ -145,8 +147,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) @@ -154,7 +160,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) diff --git a/examples/ethtool/ethtool-app/main.c b/examples/ethtool/ethtool-app/main.c index 6d50d46..011c732 100644 --- a/examples/ethtool/ethtool-app/main.c +++ b/examples/ethtool/ethtool-app/main.c @@ -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" diff --git a/examples/exception_path/main.c b/examples/exception_path/main.c index 89bf1cc..10a3926 100644 --- a/examples/exception_path/main.c +++ b/examples/exception_path/main.c @@ -422,6 +422,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); @@ -431,14 +433,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)", diff --git a/examples/ip_fragmentation/main.c b/examples/ip_fragmentation/main.c index 71c1d12..1119091 100644 --- a/examples/ip_fragmentation/main.c +++ b/examples/ip_fragmentation/main.c @@ -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, diff --git a/examples/ip_pipeline/init.c b/examples/ip_pipeline/init.c index be148fc..7cde49a 100644 --- a/examples/ip_pipeline/init.c +++ b/examples/ip_pipeline/init.c @@ -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) diff --git a/examples/ip_reassembly/main.c b/examples/ip_reassembly/main.c index c0f3ced..4032a69 100644 --- a/examples/ip_reassembly/main.c +++ b/examples/ip_reassembly/main.c @@ -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++; diff --git a/examples/ipsec-secgw/ipsec-secgw.c b/examples/ipsec-secgw/ipsec-secgw.c index 8cbf6ac..64ff564 100644 --- a/examples/ipsec-secgw/ipsec-secgw.c +++ b/examples/ipsec-secgw/ipsec-secgw.c @@ -1332,6 +1332,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++) { diff --git a/examples/ipv4_multicast/main.c b/examples/ipv4_multicast/main.c index 96a4ab6..ba4ab09 100644 --- a/examples/ipv4_multicast/main.c +++ b/examples/ipv4_multicast/main.c @@ -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(", "); diff --git a/examples/kni/main.c b/examples/kni/main.c index 0be57d8..dd6c0c3 100644 --- a/examples/kni/main.c +++ b/examples/kni/main.c @@ -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 " diff --git a/examples/l2fwd-cat/l2fwd-cat.c b/examples/l2fwd-cat/l2fwd-cat.c index 8cce33b..c293bd9 100644 --- a/examples/l2fwd-cat/l2fwd-cat.c +++ b/examples/l2fwd-cat/l2fwd-cat.c @@ -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; diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c index 9492193..168ec5f 100644 --- a/examples/l2fwd-crypto/main.c +++ b/examples/l2fwd-crypto/main.c @@ -1861,6 +1861,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, diff --git a/examples/l2fwd-jobstats/main.c b/examples/l2fwd-jobstats/main.c index e6e6c22..652e6f8 100644 --- a/examples/l2fwd-jobstats/main.c +++ b/examples/l2fwd-jobstats/main.c @@ -883,6 +883,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 */ diff --git a/examples/l2fwd-keepalive/main.c b/examples/l2fwd-keepalive/main.c index 3745348..3c6a9d3 100644 --- a/examples/l2fwd-keepalive/main.c +++ b/examples/l2fwd-keepalive/main.c @@ -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 */ diff --git a/examples/l2fwd/main.c b/examples/l2fwd/main.c index f966727..00759b9 100644 --- a/examples/l2fwd/main.c +++ b/examples/l2fwd/main.c @@ -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 */ diff --git a/examples/l3fwd-acl/main.c b/examples/l3fwd-acl/main.c index ea0b5b1..1563884 100644 --- a/examples/l3fwd-acl/main.c +++ b/examples/l3fwd-acl/main.c @@ -91,10 +91,10 @@ */ #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(", "); diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c index 9d57fde..0a6963b 100644 --- a/examples/l3fwd-power/main.c +++ b/examples/l3fwd-power/main.c @@ -131,9 +131,9 @@ */ #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(", "); diff --git a/examples/l3fwd-vf/main.c b/examples/l3fwd-vf/main.c index 797f722..a49ab86 100644 --- a/examples/l3fwd-vf/main.c +++ b/examples/l3fwd-vf/main.c @@ -99,11 +99,11 @@ * 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(", "); diff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c index fd6605b..7094197 100644 --- a/examples/l3fwd/main.c +++ b/examples/l3fwd/main.c @@ -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(", "); diff --git a/examples/link_status_interrupt/main.c b/examples/link_status_interrupt/main.c index 25da28e..a28bcfd 100644 --- a/examples/link_status_interrupt/main.c +++ b/examples/link_status_interrupt/main.c @@ -646,6 +646,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 diff --git a/examples/load_balancer/init.c b/examples/load_balancer/init.c index abd05a3..8fe7db4 100644 --- a/examples/load_balancer/init.c +++ b/examples/load_balancer/init.c @@ -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) { diff --git a/examples/multi_process/client_server_mp/mp_server/init.c b/examples/multi_process/client_server_mp/mp_server/init.c index ad941a7..0bc9292 100644 --- a/examples/multi_process/client_server_mp/mp_server/init.c +++ b/examples/multi_process/client_server_mp/mp_server/init.c @@ -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), diff --git a/examples/multi_process/l2fwd_fork/main.c b/examples/multi_process/l2fwd_fork/main.c index 59c1024..9ef9a7b 100644 --- a/examples/multi_process/l2fwd_fork/main.c +++ b/examples/multi_process/l2fwd_fork/main.c @@ -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 */ diff --git a/examples/multi_process/symmetric_mp/main.c b/examples/multi_process/symmetric_mp/main.c index 0990d96..208e356 100644 --- a/examples/multi_process/symmetric_mp/main.c +++ b/examples/multi_process/symmetric_mp/main.c @@ -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) diff --git a/examples/netmap_compat/lib/compat_netmap.c b/examples/netmap_compat/lib/compat_netmap.c index 112c551..c1f1f40 100644 --- a/examples/netmap_compat/lib/compat_netmap.c +++ b/examples/netmap_compat/lib/compat_netmap.c @@ -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); diff --git a/examples/packet_ordering/main.c b/examples/packet_ordering/main.c index 49ae35b..b26c33d 100644 --- a/examples/packet_ordering/main.c +++ b/examples/packet_ordering/main.c @@ -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; diff --git a/examples/performance-thread/l3fwd-thread/main.c b/examples/performance-thread/l3fwd-thread/main.c index 2d98473..31d679e 100644 --- a/examples/performance-thread/l3fwd-thread/main.c +++ b/examples/performance-thread/l3fwd-thread/main.c @@ -188,10 +188,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 @@ -3587,6 +3587,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(", "); diff --git a/examples/ptpclient/ptpclient.c b/examples/ptpclient/ptpclient.c index a80961d..ddfcdb8 100644 --- a/examples/ptpclient/ptpclient.c +++ b/examples/ptpclient/ptpclient.c @@ -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; diff --git a/examples/qos_meter/main.c b/examples/qos_meter/main.c index d8a2107..b0909f6 100644 --- a/examples/qos_meter/main.c +++ b/examples/qos_meter/main.c @@ -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) diff --git a/examples/qos_sched/init.c b/examples/qos_sched/init.c index fe0221c..a82cbd7 100644 --- a/examples/qos_sched/init.c +++ b/examples/qos_sched/init.c @@ -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, diff --git a/examples/quota_watermark/qw/init.c b/examples/quota_watermark/qw/init.c index b6264fc..083a37a 100644 --- a/examples/quota_watermark/qw/init.c +++ b/examples/quota_watermark/qw/init.c @@ -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) diff --git a/examples/rxtx_callbacks/main.c b/examples/rxtx_callbacks/main.c index 048b23f..6699240 100644 --- a/examples/rxtx_callbacks/main.c +++ b/examples/rxtx_callbacks/main.c @@ -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; diff --git a/examples/server_node_efd/server/init.c b/examples/server_node_efd/server/init.c index 82457b4..d114e5b 100644 --- a/examples/server_node_efd/server/init.c +++ b/examples/server_node_efd/server/init.c @@ -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), diff --git a/examples/skeleton/basicfwd.c b/examples/skeleton/basicfwd.c index c89822c..b4d50de 100644 --- a/examples/skeleton/basicfwd.c +++ b/examples/skeleton/basicfwd.c @@ -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; diff --git a/examples/tep_termination/vxlan_setup.c b/examples/tep_termination/vxlan_setup.c index b57c045..050bb32 100644 --- a/examples/tep_termination/vxlan_setup.c +++ b/examples/tep_termination/vxlan_setup.c @@ -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, diff --git a/examples/vhost/main.c b/examples/vhost/main.c index e07f866..518123f 100644 --- a/examples/vhost/main.c +++ b/examples/vhost/main.c @@ -338,6 +338,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, diff --git a/examples/vhost_xen/main.c b/examples/vhost_xen/main.c index d9ef140..fd91b11 100644 --- a/examples/vhost_xen/main.c +++ b/examples/vhost_xen/main.c @@ -278,7 +278,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; @@ -306,6 +307,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; diff --git a/examples/vmdq/main.c b/examples/vmdq/main.c index f639355..d096831 100644 --- a/examples/vmdq/main.c +++ b/examples/vmdq/main.c @@ -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; diff --git a/examples/vmdq_dcb/main.c b/examples/vmdq_dcb/main.c index 35ffffa..4f6d47e 100644 --- a/examples/vmdq_dcb/main.c +++ b/examples/vmdq_dcb/main.c @@ -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),