DPDK patches and discussions
 help / color / mirror / Atom feed
From: Robin Jarry <rjarry@redhat.com>
To: dev@dpdk.org, Jerin Jacob <jerinj@marvell.com>,
	Kiran Kumar K <kirankumark@marvell.com>,
	Nithin Dabilpuram <ndabilpuram@marvell.com>,
	Zhirun Yan <yanzhirun_163@163.com>
Cc: Tyler Retzlaff <roretzla@linux.microsoft.com>
Subject: [PATCH v4] graph: expose node context as pointers
Date: Mon, 25 Mar 2024 17:31:09 +0100	[thread overview]
Message-ID: <20240325163108.816996-3-rjarry@redhat.com> (raw)
In-Reply-To: <20240325100500.694748-2-rjarry@redhat.com>

In some cases, the node context data is used to store two pointers
because the data is larger than the reserved 16 bytes. Having to define
intermediate structures just to be able to cast is tedious. Add helper
inline functions to cast the node context to opaque pointers.

Signed-off-by: Robin Jarry <rjarry@redhat.com>
---

Notes:
    v4:
    
    * Replaced the unnamed union with helper inline functions.
    
    v3:
    
    * Added __extension__ to the unnamed struct inside the union.
    * Fixed C++ header checks.
    * Replaced alignas() with an explicit static_assert.

 lib/graph/rte_graph_worker_common.h | 54 +++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)

diff --git a/lib/graph/rte_graph_worker_common.h b/lib/graph/rte_graph_worker_common.h
index 36d864e2c14e..f54f65598193 100644
--- a/lib/graph/rte_graph_worker_common.h
+++ b/lib/graph/rte_graph_worker_common.h
@@ -130,6 +130,60 @@ struct __rte_cache_aligned rte_node {
 	alignas(RTE_CACHE_LINE_MIN_SIZE) struct rte_node *nodes[]; /**< Next nodes. */
 };
 
+/**
+ * Cast the first 8 bytes of node context as an opaque pointer.
+ *
+ * @param node
+ *   Pointer to the node object.
+ *
+ * @return
+ *   The opaque pointer value.
+ */
+static inline void *rte_node_ctx_ptr1_get(struct rte_node *node)
+{
+	return ((void **)node->ctx)[0];
+}
+
+/**
+ * Cast the last 8 bytes of node context as an opaque pointer.
+ *
+ * @param node
+ *   Pointer to the node object.
+ *
+ * @return
+ *   The opaque pointer value.
+ */
+static inline void *rte_node_ctx_ptr2_get(struct rte_node *node)
+{
+	return ((void **)node->ctx)[1];
+}
+
+/**
+ * Set the first 8 bytes of node context to an opaque pointer value.
+ *
+ * @param node
+ *   Pointer to the node object.
+ * @param ptr
+ *   The opaque pointer value.
+ */
+static inline void rte_node_ctx_ptr1_set(struct rte_node *node, void *ptr)
+{
+	((void **)node->ctx)[0] = ptr;
+}
+
+/**
+ * Set the last 8 bytes of node context to an opaque pointer value.
+ *
+ * @param node
+ *   Pointer to the node object.
+ * @param ptr
+ *   The opaque pointer value.
+ */
+static inline void rte_node_ctx_ptr2_set(struct rte_node *node, void *ptr)
+{
+	((void **)node->ctx)[1] = ptr;
+}
+
 /**
  * @internal
  *
-- 
2.44.0


  parent reply	other threads:[~2024-03-25 16:32 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-25 10:05 [PATCH v3] " Robin Jarry
2024-03-25 10:59 ` Jerin Jacob
2024-03-25 11:02   ` Robin Jarry
2024-03-25 11:08     ` Jerin Jacob
2024-03-25 11:15       ` Robin Jarry
2024-03-25 11:35         ` Jerin Jacob
2024-03-25 12:07           ` Bruce Richardson
2024-03-25 12:08           ` David Marchand
2024-03-25 15:20           ` Robin Jarry
2024-03-25 15:47             ` Jerin Jacob
2024-03-25 15:51               ` Robin Jarry
2024-03-25 15:56                 ` Jerin Jacob
2024-03-25 16:31 ` Robin Jarry [this message]
2024-03-25 16:50   ` [PATCH v4] " Jerin Jacob
2024-03-27  9:14 ` [PATCH v5] " Robin Jarry

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=20240325163108.816996-3-rjarry@redhat.com \
    --to=rjarry@redhat.com \
    --cc=dev@dpdk.org \
    --cc=jerinj@marvell.com \
    --cc=kirankumark@marvell.com \
    --cc=ndabilpuram@marvell.com \
    --cc=roretzla@linux.microsoft.com \
    --cc=yanzhirun_163@163.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).