From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9933BA00C2; Thu, 1 Dec 2022 02:45:00 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 849AD42D1D; Thu, 1 Dec 2022 02:44:47 +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 619DE42D11 for ; Thu, 1 Dec 2022 02:44:46 +0100 (CET) Received: by mail-pj1-f47.google.com with SMTP id b13-20020a17090a5a0d00b0021906102d05so489783pjd.5 for ; Wed, 30 Nov 2022 17:44:46 -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=NzalnrKZG97h2kZ/mOSJt/OFXq6bnWhNFztfZj6ds1A=; b=HbnY6CY8NAkvCcPnTaKUGCNMOkTQajfv4R/xFRQDNEi3HKJIiT3nrZ3dBud8qJOPxb 5CDcF56nxrz6/i/yrX532kK1uhzl0WKZ18oW2rvC3VfwZAcYtEOQLHr8ZZVQB1/BTNVB YzcTYINQ57Q0VYEVB7jgD+aMUx5wMeSAF3aYan0jtmc+I+/ovp4MbMc4IlEmJllR45r5 8CN7akqeEBoTI6Dx3e/zjEyimckROFm2g4pKLSWl0Xf05epNrDDnWzknLqpwD9Fkvxuj 7jmMFKB69WZoAMYfmCxzQdqWWFfhAMd+/PgL/WqHSwcyPz3MphJ//6PG0tjpbhjlYf70 XfOQ== 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=NzalnrKZG97h2kZ/mOSJt/OFXq6bnWhNFztfZj6ds1A=; b=ruVw3Lw/20j4jrFH3aVCeErs0dyejwI/F1CN6r81lIhKzs35n+hTHQ2Te3q++hMLYL I6BJJJmIPkUiW9VFWP5xLo5judtLjE37gg0kR9L4kauPZRU9ibP7ikZ2lbEkk+7LvgIl ElFfLWWWEk2eGPe5/z4p/a5YZUmJgEnxm1LKsdl1UZByuB2fiH+AMAKHWQpSDnvczy5H aLUl08FCL2kwNnPMar9d8wmCLRWgl8xetfRgipy484B3ynpG83LXLSuw+TBeMHN+mpBM RcbskPmK5BcmATijXDQ3t2m9UM6OglXKQFkO56J8d3tltPb0X2Q7frGabkO1Vtwi7H4f BRHg== X-Gm-Message-State: ANoB5plrg/Sisw1Qu54hcNHTC7lCAdPyHLqa3uY2td/OIodC/I+LjKvp B/UKJHlUiTiE5xhco6mjO6cpA97IVWeAkdYM X-Google-Smtp-Source: AA0mqf73JShCZRPwwNalEDC8AQCHz+XWqY0K0mevliG3+qP706EoqWZhH9vNJ5VMrScaqudBbgT98A== X-Received: by 2002:a17:90a:fe05:b0:219:29eb:bc4b with SMTP id ck5-20020a17090afe0500b0021929ebbc4bmr21719291pjb.199.1669859085346; Wed, 30 Nov 2022 17:44:45 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id h14-20020a170902680e00b00186ffe62502sm2125014plk.254.2022.11.30.17.44.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Nov 2022 17:44:45 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Bruce Richardson , Vladimir Medvedkin Subject: [PATCH 3/8] lpm: enable on Windows Date: Wed, 30 Nov 2022 17:44:34 -0800 Message-Id: <20221201014440.11896-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221201014440.11896-1-stephen@networkplumber.org> References: <20221201014440.11896-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- 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 -- 2.35.1