From 4bd542d78bfdbd373fd203a38bd2adb39702598f Mon Sep 17 00:00:00 2001 From: pborla Date: Wed, 5 Jun 2024 10:48:14 +0530 Subject: [PATCH] [Epic-Id: ODUHIGH-576][Task-Id: ODUHIGH-600][SubTask-Id: ODUHIGH-603]|[NFAPI_Branch]| PHY Config.Req, Config.Rsp, Start.Req and Start.Rsp Change-Id: I4bbc6e63435c3b866f0f5e375ba3c24bbd41a72a Signed-off-by: pborla --- src/5gnrmac/lwr_mac_ex_ms.c | 3 +- src/5gnrmac/lwr_mac_fsm.c | 348 +++++++++++++++++++++++++++++++++++-- src/5gnrmac/lwr_mac_phy.c | 1 - src/5gnrmac/lwr_mac_util.c | 130 ++++++++++++++ src/5gnrmac/lwr_mac_utils.h | 8 + src/5gnrmac/mac.h | 11 ++ src/5gnrmac/mac_cfg_hdl.c | 12 ++ src/5gnrmac/mac_msg_hdl.c | 9 +- src/5gnrmac/nfapi_common.c | 5 + src/pnf_stub/pnf_stub_p5_msg_hdl.c | 80 +++++++++ 10 files changed, 594 insertions(+), 13 deletions(-) diff --git a/src/5gnrmac/lwr_mac_ex_ms.c b/src/5gnrmac/lwr_mac_ex_ms.c index bdea2ee32..0b94d4911 100644 --- a/src/5gnrmac/lwr_mac_ex_ms.c +++ b/src/5gnrmac/lwr_mac_ex_ms.c @@ -19,6 +19,7 @@ /* This file is the entry point for Lower MAC */ #include "common_def.h" +#include #include "mac_utils.h" #include "lwr_mac.h" #include "lwr_mac_fsm.h" @@ -227,7 +228,7 @@ uint8_t sendParamRspToLowerMacFsm(Buffer *mBuf) vnfDb.p7TransInfo.destIpNetAddr.address = CM_INET_NTOH_UINT32(vnfDb.p7TransInfo.destIpv4Address); vnfDb.p7TransInfo.destIpNetAddr.port = vnfDb.p7TransInfo.destIpv4Port; DU_LOG("\nINFO --> LWR MAC: Sending param response message body buffer to lower mac"); - //sendEventToLowerMacFsm(PARAM_RESPONSE, 0, mBuf); TODO + sendEventToLowerMacFsm(PARAM_RESPONSE, 0, mBuf); return ROK; } #endif diff --git a/src/5gnrmac/lwr_mac_fsm.c b/src/5gnrmac/lwr_mac_fsm.c index d78540ec2..5b373e8ab 100644 --- a/src/5gnrmac/lwr_mac_fsm.c +++ b/src/5gnrmac/lwr_mac_fsm.c @@ -63,6 +63,8 @@ uint16_t fillUlTtiReq(SlotTimingInfo currTimingInfo, p_fapi_api_queue_elem_t pre uint16_t fillUlDciReq(SlotTimingInfo currTimingInfo, p_fapi_api_queue_elem_t prevElem, fapi_vendor_ul_dci_req_t *vendorUlDciReq); uint8_t lwr_mac_procStopReqEvt(SlotTimingInfo slotInfo, p_fapi_api_queue_elem_t prevElem, fapi_stop_req_vendor_msg_t *vendorMsg); + + void lwrMacLayerInit(Region region, Pool pool) { #ifdef INTEL_WLS_MEM @@ -1418,6 +1420,16 @@ uint8_t lwr_mac_procParamReqEvt(void *msg) uint8_t lwr_mac_procParamRspEvt(void *msg) { + +#ifdef NFAPI_ENABLED + if ((macCb.fapiMsgCompStatus.paramMsgComp >> 1) & 1) + { + 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; +#endif #ifdef INTEL_FAPI /* stopGuardTimer(); */ uint8_t index; @@ -2000,6 +2012,207 @@ uint8_t lwr_mac_procIqSamplesReqEvt(void *msg) } #endif +#ifdef NFAPI_ENABLED +/******************************************************************* + * + * @brief build and send config req to pnf + * + * @details + * + * Function : buildAndSendConfigReqToPnf + * + * Functionality: + * - build and send config req to pnf + * + * @params[in] + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ + +uint8_t buildAndSendConfigReqToPnf() +{ + uint32_t mib = 0; + uint16_t cellIdx =0; + MacCellCfg macCfgParams; + uint8_t timingModeInfo=0; + uint32_t dlFreq = 0, ulFreq = 0; + uint8_t vnfIp[4]; + Buffer *mBuf = NULLP; + Pst pst; + + macCfgParams = macCb.macCell[cellIdx]->macCellCfg; + + /* Fill Cell Configuration in lwrMacCb */ + memset(&lwrMacCb.cellCb[lwrMacCb.numCell], 0, sizeof(LwrMacCellCb)); + lwrMacCb.cellCb[lwrMacCb.numCell].cellId = macCfgParams.cellId; + lwrMacCb.cellCb[lwrMacCb.numCell].phyCellId = macCfgParams.cellCfg.phyCellId; + + DU_LOG("\nCall Flow: ENTMAC -> ENTLWRMAC : NFAPI P5 CONFIG_REQ %d\n",cellIdx); + + if (ODU_GET_MSG_BUF(MAC_MEM_REGION, MAC_POOL, &mBuf) != ROK) + { + DU_LOG("\nERROR --> NFAPI_VNF : Memory allocation failed in packPnfConfigReq"); + return RFAILED; + } + + //As per 5G nFAPI Specification, section 3.2.3 Config.request + nfapiFillP5Hdr(mBuf); + nfapiFillMsgHdr(mBuf, NFAPI_P5_PHY_ID, FAPI_CONFIG_REQUEST, 0); + + CMCHKPK(oduPackPostUInt8, 0, mBuf); //Error Code + + //As per 5G nFAPI Specification, Table 3-19 nFAPI TLVs included in + //CONFIG.request for IDLE and CONFIGURED states + if(timingModeInfo!=0) + { + CMCHKPK(oduPackPostUInt8, 7, mBuf); //Num TLVs = 7 + } + else + { + CMCHKPK(oduPackPostUInt8, 6, mBuf); //Num TLVs = 7 + } + + /* P7 VNF Address Ipv4 */ + extractVnfIp(vnfDb.p7TransInfo.srcIpNetAddr.address, vnfIp); + DU_LOG("Extracted vnfIp: %u.%u.%u.%u\n", vnfIp[0], vnfIp[1], vnfIp[2], vnfIp[3]); + fillTlvOfArrayOfUint8(mBuf, TAG_NFAPI_P7_VNF_ADD_IPV4, sizeof(vnfIp), vnfIp); + + /* P7 VNF Port */ + fillTlvOfSizeUint16(mBuf, TAG_NFAPI_P7_VNF_PORT, sizeof(uint16_t), vnfDb.p7TransInfo.srcIpNetAddr.port); + + /*P7 Transport*/ + fillTlvOfSizeUint8(mBuf, TAG_NFAPI_P7_TRANSPORT, sizeof(uint8_t), 1); + + /*Timing window*/ + fillTlvOfSizeUint16(mBuf, TAG_NFAPI_TIMING_WINDOW, sizeof(uint8_t), 0); + + /*Timing info mode*/ + fillTlvOfSizeUint8(mBuf, TAG_NFAPI_TIMING_INFO_MODE, sizeof(uint8_t), timingModeInfo); + + /*Timing info period*/ + if(timingModeInfo !=0) + { + fillTlvOfSizeUint8(mBuf, TAG_NFAPI_TIMING_INFO_PERIOD, sizeof(uint8_t), 1); + } + + /*5G_FAPI_MSG_BODY*/ + //As per 5G FAPI: PHY API, section 3.3.2.1 CONFIG.req, Table 3-20 + //Config.req message body +#ifndef NR_TDD + CMCHKPK(oduPackPostUInt8, 27, mBuf); //Num TLVs = 27 +#else + totalTlv = 27 + 1 + MAX_TDD_PERIODICITY_SLOTS * MAX_SYMB_PER_SLOT + CMCHKPK(oduPackPostUInt8, totalTlv, mBuf); //Num TLVs = 27 +#endif + + /* Carrier Config */ + fillTlvOfSizeUint16(mBuf, FAPI_DL_BANDWIDTH_TAG, sizeof(uint32_t), macCfgParams.carrCfg.dlBw); + dlFreq = convertArfcnToFreqKhz(macCfgParams.carrCfg.arfcnDL); + fillTlvOfSizeUint32(mBuf, FAPI_DL_FREQUENCY_TAG, sizeof(uint32_t), dlFreq); + //fillTlvOfArrayOfUint16(mBuf, FAPI_DL_K0_TAG, sizeof(uint16_t), macCfgParams.dlCarrCfg.k0[0]); + // fillTlvOfArrayOfUint16(mBuf, FAPI_DL_GRIDSIZE_TAG, sizeof(uint16_t), macCfgParams.dlCarrCfg.gridSize[0]); + fillTlvOfSizeUint16(mBuf, FAPI_NUM_TX_ANT_TAG, sizeof(uint16_t), macCfgParams.carrCfg.numTxAnt); + fillTlvOfSizeUint16(mBuf, FAPI_UPLINK_BANDWIDTH_TAG, sizeof(uint32_t), macCfgParams.carrCfg.ulBw); + ulFreq = convertArfcnToFreqKhz(macCfgParams.carrCfg.arfcnUL); + fillTlvOfSizeUint32(mBuf, FAPI_UPLINK_FREQUENCY_TAG, sizeof(uint32_t), ulFreq); + //fillTlvOfArrayOfUint16(mBuf, FAPI_UL_K0_TAG, sizeof(uint16_t), macCfgParams.ulCarrCfg.k0[0]); + //fillTlvOfArrayOfUint16(mBuf, FAPI_UL_GRID_SIZE_TAG, sizeof(uint16_t), macCfgParams.ulCarrCfg.gridSize[0]); + fillTlvOfSizeUint16(mBuf, FAPI_NUM_RX_ANT_TAG, sizeof(uint16_t), macCfgParams.carrCfg.numRxAnt); + fillTlvOfSizeUint8(mBuf, FAPI_FREQUENCY_SHIFT_7P5_KHZ_TAG,sizeof(uint8_t), 0); + + /* fill cell config */ + fillTlvOfSizeUint16(mBuf, FAPI_PHY_CELL_ID_TAG, sizeof(uint8_t), macCfgParams.cellCfg.phyCellId); + fillTlvOfSizeUint8(mBuf, FAPI_FRAME_DUPLEX_TYPE_TAG, sizeof(uint8_t), macCfgParams.cellCfg.dupType); + + /* fill SSB configuration */ + fillTlvOfSizeUint32(mBuf, FAPI_SS_PBCH_POWER_TAG, sizeof(uint32_t), macCfgParams.ssbCfg.ssbPbchPwr); + fillTlvOfSizeUint8(mBuf, FAPI_BCH_PAYLOAD_TAG, sizeof(uint8_t), macCfgParams.ssbCfg.bchPayloadFlag); + fillTlvOfSizeUint8(mBuf, FAPI_SCS_COMMON_TAG, sizeof(uint8_t), macCfgParams.ssbCfg.scsCmn); + + /* fill PRACH configuration */ + //fillTlvOfSizeUint8(mBuf, FAPI_PRACH_SEQUENCE_LENGTH_TAG, sizeof(uint8_t), macCfgParams.prachCfg.prachSeqLen); + fillTlvOfSizeUint8(mBuf, FAPI_PRACH_SUBC_SPACING_TAG, sizeof(uint8_t), convertScsValToScsEnum(macCfgParams.prachCfg.prachSubcSpacing)); + fillTlvOfSizeUint8(mBuf, FAPI_RESTRICTED_SET_CONFIG_TAG, sizeof(uint8_t), macCfgParams.prachCfg.prachRstSetCfg); + fillTlvOfSizeUint8(mBuf, FAPI_NUM_PRACH_FD_OCCASIONS_TAG, sizeof(uint8_t), macCfgParams.prachCfg.msg1Fdm); + fillTlvOfSizeUint8(mBuf, FAPI_PRACH_CONFIG_INDEX_TAG, sizeof(uint8_t), macCfgParams.prachCfg.prachCfgIdx); + fillTlvOfSizeUint16(mBuf, FAPI_PRACH_ROOT_SEQUENCE_INDEX_TAG, sizeof(uint16_t), macCfgParams.prachCfg.fdm[0].rootSeqIdx); + //fillTlvOfSizeUint8(mBuf, FAPI_NUM_ROOT_SEQUENCES_TAG, sizeof(uint8_t), macCfgParams.prachCfg.fdm[0].numRootSeq); + fillTlvOfSizeUint16(mBuf, FAPI_K1_TAG, sizeof(uint16_t), macCfgParams.prachCfg.fdm[0].k1); + fillTlvOfSizeUint8(mBuf, FAPI_PRACH_ZERO_CORR_CONF_TAG , sizeof(uint8_t), macCfgParams.prachCfg.fdm[0].zeroCorrZoneCfg); + //fillTlvOfSizeUint16(mBuf, FAPI_NUM_UNUSED_ROOT_SEQUENCES_TAG, sizeof(uint8_t), macCfgParams.prachCfg.fdm[0].numUnusedRootSeq); + /* if(macCfgParams.prachCfg.fdm[0].numUnusedRootSeq) + { + for(idx = 0; idx < macCfgParams.prachCfg.fdm[0].numUnusedRootSeq; idx++) + fillTlvOfSizeUint16(mBuf, FAPI_UNUSED_ROOT_SEQUENCES_TAG, \ + sizeof(uint16_t), macCfgParams.prachCfg.fdm[0].unsuedRootSeq[idx]); + } + else + { + macCfgParams.prachCfg.fdm[0].unsuedRootSeq = NULL; + }*/ + + fillTlvOfSizeUint8(mBuf, FAPI_SSB_PER_RACH_TAG, sizeof(uint8_t), macCfgParams.prachCfg.ssbPerRach); + //fillTlvOfSizeUint8(mBuf, FAPI_PRACH_MULTIPLE_CARRIERS_IN_A_BAND_TAG, sizeof(uint8_t), macCfgParams.prachCfg.prachMultCarrBand); + +#ifdef NR_TDD + /* fill TDD table */ + fillTlvOfSizeUint8(mBuf, FAPI_TDD_PERIOD_TAG, sizeof(uint8_t), macCfgParams.tddCfg.tddPeriod); + + for(slotIdx =0 ;slotIdx < MAX_TDD_PERIODICITY_SLOTS; slotIdx++) + { + for(symbolIdx = 0; symbolIdx < MAX_SYMB_PER_SLOT; symbolIdx++) + { + /*Fill Full-DL Slots as well as DL symbols ini 1st Flexi Slo*/ + if(slotIdx < macCfgParams.tddCfg.nrOfDlSlots || \ + (slotIdx == macCfgParams.tddCfg.nrOfDlSlots && symbolIdx < macCfgParams.tddCfg.nrOfDlSymbols)) + { + fillTlvOfSizeUint8(mBuf, FAPI_SLOT_CONFIG_TAG, sizeof(uint8_t), DL_SYMBOL); + } + + /*Fill Full-FLEXI SLOT and as well as Flexi Symbols in 1 slot preceding FULL-UL slot*/ + else if(slotIdx < (MAX_TDD_PERIODICITY_SLOTS - macCfgParams.tddCfg.nrOfUlSlots -1) || \ + (slotIdx == (MAX_TDD_PERIODICITY_SLOTS - macCfgParams.tddCfg.nrOfUlSlots -1) && \ + symbolIdx < (MAX_SYMB_PER_SLOT - macCfgParams.tddCfg.nrOfUlSymbols))) + { + fillTlvOfSizeUint8(mBuf, FAPI_SLOT_CONFIG_TAG, sizeof(uint8_t), FLEXI_SYMBOL); + } + /*Fill Partial UL symbols and Full-UL slot*/ + else + { + fillTlvOfSizeUint8(mBuf, FAPI_SLOT_CONFIG_TAG, sizeof(uint8_t), UL_SYMBOL); + } + } + } +#endif + + /* fill SSB table */ + fillTlvOfSizeUint16(mBuf, FAPI_SSB_OFFSET_POINT_A_TAG, sizeof(uint16_t), macCfgParams.ssbCfg.ssbOffsetPointA); + //fillTlvOfSizeUint8(mBuf, FAPI_BETA_PSS_TAG, sizeof(uint8_t), macCfgParams.ssbCfg.betaPss); + fillTlvOfSizeUint8(mBuf, FAPI_SSB_PERIOD_TAG, sizeof(uint8_t), macCfgParams.ssbCfg.ssbPeriod); + fillTlvOfSizeUint8(mBuf, FAPI_SSB_SUBCARRIER_OFFSET_TAG, sizeof(uint8_t), macCfgParams.ssbCfg.ssbScOffset); + + setMibPdu(macCfgParams.ssbCfg.mibPdu, &mib, 0); + fillTlvOfSizeUint32(mBuf, FAPI_MIB_TAG , sizeof(uint32_t), mib); + + fillTlvOfSizeUint32(mBuf, FAPI_SSB_MASK_TAG, sizeof(uint32_t), macCfgParams.ssbCfg.ssbMask[0]); + fillTlvOfSizeUint8(mBuf, FAPI_BEAM_ID_TAG, sizeof(uint8_t), macCfgParams.ssbCfg.beamId[0]); + //fillTlvOfSizeUint8(mBuf, FAPI_SS_PBCH_MULTIPLE_CARRIERS_IN_A_BAND_TAG, sizeof(uint8_t), macCfgParams.ssbCfg.multCarrBand); + //fillTlvOfSizeUint8(mBuf, FAPI_MULTIPLE_CELLS_SS_PBCH_IN_A_CARRIER_TAG, sizeof(uint8_t), macCfgParams.ssbCfg.multCellCarr); + + + /* fill measurement config */ + fillTlvOfSizeUint8(mBuf, FAPI_RSSI_MEASUREMENT_TAG, sizeof(uint8_t), 0); + + //TODO /* fill Beamforming Tables and fill Precoding Table */ + + DU_LOG("\nCall Flow: ENTMAC -> ENTLWRMAC : Sending P5 CONFIG_REQ\n"); + FILL_PST_LWR_MAC_TO_DUAPP(pst, EVENT_PNF_DATA); + return ODU_POST_TASK(&pst, mBuf); + +} +#endif + /******************************************************************* * * @brief Sends FAPI Config req to PHY @@ -2019,6 +2232,16 @@ uint8_t lwr_mac_procIqSamplesReqEvt(void *msg) uint8_t lwr_mac_procConfigReqEvt(void *msg) { + +#ifdef NFAPI_ENABLED + if(buildAndSendConfigReqToPnf() != ROK) + { + DU_LOG("\nERROR --> LWR_MAC: Failed to build and send config req"); + return RFAILED; + } + +#else + #ifdef INTEL_FAPI #ifdef CALL_FLOW_DEBUG_LOG DU_LOG("\nCall Flow: ENTMAC -> ENTLWRMAC : CONFIG_REQ\n"); @@ -2266,6 +2489,7 @@ uint8_t lwr_mac_procConfigReqEvt(void *msg) DU_LOG("\nDEBUG --> LWR_MAC: Sending Config Request to Phy"); LwrMacSendToL1(headerElem); +#endif #endif return ROK; @@ -2290,6 +2514,37 @@ uint8_t lwr_mac_procConfigReqEvt(void *msg) uint8_t lwr_mac_procConfigRspEvt(void *msg) { +#ifdef NFAPI_ENABLED + uint8_t errCode = 0; + DU_LOG("\nINFO --> LWR_MAC: Received EVENT[%d] at STATE[%d]", lwrMacCb.event, lwrMacCb.phyState); + + CMCHKPK(oduUnpackUInt8, &(errCode), msg); + + if(errCode == NFAPI_MSG_OK) + { + DU_LOG("\nDEBUG --> LWR_MAC: PHY has moved to Configured state \n"); + lwrMacCb.phyState = PHY_STATE_CONFIGURED; + lwrMacCb.cellCb[0].state = PHY_STATE_CONFIGURED; + /* TODO : + * Store config response into an intermediate + * struture and send to MAC + * Support LC and LWLC for sending config + * rsp to MAC + */ + fapiMacConfigRsp(lwrMacCb.cellCb[0].cellId); + if ((macCb.fapiMsgCompStatus.configMsgComp >> 1) & 1) + { + sendEventToLowerMacFsm(START_REQUEST, 0, NULL); + } + macCb.fapiMsgCompStatus.configMsgComp = (macCb.fapiMsgCompStatus.configMsgComp | 1); + } + else + { + DU_LOG("\nERROR --> NFAPI_VNF: Config response error code is not okay, errCode:%d", errCode); + return RFAILED; + } + +#else #ifdef INTEL_FAPI fapi_config_resp_t *configRsp; configRsp = (fapi_config_resp_t *)msg; @@ -2301,19 +2556,19 @@ uint8_t lwr_mac_procConfigRspEvt(void *msg) { if(configRsp->error_code == MSG_OK) { - DU_LOG("\nDEBUG --> LWR_MAC: PHY has moved to Configured state \n"); - lwrMacCb.phyState = PHY_STATE_CONFIGURED; - lwrMacCb.cellCb[0].state = PHY_STATE_CONFIGURED; - /* TODO : - * Store config response into an intermediate struture and send to MAC - * Support LC and LWLC for sending config rsp to MAC - */ - fapiMacConfigRsp(lwrMacCb.cellCb[0].cellId); + DU_LOG("\nDEBUG --> LWR_MAC: PHY has moved to Configured state \n"); + lwrMacCb.phyState = PHY_STATE_CONFIGURED; + lwrMacCb.cellCb[0].state = PHY_STATE_CONFIGURED; + /* TODO : + * Store config response into an intermediate struture and send to MAC + * Support LC and LWLC for sending config rsp to MAC + */ + fapiMacConfigRsp(lwrMacCb.cellCb[0].cellId); } else { - DU_LOG("\nERROR --> LWR_MAC: Invalid error code %d", configRsp->error_code); - return RFAILED; + DU_LOG("\nERROR --> LWR_MAC: Invalid error code %d", configRsp->error_code); + return RFAILED; } } else @@ -2321,6 +2576,7 @@ uint8_t lwr_mac_procConfigRspEvt(void *msg) DU_LOG("\nERROR --> LWR_MAC: Config Response received from PHY is NULL"); return RFAILED; } +#endif #endif return ROK; @@ -2344,6 +2600,27 @@ uint8_t lwr_mac_procConfigRspEvt(void *msg) * ****************************************************************/ uint8_t lwr_mac_procStartReqEvt(void *msg) { + +#ifdef NFAPI_ENABLED + + Buffer *mBuf = NULLP; + Pst pst; + + DU_LOG("\nCall Flow: ENTMAC -> ENTLWRMAC : NFAPI P5 START_REQ\n"); + if (ODU_GET_MSG_BUF(MAC_MEM_REGION, MAC_POOL, &mBuf) != ROK) + { + DU_LOG("\nERROR --> NFAPI_VNF : Memory allocation failed in StartReq"); + return RFAILED; + } + //As per 5G nFAPI Specification, section 3.2.5 START.request + nfapiFillP5Hdr(mBuf); + nfapiFillMsgHdr(mBuf, NFAPI_P5_PHY_ID, FAPI_START_REQUEST, 0); + + FILL_PST_LWR_MAC_TO_DUAPP(pst, EVENT_PNF_DATA); + return ODU_POST_TASK(&pst, mBuf); + +#else + #ifdef INTEL_FAPI #ifdef CALL_FLOW_DEBUG_LOG DU_LOG("\nCall Flow: ENTMAC -> ENTLWRMAC : START_REQ\n"); @@ -2406,10 +2683,52 @@ uint8_t lwr_mac_procStartReqEvt(void *msg) /* Send to PHY */ DU_LOG("\nDEBUG --> LWR_MAC: Sending Start Request to Phy"); LwrMacSendToL1(headerElem); +#endif #endif return ROK; } /* lwr_mac_procStartReqEvt */ +#ifdef NFAPI_ENABLED +/******************************************************************* + * + * @brief Build and send start response to phy + * + * @details + * + * Function : lwr_mac_procStartRspEvt + * + * Functionality: + * Build and send start response to phy + * + * @params[in] FAPI message pointer + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +uint8_t lwr_mac_procStartRspEvt(void *msg) +{ + uint8_t errCode = 0; + DU_LOG("\nINFO --> LWR_MAC: Received EVENT[%d] at STATE[%d]", lwrMacCb.event, lwrMacCb.phyState); + + CMCHKPK(oduUnpackUInt8, &(errCode), msg); + + if(errCode == NFAPI_MSG_OK) + { + if(lwrMacCb.phyState == PHY_STATE_CONFIGURED) + { + DU_LOG("\nINFO --> LWR_MAC: PHY has moved to running state"); + lwrMacCb.phyState = PHY_STATE_RUNNING; + lwrMacCb.cellCb[0].state = PHY_STATE_RUNNING; + } + } + else + { + DU_LOG("\nERROR --> NFAPI_VNF: Config response error code is not okay, errCode:%d", errCode); + return RFAILED; + } + return ROK; +} /* lwr_mac_procStartRspEvt */ +#endif /******************************************************************* * * @brief Sends FAPI Stop Req to PHY @@ -4911,6 +5230,9 @@ lwrMacFsmHdlr fapiEvtHdlr[MAX_STATE][MAX_EVENT] = lwr_mac_procConfigReqEvt, lwr_mac_procConfigRspEvt, lwr_mac_procInvalidEvt, +#ifdef NFAPI_ENABLED + lwr_mac_procInvalidEvt, +#endif lwr_mac_procInvalidEvt, }, { @@ -4923,6 +5245,9 @@ lwrMacFsmHdlr fapiEvtHdlr[MAX_STATE][MAX_EVENT] = lwr_mac_procConfigReqEvt, lwr_mac_procConfigRspEvt, lwr_mac_procStartReqEvt, +#ifdef NFAPI_ENABLED + lwr_mac_procStartRspEvt, +#endif lwr_mac_procInvalidEvt, }, { @@ -4935,6 +5260,9 @@ lwrMacFsmHdlr fapiEvtHdlr[MAX_STATE][MAX_EVENT] = lwr_mac_procConfigReqEvt, lwr_mac_procConfigRspEvt, lwr_mac_procInvalidEvt, +#ifdef NFAPI_ENABLED + lwr_mac_procInvalidEvt, +#endif lwr_mac_procInvalidEvt, } }; diff --git a/src/5gnrmac/lwr_mac_phy.c b/src/5gnrmac/lwr_mac_phy.c index e1232fc23..07163c584 100644 --- a/src/5gnrmac/lwr_mac_phy.c +++ b/src/5gnrmac/lwr_mac_phy.c @@ -278,7 +278,6 @@ uint8_t LwrMacSendToL1(void *msg) #ifndef NFAPI_ENABLED uint32_t msgLen =0; #endif - p_fapi_api_queue_elem_t currMsg = NULLP; #ifdef CALL_FLOW_DEBUG_LOG char message[100]; diff --git a/src/5gnrmac/lwr_mac_util.c b/src/5gnrmac/lwr_mac_util.c index 0fd3358be..1fe0a1f51 100644 --- a/src/5gnrmac/lwr_mac_util.c +++ b/src/5gnrmac/lwr_mac_util.c @@ -188,6 +188,136 @@ void convertFreqDomRsrcMapToIAPIFormat(uint8_t *sourceBitMap, uint8_t *destBitMa } } +#ifdef NFAPI_ENABLED +/********************************************************************************* + * + * @Function Name: fillTlvOfArrayOfUint16 + * + * + * @Functionality: + * fill tlv of array of size uint16 + * + * @params + * [IN]: Buffer, tag, length, value + * + * *******************************************************************************/ +void fillTlvOfArrayOfUint16(Buffer *mBuf, uint16_t tag, uint16_t length, uint16_t *value) +{ + uint8_t arraySize=5; + CMCHKPK(oduPackPostUInt16, tag, mBuf); + CMCHKPK(oduPackPostUInt16, length, mBuf); + for(uint8_t idx=0;idx> 24) & 0xFF; + bytes[1] = (vnfIp >> 16) & 0xFF; + bytes[2] = (vnfIp >> 8) & 0xFF; + bytes[3] = vnfIp & 0xFF; +} + +#endif + /********************************************************************** End of file **********************************************************************/ diff --git a/src/5gnrmac/lwr_mac_utils.h b/src/5gnrmac/lwr_mac_utils.h index ce9ba9179..6c5179b63 100644 --- a/src/5gnrmac/lwr_mac_utils.h +++ b/src/5gnrmac/lwr_mac_utils.h @@ -79,6 +79,14 @@ } void convertFreqDomRsrcMapToIAPIFormat(uint8_t *sourceBitMap, uint8_t *destBitMap); +#ifdef NFAPI_ENABLED +void fillTlvOfArrayOfUint16(Buffer *mBuf, uint16_t tag, uint16_t length, uint16_t *value); +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); +void fillTlvOfSizeUint16(Buffer *mBuf, uint16_t tag, uint16_t length, uint16_t value); +void fillTlvOfSizeUint32(Buffer *mBuf, uint16_t tag, uint16_t length, uint32_t value); +void extractVnfIp(uint32_t vnfIp, uint8_t bytes[4]); +#endif /********************************************************************** End of file **********************************************************************/ diff --git a/src/5gnrmac/mac.h b/src/5gnrmac/mac.h index d4a3f80cf..48702c0dc 100644 --- a/src/5gnrmac/mac.h +++ b/src/5gnrmac/mac.h @@ -256,6 +256,14 @@ typedef struct macStatistics * the statistics to be calculated at MAC */ }MacStatistics; +#ifdef NFAPI_ENABLED +typedef struct macNfapiMsgCompStatus +{ + uint8_t paramMsgComp; //0th(LSB) bit indicates PARAM_RSP received from PNF where as 1st bit indicates cell configuration confirmation received from SCH + uint8_t configMsgComp; //0th(LSB) bit indicates CONFIG_RSP received from PNF where as 1st bit indicates Cell start received from DU +}MacNfapiMsgCompStatus; +#endif + typedef struct macCb { Inst macInst; @@ -266,6 +274,9 @@ typedef struct macCb CmTimer tmrBlk[MAX_NUM_TIMER]; /*!< Timer Block */ MacCellCb *macCell[MAX_NUM_CELL]; MacStatistics statistics; +#ifdef NFAPI_ENABLED + MacNfapiMsgCompStatus fapiMsgCompStatus; +#endif }MacCb; /* global variable */ diff --git a/src/5gnrmac/mac_cfg_hdl.c b/src/5gnrmac/mac_cfg_hdl.c index 6f385c21a..7536fbbf0 100644 --- a/src/5gnrmac/mac_cfg_hdl.c +++ b/src/5gnrmac/mac_cfg_hdl.c @@ -193,6 +193,8 @@ uint8_t MacProcCellCfgReq(Pst *pst, MacCellCfg *macCellCfg) for(plmnIdx = 0; plmnIdx < MAX_PLMN; plmnIdx++) { macCb.macCell[cellIdx]->macCellCfg.cellCfg.plmnInfoList[plmnIdx].suppSliceList.numSupportedSlices = macCellCfg->cellCfg.plmnInfoList[plmnIdx].suppSliceList.numSupportedSlices; + if(macCb.macCell[cellIdx]->macCellCfg.cellCfg.plmnInfoList[plmnIdx].suppSliceList.numSupportedSlices ==0) + break; MAC_ALLOC(macCb.macCell[cellIdx]->macCellCfg.cellCfg.plmnInfoList[plmnIdx].suppSliceList.snssai, macCb.macCell[cellIdx]->macCellCfg.cellCfg.plmnInfoList[plmnIdx].suppSliceList.numSupportedSlices\ * sizeof(Snssai*)); if(macCb.macCell[cellIdx]->macCellCfg.cellCfg.plmnInfoList[plmnIdx].suppSliceList.snssai == NULLP) @@ -475,7 +477,17 @@ uint8_t MacProcSchCellCfgCfm(Pst *pst, SchCellCfgCfm *schCellCfgCfm) #ifdef INTEL_TIMER_MODE sendEventToLowerMacFsm(UL_IQ_SAMPLE, 0, (void *)cellId); #else + +#ifndef NFAPI_ENABLED sendEventToLowerMacFsm(CONFIG_REQUEST, 0, (void *)cellId); + #else + if(macCb.fapiMsgCompStatus.paramMsgComp & 1) + { + sendEventToLowerMacFsm(CONFIG_REQUEST, 0, (void *)cellId); + } + macCb.fapiMsgCompStatus.paramMsgComp = (macCb.fapiMsgCompStatus.paramMsgComp | (1 << 1)); +#endif + #endif } else diff --git a/src/5gnrmac/mac_msg_hdl.c b/src/5gnrmac/mac_msg_hdl.c index b26aa8681..09254c5d0 100644 --- a/src/5gnrmac/mac_msg_hdl.c +++ b/src/5gnrmac/mac_msg_hdl.c @@ -514,9 +514,16 @@ 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 gConfigInfo.gSlotCount = 0; sendEventToLowerMacFsm(START_REQUEST, 0, cellStart); - +#else + if (macCb.fapiMsgCompStatus.configMsgComp & 1) + { + sendEventToLowerMacFsm(START_REQUEST, 0, cellStart); + } + macCb.fapiMsgCompStatus.configMsgComp = (macCb.fapiMsgCompStatus.configMsgComp | (1 << 1)); +#endif MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cellStart, \ sizeof(CellStartInfo)); diff --git a/src/5gnrmac/nfapi_common.c b/src/5gnrmac/nfapi_common.c index 1607f47b5..30aabb128 100644 --- a/src/5gnrmac/nfapi_common.c +++ b/src/5gnrmac/nfapi_common.c @@ -226,6 +226,11 @@ uint8_t convertNfapiP5TagValToMsgId(uint16_t tagVal, NfapiPnfEvent *nfapiPnfEven *(phyEvent) = STOP_REQUEST; break; } + case TAG_NFAPI_START_RESPONSE: + { + *(phyEvent) = START_RESPONSE; + break; + } default: { DU_LOG("\n Incorrect TAG VALUE of NFAPI P5 Messages:%d",tagVal); diff --git a/src/pnf_stub/pnf_stub_p5_msg_hdl.c b/src/pnf_stub/pnf_stub_p5_msg_hdl.c index b8b9fc222..35a567318 100644 --- a/src/pnf_stub/pnf_stub_p5_msg_hdl.c +++ b/src/pnf_stub/pnf_stub_p5_msg_hdl.c @@ -348,6 +348,73 @@ uint8_t buildAndSendParamResp() return ROK; } +/********************************************************************************* + * + * @Function Name: buildAndSendConfigResp + * + * @Functionality: + * Build Config rsp as per 5G nFAPI Specification 3.2.4 CONFIG.response + * And Send to VNF + * + * *******************************************************************************/ + +uint8_t buildAndSendConfigResp() +{ + Buffer *mBuf = NULLP; + + if (ODU_GET_MSG_BUF(PNF_APP_MEM_REG, PNF_POOL, &mBuf) != ROK) + { + DU_LOG("\nERROR --> NFAPI_PNF : Memory allocation failed in %s",__func__); + return RFAILED; + } + + nfapiFillP5Hdr(mBuf); + nfapiFillMsgHdr(mBuf, 0, FAPI_CONFIG_RESPONSE, 0); + + //As per 5G nFAPI Specification, section 3.2.4 CONFIG.response + CMCHKPK(oduPackPostUInt8, 0, mBuf); //Error Code + + DU_LOG("\nINFO --> NFAPI_PNF: Sending CONFIG_RESP "); + if(pnfP5SctpSend(mBuf) == RFAILED) + { + ODU_PUT_MSG_BUF(mBuf); + } + return ROK; +} + +/********************************************************************************* + * + * @Function Name: buildAndSendStartResp + * + * @Functionality: + * Build Start rsp as per 5G nFAPI Specification 3.1.9 START.response + * And Send to VNF + * + * + *******************************************************************************/ + +uint8_t buildAndSendStartResp() +{ + Buffer *mBuf = NULLP; + + if (ODU_GET_MSG_BUF(PNF_APP_MEM_REG, PNF_POOL, &mBuf) != ROK) + { + DU_LOG("\nERROR --> NFAPI_PNF : Memory allocation failed in start response"); + return RFAILED; + } + + nfapiFillP5Hdr(mBuf); + nfapiFillMsgHdr(mBuf, 0, TAG_NFAPI_START_RESPONSE, 0); + + CMCHKPK(oduPackPostUInt8, 0, mBuf); //Error Code + + DU_LOG("\nINFO --> NFAPI_PNF: Sending START_RESP "); + if(pnfP5SctpSend(mBuf) == RFAILED) + { + ODU_PUT_MSG_BUF(mBuf); + } + return ROK; +} /********************************************************************************* * * @Function Name: p5MsgHandlerAtPnf @@ -396,10 +463,23 @@ uint8_t p5MsgHandlerAtPnf(Buffer *mBuf) } case FAPI_PARAM_REQUEST: { + sleep(1); DU_LOG("\nINFO --> NFAPI_PNF: PHY_PARAM_REQ recevied."); ret = buildAndSendParamResp(); break; } + case FAPI_CONFIG_REQUEST: + { + DU_LOG("\nINFO --> NFAPI_PNF: PHY_CONFIG_REQ recevied."); + ret = buildAndSendConfigResp(); + break; + } + case FAPI_START_REQUEST: + { + DU_LOG("\nINFO --> NFAPI_PNF: PHY_START_REQ recevied."); + ret = buildAndSendStartResp(); + break; + } default: { DU_LOG("\nERROR --> NFAPI_PNF: Wrong MSGID of NFAPI P5 Message:%d",msgHdr.msg_id); -- 2.16.6