Skip to content

Commit

Permalink
selftests: xsk: Add use_poll to ifobject
Browse files Browse the repository at this point in the history
Add a use_poll option to the ifobject so that we do not need to use a
test specific if-statement in the test runner.

Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Link: https://lore.kernel.org/bpf/20210907071928.9750-9-magnus.karlsson@gmail.com
  • Loading branch information
Magnus Karlsson authored and Daniel Borkmann committed Sep 10, 2021
1 parent 53cb3ce commit 119d4b0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tools/testing/selftests/bpf/xdpxceiver.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ static void __test_spec_init(struct test_spec *test, struct ifobject *ifobj_tx,

ifobj->umem = &ifobj->umem_arr[0];
ifobj->xsk = &ifobj->xsk_arr[0];
ifobj->use_poll = false;

if (i == tx)
ifobj->fv.vector = tx;
Expand Down Expand Up @@ -684,7 +685,7 @@ static void send_pkts(struct ifobject *ifobject)
while (pkt_cnt < ifobject->pkt_stream->nb_pkts) {
u32 sent;

if (test_type == TEST_TYPE_POLL) {
if (ifobject->use_poll) {
int ret;

ret = poll(fds, 1, POLL_TMOUT);
Expand Down Expand Up @@ -1071,6 +1072,8 @@ static void run_pkt_test(struct test_spec *test, int mode, int type)
testapp_validate_traffic(test);
break;
case TEST_TYPE_POLL:
test->ifobj_tx->use_poll = true;
test->ifobj_rx->use_poll = true;
test_spec_set_name(test, "POLL");
testapp_validate_traffic(test);
break;
Expand Down
1 change: 1 addition & 0 deletions tools/testing/selftests/bpf/xdpxceiver.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ struct ifobject {
u32 src_ip;
u16 src_port;
u16 dst_port;
bool use_poll;
u8 dst_mac[ETH_ALEN];
u8 src_mac[ETH_ALEN];
};
Expand Down

0 comments on commit 119d4b0

Please sign in to comment.