DPDK  22.03.0
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
49 extern "C" {
50 #endif
51 
52 #include <stdint.h>
53 
54 #include <rte_common.h>
55 
57 typedef uint16_t member_set_t;
59 #define RTE_MEMBER_NO_MATCH 0
60 
61 #define RTE_MEMBER_ENTRIES_MAX (1 << 30)
62 
63 #define RTE_MEMBER_LOOKUP_BULK_MAX 64
64 
65 #define RTE_MEMBER_BUCKET_ENTRIES 16
66 
67 #define RTE_MEMBER_NAMESIZE 32
68 
70 #if defined(RTE_ARCH_X86) || defined(__ARM_FEATURE_CRC32)
71 #include <rte_hash_crc.h>
72 #define MEMBER_HASH_FUNC rte_hash_crc
73 #else
74 #include <rte_jhash.h>
75 #define MEMBER_HASH_FUNC rte_jhash
76 #endif
77 
78 extern int librte_member_logtype;
79 
80 #define RTE_MEMBER_LOG(level, ...) \
81  rte_log(RTE_LOG_ ## level, \
82  librte_member_logtype, \
83  RTE_FMT("%s(): " RTE_FMT_HEAD(__VA_ARGS__,), \
84  __func__, \
85  RTE_FMT_TAIL(__VA_ARGS__,)))
86 
88 struct rte_member_setsum;
89 
97 
107  RTE_MEMBER_NUM_TYPE
108 };
109 
111 enum rte_member_sig_compare_function {
112  RTE_MEMBER_COMPARE_SCALAR = 0,
113  RTE_MEMBER_COMPARE_AVX2,
114  RTE_MEMBER_COMPARE_NUM
115 };
116 
118 struct rte_member_setsum {
119  enum rte_member_setsum_type type; /* Type of the set summary. */
120  uint32_t key_len; /* Length of key. */
121  uint32_t prim_hash_seed; /* Primary hash function seed. */
122  uint32_t sec_hash_seed; /* Secondary hash function seed. */
123 
124  /* Hash table based. */
125  uint32_t bucket_cnt; /* Number of buckets. */
126  uint32_t bucket_mask; /* Bit mask to get bucket index. */
127  /* For runtime selecting AVX, scalar, etc for signature comparison. */
128  enum rte_member_sig_compare_function sig_cmp_fn;
129  uint8_t cache; /* If it is cache mode for ht based. */
130 
131  /* Vector bloom filter. */
132  uint32_t num_set; /* Number of set (bf) in vbf. */
133  uint32_t bits; /* Number of bits in each bf. */
134  uint32_t bit_mask; /* Bit mask to get bit location in bf. */
135  uint32_t num_hashes; /* Number of hash values to index bf. */
136 
137  uint32_t mul_shift; /* vbf internal variable used during bit test. */
138  uint32_t div_shift; /* vbf internal variable used during bit test. */
139 
140  void *table; /* This is the handler of hash table or vBF array. */
141 
142 
143  /* Second cache line should start here. */
144  uint32_t socket_id; /* NUMA Socket ID for memory. */
145  char name[RTE_MEMBER_NAMESIZE]; /* Name of this set summary. */
147 
158  const char *name;
171 
191  uint8_t is_cache;
192 
209  uint32_t num_keys;
210 
215  uint32_t key_len;
216 
226  uint32_t num_set;
227 
248 
257  uint32_t prim_hash_seed;
258 
262  uint32_t sec_hash_seed;
263 
264  int socket_id;
265 };
266 
280 struct rte_member_setsum *
281 rte_member_find_existing(const char *name);
282 
295 struct rte_member_setsum *
296 rte_member_create(const struct rte_member_parameters *params);
297 
314 int
315 rte_member_lookup(const struct rte_member_setsum *setsum, const void *key,
316  member_set_t *set_id);
317 
338 int
339 rte_member_lookup_bulk(const struct rte_member_setsum *setsum,
340  const void **keys, uint32_t num_keys,
341  member_set_t *set_ids);
342 
367 int
368 rte_member_lookup_multi(const struct rte_member_setsum *setsum,
369  const void *key, uint32_t max_match_per_key,
370  member_set_t *set_id);
371 
398 int
399 rte_member_lookup_multi_bulk(const struct rte_member_setsum *setsum,
400  const void **keys, uint32_t num_keys,
401  uint32_t max_match_per_key,
402  uint32_t *match_count,
403  member_set_t *set_ids);
404 
434 int
435 rte_member_add(const struct rte_member_setsum *setsum, const void *key,
436  member_set_t set_id);
437 
447 void
448 rte_member_free(struct rte_member_setsum *setsum);
449 
460 void
461 rte_member_reset(const struct rte_member_setsum *setsum);
462 
481 int
482 rte_member_delete(const struct rte_member_setsum *setsum, const void *key,
483  member_set_t set_id);
484 
485 #ifdef __cplusplus
486 }
487 #endif
488 
489 #endif /* _RTE_MEMBER_H_ */
const char * name
Definition: rte_member.h:158
#define RTE_MEMBER_NAMESIZE
Definition: rte_member.h:67
int rte_member_delete(const struct rte_member_setsum *setsum, const void *key, member_set_t set_id)
int rte_member_add(const struct rte_member_setsum *setsum, const void *key, member_set_t set_id)
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)
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)
uint16_t member_set_t
Definition: rte_member.h:57
void rte_member_free(struct rte_member_setsum *setsum)
#define __rte_cache_aligned
Definition: rte_common.h:402
int rte_member_lookup_bulk(const struct rte_member_setsum *setsum, const void **keys, uint32_t num_keys, member_set_t *set_ids)
struct rte_member_setsum * rte_member_find_existing(const char *name)
rte_member_setsum_type
Definition: rte_member.h:104
int rte_member_lookup(const struct rte_member_setsum *setsum, const void *key, member_set_t *set_id)
void rte_member_reset(const struct rte_member_setsum *setsum)
struct rte_member_setsum * rte_member_create(const struct rte_member_parameters *params)