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:
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 SRC_VPPINFRA_FLOWHASH_24_16_H_
17 #define SRC_VPPINFRA_FLOWHASH_24_16_H_
19 #ifdef __included_flowhash_template_h__
20 #undef __included_flowhash_template_h__
23 #include <vppinfra/clib.h>
24 #include <vppinfra/xxhash.h>
25 #include <vppinfra/crc32.h>
29 } flowhash_skey_24_16_t;
33 } flowhash_lkey_24_16_t;
37 } flowhash_value_24_16_t;
39 #define FLOWHASH_TYPE _24_16
40 #include <vppinfra/flowhash_template.h>
44 u32 flowhash_hash_24_16(flowhash_lkey_24_16_t *k)
46 #ifdef clib_crc32c_uses_intrinsics
47 return clib_crc32c ((u8 *) &k->as_u64[0], 24);
53 return (u32)clib_xxhash (val);
58 u8 flowhash_cmp_key_24_16(flowhash_skey_24_16_t *a,
59 flowhash_lkey_24_16_t *b)
62 val |= (a->as_u64[0] != b->as_u64[0]);
63 val |= (a->as_u64[1] != b->as_u64[1]);
64 val |= (a->as_u64[2] != b->as_u64[2]);
69 void flowhash_cpy_key_24_16(flowhash_skey_24_16_t *dst,
70 flowhash_lkey_24_16_t *src)
72 dst->as_u64[0] = src->as_u64[0];
73 dst->as_u64[1] = src->as_u64[1];
74 dst->as_u64[2] = src->as_u64[2];
77 #endif /* SRC_VPPINFRA_FLOWHASH_24_16_H_ */