build: use static deps for pkg-config libs.private
[dpdk.git] / lib / librte_efd / rte_efd_x86.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2016-2017 Intel Corporation
3  */
4
5 /* rte_efd_x86.h
6  * This file holds all x86 specific EFD functions
7  */
8 #include <immintrin.h>
9
10 #if (RTE_EFD_VALUE_NUM_BITS == 8 || RTE_EFD_VALUE_NUM_BITS == 16 || \
11         RTE_EFD_VALUE_NUM_BITS == 24 || RTE_EFD_VALUE_NUM_BITS == 32)
12 #define EFD_LOAD_SI128(val) _mm_load_si128(val)
13 #else
14 #define EFD_LOAD_SI128(val) _mm_lddqu_si128(val)
15 #endif
16
17 static inline efd_value_t
18 efd_lookup_internal_avx2(const efd_hashfunc_t *group_hash_idx,
19                 const efd_lookuptbl_t *group_lookup_table,
20                 const uint32_t hash_val_a, const uint32_t hash_val_b)
21 {
22 #ifdef RTE_MACHINE_CPUFLAG_AVX2
23         efd_value_t value = 0;
24         uint32_t i = 0;
25         __m256i vhash_val_a = _mm256_set1_epi32(hash_val_a);
26         __m256i vhash_val_b = _mm256_set1_epi32(hash_val_b);
27
28         for (; i < RTE_EFD_VALUE_NUM_BITS; i += 8) {
29                 __m256i vhash_idx =
30                                 _mm256_cvtepu16_epi32(EFD_LOAD_SI128(
31                                 (__m128i const *) &group_hash_idx[i]));
32                 __m256i vlookup_table = _mm256_cvtepu16_epi32(
33                                 EFD_LOAD_SI128((__m128i const *)
34                                 &group_lookup_table[i]));
35                 __m256i vhash = _mm256_add_epi32(vhash_val_a,
36                                 _mm256_mullo_epi32(vhash_idx, vhash_val_b));
37                 __m256i vbucket_idx = _mm256_srli_epi32(vhash,
38                                 EFD_LOOKUPTBL_SHIFT);
39                 __m256i vresult = _mm256_srlv_epi32(vlookup_table,
40                                 vbucket_idx);
41
42                 value |= (_mm256_movemask_ps(
43                         (__m256) _mm256_slli_epi32(vresult, 31))
44                         & ((1 << (RTE_EFD_VALUE_NUM_BITS - i)) - 1)) << i;
45         }
46
47         return value;
48 #else
49         RTE_SET_USED(group_hash_idx);
50         RTE_SET_USED(group_lookup_table);
51         RTE_SET_USED(hash_val_a);
52         RTE_SET_USED(hash_val_b);
53         /* Return dummy value, only to avoid compilation breakage */
54         return 0;
55 #endif
56
57 }