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:
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 #ifndef __included_lb_hash_hash_h__
17 #define __included_lb_hash_hash_h__
19 #include <vppinfra/crc32.h>
20 #include <vppinfra/xxhash.h>
22 #if defined(clib_crc32c_uses_intrinsics) && !defined (__i386__)
23 static_always_inline u32
24 lb_hash_hash (u64 k0, u64 k1, u64 k2, u64 k3, u64 k4)
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);
35 /* Note: k0 is u64 and k1 is u32 */
36 static_always_inline u32
37 lb_hash_hash_2_tuples (u64 k0, u32 k1)
40 val = crc32_u64 (val, k0);
41 val = crc32_u32 (val, k1);
45 static_always_inline u32
46 lb_hash_hash (u64 k0, u64 k1, u64 k2, u64 k3, u64 k4)
48 u64 tmp = k0 ^ k1 ^ k2 ^ k3 ^ k4;
49 return (u32) clib_xxhash (tmp);
52 /* Note: k0 is u64 and k1 is u32 */
53 static_always_inline u32
54 lb_hash_hash_2_tuples (u64 k0, u32 k1)
57 return (u32) clib_xxhash (tmp);
61 #endif /* __included_lb_hash_hash_h__ */
64 * fd.io coding-style-patch-verification: ON
67 * eval: (c-set-style "gnu")