[Epic-Id: ODUHIGH-576][Task-Id: ODUHIGH-594][SubTask-Id: ODUHIGH-598]|[NFAPI_Branch... 12/12912/5
authorsvaidhya <svaidhya@radisys.com>
Thu, 16 May 2024 05:22:51 +0000 (10:52 +0530)
committersvaidhya <svaidhya@radisys.com>
Wed, 22 May 2024 07:27:37 +0000 (12:57 +0530)
Change-Id: Ieabeb69ea6cb92b4630552258cb86279cd51f727
Signed-off-by: svaidhya <svaidhya@radisys.com>
25 files changed:
build/config/fdd_odu_config.xml
build/config/tdd_odu_config.xml
src/5gnrmac/lwr_mac_ex_ms.c
src/5gnrmac/nfapi_common.c
src/5gnrmac/nfapi_common.h
src/5gnrmac/nfapi_udp_p7.c
src/5gnrmac/nfapi_udp_p7.h [new file with mode: 0644]
src/5gnrmac/nfapi_vnf_fsm.c
src/5gnrmac/nfapi_vnf_fsm.h
src/5gnrmac/rg_lmm.c
src/cm/du_app_p7udp_inf.c [new file with mode: 0644]
src/cm/du_app_p7udp_inf.h [new file with mode: 0644]
src/cm/ssi.h
src/du_app/du_cfg.c
src/du_app/du_cfg.h
src/du_app/du_mgr_main.c
src/du_app/du_msg_hdl.c
src/du_app/du_msg_hdl.h
src/du_app/du_utils.h
src/phy_stub/phy_stub_msg_hdl.c
src/pnf_stub/pnf_stub.c
src/pnf_stub/pnf_stub.h
src/pnf_stub/pnf_stub_p7_udp.c [new file with mode: 0644]
src/pnf_stub/pnf_stub_p7_udp.h [new file with mode: 0644]
src/pnf_stub/pnf_stub_sctp.c

index 0732b03..fa9a6f4 100644 (file)
       <DEST_F1_EGTP_PORT>2152</DEST_F1_EGTP_PORT>
       <MIN_TEID>1</MIN_TEID>
    </EGTP>
+   <P7_UDP>
+      <VNF_P7_UDP_PORT>6789</VNF_P7_UDP_PORT>
+      <PNF_P7_UDP_PORT>9876</PNF_P7_UDP_PORT>
+   </P7_UDP>
    <SIB1_PARAMS>
       <PLMN>
          <MCC>
index 798e7bc..a2cfab8 100644 (file)
       <DEST_F1_EGTP_PORT>2152</DEST_F1_EGTP_PORT>
       <MIN_TEID>1</MIN_TEID>
    </EGTP>
+   <P7_UDP>
+      <VNF_P7_UDP_PORT>6789</VNF_P7_UDP_PORT>
+      <PNF_P7_UDP_PORT>9876</PNF_P7_UDP_PORT>
+   </P7_UDP>
    <SIB1_PARAMS>
       <PLMN>
          <MCC>
index 4f28672..41077f5 100644 (file)
@@ -283,6 +283,7 @@ uint8_t lwrMacActvTsk(Pst *pst, Buffer *mBuf)
                       return RFAILED;\r
                    }\r
                    sendEventToNfapiVnfFsm(msgType, &p5Hdr, &msgHdr, mBuf);\r
+                   ODU_PUT_MSG_BUF(mBuf);\r
                    break;\r
                }\r
 #endif\r
index 39dcedf..1330837 100644 (file)
@@ -22,8 +22,8 @@
 #include "common_def.h"
 #include "mac_utils.h"
 #include "lwr_mac.h"
-#include "nfapi_vnf_fsm.h"
 #include "nfapi_interface.h"
+#include "nfapi_vnf_fsm.h"
 #include "nfapi_common.h"
 
 /*********************************************************************************
index 0cb816c..22f843c 100644 (file)
 
 #define NFAPI_MORE_SEG_NUM(_moreField, _segStart) ((_moreField << 7) | (_segStart & 0x07))
 
+#define NFAPI_UDP_P7_MEM_REGION   5
+#define NFAPI_UDP_P7_POOL         1
+#define NFAPI_UDP_P7_INST         0
+#define NFAPI_UDP_P7_PROC         0
+#define EVTSTARTNFAPIP7POLL       2
+
+#ifdef ODU_MEMORY_DEBUG_LOG
+#define NFAPI_UDP_P7_MEM_LOG(_macro, _file, _line, _func, _size, _datPtr)\
+{\
+   printf("\n%s,=== %s +%d, %s, %lu, %p \n",           \
+         _macro, _file, _line, _func, (uint64_t)_size, _datPtr); \
+}
+#else
+#define NFAPI_UDP_P7_MEM_LOG(_macro, _file, _line, _func, _size, _dataPtr) {}
+#endif
+
+/* allocate and zero out a NFAPI_UDP_P7 static buffer */
+#define NFAPI_UDP_P7_ALLOC(_datPtr, _size)                            \
+{                                                            \
+   uint8_t _ret;                                             \
+   _ret = SGetSBuf(NFAPI_UDP_P7_MEM_REGION, NFAPI_UDP_P7_POOL,                 \
+        (Data **)&_datPtr, _size);                               \
+   if(_ret == ROK)                                           \
+   {                                                         \
+      memset(_datPtr, 0, _size);                             \
+      NFAPI_UDP_P7_MEM_LOG("NFAPI_UDP_P7,ALLOC", __FILE__, __LINE__, __FUNCTION__, _size, _datPtr);\
+   }                                                         \
+   else                                                      \
+   {                                                         \
+      _datPtr = NULLP;                                       \
+   }                                                         \
+}
+
+/* free a static buffer */
+#define NFAPI_UDP_P7_FREE(_datPtr, _size)                             \
+{                                                            \
+   if(_datPtr)                                               \
+   {                                                         \
+      NFAPI_UDP_P7_MEM_LOG("NFAPI_UDP_P7,FREE", __FILE__, __LINE__, __FUNCTION__, _size, _datPtr);\
+      SPutSBuf(NFAPI_UDP_P7_MEM_REGION, NFAPI_UDP_P7_POOL,                     \
+           (Data *)_datPtr, _size);                              \
+      _datPtr = NULLP;                                       \
+   }                                                         \
+}
+
+/* Allocate shared memory to be used for LWLC
+ * during inter-layer communication */
+#define NFAPI_UDP_P7_ALLOC_SHRABL_BUF(_buf, _size)                    \
+{                                                            \
+   if(SGetStaticBuffer(NFAPI_UDP_P7_MEM_REGION, NFAPI_UDP_P7_POOL,             \
+           (Data **)&_buf, (Size) _size, 0) == ROK)              \
+   {                                                         \
+      NFAPI_UDP_P7_MEM_LOG("NFAPI_UDP_P7,ALLOC_SHRABL_BUF", __FILE__, __LINE__, __FUNCTION__, _size, _buf);\
+      memset((_buf), 0, _size);                              \
+   }                                                         \
+   else                                                      \
+   {                                                         \
+      (_buf) = NULLP;                                        \
+   }                                                         \
+}
+
+/* Free shared memory, received through LWLC */
+#define NFAPI_UDP_P7_FREE_SHRABL_BUF(_region, _pool,_buf, _size)      \
+{                                                            \
+   if (_buf != NULLP)                                        \
+   {                                                         \
+      NFAPI_UDP_P7_MEM_LOG("NFAPI_UDP_P7,FREE_SHRABL_BUF", __FILE__, __LINE__, __FUNCTION__, _size, _buf);\
+      (Void) SPutStaticBuffer(_region, _pool,                \
+           (Data *) _buf, (Size) _size, 0);                 \
+      _buf = NULLP;                                          \
+   }                                                         \
+}
+
+
 /*Common Functions*/
 void nfapiFillP5Hdr(Buffer *mBuf);
 void nfapiFillMsgHdr(Buffer *mBuf, uint8_t phyId, uint16_t msgId, uint32_t msglen);
