vppinfra: fix u32x4_byte_swap on Arm 50/26950/1
authorLijian.Zhang <Lijian.Zhang@arm.com>
Mon, 27 Apr 2020 02:46:06 +0000 (10:46 +0800)
committerLijian.Zhang <Lijian.Zhang@arm.com>
Fri, 8 May 2020 05:36:32 +0000 (13:36 +0800)
Fix the endianness conversion function u32x4_byte_swap() on Arm. Here's
an example of using this function with and without the fix.

This issue is seen using Mellanox NIC RDMA driver on Arm servers.
The packet length cannot be parsed correctly.

Testing code:
u32x4 s = {0x12345678, 0x23456789, 0x3456789a, 0x456789ab};
u32x4 ss = u32x4_byte_swap (s);

Without the code change:
(gdb) p /x s
$1 = {0x12345678, 0x23456789, 0x3456789a, 0x456789ab}
(gdb) p /x ss
$2 = {0x23456789, 0x12345678, 0x456789ab, 0x3456789a}

With the code change:
(gdb) p /x s
$3 = {0x12345678, 0x23456789, 0x3456789a, 0x456789ab}
(gdb) p /x ss
$4 = {0x78563412, 0x89674523, 0x9a785634, 0xab896745}

Type: fix

Change-Id: Ie5f263e94331783940e7c00397092a64e4fc4279
Signed-off-by: Lijian Zhang <Lijian.Zhang@arm.com>
Reviewed-by: Jieqiang Wang <Jieqiang.Wang@arm.com>
Reviewed-by: Govindarajan Mohandoss <Govindarajan.Mohandoss@arm.com>
src/vppinfra/vector_neon.h

index d80c691..15af098 100644 (file)
@@ -106,7 +106,7 @@ u16x8_byte_swap (u16x8 v)
 static_always_inline u32x4
 u32x4_byte_swap (u32x4 v)
 {
-  return vrev64q_u32 (v);
+  return (u32x4) vrev32q_u8 ((u8x16) v);
 }
 
 static_always_inline u8x16