FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
lb_hash_hash.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef __included_lb_hash_hash_h__
17 #define __included_lb_hash_hash_h__
18 
19 #include <vppinfra/crc32.h>
20 #include <vppinfra/xxhash.h>
21 
22 #if defined(clib_crc32c_uses_intrinsics) && !defined (__i386__)
24 lb_hash_hash (u64 k0, u64 k1, u64 k2, u64 k3, u64 k4)
25 {
26  u64 val = 0;
27  val = crc32_u64 (val, k0);
28  val = crc32_u64 (val, k1);
29  val = crc32_u64 (val, k2);
30  val = crc32_u64 (val, k3);
31  val = crc32_u64 (val, k4);
32  return (u32) val;
33 }
34 
35 /* Note: k0 is u64 and k1 is u32 */
38 {
39  u64 val = 0;
40  val = crc32_u64 (val, k0);
41  val = crc32_u32 (val, k1);
42  return (u32) val;
43 }
44 #else
46 lb_hash_hash (u64 k0, u64 k1, u64 k2, u64 k3, u64 k4)
47 {
48  u64 tmp = k0 ^ k1 ^ k2 ^ k3 ^ k4;
49  return (u32) clib_xxhash (tmp);
50 }
51 
52 /* Note: k0 is u64 and k1 is u32 */
55 {
56  u64 tmp = k0 ^ k1;
57  return (u32) clib_xxhash (tmp);
58 }
59 #endif
60 
61 #endif /* __included_lb_hash_hash_h__ */
62 
63 /*
64  * fd.io coding-style-patch-verification: ON
65  *
66  * Local Variables:
67  * eval: (c-set-style "gnu")
68  * End:
69  */
tmp
u32 * tmp
Definition: interface_output.c:1078
static_always_inline
#define static_always_inline
Definition: clib.h:112
lb_hash_hash
static_always_inline u32 lb_hash_hash(u64 k0, u64 k1, u64 k2, u64 k3, u64 k4)
Definition: lb_hash_hash.h:46
crc32.h
clib_xxhash
static u64 clib_xxhash(u64 key)
Definition: xxhash.h:58
xxhash.h
u64
unsigned long u64
Definition: types.h:89
u32
unsigned int u32
Definition: types.h:88
lb_hash_hash_2_tuples
static_always_inline u32 lb_hash_hash_2_tuples(u64 k0, u32 k1)
Definition: lb_hash_hash.h:54