@@ -39,4 +113,6 @@ void nFapiExtractP5Hdr(nFapi_p5_hdr *p5Hdr, Buffer *mBuf);
 void nFapiExtractMsgHdr(nFapi_msg_header *msgHdr, Buffer *mBuf);
 
 NfapiPnfEvent convertNfapiP5TagValToMsgId(uint16_t tagVal);
+uint8_t nfapiP7UdpRecvMsg();
+
 #endif
index 13c6b30..b3f93ed 100644 (file)
 /* This file is the entry point for UDP P7 */
 
 #include "common_def.h"
+#include "du_app_p7udp_inf.h"
+#include "nfapi_interface.h"
+#include "nfapi_vnf_fsm.h"
+#include "nfapi_common.h"
 
 /**************************************************************************
  * @brief Task Initiation callback function. 
@@ -68,5 +72,308 @@ uint8_t udpP7ActvInit(Ent entity, Inst inst, Region region, Reason reason)
 uint8_t udpP7ActvTsk(Pst *pst, Buffer *mBuf)
 {
    uint8_t ret = ROK;
+
+   switch(pst->srcEnt)
+   {
+      case ENTDUAPP:
+      {
+         switch(pst->event)
+         {
+            case EVENT_NFAPI_P7_UDP_CFG:
+            {
+                unpackDuNfapiP7UdpCfg(NfapiProcP7UdpCfg, pst, mBuf);
+                break;
+            }
+            default:
+            {
+                DU_LOG("\nERROR  -> NFAPI_VNF: UDP Act task received Incorrect event:%d",\
+                                                                  pst->event);
+                ret = RFAILED;
+            }
+          }
+          break;
+       }
+       case ENTUDPP7:
+       {
+           switch(pst->event)
+           {
+              case EVTSTARTNFAPIP7POLL:
+              {
+                 nfapiP7UdpRecvMsg();
+                 ODU_PUT_MSG_BUF(mBuf);
+                 break;
+              }
+              default:
+              {
+                 DU_LOG("\nERROR  -> NFAPI_VNF: UDP Act task received Incorrect event:%d",\
+                                                                  pst->event);
+                 ret = RFAILED;
+                 break;
+              }
+           }
+           break;
+        }
+       default:
+       {
+          DU_LOG("\nERROR  --> NFAPI_VNF: UDP Act task received from wrong Entity:%d",\
+                                                                  pst->srcEnt);
+          ret = RFAILED;
+          break;
+       }
+   }
+   
+   ODU_EXIT_TASK();
+   return ret;
+}
+
+/**************************************************************************
+ * @brief Handles the NFAPI_UDP_P7 Configuration received from DUAPP 
+ *
+ * @details
+ *
+ *      Function : NfapiProcP7UdpCfg 
+ * 
+ *      Functionality: UDP P7 Configuration recevied from DUAPP has to be stored
+ *      in Database of NFAPI which will be used during UDP Socket Establishment
+ *     
+ * @param[in]  Pst     *pst, Post structure of the primitive.     
+ * @param[in]  Buffer *mBuf, Packed primitive parameters in the
+ *  buffer.
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ ***************************************************************************/
+uint8_t NfapiProcP7UdpCfg(Pst *pst, NfapiP7UdpCfg *nfapiP7UdpCfg)
+{
+   uint8_t ret = ROK;
+   
+   DU_LOG("INFO --> NFAPI_VNF: Received UDP P7 Configuration from DUAPP");
+   if(nfapiP7UdpCfg)
+   {
+      if(nfapiP7UdpCfg->ipv4P7VnfPres)
+      {
+         vnfDb.p7TransInfo.srcIpv4Address = nfapiP7UdpCfg->ipv4P7VnfAddr;
+         vnfDb.p7TransInfo.srcIpv4Port = nfapiP7UdpCfg->p7VnfPort;
+         vnfDb.p7TransInfo.destIpv4Address = nfapiP7UdpCfg->ipv4P7PnfAddr;
+         vnfDb.p7TransInfo.destIpv4Port = nfapiP7UdpCfg->p7PnfPort;
+         vnfDb.p7TransInfo.srcIpNetAddr.address = CM_INET_NTOH_UINT32(vnfDb.p7TransInfo.srcIpv4Address);
+         vnfDb.p7TransInfo.srcIpNetAddr.port = vnfDb.p7TransInfo.srcIpv4Port;
+         vnfDb.p7TransInfo.destIpNetAddr.address = CM_INET_NTOH_UINT32(vnfDb.p7TransInfo.destIpv4Address);
+         vnfDb.p7TransInfo.destIpNetAddr.port = vnfDb.p7TransInfo.destIpv4Port;
+      }
+
+      NFAPI_UDP_P7_FREE_SHRABL_BUF(pst->region, pst->pool, nfapiP7UdpCfg, sizeof(NfapiP7UdpCfg));
+   }
+   else
+   {
+      DU_LOG("\nINFO  -->  MAC : Received NfapiP7UdpCfg is NULL");
+      ret =  RFAILED;
+   }
+   return ret;
+}
+
+/*******************************************************************
+ *
+ * @brief Processing Client open request
+ *
+ * @details
+ *
+ *    Function : nfapiP7UdpCliOpenPrc
+ *
+ *    Functionality: Processing UDP P7 Client open request
+ *      
+ *
+ * @params[in] 
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t nfapiP7UdpCliOpenPrc(uint8_t sockType)
+{
+   S8 ret=ROK;
+   ret = cmInetSocket(sockType, &(vnfDb.p7TransInfo.sockFd), CM_INET_PROTO_UDP); 
+       if(ret != ROK)
+   {  
+      DU_LOG("\nERROR  -->  NFAPI_VNF : Failed to open UDP socket");
+      return ret;
+   }
+   ret = cmInetBind(&(vnfDb.p7TransInfo.sockFd), &(vnfDb.p7TransInfo.srcIpNetAddr));  
+   if(ret != ROK)
+   {  
+      DU_LOG("\nERROR  -->  NFAPI_VNF : Failed to bind socket");
+      return ret;
+   }
+   
+   return ret;
+}
+
+/*******************************************************************
+ *
+ * @brief Packs Polling requesting and sends to NFAPI P7 UDP
+ *
+ * @details
+ *
+ *    Function : packNfapiP7UdpStartPollingReq
+ *
+ *    Functionality:
+ *       Packs polling request and sends to NFAPI P7 UDP
+ *
+ * @params[in] Post structure
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ *******************************************************************/
+uint8_t packNfapiP7UdpStartPollingReq(Pst *pst)
+{
+   Buffer *mBuf;
+
+   if(ODU_GET_MSG_BUF(DFLT_REGION, pst->pool, &mBuf) != ROK)
+   {
+      DU_LOG("\nERROR  -->  NFAPI_VNF : Failed to allocate memory");
+      return RFAILED;
+   }
+
+   ODU_POST_TASK(pst, mBuf);
+   return ROK;
+}
+
+/**************************************************************************
+ * @brief NFAPI P7 Interface's UDP open request 
+ *
+ * @details
+ *
+ *      Function : nfapiP7UdpOpenReq
+ * 
+ *      Functionality:
+ *           This function handles NFAPI P7 UDP open request.
+ *           It opens udp socket to receive/send msgs.
+ *     
+ * @param[in]  Pst *pst, post structure
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ ***************************************************************************/
+
+uint8_t nfapiP7UdpOpenReq()
+{
+
+   uint8_t  ret = ROK;       /* Return value */
+   Pst      nfapiP7Pst;   /* Self post */
+   uint8_t  sockType;  /* Socket type */
+
+   DU_LOG("\nDEBUG  -->  NFAPI_VNF : Received NFAPI P7's UDP open Client request");
+   sockType = CM_INET_DGRAM;
+   ret = nfapiP7UdpCliOpenPrc(sockType);
+   /* Opening and Binding receiver socket */
+   if(ret != ROK)
+   {
+      DU_LOG("\nERROR  -->  NFAPI_VNF : Failed while opening receiver transport server");
+      return ret;
+   }
+
+   DU_LOG("\nDEBUG   -->  NFAPI_VNF : Socket [%d] is open", vnfDb.p7TransInfo.sockFd.fd);
+
+   /* Start Socket polling */
+   memset(&nfapiP7Pst, 0, sizeof(nfapiP7Pst));
+   nfapiP7Pst.srcEnt = (Ent)ENTUDPP7;
+   nfapiP7Pst.srcInst = (Inst)NFAPI_UDP_P7_INST;
+   nfapiP7Pst.srcProcId = NFAPI_UDP_P7_PROC;
+   nfapiP7Pst.dstEnt = (Ent)ENTUDPP7;
+   nfapiP7Pst.dstInst = (Inst)NFAPI_UDP_P7_INST;
+   nfapiP7Pst.dstProcId = NFAPI_UDP_P7_PROC;
+   nfapiP7Pst.event = EVTSTARTNFAPIP7POLL;
+   nfapiP7Pst.selector = ODU_SELECTOR_LC;
+   nfapiP7Pst.pool= NFAPI_UDP_P7_POOL;
+   packNfapiP7UdpStartPollingReq(&nfapiP7Pst);
+
    return ret;
 }
