From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by inbox.dpdk.org (Postfix) with ESMTP id DED69A04BA;
	Wed,  7 Oct 2020 17:10:14 +0200 (CEST)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id 48DBF1BEA0;
	Wed,  7 Oct 2020 17:07:15 +0200 (CEST)
Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129])
 by dpdk.org (Postfix) with ESMTP id 88D1E1BCD8
 for <dev@dpdk.org>; Wed,  7 Oct 2020 17:07:01 +0200 (CEST)
Received: from Internal Mail-Server by MTLPINE1 (envelope-from
 viacheslavo@nvidia.com) with SMTP; 7 Oct 2020 18:06:56 +0300
Received: from nvidia.com (pegasus12.mtr.labs.mlnx [10.210.17.40])
 by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 097F6uPI010965;
 Wed, 7 Oct 2020 18:06:56 +0300
From: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
To: dev@dpdk.org
Cc: thomasm@monjalon.net, stephen@networkplumber.org, ferruh.yigit@intel.com, 
 olivier.matz@6wind.com, jerinjacobk@gmail.com,
 maxime.coquelin@redhat.com, david.marchand@redhat.com,
 arybchenko@solarflare.com
Date: Wed,  7 Oct 2020 15:06:51 +0000
Message-Id: <1602083215-22921-6-git-send-email-viacheslavo@nvidia.com>
X-Mailer: git-send-email 1.8.3.1
In-Reply-To: <1602083215-22921-1-git-send-email-viacheslavo@nvidia.com>
References: <MWHPR12MB136076E652230CEBD6EE6562DF5F0@MWHPR12MB1360.namprd12.prod.outlook.com>
 <1602083215-22921-1-git-send-email-viacheslavo@nvidia.com>
Subject: [dpdk-dev] [PATCH v2 5/9] app/testpmd: add extended Rx queue setup
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

If Rx queue is configured with split feature the extended
setup with specified segment sizes and pool will be performed.

Signed-off-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
---
 app/test-pmd/cmdline.c | 12 ++++++------
 app/test-pmd/testpmd.c | 38 ++++++++++++++++++++++++++++++++++++--
 app/test-pmd/testpmd.h |  6 ++++++
 3 files changed, 48 insertions(+), 8 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index e0ac76e..1c65499 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -2912,12 +2912,12 @@ struct cmd_setup_rxtx_queue {
 				rxring_numa[res->portid]);
 			return;
 		}
-		ret = rte_eth_rx_queue_setup(res->portid,
-					     res->qid,
-					     port->nb_rx_desc[res->qid],
-					     socket_id,
-					     &port->rx_conf[res->qid],
-					     mp);
+		ret = rx_queue_setup(res->portid,
+				     res->qid,
+				     port->nb_rx_desc[res->qid],
+				     socket_id,
+				     &port->rx_conf[res->qid],
+				     mp);
 		if (ret)
 			printf("Failed to setup RX queue\n");
 	} else {
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 3c88ca7..cd17cb0 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -2412,6 +2412,40 @@ struct extmem_param {
 	return 0;
 }
 
+/* Configure the Rx with optional split. */
+int
+rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
+	       uint16_t nb_rx_desc, unsigned int socket_id,
+	       const struct rte_eth_rxconf *rx_conf,
+	       struct rte_mempool *mp)
+{
+	struct rte_eth_rxseg rx_seg[MAX_SEGS_BUFFER_SPLIT] = {};
+	unsigned int i, mp_n;
+
+	if (rx_pkt_nb_segs <= 1 ||
+	    (rx_conf->offloads & DEV_RX_OFFLOAD_BUFFER_SPLIT) == 0)
+		return rte_eth_rx_queue_setup(port_id, rx_queue_id,
+					      nb_rx_desc, socket_id,
+					      rx_conf, mp);
+	for (i = 0; i < rx_pkt_nb_segs; i++) {
+		struct rte_mempool *mpx;
+		/*
+		 * Use last valid pool for the segments with number
+		 * exceeding the pool index.
+		 */
+		mp_n = (i > mbuf_data_size_n) ? mbuf_data_size_n - 1 : i;
+		mpx = mbuf_pool_find(socket_id, mp_n);
+		/* Handle zero as mbuf data buffer size. */
+		rx_seg[i].length = rx_pkt_seg_lengths[i] ?
+				   rx_pkt_seg_lengths[i] :
+				   mbuf_data_size[mp_n];
+		rx_seg[i].mp = mpx ? mpx : mp;
+	}
+	return rte_eth_rx_queue_setup_ex(port_id, rx_queue_id,
+					 nb_rx_desc, socket_id, rx_conf,
+					 rx_seg, rx_pkt_nb_segs);
+}
+
 int
 start_port(portid_t pid)
 {
@@ -2520,7 +2554,7 @@ struct extmem_param {
 						return -1;
 					}
 
-					diag = rte_eth_rx_queue_setup(pi, qi,
+					diag = rx_queue_setup(pi, qi,
 					     port->nb_rx_desc[qi],
 					     rxring_numa[pi],
 					     &(port->rx_conf[qi]),
@@ -2536,7 +2570,7 @@ struct extmem_param {
 							port->socket_id);
 						return -1;
 					}
-					diag = rte_eth_rx_queue_setup(pi, qi,
+					diag = rx_queue_setup(pi, qi,
 					     port->nb_rx_desc[qi],
 					     port->socket_id,
 					     &(port->rx_conf[qi]),
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 0576b7c..1953c11 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -869,6 +869,12 @@ void port_rss_reta_info(portid_t port_id,
 
 void set_vf_traffic(portid_t port_id, uint8_t is_rx, uint16_t vf, uint8_t on);
 
+int
+rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
+	       uint16_t nb_rx_desc, unsigned int socket_id,
+	       const struct rte_eth_rxconf *rx_conf,
+	       struct rte_mempool *mp);
+
 int set_queue_rate_limit(portid_t port_id, uint16_t queue_idx, uint16_t rate);
 int set_vf_rate_limit(portid_t port_id, uint16_t vf, uint16_t rate,
 				uint64_t q_msk);
-- 
1.8.3.1