DPDK 25.03.0-rc0
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
54#ifndef _RTE_MEMBER_H_
55#define _RTE_MEMBER_H_
56
57#include <stdint.h>
58#include <stdbool.h>
59#include <inttypes.h>
60
61#include <rte_common.h>
62
64typedef uint16_t member_set_t;
66#define RTE_MEMBER_NO_MATCH 0
68#define RTE_MEMBER_ENTRIES_MAX (1 << 30)
70#define RTE_MEMBER_LOOKUP_BULK_MAX 64
72#define RTE_MEMBER_BUCKET_ENTRIES 16
74#define RTE_MEMBER_NAMESIZE 32
76#define RTE_RAND_MAX ~0LLU
86#define RTE_MEMBER_SKETCH_ALWAYS_BOUNDED 0x01
88#define RTE_MEMBER_SKETCH_COUNT_BYTE 0x02
89
91#if defined(RTE_ARCH_X86) || defined(__ARM_FEATURE_CRC32)
92#include <rte_hash_crc.h>
93#define MEMBER_HASH_FUNC rte_hash_crc
94#else
95#include <rte_jhash.h>
96#define MEMBER_HASH_FUNC rte_jhash
97#endif
98
99#ifdef __cplusplus
100extern "C" {
101#endif
102
104struct rte_member_setsum;
105
110
117 RTE_MEMBER_TYPE_SKETCH,
118 RTE_MEMBER_NUM_TYPE
119};
120
122enum rte_member_sig_compare_function {
123 RTE_MEMBER_COMPARE_SCALAR = 0,
124 RTE_MEMBER_COMPARE_AVX2,
125 RTE_MEMBER_COMPARE_NUM
126};
127
128/* sketch update function with different implementations. */
129typedef void (*sketch_update_fn_t)(const struct rte_member_setsum *ss,
130 const void *key,
131 uint32_t count);
132
133/* sketch lookup function with different implementations. */
134typedef uint64_t (*sketch_lookup_fn_t)(const struct rte_member_setsum *ss,
135 const void *key);
136
137/* sketch delete function with different implementations. */
138typedef void (*sketch_delete_fn_t)(const struct rte_member_setsum *ss,
139 const void *key);
140
142struct __rte_cache_aligned rte_member_setsum {
143 enum rte_member_setsum_type type; /* Type of the set summary. */
144 uint32_t key_len; /* Length of key. */
145 uint32_t prim_hash_seed; /* Primary hash function seed. */
146 uint32_t sec_hash_seed; /* Secondary hash function seed. */
147
148 /* Hash table based. */
149 uint32_t bucket_cnt; /* Number of buckets. */
150 uint32_t bucket_mask; /* Bit mask to get bucket index. */
151 /* For runtime selecting AVX, scalar, etc for signature comparison. */
152 enum rte_member_sig_compare_function sig_cmp_fn;
153 uint8_t cache; /* If it is cache mode for ht based. */
154
155 /* Vector bloom filter. */
156 uint32_t num_set; /* Number of set (bf) in vbf. */
157 uint32_t bits; /* Number of bits in each bf. */
158 uint32_t bit_mask; /* Bit mask to get bit location in bf. */
159 uint32_t num_hashes; /* Number of hash values to index bf. */
160
161 /* Parameters for sketch */
162 float error_rate;
163 float sample_rate;
164 uint32_t num_col;
165 uint32_t num_row;
166 int always_bounded;
167 double converge_thresh;
168 uint32_t topk;
169 uint32_t count_byte;
170 uint64_t *hash_seeds;
171 sketch_update_fn_t sketch_update; /* Pointer to the sketch update function */
172 sketch_lookup_fn_t sketch_lookup; /* Pointer to the sketch lookup function */
173 sketch_delete_fn_t sketch_delete; /* Pointer to the sketch delete function */
174
175 void *runtime_var;
176 uint32_t mul_shift; /* vbf internal variable used during bit test. */
177 uint32_t div_shift; /* vbf internal variable used during bit test. */
178
179 void *table; /* This is the handler of hash table or vBF array. */
180
181
182 /* Second cache line should start here. */
183 uint32_t socket_id; /* NUMA Socket ID for memory. */
184 char name[RTE_MEMBER_NAMESIZE]; /* Name of this set summary. */
185#ifdef RTE_ARCH_X86
186 bool use_avx512;
187#endif
188};
189
196 const char *name;
209
229 uint8_t is_cache;
230
247 uint32_t num_keys;
248
253 uint32_t key_len;
254
264 uint32_t num_set;
265
286
297
302
309
316
321 uint32_t top_k;
322
326 uint32_t extra_flag;
327
329};
330
341struct rte_member_setsum *
342rte_member_find_existing(const char *name);
343
353struct rte_member_setsum *
355
369int
370rte_member_lookup(const struct rte_member_setsum *setsum, const void *key,
371 member_set_t *set_id);
372
390int
391rte_member_lookup_bulk(const struct rte_member_setsum *setsum,
392 const void **keys, uint32_t num_keys,
393 member_set_t *set_ids);
394
416int
417rte_member_lookup_multi(const struct rte_member_setsum *setsum,
418 const void *key, uint32_t max_match_per_key,
419 member_set_t *set_id);
420
444int
445rte_member_lookup_multi_bulk(const struct rte_member_setsum *setsum,
446 const void **keys, uint32_t num_keys,
447 uint32_t max_match_per_key,
448 uint32_t *match_count,
449 member_set_t *set_ids);
450
477int
478rte_member_add(const struct rte_member_setsum *setsum, const void *key,
479 member_set_t set_id);
480
493int
494rte_member_add_byte_count(const struct rte_member_setsum *setsum,
495 const void *key, uint32_t byte_count);
496
509int
510rte_member_query_count(const struct rte_member_setsum *setsum,
511 const void *key, uint64_t *count);
512
513
527int
528rte_member_report_heavyhitter(const struct rte_member_setsum *setsum,
529 void **keys, uint64_t *counts);
530
531
539void
540rte_member_free(struct rte_member_setsum *setsum);
541
549void
550rte_member_reset(const struct rte_member_setsum *setsum);
551
567int
568rte_member_delete(const struct rte_member_setsum *setsum, const void *key,
569 member_set_t set_id);
570
571#ifdef __cplusplus
572}
573#endif
574
575#endif /* _RTE_MEMBER_H_ */
#define __rte_cache_aligned
Definition: rte_common.h:627
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_query_count(const struct rte_member_setsum *setsum, const void *key, uint64_t *count)
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)
int rte_member_report_heavyhitter(const struct rte_member_setsum *setsum, void **keys, uint64_t *counts)
uint16_t member_set_t
Definition: rte_member.h:64
#define RTE_MEMBER_NAMESIZE
Definition: rte_member.h:74
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)
int rte_member_add_byte_count(const struct rte_member_setsum *setsum, const void *key, uint32_t byte_count)
rte_member_setsum_type
Definition: rte_member.h:114
@ RTE_MEMBER_TYPE_VBF
Definition: rte_member.h:116
@ RTE_MEMBER_TYPE_HT
Definition: rte_member.h:115
const char * name
Definition: rte_member.h:196
enum rte_member_setsum_type type
Definition: rte_member.h:208