DPDK  24.11.6
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_rcu_qsbr.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 
51 #define RTE_HASH_EXTRA_FLAGS_NO_FREE_ON_DEL 0x10
52 
56 #define RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF 0x20
57 
62 typedef uint32_t hash_sig_t;
63 
65 typedef uint32_t (*rte_hash_function)(const void *key, uint32_t key_len,
66  uint32_t init_val);
67 
69 typedef int (*rte_hash_cmp_eq_t)(const void *key1, const void *key2, size_t key_len);
70 
76 typedef void (*rte_hash_free_key_data)(void *p, void *key_data);
77 
82  const char *name;
83  uint32_t entries;
84  uint32_t reserved;
85  uint32_t key_len;
87  uint32_t hash_func_init_val;
88  int socket_id;
89  uint8_t extra_flag;
90 };
91 
98 };
99 
102  struct rte_rcu_qsbr *v;
107  uint32_t dq_size;
123 };
124 
126 struct rte_hash;
127 
145 struct rte_hash *
146 rte_hash_create(const struct rte_hash_parameters *params);
147 
159 void rte_hash_set_cmp_func(struct rte_hash *h, rte_hash_cmp_eq_t func);
160 
171 struct rte_hash *
172 rte_hash_find_existing(const char *name);
173 
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 
217 int32_t
218 rte_hash_max_key_id(const struct rte_hash *h);
219 
245 int
246 rte_hash_add_key_data(const struct rte_hash *h, const void *key, void *data);
247 
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 
430 int
432  const int32_t position);
433 
453 int
454 rte_hash_lookup_data(const struct rte_hash *h, const void *key, void **data);
455 
478 int
479 rte_hash_lookup_with_hash_data(const struct rte_hash *h, const void *key,
480  hash_sig_t sig, void **data);
481 
499 int32_t
500 rte_hash_lookup(const struct rte_hash *h, const void *key);
501 
521 int32_t
522 rte_hash_lookup_with_hash(const struct rte_hash *h,
523  const void *key, hash_sig_t sig);
524 
537 rte_hash_hash(const struct rte_hash *h, const void *key);
538 
558 int
559 rte_hash_lookup_bulk_data(const struct rte_hash *h, const void **keys,
560  uint32_t num_keys, uint64_t *hit_mask, void *data[]);
561 
585 int
586 rte_hash_lookup_with_hash_bulk(const struct rte_hash *h, const void **keys,
587  hash_sig_t *sig, uint32_t num_keys, int32_t *positions);
588 
610 int
612  const void **keys, hash_sig_t *sig,
613  uint32_t num_keys, uint64_t *hit_mask, void *data[]);
614 
636 int
637 rte_hash_lookup_bulk(const struct rte_hash *h, const void **keys,
638  uint32_t num_keys, int32_t *positions);
639 
659 int32_t
660 rte_hash_iterate(const struct rte_hash *h, const void **key, void **data, uint32_t *next);
661 
679 int rte_hash_rcu_qsbr_add(struct rte_hash *h, struct rte_hash_rcu_config *cfg);
680 
701 __rte_experimental
702 int rte_hash_rcu_qsbr_dq_reclaim(struct rte_hash *h, unsigned int *freed,
703  unsigned int *pending, unsigned int *available);
704 
705 #ifdef __cplusplus
706 }
707 #endif
708 
709 #endif /* _RTE_HASH_H_ */
void(* rte_hash_free_key_data)(void *p, void *key_data)
Definition: rte_hash.h:76
uint32_t(* rte_hash_function)(const void *key, uint32_t key_len, uint32_t init_val)
Definition: rte_hash.h:65
uint32_t dq_size
Definition: rte_hash.h:107
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:85
uint32_t max_reclaim_size
Definition: rte_hash.h:112
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)
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)
int rte_hash_free_key_with_position(const struct rte_hash *h, const int32_t position)
int32_t rte_hash_add_key_with_hash(const struct rte_hash *h, const void *key, hash_sig_t sig)
char name[RTE_HASH_NAMESIZE]
const char * name
Definition: rte_hash.h:82
uint32_t reserved
Definition: rte_hash.h:84
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[])
void rte_hash_reset(struct rte_hash *h)
int32_t rte_hash_max_key_id(const 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)
uint32_t trigger_reclaim_limit
Definition: rte_hash.h:111
rte_hash_free_key_data free_key_data_func
Definition: rte_hash.h:121
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:69
int32_t rte_hash_count(const struct rte_hash *h)
rte_hash_function hash_func
Definition: rte_hash.h:86
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:83
uint32_t hash_func_init_val
Definition: rte_hash.h:87
struct rte_hash * rte_hash_find_existing(const char *name)
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)
int rte_hash_rcu_qsbr_add(struct rte_hash *h, struct rte_hash_rcu_config *cfg)
__rte_experimental int rte_hash_rcu_qsbr_dq_reclaim(struct rte_hash *h, unsigned int *freed, unsigned int *pending, unsigned int *available)
int32_t rte_hash_add_key(const struct rte_hash *h, const void *key)
rte_hash_qsbr_mode
Definition: rte_hash.h:93
uint32_t hash_sig_t
Definition: rte_hash.h:62
int32_t rte_hash_del_key(const struct rte_hash *h, const void *key)
uint8_t extra_flag
Definition: rte_hash.h:89
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)
enum rte_hash_qsbr_mode mode
Definition: rte_hash.h:103
struct rte_rcu_qsbr * v
Definition: rte_hash.h:102