From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4E939A00E6 for ; Fri, 12 Jul 2019 11:18:13 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 227951B9B0; Fri, 12 Jul 2019 11:18:13 +0200 (CEST) Received: from mail.droids-corp.org (zoll.droids-corp.org [94.23.50.67]) by dpdk.org (Postfix) with ESMTP id DB80C1B9AA for ; Fri, 12 Jul 2019 11:18:11 +0200 (CEST) Received: from lfbn-lil-1-176-160.w90-45.abo.wanadoo.fr ([90.45.26.160] helo=droids-corp.org) by mail.droids-corp.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hlrjz-0001uu-KM; Fri, 12 Jul 2019 11:21:20 +0200 Received: by droids-corp.org (sSMTP sendmail emulation); Fri, 12 Jul 2019 11:18:09 +0200 Date: Fri, 12 Jul 2019 11:18:09 +0200 From: Olivier Matz To: Stephen Hemminger Cc: "Wang, Haiyue" , "dev@dpdk.org" Message-ID: <20190712091809.nifdxby75ly4tbxj@platinum> References: <20190710092907.5565-1-olivier.matz@6wind.com> <20190711072619.fldr3dz7qblyvej5@glumotte.dev.6wind.com> <20190711083119.018ff00d@hermes.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190711083119.018ff00d@hermes.lan> User-Agent: NeoMutt/20180716 Subject: Re: [dpdk-dev] [RFC] mbuf: support dynamic fields and flags X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Thu, Jul 11, 2019 at 08:31:19AM -0700, Stephen Hemminger wrote: > On Thu, 11 Jul 2019 09:26:19 +0200 > Olivier Matz wrote: > > > For generic fields, I think they should be declared in this file. For > > instance, if we decide to replace the current m->timestamp field by a > > dynamic field, we should add like this: > > > > #define RTE_MBUF_DYN_TIMESTAMP_ID "rte_timestamp" > > #define RTE_MBUF_DYN_TIMESTAMP_SIZE sizeof(uint64_t) > > #define RTE_MBUF_DYN_TIMESTAMP_ALIGN __alignof__(uint64_t) > > > Let's use structures (like rte_flow) rather that macros for > this? The purpose of having defines is: - to avoid typos when registering dynamic fields/flags - to avoid name conflicts (because define names are derived from identifier) - associate a known size and alignment to a given dynamic field Using strings instead of numeric identifiers is also done on purpose, to facilitate the definition of unique identifiers outside the dpdk subtree (as soon as we respect contraints on namespace). Instead of defines, are you suggesting something like this? struct rte_mbuf_dynfield { const char *id; size_t size; size_t align; }; /* definition of a dynamic field */ static const struct rte_mbuf_dynfield rte_mbuf_dynfield_timestamp { .id = "rte_mbuf_dynfield_timestamp", .size = sizeof(uint64_t), .size = __alignof__(uint64_t), }; /* ...and same for dynamic flags... */ And change the registration API to have one argument of type (struct rte_mbuf_dynfield *) ? I agree it could be quite nice with structs.