NAT44: fix snat_get_worker_out2in_cb (VPP-1536)
[vpp.git] / src / vppinfra / flowhash_8_8.h
1 /*
2  * Copyright (c) 2012 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 SRC_VPPINFRA_FLOWHASH_8_8_H_
17 #define SRC_VPPINFRA_FLOWHASH_8_8_H_
18
19 #ifdef __included_flowhash_template_h__
20 #undef __included_flowhash_template_h__
21 #endif
22
23 #include <vppinfra/clib.h>
24 #include <vppinfra/xxhash.h>
25 #include <vppinfra/crc32.h>
26
27 typedef struct {
28   u64 as_u64[1];
29 } flowhash_skey_8_8_t;
30
31 typedef struct {
32   u64 as_u64[1];
33 } flowhash_lkey_8_8_t;
34
35 typedef struct {
36   u64 as_u64[1];
37 } flowhash_value_8_8_t;
38
39 #define FLOWHASH_TYPE _8_8
40 #include <vppinfra/flowhash_template.h>
41 #undef FLOWHASH_TYPE
42
43 static_always_inline
44 u32 flowhash_hash_8_8(flowhash_lkey_8_8_t *k)
45 {
46 #ifdef clib_crc32c_uses_intrinsics
47   return clib_crc32c ((u8 *) &k->as_u64[0], 8);
48 #else
49   return clib_xxhash (k->as_u64[0]);
50 #endif
51 }
52
53 static_always_inline
54 u8 flowhash_cmp_key_8_8(flowhash_skey_8_8_t *a,
55                           flowhash_lkey_8_8_t *b)
56 {
57   return a->as_u64[0] != b->as_u64[0];
58 }
59
60 static_always_inline
61 void flowhash_cpy_key_8_8(flowhash_skey_8_8_t *dst,
62                                     flowhash_lkey_8_8_t *src)
63 {
64   dst->as_u64[0] = src->as_u64[0];
65 }
66
67 #endif /* SRC_VPPINFRA_FLOWHASH_8_8_H_ */