-/*-
- * BSD LICENSE
- *
- * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Intel Corporation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2014 Intel Corporation
*/
+#include "test.h"
+
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <unistd.h>
#include <inttypes.h>
+
+#ifdef RTE_EXEC_ENV_WINDOWS
+static int
+test_red(void)
+{
+ printf("red not supported on Windows, skipping test\n");
+ return TEST_SKIPPED;
+}
+
+static int
+test_red_perf(void)
+{
+ printf("red_perf not supported on Windows, skipping test\n");
+ return TEST_SKIPPED;
+}
+
+static int
+test_red_all(void)
+{
+ printf("red_all not supported on Windows, skipping test\n");
+ return TEST_SKIPPED;
+}
+#else
+
#include <sys/time.h>
#include <time.h>
#include <math.h>
-#include "test.h"
-
#include <rte_red.h>
#ifdef __INTEL_COMPILER
return ret;
}
-/**
- * get the clk frequency in Hz
- */
-static uint64_t get_machclk_freq(void)
-{
- uint64_t start = 0;
- uint64_t end = 0;
- uint64_t diff = 0;
- static uint64_t clk_freq_hz;
- struct timespec tv_start = {0, 0}, tv_end = {0, 0};
- struct timespec req = {0, 0};
-
- if (clk_freq_hz != 0)
- return clk_freq_hz;
-
- req.tv_sec = 0;
- req.tv_nsec = NSEC_PER_SEC / 4;
-
- clock_gettime(CLOCK_REALTIME, &tv_start);
- start = rte_rdtsc();
-
- if (nanosleep(&req, NULL) != 0) {
- perror("get_machclk_freq()");
- exit(EXIT_FAILURE);
- }
-
- clock_gettime(CLOCK_REALTIME, &tv_end);
- end = rte_rdtsc();
-
- diff = (uint64_t)(tv_end.tv_sec - tv_start.tv_sec) * USEC_PER_SEC
- + ((tv_end.tv_nsec - tv_start.tv_nsec + TEST_NSEC_MARGIN) /
- USEC_PER_MSEC); /**< diff is in micro secs */
-
- if (diff == 0)
- return 0;
-
- clk_freq_hz = ((end - start) * USEC_PER_SEC / diff);
- return clk_freq_hz;
-}
-
/**
* initialize the test rte_red config
*/
{
unsigned i = 0;
- tcfg->tvar->clk_freq = get_machclk_freq();
+ tcfg->tvar->clk_freq = rte_get_timer_hz();
init_port_ts( tcfg->tvar->clk_freq );
for (i = 0; i < tcfg->tconfig->num_cfg; i++) {
static struct test_config func_test6_config = {
.ifname = "functional test 6 interface",
.msg = "functional test 6 : use several queues (each with its own run-time data),\n"
- " use several RED configurations (such that each configuration is sharte_red by multiple queues),\n"
+ " use several RED configurations (such that each configuration is shared by multiple queues),\n"
" increase average queue size to target level,\n"
" dequeue all packets until queue is empty,\n"
" confirm that average queue size is computed correctly while queue is empty\n"
}
static struct test_config ovfl_test1_config = {
- .ifname = "queue avergage overflow test interface",
+ .ifname = "queue average overflow test interface",
.msg = "overflow test 1 : use one RED configuration,\n"
" increase average queue size to target level,\n"
- " check maximum number of bits requirte_red to represent avg_s\n\n",
+ " check maximum number of bits required to represent avg_s\n\n",
.htxt = "avg queue size "
"wq_log2 "
"fraction bits "
printf("%i: rte_red_config_init should have failed!\n", __LINE__);
return -1;
}
- /* min_treshold == max_treshold */
+ /* min_threshold == max_threshold */
if (rte_red_config_init(&config, 0, 1, 1, 0) == 0) {
printf("%i: rte_red_config_init should have failed!\n", __LINE__);
return -1;
}
- /* min_treshold > max_treshold */
+ /* min_threshold > max_threshold */
if (rte_red_config_init(&config, 0, 2, 1, 0) == 0) {
printf("%i: rte_red_config_init should have failed!\n", __LINE__);
return -1;
return tell_the_result(num_tests, num_pass);
}
-static struct test_command red_cmd = {
- .command = "red_autotest",
- .callback = test_red,
-};
-REGISTER_TEST_COMMAND(red_cmd);
+#endif /* !RTE_EXEC_ENV_WINDOWS */
-static struct test_command red_cmd_perf = {
- .command = "red_perf",
- .callback = test_red_perf,
-};
-REGISTER_TEST_COMMAND(red_cmd_perf);
-
-static struct test_command red_cmd_all = {
- .command = "red_all",
- .callback = test_red_all,
-};
-REGISTER_TEST_COMMAND(red_cmd_all);
+REGISTER_TEST_COMMAND(red_autotest, test_red);
+REGISTER_TEST_COMMAND(red_perf, test_red_perf);
+REGISTER_TEST_COMMAND(red_all, test_red_all);