All of lore.kernel.org
 help / color / mirror / Atom feed
From: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
To: Magnus Karlsson <magnus.karlsson@gmail.com>
Cc: <magnus.karlsson@intel.com>, <bjorn@kernel.org>, <ast@kernel.org>,
	<daniel@iogearbox.net>, <netdev@vger.kernel.org>,
	<bpf@vger.kernel.org>, <yhs@fb.com>, <andrii@kernel.org>,
	<martin.lau@linux.dev>, <song@kernel.org>,
	<john.fastabend@gmail.com>, <kpsingh@kernel.org>,
	<sdf@google.com>, <haoluo@google.com>, <jolsa@kernel.org>,
	<przemyslaw.kitszel@intel.com>
Subject: Re: [PATCH bpf-next v2 05/11] selftests/xsk: declare test names in struct
Date: Fri, 25 Aug 2023 14:06:52 +0200	[thread overview]
Message-ID: <ZOiZXIHo1rOt+tNS@boxer> (raw)
In-Reply-To: <20230824122853.3494-6-magnus.karlsson@gmail.com>

On Thu, Aug 24, 2023 at 02:28:47PM +0200, Magnus Karlsson wrote:
> From: Magnus Karlsson <magnus.karlsson@intel.com>
> 
> Declare the test names statically in a struct so that we can refer to
> them when adding the support to execute a single test in the next
> commit. Before this patch, the names of them were not declared in a
> single place which made it not possible to refer to them.
> 
> Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
> ---
>  tools/testing/selftests/bpf/xskxceiver.c | 191 +++++++----------------
>  tools/testing/selftests/bpf/xskxceiver.h |  37 +----
>  2 files changed, 57 insertions(+), 171 deletions(-)
> 
> diff --git a/tools/testing/selftests/bpf/xskxceiver.c b/tools/testing/selftests/bpf/xskxceiver.c
> index ee72bb0a8978..b1d0c69f21b8 100644
> --- a/tools/testing/selftests/bpf/xskxceiver.c
> +++ b/tools/testing/selftests/bpf/xskxceiver.c

(...)

>  		ksft_test_result_pass("PASS: %s %s%s\n", mode_string(test), busy_poll_string(test),
> @@ -2395,6 +2277,39 @@ static bool is_xdp_supported(int ifindex)
>  	return true;
>  }
>  
> +static const struct test_spec tests[] = {
> +	{.name = "SEND_RECEIVE", .test_func = testapp_send_receive},
> +	{.name = "SEND_RECEIVE_2K_FRAME", .test_func = testapp_send_receive_2k_frame},
> +	{.name = "SEND_RECEIVE_SINGLE_PKT", .test_func = testapp_single_pkt},
> +	{.name = "POLL_RX", .test_func = testapp_poll_rx},
> +	{.name = "POLL_TX", .test_func = testapp_poll_tx},
> +	{.name = "POLL_RXQ_FULL", .test_func = testapp_poll_rxq_tmout},
> +	{.name = "POLL_TXQ_FULL", .test_func = testapp_poll_txq_tmout},
> +	{.name = "SEND_RECEIVE_UNALIGNED", .test_func = testapp_send_receive_unaligned},
> +	{.name = "ALIGNED_INV_DESC", .test_func = testapp_aligned_inv_desc},
> +	{.name = "ALIGNED_INV_DESC_2K_FRAME_SIZE", .test_func = testapp_aligned_inv_desc_2k_frame},
> +	{.name = "UNALIGNED_INV_DESC", .test_func = testapp_unaligned_inv_desc},
> +	{.name = "UNALIGNED_INV_DESC_4001_FRAME_SIZE",
> +	 .test_func = testapp_unaligned_inv_desc_4001_frame},
> +	{.name = "UMEM_HEADROOM", .test_func = testapp_headroom},
> +	{.name = "TEARDOWN", .test_func = testapp_teardown},
> +	{.name = "BIDIRECTIONAL", .test_func = testapp_bidirectional},
> +	{.name = "STAT_RX_DROPPED", .test_func = testapp_stats_rx_dropped},
> +	{.name = "STAT_TX_INVALID", .test_func = testapp_stats_tx_invalid_descs},
> +	{.name = "STAT_RX_FULL", .test_func = testapp_stats_rx_full},
> +	{.name = "STAT_FILL_EMPTY", .test_func = testapp_stats_fill_empty},
> +	{.name = "XDP_PROG_CLEANUP", .test_func = testapp_xdp_prog_cleanup},
> +	{.name = "XDP_DROP_HALF", .test_func = testapp_xdp_drop},
> +	{.name = "XDP_METADATA_COPY", .test_func = testapp_xdp_metadata},
> +	{.name = "XDP_METADATA_COPY_MULTI_BUFF", .test_func = testapp_xdp_metadata_mb},
> +	{.name = "SEND_RECEIVE_9K_PACKETS", .test_func = testapp_send_receive_mb},
> +	{.name = "SEND_RECEIVE_UNALIGNED_9K_PACKETS",
> +	 .test_func = testapp_send_receive_unaligned_mb},
> +	{.name = "ALIGNED_INV_DESC_MULTI_BUFF", .test_func = testapp_aligned_inv_desc_mb},
> +	{.name = "UNALIGNED_INV_DESC_MULTI_BUFF", .test_func = testapp_unaligned_inv_desc_mb},
> +	{.name = "TOO_MANY_FRAGS", .test_func = testapp_too_many_frags},
> +};

