DPDK patches and discussions
 help / color / mirror / Atom feed
From: Konstantin Ananyev <konstantin.ananyev@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 6/8] ACL: cleanup remove unused code from acl_bld.c
Date: Thu,  4 Jun 2015 00:10:22 +0100	[thread overview]
Message-ID: <1433373024-5558-7-git-send-email-konstantin.ananyev@intel.com> (raw)
In-Reply-To: <1433373024-5558-1-git-send-email-konstantin.ananyev@intel.com>

Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
---
 lib/librte_acl/acl_bld.c | 310 -----------------------------------------------
 1 file changed, 310 deletions(-)

diff --git a/lib/librte_acl/acl_bld.c b/lib/librte_acl/acl_bld.c
index e144503..83669ac 100644
--- a/lib/librte_acl/acl_bld.c
+++ b/lib/librte_acl/acl_bld.c
@@ -120,10 +120,6 @@ static int acl_merge_trie(struct acl_build_context *context,
 	struct rte_acl_node *node_a, struct rte_acl_node *node_b,
 	uint32_t level, struct rte_acl_node **node_c);
 
-static int acl_merge(struct acl_build_context *context,
-	struct rte_acl_node *node_a, struct rte_acl_node *node_b,
-	int move, int a_subset, int level);
-
 static void
 acl_deref_ptr(struct acl_build_context *context,
 	struct rte_acl_node *node, int index);
@@ -415,58 +411,6 @@ acl_intersect_type(const struct rte_acl_bitset *a_bits,
 }
 
 /*
- * Check if all bits in the bitset are on
- */
-static int
-acl_full(struct rte_acl_node *node)
-{
-	uint32_t n;
-	bits_t all_bits = -1;
-
-	for (n = 0; n < RTE_ACL_BIT_SET_SIZE; n++)
-		all_bits &= node->values.bits[n];
-	return all_bits == -1;
-}
-
-/*
- * Check if all bits in the bitset are off
- */
-static int
-acl_empty(struct rte_acl_node *node)
-{
-	uint32_t n;
-
-	if (node->ref_count == 0) {
-		for (n = 0; n < RTE_ACL_BIT_SET_SIZE; n++) {
-			if (0 != node->values.bits[n])
-				return 0;
-		}
-		return 1;
-	} else {
-		return 0;
-	}
-}
-
-/*
- * Compute intersection of A and B
- * return 1 if there is an intersection else 0.
- */
-static int
-acl_intersect(struct rte_acl_bitset *a_bits,
-	struct rte_acl_bitset *b_bits,
-	struct rte_acl_bitset *intersect)
-{
-	uint32_t n;
-	bits_t all_bits = 0;
-
-	for (n = 0; n < RTE_ACL_BIT_SET_SIZE; n++) {
-		intersect->bits[n] = a_bits->bits[n] & b_bits->bits[n];
-		all_bits |= intersect->bits[n];
-	}
-	return all_bits != 0;
-}
-
-/*
  * Duplicate a node
  */
 static struct rte_acl_node *
