/* * safely release context while already under lock protection */ static void cntxt_release( sa_cntxt_t* sa_cntxt ) { int bucket; if( sa_cntxt->ref == 0 ) { IB_LOG_INFINI_INFO0("cntxt_release: reference count is already zero"); return; /* context already retired */ } else { --sa_cntxt->ref; if( sa_cntxt->ref == 0 ) { // This context needs to be removed from hash if( sa_cntxt->hashed ) { bucket = sa_cntxt->lid % SA_CNTXT_HASH_TABLE_DEPTH; sa_cntxt_delete_entry( sa_hash[ bucket ], sa_cntxt ); } sa_cntxt->prev = sa_cntxt->next = NULL ; sa_cntxt_retire( sa_cntxt ); } } }
int mai_dc_reader(int qp, int dev, int port) { int rc; IBhandle_t fd; IB_ENTER(__func__, qp, dev, port, 0); rc = mai_open(qp, dev, port, &fd); if (rc != VSTATUS_OK) return rc; (void) mai_dc_read(fd); IB_LOG_INFINI_INFO0("MAI DC Reader shutting down.."); (void) mai_close(fd); IB_EXIT(__func__, 0); return 0; }
Status_t sa_cntxt_release( sa_cntxt_t* sa_cntxt ) { int bucket; Status_t status; IB_ENTER( "sa_cntxt_release", sa_cntxt, 0, 0, 0 ); if (!sa_cntxt) { IB_LOG_ERROR0("sa_cntxt_release: SA context is NULL!!!"); return VSTATUS_OK ; } if ((status = vs_lock(&sa_cntxt_lock)) != VSTATUS_OK) { IB_LOG_ERRORRC("sa_cntxt_release: Failed to lock SA context rc:", status); } else { if( sa_cntxt->ref == 0 ) { IB_LOG_INFINI_INFO0("sa_cntxt_release: reference count is already zero"); } else { --sa_cntxt->ref; if( sa_cntxt->ref == 0 ) { // This context needs to be removed from hash if( sa_cntxt->hashed ) { bucket = sa_cntxt->lid % SA_CNTXT_HASH_TABLE_DEPTH; sa_cntxt_delete_entry( sa_hash[ bucket ], sa_cntxt ); } sa_cntxt->prev = sa_cntxt->next = NULL ; sa_cntxt_retire( sa_cntxt ); } } if ((status = vs_unlock(&sa_cntxt_lock)) != VSTATUS_OK) { IB_LOG_ERRORRC("sa_cntxt_release: Failed to unlock SA context rc:", status); } } IB_EXIT( "sa_cntxt_release", VSTATUS_OK ); return VSTATUS_OK ; }
size_t count_nset(bitset_t* bitset) { size_t bits_counted = 0; size_t i = 0; size_t nset = 0; if (!bitset->bits_m) { IB_LOG_INFINI_INFO0("bad bits"); return 0; } for (i=0; i<=bitset->nwords_m; i++) { uint32_t word = bitset->bits_m[i]; size_t bit = 0; for (bit=0; bit < 32; bit++) { if (bits_counted >= bitset->nbits_m) return nset; if (word & (1<<bit)) { nset += 1; } bits_counted += 1; } } return nset; }
void saRmppDebugOff(void) { saDebugRmpp = 0; IB_LOG_INFINI_INFO0("saRmppDebugOff: Turning OFF SaRmppDebug"); }
void saRmppDebugOn(void) { saDebugRmpp = 1; IB_LOG_INFINI_INFO0("saRmppDebugOn: Turning ON SaRmppDebug"); }
void saPerfDebugOff(void) { saDebugPerf = 0; IB_LOG_INFINI_INFO0("saPerfDebugOff: Turning OFF SaPerfDebug"); }
void saPerfDebugOn(void) { saDebugPerf = 1; IB_LOG_INFINI_INFO0("saPerfDebugOn: Turning ON SaPerfDebug"); }
hsm_com_errno_t fe_conf_callback(hsm_com_datagram_t *data) { fm_config_datagram_t *msg; if(data->data_len >= sizeof(msg->header)){ msg = (fm_config_datagram_t*)data->buf; switch (msg->header.data_id) { case FM_DT_COMMON: if (msg->header.data_len != sizeof(fm_config_common_t)) { msg->header.ret_code = FM_RET_BAD_LEN; } else { msg->header.ret_code = fe_conf_fill_common(msg->header.action,(fm_config_common_t*)&msg->data[0]); } break; case FM_DT_FE_CFG: if (msg->header.data_len != sizeof(fe_config_t)) { msg->header.ret_code = FM_RET_BAD_LEN; } else { msg->header.ret_code = fe_conf_fill_fe_conf(msg->header.action,(fe_config_t*)&msg->data[0]); } break; case FM_DT_LOG_LEVEL: fe_set_log_level(*(uint32_t *)&msg->data[0]); msg->header.ret_code = FM_RET_OK; break; case FM_DT_LOG_MODE: fe_set_log_mode(*(uint32_t *)&msg->data[0]); msg->header.ret_code = FM_RET_OK; break; case FM_DT_LOG_MASK: fe_set_log_mask((char*)&msg->data[sizeof(uint32_t)], *(uint32_t *)&msg->data[0]); msg->header.ret_code = FM_RET_OK; break; case FM_DT_DEBUG_TOGGLE: if (feDebugGet()) { feDebugOff(); IB_LOG_INFINI_INFO0("Turning OFF Debug for FE"); } else { feDebugOn(); IB_LOG_INFINI_INFO0("Turning ON Debug for FE"); } msg->header.ret_code = FM_RET_OK; break; case FM_DT_RMPP_DEBUG_TOGGLE: if (if3RmppDebugGet()) { IB_LOG_INFINI_INFO0("turning rmpp debug off for FE"); if3RmppDebugOff(); } else { IB_LOG_INFINI_INFO0("turning rmpp debug on for FE"); if3RmppDebugOn(); } msg->header.ret_code = FM_RET_OK; break; default: msg->header.ret_code = FM_RET_UNKNOWN_DT; break; } return HSM_COM_OK; } return HSM_COM_ERR_LEN; }
hsm_com_errno_t pm_conf_callback(hsm_com_datagram_t *data) { fm_config_datagram_t *msg; char * tmpData = NULL; int length = 0; printf("pm_conf_callback: LEN: %d, BUFLEN: %d \n", data->data_len,data->buf_size); if(data->data_len >= sizeof(msg->header)){ msg = (fm_config_datagram_t*)data->buf; switch (msg->header.data_id) { case FM_DT_COMMON: if (msg->header.data_len != sizeof(fm_config_common_t)) { msg->header.ret_code = FM_RET_BAD_LEN; } else { msg->header.ret_code = pm_conf_fill_common(msg->header.action,(fm_config_common_t*)&msg->data[0]); } break; case FM_DT_PM_CFG: if (msg->header.data_len != sizeof(pm_config_t)) { msg->header.ret_code = FM_RET_BAD_LEN; } else { msg->header.ret_code = pm_conf_fill_pm_conf(msg->header.action,(pm_config_t*)&msg->data[0]); } break; case FM_DT_PM_RESTORE_PRIORITY: case FM_DT_LOG_LEVEL: case FM_DT_LOG_MODE: case FM_DT_LOG_MASK: msg->header.ret_code = FM_RET_UNKNOWN_DT; break; case FM_DT_DEBUG_TOGGLE: if (pmDebugGet()) { pmDebugOff(); IB_LOG_INFINI_INFO0("Turning OFF Debug for PM"); } else { pmDebugOn(); IB_LOG_INFINI_INFO0("Turning ON Debug for PM"); } msg->header.ret_code = FM_RET_OK; break; case FM_DT_RMPP_DEBUG_TOGGLE: if (if3RmppDebugGet()) { IB_LOG_INFINI_INFO0("turning rmpp debug off for PM"); if3RmppDebugOff(); } else { IB_LOG_INFINI_INFO0("turning rmpp debug on for PM"); if3RmppDebugOn(); } msg->header.ret_code = FM_RET_OK; break; case FM_DT_PM_GET_COUNTERS: tmpData = pm_print_counters_to_buf(); printf("%s\n", tmpData); if (tmpData != NULL) { length = strlen(tmpData) + 1; memcpy(&msg->data[0], tmpData, MIN(msg->header.data_len, length)); msg->data[msg->header.data_len - 1] = '\0'; /* PR 116307 - buffer returned from pm_print_counters_to_buf() is from * sm_pool, so free the buffer from smpool. */ vs_pool_free(&sm_pool, tmpData); } msg->header.ret_code = FM_RET_OK; break; case FM_DT_PM_RESET_COUNTERS: pm_reset_counters(); msg->header.ret_code = FM_RET_OK; break; default: msg->header.ret_code = FM_RET_UNKNOWN_DT; break; } return HSM_COM_OK; } return HSM_COM_ERR_LEN; }