/********************************************************************************* * Name :glsv_gld_mbcsv_dec_warm_sync_resp * * Description : To decode the message at the warm sync at the standby * Arguments : NCS_MBCSV_CB_ARG - MBCSv callback argument * * Return Values : Success / Error *********************************************************************************/ static uint32_t glsv_gld_mbcsv_dec_warm_sync_resp(GLSV_GLD_CB *gld_cb, NCS_MBCSV_CB_ARG *arg) { uint32_t num_of_async_upd, rc = NCSCC_RC_SUCCESS; uint8_t data[16], *ptr; NCS_MBCSV_ARG ncs_arg; TRACE_ENTER(); /*TBD check for the validity of gld_cb arg */ memset(&ncs_arg, '\0', sizeof(NCS_MBCSV_ARG)); ptr = ncs_dec_flatten_space(&arg->info.decode.i_uba, data, sizeof(int32_t)); num_of_async_upd = ncs_decode_32bit(&ptr); ncs_dec_skip_space(&arg->info.decode.i_uba, 4); if (gld_cb->gld_async_cnt == num_of_async_upd) { goto end; } else { gld_cb_destroy(gld_cb); ncs_arg.i_op = NCS_MBCSV_OP_SEND_DATA_REQ; ncs_arg.i_mbcsv_hdl = gld_cb->mbcsv_handle; ncs_arg.info.send_data_req.i_ckpt_hdl = gld_cb->o_ckpt_hdl; rc = ncs_mbcsv_svc(&ncs_arg); if (rc != NCSCC_RC_SUCCESS) { /* Log */ /* TBD */ goto end; } } end: TRACE_LEAVE(); return rc; }
/****************************************************************************\ * Function: avnd_send_data_req * * Purpose: Encode data request to be sent. * * Input: cb - AVND CB pointer. * * Returns: NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE. * * NOTES: * * \**************************************************************************/ uns32 avnd_send_data_req(AVND_CB *cb) { NCS_MBCSV_ARG mbcsv_arg; NCS_UBAID *uba = NULL; TRACE_ENTER(); memset(&mbcsv_arg, '\0', sizeof(NCS_MBCSV_ARG)); mbcsv_arg.i_op = NCS_MBCSV_OP_SEND_DATA_REQ; mbcsv_arg.i_mbcsv_hdl = cb->avnd_mbcsv_hdl; uba = &mbcsv_arg.info.send_data_req.i_uba; memset(uba, '\0', sizeof(NCS_UBAID)); mbcsv_arg.info.send_data_req.i_ckpt_hdl = cb->avnd_mbcsv_ckpt_hdl; if (NCSCC_RC_SUCCESS != ncs_mbcsv_svc(&mbcsv_arg)) { LOG_ER("MBCSV send data req failed"); return NCSCC_RC_FAILURE; } TRACE_LEAVE(); return NCSCC_RC_SUCCESS; }
/********************************************************************************************** * Name : gld_mbcsv_async_update * * Description : This routine sends async update events to Standby * * Arguments : gld_ab, a2s_evt * * Return Values : * * Notes : None **********************************************************************************************/ uint32_t glsv_gld_mbcsv_async_update(GLSV_GLD_CB *gld_cb, GLSV_GLD_A2S_CKPT_EVT *a2s_evt) { NCS_MBCSV_ARG arg; uint32_t rc = SA_AIS_OK; TRACE_ENTER(); if ((a2s_evt == NULL) || (gld_cb == NULL)) { LOG_ER("GLD ncs mbcsv svc failed"); rc = NCSCC_RC_FAILURE; goto end; } /* populate the arg structure */ arg.i_op = NCS_MBCSV_OP_SEND_CKPT; arg.i_mbcsv_hdl = gld_cb->mbcsv_handle; arg.info.send_ckpt.i_ckpt_hdl = gld_cb->o_ckpt_hdl; arg.info.send_ckpt.i_send_type = NCS_MBCSV_SND_SYNC; arg.info.send_ckpt.i_reo_type = a2s_evt->evt_type; arg.info.send_ckpt.i_reo_hdl = NCS_PTR_TO_UNS64_CAST(a2s_evt); arg.info.send_ckpt.i_action = NCS_MBCSV_ACT_UPDATE; /*send the message using MBCSv */ rc = ncs_mbcsv_svc(&arg); if (rc != SA_AIS_OK) LOG_ER("GLD ncs mbcsv svc failed"); end: TRACE_LEAVE(); return rc; }
/********************************************************************************************************* * Name : glsv_gld_mbcsv_open * * Description : To open a session with MBCSv * * Arguments : GLSV_GLD_CB - gld_cb pointer * * Return Values : * * Notes : Open call will set up a session between the peer entities. o_ckpt_hdl returned by the OPEN call will uniquely identify the checkpoint session. *********************************************************************************************************/ static uint32_t glsv_gld_mbcsv_open(GLSV_GLD_CB *gld_cb) { NCS_MBCSV_ARG arg; uint32_t rc = NCSCC_RC_SUCCESS; TRACE_ENTER(); if (gld_cb == NULL) { LOG_ER("GLD mbcsv open failed"); rc = NCSCC_RC_FAILURE; goto end; } memset(&arg, '\0', sizeof(NCS_MBCSV_ARG)); arg.i_op = NCS_MBCSV_OP_OPEN; arg.i_mbcsv_hdl = gld_cb->mbcsv_handle; arg.info.open.i_pwe_hdl = (uint32_t)gld_cb->mds_handle; arg.info.open.i_client_hdl = gld_cb->my_hdl; /* arg.info.open.o_ckpt_hdl = NULL; */ if (ncs_mbcsv_svc(&arg) != SA_AIS_OK) { LOG_ER("GLD mbcsv open failed"); rc = NCSCC_RC_FAILURE; goto end; } else { TRACE_1("GLD mbcsv open success"); gld_cb->o_ckpt_hdl = arg.info.open.o_ckpt_hdl; goto end; } end: TRACE_LEAVE(); return rc; }
/************************************************************************************************ * Name : glsv_gld_mbcsv_init * * Description : To initialize with MBCSv * * Arguments : GLD_CB : cb pointer * * Return Values : * * Notes : None *************************************************************************************************/ uint32_t glsv_gld_mbcsv_init(GLSV_GLD_CB *gld_cb) { NCS_MBCSV_ARG arg; uint32_t rc = NCSCC_RC_FAILURE; TRACE_ENTER(); if (gld_cb == NULL) { LOG_ER("GLD mbcsv init failed"); goto end; } memset(&arg, '\0', sizeof(NCS_MBCSV_ARG)); arg.i_op = NCS_MBCSV_OP_INITIALIZE; arg.info.initialize.i_mbcsv_cb = glsv_gld_mbcsv_callback; arg.info.initialize.i_version = GLSV_GLD_MBCSV_VERSION; arg.info.initialize.i_service = NCS_SERVICE_ID_GLD; if (ncs_mbcsv_svc(&arg) != SA_AIS_OK) { LOG_ER("GLD mbcsv init failed"); goto end; } else { TRACE_1("GLD mbcsv init success"); gld_cb->mbcsv_handle = arg.info.initialize.o_mbcsv_hdl; rc = NCSCC_RC_SUCCESS; } end: TRACE_LEAVE(); return rc; }
/****************************************************************************\ * Function: avsv_mbcsv_finalize * * Purpose: Finalize AVSV with MBCSV * * Input: cb - AVD control block pointer. * * Returns: NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE. * * NOTES: * * \**************************************************************************/ static uns32 avsv_mbcsv_finalize(AVD_CL_CB *cb) { NCS_MBCSV_ARG mbcsv_arg = {0}; mbcsv_arg.i_op = NCS_MBCSV_OP_FINALIZE; mbcsv_arg.i_mbcsv_hdl = cb->mbcsv_hdl; if (NCSCC_RC_SUCCESS != ncs_mbcsv_svc(&mbcsv_arg)) { LOG_ER("%s: ncs_mbcsv_svc NCS_MBCSV_OP_FINALIZE failed", __FUNCTION__); return NCSCC_RC_FAILURE; } return NCSCC_RC_SUCCESS; }
/****************************************************************************\ * Function: avsv_mbcsv_close_ckpt * * Purpose: Close checkpoint. * * Input: cb - AVD control block pointer. * * Returns: NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE. * * NOTES: * * \**************************************************************************/ static uns32 avsv_mbcsv_close_ckpt(AVD_CL_CB *cb) { NCS_MBCSV_ARG mbcsv_arg = {0}; mbcsv_arg.i_op = NCS_MBCSV_OP_CLOSE; mbcsv_arg.i_mbcsv_hdl = cb->mbcsv_hdl; mbcsv_arg.info.close.i_ckpt_hdl = cb->ckpt_hdl; if (NCSCC_RC_SUCCESS != ncs_mbcsv_svc(&mbcsv_arg)) { LOG_ER("%s: ncs_mbcsv_svc NCS_MBCSV_OP_CLOSE failed", __FUNCTION__); return NCSCC_RC_FAILURE; } return NCSCC_RC_SUCCESS; }
/************************************************************************************** * Name : glsv_gld_mbcsv_finalize * * Description : To close the association of GLD with MBCSv * Arguments : GLD_CB - cb pointer * * Return Values : Success / Error * * Notes : Closes the association, represented by i_mbc_hdl, between the invok ing process and MBCSV ***************************************************************************************/ static uint32_t glsv_gld_mbcsv_finalize(GLSV_GLD_CB *gld_cb) { NCS_MBCSV_ARG arg; uint32_t rc = NCSCC_RC_SUCCESS; TRACE_ENTER(); memset(&arg, '\0', sizeof(NCS_MBCSV_ARG)); arg.i_op = NCS_MBCSV_OP_FINALIZE; arg.i_mbcsv_hdl = gld_cb->mbcsv_handle; if (ncs_mbcsv_svc(&arg) != SA_AIS_OK) { LOG_ER("GLD mbcsv finalize failed"); rc = NCSCC_RC_FAILURE; } TRACE_LEAVE(); return rc; }
/****************************************************************************\ * Function: avsv_get_mbcsv_sel_obj * * Purpose: Get MBCSv Selection object. * * Input: cb - AVD control block pointer. * * Returns: NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE. * * NOTES: * * \**************************************************************************/ static uns32 avsv_get_mbcsv_sel_obj(AVD_CL_CB *cb) { NCS_MBCSV_ARG mbcsv_arg = {0}; mbcsv_arg.i_op = NCS_MBCSV_OP_SEL_OBJ_GET; mbcsv_arg.i_mbcsv_hdl = cb->mbcsv_hdl; if (NCSCC_RC_SUCCESS != ncs_mbcsv_svc(&mbcsv_arg)) { LOG_ER("%s: ncs_mbcsv_svc NCS_MBCSV_OP_SEL_OBJ_GET failed", __FUNCTION__); return NCSCC_RC_FAILURE; } cb->mbcsv_sel_obj = mbcsv_arg.info.sel_obj_get.o_select_obj; return NCSCC_RC_SUCCESS; }
/****************************************************************************\ * Function: avsv_mbcsv_open_ckpt * * Purpose: Open checkpoint. * * Input: cb - AVD control block pointer. * * Returns: NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE. * * NOTES: * * \**************************************************************************/ static uns32 avsv_mbcsv_open_ckpt(AVD_CL_CB *cb) { NCS_MBCSV_ARG mbcsv_arg = {0}; mbcsv_arg.i_op = NCS_MBCSV_OP_OPEN; mbcsv_arg.i_mbcsv_hdl = cb->mbcsv_hdl; mbcsv_arg.info.open.i_pwe_hdl = cb->vaddr_pwe_hdl; if (NCSCC_RC_SUCCESS != ncs_mbcsv_svc(&mbcsv_arg)) { LOG_ER("%s: ncs_mbcsv_svc NCS_MBCSV_OP_OPEN failed", __FUNCTION__); return NCSCC_RC_FAILURE; } cb->ckpt_hdl = mbcsv_arg.info.open.o_ckpt_hdl; return NCSCC_RC_SUCCESS; }
/****************************************************************************\ * Function: avnd_mbcsv_open_ckpt * * Purpose: Open checkpoint. * * Input: cb - AVND control block pointer. * * Returns: NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE. * * NOTES: * * \**************************************************************************/ static uns32 avnd_mbcsv_open_ckpt(AVND_CB *cb) { NCS_MBCSV_ARG mbcsv_arg; memset(&mbcsv_arg, '\0', sizeof(NCS_MBCSV_ARG)); mbcsv_arg.i_op = NCS_MBCSV_OP_OPEN; mbcsv_arg.i_mbcsv_hdl = cb->avnd_mbcsv_hdl; mbcsv_arg.info.open.i_pwe_hdl = cb->avnd_mbcsv_vaddr_pwe_hdl; if (NCSCC_RC_SUCCESS != ncs_mbcsv_svc(&mbcsv_arg)) return NCSCC_RC_FAILURE; cb->avnd_mbcsv_ckpt_hdl = mbcsv_arg.info.open.o_ckpt_hdl; return NCSCC_RC_SUCCESS; }
/****************************************************************************\ * Function: avnd_mbcsv_dispatch * * Purpose: Perform dispatch operation on MBCSV selection object. * * Input: cb - AVND control block pointer. * sel_obj - Selection object returned. * * Returns: NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE. * * NOTES: * * \**************************************************************************/ uns32 avnd_mbcsv_dispatch(AVND_CB *cb, uns32 flag) { NCS_MBCSV_ARG mbcsv_arg; memset(&mbcsv_arg, '\0', sizeof(NCS_MBCSV_ARG)); mbcsv_arg.i_op = NCS_MBCSV_OP_DISPATCH; mbcsv_arg.i_mbcsv_hdl = cb->avnd_mbcsv_hdl; mbcsv_arg.info.dispatch.i_disp_flags = flag; if (NCSCC_RC_SUCCESS != ncs_mbcsv_svc(&mbcsv_arg)) { LOG_ER("MBCSv dispatch failed"); return NCSCC_RC_FAILURE; } return NCSCC_RC_SUCCESS; }
/****************************************************************************\ * Function: avsv_mbcsv_obj_set * * Purpose: Set MBCSv objects * * Input: cb - AVD control block pointer. * * Returns: NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE. * * NOTES: * * \**************************************************************************/ uns32 avsv_mbcsv_obj_set(AVD_CL_CB *cb, uns32 obj, uns32 val) { NCS_MBCSV_ARG mbcsv_arg = {0}; mbcsv_arg.i_op = NCS_MBCSV_OP_OBJ_SET; mbcsv_arg.i_mbcsv_hdl = cb->mbcsv_hdl; mbcsv_arg.info.obj_set.i_ckpt_hdl = cb->ckpt_hdl; mbcsv_arg.info.obj_set.i_obj = obj; mbcsv_arg.info.obj_set.i_val = val; if (NCSCC_RC_SUCCESS != ncs_mbcsv_svc(&mbcsv_arg)) { LOG_ER("%s: ncs_mbcsv_svc NCS_MBCSV_OP_OBJ_SET failed", __FUNCTION__); return NCSCC_RC_FAILURE; } return NCSCC_RC_SUCCESS; }
/****************************************************************************\ * Function: avnd_get_mbcsv_sel_obj * * Purpose: Get MBCSv Selection object. * * Input: cb - AVND control block pointer. * * Returns: NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE. * * NOTES: * * \**************************************************************************/ static uns32 avnd_get_mbcsv_sel_obj(AVND_CB *cb) { NCS_MBCSV_ARG mbcsv_arg; /* LOG HERE */ memset(&mbcsv_arg, '\0', sizeof(NCS_MBCSV_ARG)); mbcsv_arg.i_op = NCS_MBCSV_OP_SEL_OBJ_GET; mbcsv_arg.i_mbcsv_hdl = cb->avnd_mbcsv_hdl; if (NCSCC_RC_SUCCESS != ncs_mbcsv_svc(&mbcsv_arg)) return NCSCC_RC_FAILURE; cb->avnd_mbcsv_sel_obj = mbcsv_arg.info.sel_obj_get.o_select_obj; return NCSCC_RC_SUCCESS; }
/****************************************************************************\ * Function: avnd_mbcsv_initialize * * Purpose: Initialize AVND with MBCSV * * Input: cb - AVND control block pointer. * * Returns: NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE. * * NOTES: * * \**************************************************************************/ static uns32 avnd_mbcsv_initialize(AVND_CB *cb) { NCS_MBCSV_ARG mbcsv_arg; memset(&mbcsv_arg, '\0', sizeof(NCS_MBCSV_ARG)); mbcsv_arg.i_op = NCS_MBCSV_OP_INITIALIZE; mbcsv_arg.info.initialize.i_service = NCSMDS_SVC_ID_AVND_CNTLR; mbcsv_arg.info.initialize.i_mbcsv_cb = avnd_mbcsv_cb; mbcsv_arg.info.initialize.i_version = AVND_MBCSV_SUB_PART_VERSION; if (NCSCC_RC_SUCCESS != ncs_mbcsv_svc(&mbcsv_arg)) return NCSCC_RC_FAILURE; cb->avnd_mbcsv_hdl = mbcsv_arg.info.initialize.o_mbcsv_hdl; return NCSCC_RC_SUCCESS; }
/*********************************************************************** * Name : glsv_gld_mbcsv_close * * Description : To close the association * * Arguments : * * Return Values : Success / Error ****************************************************************************/ static uint32_t glsv_gld_mbcsv_close(GLSV_GLD_CB *cb) { NCS_MBCSV_ARG arg; uint32_t rc = NCSCC_RC_SUCCESS; TRACE_ENTER(); memset(&arg, '\0', sizeof(NCS_MBCSV_ARG)); arg.i_op = NCS_MBCSV_OP_CLOSE; arg.info.close.i_ckpt_hdl = cb->o_ckpt_hdl; if (ncs_mbcsv_svc(&arg) != SA_AIS_OK) { LOG_ER("GLD mbcsv close failed"); rc = NCSCC_RC_FAILURE; } TRACE_LEAVE(); return rc; }
/****************************************************************************\ * Function: avsv_mbcsv_dispatch * * Purpose: Perform dispatch operation on MBCSV selection object. * * Input: cb - AVD control block pointer. * sel_obj - Selection object returned. * * Returns: NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE. * * NOTES: * * \**************************************************************************/ uns32 avsv_mbcsv_dispatch(AVD_CL_CB *cb, uns32 flag) { NCS_MBCSV_ARG mbcsv_arg; uns32 rc; memset(&mbcsv_arg, '\0', sizeof(NCS_MBCSV_ARG)); mbcsv_arg.i_op = NCS_MBCSV_OP_DISPATCH; mbcsv_arg.i_mbcsv_hdl = cb->mbcsv_hdl; mbcsv_arg.info.dispatch.i_disp_flags = flag; if (NCSCC_RC_SUCCESS != (rc = ncs_mbcsv_svc(&mbcsv_arg))) { LOG_ER("ncs_mbcsv_svc NCS_MBCSV_OP_DISPATCH %u failed", rc); return NCSCC_RC_FAILURE; } return NCSCC_RC_SUCCESS; }
/****************************************************************************\ * Function: avnd_mbcsv_finalize * * Purpose: Finalize AVND with MBCSV * * Input: cb - AVND control block pointer. * * Returns: NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE. * * NOTES: * * \**************************************************************************/ static uns32 avnd_mbcsv_finalize(AVND_CB *cb) { NCS_MBCSV_ARG mbcsv_arg; /* LOG HERE */ memset(&mbcsv_arg, '\0', sizeof(NCS_MBCSV_ARG)); mbcsv_arg.i_op = NCS_MBCSV_OP_FINALIZE; mbcsv_arg.i_mbcsv_hdl = cb->avnd_mbcsv_hdl; if (NCSCC_RC_SUCCESS != ncs_mbcsv_svc(&mbcsv_arg)) { LOG_ER("MBCSV finalize failed"); return NCSCC_RC_FAILURE; } return NCSCC_RC_SUCCESS; }
/****************************************************************************\ * Function: avsv_mbcsv_initialize * * Purpose: Initialize AVSV with MBCSV * * Input: cb - AVD control block pointer. * * Returns: NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE. * * NOTES: * * \**************************************************************************/ static uns32 avsv_mbcsv_initialize(AVD_CL_CB *cb) { NCS_MBCSV_ARG mbcsv_arg = {0}; mbcsv_arg.i_op = NCS_MBCSV_OP_INITIALIZE; mbcsv_arg.info.initialize.i_service = NCS_SERVICE_ID_AVD; mbcsv_arg.info.initialize.i_mbcsv_cb = avsv_mbcsv_cb; mbcsv_arg.info.initialize.i_version = AVD_MBCSV_SUB_PART_VERSION_3; if (NCSCC_RC_SUCCESS != ncs_mbcsv_svc(&mbcsv_arg)) { LOG_ER("%s: ncs_mbcsv_svc NCS_MBCSV_OP_INITIALIZE failed", __FUNCTION__); return NCSCC_RC_FAILURE; } cb->mbcsv_hdl = mbcsv_arg.info.initialize.o_mbcsv_hdl; return NCSCC_RC_SUCCESS; }
/****************************************************************************\ * Function: avnd_set_mbcsv_ckpt_role * * Purpose: Set MBCSV checkpoint role. * * Input: cb - AVND control block pointer. * role - Role to be set. * * Returns: NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE. * * NOTES: * * \**************************************************************************/ uns32 avnd_set_mbcsv_ckpt_role(AVND_CB *cb, uns32 role) { NCS_MBCSV_ARG mbcsv_arg; uns32 rc = NCSCC_RC_SUCCESS; memset(&mbcsv_arg, '\0', sizeof(NCS_MBCSV_ARG)); mbcsv_arg.i_op = NCS_MBCSV_OP_CHG_ROLE; mbcsv_arg.i_mbcsv_hdl = cb->avnd_mbcsv_hdl; mbcsv_arg.info.chg_role.i_ckpt_hdl = cb->avnd_mbcsv_ckpt_hdl; mbcsv_arg.info.chg_role.i_ha_state = role; if (NCSCC_RC_SUCCESS != (rc = ncs_mbcsv_svc(&mbcsv_arg))) { LOG_ER("set_ckpt_role failed"); return rc; } return NCSCC_RC_SUCCESS; }
/****************************************************************************\ * Function: avnd_mbcsv_close_ckpt * * Purpose: Close checkpoint. * * Input: cb - AVND control block pointer. * * Returns: NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE. * * NOTES: * * \**************************************************************************/ static uns32 avnd_mbcsv_close_ckpt(AVND_CB *cb) { NCS_MBCSV_ARG mbcsv_arg; /* LOG HERE */ memset(&mbcsv_arg, '\0', sizeof(NCS_MBCSV_ARG)); mbcsv_arg.i_op = NCS_MBCSV_OP_CLOSE; mbcsv_arg.i_mbcsv_hdl = cb->avnd_mbcsv_hdl; mbcsv_arg.info.close.i_ckpt_hdl = cb->avnd_mbcsv_ckpt_hdl; if (NCSCC_RC_SUCCESS != ncs_mbcsv_svc(&mbcsv_arg)) { LOG_ER("MBCSv checkpoint close failed"); return NCSCC_RC_FAILURE; } return NCSCC_RC_SUCCESS; }
/****************************************************************************\ * Function: avsv_set_ckpt_role * * Purpose: Set checkpoint role. * * Input: cb - AVD control block pointer. * role - Role to be set. * * Returns: NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE. * * NOTES: * * \**************************************************************************/ uns32 avsv_set_ckpt_role(AVD_CL_CB *cb, uns32 role) { NCS_MBCSV_ARG mbcsv_arg; uns32 rc = NCSCC_RC_SUCCESS; memset(&mbcsv_arg, '\0', sizeof(NCS_MBCSV_ARG)); mbcsv_arg.i_op = NCS_MBCSV_OP_CHG_ROLE; mbcsv_arg.i_mbcsv_hdl = cb->mbcsv_hdl; mbcsv_arg.info.chg_role.i_ckpt_hdl = cb->ckpt_hdl; mbcsv_arg.info.chg_role.i_ha_state = role; if (NCSCC_RC_SUCCESS != ncs_mbcsv_svc(&mbcsv_arg)) { LOG_ER("ncs_mbcsv_svc NCS_MBCSV_OP_CHG_ROLE %u failed", role); return NCSCC_RC_FAILURE; } return rc; }
/****************************************************************************************************************** * Name :glsv_gld_mbcsv_chgrole * * Description : To assign role for a component * Arguments : GLSV_GLD_CB - cb pointer * * Return Values : Success / Error * * Notes : This API is use for setting the role. Role Standby - initiate Cold Sync Request if it finds Active Role Active - send ckpt data to multiple standby peers *********************************************************************************************************************/ uint32_t glsv_gld_mbcsv_chgrole(GLSV_GLD_CB *gld_cb) { NCS_MBCSV_ARG arg; uint32_t rc = NCSCC_RC_SUCCESS; TRACE_ENTER(); memset(&arg, '\0', sizeof(NCS_MBCSV_ARG)); arg.i_op = NCS_MBCSV_OP_CHG_ROLE; arg.i_mbcsv_hdl = gld_cb->mbcsv_handle; arg.info.chg_role.i_ckpt_hdl = gld_cb->o_ckpt_hdl; arg.info.chg_role.i_ha_state = gld_cb->ha_state; /* ha_state is assigned at the time of amf_init where csi_set_callback will assign the state */ LOG_IN("Setting the state HaState as :%d", gld_cb->ha_state); if (ncs_mbcsv_svc(&arg) != SA_AIS_OK) { LOG_ER("GLD mbcsv chgrole failed"); rc = NCSCC_RC_FAILURE; } TRACE_LEAVE(); return rc; }
/****************************************************************************\ * Function: avsv_send_data_req * * Purpose: Encode data request to be sent. * * Input: cb - AVD CB pointer. * * Returns: NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE. * * NOTES: * * \**************************************************************************/ uns32 avsv_send_data_req(AVD_CL_CB *cb) { NCS_MBCSV_ARG mbcsv_arg = {0}; NCS_UBAID *uba = NULL; mbcsv_arg.i_op = NCS_MBCSV_OP_SEND_DATA_REQ; mbcsv_arg.i_mbcsv_hdl = cb->mbcsv_hdl; uba = &mbcsv_arg.info.send_data_req.i_uba; memset(uba, '\0', sizeof(NCS_UBAID)); mbcsv_arg.info.send_data_req.i_ckpt_hdl = cb->ckpt_hdl; if (NCSCC_RC_SUCCESS != ncs_mbcsv_svc(&mbcsv_arg)) { LOG_ER("%s: ncs_mbcsv_svc NCS_MBCSV_OP_SEND_DATA_REQ failed", __FUNCTION__); return NCSCC_RC_FAILURE; } return NCSCC_RC_SUCCESS; }
/****************************************************************************\ * Function: avnd_mbcsv_obj_set * * Purpose: Set MBCSv objects * * Input: cb - AVND control block pointer. * * Returns: NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE. * * NOTES: * * \**************************************************************************/ uns32 avnd_mbcsv_obj_set(AVND_CB *cb, uns32 obj, uns32 val) { NCS_MBCSV_ARG mbcsv_arg; /* LOG HERE */ memset(&mbcsv_arg, '\0', sizeof(NCS_MBCSV_ARG)); mbcsv_arg.i_op = NCS_MBCSV_OP_OBJ_SET; mbcsv_arg.i_mbcsv_hdl = cb->avnd_mbcsv_hdl; mbcsv_arg.info.obj_set.i_ckpt_hdl = cb->avnd_mbcsv_ckpt_hdl; mbcsv_arg.info.obj_set.i_obj = obj; mbcsv_arg.info.obj_set.i_val = val; if (NCSCC_RC_SUCCESS != ncs_mbcsv_svc(&mbcsv_arg)) { LOG_ER("MBCSV object set failed"); return NCSCC_RC_FAILURE; } return NCSCC_RC_SUCCESS; }
/******************************************************************************************************** * Name : glsv_gld_mbcsv_selobj_get * * Description : To get a handle from OS to process the pending callbacks * * Arguments : GLSV_GLD_CB -gld_cb * Return Values : Success / Error * * Notes : To receive a handle from OS and can be used in further processing of pending callbacks ********************************************************************************************************/ static uint32_t glsv_gld_mbcsv_selobj_get(GLSV_GLD_CB *gld_cb) { NCS_MBCSV_ARG arg; uint32_t rc = NCSCC_RC_SUCCESS; TRACE_ENTER(); memset(&arg, '\0', sizeof(NCS_MBCSV_ARG)); arg.i_op = NCS_MBCSV_OP_SEL_OBJ_GET; arg.i_mbcsv_hdl = gld_cb->mbcsv_handle; /*arg.info.sel_obj_get.o_select_obj = NULL; */ if (ncs_mbcsv_svc(&arg) != NCSCC_RC_SUCCESS) { LOG_ER("GLD mbcsv get sel obj failure"); rc = NCSCC_RC_FAILURE; goto end; } else { TRACE_1("GLD mbcsv get sel obj success"); gld_cb->mbcsv_sel_obj = arg.info.sel_obj_get.o_select_obj; rc = NCSCC_RC_SUCCESS; } end: TRACE_LEAVE(); return rc; }
/****************************************************************************\ * Function: avsv_send_ckpt_data * * Purpose: Send checkpoint data to standby using the supplied send type. * * Input: cb - AVD control block pointer. * action - Action to be perform (add, remove or update) * reo_hdl - Redudant object handle. * reo_type - Redudant object type. * send_type - Send type to be used. * * Returns: NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE. * * NOTES: * * \**************************************************************************/ uns32 avsv_send_ckpt_data(AVD_CL_CB *cb, uns32 action, MBCSV_REO_HDL reo_hdl, uns32 reo_type, uns32 send_type) { NCS_MBCSV_ARG mbcsv_arg; /* * Validate HA state. If my HA state is Standby then don't send * async updates. In all other states, MBCSv will take care of sending * async updates. */ if (SA_AMF_HA_STANDBY == cb->avail_state_avd) return NCSCC_RC_SUCCESS; /* * Get mbcsv_handle and checkpoint handle from CB. */ memset(&mbcsv_arg, '\0', sizeof(NCS_MBCSV_ARG)); mbcsv_arg.i_op = NCS_MBCSV_OP_SEND_CKPT; mbcsv_arg.i_mbcsv_hdl = cb->mbcsv_hdl; mbcsv_arg.info.send_ckpt.i_action = action; mbcsv_arg.info.send_ckpt.i_ckpt_hdl = cb->ckpt_hdl; mbcsv_arg.info.send_ckpt.i_reo_hdl = reo_hdl; mbcsv_arg.info.send_ckpt.i_reo_type = reo_type; mbcsv_arg.info.send_ckpt.i_send_type = send_type; /* * Before sendig this message, update async update count. */ switch (reo_type) { case AVSV_CKPT_AVD_CB_CONFIG: cb->async_updt_cnt.cb_updt++; break; case AVSV_CKPT_AVD_NODE_CONFIG: case AVSV_CKPT_AVND_NODE_UP_INFO: case AVSV_CKPT_AVND_ADMIN_STATE: case AVSV_CKPT_AVND_OPER_STATE: case AVSV_CKPT_AVND_NODE_STATE: case AVSV_CKPT_AVND_RCV_MSG_ID: case AVSV_CKPT_AVND_SND_MSG_ID: cb->async_updt_cnt.node_updt++; break; case AVSV_CKPT_AVD_APP_CONFIG: cb->async_updt_cnt.app_updt++; break; case AVSV_CKPT_AVD_SG_CONFIG: case AVSV_CKPT_SG_ADMIN_STATE: case AVSV_CKPT_SG_ADJUST_STATE: case AVSV_CKPT_SG_SU_ASSIGNED_NUM: case AVSV_CKPT_SG_SU_SPARE_NUM: case AVSV_CKPT_SG_SU_UNINST_NUM: case AVSV_CKPT_SG_FSM_STATE: cb->async_updt_cnt.sg_updt++; break; case AVSV_CKPT_AVD_SU_CONFIG: case AVSV_CKPT_SU_SI_CURR_ACTIVE: case AVSV_CKPT_SU_SI_CURR_STBY: case AVSV_CKPT_SU_ADMIN_STATE: case AVSV_CKPT_SU_TERM_STATE: case AVSV_CKPT_SU_SWITCH: case AVSV_CKPT_SU_OPER_STATE: case AVSV_CKPT_SU_PRES_STATE: case AVSV_CKPT_SU_READINESS_STATE: case AVSV_CKPT_SU_ACT_STATE: case AVSV_CKPT_SU_PREINSTAN: cb->async_updt_cnt.su_updt++; break; case AVSV_CKPT_AVD_SI_CONFIG: case AVSV_CKPT_SI_SU_CURR_ACTIVE: case AVSV_CKPT_SI_SU_CURR_STBY: case AVSV_CKPT_SI_SWITCH: case AVSV_CKPT_SI_ADMIN_STATE: case AVSV_CKPT_SI_ALARM_SENT: case AVSV_CKPT_SI_ASSIGNMENT_STATE: cb->async_updt_cnt.si_updt++; break; case AVSV_CKPT_AVD_SG_OPER_SU: cb->async_updt_cnt.sg_su_oprlist_updt++; break; case AVSV_CKPT_AVD_SG_ADMIN_SI: cb->async_updt_cnt.sg_admin_si_updt++; break; case AVSV_CKPT_AVD_COMP_CONFIG: case AVSV_CKPT_COMP_CURR_PROXY_NAME: case AVSV_CKPT_COMP_CURR_NUM_CSI_ACTV: case AVSV_CKPT_COMP_CURR_NUM_CSI_STBY: case AVSV_CKPT_COMP_OPER_STATE: case AVSV_CKPT_COMP_READINESS_STATE: case AVSV_CKPT_COMP_PRES_STATE: case AVSV_CKPT_COMP_RESTART_COUNT: cb->async_updt_cnt.comp_updt++; break; case AVSV_CKPT_AVD_SI_ASS: cb->async_updt_cnt.siass_updt++; break; case AVSV_CKPT_AVD_SI_TRANS: cb->async_updt_cnt.si_trans_updt++; break; case AVSV_SYNC_COMMIT: break; case AVSV_CKPT_AVD_COMP_CS_TYPE_CONFIG: cb->async_updt_cnt.compcstype_updt++; break; default: return NCSCC_RC_SUCCESS; } /* * Now send this update. */ if (NCSCC_RC_SUCCESS != ncs_mbcsv_svc(&mbcsv_arg)) { LOG_ER("%s: ncs_mbcsv_svc NCS_MBCSV_OP_SEND_CKPT failed", __FUNCTION__); return NCSCC_RC_FAILURE; } return NCSCC_RC_SUCCESS; }
/**************************************************************************** * Name : gld_main_process * * Description : This is the function which is given as a input to the * GLD task. * This function will be select of both the FD's (AMF FD and * Mail Box FD), depending on which FD has been selected, it * will call the corresponding routines. * * Arguments : mbx - This is the mail box pointer on which GLD is * going to block. * * Return Values : None. * * Notes : None. *****************************************************************************/ static void gld_main_process(SYSF_MBX *mbx) { NCS_SEL_OBJ mbx_fd; SaAisErrorT error = SA_AIS_OK; GLSV_GLD_CB *gld_cb = NULL; NCS_MBCSV_ARG mbcsv_arg; SaSelectionObjectT amf_sel_obj; if ((gld_cb = (GLSV_GLD_CB *)ncshm_take_hdl(NCS_SERVICE_ID_GLD, gl_gld_hdl)) == NULL) { m_LOG_GLD_HEADLINE(GLD_TAKE_HANDLE_FAILED, NCSFL_SEV_ERROR, __FILE__, __LINE__, 0); return; } mbx_fd = ncs_ipc_get_sel_obj(&gld_cb->mbx); error = saAmfSelectionObjectGet(gld_cb->amf_hdl, &amf_sel_obj); if (error != SA_AIS_OK) { m_LOG_GLD_SVC_PRVDR(GLD_AMF_SEL_OBJ_GET_ERROR, NCSFL_SEV_ERROR, __FILE__, __LINE__); return; } /* Set up all file descriptors to listen to */ fds[FD_AMF].fd = amf_sel_obj; fds[FD_AMF].events = POLLIN; fds[FD_MBCSV].fd = gld_cb->mbcsv_sel_obj; fds[FD_MBCSV].events = POLLIN; fds[FD_MBX].fd = mbx_fd.rmv_obj; fds[FD_MBX].events = POLLIN; fds[FD_IMM].fd = gld_cb->imm_sel_obj; fds[FD_IMM].events = POLLIN; while (1) { if (gld_cb->immOiHandle != 0) { fds[FD_IMM].fd = gld_cb->imm_sel_obj; fds[FD_IMM].events = POLLIN; nfds = FD_IMM + 1; } else { nfds = FD_IMM; } int ret = poll(fds, nfds, -1); if (ret == -1) { if (errno == EINTR) continue; gld_log(NCSFL_SEV_ERROR, "poll failed - %s", strerror(errno)); break; } if (fds[FD_AMF].revents & POLLIN) { if (gld_cb->amf_hdl != 0) { /* dispatch all the AMF pending function */ error = saAmfDispatch(gld_cb->amf_hdl, SA_DISPATCH_ALL); if (error != SA_AIS_OK) { m_LOG_GLD_SVC_PRVDR(GLD_AMF_DISPATCH_ERROR, NCSFL_SEV_ERROR, __FILE__, __LINE__); } } else gld_log(NCSFL_SEV_ERROR, "gld_cb->amf_hdl == 0"); } if (fds[FD_MBCSV].revents & POLLIN) { /* dispatch all the MBCSV pending callbacks */ mbcsv_arg.i_op = NCS_MBCSV_OP_DISPATCH; mbcsv_arg.i_mbcsv_hdl = gld_cb->mbcsv_handle; mbcsv_arg.info.dispatch.i_disp_flags = SA_DISPATCH_ALL; if (ncs_mbcsv_svc(&mbcsv_arg) != SA_AIS_OK) { m_LOG_GLD_HEADLINE(GLD_MBCSV_DISPATCH_FAILURE, NCSFL_SEV_ERROR, __FILE__, __LINE__, 0); } } if (fds[FD_MBX].revents & POLLIN) gld_process_mbx(mbx); /* process the IMM messages */ if (gld_cb->immOiHandle && fds[FD_IMM].revents & POLLIN) { /* dispatch all the IMM pending function */ error = saImmOiDispatch(gld_cb->immOiHandle, SA_DISPATCH_ONE); /* ** BAD_HANDLE is interpreted as an IMM service restart. Try ** reinitialize the IMM OI API in a background thread and let ** this thread do business as usual especially handling write ** requests. ** ** All other errors are treated as non-recoverable (fatal) and will ** cause an exit of the process. */ if (error == SA_AIS_ERR_BAD_HANDLE) { gld_log(NCSFL_SEV_ERROR, "saImmOiDispatch returned BAD_HANDLE %u", error); /* ** Invalidate the IMM OI handle, this info is used in other ** locations. E.g. giving TRY_AGAIN responses to a create and ** close resource requests. That is needed since the IMM OI ** is used in context of these functions. */ gld_cb->immOiHandle = 0; gld_imm_reinit_bg(gld_cb); } else if (error != SA_AIS_OK) { gld_log(NCSFL_SEV_ERROR, "saImmOiDispatch FAILED: %u", error); break; } } } return; }
/****************************************************************************\ * Function: avnd_send_ckpt_data * * Purpose: Send checkpoint data to standby using the supplied send type. * * Input: cb - AVND control block pointer. * action - Action to be perform (add, remove or update) * reo_hdl - Redudant object handle. * reo_type - Redudant object type. * send_type - Send type to be used. * * Returns: NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE. * * NOTES: * * \**************************************************************************/ uns32 avnd_send_ckpt_data(AVND_CB *cb, uns32 action, MBCSV_REO_HDL reo_hdl, uns32 reo_type, uns32 send_type) { NCS_MBCSV_ARG mbcsv_arg; /* * Validate HA state. If my HA state is Standby then don't send * async updates. In all other states, MBCSv will take care of sending * async updates. */ if (SA_AMF_HA_STANDBY == cb->avail_state_avnd) return NCSCC_RC_SUCCESS; /* * Get mbcsv_handle and checkpoint handle from CB. */ memset(&mbcsv_arg, '\0', sizeof(NCS_MBCSV_ARG)); mbcsv_arg.i_op = NCS_MBCSV_OP_SEND_CKPT; mbcsv_arg.i_mbcsv_hdl = cb->avnd_mbcsv_hdl; mbcsv_arg.info.send_ckpt.i_action = action; mbcsv_arg.info.send_ckpt.i_ckpt_hdl = cb->avnd_mbcsv_ckpt_hdl; mbcsv_arg.info.send_ckpt.i_reo_hdl = reo_hdl; mbcsv_arg.info.send_ckpt.i_reo_type = reo_type; mbcsv_arg.info.send_ckpt.i_send_type = send_type; /* * Before sendig this message, update async update count. */ switch (reo_type) { case AVND_CKPT_HLT_CONFIG: case AVND_CKPT_HC_PERIOD: case AVND_CKPT_HC_MAX_DUR: cb->avnd_async_updt_cnt.hlth_config_updt++; break; case AVND_CKPT_SU_CONFIG: case AVND_CKPT_SU_FLAG_CHANGE: case AVND_CKPT_SU_ERR_ESC_LEVEL: case AVND_CKPT_SU_COMP_RESTART_PROB: case AVND_CKPT_SU_COMP_RESTART_MAX: case AVND_CKPT_SU_RESTART_PROB: case AVND_CKPT_SU_RESTART_MAX: case AVND_CKPT_SU_COMP_RESTART_CNT: case AVND_CKPT_SU_RESTART_CNT: case AVND_CKPT_SU_ERR_ESC_TMR: case AVND_CKPT_SU_OPER_STATE: case AVND_CKPT_SU_PRES_STATE: cb->avnd_async_updt_cnt.su_updt++; break; case AVND_CKPT_COMP_CONFIG: case AVND_CKPT_COMP_FLAG_CHANGE: case AVND_CKPT_COMP_REG_HDL: case AVND_CKPT_COMP_REG_DEST: case AVND_CKPT_COMP_OPER_STATE: case AVND_CKPT_COMP_PRES_STATE: case AVND_CKPT_COMP_TERM_CBK_TIMEOUT: case AVND_CKPT_COMP_CSI_SET_CBK_TIMEOUT: case AVND_CKPT_COMP_QUIES_CMPLT_CBK_TIMEOUT: case AVND_CKPT_COMP_CSI_RMV_CBK_TIMEOUT: case AVND_CKPT_COMP_PXIED_INST_CBK_TIMEOUT: case AVND_CKPT_COMP_PXIED_CLEAN_CBK_TIMEOUT: case AVND_CKPT_COMP_ERR_INFO: case AVND_CKPT_COMP_DEFAULT_RECVR: case AVND_CKPT_COMP_PEND_EVT: case AVND_CKPT_COMP_ORPH_TMR: case AVND_CKPT_COMP_NODE_ID: case AVND_CKPT_COMP_TYPE: case AVND_CKPT_COMP_MDS_CTXT: case AVND_CKPT_COMP_REG_RESP_PENDING: case AVND_CKPT_COMP_INST_CMD: case AVND_CKPT_COMP_TERM_CMD: case AVND_CKPT_COMP_INST_TIMEOUT: case AVND_CKPT_COMP_TERM_TIMEOUT: case AVND_CKPT_COMP_INST_RETRY_MAX: case AVND_CKPT_COMP_INST_RETRY_CNT: case AVND_CKPT_COMP_EXEC_CMD: case AVND_CKPT_COMP_CMD_EXEC_CTXT: case AVND_CKPT_COMP_INST_CMD_TS: case AVND_CKPT_COMP_CLC_REG_TMR: case AVND_CKPT_COMP_INST_CODE_RCVD: case AVND_CKPT_COMP_PROXY_PROXIED_ADD: case AVND_CKPT_COMP_PROXY_PROXIED_DEL: cb->avnd_async_updt_cnt.comp_updt++; break; case AVND_SYNC_COMMIT: break; case AVND_CKPT_SU_SI_REC: case AVND_CKPT_SU_SI_REC_CURR_STATE: case AVND_CKPT_SU_SI_REC_PRV_STATE: case AVND_CKPT_SU_SI_REC_CURR_ASSIGN_STATE: case AVND_CKPT_SU_SI_REC_PRV_ASSIGN_STATE: cb->avnd_async_updt_cnt.su_si_updt++; break; case AVND_CKPT_SIQ_REC: cb->avnd_async_updt_cnt.siq_updt++; break; case AVND_CKPT_CSI_REC: case AVND_CKPT_COMP_CSI_ACT_COMP_NAME: case AVND_CKPT_COMP_CSI_TRANS_DESC: case AVND_CKPT_COMP_CSI_STANDBY_RANK: case AVND_CKPT_COMP_CSI_CURR_ASSIGN_STATE: case AVND_CKPT_COMP_CSI_PRV_ASSIGN_STATE: cb->avnd_async_updt_cnt.csi_updt++; break; case AVND_CKPT_COMP_HLT_REC: case AVND_CKPT_COMP_HC_REC_STATUS: case AVND_CKPT_COMP_HC_REC_TMR: cb->avnd_async_updt_cnt.comp_hlth_rec_updt++; break; case AVND_CKPT_COMP_CBK_REC: case AVND_CKPT_COMP_CBK_REC_AMF_HDL: case AVND_CKPT_COMP_CBK_REC_MDS_DEST: case AVND_CKPT_COMP_CBK_REC_TMR: case AVND_CKPT_COMP_CBK_REC_TIMEOUT: cb->avnd_async_updt_cnt.comp_cbk_rec_updt++; break; default: return NCSCC_RC_SUCCESS; } /* * Now send this update. */ if (NCSCC_RC_SUCCESS != ncs_mbcsv_svc(&mbcsv_arg)) { LOG_ER("MBCSv send data failed"); return NCSCC_RC_FAILURE; } return NCSCC_RC_SUCCESS; }