#include <cne_acl_osdep.h>
#include <limits.h>
#include <stddef.h>
#include <stdint.h>
#include "cne_common.h"
#include "cne_vect.h"
Go to the source code of this file.
|
struct cne_acl_ctx * | cne_acl_create (const struct cne_acl_param *param) |
|
void | cne_acl_free (struct cne_acl_ctx *ctx) |
|
int | cne_acl_add_rules (struct cne_acl_ctx *ctx, const struct cne_acl_rule *rules, uint32_t num) |
|
void | cne_acl_reset_rules (struct cne_acl_ctx *ctx) |
|
int | cne_acl_build (struct cne_acl_ctx *ctx, const struct cne_acl_config *cfg) |
|
void | cne_acl_reset (struct cne_acl_ctx *ctx) |
|
void | cne_acl_set_algo (struct cne_acl_ctx *ctx, enum cne_acl_classify_alg algo) |
|
int | cne_acl_classify (const struct cne_acl_ctx *ctx, const uint8_t **data, uint32_t *results, uint32_t num, uint32_t categories) |
|
int | cne_acl_classify_alg (const struct cne_acl_ctx *ctx, const uint8_t **data, uint32_t *results, uint32_t num, uint32_t categories, enum cne_acl_classify_alg alg) |
|
void | cne_acl_dump (const struct cne_acl_ctx *ctx) |
|
Classifier code for the ACL library.
Definition in file cne_acl.h.
◆ CNE_ACL_RULE_DEF
#define CNE_ACL_RULE_DEF |
( |
|
name, |
|
|
|
fld_num |
|
) |
| |
Value:Defines single ACL rule. data - miscellaneous data for the rule. field[] - value and mask or range for each field.
Definition at line 115 of file cne_acl.h.
◆ CNE_ACL_NAMESIZE
#define CNE_ACL_NAMESIZE 32 |
Max number of characters in name.
Definition at line 127 of file cne_acl.h.
◆ cne_acl_classify_alg
Available implementations of ACL classify.
Enumerator |
---|
CNE_ACL_CLASSIFY_SCALAR | generic implementation.
|
CNE_ACL_CLASSIFY_SSE | requires SSE4.1 support.
|
CNE_ACL_CLASSIFY_AVX2 | requires AVX2 support.
|
CNE_ACL_CLASSIFY_NEON | requires NEON support.
|
CNE_ACL_CLASSIFY_ALTIVEC | requires ALTIVEC support.
|
CNE_ACL_CLASSIFY_AVX512X16 | requires ALTIVEC support.
|
CNE_ACL_CLASSIFY_AVX512X32 | requires ALTIVEC support.
|
Definition at line 140 of file cne_acl.h.
◆ cne_acl_create()
struct cne_acl_ctx* cne_acl_create |
( |
const struct cne_acl_param * |
param | ) |
|
Create a new ACL context.
- Parameters
-
param | Parameters used to create and initialise the ACL context. |
- Returns
- Pointer to ACL context structure that is used in future ACL operations, or NULL on error, with error code set in errno. Possible errno errors include:
- EINVAL - invalid parameter passed to function
- Examples
- examples/cndpfwd/acl-func.c.
◆ cne_acl_free()
void cne_acl_free |
( |
struct cne_acl_ctx * |
ctx | ) |
|
◆ cne_acl_add_rules()
int cne_acl_add_rules |
( |
struct cne_acl_ctx * |
ctx, |
|
|
const struct cne_acl_rule * |
rules, |
|
|
uint32_t |
num |
|
) |
| |
Add rules to an existing ACL context. This function is not multi-thread safe.
- Parameters
-
ctx | ACL context to add patterns to. |
rules | Array of rules to add to the ACL context. Note that all fields in cne_acl_rule structures are expected to be in host byte order. Each rule expected to be in the same format and not exceed size specified at ACL context creation time. |
num | Number of elements in the input array of rules. |
- Returns
- -ENOMEM if there is no space in the ACL context for these rules.
- -EINVAL if the parameters are invalid.
- Zero if operation completed successfully.
- Examples
- examples/cndpfwd/acl-func.c.
◆ cne_acl_reset_rules()
void cne_acl_reset_rules |
( |
struct cne_acl_ctx * |
ctx | ) |
|
Delete all rules from the ACL context. This function is not multi-thread safe. Note that internal run-time structures are not affected.
- Parameters
-
ctx | ACL context to delete rules from. |
◆ cne_acl_build()
int cne_acl_build |
( |
struct cne_acl_ctx * |
ctx, |
|
|
const struct cne_acl_config * |
cfg |
|
) |
| |
Analyze set of rules and build required internal run-time structures. This function is not multi-thread safe.
- Parameters
-
ctx | ACL context to build. |
cfg | Pointer to struct cne_acl_config - defines build parameters. |
- Returns
- -ENOMEM if couldn't allocate enough memory.
- -EINVAL if the parameters are invalid.
- Negative error code if operation failed.
- Zero if operation completed successfully.
- Examples
- examples/cndpfwd/acl-func.c.
◆ cne_acl_reset()
void cne_acl_reset |
( |
struct cne_acl_ctx * |
ctx | ) |
|
Delete all rules from the ACL context and destroy all internal run-time structures. This function is not multi-thread safe.
- Parameters
-
◆ cne_acl_set_algo()
Set the acl classify algo for the ACL context and This function is not multi-thread safe.
- Parameters
-
ctx | ACL context to reset. |
algo | the type of acl algo |
◆ cne_acl_classify()
int cne_acl_classify |
( |
const struct cne_acl_ctx * |
ctx, |
|
|
const uint8_t ** |
data, |
|
|
uint32_t * |
results, |
|
|
uint32_t |
num, |
|
|
uint32_t |
categories |
|
) |
| |
Perform search for a matching ACL rule for each input data buffer. Each input data buffer can have up to categories matches. That implies that results array should be big enough to hold (categories * num) elements. Also categories parameter should be either one or multiple of CNE_ACL_RESULTS_MULTIPLIER and can't be bigger than CNE_ACL_MAX_CATEGORIES. If more than one rule is applicable for given input buffer and given category, then rule with highest priority will be returned as a match. Note, that it is a caller's responsibility to ensure that input parameters are valid and point to correct memory locations.
- Parameters
-
ctx | ACL context to search with. |
data | Array of pointers to input data buffers to perform search. Note that all fields in input data buffers supposed to be in network byte order (MSB). |
results | Array of search results, categories results per each input data buffer. |
num | Number of elements in the input data buffers array. |
categories | Number of maximum possible matches for each input buffer, one possible match per category. |
- Returns
- zero on successful completion. -EINVAL for incorrect arguments.
- Examples
- examples/cndpfwd/acl-func.c.
◆ cne_acl_classify_alg()
Perform search using specified algorithm for a matching ACL rule for each input data buffer. Each input data buffer can have up to categories matches. That implies that results array should be big enough to hold (categories * num) elements. Also categories parameter should be either one or multiple of CNE_ACL_RESULTS_MULTIPLIER and can't be bigger than CNE_ACL_MAX_CATEGORIES. If more than one rule is applicable for given input buffer and given category, then rule with highest priority will be returned as a match. Note, that it is a caller's responsibility to ensure that input parameters are valid and point to correct memory locations.
- Parameters
-
ctx | ACL context to search with. |
data | Array of pointers to input data buffers to perform search. Note that all fields in input data buffers supposed to be in network byte order (MSB). |
results | Array of search results, categories results per each input data buffer. |
num | Number of elements in the input data buffers array. |
categories | Number of maximum possible matches for each input buffer, one possible match per category. |
alg | Algorithm to be used for the search. It is the caller responsibility to ensure that the value refers to the existing algorithm, and that it could be run on the given CPU. |
- Returns
- zero on successful completion. -EINVAL for incorrect arguments.
◆ cne_acl_dump()
void cne_acl_dump |
( |
const struct cne_acl_ctx * |
ctx | ) |
|
Dump an ACL context structure to the console.
- Parameters
-