[Epic-Id: ODUHIGH-576] [Task-Id: ODUHIGH-586] [SubTask-Id: ODUHIGH-592]| [NFAPI_BRANC... 11/12911/2
authorpborla <pborla@radisys.com>
Wed, 15 May 2024 09:45:25 +0000 (15:15 +0530)
committerpborla <pborla@radisys.com>
Wed, 15 May 2024 11:45:58 +0000 (17:15 +0530)
Change-Id: I8be0f2cfa37427016cdde9b48bf7742555e86984
Signed-off-by: pborla <pborla@radisys.com>
src/5gnrmac/nfapi_vnf_fsm.c
src/pnf_stub/pnf_stub.c
src/pnf_stub/pnf_stub.h
src/pnf_stub/pnf_stub_sctp.c

index 5587354..bb4c092 100644 (file)
@@ -48,6 +48,8 @@ void nFapiVnfInit()
    vnfDb.pnfEvent      = 0;
 }
 
+
+
 /*******************************************************************
  *
  * @brief Processes NFAPI PNF_READY_IND from PNF
@@ -134,25 +136,107 @@ uint8_t nfapi_vnf_procPnfParamReqEvt(nFapi_p5_hdr *p5Hdr, nFapi_msg_header *msgH
 
 uint8_t nfapi_vnf_procPnfParamRespEvt(nFapi_p5_hdr *p5Hdr, nFapi_msg_header *msgHdr, void *msg)
 {
-   uint8_t errorCode = 1;
-
-   DU_LOG("\nINFO   -->  NFAPI_VNF: Received EVENT[%d] at STATE[%d]",\
-         vnfDb.pnfEvent, vnfDb.pnfStateAtVnf);
-
-   CMCHKPK(oduUnpackUInt8, &(errorCode), msg);
+   uint16_t tag=0, len=0;
+   uint8_t errorCode = 1,idx=0,numtlv=0;
+   nFapi_pnf_param_general paramGeneral;
    
-   DU_LOG("\nINFO   --> NFAPI_VNF: PNF_PARAM_RESP errCode:%d",errorCode);
+   DU_LOG("\nINFO   -->  NFAPI_VNF: Received EVENT[%d] at STATE[%d]",vnfDb.pnfEvent, vnfDb.pnfStateAtVnf);
+   CMCHKPK(oduUnpackUInt8, &(errorCode), msg);
+   if(errorCode != NFAPI_MSG_OK)
+   {
+      DU_LOG("\nERROR   -->  NFAPI_VNF: Param response error code is not okay, errCode:%d", errorCode);
+      return RFAILED;
+   }
 
+   CMCHKPK(oduUnpackUInt8, &(numtlv), msg);
+   CMCHKPK(oduUnpackUInt16, &(tag), msg);
+   CMCHKPK(oduUnpackUInt16, &(len), msg);
+   CMCHKPK(oduUnpackUInt8, &paramGeneral.nFapi_sync_mode, msg);
+   CMCHKPK(oduUnpackUInt8, &paramGeneral.loc_mode, msg);
+   CMCHKPK(oduUnpackUInt16, &paramGeneral.max_num_phy, msg);
+   for(idx =0; idx < 3; idx++)
+   {
+      CMCHKPK(oduUnpackUInt8, &paramGeneral.oui[idx], msg);
+   }
+   CMCHKPK(oduUnpackUInt16, &paramGeneral.numRfInstances, msg);
+   CMCHKPK(oduUnpackUInt16, &paramGeneral.numDfeInstances, msg);
+   
+   DU_LOG("\nINFO   --> NFAPI_VNF: PNF_PARAM_RESP errCode:%d, numtlv:%d",errorCode,numtlv);
+   sendEventToNfapiVnfFsm(PNF_CONFIG_REQ, NULLP, NULLP, NULLP);
    return ROK;
 }
 
+/*******************************************************************
+ *
+ * @brief Processes NFAPI PNF_CONFIG_REQ from PNF
+ *
+ * @details
+ *
+ *    Function : nfapi_vnf_procPnfConfigReqEvt
+ *
+ *    Functionality:
+ *         - Builds and Sends PNF_CONFIG_REQ(Ref: SCF 225, Sec 3.1.3)
+ *
+ * @params[in]
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
 uint8_t nfapi_vnf_procPnfConfigReqEvt(nFapi_p5_hdr *p5Hdr, nFapi_msg_header *msgHdr, void *msg)
 {
-   return ROK;
+   Buffer *mBuf = NULLP;
+   Pst pst;
+
+   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);
+   
+   DU_LOG("\nINFO   -->  NFAPI_VNF: Sending config request");
+   FILL_PST_LWR_MAC_TO_DUAPP(pst, EVENT_PNF_DATA);
+   return ODU_POST_TASK(&pst, mBuf);
 }
 
+/*******************************************************************
+ *
+ * @brief Processes NFAPI PNF_CONFIG_RSP from PNF
+ *
+ * @details
+ *
+ *    Function : nfapi_vnf_procPnfConfigRespEvt
+ *
+ *    Functionality:
+ *         - Processes PNF_CONFIG_RSP(Ref: SCF 225, Sec 3.1.4)
+ *         - Starts the PNF Initalization(Ref: SCF 225, Sec 2.1.1.1)
+ *
+ * @params[in]
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+
 uint8_t nfapi_vnf_procPnfConfigRespEvt(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: Config response error code is not okay, errCode:%d", errCode);
+      return RFAILED;
+   }
    return ROK;
 }
 
index c6f05a5..0e3299d 100644 (file)
@@ -260,15 +260,15 @@ void nFapiExtractMsgHdr(nFapi_msg_header *msgHdr, Buffer *mBuf)
 
 /*********************************************************************************
  *
- * @Function Name: sendPnfReadyInd
+ * @Function Name: buildAndSendPnfReadyInd 
  *
  *
  * @Functionality: 
- *    It Build And Sends the PNF_READY_IND
+ *   Builds and Sends PNF_READY_IND(Ref: SCF 225, Sec 3.1.0)
  *
  *
  * *******************************************************************************/
