Lines Matching refs:test

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_without_dp(struct kunit *test, in alloc_dev_without_dp() argument
351 sw = alloc_dev_default(test, parent, route, bonded); in alloc_dev_without_dp()
385 static struct tb_switch *alloc_dev_usb4(struct kunit *test, in alloc_dev_usb4() argument
391 sw = alloc_dev_default(test, parent, route, bonded); in alloc_dev_usb4()
406 static void tb_test_path_basic(struct kunit *test) in tb_test_path_basic() argument
411 host = alloc_host(test); in tb_test_path_basic()
417 KUNIT_EXPECT_PTR_EQ(test, p, dst_port); in tb_test_path_basic()
420 KUNIT_EXPECT_TRUE(test, !p); in tb_test_path_basic()
423 static void tb_test_path_not_connected_walk(struct kunit *test) in tb_test_path_not_connected_walk() argument
428 host = alloc_host(test); in tb_test_path_not_connected_walk()
430 dev = alloc_dev_default(test, NULL, 3, true); in tb_test_path_not_connected_walk()
436 KUNIT_EXPECT_PTR_EQ(test, p, src_port); in tb_test_path_not_connected_walk()
439 KUNIT_EXPECT_PTR_EQ(test, p, &host->ports[3]); in tb_test_path_not_connected_walk()
442 KUNIT_EXPECT_TRUE(test, !p); in tb_test_path_not_connected_walk()
447 KUNIT_EXPECT_PTR_EQ(test, p, dst_port); in tb_test_path_not_connected_walk()
450 KUNIT_EXPECT_PTR_EQ(test, p, &dev->ports[1]); in tb_test_path_not_connected_walk()
453 KUNIT_EXPECT_TRUE(test, !p); in tb_test_path_not_connected_walk()
462 static void tb_test_path_single_hop_walk(struct kunit *test) in tb_test_path_single_hop_walk() argument
483 host = alloc_host(test); in tb_test_path_single_hop_walk()
484 dev = alloc_dev_default(test, host, 1, true); in tb_test_path_single_hop_walk()
493 KUNIT_EXPECT_TRUE(test, i < ARRAY_SIZE(test_data)); in tb_test_path_single_hop_walk()
494 KUNIT_EXPECT_EQ(test, tb_route(p->sw), test_data[i].route); in tb_test_path_single_hop_walk()
495 KUNIT_EXPECT_EQ(test, p->port, test_data[i].port); in tb_test_path_single_hop_walk()
496 KUNIT_EXPECT_EQ(test, (enum tb_port_type)p->config.type, in tb_test_path_single_hop_walk()
501 KUNIT_EXPECT_EQ(test, i, ARRAY_SIZE(test_data)); in tb_test_path_single_hop_walk()
505 KUNIT_EXPECT_TRUE(test, i < ARRAY_SIZE(test_data)); in tb_test_path_single_hop_walk()
506 KUNIT_EXPECT_EQ(test, tb_route(p->sw), test_data[i].route); in tb_test_path_single_hop_walk()
507 KUNIT_EXPECT_EQ(test, p->port, test_data[i].port); in tb_test_path_single_hop_walk()
508 KUNIT_EXPECT_EQ(test, (enum tb_port_type)p->config.type, in tb_test_path_single_hop_walk()
513 KUNIT_EXPECT_EQ(test, i, -1); in tb_test_path_single_hop_walk()
516 static void tb_test_path_daisy_chain_walk(struct kunit *test) in tb_test_path_daisy_chain_walk() argument
541 host = alloc_host(test); in tb_test_path_daisy_chain_walk()
542 dev1 = alloc_dev_default(test, host, 0x1, true); in tb_test_path_daisy_chain_walk()
543 dev2 = alloc_dev_default(test, dev1, 0x301, true); in tb_test_path_daisy_chain_walk()
552 KUNIT_EXPECT_TRUE(test, i < ARRAY_SIZE(test_data)); in tb_test_path_daisy_chain_walk()
553 KUNIT_EXPECT_EQ(test, tb_route(p->sw), test_data[i].route); in tb_test_path_daisy_chain_walk()
554 KUNIT_EXPECT_EQ(test, p->port, test_data[i].port); in tb_test_path_daisy_chain_walk()
555 KUNIT_EXPECT_EQ(test, (enum tb_port_type)p->config.type, in tb_test_path_daisy_chain_walk()
560 KUNIT_EXPECT_EQ(test, i, ARRAY_SIZE(test_data)); in tb_test_path_daisy_chain_walk()
564 KUNIT_EXPECT_TRUE(test, i < ARRAY_SIZE(test_data)); in tb_test_path_daisy_chain_walk()
565 KUNIT_EXPECT_EQ(test, tb_route(p->sw), test_data[i].route); in tb_test_path_daisy_chain_walk()
566 KUNIT_EXPECT_EQ(test, p->port, test_data[i].port); in tb_test_path_daisy_chain_walk()
567 KUNIT_EXPECT_EQ(test, (enum tb_port_type)p->config.type, in tb_test_path_daisy_chain_walk()
572 KUNIT_EXPECT_EQ(test, i, -1); in tb_test_path_daisy_chain_walk()
575 static void tb_test_path_simple_tree_walk(struct kunit *test) in tb_test_path_simple_tree_walk() argument
602 host = alloc_host(test); in tb_test_path_simple_tree_walk()
603 dev1 = alloc_dev_default(test, host, 0x1, true); in tb_test_path_simple_tree_walk()
604 alloc_dev_default(test, dev1, 0x301, true); in tb_test_path_simple_tree_walk()
605 dev3 = alloc_dev_default(test, dev1, 0x501, true); in tb_test_path_simple_tree_walk()
606 alloc_dev_default(test, dev1, 0x701, true); in tb_test_path_simple_tree_walk()
615 KUNIT_EXPECT_TRUE(test, i < ARRAY_SIZE(test_data)); in tb_test_path_simple_tree_walk()
616 KUNIT_EXPECT_EQ(test, tb_route(p->sw), test_data[i].route); in tb_test_path_simple_tree_walk()
617 KUNIT_EXPECT_EQ(test, p->port, test_data[i].port); in tb_test_path_simple_tree_walk()
618 KUNIT_EXPECT_EQ(test, (enum tb_port_type)p->config.type, in tb_test_path_simple_tree_walk()
623 KUNIT_EXPECT_EQ(test, i, ARRAY_SIZE(test_data)); in tb_test_path_simple_tree_walk()
627 KUNIT_EXPECT_TRUE(test, i < ARRAY_SIZE(test_data)); in tb_test_path_simple_tree_walk()
628 KUNIT_EXPECT_EQ(test, tb_route(p->sw), test_data[i].route); in tb_test_path_simple_tree_walk()
629 KUNIT_EXPECT_EQ(test, p->port, test_data[i].port); in tb_test_path_simple_tree_walk()
630 KUNIT_EXPECT_EQ(test, (enum tb_port_type)p->config.type, in tb_test_path_simple_tree_walk()
635 KUNIT_EXPECT_EQ(test, i, -1); in tb_test_path_simple_tree_walk()
638 static void tb_test_path_complex_tree_walk(struct kunit *test) in tb_test_path_complex_tree_walk() argument
681 host = alloc_host(test); in tb_test_path_complex_tree_walk()
682 dev1 = alloc_dev_default(test, host, 0x1, true); in tb_test_path_complex_tree_walk()
683 dev2 = alloc_dev_default(test, dev1, 0x301, true); in tb_test_path_complex_tree_walk()
684 dev3 = alloc_dev_with_dpin(test, dev2, 0x50301, true); in tb_test_path_complex_tree_walk()
685 alloc_dev_default(test, dev1, 0x501, true); in tb_test_path_complex_tree_walk()
686 dev5 = alloc_dev_default(test, dev1, 0x701, true); in tb_test_path_complex_tree_walk()
687 dev6 = alloc_dev_default(test, dev5, 0x70701, true); in tb_test_path_complex_tree_walk()
688 dev7 = alloc_dev_default(test, dev6, 0x3070701, true); in tb_test_path_complex_tree_walk()
689 alloc_dev_default(test, dev7, 0x303070701, true); in tb_test_path_complex_tree_walk()
690 dev9 = alloc_dev_default(test, dev7, 0x503070701, true); in tb_test_path_complex_tree_walk()
699 KUNIT_EXPECT_TRUE(test, i < ARRAY_SIZE(test_data)); in tb_test_path_complex_tree_walk()
700 KUNIT_EXPECT_EQ(test, tb_route(p->sw), test_data[i].route); in tb_test_path_complex_tree_walk()
701 KUNIT_EXPECT_EQ(test, p->port, test_data[i].port); in tb_test_path_complex_tree_walk()
702 KUNIT_EXPECT_EQ(test, (enum tb_port_type)p->config.type, in tb_test_path_complex_tree_walk()
707 KUNIT_EXPECT_EQ(test, i, ARRAY_SIZE(test_data)); in tb_test_path_complex_tree_walk()
711 KUNIT_EXPECT_TRUE(test, i < ARRAY_SIZE(test_data)); in tb_test_path_complex_tree_walk()
712 KUNIT_EXPECT_EQ(test, tb_route(p->sw), test_data[i].route); in tb_test_path_complex_tree_walk()
713 KUNIT_EXPECT_EQ(test, p->port, test_data[i].port); in tb_test_path_complex_tree_walk()
714 KUNIT_EXPECT_EQ(test, (enum tb_port_type)p->config.type, in tb_test_path_complex_tree_walk()
719 KUNIT_EXPECT_EQ(test, i, -1); in tb_test_path_complex_tree_walk()
722 static void tb_test_path_max_length_walk(struct kunit *test) in tb_test_path_max_length_walk() argument
781 host = alloc_host(test); in tb_test_path_max_length_walk()
782 dev1 = alloc_dev_default(test, host, 0x1, true); in tb_test_path_max_length_walk()
783 dev2 = alloc_dev_default(test, dev1, 0x301, true); in tb_test_path_max_length_walk()
784 dev3 = alloc_dev_default(test, dev2, 0x30301, true); in tb_test_path_max_length_walk()
785 dev4 = alloc_dev_default(test, dev3, 0x3030301, true); in tb_test_path_max_length_walk()
786 dev5 = alloc_dev_default(test, dev4, 0x303030301, true); in tb_test_path_max_length_walk()
787 dev6 = alloc_dev_with_dpin(test, dev5, 0x30303030301, true); in tb_test_path_max_length_walk()
788 dev7 = alloc_dev_default(test, host, 0x3, true); in tb_test_path_max_length_walk()
789 dev8 = alloc_dev_default(test, dev7, 0x303, true); in tb_test_path_max_length_walk()
790 dev9 = alloc_dev_default(test, dev8, 0x30303, true); in tb_test_path_max_length_walk()
791 dev10 = alloc_dev_default(test, dev9, 0x3030303, true); in tb_test_path_max_length_walk()
792 dev11 = alloc_dev_default(test, dev10, 0x303030303, true); in tb_test_path_max_length_walk()
793 dev12 = alloc_dev_default(test, dev11, 0x30303030303, true); in tb_test_path_max_length_walk()
802 KUNIT_EXPECT_TRUE(test, i < ARRAY_SIZE(test_data)); in tb_test_path_max_length_walk()
803 KUNIT_EXPECT_EQ(test, tb_route(p->sw), test_data[i].route); in tb_test_path_max_length_walk()
804 KUNIT_EXPECT_EQ(test, p->port, test_data[i].port); in tb_test_path_max_length_walk()
805 KUNIT_EXPECT_EQ(test, (enum tb_port_type)p->config.type, in tb_test_path_max_length_walk()
810 KUNIT_EXPECT_EQ(test, i, ARRAY_SIZE(test_data)); in tb_test_path_max_length_walk()
814 KUNIT_EXPECT_TRUE(test, i < ARRAY_SIZE(test_data)); in tb_test_path_max_length_walk()
815 KUNIT_EXPECT_EQ(test, tb_route(p->sw), test_data[i].route); in tb_test_path_max_length_walk()
816 KUNIT_EXPECT_EQ(test, p->port, test_data[i].port); in tb_test_path_max_length_walk()
817 KUNIT_EXPECT_EQ(test, (enum tb_port_type)p->config.type, in tb_test_path_max_length_walk()
822 KUNIT_EXPECT_EQ(test, i, -1); in tb_test_path_max_length_walk()
825 static void tb_test_path_not_connected(struct kunit *test) in tb_test_path_not_connected() argument
831 host = alloc_host(test); in tb_test_path_not_connected()
832 dev1 = alloc_dev_default(test, host, 0x3, false); in tb_test_path_not_connected()
834 dev2 = alloc_dev_default(test, NULL, 0x303, false); in tb_test_path_not_connected()
840 KUNIT_ASSERT_NULL(test, path); in tb_test_path_not_connected()
842 KUNIT_ASSERT_NULL(test, path); in tb_test_path_not_connected()
853 static void tb_test_path_not_bonded_lane0(struct kunit *test) in tb_test_path_not_bonded_lane0() argument
884 host = alloc_host(test); in tb_test_path_not_bonded_lane0()
885 dev = alloc_dev_default(test, host, 0x3, false); in tb_test_path_not_bonded_lane0()
891 KUNIT_ASSERT_NOT_NULL(test, path); in tb_test_path_not_bonded_lane0()
892 KUNIT_ASSERT_EQ(test, path->path_length, ARRAY_SIZE(test_data)); in tb_test_path_not_bonded_lane0()
899 KUNIT_EXPECT_EQ(test, tb_route(in_port->sw), test_data[i].route); in tb_test_path_not_bonded_lane0()
900 KUNIT_EXPECT_EQ(test, in_port->port, test_data[i].in_port); in tb_test_path_not_bonded_lane0()
901 KUNIT_EXPECT_EQ(test, (enum tb_port_type)in_port->config.type, in tb_test_path_not_bonded_lane0()
903 KUNIT_EXPECT_EQ(test, tb_route(out_port->sw), test_data[i].route); in tb_test_path_not_bonded_lane0()
904 KUNIT_EXPECT_EQ(test, out_port->port, test_data[i].out_port); in tb_test_path_not_bonded_lane0()
905 KUNIT_EXPECT_EQ(test, (enum tb_port_type)out_port->config.type, in tb_test_path_not_bonded_lane0()
911 static void tb_test_path_not_bonded_lane1(struct kunit *test) in tb_test_path_not_bonded_lane1() argument
946 host = alloc_host(test); in tb_test_path_not_bonded_lane1()
947 dev = alloc_dev_default(test, host, 0x1, false); in tb_test_path_not_bonded_lane1()
953 KUNIT_ASSERT_NOT_NULL(test, path); in tb_test_path_not_bonded_lane1()
954 KUNIT_ASSERT_EQ(test, path->path_length, ARRAY_SIZE(test_data)); in tb_test_path_not_bonded_lane1()
961 KUNIT_EXPECT_EQ(test, tb_route(in_port->sw), test_data[i].route); in tb_test_path_not_bonded_lane1()
962 KUNIT_EXPECT_EQ(test, in_port->port, test_data[i].in_port); in tb_test_path_not_bonded_lane1()
963 KUNIT_EXPECT_EQ(test, (enum tb_port_type)in_port->config.type, in tb_test_path_not_bonded_lane1()
965 KUNIT_EXPECT_EQ(test, tb_route(out_port->sw), test_data[i].route); in tb_test_path_not_bonded_lane1()
966 KUNIT_EXPECT_EQ(test, out_port->port, test_data[i].out_port); in tb_test_path_not_bonded_lane1()
967 KUNIT_EXPECT_EQ(test, (enum tb_port_type)out_port->config.type, in tb_test_path_not_bonded_lane1()
973 static void tb_test_path_not_bonded_lane1_chain(struct kunit *test) in tb_test_path_not_bonded_lane1_chain() argument
1024 host = alloc_host(test); in tb_test_path_not_bonded_lane1_chain()
1025 dev1 = alloc_dev_default(test, host, 0x1, false); in tb_test_path_not_bonded_lane1_chain()
1026 dev2 = alloc_dev_default(test, dev1, 0x701, false); in tb_test_path_not_bonded_lane1_chain()
1027 dev3 = alloc_dev_default(test, dev2, 0x50701, false); in tb_test_path_not_bonded_lane1_chain()
1033 KUNIT_ASSERT_NOT_NULL(test, path); in tb_test_path_not_bonded_lane1_chain()
1034 KUNIT_ASSERT_EQ(test, path->path_length, ARRAY_SIZE(test_data)); in tb_test_path_not_bonded_lane1_chain()
1041 KUNIT_EXPECT_EQ(test, tb_route(in_port->sw), test_data[i].route); in tb_test_path_not_bonded_lane1_chain()
1042 KUNIT_EXPECT_EQ(test, in_port->port, test_data[i].in_port); in tb_test_path_not_bonded_lane1_chain()
1043 KUNIT_EXPECT_EQ(test, (enum tb_port_type)in_port->config.type, in tb_test_path_not_bonded_lane1_chain()
1045 KUNIT_EXPECT_EQ(test, tb_route(out_port->sw), test_data[i].route); in tb_test_path_not_bonded_lane1_chain()
1046 KUNIT_EXPECT_EQ(test, out_port->port, test_data[i].out_port); in tb_test_path_not_bonded_lane1_chain()
1047 KUNIT_EXPECT_EQ(test, (enum tb_port_type)out_port->config.type, in tb_test_path_not_bonded_lane1_chain()
1053 static void tb_test_path_not_bonded_lane1_chain_reverse(struct kunit *test) in tb_test_path_not_bonded_lane1_chain_reverse() argument
1104 host = alloc_host(test); in tb_test_path_not_bonded_lane1_chain_reverse()
1105 dev1 = alloc_dev_default(test, host, 0x1, false); in tb_test_path_not_bonded_lane1_chain_reverse()
1106 dev2 = alloc_dev_default(test, dev1, 0x701, false); in tb_test_path_not_bonded_lane1_chain_reverse()
1107 dev3 = alloc_dev_with_dpin(test, dev2, 0x50701, false); in tb_test_path_not_bonded_lane1_chain_reverse()
1113 KUNIT_ASSERT_NOT_NULL(test, path); in tb_test_path_not_bonded_lane1_chain_reverse()
1114 KUNIT_ASSERT_EQ(test, path->path_length, ARRAY_SIZE(test_data)); in tb_test_path_not_bonded_lane1_chain_reverse()
1121 KUNIT_EXPECT_EQ(test, tb_route(in_port->sw), test_data[i].route); in tb_test_path_not_bonded_lane1_chain_reverse()
1122 KUNIT_EXPECT_EQ(test, in_port->port, test_data[i].in_port); in tb_test_path_not_bonded_lane1_chain_reverse()
1123 KUNIT_EXPECT_EQ(test, (enum tb_port_type)in_port->config.type, in tb_test_path_not_bonded_lane1_chain_reverse()
1125 KUNIT_EXPECT_EQ(test, tb_route(out_port->sw), test_data[i].route); in tb_test_path_not_bonded_lane1_chain_reverse()
1126 KUNIT_EXPECT_EQ(test, out_port->port, test_data[i].out_port); in tb_test_path_not_bonded_lane1_chain_reverse()
1127 KUNIT_EXPECT_EQ(test, (enum tb_port_type)out_port->config.type, in tb_test_path_not_bonded_lane1_chain_reverse()
1133 static void tb_test_path_mixed_chain(struct kunit *test) in tb_test_path_mixed_chain() argument
1195 host = alloc_host(test); in tb_test_path_mixed_chain()
1196 dev1 = alloc_dev_default(test, host, 0x1, true); in tb_test_path_mixed_chain()
1197 dev2 = alloc_dev_default(test, dev1, 0x701, false); in tb_test_path_mixed_chain()
1198 dev3 = alloc_dev_default(test, dev2, 0x50701, false); in tb_test_path_mixed_chain()
1199 dev4 = alloc_dev_default(test, dev3, 0x3050701, true); in tb_test_path_mixed_chain()
1205 KUNIT_ASSERT_NOT_NULL(test, path); in tb_test_path_mixed_chain()
1206 KUNIT_ASSERT_EQ(test, path->path_length, ARRAY_SIZE(test_data)); in tb_test_path_mixed_chain()
1213 KUNIT_EXPECT_EQ(test, tb_route(in_port->sw), test_data[i].route); in tb_test_path_mixed_chain()
1214 KUNIT_EXPECT_EQ(test, in_port->port, test_data[i].in_port); in tb_test_path_mixed_chain()
1215 KUNIT_EXPECT_EQ(test, (enum tb_port_type)in_port->config.type, in tb_test_path_mixed_chain()
1217 KUNIT_EXPECT_EQ(test, tb_route(out_port->sw), test_data[i].route); in tb_test_path_mixed_chain()
1218 KUNIT_EXPECT_EQ(test, out_port->port, test_data[i].out_port); in tb_test_path_mixed_chain()
1219 KUNIT_EXPECT_EQ(test, (enum tb_port_type)out_port->config.type, in tb_test_path_mixed_chain()
1225 static void tb_test_path_mixed_chain_reverse(struct kunit *test) in tb_test_path_mixed_chain_reverse() argument
1287 host = alloc_host(test); in tb_test_path_mixed_chain_reverse()
1288 dev1 = alloc_dev_default(test, host, 0x1, true); in tb_test_path_mixed_chain_reverse()
1289 dev2 = alloc_dev_default(test, dev1, 0x701, false); in tb_test_path_mixed_chain_reverse()
1290 dev3 = alloc_dev_default(test, dev2, 0x50701, false); in tb_test_path_mixed_chain_reverse()
1291 dev4 = alloc_dev_default(test, dev3, 0x3050701, true); in tb_test_path_mixed_chain_reverse()
1297 KUNIT_ASSERT_NOT_NULL(test, path); in tb_test_path_mixed_chain_reverse()
1298 KUNIT_ASSERT_EQ(test, path->path_length, ARRAY_SIZE(test_data)); in tb_test_path_mixed_chain_reverse()
1305 KUNIT_EXPECT_EQ(test, tb_route(in_port->sw), test_data[i].route); in tb_test_path_mixed_chain_reverse()
1306 KUNIT_EXPECT_EQ(test, in_port->port, test_data[i].in_port); in tb_test_path_mixed_chain_reverse()
1307 KUNIT_EXPECT_EQ(test, (enum tb_port_type)in_port->config.type, in tb_test_path_mixed_chain_reverse()
1309 KUNIT_EXPECT_EQ(test, tb_route(out_port->sw), test_data[i].route); in tb_test_path_mixed_chain_reverse()
1310 KUNIT_EXPECT_EQ(test, out_port->port, test_data[i].out_port); in tb_test_path_mixed_chain_reverse()
1311 KUNIT_EXPECT_EQ(test, (enum tb_port_type)out_port->config.type, in tb_test_path_mixed_chain_reverse()
1317 static void tb_test_tunnel_pcie(struct kunit *test) in tb_test_tunnel_pcie() argument
1334 host = alloc_host(test); in tb_test_tunnel_pcie()
1335 dev1 = alloc_dev_default(test, host, 0x1, true); in tb_test_tunnel_pcie()
1336 dev2 = alloc_dev_default(test, dev1, 0x501, true); in tb_test_tunnel_pcie()
1341 KUNIT_ASSERT_NOT_NULL(test, tunnel1); in tb_test_tunnel_pcie()
1342 KUNIT_EXPECT_EQ(test, tunnel1->type, TB_TUNNEL_PCI); in tb_test_tunnel_pcie()
1343 KUNIT_EXPECT_PTR_EQ(test, tunnel1->src_port, down); in tb_test_tunnel_pcie()
1344 KUNIT_EXPECT_PTR_EQ(test, tunnel1->dst_port, up); in tb_test_tunnel_pcie()
1345 KUNIT_ASSERT_EQ(test, tunnel1->npaths, 2); in tb_test_tunnel_pcie()
1346 KUNIT_ASSERT_EQ(test, tunnel1->paths[0]->path_length, 2); in tb_test_tunnel_pcie()
1347 KUNIT_EXPECT_PTR_EQ(test, tunnel1->paths[0]->hops[0].in_port, down); in tb_test_tunnel_pcie()
1348 KUNIT_EXPECT_PTR_EQ(test, tunnel1->paths[0]->hops[1].out_port, up); in tb_test_tunnel_pcie()
1349 KUNIT_ASSERT_EQ(test, tunnel1->paths[1]->path_length, 2); in tb_test_tunnel_pcie()
1350 KUNIT_EXPECT_PTR_EQ(test, tunnel1->paths[1]->hops[0].in_port, up); in tb_test_tunnel_pcie()
1351 KUNIT_EXPECT_PTR_EQ(test, tunnel1->paths[1]->hops[1].out_port, down); in tb_test_tunnel_pcie()
1356 KUNIT_ASSERT_NOT_NULL(test, tunnel2); in tb_test_tunnel_pcie()
1357 KUNIT_EXPECT_EQ(test, tunnel2->type, TB_TUNNEL_PCI); in tb_test_tunnel_pcie()
1358 KUNIT_EXPECT_PTR_EQ(test, tunnel2->src_port, down); in tb_test_tunnel_pcie()
1359 KUNIT_EXPECT_PTR_EQ(test, tunnel2->dst_port, up); in tb_test_tunnel_pcie()
1360 KUNIT_ASSERT_EQ(test, tunnel2->npaths, 2); in tb_test_tunnel_pcie()
1361 KUNIT_ASSERT_EQ(test, tunnel2->paths[0]->path_length, 2); in tb_test_tunnel_pcie()
1362 KUNIT_EXPECT_PTR_EQ(test, tunnel2->paths[0]->hops[0].in_port, down); in tb_test_tunnel_pcie()
1363 KUNIT_EXPECT_PTR_EQ(test, tunnel2->paths[0]->hops[1].out_port, up); in tb_test_tunnel_pcie()
1364 KUNIT_ASSERT_EQ(test, tunnel2->paths[1]->path_length, 2); in tb_test_tunnel_pcie()
1365 KUNIT_EXPECT_PTR_EQ(test, tunnel2->paths[1]->hops[0].in_port, up); in tb_test_tunnel_pcie()
1366 KUNIT_EXPECT_PTR_EQ(test, tunnel2->paths[1]->hops[1].out_port, down); in tb_test_tunnel_pcie()
1372 static void tb_test_tunnel_dp(struct kunit *test) in tb_test_tunnel_dp() argument
1386 host = alloc_host(test); in tb_test_tunnel_dp()
1387 dev = alloc_dev_default(test, host, 0x3, true); in tb_test_tunnel_dp()
1393 KUNIT_ASSERT_NOT_NULL(test, tunnel); in tb_test_tunnel_dp()
1394 KUNIT_EXPECT_EQ(test, tunnel->type, TB_TUNNEL_DP); in tb_test_tunnel_dp()
1395 KUNIT_EXPECT_PTR_EQ(test, tunnel->src_port, in); in tb_test_tunnel_dp()
1396 KUNIT_EXPECT_PTR_EQ(test, tunnel->dst_port, out); in tb_test_tunnel_dp()
1397 KUNIT_ASSERT_EQ(test, tunnel->npaths, 3); in tb_test_tunnel_dp()
1398 KUNIT_ASSERT_EQ(test, tunnel->paths[0]->path_length, 2); in tb_test_tunnel_dp()
1399 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[0]->hops[0].in_port, in); in tb_test_tunnel_dp()
1400 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[0]->hops[1].out_port, out); in tb_test_tunnel_dp()
1401 KUNIT_ASSERT_EQ(test, tunnel->paths[1]->path_length, 2); in tb_test_tunnel_dp()
1402 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[1]->hops[0].in_port, in); in tb_test_tunnel_dp()
1403 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[1]->hops[1].out_port, out); in tb_test_tunnel_dp()
1404 KUNIT_ASSERT_EQ(test, tunnel->paths[2]->path_length, 2); in tb_test_tunnel_dp()
1405 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[2]->hops[0].in_port, out); in tb_test_tunnel_dp()
1406 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[2]->hops[1].out_port, in); in tb_test_tunnel_dp()
1410 static void tb_test_tunnel_dp_chain(struct kunit *test) in tb_test_tunnel_dp_chain() argument
1429 host = alloc_host(test); in tb_test_tunnel_dp_chain()
1430 dev1 = alloc_dev_default(test, host, 0x1, true); in tb_test_tunnel_dp_chain()
1431 alloc_dev_default(test, dev1, 0x301, true); in tb_test_tunnel_dp_chain()
1432 alloc_dev_default(test, dev1, 0x501, true); in tb_test_tunnel_dp_chain()
1433 dev4 = alloc_dev_default(test, dev1, 0x701, true); in tb_test_tunnel_dp_chain()
1439 KUNIT_ASSERT_NOT_NULL(test, tunnel); in tb_test_tunnel_dp_chain()
1440 KUNIT_EXPECT_EQ(test, tunnel->type, TB_TUNNEL_DP); in tb_test_tunnel_dp_chain()
1441 KUNIT_EXPECT_PTR_EQ(test, tunnel->src_port, in); in tb_test_tunnel_dp_chain()
1442 KUNIT_EXPECT_PTR_EQ(test, tunnel->dst_port, out); in tb_test_tunnel_dp_chain()
1443 KUNIT_ASSERT_EQ(test, tunnel->npaths, 3); in tb_test_tunnel_dp_chain()
1444 KUNIT_ASSERT_EQ(test, tunnel->paths[0]->path_length, 3); in tb_test_tunnel_dp_chain()
1445 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[0]->hops[0].in_port, in); in tb_test_tunnel_dp_chain()
1446 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[0]->hops[2].out_port, out); in tb_test_tunnel_dp_chain()
1447 KUNIT_ASSERT_EQ(test, tunnel->paths[1]->path_length, 3); in tb_test_tunnel_dp_chain()
1448 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[1]->hops[0].in_port, in); in tb_test_tunnel_dp_chain()
1449 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[1]->hops[2].out_port, out); in tb_test_tunnel_dp_chain()
1450 KUNIT_ASSERT_EQ(test, tunnel->paths[2]->path_length, 3); in tb_test_tunnel_dp_chain()
1451 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[2]->hops[0].in_port, out); in tb_test_tunnel_dp_chain()
1452 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[2]->hops[2].out_port, in); in tb_test_tunnel_dp_chain()
1456 static void tb_test_tunnel_dp_tree(struct kunit *test) in tb_test_tunnel_dp_tree() argument
1478 host = alloc_host(test); in tb_test_tunnel_dp_tree()
1479 dev1 = alloc_dev_default(test, host, 0x3, true); in tb_test_tunnel_dp_tree()
1480 dev2 = alloc_dev_with_dpin(test, dev1, 0x303, true); in tb_test_tunnel_dp_tree()
1481 dev3 = alloc_dev_default(test, dev1, 0x503, true); in tb_test_tunnel_dp_tree()
1482 alloc_dev_default(test, dev1, 0x703, true); in tb_test_tunnel_dp_tree()
1483 dev5 = alloc_dev_default(test, dev3, 0x50503, true); in tb_test_tunnel_dp_tree()
1489 KUNIT_ASSERT_NOT_NULL(test, tunnel); in tb_test_tunnel_dp_tree()
1490 KUNIT_EXPECT_EQ(test, tunnel->type, TB_TUNNEL_DP); in tb_test_tunnel_dp_tree()
1491 KUNIT_EXPECT_PTR_EQ(test, tunnel->src_port, in); in tb_test_tunnel_dp_tree()
1492 KUNIT_EXPECT_PTR_EQ(test, tunnel->dst_port, out); in tb_test_tunnel_dp_tree()
1493 KUNIT_ASSERT_EQ(test, tunnel->npaths, 3); in tb_test_tunnel_dp_tree()
1494 KUNIT_ASSERT_EQ(test, tunnel->paths[0]->path_length, 4); in tb_test_tunnel_dp_tree()
1495 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[0]->hops[0].in_port, in); in tb_test_tunnel_dp_tree()
1496 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[0]->hops[3].out_port, out); in tb_test_tunnel_dp_tree()
1497 KUNIT_ASSERT_EQ(test, tunnel->paths[1]->path_length, 4); in tb_test_tunnel_dp_tree()
1498 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[1]->hops[0].in_port, in); in tb_test_tunnel_dp_tree()
1499 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[1]->hops[3].out_port, out); in tb_test_tunnel_dp_tree()
1500 KUNIT_ASSERT_EQ(test, tunnel->paths[2]->path_length, 4); in tb_test_tunnel_dp_tree()
1501 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[2]->hops[0].in_port, out); in tb_test_tunnel_dp_tree()
1502 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[2]->hops[3].out_port, in); in tb_test_tunnel_dp_tree()
1506 static void tb_test_tunnel_dp_max_length(struct kunit *test) in tb_test_tunnel_dp_max_length() argument
1536 host = alloc_host(test); in tb_test_tunnel_dp_max_length()
1537 dev1 = alloc_dev_default(test, host, 0x1, true); in tb_test_tunnel_dp_max_length()
1538 dev2 = alloc_dev_default(test, dev1, 0x301, true); in tb_test_tunnel_dp_max_length()
1539 dev3 = alloc_dev_default(test, dev2, 0x30301, true); in tb_test_tunnel_dp_max_length()
1540 dev4 = alloc_dev_default(test, dev3, 0x3030301, true); in tb_test_tunnel_dp_max_length()
1541 dev5 = alloc_dev_default(test, dev4, 0x303030301, true); in tb_test_tunnel_dp_max_length()
1542 dev6 = alloc_dev_with_dpin(test, dev5, 0x30303030301, true); in tb_test_tunnel_dp_max_length()
1543 dev7 = alloc_dev_default(test, host, 0x3, true); in tb_test_tunnel_dp_max_length()
1544 dev8 = alloc_dev_default(test, dev7, 0x303, true); in tb_test_tunnel_dp_max_length()
1545 dev9 = alloc_dev_default(test, dev8, 0x30303, true); in tb_test_tunnel_dp_max_length()
1546 dev10 = alloc_dev_default(test, dev9, 0x3030303, true); in tb_test_tunnel_dp_max_length()
1547 dev11 = alloc_dev_default(test, dev10, 0x303030303, true); in tb_test_tunnel_dp_max_length()
1548 dev12 = alloc_dev_default(test, dev11, 0x30303030303, true); in tb_test_tunnel_dp_max_length()
1554 KUNIT_ASSERT_NOT_NULL(test, tunnel); in tb_test_tunnel_dp_max_length()
1555 KUNIT_EXPECT_EQ(test, tunnel->type, TB_TUNNEL_DP); in tb_test_tunnel_dp_max_length()
1556 KUNIT_EXPECT_PTR_EQ(test, tunnel->src_port, in); in tb_test_tunnel_dp_max_length()
1557 KUNIT_EXPECT_PTR_EQ(test, tunnel->dst_port, out); in tb_test_tunnel_dp_max_length()
1558 KUNIT_ASSERT_EQ(test, tunnel->npaths, 3); in tb_test_tunnel_dp_max_length()
1559 KUNIT_ASSERT_EQ(test, tunnel->paths[0]->path_length, 13); in tb_test_tunnel_dp_max_length()
1561 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[0]->hops[0].in_port, in); in tb_test_tunnel_dp_max_length()
1563 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[0]->hops[6].in_port, in tb_test_tunnel_dp_max_length()
1565 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[0]->hops[6].out_port, in tb_test_tunnel_dp_max_length()
1568 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[0]->hops[12].out_port, out); in tb_test_tunnel_dp_max_length()
1569 KUNIT_ASSERT_EQ(test, tunnel->paths[1]->path_length, 13); in tb_test_tunnel_dp_max_length()
1570 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[1]->hops[0].in_port, in); in tb_test_tunnel_dp_max_length()
1571 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[1]->hops[6].in_port, in tb_test_tunnel_dp_max_length()
1573 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[1]->hops[6].out_port, in tb_test_tunnel_dp_max_length()
1575 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[1]->hops[12].out_port, out); in tb_test_tunnel_dp_max_length()
1576 KUNIT_ASSERT_EQ(test, tunnel->paths[2]->path_length, 13); in tb_test_tunnel_dp_max_length()
1577 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[2]->hops[0].in_port, out); in tb_test_tunnel_dp_max_length()
1578 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[2]->hops[6].in_port, in tb_test_tunnel_dp_max_length()
1580 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[2]->hops[6].out_port, in tb_test_tunnel_dp_max_length()
1582 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[2]->hops[12].out_port, in); in tb_test_tunnel_dp_max_length()
1586 static void tb_test_tunnel_usb3(struct kunit *test) in tb_test_tunnel_usb3() argument
1603 host = alloc_host(test); in tb_test_tunnel_usb3()
1604 dev1 = alloc_dev_default(test, host, 0x1, true); in tb_test_tunnel_usb3()
1605 dev2 = alloc_dev_default(test, dev1, 0x701, true); in tb_test_tunnel_usb3()
1610 KUNIT_ASSERT_NOT_NULL(test, tunnel1); in tb_test_tunnel_usb3()
1611 KUNIT_EXPECT_EQ(test, tunnel1->type, TB_TUNNEL_USB3); in tb_test_tunnel_usb3()
1612 KUNIT_EXPECT_PTR_EQ(test, tunnel1->src_port, down); in tb_test_tunnel_usb3()
1613 KUNIT_EXPECT_PTR_EQ(test, tunnel1->dst_port, up); in tb_test_tunnel_usb3()
1614 KUNIT_ASSERT_EQ(test, tunnel1->npaths, 2); in tb_test_tunnel_usb3()
1615 KUNIT_ASSERT_EQ(test, tunnel1->paths[0]->path_length, 2); in tb_test_tunnel_usb3()
1616 KUNIT_EXPECT_PTR_EQ(test, tunnel1->paths[0]->hops[0].in_port, down); in tb_test_tunnel_usb3()
1617 KUNIT_EXPECT_PTR_EQ(test, tunnel1->paths[0]->hops[1].out_port, up); in tb_test_tunnel_usb3()
1618 KUNIT_ASSERT_EQ(test, tunnel1->paths[1]->path_length, 2); in tb_test_tunnel_usb3()
1619 KUNIT_EXPECT_PTR_EQ(test, tunnel1->paths[1]->hops[0].in_port, up); in tb_test_tunnel_usb3()
1620 KUNIT_EXPECT_PTR_EQ(test, tunnel1->paths[1]->hops[1].out_port, down); in tb_test_tunnel_usb3()
1625 KUNIT_ASSERT_NOT_NULL(test, tunnel2); in tb_test_tunnel_usb3()
1626 KUNIT_EXPECT_EQ(test, tunnel2->type, TB_TUNNEL_USB3); in tb_test_tunnel_usb3()
1627 KUNIT_EXPECT_PTR_EQ(test, tunnel2->src_port, down); in tb_test_tunnel_usb3()
1628 KUNIT_EXPECT_PTR_EQ(test, tunnel2->dst_port, up); in tb_test_tunnel_usb3()
1629 KUNIT_ASSERT_EQ(test, tunnel2->npaths, 2); in tb_test_tunnel_usb3()
1630 KUNIT_ASSERT_EQ(test, tunnel2->paths[0]->path_length, 2); in tb_test_tunnel_usb3()
1631 KUNIT_EXPECT_PTR_EQ(test, tunnel2->paths[0]->hops[0].in_port, down); in tb_test_tunnel_usb3()
1632 KUNIT_EXPECT_PTR_EQ(test, tunnel2->paths[0]->hops[1].out_port, up); in tb_test_tunnel_usb3()
1633 KUNIT_ASSERT_EQ(test, tunnel2->paths[1]->path_length, 2); in tb_test_tunnel_usb3()
1634 KUNIT_EXPECT_PTR_EQ(test, tunnel2->paths[1]->hops[0].in_port, up); in tb_test_tunnel_usb3()
1635 KUNIT_EXPECT_PTR_EQ(test, tunnel2->paths[1]->hops[1].out_port, down); in tb_test_tunnel_usb3()
1641 static void tb_test_tunnel_port_on_path(struct kunit *test) in tb_test_tunnel_port_on_path() argument
1661 host = alloc_host(test); in tb_test_tunnel_port_on_path()
1662 dev1 = alloc_dev_default(test, host, 0x3, true); in tb_test_tunnel_port_on_path()
1663 dev2 = alloc_dev_with_dpin(test, dev1, 0x303, true); in tb_test_tunnel_port_on_path()
1664 dev3 = alloc_dev_default(test, dev1, 0x503, true); in tb_test_tunnel_port_on_path()
1665 dev4 = alloc_dev_default(test, dev1, 0x703, true); in tb_test_tunnel_port_on_path()
1666 dev5 = alloc_dev_default(test, dev3, 0x50503, true); in tb_test_tunnel_port_on_path()
1672 KUNIT_ASSERT_NOT_NULL(test, dp_tunnel); in tb_test_tunnel_port_on_path()
1674 KUNIT_EXPECT_TRUE(test, tb_tunnel_port_on_path(dp_tunnel, in)); in tb_test_tunnel_port_on_path()
1675 KUNIT_EXPECT_TRUE(test, tb_tunnel_port_on_path(dp_tunnel, out)); in tb_test_tunnel_port_on_path()
1678 KUNIT_EXPECT_FALSE(test, tb_tunnel_port_on_path(dp_tunnel, port)); in tb_test_tunnel_port_on_path()
1681 KUNIT_EXPECT_FALSE(test, tb_tunnel_port_on_path(dp_tunnel, port)); in tb_test_tunnel_port_on_path()
1684 KUNIT_EXPECT_FALSE(test, tb_tunnel_port_on_path(dp_tunnel, port)); in tb_test_tunnel_port_on_path()
1687 KUNIT_EXPECT_TRUE(test, tb_tunnel_port_on_path(dp_tunnel, port)); in tb_test_tunnel_port_on_path()
1690 KUNIT_EXPECT_TRUE(test, tb_tunnel_port_on_path(dp_tunnel, port)); in tb_test_tunnel_port_on_path()
1693 KUNIT_EXPECT_FALSE(test, tb_tunnel_port_on_path(dp_tunnel, port)); in tb_test_tunnel_port_on_path()
1696 KUNIT_EXPECT_TRUE(test, tb_tunnel_port_on_path(dp_tunnel, port)); in tb_test_tunnel_port_on_path()
1699 KUNIT_EXPECT_TRUE(test, tb_tunnel_port_on_path(dp_tunnel, port)); in tb_test_tunnel_port_on_path()
1702 KUNIT_EXPECT_FALSE(test, tb_tunnel_port_on_path(dp_tunnel, port)); in tb_test_tunnel_port_on_path()
1707 static void tb_test_tunnel_dma(struct kunit *test) in tb_test_tunnel_dma() argument
1724 host = alloc_host(test); in tb_test_tunnel_dma()
1729 KUNIT_ASSERT_NOT_NULL(test, tunnel); in tb_test_tunnel_dma()
1730 KUNIT_EXPECT_EQ(test, tunnel->type, TB_TUNNEL_DMA); in tb_test_tunnel_dma()
1731 KUNIT_EXPECT_PTR_EQ(test, tunnel->src_port, nhi); in tb_test_tunnel_dma()
1732 KUNIT_EXPECT_PTR_EQ(test, tunnel->dst_port, port); in tb_test_tunnel_dma()
1733 KUNIT_ASSERT_EQ(test, tunnel->npaths, 2); in tb_test_tunnel_dma()
1735 KUNIT_ASSERT_EQ(test, tunnel->paths[0]->path_length, 1); in tb_test_tunnel_dma()
1736 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[0]->hops[0].in_port, port); in tb_test_tunnel_dma()
1737 KUNIT_EXPECT_EQ(test, tunnel->paths[0]->hops[0].in_hop_index, 8); in tb_test_tunnel_dma()
1738 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[0]->hops[0].out_port, nhi); in tb_test_tunnel_dma()
1739 KUNIT_EXPECT_EQ(test, tunnel->paths[0]->hops[0].next_hop_index, 1); in tb_test_tunnel_dma()
1741 KUNIT_ASSERT_EQ(test, tunnel->paths[1]->path_length, 1); in tb_test_tunnel_dma()
1742 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[1]->hops[0].in_port, nhi); in tb_test_tunnel_dma()
1743 KUNIT_EXPECT_EQ(test, tunnel->paths[1]->hops[0].in_hop_index, 1); in tb_test_tunnel_dma()
1744 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[1]->hops[0].out_port, port); in tb_test_tunnel_dma()
1745 KUNIT_EXPECT_EQ(test, tunnel->paths[1]->hops[0].next_hop_index, 8); in tb_test_tunnel_dma()
1750 static void tb_test_tunnel_dma_rx(struct kunit *test) in tb_test_tunnel_dma_rx() argument
1767 host = alloc_host(test); in tb_test_tunnel_dma_rx()
1772 KUNIT_ASSERT_NOT_NULL(test, tunnel); in tb_test_tunnel_dma_rx()
1773 KUNIT_EXPECT_EQ(test, tunnel->type, TB_TUNNEL_DMA); in tb_test_tunnel_dma_rx()
1774 KUNIT_EXPECT_PTR_EQ(test, tunnel->src_port, nhi); in tb_test_tunnel_dma_rx()
1775 KUNIT_EXPECT_PTR_EQ(test, tunnel->dst_port, port); in tb_test_tunnel_dma_rx()
1776 KUNIT_ASSERT_EQ(test, tunnel->npaths, 1); in tb_test_tunnel_dma_rx()
1778 KUNIT_ASSERT_EQ(test, tunnel->paths[0]->path_length, 1); in tb_test_tunnel_dma_rx()
1779 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[0]->hops[0].in_port, port); in tb_test_tunnel_dma_rx()
1780 KUNIT_EXPECT_EQ(test, tunnel->paths[0]->hops[0].in_hop_index, 15); in tb_test_tunnel_dma_rx()
1781 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[0]->hops[0].out_port, nhi); in tb_test_tunnel_dma_rx()
1782 KUNIT_EXPECT_EQ(test, tunnel->paths[0]->hops[0].next_hop_index, 2); in tb_test_tunnel_dma_rx()
1787 static void tb_test_tunnel_dma_tx(struct kunit *test) in tb_test_tunnel_dma_tx() argument
1804 host = alloc_host(test); in tb_test_tunnel_dma_tx()
1809 KUNIT_ASSERT_NOT_NULL(test, tunnel); in tb_test_tunnel_dma_tx()
1810 KUNIT_EXPECT_EQ(test, tunnel->type, TB_TUNNEL_DMA); in tb_test_tunnel_dma_tx()
1811 KUNIT_EXPECT_PTR_EQ(test, tunnel->src_port, nhi); in tb_test_tunnel_dma_tx()
1812 KUNIT_EXPECT_PTR_EQ(test, tunnel->dst_port, port); in tb_test_tunnel_dma_tx()
1813 KUNIT_ASSERT_EQ(test, tunnel->npaths, 1); in tb_test_tunnel_dma_tx()
1815 KUNIT_ASSERT_EQ(test, tunnel->paths[0]->path_length, 1); in tb_test_tunnel_dma_tx()
1816 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[0]->hops[0].in_port, nhi); in tb_test_tunnel_dma_tx()
1817 KUNIT_EXPECT_EQ(test, tunnel->paths[0]->hops[0].in_hop_index, 2); in tb_test_tunnel_dma_tx()
1818 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[0]->hops[0].out_port, port); in tb_test_tunnel_dma_tx()
1819 KUNIT_EXPECT_EQ(test, tunnel->paths[0]->hops[0].next_hop_index, 15); in tb_test_tunnel_dma_tx()
1824 static void tb_test_tunnel_dma_chain(struct kunit *test) in tb_test_tunnel_dma_chain() argument
1848 host = alloc_host(test); in tb_test_tunnel_dma_chain()
1849 dev1 = alloc_dev_default(test, host, 0x1, true); in tb_test_tunnel_dma_chain()
1850 dev2 = alloc_dev_default(test, dev1, 0x701, true); in tb_test_tunnel_dma_chain()
1855 KUNIT_ASSERT_NOT_NULL(test, tunnel); in tb_test_tunnel_dma_chain()
1856 KUNIT_EXPECT_EQ(test, tunnel->type, TB_TUNNEL_DMA); in tb_test_tunnel_dma_chain()
1857 KUNIT_EXPECT_PTR_EQ(test, tunnel->src_port, nhi); in tb_test_tunnel_dma_chain()
1858 KUNIT_EXPECT_PTR_EQ(test, tunnel->dst_port, port); in tb_test_tunnel_dma_chain()
1859 KUNIT_ASSERT_EQ(test, tunnel->npaths, 2); in tb_test_tunnel_dma_chain()
1861 KUNIT_ASSERT_EQ(test, tunnel->paths[0]->path_length, 3); in tb_test_tunnel_dma_chain()
1862 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[0]->hops[0].in_port, port); in tb_test_tunnel_dma_chain()
1863 KUNIT_EXPECT_EQ(test, tunnel->paths[0]->hops[0].in_hop_index, 8); in tb_test_tunnel_dma_chain()
1864 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[0]->hops[0].out_port, in tb_test_tunnel_dma_chain()
1866 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[0]->hops[1].in_port, in tb_test_tunnel_dma_chain()
1868 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[0]->hops[1].out_port, in tb_test_tunnel_dma_chain()
1870 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[0]->hops[2].in_port, in tb_test_tunnel_dma_chain()
1872 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[0]->hops[2].out_port, nhi); in tb_test_tunnel_dma_chain()
1873 KUNIT_EXPECT_EQ(test, tunnel->paths[0]->hops[2].next_hop_index, 1); in tb_test_tunnel_dma_chain()
1875 KUNIT_ASSERT_EQ(test, tunnel->paths[1]->path_length, 3); in tb_test_tunnel_dma_chain()
1876 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[1]->hops[0].in_port, nhi); in tb_test_tunnel_dma_chain()
1877 KUNIT_EXPECT_EQ(test, tunnel->paths[1]->hops[0].in_hop_index, 1); in tb_test_tunnel_dma_chain()
1878 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[1]->hops[1].in_port, in tb_test_tunnel_dma_chain()
1880 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[1]->hops[1].out_port, in tb_test_tunnel_dma_chain()
1882 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[1]->hops[2].in_port, in tb_test_tunnel_dma_chain()
1884 KUNIT_EXPECT_PTR_EQ(test, tunnel->paths[1]->hops[2].out_port, port); in tb_test_tunnel_dma_chain()
1885 KUNIT_EXPECT_EQ(test, tunnel->paths[1]->hops[2].next_hop_index, 8); in tb_test_tunnel_dma_chain()
1890 static void tb_test_tunnel_dma_match(struct kunit *test) in tb_test_tunnel_dma_match() argument
1896 host = alloc_host(test); in tb_test_tunnel_dma_match()
1901 KUNIT_ASSERT_NOT_NULL(test, tunnel); in tb_test_tunnel_dma_match()
1903 KUNIT_ASSERT_TRUE(test, tb_tunnel_match_dma(tunnel, 15, 1, 15, 1)); in tb_test_tunnel_dma_match()
1904 KUNIT_ASSERT_FALSE(test, tb_tunnel_match_dma(tunnel, 8, 1, 15, 1)); in tb_test_tunnel_dma_match()
1905 KUNIT_ASSERT_TRUE(test, tb_tunnel_match_dma(tunnel, -1, -1, 15, 1)); in tb_test_tunnel_dma_match()
1906 KUNIT_ASSERT_TRUE(test, tb_tunnel_match_dma(tunnel, 15, 1, -1, -1)); in tb_test_tunnel_dma_match()
1907 KUNIT_ASSERT_TRUE(test, tb_tunnel_match_dma(tunnel, 15, -1, -1, -1)); in tb_test_tunnel_dma_match()
1908 KUNIT_ASSERT_TRUE(test, tb_tunnel_match_dma(tunnel, -1, 1, -1, -1)); in tb_test_tunnel_dma_match()
1909 KUNIT_ASSERT_TRUE(test, tb_tunnel_match_dma(tunnel, -1, -1, 15, -1)); in tb_test_tunnel_dma_match()
1910 KUNIT_ASSERT_TRUE(test, tb_tunnel_match_dma(tunnel, -1, -1, -1, 1)); in tb_test_tunnel_dma_match()
1911 KUNIT_ASSERT_TRUE(test, tb_tunnel_match_dma(tunnel, -1, -1, -1, -1)); in tb_test_tunnel_dma_match()
1912 KUNIT_ASSERT_FALSE(test, tb_tunnel_match_dma(tunnel, 8, -1, 8, -1)); in tb_test_tunnel_dma_match()
1917 KUNIT_ASSERT_NOT_NULL(test, tunnel); in tb_test_tunnel_dma_match()
1918 KUNIT_ASSERT_TRUE(test, tb_tunnel_match_dma(tunnel, 15, 1, -1, -1)); in tb_test_tunnel_dma_match()
1919 KUNIT_ASSERT_TRUE(test, tb_tunnel_match_dma(tunnel, 15, -1, -1, -1)); in tb_test_tunnel_dma_match()
1920 KUNIT_ASSERT_TRUE(test, tb_tunnel_match_dma(tunnel, -1, 1, -1, -1)); in tb_test_tunnel_dma_match()
1921 KUNIT_ASSERT_TRUE(test, tb_tunnel_match_dma(tunnel, -1, -1, -1, -1)); in tb_test_tunnel_dma_match()
1922 KUNIT_ASSERT_FALSE(test, tb_tunnel_match_dma(tunnel, 15, 1, 15, 1)); in tb_test_tunnel_dma_match()
1923 KUNIT_ASSERT_FALSE(test, tb_tunnel_match_dma(tunnel, -1, -1, 15, 1)); in tb_test_tunnel_dma_match()
1924 KUNIT_ASSERT_FALSE(test, tb_tunnel_match_dma(tunnel, 15, 11, -1, -1)); in tb_test_tunnel_dma_match()
1929 KUNIT_ASSERT_NOT_NULL(test, tunnel); in tb_test_tunnel_dma_match()
1930 KUNIT_ASSERT_TRUE(test, tb_tunnel_match_dma(tunnel, -1, -1, 15, 11)); in tb_test_tunnel_dma_match()
1931 KUNIT_ASSERT_TRUE(test, tb_tunnel_match_dma(tunnel, -1, -1, 15, -1)); in tb_test_tunnel_dma_match()
1932 KUNIT_ASSERT_TRUE(test, tb_tunnel_match_dma(tunnel, -1, -1, -1, 11)); in tb_test_tunnel_dma_match()
1933 KUNIT_ASSERT_TRUE(test, tb_tunnel_match_dma(tunnel, -1, -1, -1, -1)); in tb_test_tunnel_dma_match()
1934 KUNIT_ASSERT_FALSE(test, tb_tunnel_match_dma(tunnel, -1, -1, 15, 1)); in tb_test_tunnel_dma_match()
1935 KUNIT_ASSERT_FALSE(test, tb_tunnel_match_dma(tunnel, -1, -1, 10, 11)); in tb_test_tunnel_dma_match()
1936 KUNIT_ASSERT_FALSE(test, tb_tunnel_match_dma(tunnel, 15, 11, -1, -1)); in tb_test_tunnel_dma_match()
1941 static void tb_test_credit_alloc_legacy_not_bonded(struct kunit *test) in tb_test_credit_alloc_legacy_not_bonded() argument
1948 host = alloc_host(test); in tb_test_credit_alloc_legacy_not_bonded()
1949 dev = alloc_dev_default(test, host, 0x1, false); in tb_test_credit_alloc_legacy_not_bonded()
1954 KUNIT_ASSERT_NOT_NULL(test, tunnel); in tb_test_credit_alloc_legacy_not_bonded()
1955 KUNIT_ASSERT_EQ(test, tunnel->npaths, (size_t)2); in tb_test_credit_alloc_legacy_not_bonded()
1958 KUNIT_ASSERT_EQ(test, path->path_length, 2); in tb_test_credit_alloc_legacy_not_bonded()
1959 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in tb_test_credit_alloc_legacy_not_bonded()
1960 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 7U); in tb_test_credit_alloc_legacy_not_bonded()
1961 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in tb_test_credit_alloc_legacy_not_bonded()
1962 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 16U); in tb_test_credit_alloc_legacy_not_bonded()
1965 KUNIT_ASSERT_EQ(test, path->path_length, 2); in tb_test_credit_alloc_legacy_not_bonded()
1966 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in tb_test_credit_alloc_legacy_not_bonded()
1967 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 7U); in tb_test_credit_alloc_legacy_not_bonded()
1968 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in tb_test_credit_alloc_legacy_not_bonded()
1969 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 16U); in tb_test_credit_alloc_legacy_not_bonded()
1974 static void tb_test_credit_alloc_legacy_bonded(struct kunit *test) in tb_test_credit_alloc_legacy_bonded() argument
1981 host = alloc_host(test); in tb_test_credit_alloc_legacy_bonded()
1982 dev = alloc_dev_default(test, host, 0x1, true); in tb_test_credit_alloc_legacy_bonded()
1987 KUNIT_ASSERT_NOT_NULL(test, tunnel); in tb_test_credit_alloc_legacy_bonded()
1988 KUNIT_ASSERT_EQ(test, tunnel->npaths, (size_t)2); in tb_test_credit_alloc_legacy_bonded()
1991 KUNIT_ASSERT_EQ(test, path->path_length, 2); in tb_test_credit_alloc_legacy_bonded()
1992 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in tb_test_credit_alloc_legacy_bonded()
1993 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 7U); in tb_test_credit_alloc_legacy_bonded()
1994 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in tb_test_credit_alloc_legacy_bonded()
1995 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 32U); in tb_test_credit_alloc_legacy_bonded()
1998 KUNIT_ASSERT_EQ(test, path->path_length, 2); in tb_test_credit_alloc_legacy_bonded()
1999 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in tb_test_credit_alloc_legacy_bonded()
2000 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 7U); in tb_test_credit_alloc_legacy_bonded()
2001 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in tb_test_credit_alloc_legacy_bonded()
2002 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 32U); in tb_test_credit_alloc_legacy_bonded()
2007 static void tb_test_credit_alloc_pcie(struct kunit *test) in tb_test_credit_alloc_pcie() argument
2014 host = alloc_host_usb4(test); in tb_test_credit_alloc_pcie()
2015 dev = alloc_dev_usb4(test, host, 0x1, true); in tb_test_credit_alloc_pcie()
2020 KUNIT_ASSERT_NOT_NULL(test, tunnel); in tb_test_credit_alloc_pcie()
2021 KUNIT_ASSERT_EQ(test, tunnel->npaths, (size_t)2); in tb_test_credit_alloc_pcie()
2024 KUNIT_ASSERT_EQ(test, path->path_length, 2); in tb_test_credit_alloc_pcie()
2025 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in tb_test_credit_alloc_pcie()
2026 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 7U); in tb_test_credit_alloc_pcie()
2027 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in tb_test_credit_alloc_pcie()
2028 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 32U); in tb_test_credit_alloc_pcie()
2031 KUNIT_ASSERT_EQ(test, path->path_length, 2); in tb_test_credit_alloc_pcie()
2032 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in tb_test_credit_alloc_pcie()
2033 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 7U); in tb_test_credit_alloc_pcie()
2034 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in tb_test_credit_alloc_pcie()
2035 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 64U); in tb_test_credit_alloc_pcie()
2040 static void tb_test_credit_alloc_without_dp(struct kunit *test) in tb_test_credit_alloc_without_dp() argument
2047 host = alloc_host_usb4(test); in tb_test_credit_alloc_without_dp()
2048 dev = alloc_dev_without_dp(test, host, 0x1, true); in tb_test_credit_alloc_without_dp()
2068 KUNIT_ASSERT_TRUE(test, tunnel != NULL); in tb_test_credit_alloc_without_dp()
2069 KUNIT_ASSERT_EQ(test, tunnel->npaths, (size_t)2); in tb_test_credit_alloc_without_dp()
2073 KUNIT_ASSERT_EQ(test, path->path_length, 2); in tb_test_credit_alloc_without_dp()
2074 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in tb_test_credit_alloc_without_dp()
2075 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 7U); in tb_test_credit_alloc_without_dp()
2076 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in tb_test_credit_alloc_without_dp()
2077 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 9U); in tb_test_credit_alloc_without_dp()
2081 KUNIT_ASSERT_EQ(test, path->path_length, 2); in tb_test_credit_alloc_without_dp()
2082 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in tb_test_credit_alloc_without_dp()
2083 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 7U); in tb_test_credit_alloc_without_dp()
2084 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in tb_test_credit_alloc_without_dp()
2085 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 64U); in tb_test_credit_alloc_without_dp()
2090 static void tb_test_credit_alloc_dp(struct kunit *test) in tb_test_credit_alloc_dp() argument
2097 host = alloc_host_usb4(test); in tb_test_credit_alloc_dp()
2098 dev = alloc_dev_usb4(test, host, 0x1, true); in tb_test_credit_alloc_dp()
2104 KUNIT_ASSERT_NOT_NULL(test, tunnel); in tb_test_credit_alloc_dp()
2105 KUNIT_ASSERT_EQ(test, tunnel->npaths, (size_t)3); in tb_test_credit_alloc_dp()
2109 KUNIT_ASSERT_EQ(test, path->path_length, 2); in tb_test_credit_alloc_dp()
2110 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 12U); in tb_test_credit_alloc_dp()
2111 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 0U); in tb_test_credit_alloc_dp()
2112 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 18U); in tb_test_credit_alloc_dp()
2113 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 0U); in tb_test_credit_alloc_dp()
2117 KUNIT_ASSERT_EQ(test, path->path_length, 2); in tb_test_credit_alloc_dp()
2118 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in tb_test_credit_alloc_dp()
2119 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 1U); in tb_test_credit_alloc_dp()
2120 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in tb_test_credit_alloc_dp()
2121 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 1U); in tb_test_credit_alloc_dp()
2125 KUNIT_ASSERT_EQ(test, path->path_length, 2); in tb_test_credit_alloc_dp()
2126 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in tb_test_credit_alloc_dp()
2127 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 1U); in tb_test_credit_alloc_dp()
2128 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in tb_test_credit_alloc_dp()
2129 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 1U); in tb_test_credit_alloc_dp()
2134 static void tb_test_credit_alloc_usb3(struct kunit *test) in tb_test_credit_alloc_usb3() argument
2141 host = alloc_host_usb4(test); in tb_test_credit_alloc_usb3()
2142 dev = alloc_dev_usb4(test, host, 0x1, true); in tb_test_credit_alloc_usb3()
2147 KUNIT_ASSERT_NOT_NULL(test, tunnel); in tb_test_credit_alloc_usb3()
2148 KUNIT_ASSERT_EQ(test, tunnel->npaths, (size_t)2); in tb_test_credit_alloc_usb3()
2151 KUNIT_ASSERT_EQ(test, path->path_length, 2); in tb_test_credit_alloc_usb3()
2152 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in tb_test_credit_alloc_usb3()
2153 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 7U); in tb_test_credit_alloc_usb3()
2154 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in tb_test_credit_alloc_usb3()
2155 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 14U); in tb_test_credit_alloc_usb3()
2158 KUNIT_ASSERT_EQ(test, path->path_length, 2); in tb_test_credit_alloc_usb3()
2159 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in tb_test_credit_alloc_usb3()
2160 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 7U); in tb_test_credit_alloc_usb3()
2161 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in tb_test_credit_alloc_usb3()
2162 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 32U); in tb_test_credit_alloc_usb3()
2167 static void tb_test_credit_alloc_dma(struct kunit *test) in tb_test_credit_alloc_dma() argument
2174 host = alloc_host_usb4(test); in tb_test_credit_alloc_dma()
2175 dev = alloc_dev_usb4(test, host, 0x1, true); in tb_test_credit_alloc_dma()
2181 KUNIT_ASSERT_NOT_NULL(test, tunnel); in tb_test_credit_alloc_dma()
2182 KUNIT_ASSERT_EQ(test, tunnel->npaths, (size_t)2); in tb_test_credit_alloc_dma()
2186 KUNIT_ASSERT_EQ(test, path->path_length, 2); in tb_test_credit_alloc_dma()
2187 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in tb_test_credit_alloc_dma()
2188 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 14U); in tb_test_credit_alloc_dma()
2189 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in tb_test_credit_alloc_dma()
2190 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 14U); in tb_test_credit_alloc_dma()
2194 KUNIT_ASSERT_EQ(test, path->path_length, 2); in tb_test_credit_alloc_dma()
2195 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in tb_test_credit_alloc_dma()
2196 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 0U); in tb_test_credit_alloc_dma()
2197 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in tb_test_credit_alloc_dma()
2198 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 14U); in tb_test_credit_alloc_dma()
2203 static void tb_test_credit_alloc_dma_multiple(struct kunit *test) in tb_test_credit_alloc_dma_multiple() argument
2210 host = alloc_host_usb4(test); in tb_test_credit_alloc_dma_multiple()
2211 dev = alloc_dev_usb4(test, host, 0x1, true); in tb_test_credit_alloc_dma_multiple()
2235 KUNIT_ASSERT_NOT_NULL(test, tunnel1); in tb_test_credit_alloc_dma_multiple()
2236 KUNIT_ASSERT_EQ(test, tunnel1->npaths, (size_t)2); in tb_test_credit_alloc_dma_multiple()
2239 KUNIT_ASSERT_EQ(test, path->path_length, 2); in tb_test_credit_alloc_dma_multiple()
2240 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in tb_test_credit_alloc_dma_multiple()
2241 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 14U); in tb_test_credit_alloc_dma_multiple()
2242 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in tb_test_credit_alloc_dma_multiple()
2243 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 14U); in tb_test_credit_alloc_dma_multiple()
2246 KUNIT_ASSERT_EQ(test, path->path_length, 2); in tb_test_credit_alloc_dma_multiple()
2247 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in tb_test_credit_alloc_dma_multiple()
2248 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 0U); in tb_test_credit_alloc_dma_multiple()
2249 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in tb_test_credit_alloc_dma_multiple()
2250 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 14U); in tb_test_credit_alloc_dma_multiple()
2253 KUNIT_ASSERT_NOT_NULL(test, tunnel2); in tb_test_credit_alloc_dma_multiple()
2254 KUNIT_ASSERT_EQ(test, tunnel2->npaths, (size_t)2); in tb_test_credit_alloc_dma_multiple()
2257 KUNIT_ASSERT_EQ(test, path->path_length, 2); in tb_test_credit_alloc_dma_multiple()
2258 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in tb_test_credit_alloc_dma_multiple()
2259 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 14U); in tb_test_credit_alloc_dma_multiple()
2260 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in tb_test_credit_alloc_dma_multiple()
2261 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 1U); in tb_test_credit_alloc_dma_multiple()
2264 KUNIT_ASSERT_EQ(test, path->path_length, 2); in tb_test_credit_alloc_dma_multiple()
2265 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in tb_test_credit_alloc_dma_multiple()
2266 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 0U); in tb_test_credit_alloc_dma_multiple()
2267 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in tb_test_credit_alloc_dma_multiple()
2268 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 1U); in tb_test_credit_alloc_dma_multiple()
2271 KUNIT_ASSERT_NULL(test, tunnel3); in tb_test_credit_alloc_dma_multiple()
2280 KUNIT_ASSERT_NOT_NULL(test, tunnel3); in tb_test_credit_alloc_dma_multiple()
2283 KUNIT_ASSERT_EQ(test, path->path_length, 2); in tb_test_credit_alloc_dma_multiple()
2284 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in tb_test_credit_alloc_dma_multiple()
2285 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 14U); in tb_test_credit_alloc_dma_multiple()
2286 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in tb_test_credit_alloc_dma_multiple()
2287 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 14U); in tb_test_credit_alloc_dma_multiple()
2290 KUNIT_ASSERT_EQ(test, path->path_length, 2); in tb_test_credit_alloc_dma_multiple()
2291 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in tb_test_credit_alloc_dma_multiple()
2292 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 0U); in tb_test_credit_alloc_dma_multiple()
2293 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in tb_test_credit_alloc_dma_multiple()
2294 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 14U); in tb_test_credit_alloc_dma_multiple()
2300 static struct tb_tunnel *TB_TEST_PCIE_TUNNEL(struct kunit *test, in TB_TEST_PCIE_TUNNEL() argument
2310 KUNIT_ASSERT_NOT_NULL(test, pcie_tunnel); in TB_TEST_PCIE_TUNNEL()
2311 KUNIT_ASSERT_EQ(test, pcie_tunnel->npaths, (size_t)2); in TB_TEST_PCIE_TUNNEL()
2314 KUNIT_ASSERT_EQ(test, path->path_length, 2); in TB_TEST_PCIE_TUNNEL()
2315 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in TB_TEST_PCIE_TUNNEL()
2316 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 7U); in TB_TEST_PCIE_TUNNEL()
2317 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in TB_TEST_PCIE_TUNNEL()
2318 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 32U); in TB_TEST_PCIE_TUNNEL()
2321 KUNIT_ASSERT_EQ(test, path->path_length, 2); in TB_TEST_PCIE_TUNNEL()
2322 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in TB_TEST_PCIE_TUNNEL()
2323 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 7U); in TB_TEST_PCIE_TUNNEL()
2324 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in TB_TEST_PCIE_TUNNEL()
2325 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 64U); in TB_TEST_PCIE_TUNNEL()
2330 static struct tb_tunnel *TB_TEST_DP_TUNNEL1(struct kunit *test, in TB_TEST_DP_TUNNEL1() argument
2340 KUNIT_ASSERT_NOT_NULL(test, dp_tunnel1); in TB_TEST_DP_TUNNEL1()
2341 KUNIT_ASSERT_EQ(test, dp_tunnel1->npaths, (size_t)3); in TB_TEST_DP_TUNNEL1()
2344 KUNIT_ASSERT_EQ(test, path->path_length, 2); in TB_TEST_DP_TUNNEL1()
2345 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 12U); in TB_TEST_DP_TUNNEL1()
2346 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 0U); in TB_TEST_DP_TUNNEL1()
2347 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 18U); in TB_TEST_DP_TUNNEL1()
2348 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 0U); in TB_TEST_DP_TUNNEL1()
2351 KUNIT_ASSERT_EQ(test, path->path_length, 2); in TB_TEST_DP_TUNNEL1()
2352 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in TB_TEST_DP_TUNNEL1()
2353 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 1U); in TB_TEST_DP_TUNNEL1()
2354 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in TB_TEST_DP_TUNNEL1()
2355 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 1U); in TB_TEST_DP_TUNNEL1()
2358 KUNIT_ASSERT_EQ(test, path->path_length, 2); in TB_TEST_DP_TUNNEL1()
2359 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in TB_TEST_DP_TUNNEL1()
2360 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 1U); in TB_TEST_DP_TUNNEL1()
2361 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in TB_TEST_DP_TUNNEL1()
2362 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 1U); in TB_TEST_DP_TUNNEL1()
2367 static struct tb_tunnel *TB_TEST_DP_TUNNEL2(struct kunit *test, in TB_TEST_DP_TUNNEL2() argument
2377 KUNIT_ASSERT_NOT_NULL(test, dp_tunnel2); in TB_TEST_DP_TUNNEL2()
2378 KUNIT_ASSERT_EQ(test, dp_tunnel2->npaths, (size_t)3); in TB_TEST_DP_TUNNEL2()
2381 KUNIT_ASSERT_EQ(test, path->path_length, 2); in TB_TEST_DP_TUNNEL2()
2382 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 12U); in TB_TEST_DP_TUNNEL2()
2383 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 0U); in TB_TEST_DP_TUNNEL2()
2384 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 18U); in TB_TEST_DP_TUNNEL2()
2385 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 0U); in TB_TEST_DP_TUNNEL2()
2388 KUNIT_ASSERT_EQ(test, path->path_length, 2); in TB_TEST_DP_TUNNEL2()
2389 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in TB_TEST_DP_TUNNEL2()
2390 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 1U); in TB_TEST_DP_TUNNEL2()
2391 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in TB_TEST_DP_TUNNEL2()
2392 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 1U); in TB_TEST_DP_TUNNEL2()
2395 KUNIT_ASSERT_EQ(test, path->path_length, 2); in TB_TEST_DP_TUNNEL2()
2396 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in TB_TEST_DP_TUNNEL2()
2397 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 1U); in TB_TEST_DP_TUNNEL2()
2398 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in TB_TEST_DP_TUNNEL2()
2399 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 1U); in TB_TEST_DP_TUNNEL2()
2404 static struct tb_tunnel *TB_TEST_USB3_TUNNEL(struct kunit *test, in TB_TEST_USB3_TUNNEL() argument
2414 KUNIT_ASSERT_NOT_NULL(test, usb3_tunnel); in TB_TEST_USB3_TUNNEL()
2415 KUNIT_ASSERT_EQ(test, usb3_tunnel->npaths, (size_t)2); in TB_TEST_USB3_TUNNEL()
2418 KUNIT_ASSERT_EQ(test, path->path_length, 2); in TB_TEST_USB3_TUNNEL()
2419 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in TB_TEST_USB3_TUNNEL()
2420 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 7U); in TB_TEST_USB3_TUNNEL()
2421 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in TB_TEST_USB3_TUNNEL()
2422 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 14U); in TB_TEST_USB3_TUNNEL()
2425 KUNIT_ASSERT_EQ(test, path->path_length, 2); in TB_TEST_USB3_TUNNEL()
2426 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in TB_TEST_USB3_TUNNEL()
2427 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 7U); in TB_TEST_USB3_TUNNEL()
2428 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in TB_TEST_USB3_TUNNEL()
2429 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 32U); in TB_TEST_USB3_TUNNEL()
2434 static struct tb_tunnel *TB_TEST_DMA_TUNNEL1(struct kunit *test, in TB_TEST_DMA_TUNNEL1() argument
2444 KUNIT_ASSERT_NOT_NULL(test, dma_tunnel1); in TB_TEST_DMA_TUNNEL1()
2445 KUNIT_ASSERT_EQ(test, dma_tunnel1->npaths, (size_t)2); in TB_TEST_DMA_TUNNEL1()
2448 KUNIT_ASSERT_EQ(test, path->path_length, 2); in TB_TEST_DMA_TUNNEL1()
2449 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in TB_TEST_DMA_TUNNEL1()
2450 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 14U); in TB_TEST_DMA_TUNNEL1()
2451 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in TB_TEST_DMA_TUNNEL1()
2452 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 14U); in TB_TEST_DMA_TUNNEL1()
2455 KUNIT_ASSERT_EQ(test, path->path_length, 2); in TB_TEST_DMA_TUNNEL1()
2456 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in TB_TEST_DMA_TUNNEL1()
2457 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 0U); in TB_TEST_DMA_TUNNEL1()
2458 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in TB_TEST_DMA_TUNNEL1()
2459 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 14U); in TB_TEST_DMA_TUNNEL1()
2464 static struct tb_tunnel *TB_TEST_DMA_TUNNEL2(struct kunit *test, in TB_TEST_DMA_TUNNEL2() argument
2474 KUNIT_ASSERT_NOT_NULL(test, dma_tunnel2); in TB_TEST_DMA_TUNNEL2()
2475 KUNIT_ASSERT_EQ(test, dma_tunnel2->npaths, (size_t)2); in TB_TEST_DMA_TUNNEL2()
2478 KUNIT_ASSERT_EQ(test, path->path_length, 2); in TB_TEST_DMA_TUNNEL2()
2479 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in TB_TEST_DMA_TUNNEL2()
2480 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 14U); in TB_TEST_DMA_TUNNEL2()
2481 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in TB_TEST_DMA_TUNNEL2()
2482 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 1U); in TB_TEST_DMA_TUNNEL2()
2485 KUNIT_ASSERT_EQ(test, path->path_length, 2); in TB_TEST_DMA_TUNNEL2()
2486 KUNIT_EXPECT_EQ(test, path->hops[0].nfc_credits, 0U); in TB_TEST_DMA_TUNNEL2()
2487 KUNIT_EXPECT_EQ(test, path->hops[0].initial_credits, 0U); in TB_TEST_DMA_TUNNEL2()
2488 KUNIT_EXPECT_EQ(test, path->hops[1].nfc_credits, 0U); in TB_TEST_DMA_TUNNEL2()
2489 KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 1U); in TB_TEST_DMA_TUNNEL2()
2494 static void tb_test_credit_alloc_all(struct kunit *test) in tb_test_credit_alloc_all() argument
2506 host = alloc_host_usb4(test); in tb_test_credit_alloc_all()
2507 dev = alloc_dev_usb4(test, host, 0x1, true); in tb_test_credit_alloc_all()
2509 pcie_tunnel = TB_TEST_PCIE_TUNNEL(test, host, dev); in tb_test_credit_alloc_all()
2510 dp_tunnel1 = TB_TEST_DP_TUNNEL1(test, host, dev); in tb_test_credit_alloc_all()
2511 dp_tunnel2 = TB_TEST_DP_TUNNEL2(test, host, dev); in tb_test_credit_alloc_all()
2512 usb3_tunnel = TB_TEST_USB3_TUNNEL(test, host, dev); in tb_test_credit_alloc_all()
2513 dma_tunnel1 = TB_TEST_DMA_TUNNEL1(test, host, dev); in tb_test_credit_alloc_all()
2514 dma_tunnel2 = TB_TEST_DMA_TUNNEL2(test, host, dev); in tb_test_credit_alloc_all()
2584 static void tb_test_property_parse(struct kunit *test) in tb_test_property_parse() argument
2590 KUNIT_ASSERT_NOT_NULL(test, dir); in tb_test_property_parse()
2593 KUNIT_ASSERT_NULL(test, p); in tb_test_property_parse()
2596 KUNIT_ASSERT_NOT_NULL(test, p); in tb_test_property_parse()
2597 KUNIT_EXPECT_STREQ(test, p->value.text, "Apple Inc."); in tb_test_property_parse()
2600 KUNIT_ASSERT_NOT_NULL(test, p); in tb_test_property_parse()
2601 KUNIT_EXPECT_EQ(test, p->value.immediate, 0xa27); in tb_test_property_parse()
2604 KUNIT_ASSERT_NOT_NULL(test, p); in tb_test_property_parse()
2605 KUNIT_EXPECT_STREQ(test, p->value.text, "Macintosh"); in tb_test_property_parse()
2608 KUNIT_ASSERT_NOT_NULL(test, p); in tb_test_property_parse()
2609 KUNIT_EXPECT_EQ(test, p->value.immediate, 0xa); in tb_test_property_parse()
2612 KUNIT_ASSERT_NULL(test, p); in tb_test_property_parse()
2615 KUNIT_ASSERT_NOT_NULL(test, p); in tb_test_property_parse()
2618 KUNIT_EXPECT_TRUE(test, uuid_equal(network_dir->uuid, &network_dir_uuid)); in tb_test_property_parse()
2621 KUNIT_ASSERT_NOT_NULL(test, p); in tb_test_property_parse()
2622 KUNIT_EXPECT_EQ(test, p->value.immediate, 0x1); in tb_test_property_parse()
2625 KUNIT_ASSERT_NOT_NULL(test, p); in tb_test_property_parse()
2626 KUNIT_EXPECT_EQ(test, p->value.immediate, 0x1); in tb_test_property_parse()
2629 KUNIT_ASSERT_NOT_NULL(test, p); in tb_test_property_parse()
2630 KUNIT_EXPECT_EQ(test, p->value.immediate, 0x1); in tb_test_property_parse()
2633 KUNIT_ASSERT_NOT_NULL(test, p); in tb_test_property_parse()
2634 KUNIT_EXPECT_EQ(test, p->value.immediate, 0x0); in tb_test_property_parse()
2637 KUNIT_EXPECT_TRUE(test, !p); in tb_test_property_parse()
2639 KUNIT_EXPECT_TRUE(test, !p); in tb_test_property_parse()
2644 static void tb_test_property_format(struct kunit *test) in tb_test_property_format() argument
2652 KUNIT_ASSERT_NOT_NULL(test, dir); in tb_test_property_format()
2655 KUNIT_ASSERT_EQ(test, ret, ARRAY_SIZE(root_directory)); in tb_test_property_format()
2659 block = kunit_kzalloc(test, block_len * sizeof(u32), GFP_KERNEL); in tb_test_property_format()
2660 KUNIT_ASSERT_NOT_NULL(test, block); in tb_test_property_format()
2663 KUNIT_EXPECT_EQ(test, ret, 0); in tb_test_property_format()
2666 KUNIT_EXPECT_EQ(test, root_directory[i], block[i]); in tb_test_property_format()
2671 static void compare_dirs(struct kunit *test, struct tb_property_dir *d1, in compare_dirs() argument
2678 KUNIT_ASSERT_NOT_NULL(test, d2->uuid); in compare_dirs()
2679 KUNIT_ASSERT_TRUE(test, uuid_equal(d1->uuid, d2->uuid)); in compare_dirs()
2681 KUNIT_ASSERT_NULL(test, d2->uuid); in compare_dirs()
2687 KUNIT_ASSERT_NE(test, n1, 0); in compare_dirs()
2692 KUNIT_ASSERT_NE(test, n2, 0); in compare_dirs()
2694 KUNIT_ASSERT_EQ(test, n1, n2); in compare_dirs()
2700 KUNIT_ASSERT_NOT_NULL(test, p1); in compare_dirs()
2702 KUNIT_ASSERT_NOT_NULL(test, p2); in compare_dirs()
2704 KUNIT_ASSERT_STREQ(test, &p1->key[0], &p2->key[0]); in compare_dirs()
2705 KUNIT_ASSERT_EQ(test, p1->type, p2->type); in compare_dirs()
2706 KUNIT_ASSERT_EQ(test, p1->length, p2->length); in compare_dirs()
2710 KUNIT_ASSERT_NOT_NULL(test, p1->value.dir); in compare_dirs()
2711 KUNIT_ASSERT_NOT_NULL(test, p2->value.dir); in compare_dirs()
2712 compare_dirs(test, p1->value.dir, p2->value.dir); in compare_dirs()
2716 KUNIT_ASSERT_NOT_NULL(test, p1->value.data); in compare_dirs()
2717 KUNIT_ASSERT_NOT_NULL(test, p2->value.data); in compare_dirs()
2718 KUNIT_ASSERT_TRUE(test, in compare_dirs()
2725 KUNIT_ASSERT_NOT_NULL(test, p1->value.text); in compare_dirs()
2726 KUNIT_ASSERT_NOT_NULL(test, p2->value.text); in compare_dirs()
2727 KUNIT_ASSERT_STREQ(test, p1->value.text, p2->value.text); in compare_dirs()
2731 KUNIT_ASSERT_EQ(test, p1->value.immediate, in compare_dirs()
2735 KUNIT_FAIL(test, "unexpected property type"); in compare_dirs()
2741 static void tb_test_property_copy(struct kunit *test) in tb_test_property_copy() argument
2748 KUNIT_ASSERT_NOT_NULL(test, src); in tb_test_property_copy()
2751 KUNIT_ASSERT_NOT_NULL(test, dst); in tb_test_property_copy()
2754 compare_dirs(test, src, dst); in tb_test_property_copy()
2758 KUNIT_ASSERT_EQ(test, ret, ARRAY_SIZE(root_directory)); in tb_test_property_copy()
2760 block = kunit_kzalloc(test, sizeof(root_directory), GFP_KERNEL); in tb_test_property_copy()
2761 KUNIT_ASSERT_NOT_NULL(test, block); in tb_test_property_copy()
2764 KUNIT_EXPECT_TRUE(test, !ret); in tb_test_property_copy()
2767 KUNIT_EXPECT_EQ(test, root_directory[i], block[i]); in tb_test_property_copy()