@@ -2206,23 +2206,13 @@ static void tb_test_credit_alloc_dma_multiple(struct kunit *test)
2206
2206
tb_tunnel_free (tunnel2 );
2207
2207
}
2208
2208
2209
- static void tb_test_credit_alloc_all (struct kunit * test )
2209
+ static struct tb_tunnel * TB_TEST_PCIE_TUNNEL (struct kunit * test ,
2210
+ struct tb_switch * host , struct tb_switch * dev )
2210
2211
{
2211
- struct tb_port * up , * down , * in , * out , * nhi , * port ;
2212
- struct tb_tunnel * pcie_tunnel , * dp_tunnel1 , * dp_tunnel2 , * usb3_tunnel ;
2213
- struct tb_tunnel * dma_tunnel1 , * dma_tunnel2 ;
2214
- struct tb_switch * host , * dev ;
2212
+ struct tb_port * up , * down ;
2213
+ struct tb_tunnel * pcie_tunnel ;
2215
2214
struct tb_path * path ;
2216
2215
2217
- /*
2218
- * Create PCIe, 2 x DP, USB 3.x and two DMA tunnels from host to
2219
- * device. Expectation is that all these can be established with
2220
- * the default credit allocation found in Intel hardware.
2221
- */
2222
-
2223
- host = alloc_host_usb4 (test );
2224
- dev = alloc_dev_usb4 (test , host , 0x1 , true);
2225
-
2226
2216
down = & host -> ports [8 ];
2227
2217
up = & dev -> ports [9 ];
2228
2218
pcie_tunnel = tb_tunnel_alloc_pci (NULL , up , down );
@@ -2243,9 +2233,18 @@ static void tb_test_credit_alloc_all(struct kunit *test)
2243
2233
KUNIT_EXPECT_EQ (test , path -> hops [1 ].nfc_credits , 0U );
2244
2234
KUNIT_EXPECT_EQ (test , path -> hops [1 ].initial_credits , 64U );
2245
2235
2236
+ return pcie_tunnel ;
2237
+ }
2238
+
2239
+ static struct tb_tunnel * TB_TEST_DP_TUNNEL1 (struct kunit * test ,
2240
+ struct tb_switch * host , struct tb_switch * dev )
2241
+ {
2242
+ struct tb_port * in , * out ;
2243
+ struct tb_tunnel * dp_tunnel1 ;
2244
+ struct tb_path * path ;
2245
+
2246
2246
in = & host -> ports [5 ];
2247
2247
out = & dev -> ports [13 ];
2248
-
2249
2248
dp_tunnel1 = tb_tunnel_alloc_dp (NULL , in , out , 0 , 0 );
2250
2249
KUNIT_ASSERT_TRUE (test , dp_tunnel1 != NULL );
2251
2250
KUNIT_ASSERT_EQ (test , dp_tunnel1 -> npaths , (size_t )3 );
@@ -2271,9 +2270,18 @@ static void tb_test_credit_alloc_all(struct kunit *test)
2271
2270
KUNIT_EXPECT_EQ (test , path -> hops [1 ].nfc_credits , 0U );
2272
2271
KUNIT_EXPECT_EQ (test , path -> hops [1 ].initial_credits , 1U );
2273
2272
2273
+ return dp_tunnel1 ;
2274
+ }
2275
+
2276
+ static struct tb_tunnel * TB_TEST_DP_TUNNEL2 (struct kunit * test ,
2277
+ struct tb_switch * host , struct tb_switch * dev )
2278
+ {
2279
+ struct tb_port * in , * out ;
2280
+ struct tb_tunnel * dp_tunnel2 ;
2281
+ struct tb_path * path ;
2282
+
2274
2283
in = & host -> ports [6 ];
2275
2284
out = & dev -> ports [14 ];
2276
-
2277
2285
dp_tunnel2 = tb_tunnel_alloc_dp (NULL , in , out , 0 , 0 );
2278
2286
KUNIT_ASSERT_TRUE (test , dp_tunnel2 != NULL );
2279
2287
KUNIT_ASSERT_EQ (test , dp_tunnel2 -> npaths , (size_t )3 );
@@ -2299,6 +2307,16 @@ static void tb_test_credit_alloc_all(struct kunit *test)
2299
2307
KUNIT_EXPECT_EQ (test , path -> hops [1 ].nfc_credits , 0U );
2300
2308
KUNIT_EXPECT_EQ (test , path -> hops [1 ].initial_credits , 1U );
2301
2309
2310
+ return dp_tunnel2 ;
2311
+ }
2312
+
2313
+ static struct tb_tunnel * TB_TEST_USB3_TUNNEL (struct kunit * test ,
2314
+ struct tb_switch * host , struct tb_switch * dev )
2315
+ {
2316
+ struct tb_port * up , * down ;
2317
+ struct tb_tunnel * usb3_tunnel ;
2318
+ struct tb_path * path ;
2319
+
2302
2320
down = & host -> ports [12 ];
2303
2321
up = & dev -> ports [16 ];
2304
2322
usb3_tunnel = tb_tunnel_alloc_usb3 (NULL , up , down , 0 , 0 );
@@ -2319,9 +2337,18 @@ static void tb_test_credit_alloc_all(struct kunit *test)
2319
2337
KUNIT_EXPECT_EQ (test , path -> hops [1 ].nfc_credits , 0U );
2320
2338
KUNIT_EXPECT_EQ (test , path -> hops [1 ].initial_credits , 32U );
2321
2339
2340
+ return usb3_tunnel ;
2341
+ }
2342
+
2343
+ static struct tb_tunnel * TB_TEST_DMA_TUNNEL1 (struct kunit * test ,
2344
+ struct tb_switch * host , struct tb_switch * dev )
2345
+ {
2346
+ struct tb_port * nhi , * port ;
2347
+ struct tb_tunnel * dma_tunnel1 ;
2348
+ struct tb_path * path ;
2349
+
2322
2350
nhi = & host -> ports [7 ];
2323
2351
port = & dev -> ports [3 ];
2324
-
2325
2352
dma_tunnel1 = tb_tunnel_alloc_dma (NULL , nhi , port , 8 , 1 , 8 , 1 );
2326
2353
KUNIT_ASSERT_TRUE (test , dma_tunnel1 != NULL );
2327
2354
KUNIT_ASSERT_EQ (test , dma_tunnel1 -> npaths , (size_t )2 );
@@ -2340,6 +2367,18 @@ static void tb_test_credit_alloc_all(struct kunit *test)
2340
2367
KUNIT_EXPECT_EQ (test , path -> hops [1 ].nfc_credits , 0U );
2341
2368
KUNIT_EXPECT_EQ (test , path -> hops [1 ].initial_credits , 14U );
2342
2369
2370
+ return dma_tunnel1 ;
2371
+ }
2372
+
2373
+ static struct tb_tunnel * TB_TEST_DMA_TUNNEL2 (struct kunit * test ,
2374
+ struct tb_switch * host , struct tb_switch * dev )
2375
+ {
2376
+ struct tb_port * nhi , * port ;
2377
+ struct tb_tunnel * dma_tunnel2 ;
2378
+ struct tb_path * path ;
2379
+
2380
+ nhi = & host -> ports [7 ];
2381
+ port = & dev -> ports [3 ];
2343
2382
dma_tunnel2 = tb_tunnel_alloc_dma (NULL , nhi , port , 9 , 2 , 9 , 2 );
2344
2383
KUNIT_ASSERT_TRUE (test , dma_tunnel2 != NULL );
2345
2384
KUNIT_ASSERT_EQ (test , dma_tunnel2 -> npaths , (size_t )2 );
@@ -2358,6 +2397,31 @@ static void tb_test_credit_alloc_all(struct kunit *test)
2358
2397
KUNIT_EXPECT_EQ (test , path -> hops [1 ].nfc_credits , 0U );
2359
2398
KUNIT_EXPECT_EQ (test , path -> hops [1 ].initial_credits , 1U );
2360
2399
2400
+ return dma_tunnel2 ;
2401
+ }
2402
+
2403
+ static void tb_test_credit_alloc_all (struct kunit * test )
2404
+ {
2405
+ struct tb_tunnel * pcie_tunnel , * dp_tunnel1 , * dp_tunnel2 , * usb3_tunnel ;
2406
+ struct tb_tunnel * dma_tunnel1 , * dma_tunnel2 ;
2407
+ struct tb_switch * host , * dev ;
2408
+
2409
+ /*
2410
+ * Create PCIe, 2 x DP, USB 3.x and two DMA tunnels from host to
2411
+ * device. Expectation is that all these can be established with
2412
+ * the default credit allocation found in Intel hardware.
2413
+ */
2414
+
2415
+ host = alloc_host_usb4 (test );
2416
+ dev = alloc_dev_usb4 (test , host , 0x1 , true);
2417
+
2418
+ pcie_tunnel = TB_TEST_PCIE_TUNNEL (test , host , dev );
2419
+ dp_tunnel1 = TB_TEST_DP_TUNNEL1 (test , host , dev );
2420
+ dp_tunnel2 = TB_TEST_DP_TUNNEL2 (test , host , dev );
2421
+ usb3_tunnel = TB_TEST_USB3_TUNNEL (test , host , dev );
2422
+ dma_tunnel1 = TB_TEST_DMA_TUNNEL1 (test , host , dev );
2423
+ dma_tunnel2 = TB_TEST_DMA_TUNNEL2 (test , host , dev );
2424
+
2361
2425
tb_tunnel_free (dma_tunnel2 );
2362
2426
tb_tunnel_free (dma_tunnel1 );
2363
2427
tb_tunnel_free (usb3_tunnel );
0 commit comments