From: Konstantin Ananyev Date: Tue, 20 Jan 2015 18:40:58 +0000 (+0000) Subject: acl: deduplicate a bit of RT code X-Git-Tag: spdx-start~9816 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=3858b90d824443e6a77a380f22d0ad13422e93a3;p=dpdk.git acl: deduplicate a bit of RT code Move common check for input parameters up into rte_acl_classify_alg(). Signed-off-by: Konstantin Ananyev Acked-by: Neil Horman --- diff --git a/lib/librte_acl/acl_run_scalar.c b/lib/librte_acl/acl_run_scalar.c index 9935125cec..5be216c660 100644 --- a/lib/librte_acl/acl_run_scalar.c +++ b/lib/librte_acl/acl_run_scalar.c @@ -147,10 +147,6 @@ rte_acl_classify_scalar(const struct rte_acl_ctx *ctx, const uint8_t **data, struct completion cmplt[MAX_SEARCHES_SCALAR]; struct parms parms[MAX_SEARCHES_SCALAR]; - if (categories != 1 && - ((RTE_ACL_RESULTS_MULTIPLIER - 1) & categories) != 0) - return -EINVAL; - acl_set_flow(&flows, cmplt, RTE_DIM(cmplt), data, results, num, categories, ctx->trans_table); diff --git a/lib/librte_acl/acl_run_sse.c b/lib/librte_acl/acl_run_sse.c index 576c92b067..09e32bee6e 100644 --- a/lib/librte_acl/acl_run_sse.c +++ b/lib/librte_acl/acl_run_sse.c @@ -572,10 +572,6 @@ int rte_acl_classify_sse(const struct rte_acl_ctx *ctx, const uint8_t **data, uint32_t *results, uint32_t num, uint32_t categories) { - if (categories != 1 && - ((RTE_ACL_RESULTS_MULTIPLIER - 1) & categories) != 0) - return -EINVAL; - if (likely(num >= MAX_SEARCHES_SSE8)) return search_sse_8(ctx, data, results, num, categories); else if (num >= MAX_SEARCHES_SSE4) diff --git a/lib/librte_acl/rte_acl.c b/lib/librte_acl/rte_acl.c index 547e6daecf..a16c4a4689 100644 --- a/lib/librte_acl/rte_acl.c +++ b/lib/librte_acl/rte_acl.c @@ -75,21 +75,26 @@ rte_acl_init(void) rte_acl_set_default_classify(alg); } -int -rte_acl_classify(const struct rte_acl_ctx *ctx, const uint8_t **data, - uint32_t *results, uint32_t num, uint32_t categories) -{ - return classify_fns[ctx->alg](ctx, data, results, num, 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) { + if (categories != 1 && + ((RTE_ACL_RESULTS_MULTIPLIER - 1) & categories) != 0) + return -EINVAL; + return classify_fns[alg](ctx, data, results, num, categories); } +int +rte_acl_classify(const struct rte_acl_ctx *ctx, const uint8_t **data, + uint32_t *results, uint32_t num, uint32_t categories) +{ + return rte_acl_classify_alg(ctx, data, results, num, categories, + ctx->alg); +} + struct rte_acl_ctx * rte_acl_find_existing(const char *name) {