From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 40E9458DD for ; Mon, 8 Jun 2015 12:41:43 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP; 08 Jun 2015 03:41:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,573,1427785200"; d="scan'208";a="723016121" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga001.fm.intel.com with ESMTP; 08 Jun 2015 03:41:37 -0700 Received: from sivswdev02.ir.intel.com (sivswdev02.ir.intel.com [10.237.217.46]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id t58AfbrE029636; Mon, 8 Jun 2015 11:41:37 +0100 Received: from sivswdev02.ir.intel.com (localhost [127.0.0.1]) by sivswdev02.ir.intel.com with ESMTP id t58AfbEh017572; Mon, 8 Jun 2015 11:41:37 +0100 Received: (from kananye1@localhost) by sivswdev02.ir.intel.com with id t58Afbla017568; Mon, 8 Jun 2015 11:41:37 +0100 From: Konstantin Ananyev To: dev@dpdk.org Date: Mon, 8 Jun 2015 11:41:26 +0100 Message-Id: <1433760090-17110-5-git-send-email-konstantin.ananyev@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1433760090-17110-1-git-send-email-konstantin.ananyev@intel.com> References: <1433373024-5558-2-git-send-email-konstantin.ananyev@intel.com> <1433760090-17110-1-git-send-email-konstantin.ananyev@intel.com> Subject: [dpdk-dev] [PATCHv2 4/8] acl: fix avoid unneeded trie splitting for subset of rules. X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Jun 2015 10:41:43 -0000 When rebuilding a trie for limited rule-set, don't try to split the rule-set even further. Signed-off-by: Konstantin Ananyev --- lib/librte_acl/acl_bld.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/librte_acl/acl_bld.c b/lib/librte_acl/acl_bld.c index 45ee065..d89c66a 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; -- 2.4.2