Commit 744eb5c8 authored by Magnus Karlsson's avatar Magnus Karlsson Committed by Daniel Borkmann

selftests: xsk: Introduce type for thread function

Introduce a typedef of the thread function so this can be passed to
init_iface() in order to simplify that function.
Signed-off-by: default avatarMagnus Karlsson <magnus.karlsson@intel.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Acked-by: default avatarMaciej Fijalkowski <maciej.fijalkowski@intel.com>
Link: https://lore.kernel.org/bpf/20210907071928.9750-3-magnus.karlsson@gmail.com
parent ed7b74dc
...@@ -974,10 +974,9 @@ static void testapp_stats(void) ...@@ -974,10 +974,9 @@ static void testapp_stats(void)
print_ksft_result(); print_ksft_result();
} }
static void init_iface(struct ifobject *ifobj, const char *dst_mac, static void init_iface(struct ifobject *ifobj, const char *dst_mac, const char *src_mac,
const char *src_mac, const char *dst_ip, const char *dst_ip, const char *src_ip, const u16 dst_port,
const char *src_ip, const u16 dst_port, const u16 src_port, enum fvector vector, thread_func_t func_ptr)
const u16 src_port, enum fvector vector)
{ {
struct in_addr ip; struct in_addr ip;
...@@ -993,15 +992,13 @@ static void init_iface(struct ifobject *ifobj, const char *dst_mac, ...@@ -993,15 +992,13 @@ static void init_iface(struct ifobject *ifobj, const char *dst_mac,
ifobj->dst_port = dst_port; ifobj->dst_port = dst_port;
ifobj->src_port = src_port; ifobj->src_port = src_port;
if (vector == tx) { if (vector == tx)
ifobj->fv.vector = tx;
ifobj->func_ptr = worker_testapp_validate_tx;
ifdict_tx = ifobj; ifdict_tx = ifobj;
} else { else
ifobj->fv.vector = rx;
ifobj->func_ptr = worker_testapp_validate_rx;
ifdict_rx = ifobj; ifdict_rx = ifobj;
}
ifobj->fv.vector = vector;
ifobj->func_ptr = func_ptr;
} }
static void run_pkt_test(int mode, int type) static void run_pkt_test(int mode, int type)
...@@ -1097,8 +1094,10 @@ int main(int argc, char **argv) ...@@ -1097,8 +1094,10 @@ int main(int argc, char **argv)
parse_command_line(argc, argv); parse_command_line(argc, argv);
init_iface(ifdict[tx], MAC1, MAC2, IP1, IP2, UDP_PORT1, UDP_PORT2, tx); init_iface(ifdict[tx], MAC1, MAC2, IP1, IP2, UDP_PORT1, UDP_PORT2, tx,
init_iface(ifdict[rx], MAC2, MAC1, IP2, IP1, UDP_PORT2, UDP_PORT1, rx); worker_testapp_validate_tx);
init_iface(ifdict[rx], MAC2, MAC1, IP2, IP1, UDP_PORT2, UDP_PORT1, rx,
worker_testapp_validate_rx);
ksft_set_plan(TEST_MODE_MAX * TEST_TYPE_MAX); ksft_set_plan(TEST_MODE_MAX * TEST_TYPE_MAX);
......
...@@ -116,6 +116,8 @@ struct pkt_stream { ...@@ -116,6 +116,8 @@ struct pkt_stream {
struct pkt *pkts; struct pkt *pkts;
}; };
typedef void *(*thread_func_t)(void *arg);
struct ifobject { struct ifobject {
char ifname[MAX_INTERFACE_NAME_CHARS]; char ifname[MAX_INTERFACE_NAME_CHARS];
char nsname[MAX_INTERFACES_NAMESPACE_CHARS]; char nsname[MAX_INTERFACES_NAMESPACE_CHARS];
...@@ -123,8 +125,8 @@ struct ifobject { ...@@ -123,8 +125,8 @@ struct ifobject {
struct xsk_socket_info *xsk_arr; struct xsk_socket_info *xsk_arr;
struct xsk_umem_info *umem; struct xsk_umem_info *umem;
struct xsk_umem_info *umem_arr; struct xsk_umem_info *umem_arr;
void *(*func_ptr)(void *arg);
struct flow_vector fv; struct flow_vector fv;
thread_func_t func_ptr;
struct pkt_stream *pkt_stream; struct pkt_stream *pkt_stream;
int ns_fd; int ns_fd;
u32 dst_ip; u32 dst_ip;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment