+/*******************************************************************
+ *
+ * @brief Process UL RRC Message from RLC
+ *
+ * @details
+ *
+ * Function : DuProcRlcUlRrcMsgTrans
+ *
+ * Functionality: Process UL RRC Message from RLC
+ *
+ * @params[in] Post structure
+ * UL RRC Message Info
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t DuProcRlcUlRrcMsgTrans(Pst *pst, RlcUlRrcMsgInfo *ulRrcMsgInfo)
+{
+ uint8_t ret = ROK;
+ DuCellCb *cellCb = NULLP;
+ DuUeCb *ueCb = NULLP;
+
+ duGetCellCb(ulRrcMsgInfo->cellId, &cellCb);
+ if(cellCb)
+ {
+ 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 ret;
+}
+
+/*******************************************************************
+*
+* @brief Process RRC delivery report from RLC
+*
+* @details
+*
+* Function : DuProcRlcRrcDeliveryReport
+*
+* Functionality: Process RRC delivery Message from RLC
+*
+* @params[in] Post structure
+* UL RRC Message Info
+* @return ROK - success
+* RFAILED - failure
+*
+* ****************************************************************/
+uint8_t DuProcRlcRrcDeliveryReport(Pst *pst, RrcDeliveryReport *rrcDeliveryReport)
+{
+ DuCellCb *cellCb = NULLP;
+ DuUeCb ueCb;
+ uint8_t ret = RFAILED;
+
+ if(duGetCellCb(rrcDeliveryReport->cellId, &cellCb) != ROK)
+ return RFAILED;
+
+ 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; policyIdx<tempSliceCfg->totalRrmPolicy; policyIdx++)
+ {
+ if(tempSliceCfg->rrmPolicy[policyIdx]->numMemberList)
+ {
+ for(memberListTdx = 0; memberListTdx<tempSliceCfg->rrmPolicy[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; cfgIdx<cfgRsp->numSliceCfgRsp; 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; cfgIdx<cfgRsp->numSliceCfgRsp; 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; sliceIdx<totalRrmPolicy; sliceIdx++)
+ {
+ for(memberListIdx = 0; memberListIdx<rrmPolicy[sliceIdx]->numMemberList; 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;
+}