test-flow-perf: Enable to build on Windows
PATCH 1/1 test-flow-perf: Enable to build on Windows
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.
--- 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(-)
app/test-flow-perf/actions_gen.c +15 -2
@@ -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); }
app/test-flow-perf/main.c +12 -11
@@ -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 ;
app/test-flow-perf/meson.build +0 -6
@@ -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',
Signature · 1 line
2.50.1.vfs.0.0
Hello,
Quoted 9 lines · Andre Muezerie
This patch fixes some issues which were preventing this test to be built on Windows:
- Remove VLAs (not supported by msvc).
- Replacestrsep()(which is not natively available on Windows) withstrtok_r().
- Remove the "thousands" separator fromprintf()calls as it is not available on Windows.
Can we use rte_size_to_str() instead?
Quoted 3 lines
- Include the test in the Windows build.
Signed-off-by Andre Muezerie <[email protected]>
Otherwise it lgtm.
Signature · 1 line
David Marchand
Quoted 8 lines · David Marchand
Hello,
Quoted 4 lines · Andre Muezerie
This patch fixes some issues which were preventing this test to be built on Windows:
Quoted 8 lines
Quoted 5 lines
- Remove VLAs (not supported by msvc).
- Replacestrsep()(which is not natively available on Windows) withstrtok_r().
- Remove the "thousands" separator fromprintf()calls as it is not available on Windows.Can we use
rte_size_to_str()instead?
I considered doing that, but I thought that since the app is printing deltas it could be better to print the exact numbers instead of some approximation like "1.02 k" which could possibly make debugging harder.
If you strongly believe that rte_size_to_str() should indeed be used here I can make the change.
What are your thoughts about this?
Andre Muezerie
Quoted 9 lines
Quoted 3 lines
- Include the test in the Windows build.
Signed-off-by Andre Muezerie <[email protected]>Otherwise it lgtm.
Signature · 1 line
David Marchand
Hello,
Quoted 19 lines · Andre Muezerie
Quoted 8 lines · David Marchand
Hello,
Quoted 4 lines · Andre Muezerie
This patch fixes some issues which were preventing this test to be built on Windows:
Quoted 8 lines
Quoted 5 lines
- Remove VLAs (not supported by msvc).
- Replacestrsep()(which is not natively available on Windows) withstrtok_r().
- Remove the "thousands" separator fromprintf()calls as it is not available on Windows.Can we use
rte_size_to_str()instead?
Quoted 8 lines
I considered doing that, but I thought that since the app is printing deltas it could be better to print the exact numbers instead of some approximation like "1.02 k" which could possibly make debugging harder.
If you strongly believe that
rte_size_to_str()should indeed be used here I can make the change.What are your thoughts about this?
No strong opinion: just that we introduced this rte_size_to_str() for this "thousands" separator stuff.
I don't mind merging as is, and I did not hear from Wisam, so I guess this is fine.
Signature · 1 line
David Marchand
Quoted 30 lines · David Marchand
Hello,
Quoted 26 lines · Andre Muezerie
Quoted 8 lines · David Marchand
Hello,
Quoted 4 lines · Andre Muezerie
This patch fixes some issues which were preventing this test to be built on Windows:
Quoted 8 lines
Quoted 5 lines
- Remove VLAs (not supported by msvc).
- Replacestrsep()(which is not natively available on Windows) withstrtok_r().
- Remove the "thousands" separator fromprintf()calls as it is not available on Windows.Can we use
rte_size_to_str()instead?I considered doing that, but I thought that since the app is printing deltas it could be better to print the exact numbers instead of some approximation like "1.02 k" which could possibly make debugging harder.
If you strongly believe that
rte_size_to_str()should indeed be used here I can make the change.
Quoted 10 lines
Quoted 1 line
What are your thoughts about this?
No strong opinion: just that we introduced this
rte_size_to_str()for this "thousands" separator stuff.
I don't mind merging as is, and I did not hear from Wisam, so I guess this is fine.Signature · 1 line
David Marchand
I don't have a strong opinion on this either, but I remember that when rte_size_to_str() got introduced one of the reviewers mentioned that while the new API would be nice for # of bytes or # of packets transmitted, they would prefer to see the exact number of bytes for the deltas. That's the reason I took this approach. I'm assuming others are fine with this too if we don't hear back.
Andre Muezerie
David Marchand
AppliedQuoted 4 lines · Andre Muezerie
This patch fixes some issues which were preventing this test to be built on Windows:
Quoted 8 lines
- Remove VLAs (not supported by msvc).
- Replacestrsep()(which is not natively available on Windows) withstrtok_r().
- Remove the "thousands" separator fromprintf()calls as it is not available on Windows.
- Include the test in the Windows build.Signed-off-by Andre Muezerie <[email protected]>
Applied, thanks.
Signature · 1 line
David Marchand