DPDK  20.11.0
rte_cmp_loongarch.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2015 Intel Corporation
3  */
4 
5 #include <rte_vect.h>
6 
7 /* Functions to compare multiple of 16 byte keys (up to 128 bytes) */
8 static int
9 rte_hash_k16_cmp_eq(const void *key1, const void *key2, size_t key_len __rte_unused)
10 {
11 #ifdef RTE_ARCH_NO_VECTOR
12  xmm_t tmp, tmp1;
13  int i;
14  int cnt = 0;
15  const xmm_t k1 = *(const xmm_t *) key1;
16  const xmm_t k2 = *(const xmm_t *) key2;
17  for (i = 0; i < 16; i++)
18  tmp.u8[i] = k1.u8[i] ^ k2.u8[i];
19  const xmm_t x = tmp;
20 
21  tmp1.i64[0] = (x.i64[0] == 0) ? 0xffffffffffffffffLL : 0;
22  tmp1.i64[1] = (x.i64[1] == 0) ? 0xffffffffffffffffLL : 0;
23 
24  cnt += (tmp1.i64[0] != 0) ? 64 : 0;
25  cnt += (tmp1.i64[1] != 0) ? 64 : 0;
26  cnt = ((cnt == 128) ? 0 : 1);
27 #else
28  //TODO add vec support
29 #endif
30  return cnt;
31 }
32 
33 static int
34 rte_hash_k32_cmp_eq(const void *key1, const void *key2, size_t key_len)
35 {
36  return rte_hash_k16_cmp_eq(key1, key2, key_len) ||
37  rte_hash_k16_cmp_eq((const char *) key1 + 16,
38  (const char *) key2 + 16, key_len);
39 }
40 
41 static int
42 rte_hash_k48_cmp_eq(const void *key1, const void *key2, size_t key_len)
43 {
44  return rte_hash_k16_cmp_eq(key1, key2, key_len) ||
45  rte_hash_k16_cmp_eq((const char *) key1 + 16,
46  (const char *) key2 + 16, key_len) ||
47  rte_hash_k16_cmp_eq((const char *) key1 + 32,
48  (const char *) key2 + 32, key_len);
49 }
50 
51 static int
52 rte_hash_k64_cmp_eq(const void *key1, const void *key2, size_t key_len)
53 {
54  return rte_hash_k32_cmp_eq(key1, key2, key_len) ||
55  rte_hash_k32_cmp_eq((const char *) key1 + 32,
56  (const char *) key2 + 32, key_len);
57 }
58 
59 static int
60 rte_hash_k80_cmp_eq(const void *key1, const void *key2, size_t key_len)
61 {
62  return rte_hash_k64_cmp_eq(key1, key2, key_len) ||
63  rte_hash_k16_cmp_eq((const char *) key1 + 64,
64  (const char *) key2 + 64, key_len);
65 }
66 
67 static int
68 rte_hash_k96_cmp_eq(const void *key1, const void *key2, size_t key_len)
69 {
70  return rte_hash_k64_cmp_eq(key1, key2, key_len) ||
71  rte_hash_k32_cmp_eq((const char *) key1 + 64,
72  (const char *) key2 + 64, key_len);
73 }
74 
75 static int
76 rte_hash_k112_cmp_eq(const void *key1, const void *key2, size_t key_len)
77 {
78  return rte_hash_k64_cmp_eq(key1, key2, key_len) ||
79  rte_hash_k32_cmp_eq((const char *) key1 + 64,
80  (const char *) key2 + 64, key_len) ||
81  rte_hash_k16_cmp_eq((const char *) key1 + 96,
82  (const char *) key2 + 96, key_len);
83 }
84 
85 static int
86 rte_hash_k128_cmp_eq(const void *key1, const void *key2, size_t key_len)
87 {
88  return rte_hash_k64_cmp_eq(key1, key2, key_len) ||
89  rte_hash_k64_cmp_eq((const char *) key1 + 64,
90  (const char *) key2 + 64, key_len);
91 }
#define __rte_unused
Definition: rte_common.h:116