enable "app" to be compiled with MSVC
cover enable "app" to be compiled with MSVC
This series fixes many issues that prevent the "app" directory from being compiled with MSVC.
Andre Muezerie (10):
eal: add workaround for __builtin_constant_p
test_alarm: avoid warning about different qualifiers
test-pmd: fix printf format string mismatch
test-pmd: do explicit 64-bit shift to avoid implicit conversion
test-pmd: avoid undefined behavior
test-pmd: avoid non-constant initializer
test-pmd: don't return value from void function
test-pmd: declare lcore_count atomic when using C11 memory model
test: add workaround for __builtin_constant_p in test_memcpy_perf
app: enable app directory to be compiled with MSVC
app/meson.build | 4 -- app/test-pmd/cmdline.c | 19 +++-- app/test-pmd/cmdline_flow.c | 22 +++--- app/test-pmd/csumonly.c | 12 ++-- app/test-pmd/meson.build | 4 +- app/test-pmd/testpmd.c | 2 +- app/test-pmd/util.c | 2 +- app/test/test_alarm.c | 12 ++-- app/test/test_memcpy_perf.c | 106 ++++++++++++++-------------- app/test/test_ring_perf.c | 6 +- lib/eal/include/generic/rte_pause.h | 2 +- lib/eal/include/rte_common.h | 12 ++++ 12 files changed, 114 insertions(+), 89 deletions(-)
--
2.47.2.vfs.0.1
PATCH 1/10 eal: add workaround for __builtin_constant_p
There's no MSVC equivalent for compiler extension __builtin_constant_p. EAL already had __rte_constant which was used as a first attempt to workaround __builtin_constant_p when using MSVC. However, there are pieces of code that would benefit from being able to provide a default value to be used instead of it being always 0 like how it was done by __rte_constant.
A new macro is added here allowing such default to be provided by the caller.
--- lib/eal/include/generic/rte_pause.h | 2 +- lib/eal/include/rte_common.h | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-)
lib/eal/include/generic/rte_pause.h +1 -1
@@ -130,7 +130,7 @@ rte_wait_until_equal_64(volatile uint64_t *addr, uint64_t expected,* rte_memory_order_acquire and rte_memory_order_relaxed. */ #define RTE_WAIT_UNTIL_MASKED (addr, mask, cond, expected, memorder) do { \ - RTE_BUILD_BUG_ON(!__builtin_constant_p(memorder)); \ + RTE_BUILD_BUG_ON(!__rte_constant_with_default(memorder, 1)); \ RTE_BUILD_BUG_ON((memorder) != rte_memory_order_acquire && \ (memorder) != rte_memory_order_relaxed); \ typeof(*(addr)) expected_value = (expected); \
lib/eal/include/rte_common.h +12 -0
@@ -50,6 +50,18 @@ extern "C" {#define __rte_constant (e) __extension__(__builtin_constant_p(e))#endif +/** +* Determine if an expression's value is constant at compile time. +* All compilers except MSVC will return 1 if the first argument is a +* compile-time constant, and 0 otherwise. MSVC will just return the second +* argument as a default value. +*/ +#ifdef RTE_TOOLCHAIN_MSVC +#define __rte_constant_with_default (e, def) def +#else +#define __rte_constant_with_default (e, def) __extension__(__builtin_constant_p(e)) +#endif +/* * RTE_TOOLCHAIN_GCC is defined if the target is built with GCC, * while a host application (like pmdinfogen) may have another compiler.
Signature · 1 line
2.47.2.vfs.0.1
PATCH 2/10 test_alarm: avoid warning about different qualifiers
In reply to Andre MuezerieCompiling with MSVC results in the warning below:
app/test/test_alarm.c(54): warning C4090: 'function':
different '_Atomic' qualifiers
The fix is to use a macro to explicitly drop the qualifier.
--- app/test/test_alarm.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
app/test/test_alarm.c +6 -6
@@ -51,12 +51,12 @@ test_alarm(void) "Expected rte_eal_alarm_cancel to fail with null callback parameter");/* check if can set a alarm for one second */ -TEST_ASSERT_SUCCESS (rte_eal_alarm_set (US_PER_SEC , test_alarm_callback, &triggered), -"Setting one second alarm failed" ); +TEST_ASSERT_SUCCESS (rte_eal_alarm_set (US_PER_SEC , test_alarm_callback, +RTE_PTR_UNQUAL (&triggered)),"Setting one second alarm failed" );/* set a longer alarm that will be canceled. */ -TEST_ASSERT_SUCCESS (rte_eal_alarm_set (10 *US_PER_SEC , test_alarm_callback, &later), -"Setting ten second alarm failed" ); +TEST_ASSERT_SUCCESS (rte_eal_alarm_set (10 *US_PER_SEC , test_alarm_callback, +RTE_PTR_UNQUAL (&later)),"Setting ten second alarm failed" );/* wait for alarm to happen */ while (rte_atomic_load_explicit (&triggered, rte_memory_order_acquire) == false)
@@ -65,11 +65,11 @@ test_alarm(void)TEST_ASSERT (!rte_atomic_load_explicit (&later, rte_memory_order_acquire),"Only one alarm should have fired." ); - ret =rte_eal_alarm_cancel (test_alarm_callback, &triggered); + ret =rte_eal_alarm_cancel (test_alarm_callback,RTE_PTR_UNQUAL (&triggered));TEST_ASSERT (ret ==0 && rte_errno ==ENOENT ,"Canceling alarm after run ret %d: %s" , ret,rte_strerror (rte_errno)); - ret =rte_eal_alarm_cancel (test_alarm_callback, &later); + ret =rte_eal_alarm_cancel (test_alarm_callback,RTE_PTR_UNQUAL (&later));TEST_ASSERT (ret ==1 ,"Canceling ten second alarm failed %d: %s" , ret,rte_strerror (rte_errno));
Signature · 1 line
2.47.2.vfs.0.1
PATCH 3/10 test-pmd: fix printf format string mismatch
In reply to Andre MuezerieCompiling with MSVC results in warnings like the one below:
app/test-pmd/csumonly.c(1085): warning C4477: 'printf' : format string
'%d' requires an argument of type 'int',
but variadic argument 1 has type 'uint64_t'
--- app/test-pmd/csumonly.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
app/test-pmd/csumonly.c +6 -6
@@ -1070,7 +1070,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) info.l2_len,rte_be_to_cpu_16 (info.ethertype), info.l3_len, info.l4_proto, info.l4_len, buf);if (rx_ol_flags &RTE_MBUF_F_RX_LRO ) -printf ("rx: m->lro_segsz=%u\n" , m->tso_segsz); +printf ("rx: m->lro_segsz=%d\n" , (int )m->tso_segsz);if (info.is_tunnel ==1 ) printf("rx: outer_l2_len=%d outer_ethertype=%x " "outer_l3_len=%d\n", info.outer_l2_len,
@@ -1084,7 +1084,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) info.tso_segsz != 0)printf ("tx: m->l2_len=%d m->l3_len=%d " "m->l4_len=%d\n" , - m->l2_len, m->l3_len, m->l4_len); + (int )m->l2_len, (int )m->l3_len, (int )m->l4_len);if (info.is_tunnel ==1 ) { if ((tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) ||
@@ -1093,17 +1093,17 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) (tx_ol_flags & RTE_MBUF_F_TX_OUTER_IPV6))printf ("tx: m->outer_l2_len=%d " "m->outer_l3_len=%d\n" , - m->outer_l2_len, - m->outer_l3_len); + (int )m->outer_l2_len, + (int )m->outer_l3_len);if (info.tunnel_tso_segsz !=0 && (m->ol_flags & (RTE_MBUF_F_TX_TCP_SEG |RTE_MBUF_F_TX_UDP_SEG )))printf ("tx: m->tso_segsz=%d\n" , - m->tso_segsz); + (int )m->tso_segsz); }else if (info.tso_segsz !=0 && (m->ol_flags & (RTE_MBUF_F_TX_TCP_SEG |RTE_MBUF_F_TX_UDP_SEG ))) -printf ("tx: m->tso_segsz=%d\n" , m->tso_segsz); +printf ("tx: m->tso_segsz=%d\n" , (int )m->tso_segsz);rte_get_tx_ol_flag_list (m->ol_flags, buf,sizeof (buf));printf ("tx: flags=%s" , buf);printf ("\n" );
Signature · 1 line
2.47.2.vfs.0.1
PATCH 4/10 test-pmd: do explicit 64-bit shift to avoid implicit conversion
In reply to Andre MuezerieCompiling with MSVC results in warnings like the one below:
app/test-pmd/util.c(201): warning C4334: '<<': result of 32-bit shift
implicitly converted to 64 bits (was 64-bit shift intended?)
--- app/test-pmd/cmdline.c | 4 ++-- app/test-pmd/testpmd.c | 2 +- app/test-pmd/util.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
app/test-pmd/cmdline.c +2 -2
@@ -12632,11 +12632,11 @@ cmd_config_dynf_specific_parsed(void *parsed_result, } old_port_flags = ports[res->port_id].mbuf_dynf;if (!strcmp (res->value,"set" )) { - ports[res->port_id].mbuf_dynf |=1UL << flag; + ports[res->port_id].mbuf_dynf |=RTE_BIT64 (flag);if (old_port_flags ==0 )add_tx_dynf_callback (res->port_id); }else { - ports[res->port_id].mbuf_dynf &= ~(1UL << flag); + ports[res->port_id].mbuf_dynf &= ~RTE_BIT64 (flag);if (ports[res->port_id].mbuf_dynf ==0 )remove_tx_dynf_callback (res->port_id); }
app/test-pmd/testpmd.c +1 -1
@@ -4152,7 +4152,7 @@ get_eth_dcb_conf(struct rte_eth_conf *eth_conf, enum dcb_mode_enable dcb_mode,for (i =0 ; i < vmdq_rx_conf->nb_pool_maps; i++) { vmdq_rx_conf->pool_map[i].vlan_id = vlan_tags[i]; vmdq_rx_conf->pool_map[i].pools = -1 << (i % vmdq_rx_conf->nb_queue_pools); +RTE_BIT64 (i % vmdq_rx_conf->nb_queue_pools); }for (i =0 ; i <RTE_ETH_DCB_NUM_USER_PRIORITIES ; i++) { vmdq_rx_conf->dcb_tc[i] = i % num_tcs;
app/test-pmd/util.c +1 -1
@@ -201,7 +201,7 @@ dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[],MKDUMPSTR (print_buf, buf_size, cur_len," - dynf %s: %d" , dynf_names[dynf_index], - !!(ol_flags & (1UL << dynf_index))); + !!(ol_flags &RTE_BIT64 (dynf_index))); }if (mb->packet_type) {rte_get_ptype_name (mb->packet_type, buf,sizeof (buf));
Signature · 1 line
2.47.2.vfs.0.1
PATCH 5/10 test-pmd: avoid undefined behavior
In reply to Andre MuezerieCompiling with MSVC results in warnings like below:
app/test-pmd/cmdline.c(9023): warning C5101: use of preprocessor
directive in function-like macro argument list is undefined behavior
--- app/test-pmd/cmdline.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
app/test-pmd/cmdline.c +13 -2
@@ -9011,6 +9011,18 @@ static void cmd_dump_parsed(void *parsed_result, } static cmdline_parse_token_string_t cmd_dump_dump = +#ifdef RTE_EXEC_ENV_WINDOWS + TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump, +"dump_physmem#" +"dump_memzone#" +"dump_socket_mem#" +"dump_struct_sizes#" +"dump_ring#" +"dump_mempool#" +"dump_devargs#" +"dump_lcores#" + "dump_log_types"); +#else TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,"dump_physmem#" "dump_memzone#"
@@ -9020,10 +9032,9 @@ static cmdline_parse_token_string_t cmd_dump_dump ="dump_mempool#" "dump_devargs#" "dump_lcores#" -#ifndef RTE_EXEC_ENV_WINDOWS"dump_trace#" -#endif "dump_log_types"); +#endif static cmdline_parse_inst_t cmd_dump = { .f = cmd_dump_parsed,/* function to call */
Signature · 1 line
2.47.2.vfs.0.1
PATCH 7/10 test-pmd: don't return value from void function
In reply to Andre MuezerieCompiling with MSVC results in the warning below:
app/test-pmd/cmdline_flow.c(13964): warning C4098: 'cmd_set_raw_parsed':
'void' function returning a value
--- app/test-pmd/cmdline_flow.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
app/test-pmd/cmdline_flow.c +8 -4
@@ -13952,11 +13952,15 @@ cmd_set_raw_parsed(const struct buffer *in)int gtp_psc =-1 ;/* GTP PSC option index. */ const void *src_spec; -if (in->command ==SET_SAMPLE_ACTIONS ) -return cmd_set_raw_parsed_sample (in); +if (in->command ==SET_SAMPLE_ACTIONS ) { +cmd_set_raw_parsed_sample (in); +return ; + }else if (in->command ==SET_IPV6_EXT_PUSH || - in->command ==SET_IPV6_EXT_REMOVE ) -return cmd_set_ipv6_ext_parsed (in); + in->command ==SET_IPV6_EXT_REMOVE ) { +cmd_set_ipv6_ext_parsed (in); +return ; + }RTE_ASSERT (in->command ==SET_RAW_ENCAP || in->command ==SET_RAW_DECAP );if (in->command ==SET_RAW_ENCAP ) {
Signature · 1 line
2.47.2.vfs.0.1
PATCH 6/10 test-pmd: avoid non-constant initializer
In reply to Andre MuezerieCompiling with MSVC results in errors like the one below:
app/test-pmd/cmdline_flow.c(8819): error C2099: initializer
is not a constant
--- app/test-pmd/cmdline_flow.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
app/test-pmd/cmdline_flow.c +3 -7
@@ -8812,8 +8812,6 @@ parse_vc_spec(struct context *ctx, const struct token *token,return -1 ;/* Parse parameter types. */ switch (ctx->curr) { -static const enum index prefix[] =NEXT_ENTRY (COMMON_PREFIX ); -case ITEM_PARAM_IS : index =0 ; objmask =1 ;
@@ -8828,7 +8826,7 @@ parse_vc_spec(struct context *ctx, const struct token *token,/* Modify next token to expect a prefix. */ if (ctx->next_num <2 )return -1 ; - ctx->next[ctx->next_num -2 ] = prefix; + ctx->next[ctx->next_num -2 ] =NEXT_ENTRY (COMMON_PREFIX );/* Fall through. */ case ITEM_PARAM_MASK : index =2 ;
@@ -9270,7 +9268,6 @@ parse_vc_action_rss_type(struct context *ctx, const struct token *token, const char *str, unsigned int len, void *buf, unsigned int size) { - static const enum index next[] = NEXT_ENTRY(ACTION_RSS_TYPE); struct action_rss_data *action_rss_data;unsigned int i;
@@ -9296,7 +9293,7 @@ parse_vc_action_rss_type(struct context *ctx, const struct token *token,/* Repeat token. */ if (ctx->next_num ==RTE_DIM (ctx->next))return -1 ; - ctx->next[ctx->next_num++] = next; + ctx->next[ctx->next_num++] =NEXT_ENTRY (ACTION_RSS_TYPE );if (!ctx->object)return len; action_rss_data = ctx->object;
@@ -9314,7 +9311,6 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token, const char *str, unsigned int len, void *buf, unsigned int size) { - static const enum index next[] = NEXT_ENTRY(ACTION_RSS_QUEUE); struct action_rss_data *action_rss_data;const struct arg *arg;int ret;
@@ -9347,7 +9343,7 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token,/* Repeat token. */ if (ctx->next_num ==RTE_DIM (ctx->next))return -1 ; - ctx->next[ctx->next_num++] = next; + ctx->next[ctx->next_num++] =NEXT_ENTRY (ACTION_RSS_QUEUE ); end:if (!ctx->object)return len;
Signature · 1 line
2.47.2.vfs.0.1
PATCH 8/10 test-pmd: declare lcore_count atomic when using C11 memory model
In reply to Andre MuezerieCompiling with MSVC results in the error below:
app/test/test_ring_perf.c(197): error C7712: address argument to atomic
operation must be a pointer to an atomic integer, 'volatile unsigned int *' is not valid
The fix is to mark lcore_count as atomic when using C11 memory model.
--- app/test/test_ring_perf.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
app/test/test_ring_perf.c +5 -1
@@ -34,7 +34,11 @@ struct lcore_pair {unsigned c1, c2; }; -static volatile unsigned lcore_count =0 ; +#ifdef RTE_USE_C11_MEM_MODEL +static RTE_ATOMIC (unsigned int ) lcore_count; +#else +static volatile unsigned int lcore_count; +#endif static void test_ring_print_test_string(unsigned int api_type, int esize,
Signature · 1 line
2.47.2.vfs.0.1
PATCH 9/10 test: add workaround for __builtin_constant_p in test_memcpy_perf
In reply to Andre MuezerieThere's no MSVC equivalent for compiler extension __builtin_constant_p, so a workaround is needed.
--- app/test/test_memcpy_perf.c | 106 ++++++++++++++++++------------------ 1 file changed, 53 insertions(+), 53 deletions(-)
app/test/test_memcpy_perf.c +53 -53
@@ -167,66 +167,66 @@ do_uncached_write(uint8_t *dst, int is_dst_cached,* Run a single memcpy performance test. This is a macro to ensure that if * the "size" parameter is a constant it won't be converted to a variable. */ -#define SINGLE_PERF_TEST (dst, is_dst_cached, dst_uoffset, \ - src, is_src_cached, src_uoffset, size) \ -do { \ - unsigned int iter, t; \ - size_t dst_addrs[TEST_BATCH_SIZE], src_addrs[TEST_BATCH_SIZE]; \ - uint64_t start_time, total_time = 0; \ - uint64_t total_time2 = 0; \ - for (iter = 0; iter < (TEST_ITERATIONS / TEST_BATCH_SIZE); iter++) { \ - fill_addr_arrays(dst_addrs, is_dst_cached, dst_uoffset, \ - src_addrs, is_src_cached, src_uoffset); \ - start_time = rte_rdtsc(); \ - for (t = 0; t < TEST_BATCH_SIZE; t++) \ - rte_memcpy(dst+dst_addrs[t], src+src_addrs[t], size); \ - total_time += rte_rdtsc() - start_time; \ - } \ - for (iter = 0; iter < (TEST_ITERATIONS / TEST_BATCH_SIZE); iter++) { \ - fill_addr_arrays(dst_addrs, is_dst_cached, dst_uoffset, \ - src_addrs, is_src_cached, src_uoffset); \ - start_time = rte_rdtsc(); \ - for (t = 0; t < TEST_BATCH_SIZE; t++) \ - memcpy(dst+dst_addrs[t], src+src_addrs[t], size); \ - total_time2 += rte_rdtsc() - start_time; \ - } \ - printf("%3.0f -", (double)total_time / TEST_ITERATIONS); \ - printf("%3.0f", (double)total_time2 / TEST_ITERATIONS); \ - printf("(%6.2f%%) ", ((double)total_time - total_time2)*100/total_time2); \ +#define SINGLE_PERF_TEST (dst, is_dst_cached, dst_uoffset, \ + src, is_src_cached, src_uoffset, size) \ +do { \ + unsigned int iter, t; \ + size_t dst_addrs[TEST_BATCH_SIZE], src_addrs[TEST_BATCH_SIZE]; \ + uint64_t start_time, total_time = 0; \ + uint64_t total_time2 = 0; \ + for (iter = 0; iter < (TEST_ITERATIONS / TEST_BATCH_SIZE); iter++) { \ + fill_addr_arrays(dst_addrs, is_dst_cached, dst_uoffset, \ + src_addrs, is_src_cached, src_uoffset); \ + start_time = rte_rdtsc(); \ + for (t = 0; t < TEST_BATCH_SIZE; t++) \ + rte_memcpy(dst+dst_addrs[t], src+src_addrs[t], size); \ + total_time += rte_rdtsc() - start_time; \ + } \ + for (iter = 0; iter < (TEST_ITERATIONS / TEST_BATCH_SIZE); iter++) { \ + fill_addr_arrays(dst_addrs, is_dst_cached, dst_uoffset, \ + src_addrs, is_src_cached, src_uoffset); \ + start_time = rte_rdtsc(); \ + for (t = 0; t < TEST_BATCH_SIZE; t++) \ + memcpy(dst+dst_addrs[t], src+src_addrs[t], size); \ + total_time2 += rte_rdtsc() - start_time; \ + } \ + printf("%3.0f -", (double)total_time / TEST_ITERATIONS); \ + printf("%3.0f", (double)total_time2 / TEST_ITERATIONS); \ + printf("(%6.2f%%) ", ((double)total_time - total_time2)*100/total_time2); \ } while (0)/* Run aligned memcpy tests for each cached/uncached permutation */ -#define ALL_PERF_TESTS_FOR_SIZE (n) \ -do { \ - if (__builtin_constant_p(n)) \ - printf("\nC%6u", (unsigned)n); \ - else \ - printf("\n%7u", (unsigned)n); \ - SINGLE_PERF_TEST(small_buf_write, 1, 0, small_buf_read, 1, 0, n); \ - SINGLE_PERF_TEST(large_buf_write, 0, 0, small_buf_read, 1, 0, n); \ - SINGLE_PERF_TEST(small_buf_write, 1, 0, large_buf_read, 0, 0, n); \ - SINGLE_PERF_TEST(large_buf_write, 0, 0, large_buf_read, 0, 0, n); \ +#define ALL_PERF_TESTS_FOR_SIZE (n, def) \ +do { \ + if (__rte_constant_with_default(n, def)) \ + printf("\nC%6u", (unsigned int)n); \ + else \ + printf("\n%7u", (unsigned int)n); \ + SINGLE_PERF_TEST(small_buf_write, 1, 0, small_buf_read, 1, 0, n); \ + SINGLE_PERF_TEST(large_buf_write, 0, 0, small_buf_read, 1, 0, n); \ + SINGLE_PERF_TEST(small_buf_write, 1, 0, large_buf_read, 0, 0, n); \ + SINGLE_PERF_TEST(large_buf_write, 0, 0, large_buf_read, 0, 0, n); \ } while (0)/* Run unaligned memcpy tests for each cached/uncached permutation */ -#define ALL_PERF_TESTS_FOR_SIZE_UNALIGNED (n) \ -do { \ - if (__builtin_constant_p(n)) \ - printf("\nC%6u", (unsigned)n); \ - else \ - printf("\n%7u", (unsigned)n); \ - SINGLE_PERF_TEST(small_buf_write, 1, 1, small_buf_read, 1, 5, n); \ - SINGLE_PERF_TEST(large_buf_write, 0, 1, small_buf_read, 1, 5, n); \ - SINGLE_PERF_TEST(small_buf_write, 1, 1, large_buf_read, 0, 5, n); \ - SINGLE_PERF_TEST(large_buf_write, 0, 1, large_buf_read, 0, 5, n); \ +#define ALL_PERF_TESTS_FOR_SIZE_UNALIGNED (n, def) \ +do { \ + if (__rte_constant_with_default(n, def)) \ + printf("\nC%6u", (unsigned int)n); \ + else \ + printf("\n%7u", (unsigned int)n); \ + SINGLE_PERF_TEST(small_buf_write, 1, 1, small_buf_read, 1, 5, n); \ + SINGLE_PERF_TEST(large_buf_write, 0, 1, small_buf_read, 1, 5, n); \ + SINGLE_PERF_TEST(small_buf_write, 1, 1, large_buf_read, 0, 5, n); \ + SINGLE_PERF_TEST(large_buf_write, 0, 1, large_buf_read, 0, 5, n); \ } while (0)/* Run memcpy tests for constant length */ -#define ALL_PERF_TEST_FOR_CONSTANT \ -do { \ - TEST_CONSTANT(6U); TEST_CONSTANT(64U); TEST_CONSTANT(128U); \ - TEST_CONSTANT(192U); TEST_CONSTANT(256U); TEST_CONSTANT(512U); \ - TEST_CONSTANT(768U); TEST_CONSTANT(1024U); TEST_CONSTANT(1536U); \ +#define ALL_PERF_TEST_FOR_CONSTANT \ +do { \ + TEST_CONSTANT(6U, 1); TEST_CONSTANT(64U, 1); TEST_CONSTANT(128U, 1); \ + TEST_CONSTANT(192U, 1); TEST_CONSTANT(256U, 1); TEST_CONSTANT(512U, 1); \ + TEST_CONSTANT(768U, 1); TEST_CONSTANT(1024U, 1); TEST_CONSTANT(1536U, 1); \ } while (0)/* Run all memcpy tests for aligned constant cases */
@@ -253,7 +253,7 @@ perf_test_variable_aligned(void) {unsigned i;for (i =0 ; i <RTE_DIM (buf_sizes); i++) { -ALL_PERF_TESTS_FOR_SIZE ((size_t )buf_sizes[i]); +ALL_PERF_TESTS_FOR_SIZE (buf_sizes[i],0 ); } }
@@ -263,7 +263,7 @@ perf_test_variable_unaligned(void) {unsigned i;for (i =0 ; i <RTE_DIM (buf_sizes); i++) { -ALL_PERF_TESTS_FOR_SIZE_UNALIGNED ((size_t )buf_sizes[i]); +ALL_PERF_TESTS_FOR_SIZE_UNALIGNED (buf_sizes[i],0 ); } }
Signature · 1 line
2.47.2.vfs.0.1
Re: [PATCH 01/10] eal: add workaround for __builtin_constant_p
In reply to Andre MuezerieQuoted 11 lines · On Tue, 11 Feb 2025 14:01:57 -0800 Andre Muezerie…
There's no MSVC equivalent for compiler extension
__builtin_constant_p. EAL already had__rte_constantwhich was used as a first attempt to workaround__builtin_constant_pwhen using MSVC. However, there are pieces of code that would benefit from being able to provide a default value to be used instead of it being always 0 like how it was done by__rte_constant.A new macro is added here allowing such default to be provided by the caller.
Signed-off-by Andre Muezerie <[email protected]>
There is a hack way of determining if expression is constant using sizeof tricks, maybe that would be ideal solution?
Re: [PATCH 03/10] test-pmd: fix printf format string mismatch
In reply to Andre MuezerieQuoted 8 lines · On Tue, 11 Feb 2025 14:01:59 -0800 Andre Muezerie…
Compiling with MSVC results in warnings like the one below:
app/test-pmd/csumonly.c(1085): warning C4477: 'printf' : format string
'%d' requires an argument of type 'int',
but variadic argument 1 has type 'uint64_t'Signed-off-by Andre Muezerie <[email protected]>---
In general, DPDK code prefers to use inttypes.h which has PRIu64 macro for this.
Re: [PATCH 08/10] test-pmd: declare lcore_count atomic when using C11 memory model
In reply to Andre MuezerieQuoted 9 lines · On Tue, 11 Feb 2025 14:02:04 -0800 Andre Muezerie…
Compiling with MSVC results in the error below:
app/test/test_ring_perf.c(197): error C7712: address argument to atomic
operation must be a pointer to an atomic integer, 'volatile unsigned int *' is not validThe fix is to mark
lcore_countas atomic when using C11 memory model.Signed-off-by Andre Muezerie <[email protected]>
Prefer using RTE_ATOMIC() all teh time now.
Re: [PATCH 09/10] test: add workaround for __builtin_constant_p in test_memcpy_perf
In reply to Andre MuezerieQuoted 4 lines · On Tue, 11 Feb 2025 14:02:05 -0800 Andre Muezerie…
There's no MSVC equivalent for compiler extension
__builtin_constant_p, so a workaround is needed.Signed-off-by Andre Muezerie <[email protected]>
Prefer that __rte_constant worked on all platforms, but template code is hard to maintain.
Re: [PATCH 01/10] eal: add workaround for __builtin_constant_p
In reply to Andre MuezerieQuoted 11 lines · Andre Muezerie
There's no MSVC equivalent for compiler extension
__builtin_constant_p. EAL already had__rte_constantwhich was used as a first attempt to workaround__builtin_constant_pwhen using MSVC. However, there are pieces of code that would benefit from being able to provide a default value to be used instead of it being always 0 like how it was done by__rte_constant.A new macro is added here allowing such default to be provided by the caller.
Signed-off-by Andre Muezerie <[email protected]>
Re: [PATCH 02/10] test_alarm: avoid warning about different qualifiers
In reply to Andre MuezerieQuoted 8 lines · Andre Muezerie
Compiling with MSVC results in the warning below:
app/test/test_alarm.c(54): warning C4090: 'function':
different '_Atomic' qualifiersThe fix is to use a macro to explicitly drop the qualifier.
Signed-off-by Andre Muezerie <[email protected]>
Re: [PATCH 03/10] test-pmd: fix printf format string mismatch
In reply to Andre MuezerieQuoted 7 lines · Andre Muezerie
Compiling with MSVC results in warnings like the one below:
app/test-pmd/csumonly.c(1085): warning C4477: 'printf' : format string
'%d' requires an argument of type 'int',
but variadic argument 1 has type 'uint64_t'Signed-off-by Andre Muezerie <[email protected]>
Re: [PATCH 04/10] test-pmd: do explicit 64-bit shift to avoid implicit conversion
In reply to Andre MuezerieQuoted 6 lines · Andre Muezerie
Compiling with MSVC results in warnings like the one below:
app/test-pmd/util.c(201): warning C4334: '<<': result of 32-bit shift
implicitly converted to 64 bits (was 64-bit shift intended?)Signed-off-by Andre Muezerie <[email protected]>
Re: [PATCH 05/10] test-pmd: avoid undefined behavior
In reply to Andre MuezerieQuoted 6 lines · Andre Muezerie
Compiling with MSVC results in warnings like below:
app/test-pmd/cmdline.c(9023): warning C5101: use of preprocessor
directive in function-like macro argument list is undefined behaviorSigned-off-by Andre Muezerie <[email protected]>
Re: [PATCH 06/10] test-pmd: avoid non-constant initializer
In reply to Andre MuezerieQuoted 6 lines · Andre Muezerie
Compiling with MSVC results in errors like the one below:
app/test-pmd/cmdline_flow.c(8819): error C2099: initializer
is not a constantSigned-off-by Andre Muezerie <[email protected]>
Re: [PATCH 07/10] test-pmd: don't return value from void function
In reply to Andre MuezerieQuoted 6 lines · Andre Muezerie
Compiling with MSVC results in the warning below:
app/test-pmd/cmdline_flow.c(13964): warning C4098: '
cmd_set_raw_parsed':
'void' function returning a valueSigned-off-by Andre Muezerie <[email protected]>
Re: [PATCH 08/10] test-pmd: declare lcore_count atomic when using C11 memory model
In reply to Andre MuezerieQuoted 9 lines · Andre Muezerie
Compiling with MSVC results in the error below:
app/test/test_ring_perf.c(197): error C7712: address argument to atomic
operation must be a pointer to an atomic integer, 'volatile unsigned int *' is not validThe fix is to mark
lcore_countas atomic when using C11 memory model.Signed-off-by Andre Muezerie <[email protected]>
Re: [PATCH 08/10] test-pmd: declare lcore_count atomic when using C11 memory model
In reply to Stephen HemmingerQuoted 9 lines · Stephen Hemminger
Quoted 6 lines · On Tue, 11 Feb 2025 14:02:04 -0800 Andre Muezerie…
Compiling with MSVC results in the error below:
app/test/test_ring_perf.c(197): error C7712: address argument to atomic
operation must be a pointer to an atomic integer, 'volatile unsigned int *' is not valid
Quoted 5 lines
Quoted 3 lines
The fix is to mark
lcore_countas atomic when using C11 memory model.Signed-off-by Andre Muezerie <[email protected]>Prefer using
RTE_ATOMIC()all teh time now.
You mean even when not explicitly using the C11 model, right?
Re: [PATCH 09/10] test: add workaround for __builtin_constant_p in test_memcpy_perf
In reply to Stephen HemmingerQuoted 10 lines · Stephen Hemminger
Quoted 4 lines · On Tue, 11 Feb 2025 14:02:05 -0800 Andre Muezerie…
There's no MSVC equivalent for compiler extension
__builtin_constant_p, so a workaround is needed.Signed-off-by Andre Muezerie <[email protected]>Prefer that
__rte_constantworked on all platforms, but template code is hard to maintain.
I'm not a huge fan of __rte_constant_with_default either. Here are some thoughts about it:
In test_memcpy_perf we could get rid of __builtin_constant_p or similar macros and just use the second argument (def) I'm passing to __rte_constant_with_default as the condition in the if() statement. I only used __rte_constant_with_default to keep the source code practically the same when using non-msvc compilers. But I don't see advantages beyond that, other than not having to pass that second parameter (def), which now we have to anyways.
__rte_constant_with_default is needed though in the first patch of this series, unless we decide to remove that extra check where it is being used.
Quoted 16 lines · Andre Muezerie
This series fixes many issues that prevent the "app" directory from being compiled with MSVC.
Andre Muezerie (10):
eal: add workaround for__builtin_constant_p
test_alarm: avoid warning about different qualifiers
test-pmd: fix printf format string mismatch
test-pmd: do explicit 64-bit shift to avoid implicit conversion
test-pmd: avoid undefined behavior
test-pmd: avoid non-constant initializer
test-pmd: don't return value from void function
test-pmd: declarelcore_countatomic when using C11 memory model
test: add workaround for__builtin_constant_pintest_memcpy_perf
app: enable app directory to be compiled with MSVC
Quoted 13 lines
app/meson.build | 4 -- app/test-pmd/cmdline.c | 19 +++-- app/test-pmd/cmdline_flow.c | 22 +++--- app/test-pmd/csumonly.c | 12 ++-- app/test-pmd/meson.build | 4 +- app/test-pmd/testpmd.c | 2 +- app/test-pmd/util.c | 2 +- app/test/test_alarm.c | 12 ++-- app/test/test_memcpy_perf.c | 106 ++++++++++++++-------------- app/test/test_ring_perf.c | 6 +- lib/eal/include/generic/rte_pause.h | 2 +- lib/eal/include/rte_common.h | 12 ++++ 12 files changed, 114 insertions(+), 89 deletions(-)
The last patch of the series was not received on the ml. This prevents CI from testing it.
Please resubmit the whole series.
Thanks.
Signature · 1 line
David Marchand
PATCH v2 3/10 test-pmd: fix printf format string mismatch
In reply to Andre MuezerieCompiling with MSVC results in warnings like the one below:
app/test-pmd/csumonly.c(1085): warning C4477: 'printf' : format string
'%d' requires an argument of type 'int',
but variadic argument 1 has type 'uint64_t'
--- app/test-pmd/csumonly.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-)
app/test-pmd/csumonly.c +12 -11
@@ -1070,7 +1070,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) info.l2_len,rte_be_to_cpu_16 (info.ethertype), info.l3_len, info.l4_proto, info.l4_len, buf);if (rx_ol_flags &RTE_MBUF_F_RX_LRO ) -printf ("rx: m->lro_segsz=%u\n" , m->tso_segsz); +printf ("rx: m->lro_segsz=%" PRIu64"\n" , (uint64_t )m->tso_segsz);if (info.is_tunnel ==1 ) printf("rx: outer_l2_len=%d outer_ethertype=%x " "outer_l3_len=%d\n", info.outer_l2_len,
@@ -1082,28 +1082,29 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) RTE_ETH_TX_OFFLOAD_TCP_CKSUM | RTE_ETH_TX_OFFLOAD_SCTP_CKSUM)) || info.tso_segsz != 0) -printf ("tx: m->l2_len=%d m->l3_len=%d " -"m->l4_len=%d\n" , - m->l2_len, m->l3_len, m->l4_len); +printf ("tx: m->l2_len=%" PRIu64" m->l3_len=%" PRIu64 +" m->l4_len=%" PRIu64"\n" , + (uint64_t )m->l2_len, (uint64_t )m->l3_len, + (uint64_t )m->l4_len);if (info.is_tunnel ==1 ) {if ((tx_offloads &RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM ) || (tx_offloads &RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM ) || (tx_ol_flags &RTE_MBUF_F_TX_OUTER_IPV6 )) -printf ("tx: m->outer_l2_len=%d " -"m->outer_l3_len=%d\n" , - m->outer_l2_len, - m->outer_l3_len); +printf ("tx: m->outer_l2_len=%" PRIu64 +" m->outer_l3_len=%" PRIu64"\n" , + (uint64_t )m->outer_l2_len, + (uint64_t )m->outer_l3_len);if (info.tunnel_tso_segsz !=0 && (m->ol_flags & (RTE_MBUF_F_TX_TCP_SEG |RTE_MBUF_F_TX_UDP_SEG ))) -printf ("tx: m->tso_segsz=%d\n" , - m->tso_segsz); +printf ("tx: m->tso_segsz=%" PRIu64"\n" , + (uint64_t )m->tso_segsz); }else if (info.tso_segsz !=0 && (m->ol_flags & (RTE_MBUF_F_TX_TCP_SEG |RTE_MBUF_F_TX_UDP_SEG ))) -printf ("tx: m->tso_segsz=%d\n" , m->tso_segsz); +printf ("tx: m->tso_segsz=%" PRIu64"\n" , (uint64_t )m->tso_segsz);rte_get_tx_ol_flag_list (m->ol_flags, buf,sizeof (buf));printf ("tx: flags=%s" , buf);printf ("\n" );
Signature · 1 line
2.48.1.vfs.0.0
PATCH v2 4/10 test-pmd: do explicit 64-bit shift to avoid implicit conversion
In reply to Andre MuezerieCompiling with MSVC results in warnings like the one below:
app/test-pmd/util.c(201): warning C4334: '<<': result of 32-bit shift
implicitly converted to 64 bits (was 64-bit shift intended?)
--- app/test-pmd/cmdline.c | 4 ++-- app/test-pmd/testpmd.c | 2 +- app/test-pmd/util.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
app/test-pmd/cmdline.c +2 -2
@@ -12632,11 +12632,11 @@ cmd_config_dynf_specific_parsed(void *parsed_result, } old_port_flags = ports[res->port_id].mbuf_dynf;if (!strcmp (res->value,"set" )) { - ports[res->port_id].mbuf_dynf |=1UL << flag; + ports[res->port_id].mbuf_dynf |=RTE_BIT64 (flag);if (old_port_flags ==0 )add_tx_dynf_callback (res->port_id); }else { - ports[res->port_id].mbuf_dynf &= ~(1UL << flag); + ports[res->port_id].mbuf_dynf &= ~RTE_BIT64 (flag);if (ports[res->port_id].mbuf_dynf ==0 )remove_tx_dynf_callback (res->port_id); }
app/test-pmd/testpmd.c +1 -1
@@ -4152,7 +4152,7 @@ get_eth_dcb_conf(struct rte_eth_conf *eth_conf, enum dcb_mode_enable dcb_mode,for (i =0 ; i < vmdq_rx_conf->nb_pool_maps; i++) { vmdq_rx_conf->pool_map[i].vlan_id = vlan_tags[i]; vmdq_rx_conf->pool_map[i].pools = -1 << (i % vmdq_rx_conf->nb_queue_pools); +RTE_BIT64 (i % vmdq_rx_conf->nb_queue_pools); }for (i =0 ; i <RTE_ETH_DCB_NUM_USER_PRIORITIES ; i++) { vmdq_rx_conf->dcb_tc[i] = i % num_tcs;
app/test-pmd/util.c +1 -1
@@ -201,7 +201,7 @@ dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[],MKDUMPSTR (print_buf, buf_size, cur_len," - dynf %s: %d" , dynf_names[dynf_index], - !!(ol_flags & (1UL << dynf_index))); + !!(ol_flags &RTE_BIT64 (dynf_index))); }if (mb->packet_type) {rte_get_ptype_name (mb->packet_type, buf,sizeof (buf));
Signature · 1 line
2.48.1.vfs.0.0
v2 cover enable "app" to be compiled with MSVC
In reply to Andre Muezeriev2:
- use lcore_count as atomic always, not only when RTE_USE_C11_MEM_MODEL is set.
- use PRIu64 in csumonly.c instead of casting variables to int.
This series fixes many issues that prevent the "app" directory from being compiled with MSVC.
Andre Muezerie (10):
eal: add workaround for __builtin_constant_p
test_alarm: avoid warning about different qualifiers
test-pmd: fix printf format string mismatch
test-pmd: do explicit 64-bit shift to avoid implicit conversion
test-pmd: avoid undefined behavior
test-pmd: avoid non-constant initializer
test-pmd: don't return value from void function
test-pmd: declare lcore_count atomic
test: add workaround for __builtin_constant_p in test_memcpy_perf
app: enable app directory to be compiled with MSVC
app/meson.build | 4 -- app/test-pmd/cmdline.c | 19 +++-- app/test-pmd/cmdline_flow.c | 22 +++--- app/test-pmd/csumonly.c | 23 +++--- app/test-pmd/meson.build | 4 +- app/test-pmd/testpmd.c | 2 +- app/test-pmd/util.c | 2 +- app/test/test_alarm.c | 12 ++-- app/test/test_memcpy_perf.c | 106 ++++++++++++++-------------- app/test/test_ring_perf.c | 6 +- lib/eal/include/generic/rte_pause.h | 2 +- lib/eal/include/rte_common.h | 12 ++++ 12 files changed, 116 insertions(+), 98 deletions(-)
--
2.48.1.vfs.0.0
PATCH v2 1/10 eal: add workaround for __builtin_constant_p
There's no MSVC equivalent for compiler extension __builtin_constant_p. EAL already had __rte_constant which was used as a first attempt to workaround __builtin_constant_p when using MSVC. However, there are pieces of code that would benefit from being able to provide a default value to be used instead of it being always 0 like how it was done by __rte_constant.
A new macro is added here allowing such default to be provided by the caller.
--- lib/eal/include/generic/rte_pause.h | 2 +- lib/eal/include/rte_common.h | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-)
lib/eal/include/generic/rte_pause.h +1 -1
@@ -130,7 +130,7 @@ rte_wait_until_equal_64(volatile uint64_t *addr, uint64_t expected,* rte_memory_order_acquire and rte_memory_order_relaxed. */ #define RTE_WAIT_UNTIL_MASKED (addr, mask, cond, expected, memorder) do { \ - RTE_BUILD_BUG_ON(!__builtin_constant_p(memorder)); \ + RTE_BUILD_BUG_ON(!__rte_constant_with_default(memorder, 1)); \ RTE_BUILD_BUG_ON((memorder) != rte_memory_order_acquire && \ (memorder) != rte_memory_order_relaxed); \ typeof(*(addr)) expected_value = (expected); \
lib/eal/include/rte_common.h +12 -0
@@ -50,6 +50,18 @@ extern "C" {#define __rte_constant (e) __extension__(__builtin_constant_p(e))#endif +/** +* Determine if an expression's value is constant at compile time. +* All compilers except MSVC will return 1 if the first argument is a +* compile-time constant, and 0 otherwise. MSVC will just return the second +* argument as a default value. +*/ +#ifdef RTE_TOOLCHAIN_MSVC +#define __rte_constant_with_default (e, def) def +#else +#define __rte_constant_with_default (e, def) __extension__(__builtin_constant_p(e)) +#endif +/* * RTE_TOOLCHAIN_GCC is defined if the target is built with GCC, * while a host application (like pmdinfogen) may have another compiler.
Signature · 1 line
2.48.1.vfs.0.0
PATCH v2 2/10 test_alarm: avoid warning about different qualifiers
In reply to Andre MuezerieCompiling with MSVC results in the warning below:
app/test/test_alarm.c(54): warning C4090: 'function':
different '_Atomic' qualifiers
The fix is to use a macro to explicitly drop the qualifier.
--- app/test/test_alarm.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
app/test/test_alarm.c +6 -6
@@ -51,12 +51,12 @@ test_alarm(void) "Expected rte_eal_alarm_cancel to fail with null callback parameter");/* check if can set a alarm for one second */ -TEST_ASSERT_SUCCESS (rte_eal_alarm_set (US_PER_SEC , test_alarm_callback, &triggered), -"Setting one second alarm failed" ); +TEST_ASSERT_SUCCESS (rte_eal_alarm_set (US_PER_SEC , test_alarm_callback, +RTE_PTR_UNQUAL (&triggered)),"Setting one second alarm failed" );/* set a longer alarm that will be canceled. */ -TEST_ASSERT_SUCCESS (rte_eal_alarm_set (10 *US_PER_SEC , test_alarm_callback, &later), -"Setting ten second alarm failed" ); +TEST_ASSERT_SUCCESS (rte_eal_alarm_set (10 *US_PER_SEC , test_alarm_callback, +RTE_PTR_UNQUAL (&later)),"Setting ten second alarm failed" );/* wait for alarm to happen */ while (rte_atomic_load_explicit (&triggered, rte_memory_order_acquire) == false)
@@ -65,11 +65,11 @@ test_alarm(void)TEST_ASSERT (!rte_atomic_load_explicit (&later, rte_memory_order_acquire),"Only one alarm should have fired." ); - ret =rte_eal_alarm_cancel (test_alarm_callback, &triggered); + ret =rte_eal_alarm_cancel (test_alarm_callback,RTE_PTR_UNQUAL (&triggered));TEST_ASSERT (ret ==0 && rte_errno ==ENOENT ,"Canceling alarm after run ret %d: %s" , ret,rte_strerror (rte_errno)); - ret =rte_eal_alarm_cancel (test_alarm_callback, &later); + ret =rte_eal_alarm_cancel (test_alarm_callback,RTE_PTR_UNQUAL (&later));TEST_ASSERT (ret ==1 ,"Canceling ten second alarm failed %d: %s" , ret,rte_strerror (rte_errno));
Signature · 1 line
2.48.1.vfs.0.0
PATCH v2 6/10 test-pmd: avoid non-constant initializer
In reply to Andre MuezerieCompiling with MSVC results in errors like the one below:
app/test-pmd/cmdline_flow.c(8819): error C2099: initializer
is not a constant
--- app/test-pmd/cmdline_flow.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
app/test-pmd/cmdline_flow.c +3 -7
@@ -8812,8 +8812,6 @@ parse_vc_spec(struct context *ctx, const struct token *token,return -1 ;/* Parse parameter types. */ switch (ctx->curr) { -static const enum index prefix[] =NEXT_ENTRY (COMMON_PREFIX ); -case ITEM_PARAM_IS : index =0 ; objmask =1 ;
@@ -8828,7 +8826,7 @@ parse_vc_spec(struct context *ctx, const struct token *token,/* Modify next token to expect a prefix. */ if (ctx->next_num <2 )return -1 ; - ctx->next[ctx->next_num -2 ] = prefix; + ctx->next[ctx->next_num -2 ] =NEXT_ENTRY (COMMON_PREFIX );/* Fall through. */ case ITEM_PARAM_MASK : index =2 ;
@@ -9270,7 +9268,6 @@ parse_vc_action_rss_type(struct context *ctx, const struct token *token, const char *str, unsigned int len, void *buf, unsigned int size) { - static const enum index next[] = NEXT_ENTRY(ACTION_RSS_TYPE); struct action_rss_data *action_rss_data;unsigned int i;
@@ -9296,7 +9293,7 @@ parse_vc_action_rss_type(struct context *ctx, const struct token *token,/* Repeat token. */ if (ctx->next_num ==RTE_DIM (ctx->next))return -1 ; - ctx->next[ctx->next_num++] = next; + ctx->next[ctx->next_num++] =NEXT_ENTRY (ACTION_RSS_TYPE );if (!ctx->object)return len; action_rss_data = ctx->object;
@@ -9314,7 +9311,6 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token, const char *str, unsigned int len, void *buf, unsigned int size) { - static const enum index next[] = NEXT_ENTRY(ACTION_RSS_QUEUE); struct action_rss_data *action_rss_data;const struct arg *arg;int ret;
@@ -9347,7 +9343,7 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token,/* Repeat token. */ if (ctx->next_num ==RTE_DIM (ctx->next))return -1 ; - ctx->next[ctx->next_num++] = next; + ctx->next[ctx->next_num++] =NEXT_ENTRY (ACTION_RSS_QUEUE ); end:if (!ctx->object)return len;
Signature · 1 line
2.48.1.vfs.0.0
PATCH v2 8/10 test-pmd: declare lcore_count atomic
In reply to Andre MuezerieCompiling with MSVC results in the error below:
app/test/test_ring_perf.c(197): error C7712: address argument to atomic
operation must be a pointer to an atomic integer, 'volatile unsigned int *' is not valid
The fix is to mark lcore_count as atomic.
--- app/test/test_ring_perf.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
app/test/test_ring_perf.c +1 -5
@@ -34,7 +34,7 @@ struct lcore_pair {unsigned c1, c2; }; -static volatile unsigned lcore_count =0 ; +static RTE_ATOMIC (unsigned int ) lcore_count; static void test_ring_print_test_string(unsigned int api_type, int esize,
@@ -193,11 +193,7 @@ enqueue_dequeue_bulk_helper(const unsigned int flag, struct thread_params *p)unsigned int n_remaining;const unsigned int bulk_n = bulk_sizes[p->ring_params->bulk_sizes_i]; -#ifdef RTE_USE_C11_MEM_MODEL if (rte_atomic_fetch_add_explicit (&lcore_count,1 , rte_memory_order_relaxed) +1 !=2 ) -#else - if (__sync_add_and_fetch(&lcore_count, 1) != 2) -#endif while (lcore_count !=2 )rte_pause ();
Signature · 1 line
2.48.1.vfs.0.0
PATCH v2 7/10 test-pmd: don't return value from void function
In reply to Andre MuezerieCompiling with MSVC results in the warning below:
app/test-pmd/cmdline_flow.c(13964): warning C4098: 'cmd_set_raw_parsed':
'void' function returning a value
--- app/test-pmd/cmdline_flow.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
app/test-pmd/cmdline_flow.c +8 -4
@@ -13952,11 +13952,15 @@ cmd_set_raw_parsed(const struct buffer *in)int gtp_psc =-1 ;/* GTP PSC option index. */ const void *src_spec; -if (in->command ==SET_SAMPLE_ACTIONS ) -return cmd_set_raw_parsed_sample (in); +if (in->command ==SET_SAMPLE_ACTIONS ) { +cmd_set_raw_parsed_sample (in); +return ; + }else if (in->command ==SET_IPV6_EXT_PUSH || - in->command ==SET_IPV6_EXT_REMOVE ) -return cmd_set_ipv6_ext_parsed (in); + in->command ==SET_IPV6_EXT_REMOVE ) { +cmd_set_ipv6_ext_parsed (in); +return ; + }RTE_ASSERT (in->command ==SET_RAW_ENCAP || in->command ==SET_RAW_DECAP );if (in->command ==SET_RAW_ENCAP ) {
Signature · 1 line
2.48.1.vfs.0.0
PATCH v2 10/10 app: enable app directory to be compiled with MSVC
In reply to Andre MuezerieEnabled "app" directory to be compiled with MSVC along with all its contents.
--- app/meson.build | 4 ---- app/test-pmd/meson.build | 4 +++- 2 files changed, 3 insertions(+), 5 deletions(-)
app/meson.build +0 -4
@@ -1,10 +1,6 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017-2019 Intel Corporation -if is_ms_compiler - subdir_done() -endif - disable_apps = ',' + get_option('disable_apps') disable_apps = run_command(list_dir_globs, disable_apps, check: true).stdout().split()
app/test-pmd/meson.build +3 -1
@@ -3,7 +3,9 @@ # override default name to drop the hyphen name = 'testpmd' -cflags += '-Wno-deprecated-declarations' +if cc.has_argument('-Wno-deprecated-declarations') + cflags += '-Wno-deprecated-declarations' +endif sources = files( '5tswap.c', 'cmdline.c',
Signature · 1 line
2.48.1.vfs.0.0
PATCH v2 5/10 test-pmd: avoid undefined behavior
In reply to Andre MuezerieCompiling with MSVC results in warnings like below:
app/test-pmd/cmdline.c(9023): warning C5101: use of preprocessor
directive in function-like macro argument list is undefined behavior
--- app/test-pmd/cmdline.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
app/test-pmd/cmdline.c +13 -2
@@ -9011,6 +9011,18 @@ static void cmd_dump_parsed(void *parsed_result, } static cmdline_parse_token_string_t cmd_dump_dump = +#ifdef RTE_EXEC_ENV_WINDOWS + TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump, +"dump_physmem#" +"dump_memzone#" +"dump_socket_mem#" +"dump_struct_sizes#" +"dump_ring#" +"dump_mempool#" +"dump_devargs#" +"dump_lcores#" + "dump_log_types"); +#else TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,"dump_physmem#" "dump_memzone#"
@@ -9020,10 +9032,9 @@ static cmdline_parse_token_string_t cmd_dump_dump ="dump_mempool#" "dump_devargs#" "dump_lcores#" -#ifndef RTE_EXEC_ENV_WINDOWS"dump_trace#" -#endif "dump_log_types"); +#endif static cmdline_parse_inst_t cmd_dump = { .f = cmd_dump_parsed,/* function to call */
Signature · 1 line
2.48.1.vfs.0.0
PATCH v2 9/10 test: add workaround for __builtin_constant_p in test_memcpy_perf
In reply to Andre MuezerieThere's no MSVC equivalent for compiler extension __builtin_constant_p, so a workaround is needed.
--- app/test/test_memcpy_perf.c | 106 ++++++++++++++++++------------------ 1 file changed, 53 insertions(+), 53 deletions(-)
app/test/test_memcpy_perf.c +53 -53
@@ -167,66 +167,66 @@ do_uncached_write(uint8_t *dst, int is_dst_cached,* Run a single memcpy performance test. This is a macro to ensure that if * the "size" parameter is a constant it won't be converted to a variable. */ -#define SINGLE_PERF_TEST (dst, is_dst_cached, dst_uoffset, \ - src, is_src_cached, src_uoffset, size) \ -do { \ - unsigned int iter, t; \ - size_t dst_addrs[TEST_BATCH_SIZE], src_addrs[TEST_BATCH_SIZE]; \ - uint64_t start_time, total_time = 0; \ - uint64_t total_time2 = 0; \ - for (iter = 0; iter < (TEST_ITERATIONS / TEST_BATCH_SIZE); iter++) { \ - fill_addr_arrays(dst_addrs, is_dst_cached, dst_uoffset, \ - src_addrs, is_src_cached, src_uoffset); \ - start_time = rte_rdtsc(); \ - for (t = 0; t < TEST_BATCH_SIZE; t++) \ - rte_memcpy(dst+dst_addrs[t], src+src_addrs[t], size); \ - total_time += rte_rdtsc() - start_time; \ - } \ - for (iter = 0; iter < (TEST_ITERATIONS / TEST_BATCH_SIZE); iter++) { \ - fill_addr_arrays(dst_addrs, is_dst_cached, dst_uoffset, \ - src_addrs, is_src_cached, src_uoffset); \ - start_time = rte_rdtsc(); \ - for (t = 0; t < TEST_BATCH_SIZE; t++) \ - memcpy(dst+dst_addrs[t], src+src_addrs[t], size); \ - total_time2 += rte_rdtsc() - start_time; \ - } \ - printf("%3.0f -", (double)total_time / TEST_ITERATIONS); \ - printf("%3.0f", (double)total_time2 / TEST_ITERATIONS); \ - printf("(%6.2f%%) ", ((double)total_time - total_time2)*100/total_time2); \ +#define SINGLE_PERF_TEST (dst, is_dst_cached, dst_uoffset, \ + src, is_src_cached, src_uoffset, size) \ +do { \ + unsigned int iter, t; \ + size_t dst_addrs[TEST_BATCH_SIZE], src_addrs[TEST_BATCH_SIZE]; \ + uint64_t start_time, total_time = 0; \ + uint64_t total_time2 = 0; \ + for (iter = 0; iter < (TEST_ITERATIONS / TEST_BATCH_SIZE); iter++) { \ + fill_addr_arrays(dst_addrs, is_dst_cached, dst_uoffset, \ + src_addrs, is_src_cached, src_uoffset); \ + start_time = rte_rdtsc(); \ + for (t = 0; t < TEST_BATCH_SIZE; t++) \ + rte_memcpy(dst+dst_addrs[t], src+src_addrs[t], size); \ + total_time += rte_rdtsc() - start_time; \ + } \ + for (iter = 0; iter < (TEST_ITERATIONS / TEST_BATCH_SIZE); iter++) { \ + fill_addr_arrays(dst_addrs, is_dst_cached, dst_uoffset, \ + src_addrs, is_src_cached, src_uoffset); \ + start_time = rte_rdtsc(); \ + for (t = 0; t < TEST_BATCH_SIZE; t++) \ + memcpy(dst+dst_addrs[t], src+src_addrs[t], size); \ + total_time2 += rte_rdtsc() - start_time; \ + } \ + printf("%3.0f -", (double)total_time / TEST_ITERATIONS); \ + printf("%3.0f", (double)total_time2 / TEST_ITERATIONS); \ + printf("(%6.2f%%) ", ((double)total_time - total_time2)*100/total_time2); \ } while (0)/* Run aligned memcpy tests for each cached/uncached permutation */ -#define ALL_PERF_TESTS_FOR_SIZE (n) \ -do { \ - if (__builtin_constant_p(n)) \ - printf("\nC%6u", (unsigned)n); \ - else \ - printf("\n%7u", (unsigned)n); \ - SINGLE_PERF_TEST(small_buf_write, 1, 0, small_buf_read, 1, 0, n); \ - SINGLE_PERF_TEST(large_buf_write, 0, 0, small_buf_read, 1, 0, n); \ - SINGLE_PERF_TEST(small_buf_write, 1, 0, large_buf_read, 0, 0, n); \ - SINGLE_PERF_TEST(large_buf_write, 0, 0, large_buf_read, 0, 0, n); \ +#define ALL_PERF_TESTS_FOR_SIZE (n, def) \ +do { \ + if (__rte_constant_with_default(n, def)) \ + printf("\nC%6u", (unsigned int)n); \ + else \ + printf("\n%7u", (unsigned int)n); \ + SINGLE_PERF_TEST(small_buf_write, 1, 0, small_buf_read, 1, 0, n); \ + SINGLE_PERF_TEST(large_buf_write, 0, 0, small_buf_read, 1, 0, n); \ + SINGLE_PERF_TEST(small_buf_write, 1, 0, large_buf_read, 0, 0, n); \ + SINGLE_PERF_TEST(large_buf_write, 0, 0, large_buf_read, 0, 0, n); \ } while (0)/* Run unaligned memcpy tests for each cached/uncached permutation */ -#define ALL_PERF_TESTS_FOR_SIZE_UNALIGNED (n) \ -do { \ - if (__builtin_constant_p(n)) \ - printf("\nC%6u", (unsigned)n); \ - else \ - printf("\n%7u", (unsigned)n); \ - SINGLE_PERF_TEST(small_buf_write, 1, 1, small_buf_read, 1, 5, n); \ - SINGLE_PERF_TEST(large_buf_write, 0, 1, small_buf_read, 1, 5, n); \ - SINGLE_PERF_TEST(small_buf_write, 1, 1, large_buf_read, 0, 5, n); \ - SINGLE_PERF_TEST(large_buf_write, 0, 1, large_buf_read, 0, 5, n); \ +#define ALL_PERF_TESTS_FOR_SIZE_UNALIGNED (n, def) \ +do { \ + if (__rte_constant_with_default(n, def)) \ + printf("\nC%6u", (unsigned int)n); \ + else \ + printf("\n%7u", (unsigned int)n); \ + SINGLE_PERF_TEST(small_buf_write, 1, 1, small_buf_read, 1, 5, n); \ + SINGLE_PERF_TEST(large_buf_write, 0, 1, small_buf_read, 1, 5, n); \ + SINGLE_PERF_TEST(small_buf_write, 1, 1, large_buf_read, 0, 5, n); \ + SINGLE_PERF_TEST(large_buf_write, 0, 1, large_buf_read, 0, 5, n); \ } while (0)/* Run memcpy tests for constant length */ -#define ALL_PERF_TEST_FOR_CONSTANT \ -do { \ - TEST_CONSTANT(6U); TEST_CONSTANT(64U); TEST_CONSTANT(128U); \ - TEST_CONSTANT(192U); TEST_CONSTANT(256U); TEST_CONSTANT(512U); \ - TEST_CONSTANT(768U); TEST_CONSTANT(1024U); TEST_CONSTANT(1536U); \ +#define ALL_PERF_TEST_FOR_CONSTANT \ +do { \ + TEST_CONSTANT(6U, 1); TEST_CONSTANT(64U, 1); TEST_CONSTANT(128U, 1); \ + TEST_CONSTANT(192U, 1); TEST_CONSTANT(256U, 1); TEST_CONSTANT(512U, 1); \ + TEST_CONSTANT(768U, 1); TEST_CONSTANT(1024U, 1); TEST_CONSTANT(1536U, 1); \ } while (0)/* Run all memcpy tests for aligned constant cases */
@@ -253,7 +253,7 @@ perf_test_variable_aligned(void) {unsigned i;for (i =0 ; i <RTE_DIM (buf_sizes); i++) { -ALL_PERF_TESTS_FOR_SIZE ((size_t )buf_sizes[i]); +ALL_PERF_TESTS_FOR_SIZE (buf_sizes[i],0 ); } }
@@ -263,7 +263,7 @@ perf_test_variable_unaligned(void) {unsigned i;for (i =0 ; i <RTE_DIM (buf_sizes); i++) { -ALL_PERF_TESTS_FOR_SIZE_UNALIGNED ((size_t )buf_sizes[i]); +ALL_PERF_TESTS_FOR_SIZE_UNALIGNED (buf_sizes[i],0 ); } }
Signature · 1 line
2.48.1.vfs.0.0
Re: [PATCH v2 05/10] test-pmd: avoid undefined behavior
In reply to Andre MuezerieQuoted 35 lines · Andre Muezerie
Compiling with MSVC results in warnings like below:
app/test-pmd/cmdline.c(9023): warning C5101: use of preprocessor
directive in function-like macro argument list is undefined behaviorSigned-off-by Andre Muezerie <[email protected]>Signed-off-by Chengwen Feng <[email protected]>--- app/test-pmd/cmdline.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)app/test-pmd/cmdline.c +12
-0@@ -9011,6 +9011,18 @@ static void cmd_dump_parsed(void *parsed_result, } static cmdline_parse_token_string_t cmd_dump_dump = +#ifdef RTE_EXEC_ENV_WINDOWS + TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump, +"dump_physmem#" +"dump_memzone#" +"dump_socket_mem#" +"dump_struct_sizes#" +"dump_ring#" +"dump_mempool#" +"dump_devargs#" +"dump_lcores#" + "dump_log_types"); +#else TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,"dump_physmem#" "dump_memzone#"
app/test-pmd/cmdline.c static cmdline_parse_token_string_t cmd_dump_dump = · line 9038
Quoted 9 lines
app/test-pmd/cmdline.c +1
-2@@ -9020,10 +9032,9 @@ static cmdline_parse_token_string_t cmd_dump_dump ="dump_mempool#" "dump_devargs#" "dump_lcores#" -#ifndef RTE_EXEC_ENV_WINDOWS"dump_trace#" -#endif "dump_log_types"); +#endif
Rather than defining two separate lists, is a better fix not to provide a dummy implementation of dump_trace for windows, that returns e.g. TEST_SKIPPED.
/Bruce
Re: [PATCH v2 07/10] test-pmd: don't return value from void function
In reply to Andre MuezerieQuoted 8 lines · Andre Muezerie
Compiling with MSVC results in the warning below:
app/test-pmd/cmdline_flow.c(13964): warning C4098: '
cmd_set_raw_parsed':
'void' function returning a valueSigned-off-by Andre Muezerie <[email protected]>Signed-off-by Chengwen Feng <[email protected]>---
Re: [PATCH v2 03/10] test-pmd: fix printf format string mismatch
In reply to Andre MuezerieQuoted 17 lines · Andre Muezerie
Compiling with MSVC results in warnings like the one below:
app/test-pmd/csumonly.c(1085): warning C4477: 'printf' : format string
'%d' requires an argument of type 'int',
but variadic argument 1 has type 'uint64_t'Signed-off-by Andre Muezerie <[email protected]>Signed-off-by Chengwen Feng <[email protected]>--- app/test-pmd/csumonly.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-)app/test-pmd/csumonly.c +0
-0
app/test-pmd/csumonly.c pkt_burst_checksum_forward(struct fwd_stream *fs) · line 1073
Quoted 5 lines
app/test-pmd/csumonly.c +1
-1@@ -1070,7 +1070,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) info.l2_len,rte_be_to_cpu_16 (info.ethertype), info.l3_len, info.l4_proto, info.l4_len, buf);if (rx_ol_flags &RTE_MBUF_F_RX_LRO ) -printf ("rx: m->lro_segsz=%u\n" , m->tso_segsz); +printf ("rx: m->lro_segsz=%" PRIu64"\n" , (uint64_t )m->tso_segsz);
tso_segsz is already uint64_t, so no need for the cast.
Quoted 4 lines
app/test-pmd/csumonly.c +0
-0if (info.is_tunnel ==1 ) printf("rx: outer_l2_len=%d outer_ethertype=%x " "outer_l3_len=%d\n", info.outer_l2_len,
app/test-pmd/csumonly.c pkt_burst_checksum_forward(struct fwd_stream *fs) · line 1088
Quoted 10 lines
app/test-pmd/csumonly.c +4
-3@@ -1082,28 +1082,29 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) RTE_ETH_TX_OFFLOAD_TCP_CKSUM | RTE_ETH_TX_OFFLOAD_SCTP_CKSUM)) || info.tso_segsz != 0) -printf ("tx: m->l2_len=%d m->l3_len=%d " -"m->l4_len=%d\n" , - m->l2_len, m->l3_len, m->l4_len); +printf ("tx: m->l2_len=%" PRIu64" m->l3_len=%" PRIu64 +" m->l4_len=%" PRIu64"\n" , + (uint64_t )m->l2_len, (uint64_t )m->l3_len, + (uint64_t )m->l4_len);
Same here, using casts and a changed print format seems wrong in the patch. Either we change the format string to match the variable type, or we cast the variables to match the format string. We should not do both, IMHO.
Quoted 32 lines
app/test-pmd/csumonly.c +7
-7if (info.is_tunnel ==1 ) {if ((tx_offloads &RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM ) || (tx_offloads &RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM ) || (tx_ol_flags &RTE_MBUF_F_TX_OUTER_IPV6 )) -printf ("tx: m->outer_l2_len=%d " -"m->outer_l3_len=%d\n" , - m->outer_l2_len, - m->outer_l3_len); +printf ("tx: m->outer_l2_len=%" PRIu64 +" m->outer_l3_len=%" PRIu64"\n" , + (uint64_t )m->outer_l2_len, + (uint64_t )m->outer_l3_len);if (info.tunnel_tso_segsz !=0 && (m->ol_flags & (RTE_MBUF_F_TX_TCP_SEG |RTE_MBUF_F_TX_UDP_SEG ))) -printf ("tx: m->tso_segsz=%d\n" , - m->tso_segsz); +printf ("tx: m->tso_segsz=%" PRIu64"\n" , + (uint64_t )m->tso_segsz); }else if (info.tso_segsz !=0 && (m->ol_flags & (RTE_MBUF_F_TX_TCP_SEG |RTE_MBUF_F_TX_UDP_SEG ))) -printf ("tx: m->tso_segsz=%d\n" , m->tso_segsz); +printf ("tx: m->tso_segsz=%" PRIu64"\n" , (uint64_t )m->tso_segsz);rte_get_tx_ol_flag_list (m->ol_flags, buf,sizeof (buf));printf ("tx: flags=%s" , buf);printf ("\n" );Signature · 1 line
2.48.1.vfs.0.0
Re: [PATCH v2 04/10] test-pmd: do explicit 64-bit shift to avoid implicit conversion
In reply to Andre MuezerieQuoted 8 lines · Andre Muezerie
Compiling with MSVC results in warnings like the one below:
app/test-pmd/util.c(201): warning C4334: '<<': result of 32-bit shift
implicitly converted to 64 bits (was 64-bit shift intended?)Signed-off-by Andre Muezerie <[email protected]>Signed-off-by Chengwen Feng <[email protected]>---
Re: [PATCH v2 10/10] app: enable app directory to be compiled with MSVC
In reply to Andre MuezerieQuoted 30 lines · Andre Muezerie
Enabled "app" directory to be compiled with MSVC along with all its contents.
Signed-off-by Andre Muezerie <[email protected]>--- app/meson.build | 4 ---- app/test-pmd/meson.build | 4 +++- 2 files changed, 3 insertions(+), 5 deletions(-)app/meson.build +0
-4@@ -1,10 +1,6 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017-2019 Intel Corporation -if is_ms_compiler - subdir_done() -endif - disable_apps = ',' + get_option('disable_apps') disable_apps = run_command(list_dir_globs, disable_apps, check: true).stdout().split()app/test-pmd/meson.build +0
-0
app/test-pmd/meson.build line 11
Quoted 10 lines
app/test-pmd/meson.build +3
-1@@ -3,7 +3,9 @@ # override default name to drop the hyphen name = 'testpmd' -cflags += '-Wno-deprecated-declarations' +if cc.has_argument('-Wno-deprecated-declarations') + cflags += '-Wno-deprecated-declarations' +endif sources = files( '5tswap.c', 'cmdline.c',
Re: [PATCH v2 03/10] test-pmd: fix printf format string mismatch
In reply to Bruce RichardsonQuoted 13 lines · Bruce Richardson
Quoted 12 lines · Andre Muezerie
Compiling with MSVC results in warnings like the one below:
app/test-pmd/csumonly.c(1085): warning C4477: 'printf' : format string
'%d' requires an argument of type 'int',
but variadic argument 1 has type 'uint64_t'Signed-off-by Andre Muezerie <[email protected]>Signed-off-by Chengwen Feng <[email protected]>--- app/test-pmd/csumonly.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-)
Quoted 12 lines
app/test-pmd/csumonly.c pkt_burst_checksum_forward(struct fwd_stream *fs) · line 1073
Quoted 10 lines
app/test-pmd/csumonly.c +1
-1@@ -1070,7 +1070,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) info.l2_len,rte_be_to_cpu_16 (info.ethertype), info.l3_len, info.l4_proto, info.l4_len, buf);if (rx_ol_flags &RTE_MBUF_F_RX_LRO ) -printf ("rx: m->lro_segsz=%u\n" , m->tso_segsz); +printf ("rx: m->lro_segsz=%" PRIu64"\n" , (uint64_t )m->tso_segsz);
tso_segszis alreadyuint64_t, so no need for the cast.
The compilers differ in behavior here. tso_segsz only uses 16 bits of the uint64_t, and gcc tries to be smart about it and implicitly converts tso_segsz into an int (since it fits into an int). Msvc does not do that, and keeps the type for tso_segsz as uint64_t. To support both compilers it seems there's no way to avoid the cast.
Quoted 11 lines
Quoted 11 lines
app/test-pmd/csumonly.c +0
-3if (info.is_tunnel ==1 ) printf("rx: outer_l2_len=%d outer_ethertype=%x " "outer_l3_len=%d\n", info.outer_l2_len,@@ -1082,28 +1082,29 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)RTE_ETH_TX_OFFLOAD_TCP_CKSUM | RTE_ETH_TX_OFFLOAD_SCTP_CKSUM)) || info.tso_segsz != 0) -printf ("tx: m->l2_len=%d m->l3_len=%d " -"m->l4_len=%d\n" , - m->l2_len, m->l3_len, m->l4_len);
Quoted 8 lines
app/test-pmd/csumonly.c pkt_burst_checksum_forward(struct fwd_stream *fs) · line 1088
Quoted 4 lines
app/test-pmd/csumonly.c +4
-0+printf ("tx: m->l2_len=%" PRIu64" m->l3_len=%" PRIu64 +" m->l4_len=%" PRIu64"\n" , + (uint64_t )m->l2_len, (uint64_t )m->l3_len, + (uint64_t )m->l4_len);Same here, using casts and a changed print format seems wrong in the patch. Either we change the format string to match the variable type, or we cast the variables to match the format string. We should not do both, IMHO.
I also normally prefer to not see unnecessary casts in the code, but it looks like it is needed in this case, as explained above.
Quoted 33 lines
Quoted 33 lines
app/test-pmd/csumonly.c +7
-7if (info.is_tunnel ==1 ) {if ((tx_offloads &RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM ) || (tx_offloads &RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM ) || (tx_ol_flags &RTE_MBUF_F_TX_OUTER_IPV6 )) -printf ("tx: m->outer_l2_len=%d " -"m->outer_l3_len=%d\n" , - m->outer_l2_len, - m->outer_l3_len); +printf ("tx: m->outer_l2_len=%" PRIu64 +" m->outer_l3_len=%" PRIu64"\n" , + (uint64_t )m->outer_l2_len, + (uint64_t )m->outer_l3_len);if (info.tunnel_tso_segsz !=0 && (m->ol_flags & (RTE_MBUF_F_TX_TCP_SEG |RTE_MBUF_F_TX_UDP_SEG ))) -printf ("tx: m->tso_segsz=%d\n" , - m->tso_segsz); +printf ("tx: m->tso_segsz=%" PRIu64"\n" , + (uint64_t )m->tso_segsz); }else if (info.tso_segsz !=0 && (m->ol_flags & (RTE_MBUF_F_TX_TCP_SEG |RTE_MBUF_F_TX_UDP_SEG ))) -printf ("tx: m->tso_segsz=%d\n" , m->tso_segsz); +printf ("tx: m->tso_segsz=%" PRIu64"\n" , (uint64_t )m->tso_segsz);rte_get_tx_ol_flag_list (m->ol_flags, buf,sizeof (buf));printf ("tx: flags=%s" , buf);printf ("\n" );Signature · 1 line
2.48.1.vfs.0.0
Re: [PATCH v2 03/10] test-pmd: fix printf format string mismatch
Quoted 27 lines · Andre Muezerie
Quoted 13 lines · Bruce Richardson
Quoted 12 lines · Andre Muezerie
Compiling with MSVC results in warnings like the one below:
app/test-pmd/csumonly.c(1085): warning C4477: 'printf' : format string
'%d' requires an argument of type 'int',
but variadic argument 1 has type 'uint64_t'Signed-off-by Andre Muezerie <[email protected]>Signed-off-by Chengwen Feng <[email protected]>--- app/test-pmd/csumonly.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-)Quoted 12 lines
app/test-pmd/csumonly.c pkt_burst_checksum_forward(struct fwd_stream *fs) · line 1073
Quoted 10 lines
app/test-pmd/csumonly.c +1
-1@@ -1070,7 +1070,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) info.l2_len,rte_be_to_cpu_16 (info.ethertype), info.l3_len, info.l4_proto, info.l4_len, buf);if (rx_ol_flags &RTE_MBUF_F_RX_LRO ) -printf ("rx: m->lro_segsz=%u\n" , m->tso_segsz); +printf ("rx: m->lro_segsz=%" PRIu64"\n" , (uint64_t )m->tso_segsz);
tso_segszis alreadyuint64_t, so no need for the cast.
Quoted 5 lines
The compilers differ in behavior here.
tso_segszonly uses 16 bits of theuint64_t, and gcc tries to be smart about it and implicitly convertstso_segszinto an int (since it fits into an int). Msvc does not do that, and keeps the type fortso_segszasuint64_t. To support both compilers it seems there's no way to avoid the cast.
Ok. Then can we just keep the %u and cast to either unsigned or uint16_t? No need to update the format char if we are casting, right?
/Bruce
RE: [PATCH v2 01/10] eal: add workaround for __builtin_constant_p
In reply to Andre MuezerieQuoted 10 lines
From: Andre Muezerie [mailto:[email protected]]
Sent: Tuesday, 18 February 2025 17.32There's no MSVC equivalent for compiler extension
__builtin_constant_p. EAL already had__rte_constantwhich was used as a first attempt to workaround__builtin_constant_pwhen using MSVC. However, there are pieces of code that would benefit from being able to provide a default value to be used instead of it being always 0 like how it was done by__rte_constant.
Quoted 2 lines
A new macro is added here allowing such default to be provided by the caller.
NAK to the new macro.
Please use the sizeof() hack suggested by Stephen to provide an implementation of __rte_constant(e) for MSVC. Here's a link to an example of the hack:
https://news.ycombinator.com/item?id=16720172
Re: [PATCH v2 10/10] app: enable app directory to be compiled with MSVC
In reply to Andre MuezerieQuoted 5 lines · Andre Muezerie
app/test-pmd/meson.build +0
-0
app/test-pmd/meson.build line 11
Quoted 10 lines
app/test-pmd/meson.build +3
-1@@ -3,7 +3,9 @@ # override default name to drop the hyphen name = 'testpmd' -cflags += '-Wno-deprecated-declarations' +if cc.has_argument('-Wno-deprecated-declarations') + cflags += '-Wno-deprecated-declarations' +endif sources = files( '5tswap.c', 'cmdline.c',
We don't need this flag anymore.
This is probably a remnant of 9f2be5b3db8b ("ethdev: deprecate attach and detach functions"), which got fixed later with c9cce42876f5 ("ethdev: remove deprecated attach/detach functions").
Signature · 1 line
David Marchand
Re: [PATCH v2 10/10] app: enable app directory to be compiled with MSVC
Quoted 20 lines · David Marchand
Quoted 5 lines · Andre Muezerie
app/test-pmd/meson.build +0
-0app/test-pmd/meson.build line 11
Quoted 10 lines
app/test-pmd/meson.build +3
-1@@ -3,7 +3,9 @@ # override default name to drop the hyphen name = 'testpmd' -cflags += '-Wno-deprecated-declarations' +if cc.has_argument('-Wno-deprecated-declarations') + cflags += '-Wno-deprecated-declarations' +endif sources = files( '5tswap.c', 'cmdline.c',We don't need this flag anymore.
Quoted 7 lines
This is probably a remnant of
9f2be5b3db8b("ethdev: deprecate attach and detach functions"), which got fixed later withc9cce42876f5("ethdev: remove deprecated attach/detach functions").Signature · 1 line
David Marchand
Good to know. I'll remove it then.
Re: [PATCH v2 01/10] eal: add workaround for __builtin_constant_p
In reply to Morten BrørupQuoted 10 lines · Morten Brørup
Quoted 10 lines
From: Andre Muezerie [mailto:[email protected]]
Sent: Tuesday, 18 February 2025 17.32There's no MSVC equivalent for compiler extension
__builtin_constant_p. EAL already had__rte_constantwhich was used as a first attempt to workaround__builtin_constant_pwhen using MSVC. However, there are pieces of code that would benefit from being able to provide a default value to be used instead of it being always 0 like how it was done by__rte_constant.
Quoted 8 lines
Quoted 2 lines
A new macro is added here allowing such default to be provided by the caller.
NAK to the new macro.
Please use the
sizeof()hack suggested by Stephen to provide an implementation of__rte_constant(e)for MSVC. Here's a link to an example of the hack:
https://news.ycombinator.com/item?id=16720172
Thanks for the link. I tried to use the hack as suggested but turns out it does not work with msvc. It results in error C2100: "you cannot dereference an operand of type 'void'".
I'm open to further suggestions.
Re: [PATCH v2 03/10] test-pmd: fix printf format string mismatch
In reply to Bruce RichardsonQuoted 34 lines · Bruce Richardson
Quoted 27 lines · Andre Muezerie
Quoted 13 lines · Bruce Richardson
Quoted 12 lines · Andre Muezerie
Compiling with MSVC results in warnings like the one below:
app/test-pmd/csumonly.c(1085): warning C4477: 'printf' : format string
'%d' requires an argument of type 'int',
but variadic argument 1 has type 'uint64_t'Signed-off-by Andre Muezerie <[email protected]>Signed-off-by Chengwen Feng <[email protected]>--- app/test-pmd/csumonly.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-)Quoted 12 lines
app/test-pmd/csumonly.c pkt_burst_checksum_forward(struct fwd_stream *fs) · line 1073
Quoted 10 lines
app/test-pmd/csumonly.c +1
-1@@ -1070,7 +1070,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) info.l2_len,rte_be_to_cpu_16 (info.ethertype), info.l3_len, info.l4_proto, info.l4_len, buf);if (rx_ol_flags &RTE_MBUF_F_RX_LRO ) -printf ("rx: m->lro_segsz=%u\n" , m->tso_segsz); +printf ("rx: m->lro_segsz=%" PRIu64"\n" , (uint64_t )m->tso_segsz);
tso_segszis alreadyuint64_t, so no need for the cast.Quoted 5 lines
The compilers differ in behavior here.
tso_segszonly uses 16 bits of theuint64_t, and gcc tries to be smart about it and implicitly convertstso_segszinto an int (since it fits into an int). Msvc does not do that, and keeps the type fortso_segszasuint64_t. To support both compilers it seems there's no way to avoid the cast.
Quoted 4 lines
Ok. Then can we just keep the %u and cast to either unsigned or
uint16_t? No need to update the format char if we are casting, right?/Bruce
Yes, I'll do that.
Re: [PATCH v2 05/10] test-pmd: avoid undefined behavior
In reply to Bruce RichardsonQuoted 49 lines · Bruce Richardson
Quoted 35 lines · Andre Muezerie
Compiling with MSVC results in warnings like below:
app/test-pmd/cmdline.c(9023): warning C5101: use of preprocessor
directive in function-like macro argument list is undefined behaviorSigned-off-by Andre Muezerie <[email protected]>Signed-off-by Chengwen Feng <[email protected]>--- app/test-pmd/cmdline.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)app/test-pmd/cmdline.c +12
-0@@ -9011,6 +9011,18 @@ static void cmd_dump_parsed(void *parsed_result, } static cmdline_parse_token_string_t cmd_dump_dump = +#ifdef RTE_EXEC_ENV_WINDOWS + TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump, +"dump_physmem#" +"dump_memzone#" +"dump_socket_mem#" +"dump_struct_sizes#" +"dump_ring#" +"dump_mempool#" +"dump_devargs#" +"dump_lcores#" + "dump_log_types"); +#else TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,"dump_physmem#" "dump_memzone#" app/test-pmd/cmdline.c static cmdline_parse_token_string_t cmd_dump_dump = · line 9038
Quoted 9 lines
app/test-pmd/cmdline.c +1
-2@@ -9020,10 +9032,9 @@ static cmdline_parse_token_string_t cmd_dump_dump ="dump_mempool#" "dump_devargs#" "dump_lcores#" -#ifndef RTE_EXEC_ENV_WINDOWS"dump_trace#" -#endif "dump_log_types"); +#endif Rather than defining two separate lists, is a better fix not to provide a dummy implementation of
dump_tracefor windows, that returns e.g.TEST_SKIPPED.
Quoted 1 line
/Bruce
Good suggestion. I'll update the patch accordingly.
Re: [PATCH v2 01/10] eal: add workaround for __builtin_constant_p
In reply to Andre MuezerieQuoted 20 lines · On Wed, 19 Feb 2025 08:50:02 -0800 Andre Muezerie…
Quoted 10 lines · Morten Brørup
Quoted 10 lines
From: Andre Muezerie [mailto:[email protected]]
Sent: Tuesday, 18 February 2025 17.32There's no MSVC equivalent for compiler extension
__builtin_constant_p. EAL already had__rte_constantwhich was used as a first attempt to workaround__builtin_constant_pwhen using MSVC. However, there are pieces of code that would benefit from being able to provide a default value to be used instead of it being always 0 like how it was done by__rte_constant.Quoted 8 lines
Quoted 2 lines
A new macro is added here allowing such default to be provided by the caller.
NAK to the new macro.
Please use the
sizeof()hack suggested by Stephen to provide an implementation of__rte_constant(e)for MSVC. Here's a link to an example of the hack:
https://news.ycombinator.com/item?id=16720172
Quoted 5 lines
Thanks for the link. I tried to use the hack as suggested but turns out it does not work with msvc. It results in error C2100: "you cannot dereference an operand of type 'void'".
I'm open to further suggestions.
Maybe contact the MSVC team? there really ought to be way to do this.
The compiler knows what is constant and what is not since it needs this for static assertions.
Re: [PATCH v2 01/10] eal: add workaround for __builtin_constant_p
Quoted 23 lines · Stephen Hemminger
Quoted 20 lines · On Wed, 19 Feb 2025 08:50:02 -0800 Andre Muezerie…
Quoted 18 lines · Morten Brørup
Quoted 10 lines
From: Andre Muezerie [mailto:[email protected]]
Sent: Tuesday, 18 February 2025 17.32There's no MSVC equivalent for compiler extension
__builtin_constant_p. EAL already had__rte_constantwhich was used as a first attempt to workaround__builtin_constant_pwhen using MSVC. However, there are pieces of code that would benefit from being able to provide a default value to be used instead of it being always 0 like how it was done by__rte_constant.Quoted 2 lines
A new macro is added here allowing such default to be provided by the caller.
NAK to the new macro.
Please use the
sizeof()hack suggested by Stephen to provide an implementation of__rte_constant(e)for MSVC. Here's a link to an example of the hack:
https://news.ycombinator.com/item?id=16720172
Quoted 8 lines
Quoted 5 lines
Thanks for the link. I tried to use the hack as suggested but turns out it does not work with msvc. It results in error C2100: "you cannot dereference an operand of type 'void'".
I'm open to further suggestions.
Maybe contact the MSVC team? there really ought to be way to do this.
The compiler knows what is constant and what is not since it needs this for static assertions.
I reached out to the MSVC team and they suggested a similar hack using _Generic, which works with msvc. I'll send out an updated series.
PATCH v3 3/10 test-pmd: fix printf format string mismatch
In reply to Andre MuezerieCompiling with MSVC results in warnings like the one below:
app/test-pmd/csumonly.c(1085): warning C4477: 'printf' : format string
'%d' requires an argument of type 'int',
but variadic argument 1 has type 'uint64_t'
--- app/test-pmd/csumonly.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-)
app/test-pmd/csumonly.c +12 -11
@@ -1070,7 +1070,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) info.l2_len,rte_be_to_cpu_16 (info.ethertype), info.l3_len, info.l4_proto, info.l4_len, buf);if (rx_ol_flags &RTE_MBUF_F_RX_LRO ) -printf ("rx: m->lro_segsz=%u\n" , m->tso_segsz); +printf ("rx: m->lro_segsz=%u\n" , (unsigned int )m->tso_segsz);if (info.is_tunnel ==1 ) printf("rx: outer_l2_len=%d outer_ethertype=%x " "outer_l3_len=%d\n", info.outer_l2_len,
@@ -1082,28 +1082,29 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) RTE_ETH_TX_OFFLOAD_TCP_CKSUM | RTE_ETH_TX_OFFLOAD_SCTP_CKSUM)) || info.tso_segsz != 0) -printf ("tx: m->l2_len=%d m->l3_len=%d " -"m->l4_len=%d\n" , - m->l2_len, m->l3_len, m->l4_len); +printf ("tx: m->l2_len=%u m->l3_len=%u " +"m->l4_len=%u\n" , + (unsigned int )m->l2_len, (unsigned int )m->l3_len, + (unsigned int )m->l4_len);if (info.is_tunnel ==1 ) {if ((tx_offloads &RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM ) || (tx_offloads &RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM ) || (tx_ol_flags &RTE_MBUF_F_TX_OUTER_IPV6 )) -printf ("tx: m->outer_l2_len=%d " -"m->outer_l3_len=%d\n" , - m->outer_l2_len, - m->outer_l3_len); +printf ("tx: m->outer_l2_len=%u " +"m->outer_l3_len=%u\n" , + (unsigned int )m->outer_l2_len, + (unsigned int )m->outer_l3_len);if (info.tunnel_tso_segsz !=0 && (m->ol_flags & (RTE_MBUF_F_TX_TCP_SEG |RTE_MBUF_F_TX_UDP_SEG ))) -printf ("tx: m->tso_segsz=%d\n" , - m->tso_segsz); +printf ("tx: m->tso_segsz=%u\n" , + (unsigned int )m->tso_segsz); }else if (info.tso_segsz !=0 && (m->ol_flags & (RTE_MBUF_F_TX_TCP_SEG |RTE_MBUF_F_TX_UDP_SEG ))) -printf ("tx: m->tso_segsz=%d\n" , m->tso_segsz); +printf ("tx: m->tso_segsz=%u\n" , (unsigned int )m->tso_segsz);rte_get_tx_ol_flag_list (m->ol_flags, buf,sizeof (buf));printf ("tx: flags=%s" , buf);printf ("\n" );
Signature · 1 line
2.48.1.vfs.0.0
PATCH v3 1/10 eal: add workaround for __builtin_constant_p
In reply to Andre MuezerieThere's no MSVC equivalent for compiler extension __builtin_constant_p, but the same result can be obtained though a clever expression using _Generic.
This patch redefines the macro __rte_constant when msvc is used and uses it as a replacement for __builtin_constant_p.
--- lib/eal/include/generic/rte_pause.h | 2 +- lib/eal/include/rte_common.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
lib/eal/include/generic/rte_pause.h +1 -1
@@ -130,7 +130,7 @@ rte_wait_until_equal_64(volatile uint64_t *addr, uint64_t expected,* rte_memory_order_acquire and rte_memory_order_relaxed. */ #define RTE_WAIT_UNTIL_MASKED (addr, mask, cond, expected, memorder) do { \ - RTE_BUILD_BUG_ON(!__builtin_constant_p(memorder)); \ + RTE_BUILD_BUG_ON(!__rte_constant(memorder)); \ RTE_BUILD_BUG_ON((memorder) != rte_memory_order_acquire && \ (memorder) != rte_memory_order_relaxed); \ typeof(*(addr)) expected_value = (expected); \
lib/eal/include/rte_common.h +1 -1
@@ -45,7 +45,7 @@ extern "C" {#endif #ifdef RTE_TOOLCHAIN_MSVC -#define __rte_constant (e) 0 +#define __rte_constant (e) _Generic((1 ? (void *) ((e) * 0ll) : (int *) 0), int * : 1, void * : 0)#else #define __rte_constant (e) __extension__(__builtin_constant_p(e))#endif
Signature · 1 line
2.48.1.vfs.0.0
v3 cover enable "app" to be compiled with MSVC
In reply to Andre Muezeriev3:
- use clever expression with _Generic for __rte_constant and use it where __builtin_constant_p was being used.
- use %u in csumonly.c and just cast variables to unsigned int.
v2:
- use lcore_count as atomic always, not only when RTE_USE_C11_MEM_MODEL is set.
- use PRIu64 in csumonly.c instead of casting variables to int.
This series fixes many issues that prevent the "app" directory from being compiled with MSVC.
Andre Muezerie (10):
eal: add workaround for __builtin_constant_p
test_alarm: avoid warning about different qualifiers
test-pmd: fix printf format string mismatch
test-pmd: do explicit 64-bit shift to avoid implicit conversion
test-pmd: avoid undefined behavior
test-pmd: avoid non-constant initializer
test-pmd: don't return value from void function
test-pmd: declare lcore_count atomic
test: add workaround for __builtin_constant_p in test_memcpy_perf
app: enable app directory to be compiled with MSVC
app/meson.build | 4 --- app/test-pmd/cmdline.c | 16 +++++---- app/test-pmd/cmdline_flow.c | 22 ++++++------ app/test-pmd/csumonly.c | 23 ++++++------ app/test-pmd/meson.build | 1 - app/test-pmd/testpmd.c | 2 +- app/test-pmd/testpmd.h | 2 ++ app/test-pmd/util.c | 2 +- app/test/test_alarm.c | 12 +++---- app/test/test_memcpy_perf.c | 54 ++++++++++++++--------------- app/test/test_ring_perf.c | 6 +--- lib/eal/include/generic/rte_pause.h | 2 +- lib/eal/include/rte_common.h | 2 +- 13 files changed, 73 insertions(+), 75 deletions(-)
--
2.48.1.vfs.0.0
PATCH v3 4/10 test-pmd: do explicit 64-bit shift to avoid implicit conversion
Compiling with MSVC results in warnings like the one below:
app/test-pmd/util.c(201): warning C4334: '<<': result of 32-bit shift
implicitly converted to 64 bits (was 64-bit shift intended?)
--- app/test-pmd/cmdline.c | 4 ++-- app/test-pmd/testpmd.c | 2 +- app/test-pmd/util.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
app/test-pmd/cmdline.c +2 -2
@@ -12632,11 +12632,11 @@ cmd_config_dynf_specific_parsed(void *parsed_result, } old_port_flags = ports[res->port_id].mbuf_dynf;if (!strcmp (res->value,"set" )) { - ports[res->port_id].mbuf_dynf |=1UL << flag; + ports[res->port_id].mbuf_dynf |=RTE_BIT64 (flag);if (old_port_flags ==0 )add_tx_dynf_callback (res->port_id); }else { - ports[res->port_id].mbuf_dynf &= ~(1UL << flag); + ports[res->port_id].mbuf_dynf &= ~RTE_BIT64 (flag);if (ports[res->port_id].mbuf_dynf ==0 )remove_tx_dynf_callback (res->port_id); }
app/test-pmd/testpmd.c +1 -1
@@ -4152,7 +4152,7 @@ get_eth_dcb_conf(struct rte_eth_conf *eth_conf, enum dcb_mode_enable dcb_mode,for (i =0 ; i < vmdq_rx_conf->nb_pool_maps; i++) { vmdq_rx_conf->pool_map[i].vlan_id = vlan_tags[i]; vmdq_rx_conf->pool_map[i].pools = -1 << (i % vmdq_rx_conf->nb_queue_pools); +RTE_BIT64 (i % vmdq_rx_conf->nb_queue_pools); }for (i =0 ; i <RTE_ETH_DCB_NUM_USER_PRIORITIES ; i++) { vmdq_rx_conf->dcb_tc[i] = i % num_tcs;
app/test-pmd/util.c +1 -1
@@ -201,7 +201,7 @@ dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[],MKDUMPSTR (print_buf, buf_size, cur_len," - dynf %s: %d" , dynf_names[dynf_index], - !!(ol_flags & (1UL << dynf_index))); + !!(ol_flags &RTE_BIT64 (dynf_index))); }if (mb->packet_type) {rte_get_ptype_name (mb->packet_type, buf,sizeof (buf));
Signature · 1 line
2.48.1.vfs.0.0
PATCH v3 2/10 test_alarm: avoid warning about different qualifiers
In reply to Andre MuezerieCompiling with MSVC results in the warning below:
app/test/test_alarm.c(54): warning C4090: 'function':
different '_Atomic' qualifiers
The fix is to use a macro to explicitly drop the qualifier.
--- app/test/test_alarm.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
app/test/test_alarm.c +6 -6
@@ -51,12 +51,12 @@ test_alarm(void) "Expected rte_eal_alarm_cancel to fail with null callback parameter");/* check if can set a alarm for one second */ -TEST_ASSERT_SUCCESS (rte_eal_alarm_set (US_PER_SEC , test_alarm_callback, &triggered), -"Setting one second alarm failed" ); +TEST_ASSERT_SUCCESS (rte_eal_alarm_set (US_PER_SEC , test_alarm_callback, +RTE_PTR_UNQUAL (&triggered)),"Setting one second alarm failed" );/* set a longer alarm that will be canceled. */ -TEST_ASSERT_SUCCESS (rte_eal_alarm_set (10 *US_PER_SEC , test_alarm_callback, &later), -"Setting ten second alarm failed" ); +TEST_ASSERT_SUCCESS (rte_eal_alarm_set (10 *US_PER_SEC , test_alarm_callback, +RTE_PTR_UNQUAL (&later)),"Setting ten second alarm failed" );/* wait for alarm to happen */ while (rte_atomic_load_explicit (&triggered, rte_memory_order_acquire) == false)
@@ -65,11 +65,11 @@ test_alarm(void)TEST_ASSERT (!rte_atomic_load_explicit (&later, rte_memory_order_acquire),"Only one alarm should have fired." ); - ret =rte_eal_alarm_cancel (test_alarm_callback, &triggered); + ret =rte_eal_alarm_cancel (test_alarm_callback,RTE_PTR_UNQUAL (&triggered));TEST_ASSERT (ret ==0 && rte_errno ==ENOENT ,"Canceling alarm after run ret %d: %s" , ret,rte_strerror (rte_errno)); - ret =rte_eal_alarm_cancel (test_alarm_callback, &later); + ret =rte_eal_alarm_cancel (test_alarm_callback,RTE_PTR_UNQUAL (&later));TEST_ASSERT (ret ==1 ,"Canceling ten second alarm failed %d: %s" , ret,rte_strerror (rte_errno));
Signature · 1 line
2.48.1.vfs.0.0
PATCH v3 7/10 test-pmd: don't return value from void function
In reply to Andre MuezerieCompiling with MSVC results in the warning below:
app/test-pmd/cmdline_flow.c(13964): warning C4098: 'cmd_set_raw_parsed':
'void' function returning a value
--- app/test-pmd/cmdline_flow.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
app/test-pmd/cmdline_flow.c +8 -4
@@ -13952,11 +13952,15 @@ cmd_set_raw_parsed(const struct buffer *in)int gtp_psc =-1 ;/* GTP PSC option index. */ const void *src_spec; -if (in->command ==SET_SAMPLE_ACTIONS ) -return cmd_set_raw_parsed_sample (in); +if (in->command ==SET_SAMPLE_ACTIONS ) { +cmd_set_raw_parsed_sample (in); +return ; + }else if (in->command ==SET_IPV6_EXT_PUSH || - in->command ==SET_IPV6_EXT_REMOVE ) -return cmd_set_ipv6_ext_parsed (in); + in->command ==SET_IPV6_EXT_REMOVE ) { +cmd_set_ipv6_ext_parsed (in); +return ; + }RTE_ASSERT (in->command ==SET_RAW_ENCAP || in->command ==SET_RAW_DECAP );if (in->command ==SET_RAW_ENCAP ) {
Signature · 1 line
2.48.1.vfs.0.0
PATCH v3 5/10 test-pmd: avoid undefined behavior
In reply to Andre MuezerieCompiling with MSVC results in warnings like below:
app/test-pmd/cmdline.c(9023): warning C5101: use of preprocessor
directive in function-like macro argument list is undefined behavior
--- app/test-pmd/cmdline.c | 12 ++++++++---- app/test-pmd/testpmd.h | 2 ++ 2 files changed, 10 insertions(+), 4 deletions(-)
app/test-pmd/cmdline.c +8 -4
@@ -8980,6 +8980,14 @@ dump_socket_mem(FILE *f) last_total = total; } +#ifdef RTE_EXEC_ENV_WINDOWS +int +rte_trace_save (void ) +{ +return TEST_SKIPPED ; +} +#endif +static void cmd_dump_parsed (void *parsed_result, __rte_unused struct cmdline *cl, __rte_unused void *data)
@@ -9002,10 +9010,8 @@ static void cmd_dump_parsed(void *parsed_result,rte_devargs_dump (stdout); else if (!strcmp(res->dump, "dump_lcores"))rte_lcore_dump (stdout); -#ifndef RTE_EXEC_ENV_WINDOWS else if (!strcmp(res->dump, "dump_trace"))rte_trace_save (); -#endif else if (!strcmp(res->dump, "dump_log_types"))rte_log_dump (stdout); }
@@ -9020,9 +9026,7 @@ static cmdline_parse_token_string_t cmd_dump_dump ="dump_mempool#" "dump_devargs#" "dump_lcores#" -#ifndef RTE_EXEC_ENV_WINDOWS"dump_trace#" -#endif "dump_log_types");static cmdline_parse_inst_t cmd_dump = {
app/test-pmd/testpmd.h +2 -0
@@ -84,6 +84,8 @@ extern volatile uint8_t f_quit;/* Maximum number of pools supported per Rx queue */ #define MAX_MEMPOOL 8 +#define TEST_SKIPPED 77 +typedef uint32_t lcoreid_t ;typedef uint16_t portid_t ;typedef uint16_t queueid_t ;
Signature · 1 line
2.48.1.vfs.0.0
PATCH v3 6/10 test-pmd: avoid non-constant initializer
In reply to Andre MuezerieCompiling with MSVC results in errors like the one below:
app/test-pmd/cmdline_flow.c(8819): error C2099: initializer
is not a constant
--- app/test-pmd/cmdline_flow.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
app/test-pmd/cmdline_flow.c +3 -7
@@ -8812,8 +8812,6 @@ parse_vc_spec(struct context *ctx, const struct token *token,return -1 ;/* Parse parameter types. */ switch (ctx->curr) { -static const enum index prefix[] =NEXT_ENTRY (COMMON_PREFIX ); -case ITEM_PARAM_IS : index =0 ; objmask =1 ;
@@ -8828,7 +8826,7 @@ parse_vc_spec(struct context *ctx, const struct token *token,/* Modify next token to expect a prefix. */ if (ctx->next_num <2 )return -1 ; - ctx->next[ctx->next_num -2 ] = prefix; + ctx->next[ctx->next_num -2 ] =NEXT_ENTRY (COMMON_PREFIX );/* Fall through. */ case ITEM_PARAM_MASK : index =2 ;
@@ -9270,7 +9268,6 @@ parse_vc_action_rss_type(struct context *ctx, const struct token *token, const char *str, unsigned int len, void *buf, unsigned int size) { - static const enum index next[] = NEXT_ENTRY(ACTION_RSS_TYPE); struct action_rss_data *action_rss_data;unsigned int i;
@@ -9296,7 +9293,7 @@ parse_vc_action_rss_type(struct context *ctx, const struct token *token,/* Repeat token. */ if (ctx->next_num ==RTE_DIM (ctx->next))return -1 ; - ctx->next[ctx->next_num++] = next; + ctx->next[ctx->next_num++] =NEXT_ENTRY (ACTION_RSS_TYPE );if (!ctx->object)return len; action_rss_data = ctx->object;
@@ -9314,7 +9311,6 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token, const char *str, unsigned int len, void *buf, unsigned int size) { - static const enum index next[] = NEXT_ENTRY(ACTION_RSS_QUEUE); struct action_rss_data *action_rss_data;const struct arg *arg;int ret;
@@ -9347,7 +9343,7 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token,/* Repeat token. */ if (ctx->next_num ==RTE_DIM (ctx->next))return -1 ; - ctx->next[ctx->next_num++] = next; + ctx->next[ctx->next_num++] =NEXT_ENTRY (ACTION_RSS_QUEUE ); end:if (!ctx->object)return len;
Signature · 1 line
2.48.1.vfs.0.0
PATCH v3 8/10 test-pmd: declare lcore_count atomic
In reply to Andre MuezerieCompiling with MSVC results in the error below:
app/test/test_ring_perf.c(197): error C7712: address argument to atomic
operation must be a pointer to an atomic integer, 'volatile unsigned int *' is not valid
The fix is to mark lcore_count as atomic.
--- app/test/test_ring_perf.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
app/test/test_ring_perf.c +1 -5
@@ -34,7 +34,7 @@ struct lcore_pair {unsigned c1, c2; }; -static volatile unsigned lcore_count =0 ; +static RTE_ATOMIC (unsigned int ) lcore_count; static void test_ring_print_test_string(unsigned int api_type, int esize,
@@ -193,11 +193,7 @@ enqueue_dequeue_bulk_helper(const unsigned int flag, struct thread_params *p)unsigned int n_remaining;const unsigned int bulk_n = bulk_sizes[p->ring_params->bulk_sizes_i]; -#ifdef RTE_USE_C11_MEM_MODEL if (rte_atomic_fetch_add_explicit (&lcore_count,1 , rte_memory_order_relaxed) +1 !=2 ) -#else - if (__sync_add_and_fetch(&lcore_count, 1) != 2) -#endif while (lcore_count !=2 )rte_pause ();
Signature · 1 line
2.48.1.vfs.0.0
PATCH v3 10/10 app: enable app directory to be compiled with MSVC
In reply to Andre MuezerieEnabled "app" directory to be compiled with MSVC along with all its contents.
Removed flag Wno-deprecated-declarations which is not needed anymore.
--- app/meson.build | 4 ---- app/test-pmd/meson.build | 1 - 2 files changed, 5 deletions(-)
app/meson.build +0 -4
@@ -1,10 +1,6 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017-2019 Intel Corporation -if is_ms_compiler - subdir_done() -endif - disable_apps = ',' + get_option('disable_apps') disable_apps = run_command(list_dir_globs, disable_apps, check: true).stdout().split()
app/test-pmd/meson.build +0 -1
@@ -3,7 +3,6 @@ # override default name to drop the hyphen name = 'testpmd' -cflags += '-Wno-deprecated-declarations' sources = files( '5tswap.c', 'cmdline.c',
Signature · 1 line
2.48.1.vfs.0.0
PATCH v3 9/10 test: add workaround for __builtin_constant_p in test_memcpy_perf
In reply to Andre MuezerieThere's no MSVC equivalent for compiler extension __builtin_constant_p, so a workaround is needed.
--- app/test/test_memcpy_perf.c | 54 ++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 27 deletions(-)
app/test/test_memcpy_perf.c +27 -27
@@ -196,37 +196,37 @@ do { \ }while (0 ) /* Run aligned memcpy tests for each cached/uncached permutation */ -#define ALL_PERF_TESTS_FOR_SIZE (n) \ -do { \ - if (__builtin_constant_p(n)) \ - printf("\nC%6u", (unsigned)n); \ - else \ - printf("\n%7u", (unsigned)n); \ - SINGLE_PERF_TEST(small_buf_write, 1, 0, small_buf_read, 1, 0, n); \ - SINGLE_PERF_TEST(large_buf_write, 0, 0, small_buf_read, 1, 0, n); \ - SINGLE_PERF_TEST(small_buf_write, 1, 0, large_buf_read, 0, 0, n); \ - SINGLE_PERF_TEST(large_buf_write, 0, 0, large_buf_read, 0, 0, n); \ +#define ALL_PERF_TESTS_FOR_SIZE (n) \ +do { \ + if (__rte_constant(n)) \ + printf("\nC%6u", (unsigned int)n); \ + else \ + printf("\n%7u", (unsigned int)n); \ + SINGLE_PERF_TEST(small_buf_write, 1, 0, small_buf_read, 1, 0, n); \ + SINGLE_PERF_TEST(large_buf_write, 0, 0, small_buf_read, 1, 0, n); \ + SINGLE_PERF_TEST(small_buf_write, 1, 0, large_buf_read, 0, 0, n); \ + SINGLE_PERF_TEST(large_buf_write, 0, 0, large_buf_read, 0, 0, n); \ } while (0)/* Run unaligned memcpy tests for each cached/uncached permutation */ -#define ALL_PERF_TESTS_FOR_SIZE_UNALIGNED (n) \ -do { \ - if (__builtin_constant_p(n)) \ - printf("\nC%6u", (unsigned)n); \ - else \ - printf("\n%7u", (unsigned)n); \ - SINGLE_PERF_TEST(small_buf_write, 1, 1, small_buf_read, 1, 5, n); \ - SINGLE_PERF_TEST(large_buf_write, 0, 1, small_buf_read, 1, 5, n); \ - SINGLE_PERF_TEST(small_buf_write, 1, 1, large_buf_read, 0, 5, n); \ - SINGLE_PERF_TEST(large_buf_write, 0, 1, large_buf_read, 0, 5, n); \ +#define ALL_PERF_TESTS_FOR_SIZE_UNALIGNED (n) \ +do { \ + if (__rte_constant(n)) \ + printf("\nC%6u", (unsigned int)n); \ + else \ + printf("\n%7u", (unsigned int)n); \ + SINGLE_PERF_TEST(small_buf_write, 1, 1, small_buf_read, 1, 5, n); \ + SINGLE_PERF_TEST(large_buf_write, 0, 1, small_buf_read, 1, 5, n); \ + SINGLE_PERF_TEST(small_buf_write, 1, 1, large_buf_read, 0, 5, n); \ + SINGLE_PERF_TEST(large_buf_write, 0, 1, large_buf_read, 0, 5, n); \ } while (0)/* Run memcpy tests for constant length */ -#define ALL_PERF_TEST_FOR_CONSTANT \ -do { \ - TEST_CONSTANT(6U); TEST_CONSTANT(64U); TEST_CONSTANT(128U); \ - TEST_CONSTANT(192U); TEST_CONSTANT(256U); TEST_CONSTANT(512U); \ - TEST_CONSTANT(768U); TEST_CONSTANT(1024U); TEST_CONSTANT(1536U); \ +#define ALL_PERF_TEST_FOR_CONSTANT \ +do { \ + TEST_CONSTANT(6U); TEST_CONSTANT(64U); TEST_CONSTANT(128U); \ + TEST_CONSTANT(192U); TEST_CONSTANT(256U); TEST_CONSTANT(512U); \ + TEST_CONSTANT(768U); TEST_CONSTANT(1024U); TEST_CONSTANT(1536U); \ } while (0)/* Run all memcpy tests for aligned constant cases */
@@ -253,7 +253,7 @@ perf_test_variable_aligned(void) {unsigned i;for (i =0 ; i <RTE_DIM (buf_sizes); i++) { -ALL_PERF_TESTS_FOR_SIZE ((size_t )buf_sizes[i]); +ALL_PERF_TESTS_FOR_SIZE (buf_sizes[i]); } }
@@ -263,7 +263,7 @@ perf_test_variable_unaligned(void) {unsigned i;for (i =0 ; i <RTE_DIM (buf_sizes); i++) { -ALL_PERF_TESTS_FOR_SIZE_UNALIGNED ((size_t )buf_sizes[i]); +ALL_PERF_TESTS_FOR_SIZE_UNALIGNED (buf_sizes[i]); } }
Signature · 1 line
2.48.1.vfs.0.0
Re: [PATCH v3 01/10] eal: add workaround for __builtin_constant_p
In reply to Andre Muezerielib/eal/include/rte_common.h extern "C" { · line 51
Quoted 7 lines · On Wed, 19 Feb 2025 18:01:30 -0800 Andre Muezerie…
#ifdef
RTE_TOOLCHAIN_MSVClib/eal/include/rte_common.h +1
-1-#define __rte_constant (e) 0 +#define __rte_constant (e) _Generic((1 ? (void *) ((e) * 0ll) : (int *) 0), int * : 1, void * : 0)#else #define __rte_constant (e) __extension__(__builtin_constant_p(e))#endif
Probably worth some explanation as to what is going on.
PATCH v4 2/10 test_alarm: avoid warning about different qualifiers
In reply to Andre MuezerieCompiling with MSVC results in the warning below:
app/test/test_alarm.c(54): warning C4090: 'function':
different '_Atomic' qualifiers
The fix is to use a macro to explicitly drop the qualifier.
--- app/test/test_alarm.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
app/test/test_alarm.c +6 -6
@@ -51,12 +51,12 @@ test_alarm(void) "Expected rte_eal_alarm_cancel to fail with null callback parameter");/* check if can set a alarm for one second */ -TEST_ASSERT_SUCCESS (rte_eal_alarm_set (US_PER_SEC , test_alarm_callback, &triggered), -"Setting one second alarm failed" ); +TEST_ASSERT_SUCCESS (rte_eal_alarm_set (US_PER_SEC , test_alarm_callback, +RTE_PTR_UNQUAL (&triggered)),"Setting one second alarm failed" );/* set a longer alarm that will be canceled. */ -TEST_ASSERT_SUCCESS (rte_eal_alarm_set (10 *US_PER_SEC , test_alarm_callback, &later), -"Setting ten second alarm failed" ); +TEST_ASSERT_SUCCESS (rte_eal_alarm_set (10 *US_PER_SEC , test_alarm_callback, +RTE_PTR_UNQUAL (&later)),"Setting ten second alarm failed" );/* wait for alarm to happen */ while (rte_atomic_load_explicit (&triggered, rte_memory_order_acquire) == false)
@@ -65,11 +65,11 @@ test_alarm(void)TEST_ASSERT (!rte_atomic_load_explicit (&later, rte_memory_order_acquire),"Only one alarm should have fired." ); - ret =rte_eal_alarm_cancel (test_alarm_callback, &triggered); + ret =rte_eal_alarm_cancel (test_alarm_callback,RTE_PTR_UNQUAL (&triggered));TEST_ASSERT (ret ==0 && rte_errno ==ENOENT ,"Canceling alarm after run ret %d: %s" , ret,rte_strerror (rte_errno)); - ret =rte_eal_alarm_cancel (test_alarm_callback, &later); + ret =rte_eal_alarm_cancel (test_alarm_callback,RTE_PTR_UNQUAL (&later));TEST_ASSERT (ret ==1 ,"Canceling ten second alarm failed %d: %s" , ret,rte_strerror (rte_errno));
Signature · 1 line
2.48.1.vfs.0.0
PATCH v4 3/10 test-pmd: fix printf format string mismatch
In reply to Andre MuezerieCompiling with MSVC results in warnings like the one below:
app/test-pmd/csumonly.c(1085): warning C4477: 'printf' : format string
'%d' requires an argument of type 'int',
but variadic argument 1 has type 'uint64_t'
--- app/test-pmd/csumonly.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-)
app/test-pmd/csumonly.c +12 -11
@@ -1070,7 +1070,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) info.l2_len,rte_be_to_cpu_16 (info.ethertype), info.l3_len, info.l4_proto, info.l4_len, buf);if (rx_ol_flags &RTE_MBUF_F_RX_LRO ) -printf ("rx: m->lro_segsz=%u\n" , m->tso_segsz); +printf ("rx: m->lro_segsz=%u\n" , (unsigned int )m->tso_segsz);if (info.is_tunnel ==1 ) printf("rx: outer_l2_len=%d outer_ethertype=%x " "outer_l3_len=%d\n", info.outer_l2_len,
@@ -1082,28 +1082,29 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) RTE_ETH_TX_OFFLOAD_TCP_CKSUM | RTE_ETH_TX_OFFLOAD_SCTP_CKSUM)) || info.tso_segsz != 0) -printf ("tx: m->l2_len=%d m->l3_len=%d " -"m->l4_len=%d\n" , - m->l2_len, m->l3_len, m->l4_len); +printf ("tx: m->l2_len=%u m->l3_len=%u " +"m->l4_len=%u\n" , + (unsigned int )m->l2_len, (unsigned int )m->l3_len, + (unsigned int )m->l4_len);if (info.is_tunnel ==1 ) {if ((tx_offloads &RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM ) || (tx_offloads &RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM ) || (tx_ol_flags &RTE_MBUF_F_TX_OUTER_IPV6 )) -printf ("tx: m->outer_l2_len=%d " -"m->outer_l3_len=%d\n" , - m->outer_l2_len, - m->outer_l3_len); +printf ("tx: m->outer_l2_len=%u " +"m->outer_l3_len=%u\n" , + (unsigned int )m->outer_l2_len, + (unsigned int )m->outer_l3_len);if (info.tunnel_tso_segsz !=0 && (m->ol_flags & (RTE_MBUF_F_TX_TCP_SEG |RTE_MBUF_F_TX_UDP_SEG ))) -printf ("tx: m->tso_segsz=%d\n" , - m->tso_segsz); +printf ("tx: m->tso_segsz=%u\n" , + (unsigned int )m->tso_segsz); }else if (info.tso_segsz !=0 && (m->ol_flags & (RTE_MBUF_F_TX_TCP_SEG |RTE_MBUF_F_TX_UDP_SEG ))) -printf ("tx: m->tso_segsz=%d\n" , m->tso_segsz); +printf ("tx: m->tso_segsz=%u\n" , (unsigned int )m->tso_segsz);rte_get_tx_ol_flag_list (m->ol_flags, buf,sizeof (buf));printf ("tx: flags=%s" , buf);printf ("\n" );
Signature · 1 line
2.48.1.vfs.0.0
v4 cover enable "app" to be compiled with MSVC
In reply to Andre Muezeriev4:
- add explanation about the expression used in __rte_constant during v3.
v3:
- use clever expression with _Generic for __rte_constant and use it where __builtin_constant_p was being used.
- use %u in csumonly.c and just cast variables to unsigned int.
v2:
- use lcore_count as atomic always, not only when RTE_USE_C11_MEM_MODEL is set.
- use PRIu64 in csumonly.c instead of casting variables to int.
This series fixes many issues that prevent the "app" directory from being compiled with MSVC.
Andre Muezerie (10):
eal: add workaround for __builtin_constant_p
test_alarm: avoid warning about different qualifiers
test-pmd: fix printf format string mismatch
test-pmd: do explicit 64-bit shift to avoid implicit conversion
test-pmd: avoid undefined behavior
test-pmd: avoid non-constant initializer
test-pmd: don't return value from void function
test-pmd: declare lcore_count atomic
test: add workaround for __builtin_constant_p in test_memcpy_perf
app: enable app directory to be compiled with MSVC
app/meson.build | 4 --- app/test-pmd/cmdline.c | 16 +++++---- app/test-pmd/cmdline_flow.c | 22 ++++++------ app/test-pmd/csumonly.c | 23 ++++++------ app/test-pmd/meson.build | 1 - app/test-pmd/testpmd.c | 2 +- app/test-pmd/testpmd.h | 2 ++ app/test-pmd/util.c | 2 +- app/test/test_alarm.c | 12 +++---- app/test/test_memcpy_perf.c | 54 ++++++++++++++--------------- app/test/test_ring_perf.c | 6 +--- lib/eal/include/generic/rte_pause.h | 2 +- lib/eal/include/rte_common.h | 34 +++++++++++++++++- 13 files changed, 105 insertions(+), 75 deletions(-)
--
2.48.1.vfs.0.0
PATCH v4 4/10 test-pmd: do explicit 64-bit shift to avoid implicit conversion
Compiling with MSVC results in warnings like the one below:
app/test-pmd/util.c(201): warning C4334: '<<': result of 32-bit shift
implicitly converted to 64 bits (was 64-bit shift intended?)
--- app/test-pmd/cmdline.c | 4 ++-- app/test-pmd/testpmd.c | 2 +- app/test-pmd/util.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
app/test-pmd/cmdline.c +2 -2
@@ -12632,11 +12632,11 @@ cmd_config_dynf_specific_parsed(void *parsed_result, } old_port_flags = ports[res->port_id].mbuf_dynf;if (!strcmp (res->value,"set" )) { - ports[res->port_id].mbuf_dynf |=1UL << flag; + ports[res->port_id].mbuf_dynf |=RTE_BIT64 (flag);if (old_port_flags ==0 )add_tx_dynf_callback (res->port_id); }else { - ports[res->port_id].mbuf_dynf &= ~(1UL << flag); + ports[res->port_id].mbuf_dynf &= ~RTE_BIT64 (flag);if (ports[res->port_id].mbuf_dynf ==0 )remove_tx_dynf_callback (res->port_id); }
app/test-pmd/testpmd.c +1 -1
@@ -4152,7 +4152,7 @@ get_eth_dcb_conf(struct rte_eth_conf *eth_conf, enum dcb_mode_enable dcb_mode,for (i =0 ; i < vmdq_rx_conf->nb_pool_maps; i++) { vmdq_rx_conf->pool_map[i].vlan_id = vlan_tags[i]; vmdq_rx_conf->pool_map[i].pools = -1 << (i % vmdq_rx_conf->nb_queue_pools); +RTE_BIT64 (i % vmdq_rx_conf->nb_queue_pools); }for (i =0 ; i <RTE_ETH_DCB_NUM_USER_PRIORITIES ; i++) { vmdq_rx_conf->dcb_tc[i] = i % num_tcs;
app/test-pmd/util.c +1 -1
@@ -201,7 +201,7 @@ dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[],MKDUMPSTR (print_buf, buf_size, cur_len," - dynf %s: %d" , dynf_names[dynf_index], - !!(ol_flags & (1UL << dynf_index))); + !!(ol_flags &RTE_BIT64 (dynf_index))); }if (mb->packet_type) {rte_get_ptype_name (mb->packet_type, buf,sizeof (buf));
Signature · 1 line
2.48.1.vfs.0.0
PATCH v4 1/10 eal: add workaround for __builtin_constant_p
In reply to Andre MuezerieThere's no MSVC equivalent for compiler extension __builtin_constant_p, but the same result can be obtained through a clever expression using _Generic.
This patch redefines the macro __rte_constant when msvc is used and uses it as a replacement for __builtin_constant_p.
--- lib/eal/include/generic/rte_pause.h | 2 +- lib/eal/include/rte_common.h | 34 ++++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 2 deletions(-)
lib/eal/include/generic/rte_pause.h +1 -1
@@ -130,7 +130,7 @@ rte_wait_until_equal_64(volatile uint64_t *addr, uint64_t expected,* rte_memory_order_acquire and rte_memory_order_relaxed. */ #define RTE_WAIT_UNTIL_MASKED (addr, mask, cond, expected, memorder) do { \ - RTE_BUILD_BUG_ON(!__builtin_constant_p(memorder)); \ + RTE_BUILD_BUG_ON(!__rte_constant(memorder)); \ RTE_BUILD_BUG_ON((memorder) != rte_memory_order_acquire && \ (memorder) != rte_memory_order_relaxed); \ typeof(*(addr)) expected_value = (expected); \
lib/eal/include/rte_common.h +33 -1
@@ -44,8 +44,40 @@ extern "C" {#endif #endif +/* +* Macro __rte_constant checks if an expression's value can be determined at +* compile time. It takes a single argument, the expression to test, and +* returns 1 if the expression is a compile-time constant, and 0 otherwise. +* For most compilers it uses built-in function __builtin_constant_p, but for +* MSVC it uses a different method because MSVC does not have an equivalent +* to __builtin_constant_p. +* +* The trick used with MSVC relies on the way null pointer constants interact +* with the type of a ?: expression: +* An integer constant expression with the value 0, or such an expression cast +* to type void *, is called a null pointer constant. +* If both the second and third operands (of the ?: expression) are pointers or +* one is a null pointer constant and the other is a pointer, the result type +* is a pointer to a type qualified with all the type qualifiers of the types +* referenced by both operands. Furthermore, if both operands are pointers to +* compatible types or to differently qualified versions of compatible types, +* the result type is a pointer to an appropriately qualified version of the +* composite type; if one operand is a null pointer constant, the result has +* the type of the other operand; otherwise, one operand is a pointer to void +* or a qualified version of void, in which case the result type is a pointer +* to an appropriately qualified version of void. +* +* The _Generic keyword then checks the type of the expression +* (void *) ((e) * 0ll). It matches this type against the types listed in the +* _Generic construct: +* - If the type is int *, the result is 1. +* - If the type is void *, the result is 0. +* +* This explanation with some more details can be found at: +* https://stackoverflow.com/questions/49480442/detecting-integer-constant-expressions-in-macros +*/ #ifdef RTE_TOOLCHAIN_MSVC -#define __rte_constant (e) 0 +#define __rte_constant (e) _Generic((1 ? (void *) ((e) * 0ll) : (int *) 0), int * : 1, void * : 0)#else #define __rte_constant (e) __extension__(__builtin_constant_p(e))#endif
Signature · 1 line
2.48.1.vfs.0.0
PATCH v4 5/10 test-pmd: avoid undefined behavior
In reply to Andre MuezerieCompiling with MSVC results in warnings like below:
app/test-pmd/cmdline.c(9023): warning C5101: use of preprocessor
directive in function-like macro argument list is undefined behavior
--- app/test-pmd/cmdline.c | 12 ++++++++---- app/test-pmd/testpmd.h | 2 ++ 2 files changed, 10 insertions(+), 4 deletions(-)
app/test-pmd/cmdline.c +8 -4
@@ -8980,6 +8980,14 @@ dump_socket_mem(FILE *f) last_total = total; } +#ifdef RTE_EXEC_ENV_WINDOWS +int +rte_trace_save (void ) +{ +return TEST_SKIPPED ; +} +#endif +static void cmd_dump_parsed (void *parsed_result, __rte_unused struct cmdline *cl, __rte_unused void *data)
@@ -9002,10 +9010,8 @@ static void cmd_dump_parsed(void *parsed_result,rte_devargs_dump (stdout); else if (!strcmp(res->dump, "dump_lcores"))rte_lcore_dump (stdout); -#ifndef RTE_EXEC_ENV_WINDOWS else if (!strcmp(res->dump, "dump_trace"))rte_trace_save (); -#endif else if (!strcmp(res->dump, "dump_log_types"))rte_log_dump (stdout); }
@@ -9020,9 +9026,7 @@ static cmdline_parse_token_string_t cmd_dump_dump ="dump_mempool#" "dump_devargs#" "dump_lcores#" -#ifndef RTE_EXEC_ENV_WINDOWS"dump_trace#" -#endif "dump_log_types");static cmdline_parse_inst_t cmd_dump = {
app/test-pmd/testpmd.h +2 -0
@@ -84,6 +84,8 @@ extern volatile uint8_t f_quit;/* Maximum number of pools supported per Rx queue */ #define MAX_MEMPOOL 8 +#define TEST_SKIPPED 77 +typedef uint32_t lcoreid_t ;typedef uint16_t portid_t ;typedef uint16_t queueid_t ;
Signature · 1 line
2.48.1.vfs.0.0
PATCH v4 10/10 app: enable app directory to be compiled with MSVC
In reply to Andre MuezerieEnabled "app" directory to be compiled with MSVC along with all its contents.
Removed flag Wno-deprecated-declarations which is not needed anymore.
--- app/meson.build | 4 ---- app/test-pmd/meson.build | 1 - 2 files changed, 5 deletions(-)
app/meson.build +0 -4
@@ -1,10 +1,6 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017-2019 Intel Corporation -if is_ms_compiler - subdir_done() -endif - disable_apps = ',' + get_option('disable_apps') disable_apps = run_command(list_dir_globs, disable_apps, check: true).stdout().split()
app/test-pmd/meson.build +0 -1
@@ -3,7 +3,6 @@ # override default name to drop the hyphen name = 'testpmd' -cflags += '-Wno-deprecated-declarations' sources = files( '5tswap.c', 'cmdline.c',
Signature · 1 line
2.48.1.vfs.0.0
PATCH v4 8/10 test-pmd: declare lcore_count atomic
In reply to Andre MuezerieCompiling with MSVC results in the error below:
app/test/test_ring_perf.c(197): error C7712: address argument to atomic
operation must be a pointer to an atomic integer, 'volatile unsigned int *' is not valid
The fix is to mark lcore_count as atomic.
--- app/test/test_ring_perf.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
app/test/test_ring_perf.c +1 -5
@@ -34,7 +34,7 @@ struct lcore_pair {unsigned c1, c2; }; -static volatile unsigned lcore_count =0 ; +static RTE_ATOMIC (unsigned int ) lcore_count; static void test_ring_print_test_string(unsigned int api_type, int esize,
@@ -193,11 +193,7 @@ enqueue_dequeue_bulk_helper(const unsigned int flag, struct thread_params *p)unsigned int n_remaining;const unsigned int bulk_n = bulk_sizes[p->ring_params->bulk_sizes_i]; -#ifdef RTE_USE_C11_MEM_MODEL if (rte_atomic_fetch_add_explicit (&lcore_count,1 , rte_memory_order_relaxed) +1 !=2 ) -#else - if (__sync_add_and_fetch(&lcore_count, 1) != 2) -#endif while (lcore_count !=2 )rte_pause ();
Signature · 1 line
2.48.1.vfs.0.0
PATCH v4 7/10 test-pmd: don't return value from void function
In reply to Andre MuezerieCompiling with MSVC results in the warning below:
app/test-pmd/cmdline_flow.c(13964): warning C4098: 'cmd_set_raw_parsed':
'void' function returning a value
--- app/test-pmd/cmdline_flow.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
app/test-pmd/cmdline_flow.c +8 -4
@@ -13952,11 +13952,15 @@ cmd_set_raw_parsed(const struct buffer *in)int gtp_psc =-1 ;/* GTP PSC option index. */ const void *src_spec; -if (in->command ==SET_SAMPLE_ACTIONS ) -return cmd_set_raw_parsed_sample (in); +if (in->command ==SET_SAMPLE_ACTIONS ) { +cmd_set_raw_parsed_sample (in); +return ; + }else if (in->command ==SET_IPV6_EXT_PUSH || - in->command ==SET_IPV6_EXT_REMOVE ) -return cmd_set_ipv6_ext_parsed (in); + in->command ==SET_IPV6_EXT_REMOVE ) { +cmd_set_ipv6_ext_parsed (in); +return ; + }RTE_ASSERT (in->command ==SET_RAW_ENCAP || in->command ==SET_RAW_DECAP );if (in->command ==SET_RAW_ENCAP ) {
Signature · 1 line
2.48.1.vfs.0.0
PATCH v4 9/10 test: add workaround for __builtin_constant_p in test_memcpy_perf
In reply to Andre MuezerieThere's no MSVC equivalent for compiler extension __builtin_constant_p, so a workaround is needed.
--- app/test/test_memcpy_perf.c | 54 ++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 27 deletions(-)
app/test/test_memcpy_perf.c +27 -27
@@ -196,37 +196,37 @@ do { \ }while (0 ) /* Run aligned memcpy tests for each cached/uncached permutation */ -#define ALL_PERF_TESTS_FOR_SIZE (n) \ -do { \ - if (__builtin_constant_p(n)) \ - printf("\nC%6u", (unsigned)n); \ - else \ - printf("\n%7u", (unsigned)n); \ - SINGLE_PERF_TEST(small_buf_write, 1, 0, small_buf_read, 1, 0, n); \ - SINGLE_PERF_TEST(large_buf_write, 0, 0, small_buf_read, 1, 0, n); \ - SINGLE_PERF_TEST(small_buf_write, 1, 0, large_buf_read, 0, 0, n); \ - SINGLE_PERF_TEST(large_buf_write, 0, 0, large_buf_read, 0, 0, n); \ +#define ALL_PERF_TESTS_FOR_SIZE (n) \ +do { \ + if (__rte_constant(n)) \ + printf("\nC%6u", (unsigned int)n); \ + else \ + printf("\n%7u", (unsigned int)n); \ + SINGLE_PERF_TEST(small_buf_write, 1, 0, small_buf_read, 1, 0, n); \ + SINGLE_PERF_TEST(large_buf_write, 0, 0, small_buf_read, 1, 0, n); \ + SINGLE_PERF_TEST(small_buf_write, 1, 0, large_buf_read, 0, 0, n); \ + SINGLE_PERF_TEST(large_buf_write, 0, 0, large_buf_read, 0, 0, n); \ } while (0)/* Run unaligned memcpy tests for each cached/uncached permutation */ -#define ALL_PERF_TESTS_FOR_SIZE_UNALIGNED (n) \ -do { \ - if (__builtin_constant_p(n)) \ - printf("\nC%6u", (unsigned)n); \ - else \ - printf("\n%7u", (unsigned)n); \ - SINGLE_PERF_TEST(small_buf_write, 1, 1, small_buf_read, 1, 5, n); \ - SINGLE_PERF_TEST(large_buf_write, 0, 1, small_buf_read, 1, 5, n); \ - SINGLE_PERF_TEST(small_buf_write, 1, 1, large_buf_read, 0, 5, n); \ - SINGLE_PERF_TEST(large_buf_write, 0, 1, large_buf_read, 0, 5, n); \ +#define ALL_PERF_TESTS_FOR_SIZE_UNALIGNED (n) \ +do { \ + if (__rte_constant(n)) \ + printf("\nC%6u", (unsigned int)n); \ + else \ + printf("\n%7u", (unsigned int)n); \ + SINGLE_PERF_TEST(small_buf_write, 1, 1, small_buf_read, 1, 5, n); \ + SINGLE_PERF_TEST(large_buf_write, 0, 1, small_buf_read, 1, 5, n); \ + SINGLE_PERF_TEST(small_buf_write, 1, 1, large_buf_read, 0, 5, n); \ + SINGLE_PERF_TEST(large_buf_write, 0, 1, large_buf_read, 0, 5, n); \ } while (0)/* Run memcpy tests for constant length */ -#define ALL_PERF_TEST_FOR_CONSTANT \ -do { \ - TEST_CONSTANT(6U); TEST_CONSTANT(64U); TEST_CONSTANT(128U); \ - TEST_CONSTANT(192U); TEST_CONSTANT(256U); TEST_CONSTANT(512U); \ - TEST_CONSTANT(768U); TEST_CONSTANT(1024U); TEST_CONSTANT(1536U); \ +#define ALL_PERF_TEST_FOR_CONSTANT \ +do { \ + TEST_CONSTANT(6U); TEST_CONSTANT(64U); TEST_CONSTANT(128U); \ + TEST_CONSTANT(192U); TEST_CONSTANT(256U); TEST_CONSTANT(512U); \ + TEST_CONSTANT(768U); TEST_CONSTANT(1024U); TEST_CONSTANT(1536U); \ } while (0)/* Run all memcpy tests for aligned constant cases */
@@ -253,7 +253,7 @@ perf_test_variable_aligned(void) {unsigned i;for (i =0 ; i <RTE_DIM (buf_sizes); i++) { -ALL_PERF_TESTS_FOR_SIZE ((size_t )buf_sizes[i]); +ALL_PERF_TESTS_FOR_SIZE (buf_sizes[i]); } }
@@ -263,7 +263,7 @@ perf_test_variable_unaligned(void) {unsigned i;for (i =0 ; i <RTE_DIM (buf_sizes); i++) { -ALL_PERF_TESTS_FOR_SIZE_UNALIGNED ((size_t )buf_sizes[i]); +ALL_PERF_TESTS_FOR_SIZE_UNALIGNED (buf_sizes[i]); } }
Signature · 1 line
2.48.1.vfs.0.0
PATCH v4 6/10 test-pmd: avoid non-constant initializer
In reply to Andre MuezerieCompiling with MSVC results in errors like the one below:
app/test-pmd/cmdline_flow.c(8819): error C2099: initializer
is not a constant
--- app/test-pmd/cmdline_flow.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
app/test-pmd/cmdline_flow.c +3 -7
@@ -8812,8 +8812,6 @@ parse_vc_spec(struct context *ctx, const struct token *token,return -1 ;/* Parse parameter types. */ switch (ctx->curr) { -static const enum index prefix[] =NEXT_ENTRY (COMMON_PREFIX ); -case ITEM_PARAM_IS : index =0 ; objmask =1 ;
@@ -8828,7 +8826,7 @@ parse_vc_spec(struct context *ctx, const struct token *token,/* Modify next token to expect a prefix. */ if (ctx->next_num <2 )return -1 ; - ctx->next[ctx->next_num -2 ] = prefix; + ctx->next[ctx->next_num -2 ] =NEXT_ENTRY (COMMON_PREFIX );/* Fall through. */ case ITEM_PARAM_MASK : index =2 ;
@@ -9270,7 +9268,6 @@ parse_vc_action_rss_type(struct context *ctx, const struct token *token, const char *str, unsigned int len, void *buf, unsigned int size) { - static const enum index next[] = NEXT_ENTRY(ACTION_RSS_TYPE); struct action_rss_data *action_rss_data;unsigned int i;
@@ -9296,7 +9293,7 @@ parse_vc_action_rss_type(struct context *ctx, const struct token *token,/* Repeat token. */ if (ctx->next_num ==RTE_DIM (ctx->next))return -1 ; - ctx->next[ctx->next_num++] = next; + ctx->next[ctx->next_num++] =NEXT_ENTRY (ACTION_RSS_TYPE );if (!ctx->object)return len; action_rss_data = ctx->object;
@@ -9314,7 +9311,6 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token, const char *str, unsigned int len, void *buf, unsigned int size) { - static const enum index next[] = NEXT_ENTRY(ACTION_RSS_QUEUE); struct action_rss_data *action_rss_data;const struct arg *arg;int ret;
@@ -9347,7 +9343,7 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token,/* Repeat token. */ if (ctx->next_num ==RTE_DIM (ctx->next))return -1 ; - ctx->next[ctx->next_num++] = next; + ctx->next[ctx->next_num++] =NEXT_ENTRY (ACTION_RSS_QUEUE ); end:if (!ctx->object)return len;
Signature · 1 line
2.48.1.vfs.0.0
Quoted 43 lines · On Thu, 20 Feb 2025 13:30:54 -0800 Andre Muezerie…
v4:
- add explanation about the expression used in__rte_constantduring v3.v3:
- use clever expression with_Genericfor__rte_constantand use it where__builtin_constant_pwas being used.
- use %u incsumonly.cand just cast variables to unsigned int.v2:
- uselcore_countas atomic always, not only whenRTE_USE_C11_MEM_MODELis set.
- use PRIu64 incsumonly.cinstead of casting variables to int.This series fixes many issues that prevent the "app" directory from being compiled with MSVC.
Andre Muezerie (10):
eal: add workaround for__builtin_constant_p
test_alarm: avoid warning about different qualifiers
test-pmd: fix printf format string mismatch
test-pmd: do explicit 64-bit shift to avoid implicit conversion
test-pmd: avoid undefined behavior
test-pmd: avoid non-constant initializer
test-pmd: don't return value from void function
test-pmd: declarelcore_countatomic
test: add workaround for__builtin_constant_pintest_memcpy_perf
app: enable app directory to be compiled with MSVCapp/meson.build | 4 --- app/test-pmd/cmdline.c | 16 +++++---- app/test-pmd/cmdline_flow.c | 22 ++++++------ app/test-pmd/csumonly.c | 23 ++++++------ app/test-pmd/meson.build | 1 - app/test-pmd/testpmd.c | 2 +- app/test-pmd/testpmd.h | 2 ++ app/test-pmd/util.c | 2 +- app/test/test_alarm.c | 12 +++---- app/test/test_memcpy_perf.c | 54 ++++++++++++++--------------- app/test/test_ring_perf.c | 6 +--- lib/eal/include/generic/rte_pause.h | 2 +- lib/eal/include/rte_common.h | 34 +++++++++++++++++- 13 files changed, 105 insertions(+), 75 deletions(-)
Quoted 3 lines
--
2.48.1.vfs.0.0
RE: [PATCH v4 08/10] test-pmd: declare lcore_count atomic
In reply to Andre MuezerieQuoted 21 lines
Compiling with MSVC results in the error below:
app/test/test_ring_perf.c(197): error C7712: address argument to atomic
operation must be a pointer to an atomic integer, 'volatile unsigned int *' is not validThe fix is to mark
lcore_countas atomic.Signed-off-by Andre Muezerie <[email protected]>Signed-off-by Chengwen Feng <[email protected]>--- app/test/test_ring_perf.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)app/test/test_ring_perf.c +0
-0
app/test/test_ring_perf.c struct lcore_pair { · line 37
Quoted 5 lines
app/test/test_ring_perf.c +1
-1@@ -34,7 +34,7 @@ struct lcore_pair {unsigned c1, c2; }; -static volatile unsigned lcore_count =0 ; +static RTE_ATOMIC (unsigned int ) lcore_count;
But for not-MSVC builds RTE_ATOMIC() by default means nothing.
If you are removing volatile, then I think, you need to fix the code to ensure that all reads/writes to this var are done with atomic ops.
Or have both - volatile and RTE_ATOMIC()
Quoted 17 lines
app/test/test_ring_perf.c +0
-5static void test_ring_print_test_string(unsigned int api_type, int esize,@@ -193,11 +193,7 @@ enqueue_dequeue_bulk_helper(const unsigned int flag, struct thread_params *p)unsigned int n_remaining;const unsigned int bulk_n = bulk_sizes[p->ring_params->bulk_sizes_i]; -#ifdef RTE_USE_C11_MEM_MODEL if (rte_atomic_fetch_add_explicit (&lcore_count,1 , rte_memory_order_relaxed) +1 !=2 ) -#else -if (__sync_add_and_fetch (&lcore_count,1 ) !=2 ) -#endifwhile (lcore_count !=2 )rte_pause (); --2.48.1.vfs.0.0
Re: [PATCH v4 03/10] test-pmd: fix printf format string mismatch
In reply to Andre MuezerieQuoted 6 lines · Andre Muezerie
Compiling with MSVC results in warnings like the one below:
app/test-pmd/csumonly.c(1085): warning C4477: 'printf' : format string
'%d' requires an argument of type 'int',
but variadic argument 1 has type 'uint64_t'
Quoted 6 lines
Signed-off-by Andre Muezerie <[email protected]>Signed-off-by Chengwen Feng <[email protected]>--- app/test-pmd/csumonly.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-)
RE: [PATCH v4 01/10] eal: add workaround for __builtin_constant_p
In reply to Andre MuezerieThank you for this updated MSVC variant of the macro, and its detailed description.
Re: [PATCH v4 01/10] eal: add workaround for __builtin_constant_p
Quoted 3 lines · Morten Brørup
Thank you for this updated MSVC variant of the macro, and its detailed description.
Acked-by Morten Brørup <[email protected]>
Sure. Thank you for pushing for this better solution.
Re: [PATCH v4 08/10] test-pmd: declare lcore_count atomic
In reply to Konstantin AnanyevQuoted 24 lines · Konstantin Ananyev
Quoted 24 lines
Compiling with MSVC results in the error below:
app/test/test_ring_perf.c(197): error C7712: address argument to atomic
operation must be a pointer to an atomic integer, 'volatile unsigned int *' is not validThe fix is to mark
lcore_countas atomic.Signed-off-by Andre Muezerie <[email protected]>Signed-off-by Chengwen Feng <[email protected]>--- app/test/test_ring_perf.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)app/test/test_ring_perf.c +0
-0@@ -34,7 +34,7 @@ struct lcore_pair {unsigned c1, c2; };
Quoted 7 lines
app/test/test_ring_perf.c struct lcore_pair { · line 37
Quoted 2 lines
app/test/test_ring_perf.c +1
-1-static volatile unsigned lcore_count =0 ; +static RTE_ATOMIC (unsigned int ) lcore_count;But for not-MSVC builds
RTE_ATOMIC()by default means nothing.
If you are removing volatile, then I think, you need to fix the code to ensure that all reads/writes to this var are done with atomic ops.
Or have both - volatile andRTE_ATOMIC()
Good point.
I'll use both volatile and RTE_ATOMIC() in the next series.
Quoted 19 lines
Quoted 19 lines
app/test/test_ring_perf.c +0
-5static void test_ring_print_test_string(unsigned int api_type, int esize,@@ -193,11 +193,7 @@ enqueue_dequeue_bulk_helper(const unsigned int flag, struct thread_params *p)unsigned int n_remaining;const unsigned int bulk_n = bulk_sizes[p->ring_params->bulk_sizes_i]; -#ifdef RTE_USE_C11_MEM_MODEL if (rte_atomic_fetch_add_explicit (&lcore_count,1 , rte_memory_order_relaxed) +1 !=2 ) -#else -if (__sync_add_and_fetch (&lcore_count,1 ) !=2 ) -#endifwhile (lcore_count !=2 )rte_pause (); --2.48.1.vfs.0.0
v5 cover enable "app" to be compiled with MSVC
In reply to Andre Muezeriev5:
- add "volatile" to declaration of lcore_count in test_ring_perf.c.
v4:
- add explanation about the expression used in __rte_constant during v3.
v3:
- use clever expression with _Generic for __rte_constant and use it where __builtin_constant_p was being used.
- use %u in csumonly.c and just cast variables to unsigned int.
v2:
- use lcore_count as atomic always, not only when RTE_USE_C11_MEM_MODEL is set.
- use PRIu64 in csumonly.c instead of casting variables to int.
This series fixes many issues that prevent the "app" directory from being compiled with MSVC.
Andre Muezerie (10):
eal: add workaround for __builtin_constant_p
test_alarm: avoid warning about different qualifiers
test-pmd: fix printf format string mismatch
test-pmd: do explicit 64-bit shift to avoid implicit conversion
test-pmd: avoid undefined behavior
test-pmd: avoid non-constant initializer
test-pmd: don't return value from void function
test-pmd: declare lcore_count atomic
test: add workaround for __builtin_constant_p in test_memcpy_perf
app: enable app directory to be compiled with MSVC
app/meson.build | 4 --- app/test-pmd/cmdline.c | 16 +++++---- app/test-pmd/cmdline_flow.c | 22 ++++++------ app/test-pmd/csumonly.c | 23 ++++++------ app/test-pmd/meson.build | 1 - app/test-pmd/testpmd.c | 2 +- app/test-pmd/testpmd.h | 2 ++ app/test-pmd/util.c | 2 +- app/test/test_alarm.c | 12 +++---- app/test/test_memcpy_perf.c | 54 ++++++++++++++--------------- app/test/test_ring_perf.c | 6 +--- lib/eal/include/generic/rte_pause.h | 2 +- lib/eal/include/rte_common.h | 34 +++++++++++++++++- 13 files changed, 105 insertions(+), 75 deletions(-)
--
2.48.1.vfs.0.0
PATCH v5 2/10 test_alarm: avoid warning about different qualifiers
Compiling with MSVC results in the warning below:
app/test/test_alarm.c(54): warning C4090: 'function':
different '_Atomic' qualifiers
The fix is to use a macro to explicitly drop the qualifier.
--- app/test/test_alarm.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
app/test/test_alarm.c +6 -6
@@ -51,12 +51,12 @@ test_alarm(void) "Expected rte_eal_alarm_cancel to fail with null callback parameter");/* check if can set a alarm for one second */ -TEST_ASSERT_SUCCESS (rte_eal_alarm_set (US_PER_SEC , test_alarm_callback, &triggered), -"Setting one second alarm failed" ); +TEST_ASSERT_SUCCESS (rte_eal_alarm_set (US_PER_SEC , test_alarm_callback, +RTE_PTR_UNQUAL (&triggered)),"Setting one second alarm failed" );/* set a longer alarm that will be canceled. */ -TEST_ASSERT_SUCCESS (rte_eal_alarm_set (10 *US_PER_SEC , test_alarm_callback, &later), -"Setting ten second alarm failed" ); +TEST_ASSERT_SUCCESS (rte_eal_alarm_set (10 *US_PER_SEC , test_alarm_callback, +RTE_PTR_UNQUAL (&later)),"Setting ten second alarm failed" );/* wait for alarm to happen */ while (rte_atomic_load_explicit (&triggered, rte_memory_order_acquire) == false)
@@ -65,11 +65,11 @@ test_alarm(void)TEST_ASSERT (!rte_atomic_load_explicit (&later, rte_memory_order_acquire),"Only one alarm should have fired." ); - ret =rte_eal_alarm_cancel (test_alarm_callback, &triggered); + ret =rte_eal_alarm_cancel (test_alarm_callback,RTE_PTR_UNQUAL (&triggered));TEST_ASSERT (ret ==0 && rte_errno ==ENOENT ,"Canceling alarm after run ret %d: %s" , ret,rte_strerror (rte_errno)); - ret =rte_eal_alarm_cancel (test_alarm_callback, &later); + ret =rte_eal_alarm_cancel (test_alarm_callback,RTE_PTR_UNQUAL (&later));TEST_ASSERT (ret ==1 ,"Canceling ten second alarm failed %d: %s" , ret,rte_strerror (rte_errno));
Signature · 1 line
2.48.1.vfs.0.0
PATCH v5 3/10 test-pmd: fix printf format string mismatch
In reply to Andre MuezerieCompiling with MSVC results in warnings like the one below:
app/test-pmd/csumonly.c(1085): warning C4477: 'printf' : format string
'%d' requires an argument of type 'int',
but variadic argument 1 has type 'uint64_t'
--- app/test-pmd/csumonly.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-)
app/test-pmd/csumonly.c +12 -11
@@ -1070,7 +1070,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) info.l2_len,rte_be_to_cpu_16 (info.ethertype), info.l3_len, info.l4_proto, info.l4_len, buf);if (rx_ol_flags &RTE_MBUF_F_RX_LRO ) -printf ("rx: m->lro_segsz=%u\n" , m->tso_segsz); +printf ("rx: m->lro_segsz=%u\n" , (unsigned int )m->tso_segsz);if (info.is_tunnel ==1 ) printf("rx: outer_l2_len=%d outer_ethertype=%x " "outer_l3_len=%d\n", info.outer_l2_len,
@@ -1082,28 +1082,29 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) RTE_ETH_TX_OFFLOAD_TCP_CKSUM | RTE_ETH_TX_OFFLOAD_SCTP_CKSUM)) || info.tso_segsz != 0) -printf ("tx: m->l2_len=%d m->l3_len=%d " -"m->l4_len=%d\n" , - m->l2_len, m->l3_len, m->l4_len); +printf ("tx: m->l2_len=%u m->l3_len=%u " +"m->l4_len=%u\n" , + (unsigned int )m->l2_len, (unsigned int )m->l3_len, + (unsigned int )m->l4_len);if (info.is_tunnel ==1 ) {if ((tx_offloads &RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM ) || (tx_offloads &RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM ) || (tx_ol_flags &RTE_MBUF_F_TX_OUTER_IPV6 )) -printf ("tx: m->outer_l2_len=%d " -"m->outer_l3_len=%d\n" , - m->outer_l2_len, - m->outer_l3_len); +printf ("tx: m->outer_l2_len=%u " +"m->outer_l3_len=%u\n" , + (unsigned int )m->outer_l2_len, + (unsigned int )m->outer_l3_len);if (info.tunnel_tso_segsz !=0 && (m->ol_flags & (RTE_MBUF_F_TX_TCP_SEG |RTE_MBUF_F_TX_UDP_SEG ))) -printf ("tx: m->tso_segsz=%d\n" , - m->tso_segsz); +printf ("tx: m->tso_segsz=%u\n" , + (unsigned int )m->tso_segsz); }else if (info.tso_segsz !=0 && (m->ol_flags & (RTE_MBUF_F_TX_TCP_SEG |RTE_MBUF_F_TX_UDP_SEG ))) -printf ("tx: m->tso_segsz=%d\n" , m->tso_segsz); +printf ("tx: m->tso_segsz=%u\n" , (unsigned int )m->tso_segsz);rte_get_tx_ol_flag_list (m->ol_flags, buf,sizeof (buf));printf ("tx: flags=%s" , buf);printf ("\n" );
Signature · 1 line
2.48.1.vfs.0.0
PATCH v5 1/10 eal: add workaround for __builtin_constant_p
In reply to Andre MuezerieThere's no MSVC equivalent for compiler extension __builtin_constant_p, but the same result can be obtained through a clever expression using _Generic.
This patch redefines the macro __rte_constant when msvc is used and uses it as a replacement for __builtin_constant_p.
--- lib/eal/include/generic/rte_pause.h | 2 +- lib/eal/include/rte_common.h | 34 ++++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 2 deletions(-)
lib/eal/include/generic/rte_pause.h +1 -1
@@ -130,7 +130,7 @@ rte_wait_until_equal_64(volatile uint64_t *addr, uint64_t expected,* rte_memory_order_acquire and rte_memory_order_relaxed. */ #define RTE_WAIT_UNTIL_MASKED (addr, mask, cond, expected, memorder) do { \ - RTE_BUILD_BUG_ON(!__builtin_constant_p(memorder)); \ + RTE_BUILD_BUG_ON(!__rte_constant(memorder)); \ RTE_BUILD_BUG_ON((memorder) != rte_memory_order_acquire && \ (memorder) != rte_memory_order_relaxed); \ typeof(*(addr)) expected_value = (expected); \
lib/eal/include/rte_common.h +33 -1
@@ -44,8 +44,40 @@ extern "C" {#endif #endif +/* +* Macro __rte_constant checks if an expression's value can be determined at +* compile time. It takes a single argument, the expression to test, and +* returns 1 if the expression is a compile-time constant, and 0 otherwise. +* For most compilers it uses built-in function __builtin_constant_p, but for +* MSVC it uses a different method because MSVC does not have an equivalent +* to __builtin_constant_p. +* +* The trick used with MSVC relies on the way null pointer constants interact +* with the type of a ?: expression: +* An integer constant expression with the value 0, or such an expression cast +* to type void *, is called a null pointer constant. +* If both the second and third operands (of the ?: expression) are pointers or +* one is a null pointer constant and the other is a pointer, the result type +* is a pointer to a type qualified with all the type qualifiers of the types +* referenced by both operands. Furthermore, if both operands are pointers to +* compatible types or to differently qualified versions of compatible types, +* the result type is a pointer to an appropriately qualified version of the +* composite type; if one operand is a null pointer constant, the result has +* the type of the other operand; otherwise, one operand is a pointer to void +* or a qualified version of void, in which case the result type is a pointer +* to an appropriately qualified version of void. +* +* The _Generic keyword then checks the type of the expression +* (void *) ((e) * 0ll). It matches this type against the types listed in the +* _Generic construct: +* - If the type is int *, the result is 1. +* - If the type is void *, the result is 0. +* +* This explanation with some more details can be found at: +* https://stackoverflow.com/questions/49480442/detecting-integer-constant-expressions-in-macros +*/ #ifdef RTE_TOOLCHAIN_MSVC -#define __rte_constant (e) 0 +#define __rte_constant (e) _Generic((1 ? (void *) ((e) * 0ll) : (int *) 0), int * : 1, void * : 0)#else #define __rte_constant (e) __extension__(__builtin_constant_p(e))#endif
Signature · 1 line
2.48.1.vfs.0.0
PATCH v5 4/10 test-pmd: do explicit 64-bit shift to avoid implicit conversion
In reply to Andre MuezerieCompiling with MSVC results in warnings like the one below:
app/test-pmd/util.c(201): warning C4334: '<<': result of 32-bit shift
implicitly converted to 64 bits (was 64-bit shift intended?)
--- app/test-pmd/cmdline.c | 4 ++-- app/test-pmd/testpmd.c | 2 +- app/test-pmd/util.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
app/test-pmd/cmdline.c +2 -2
@@ -12632,11 +12632,11 @@ cmd_config_dynf_specific_parsed(void *parsed_result, } old_port_flags = ports[res->port_id].mbuf_dynf;if (!strcmp (res->value,"set" )) { - ports[res->port_id].mbuf_dynf |=1UL << flag; + ports[res->port_id].mbuf_dynf |=RTE_BIT64 (flag);if (old_port_flags ==0 )add_tx_dynf_callback (res->port_id); }else { - ports[res->port_id].mbuf_dynf &= ~(1UL << flag); + ports[res->port_id].mbuf_dynf &= ~RTE_BIT64 (flag);if (ports[res->port_id].mbuf_dynf ==0 )remove_tx_dynf_callback (res->port_id); }
app/test-pmd/testpmd.c +1 -1
@@ -4152,7 +4152,7 @@ get_eth_dcb_conf(struct rte_eth_conf *eth_conf, enum dcb_mode_enable dcb_mode,for (i =0 ; i < vmdq_rx_conf->nb_pool_maps; i++) { vmdq_rx_conf->pool_map[i].vlan_id = vlan_tags[i]; vmdq_rx_conf->pool_map[i].pools = -1 << (i % vmdq_rx_conf->nb_queue_pools); +RTE_BIT64 (i % vmdq_rx_conf->nb_queue_pools); }for (i =0 ; i <RTE_ETH_DCB_NUM_USER_PRIORITIES ; i++) { vmdq_rx_conf->dcb_tc[i] = i % num_tcs;
app/test-pmd/util.c +1 -1
@@ -201,7 +201,7 @@ dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[],MKDUMPSTR (print_buf, buf_size, cur_len," - dynf %s: %d" , dynf_names[dynf_index], - !!(ol_flags & (1UL << dynf_index))); + !!(ol_flags &RTE_BIT64 (dynf_index))); }if (mb->packet_type) {rte_get_ptype_name (mb->packet_type, buf,sizeof (buf));
Signature · 1 line
2.48.1.vfs.0.0
PATCH v5 6/10 test-pmd: avoid non-constant initializer
In reply to Andre MuezerieCompiling with MSVC results in errors like the one below:
app/test-pmd/cmdline_flow.c(8819): error C2099: initializer
is not a constant
--- app/test-pmd/cmdline_flow.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
app/test-pmd/cmdline_flow.c +3 -7
@@ -8812,8 +8812,6 @@ parse_vc_spec(struct context *ctx, const struct token *token,return -1 ;/* Parse parameter types. */ switch (ctx->curr) { -static const enum index prefix[] =NEXT_ENTRY (COMMON_PREFIX ); -case ITEM_PARAM_IS : index =0 ; objmask =1 ;
@@ -8828,7 +8826,7 @@ parse_vc_spec(struct context *ctx, const struct token *token,/* Modify next token to expect a prefix. */ if (ctx->next_num <2 )return -1 ; - ctx->next[ctx->next_num -2 ] = prefix; + ctx->next[ctx->next_num -2 ] =NEXT_ENTRY (COMMON_PREFIX );/* Fall through. */ case ITEM_PARAM_MASK : index =2 ;
@@ -9270,7 +9268,6 @@ parse_vc_action_rss_type(struct context *ctx, const struct token *token, const char *str, unsigned int len, void *buf, unsigned int size) { - static const enum index next[] = NEXT_ENTRY(ACTION_RSS_TYPE); struct action_rss_data *action_rss_data;unsigned int i;
@@ -9296,7 +9293,7 @@ parse_vc_action_rss_type(struct context *ctx, const struct token *token,/* Repeat token. */ if (ctx->next_num ==RTE_DIM (ctx->next))return -1 ; - ctx->next[ctx->next_num++] = next; + ctx->next[ctx->next_num++] =NEXT_ENTRY (ACTION_RSS_TYPE );if (!ctx->object)return len; action_rss_data = ctx->object;
@@ -9314,7 +9311,6 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token, const char *str, unsigned int len, void *buf, unsigned int size) { - static const enum index next[] = NEXT_ENTRY(ACTION_RSS_QUEUE); struct action_rss_data *action_rss_data;const struct arg *arg;int ret;
@@ -9347,7 +9343,7 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token,/* Repeat token. */ if (ctx->next_num ==RTE_DIM (ctx->next))return -1 ; - ctx->next[ctx->next_num++] = next; + ctx->next[ctx->next_num++] =NEXT_ENTRY (ACTION_RSS_QUEUE ); end:if (!ctx->object)return len;
Signature · 1 line
2.48.1.vfs.0.0
PATCH v5 5/10 test-pmd: avoid undefined behavior
In reply to Andre MuezerieCompiling with MSVC results in warnings like below:
app/test-pmd/cmdline.c(9023): warning C5101: use of preprocessor
directive in function-like macro argument list is undefined behavior
--- app/test-pmd/cmdline.c | 12 ++++++++---- app/test-pmd/testpmd.h | 2 ++ 2 files changed, 10 insertions(+), 4 deletions(-)
app/test-pmd/cmdline.c +8 -4
@@ -8980,6 +8980,14 @@ dump_socket_mem(FILE *f) last_total = total; } +#ifdef RTE_EXEC_ENV_WINDOWS +int +rte_trace_save (void ) +{ +return TEST_SKIPPED ; +} +#endif +static void cmd_dump_parsed (void *parsed_result, __rte_unused struct cmdline *cl, __rte_unused void *data)
@@ -9002,10 +9010,8 @@ static void cmd_dump_parsed(void *parsed_result,rte_devargs_dump (stdout); else if (!strcmp(res->dump, "dump_lcores"))rte_lcore_dump (stdout); -#ifndef RTE_EXEC_ENV_WINDOWS else if (!strcmp(res->dump, "dump_trace"))rte_trace_save (); -#endif else if (!strcmp(res->dump, "dump_log_types"))rte_log_dump (stdout); }
@@ -9020,9 +9026,7 @@ static cmdline_parse_token_string_t cmd_dump_dump ="dump_mempool#" "dump_devargs#" "dump_lcores#" -#ifndef RTE_EXEC_ENV_WINDOWS"dump_trace#" -#endif "dump_log_types");static cmdline_parse_inst_t cmd_dump = {
app/test-pmd/testpmd.h +2 -0
@@ -84,6 +84,8 @@ extern volatile uint8_t f_quit;/* Maximum number of pools supported per Rx queue */ #define MAX_MEMPOOL 8 +#define TEST_SKIPPED 77 +typedef uint32_t lcoreid_t ;typedef uint16_t portid_t ;typedef uint16_t queueid_t ;
Signature · 1 line
2.48.1.vfs.0.0
PATCH v5 7/10 test-pmd: don't return value from void function
In reply to Andre MuezerieCompiling with MSVC results in the warning below:
app/test-pmd/cmdline_flow.c(13964): warning C4098: 'cmd_set_raw_parsed':
'void' function returning a value
--- app/test-pmd/cmdline_flow.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
app/test-pmd/cmdline_flow.c +8 -4
@@ -13952,11 +13952,15 @@ cmd_set_raw_parsed(const struct buffer *in)int gtp_psc =-1 ;/* GTP PSC option index. */ const void *src_spec; -if (in->command ==SET_SAMPLE_ACTIONS ) -return cmd_set_raw_parsed_sample (in); +if (in->command ==SET_SAMPLE_ACTIONS ) { +cmd_set_raw_parsed_sample (in); +return ; + }else if (in->command ==SET_IPV6_EXT_PUSH || - in->command ==SET_IPV6_EXT_REMOVE ) -return cmd_set_ipv6_ext_parsed (in); + in->command ==SET_IPV6_EXT_REMOVE ) { +cmd_set_ipv6_ext_parsed (in); +return ; + }RTE_ASSERT (in->command ==SET_RAW_ENCAP || in->command ==SET_RAW_DECAP );if (in->command ==SET_RAW_ENCAP ) {
Signature · 1 line
2.48.1.vfs.0.0
PATCH v5 8/10 test-pmd: declare lcore_count atomic
In reply to Andre MuezerieCompiling with MSVC results in the error below:
app/test/test_ring_perf.c(197): error C7712: address argument to atomic
operation must be a pointer to an atomic integer, 'volatile unsigned int *' is not valid
The fix is to mark lcore_count as atomic.
--- app/test/test_ring_perf.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
app/test/test_ring_perf.c +1 -5
@@ -34,7 +34,7 @@ struct lcore_pair {unsigned c1, c2; }; -static volatile unsigned lcore_count =0 ; +static volatile RTE_ATOMIC (unsigned int ) lcore_count; static void test_ring_print_test_string(unsigned int api_type, int esize,
@@ -193,11 +193,7 @@ enqueue_dequeue_bulk_helper(const unsigned int flag, struct thread_params *p)unsigned int n_remaining;const unsigned int bulk_n = bulk_sizes[p->ring_params->bulk_sizes_i]; -#ifdef RTE_USE_C11_MEM_MODEL if (rte_atomic_fetch_add_explicit (&lcore_count,1 , rte_memory_order_relaxed) +1 !=2 ) -#else - if (__sync_add_and_fetch(&lcore_count, 1) != 2) -#endif while (lcore_count !=2 )rte_pause ();
Signature · 1 line
2.48.1.vfs.0.0
PATCH v5 10/10 app: enable app directory to be compiled with MSVC
In reply to Andre MuezerieEnabled "app" directory to be compiled with MSVC along with all its contents.
Removed flag Wno-deprecated-declarations which is not needed anymore.
--- app/meson.build | 4 ---- app/test-pmd/meson.build | 1 - 2 files changed, 5 deletions(-)
app/meson.build +0 -4
@@ -1,10 +1,6 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017-2019 Intel Corporation -if is_ms_compiler - subdir_done() -endif - disable_apps = ',' + get_option('disable_apps') disable_apps = run_command(list_dir_globs, disable_apps, check: true).stdout().split()
app/test-pmd/meson.build +0 -1
@@ -3,7 +3,6 @@ # override default name to drop the hyphen name = 'testpmd' -cflags += '-Wno-deprecated-declarations' sources = files( '5tswap.c', 'cmdline.c',
Signature · 1 line
2.48.1.vfs.0.0
PATCH v5 9/10 test: add workaround for __builtin_constant_p in test_memcpy_perf
In reply to Andre MuezerieThere's no MSVC equivalent for compiler extension __builtin_constant_p, so a workaround is needed.
--- app/test/test_memcpy_perf.c | 54 ++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 27 deletions(-)
app/test/test_memcpy_perf.c +27 -27
@@ -196,37 +196,37 @@ do { \ }while (0 ) /* Run aligned memcpy tests for each cached/uncached permutation */ -#define ALL_PERF_TESTS_FOR_SIZE (n) \ -do { \ - if (__builtin_constant_p(n)) \ - printf("\nC%6u", (unsigned)n); \ - else \ - printf("\n%7u", (unsigned)n); \ - SINGLE_PERF_TEST(small_buf_write, 1, 0, small_buf_read, 1, 0, n); \ - SINGLE_PERF_TEST(large_buf_write, 0, 0, small_buf_read, 1, 0, n); \ - SINGLE_PERF_TEST(small_buf_write, 1, 0, large_buf_read, 0, 0, n); \ - SINGLE_PERF_TEST(large_buf_write, 0, 0, large_buf_read, 0, 0, n); \ +#define ALL_PERF_TESTS_FOR_SIZE (n) \ +do { \ + if (__rte_constant(n)) \ + printf("\nC%6u", (unsigned int)n); \ + else \ + printf("\n%7u", (unsigned int)n); \ + SINGLE_PERF_TEST(small_buf_write, 1, 0, small_buf_read, 1, 0, n); \ + SINGLE_PERF_TEST(large_buf_write, 0, 0, small_buf_read, 1, 0, n); \ + SINGLE_PERF_TEST(small_buf_write, 1, 0, large_buf_read, 0, 0, n); \ + SINGLE_PERF_TEST(large_buf_write, 0, 0, large_buf_read, 0, 0, n); \ } while (0)/* Run unaligned memcpy tests for each cached/uncached permutation */ -#define ALL_PERF_TESTS_FOR_SIZE_UNALIGNED (n) \ -do { \ - if (__builtin_constant_p(n)) \ - printf("\nC%6u", (unsigned)n); \ - else \ - printf("\n%7u", (unsigned)n); \ - SINGLE_PERF_TEST(small_buf_write, 1, 1, small_buf_read, 1, 5, n); \ - SINGLE_PERF_TEST(large_buf_write, 0, 1, small_buf_read, 1, 5, n); \ - SINGLE_PERF_TEST(small_buf_write, 1, 1, large_buf_read, 0, 5, n); \ - SINGLE_PERF_TEST(large_buf_write, 0, 1, large_buf_read, 0, 5, n); \ +#define ALL_PERF_TESTS_FOR_SIZE_UNALIGNED (n) \ +do { \ + if (__rte_constant(n)) \ + printf("\nC%6u", (unsigned int)n); \ + else \ + printf("\n%7u", (unsigned int)n); \ + SINGLE_PERF_TEST(small_buf_write, 1, 1, small_buf_read, 1, 5, n); \ + SINGLE_PERF_TEST(large_buf_write, 0, 1, small_buf_read, 1, 5, n); \ + SINGLE_PERF_TEST(small_buf_write, 1, 1, large_buf_read, 0, 5, n); \ + SINGLE_PERF_TEST(large_buf_write, 0, 1, large_buf_read, 0, 5, n); \ } while (0)/* Run memcpy tests for constant length */ -#define ALL_PERF_TEST_FOR_CONSTANT \ -do { \ - TEST_CONSTANT(6U); TEST_CONSTANT(64U); TEST_CONSTANT(128U); \ - TEST_CONSTANT(192U); TEST_CONSTANT(256U); TEST_CONSTANT(512U); \ - TEST_CONSTANT(768U); TEST_CONSTANT(1024U); TEST_CONSTANT(1536U); \ +#define ALL_PERF_TEST_FOR_CONSTANT \ +do { \ + TEST_CONSTANT(6U); TEST_CONSTANT(64U); TEST_CONSTANT(128U); \ + TEST_CONSTANT(192U); TEST_CONSTANT(256U); TEST_CONSTANT(512U); \ + TEST_CONSTANT(768U); TEST_CONSTANT(1024U); TEST_CONSTANT(1536U); \ } while (0)/* Run all memcpy tests for aligned constant cases */
@@ -253,7 +253,7 @@ perf_test_variable_aligned(void) {unsigned i;for (i =0 ; i <RTE_DIM (buf_sizes); i++) { -ALL_PERF_TESTS_FOR_SIZE ((size_t )buf_sizes[i]); +ALL_PERF_TESTS_FOR_SIZE (buf_sizes[i]); } }
@@ -263,7 +263,7 @@ perf_test_variable_unaligned(void) {unsigned i;for (i =0 ; i <RTE_DIM (buf_sizes); i++) { -ALL_PERF_TESTS_FOR_SIZE_UNALIGNED ((size_t )buf_sizes[i]); +ALL_PERF_TESTS_FOR_SIZE_UNALIGNED (buf_sizes[i]); } }
Signature · 1 line
2.48.1.vfs.0.0
RE: [PATCH v5 08/10] test-pmd: declare lcore_count atomic
In reply to Andre MuezerieQuoted 22 lines
From: Andre Muezerie [mailto:[email protected]]
Sent: Friday, 21 February 2025 20.53Compiling with MSVC results in the error below:
app/test/test_ring_perf.c(197): error C7712: address argument to atomic
operation must be a pointer to an atomic integer, 'volatile unsigned int *' is not validThe fix is to mark
lcore_countas atomic.Signed-off-by Andre Muezerie <[email protected]>Signed-off-by Chengwen Feng <[email protected]>--- app/test/test_ring_perf.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)app/test/test_ring_perf.c +0
-0
app/test/test_ring_perf.c struct lcore_pair { · line 37
Quoted 5 lines
app/test/test_ring_perf.c +1
-1@@ -34,7 +34,7 @@ struct lcore_pair {unsigned c1, c2; }; -static volatile unsigned lcore_count =0 ; +static volatile RTE_ATOMIC (unsigned int ) lcore_count;
Using rte_atomic_xxx to access the RTE_ATOMIC qualified lcore_count seems more clean than making it volatile and sometimes access it non-atomically. It is only accessed two more times, so not a big change.
Anyway, this could just be my personal preference. No change required if you disagree.
Re: [PATCH v5 09/10] test: add workaround for __builtin_constant_p in test_memcpy_perf
In reply to Andre MuezerieQuoted 4 lines · Andre Muezerie
There's no MSVC equivalent for compiler extension
__builtin_constant_p, so a workaround is needed.Signed-off-by Andre Muezerie <[email protected]>
Re: [PATCH v5 10/10] app: enable app directory to be compiled with MSVC
In reply to Andre MuezerieQuoted 7 lines · Andre Muezerie
Enabled "app" directory to be compiled with MSVC along with all its contents.
Removed flag Wno-deprecated-declarations which is not needed anymore.
Signed-off-by Andre Muezerie <[email protected]>Acked-by Bruce Richardson <[email protected]>
RE: [PATCH v5 08/10] test-pmd: declare lcore_count atomic
In reply to Andre MuezerieQuoted 3 lines
Subject: [PATCH v5 08/10] test-pmd: declare
lcore_countatomic
As a nit, the changes are not in testpmd, bit in the UT.
Quoted 42 lines
Compiling with MSVC results in the error below:
app/test/test_ring_perf.c(197): error C7712: address argument to atomic
operation must be a pointer to an atomic integer, 'volatile unsigned int *' is not validThe fix is to mark
lcore_countas atomic.Signed-off-by Andre Muezerie <[email protected]>Signed-off-by Chengwen Feng <[email protected]>--- app/test/test_ring_perf.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)app/test/test_ring_perf.c +1
-6@@ -34,7 +34,7 @@ struct lcore_pair {unsigned c1, c2; }; -static volatile unsigned lcore_count =0 ; +static volatile RTE_ATOMIC (unsigned int ) lcore_count; static void test_ring_print_test_string(unsigned int api_type, int esize,@@ -193,11 +193,7 @@ enqueue_dequeue_bulk_helper(const unsigned int flag, struct thread_params *p)unsigned int n_remaining;const unsigned int bulk_n = bulk_sizes[p->ring_params->bulk_sizes_i]; -#ifdef RTE_USE_C11_MEM_MODEL if (rte_atomic_fetch_add_explicit (&lcore_count,1 , rte_memory_order_relaxed) +1 !=2 ) -#else -if (__sync_add_and_fetch (&lcore_count,1 ) !=2 ) -#endifwhile (lcore_count !=2 )rte_pause (); --2.48.1.vfs.0.0
Re: [PATCH v5 08/10] test-pmd: declare lcore_count atomic
In reply to Morten BrørupQuoted 25 lines · Morten Brørup
Quoted 25 lines
From: Andre Muezerie [mailto:[email protected]]
Sent: Friday, 21 February 2025 20.53Compiling with MSVC results in the error below:
app/test/test_ring_perf.c(197): error C7712: address argument to atomic
operation must be a pointer to an atomic integer, 'volatile unsigned int *' is not validThe fix is to mark
lcore_countas atomic.Signed-off-by Andre Muezerie <[email protected]>Signed-off-by Chengwen Feng <[email protected]>--- app/test/test_ring_perf.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)app/test/test_ring_perf.c +0
-0@@ -34,7 +34,7 @@ struct lcore_pair {unsigned c1, c2; };
Quoted 7 lines
app/test/test_ring_perf.c struct lcore_pair { · line 37
Quoted 2 lines
app/test/test_ring_perf.c +1
-1-static volatile unsigned lcore_count =0 ; +static volatile RTE_ATOMIC (unsigned int ) lcore_count;Using
rte_atomic_xxxto access theRTE_ATOMICqualifiedlcore_countseems more clean than making it volatile and sometimes access it non-atomically. It is only accessed two more times, so not a big change.Anyway, this could just be my personal preference. No change required if you disagree.
Makes sense. I'll send an updated series.
PATCH v6 3/10 test-pmd: fix printf format string mismatch
In reply to Andre MuezerieCompiling with MSVC results in warnings like the one below:
app/test-pmd/csumonly.c(1085): warning C4477: 'printf' : format string
'%d' requires an argument of type 'int',
but variadic argument 1 has type 'uint64_t'
--- app/test-pmd/csumonly.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-)
app/test-pmd/csumonly.c +12 -11
@@ -1070,7 +1070,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) info.l2_len,rte_be_to_cpu_16 (info.ethertype), info.l3_len, info.l4_proto, info.l4_len, buf);if (rx_ol_flags &RTE_MBUF_F_RX_LRO ) -printf ("rx: m->lro_segsz=%u\n" , m->tso_segsz); +printf ("rx: m->lro_segsz=%u\n" , (unsigned int )m->tso_segsz);if (info.is_tunnel ==1 ) printf("rx: outer_l2_len=%d outer_ethertype=%x " "outer_l3_len=%d\n", info.outer_l2_len,
@@ -1082,28 +1082,29 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) RTE_ETH_TX_OFFLOAD_TCP_CKSUM | RTE_ETH_TX_OFFLOAD_SCTP_CKSUM)) || info.tso_segsz != 0) -printf ("tx: m->l2_len=%d m->l3_len=%d " -"m->l4_len=%d\n" , - m->l2_len, m->l3_len, m->l4_len); +printf ("tx: m->l2_len=%u m->l3_len=%u " +"m->l4_len=%u\n" , + (unsigned int )m->l2_len, (unsigned int )m->l3_len, + (unsigned int )m->l4_len);if (info.is_tunnel ==1 ) {if ((tx_offloads &RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM ) || (tx_offloads &RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM ) || (tx_ol_flags &RTE_MBUF_F_TX_OUTER_IPV6 )) -printf ("tx: m->outer_l2_len=%d " -"m->outer_l3_len=%d\n" , - m->outer_l2_len, - m->outer_l3_len); +printf ("tx: m->outer_l2_len=%u " +"m->outer_l3_len=%u\n" , + (unsigned int )m->outer_l2_len, + (unsigned int )m->outer_l3_len);if (info.tunnel_tso_segsz !=0 && (m->ol_flags & (RTE_MBUF_F_TX_TCP_SEG |RTE_MBUF_F_TX_UDP_SEG ))) -printf ("tx: m->tso_segsz=%d\n" , - m->tso_segsz); +printf ("tx: m->tso_segsz=%u\n" , + (unsigned int )m->tso_segsz); }else if (info.tso_segsz !=0 && (m->ol_flags & (RTE_MBUF_F_TX_TCP_SEG |RTE_MBUF_F_TX_UDP_SEG ))) -printf ("tx: m->tso_segsz=%d\n" , m->tso_segsz); +printf ("tx: m->tso_segsz=%u\n" , (unsigned int )m->tso_segsz);rte_get_tx_ol_flag_list (m->ol_flags, buf,sizeof (buf));printf ("tx: flags=%s" , buf);printf ("\n" );
Signature · 1 line
2.48.1.vfs.0.0
PATCH v6 1/10 eal: add workaround for __builtin_constant_p
In reply to Andre MuezerieThere's no MSVC equivalent for compiler extension __builtin_constant_p, but the same result can be obtained through a clever expression using _Generic.
This patch redefines the macro __rte_constant when msvc is used and uses it as a replacement for __builtin_constant_p.
--- lib/eal/include/generic/rte_pause.h | 2 +- lib/eal/include/rte_common.h | 34 ++++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 2 deletions(-)
lib/eal/include/generic/rte_pause.h +1 -1
@@ -130,7 +130,7 @@ rte_wait_until_equal_64(volatile uint64_t *addr, uint64_t expected,* rte_memory_order_acquire and rte_memory_order_relaxed. */ #define RTE_WAIT_UNTIL_MASKED (addr, mask, cond, expected, memorder) do { \ - RTE_BUILD_BUG_ON(!__builtin_constant_p(memorder)); \ + RTE_BUILD_BUG_ON(!__rte_constant(memorder)); \ RTE_BUILD_BUG_ON((memorder) != rte_memory_order_acquire && \ (memorder) != rte_memory_order_relaxed); \ typeof(*(addr)) expected_value = (expected); \
lib/eal/include/rte_common.h +33 -1
@@ -44,8 +44,40 @@ extern "C" {#endif #endif +/* +* Macro __rte_constant checks if an expression's value can be determined at +* compile time. It takes a single argument, the expression to test, and +* returns 1 if the expression is a compile-time constant, and 0 otherwise. +* For most compilers it uses built-in function __builtin_constant_p, but for +* MSVC it uses a different method because MSVC does not have an equivalent +* to __builtin_constant_p. +* +* The trick used with MSVC relies on the way null pointer constants interact +* with the type of a ?: expression: +* An integer constant expression with the value 0, or such an expression cast +* to type void *, is called a null pointer constant. +* If both the second and third operands (of the ?: expression) are pointers or +* one is a null pointer constant and the other is a pointer, the result type +* is a pointer to a type qualified with all the type qualifiers of the types +* referenced by both operands. Furthermore, if both operands are pointers to +* compatible types or to differently qualified versions of compatible types, +* the result type is a pointer to an appropriately qualified version of the +* composite type; if one operand is a null pointer constant, the result has +* the type of the other operand; otherwise, one operand is a pointer to void +* or a qualified version of void, in which case the result type is a pointer +* to an appropriately qualified version of void. +* +* The _Generic keyword then checks the type of the expression +* (void *) ((e) * 0ll). It matches this type against the types listed in the +* _Generic construct: +* - If the type is int *, the result is 1. +* - If the type is void *, the result is 0. +* +* This explanation with some more details can be found at: +* https://stackoverflow.com/questions/49480442/detecting-integer-constant-expressions-in-macros +*/ #ifdef RTE_TOOLCHAIN_MSVC -#define __rte_constant (e) 0 +#define __rte_constant (e) _Generic((1 ? (void *) ((e) * 0ll) : (int *) 0), int * : 1, void * : 0)#else #define __rte_constant (e) __extension__(__builtin_constant_p(e))#endif
Signature · 1 line
2.48.1.vfs.0.0
PATCH v6 2/10 test_alarm: avoid warning about different qualifiers
In reply to Andre MuezerieCompiling with MSVC results in the warning below:
app/test/test_alarm.c(54): warning C4090: 'function':
different '_Atomic' qualifiers
The fix is to use a macro to explicitly drop the qualifier.
--- app/test/test_alarm.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
app/test/test_alarm.c +6 -6
@@ -51,12 +51,12 @@ test_alarm(void) "Expected rte_eal_alarm_cancel to fail with null callback parameter");/* check if can set a alarm for one second */ -TEST_ASSERT_SUCCESS (rte_eal_alarm_set (US_PER_SEC , test_alarm_callback, &triggered), -"Setting one second alarm failed" ); +TEST_ASSERT_SUCCESS (rte_eal_alarm_set (US_PER_SEC , test_alarm_callback, +RTE_PTR_UNQUAL (&triggered)),"Setting one second alarm failed" );/* set a longer alarm that will be canceled. */ -TEST_ASSERT_SUCCESS (rte_eal_alarm_set (10 *US_PER_SEC , test_alarm_callback, &later), -"Setting ten second alarm failed" ); +TEST_ASSERT_SUCCESS (rte_eal_alarm_set (10 *US_PER_SEC , test_alarm_callback, +RTE_PTR_UNQUAL (&later)),"Setting ten second alarm failed" );/* wait for alarm to happen */ while (rte_atomic_load_explicit (&triggered, rte_memory_order_acquire) == false)
@@ -65,11 +65,11 @@ test_alarm(void)TEST_ASSERT (!rte_atomic_load_explicit (&later, rte_memory_order_acquire),"Only one alarm should have fired." ); - ret =rte_eal_alarm_cancel (test_alarm_callback, &triggered); + ret =rte_eal_alarm_cancel (test_alarm_callback,RTE_PTR_UNQUAL (&triggered));TEST_ASSERT (ret ==0 && rte_errno ==ENOENT ,"Canceling alarm after run ret %d: %s" , ret,rte_strerror (rte_errno)); - ret =rte_eal_alarm_cancel (test_alarm_callback, &later); + ret =rte_eal_alarm_cancel (test_alarm_callback,RTE_PTR_UNQUAL (&later));TEST_ASSERT (ret ==1 ,"Canceling ten second alarm failed %d: %s" , ret,rte_strerror (rte_errno));
Signature · 1 line
2.48.1.vfs.0.0
v6 cover enable "app" to be compiled with MSVC
In reply to Andre Muezeriev6:
- remove "volatile" and use rte_atomic_xxx to access the RTE_ATOMIC qualified lcore_count, which is cleaner than using "volatile".
v5:
- add "volatile" to declaration of lcore_count in test_ring_perf.c.
v4:
- add explanation about the expression used in __rte_constant during v3.
v3:
- use clever expression with _Generic for __rte_constant and use it where __builtin_constant_p was being used.
- use %u in csumonly.c and just cast variables to unsigned int.
v2:
- use lcore_count as atomic always, not only when RTE_USE_C11_MEM_MODEL is set.
- use PRIu64 in csumonly.c instead of casting variables to int.
Andre Muezerie (10):
eal: add workaround for __builtin_constant_p
test_alarm: avoid warning about different qualifiers
test-pmd: fix printf format string mismatch
test-pmd: do explicit 64-bit shift to avoid implicit conversion
test-pmd: avoid undefined behavior
test-pmd: avoid non-constant initializer
test-pmd: don't return value from void function test/test-pmd: declare lcore_count atomic
test: add workaround for __builtin_constant_p in test_memcpy_perf
app: enable app directory to be compiled with MSVC
app/meson.build | 4 --- app/test-pmd/cmdline.c | 16 +++++---- app/test-pmd/cmdline_flow.c | 22 ++++++------ app/test-pmd/csumonly.c | 23 ++++++------ app/test-pmd/meson.build | 1 - app/test-pmd/testpmd.c | 2 +- app/test-pmd/testpmd.h | 2 ++ app/test-pmd/util.c | 2 +- app/test/test_alarm.c | 12 +++---- app/test/test_memcpy_perf.c | 54 ++++++++++++++--------------- app/test/test_ring_perf.c | 13 +++---- lib/eal/include/generic/rte_pause.h | 2 +- lib/eal/include/rte_common.h | 34 +++++++++++++++++- 13 files changed, 109 insertions(+), 78 deletions(-)
--
2.48.1.vfs.0.0
PATCH v6 4/10 test-pmd: do explicit 64-bit shift to avoid implicit conversion
Compiling with MSVC results in warnings like the one below:
app/test-pmd/util.c(201): warning C4334: '<<': result of 32-bit shift
implicitly converted to 64 bits (was 64-bit shift intended?)
--- app/test-pmd/cmdline.c | 4 ++-- app/test-pmd/testpmd.c | 2 +- app/test-pmd/util.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
app/test-pmd/cmdline.c +2 -2
@@ -12632,11 +12632,11 @@ cmd_config_dynf_specific_parsed(void *parsed_result, } old_port_flags = ports[res->port_id].mbuf_dynf;if (!strcmp (res->value,"set" )) { - ports[res->port_id].mbuf_dynf |=1UL << flag; + ports[res->port_id].mbuf_dynf |=RTE_BIT64 (flag);if (old_port_flags ==0 )add_tx_dynf_callback (res->port_id); }else { - ports[res->port_id].mbuf_dynf &= ~(1UL << flag); + ports[res->port_id].mbuf_dynf &= ~RTE_BIT64 (flag);if (ports[res->port_id].mbuf_dynf ==0 )remove_tx_dynf_callback (res->port_id); }
app/test-pmd/testpmd.c +1 -1
@@ -4152,7 +4152,7 @@ get_eth_dcb_conf(struct rte_eth_conf *eth_conf, enum dcb_mode_enable dcb_mode,for (i =0 ; i < vmdq_rx_conf->nb_pool_maps; i++) { vmdq_rx_conf->pool_map[i].vlan_id = vlan_tags[i]; vmdq_rx_conf->pool_map[i].pools = -1 << (i % vmdq_rx_conf->nb_queue_pools); +RTE_BIT64 (i % vmdq_rx_conf->nb_queue_pools); }for (i =0 ; i <RTE_ETH_DCB_NUM_USER_PRIORITIES ; i++) { vmdq_rx_conf->dcb_tc[i] = i % num_tcs;
app/test-pmd/util.c +1 -1
@@ -201,7 +201,7 @@ dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[],MKDUMPSTR (print_buf, buf_size, cur_len," - dynf %s: %d" , dynf_names[dynf_index], - !!(ol_flags & (1UL << dynf_index))); + !!(ol_flags &RTE_BIT64 (dynf_index))); }if (mb->packet_type) {rte_get_ptype_name (mb->packet_type, buf,sizeof (buf));
Signature · 1 line
2.48.1.vfs.0.0
PATCH v6 6/10 test-pmd: avoid non-constant initializer
In reply to Andre MuezerieCompiling with MSVC results in errors like the one below:
app/test-pmd/cmdline_flow.c(8819): error C2099: initializer
is not a constant
--- app/test-pmd/cmdline_flow.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
app/test-pmd/cmdline_flow.c +3 -7
@@ -8812,8 +8812,6 @@ parse_vc_spec(struct context *ctx, const struct token *token,return -1 ;/* Parse parameter types. */ switch (ctx->curr) { -static const enum index prefix[] =NEXT_ENTRY (COMMON_PREFIX ); -case ITEM_PARAM_IS : index =0 ; objmask =1 ;
@@ -8828,7 +8826,7 @@ parse_vc_spec(struct context *ctx, const struct token *token,/* Modify next token to expect a prefix. */ if (ctx->next_num <2 )return -1 ; - ctx->next[ctx->next_num -2 ] = prefix; + ctx->next[ctx->next_num -2 ] =NEXT_ENTRY (COMMON_PREFIX );/* Fall through. */ case ITEM_PARAM_MASK : index =2 ;
@@ -9270,7 +9268,6 @@ parse_vc_action_rss_type(struct context *ctx, const struct token *token, const char *str, unsigned int len, void *buf, unsigned int size) { - static const enum index next[] = NEXT_ENTRY(ACTION_RSS_TYPE); struct action_rss_data *action_rss_data;unsigned int i;
@@ -9296,7 +9293,7 @@ parse_vc_action_rss_type(struct context *ctx, const struct token *token,/* Repeat token. */ if (ctx->next_num ==RTE_DIM (ctx->next))return -1 ; - ctx->next[ctx->next_num++] = next; + ctx->next[ctx->next_num++] =NEXT_ENTRY (ACTION_RSS_TYPE );if (!ctx->object)return len; action_rss_data = ctx->object;
@@ -9314,7 +9311,6 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token, const char *str, unsigned int len, void *buf, unsigned int size) { - static const enum index next[] = NEXT_ENTRY(ACTION_RSS_QUEUE); struct action_rss_data *action_rss_data;const struct arg *arg;int ret;
@@ -9347,7 +9343,7 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token,/* Repeat token. */ if (ctx->next_num ==RTE_DIM (ctx->next))return -1 ; - ctx->next[ctx->next_num++] = next; + ctx->next[ctx->next_num++] =NEXT_ENTRY (ACTION_RSS_QUEUE ); end:if (!ctx->object)return len;
Signature · 1 line
2.48.1.vfs.0.0
PATCH v6 5/10 test-pmd: avoid undefined behavior
In reply to Andre MuezerieCompiling with MSVC results in warnings like below:
app/test-pmd/cmdline.c(9023): warning C5101: use of preprocessor
directive in function-like macro argument list is undefined behavior
--- app/test-pmd/cmdline.c | 12 ++++++++---- app/test-pmd/testpmd.h | 2 ++ 2 files changed, 10 insertions(+), 4 deletions(-)
app/test-pmd/cmdline.c +8 -4
@@ -8980,6 +8980,14 @@ dump_socket_mem(FILE *f) last_total = total; } +#ifdef RTE_EXEC_ENV_WINDOWS +int +rte_trace_save (void ) +{ +return TEST_SKIPPED ; +} +#endif +static void cmd_dump_parsed (void *parsed_result, __rte_unused struct cmdline *cl, __rte_unused void *data)
@@ -9002,10 +9010,8 @@ static void cmd_dump_parsed(void *parsed_result,rte_devargs_dump (stdout); else if (!strcmp(res->dump, "dump_lcores"))rte_lcore_dump (stdout); -#ifndef RTE_EXEC_ENV_WINDOWS else if (!strcmp(res->dump, "dump_trace"))rte_trace_save (); -#endif else if (!strcmp(res->dump, "dump_log_types"))rte_log_dump (stdout); }
@@ -9020,9 +9026,7 @@ static cmdline_parse_token_string_t cmd_dump_dump ="dump_mempool#" "dump_devargs#" "dump_lcores#" -#ifndef RTE_EXEC_ENV_WINDOWS"dump_trace#" -#endif "dump_log_types");static cmdline_parse_inst_t cmd_dump = {
app/test-pmd/testpmd.h +2 -0
@@ -84,6 +84,8 @@ extern volatile uint8_t f_quit;/* Maximum number of pools supported per Rx queue */ #define MAX_MEMPOOL 8 +#define TEST_SKIPPED 77 +typedef uint32_t lcoreid_t ;typedef uint16_t portid_t ;typedef uint16_t queueid_t ;
Signature · 1 line
2.48.1.vfs.0.0
PATCH v6 7/10 test-pmd: don't return value from void function
In reply to Andre MuezerieCompiling with MSVC results in the warning below:
app/test-pmd/cmdline_flow.c(13964): warning C4098: 'cmd_set_raw_parsed':
'void' function returning a value
--- app/test-pmd/cmdline_flow.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
app/test-pmd/cmdline_flow.c +8 -4
@@ -13952,11 +13952,15 @@ cmd_set_raw_parsed(const struct buffer *in)int gtp_psc =-1 ;/* GTP PSC option index. */ const void *src_spec; -if (in->command ==SET_SAMPLE_ACTIONS ) -return cmd_set_raw_parsed_sample (in); +if (in->command ==SET_SAMPLE_ACTIONS ) { +cmd_set_raw_parsed_sample (in); +return ; + }else if (in->command ==SET_IPV6_EXT_PUSH || - in->command ==SET_IPV6_EXT_REMOVE ) -return cmd_set_ipv6_ext_parsed (in); + in->command ==SET_IPV6_EXT_REMOVE ) { +cmd_set_ipv6_ext_parsed (in); +return ; + }RTE_ASSERT (in->command ==SET_RAW_ENCAP || in->command ==SET_RAW_DECAP );if (in->command ==SET_RAW_ENCAP ) {
Signature · 1 line
2.48.1.vfs.0.0
PATCH v6 8/10 test/test-pmd: declare lcore_count atomic
In reply to Andre MuezerieCompiling with MSVC results in the error below:
app/test/test_ring_perf.c(197): error C7712: address argument to atomic
operation must be a pointer to an atomic integer, 'volatile unsigned int *' is not valid
The fix is to mark lcore_count as atomic.
--- app/test/test_ring_perf.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
app/test/test_ring_perf.c +5 -8
@@ -34,7 +34,7 @@ struct lcore_pair {unsigned c1, c2; }; -static volatile unsigned lcore_count =0 ; +static RTE_ATOMIC (unsigned int ) lcore_count; static void test_ring_print_test_string(unsigned int api_type, int esize,
@@ -193,13 +193,10 @@ enqueue_dequeue_bulk_helper(const unsigned int flag, struct thread_params *p)unsigned int n_remaining;const unsigned int bulk_n = bulk_sizes[p->ring_params->bulk_sizes_i]; -#ifdef RTE_USE_C11_MEM_MODEL -if (rte_atomic_fetch_add_explicit (&lcore_count,1 , rte_memory_order_relaxed) +1 !=2 ) -#else - if (__sync_add_and_fetch(&lcore_count, 1) != 2) -#endif -while (lcore_count !=2 ) +if (rte_atomic_fetch_add_explicit (&lcore_count,1 , rte_memory_order_relaxed) +1 !=2 ) { +while (rte_atomic_load_explicit (&lcore_count, rte_memory_order_relaxed) !=2 )rte_pause (); + } burst =test_ring_calloc (MAX_BURST , p->ring_params->elem_size);if (burst ==NULL )
@@ -272,7 +269,7 @@ run_on_core_pair(struct lcore_pair *cores,struct ring_params *ring_params = param1->ring_params;for (i =0 ; i <RTE_DIM (bulk_sizes); i++) { - lcore_count =0 ; +rte_atomic_store_explicit (&lcore_count,0 , rte_memory_order_relaxed); ring_params->bulk_sizes_i = i;if (cores->c1 ==rte_get_main_lcore ()) {rte_eal_remote_launch (dequeue_bulk, param2, cores->c2);
Signature · 1 line
2.48.1.vfs.0.0
PATCH v6 10/10 app: enable app directory to be compiled with MSVC
In reply to Andre MuezerieEnabled "app" directory to be compiled with MSVC along with all its contents.
Removed flag Wno-deprecated-declarations which is not needed anymore.
--- app/meson.build | 4 ---- app/test-pmd/meson.build | 1 - 2 files changed, 5 deletions(-)
app/meson.build +0 -4
@@ -1,10 +1,6 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017-2019 Intel Corporation -if is_ms_compiler - subdir_done() -endif - disable_apps = ',' + get_option('disable_apps') disable_apps = run_command(list_dir_globs, disable_apps, check: true).stdout().split()
app/test-pmd/meson.build +0 -1
@@ -3,7 +3,6 @@ # override default name to drop the hyphen name = 'testpmd' -cflags += '-Wno-deprecated-declarations' sources = files( '5tswap.c', 'cmdline.c',
Signature · 1 line
2.48.1.vfs.0.0
PATCH v6 9/10 test: add workaround for __builtin_constant_p in test_memcpy_perf
In reply to Andre MuezerieThere's no MSVC equivalent for compiler extension __builtin_constant_p, so a workaround is needed.
--- app/test/test_memcpy_perf.c | 54 ++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 27 deletions(-)
app/test/test_memcpy_perf.c +27 -27
@@ -196,37 +196,37 @@ do { \ }while (0 ) /* Run aligned memcpy tests for each cached/uncached permutation */ -#define ALL_PERF_TESTS_FOR_SIZE (n) \ -do { \ - if (__builtin_constant_p(n)) \ - printf("\nC%6u", (unsigned)n); \ - else \ - printf("\n%7u", (unsigned)n); \ - SINGLE_PERF_TEST(small_buf_write, 1, 0, small_buf_read, 1, 0, n); \ - SINGLE_PERF_TEST(large_buf_write, 0, 0, small_buf_read, 1, 0, n); \ - SINGLE_PERF_TEST(small_buf_write, 1, 0, large_buf_read, 0, 0, n); \ - SINGLE_PERF_TEST(large_buf_write, 0, 0, large_buf_read, 0, 0, n); \ +#define ALL_PERF_TESTS_FOR_SIZE (n) \ +do { \ + if (__rte_constant(n)) \ + printf("\nC%6u", (unsigned int)n); \ + else \ + printf("\n%7u", (unsigned int)n); \ + SINGLE_PERF_TEST(small_buf_write, 1, 0, small_buf_read, 1, 0, n); \ + SINGLE_PERF_TEST(large_buf_write, 0, 0, small_buf_read, 1, 0, n); \ + SINGLE_PERF_TEST(small_buf_write, 1, 0, large_buf_read, 0, 0, n); \ + SINGLE_PERF_TEST(large_buf_write, 0, 0, large_buf_read, 0, 0, n); \ } while (0)/* Run unaligned memcpy tests for each cached/uncached permutation */ -#define ALL_PERF_TESTS_FOR_SIZE_UNALIGNED (n) \ -do { \ - if (__builtin_constant_p(n)) \ - printf("\nC%6u", (unsigned)n); \ - else \ - printf("\n%7u", (unsigned)n); \ - SINGLE_PERF_TEST(small_buf_write, 1, 1, small_buf_read, 1, 5, n); \ - SINGLE_PERF_TEST(large_buf_write, 0, 1, small_buf_read, 1, 5, n); \ - SINGLE_PERF_TEST(small_buf_write, 1, 1, large_buf_read, 0, 5, n); \ - SINGLE_PERF_TEST(large_buf_write, 0, 1, large_buf_read, 0, 5, n); \ +#define ALL_PERF_TESTS_FOR_SIZE_UNALIGNED (n) \ +do { \ + if (__rte_constant(n)) \ + printf("\nC%6u", (unsigned int)n); \ + else \ + printf("\n%7u", (unsigned int)n); \ + SINGLE_PERF_TEST(small_buf_write, 1, 1, small_buf_read, 1, 5, n); \ + SINGLE_PERF_TEST(large_buf_write, 0, 1, small_buf_read, 1, 5, n); \ + SINGLE_PERF_TEST(small_buf_write, 1, 1, large_buf_read, 0, 5, n); \ + SINGLE_PERF_TEST(large_buf_write, 0, 1, large_buf_read, 0, 5, n); \ } while (0)/* Run memcpy tests for constant length */ -#define ALL_PERF_TEST_FOR_CONSTANT \ -do { \ - TEST_CONSTANT(6U); TEST_CONSTANT(64U); TEST_CONSTANT(128U); \ - TEST_CONSTANT(192U); TEST_CONSTANT(256U); TEST_CONSTANT(512U); \ - TEST_CONSTANT(768U); TEST_CONSTANT(1024U); TEST_CONSTANT(1536U); \ +#define ALL_PERF_TEST_FOR_CONSTANT \ +do { \ + TEST_CONSTANT(6U); TEST_CONSTANT(64U); TEST_CONSTANT(128U); \ + TEST_CONSTANT(192U); TEST_CONSTANT(256U); TEST_CONSTANT(512U); \ + TEST_CONSTANT(768U); TEST_CONSTANT(1024U); TEST_CONSTANT(1536U); \ } while (0)/* Run all memcpy tests for aligned constant cases */
@@ -253,7 +253,7 @@ perf_test_variable_aligned(void) {unsigned i;for (i =0 ; i <RTE_DIM (buf_sizes); i++) { -ALL_PERF_TESTS_FOR_SIZE ((size_t )buf_sizes[i]); +ALL_PERF_TESTS_FOR_SIZE (buf_sizes[i]); } }
@@ -263,7 +263,7 @@ perf_test_variable_unaligned(void) {unsigned i;for (i =0 ; i <RTE_DIM (buf_sizes); i++) { -ALL_PERF_TESTS_FOR_SIZE_UNALIGNED ((size_t )buf_sizes[i]); +ALL_PERF_TESTS_FOR_SIZE_UNALIGNED (buf_sizes[i]); } }
Signature · 1 line
2.48.1.vfs.0.0
Re: [PATCH v6 05/10] test-pmd: avoid undefined behavior
In reply to Andre MuezerieQuoted 19 lines · Andre Muezerie
Compiling with MSVC results in warnings like below:
app/test-pmd/cmdline.c(9023): warning C5101: use of preprocessor
directive in function-like macro argument list is undefined behaviorSigned-off-by Andre Muezerie <[email protected]>Signed-off-by Chengwen Feng <[email protected]>--- app/test-pmd/cmdline.c | 12 ++++++++---- app/test-pmd/testpmd.h | 2 ++ 2 files changed, 10 insertions(+), 4 deletions(-)app/test-pmd/cmdline.c +0
-0@@ -8980,6 +8980,14 @@ dump_socket_mem(FILE *f) last_total = total;
app/test-pmd/cmdline.c dump_socket_mem(FILE *f) · line 8990
Quoted 10 lines
app/test-pmd/cmdline.c +8
-0} +#ifdef RTE_EXEC_ENV_WINDOWS +int +rte_trace_save (void ) +{ +return TEST_SKIPPED ; +} +#endif +
- I don't like this fake declaration.
It does not comply with this function documented API.
And there are other stubs for the trace API in eal/windows, where this could be a better place.
- TEST_SKIPPED 77 is some known error code when invoking unit test via meson, which does not make sense with testpmd.
I sent a simpler fix, could you have a look?
https://patchwork.dpdk.org/project/dpdk/patch/[email protected]/
Signature · 1 line
David Marchand
Re: [PATCH v6 05/10] test-pmd: avoid undefined behavior
Quoted 37 lines · David Marchand
Quoted 19 lines · Andre Muezerie
Compiling with MSVC results in warnings like below:
app/test-pmd/cmdline.c(9023): warning C5101: use of preprocessor
directive in function-like macro argument list is undefined behaviorSigned-off-by Andre Muezerie <[email protected]>Signed-off-by Chengwen Feng <[email protected]>--- app/test-pmd/cmdline.c | 12 ++++++++---- app/test-pmd/testpmd.h | 2 ++ 2 files changed, 10 insertions(+), 4 deletions(-)app/test-pmd/cmdline.c +0
-0@@ -8980,6 +8980,14 @@ dump_socket_mem(FILE *f) last_total = total;app/test-pmd/cmdline.c dump_socket_mem(FILE *f) · line 8990
Quoted 10 lines
app/test-pmd/cmdline.c +8
-0} +#ifdef RTE_EXEC_ENV_WINDOWS +int +rte_trace_save (void ) +{ +return TEST_SKIPPED ; +} +#endif +- I don't like this fake declaration.
It does not comply with this function documented API.
And there are other stubs for the trace API in eal/windows, where this could be a better place.
Quoted 7 lines
-
TEST_SKIPPED77 is some known error code when invoking unit test via meson, which does not make sense with testpmd.I sent a simpler fix, could you have a look?
https://patchwork.dpdk.org/project/dpdk/patch/[email protected]/
I like the solution you proposed. Thanks!
Quoted 3 lines
Signature · 2 lines
-- David Marchand
Hello Andre,
Quoted 33 lines · Andre Muezerie
v6:
- remove "volatile" and userte_atomic_xxxto access theRTE_ATOMICqualifiedlcore_count, which is cleaner than using "volatile".v5:
- add "volatile" to declaration oflcore_countintest_ring_perf.c.v4:
- add explanation about the expression used in__rte_constantduring v3.v3:
- use clever expression with_Genericfor__rte_constantand use it where__builtin_constant_pwas being used.
- use %u incsumonly.cand just cast variables to unsigned int.v2:
- uselcore_countas atomic always, not only whenRTE_USE_C11_MEM_MODELis set.
- use PRIu64 incsumonly.cinstead of casting variables to int.Andre Muezerie (10):
eal: add workaround for__builtin_constant_p
test_alarm: avoid warning about different qualifiers
test-pmd: fix printf format string mismatch
test-pmd: do explicit 64-bit shift to avoid implicit conversion
test-pmd: avoid undefined behavior
test-pmd: avoid non-constant initializer
test-pmd: don't return value from void function test/test-pmd: declarelcore_countatomic
test: add workaround for__builtin_constant_pintest_memcpy_perf
app: enable app directory to be compiled with MSVC
Quoted 14 lines
app/meson.build | 4 --- app/test-pmd/cmdline.c | 16 +++++---- app/test-pmd/cmdline_flow.c | 22 ++++++------ app/test-pmd/csumonly.c | 23 ++++++------ app/test-pmd/meson.build | 1 - app/test-pmd/testpmd.c | 2 +- app/test-pmd/testpmd.h | 2 ++ app/test-pmd/util.c | 2 +- app/test/test_alarm.c | 12 +++---- app/test/test_memcpy_perf.c | 54 ++++++++++++++--------------- app/test/test_ring_perf.c | 13 +++---- lib/eal/include/generic/rte_pause.h | 2 +- lib/eal/include/rte_common.h | 34 +++++++++++++++++- 13 files changed, 109 insertions(+), 78 deletions(-)
I replaced patch 5 with the alternative that I sent yesterday. Series applied.
We now have dpdk-test and dpdk-testpmd built with MSVC in the CI. We are still missing net/null and mempool/ring to do some basic test like devtools/test-null.sh.
On the other hand, what prevents us from running the fast-tests testsuite in the CI?
Signature · 1 line
David Marchand
Quoted 52 lines · David Marchand
Hello Andre,
Quoted 33 lines · Andre Muezerie
v6:
- remove "volatile" and userte_atomic_xxxto access theRTE_ATOMICqualifiedlcore_count, which is cleaner than using "volatile".v5:
- add "volatile" to declaration oflcore_countintest_ring_perf.c.v4:
- add explanation about the expression used in__rte_constantduring v3.v3:
- use clever expression with_Genericfor__rte_constantand use it where__builtin_constant_pwas being used.
- use %u incsumonly.cand just cast variables to unsigned int.v2:
- uselcore_countas atomic always, not only whenRTE_USE_C11_MEM_MODELis set.
- use PRIu64 incsumonly.cinstead of casting variables to int.Andre Muezerie (10):
eal: add workaround for__builtin_constant_p
test_alarm: avoid warning about different qualifiers
test-pmd: fix printf format string mismatch
test-pmd: do explicit 64-bit shift to avoid implicit conversion
test-pmd: avoid undefined behavior
test-pmd: avoid non-constant initializer
test-pmd: don't return value from void function test/test-pmd: declarelcore_countatomic
test: add workaround for__builtin_constant_pintest_memcpy_perf
app: enable app directory to be compiled with MSVCQuoted 14 lines
app/meson.build | 4 --- app/test-pmd/cmdline.c | 16 +++++---- app/test-pmd/cmdline_flow.c | 22 ++++++------ app/test-pmd/csumonly.c | 23 ++++++------ app/test-pmd/meson.build | 1 - app/test-pmd/testpmd.c | 2 +- app/test-pmd/testpmd.h | 2 ++ app/test-pmd/util.c | 2 +- app/test/test_alarm.c | 12 +++---- app/test/test_memcpy_perf.c | 54 ++++++++++++++--------------- app/test/test_ring_perf.c | 13 +++---- lib/eal/include/generic/rte_pause.h | 2 +- lib/eal/include/rte_common.h | 34 +++++++++++++++++- 13 files changed, 109 insertions(+), 78 deletions(-)
Quoted 9 lines
I replaced patch 5 with the alternative that I sent yesterday. Series applied.
We now have dpdk-test and dpdk-testpmd built with MSVC in the CI. We are still missing net/null and mempool/ring to do some basic test like
devtools/test-null.sh.
On the other hand, what prevents us from running the fast-tests testsuite in the CI?
We are certainly close to the point where fast-tests testsuite can be run. On my machine, with some fixes that are still under review, I'm seeing all tests passing or getting skipped, except for memzone_autotest, which I also see failing on Linux when the same parameters are used. So this test failure does not look like is msvc-specific.
meson test -C build --suite fast-tests --test-args="--no-huge -m 8192" -t 4 …
56/93 DPDK:fast-tests / memzone_autotest FAIL 0.12s (exit status 4294967295 or signal 4294967167 SIGinvalid)
Quoted 1 line
Quoted 1 line
Quoted 1 line
DPDK_TEST=memzone_autotest MESON_TEST_ITERATION=1 ASAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1 MALLOC_PERTURB_=87 MSAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1:print_stacktrace=1 UBSAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1:print_stacktrace=1 V:\github\dpdk13_drivers_used_vars\dpdk\build\app\dpdk-test.exe --no-huge -m 8192
Ok: 73 Expected Fail: 0 Fail: 1 Unexpected Pass: 0 Skipped: 19 Timeout: 0
When running the same command on "main" branch I see less tests running and more failures.
--
Andre Muezerie
Quoted 3 lines
Signature · 2 lines
-- David Marchand