DPDK patches and discussions
 help / color / mirror / Atom feed
From: Konstantin Ananyev <konstantin.ananyev@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCHv2 2/8] acl: code cleanup - use global EAL macro, instead of creating a local copy
Date: Mon,  8 Jun 2015 11:41:24 +0100	[thread overview]
Message-ID: <1433760090-17110-3-git-send-email-konstantin.ananyev@intel.com> (raw)
In-Reply-To: <1433760090-17110-1-git-send-email-konstantin.ananyev@intel.com>

use global RTE_LEN2MASK macro, instead of LEN2MASK.

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 --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 aee6ed5..ff3ba8b 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>
-- 
2.4.2

  parent reply	other threads:[~2015-06-08 10:43 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-03 23:10 [dpdk-dev] [PATCH 0/8] ACL: various fixes and cleanups Konstantin Ananyev
2015-06-03 23:10 ` [dpdk-dev] [PATCH 1/8] ACL: fix invalid rule wildness calculation for RTE_ACL_FIELD_TYPE_BITMASK Konstantin Ananyev
2015-06-08 10:41   ` [dpdk-dev] [PATCHv2 0/8] acl: various fixes and cleanups Konstantin Ananyev
2015-06-08 10:41     ` [dpdk-dev] [PATCHv2 1/8] acl: fix invalid rule wildness calculation for bitmask field type Konstantin Ananyev
2015-06-08 10:41     ` Konstantin Ananyev [this message]
2015-06-08 10:41     ` [dpdk-dev] [PATCHv2 3/8] acl: add function to check build input parameters Konstantin Ananyev
2015-06-08 10:41     ` [dpdk-dev] [PATCHv2 4/8] acl: fix avoid unneeded trie splitting for subset of rules Konstantin Ananyev
2015-06-08 10:41     ` [dpdk-dev] [PATCHv2 5/8] acl: code dedup - introduce a new macro Konstantin Ananyev
2015-06-08 10:41     ` [dpdk-dev] [PATCHv2 6/8] acl: cleanup remove unused code from acl_bld.c Konstantin Ananyev
2015-06-08 10:41     ` [dpdk-dev] [PATCHv2 7/8] acl: fix ambiguity between ACL rules in UT Konstantin Ananyev
2015-06-08 10:41     ` [dpdk-dev] [PATCHv2 8/8] acl: add new test-cases into UT Konstantin Ananyev
2015-06-18 16:14     ` [dpdk-dev] [PATCHv2 0/8] acl: various fixes and cleanups Thomas Monjalon
2015-06-03 23:10 ` [dpdk-dev] [PATCH 2/8] ACL: code cleanup - use global RTE_LEN2MASK macro Konstantin Ananyev
2015-06-03 23:10 ` [dpdk-dev] [PATCH 3/8] ACL: add function to check rte_acl_build() input parameters Konstantin Ananyev
2015-06-03 23:10 ` [dpdk-dev] [PATCH 4/8] ACL: fix rebuilding a trie for subset of rules Konstantin Ananyev
2015-06-03 23:10 ` [dpdk-dev] [PATCH 5/8] ACL: introduce RTE_ACL_MASKLEN_TO_BITMASK macro Konstantin Ananyev
2015-06-03 23:10 ` [dpdk-dev] [PATCH 6/8] ACL: cleanup remove unused code from acl_bld.c Konstantin Ananyev
2015-06-03 23:10 ` [dpdk-dev] [PATCH 7/8] ACL: fix remove ambiguity between rules at UT Konstantin Ananyev
2015-06-03 23:10 ` [dpdk-dev] [PATCH 8/8] ACL: add new test-cases into UT Konstantin Ananyev
2015-06-04  9:27 ` [dpdk-dev] [PATCH 0/8] ACL: various fixes and cleanups Thomas Monjalon
2015-06-04 10:20   ` Ananyev, Konstantin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1433760090-17110-3-git-send-email-konstantin.ananyev@intel.com \
    --to=konstantin.ananyev@intel.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).