diff mbox

[dpdk-dev,4/8] ACL: fix rebuilding a trie for subset of rules

Message ID 1433373024-5558-5-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
When rebuilding a trie for limited rule-set,
don't try to split the rule-set even further.

Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
---
 lib/librte_acl/acl_bld.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
diff mbox

Patch

diff --git a/lib/librte_acl/acl_bld.c b/lib/librte_acl/acl_bld.c
index 8315d84..4bcf637 100644
--- a/lib/librte_acl/acl_bld.c
+++ b/lib/librte_acl/acl_bld.c
@@ -97,6 +97,7 @@  struct acl_build_context {
 	struct rte_acl_build_rule *build_rules;
 	struct rte_acl_config     cfg;
 	int32_t                   node_max;
+	int32_t                   cur_node_max;
 	uint32_t                  node;
 	uint32_t                  num_nodes;
 	uint32_t                  category_mask;
@@ -1337,7 +1338,7 @@  build_trie(struct acl_build_context *context, struct rte_acl_build_rule *head,
 			return NULL;
 
 		node_count = context->num_nodes - node_count;
-		if (node_count > context->node_max) {
+		if (node_count > context->cur_node_max) {
 			*last = prev;
 			return trie;
 		}
@@ -1536,7 +1537,7 @@  acl_build_index(const struct rte_acl_config *config, uint32_t *data_index)
 static struct rte_acl_build_rule *
 build_one_trie(struct acl_build_context *context,
 	struct rte_acl_build_rule *rule_sets[RTE_ACL_MAX_TRIES],
-	uint32_t n)
+	uint32_t n, int32_t node_max)
 {
 	struct rte_acl_build_rule *last;
 	struct rte_acl_config *config;
@@ -1553,6 +1554,8 @@  build_one_trie(struct acl_build_context *context,
 		context->data_indexes[n]);
 	context->tries[n].data_index = context->data_indexes[n];
 
+	context->cur_node_max = node_max;
+
 	context->bld_tries[n].trie = build_trie(context, rule_sets[n],
 		&last, &context->tries[n].count);
 
@@ -1587,7 +1590,7 @@  acl_build_tries(struct acl_build_context *context,
 
 		num_tries = n + 1;
 
-		last = build_one_trie(context, rule_sets, n);
+		last = build_one_trie(context, rule_sets, n, context->node_max);
 		if (context->bld_tries[n].trie == NULL) {
 			RTE_LOG(ERR, ACL, "Build of %u-th trie failed\n", n);
 			return -ENOMEM;
@@ -1618,8 +1621,11 @@  acl_build_tries(struct acl_build_context *context,
 				head = head->next)
 			head->config = config;
 
-		/* Rebuild the trie for the reduced rule-set. */
-		last = build_one_trie(context, rule_sets, n);
+		/*
+		 * Rebuild the trie for the reduced rule-set.
+		 * Don't try to split it any further.
+		 */
+		last = build_one_trie(context, rule_sets, n, INT32_MAX);
 		if (context->bld_tries[n].trie == NULL || last != NULL) {
 			RTE_LOG(ERR, ACL, "Build of %u-th trie failed\n", n);
 			return -ENOMEM;