Skip to content

Commit 17f1878

Browse files
committed
NA OFI: use global auth_key when num_auth_keys is 1
This prevents the use of FI_AV_AUTH_KEY with prov/cxi when num_auth_keys=1 and works around an issue where prov/cxi is forcing the use of the svc_id defined in SLINGSHOT_SVC_IDS.
1 parent 8aa8cae commit 17f1878

File tree

1 file changed

+36
-24
lines changed

1 file changed

+36
-24
lines changed

src/na/na_ofi.c

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,7 @@ struct na_ofi_domain {
759759
struct na_ofi_map addr_map; /* Address map */
760760
hg_hash_table_t *auth_key_map; /* Auth key map (FI_AV_AUTH_KEY) */
761761
struct fid_domain *fi_domain; /* Domain handle */
762+
union na_ofi_auth_key *auth_key; /* Global auth key */
762763
struct fid_av *fi_av; /* Address vector handle */
763764
char *name; /* Domain name */
764765
size_t context_max; /* Max contexts available */
@@ -910,8 +911,8 @@ na_ofi_addr_prov(const char *str);
910911
* Get native address from string.
911912
*/
912913
static NA_INLINE na_return_t
913-
na_ofi_str_to_raw_addr(
914-
const char *str, int addr_format, union na_ofi_raw_addr *addr);
914+
na_ofi_str_to_raw_addr(const char *str, int addr_format,
915+
const union na_ofi_auth_key *auth_key, union na_ofi_raw_addr *addr);
915916
static na_return_t
916917
na_ofi_str_to_sin(const char *str, struct sockaddr_in *sin_addr);
917918
static na_return_t
@@ -927,7 +928,8 @@ na_ofi_str_to_opx(const char *str, struct na_ofi_opx_addr *opx_addr);
927928
static na_return_t
928929
na_ofi_str_to_gni(const char *str, struct na_ofi_gni_addr *gni_addr);
929930
static na_return_t
930-
na_ofi_str_to_cxi(const char *str, struct na_ofi_cxi_addr *cxi_addr);
931+
na_ofi_str_to_cxi(const char *str, const struct cxi_auth_key *cxi_auth_key,
932+
struct na_ofi_cxi_addr *cxi_addr);
931933
static na_return_t
932934
na_ofi_str_to_str(const char *str, struct na_ofi_str_addr *str_addr);
933935

@@ -2427,8 +2429,8 @@ na_ofi_addr_prov(const char *str)
24272429

24282430
/*---------------------------------------------------------------------------*/
24292431
static NA_INLINE na_return_t
2430-
na_ofi_str_to_raw_addr(
2431-
const char *str, int addr_format, union na_ofi_raw_addr *addr)
2432+
na_ofi_str_to_raw_addr(const char *str, int addr_format,
2433+
const union na_ofi_auth_key *auth_key, union na_ofi_raw_addr *addr)
24322434
{
24332435
switch (addr_format) {
24342436
case FI_SOCKADDR_IN:
@@ -2446,7 +2448,9 @@ na_ofi_str_to_raw_addr(
24462448
case FI_ADDR_GNI:
24472449
return na_ofi_str_to_gni(str, &addr->gni);
24482450
case FI_ADDR_CXI:
2449-
return na_ofi_str_to_cxi(str, &addr->cxi);
2451+
return na_ofi_str_to_cxi(str,
2452+
(auth_key != NULL) ? &auth_key->cxi_auth_key : NULL,
2453+
&addr->cxi);
24502454
case FI_ADDR_STR:
24512455
return na_ofi_str_to_str(str, &addr->str);
24522456
default:
@@ -2709,7 +2713,8 @@ na_ofi_str_to_gni(const char *str, struct na_ofi_gni_addr *gni_addr)
27092713

27102714
/*---------------------------------------------------------------------------*/
27112715
static na_return_t
2712-
na_ofi_str_to_cxi(const char *str, struct na_ofi_cxi_addr *cxi_addr)
2716+
na_ofi_str_to_cxi(const char *str, const struct cxi_auth_key *cxi_auth_key,
2717+
struct na_ofi_cxi_addr *cxi_addr)
27132718
{
27142719
na_return_t ret;
27152720
int rc;
@@ -2720,8 +2725,17 @@ na_ofi_str_to_cxi(const char *str, struct na_ofi_cxi_addr *cxi_addr)
27202725
rc = sscanf(str, "%*[^:]://%" SCNx32, (uint32_t *) cxi_addr);
27212726
NA_CHECK_SUBSYS_ERROR(addr, rc != 1, error, ret, NA_PROTONOSUPPORT,
27222727
"Could not convert addr string to CXI addr format");
2728+
2729+
#if FI_VERSION_LT(FI_COMPILE_VERSION, FI_VERSION(1, 20))
27232730
NA_LOG_SUBSYS_DEBUG(addr, "CXI addr is: nic=%" PRIu32 ", pid=%" PRIu32,
27242731
cxi_addr->nic, cxi_addr->pid);
2732+
#else
2733+
if (cxi_auth_key != NULL)
2734+
cxi_addr->vni = cxi_auth_key->vni;
2735+
NA_LOG_SUBSYS_DEBUG(addr,
2736+
"CXI addr is: nic=%" PRIu32 ", pid=%" PRIu32 ", vni=%" PRIu16,
2737+
cxi_addr->nic, cxi_addr->pid, cxi_addr->vni);
2738+
#endif
27252739

27262740
return NA_SUCCESS;
27272741

@@ -3614,11 +3628,10 @@ na_ofi_getinfo(enum na_ofi_prov_type prov_type, const struct na_ofi_info *info,
36143628
#if FI_VERSION_GE(FI_COMPILE_VERSION, FI_VERSION(1, 20))
36153629
/* Ask for auth keys */
36163630
if ((na_ofi_prov_flags[prov_type] & NA_OFI_AV_AUTH_KEY) &&
3617-
(info->num_auth_keys > 0)) {
3631+
info->num_auth_keys > 1) {
36183632
/* The CXI provider does not support FI_DIRECTED_RECV if
36193633
* max_ep_auth_key > 1 */
3620-
if (info->num_auth_keys > 1)
3621-
hints->caps &= ~FI_DIRECTED_RECV;
3634+
hints->caps &= ~FI_DIRECTED_RECV;
36223635
hints->domain_attr->max_ep_auth_key = info->num_auth_keys;
36233636
hints->domain_attr->auth_key_size = FI_AV_AUTH_KEY;
36243637
}
@@ -4943,19 +4956,15 @@ na_ofi_domain_open(const struct na_ofi_fabric *na_ofi_fabric,
49434956
&auth_key_size);
49444957
NA_CHECK_SUBSYS_NA_ERROR(cls, error, ret, "Could not parse auth key");
49454958

4946-
/* If we're using FI_AV_AUTH_KEY, use same mechanism to handle single
4947-
* auth key in order to keep addr fields populated */
4948-
#if FI_VERSION_GE(FI_COMPILE_VERSION, FI_VERSION(1, 20))
4949-
if (na_ofi_prov_flags[na_ofi_fabric->prov_type] & NA_OFI_AV_AUTH_KEY) {
4950-
na_ofi_domain->av_auth_key = true;
4951-
base_auth_key_p = &base_auth_key;
4952-
} else {
4953-
#endif
4954-
domain_attr->auth_key = (void *) &base_auth_key;
4955-
domain_attr->auth_key_size = auth_key_size;
4956-
#if FI_VERSION_GE(FI_COMPILE_VERSION, FI_VERSION(1, 20))
4957-
}
4958-
#endif
4959+
/* Keep a copy of the domain auth key for later use */
4960+
na_ofi_domain->auth_key =
4961+
(union na_ofi_auth_key *) malloc(sizeof(*na_ofi_domain->auth_key));
4962+
NA_CHECK_SUBSYS_ERROR(cls, na_ofi_domain->auth_key == NULL, error, ret,
4963+
NA_NOMEM, "Could not allocate auth_key");
4964+
memcpy(na_ofi_domain->auth_key, &base_auth_key, sizeof(base_auth_key));
4965+
4966+
domain_attr->auth_key = (void *) &base_auth_key;
4967+
domain_attr->auth_key_size = auth_key_size;
49594968
}
49604969

49614970
/* Traffic class */
@@ -5031,6 +5040,7 @@ na_ofi_domain_open(const struct na_ofi_fabric *na_ofi_fabric,
50315040
if (na_ofi_domain->fi_domain)
50325041
(void) fi_close(&na_ofi_domain->fi_domain->fid);
50335042

5043+
free(na_ofi_domain->auth_key);
50345044
free(na_ofi_domain->name);
50355045
free(na_ofi_domain);
50365046
}
@@ -5063,6 +5073,7 @@ na_ofi_domain_close(
50635073
na_ofi_domain->fi_domain = NULL;
50645074
}
50655075

5076+
free(na_ofi_domain->auth_key);
50665077
free(na_ofi_domain->name);
50675078
free(na_ofi_domain);
50685079

@@ -8367,7 +8378,8 @@ na_ofi_addr_lookup(na_class_t *na_class, const char *name, na_addr_t **addr_p)
83678378
name);
83688379

83698380
/* Convert name to raw address */
8370-
ret = na_ofi_str_to_raw_addr(name, addr_format, &addr_key.addr);
8381+
ret = na_ofi_str_to_raw_addr(
8382+
name, addr_format, na_ofi_class->domain->auth_key, &addr_key.addr);
83718383
NA_CHECK_SUBSYS_NA_ERROR(
83728384
addr, error, ret, "Could not convert string to address");
83738385

0 commit comments

Comments
 (0)