Esempio n. 1
0
/****************************************************************************
  Name          :  ncs_ava_startup

  Description   :  This routine creates a AVSv agent infrastructure to interface
                   with AVSv service. Once the infrastructure is created from
                   then on use_count is incremented for every startup request.

  Arguments     :  - NIL-

  Return Values :  NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE

  Notes         :  None
******************************************************************************/
unsigned int ncs_ava_startup(void)
{
	NCS_LIB_REQ_INFO lib_create;
	TRACE_ENTER();

	m_AVA_AGENT_LOCK;

	if (ava_use_count > 0) {
		/* Already created, so just increment the use_count */
		ava_use_count++;
		m_AVA_AGENT_UNLOCK;
		TRACE_LEAVE2("AVA use count = %d",ava_use_count);
		return NCSCC_RC_SUCCESS;
	}

   /*** Init AVA ***/
	memset(&lib_create, 0, sizeof(lib_create));
	lib_create.i_op = NCS_LIB_REQ_CREATE;
	if (ava_lib_req(&lib_create) != NCSCC_RC_SUCCESS) {
		m_AVA_AGENT_UNLOCK;
		TRACE_LEAVE2("AVA lib create failed");
		return NCSCC_RC_FAILURE;
	} else {
		ava_use_count = 1;
	}

	m_AVA_AGENT_UNLOCK;

	TRACE_LEAVE2("AVA Use count = %u",ava_use_count);
	return NCSCC_RC_SUCCESS;
}
Esempio n. 2
0
/****************************************************************************
  Name          :  ncs_eda_startup

  Description   :  This routine creates a EDSv agent infrastructure to interface
                   with EDSv service. Once the infrastructure is created from
                   then on use_count is incremented for every startup request.

  Arguments     :  - NIL-

  Return Values :  NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE

  Notes         :  None
******************************************************************************/
unsigned int ncs_eda_startup(void)
{
    NCS_LIB_REQ_INFO lib_create;
    TRACE_ENTER();

    osaf_mutex_lock_ordie(&s_agent_startup_mutex);
    if (eda_use_count > 0) {
        /* Already created, so just increment the use_count */
        eda_use_count++;
        osaf_mutex_unlock_ordie(&s_agent_startup_mutex);
        TRACE_LEAVE2("Library use count: %u", eda_use_count);
        return NCSCC_RC_SUCCESS;
    }

    /*** Init EDA ***/
    memset(&lib_create, 0, sizeof(lib_create));
    lib_create.i_op = NCS_LIB_REQ_CREATE;
    if (ncs_eda_lib_req(&lib_create) != NCSCC_RC_SUCCESS) {
        osaf_mutex_unlock_ordie(&s_agent_startup_mutex);
        return NCSCC_RC_FAILURE;
    } else {
        eda_use_count = 1;
        TRACE("EDA agent library initialized");
    }

    osaf_mutex_unlock_ordie(&s_agent_startup_mutex);
    TRACE_LEAVE2("Library use count: %u", eda_use_count);
    return NCSCC_RC_SUCCESS;
}
Esempio n. 3
0
/****************************************************************************
  Name          : ava_hdl_rec_del
 
  Description   : This routine deletes the handle record.
 
  Arguments     : cb      - ptr tot he AvA control block
                  hdl_db  - ptr to the hdl db
                  hdl_rec - ptr to the hdl record
 
  Return Values : None
 
  Notes         : The selection object is destroyed after all the means to 
                  access the handle record (ie. hdl db tree or hdl mngr) is 
                  removed. This is to disallow the waiting thread to access 
                  the hdl rec while other thread executes saAmfFinalize on it.
******************************************************************************/
void ava_hdl_rec_del(AVA_CB *cb, AVA_HDL_DB *hdl_db, AVA_HDL_REC **_hdl_rec)
{
	AVA_HDL_REC *hdl_rec = *_hdl_rec;
	uint32_t hdl = hdl_rec->hdl;
	TRACE_ENTER();

	/* pop the hdl rec */
	ncs_patricia_tree_del(&hdl_db->hdl_db_anchor, &hdl_rec->hdl_node);

	/* detach the mail box */
	m_NCS_IPC_DETACH(&hdl_rec->callbk_mbx, ava_hdl_cbk_ipc_mbx_del, hdl_rec);

	/* delete the mailbox */
	m_NCS_IPC_RELEASE(&hdl_rec->callbk_mbx, NULL);

	/* clean the pend resp list */
	ava_hdl_pend_resp_list_del(cb, &hdl_rec->pend_resp);

	/* remove the association with hdl-mngr */
	ncshm_destroy_hdl(NCS_SERVICE_ID_AVA, hdl_rec->hdl);

	/* free the hdl rec */
	free(hdl_rec);
	*_hdl_rec = NULL;

	/* update the no of records */
	hdl_db->num--;

	TRACE_LEAVE2("Handle = %x, successfully deleted from Handle DB, num handles = %d",hdl, hdl_db->num);
	return;
}
Esempio n. 4
0
/****************************************************************************
  Name          : avnd_mbx_create
 
  Description   : This routine creates & attaches AvND mailbox.
 
  Arguments     : cb - ptr to AvND control block
 
  Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
 
  Notes         : None
******************************************************************************/
uns32 avnd_mbx_create(AVND_CB *cb)
{
	uns32 rc = NCSCC_RC_SUCCESS;
	TRACE_ENTER();

	/* create the mail box */
	rc = m_NCS_IPC_CREATE(&cb->mbx);
	if (NCSCC_RC_SUCCESS != rc) {
		LOG_CR("AvND Mailbox creation failed");
		goto err;
	}
	TRACE("AvND mailbox creation success");

	/* attach the mail box */
	rc = m_NCS_IPC_ATTACH(&cb->mbx);
	if (NCSCC_RC_SUCCESS != rc) {
		LOG_CR("AvND mailbox attach failed");
		goto err;
	}
	TRACE_LEAVE2("AvND mailbox attach success");

	return rc;

 err:
	/* destroy the mailbox */
	if (cb->mbx)
		avnd_mbx_destroy(cb);
	TRACE_LEAVE();
	return rc;
}
Esempio n. 5
0
/**
 * 
 * 
 * @return unsigned int
 */
