From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-we0-f179.google.com (mail-we0-f179.google.com [74.125.82.179]) by dpdk.org (Postfix) with ESMTP id C372DAFCD for ; Wed, 28 May 2014 14:03:21 +0200 (CEST) Received: by mail-we0-f179.google.com with SMTP id q59so10994623wes.38 for ; Wed, 28 May 2014 05:03:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=XNG/eidrfpq+lmctSAlHSDIauBF5LNM8t/lzVMYcWZI=; b=HqQLFbiZ/V4qUINeYnRsGMJ0N0hMRl1RPMej/RK5Z3W45yCsKuFNI/3hQbGK3R95Dv chhI1/KdccKY4DYj3erdlrQ9znQ67j+4YrdfPcemn8Clx8nZ7jWzxFfTJRYO2AcUit+u 8kVuuzF0DNWZzCRhXQ9KJGnw4Tqkfns4cRYArU7VTblzMOhAHCZN6sokTdFEZlB8Cth0 QHb7GQvhda8hi/22HB2J8HZNrMyZXGXvw1uyNRDifHea5nJSvtsH7QVKuUwG4HZuCUTl MEpSwizdU9b3uzZOWUPP6ingMgM0Me4XBx2z1uKqbOPMc7Had/tKOsux+v5kzBv3pG2S RyYQ== X-Gm-Message-State: ALoCoQkbWDPEWCZS6TGXbwMaovDpL5CFa8nMnvMH4XEGRSF3/JZad75g5/5oa3Qk+SlFQWu4uWK4 X-Received: by 10.180.160.205 with SMTP id xm13mr102322wib.13.1401278611745; Wed, 28 May 2014 05:03:31 -0700 (PDT) Received: from [10.16.0.189] (6wind.net2.nerim.net. [213.41.180.237]) by mx.google.com with ESMTPSA id m5sm16319733wie.23.2014.05.28.05.03.30 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 28 May 2014 05:03:31 -0700 (PDT) Message-ID: <5385D091.1010205@6wind.com> Date: Wed, 28 May 2014 14:03:29 +0200 From: Ivan Boule User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Icedove/24.5.0 MIME-Version: 1.0 To: Cristian Dumitrescu , dev@dpdk.org References: <1401210592-19732-1-git-send-email-cristian.dumitrescu@intel.com> <1401210592-19732-5-git-send-email-cristian.dumitrescu@intel.com> In-Reply-To: <1401210592-19732-5-git-send-email-cristian.dumitrescu@intel.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH 04/29] mbuf: added offset of packet meta-data in the packet buffer just after mbuf X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 May 2014 12:03:22 -0000 Hi Cristian, Currently, the DPDK framework does not make any assumption on the actual layout of a mbuf. More precisely, the DPDK does not impose any constraint on the actual location of additional metadata, if any, or on the actual location and size of its associated payload data buffer. This is coherent with the fact that mbuf pools are not created by the DPDK itself, but by network applications that are free to choose whatever packet mbuf layout that fits their particular needs. There is one exception to this basic DPDK rule: the mbuf cloning feature available through the RTE_MBUF_SCATTER_GATHER configuration option assumes that the payload data buffer of the mbuf immediately follows the rte_mbuf data structure (see the macros RTE_MBUF_FROM_BADDR, RTE_MBUF_TO_BADDR, RTE_MBUF_INDIRECT, and RTE_MBUF_DIRECT in the file lib/librte_mbuf/rte_mbuf.h). The cloning feature prevents to build packet mbufs with their metadata located immediately after the rte_mbuf data structure, which is exactly what your patch introduces. At least, a comment that clearly warns the user of this incompatibility might be worth adding into both the code and your patch log. Regards, Ivan On 05/27/2014 07:09 PM, Cristian Dumitrescu wrote: > Added zero-size field (offset in data structure) to specify the beginning of packet meta-data in the packet buffer just after the mbuf. > > The size of the packet meta-data is application specific and the packet meta-data is managed by the application. > > The packet meta-data should always be accessed through the provided macros. > > This is used by the Packet Framework libraries (port, table, pipeline). > > There is absolutely no performance impact due to this mbuf field, as it does not take any space in the mbuf structure (zero-size field). > > Signed-off-by: Cristian Dumitrescu > --- > lib/librte_mbuf/rte_mbuf.h | 17 +++++++++++++++++ > 1 files changed, 17 insertions(+), 0 deletions(-) > > diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h > index 4a9ab41..bf09618 100644 > --- a/lib/librte_mbuf/rte_mbuf.h > +++ b/lib/librte_mbuf/rte_mbuf.h > @@ -201,8 +201,25 @@ struct rte_mbuf { > struct rte_ctrlmbuf ctrl; > struct rte_pktmbuf pkt; > }; > + > + union { > + uint8_t metadata[0]; > + uint16_t metadata16[0]; > + uint32_t metadata32[0]; > + uint64_t metadata64[0]; > + }; > } __rte_cache_aligned; > > +#define RTE_MBUF_METADATA_UINT8(mbuf, offset) (mbuf->metadata[offset]) > +#define RTE_MBUF_METADATA_UINT16(mbuf, offset) (mbuf->metadata16[offset/sizeof(uint16_t)]) > +#define RTE_MBUF_METADATA_UINT32(mbuf, offset) (mbuf->metadata32[offset/sizeof(uint32_t)]) > +#define RTE_MBUF_METADATA_UINT64(mbuf, offset) (mbuf->metadata64[offset/sizeof(uint64_t)]) > + > +#define RTE_MBUF_METADATA_UINT8_PTR(mbuf, offset) (&mbuf->metadata[offset]) > +#define RTE_MBUF_METADATA_UINT16_PTR(mbuf, offset) (&mbuf->metadata16[offset/sizeof(uint16_t)]) > +#define RTE_MBUF_METADATA_UINT32_PTR(mbuf, offset) (&mbuf->metadata32[offset/sizeof(uint32_t)]) > +#define RTE_MBUF_METADATA_UINT64_PTR(mbuf, offset) (&mbuf->metadata64[offset/sizeof(uint64_t)]) > + > /** > * Given the buf_addr returns the pointer to corresponding mbuf. > */ > -- Ivan Boule 6WIND Development Engineer