<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>
<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>
return RFAILED;\r
}\r
sendEventToNfapiVnfFsm(msgType, &p5Hdr, &msgHdr, mBuf);\r
+ ODU_PUT_MSG_BUF(mBuf);\r
break;\r
}\r
#endif\r
#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"
/*********************************************************************************
#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);
void nFapiExtractMsgHdr(nFapi_msg_header *msgHdr, Buffer *mBuf);
NfapiPnfEvent convertNfapiP5TagValToMsgId(uint16_t tagVal);
+uint8_t nfapiP7UdpRecvMsg();
+
#endif
/* 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.
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
+**********************************************************************/
--- /dev/null
+
+ /*******************************************************************************
+ ################################################################################
+ # 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
/* 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"
/*******************************************************************
*
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;
}
#ifndef _NFAPI_VNF_FSM_H_
#define _NFAPI_VNF_FSM_H_
-#include "nfapi_interface.h"
-
typedef enum {
PNF_STATE_IDLE = 0,
PNF_STATE_CONFIGURED,
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*/
#include "lwr_mac_phy.h"
#ifdef NFAPI_ENABLED
+#include "nfapi_interface.h"
#include "nfapi_vnf_fsm.h"
#endif
--- /dev/null
+/*******************************************************************************
+################################################################################
+# 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
+ **********************************************************************/
--- /dev/null
+/*******************************************************************************
+################################################################################
+# 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
+ **********************************************************************/
#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 */
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
char *ricIpV4Addr;
#ifdef NFAPI_ENABLED
char *pnfP5IpV4Addr;
- CmInetIpAddr pnfP5Ip;
+ CmInetIpAddr pnfIp;
#endif
CmInetIpAddr duIp;
CmInetIpAddr cuIp;
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))
duCfgParam.sctpParams.ricIpAddr.ipV4Addr = ricIp;
#ifdef NFAPI_ENABLED
duCfgParam.sctpParams.pnfP5IpAddr.ipV4Pres = true;
- duCfgParam.sctpParams.pnfP5IpAddr.ipV4Addr = pnfP5Ip;
+ duCfgParam.sctpParams.pnfP5IpAddr.ipV4Addr = pnfIp;
#endif
}
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)
#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 */
MibParams mibParams; /* MIB Params */
Sib1Params sib1Params; /* SIB1 Params */
MacSliceCfgReq tempSliceCfg;
+#ifdef NFAPI_ENABLED
+ NfapiP7UdpCfg tempNFapiP7UdpCfg;
+#endif
}DuCfgParams;
#ifndef O1_ENABLE
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;
}
#endif
+#ifdef NFAPI_ENABLED
+#include "du_app_p7udp_inf.h"
+#endif
+
uint8_t rlcDlCfg = 0;
uint8_t numRlcDlSaps = 0;
uint8_t rlcUlCfg = 0;
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
*
{
//Start layer configs
ret = duSendRlcUlCfg();
+#ifdef NFAPI_ENABLED
+ ret = BuildAndSendNfapiP7UdpConfig();
+#endif
}
return ret;
}
+
/**************************************************************************
* @brief Function to invoke DU Layer Configs
*
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
**********************************************************************/
uint8_t BuildAndSendStatsDeleteReq(RicSubscription *ricSubscriptionInfo, bool deleteAllStats);
uint8_t BuildAndSendStatsModificationReqToMac(RicSubscription *ricSubscriptionInfo);
uint8_t BuildAndSendStatsModificationReq(RicSubscription *ricSubscriptionInfo);
-
+uint8_t BuildAndSendNfapiP7UdpConfig();
/**********************************************************************
End of file
#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) \
{ \
}
/*******************************************************************
- *
* @brief Builds and sends config response to lower mac
*
* @details
#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"
}
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 */
/* 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;
/**********************************************************************
End of file
**********************************************************************/
-
#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
uint32_t pnfId;
char pnfName[PNF_NAME_LEN_MAX];
PnfP5SctpParams pnfP5SctpParams;
+ PnfP7UdpParams pnfP7UdpParams;
}PnfCfgParams;
typedef struct pnfGlobalCb
--- /dev/null
+/*******************************************************************************
+################################################################################
+# 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;
+}
--- /dev/null
+/*******************************************************************************
+################################################################################
+# 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
+
#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 */
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));
{
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() */