summaryrefslogtreecommitdiffstats
path: root/src/vppinfra/vector_avx2.h
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2018-06-18 22:21:40 +0200
committerDamjan Marion <dmarion@me.com>2018-06-28 10:00:05 +0000
commit08bca80c998bdae87060306350124714606a1604 (patch)
treeb207c71fc42030e9beb26addf5e4e4056a39e73d /src/vppinfra/vector_avx2.h
parent0d427d8d8a48af404dfc6535ae72d334b790f809 (diff)
ip: vectorized ip checksum
Change-Id: Ida678e6f31daa8decb18189da712a350336326e2 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vppinfra/vector_avx2.h')
-rw-r--r--src/vppinfra/vector_avx2.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/vppinfra/vector_avx2.h b/src/vppinfra/vector_avx2.h
index 6b298be8bfd..66c46f226aa 100644
--- a/src/vppinfra/vector_avx2.h
+++ b/src/vppinfra/vector_avx2.h
@@ -137,6 +137,34 @@ u32x8_hadd (u32x8 v1, u32x8 v2)
return (u32x8) _mm256_hadd_epi32 ((__m256i) v1, (__m256i) v2);
}
+static_always_inline u16x16
+u16x16_mask_last (u16x16 v, u8 n_last)
+{
+ const u16x16 masks[17] = {
+ {0},
+ {-1},
+ {-1, -1},
+ {-1, -1, -1},
+ {-1, -1, -1, -1},
+ {-1, -1, -1, -1, -1},
+ {-1, -1, -1, -1, -1, -1},
+ {-1, -1, -1, -1, -1, -1, -1},
+ {-1, -1, -1, -1, -1, -1, -1, -1},
+ {-1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ };
+
+ ASSERT (n_last < 17);
+
+ return v & masks[16 - n_last];
+}
+
#endif /* included_vector_avx2_h */
/*