-uint8_t sendReadyInd()
+uint8_t buildAndSendPnfReadyInd()
 {
    uint8_t ret = ROK;
    Buffer *mBuf = NULLP;
@@ -289,10 +289,25 @@ uint8_t sendReadyInd()
    return ret;
 }
 
+/*********************************************************************************
+ *
+ * @Function Name: buildAndSendPnfParamResp 
+ *
+ * @Functionality: 
+ *    Build Pnf Param rsp as per  5G nFAPI Specification 3.1.2 PNF_PARAM.response 
+ *    And Send to VNF
+ *
+ * *******************************************************************************/
+
 uint8_t buildAndSendPnfParamResp()
 {
-   uint8_t ret = ROK;
+   uint8_t ret = ROK,idx=0, array_size=0;
    Buffer *mBuf = NULLP;
+   nFapi_pnf_param_general paramGeneral;
+
+   memset(&paramGeneral, 0, sizeof(nFapi_pnf_param_general));
+   array_size = sizeof(paramGeneral.loc_coordinates) / sizeof(paramGeneral.loc_coordinates[0]);
+   paramGeneral.max_num_phy=1;
 
    if (ODU_GET_MSG_BUF(PNF_APP_MEM_REG, PNF_POOL, &mBuf) != ROK)
    {
@@ -301,7 +316,51 @@ uint8_t buildAndSendPnfParamResp()
    }
    nfapiFillP5Hdr(mBuf);
    nfapiFillMsgHdr(mBuf, 0, TAG_NFAPI_PNF_PARAM_RESP, 0);
-   CMCHKPK(oduPackPostUInt8, 0, mBuf); //errorCode
+   CMCHKPK(oduPackPostUInt8, 0, mBuf); 
+   CMCHKPK(oduPackPostUInt8, 1, mBuf); 
+   CMCHKPK(oduPackPostUInt16, TAG_NFAPI_PNF_PARAM_GENERAL, mBuf);
+   CMCHKPK(oduPackPostUInt16, sizeof(nFapi_pnf_param_general), mBuf);
+   CMCHKPK(oduPackPostUInt8, paramGeneral.nFapi_sync_mode, mBuf); 
+   CMCHKPK(oduPackPostUInt8, paramGeneral.loc_mode, mBuf);
+   CMCHKPK(oduPackPostUInt16, paramGeneral.max_num_phy, mBuf); 
+   for(idx =0; idx < 3; idx++)
+   {
+      CMCHKPK(oduPackPostUInt8, paramGeneral.oui[idx], mBuf); 
+   }
+   CMCHKPK(oduPackPostUInt16, paramGeneral.numRfInstances, mBuf); 
+   CMCHKPK(oduPackPostUInt16, paramGeneral.numDfeInstances, mBuf); 
+
+   ret = pnfP5SctpSend(mBuf);
+   if(ret == RFAILED)
+   {
+      ODU_PUT_MSG_BUF(mBuf);
+   }
+   return ret;
+}
+
+/*********************************************************************************
+ *
+ * @Function Name: buildAndSendPnfConfigResp
+ *
+ *
+ * @Functionality:
+ *   Builds and Sends PNF_CONFIG_RSP(Ref: SCF 225, Sec 3.1.4)
+ *
+ *
+ * *******************************************************************************/
+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("\nERROR  --> NFAPI_PNF : Memory allocation failed in pnf config rsp");
+      return RFAILED;
+   }
+   nfapiFillP5Hdr(mBuf);
+   nfapiFillMsgHdr(mBuf, 0, TAG_NFAPI_PNF_CONFIG_RESP, 0);
+   CMCHKPK(oduPackPostUInt32, 0, mBuf); //Error Code
    ret = pnfP5SctpSend(mBuf);
    if(ret == RFAILED)
    {
@@ -333,15 +392,26 @@ uint8_t  p5MsgHandlerAtPnf(Buffer *mBuf)
    switch(msgHdr.msg_id)
    {
       case TAG_NFAPI_PNF_PARAM_REQ:
-      {
-         DU_LOG("\nINFO   --> NFAPI_PNF: PNF_PARAM_REQ recevied.");
-         ret = buildAndSendPnfParamResp();
-         break;
-      }
+         {
+            DU_LOG("\nINFO   --> NFAPI_PNF: PNF_PARAM_REQ recevied.");
+            ret = buildAndSendPnfParamResp();
+            break;
+         }
+      case TAG_NFAPI_PNF_CONFIG_REQ:
+         {
+            DU_LOG("\nINFO   --> NFAPI_PNF: PNF_CONFIG_REQ recevied.");
+            ret = buildAndSendPnfConfigResp();
+            break;
+         }
       default:
       {
          DU_LOG("\nERROR  --> NFAPI_PNF: Wrong MSGID of NFAPI P5 Message:%d",msgHdr.msg_id);
       }
    }
+
+   if(ret == RFAILED)
+   {
+      return RFAILED;
+   }
    return ret;
 }
index eedeb93..735fa9c 100644 (file)
@@ -47,7 +47,7 @@ typedef struct pnfGlobalCb
 }PnfGlobalCb;
 
 extern PnfGlobalCb pnfCb;
-uint8_t sendReadyInd();
+uint8_t buildAndSendPnfReadyInd();
+uint8_t buildAndSendPnfConfigRsp();
 uint8_t p5MsgHandlerAtPnf(Buffer *mBuf);
-
 #endif
index ee3bf29..27950e7 100644 (file)
@@ -194,7 +194,7 @@ uint8_t pnfP5SctpStartReq()
 
    /*Since Socket is UP and Client(VNF) has responded with CONNECT thus
     * initating PNF_READY_IND as part of PNF INITIALIZATION msg*/
-   ret = sendReadyInd();
+   ret = buildAndSendPnfReadyInd();
    if(ret == ROK)
    {
       if(pnfP5SctpSockPoll() != ROK)