unsigned int ntfa_startup(void)
{
	unsigned int rc = NCSCC_RC_SUCCESS;
	pthread_mutex_lock(&ntfa_lock);

	TRACE_ENTER2("ntfa_use_count: %u", ntfa_use_count);
	if (ntfa_use_count > 0) {
		/* Already created, just increment the use_count */
		ntfa_use_count++;
		goto done;
	} else {
		if ((rc = ncs_agents_startup()) != NCSCC_RC_SUCCESS) {
			TRACE("ncs_agents_startup FAILED");
			goto done;
		}

		if ((rc = ntfa_create()) != NCSCC_RC_SUCCESS) {
			ncs_agents_shutdown();
			goto done;
		} else
			ntfa_use_count = 1;
	}

 done:
	pthread_mutex_unlock(&ntfa_lock);
	TRACE_LEAVE2("rc: %u, ntfa_use_count: %u", rc, ntfa_use_count);
	return rc;
}
Esempio n. 6
0
/****************************************************************************\
 PROCEDURE NAME : mqd_qgrp_cnt_get_evt_process 

 DESCRIPTION    : This routine process the qcount get event .

 ARGUMENTS      : pMqd - MQD Control block pointer
                  pEvt - Event structure

 RETURNS        : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
\*****************************************************************************/
static uint32_t mqd_qgrp_cnt_get_evt_process(MQD_CB *pMqd, MQSV_EVT *pevt)
{
	MQD_OBJ_NODE *pObjNode = 0;
	MQSV_EVT rsp;
	uint32_t rc = NCSCC_RC_SUCCESS;
	MQSV_CTRL_EVT_QGRP_CNT *qgrp_cnt_info = &pevt->msg.mqd_ctrl.info.qgrp_cnt_info;
	TRACE_ENTER();

	memset(&rsp, 0, sizeof(MQSV_EVT));

	if (pMqd->ha_state == SA_AMF_HA_ACTIVE) {
		rsp.type = MQSV_EVT_MQND_CTRL;
		rsp.msg.mqnd_ctrl.type = MQND_CTRL_EVT_QGRP_CNT_RSP;
		rsp.msg.mqnd_ctrl.info.qgrp_cnt_info.info.queueName = qgrp_cnt_info->info.queueName;

		pObjNode = (MQD_OBJ_NODE *)ncs_patricia_tree_get(&pMqd->qdb, (uint8_t *)&qgrp_cnt_info->info.queueName);
		if (pObjNode) {
			rsp.msg.mqnd_ctrl.info.qgrp_cnt_info.error = SA_AIS_OK;
			rsp.msg.mqnd_ctrl.info.qgrp_cnt_info.info.noOfQueueGroupMemOf = pObjNode->oinfo.ilist.count;
		} else {
			rsp.msg.mqnd_ctrl.info.qgrp_cnt_info.error = SA_AIS_ERR_NOT_EXIST;
			rsp.msg.mqnd_ctrl.info.qgrp_cnt_info.info.noOfQueueGroupMemOf = 0;
		}
		rc = mqd_mds_send_rsp(pMqd, &pevt->sinfo, &rsp);
	}
	TRACE_LEAVE2(" return code %u", rc);
	return rc;
}
Esempio n. 7
0
/****************************************************************************\
 PROCEDURE NAME : mqd_ctrl_evt_hdlr

 DESCRIPTION    : This is the callback handler for MQD Controll events.

 ARGUMENTS      : pEvt - This is the pointer which holds the event structure.
                  pMqd - MQD Controll block

 RETURNS        : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
\*****************************************************************************/
uint32_t mqd_ctrl_evt_hdlr(MQSV_EVT *pEvt, MQD_CB *pMqd)
{
	uint32_t rc = NCSCC_RC_SUCCESS;
	TRACE_ENTER();

	/* Check the message type and handle the message */
	if (MQD_MSG_USER == pEvt->msg.mqd_ctrl.type) {
		rc = mqd_user_evt_process(pMqd, &pEvt->msg.mqd_ctrl.info.user);
	} else if (MQD_MSG_COMP == pEvt->msg.mqd_ctrl.type) {
		rc = mqd_comp_evt_process(pMqd, &pEvt->msg.mqd_ctrl.info.init);
	}
	if (MQD_MSG_TMR_EXPIRY == pEvt->msg.mqd_ctrl.type) {
		rc = mqd_timer_expiry_evt_process(pMqd, &pEvt->msg.mqd_ctrl.info.tmr_info.nodeid);
	} else if (MQD_ND_STATUS_INFO_TYPE == pEvt->msg.mqd_ctrl.type) {
		rc = mqd_nd_status_evt_process(pMqd, &pEvt->msg.mqd_ctrl.info.nd_info);
	} else if (MQD_QUISCED_STATE_INFO_TYPE == pEvt->msg.mqd_ctrl.type) {
		rc = mqd_quisced_process(pMqd, &pEvt->msg.mqd_ctrl.info.quisced_info);
	} else if (MQD_CB_DUMP_INFO_TYPE == pEvt->msg.mqd_ctrl.type) {
		rc = mqd_cb_dump();
	} else if (MQD_QGRP_CNT_GET == pEvt->msg.mqd_ctrl.type) {
		rc = mqd_qgrp_cnt_get_evt_process(pMqd, pEvt);
	}
	TRACE_LEAVE2(" return code %u", rc);
	return rc;
}	/* End of mqd_ctrl_evt_hdlr() */
Esempio n. 8
0
void client_added_res_lib(SaAisErrorT error, unsigned int clientId, MDS_DEST mdsDest, MDS_SYNC_SND_CTXT *mdsCtxt)
{
	uns32 rc;
	ntfsv_msg_t msg;
	ntfsv_ckpt_msg_t ckpt;
	TRACE_ENTER2("clientId: %u, rv: %u", clientId, error);
	msg.type = NTFSV_NTFA_API_RESP_MSG;
	msg.info.api_resp_info.type = NTFSV_INITIALIZE_RSP;
	msg.info.api_resp_info.rc = error;
	msg.info.api_resp_info.param.init_rsp.client_id = clientId;
	rc = ntfs_mds_msg_send(ntfs_cb, &msg, &mdsDest, mdsCtxt, MDS_SEND_PRIORITY_HIGH);
	if (rc != NCSCC_RC_SUCCESS) {
		TRACE_LEAVE2("ntfs_mds_msg_send FAILED rc = %u", (unsigned int)rc);
		return;
	}

	if (error == SA_AIS_OK) {
		memset(&ckpt, 0, sizeof(ckpt));
		ckpt.header.ckpt_rec_type = NTFS_CKPT_INITIALIZE_REC;
		ckpt.header.num_ckpt_records = 1;
		ckpt.header.data_len = 1;
		ckpt.ckpt_rec.reg_rec.client_id = clientId;
		ckpt.ckpt_rec.reg_rec.mds_dest = mdsDest;
		update_standby(&ckpt, NCS_MBCSV_ACT_ADD);
	}
	TRACE_LEAVE();
}
Esempio n. 9
0
/****************************************************************************
  Name          : eda_destroy

  Description   : This routine destroys the EDA control block.

  Arguments     : destroy_info - ptr to the destroy info

  Return Values : None

  Notes         : None
******************************************************************************/
void eda_destroy(NCS_LIB_DESTROY *destroy_info)
{
    EDA_CB *cb = 0;
    TRACE_ENTER();

    /* retrieve EDA CB */
    cb = (EDA_CB *)ncshm_take_hdl(NCS_SERVICE_ID_EDA, gl_eda_hdl);
    if (!cb) {
        TRACE_LEAVE2("global take handle failed: %u", gl_eda_hdl);
        return;
    }
    /* delete the hdl db */
    eda_hdl_list_del(&cb->eda_init_rec_list);

    /* unregister with MDS */
    eda_mds_finalize(cb);

    /* destroy the lock */
    m_NCS_LOCK_DESTROY(&cb->cb_lock);

    /* return EDA CB */
    ncshm_give_hdl(gl_eda_hdl);

    /* remove the association with hdl-mngr */
    ncshm_destroy_hdl(NCS_SERVICE_ID_EDA, cb->cb_hdl);

    /* free the control block */
    m_MMGR_FREE_EDA_CB(cb);

    /* reset the global cb handle */
    gl_eda_hdl = 0;

    TRACE_LEAVE();
    return;
}
Esempio n. 10
0
/****************************************************************************
  Name          : ava_hdl_rec_add
 
  Description   : This routine adds the handle record to the handle db.
 
  Arguments     : cb       - ptr tot he AvA control block
                  hdl_db   - ptr to the hdl db
                  reg_cbks - ptr to the set of registered callbacks
 
  Return Values : ptr to the handle record
 
  Notes         : None
******************************************************************************/
AVA_HDL_REC *ava_hdl_rec_add(AVA_CB *cb, AVA_HDL_DB *hdl_db, const SaAmfCallbacksT *reg_cbks)
{
	AVA_HDL_REC *rec = 0;
	TRACE_ENTER();

	/* allocate the hdl rec */
	if (!(rec = calloc(1, sizeof(AVA_HDL_REC)))) {
		LOG_CR("Error occurred calling calloc");
		osafassert(0);
	}

	/* create the association with hdl-mngr */
	if (!(rec->hdl = ncshm_create_hdl(cb->pool_id, NCS_SERVICE_ID_AVA, (NCSCONTEXT)rec))) {
		LOG_CR("Error occurred during creation of handle");
		osafassert(0);
	}

	/* store the registered callbacks */
	if (reg_cbks)
		memcpy((void *)&rec->reg_cbk, (void *)reg_cbks, sizeof(SaAmfCallbacksT));

	/* add the record to the hdl db */
	rec->hdl_node.key_info = (uint8_t *)&rec->hdl;
	if (ncs_patricia_tree_add(&hdl_db->hdl_db_anchor, &rec->hdl_node)
	    != NCSCC_RC_SUCCESS) {
		LOG_CR("Patricia tree add failed ");
		osafassert(0);
	}

	/* update the no of records */
	hdl_db->num++;

	TRACE_LEAVE2("Handle = %x successfully added to Handle DB, num hdls = %d",rec->hdl,hdl_db->num);
	return rec;
}
Esempio n. 11
0
/****************************************************************************
  Name          : ava_hdl_cbk_param_add
 
  Description   : This routine adds the callback parameters to the pending 
                  callback list.
 
  Arguments     : cb       - ptr to the AvA control block
                  hdl_rec  - ptr to the handle record
                  cbk_info - ptr to the callback parameters
 
  Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
 
  Notes         : This routine reuses the callback info ptr that is received 
                  from MDS thus avoiding an extra copy.
******************************************************************************/
uint32_t ava_hdl_cbk_param_add(AVA_CB *cb, AVA_HDL_REC *hdl_rec, AVSV_AMF_CBK_INFO *cbk_info)
{
	AVA_PEND_CBK_REC *rec = 0;
	uint32_t rc = NCSCC_RC_SUCCESS;
	TRACE_ENTER();

	/* allocate the callbk rec */
	if (!(rec = calloc(1, sizeof(AVA_PEND_CBK_REC)))) {
		rc = NCSCC_RC_FAILURE;
		goto done;
	}

	/* populate the callbk parameters */
	rec->cbk_info = cbk_info;

	/* now push it to the pending list */
	rc = m_NCS_IPC_SEND(&hdl_rec->callbk_mbx, rec, NCS_IPC_PRIORITY_NORMAL);

done:
	if ((NCSCC_RC_SUCCESS != rc) && rec)
		ava_hdl_cbk_rec_del(rec);

	TRACE_LEAVE2("Callback param successfully added for handle: %x", hdl_rec->hdl);
	return rc;
}
Esempio n. 12
0
/****************************************************************************
  Name          : cpa_mds_msg_sync_send
 
  Description   : This routine sends the CPA message to CPND.
 
  Arguments     :
                  uint32_t      cpa_mds_hdl Handle of CPA
                  MDS_DEST  *destination - destintion to send to
                  CPSV_EVT   *i_evt - CPSV_EVT pointer
                  CPSV_EVT   **o_evt - CPSV_EVT pointer to result data
                  timeout - timeout value in 10 ms 
 
  Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
 
  Notes         : None.
******************************************************************************/
uint32_t cpa_mds_msg_sync_send(uint32_t cpa_mds_hdl, MDS_DEST *destination, CPSV_EVT *i_evt, CPSV_EVT **o_evt, uint32_t timeout)
{
	NCSMDS_INFO mds_info;
	uint32_t rc;
	
	TRACE_ENTER();

	if (!i_evt)
		return NCSCC_RC_FAILURE;

	memset(&mds_info, 0, sizeof(NCSMDS_INFO));
	mds_info.i_mds_hdl = cpa_mds_hdl;
	mds_info.i_svc_id = NCSMDS_SVC_ID_CPA;
	mds_info.i_op = MDS_SEND;

	/* fill the send structure */
	mds_info.info.svc_send.i_msg = (NCSCONTEXT)i_evt;
	mds_info.info.svc_send.i_priority = MDS_SEND_PRIORITY_MEDIUM;
	mds_info.info.svc_send.i_to_svc = NCSMDS_SVC_ID_CPND;
	mds_info.info.svc_send.i_sendtype = MDS_SENDTYPE_SNDRSP;

	/* fill the send rsp strcuture */
	mds_info.info.svc_send.info.sndrsp.i_time_to_wait = timeout;	/* timeto wait in 10ms */
	mds_info.info.svc_send.info.sndrsp.i_to_dest = *destination;

	/* send the message */
	rc = ncsmds_api(&mds_info);

	if (rc == NCSCC_RC_SUCCESS)
		*o_evt = mds_info.info.svc_send.info.sndrsp.o_rsp;

	TRACE_LEAVE2("retval = %u",rc);
	return rc;
}
Esempio n. 13
0
/****************************************************************************
  Name          : avnd_mds_red_send
 
  Description   : This routine sends the mds message to specified AvD.
 
  Arguments     : cb       - ptr to the AvND control block
                  msg      - ptr to the message
                  dest     - ptr to the MDS destination
                  adest    - ptr to the MDS adest(anchor) 
 
  Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
 
  Notes         : This funtion as of now is only used to send the ACK-NACK msg
                  to AvD. This funtion is introduced to overcome the problem
                  of MDS dropping a msg when the role has changed but MDS in 
                  AvND has not updated its tables about the role change.
                  Due to this problem MDS will try to send the msg to old
                  active which may not be there in the system and hence the
                  msg will be dropped.
                  With this funtion we are sending msg to the new active AvD
                  directly, without looking for its MDS role as seen by AvND. 
******************************************************************************/
uns32 avnd_mds_red_send(AVND_CB *cb, AVND_MSG *msg, MDS_DEST *dest, MDS_DEST *adest)
{
	NCSMDS_INFO mds_info;
	MDS_SEND_INFO *send_info = &mds_info.info.svc_send;
	MDS_SENDTYPE_RED_INFO *send = &send_info->info.red;
	uns32 rc = NCSCC_RC_SUCCESS;
	TRACE_ENTER2("Msg type '%u'", msg->type);

	/* populate the mds params */
	memset(&mds_info, 0, sizeof(NCSMDS_INFO));

	mds_info.i_mds_hdl = cb->mds_hdl;
	mds_info.i_svc_id = NCSMDS_SVC_ID_AVND;
	mds_info.i_op = MDS_SEND;

	send_info->i_msg = (NCSCONTEXT)msg;
	send_info->i_priority = MDS_SEND_PRIORITY_MEDIUM;

	/* this is be used only for ACK NACK for AVD */
	if (msg->type != AVND_MSG_AVD)
		assert(0);

	send_info->i_to_svc = NCSMDS_SVC_ID_AVD;
	send_info->i_sendtype = MDS_SENDTYPE_RED;
	send->i_to_vdest = *dest;
	send->i_to_anc = *adest;	/* assumption-:ADEST is same as anchor */

	/* send the message */
	rc = ncsmds_api(&mds_info);
	if (NCSCC_RC_SUCCESS != rc)
		LOG_CR("AVND MDS send failed: Msg type = %u, vdest = %llu, anchor = %llu",msg->type,send->i_to_vdest,send->i_to_anc);

	TRACE_LEAVE2("rc '%u'", rc);
	return rc;
}
Esempio n. 14
0
/****************************************************************************
  Name          : avnd_diq_rec_add
 
  Description   : This routine adds a record to the AvD msg list.
 
  Arguments     : cb  - ptr to the AvND control block
                  msg - ptr to the message
 
  Return Values : ptr to the newly added msg record
 
  Notes         : None.
******************************************************************************/
AVND_DND_MSG_LIST *avnd_diq_rec_add(AVND_CB *cb, AVND_MSG *msg)
{
	AVND_DND_MSG_LIST *rec = 0;
	TRACE_ENTER();

	if ((0 == (rec = calloc(1, sizeof(AVND_DND_MSG_LIST)))))
		goto error;

	/* create the association with hdl-mngr */
	if ((0 == (rec->opq_hdl = ncshm_create_hdl(cb->pool_id, NCS_SERVICE_ID_AVND, (NCSCONTEXT)rec))))
		goto error;

	/* store the msg (transfer memory ownership) */
	rec->msg.type = msg->type;
	rec->msg.info.avd = msg->info.avd;
	msg->info.avd = 0;

	/* push the record to the AvD msg list */
	m_AVND_DIQ_REC_PUSH(cb, rec);
	TRACE_LEAVE();
	return rec;

 error:
	TRACE_LEAVE2("'%p'", rec);
	if (rec)
		avnd_diq_rec_del(cb, rec);

	return 0;
}
Esempio n. 15
0
/****************************************************************************
  Name          : avnd_diq_rec_send
 
  Description   : This routine sends message (contained in the record) to 
                  AvD. It allocates a new message, copies the contents from 
                  the message contained in the record & then sends it to AvD.
 
  Arguments     : cb  - ptr to the AvND control block
                  rec - ptr to the msg record
 
  Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE.
 
  Notes         : None
******************************************************************************/
uns32 avnd_diq_rec_send(AVND_CB *cb, AVND_DND_MSG_LIST *rec)
{
	AVND_MSG msg;
	uns32 rc = NCSCC_RC_SUCCESS;
	TRACE_ENTER();

	memset(&msg, 0, sizeof(AVND_MSG));

	/* copy the contents from the record */
	rc = avnd_msg_copy(cb, &msg, &rec->msg);

	/* send the message to AvD */
	if (NCSCC_RC_SUCCESS == rc)
		rc = avnd_mds_send(cb, &msg, &cb->avd_dest, 0);

	/* start the msg response timer */
	if (NCSCC_RC_SUCCESS == rc) {
		if (rec->msg.info.avd->msg_type == AVSV_N2D_NODE_UP_MSG)
			m_AVND_TMR_MSG_RESP_START(cb, *rec, rc);
		msg.info.avd = 0;
	}

	/* free the msg */
	avnd_msg_content_free(cb, &msg);
	TRACE_LEAVE2("%u", rc);
	return rc;
}
Esempio n. 16
0
/****************************************************************************
  Name          : avnd_di_object_upd_send
 
  Description   : This routine sends update of those objects that reside 
                  on AvD but are maintained on AvND.
 
  Arguments     : cb    - ptr to the AvND control block
                  param - ptr to the params that are to be updated to AvD
 
  Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
 
  Notes         : None.
******************************************************************************/
uns32 avnd_di_object_upd_send(AVND_CB *cb, AVSV_PARAM_INFO *param)
{
	AVND_MSG msg;
	uns32 rc = NCSCC_RC_SUCCESS;
	TRACE_ENTER2("Comp '%s'", param->name.value);

	memset(&msg, 0, sizeof(AVND_MSG));

	/* populate the msg */
	if (0 != (msg.info.avd = calloc(1, sizeof(AVSV_DND_MSG)))) {
		msg.type = AVND_MSG_AVD;
		msg.info.avd->msg_type = AVSV_N2D_DATA_REQUEST_MSG;
		msg.info.avd->msg_info.n2d_data_req.msg_id = ++(cb->snd_msg_id);
		msg.info.avd->msg_info.n2d_data_req.node_id = cb->node_info.nodeId;
		msg.info.avd->msg_info.n2d_data_req.param_info = *param;

		/* send the msg to AvD */
		rc = avnd_di_msg_send(cb, &msg);
		if (NCSCC_RC_SUCCESS == rc)
			msg.info.avd = 0;
	} else
		rc = NCSCC_RC_FAILURE;

	/* free the contents of avnd message */
	avnd_msg_content_free(cb, &msg);
	TRACE_LEAVE2("%u", rc);
	return rc;
}
Esempio n. 17
0
/****************************************************************************
  Name          : avnd_di_ack_nack_msg_send
 
  Description   : This routine processes the data verify message sent by newly
                  Active AVD.
 
  Arguments     : cb  - ptr to the AvND control block
                  rcv_id - Receive message ID for AVND
                  view_num - Cluster view number
 
  Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
 
  Notes         : None.
******************************************************************************/
uns32 avnd_di_ack_nack_msg_send(AVND_CB *cb, uns32 rcv_id, uns32 view_num)
{
	AVND_MSG msg;
	uns32 rc = NCSCC_RC_SUCCESS;
	TRACE_ENTER2("Receive id = %u",rcv_id);

   /*** send the response to AvD ***/
	memset(&msg, 0, sizeof(AVND_MSG));

	if (0 != (msg.info.avd = calloc(1, sizeof(AVSV_DND_MSG)))) {
		msg.type = AVND_MSG_AVD;
		msg.info.avd->msg_type = AVSV_N2D_VERIFY_ACK_NACK_MSG;
		msg.info.avd->msg_info.n2d_ack_nack_info.msg_id = (cb->snd_msg_id + 1);
		msg.info.avd->msg_info.n2d_ack_nack_info.node_id = cb->node_info.nodeId;

		if (rcv_id != cb->rcv_msg_id)
			msg.info.avd->msg_info.n2d_ack_nack_info.ack = FALSE;
		else
			msg.info.avd->msg_info.n2d_ack_nack_info.ack = TRUE;

		TRACE_1("MsgId=%u,ACK=%u",msg.info.avd->msg_info.n2d_ack_nack_info.msg_id,msg.info.avd->msg_info.n2d_ack_nack_info.ack);

		rc = avnd_di_msg_send(cb, &msg);
		if (NCSCC_RC_SUCCESS == rc)
			msg.info.avd = 0;
	} else
		rc = NCSCC_RC_FAILURE;

	/* free the contents of avnd message */
	avnd_msg_content_free(cb, &msg);

	TRACE_LEAVE2("retval=%u",rc);
	return rc;
}
Esempio n. 18
0
/****************************************************************************
  Name          : avnd_su_curr_info_del
 
  Description   : This routine deletes the dynamic info associated with this 
                  SU. This includes deleting the dynamic info for all it's 
                  components. If the SU is marked failed, the error 
                  escalation parameters are retained.
 
  Arguments     : cb - ptr to the AvND control block
                  su - ptr to the su
 
  Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
 
  Notes         : SIs associated with this SU are not deleted.
******************************************************************************/
uns32 avnd_su_curr_info_del(AVND_CB *cb, AVND_SU *su)
{
	AVND_COMP *comp = 0;
	uns32 rc = NCSCC_RC_SUCCESS;
	TRACE_ENTER2("'%s'", su->name.value);

	/* reset err-esc param & oper state (if su is healthy) */
	if (!m_AVND_SU_IS_FAILED(su)) {
		su->su_err_esc_level = AVND_ERR_ESC_LEVEL_0;
		su->comp_restart_cnt = 0;
		su->su_restart_cnt = 0;
		m_AVND_SEND_CKPT_UPDT_ASYNC_UPDT(cb, su, AVND_CKPT_SU_CONFIG);
		/* stop su_err_esc_tmr TBD Later */

		/* disable the oper state (if pi su) */
		if (m_AVND_SU_IS_PREINSTANTIABLE(su)) {
			m_AVND_SU_OPER_STATE_SET(su, SA_AMF_OPERATIONAL_DISABLED);
			m_AVND_SEND_CKPT_UPDT_ASYNC_UPDT(cb, su, AVND_CKPT_SU_OPER_STATE);
		}
	}

	/* scan & delete the current info store in each component */
	for (comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(m_NCS_DBLIST_FIND_FIRST(&su->comp_list));
	     comp; comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(m_NCS_DBLIST_FIND_NEXT(&comp->su_dll_node))) {
		rc = avnd_comp_curr_info_del(cb, comp);
		if (NCSCC_RC_SUCCESS != rc)
			goto done;
	}

 done:
	TRACE_LEAVE2("%u", rc);
	return rc;
}
Esempio n. 19
0
/****************************************************************************
  Name          : avnd_evt_avd_info_su_si_assign_msg
 
  Description   : This routine processes the SU-SI assignment message from 
                  AvD. It buffers the message if already some assignment is on.
                  Else it initiates SI addition, deletion or removal.
 
  Arguments     : cb  - ptr to the AvND control block
                  evt - ptr to the AvND event
 
  Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
 
  Notes         : None.
******************************************************************************/
uns32 avnd_evt_avd_info_su_si_assign_evh(AVND_CB *cb, AVND_EVT *evt)
{
	AVSV_D2N_INFO_SU_SI_ASSIGN_MSG_INFO *info = &evt->info.avd->msg_info.d2n_su_si_assign;
	AVND_SU_SIQ_REC *siq = 0;
	AVND_SU *su = 0;
	uns32 rc = NCSCC_RC_SUCCESS;

	TRACE_ENTER();

	/* get the su */
	su = m_AVND_SUDB_REC_GET(cb->sudb, info->su_name);
	if (!su) {
		TRACE_LEAVE2("SU record not found");
		return rc;
	}

	TRACE("'%s'", su->name.value);

	if (info->msg_id != (cb->rcv_msg_id + 1)) {
		/* Log Error */
		rc = NCSCC_RC_FAILURE;
		LOG_EM("%s %u Message Id mismatch, received msg id = %u",__FUNCTION__, __LINE__, info->msg_id);

		goto done;
	}

	cb->rcv_msg_id = info->msg_id;

	/* buffer the msg (if no assignment / removal is on) */
	siq = avnd_su_siq_rec_buf(cb, su, info);
	if (siq) {
		/* Send async update for SIQ Record for external SU only. */
		if (TRUE == su->su_is_external) {
			m_AVND_SEND_CKPT_UPDT_ASYNC_ADD(cb, &(siq->info), AVND_CKPT_SIQ_REC);
		}
		TRACE_LEAVE();
		return rc;
	}

	/* the msg isn't buffered, process it */
	rc = avnd_su_si_msg_prc(cb, su, info);

done:
	TRACE_LEAVE2("%u", rc);
	return rc;
}
Esempio n. 20
0
/****************************************************************************
 * Name          : eds_proc_ret_tmr_exp_evt
 *
 * Description   : This is the function which is called when eds receives any
 *                 a retention tmr expiry evt
 *
 * Arguments     : evt  - Evt that was posted to the EDS Mail box.
 *
 * Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
 *
 * Notes         : None.
 *****************************************************************************/
