From: Cristian Dumitrescu Date: Wed, 4 Jun 2014 18:08:18 +0000 (+0100) Subject: mbuf: meta-data offset X-Git-Tag: spdx-start~10703 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=3179b9ee4f91923b7df66f5d2e4fc52771bfad1f;p=dpdk.git mbuf: meta-data offset 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 Acked-by: Pablo de Lara Guarch Acked by: Ivan Boule --- diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h index 7ec66826ba..416e84e613 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. */