@@ -534,63 +478,6 @@ acl_deref_ptr(struct acl_build_context *context,
 }
 
 /*
- * Exclude bitset from a node pointer
- * returns  0 if poiter was deref'd
- *          1 otherwise.
- */
-static int
-acl_exclude_ptr(struct acl_build_context *context,
-	struct rte_acl_node *node,
-	int index,
-	struct rte_acl_bitset *b_bits)
-{
-	int retval = 1;
-
-	/*
-	 * remove bitset from node pointer and deref
-	 * if the bitset becomes empty.
-	 */
-	if (!acl_exclude(&node->ptrs[index].values,
-			&node->ptrs[index].values,
-			b_bits)) {
-		acl_deref_ptr(context, node, index);
-		node->ptrs[index].ptr = NULL;
-		retval = 0;
-	}
-
-	/* exclude bits from the composite bits for the node */
-	acl_exclude(&node->values, &node->values, b_bits);
-	return retval;
-}
-
-/*
- * Remove a bitset from src ptr and move remaining ptr to dst
- */
-static int
-acl_move_ptr(struct acl_build_context *context,
-	struct rte_acl_node *dst,
-	struct rte_acl_node *src,
-	int index,
-	struct rte_acl_bitset *b_bits)
-{
-	int rc;
-
-	if (b_bits != NULL)
-		if (!acl_exclude_ptr(context, src, index, b_bits))
-			return 0;
-
-	/* add src pointer to dst node */
-	rc = acl_add_ptr(context, dst, src->ptrs[index].ptr,
-			&src->ptrs[index].values);
-	if (rc < 0)
-		return rc;
-
-	/* remove ptr from src */
-	acl_exclude_ptr(context, src, index, &src->ptrs[index].values);
-	return 1;
-}
-
-/*
  * acl_exclude rte_acl_bitset from src and copy remaining pointer to dst
  */
 static int
@@ -650,203 +537,6 @@ acl_compact_node_ptrs(struct rte_acl_node *node_a)
 	}
 }
 
