X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_acl%2Frte_acl.h;h=b53179a839b7b585711aaab441f6b5e65b55d0c6;hb=b264a1ab0627614a17005cde39152b749d0a01c3;hp=afc0f69090ef6a4009c00dffc596e93a115d2c8b;hpb=dc276b5780c29a86c537774b6f7b91379ee0690d;p=dpdk.git diff --git a/lib/librte_acl/rte_acl.h b/lib/librte_acl/rte_acl.h index afc0f69090..b53179a839 100644 --- a/lib/librte_acl/rte_acl.h +++ b/lib/librte_acl/rte_acl.h @@ -67,7 +67,7 @@ enum { }; /** - * ACL Field defintion. + * ACL Field definition. * Each field in the ACL rule has an associate definition. * It defines the type of field, its size, its offset in the input buffer, * the field index, and the input index. @@ -94,6 +94,8 @@ struct rte_acl_config { uint32_t num_fields; /**< Number of field definitions. */ struct rte_acl_field_def defs[RTE_ACL_MAX_FIELDS]; /**< array of field definitions. */ + size_t max_size; + /**< max memory limit for internal run-time structures. */ }; /** @@ -113,12 +115,13 @@ struct rte_acl_field { enum { RTE_ACL_TYPE_SHIFT = 29, - RTE_ACL_MAX_INDEX = LEN2MASK(RTE_ACL_TYPE_SHIFT), + RTE_ACL_MAX_INDEX = RTE_LEN2MASK(RTE_ACL_TYPE_SHIFT, uint32_t), RTE_ACL_MAX_PRIORITY = RTE_ACL_MAX_INDEX, RTE_ACL_MIN_PRIORITY = 0, }; -#define RTE_ACL_INVALID_USERDATA 0 +#define RTE_ACL_MASKLEN_TO_BITMASK(v, s) \ +((v) == 0 ? (v) : (typeof(v))((uint64_t)-1 << ((s) * CHAR_BIT - (v)))) /** * Miscellaneous data for ACL rule. @@ -139,7 +142,7 @@ struct rte_acl_rule_data { struct rte_acl_field field[fld_num]; \ } -RTE_ACL_RULE_DEF(rte_acl_rule, 0); +RTE_ACL_RULE_DEF(rte_acl_rule,); #define RTE_ACL_RULE_SZ(fld_num) \ (sizeof(struct rte_acl_rule) + sizeof(struct rte_acl_field) * (fld_num)) @@ -168,7 +171,6 @@ struct rte_acl_param { * 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: - * - E_RTE_NO_TAILQ - no tailq list could be got for the ACL context list * - EINVAL - invalid parameter passed to function */ struct rte_acl_ctx * @@ -259,7 +261,20 @@ void rte_acl_reset(struct rte_acl_ctx *ctx); /** - * Search for a matching ACL rule for each input data buffer. + * Available implementations of ACL classify. + */ +enum rte_acl_classify_alg { + RTE_ACL_CLASSIFY_DEFAULT = 0, + RTE_ACL_CLASSIFY_SCALAR = 1, /**< generic implementation. */ + RTE_ACL_CLASSIFY_SSE = 2, /**< requires SSE4.1 support. */ + RTE_ACL_CLASSIFY_AVX2 = 3, /**< requires AVX2 support. */ + RTE_ACL_CLASSIFY_NEON = 4, /**< requires NEON support. */ + RTE_ACL_CLASSIFY_ALTIVEC = 5, /**< requires ALTIVEC support. */ + RTE_ACL_CLASSIFY_NUM /* should always be the last one. */ +}; + +/** + * 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. @@ -267,7 +282,7 @@ rte_acl_reset(struct rte_acl_ctx *ctx); * 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 responsibility to ensure that input parameters + * Note, that it is a caller's responsibility to ensure that input parameters * are valid and point to correct memory locations. * * @param ctx @@ -287,15 +302,15 @@ rte_acl_reset(struct rte_acl_ctx *ctx); * zero on successful completion. * -EINVAL for incorrect arguments. */ -int -rte_acl_classify(const struct rte_acl_ctx *ctx, const uint8_t **data, - uint32_t *results, uint32_t num, uint32_t categories); +extern int +rte_acl_classify(const struct rte_acl_ctx *ctx, + const uint8_t **data, + uint32_t *results, uint32_t num, + uint32_t categories); /** - * Perform scalar search for a matching ACL rule for each input data buffer. - * Note, that while the search itself will avoid explicit use of SSE/AVX - * intrinsics, code for comparing matching results/priorities sill might use - * vector intrinsics (for categories > 1). + * 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. @@ -319,13 +334,36 @@ rte_acl_classify(const struct rte_acl_ctx *ctx, const uint8_t **data, * @param categories * Number of maximum possible matches for each input buffer, one possible * match per category. + * @param 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. * @return * zero on successful completion. * -EINVAL for incorrect arguments. */ -int -rte_acl_classify_scalar(const struct rte_acl_ctx *ctx, const uint8_t **data, - uint32_t *results, uint32_t num, uint32_t categories); +extern 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); + +/* + * Override the default classifier function for a given ACL context. + * @param ctx + * ACL context to change classify function for. + * @param alg + * New default classify algorithm for given ACL context. + * 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. + * @return + * - -EINVAL if the parameters are invalid. + * - Zero if operation completed successfully. + */ +extern int +rte_acl_set_ctx_classify(struct rte_acl_ctx *ctx, + enum rte_acl_classify_alg alg); /** * Dump an ACL context structure to the console. @@ -342,110 +380,6 @@ rte_acl_dump(const struct rte_acl_ctx *ctx); void rte_acl_list_dump(void); -/** - * Legacy support for 7-tuple IPv4 and VLAN rule. - * This structure and corresponding API is deprecated. - */ -struct rte_acl_ipv4vlan_rule { - struct rte_acl_rule_data data; /**< Miscellaneous data for the rule. */ - uint8_t proto; /**< IPv4 protocol ID. */ - uint8_t proto_mask; /**< IPv4 protocol ID mask. */ - uint16_t vlan; /**< VLAN ID. */ - uint16_t vlan_mask; /**< VLAN ID mask. */ - uint16_t domain; /**< VLAN domain. */ - uint16_t domain_mask; /**< VLAN domain mask. */ - uint32_t src_addr; /**< IPv4 source address. */ - uint32_t src_mask_len; /**< IPv4 source address mask. */ - uint32_t dst_addr; /**< IPv4 destination address. */ - uint32_t dst_mask_len; /**< IPv4 destination address mask. */ - uint16_t src_port_low; /**< L4 source port low. */ - uint16_t src_port_high; /**< L4 source port high. */ - uint16_t dst_port_low; /**< L4 destination port low. */ - uint16_t dst_port_high; /**< L4 destination port high. */ -}; - -/** - * Specifies fields layout inside rte_acl_rule for rte_acl_ipv4vlan_rule. - */ -enum { - RTE_ACL_IPV4VLAN_PROTO_FIELD, - RTE_ACL_IPV4VLAN_VLAN1_FIELD, - RTE_ACL_IPV4VLAN_VLAN2_FIELD, - RTE_ACL_IPV4VLAN_SRC_FIELD, - RTE_ACL_IPV4VLAN_DST_FIELD, - RTE_ACL_IPV4VLAN_SRCP_FIELD, - RTE_ACL_IPV4VLAN_DSTP_FIELD, - RTE_ACL_IPV4VLAN_NUM_FIELDS -}; - -/** - * Macro to define rule size for rte_acl_ipv4vlan_rule. - */ -#define RTE_ACL_IPV4VLAN_RULE_SZ \ - RTE_ACL_RULE_SZ(RTE_ACL_IPV4VLAN_NUM_FIELDS) - -/* - * That effectively defines order of IPV4VLAN classifications: - * - PROTO - * - VLAN (TAG and DOMAIN) - * - SRC IP ADDRESS - * - DST IP ADDRESS - * - PORTS (SRC and DST) - */ -enum { - RTE_ACL_IPV4VLAN_PROTO, - RTE_ACL_IPV4VLAN_VLAN, - RTE_ACL_IPV4VLAN_SRC, - RTE_ACL_IPV4VLAN_DST, - RTE_ACL_IPV4VLAN_PORTS, - RTE_ACL_IPV4VLAN_NUM -}; - -/** - * Add ipv4vlan rules to an existing ACL context. - * This function is not multi-thread safe. - * - * @param ctx - * ACL context to add patterns to. - * @param rules - * Array 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. - * @param num - * Number of elements in the input array of rules. - * @return - * - -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_add_rules(struct rte_acl_ctx *ctx, - const struct rte_acl_ipv4vlan_rule *rules, - uint32_t num); - -/** - * Analyze set of ipv4vlan rules and build required internal - * run-time structures. - * This function is not multi-thread safe. - * - * @param ctx - * ACL context to build. - * @param layout - * Layout of input data to search through. - * @param num_categories - * Maximum number of categories to use in that build. - * @return - * - -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_ipv4vlan_build(struct rte_acl_ctx *ctx, - const uint32_t layout[RTE_ACL_IPV4VLAN_NUM], - uint32_t num_categories); - - #ifdef __cplusplus } #endif