From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 54D7BA0350;
	Thu, 14 May 2020 14:29:30 +0200 (CEST)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id BF2CA1D930;
	Thu, 14 May 2020 14:28:45 +0200 (CEST)
Received: from mga14.intel.com (mga14.intel.com [192.55.52.115])
 by dpdk.org (Postfix) with ESMTP id 84F611D91A
 for <dev@dpdk.org>; Thu, 14 May 2020 14:28:41 +0200 (CEST)
IronPort-SDR: /58fnfmDSmtkMPxJjDN6P0kAI9zUrbWogyKcZQzXLoRZkrAKIYIjIIe+VlhtKVkP58jLhOTUp6
 G0/mLhIDPuPg==
X-Amp-Result: SKIPPED(no attachment in message)
X-Amp-File-Uploaded: False
Received: from fmsmga005.fm.intel.com ([10.253.24.32])
 by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 14 May 2020 05:28:41 -0700
IronPort-SDR: /bH2GAPDeayg02lTDZBP9KlB/gyaR9gtXToGdRebPIVi4O9UPkQA8u+qNkGHBtxA6W14XLmIXU
 bGNNmC0Nx1Uw==
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.73,391,1583222400"; d="scan'208";a="464313932"
Received: from silpixa00400072.ir.intel.com ([10.237.222.213])
 by fmsmga005.fm.intel.com with ESMTP; 14 May 2020 05:28:40 -0700
From: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
To: dev@dpdk.org
Cc: konstantin.ananyev@intel.com,
	bruce.richardson@intel.com
Date: Thu, 14 May 2020 13:28:30 +0100
Message-Id: <d9063d6013a8fcf9da3cc8f6fc9b73b56c6009ba.1589458934.git.vladimir.medvedkin@intel.com>
X-Mailer: git-send-email 2.7.4
In-Reply-To: <cover.1589458934.git.vladimir.medvedkin@intel.com>
References: <cover.1589458934.git.vladimir.medvedkin@intel.com>
In-Reply-To: <cover.1589458934.git.vladimir.medvedkin@intel.com>
References: <1583757826-375246-1-git-send-email-vladimir.medvedkin@intel.com>
 <cover.1589458934.git.vladimir.medvedkin@intel.com>
Subject: [dpdk-dev] [PATCH v2 6/6] app/testfib: add support for different
	lookup functions
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

Added -v option to switch between different lookup implementations
to measure their performance and correctness.

Signed-off-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
---
 app/test-fib/main.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 55 insertions(+), 3 deletions(-)

diff --git a/app/test-fib/main.c b/app/test-fib/main.c
index 6e80d65..b72e8c4 100644
--- a/app/test-fib/main.c
+++ b/app/test-fib/main.c
@@ -99,6 +99,7 @@ static struct {
 	uint8_t		ent_sz;
 	uint8_t		rnd_lookup_ips_ratio;
 	uint8_t		print_fract;
+	uint8_t		lookup_fn;
 } config = {
 	.routes_file = NULL,
 	.lookup_ips_file = NULL,
@@ -110,7 +111,8 @@ static struct {
 	.tbl8 = DEFAULT_LPM_TBL8,
 	.ent_sz = 4,
 	.rnd_lookup_ips_ratio = 0,
-	.print_fract = 10
+	.print_fract = 10,
+	.lookup_fn = 0
 };
 
 struct rt_rule_4 {
@@ -636,7 +638,11 @@ print_usage(void)
 		"1/2/4/8 (default 4)>]\n"
 		"[-g <number of tbl8's for dir24_8 or trie FIBs>]\n"
 		"[-w <path to the file to dump routing table>]\n"
-		"[-u <path to the file to dump ip's for lookup>]\n",
+		"[-u <path to the file to dump ip's for lookup>]\n"
+		"[-v <type of loookup function:"
+		"\ts1, s2, s3 (3 types of scalar), v (vector) -"
+		" for DIR24_8 based FIB\n"
+		"\ts, v - for TRIE based ipv6 FIB>]\n",
 		config.prgname);
 }
 
@@ -679,7 +685,7 @@ parse_opts(int argc, char **argv)
 	int opt;
 	char *endptr;
 
-	while ((opt = getopt(argc, argv, "f:t:n:d:l:r:c6ab:e:g:w:u:s")) !=
+	while ((opt = getopt(argc, argv, "f:t:n:d:l:r:c6ab:e:g:w:u:sv:")) !=
 			-1) {
 		switch (opt) {
 		case 'f':
@@ -767,6 +773,22 @@ parse_opts(int argc, char **argv)
 				rte_exit(-EINVAL, "Invalid option -g\n");
 			}
 			break;
+		case 'v':
+			if ((strcmp(optarg, "s1") == 0) ||
+					(strcmp(optarg, "s") == 0))
+				break;
+			else if (strcmp(optarg, "v") == 0) {
+				config.lookup_fn = 1;
+				break;
+			} else if (strcmp(optarg, "s2") == 0) {
+				config.lookup_fn = 2;
+				break;
+			} else if (strcmp(optarg, "s3") == 0) {
+				config.lookup_fn = 3;
+				break;
+			}
+			print_usage();
+			rte_exit(-EINVAL, "Invalid option -v %s\n", optarg);
 		default:
 			print_usage();
 			rte_exit(-EINVAL, "Invalid options\n");
@@ -844,6 +866,24 @@ run_v4(void)
 		return -rte_errno;
 	}
 
+	if (config.lookup_fn != 0) {
+		if (config.lookup_fn == 1)
+			ret = rte_fib_set_lookup_fn(fib,
+				RTE_FIB_DIR24_8_VECTOR);
+		else if (config.lookup_fn == 2)
+			ret = rte_fib_set_lookup_fn(fib,
+				RTE_FIB_DIR24_8_SCALAR_INLINE);
+		else if (config.lookup_fn == 3)
+			ret = rte_fib_set_lookup_fn(fib,
+				RTE_FIB_DIR24_8_SCALAR_UNI);
+		else
+			ret = -EINVAL;
+		if (ret != 0) {
+			printf("Can not init lookup function\n");
+			return ret;
+		}
+	}
+
 	for (k = config.print_fract, i = 0; k > 0; k--) {
 		start = rte_rdtsc_precise();
 		for (j = 0; j < (config.nb_routes - i) / k; j++) {
@@ -1023,6 +1063,18 @@ run_v6(void)
 		return -rte_errno;
 	}
 
+	if (config.lookup_fn != 0) {
+		if (config.lookup_fn == 1)
+			ret = rte_fib6_set_lookup_fn(fib,
+				RTE_FIB6_TRIE_VECTOR);
+		else
+			ret = -EINVAL;
+		if (ret != 0) {
+			printf("Can not init lookup function\n");
+			return ret;
+		}
+	}
+
 	for (k = config.print_fract, i = 0; k > 0; k--) {
 		start = rte_rdtsc_precise();
 		for (j = 0; j < (config.nb_routes - i) / k; j++) {
-- 
2.7.4