+
+/*******************************************************************
+ *
+ * @brief Receives NFAPI P7 message from UDP socket 
+ *
+ * @details
+ *
+ *    Function : nfapiP7UdpRecvMsg
+ *
+ *    Functionality:
+ *      Receive incoming messages from UDP socket
+ *
+ * @params[in] 
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t nfapiP7UdpRecvMsg()
+{
+   uint8_t        ret = ROK;           /* Return value */
+   uint16_t       bufLen;        /* Length of received buffer */
+   Buffer         *recvBuf;      /* Received buffer */
+   CmInetMemInfo  memInfo;       /* Buffer allocation info */
+   memInfo.region = NFAPI_UDP_P7_MEM_REGION;
+   memInfo.pool   = NFAPI_UDP_P7_POOL;
+
+   while(true)
+   {
+      bufLen = -1;
+      ret = RFAILED;
+      recvBuf = NULLP;
+      ret = cmInetRecvMsg(&vnfDb.p7TransInfo.sockFd, &vnfDb.p7TransInfo.destIpNetAddr, &memInfo, &recvBuf, (int16_t *)&bufLen, CM_INET_NO_FLAG);
+      if(ret == ROK && recvBuf != NULLP)
+      {
+         DU_LOG("\nDEBUG  -->  NFAPI_VNF : Received P7 Message\n");
+         ODU_PUT_MSG_BUF(recvBuf);
+      }
+   }
+   return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief Sends message over UDP
+ *
+ * @details
+ *
+ *    Function : nfapiP7UdpSendMsg
+ *
+ *    Functionality:
+ *           Sends message over UDP
+ *
+ * @params[in] Message Buffer 
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t nfapiP7UdpSendMsg(Buffer *mBuf)
+{
+   uint8_t        ret;
+   uint16_t       txLen;
+   CmInetMemInfo  info;
+   static uint64_t numDataSent = 0;
+
+   info.region = NFAPI_UDP_P7_MEM_REGION;
+   info.pool = NFAPI_UDP_P7_POOL;
+
+   ret = cmInetSendMsg(&vnfDb.p7TransInfo.sockFd, &vnfDb.p7TransInfo.destIpNetAddr, &info, mBuf, (int16_t *)&txLen, CM_INET_NO_FLAG);
+   if(ret != ROK && ret != RWOULDBLOCK)
+   {
+      DU_LOG("\nERROR  -->  NFAPI_VNF : Failed sending the message");
+      return RFAILED;
+   }
+   else
+   {
+      DU_LOG("\nDEBUG -->  NFAPI_VNF : Sent NFAPI P7 Message [%ld]", numDataSent+1);
+      numDataSent++;
+   }
+
+   return ROK;
+}
+
+/**********************************************************************
+         End of file
+**********************************************************************/
diff --git a/src/5gnrmac/nfapi_udp_p7.h b/src/5gnrmac/nfapi_udp_p7.h
new file mode 100644 (file)
index 0000000..a573900
--- /dev/null
@@ -0,0 +1,27 @@
+
+ /*******************************************************************************
+ ################################################################################
+ #   Copyright (c) [2017-2019] [Radisys]                                        #
+ #                                                                              #
+ #   Licensed under the Apache License, Version 2.0 (the "License");            #
+ #   you may not use this file except in compliance with the License.           #
+ #   You may obtain a copy of the License at                                    #
+ #                                                                              #
+ #       http://www.apache.org/licenses/LICENSE-2.0                             #
+ #                                                                              #
+ #   Unless required by applicable law or agreed to in writing, software        #
+ #   distributed under the License is distributed on an "AS IS" BASIS,          #
+ #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+ #   See the License for the specific language governing permissions and        #
+ #   limitations under the License.                                             #
+ ################################################################################
+ *******************************************************************************/
+
+/*Reference: SCF225_5G_NFAPI_SPECIFICATION, v225.2.1, Issue Date: 23 Nov 2021*/
+
+#ifndef _NFAPI_UDP_P7_H__
+#define _NFAPI_UDP_P7_H__
+
+uint8_t nfapiP7UdpOpenReq();
+
+#endif
index 84b9ea6..0dd85c2 100644 (file)
 /* header include files -- defines (.h) */
 #include "common_def.h"
 #include "lwr_mac.h"
