X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Fdu_app%2Fdu_msg_hdl.c;h=9f402faee51972d0013a2ae9469a4c084d6f6b47;hb=ca0353e5cb5699aecb6840efe9572934a1150e2b;hp=16a4f393757a04b1d86e2700ee077fcd8b38c765;hpb=082b269b31990bb7ddc3b387e921bf7c68bf4292;p=o-du%2Fl2.git diff --git a/src/du_app/du_msg_hdl.c b/src/du_app/du_msg_hdl.c index 16a4f3937..9f402faee 100644 --- a/src/du_app/du_msg_hdl.c +++ b/src/du_app/du_msg_hdl.c @@ -36,14 +36,14 @@ #include "du_ue_mgr.h" #include "lsctp.h" #include "legtp.h" -#include "lphy_stub.h" #include "du_utils.h" #include "du_cell_mgr.h" #ifdef O1_ENABLE -#include "GlobalDefs.h" #include "AlarmInterface.h" +#include "CmInterface.h" +#include "PmInterface.h" #endif @@ -58,11 +58,11 @@ DuCfgParams duCfgParam; uint8_t packRlcConfigReq(Pst *pst, RlcMngmt *cfg); uint8_t cmPkLkwCntrlReq(Pst *pst, RlcMngmt *cfg); uint8_t cmPkLrgCfgReq(Pst *pst, RgMngmt *cfg); -uint8_t BuildAndSendE2SetupReq(); uint8_t egtpHdlDatInd(EgtpMsg egtpMsg); uint8_t BuildAndSendDUConfigUpdate(); uint16_t getTransId(); uint8_t cmPkLrgSchCfgReq(Pst * pst,RgMngmt * cfg); +uint8_t sendCellDeleteReqToMac(uint16_t cellId); packMacCellCfgReq packMacCellCfgOpts[] = { @@ -85,6 +85,20 @@ DuMacCellStop packMacCellStopOpts[] = packMacCellStop /* Light weight-loose coupling */ }; +DuMacSliceCfgReq packMacSliceCfgReqOpts[] = +{ + packDuMacSliceCfgReq, /* Loose coupling */ + MacProcSliceCfgReq, /* TIght coupling */ + packDuMacSliceCfgReq /* Light weight-loose coupling */ +}; + + +DuMacSliceRecfgReq packMacSliceRecfgReqOpts[] = +{ + packDuMacSliceRecfgReq, /* Loose coupling */ + MacProcSliceRecfgReq, /* TIght coupling */ + packDuMacSliceRecfgReq /* Light weight-loose coupling */ +}; /************************************************************************** * @brief Function to fill configs required by RLC * @@ -330,45 +344,46 @@ uint8_t duBuildRlcUsapCfg(uint8_t elemId, Ent ent, Inst inst) uint8_t duProcCfgComplete() { uint8_t ret = ROK; - static uint16_t cellId = 0; uint16_t idx; for(idx=0; idx< DEFAULT_CELLS; idx++) { DuCellCb *cell = NULLP; - DU_ALLOC(cell, sizeof(DuCellCb)) + DU_ALLOC(cell, sizeof(DuCellCb)); if(cell == NULLP) { - DU_LOG("\nERROR --> DU_APP : Memory Allocation failed in duProcCfgComplete"); - ret = RFAILED; + DU_LOG("\nERROR --> DU_APP : Memory Allocation failed in duProcCfgComplete"); + ret = RFAILED; } else { - uint8_t idx1=0; - memset(cell, 0, sizeof(DuCellCb)); - cell->cellId = ++cellId; - memset(&cell->cellInfo.nrEcgi.plmn, 0, sizeof(Plmn)); - cell->cellInfo.nrEcgi.plmn.mcc[0] = PLMN_MCC0; - cell->cellInfo.nrEcgi.plmn.mcc[1] = PLMN_MCC1; - cell->cellInfo.nrEcgi.plmn.mcc[2] = PLMN_MCC2; - cell->cellInfo.nrEcgi.plmn.mnc[0] = PLMN_MNC0; - cell->cellInfo.nrEcgi.plmn.mnc[1] = PLMN_MNC1; - cell->cellInfo.nrEcgi.cellId = NR_CELL_ID; - cell->cellInfo.nrPci = NR_PCI; - cell->cellInfo.fiveGsTac = DU_TAC; - memset(&cell->cellInfo.plmn[idx1], 0, sizeof(Plmn)); - for(idx1=0; idx1cellInfo.plmn[idx1].mcc[0] = PLMN_MCC0; - cell->cellInfo.plmn[idx1].mcc[1] = PLMN_MCC1; - cell->cellInfo.plmn[idx1].mcc[2] = PLMN_MCC2; - cell->cellInfo.plmn[idx1].mnc[0] = PLMN_MNC0; - cell->cellInfo.plmn[idx1].mnc[1] = PLMN_MNC1; - } - cell->cellInfo.maxUe = duCfgParam.maxUe; - cell->cellStatus = CELL_OUT_OF_SERVICE; - - duCb.cfgCellLst[duCb.numCfgCells] = cell; - duCb.numCfgCells++; + uint8_t idx1=0; + memset(cell, 0, sizeof(DuCellCb)); + cell->cellId = NR_CELL_ID; //++cellId; + memset(&cell->cellInfo.nrEcgi.plmn, 0, sizeof(Plmn)); + cell->cellInfo.nrEcgi.plmn.mcc[0] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mcc[0]; + cell->cellInfo.nrEcgi.plmn.mcc[1] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mcc[1]; + cell->cellInfo.nrEcgi.plmn.mcc[2] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mcc[2]; + cell->cellInfo.nrEcgi.plmn.mnc[0] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mnc[0]; + cell->cellInfo.nrEcgi.plmn.mnc[1] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mnc[1]; + cell->cellInfo.nrEcgi.plmn.mnc[2] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mnc[2]; + cell->cellInfo.nrEcgi.cellId = cell->cellId; + cell->cellInfo.nrPci = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrPci; + cell->cellInfo.fiveGsTac = duCfgParam.srvdCellLst[0].duCellInfo.tac; + memset(&cell->cellInfo.plmn[idx1], 0, sizeof(Plmn)); + for(idx1=0; idx1cellInfo.plmn[idx1].mcc[0] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mcc[0]; + cell->cellInfo.plmn[idx1].mcc[1] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mcc[1]; + cell->cellInfo.plmn[idx1].mcc[2] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mcc[2]; + cell->cellInfo.plmn[idx1].mnc[0] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mnc[0]; + cell->cellInfo.plmn[idx1].mnc[1] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mnc[1]; + cell->cellInfo.plmn[idx1].mnc[2] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mnc[2]; + } + cell->cellInfo.maxUe = duCfgParam.maxUe; + cell->cellStatus = CELL_OUT_OF_SERVICE; + gCellStatus = CELL_DOWN; + duCb.cfgCellLst[duCb.numCfgCells] = cell; + duCb.numCfgCells++; } } if(ret != RFAILED) @@ -963,15 +978,12 @@ uint8_t duSctpNtfyHdl(Buffer *mBuf, CmInetSctpNotification *ntfy) { if(BuildAndSendF1SetupReq() != ROK) { - return RFAILED; + return RFAILED; } } else if(ricParams.assocId == ntfy->u.assocChange.assocId) { - if(BuildAndSendE2SetupReq() != ROK) - { - return RFAILED; - } + return ROK; } else { @@ -1070,9 +1082,7 @@ uint8_t duHdlEgtpCfgComplete(CmStatus cfm) if(cfm.status == LCM_PRIM_OK) { DU_LOG("\nDEBUG --> DU_APP : EGTP configuraton complete"); -#ifdef EGTP_TEST duSendEgtpSrvOpenReq(); -#endif } else { @@ -1136,9 +1146,6 @@ uint8_t duHdlEgtpSrvOpenComplete(CmStatus cfm) if(cfm.status == LCM_PRIM_OK) { DU_LOG("\nDEBUG --> DU_APP : EGTP server opened successfully"); -#ifdef EGTP_TEST - duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_ADD, EGTP_LCL_TEID, EGTP_REM_TEID); -#endif } else { @@ -1168,19 +1175,28 @@ uint8_t duHdlEgtpSrvOpenComplete(CmStatus cfm) * * ****************************************************************/ -uint8_t duSendEgtpTnlMgmtReq(uint8_t action, uint32_t lclTeid, uint32_t remTeid) +uint8_t duSendEgtpTnlMgmtReq(uint8_t action, uint32_t teIdTobeMod, GtpTnlCfg *ueCbTnlCfg) { + uint8_t ret =ROK; Pst pst; EgtpTnlEvt tnlEvt; - tnlEvt.action = action; - tnlEvt.lclTeid = lclTeid; - tnlEvt.remTeid = remTeid; + DU_LOG("\nDEBUG --> DU_APP : Sending EGTP tunnel management request for teId [%d]", ueCbTnlCfg->teId); - DU_LOG("\nDEBUG --> DU_APP : Sending EGTP tunnel management request"); + /* ADD/MOD/DEL per tunnel */ + tnlEvt.action = action; + tnlEvt.remTeid = ueCbTnlCfg->teId; + if(action != EGTP_TNL_MGMT_ADD) + { + tnlEvt.lclTeid = teIdTobeMod; + } + else + { + tnlEvt.lclTeid = ueCbTnlCfg->teId; + } duFillEgtpPst(&pst, EVTTNLMGMTREQ); - egtpTnlMgmtReq(&pst, tnlEvt); - return ROK; + ret = egtpTnlMgmtReq(&pst, tnlEvt); + return ret; } /******************************************************************* @@ -1205,14 +1221,11 @@ uint8_t duHdlEgtpTnlMgmtCfm(EgtpTnlEvt tnlEvtCfm) if(tnlEvtCfm.cfmStatus.status == LCM_PRIM_OK) { - DU_LOG("\nDEBUG --> DU_APP : Tunnel management confirm OK"); -#ifdef EGTP_TEST - duSendEgtpTestData(); -#endif + DU_LOG("\nDEBUG --> DU_APP: Tunnel management confirm OK"); } else { - DU_LOG("\nERROR --> DU_APP : Tunnel management failed"); + DU_LOG("\nERROR --> DU_APP: Tunnel management failed"); ret = RFAILED; } @@ -1246,128 +1259,13 @@ uint8_t duSendEgtpDatInd(Buffer *mBuf) egtpMsg.msgHdr.extHdr.pdcpNmb.pres = FALSE; egtpMsg.msgHdr.teId = 1; egtpMsg.msg = mBuf; - + egtpHdlDatInd(egtpMsg); return ROK; } -#ifdef EGTP_TEST -/******************************************************************* - * - * @brief Simulate UL Data for intial test - * - * @details - * - * Function : duSendEgtpTestData - * - * Functionality: - * Simulate UL data for initial test - * - * @params[in] - * @return ROK - success - * RFAILED - failure - * - * ****************************************************************/ -uint8_t duSendEgtpTestData() -{ - char data[30] = "This is EGTP data from DU"; - int datSize = 30; - - Buffer *mBuf; - - if(ODU_GET_MSG_BUF(DU_APP_MEM_REGION, DU_POOL, &mBuf) == ROK) - { - if(ODU_ADD_POST_MSG_MULT((Data *)data, datSize, mBuf) != ROK) - { - DU_LOG("\nERROR --> DU_APP : ODU_ADD_POST_MSG_MULT failed"); - ODU_PUT_MSG_BUF(mBuf); - return RFAILED; - } - } - else - { - DU_LOG("\nERROR --> DU_APP : Failed to allocate memory"); - return RFAILED; - } - - /* filling IPv4 header */ - CmIpv4Hdr ipv4Hdr; - MsgLen mLen; - - mLen = 0; - ODU_GET_MSG_LEN(mBuf, &mLen); - - memset(&ipv4Hdr, 0, sizeof(CmIpv4Hdr)); - ipv4Hdr.length = CM_IPV4_HDRLEN + mLen; - ipv4Hdr.hdrVer = 0x45; - ipv4Hdr.proto = 1; - ipv4Hdr.srcAddr = CM_INET_NTOH_UINT32(duCfgParam.egtpParams.localIp.ipV4Addr); - ipv4Hdr.destAddr = CM_INET_NTOH_UINT32(duCfgParam.egtpParams.destIp.ipV4Addr); - - /* Packing IPv4 header into buffer */ - uint8_t ret, cnt, idx; - Data revPkArray[CM_IPV4_HDRLEN]; - Data pkArray[CM_IPV4_HDRLEN]; - - /* initialize locals */ - cnt = 0; - memset(revPkArray, 0, CM_IPV4_HDRLEN); - memset(pkArray, 0, CM_IPV4_HDRLEN); - - /* Pack Header Version */ - pkArray[cnt++] = ipv4Hdr.hdrVer; - - /* Pack TOS */ - pkArray[cnt++] = ipv4Hdr.tos; - - pkArray[cnt++] = (Data)GetHiByte(ipv4Hdr.length); - pkArray[cnt++] = (Data)GetLoByte(ipv4Hdr.length); - - /* Pack Id */ - pkArray[cnt++] = (Data) GetHiByte(ipv4Hdr.id); - pkArray[cnt++] = (Data) GetLoByte(ipv4Hdr.id); - - /* Pack Offset */ - pkArray[cnt++] = (Data)GetHiByte(ipv4Hdr.off); - pkArray[cnt++] = (Data)GetLoByte(ipv4Hdr.off); - - /* Pack TTL */ - pkArray[cnt++] = ipv4Hdr.ttl; - - /* Pack Protocol */ - pkArray[cnt++] = ipv4Hdr.proto; - - /* Pack Checksum */ - pkArray[cnt++] = (Data)GetHiByte(ipv4Hdr.chkSum); - pkArray[cnt++] = (Data)GetLoByte(ipv4Hdr.chkSum); - - /* Pack Source Address */ - pkArray[cnt++] = (Data)GetHiByte(GetHiWord(ipv4Hdr.srcAddr)); - pkArray[cnt++] = (Data)GetLoByte(GetHiWord(ipv4Hdr.srcAddr)); - pkArray[cnt++] = (Data)GetHiByte(GetLoWord(ipv4Hdr.srcAddr)); - pkArray[cnt++] = (Data)GetLoByte(GetLoWord(ipv4Hdr.srcAddr)); - - /* Pack Destination Address */ - pkArray[cnt++] = (Data)GetHiByte(GetHiWord(ipv4Hdr.destAddr)); - pkArray[cnt++] = (Data)GetLoByte(GetHiWord(ipv4Hdr.destAddr)); - pkArray[cnt++] = (Data)GetHiByte(GetLoWord(ipv4Hdr.destAddr)); - pkArray[cnt++] = (Data)GetLoByte(GetLoWord(ipv4Hdr.destAddr)); - - for (idx = 0; idx < CM_IPV4_HDRLEN; idx++) - revPkArray[idx] = pkArray[CM_IPV4_HDRLEN - idx -1]; - - /* this function automatically reverses revPkArray */ - ret = ODU_ADD_PRE_MSG_MULT(revPkArray, (MsgLen)cnt, mBuf); - - duSendEgtpDatInd(mBuf); - - return ROK; -} -#endif /* EGTP_TEST */ - - /************************************************************************** * @brief Function to send configs to SCH * @@ -1551,7 +1449,13 @@ uint8_t duBuildAndSendMacCellCfg(uint16_t cellId) } /* store the address in the duCellCb so that we can free on confirm msg */ - duCb.actvCellLst[cellId-1]->duMacCellCfg = duMacCellCfg; + if(duCb.actvCellLst[cellId-1]) + duCb.actvCellLst[cellId-1]->duMacCellCfg = duMacCellCfg; + else + { + DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, duMacCellCfg, sizeof(MacCellCfg)); + return RFAILED; + } /* copy the mac config structure from duCfgParams */ memcpy(duMacCellCfg,&duCfgParam.macCellCfg,sizeof(MacCellCfg)); @@ -1585,15 +1489,15 @@ uint8_t duHandleMacCellCfgCfm(Pst *pst, MacCellCfgCfm *macCellCfgCfm) for(actvCellIdx = 0; actvCellIdx < MAX_NUM_CELL; actvCellIdx++) { - if(macCellCfgCfm->cellId == duCb.actvCellLst[actvCellIdx]->cellId) + if((duCb.actvCellLst[actvCellIdx]) && (macCellCfgCfm->cellId == duCb.actvCellLst[actvCellIdx]->cellId)) { - duCb.actvCellLst[actvCellIdx]->duMacCellCfg = NULLP; + duCb.actvCellLst[actvCellIdx]->duMacCellCfg = NULLP; } } if(macCellCfgCfm->rsp == ROK) { /* Build and send GNB-DU config update */ - ret = BuildAndSendDUConfigUpdate(); + ret = BuildAndSendDUConfigUpdate(SERV_CELL_TO_MODIFY); /* Build and Send Cell Start Req to MAC */ ret = duBuildAndSendMacCellStart(); @@ -1628,28 +1532,28 @@ uint8_t duHandleMacCellCfgCfm(Pst *pst, MacCellCfgCfm *macCellCfgCfm) uint8_t duBuildAndSendMacCellStart() { Pst pst; - OduCellId *cellId = NULL; + CellStartInfo *cellStart = NULL; DU_LOG("\nINFO --> DU APP : Building and Sending cell start request to MAC"); /* Send Cell Start Request to MAC */ - DU_ALLOC_SHRABL_BUF(cellId, sizeof(OduCellId)); - if(!cellId) + DU_ALLOC_SHRABL_BUF(cellStart, sizeof(CellStartInfo)); + if(!cellStart) { DU_LOG("\nERROR --> DU APP : Memory alloc failed while building cell start request"); return RFAILED; } - for(uint8_t id = 0; id < duCb.numActvCells; id++) + for(uint8_t id = 0; id < MAX_NUM_CELL; id++) { if(duCb.actvCellLst[id]) { - cellId->cellId = duCb.actvCellLst[id]->cellId; + cellStart->cellId = duCb.actvCellLst[id]->cellId; - /* Fill Pst */ - FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_CELL_START); + /* Fill Pst */ + FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_CELL_START); - return (*packMacCellStartOpts[pst.selector])(&pst, cellId); + return (*packMacCellStartOpts[pst.selector])(&pst, cellStart); } } return ROK; @@ -1671,26 +1575,38 @@ uint8_t duBuildAndSendMacCellStart() * RFAILED - failure * * ****************************************************************/ -uint8_t duBuildAndSendMacCellStop() +uint8_t duBuildAndSendMacCellStop(uint16_t cellId) { Pst pst; - OduCellId *cellId = NULL; + uint16_t cellIdx=0; + CellStopInfo *cellStop = NULL; DU_LOG("\nINFO --> DU APP : Building and Sending cell stop request to MAC"); - /* Send Cell Stop Request to MAC */ - DU_ALLOC_SHRABL_BUF(cellId, sizeof(OduCellId)); - if(!cellId) + GET_CELL_IDX(cellId, cellIdx); + if(duCb.actvCellLst[cellIdx] != NULLP) { - DU_LOG("\nERROR --> DU APP : Memory alloc failed while building cell stop request"); - return RFAILED; - } - cellId->cellId = duCb.actvCellLst[0]->cellId; + /* Send Cell Stop Request to MAC */ + DU_ALLOC_SHRABL_BUF(cellStop, sizeof(CellStopInfo)); + if(!cellStop) + { + DU_LOG("\nERROR --> DU APP : Memory alloc failed while building cell stop request"); + return RFAILED; + } + memset(cellStop, 0, sizeof(CellStopInfo)); + cellStop->cellId = duCb.actvCellLst[cellIdx]->cellId; - /* Fill Pst */ - FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_CELL_STOP); + /* Fill Pst */ + FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_CELL_STOP); - return (*packMacCellStopOpts[pst.selector])(&pst, cellId); + return (*packMacCellStopOpts[pst.selector])(&pst, cellStop); + } + else + { + DU_LOG("\nERROR --> DU APP : duBuildAndSendMacCellStop(): cellId[%d] doesnot exists", cellId); + return RFAILED; + } + return ROK; } /******************************************************************* @@ -1721,14 +1637,21 @@ uint8_t duHandleStopInd(Pst *pst, OduCellId *cellId) if(duGetCellCb(cellId->cellId, &cellCb) != ROK) return RFAILED; - if((cellCb->cellStatus == ACTIVATED)) + if((cellCb->cellStatus == ACTIVATED) || (cellCb->cellStatus == DELETION_IN_PROGRESS)) { DU_LOG("\nINFO --> DU APP : 5G-NR Cell %d is DOWN", cellId->cellId); - cellCb->cellStatus = DELETION_IN_PROGRESS; + if(sendCellDeleteReqToMac(cellId->cellId) == RFAILED) + { + DU_LOG("\nERROR --> DU APP : duHandleStopInd(): Failed to send Cell delete req to MAC for\ + cellId[%d]", cellId->cellId); + return RFAILED; + } + #ifdef O1_ENABLE DU_LOG("\nINFO --> DU APP : Raise cell down alarm for cell id=%d", cellId->cellId); raiseCellAlrm(CELL_DOWN_ALARM_ID, cellId->cellId); + setCellOpState(cellId->cellId, DISABLED, INACTIVE); #endif } @@ -1784,23 +1707,63 @@ uint8_t duHandleUlCcchInd(Pst *pst, UlCcchIndInfo *ulCcchIndInfo) * ****************************************************************/ uint8_t DuProcRlcUlRrcMsgTrans(Pst *pst, RlcUlRrcMsgInfo *ulRrcMsgInfo) { + uint8_t ret = ROK; DuCellCb *cellCb = NULLP; - DuUeCb ueCb ={0}; + DuUeCb *ueCb = NULLP; - if(duGetCellCb(ulRrcMsgInfo->cellId, &cellCb) != ROK) - return RFAILED; - if(ulRrcMsgInfo->ueIdx > 0) + duGetCellCb(ulRrcMsgInfo->cellId, &cellCb); + if(cellCb) { - ueCb = cellCb->ueCb[ulRrcMsgInfo->ueIdx -1]; - - - BuildAndSendULRRCMessageTransfer(ueCb, ulRrcMsgInfo->lcId, ulRrcMsgInfo->msgLen, \ - ulRrcMsgInfo->rrcMsg); + if(ulRrcMsgInfo->ueId > 0) + { + if(cellCb->ueCb[ulRrcMsgInfo->ueId -1].gnbDuUeF1apId == ulRrcMsgInfo->ueId) + ueCb = &cellCb->ueCb[ulRrcMsgInfo->ueId -1]; + + if(ueCb) + { + /* If UL message is received for a UE in handover, it signifies that UE is now + * attached to GNB. Hence marking this UE as active and requesting MAC to + * release the dedicated RACH resources */ + if(ueCb->ueState == UE_HANDIN_IN_PROGRESS) + { + ueCb->ueState = UE_ACTIVE; + cellCb->numActvUes++; + + /* Release RACH resources */ + memset(&ueCb->cfraResource, 0, sizeof(MacCfraResource)); + if(duBuildAndSendRachRsrcRelToMac(ulRrcMsgInfo->cellId, ueCb) != ROK) + { + DU_LOG("\nERROR --> DU_APP : DuProcRlcUlRrcMsgTrans() : Failed to send RACH resource release to MAC"); + } + } + + if(BuildAndSendULRRCMessageTransfer(ueCb, ulRrcMsgInfo->lcId, ulRrcMsgInfo->msgLen, ulRrcMsgInfo->rrcMsg) != ROK) + { + DU_LOG("\nERROR --> DU_APP : DuProcRlcUlRrcMsgTrans() : Failed to build and send UL RRC Message Transfer"); + ret = RFAILED; + } + } + else + { + DU_LOG("\nERROR --> DU_APP : DuProcRlcUlRrcMsgTrans() : UE ID [%d] not found", ulRrcMsgInfo->ueId); + ret = RFAILED; + } + } + else + { + DU_LOG("\nERROR --> DU_APP : DuProcRlcUlRrcMsgTrans() : Invalid UE ID [%d]", ulRrcMsgInfo->ueId); + ret = RFAILED; + } + } + else + { + DU_LOG("\nERROR --> DU_APP : DuProcRlcUlRrcMsgTrans() : Cell ID [%d] not found", ulRrcMsgInfo->cellId); + ret = RFAILED; + } DU_FREE_SHRABL_BUF(pst->region, pst->pool, ulRrcMsgInfo->rrcMsg, ulRrcMsgInfo->msgLen); DU_FREE_SHRABL_BUF(pst->region, pst->pool, ulRrcMsgInfo, sizeof(RlcUlRrcMsgInfo)); - } - return ROK; + return ret; } /******************************************************************* @@ -1828,13 +1791,439 @@ uint8_t DuProcRlcRrcDeliveryReport(Pst *pst, RrcDeliveryReport *rrcDeliveryRepor if(duGetCellCb(rrcDeliveryReport->cellId, &cellCb) != ROK) return RFAILED; - ueCb = cellCb->ueCb[rrcDeliveryReport->ueIdx -1]; + ueCb = cellCb->ueCb[rrcDeliveryReport->ueId -1]; ret = BuildAndSendRrcDeliveryReport(ueCb.gnbCuUeF1apId, ueCb.gnbDuUeF1apId,rrcDeliveryReport); DU_FREE_SHRABL_BUF(pst->region, pst->pool, rrcDeliveryReport, sizeof(RrcDeliveryReport)); return ret; } +/******************************************************************* + * + * @brief Process UL user data from RLC + * + * @details + * + * Function : DuProcRlcUlUserDataTrans + * + * Functionality: Process UL user data from RLC + * + * @params[in] Post structure + * UL user data + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +uint8_t DuProcRlcUlUserDataTrans(Pst *pst, RlcUlUserDatInfo *ulUserData) +{ + uint8_t teIdx = 0; + EgtpMsg egtpMsg; + Buffer *mBuf; + + DU_LOG("\nDEBUG --> DU APP : Received UL user data"); + + /* Fill EGTP header */ + egtpMsg.msgHdr.msgType = EGTPU_MSG_GPDU; + egtpMsg.msgHdr.nPdu.pres = FALSE; + egtpMsg.msgHdr.seqNum.pres = FALSE; + egtpMsg.msgHdr.extHdr.udpPort.pres = FALSE; + egtpMsg.msgHdr.extHdr.pdcpNmb.pres = FALSE; + + /* Fetch EGTP tunnel info */ + for(teIdx = 0; teIdx < duCb.numTeId; teIdx++) + { + /*TODO: If multiple Cell Support is enables then CellId also needs to be validated alongwith ueId and DrbId*/ + if((duCb.upTnlCfg[teIdx] != NULLP) && (duCb.upTnlCfg[teIdx]->ueId == ulUserData->ueId) && \ + (duCb.upTnlCfg[teIdx]->drbId == ulUserData->rbId)) + { + if(duCb.upTnlCfg[teIdx]->tnlCfg1) + { + egtpMsg.msgHdr.teId = duCb.upTnlCfg[teIdx]->tnlCfg1->teId; /*As we are supporting only 1 tunnel per DRB*/ + break; + } + } + } + + if (ODU_GET_MSG_BUF(DU_APP_MEM_REGION, DU_POOL, &mBuf) != ROK) + { + DU_LOG("\nERROR --> DU APP : Failed to allocated buffer memory in DuProcRlcUlUserDataTrans"); + DU_FREE_SHRABL_BUF(pst->region, pst->pool, ulUserData->userData, ulUserData->msgLen); + DU_FREE_SHRABL_BUF(pst->region, pst->pool, ulUserData, sizeof(RlcUlUserDatInfo)); + return RFAILED; + } + oduCpyFixBufToMsg(ulUserData->userData, mBuf, ulUserData->msgLen); + ODU_PRINT_MSG(mBuf, 0, 0); + egtpMsg.msg = mBuf; + egtpHdlDatInd(egtpMsg); + + DU_FREE_SHRABL_BUF(pst->region, pst->pool, ulUserData->userData, ulUserData->msgLen); + DU_FREE_SHRABL_BUF(pst->region, pst->pool, ulUserData, sizeof(RlcUlUserDatInfo)); + return ROK; +} + +/******************************************************************* + * + * @brief Free tempSLiceCfg stored in duCfgParams + * + * @details + * + * Function : duFreeTempSliceCfg + * + * Functionality: Free tempSLiceCfg stored in duCfgParams + * + * @params[in] Post structure, + * + * @return Void + * + * ****************************************************************/ + +void duFreeTempSliceCfg() +{ + uint8_t policyIdx = 0, memberListTdx =0; + CopyOfRecvdSliceCfg *tempSliceCfg = &duCfgParam.tempSliceCfg; + + if(tempSliceCfg->totalRrmPolicy) + { + for(policyIdx = 0; policyIdxtotalRrmPolicy; policyIdx++) + { + if(tempSliceCfg->rrmPolicy[policyIdx]->numMemberList) + { + for(memberListTdx = 0; memberListTdxrrmPolicy[policyIdx]->numMemberList; memberListTdx++) + { + DU_FREE(tempSliceCfg->rrmPolicy[policyIdx]->memberList[memberListTdx], sizeof(PolicyMemberList)); + } + DU_FREE(tempSliceCfg->rrmPolicy[policyIdx]->memberList, (tempSliceCfg->rrmPolicy[policyIdx]->numMemberList) * sizeof(PolicyMemberList*)); + } + DU_FREE(tempSliceCfg->rrmPolicy[policyIdx], sizeof(RrmPolicy)); + } + DU_FREE(tempSliceCfg->rrmPolicy, tempSliceCfg->totalRrmPolicy* sizeof(RrmPolicy*)); + } + memset(tempSliceCfg, 0, sizeof(CopyOfRecvdSliceCfg)); +} + +/******************************************************************* + * + * @brief free the slice cfg rsp + * + * @details + * + * Function : duFreeSliceCfgRsp + * + * Functionality: free the slice cfg rsp + * + * @params[in] Post structure, MacSliceCfgRsp *cfgRsp + * + * @return ROK - success + * RFAILED - failure + * + **********************************************************************/ +void duFreeSliceCfgRsp(Pst *pst, MacSliceCfgRsp *cfgRsp) +{ + uint8_t cfgIdx; + + if(cfgRsp) + { + if(cfgRsp->numSliceCfgRsp) + { + for(cfgIdx = 0; cfgIdxnumSliceCfgRsp; cfgIdx++) + { + DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp->listOfSliceCfgRsp[cfgIdx], sizeof(MacSliceRsp)); + } + DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp->listOfSliceCfgRsp, cfgRsp->numSliceCfgRsp * sizeof(MacSliceRsp*)); + } + DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(MacSliceCfgRsp)); + } +} + +/******************************************************************* + * + * @brief process the slice cfg rsp received from MAC + * + * @details + * + * Function : DuProcMacSliceCfgRsp + * + * Functionality: process the slice cfg rsp received from MAC + * + * @params[in] Post structure, MacSliceCfgRsp *cfgRsp + * + * @return ROK - success + * RFAILED - failure + * + **********************************************************************/ +uint8_t DuProcMacSliceCfgRsp(Pst *pst, MacSliceCfgRsp *cfgRsp) +{ + uint8_t cfgIdx = 0; + + if(cfgRsp) + { + if(cfgRsp->listOfSliceCfgRsp) + { + for(cfgIdx = 0; cfgIdxnumSliceCfgRsp; cfgIdx++) + { + if(cfgRsp->listOfSliceCfgRsp[cfgIdx]->rsp == MAC_DU_APP_RSP_OK) + { + duCb.sliceState = SLICE_CONFIGURED; + } + } + DU_LOG("\nINFO --> DU_APP : Slice Configuration is done successfully "); + } + duFreeSliceCfgRsp(pst, cfgRsp); + } + duFreeTempSliceCfg(); + return ROK; +} + +/******************************************************************* + * + * @brief Fill the slice configration and rrm policy ratio + * information received form O1 + * + * @details + * + * Function : fillSliceCfgReCfgInfo + * + * Functionality: Fill the slice configration and recfg info + * + * @params[in] Post structure + * + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ + +uint8_t fillSliceCfgReCfgInfo(MacSliceRecfgReq *sliceRecfgReq, RrmPolicy *rrmPolicy[], uint8_t totalRrmPolicy, uint8_t totalSliceCount) +{ + uint8_t sliceIdx = 0, cfgIdx = 0, memberListIdx = 0; + + if(totalRrmPolicy) + { + DU_ALLOC_SHRABL_BUF(sliceRecfgReq->listOfSliceCfg, totalSliceCount*sizeof(MacSliceRrmPolicy*)); + if(sliceRecfgReq->listOfSliceCfg == NULLP) + { + DU_LOG("\nERROR --> DU_APP : Memory allocation failed in fillSliceCfgReCfgInfo"); + return RFAILED; + } + + for(sliceIdx = 0; sliceIdxnumMemberList; memberListIdx++) + { + DU_ALLOC_SHRABL_BUF(sliceRecfgReq->listOfSliceCfg[cfgIdx], sizeof(MacSliceRrmPolicy)); + if(sliceRecfgReq->listOfSliceCfg[cfgIdx] == NULLP) + { + DU_LOG("\nERROR --> DU_APP : Memory allocation failed in fillSliceCfgReCfgInfo"); + return RFAILED; + } + + + memcpy(&sliceRecfgReq->listOfSliceCfg[cfgIdx]->snssai, &rrmPolicy[sliceIdx]->memberList[memberListIdx]->snssai, sizeof(Snssai)); + + DU_ALLOC_SHRABL_BUF(sliceRecfgReq->listOfSliceCfg[cfgIdx]->rrmPolicyRatio, sizeof(RrmPolicyRatio)); + if(sliceRecfgReq->listOfSliceCfg[cfgIdx]->rrmPolicyRatio == NULLP) + { + DU_LOG("\nERROR --> DU_APP : Memory allocation failed in fillSliceCfgReCfgInfo"); + return RFAILED; + } + + sliceRecfgReq->listOfSliceCfg[cfgIdx]->rrmPolicyRatio->policyMaxRatio = rrmPolicy[sliceIdx]->policyMaxRatio; + sliceRecfgReq->listOfSliceCfg[cfgIdx]->rrmPolicyRatio->policyMinRatio = rrmPolicy[sliceIdx]->policyMinRatio; + sliceRecfgReq->listOfSliceCfg[cfgIdx]->rrmPolicyRatio->policyDedicatedRatio = rrmPolicy[sliceIdx]->policyDedicatedRatio; + sliceRecfgReq->numOfConfiguredSlice++; + cfgIdx++; + } + } + } + return ROK; +} + +/******************************************************************* + * + * @brief Fill the slice configration and rrm policy related + * information received form O1 + * + * @details + * + * Function : BuildAndSendSliceConfigReq + * + * Functionality: Fill the slice configration and rrm policy related + * + * @params[in] RrmPolicy *rrmPolicy[], uint8_t totalRrmPolicy, uint8_t + * totalSliceCnt + * + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +uint8_t BuildAndSendSliceConfigReq(RrmPolicy *rrmPolicy[], uint8_t totalRrmPolicy, uint8_t totalSliceCnt) +{ + Pst pst; + MacSliceCfgReq *sliceCfgReq; + + DU_ALLOC_SHRABL_BUF(sliceCfgReq, sizeof(MacSliceCfgReq)); + if(sliceCfgReq == NULLP) + { + DU_LOG("\nERROR --> DU_APP : Memory allocation failed in BuildAndSendSliceConfigReq"); + return RFAILED; + } + else + { + if(fillSliceCfgReCfgInfo(sliceCfgReq, rrmPolicy, totalRrmPolicy, totalSliceCnt) != ROK) + { + DU_LOG("\nERROR --> DU_APP : Failed to fill slice Configuration info in MacSliceCfgReq"); + return RFAILED; + } + FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_SLICE_CFG_REQ); + + DU_LOG("\nDEBUG --> DU_APP : Sending Slice Cfg Request to MAC "); + if((*packMacSliceCfgReqOpts[pst.selector])(&pst, sliceCfgReq) == RFAILED) + { + DU_LOG("\nERROR --> DU_APP : Failed to send Slice Cfg Req to MAC"); + DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, sliceCfgReq, sizeof(MacSliceCfgReq)); + } + } + return ROK; +} + + +/******************************************************************* + * + * @brief Fill the slice configration and rrm policy related + * information received form O1 + * + * @details + * + * Function : BuildAndSendSliceRecfgReq + * + * Functionality: Fill the slice configration and rrm policy related + * + * @params[in] RrmPolicy rrmPolicy[], uint8_t totalSliceCount + * + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +uint8_t BuildAndSendSliceRecfgReq(RrmPolicy *rrmPolicy[], uint8_t totalRrmPolicy, uint8_t totalSliceCount) +{ + Pst pst; + MacSliceRecfgReq *sliceRecfgReq = NULLP; + + DU_LOG("\nINFO --> DU_APP : Slice ReConfiguration Request received"); + + DU_ALLOC_SHRABL_BUF(sliceRecfgReq, sizeof(MacSliceRecfgReq)); + if(sliceRecfgReq == NULLP) + { + DU_LOG("\nERROR --> DU_APP : Memory allocation failed to BuildAndSendSliceRecfgReq"); + return RFAILED; + } + else + { + if(fillSliceCfgReCfgInfo(sliceRecfgReq, rrmPolicy, totalRrmPolicy, totalSliceCount) != ROK) + { + DU_LOG("\nERROR --> DU_APP: Failed to fill slice cfg request info"); + return RFAILED; + } + FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_SLICE_RECFG_REQ); + + DU_LOG("\nDEBUG --> DU_APP: Sending Slice ReCfg Request to MAC "); + if( (*packMacSliceRecfgReqOpts[pst.selector])(&pst, sliceRecfgReq) == RFAILED) + { + DU_LOG("\nERROR --> DU_APP: Failed to send Slice ReCfg Req to MAC"); + DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, sliceRecfgReq, sizeof(MacSliceRecfgReq)); + } + } + return ROK; +} +/******************************************************************* + * + * @brief process the slice ReCfg rsp received from MAC + * + * @details + * + * Function : DuProcMacSliceRecfgRsp + * + * Functionality: process the slice ReCfg rsp received from MAC + * + * @params[in] Post structure, MacSliceRecfgRsp *ReCfgRsp + * + * @return ROK - success + * RFAILED - failure + * + **********************************************************************/ +uint8_t DuProcMacSliceRecfgRsp(Pst *pst, MacSliceRecfgRsp *reCfgRsp) +{ + uint8_t cfgIdx = 0; + + if(reCfgRsp) + { + if(reCfgRsp->listOfSliceCfgRsp) + { + for(cfgIdx = 0; cfgIdx < reCfgRsp->numSliceCfgRsp; cfgIdx++) + { + if(reCfgRsp->listOfSliceCfgRsp[cfgIdx]->rsp == MAC_DU_APP_RSP_OK) + { + duCb.sliceState = SLICE_RECONFIGURED; + } + else + { + DU_LOG("\nERROR --> DU_APP : Slice not available"); + } + } + DU_LOG("\nINFO --> DU_APP : Slice ReCOnfiguration response received"); + } + duFreeSliceCfgRsp(pst, reCfgRsp); + } + duFreeTempSliceCfg(); + return ROK; +} + +/******************************************************************* +* +* @brief Handles received Slice Metrics from RLC and forward it to O1 +* +* @details +* +* Function : DuProcRlcSliceMetrics +* +* Functionality: +* Handles received Slice Metrics from RLC and forward it to O1 +* +* @params[in] Post structure pointer +* SlicePmList *sliceStats +* +* @return ROK - success +* RFAILED - failure +* +* ****************************************************************/ +uint8_t DuProcRlcSliceMetrics(Pst *pst, SlicePmList *sliceStats) +{ + uint8_t sliceRecord = 0; + + DU_LOG("\nDEBUG --> DU APP : Received Slice Metrics"); + if(sliceStats == NULLP) + { + DU_LOG("\nERROR --> DU APP : Empty Metrics"); + return RFAILED; + } + + for(sliceRecord = 0; sliceRecord < sliceStats->numSlice; sliceRecord++) + { + DU_LOG("\nINFO --> DU_APP: SliceId[SST-SD]:%d-%d, DlTput %.5lf, UlTput:%.5lf", sliceStats->sliceRecord[sliceRecord].networkSliceIdentifier.sst,\ + sliceStats->sliceRecord[sliceRecord].networkSliceIdentifier.sd,sliceStats->sliceRecord[sliceRecord].ThpDl,\ + sliceStats->sliceRecord[sliceRecord].ThpUl); + } +#ifdef O1_ENABLE + if(sliceStats) + { + sendSliceMetric((SliceMetricList*) sliceStats); + } +#endif + + DU_FREE_SHRABL_BUF(pst->region, pst->pool,sliceStats->sliceRecord, (sliceStats->numSlice) * (sizeof(SlicePm))); + DU_FREE_SHRABL_BUF(pst->region, pst->pool,sliceStats, sizeof(SlicePmList)); + + return ROK; +} /********************************************************************** End of file