From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [143.182.124.21]) by dpdk.org (Postfix) with ESMTP id 0AAF7AFD6 for ; Tue, 27 May 2014 19:09:55 +0200 (CEST) Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga101.ch.intel.com with ESMTP; 27 May 2014 10:10:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.98,920,1392192000"; d="scan'208";a="437445099" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by azsmga001.ch.intel.com with ESMTP; 27 May 2014 10:10:05 -0700 Received: from sivswdev01.ir.intel.com (sivswdev01.ir.intel.com [10.237.217.45]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id s4RHA4gZ012421; Tue, 27 May 2014 18:10:04 +0100 Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1]) by sivswdev01.ir.intel.com with ESMTP id s4RHA4U3019900; Tue, 27 May 2014 18:10:04 +0100 Received: (from cfdumitr@localhost) by sivswdev01.ir.intel.com with id s4RHA4ki019896; Tue, 27 May 2014 18:10:04 +0100 From: Cristian Dumitrescu To: dev@dpdk.org Date: Tue, 27 May 2014 18:09:27 +0100 Message-Id: <1401210592-19732-5-git-send-email-cristian.dumitrescu@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <1401210592-19732-1-git-send-email-cristian.dumitrescu@intel.com> References: <1401210592-19732-1-git-send-email-cristian.dumitrescu@intel.com> Subject: [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: Tue, 27 May 2014 17:09:56 -0000 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. */ -- 1.7.7.6