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 4E2F9A04E6;
	Fri, 30 Oct 2020 18:48:50 +0100 (CET)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id 22F3A69C8;
	Fri, 30 Oct 2020 18:45:28 +0100 (CET)
Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com
 [66.111.4.26]) by dpdk.org (Postfix) with ESMTP id 91D3D593A
 for <dev@dpdk.org>; Fri, 30 Oct 2020 18:45:12 +0100 (CET)
Received: from compute2.internal (compute2.nyi.internal [10.202.2.42])
 by mailout.nyi.internal (Postfix) with ESMTP id 48BE35C021F;
 Fri, 30 Oct 2020 13:45:12 -0400 (EDT)
Received: from mailfrontend2 ([10.202.2.163])
 by compute2.internal (MEProxy); Fri, 30 Oct 2020 13:45:12 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h=
 from:to:cc:subject:date:message-id:in-reply-to:references
 :mime-version:content-transfer-encoding; s=fm2; bh=HhLwf0w4DGO4G
 rUYkzhR7OWJ7zfGCnjW/SYxuiDy6eY=; b=QzhH0+/9DHxxQesD3pKLk3Mf081Jg
 cePr4VRYblniQCONpS1av9xhgk8DfhNLVUpQcLQAv+cmqJ2C76GYCkL+mt2CqVtn
 8Pfx3BjVi0DGCcd3JdJurajlD/Ri+hIANpcRt7hVJe9lUQliGdw/J6GlVRdOHG7g
 ycLaAtBXzsXLC1kOx2r+hhyPUNwL7PgHj41xnCefoUdHuuMTQBAOVaCt40bsvWJn
 JYaVXkpMDrH3/9d+Rwy0EwbnOg/ZQlppPbnOiUgGDs1mkum32wkAJBLe+t+hywm7
 q8mP0LXV27/ZCR9MSJh5Tcb+MKDfUa1WrCw+4DD0AuCRqgynHC4IgDNKA==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
 messagingengine.com; h=cc: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=
 fm1; bh=HhLwf0w4DGO4GrUYkzhR7OWJ7zfGCnjW/SYxuiDy6eY=; b=kQkvN3JC
 XIz7A0Cze3rurcgTPgN03arpCEKZTMmnb08g4QlASLfwE26so3no8co3g2+WbGmv
 tZpVWV1nAT/BL9R0NZe5Sq3nm+inkWHP+4S4hIhtWJrjVJ/+/8Mb4/qDSsbnGWl5
 7G5Lw1HdNcFWPoAhVfFc72D7TtMB3idUc2wVRkpUFUaRgoaKncvhm7f4XYNzaqkO
 i9Ij68kw+30bPA4DKSb0JfUiLFnQHDEKNSsIxxPUWS+XAF/+KJRLy73j3FSKeZtT
 rtEcr3X49mXQJ+61b69dyWD80lN3lGysTOUqgYUyRbXpQ/xXgWGdUUeQR1hDikT1
 HRLAOnrF0d2zlg==
X-ME-Sender: <xms:KFGcX8t3AItpfL24llKCEeBmmPgJ-SPoib4zopuLD5tDUY01N8Fqlw>
 <xme:KFGcX5d_7VtgnWy6dOSjqc7S6zy8wLd9SLnJVvYqHSnpBADxT9_NafWdRbWqUeVTS
 8OymNLmkH-2KwVGAg>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrleehgdellecutefuodetggdotefrodftvf
 curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu
 uegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtkeertd
 ertddtnecuhfhrohhmpefvhhhomhgrshcuofhonhhjrghlohhnuceothhhohhmrghssehm
 ohhnjhgrlhhonhdrnhgvtheqnecuggftrfgrthhtvghrnhepvdehgfeivdejgedtveehfe
 fhteelfefgieevgfffveefjeegtdfguedthedtgeevnecukfhppeejjedrudefgedrvddt
 fedrudekgeenucevlhhushhtvghrufhiiigvpeelnecurfgrrhgrmhepmhgrihhlfhhroh
 hmpehthhhomhgrshesmhhonhhjrghlohhnrdhnvght