-/*
- * acl_merge helper routine.
- */
-static int
-acl_merge_intersect(struct acl_build_context *context,
-	struct rte_acl_node *node_a, uint32_t idx_a,
-	struct rte_acl_node *node_b, uint32_t idx_b,
-	int next_move, int level,
-	struct rte_acl_bitset *intersect_ptr)
-{
-	struct rte_acl_node *node_c;
-
-	/* Duplicate A for intersection */
-	node_c = acl_dup_node(context, node_a->ptrs[idx_a].ptr);
-
-	/* Remove intersection from A */
-	acl_exclude_ptr(context, node_a, idx_a, intersect_ptr);
-
-	/*
-	 * Added link from A to C for all transitions
-	 * in the intersection
-	 */
-	if (acl_add_ptr(context, node_a, node_c, intersect_ptr) < 0)
-		return -1;
-
-	/* merge B->node into C */
-	return acl_merge(context, node_c, node_b->ptrs[idx_b].ptr, next_move,
-		0, level + 1);
-}
-
-
-/*
- * Merge the children of nodes A and B together.
- *
- * if match node
- *	For each category
- *		node A result = highest priority result
- * if any pointers in A intersect with any in B
- *	For each intersection
- *		C = copy of node that A points to
- *		remove intersection from A pointer
- *		add a pointer to A that points to C for the intersection
- *		Merge C and node that B points to
- * Compact the pointers in A and B
- * if move flag
- *	If B has only one reference
- *		Move B pointers to A
- *	else
- *		Copy B pointers to A
- */
-static int
-acl_merge(struct acl_build_context *context,
-	struct rte_acl_node *node_a, struct rte_acl_node *node_b,
-	int move, int a_subset, int level)
-{
-	uint32_t n, m, ptrs_a, ptrs_b;
-	uint32_t min_add_a, min_add_b;
-	int intersect_type;
-	int node_intersect_type;
-	int b_full, next_move, rc;
-	struct rte_acl_bitset intersect_values;
-	struct rte_acl_bitset intersect_ptr;
-
-	min_add_a = 0;
-	min_add_b = 0;
-	intersect_type = 0;
-	node_intersect_type = 0;
-
-	if (level == 0)
-		a_subset = 1;
-
-	/*
-	 *  Resolve match priorities
-	 */
-	if (node_a->match_flag != 0 || node_b->match_flag != 0) {
-
-		if (node_a->match_flag == 0 || node_b->match_flag == 0)
-			RTE_LOG(ERR, ACL, "Not both matches\n");
-
-		if (node_b->match_flag < node_a->match_flag)
-			RTE_LOG(ERR, ACL, "Not same match\n");
-
-		for (n = 0; n < context->cfg.num_categories; n++) {
-			if (node_a->mrt->priority[n] <
-					node_b->mrt->priority[n]) {
-				node_a->mrt->priority[n] =
-					node_b->mrt->priority[n];
-				node_a->mrt->results[n] =
-					node_b->mrt->results[n];
-			}
-		}
-	}
-
-	/*
-	 * If the two node transitions intersect then merge the transitions.
-	 * Check intersection for entire node (all pointers)
-	 */
-	node_intersect_type = acl_intersect_type(&node_a->values,
-		&node_b->values,
-		&intersect_values);
-
-	if (node_intersect_type & ACL_INTERSECT) {
-
-		b_full = acl_full(node_b);
-
-		min_add_b = node_b->min_add;
-		node_b->min_add = node_b->num_ptrs;
-		ptrs_b = node_b->num_ptrs;
-
-		min_add_a = node_a->min_add;
-		node_a->min_add = node_a->num_ptrs;
-		ptrs_a = node_a->num_ptrs;
-
-		for (n = 0; n < ptrs_a; n++) {
-			for (m = 0; m < ptrs_b; m++) {
-
-				if (node_a->ptrs[n].ptr == NULL ||
-						node_b->ptrs[m].ptr == NULL ||
-						node_a->ptrs[n].ptr ==
-						node_b->ptrs[m].ptr)
-						continue;
-
-				intersect_type = acl_intersect_type(
-					&node_a->ptrs[n].values,
-					&node_b->ptrs[m].values,
-					&intersect_ptr);
-
-				/* If this node is not a 'match' node */
-				if ((intersect_type & ACL_INTERSECT) &&
-					(context->cfg.num_categories != 1 ||
-					!(node_a->ptrs[n].ptr->match_flag))) {
-
-					/*
-					 * next merge is a 'move' pointer,
-					 * if this one is and B is a
-					 * subset of the intersection.
-					 */
-					next_move = move &&
-						(intersect_type &
-						ACL_INTERSECT_B) == 0;
-
-					if (a_subset && b_full) {
-						rc = acl_merge(context,
-							node_a->ptrs[n].ptr,
-							node_b->ptrs[m].ptr,
-							next_move,
-							1, level + 1);
-						if (rc != 0)
-							return rc;
-					} else {
-						rc = acl_merge_intersect(
-							context, node_a, n,
-							node_b, m, next_move,
-							level, &intersect_ptr);
-						if (rc != 0)
-							return rc;
-					}
-				}
-			}
-		}
-	}
-
-	/* Compact pointers */
-	node_a->min_add = min_add_a;
-	acl_compact_node_ptrs(node_a);
-	node_b->min_add = min_add_b;
-	acl_compact_node_ptrs(node_b);
-
-	/*
-	 *  Either COPY or MOVE pointers from B to A
-	 */
-	acl_intersect(&node_a->values, &node_b->values, &intersect_values);
-
-	if (move && node_b->ref_count == 1) {
-		for (m = 0; m < node_b->num_ptrs; m++) {
-			if (node_b->ptrs[m].ptr != NULL &&
-					acl_move_ptr(context, node_a, node_b, m,
-					&intersect_values) < 0)
-				return -1;
-		}
-	} else {
-		for (m = 0; m < node_b->num_ptrs; m++) {
-			if (node_b->ptrs[m].ptr != NULL &&
-					acl_copy_ptr(context, node_a, node_b, m,
-					&intersect_values) < 0)
-				return -1;
-		}
-	}
-
-	/*
-	 *  Free node if its empty (no longer used)
-	 */
-	if (acl_empty(node_b))
-		acl_free_node(context, node_b);
-	return 0;
-}
-
 static int
 acl_resolve_leaf(struct acl_build_context *context,
 	struct rte_acl_node *node_a,
-- 
1.8.5.3

  parent reply	other threads:[~2015-06-03 23:10 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     ` [dpdk-dev] [PATCHv2 2/8] acl: code cleanup - use global EAL macro, instead of creating a local copy Konstantin Ananyev
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 ` Konstantin Ananyev [this message]
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=1433373024-5558-7-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).