/**************************************************************************** * Name : mds_vdest_create * * Description : This function created the VDEST for SMFD * * Arguments : * * Return Values : NCSCC_RC_SUCCESS/Error Code. * * Notes : None. *****************************************************************************/ static uint32_t mds_vdest_create(smfd_cb_t * cb) { NCSVDA_INFO arg; uint32_t rc = NCSCC_RC_SUCCESS; memset(&arg, 0, sizeof(arg)); cb->mds_dest = SMFD_VDEST_ID; arg.req = NCSVDA_VDEST_CREATE; arg.info.vdest_create.i_persistent = false; arg.info.vdest_create.i_policy = NCS_VDEST_TYPE_DEFAULT; arg.info.vdest_create.i_create_type = NCSVDA_VDEST_CREATE_SPECIFIC; arg.info.vdest_create.info.specified.i_vdest = cb->mds_dest; /* Create VDEST */ rc = ncsvda_api(&arg); if (NCSCC_RC_SUCCESS != rc) { LOG_ER("mds_vdest_create: create vdest for SMFD FAILED\n"); return rc; } cb->mds_handle = arg.info.vdest_create.o_mds_pwe1_hdl; return rc; }
/****************************************************************************\ PROCEDURE NAME : plms_mds_vdest_create DESCRIPTION : This function Creates the Virtual destination for PLMS ARGUMENTS : NULL RETURNS : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE. \****************************************************************************/ SaUint32T plms_mds_vdest_create() { PLMS_CB *cb = plms_cb; NCSVDA_INFO arg; uns32 rc = NCSCC_RC_SUCCESS; TRACE_ENTER(); memset(&arg, 0, sizeof(arg)); cb->mdest_id = PLMS_VDEST_ID; arg.req = NCSVDA_VDEST_CREATE; arg.info.vdest_create.i_persistent = FALSE; arg.info.vdest_create.i_policy = NCS_VDEST_TYPE_DEFAULT; arg.info.vdest_create.i_create_type = NCSVDA_VDEST_CREATE_SPECIFIC; arg.info.vdest_create.info.specified.i_vdest = cb->mdest_id; /* Create VDEST */ rc = ncsvda_api(&arg); if (NCSCC_RC_SUCCESS != rc) { LOG_ER("PLMS NCSVDA_VDEST_CREATE failed"); return rc; } cb->mds_hdl = arg.info.vdest_create.o_mds_pwe1_hdl; TRACE_LEAVE(); return rc; }
/**************************************************************************** Name : avnd_mds_vdest_reg Description : This routine registers the AVND Service with MDS for VDEST. It does the following: a) Gets the MDS handle & AvND MDS address b) installs AvND service with MDS c) Subscribes to MDS events Arguments : cb - ptr to the AVND control block Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE Notes : MDS messages are not used, we are only interested in MBCSV messages. ******************************************************************************/ uns32 avnd_mds_vdest_reg(AVND_CB *cb) { NCSVDA_INFO vda_info; NCSMDS_INFO svc_to_mds_info; memset(&vda_info, '\0', sizeof(NCSVDA_INFO)); cb->avnd_mbcsv_vaddr = AVND_VDEST_ID; vda_info.req = NCSVDA_VDEST_CREATE; vda_info.info.vdest_create.i_persistent = FALSE; vda_info.info.vdest_create.i_policy = NCS_VDEST_TYPE_DEFAULT; vda_info.info.vdest_create.i_create_type = NCSVDA_VDEST_CREATE_SPECIFIC; vda_info.info.vdest_create.info.specified.i_vdest = cb->avnd_mbcsv_vaddr; /* create Vdest address */ if (ncsvda_api(&vda_info) != NCSCC_RC_SUCCESS) { LOG_CR("Vdest Creation failed"); return NCSCC_RC_FAILURE; } /* store the info returned by MDS */ cb->avnd_mbcsv_vaddr_pwe_hdl = vda_info.info.vdest_create.o_mds_pwe1_hdl; cb->avnd_mbcsv_vaddr_hdl = vda_info.info.vdest_create.o_mds_vdest_hdl; memset(&svc_to_mds_info, '\0', sizeof(NCSMDS_INFO)); /* Install on mds VDEST */ svc_to_mds_info.i_mds_hdl = cb->avnd_mbcsv_vaddr_pwe_hdl; svc_to_mds_info.i_svc_id = NCSMDS_SVC_ID_AVND_CNTLR; svc_to_mds_info.i_op = MDS_INSTALL; svc_to_mds_info.info.svc_install.i_install_scope = NCSMDS_SCOPE_NONE; svc_to_mds_info.info.svc_install.i_svc_cb = avnd_mds_cbk; svc_to_mds_info.info.svc_install.i_mds_q_ownership = FALSE; svc_to_mds_info.info.svc_install.i_mds_svc_pvt_ver = AVND_MDS_SUB_PART_VERSION; if (ncsmds_api(&svc_to_mds_info) != NCSCC_RC_SUCCESS) { memset(&vda_info, '\0', sizeof(NCSVDA_INFO)); vda_info.req = NCSVDA_VDEST_DESTROY; vda_info.info.vdest_destroy.i_vdest = cb->avnd_mbcsv_vaddr; ncsvda_api(&vda_info); LOG_CR("Mds Installation failed"); return NCSCC_RC_FAILURE; } return NCSCC_RC_SUCCESS; }
/**************************************************************************** * Name : smfd_mds_change_role * * Description : This function informs mds of our vdest role change * * Arguments : cb : SMFD control Block pointer. * * Return Values : NCSCC_RC_SUCCESS/Error Code. * * Notes : None. *****************************************************************************/ uint32_t smfd_mds_change_role(smfd_cb_t * cb) { NCSVDA_INFO arg; memset(&arg, 0, sizeof(NCSVDA_INFO)); arg.req = NCSVDA_VDEST_CHG_ROLE; arg.info.vdest_chg_role.i_vdest = cb->mds_dest; arg.info.vdest_chg_role.i_new_role = cb->mds_role; return ncsvda_api(&arg); }
/**************************************************************************** * Name : plms_mds_change_role * * Description : This function informs mds of our vdest role change * * Arguments : cb : PLMS control Block pointer. * * Return Values : NCSCC_RC_SUCCESS/Error Code. *****************************************************************************/ SaUint32T plms_mds_change_role() { NCSVDA_INFO arg; PLMS_CB *cb = plms_cb; TRACE_ENTER(); memset(&arg, 0, sizeof(NCSVDA_INFO)); arg.req = NCSVDA_VDEST_CHG_ROLE; arg.info.vdest_chg_role.i_vdest = cb->mdest_id; arg.info.vdest_chg_role.i_new_role = cb->mds_role; TRACE_LEAVE(); return ncsvda_api(&arg); }
/**************************************************************************** Name : dts_mds_change_role Description : This routine use for setting and changing role. Arguments : role - Role to be set. Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE Notes : None. ******************************************************************************/ uns32 dts_mds_change_role(DTS_CB *cb, SaAmfHAStateT role) { NCSVDA_INFO vda_info; memset(&vda_info, 0, sizeof(vda_info)); vda_info.req = NCSVDA_VDEST_CHG_ROLE; vda_info.info.vdest_chg_role.i_vdest = cb->vaddr; /*vda_info.info.vdest_chg_role.i_anc = V_DEST_QA_1; */ vda_info.info.vdest_chg_role.i_new_role = role; if (ncsvda_api(&vda_info) != NCSCC_RC_SUCCESS) { return m_DTS_DBG_SINK(NCSCC_RC_FAILURE, "dts_mds_change_role: DTS change role failed."); } return NCSCC_RC_SUCCESS; }
/**************************************************************************** * Name : mds_vdest_destroy * * Description : This function Destroys the Virtual destination of LGS * * Arguments : cb : SMFD control Block pointer. * * Return Values : NCSCC_RC_SUCCESS/Error Code. * * Notes : None. *****************************************************************************/ static uint32_t mds_vdest_destroy(smfd_cb_t * cb) { NCSVDA_INFO vda_info; uint32_t rc; memset(&vda_info, 0, sizeof(NCSVDA_INFO)); vda_info.req = NCSVDA_VDEST_DESTROY; vda_info.info.vdest_destroy.i_vdest = cb->mds_dest; if (NCSCC_RC_SUCCESS != (rc = ncsvda_api(&vda_info))) { LOG_ER("NCSVDA_VDEST_DESTROY failed"); return rc; } return rc; }
/**************************************************************************** Name : dts_mds_unreg Description : This routine unregisters the DTS Service from MDS on the DTSs Vaddress Arguments : cb - ptr to the DTScontrol block Return Values : NONE Notes : None. ******************************************************************************/ void dts_mds_unreg(DTS_CB *cb, NCS_BOOL un_install) { NCSVDA_INFO vda_info; NCSMDS_INFO svc_to_mds_info; /* uninstall MDS */ if (un_install) { svc_to_mds_info.i_mds_hdl = cb->mds_hdl; svc_to_mds_info.i_svc_id = NCSMDS_SVC_ID_DTS; svc_to_mds_info.i_op = MDS_UNINSTALL; ncsmds_api(&svc_to_mds_info); } /* destroy vaddress */ vda_info.req = NCSVDA_VDEST_DESTROY; vda_info.info.vdest_destroy.i_vdest = cb->vaddr; ncsvda_api(&vda_info); return; }
/**************************************************************************** Name : avnd_mds_set_vdest_role Description : This routine is used for setting the VDEST role. Arguments : cb - ptr to the AVND control block role - Set the role. Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE Notes : None. ******************************************************************************/ uns32 avnd_mds_set_vdest_role(AVND_CB *cb, SaAmfHAStateT role) { NCSVDA_INFO vda_info; if (SA_AMF_HA_QUIESCED == role) { cb->is_quisced_set = TRUE; } memset(&vda_info, '\0', sizeof(NCSVDA_INFO)); /* set the role of the vdest */ vda_info.req = NCSVDA_VDEST_CHG_ROLE; vda_info.info.vdest_chg_role.i_new_role = role; vda_info.info.vdest_chg_role.i_vdest = cb->avnd_mbcsv_vaddr; if (ncsvda_api(&vda_info) != NCSCC_RC_SUCCESS) { return NCSCC_RC_FAILURE; } return NCSCC_RC_SUCCESS; }
/**************************************************************************** Name : dts_mds_reg Description : This routine registers the DTS Service with MDS with the DTSs Vaddress. Arguments : cb - ptr to the DTS control block Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE Notes : None. ******************************************************************************/ uns32 dts_mds_reg(DTS_CB *cb) { NCSVDA_INFO vda_info; NCSMDS_INFO svc_to_mds_info; MDS_SVC_ID svc_ids_array[2]; /* prepare the cb with the vaddress */ memset(&cb->vaddr, 0, sizeof(MDS_DEST)); cb->vaddr = DTS_VDEST_ID; vda_info.req = NCSVDA_VDEST_CREATE; vda_info.info.vdest_create.i_persistent = FALSE; vda_info.info.vdest_create.i_policy = NCS_VDEST_TYPE_DEFAULT; vda_info.info.vdest_create.i_create_type = NCSVDA_VDEST_CREATE_SPECIFIC; vda_info.info.vdest_create.info.specified.i_vdest = cb->vaddr; /* create Vdest address */ if (ncsvda_api(&vda_info) != NCSCC_RC_SUCCESS) return m_DTS_DBG_SINK(NCSCC_RC_FAILURE, "dts_mds_reg: Vdest creation failed"); /* store the info returned by MDS */ cb->mds_hdl = vda_info.info.vdest_create.o_mds_pwe1_hdl; /* Smik - New additions */ cb->vaddr_pwe_hdl = vda_info.info.vdest_create.o_mds_pwe1_hdl; cb->vaddr_hdl = vda_info.info.vdest_create.o_mds_vdest_hdl; #if (DTS_SIM_TEST_ENV == 1) if (TRUE == cb->is_test) { /* set the role of the vdest */ if (dts_mds_change_role(cb, cb->ha_state) != NCSCC_RC_SUCCESS) { dts_mds_unreg(cb, FALSE); return m_DTS_DBG_SINK(NCSCC_RC_FAILURE, "dts_mds_reg: DTS Role change failed"); } } /* is_test is TRUE */ #endif /* Install mds */ memset(&svc_to_mds_info, 0, sizeof(NCSMDS_INFO)); svc_to_mds_info.i_mds_hdl = cb->mds_hdl; svc_to_mds_info.i_svc_id = NCSMDS_SVC_ID_DTS; svc_to_mds_info.i_op = MDS_INSTALL; svc_to_mds_info.info.svc_install.i_yr_svc_hdl = (MDS_CLIENT_HDL)(long)cb; svc_to_mds_info.info.svc_install.i_install_scope = NCSMDS_SCOPE_NONE; svc_to_mds_info.info.svc_install.i_svc_cb = dts_mds_callback; svc_to_mds_info.info.svc_install.i_mds_q_ownership = FALSE; /* versioning changes */ svc_to_mds_info.info.svc_install.i_mds_svc_pvt_ver = cb->dts_mds_version; cb->created = TRUE; if (ncsmds_api(&svc_to_mds_info) != NCSCC_RC_SUCCESS) { cb->created = FALSE; dts_mds_unreg(cb, FALSE); return m_DTS_DBG_SINK(NCSCC_RC_FAILURE, "dts_mds_reg: MDS install failed"); } /* DTS is subscribing for DTA MDS service */ memset(&svc_to_mds_info, 0, sizeof(NCSMDS_INFO)); svc_to_mds_info.i_mds_hdl = cb->mds_hdl; svc_to_mds_info.i_svc_id = NCSMDS_SVC_ID_DTS; svc_to_mds_info.i_op = MDS_SUBSCRIBE; svc_to_mds_info.info.svc_subscribe.i_scope = NCSMDS_SCOPE_NONE; svc_to_mds_info.info.svc_subscribe.i_num_svcs = DTS_NUM_SVCS_TO_SUBSCRIBE; svc_ids_array[0] = NCSMDS_SVC_ID_DTA; svc_to_mds_info.info.svc_subscribe.i_svc_ids = svc_ids_array; if (ncsmds_api(&svc_to_mds_info) != NCSCC_RC_SUCCESS) { cb->created = FALSE; dts_mds_unreg(cb, TRUE); return m_DTS_DBG_SINK(NCSCC_RC_FAILURE, "dts_mds_reg: DTA Event subscription failed!!"); } /* DTS is subscribing for IMMMD MDS service */ memset(&svc_to_mds_info, 0, sizeof(NCSMDS_INFO)); svc_to_mds_info.i_mds_hdl = cb->mds_hdl; svc_to_mds_info.i_svc_id = NCSMDS_SVC_ID_DTS; svc_to_mds_info.i_op = MDS_SUBSCRIBE; svc_to_mds_info.info.svc_subscribe.i_scope = NCSMDS_SCOPE_INTRANODE; svc_to_mds_info.info.svc_subscribe.i_num_svcs = DTS_NUM_SVCS_TO_SUBSCRIBE; svc_ids_array[0] = NCSMDS_SVC_ID_IMMND; svc_to_mds_info.info.svc_subscribe.i_svc_ids = svc_ids_array; if (ncsmds_api(&svc_to_mds_info) != NCSCC_RC_SUCCESS) { cb->created = FALSE; dts_mds_unreg(cb, TRUE); return m_DTS_DBG_SINK(NCSCC_RC_FAILURE, "dts_mds_reg: IMMND Event subscription failed!!"); } return NCSCC_RC_SUCCESS; }
void cpd_saf_csi_set_cb(SaInvocationT invocation, const SaNameT *compName, SaAmfHAStateT haState, SaAmfCSIDescriptorT csiDescriptor) { CPD_CB *cb = 0; SaAisErrorT saErr = SA_AIS_OK; V_DEST_RL mds_role; /* V_CARD_QA anchor; */ NCSVDA_INFO vda_info; uint32_t rc = NCSCC_RC_SUCCESS; CPD_CPND_INFO_NODE *node_info = NULL; MDS_DEST prev_dest; TRACE_ENTER(); cb = ncshm_take_hdl(NCS_SERVICE_ID_CPD, gl_cpd_cb_hdl); if (cb) { if ((cb->ha_state == SA_AMF_HA_STANDBY) && (haState == SA_AMF_HA_ACTIVE)) { if (cb->cold_or_warm_sync_on == true) { TRACE("STANDBY cpd_saf_csi_set_cb -cb->cold_or_warm_sync_on == true "); saErr = SA_AIS_ERR_TRY_AGAIN; saAmfResponse(cb->amf_hdl, invocation, saErr); ncshm_give_hdl(cb->cpd_hdl); TRACE_4("cpd vdest change role failed"); m_CPSV_DBG_SINK(NCSCC_RC_FAILURE, "cpd_role_change: Failed to send Error report to AMF for Active role assignment during Cold-Sync"); return; } } if ((cb->ha_state == SA_AMF_HA_ACTIVE) && (haState == SA_AMF_HA_QUIESCED)) { if (cb->cold_or_warm_sync_on == true) { TRACE("ACTIVE cpd_saf_csi_set_cb -cb->cold_or_warm_sync_on == true "); } } /* cb->ha_state = haState; */ /* saAmfResponse(cb->amf_hdl, invocation, saErr); */ if (SA_AMF_HA_ACTIVE == haState) { /** Change the MDS role **/ cb->ha_state = haState; mds_role = V_DEST_RL_ACTIVE; TRACE("ACTIVE STATE"); /* If this is the active server, become implementer again. */ /* If this is the active Director, become implementer */ saErr = immutil_saImmOiImplementerSet(cb->immOiHandle, implementer_name); if (saErr != SA_AIS_OK){ LOG_ER("cpd immOiImplmenterSet failed with err = %u",saErr); exit(EXIT_FAILURE); } /* anchor = cb->cpd_anc; */ } else if (SA_AMF_HA_QUIESCED == haState) { mds_role = V_DEST_RL_QUIESCED; cb->amf_invocation = invocation; cb->is_quiesced_set = true; memset(&vda_info, 0, sizeof(vda_info)); vda_info.req = NCSVDA_VDEST_CHG_ROLE; vda_info.info.vdest_chg_role.i_vdest = cb->cpd_dest_id; /* vda_info.info.vdest_chg_role.i_anc = anchor; */ vda_info.info.vdest_chg_role.i_new_role = mds_role; rc = ncsvda_api(&vda_info); if (NCSCC_RC_SUCCESS != rc) { m_LEAP_DBG_SINK_VOID; LOG_ER("cpd vdest change role failed"); ncshm_give_hdl(cb->cpd_hdl); TRACE_LEAVE(); return; } ncshm_give_hdl(cb->cpd_hdl); TRACE_2("cpd csi set cb success"); TRACE_LEAVE(); return; } else { /** Change the MDS role **/ cb->ha_state = haState; mds_role = V_DEST_RL_STANDBY; TRACE("STANDBY STATE"); /* anchor = cb->cpd_anc; */ } memset(&vda_info, 0, sizeof(vda_info)); vda_info.req = NCSVDA_VDEST_CHG_ROLE; vda_info.info.vdest_chg_role.i_vdest = cb->cpd_dest_id; /* vda_info.info.vdest_chg_role.i_anc = anchor; */ vda_info.info.vdest_chg_role.i_new_role = mds_role; rc = ncsvda_api(&vda_info); if (NCSCC_RC_SUCCESS != rc) { m_LEAP_DBG_SINK_VOID; LOG_ER("cpd vdest change role failed"); ncshm_give_hdl(cb->cpd_hdl); TRACE_LEAVE(); return; } if (cpd_mbcsv_chgrole(cb) != NCSCC_RC_SUCCESS) { TRACE_4("cpd mbcsv chgrole failed"); } /** Set the CB's anchor value */ /* cb->cpd_anc= anchor; */ saAmfResponse(cb->amf_hdl, invocation, saErr); ncshm_give_hdl(cb->cpd_hdl); if (SA_AMF_HA_ACTIVE == cb->ha_state) { cpd_cpnd_info_node_getnext(&cb->cpnd_tree, NULL, &node_info); while (node_info) { prev_dest = node_info->cpnd_dest; if (node_info->timer_state == 2) { TRACE ("THE TIMER STATE IS 2 MEANS TIMER EXPIRED BUT STILL DID NOT GET ACTIVE STATE"); cpd_process_cpnd_down(cb, &node_info->cpnd_dest); } cpd_cpnd_info_node_getnext(&cb->cpnd_tree, &prev_dest, &node_info); } TRACE_2("cpd csi set cb success I AM ACTIVE "); } if (SA_AMF_HA_STANDBY == cb->ha_state) TRACE_2("cpd csi set cb success I AM STANDBY"); } else { TRACE_4("cpd donot exist"); } TRACE_LEAVE(); return; } /* End of cpd_saf_csi_set_cb() */