X-ME-Proxy: <xmx:KFGcX3xVVQ09b83rTxlsfvskJP_aJMqydaOcoBAqy8hS9Jmdz0Me1g>
 <xmx:KFGcX_M5VvP3zhqhsp9cL85ZZ6pySHy8lgqLqO3pA14bRZ_5oswhXA>
 <xmx:KFGcX8_CDnYLt4BwaPkOdJdwx6jLGvErKzLPLtCwy2laHldG-IHARg>
 <xmx:KFGcX7n4VXHqvddzO_S8H-VhR2z0aQFDynNbLOWbFJUgc2aanhvbmQ>
Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184])
 by mail.messagingengine.com (Postfix) with ESMTPA id 4666E3064674;
 Fri, 30 Oct 2020 13:45:11 -0400 (EDT)
From: Thomas Monjalon <thomas@monjalon.net>
To: dev@dpdk.org
Cc: ferruh.yigit@intel.com, david.marchand@redhat.com,
 bruce.richardson@intel.com, olivier.matz@6wind.com,
 andrew.rybchenko@oktetlabs.ru, akhil.goyal@nxp.com, jerinj@marvell.com
Date: Fri, 30 Oct 2020 18:44:38 +0100
Message-Id: <20201030174441.1076264-13-thomas@monjalon.net>
X-Mailer: git-send-email 2.28.0
In-Reply-To: <20201030174441.1076264-1-thomas@monjalon.net>
References: <20201026052105.1561859-1-thomas@monjalon.net>
 <20201030174441.1076264-1-thomas@monjalon.net>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Subject: [dpdk-dev] [PATCH v6 12/15] app/eventdev: switch flow ID to dynamic
	mbuf field
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>

The order test stored the flow ID in the deprecated mbuf field udata64.
It is moved to a dynamic field in order to allow removal of udata64.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 app/test-eventdev/test_order_atq.c    |  4 ++--
 app/test-eventdev/test_order_common.c | 21 +++++++++++++++------
 app/test-eventdev/test_order_common.h | 21 +++++++++++++++++++++
 app/test-eventdev/test_order_queue.c  |  4 ++--
 4 files changed, 40 insertions(+), 10 deletions(-)

diff --git a/app/test-eventdev/test_order_atq.c b/app/test-eventdev/test_order_atq.c
index cfcb1dc4e9..71215a07b6 100644
--- a/app/test-eventdev/test_order_atq.c
+++ b/app/test-eventdev/test_order_atq.c
@@ -35,7 +35,7 @@ order_atq_worker(void *arg, const bool flow_id_cap)
 		}
 
 		if (!flow_id_cap)
