diff mbox series

[ovs-dev] odp-execute: Fix AVX checksum calculation.

Message ID 20240507152450.3781323-1-emma.finn@intel.com
State Superseded
Headers show
Series [ovs-dev] odp-execute: Fix AVX checksum calculation. | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test success github build: passed
ovsrobot/intel-ovs-compilation success test: success

Commit Message

Finn, Emma May 7, 2024, 3:24 p.m. UTC
The AVX implementation for calcualting checksum was not
handling carry-over addition correctly in some cases.
This patch adds an additional shuffle to add 16-bit padding
to the final part of the calculation to handle such cases.

Fixes: 92eb03f7b03a ("odp-execute: Add ISA implementation of set_masked IPv4 action")
Signed-off-by: Emma Finn <emma.finn@intel.com>
Reported-by: Eelco Chaudron <echaudro@redhat.com>
---
 lib/odp-execute-avx512.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Eelco Chaudron May 10, 2024, 11:48 a.m. UTC | #1
On 7 May 2024, at 17:24, Emma Finn wrote:

> The AVX implementation for calcualting checksum was not
> handling carry-over addition correctly in some cases.
> This patch adds an additional shuffle to add 16-bit padding
> to the final part of the calculation to handle such cases.
>
> Fixes: 92eb03f7b03a ("odp-execute: Add ISA implementation of set_masked IPv4 action")
> Signed-off-by: Emma Finn <emma.finn@intel.com>
> Reported-by: Eelco Chaudron <echaudro@redhat.com>

Hi Emma,

Thanks for fixing this, however, it looks like the same issue also exists in IPv6.

In addition, can you also add a test case for both IPv4 and IPv6?

Thanks,

Eelco

> ---
>  lib/odp-execute-avx512.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/lib/odp-execute-avx512.c b/lib/odp-execute-avx512.c
> index 50c48bfd4..911fdd3ea 100644
> --- a/lib/odp-execute-avx512.c
> +++ b/lib/odp-execute-avx512.c
> @@ -366,6 +366,8 @@ avx512_get_delta(__m256i old_header, __m256i new_header)
>                                            0xF, 0xF, 0xF, 0xF);
>      v_delta = _mm256_permutexvar_epi32(v_swap32a, v_delta);
>
> +    v_delta = _mm256_hadd_epi32(v_delta, v_zeros);
> +    v_delta = _mm256_shuffle_epi8(v_delta, v_swap16a);
>      v_delta = _mm256_hadd_epi32(v_delta, v_zeros);
>      v_delta = _mm256_hadd_epi16(v_delta, v_zeros);
>
> -- 
> 2.25.1
diff mbox series

Patch

diff --git a/lib/odp-execute-avx512.c b/lib/odp-execute-avx512.c
index 50c48bfd4..911fdd3ea 100644
--- a/lib/odp-execute-avx512.c
+++ b/lib/odp-execute-avx512.c
@@ -366,6 +366,8 @@  avx512_get_delta(__m256i old_header, __m256i new_header)
                                           0xF, 0xF, 0xF, 0xF);
     v_delta = _mm256_permutexvar_epi32(v_swap32a, v_delta);
 
+    v_delta = _mm256_hadd_epi32(v_delta, v_zeros);
+    v_delta = _mm256_shuffle_epi8(v_delta, v_swap16a);
     v_delta = _mm256_hadd_epi32(v_delta, v_zeros);
     v_delta = _mm256_hadd_epi16(v_delta, v_zeros);