static void psib_cleanup_hca(hca_info_t *hca_info) { if (hca_info->pd_hndl) VAPI_dealloc_pd(hca_info->hca_hndl, hca_info->pd_hndl); if (hca_info->cq_hndl) VAPI_destroy_cq(hca_info->hca_hndl, hca_info->cq_hndl); if (hca_info->hca_hndl) EVAPI_release_hca_hndl(hca_info->hca_hndl); }
/* if hca_name == NULL choose first HCA */ static int psib_open_hca(IN char *hca_name, OUT VAPI_hca_hndl_t *hca_hndl) { VAPI_hca_id_t hca_id; VAPI_ret_t rc; assert(hca_hndl != NULL); if (psib_get_hca_name(&hca_id, hca_name)) goto err_hca_name; /* try to get a handle to the given hca_id */ rc = EVAPI_get_hca_hndl(hca_id, hca_hndl); if (rc != VAPI_SUCCESS) goto err_EVAPI_get_hca_hndl; if (psib_debug > 1) { VAPI_hca_vendor_t hca_vendor; /* ?? */ VAPI_hca_cap_t hca_cap; /* HCA capabilities */ rc = VAPI_query_hca_cap(*hca_hndl, &hca_vendor, &hca_cap); if (rc != VAPI_SUCCESS) goto err_VAPI_query_hca_cap; print_hca_cap(&hca_vendor, &hca_cap); } return 0; /* --- */ err_VAPI_query_hca_cap: EVAPI_release_hca_hndl(*hca_hndl); psib_err_rc("VAPI_query_hca_cap() failed", rc); return -1; /* --- */ err_EVAPI_get_hca_hndl: psib_err_rc("EVAPI_get_hca_hndl() failed", rc); return -1; /* --- */ err_hca_name: return -1; }
int finalizeIB(ArgStruct *p) { VAPI_ret_t ret; LOGPRINTF("Finalizing IB stuff\n"); /* Clear completion event handler */ if(p->prot.comptype == NP_COMP_EVENT ) { LOGPRINTF("Clearing comp handler\n"); ret = EVAPI_clear_comp_eventh(hca_hndl, ceh_hndl); if(ret != VAPI_OK) { fprintf(stderr, "Error clearing event handler: %s\n", VAPI_strerror(ret)); } } if(qp_hndl != VAPI_INVAL_HNDL) { LOGPRINTF("Destroying QP\n"); ret = VAPI_destroy_qp(hca_hndl, qp_hndl); if(ret != VAPI_OK) { fprintf(stderr, "Error destroying Queue Pair: %s\n", VAPI_strerror(ret)); } } if(r_cq_hndl != VAPI_INVAL_HNDL) { LOGPRINTF("Destroying Recv CQ\n"); ret = VAPI_destroy_cq(hca_hndl, r_cq_hndl); if(ret != VAPI_OK) { fprintf(stderr, "Error destroying recv CQ: %s\n", VAPI_strerror(ret)); } } if(s_cq_hndl != VAPI_INVAL_HNDL) { LOGPRINTF("Destroying Send CQ\n"); ret = VAPI_destroy_cq(hca_hndl, s_cq_hndl); if(ret != VAPI_OK) { fprintf(stderr, "Error destroying send CQ: %s\n", VAPI_strerror(ret)); } } /* Check memory registrations just in case user bailed out */ if(s_mr_hndl != VAPI_INVAL_HNDL) { LOGPRINTF("Deregistering send buffer\n"); ret = VAPI_deregister_mr(hca_hndl, s_mr_hndl); if(ret != VAPI_OK) { fprintf(stderr, "Error deregistering send mr: %s\n", VAPI_strerror(ret)); } } if(r_mr_hndl != VAPI_INVAL_HNDL) { LOGPRINTF("Deregistering recv buffer\n"); ret = VAPI_deregister_mr(hca_hndl, r_mr_hndl); if(ret != VAPI_OK) { fprintf(stderr, "Error deregistering recv mr: %s\n", VAPI_strerror(ret)); } } if(pd_hndl != VAPI_INVAL_HNDL) { LOGPRINTF("Deallocating PD\n"); ret = VAPI_dealloc_pd(hca_hndl, pd_hndl); if(ret != VAPI_OK) { fprintf(stderr, "Error deallocating PD: %s\n", VAPI_strerror(ret)); } } /* Application code should not close HCA, just release handle */ if(hca_hndl != VAPI_INVAL_HNDL) { LOGPRINTF("Releasing HCA\n"); ret = EVAPI_release_hca_hndl(hca_hndl); if(ret != VAPI_OK) { fprintf(stderr, "Error releasing HCA: %s\n", VAPI_strerror(ret)); } } return 0; }