@@ -1538,7 +1538,68 @@ Test(av_auth_key, lookup_without_av_auth_key_set)
1538
1538
}
1539
1539
1540
1540
/* Insert multiple auth_keys. */
1541
+ #ifdef CXI_HAVE_SVC_GET_VNI_RANGE
1542
+ #define NUM_VNIS 32U
1543
+ #else
1541
1544
#define NUM_VNIS 4U
1545
+ #endif
1546
+ #define VNI 64
1547
+
1548
+ void service_setup (struct cxil_dev * dev , struct cxi_svc_desc * svc_desc )
1549
+ {
1550
+ int ret ;
1551
+ struct cxi_svc_fail_info fail_info = {};
1552
+ #ifndef CXI_HAVE_SVC_GET_VNI_RANGE
1553
+ int i ;
1554
+
1555
+ svc_desc -> restricted_vnis = 1 ;
1556
+ svc_desc -> num_vld_vnis = NUM_VNIS ;
1557
+
1558
+ for (i = 0 ; i < NUM_VNIS ; i ++ )
1559
+ svc_desc -> vnis [i ] = VNI + i ;
1560
+ #endif
1561
+
1562
+ svc_desc -> restricted_members = 1 ;
1563
+ svc_desc -> members [0 ].type = CXI_SVC_MEMBER_UID ;
1564
+ svc_desc -> members [0 ].svc_member .uid = geteuid ();
1565
+
1566
+
1567
+ ret = cxil_alloc_svc (dev , svc_desc , & fail_info );
1568
+ cr_assert_gt (ret , 0 , "cxil_alloc_svc failed:%d" , ret );
1569
+ svc_desc -> svc_id = ret ;
1570
+
1571
+ #ifdef CXI_HAVE_SVC_GET_VNI_RANGE
1572
+ ret = cxil_svc_set_vni_range (dev ,
1573
+ svc_desc -> svc_id ,
1574
+ VNI , VNI + NUM_VNIS - 1 );
1575
+ if (ret ) {
1576
+ int rc ;
1577
+ cr_log_info ("cxil_svc_set_vni_range failed: %d-%d %d" ,
1578
+ VNI , VNI + NUM_VNIS - 1 , ret );
1579
+ rc = cxil_destroy_svc (dev , svc_desc -> svc_id );
1580
+ cr_assert (rc , "cxil_destroy_svc failed:%d" , rc );
1581
+ cr_assert (ret , "cxil_svc_set_vni_range failed: %d-%d %d" ,
1582
+ VNI , VNI + NUM_VNIS - 1 , ret );
1583
+ }
1584
+
1585
+ ret = cxil_svc_enable (dev , svc_desc -> svc_id , false);
1586
+ cr_assert (!ret , "cxil_svc_enable failed disable:%d" , ret );
1587
+
1588
+ ret = cxil_svc_set_exclusive_cp (dev , svc_desc -> svc_id , true);
1589
+ cr_assert (!ret , "cxil_svc_set_exclusive_cp failed:%d" , ret );
1590
+
1591
+ ret = cxil_svc_enable (dev , svc_desc -> svc_id , true);
1592
+ cr_assert (!ret , "cxil_svc_enable failed enable:%d" , ret );
1593
+ #endif
1594
+ }
1595
+
1596
+ void service_cleanup (struct cxil_dev * dev , struct cxi_svc_desc * svc_desc )
1597
+ {
1598
+ int ret ;
1599
+ ret = cxil_destroy_svc (dev , svc_desc -> svc_id );
1600
+ cr_assert (ret , "cxil_destroy_svc failed:%d" , ret );
1601
+ }
1602
+
1542
1603
Test (av_auth_key , insert_lookup_valid_auth_key )
1543
1604
{
1544
1605
struct fi_info * hints ;
@@ -1552,23 +1613,13 @@ Test(av_auth_key, insert_lookup_valid_auth_key)
1552
1613
size_t auth_key_size ;
1553
1614
fi_addr_t addr_key ;
1554
1615
struct cxil_dev * dev ;
1555
- struct cxi_svc_fail_info fail_info = {};
1556
1616
struct cxi_svc_desc svc_desc = {};
1557
1617
int i ;
1558
1618
1559
1619
ret = cxil_open_device (0 , & dev );
1560
1620
cr_assert_eq (ret , 0 , "cxil_open_device failed: %d" , ret );
1561
1621
1562
- svc_desc .restricted_vnis = 1 ;
1563
- svc_desc .enable = 1 ;
1564
- svc_desc .num_vld_vnis = NUM_VNIS ;
1565
-
1566
- for (i = 0 ; i < NUM_VNIS ; i ++ )
1567
- svc_desc .vnis [i ] = 123 + i ;
1568
-
1569
- ret = cxil_alloc_svc (dev , & svc_desc , & fail_info );
1570
- cr_assert_gt (ret , 0 , "cxil_alloc_svc failed: %d" , ret );
1571
- svc_desc .svc_id = ret ;
1622
+ service_setup (dev , & svc_desc );
1572
1623
1573
1624
hints = fi_allocinfo ();
1574
1625
cr_assert_not_null (hints , "fi_allocinfo failed" );
@@ -1587,7 +1638,7 @@ Test(av_auth_key, insert_lookup_valid_auth_key)
1587
1638
open_av_auth_key (info , & fab , & dom , & av );
1588
1639
1589
1640
for (i = 0 ; i < NUM_VNIS ; i ++ ) {
1590
- auth_key .vni = svc_desc . vnis [ i ] ;
1641
+ auth_key .vni = VNI + i ;
1591
1642
1592
1643
ret = fi_av_insert_auth_key (av , & auth_key , sizeof (auth_key ),
1593
1644
& addr_key , 0 );
@@ -2226,16 +2277,10 @@ Test(av_auth_key, invalid_multiple_auth_keys_per_ep_with_directed_recv_rx_cap)
2226
2277
fi_freeinfo (hints );
2227
2278
}
2228
2279
2229
- #define NUM_VNIS 4U
2230
2280
#define NUM_TX_EPS NUM_VNIS
2231
2281
2232
2282
static struct cxil_dev * dev ;
2233
- static struct cxi_svc_desc svc_desc = {
2234
- .restricted_vnis = 1 ,
2235
- .enable = 1 ,
2236
- .num_vld_vnis = NUM_VNIS ,
2237
- .vnis = {1234 , 1235 , 1236 , 1237 },
2238
- };
2283
+ static struct cxi_svc_desc svc_desc = {};
2239
2284
2240
2285
static struct fid_fabric * fab ;
2241
2286
static struct fid_domain * dom ;
@@ -2248,12 +2293,11 @@ static fi_addr_t auth_keys[NUM_VNIS];
2248
2293
static fi_addr_t init_addrs [NUM_TX_EPS ];
2249
2294
2250
2295
static char * rx_ep_pid = "0" ;
2251
- static char * tx_ep_pids [] = {"128" , "129" , "130" , "131" };
2252
2296
static unsigned int nic_addr ;
2253
2297
2254
- static struct fid_domain * tx_dom ;
2255
- static struct fid_cq * tx_cq ;
2256
- static struct fid_av * tx_av ;
2298
+ static struct fid_domain * tx_dom [ NUM_TX_EPS ] ;
2299
+ static struct fid_cq * tx_cq [ NUM_TX_EPS ] ;
2300
+ static struct fid_av * tx_av [ NUM_TX_EPS ] ;
2257
2301
static struct fid_ep * tx_ep [NUM_TX_EPS ];
2258
2302
static volatile uint64_t tx_mr_buf [NUM_TX_EPS ];
2259
2303
static struct fid_mr * tx_mr [NUM_TX_EPS ];
@@ -2273,6 +2317,7 @@ static void av_auth_key_test_tx_ep_init(unsigned int num_vnis)
2273
2317
int i ;
2274
2318
struct cxi_auth_key key = {};
2275
2319
char node [64 ];
2320
+ char service [10 ];
2276
2321
2277
2322
hints = fi_allocinfo ();
2278
2323
cr_assert_not_null (hints , "fi_allocinfo failed" );
@@ -2284,50 +2329,52 @@ static void av_auth_key_test_tx_ep_init(unsigned int num_vnis)
2284
2329
hints -> fabric_attr -> prov_name = strdup ("cxi" );
2285
2330
cr_assert_not_null (hints -> fabric_attr -> prov_name , "strdup failed" );
2286
2331
2287
- ret = fi_getinfo (FI_VERSION (FI_MAJOR_VERSION , FI_MINOR_VERSION ), "cxi0" ,
2288
- NULL , FI_SOURCE , hints , & info );
2289
- cr_assert_eq (ret , FI_SUCCESS , "fi_getinfo failed: %d" , ret );
2332
+ for (i = 0 ; i < num_vnis ; i ++ ) {
2333
+ ret = fi_getinfo (FI_VERSION (FI_MAJOR_VERSION , FI_MINOR_VERSION ), "cxi0" ,
2334
+ NULL , FI_SOURCE , hints , & info );
2335
+ cr_assert_eq (ret , FI_SUCCESS , "fi_getinfo failed: %d" , ret );
2290
2336
2291
- ret = fi_domain (fab , info , & tx_dom , NULL );
2292
- cr_assert_eq (ret , FI_SUCCESS , "fi_domain failed: %d" , ret );
2337
+ ret = fi_domain (fab , info , & tx_dom [ i ] , NULL );
2338
+ cr_assert_eq (ret , FI_SUCCESS , "fi_domain failed: %d" , ret );
2293
2339
2294
- fi_freeinfo (info );
2340
+ fi_freeinfo (info );
2295
2341
2296
- ret = fi_cq_open (tx_dom , & cq_attr , & tx_cq , NULL );
2297
- cr_assert_eq (ret , FI_SUCCESS , "fi_cq_open failed: %d" , ret );
2342
+ ret = fi_cq_open (tx_dom [ i ] , & cq_attr , & tx_cq [ i ] , NULL );
2343
+ cr_assert_eq (ret , FI_SUCCESS , "fi_cq_open failed: %d" , ret );
2298
2344
2299
- ret = fi_av_open (tx_dom , & av_attr , & tx_av , NULL );
2300
- cr_assert_eq (ret , FI_SUCCESS , "fi_av_open failed: %d" , ret );
2345
+ ret = fi_av_open (tx_dom [ i ] , & av_attr , & tx_av [ i ] , NULL );
2346
+ cr_assert_eq (ret , FI_SUCCESS , "fi_av_open failed: %d" , ret );
2301
2347
2302
- sprintf (node , "%u" , nic_addr );
2303
- ret = fi_av_insertsvc (tx_av , node , rx_ep_pid , & target_addr , 0 , NULL );
2304
- cr_assert_eq (ret , 1 , "fi_av_insertsvc failed: %d" , ret );
2348
+ sprintf (node , "%u" , nic_addr );
2349
+ ret = fi_av_insertsvc (tx_av [i ], node , rx_ep_pid , & target_addr , 0 ,
2350
+ NULL );
2351
+ cr_assert_eq (ret , 1 , "fi_av_insertsvc failed: %d" , ret );
2305
2352
2306
- for (i = 0 ; i < num_vnis ; i ++ ) {
2307
- key .vni = svc_desc .vnis [i ];
2353
+ key .vni = VNI + i ;
2308
2354
key .svc_id = svc_desc .svc_id ;
2309
2355
2310
2356
hints -> ep_attr -> auth_key = (void * )& key ;
2311
2357
hints -> ep_attr -> auth_key_size = sizeof (key );
2312
2358
2359
+ sprintf (service , "%d" , 128 + i );
2313
2360
ret = fi_getinfo (FI_VERSION (FI_MAJOR_VERSION , FI_MINOR_VERSION ),
2314
- "cxi0" , tx_ep_pids [ i ] , FI_SOURCE , hints ,
2361
+ "cxi0" , service , FI_SOURCE , hints ,
2315
2362
& info );
2316
2363
cr_assert_eq (ret , FI_SUCCESS , "fi_getinfo failed: %d" , ret );
2317
2364
2318
- ret = fi_endpoint (tx_dom , info , & tx_ep [i ], NULL );
2365
+ ret = fi_endpoint (tx_dom [ i ] , info , & tx_ep [i ], NULL );
2319
2366
cr_assert_eq (ret , FI_SUCCESS , "fi_endpoint failed: %d" , ret );
2320
2367
2321
- ret = fi_ep_bind (tx_ep [i ], & tx_cq -> fid , FI_TRANSMIT | FI_RECV );
2368
+ ret = fi_ep_bind (tx_ep [i ], & tx_cq [ i ] -> fid , FI_TRANSMIT | FI_RECV );
2322
2369
cr_assert_eq (ret , FI_SUCCESS , "fi_ep_bind CQ failed: %d" , ret );
2323
2370
2324
- ret = fi_ep_bind (tx_ep [i ], & tx_av -> fid , 0 );
2371
+ ret = fi_ep_bind (tx_ep [i ], & tx_av [ i ] -> fid , 0 );
2325
2372
cr_assert_eq (ret , FI_SUCCESS , "fi_ep_bind AV failed: %d" , ret );
2326
2373
2327
2374
ret = fi_enable (tx_ep [i ]);
2328
2375
cr_assert_eq (ret , FI_SUCCESS , "fi_enable failed: %d" , ret );
2329
2376
2330
- ret = fi_mr_reg (tx_dom , (void * )& tx_mr_buf [i ],
2377
+ ret = fi_mr_reg (tx_dom [ i ] , (void * )& tx_mr_buf [i ],
2331
2378
sizeof (tx_mr_buf [i ]),
2332
2379
FI_WRITE | FI_READ | FI_REMOTE_WRITE | FI_REMOTE_READ ,
2333
2380
0 , 0 , 0 , & tx_mr [i ], NULL );
@@ -2351,7 +2398,6 @@ static void av_auth_key_test_rx_ep_init(bool source_err, unsigned int num_vnis,
2351
2398
{
2352
2399
struct fi_info * hints ;
2353
2400
static struct fi_info * info ;
2354
- struct cxi_svc_fail_info fail_info = {};
2355
2401
int ret ;
2356
2402
struct fi_cq_attr cq_attr = {
2357
2403
.format = FI_CQ_FORMAT_TAGGED ,
@@ -2363,16 +2409,15 @@ static void av_auth_key_test_rx_ep_init(bool source_err, unsigned int num_vnis,
2363
2409
struct cxi_auth_key key = {};
2364
2410
size_t key_size ;
2365
2411
char node [64 ];
2412
+ char service [10 ];
2366
2413
2367
2414
/* Need to allocate a service to be used by libfabric. */
2368
2415
ret = cxil_open_device (0 , & dev );
2369
2416
cr_assert_eq (ret , 0 , "cxil_open_device failed: %d" , ret );
2370
2417
2371
2418
nic_addr = dev -> info .nic_addr ;
2372
2419
2373
- ret = cxil_alloc_svc (dev , & svc_desc , & fail_info );
2374
- cr_assert_gt (ret , 0 , "cxil_alloc_svc failed: %d" , ret );
2375
- svc_desc .svc_id = ret ;
2420
+ service_setup (dev , & svc_desc );
2376
2421
2377
2422
hints = fi_allocinfo ();
2378
2423
cr_assert_not_null (hints , "fi_allocinfo failed" );
@@ -2422,7 +2467,7 @@ static void av_auth_key_test_rx_ep_init(bool source_err, unsigned int num_vnis,
2422
2467
cr_assert_eq (ret , FI_SUCCESS , "fi_ep_bind AV failed: %d" , ret );
2423
2468
2424
2469
for (i = 0 ; i < num_vnis ; i ++ ) {
2425
- key .vni = svc_desc . vnis [ i ] ;
2470
+ key .vni = VNI + i ;
2426
2471
key_size = sizeof (key );
2427
2472
2428
2473
ret = fi_av_insert_auth_key (av , & key , key_size , & auth_keys [i ],
@@ -2434,8 +2479,9 @@ static void av_auth_key_test_rx_ep_init(bool source_err, unsigned int num_vnis,
2434
2479
continue ;
2435
2480
2436
2481
sprintf (node , "%u" , nic_addr );
2482
+ sprintf (service , "%d" , 128 + i );
2437
2483
init_addrs [i ] = auth_keys [i ];
2438
- ret = fi_av_insertsvc (av , node , tx_ep_pids [ i ] , & init_addrs [i ],
2484
+ ret = fi_av_insertsvc (av , node , service , & init_addrs [i ],
2439
2485
FI_AUTH_KEY , NULL );
2440
2486
cr_assert_eq (ret , 1 , "fi_av_insertsvc failed: %d" , ret );
2441
2487
}
@@ -2468,16 +2514,16 @@ static void av_auth_key_tx_ep_fini(unsigned int num_vnis)
2468
2514
2469
2515
ret = fi_close (& tx_ep [i ]-> fid );
2470
2516
cr_assert_eq (ret , FI_SUCCESS , "fi_close EP failed: %d" , ret );
2471
- }
2472
2517
2473
- ret = fi_close (& tx_av -> fid );
2474
- cr_assert_eq (ret , FI_SUCCESS , "fi_close AV failed: %d" , ret );
2518
+ ret = fi_close (& tx_av [ i ] -> fid );
2519
+ cr_assert_eq (ret , FI_SUCCESS , "fi_close AV failed: %d" , ret );
2475
2520
2476
- ret = fi_close (& tx_cq -> fid );
2477
- cr_assert_eq (ret , FI_SUCCESS , "fi_close CQ failed: %d" , ret );
2521
+ ret = fi_close (& tx_cq [ i ] -> fid );
2522
+ cr_assert_eq (ret , FI_SUCCESS , "fi_close CQ failed: %d" , ret );
2478
2523
2479
- ret = fi_close (& tx_dom -> fid );
2480
- cr_assert_eq (ret , FI_SUCCESS , "fi_close dom failed: %d" , ret );
2524
+ ret = fi_close (& tx_dom [i ]-> fid );
2525
+ cr_assert_eq (ret , FI_SUCCESS , "fi_close dom failed: %d" , ret );
2526
+ }
2481
2527
}
2482
2528
2483
2529
static void av_auth_key_test_rx_ep_fini (void )
@@ -2542,7 +2588,7 @@ Test(data_transfer_av_auth_key, successful_inject_transfer_source)
2542
2588
cr_assert_eq (ret , FI_SUCCESS , "fi_recv failed: %d" , ret );
2543
2589
2544
2590
do {
2545
- ret = fi_cq_readfrom (tx_cq , & event , 1 , & src_addr );
2591
+ ret = fi_cq_readfrom (tx_cq [ i ] , & event , 1 , & src_addr );
2546
2592
} while (ret == - FI_EAGAIN );
2547
2593
cr_assert_eq (ret , 1 , "fi_cq_readfrom failed: %d" , ret );
2548
2594
cr_assert_eq (src_addr , target_addr , "Bad source addr" );
@@ -2585,7 +2631,7 @@ Test(data_transfer_av_auth_key, successful_rdzv_transfer_source)
2585
2631
cr_assert_eq (src_addr , init_addrs [i ], "Bad source addr" );
2586
2632
2587
2633
do {
2588
- ret = fi_cq_read (tx_cq , & event , 1 );
2634
+ ret = fi_cq_read (tx_cq [ i ] , & event , 1 );
2589
2635
} while (ret == - FI_EAGAIN );
2590
2636
cr_assert_eq (ret , 1 , "fi_cq_read failed: %d" , ret );
2591
2637
@@ -2597,7 +2643,7 @@ Test(data_transfer_av_auth_key, successful_rdzv_transfer_source)
2597
2643
cr_assert_eq (ret , FI_SUCCESS , "fi_recv failed: %d" , ret );
2598
2644
2599
2645
do {
2600
- ret = fi_cq_readfrom (tx_cq , & event , 1 , & src_addr );
2646
+ ret = fi_cq_readfrom (tx_cq [ i ] , & event , 1 , & src_addr );
2601
2647
} while (ret == - FI_EAGAIN );
2602
2648
cr_assert_eq (ret , 1 , "fi_cq_readfrom failed: %d" , ret );
2603
2649
cr_assert_eq (src_addr , target_addr , "Bad source addr" );
@@ -2648,7 +2694,7 @@ Test(data_transfer_av_auth_key, successful_transfer_source_err)
2648
2694
error .src_addr , auth_keys [i ]);
2649
2695
2650
2696
do {
2651
- ret = fi_cq_read (tx_cq , & event , 1 );
2697
+ ret = fi_cq_read (tx_cq [ i ] , & event , 1 );
2652
2698
} while (ret == - FI_EAGAIN );
2653
2699
cr_assert_eq (ret , 1 , "fi_cq_read failed: %d" , ret );
2654
2700
}
@@ -2746,7 +2792,7 @@ Test(data_transfer_av_auth_key, av_user_id_source_err_missing_auth_key_user_id)
2746
2792
error .src_addr , FI_ADDR_UNSPEC );
2747
2793
2748
2794
do {
2749
- ret = fi_cq_read (tx_cq , & event , 1 );
2795
+ ret = fi_cq_read (tx_cq [ i ] , & event , 1 );
2750
2796
} while (ret == - FI_EAGAIN );
2751
2797
cr_assert_eq (ret , 1 , "fi_cq_read failed: %d" , ret );
2752
2798
}
@@ -2797,7 +2843,7 @@ Test(data_transfer_av_auth_key, av_user_id_source_err_auth_key_user_id)
2797
2843
error .src_addr , user_id [i ]);
2798
2844
2799
2845
do {
2800
- ret = fi_cq_read (tx_cq , & event , 1 );
2846
+ ret = fi_cq_read (tx_cq [ i ] , & event , 1 );
2801
2847
} while (ret == - FI_EAGAIN );
2802
2848
cr_assert_eq (ret , 1 , "fi_cq_read failed: %d" , ret );
2803
2849
}
0 commit comments