net/mlx5: declare size of rte_v128u32_t
PATCH 1/1 net/mlx5: declare size of rte_v128u32_t
When compiling with MSVC the error below is hit:
drivers\net\mlx5\mlx5_tx.h(1148): error C2065: 'rte_v128u32_t':
undeclared identifier
Turns out that with MSVC the data type rte_v128u32_t is not used, but its size needs to be known. This patch defines a macro to store that size and replaces instances of sizeof(rte_v128u32_t) with that macro.
--- drivers/net/mlx5/mlx5_defs.h | 2 ++ drivers/net/mlx5/mlx5_rxtx.c | 6 +++--- drivers/net/mlx5/mlx5_tx.h | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-)
drivers/net/mlx5/mlx5_defs.h +2 -0
@@ -196,4 +196,6 @@#define MLX5_CNT_SVC_CYCLE_TIME_DEFAULT 500 +#define MLX5_SIZEOF_V128U32_T 16 +#endif /* RTE_PMD_MLX5_DEFS_H_ */
drivers/net/mlx5/mlx5_rxtx.c +3 -3
@@ -32,7 +32,7 @@ static_assert(MLX5_CQE_STATUS_HW_OWN < 0, "Must be negative value");static_assert (MLX5_CQE_STATUS_SW_OWN <0 ,"Must be negative value" );static_assert (MLX5_ESEG_MIN_INLINE_SIZE == (sizeof (uint16_t ) + -sizeof (rte_v128u32_t)), +MLX5_SIZEOF_V128U32_T ),"invalid Ethernet Segment data size" ); static_assert(MLX5_ESEG_MIN_INLINE_SIZE == (sizeof(uint16_t) +
@@ -41,7 +41,7 @@ static_assert(MLX5_ESEG_MIN_INLINE_SIZE == "invalid Ethernet Segment data size");static_assert (MLX5_ESEG_MIN_INLINE_SIZE == (sizeof (uint16_t ) + -sizeof (rte_v128u32_t)), +MLX5_SIZEOF_V128U32_T ),"invalid Ethernet Segment data size" ); static_assert(MLX5_ESEG_MIN_INLINE_SIZE == (sizeof(uint16_t) +
@@ -50,7 +50,7 @@ static_assert(MLX5_ESEG_MIN_INLINE_SIZE == "invalid Ethernet Segment data size");static_assert (MLX5_ESEG_MIN_INLINE_SIZE == (sizeof (uint16_t ) + -sizeof (rte_v128u32_t)), +MLX5_SIZEOF_V128U32_T ),"invalid Ethernet Segment data size" ); static_assert(MLX5_ESEG_MIN_INLINE_SIZE == (sizeof(uint16_t) +
drivers/net/mlx5/mlx5_tx.h +1 -1
@@ -1145,7 +1145,7 @@ mlx5_tx_eseg_data(struct mlx5_txq_data *__rte_restrict txq, }else {/* Fill the gap in the title WQEBB with inline data. */ rte_mov16 (pdst, psrc); - psrc +=sizeof (rte_v128u32_t); + psrc +=MLX5_SIZEOF_V128U32_T ; } pdst = (uint8_t *)(es +2 );MLX5_ASSERT (inlen >=MLX5_ESEG_MIN_INLINE_SIZE );
Signature · 1 line
2.49.0.vfs.0.0
Hi, Andre,
Thanks for your contribution and patches,
This fix should be handled diff and not by const,
as the typedef might change in future and the const value will stay and cause a bug.
Regards,
Maayan Kashani
Quoted 87 lines
-----Original Message-----
From: Andre Muezerie <[email protected]>
Sent: Monday, 5 May 2025 18:10
To: Dariusz Sosnowski <[email protected]>; Slava Ovsiienko <[email protected]>; Bing Zhao <[email protected]>; Ori Kam <[email protected]>; Suanming Mou <[email protected]>; Matan Azrad <[email protected]>
Cc: [email protected]; Andre Muezerie <[email protected]>
Subject: [PATCH] net/mlx5: declare size ofrte_v128u32_tExternal email: Use caution opening links or attachments
When compiling with MSVC the error below is hit:
drivers\net\mlx5\mlx5_tx.h(1148): error C2065: '
rte_v128u32_t':
undeclared identifierTurns out that with MSVC the data type
rte_v128u32_tis not used, but its size needs to be known. This patch defines a macro to store that size and replaces instances ofsizeof(rte_v128u32_t)with that macro.Signed-off-by Andre Muezerie <[email protected]>--- drivers/net/mlx5/mlx5_defs.h | 2 ++ drivers/net/mlx5/mlx5_rxtx.c | 6 +++--- drivers/net/mlx5/mlx5_tx.h | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-)drivers/net/mlx5/mlx5_defs.h +2
-0@@ -196,4 +196,6 @@#define MLX5_CNT_SVC_CYCLE_TIME_DEFAULT 500 +#define MLX5_SIZEOF_V128U32_T 16 +#endif /* RTE_PMD_MLX5_DEFS_H_ */ drivers/net/mlx5/mlx5_rxtx.c +0
-0@@ -32,7 +32,7 @@ static_assert(MLX5_CQE_STATUS_HW_OWN < 0, "Mustbe negative value");
static_assert(MLX5_CQE_STATUS_SW_OWN < 0, "Must be negative value"); static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==(sizeof(uint16_t) +drivers/net/mlx5/mlx5_rxtx.c +1
-1- sizeof(rte_v128u32_t)), + MLX5_SIZEOF_V128U32_T), "invalid Ethernet Segment data size");static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==
(sizeof(uint16_t) +drivers/net/mlx5/mlx5_rxtx.c +0
-0@@ -41,7 +41,7 @@ static_assert(MLX5_ESEG_MIN_INLINE_SIZE == "invalid Ethernet Segment data size");static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==
(sizeof(uint16_t) +drivers/net/mlx5/mlx5_rxtx.c +1
-1- sizeof(rte_v128u32_t)), + MLX5_SIZEOF_V128U32_T), "invalid Ethernet Segment data size");static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==
(sizeof(uint16_t) +drivers/net/mlx5/mlx5_rxtx.c +0
-0@@ -50,7 +50,7 @@ static_assert(MLX5_ESEG_MIN_INLINE_SIZE == "invalid Ethernet Segment data size");static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==
(sizeof(uint16_t) +drivers/net/mlx5/mlx5_rxtx.c +1
-1- sizeof(rte_v128u32_t)), + MLX5_SIZEOF_V128U32_T), "invalid Ethernet Segment data size");static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==
(sizeof(uint16_t) +drivers/net/mlx5/mlx5_tx.h index renamed from drivers/net/mlx5/mlx5_tx.h +0
-0
55568c41b1..5647f6a37d100644drivers/net/mlx5/mlx5_tx.h +1
-1@@ -1145,7 +1145,7 @@ mlx5_tx_eseg_data(struct mlx5_txq_data *__rte_restrict txq, }else {/* Fill the gap in the title WQEBB with inline data. */ rte_mov16 (pdst, psrc); - psrc +=sizeof (rte_v128u32_t); + psrc +=MLX5_SIZEOF_V128U32_T ; } pdst = (uint8_t *)(es +2 );MLX5_ASSERT(inlen >= MLX5_ESEG_MIN_INLINE_SIZE);--
2.49.0.vfs.0.0
Quoted 5 lines · Maayan Kashani
Hi, Andre,
Thanks for your contribution and patches,
This fix should be handled diff and not by const,
as the typedef might change in future and the const value will stay and cause a bug.
Hi Maayan,
I agree that in general it's better to not hardcode the size of a structure because as you said, structures can change over time.
This specific structure is defined as
typedef uint32_t rte_v128u32_t __attribute__((vector_size(16), aligned(16)));
which uses non-standard __attribute__, which MSVC does not implement. We could create a MSVC-specific definition, but then we would have the same problem again: when updating the old definition, this new one could be missed.
That makes me think that a good approach would be to have a static assert that ensures that MLX5_SIZEOF_V128U32_T holds the correct value. This would avoid the need to create the MSVC-specific definition, which has no other use for now. This should address the concern you raised.
It should also be noted that rte_v128u32_t has a rigid size - its name implies that it is 128 bits long. If that size ever changed, the name of the structure would likely be changed as well.
I'll send out the updated patch adding the assert. Let me know what you think about it.
Regards,
Andre
Quoted 91 lines
Regards,
Maayan KashaniQuoted 87 lines
-----Original Message-----
From: Andre Muezerie <[email protected]>
Sent: Monday, 5 May 2025 18:10
To: Dariusz Sosnowski <[email protected]>; Slava Ovsiienko <[email protected]>; Bing Zhao <[email protected]>; Ori Kam <[email protected]>; Suanming Mou <[email protected]>; Matan Azrad <[email protected]>
Cc: [email protected]; Andre Muezerie <[email protected]>
Subject: [PATCH] net/mlx5: declare size ofrte_v128u32_tExternal email: Use caution opening links or attachments
When compiling with MSVC the error below is hit:
drivers\net\mlx5\mlx5_tx.h(1148): error C2065: '
rte_v128u32_t':
undeclared identifierTurns out that with MSVC the data type
rte_v128u32_tis not used, but its size needs to be known. This patch defines a macro to store that size and replaces instances ofsizeof(rte_v128u32_t)with that macro.Signed-off-by Andre Muezerie <[email protected]>--- drivers/net/mlx5/mlx5_defs.h | 2 ++ drivers/net/mlx5/mlx5_rxtx.c | 6 +++--- drivers/net/mlx5/mlx5_tx.h | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-)drivers/net/mlx5/mlx5_defs.h +2
-0@@ -196,4 +196,6 @@#define MLX5_CNT_SVC_CYCLE_TIME_DEFAULT 500 +#define MLX5_SIZEOF_V128U32_T 16 +#endif /* RTE_PMD_MLX5_DEFS_H_ */ drivers/net/mlx5/mlx5_rxtx.c +0
-0@@ -32,7 +32,7 @@ static_assert(MLX5_CQE_STATUS_HW_OWN < 0, "Mustbe negative value");
static_assert(MLX5_CQE_STATUS_SW_OWN < 0, "Must be negative value"); static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==(sizeof(uint16_t) +drivers/net/mlx5/mlx5_rxtx.c +1
-1- sizeof(rte_v128u32_t)), + MLX5_SIZEOF_V128U32_T), "invalid Ethernet Segment data size");static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==
(sizeof(uint16_t) +drivers/net/mlx5/mlx5_rxtx.c +0
-0@@ -41,7 +41,7 @@ static_assert(MLX5_ESEG_MIN_INLINE_SIZE == "invalid Ethernet Segment data size");static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==
(sizeof(uint16_t) +drivers/net/mlx5/mlx5_rxtx.c +1
-1- sizeof(rte_v128u32_t)), + MLX5_SIZEOF_V128U32_T), "invalid Ethernet Segment data size");static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==
(sizeof(uint16_t) +drivers/net/mlx5/mlx5_rxtx.c +0
-0@@ -50,7 +50,7 @@ static_assert(MLX5_ESEG_MIN_INLINE_SIZE == "invalid Ethernet Segment data size");static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==
(sizeof(uint16_t) +drivers/net/mlx5/mlx5_rxtx.c +1
-1- sizeof(rte_v128u32_t)), + MLX5_SIZEOF_V128U32_T), "invalid Ethernet Segment data size");static_assert(MLX5_ESEG_MIN_INLINE_SIZE ==
(sizeof(uint16_t) +drivers/net/mlx5/mlx5_tx.h index renamed from drivers/net/mlx5/mlx5_tx.h +0
-0
55568c41b1..5647f6a37d100644drivers/net/mlx5/mlx5_tx.h +1
-1@@ -1145,7 +1145,7 @@ mlx5_tx_eseg_data(struct mlx5_txq_data *__rte_restrict txq, }else {/* Fill the gap in the title WQEBB with inline data. */ rte_mov16 (pdst, psrc); - psrc +=sizeof (rte_v128u32_t); + psrc +=MLX5_SIZEOF_V128U32_T ; } pdst = (uint8_t *)(es +2 );MLX5_ASSERT(inlen >= MLX5_ESEG_MIN_INLINE_SIZE);--
2.49.0.vfs.0.0
PATCH v2 1/1 net/mlx5: declare size of rte_v128u32_t
In reply to Andre MuezerieWhen compiling with MSVC the error below is hit:
drivers\net\mlx5\mlx5_tx.h(1148): error C2065: 'rte_v128u32_t':
undeclared identifier
Turns out that with MSVC the data type rte_v128u32_t is not used, but its size needs to be known. This patch defines a macro to store that size and replaces instances of sizeof(rte_v128u32_t) with that macro.
A static assert is added to ensure the new macro never diverges from sizeof(rte_v128u32_t).
--- drivers/net/mlx5/mlx5_defs.h | 2 ++ drivers/net/mlx5/mlx5_rxtx.c | 11 ++++++++--- drivers/net/mlx5/mlx5_tx.h | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-)
drivers/net/mlx5/mlx5_defs.h +2 -0
@@ -196,4 +196,6 @@#define MLX5_CNT_SVC_CYCLE_TIME_DEFAULT 500 +#define MLX5_SIZEOF_V128U32_T 16 +#endif /* RTE_PMD_MLX5_DEFS_H_ */
drivers/net/mlx5/mlx5_rxtx.c +8 -3
@@ -28,11 +28,16 @@#include "mlx5_tx.h" /* static asserts */ +#ifndef RTE_TOOLCHAIN_MSVC +static_assert (sizeof (rte_v128u32_t) ==MLX5_SIZEOF_V128U32_T , +"MLX5_SIZEOF_V128U32_T must hold sizeof(rte_v128u32_t)" ); +#endif +static_assert (MLX5_CQE_STATUS_HW_OWN <0 ,"Must be negative value" );static_assert (MLX5_CQE_STATUS_SW_OWN <0 ,"Must be negative value" );static_assert (MLX5_ESEG_MIN_INLINE_SIZE == (sizeof (uint16_t ) + -sizeof (rte_v128u32_t)), +MLX5_SIZEOF_V128U32_T ),"invalid Ethernet Segment data size" ); static_assert(MLX5_ESEG_MIN_INLINE_SIZE == (sizeof(uint16_t) +
@@ -41,7 +46,7 @@ static_assert(MLX5_ESEG_MIN_INLINE_SIZE == "invalid Ethernet Segment data size");static_assert (MLX5_ESEG_MIN_INLINE_SIZE == (sizeof (uint16_t ) + -sizeof (rte_v128u32_t)), +MLX5_SIZEOF_V128U32_T ),"invalid Ethernet Segment data size" ); static_assert(MLX5_ESEG_MIN_INLINE_SIZE == (sizeof(uint16_t) +
@@ -50,7 +55,7 @@ static_assert(MLX5_ESEG_MIN_INLINE_SIZE == "invalid Ethernet Segment data size");static_assert (MLX5_ESEG_MIN_INLINE_SIZE == (sizeof (uint16_t ) + -sizeof (rte_v128u32_t)), +MLX5_SIZEOF_V128U32_T ),"invalid Ethernet Segment data size" ); static_assert(MLX5_ESEG_MIN_INLINE_SIZE == (sizeof(uint16_t) +
drivers/net/mlx5/mlx5_tx.h +1 -1
@@ -1145,7 +1145,7 @@ mlx5_tx_eseg_data(struct mlx5_txq_data *__rte_restrict txq, }else {/* Fill the gap in the title WQEBB with inline data. */ rte_mov16 (pdst, psrc); - psrc +=sizeof (rte_v128u32_t); + psrc +=MLX5_SIZEOF_V128U32_T ; } pdst = (uint8_t *)(es +2 );MLX5_ASSERT (inlen >=MLX5_ESEG_MIN_INLINE_SIZE );
Signature · 1 line
2.49.0.vfs.0.3
Hi,
Quoted 35 lines · Andre Muezerie
When compiling with MSVC the error below is hit:
drivers\net\mlx5\mlx5_tx.h(1148): error C2065: '
rte_v128u32_t':
undeclared identifierTurns out that with MSVC the data type
rte_v128u32_tis not used, but its size needs to be known. This patch defines a macro to store that size and replaces instances ofsizeof(rte_v128u32_t)with that macro.A static assert is added to ensure the new macro never diverges from
sizeof(rte_v128u32_t).Signed-off-by Andre Muezerie <[email protected]>--- drivers/net/mlx5/mlx5_defs.h | 2 ++ drivers/net/mlx5/mlx5_rxtx.c | 11 ++++++++--- drivers/net/mlx5/mlx5_tx.h | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-)drivers/net/mlx5/mlx5_defs.h +2
-0@@ -196,4 +196,6 @@#define MLX5_CNT_SVC_CYCLE_TIME_DEFAULT 500 +#define MLX5_SIZEOF_V128U32_T 16 +#endif /* RTE_PMD_MLX5_DEFS_H_ */ drivers/net/mlx5/mlx5_rxtx.c +0
-0
drivers/net/mlx5/mlx5_rxtx.c line 34
Quoted 7 lines
drivers/net/mlx5/mlx5_rxtx.c +4
-0@@ -28,11 +28,16 @@#include "mlx5_tx.h" /* static asserts */ +#ifndef RTE_TOOLCHAIN_MSVC +static_assert (sizeof (rte_v128u32_t) ==MLX5_SIZEOF_V128U32_T , +"MLX5_SIZEOF_V128U32_T must hold sizeof(rte_v128u32_t)" ); +#endif
Thank you for the patch.
This proposal is ok, but I think it can be slightly improved.
The reference to rte_v128u32_t (in code and in names) can be removed, because the code which relies on MLX5_ESEG_MIN_INLINE_SIZE does not really use rte_v128u32_t type. The relevant code e.g., in mlx5_tx_eseg_dmin(), always copies first 2 bytes of the packet (through uint16_t pointer, these would be first 2 bytes of destination MAC address)
and then does one of the two:
1. Copies following 16 bytes using rte_mov16(). (Corresponds to first static_assert for MLX5_ESEG_MIN_INLINE_SIZE).
2. If there is a VLAN defined in mbuf, then:
- the rest of destination MAC address is copied,
- source MAC address is copied,
- VLAN is inserted,
- 2 bytes appearing after VLAN header are copied. (Corresponds to 2nd static_assert for MLX5_ESEG_MIN_INLINE_SIZE).
Amount of data copied is inferred from HW arch and packet descriptor layout, not rte_v128u32_t.
Since rte_mov16() is used in real code and rte_v128u32_t is only used to carry over the length of the copy, I would propose to:
- Replace instances of sizeof(rte_v128u32_t) with a macro named MLX5_SIZE_MOV16 to better reflect the real usage in mlx5 PMD.
- Remove static_assert for
"sizeof(rte_v128u32_t) == MLX5_SIZEOF_V128U32_T".
Would you be able to apply these changes?
Quoted 44 lines
drivers/net/mlx5/mlx5_rxtx.c +4
-3+static_assert (MLX5_CQE_STATUS_HW_OWN <0 ,"Must be negative value" );static_assert (MLX5_CQE_STATUS_SW_OWN <0 ,"Must be negative value" );static_assert (MLX5_ESEG_MIN_INLINE_SIZE == (sizeof (uint16_t ) + -sizeof (rte_v128u32_t)), +MLX5_SIZEOF_V128U32_T ),"invalid Ethernet Segment data size" ); static_assert(MLX5_ESEG_MIN_INLINE_SIZE == (sizeof(uint16_t) +@@ -41,7 +46,7 @@ static_assert(MLX5_ESEG_MIN_INLINE_SIZE == "invalid Ethernet Segment data size");static_assert (MLX5_ESEG_MIN_INLINE_SIZE == (sizeof (uint16_t ) + -sizeof (rte_v128u32_t)), +MLX5_SIZEOF_V128U32_T ),"invalid Ethernet Segment data size" ); static_assert(MLX5_ESEG_MIN_INLINE_SIZE == (sizeof(uint16_t) +@@ -50,7 +55,7 @@ static_assert(MLX5_ESEG_MIN_INLINE_SIZE == "invalid Ethernet Segment data size");static_assert (MLX5_ESEG_MIN_INLINE_SIZE == (sizeof (uint16_t ) + -sizeof (rte_v128u32_t)), +MLX5_SIZEOF_V128U32_T ),"invalid Ethernet Segment data size" ); static_assert(MLX5_ESEG_MIN_INLINE_SIZE == (sizeof(uint16_t) +drivers/net/mlx5/mlx5_tx.h +1
-1@@ -1145,7 +1145,7 @@ mlx5_tx_eseg_data(struct mlx5_txq_data *__rte_restrict txq, }else {/* Fill the gap in the title WQEBB with inline data. */ rte_mov16 (pdst, psrc); - psrc +=sizeof (rte_v128u32_t); + psrc +=MLX5_SIZEOF_V128U32_T ; } pdst = (uint8_t *)(es +2 );MLX5_ASSERT (inlen >=MLX5_ESEG_MIN_INLINE_SIZE );Signature · 1 line
2.49.0.vfs.0.3
Best regards,
Dariusz Sosnowski
Quoted 71 lines · Dariusz Sosnowski
Hi,
Quoted 35 lines · Andre Muezerie
When compiling with MSVC the error below is hit:
drivers\net\mlx5\mlx5_tx.h(1148): error C2065: '
rte_v128u32_t':
undeclared identifierTurns out that with MSVC the data type
rte_v128u32_tis not used, but its size needs to be known. This patch defines a macro to store that size and replaces instances ofsizeof(rte_v128u32_t)with that macro.A static assert is added to ensure the new macro never diverges from
sizeof(rte_v128u32_t).Signed-off-by Andre Muezerie <[email protected]>--- drivers/net/mlx5/mlx5_defs.h | 2 ++ drivers/net/mlx5/mlx5_rxtx.c | 11 ++++++++--- drivers/net/mlx5/mlx5_tx.h | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-)drivers/net/mlx5/mlx5_defs.h +2
-0@@ -196,4 +196,6 @@#define MLX5_CNT_SVC_CYCLE_TIME_DEFAULT 500 +#define MLX5_SIZEOF_V128U32_T 16 +#endif /* RTE_PMD_MLX5_DEFS_H_ */ drivers/net/mlx5/mlx5_rxtx.c +0
-0drivers/net/mlx5/mlx5_rxtx.c line 34
Quoted 7 lines
drivers/net/mlx5/mlx5_rxtx.c +4
-0@@ -28,11 +28,16 @@#include "mlx5_tx.h" /* static asserts */ +#ifndef RTE_TOOLCHAIN_MSVC +static_assert (sizeof (rte_v128u32_t) ==MLX5_SIZEOF_V128U32_T , +"MLX5_SIZEOF_V128U32_T must hold sizeof(rte_v128u32_t)" ); +#endif Thank you for the patch.
This proposal is ok, but I think it can be slightly improved.The reference to
rte_v128u32_t(in code and in names) can be removed, because the code which relies onMLX5_ESEG_MIN_INLINE_SIZEdoes not really userte_v128u32_ttype. The relevant code e.g., inmlx5_tx_eseg_dmin(), always copies first 2 bytes of the packet (throughuint16_tpointer, these would be first 2 bytes of destination MAC address)
and then does one of the two:1. Copies following 16 bytes using
rte_mov16(). (Corresponds to firststatic_assertforMLX5_ESEG_MIN_INLINE_SIZE).
2. If there is a VLAN defined in mbuf, then:
- the rest of destination MAC address is copied,
- source MAC address is copied,
- VLAN is inserted,
- 2 bytes appearing after VLAN header are copied. (Corresponds to 2ndstatic_assertforMLX5_ESEG_MIN_INLINE_SIZE).Amount of data copied is inferred from HW arch and packet descriptor layout, not
rte_v128u32_t.Since
rte_mov16()is used in real code andrte_v128u32_tis only used to carry over the length of the copy, I would propose to:
Quoted 6 lines
- Replace instances of
sizeof(rte_v128u32_t)with a macro namedMLX5_SIZE_MOV16to better reflect the real usage in mlx5 PMD.
- Removestatic_assertfor
"sizeof(rte_v128u32_t)==MLX5_SIZEOF_V128U32_T".Would you be able to apply these changes?
Yes, I'll send a new patch with the changes suggested.
Thanks,
Andre Muezerie
Quoted 48 lines
Quoted 45 lines
drivers/net/mlx5/mlx5_rxtx.c +4
-3+static_assert (MLX5_CQE_STATUS_HW_OWN <0 ,"Must be negative value" );static_assert (MLX5_CQE_STATUS_SW_OWN <0 ,"Must be negative value" );static_assert (MLX5_ESEG_MIN_INLINE_SIZE == (sizeof (uint16_t ) + -sizeof (rte_v128u32_t)), +MLX5_SIZEOF_V128U32_T ),"invalid Ethernet Segment data size" ); static_assert(MLX5_ESEG_MIN_INLINE_SIZE == (sizeof(uint16_t) +@@ -41,7 +46,7 @@ static_assert(MLX5_ESEG_MIN_INLINE_SIZE == "invalid Ethernet Segment data size");static_assert (MLX5_ESEG_MIN_INLINE_SIZE == (sizeof (uint16_t ) + -sizeof (rte_v128u32_t)), +MLX5_SIZEOF_V128U32_T ),"invalid Ethernet Segment data size" ); static_assert(MLX5_ESEG_MIN_INLINE_SIZE == (sizeof(uint16_t) +@@ -50,7 +55,7 @@ static_assert(MLX5_ESEG_MIN_INLINE_SIZE == "invalid Ethernet Segment data size");static_assert (MLX5_ESEG_MIN_INLINE_SIZE == (sizeof (uint16_t ) + -sizeof (rte_v128u32_t)), +MLX5_SIZEOF_V128U32_T ),"invalid Ethernet Segment data size" ); static_assert(MLX5_ESEG_MIN_INLINE_SIZE == (sizeof(uint16_t) +drivers/net/mlx5/mlx5_tx.h +1
-1@@ -1145,7 +1145,7 @@ mlx5_tx_eseg_data(struct mlx5_txq_data *__rte_restrict txq, }else {/* Fill the gap in the title WQEBB with inline data. */ rte_mov16 (pdst, psrc); - psrc +=sizeof (rte_v128u32_t); + psrc +=MLX5_SIZEOF_V128U32_T ; } pdst = (uint8_t *)(es +2 );MLX5_ASSERT (inlen >=MLX5_ESEG_MIN_INLINE_SIZE );Signature · 1 line
2.49.0.vfs.0.3Best regards,
Dariusz Sosnowski
PATCH v3 1/1 net/mlx5: remove use of sizeof(rte_v128u32_t)
In reply to Andre MuezerieWhen compiling with MSVC the error below is hit:
drivers\net\mlx5\mlx5_tx.h(1148): error C2065: 'rte_v128u32_t':
undeclared identifier
The reference to rte_v128u32_t (in code and in names) can be removed, because the code which relies on MLX5_ESEG_MIN_INLINE_SIZE does not really use rte_v128u32_t type. The relevant code e.g.,
in mlx5_tx_eseg_dmin(), always copies first 2 bytes of the packet (through uint16_t pointer, these would be first 2 bytes of destination MAC address) and then does one of the two:
1. Copies following 16 bytes using rte_mov16(). (Corresponds to first static_assert for MLX5_ESEG_MIN_INLINE_SIZE).
2. If there is a VLAN defined in mbuf, then:
- the rest of destination MAC address is copied,
- source MAC address is copied,
- VLAN is inserted,
- 2 bytes appearing after VLAN header are copied. (Corresponds to 2nd static_assert for MLX5_ESEG_MIN_INLINE_SIZE).
The amount of data copied is inferred from HW arch and packet descriptor layout, not rte_v128u32_t.
Since rte_mov16() is used in real code and rte_v128u32_t is only used to carry over the length of the copy, this patch replaces instances of sizeof(rte_v128u32_t) with a macro named MLX5_SIZE_MOV16 to better reflect the real usage in mlx5 PMD.
--- drivers/net/mlx5/mlx5_defs.h | 2 ++ drivers/net/mlx5/mlx5_rxtx.c | 6 +++--- drivers/net/mlx5/mlx5_tx.h | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-)
drivers/net/mlx5/mlx5_defs.h +2 -0
@@ -196,4 +196,6 @@#define MLX5_CNT_SVC_CYCLE_TIME_DEFAULT 500 +#define MLX5_SIZE_MOV16 16 +#endif /* RTE_PMD_MLX5_DEFS_H_ */
drivers/net/mlx5/mlx5_rxtx.c +3 -3
@@ -32,7 +32,7 @@ static_assert(MLX5_CQE_STATUS_HW_OWN < 0, "Must be negative value");static_assert (MLX5_CQE_STATUS_SW_OWN <0 ,"Must be negative value" );static_assert (MLX5_ESEG_MIN_INLINE_SIZE == (sizeof (uint16_t ) + -sizeof (rte_v128u32_t)), +MLX5_SIZE_MOV16 ),"invalid Ethernet Segment data size" ); static_assert(MLX5_ESEG_MIN_INLINE_SIZE == (sizeof(uint16_t) +
@@ -41,7 +41,7 @@ static_assert(MLX5_ESEG_MIN_INLINE_SIZE == "invalid Ethernet Segment data size");static_assert (MLX5_ESEG_MIN_INLINE_SIZE == (sizeof (uint16_t ) + -sizeof (rte_v128u32_t)), +MLX5_SIZE_MOV16 ),"invalid Ethernet Segment data size" ); static_assert(MLX5_ESEG_MIN_INLINE_SIZE == (sizeof(uint16_t) +
@@ -50,7 +50,7 @@ static_assert(MLX5_ESEG_MIN_INLINE_SIZE == "invalid Ethernet Segment data size");static_assert (MLX5_ESEG_MIN_INLINE_SIZE == (sizeof (uint16_t ) + -sizeof (rte_v128u32_t)), +MLX5_SIZE_MOV16 ),"invalid Ethernet Segment data size" ); static_assert(MLX5_ESEG_MIN_INLINE_SIZE == (sizeof(uint16_t) +
drivers/net/mlx5/mlx5_tx.h +1 -1
@@ -1147,7 +1147,7 @@ mlx5_tx_eseg_data(struct mlx5_txq_data *__rte_restrict txq, }else {/* Fill the gap in the title WQEBB with inline data. */ rte_mov16 (pdst, psrc); - psrc +=sizeof (rte_v128u32_t); + psrc +=MLX5_SIZE_MOV16 ; } pdst = (uint8_t *)(es +2 );MLX5_ASSERT (inlen >=MLX5_ESEG_MIN_INLINE_SIZE );
Signature · 1 line
2.49.0.vfs.0.4
Re: [PATCH v3] net/mlx5: remove use of sizeof(rte_v128u32_t)
Thank you for addressing the comments.
Quoted 24 lines · Andre Muezerie
When compiling with MSVC the error below is hit:
drivers\net\mlx5\mlx5_tx.h(1148): error C2065: '
rte_v128u32_t':
undeclared identifierThe reference to
rte_v128u32_t(in code and in names) can be removed, because the code which relies onMLX5_ESEG_MIN_INLINE_SIZEdoes not really userte_v128u32_ttype. The relevant code e.g.,
inmlx5_tx_eseg_dmin(), always copies first 2 bytes of the packet (throughuint16_tpointer, these would be first 2 bytes of destination MAC address) and then does one of the two:1. Copies following 16 bytes using
rte_mov16(). (Corresponds to firststatic_assertforMLX5_ESEG_MIN_INLINE_SIZE).
2. If there is a VLAN defined in mbuf, then:
- the rest of destination MAC address is copied,
- source MAC address is copied,
- VLAN is inserted,
- 2 bytes appearing after VLAN header are copied. (Corresponds to 2ndstatic_assertforMLX5_ESEG_MIN_INLINE_SIZE).The amount of data copied is inferred from HW arch and packet descriptor layout, not
rte_v128u32_t.
Quoted 6 lines
Since
rte_mov16()is used in real code andrte_v128u32_tis only used to carry over the length of the copy, this patch replaces instances ofsizeof(rte_v128u32_t)with a macro namedMLX5_SIZE_MOV16to better reflect the real usage in mlx5 PMD.Signed-off-by Andre Muezerie <[email protected]>
Best regards,
Dariusz Sosnowski
Thomas Monjalon
AppliedRe: [PATCH v3] net/mlx5: remove use of sizeof(rte_v128u32_t)
09/07/2025 09:26, Dariusz Sosnowski:
Quoted 27 lines
Thank you for addressing the comments.
Quoted 24 lines · Andre Muezerie
When compiling with MSVC the error below is hit:
drivers\net\mlx5\mlx5_tx.h(1148): error C2065: '
rte_v128u32_t':
undeclared identifierThe reference to
rte_v128u32_t(in code and in names) can be removed, because the code which relies onMLX5_ESEG_MIN_INLINE_SIZEdoes not really userte_v128u32_ttype. The relevant code e.g.,
inmlx5_tx_eseg_dmin(), always copies first 2 bytes of the packet (throughuint16_tpointer, these would be first 2 bytes of destination MAC address) and then does one of the two:1. Copies following 16 bytes using
rte_mov16(). (Corresponds to firststatic_assertforMLX5_ESEG_MIN_INLINE_SIZE).
2. If there is a VLAN defined in mbuf, then:
- the rest of destination MAC address is copied,
- source MAC address is copied,
- VLAN is inserted,
- 2 bytes appearing after VLAN header are copied. (Corresponds to 2ndstatic_assertforMLX5_ESEG_MIN_INLINE_SIZE).The amount of data copied is inferred from HW arch and packet descriptor layout, not
rte_v128u32_t.
Quoted 8 lines
Quoted 6 lines
Since
rte_mov16()is used in real code andrte_v128u32_tis only used to carry over the length of the copy, this patch replaces instances ofsizeof(rte_v128u32_t)with a macro namedMLX5_SIZE_MOV16to better reflect the real usage in mlx5 PMD.Signed-off-by Andre Muezerie <[email protected]>
Applied, thanks.
Looks like the generic vector types rte_v*_t are useless, and not compatible with MSVC.
We may think whether we really want to keep them.