From: Bruce Richardson Date: Tue, 23 Sep 2014 11:08:16 +0000 (+0100) Subject: mbuf: add userdata pointer field X-Git-Tag: spdx-start~10328 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=4cd917b3083c88185a9b420a8831a285b2d68d4c;p=dpdk.git mbuf: add userdata pointer field While some applications may store metadata about packets in the packet mbuf headroom, this is not a workable solution for packet metadata which is either: * larger than the headroom (or headroom is needed for adding pkt headers) * needs to be shared or copied among packets To support these use cases in applications, we reserve a general "userdata" pointer field inside the second cache-line of the mbuf. This is better than having the application store the pointer to the external metadata in the packet headroom, as it saves an additional cache-line from being used. Apart from storing metadata, this field also provides a general 8-byte scratch space inside the mbuf for any other application uses that are applicable. Signed-off-by: Bruce Richardson Acked-by: Pablo de Lara --- diff --git a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h index 25ed672136..e548161bee 100644 --- a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h +++ b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h @@ -116,8 +116,10 @@ struct rte_kni_mbuf { char pad2[2]; uint16_t data_len; /**< Amount of data in segment buffer. */ uint32_t pkt_len; /**< Total pkt len: sum of all segment data_len. */ - char pad3[8]; - void *pool __attribute__((__aligned__(64))); + + /* fields on second cache line */ + char pad3[8] __attribute__((__aligned__(64))); + void *pool; void *next; }; diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h index 8e27d2eedb..9e70d3b55c 100644 --- a/lib/librte_mbuf/rte_mbuf.h +++ b/lib/librte_mbuf/rte_mbuf.h @@ -172,6 +172,12 @@ struct rte_mbuf { /* second cache line - fields only used in slow path or on TX */ MARKER cacheline1 __rte_cache_aligned; + + union { + void *userdata; /**< Can be used for external metadata */ + uint64_t udata64; /**< Allow 8-byte userdata on 32-bit */ + }; + struct rte_mempool *pool; /**< Pool from which mbuf was allocated. */ struct rte_mbuf *next; /**< Next segment of scattered packet. */