DPDK 22.11.5
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
57#ifndef _RTE_MEMBER_H_
58#define _RTE_MEMBER_H_
59
60#ifdef __cplusplus
61extern "C" {
62#endif
63
64#include <stdint.h>
65#include <stdbool.h>
66#include <inttypes.h>
67
68#include <rte_compat.h>
69#include <rte_common.h>
70
72typedef uint16_t member_set_t;
74#define RTE_MEMBER_NO_MATCH 0
76#define RTE_MEMBER_ENTRIES_MAX (1 << 30)
78#define RTE_MEMBER_LOOKUP_BULK_MAX 64
80#define RTE_MEMBER_BUCKET_ENTRIES 16
82#define RTE_MEMBER_NAMESIZE 32
84#define RTE_RAND_MAX ~0LLU
94#define RTE_MEMBER_SKETCH_ALWAYS_BOUNDED 0x01
96#define RTE_MEMBER_SKETCH_COUNT_BYTE 0x02
97
99#if defined(RTE_ARCH_X86) || defined(__ARM_FEATURE_CRC32)
100#include <rte_hash_crc.h>
101#define MEMBER_HASH_FUNC rte_hash_crc
102#else
103#include <rte_jhash.h>
104#define MEMBER_HASH_FUNC rte_jhash
105#endif
106
107extern int librte_member_logtype;
108
109#define RTE_MEMBER_LOG(level, ...) \
110 rte_log(RTE_LOG_ ## level, \
111 librte_member_logtype, \
112 RTE_FMT("%s(): " RTE_FMT_HEAD(__VA_ARGS__,), \
113 __func__, \
114 RTE_FMT_TAIL(__VA_ARGS__,)))
115
117struct rte_member_setsum;
118
126
136 RTE_MEMBER_TYPE_SKETCH,
137 RTE_MEMBER_NUM_TYPE
138};
139
141enum rte_member_sig_compare_function {
142 RTE_MEMBER_COMPARE_SCALAR = 0,
143 RTE_MEMBER_COMPARE_AVX2,
144 RTE_MEMBER_COMPARE_NUM
145};
146
147/* sketch update function with different implementations. */
148typedef void (*sketch_update_fn_t)(const struct rte_member_setsum *ss,
149 const void *key,
150 uint32_t count);
151
152/* sketch lookup function with different implementations. */
153typedef uint64_t (*sketch_lookup_fn_t)(const struct rte_member_setsum *ss,
154 const void *key);
155
156/* sketch delete function with different implementations. */
157typedef void (*sketch_delete_fn_t)(const struct rte_member_setsum *ss,
158 const void *key);
159
161struct rte_member_setsum {
162 enum rte_member_setsum_type type; /* Type of the set summary. */
163 uint32_t key_len; /* Length of key. */
164 uint32_t prim_hash_seed; /* Primary hash function seed. */
165 uint32_t sec_hash_seed; /* Secondary hash function seed. */
166
167 /* Hash table based. */
168 uint32_t bucket_cnt; /* Number of buckets. */
169 uint32_t bucket_mask; /* Bit mask to get bucket index. */
170 /* For runtime selecting AVX, scalar, etc for signature comparison. */
171 enum rte_member_sig_compare_function sig_cmp_fn;
172 uint8_t cache; /* If it is cache mode for ht based. */
173
174 /* Vector bloom filter. */
175 uint32_t num_set; /* Number of set (bf) in vbf. */
176 uint32_t bits; /* Number of bits in each bf. */
177 uint32_t bit_mask; /* Bit mask to get bit location in bf. */
178 uint32_t num_hashes; /* Number of hash values to index bf. */
179
180 /* Parameters for sketch */
181 float error_rate;
182 float sample_rate;
183 uint32_t num_col;
184 uint32_t num_row;
185 int always_bounded;
186 double converge_thresh;
187 uint32_t topk;
188 uint32_t count_byte;
189 uint64_t *hash_seeds;
190 sketch_update_fn_t sketch_update; /* Pointer to the sketch update function */
191 sketch_lookup_fn_t sketch_lookup; /* Pointer to the sketch lookup function */
192 sketch_delete_fn_t sketch_delete; /* Pointer to the sketch delete function */
193
194 void *runtime_var;
195 uint32_t mul_shift; /* vbf internal variable used during bit test. */
196 uint32_t div_shift; /* vbf internal variable used during bit test. */
197
198 void *table; /* This is the handler of hash table or vBF array. */
199
200
201 /* Second cache line should start here. */
202 uint32_t socket_id; /* NUMA Socket ID for memory. */
203 char name[RTE_MEMBER_NAMESIZE]; /* Name of this set summary. */
204#ifdef RTE_ARCH_X86
205 bool use_avx512;
206#endif
208
219 const char *name;
232
252 uint8_t is_cache;
253
270 uint32_t num_keys;
271
276 uint32_t key_len;
277
287 uint32_t num_set;
288
309
320
325
332
339
344 uint32_t top_k;
345
349 uint32_t extra_flag;
350
353
367struct rte_member_setsum *
368rte_member_find_existing(const char *name);
369
382struct rte_member_setsum *
384
401int
402rte_member_lookup(const struct rte_member_setsum *setsum, const void *key,
403 member_set_t *set_id);
404
425int
426rte_member_lookup_bulk(const struct rte_member_setsum *setsum,
427 const void **keys, uint32_t num_keys,
428 member_set_t *set_ids);
429
454int
455rte_member_lookup_multi(const struct rte_member_setsum *setsum,
456 const void *key, uint32_t max_match_per_key,
457 member_set_t *set_id);
458
485int
486rte_member_lookup_multi_bulk(const struct rte_member_setsum *setsum,
487 const void **keys, uint32_t num_keys,
488 uint32_t max_match_per_key,
489 uint32_t *match_count,
490 member_set_t *set_ids);
491
521int
522rte_member_add(const struct rte_member_setsum *setsum, const void *key,
523 member_set_t set_id);
524
540__rte_experimental
541int
542rte_member_add_byte_count(const struct rte_member_setsum *setsum,
543 const void *key, uint32_t byte_count);
544
560__rte_experimental
561int
562rte_member_query_count(const struct rte_member_setsum *setsum,
563 const void *key, uint64_t *count);
564
565
582__rte_experimental
583int
584rte_member_report_heavyhitter(const struct rte_member_setsum *setsum,
585 void **keys, uint64_t *counts);
586
587
598void
599rte_member_free(struct rte_member_setsum *setsum);
600
611void
612rte_member_reset(const struct rte_member_setsum *setsum);
613
632int
633rte_member_delete(const struct rte_member_setsum *setsum, const void *key,
634 member_set_t set_id);
635
636#ifdef __cplusplus
637}
638#endif
639
640#endif /* _RTE_MEMBER_H_ */
#define __rte_cache_aligned
Definition: rte_common.h:440
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)
__rte_experimental int rte_member_report_heavyhitter(const struct rte_member_setsum *setsum, void **keys, uint64_t *counts)
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)
__rte_experimental int rte_member_add_byte_count(const struct rte_member_setsum *setsum, const void *key, uint32_t byte_count)
__rte_experimental int rte_member_query_count(const struct rte_member_setsum *setsum, const void *key, uint64_t *count)
uint16_t member_set_t
Definition: rte_member.h:72
#define RTE_MEMBER_NAMESIZE
Definition: rte_member.h:82
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:133
@ RTE_MEMBER_TYPE_VBF
Definition: rte_member.h:135
@ RTE_MEMBER_TYPE_HT
Definition: rte_member.h:134
const char * name
Definition: rte_member.h:219
enum rte_member_setsum_type type
Definition: rte_member.h:231