Lines Matching refs:ifobj

164 static bool is_umem_valid(struct ifobject *ifobj)  in is_umem_valid()  argument
166 return !!ifobj->umem->umem; in is_umem_valid()
179 static int xsk_configure_umem(struct ifobject *ifobj, struct xsk_umem_info *umem, void *buffer, in xsk_configure_umem() argument
200 if (ifobj->shared_umem && ifobj->rx_on) { in xsk_configure_umem()
328 static bool validate_interface(struct ifobject *ifobj) in validate_interface() argument
330 if (!strcmp(ifobj->ifname, "")) in validate_interface()
338 struct ifobject *ifobj; in parse_command_line() local
352 ifobj = ifobj_tx; in parse_command_line()
354 ifobj = ifobj_rx; in parse_command_line()
358 memcpy(ifobj->ifname, optarg, in parse_command_line()
361 ifobj->ifindex = if_nametoindex(ifobj->ifname); in parse_command_line()
362 if (!ifobj->ifindex) in parse_command_line()
387 struct ifobject *ifobj = i ? ifobj_rx : ifobj_tx; in __test_spec_init() local
389 ifobj->xsk = &ifobj->xsk_arr[0]; in __test_spec_init()
390 ifobj->use_poll = false; in __test_spec_init()
391 ifobj->use_fill_ring = true; in __test_spec_init()
392 ifobj->release_rx = true; in __test_spec_init()
393 ifobj->validation_func = NULL; in __test_spec_init()
394 ifobj->use_metadata = false; in __test_spec_init()
397 ifobj->rx_on = false; in __test_spec_init()
398 ifobj->tx_on = true; in __test_spec_init()
399 ifobj->pkt_stream = test->tx_pkt_stream_default; in __test_spec_init()
401 ifobj->rx_on = true; in __test_spec_init()
402 ifobj->tx_on = false; in __test_spec_init()
403 ifobj->pkt_stream = test->rx_pkt_stream_default; in __test_spec_init()
406 memset(ifobj->umem, 0, sizeof(*ifobj->umem)); in __test_spec_init()
407 ifobj->umem->num_frames = DEFAULT_UMEM_BUFFERS; in __test_spec_init()
408 ifobj->umem->frame_size = XSK_UMEM__DEFAULT_FRAME_SIZE; in __test_spec_init()
411 memset(&ifobj->xsk_arr[j], 0, sizeof(ifobj->xsk_arr[j])); in __test_spec_init()
412 ifobj->xsk_arr[j].rxqsize = XSK_RING_CONS__DEFAULT_NUM_DESCS; in __test_spec_init()
443 struct ifobject *ifobj = i ? ifobj_rx : ifobj_tx; in test_spec_init() local
445 ifobj->bind_flags = XDP_USE_NEED_WAKEUP; in test_spec_init()
447 ifobj->bind_flags |= XDP_ZEROCOPY; in test_spec_init()
449 ifobj->bind_flags |= XDP_COPY; in test_spec_init()
651 static void __pkt_stream_replace_half(struct ifobject *ifobj, u32 pkt_len, in __pkt_stream_replace_half() argument
654 struct xsk_umem_info *umem = ifobj->umem; in __pkt_stream_replace_half()
658 pkt_stream = pkt_stream_clone(umem, ifobj->pkt_stream); in __pkt_stream_replace_half()
659 for (i = 1; i < ifobj->pkt_stream->nb_pkts; i += 2) in __pkt_stream_replace_half()
662 ifobj->pkt_stream = pkt_stream; in __pkt_stream_replace_half()
716 static struct pkt_stream *__pkt_stream_generate_custom(struct ifobject *ifobj, struct pkt *frames, in __pkt_stream_generate_custom() argument
973 struct ifobject *ifobj = test->ifobj_rx; in receive_pkts() local
997 if (ifobj->use_poll) { in receive_pkts()
1018 if (ifobj->use_fill_ring) { in receive_pkts()
1047 (ifobj->use_metadata && !is_metadata_correct(pkt, umem->buffer, addr))) in receive_pkts()
1054 if (ifobj->use_fill_ring) in receive_pkts()
1074 if (ifobj->use_fill_ring) { in receive_pkts()
1081 if (ifobj->use_fill_ring) in receive_pkts()
1083 if (ifobj->release_rx) in receive_pkts()
1528 static void testapp_clean_xsk_umem(struct ifobject *ifobj) in testapp_clean_xsk_umem() argument
1530 u64 umem_sz = ifobj->umem->num_frames * ifobj->umem->frame_size; in testapp_clean_xsk_umem()
1532 if (ifobj->shared_umem) in testapp_clean_xsk_umem()
1536 xsk_umem__delete(ifobj->umem->umem); in testapp_clean_xsk_umem()
1537 munmap(ifobj->umem->buffer, umem_sz); in testapp_clean_xsk_umem()
1547 struct ifobject *ifobj = test->ifobj_rx; in xdp_prog_changed_rx() local
1549 return ifobj->xdp_prog != test->xdp_prog_rx || ifobj->mode != test->mode; in xdp_prog_changed_rx()
1554 struct ifobject *ifobj = test->ifobj_tx; in xdp_prog_changed_tx() local
1556 return ifobj->xdp_prog != test->xdp_prog_tx || ifobj->mode != test->mode; in xdp_prog_changed_tx()
1559 static void xsk_reattach_xdp(struct ifobject *ifobj, struct bpf_program *xdp_prog, in xsk_reattach_xdp() argument
1564 xsk_detach_xdp_program(ifobj->ifindex, mode_to_xdp_flags(ifobj->mode)); in xsk_reattach_xdp()
1565 err = xsk_attach_xdp_program(xdp_prog, ifobj->ifindex, mode_to_xdp_flags(mode)); in xsk_reattach_xdp()
1571 if (ifobj->mode != mode && (mode == TEST_MODE_DRV || mode == TEST_MODE_ZC)) in xsk_reattach_xdp()
1572 if (!xsk_is_in_mode(ifobj->ifindex, XDP_FLAGS_DRV_MODE)) { in xsk_reattach_xdp()
1577 ifobj->xdp_prog = xdp_prog; in xsk_reattach_xdp()
1578 ifobj->xskmap = xskmap; in xsk_reattach_xdp()
1579 ifobj->mode = mode; in xsk_reattach_xdp()
1676 static int testapp_validate_traffic_single_thread(struct test_spec *test, struct ifobject *ifobj) in testapp_validate_traffic_single_thread() argument
1678 return __testapp_validate_traffic(test, ifobj, NULL); in testapp_validate_traffic_single_thread()
2027 static int xsk_load_xdp_programs(struct ifobject *ifobj) in xsk_load_xdp_programs() argument
2029 ifobj->xdp_progs = xsk_xdp_progs__open_and_load(); in xsk_load_xdp_programs()
2030 if (libbpf_get_error(ifobj->xdp_progs)) in xsk_load_xdp_programs()
2031 return libbpf_get_error(ifobj->xdp_progs); in xsk_load_xdp_programs()
2036 static void xsk_unload_xdp_programs(struct ifobject *ifobj) in xsk_unload_xdp_programs() argument
2038 xsk_xdp_progs__destroy(ifobj->xdp_progs); in xsk_unload_xdp_programs()
2057 static void init_iface(struct ifobject *ifobj, const char *dst_mac, const char *src_mac, in init_iface() argument
2063 memcpy(ifobj->dst_mac, dst_mac, ETH_ALEN); in init_iface()
2064 memcpy(ifobj->src_mac, src_mac, ETH_ALEN); in init_iface()
2066 ifobj->func_ptr = func_ptr; in init_iface()
2068 err = xsk_load_xdp_programs(ifobj); in init_iface()
2075 ifobj->unaligned_supp = true; in init_iface()
2077 err = bpf_xdp_query(ifobj->ifindex, XDP_FLAGS_DRV_MODE, &query_opts); in init_iface()
2083 ifobj->multi_buff_supp = true; in init_iface()
2086 ifobj->multi_buff_zc_supp = true; in init_iface()
2087 ifobj->xdp_zc_max_segs = query_opts.xdp_zc_max_segs; in init_iface()
2089 ifobj->xdp_zc_max_segs = 0; in init_iface()
2235 struct ifobject *ifobj; in ifobject_create() local
2237 ifobj = calloc(1, sizeof(struct ifobject)); in ifobject_create()
2238 if (!ifobj) in ifobject_create()
2241 ifobj->xsk_arr = calloc(MAX_SOCKETS, sizeof(*ifobj->xsk_arr)); in ifobject_create()
2242 if (!ifobj->xsk_arr) in ifobject_create()
2245 ifobj->umem = calloc(1, sizeof(*ifobj->umem)); in ifobject_create()
2246 if (!ifobj->umem) in ifobject_create()
2249 return ifobj; in ifobject_create()
2252 free(ifobj->xsk_arr); in ifobject_create()
2254 free(ifobj); in ifobject_create()
2258 static void ifobject_delete(struct ifobject *ifobj) in ifobject_delete() argument
2260 free(ifobj->umem); in ifobject_delete()
2261 free(ifobj->xsk_arr); in ifobject_delete()
2262 free(ifobj); in ifobject_delete()