-#include "nfapi_vnf_fsm.h"
 #include "nfapi_interface.h"
+#include "nfapi_vnf_fsm.h"
 #include "nfapi_common.h"
 #include "lwr_mac_utils.h"
 #include "lwr_mac_sctp_inf.h"
 #include "mac_utils.h"
 #include "lwr_mac_fsm.h"
+#include "nfapi_udp_p7.h"
 
 /*******************************************************************
  *
@@ -77,9 +78,12 @@ uint8_t nfapi_vnf_procPnfReadyIndEvt(nFapi_p5_hdr *p5Hdr, nFapi_msg_header *msgH
          vnfDb.pnfEvent, vnfDb.pnfStateAtVnf);
 
    CMCHKPK(oduUnpackUInt32, &(version), msg);
-   
+
    DU_LOG("\nINFO   --> NFAPI_VNF: PNF_READY_IND version:%d",version);
 
+   /*TODO: Need to put it when START.RESPONSE is received.*/
+   nfapiP7UdpOpenReq(); 
+   
    sendEventToNfapiVnfFsm(PNF_PARAM_REQ, NULLP, NULLP, NULLP);
    return ROK;
 }
index 48002df..a20ef32 100644 (file)
@@ -21,8 +21,6 @@
 #ifndef _NFAPI_VNF_FSM_H_
 #define _NFAPI_VNF_FSM_H_
 
