DPDK 26.07.0-rc1
rte_cmp_generic.h
1/* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2026 Stephen Hemminger
3 */
4
5#ifndef _RTE_CMP_GENERIC_H_
6#define _RTE_CMP_GENERIC_H_
7
8/* Function to compare 16 byte keys */
9static inline int
10rte_hash_k16_cmp_eq(const void *key1, const void *key2, size_t key_len __rte_unused)
11{
12#ifdef RTE_ARCH_64
13 const unaligned_uint64_t *k1 = key1;
14 const unaligned_uint64_t *k2 = key2;
15
16 return !!((k1[0] ^ k2[0]) | (k1[1] ^ k2[1]));
17#else
18 const unaligned_uint32_t *k1 = key1;
19 const unaligned_uint32_t *k2 = key2;
20
21 return !!((k1[0] ^ k2[0]) | (k1[1] ^ k2[1]) |
22 (k1[2] ^ k2[2]) | (k1[3] ^ k2[3]));
23#endif
24}
25
26/* Function to compare 32 byte keys */
27static inline int
28rte_hash_k32_cmp_eq(const void *key1, const void *key2, size_t key_len)
29{
30 return rte_hash_k16_cmp_eq(key1, key2, key_len) |
31 rte_hash_k16_cmp_eq((const uint8_t *) key1 + 16,
32 (const uint8_t *) key2 + 16, key_len);
33}
34
35#endif /* _RTE_CMP_GENERIC_H_ */
#define __rte_unused
Definition: rte_common.h:248