DPDK  make-f/builddir/build/BUILD/dpdk-17.02/mk/rte.sdkconfig.mkshowversion
rte_efd.h
Go to the documentation of this file.
1 /*-
2  * BSD LICENSE
3  *
4  * Copyright(c) 2016-2017 Intel Corporation. All rights reserved.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in
15  * the documentation and/or other materials provided with the
16  * distribution.
17  * * Neither the name of Intel Corporation nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 #ifndef _RTE_EFD_H_
35 #define _RTE_EFD_H_
36 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
47 /*************************************************************************
48  * User selectable constants
49  *************************************************************************/
50 
51 /*
52  * If possible, best lookup performance will be achieved by ensuring that
53  * the entire table fits in the L3 cache.
54  *
55  * Some formulas for calculating various sizes are listed below:
56  *
57  * # of chunks =
58  * 2 ^ (ceiling(log2((requested # of rules) /
59  * (EFD_CHUNK_NUM_GROUPS * EFD_TARGET_GROUP_NUM_RULES))))
60  *
61  * Target # of rules = (# of chunks) * EFD_CHUNK_NUM_GROUPS *
62  * EFD_TARGET_GROUP_NUM_RULES
63  *
64  * Group Size (in bytes) = 4 (per value bit)
65  *
66  * Table size (in bytes) = RTE_EFD_VALUE_NUM_BITS * (# of chunks) *
67  * EFD_CHUNK_NUM_GROUPS * (group size)
68  */
69 
91 #ifndef RTE_EFD_VALUE_NUM_BITS
92 #define RTE_EFD_VALUE_NUM_BITS (8)
93 #endif
94 
95 /*
96  * EFD_TARGET_GROUP_NUM_RULES:
97  * Adjusts how many groups/chunks are allocated at table creation time
98  * to support the requested number of rules. Higher values pack entries
99  * more tightly in memory, resulting in a smaller memory footprint
100  * for the online table.
101  * This comes at the cost of lower insert/update performance.
102  *
103  * EFD_MAX_GROUP_NUM_RULES:
104  * This adjusts the amount of offline memory allocated to store key/value
105  * pairs for the table. The recommended numbers are upper-bounds for
106  * this parameter
107  * - any higher and it becomes very unlikely that a perfect hash function
108  * can be found for that group size. This value should be at
109  * least 40% larger than EFD_TARGET_GROUP_NUM_RULES
110  *
111  * Recommended values for various lookuptable and hashfunc sizes are:
112  *
113  * HASH_FUNC_SIZE = 16, LOOKUPTBL_SIZE = 16:
114  * EFD_TARGET_GROUP_NUM_RULES = 22
115  * EFD_MAX_GROUP_NUM_RULES = 28
116  */
117 #define EFD_TARGET_GROUP_NUM_RULES (22)
118 #define EFD_MAX_GROUP_NUM_RULES (28LU)
119 
120 #define EFD_MIN_BALANCED_NUM_RULES 5
121 
125 #ifndef RTE_EFD_BURST_MAX
126 #define RTE_EFD_BURST_MAX (32)
127 #endif
128 
130 #define RTE_EFD_NAMESIZE 32
131 
132 #if (RTE_EFD_VALUE_NUM_BITS > 0 && RTE_EFD_VALUE_NUM_BITS <= 8)
133 typedef uint8_t efd_value_t;
134 #elif (RTE_EFD_VALUE_NUM_BITS > 8 && RTE_EFD_VALUE_NUM_BITS <= 16)
135 typedef uint16_t efd_value_t;
136 #elif (RTE_EFD_VALUE_NUM_BITS > 16 && RTE_EFD_VALUE_NUM_BITS <= 32)
137 typedef uint32_t efd_value_t;
138 #else
139 #error("RTE_EFD_VALUE_NUM_BITS must be in the range [1:32]")
140 #endif
141 
142 #define EFD_LOOKUPTBL_SHIFT (32 - 4)
143 typedef uint16_t efd_lookuptbl_t;
144 typedef uint16_t efd_hashfunc_t;
145 
167 struct rte_efd_table *
168 rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len,
169  uint8_t online_cpu_socket_bitmask, uint8_t offline_cpu_socket);
170 
177 void
178 rte_efd_free(struct rte_efd_table *table);
179 
190 struct rte_efd_table*
191 rte_efd_find_existing(const char *name);
192 
193 #define RTE_EFD_UPDATE_WARN_GROUP_FULL (1)
194 #define RTE_EFD_UPDATE_NO_CHANGE (2)
195 #define RTE_EFD_UPDATE_FAILED (3)
196 
226 int
227 rte_efd_update(struct rte_efd_table *table, unsigned int socket_id,
228  const void *key, efd_value_t value);
229 
248 int
249 rte_efd_delete(struct rte_efd_table *table, unsigned int socket_id,
250  const void *key, efd_value_t *prev_value);
251 
272 efd_value_t
273 rte_efd_lookup(const struct rte_efd_table *table, unsigned int socket_id,
274  const void *key);
275 
297 void
298 rte_efd_lookup_bulk(const struct rte_efd_table *table, unsigned int socket_id,
299  int num_keys, const void **key_list,
300  efd_value_t *value_list);
301 
302 #ifdef __cplusplus
303 }
304 #endif
305 
306 #endif /* _RTE_EFD_H_ */
void rte_efd_lookup_bulk(const struct rte_efd_table *table, unsigned int socket_id, int num_keys, const void **key_list, efd_value_t *value_list)
struct rte_efd_table * rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len, uint8_t online_cpu_socket_bitmask, uint8_t offline_cpu_socket)
int rte_efd_update(struct rte_efd_table *table, unsigned int socket_id, const void *key, efd_value_t value)
efd_value_t rte_efd_lookup(const struct rte_efd_table *table, unsigned int socket_id, const void *key)
struct rte_efd_table * rte_efd_find_existing(const char *name)
void rte_efd_free(struct rte_efd_table *table)
int rte_efd_delete(struct rte_efd_table *table, unsigned int socket_id, const void *key, efd_value_t *prev_value)