-#include "nfapi_interface.h"
-
 typedef enum {
    PNF_STATE_IDLE = 0,
    PNF_STATE_CONFIGURED,
@@ -46,13 +44,14 @@ typedef enum {
 typedef struct nfapiTransportInfo
 {
    uint32_t         assocId;
-   uint8_t          srcIpv4Address[4];   /*Src :: PNF Address Details*/
+   uint32_t         srcIpv4Address;   /*Src :: PNF Address Details*/
    uint16_t         srcIpv4Port;          
-   uint8_t          destIpv4Address[4];  /*Dest :: VNF Address Details*/
+   uint32_t         destIpv4Address;  /*Dest :: VNF Address Details*/
    uint16_t         destIpv4Port;
    CmInetFd         sockFd;           /* Socket file descriptor */
-   CmInetNetAddrLst addrLst;      /* Refers to the destinaiton Addr Lst in CmInetNetAddrLst format */
-   CmInetNetAddr    ipNetAddr;    /* Refers to the destination Addr in CmInetNet Addr format */
+   CmInetAddr       srcIpNetAddr;    /* Refers to the Source(VNF) Addr in CmInetNet Addr format */
+   CmInetAddr       destIpNetAddr;    /* Refers to the destination(PNF) Addr in CmInetNet Addr format */
+   //CmInetNetAddrLst addrLst;      /* Refers to the destinaiton Addr Lst in CmInetNetAddrLst format */
    
    /*TODO: Add the IPV6 support*/
 
index 968d784..d21524b 100755 (executable)
@@ -69,6 +69,7 @@
 #include "lwr_mac_phy.h"
 
 #ifdef NFAPI_ENABLED
+#include "nfapi_interface.h"
 #include "nfapi_vnf_fsm.h"
 #endif
 
diff --git a/src/cm/du_app_p7udp_inf.c b/src/cm/du_app_p7udp_inf.c
new file mode 100644 (file)
index 0000000..4c7d49f
--- /dev/null
@@ -0,0 +1,103 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2017-2019] [Radisys]                                        #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+ *******************************************************************************/
+
+#include "common_def.h"
+#include "du_app_p7udp_inf.h"
+
+/*******************************************************************
+*
+* @brief Packs and Sends NFAPI's UDP P7 Interface's Config 
+*
+* @details
+*
+*    Function : packDuNfapiP7UdpCfg
+*
+*    Functionality:
+*       Packs and Sends NFAPI's UDP P7 Interface's Configuration 
+*
+*
+* @params[in] Post structure pointer
+*             NfapiP7UdpCfg pointer
+* @return ROK     - success
+*         RFAILED - failure
+*
+* ****************************************************************/
+uint8_t packDuNfapiP7UdpCfg(Pst *pst,  NfapiP7UdpCfg *nfapiP7UdpCfg)
+{
+    Buffer *mBuf = NULLP;
+
+    if(pst->selector == ODU_SELECTOR_LWLC)
+    {
+       if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
+       {
+          DU_LOG("\nERROR  --> MAC : Memory allocation failed at packDuNfapiP7UdpCfg");
+          return RFAILED;
+       }
+       /* pack the address of the structure */
+       CMCHKPK(oduPackPointer,(PTR)nfapiP7UdpCfg, mBuf);
+    }
+    else
+    {
+       DU_LOG("\nERROR  -->  MAC: Only LWLC supported for packDuNfapiP7UdpCfg");
+       return RFAILED;
+    }
+    return ODU_POST_TASK(pst,mBuf);
+}
+
+/*******************************************************************
+*
+* @brief Unpacks NFAPI's UDP P7 Interface's Configuration 
+*
+* @details
+*
+*    Function : unpackDuNfapiP7UdpCfg
+*
+*    Functionality:
+*         Unpacks NFAPI's UDP P7 Interface's Configuration 
+*
+* @params[in] Pointer to Handler
+*             Post structure pointer
+*             Message Buffer
+* @return ROK     - success
+*         RFAILED - failure
+*
+* ****************************************************************/
+uint8_t unpackDuNfapiP7UdpCfg(DuNfapiP7UdpCfgFunc func, Pst *pst, Buffer *mBuf)
+{
+    if(pst->selector == ODU_SELECTOR_LWLC)
+    {
+       NfapiP7UdpCfg *nfapiP7UdpCfg = NULLP;
+
+       /* unpack the address of the structure */
+       CMCHKUNPK(oduUnpackPointer, (PTR *)&nfapiP7UdpCfg, mBuf);
+       ODU_PUT_MSG_BUF(mBuf);
+       return (*func)(pst, nfapiP7UdpCfg);
+    }
+    else
+    {
+       /* Nothing to do for other selectors */
+       DU_LOG("\nERROR  -->  DU APP : Only LWLC supported for UDP P7 Config Request ");
+       ODU_PUT_MSG_BUF(mBuf);
+    }
+
+    return RFAILED;
+}
+
+/**********************************************************************
+  End of file
+ **********************************************************************/
diff --git a/src/cm/du_app_p7udp_inf.h b/src/cm/du_app_p7udp_inf.h
new file mode 100644 (file)
index 0000000..8f71cbf
--- /dev/null
@@ -0,0 +1,53 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2017-2019] [Radisys]                                        #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+ *******************************************************************************/
+
+/* Defines APIs exchanged between du_app and UDP P7 module */
+#ifndef __DUAPP_P7UDP_INF_H__
+#define __DUAPP_P7UDP_INF_H__
+
+#define EVENT_NFAPI_P7_UDP_CFG 1
+
+/********************* Global Variable ********************/
+
+typedef struct nfapiP7UdpCfg{
+   bool      ipv4P7VnfPres;
+   uint32_t  ipv4P7VnfAddr;
+   bool      ipv6P7VnfPres;
+   uint32_t  ipv6P7VnfAddr;
+   bool      ipv4P7PnfPres;
+   uint32_t  ipv4P7PnfAddr;
+   uint16_t  p7VnfPort;
+   uint16_t  p7PnfPort;
+
+}NfapiP7UdpCfg;
+
+typedef uint8_t (* DuNfapiP7UdpCfgFunc) ARGS((
+      Pst *pst,
+      NfapiP7UdpCfg *nfapiP7UdpCfg));
+
+
+/******************** FUNCTION DECLARATIONS ********************************/
+uint8_t packDuNfapiP7UdpCfg(Pst *pst, NfapiP7UdpCfg *nfapiP7UdpCfg);
+uint8_t NfapiProcP7UdpCfg(Pst *pst, NfapiP7UdpCfg *nfapiP7UdpCfg);
+uint8_t unpackDuNfapiP7UdpCfg(DuNfapiP7UdpCfgFunc func, Pst *pst, Buffer *mBuf);
+
+#endif
+
+/**********************************************************************
+  End of file
+ **********************************************************************/
index 42a2844..ee2a508 100755 (executable)
 #define ENTPHYSTUB  0xd4
 #else
 #ifdef NFAPI_ENABLED
-#define ENTUDP7       0xd4            /* UDP P7 */
+#define ENTUDPP7       0xd4            /* UDP P7 */
 #endif
 #endif
 /* ssi_h_001.main_135 : addition of LTE related entities */
index d6d20fa..cc1eb65 100644 (file)
@@ -302,6 +302,43 @@ uint8_t parseEgtpParams(xmlDocPtr doc, xmlNsPtr ns, xmlNodePtr cur, F1EgtpParams
    return ROK;
 }
 
+/*******************************************************************
+ *
+ * @brief Fill P7 UDP Parameters
+ *
+ * @details
+ *
+ *    Function : parseP7UdpParams
+ *
+ *    Functionality: Fill P7 UDP Parmeters
+ *
+ * @params[in] XML document pointer
+ *             XML namespace
+ *             Current node in XML
+ *             Pointer to structure to be filled
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t parseP7UdpParams(xmlDocPtr doc, xmlNsPtr ns, xmlNodePtr cur, NfapiP7UdpCfg *p7Udp) 
+{
+   memset(p7Udp, 0, sizeof(NfapiP7UdpCfg));
+   cur = cur->xmlChildrenNode;
+   while (cur != NULL) 
+   {
+      if ((!xmlStrcmp(cur->name, (const xmlChar *)"VNF_P7_UDP_PORT")) && (cur->ns == ns))
+      {
+         p7Udp->p7VnfPort = atoi((char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1));
+      }
+      if ((!xmlStrcmp(cur->name, (const xmlChar *)"PNF_P7_UDP_PORT")) && (cur->ns == ns))
+      {
+         p7Udp->p7PnfPort = atoi((char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1));
+      }
+      cur = cur -> next;
+   }
+   return ROK;
+}
+
 /*******************************************************************
  *
  * @brief Fill MIB configuration 
@@ -5190,7 +5227,7 @@ uint8_t parseDuCfgParams(xmlDocPtr doc, xmlNsPtr ns, xmlNodePtr cur)
    char *ricIpV4Addr;
 #ifdef NFAPI_ENABLED
    char *pnfP5IpV4Addr;
-   CmInetIpAddr pnfP5Ip;
+   CmInetIpAddr pnfIp;
 #endif
    CmInetIpAddr duIp;
    CmInetIpAddr cuIp;
@@ -5268,7 +5305,7 @@ uint8_t parseDuCfgParams(xmlDocPtr doc, xmlNsPtr ns, xmlNodePtr cur)
       if ((!xmlStrcmp(cur->name, (const xmlChar *)"PNF_P5_IP_V4_ADDR")) && (cur->ns == ns))
       {
          pnfP5IpV4Addr = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
-         cmInetAddr(pnfP5IpV4Addr, &(pnfP5Ip));
+         cmInetAddr(pnfP5IpV4Addr, &(pnfIp));
       }
 #endif
       if ((!xmlStrcmp(cur->name, (const xmlChar *)"SCTP")) && (cur->ns == ns))
@@ -5286,7 +5323,7 @@ uint8_t parseDuCfgParams(xmlDocPtr doc, xmlNsPtr ns, xmlNodePtr cur)
          duCfgParam.sctpParams.ricIpAddr.ipV4Addr = ricIp;
 #ifdef NFAPI_ENABLED
          duCfgParam.sctpParams.pnfP5IpAddr.ipV4Pres = true;
-         duCfgParam.sctpParams.pnfP5IpAddr.ipV4Addr = pnfP5Ip;
+         duCfgParam.sctpParams.pnfP5IpAddr.ipV4Addr = pnfIp;
 #endif
       }
 
@@ -5304,6 +5341,21 @@ uint8_t parseDuCfgParams(xmlDocPtr doc, xmlNsPtr ns, xmlNodePtr cur)
          duCfgParam.egtpParams.maxTunnelId = duCfgParam.maxNumDrb * MAX_NUM_UE; 
       }
 
+#ifdef NFAPI_ENABLED
+      if ((!xmlStrcmp(cur->name, (const xmlChar *)"P7_UDP")) && (cur->ns == ns))
+      {
+         parseP7UdpParams(doc, ns, cur, &duCfgParam.tempNFapiP7UdpCfg); 
+         if(duCfgParam.sctpParams.duIpAddr.ipV4Pres)
+         {
+            duCfgParam.tempNFapiP7UdpCfg.ipv4P7VnfPres = true;
+            duCfgParam.tempNFapiP7UdpCfg.ipv4P7VnfAddr = duIp;
+            duCfgParam.tempNFapiP7UdpCfg.ipv6P7VnfPres = false;
+            duCfgParam.tempNFapiP7UdpCfg.ipv6P7VnfAddr = 0;
+            duCfgParam.tempNFapiP7UdpCfg.ipv4P7PnfPres = true;
+            duCfgParam.tempNFapiP7UdpCfg.ipv4P7PnfAddr = pnfIp;
+         }
+      }
+#endif
       if ((!xmlStrcmp(cur->name, (const xmlChar *)"MIB_PARAMS")) && (cur->ns == ns))
       {
          if(parseMibParams(doc, ns, cur, &duCfgParam.mibParams) != ROK)
index 63b0d76..0bb98ca 100644 (file)
@@ -22,7 +22,9 @@
 #ifdef O1_ENABLE
 #include "CmInterface.h"
 #endif
-
+#ifdef NFAPI_ENABLED
+#include "du_app_p7udp_inf.h"
+#endif
 /* MACROS */
 #define GNB_ID  1 /* As per 38.423,Sec 9.2.2.1, gnbId range b/w 0 to 4294967295 */
 
@@ -1179,6 +1181,9 @@ typedef struct duCfgParams
    MibParams          mibParams;                  /* MIB Params */
    Sib1Params         sib1Params;                 /* SIB1 Params */
    MacSliceCfgReq     tempSliceCfg;
+#ifdef NFAPI_ENABLED
+   NfapiP7UdpCfg      tempNFapiP7UdpCfg;
+#endif
 }DuCfgParams;
 
 #ifndef O1_ENABLE
