From: pborla Date: Thu, 16 May 2024 19:15:32 +0000 (+0530) Subject: [Epic-Id: ODUHIGH-576] [Task-Id: ODUHIGH-586] [SubTask-Id: ODUHIGH-599]| [NFAPI_BRANC... X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=75cc4afe2a1db2d18bffc51526c006a2879f1bc6;p=o-du%2Fl2.git [Epic-Id: ODUHIGH-576] [Task-Id: ODUHIGH-586] [SubTask-Id: ODUHIGH-599]| [NFAPI_BRANCH] | Implementation of start req-rsp, stop req-rsp, pnf restart and pnf reconfig procedure2 Change-Id: If1daa5c1d07e761994bcd9d22503381f421daea9 Signed-off-by: pborla --- diff --git a/src/5gnrmac/nfapi_vnf_fsm.c b/src/5gnrmac/nfapi_vnf_fsm.c index bb4c09214..d63ed4b84 100644 --- a/src/5gnrmac/nfapi_vnf_fsm.c +++ b/src/5gnrmac/nfapi_vnf_fsm.c @@ -186,19 +186,27 @@ uint8_t nfapi_vnf_procPnfConfigReqEvt(nFapi_p5_hdr *p5Hdr, nFapi_msg_header *msg { 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; } /******************************************************************* @@ -237,29 +245,241 @@ uint8_t nfapi_vnf_procPnfConfigRespEvt(nFapi_p5_hdr *p5Hdr, nFapi_msg_header *ms 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 @@ -296,31 +516,31 @@ nFapiVnfFsmHdlr nFapiEvtHdlr[PNF_MAX_STATE][PNF_MAX_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*/ } diff --git a/src/5gnrmac/nfapi_vnf_fsm.h b/src/5gnrmac/nfapi_vnf_fsm.h index f72716e0d..48002df7e 100644 --- a/src/5gnrmac/nfapi_vnf_fsm.h +++ b/src/5gnrmac/nfapi_vnf_fsm.h @@ -101,6 +101,8 @@ typedef struct nfapiP5Info typedef struct nfapiVnfDb { + bool pnfToRestart; + bool pnfToReconfigure; NfapiPnfState pnfStateAtVnf; NfapiPnfEvent pnfEvent; NfapiP5Info p5Info; @@ -129,5 +131,7 @@ uint8_t nfapi_vnf_procPnfStopReqEvt(nFapi_p5_hdr *p5Hdr, nFapi_msg_header *msgHd uint8_t nfapi_vnf_procPnfStopRespEvt(nFapi_p5_hdr *p5Hdr, nFapi_msg_header *msgHdr, void *msg); uint8_t nfapi_vnf_procInvalidEvt(nFapi_p5_hdr *p5Hdr, nFapi_msg_header *msgHdr, void *msg); - +/*NFAPI Misc procedure*/ +uint8_t TriggerPnfRestartProcedure(); +uint8_t TriggerPnfReconfigureProcedure(); #endif diff --git a/src/pnf_stub/pnf_stub.c b/src/pnf_stub/pnf_stub.c index 0e3299db8..f56a4902a 100644 --- a/src/pnf_stub/pnf_stub.c +++ b/src/pnf_stub/pnf_stub.c @@ -66,7 +66,8 @@ void readPnfCfg() 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); @@ -353,7 +354,10 @@ uint8_t buildAndSendPnfConfigResp() 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; @@ -369,6 +373,74 @@ uint8_t buildAndSendPnfConfigResp() 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 @@ -403,6 +475,18 @@ uint8_t p5MsgHandlerAtPnf(Buffer *mBuf) 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); diff --git a/src/pnf_stub/pnf_stub.h b/src/pnf_stub/pnf_stub.h index 735fa9cb4..e49d7d48d 100644 --- a/src/pnf_stub/pnf_stub.h +++ b/src/pnf_stub/pnf_stub.h @@ -32,8 +32,16 @@ #define PNF_APP_MEM_REG 1 #define PNF_POOL 1 +typedef enum +{ + PNF_IDLE, + PNF_CONFIGURED, + PNF_RUNNING +}PnfState; + typedef struct pnfCfgParams { + PnfState pnfState; uint32_t pnfId; char pnfName[PNF_NAME_LEN_MAX]; PnfP5SctpParams pnfP5SctpParams;