DPDK  20.11.5
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 #include <rte_rcu_qsbr.h>
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
25 #define RTE_HASH_ENTRIES_MAX (1 << 30)
26 
28 #define RTE_HASH_NAMESIZE 32
29 
31 #define RTE_HASH_LOOKUP_BULK_MAX 64
32 #define RTE_HASH_LOOKUP_MULTI_MAX RTE_HASH_LOOKUP_BULK_MAX
33 
35 #define RTE_HASH_EXTRA_FLAGS_TRANS_MEM_SUPPORT 0x01
36 
38 #define RTE_HASH_EXTRA_FLAGS_MULTI_WRITER_ADD 0x02
39 
41 #define RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY 0x04
42 
44 #define RTE_HASH_EXTRA_FLAGS_EXT_TABLE 0x08
45 
52 #define RTE_HASH_EXTRA_FLAGS_NO_FREE_ON_DEL 0x10
53 
57 #define RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF 0x20
58 
63 typedef uint32_t hash_sig_t;
64 
66 typedef uint32_t (*rte_hash_function)(const void *key, uint32_t key_len,
67  uint32_t init_val);
68 
70 typedef int (*rte_hash_cmp_eq_t)(const void *key1, const void *key2, size_t key_len);
71 
77 typedef void (*rte_hash_free_key_data)(void *p, void *key_data);
78 
83  const char *name;
84  uint32_t entries;
85  uint32_t reserved;
86  uint32_t key_len;
88  uint32_t hash_func_init_val;
89  int socket_id;
90  uint8_t extra_flag;
91 };
92 
99 };
100 
103  struct rte_rcu_qsbr *v;
108  uint32_t dq_size;
124 };
125 
127 struct rte_hash;
128 
146 struct rte_hash *
147 rte_hash_create(const struct rte_hash_parameters *params);
148 
160 void rte_hash_set_cmp_func(struct rte_hash *h, rte_hash_cmp_eq_t func);
161 
172 struct rte_hash *
173 rte_hash_find_existing(const char *name);
174 
180 void
181 rte_hash_free(struct rte_hash *h);
182 
193 void
194 rte_hash_reset(struct rte_hash *h);
195 
204 int32_t
205 rte_hash_count(const struct rte_hash *h);
206 
220 __rte_experimental
221 int32_t
222 rte_hash_max_key_id(const struct rte_hash *h);
223 
247 int
248 rte_hash_add_key_data(const struct rte_hash *h, const void *key, void *data);
249 
276 int32_t
277 rte_hash_add_key_with_hash_data(const struct rte_hash *h, const void *key,
278  hash_sig_t sig, void *data);
279 
298 int32_t
299 rte_hash_add_key(const struct rte_hash *h, const void *key);
300 
322 int32_t
323 rte_hash_add_key_with_hash(const struct rte_hash *h, const void *key, hash_sig_t sig);
324 
352 int32_t
353 rte_hash_del_key(const struct rte_hash *h, const void *key);
354 
384 int32_t
385 rte_hash_del_key_with_hash(const struct rte_hash *h, const void *key, hash_sig_t sig);
386 
404 int
405 rte_hash_get_key_with_position(const struct rte_hash *h, const int32_t position,
406  void **key);
407 
433 __rte_experimental
434 int
436  const int32_t position);
437 
457 int
458 rte_hash_lookup_data(const struct rte_hash *h, const void *key, void **data);
459 
482 int
483 rte_hash_lookup_with_hash_data(const struct rte_hash *h, const void *key,
484  hash_sig_t sig, void **data);
485 
503 int32_t
504 rte_hash_lookup(const struct rte_hash *h, const void *key);
505 
525 int32_t
526 rte_hash_lookup_with_hash(const struct rte_hash *h,
527  const void *key, hash_sig_t sig);
528 
541 rte_hash_hash(const struct rte_hash *h, const void *key);
542 
562 int
563 rte_hash_lookup_bulk_data(const struct rte_hash *h, const void **keys,
564  uint32_t num_keys, uint64_t *hit_mask, void *data[]);
565 
592 __rte_experimental
593 int
594 rte_hash_lookup_with_hash_bulk(const struct rte_hash *h, const void **keys,
595  hash_sig_t *sig, uint32_t num_keys, int32_t *positions);
596 
621 __rte_experimental
622 int
624  const void **keys, hash_sig_t *sig,
625  uint32_t num_keys, uint64_t *hit_mask, void *data[]);
626 
648 int
649 rte_hash_lookup_bulk(const struct rte_hash *h, const void **keys,
650  uint32_t num_keys, int32_t *positions);
651 
671 int32_t
672 rte_hash_iterate(const struct rte_hash *h, const void **key, void **data, uint32_t *next);
673 
694 __rte_experimental
695 int rte_hash_rcu_qsbr_add(struct rte_hash *h, struct rte_hash_rcu_config *cfg);
696 
697 #ifdef __cplusplus
698 }
699 #endif
700 
701 #endif /* _RTE_HASH_H_ */
rte_hash_rcu_config
Definition: rte_hash.h:102
rte_hash_add_key
int32_t rte_hash_add_key(const struct rte_hash *h, const void *key)
rte_hash_lookup_with_hash
int32_t rte_hash_lookup_with_hash(const struct rte_hash *h, const void *key, hash_sig_t sig)
RTE_HASH_QSBR_MODE_SYNC
@ RTE_HASH_QSBR_MODE_SYNC
Definition: rte_hash.h:98
rte_hash_lookup_bulk
int rte_hash_lookup_bulk(const struct rte_hash *h, const void **keys, uint32_t num_keys, int32_t *positions)
rte_hash_rcu_config::v
struct rte_rcu_qsbr * v
Definition: rte_hash.h:103
rte_hash_parameters
Definition: rte_hash.h:82
rte_hash_lookup_bulk_data
int rte_hash_lookup_bulk_data(const struct rte_hash *h, const void **keys, uint32_t num_keys, uint64_t *hit_mask, void *data[])
rte_hash_get_key_with_position
int rte_hash_get_key_with_position(const struct rte_hash *h, const int32_t position, void **key)
rte_hash_iterate
int32_t rte_hash_iterate(const struct rte_hash *h, const void **key, void **data, uint32_t *next)
rte_fbk_hash_table::init_val
uint32_t init_val
Definition: rte_fbk_hash.h:79
rte_hash_rcu_config::dq_size
uint32_t dq_size
Definition: rte_hash.h:108
rte_hash_max_key_id
__rte_experimental int32_t rte_hash_max_key_id(const struct rte_hash *h)
rte_hash_add_key_with_hash_data
int32_t rte_hash_add_key_with_hash_data(const struct rte_hash *h, const void *key, hash_sig_t sig, void *data)
rte_hash_count
int32_t rte_hash_count(const struct rte_hash *h)
rte_hash_find_existing
struct rte_hash * rte_hash_find_existing(const char *name)
rte_hash_lookup_with_hash_bulk_data
__rte_experimental int rte_hash_lookup_with_hash_bulk_data(const struct rte_hash *h, const void **keys, hash_sig_t *sig, uint32_t num_keys, uint64_t *hit_mask, void *data[])
rte_hash_free_key_with_position
__rte_experimental int rte_hash_free_key_with_position(const struct rte_hash *h, const int32_t position)
RTE_HASH_QSBR_MODE_DQ
@ RTE_HASH_QSBR_MODE_DQ
Definition: rte_hash.h:96
rte_hash_free
void rte_hash_free(struct rte_hash *h)
rte_hash_lookup
int32_t rte_hash_lookup(const struct rte_hash *h, const void *key)
rte_hash_free_key_data
void(* rte_hash_free_key_data)(void *p, void *key_data)
Definition: rte_hash.h:77
rte_hash_del_key
int32_t rte_hash_del_key(const struct rte_hash *h, const void *key)
rte_hash_lookup_data
int rte_hash_lookup_data(const struct rte_hash *h, const void *key, void **data)
rte_hash_parameters::name
const char * name
Definition: rte_hash.h:83
rte_hash_parameters::reserved
uint32_t reserved
Definition: rte_hash.h:85
rte_hash_add_key_with_hash
int32_t rte_hash_add_key_with_hash(const struct rte_hash *h, const void *key, hash_sig_t sig)
rte_hash_set_cmp_func
void rte_hash_set_cmp_func(struct rte_hash *h, rte_hash_cmp_eq_t func)
rte_hash_parameters::hash_func
rte_hash_function hash_func
Definition: rte_hash.h:87
rte_hash_parameters::entries
uint32_t entries
Definition: rte_hash.h:84
rte_hash_lookup_with_hash_data
int rte_hash_lookup_with_hash_data(const struct rte_hash *h, const void *key, hash_sig_t sig, void **data)
rte_hash_qsbr_mode
rte_hash_qsbr_mode
Definition: rte_hash.h:94
rte_hash_lookup_with_hash_bulk
__rte_experimental int rte_hash_lookup_with_hash_bulk(const struct rte_hash *h, const void **keys, hash_sig_t *sig, uint32_t num_keys, int32_t *positions)
rte_hash_cmp_eq_t
int(* rte_hash_cmp_eq_t)(const void *key1, const void *key2, size_t key_len)
Definition: rte_hash.h:70
rte_hash_function
uint32_t(* rte_hash_function)(const void *key, uint32_t key_len, uint32_t init_val)
Definition: rte_hash.h:66
hash_sig_t
uint32_t hash_sig_t
Definition: rte_hash.h:63
rte_hash_parameters::hash_func_init_val
uint32_t hash_func_init_val
Definition: rte_hash.h:88
rte_hash_parameters::extra_flag
uint8_t extra_flag
Definition: rte_hash.h:90
rte_hash_hash
hash_sig_t rte_hash_hash(const struct rte_hash *h, const void *key)
rte_hash_rcu_config::mode
enum rte_hash_qsbr_mode mode
Definition: rte_hash.h:104
rte_hash_rcu_config::trigger_reclaim_limit
uint32_t trigger_reclaim_limit
Definition: rte_hash.h:112
rte_rcu_qsbr.h
rte_hash_rcu_config::key_data_ptr
void * key_data_ptr
Definition: rte_hash.h:117
rte_hash_create
struct rte_hash * rte_hash_create(const struct rte_hash_parameters *params)
rte_hash::name
char name[RTE_HASH_NAMESIZE]
Definition: rte_cuckoo_hash.h:161
rte_hash
Definition: rte_cuckoo_hash.h:160
rte_hash_del_key_with_hash
int32_t rte_hash_del_key_with_hash(const struct rte_hash *h, const void *key, hash_sig_t sig)
rte_hash_parameters::socket_id
int socket_id
Definition: rte_hash.h:89
rte_hash_parameters::key_len
uint32_t key_len
Definition: rte_hash.h:86
rte_hash_rcu_config::free_key_data_func
rte_hash_free_key_data free_key_data_func
Definition: rte_hash.h:122
rte_hash_reset
void rte_hash_reset(struct rte_hash *h)
rte_hash_rcu_config::max_reclaim_size
uint32_t max_reclaim_size
Definition: rte_hash.h:113
rte_hash_add_key_data
int rte_hash_add_key_data(const struct rte_hash *h, const void *key, void *data)
rte_hash_rcu_qsbr_add
__rte_experimental int rte_hash_rcu_qsbr_add(struct rte_hash *h, struct rte_hash_rcu_config *cfg)