/* * dapl_hca_alloc * * alloc and initialize an HCA struct * * Input: * name * port * * Output: * hca_ptr * * Returns: * none * */ DAPL_HCA *dapl_hca_alloc(char *name, char *port) { DAPL_HCA *hca_ptr; hca_ptr = dapl_os_alloc(sizeof(DAPL_HCA)); if (NULL == hca_ptr) { goto bail; } dapl_os_memzero(hca_ptr, sizeof(DAPL_HCA)); dapl_os_lock_init(&hca_ptr->lock); dapl_llist_init_head(&hca_ptr->ia_list_head); hca_ptr->name = dapl_os_strdup(name); if (NULL == hca_ptr->name) { goto bail; } hca_ptr->ib_hca_handle = IB_INVALID_HANDLE; hca_ptr->port_num = dapl_os_strtol(port, NULL, 0); return (hca_ptr); bail: if (NULL != hca_ptr) dapl_os_free(hca_ptr, sizeof(DAPL_HCA)); return NULL; }
/* * dapl_cno_alloc * * alloc and initialize an EVD struct * * Input: * ia * * Returns: * cno_ptr, or null on failure. */ DAPL_CNO * dapl_cno_alloc( IN DAPL_IA *ia_ptr, IN DAT_OS_WAIT_PROXY_AGENT wait_agent) { DAPL_CNO *cno_ptr; cno_ptr = (DAPL_CNO *) dapl_os_alloc(sizeof (DAPL_CNO)); if (!cno_ptr) { return (NULL); } /* zero the structure */ (void) dapl_os_memzero(cno_ptr, sizeof (DAPL_CNO)); /* * Initialize the header. */ cno_ptr->header.provider = ia_ptr->header.provider; cno_ptr->header.magic = DAPL_MAGIC_CNO; cno_ptr->header.handle_type = DAT_HANDLE_TYPE_CNO; cno_ptr->header.owner_ia = ia_ptr; cno_ptr->header.user_context.as_64 = 0; cno_ptr->header.user_context.as_ptr = NULL; dapl_llist_init_entry(&cno_ptr->header.ia_list_entry); dapl_llist_init_head(&cno_ptr->evd_list_head); dapl_os_lock_init(&cno_ptr->header.lock); /* * Initialize the body */ cno_ptr->cno_waiters = 0; cno_ptr->cno_ref_count = 0; cno_ptr->cno_state = DAPL_CNO_STATE_UNTRIGGERED; cno_ptr->cno_evd_triggered = NULL; cno_ptr->cno_wait_agent = wait_agent; (void) dapl_os_wait_object_init(&cno_ptr->cno_wait_object); return (cno_ptr); }
/* * dapl_sp_alloc * * alloc and initialize a PSP INFO struct * * Input: * IA INFO struct ptr * * Output: * sp_ptr * * Returns: * NULL * pointer to sp info struct * */ DAPL_SP * dapls_sp_alloc( IN DAPL_IA *ia_ptr, IN DAT_BOOLEAN is_psp) { DAPL_SP *sp_ptr; /* Allocate EP */ sp_ptr = (DAPL_SP *)dapl_os_alloc(sizeof (DAPL_SP)); if (sp_ptr == NULL) { return (NULL); } /* zero the structure */ (void) dapl_os_memzero(sp_ptr, sizeof (DAPL_SP)); /* * initialize the header */ sp_ptr->header.provider = ia_ptr->header.provider; if (is_psp) { sp_ptr->header.magic = DAPL_MAGIC_PSP; sp_ptr->header.handle_type = DAT_HANDLE_TYPE_PSP; } else { sp_ptr->header.magic = DAPL_MAGIC_RSP; sp_ptr->header.handle_type = DAT_HANDLE_TYPE_RSP; } sp_ptr->header.owner_ia = ia_ptr; sp_ptr->header.user_context.as_64 = 0; sp_ptr->header.user_context.as_ptr = NULL; dapl_llist_init_entry(&sp_ptr->header.ia_list_entry); dapl_os_lock_init(&sp_ptr->header.lock); /* * Initialize the Body (set to NULL above) */ dapl_llist_init_head(&sp_ptr->cr_list_head); return (sp_ptr); }