* [PATCH] net/mlx5: declare size of rte_v128u32_t @ 2025-05-05 15:10 Andre Muezerie 2025-05-25 8:47 ` Maayan Kashani 2025-05-31 0:21 ` [PATCH v2] " Andre Muezerie 0 siblings, 2 replies; 4+ messages in thread From: Andre Muezerie @ 2025-05-05 15:10 UTC (permalink / raw) To: Dariusz Sosnowski, Viacheslav Ovsiienko, Bing Zhao, Ori Kam, Suanming Mou, Matan Azrad Cc: dev, Andre Muezerie 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. Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com> --- 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(-) diff --git a/drivers/net/mlx5/mlx5_defs.h b/drivers/net/mlx5/mlx5_defs.h index 9c454983be..c5e2c59309 100644 --- a/drivers/net/mlx5/mlx5_defs.h +++ b/drivers/net/mlx5/mlx5_defs.h @@ -196,4 +196,6 @@ #define MLX5_CNT_SVC_CYCLE_TIME_DEFAULT 500 +#define MLX5_SIZEOF_V128U32_T 16 + #endif /* RTE_PMD_MLX5_DEFS_H_ */ diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c index 9c075f6a56..b30d620f54 100644 --- a/drivers/net/mlx5/mlx5_rxtx.c +++ b/drivers/net/mlx5/mlx5_rxtx.c @@ -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) + diff --git a/drivers/net/mlx5/mlx5_tx.h b/drivers/net/mlx5/mlx5_tx.h index 55568c41b1..5647f6a37d 100644 --- a/drivers/net/mlx5/mlx5_tx.h +++ b/drivers/net/mlx5/mlx5_tx.h @@ -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 ^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH] net/mlx5: declare size of rte_v128u32_t 2025-05-05 15:10 [PATCH] net/mlx5: declare size of rte_v128u32_t Andre Muezerie @ 2025-05-25 8:47 ` Maayan Kashani 2025-05-31 0:20 ` Andre Muezerie 2025-05-31 0:21 ` [PATCH v2] " Andre Muezerie 1 sibling, 1 reply; 4+ messages in thread From: Maayan Kashani @ 2025-05-25 8:47 UTC (permalink / raw) To: Andre Muezerie, Dariusz Sosnowski, Slava Ovsiienko, Bing Zhao, Ori Kam, Suanming Mou, Matan Azrad Cc: dev 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 > -----Original Message----- > From: Andre Muezerie <andremue@linux.microsoft.com> > Sent: Monday, 5 May 2025 18:10 > To: Dariusz Sosnowski <dsosnowski@nvidia.com>; Slava Ovsiienko > <viacheslavo@nvidia.com>; Bing Zhao <bingz@nvidia.com>; Ori Kam > <orika@nvidia.com>; Suanming Mou <suanmingm@nvidia.com>; Matan > Azrad <matan@nvidia.com> > Cc: dev@dpdk.org; Andre Muezerie <andremue@linux.microsoft.com> > Subject: [PATCH] net/mlx5: declare size of rte_v128u32_t > > External 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 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. > > Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com> > --- > 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(-) > > diff --git a/drivers/net/mlx5/mlx5_defs.h b/drivers/net/mlx5/mlx5_defs.h > index 9c454983be..c5e2c59309 100644 > --- a/drivers/net/mlx5/mlx5_defs.h > +++ b/drivers/net/mlx5/mlx5_defs.h > @@ -196,4 +196,6 @@ > > #define MLX5_CNT_SVC_CYCLE_TIME_DEFAULT 500 > > +#define MLX5_SIZEOF_V128U32_T 16 > + > #endif /* RTE_PMD_MLX5_DEFS_H_ */ > diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c > index 9c075f6a56..b30d620f54 100644 > --- a/drivers/net/mlx5/mlx5_rxtx.c > +++ b/drivers/net/mlx5/mlx5_rxtx.c > @@ -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) + > diff --git a/drivers/net/mlx5/mlx5_tx.h b/drivers/net/mlx5/mlx5_tx.h index > 55568c41b1..5647f6a37d 100644 > --- a/drivers/net/mlx5/mlx5_tx.h > +++ b/drivers/net/mlx5/mlx5_tx.h > @@ -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 ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] net/mlx5: declare size of rte_v128u32_t 2025-05-25 8:47 ` Maayan Kashani @ 2025-05-31 0:20 ` Andre Muezerie 0 siblings, 0 replies; 4+ messages in thread From: Andre Muezerie @ 2025-05-31 0:20 UTC (permalink / raw) To: Maayan Kashani Cc: Dariusz Sosnowski, Slava Ovsiienko, Bing Zhao, Ori Kam, Suanming Mou, Matan Azrad, dev On Sun, May 25, 2025 at 08:47:31AM +0000, Maayan Kashani wrote: > 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 > Regards, > Maayan Kashani > > > -----Original Message----- > > From: Andre Muezerie <andremue@linux.microsoft.com> > > Sent: Monday, 5 May 2025 18:10 > > To: Dariusz Sosnowski <dsosnowski@nvidia.com>; Slava Ovsiienko > > <viacheslavo@nvidia.com>; Bing Zhao <bingz@nvidia.com>; Ori Kam > > <orika@nvidia.com>; Suanming Mou <suanmingm@nvidia.com>; Matan > > Azrad <matan@nvidia.com> > > Cc: dev@dpdk.org; Andre Muezerie <andremue@linux.microsoft.com> > > Subject: [PATCH] net/mlx5: declare size of rte_v128u32_t > > > > External 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 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. > > > > Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com> > > --- > > 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(-) > > > > diff --git a/drivers/net/mlx5/mlx5_defs.h b/drivers/net/mlx5/mlx5_defs.h > > index 9c454983be..c5e2c59309 100644 > > --- a/drivers/net/mlx5/mlx5_defs.h > > +++ b/drivers/net/mlx5/mlx5_defs.h > > @@ -196,4 +196,6 @@ > > > > #define MLX5_CNT_SVC_CYCLE_TIME_DEFAULT 500 > > > > +#define MLX5_SIZEOF_V128U32_T 16 > > + > > #endif /* RTE_PMD_MLX5_DEFS_H_ */ > > diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c > > index 9c075f6a56..b30d620f54 100644 > > --- a/drivers/net/mlx5/mlx5_rxtx.c > > +++ b/drivers/net/mlx5/mlx5_rxtx.c > > @@ -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) + > > diff --git a/drivers/net/mlx5/mlx5_tx.h b/drivers/net/mlx5/mlx5_tx.h index > > 55568c41b1..5647f6a37d 100644 > > --- a/drivers/net/mlx5/mlx5_tx.h > > +++ b/drivers/net/mlx5/mlx5_tx.h > > @@ -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 > ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2] net/mlx5: declare size of rte_v128u32_t 2025-05-05 15:10 [PATCH] net/mlx5: declare size of rte_v128u32_t Andre Muezerie 2025-05-25 8:47 ` Maayan Kashani @ 2025-05-31 0:21 ` Andre Muezerie 1 sibling, 0 replies; 4+ messages in thread From: Andre Muezerie @ 2025-05-31 0:21 UTC (permalink / raw) To: andremue Cc: bingz, dev, dsosnowski, matan, orika, suanmingm, viacheslavo, mkashani 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. A static assert is added to ensure the new macro never diverges from sizeof(rte_v128u32_t). Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com> --- 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(-) diff --git a/drivers/net/mlx5/mlx5_defs.h b/drivers/net/mlx5/mlx5_defs.h index 9c454983be..c5e2c59309 100644 --- a/drivers/net/mlx5/mlx5_defs.h +++ b/drivers/net/mlx5/mlx5_defs.h @@ -196,4 +196,6 @@ #define MLX5_CNT_SVC_CYCLE_TIME_DEFAULT 500 +#define MLX5_SIZEOF_V128U32_T 16 + #endif /* RTE_PMD_MLX5_DEFS_H_ */ diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c index 9c075f6a56..3f4942e225 100644 --- a/drivers/net/mlx5/mlx5_rxtx.c +++ b/drivers/net/mlx5/mlx5_rxtx.c @@ -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) + diff --git a/drivers/net/mlx5/mlx5_tx.h b/drivers/net/mlx5/mlx5_tx.h index 55568c41b1..5647f6a37d 100644 --- a/drivers/net/mlx5/mlx5_tx.h +++ b/drivers/net/mlx5/mlx5_tx.h @@ -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.3 ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-05-31 0:22 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2025-05-05 15:10 [PATCH] net/mlx5: declare size of rte_v128u32_t Andre Muezerie 2025-05-25 8:47 ` Maayan Kashani 2025-05-31 0:20 ` Andre Muezerie 2025-05-31 0:21 ` [PATCH v2] " Andre Muezerie
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).