* [PATCH] test-flow-perf: Enable to build on Windows
@ 2025-08-05 19:59 Andre Muezerie
0 siblings, 0 replies; only message in thread
From: Andre Muezerie @ 2025-08-05 19:59 UTC (permalink / raw)
To: Wisam Jaddo; +Cc: dev, Andre Muezerie
This patch fixes some issues which were preventing this test to be
built on Windows:
- Remove VLAs (not supported by msvc).
- Replace strsep() (which is not natively available on Windows)
with strtok_r().
- Remove the "thousands" separator from printf() calls as it is
not available on Windows.
- Include the test in the Windows build.
Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
app/test-flow-perf/actions_gen.c | 17 +++++++++++++++--
app/test-flow-perf/main.c | 23 ++++++++++++-----------
app/test-flow-perf/meson.build | 6 ------
3 files changed, 27 insertions(+), 19 deletions(-)
diff --git a/app/test-flow-perf/actions_gen.c b/app/test-flow-perf/actions_gen.c
index 54fcbacb98..9d102e3af4 100644
--- a/app/test-flow-perf/actions_gen.c
+++ b/app/test-flow-perf/actions_gen.c
@@ -15,6 +15,7 @@
#include <rte_gtp.h>
#include <rte_gre.h>
#include <rte_geneve.h>
+#include <rte_os_shim.h>
#include "actions_gen.h"
#include "flow_gen.h"
@@ -921,10 +922,19 @@ fill_actions(struct rte_flow_action *actions, uint64_t *flow_actions,
{
struct additional_para additional_para_data;
uint8_t actions_counter = 0;
- uint16_t hairpin_queues[hairpinq];
- uint16_t queues[rx_queues_count];
+ uint16_t *hairpin_queues;
+ uint16_t *queues;
uint16_t i, j;
+ hairpin_queues = calloc(hairpinq, sizeof(uint16_t));
+ if (hairpin_queues == NULL)
+ rte_exit(EXIT_FAILURE, "No Memory available!");
+ queues = calloc(rx_queues_count, sizeof(uint16_t));
+ if (queues == NULL) {
+ free(hairpin_queues);
+ rte_exit(EXIT_FAILURE, "No Memory available!");
+ }
+
for (i = 0; i < rx_queues_count; i++)
queues[i] = i;
@@ -1151,4 +1161,7 @@ fill_actions(struct rte_flow_action *actions, uint64_t *flow_actions,
}
}
actions[actions_counter].type = RTE_FLOW_ACTION_TYPE_END;
+
+ free(queues);
+ free(hairpin_queues);
}
diff --git a/app/test-flow-perf/main.c b/app/test-flow-perf/main.c
index 07ddfe0e46..226501caf9 100644
--- a/app/test-flow-perf/main.c
+++ b/app/test-flow-perf/main.c
@@ -26,7 +26,6 @@
#include <errno.h>
#include <getopt.h>
#include <stdbool.h>
-#include <sys/time.h>
#include <signal.h>
#include <unistd.h>
@@ -36,6 +35,7 @@
#include <rte_ethdev.h>
#include <rte_flow.h>
#include <rte_mtr.h>
+#include <rte_os_shim.h>
#include "config.h"
#include "actions_gen.h"
@@ -601,15 +601,16 @@ static void
read_meter_policy(char *prog, char *arg)
{
char *token;
+ char *saveptr = NULL;
size_t i, j, k;
j = 0;
k = 0;
policy_mtr = true;
- token = strsep(&arg, ":\0");
+ token = arg ? strtok_r(arg, ":", &saveptr) : NULL;
while (token != NULL && j < RTE_COLORS) {
actions_str[j++] = token;
- token = strsep(&arg, ":\0");
+ token = strtok_r(NULL, ":", &saveptr);
}
j = 0;
token = strtok(actions_str[0], ",\0");
@@ -733,7 +734,7 @@ args_parse(int argc, char **argv)
};
RTE_ETH_FOREACH_DEV(i)
- ports_mask |= 1 << i;
+ ports_mask |= RTE_BIT64(i);
for (i = 0; i < RTE_MAX_ETHPORTS; i++)
dst_ports[i] = PORT_ID_DST;
@@ -961,15 +962,15 @@ args_parse(int argc, char **argv)
}
if (strcmp(lgopts[opt_idx].name, "policy-mtr") == 0)
read_meter_policy(argv[0], optarg);
- if (strcmp(lgopts[opt_idx].name,
- "meter-profile") == 0) {
+ if (strcmp(lgopts[opt_idx].name, "meter-profile") == 0) {
i = 0;
- token = strsep(&optarg, ",\0");
+ char *saveptr = NULL;
+ token = strtok_r(optarg, ",", &saveptr);
while (token != NULL && i < sizeof(
meter_profile_values) /
sizeof(uint64_t)) {
meter_profile_values[i++] = atol(token);
- token = strsep(&optarg, ",\0");
+ token = strtok_r(NULL, ",", &saveptr);
}
}
if (strcmp(lgopts[opt_idx].name, "packet-mode") == 0)
@@ -1759,7 +1760,7 @@ packet_per_second_stats(void)
uint64_t tx_delta, rx_delta, drops_delta;
int nr_valid_core = 0;
- sleep(1);
+ rte_delay_us_sleep(US_PER_S);
if (nr_lines) {
char go_up_nr_lines[16];
@@ -1781,7 +1782,7 @@ packet_per_second_stats(void)
tx_delta = li->tx_pkts - oli->tx_pkts;
rx_delta = li->rx_pkts - oli->rx_pkts;
drops_delta = li->tx_drops - oli->tx_drops;
- printf("%6d %'16"PRId64" %'16"PRId64" %'16"PRId64"\n",
+ printf("%6d %16" PRId64 " %16" PRId64 " %16" PRId64 "\n",
i, tx_delta, drops_delta, rx_delta);
total_tx_pkts += tx_delta;
@@ -1793,7 +1794,7 @@ packet_per_second_stats(void)
}
if (nr_valid_core > 1) {
- printf("%6s %'16"PRId64" %'16"PRId64" %'16"PRId64"\n",
+ printf("%6s %16" PRId64 " %16" PRId64 " %16" PRId64 "\n",
"total", total_tx_pkts, total_tx_drops,
total_rx_pkts);
nr_lines += 1;
diff --git a/app/test-flow-perf/meson.build b/app/test-flow-perf/meson.build
index 5758f8d9c6..e101449e32 100644
--- a/app/test-flow-perf/meson.build
+++ b/app/test-flow-perf/meson.build
@@ -1,12 +1,6 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2020 Mellanox Technologies, Ltd
-if is_windows
- build = false
- reason = 'not supported on Windows'
- subdir_done()
-endif
-
sources = files(
'actions_gen.c',
'flow_gen.c',
--
2.50.1.vfs.0.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-08-05 20:00 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-08-05 19:59 [PATCH] test-flow-perf: Enable to build on Windows Andre Muezerie
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).