#include "lwr_mac_sctp_inf.h"\r
#include "nfapi_interface.h"\r
#include "nfapi_common.h"\r
-#include "nfapi_vnf_fsm.h"\r
+#include "nfapi_udp_p7.h"\r
#endif\r
\r
/**************************************************************************\r
#ifdef NFAPI_ENABLED\r
case EVENT_PNF_DATA:\r
{\r
+ uint8_t retVal = RFAILED;\r
+\r
nFapi_p5_hdr p5Hdr;\r
nFapi_msg_header msgHdr;\r
EventState phyEvent;\r
}\r
else if(phyEvent != MAX_EVENT)\r
{\r
-\r
if(phyEvent == PARAM_RESPONSE)\r
{\r
if(sendParamRspToLowerMacFsm(mBuf) != ROK)\r
}\r
else\r
{\r
- sendEventToLowerMacFsm(phyEvent, msgHdr.length, mBuf); \r
+ retVal = sendEventToLowerMacFsm(phyEvent, msgHdr.length, mBuf);\r
+ if(phyEvent == START_RESPONSE && retVal == ROK)\r
+ {\r
+ DU_LOG("\nDEBUG --> NFAPI_VNF: Opening UDP Socket");\r
+ nfapiP7UdpOpenReq(); \r
+ }\r
}\r
}\r
ODU_PUT_MSG_BUF(mBuf);\r
DU_LOG("\nCall Flow: ENTMAC -> ENTLWRMAC : INVALID_EVENT\n");
#endif
DU_LOG("\nERROR --> LWR_MAC: Error Indication Event[%d] received in state [%d]", lwrMacCb.event, lwrMacCb.phyState);
- return ROK;
+ return RFAILED;
}
#ifdef INTEL_FAPI
return ODU_POST_TASK(&pst, mBuf);
#else
+
#ifdef INTEL_FAPI
#ifdef CALL_FLOW_DEBUG_LOG
DU_LOG("\nCall Flow: ENTMAC -> ENTLWRMAC : PARAM_REQ\n");
return RFAILED;
}
#endif
+
#endif
return ROK;
}
{
#ifdef NFAPI_ENABLED
+ uint8_t ret = ROK;
+
if ((macCb.fapiMsgCompStatus.paramMsgComp >> 1) & 1)
{
- sendEventToLowerMacFsm(CONFIG_REQUEST, 0, (void *)NULL);
+ ret = sendEventToLowerMacFsm(CONFIG_REQUEST, 0, (void *)NULL);
DU_LOG("\nINFO --> LWR_MAC: Received EVENT[%d] at STATE[%d]", lwrMacCb.event, lwrMacCb.phyState);
}
macCb.fapiMsgCompStatus.paramMsgComp = (macCb.fapiMsgCompStatus.paramMsgComp | 1);
- return ROK;
+ return ret;
#endif
#ifdef INTEL_FAPI
/* stopGuardTimer(); */
* Message Length
* Messaga Pointer
*
- * @return void
+ * @return ROK/RFAILED
*
******************************************************************/
-void sendEventToLowerMacFsm(uint16_t msgType, uint32_t msgLen, void *msg)
+uint8_t sendEventToLowerMacFsm(uint16_t msgType, uint32_t msgLen, void *msg)
{
+ uint8_t ret = RFAILED;
+
lwrMacCb.event = msgType;
- fapiEvtHdlr[lwrMacCb.phyState][lwrMacCb.event](msg);
+ ret = fapiEvtHdlr[lwrMacCb.phyState][lwrMacCb.event](msg);
+ return ret;
}
/**********************************************************************
uint8_t lwr_mac_procConfigReqEvt(void *msg);
uint8_t lwr_mac_procConfigRspEvt(void *msg);
uint8_t lwr_mac_procStartReqEvt(void *msg);
-void sendEventToLowerMacFsm(uint16_t, uint32_t, void *);
+uint8_t sendEventToLowerMacFsm(uint16_t, uint32_t, void *);
void procPhyMessages(uint16_t msgType, uint32_t msgSize, void *msg);
uint16_t fillDlTtiReq(SlotTimingInfo currTimingInfo);
typedef uint8_t (*lwrMacFsmHdlr)(void *);
#ifdef INTEL_FAPI
#ifndef NFAPI_ENABLED
uint32_t msgLen =0;
+ p_fapi_api_queue_elem_t currMsg = NULLP;
#endif
#ifdef CALL_FLOW_DEBUG_LOG
uint8_t MacProcCellStart(Pst *pst, CellStartInfo *cellStart)
{
DU_LOG("\nINFO --> MAC : Handling cell start request");
-#ifndef NFAPI_ENABLE
+#ifndef NFAPI_ENABLED
gConfigInfo.gSlotCount = 0;
sendEventToLowerMacFsm(START_REQUEST, 0, cellStart);
#else
}
break;
}
+#ifdef NFAPI_ENABLED
case ENTP7CLK:
{
strcpy(sourceTask,"ENTP7CLK");
}
break;
}
-
+#endif
default:
{
strcpy(sourceTask,"Invalid Source Entity Id");
case ENTLWRMAC:
MacHdlLwrMacEvents(pst, mBuf);
break;
+#ifdef NFAPI_ENABLED
case ENTP7CLK:
{
if(pst->event == EVENT_SLOT_IND_TO_MAC)
}
break;
}
+#endif
default:
RG_FREE_MSG(mBuf);
break;
/*Reference: SCF225_5G_NFAPI_SPECIFICATION, v225.2.1, Issue Date: 23 Nov 2021*/
/* header include files -- defines (.h) */
+#ifdef NFAPI_ENABLED
+
#include "common_def.h"
#include "mac_utils.h"
#include "lwr_mac.h"
*
*
* @Functionality:
- * It Fills NFAPI P5 Msg Header[as per Table 2-3 " nFapi Header"]
+ * It Fills NFAPI P5 Msg Header[as per Table 2-3 " P5 nFapi Header"]
*
*
* @params
void nfapiFillP5Hdr(Buffer *mBuf)
{
- uint8_t moreSeqNum = 0;
- moreSeqNum = NFAPI_MORE_SEG_NUM(NFAPI_P5_MORE, NFAPI_P5_SEG_NUM);
+ uint8_t moreSegNum = 0;
+ moreSegNum = NFAPI_MORE_SEG_NUM(NFAPI_P5_MORE, NFAPI_P5_SEG_NUM);
CMCHKPK(oduPackPostUInt16, NFAPI_P5_SEG_NUM, mBuf);
- CMCHKPK(oduPackPostUInt8, moreSeqNum, mBuf);
+ CMCHKPK(oduPackPostUInt8, moreSegNum, mBuf);
CMCHKPK(oduPackPostUInt8, vnfDb.p5Info.seqNum, mBuf);
CMCHKPK(oduPackPostUInt32, NFAPI_P5_TIMESTAMP, mBuf);
}
+/*********************************************************************************
+ *
+ * @Function Name: nFapiFillP7Hdr
+ *
+ *
+ * @Functionality:
+ * It Fills NFAPI P7 Msg Header[as per Table 2-5 " P7 nFapi Header"]
+ *
+ *
+ * @params [IN]:Buffer *mBuf,uint32_t totSduLen, uint32_t byteOffset, uint32_t time
+ * [OUT]: void
+ *
+ * *******************************************************************************/
+
+void nfapiFillP7Hdr(Buffer *mBuf,uint32_t totSduLen, uint32_t byteOffset, uint32_t time)
+{
+ CMCHKPK(oduPackPostUInt16, 0, mBuf);
+ CMCHKPK(oduPackPostUInt32, totSduLen, mBuf);
+ CMCHKPK(oduPackPostUInt32, byteOffset, mBuf);
+ CMCHKPK(oduPackPostUInt32, time, mBuf);
+
+}
+
/*********************************************************************************
*
* @Function Name: nFapiFillMsgHdr
*
*
* @Functionality:
- * It extracts NFAPI P5 Message Header[as per Table 2-5 "P5 nFapi Header"]
+ * It extracts NFAPI P5 Message Header[as per Table 2-3 "P5 nFapi Header"]
*
*
* @params
p5Hdr->seg_len,p5Hdr->more_segNum,p5Hdr->seq_num,p5Hdr->timeStamp);
}
+/*********************************************************************************
+ *
+ * @Function Name: nFapiExtractP7Hdr
+ *
+ *
+ * @Functionality:
+ * It extracts NFAPI P7 Message Header[as per Table 2-5 "P7 nFapi Header"]
+ *
+ *
+ * @params
+ * [IN]: Msg Buffer received in UDP P7 Interface
+ * [OUT]: nFapi_p7_hdr *p7Hdr
+ *
+ * *******************************************************************************/
+
+void nFapiExtractP7Hdr(nFapi_p7_hdr *p7Hdr, Buffer *mBuf)
+{
+ CMCHKPK(oduUnpackUInt16, &(p7Hdr->seq_num), mBuf);
+ CMCHKPK(oduUnpackUInt32, &(p7Hdr->tot_SDU_len), mBuf);
+ CMCHKPK(oduUnpackUInt32, &(p7Hdr->byteOffset), mBuf);
+ CMCHKPK(oduUnpackUInt32, &(p7Hdr->timeStamp), mBuf);
+ DU_LOG("\nINFo --> NFAPI_VNF: se1_num:%d, totSdu len:%u, byteOffset:%u, timeStamp:%u",
+ p7Hdr->seq_num,p7Hdr->tot_SDU_len, p7Hdr->byteOffset, p7Hdr->timeStamp);
+}
+
/*********************************************************************************
*
* @Function Name: nFapiExtractMsgHdr
}
return ROK;
}
+#endif
+
#define NFAPI_P7_CLK_MEM_REGION 6
#define NFAPI_P7_CLK_POOL 2
+#define NFAPI_P7_SEG_NUM 0
+
#ifdef ODU_MEMORY_DEBUG_LOG
#define NFAPI_UDP_P7_MEM_LOG(_macro, _file, _line, _func, _size, _datPtr)\
{\
} \
}
+#define CALC_NEXT_SFN_SLOT(_frameInfo)\
+{ \
+ if((_frameInfo.slot + 1) >= NUM_SLOTS_PER_SUBFRAME) \
+ { \
+ _frameInfo.sfn++; \
+ } \
+ _frameInfo.slot = (_frameInfo.slot + 1) % NUM_SLOTS_PER_SUBFRAME; \
+ if(_frameInfo.sfn >= 1024) \
+ { \
+ _frameInfo.sfn = _frameInfo.sfn % 1024; \
+ } \
+}
+
+#define CALC_TIME_USEC_FROM_SFNSLOT(_frameInfo) (_frameInfo.sfn * 10000) + (_frameInfo.slot * PER_TTI_TIME_USEC)
+
+/*Global Variable*/
+uint32_t PER_TTI_TIME_USEC;
+uint8_t NUM_SLOTS_PER_SUBFRAME;
+
/*Common Functions*/
void nfapiFillP5Hdr(Buffer *mBuf);
void nfapiFillMsgHdr(Buffer *mBuf, uint8_t phyId, uint16_t msgId, uint32_t msglen);
-
+void nfapiFillP7Hdr(Buffer *mBuf,uint32_t totSduLen, uint32_t byteOffset, uint32_t time);
void nFapiExtractP5Hdr(nFapi_p5_hdr *p5Hdr, Buffer *mBuf);
void nFapiExtractMsgHdr(nFapi_msg_header *msgHdr, Buffer *mBuf);
/* This file is the entry point for NFAPI P7 CLOCK*/
+#ifdef NFAPI_ENABLED
#include "common_def.h"
+#include "lwr_mac.h"
#include "nfapi_interface.h"
#include "nfapi_common.h"
#include "lwr_mac_upr_inf.h"
#include "mac_utils.h"
+#include "nfapi_p7_msg_hdl.h"
+
+extern uint32_t PER_TTI_TIME_USEC;
+extern uint8_t NUM_SLOTS_PER_SUBFRAME;
/**************************************************************************
* @brief Task Initiation callback function.
* ****************************************************************/
void nfapiGenerateTicks()
{
- float slotDur_ms = 1/pow(2,vnfDb.numerology);
+ float slotDur_ms = 0;
struct timespec tti_req = {0}, currTime = {0};
- uint8_t ratio = 2;
+ uint8_t ratio = 1;
uint32_t currTime_ns = 0;
/* Currently the code takes longer that one slot indication to execute.
* for L2 to complete one slot processing.
* The ratio must be removed once code optimization is complete */
- tti_req.tv_sec = 0;
- tti_req.tv_nsec = slotDur_ms * 1000000L * ratio;
while(true)
{
if(vnfDb.cellId == 0xFFFF)
/*Still Cell not configured thus skipping Slot Ind*/
continue;
}
- if((vnfDb.vnfP7Info.p7SyncInfo.slot == 0xFF && vnfDb.vnfP7Info.p7SyncInfo.sfn == 0xFFFF))
+
+ if((vnfDb.vnfP7Info.p7SyncInfo.frameInfo.slot == 0xFF && vnfDb.vnfP7Info.p7SyncInfo.frameInfo.sfn == 0xFFFF))
{
+ /*Calculating the Slot Duration*/
+ slotDur_ms = 1/pow(2,vnfDb.numerology);
+ tti_req.tv_sec = 0;
+ tti_req.tv_nsec = slotDur_ms * 1000000L * ratio;
+
clock_gettime(CLOCK_REALTIME, &currTime);
currTime_ns = currTime.tv_sec * 1000000000 + currTime.tv_nsec;
vnfDb.vnfP7Info.t_ref_ns = currTime_ns;
- DU_LOG("\nVNF_NFAPI : Starting to generate slot indications t_ref:%llu, slotDur:%f",\
- vnfDb.vnfP7Info.t_ref_ns, slotDur_ms);
+
+ PER_TTI_TIME_USEC = slotDur_ms * 1000;
+ NUM_SLOTS_PER_SUBFRAME = (pow(2, vnfDb.numerology) * 10);
+
+ vnfDb.vnfP7Info.p7SyncInfo.frameInfo.sfn++;
+ vnfDb.vnfP7Info.p7SyncInfo.frameInfo.slot++;
+ DU_LOG("\nVNF_NFAPI : Starting to generate slot indications t_ref:%llu, slotDur:%f, perTTi:%u, slotsPerFrame:%d, nanoSec:%d",\
+ vnfDb.vnfP7Info.t_ref_ns, slotDur_ms, PER_TTI_TIME_USEC, NUM_SLOTS_PER_SUBFRAME, tti_req.tv_nsec);
+ nfapiBuildAndSendDlNodeSync();
+ }
+ else
+ {
+ CALC_NEXT_SFN_SLOT(vnfDb.vnfP7Info.p7SyncInfo.frameInfo);
}
- vnfDb.vnfP7Info.p7SyncInfo.sfn++;
- vnfDb.vnfP7Info.p7SyncInfo.slot++;
#if 0
/*TODO: To enable when P5 messages are all done and implemented*/
if(nfapiSendSlotIndToMac() != ROK)
#ifdef ODU_SLOT_IND_DEBUG_LOG
DU_LOG("\nVNF_NFAPI --> DEBUG: SFN/Slot:%d,%d",\
- vnfDb.vnfP7Info.p7SyncInfo.sfn, vnfDb.vnfP7Info.p7SyncInfo.slot);
+ vnfDb.vnfP7Info.p7SyncInfo.frameInfo.sfn, vnfDb.vnfP7Info.p7SyncInfo.frameInfo.slot);
#endif
clock_nanosleep(CLOCK_REALTIME, 0, &tti_req, NULL);
}
if(slotInd)
{
slotInd->cellId = vnfDb.cellId;
- slotInd->sfn = vnfDb.vnfP7Info.p7SyncInfo.sfn;
- slotInd->slot = vnfDb.vnfP7Info.p7SyncInfo.slot;
+ slotInd->sfn = vnfDb.vnfP7Info.p7SyncInfo.frameInfo.sfn;
+ slotInd->slot = vnfDb.vnfP7Info.p7SyncInfo.frameInfo.slot;
pst.selector = ODU_SELECTOR_LWLC;
pst.srcEnt = ENTP7CLK;
pst.dstEnt = ENTMAC;
}
return ROK;
}
+#endif
/* This file is the entry point for P7 Msg Handling */
/*Reference SCF225 version: 225.2.1 */
+#ifdef NFAPI_ENABLED
#include "common_def.h"
+#include "mac_utils.h"
+#include "lwr_mac.h"
#include "nfapi_interface.h"
#include "nfapi_common.h"
-#include "nfapi_vnf_fsm.h"
+#include "nfapi_udp_p7.h"
extern NfapiVnfDb vnfDb;
-/*Following parameters can be referred to Table 4-1 Dl Node Sync Parameters*/
-void buildAndSendDlNodeSync()
+/*******************************************************************
+ *
+ * @brief Build and Sends DL_NODE_SYNC
+ *
+ * @details
+ *
+ * Function : nfapiBuildAndSendDlNodeSync
+ *
+ * Functionality:
+ * Build and Sends DL Node Synch
+ * (Params can be referred to Table 4-1 Dl Node Sync Parameters)
+ * @params[in]
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t nfapiBuildAndSendDlNodeSync()
{
uint32_t t1 = 0; /*Offset from VNF SFN/Slot 0/0 to the DL Node Sync Tx*/
- int32_t delta_sfn_slot = 0;
-
+ uint8_t scs = 0;
+ Buffer *mBuf = NULLP;
-
-}
+ if(ODU_GET_MSG_BUF(MAC_MEM_REGION, MAC_POOL, &mBuf) != ROK)
+ {
+ DU_LOG("\nERROR --> NFAPI_VNF : Memory allocation failed in packPnfParamReq");
+ return RFAILED;
+ }
+
+
+ t1 = CALC_TIME_USEC_FROM_SFNSLOT(vnfDb.vnfP7Info.p7SyncInfo.frameInfo);
+ scs = 15 * (pow(2, vnfDb.numerology));
+
+ nfapiFillP7Hdr(mBuf,( sizeof(nFapi_dl_node_sync_info) + sizeof(nFapi_msg_header)), 0, 0);
+ nfapiFillMsgHdr(mBuf, vnfDb.vnfP7Info.p7SyncInfo.phyId, TAG_NFAPI_DL_NODE_SYNC, sizeof(nFapi_dl_node_sync_info));
+ CMCHKPK(oduPackPostUInt32, t1, mBuf);
+ CMCHKPK(SPkPostS32, vnfDb.vnfP7Info.p7SyncInfo.delta_sfn_slot, mBuf);
+ CMCHKPK(oduPackPostUInt8, scs, mBuf);
+ return(nfapiP7UdpSendMsg(mBuf));
+}
+#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. #
+ ################################################################################
+ *******************************************************************************/
+
+/*Reference: SCF225_5G_NFAPI_SPECIFICATION, v225.2.1, Issue Date: 23 Nov 2021*/
+
+#ifndef _NFAPI_P7_MSG_HDL_H
+#define _NFAPI_P7_MSG_HDL_H
+
+uint8_t nfapiBuildAndSendDlNodeSync();
+
+#endif
*******************************************************************************/
/* This file is the entry point for UDP P7 */
+#ifdef NFAPI_ENABLED
#include "common_def.h"
#include "lwr_mac.h"
#include "du_app_p7udp_inf.h"
#include "nfapi_interface.h"
-#include "nfapi_vnf_fsm.h"
#include "nfapi_common.h"
/**************************************************************************
uint8_t nfapiP7UdpOpenReq()
{
-
uint8_t ret = ROK; /* Return value */
Pst nfapiP7Pst; /* Self post */
uint8_t sockType; /* Socket type */
return ret;
}
- DU_LOG("\nDEBUG --> NFAPI_VNF : Socket [%d] is open", vnfDb.p7TransInfo.sockFd.fd);
+ DU_LOG("\nDEBUG --> NFAPI_VNF : Socket [%d] is open", vnfDb.p7TransInfo.sockFd.fd);
/* Start Socket polling */
memset(&nfapiP7Pst, 0, sizeof(nfapiP7Pst));
packNfapiP7UdpStartPollingReq(&nfapiP7Pst);
/*Trigger P7 Clock as well */
+ DU_LOG("\nDEBUG --> NFAPI_VNF : Triggering Clock");
nfapiTriggerP7Clock();
return ret;
}
info.region = NFAPI_UDP_P7_MEM_REGION;
info.pool = NFAPI_UDP_P7_POOL;
+ DU_LOG("\n udp sending: add:0x%x, port:%d", vnfDb.p7TransInfo.destIpNetAddr.address, vnfDb.p7TransInfo.destIpNetAddr.port );
ret = cmInetSendMsg(&vnfDb.p7TransInfo.sockFd, &vnfDb.p7TransInfo.destIpNetAddr, &info, mBuf, (int16_t *)&txLen, CM_INET_NO_FLAG);
if(ret != ROK && ret != RWOULDBLOCK)
{
return ROK;
}
+#endif
/**********************************************************************
End of file
**********************************************************************/
-
/*******************************************************************************
################################################################################
# Copyright (c) [2017-2019] [Radisys] #
#define _NFAPI_UDP_P7_H__
uint8_t nfapiP7UdpOpenReq();
+uint8_t nfapiP7UdpSendMsg(Buffer *mBuf);
#endif
*******************************************************************************/
/*Reference: SCF225_5G_NFAPI_SPECIFICATION, v225.2.1, Issue Date: 23 Nov 2021*/
+#ifdef NFAPI_ENABLED
/* header include files -- defines (.h) */
#include "common_def.h"
#include "lwr_mac.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"
/*******************************************************************
*
memset(&vnfDb, 0, sizeof(NfapiVnfDb));
vnfDb.pnfStateAtVnf = PNF_STATE_IDLE;
vnfDb.pnfEvent = 0;
- vnfDb.vnfP7Info.p7SyncInfo.slot = 0xFF;
- vnfDb.vnfP7Info.p7SyncInfo.sfn = 0xFFFF;
+ vnfDb.vnfP7Info.p7SyncInfo.frameInfo.slot = 0xFF;
+ vnfDb.vnfP7Info.p7SyncInfo.frameInfo.sfn = 0xFFFF;
vnfDb.cellId = 0xFFFF;
}
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;
}
}
}
+#endif
/**********************************************************************
End of file
**********************************************************************/
NfapiTimingInfo vnfTimingCfg;
}NfapiPnfConfig;
+typedef struct nfapiFrameInfo
+{
+ uint16_t hSfn; /*Hyper System Frame Number*/
+ uint16_t sfn; /*System Frame Number*/
+ uint8_t slot; /*Sub Frame Number*/
+}NfapiFrameInfo;
+
typedef struct nfapiSyncInfo
{
- uint8_t phyId;
- uint8_t inSync;
- uint32_t prev_t1;
- uint32_t prev_t2;
- uint32_t prev_t3;
- uint16_t sfn;
- uint8_t slot;
- struct nfapiSyncInfo *next;
+ uint8_t phyId;
+ NfapiFrameInfo frameInfo;
+ uint8_t inSync;
+ uint32_t prev_t1;
+ uint32_t prev_t2;
+ uint32_t prev_t3;
+ int32_t delta_sfn_slot;
+ struct nfapiSyncInfo *next;
}NfapiSyncInfo;
typedef struct nfapiP7VnfInfo
S16 oduPackUInt16 ARGS((uint16_t val,Buffer *mBuf));
S16 oduPackPostUInt16 ARGS((uint16_t val,Buffer *mBuf));
S16 SPkS32 ARGS((S32 val,Buffer *mBuf));
+S16 SPkPostS32 ARGS((S32 val,Buffer *mBuf));
S16 oduPackUInt32 ARGS((uint32_t val,Buffer *mBuf));
S16 oduPackPostUInt32 ARGS((uint32_t val,Buffer *mBuf));
/* ssi_x_001.main_49 : added packing of F32 and F64*/
return ROK;
}
+#ifdef NFAPI_ENABLED
/*******************************************************************
*
* @brief Fill P7 UDP Parameters
}
return ROK;
}
+#endif
/*******************************************************************
*
/*Table 2-5*/
typedef struct nFapi_p7_hdr_t{
uint16_t seq_num; /*Sequence Number*/
- uint16_t pad; /*Padding for Byte alignment*/
uint32_t tot_SDU_len; /*Total SDU length*/
uint32_t byteOffset; /*Byte Offset: Offset specifying the start of a segment*/
uint32_t timeStamp; /*Transit TimeStamp*/
return (ret);
} /* end of SPkS32 */
+/*
+*
+* Fun: SPkPostS32
+*
+* Desc: This function packs a signed 32 bit value into a message.
+*
+* Ret: ROK - ok
+* RFAILED - failed, general (optional)
+* ROUTRES - failed, out of resources (optional)
+*
+* Notes: None
+*
+* File: ss_pack.c
+*
+*/
+
+S16 SPkPostS32
+(
+S32 val, /* value */
+Buffer *mBuf /* message buffer */
+)
+{
+ uint16_t tmp; /* temporary value */
+ Data pkArray[4]; /* packing array */
+ S16 ret; /* return code */
+
+ tmp = (uint16_t) GetHiWord(val);
+ pkArray[3] = (Data) GetHiByte(tmp);
+ pkArray[2] = (Data) GetLoByte(tmp);
+ tmp = (uint16_t) GetLoWord(val);
+ pkArray[1] = (Data) GetHiByte(tmp);
+ pkArray[0] = (Data) GetLoByte(tmp);
+
+ ret = SAddPstMsgMult(pkArray, (MsgLen) 4, mBuf);
+#if (ERRCLASS & ERRCLS_ADD_RES)
+ if (ret != ROK)
+ SSLOGERROR(ERRCLS_ADD_RES, ESS246, (ErrVal)ret, "SAddPstMsgMult() failed");
+#endif
+ return (ret);
+} /* end of SPkPostS32 */
+
\f
/*
*
#include "pnf_stub.h"
#include "pnf_stub_p5_msg_hdl.h"
-
-PnfGlobalCb pnfCb;
+extern uint32_t PER_TTI_TIME_USEC;
+extern uint8_t NUM_SLOTS_PER_SUBFRAME;
+extern PnfGlobalCb pnfCb;
void init_log()
{
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;
+ pnfCb.pnfCfgParams.pnfP7UdpParams.destIpv4Port = VNF_P7_UDP_PORT;
+
+ pnfCb.pnfSlotInfo.sfn = 0xFFFF;
+ pnfCb.pnfSlotInfo.slot = 0xFF;
} /* End of readPnfCfg */
+/*******************************************************************
+ *
+ * @brief Trigger Pnf Clock from this function
+ *
+ * @details
+ *
+ * Function : pnfClock
+ *
+ * Functionality:
+ * - This function will trigger the PNF clock generation
+ * and
+ *
+ * @params[in]
+ * @return void
+ *
+ * ****************************************************************/
+void *pnfClock()
+{
+ float slotDur_ms = 0;
+ struct timespec tti_req = {0}, currTime = {0};
+ uint8_t ratio = 1;
+ uint32_t currTime_ns = 0;
+
+ /* Currently the code takes longer that one slot indication to execute.
+ * Hence, multiplying slot time interval by 2 in order to give enough time
+ * for L2 to complete one slot processing.
+ * The ratio must be removed once code optimization is complete */
+
+ while(true)
+ {
+ if((pnfCb.pnfSlotInfo.slot == 0xFF && pnfCb.pnfSlotInfo.sfn == 0xFFFF))
+ {
+ /*Calculating the Slot Duration*/
+ slotDur_ms = 1/pow(2, NUMEROLOGY);
+ tti_req.tv_sec = 0;
+ tti_req.tv_nsec = slotDur_ms * 1000000L * ratio;
+
+ clock_gettime(CLOCK_REALTIME, &currTime);
+ currTime_ns = currTime.tv_sec * 1000000000 + currTime.tv_nsec;
+ pnfCb.pnfP7Info.t_ref_ns = currTime_ns;
+
+ PER_TTI_TIME_USEC = slotDur_ms * 1000;
+ NUM_SLOTS_PER_SUBFRAME = (pow(2,NUMEROLOGY) * 10);
+
+ pnfCb.pnfSlotInfo.sfn++;
+ pnfCb.pnfSlotInfo.slot++;
+ DU_LOG("\nPNF_NFAPI : Starting to generate slot indications t_ref:%llu, slotDur:%f, perTTi:%u, slotsPerFrame:%d, nanoSec:%d",\
+ pnfCb.pnfP7Info.t_ref_ns, slotDur_ms, PER_TTI_TIME_USEC, NUM_SLOTS_PER_SUBFRAME, tti_req.tv_nsec);
+ }
+ else
+ {
+ CALC_NEXT_SFN_SLOT(pnfCb.pnfSlotInfo);
+ }
+
+#ifdef ODU_SLOT_IND_DEBUG_LOG
+ DU_LOG("\nVNF_NFAPI --> DEBUG: SFN/Slot:%d,%d",\
+ pnfCb.pnfSlotInfo.sfn, pnfCb.pnfSlotInfo.slot);
+#endif
+ clock_nanosleep(CLOCK_REALTIME, 0, &tti_req, NULL);
+ }
+}
/*******************************************************************
*
uint8_t tst()
{
-#if 0
+#if 1
int retVal=0;
pthread_t conThrdId;
pthread_attr_t attr;
DU_LOG("\nINFO --> PNF_STUB : Starting PNF_STUB\n");
/* TODO: Start thread to receive console input */
-#if 0
- pthread_attr_init(&attr);
- pthread_attr_setstacksize(&attr, (size_t)NULLD);
- pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM);
- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
- retVal = pthread_create(&conThrdId, &attr, vnfConsoleHandler, NULLP);
- if(retVal != 0)
- {
- DU_LOG("\nERROR --> PNF_STUB : Thread creation failed. Cause %d", retVal);
- }
- pthread_attr_destroy(&attr);
-#endif
/* Read PNF configurations */
readPnfCfg();
/*Sleep is introduced for GDB to increase the waiting time for PNF Configuration from VNF*/
sleep(1);
+#if 1
+ pthread_attr_init(&attr);
+ pthread_attr_setstacksize(&attr, (size_t)NULLD);
+ pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM);
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+ retVal = pthread_create(&conThrdId, &attr, pnfClock, NULLP);
+ if(retVal != 0)
+ {
+ DU_LOG("\nERROR --> PNF_STUB : Thread creation failed. Cause %d", retVal);
+ }
+ pthread_attr_destroy(&attr);
+#endif
+
/* Start PNF-P5-SCTP to listen on incoming connection */
pnfP5SctpStartReq();
return;
}
+/*********************************************************************************
+ *
+ * @Function Name: nFapiFillP7Hdr
+ *
+ *
+ * @Functionality:
+ * It Fills NFAPI P7 Msg Header[as per Table 2-5 " P7 nFapi Header"]
+ *
+ *
+ * @params
+ * [OUT]: Msg Buffer to send in UDP P7 Interface
+ *
+ * *******************************************************************************/
+
+void nfapiFillP7Hdr(Buffer *mBuf,uint32_t totSduLen, uint32_t byteOffset, uint32_t time)
+{
+ CMCHKPK(oduPackPostUInt16, 0, mBuf);
+ CMCHKPK(oduPackPostUInt32, totSduLen, mBuf);
+ CMCHKPK(oduPackPostUInt32, byteOffset, mBuf);
+ CMCHKPK(oduPackPostUInt32, time, mBuf);
+
+}
+
+/*********************************************************************************
+ *
+ * @Function Name: nFapiExtractP7Hdr
+ *
+ *
+ * @Functionality:
+ * It extracts NFAPI P7 Message Header[as per Table 2-5 "P7 nFapi Header"]
+ *
+ *
+ * @params
+ * [IN]: Msg Buffer received in UDP P7 Interface
+ * [OUT]: nFapi_p7_hdr *p7Hdr
+ *
+ * *******************************************************************************/
+
+void nFapiExtractP7Hdr(nFapi_p7_hdr *p7Hdr, Buffer *mBuf)
+{
+ CMCHKPK(oduUnpackUInt16, &(p7Hdr->seq_num), mBuf);
+ CMCHKPK(oduUnpackUInt32, &(p7Hdr->tot_SDU_len), mBuf);
+ CMCHKPK(oduUnpackUInt32, &(p7Hdr->byteOffset), mBuf);
+ CMCHKPK(oduUnpackUInt32, &(p7Hdr->timeStamp), mBuf);
+ DU_LOG("\nINFo --> NFAPI_VNF: se1_num:%d, totSdu len:%u, byteOffset:%u, timeStamp:%u",
+ p7Hdr->seq_num,p7Hdr->tot_SDU_len, p7Hdr->byteOffset, p7Hdr->timeStamp);
+}
+
/*********************************************************************************
*
* @Function Name: convertIpStringToUInt8
#define NUM_PNF_P5_ASSOC 1
#define REMOTE_IP_DU (char*[]){"192.168.130.81", "192.168.130.83"}
+#define CALC_TIME_USEC_FROM_SFNSLOT(_frameInfo) (_frameInfo.sfn * 10000) + (_frameInfo.slot * PER_TTI_TIME_USEC)
+
+#define CALC_NEXT_SFN_SLOT(_frameInfo)\
+{ \
+ if((_frameInfo.slot + 1) >= NUM_SLOTS_PER_SUBFRAME) \
+ { \
+ _frameInfo.sfn++; \
+ } \
+ _frameInfo.slot = (_frameInfo.slot + 1) % NUM_SLOTS_PER_SUBFRAME; \
+ if(_frameInfo.sfn >= 1024) \
+ { \
+ _frameInfo.sfn = _frameInfo.sfn % 1024; \
+ } \
+}
+
+#define EXTRACT_SFN_SLOT_FROM_TIME(_t, _frameInfo) \
+{ \
+ unsigned int time; \
+ time = _t / PER_TTI_TIME_USEC; \
+ _frameInfo.sfn = time / NUM_SLOTS_PER_SUBFRAME; \
+ _frameInfo.slot = time % NUM_SLOTS_PER_SUBFRAME; \
+}
+
/*P7 UDP Teansport Cfg Details*/
#define PNF_P7_UDP_PORT 9876
+#define VNF_P7_UDP_PORT 6789
#define PNF_APP_MEM_REG 1
#define PNF_POOL 1
+#define NUMEROLOGY 0
+
+uint32_t PER_TTI_TIME_USEC;
+uint8_t NUM_SLOTS_PER_SUBFRAME;
+
typedef enum
{
PNF_IDLE,
PnfP7UdpParams pnfP7UdpParams;
}PnfCfgParams;
+typedef struct pnfSlotInfo
+{
+ uint16_t sfn;
+ uint8_t slot;
+}PnfSlotInfo;
+
+typedef struct pnfP7Info
+{
+ uint32_t t_ref_ns;
+}PnfP7Info;
+
typedef struct pnfGlobalCb
{
PnfCfgParams pnfCfgParams;
+ PnfSlotInfo pnfSlotInfo;
+ PnfP7Info pnfP7Info;
uint8_t numDu;
//DuDb duInfo[MAX_DU_SUPPORTED]; /*TODO: VNF Database can be added*/
}PnfGlobalCb;
-extern PnfGlobalCb pnfCb;
+PnfGlobalCb pnfCb;
uint8_t p5MsgHandlerAtPnf(Buffer *mBuf);
void nfapiFillP5Hdr(Buffer *mBuf);
void nfapiFillMsgHdr(Buffer *mBuf, uint8_t phyId, uint16_t msgId, uint32_t msgLen);
void nFapiExtractP5Hdr(nFapi_p5_hdr *p5Hdr, Buffer *mBuf);
void nFapiExtractMsgHdr(nFapi_msg_header *msgHdr, Buffer *mBuf);
+void nfapiFillP7Hdr(Buffer *mBuf,uint32_t totSduLen, uint32_t byteOffset, uint32_t time);
+void nFapiExtractP7Hdr(nFapi_p7_hdr *p7Hdr, Buffer *mBuf);
void convertIpStringToUInt8(const char *ip_str, uint8_t ip_address[]);
void fillTlvOfArrayOfUint8(Buffer *mBuf, uint16_t tag, uint16_t length, uint8_t *value);
void fillTlvOfSizeUint8(Buffer *mBuf, uint16_t tag, uint16_t length, uint8_t value);
uint8_t buildAndSendParamResp()
{
- uint8_t index = 0;
uint8_t pnfAdd[4];
Buffer *mBuf = NULLP;
uint32_t len = 20+sizeof(fapi_param_resp_t); //As per 5G nFAPI Specification, figure 2–21 Combined P5 message (PARAM.response),
* Ipv4 and P7 PNF Port */
convertIpStringToUInt8(LOCAL_IP_PNF, pnfAdd);
fillTlvOfArrayOfUint8(mBuf, TAG_NFAPI_P7_PNF_ADD_IPV4, sizeof(pnfAdd), pnfAdd); /* P7 PNF Address Ipv4 */
- fillTlvOfSizeUint16(mBuf, TAG_NFAPI_P7_PNF_PORT, sizeof(uint16_t), PNF_P5_SCTP_PORT); /* P7 PNF Port */
+ fillTlvOfSizeUint16(mBuf, TAG_NFAPI_P7_PNF_PORT, sizeof(uint16_t), PNF_P7_UDP_PORT); /* P7 PNF Port */
/* filling 5G_FAPI_MSG_BODY */
CMCHKPK(oduPackPostUInt16, TAG_NFAPI_5G_FAPI_MSG_BODY, mBuf); //5G_FAPI_MSG_BODY tag
--- /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 functions contains main() for pnf simulator */
+#include "common_def.h"
+#include <unistd.h>
+#include "pnf_stub_p5_msg_hdl.h"
+#include "nfapi_interface.h"
+#include "pnf_stub_sctp.h"
+#include "pnf_stub_p7_udp.h"
+#include "pnf_stub.h"
+
+extern PnfGlobalCb pnfCb;
+
+/*********************************************************************************
+ *
+ * @Function Name: pnfDlNodeSyncHandler
+ *
+ *
+ * @Functionality:
+ * Processes DL Node Sync i.e. Extracts the DL_NODE_SYNC and will generate
+ * UL_NODE_SYNC
+ *
+ * @Params [IN]: Message Buffer received at UDP NFAPI P7 Interface
+ *
+ * *******************************************************************************/
+uint8_t pnfDlNodeSyncHandler(Buffer *mBuf)
+{
+ nFapi_dl_node_sync_info dlNodeSync;
+ PnfSlotInfo vnfFrameInfo;
+
+ CMCHKPK(oduUnpackUInt32, &(dlNodeSync.t1), mBuf);
+ CMCHKPK(SUnpkS32, &(dlNodeSync.delta_sfnSlot), mBuf);
+ CMCHKPK(oduUnpackUInt8, &(dlNodeSync.scs), mBuf);
+
+ DU_LOG("\n PNF_NFAPI: t1:%u, delta:%d, scs:%d",dlNodeSync.t1, dlNodeSync.delta_sfnSlot, dlNodeSync.scs);
+
+ EXTRACT_SFN_SLOT_FROM_TIME(dlNodeSync.t1, vnfFrameInfo);
+ DU_LOG("\n dl node sync at VNF SFN:SLOT:%d/%d",vnfFrameInfo.sfn, vnfFrameInfo.slot);
+ //buildAndSendUlNodeSync(dlNodeSync.t1, dlNodeSync.delta_sfnSlot);
+ return ROK;
+}
+
+/*********************************************************************************
+ *
+ * @Function Name: pnfP7MsgHandler
+ *
+ *
+ * @Functionality:
+ * Handles the P7 MEssages at PNF SIM
+ *
+ * @Params [IN]: Message Buffer received at UDP NFAPI P7 Interface
+ *
+ * *******************************************************************************/
+uint8_t pnfP7MsgHandler(Buffer *mBuf)
+{
+ nFapi_p7_hdr p7Hdr;
+ nFapi_msg_header msgHdr;
+ uint8_t ret = ROK;
+
+ nFapiExtractP7Hdr(&p7Hdr, mBuf);
+ nFapiExtractMsgHdr(&msgHdr, mBuf);
+
+ switch(msgHdr.msg_id)
+ {
+ case TAG_NFAPI_DL_NODE_SYNC:
+ {
+ DU_LOG("\nINFO --> NFAPI_PNF: DL_NODE_SYNC recevied.");
+ ret = pnfDlNodeSyncHandler(mBuf);
+ break;
+ }
+ default:
+ {
+ DU_LOG("\nERROR --> NFAPI_PNF: Wrong MSGID of NFAPI P7 Message:%d",msgHdr.msg_id);
+ ret = RFAILED;
+ break;
+ }
+ }
+
+ if(ret == RFAILED)
+ {
+ return RFAILED;
+ }
+ return ret;
+}
+
+/**********************************************************************
+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. #
+################################################################################
+*******************************************************************************/
+
+uint8_t pnfP7MsgHandler(Buffer *mBuf);
+
+/**********************************************************************
+End of file
+**********************************************************************/
#include "common_def.h"
#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"
+#include "pnf_stub_p5_msg_hdl.h"
+#include "pnf_stub_p7_msg_hdl.h"
uint8_t socket_type; /* Socket type */
PnfP5SctpGlobalCb pnfP5SctpCb;
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))
+ if((fromAddr.port == pnfP7Cb.destAddr.port) && (fromAddr.address == pnfP7Cb.destAddr.address))
{
DU_LOG("\nINFO --> P7_UDP : Received P7 Message [%ld] \n", numMsgRcvd+1);
numMsgRcvd++;
+ pnfP7MsgHandler(pnfP7UdpBuf);
break;
}
}