From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 4CEBE4CE6 for ; Thu, 14 Jul 2016 18:07:02 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP; 14 Jul 2016 09:06:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,363,1464678000"; d="scan'208";a="995303105" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga001.jf.intel.com with ESMTP; 14 Jul 2016 09:06:51 -0700 Received: from sivswdev01.ir.intel.com (sivswdev01.ir.intel.com [10.237.217.45]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id u6EG6o6M024304; Thu, 14 Jul 2016 17:06:50 +0100 Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1]) by sivswdev01.ir.intel.com with ESMTP id u6EG6ocY030794; Thu, 14 Jul 2016 17:06:50 +0100 Received: (from bricha3@localhost) by sivswdev01.ir.intel.com with id u6EG6o4J030789; Thu, 14 Jul 2016 17:06:50 +0100 From: Bruce Richardson To: dev@dpdk.org Cc: Nikita Kozlov , Thomas Monjalon , Bruce Richardson Date: Thu, 14 Jul 2016 17:06:21 +0100 Message-Id: <1468512382-30412-5-git-send-email-bruce.richardson@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1468512382-30412-1-git-send-email-bruce.richardson@intel.com> References: <1465909410-4668-1-git-send-email-nikita@elyzion.net> <1468512382-30412-1-git-send-email-bruce.richardson@intel.com> Subject: [dpdk-dev] [PATCH v2 4/5] test: change lpm test to use routes as resource 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: Thu, 14 Jul 2016 16:07:02 -0000 Change the lpm autotest to use the routes data from the resource data stored in the binary rather than including it directly into the C file as a C header. This speeds up compile and link time, without changing the test results. Signed-off-by: Bruce Richardson --- app/test/test_lpm_perf.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 74 insertions(+), 1 deletion(-) diff --git a/app/test/test_lpm_perf.c b/app/test/test_lpm_perf.c index 0e64919..ad70b02 100644 --- a/app/test/test_lpm_perf.c +++ b/app/test/test_lpm_perf.c @@ -34,17 +34,25 @@ #include #include #include +#include #include #include +#include #include #include #include "test.h" #include "resource.h" -#include "test_lpm_routes.h" #include "test_xmmt_ops.h" +struct route_rule { + uint32_t ip; + uint8_t depth; +}; +static struct route_rule *large_route_table; +static unsigned int NUM_ROUTE_ENTRIES; + REGISTER_LINKED_RESOURCE(test_lpm_data) #define TEST_LPM_ASSERT(cond) do { \ @@ -83,6 +91,68 @@ print_route_distribution(const struct route_rule *table, uint32_t n) } static int +load_large_route_table(void) +{ + const struct resource *r; + const char *lpm_data; + + r = resource_find("test_lpm_data"); + TEST_ASSERT_NOT_NULL(r, "No large lpm table data found"); + + /* the routing table size is going to be less than the size of the + * resource, since text extries are more verbose. Allocate this as + * the max size, and shrink the allocation later + */ + large_route_table = rte_malloc(NULL, resource_size(r), 0); + if (large_route_table == NULL) + return -1; + + /* parse the lpm table. All entries are of format: + * {IP-as-decimal-unsigned, depth} + * For example: + * {1234567U, 24}, + * We use the "U" and "}" characters as format check characters, + * after parsing each number. + */ + for (lpm_data = r->begin; lpm_data < r->end; lpm_data++) { + if (*lpm_data == '{') { + char *endptr; + + lpm_data++; + large_route_table[NUM_ROUTE_ENTRIES].ip = \ + strtoul(lpm_data, &endptr, 0); + if (*endptr != 'U') { + if (NUM_ROUTE_ENTRIES > 0) { + char *value = strndup(lpm_data, 12); + printf("Failed parse of %s\n", value); + free(value); + } + continue; + } + + lpm_data = endptr + 2; /* skip U and , */ + large_route_table[NUM_ROUTE_ENTRIES].depth = \ + strtoul(lpm_data, &endptr, 0); + if (*endptr != '}') { + if (NUM_ROUTE_ENTRIES > 0) { + char *value = strndup(lpm_data, 5); + printf("Failed parse of %s\n", value); + free(value); + } + continue; + } + + NUM_ROUTE_ENTRIES++; + } + } + + large_route_table = rte_realloc(large_route_table, + sizeof(large_route_table[0]) * NUM_ROUTE_ENTRIES, 0); + printf("Read %u route entries\n", NUM_ROUTE_ENTRIES); + return 0; +} + +static int test_lpm_perf(void) { struct rte_lpm *lpm = NULL; @@ -98,6 +168,9 @@ test_lpm_perf(void) uint64_t cache_line_counter = 0; int64_t count = 0; + TEST_ASSERT_SUCCESS(load_large_route_table(), + "Error loading lpm table"); + rte_srand(rte_rdtsc()); printf("No. routes = %u\n", (unsigned) NUM_ROUTE_ENTRIES); -- 2.5.5