To others, I was asking on v1 to move this to a header file but i missed
somehow that we also set .test_func here so this would require us to
un-static each and every function which would in turn cause the diffstat
to grow significantly. IOW let us address that later.

> +
>  int main(int argc, char **argv)
>  {
>  	struct pkt_stream *rx_pkt_stream_default;
> @@ -2437,7 +2352,7 @@ int main(int argc, char **argv)
>  	init_iface(ifobj_rx, MAC1, MAC2, worker_testapp_validate_rx);
>  	init_iface(ifobj_tx, MAC2, MAC1, worker_testapp_validate_tx);
>  
> -	test_spec_init(&test, ifobj_tx, ifobj_rx, 0);
> +	test_spec_init(&test, ifobj_tx, ifobj_rx, 0, &tests[0]);
>  	tx_pkt_stream_default = pkt_stream_generate(ifobj_tx->umem, DEFAULT_PKT_CNT, MIN_PKT_SIZE);
>  	rx_pkt_stream_default = pkt_stream_generate(ifobj_rx->umem, DEFAULT_PKT_CNT, MIN_PKT_SIZE);
>  	if (!tx_pkt_stream_default || !rx_pkt_stream_default)
> @@ -2446,17 +2361,17 @@ int main(int argc, char **argv)
>  	test.rx_pkt_stream_default = rx_pkt_stream_default;
>  
>  	if (opt_mode == TEST_MODE_ALL)
> -		ksft_set_plan(modes * TEST_TYPE_MAX);
> +		ksft_set_plan(modes * ARRAY_SIZE(tests));
>  	else
> -		ksft_set_plan(TEST_TYPE_MAX);
> +		ksft_set_plan(ARRAY_SIZE(tests));
>  
>  	for (i = 0; i < modes; i++) {
>  		if (opt_mode != TEST_MODE_ALL && i != opt_mode)
>  			continue;
>  
> -		for (j = 0; j < TEST_TYPE_MAX; j++) {
> -			test_spec_init(&test, ifobj_tx, ifobj_rx, i);
> -			run_pkt_test(&test, i, j);
> +		for (j = 0; j < ARRAY_SIZE(tests); j++) {
> +			test_spec_init(&test, ifobj_tx, ifobj_rx, i, &tests[j]);
> +			run_pkt_test(&test);
>  			usleep(USLEEP_MAX);
>  
>  			if (test.fail)
> diff --git a/tools/testing/selftests/bpf/xskxceiver.h b/tools/testing/selftests/bpf/xskxceiver.h
> index 1412492e9618..3a71d490db3e 100644
> --- a/tools/testing/selftests/bpf/xskxceiver.h
> +++ b/tools/testing/selftests/bpf/xskxceiver.h
> @@ -34,7 +34,7 @@
>  #define MAX_INTERFACES 2
>  #define MAX_INTERFACE_NAME_CHARS 16
>  #define MAX_SOCKETS 2
> -#define MAX_TEST_NAME_SIZE 32
> +#define MAX_TEST_NAME_SIZE 48
>  #define MAX_TEARDOWN_ITER 10
>  #define PKT_HDR_SIZE (sizeof(struct ethhdr) + 2) /* Just to align the data in the packet */
>  #define MIN_PKT_SIZE 64
> @@ -66,38 +66,6 @@ enum test_mode {
>  	TEST_MODE_ALL
>  };
>  
> -enum test_type {
> -	TEST_TYPE_RUN_TO_COMPLETION,
> -	TEST_TYPE_RUN_TO_COMPLETION_2K_FRAME,
> -	TEST_TYPE_RUN_TO_COMPLETION_SINGLE_PKT,
> -	TEST_TYPE_RX_POLL,
> -	TEST_TYPE_TX_POLL,
> -	TEST_TYPE_POLL_RXQ_TMOUT,
> -	TEST_TYPE_POLL_TXQ_TMOUT,
> -	TEST_TYPE_UNALIGNED,
> -	TEST_TYPE_ALIGNED_INV_DESC,
> -	TEST_TYPE_ALIGNED_INV_DESC_2K_FRAME,
> -	TEST_TYPE_UNALIGNED_INV_DESC,
> -	TEST_TYPE_UNALIGNED_INV_DESC_4K1_FRAME,
> -	TEST_TYPE_HEADROOM,
> -	TEST_TYPE_TEARDOWN,
> -	TEST_TYPE_BIDI,
> -	TEST_TYPE_STATS_RX_DROPPED,
> -	TEST_TYPE_STATS_TX_INVALID_DESCS,
> -	TEST_TYPE_STATS_RX_FULL,
> -	TEST_TYPE_STATS_FILL_EMPTY,
> -	TEST_TYPE_BPF_RES,
> -	TEST_TYPE_XDP_DROP_HALF,
> -	TEST_TYPE_XDP_METADATA_COUNT,
> -	TEST_TYPE_XDP_METADATA_COUNT_MB,
> -	TEST_TYPE_RUN_TO_COMPLETION_MB,
> -	TEST_TYPE_UNALIGNED_MB,
> -	TEST_TYPE_ALIGNED_INV_DESC_MB,
> -	TEST_TYPE_UNALIGNED_INV_DESC_MB,
> -	TEST_TYPE_TOO_MANY_FRAGS,
> -	TEST_TYPE_MAX
> -};
> -
>  struct xsk_umem_info {
>  	struct xsk_ring_prod fq;
>  	struct xsk_ring_cons cq;
> @@ -137,8 +105,10 @@ struct pkt_stream {
>  };
>  
>  struct ifobject;
> +struct test_spec;
>  typedef int (*validation_func_t)(struct ifobject *ifobj);
>  typedef void *(*thread_func_t)(void *arg);
> +typedef int (*test_func_t)(struct test_spec *test);
>  
>  struct ifobject {
>  	char ifname[MAX_INTERFACE_NAME_CHARS];
> @@ -180,6 +150,7 @@ struct test_spec {
>  	struct bpf_program *xdp_prog_tx;
>  	struct bpf_map *xskmap_rx;
>  	struct bpf_map *xskmap_tx;
> +	test_func_t test_func;
>  	int mtu;
>  	u16 total_steps;
>  	u16 current_step;
> -- 
> 2.34.1
> 

  reply	other threads:[~2023-08-25 12:07 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-24 12:28 [PATCH bpf-next v2 00/11] seltests/xsk: various improvements to xskxceiver Magnus Karlsson
2023-08-24 12:28 ` [PATCH bpf-next v2 01/11] selftests/xsk: print per packet info in verbose mode Magnus Karlsson
2023-08-24 12:28 ` [PATCH bpf-next v2 02/11] selftests/xsk: add timeout for Tx thread Magnus Karlsson
2023-08-24 12:28 ` [PATCH bpf-next v2 03/11] selftests/xsk: add option to only run tests in a single mode Magnus Karlsson
2023-08-25 12:02   ` Maciej Fijalkowski
2023-08-25 12:30     ` Magnus Karlsson
2023-08-24 12:28 ` [PATCH bpf-next v2 04/11] selftests/xsk: move all tests to separate functions Magnus Karlsson
2023-08-24 12:28 ` [PATCH bpf-next v2 05/11] selftests/xsk: declare test names in struct Magnus Karlsson
2023-08-25 12:06   ` Maciej Fijalkowski [this message]
2023-08-24 12:28 ` [PATCH bpf-next v2 06/11] selftests/xsk: add option that lists all tests Magnus Karlsson
2023-08-24 12:28 ` [PATCH bpf-next v2 07/11] selftests/xsk: add option to run single test Magnus Karlsson
2023-08-25 12:44   ` Maciej Fijalkowski
2023-08-25 12:50     ` Magnus Karlsson
2023-08-24 12:28 ` [PATCH bpf-next v2 08/11] selftests/xsk: use ksft_print_msg uniformly Magnus Karlsson
2023-08-24 12:28 ` [PATCH bpf-next v2 09/11] selftests/xsk: fail single test instead of all tests Magnus Karlsson
2023-08-25 12:48   ` Maciej Fijalkowski
2023-08-24 12:28 ` [PATCH bpf-next v2 10/11] selftests/xsk: display command line options with -h Magnus Karlsson
2023-08-25 12:49   ` Maciej Fijalkowski
2023-08-25 12:54     ` Magnus Karlsson
2023-08-25 13:06       ` Maciej Fijalkowski
2023-08-24 12:28 ` [PATCH bpf-next v2 11/11] selftests/xsk: introduce XSKTEST_ETH environment variable Magnus Karlsson
2023-08-25 12:57   ` Maciej Fijalkowski
2023-08-25 13:03     ` Magnus Karlsson
2023-08-25 13:19       ` Maciej Fijalkowski
2023-08-25 13:34         ` Magnus Karlsson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZOiZXIHo1rOt+tNS@boxer \
    --to=maciej.fijalkowski@intel.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bjorn@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=magnus.karlsson@gmail.com \
    --cc=magnus.karlsson@intel.com \
    --cc=martin.lau@linux.dev \
    --cc=netdev@vger.kernel.org \
    --cc=przemyslaw.kitszel@intel.com \
    --cc=sdf@google.com \
    --cc=song@kernel.org \
    --cc=yhs@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.