[v4,5/7] lib: move mbuf next pointer to first cache line

Message ID 465a7303a72cc4a77c42d8479f727efd1dabbc46.1665170500.git.sthotton@marvell.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series mbuf dynamic field expansion |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Shijith Thotton Oct. 7, 2022, 7:30 p.m. UTC
  Swapped position of mbuf next pointer and second dynamic field (dynfield2)
if the build is configured to disable IOVA as PA. This is to move the
mbuf next pointer to first cache line.

Signed-off-by: Shijith Thotton <sthotton@marvell.com>
---
 doc/guides/rel_notes/release_22_11.rst |  3 +++
 lib/mbuf/rte_mbuf_core.h               | 19 ++++++++++++++-----
 2 files changed, 17 insertions(+), 5 deletions(-)
  

Patch

diff --git a/doc/guides/rel_notes/release_22_11.rst b/doc/guides/rel_notes/release_22_11.rst
index 0b4740abd1..006d1f5988 100644
--- a/doc/guides/rel_notes/release_22_11.rst
+++ b/doc/guides/rel_notes/release_22_11.rst
@@ -269,6 +269,9 @@  ABI Changes
 * eventdev: Added ``weight`` and ``affinity`` fields
   to ``rte_event_queue_conf`` structure.
 
+* mbuf: Replaced ``buf_iova`` field with ``next`` field and added a new field
+  ``dynfield2`` at its place in second cacheline if ``RTE_IOVA_AS_PA`` is 0.
+
 
 Known Issues
 ------------
diff --git a/lib/mbuf/rte_mbuf_core.h b/lib/mbuf/rte_mbuf_core.h
index dc6c54015e..37d3fcc3b8 100644
--- a/lib/mbuf/rte_mbuf_core.h
+++ b/lib/mbuf/rte_mbuf_core.h
@@ -479,10 +479,11 @@  struct rte_mbuf {
 	rte_iova_t buf_iova __rte_aligned(sizeof(rte_iova_t));
 #else
 	/**
-	 * Reserved for dynamic field in builds where physical address
-	 * field is undefined.
+	 * Next segment of scattered packet.
+	 * This field is valid when physical address field is undefined.
+	 * Otherwise next pointer in the second cache line will be used.
 	 */
-	uint64_t dynfield2;
+	struct rte_mbuf *next;
 #endif
 
 	/* next 8 bytes are initialised on RX descriptor rearm */
@@ -599,11 +600,19 @@  struct rte_mbuf {
 	/* second cache line - fields only used in slow path or on TX */
 	RTE_MARKER cacheline1 __rte_cache_min_aligned;
 
+#if RTE_IOVA_AS_PA
 	/**
-	 * Next segment of scattered packet. Must be NULL in the last segment or
-	 * in case of non-segmented packet.
+	 * Next segment of scattered packet. Must be NULL in the last
+	 * segment or in case of non-segmented packet.
 	 */
 	struct rte_mbuf *next;
+#else
+	/**
+	 * Reserved for dynamic field when the next pointer is in first
+	 * cache line (i.e. RTE_IOVA_AS_PA is 0).
+	 */
+	uint64_t dynfield2;
+#endif
 
 	/* fields to support TX offloads */
 	RTE_STD_C11