DPDK 21.11.9
rte_member.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2017 Intel Corporation
3 */
4
45#ifndef _RTE_MEMBER_H_
46#define _RTE_MEMBER_H_
47
48#ifdef __cplusplus
49extern "C" {
50#endif
51
52#include <stdint.h>
53
54#include <rte_common.h>
55#include <rte_config.h>
56
58typedef uint16_t member_set_t;
60#define RTE_MEMBER_NO_MATCH 0
62#define RTE_MEMBER_ENTRIES_MAX (1 << 30)
64#define RTE_MEMBER_LOOKUP_BULK_MAX 64
66#define RTE_MEMBER_BUCKET_ENTRIES 16
68#define RTE_MEMBER_NAMESIZE 32
69
71#if defined(RTE_ARCH_X86) || defined(__ARM_FEATURE_CRC32)
72#include <rte_hash_crc.h>
73#define MEMBER_HASH_FUNC rte_hash_crc
74#else
75#include <rte_jhash.h>
76#define MEMBER_HASH_FUNC rte_jhash
77#endif
78
79extern int librte_member_logtype;
80
81#define RTE_MEMBER_LOG(level, ...) \
82 rte_log(RTE_LOG_ ## level, \
83 librte_member_logtype, \
84 RTE_FMT("%s(): " RTE_FMT_HEAD(__VA_ARGS__,), \
85 __func__, \
86 RTE_FMT_TAIL(__VA_ARGS__,)))
87
89struct rte_member_setsum;
90
98
108 RTE_MEMBER_NUM_TYPE
109};
110
112enum rte_member_sig_compare_function {
113 RTE_MEMBER_COMPARE_SCALAR = 0,
114 RTE_MEMBER_COMPARE_AVX2,
115 RTE_MEMBER_COMPARE_NUM
116};
117
119struct rte_member_setsum {
120 enum rte_member_setsum_type type; /* Type of the set summary. */
121 uint32_t key_len; /* Length of key. */
122 uint32_t prim_hash_seed; /* Primary hash function seed. */
123 uint32_t sec_hash_seed; /* Secondary hash function seed. */
124
125 /* Hash table based. */
126 uint32_t bucket_cnt; /* Number of buckets. */
127 uint32_t bucket_mask; /* Bit mask to get bucket index. */
128 /* For runtime selecting AVX, scalar, etc for signature comparison. */
129 enum rte_member_sig_compare_function sig_cmp_fn;
130 uint8_t cache; /* If it is cache mode for ht based. */
131
132 /* Vector bloom filter. */
133 uint32_t num_set; /* Number of set (bf) in vbf. */
134 uint32_t bits; /* Number of bits in each bf. */
135 uint32_t bit_mask; /* Bit mask to get bit location in bf. */
136 uint32_t num_hashes; /* Number of hash values to index bf. */
137
138 uint32_t mul_shift; /* vbf internal variable used during bit test. */
139 uint32_t div_shift; /* vbf internal variable used during bit test. */
140
141 void *table; /* This is the handler of hash table or vBF array. */
142
143
144 /* Second cache line should start here. */
145 uint32_t socket_id; /* NUMA Socket ID for memory. */
146 char name[RTE_MEMBER_NAMESIZE]; /* Name of this set summary. */
148
159 const char *name;
172
192 uint8_t is_cache;
193
210 uint32_t num_keys;
211
216 uint32_t key_len;
217
227 uint32_t num_set;
228
249
259
264
266};
267
281struct rte_member_setsum *
282rte_member_find_existing(const char *name);
283
296struct rte_member_setsum *
298
315int
316rte_member_lookup(const struct rte_member_setsum *setsum, const void *key,
317 member_set_t *set_id);
318
339int
340rte_member_lookup_bulk(const struct rte_member_setsum *setsum,
341 const void **keys, uint32_t num_keys,
342 member_set_t *set_ids);
343
368int
369rte_member_lookup_multi(const struct rte_member_setsum *setsum,
370 const void *key, uint32_t max_match_per_key,
371 member_set_t *set_id);
372
399int
400rte_member_lookup_multi_bulk(const struct rte_member_setsum *setsum,
401 const void **keys, uint32_t num_keys,
402 uint32_t max_match_per_key,
403 uint32_t *match_count,
404 member_set_t *set_ids);
405
435int
436rte_member_add(const struct rte_member_setsum *setsum, const void *key,
437 member_set_t set_id);
438
448void
449rte_member_free(struct rte_member_setsum *setsum);
450
461void
462rte_member_reset(const struct rte_member_setsum *setsum);
463
482int
483rte_member_delete(const struct rte_member_setsum *setsum, const void *key,
484 member_set_t set_id);
485
486#ifdef __cplusplus
487}
488#endif
489
490#endif /* _RTE_MEMBER_H_ */
#define __rte_cache_aligned
Definition: rte_common.h:420
struct rte_member_setsum * rte_member_find_existing(const char *name)
int rte_member_add(const struct rte_member_setsum *setsum, const void *key, member_set_t set_id)
int rte_member_lookup_bulk(const struct rte_member_setsum *setsum, const void **keys, uint32_t num_keys, member_set_t *set_ids)
int rte_member_lookup(const struct rte_member_setsum *setsum, const void *key, member_set_t *set_id)
int rte_member_delete(const struct rte_member_setsum *setsum, const void *key, member_set_t set_id)
struct rte_member_setsum * rte_member_create(const struct rte_member_parameters *params)
uint16_t member_set_t
Definition: rte_member.h:58
#define RTE_MEMBER_NAMESIZE
Definition: rte_member.h:68
void rte_member_free(struct rte_member_setsum *setsum)
int rte_member_lookup_multi(const struct rte_member_setsum *setsum, const void *key, uint32_t max_match_per_key, member_set_t *set_id)
void rte_member_reset(const struct rte_member_setsum *setsum)
int rte_member_lookup_multi_bulk(const struct rte_member_setsum *setsum, const void **keys, uint32_t num_keys, uint32_t max_match_per_key, uint32_t *match_count, member_set_t *set_ids)
rte_member_setsum_type
Definition: rte_member.h:105
@ RTE_MEMBER_TYPE_VBF
Definition: rte_member.h:107
@ RTE_MEMBER_TYPE_HT
Definition: rte_member.h:106
const char * name
Definition: rte_member.h:159
enum rte_member_setsum_type type
Definition: rte_member.h:171