From patchwork Sun Feb 19 23:14:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 124158 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 60A4041CE4; Mon, 20 Feb 2023 00:14:38 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8F7AE42D94; Mon, 20 Feb 2023 00:14:30 +0100 (CET) Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) by mails.dpdk.org (Postfix) with ESMTP id 7236F42D7E for ; Mon, 20 Feb 2023 00:14:23 +0100 (CET) Received: by mail-pj1-f47.google.com with SMTP id ot9so1506846pjb.3 for ; Sun, 19 Feb 2023 15:14:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1XH+YIdS2J0+gUtw3hNcVseB7jI92w+W7yJ531/tnpU=; b=PpGTGGWriVeBLjapj211BWF3vqIZZsOaSCxbcUu/dVfGTurT0TaWLvoTUi+QptRU16 6lfvQtqkPqDPZF5Kfo4huwH4JXSVHgQCjwbWw8LHlkrvgFj40+jf/yoczFGshYCUGCyq xMFsaIhijnY/DD0HZT7PzH9xEaWq2Woqzi11RV8myq+v8Als+SCF6PTL3F7CxHpYD/Sf zz6Ru0aT8r88od0H4ozG8T6quJ0egCqu5TA5Ff+ccr/Zt+khaQ4T8F8/wz1bjM4yS2uS RYacgLFw19238DcGboyZgH0RzQQJJrKaueqC7bO25oqjw1+yMkJVxn9lPz8PG8STX8zr SrIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1XH+YIdS2J0+gUtw3hNcVseB7jI92w+W7yJ531/tnpU=; b=bRXQlsx1YdltHZQw+1hCt2oMgzlDnTH9IB43Mjkgqkt+KngFragfzywT+ACooSP0nk DdxRFrHZHCwAkOFcHQZvynQc5jVOES2NdbdocbkUKnDQ1WhgWaGVfhHuG6rTi5cqFiEJ QxQzcn6LGI16vaMOB+6xHuarG40vCFcGvbyMjUqMTkrSgk183zHJjPlbV644GStFtPK9 +21ND4Qy7mmfWTzM1GYW8z+mLMjF9mjS2IqWWzgRw4e8PG84LcHbuyRQbWo2/ojY/S5R o74DqjhRb8C5XRfo+Y9udQ8ETz72lGEUfoEN46rg9GxBN7URVne+yEOkxR/CWkt3Pso+ JydA== X-Gm-Message-State: AO0yUKU66TEy6HAA3uxpNMC/265YwhS3eu01C5o26BwVSru34tpYQy5U QxbM7r8WCrp2bVj6ABQKJCotrSxIQgnLuTMokh0= X-Google-Smtp-Source: AK7set+uW5IHXf5523nYwZX3YE3AhNg0Db1i5HYsKiUN0FNtLljazf7TH/SgIR5UiEEGcnoAWy5xZw== X-Received: by 2002:a17:902:ecc7:b0:19a:f9b5:2f2f with SMTP id a7-20020a170902ecc700b0019af9b52f2fmr2138323plh.55.1676848462297; Sun, 19 Feb 2023 15:14:22 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id l10-20020a170902d34a00b00192fe452e17sm683336plk.162.2023.02.19.15.14.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Feb 2023 15:14:21 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Tyler Retzlaff , Bruce Richardson , Vladimir Medvedkin Subject: [PATCH v4 3/9] lpm: enable on Windows Date: Sun, 19 Feb 2023 15:14:10 -0800 Message-Id: <20230219231416.22524-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230219231416.22524-1-stephen@networkplumber.org> References: <20230207001937.875608-1-stephen@networkplumber.org> <20230219231416.22524-1-stephen@networkplumber.org> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org This builds on Windows without changes. Signed-off-by: Stephen Hemminger Acked-by: Tyler Retzlaff --- app/test/test_lpm.c | 15 +-------------- app/test/test_lpm6.c | 12 ------------ app/test/test_lpm6_data.h | 3 ++- app/test/test_lpm6_perf.c | 14 +------------- app/test/test_lpm_perf.c | 39 ++++++++++++--------------------------- lib/lpm/meson.build | 6 ------ 6 files changed, 16 insertions(+), 73 deletions(-) diff --git a/app/test/test_lpm.c b/app/test/test_lpm.c index bceb9ae743d7..37b460af3a96 100644 --- a/app/test/test_lpm.c +++ b/app/test/test_lpm.c @@ -2,18 +2,6 @@ * Copyright(c) 2010-2014 Intel Corporation */ -#include "test.h" - -#ifdef RTE_EXEC_ENV_WINDOWS -static int -test_lpm(void) -{ - printf("lpm not supported on Windows, skipping test\n"); - return TEST_SKIPPED; -} - -#else - #include #include #include @@ -22,6 +10,7 @@ test_lpm(void) #include #include +#include "test.h" #include "test_xmmt_ops.h" #define TEST_LPM_ASSERT(cond) do { \ @@ -1595,6 +1584,4 @@ test_lpm(void) return global_status; } -#endif /* !RTE_EXEC_ENV_WINDOWS */ - REGISTER_TEST_COMMAND(lpm_autotest, test_lpm); diff --git a/app/test/test_lpm6.c b/app/test/test_lpm6.c index 1f44392db739..b6b6f8615ea5 100644 --- a/app/test/test_lpm6.c +++ b/app/test/test_lpm6.c @@ -10,16 +10,6 @@ #include #include -#ifdef RTE_EXEC_ENV_WINDOWS -static int -test_lpm6(void) -{ - printf("lpm6 not supported on Windows, skipping test\n"); - return TEST_SKIPPED; -} - -#else - #include #include "test_lpm6_data.h" @@ -1803,6 +1793,4 @@ test_lpm6(void) return global_status; } -#endif /* !RTE_EXEC_ENV_WINDOWS */ - REGISTER_TEST_COMMAND(lpm6_autotest, test_lpm6); diff --git a/app/test/test_lpm6_data.h b/app/test/test_lpm6_data.h index da9b161f20e5..3a1fa25f8433 100644 --- a/app/test/test_lpm6_data.h +++ b/app/test/test_lpm6_data.h @@ -6,6 +6,7 @@ #include #include +#include struct rules_tbl_entry { uint8_t ip[16]; @@ -1129,7 +1130,7 @@ static void generate_large_ips_table(int gen_expected_next_hop) for (i = 0; i < NUM_IPS_ENTRIES; i++) { for (j = 0; j < 16; j++) - large_ips_table[i].ip[j] = lrand48(); + large_ips_table[i].ip[j] = rte_rand(); } for (k = j = 0, i = 0; i < NUM_IPS_ENTRIES; i++) { diff --git a/app/test/test_lpm6_perf.c b/app/test/test_lpm6_perf.c index aaf2773b6fac..5b684686a687 100644 --- a/app/test/test_lpm6_perf.c +++ b/app/test/test_lpm6_perf.c @@ -2,17 +2,6 @@ * Copyright(c) 2010-2014 Intel Corporation */ -#include "test.h" - -#ifdef RTE_EXEC_ENV_WINDOWS -static int -test_lpm6_perf(void) -{ - printf("lpm6_perf not supported on Windows, skipping test\n"); - return TEST_SKIPPED; -} - -#else #include #include @@ -24,6 +13,7 @@ test_lpm6_perf(void) #include #include +#include "test.h" #include "test_lpm6_data.h" #define TEST_LPM_ASSERT(cond) do { \ @@ -171,6 +161,4 @@ test_lpm6_perf(void) return 0; } -#endif /* !RTE_EXEC_ENV_WINDOWS */ - REGISTER_TEST_COMMAND(lpm6_perf_autotest, test_lpm6_perf); diff --git a/app/test/test_lpm_perf.c b/app/test/test_lpm_perf.c index e858716f909b..e72437ba3850 100644 --- a/app/test/test_lpm_perf.c +++ b/app/test/test_lpm_perf.c @@ -3,17 +3,6 @@ * Copyright(c) 2020 Arm Limited */ -#include "test.h" - -#ifdef RTE_EXEC_ENV_WINDOWS -static int -test_lpm_perf(void) -{ - printf("lpm_perf not supported on Windows, skipping test\n"); - return TEST_SKIPPED; -} - -#else #include #include #include @@ -25,7 +14,9 @@ test_lpm_perf(void) #include #include #include +#include +#include "test.h" #include "test_xmmt_ops.h" struct rte_lpm *lpm; @@ -34,8 +25,9 @@ static volatile uint8_t writer_done; static volatile uint32_t thr_id; static uint64_t gwrite_cycles; static uint32_t num_writers; -/* LPM APIs are not thread safe, use mutex to provide thread safety */ -static pthread_mutex_t lpm_mutex = PTHREAD_MUTEX_INITIALIZER; + +/* LPM APIs are not thread safe, use spinlock */ +static rte_spinlock_t lpm_lock = RTE_SPINLOCK_INITIALIZER; /* Report quiescent state interval every 1024 lookups. Larger critical * sections in reader will result in writer polling multiple times. @@ -267,7 +259,7 @@ static void generate_random_rule_prefix(uint32_t ip_class, uint8_t depth) /* Only generate rest bits except the most significant * fixed bits for IP address class */ - start = lrand48() & mask; + start = rte_rand() & mask; ptr_rule = &large_route_table[num_route_entries]; ptr_ldepth_rule = &large_ldepth_route_table[num_ldepth_route_entries]; for (k = 0; k < rule_num; k++) { @@ -296,7 +288,7 @@ static void insert_rule_in_random_pos(uint32_t ip, uint8_t depth) struct route_rule tmp; do { - pos = lrand48(); + pos = rte_rand(); try_count++; } while ((try_count < 10) && (pos > num_route_entries)); @@ -452,8 +444,7 @@ test_lpm_rcu_qsbr_writer(void *arg) for (i = 0; i < RCU_ITERATIONS; i++) { /* Add all the entries */ for (j = si; j < ei; j++) { - if (num_writers > 1) - pthread_mutex_lock(&lpm_mutex); + rte_spinlock_lock(&lpm_lock); if (rte_lpm_add(lpm, large_ldepth_route_table[j].ip, large_ldepth_route_table[j].depth, next_hop_add) != 0) { @@ -461,22 +452,19 @@ test_lpm_rcu_qsbr_writer(void *arg) i, j); goto error; } - if (num_writers > 1) - pthread_mutex_unlock(&lpm_mutex); + rte_spinlock_unlock(&lpm_lock); } /* Delete all the entries */ for (j = si; j < ei; j++) { - if (num_writers > 1) - pthread_mutex_lock(&lpm_mutex); + rte_spinlock_lock(&lpm_lock); if (rte_lpm_delete(lpm, large_ldepth_route_table[j].ip, large_ldepth_route_table[j].depth) != 0) { printf("Failed to delete iteration %d, route# %d\n", i, j); goto error; } - if (num_writers > 1) - pthread_mutex_unlock(&lpm_mutex); + rte_spinlock_unlock(&lpm_lock); } } @@ -487,8 +475,7 @@ test_lpm_rcu_qsbr_writer(void *arg) return 0; error: - if (num_writers > 1) - pthread_mutex_unlock(&lpm_mutex); + rte_spinlock_unlock(&lpm_lock); return -1; } @@ -773,6 +760,4 @@ test_lpm_perf(void) return 0; } -#endif /* !RTE_EXEC_ENV_WINDOWS */ - REGISTER_TEST_COMMAND(lpm_perf_autotest, test_lpm_perf); diff --git a/lib/lpm/meson.build b/lib/lpm/meson.build index 6b47361fcec0..4cd48886fc41 100644 --- a/lib/lpm/meson.build +++ b/lib/lpm/meson.build @@ -1,12 +1,6 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017 Intel Corporation -if is_windows - build = false - reason = 'not supported on Windows' - subdir_done() -endif - sources = files('rte_lpm.c', 'rte_lpm6.c') headers = files('rte_lpm.h', 'rte_lpm6.h') # since header files have different names, we can install all vector headers