static uint32_t eds_proc_ret_tmr_exp_evt(EDSV_EDS_EVT *evt)
{
	EDS_RETAINED_EVT_REC *ret_evt;
	uint32_t rc = NCSCC_RC_SUCCESS;
	EDS_CB *eds_cb;
	TRACE_ENTER();

	/* retrieve retained evt */
	if (NULL == (eds_cb = (EDS_CB *)ncshm_take_hdl(NCS_SERVICE_ID_EDS, evt->cb_hdl))) {
		TRACE_LEAVE2("take handle failed for cb");
		return NCSCC_RC_FAILURE;
	}

	/* retrieve retained evt */
	if (NULL == (ret_evt = (EDS_RETAINED_EVT_REC *)ncshm_take_hdl(NCS_SERVICE_ID_EDS, evt->info.tmr_info.opq_hdl))) {
		TRACE_LEAVE2("take handle failed for retained evt rec.");
		return NCSCC_RC_FAILURE;
	}

	m_NCS_LOCK(&eds_cb->cb_lock, NCS_LOCK_WRITE);

   /** store the chan id as we would need it
    ** after the event is freed
    **/

/* CHECKPOINT:
   if ( EDS_CB->ha_state == standby)
        compose a EDSV_CKPT_RETENTION_TIME_CLEAR_MSG and send to standby peer. 
*/
   /** This also frees the event **/
	rc = eds_clear_retained_event(eds_cb,
				      ret_evt->chan_id, ret_evt->retd_evt_chan_open_id, ret_evt->event_id, true);

	m_NCS_UNLOCK(&eds_cb->cb_lock, NCS_LOCK_WRITE);

	if (NCSCC_RC_SUCCESS != rc) {
		ncshm_give_hdl(evt->info.tmr_info.opq_hdl);
		ncshm_give_hdl(evt->cb_hdl);
		TRACE_LEAVE();
		return rc;
	}

	ncshm_give_hdl(evt->cb_hdl);
	TRACE_LEAVE();
	return NCSCC_RC_SUCCESS;
}
Esempio n. 21
0
/****************************************************************************
  Name          : ava_hdl_cbk_dispatch_one
 
  Description   : This routine dispatches one pending callback.
 
  Arguments     : cb      - ptr to the AvA control block
                  hdl_rec - ptr to the handle record
 
  Return Values : SA_AIS_OK/SA_AIS_ERR_<CODE>
 
  Notes         : None.
******************************************************************************/
uint32_t ava_hdl_cbk_dispatch_one(AVA_CB **cb, AVA_HDL_REC **hdl_rec)
{
	AVA_PEND_RESP *list_resp = &(*hdl_rec)->pend_resp;
	AVA_PEND_CBK_REC *rec = 0;
	uint32_t hdl = (*hdl_rec)->hdl;
	SaAmfCallbacksT reg_cbk;
	uint32_t rc = SA_AIS_OK;
	TRACE_ENTER();

	memset(&reg_cbk, 0, sizeof(SaAmfCallbacksT));
	memcpy(&reg_cbk, &(*hdl_rec)->reg_cbk, sizeof(SaAmfCallbacksT));

	/* pop the rec from the mailbox queue */
	rec = (AVA_PEND_CBK_REC *)m_NCS_IPC_NON_BLK_RECEIVE(&(*hdl_rec)->callbk_mbx, NULL);

	if (rec) {

		if (rec->cbk_info->type != AVSV_AMF_PG_TRACK) {
			/* push this record into pending response list */
			m_AVA_HDL_PEND_RESP_PUSH(list_resp, (AVA_PEND_RESP_REC *)rec);
			m_AVA_HDL_CBK_REC_IN_DISPATCH_SET(rec);
		}

		/* release the cb lock & return the hdls to the hdl-mngr */
		m_NCS_UNLOCK(&(*cb)->lock, NCS_LOCK_WRITE);
		ncshm_give_hdl(hdl);

		/* process the callback list record */
		ava_hdl_cbk_rec_prc(rec->cbk_info, &reg_cbk);

		m_NCS_LOCK(&(*cb)->lock, NCS_LOCK_WRITE);

		if (0 == (*hdl_rec = ncshm_take_hdl(NCS_SERVICE_ID_AVA, hdl))) {
			/* hdl is already finalized */
			ava_hdl_cbk_rec_del(rec);
			TRACE_LEAVE2("Handle is already finalized");
			return rc;
		}

		/* if we are done with this rec, free it */
		if ((rec->cbk_info->type != AVSV_AMF_PG_TRACK) && m_AVA_HDL_IS_CBK_RESP_DONE(rec)) {
			m_AVA_HDL_PEND_RESP_POP(list_resp, rec, rec->cbk_info->inv);
			ava_hdl_cbk_rec_del(rec);
		} else if (rec->cbk_info->type == AVSV_AMF_PG_TRACK) {
			/* PG Track cbk do not have any response */
			ava_hdl_cbk_rec_del(rec);
		} else {
			m_AVA_HDL_CBK_REC_IN_DISPATCH_RESET(rec);
		}

	}
	else
		TRACE_3("No record to process the dispatch()");

	TRACE_LEAVE();
	return rc;
}
Esempio n. 22
0
/****************************************************************************
 * PROCEDURE: mbcsv_lib_init
 *
 * Description   : This is the function which initalize the mbcsv libarary.
 *                 This function creates an global lock, creates MBCSV linked 
 *                 list, etc.
 *
 * Arguments     : req_info - Request info.
 *
 * Return Values : SA_AIS_OK/Failure code.
 *
 * Notes         : None.
 *****************************************************************************/
