From 2987b6b0d3df2c255ec59eb73fac1fb9df36e7bb Mon Sep 17 00:00:00 2001 From: Jianxin Xiong Date: Fri, 8 Dec 2017 13:17:49 -0800 Subject: [PATCH] prov/psm2: Simplify the code for checking endpoint capabilities (1) Remove the special case for empty ep which was used to initialize AM handlers before any endpoint was created. It is no longer needed since now AM handlers are initialized for each endpoint. (2) Remove duplicated capability checking at the time an endpoint is opened. Signed-off-by: Jianxin Xiong --- prov/psm2/src/psmx2.h | 1 - prov/psm2/src/psmx2_domain.c | 36 +++++++----------------------------- prov/psm2/src/psmx2_ep.c | 4 ---- 3 files changed, 7 insertions(+), 34 deletions(-) diff --git a/prov/psm2/src/psmx2.h b/prov/psm2/src/psmx2.h index 50c7aeeb8b0..50da15b3267 100644 --- a/prov/psm2/src/psmx2.h +++ b/prov/psm2/src/psmx2.h @@ -981,7 +981,6 @@ static inline void psmx2_domain_release(struct psmx2_fid_domain *domain) ofi_atomic_dec32(&domain->util_domain.ref); } -int psmx2_domain_check_features(struct psmx2_fid_domain *domain, int ep_cap); int psmx2_domain_enable_ep(struct psmx2_fid_domain *domain, struct psmx2_fid_ep *ep); void psmx2_trx_ctxt_free(struct psmx2_trx_ctxt *trx_ctxt); diff --git a/prov/psm2/src/psmx2_domain.c b/prov/psm2/src/psmx2_domain.c index d1948d5dd5c..f0c9b6f08e3 100644 --- a/prov/psm2/src/psmx2_domain.c +++ b/prov/psm2/src/psmx2_domain.c @@ -518,26 +518,13 @@ static int psmx2_domain_init(struct psmx2_fid_domain *domain, dlist_init(&domain->trx_ctxt_list); fastlock_init(&domain->trx_ctxt_lock); - /* Set active domain before psmx2_domain_enable_ep() installs the - * AM handlers to ensure that psmx2_active_fabric->active_domain - * is always non-NULL inside the handlers. Notice that the - * active_domain becomes NULL again only when the domain is closed. - * At that time the AM handlers are gone with the PSM endpoint. - */ domain->fabric->active_domain = domain; - if (psmx2_domain_enable_ep(domain, NULL) < 0) - goto err_out_reset_active_domain; - if (domain->progress_thread_enabled) psmx2_domain_start_progress(domain); return 0; -err_out_reset_active_domain: - domain->fabric->active_domain = NULL; - rbtDelete(domain->mr_map); - err_out_destroy_mr_lock: fastlock_destroy(&domain->mr_lock); @@ -628,7 +615,8 @@ int psmx2_domain_open(struct fid_fabric *fabric, struct fi_info *info, return err; } -int psmx2_domain_check_features(struct psmx2_fid_domain *domain, int ep_cap) +static int psmx2_domain_check_features(struct psmx2_fid_domain *domain, + uint64_t ep_cap) { if ((domain->caps & ep_cap & ~PSMX2_SUB_CAPS) != (ep_cap & ~PSMX2_SUB_CAPS)) { @@ -647,23 +635,13 @@ int psmx2_domain_check_features(struct psmx2_fid_domain *domain, int ep_cap) int psmx2_domain_enable_ep(struct psmx2_fid_domain *domain, struct psmx2_fid_ep *ep) { - uint64_t ep_cap = 0; - - if (ep) - ep_cap = ep->caps; + int err; - if ((domain->caps & ep_cap & ~PSMX2_SUB_CAPS) != - (ep_cap & ~PSMX2_SUB_CAPS)) { - uint64_t mask = ~PSMX2_SUB_CAPS; - FI_INFO(&psmx2_prov, FI_LOG_CORE, - "caps mismatch: domain->caps=%s,\n ep->caps=%s,\n mask=%s\n", - fi_tostr(&domain->caps, FI_TYPE_CAPS), - fi_tostr(&ep_cap, FI_TYPE_CAPS), - fi_tostr(&mask, FI_TYPE_CAPS)); - return -FI_EOPNOTSUPP; - } + err = psmx2_domain_check_features(domain, ep->caps); + if (err) + return err; - if ((ep_cap & FI_RMA) || (ep_cap & FI_ATOMICS)) + if ((ep->caps & FI_RMA) || (ep->caps & FI_ATOMICS)) return psmx2_am_init(ep->trx_ctxt); return 0; diff --git a/prov/psm2/src/psmx2_ep.c b/prov/psm2/src/psmx2_ep.c index dfdb0d21fb4..b2e54bd338d 100644 --- a/prov/psm2/src/psmx2_ep.c +++ b/prov/psm2/src/psmx2_ep.c @@ -497,10 +497,6 @@ int psmx2_ep_open_internal(struct psmx2_fid_domain *domain_priv, } } - err = psmx2_domain_check_features(domain_priv, ep_cap); - if (err) - goto errout; - ep_priv = (struct psmx2_fid_ep *) calloc(1, sizeof *ep_priv); if (!ep_priv) { err = -FI_ENOMEM;