Lines Matching refs:test
129 #define busy_poll_string(test) (test)->ifobj_tx->busy_poll ? "BUSY-POLL " : "" argument
130 static char *mode_string(struct test_spec *test) in mode_string() argument
132 switch (test->mode) { in mode_string()
144 static void report_failure(struct test_spec *test) in report_failure() argument
146 if (test->fail) in report_failure()
149 ksft_test_result_fail("FAIL: %s %s%s\n", mode_string(test), busy_poll_string(test), in report_failure()
150 test->name); in report_failure()
151 test->fail = true; in report_failure()
476 static void __test_spec_init(struct test_spec *test, struct ifobject *ifobj_tx, in __test_spec_init() argument
508 ifobj->xsk_arr[j].pkt_stream = test->tx_pkt_stream_default; in __test_spec_init()
510 ifobj->xsk_arr[j].pkt_stream = test->rx_pkt_stream_default; in __test_spec_init()
522 test->ifobj_tx = ifobj_tx; in __test_spec_init()
523 test->ifobj_rx = ifobj_rx; in __test_spec_init()
524 test->current_step = 0; in __test_spec_init()
525 test->total_steps = 1; in __test_spec_init()
526 test->nb_sockets = 1; in __test_spec_init()
527 test->fail = false; in __test_spec_init()
528 test->set_ring = false; in __test_spec_init()
529 test->adjust_tail = false; in __test_spec_init()
530 test->adjust_tail_support = false; in __test_spec_init()
531 test->mtu = MAX_ETH_PKT_SIZE; in __test_spec_init()
532 test->xdp_prog_rx = ifobj_rx->xdp_progs->progs.xsk_def_prog; in __test_spec_init()
533 test->xskmap_rx = ifobj_rx->xdp_progs->maps.xsk; in __test_spec_init()
534 test->xdp_prog_tx = ifobj_tx->xdp_progs->progs.xsk_def_prog; in __test_spec_init()
535 test->xskmap_tx = ifobj_tx->xdp_progs->maps.xsk; in __test_spec_init()
538 static void test_spec_init(struct test_spec *test, struct ifobject *ifobj_tx, in test_spec_init() argument
546 tx_pkt_stream = test->tx_pkt_stream_default; in test_spec_init()
547 rx_pkt_stream = test->rx_pkt_stream_default; in test_spec_init()
548 memset(test, 0, sizeof(*test)); in test_spec_init()
549 test->tx_pkt_stream_default = tx_pkt_stream; in test_spec_init()
550 test->rx_pkt_stream_default = rx_pkt_stream; in test_spec_init()
562 strncpy(test->name, test_to_run->name, MAX_TEST_NAME_SIZE); in test_spec_init()
563 test->test_func = test_to_run->test_func; in test_spec_init()
564 test->mode = mode; in test_spec_init()
565 __test_spec_init(test, ifobj_tx, ifobj_rx); in test_spec_init()
568 static void test_spec_reset(struct test_spec *test) in test_spec_reset() argument
570 __test_spec_init(test, test->ifobj_tx, test->ifobj_rx); in test_spec_reset()
573 static void test_spec_set_xdp_prog(struct test_spec *test, struct bpf_program *xdp_prog_rx, in test_spec_set_xdp_prog() argument
577 test->xdp_prog_rx = xdp_prog_rx; in test_spec_set_xdp_prog()
578 test->xdp_prog_tx = xdp_prog_tx; in test_spec_set_xdp_prog()
579 test->xskmap_rx = xskmap_rx; in test_spec_set_xdp_prog()
580 test->xskmap_tx = xskmap_tx; in test_spec_set_xdp_prog()
583 static int test_spec_set_mtu(struct test_spec *test, int mtu) in test_spec_set_mtu() argument
587 if (test->ifobj_rx->mtu != mtu) { in test_spec_set_mtu()
588 err = xsk_set_mtu(test->ifobj_rx->ifindex, mtu); in test_spec_set_mtu()
591 test->ifobj_rx->mtu = mtu; in test_spec_set_mtu()
593 if (test->ifobj_tx->mtu != mtu) { in test_spec_set_mtu()
594 err = xsk_set_mtu(test->ifobj_tx->ifindex, mtu); in test_spec_set_mtu()
597 test->ifobj_tx->mtu = mtu; in test_spec_set_mtu()
636 static void pkt_stream_restore_default(struct test_spec *test) in pkt_stream_restore_default() argument
638 struct pkt_stream *tx_pkt_stream = test->ifobj_tx->xsk->pkt_stream; in pkt_stream_restore_default()
639 struct pkt_stream *rx_pkt_stream = test->ifobj_rx->xsk->pkt_stream; in pkt_stream_restore_default()
641 if (tx_pkt_stream != test->tx_pkt_stream_default) { in pkt_stream_restore_default()
642 pkt_stream_delete(test->ifobj_tx->xsk->pkt_stream); in pkt_stream_restore_default()
643 test->ifobj_tx->xsk->pkt_stream = test->tx_pkt_stream_default; in pkt_stream_restore_default()
646 if (rx_pkt_stream != test->rx_pkt_stream_default) { in pkt_stream_restore_default()
647 pkt_stream_delete(test->ifobj_rx->xsk->pkt_stream); in pkt_stream_restore_default()
648 test->ifobj_rx->xsk->pkt_stream = test->rx_pkt_stream_default; in pkt_stream_restore_default()
769 static void pkt_stream_replace(struct test_spec *test, u32 nb_pkts, u32 pkt_len) in pkt_stream_replace() argument
771 pkt_stream_replace_ifobject(test->ifobj_tx, nb_pkts, pkt_len); in pkt_stream_replace()
772 pkt_stream_replace_ifobject(test->ifobj_rx, nb_pkts, pkt_len); in pkt_stream_replace()
788 static void pkt_stream_replace_half(struct test_spec *test, u32 pkt_len, int offset) in pkt_stream_replace_half() argument
790 __pkt_stream_replace_half(test->ifobj_tx, pkt_len, offset); in pkt_stream_replace_half()
791 __pkt_stream_replace_half(test->ifobj_rx, pkt_len, offset); in pkt_stream_replace_half()
794 static void pkt_stream_receive_half(struct test_spec *test) in pkt_stream_receive_half() argument
796 struct pkt_stream *pkt_stream = test->ifobj_tx->xsk->pkt_stream; in pkt_stream_receive_half()
799 test->ifobj_rx->xsk->pkt_stream = pkt_stream_generate(pkt_stream->nb_pkts, in pkt_stream_receive_half()
801 pkt_stream = test->ifobj_rx->xsk->pkt_stream; in pkt_stream_receive_half()
808 static void pkt_stream_even_odd_sequence(struct test_spec *test) in pkt_stream_even_odd_sequence() argument
813 for (i = 0; i < test->nb_sockets; i++) { in pkt_stream_even_odd_sequence()
814 pkt_stream = test->ifobj_tx->xsk_arr[i].pkt_stream; in pkt_stream_even_odd_sequence()
817 test->ifobj_tx->xsk_arr[i].pkt_stream = pkt_stream; in pkt_stream_even_odd_sequence()
819 pkt_stream = test->ifobj_rx->xsk_arr[i].pkt_stream; in pkt_stream_even_odd_sequence()
822 test->ifobj_rx->xsk_arr[i].pkt_stream = pkt_stream; in pkt_stream_even_odd_sequence()
909 static void pkt_stream_generate_custom(struct test_spec *test, struct pkt *pkts, u32 nb_pkts) in pkt_stream_generate_custom() argument
913 pkt_stream = __pkt_stream_generate_custom(test->ifobj_tx, pkts, nb_pkts, true); in pkt_stream_generate_custom()
914 test->ifobj_tx->xsk->pkt_stream = pkt_stream; in pkt_stream_generate_custom()
916 pkt_stream = __pkt_stream_generate_custom(test->ifobj_rx, pkts, nb_pkts, false); in pkt_stream_generate_custom()
917 test->ifobj_rx->xsk->pkt_stream = pkt_stream; in pkt_stream_generate_custom()
1185 static int __receive_pkts(struct test_spec *test, struct xsk_socket_info *xsk) in __receive_pkts() argument
1190 struct ifobject *ifobj = test->ifobj_rx; in __receive_pkts()
1210 if (!is_umem_valid(test->ifobj_tx)) in __receive_pkts()
1305 bool all_packets_received(struct test_spec *test, struct xsk_socket_info *xsk, u32 sock_num, in all_packets_received() argument
1317 if (bitmap_full(bitmap, test->nb_sockets)) in all_packets_received()
1324 static int receive_pkts(struct test_spec *test) in receive_pkts() argument
1327 DECLARE_BITMAP(bitmap, test->nb_sockets); in receive_pkts()
1339 xsk = &test->ifobj_rx->xsk_arr[sock_num]; in receive_pkts()
1341 if ((all_packets_received(test, xsk, sock_num, bitmap))) in receive_pkts()
1344 res = __receive_pkts(test, xsk); in receive_pkts()
1356 sock_num = (sock_num + 1) % test->nb_sockets; in receive_pkts()
1511 bool all_packets_sent(struct test_spec *test, unsigned long *bitmap) in all_packets_sent() argument
1513 return bitmap_full(bitmap, test->nb_sockets); in all_packets_sent()
1516 static int send_pkts(struct test_spec *test, struct ifobject *ifobject) in send_pkts() argument
1518 bool timeout = !is_umem_valid(test->ifobj_rx); in send_pkts()
1519 DECLARE_BITMAP(bitmap, test->nb_sockets); in send_pkts()
1522 while (!(all_packets_sent(test, bitmap))) { in send_pkts()
1523 for (i = 0; i < test->nb_sockets; i++) { in send_pkts()
1532 if (ret == TEST_CONTINUE && !test->fail) in send_pkts()
1535 if ((ret || test->fail) && !timeout) in send_pkts()
1669 static void xsk_configure_socket(struct test_spec *test, struct ifobject *ifobject, in xsk_configure_socket() argument
1674 for (i = 0; i < test->nb_sockets; i++) { in xsk_configure_socket()
1694 static void thread_common_ops_tx(struct test_spec *test, struct ifobject *ifobject) in thread_common_ops_tx() argument
1696 xsk_configure_socket(test, ifobject, test->ifobj_rx->umem, true); in thread_common_ops_tx()
1698 ifobject->xskmap = test->ifobj_rx->xskmap; in thread_common_ops_tx()
1699 memcpy(ifobject->umem, test->ifobj_rx->umem, sizeof(struct xsk_umem_info)); in thread_common_ops_tx()
1747 static void thread_common_ops(struct test_spec *test, struct ifobject *ifobject) in thread_common_ops() argument
1770 xsk_configure_socket(test, ifobject, ifobject->umem, false); in thread_common_ops()
1779 for (i = 0; i < test->nb_sockets; i++) { in thread_common_ops()
1789 struct test_spec *test = (struct test_spec *)arg; in worker_testapp_validate_tx() local
1790 struct ifobject *ifobject = test->ifobj_tx; in worker_testapp_validate_tx()
1793 if (test->current_step == 1) { in worker_testapp_validate_tx()
1795 thread_common_ops(test, ifobject); in worker_testapp_validate_tx()
1797 thread_common_ops_tx(test, ifobject); in worker_testapp_validate_tx()
1800 err = send_pkts(test, ifobject); in worker_testapp_validate_tx()
1805 report_failure(test); in worker_testapp_validate_tx()
1812 struct test_spec *test = (struct test_spec *)arg; in worker_testapp_validate_rx() local
1813 struct ifobject *ifobject = test->ifobj_rx; in worker_testapp_validate_rx()
1816 if (test->current_step == 1) { in worker_testapp_validate_rx()
1817 thread_common_ops(test, ifobject); in worker_testapp_validate_rx()
1830 err = receive_pkts(test); in worker_testapp_validate_rx()
1836 if (test->adjust_tail && !is_adjust_tail_supported(ifobject->xdp_progs)) in worker_testapp_validate_rx()
1837 test->adjust_tail_support = false; in worker_testapp_validate_rx()
1839 report_failure(test); in worker_testapp_validate_rx()
1867 static bool xdp_prog_changed_rx(struct test_spec *test) in xdp_prog_changed_rx() argument
1869 struct ifobject *ifobj = test->ifobj_rx; in xdp_prog_changed_rx()
1871 return ifobj->xdp_prog != test->xdp_prog_rx || ifobj->mode != test->mode; in xdp_prog_changed_rx()
1874 static bool xdp_prog_changed_tx(struct test_spec *test) in xdp_prog_changed_tx() argument
1876 struct ifobject *ifobj = test->ifobj_tx; in xdp_prog_changed_tx()
1878 return ifobj->xdp_prog != test->xdp_prog_tx || ifobj->mode != test->mode; in xdp_prog_changed_tx()
1904 static void xsk_attach_xdp_progs(struct test_spec *test, struct ifobject *ifobj_rx, in xsk_attach_xdp_progs() argument
1907 if (xdp_prog_changed_rx(test)) in xsk_attach_xdp_progs()
1908 xsk_reattach_xdp(ifobj_rx, test->xdp_prog_rx, test->xskmap_rx, test->mode); in xsk_attach_xdp_progs()
1913 if (xdp_prog_changed_tx(test)) in xsk_attach_xdp_progs()
1914 xsk_reattach_xdp(ifobj_tx, test->xdp_prog_tx, test->xskmap_tx, test->mode); in xsk_attach_xdp_progs()
1917 static int __testapp_validate_traffic(struct test_spec *test, struct ifobject *ifobj1, in __testapp_validate_traffic() argument
1923 if (test->mtu > MAX_ETH_PKT_SIZE) { in __testapp_validate_traffic()
1924 if (test->mode == TEST_MODE_ZC && (!ifobj1->multi_buff_zc_supp || in __testapp_validate_traffic()
1929 if (test->mode != TEST_MODE_ZC && (!ifobj1->multi_buff_supp || in __testapp_validate_traffic()
1935 err = test_spec_set_mtu(test, test->mtu); in __testapp_validate_traffic()
1947 test->current_step++; in __testapp_validate_traffic()
1953 pthread_create(&t0, NULL, ifobj1->func_ptr, test); in __testapp_validate_traffic()
1961 pthread_create(&t1, NULL, ifobj2->func_ptr, test); in __testapp_validate_traffic()
1971 if (test->total_steps == test->current_step || test->fail) { in __testapp_validate_traffic()
1975 for (i = 0; i < test->nb_sockets; i++) in __testapp_validate_traffic()
1978 for (i = 0; i < test->nb_sockets; i++) in __testapp_validate_traffic()
1986 return !!test->fail; in __testapp_validate_traffic()
1989 static int testapp_validate_traffic(struct test_spec *test) in testapp_validate_traffic() argument
1991 struct ifobject *ifobj_rx = test->ifobj_rx; in testapp_validate_traffic()
1992 struct ifobject *ifobj_tx = test->ifobj_tx; in testapp_validate_traffic()
2000 if (test->set_ring) { in testapp_validate_traffic()
2012 xsk_attach_xdp_progs(test, ifobj_rx, ifobj_tx); in testapp_validate_traffic()
2013 return __testapp_validate_traffic(test, ifobj_rx, ifobj_tx); in testapp_validate_traffic()
2016 static int testapp_validate_traffic_single_thread(struct test_spec *test, struct ifobject *ifobj) in testapp_validate_traffic_single_thread() argument
2018 return __testapp_validate_traffic(test, ifobj, NULL); in testapp_validate_traffic_single_thread()
2021 static int testapp_teardown(struct test_spec *test) in testapp_teardown() argument
2026 if (testapp_validate_traffic(test)) in testapp_teardown()
2028 test_spec_reset(test); in testapp_teardown()
2046 static int testapp_bidirectional(struct test_spec *test) in testapp_bidirectional() argument
2050 test->ifobj_tx->rx_on = true; in testapp_bidirectional()
2051 test->ifobj_rx->tx_on = true; in testapp_bidirectional()
2052 test->total_steps = 2; in testapp_bidirectional()
2053 if (testapp_validate_traffic(test)) in testapp_bidirectional()
2057 swap_directions(&test->ifobj_rx, &test->ifobj_tx); in testapp_bidirectional()
2058 res = __testapp_validate_traffic(test, test->ifobj_rx, test->ifobj_tx); in testapp_bidirectional()
2060 swap_directions(&test->ifobj_rx, &test->ifobj_tx); in testapp_bidirectional()
2064 static int swap_xsk_resources(struct test_spec *test) in swap_xsk_resources() argument
2068 test->ifobj_tx->xsk_arr[0].pkt_stream = NULL; in swap_xsk_resources()
2069 test->ifobj_rx->xsk_arr[0].pkt_stream = NULL; in swap_xsk_resources()
2070 test->ifobj_tx->xsk_arr[1].pkt_stream = test->tx_pkt_stream_default; in swap_xsk_resources()
2071 test->ifobj_rx->xsk_arr[1].pkt_stream = test->rx_pkt_stream_default; in swap_xsk_resources()
2072 test->ifobj_tx->xsk = &test->ifobj_tx->xsk_arr[1]; in swap_xsk_resources()
2073 test->ifobj_rx->xsk = &test->ifobj_rx->xsk_arr[1]; in swap_xsk_resources()
2075 ret = xsk_update_xskmap(test->ifobj_rx->xskmap, test->ifobj_rx->xsk->xsk, 0); in swap_xsk_resources()
2082 static int testapp_xdp_prog_cleanup(struct test_spec *test) in testapp_xdp_prog_cleanup() argument
2084 test->total_steps = 2; in testapp_xdp_prog_cleanup()
2085 test->nb_sockets = 2; in testapp_xdp_prog_cleanup()
2086 if (testapp_validate_traffic(test)) in testapp_xdp_prog_cleanup()
2089 if (swap_xsk_resources(test)) in testapp_xdp_prog_cleanup()
2091 return testapp_validate_traffic(test); in testapp_xdp_prog_cleanup()
2094 static int testapp_headroom(struct test_spec *test) in testapp_headroom() argument
2096 test->ifobj_rx->umem->frame_headroom = UMEM_HEADROOM_TEST_SIZE; in testapp_headroom()
2097 return testapp_validate_traffic(test); in testapp_headroom()
2100 static int testapp_stats_rx_dropped(struct test_spec *test) in testapp_stats_rx_dropped() argument
2102 if (test->mode == TEST_MODE_ZC) { in testapp_stats_rx_dropped()
2107 pkt_stream_replace_half(test, MIN_PKT_SIZE * 4, 0); in testapp_stats_rx_dropped()
2108 test->ifobj_rx->umem->frame_headroom = test->ifobj_rx->umem->frame_size - in testapp_stats_rx_dropped()
2110 pkt_stream_receive_half(test); in testapp_stats_rx_dropped()
2111 test->ifobj_rx->validation_func = validate_rx_dropped; in testapp_stats_rx_dropped()
2112 return testapp_validate_traffic(test); in testapp_stats_rx_dropped()
2115 static int testapp_stats_tx_invalid_descs(struct test_spec *test) in testapp_stats_tx_invalid_descs() argument
2117 pkt_stream_replace_half(test, XSK_UMEM__INVALID_FRAME_SIZE, 0); in testapp_stats_tx_invalid_descs()
2118 test->ifobj_tx->validation_func = validate_tx_invalid_descs; in testapp_stats_tx_invalid_descs()
2119 return testapp_validate_traffic(test); in testapp_stats_tx_invalid_descs()
2122 static int testapp_stats_rx_full(struct test_spec *test) in testapp_stats_rx_full() argument
2124 pkt_stream_replace(test, DEFAULT_UMEM_BUFFERS + DEFAULT_UMEM_BUFFERS / 2, MIN_PKT_SIZE); in testapp_stats_rx_full()
2125 test->ifobj_rx->xsk->pkt_stream = pkt_stream_generate(DEFAULT_UMEM_BUFFERS, MIN_PKT_SIZE); in testapp_stats_rx_full()
2127 test->ifobj_rx->xsk->rxqsize = DEFAULT_UMEM_BUFFERS; in testapp_stats_rx_full()
2128 test->ifobj_rx->release_rx = false; in testapp_stats_rx_full()
2129 test->ifobj_rx->validation_func = validate_rx_full; in testapp_stats_rx_full()
2130 return testapp_validate_traffic(test); in testapp_stats_rx_full()
2133 static int testapp_stats_fill_empty(struct test_spec *test) in testapp_stats_fill_empty() argument
2135 pkt_stream_replace(test, DEFAULT_UMEM_BUFFERS + DEFAULT_UMEM_BUFFERS / 2, MIN_PKT_SIZE); in testapp_stats_fill_empty()
2136 test->ifobj_rx->xsk->pkt_stream = pkt_stream_generate(DEFAULT_UMEM_BUFFERS, MIN_PKT_SIZE); in testapp_stats_fill_empty()
2138 test->ifobj_rx->use_fill_ring = false; in testapp_stats_fill_empty()
2139 test->ifobj_rx->validation_func = validate_fill_empty; in testapp_stats_fill_empty()
2140 return testapp_validate_traffic(test); in testapp_stats_fill_empty()
2143 static int testapp_send_receive_unaligned(struct test_spec *test) in testapp_send_receive_unaligned() argument
2145 test->ifobj_tx->umem->unaligned_mode = true; in testapp_send_receive_unaligned()
2146 test->ifobj_rx->umem->unaligned_mode = true; in testapp_send_receive_unaligned()
2148 pkt_stream_replace_half(test, MIN_PKT_SIZE, -MIN_PKT_SIZE / 2); in testapp_send_receive_unaligned()
2150 return testapp_validate_traffic(test); in testapp_send_receive_unaligned()
2153 static int testapp_send_receive_unaligned_mb(struct test_spec *test) in testapp_send_receive_unaligned_mb() argument
2155 test->mtu = MAX_ETH_JUMBO_SIZE; in testapp_send_receive_unaligned_mb()
2156 test->ifobj_tx->umem->unaligned_mode = true; in testapp_send_receive_unaligned_mb()
2157 test->ifobj_rx->umem->unaligned_mode = true; in testapp_send_receive_unaligned_mb()
2158 pkt_stream_replace(test, DEFAULT_PKT_CNT, MAX_ETH_JUMBO_SIZE); in testapp_send_receive_unaligned_mb()
2159 return testapp_validate_traffic(test); in testapp_send_receive_unaligned_mb()
2162 static int testapp_single_pkt(struct test_spec *test) in testapp_single_pkt() argument
2166 pkt_stream_generate_custom(test, pkts, ARRAY_SIZE(pkts)); in testapp_single_pkt()
2167 return testapp_validate_traffic(test); in testapp_single_pkt()
2170 static int testapp_send_receive_mb(struct test_spec *test) in testapp_send_receive_mb() argument
2172 test->mtu = MAX_ETH_JUMBO_SIZE; in testapp_send_receive_mb()
2173 pkt_stream_replace(test, DEFAULT_PKT_CNT, MAX_ETH_JUMBO_SIZE); in testapp_send_receive_mb()
2175 return testapp_validate_traffic(test); in testapp_send_receive_mb()
2178 static int testapp_invalid_desc_mb(struct test_spec *test) in testapp_invalid_desc_mb() argument
2180 struct xsk_umem_info *umem = test->ifobj_tx->umem; in testapp_invalid_desc_mb()
2213 test->mtu = MAX_ETH_JUMBO_SIZE; in testapp_invalid_desc_mb()
2214 pkt_stream_generate_custom(test, pkts, ARRAY_SIZE(pkts)); in testapp_invalid_desc_mb()
2215 return testapp_validate_traffic(test); in testapp_invalid_desc_mb()
2218 static int testapp_invalid_desc(struct test_spec *test) in testapp_invalid_desc() argument
2220 struct xsk_umem_info *umem = test->ifobj_tx->umem; in testapp_invalid_desc()
2253 if (test->ifobj_tx->shared_umem) { in testapp_invalid_desc()
2259 pkt_stream_generate_custom(test, pkts, ARRAY_SIZE(pkts)); in testapp_invalid_desc()
2260 return testapp_validate_traffic(test); in testapp_invalid_desc()
2263 static int testapp_xdp_drop(struct test_spec *test) in testapp_xdp_drop() argument
2265 struct xsk_xdp_progs *skel_rx = test->ifobj_rx->xdp_progs; in testapp_xdp_drop()
2266 struct xsk_xdp_progs *skel_tx = test->ifobj_tx->xdp_progs; in testapp_xdp_drop()
2268 test_spec_set_xdp_prog(test, skel_rx->progs.xsk_xdp_drop, skel_tx->progs.xsk_xdp_drop, in testapp_xdp_drop()
2271 pkt_stream_receive_half(test); in testapp_xdp_drop()
2272 return testapp_validate_traffic(test); in testapp_xdp_drop()
2275 static int testapp_xdp_metadata_copy(struct test_spec *test) in testapp_xdp_metadata_copy() argument
2277 struct xsk_xdp_progs *skel_rx = test->ifobj_rx->xdp_progs; in testapp_xdp_metadata_copy()
2278 struct xsk_xdp_progs *skel_tx = test->ifobj_tx->xdp_progs; in testapp_xdp_metadata_copy()
2283 test_spec_set_xdp_prog(test, skel_rx->progs.xsk_xdp_populate_metadata, in testapp_xdp_metadata_copy()
2286 test->ifobj_rx->use_metadata = true; in testapp_xdp_metadata_copy()
2299 return testapp_validate_traffic(test); in testapp_xdp_metadata_copy()
2302 static int testapp_xdp_shared_umem(struct test_spec *test) in testapp_xdp_shared_umem() argument
2304 struct xsk_xdp_progs *skel_rx = test->ifobj_rx->xdp_progs; in testapp_xdp_shared_umem()
2305 struct xsk_xdp_progs *skel_tx = test->ifobj_tx->xdp_progs; in testapp_xdp_shared_umem()
2307 test->total_steps = 1; in testapp_xdp_shared_umem()
2308 test->nb_sockets = 2; in testapp_xdp_shared_umem()
2310 test_spec_set_xdp_prog(test, skel_rx->progs.xsk_xdp_shared_umem, in testapp_xdp_shared_umem()
2314 pkt_stream_even_odd_sequence(test); in testapp_xdp_shared_umem()
2316 return testapp_validate_traffic(test); in testapp_xdp_shared_umem()
2319 static int testapp_poll_txq_tmout(struct test_spec *test) in testapp_poll_txq_tmout() argument
2321 test->ifobj_tx->use_poll = true; in testapp_poll_txq_tmout()
2323 test->ifobj_tx->umem->frame_size = 2048; in testapp_poll_txq_tmout()
2324 pkt_stream_replace(test, 2 * DEFAULT_PKT_CNT, 2048); in testapp_poll_txq_tmout()
2325 return testapp_validate_traffic_single_thread(test, test->ifobj_tx); in testapp_poll_txq_tmout()
2328 static int testapp_poll_rxq_tmout(struct test_spec *test) in testapp_poll_rxq_tmout() argument
2330 test->ifobj_rx->use_poll = true; in testapp_poll_rxq_tmout()
2331 return testapp_validate_traffic_single_thread(test, test->ifobj_rx); in testapp_poll_rxq_tmout()
2334 static int testapp_too_many_frags(struct test_spec *test) in testapp_too_many_frags() argument
2340 if (test->mode == TEST_MODE_ZC) { in testapp_too_many_frags()
2341 max_frags = test->ifobj_tx->xdp_zc_max_segs; in testapp_too_many_frags()
2355 test->mtu = MAX_ETH_JUMBO_SIZE; in testapp_too_many_frags()
2382 pkt_stream_generate_custom(test, pkts, 2 * max_frags + 2); in testapp_too_many_frags()
2383 ret = testapp_validate_traffic(test); in testapp_too_many_frags()
2452 static int testapp_send_receive(struct test_spec *test) in testapp_send_receive() argument
2454 return testapp_validate_traffic(test); in testapp_send_receive()
2457 static int testapp_send_receive_2k_frame(struct test_spec *test) in testapp_send_receive_2k_frame() argument
2459 test->ifobj_tx->umem->frame_size = 2048; in testapp_send_receive_2k_frame()
2460 test->ifobj_rx->umem->frame_size = 2048; in testapp_send_receive_2k_frame()
2461 pkt_stream_replace(test, DEFAULT_PKT_CNT, MIN_PKT_SIZE); in testapp_send_receive_2k_frame()
2462 return testapp_validate_traffic(test); in testapp_send_receive_2k_frame()
2465 static int testapp_poll_rx(struct test_spec *test) in testapp_poll_rx() argument
2467 test->ifobj_rx->use_poll = true; in testapp_poll_rx()
2468 return testapp_validate_traffic(test); in testapp_poll_rx()
2471 static int testapp_poll_tx(struct test_spec *test) in testapp_poll_tx() argument
2473 test->ifobj_tx->use_poll = true; in testapp_poll_tx()
2474 return testapp_validate_traffic(test); in testapp_poll_tx()
2477 static int testapp_aligned_inv_desc(struct test_spec *test) in testapp_aligned_inv_desc() argument
2479 return testapp_invalid_desc(test); in testapp_aligned_inv_desc()
2482 static int testapp_aligned_inv_desc_2k_frame(struct test_spec *test) in testapp_aligned_inv_desc_2k_frame() argument
2484 test->ifobj_tx->umem->frame_size = 2048; in testapp_aligned_inv_desc_2k_frame()
2485 test->ifobj_rx->umem->frame_size = 2048; in testapp_aligned_inv_desc_2k_frame()
2486 return testapp_invalid_desc(test); in testapp_aligned_inv_desc_2k_frame()
2489 static int testapp_unaligned_inv_desc(struct test_spec *test) in testapp_unaligned_inv_desc() argument
2491 test->ifobj_tx->umem->unaligned_mode = true; in testapp_unaligned_inv_desc()
2492 test->ifobj_rx->umem->unaligned_mode = true; in testapp_unaligned_inv_desc()
2493 return testapp_invalid_desc(test); in testapp_unaligned_inv_desc()
2496 static int testapp_unaligned_inv_desc_4001_frame(struct test_spec *test) in testapp_unaligned_inv_desc_4001_frame() argument
2501 test->ifobj_tx->umem->frame_size = 4001; in testapp_unaligned_inv_desc_4001_frame()
2502 test->ifobj_rx->umem->frame_size = 4001; in testapp_unaligned_inv_desc_4001_frame()
2503 test->ifobj_tx->umem->unaligned_mode = true; in testapp_unaligned_inv_desc_4001_frame()
2504 test->ifobj_rx->umem->unaligned_mode = true; in testapp_unaligned_inv_desc_4001_frame()
2509 umem_size = test->ifobj_tx->umem->num_frames * test->ifobj_tx->umem->frame_size; in testapp_unaligned_inv_desc_4001_frame()
2513 return testapp_invalid_desc(test); in testapp_unaligned_inv_desc_4001_frame()
2516 static int testapp_aligned_inv_desc_mb(struct test_spec *test) in testapp_aligned_inv_desc_mb() argument
2518 return testapp_invalid_desc_mb(test); in testapp_aligned_inv_desc_mb()
2521 static int testapp_unaligned_inv_desc_mb(struct test_spec *test) in testapp_unaligned_inv_desc_mb() argument
2523 test->ifobj_tx->umem->unaligned_mode = true; in testapp_unaligned_inv_desc_mb()
2524 test->ifobj_rx->umem->unaligned_mode = true; in testapp_unaligned_inv_desc_mb()
2525 return testapp_invalid_desc_mb(test); in testapp_unaligned_inv_desc_mb()
2528 static int testapp_xdp_metadata(struct test_spec *test) in testapp_xdp_metadata() argument
2530 return testapp_xdp_metadata_copy(test); in testapp_xdp_metadata()
2533 static int testapp_xdp_metadata_mb(struct test_spec *test) in testapp_xdp_metadata_mb() argument
2535 test->mtu = MAX_ETH_JUMBO_SIZE; in testapp_xdp_metadata_mb()
2536 return testapp_xdp_metadata_copy(test); in testapp_xdp_metadata_mb()
2539 static int testapp_hw_sw_min_ring_size(struct test_spec *test) in testapp_hw_sw_min_ring_size() argument
2543 test->set_ring = true; in testapp_hw_sw_min_ring_size()
2544 test->total_steps = 2; in testapp_hw_sw_min_ring_size()
2545 test->ifobj_tx->ring.tx_pending = DEFAULT_BATCH_SIZE; in testapp_hw_sw_min_ring_size()
2546 test->ifobj_tx->ring.rx_pending = DEFAULT_BATCH_SIZE * 2; in testapp_hw_sw_min_ring_size()
2547 test->ifobj_tx->xsk->batch_size = 1; in testapp_hw_sw_min_ring_size()
2548 test->ifobj_rx->xsk->batch_size = 1; in testapp_hw_sw_min_ring_size()
2549 ret = testapp_validate_traffic(test); in testapp_hw_sw_min_ring_size()
2554 test->ifobj_tx->xsk->batch_size = DEFAULT_BATCH_SIZE - 1; in testapp_hw_sw_min_ring_size()
2555 test->ifobj_rx->xsk->batch_size = DEFAULT_BATCH_SIZE - 1; in testapp_hw_sw_min_ring_size()
2556 return testapp_validate_traffic(test); in testapp_hw_sw_min_ring_size()
2559 static int testapp_hw_sw_max_ring_size(struct test_spec *test) in testapp_hw_sw_max_ring_size() argument
2564 test->set_ring = true; in testapp_hw_sw_max_ring_size()
2565 test->total_steps = 2; in testapp_hw_sw_max_ring_size()
2566 test->ifobj_tx->ring.tx_pending = test->ifobj_tx->ring.tx_max_pending; in testapp_hw_sw_max_ring_size()
2567 test->ifobj_tx->ring.rx_pending = test->ifobj_tx->ring.rx_max_pending; in testapp_hw_sw_max_ring_size()
2568 test->ifobj_rx->umem->num_frames = max_descs; in testapp_hw_sw_max_ring_size()
2569 test->ifobj_rx->umem->fill_size = max_descs; in testapp_hw_sw_max_ring_size()
2570 test->ifobj_rx->umem->comp_size = max_descs; in testapp_hw_sw_max_ring_size()
2571 test->ifobj_tx->xsk->batch_size = XSK_RING_PROD__DEFAULT_NUM_DESCS; in testapp_hw_sw_max_ring_size()
2572 test->ifobj_rx->xsk->batch_size = XSK_RING_PROD__DEFAULT_NUM_DESCS; in testapp_hw_sw_max_ring_size()
2574 ret = testapp_validate_traffic(test); in testapp_hw_sw_max_ring_size()
2581 test->ifobj_tx->xsk->batch_size = test->ifobj_tx->ring.tx_max_pending - 8; in testapp_hw_sw_max_ring_size()
2582 test->ifobj_rx->xsk->batch_size = test->ifobj_tx->ring.tx_max_pending - 8; in testapp_hw_sw_max_ring_size()
2583 pkt_stream_replace(test, max_descs, MIN_PKT_SIZE); in testapp_hw_sw_max_ring_size()
2584 return testapp_validate_traffic(test); in testapp_hw_sw_max_ring_size()
2587 static int testapp_xdp_adjust_tail(struct test_spec *test, int adjust_value) in testapp_xdp_adjust_tail() argument
2589 struct xsk_xdp_progs *skel_rx = test->ifobj_rx->xdp_progs; in testapp_xdp_adjust_tail()
2590 struct xsk_xdp_progs *skel_tx = test->ifobj_tx->xdp_progs; in testapp_xdp_adjust_tail()
2592 test_spec_set_xdp_prog(test, skel_rx->progs.xsk_xdp_adjust_tail, in testapp_xdp_adjust_tail()
2598 return testapp_validate_traffic(test); in testapp_xdp_adjust_tail()
2601 static int testapp_adjust_tail(struct test_spec *test, u32 value, u32 pkt_len) in testapp_adjust_tail() argument
2605 test->adjust_tail_support = true; in testapp_adjust_tail()
2606 test->adjust_tail = true; in testapp_adjust_tail()
2607 test->total_steps = 1; in testapp_adjust_tail()
2609 pkt_stream_replace_ifobject(test->ifobj_tx, DEFAULT_BATCH_SIZE, pkt_len); in testapp_adjust_tail()
2610 pkt_stream_replace_ifobject(test->ifobj_rx, DEFAULT_BATCH_SIZE, pkt_len + value); in testapp_adjust_tail()
2612 ret = testapp_xdp_adjust_tail(test, value); in testapp_adjust_tail()
2616 if (!test->adjust_tail_support) { in testapp_adjust_tail()
2618 mode_string(test), busy_poll_string(test)); in testapp_adjust_tail()
2625 static int testapp_adjust_tail_shrink(struct test_spec *test) in testapp_adjust_tail_shrink() argument
2628 return testapp_adjust_tail(test, -4, MIN_PKT_SIZE * 2); in testapp_adjust_tail_shrink()
2631 static int testapp_adjust_tail_shrink_mb(struct test_spec *test) in testapp_adjust_tail_shrink_mb() argument
2633 test->mtu = MAX_ETH_JUMBO_SIZE; in testapp_adjust_tail_shrink_mb()
2635 return testapp_adjust_tail(test, -XSK_UMEM__MAX_FRAME_SIZE, XSK_UMEM__LARGE_FRAME_SIZE * 2); in testapp_adjust_tail_shrink_mb()
2638 static int testapp_adjust_tail_grow(struct test_spec *test) in testapp_adjust_tail_grow() argument
2641 return testapp_adjust_tail(test, 4, MIN_PKT_SIZE * 2); in testapp_adjust_tail_grow()
2644 static int testapp_adjust_tail_grow_mb(struct test_spec *test) in testapp_adjust_tail_grow_mb() argument
2646 test->mtu = MAX_ETH_JUMBO_SIZE; in testapp_adjust_tail_grow_mb()
2648 return testapp_adjust_tail(test, (XSK_UMEM__MAX_FRAME_SIZE / 2) - 1, in testapp_adjust_tail_grow_mb()
2652 static int testapp_tx_queue_consumer(struct test_spec *test) in testapp_tx_queue_consumer() argument
2656 if (test->mode == TEST_MODE_ZC) { in testapp_tx_queue_consumer()
2662 pkt_stream_replace(test, nr_packets, MIN_PKT_SIZE); in testapp_tx_queue_consumer()
2663 test->ifobj_tx->xsk->batch_size = nr_packets; in testapp_tx_queue_consumer()
2664 test->ifobj_tx->xsk->check_consumer = true; in testapp_tx_queue_consumer()
2666 return testapp_validate_traffic(test); in testapp_tx_queue_consumer()
2669 static void run_pkt_test(struct test_spec *test) in run_pkt_test() argument
2673 ret = test->test_func(test); in run_pkt_test()
2676 ksft_test_result_pass("PASS: %s %s%s\n", mode_string(test), busy_poll_string(test), in run_pkt_test()
2677 test->name); in run_pkt_test()
2678 pkt_stream_restore_default(test); in run_pkt_test()
2798 struct test_spec test; in main() local
2848 test_spec_init(&test, ifobj_tx, ifobj_rx, 0, &tests[0]); in main()
2853 test.tx_pkt_stream_default = tx_pkt_stream_default; in main()
2854 test.rx_pkt_stream_default = rx_pkt_stream_default; in main()
2883 test_spec_init(&test, ifobj_tx, ifobj_rx, i, &tests[j]); in main()
2884 run_pkt_test(&test); in main()
2887 if (test.fail) in main()