[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZOiZXIHo1rOt+tNS@boxer>
Date: Fri, 25 Aug 2023 14:06:52 +0200
From: Maciej Fijalkowski <maciej.fijalkowski@...el.com>
To: Magnus Karlsson <magnus.karlsson@...il.com>
CC: <magnus.karlsson@...el.com>, <bjorn@...nel.org>, <ast@...nel.org>,
<daniel@...earbox.net>, <netdev@...r.kernel.org>, <bpf@...r.kernel.org>,
<yhs@...com>, <andrii@...nel.org>, <martin.lau@...ux.dev>, <song@...nel.org>,
<john.fastabend@...il.com>, <kpsingh@...nel.org>, <sdf@...gle.com>,
<haoluo@...gle.com>, <jolsa@...nel.org>, <przemyslaw.kitszel@...el.com>
Subject: Re: [PATCH bpf-next v2 05/11] selftests/xsk: declare test names in
struct
On Thu, Aug 24, 2023 at 02:28:47PM +0200, Magnus Karlsson wrote:
> From: Magnus Karlsson <magnus.karlsson@...el.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@...el.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
>
Powered by blists - more mailing lists