DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH 0/2] node: add mbuf dynamic field for nodes
@ 2025-04-01  4:20 Nitin Saxena
  2025-04-01  4:20 ` [PATCH 1/2] node: add global node mbuf dynfield Nitin Saxena
  2025-04-01  4:20 ` [PATCH 2/2] node: use node mbuf dynfield in ip4 nodes Nitin Saxena
  0 siblings, 2 replies; 4+ messages in thread
From: Nitin Saxena @ 2025-04-01  4:20 UTC (permalink / raw)
  To: Nithin Dabilpuram, Pavan Nikhilesh, Robin Jarry, Christophe Fontaine
  Cc: dev, Jerin Jacob, Nitin Saxena

Currently each rte_node registers separate mbuf dynamic fields for their
own purpose. This leads to wastage of mbuf space as once mbuf get passed
a particular node, the registered dynamic field(by that node) is no
longer used.

This patch series adds a global/common mbuf dynamic field which is
reusable by all the nodes(including out-of-tree nodes). This helps to
repurpose same mbuf dynamic field for other nodes. It contains two types
of fields: (a) persistent (b) overloadable.

While persistent fields are those which does not often changes during a
graph walk such as rx/tx interface, buffer flags etc. Currently there
are no persistent fields added but they can be added later

Overloadable fields are those which can be overloaded by two adjacent
nodes. Overloadable fields can be repurposed by other two adjacent nodes.

This patch series also updates ip4/ip6 lookup/rewrite nodes to use
overlaodable mbuf dynamic fields.

Nitin Saxena (2):
  node: add global node mbuf dynfield
  node: use node mbuf dynfield in ip4 nodes

 doc/api/doxy-api-index.md              |   3 +-
 doc/guides/rel_notes/release_25_07.rst |   6 ++
 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/meson.build                   |   2 +
 lib/node/node_mbuf_dynfield.c          |  56 ++++++++++
 lib/node/node_private.h                |  40 +------
 lib/node/rte_node_mbuf_dynfield.h      | 139 +++++++++++++++++++++++++
 lib/node/version.map                   |   3 +
 11 files changed, 233 insertions(+), 74 deletions(-)
 create mode 100644 lib/node/node_mbuf_dynfield.c
 create mode 100644 lib/node/rte_node_mbuf_dynfield.h

--
2.43.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] node: add global node mbuf dynfield
  2025-04-01  4:20 [PATCH 0/2] node: add mbuf dynamic field for nodes Nitin Saxena
