DPDK  20.05.0-rc0
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 #include <rte_compat.h>
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
24 #define RTE_HASH_ENTRIES_MAX (1 << 30)
25 
27 #define RTE_HASH_NAMESIZE 32
28 
30 #define RTE_HASH_LOOKUP_BULK_MAX 64
31 #define RTE_HASH_LOOKUP_MULTI_MAX RTE_HASH_LOOKUP_BULK_MAX
32 
34 #define RTE_HASH_EXTRA_FLAGS_TRANS_MEM_SUPPORT 0x01
35 
37 #define RTE_HASH_EXTRA_FLAGS_MULTI_WRITER_ADD 0x02
38 
40 #define RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY 0x04
41 
43 #define RTE_HASH_EXTRA_FLAGS_EXT_TABLE 0x08
44 
50 #define RTE_HASH_EXTRA_FLAGS_NO_FREE_ON_DEL 0x10
51 
55 #define RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF 0x20
56 
61 typedef uint32_t hash_sig_t;
62 
64 typedef uint32_t (*rte_hash_function)(const void *key, uint32_t key_len,
65  uint32_t init_val);
66 
68 typedef int (*rte_hash_cmp_eq_t)(const void *key1, const void *key2, size_t key_len);
69 
74  const char *name;
75  uint32_t entries;
76  uint32_t reserved;
77  uint32_t key_len;
79  uint32_t hash_func_init_val;
80  int socket_id;
81  uint8_t extra_flag;
82 };
83 
85 struct rte_hash;
86 
104 struct rte_hash *
105 rte_hash_create(const struct rte_hash_parameters *params);
106 
118 void rte_hash_set_cmp_func(struct rte_hash *h, rte_hash_cmp_eq_t func);
119 
130 struct rte_hash *
131 rte_hash_find_existing(const char *name);
132 
138 void
139 rte_hash_free(struct rte_hash *h);
140 
151 void
152 rte_hash_reset(struct rte_hash *h);
153 
162 int32_t
163 rte_hash_count(const struct rte_hash *h);
164 
178 __rte_experimental
179 int32_t
180 rte_hash_max_key_id(const struct rte_hash *h);
181 
205 int
206 rte_hash_add_key_data(const struct rte_hash *h, const void *key, void *data);
207 
234 int32_t
235 rte_hash_add_key_with_hash_data(const struct rte_hash *h, const void *key,
236  hash_sig_t sig, void *data);
237 
256 int32_t
257 rte_hash_add_key(const struct rte_hash *h, const void *key);
258 
280 int32_t
281 rte_hash_add_key_with_hash(const struct rte_hash *h, const void *key, hash_sig_t sig);
282 
309 int32_t
310 rte_hash_del_key(const struct rte_hash *h, const void *key);
311 
340 int32_t
341 rte_hash_del_key_with_hash(const struct rte_hash *h, const void *key, hash_sig_t sig);
342 
360 int
361 rte_hash_get_key_with_position(const struct rte_hash *h, const int32_t position,
362  void **key);
363 
388 __rte_experimental
389 int
391  const int32_t position);
392 
412 int
413 rte_hash_lookup_data(const struct rte_hash *h, const void *key, void **data);
414 
437 int
438 rte_hash_lookup_with_hash_data(const struct rte_hash *h, const void *key,
439  hash_sig_t sig, void **data);
440 
458 int32_t
459 rte_hash_lookup(const struct rte_hash *h, const void *key);
460 
480 int32_t
481 rte_hash_lookup_with_hash(const struct rte_hash *h,
482  const void *key, hash_sig_t sig);
483 
495 hash_sig_t
496 rte_hash_hash(const struct rte_hash *h, const void *key);
497 
517 int
518 rte_hash_lookup_bulk_data(const struct rte_hash *h, const void **keys,
519  uint32_t num_keys, uint64_t *hit_mask, void *data[]);
520 
542 int
543 rte_hash_lookup_bulk(const struct rte_hash *h, const void **keys,
544  uint32_t num_keys, int32_t *positions);
545 
565 int32_t
566 rte_hash_iterate(const struct rte_hash *h, const void **key, void **data, uint32_t *next);
567 #ifdef __cplusplus
568 }
569 #endif
570 
571 #endif /* _RTE_HASH_H_ */
uint32_t(* rte_hash_function)(const void *key, uint32_t key_len, uint32_t init_val)
Definition: rte_hash.h:64
int rte_hash_lookup_bulk(const struct rte_hash *h, const void **keys, uint32_t num_keys, int32_t *positions)
uint32_t key_len
Definition: rte_hash.h:77
int rte_hash_get_key_with_position(const struct rte_hash *h, const int32_t position, void **key)
int32_t rte_hash_lookup_with_hash(const struct rte_hash *h, const void *key, hash_sig_t sig)
__rte_experimental int32_t rte_hash_max_key_id(const struct rte_hash *h)
int rte_hash_lookup_data(const struct rte_hash *h, const void *key, void **data)
struct rte_hash * rte_hash_create(const struct rte_hash_parameters *params)
int rte_hash_lookup_bulk_data(const struct rte_hash *h, const void **keys, uint32_t num_keys, uint64_t *hit_mask, void *data[])
hash_sig_t rte_hash_hash(const struct rte_hash *h, const void *key)
int32_t rte_hash_add_key_with_hash(const struct rte_hash *h, const void *key, hash_sig_t sig)
const char * name
Definition: rte_hash.h:74
uint32_t reserved
Definition: rte_hash.h:76
void rte_hash_reset(struct rte_hash *h)
int rte_hash_add_key_data(const struct rte_hash *h, const void *key, void *data)
void rte_hash_free(struct rte_hash *h)
int rte_hash_lookup_with_hash_data(const struct rte_hash *h, const void *key, hash_sig_t sig, void **data)
int32_t rte_hash_lookup(const struct rte_hash *h, const void *key)
int32_t rte_hash_add_key_with_hash_data(const struct rte_hash *h, const void *key, hash_sig_t sig, void *data)
int(* rte_hash_cmp_eq_t)(const void *key1, const void *key2, size_t key_len)
Definition: rte_hash.h:68
int32_t rte_hash_count(const struct rte_hash *h)
rte_hash_function hash_func
Definition: rte_hash.h:78
int32_t rte_hash_del_key_with_hash(const struct rte_hash *h, const void *key, hash_sig_t sig)
uint32_t entries
Definition: rte_hash.h:75
uint32_t hash_func_init_val
Definition: rte_hash.h:79
struct rte_hash * rte_hash_find_existing(const char *name)
int32_t rte_hash_add_key(const struct rte_hash *h, const void *key)
uint32_t hash_sig_t
Definition: rte_hash.h:61
int32_t rte_hash_del_key(const struct rte_hash *h, const void *key)
uint8_t extra_flag
Definition: rte_hash.h:81
void rte_hash_set_cmp_func(struct rte_hash *h, rte_hash_cmp_eq_t func)
int32_t rte_hash_iterate(const struct rte_hash *h, const void **key, void **data, uint32_t *next)
__rte_experimental int rte_hash_free_key_with_position(const struct rte_hash *h, const int32_t position)