DPDK 26.03.0-rc2
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_common.h>
18#include <rte_rcu_qsbr.h>
19
20#ifdef __cplusplus
21extern "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
63typedef uint32_t hash_sig_t;
64
66typedef uint32_t (*rte_hash_function)(const void *key, uint32_t key_len,
67 uint32_t init_val);
68
70typedef int (*rte_hash_cmp_eq_t)(const void *key1, const void *key2, size_t key_len);
71
77typedef 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;
90 uint8_t extra_flag;
91};
92
99};
100
103 struct rte_rcu_qsbr *v;
108 uint32_t dq_size;
124};
125
127struct rte_hash;
128
135void
137
155struct rte_hash *
158
171
182struct rte_hash *
184
195void
197
206int32_t
207rte_hash_count(const struct rte_hash *h);
208
219int32_t
221
247int
248rte_hash_add_key_data(const struct rte_hash *h, const void *key, void *data);
249
278int32_t
279rte_hash_add_key_with_hash_data(const struct rte_hash *h, const void *key,
280 hash_sig_t sig, void *data);
281
300int32_t
301rte_hash_add_key(const struct rte_hash *h, const void *key);
302
324int32_t
325rte_hash_add_key_with_hash(const struct rte_hash *h, const void *key, hash_sig_t sig);
326
354int32_t
355rte_hash_del_key(const struct rte_hash *h, const void *key);
356
386int32_t
387rte_hash_del_key_with_hash(const struct rte_hash *h, const void *key, hash_sig_t sig);
388
406int
407rte_hash_get_key_with_position(const struct rte_hash *h, const int32_t position,
408 void **key);
409
432int
434 const int32_t position);
435
455int
456rte_hash_lookup_data(const struct rte_hash *h, const void *key, void **data);
457
480int
481rte_hash_lookup_with_hash_data(const struct rte_hash *h, const void *key,
482 hash_sig_t sig, void **data);
483
501int32_t
502rte_hash_lookup(const struct rte_hash *h, const void *key);
503
523int32_t
525 const void *key, hash_sig_t sig);
526
539rte_hash_hash(const struct rte_hash *h, const void *key);
540
560int
561rte_hash_lookup_bulk_data(const struct rte_hash *h, const void **keys,
562 uint32_t num_keys, uint64_t *hit_mask, void *data[]);
563
587int
588rte_hash_lookup_with_hash_bulk(const struct rte_hash *h, const void **keys,
589 hash_sig_t *sig, uint32_t num_keys, int32_t *positions);
590
612int
614 const void **keys, hash_sig_t *sig,
615 uint32_t num_keys, uint64_t *hit_mask, void *data[]);
616
638int
639rte_hash_lookup_bulk(const struct rte_hash *h, const void **keys,
640 uint32_t num_keys, int32_t *positions);
641
661int32_t
662rte_hash_iterate(const struct rte_hash *h, const void **key, void **data, uint32_t *next);
663
682
703__rte_experimental
704int rte_hash_rcu_qsbr_dq_reclaim(struct rte_hash *h, unsigned int *freed,
705 unsigned int *pending, unsigned int *available);
706
707#ifdef __cplusplus
708}
709#endif
710
711#endif /* _RTE_HASH_H_ */
#define __rte_dealloc(dealloc, argno)
Definition: rte_common.h:339
#define __rte_malloc
Definition: rte_common.h:328
int32_t rte_hash_add_key(const struct rte_hash *h, const void *key)
int32_t rte_hash_del_key_with_hash(const struct rte_hash *h, const void *key, hash_sig_t sig)
uint32_t(* rte_hash_function)(const void *key, uint32_t key_len, uint32_t init_val)
Definition: rte_hash.h:66
int rte_hash_lookup_data(const struct rte_hash *h, const void *key, void **data)
void rte_hash_free(struct rte_hash *h)
int rte_hash_add_key_data(const struct rte_hash *h, const void *key, void *data)
int32_t rte_hash_add_key_with_hash_data(const struct rte_hash *h, const void *key, hash_sig_t sig, void *data)
int32_t rte_hash_count(const struct rte_hash *h)
int rte_hash_rcu_qsbr_add(struct rte_hash *h, struct rte_hash_rcu_config *cfg)
int rte_hash_lookup_bulk(const struct rte_hash *h, const void **keys, uint32_t num_keys, int32_t *positions)
int32_t rte_hash_iterate(const struct rte_hash *h, const void **key, void **data, uint32_t *next)
struct rte_hash void rte_hash_set_cmp_func(struct rte_hash *h, rte_hash_cmp_eq_t func)
rte_hash_qsbr_mode
Definition: rte_hash.h:94
@ RTE_HASH_QSBR_MODE_SYNC
Definition: rte_hash.h:98
@ RTE_HASH_QSBR_MODE_DQ
Definition: rte_hash.h:96
struct rte_hash * rte_hash_find_existing(const char *name)
void(* rte_hash_free_key_data)(void *p, void *key_data)
Definition: rte_hash.h:77
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)
__rte_experimental int rte_hash_rcu_qsbr_dq_reclaim(struct rte_hash *h, unsigned int *freed, unsigned int *pending, unsigned int *available)
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_free_key_with_position(const struct rte_hash *h, const int32_t position)
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)
int32_t rte_hash_del_key(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)
hash_sig_t rte_hash_hash(const struct rte_hash *h, const void *key)
uint32_t hash_sig_t
Definition: rte_hash.h:63
int32_t rte_hash_max_key_id(const struct rte_hash *h)
struct rte_hash * rte_hash_create(const struct rte_hash_parameters *params) __rte_malloc __rte_dealloc(rte_hash_free
void rte_hash_reset(struct rte_hash *h)
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[])
int(* rte_hash_cmp_eq_t)(const void *key1, const void *key2, size_t key_len)
Definition: rte_hash.h:70
int rte_hash_lookup_bulk_data(const struct rte_hash *h, const void **keys, uint32_t num_keys, uint64_t *hit_mask, void *data[])
uint32_t hash_func_init_val
Definition: rte_hash.h:88
uint8_t extra_flag
Definition: rte_hash.h:90
uint32_t entries
Definition: rte_hash.h:84
uint32_t key_len
Definition: rte_hash.h:86
const char * name
Definition: rte_hash.h:83
uint32_t reserved
Definition: rte_hash.h:85
rte_hash_function hash_func
Definition: rte_hash.h:87
struct rte_rcu_qsbr * v
Definition: rte_hash.h:103
uint32_t trigger_reclaim_limit
Definition: rte_hash.h:112
rte_hash_free_key_data free_key_data_func
Definition: rte_hash.h:122
enum rte_hash_qsbr_mode mode
Definition: rte_hash.h:104
uint32_t dq_size
Definition: rte_hash.h:108
uint32_t max_reclaim_size
Definition: rte_hash.h:113
char name[RTE_HASH_NAMESIZE]