@ 2025-04-01  4:20 ` Nitin Saxena
  2025-04-01 14:15   ` Stephen Hemminger
  2025-04-01  4:20 ` [PATCH 2/2] node: use node mbuf dynfield in ip4 nodes Nitin Saxena
  1 sibling, 1 reply; 4+ messages in thread
From: Nitin Saxena @ 2025-04-01  4:20 UTC (permalink / raw)
  To: Nithin Dabilpuram, Pavan Nikhilesh, Robin Jarry, Christophe Fontaine
  Cc: dev, Jerin Jacob, Nitin Saxena

This patch defines rte_node specific dynamic field structure
(rte_node_mbuf_dynfield_t)

rte_node_mbuf_dynfield_t structure holds two types of fields
- Persistent data fields which are preserved across graph walk.
  Currently size of persistent data fields is zero.
- Overloadable data fields which are used by any two adjacent nodes.
  Same fields can be repurposed by any other adjacent nodes

This dynfield can be also be used by out-of-tree nodes.

Signed-off-by: Nitin Saxena <nsaxena@marvell.com>
---
 doc/api/doxy-api-index.md              |   3 +-
 doc/guides/rel_notes/release_25_07.rst |   6 ++
 lib/node/meson.build                   |   2 +
 lib/node/node_mbuf_dynfield.c          |  56 +++++++++++
 lib/node/rte_node_mbuf_dynfield.h      | 130 +++++++++++++++++++++++++
 lib/node/version.map                   |   3 +
 6 files changed, 199 insertions(+), 1 deletion(-)
 create mode 100644 lib/node/node_mbuf_dynfield.c
 create mode 100644 lib/node/rte_node_mbuf_dynfield.h

diff --git a/doc/api/doxy-api-index.md b/doc/api/doxy-api-index.md
index b2fc24b3e4..6b93b3cd97 100644
--- a/doc/api/doxy-api-index.md
+++ b/doc/api/doxy-api-index.md
@@ -219,7 +219,8 @@ The public API headers are grouped by topics:
     [ip4_node](@ref rte_node_ip4_api.h),
     [ip6_node](@ref rte_node_ip6_api.h),
     [udp4_input_node](@ref rte_node_udp4_input_api.h)
-
+  * graph_nodes_mbuf:
+    [node_mbuf_dynfield](@ref rte_node_mbuf_dynfield.h)
 - **basic**:
   [bitops](@ref rte_bitops.h),
   [approx fraction](@ref rte_approx.h),
diff --git a/doc/guides/rel_notes/release_25_07.rst b/doc/guides/rel_notes/release_25_07.rst
index cd1025aac0..72d5d88ff3 100644
--- a/doc/guides/rel_notes/release_25_07.rst
+++ b/doc/guides/rel_notes/release_25_07.rst
@@ -55,6 +55,12 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================

+* **Added rte_node specific global mbuf dynamic field.**
+
+  Instead each node registering mbuf dynamic field for its own purpose, a
+  global structure is added which can be used/overloaded by all nodes
+  (including out-of-tree nodes). This minimizes footprint of node specific mbuf
+  dynamic field.

 Removed Items
 -------------
diff --git a/lib/node/meson.build b/lib/node/meson.build
index 0bed97a96c..4330d0450b 100644
--- a/lib/node/meson.build
+++ b/lib/node/meson.build
@@ -8,6 +8,7 @@ if is_windows
 endif

 sources = files(
+        'node_mbuf_dynfield.c',
         'ethdev_ctrl.c',
         'ethdev_rx.c',
         'ethdev_tx.c',
@@ -30,6 +31,7 @@ headers = files(
         'rte_node_ip4_api.h',
         'rte_node_ip6_api.h',
         'rte_node_udp4_input_api.h',
+        'rte_node_mbuf_dynfield.h'
 )

 # Strict-aliasing rules are violated by uint8_t[] to context size casts.
diff --git a/lib/node/node_mbuf_dynfield.c b/lib/node/node_mbuf_dynfield.c
new file mode 100644
index 0000000000..e42631f432
--- /dev/null
+++ b/lib/node/node_mbuf_dynfield.c
@@ -0,0 +1,56 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2025 Marvell International Ltd.
+ */
+#include <rte_memzone.h>
+#include <rte_mbuf.h>
+#include <rte_mbuf_dyn.h>
+#include <rte_node_mbuf_dynfield.h>
+#include <node_private.h>
+
+#define NODE_MBUF_DYNFIELD_MEMZONE_NAME "__rte_node_mbuf_dynfield"
+
+struct node_mbuf_dynfield_mz {
+	int dynfield_offset;
+};
+
+static const struct rte_mbuf_dynfield node_mbuf_dynfield_desc = {
+	.name = "rte_node_mbuf_dynfield",
+	.size = sizeof(rte_node_mbuf_dynfield_t),
+	.align = alignof(rte_node_mbuf_dynfield_t),
+};
+
+int rte_node_mbuf_dynfield_register(void)
+{
+	struct node_mbuf_dynfield_mz *f = NULL;
+	const struct rte_memzone *mz = NULL;
+	int dyn_offset;
+
+	RTE_BUILD_BUG_ON(sizeof(rte_node_mbuf_dynfield_t) < RTE_NODE_MBUF_DYNFIELD_SIZE);
+	RTE_BUILD_BUG_ON(sizeof(rte_node_mbuf_overload_fields_t) <
+			 RTE_NODE_MBUF_OVERLOADABLE_FIELDS_SIZE);
+
+	mz = rte_memzone_lookup(NODE_MBUF_DYNFIELD_MEMZONE_NAME);
+
+	if (!mz) {
+		mz = rte_memzone_reserve(NODE_MBUF_DYNFIELD_MEMZONE_NAME,
+					 sizeof(struct node_mbuf_dynfield_mz),
+					 SOCKET_ID_ANY, 0);
+		if (!mz) {
+			node_err("node_mbuf_dyn", "memzone reserve failed for node mbuf field");
+			return -1;
+		}
+		dyn_offset = rte_mbuf_dynfield_register(&node_mbuf_dynfield_desc);
+		if (dyn_offset < 0) {
+			node_err("node_mbuf_dyn", "rte_mbuf_dynfield_register failed");
+			return -1;
+		}
+		f = (struct node_mbuf_dynfield_mz *)mz->addr;
+		f->dynfield_offset = dyn_offset;
+
+		node_dbg("node_mbuf_dyn", "memzone: %s of size 0x%zx at offset: %d",
+			 mz->name, mz->len, f->dynfield_offset);
+	} else {
+		f = (struct node_mbuf_dynfield_mz *)mz->addr;
+	}
+	return f->dynfield_offset;
+}
diff --git a/lib/node/rte_node_mbuf_dynfield.h b/lib/node/rte_node_mbuf_dynfield.h
new file mode 100644
index 0000000000..91eec33a56
--- /dev/null
+++ b/lib/node/rte_node_mbuf_dynfield.h
@@ -0,0 +1,130 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2025 Marvell International Ltd.
+ */
+
+#ifndef _RTE_GRAPH_MBUF_DYNFIELD_H_
+#define _RTE_GRAPH_MBUF_DYNFIELD_H_
+
+#include <rte_common.h>
+
+/**
+ * @file: rte_node_mbuf_dynfield.h
+ *
+ * Defines rte_node specific mbuf dynamic field region [rte_node_mbuf_dynfield_t] which
+ * can used by both DPDK in-built and out-of-tree nodes for storing per-mbuf
+ * fields for graph walk
+ */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** Size of persistent mbuf fields */
+#define RTE_NODE_MBUF_PERSISTENT_FIELDS_SIZE          (0)
+/** Size of overloadable mbuf fields */
+#define RTE_NODE_MBUF_OVERLOADABLE_FIELDS_SIZE        (16)
+/** Size of node mbuf dynamic field */
+#define RTE_NODE_MBUF_DYNFIELD_SIZE     \
+	(RTE_NODE_MBUF_PERSISTENT_FIELDS_SIZE + RTE_NODE_MBUF_OVERLOADABLE_FIELDS_SIZE)
+/**
+ * Node mbuf overloadable data.
+ *
+ * Out-of-tree nodes can repurpose overloadable fields via
+ * rte_node_mbuf_overload_fields_get(mbuf). Overloadable fields are not
+ * preserved and typically can be used with-in two adjacent nodes in the graph.
+ */
+typedef struct rte_node_mbuf_overload_fields {
+	union {
+		uint8_t data[RTE_NODE_MBUF_OVERLOADABLE_FIELDS_SIZE];
+	};
+} rte_node_mbuf_overload_fields_t;
+
+/**
+ * rte_node specific mbuf dynamic field structure [rte_node_mbuf_dynfield_t]
+ *
+ * It holds two types of fields:
+ * 1. Persistent fields: Fields which are preserved across nodes during graph walk.
+ *    - Eg: rx/tx interface etc
+ * 2. Overloadable fields: Fields which can be repurposed by two adjacent nodes.
+ */
+typedef struct rte_node_mbuf_dynfield {
+	/**
+	 * Persistent mbuf region across nodes in graph walk
+	 *
+	 * These fields are preserved across graph walk and can be accessed by
+	 * rte_node_mbuf_dynfield_get() in fast path.
+	 */
+	union {
+		uint8_t peristent_data[RTE_NODE_MBUF_PERSISTENT_FIELDS_SIZE];
+	};
+
+	/**
+	 * Overloadable mbuf fields across graph walk. Fields which can change
+	 *
+	 * Two adjacent nodes (producer, consumer) can use this memory region for
+	 * sharing per-mbuf specific information. Once mbuf leaves a consumer node,
+	 * this region can be repurposed by another sets of [producer, consumer] node.
+	 *
+	 * In fast path, this region can be accessed by rte_node_mbuf_overload_fields_get()
+	 */
+	rte_node_mbuf_overload_fields_t overloadable_data;
+} rte_node_mbuf_dynfield_t;
+
+/**
+ * For a given mbuf and dynamic offset, return pointer to rte_node_mbuf_dynfield_t *
+ *
+ * @param m
+ *   Mbuf
+ * @param offset
+ *   Dynamic offset returned by @ref rte_node_mbuf_dynfield_register()
+ */
+__rte_experimental
+static __rte_always_inline rte_node_mbuf_dynfield_t *
+rte_node_mbuf_dynfield_get(struct rte_mbuf *m, const int offset)
+{
+	return RTE_MBUF_DYNFIELD(m, offset, struct rte_node_mbuf_dynfield *);
+}
+
+/**
+ * For a given mbuf and dynamic offset, return pointer to overloadable fields
+ * Nodes can typecast returned pointer to reuse for their own purpose
+ *
+ * @param m
+ *   Mbuf
+ * @param offset
+ *   Dynamic offset returned by @ref rte_node_mbuf_dynfield_register()
+ */
+__rte_experimental
+static __rte_always_inline rte_node_mbuf_overload_fields_t *
+rte_node_mbuf_overload_fields_get(struct rte_mbuf *m, const int offset)
+{
+	struct rte_node_mbuf_dynfield *f = NULL;
+
+	f = RTE_MBUF_DYNFIELD(m, offset, struct rte_node_mbuf_dynfield *);
+
+	return &(f->overloadable_data);
+}
+
+/**
+ *  Registers common mbuf dynamic field region. Can be called in
+ *  rte_node_register()->init() function to save offset in node->ctx
+ *
+ *  In process() function, node->ctx can be passed to
+ *  - rte_node_mbuf_dynfield_get(mbuf, offset)
+ *  - rte_node_mbuf_overload_fields_get(mbuf, offset)
+ *
+ *  Can be called multiple times by any number of nodes.
+ *  - Very first call registers dynamic field and returns offset
+ *  - Subsequent calls return same offset
+ *
+ *  @return
+ *   -1 on error
+ *   dynamic field offset on success
+ */
+__rte_experimental
+int rte_node_mbuf_dynfield_register(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/lib/node/version.map b/lib/node/version.map
index a402182fbe..bceaaadd0e 100644
--- a/lib/node/version.map
+++ b/lib/node/version.map
@@ -22,4 +22,7 @@ EXPERIMENTAL {

 	# added in 24.03
 	rte_node_ethdev_rx_next_update;
+
+	# added in 25.07
+	rte_node_mbuf_dynfield_register;
 };
--
2.43.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/2] node: use node mbuf dynfield in ip4 nodes
  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  4:20 ` Nitin Saxena
  1 sibling, 0 replies; 4+ messages in thread
