Lines Matching refs:ifobj

255 static bool is_umem_valid(struct ifobject *ifobj)  in is_umem_valid()  argument
257 return !!ifobj->umem->umem; in is_umem_valid()
398 static bool validate_interface(struct ifobject *ifobj) in validate_interface() argument
400 if (!strcmp(ifobj->ifname, "")) in validate_interface()
408 struct ifobject *ifobj; in parse_command_line() local
422 ifobj = ifobj_tx; in parse_command_line()
424 ifobj = ifobj_rx; in parse_command_line()
428 memcpy(ifobj->ifname, optarg, in parse_command_line()
431 ifobj->ifindex = if_nametoindex(ifobj->ifname); in parse_command_line()
432 if (!ifobj->ifindex) in parse_command_line()
460 struct ifobject *ifobj = i ? ifobj_rx : ifobj_tx; in __test_spec_init() local
462 ifobj->xsk = &ifobj->xsk_arr[0]; in __test_spec_init()
463 ifobj->use_poll = false; in __test_spec_init()
464 ifobj->use_fill_ring = true; in __test_spec_init()
465 ifobj->release_rx = true; in __test_spec_init()
466 ifobj->validation_func = NULL; in __test_spec_init()
469 ifobj->rx_on = false; in __test_spec_init()
470 ifobj->tx_on = true; in __test_spec_init()
471 ifobj->pkt_stream = test->tx_pkt_stream_default; in __test_spec_init()
473 ifobj->rx_on = true; in __test_spec_init()
474 ifobj->tx_on = false; in __test_spec_init()
475 ifobj->pkt_stream = test->rx_pkt_stream_default; in __test_spec_init()
478 memset(ifobj->umem, 0, sizeof(*ifobj->umem)); in __test_spec_init()
479 ifobj->umem->num_frames = DEFAULT_UMEM_BUFFERS; in __test_spec_init()
480 ifobj->umem->frame_size = XSK_UMEM__DEFAULT_FRAME_SIZE; in __test_spec_init()
481 if (ifobj->shared_umem && ifobj->rx_on) in __test_spec_init()
482 ifobj->umem->base_addr = DEFAULT_UMEM_BUFFERS * in __test_spec_init()
486 memset(&ifobj->xsk_arr[j], 0, sizeof(ifobj->xsk_arr[j])); in __test_spec_init()
487 ifobj->xsk_arr[j].rxqsize = XSK_RING_CONS__DEFAULT_NUM_DESCS; in __test_spec_init()
517 struct ifobject *ifobj = i ? ifobj_rx : ifobj_tx; in test_spec_init() local
519 ifobj->bind_flags = XDP_USE_NEED_WAKEUP; in test_spec_init()
521 ifobj->bind_flags |= XDP_ZEROCOPY; in test_spec_init()
523 ifobj->bind_flags |= XDP_COPY; in test_spec_init()
660 static void __pkt_stream_replace_half(struct ifobject *ifobj, u32 pkt_len, in __pkt_stream_replace_half() argument
663 struct xsk_umem_info *umem = ifobj->umem; in __pkt_stream_replace_half()
667 pkt_stream = pkt_stream_clone(umem, ifobj->pkt_stream); in __pkt_stream_replace_half()
668 for (i = 1; i < ifobj->pkt_stream->nb_pkts; i += 2) in __pkt_stream_replace_half()
672 ifobj->pkt_stream = pkt_stream; in __pkt_stream_replace_half()
720 static void __pkt_stream_generate_custom(struct ifobject *ifobj, in __pkt_stream_generate_custom() argument
731 pkt_stream->pkts[i].addr = pkts[i].addr + ifobj->umem->base_addr; in __pkt_stream_generate_custom()
737 ifobj->pkt_stream = pkt_stream; in __pkt_stream_generate_custom()
897 struct ifobject *ifobj = test->ifobj_rx; in receive_pkts() local
918 if (ifobj->use_poll) { in receive_pkts()
940 if (ifobj->use_fill_ring) { in receive_pkts()
965 if (ifobj->use_fill_ring) in receive_pkts()
970 if (ifobj->use_fill_ring) in receive_pkts()
972 if (ifobj->release_rx) in receive_pkts()
1358 static void testapp_clean_xsk_umem(struct ifobject *ifobj) in testapp_clean_xsk_umem() argument
1360 u64 umem_sz = ifobj->umem->num_frames * ifobj->umem->frame_size; in testapp_clean_xsk_umem()
1362 if (ifobj->shared_umem) in testapp_clean_xsk_umem()
1365 xsk_umem__delete(ifobj->umem->umem); in testapp_clean_xsk_umem()
1366 munmap(ifobj->umem->buffer, umem_sz); in testapp_clean_xsk_umem()
1374 static bool xdp_prog_changed(struct test_spec *test, struct ifobject *ifobj) in xdp_prog_changed() argument
1376 return ifobj->xdp_prog != test->xdp_prog_rx || ifobj->mode != test->mode; in xdp_prog_changed()
1379 static void xsk_reattach_xdp(struct ifobject *ifobj, struct bpf_program *xdp_prog, in xsk_reattach_xdp() argument
1384 xsk_detach_xdp_program(ifobj->ifindex, mode_to_xdp_flags(ifobj->mode)); in xsk_reattach_xdp()
1385 err = xsk_attach_xdp_program(xdp_prog, ifobj->ifindex, mode_to_xdp_flags(mode)); in xsk_reattach_xdp()
1391 if (ifobj->mode != mode && (mode == TEST_MODE_DRV || mode == TEST_MODE_ZC)) in xsk_reattach_xdp()
1392 if (!xsk_is_in_mode(ifobj->ifindex, XDP_FLAGS_DRV_MODE)) { in xsk_reattach_xdp()
1397 ifobj->xdp_prog = xdp_prog; in xsk_reattach_xdp()
1398 ifobj->xskmap = xskmap; in xsk_reattach_xdp()
1399 ifobj->mode = mode; in xsk_reattach_xdp()
1469 static int testapp_validate_traffic_single_thread(struct test_spec *test, struct ifobject *ifobj) in testapp_validate_traffic_single_thread() argument
1471 return __testapp_validate_traffic(test, ifobj, NULL); in testapp_validate_traffic_single_thread()
1707 static int xsk_load_xdp_programs(struct ifobject *ifobj) in xsk_load_xdp_programs() argument
1709 ifobj->xdp_progs = xsk_xdp_progs__open_and_load(); in xsk_load_xdp_programs()
1710 if (libbpf_get_error(ifobj->xdp_progs)) in xsk_load_xdp_programs()
1711 return libbpf_get_error(ifobj->xdp_progs); in xsk_load_xdp_programs()
1716 static void xsk_unload_xdp_programs(struct ifobject *ifobj) in xsk_unload_xdp_programs() argument
1718 xsk_xdp_progs__destroy(ifobj->xdp_progs); in xsk_unload_xdp_programs()
1721 static void init_iface(struct ifobject *ifobj, const char *dst_mac, const char *src_mac, in init_iface() argument
1728 memcpy(ifobj->dst_mac, dst_mac, ETH_ALEN); in init_iface()
1729 memcpy(ifobj->src_mac, src_mac, ETH_ALEN); in init_iface()
1732 ifobj->dst_ip = ip.s_addr; in init_iface()
1735 ifobj->src_ip = ip.s_addr; in init_iface()
1737 ifobj->dst_port = dst_port; in init_iface()
1738 ifobj->src_port = src_port; in init_iface()
1740 ifobj->func_ptr = func_ptr; in init_iface()
1742 err = xsk_load_xdp_programs(ifobj); in init_iface()
1850 struct ifobject *ifobj; in ifobject_create() local
1852 ifobj = calloc(1, sizeof(struct ifobject)); in ifobject_create()
1853 if (!ifobj) in ifobject_create()
1856 ifobj->xsk_arr = calloc(MAX_SOCKETS, sizeof(*ifobj->xsk_arr)); in ifobject_create()
1857 if (!ifobj->xsk_arr) in ifobject_create()
1860 ifobj->umem = calloc(1, sizeof(*ifobj->umem)); in ifobject_create()
1861 if (!ifobj->umem) in ifobject_create()
1864 return ifobj; in ifobject_create()
1867 free(ifobj->xsk_arr); in ifobject_create()
1869 free(ifobj); in ifobject_create()
1873 static void ifobject_delete(struct ifobject *ifobj) in ifobject_delete() argument
1875 free(ifobj->umem); in ifobject_delete()
1876 free(ifobj->xsk_arr); in ifobject_delete()
1877 free(ifobj); in ifobject_delete()