From: svaidhya Date: Wed, 12 Jun 2024 07:41:18 +0000 (+0530) Subject: [Epic-Id: ODUHIGH-576][Task-Id: ODUHIGH-594][SubTask-Id: ODUHIGH-605]|[NFAPI_Branch... X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F58%2F12958%2F4;p=o-du%2Fl2.git [Epic-Id: ODUHIGH-576][Task-Id: ODUHIGH-594][SubTask-Id: ODUHIGH-605]|[NFAPI_Branch]|P7 DL NODE SYNC Change-Id: I087c89924b373637e3b3c365bb92184bc23906cb Signed-off-by: svaidhya --- diff --git a/src/5gnrmac/lwr_mac_ex_ms.c b/src/5gnrmac/lwr_mac_ex_ms.c index 0b94d4911..b387cad71 100644 --- a/src/5gnrmac/lwr_mac_ex_ms.c +++ b/src/5gnrmac/lwr_mac_ex_ms.c @@ -35,7 +35,7 @@ #include "lwr_mac_sctp_inf.h" #include "nfapi_interface.h" #include "nfapi_common.h" -#include "nfapi_vnf_fsm.h" +#include "nfapi_udp_p7.h" #endif /************************************************************************** @@ -333,6 +333,8 @@ uint8_t lwrMacActvTsk(Pst *pst, Buffer *mBuf) #ifdef NFAPI_ENABLED case EVENT_PNF_DATA: { + uint8_t retVal = RFAILED; + nFapi_p5_hdr p5Hdr; nFapi_msg_header msgHdr; EventState phyEvent; @@ -361,7 +363,6 @@ uint8_t lwrMacActvTsk(Pst *pst, Buffer *mBuf) } else if(phyEvent != MAX_EVENT) { - if(phyEvent == PARAM_RESPONSE) { if(sendParamRspToLowerMacFsm(mBuf) != ROK) @@ -374,7 +375,12 @@ uint8_t lwrMacActvTsk(Pst *pst, Buffer *mBuf) } else { - sendEventToLowerMacFsm(phyEvent, msgHdr.length, mBuf); + retVal = sendEventToLowerMacFsm(phyEvent, msgHdr.length, mBuf); + if(phyEvent == START_RESPONSE && retVal == ROK) + { + DU_LOG("\nDEBUG --> NFAPI_VNF: Opening UDP Socket"); + nfapiP7UdpOpenReq(); + } } } ODU_PUT_MSG_BUF(mBuf); diff --git a/src/5gnrmac/lwr_mac_fsm.c b/src/5gnrmac/lwr_mac_fsm.c index 5b373e8ab..9245efafb 100644 --- a/src/5gnrmac/lwr_mac_fsm.c +++ b/src/5gnrmac/lwr_mac_fsm.c @@ -110,7 +110,7 @@ uint8_t lwr_mac_procInvalidEvt(void *msg) 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 @@ -1354,6 +1354,7 @@ uint8_t lwr_mac_procParamReqEvt(void *msg) return ODU_POST_TASK(&pst, mBuf); #else + #ifdef INTEL_FAPI #ifdef CALL_FLOW_DEBUG_LOG DU_LOG("\nCall Flow: ENTMAC -> ENTLWRMAC : PARAM_REQ\n"); @@ -1397,6 +1398,7 @@ uint8_t lwr_mac_procParamReqEvt(void *msg) return RFAILED; } #endif + #endif return ROK; } @@ -1422,13 +1424,15 @@ uint8_t lwr_mac_procParamRspEvt(void *msg) { #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(); */ @@ -5282,13 +5286,16 @@ lwrMacFsmHdlr fapiEvtHdlr[MAX_STATE][MAX_EVENT] = * 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; } /********************************************************************** diff --git a/src/5gnrmac/lwr_mac_fsm.h b/src/5gnrmac/lwr_mac_fsm.h index b46c101a1..667a512b5 100644 --- a/src/5gnrmac/lwr_mac_fsm.h +++ b/src/5gnrmac/lwr_mac_fsm.h @@ -67,7 +67,7 @@ uint8_t lwr_mac_procParamRspEvt(void *msg); 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 *); diff --git a/src/5gnrmac/lwr_mac_phy.c b/src/5gnrmac/lwr_mac_phy.c index 07163c584..b2b075126 100644 --- a/src/5gnrmac/lwr_mac_phy.c +++ b/src/5gnrmac/lwr_mac_phy.c @@ -277,6 +277,7 @@ uint8_t LwrMacSendToL1(void *msg) #ifdef INTEL_FAPI #ifndef NFAPI_ENABLED uint32_t msgLen =0; + p_fapi_api_queue_elem_t currMsg = NULLP; #endif #ifdef CALL_FLOW_DEBUG_LOG diff --git a/src/5gnrmac/mac_msg_hdl.c b/src/5gnrmac/mac_msg_hdl.c index 09254c5d0..0e517b01c 100644 --- a/src/5gnrmac/mac_msg_hdl.c +++ b/src/5gnrmac/mac_msg_hdl.c @@ -514,7 +514,7 @@ uint8_t sendSchedRptToRlc(DlSchedInfo dlInfo, SlotTimingInfo slotInfo, uint8_t u 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 diff --git a/src/5gnrmac/mac_msg_router.c b/src/5gnrmac/mac_msg_router.c index 253d4eabc..db34b4421 100755 --- a/src/5gnrmac/mac_msg_router.c +++ b/src/5gnrmac/mac_msg_router.c @@ -523,6 +523,7 @@ void callFlowMacActvTsk(Pst *pst) } break; } +#ifdef NFAPI_ENABLED case ENTP7CLK: { strcpy(sourceTask,"ENTP7CLK"); @@ -537,7 +538,7 @@ void callFlowMacActvTsk(Pst *pst) } break; } - +#endif default: { strcpy(sourceTask,"Invalid Source Entity Id"); @@ -585,6 +586,7 @@ uint8_t macActvTsk(Pst *pst, Buffer *mBuf) case ENTLWRMAC: MacHdlLwrMacEvents(pst, mBuf); break; +#ifdef NFAPI_ENABLED case ENTP7CLK: { if(pst->event == EVENT_SLOT_IND_TO_MAC) @@ -593,6 +595,7 @@ uint8_t macActvTsk(Pst *pst, Buffer *mBuf) } break; } +#endif default: RG_FREE_MSG(mBuf); break; diff --git a/src/5gnrmac/nfapi_common.c b/src/5gnrmac/nfapi_common.c index 30aabb128..b079120b6 100644 --- a/src/5gnrmac/nfapi_common.c +++ b/src/5gnrmac/nfapi_common.c @@ -19,6 +19,8 @@ /*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" @@ -32,7 +34,7 @@ * * * @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 @@ -42,16 +44,39 @@ 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 @@ -82,7 +107,7 @@ void nfapiFillMsgHdr(Buffer *mBuf, uint8_t phyId, uint16_t msgId, uint32_t msgLe * * * @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 @@ -101,6 +126,31 @@ void nFapiExtractP5Hdr(nFapi_p5_hdr *p5Hdr, Buffer *mBuf) 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 @@ -239,3 +289,5 @@ uint8_t convertNfapiP5TagValToMsgId(uint16_t tagVal, NfapiPnfEvent *nfapiPnfEven } return ROK; } +#endif + diff --git a/src/5gnrmac/nfapi_common.h b/src/5gnrmac/nfapi_common.h index 15fa810c7..6642fc5d5 100644 --- a/src/5gnrmac/nfapi_common.h +++ b/src/5gnrmac/nfapi_common.h @@ -42,6 +42,8 @@ #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)\ {\ @@ -134,10 +136,29 @@ } \ } +#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); diff --git a/src/5gnrmac/nfapi_p7_clk.c b/src/5gnrmac/nfapi_p7_clk.c index d0c8f1b8b..a9a4fa0f8 100644 --- a/src/5gnrmac/nfapi_p7_clk.c +++ b/src/5gnrmac/nfapi_p7_clk.c @@ -31,12 +31,18 @@ /* 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. @@ -139,9 +145,9 @@ uint8_t nfapiP7ClkActvTsk(Pst *pst, Buffer *mBuf) * ****************************************************************/ 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. @@ -149,8 +155,6 @@ void nfapiGenerateTicks() * 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) @@ -158,16 +162,31 @@ void nfapiGenerateTicks() /*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) @@ -179,7 +198,7 @@ void nfapiGenerateTicks() #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); } @@ -253,8 +272,8 @@ uint8_t nfapiSendSlotIndToMac() 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; @@ -282,3 +301,4 @@ uint8_t nfapiSendSlotIndToMac() } return ROK; } +#endif diff --git a/src/5gnrmac/nfapi_p7_msg_hdl.c b/src/5gnrmac/nfapi_p7_msg_hdl.c index 82212edfa..a9855e845 100644 --- a/src/5gnrmac/nfapi_p7_msg_hdl.c +++ b/src/5gnrmac/nfapi_p7_msg_hdl.c @@ -18,22 +18,57 @@ /* 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 diff --git a/src/5gnrmac/nfapi_p7_msg_hdl.h b/src/5gnrmac/nfapi_p7_msg_hdl.h new file mode 100644 index 000000000..4ddd17024 --- /dev/null +++ b/src/5gnrmac/nfapi_p7_msg_hdl.h @@ -0,0 +1,26 @@ + /******************************************************************************* + ################################################################################ + # 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 diff --git a/src/5gnrmac/nfapi_udp_p7.c b/src/5gnrmac/nfapi_udp_p7.c index 12a0afdc2..0b5f8cd77 100644 --- a/src/5gnrmac/nfapi_udp_p7.c +++ b/src/5gnrmac/nfapi_udp_p7.c @@ -17,12 +17,12 @@ *******************************************************************************/ /* 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" /************************************************************************** @@ -260,7 +260,6 @@ uint8_t packNfapiP7UdpStartPollingReq(Pst *pst) uint8_t nfapiP7UdpOpenReq() { - uint8_t ret = ROK; /* Return value */ Pst nfapiP7Pst; /* Self post */ uint8_t sockType; /* Socket type */ @@ -276,7 +275,7 @@ uint8_t nfapiP7UdpOpenReq() 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)); @@ -292,6 +291,7 @@ uint8_t nfapiP7UdpOpenReq() packNfapiP7UdpStartPollingReq(&nfapiP7Pst); /*Trigger P7 Clock as well */ + DU_LOG("\nDEBUG --> NFAPI_VNF : Triggering Clock"); nfapiTriggerP7Clock(); return ret; } @@ -364,6 +364,7 @@ uint8_t nfapiP7UdpSendMsg(Buffer *mBuf) 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) { @@ -379,6 +380,7 @@ uint8_t nfapiP7UdpSendMsg(Buffer *mBuf) return ROK; } +#endif /********************************************************************** End of file **********************************************************************/ diff --git a/src/5gnrmac/nfapi_udp_p7.h b/src/5gnrmac/nfapi_udp_p7.h index a5739007d..90551feca 100644 --- a/src/5gnrmac/nfapi_udp_p7.h +++ b/src/5gnrmac/nfapi_udp_p7.h @@ -1,4 +1,3 @@ - /******************************************************************************* ################################################################################ # Copyright (c) [2017-2019] [Radisys] # @@ -23,5 +22,6 @@ #define _NFAPI_UDP_P7_H__ uint8_t nfapiP7UdpOpenReq(); +uint8_t nfapiP7UdpSendMsg(Buffer *mBuf); #endif diff --git a/src/5gnrmac/nfapi_vnf_fsm.c b/src/5gnrmac/nfapi_vnf_fsm.c index 82f547a26..98dbb9a3d 100644 --- a/src/5gnrmac/nfapi_vnf_fsm.c +++ b/src/5gnrmac/nfapi_vnf_fsm.c @@ -17,18 +17,17 @@ *******************************************************************************/ /*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" /******************************************************************* * @@ -48,8 +47,8 @@ void nFapiVnfInit() 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; } @@ -84,9 +83,6 @@ uint8_t nfapi_vnf_procPnfReadyIndEvt(nFapi_p5_hdr *p5Hdr, nFapi_msg_header *msgH 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; } @@ -584,6 +580,7 @@ void sendEventToNfapiVnfFsm(NfapiPnfEvent msgType, nFapi_p5_hdr *p5Hdr, nFapi_ms } } +#endif /********************************************************************** End of file **********************************************************************/ diff --git a/src/5gnrmac/nfapi_vnf_fsm.h b/src/5gnrmac/nfapi_vnf_fsm.h index 7b12cc151..17a0d7237 100644 --- a/src/5gnrmac/nfapi_vnf_fsm.h +++ b/src/5gnrmac/nfapi_vnf_fsm.h @@ -74,16 +74,23 @@ typedef struct nfapiPnfConfig 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 diff --git a/src/cm/ssi.x b/src/cm/ssi.x index 3613b12af..6f4b0208b 100755 --- a/src/cm/ssi.x +++ b/src/cm/ssi.x @@ -942,6 +942,7 @@ S16 SPkS16 ARGS((S16 val,Buffer *mBuf)); 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*/ diff --git a/src/du_app/du_cfg.c b/src/du_app/du_cfg.c index cf11003ce..d77d15d85 100644 --- a/src/du_app/du_cfg.c +++ b/src/du_app/du_cfg.c @@ -302,6 +302,7 @@ uint8_t parseEgtpParams(xmlDocPtr doc, xmlNsPtr ns, xmlNodePtr cur, F1EgtpParams return ROK; } +#ifdef NFAPI_ENABLED /******************************************************************* * * @brief Fill P7 UDP Parameters @@ -338,6 +339,7 @@ uint8_t parseP7UdpParams(xmlDocPtr doc, xmlNsPtr ns, xmlNodePtr cur, NfapiP7UdpC } return ROK; } +#endif /******************************************************************* * diff --git a/src/intel_fapi/nfapi_interface.h b/src/intel_fapi/nfapi_interface.h index 71c478b43..b2a9b91ba 100644 --- a/src/intel_fapi/nfapi_interface.h +++ b/src/intel_fapi/nfapi_interface.h @@ -110,7 +110,6 @@ typedef struct nFapi_p5_hdr_t{ /*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*/ diff --git a/src/mt/ss_pack.c b/src/mt/ss_pack.c index 218f4061b..bdbb0caeb 100644 --- a/src/mt/ss_pack.c +++ b/src/mt/ss_pack.c @@ -325,6 +325,47 @@ Buffer *mBuf /* message buffer */ 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 */ + /* * diff --git a/src/pnf_stub/pnf_stub.c b/src/pnf_stub/pnf_stub.c index 9797cab9c..4b9cb53d4 100644 --- a/src/pnf_stub/pnf_stub.c +++ b/src/pnf_stub/pnf_stub.c @@ -38,8 +38,9 @@ #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() { @@ -106,10 +107,74 @@ void readPnfCfg() 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); + } +} /******************************************************************* * @@ -131,7 +196,7 @@ void readPnfCfg() uint8_t tst() { -#if 0 +#if 1 int retVal=0; pthread_t conThrdId; pthread_attr_t attr; @@ -141,18 +206,6 @@ uint8_t tst() 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(); @@ -168,6 +221,19 @@ uint8_t tst() /*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(); @@ -272,6 +338,54 @@ void nFapiExtractMsgHdr(nFapi_msg_header *msgHdr, Buffer *mBuf) 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 diff --git a/src/pnf_stub/pnf_stub.h b/src/pnf_stub/pnf_stub.h index 427b2a402..d6fc85cdc 100644 --- a/src/pnf_stub/pnf_stub.h +++ b/src/pnf_stub/pnf_stub.h @@ -29,12 +29,41 @@ #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, @@ -51,19 +80,34 @@ typedef struct pnfCfgParams 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); diff --git a/src/pnf_stub/pnf_stub_p5_msg_hdl.c b/src/pnf_stub/pnf_stub_p5_msg_hdl.c index 35a567318..36d50e502 100644 --- a/src/pnf_stub/pnf_stub_p5_msg_hdl.c +++ b/src/pnf_stub/pnf_stub_p5_msg_hdl.c @@ -233,7 +233,6 @@ uint8_t buildAndSendPnfStopResp() 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), @@ -257,7 +256,7 @@ uint8_t buildAndSendParamResp() * 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 diff --git a/src/pnf_stub/pnf_stub_p7_msg_hdl.c b/src/pnf_stub/pnf_stub_p7_msg_hdl.c new file mode 100644 index 000000000..9c26588d2 --- /dev/null +++ b/src/pnf_stub/pnf_stub_p7_msg_hdl.c @@ -0,0 +1,117 @@ +/******************************************************************************* + * ################################################################################ + * # 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 +#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 +**********************************************************************/ diff --git a/src/pnf_stub/pnf_stub_p7_msg_hdl.h b/src/pnf_stub/pnf_stub_p7_msg_hdl.h new file mode 100644 index 000000000..12235d9a2 --- /dev/null +++ b/src/pnf_stub/pnf_stub_p7_msg_hdl.h @@ -0,0 +1,24 @@ + +/******************************************************************************* +################################################################################ +# 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 +**********************************************************************/ diff --git a/src/pnf_stub/pnf_stub_sctp.c b/src/pnf_stub/pnf_stub_sctp.c index 868d3554b..f79077437 100644 --- a/src/pnf_stub/pnf_stub_sctp.c +++ b/src/pnf_stub/pnf_stub_sctp.c @@ -21,9 +21,10 @@ #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; @@ -349,10 +350,11 @@ uint8_t pnfP5SctpSockPoll() 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; } }