From: Nitin Saxena @ 2025-04-01  4:20 UTC (permalink / raw)
  To: Nithin Dabilpuram, Pavan Nikhilesh, Robin Jarry, Christophe Fontaine
  Cc: dev, Jerin Jacob, Nitin Saxena

- 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 91eec33a56..a69661f41b 100644
--- a/lib/node/rte_node_mbuf_dynfield.h
+++ b/lib/node/rte_node_mbuf_dynfield.h
@@ -34,6 +34,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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] node: add global node mbuf dynfield
  2025-04-01  4:20 ` [PATCH 1/2] node: add global node mbuf dynfield Nitin Saxena
@ 2025-04-01 14:15   ` Stephen Hemminger
  0 siblings, 0 replies; 4+ messages in thread
From: Stephen Hemminger @ 2025-04-01 14:15 UTC (permalink / raw)
  To: Nitin Saxena
  Cc: Nithin Dabilpuram, Pavan Nikhilesh, Robin Jarry,
	Christophe Fontaine, dev, Jerin Jacob, Nitin Saxena

On Tue, 1 Apr 2025 09:50:46 +0530
Nitin Saxena <nsaxena@marvell.com> wrote:

> +int rte_node_mbuf_dynfield_register(void)
> +{
> +	struct node_mbuf_dynfield_mz *f = NULL;
> +	const struct rte_memzone *mz = NULL;
> +	int dyn_offset;
> +
> +	RTE_BUILD_BUG_ON(sizeof(rte_node_mbuf_dynfield_t) < RTE_NODE_MBUF_DYNFIELD_SIZE);
> +	RTE_BUILD_BUG_ON(sizeof(rte_node_mbuf_overload_fields_t) <
> +			 RTE_NODE_MBUF_OVERLOADABLE_FIELDS_SIZE);
> +
> +	mz = rte_memzone_lookup(NODE_MBUF_DYNFIELD_MEMZONE_NAME);

Seems wasteful to have a whole memzone for this, the data is small.
Is there a reason it could not just be a global variable like timestamp.

I would prefer this was a clone of timestamp code, and put in rte_mbuf_dynfield.c

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-04-01 14:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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-01  4:20 ` [PATCH 2/2] node: use node mbuf dynfield in ip4 nodes Nitin Saxena

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).