index 56dd91e..7b71fe7 100644 (file)
@@ -580,13 +580,13 @@ uint8_t phyStubInit(SSTskId sysTskId)
 uint8_t udpP7Init(SSTskId sysTskId)
 {
    /* Register UDP P7 TAPA Task */
-   if(ODU_REG_TTSK((Ent)ENTUDP7, (Inst)0, (Ttype)TTNORM, (Prior)PRIOR0,
+   if(ODU_REG_TTSK((Ent)ENTUDPP7, (Inst)0, (Ttype)TTNORM, (Prior)PRIOR0,
             udpP7ActvInit, (ActvTsk)udpP7ActvTsk) != ROK)
    {
       return RFAILED;
    }
    /* Attach UDP P7 TAPA Task */
-   if (ODU_ATTACH_TTSK((Ent)ENTUDP7, (Inst)0, sysTskId)!= ROK)
+   if (ODU_ATTACH_TTSK((Ent)ENTUDPP7, (Inst)0, sysTskId)!= ROK)
    {
       return RFAILED;
    }
index b2ab028..f572270 100644 (file)
 
 #endif 
 
+#ifdef NFAPI_ENABLED
+#include "du_app_p7udp_inf.h"
+#endif
+
 uint8_t rlcDlCfg = 0;
 uint8_t numRlcDlSaps = 0;
 uint8_t rlcUlCfg = 0;
@@ -115,6 +119,15 @@ DuMacStatsModificationReqFunc packMacStatsModificationReqOpts[]=
    packDuMacStatsModificationReq           /* Light weight-loose coupling */
 };
 
+#ifdef NFAPI_ENABLED
+DuNfapiP7UdpCfgFunc packNfapiP7UdpCfgOpts[]=
+{
+   packDuNfapiP7UdpCfg,      /*Loose Coupling*/
+   NfapiProcP7UdpCfg,        /*Tight-Coupling*/
+   packDuNfapiP7UdpCfg       /*Light weight-loose coupling */
+};
+#endif
+
 /**************************************************************************
  * @brief Function to fill configs required by RLC
  *
@@ -406,9 +419,13 @@ uint8_t duProcCfgComplete()
    {
       //Start layer configs
       ret = duSendRlcUlCfg();
+#ifdef NFAPI_ENABLED
+      ret = BuildAndSendNfapiP7UdpConfig();
+#endif
    }
    return ret;
 }
+
 /**************************************************************************
  * @brief Function to invoke DU Layer Configs
  *
@@ -2578,6 +2595,51 @@ uint8_t DuProcMacStatsModificationRsp(Pst *pst, MacStatsModificationRsp *statsMo
    return ret;
 }
 
+#ifdef NFAPI_ENABLED
+/*******************************************************************
+ *
+ * @brief Fill the NFAPI P7 UDP Socket Config to NFAPI UDP P7 (VNF)
+ * 
+ * @details
+ *
+ *    Function : BuildAndSendNfapiP7UdpConfig 
+ *
+ *    Functionality: Fill the NFAPI P7 UDP Socket Config 
+ *
+ * @params[in]
+ *             
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t BuildAndSendNfapiP7UdpConfig()
+{
+   Pst pst;
+   NfapiP7UdpCfg *p7UdpCfg = NULLP;
+
+   DU_ALLOC_SHRABL_BUF(p7UdpCfg, sizeof(NfapiP7UdpCfg));
+   if(p7UdpCfg == NULLP)
+   {
+      DU_LOG("\nERROR  -->  DU_APP : Memory allocation failed in BuildAndSendNfapiP7UdpConfig");
+      return RFAILED;
+   }
+   else
+   {
+      memcpy(p7UdpCfg,  &duCfgParam.tempNFapiP7UdpCfg, sizeof(NfapiP7UdpCfg));
+      FILL_PST_DUAPP_TO_NFAPIUDPP7(pst, EVENT_NFAPI_P7_UDP_CFG);
+
+      DU_LOG("\nDEBUG  -->  DU_APP : Sending NFAPI P7 UDP Cfg to NFAPI P7 (VNF)");
+      if((*packNfapiP7UdpCfgOpts[pst.selector])(&pst, p7UdpCfg) == RFAILED)
+      {
+         DU_LOG("\nERROR  -->  DU_APP : Failed to send NFAPI P7 UDP Cfg to NFAPI P7");
+         DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, p7UdpCfg, sizeof(NfapiP7UdpCfg));
+         return RFAILED;
+      }
+   }
+   return ROK;  
+}
+#endif
+
 /**********************************************************************
   End of file
  **********************************************************************/
index 33a2771..d09d683 100644 (file)
@@ -28,7 +28,7 @@ uint8_t sendCellDeleteReqToMac(uint16_t cellId);
 uint8_t BuildAndSendStatsDeleteReq(RicSubscription *ricSubscriptionInfo, bool deleteAllStats);
 uint8_t BuildAndSendStatsModificationReqToMac(RicSubscription *ricSubscriptionInfo);
 uint8_t BuildAndSendStatsModificationReq(RicSubscription *ricSubscriptionInfo);
-
+uint8_t BuildAndSendNfapiP7UdpConfig();
 
 /**********************************************************************
   End of file
index e98aa43..282c967 100644 (file)
@@ -23,6 +23,9 @@
 #define RLC_UL_MEM_REGION    1
 #define RLC_DL_MEM_REGION    4
 #define MAC_MEM_REGION       4
+#ifdef NFAPI_ENABLED
+#define NFAPI_UDP_P7_MEM_REGION   5
+#endif
 
 #define DU_POOL  1
 #define RLC_POOL  1
    }                                                            \
 }
 
+#ifdef NFAPI_ENABLED
+/* Fill Pst structure for sending msg from DU APP to NFAPI UDP P7 */
+#define FILL_PST_DUAPP_TO_NFAPIUDPP7(_pst, _event)                 \
+{                                                           \
+   _pst.selector  = ODU_SELECTOR_LWLC;                      \
+   _pst.srcEnt    = ENTDUAPP;                               \
+   _pst.dstEnt    = ENTUDPP7;                                  \
+   _pst.dstInst   = 0;                                      \
+   _pst.srcInst   = 0;                                      \
+   _pst.dstProcId = DU_PROC;                                \
+   _pst.srcProcId = DU_PROC;                                \
+   _pst.region = DU_APP_MEM_REGION;                         \
+   _pst.pool = DU_POOL;                                     \
+   _pst.event = _event;                                     \
+   _pst.route = 0;                                          \
+   _pst.prior = 0;                                          \
+   _pst.intfVer = 0;                                        \
+}
+#endif
+
 /* Fill Pst structure for sending msg from DU APP to MAC */
 #define FILL_PST_DUAPP_TO_MAC(_pst, _event)                 \
 {                                                           \
index bc9b51c..22a12b5 100644 (file)
@@ -180,7 +180,6 @@ S16 l1BldAndSndParamRsp(void *msg)
 }
 
 /*******************************************************************
- *
  * @brief Builds and sends config response to lower mac
  *
  * @details
index 40acea5..a62dd00 100644 (file)
@@ -34,6 +34,7 @@
 #include <unistd.h>
 #include "nfapi_interface.h"
 #include "pnf_stub_sctp.h"
+#include "pnf_stub_p7_udp.h"
 #include "pnf_stub.h"
 #include "pnf_stub_p5_msg_hdl.h"
 
@@ -100,7 +101,13 @@ void readPnfCfg()
    }
 
    pnfCb.pnfCfgParams.pnfP5SctpParams.numDestNode = cntNumVnf;
-  
+   /*P7 UDP Transport Cfg*/
+   pnfCb.pnfCfgParams.pnfP7UdpParams.srcIpv4P7Addr = ipv4_pnf;
+   pnfCb.pnfCfgParams.pnfP7UdpParams.srcIpv4Port = PNF_P7_UDP_PORT;
+   pnfCb.pnfCfgParams.pnfP7UdpParams.destIpv4P7Addr = ipv4_vnf;
+   pnfCb.pnfCfgParams.pnfP7UdpParams.destIpv4Port = PNF_P7_UDP_PORT;
+
 } /* End of readPnfCfg */
 
 
@@ -152,12 +159,16 @@ uint8_t tst()
    /* Initializing SCTP global parameters */
    pnfP5SctpActvInit();
  
-   /* Start PNF-P5-SCTP to listen on incoming connection */
    pnfP5SctpCfgReq();
-   
+  
+   /* Initializing UDP global parameters */
+   pnfP7UdpActvInit();
+   pnfP7UdpCfgReq();
+
    /*Sleep is introduced for GDB to increase the waiting time for PNF Configuration from VNF*/
    sleep(1);
    
+   /* Start PNF-P5-SCTP to listen on incoming connection */
    pnfP5SctpStartReq();
 
    return ROK;
@@ -264,4 +275,3 @@ void nFapiExtractMsgHdr(nFapi_msg_header *msgHdr, Buffer *mBuf)
 /**********************************************************************
 End of file
 **********************************************************************/
-
index 2c6baba..7551ed9 100644 (file)
@@ -29,6 +29,9 @@
 #define NUM_PNF_P5_ASSOC 1 
 #define REMOTE_IP_DU (char*[]){"192.168.130.81", "192.168.130.83"}
 
+/*P7 UDP Teansport Cfg Details*/
+#define PNF_P7_UDP_PORT 9876
+
 #define PNF_APP_MEM_REG 1
 #define PNF_POOL 1
 
@@ -45,6 +48,7 @@ typedef struct pnfCfgParams
    uint32_t          pnfId;
    char              pnfName[PNF_NAME_LEN_MAX];
    PnfP5SctpParams   pnfP5SctpParams;
+   PnfP7UdpParams    pnfP7UdpParams;
 }PnfCfgParams;
 
 typedef struct pnfGlobalCb