uint32_t mbcsv_lib_init(NCS_LIB_REQ_INFO *req_info)
{
	NCS_PATRICIA_PARAMS pt_params;
	uint32_t rc = SA_AIS_OK;
	TRACE_ENTER();

	if (mbcsv_cb.created == true) {
		TRACE_LEAVE2("Lib init request failed: MBCA already created");
		return SA_AIS_ERR_INIT;
	}

	/*
	 * Create global lock 
	 */
	m_NCS_LOCK_INIT(&mbcsv_cb.global_lock);

	/* 
	 * Create patricia tree for the MBCA registration instance 
	 */
	pt_params.key_size = sizeof(uint32_t);

	if (ncs_patricia_tree_init(&mbcsv_cb.reg_list, &pt_params) != NCSCC_RC_SUCCESS) {
		TRACE_4("pat tree init failed");
		rc = SA_AIS_ERR_FAILED_OPERATION;
		goto err1;
	}

	if (NCSCC_RC_SUCCESS != mbcsv_initialize_mbx_list()) {
		TRACE_4("pat tree init for mailbox failed");
		rc = SA_AIS_ERR_FAILED_OPERATION;
		goto err2;
	}

	/* 
	 * Create patricia tree for the peer list 
	 */
	if (mbcsv_initialize_peer_list() != NCSCC_RC_SUCCESS) {
		TRACE_4("pat tree init for peer list failed");
		rc = SA_AIS_ERR_FAILED_OPERATION;
		goto err3;
	}

	mbcsv_cb.created = true;

	return rc;

	/* Handle Different Error Situations */
 err3:
	ncs_patricia_tree_destroy(&mbcsv_cb.mbx_list);
	m_NCS_LOCK_DESTROY(&mbcsv_cb.mbx_list_lock);
 err2:
	ncs_patricia_tree_destroy(&mbcsv_cb.reg_list);
 err1:
	m_NCS_LOCK_DESTROY(&mbcsv_cb.global_lock);
	TRACE_LEAVE();
	return rc;
}
Esempio n. 23
0
/****************************************************************************
 * Name          : cpd_amf_register
 *
 * Description   : CPD registers with AMF for involking process.
 *
 * Arguments     : cpd_cb  - Ifsv control block pointer.
 *
 * Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE.
 *
 * Notes         : None.
 *****************************************************************************/
