DPDK  2.0.0
Data Structures | Macros | Enumerations | Functions
rte_acl.h File Reference
#include <rte_acl_osdep.h>

Data Structures

struct  rte_acl_field_def
struct  rte_acl_config
struct  rte_acl_field
struct  rte_acl_rule_data
struct  rte_acl_param
struct  rte_acl_ipv4vlan_rule

Macros

#define RTE_ACL_RULE_DEF(name, fld_num)
#define RTE_ACL_NAMESIZE   32
#define RTE_ACL_IPV4VLAN_RULE_SZ   RTE_ACL_RULE_SZ(RTE_ACL_IPV4VLAN_NUM_FIELDS)

Enumerations

enum  rte_acl_classify_alg { , RTE_ACL_CLASSIFY_SCALAR = 1, RTE_ACL_CLASSIFY_SSE = 2, RTE_ACL_CLASSIFY_AVX2 = 3 }
enum  

Functions

struct rte_acl_ctx * rte_acl_create (const struct rte_acl_param *param)
struct rte_acl_ctx * rte_acl_find_existing (const char *name)
void rte_acl_free (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_rules (struct rte_acl_ctx *ctx)
int rte_acl_build (struct rte_acl_ctx *ctx, const struct rte_acl_config *cfg)
void rte_acl_reset (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)
int rte_acl_classify_alg (const struct rte_acl_ctx *ctx, const uint8_t **data, uint32_t *results, uint32_t num, uint32_t categories, enum rte_acl_classify_alg alg)
void rte_acl_dump (const struct rte_acl_ctx *ctx)
void rte_acl_list_dump (void)
int rte_acl_ipv4vlan_add_rules (struct rte_acl_ctx *ctx, const struct rte_acl_ipv4vlan_rule *rules, uint32_t num)
int rte_acl_ipv4vlan_build (struct rte_acl_ctx *ctx, const uint32_t layout[RTE_ACL_IPV4VLAN_NUM], uint32_t num_categories)

Detailed Description

RTE Classifier.

Macro Definition Documentation

#define RTE_ACL_IPV4VLAN_RULE_SZ   RTE_ACL_RULE_SZ(RTE_ACL_IPV4VLAN_NUM_FIELDS)

Macro to define rule size for rte_acl_ipv4vlan_rule.

#define RTE_ACL_NAMESIZE   32

Max number of characters in name.

#define RTE_ACL_RULE_DEF (   name,
  fld_num 
)
Value:
struct name {\
struct rte_acl_rule_data data; \
struct rte_acl_field field[fld_num]; \
}

Defines single ACL rule. data - miscellaneous data for the rule. field[] - value and mask or range for each field.

Enumeration Type Documentation

anonymous enum

Specifies fields layout inside rte_acl_rule for rte_acl_ipv4vlan_rule.

Available implementations of ACL classify.

Enumerator:
RTE_ACL_CLASSIFY_SCALAR 

generic implementation.

RTE_ACL_CLASSIFY_SSE 

requires SSE4.1 support.

RTE_ACL_CLASSIFY_AVX2 

requires AVX2 support.

Function Documentation

int rte_acl_add_rules ( struct rte_acl_ctx *  ctx,
const struct rte_acl_rule *  rules,
uint32_t  num 
)

Add rules to an existing ACL context. This function is not multi-thread safe.

Parameters
ctxACL context to add patterns to.
rulesArray of rules to add to the ACL context. Note that all fields in rte_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.
numNumber 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.
int rte_acl_build ( struct rte_acl_ctx *  ctx,
const struct rte_acl_config cfg 
)

Analyze set of rules and build required internal run-time structures. This function is not multi-thread safe.

Parameters
ctxACL context to build.
cfgPointer to struct rte_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.
int rte_acl_classify ( const struct rte_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 RTE_ACL_RESULTS_MULTIPLIER and can't be bigger than RTE_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
ctxACL context to search with.
dataArray 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).
resultsArray of search results, categories results per each input data buffer.
numNumber of elements in the input data buffers array.
categoriesNumber of maximum possible matches for each input buffer, one possible match per category.
Returns
zero on successful completion. -EINVAL for incorrect arguments.
int rte_acl_classify_alg ( const struct rte_acl_ctx *  ctx,
const uint8_t **  data,
uint32_t *  results,
uint32_t  num,
uint32_t  categories,
enum rte_acl_classify_alg  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 RTE_ACL_RESULTS_MULTIPLIER and can't be bigger than RTE_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
ctxACL context to search with.
dataArray 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).
resultsArray of search results, categories results per each input data buffer.
numNumber of elements in the input data buffers array.
categoriesNumber of maximum possible matches for each input buffer, one possible match per category.
algAlgorithm 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.
struct rte_acl_ctx* rte_acl_create ( const struct rte_acl_param param)
read

Create a new ACL context.

Parameters
paramParameters 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 rte_errno. Possible rte_errno errors include:
  • EINVAL - invalid parameter passed to function
void rte_acl_dump ( const struct rte_acl_ctx *  ctx)

Dump an ACL context structure to the console.

Parameters
ctxACL context to dump.
struct rte_acl_ctx* rte_acl_find_existing ( const char *  name)
read

Find an existing ACL context object and return a pointer to it.

Parameters
nameName of the ACL context as passed to rte_acl_create()
Returns
Pointer to ACL context or NULL if object not found with rte_errno set appropriately. Possible rte_errno values include:
  • ENOENT - value not available for return
void rte_acl_free ( struct rte_acl_ctx *  ctx)

De-allocate all memory used by ACL context.

Parameters
ctxACL context to free
int rte_acl_ipv4vlan_add_rules ( struct rte_acl_ctx *  ctx,
const struct rte_acl_ipv4vlan_rule rules,
uint32_t  num 
)

Add ipv4vlan rules to an existing ACL context. This function is not multi-thread safe.

Parameters
ctxACL context to add patterns to.
rulesArray of rules to add to the ACL context. Note that all fields in rte_acl_ipv4vlan_rule structures are expected to be in host byte order.
numNumber 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.
int rte_acl_ipv4vlan_build ( struct rte_acl_ctx *  ctx,
const uint32_t  layout[RTE_ACL_IPV4VLAN_NUM],
uint32_t  num_categories 
)

Analyze set of ipv4vlan rules and build required internal run-time structures. This function is not multi-thread safe.

Parameters
ctxACL context to build.
layoutLayout of input data to search through.
num_categoriesMaximum number of categories to use in that build.
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.
void rte_acl_list_dump ( void  )

Dump all ACL context structures to the console.

void rte_acl_reset ( struct rte_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
ctxACL context to reset.
void rte_acl_reset_rules ( struct rte_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
ctxACL context to delete rules from.