diff --git a/src/pnf_stub/pnf_stub_p7_udp.c b/src/pnf_stub/pnf_stub_p7_udp.c
new file mode 100644 (file)
index 0000000..c1b02d0
--- /dev/null
@@ -0,0 +1,165 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2017-2019] [Radisys]                                        #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+/* This file contains all P7 UDP related functionality */
+
+#include "common_def.h"
+#include "cm_inet.x"
+#include "pnf_stub_p7_udp.h"
+#include "pnf_stub_sctp.h"
+#include "pnf_stub.h"
+
+uint8_t sockType;
+uint8_t protType;
+
+/**************************************************************************
+ * @brief Task Initiation callback function. 
+ *
+ * @details
+ *
+ *     Function :  pnfP7UdpActvInit
+ *    
+ *     Functionality:
+ *             This function is supplied as one of parameters during UDP P7's 
+ *             task registration. SSI will invoke this function once, after
+ *             it creates and attaches this TAPA Task to a system task.
+ *     
+ * @param[in]    
+ * @return ROK     - success
+ *         RFAILED - failure
+ ***************************************************************************/
+uint8_t pnfP7UdpActvInit()
+{
+  DU_LOG("\n\nDEBUG  -->  P7_UDP : Initializing ");
+  memset (&pnfP7Cb, 0, sizeof(PnfP7UdpGlobalCb));
+  
+  //Initializing with INVALID value
+  pnfP7Cb.gCntMsg =  0xFFFF; 
+  protType = CM_INET_PROTO_UDP;
+  return ROK;
+}
+
+/**************************************************************************
+ * @brief UDP P7 server open request 
+ *
+ * @details
+ *
+ *      Function : pnfP7UdpSrvOpenReq
+ * 
+ *      Functionality:
+ *           This function handles P7 UDP open server request.
+ *           It opens udp socket to receive/send msgs.
+ *     
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ ***************************************************************************/
+
+uint8_t pnfP7UdpSrvOpenReq()
+{
+   uint8_t ret = ROK;
+
+   DU_LOG("\nINFO  -->  P7_UDP: Received open server request");
+
+   sockType = CM_INET_DGRAM;
+   if((ret = (cmInetSocket(sockType, &(pnfP7Cb.sockFd), protType))) != ROK)
+   {
+      DU_LOG("\nERROR  -->  P7_UDP : Failed to open UDP socket");
+      return RFAILED;
+   }
+
+   ret = cmInetBind(&(pnfP7Cb.sockFd), &(pnfP7Cb.srcAddr));
+   if(ret != ROK)
+   {
+      DU_LOG("\nERROR  -->  P7_UDP : Failed to bind socket");
+      return RFAILED;
+   }
+
+   DU_LOG("\nINFO  -->  P7_UDP : Socket[%d] is open", pnfP7Cb.sockFd.fd);
+   return ROK;
+} /* pnfP7UdpSrvOpenReq */
+
+/**************************************************************************
+ * @brief Task Activation callback function. 
+ *
+ * @details
+ *
+ *      Function : pnfP7UdpCfgReq 
+ * 
+ *      Functionality: Fills the PnfP7 Database with UDP Client/Server Addresses
+ *
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ ***************************************************************************/
+uint8_t pnfP7UdpCfgReq()
+{
+   uint8_t ret = ROK;
+   
+   pnfP7Cb.srcAddr.address = CM_INET_NTOH_UINT32(pnfCb.pnfCfgParams.pnfP7UdpParams.srcIpv4P7Addr);
+   pnfP7Cb.srcAddr.port = pnfCb.pnfCfgParams.pnfP7UdpParams.srcIpv4Port;
+   pnfP7Cb.destAddr.address = CM_INET_NTOH_UINT32(pnfCb.pnfCfgParams.pnfP7UdpParams.destIpv4P7Addr);
+   pnfP7Cb.destAddr.port = pnfCb.pnfCfgParams.pnfP7UdpParams.destIpv4Port;
+
+   ret = pnfP7UdpSrvOpenReq();
+   if(ret != ROK)
+   {
+       DU_LOG("\nERROR  -->  P7_UDP : Transport server open request failed");
+       return (ret);
+   }
+
+   return ret;
+} /* pnfP7UdpCfgReq */
+
+/*******************************************************************
+ *
+ * @brief Send the UDP P7 message to the destination VNF
+ *
+ * @details
+ *
+ *    Function : pnfP7UdpSendMsg 
+ * 
+ *    Functionality:
+ *       Send the UDP P7 message to the destination DU
+ *
+ * @params[in]  Message Buffer 
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+S16 pnfP7UdpSendMsg(Buffer *mBuf)
+{
+   S16            ret;
+   MsgLen         txLen;
+   CmInetMemInfo  info;
+
+   info.region = PNF_APP_MEM_REG;
+   info.pool = PNF_POOL;
+   
+   ret = cmInetSendMsg(&(pnfP7Cb.sockFd), &pnfP7Cb.destAddr, &info, mBuf, &txLen, CM_INET_NO_FLAG);
+   if(ret != ROK && ret != RWOULDBLOCK)
+   {
+      DU_LOG("\nERROR  -->  P7_UDP : Message send failure");
+      return RFAILED;
+   }
+   
+   DU_LOG("\nDEBUG  -->  P7_UDP : Message Sent");
+   return ROK;
+}
diff --git a/src/pnf_stub/pnf_stub_p7_udp.h b/src/pnf_stub/pnf_stub_p7_udp.h
new file mode 100644 (file)
index 0000000..6ebaf49
--- /dev/null
@@ -0,0 +1,47 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2017-2019] [Radisys]                                        #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+/* This file contains all SCTP related functionality */
+#ifndef __PNF_STUB_P7_UDP_H__
+#define __PNF_STUB_P7_UDP_H__
+
+typedef struct pnfP7UdpParams
+{
+   uint32_t     srcIpv4P7Addr;  /*PNF P7*/
+   uint16_t     srcIpv4Port;          
+   uint32_t     destIpv4P7Addr; /*VNF P7*/
+   uint16_t     destIpv4Port;          
+}PnfP7UdpParams;
+
+typedef struct pnfP7UdpGlobalCb
+{
+   CmInetAddr   srcAddr;        /*PNF IP Address*/
+   CmInetAddr   destAddr;       /*VNF IP Address*/
+   CmInetFd     sockFd;         /* Socket file descriptor */
+   uint16_t     gCntMsg; 
+}PnfP7UdpGlobalCb;
+
+PnfP7UdpGlobalCb pnfP7Cb;
+
+uint8_t pnfP7UdpActvInit();
+uint8_t pnfP7UdpCfgReq();
+void    pnfP7UdpHdlRecvMsg(Buffer *buf);
+
+#endif
+
index a6ea67b..f809097 100644 (file)
@@ -22,6 +22,7 @@
 #include "nfapi_interface.h"
 #include "pnf_stub_sctp.h"
 #include "pnf_stub_p5_msg_hdl.h"
