/********************************************************************** * * FUNCTION * vs_thread_kill * * DESCRIPTION * Kill the specified thread. * * INPUTS * * OUTPUTS * Status_t - On success VSTATUS_OK is returned, otherwise * the cause of the error. * * RESPONSIBLE ENGINEER: * Common Services * * HISTORY * * NAME DATE REMARKS * SFW 03/06/02 Initial creation of function. **********************************************************************/ Status_t vs_thread_kill (Thread_t *handle) { Status_t status; IB_ENTER (function, (unint) handle, (uint32_t) 0U, (uint32_t) 0U, (uint32_t) 0U); /* ** Verify required pointer arguments. */ if (handle == 0) { IB_LOG_ERROR0 ("handle parameter is null"); IB_EXIT (function, VSTATUS_ILLPARM); return VSTATUS_ILLPARM; } /* ** Invoke environment specific implmentation and return status. */ status = impl_vs_thread_kill(handle); IB_EXIT (function, status); return status; }
int mai_spawn_dc_reader(int qp, int dev, int port) { int rc; unsigned char name[VS_NAME_MAX]; IB_ENTER(__func__, qp, dev, port, 0); dc_reader_args.qp = qp; dc_reader_args.dev = dev; dc_reader_args.port = port; /* * start the workert thread */ (void) memset (name, 8, sizeof(name)); (void) sprintf((void *)name,"mai_dc"); rc = vs_thread_create (&dc_thandle, name, (void (*)(uint32_t, uint8_t **))dc_reader_start, 0,NULL , MAI_DC_STACK_SIZE); if (rc) { IB_LOG_ERRORRC("failed to create MAI layer server thread rc:", rc); IB_EXIT(__func__, rc); return rc; } else { /* need to wait (up to 2 seconds) for the dedicated dcthread to initialize here */ return(cs_psema_wait(&gMAI_DCTHREAD_SEMA, 2)); } IB_LOG_INFO("INFO: MAI layer server thread created ", rc); IB_EXIT(__func__, 0); return VSTATUS_OK; }
Status_t vs_event_delete (Event_t * ec) { static const char function[] = "vs_event_delete"; Implpriv_Event_t *implpriv; if (ec == 0) { IB_LOG_ERROR0 ("handle parameter is null"); IB_EXIT (function, VSTATUS_ILLPARM); return VSTATUS_ILLPARM; } implpriv = (Implpriv_Event_t *) (void *) & ec->opaque; if (implpriv->magic != IMPLPRIV_EVENT_MAGIC) { IB_LOG_ERRORX ("Invalid magic:", implpriv->magic); IB_EXIT (function, VSTATUS_NXIO); return VSTATUS_NXIO; } implpriv->magic = ~IMPLPRIV_EVENT_MAGIC; ec->event_handle = 0; deleteMask(implpriv->id); implpriv->id = 0; IB_EXIT (function, VSTATUS_OK); return VSTATUS_OK; }
/********************************************************************** * * FUNCTION * vs_thread_groupname * * DESCRIPTION * Return the globaly unique opaque thread group id for the * running user thread. * * INPUTS * * OUTPUTS * Status_t - On success VSTATUS_OK is returned, otherwise * the cause of the error. * * RESPONSIBLE ENGINEER: * Common Services * * HISTORY * * NAME DATE REMARKS * SFW 03/05/02 Initial creation of function. **********************************************************************/ Status_t vs_thread_groupname (Threadname_t name, Threadname_t *grpname) { Status_t status; IB_ENTER (function, name, (unint) grpname, (uint32_t) 0U, (uint32_t) 0U); /* ** Verify required pointer arguments. */ if (grpname == 0) { IB_LOG_ERROR0 ("group name parameter is null"); IB_EXIT (function, VSTATUS_ILLPARM); return VSTATUS_ILLPARM; } /* ** Invoke environment specific implmentation and return status. */ status = impl_vs_thread_groupname(name, grpname); IB_EXIT (function, status); return status; }
Status_t sa_SMInfoRecord(Mai_t *maip, sa_cntxt_t* sa_cntxt) { uint32_t records; uint16_t attribOffset; IB_ENTER("sa_SMInfoRecord", maip, 0, 0, 0); // // Assume failure. // records = 0; // // Check the method. If this is a template lookup, then call the regular // GetTable(*) template lookup routine. // switch (maip->base.method) { case SA_CM_GET: INCREMENT_COUNTER(smCounterSaRxGetSmInfoRecord); (void)sa_SMInfoRecord_GetTable(maip, &records); break; case SA_CM_GETTABLE: INCREMENT_COUNTER(smCounterSaRxGetTblSmInfoRecord); (void)sa_SMInfoRecord_GetTable(maip, &records); break; default: maip->base.status = MAD_STATUS_BAD_METHOD; (void)sa_send_reply(maip, sa_cntxt); IB_LOG_WARN("sa_SMInfoRecord: invalid METHOD:", maip->base.method); IB_EXIT("sa_SMInfoRecord", VSTATUS_OK); return(VSTATUS_OK); break; } // // Determine reply status // if (records == 0) { maip->base.status = MAD_STATUS_SA_NO_RECORDS; } else if ((maip->base.method == SA_CM_GET) && (records != 1)) { IB_LOG_WARN("sa_SMInfoRecord: too many records for SA_CM_GET:", records); records = 0; maip->base.status = MAD_STATUS_SA_TOO_MANY_RECS; } else { maip->base.status = MAD_STATUS_OK; } attribOffset = sizeof(STL_SMINFO_RECORD) + Calculate_Padding(sizeof(STL_SMINFO_RECORD)); /* setup attribute offset for possible RMPP transfer */ sa_cntxt->attribLen = attribOffset; sa_cntxt_data( sa_cntxt, sa_data, records * attribOffset); (void)sa_send_reply(maip, sa_cntxt ); IB_EXIT("sa_SMInfoRecord", VSTATUS_OK); return(VSTATUS_OK); }
int mai_dc_read(IBhandle_t fd) { int rc; IB_ENTER(__func__, fd, 0, 0, 0); if (gMAI_USE_DEDICATED_DCTHREAD) { if (gMAI_DCTHREAD_HANDLE != MAI_INVALID) { IB_LOG_WARNX("down call thread handle is busy handle:", gMAI_DCTHREAD_HANDLE); IB_EXIT(__func__, VSTATUS_BUSY); return VSTATUS_BUSY; } /* * Remember the handle associated with the thread */ gMAI_DCTHREAD_HANDLE = fd; /* release the waiting initiator thread */ cs_vsema(&gMAI_DCTHREAD_SEMA); } mai_dc_read_exit = 0; if (mai_dc_read_exit == 1) { IB_LOG_VERBOSE0("Mai DC Task exiting OK."); return VSTATUS_OK; } do { rc = mai_recv(fd, &mad, DC_THREAD_TIMEOUT); } while (rc == VSTATUS_TIMEOUT); if (rc != VSTATUS_TIMEOUT) { if (rc == VSTATUS_CONNECT_GONE) { IB_LOG_VERBOSERC("mai is shutting down rc:", rc); } else { IB_LOG_ERRORRC("bad status rc:", rc); } } if (gMAI_USE_DEDICATED_DCTHREAD) { /* * Reset the handle associated with the DC thread */ gMAI_DCTHREAD_HANDLE = MAI_INVALID; } IB_EXIT(__func__, rc); return rc; }
/********************************************************************** * * FUNCTION * cs_psema * * DESCRIPTION * Decrement a semaphore (wait or take operation) * * INPUTS * handle - A pointer to a semaphore object filled in by the * cs_sema_create() call. * * OUTPUTS * Status_t - On success VSTATUS_OK is returned, otherwise * the cause of the error. * * RESPONSIBLE ENGINEER: * CS Developers. * * HISTORY * * NAME DATE REMARKS * MGR 03/14/02 Initial creation of function. * MGR 04/18/02 PR1728. vs_psema should return VSTATUS_AGAIN * error code, if thread has been killed. * **********************************************************************/ Status_t cs_psema (Sema_t *handle) { Status_t rc; IB_ENTER (function, (unint)handle, (uint32_t)0U, (uint32_t)0U, (uint32_t)0U); /* ** Validate handle */ if (handle == (Sema_t *) 0) { IB_LOG_ERROR0 ("NULL handle pointer"); IB_EXIT (function, VSTATUS_ILLPARM); return VSTATUS_ILLPARM; } if (handle->magic != SEMAPHORE_MAGIC) { IB_LOG_ERRORX ("Invalid semaphore specified:", handle->magic); IB_EXIT (function, VSTATUS_NXIO); return VSTATUS_NXIO; } #ifdef __VXWORKS__ if (ERROR == semTake(handle->semId, WAIT_FOREVER)) { IB_LOG_ERROR0 ("Failed to take semaphore"); rc = VSTATUS_NXIO; IB_EXIT(function, rc); return rc; } handle->count--; #else // LINUX USER SEMA if (sem_wait((sem_t *)&handle->osdSema) != 0) { IB_LOG_ERROR0 ("Failed to take semaphore"); rc = VSTATUS_NXIO; IB_EXIT(function, rc); return rc; } #endif IB_EXIT (function, VSTATUS_OK); return VSTATUS_OK; }
/********************************************************************** * * FUNCTION * cs_psema * * DESCRIPTION * Decrement a semaphore (wait or take operation) * * INPUTS * handle - A pointer to a semaphore object filled in by the * cs_sema_create() call. * * OUTPUTS * Status_t - On success VSTATUS_OK is returned, otherwise * the cause of the error. * * RESPONSIBLE ENGINEER: * CS Developers. * * HISTORY * * NAME DATE REMARKS * MGR 03/14/02 Initial creation of function. * MGR 04/18/02 PR1728. vs_psema should return VSTATUS_AGAIN * error code, if thread has been killed. * **********************************************************************/ Status_t cs_psema_wait (Sema_t *handle, int timeout) { Status_t rc=VSTATUS_OK; IB_ENTER (function, (unint)handle, 0U, 0U, 0U); /* Validate handle */ if (handle == (Sema_t *) 0) { IB_LOG_ERROR0 ("NULL handle pointer"); IB_EXIT (function, VSTATUS_ILLPARM); return VSTATUS_ILLPARM; } if (handle->magic != SEMAPHORE_MAGIC) { IB_LOG_ERRORX ("Invalid semaphore specified:", handle->magic); IB_EXIT (function, VSTATUS_NXIO); return VSTATUS_NXIO; } if (timeout == CS_SEMA_WAIT_FOREVER) { return(cs_psema(handle)); } else { #ifdef __VXWORKS__ if (ERROR == semTake(handle->semId, timeout*sysClkRateGet())) { IB_LOG_WARN0("Timed out trying to take semaphore"); rc = VSTATUS_NXIO; } else { handle->count--; } #elif defined (__LINUX__) // LINUX USER SEMA int i=0, rc=-1; do { rc = sem_trywait((sem_t *)&handle->osdSema); ++i; (void)vs_thread_sleep(VTIMER_1S); } while (i<timeout && rc); if (rc != 0) { IB_LOG_WARN0("Timed out trying to take semaphore"); rc = VSTATUS_NXIO; } #endif } IB_EXIT (function, rc); return rc; }
/********************************************************************** * * FUNCTION * cs_sema_create * * DESCRIPTION * Initialize a counting semaphore object for use. * * INPUTS * handle - A pointer to a semaphore object to be filled in by * the routine. * count - The initial value for the semaphore. * * OUTPUTS * Status_t - On success VSTATUS_OK is returned, otherwise * the cause of the error. * * RESPONSIBLE ENGINEER: * CS Developers. * * HISTORY * * NAME DATE REMARKS * MGR 03/14/02 Initial creation of function. * **********************************************************************/ Status_t cs_sema_create (Sema_t *handle, uint32_t count) { Status_t rc; IB_ENTER (function, (unint)handle, (uint32_t)count, (uint32_t)0U, (uint32_t)0U); /* ** Validate handle */ if (handle == (Sema_t *) 0) { IB_LOG_ERROR0 ("NULL handle pointer"); IB_EXIT (function, VSTATUS_ILLPARM); return VSTATUS_ILLPARM; } #ifdef __VXWORKS__ handle->magic = SEMAPHORE_MAGIC; handle->semId = semCCreate(SEM_Q_FIFO, count); handle->count = count; if (!handle->semId) { IB_LOG_ERROR0 ("failed to allocate semaphore"); rc = VSTATUS_ILLPARM; IB_EXIT(function, rc); return rc; } #else // LINUX USER SEMA handle->magic = SEMAPHORE_MAGIC; if (sem_init((sem_t *)&handle->osdSema, 0, 0) != 0) { IB_LOG_ERROR0 ("failed to allocate semaphore"); rc = VSTATUS_ILLPARM; IB_EXIT(function, rc); return rc; } #endif // vxworks IB_EXIT (function, VSTATUS_OK); return VSTATUS_OK; }
/********************************************************************** * * FUNCTION * cs_sema_getcount * * DESCRIPTION * return counting semaphore count * * INPUTS * handle - A pointer to a semaphore object filled in by the * cs_sema_create() call. * * OUTPUTS * int - semaphore count * * RESPONSIBLE ENGINEER: * CS Developers. * * HISTORY * * NAME DATE REMARKS * JMS 02/20/07 Initial creation of function. * **********************************************************************/ Status_t cs_sema_getcount(Sema_t *handle, int *semCount) { Status_t rc = VSTATUS_OK; IB_ENTER (function, (unint)handle, 0U, 0U, 0U); /* Validate handle */ if (handle == (Sema_t *) 0) { IB_LOG_ERROR0 ("NULL handle pointer"); rc = VSTATUS_ILLPARM; } else if (handle->magic != SEMAPHORE_MAGIC) { IB_LOG_ERRORX ("Invalid semaphore specified:", handle->magic); rc = VSTATUS_NXIO; } else { #ifdef __VXWORKS__ *semCount = handle->count; #elif defined (__LINUX__) if ((sem_getvalue((sem_t *)&handle->osdSema, semCount)) != 0) { IB_LOG_ERROR0 ("Failed to get semaphore count"); rc = VSTATUS_NXIO; } #endif } IB_EXIT (function, rc); return rc; }
uint32_t fe_send_packet(NetConnection *conn, uint8_t *buf, int32_t len) { NetError err; OOBPacket* packet; /* Pointer to out of band packet */ uint32_t rc = SUCCESS; IB_ENTER(__func__, buf, len, 0, 0); packet = (OOBPacket *) buf; packet->Header.Length = len - sizeof(OOBHeader); BSWAP_OOB_PACKET(packet); IB_LOG_INFO0("Sending packet"); /* Do nothing if no conn */ if (!conn) { IB_LOG_ERROR0("failed: no connection"); return(FAILED); } if (fe_net_send(conn,(void *)buf,len,&err)) { IB_LOG_ERROR("Error err:", err); rc = FAILED; } IB_EXIT(__func__, rc); return(rc); }
Status_t sm_routing_alloc_cost_matrix(Topology_t *topop) { Status_t status; size_t bytesCost; /* Allocate space for the cost array. */ bytesCost = topop->max_sws * topop->max_sws * sizeof(uint16_t); if (bytesCost > topop->bytes) { topop->bytes = 0; if (topop->cost != NULL) { (void)vs_pool_free(&sm_pool, (void *)topop->cost); topop->cost = NULL; } status = vs_pool_alloc(&sm_pool, bytesCost, (void *)&topop->cost); if (status != VSTATUS_OK) { IB_LOG_ERRORRC("can't malloc cost array rc:", status); IB_EXIT(__func__, status); return status; } topop->bytes = bytesCost; } return VSTATUS_OK; }
/* * reserving context inserts it into the hash table if !hashed * and increments reference count */ Status_t sa_cntxt_reserve( sa_cntxt_t* sa_cntxt ) { int bucket; Status_t status; IB_ENTER( "sa_cntxt_reserve", sa_cntxt, 0, 0, 0 ); if ((status = vs_lock(&sa_cntxt_lock)) != VSTATUS_OK) { IB_LOG_ERRORRC("sa_cntxt_reserve: Failed to lock SA context rc:", status); } else { sa_cntxt->ref ++; if( sa_cntxt->hashed == 0 ) { // This context needs to be inserted into the hash table bucket = sa_cntxt->lid % SA_CNTXT_HASH_TABLE_DEPTH; sa_cntxt->hashed = 1 ; vs_time_get( &sa_cntxt->tstamp ); sa_cntxt_insert_head( sa_hash[ bucket ], sa_cntxt ); } if ((status = vs_unlock(&sa_cntxt_lock)) != VSTATUS_OK) { IB_LOG_ERRORRC("sa_cntxt_reserve: Failed to unlock SA context rc:", status); } } IB_EXIT( "sa_cntxt_reserve", VSTATUS_OK ); return VSTATUS_OK ; }
Status_t sa_cntxt_data( sa_cntxt_t* sa_cntxt, void* buf, uint32_t len ) { Status_t status ; IB_ENTER( "sa_cntxt_data", sa_cntxt, buf, len, 0 ); status = VSTATUS_OK ; if (!buf || !len) { sa_cntxt->data = NULL; sa_cntxt->len = 0; sa_cntxt->freeDataFunc = NULL; goto done; } status = vs_pool_alloc(&sm_pool, len, (void*)&sa_cntxt->data); if (status == VSTATUS_OK) { sa_cntxt->len = len; memcpy(sa_cntxt->data, buf, len); sa_cntxt->freeDataFunc = sa_cntxt_free_data; } else { sa_cntxt->len = 0; sa_cntxt->data = NULL; /* If data is NULL, sa_send_reply will send error response to caller */ sa_cntxt->freeDataFunc = NULL; } done: IB_EXIT("sa_cntxt_data", status); return status ; }
void fe_net_init_queue(NetQueue *q) { IB_ENTER(__func__,q,0,0,0); q->head = q->tail = NULL; IB_EXIT(__func__,0); }
static void sa_cntxt_retire( sa_cntxt_t* lcl_cntxt ) { IB_ENTER( "sa_cntxt_retire", lcl_cntxt, 0, 0, 0 ); // release getMulti request buffer if allocated if( lcl_cntxt->reqData ) { vs_pool_free( &sm_pool, lcl_cntxt->reqData ); } // If data was privately allocated, free it if (lcl_cntxt->freeDataFunc) { (void)lcl_cntxt->freeDataFunc(lcl_cntxt); } // Reset all fields lcl_cntxt->ref = 0 ; lcl_cntxt->isDS = 0; lcl_cntxt->reqDataLen = 0; lcl_cntxt->reqData = NULL ; lcl_cntxt->data = NULL ; lcl_cntxt->len = 0 ; lcl_cntxt->lid = 0 ; lcl_cntxt->tid = 0 ; lcl_cntxt->hashed = 0 ; lcl_cntxt->cache = NULL; lcl_cntxt->freeDataFunc = NULL; sa_cntxt_insert_head( sa_cntxt_free_list, lcl_cntxt ); INCR_SA_CNTXT_NFREE(); DECR_SA_CNTXT_NALLOC(); IB_EXIT( "sa_cntxt_retire", 0 ); }
/***************************************************************************** * * FUNCTION * help * * DESCRIPTION * prints out SYNTAX error/help message * * INPUTS * * OUTPUTS * ******************************************************************************/ static void help(uint8_t *progName) { IB_ENTER(__func__, 0, 0, 0, 0); if ((strcmp((void *)progName, "fab_exsim")) == 0) { printf("fab_exsim - Fabric Executive Simulator Server\n"); printf("Syntax: fab_exsim [ -d <ibdev> -m <port> -n <login> \n"); printf("\t -p <ibport> ] \n"); printf("\t -d Specify iba device to open\n"); printf("\t -m Specify port number to listen on\n"); printf("\t -n Turn login off\n"); printf("\t -p Specify iba port on the device\n"); } else if ((strcmp((void *)progName, "fe")) == 0) { printf("fe - Fabric Executive Control Server\n"); printf("Syntax: fe [ -d <ibdev> -e <env> -m <port> -n <login> -X <filename>\n"); printf("\t -p <ibport> ] \n"); printf("\t -d Specify iba device to open\n"); printf("\t -e Specify startup environment\n"); printf("\t -m Specify port number to listen on\n"); printf("\t -n Turn login off \n"); printf("\t -p Specify iba port on the device\n"); printf("\t -X config_filename\n"); } else if ((strcmp((void *)progName, "fab_tsim")) == 0) { printf("fab_tsim - Fabric Executive Test Server\n"); printf("Syntax: fab_tsim [ -n <login> -m <port> ] \n"); printf(" -m Specify port number to listen on\n"); printf(" -n Turn login off \n"); } printf(" -h prints this help message\n"); IB_EXIT(__func__, 0); exit(1); }
Status_t sm_fsm_discovering(Mai_t *maip, char *nodename) { Status_t status; STL_SM_INFO theirSmInfo; Lid_t slid=maip->addrInfo.slid; // original source lid; mai_reply swaps slid-dlid IB_ENTER(__func__, maip->base.amod, sm_state, 0, 0); BSWAPCOPY_STL_SM_INFO((STL_SM_INFO *)STL_GET_SMP_DATA(maip), &theirSmInfo); // // The SM in the DISCOVERING state does not have any valid transitions via // the Set(SMInfo) method. // maip->base.status = MAD_STATUS_BAD_ATTR; sm_smInfo.ActCount++; BSWAPCOPY_STL_SM_INFO(&sm_smInfo, (STL_SM_INFO *)STL_GET_SMP_DATA(maip)); status = mai_stl_reply(fd_async, maip, sizeof(STL_SM_INFO)); if (status != VSTATUS_OK) { IB_LOG_ERRORRC("sm_fsm_discovering - bad mai_reply rc:", status); } IB_LOG_WARN_FMT(__func__, "No transitions allowed from DISCOVERING state; Got %s request from [%s] SM node %s, LID [0x%x], portguid ["FMT_U64"], TID="FMT_U64, getAmod(maip->base.amod), sm_getStateText(theirSmInfo.u.s.SMStateCurrent), nodename, slid, theirSmInfo.PortGUID, maip->base.tid); IB_EXIT(__func__, 0); return(VSTATUS_OK); }
Status_t sa_create_template_mask(uint16_t type, uint64_t componentMask) { uint8_t bits; int16_t offset; int16_t length; IB_ENTER("sa_create_template_mask", type, componentMask, template_fieldp, 0); // // Zero out the global masking array. // (void)memset((void *)template_mask, 0, sizeof(template_mask)); // // The template global variables have been set by a previous call. So // we can use them here. (This assumes that SA remains single threaded.) // if (template_fieldp == NULL) { IB_EXIT("sa_create_template_mask", VSTATUS_OK); return(VSTATUS_OK); } // // Loop through the component mask and update the global 'template_mask' // while ((componentMask != 0ull) && (template_fieldp->length != 0)) { if ((componentMask & 1ull) != 0) { offset = template_fieldp->offset; length = template_fieldp->length; // // Fill out partial first byte. // if ((offset%8) != 0) { bits = (length < 8) ? 0xff >> (8-length) : 0xff; bits <<= (offset%8); if ((offset/8) < sizeof(template_mask)) template_mask[offset/8] |= bits; length -= (8 - (offset%8)); offset += (8 - (offset%8)); } // // Fill out full bytes. // while (length >= 8) { if ((offset/8) < sizeof(template_mask)) template_mask[offset/8] |= 0xff; offset += 8; length -= 8; } // // Fill out partial trailing byte. // if (length > 0) { bits = (length < 8) ? 0xff << (8-length) : 0xff; if ((offset/8) < sizeof(template_mask)) template_mask[offset/8] |= bits; } }
/********************************************************************** * * FUNCTION * vs_pool_delete * * DESCRIPTION * Does fundamental common validation for vs_pool_delete * parameters and invokes environment specific implmentation. * * INPUTS * * OUTPUTS * Status_t - On success VSTATUS_OK is returned, otherwise * the cause of the error. * * * HISTORY * * NAME DATE REMARKS * DKJ 03/07/02 Initial creation of function. **********************************************************************/ Status_t vs_pool_delete (Pool_t * handle) { Status_t rc; IB_ENTER (function, (unint) handle, (uint32_t) 0U, (uint32_t) 0U, (uint32_t) 0U); if (handle == 0) { IB_LOG_ERROR0 ("handle is null"); IB_EXIT (function, VSTATUS_ILLPARM); return VSTATUS_ILLPARM; } if (handle->magic != VSPOOL_MAGIC) { IB_LOG_ERRORX ("invalid handle magic:", handle->magic); IB_EXIT (function, VSTATUS_ILLPARM); return VSTATUS_ILLPARM; } rc = vs_lock (&handle->lock); if (rc != VSTATUS_OK) { IB_LOG_ERRORRC("vs_lock failed rc:", rc); IB_EXIT (function, VSTATUS_NXIO); return VSTATUS_NXIO; } rc = vs_implpool_delete (handle); if (rc == VSTATUS_OK) { handle->magic = ~VSPOOL_MAGIC; (void) vs_unlock (&handle->lock); (void) vs_lock_delete (&handle->lock); } else { (void) vs_unlock (&handle->lock); } (void) memset (handle, 0, sizeof (Pool_t)); IB_EXIT (function, rc); return rc; }
Status_t mai_get_stl_portinfo(IBhandle_t fd, STL_PORT_INFO * pinfop, uint8_t port) { Status_t status; struct mai_fd *act; IB_ENTER(__func__, fd, pinfop, port, 0); if (!gMAI_INITIALIZED) { IB_LOG_ERROR("not initialized port:", port); IB_EXIT(__func__, VSTATUS_INVALID_HANDL); return (VSTATUS_BAD); } /* * Validate parameters */ if ((fd < 0) || (fd >= MAI_MAX_CHANNELS)) { IB_LOG_ERROR("Invalid fd:", fd); IB_EXIT(__func__, VSTATUS_INVALID_HANDL); return (VSTATUS_INVALID_HANDL); } if (pinfop == NULL) { IB_LOG_ERROR("NULL pinfop fd:", fd); IB_EXIT(__func__, VSTATUS_ILLPARM); return (VSTATUS_ILLPARM); } act = &gMAI_CHANNELS[fd]; if (act->state == MAI_FREE) { IB_LOG_ERROR("Channel not active fd:", fd); IB_EXIT(__func__, VSTATUS_INVALID_HANDL); return (VSTATUS_INVALID_HANDL); } status = stl_get_portinfo(fd, pinfop, port, act->dev, act->port, act->qp); IB_EXIT(__func__, status); return (status); }
/********************************************************************** * * FUNCTION * vs_pool_size * * DESCRIPTION * Does fundamental common validation for vs_pool_size * parameters and invokes environment specific implmentation. * * INPUTS * * OUTPUTS * number of bytes allocated from pool. **********************************************************************/ Status_t vs_pool_size (Pool_t * handle, uint64_t *numBytesAlloc) { Status_t rc; IB_ENTER (function, (unint) handle, 0, 0, 0); if (handle == 0) { IB_LOG_ERROR0 ("handle is null"); IB_EXIT (function, VSTATUS_ILLPARM); return VSTATUS_ILLPARM; } if (handle->magic != VSPOOL_MAGIC) { IB_LOG_ERRORX ("invalid handle magic:", handle->magic); IB_EXIT (function, VSTATUS_ILLPARM); return VSTATUS_ILLPARM; } if (numBytesAlloc == 0) { IB_LOG_ERROR0 ("numBytesAlloc is null"); IB_EXIT (function, VSTATUS_ILLPARM); return VSTATUS_ILLPARM; } // TBD - do we need to lock here? rc = vs_lock (&handle->lock); if (rc != VSTATUS_OK) { IB_LOG_ERRORRC("vs_lock failed rc:", rc); *numBytesAlloc = 0; IB_EXIT (function, VSTATUS_NXIO); return VSTATUS_NXIO; } rc = vs_implpool_size (handle, numBytesAlloc); (void) vs_unlock (&handle->lock); IB_EXIT (function, rc); return rc; }
uint32_t fe_vieo_init(uint8_t *logName) { uint32_t rc = SUCCESS; static const char func[] = "fe_vieo_init"; IB_ENTER(func, 0, 0, 0, 0); fd_dm = INVALID_HANDLE; fdsa = INVALID_HANDLE; // initialize MAI subsystem mai_set_num_end_ports( MIN(fe_config.subnet_size, MAI_MAX_QUEUED_DEFAULT) ); mai_init(); IB_LOG_INFO("Device = ", fe_config.hca); rc = if3_register_fe(fe_config.hca,fe_config.port,(void *)FE_SERVICE_NAME,FE_SERVICE_ID, IF3_REGFORCE_PORT,&fdsa); if (rc != VSTATUS_OK) { if (fe_config.debug) IB_LOG_INFINI_INFORC("Failed to register with IF3, will try later. rc:", rc); } else { rc = fe_if3_subscribe_sa(); if (rc != VSTATUS_OK) { IB_LOG_ERRORRC("Failed to subscribe for traps in SA rc:", rc); } // connect to Performance Manager if (pm_lid) rc = if3_lid_mngr_cnx(fe_config.hca,fe_config.port,MAD_CV_VFI_PM,pm_lid,&fd_pm); else rc = if3_sid_mngr_cnx(fe_config.hca,fe_config.port,(void *)PM_SERVICE_NAME,PM_SERVICE_ID, MAD_CV_VFI_PM,&fd_pm); if (rc != VSTATUS_OK) { IB_LOG_INFINI_INFORC("Failed to open Performance Manager, will try later. rc:", rc); fd_pm = INVALID_HANDLE; } #ifdef DEVICE_MANAGER // not implemented yet // connect to Device Manager if (dm_lid) rc = if3_lid_mngr_cnx(fe_config.hca,fe_config.port,DM_IF3_MCLASS,dm_lid,&fd_dm); else rc = if3_sid_mngr_cnx(fe_config.hca,fe_config.port,DM_SERVICE_NAME,DM_SERVICE_ID, DM_IF3_MCLASS,&fd_dm); if (rc != VSTATUS_OK) { IB_LOG_INFINI_INFORC("Failed to open Device Manager, wil try later. rc:", rc); fd_dm = INVALID_HANDLE; } #endif } IB_EXIT(func, 0); return(rc); }
/********************************************************************** * * FUNCTION * vs_pool_free * * DESCRIPTION * Does fundamental common validation for vs_pool_free * parameters and invokes environment specific implmentation. * * INPUTS * * OUTPUTS * Status_t - On success VSTATUS_OK is returned, otherwise * the cause of the error. * * * HISTORY * * NAME DATE REMARKS * DKJ 03/07/02 Initial creation of function. **********************************************************************/ Status_t vs_pool_free (Pool_t * handle, void *loc) { Status_t rc; IB_ENTER (function, (unint) handle, (unint) loc, (uint32_t) 0U, (uint32_t) 0U); if (handle == 0) { IB_LOG_ERROR0 ("handle is null"); IB_EXIT (function, VSTATUS_ILLPARM); return VSTATUS_ILLPARM; } if (handle->magic != VSPOOL_MAGIC) { IB_LOG_ERRORX ("invalid handle magic:", handle->magic); IB_EXIT (function, VSTATUS_ILLPARM); return VSTATUS_ILLPARM; } if (loc == 0) { IB_LOG_ERROR0 ("loc is null"); IB_EXIT (function, VSTATUS_ILLPARM); return VSTATUS_ILLPARM; } rc = vs_lock (&handle->lock); if (rc != VSTATUS_OK) { IB_LOG_ERRORRC("vs_lock failed rc:", rc); IB_EXIT (function, VSTATUS_NXIO); return VSTATUS_NXIO; } rc = vs_implpool_free (handle, loc); (void) vs_unlock (&handle->lock); IB_EXIT (function, rc); return rc; }
Status_t state_event_timeout(void) { uint64_t now; Status_t status; static uint64_t lastStandbyCheck=0; IB_ENTER(__func__, 0, 0, 0, 0); // // If this is the STANDBY state, then we need to heartbeat the Master. // If this is the MASTER or DISCOVERING state, then we need to do a topology sweep. // // Note that sweeping in DISCOVERING is required to avoid deadlocks when we // abort a sweep before transitioning out of DISCOVERING. // if (lastStandbyCheck == 0) { (void)vs_time_get(&lastStandbyCheck); } if (sm_state == SM_STATE_STANDBY) { #if defined(IB_STACK_OPENIB) status = ib_refresh_devport(); if (status != VSTATUS_OK) { IB_LOG_ERRORRC("cannot refresh sm pkeys rc:", status); } #endif status = sm_check_Master(); if (status != VSTATUS_OK) { /* Master in trouble, start discovery */ (void)sm_transition(SM_STATE_DISCOVERING); sm_trigger_sweep(SM_SWEEP_REASON_MASTER_TROUBLE); } } else if (sm_state == SM_STATE_DISCOVERING || sm_state == SM_STATE_MASTER) { (void)vs_time_get(&now); if ((topology_wakeup_time != 0ull) && (now >= topology_wakeup_time)) { topology_wakeup_time = 0ull; lastStandbyCheck = now; sm_trigger_sweep(SM_SWEEP_REASON_SCHEDULED); } else if (sm_config.monitor_standby_enable && topology_wakeup_time != 0ull && sm_state == SM_STATE_MASTER && ((now - lastStandbyCheck) > sm_masterCheckInterval * sm_config.master_ping_max_fail)) { sm_dbsync_standbyCheck(); lastStandbyCheck = now; } } else if (sm_state == SM_STATE_NOTACTIVE) { // Notify master sm that we are going away. Most HSMs and the X switches // don't currently support capabilityMask trap indicating IsSm off. status = sm_check_Master(); } IB_EXIT(__func__, VSTATUS_OK); return(VSTATUS_OK); }
Status_t sa_VFabric_Set(uint8_t *vfrp, uint8_t vf, STL_SA_MAD *samad, uint64_t serviceId, IB_GID mGid) { STL_VFINFO_RECORD vfRecord = {0}; IB_ENTER("sa_VFabric_Set", vfrp, 0, 0, 0); VirtualFabrics_t *VirtualFabrics = old_topology.vfs_ptr; vfRecord.vfIndex = VirtualFabrics->v_fabric[vf].index; vfRecord.pKey = VirtualFabrics->v_fabric[vf].pkey; strncpy((void *)vfRecord.vfName, (void *)VirtualFabrics->v_fabric[vf].name, STL_VFABRIC_NAME_LEN); vfRecord.ServiceID = serviceId; vfRecord.MGID = mGid; if (VirtualFabrics->v_fabric[vf].security) { vfRecord.s1.selectFlags = STL_VFINFO_REC_SEL_PKEY_QUERY; } if (VirtualFabrics->v_fabric[vf].qos_enable) { vfRecord.s1.selectFlags |= STL_VFINFO_REC_SEL_SL_QUERY; } vfRecord.s1.mtu = VirtualFabrics->v_fabric[vf].max_mtu_int; vfRecord.s1.mtuSpecified = VirtualFabrics->v_fabric[vf].max_mtu_specified; vfRecord.s1.rate = VirtualFabrics->v_fabric[vf].max_rate_int; vfRecord.s1.rateSpecified = VirtualFabrics->v_fabric[vf].max_rate_specified; vfRecord.s1.pktLifeTimeInc = VirtualFabrics->v_fabric[vf].pkt_lifetime_mult; vfRecord.s1.pktLifeSpecified = VirtualFabrics->v_fabric[vf].pkt_lifetime_specified; vfRecord.s1.sl = VirtualFabrics->v_fabric[vf].base_sl; vfRecord.bandwidthPercent = VirtualFabrics->v_fabric[vf].percent_bandwidth; vfRecord.priority = VirtualFabrics->v_fabric[vf].priority; vfRecord.routingSLs = VirtualFabrics->v_fabric[vf].routing_sls; vfRecord.preemptionRank = VirtualFabrics->v_fabric[vf].preempt_rank; vfRecord.hoqLife = VirtualFabrics->v_fabric[vf].hoqlife_vf; vfRecord.optionFlags = 0; if (VirtualFabrics->v_fabric[vf].security) { vfRecord.optionFlags |= STL_VFINFO_REC_OPT_SECURITY; } if (old_topology.qosEnforced && VirtualFabrics->v_fabric[vf].qos_enable) { vfRecord.optionFlags |= STL_VFINFO_REC_OPT_QOS; } if (VirtualFabrics->v_fabric[vf].flowControlDisable) { vfRecord.optionFlags |= STL_VFINFO_REC_OPT_FLOW_DISABLE; } *(STL_VFINFO_RECORD*)vfrp = vfRecord; IB_EXIT("sa_VFabric_Set", VSTATUS_OK); return(VSTATUS_OK); }
static Status_t activate_switch(Topology_t * topop, Node_t * nodep, pActivationRetry_t retry) { Status_t status; IB_ENTER(__func__, topop, nodep, retry, 0); Port_t *port0p = sm_get_port(nodep, 0); if (!sm_valid_port(port0p) || port0p->state < IB_PORT_INIT) { IB_LOG_WARN_FMT(__func__, "Switch %s nodeGuid "FMT_U64" has invalid port 0: unable to activate", sm_nodeDescString(nodep), nodep->nodeInfo.NodeGUID); // fail outright without access to port 0 IB_EXIT(__func__, VSTATUS_BAD); return VSTATUS_BAD; } // activate port 0 via Set(PortInfo) if // - it's enhanced, AND... // - we're ARMED and retrying (as we only Set(PortStateInfo) on first attempt) // - we're ACTIVE and need a reregistration if ( nodep->switchInfo.u2.s.EnhancedPort0 && ( (port0p->state == IB_PORT_ARMED && activation_retry_attempts(retry)) || (port0p->state == IB_PORT_ACTIVE && needs_reregistration(nodep, port0p, retry)))) { status = sm_activate_port(topop, nodep, port0p, FALSE, retry); if (status != VSTATUS_OK) { IB_LOG_WARN_FMT(__func__, "Failed to activate node %s nodeGuid "FMT_U64" port 0: status=%u", sm_nodeDescString(nodep), nodep->nodeInfo.NodeGUID, status); } } // for remaining switch ports, use PortStateInfo on the first attempt status = activation_retry_attempts(retry) ? activate_switch_via_portinfo(topop, nodep, retry) : activate_switch_via_portstateinfo(topop, nodep, port0p, retry); IB_EXIT(__func__, status); return status; }
// "free" function for SA Contexts that contain allocated (non-cached) data // static Status_t sa_cntxt_free_data(sa_cntxt_t *cntxt) { IB_ENTER( "sa_cntxt_retire", cntxt, 0, 0, 0 ); if (cntxt->data) vs_pool_free(&sm_pool, cntxt->data); IB_EXIT( "sa_cntxt_retire", VSTATUS_OK); return VSTATUS_OK; }
static void dc_reader_start(void) { int rc; IB_ENTER(__func__, dc_reader_args.qp, dc_reader_args.dev, dc_reader_args.port, 0); rc = mai_dc_reader(dc_reader_args.qp, dc_reader_args.dev, dc_reader_args.port); IB_EXIT(__func__, rc); }
Status_t sa_template_test(uint8_t *src, uint8_t ** dstp, uint32_t length, uint32_t bytes, uint32_t * records) { Status_t status; IB_ENTER("sa_template_test", src, dstp, length, bytes); if ((status = sa_template_test_noinc(src, *dstp, length)) == VSTATUS_OK) { sa_increment_and_pad(dstp, length, bytes, records); } IB_EXIT("sa_template_test", status); return(status); }