DPDK patches and discussions
 help / color / mirror / Atom feed
From: Pavan Nikhilesh Bhagavatula <pbhagavatula@marvell.com>
To: Nitin Saxena <nsaxena@marvell.com>,
	Nithin Kumar Dabilpuram <ndabilpuram@marvell.com>,
	Robin Jarry <rjarry@redhat.com>,
	Christophe Fontaine <cfontain@redhat.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>, Jerin Jacob <jerinj@marvell.com>,
	Nitin Saxena <nsaxena16@gmail.com>
Subject: RE: [PATCH v6 2/2] node: use node mbuf dynfield in ip4 nodes
Date: Fri, 9 May 2025 07:17:32 +0000	[thread overview]
Message-ID: <PH0PR18MB40865BD7D541CF679E8899C7DE8AA@PH0PR18MB4086.namprd18.prod.outlook.com> (raw)
In-Reply-To: <20250428103711.3317231-3-nsaxena@marvell.com>



> -----Original Message-----
> From: Nitin Saxena <nsaxena@marvell.com>
> Sent: Monday, April 28, 2025 4:07 PM
> To: Nithin Kumar Dabilpuram <ndabilpuram@marvell.com>; Pavan Nikhilesh
> Bhagavatula <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 v6 2/2] node: use node mbuf dynfield in ip4 nodes
> 
> - 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>

Acked-by: Pavan Nikhilesh <pbhagavatula@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 604fcb267a..f6db3219f0 100644
> --- a/lib/node/ip4_lookup.c
> +++ b/lib/node/ip4_lookup.c
> @@ -32,8 +32,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) \
> @@ -182,17 +180,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)
>  		{
> @@ -210,7 +206,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 a9ab5eaa57..dfa4382350 100644
> --- a/lib/node/ip4_rewrite.c
> +++ b/lib/node/ip4_rewrite.c
> @@ -259,19 +259,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 827fc2f379..83c0500c76 100644
> --- a/lib/node/ip6_lookup.c
> +++ b/lib/node/ip6_lookup.c
> @@ -318,18 +318,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)
>  		{
> @@ -347,8 +345,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 e157964c6a..d5488e7fa3 100644
> --- a/lib/node/ip6_rewrite.c
> +++ b/lib/node/ip6_rewrite.c
> @@ -243,19 +243,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 4db5382f91..0b22fbf718 100644
> --- a/lib/node/rte_node_mbuf_dynfield.h
> +++ b/lib/node/rte_node_mbuf_dynfield.h
> @@ -40,6 +40,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


  reply	other threads:[~2025-05-09  7:17 UTC|newest]

Thread overview: 31+ 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   ` [PATCH v3 2/2] node: use node mbuf dynfield in ip4 nodes Nitin Saxena
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 [this message]
2025-05-05 17:20   ` [PATCH v6 0/2] node: add mbuf dynamic field for nodes Pavan Nikhilesh Bhagavatula

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=PH0PR18MB40865BD7D541CF679E8899C7DE8AA@PH0PR18MB4086.namprd18.prod.outlook.com \
    --to=pbhagavatula@marvell.com \
    --cc=cfontain@redhat.com \
    --cc=dev@dpdk.org \
    --cc=jerinj@marvell.com \
    --cc=ndabilpuram@marvell.com \
    --cc=nsaxena16@gmail.com \
    --cc=nsaxena@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 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).