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 37992A0613 for ; Mon, 23 Sep 2019 13:01:35 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C80E91BE9C; Mon, 23 Sep 2019 13:01:33 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 7328E1BE82 for ; Mon, 23 Sep 2019 13:01:32 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Sep 2019 04:01:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,539,1559545200"; d="scan'208";a="179093997" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by orsmga007.jf.intel.com with ESMTP; 23 Sep 2019 04:01:31 -0700 Received: from fmsmsx114.amr.corp.intel.com (10.18.116.8) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 23 Sep 2019 04:01:30 -0700 Received: from shsmsx153.ccr.corp.intel.com (10.239.6.53) by FMSMSX114.amr.corp.intel.com (10.18.116.8) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 23 Sep 2019 04:01:30 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.113]) by SHSMSX153.ccr.corp.intel.com ([169.254.12.235]) with mapi id 14.03.0439.000; Mon, 23 Sep 2019 19:01:27 +0800 From: "Wang, Haiyue" To: Olivier Matz CC: "dev@dpdk.org" , Thomas Monjalon , Stephen Hemminger , Andrew Rybchenko , "Wiles, Keith" , "Jerin Jacob Kollanukkaran" Thread-Topic: [PATCH] mbuf: support dynamic fields and flags Thread-Index: AQHVbkHYDmvFbKamSUyLqioNa6wXdac1kezQgALeHICAAK+HkA== Date: Mon, 23 Sep 2019 11:01:27 +0000 Message-ID: References: <20190710092907.5565-1-olivier.matz@6wind.com> <20190918165448.22409-1-olivier.matz@6wind.com> <20190923083143.ml3jkipy7wdvzwg6@platinum> In-Reply-To: <20190923083143.ml3jkipy7wdvzwg6@platinum> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMTIxZjc5ZjYtMWExYS00NmZmLThhZTEtZTNmYTE4ODU5MTE1IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiaFNKb0o4NTVXamZTN0ZadFRkUWY4MG5NUzVmaDFlSUdrTlBRUXpLbHh3Z1NTRzZDbGl4dVFObFB4TmszXC80WEsifQ== x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] 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" > -----Original Message----- > From: Olivier Matz [mailto:olivier.matz@6wind.com] > Sent: Monday, September 23, 2019 16:32 > To: Wang, Haiyue > Cc: dev@dpdk.org; Thomas Monjalon ; Stephen Hemminge= r > ; Andrew Rybchenko ; Wiles, Keith > ; Jerin Jacob Kollanukkaran > Subject: Re: [PATCH] mbuf: support dynamic fields and flags >=20 > Hi, >=20 > On Sat, Sep 21, 2019 at 04:54:39AM +0000, Wang, Haiyue wrote: > > > -----Original Message----- > > > From: Olivier Matz [mailto:olivier.matz@6wind.com] > > > Sent: Thursday, September 19, 2019 00:55 > > > To: dev@dpdk.org > > > Cc: Thomas Monjalon ; Wang, Haiyue ; Stephen Hemminger > > > ; Andrew Rybchenko ; Wiles, Keith > > > ; Jerin Jacob Kollanukkaran > > > Subject: [PATCH] mbuf: support dynamic fields and flags > > > > > > Many features require to store data inside the mbuf. As the room in m= buf > > > structure is limited, it is not possible to have a field for each > > > feature. Also, changing fields in the mbuf structure can break the AP= I > > > or ABI. > > > > > > This commit addresses these issues, by enabling the dynamic registrat= ion > > > of fields or flags: > > > > > > - a dynamic field is a named area in the rte_mbuf structure, with a > > > given size (>=3D 1 byte) and alignment constraint. > > > - a dynamic flag is a named bit in the rte_mbuf structure. > > > > > > The typical use case is a PMD that registers space for an offload > > > feature, when the application requests to enable this feature. As > > > the space in mbuf is limited, the space should only be reserved if it > > > is going to be used (i.e when the application explicitly asks for it)= . > > > > > > The registration can be done at any moment, but it is not possible > > > to unregister fields or flags for now. > > > > > > Signed-off-by: Olivier Matz > > > Acked-by: Thomas Monjalon > > > --- > > > > > > rfc -> v1 > > > > > > * Rebase on top of master > > > * Change registration API to use a structure instead of > > > variables, getting rid of #defines (Stephen's comment) > > > * Update flag registration to use a similar API as fields. > > > * Change max name length from 32 to 64 (sugg. by Thomas) > > > * Enhance API documentation (Haiyue's and Andrew's comments) > > > * Add a debug log at registration > > > * Add some words in release note > > > * Did some performance tests (sugg. by Andrew): > > > On my platform, reading a dynamic field takes ~3 cycles more > > > than a static field, and ~2 cycles more for writing. > > > > > > app/test/test_mbuf.c | 114 ++++++- > > > doc/guides/rel_notes/release_19_11.rst | 7 + > > > lib/librte_mbuf/Makefile | 2 + > > > lib/librte_mbuf/meson.build | 6 +- > > > lib/librte_mbuf/rte_mbuf.h | 25 +- > > > lib/librte_mbuf/rte_mbuf_dyn.c | 408 +++++++++++++++++++++++= ++ > > > lib/librte_mbuf/rte_mbuf_dyn.h | 163 ++++++++++ > > > lib/librte_mbuf/rte_mbuf_version.map | 4 + > > > 8 files changed, 724 insertions(+), 5 deletions(-) > > > create mode 100644 lib/librte_mbuf/rte_mbuf_dyn.c > > > create mode 100644 lib/librte_mbuf/rte_mbuf_dyn.h > > > > > > > [snip] > > > > > +/** > > > + * Helper macro to access to a dynamic field. > > > + */ > > > +#define RTE_MBUF_DYNFIELD(m, offset, type) ((type)((uintptr_t)(m) + = (offset))) > > > > How about to change it as: ? > > #define RTE_MBUF_DYNFIELD(m, offset, type) ((type *)((uintptr_t)(m) + (= offset))) > > ^ > > Then, > > *RTE_MBUF_DYNFIELD(mb, xxx, uint32_t) =3D yyy; > > > > Since we use 'type' like: sizeof(type), __alignof__(type), this makes '= type' be > > more consistent, not have to force cast 'type *' when using it. > > > > const struct rte_mbuf_dynfield dynfield2 =3D { > > .name =3D "test-dynfield2", > > .size =3D sizeof(uint16_t), > > .align =3D __alignof__(uint16_t), > > .flags =3D 0, > > }; >=20 > Yes, I don't see use cases where the '*' is omitted, so it could be in th= e > macro. On the other hand, doing like in the patch is more consistent with > similar macros like rte_pktmbuf_mtod(), so I'll tend to keep it as is. >=20 > This is maybe not that important, because this macro will often be hidden > in a wrapper, like below: >=20 > static inline uint64_t rte_mbuf_dyn_timestamp_get(const struct rte_mbuf= *m) > { > return *RTE_MBUF_DYNFIELD(m, rte_mbuf_dynfield_timestamp_offset, > uint64_t *); > } >=20 Thanks, yes, the same style as 'rte_pktmbuf_mtod', I didn't notice it. >=20 > Thank you for the feedback! >=20 > Olivier