uint32_t cpd_amf_register(CPD_CB *cpd_cb)
{
	SaAisErrorT error;
	TRACE_ENTER();
	/* get the component name */
	error = saAmfComponentNameGet(cpd_cb->amf_hdl, &cpd_cb->comp_name);
	if (error != SA_AIS_OK) {
		LOG_ER("cpd amf compname get failed with Error: %u",error);
		TRACE_LEAVE();
		return NCSCC_RC_FAILURE;
	}

	if (saAmfComponentRegister(cpd_cb->amf_hdl, &cpd_cb->comp_name, (SaNameT *)NULL) == SA_AIS_OK) {
		TRACE_LEAVE2("cpd amf register success for %s",cpd_cb->comp_name.value);
		return NCSCC_RC_SUCCESS;
	} else {
		TRACE_LEAVE2("cpd Amf component register failed for %s",cpd_cb->comp_name.value);
		return NCSCC_RC_FAILURE;
	}
}
Esempio n. 24
0
/****************************************************************************
  Name          : avnd_mds_send
 
  Description   : This routine sends the mds message to AvA or AvD or AvND.
 
  Arguments     : cb       - ptr to the AvND control block
                  msg      - ptr to the message
                  dest     - ptr to the MDS destination
                  mds_ctxt - ptr to the MDS message context 
 
  Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
 
  Notes         : None.
******************************************************************************/
uns32 avnd_mds_send(AVND_CB *cb, AVND_MSG *msg, MDS_DEST *dest, MDS_SYNC_SND_CTXT *mds_ctxt)
{
	NCSMDS_INFO mds_info;
	MDS_SEND_INFO *send_info = &mds_info.info.svc_send;
	uns32 rc = NCSCC_RC_SUCCESS;

	TRACE_ENTER2("Msg type '%u'", msg->type);
	/* populate the mds params */
	memset(&mds_info, 0, sizeof(NCSMDS_INFO));

	mds_info.i_mds_hdl = cb->mds_hdl;
	mds_info.i_svc_id = NCSMDS_SVC_ID_AVND;
	mds_info.i_op = MDS_SEND;

	send_info->i_msg = (NCSCONTEXT)msg;
	send_info->i_priority = MDS_SEND_PRIORITY_MEDIUM;

	switch (msg->type) {
	case AVND_MSG_AVD:
		send_info->i_to_svc = NCSMDS_SVC_ID_AVD;
		break;

	case AVND_MSG_AVA:
		send_info->i_to_svc = NCSMDS_SVC_ID_AVA;
		break;

	default:
		assert(0);
		break;
	}

	if (!mds_ctxt) {
		/* regular send */
		MDS_SENDTYPE_SND_INFO *send = &send_info->info.snd;

		send_info->i_sendtype = MDS_SENDTYPE_SND;
		send->i_to_dest = *dest;
	} else {
		/* response message (somebody is waiting for it) */
		MDS_SENDTYPE_RSP_INFO *resp = &send_info->info.rsp;

		send_info->i_sendtype = MDS_SENDTYPE_RSP;
		resp->i_sender_dest = *dest;
		resp->i_msg_ctxt = *mds_ctxt;
	}

	/* send the message */
	rc = ncsmds_api(&mds_info);
	if (NCSCC_RC_SUCCESS != rc)
		LOG_ER("ncsmds_api for %u FAILED, dest=%llx", send_info->i_sendtype, *dest);

	TRACE_LEAVE2("%u", rc);
	return rc;
}
Esempio n. 25
0
uns32 rde_amf_init(RDE_AMF_CB *rde_amf_cb)
{
	uns32 rc = NCSCC_RC_SUCCESS;
	SaAisErrorT amf_error = SA_AIS_OK;
	SaNameT sname;
	SaAmfCallbacksT amfCallbacks;
	SaVersionT amf_version;

	TRACE_ENTER();

	if (amf_comp_name_get_set_from_file("RDE_COMP_NAME_FILE", &sname) != NCSCC_RC_SUCCESS)
		return NCSCC_RC_FAILURE;

	amfCallbacks.saAmfHealthcheckCallback = rde_saf_health_chk_callback;
	amfCallbacks.saAmfCSISetCallback = rde_saf_CSI_set_callback;
	amfCallbacks.saAmfCSIRemoveCallback = rde_saf_CSI_rem_callback;
	amfCallbacks.saAmfComponentTerminateCallback = rde_saf_comp_terminate_callback;

	m_RDE_GET_AMF_VER(amf_version);

	amf_error = saAmfInitialize(&rde_amf_cb->amf_hdl, &amfCallbacks, &amf_version);
	if (amf_error != SA_AIS_OK) {
		LOG_ER("saAmfInitialize FAILED %u", amf_error);
		return NCSCC_RC_FAILURE;
	}

	memset(&sname, 0, sizeof(sname));
	amf_error = saAmfComponentNameGet(rde_amf_cb->amf_hdl, &sname);
	if (amf_error != SA_AIS_OK) {
		LOG_ER("saAmfComponentNameGet FAILED %u", amf_error);
		return NCSCC_RC_FAILURE;
	}

	strcpy((char*)rde_amf_cb->comp_name, (char*)sname.value);

	amf_error = saAmfSelectionObjectGet(rde_amf_cb->amf_hdl, &rde_amf_cb->amf_fd);
	if (amf_error != SA_AIS_OK) {
		LOG_ER("saAmfSelectionObjectGet FAILED %u", amf_error);
		return NCSCC_RC_FAILURE;
	}

	amf_error = saAmfComponentRegister(rde_amf_cb->amf_hdl, &sname, (SaNameT *)NULL);
	if (amf_error != SA_AIS_OK) {
		LOG_ER("saAmfComponentRegister FAILED %u", amf_error);
		return NCSCC_RC_FAILURE;
	}

	rc = rde_amf_healthcheck_start(rde_amf_cb);
	if (rc != NCSCC_RC_SUCCESS)
		return NCSCC_RC_FAILURE;

	TRACE_LEAVE2("AMF Initialization SUCCESS......");
	return(rc);
}
Esempio n. 26
0
/****************************************************************************
 * Name          : plms_amf_init
 *
 * Description   : PLMS initializes AMF for invoking process and registers 
 *                 the various callback functions.
 *
 * Arguments     : PLMS_CB - PLMS control block pointer.
 *
 * Return Values : NCSCC_RC_SUCCESS/Error Code.
 *
 * Notes         : None.
 *****************************************************************************/
