Lines Matching refs:test
119 #define mode_string(test) (test)->ifobj_tx->xdp_flags & XDP_FLAGS_SKB_MODE ? "SKB" : "DRV" argument
121 #define print_ksft_result(test) \ argument
122 (ksft_test_result_pass("PASS: %s %s\n", mode_string(test), (test)->name))
376 static void __test_spec_init(struct test_spec *test, struct ifobject *ifobj_tx, in __test_spec_init() argument
388 ifobj->pkt_stream = test->pkt_stream_default; in __test_spec_init()
407 test->ifobj_tx = ifobj_tx; in __test_spec_init()
408 test->ifobj_rx = ifobj_rx; in __test_spec_init()
409 test->current_step = 0; in __test_spec_init()
410 test->total_steps = 1; in __test_spec_init()
411 test->nb_sockets = 1; in __test_spec_init()
414 static void test_spec_init(struct test_spec *test, struct ifobject *ifobj_tx, in test_spec_init() argument
420 pkt_stream = test->pkt_stream_default; in test_spec_init()
421 memset(test, 0, sizeof(*test)); in test_spec_init()
422 test->pkt_stream_default = pkt_stream; in test_spec_init()
436 __test_spec_init(test, ifobj_tx, ifobj_rx); in test_spec_init()
439 static void test_spec_reset(struct test_spec *test) in test_spec_reset() argument
441 __test_spec_init(test, test->ifobj_tx, test->ifobj_rx); in test_spec_reset()
444 static void test_spec_set_name(struct test_spec *test, const char *name) in test_spec_set_name() argument
446 strncpy(test->name, name, MAX_TEST_NAME_SIZE); in test_spec_set_name()
479 static void pkt_stream_restore_default(struct test_spec *test) in pkt_stream_restore_default() argument
481 if (test->ifobj_tx->pkt_stream != test->pkt_stream_default) { in pkt_stream_restore_default()
482 pkt_stream_delete(test->ifobj_tx->pkt_stream); in pkt_stream_restore_default()
483 test->ifobj_tx->pkt_stream = test->pkt_stream_default; in pkt_stream_restore_default()
485 test->ifobj_rx->pkt_stream = test->pkt_stream_default; in pkt_stream_restore_default()
536 static void pkt_stream_replace(struct test_spec *test, u32 nb_pkts, u32 pkt_len) in pkt_stream_replace() argument
540 pkt_stream = pkt_stream_generate(test->ifobj_tx->umem, nb_pkts, pkt_len); in pkt_stream_replace()
541 test->ifobj_tx->pkt_stream = pkt_stream; in pkt_stream_replace()
542 test->ifobj_rx->pkt_stream = pkt_stream; in pkt_stream_replace()
545 static void pkt_stream_replace_half(struct test_spec *test, u32 pkt_len, int offset) in pkt_stream_replace_half() argument
547 struct xsk_umem_info *umem = test->ifobj_tx->umem; in pkt_stream_replace_half()
551 pkt_stream = pkt_stream_clone(umem, test->pkt_stream_default); in pkt_stream_replace_half()
552 for (i = 1; i < test->pkt_stream_default->nb_pkts; i += 2) { in pkt_stream_replace_half()
557 test->ifobj_tx->pkt_stream = pkt_stream; in pkt_stream_replace_half()
558 test->ifobj_rx->pkt_stream = pkt_stream; in pkt_stream_replace_half()
587 static void pkt_stream_generate_custom(struct test_spec *test, struct pkt *pkts, u32 nb_pkts) in pkt_stream_generate_custom() argument
596 test->ifobj_tx->pkt_stream = pkt_stream; in pkt_stream_generate_custom()
597 test->ifobj_rx->pkt_stream = pkt_stream; in pkt_stream_generate_custom()
944 static void thread_common_ops(struct test_spec *test, struct ifobject *ifobject) in thread_common_ops() argument
954 for (i = 0; i < test->nb_sockets; i++) { in thread_common_ops()
995 struct test_spec *test = (struct test_spec *)arg; in worker_testapp_validate_tx() local
996 struct ifobject *ifobject = test->ifobj_tx; in worker_testapp_validate_tx()
998 if (test->current_step == 1) in worker_testapp_validate_tx()
999 thread_common_ops(test, ifobject); in worker_testapp_validate_tx()
1008 if (test->total_steps == test->current_step) in worker_testapp_validate_tx()
1046 struct test_spec *test = (struct test_spec *)arg; in worker_testapp_validate_rx() local
1047 struct ifobject *ifobject = test->ifobj_rx; in worker_testapp_validate_rx()
1050 if (test->current_step == 1) in worker_testapp_validate_rx()
1051 thread_common_ops(test, ifobject); in worker_testapp_validate_rx()
1066 if (test->total_steps == test->current_step) in worker_testapp_validate_rx()
1071 static void testapp_validate_traffic(struct test_spec *test) in testapp_validate_traffic() argument
1073 struct ifobject *ifobj_tx = test->ifobj_tx; in testapp_validate_traffic()
1074 struct ifobject *ifobj_rx = test->ifobj_rx; in testapp_validate_traffic()
1080 test->current_step++; in testapp_validate_traffic()
1085 pthread_create(&t0, NULL, ifobj_rx->func_ptr, test); in testapp_validate_traffic()
1092 pthread_create(&t1, NULL, ifobj_tx->func_ptr, test); in testapp_validate_traffic()
1098 static void testapp_teardown(struct test_spec *test) in testapp_teardown() argument
1102 test_spec_set_name(test, "TEARDOWN"); in testapp_teardown()
1104 testapp_validate_traffic(test); in testapp_teardown()
1105 test_spec_reset(test); in testapp_teardown()
1121 static void testapp_bidi(struct test_spec *test) in testapp_bidi() argument
1123 test_spec_set_name(test, "BIDIRECTIONAL"); in testapp_bidi()
1124 test->ifobj_tx->rx_on = true; in testapp_bidi()
1125 test->ifobj_rx->tx_on = true; in testapp_bidi()
1126 test->total_steps = 2; in testapp_bidi()
1127 testapp_validate_traffic(test); in testapp_bidi()
1130 swap_directions(&test->ifobj_rx, &test->ifobj_tx); in testapp_bidi()
1131 testapp_validate_traffic(test); in testapp_bidi()
1133 swap_directions(&test->ifobj_rx, &test->ifobj_tx); in testapp_bidi()
1148 static void testapp_bpf_res(struct test_spec *test) in testapp_bpf_res() argument
1150 test_spec_set_name(test, "BPF_RES"); in testapp_bpf_res()
1151 test->total_steps = 2; in testapp_bpf_res()
1152 test->nb_sockets = 2; in testapp_bpf_res()
1153 testapp_validate_traffic(test); in testapp_bpf_res()
1155 swap_xsk_resources(test->ifobj_tx, test->ifobj_rx); in testapp_bpf_res()
1156 testapp_validate_traffic(test); in testapp_bpf_res()
1159 static void testapp_headroom(struct test_spec *test) in testapp_headroom() argument
1161 test_spec_set_name(test, "UMEM_HEADROOM"); in testapp_headroom()
1162 test->ifobj_rx->umem->frame_headroom = UMEM_HEADROOM_TEST_SIZE; in testapp_headroom()
1163 testapp_validate_traffic(test); in testapp_headroom()
1166 static void testapp_stats(struct test_spec *test) in testapp_stats() argument
1171 test_spec_reset(test); in testapp_stats()
1174 test->ifobj_tx->pacing_on = false; in testapp_stats()
1178 test_spec_set_name(test, "STAT_RX_DROPPED"); in testapp_stats()
1179 test->ifobj_rx->umem->frame_headroom = test->ifobj_rx->umem->frame_size - in testapp_stats()
1181 testapp_validate_traffic(test); in testapp_stats()
1184 test_spec_set_name(test, "STAT_RX_FULL"); in testapp_stats()
1185 test->ifobj_rx->xsk->rxqsize = RX_FULL_RXQSIZE; in testapp_stats()
1186 testapp_validate_traffic(test); in testapp_stats()
1189 test_spec_set_name(test, "STAT_TX_INVALID"); in testapp_stats()
1190 pkt_stream_replace(test, DEFAULT_PKT_CNT, XSK_UMEM__INVALID_FRAME_SIZE); in testapp_stats()
1191 testapp_validate_traffic(test); in testapp_stats()
1193 pkt_stream_restore_default(test); in testapp_stats()
1196 test_spec_set_name(test, "STAT_RX_FILL_EMPTY"); in testapp_stats()
1197 test->ifobj_rx->pkt_stream = pkt_stream_generate(test->ifobj_rx->umem, 0, in testapp_stats()
1199 if (!test->ifobj_rx->pkt_stream) in testapp_stats()
1201 test->ifobj_rx->pkt_stream->use_addr_for_fill = true; in testapp_stats()
1202 testapp_validate_traffic(test); in testapp_stats()
1204 pkt_stream_restore_default(test); in testapp_stats()
1212 test_spec_set_name(test, "STATS"); in testapp_stats()
1230 static bool testapp_unaligned(struct test_spec *test) in testapp_unaligned() argument
1232 if (!hugepages_present(test->ifobj_tx)) { in testapp_unaligned()
1237 test_spec_set_name(test, "UNALIGNED_MODE"); in testapp_unaligned()
1238 test->ifobj_tx->umem->unaligned_mode = true; in testapp_unaligned()
1239 test->ifobj_rx->umem->unaligned_mode = true; in testapp_unaligned()
1241 pkt_stream_replace_half(test, PKT_SIZE, -PKT_SIZE / 2); in testapp_unaligned()
1242 test->ifobj_rx->pkt_stream->use_addr_for_fill = true; in testapp_unaligned()
1243 testapp_validate_traffic(test); in testapp_unaligned()
1245 pkt_stream_restore_default(test); in testapp_unaligned()
1249 static void testapp_single_pkt(struct test_spec *test) in testapp_single_pkt() argument
1253 pkt_stream_generate_custom(test, pkts, ARRAY_SIZE(pkts)); in testapp_single_pkt()
1254 testapp_validate_traffic(test); in testapp_single_pkt()
1255 pkt_stream_restore_default(test); in testapp_single_pkt()
1258 static void testapp_invalid_desc(struct test_spec *test) in testapp_invalid_desc() argument
1280 if (test->ifobj_tx->umem->unaligned_mode) { in testapp_invalid_desc()
1284 if (test->ifobj_tx->umem->frame_size == XSK_UMEM__DEFAULT_FRAME_SIZE / 2) { in testapp_invalid_desc()
1289 pkt_stream_generate_custom(test, pkts, ARRAY_SIZE(pkts)); in testapp_invalid_desc()
1290 testapp_validate_traffic(test); in testapp_invalid_desc()
1291 pkt_stream_restore_default(test); in testapp_invalid_desc()
1315 static void run_pkt_test(struct test_spec *test, enum test_mode mode, enum test_type type) in run_pkt_test() argument
1324 testapp_stats(test); in run_pkt_test()
1327 testapp_teardown(test); in run_pkt_test()
1330 testapp_bidi(test); in run_pkt_test()
1333 testapp_bpf_res(test); in run_pkt_test()
1336 test_spec_set_name(test, "RUN_TO_COMPLETION"); in run_pkt_test()
1337 testapp_validate_traffic(test); in run_pkt_test()
1340 test_spec_set_name(test, "RUN_TO_COMPLETION_SINGLE_PKT"); in run_pkt_test()
1341 testapp_single_pkt(test); in run_pkt_test()
1344 test_spec_set_name(test, "RUN_TO_COMPLETION_2K_FRAME_SIZE"); in run_pkt_test()
1345 test->ifobj_tx->umem->frame_size = 2048; in run_pkt_test()
1346 test->ifobj_rx->umem->frame_size = 2048; in run_pkt_test()
1347 pkt_stream_replace(test, DEFAULT_PKT_CNT, MIN_PKT_SIZE); in run_pkt_test()
1348 testapp_validate_traffic(test); in run_pkt_test()
1350 pkt_stream_restore_default(test); in run_pkt_test()
1353 test->ifobj_tx->use_poll = true; in run_pkt_test()
1354 test->ifobj_rx->use_poll = true; in run_pkt_test()
1355 test_spec_set_name(test, "POLL"); in run_pkt_test()
1356 testapp_validate_traffic(test); in run_pkt_test()
1359 test_spec_set_name(test, "ALIGNED_INV_DESC"); in run_pkt_test()
1360 testapp_invalid_desc(test); in run_pkt_test()
1363 test_spec_set_name(test, "ALIGNED_INV_DESC_2K_FRAME_SIZE"); in run_pkt_test()
1364 test->ifobj_tx->umem->frame_size = 2048; in run_pkt_test()
1365 test->ifobj_rx->umem->frame_size = 2048; in run_pkt_test()
1366 testapp_invalid_desc(test); in run_pkt_test()
1369 test_spec_set_name(test, "UNALIGNED_INV_DESC"); in run_pkt_test()
1370 test->ifobj_tx->umem->unaligned_mode = true; in run_pkt_test()
1371 test->ifobj_rx->umem->unaligned_mode = true; in run_pkt_test()
1372 testapp_invalid_desc(test); in run_pkt_test()
1375 if (!testapp_unaligned(test)) in run_pkt_test()
1379 testapp_headroom(test); in run_pkt_test()
1385 print_ksft_result(test); in run_pkt_test()
1425 struct test_spec test; in main() local
1452 test_spec_init(&test, ifobj_tx, ifobj_rx, 0); in main()
1456 test.pkt_stream_default = pkt_stream_default; in main()
1462 test_spec_init(&test, ifobj_tx, ifobj_rx, i); in main()
1463 run_pkt_test(&test, i, j); in main()