DPDK  21.11.7-rc1
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 
217 int32_t
218 rte_hash_max_key_id(const struct rte_hash *h);
219 
243 int
244 rte_hash_add_key_data(const struct rte_hash *h, const void *key, void *data);
245 
272 int32_t
273 rte_hash_add_key_with_hash_data(const struct rte_hash *h, const void *key,
274  hash_sig_t sig, void *data);
275 
294 int32_t
295 rte_hash_add_key(const struct rte_hash *h, const void *key);
296 
318 int32_t
319 rte_hash_add_key_with_hash(const struct rte_hash *h, const void *key, hash_sig_t sig);
320 
348 int32_t
349 rte_hash_del_key(const struct rte_hash *h, const void *key);
350 
380 int32_t
381 rte_hash_del_key_with_hash(const struct rte_hash *h, const void *key, hash_sig_t sig);
382 
400 int
401 rte_hash_get_key_with_position(const struct rte_hash *h, const int32_t position,
402  void **key);
403 
426 int
428  const int32_t position);
429 
449 int
450 rte_hash_lookup_data(const struct rte_hash *h, const void *key, void **data);
451 
474 int
475 rte_hash_lookup_with_hash_data(const struct rte_hash *h, const void *key,
476  hash_sig_t sig, void **data);
477 
495 int32_t
496 rte_hash_lookup(const struct rte_hash *h, const void *key);
497 
517 int32_t
518 rte_hash_lookup_with_hash(const struct rte_hash *h,
519  const void *key, hash_sig_t sig);
520 
532 hash_sig_t
533 rte_hash_hash(const struct rte_hash *h, const void *key);
534 
554 int
555 rte_hash_lookup_bulk_data(const struct rte_hash *h, const void **keys,
556  uint32_t num_keys, uint64_t *hit_mask, void *data[]);
557 
581 int
582 rte_hash_lookup_with_hash_bulk(const struct rte_hash *h, const void **keys,
583  hash_sig_t *sig, uint32_t num_keys, int32_t *positions);
584 
606 int
608  const void **keys, hash_sig_t *sig,
609  uint32_t num_keys, uint64_t *hit_mask, void *data[]);
610 
632 int
633 rte_hash_lookup_bulk(const struct rte_hash *h, const void **keys,
634  uint32_t num_keys, int32_t *positions);
635 
655 int32_t
656 rte_hash_iterate(const struct rte_hash *h, const void **key, void **data, uint32_t *next);
657 
675 int rte_hash_rcu_qsbr_add(struct rte_hash *h, struct rte_hash_rcu_config *cfg);
676 
677 #ifdef __cplusplus
678 }
679 #endif
680 
681 #endif /* _RTE_HASH_H_ */
void(* rte_hash_free_key_data)(void *p, void *key_data)
Definition: rte_hash.h:77
uint32_t(* rte_hash_function)(const void *key, uint32_t key_len, uint32_t init_val)
Definition: rte_hash.h:66
uint32_t dq_size
Definition: rte_hash.h:108
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:86
uint32_t max_reclaim_size
Definition: rte_hash.h:113
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)
const char * name
Definition: rte_hash.h:83
uint32_t reserved
Definition: rte_hash.h:85
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:112
rte_hash_free_key_data free_key_data_func
Definition: rte_hash.h:122
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:70
int32_t rte_hash_count(const struct rte_hash *h)
rte_hash_function hash_func
Definition: rte_hash.h:87
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:84
uint32_t hash_func_init_val
Definition: rte_hash.h:88
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)
int32_t rte_hash_add_key(const struct rte_hash *h, const void *key)
rte_hash_qsbr_mode
Definition: rte_hash.h:94
uint32_t hash_sig_t
Definition: rte_hash.h:63
int32_t rte_hash_del_key(const struct rte_hash *h, const void *key)
uint8_t extra_flag
Definition: rte_hash.h:90
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)
struct rte_rcu_qsbr * v
Definition: rte_hash.h:103