DPDK  18.08.1
rte_hash.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2015 Intel Corporation
3  */
4 
5 #ifndef _RTE_HASH_H_
6 #define _RTE_HASH_H_
7 
14 #include <stdint.h>
15 #include <stddef.h>
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
22 #define RTE_HASH_ENTRIES_MAX (1 << 30)
23 
25 #define RTE_HASH_NAMESIZE 32
26 
28 #define RTE_HASH_LOOKUP_BULK_MAX 64
29 #define RTE_HASH_LOOKUP_MULTI_MAX RTE_HASH_LOOKUP_BULK_MAX
30 
32 #define RTE_HASH_EXTRA_FLAGS_TRANS_MEM_SUPPORT 0x01
33 
35 #define RTE_HASH_EXTRA_FLAGS_MULTI_WRITER_ADD 0x02
36 
38 #define RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY 0x04
39 
41 typedef uint32_t hash_sig_t;
42 
44 typedef uint32_t (*rte_hash_function)(const void *key, uint32_t key_len,
45  uint32_t init_val);
46 
48 typedef int (*rte_hash_cmp_eq_t)(const void *key1, const void *key2, size_t key_len);
49 
54  const char *name;
55  uint32_t entries;
56  uint32_t reserved;
57  uint32_t key_len;
59  uint32_t hash_func_init_val;
60  int socket_id;
61  uint8_t extra_flag;
62 };
63 
65 struct rte_hash;
66 
84 struct rte_hash *
85 rte_hash_create(const struct rte_hash_parameters *params);
86 
99 
110 struct rte_hash *
111 rte_hash_find_existing(const char *name);
112 
118 void
119 rte_hash_free(struct rte_hash *h);
120 
126 void
127 rte_hash_reset(struct rte_hash *h);
128 
137 int32_t
138 rte_hash_count(const struct rte_hash *h);
139 
158 int
159 rte_hash_add_key_data(const struct rte_hash *h, const void *key, void *data);
160 
182 int32_t
183 rte_hash_add_key_with_hash_data(const struct rte_hash *h, const void *key,
184  hash_sig_t sig, void *data);
185 
202 int32_t
203 rte_hash_add_key(const struct rte_hash *h, const void *key);
204 
224 int32_t
225 rte_hash_add_key_with_hash(const struct rte_hash *h, const void *key, hash_sig_t sig);
226 
245 int32_t
246 rte_hash_del_key(const struct rte_hash *h, const void *key);
247 
268 int32_t
269 rte_hash_del_key_with_hash(const struct rte_hash *h, const void *key, hash_sig_t sig);
270 
288 int
289 rte_hash_get_key_with_position(const struct rte_hash *h, const int32_t position,
290  void **key);
291 
311 int
312 rte_hash_lookup_data(const struct rte_hash *h, const void *key, void **data);
313 
336 int
337 rte_hash_lookup_with_hash_data(const struct rte_hash *h, const void *key,
338  hash_sig_t sig, void **data);
339 
357 int32_t
358 rte_hash_lookup(const struct rte_hash *h, const void *key);
359 
379 int32_t
380 rte_hash_lookup_with_hash(const struct rte_hash *h,
381  const void *key, hash_sig_t sig);
382 
394 hash_sig_t
395 rte_hash_hash(const struct rte_hash *h, const void *key);
396 
416 int
417 rte_hash_lookup_bulk_data(const struct rte_hash *h, const void **keys,
418  uint32_t num_keys, uint64_t *hit_mask, void *data[]);
419 
441 int
442 rte_hash_lookup_bulk(const struct rte_hash *h, const void **keys,
443  uint32_t num_keys, int32_t *positions);
444 
464 int32_t
465 rte_hash_iterate(const struct rte_hash *h, const void **key, void **data, uint32_t *next);
466 #ifdef __cplusplus
467 }
468 #endif
469 
470 #endif /* _RTE_HASH_H_ */