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 99130A2EFC for ; Sat, 21 Sep 2019 06:54:50 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E0BB51ED55; Sat, 21 Sep 2019 06:54:49 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id C92D31ED52 for ; Sat, 21 Sep 2019 06:54:45 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Sep 2019 21:54:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,531,1559545200"; d="scan'208";a="363029845" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by orsmga005.jf.intel.com with ESMTP; 20 Sep 2019 21:54:44 -0700 Received: from fmsmsx115.amr.corp.intel.com (10.18.116.19) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.439.0; Fri, 20 Sep 2019 21:54:43 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by fmsmsx115.amr.corp.intel.com (10.18.116.19) with Microsoft SMTP Server (TLS) id 14.3.439.0; Fri, 20 Sep 2019 21:54:43 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.113]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.32]) with mapi id 14.03.0439.000; Sat, 21 Sep 2019 12:54:41 +0800 From: "Wang, Haiyue" To: Olivier Matz , "dev@dpdk.org" CC: Thomas Monjalon , Stephen Hemminger , Andrew Rybchenko , "Wiles, Keith" , Jerin Jacob Kollanukkaran Thread-Topic: [PATCH] mbuf: support dynamic fields and flags Thread-Index: AQHVbkHYDmvFbKamSUyLqioNa6wXdac1kezQ Date: Sat, 21 Sep 2019 04:54:39 +0000 Message-ID: References: <20190710092907.5565-1-olivier.matz@6wind.com> <20190918165448.22409-1-olivier.matz@6wind.com> In-Reply-To: <20190918165448.22409-1-olivier.matz@6wind.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNWJlNmNjODAtYjk0ZC00OGIwLWJjNjAtZjg5YWM1OGYwYTUxIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiUmdSXC84M0M4a0JVc0dFZytwRmtpbEFhc2hrRkRTVThTdklnbjdPRjJldXpoMUllblRrXC9vQ3BUSTBQYk1kM0U1In0= 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: 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 >=20 > Many features require to store data inside the mbuf. As the room in mbuf > structure is limited, it is not possible to have a field for each > feature. Also, changing fields in the mbuf structure can break the API > or ABI. >=20 > This commit addresses these issues, by enabling the dynamic registration > of fields or flags: >=20 > - 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. >=20 > 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). >=20 > The registration can be done at any moment, but it is not possible > to unregister fields or flags for now. >=20 > Signed-off-by: Olivier Matz > Acked-by: Thomas Monjalon > --- >=20 > rfc -> v1 >=20 > * 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. >=20 > 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 >=20 [snip] > +/** > + * Helper macro to access to a dynamic field. > + */ > +#define RTE_MBUF_DYNFIELD(m, offset, type) ((type)((uintptr_t)(m) + (off= set))) How about to change it as: ? #define RTE_MBUF_DYNFIELD(m, offset, type) ((type *)((uintptr_t)(m) + (offs= et))) ^ 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, }; And also, when I'm trying to use the dynamic flag, found a macro will be be= tter for making code align with dynamic field. Just a small suggestion. ;-) mb->ol_flags |=3D RTE_MBUF_DYNFLAG(ol_offset); /** * Helper macro to access to a dynamic flag. */ #define RTE_MBUF_DYNFLAG(offset) (1ULL << (offset)) > + > +#endif > diff --git a/lib/librte_mbuf/rte_mbuf_version.map b/lib/librte_mbuf/rte_m= buf_version.map > index 2662a37bf..a98310570 100644 > --- a/lib/librte_mbuf/rte_mbuf_version.map > +++ b/lib/librte_mbuf/rte_mbuf_version.map > @@ -50,4 +50,8 @@ EXPERIMENTAL { > global: >=20 > rte_mbuf_check; > + rte_mbuf_dynfield_lookup; > + rte_mbuf_dynfield_register; > + rte_mbuf_dynflag_lookup; > + rte_mbuf_dynflag_register; > } DPDK_18.08; > -- > 2.20.1