From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B2C2743D47; Mon, 25 Mar 2024 17:32:31 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4BAED40298; Mon, 25 Mar 2024 17:32:31 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 71FAC40275 for ; Mon, 25 Mar 2024 17:32:29 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711384349; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=djxpWsrRzEyQSqRaLTSojO04nK6dGkrUUOuEfoy7u0A=; b=Z/cpmZbhnkQ5FUUEDhfxbA4/0oz1eNdfJr9AeDC/GXq+hkmAojSVua+FLJXVKJgUDf/atP RNt1JhGrTZ8WpfLFFuN7MM3KxbaIqMJl+mWJto6EzfiPPT2lkQNmJYMI69kkeiR0thAxC8 kegI0/q2cwZv62Ek2+xRPxEHV1Oph+g= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-543-CzRKyzowOtOr8ebjozwNfw-1; Mon, 25 Mar 2024 12:32:23 -0400 X-MC-Unique: CzRKyzowOtOr8ebjozwNfw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 189E51C02145; Mon, 25 Mar 2024 16:32:23 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.208.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id A2AD410189; Mon, 25 Mar 2024 16:32:21 +0000 (UTC) From: Robin Jarry To: dev@dpdk.org, Jerin Jacob , Kiran Kumar K , Nithin Dabilpuram , Zhirun Yan Cc: Tyler Retzlaff Subject: [PATCH v4] graph: expose node context as pointers Date: Mon, 25 Mar 2024 17:31:09 +0100 Message-ID: <20240325163108.816996-3-rjarry@redhat.com> In-Reply-To: <20240325100500.694748-2-rjarry@redhat.com> References: <20240325100500.694748-2-rjarry@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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 --- 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