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 02258A04DD;
	Mon, 26 Oct 2020 23:23:58 +0100 (CET)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id 06F8C4CA6;
	Mon, 26 Oct 2020 23:20:58 +0100 (CET)
Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com
 [66.111.4.27]) by dpdk.org (Postfix) with ESMTP id 567D84C6C
 for <dev@dpdk.org>; Mon, 26 Oct 2020 23:20:49 +0100 (CET)
Received: from compute2.internal (compute2.nyi.internal [10.202.2.42])
 by mailout.nyi.internal (Postfix) with ESMTP id EB40D5C0174;
 Mon, 26 Oct 2020 18:20:47 -0400 (EDT)
Received: from mailfrontend2 ([10.202.2.163])
 by compute2.internal (MEProxy); Mon, 26 Oct 2020 18:20:47 -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=Ya2HrAbpT+eOo
 k9Jcb/mBGWRQ+5W3AnEcgyH7RH7G5w=; b=ajxEnV2n7KV9Q/XXUKPGyBiKIQHuP
 hyCGKhA6I8wM8moMDBoBfA7sGV2uNQnlKewCeQJtIWb5h3TUEOp2Nem/WLTqRlEP
 6eL90ny8SzJQHp8jbw9TApFjhkB0FHmk1fpvhDtARKlg07I0LECvLl7ssQeXnT7c
 77Ds2xhJOl9iDjLX7j3VNd3a/OSg1vYRZo6cRkxyjZeTWzCoa1tkRnsjsK9EkW+J
 xx5f84eXSDPs8iatEXuGAq8lBVb2wwTHLGWZcNstXmG41Rd7a/+5YNsrHP+51mPx
 oYuvasA5zj88ghJ34WOnHIMeMwY8L6eOfuSC+Jh2hyq7QycdGS5YLzvCQ==
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=Ya2HrAbpT+eOok9Jcb/mBGWRQ+5W3AnEcgyH7RH7G5w=; b=RwH9Hz6w
 1XbGpuE3QNoqxPmxF4zrUfXEvxGHmca9FWsMczdTX5qxvqlVD8Ez1pp7GmNM5NMK
 /iqz6mtgWdACYPvexzjsxy2pxviCL3J8DLvQZDYOzQAWdy6FFuJTuF+sAmLGuuEY
 v0ipgB1Txe12hUaJX+qtMyd9+InuJpTwMACnZt8/Hl/AyQEjSygRqNpNTb61raQf
 4/QE11td6O4VoyL4CAQmiyGLuThMpsjzqZhAkuO3RrQEotgIYrWkO1eVajDaYNFc
 IKJvcFPz53gL20yZDyv/8q202Pv0fCQLyfWspqlUysQjUcPq/OxmV/ib6BGCDg4X
 RnQULy4cOwsKyA==
X-ME-Sender: <xms:v0uXX8EimZ3hBIeBHIViyBGK3CM-Oy8TIKEIHi6bqLQaxreCvi8OXQ>
 <xme:v0uXX1VOT1-R8F9ppBBpMij8RYghzhGeJl3A2pk99_JzAlbTOUd_m6hIQtequOCiu
 _IUAdQqefOvSzK7fg>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrkeejgdduvdegucetufdoteggodetrfdotf
 fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen
 uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne
 cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefvhhhomhgr
 shcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqnecugg
 ftrfgrthhtvghrnhepvdehgfeivdejgedtveehfefhteelfefgieevgfffveefjeegtdfg
 uedthedtgeevnecukfhppeejjedrudefgedrvddtfedrudekgeenucevlhhushhtvghruf
 hiiigvpeelnecurfgrrhgrmhepmhgrihhlfhhrohhmpehthhhomhgrshesmhhonhhjrghl
 ohhnrdhnvght
X-ME-Proxy: <xmx:v0uXX2IQ4bhHdLwBYdyX2yWLlNBn9RauMcJdSbzhY3FSXFfAWj-npw>
 <xmx:v0uXX-Fxx0ezF3MOOQlxMI9Jjyn--KyFCl06GgxPknbnWPqGfNHo4g>
 <xmx:v0uXXyVn6xUe6rW3hKuzb49_DPt-dqkoze850r10wVhbOrLU_ZRwxQ>
 <xmx:v0uXX9EXrSIuxVskyIiXXrXogEyCnOsD4rNJl9AdqEw66Hf6kbOWdw>
Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184])
 by mail.messagingengine.com (Postfix) with ESMTPA id C0279306467E;
 Mon, 26 Oct 2020 18:20:46 -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,
 Jerin Jacob <jerinj@marvell.com>, Kiran Kumar K <kirankumark@marvell.com>,
 Nithin Dabilpuram <ndabilpuram@marvell.com>
