DPDK 26.03.0-rc1
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_common.h>
15#include <rte_acl_osdep.h>
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20
21#define RTE_ACL_MAX_CATEGORIES 16
22
23#define RTE_ACL_RESULTS_MULTIPLIER (XMM_SIZE / sizeof(uint32_t))
24
25#define RTE_ACL_MAX_LEVELS 64
26#define RTE_ACL_MAX_FIELDS 64
27
28union rte_acl_field_types {
29 uint8_t u8;
30 uint16_t u16;
31 uint32_t u32;
32 uint64_t u64;
33};
34
35enum {
36 RTE_ACL_FIELD_TYPE_MASK = 0,
37 RTE_ACL_FIELD_TYPE_RANGE,
38 RTE_ACL_FIELD_TYPE_BITMASK
39};
40
53 uint8_t type;
54 uint8_t size;
55 uint8_t field_index;
56 uint8_t input_index;
57 uint32_t offset;
58};
59
65 uint32_t num_categories;
66 uint32_t num_fields;
67 struct rte_acl_field_def defs[RTE_ACL_MAX_FIELDS];
69 size_t max_size;
71};
72
77 union rte_acl_field_types value;
79 union rte_acl_field_types mask_range;
86};
87
88enum {
89 RTE_ACL_TYPE_SHIFT = 29,
90 RTE_ACL_MAX_INDEX = RTE_LEN2MASK(RTE_ACL_TYPE_SHIFT, uint32_t),
91 RTE_ACL_MAX_PRIORITY = RTE_ACL_MAX_INDEX,
92 RTE_ACL_MIN_PRIORITY = 1,
93};
94
95#define RTE_ACL_MASKLEN_TO_BITMASK(v, s) \
96((v) == 0 ? (v) : (typeof(v))((uint64_t)-1 << ((s) * CHAR_BIT - (v))))
97
102 uint32_t category_mask;
103 int32_t priority;
104 uint32_t userdata;
105};
106
112#define RTE_ACL_RULE_DEF(name, fld_num) struct name {\
113 struct rte_acl_rule_data data; \
114 struct rte_acl_field field[fld_num]; \
115}
116
117RTE_ACL_RULE_DEF(rte_acl_rule,);
118
119#define RTE_ACL_RULE_SZ(fld_num) \
120 (sizeof(struct rte_acl_rule) + sizeof(struct rte_acl_field) * (fld_num))
121
122
124#define RTE_ACL_NAMESIZE 32
125
130 const char *name;
132 uint32_t rule_size;
133 uint32_t max_rule_num;
134};
135
137struct rte_acl_ctx;
138
144 void *(*zalloc)(char *name, size_t size, size_t align, int32_t socket_id, void *udata);
145
147 void (*free)(void *ptr, void *udata);
148
150 void *udata;
151};
152
176__rte_experimental
177int rte_acl_set_mem_hook(struct rte_acl_ctx *acl, const struct rte_acl_mem_hook *mhook);
178
191__rte_experimental
192int rte_acl_get_mem_hook(const struct rte_acl_ctx *acl, struct rte_acl_mem_hook *mhook);
193
201void
202rte_acl_free(struct rte_acl_ctx *ctx);
203
215struct rte_acl_ctx *
216rte_acl_create(const struct rte_acl_param *param)
218
229struct rte_acl_ctx *
230rte_acl_find_existing(const char *name);
231
251int
252rte_acl_add_rules(struct rte_acl_ctx *ctx, const struct rte_acl_rule *rules,
253 uint32_t num);
254
263void
264rte_acl_reset_rules(struct rte_acl_ctx *ctx);
265
280int
281rte_acl_build(struct rte_acl_ctx *ctx, const struct rte_acl_config *cfg);
282
291void
292rte_acl_reset(struct rte_acl_ctx *ctx);
293
298 RTE_ACL_CLASSIFY_DEFAULT = 0,
306};
307
337extern int
338rte_acl_classify(const struct rte_acl_ctx *ctx,
339 const uint8_t **data,
340 uint32_t *results, uint32_t num,
341 uint32_t categories);
342
377extern int
378rte_acl_classify_alg(const struct rte_acl_ctx *ctx,
379 const uint8_t **data,
380 uint32_t *results, uint32_t num,
381 uint32_t categories,
382 enum rte_acl_classify_alg alg);
383
384/*
385 * Override the default classifier function for a given ACL context.
386 * @param ctx
387 * ACL context to change classify function for.
388 * @param alg
389 * New default classify algorithm for given ACL context.
390 * It is the caller responsibility to ensure that the value refers to the
391 * existing algorithm, and that it could be run on the given CPU.
392 * The max SIMD bitwidth value in EAL must also allow for the chosen algorithm.
393 * @return
394 * - -EINVAL if the parameters are invalid.
395 * - -ENOTSUP requested algorithm is not supported by given platform.
396 * - Zero if operation completed successfully.
397 */
398extern int
399rte_acl_set_ctx_classify(struct rte_acl_ctx *ctx,
400 enum rte_acl_classify_alg alg);
401
408void
409rte_acl_dump(const struct rte_acl_ctx *ctx);
410
414void
416
417#ifdef __cplusplus
418}
419#endif
420
421#endif /* _RTE_ACL_H_ */
void rte_acl_list_dump(void)
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:297
@ RTE_ACL_CLASSIFY_NEON
Definition: rte_acl.h:302
@ RTE_ACL_CLASSIFY_AVX2
Definition: rte_acl.h:301
@ RTE_ACL_CLASSIFY_SSE
Definition: rte_acl.h:300
@ RTE_ACL_CLASSIFY_SCALAR
Definition: rte_acl.h:299
@ RTE_ACL_CLASSIFY_AVX512X32
Definition: rte_acl.h:305
@ RTE_ACL_CLASSIFY_AVX512X16
Definition: rte_acl.h:304
@ RTE_ACL_CLASSIFY_ALTIVEC
Definition: rte_acl.h:303
__rte_experimental int rte_acl_get_mem_hook(const struct rte_acl_ctx *acl, struct rte_acl_mem_hook *mhook)
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 struct rte_acl_ctx * rte_acl_find_existing(const char *name)
__rte_experimental int rte_acl_set_mem_hook(struct rte_acl_ctx *acl, const struct rte_acl_mem_hook *mhook)
struct rte_acl_ctx * rte_acl_create(const struct rte_acl_param *param) __rte_malloc __rte_dealloc(rte_acl_free
#define RTE_ACL_RULE_DEF(name, fld_num)
Definition: rte_acl.h:112
int rte_acl_build(struct rte_acl_ctx *ctx, const struct rte_acl_config *cfg)
#define __rte_dealloc(dealloc, argno)
Definition: rte_common.h:339
#define RTE_LEN2MASK(ln, tp)
Definition: rte_common.h:927
#define __rte_malloc
Definition: rte_common.h:328
uint32_t num_fields
Definition: rte_acl.h:66
uint32_t num_categories
Definition: rte_acl.h:65
struct rte_acl_field_def defs[RTE_ACL_MAX_FIELDS]
Definition: rte_acl.h:67
size_t max_size
Definition: rte_acl.h:69
uint8_t type
Definition: rte_acl.h:53
uint32_t offset
Definition: rte_acl.h:57
uint8_t input_index
Definition: rte_acl.h:56
uint8_t field_index
Definition: rte_acl.h:55
uint8_t size
Definition: rte_acl.h:54
union rte_acl_field_types mask_range
Definition: rte_acl.h:79
union rte_acl_field_types value
Definition: rte_acl.h:77
void * udata
Definition: rte_acl.h:150
void(* free)(void *ptr, void *udata)
Definition: rte_acl.h:147
int socket_id
Definition: rte_acl.h:131
const char * name
Definition: rte_acl.h:130
uint32_t max_rule_num
Definition: rte_acl.h:133
uint32_t rule_size
Definition: rte_acl.h:132
int32_t priority
Definition: rte_acl.h:103
uint32_t userdata
Definition: rte_acl.h:104
uint32_t category_mask
Definition: rte_acl.h:102