[PATCH v6 20/23] mbuf: remove and stop using rte marker fields
Konstantin Ananyev
konstantin.ananyev at huawei.com
Tue Feb 27 11:03:25 CET 2024
> Subject: [PATCH v6 20/23] mbuf: remove and stop using rte marker fields
>
> RTE_MARKER typedefs are a GCC extension unsupported by MSVC. Remove
> RTE_MARKER fields from rte_mbuf struct.
>
> Maintain alignment of fields after removed cacheline1 marker by placing
> C11 alignas(RTE_CACHE_LINE_MIN_SIZE).
>
> Update implementation of rte_mbuf_prefetch_part1() and
> rte_mbuf_prefetch_part2() inline functions calculate pointer for
> prefetch of cachline0 and cachline1 without using removed markers.
>
> Update static_assert of rte_mbuf struct fields to reference data_off and
> packet_type fields that occupy the original offsets of the marker
> fields.
>
> Signed-off-by: Tyler Retzlaff <roretzla at linux.microsoft.com>
> ---
> doc/guides/rel_notes/release_24_03.rst | 9 ++++++++
> lib/mbuf/rte_mbuf.h | 4 ++--
> lib/mbuf/rte_mbuf_core.h | 39 +++++++++++++---------------------
> 3 files changed, 26 insertions(+), 26 deletions(-)
>
> diff --git a/doc/guides/rel_notes/release_24_03.rst b/doc/guides/rel_notes/release_24_03.rst
> index 879bb49..67750f2 100644
> --- a/doc/guides/rel_notes/release_24_03.rst
> +++ b/doc/guides/rel_notes/release_24_03.rst
> @@ -156,6 +156,15 @@ Removed Items
> The application reserved statically defined logtypes ``RTE_LOGTYPE_USER1..RTE_LOGTYPE_USER8``
> are still defined.
>
> +* mbuf: ``RTE_MARKER`` fields ``cacheline0`` ``cacheline1``
> + ``rx_descriptor_fields1`` and ``RTE_MARKER64`` field ``rearm_data``
> + have been removed from ``struct rte_mbuf``.
> + Prefetch of ``cacheline0`` and ``cacheline1`` may be achieved through
> + ``rte_mbuf_prefetch_part1()`` and ``rte_mbuf_prefetch_part2()`` inline
> + functions respectively.
> + Access to ``rearm_data`` and ``rx_descriptor_fields1`` should be
> + through new inline functions ``rte_mbuf_rearm_data()`` and
> + ``rte_mbuf_rx_descriptor_fields1()`` respectively.
>
> API Changes
> -----------
> diff --git a/lib/mbuf/rte_mbuf.h b/lib/mbuf/rte_mbuf.h
> index aa7495b..61cda20 100644
> --- a/lib/mbuf/rte_mbuf.h
> +++ b/lib/mbuf/rte_mbuf.h
> @@ -108,7 +108,7 @@
> static inline void
> rte_mbuf_prefetch_part1(struct rte_mbuf *m)
> {
> - rte_prefetch0(&m->cacheline0);
> + rte_prefetch0(m);
> }
>
> /**
> @@ -126,7 +126,7 @@
> rte_mbuf_prefetch_part2(struct rte_mbuf *m)
> {
> #if RTE_CACHE_LINE_SIZE == 64
> - rte_prefetch0(&m->cacheline1);
> + rte_prefetch0(RTE_PTR_ADD(m, RTE_CACHE_LINE_MIN_SIZE));
> #else
> RTE_SET_USED(m);
> #endif
> diff --git a/lib/mbuf/rte_mbuf_core.h b/lib/mbuf/rte_mbuf_core.h
> index 36551c2..4e06f15 100644
> --- a/lib/mbuf/rte_mbuf_core.h
> +++ b/lib/mbuf/rte_mbuf_core.h
> @@ -18,6 +18,7 @@
>
> #include <assert.h>
> #include <stddef.h>
> +#include <stdalign.h>
> #include <stdint.h>
>
> #include <rte_common.h>
> @@ -467,8 +468,6 @@ enum {
> * The generic rte_mbuf, containing a packet mbuf.
> */
> struct rte_mbuf {
> - RTE_MARKER cacheline0;
> -
> void *buf_addr; /**< Virtual address of segment buffer. */
> #if RTE_IOVA_IN_MBUF
> /**
> @@ -495,7 +494,6 @@ struct rte_mbuf {
> * To obtain a pointer to rearm_data use the rte_mbuf_rearm_data()
> * accessor instead of directly referencing through the data_off field.
> */
> - RTE_MARKER64 rearm_data;
> uint16_t data_off;
>
> /**
> @@ -522,8 +520,6 @@ struct rte_mbuf {
> uint64_t ol_flags; /**< Offload features. */
>
> /* remaining bytes are set on RX when pulling packet from descriptor */
> - RTE_MARKER rx_descriptor_fields1;
> -
> /*
> * The packet type, which is the combination of outer/inner L2, L3, L4
> * and tunnel types. The packet_type is about data really present in the
> @@ -607,8 +603,7 @@ struct rte_mbuf {
> struct rte_mempool *pool; /**< Pool from which mbuf was allocated. */
>
> /* second cache line - fields only used in slow path or on TX */
> - RTE_MARKER cacheline1 __rte_cache_min_aligned;
> -
> + alignas(RTE_CACHE_LINE_MIN_SIZE)
> #if RTE_IOVA_IN_MBUF
> /**
> * Next segment of scattered packet. Must be NULL in the last
> @@ -677,35 +672,31 @@ struct rte_mbuf {
> } __rte_cache_aligned;
>
> static_assert(!(offsetof(struct rte_mbuf, ol_flags) !=
> - offsetof(struct rte_mbuf, rearm_data) + 8), "ol_flags");
> -static_assert(!(offsetof(struct rte_mbuf, rearm_data) !=
> - RTE_ALIGN(offsetof(struct rte_mbuf, rearm_data), 16)), "rearm_data");
> + offsetof(struct rte_mbuf, data_off) + 8), "ol_flags");
> static_assert(!(offsetof(struct rte_mbuf, data_off) !=
> - offsetof(struct rte_mbuf, rearm_data)), "data_off");
> -static_assert(!(offsetof(struct rte_mbuf, data_off) <
> - offsetof(struct rte_mbuf, rearm_data)), "data_off");
> + RTE_ALIGN(offsetof(struct rte_mbuf, data_off), 16)), "data_off");
> static_assert(!(offsetof(struct rte_mbuf, refcnt) <
> - offsetof(struct rte_mbuf, rearm_data)), "refcnt");
> + offsetof(struct rte_mbuf, data_off)), "refcnt");
> static_assert(!(offsetof(struct rte_mbuf, nb_segs) <
> - offsetof(struct rte_mbuf, rearm_data)), "nb_segs");
> + offsetof(struct rte_mbuf, data_off)), "nb_segs");
> static_assert(!(offsetof(struct rte_mbuf, port) <
> - offsetof(struct rte_mbuf, rearm_data)), "port");
> + offsetof(struct rte_mbuf, data_off)), "port");
> static_assert(!(offsetof(struct rte_mbuf, data_off) -
> - offsetof(struct rte_mbuf, rearm_data) > 6), "data_off");
> + offsetof(struct rte_mbuf, data_off) > 6), "data_off");
> static_assert(!(offsetof(struct rte_mbuf, refcnt) -
> - offsetof(struct rte_mbuf, rearm_data) > 6), "refcnt");
> + offsetof(struct rte_mbuf, data_off) > 6), "refcnt");
> static_assert(!(offsetof(struct rte_mbuf, nb_segs) -
> - offsetof(struct rte_mbuf, rearm_data) > 6), "nb_segs");
> + offsetof(struct rte_mbuf, data_off) > 6), "nb_segs");
> static_assert(!(offsetof(struct rte_mbuf, port) -
> - offsetof(struct rte_mbuf, rearm_data) > 6), "port");
> + offsetof(struct rte_mbuf, data_off) > 6), "port");
> static_assert(!(offsetof(struct rte_mbuf, pkt_len) !=
> - offsetof(struct rte_mbuf, rx_descriptor_fields1) + 4), "pkt_len");
> + offsetof(struct rte_mbuf, packet_type) + 4), "pkt_len");
> static_assert(!(offsetof(struct rte_mbuf, data_len) !=
> - offsetof(struct rte_mbuf, rx_descriptor_fields1) + 8), "data_len");
> + offsetof(struct rte_mbuf, packet_type) + 8), "data_len");
> static_assert(!(offsetof(struct rte_mbuf, vlan_tci) !=
> - offsetof(struct rte_mbuf, rx_descriptor_fields1) + 10), "vlan_tci");
> + offsetof(struct rte_mbuf, packet_type) + 10), "vlan_tci");
> static_assert(!(offsetof(struct rte_mbuf, hash) !=
> - offsetof(struct rte_mbuf, rx_descriptor_fields1) + 12), "hash");
> + offsetof(struct rte_mbuf, packet_type) + 12), "hash");
>
> /**
> * Function typedef of callback to free externally attached buffer.
> --
Acked-by: Konstantin Ananyev <konstantin.ananyev at huawei.com>
> 1.8.3.1
More information about the dev
mailing list