Date: Mon, 26 Oct 2020 23:20:09 +0100
Message-Id: <20201026222013.2147904-12-thomas@monjalon.net>
X-Mailer: git-send-email 2.28.0
In-Reply-To: <20201026222013.2147904-1-thomas@monjalon.net>
References: <20201026052105.1561859-1-thomas@monjalon.net>
 <20201026222013.2147904-1-thomas@monjalon.net>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Subject: [dpdk-dev] [PATCH v2 11/15] test/graph: switch user data 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 test used 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/test_graph.c | 94 ++++++++++++++++++++++++++-----------------
 1 file changed, 56 insertions(+), 38 deletions(-)

diff --git a/app/test/test_graph.c b/app/test/test_graph.c
index ed69eda997..d6b9e368e0 100644
--- a/app/test/test_graph.c
+++ b/app/test/test_graph.c
@@ -12,6 +12,7 @@
 #include <rte_graph.h>
 #include <rte_graph_worker.h>
 #include <rte_mbuf.h>
+#include <rte_mbuf_dyn.h>
 #include <rte_random.h>
 
 #include "test.h"
@@ -39,6 +40,11 @@ static uint16_t test_node3_worker(struct rte_graph *graph,
 #define MBUFF_SIZE 512
 #define MAX_NODES  4
 
+static int graph_dynfield_offset;
+#define GRAPH_FIELD_TYPE uint64_t
+#define GRAPH_FIELD(mbuf) (*RTE_MBUF_DYNFIELD(mbuf, \
+		graph_dynfield_offset, GRAPH_FIELD_TYPE *))
+
 static struct rte_mbuf mbuf[MAX_NODES + 1][MBUFF_SIZE];
 static void *mbuf_p[MAX_NODES + 1][MBUFF_SIZE];
 static rte_graph_t graph_id;
