a2536ffb9a63d5e6a581bbeba4f47ac836292ac2
[samplevnf.git] / VNFs / DPPD-PROX / hash_utils.h
1 /*
2 // Copyright (c) 2010-2017 Intel Corporation
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 */
16
17 #ifndef _HASH_UTILS_H_
18 #define _HASH_UTILS_H_
19
20 #include <rte_common.h>
21 #include <rte_version.h>
22
23 struct rte_table_hash;
24
25 /* Take DPDK 2.2.0 ABI change into account: offset 0 now means first byte of mbuf struct
26  * see http://www.dpdk.org/browse/dpdk/commit/?id=ba92d511ddacf863fafaaa14c0577f30ee57d092
27  */
28 #if RTE_VERSION >= RTE_VERSION_NUM(2,2,0,0)
29 #define HASH_METADATA_OFFSET(offset)    (sizeof(struct rte_mbuf) + (offset))
30 #else
31 #define HASH_METADATA_OFFSET(offset)    (offset)
32 #endif
33
34 /* Wrap crc32 hash function to match that required for rte_table */
35 uint64_t hash_crc32(void* key, uint32_t key_size, uint64_t seed);
36
37 void print_hash_table_size(const struct rte_table_hash *h);
38 void print_hash_table(const struct rte_table_hash *h);
39
40 uint64_t get_bucket_key8(void* table, uint32_t bucket_idx, void** key, void** entries);
41 uint64_t get_bucket(void* table, uint32_t bucket_idx, void** key, void** entries);
42 #endif /* _HASH_UTILS_H_ */