From patchwork Mon Mar 9 12:42:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Medvedkin X-Patchwork-Id: 66449 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8CE57A052E; Mon, 9 Mar 2020 13:42:43 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 950C91C067; Mon, 9 Mar 2020 13:42:36 +0100 (CET) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id D7CD21C021 for ; Mon, 9 Mar 2020 13:42:33 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Mar 2020 05:42:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,533,1574150400"; d="scan'208";a="265243894" Received: from silpixa00400072.ir.intel.com ([10.237.222.213]) by fmsmga004.fm.intel.com with ESMTP; 09 Mar 2020 05:42:31 -0700 From: Vladimir Medvedkin To: dev@dpdk.org Cc: vladimir.medvedkin@intel.com Date: Mon, 9 Mar 2020 12:42:20 +0000 Message-Id: <1583757743-375198-2-git-send-email-vladimir.medvedkin@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1583757743-375198-1-git-send-email-vladimir.medvedkin@intel.com> References: <1583757743-375198-1-git-send-email-vladimir.medvedkin@intel.com> Subject: [dpdk-dev] [PATCH 1/4] app/testfib: fix possible uninitialized warning X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Compiller can throw warning message for routes and lookup files. Fixes: 103809d032cd ("app/test-fib: add test application for FIB") Cc: vladimir.medvedkin@intel.com Signed-off-by: Vladimir Medvedkin --- app/test-fib/main.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/test-fib/main.c b/app/test-fib/main.c index 3c29ca4..aa83f76 100644 --- a/app/test-fib/main.c +++ b/app/test-fib/main.c @@ -362,7 +362,7 @@ complete_v6_addr(uint32_t *addr, uint32_t rnd, int n) static void gen_random_rt_6(struct rt_rule_6 *rt, int nh_sz) { - uint32_t i, j, k = 0; + uint32_t a, i, j, k = 0; if (config.nb_routes_per_depth[0] != 0) { memset(rt[k].addr, 0, 16); @@ -370,7 +370,7 @@ gen_random_rt_6(struct rt_rule_6 *rt, int nh_sz) rt[k++].nh = rte_rand() & get_max_nh(nh_sz); } - for (int a = 0; a < 4; a++) { + for (a = 0; a < 4; a++) { for (i = 1; i <= 32; i++) { uint32_t rnd; double edge = 0; @@ -1145,7 +1145,8 @@ int main(int argc, char **argv) { int ret, af, rt_ent_sz, lookup_ent_sz; - FILE *fr, *fl; + FILE *fr = NULL; + FILE *fl = NULL; uint8_t depth_lim; ret = rte_eal_init(argc, argv); @@ -1207,7 +1208,7 @@ main(int argc, char **argv) rte_exit(-ENOMEM, "Can not alloc lookup table\n"); /* Fill routes table */ - if (config.routes_file == NULL) { + if (fr == NULL) { if (distrib_string != NULL) ret = parse_distrib(depth_lim, config.nb_routes); else { @@ -1243,7 +1244,7 @@ main(int argc, char **argv) } /* Fill lookup table with ip's*/ - if (config.lookup_ips_file == NULL) + if (fl == NULL) gen_rnd_lookup_tbl(af); else { ret = parse_lookup(fl, af); From patchwork Mon Mar 9 12:42:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Medvedkin X-Patchwork-Id: 66450 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id C8D2DA052E; Mon, 9 Mar 2020 13:42:52 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 05F661C07F; Mon, 9 Mar 2020 13:42:38 +0100 (CET) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 78CEE1C028 for ; Mon, 9 Mar 2020 13:42:34 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Mar 2020 05:42:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,533,1574150400"; d="scan'208";a="265243899" Received: from silpixa00400072.ir.intel.com ([10.237.222.213]) by fmsmga004.fm.intel.com with ESMTP; 09 Mar 2020 05:42:32 -0700 From: Vladimir Medvedkin To: dev@dpdk.org Cc: vladimir.medvedkin@intel.com Date: Mon, 9 Mar 2020 12:42:21 +0000 Message-Id: <1583757743-375198-3-git-send-email-vladimir.medvedkin@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1583757743-375198-1-git-send-email-vladimir.medvedkin@intel.com> References: <1583757743-375198-1-git-send-email-vladimir.medvedkin@intel.com> Subject: [dpdk-dev] [PATCH 2/4] app/testfib: fix format string X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Change format for uint64_t to to %"PRIu64" to make compiller happy Fixes: 103809d032cd ("app/test-fib: add test application for FIB") Cc: vladimir.medvedkin@intel.com Signed-off-by: Vladimir Medvedkin --- app/test-fib/main.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/app/test-fib/main.c b/app/test-fib/main.c index aa83f76..7fd3420 100644 --- a/app/test-fib/main.c +++ b/app/test-fib/main.c @@ -790,7 +790,7 @@ dump_rt_4(struct rt_rule_4 *rt) } for (i = 0; i < config.nb_routes; i++) - fprintf(f, NIPQUAD_FMT"/%d %lu\n", NIPQUAD(rt[i].addr), + fprintf(f, NIPQUAD_FMT"/%d %"PRIu64"\n", NIPQUAD(rt[i].addr), rt[i].depth, rt[i].nh); fclose(f); @@ -858,7 +858,8 @@ run_v4(void) return -ret; } } - printf("AVG FIB add %lu\n", (rte_rdtsc_precise() - start) / j); + printf("AVG FIB add %"PRIu64"\n", + (rte_rdtsc_precise() - start) / j); i += j; } @@ -885,7 +886,7 @@ run_v4(void) return -ret; } } - printf("AVG LPM add %lu\n", + printf("AVG LPM add %"PRIu64"\n", (rte_rdtsc_precise() - start) / j); i += j; } @@ -939,7 +940,7 @@ run_v4(void) for (j = 0; j < (config.nb_routes - i) / k; j++) rte_fib_delete(fib, rt[i + j].addr, rt[i + j].depth); - printf("AVG FIB delete %lu\n", + printf("AVG FIB delete %"PRIu64"\n", (rte_rdtsc_precise() - start) / j); i += j; } @@ -951,7 +952,7 @@ run_v4(void) rte_lpm_delete(lpm, rt[i + j].addr, rt[i + j].depth); - printf("AVG LPM delete %lu\n", + printf("AVG LPM delete %"PRIu64"\n", (rte_rdtsc_precise() - start) / j); i += j; } @@ -973,7 +974,7 @@ dump_rt_6(struct rt_rule_6 *rt) } for (i = 0; i < config.nb_routes; i++) { - fprintf(f, NIPQUAD6_FMT"/%d %lu\n", NIPQUAD6(rt[i].addr), + fprintf(f, NIPQUAD6_FMT"/%d %"PRIu64"\n", NIPQUAD6(rt[i].addr), rt[i].depth, rt[i].nh); } @@ -1036,7 +1037,8 @@ run_v6(void) return -ret; } } - printf("AVG FIB add %lu\n", (rte_rdtsc_precise() - start) / j); + printf("AVG FIB add %"PRIu64"\n", + (rte_rdtsc_precise() - start) / j); i += j; } @@ -1063,7 +1065,7 @@ run_v6(void) return -ret; } } - printf("AVG LPM add %lu\n", + printf("AVG LPM add %"PRIu64"\n", (rte_rdtsc_precise() - start) / j); i += j; } @@ -1121,7 +1123,7 @@ run_v6(void) for (j = 0; j < (config.nb_routes - i) / k; j++) rte_fib6_delete(fib, rt[i + j].addr, rt[i + j].depth); - printf("AVG FIB delete %lu\n", + printf("AVG FIB delete %"PRIu64"\n", (rte_rdtsc_precise() - start) / j); i += j; } @@ -1133,7 +1135,7 @@ run_v6(void) rte_lpm6_delete(lpm, rt[i + j].addr, rt[i + j].depth); - printf("AVG LPM delete %lu\n", + printf("AVG LPM delete %"PRIu64"\n", (rte_rdtsc_precise() - start) / j); i += j; } From patchwork Mon Mar 9 12:42:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Medvedkin X-Patchwork-Id: 66451 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 34A5CA052E; Mon, 9 Mar 2020 13:43:02 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6BDAD1C0B2; Mon, 9 Mar 2020 13:42:39 +0100 (CET) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 3F1851C065 for ; Mon, 9 Mar 2020 13:42:35 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Mar 2020 05:42:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,533,1574150400"; d="scan'208";a="265243900" Received: from silpixa00400072.ir.intel.com ([10.237.222.213]) by fmsmga004.fm.intel.com with ESMTP; 09 Mar 2020 05:42:33 -0700 From: Vladimir Medvedkin To: dev@dpdk.org Date: Mon, 9 Mar 2020 12:42:22 +0000 Message-Id: <1583757743-375198-4-git-send-email-vladimir.medvedkin@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1583757743-375198-1-git-send-email-vladimir.medvedkin@intel.com> References: <1583757743-375198-1-git-send-email-vladimir.medvedkin@intel.com> Subject: [dpdk-dev] [PATCH 3/4] app/testfib: get rid of libresolv dependency X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Get rid of using inet_net_pton(). Implement it internally in the app. Signed-off-by: Vladimir Medvedkin --- app/test-fib/Makefile | 2 -- app/test-fib/main.c | 85 +++++++++++++++++++++++++-------------------------- 2 files changed, 41 insertions(+), 46 deletions(-) diff --git a/app/test-fib/Makefile b/app/test-fib/Makefile index 78b45fe..9da34eb 100644 --- a/app/test-fib/Makefile +++ b/app/test-fib/Makefile @@ -11,8 +11,6 @@ CFLAGS += -O3 CFLAGS += $(WERROR_FLAGS) CFLAGS += -DALLOW_EXPERIMENTAL_API -LDFLAGS += -lresolv - # all source are stored in SRCS-y SRCS-y := main.c diff --git a/app/test-fib/main.c b/app/test-fib/main.c index 7fd3420..5fb67f3 100644 --- a/app/test-fib/main.c +++ b/app/test-fib/main.c @@ -2,14 +2,10 @@ * Copyright(c) 2019 Intel Corporation */ -#include #include #include -#include -#include -#include -#include #include +#include #include #include @@ -444,46 +440,12 @@ gen_rnd_lookup_tbl(int af) } static int -parse_rt_4(FILE *f) -{ - int ret, i, j = 0; - char *s, *sp, *in[RT_NUM]; - static const char *dlm = " \t\n"; - int string_tok_nb = RTE_DIM(in); - struct rt_rule_4 *rt; - - rt = (struct rt_rule_4 *)config.rt; - - while (fgets(line, sizeof(line), f) != NULL) { - s = line; - for (i = 0; i != string_tok_nb; i++) { - in[i] = strtok_r(s, dlm, &sp); - if (in[i] == NULL) - return -EINVAL; - s = NULL; - } - - ret = inet_net_pton(AF_INET, in[RT_PREFIX], &rt[j].addr, - sizeof(rt[j].addr)); - if (ret == -1) - return -errno; - - rt[j].addr = rte_be_to_cpu_32(rt[j].addr); - rt[j].depth = ret; - config.nb_routes_per_depth[ret]++; - GET_CB_FIELD(in[RT_NEXTHOP], rt[j].nh, 0, - UINT32_MAX, 0); - j++; - } - return 0; -} - -static int -__inet_net_pton6(char *prefix, uint8_t *addr) +_inet_net_pton(int af, char *prefix, void *addr) { const char *dlm = "/"; char *s, *sp; int ret, depth; + unsigned max_depth; if ((prefix == NULL) || (addr == NULL)) return -EINVAL; @@ -492,17 +454,52 @@ __inet_net_pton6(char *prefix, uint8_t *addr) if (s == NULL) return -EINVAL; - ret = inet_pton(AF_INET6, s, addr); + ret = inet_pton(af, s, addr); if (ret != 1) return -errno; s = strtok_r(NULL, dlm, &sp); - GET_CB_FIELD(s, depth, 0, 128, 0); + max_depth = (af == AF_INET) ? 32 : 128; + GET_CB_FIELD(s, depth, 0, max_depth, 0); return depth; } static int +parse_rt_4(FILE *f) +{ + int ret, i, j = 0; + char *s, *sp, *in[RT_NUM]; + static const char *dlm = " \t\n"; + int string_tok_nb = RTE_DIM(in); + struct rt_rule_4 *rt; + + rt = (struct rt_rule_4 *)config.rt; + + while (fgets(line, sizeof(line), f) != NULL) { + s = line; + for (i = 0; i != string_tok_nb; i++) { + in[i] = strtok_r(s, dlm, &sp); + if (in[i] == NULL) + return -EINVAL; + s = NULL; + } + + ret = _inet_net_pton(AF_INET, in[RT_PREFIX], &rt[j].addr); + if (ret == -1) + return -errno; + + rt[j].addr = rte_be_to_cpu_32(rt[j].addr); + rt[j].depth = ret; + config.nb_routes_per_depth[ret]++; + GET_CB_FIELD(in[RT_NEXTHOP], rt[j].nh, 0, + UINT32_MAX, 0); + j++; + } + return 0; +} + +static int parse_rt_6(FILE *f) { int ret, i, j = 0; @@ -522,7 +519,7 @@ parse_rt_6(FILE *f) s = NULL; } - ret = __inet_net_pton6(in[RT_PREFIX], rt[j].addr); + ret = _inet_net_pton(AF_INET6, in[RT_PREFIX], rt[j].addr); if (ret < 0) return ret; From patchwork Mon Mar 9 12:42:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Medvedkin X-Patchwork-Id: 66452 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id F398DA052E; Mon, 9 Mar 2020 13:43:10 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id CB7BF1C0BC; Mon, 9 Mar 2020 13:42:40 +0100 (CET) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id BA87A1C067 for ; Mon, 9 Mar 2020 13:42:35 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Mar 2020 05:42:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,533,1574150400"; d="scan'208";a="265243903" Received: from silpixa00400072.ir.intel.com ([10.237.222.213]) by fmsmga004.fm.intel.com with ESMTP; 09 Mar 2020 05:42:34 -0700 From: Vladimir Medvedkin To: dev@dpdk.org Date: Mon, 9 Mar 2020 12:42:23 +0000 Message-Id: <1583757743-375198-5-git-send-email-vladimir.medvedkin@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1583757743-375198-1-git-send-email-vladimir.medvedkin@intel.com> References: <1583757743-375198-1-git-send-email-vladimir.medvedkin@intel.com> Subject: [dpdk-dev] [PATCH 4/4] app: enable test-fib application X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Build test-fib application Signed-off-by: Vladimir Medvedkin --- app/Makefile | 1 + app/meson.build | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/Makefile b/app/Makefile index db9d2d5..9fd62fb 100644 --- a/app/Makefile +++ b/app/Makefile @@ -11,6 +11,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_ACL) += test-acl DIRS-$(CONFIG_RTE_LIBRTE_CMDLINE) += test-cmdline DIRS-$(CONFIG_RTE_LIBRTE_PIPELINE) += test-pipeline DIRS-$(CONFIG_RTE_LIBRTE_IPSEC) += test-sad +DIRS-$(CONFIG_RTE_LIBRTE_FIB) += test-fib ifeq ($(CONFIG_RTE_LIBRTE_BBDEV),y) DIRS-$(CONFIG_RTE_TEST_BBDEV) += test-bbdev diff --git a/app/meson.build b/app/meson.build index 71109cc..3f3512f 100644 --- a/app/meson.build +++ b/app/meson.build @@ -16,7 +16,8 @@ apps = [ 'test-eventdev', 'test-pipeline', 'test-pmd', - 'test-sad'] + 'test-sad', + 'test-fib'] # for BSD only lib_execinfo = cc.find_library('execinfo', required: false)