-			ev.flow_id = ev.mbuf->udata64;
+			order_flow_id_copy_from_mbuf(t, &ev);
 
 		if (ev.sub_event_type == 0) { /* stage 0 from producer */
 			order_atq_process_stage_0(&ev);
@@ -72,7 +72,7 @@ order_atq_worker_burst(void *arg, const bool flow_id_cap)
 
 		for (i = 0; i < nb_rx; i++) {
 			if (!flow_id_cap)
-				ev[i].flow_id = ev[i].mbuf->udata64;
+				order_flow_id_copy_from_mbuf(t, &ev[i]);
 
 			if (ev[i].sub_event_type == 0) { /*stage 0 */
 				order_atq_process_stage_0(&ev[i]);
diff --git a/app/test-eventdev/test_order_common.c b/app/test-eventdev/test_order_common.c
index dc55d93921..01a44bcd75 100644
--- a/app/test-eventdev/test_order_common.c
+++ b/app/test-eventdev/test_order_common.c
@@ -46,13 +46,10 @@ order_producer(void *arg)
 		if (m == NULL)
 			continue;
 
-		const uint32_t flow = (uintptr_t)m % nb_flows;
+		const flow_id_t flow = (uintptr_t)m % nb_flows;
 		/* Maintain seq number per flow */
 		m->seqn = producer_flow_seq[flow]++;
-		m->udata64 = flow;
-
-		ev.flow_id = flow;
-		ev.mbuf = m;
+		order_flow_id_save(t, flow, m, &ev);
 
 		while (rte_event_enqueue_burst(dev_id, port, &ev, 1) != 1) {
 			if (t->err)
@@ -138,6 +135,12 @@ int
 order_test_setup(struct evt_test *test, struct evt_options *opt)
 {
 	void *test_order;
+	struct test_order *t;
+	static const struct rte_mbuf_dynfield flow_id_dynfield_desc = {
+		.name = "test_event_dynfield_flow_id",
+		.size = sizeof(flow_id_t),
+		.align = __alignof__(flow_id_t),
+	};
 
 	test_order = rte_zmalloc_socket(test->name, sizeof(struct test_order),
 				RTE_CACHE_LINE_SIZE, opt->socket_id);
@@ -146,8 +149,14 @@ order_test_setup(struct evt_test *test, struct evt_options *opt)
 		goto nomem;
 	}
 	test->test_priv = test_order;
+	t = evt_test_priv(test);
 
-	struct test_order *t = evt_test_priv(test);
+	t->flow_id_dynfield_offset =
+		rte_mbuf_dynfield_register(&flow_id_dynfield_desc);
+	if (t->flow_id_dynfield_offset < 0) {
+		evt_err("failed to register mbuf field");
+		return -rte_errno;
+	}
 
 	t->producer_flow_seq = rte_zmalloc_socket("test_producer_flow_seq",
 				 sizeof(*t->producer_flow_seq) * opt->nb_flows,
diff --git a/app/test-eventdev/test_order_common.h b/app/test-eventdev/test_order_common.h
index e0fe9c968a..90eac96fc8 100644
--- a/app/test-eventdev/test_order_common.h
+++ b/app/test-eventdev/test_order_common.h
@@ -13,6 +13,7 @@
 #include <rte_lcore.h>
 #include <rte_malloc.h>
 #include <rte_mbuf.h>
+#include <rte_mbuf_dyn.h>
 
 #include "evt_common.h"
 #include "evt_options.h"
@@ -20,6 +21,8 @@
 
 #define BURST_SIZE 16
 
+typedef uint32_t flow_id_t;
+
 struct test_order;
 
 struct worker_data {
@@ -49,6 +52,7 @@ struct test_order {
 	uint32_t nb_flows;
 	uint64_t nb_pkts;
 	struct rte_mempool *pool;
+	int flow_id_dynfield_offset;
 	struct prod_data prod;
 	struct worker_data worker[EVT_MAX_PORTS];
 	uint32_t *producer_flow_seq;
@@ -56,6 +60,23 @@ struct test_order {
 	struct evt_options *opt;
 } __rte_cache_aligned;
 
+static inline void
+order_flow_id_copy_from_mbuf(struct test_order *t, struct rte_event *event)
+{
+	event->flow_id = *RTE_MBUF_DYNFIELD(event->mbuf,
+			t->flow_id_dynfield_offset, flow_id_t *);
+}
+
+static inline void
+order_flow_id_save(struct test_order *t, flow_id_t flow_id,
+		struct rte_mbuf *mbuf, struct rte_event *event)
+{
+	*RTE_MBUF_DYNFIELD(mbuf,
+			t->flow_id_dynfield_offset, flow_id_t *) = flow_id;
+	event->flow_id = flow_id;
+	event->mbuf = mbuf;
+}
+
 static inline int
 order_nb_event_ports(struct evt_options *opt)
 {
diff --git a/app/test-eventdev/test_order_queue.c b/app/test-eventdev/test_order_queue.c
index 1511c0092d..621367805a 100644
--- a/app/test-eventdev/test_order_queue.c
+++ b/app/test-eventdev/test_order_queue.c
@@ -35,7 +35,7 @@ order_queue_worker(void *arg, const bool flow_id_cap)
 		}
 
 		if (!flow_id_cap)
-			ev.flow_id = ev.mbuf->udata64;
+			order_flow_id_copy_from_mbuf(t, &ev);
 
 		if (ev.queue_id == 0) { /* from ordered queue */
 			order_queue_process_stage_0(&ev);
@@ -73,7 +73,7 @@ order_queue_worker_burst(void *arg, const bool flow_id_cap)
 		for (i = 0; i < nb_rx; i++) {
 
 			if (!flow_id_cap)
-				ev[i].flow_id = ev[i].mbuf->udata64;
+				order_flow_id_copy_from_mbuf(t, &ev[i]);
 
 			if (ev[i].queue_id == 0) { /* from ordered queue */
 				order_queue_process_stage_0(&ev[i]);
-- 
2.28.0