X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Fdu_app%2Fdu_msg_hdl.c;h=c7c9bc3b5f595eedaafe149caff8c138188a7f89;hb=964fd8f1dc9c969e70caf8885332cc086ff22d74;hp=ba1a48a5abadcba84c8a987f4529b449d5a08c61;hpb=399c1055e8260b87835b3017e63183e725b9d1bd;p=o-du%2Fl2.git diff --git a/src/du_app/du_msg_hdl.c b/src/du_app/du_msg_hdl.c index ba1a48a5a..c7c9bc3b5 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 "AlarmInterface.h" -#include "ConfigInterface.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 { @@ -1249,7 +1259,7 @@ uint8_t duSendEgtpDatInd(Buffer *mBuf) egtpMsg.msgHdr.extHdr.pdcpNmb.pres = FALSE; egtpMsg.msgHdr.teId = 1; egtpMsg.msg = mBuf; - + egtpHdlDatInd(egtpMsg); return ROK; @@ -1439,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)); @@ -1473,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(); @@ -1528,16 +1544,16 @@ uint8_t duBuildAndSendMacCellStart() 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; + cellId->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, cellId); } } return ROK; @@ -1559,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; + OduCellId *oduCellId = 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(oduCellId, sizeof(OduCellId)); + if(!oduCellId) + { + DU_LOG("\nERROR --> DU APP : duBuildAndSendMacCellStop(): Memory allocation failed "); + return RFAILED; + } + memset(oduCellId, 0, sizeof(OduCellId)); + oduCellId->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, oduCellId); + } + else + { + DU_LOG("\nERROR --> DU APP : duBuildAndSendMacCellStop(): cellId[%d] doesnot exists", cellId); + return RFAILED; + } + return ROK; } /******************************************************************* @@ -1609,10 +1637,16 @@ 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); @@ -1673,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; } /******************************************************************* @@ -1717,7 +1791,7 @@ 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)); @@ -1742,7 +1816,7 @@ uint8_t DuProcRlcRrcDeliveryReport(Pst *pst, RrcDeliveryReport *rrcDeliveryRepor * ****************************************************************/ uint8_t DuProcRlcUlUserDataTrans(Pst *pst, RlcUlUserDatInfo *ulUserData) { - uint8_t rbIdx; + uint8_t teIdx = 0; EgtpMsg egtpMsg; Buffer *mBuf; @@ -1756,15 +1830,17 @@ uint8_t DuProcRlcUlUserDataTrans(Pst *pst, RlcUlUserDatInfo *ulUserData) egtpMsg.msgHdr.extHdr.pdcpNmb.pres = FALSE; /* Fetch EGTP tunnel info */ - for(rbIdx = 0; rbIdx < duCb.numDrb; rbIdx++) + for(teIdx = 0; teIdx < duCb.numTeId; teIdx++) { - if((duCb.upTnlCfg[rbIdx] != NULLP) && (duCb.upTnlCfg[rbIdx]->drbId == ulUserData->rbId)) + /*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[rbIdx]->tnlCfg1) - { - egtpMsg.msgHdr.teId = duCb.upTnlCfg[rbIdx]->tnlCfg1->teId; /*As we are supporting only 1 tunnel per DRB*/ - break; - } + if(duCb.upTnlCfg[teIdx]->tnlCfg1) + { + egtpMsg.msgHdr.teId = duCb.upTnlCfg[teIdx]->tnlCfg1->teId; /*As we are supporting only 1 tunnel per DRB*/ + break; + } } } @@ -1785,6 +1861,370 @@ uint8_t DuProcRlcUlUserDataTrans(Pst *pst, RlcUlUserDatInfo *ulUserData) 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(MacSliceCfgReq *sliceCfgReq, RrmPolicy *rrmPolicy[], uint8_t totalRrmPolicy, uint8_t totalSliceCount) +{ + uint8_t sliceIdx = 0, cfgIdx = 0, memberListIdx = 0; + + if(totalRrmPolicy) + { + DU_ALLOC_SHRABL_BUF(sliceCfgReq->listOfSliceCfg, totalSliceCount*sizeof(MacSliceRrmPolicy*)); + if(sliceCfgReq->listOfSliceCfg == NULLP) + { + DU_LOG("\nERROR --> DU_APP : Memory allocation failed in fillSliceCfgReCfgInfo"); + return RFAILED; + } + + for(sliceIdx = 0; sliceIdxnumMemberList; memberListIdx++) + { + DU_ALLOC_SHRABL_BUF(sliceCfgReq->listOfSliceCfg[cfgIdx], sizeof(MacSliceRrmPolicy)); + if(sliceCfgReq->listOfSliceCfg[cfgIdx] == NULLP) + { + DU_LOG("\nERROR --> DU_APP : Memory allocation failed in fillSliceCfgReCfgInfo"); + return RFAILED; + } + + + memcpy(&sliceCfgReq->listOfSliceCfg[cfgIdx]->snssai, &rrmPolicy[sliceIdx]->memberList[memberListIdx]->snssai, sizeof(Snssai)); + + DU_ALLOC_SHRABL_BUF(sliceCfgReq->listOfSliceCfg[cfgIdx]->rrmPolicyRatio, sizeof(RrmPolicyRatio)); + if(sliceCfgReq->listOfSliceCfg[cfgIdx]->rrmPolicyRatio == NULLP) + { + DU_LOG("\nERROR --> DU_APP : Memory allocation failed in fillSliceCfgReCfgInfo"); + return RFAILED; + } + + sliceCfgReq->listOfSliceCfg[cfgIdx]->rrmPolicyRatio->policyMaxRatio = rrmPolicy[sliceIdx]->policyMaxRatio; + sliceCfgReq->listOfSliceCfg[cfgIdx]->rrmPolicyRatio->policyMinRatio = rrmPolicy[sliceIdx]->policyMinRatio; + sliceCfgReq->listOfSliceCfg[cfgIdx]->rrmPolicyRatio->policyDedicatedRatio = rrmPolicy[sliceIdx]->policyDedicatedRatio; + sliceCfgReq->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; + MacSliceCfgReq *sliceReCfgReq = NULLP; + + DU_LOG("\nINFO --> DU_APP : Slice ReConfiguration Request received"); + + DU_ALLOC_SHRABL_BUF(sliceReCfgReq, sizeof(MacSliceCfgReq)); + 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(MacSliceCfgReq)); + } + } + 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, MacSliceCfgRsp *ReCfgRsp + * + * @return ROK - success + * RFAILED - failure + * + **********************************************************************/ +uint8_t DuProcMacSliceReCfgRsp(Pst *pst, MacSliceCfgRsp *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 **********************************************************************/