mbuf: improve mbuf comments
PATCH 1/1 mbuf: improve mbuf comments
Updated the comment preceding the 'rearm_data' fields to reflect that some ethdev drivers don't really set the rearm_data fields on RX descriptor rearm, but rather when pulling the packet from the descriptor. By doing this, they avoid a store operation into the mbuf when they rearm the TX descriptor, and instead postpone it to later, where it will be combined with other store operations into the mbuf.
Updated the comment describing what the second cache line is used for, to reflect that there are exceptions, where some fields are set on RX too.
Updated comments describing what needs to be updated when adding new RX and TX offload flags.
--- lib/mbuf/rte_mbuf_core.h | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-)
lib/mbuf/rte_mbuf_core.h +22 -7
@@ -37,8 +37,8 @@ extern "C" {* added to the right of the previously defined flags i.e. they should count * downwards, not upwards. * -* Keep these flags synchronized with rte_get_rx_ol_flag_name() and -* rte_get_tx_ol_flag_name(). +* Keep these flags synchronized with rte_get_rx_ol_flag_name(), rte_get_rx_ol_flag_list(), +* rte_get_tx_ol_flag_name(), and rte_get_tx_ol_flag_list(). */ /**
@@ -180,12 +180,20 @@ extern "C" {#define RTE_MBUF_F_RX_OUTER_L4_CKSUM_GOOD (1ULL << 22)#define RTE_MBUF_F_RX_OUTER_L4_CKSUM_INVALID ((1ULL << 21) | (1ULL << 22)) -/* add new RX flags here, don't forget to update RTE_MBUF_F_FIRST_FREE */ +/* +* Add new RX flags here. +* Don't forget to update RTE_MBUF_F_FIRST_FREE, +* rte_get_rx_ol_flag_name(), and rte_get_rx_ol_flag_list(). +*/ #define RTE_MBUF_F_FIRST_FREE (1ULL << 23)#define RTE_MBUF_F_LAST_FREE (1ULL << 40) -/* add new TX flags here, don't forget to update RTE_MBUF_F_LAST_FREE */ +/* +* Add new TX flags here. +* Don't forget to update RTE_MBUF_F_LAST_FREE, RTE_MBUF_F_TX_OFFLOAD_MASK, +* rte_get_tx_ol_flag_name(), and rte_get_tx_ol_flag_list(). +*/ /** * Outer UDP checksum offload flag. This flag is used for enabling
@@ -485,7 +493,10 @@ struct __rte_cache_aligned rte_mbuf {struct rte_mbuf *next;#endif -/* next 8 bytes are initialised on RX descriptor rearm */ +/* +* Next 8 bytes are initialised on RX descriptor rearm, +* or on RX when pulling packet from descriptor. +*/ union {uint64_t rearm_data[1 ]; __extension__
@@ -517,7 +528,7 @@ struct __rte_cache_aligned rte_mbuf {uint64_t ol_flags;/**< Offload features. */ -/* remaining 24 bytes are set on RX when pulling packet from descriptor */ +/* Remaining 24 bytes are set on RX when pulling packet from descriptor. */ union {/* void * type of the array elements is retained for driver compatibility. */ void *rx_descriptor_fields1[24 /sizeof (void *)];
@@ -603,7 +614,11 @@ struct __rte_cache_aligned rte_mbuf {struct rte_mempool *pool;/**< Pool from which mbuf was allocated. */ -/* second cache line - fields only used in slow path or on TX */ +/* +* Second cache line - fields only used in slow path or on TX. +* In special cases, some of these fields are also set on RX, +* most notably the 'next' field is set on RX scattered packets. +*/ #if RTE_IOVA_IN_MBUF /** * Next segment of scattered packet. Must be NULL in the last
Signature · 1 line
2.43.0
Quoted 10 lines
From: Morten Brørup [mailto:[email protected]]
Sent: Wednesday, 5 November 2025 12.28Updated the comment preceding the '
rearm_data' fields to reflect that some
ethdev drivers don't really set therearm_datafields on RX descriptor rearm, but rather when pulling the packet from the descriptor. By doing this, they avoid a store operation into the mbuf when they rearm
the TX descriptor, and instead postpone it to later, where it will be
Typo: TX descriptor -> RX descriptor.
Quoted 98 lines
combined with other store operations into the mbuf.
Updated the comment describing what the second cache line is used for, to
reflect that there are exceptions, where some fields are set on RX too.Updated comments describing what needs to be updated when adding new RX and TX offload flags.
Signed-off-by Morten Brørup <[email protected]>--- lib/mbuf/rte_mbuf_core.h | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-)lib/mbuf/rte_mbuf_core.h +0
-0@@ -37,8 +37,8 @@ extern "C" {* added to the right of the previously defined flags i.e. they should count
* downwards, not upwards.
*
- * Keep these flags synchronized withrte_get_rx_ol_flag_name()and
- *rte_get_tx_ol_flag_name().
+ * Keep these flags synchronized withrte_get_rx_ol_flag_name(),rte_get_rx_ol_flag_list(),
+ *rte_get_tx_ol_flag_name(), andrte_get_tx_ol_flag_list(). *//**
lib/mbuf/rte_mbuf_core.h +8
-2@@ -180,12 +180,20 @@ extern "C" {#define RTE_MBUF_F_RX_OUTER_L4_CKSUM_GOOD (1ULL << 22) #define RTE_MBUF_F_RX_OUTER_L4_CKSUM_INVALID ((1ULL << 21) | (1ULL << 22)) -/* add new RX flags here, don't forget to update RTE_MBUF_F_FIRST_FREE */ +/* +* Add new RX flags here. +* Don't forget to update RTE_MBUF_F_FIRST_FREE, +* rte_get_rx_ol_flag_name(), and rte_get_rx_ol_flag_list(). +*/ #define RTE_MBUF_F_FIRST_FREE (1ULL << 23)#define RTE_MBUF_F_LAST_FREE (1ULL << 40) -/* add new TX flags here, don't forget to update RTE_MBUF_F_LAST_FREE */ +/* +* Add new TX flags here. +* Don't forget to update RTE_MBUF_F_LAST_FREE,
RTE_MBUF_F_TX_OFFLOAD_MASK,
+ *rte_get_tx_ol_flag_name(), andrte_get_tx_ol_flag_list().
+ *//**
* Outer UDP checksum offload flag. This flag is used for enablinglib/mbuf/rte_mbuf_core.h +4
-2@@ -485,7 +493,10 @@ struct __rte_cache_aligned rte_mbuf {struct rte_mbuf *next;#endif -/* next 8 bytes are initialised on RX descriptor rearm */ +/* +* Next 8 bytes are initialised on RX descriptor rearm, +* or on RX when pulling packet from descriptor. +*/ union {uint64_t rearm_data[1 ]; __extension__@@ -517,7 +528,7 @@ struct __rte_cache_aligned rte_mbuf {uint64_t ol_flags;/**< Offload features. */ -/* remaining 24 bytes are set on RX when pulling packet from descriptor */
lib/mbuf/rte_mbuf_core.h +1
-0+/* Remaining 24 bytes are set on RX when pulling packet from descriptor. */
lib/mbuf/rte_mbuf_core.h +0
-0union {/* void * type of the array elements is retained for driver compatibility. */
lib/mbuf/rte_mbuf_core.h +0
-0void *rx_descriptor_fields1[24 /sizeof (void *)];@@ -603,7 +614,11 @@ struct __rte_cache_aligned rte_mbuf {struct rte_mempool *pool;/**< Pool from which mbuf was allocated. */
lib/mbuf/rte_mbuf_core.h +5
-2-/* second cache line - fields only used in slow path or on TX */ +/* +* Second cache line - fields only used in slow path or on TX. +* In special cases, some of these fields are also set on RX, +* most notably the 'next' field is set on RX scattered packets. +*/ #if RTE_IOVA_IN_MBUF /** * Next segment of scattered packet. Must be NULL in the last -- 2.43.0
05/11/2025 12:33, Morten Brørup:
Quoted 11 lines
Quoted 10 lines
From: Morten Brørup [mailto:[email protected]]
Sent: Wednesday, 5 November 2025 12.28Updated the comment preceding the '
rearm_data' fields to reflect that some
ethdev drivers don't really set therearm_datafields on RX descriptor rearm, but rather when pulling the packet from the descriptor. By doing this, they avoid a store operation into the mbuf when they rearm
the TX descriptor, and instead postpone it to later, where it will be
Quoted 1 line
Typo: TX descriptor -> RX descriptor.
Another Typo: RX -> Rx ;)
We agreed to prefer Tx/Rx capitalization in devtools/words-case.txt. I personnaly think it is more correct, as it is not an acronym.
Quoted 6 lines
Quoted 1 line
Typo: TX descriptor -> RX descriptor.
Another Typo: RX -> Rx ;)
We agreed to prefer Tx/Rx capitalization in
devtools/words-case.txt. I personnaly think it is more correct, as it is not an acronym.
It is an acronym, and I think RX/TX is generally more common than Rx/Tx. However, after checking with Claude, I'll respect the decision to use Rx/Tx. Please fix the spelling while merging.
My degree is in electrical engineering, not computer science, and Claude confirms that RX/TX is more common for electronics, while Rx/Tx is generally preferred for readability. So I learned something new about spelling today. ;-)
Claude:
Q: What is the origin of the shorthand form Rx and Tx, and which spelling is most commonly used, RX/TX or Rx/Tx? A:
The shorthand "Rx" and "Tx" have different origins depending on the context:
In Medicine/Pharmacy
Rx comes from Latin and has been used since medieval times. It's derived from the Latin word "recipe" (meaning "take" or "receive"), which was written at the beginning of prescriptions. Over time, the "R" with a crossed tail evolved into the symbol ℞ and then the shorthand "Rx." This is why prescriptions are often called "Rx."
Tx in medical contexts is a modern abbreviation for "treatment" or "therapy," likely created by analogy with Rx.
In Electronics/Telecommunications
Rx stands for "receive" or "receiver" Tx stands for "transmit" or "transmitter"
These abbreviations became standard in radio, telecommunications, and digital communications to label signal pins, circuits, and data lines.
Capitalization Convention
Both RX/TX and Rx/Tx are widely used, but the preference varies by field:
Electronics/Engineering: RX/TX (all caps) is more common, especially on technical diagrams, circuit boards, and data sheets
Medicine: Rx (capital R, lowercase x) is traditional and standard
General writing: Rx/Tx (mixed case) is often used for readability
In technical documentation for electronics, you'll see both styles, but RX/TX tends to be slightly more prevalent in professional contexts. However, both are perfectly acceptable and widely understood.
PATCH 1/1 mbuf: improve mbuf comments
In reply to Morten BrørupUpdated the comment preceding the 'rearm_data' fields to reflect that some ethdev drivers don't really set the rearm_data fields on Rx descriptor rearm, but rather when pulling the packet from the descriptor. By doing this, they avoid a store operation into the mbuf when they rearm the Rx descriptor, and instead postpone it to later, where it will be combined with other store operations into the mbuf.
Updated the comment describing what the second cache line is used for, to reflect that there are exceptions, where some fields are set on Rx too.
Updated comments describing what needs to be updated when adding new Rx and Tx offload flags.
---
v2:
* Fix typo in commit message.
* Fix spelling: RX/TX should be Rx/Tx. (Thomas Monjalon)
--- lib/mbuf/rte_mbuf_core.h | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-)
lib/mbuf/rte_mbuf_core.h +22 -7
@@ -37,8 +37,8 @@ extern "C" {* added to the right of the previously defined flags i.e. they should count * downwards, not upwards. * -* Keep these flags synchronized with rte_get_rx_ol_flag_name() and -* rte_get_tx_ol_flag_name(). +* Keep these flags synchronized with rte_get_rx_ol_flag_name(), rte_get_rx_ol_flag_list(), +* rte_get_tx_ol_flag_name(), and rte_get_tx_ol_flag_list(). */ /**
@@ -180,12 +180,20 @@ extern "C" {#define RTE_MBUF_F_RX_OUTER_L4_CKSUM_GOOD (1ULL << 22)#define RTE_MBUF_F_RX_OUTER_L4_CKSUM_INVALID ((1ULL << 21) | (1ULL << 22)) -/* add new RX flags here, don't forget to update RTE_MBUF_F_FIRST_FREE */ +/* +* Add new Rx flags here. +* Don't forget to update RTE_MBUF_F_FIRST_FREE, +* rte_get_rx_ol_flag_name(), and rte_get_rx_ol_flag_list(). +*/ #define RTE_MBUF_F_FIRST_FREE (1ULL << 23)#define RTE_MBUF_F_LAST_FREE (1ULL << 40) -/* add new TX flags here, don't forget to update RTE_MBUF_F_LAST_FREE */ +/* +* Add new Tx flags here. +* Don't forget to update RTE_MBUF_F_LAST_FREE, RTE_MBUF_F_TX_OFFLOAD_MASK, +* rte_get_tx_ol_flag_name(), and rte_get_tx_ol_flag_list(). +*/ /** * Outer UDP checksum offload flag. This flag is used for enabling
@@ -485,7 +493,10 @@ struct __rte_cache_aligned rte_mbuf {struct rte_mbuf *next;#endif -/* next 8 bytes are initialised on RX descriptor rearm */ +/* +* Next 8 bytes are initialised on Rx descriptor rearm, +* or on Rx when pulling packet from descriptor. +*/ union {uint64_t rearm_data[1 ]; __extension__
@@ -517,7 +528,7 @@ struct __rte_cache_aligned rte_mbuf {uint64_t ol_flags;/**< Offload features. */ -/* remaining 24 bytes are set on RX when pulling packet from descriptor */ +/* Remaining 24 bytes are set on Rx when pulling packet from descriptor. */ union {/* void * type of the array elements is retained for driver compatibility. */ void *rx_descriptor_fields1[24 /sizeof (void *)];
@@ -603,7 +614,11 @@ struct __rte_cache_aligned rte_mbuf {struct rte_mempool *pool;/**< Pool from which mbuf was allocated. */ -/* second cache line - fields only used in slow path or on TX */ +/* +* Second cache line - fields only used in slow path or on Tx. +* In special cases, some of these fields are also set on Rx, +* most notably the 'next' field is set on Rx scattered packets. +*/ #if RTE_IOVA_IN_MBUF /** * Next segment of scattered packet. Must be NULL in the last
Signature · 1 line
2.43.0
Please ignore this one. Forgot to save before sending.
Venlig hilsen / Kind regards,
-Morten Brørup
Quoted 116 lines
-----Original Message-----
From: Morten Brørup [mailto:[email protected]]
Sent: Friday, 7 November 2025 15.36
To: [email protected]; Thomas Monjalon
Cc: Morten Brørup
Subject: [PATCH] mbuf: improve mbuf commentsUpdated the comment preceding the '
rearm_data' fields to reflect that some
ethdev drivers don't really set therearm_datafields on Rx descriptor rearm, but rather when pulling the packet from the descriptor. By doing this, they avoid a store operation into the mbuf when they rearm
the Rx descriptor, and instead postpone it to later, where it will be combined with other store operations into the mbuf.Updated the comment describing what the second cache line is used for, to
reflect that there are exceptions, where some fields are set on Rx too.Updated comments describing what needs to be updated when adding new Rx and Tx offload flags.
Signed-off-by Morten Brørup <[email protected]>---
v2:
* Fix typo in commit message.
* Fix spelling: RX/TX should be Rx/Tx. (Thomas Monjalon)--- lib/mbuf/rte_mbuf_core.h | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-)lib/mbuf/rte_mbuf_core.h +0
-0@@ -37,8 +37,8 @@ extern "C" {* added to the right of the previously defined flags i.e. they should count
* downwards, not upwards.
*
- * Keep these flags synchronized withrte_get_rx_ol_flag_name()and
- *rte_get_tx_ol_flag_name().
+ * Keep these flags synchronized withrte_get_rx_ol_flag_name(),rte_get_rx_ol_flag_list(),
+ *rte_get_tx_ol_flag_name(), andrte_get_tx_ol_flag_list(). *//**
lib/mbuf/rte_mbuf_core.h +8
-2@@ -180,12 +180,20 @@ extern "C" {#define RTE_MBUF_F_RX_OUTER_L4_CKSUM_GOOD (1ULL << 22) #define RTE_MBUF_F_RX_OUTER_L4_CKSUM_INVALID ((1ULL << 21) | (1ULL << 22)) -/* add new RX flags here, don't forget to update RTE_MBUF_F_FIRST_FREE */ +/* +* Add new Rx flags here. +* Don't forget to update RTE_MBUF_F_FIRST_FREE, +* rte_get_rx_ol_flag_name(), and rte_get_rx_ol_flag_list(). +*/ #define RTE_MBUF_F_FIRST_FREE (1ULL << 23)#define RTE_MBUF_F_LAST_FREE (1ULL << 40) -/* add new TX flags here, don't forget to update RTE_MBUF_F_LAST_FREE */ +/* +* Add new Tx flags here. +* Don't forget to update RTE_MBUF_F_LAST_FREE,
RTE_MBUF_F_TX_OFFLOAD_MASK,
+ *rte_get_tx_ol_flag_name(), andrte_get_tx_ol_flag_list().
+ *//**
* Outer UDP checksum offload flag. This flag is used for enablinglib/mbuf/rte_mbuf_core.h +4
-2@@ -485,7 +493,10 @@ struct __rte_cache_aligned rte_mbuf {struct rte_mbuf *next;#endif -/* next 8 bytes are initialised on RX descriptor rearm */ +/* +* Next 8 bytes are initialised on Rx descriptor rearm, +* or on Rx when pulling packet from descriptor. +*/ union {uint64_t rearm_data[1 ]; __extension__@@ -517,7 +528,7 @@ struct __rte_cache_aligned rte_mbuf {uint64_t ol_flags;/**< Offload features. */ -/* remaining 24 bytes are set on RX when pulling packet from descriptor */
lib/mbuf/rte_mbuf_core.h +1
-0+/* Remaining 24 bytes are set on Rx when pulling packet from descriptor. */
lib/mbuf/rte_mbuf_core.h +0
-0union {/* void * type of the array elements is retained for driver compatibility. */
lib/mbuf/rte_mbuf_core.h +0
-0void *rx_descriptor_fields1[24 /sizeof (void *)];@@ -603,7 +614,11 @@ struct __rte_cache_aligned rte_mbuf {struct rte_mempool *pool;/**< Pool from which mbuf was allocated. */
lib/mbuf/rte_mbuf_core.h +5
-2-/* second cache line - fields only used in slow path or on TX */ +/* +* Second cache line - fields only used in slow path or on Tx. +* In special cases, some of these fields are also set on Rx, +* most notably the 'next' field is set on Rx scattered packets. +*/ #if RTE_IOVA_IN_MBUF /** * Next segment of scattered packet. Must be NULL in the last -- 2.43.0
PATCH v2 1/1 mbuf: improve mbuf comments
In reply to Morten BrørupUpdated the comment preceding the 'rearm_data' fields to reflect that some ethdev drivers don't really set the rearm_data fields on Rx descriptor rearm, but rather when pulling the packet from the descriptor. By doing this, they avoid a store operation into the mbuf when they rearm the Rx descriptor, and instead postpone it to later, where it will be combined with other store operations into the mbuf.
Updated the comment describing what the second cache line is used for, to reflect that there are exceptions, where some fields are set on Rx too.
Updated comments describing what needs to be updated when adding new Rx and Tx offload flags.
---
v2:
* Fix typo in commit message.
* Fix spelling: RX/TX should be Rx/Tx. (Thomas Monjalon)
--- lib/mbuf/rte_mbuf_core.h | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-)
lib/mbuf/rte_mbuf_core.h +22 -7
@@ -37,8 +37,8 @@ extern "C" {* added to the right of the previously defined flags i.e. they should count * downwards, not upwards. * -* Keep these flags synchronized with rte_get_rx_ol_flag_name() and -* rte_get_tx_ol_flag_name(). +* Keep these flags synchronized with rte_get_rx_ol_flag_name(), rte_get_rx_ol_flag_list(), +* rte_get_tx_ol_flag_name(), and rte_get_tx_ol_flag_list(). */ /**
@@ -180,12 +180,20 @@ extern "C" {#define RTE_MBUF_F_RX_OUTER_L4_CKSUM_GOOD (1ULL << 22)#define RTE_MBUF_F_RX_OUTER_L4_CKSUM_INVALID ((1ULL << 21) | (1ULL << 22)) -/* add new RX flags here, don't forget to update RTE_MBUF_F_FIRST_FREE */ +/* +* Add new Rx flags here. +* Don't forget to update RTE_MBUF_F_FIRST_FREE, +* rte_get_rx_ol_flag_name(), and rte_get_rx_ol_flag_list(). +*/ #define RTE_MBUF_F_FIRST_FREE (1ULL << 23)#define RTE_MBUF_F_LAST_FREE (1ULL << 40) -/* add new TX flags here, don't forget to update RTE_MBUF_F_LAST_FREE */ +/* +* Add new Tx flags here. +* Don't forget to update RTE_MBUF_F_LAST_FREE, RTE_MBUF_F_TX_OFFLOAD_MASK, +* rte_get_tx_ol_flag_name(), and rte_get_tx_ol_flag_list(). +*/ /** * Outer UDP checksum offload flag. This flag is used for enabling
@@ -485,7 +493,10 @@ struct __rte_cache_aligned rte_mbuf {struct rte_mbuf *next;#endif -/* next 8 bytes are initialised on RX descriptor rearm */ +/* +* Next 8 bytes are initialised on Rx descriptor rearm, +* or on Rx when pulling packet from descriptor. +*/ union {uint64_t rearm_data[1 ]; __extension__
@@ -517,7 +528,7 @@ struct __rte_cache_aligned rte_mbuf {uint64_t ol_flags;/**< Offload features. */ -/* remaining 24 bytes are set on RX when pulling packet from descriptor */ +/* Remaining 24 bytes are set on Rx when pulling packet from descriptor. */ union {/* void * type of the array elements is retained for driver compatibility. */ void *rx_descriptor_fields1[24 /sizeof (void *)];
@@ -603,7 +614,11 @@ struct __rte_cache_aligned rte_mbuf {struct rte_mempool *pool;/**< Pool from which mbuf was allocated. */ -/* second cache line - fields only used in slow path or on TX */ +/* +* Second cache line - fields only used in slow path or on Tx. +* In special cases, some of these fields are also set on Rx, +* most notably the 'next' field is set on Rx scattered packets. +*/ #if RTE_IOVA_IN_MBUF /** * Next segment of scattered packet. Must be NULL in the last
Signature · 1 line
2.43.0
Thomas Monjalon
Applied07/11/2025 15:36, Morten Brørup:
Quoted 7 lines
Updated the comment preceding the '
rearm_data' fields to reflect that some ethdev drivers don't really set therearm_datafields on Rx descriptor rearm, but rather when pulling the packet from the descriptor. By doing this, they avoid a store operation into the mbuf when they rearm the Rx descriptor, and instead postpone it to later, where it will be combined with other store operations into the mbuf.
Quoted 7 lines
Updated the comment describing what the second cache line is used for, to reflect that there are exceptions, where some fields are set on Rx too.
Updated comments describing what needs to be updated when adding new Rx and Tx offload flags.
Signed-off-by Morten Brørup <[email protected]>
Applied, thanks.