SaUint32T plms_amf_init()
{
	PLMS_CB * cb = plms_cb;
	SaAmfCallbacksT amfCallbacks;
	SaVersionT amf_version;
	uint32_t rc = NCSCC_RC_SUCCESS;

	TRACE_ENTER();

	if (cb->nid_started &&
		amf_comp_name_get_set_from_file("PLMD_COMP_NAME_FILE", &cb->comp_name) != NCSCC_RC_SUCCESS)
                goto done;

	/* Initialize amf callbacks */
	memset(&amfCallbacks, 0, sizeof(SaAmfCallbacksT));

	amfCallbacks.saAmfHealthcheckCallback = plms_amf_health_chk_callback;
	amfCallbacks.saAmfCSISetCallback = plms_amf_CSI_set_callback;
	amfCallbacks.saAmfComponentTerminateCallback = plms_amf_comp_terminate_callback;
	amfCallbacks.saAmfCSIRemoveCallback = plms_amf_csi_rmv_callback;

	m_PLMS_GET_AMF_VER(amf_version);

	/*Initialize the amf library */

	rc = saAmfInitialize(&cb->amf_hdl, &amfCallbacks, &amf_version);

	if (rc != SA_AIS_OK) {
		LOG_ER("  plms_amf_init: saAmfInitialize() AMF initialization FAILED\n");
		goto done;
	}
	LOG_IN("  plms_amf_init: saAmfInitialize() AMF initialization SUCCESS\n");

	/* Obtain the amf selection object to wait for amf events */
	if (SA_AIS_OK != (rc = saAmfSelectionObjectGet(cb->amf_hdl, &cb->amf_sel_obj))) {
		LOG_ER("saAmfSelectionObjectGet() FAILED\n");
		goto done;
	}
	LOG_IN("saAmfSelectionObjectGet() SUCCESS\n");

	/* get the component name */

	rc = saAmfComponentNameGet(cb->amf_hdl, &cb->comp_name);
	if (rc != SA_AIS_OK) {
		LOG_ER("  plmss_amf_init: saAmfComponentNameGet() FAILED\n");
		goto done ;
	}

	rc = NCSCC_RC_SUCCESS;
done:
        TRACE_LEAVE2("%u, %s", rc, cb->comp_name.value);
        return rc;

}	/*End plms_amf_init */
Esempio n. 27
0
/**
 * Adds the node to patricia tree
 *
 * @param node
 *
 * @return NCSCC_RC_SUCCESS
 * @return NCSCC_RC_FAILURE
 *
 */
