DPDK  18.11.10
rte_cmp_mips.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 #endif
28  return cnt;
29 }
30 
31 static int
32 rte_hash_k32_cmp_eq(const void *key1, const void *key2, size_t key_len)
33 {
34  return rte_hash_k16_cmp_eq(key1, key2, key_len) ||
35  rte_hash_k16_cmp_eq((const char *) key1 + 16,
36  (const char *) key2 + 16, key_len);
37 }
38 
39 static int
40 rte_hash_k48_cmp_eq(const void *key1, const void *key2, size_t key_len)
41 {
42  return rte_hash_k16_cmp_eq(key1, key2, key_len) ||
43  rte_hash_k16_cmp_eq((const char *) key1 + 16,
44  (const char *) key2 + 16, key_len) ||
45  rte_hash_k16_cmp_eq((const char *) key1 + 32,
46  (const char *) key2 + 32, key_len);
47 }
48 
49 static int
50 rte_hash_k64_cmp_eq(const void *key1, const void *key2, size_t key_len)
51 {
52  return rte_hash_k32_cmp_eq(key1, key2, key_len) ||
53  rte_hash_k32_cmp_eq((const char *) key1 + 32,
54  (const char *) key2 + 32, key_len);
55 }
56 
57 static int
58 rte_hash_k80_cmp_eq(const void *key1, const void *key2, size_t key_len)
59 {
60  return rte_hash_k64_cmp_eq(key1, key2, key_len) ||
61  rte_hash_k16_cmp_eq((const char *) key1 + 64,
62  (const char *) key2 + 64, key_len);
63 }
64 
65 static int
66 rte_hash_k96_cmp_eq(const void *key1, const void *key2, size_t key_len)
67 {
68  return rte_hash_k64_cmp_eq(key1, key2, key_len) ||
69  rte_hash_k32_cmp_eq((const char *) key1 + 64,
70  (const char *) key2 + 64, key_len);
71 }
72 
73 static int
74 rte_hash_k112_cmp_eq(const void *key1, const void *key2, size_t key_len)
75 {
76  return rte_hash_k64_cmp_eq(key1, key2, key_len) ||
77  rte_hash_k32_cmp_eq((const char *) key1 + 64,
78  (const char *) key2 + 64, key_len) ||
79  rte_hash_k16_cmp_eq((const char *) key1 + 96,
80  (const char *) key2 + 96, key_len);
81 }
82 
83 static int
84 rte_hash_k128_cmp_eq(const void *key1, const void *key2, size_t key_len)
85 {
86  return rte_hash_k64_cmp_eq(key1, key2, key_len) ||
87  rte_hash_k64_cmp_eq((const char *) key1 + 64,
88  (const char *) key2 + 64, key_len);
89 }
#define __rte_unused
Definition: rte_common.h:81