Lines Matching defs:ifobject
157 static void gen_eth_hdr(struct ifobject *ifobject, struct ethhdr *eth_hdr)
159 memcpy(eth_hdr->h_dest, ifobject->dst_mac, ETH_ALEN);
160 memcpy(eth_hdr->h_source, ifobject->src_mac, ETH_ALEN);
164 static bool is_umem_valid(struct ifobject *ifobj)
179 static int xsk_configure_umem(struct ifobject *ifobj, struct xsk_umem_info *umem, void *buffer,
246 struct ifobject *ifobject, bool shared)
255 cfg.bind_flags = ifobject->bind_flags;
258 if (ifobject->pkt_stream && ifobject->mtu > MAX_ETH_PKT_SIZE)
261 txr = ifobject->tx_on ? &xsk->tx : NULL;
262 rxr = ifobject->rx_on ? &xsk->rx : NULL;
263 return xsk_socket__create(&xsk->xsk, ifobject->ifindex, 0, umem->umem, rxr, txr, &cfg);
266 static bool ifobj_zc_avail(struct ifobject *ifobject)
286 ret = xsk_configure_umem(ifobject, umem, bufs, umem_sz);
293 ifobject->bind_flags = XDP_USE_NEED_WAKEUP | XDP_ZEROCOPY;
294 ifobject->rx_on = true;
296 ret = __xsk_configure_socket(xsk, umem, ifobject, false);
328 static bool validate_interface(struct ifobject *ifobj)
335 static void parse_command_line(struct ifobject *ifobj_tx, struct ifobject *ifobj_rx, int argc,
338 struct ifobject *ifobj;
381 static void __test_spec_init(struct test_spec *test, struct ifobject *ifobj_tx,
382 struct ifobject *ifobj_rx)
387 struct ifobject *ifobj = i ? ifobj_rx : ifobj_tx;
429 static void test_spec_init(struct test_spec *test, struct ifobject *ifobj_tx,
430 struct ifobject *ifobj_rx, enum test_mode mode)
443 struct ifobject *ifobj = i ? ifobj_rx : ifobj_tx;
651 static void __pkt_stream_replace_half(struct ifobject *ifobj, u32 pkt_len,
696 static void pkt_generate(struct ifobject *ifobject, u64 addr, u32 len, u32 pkt_nb,
699 void *data = xsk_umem__get_data(ifobject->umem->buffer, addr);
705 gen_eth_hdr(ifobject, data);
716 static struct pkt_stream *__pkt_stream_generate_custom(struct ifobject *ifobj, struct pkt *frames,
973 struct ifobject *ifobj = test->ifobj_rx;
1095 static int __send_pkts(struct ifobject *ifobject, struct pollfd *fds, bool timeout)
1098 struct pkt_stream *pkt_stream = ifobject->pkt_stream;
1099 struct xsk_socket_info *xsk = ifobject->xsk;
1100 struct xsk_umem_info *umem = ifobject->umem;
1101 bool use_poll = ifobject->use_poll;
1152 tx_desc->addr = pkt_get_addr(pkt, ifobject->umem);
1164 pkt_generate(ifobject, tx_desc->addr, tx_desc->len, pkt->pkt_nb,
1216 static int send_pkts(struct test_spec *test, struct ifobject *ifobject)
1218 struct pkt_stream *pkt_stream = ifobject->pkt_stream;
1223 fds.fd = xsk_socket__fd(ifobject->xsk->xsk);
1227 ret = __send_pkts(ifobject, &fds, timeout);
1236 wait_for_tx_completion(ifobject->xsk);
1263 static int validate_rx_dropped(struct ifobject *ifobject)
1265 struct xsk_socket *xsk = ifobject->xsk->xsk;
1269 kick_rx(ifobject->xsk);
1281 if (stats.rx_dropped == ifobject->pkt_stream->nb_pkts / 2 ||
1282 stats.rx_dropped == ifobject->pkt_stream->nb_pkts / 2 - 1)
1288 static int validate_rx_full(struct ifobject *ifobject)
1290 struct xsk_socket *xsk = ifobject->xsk->xsk;
1295 kick_rx(ifobject->xsk);
1307 static int validate_fill_empty(struct ifobject *ifobject)
1309 struct xsk_socket *xsk = ifobject->xsk->xsk;
1314 kick_rx(ifobject->xsk);
1326 static int validate_tx_invalid_descs(struct ifobject *ifobject)
1328 struct xsk_socket *xsk = ifobject->xsk->xsk;
1342 if (stats.tx_invalid_descs != ifobject->pkt_stream->nb_pkts / 2) {
1344 __func__, stats.tx_invalid_descs, ifobject->pkt_stream->nb_pkts);
1351 static void xsk_configure_socket(struct test_spec *test, struct ifobject *ifobject,
1357 bool shared = (ifobject->shared_umem && tx) ? true : !!i;
1361 ret = __xsk_configure_socket(&ifobject->xsk_arr[i], umem,
1362 ifobject, shared);
1371 if (ifobject->busy_poll)
1372 enable_busy_poll(&ifobject->xsk_arr[i]);
1376 static void thread_common_ops_tx(struct test_spec *test, struct ifobject *ifobject)
1378 xsk_configure_socket(test, ifobject, test->ifobj_rx->umem, true);
1379 ifobject->xsk = &ifobject->xsk_arr[0];
1380 ifobject->xskmap = test->ifobj_rx->xskmap;
1381 memcpy(ifobject->umem, test->ifobj_rx->umem, sizeof(struct xsk_umem_info));
1382 ifobject->umem->base_addr = 0;
1429 static void thread_common_ops(struct test_spec *test, struct ifobject *ifobject)
1431 u64 umem_sz = ifobject->umem->num_frames * ifobject->umem->frame_size;
1437 if (ifobject->umem->unaligned_mode)
1440 if (ifobject->shared_umem)
1447 ret = xsk_configure_umem(ifobject, ifobject->umem, bufs, umem_sz);
1451 xsk_configure_socket(test, ifobject, ifobject->umem, false);
1453 ifobject->xsk = &ifobject->xsk_arr[0];
1455 if (!ifobject->rx_on)
1458 xsk_populate_fill_ring(ifobject->umem, ifobject->pkt_stream, ifobject->use_fill_ring);
1460 ret = xsk_update_xskmap(ifobject->xskmap, ifobject->xsk->xsk);
1468 struct ifobject *ifobject = test->ifobj_tx;
1472 if (!ifobject->shared_umem)
1473 thread_common_ops(test, ifobject);
1475 thread_common_ops_tx(test, ifobject);
1478 print_verbose("Sending %d packets on interface %s\n", ifobject->pkt_stream->nb_pkts,
1479 ifobject->ifname);
1480 err = send_pkts(test, ifobject);
1482 if (!err && ifobject->validation_func)
1483 err = ifobject->validation_func(ifobject);
1493 struct ifobject *ifobject = test->ifobj_rx;
1498 thread_common_ops(test, ifobject);
1500 xsk_clear_xskmap(ifobject->xskmap);
1501 err = xsk_update_xskmap(ifobject->xskmap, ifobject->xsk->xsk);
1508 fds.fd = xsk_socket__fd(ifobject->xsk->xsk);
1515 if (!err && ifobject->validation_func)
1516 err = ifobject->validation_func(ifobject);
1528 static void testapp_clean_xsk_umem(struct ifobject *ifobj)
1547 struct ifobject *ifobj = test->ifobj_rx;
1554 struct ifobject *ifobj = test->ifobj_tx;
1559 static void xsk_reattach_xdp(struct ifobject *ifobj, struct bpf_program *xdp_prog,
1582 static void xsk_attach_xdp_progs(struct test_spec *test, struct ifobject *ifobj_rx,
1583 struct ifobject *ifobj_tx)
1595 static int __testapp_validate_traffic(struct test_spec *test, struct ifobject *ifobj1,
1596 struct ifobject *ifobj2)
1663 struct ifobject *ifobj_rx = test->ifobj_rx;
1664 struct ifobject *ifobj_tx = test->ifobj_tx;
1676 static int testapp_validate_traffic_single_thread(struct test_spec *test, struct ifobject *ifobj)
1695 static void swap_directions(struct ifobject **ifobj1, struct ifobject **ifobj2)
1698 struct ifobject *tmp_ifobj = (*ifobj1);
1726 static void swap_xsk_resources(struct ifobject *ifobj_tx, struct ifobject *ifobj_rx)
2027 static int xsk_load_xdp_programs(struct ifobject *ifobj)
2036 static void xsk_unload_xdp_programs(struct ifobject *ifobj)
2057 static void init_iface(struct ifobject *ifobj, const char *dst_mac, const char *src_mac,
2233 static struct ifobject *ifobject_create(void)
2235 struct ifobject *ifobj;
2237 ifobj = calloc(1, sizeof(struct ifobject));
2258 static void ifobject_delete(struct ifobject *ifobj)
2297 struct ifobject *ifobj_tx, *ifobj_rx;