uns32 dtm_node_add(DTM_NODE_DB * node, int i)
{
	uns32 rc = NCSCC_RC_SUCCESS;
	DTM_INTERNODE_CB *dtms_cb = dtms_gl_cb;
	TRACE_ENTER();
	TRACE("DTM:value of i %d", i);

	assert(node != NULL);

	switch (i) {

	case 0:
		TRACE("DTM:Adding node_id to the patricia tree with node_id :%u as key", node->node_id);
		node->pat_nodeid.key_info = (uns8 *)&(node->node_id);
		rc = ncs_patricia_tree_add(&dtms_cb->nodeid_tree, &node->pat_nodeid);
		if (rc != NCSCC_RC_SUCCESS) {
			TRACE("DTM:ncs_patricia_tree_add for node_id  FAILED for :%d :%u", node->node_id, rc);
			node->pat_nodeid.key_info = NULL;
			goto done;
		}
		break;
	case 1:
		TRACE("DTM:Adding node_id to the patricia tree with comm_socket :%u as key", node->comm_socket);
		node->pat_comm_socket.key_info = (uns8 *)&(node->comm_socket);
		rc = ncs_patricia_tree_add(&dtms_cb->comm_sock_tree, &node->pat_comm_socket);
		if (rc != NCSCC_RC_SUCCESS) {
			TRACE("DTM:ncs_patricia_tree_add for node_id  FAILED for :%d :%u", node->comm_socket, rc);
			node->pat_comm_socket.key_info = NULL;
			goto done;
		}
		break;

	case 2:
		TRACE("DTM:Adding node_ip to the patricia tree with node_ip :%s as key", node->node_ip);
		node->pat_ip_address.key_info = (uns8 *)&(node->node_ip);
		rc = ncs_patricia_tree_add(&dtms_cb->ip_addr_tree, &node->pat_ip_address);
		if (rc != NCSCC_RC_SUCCESS) {
			TRACE("DTM:ncs_patricia_tree_add for node_id  FAILED for :%s :%u", node->node_ip, rc);
			node->pat_comm_socket.key_info = NULL;
			goto done;
		}
		break;

	default:
		TRACE("DTM:Invalid Patricia add");
		rc = NCSCC_RC_FAILURE;
		goto done;
	}

 done:
	TRACE_LEAVE2("rc : %d", rc);
	return rc;
}
Esempio n. 28
0
/****************************************************************************
 * Name          : gld_mds_glnd_down
 *
 * Description   : MDS indicated that a glnd has gone down
 *
 * Arguments     : evt  - Event structure
 *
 * Return Values : NCSCC_RC_SUCCESS/ NCSCC_RC_FAILURE
 *
 * Notes         : None.
 *****************************************************************************/
