From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 242F868CD for ; Wed, 4 Jun 2014 20:08:41 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 04 Jun 2014 11:08:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.98,974,1392192000"; d="scan'208";a="549795601" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga002.fm.intel.com with ESMTP; 04 Jun 2014 11:08:49 -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 s54I8nvu011706; Wed, 4 Jun 2014 19:08:49 +0100 Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1]) by sivswdev01.ir.intel.com with ESMTP id s54I8nRI008962; Wed, 4 Jun 2014 19:08:49 +0100 Received: (from cfdumitr@localhost) by sivswdev01.ir.intel.com with id s54I8nlT008956; Wed, 4 Jun 2014 19:08:49 +0100 From: Cristian Dumitrescu To: dev@dpdk.org Date: Wed, 4 Jun 2014 19:08:18 +0100 Message-Id: <1401905319-8882-3-git-send-email-cristian.dumitrescu@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <1401905319-8882-1-git-send-email-cristian.dumitrescu@intel.com> References: <1401905319-8882-1-git-send-email-cristian.dumitrescu@intel.com> Subject: [dpdk-dev] [v2 02/23] mbuf: meta-data 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, 04 Jun 2014 18:08:44 -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 | 25 +++++++++++++++++++++++++ 1 files changed, 25 insertions(+), 0 deletions(-) diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h index 4a9ab41..a3f9503 100644 --- a/lib/librte_mbuf/rte_mbuf.h +++ b/lib/librte_mbuf/rte_mbuf.h @@ -201,8 +201,33 @@ 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