From 4887a7e23484ed7fbba3af1d3d2bd2a2bf347993 Mon Sep 17 00:00:00 2001 From: Tal Shnaiderman Date: Tue, 19 May 2020 21:41:11 +0300 Subject: [PATCH] mbuf: align layout in Windows Using uint32_t type bit-fields in Windows will pads the 'L2/L3/L4 and tunnel information' union with additional bits. This padding causes rte_mbuf size misalignment and the total size increases to 3 cache-lines. Changed packet_type bit-fields types from uint32_t to uint8_t to allow unified 2 cache-line structure size. Added the __extension__ attribute over the modified struct to avoid the warning: type of bit-field ... is a GCC extension [-pedantic] Signed-off-by: Tal Shnaiderman Tested-by: Dmitry Kozlyuk Acked-by: Ranjit Menon Acked-by: Olivier Matz --- lib/librte_mbuf/rte_mbuf_core.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/librte_mbuf/rte_mbuf_core.h b/lib/librte_mbuf/rte_mbuf_core.h index 22be41e520..16600f1714 100644 --- a/lib/librte_mbuf/rte_mbuf_core.h +++ b/lib/librte_mbuf/rte_mbuf_core.h @@ -523,11 +523,12 @@ struct rte_mbuf { RTE_STD_C11 union { uint32_t packet_type; /**< L2/L3/L4 and tunnel information. */ + __extension__ struct { - uint32_t l2_type:4; /**< (Outer) L2 type. */ - uint32_t l3_type:4; /**< (Outer) L3 type. */ - uint32_t l4_type:4; /**< (Outer) L4 type. */ - uint32_t tun_type:4; /**< Tunnel type. */ + uint8_t l2_type:4; /**< (Outer) L2 type. */ + uint8_t l3_type:4; /**< (Outer) L3 type. */ + uint8_t l4_type:4; /**< (Outer) L4 type. */ + uint8_t tun_type:4; /**< Tunnel type. */ RTE_STD_C11 union { uint8_t inner_esp_next_proto; @@ -543,7 +544,7 @@ struct rte_mbuf { /**< Inner L3 type. */ }; }; - uint32_t inner_l4_type:4; /**< Inner L4 type. */ + uint8_t inner_l4_type:4; /**< Inner L4 type. */ }; }; -- 2.20.1