DPDK  18.11.10
rte_efd_lsx.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2021 Loongson, Inc
3  */
4 
5 /*
6  * rte_efd_loongarch.h
7  * This file holds all loongarch specific EFD functions
8  */
9 
10 #ifndef __RTE_EFD_LSX_H__
11 #define __RTE_EFD_LSX_H__
12 
13 #include <rte_vect.h>
14 
15 static inline efd_value_t
16 efd_lookup_internal_lsx(const efd_hashfunc_t *group_hash_idx,
17  const efd_lookuptbl_t *group_lookup_table,
18  const uint32_t hash_val_a, const uint32_t hash_val_b)
19 {
20  efd_value_t value = 0;
21  uint32_t i = 0;
22  __m128i xtmp = __lsx_vldi(0);
23  __m128i vhash_val_a = __lsx_vreplgr2vr_w(hash_val_a);
24  __m128i vhash_val_b = __lsx_vreplgr2vr_w(hash_val_b);
25  uint64_t t_val;
26 
27  for (; i < RTE_EFD_VALUE_NUM_BITS; i += 4) {
28  t_val = *(uint64_t const *)&group_hash_idx[i];
29  xtmp = __lsx_vinsgr2vr_d(xtmp, t_val, 0);
30  __m128i vhash_idx = __lsx_vsllwil_wu_hu(xtmp, 0);
31  t_val = *(uint64_t const *)&group_lookup_table[i];
32  xtmp = __lsx_vinsgr2vr_d(xtmp, t_val, 0);
33  __m128i vlookup_table = __lsx_vsllwil_wu_hu(xtmp, 0);
34  __m128i vhash = __lsx_vadd_w(vhash_val_a,
35  __lsx_vmul_w(vhash_idx, vhash_val_b));
36  __m128i vbucket_idx = __lsx_vsrli_w(vhash, EFD_LOOKUPTBL_SHIFT);
37  __m128i vresult = __lsx_vsrl_w(vlookup_table, vbucket_idx);
38  xtmp = __lsx_vmskltz_w(__lsx_vslli_w(vresult, 31));
39  value |= (__lsx_vpickve2gr_d(xtmp, 0) &
40  ((1 << (RTE_EFD_VALUE_NUM_BITS - i)) - 1)) << i;
41  }
42 
43  return value;
44 }
45 
46 #endif /* __RTE_EFD_LSX_H__ */
#define RTE_EFD_VALUE_NUM_BITS
Definition: rte_efd.h:65