diff mbox

[dpdk-dev,2/8] ACL: code cleanup - use global RTE_LEN2MASK macro

Message ID 1433373024-5558-3-git-send-email-konstantin.ananyev@intel.com (mailing list archive)
State Superseded, archived
Headers show

Commit Message

Konstantin Ananyev June 3, 2015, 11:10 p.m. UTC
Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
---
 app/test-acl/main.c            | 3 ++-
 lib/librte_acl/acl_bld.c       | 3 ++-
 lib/librte_acl/rte_acl.c       | 3 ++-
 lib/librte_acl/rte_acl.h       | 2 +-
 lib/librte_acl/rte_acl_osdep.h | 2 --
 5 files changed, 7 insertions(+), 6 deletions(-)
diff mbox

Patch

diff --git a/app/test-acl/main.c b/app/test-acl/main.c
index 524c43a..be3d773 100644
--- a/app/test-acl/main.c
+++ b/app/test-acl/main.c
@@ -739,7 +739,8 @@  add_cb_rules(FILE *f, struct rte_acl_ctx *ctx)
 			return rc;
 		}
 
-		v.data.category_mask = LEN2MASK(RTE_ACL_MAX_CATEGORIES);
+		v.data.category_mask = RTE_LEN2MASK(RTE_ACL_MAX_CATEGORIES,
+			typeof(v.data.category_mask));
 		v.data.priority = RTE_ACL_MAX_PRIORITY - n;
 		v.data.userdata = n;
 
diff --git a/lib/librte_acl/acl_bld.c b/lib/librte_acl/acl_bld.c
index e2db9bf..19a4178 100644
--- a/lib/librte_acl/acl_bld.c
+++ b/lib/librte_acl/acl_bld.c
@@ -1772,7 +1772,8 @@  acl_bld(struct acl_build_context *bcx, struct rte_acl_ctx *ctx,
 	bcx->pool.alignment = ACL_POOL_ALIGN;
 	bcx->pool.min_alloc = ACL_POOL_ALLOC_MIN;
 	bcx->cfg = *cfg;
-	bcx->category_mask = LEN2MASK(bcx->cfg.num_categories);
+	bcx->category_mask = RTE_LEN2MASK(bcx->cfg.num_categories,
+		typeof(bcx->category_mask));
 	bcx->node_max = node_max;
 
 	rc = sigsetjmp(bcx->pool.fail, 0);
diff --git a/lib/librte_acl/rte_acl.c b/lib/librte_acl/rte_acl.c
index b6ddeeb..a54d531 100644
--- a/lib/librte_acl/rte_acl.c
+++ b/lib/librte_acl/rte_acl.c
@@ -271,7 +271,8 @@  acl_add_rules(struct rte_acl_ctx *ctx, const void *rules, uint32_t num)
 static int
 acl_check_rule(const struct rte_acl_rule_data *rd)
 {
-	if ((rd->category_mask & LEN2MASK(RTE_ACL_MAX_CATEGORIES)) == 0 ||
+	if ((RTE_LEN2MASK(RTE_ACL_MAX_CATEGORIES, typeof(rd->category_mask)) &
+			rd->category_mask) == 0 ||
 			rd->priority > RTE_ACL_MAX_PRIORITY ||
 			rd->priority < RTE_ACL_MIN_PRIORITY ||
 			rd->userdata == RTE_ACL_INVALID_USERDATA)
diff --git a/lib/librte_acl/rte_acl.h b/lib/librte_acl/rte_acl.h
index 3a93730..8d9bbe5 100644
--- a/lib/librte_acl/rte_acl.h
+++ b/lib/librte_acl/rte_acl.h
@@ -115,7 +115,7 @@  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,
 };
diff --git a/lib/librte_acl/rte_acl_osdep.h b/lib/librte_acl/rte_acl_osdep.h
index 81fdefb..41f7e3d 100644
--- a/lib/librte_acl/rte_acl_osdep.h
+++ b/lib/librte_acl/rte_acl_osdep.h
@@ -56,8 +56,6 @@ 
  * Common defines.
  */
 
-#define	LEN2MASK(ln)	((uint32_t)(((uint64_t)1 << (ln)) - 1))
-
 #define DIM(x) RTE_DIM(x)
 
 #include <rte_common.h>