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 EBC2543D47; Mon, 25 Mar 2024 17:51:26 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9413940A72; Mon, 25 Mar 2024 17:51:26 +0100 (CET) Received: from mail-qt1-f173.google.com (mail-qt1-f173.google.com [209.85.160.173]) by mails.dpdk.org (Postfix) with ESMTP id AEF2740298 for ; Mon, 25 Mar 2024 17:51:24 +0100 (CET) Received: by mail-qt1-f173.google.com with SMTP id d75a77b69052e-430a25ed4e7so30862021cf.0 for ; Mon, 25 Mar 2024 09:51:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711385484; x=1711990284; darn=dpdk.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=ASXFURFGOTN9Mdab3hFz+NUcEgtEhWMb2TzXrLn65+M=; b=dEO9RFdIy8D1hbJ65i8sRrYMY7+TLX6gVMxAWqeL+PyYYmQLUruWyDbNvbevjlqWTs sPqMlqC32bBIKk2ZjBF1OEyocFNsKtMv4EIldnhQPMKUseYJHlSLgmIwiKBAuvdzktIh pJUElzEx0hgAL97d7h6ZJJYmz1PtgzZlrl3V6wNbcmVY6Pv76fxZZiQ+SJ9LX99poTeY EsiPdaLhF2lgk9owOSadiaWO2ViRXahKRrDUsPdEI8K56zEM88iSx2prvI4LR/mKAnsD G0ZOiP4rWcqn9e9l2V/emT/eqcN+yLonQf7tQcdTLHMPw7er/KfpVJXhmYqulqjKRIXS lGhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711385484; x=1711990284; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ASXFURFGOTN9Mdab3hFz+NUcEgtEhWMb2TzXrLn65+M=; b=wekapZGGpMvUvrwd4vk3gubxe893a79kl9XPsdECubbutCNGrvHk5mi3rL1kMMzcdE nxqwbJeRLFlEs7TVoHHl/Qp+ssEjNqA9JBmukfiFLWosn1VOnJaGsahsjCMwV3yRlWek nzBhFafN8vCWYAZ6jGosrGlOjJHcFs8s3MWJORksrqemA9cGGTQJ0+O+IXaRl5Ac2XKX 0xW9SXhZ9YzoFhND/pe5AXFqRbGXN7Np3x51RSGFGjZL/vWncRIUTjTeRVRD0uR6RIKv ImvBxhRLbJS0perPIn5ST1MbWD2prKoFCzXs94b6qaV+sfHtA0f6jZOj++UbOl/9vdVs zy3g== X-Gm-Message-State: AOJu0YxqRHOEcw8wI9vh67DuFIIfvqQArYS0Er61OvYtbVmfrHryYBng RtcrlInxs7u8tAz+aC815FtNv+CPsn+jtJngbnvCP4Xj26eShQPA2l+0MYFiclDf7KoQWsbJ7vE Ok8mqtm3jCoj/9E1YJliMAGBp9UE= X-Google-Smtp-Source: AGHT+IFuRs64kOcKaVDlnHQvUWOdm9GrRSHtFnDeaixg3d1/alKLISU9p/DJ1cylFepN0TwMf2f8pkogTeeQafXOWEE= X-Received: by 2002:a05:622a:1a19:b0:431:6194:4580 with SMTP id f25-20020a05622a1a1900b0043161944580mr1734801qtb.13.1711385483948; Mon, 25 Mar 2024 09:51:23 -0700 (PDT) MIME-Version: 1.0 References: <20240325100500.694748-2-rjarry@redhat.com> <20240325163108.816996-3-rjarry@redhat.com> In-Reply-To: <20240325163108.816996-3-rjarry@redhat.com> From: Jerin Jacob Date: Mon, 25 Mar 2024 22:20:57 +0530 Message-ID: Subject: Re: [PATCH v4] graph: expose node context as pointers To: Robin Jarry Cc: dev@dpdk.org, Jerin Jacob , Kiran Kumar K , Nithin Dabilpuram , Zhirun Yan , Tyler Retzlaff Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 On Mon, Mar 25, 2024 at 10:11=E2=80=AFPM Robin Jarry wr= ote: > > 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_wo= rker_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[]; /**< N= ext 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) New line after void*. Same for all new functions. With that change: Acked-by: Jerin Jacob > +{ > + 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 *pt= r) > +{ > + ((void **)node->ctx)[0] =3D 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 *pt= r) > +{ > + ((void **)node->ctx)[1] =3D ptr; > +} > + > /** > * @internal > * > -- > 2.44.0 >