@@ -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 <stdio.h>
#include <stdint.h>
#include <stdlib.h>
@@ -22,6 +10,7 @@ test_lpm(void)
#include <rte_lpm.h>
#include <rte_malloc.h>
+#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);
@@ -10,16 +10,6 @@
#include <string.h>
#include <rte_memory.h>
-#ifdef RTE_EXEC_ENV_WINDOWS
-static int
-test_lpm6(void)
-{
- printf("lpm6 not supported on Windows, skipping test\n");
- return TEST_SKIPPED;
-}
-
-#else
-
#include <rte_lpm6.h>
#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);
@@ -6,6 +6,7 @@
#include <stdint.h>
#include <stdlib.h>
+#include <rte_random.h>
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++) {
@@ -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 <stdio.h>
#include <stdint.h>
@@ -24,6 +13,7 @@ test_lpm6_perf(void)
#include <rte_memory.h>
#include <rte_lpm6.h>
+#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);
@@ -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 <stdio.h>
#include <stdint.h>
#include <stdlib.h>
@@ -25,7 +14,9 @@ test_lpm_perf(void)
#include <rte_malloc.h>
#include <rte_ip.h>
#include <rte_lpm.h>
+#include <rte_spinlock.h>
+#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);
@@ -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