From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1AE51A04DD; Wed, 28 Oct 2020 11:30:39 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E1A52CA4E; Wed, 28 Oct 2020 11:27:34 +0100 (CET) Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by dpdk.org (Postfix) with ESMTP id 5312CC9EE for ; Wed, 28 Oct 2020 11:27:25 +0100 (CET) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 059ED5C0189; Wed, 28 Oct 2020 06:27:24 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Wed, 28 Oct 2020 06:27:24 -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=gCnFlPwlPHUt5 Qjmew/qeycaqOI5GSF2L7hRxaoB3vc=; b=edix0yg6I/UIT5vElekZ4RK4rVxxF wI0leWSP4t4qbPewXcu4ywmI4WWNR7PLuBMqsdrZJjjCdVD4RZNeBDRZbKzzbTpW ZQQKaZV/EGAgwZx0tKP16fhxcXQAeBO9U4MOwIUq8wIOCzsMCXcr1J205WTTfKpE 6egZmd/MP71j6ktpCIXMPVXM8edPrMy634wMlEfNoChbC1hlbCxJbxd1K5pStnYY LJ9tIqBfVU7BMBlOtz1DICXDlFs4hemgLlMrlZF+Ff/lfwPXHvJtMMzNpaOzfCKp a2xSuIL2dLJuMTO/Txi0FKlFZEbhm39owIQSpDYEzsUnk6lOgoo0AXTRQ== 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=gCnFlPwlPHUt5Qjmew/qeycaqOI5GSF2L7hRxaoB3vc=; b=OWLMV8lA kHCdxXzsCjkruVbSaSqY7+2VnzGysjZdgbzZdwUBKqJdisZAIfGwWYy/lAxZNe6Y w6TbAB3+wMg7dYOHG8jaQW2ejIHn0tDBPOFQxG+2AeDMoR3EqejXqja6Q9U/RKEo Es6jDOmY6OAbfEVKTTMtqUmxDfylpK5gT2VP/j+kK9WwblD6JnoFCZuSr9eJrTMQ Lg6HKGIF1Z6YB8fH8tXilzCPnkvGSMCdZi3BsO8HfPkvPsB3HA5Uoc/52ALfhCGz c7yr91qADyFcGvnw2T8BLRhIXK8+US9q4Df6cXSBFLNtvm+TuQTIRiPDEQ0SOJgU hkDKSTwtoUIBDA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrledugdduhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepvfhhohhmrghs ucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenucggtf frrghtthgvrhhnpedvhefgiedvjeegtdevheefhfetleefgfeivefgffevfeejgedtgfeu tdehtdegveenucfkphepjeejrddufeegrddvtdefrddukeegnecuvehluhhsthgvrhfuih iivgepieenucfrrghrrghmpehmrghilhhfrhhomhepthhhohhmrghssehmohhnjhgrlhho nhdrnhgvth 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 C03FA3280059; Wed, 28 Oct 2020 06:27:22 -0400 (EDT) From: Thomas Monjalon 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 , Kiran Kumar K , Nithin Dabilpuram Date: Wed, 28 Oct 2020 11:26:36 +0100 Message-Id: <20201028102640.3191964-12-thomas@monjalon.net> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201028102640.3191964-1-thomas@monjalon.net> References: <20201026052105.1561859-1-thomas@monjalon.net> <20201028102640.3191964-1-thomas@monjalon.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v4 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 --- 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..164486911f 100644 --- a/app/test/test_graph.c +++ b/app/test/test_graph.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #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 +typedef uint64_t graph_dynfield_t; +static int graph_dynfield_offset = -1; +#define GRAPH_FIELD(mbuf) (*RTE_MBUF_DYNFIELD(mbuf, \ + graph_dynfield_offset, graph_dynfield_t *)) + 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_dynfield_t), + .align = __alignof__(graph_dynfield_t), + }; + 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