DPDK  18.11.11
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 #include <rte_config.h>
56 
58 typedef uint16_t member_set_t;
60 #define RTE_MEMBER_NO_MATCH 0
61 
62 #define RTE_MEMBER_ENTRIES_MAX (1 << 30)
63 
64 #define RTE_MEMBER_LOOKUP_BULK_MAX 64
65 
66 #define RTE_MEMBER_BUCKET_ENTRIES 16
67 
68 #define RTE_MEMBER_NAMESIZE 32
69 
71 #if defined(RTE_ARCH_X86) || defined(RTE_MACHINE_CPUFLAG_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 
79 extern 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 
89 struct rte_member_setsum;
90 
98 
108  RTE_MEMBER_NUM_TYPE
109 };
110 
112 enum rte_member_sig_compare_function {
113  RTE_MEMBER_COMPARE_SCALAR = 0,
114  RTE_MEMBER_COMPARE_AVX2,
115  RTE_MEMBER_COMPARE_NUM
116 };
117 
119 struct 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 
258  uint32_t prim_hash_seed;
259 
263  uint32_t sec_hash_seed;
264 
265  int socket_id;
266 };
267 
281 struct rte_member_setsum *
282 rte_member_find_existing(const char *name);
283 
296 struct rte_member_setsum *
297 rte_member_create(const struct rte_member_parameters *params);
298 
315 int
316 rte_member_lookup(const struct rte_member_setsum *setsum, const void *key,
317  member_set_t *set_id);
318 
339 int
340 rte_member_lookup_bulk(const struct rte_member_setsum *setsum,
341  const void **keys, uint32_t num_keys,
342  member_set_t *set_ids);
343 
368 int
369 rte_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 
399 int
400 rte_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 
435 int
436 rte_member_add(const struct rte_member_setsum *setsum, const void *key,
437  member_set_t set_id);
438 
448 void
449 rte_member_free(struct rte_member_setsum *setsum);
450 
461 void
462 rte_member_reset(const struct rte_member_setsum *setsum);
463 
482 int
483 rte_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_ */
const char * name
Definition: rte_member.h:159
#define RTE_MEMBER_NAMESIZE
Definition: rte_member.h:68
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:58
void rte_member_free(struct rte_member_setsum *setsum)
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:105
#define __rte_cache_aligned
Definition: rte_memory.h:66
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)
enum rte_member_setsum_type type
Definition: rte_member.h:171