DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] drivers/net: use intrinsic to access content of __m128i
@ 2024-12-27 19:44 Andre Muezerie
  2024-12-28  1:23 ` [PATCH v2] " Andre Muezerie
  0 siblings, 1 reply; 2+ messages in thread
From: Andre Muezerie @ 2024-12-27 19:44 UTC (permalink / raw)
  To: Bruce Richardson, Konstantin Ananyev, Vamsi Attunuru; +Cc: dev, Andre Muezerie

Compiler intrinsics should be used to access/manipulate contents
of __m128i.
Existing code results in the error below when compiled with MSVC:

../drivers/net/octeon_ep/cnxk_ep_rx_sse.c(61): error C2440:
    'type cast': cannot convert from '__m128i' to 'rte_xmm_t'

The fix is to use an intrinsic instead. This compiles fine with
gcc, clang and msvc.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
 drivers/net/octeon_ep/cnxk_ep_rx_sse.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/octeon_ep/cnxk_ep_rx_sse.c b/drivers/net/octeon_ep/cnxk_ep_rx_sse.c
index fbd1f73c1e..bbc4490f49 100644
--- a/drivers/net/octeon_ep/cnxk_ep_rx_sse.c
+++ b/drivers/net/octeon_ep/cnxk_ep_rx_sse.c
@@ -58,10 +58,10 @@ cnxk_ep_process_pkts_vec_sse(struct rte_mbuf **rx_pkts, struct otx_ep_droq *droq
 		s23 = _mm_shuffle_epi8(s23, cpy_mask);
 
 		/* Store packet length and data length to mbuf. */
-		*(uint64_t *)&m0->pkt_len = ((rte_xmm_t)s01).u64[0];
-		*(uint64_t *)&m1->pkt_len = ((rte_xmm_t)s01).u64[1];
-		*(uint64_t *)&m2->pkt_len = ((rte_xmm_t)s23).u64[0];
-		*(uint64_t *)&m3->pkt_len = ((rte_xmm_t)s23).u64[1];
+		*(uint64_t *)&m0->pkt_len = _mm_extract_epi64(s01, 0);
+		*(uint64_t *)&m1->pkt_len = _mm_extract_epi64(s01, 1);
+		*(uint64_t *)&m2->pkt_len = _mm_extract_epi64(s23, 0);
+		*(uint64_t *)&m3->pkt_len = _mm_extract_epi64(s23, 1);
 
 		/* Reset rearm data. */
 		*(uint64_t *)&m0->rearm_data = droq->rearm_data;
-- 
2.47.0.vfs.0.3


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH v2] drivers/net: use intrinsic to access content of __m128i
  2024-12-27 19:44 [PATCH] drivers/net: use intrinsic to access content of __m128i Andre Muezerie
@ 2024-12-28  1:23 ` Andre Muezerie
  0 siblings, 0 replies; 2+ messages in thread
From: Andre Muezerie @ 2024-12-28  1:23 UTC (permalink / raw)
  To: andremue; +Cc: bruce.richardson, dev, konstantin.v.ananyev, vattunuru

Compiler intrinsics should be used to access/manipulate contents
of __m128i.
Existing code results in the error below when compiled with MSVC:

../drivers/net/octeon_ep/cnxk_ep_rx_sse.c(61): error C2440:
    'type cast': cannot convert from '__m128i' to 'rte_xmm_t'

The fix is to use an intrinsic instead. This compiles fine with
gcc, clang and msvc.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
 drivers/net/octeon_ep/cnxk_ep_rx_sse.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/net/octeon_ep/cnxk_ep_rx_sse.c b/drivers/net/octeon_ep/cnxk_ep_rx_sse.c
index fbd1f73c1e..d17ec46211 100644
--- a/drivers/net/octeon_ep/cnxk_ep_rx_sse.c
+++ b/drivers/net/octeon_ep/cnxk_ep_rx_sse.c
@@ -58,10 +58,21 @@ cnxk_ep_process_pkts_vec_sse(struct rte_mbuf **rx_pkts, struct otx_ep_droq *droq
 		s23 = _mm_shuffle_epi8(s23, cpy_mask);
 
 		/* Store packet length and data length to mbuf. */
+#ifdef RTE_ARCH_64
+		*(uint64_t *)&m0->pkt_len = _mm_extract_epi64(s01, 0);
+		*(uint64_t *)&m1->pkt_len = _mm_extract_epi64(s01, 1);
+		*(uint64_t *)&m2->pkt_len = _mm_extract_epi64(s23, 0);
+		*(uint64_t *)&m3->pkt_len = _mm_extract_epi64(s23, 1);
+#else
+		/* _mm_extract_epi64 is only available on 64-bit architecture.
+		 * The cast below is non-portable and results in compile error
+		 * using MSVC.
+		 */
 		*(uint64_t *)&m0->pkt_len = ((rte_xmm_t)s01).u64[0];
 		*(uint64_t *)&m1->pkt_len = ((rte_xmm_t)s01).u64[1];
 		*(uint64_t *)&m2->pkt_len = ((rte_xmm_t)s23).u64[0];
 		*(uint64_t *)&m3->pkt_len = ((rte_xmm_t)s23).u64[1];
+#endif
 
 		/* Reset rearm data. */
 		*(uint64_t *)&m0->rearm_data = droq->rearm_data;
-- 
2.47.0.vfs.0.3


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-12-28  1:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-12-27 19:44 [PATCH] drivers/net: use intrinsic to access content of __m128i Andre Muezerie
2024-12-28  1:23 ` [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).