[dpdk-dev] [PATCH v9 07/10] app/testpmd: replace POSIX specific code

Tal Shnaiderman talshn at nvidia.com
Mon May 3 19:37:52 CEST 2021


> Subject: [PATCH v9 07/10] app/testpmd: replace POSIX specific code
> 
> External email: Use caution opening links or attachments
> 
> 
> - Make printf format OS independent
>  - Replace htons with RTE_BE16
>  - Replace POSIX specific inet_aton with OS independent inet_pton
>  - Replace sleep with rte_delay_us_sleep
>  - Repalce random with rte_rand
>  - #ifndef mman related code for now
> 
> Signed-off-by: Jie Zhou <jizh at microsoft.com>
> Signed-off-by: Jie Zhou <jizh at linux.microsoft.com>
> ---
>  app/test-pmd/cmdline.c     |  3 +--
>  app/test-pmd/csumonly.c    |  2 +-
>  app/test-pmd/icmpecho.c    |  4 ++--
>  app/test-pmd/ieee1588fwd.c |  8 ++++----  app/test-pmd/parameters.c  |
> 10 +++++++---
>  app/test-pmd/testpmd.c     | 21 ++++++++++++++++++++-
>  app/test-pmd/testpmd.h     |  2 +-
>  7 files changed, 36 insertions(+), 14 deletions(-)
> 
> diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index
> d804ee233..f0636ca9b 100644
> --- a/app/test-pmd/cmdline.c
> +++ b/app/test-pmd/cmdline.c

<snip>

> @@ -8,7 +8,6 @@
> @@ pmd_test_exit(void)
>                                                      NULL);
>                 }
>         }
> +#endif
>         if (ports != NULL) {
>                 no_link_check = 1;
>                 RTE_ETH_FOREACH_DEV(pt_id) { @@ -3762,7 +3777,9 @@
> signal_handler(int signum)
>                 f_quit = 1;
>                 /* exit with the expected status */
>                 signal(signum, SIG_DFL);
> +#ifndef RTE_EXEC_ENV_WINDOWS
>                 kill(getpid(), signum);
> +#endif

signal() doesn't need to be inside the ifndef?

>         }
>  }
> 
> @@ -3837,10 +3854,12 @@ main(int argc, char** argv)
>         if (argc > 1)
>                 launch_args_parse(argc, argv);
> 
> +#ifndef RTE_EXEC_ENV_WINDOWS
>         if (do_mlockall && mlockall(MCL_CURRENT | MCL_FUTURE)) {
>                 TESTPMD_LOG(NOTICE, "mlockall() failed with error \"%s\"\n",
>                         strerror(errno));
>         }
> +#endif
> 
>         if (tx_first && interactive)
>                 rte_exit(EXIT_FAILURE, "--tx-first cannot be used on "
> @@ -3961,7 +3980,7 @@ main(int argc, char** argv)
>                                 }
>                                 /* Sleep to avoid unnecessary checks */
>                                 prev_time = cur_time;
> -                               sleep(1);
> +                               rte_delay_us_sleep(1000000);

Please use US_PER_S

>                         }
>                 }
> 
> diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index
> 1d104213b..a4115861b 100644
> --- a/app/test-pmd/testpmd.h
> +++ b/app/test-pmd/testpmd.h
> @@ -763,7 +763,7 @@ inc_tx_burst_stats(struct fwd_stream *fs, uint16_t
> nb_tx)  }
> 
>  /* Prototypes */
> -unsigned int parse_item_list(char* str, const char* item_name,
> +unsigned int parse_item_list(const char *str, const char *item_name,
>                         unsigned int max_items,
>                         unsigned int *parsed_items, int check_unique_values);  void
> launch_args_parse(int argc, char** argv);
> --
> 2.30.0.vfs.0.2



More information about the dev mailing list