DPDK 21.11.9
rte_acl.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation
3 */
4
5#ifndef _RTE_ACL_H_
6#define _RTE_ACL_H_
7
14#include <rte_acl_osdep.h>
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
20#define RTE_ACL_MAX_CATEGORIES 16
21
22#define RTE_ACL_RESULTS_MULTIPLIER (XMM_SIZE / sizeof(uint32_t))
23
24#define RTE_ACL_MAX_LEVELS 64
25#define RTE_ACL_MAX_FIELDS 64
26
27union rte_acl_field_types {
28 uint8_t u8;
29 uint16_t u16;
30 uint32_t u32;
31 uint64_t u64;
32};
33
34enum {
35 RTE_ACL_FIELD_TYPE_MASK = 0,
36 RTE_ACL_FIELD_TYPE_RANGE,
37 RTE_ACL_FIELD_TYPE_BITMASK
38};
39
52 uint8_t type;
53 uint8_t size;
54 uint8_t field_index;
55 uint8_t input_index;
56 uint32_t offset;
57};
58
64 uint32_t num_categories;
65 uint32_t num_fields;
66 struct rte_acl_field_def defs[RTE_ACL_MAX_FIELDS];
68 size_t max_size;
70};
71
76 union rte_acl_field_types value;
78 union rte_acl_field_types mask_range;
85};
86
87enum {
88 RTE_ACL_TYPE_SHIFT = 29,
89 RTE_ACL_MAX_INDEX = RTE_LEN2MASK(RTE_ACL_TYPE_SHIFT, uint32_t),
90 RTE_ACL_MAX_PRIORITY = RTE_ACL_MAX_INDEX,
91 RTE_ACL_MIN_PRIORITY = 1,
92};
93
94#define RTE_ACL_MASKLEN_TO_BITMASK(v, s) \
95((v) == 0 ? (v) : (typeof(v))((uint64_t)-1 << ((s) * CHAR_BIT - (v))))
96
101 uint32_t category_mask;
102 int32_t priority;
103 uint32_t userdata;
104};
105
111#define RTE_ACL_RULE_DEF(name, fld_num) struct name {\
112 struct rte_acl_rule_data data; \
113 struct rte_acl_field field[fld_num]; \
114}
115
116RTE_ACL_RULE_DEF(rte_acl_rule,);
117
118#define RTE_ACL_RULE_SZ(fld_num) \
119 (sizeof(struct rte_acl_rule) + sizeof(struct rte_acl_field) * (fld_num))
120
121
123#define RTE_ACL_NAMESIZE 32
124
129 const char *name;
131 uint32_t rule_size;
132 uint32_t max_rule_num;
133};
134
135
147struct rte_acl_ctx *
148rte_acl_create(const struct rte_acl_param *param);
149
160struct rte_acl_ctx *
161rte_acl_find_existing(const char *name);
162
169void
170rte_acl_free(struct rte_acl_ctx *ctx);
171
191int
192rte_acl_add_rules(struct rte_acl_ctx *ctx, const struct rte_acl_rule *rules,
193 uint32_t num);
194
203void
204rte_acl_reset_rules(struct rte_acl_ctx *ctx);
205
220int
221rte_acl_build(struct rte_acl_ctx *ctx, const struct rte_acl_config *cfg);
222
231void
232rte_acl_reset(struct rte_acl_ctx *ctx);
233
238 RTE_ACL_CLASSIFY_DEFAULT = 0,
246};
247
277extern int
278rte_acl_classify(const struct rte_acl_ctx *ctx,
279 const uint8_t **data,
280 uint32_t *results, uint32_t num,
281 uint32_t categories);
282
317extern int
318rte_acl_classify_alg(const struct rte_acl_ctx *ctx,
319 const uint8_t **data,
320 uint32_t *results, uint32_t num,
321 uint32_t categories,
322 enum rte_acl_classify_alg alg);
323
324/*
325 * Override the default classifier function for a given ACL context.
326 * @param ctx
327 * ACL context to change classify function for.
328 * @param alg
329 * New default classify algorithm for given ACL context.
330 * It is the caller responsibility to ensure that the value refers to the
331 * existing algorithm, and that it could be run on the given CPU.
332 * The max SIMD bitwidth value in EAL must also allow for the chosen algorithm.
333 * @return
334 * - -EINVAL if the parameters are invalid.
335 * - -ENOTSUP requested algorithm is not supported by given platform.
336 * - Zero if operation completed successfully.
337 */
338extern int
339rte_acl_set_ctx_classify(struct rte_acl_ctx *ctx,
340 enum rte_acl_classify_alg alg);
341
348void
349rte_acl_dump(const struct rte_acl_ctx *ctx);
350
354void
356
357#ifdef __cplusplus
358}
359#endif
360
361#endif /* _RTE_ACL_H_ */
void rte_acl_list_dump(void)
struct rte_acl_ctx * rte_acl_find_existing(const char *name)
void rte_acl_dump(const struct rte_acl_ctx *ctx)
int rte_acl_add_rules(struct rte_acl_ctx *ctx, const struct rte_acl_rule *rules, uint32_t num)
void rte_acl_reset(struct rte_acl_ctx *ctx)
void rte_acl_reset_rules(struct rte_acl_ctx *ctx)
rte_acl_classify_alg
Definition: rte_acl.h:237
@ RTE_ACL_CLASSIFY_NEON
Definition: rte_acl.h:242
@ RTE_ACL_CLASSIFY_AVX2
Definition: rte_acl.h:241
@ RTE_ACL_CLASSIFY_SSE
Definition: rte_acl.h:240
@ RTE_ACL_CLASSIFY_SCALAR
Definition: rte_acl.h:239
@ RTE_ACL_CLASSIFY_AVX512X32
Definition: rte_acl.h:245
@ RTE_ACL_CLASSIFY_AVX512X16
Definition: rte_acl.h:244
@ RTE_ACL_CLASSIFY_ALTIVEC
Definition: rte_acl.h:243
void rte_acl_free(struct rte_acl_ctx *ctx)
int rte_acl_classify(const struct rte_acl_ctx *ctx, const uint8_t **data, uint32_t *results, uint32_t num, uint32_t categories)
struct rte_acl_ctx * rte_acl_create(const struct rte_acl_param *param)
#define RTE_ACL_RULE_DEF(name, fld_num)
Definition: rte_acl.h:111
int rte_acl_build(struct rte_acl_ctx *ctx, const struct rte_acl_config *cfg)
#define RTE_LEN2MASK(ln, tp)
Definition: rte_common.h:833
uint32_t num_fields
Definition: rte_acl.h:65
uint32_t num_categories
Definition: rte_acl.h:64
struct rte_acl_field_def defs[RTE_ACL_MAX_FIELDS]
Definition: rte_acl.h:66
size_t max_size
Definition: rte_acl.h:68
uint8_t type
Definition: rte_acl.h:52
uint32_t offset
Definition: rte_acl.h:56
uint8_t input_index
Definition: rte_acl.h:55
uint8_t field_index
Definition: rte_acl.h:54
uint8_t size
Definition: rte_acl.h:53
union rte_acl_field_types mask_range
Definition: rte_acl.h:78
union rte_acl_field_types value
Definition: rte_acl.h:76
int socket_id
Definition: rte_acl.h:130
const char * name
Definition: rte_acl.h:129
uint32_t max_rule_num
Definition: rte_acl.h:132
uint32_t rule_size
Definition: rte_acl.h:131
int32_t priority
Definition: rte_acl.h:102
uint32_t userdata
Definition: rte_acl.h:103
uint32_t category_mask
Definition: rte_acl.h:101