static uint32_t gld_mds_glnd_down(GLSV_GLD_EVT *evt)
{
	GLSV_GLD_CB *gld_cb = evt->gld_cb;
	GLSV_GLD_GLND_DETAILS *node_details = NULL;
	GLSV_GLD_RSC_INFO *rsc_info;
	uint32_t node_id;
	uint32_t rc = NCSCC_RC_FAILURE;
	TRACE_ENTER2("mds identification %u",gld_cb->my_dest_id );

	node_id = m_NCS_NODE_ID_FROM_MDS_DEST(evt->info.glnd_mds_info.mds_dest_id);

	if ((evt == GLSV_GLD_EVT_NULL) || (gld_cb == NULL))
		goto end;

	memcpy(&evt->fr_dest_id, &evt->info.glnd_mds_info.mds_dest_id, sizeof(MDS_DEST)
	    );

	if ((node_details = (GLSV_GLD_GLND_DETAILS *)ncs_patricia_tree_get(&gld_cb->glnd_details,
									   (uint8_t *)&node_id)) == NULL) {
		TRACE_1("Resource details is empty for glnd on node_id %u ", node_id);
		rc = NCSCC_RC_SUCCESS;
		goto end;
	}
	node_details->status = GLND_RESTART_STATE;

	TRACE("EVT Processing MDS GLND DOWN: node_id %u", node_details->node_id);
	memcpy(&node_details->restart_timer.mdest_id, &node_details->dest_id, sizeof(MDS_DEST));

	/* Start GLSV_GLD_GLND_RESTART_TIMEOUT timer */
	gld_start_tmr(gld_cb, &node_details->restart_timer, GLD_TMR_NODE_RESTART_TIMEOUT, GLD_NODE_RESTART_TIMEOUT, 0);

	/* Check whether this node is master for any resource, if yes send the status to all
	   the
	   non master nodes */
	if (gld_cb->ha_state == SA_AMF_HA_ACTIVE) {
		/* Check whether this node is master for any resource, if yes send the status to all the non master nodes */
		rsc_info = gld_cb->rsc_info;
		while (rsc_info != NULL) {
			if (rsc_info->node_list) {
				if (rsc_info->node_list->node_id == node_details->node_id)
					gld_snd_master_status(gld_cb, rsc_info, GLND_RESOURCE_MASTER_RESTARTED);
			}
			rsc_info = rsc_info->next;
		}

		/* If this node is non master for any resource, then send node status to the master */
		gld_process_send_non_master_status(gld_cb, node_details, GLND_RESTART_STATE);

	}
 end:
	TRACE_LEAVE2("Return value: %u", rc);
	return rc;
}
Esempio n. 29
0
void ncs_mbcsv_tmr_expiry(void *uarg)
{
	NCS_MBCSV_TMR *tmr;
	PEER_INST *peer;
	uint8_t type;
	MBCSV_EVT *mbc_evt;	/* MBCSV event to be posted */

	if (NULL == (mbc_evt = m_MMGR_ALLOC_MBCSV_EVT)) {
		TRACE_LEAVE2("malloc failed");
		return;
	}

	/* Extract timer expiration info from uarg. */
	tmr = (NCS_MBCSV_TMR *)uarg;
	peer = (PEER_INST *)tmr->xdb;
	type = tmr->type;

	/* Clean up timer. */
	TRACE("Timer expired. my role:%u, svc_id:%u, pwe_hdl:%u, peer_anchor:%" PRIu64 ", tmr type:%s",
				peer->my_ckpt_inst->my_role,
				peer->my_ckpt_inst->my_mbcsv_inst->svc_id,
				peer->my_ckpt_inst->pwe_hdl, peer->peer_anchor,
				tmr_type_str[type]);

	m_SET_NCS_MBCSV_TMR_INACTIVE(peer, type);
	m_SET_NCS_MBCSV_TMR_EXP_ON(peer, type);	/* expired and valid at action routine */

	mbc_evt->msg_type = MBCSV_EVT_TMR;
	mbc_evt->info.tmr_evt.type = type;
	mbc_evt->info.tmr_evt.peer_inst_hdl = peer->hdl;

	/* Post the timer event to the ncs_mbcsv process. */
	if (NCSCC_RC_SUCCESS != m_MBCSV_SND_MSG(&peer->my_ckpt_inst->my_mbcsv_inst->mbx,
						mbc_evt, NCS_IPC_PRIORITY_HIGH)) {
		m_MMGR_FREE_MBCSV_EVT(mbc_evt);
		TRACE_LEAVE2("ipc send (to mailbox) failed ");
		return;
	}
}
Esempio n. 30
0
uint32_t cpa_mds_register(CPA_CB *cb)
{
	NCSMDS_INFO svc_info;
	MDS_SVC_ID subs_id[2] = { NCSMDS_SVC_ID_CPND, NCSMDS_SVC_ID_CPD };
	uint32_t rc = NCSCC_RC_SUCCESS;
	
	TRACE_ENTER();
	/* STEP1: Get the MDS Handle */
	if (cpa_mds_get_handle(cb) != NCSCC_RC_SUCCESS)
		return NCSCC_RC_FAILURE;

	/* memset the svc_info */
	memset(&svc_info, 0, sizeof(NCSMDS_INFO));

	/* STEP 2 : Install on ADEST with MDS with service ID NCSMDS_SVC_ID_CPA. */
	svc_info.i_mds_hdl = cb->cpa_mds_hdl;
	svc_info.i_svc_id = NCSMDS_SVC_ID_CPA;
	svc_info.i_op = MDS_INSTALL;

	svc_info.info.svc_install.i_yr_svc_hdl = cb->agent_handle_id;
	svc_info.info.svc_install.i_install_scope = NCSMDS_SCOPE_NONE;	/* node specific */
	svc_info.info.svc_install.i_svc_cb = cpa_mds_callback;	/* callback */
	svc_info.info.svc_install.i_mds_q_ownership = false;	/* CPA owns the mds queue */
	svc_info.info.svc_install.i_mds_svc_pvt_ver = CPA_MDS_PVT_SUBPART_VERSION;	/* Private Subpart Version of CPA for Versioning infrastructure */

	if ((rc = ncsmds_api(&svc_info)) != NCSCC_RC_SUCCESS) {
		TRACE_4("CPA MDS:INSTALL failed with return value:%d",rc);
		return rc;
	}
	cb->cpa_mds_dest = svc_info.info.svc_install.o_dest;

	/* STEP 3: Subscribe to CPND up/down events */
	svc_info.i_op = MDS_SUBSCRIBE;
	svc_info.info.svc_subscribe.i_num_svcs = 1;
	svc_info.info.svc_subscribe.i_scope = NCSMDS_SCOPE_NONE;
	svc_info.info.svc_subscribe.i_svc_ids = &subs_id[0];

	if ((rc = ncsmds_api(&svc_info)) != NCSCC_RC_SUCCESS) {
		TRACE_4("CPA MDS:SUBSCRIBE failed with return value:%d",rc);
		goto error;
	}

	return NCSCC_RC_SUCCESS;

 error:
	/* Uninstall with the mds */
	cpa_mds_unregister(cb);
	
	TRACE_LEAVE2("retval = %u", rc);
	return NCSCC_RC_FAILURE;
}