Lines Matching full:test

9 #include <kunit/test.h>
31 static void kunit_ida_init(struct kunit *test, struct ida *ida) in kunit_ida_init() argument
33 kunit_alloc_resource(test, __ida_init, __ida_destroy, GFP_KERNEL, ida); in kunit_ida_init()
36 static struct tb_switch *alloc_switch(struct kunit *test, u64 route, in alloc_switch() argument
43 sw = kunit_kzalloc(test, sizeof(*sw), GFP_KERNEL); in alloc_switch()
55 sw->ports = kunit_kzalloc(test, size, GFP_KERNEL); in alloc_switch()
64 kunit_ida_init(test, &sw->ports[i].in_hopids); in alloc_switch()
65 kunit_ida_init(test, &sw->ports[i].out_hopids); in alloc_switch()
72 static struct tb_switch *alloc_host(struct kunit *test) in alloc_host() argument
76 sw = alloc_switch(test, 0, 7, 13); in alloc_host()
154 static struct tb_switch *alloc_host_usb4(struct kunit *test) in alloc_host_usb4() argument
158 sw = alloc_host(test); in alloc_host_usb4()
173 static struct tb_switch *alloc_dev_default(struct kunit *test, in alloc_dev_default() argument
180 sw = alloc_switch(test, route, 1, 19); in alloc_dev_default()
323 static struct tb_switch *alloc_dev_with_dpin(struct kunit *test, in alloc_dev_with_dpin() argument
329 sw = alloc_dev_default(test, parent, route, bonded); in alloc_dev_with_dpin()
344 static struct tb_switch *alloc_dev_usb4(struct kunit *test, in alloc_dev_usb4() argument
350 sw = alloc_dev_default(test, parent, route, bonded); in alloc_dev_usb4()
365 static void tb_test_path_basic(struct kunit *test) in tb_test_path_basic() argument
370 host = alloc_host(test); in tb_test_path_basic()
376 KUNIT_EXPECT_PTR_EQ(test, p, dst_port); in tb_test_path_basic()
379 KUNIT_EXPECT_TRUE(test, !p); in tb_test_path_basic()
382 static void tb_test_path_not_connected_walk(struct kunit *test) in tb_test_path_not_connected_walk() argument
387 host = alloc_host(test); in tb_test_path_not_connected_walk()
389 dev = alloc_dev_default(test, NULL, 3, true); in tb_test_path_not_connected_walk()
395 KUNIT_EXPECT_PTR_EQ(test, p, src_port); in tb_test_path_not_connected_walk()
398 KUNIT_EXPECT_PTR_EQ(test, p, &host->ports[3]); in tb_test_path_not_connected_walk()
401 KUNIT_EXPECT_TRUE(test, !p); in tb_test_path_not_connected_walk()
406 KUNIT_EXPECT_PTR_EQ(test, p, dst_port); in tb_test_path_not_connected_walk()
409 KUNIT_EXPECT_PTR_EQ(test, p, &dev->ports[1]); in tb_test_path_not_connected_walk()
412 KUNIT_EXPECT_TRUE(test, !p); in tb_test_path_not_connected_walk()
421 static void tb_test_path_single_hop_walk(struct kunit *test) in tb_test_path_single_hop_walk() argument
442 host = alloc_host(test); in tb_test_path_single_hop_walk()
443 dev = alloc_dev_default(test, host, 1, true); in tb_test_path_single_hop_walk()
452 KUNIT_EXPECT_TRUE(test, i < ARRAY_SIZE(test_data)); in tb_test_path_single_hop_walk()
453 KUNIT_EXPECT_EQ(test, tb_route(p->sw), test_data[i].route); in tb_test_path_single_hop_walk()
454 KUNIT_EXPECT_EQ(test, p->port, test_data[i].port); in tb_test_path_single_hop_walk()
455 KUNIT_EXPECT_EQ(test, (enum tb_port_type)p->config.type, in tb_test_path_single_hop_walk()
460 KUNIT_EXPECT_EQ(test, i, ARRAY_SIZE(test_data)); in tb_test_path_single_hop_walk()
464 KUNIT_EXPECT_TRUE(test, i < ARRAY_SIZE(test_data)); in tb_test_path_single_hop_walk()
465 KUNIT_EXPECT_EQ(test, tb_route(p->sw), test_data[i].route); in tb_test_path_single_hop_walk()
466 KUNIT_EXPECT_EQ(test, p->port, test_data[i].port); in tb_test_path_single_hop_walk()
467 KUNIT_EXPECT_EQ(test, (enum tb_port_type)p->config.type, in tb_test_path_single_hop_walk()
472 KUNIT_EXPECT_EQ(test, i, -1); in tb_test_path_single_hop_walk()
475 static void tb_test_path_daisy_chain_walk(struct kunit *test) in tb_test_path_daisy_chain_walk() argument
500 host = alloc_host(test); in tb_test_path_daisy_chain_walk()
501 dev1 = alloc_dev_default(test, host, 0x1, true); in tb_test_path_daisy_chain_walk()
502 dev2 = alloc_dev_default(test, dev1, 0x301, true); in tb_test_path_daisy_chain_walk()
511 KUNIT_EXPECT_TRUE(test, i < ARRAY_SIZE(test_data)); in tb_test_path_daisy_chain_walk()
512 KUNIT_EXPECT_EQ(test, tb_route(p->sw), test_data[i].route); in tb_test_path_daisy_chain_walk()
513 KUNIT_EXPECT_EQ(test, p->port, test_data[i].port); in tb_test_path_daisy_chain_walk()
514 KUNIT_EXPECT_EQ(test, (enum tb_port_type)p->config.type, in tb_test_path_daisy_chain_walk()
519 KUNIT_EXPECT_EQ(test, i, ARRAY_SIZE(test_data)); in tb_test_path_daisy_chain_walk()
523 KUNIT_EXPECT_TRUE(test, i < ARRAY_SIZE(test_data)); in tb_test_path_daisy_chain_walk()
524 KUNIT_EXPECT_EQ(test, tb_route(p->sw), test_data[i].route); in tb_test_path_daisy_chain_walk()
525 KUNIT_EXPECT_EQ(test, p->port, test_data[i].port); in tb_test_path_daisy_chain_walk()
526 KUNIT_EXPECT_EQ(test, (enum tb_port_type)p->config.type, in tb_test_path_daisy_chain_walk()
531 KUNIT_EXPECT_EQ(test, i, -1); in tb_test_path_daisy_chain_walk()
534 static void tb_test_path_simple_tree_walk(struct kunit *test) in tb_test_path_simple_tree_walk() argument
561 host = alloc_host(test); in tb_test_path_simple_tree_walk()
562 dev1 = alloc_dev_default(test, host, 0x1, true); in tb_test_path_simple_tree_walk()
563 alloc_dev_default(test, dev1, 0x301, true); in tb_test_path_simple_tree_walk()
564 dev3 = alloc_dev_default(test, dev1, 0x501, true); in tb_test_path_simple_tree_walk()
565 alloc_dev_default(test, dev1, 0x701, true); in tb_test_path_simple_tree_walk()
574 KUNIT_EXPECT_TRUE(test, i < ARRAY_SIZE(test_data)); in tb_test_path_simple_tree_walk()
575 KUNIT_EXPECT_EQ(test, tb_route(p->sw), test_data[i].route); in tb_test_path_simple_tree_walk()
576 KUNIT_EXPECT_EQ(test, p->port, test_data[i].port); in tb_test_path_simple_tree_walk()
577 KUNIT_EXPECT_EQ(test, (enum tb_port_type)p->config.type, in tb_test_path_simple_tree_walk()
582 KUNIT_EXPECT_EQ(test, i, ARRAY_SIZE(test_data)); in tb_test_path_simple_tree_walk()
586 KUNIT_EXPECT_TRUE(test, i < ARRAY_SIZE(test_data)); in tb_test_path_simple_tree_walk()
587 KUNIT_EXPECT_EQ(test, tb_route(p->sw), test_data[i].route); in tb_test_path_simple_tree_walk()
588 KUNIT_EXPECT_EQ(test, p->port, test_data[i].port); in tb_test_path_simple_tree_walk()
589 KUNIT_EXPECT_EQ(test, (enum tb_port_type)p->config.type, in tb_test_path_simple_tree_walk()
594 KUNIT_EXPECT_EQ(test, i, -1); in tb_test_path_simple_tree_walk()
597 static void tb_test_path_complex_tree_walk(struct kunit *test) in tb_test_path_complex_tree_walk() argument
640 host = alloc_host(test); in tb_test_path_complex_tree_walk()
641 dev1 = alloc_dev_default(test, host, 0x1, true); in tb_test_path_complex_tree_walk()
642 dev2 = alloc_dev_default(test, dev1, 0x301, true); in tb_test_path_complex_tree_walk()
643 dev3 = alloc_dev_with_dpin(test, dev2, 0x50301, true); in tb_test_path_complex_tree_walk()
644 alloc_dev_default(test, dev1, 0x501, true); in tb_test_path_complex_tree_walk()
645 dev5 = alloc_dev_default(test, dev1, 0x701, true); in tb_test_path_complex_tree_walk()
646 dev6 = alloc_dev_default(test, dev5, 0x70701, true); in tb_test_path_complex_tree_walk()
647 dev7 = alloc_dev_default(test, dev6, 0x3070701, true); in tb_test_path_complex_tree_walk()
648 alloc_dev_default(test, dev7, 0x303070701, true); in tb_test_path_complex_tree_walk()
649 dev9 = alloc_dev_default(test, dev7, 0x503070701, true); in tb_test_path_complex_tree_walk()
658 KUNIT_EXPECT_TRUE(test, i < ARRAY_SIZE(test_data)); in tb_test_path_complex_tree_walk()
659 KUNIT_EXPECT_EQ(test, tb_route(p->sw), test_data[i].route); in tb_test_path_complex_tree_walk()
660 KUNIT_EXPECT_EQ(test, p->port, test_data[i].port); in tb_test_path_complex_tree_walk()
661 KUNIT_EXPECT_EQ(test, (enum tb_port_type)p->config.type, in tb_test_path_complex_tree_walk()
666 KUNIT_EXPECT_EQ(test, i, ARRAY_SIZE(test_data)); in tb_test_path_complex_tree_walk()
670 KUNIT_EXPECT_TRUE(test, i < ARRAY_SIZE(test_data)); in tb_test_path_complex_tree_walk()
671 KUNIT_EXPECT_EQ(test, tb_route(p->sw), test_data[i].route); in tb_test_path_complex_tree_walk()
672 KUNIT_EXPECT_EQ(test, p->port, test_data[i].port); in tb_test_path_complex_tree_walk()
673 KUNIT_EXPECT_EQ(test, (enum tb_port_type)p->config.type, in tb_test_path_complex_tree_walk()
678 KUNIT_EXPECT_EQ(test, i, -1); in tb_test_path_complex_tree_walk()
681 static void tb_test_path_max_length_walk(struct kunit *test) in tb_test_path_max_length_walk() argument
740 host = alloc_host(test); in tb_test_path_max_length_walk()
741 dev1 = alloc_dev_default(test, host, 0x1, true); in tb_test_path_max_length_walk()
742 dev2 = alloc_dev_default(test, dev1, 0x301, true); in tb_test_path_max_length_walk()
743 dev3 = alloc_dev_default(test, dev2, 0x30301, true); in tb_test_path_max_length_walk()
744 dev4 = alloc_dev_default(test, dev3, 0x3030301, true); in tb_test_path_max_length_walk()
745 dev5 = alloc_dev_default(test, dev4, 0x303030301, true); in tb_test_path_max_length_walk()
746 dev6 = alloc_dev_with_dpin(test, dev5, 0x30303030301, true); in tb_test_path_max_length_walk()
747 dev7 = alloc_dev_default(test, host, 0x3, true); in tb_test_path_max_length_walk()
748 dev8 = alloc_dev_default(test, dev7, 0x303, true); in tb_test_path_max_length_walk()
749 dev9 = alloc_dev_default(test, dev8, 0x30303, true); in tb_test_path_max_length_walk()
750 dev10 = alloc_dev_default(test, dev9, 0x3030303, true); in tb_test_path_max_length_walk()
751 dev11 = alloc_dev_default(test, dev10, 0x303030303, true); in tb_test_path_max_length_walk()
752 dev12 = alloc_dev_default(test, dev11, 0x30303030303, true); in tb_test_path_max_length_walk()
761 KUNIT_EXPECT_TRUE(test, i < ARRAY_SIZE(test_data)); in tb_test_path_max_length_walk()
762 KUNIT_EXPECT_EQ(test, tb_route(p->sw), test_data[i].route); in tb_test_path_max_length_walk()
763 KUNIT_EXPECT_EQ(test, p->port, test_data[i].port); in tb_test_path_max_length_walk()
764 KUNIT_EXPECT_EQ(test, (enum tb_port_type)p->config.type, in tb_test_path_max_length_walk()
769 KUNIT_EXPECT_EQ(test, i, ARRAY_SIZE(test_data)); in tb_test_path_max_length_walk()
773 KUNIT_EXPECT_TRUE(test, i < ARRAY_SIZE(test_data)); in tb_test_path_max_length_walk()
774 KUNIT_EXPECT_EQ(test, tb_route(p->sw), test_data[i].route); in tb_test_path_max_length_walk()
775 KUNIT_EXPECT_EQ(test, p->port, test_data[i].port); in tb_test_path_max_length_walk()
776 KUNIT_EXPECT_EQ(test, (enum tb_port_type)p->config.type, in tb_test_path_max_length_walk()
781 KUNIT_EXPECT_EQ(test, i, -1); in tb_test_path_max_length_walk()
784 static void tb_test_path_not_connected(struct kunit *test) in tb_test_path_not_connected() argument
790 host = alloc_host(test); in tb_test_path_not_connected()
791 dev1 = alloc_dev_default(test, host, 0x3, false); in tb_test_path_not_connected()
793 dev2 = alloc_dev_default(test, NULL, 0x303, false); in tb_test_path_not_connected()
799 KUNIT_ASSERT_TRUE(test, path == NULL); in tb_test_path_not_connected()
801 KUNIT_ASSERT_TRUE(test, path == NULL); in tb_test_path_not_connected()
812 static void tb_test_path_not_bonded_lane0(struct kunit *test) in tb_test_path_not_bonded_lane0() argument
843 host = alloc_host(test); in tb_test_path_not_bonded_lane0()
844 dev = alloc_dev_default(test, host, 0x3, false); in tb_test_path_not_bonded_lane0()
850 KUNIT_ASSERT_TRUE(test, path != NULL); in tb_test_path_not_bonded_lane0()
851 KUNIT_ASSERT_EQ(test, path->path_length, ARRAY_SIZE(test_data)); in tb_test_path_not_bonded_lane0()
858 KUNIT_EXPECT_EQ(test, tb_route(in_port->sw), test_data[i].route); in tb_test_path_not_bonded_lane0()
859 KUNIT_EXPECT_EQ(test, in_port->port, test_data[i].in_port); in tb_test_path_not_bonded_lane0()
860 KUNIT_EXPECT_EQ(test, (enum tb_port_type)in_port->config.type, in tb_test_path_not_bonded_lane0()
862 KUNIT_EXPECT_EQ(test, tb_route(out_port->sw), test_data[i].route); in tb_test_path_not_bonded_lane0()
863 KUNIT_EXPECT_EQ(test, out_port->port, test_data[i].out_port); in tb_test_path_not_bonded_lane0()
864 KUNIT_EXPECT_EQ(test, (enum tb_port_type)out_port->config.type, in tb_test_path_not_bonded_lane0()
870 static void tb_test_path_not_bonded_lane1(struct kunit *test) in tb_test_path_not_bonded_lane1() argument
905 host = alloc_host(test); in tb_test_path_not_bonded_lane1()
906 dev = alloc_dev_default(test, host, 0x1, false); in tb_test_path_not_bonded_lane1()
912 KUNIT_ASSERT_TRUE(test, path != NULL); in tb_test_path_not_bonded_lane1()
913 KUNIT_ASSERT_EQ(test, path->path_length, ARRAY_SIZE(test_data)); in tb_test_path_not_bonded_lane1()
920 KUNIT_EXPECT_EQ(test, tb_route(in_port->sw), test_data[i].route); in tb_test_path_not_bonded_lane1()
921 KUNIT_EXPECT_EQ(test, in_port->port, test_data[i].in_port); in tb_test_path_not_bonded_lane1()
922 KUNIT_EXPECT_EQ(test, (enum tb_port_type)in_port->config.type, in tb_test_path_not_bonded_lane1()
924 KUNIT_EXPECT_EQ(test, tb_route(out_port->sw), test_data[i].route); in tb_test_path_not_bonded_lane1()
925 KUNIT_EXPECT_EQ(test, out_port->port, test_data[i].out_port); in tb_test_path_not_bonded_lane1()
926 KUNIT_EXPECT_EQ(test, (enum tb_port_type)out_port->config.type, in tb_test_path_not_bonded_lane1()
932 static void tb_test_path_not_bonded_lane1_chain(struct kunit *test) in tb_test_path_not_bonded_lane1_chain() argument
983 host = alloc_host(test); in tb_test_path_not_bonded_lane1_chain()
984 dev1 = alloc_dev_default(test, host, 0x1, false); in tb_test_path_not_bonded_lane1_chain()
985 dev2 = alloc_dev_default(test, dev1, 0x701, false); in tb_test_path_not_bonded_lane1_chain()
986 dev3 = alloc_dev_default(test, dev2, 0x50701, false); in tb_test_path_not_bonded_lane1_chain()
992 KUNIT_ASSERT_TRUE(test, path != NULL); in tb_test_path_not_bonded_lane1_chain()
993 KUNIT_ASSERT_EQ(test, path->path_length, ARRAY_SIZE(test_data)); in tb_test_path_not_bonded_lane1_chain()
1000 KUNIT_EXPECT_EQ(test, tb_route(in_port->sw), test_data[i].route); in tb_test_path_not_bonded_lane1_chain()
1001 KUNIT_EXPECT_EQ(test, in_port->port, test_data[i].in_port); in tb_test_path_not_bonded_lane1_chain()
1002 KUNIT_EXPECT_EQ(test, (enum tb_port_type)in_port->config.type, in tb_test_path_not_bonded_lane1_chain()
1004 KUNIT_EXPECT_EQ(test, tb_route(out_port->sw), test_data[i].route); in tb_test_path_not_bonded_lane1_chain()
1005 KUNIT_EXPECT_EQ(test, out_port->port, test_data[i].out_port); in tb_test_path_not_bonded_lane1_chain()
1006 KUNIT_EXPECT_EQ(test, (enum tb_port_type)out_port->config.type, in tb_test_path_not_bonded_lane1_chain()
1012 static void tb_test_path_not_bonded_lane1_chain_reverse(struct kunit *test) in tb_test_path_not_bonded_lane1_chain_reverse() argument
1063 host = alloc_host(test); in tb_test_path_not_bonded_lane1_chain_reverse()
1064 dev1 = alloc_dev_default(test, host, 0x1, false); in tb_test_path_not_bonded_lane1_chain_reverse()
1065 dev2 = alloc_dev_default(test, dev1, 0x701, false); in tb_test_path_not_bonded_lane1_chain_reverse()
1066 dev3 = alloc_dev_with_dpin(test, dev2, 0x50701, false); in tb_test_path_not_bonded_lane1_chain_reverse()
1072 KUNIT_ASSERT_TRUE(test, path != NULL); in tb_test_path_not_bonded_lane1_chain_reverse()
1073 KUNIT_ASSERT_EQ(test, path->path_length, ARRAY_SIZE(test_data)); in tb_test_path_not_bonded_lane1_chain_reverse()
1080 KUNIT_EXPECT_EQ(test, tb_route(in_port->sw), test_data[i].route); in tb_test_path_not_bonded_lane1_chain_reverse()
1081 KUNIT_EXPECT_EQ(test, in_port->port, test_data[i].in_port); in tb_test_path_not_bonded_lane1_chain_reverse()
1082 KUNIT_EXPECT_EQ(test, (enum tb_port_type)in_port->config.type, in tb_test_path_not_bonded_lane1_chain_reverse()
1084 KUNIT_EXPECT_EQ(test, tb_route(out_port->sw), test_data[i].route); in tb_test_path_not_bonded_lane1_chain_reverse()
1085 KUNIT_EXPECT_EQ(test, out_port->port, test_data[i].out_port); in tb_test_path_not_bonded_lane1_chain_reverse()
1086 KUNIT_EXPECT_EQ(test, (enum tb_port_type)out_port->config.type, in tb_test_path_not_bonded_lane1_chain_reverse()
1092 static void tb_test_path_mixed_chain(struct kunit *test) in tb_test_path_mixed_chain() argument
1154 host = alloc_host(test); in tb_test_path_mixed_chain()
1155 dev1 = alloc_dev_default(test, host, 0x1, true); in tb_test_path_mixed_chain()
1156 dev2 = alloc_dev_default(test, dev1, 0x701, false); in tb_test_path_mixed_chain()
1157 dev3 = alloc_dev_default(test, dev2, 0x50701, false); in tb_test_path_mixed_chain()
1158 dev4 = alloc_dev_default(test, dev3, 0x3050701, true); in tb_test_path_mixed_chain()
1164 KUNIT_ASSERT_TRUE(test, path != NULL); in tb_test_path_mixed_chain()
1165 KUNIT_ASSERT_EQ(test, path->path_length, ARRAY_SIZE(test_data)); in tb_test_path_mixed_chain()
1172 KUNIT_EXPECT_EQ(test, tb_route(in_port->sw), test_data[i].route); in tb_test_path_mixed_chain()
1173 KUNIT_EXPECT_EQ(test, in_port->port, test_data[i].in_port); in tb_test_path_mixed_chain()
1174 KUNIT_EXPECT_EQ(test, (enum tb_port_type)in_port->config.type, in tb_test_path_mixed_chain()
1176 KUNIT_EXPECT_EQ(test, tb_route(out_port->sw), test_data[i].route); in tb_test_path_mixed_chain()
1177 KUNIT_EXPECT_EQ(test, out_port->port, test_data[i].out_port); in tb_test_path_mixed_chain()
1178 KUNIT_EXPECT_EQ(test, (enum tb_port_type)out_port->config.type, in tb_test_path_mixed_chain()
1184 static void tb_test_path_mixed_chain_reverse(struct kunit *test) in tb_test_path_mixed_chain_reverse() argument
1246 host = alloc_host(test); in tb_test_path_mixed_chain_reverse()
1247 dev1 = alloc_dev_default(test, host, 0x1, true); in tb_test_path_mixed_chain_reverse()
1248 dev2 = alloc_dev_default(test, dev1, 0x701, false); in tb_test_path_mixed_chain_reverse()
1249 dev3 = alloc_dev_default(test, dev2, 0x50701, false); in tb_test_path_mixed_chain_reverse()
1250 dev4 = alloc_dev_default(test, dev3, 0x3050701, true); in tb_test_path_mixed_chain_reverse()
1256 KUNIT_ASSERT_TRUE(test, path != NULL); in tb_test_path_mixed_chain_reverse()
1257 KUNIT_ASSERT_EQ(test, path->path_length, ARRAY_SIZE(test_data)); in tb_test_path_mixed_chain_reverse()
1264 KUNIT_EXPECT_EQ(test, tb_route(in_port->sw), test_data[i].route); in tb_test_path_mixed_chain_reverse()
1265 KUNIT_EXPECT_EQ(test, in_port->port, test_data[i].in_port); in tb_test_path_mixed_chain_reverse()
1266 KUNIT_EXPECT_EQ(test, (enum tb_port_type)in_port->config.type, in tb_test_path_mixed_chain_reverse()
1268 KUNIT_EXPECT_EQ(test, tb_route(out_port->sw), test_data[i].route); in tb_test_path_mixed_chain_reverse()
1269 KUNIT_EXPECT_EQ(test, out_port->port, test_data[i].out_port); in tb_test_path_mixed_chain_reverse()
1270 KUNIT_EXPECT_EQ(test, (enum tb_port_type)out_port->config.type, in tb_test_path_mixed_chain_reverse()
1276 static void tb_test_tunnel_pcie(struct kunit *test) in tb_test_tunnel_pcie() argument
1293 host = alloc_host(test); in tb_test_tunnel_pcie()
1294 dev1 = alloc_dev_default(test, host, 0x1, true); in tb_test_tunnel_pcie()
1295 dev2 = alloc_dev_default(test, dev1, 0x501, true); in tb_test_tunnel_pcie()
1300 KUNIT_ASSERT_TRUE(test, tunnel1 != NULL); in tb_test_tunnel_pcie()
1301 KUNIT_EXPECT_EQ(test, tunnel1->type, TB_TUNNEL_PCI); in tb_test_tunnel_pcie()
1302 KUNIT_EXPECT_PTR_EQ(test, tunnel1->src_port, down); in tb_test_tunnel_pcie()
1303 KUNIT_EXPECT_PTR_EQ(test, tunnel1->dst_port, up); in tb_test_tunnel_pcie()
1304 KUNIT_ASSERT_EQ(test, tunnel1->npaths, 2); in tb_test_tunnel_pcie()
1305 KUNIT_ASSERT_EQ(test, tunnel1->paths[0]->path_length, 2); in tb_test_tunnel_pcie()
1306 KUNIT_EXPECT_PTR_EQ(test, tunnel1->paths[0]->hops[0].in_port, down); in tb_test_tunnel_pcie()
1307 KUNIT_EXPECT_PTR_EQ(test, tunnel1->paths[0]->hops[1].out_port, up); in tb_test_tunnel_pcie()
1308 KUNIT_ASSERT_EQ(test, tunnel1->paths[1]->path_length, 2); in tb_test_tunnel_pcie()
1309 KUNIT_EXPECT_PTR_EQ(test, tunnel1->paths[1]->hops[0].in_port, up); in tb_test_tunnel_pcie()
1310 KUNIT_EXPECT_PTR_EQ(test, tunnel1->paths[1]->hops[1].out_port, down); in tb_test_tunnel_pcie()
1315 KUNIT_ASSERT_TRUE(test, tunnel2 != NULL); in tb_test_tunnel_pcie()
1316 KUNIT_EXPECT_EQ(test, tunnel2->type, TB_TUNNEL_PCI); in tb_test_tunnel_pcie()
1317 KUNIT_EXPECT_PTR_EQ(test, tunnel2->src_port, down); in tb_test_tunnel_pcie()
1318 KUNIT_EXPECT_PTR_EQ(test, tunnel2->dst_port, up); in tb_test_tunnel_pcie()
1319 KUNIT_ASSERT_EQ(test, tunnel2->npaths, 2); in tb_test_tunnel_pcie()
1320 KUNIT_ASSERT_EQ(test, tunnel2->paths[0]->path_length, 2); in tb_test_tunnel_pcie()
1321 KUNIT_EXPECT_PTR_EQ(test, tunnel2->paths[0]->hops[0].in_port, down); in tb_test_tunnel_pcie()
1322 KUNIT_EXPECT_PTR_EQ(test, tunnel2->paths[0]->hops[1].out_port, up); in tb_test_tunnel_pcie()
1323 KUNIT_ASSERT_EQ(test, tunnel2->paths[1]->path_length, 2); in tb_test_tunnel_pcie()
1324 KUNIT_EXPECT_PTR_EQ(test, tunnel2->paths[1]->hops[0].in_port, up); in tb_test_tunnel_pcie()
1325 KUNIT_EXPECT_PTR_EQ(test, tunnel2->paths[1]->hops[1].out_port, down); in tb_test_tunnel_pcie()
1331 static void tb_test_tunnel_dp(struct kunit *test) in tb_test_tunnel_dp() argument
1345 host = alloc_host(test); in tb_test_tunnel_dp()
1346 dev = alloc_dev_default(test, host, 0x3, true); in tb_test_tunnel_dp()
1352 KUNIT_ASSERT_TRUE(test, tunnel != NULL); in tb_test_tunnel_dp()
1353 KUNIT_EXPECT_EQ(test, tunnel->type, TB_TUNNEL_DP); in tb_test_tunnel_dp()
1354 KUNIT_EXPECT_PTR_EQ(test, tunnel->src_port, in); in tb_test_tunnel_dp()
1355 KUNIT_EXPECT_PTR_EQ(test, tunnel->dst_port, out); in tb_test_tunnel_dp()
1356 KUNIT_ASSERT_EQ(test, tunnel->npaths, 3); in tb_test_tunnel_dp()
1357 KUNIT_ASSERT_EQ(test, tunnel->paths[0]->path_length, 2); in tb_test_tunnel_dp()
1358 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[0]->hops[0].in_port, in); in tb_test_tunnel_dp()
1359 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[0]->hops[1].out_port, out); in tb_test_tunnel_dp()
1360 KUNIT_ASSERT_EQ(test, tunnel->paths[1]->path_length, 2); in tb_test_tunnel_dp()
1361 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[1]->hops[0].in_port, in); in tb_test_tunnel_dp()
1362 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[1]->hops[1].out_port, out); in tb_test_tunnel_dp()
1363 KUNIT_ASSERT_EQ(test, tunnel->paths[2]->path_length, 2); in tb_test_tunnel_dp()
1364 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[2]->hops[0].in_port, out); in tb_test_tunnel_dp()
1365 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[2]->hops[1].out_port, in); in tb_test_tunnel_dp()
1369 static void tb_test_tunnel_dp_chain(struct kunit *test) in tb_test_tunnel_dp_chain() argument
1388 host = alloc_host(test); in tb_test_tunnel_dp_chain()
1389 dev1 = alloc_dev_default(test, host, 0x1, true); in tb_test_tunnel_dp_chain()
1390 alloc_dev_default(test, dev1, 0x301, true); in tb_test_tunnel_dp_chain()
1391 alloc_dev_default(test, dev1, 0x501, true); in tb_test_tunnel_dp_chain()
1392 dev4 = alloc_dev_default(test, dev1, 0x701, true); in tb_test_tunnel_dp_chain()
1398 KUNIT_ASSERT_TRUE(test, tunnel != NULL); in tb_test_tunnel_dp_chain()
1399 KUNIT_EXPECT_EQ(test, tunnel->type, TB_TUNNEL_DP); in tb_test_tunnel_dp_chain()
1400 KUNIT_EXPECT_PTR_EQ(test, tunnel->src_port, in); in tb_test_tunnel_dp_chain()
1401 KUNIT_EXPECT_PTR_EQ(test, tunnel->dst_port, out); in tb_test_tunnel_dp_chain()
1402 KUNIT_ASSERT_EQ(test, tunnel->npaths, 3); in tb_test_tunnel_dp_chain()
1403 KUNIT_ASSERT_EQ(test, tunnel->paths[0]->path_length, 3); in tb_test_tunnel_dp_chain()
1404 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[0]->hops[0].in_port, in); in tb_test_tunnel_dp_chain()
1405 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[0]->hops[2].out_port, out); in tb_test_tunnel_dp_chain()
1406 KUNIT_ASSERT_EQ(test, tunnel->paths[1]->path_length, 3); in tb_test_tunnel_dp_chain()
1407 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[1]->hops[0].in_port, in); in tb_test_tunnel_dp_chain()
1408 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[1]->hops[2].out_port, out); in tb_test_tunnel_dp_chain()
1409 KUNIT_ASSERT_EQ(test, tunnel->paths[2]->path_length, 3); in tb_test_tunnel_dp_chain()
1410 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[2]->hops[0].in_port, out); in tb_test_tunnel_dp_chain()
1411 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[2]->hops[2].out_port, in); in tb_test_tunnel_dp_chain()
1415 static void tb_test_tunnel_dp_tree(struct kunit *test) in tb_test_tunnel_dp_tree() argument
1437 host = alloc_host(test); in tb_test_tunnel_dp_tree()
1438 dev1 = alloc_dev_default(test, host, 0x3, true); in tb_test_tunnel_dp_tree()
1439 dev2 = alloc_dev_with_dpin(test, dev1, 0x303, true); in tb_test_tunnel_dp_tree()
1440 dev3 = alloc_dev_default(test, dev1, 0x503, true); in tb_test_tunnel_dp_tree()
1441 alloc_dev_default(test, dev1, 0x703, true); in tb_test_tunnel_dp_tree()
1442 dev5 = alloc_dev_default(test, dev3, 0x50503, true); in tb_test_tunnel_dp_tree()
1448 KUNIT_ASSERT_TRUE(test, tunnel != NULL); in tb_test_tunnel_dp_tree()
1449 KUNIT_EXPECT_EQ(test, tunnel->type, TB_TUNNEL_DP); in tb_test_tunnel_dp_tree()
1450 KUNIT_EXPECT_PTR_EQ(test, tunnel->src_port, in); in tb_test_tunnel_dp_tree()
1451 KUNIT_EXPECT_PTR_EQ(test, tunnel->dst_port, out); in tb_test_tunnel_dp_tree()
1452 KUNIT_ASSERT_EQ(test, tunnel->npaths, 3); in tb_test_tunnel_dp_tree()
1453 KUNIT_ASSERT_EQ(test, tunnel->paths[0]->path_length, 4); in tb_test_tunnel_dp_tree()
1454 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[0]->hops[0].in_port, in); in tb_test_tunnel_dp_tree()
1455 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[0]->hops[3].out_port, out); in tb_test_tunnel_dp_tree()
1456 KUNIT_ASSERT_EQ(test, tunnel->paths[1]->path_length, 4); in tb_test_tunnel_dp_tree()
1457 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[1]->hops[0].in_port, in); in tb_test_tunnel_dp_tree()
1458 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[1]->hops[3].out_port, out); in tb_test_tunnel_dp_tree()
1459 KUNIT_ASSERT_EQ(test, tunnel->paths[2]->path_length, 4); in tb_test_tunnel_dp_tree()
1460 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[2]->hops[0].in_port, out); in tb_test_tunnel_dp_tree()
1461 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[2]->hops[3].out_port, in); in tb_test_tunnel_dp_tree()
1465 static void tb_test_tunnel_dp_max_length(struct kunit *test) in tb_test_tunnel_dp_max_length() argument
1495 host = alloc_host(test); in tb_test_tunnel_dp_max_length()
1496 dev1 = alloc_dev_default(test, host, 0x1, true); in tb_test_tunnel_dp_max_length()
1497 dev2 = alloc_dev_default(test, dev1, 0x301, true); in tb_test_tunnel_dp_max_length()
1498 dev3 = alloc_dev_default(test, dev2, 0x30301, true); in tb_test_tunnel_dp_max_length()
1499 dev4 = alloc_dev_default(test, dev3, 0x3030301, true); in tb_test_tunnel_dp_max_length()
1500 dev5 = alloc_dev_default(test, dev4, 0x303030301, true); in tb_test_tunnel_dp_max_length()
1501 dev6 = alloc_dev_with_dpin(test, dev5, 0x30303030301, true); in tb_test_tunnel_dp_max_length()
1502 dev7 = alloc_dev_default(test, host, 0x3, true); in tb_test_tunnel_dp_max_length()
1503 dev8 = alloc_dev_default(test, dev7, 0x303, true); in tb_test_tunnel_dp_max_length()
1504 dev9 = alloc_dev_default(test, dev8, 0x30303, true); in tb_test_tunnel_dp_max_length()
1505 dev10 = alloc_dev_default(test, dev9, 0x3030303, true); in tb_test_tunnel_dp_max_length()
1506 dev11 = alloc_dev_default(test, dev10, 0x303030303, true); in tb_test_tunnel_dp_max_length()
1507 dev12 = alloc_dev_default(test, dev11, 0x30303030303, true); in tb_test_tunnel_dp_max_length()
1513 KUNIT_ASSERT_TRUE(test, tunnel != NULL); in tb_test_tunnel_dp_max_length()
1514 KUNIT_EXPECT_EQ(test, tunnel->type, TB_TUNNEL_DP); in tb_test_tunnel_dp_max_length()
1515 KUNIT_EXPECT_PTR_EQ(test, tunnel->src_port, in); in tb_test_tunnel_dp_max_length()
1516 KUNIT_EXPECT_PTR_EQ(test, tunnel->dst_port, out); in tb_test_tunnel_dp_max_length()
1517 KUNIT_ASSERT_EQ(test, tunnel->npaths, 3); in tb_test_tunnel_dp_max_length()
1518 KUNIT_ASSERT_EQ(test, tunnel->paths[0]->path_length, 13); in tb_test_tunnel_dp_max_length()
1520 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[0]->hops[0].in_port, in); in tb_test_tunnel_dp_max_length()
1522 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[0]->hops[6].in_port, in tb_test_tunnel_dp_max_length()
1524 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[0]->hops[6].out_port, in tb_test_tunnel_dp_max_length()
1527 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[0]->hops[12].out_port, out); in tb_test_tunnel_dp_max_length()
1528 KUNIT_ASSERT_EQ(test, tunnel->paths[1]->path_length, 13); in tb_test_tunnel_dp_max_length()
1529 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[1]->hops[0].in_port, in); in tb_test_tunnel_dp_max_length()
1530 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[1]->hops[6].in_port, in tb_test_tunnel_dp_max_length()
1532 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[1]->hops[6].out_port, in tb_test_tunnel_dp_max_length()
1534 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[1]->hops[12].out_port, out); in tb_test_tunnel_dp_max_length()
1535 KUNIT_ASSERT_EQ(test, tunnel->paths[2]->path_length, 13); in tb_test_tunnel_dp_max_length()
1536 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[2]->hops[0].in_port, out); in tb_test_tunnel_dp_max_length()
1537 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[2]->hops[6].in_port, in tb_test_tunnel_dp_max_length()
1539 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[2]->hops[6].out_port, in tb_test_tunnel_dp_max_length()
1541 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[2]->hops[12].out_port, in); in tb_test_tunnel_dp_max_length()
1545 static void tb_test_tunnel_usb3(struct kunit *test) in tb_test_tunnel_usb3() argument
1562 host = alloc_host(test); in tb_test_tunnel_usb3()
1563 dev1 = alloc_dev_default(test, host, 0x1, true); in tb_test_tunnel_usb3()
1564 dev2 = alloc_dev_default(test, dev1, 0x701, true); in tb_test_tunnel_usb3()
1569 KUNIT_ASSERT_TRUE(test, tunnel1 != NULL); in tb_test_tunnel_usb3()
1570 KUNIT_EXPECT_EQ(test, tunnel1->type, TB_TUNNEL_USB3); in tb_test_tunnel_usb3()
1571 KUNIT_EXPECT_PTR_EQ(test, tunnel1->src_port, down); in tb_test_tunnel_usb3()
1572 KUNIT_EXPECT_PTR_EQ(test, tunnel1->dst_port, up); in tb_test_tunnel_usb3()
1573 KUNIT_ASSERT_EQ(test, tunnel1->npaths, 2); in tb_test_tunnel_usb3()
1574 KUNIT_ASSERT_EQ(test, tunnel1->paths[0]->path_length, 2); in tb_test_tunnel_usb3()
1575 KUNIT_EXPECT_PTR_EQ(test, tunnel1->paths[0]->hops[0].in_port, down); in tb_test_tunnel_usb3()
1576 KUNIT_EXPECT_PTR_EQ(test, tunnel1->paths[0]->hops[1].out_port, up); in tb_test_tunnel_usb3()
1577 KUNIT_ASSERT_EQ(test, tunnel1->paths[1]->path_length, 2); in tb_test_tunnel_usb3()
1578 KUNIT_EXPECT_PTR_EQ(test, tunnel1->paths[1]->hops[0].in_port, up); in tb_test_tunnel_usb3()
1579 KUNIT_EXPECT_PTR_EQ(test, tunnel1->paths[1]->hops[1].out_port, down); in tb_test_tunnel_usb3()
1584 KUNIT_ASSERT_TRUE(test, tunnel2 != NULL); in tb_test_tunnel_usb3()
1585 KUNIT_EXPECT_EQ(test, tunnel2->type, TB_TUNNEL_USB3); in tb_test_tunnel_usb3()
1586 KUNIT_EXPECT_PTR_EQ(test, tunnel2->src_port, down); in tb_test_tunnel_usb3()
1587 KUNIT_EXPECT_PTR_EQ(test, tunnel2->dst_port, up); in tb_test_tunnel_usb3()
1588 KUNIT_ASSERT_EQ(test, tunnel2->npaths, 2); in tb_test_tunnel_usb3()
1589 KUNIT_ASSERT_EQ(test, tunnel2->paths[0]->path_length, 2); in tb_test_tunnel_usb3()
1590 KUNIT_EXPECT_PTR_EQ(test, tunnel2->paths[0]->hops[0].in_port, down); in tb_test_tunnel_usb3()
1591 KUNIT_EXPECT_PTR_EQ(test, tunnel2->paths[0]->hops[1].out_port, up); in tb_test_tunnel_usb3()
1592 KUNIT_ASSERT_EQ(test, tunnel2->paths[1]->path_length, 2); in tb_test_tunnel_usb3()
1593 KUNIT_EXPECT_PTR_EQ(test, tunnel2->paths[1]->hops[0].in_port, up); in tb_test_tunnel_usb3()
1594 KUNIT_EXPECT_PTR_EQ(test, tunnel2->paths[1]->hops[1].out_port, down); in tb_test_tunnel_usb3()
1600 static void tb_test_tunnel_port_on_path(struct kunit *test) in tb_test_tunnel_port_on_path() argument
1620 host = alloc_host(test); in tb_test_tunnel_port_on_path()
1621 dev1 = alloc_dev_default(test, host, 0x3, true); in tb_test_tunnel_port_on_path()
1622 dev2 = alloc_dev_with_dpin(test, dev1, 0x303, true); in tb_test_tunnel_port_on_path()
1623 dev3 = alloc_dev_default(test, dev1, 0x503, true); in tb_test_tunnel_port_on_path()
1624 dev4 = alloc_dev_default(test, dev1, 0x703, true); in tb_test_tunnel_port_on_path()
1625 dev5 = alloc_dev_default(test, dev3, 0x50503, true); in tb_test_tunnel_port_on_path()
1631 KUNIT_ASSERT_TRUE(test, dp_tunnel != NULL); in tb_test_tunnel_port_on_path()
1633 KUNIT_EXPECT_TRUE(test, tb_tunnel_port_on_path(dp_tunnel, in)); in tb_test_tunnel_port_on_path()
1634 KUNIT_EXPECT_TRUE(test, tb_tunnel_port_on_path(dp_tunnel, out)); in tb_test_tunnel_port_on_path()
1637 KUNIT_EXPECT_FALSE(test, tb_tunnel_port_on_path(dp_tunnel, port)); in tb_test_tunnel_port_on_path()
1640 KUNIT_EXPECT_FALSE(test, tb_tunnel_port_on_path(dp_tunnel, port)); in tb_test_tunnel_port_on_path()
1643 KUNIT_EXPECT_FALSE(test, tb_tunnel_port_on_path(dp_tunnel, port)); in tb_test_tunnel_port_on_path()
1646 KUNIT_EXPECT_TRUE(test, tb_tunnel_port_on_path(dp_tunnel, port)); in tb_test_tunnel_port_on_path()
1649 KUNIT_EXPECT_TRUE(test, tb_tunnel_port_on_path(dp_tunnel, port)); in tb_test_tunnel_port_on_path()
1652 KUNIT_EXPECT_FALSE(test, tb_tunnel_port_on_path(dp_tunnel, port)); in tb_test_tunnel_port_on_path()
1655 KUNIT_EXPECT_TRUE(test, tb_tunnel_port_on_path(dp_tunnel, port)); in tb_test_tunnel_port_on_path()
1658 KUNIT_EXPECT_TRUE(test, tb_tunnel_port_on_path(dp_tunnel, port)); in tb_test_tunnel_port_on_path()
1661 KUNIT_EXPECT_FALSE(test, tb_tunnel_port_on_path(dp_tunnel, port)); in tb_test_tunnel_port_on_path()
1666 static void tb_test_tunnel_dma(struct kunit *test) in tb_test_tunnel_dma() argument
1683 host = alloc_host(test); in tb_test_tunnel_dma()
1688 KUNIT_ASSERT_TRUE(test, tunnel != NULL); in tb_test_tunnel_dma()
1689 KUNIT_EXPECT_EQ(test, tunnel->type, TB_TUNNEL_DMA); in tb_test_tunnel_dma()
1690 KUNIT_EXPECT_PTR_EQ(test, tunnel->src_port, nhi); in tb_test_tunnel_dma()
1691 KUNIT_EXPECT_PTR_EQ(test, tunnel->dst_port, port); in tb_test_tunnel_dma()
1692 KUNIT_ASSERT_EQ(test, tunnel->npaths, 2); in tb_test_tunnel_dma()
1694 KUNIT_ASSERT_EQ(test, tunnel->paths[0]->path_length, 1); in tb_test_tunnel_dma()
1695 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[0]->hops[0].in_port, port); in tb_test_tunnel_dma()
1696 KUNIT_EXPECT_EQ(test, tunnel->paths[0]->hops[0].in_hop_index, 8); in tb_test_tunnel_dma()
1697 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[0]->hops[0].out_port, nhi); in tb_test_tunnel_dma()
1698 KUNIT_EXPECT_EQ(test, tunnel->paths[0]->hops[0].next_hop_index, 1); in tb_test_tunnel_dma()
1700 KUNIT_ASSERT_EQ(test, tunnel->paths[1]->path_length, 1); in tb_test_tunnel_dma()
1701 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[1]->hops[0].in_port, nhi); in tb_test_tunnel_dma()
1702 KUNIT_EXPECT_EQ(test, tunnel->paths[1]->hops[0].in_hop_index, 1); in tb_test_tunnel_dma()
1703 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[1]->hops[0].out_port, port); in tb_test_tunnel_dma()
1704 KUNIT_EXPECT_EQ(test, tunnel->paths[1]->hops[0].next_hop_index, 8); in tb_test_tunnel_dma()
1709 static void tb_test_tunnel_dma_rx(struct kunit *test) in tb_test_tunnel_dma_rx() argument
1726 host = alloc_host(test); in tb_test_tunnel_dma_rx()
1731 KUNIT_ASSERT_TRUE(test, tunnel != NULL); in tb_test_tunnel_dma_rx()
1732 KUNIT_EXPECT_EQ(test, tunnel->type, TB_TUNNEL_DMA); in tb_test_tunnel_dma_rx()
1733 KUNIT_EXPECT_PTR_EQ(test, tunnel->src_port, nhi); in tb_test_tunnel_dma_rx()
1734 KUNIT_EXPECT_PTR_EQ(test, tunnel->dst_port, port); in tb_test_tunnel_dma_rx()
1735 KUNIT_ASSERT_EQ(test, tunnel->npaths, 1); in tb_test_tunnel_dma_rx()
1737 KUNIT_ASSERT_EQ(test, tunnel->paths[0]->path_length, 1); in tb_test_tunnel_dma_rx()
1738 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[0]->hops[0].in_port, port); in tb_test_tunnel_dma_rx()
1739 KUNIT_EXPECT_EQ(test, tunnel->paths[0]->hops[0].in_hop_index, 15); in tb_test_tunnel_dma_rx()
1740 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[0]->hops[0].out_port, nhi); in tb_test_tunnel_dma_rx()
1741 KUNIT_EXPECT_EQ(test, tunnel->paths[0]->hops[0].next_hop_index, 2); in tb_test_tunnel_dma_rx()
1746 static void tb_test_tunnel_dma_tx(struct kunit *test) in tb_test_tunnel_dma_tx() argument
1763 host = alloc_host(test); in tb_test_tunnel_dma_tx()
1768 KUNIT_ASSERT_TRUE(test, tunnel != NULL); in tb_test_tunnel_dma_tx()
1769 KUNIT_EXPECT_EQ(test, tunnel->type, TB_TUNNEL_DMA); in tb_test_tunnel_dma_tx()
1770 KUNIT_EXPECT_PTR_EQ(test, tunnel->src_port, nhi); in tb_test_tunnel_dma_tx()
1771 KUNIT_EXPECT_PTR_EQ(test, tunnel->dst_port, port); in tb_test_tunnel_dma_tx()
1772 KUNIT_ASSERT_EQ(test, tunnel->npaths, 1); in tb_test_tunnel_dma_tx()
1774 KUNIT_ASSERT_EQ(test, tunnel->paths[0]->path_length, 1); in tb_test_tunnel_dma_tx()
1775 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[0]->hops[0].in_port, nhi); in tb_test_tunnel_dma_tx()
1776 KUNIT_EXPECT_EQ(test, tunnel->paths[0]->hops[0].in_hop_index, 2); in tb_test_tunnel_dma_tx()
1777 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[0]->hops[0].out_port, port); in tb_test_tunnel_dma_tx()
1778 KUNIT_EXPECT_EQ(test, tunnel->paths[0]->hops[0].next_hop_index, 15); in tb_test_tunnel_dma_tx()
1783 static void tb_test_tunnel_dma_chain(struct kunit *test) in tb_test_tunnel_dma_chain() argument
1807 host = alloc_host(test); in tb_test_tunnel_dma_chain()
1808 dev1 = alloc_dev_default(test, host, 0x1, true); in tb_test_tunnel_dma_chain()
1809 dev2 = alloc_dev_default(test, dev1, 0x701, true); in tb_test_tunnel_dma_chain()
1814 KUNIT_ASSERT_TRUE(test, tunnel != NULL); in tb_test_tunnel_dma_chain()
1815 KUNIT_EXPECT_EQ(test, tunnel->type, TB_TUNNEL_DMA); in tb_test_tunnel_dma_chain()
1816 KUNIT_EXPECT_PTR_EQ(test, tunnel->src_port, nhi); in tb_test_tunnel_dma_chain()
1817 KUNIT_EXPECT_PTR_EQ(test, tunnel->dst_port, port); in tb_test_tunnel_dma_chain()
1818 KUNIT_ASSERT_EQ(test, tunnel->npaths, 2); in tb_test_tunnel_dma_chain()
1820 KUNIT_ASSERT_EQ(test, tunnel->paths[0]->path_length, 3); in tb_test_tunnel_dma_chain()
1821 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[0]->hops[0].in_port, port); in tb_test_tunnel_dma_chain()
1822 KUNIT_EXPECT_EQ(test, tunnel->paths[0]->hops[0].in_hop_index, 8); in tb_test_tunnel_dma_chain()
1823 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[0]->hops[0].out_port, in tb_test_tunnel_dma_chain()
1825 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[0]->hops[1].in_port, in tb_test_tunnel_dma_chain()
1827 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[0]->hops[1].out_port, in tb_test_tunnel_dma_chain()
1829 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[0]->hops[2].in_port, in tb_test_tunnel_dma_chain()
1831 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[0]->hops[2].out_port, nhi); in tb_test_tunnel_dma_chain()
1832 KUNIT_EXPECT_EQ(test, tunnel->paths[0]->hops[2].next_hop_index, 1); in tb_test_tunnel_dma_chain()
1834 KUNIT_ASSERT_EQ(test, tunnel->paths[1]->path_length, 3); in tb_test_tunnel_dma_chain()
1835 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[1]->hops[0].in_port, nhi); in tb_test_tunnel_dma_chain()
1836 KUNIT_EXPECT_EQ(test, tunnel->paths[1]->hops[0].in_hop_index, 1); in tb_test_tunnel_dma_chain()
1837 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[1]->hops[1].in_port, in tb_test_tunnel_dma_chain()
1839 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[1]->hops[1].out_port, in tb_test_tunnel_dma_chain()
1841 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[1]->hops[2].in_port, in tb_test_tunnel_dma_chain()
1843 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[1]->hops[2].out_port, port); in tb_test_tunnel_dma_chain()
1844 KUNIT_EXPECT_EQ(test, tunnel->paths[1]->hops[2].next_hop_index, 8); in tb_test_tunnel_dma_chain()
1849 static void tb_test_tunnel_dma_match(struct kunit *test) in tb_test_tunnel_dma_match() argument
1855 host = alloc_host(test); in tb_test_tunnel_dma_match()
1860 KUNIT_ASSERT_TRUE(test, tunnel != NULL); in tb_test_tunnel_dma_match()
1862 KUNIT_ASSERT_TRUE(test, tb_tunnel_match_dma(tunnel, 15, 1, 15, 1)); in tb_test_tunnel_dma_match()
1863 KUNIT_ASSERT_FALSE(test, tb_tunnel_match_dma(tunnel, 8, 1, 15, 1)); in tb_test_tunnel_dma_match()
1864 KUNIT_ASSERT_TRUE(test, tb_tunnel_match_dma(tunnel, -1, -1, 15, 1)); in tb_test_tunnel_dma_match()
1865 KUNIT_ASSERT_TRUE(test, tb_tunnel_match_dma(tunnel, 15, 1, -1, -1)); in tb_test_tunnel_dma_match()
1866 KUNIT_ASSERT_TRUE(test, tb_tunnel_match_dma(tunnel, 15, -1, -1, -1)); in tb_test_tunnel_dma_match()
1867 KUNIT_ASSERT_TRUE(test, tb_tunnel_match_dma(tunnel, -1, 1, -1, -1)); in tb_test_tunnel_dma_match()
1868 KUNIT_ASSERT_TRUE(test, tb_tunnel_match_dma(tunnel, -1, -1, 15, -1)); in tb_test_tunnel_dma_match()
1869 KUNIT_ASSERT_TRUE(test, tb_tunnel_match_dma(tunnel, -1, -1, -1, 1)); in tb_test_tunnel_dma_match()
1870 KUNIT_ASSERT_TRUE(test, tb_tunnel_match_dma(tunnel, -1, -1, -1, -1)); in tb_test_tunnel_dma_match()
1871 KUNIT_ASSERT_FALSE(test, tb_tunnel_match_dma(tunnel, 8, -1, 8, -1)); in tb_test_tunnel_dma_match()
1876 KUNIT_ASSERT_TRUE(test, tunnel != NULL); in tb_test_tunnel_dma_match()
1877 KUNIT_ASSERT_TRUE(test, tb_tunnel_match_dma(tunnel, 15, 1, -1, -1)); in tb_test_tunnel_dma_match()
1878 KUNIT_ASSERT_TRUE(test, tb_tunnel_match_dma(tunnel, 15, -1, -1, -1)); in tb_test_tunnel_dma_match()
1879 KUNIT_ASSERT_TRUE(test, tb_tunnel_match_dma(tunnel, -1, 1, -1, -1)); in tb_test_tunnel_dma_match()
1880 KUNIT_ASSERT_TRUE(test, tb_tunnel_match_dma(tunnel, -1, -1, -1, -1)); in tb_test_tunnel_dma_match()
1881 KUNIT_ASSERT_FALSE(test, tb_tunnel_match_dma(tunnel, 15, 1, 15, 1)); in tb_test_tunnel_dma_match()
1882 KUNIT_ASSERT_FALSE(test, tb_tunnel_match_dma(tunnel, -1, -1, 15, 1)); in tb_test_tunnel_dma_match()
1883 KUNIT_ASSERT_FALSE(test, tb_tunnel_match_dma(tunnel, 15, 11, -1, -1)); in tb_test_tunnel_dma_match()
1888 KUNIT_ASSERT_TRUE(test, tunnel != NULL); in tb_test_tunnel_dma_match()
1889 KUNIT_ASSERT_TRUE(test, tb_tunnel_match_dma(tunnel, -1, -1, 15, 11)); in tb_test_tunnel_dma_match()
1890 KUNIT_ASSERT_TRUE(test, tb_tunnel_match_dma(tunnel, -1, -1, 15, -1)); in tb_test_tunnel_dma_match()
1891 KUNIT_ASSERT_TRUE(test, tb_tunnel_match_dma(tunnel, -1, -1, -1, 11)); in tb_test_tunnel_dma_match()
1892 KUNIT_ASSERT_TRUE(test, tb_tunnel_match_dma(tunnel, -1, -1, -1, -1)); in tb_test_tunnel_dma_match()
1893 KUNIT_ASSERT_FALSE(test, tb_tunnel_match_dma(tunnel, -1, -1, 15, 1)); in tb_test_tunnel_dma_match()
1894 KUNIT_ASSERT_FALSE(test, tb_tunnel_match_dma(tunnel, -1, -1, 10, 11)); in tb_test_tunnel_dma_match()
1895 KUNIT_ASSERT_FALSE(test, tb_tunnel_match_dma(tunnel, 15, 11, -1, -1)); in tb_test_tunnel_dma_match()
1900 static void tb_test_credit_alloc_legacy_not_bonded(struct kunit *test) in tb_test_credit_alloc_legacy_not_bonded() argument
1907 host = alloc_host(test); in tb_test_credit_alloc_legacy_not_bonded()
1908 dev = alloc_dev_default(test, host, 0x1, false); in tb_test_credit_alloc_legacy_not_bonded()
1913 KUNIT_ASSERT_TRUE(test, tunnel != NULL); in tb_test_credit_alloc_legacy_not_bonded()
1914 KUNIT_ASSERT_EQ(test, tunnel->npaths, (size_t)2); in tb_test_credit_alloc_legacy_not_bonded()
1917 KUNIT_ASSERT_EQ(test, path->path_length, 2); in tb_test_credit_alloc_legacy_not_bonded()
1918 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in tb_test_credit_alloc_legacy_not_bonded()
1919 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 7U); in tb_test_credit_alloc_legacy_not_bonded()
1920 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in tb_test_credit_alloc_legacy_not_bonded()
1921 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 16U); in tb_test_credit_alloc_legacy_not_bonded()
1924 KUNIT_ASSERT_EQ(test, path->path_length, 2); in tb_test_credit_alloc_legacy_not_bonded()
1925 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in tb_test_credit_alloc_legacy_not_bonded()
1926 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 7U); in tb_test_credit_alloc_legacy_not_bonded()
1927 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in tb_test_credit_alloc_legacy_not_bonded()
1928 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 16U); in tb_test_credit_alloc_legacy_not_bonded()
1933 static void tb_test_credit_alloc_legacy_bonded(struct kunit *test) in tb_test_credit_alloc_legacy_bonded() argument
1940 host = alloc_host(test); in tb_test_credit_alloc_legacy_bonded()
1941 dev = alloc_dev_default(test, host, 0x1, true); in tb_test_credit_alloc_legacy_bonded()
1946 KUNIT_ASSERT_TRUE(test, tunnel != NULL); in tb_test_credit_alloc_legacy_bonded()
1947 KUNIT_ASSERT_EQ(test, tunnel->npaths, (size_t)2); in tb_test_credit_alloc_legacy_bonded()
1950 KUNIT_ASSERT_EQ(test, path->path_length, 2); in tb_test_credit_alloc_legacy_bonded()
1951 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in tb_test_credit_alloc_legacy_bonded()
1952 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 7U); in tb_test_credit_alloc_legacy_bonded()
1953 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in tb_test_credit_alloc_legacy_bonded()
1954 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 32U); in tb_test_credit_alloc_legacy_bonded()
1957 KUNIT_ASSERT_EQ(test, path->path_length, 2); in tb_test_credit_alloc_legacy_bonded()
1958 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in tb_test_credit_alloc_legacy_bonded()
1959 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 7U); in tb_test_credit_alloc_legacy_bonded()
1960 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in tb_test_credit_alloc_legacy_bonded()
1961 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 32U); in tb_test_credit_alloc_legacy_bonded()
1966 static void tb_test_credit_alloc_pcie(struct kunit *test) in tb_test_credit_alloc_pcie() argument
1973 host = alloc_host_usb4(test); in tb_test_credit_alloc_pcie()
1974 dev = alloc_dev_usb4(test, host, 0x1, true); in tb_test_credit_alloc_pcie()
1979 KUNIT_ASSERT_TRUE(test, tunnel != NULL); in tb_test_credit_alloc_pcie()
1980 KUNIT_ASSERT_EQ(test, tunnel->npaths, (size_t)2); in tb_test_credit_alloc_pcie()
1983 KUNIT_ASSERT_EQ(test, path->path_length, 2); in tb_test_credit_alloc_pcie()
1984 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in tb_test_credit_alloc_pcie()
1985 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 7U); in tb_test_credit_alloc_pcie()
1986 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in tb_test_credit_alloc_pcie()
1987 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 32U); in tb_test_credit_alloc_pcie()
1990 KUNIT_ASSERT_EQ(test, path->path_length, 2); in tb_test_credit_alloc_pcie()
1991 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in tb_test_credit_alloc_pcie()
1992 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 7U); in tb_test_credit_alloc_pcie()
1993 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in tb_test_credit_alloc_pcie()
1994 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 64U); in tb_test_credit_alloc_pcie()
1999 static void tb_test_credit_alloc_dp(struct kunit *test) in tb_test_credit_alloc_dp() argument
2006 host = alloc_host_usb4(test); in tb_test_credit_alloc_dp()
2007 dev = alloc_dev_usb4(test, host, 0x1, true); in tb_test_credit_alloc_dp()
2013 KUNIT_ASSERT_TRUE(test, tunnel != NULL); in tb_test_credit_alloc_dp()
2014 KUNIT_ASSERT_EQ(test, tunnel->npaths, (size_t)3); in tb_test_credit_alloc_dp()
2018 KUNIT_ASSERT_EQ(test, path->path_length, 2); in tb_test_credit_alloc_dp()
2019 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 12U); in tb_test_credit_alloc_dp()
2020 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 0U); in tb_test_credit_alloc_dp()
2021 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 18U); in tb_test_credit_alloc_dp()
2022 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 0U); in tb_test_credit_alloc_dp()
2026 KUNIT_ASSERT_EQ(test, path->path_length, 2); in tb_test_credit_alloc_dp()
2027 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in tb_test_credit_alloc_dp()
2028 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 1U); in tb_test_credit_alloc_dp()
2029 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in tb_test_credit_alloc_dp()
2030 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 1U); in tb_test_credit_alloc_dp()
2034 KUNIT_ASSERT_EQ(test, path->path_length, 2); in tb_test_credit_alloc_dp()
2035 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in tb_test_credit_alloc_dp()
2036 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 1U); in tb_test_credit_alloc_dp()
2037 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in tb_test_credit_alloc_dp()
2038 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 1U); in tb_test_credit_alloc_dp()
2043 static void tb_test_credit_alloc_usb3(struct kunit *test) in tb_test_credit_alloc_usb3() argument
2050 host = alloc_host_usb4(test); in tb_test_credit_alloc_usb3()
2051 dev = alloc_dev_usb4(test, host, 0x1, true); in tb_test_credit_alloc_usb3()
2056 KUNIT_ASSERT_TRUE(test, tunnel != NULL); in tb_test_credit_alloc_usb3()
2057 KUNIT_ASSERT_EQ(test, tunnel->npaths, (size_t)2); in tb_test_credit_alloc_usb3()
2060 KUNIT_ASSERT_EQ(test, path->path_length, 2); in tb_test_credit_alloc_usb3()
2061 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in tb_test_credit_alloc_usb3()
2062 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 7U); in tb_test_credit_alloc_usb3()
2063 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in tb_test_credit_alloc_usb3()
2064 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 14U); in tb_test_credit_alloc_usb3()
2067 KUNIT_ASSERT_EQ(test, path->path_length, 2); in tb_test_credit_alloc_usb3()
2068 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in tb_test_credit_alloc_usb3()
2069 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 7U); in tb_test_credit_alloc_usb3()
2070 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in tb_test_credit_alloc_usb3()
2071 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 32U); in tb_test_credit_alloc_usb3()
2076 static void tb_test_credit_alloc_dma(struct kunit *test) in tb_test_credit_alloc_dma() argument
2083 host = alloc_host_usb4(test); in tb_test_credit_alloc_dma()
2084 dev = alloc_dev_usb4(test, host, 0x1, true); in tb_test_credit_alloc_dma()
2090 KUNIT_ASSERT_TRUE(test, tunnel != NULL); in tb_test_credit_alloc_dma()
2091 KUNIT_ASSERT_EQ(test, tunnel->npaths, (size_t)2); in tb_test_credit_alloc_dma()
2095 KUNIT_ASSERT_EQ(test, path->path_length, 2); in tb_test_credit_alloc_dma()
2096 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in tb_test_credit_alloc_dma()
2097 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 14U); in tb_test_credit_alloc_dma()
2098 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in tb_test_credit_alloc_dma()
2099 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 14U); in tb_test_credit_alloc_dma()
2103 KUNIT_ASSERT_EQ(test, path->path_length, 2); in tb_test_credit_alloc_dma()
2104 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in tb_test_credit_alloc_dma()
2105 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 0U); in tb_test_credit_alloc_dma()
2106 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in tb_test_credit_alloc_dma()
2107 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 14U); in tb_test_credit_alloc_dma()
2112 static void tb_test_credit_alloc_dma_multiple(struct kunit *test) in tb_test_credit_alloc_dma_multiple() argument
2119 host = alloc_host_usb4(test); in tb_test_credit_alloc_dma_multiple()
2120 dev = alloc_dev_usb4(test, host, 0x1, true); in tb_test_credit_alloc_dma_multiple()
2144 KUNIT_ASSERT_TRUE(test, tunnel1 != NULL); in tb_test_credit_alloc_dma_multiple()
2145 KUNIT_ASSERT_EQ(test, tunnel1->npaths, (size_t)2); in tb_test_credit_alloc_dma_multiple()
2148 KUNIT_ASSERT_EQ(test, path->path_length, 2); in tb_test_credit_alloc_dma_multiple()
2149 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in tb_test_credit_alloc_dma_multiple()
2150 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 14U); in tb_test_credit_alloc_dma_multiple()
2151 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in tb_test_credit_alloc_dma_multiple()
2152 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 14U); in tb_test_credit_alloc_dma_multiple()
2155 KUNIT_ASSERT_EQ(test, path->path_length, 2); in tb_test_credit_alloc_dma_multiple()
2156 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in tb_test_credit_alloc_dma_multiple()
2157 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 0U); in tb_test_credit_alloc_dma_multiple()
2158 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in tb_test_credit_alloc_dma_multiple()
2159 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 14U); in tb_test_credit_alloc_dma_multiple()
2162 KUNIT_ASSERT_TRUE(test, tunnel2 != NULL); in tb_test_credit_alloc_dma_multiple()
2163 KUNIT_ASSERT_EQ(test, tunnel2->npaths, (size_t)2); in tb_test_credit_alloc_dma_multiple()
2166 KUNIT_ASSERT_EQ(test, path->path_length, 2); in tb_test_credit_alloc_dma_multiple()
2167 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in tb_test_credit_alloc_dma_multiple()
2168 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 14U); in tb_test_credit_alloc_dma_multiple()
2169 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in tb_test_credit_alloc_dma_multiple()
2170 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 1U); in tb_test_credit_alloc_dma_multiple()
2173 KUNIT_ASSERT_EQ(test, path->path_length, 2); in tb_test_credit_alloc_dma_multiple()
2174 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in tb_test_credit_alloc_dma_multiple()
2175 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 0U); in tb_test_credit_alloc_dma_multiple()
2176 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in tb_test_credit_alloc_dma_multiple()
2177 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 1U); in tb_test_credit_alloc_dma_multiple()
2180 KUNIT_ASSERT_TRUE(test, tunnel3 == NULL); in tb_test_credit_alloc_dma_multiple()
2189 KUNIT_ASSERT_TRUE(test, tunnel3 != NULL); in tb_test_credit_alloc_dma_multiple()
2192 KUNIT_ASSERT_EQ(test, path->path_length, 2); in tb_test_credit_alloc_dma_multiple()
2193 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in tb_test_credit_alloc_dma_multiple()
2194 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 14U); in tb_test_credit_alloc_dma_multiple()
2195 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in tb_test_credit_alloc_dma_multiple()
2196 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 14U); in tb_test_credit_alloc_dma_multiple()
2199 KUNIT_ASSERT_EQ(test, path->path_length, 2); in tb_test_credit_alloc_dma_multiple()
2200 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in tb_test_credit_alloc_dma_multiple()
2201 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 0U); in tb_test_credit_alloc_dma_multiple()
2202 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in tb_test_credit_alloc_dma_multiple()
2203 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 14U); in tb_test_credit_alloc_dma_multiple()
2209 static struct tb_tunnel *TB_TEST_PCIE_TUNNEL(struct kunit *test, in TB_TEST_PCIE_TUNNEL() argument
2219 KUNIT_ASSERT_TRUE(test, pcie_tunnel != NULL); in TB_TEST_PCIE_TUNNEL()
2220 KUNIT_ASSERT_EQ(test, pcie_tunnel->npaths, (size_t)2); in TB_TEST_PCIE_TUNNEL()
2223 KUNIT_ASSERT_EQ(test, path->path_length, 2); in TB_TEST_PCIE_TUNNEL()
2224 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in TB_TEST_PCIE_TUNNEL()
2225 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 7U); in TB_TEST_PCIE_TUNNEL()
2226 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in TB_TEST_PCIE_TUNNEL()
2227 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 32U); in TB_TEST_PCIE_TUNNEL()
2230 KUNIT_ASSERT_EQ(test, path->path_length, 2); in TB_TEST_PCIE_TUNNEL()
2231 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in TB_TEST_PCIE_TUNNEL()
2232 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 7U); in TB_TEST_PCIE_TUNNEL()
2233 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in TB_TEST_PCIE_TUNNEL()
2234 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 64U); in TB_TEST_PCIE_TUNNEL()
2239 static struct tb_tunnel *TB_TEST_DP_TUNNEL1(struct kunit *test, in TB_TEST_DP_TUNNEL1() argument
2249 KUNIT_ASSERT_TRUE(test, dp_tunnel1 != NULL); in TB_TEST_DP_TUNNEL1()
2250 KUNIT_ASSERT_EQ(test, dp_tunnel1->npaths, (size_t)3); in TB_TEST_DP_TUNNEL1()
2253 KUNIT_ASSERT_EQ(test, path->path_length, 2); in TB_TEST_DP_TUNNEL1()
2254 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 12U); in TB_TEST_DP_TUNNEL1()
2255 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 0U); in TB_TEST_DP_TUNNEL1()
2256 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 18U); in TB_TEST_DP_TUNNEL1()
2257 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 0U); in TB_TEST_DP_TUNNEL1()
2260 KUNIT_ASSERT_EQ(test, path->path_length, 2); in TB_TEST_DP_TUNNEL1()
2261 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in TB_TEST_DP_TUNNEL1()
2262 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 1U); in TB_TEST_DP_TUNNEL1()
2263 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in TB_TEST_DP_TUNNEL1()
2264 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 1U); in TB_TEST_DP_TUNNEL1()
2267 KUNIT_ASSERT_EQ(test, path->path_length, 2); in TB_TEST_DP_TUNNEL1()
2268 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in TB_TEST_DP_TUNNEL1()
2269 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 1U); in TB_TEST_DP_TUNNEL1()
2270 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in TB_TEST_DP_TUNNEL1()
2271 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 1U); in TB_TEST_DP_TUNNEL1()
2276 static struct tb_tunnel *TB_TEST_DP_TUNNEL2(struct kunit *test, in TB_TEST_DP_TUNNEL2() argument
2286 KUNIT_ASSERT_TRUE(test, dp_tunnel2 != NULL); in TB_TEST_DP_TUNNEL2()
2287 KUNIT_ASSERT_EQ(test, dp_tunnel2->npaths, (size_t)3); in TB_TEST_DP_TUNNEL2()
2290 KUNIT_ASSERT_EQ(test, path->path_length, 2); in TB_TEST_DP_TUNNEL2()
2291 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 12U); in TB_TEST_DP_TUNNEL2()
2292 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 0U); in TB_TEST_DP_TUNNEL2()
2293 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 18U); in TB_TEST_DP_TUNNEL2()
2294 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 0U); in TB_TEST_DP_TUNNEL2()
2297 KUNIT_ASSERT_EQ(test, path->path_length, 2); in TB_TEST_DP_TUNNEL2()
2298 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in TB_TEST_DP_TUNNEL2()
2299 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 1U); in TB_TEST_DP_TUNNEL2()
2300 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in TB_TEST_DP_TUNNEL2()
2301 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 1U); in TB_TEST_DP_TUNNEL2()
2304 KUNIT_ASSERT_EQ(test, path->path_length, 2); in TB_TEST_DP_TUNNEL2()
2305 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in TB_TEST_DP_TUNNEL2()
2306 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 1U); in TB_TEST_DP_TUNNEL2()
2307 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in TB_TEST_DP_TUNNEL2()
2308 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 1U); in TB_TEST_DP_TUNNEL2()
2313 static struct tb_tunnel *TB_TEST_USB3_TUNNEL(struct kunit *test, in TB_TEST_USB3_TUNNEL() argument
2323 KUNIT_ASSERT_TRUE(test, usb3_tunnel != NULL); in TB_TEST_USB3_TUNNEL()
2324 KUNIT_ASSERT_EQ(test, usb3_tunnel->npaths, (size_t)2); in TB_TEST_USB3_TUNNEL()
2327 KUNIT_ASSERT_EQ(test, path->path_length, 2); in TB_TEST_USB3_TUNNEL()
2328 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in TB_TEST_USB3_TUNNEL()
2329 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 7U); in TB_TEST_USB3_TUNNEL()
2330 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in TB_TEST_USB3_TUNNEL()
2331 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 14U); in TB_TEST_USB3_TUNNEL()
2334 KUNIT_ASSERT_EQ(test, path->path_length, 2); in TB_TEST_USB3_TUNNEL()
2335 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in TB_TEST_USB3_TUNNEL()
2336 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 7U); in TB_TEST_USB3_TUNNEL()
2337 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in TB_TEST_USB3_TUNNEL()
2338 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 32U); in TB_TEST_USB3_TUNNEL()
2343 static struct tb_tunnel *TB_TEST_DMA_TUNNEL1(struct kunit *test, in TB_TEST_DMA_TUNNEL1() argument
2353 KUNIT_ASSERT_TRUE(test, dma_tunnel1 != NULL); in TB_TEST_DMA_TUNNEL1()
2354 KUNIT_ASSERT_EQ(test, dma_tunnel1->npaths, (size_t)2); in TB_TEST_DMA_TUNNEL1()
2357 KUNIT_ASSERT_EQ(test, path->path_length, 2); in TB_TEST_DMA_TUNNEL1()
2358 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in TB_TEST_DMA_TUNNEL1()
2359 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 14U); in TB_TEST_DMA_TUNNEL1()
2360 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in TB_TEST_DMA_TUNNEL1()
2361 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 14U); in TB_TEST_DMA_TUNNEL1()
2364 KUNIT_ASSERT_EQ(test, path->path_length, 2); in TB_TEST_DMA_TUNNEL1()
2365 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in TB_TEST_DMA_TUNNEL1()
2366 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 0U); in TB_TEST_DMA_TUNNEL1()
2367 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in TB_TEST_DMA_TUNNEL1()
2368 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 14U); in TB_TEST_DMA_TUNNEL1()
2373 static struct tb_tunnel *TB_TEST_DMA_TUNNEL2(struct kunit *test, in TB_TEST_DMA_TUNNEL2() argument
2383 KUNIT_ASSERT_TRUE(test, dma_tunnel2 != NULL); in TB_TEST_DMA_TUNNEL2()
2384 KUNIT_ASSERT_EQ(test, dma_tunnel2->npaths, (size_t)2); in TB_TEST_DMA_TUNNEL2()
2387 KUNIT_ASSERT_EQ(test, path->path_length, 2); in TB_TEST_DMA_TUNNEL2()
2388 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in TB_TEST_DMA_TUNNEL2()
2389 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 14U); in TB_TEST_DMA_TUNNEL2()
2390 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in TB_TEST_DMA_TUNNEL2()
2391 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 1U); in TB_TEST_DMA_TUNNEL2()
2394 KUNIT_ASSERT_EQ(test, path->path_length, 2); in TB_TEST_DMA_TUNNEL2()
2395 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in TB_TEST_DMA_TUNNEL2()
2396 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 0U); in TB_TEST_DMA_TUNNEL2()
2397 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in TB_TEST_DMA_TUNNEL2()
2398 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 1U); in TB_TEST_DMA_TUNNEL2()
2403 static void tb_test_credit_alloc_all(struct kunit *test) in tb_test_credit_alloc_all() argument
2415 host = alloc_host_usb4(test); in tb_test_credit_alloc_all()
2416 dev = alloc_dev_usb4(test, host, 0x1, true); in tb_test_credit_alloc_all()
2418 pcie_tunnel = TB_TEST_PCIE_TUNNEL(test, host, dev); in tb_test_credit_alloc_all()
2419 dp_tunnel1 = TB_TEST_DP_TUNNEL1(test, host, dev); in tb_test_credit_alloc_all()
2420 dp_tunnel2 = TB_TEST_DP_TUNNEL2(test, host, dev); in tb_test_credit_alloc_all()
2421 usb3_tunnel = TB_TEST_USB3_TUNNEL(test, host, dev); in tb_test_credit_alloc_all()
2422 dma_tunnel1 = TB_TEST_DMA_TUNNEL1(test, host, dev); in tb_test_credit_alloc_all()
2423 dma_tunnel2 = TB_TEST_DMA_TUNNEL2(test, host, dev); in tb_test_credit_alloc_all()
2493 static void tb_test_property_parse(struct kunit *test) in tb_test_property_parse() argument
2499 KUNIT_ASSERT_TRUE(test, dir != NULL); in tb_test_property_parse()
2502 KUNIT_ASSERT_TRUE(test, !p); in tb_test_property_parse()
2505 KUNIT_ASSERT_TRUE(test, p != NULL); in tb_test_property_parse()
2506 KUNIT_EXPECT_STREQ(test, p->value.text, "Apple Inc."); in tb_test_property_parse()
2509 KUNIT_ASSERT_TRUE(test, p != NULL); in tb_test_property_parse()
2510 KUNIT_EXPECT_EQ(test, p->value.immediate, 0xa27); in tb_test_property_parse()
2513 KUNIT_ASSERT_TRUE(test, p != NULL); in tb_test_property_parse()
2514 KUNIT_EXPECT_STREQ(test, p->value.text, "Macintosh"); in tb_test_property_parse()
2517 KUNIT_ASSERT_TRUE(test, p != NULL); in tb_test_property_parse()
2518 KUNIT_EXPECT_EQ(test, p->value.immediate, 0xa); in tb_test_property_parse()
2521 KUNIT_ASSERT_TRUE(test, !p); in tb_test_property_parse()
2524 KUNIT_ASSERT_TRUE(test, p != NULL); in tb_test_property_parse()
2527 KUNIT_EXPECT_TRUE(test, uuid_equal(network_dir->uuid, &network_dir_uuid)); in tb_test_property_parse()
2530 KUNIT_ASSERT_TRUE(test, p != NULL); in tb_test_property_parse()
2531 KUNIT_EXPECT_EQ(test, p->value.immediate, 0x1); in tb_test_property_parse()
2534 KUNIT_ASSERT_TRUE(test, p != NULL); in tb_test_property_parse()
2535 KUNIT_EXPECT_EQ(test, p->value.immediate, 0x1); in tb_test_property_parse()
2538 KUNIT_ASSERT_TRUE(test, p != NULL); in tb_test_property_parse()
2539 KUNIT_EXPECT_EQ(test, p->value.immediate, 0x1); in tb_test_property_parse()
2542 KUNIT_ASSERT_TRUE(test, p != NULL); in tb_test_property_parse()
2543 KUNIT_EXPECT_EQ(test, p->value.immediate, 0x0); in tb_test_property_parse()
2546 KUNIT_EXPECT_TRUE(test, !p); in tb_test_property_parse()
2548 KUNIT_EXPECT_TRUE(test, !p); in tb_test_property_parse()
2553 static void tb_test_property_format(struct kunit *test) in tb_test_property_format() argument
2561 KUNIT_ASSERT_TRUE(test, dir != NULL); in tb_test_property_format()
2564 KUNIT_ASSERT_EQ(test, ret, ARRAY_SIZE(root_directory)); in tb_test_property_format()
2568 block = kunit_kzalloc(test, block_len * sizeof(u32), GFP_KERNEL); in tb_test_property_format()
2569 KUNIT_ASSERT_TRUE(test, block != NULL); in tb_test_property_format()
2572 KUNIT_EXPECT_EQ(test, ret, 0); in tb_test_property_format()
2575 KUNIT_EXPECT_EQ(test, root_directory[i], block[i]); in tb_test_property_format()
2580 static void compare_dirs(struct kunit *test, struct tb_property_dir *d1, in compare_dirs() argument
2587 KUNIT_ASSERT_TRUE(test, d2->uuid != NULL); in compare_dirs()
2588 KUNIT_ASSERT_TRUE(test, uuid_equal(d1->uuid, d2->uuid)); in compare_dirs()
2590 KUNIT_ASSERT_TRUE(test, d2->uuid == NULL); in compare_dirs()
2596 KUNIT_ASSERT_NE(test, n1, 0); in compare_dirs()
2601 KUNIT_ASSERT_NE(test, n2, 0); in compare_dirs()
2603 KUNIT_ASSERT_EQ(test, n1, n2); in compare_dirs()
2609 KUNIT_ASSERT_TRUE(test, p1 != NULL); in compare_dirs()
2611 KUNIT_ASSERT_TRUE(test, p2 != NULL); in compare_dirs()
2613 KUNIT_ASSERT_STREQ(test, &p1->key[0], &p2->key[0]); in compare_dirs()
2614 KUNIT_ASSERT_EQ(test, p1->type, p2->type); in compare_dirs()
2615 KUNIT_ASSERT_EQ(test, p1->length, p2->length); in compare_dirs()
2619 KUNIT_ASSERT_TRUE(test, p1->value.dir != NULL); in compare_dirs()
2620 KUNIT_ASSERT_TRUE(test, p2->value.dir != NULL); in compare_dirs()
2621 compare_dirs(test, p1->value.dir, p2->value.dir); in compare_dirs()
2625 KUNIT_ASSERT_TRUE(test, p1->value.data != NULL); in compare_dirs()
2626 KUNIT_ASSERT_TRUE(test, p2->value.data != NULL); in compare_dirs()
2627 KUNIT_ASSERT_TRUE(test, in compare_dirs()
2634 KUNIT_ASSERT_TRUE(test, p1->value.text != NULL); in compare_dirs()
2635 KUNIT_ASSERT_TRUE(test, p2->value.text != NULL); in compare_dirs()
2636 KUNIT_ASSERT_STREQ(test, p1->value.text, p2->value.text); in compare_dirs()
2640 KUNIT_ASSERT_EQ(test, p1->value.immediate, in compare_dirs()
2644 KUNIT_FAIL(test, "unexpected property type"); in compare_dirs()
2650 static void tb_test_property_copy(struct kunit *test) in tb_test_property_copy() argument
2657 KUNIT_ASSERT_TRUE(test, src != NULL); in tb_test_property_copy()
2660 KUNIT_ASSERT_TRUE(test, dst != NULL); in tb_test_property_copy()
2663 compare_dirs(test, src, dst); in tb_test_property_copy()
2667 KUNIT_ASSERT_EQ(test, ret, ARRAY_SIZE(root_directory)); in tb_test_property_copy()
2669 block = kunit_kzalloc(test, sizeof(root_directory), GFP_KERNEL); in tb_test_property_copy()
2670 KUNIT_ASSERT_TRUE(test, block != NULL); in tb_test_property_copy()
2673 KUNIT_EXPECT_TRUE(test, !ret); in tb_test_property_copy()
2676 KUNIT_EXPECT_EQ(test, root_directory[i], block[i]); in tb_test_property_copy()