+#include "pnf_stub_p7_udp.h"
 #include "pnf_stub.h"
 
 uint8_t   socket_type;      /* Socket type */
@@ -314,8 +315,14 @@ uint8_t pnfP5SctpSockPoll()
    uint16_t           ret = ROK;
    uint32_t           timeout;
    uint32_t           *timeoutPtr;
+   uint64_t           numMsgRcvd = 0;
+   Buffer             *pnfP7UdpBuf;
+   MsgLen             pnfP7UdpBufLen;
+   CmInetAddr         fromAddr;
    CmInetMemInfo      memInfo;
    PnfP5SctpSockPollParams pnfP5PollParams;
+   
+   char msg[255];
 
    memset(&pnfP5PollParams, 0, sizeof(PnfP5SctpSockPollParams));
     
@@ -335,9 +342,22 @@ uint8_t pnfP5SctpSockPoll()
       {
          if((ret = pnfP5ProcessPolling(&pnfP5PollParams, &pnfP5SctpCb.assocCb[assocIdx], timeoutPtr, &memInfo)) != ROK)
          {
-            DU_LOG("\nERROR  -->  SCTP : Failed to RecvMsg for PNF at P5 Interface \n");
+            DU_LOG("\nERROR  -->  P5_SCTP : Failed to RecvMsg for PNF at P5 Interface \n");
          }
       }
+
+      /* Receiving UDP data */
+      pnfP7UdpBufLen = -1;
+      ret = cmInetRecvMsg(&(pnfP7Cb.sockFd), &fromAddr, &memInfo, &pnfP7UdpBuf, &pnfP7UdpBufLen, CM_INET_NO_FLAG);
+      if(ret == ROK && pnfP7UdpBuf != NULLP)
+      {
+          if((fromAddr.port == pnfP7Cb.srcAddr.port) && (fromAddr.address == pnfP7Cb.srcAddr.address))
+          {
+               DU_LOG("\nINFO  -->  P7_UDP : Received P7 Message [%ld] \n", numMsgRcvd+1);
+               numMsgRcvd++;
+               break;
+          }
+      }
    };
    return (ret);
 }/* End of sctpSockPoll() */