From: Nitin Saxena <nsaxena@marvell.com>
To: Nithin Dabilpuram <ndabilpuram@marvell.com>,
Pavan Nikhilesh <pbhagavatula@marvell.com>,
Robin Jarry <rjarry@redhat.com>,
"Christophe Fontaine" <cfontain@redhat.com>
Cc: <dev@dpdk.org>, Jerin Jacob <jerinj@marvell.com>,
Nitin Saxena <nsaxena16@gmail.com>
Subject: [PATCH v3 2/2] node: use node mbuf dynfield in ip4 nodes
Date: Fri, 4 Apr 2025 12:42:22 +0530 [thread overview]
Message-ID: <20250404071228.893308-3-nsaxena@marvell.com> (raw)
In-Reply-To: <20250404071228.893308-1-nsaxena@marvell.com>
- Used global node mbuf in ip[4|6]_lookup/rewrite nodes
- Redefine node_mbuf_priv1() to rte_node_mbuf_overload_fields_get()
Signed-off-by: Nitin Saxena <nsaxena@marvell.com>
---
lib/node/ip4_lookup.c | 14 ++++-------
lib/node/ip4_rewrite.c | 15 +++++-------
lib/node/ip6_lookup.c | 15 +++++-------
lib/node/ip6_rewrite.c | 14 ++++-------
lib/node/node_private.h | 40 +++----------------------------
lib/node/rte_node_mbuf_dynfield.h | 9 +++++++
6 files changed, 34 insertions(+), 73 deletions(-)
diff --git a/lib/node/ip4_lookup.c b/lib/node/ip4_lookup.c
index 0b474cd2bc..7e9d21a9c9 100644
--- a/lib/node/ip4_lookup.c
+++ b/lib/node/ip4_lookup.c
@@ -31,8 +31,6 @@ struct ip4_lookup_node_ctx {
int mbuf_priv1_off;
};
-int node_mbuf_priv1_dynfield_offset = -1;
-
static struct ip4_lookup_node_main ip4_lookup_nm;
#define IP4_LOOKUP_NODE_LPM(ctx) \
@@ -180,17 +178,15 @@ ip4_lookup_node_init(const struct rte_graph *graph, struct rte_node *node)
{
uint16_t socket, lcore_id;
static uint8_t init_once;
- int rc;
+ int rc, dyn;
RTE_SET_USED(graph);
RTE_BUILD_BUG_ON(sizeof(struct ip4_lookup_node_ctx) > RTE_NODE_CTX_SZ);
+ dyn = rte_node_mbuf_dynfield_register();
+ if (dyn < 0)
+ return -rte_errno;
if (!init_once) {
- node_mbuf_priv1_dynfield_offset = rte_mbuf_dynfield_register(
- &node_mbuf_priv1_dynfield_desc);
- if (node_mbuf_priv1_dynfield_offset < 0)
- return -rte_errno;
-
/* Setup LPM tables for all sockets */
RTE_LCORE_FOREACH(lcore_id)
{
@@ -208,7 +204,7 @@ ip4_lookup_node_init(const struct rte_graph *graph, struct rte_node *node)
/* Update socket's LPM and mbuf dyn priv1 offset in node ctx */
IP4_LOOKUP_NODE_LPM(node->ctx) = ip4_lookup_nm.lpm_tbl[graph->socket];
- IP4_LOOKUP_NODE_PRIV1_OFF(node->ctx) = node_mbuf_priv1_dynfield_offset;
+ IP4_LOOKUP_NODE_PRIV1_OFF(node->ctx) = dyn;
#if defined(__ARM_NEON) || defined(RTE_ARCH_X86)
if (rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_128)
diff --git a/lib/node/ip4_rewrite.c b/lib/node/ip4_rewrite.c
index 34a920df5e..b05decc1a3 100644
--- a/lib/node/ip4_rewrite.c
+++ b/lib/node/ip4_rewrite.c
@@ -258,19 +258,16 @@ ip4_rewrite_node_process(struct rte_graph *graph, struct rte_node *node,
static int
ip4_rewrite_node_init(const struct rte_graph *graph, struct rte_node *node)
{
- static bool init_once;
+ int dyn;
RTE_SET_USED(graph);
RTE_BUILD_BUG_ON(sizeof(struct ip4_rewrite_node_ctx) > RTE_NODE_CTX_SZ);
- if (!init_once) {
- node_mbuf_priv1_dynfield_offset = rte_mbuf_dynfield_register(
- &node_mbuf_priv1_dynfield_desc);
- if (node_mbuf_priv1_dynfield_offset < 0)
- return -rte_errno;
- init_once = true;
- }
- IP4_REWRITE_NODE_PRIV1_OFF(node->ctx) = node_mbuf_priv1_dynfield_offset;
+ dyn = rte_node_mbuf_dynfield_register();
+ if (dyn < 0)
+ return -rte_errno;
+
+ IP4_REWRITE_NODE_PRIV1_OFF(node->ctx) = dyn;
node_dbg("ip4_rewrite", "Initialized ip4_rewrite node initialized");
diff --git a/lib/node/ip6_lookup.c b/lib/node/ip6_lookup.c
index f378d2d064..c140aa9cf3 100644
--- a/lib/node/ip6_lookup.c
+++ b/lib/node/ip6_lookup.c
@@ -316,18 +316,16 @@ ip6_lookup_node_init(const struct rte_graph *graph, struct rte_node *node)
{
uint16_t socket, lcore_id;
static uint8_t init_once;
- int rc;
+ int rc, dyn;
RTE_SET_USED(graph);
RTE_BUILD_BUG_ON(sizeof(struct ip6_lookup_node_ctx) > RTE_NODE_CTX_SZ);
- if (!init_once) {
- node_mbuf_priv1_dynfield_offset =
- rte_mbuf_dynfield_register(
- &node_mbuf_priv1_dynfield_desc);
- if (node_mbuf_priv1_dynfield_offset < 0)
- return -rte_errno;
+ dyn = rte_node_mbuf_dynfield_register();
+ if (dyn < 0)
+ return -rte_errno;
+ if (!init_once) {
/* Setup LPM tables for all sockets */
RTE_LCORE_FOREACH(lcore_id)
{
@@ -345,8 +343,7 @@ ip6_lookup_node_init(const struct rte_graph *graph, struct rte_node *node)
/* Update socket's LPM and mbuf dyn priv1 offset in node ctx */
IP6_LOOKUP_NODE_LPM(node->ctx) = ip6_lookup_nm.lpm_tbl[graph->socket];
- IP6_LOOKUP_NODE_PRIV1_OFF(node->ctx) =
- node_mbuf_priv1_dynfield_offset;
+ IP6_LOOKUP_NODE_PRIV1_OFF(node->ctx) = dyn;
node_dbg("ip6_lookup", "Initialized ip6_lookup node");
diff --git a/lib/node/ip6_rewrite.c b/lib/node/ip6_rewrite.c
index 198d8d8820..b9e223ab3a 100644
--- a/lib/node/ip6_rewrite.c
+++ b/lib/node/ip6_rewrite.c
@@ -242,19 +242,15 @@ ip6_rewrite_node_process(struct rte_graph *graph, struct rte_node *node,
static int
ip6_rewrite_node_init(const struct rte_graph *graph, struct rte_node *node)
{
- static bool init_once;
+ int dyn;
RTE_SET_USED(graph);
RTE_BUILD_BUG_ON(sizeof(struct ip6_rewrite_node_ctx) > RTE_NODE_CTX_SZ);
- if (!init_once) {
- node_mbuf_priv1_dynfield_offset = rte_mbuf_dynfield_register(
- &node_mbuf_priv1_dynfield_desc);
- if (node_mbuf_priv1_dynfield_offset < 0)
- return -rte_errno;
- init_once = true;
- }
- IP6_REWRITE_NODE_PRIV1_OFF(node->ctx) = node_mbuf_priv1_dynfield_offset;
+ dyn = rte_node_mbuf_dynfield_register();
+ if (dyn < 0)
+ return -rte_errno;
+ IP6_REWRITE_NODE_PRIV1_OFF(node->ctx) = dyn;
node_dbg("ip6_rewrite", "Initialized ip6_rewrite node");
diff --git a/lib/node/node_private.h b/lib/node/node_private.h
index 4fafab19be..7fb2aff0b8 100644
--- a/lib/node/node_private.h
+++ b/lib/node/node_private.h
@@ -13,6 +13,7 @@
#include <rte_mbuf_dyn.h>
#include <rte_graph_worker_common.h>
+#include <rte_node_mbuf_dynfield.h>
extern int rte_node_logtype;
#define RTE_LOGTYPE_NODE rte_node_logtype
@@ -26,28 +27,8 @@ extern int rte_node_logtype;
#define node_info(node_name, ...) NODE_LOG(INFO, node_name, __VA_ARGS__)
#define node_dbg(node_name, ...) NODE_LOG(DEBUG, node_name, __VA_ARGS__)
-/**
- * Node mbuf private data to store next hop, ttl and checksum.
- */
-struct node_mbuf_priv1 {
- union {
- /* IP4/IP6 rewrite */
- struct {
- uint16_t nh;
- uint16_t ttl;
- uint32_t cksum;
- };
-
- uint64_t u;
- };
-};
-
-static const struct rte_mbuf_dynfield node_mbuf_priv1_dynfield_desc = {
- .name = "rte_node_dynfield_priv1",
- .size = sizeof(struct node_mbuf_priv1),
- .align = alignof(struct node_mbuf_priv1),
-};
-extern int node_mbuf_priv1_dynfield_offset;
+/* define internal function used by nodes */
+#define node_mbuf_priv1 rte_node_mbuf_overload_fields_get
/**
* Node mbuf private area 2.
@@ -60,21 +41,6 @@ struct __rte_cache_aligned node_mbuf_priv2 {
#define OBJS_PER_CLINE (RTE_CACHE_LINE_SIZE / sizeof(void *))
-/**
- * Get mbuf_priv1 pointer from rte_mbuf.
- *
- * @param
- * Pointer to the rte_mbuf.
- *
- * @return
- * Pointer to the mbuf_priv1.
- */
-static __rte_always_inline struct node_mbuf_priv1 *
-node_mbuf_priv1(struct rte_mbuf *m, const int offset)
-{
- return RTE_MBUF_DYNFIELD(m, offset, struct node_mbuf_priv1 *);
-}
-
/**
* Get mbuf_priv2 pointer from rte_mbuf.
*
diff --git a/lib/node/rte_node_mbuf_dynfield.h b/lib/node/rte_node_mbuf_dynfield.h
index 4293b3823d..8dd6cfc401 100644
--- a/lib/node/rte_node_mbuf_dynfield.h
+++ b/lib/node/rte_node_mbuf_dynfield.h
@@ -36,6 +36,15 @@ extern "C" {
*/
typedef struct rte_node_mbuf_overload_fields {
union {
+ /* Following fields used by ip[4|6]-lookup -> ip[4|6]-rewrite nodes */
+ union {
+ struct {
+ uint16_t nh;
+ uint16_t ttl;
+ uint32_t cksum;
+ };
+ uint64_t u;
+ };
uint8_t data[RTE_NODE_MBUF_OVERLOADABLE_FIELDS_SIZE];
};
} rte_node_mbuf_overload_fields_t;
--
2.43.0
next prev parent reply other threads:[~2025-04-04 7:12 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-01 4:20 [PATCH 0/2] node: add mbuf dynamic field for nodes Nitin Saxena
2025-04-01 4:20 ` [PATCH 1/2] node: add global node mbuf dynfield Nitin Saxena
2025-04-01 14:15 ` Stephen Hemminger
2025-04-03 10:27 ` Nitin Saxena
2025-04-04 8:11 ` [EXTERNAL] " Pavan Nikhilesh Bhagavatula
2025-04-04 15:21 ` Stephen Hemminger
2025-04-07 6:01 ` Nitin Saxena
2025-04-01 4:20 ` [PATCH 2/2] node: use node mbuf dynfield in ip4 nodes Nitin Saxena
2025-04-03 10:17 ` [PATCH v2 0/2] node: add mbuf dynamic field for nodes Nitin Saxena
2025-04-03 10:17 ` [PATCH v2 1/2] node: add global node mbuf dynfield Nitin Saxena
2025-04-03 10:17 ` [PATCH v2 2/2] node: use node mbuf dynfield in ip4 nodes Nitin Saxena
2025-04-04 7:12 ` [PATCH v3 0/2] node: add mbuf dynamic field for nodes Nitin Saxena
2025-04-04 7:12 ` [PATCH v3 1/2] node: add global node mbuf dynfield Nitin Saxena
2025-04-04 21:35 ` Stephen Hemminger
2025-04-04 7:12 ` Nitin Saxena [this message]
2025-04-07 7:47 ` [PATCH v4 0/2] node: add mbuf dynamic field for nodes Nitin Saxena
2025-04-07 7:47 ` [PATCH v4 1/2] node: add global node mbuf dynfield Nitin Saxena
2025-04-07 7:47 ` [PATCH v4 2/2] node: use node mbuf dynfield in ip4 nodes Nitin Saxena
2025-04-08 7:35 ` [PATCH v4 0/2] node: add mbuf dynamic field for nodes David Marchand
2025-04-08 8:42 ` Nitin Saxena
2025-04-09 13:55 ` [PATCH v5 " Nitin Saxena
2025-04-09 13:55 ` [PATCH v5 1/2] node: add global node mbuf dynfield Nitin Saxena
2025-04-18 19:03 ` Pavan Nikhilesh Bhagavatula
2025-04-28 10:42 ` Nitin Saxena
2025-04-09 13:55 ` [PATCH v5 2/2] node: use node mbuf dynfield in ip4 nodes Nitin Saxena
2025-04-28 10:37 ` [PATCH v6 0/2] node: add mbuf dynamic field for nodes Nitin Saxena
2025-04-28 10:37 ` [PATCH v6 1/2] node: add global node mbuf dynfield Nitin Saxena
2025-05-09 7:16 ` Pavan Nikhilesh Bhagavatula
2025-04-28 10:37 ` [PATCH v6 2/2] node: use node mbuf dynfield in ip4 nodes Nitin Saxena
2025-05-09 7:17 ` Pavan Nikhilesh Bhagavatula
2025-05-05 17:20 ` [PATCH v6 0/2] node: add mbuf dynamic field for nodes Pavan Nikhilesh Bhagavatula
2025-06-11 11:45 ` Thomas Monjalon
2025-06-19 15:51 ` Nitin Saxena
2025-06-19 15:44 ` [PATCH v7 " Nitin Saxena
2025-06-19 15:44 ` [PATCH v7 1/2] node: add global node mbuf dynfield Nitin Saxena
2025-06-26 13:59 ` Stephen Hemminger
2025-06-26 14:14 ` Nitin Saxena
2025-06-27 21:36 ` Thomas Monjalon
2025-06-19 15:44 ` [PATCH v7 2/2] node: use node mbuf dynfield in ip4 nodes Nitin Saxena
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250404071228.893308-3-nsaxena@marvell.com \
--to=nsaxena@marvell.com \
--cc=cfontain@redhat.com \
--cc=dev@dpdk.org \
--cc=jerinj@marvell.com \
--cc=ndabilpuram@marvell.com \
--cc=nsaxena16@gmail.com \
--cc=pbhagavatula@marvell.com \
--cc=rjarry@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.