{
Buffer *mBuf = NULLP;
Pst pst;
+
+ if(vnfDb.pnfStateAtVnf != PNF_STATE_RUNNING)
+ {
+ if (ODU_GET_MSG_BUF(MAC_MEM_REGION, MAC_POOL, &mBuf) != ROK)
+ {
+ DU_LOG("\nERROR --> NFAPI_VNF : Memory allocation failed in packPnfConfigReq");
+ return RFAILED;
+ }
+ nfapiFillP5Hdr(mBuf);
+ nfapiFillMsgHdr(mBuf, NFAPI_P5_PHY_ID, TAG_NFAPI_PNF_CONFIG_REQ, 0);
+ CMCHKPK(oduPackPostUInt8, 0, mBuf);
- if (ODU_GET_MSG_BUF(MAC_MEM_REGION, MAC_POOL, &mBuf) != ROK)
+ DU_LOG("\nINFO --> NFAPI_VNF: Sending config request");
+ FILL_PST_LWR_MAC_TO_DUAPP(pst, EVENT_PNF_DATA);
+ return ODU_POST_TASK(&pst, mBuf);
+ }
+ else
{
- DU_LOG("\nERROR --> NFAPI_VNF : Memory allocation failed in packPnfConfigReq");
- return RFAILED;
+ TriggerPnfReconfigureProcedure();
}
- nfapiFillP5Hdr(mBuf);
- nfapiFillMsgHdr(mBuf, NFAPI_P5_PHY_ID, TAG_NFAPI_PNF_CONFIG_REQ, 0);
- CMCHKPK(oduPackPostUInt8, 0, mBuf);
-
- DU_LOG("\nINFO --> NFAPI_VNF: Sending config request");
- FILL_PST_LWR_MAC_TO_DUAPP(pst, EVENT_PNF_DATA);
- return ODU_POST_TASK(&pst, mBuf);
+ return ROK;
}
/*******************************************************************
DU_LOG("\nERROR --> NFAPI_VNF: Config response error code is not okay, errCode:%d", errCode);
return RFAILED;
}
+ sendEventToNfapiVnfFsm(PNF_START_REQ, NULLP, NULLP, NULLP);
return ROK;
}
+/*******************************************************************
+ *
+ * @brief Processes NFAPI PNF_START_REQ from PNF
+ *
+ * @details
+ *
+ * Function : nfapi_vnf_procPnfStartReqEvt
+ *
+ * Functionality:
+ * - Builds and Sends PNF_START_REQ(Ref: SCF 225, Sec 3.1.5)
+ *
+ * @params[in]
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+
uint8_t nfapi_vnf_procPnfStartReqEvt(nFapi_p5_hdr *p5Hdr, nFapi_msg_header *msgHdr, void *msg)
{
+ Buffer *mBuf = NULLP;
+ Pst pst;
+
+ if(vnfDb.pnfStateAtVnf != PNF_STATE_RUNNING)
+ {
+ DU_LOG("\nINFO --> NFAPI_VNF: Building the Pnf start request");
+ if (ODU_GET_MSG_BUF(MAC_MEM_REGION, MAC_POOL, &mBuf) != ROK)
+ {
+ DU_LOG("\nERROR --> NFAPI_VNF : Memory allocation failed in packPnfStartReq");
+ return RFAILED;
+ }
+ nfapiFillP5Hdr(mBuf);
+ nfapiFillMsgHdr(mBuf, NFAPI_P5_PHY_ID, TAG_NFAPI_PNF_START_REQ, 0);
+ FILL_PST_LWR_MAC_TO_DUAPP(pst, EVENT_PNF_DATA);
+ return ODU_POST_TASK(&pst, mBuf);
+ }
+ else
+ {
+ TriggerPnfRestartProcedure();
+ }
return ROK;
}
+/*******************************************************************
+ *
+ * @brief Processes NFAPI PNF_START_RSP from PNF
+ *
+ * @details
+ *
+ * Function : nfapi_vnf_procPnfStartRespEvt
+ *
+ * Functionality:
+ * - Processes PNF_START_RSP(Ref: SCF 225, Sec 3.1.6)
+ * if start response received from PNF Restart procedure
+ * then set pnfToRestart as complete.
+ * if start response received from PNF Reconfigure procedure
+ * then set pnfToReconfigure as complete.
+ *
+ *
+ * @params[in]
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+
uint8_t nfapi_vnf_procPnfStartRespEvt(nFapi_p5_hdr *p5Hdr, nFapi_msg_header *msgHdr, void *msg)
{
+ uint8_t errCode = 0;
+ DU_LOG("\nINFO --> NFAPI_VNF: Received EVENT[%d] at STATE[%d]",\
+ vnfDb.pnfEvent, vnfDb.pnfStateAtVnf);
+
+ CMCHKPK(oduUnpackUInt8, &(errCode), msg);
+
+ if(errCode == NFAPI_MSG_OK)
+ {
+ vnfDb.pnfStateAtVnf=PNF_STATE_RUNNING;
+ if(vnfDb.pnfToRestart == true)
+ {
+ vnfDb.pnfToRestart =false;
+ }
+ else if(vnfDb.pnfToReconfigure == true)
+ {
+ vnfDb.pnfToReconfigure = false;
+ }
+ }
+ else
+ {
+ DU_LOG("\nERROR --> NFAPI_VNF: Start response error code is not okay, errCode:%d", errCode);
+ return RFAILED;
+ }
return ROK;
}
+/*******************************************************************
+ *
+ * @brief Processes NFAPI PNF_STOP_REQ from PNF
+ *
+ * @details
+ *
+ * Function : nfapi_vnf_procPnfStopReqEvt
+ *
+ * Functionality:
+ * - Builds and Sends PNF_STOP_REQ(Ref: SCF 225, Sec 3.1.7)
+ *
+ * @params[in]
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+
uint8_t nfapi_vnf_procPnfStopReqEvt(nFapi_p5_hdr *p5Hdr, nFapi_msg_header *msgHdr, void *msg)
{
- return ROK;
+ Buffer *mBuf = NULLP;
+ Pst pst;
+
+ DU_LOG("\nINFO --> NFAPI_VNF: Building the Pnf stop request");
+ if (ODU_GET_MSG_BUF(MAC_MEM_REGION, MAC_POOL, &mBuf) != ROK)
+ {
+ DU_LOG("\nERROR --> NFAPI_VNF : Memory allocation failed in packPnfStopReq");
+ return RFAILED;
+ }
+ nfapiFillP5Hdr(mBuf);
+ nfapiFillMsgHdr(mBuf, NFAPI_P5_PHY_ID, TAG_NFAPI_PNF_STOP_REQ, 0);
+ FILL_PST_LWR_MAC_TO_DUAPP(pst, EVENT_PNF_DATA);
+ return ODU_POST_TASK(&pst, mBuf);
}
+/*******************************************************************
+ *
+ * @brief Processes NFAPI PNF_STOP_RSP from PNF
+ *
+ * @details
+ *
+ * Function : nfapi_vnf_procPnfStopRespEvt
+ *
+ * Functionality:
+ * - Processes PNF_STOP_RSP(Ref: SCF 225, Sec 3.1.8, 2.1.1.3
+ * and 2.1.1.4)
+ * - If stop response received as part of Restart procedure
+ * then send PNF_START request.
+ * - If stop response received as part of PNF Reconfigure procedure
+ * then send PNF_CONFIG request.
+ *
+ *
+ * @params[in]
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
uint8_t nfapi_vnf_procPnfStopRespEvt(nFapi_p5_hdr *p5Hdr, nFapi_msg_header *msgHdr, void *msg)
{
+ uint8_t errCode = 0;
+ DU_LOG("\nINFO --> NFAPI_VNF: Received EVENT[%d] at STATE[%d]",\
+ vnfDb.pnfEvent, vnfDb.pnfStateAtVnf);
+
+ CMCHKPK(oduUnpackUInt8, &(errCode), msg);
+
+ if(errCode == NFAPI_MSG_OK)
+ {
+ vnfDb.pnfStateAtVnf=PNF_STATE_CONFIGURED;
+ DU_LOG("\nINFO --> NFAPI_VNF: PNF STATE[%d]",vnfDb.pnfStateAtVnf);
+ }
+ else
+ {
+ DU_LOG("\nERROR --> NFAPI_VNF: Stop response error code is not okay, errCode:%d", errCode);
+ return RFAILED;
+ }
+
+ if(vnfDb.pnfToRestart == true)
+ {
+ sendEventToNfapiVnfFsm(PNF_START_REQ, NULLP, NULLP, NULLP);
+ }
+ else if(vnfDb.pnfToReconfigure == true)
+ {
+ sendEventToNfapiVnfFsm(PNF_CONFIG_REQ, NULLP, NULLP, NULLP);
+ }
+
+ return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief Build and send PNF Restart procedure
+ *
+ * @details
+ *
+ * Function : TriggerPnfRestartProcedure
+ *
+ * Functionality:
+ * - Build and send PNF Restart procedure as per 2.1.1.3
+ *
+ * @params[in]
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t TriggerPnfRestartProcedure()
+{
+ DU_LOG("\nINFO --> NFAPI_VNF: Build and send PNF Restart procedure");
+
+ vnfDb.pnfToRestart = true;
+ sendEventToNfapiVnfFsm(PNF_STOP_REQ, NULLP, NULLP, NULLP);
return ROK;
}
+
+/*******************************************************************
+ *
+ * @brief Build and send PNF Reconfigured procedure
+ *
+ * @details
+ *
+ * Function : TriggerPnfReconfigureProcedure
+ *
+ * Functionality:
+ * - Build and send PNF Reconfigured procedure as per 2.1.1.3
+ * - If PNF state is running then send PNF_STOP_REQ
+ * - If PNF state is not running then send PNF_CONFIG_REQ
+ *
+ * @params[in]
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t TriggerPnfReconfigureProcedure()
+{
+ DU_LOG("\nINFO --> NFAPI_VNF: Build and send PNF Recfg procedure");
+
+ vnfDb.pnfToReconfigure = true;
+ sendEventToNfapiVnfFsm(PNF_STOP_REQ, NULLP, NULLP, NULLP);
+ return ROK;
+}
/*******************************************************************
*
* @brief Handles Invalid Request Event
nfapi_vnf_procPnfConfigReqEvt, /*PNF_CONFIG_REQ*/
nfapi_vnf_procPnfConfigRespEvt, /*PNF_CONFIG_RESP*/
nfapi_vnf_procInvalidEvt, /*PNF_START_REQ*/
- nfapi_vnf_procPnfStartRespEvt, /*PNF_START_RESP*/
+ nfapi_vnf_procInvalidEvt, /*PNF_START_RESP*/
nfapi_vnf_procInvalidEvt, /*PNF_STOP_REQ*/
- nfapi_vnf_procPnfStopRespEvt, /*PNF_STOP_RESP*/
+ nfapi_vnf_procInvalidEvt, /*PNF_STOP_RESP*/
},
{
/* PNF_STATE_CONFIGURED */
nfapi_vnf_procInvalidEvt, /*PNF_READY_IND*/
- nfapi_vnf_procPnfParamReqEvt, /*PNF_PARAM_REQ*/
- nfapi_vnf_procPnfParamRespEvt, /*PNF_PARAM_RESP*/
+ nfapi_vnf_procInvalidEvt, /*PNF_PARAM_REQ*/
+ nfapi_vnf_procInvalidEvt, /*PNF_PARAM_RESP*/
nfapi_vnf_procPnfConfigReqEvt, /*PNF_CONFIG_REQ*/
nfapi_vnf_procPnfConfigRespEvt, /*PNF_CONFIG_RESP*/
nfapi_vnf_procPnfStartReqEvt, /*PNF_START_REQ*/
nfapi_vnf_procPnfStartRespEvt, /*PNF_START_RESP*/
nfapi_vnf_procInvalidEvt, /*PNF_STOP_REQ*/
- nfapi_vnf_procPnfStopRespEvt, /*PNF_STOP_RESP*/
+ nfapi_vnf_procInvalidEvt, /*PNF_STOP_RESP*/
},
{
/* PNF_STATE_RUNNING */
nfapi_vnf_procInvalidEvt, /*PNF_READY_IND*/
nfapi_vnf_procInvalidEvt, /*PNF_PARAM_REQ*/
- nfapi_vnf_procPnfParamRespEvt, /*PNF_PARAM_RESP*/
+ nfapi_vnf_procInvalidEvt, /*PNF_PARAM_RESP*/
nfapi_vnf_procPnfConfigReqEvt, /*PNF_CONFIG_REQ*/
- nfapi_vnf_procPnfConfigRespEvt, /*PNF_CONFIG_RESP*/
- nfapi_vnf_procInvalidEvt, /*PNF_START_REQ*/
- nfapi_vnf_procPnfStartRespEvt, /*PNF_START_RESP*/
+ nfapi_vnf_procInvalidEvt, /*PNF_CONFIG_RESP*/
+ nfapi_vnf_procPnfStartReqEvt, /*PNF_START_REQ*/
+ nfapi_vnf_procInvalidEvt, /*PNF_START_RESP*/
nfapi_vnf_procPnfStopReqEvt, /*PNF_STOP_REQ*/
nfapi_vnf_procPnfStopRespEvt, /*PNF_STOP_RESP*/
}
uint32_t ipv4_vnf = 0, ipv4_pnf = 0;
DU_LOG("\nDEBUG --> PNF_STUB : Reading PNF P5 configurations");
-
+
+ pnfCb.pnfCfgParams.pnfState=PNF_IDLE;
pnfCb.pnfCfgParams.pnfId = PNF_ID;
strcpy(pnfCb.pnfCfgParams.pnfName, PNF_NAME);
uint8_t ret = ROK;
Buffer *mBuf = NULLP;
- if (ODU_GET_MSG_BUF(PNF_APP_MEM_REG, PNF_POOL, &mBuf) != ROK)
+ DU_LOG("\nINFO --> NFAPI_PNF: Building PNF_CONFIG_RSP");
+ pnfCb.pnfCfgParams.pnfState=PNF_CONFIGURED;
+
+ if(ODU_GET_MSG_BUF(PNF_APP_MEM_REG, PNF_POOL, &mBuf) != ROK)
{
DU_LOG("\nERROR --> NFAPI_PNF : Memory allocation failed in pnf config rsp");
return RFAILED;
return ret;
}
+/*********************************************************************************
+ *
+ * @Function Name: buildAndSendPnfStartResp
+ *
+ *
+ * @Functionality:
+ * Builds and Sends PNF_START_RSP(Ref: SCF 225, Sec 3.1.6)
+ *
+ *
+ * *******************************************************************************/
+uint8_t buildAndSendPnfStartResp()
+{
+ uint8_t ret = ROK;
+ Buffer *mBuf = NULLP;
+
+ DU_LOG("\nINFO --> NFAPI_PNF: Building PNF_START_RSP");
+ pnfCb.pnfCfgParams.pnfState=PNF_RUNNING;
+
+ if(ODU_GET_MSG_BUF(PNF_APP_MEM_REG, PNF_POOL, &mBuf) != ROK)
+ {
+ DU_LOG("\nERROR --> NFAPI_PNF : Memory allocation failed in pnf start rsp");
+ return RFAILED;
+ }
+ nfapiFillP5Hdr(mBuf);
+ nfapiFillMsgHdr(mBuf, 0, TAG_NFAPI_PNF_START_RESP, 0);
+ CMCHKPK(oduPackPostUInt32, 0, mBuf); //Error Code
+ ret = pnfP5SctpSend(mBuf);
+ if(ret == RFAILED)
+ {
+ ODU_PUT_MSG_BUF(mBuf);
+ }
+ return ret;
+}
+
+/*********************************************************************************
+ *
+ * @Function Name: buildAndSendPnfStopResp
+ *
+ *
+ * @Functionality:
+ * Builds and Sends PNF_STOP_RSP(Ref: SCF 225, Sec 3.1.8)
+ *
+ *
+ * *******************************************************************************/
+uint8_t buildAndSendPnfStopResp()
+{
+ uint8_t ret = ROK;
+ Buffer *mBuf = NULLP;
+
+ DU_LOG("\nINFO --> NFAPI_PNF: Building PNF_STOP_RSP");
+ pnfCb.pnfCfgParams.pnfState=PNF_CONFIGURED;
+
+ if(ODU_GET_MSG_BUF(PNF_APP_MEM_REG, PNF_POOL, &mBuf) != ROK)
+ {
+ DU_LOG("\nERROR --> NFAPI_PNF : Memory allocation failed in pnf stop rsp");
+ return RFAILED;
+ }
+ nfapiFillP5Hdr(mBuf);
+ nfapiFillMsgHdr(mBuf, 0, TAG_NFAPI_PNF_STOP_RESP, 0);
+ CMCHKPK(oduPackPostUInt32, 0, mBuf); //Error Code
+ ret = pnfP5SctpSend(mBuf);
+ if(ret == RFAILED)
+ {
+ ODU_PUT_MSG_BUF(mBuf);
+ }
+ return ret;
+}
+
/*********************************************************************************
*
* @Function Name: p5MsgHandlerAtPnf
ret = buildAndSendPnfConfigResp();
break;
}
+ case TAG_NFAPI_PNF_START_REQ:
+ {
+ DU_LOG("\nINFO --> NFAPI_PNF: PNF_START_REQ recevied.");
+ ret = buildAndSendPnfStartResp();
+ break;
+ }
+ case TAG_NFAPI_PNF_STOP_REQ:
+ {
+ DU_LOG("\nINFO --> NFAPI_PNF: PNF_STOP_REQ recevied.");
+ ret = buildAndSendPnfStopResp();
+ break;
+ }
default:
{
DU_LOG("\nERROR --> NFAPI_PNF: Wrong MSGID of NFAPI P5 Message:%d",msgHdr.msg_id);