+ if(!drbFound && ret == ROK)/* new DRB to Add */
+ {
+ if(duProcEgtpTunnelCfg(NULLP, NULLP, &duUeCfg->upTnlInfo[drbIdx]) != ROK)
+ {
+ DU_LOG("\nERROR -> DU_APP : duUpdateTunnelCfgDb: Failed to add tunnel req for Drb id[%d]",
+ duUeCfg->upTnlInfo[drbIdx].drbId);
+ ret = RFAILED;
+ break;
+ }
+ }
+ }
+ return ret;
+}
+
+/*******************************************************************
+ *
+ * @brief @brief To update DuUeCb Mac and Rlc Ue Cfg
+ *
+ *
+ * @details
+ *
+ * Function : duUpdateDuUeCbCfg
+ *
+ * Functionality: update DuUeCb Mac and Rlc Ue Cfg
+ *
+ * @params[in] ueId, cellIdx
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t duUpdateDuUeCbCfg(uint8_t ueId, uint8_t cellId)
+{
+ uint8_t ret = ROK;
+ uint16_t cellIdx = 0, crnti=0;
+ DuUeCb *ueCb = NULLP;
+
+ GET_CELL_IDX(cellId, cellIdx);
+ ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueId-1];
+
+ /*Filling RLC Ue Cfg */
+ ueCb->duRlcUeCfg.cellId = cellId;
+ ueCb->duRlcUeCfg.ueId = ueId;
+ ret = duUpdateRlcLcCfg(&ueCb->duRlcUeCfg, ueCb->f1UeDb);
+ if(ret == ROK)
+ {
+ /*Filling MAC Ue Cfg */
+ GET_CRNTI(crnti, ueId);
+ ueCb->duMacUeCfg.cellId = cellId;
+ ueCb->duMacUeCfg.ueId = ueId;
+ ueCb->duMacUeCfg.crnti = crnti;
+ ret = duUpdateMacCfg(&ueCb->duMacUeCfg, ueCb->f1UeDb);
+ if(ret == RFAILED)
+ DU_LOG("\nERROR --> DU APP : Failed while updating MAC LC Config at duUpdateDuUeCbCfg()");
+ else
+ {
+ if(duUpdateTunnelCfgDb(ueId, cellId, &ueCb->f1UeDb->duUeCfg) != ROK)
+ {
+ DU_LOG("\nERROR --> DU_APP : Failed to establish tunnel in duUpdateDuUeCbCfg()");
+ return RFAILED;
+ }
+ }
+ }
+ else
+ DU_LOG("\nERROR --> DU APP : Failed while updating RLC LC Config at duUpdateDuUeCbCfg()");
+ return ret;
+}
+
+/*******************************************************************
+ *
+ * @brief Handle UE create response from MAC
+ *
+ * @details
+ *
+ * Function : DuProcMacUeCreateRsp
+ *
+ * Functionality: Handle UE Create response from MAC
+ *
+ * @params[in] Pointer to MacUeCreateRsp and Pst
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t DuProcMacUeCreateRsp(Pst *pst, MacUeCreateRsp *cfgRsp)
+{
+ uint8_t ret = ROK;
+ uint16_t cellIdx;
+
+ if(cfgRsp)
+ {
+ GET_CELL_IDX(cfgRsp->cellId, cellIdx);
+ if(cfgRsp->result == MAC_DU_APP_RSP_OK)
+ {
+ if(pst->event == EVENT_MAC_UE_CREATE_RSP)
+ {
+ DU_LOG("\nINFO --> DU APP : MAC UE Create Response : SUCCESS [DU UE F1AP ID : %d]", cfgRsp->ueId);
+
+ if(duCb.actvCellLst[cellIdx] && (duCb.actvCellLst[cellIdx]->ueCb[cfgRsp->ueId -1].gnbDuUeF1apId == cfgRsp->ueId))
+ {
+ duCb.actvCellLst[cellIdx]->ueCb[cfgRsp->ueId -1].duMacUeCfg.macUeCfgState = UE_CREATE_COMPLETE;
+
+ if((duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].ueState == UE_HANDIN_IN_PROGRESS) &&
+ (duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].duMacUeCfg.macUeCfgState == UE_CREATE_COMPLETE) &&
+ (duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].duRlcUeCfg.rlcUeCfgState == UE_CREATE_COMPLETE))
+ {
+ if((ret = duUpdateDuUeCbCfg(cfgRsp->ueId, cfgRsp->cellId)) == ROK)
+ {
+ /* If UE is in handover, RACH resource needs to be requested
+ * from MAC for CFRA */
+ if((duBuildAndSendRachRsrcReqToMac(cfgRsp->cellId, cfgRsp->ueId)) != ROK)
+ {
+ DU_LOG("\nERROR --> DU APP : Failed to send RACH Resource Request to MAC");
+ DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(MacUeCreateRsp));
+ return RFAILED;
+ }
+ }
+ else
+ {
+ DU_LOG("\nERROR -> DU APP : Failure in updating DU UE CB");
+ DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(MacUeCreateRsp));
+ return RFAILED;
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ DU_LOG("\nERROR --> DU APP : MAC UE CFG Response for EVENT[%d]: FAILURE [DU UE F1AP ID : %d]", pst->event, cfgRsp->ueId);
+ ret = RFAILED;
+ }
+ DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(MacUeCreateRsp));
+ }
+ else
+ {
+ DU_LOG("\nERROR --> DU APP : Received MAC Ue Config Response is NULL at DuProcMacUeCreateRsp()");
+ ret = RFAILED;
+ }
+ return ret;
+}
+
+/*******************************************************************
+ *
+ * @brief Handle UE Reconfig response from MAC
+ *
+ * @details
+ *
+ * Function : DuProcMacUeRecfgRsp
+ *
+ * Functionality: Handle UE ReConfig response from MAC
+ *
+ * @params[in] Pointer to MacUeRecfgRsp and Pst
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t DuProcMacUeRecfgRsp(Pst *pst, MacUeRecfgRsp *reCfgRsp)
+{
+ uint8_t ret = ROK;
+ uint16_t cellIdx;
+
+ if(reCfgRsp)
+ {
+ GET_CELL_IDX(reCfgRsp->cellId, cellIdx);
+ if(reCfgRsp->result == MAC_DU_APP_RSP_OK)
+ {
+ if(pst->event == EVENT_MAC_UE_RECONFIG_RSP)
+ {
+ DU_LOG("\nINFO --> DU APP : MAC UE Reconfig Response : SUCCESS [DU UE F1AP ID : %d]", reCfgRsp->ueId);
+ if(duCb.actvCellLst[cellIdx] &&
+ (duCb.actvCellLst[cellIdx]->ueCb[reCfgRsp->ueId -1].gnbDuUeF1apId == reCfgRsp->ueId))
+ {
+ duCb.actvCellLst[cellIdx]->ueCb[reCfgRsp->ueId -1].duMacUeCfg.macUeCfgState = UE_RECFG_COMPLETE;
+ if((duCb.actvCellLst[cellIdx]->ueCb[reCfgRsp->ueId -1].duMacUeCfg.macUeCfgState == UE_RECFG_COMPLETE) &&
+ (duCb.actvCellLst[reCfgRsp->cellId -1]->ueCb[reCfgRsp->ueId -1].duRlcUeCfg.rlcUeCfgState == UE_RECFG_COMPLETE))
+ {
+ if((ret = duUpdateDuUeCbCfg(reCfgRsp->ueId, reCfgRsp->cellId)) == ROK)
+ {
+ if((BuildAndSendUeCtxtRsp(reCfgRsp->cellId, reCfgRsp->ueId)) != ROK)
+ {
+ DU_LOG("\nERROR -> DU APP : Failure in BuildAndSendUeCtxtRsp()");
+ DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, reCfgRsp, sizeof(MacUeRecfgRsp));
+ return RFAILED;
+ }
+ }
+ else
+ {
+ DU_LOG("\nERROR -> DU APP : Failure in updating DU UE CB");
+ DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, reCfgRsp, sizeof(MacUeRecfgRsp));
+ return RFAILED;
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ DU_LOG("\nERROR --> DU APP : MAC UE RECFG Response for EVENT[%d]: FAILURE [DU UE F1AP ID : %d]", pst->event, reCfgRsp->ueId);
+ if(pst->event == EVENT_MAC_UE_RECONFIG_RSP)
+ {
+ //TODO: Send the failure case in Ue Context Setup Response
+ }
+ ret = RFAILED;
+ }
+ DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, reCfgRsp, sizeof(MacUeRecfgRsp));
+ }
+ else
+ {
+ DU_LOG("\nERROR --> DU APP : Received MAC Ue ReConfig Response is NULL at DuProcMacUeRecfgRsp()");
+ ret = RFAILED;
+ }
+ return ret;
+}
+
+/*******************************************************************
+ *
+ * @brief Processes UE create Req to RLC UL
+ *
+ * @details
+ *
+ * Function : duBuildAndSendUeCreateReqToRlc
+ *
+ * Functionality:
+ * Processes UE create Req to RLC UL
+ *
+ * @params[in] cellId,
+ * ueId,
+ * Pointer to RlcUeCreate
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ *****************************************************************/
+
+uint8_t duBuildAndSendUeCreateReqToRlc(uint16_t cellId, uint8_t gnbDuUeF1apId, DuUeCfg *ueCfgDb, DuRlcUeCfg *duRlcUeCfg)
+{
+ uint8_t ret = ROK;
+ RlcUeCreate *rlcUeCfg = NULLP;
+ Pst pst;
+
+ ret = updateRlcUeCfg(cellId, gnbDuUeF1apId, ueCfgDb, duRlcUeCfg);
+ if(ret == RFAILED)
+ {
+ DU_LOG("\nERROR --> DU APP : Failed to fill Rlc Ue Cfg at duBuildAndSendUeCreateReqToRlc()");
+ return ret;
+ }
+
+ FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_CREATE_REQ);
+ /* Copying ueCfg to a sharable buffer */
+ DU_ALLOC_SHRABL_BUF(rlcUeCfg, sizeof(RlcUeCreate));
+ if(rlcUeCfg)
+ {
+ memset(rlcUeCfg, 0, sizeof(RlcUeCreate));
+ fillRlcUeCfg(duRlcUeCfg, rlcUeCfg);
+
+ /* Processing one Ue at a time to RLC */
+ DU_LOG("\nDEBUG --> DU_APP: Sending UE create request to RLC UL");
+ ret = (*packRlcUeCreateReqOpts[pst.selector])(&pst, rlcUeCfg);
+ if(ret == RFAILED)
+ {
+ DU_LOG("\nERROR --> DU_APP : Failure in sending Ue Create Req to RLC");
+ DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rlcUeCfg, sizeof(RlcUeCreate));
+ ret = RFAILED;
+ }
+ }
+ else
+ {
+ DU_LOG("\n ERROR --> DU APP : Memory alloc failed at duBuildAndSendUeCreateReqToRlc()");
+ ret = RFAILED;
+ }
+ return ret;
+}
+
+/*******************************************************************
+ *
+ * @brief Processes UE create Rsp received from RLC UL
+ *
+ * @details
+ *
+
+ * Function : DuProcRlcUeCreateRsp
+ *
+ * Functionality:
+ * Processes UE create Rsp received from RLC UL
+ *
+ * @params[in] Post structure
+ * Pointer to RlcCfgCfm
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ *****************************************************************/
+uint8_t DuProcRlcUeCreateRsp(Pst *pst, RlcUeCreateRsp *cfgRsp)
+{
+ uint8_t ret = ROK;
+
+ if(cfgRsp)
+ {
+ if(cfgRsp->result == RLC_DU_APP_RSP_OK)
+ {
+ if(pst->event == EVENT_RLC_UE_CREATE_RSP)
+ {
+ DU_LOG("\nINFO --> DU_APP: RLC UE Create Response : SUCCESS [UE IDX:%d]", cfgRsp->ueId);
+ duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].duRlcUeCfg.rlcUeCfgState = UE_CREATE_COMPLETE;
+
+ if((duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].ueState == UE_HANDIN_IN_PROGRESS) &&
+ (duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].duMacUeCfg.macUeCfgState == UE_CREATE_COMPLETE) &&
+ (duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].duRlcUeCfg.rlcUeCfgState == UE_CREATE_COMPLETE))
+ {
+ if((ret = duUpdateDuUeCbCfg(cfgRsp->ueId, cfgRsp->cellId)) == ROK)
+ {
+ /* If UE is in handover, RACH resource needs to be requested
+ * from MAC for CFRA */
+ if((duBuildAndSendRachRsrcReqToMac(cfgRsp->cellId, cfgRsp->ueId)) != ROK)
+ {
+ DU_LOG("\nERROR --> DU APP : Failed to send RACH Resource Request to MAC");
+ DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(RlcUeCreateRsp));
+ return RFAILED;
+ }
+ }
+ else
+ {
+ DU_LOG("\nERROR --> DU APP : Failure in updating DU UE CB");
+ DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(RlcUeCreateRsp));
+ return RFAILED;
+ }
+ }
+ }
+ }
+ else
+ {
+ DU_LOG("\nERROR --> DU_APP: RLC UE CREATE Response for EVENT[%d] : FAILED [UE IDX : %d, REASON :%d]",\
+ pst->event, cfgRsp->ueId, cfgRsp->reason);
+ ret = RFAILED;
+ }
+ DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(RlcUeCreateRsp));
+ }
+ else
+ {
+ DU_LOG("\nERROR --> DU_APP: Received RLC Ue Create Response is NULL at DuProcRlcUeCreateRsp()");
+ ret = RFAILED;
+ }
+ return ret;
+}
+
+/*******************************************************************
+ *
+ * @brief Processes UE reconfig Rsp received from RLC UL
+ *
+ * @details
+ *
+
+ * Function : DuProcRlcUeReconfigRsp
+ *
+ * Functionality:
+ * Processes UE reconfig Rsp received from RLC UL
+ *
+ * @params[in] Post structure
+ * Pointer to RlcCfgCfm
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ *****************************************************************/
+uint8_t DuProcRlcUeReconfigRsp(Pst *pst, RlcUeReconfigRsp *cfgRsp)
+{
+ uint8_t ret = ROK;
+
+ if(cfgRsp)
+ {
+ if(cfgRsp->result == RLC_DU_APP_RSP_OK)
+ {
+ if(pst->event == EVENT_RLC_UE_RECONFIG_RSP)
+ {
+ DU_LOG("\nINFO --> DU_APP: RLC UE Reconfig Response : SUCCESS [UE IDX:%d]", cfgRsp->ueId);
+
+ duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].duRlcUeCfg.rlcUeCfgState = UE_RECFG_COMPLETE;
+ if((duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].duMacUeCfg.macUeCfgState == UE_RECFG_COMPLETE) &&
+ (duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].duRlcUeCfg.rlcUeCfgState == UE_RECFG_COMPLETE))
+ {
+ if((ret = duUpdateDuUeCbCfg(cfgRsp->ueId, cfgRsp->cellId)) == ROK)
+ {
+ if((BuildAndSendUeCtxtRsp(cfgRsp->cellId, cfgRsp->ueId)) != ROK)
+ {
+ DU_LOG("\nERROR --> DU APP : Failure in BuildAndSendUeCtxtRsp");
+ DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(RlcUeReconfigRsp));
+ return RFAILED;
+ }
+ }
+ else
+ {
+ DU_LOG("\nERROR --> DU APP : Failure in updating DU UE CB");
+ DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(RlcUeReconfigRsp));
+ return RFAILED;
+ }
+ }
+ }
+ }
+ else
+ {
+ DU_LOG("\nERROR --> DU_APP: RLC UE RE-CFG Response for EVENT[%d] : FAILED [UE IDX : %d, REASON :%d]",\
+ pst->event, cfgRsp->ueId, cfgRsp->reason);
+ if((pst->event == EVENT_RLC_UE_RECONFIG_RSP))
+ {
+ //TODO: update failure case in ue Context setup Response
+ }
+ ret = RFAILED;
+ }
+ DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(RlcUeReconfigRsp));
+ }
+ else
+ {
+ DU_LOG("\nERROR --> DU_APP: Received RLC Ue ReConfig Response is NULL at DuProcRlcUeReconfigRsp()");
+ ret = RFAILED;
+ }
+ return ret;
+}
+/**********************************************************************************
+ *
+ * @brief Fills Ue ReCfg from DU DB to RlcUeRecfg
+ *
+ * @details
+ *
+ * Function : fillRlcUeRecfg
+ *
+ * Functionality: fills ue ReCfg to be sent to RLC
+ *
+ * @params[in] DuRlcUeCfg Pointer
+ * RlcUeRecfg Pointer
+ *
+ * @return void
+ * *******************************************************************************/
+void fillRlcUeRecfg(DuRlcUeCfg *duRlcUeCfg, RlcUeRecfg *rlcUeRecfg)
+{
+ uint8_t lcIdx = 0;
+
+ rlcUeRecfg->cellId = duRlcUeCfg->cellId;
+ rlcUeRecfg->ueId = duRlcUeCfg->ueId;
+
+
+ if(duRlcUeCfg->numLcs > 0)
+ {
+ rlcUeRecfg->numLcsToAdd = 0;
+ rlcUeRecfg->numLcsToMod = 0;
+ rlcUeRecfg->numLcsToRel = 0;
+
+ for(lcIdx = 0; lcIdx < duRlcUeCfg->numLcs; lcIdx++)
+ {
+ if(duRlcUeCfg->rlcLcCfg[lcIdx].configType == CONFIG_ADD)
+ {
+ memcpy(&rlcUeRecfg->rlcLcCfgAdd[rlcUeRecfg->numLcsToAdd], &duRlcUeCfg->rlcLcCfg[lcIdx].rlcBearerCfg, sizeof(RlcBearerCfg));
+ rlcUeRecfg->numLcsToAdd++;
+ }
+ if(duRlcUeCfg->rlcLcCfg[lcIdx].configType == CONFIG_MOD)
+ {
+ memcpy(&rlcUeRecfg->rlcLcCfgMod[rlcUeRecfg->numLcsToMod], &duRlcUeCfg->rlcLcCfg[lcIdx].rlcBearerCfg, sizeof(RlcBearerCfg));
+ rlcUeRecfg->numLcsToMod++;
+ }
+ if(duRlcUeCfg->rlcLcCfg[lcIdx].configType == CONFIG_DEL)
+ {
+ memcpy(&rlcUeRecfg->rlcLcCfgRel[rlcUeRecfg->numLcsToRel], &duRlcUeCfg->rlcLcCfg[lcIdx].rlcBearerCfg, sizeof(RlcBearerCfg));
+ rlcUeRecfg->numLcsToRel++;
+ }
+ }
+ }
+ return;
+}
+
+/*******************************************************************
+ *
+ * @brief Builds and Send Ue Reconfig Req to RLC
+ *
+ * @details
+ *
+ * Function : duBuildAndSendUeRecfgReqToRLC
+ *
+ * Functionality: Builds and Send Ue Reconfig Req to RLC
+ *
+ * @params[in] uint16_t cellId,
+ * uint6_t crnti #AS per 38.473 V15.3.0, Section 9.3.1.32 crnti
+ * value range is b/w 0..65535#
+ * DuUeCfg *ueCfgDb
+ * RlcUeCreate *rlcUeCfg
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t duBuildAndSendUeRecfgReqToRlc(uint16_t cellId, uint8_t gnbDuUeF1apId, uint16_t crnti, DuUeCfg *ueCfgDb)
+{
+ uint8_t ret = ROK;
+ DuRlcUeCfg *duRlcUeCfg = NULLP;
+ RlcUeRecfg *rlcUeRecfg = NULLP;
+
+ DU_ALLOC(duRlcUeCfg, sizeof(DuRlcUeCfg));
+ DU_ALLOC_SHRABL_BUF(rlcUeRecfg, sizeof(RlcUeRecfg));
+ if(duRlcUeCfg && rlcUeRecfg)
+ {
+ memset(duRlcUeCfg, 0, sizeof(DuRlcUeCfg));
+ memset(rlcUeRecfg, 0, sizeof(RlcUeRecfg));
+
+ ret = updateRlcUeCfg(cellId, gnbDuUeF1apId, ueCfgDb, duRlcUeCfg);
+
+ if(ret == RFAILED)
+ DU_LOG("\nERROR --> DU APP : Failed at duBuildAndSendUeRecfgReqToRlc()");
+ else
+ {
+ fillRlcUeRecfg(duRlcUeCfg, rlcUeRecfg);
+ ret = sendUeRecfgReqToRlc(rlcUeRecfg);
+ }
+ }
+ else
+ {
+ DU_LOG("\nERROR --> DU APP : Memory Alloc failed at duBuildAndSendUeRecfgReqToRlc()");
+ ret = RFAILED;
+ }
+ DU_FREE(duRlcUeCfg, sizeof(DuRlcUeCfg));
+ return ret;
+}
+
+/**********************************************************************************
+ *
+ * @brief Fills Ue ReCfg from DU DB to MacUeRecfg
+ *
+ * @details
+ *
+ * Function : fillMacUeRecfg
+ *
+ * Functionality: fills ue ReCfg to be sent to MAC
+ *
+ * @params[in] DuMacUeCfg Pointer
+ * MacUeRecfg Pointer
+ *
+ * @return void
+ * *******************************************************************************/
+void fillMacUeRecfg(DuMacUeCfg *duMacUeCfg, MacUeRecfg *macUeRecfg)
+{
+ uint8_t lcIdx = 0;
+
+ macUeRecfg->cellId = duMacUeCfg->cellId;
+ macUeRecfg->ueId = duMacUeCfg->ueId;
+ macUeRecfg->crnti = duMacUeCfg->crnti;
+ macUeRecfg->macCellGrpRecfgPres = duMacUeCfg->macCellGrpCfgPres;
+ if(macUeRecfg->macCellGrpRecfgPres)
+ {
+ memcpy(&macUeRecfg->macCellGrpRecfg, &duMacUeCfg->macCellGrpCfg, sizeof(MacCellGrpCfg));
+ }
+ macUeRecfg->phyCellGrpRecfgPres = duMacUeCfg->phyCellGrpCfgPres;
+ if(macUeRecfg->phyCellGrpRecfgPres)
+ {
+ memcpy(&macUeRecfg->phyCellGrpRecfg, &duMacUeCfg->phyCellGrpCfg, sizeof(PhyCellGrpCfg));
+ }
+ macUeRecfg->spCellRecfgPres = duMacUeCfg->spCellCfgPres;
+ if(macUeRecfg->spCellRecfgPres)
+ {
+ memcpy(&macUeRecfg->spCellRecfg, &duMacUeCfg->spCellCfg, sizeof(SpCellRecfg));
+ }
+ if(duMacUeCfg->ambrCfg != NULLP)
+ {
+ DU_ALLOC_SHRABL_BUF(macUeRecfg->ambrRecfg, sizeof(AmbrCfg));
+ memcpy(macUeRecfg->ambrRecfg, duMacUeCfg->ambrCfg, sizeof(AmbrCfg));
+ }
+ memcpy(&macUeRecfg->dlModInfo, &duMacUeCfg->dlModInfo, sizeof(ModulationInfo));
+ memcpy(&macUeRecfg->ulModInfo, &duMacUeCfg->ulModInfo, sizeof(ModulationInfo));
+ if(duMacUeCfg->numLcs > 0)
+ {
+ macUeRecfg->numLcsToAdd = 0;
+ macUeRecfg->numLcsToDel = 0;
+ macUeRecfg->numLcsToMod = 0;
+
+ for(lcIdx = 0; lcIdx < duMacUeCfg->numLcs; lcIdx++)
+ {
+ if(duMacUeCfg->lcCfgList[lcIdx].configType == CONFIG_ADD)
+ {
+ /*VS: To thoroughly check*/
+ memcpy(&macUeRecfg->lcCfgAdd[macUeRecfg->numLcsToAdd], &duMacUeCfg->lcCfgList[lcIdx].lcConfig, sizeof(LcCfg));
+ macUeRecfg->numLcsToAdd++;
+ }
+ if(duMacUeCfg->lcCfgList[lcIdx].configType == CONFIG_DEL)
+ {
+ /*VS: To thoroughly check*/
+ macUeRecfg->lcIdToDel[macUeRecfg->numLcsToDel] = duMacUeCfg->lcCfgList[lcIdx].lcConfig.lcId;
+ macUeRecfg->numLcsToDel++;
+ }
+ if(duMacUeCfg->lcCfgList[lcIdx].configType == CONFIG_MOD)
+ {
+ /*VS: To thoroughly check*/
+ memcpy(&macUeRecfg->lcCfgMod[macUeRecfg->numLcsToMod], &duMacUeCfg->lcCfgList[lcIdx].lcConfig, sizeof(LcCfg));
+ macUeRecfg->numLcsToMod++;
+ }
+ }
+ }
+ macUeRecfg->transmissionAction = duMacUeCfg->transmissionAction;
+#ifdef NR_DRX
+ macUeRecfg->drxConfigIndicatorRelease = duMacUeCfg->drxConfigIndicatorRelease;
+#endif
+}
+
+/*******************************************************************
+ *
+ * @brief Builds and Send Ue Reconfig Req to MAC
+ *
+ * @details
+ *
+ * Function : duBuildAndSendUeRecfgReqToMac
+ *
+ * Functionality: Builds and Send Ue Reconfig Req to MAC
+ *
+ * @params[in] uint16_t cellId,
+ * uint6_t crnti #AS per 38.473 V15.3.0, Section 9.3.1.32 crnti
+ * value range is b/w 0..65535#
+ * CellGroupConfigRrc_t *macCellGrpCfg
+ * DuUeCfg *ueCfgDb
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t duBuildAndSendUeRecfgReqToMac(uint16_t cellId, uint8_t duUeF1apId, uint16_t crnti, DuUeCfg *ueCfgDb)
+{
+ uint8_t ret = ROK;
+ DuMacUeCfg *duMacUeCfg = NULLP;
+ MacUeRecfg *macUeRecfg = NULLP;
+
+ DU_ALLOC(duMacUeCfg, sizeof(DuMacUeCfg));
+ DU_ALLOC_SHRABL_BUF(macUeRecfg, sizeof(MacUeRecfg));
+ if(macUeRecfg && duMacUeCfg)
+ {
+ memset(duMacUeCfg, 0, sizeof(DuMacUeCfg));
+ memset(macUeRecfg, 0, sizeof(MacUeRecfg));
+
+ ret = updateDuMacUeCfg(cellId, duUeF1apId, crnti, ueCfgDb, duMacUeCfg);
+ if(ret == RFAILED)
+ DU_LOG("\nERROR --> DU APP : Failed to fill Mac Ue Cfg at duBuildAndSendUeRecfgReqToMac()");
+ else
+ {
+ fillMacUeRecfg(duMacUeCfg, macUeRecfg);
+ ret = sendUeRecfgReqToMac(macUeRecfg);
+ }
+ }
+ else
+ {
+ DU_LOG("\nERROR --> DU APP : Memory alloc failed for macUeCfg at duBuildAndSendUeRecfgReqToMac()");
+ ret = RFAILED;
+ }
+ DU_FREE(duMacUeCfg, sizeof(DuMacUeCfg));
+
+ return ret;
+}
+
+/*******************************************************************
+ *
+ * @brief Build and Send Ue context setup request
+ *
+ * @details
+ *
+
+ * Function : duBuildAndSendUeContextSetupReq
+ *
+ * Functionality:
+ * Build and Send Ue context setup request
+ *
+ * @params[in] cellId, crnti, DuUeCfg pointer
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ *****************************************************************/
+
+uint8_t duBuildAndSendUeContextSetupReq(uint16_t cellId, DuUeCb *ueCb)
+{
+ uint8_t ret = ROK;
+ uint16_t crnti;
+ DuUeCfg *duUeCfg = NULLP;
+
+ DU_LOG("\nDEBUG --> DU_APP: Processing Ue Context Setup Request for cellId [%d]", cellId);
+
+ if(!ueCb)
+ {
+ DU_LOG("\nERROR --> DU APP : UE Cb is NULL");
+ return RFAILED;
+ }
+
+ crnti = ueCb->crnti;
+ duUeCfg = &ueCb->f1UeDb->duUeCfg;
+
+ /* If UE is being handed-in to this DU, UE context setup request will create
+ * new UE context at MAC/SCH and RLC.
+ * If UE is in active state, UE contex setup request will lead to
+ * reconfiguration of UE at MAC/SCH and RLC
+ */
+ if(ueCb->ueState == UE_HANDIN_IN_PROGRESS)
+ {
+ /* Filling MAC UE Config */
+ memset(&ueCb->duMacUeCfg, 0, sizeof(DuMacUeCfg));
+
+ /* Since UE attach has not yet happened, crnti is unknow. Hence passing 0 */
+ ret = duBuildAndSendUeCreateReqToMac(cellId, ueCb->gnbDuUeF1apId, 0, duUeCfg, &ueCb->duMacUeCfg);
+ if(ret == RFAILED)
+ DU_LOG("\nERROR --> DU APP : Failed to send UE create request to MAC");
+
+ ret = duBuildAndSendUeCreateReqToRlc(cellId, ueCb->gnbDuUeF1apId, duUeCfg, &ueCb->duRlcUeCfg);
+ if(ret == RFAILED)
+ DU_LOG("\nERROR --> DU APP : Failed to send UE create request to RLC");
+
+ }
+ else
+ {
+ /* Filling RLC UE Reconfig */
+ ret = duBuildAndSendUeRecfgReqToRlc(cellId, ueCb->gnbDuUeF1apId, crnti, duUeCfg);
+ if(ret == RFAILED)
+ DU_LOG("\nERROR --> DU APP : Failed to build ctxt setup req for RLC at duBuildAndSendUeContextSetupReq()");
+
+ /* Filling MAC UE Reconfig */
+ ret = duBuildAndSendUeRecfgReqToMac(cellId, ueCb->gnbDuUeF1apId, crnti, duUeCfg);
+ if(ret == RFAILED)
+ DU_LOG("\nERROR --> DU APP : Failed at build ctxt setup req for MAC at duBuildAndSendUeContextSetupReq()");
+ }
+
+ return ret;
+}
+
+/*******************************************************************
+ *
+ * @brief Processes DL Rsp received from RLC DL
+ *
+ * @details
+ *
+
+ * Function : DuProcRlcDlRrcMsgRsp
+ *
+ * Functionality:
+ * Processes UE Rsp received from RLC DL
+ *
+ * @params[in] Post structure
+ * Pointer to RlcCfgCfm
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ *****************************************************************/
+uint8_t DuProcRlcDlRrcMsgRsp(Pst *pst, RlcDlRrcMsgRsp *dlRrcMsg)
+{
+ uint8_t ret = ROK, ueId = 0;
+ uint16_t cellId, crnti;
+ DuUeCb *ueCb = NULLP;
+ DlMsgState state;
+
+ state = dlRrcMsg->state;
+ cellId = dlRrcMsg->cellId;
+ crnti = dlRrcMsg->crnti;
+ DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlRrcMsg, sizeof(RlcDlRrcMsgRsp));
+
+ if(state == TRANSMISSION_COMPLETE)
+ {
+ GET_UE_ID(crnti, ueId);
+ ueCb = &duCb.actvCellLst[cellId -1]->ueCb[ueId -1];
+
+ if(ueCb->f1UeDb && ueCb->f1UeDb->dlRrcMsgPres)
+ {
+ if(ueCb->f1UeDb->actionType == UE_CTXT_SETUP)
+ {
+ ret = duBuildAndSendUeContextSetupReq(cellId, ueCb);
+ if(ret == RFAILED)
+ DU_LOG("\nERROR --> DU APP : Failed to process UE Context Setup Request in DuProcRlcDlRrcMsgRsp()");
+ }
+
+ if(ueCb->f1UeDb->actionType == UE_CTXT_MOD)
+ {
+ ret = duBuildAndSendUeContextModReq(cellId, ueCb->gnbDuUeF1apId, crnti, &ueCb->f1UeDb->duUeCfg);
+ if(ret == RFAILED)
+ DU_LOG("\nERROR --> DU APP : Failed to process UE Context Mod Request in DuProcRlcDlRrcMsgRsp()");
+ }
+
+ if(ueCb->f1UeDb->actionType == UE_CTXT_RELEASE && ueCb->ueState == UE_ACTIVE)
+ {
+ ret = duBuildAndSendUeDeleteReq(cellId, crnti);
+ if(ret == RFAILED)
+ {
+ DU_LOG("\nERROR --> DU APP : Failed to process UE Context Release Request in DuProcRlcDlRrcMsgRsp()");
+ }
+ }
+ }
+ }
+ else
+ DU_LOG("\nERROR --> DU APP : Failed to transmit DL RRC Msg");
+
+ return ret;
+}
+/*******************************************************************
+ *
+ * @brief Process UE context setup request from CU
+ *
+ * @details
+ *
+ * Function : duProcUeContextSetupRequest
+ *
+ * Functionality: Process UE context setup request from CU
+ *
+ * @params[in] F1AP message
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t duProcUeContextSetupRequest(DuUeCb *ueCb)
+{
+ uint8_t ret, cellId;
+
+ ret = ROK;
+ if(ueCb)
+ {
+ cellId = duCb.actvCellLst[ueCb->f1UeDb->cellIdx]->cellId;
+
+ /* Send DL RRC msg for security Mode */
+ if(ueCb->f1UeDb->dlRrcMsg)
+ {
+ if(ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
+ {
+ /* Sending DL RRC Message to RLC */
+ ret = duBuildAndSendDlRrcMsgToRlc(cellId, ueCb->duRlcUeCfg, ueCb->f1UeDb->dlRrcMsg);
+ if(ret == RFAILED)
+ {
+ DU_LOG("\nERROR --> DU APP : Failed to send DL RRC msg in duProcUeContextSetupRequest()");
+ DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
+ ueCb->f1UeDb->dlRrcMsg->rrcMsgSize);
+ DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
+ }
+ }
+ }
+ else if(ueCb->f1UeDb->actionType == UE_CTXT_SETUP)
+ {
+ ret = duBuildAndSendUeContextSetupReq(cellId, ueCb);
+ if(ret == RFAILED)
+ {
+ DU_LOG("\nERROR --> DU APP : Failed to build ue context setup Req in duProcUeContextSetupRequest()");
+ }
+ }
+ }
+ else
+ {
+ //TODO: To send the failure cause in UeContextSetupRsp
+ DU_LOG("ERROR --> DU APP : Failed to process UE CNTXT SETUP REQ at duProcUeContextSetupRequest()");
+ }
+ return ret;
+}
+
+/*******************************************************************
+ *
+ * @brief Build and Send Ue context mod request
+ *
+ * @details
+ *
+ *
+ * Function : duBuildAndSendUeContextModReq
+ *
+ * Functionality:
+ * Build and Send Ue context mod request
+ *
+ * @params[in] cellId, crnti, DuUeCfg pointer
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ *****************************************************************/
+
+uint8_t duBuildAndSendUeContextModReq(uint16_t cellId, uint8_t gnbDuUeF1apId, uint16_t crnti, DuUeCfg *duUeCfg)
+{
+ uint8_t ret = ROK;
+
+ DU_LOG("\nDEBUG --> DU_APP: Processing Ue Context Mod Request for cellId [%d]", cellId);
+ /* Filling RLC Ue Reconfig */
+ ret = duBuildAndSendUeRecfgReqToRlc(cellId, gnbDuUeF1apId, crnti, duUeCfg);
+ if(ret == RFAILED)
+ DU_LOG("\nERROR --> DU APP : Failed to build ctxt setup req for RLC at duBuildAndSendUeContextModReq()");
+
+ /* Filling MAC Ue Reconfig */
+ ret = duBuildAndSendUeRecfgReqToMac(cellId, gnbDuUeF1apId, crnti, duUeCfg);
+ if(ret == RFAILED)
+ DU_LOG("\nERROR --> DU APP : Failed at build ctxt setup req for MAC at duBuildAndSendUeContextModReq()");
+
+ return ret;
+}
+/*******************************************************************
+ *
+ * @brief Processing Ue context mod request
+ *
+ * @details
+ *
+ *
+ * Function : duProcUeContextModReq
+ *
+ * Functionality:
+ * Processing Ue context mod request
+ *
+ * @params[in] DuUeCb *ueCb
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ *****************************************************************/
+
+uint8_t duProcUeContextModReq(DuUeCb *ueCb)
+{
+ uint8_t ret, cellId;
+
+ ret = ROK;
+ if(ueCb)
+ {
+ cellId = duCb.actvCellLst[ueCb->f1UeDb->cellIdx]->cellId;
+ /* Send DL RRC msg for security Mode */
+ if(ueCb->f1UeDb->dlRrcMsg)
+ {
+ if(ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
+ {
+ /* Sending DL RRC Message to RLC */
+ ret = duBuildAndSendDlRrcMsgToRlc(cellId, ueCb->duRlcUeCfg, ueCb->f1UeDb->dlRrcMsg);
+ if(ret == RFAILED)
+ {
+ DU_LOG("\nERROR --> DU APP : Failed to send DL RRC msg in duProcUeContextModReq()");
+ DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
+ ueCb->f1UeDb->dlRrcMsg->rrcMsgSize);
+ DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
+ }
+ }
+ }
+ else if(ueCb->f1UeDb->actionType == UE_CTXT_MOD)
+ {
+ ret = duBuildAndSendUeContextModReq(cellId, ueCb->gnbDuUeF1apId, ueCb->crnti, &ueCb->f1UeDb->duUeCfg);
+ if(ret == RFAILED)
+ {
+ DU_LOG("\nERROR --> DU APP : Failed to build ue context setup Req in duProcUeContextModReq()");
+ return RFAILED;
+ }
+ }
+ else if((ueCb->f1UeDb->actionType == UE_CTXT_CFG_QUERY) || (ueCb->f1UeDb->actionType == UE_CTXT_RRC_RECFG_COMPLETE))
+ {
+ if((BuildAndSendUeContextModRsp(ueCb) != ROK))
+ {
+ DU_LOG("\nERROR --> DU APP : Failed to build UE Context modification response");
+ return RFAILED;
+ }
+ }
+ }
+ else
+ {
+ //TODO: To send the failure cause in UeContextModRsp
+
+ DU_LOG("ERROR --> DU APP : Failed to process UE CNTXT MOD REQ at duProcUeContextModReq()");
+ return RFAILED;
+ }
+ return ROK;
+}
+
+/*******************************************************************
+*
+* @brief Build and send dedicated RACH resource release request to MAC
+*
+* @details
+*
+* Function : duBuildAndSendRachRsrcRelToMac
+*
+* Functionality: Function to Build and send dedicated RACH resource
+* release request to MAC
+*
+* @params[in] Cell ID
+* UE CB
+* @return ROK - Success
+* RFAILED - Failure
+*
+* ****************************************************************/
+uint8_t duBuildAndSendRachRsrcRelToMac(uint16_t cellId, DuUeCb *ueCb)
+{
+ Pst pst;
+ MacRachRsrcRel *rachRsrcRel = NULLP;
+
+ DU_ALLOC_SHRABL_BUF(rachRsrcRel, sizeof(MacRachRsrcRel));
+ if(!rachRsrcRel)
+ {
+ DU_LOG("\nERROR --> DU APP : Failed to allocate memory for RACH Resource Release in \
+ duBuildAndSendRachRsrcRelToMac()");
+ return RFAILED;
+ }
+
+ rachRsrcRel->cellId = cellId;
+ rachRsrcRel->ueId = ueCb->gnbDuUeF1apId;
+ rachRsrcRel->crnti = ueCb->crnti;
+
+ /* Fill Pst */
+ FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_RACH_RESOURCE_REL);
+
+ if(((*packMacRachRsrcRelOpts[pst.selector])(&pst, rachRsrcRel)) != ROK)
+ {
+ DU_LOG("\nERROR --> DU_APP : Failure in sending RACH Resource Release to MAC at \
+ duBuildAndSendRachRsrcRelToMac()");
+ DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rachRsrcRel, sizeof(MacRachRsrcRel));
+ return RFAILED;
+ }
+
+ return ROK;
+}
+
+/*******************************************************************
+ *
+* @brief delete DuMacUeCfg from duCb
+*
+* @details
+*
+* Function : deleteMacUeCfg
+*
+* Functionality: delete DuMacUeCfg from duCb
+*
+* @params[in] Pointer to DuMacUeCfg
+* @return ROK - success
+* RFAILED - failure
+*
+*******************************************************************/
+
+void deleteMacUeCfg(DuMacUeCfg *ueCfg)
+{
+ uint8_t lcCfgIdx=0;
+
+ if(ueCfg->spCellCfgPres)
+ {
+ freeUeRecfgCellGrpInfo(ueCfg);
+ }
+ if(ueCfg->ambrCfg)
+ {
+ DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,ueCfg->ambrCfg, sizeof(AmbrCfg));
+ }
+ for(lcCfgIdx=0; lcCfgIdx< ueCfg->numLcs; lcCfgIdx++)
+ {
+ freeMacLcCfg(&ueCfg->lcCfgList[lcCfgIdx].lcConfig);
+ }
+ memset(ueCfg, 0, sizeof(DuMacUeCfg));
+}
+
+/*******************************************************************
+*
+* @brief delete UE Configuration of a particular UE
+*
+* @details
+*
+* Function : deleteUeCfg
+*
+* Functionality: delete UE Configuration of a particular UE
+*
+* @params[in] uint16_t cellIdx, uint8_t ueId
+* @return ROK - success
+* RFAILED - failure
+*
+* ****************************************************************/
+uint8_t deleteUeCfg(uint16_t cellId, uint8_t ueId)
+{
+ uint8_t tnlIdx = 0;
+ uint16_t cellIdx = 0;
+ DuUeCb *ueCb = NULLP;
+
+ GET_CELL_IDX(cellId, cellIdx);
+ if(duCb.actvCellLst[cellIdx] != NULLP)
+ {
+ if((duCb.actvCellLst[cellIdx]->ueCb[ueId-1].duMacUeCfg.macUeCfgState == UE_DELETE_COMPLETE)\
+ &&(duCb.actvCellLst[cellIdx]->ueCb[ueId-1].duRlcUeCfg.rlcUeCfgState == UE_DELETE_COMPLETE))
+ {
+ ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueId-1];
+ deleteMacUeCfg(&ueCb->duMacUeCfg);
+ deleteRlcUeCfg(&ueCb->duRlcUeCfg);
+ if(ueCb->f1UeDb !=NULLP)
+ {
+ freeF1UeDb(ueCb->f1UeDb);
+ }
+ for(tnlIdx = 0; tnlIdx < duCb.numTeId; )
+ {
+ if(duCb.upTnlCfg[tnlIdx]->ueId == ueId)
+ {
+ duCb.upTnlCfg[tnlIdx]->configType = CONFIG_DEL;
+ duProcEgtpTunnelCfg(tnlIdx, duCb.upTnlCfg[tnlIdx], duCb.upTnlCfg[tnlIdx]);
+ }
+ else
+ tnlIdx++;
+ }
+ unsetBitInUeBitMap(cellId, ueId-1);
+ duCb.actvCellLst[cellIdx]->numActvUes--;
+ memset(ueCb, 0, sizeof(DuUeCb));
+ }
+ else
+ {
+ return RFAILED;
+ }
+ }
+ else
+ {
+ DU_LOG("\nERROR --> DU APP : deleteUeCfg(): CellIdx[%d] is not found", cellIdx);
+ return RFAILED;
+ }
+ return ROK;
+}
+
+
+/*******************************************************************
+*
+* @brief Handle UE delete response from MAC
+*
+* @details
+*
+* Function : DuProcMacUeDeleteRsp
+*
+* Functionality: Handle UE delete response from MAC
+*
+* @params[in] Pointer to MacUeDeleteRsp and Pst
+* @return ROK - success
+* RFAILED - failure
+*
+* ****************************************************************/
+
+uint8_t DuProcMacUeDeleteRsp(Pst *pst, MacUeDeleteRsp *deleteRsp)
+{
+ uint8_t ret =ROK,ueId=0;
+ uint16_t cellIdx=0;
+ uint32_t gnbCuUeF1apId =0 , gnbDuUeF1apId =0;
+
+ if(deleteRsp)
+ {
+ if(deleteRsp->status == SUCCESSFUL)
+ {
+ DU_LOG("\nINFO --> DU APP : MAC UE Delete Response : SUCCESS [UE IDX : %d]", deleteRsp->ueId);
+ GET_CELL_IDX(deleteRsp->cellId, cellIdx);
+ if(duCb.actvCellLst[cellIdx])
+ {
+ duCb.actvCellLst[cellIdx]->ueCb[deleteRsp->ueId -1].duMacUeCfg.macUeCfgState = UE_DELETE_COMPLETE;
+ ueId = deleteRsp->ueId;
+ gnbCuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueId-1].gnbCuUeF1apId;
+ gnbDuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueId-1].gnbDuUeF1apId;
+ if(deleteUeCfg(deleteRsp->cellId, ueId) == ROK)
+ {
+ ret = BuildAndSendUeContextReleaseComplete(deleteRsp->cellId, gnbCuUeF1apId, gnbDuUeF1apId);
+ if(ret != ROK)
+ {
+ DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): failed to send UE context release complete");
+ }
+ }
+
+ }
+ }
+ else
+ {
+ DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): MAC UE Delete Response : FAILURE [UE IDX : %d]",\
+ deleteRsp->ueId);
+ ret = RFAILED;
+ }
+ DU_FREE_SHRABL_BUF(pst->region, pst->pool, deleteRsp, sizeof(MacUeDeleteRsp));
+ }
+ else
+ {
+ DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): MAC UE Delete Response is null");
+ ret = RFAILED;
+ }
+ return ret;
+}
+
+/*******************************************************************
+ *
+ * @brief Processes UE Delete Rsp received from RLC
+ *
+ * @details
+ *
+ * Function : DuProcRlcUeDeleteRsp
+ *
+ * Functionality:
+ * Processes UE Delete Rsp received from RLC
+ *
+ * @params[in] Post structure
+ * Pointer to RlcUeDeleteRsp
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * *****************************************************************/
+
+uint8_t DuProcRlcUeDeleteRsp(Pst *pst, RlcUeDeleteRsp *delRsp)
+{
+ uint8_t ueId = 0, ret = ROK;
+ uint16_t cellIdx = 0,crnti=0;
+
+ if(delRsp)
+ {
+ ueId = delRsp->ueId;
+ GET_CELL_IDX(delRsp->cellId, cellIdx);
+
+ if(delRsp->status == SUCCESSFUL)
+ {
+ DU_LOG("\nINFO --> DU_APP: RLC UE Delete Response : SUCCESS [UE IDX:%d]", ueId);
+ if(duCb.actvCellLst[cellIdx]!=NULLP)
+ {
+ duCb.actvCellLst[cellIdx]->ueCb[ueId-1].duRlcUeCfg.rlcUeCfgState = UE_DELETE_COMPLETE;
+ GET_CRNTI(crnti, ueId);
+ if(sendUeDeleteReqToMac(delRsp->cellId, ueId, crnti) == RFAILED)
+ {
+ DU_LOG("\nERROR --> DU APP : duBuildAndSendUeDeleteReq(): Failed to build UE delete req for MAC ");
+ return RFAILED;
+ }
+
+ }
+ }
+ else
+ {
+ DU_LOG("\nERROR --> DU_APP: RLC UE Delete Response : FAILED [UE IDX:%d]", ueId);
+ ret = RFAILED;
+ }
+ DU_FREE_SHRABL_BUF(pst->region, pst->pool, delRsp, sizeof(RlcUeDeleteRsp));
+
+ }
+ return ret;
+}
+
+/*******************************************************************
+ *
+ * @brief Sending UE Delete Req To Mac
+*
+* @details
+*
+* Function : sendUeDeleteReqToMac
+*
+* Functionality:
+* sending UE Delete Req To Mac
+*
+* @params[in] cellId, ueId, crnti
+* @return ROK - success
+* RFAILED - failure
+*
+*****************************************************************/
+
+uint8_t sendUeDeleteReqToMac(uint16_t cellId, uint8_t ueId, uint16_t crnti)
+{
+ Pst pst;
+ uint8_t ret=ROK;
+ MacUeDelete *ueDelete = NULLP;
+
+ DU_ALLOC_SHRABL_BUF(ueDelete, sizeof(MacUeDelete));
+ if(ueDelete)
+ {
+ ueDelete->cellId = cellId;
+ ueDelete->ueId = ueId;
+ ueDelete->crnti = crnti;
+ FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_DELETE_REQ);
+
+ DU_LOG("\nDEBUG --> DU_APP: Sending UE delete Request to MAC ");
+ ret = (*packMacUeDeleteReqOpts[pst.selector])(&pst, ueDelete);
+ if(ret == RFAILED)
+ {
+ DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToMac(): Failed to send UE delete Req to MAC");
+ DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueDelete, sizeof(MacUeDelete));
+ }
+ }
+ else
+ {
+ DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToMac(): Failed to allocate memory");
+ ret = RFAILED;
+ }
+ return ret;
+}
+
+/*******************************************************************
+ *
+ * @brief Sending UE Delete Req To Rlc
+ *
+ * @details
+ *
+ * Function : sendUeDeleteReqToRlc
+ *
+ * Functionality:
+ * Sending UE Delete Req To Rlc
+ *
+ * @params[in] cellId, ueId
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ *****************************************************************/
+
+uint8_t sendUeDeleteReqToRlc(uint16_t cellId, uint8_t ueId)
+{
+ uint8_t ret;
+ Pst pst;
+ RlcUeDelete *ueDelete;
+
+ DU_ALLOC_SHRABL_BUF(ueDelete, sizeof(RlcUeDelete));
+ if(ueDelete !=NULLP)
+ {
+ ueDelete->cellId = cellId;
+ ueDelete->ueId = ueId;
+ FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_DELETE_REQ);
+
+ ret = (*packRlcUeDeleteReqOpts[pst.selector])(&pst, ueDelete);
+ if(ret == RFAILED)