From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) by dpdk.org (Postfix) with ESMTP id 93A024CA0 for ; Wed, 13 Mar 2019 11:09:38 +0100 (CET) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id C13BB38A0; Wed, 13 Mar 2019 06:09:37 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Wed, 13 Mar 2019 06:09:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=mesmtp; bh=TgBS/vy3aH cRbz5UKdCeacEnizD1UY3yGYcc2YZcMj8=; b=LuXrZhcqFEN+OQ7g5ie/SCSqLq PzLb+Q8p4ptjQqktdCNOLKdg0S5qpFTjwR04SaotCtppo6SnG4T2FLja6zmF/fdF xgfz/vYFQpzc5ObjNAznS5+9dbSRWSTFvO1Mo5Ccc/pHfNrCk3cVm1DgDHJJJvR1 BunHLNepDQd4whIAg= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=TgBS/vy3aHcRbz5UKdCeacEnizD1UY3yGYcc2YZcMj8=; b=ZjXMiap0 PkIvPutH2WPnQD6FHj+T2HZ801qJpx8N79YkTM7g0q5Bx1AqkeZ1EE7PLJySTA1H g/EJ5rzsB2LjK76b1rBm5D5Pa+yP4YI/CT8FQM3OBuJfbE5YTr+Iw6W04BHfFta3 Ga6GrxRjq8SrSgOippmGrPrPZtiGYhFp905CDT+P6kpYeX2q73tcyY9Z+Gh/31Dg HKPyiQ3Kl8dMmbNd8NsC5/yUmBJ7FufzLNcB5lkcNths3T1d14Ru/GRALZjbGWl7 0Ch20RdhJfJRWh09Nfh4z8YQdcc39jrTpFA2GXQV6Ds7uS5TuUsNBE+i/SfUXRGz 0Gwq7fYa/feg5A== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedutddrhedtgdduudcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtkeertd ertddtnecuhfhrohhmpefvhhhomhgrshcuofhonhhjrghlohhnuceothhhohhmrghssehm ohhnjhgrlhhonhdrnhgvtheqnecuffhomhgrihhnpehtgihmohguvgdrmhhqnecukfhppe ejjedrudefgedrvddtfedrudekgeenucfrrghrrghmpehmrghilhhfrhhomhepthhhohhm rghssehmohhnjhgrlhhonhdrnhgvthenucevlhhushhtvghrufhiiigvpedu X-ME-Proxy: Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id 7A9D6E4693 for ; Wed, 13 Mar 2019 06:09:36 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Date: Wed, 13 Mar 2019 11:09:10 +0100 Message-Id: <20190313100910.31260-3-thomas@monjalon.net> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190313100910.31260-1-thomas@monjalon.net> References: <20190313100910.31260-1-thomas@monjalon.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH 2/2] examples/ethtool: allocate only one mempool 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: , X-List-Received-Date: Wed, 13 Mar 2019 10:09:39 -0000 No need to allocate one mempool per port. The number of mbufs is fixed for simplicity. Signed-off-by: Thomas Monjalon --- examples/ethtool/ethtool-app/main.c | 32 ++++++++--------------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/examples/ethtool/ethtool-app/main.c b/examples/ethtool/ethtool-app/main.c index e23d3afd2..e7185ca79 100644 --- a/examples/ethtool/ethtool-app/main.c +++ b/examples/ethtool/ethtool-app/main.c @@ -22,7 +22,7 @@ #define MAX_BURST_LENGTH 32 #define PORT_RX_QUEUE_SIZE 1024 #define PORT_TX_QUEUE_SIZE 1024 -#define PKTPOOL_EXTRA_SIZE 512 +#define NUM_MBUFS 8191 #define PKTPOOL_CACHE 32 @@ -38,7 +38,6 @@ struct app_port { int port_active; int port_dirty; int idx_port; - struct rte_mempool *pkt_pool; }; struct app_config { @@ -89,36 +88,23 @@ void mark_port_newmac(int idx_port) static void setup_ports(struct app_config *app_cfg, int cnt_ports) { int idx_port; - int size_pktpool; 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; + struct rte_mempool *pkt_pool; memset(&cfg_port, 0, sizeof(cfg_port)); cfg_port.txmode.mq_mode = ETH_MQ_TX_NONE; + pkt_pool = rte_pktmbuf_pool_create("mbuf pool", + NUM_MBUFS, PKTPOOL_CACHE, 0, RTE_MBUF_DEFAULT_BUF_SIZE, + rte_socket_id()); + if (pkt_pool == NULL) + rte_exit(EXIT_FAILURE, "rte_pktmbuf_pool_create failed"); + for (idx_port = 0; idx_port < cnt_ports; idx_port++) { struct app_port *ptr_port = &app_cfg->ports[idx_port]; - rte_eth_dev_info_get(idx_port, &dev_info); - size_pktpool = dev_info.rx_desc_lim.nb_max + - dev_info.tx_desc_lim.nb_max + PKTPOOL_EXTRA_SIZE; - - snprintf(str_name, 16, "pkt_pool%i", idx_port); - ptr_port->pkt_pool = rte_pktmbuf_pool_create( - str_name, - size_pktpool, PKTPOOL_CACHE, - 0, - RTE_MBUF_DEFAULT_BUF_SIZE, - rte_socket_id() - ); - if (ptr_port->pkt_pool == NULL) - rte_exit(EXIT_FAILURE, - "rte_pktmbuf_pool_create failed" - ); - printf("Init port %i..\n", idx_port); ptr_port->port_active = 1; ptr_port->port_dirty = 0; @@ -135,7 +121,7 @@ static void setup_ports(struct app_config *app_cfg, int cnt_ports) if (rte_eth_rx_queue_setup( idx_port, 0, nb_rxd, rte_eth_dev_socket_id(idx_port), NULL, - ptr_port->pkt_pool) < 0) + pkt_pool) < 0) rte_exit(EXIT_FAILURE, "rte_eth_rx_queue_setup failed" ); -- 2.20.1