@@ -162,9 +168,9 @@ test_node_worker_source(struct rte_graph *graph, struct rte_node *node,
 	next_stream = rte_node_next_stream_get(graph, node, next, obj_node0);
 	for (i = 0; i < obj_node0; i++) {
 		data = &mbuf[0][i];
-		data->udata64 = ((uint64_t)tm->test_node[0].idx << 32) | i;
+		GRAPH_FIELD(data) = ((uint64_t)tm->test_node[0].idx << 32) | i;
 		if ((i + 1) == obj_node0)
-			data->udata64 |= (1 << 16);
+			GRAPH_FIELD(data) |= (1 << 16);
 		next_stream[i] = &mbuf[0][i];
 	}
 	rte_node_next_stream_put(graph, node, next, obj_node0);
@@ -175,9 +181,9 @@ test_node_worker_source(struct rte_graph *graph, struct rte_node *node,
 	next_stream = rte_node_next_stream_get(graph, node, next, obj_node1);
 	for (i = 0; i < obj_node1; i++) {
 		data = &mbuf[0][obj_node0 + i];
-		data->udata64 = ((uint64_t)tm->test_node[1].idx << 32) | i;
+		GRAPH_FIELD(data) = ((uint64_t)tm->test_node[1].idx << 32) | i;
 		if ((i + 1) == obj_node1)
-			data->udata64 |= (1 << 16);
+			GRAPH_FIELD(data) |= (1 << 16);
 		next_stream[i] = &mbuf[0][obj_node0 + i];
 	}
 
@@ -205,23 +211,23 @@ test_node0_worker(struct rte_graph *graph, struct rte_node *node, void **objs,
 
 		for (i = 0; i < nb_objs; i++) {
 			data = (struct rte_mbuf *)objs[i];
-			if ((data->udata64 >> 32) != tm->test_node[0].idx) {
+			if ((GRAPH_FIELD(data) >> 32) != tm->test_node[0].idx) {
 				printf("Data idx miss match at node 0, expected"
 				       " = %u got = %u\n",
 				       tm->test_node[0].idx,
-				       (uint32_t)(data->udata64 >> 32));
+				       (uint32_t)(GRAPH_FIELD(data) >> 32));
 				goto end;
 			}
 
-			if ((data->udata64 & 0xffff) != (i - count)) {
+			if ((GRAPH_FIELD(data) & 0xffff) != (i - count)) {
 				printf("Expected buff count miss match at "
 				       "node 0\n");
 				goto end;
 			}
 
-			if (data->udata64 & (0x1 << 16))
+			if (GRAPH_FIELD(data) & (0x1 << 16))
 				count = i + 1;
-			if (data->udata64 & (0x1 << 17))
+			if (GRAPH_FIELD(data) & (0x1 << 17))
 				second_pass = 1;
 		}
 
@@ -233,12 +239,12 @@ test_node0_worker(struct rte_graph *graph, struct rte_node *node, void **objs,
 		obj_node0 = nb_objs * obj_node0 * 0.01;
 		for (i = 0; i < obj_node0; i++) {
 			data = &mbuf[1][i];
-			data->udata64 =
+			GRAPH_FIELD(data) =
 				((uint64_t)tm->test_node[1].idx << 32) | i;
 			if ((i + 1) == obj_node0)
-				data->udata64 |= (1 << 16);
+				GRAPH_FIELD(data) |= (1 << 16);
 			if (second_pass)
-				data->udata64 |= (1 << 17);
+				GRAPH_FIELD(data) |= (1 << 17);
 		}
 		rte_node_enqueue(graph, node, 0, (void **)&mbuf_p[1][0],
 				 obj_node0);
@@ -246,12 +252,12 @@ test_node0_worker(struct rte_graph *graph, struct rte_node *node, void **objs,
 		obj_node1 = nb_objs - obj_node0;
 		for (i = 0; i < obj_node1; i++) {
 			data = &mbuf[1][obj_node0 + i];
-			data->udata64 =
+			GRAPH_FIELD(data) =
 				((uint64_t)tm->test_node[2].idx << 32) | i;
 			if ((i + 1) == obj_node1)
-				data->udata64 |= (1 << 16);
+				GRAPH_FIELD(data) |= (1 << 16);
 			if (second_pass)
-				data->udata64 |= (1 << 17);
+				GRAPH_FIELD(data) |= (1 << 17);
 		}
 		rte_node_enqueue(graph, node, 1, (void **)&mbuf_p[1][obj_node0],
 				 obj_node1);
@@ -285,22 +291,22 @@ test_node1_worker(struct rte_graph *graph, struct rte_node *node, void **objs,
 	fn_calls[2] += 1;
 	for (i = 0; i < nb_objs; i++) {
 		data = (struct rte_mbuf *)objs[i];
-		if ((data->udata64 >> 32) != tm->test_node[1].idx) {
+		if ((GRAPH_FIELD(data) >> 32) != tm->test_node[1].idx) {
 			printf("Data idx miss match at node 1, expected = %u"
 			       " got = %u\n",
 			       tm->test_node[1].idx,
-			       (uint32_t)(data->udata64 >> 32));
+			       (uint32_t)(GRAPH_FIELD(data) >> 32));
 			goto end;
 		}
 
-		if ((data->udata64 & 0xffff) != (i - count)) {
+		if ((GRAPH_FIELD(data) & 0xffff) != (i - count)) {
 			printf("Expected buff count miss match at node 1\n");
 			goto end;
 		}
 
-		if (data->udata64 & (0x1 << 16))
+		if (GRAPH_FIELD(data) & (0x1 << 16))
 			count = i + 1;
-		if (data->udata64 & (0x1 << 17))
+		if (GRAPH_FIELD(data) & (0x1 << 17))
 			second_pass = 1;
 	}
 
@@ -312,11 +318,11 @@ test_node1_worker(struct rte_graph *graph, struct rte_node *node, void **objs,
 	obj_node0 = nb_objs;
 	for (i = 0; i < obj_node0; i++) {
 		data = &mbuf[2][i];
-		data->udata64 = ((uint64_t)tm->test_node[2].idx << 32) | i;
+		GRAPH_FIELD(data) = ((uint64_t)tm->test_node[2].idx << 32) | i;
 		if ((i + 1) == obj_node0)
-			data->udata64 |= (1 << 16);
+			GRAPH_FIELD(data) |= (1 << 16);
 		if (second_pass)
-			data->udata64 |= (1 << 17);
+			GRAPH_FIELD(data) |= (1 << 17);
 	}
 	rte_node_enqueue(graph, node, 0, (void **)&mbuf_p[2][0], obj_node0);
 
@@ -339,22 +345,22 @@ test_node2_worker(struct rte_graph *graph, struct rte_node *node, void **objs,
 	fn_calls[3] += 1;
 	for (i = 0; i < nb_objs; i++) {
 		data = (struct rte_mbuf *)objs[i];
-		if ((data->udata64 >> 32) != tm->test_node[2].idx) {
+		if ((GRAPH_FIELD(data) >> 32) != tm->test_node[2].idx) {
 			printf("Data idx miss match at node 2, expected = %u"
 			       " got = %u\n",
 			       tm->test_node[2].idx,
-			       (uint32_t)(data->udata64 >> 32));
+			       (uint32_t)(GRAPH_FIELD(data) >> 32));
 			goto end;
 		}
 
-		if ((data->udata64 & 0xffff) != (i - count)) {
+		if ((GRAPH_FIELD(data) & 0xffff) != (i - count)) {
 			printf("Expected buff count miss match at node 2\n");
 			goto end;
 		}
 
-		if (data->udata64 & (0x1 << 16))
+		if (GRAPH_FIELD(data) & (0x1 << 16))
 			count = i + 1;
-		if (data->udata64 & (0x1 << 17))
+		if (GRAPH_FIELD(data) & (0x1 << 17))
 			second_pass = 1;
 	}
 
@@ -367,10 +373,10 @@ test_node2_worker(struct rte_graph *graph, struct rte_node *node, void **objs,
 		obj_node0 = nb_objs;
 		for (i = 0; i < obj_node0; i++) {
 			data = &mbuf[3][i];
-			data->udata64 =
+			GRAPH_FIELD(data) =
 				((uint64_t)tm->test_node[3].idx << 32) | i;
 			if ((i + 1) == obj_node0)
-				data->udata64 |= (1 << 16);
+				GRAPH_FIELD(data) |= (1 << 16);
 		}
 		rte_node_enqueue(graph, node, 0, (void **)&mbuf_p[3][0],
 				 obj_node0);
@@ -395,22 +401,22 @@ test_node3_worker(struct rte_graph *graph, struct rte_node *node, void **objs,
 	fn_calls[4] += 1;
 	for (i = 0; i < nb_objs; i++) {
 		data = (struct rte_mbuf *)objs[i];
-		if ((data->udata64 >> 32) != tm->test_node[3].idx) {
+		if ((GRAPH_FIELD(data) >> 32) != tm->test_node[3].idx) {
 			printf("Data idx miss match at node 3, expected = %u"
 			       " got = %u\n",
 			       tm->test_node[3].idx,
-			       (uint32_t)(data->udata64 >> 32));
+			       (uint32_t)(GRAPH_FIELD(data) >> 32));
 			goto end;
 		}
 
-		if ((data->udata64 & 0xffff) != (i - count)) {
+		if ((GRAPH_FIELD(data) & 0xffff) != (i - count)) {
 			printf("Expected buff count miss match at node 3\n");
 			goto end;
 		}
 
-		if (data->udata64 & (0x1 << 16))
+		if (GRAPH_FIELD(data) & (0x1 << 16))
 			count = i + 1;
-		if (data->udata64 & (0x1 << 17))
+		if (GRAPH_FIELD(data) & (0x1 << 17))
 			second_pass = 1;
 	}
 
@@ -426,11 +432,11 @@ test_node3_worker(struct rte_graph *graph, struct rte_node *node, void **objs,
 		obj_node0 = nb_objs * 2;
 		for (i = 0; i < obj_node0; i++) {
 			data = &mbuf[4][i];
-			data->udata64 =
+			GRAPH_FIELD(data) =
 				((uint64_t)tm->test_node[0].idx << 32) | i;
-			data->udata64 |= (1 << 17);
+			GRAPH_FIELD(data) |= (1 << 17);
 			if ((i + 1) == obj_node0)
-				data->udata64 |= (1 << 16);
+				GRAPH_FIELD(data) |= (1 << 16);
 		}
 		rte_node_enqueue(graph, node, 0, (void **)&mbuf_p[4][0],
 				 obj_node0);
@@ -765,6 +771,18 @@ graph_setup(void)
 {
 	int i, j;
 
+	static const struct rte_mbuf_dynfield graph_dynfield_desc = {
+		.name = "test_graph_dynfield",
+		.size = sizeof(GRAPH_FIELD_TYPE),
+		.align = __alignof__(GRAPH_FIELD_TYPE),
+	};
+	graph_dynfield_offset =
+		rte_mbuf_dynfield_register(&graph_dynfield_desc);
+	if (graph_dynfield_offset < 0) {
+		printf("Cannot register mbuf field\n");
+		return TEST_FAILED;
+	}
+
 	for (i = 0; i <= MAX_NODES; i++) {
 		for (j = 0; j < MBUFF_SIZE; j++)
 			mbuf_p[i][j] = &mbuf[i][j];
-- 
2.28.0