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 840B6A3295 for ; Wed, 23 Oct 2019 17:00:31 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 56F931C29D; Wed, 23 Oct 2019 17:00:31 +0200 (CEST) Received: from mail-pg1-f196.google.com (mail-pg1-f196.google.com [209.85.215.196]) by dpdk.org (Postfix) with ESMTP id 358721C227 for ; Wed, 23 Oct 2019 17:00:30 +0200 (CEST) Received: by mail-pg1-f196.google.com with SMTP id e10so12299774pgd.11 for ; Wed, 23 Oct 2019 08:00:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vp8NCcUdzyNJCZECIsJEPaplHXknEV1mnvMZjnEPPkU=; b=LhRjSsZspWD6+TF6lQmJA3GFs95YY+qsyxRPQ6AZx3PBHeAb6UjSKkjnFy4dUrCSLW 8zU+e32Iu2sYdVa30EZGoEKgHNRsLLLTrDewVJFp1INIQZoE58AuP1oXkl3vlyWcQcck B2jWSTAxYpWDgUFc/tH0UmS9WHA0rj3Aj9VJaeiRpAq2BQUAr5FETqklQOKcLskw4fGK Cc41tYRDuNA00OhoRWsxF60I3pWA+TkSujPn+vdHBUwqUHu8FpmFkQ38bee+JmDTyTm/ BSi7tHZAkuz84aywFJryrJXaXcUjid4Rfv16PMTt4zEqP8d1vBUs4PGuVi3IxpFFwzxv 3L0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vp8NCcUdzyNJCZECIsJEPaplHXknEV1mnvMZjnEPPkU=; b=J696oOBWu0S0a82eLl7ibAq6w175ESKGrP+ZGvwK8nnq4Ye3E2ZfnWsNMT1ln961Dz CY0OXVuB7Iu/G8eYW6R1Mc+zkROCEVRge3JTa7dBlocaliyUjqoHJ0YTBusgZDLxpfV4 ikLiqlcburDECjAplhkGRIdtc8qkap/EEnM74qSV8jTbKXExhwKl/Zrhs3fpQS3ZaMiY /WU1br+tB99J4C0w/UdoxGL5A/2aj/1UkrusB48fOtFh9Ro3CJSxcd4il8Dnpgpf2+PO w3/3VfWJ0EFAc/6Jf2p1jacp5ySmR3pQC5C/tCHEuSdMlv/8Kqye/bflfG5dGzIJZRI6 mcSA== X-Gm-Message-State: APjAAAVlR1fhxtR/35lzUt+1llxkiUtCZ0BcBq0gpNRvy9xDOoWq1Z6L 8JIM+R0/S0QvLEFewh2ltVvCqg== X-Google-Smtp-Source: APXvYqxV2hZcFEhSdBhzno+tOpckAzG2NNu7dCZ5cAqFO8A6w5y3Q36GUXL7iEtPuNHsbiyerOjXzw== X-Received: by 2002:a17:90a:b285:: with SMTP id c5mr421833pjr.123.1571842829274; Wed, 23 Oct 2019 08:00:29 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id t141sm28030521pfc.65.2019.10.23.08.00.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2019 08:00:28 -0700 (PDT) Date: Wed, 23 Oct 2019 08:00:17 -0700 From: Stephen Hemminger To: Olivier Matz Cc: "Wang, Haiyue" , "Ananyev, Konstantin" , "dev@dpdk.org" , Andrew Rybchenko , "Richardson, Bruce" , Jerin Jacob Kollanukkaran , "Wiles, Keith" , Morten =?UTF-8?B?QnLDuHJ1cA==?= , Thomas Monjalon Message-ID: <20191023080017.6b62ea7d@hermes.lan> In-Reply-To: <20191023102143.GI25286@glumotte.dev.6wind.com> References: <20190710092907.5565-1-olivier.matz@6wind.com> <20191017144219.32708-1-olivier.matz@6wind.com> <2601191342CEEE43887BDE71AB97725801A8C6E2BD@IRSMSX104.ger.corp.intel.com> <20191023102143.GI25286@glumotte.dev.6wind.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [dpdk-dev] [PATCH v2] 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 Wed, 23 Oct 2019 12:21:43 +0200 Olivier Matz wrote: > On Wed, Oct 23, 2019 at 03:16:13AM +0000, Wang, Haiyue wrote: > > > -----Original Message----- > > > From: Ananyev, Konstantin > > > Sent: Wednesday, October 23, 2019 06:52 > > > To: Olivier Matz ; dev@dpdk.org > > > Cc: Andrew Rybchenko ; Richardson, Bruce <= bruce.richardson@intel.com>; Wang, > > > Haiyue ; Jerin Jacob Kollanukkaran ; Wiles, Keith > > > ; Morten Br=C3=B8rup ; Stephen Hemminger > > > ; Thomas Monjalon > > > Subject: RE: [PATCH v2] mbuf: support dynamic fields and flags > > >=20 > > > =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. > > > > > > > > This commit addresses these issues, by enabling the dynamic registr= ation > > > > 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 i= t). > > > > > > > > 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 > > > > --- > > > > > > > > v2 > > > > > > > > * Rebase on top of master: solve conflict with Stephen's patchset > > > > (packet copy) > > > > * Add new apis to register a dynamic field/flag at a specific place > > > > * Add a dump function (sugg by David) > > > > * Enhance field registration function to select the best offset, ke= eping > > > > large aligned zones as much as possible (sugg by Konstantin) > > > > * Use a size_t and unsigned int instead of int when relevant > > > > (sugg by Konstantin) > > > > * Use "uint64_t dynfield1[2]" in mbuf instead of 2 uint64_t fields > > > > (sugg by Konstantin) > > > > * Remove unused argument in private function (sugg by Konstantin) > > > > * Fix and simplify locking (sugg by Konstantin) > > > > * Fix minor typo > > > > > > > > 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 | 145 ++++++- > > > > 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 | 23 +- > > > > lib/librte_mbuf/rte_mbuf_dyn.c | 548 +++++++++++++++++++++= ++++ > > > > lib/librte_mbuf/rte_mbuf_dyn.h | 226 ++++++++++ > > > > lib/librte_mbuf/rte_mbuf_version.map | 7 + > > > > 8 files changed, 959 insertions(+), 5 deletions(-) > > > > create mode 100644 lib/librte_mbuf/rte_mbuf_dyn.c > > > > create mode 100644 lib/librte_mbuf/rte_mbuf_dyn.h > > > > > > > > diff --git a/app/test/test_mbuf.c b/app/test/test_mbuf.c > > > > index b9c2b2500..01cafad59 100644 > > > > --- a/app/test/test_mbuf.c > > > > +++ b/app/test/test_mbuf.c > > > > @@ -28,6 +28,7 @@ > > > > #include > > > > #include > > > > #include > > > > +#include > > > > =20 > >=20 > > [snip] =20 > > > > +int > > > > +rte_mbuf_dynflag_register_bitnum(const struct rte_mbuf_dynflag *pa= rams, > > > > + unsigned int req) > > > > +{ > > > > + int ret; > > > > + > > > > + if (req !=3D UINT_MAX && req >=3D 64) { =20 > > >=20 > > > Might be better to replace 64 with something like sizeof(mbuf->ol_fla= gs) * CHAR_BIT or so. =20 > >=20 > > Might introduce a new macro like kernel: > >=20 > > /** > > * FIELD_SIZEOF - get the size of a struct's field > > * @t: the target struct > > * @f: the target struct's field > > * Return: the size of @f in the struct definition without having a > > * declared instance of @t. > > */ > > #define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f)) > >=20 > > Then: FIELD_SIZEOF(rte_mbuf, ol_flags) * CHAR_BIT =20 >=20 > Good idea, thanks >=20 Kernel is replacing FIELD_SIZEOF with sizeof_member