@@ -1538,7 +1538,68 @@ Test(av_auth_key, lookup_without_av_auth_key_set)
15381538}
15391539
15401540/* Insert multiple auth_keys. */
1541+ #ifdef CXI_HAVE_SVC_GET_VNI_RANGE
1542+ #define NUM_VNIS 32U
1543+ #else
15411544#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+
15421603Test (av_auth_key , insert_lookup_valid_auth_key )
15431604{
15441605 struct fi_info * hints ;
@@ -1552,23 +1613,13 @@ Test(av_auth_key, insert_lookup_valid_auth_key)
15521613 size_t auth_key_size ;
15531614 fi_addr_t addr_key ;
15541615 struct cxil_dev * dev ;
1555- struct cxi_svc_fail_info fail_info = {};
15561616 struct cxi_svc_desc svc_desc = {};
15571617 int i ;
15581618
15591619 ret = cxil_open_device (0 , & dev );
15601620 cr_assert_eq (ret , 0 , "cxil_open_device failed: %d" , ret );
15611621
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 );
15721623
15731624 hints = fi_allocinfo ();
15741625 cr_assert_not_null (hints , "fi_allocinfo failed" );
@@ -1587,7 +1638,7 @@ Test(av_auth_key, insert_lookup_valid_auth_key)
15871638 open_av_auth_key (info , & fab , & dom , & av );
15881639
15891640 for (i = 0 ; i < NUM_VNIS ; i ++ ) {
1590- auth_key .vni = svc_desc . vnis [ i ] ;
1641+ auth_key .vni = VNI + i ;
15911642
15921643 ret = fi_av_insert_auth_key (av , & auth_key , sizeof (auth_key ),
15931644 & addr_key , 0 );
@@ -2226,16 +2277,10 @@ Test(av_auth_key, invalid_multiple_auth_keys_per_ep_with_directed_recv_rx_cap)
22262277 fi_freeinfo (hints );
22272278}
22282279
2229- #define NUM_VNIS 4U
22302280#define NUM_TX_EPS NUM_VNIS
22312281
22322282static 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 = {};
22392284
22402285static struct fid_fabric * fab ;
22412286static struct fid_domain * dom ;
@@ -2248,12 +2293,11 @@ static fi_addr_t auth_keys[NUM_VNIS];
22482293static fi_addr_t init_addrs [NUM_TX_EPS ];
22492294
22502295static char * rx_ep_pid = "0" ;
2251- static char * tx_ep_pids [] = {"128" , "129" , "130" , "131" };
22522296static unsigned int nic_addr ;
22532297
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 ] ;
22572301static struct fid_ep * tx_ep [NUM_TX_EPS ];
22582302static volatile uint64_t tx_mr_buf [NUM_TX_EPS ];
22592303static 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)
22732317 int i ;
22742318 struct cxi_auth_key key = {};
22752319 char node [64 ];
2320+ char service [10 ];
22762321
22772322 hints = fi_allocinfo ();
22782323 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)
22842329 hints -> fabric_attr -> prov_name = strdup ("cxi" );
22852330 cr_assert_not_null (hints -> fabric_attr -> prov_name , "strdup failed" );
22862331
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 );
22902336
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 );
22932339
2294- fi_freeinfo (info );
2340+ fi_freeinfo (info );
22952341
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 );
22982344
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 );
23012347
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 );
23052352
2306- for (i = 0 ; i < num_vnis ; i ++ ) {
2307- key .vni = svc_desc .vnis [i ];
2353+ key .vni = VNI + i ;
23082354 key .svc_id = svc_desc .svc_id ;
23092355
23102356 hints -> ep_attr -> auth_key = (void * )& key ;
23112357 hints -> ep_attr -> auth_key_size = sizeof (key );
23122358
2359+ sprintf (service , "%d" , 128 + i );
23132360 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 ,
23152362 & info );
23162363 cr_assert_eq (ret , FI_SUCCESS , "fi_getinfo failed: %d" , ret );
23172364
2318- ret = fi_endpoint (tx_dom , info , & tx_ep [i ], NULL );
2365+ ret = fi_endpoint (tx_dom [ i ] , info , & tx_ep [i ], NULL );
23192366 cr_assert_eq (ret , FI_SUCCESS , "fi_endpoint failed: %d" , ret );
23202367
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 );
23222369 cr_assert_eq (ret , FI_SUCCESS , "fi_ep_bind CQ failed: %d" , ret );
23232370
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 );
23252372 cr_assert_eq (ret , FI_SUCCESS , "fi_ep_bind AV failed: %d" , ret );
23262373
23272374 ret = fi_enable (tx_ep [i ]);
23282375 cr_assert_eq (ret , FI_SUCCESS , "fi_enable failed: %d" , ret );
23292376
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 ],
23312378 sizeof (tx_mr_buf [i ]),
23322379 FI_WRITE | FI_READ | FI_REMOTE_WRITE | FI_REMOTE_READ ,
23332380 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,
23512398{
23522399 struct fi_info * hints ;
23532400 static struct fi_info * info ;
2354- struct cxi_svc_fail_info fail_info = {};
23552401 int ret ;
23562402 struct fi_cq_attr cq_attr = {
23572403 .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,
23632409 struct cxi_auth_key key = {};
23642410 size_t key_size ;
23652411 char node [64 ];
2412+ char service [10 ];
23662413
23672414 /* Need to allocate a service to be used by libfabric. */
23682415 ret = cxil_open_device (0 , & dev );
23692416 cr_assert_eq (ret , 0 , "cxil_open_device failed: %d" , ret );
23702417
23712418 nic_addr = dev -> info .nic_addr ;
23722419
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 );
23762421
23772422 hints = fi_allocinfo ();
23782423 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,
24222467 cr_assert_eq (ret , FI_SUCCESS , "fi_ep_bind AV failed: %d" , ret );
24232468
24242469 for (i = 0 ; i < num_vnis ; i ++ ) {
2425- key .vni = svc_desc . vnis [ i ] ;
2470+ key .vni = VNI + i ;
24262471 key_size = sizeof (key );
24272472
24282473 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,
24342479 continue ;
24352480
24362481 sprintf (node , "%u" , nic_addr );
2482+ sprintf (service , "%d" , 128 + i );
24372483 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 ],
24392485 FI_AUTH_KEY , NULL );
24402486 cr_assert_eq (ret , 1 , "fi_av_insertsvc failed: %d" , ret );
24412487 }
@@ -2468,16 +2514,16 @@ static void av_auth_key_tx_ep_fini(unsigned int num_vnis)
24682514
24692515 ret = fi_close (& tx_ep [i ]-> fid );
24702516 cr_assert_eq (ret , FI_SUCCESS , "fi_close EP failed: %d" , ret );
2471- }
24722517
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 );
24752520
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 );
24782523
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+ }
24812527}
24822528
24832529static void av_auth_key_test_rx_ep_fini (void )
@@ -2542,7 +2588,7 @@ Test(data_transfer_av_auth_key, successful_inject_transfer_source)
25422588 cr_assert_eq (ret , FI_SUCCESS , "fi_recv failed: %d" , ret );
25432589
25442590 do {
2545- ret = fi_cq_readfrom (tx_cq , & event , 1 , & src_addr );
2591+ ret = fi_cq_readfrom (tx_cq [ i ] , & event , 1 , & src_addr );
25462592 } while (ret == - FI_EAGAIN );
25472593 cr_assert_eq (ret , 1 , "fi_cq_readfrom failed: %d" , ret );
25482594 cr_assert_eq (src_addr , target_addr , "Bad source addr" );
@@ -2585,7 +2631,7 @@ Test(data_transfer_av_auth_key, successful_rdzv_transfer_source)
25852631 cr_assert_eq (src_addr , init_addrs [i ], "Bad source addr" );
25862632
25872633 do {
2588- ret = fi_cq_read (tx_cq , & event , 1 );
2634+ ret = fi_cq_read (tx_cq [ i ] , & event , 1 );
25892635 } while (ret == - FI_EAGAIN );
25902636 cr_assert_eq (ret , 1 , "fi_cq_read failed: %d" , ret );
25912637
@@ -2597,7 +2643,7 @@ Test(data_transfer_av_auth_key, successful_rdzv_transfer_source)
25972643 cr_assert_eq (ret , FI_SUCCESS , "fi_recv failed: %d" , ret );
25982644
25992645 do {
2600- ret = fi_cq_readfrom (tx_cq , & event , 1 , & src_addr );
2646+ ret = fi_cq_readfrom (tx_cq [ i ] , & event , 1 , & src_addr );
26012647 } while (ret == - FI_EAGAIN );
26022648 cr_assert_eq (ret , 1 , "fi_cq_readfrom failed: %d" , ret );
26032649 cr_assert_eq (src_addr , target_addr , "Bad source addr" );
@@ -2648,7 +2694,7 @@ Test(data_transfer_av_auth_key, successful_transfer_source_err)
26482694 error .src_addr , auth_keys [i ]);
26492695
26502696 do {
2651- ret = fi_cq_read (tx_cq , & event , 1 );
2697+ ret = fi_cq_read (tx_cq [ i ] , & event , 1 );
26522698 } while (ret == - FI_EAGAIN );
26532699 cr_assert_eq (ret , 1 , "fi_cq_read failed: %d" , ret );
26542700 }
@@ -2746,7 +2792,7 @@ Test(data_transfer_av_auth_key, av_user_id_source_err_missing_auth_key_user_id)
27462792 error .src_addr , FI_ADDR_UNSPEC );
27472793
27482794 do {
2749- ret = fi_cq_read (tx_cq , & event , 1 );
2795+ ret = fi_cq_read (tx_cq [ i ] , & event , 1 );
27502796 } while (ret == - FI_EAGAIN );
27512797 cr_assert_eq (ret , 1 , "fi_cq_read failed: %d" , ret );
27522798 }
@@ -2797,7 +2843,7 @@ Test(data_transfer_av_auth_key, av_user_id_source_err_auth_key_user_id)
27972843 error .src_addr , user_id [i ]);
27982844
27992845 do {
2800- ret = fi_cq_read (tx_cq , & event , 1 );
2846+ ret = fi_cq_read (tx_cq [ i ] , & event , 1 );
28012847 } while (ret == - FI_EAGAIN );
28022848 cr_assert_eq (ret , 1 , "fi_cq_read failed: %d" , ret );
28032849 }
0 commit comments