@@ -170,6 +170,23 @@ static struct tb_switch *alloc_host_usb4(struct kunit *test)
170170 return sw ;
171171}
172172
173+ static struct tb_switch * alloc_host_br (struct kunit * test )
174+ {
175+ struct tb_switch * sw ;
176+
177+ sw = alloc_host_usb4 (test );
178+ if (!sw )
179+ return NULL ;
180+
181+ sw -> ports [10 ].config .type = TB_TYPE_DP_HDMI_IN ;
182+ sw -> ports [10 ].config .max_in_hop_id = 9 ;
183+ sw -> ports [10 ].config .max_out_hop_id = 9 ;
184+ sw -> ports [10 ].cap_adap = -1 ;
185+ sw -> ports [10 ].disabled = false;
186+
187+ return sw ;
188+ }
189+
173190static struct tb_switch * alloc_dev_default (struct kunit * test ,
174191 struct tb_switch * parent ,
175192 u64 route , bool bonded )
@@ -1583,6 +1600,71 @@ static void tb_test_tunnel_dp_max_length(struct kunit *test)
15831600 tb_tunnel_free (tunnel );
15841601}
15851602
1603+ static void tb_test_tunnel_3dp (struct kunit * test )
1604+ {
1605+ struct tb_switch * host , * dev1 , * dev2 , * dev3 , * dev4 , * dev5 ;
1606+ struct tb_port * in1 , * in2 , * in3 , * out1 , * out2 , * out3 ;
1607+ struct tb_tunnel * tunnel1 , * tunnel2 , * tunnel3 ;
1608+
1609+ /*
1610+ * Create 3 DP tunnels from Host to Devices #2, #5 and #4.
1611+ *
1612+ * [Host]
1613+ * 3 |
1614+ * 1 |
1615+ * [Device #1]
1616+ * 3 / | 5 \ 7
1617+ * 1 / | \ 1
1618+ * [Device #2] | [Device #4]
1619+ * | 1
1620+ * [Device #3]
1621+ * | 5
1622+ * | 1
1623+ * [Device #5]
1624+ */
1625+ host = alloc_host_br (test );
1626+ dev1 = alloc_dev_default (test , host , 0x3 , true);
1627+ dev2 = alloc_dev_default (test , dev1 , 0x303 , true);
1628+ dev3 = alloc_dev_default (test , dev1 , 0x503 , true);
1629+ dev4 = alloc_dev_default (test , dev1 , 0x703 , true);
1630+ dev5 = alloc_dev_default (test , dev3 , 0x50503 , true);
1631+
1632+ in1 = & host -> ports [5 ];
1633+ in2 = & host -> ports [6 ];
1634+ in3 = & host -> ports [10 ];
1635+
1636+ out1 = & dev2 -> ports [13 ];
1637+ out2 = & dev5 -> ports [13 ];
1638+ out3 = & dev4 -> ports [14 ];
1639+
1640+ tunnel1 = tb_tunnel_alloc_dp (NULL , in1 , out1 , 1 , 0 , 0 );
1641+ KUNIT_ASSERT_TRUE (test , tunnel1 != NULL );
1642+ KUNIT_EXPECT_EQ (test , tunnel1 -> type , TB_TUNNEL_DP );
1643+ KUNIT_EXPECT_PTR_EQ (test , tunnel1 -> src_port , in1 );
1644+ KUNIT_EXPECT_PTR_EQ (test , tunnel1 -> dst_port , out1 );
1645+ KUNIT_ASSERT_EQ (test , tunnel1 -> npaths , 3 );
1646+ KUNIT_ASSERT_EQ (test , tunnel1 -> paths [0 ]-> path_length , 3 );
1647+
1648+ tunnel2 = tb_tunnel_alloc_dp (NULL , in2 , out2 , 1 , 0 , 0 );
1649+ KUNIT_ASSERT_TRUE (test , tunnel2 != NULL );
1650+ KUNIT_EXPECT_EQ (test , tunnel2 -> type , TB_TUNNEL_DP );
1651+ KUNIT_EXPECT_PTR_EQ (test , tunnel2 -> src_port , in2 );
1652+ KUNIT_EXPECT_PTR_EQ (test , tunnel2 -> dst_port , out2 );
1653+ KUNIT_ASSERT_EQ (test , tunnel2 -> npaths , 3 );
1654+ KUNIT_ASSERT_EQ (test , tunnel2 -> paths [0 ]-> path_length , 4 );
1655+
1656+ tunnel3 = tb_tunnel_alloc_dp (NULL , in3 , out3 , 1 , 0 , 0 );
1657+ KUNIT_ASSERT_TRUE (test , tunnel3 != NULL );
1658+ KUNIT_EXPECT_EQ (test , tunnel3 -> type , TB_TUNNEL_DP );
1659+ KUNIT_EXPECT_PTR_EQ (test , tunnel3 -> src_port , in3 );
1660+ KUNIT_EXPECT_PTR_EQ (test , tunnel3 -> dst_port , out3 );
1661+ KUNIT_ASSERT_EQ (test , tunnel3 -> npaths , 3 );
1662+ KUNIT_ASSERT_EQ (test , tunnel3 -> paths [0 ]-> path_length , 3 );
1663+
1664+ tb_tunnel_free (tunnel2 );
1665+ tb_tunnel_free (tunnel1 );
1666+ }
1667+
15861668static void tb_test_tunnel_usb3 (struct kunit * test )
15871669{
15881670 struct tb_switch * host , * dev1 , * dev2 ;
@@ -2790,6 +2872,7 @@ static struct kunit_case tb_test_cases[] = {
27902872 KUNIT_CASE (tb_test_tunnel_dp_chain ),
27912873 KUNIT_CASE (tb_test_tunnel_dp_tree ),
27922874 KUNIT_CASE (tb_test_tunnel_dp_max_length ),
2875+ KUNIT_CASE (tb_test_tunnel_3dp ),
27932876 KUNIT_CASE (tb_test_tunnel_port_on_path ),
27942877 KUNIT_CASE (tb_test_tunnel_usb3 ),
27952878 KUNIT_CASE (tb_test_tunnel_dma ),
0 commit comments