+ DU_LOG("\nINFO : DU APP : RACH Resource Response from MAC : Result [SUCCESS]");
+
+ /* Fetch Cell Cb */
+ GET_CELL_IDX(rachRsrcRsp->cellId, cellIdx);
+ if(duCb.actvCellLst[cellIdx] && (duCb.actvCellLst[cellIdx]->cellId == rachRsrcRsp->cellId))
+ {
+ cellCb = duCb.actvCellLst[cellIdx];
+
+ /* Fetch UE CB */
+ if(cellCb->ueCb[rachRsrcRsp->ueId-1].gnbDuUeF1apId == rachRsrcRsp->ueId)
+ {
+ ueCb = &cellCb->ueCb[rachRsrcRsp->ueId-1];
+
+ /* Store CRNTI alloted to this UE by MAC */
+ ueCb->crnti = rachRsrcRsp->newCrnti;
+
+ /* Store the assigned CF-RA resources */
+ memcpy(&ueCb->cfraResource, &rachRsrcRsp->cfraResource, sizeof(MacCfraResource));
+
+ /* RACH resources allocated to UE is sent to CU in UE Context Setup Response
+ * along with the result of UE Context setup requested by CU */
+ if((ret = BuildAndSendUeCtxtRsp(rachRsrcRsp->cellId, rachRsrcRsp->ueId)) != ROK)
+ DU_LOG("\nERROR -> DU APP : Failure in BuildAndSendUeCtxtRsp()");
+ }
+ else
+ DU_LOG("\nERROR --> DU APP : UE ID [%d] not found in DuProcMacRachRsrcRsp", rachRsrcRsp->ueId);
+ }
+ else
+ DU_LOG("\nERROR --> DU APP : Cell ID [%d] not found in DuProcMacRachRsrcRsp", rachRsrcRsp->cellId);
+ }
+ else
+ DU_LOG("\nINFO : DU APP : RACH Resource Response from MAC : Result [FAILURE]");
+
+ DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rachRsrcRsp, sizeof(MacRachRsrcRsp));
+ return ret;
+}
+
+/*******************************************************************
+ *
+ * @brief fill k0 value in duCb
+ *
+ * @details
+ *
+ * Function : fillK0Values
+ * Functionality: update k0 value in duCb
+ *
+ * @params[in] PdschConfig *cuPdschCfg, PdschConfig *storePdschCfg
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t fillK0Values(PdschConfig *cuPdschCfg, PdschConfig *storePdschCfg)
+{
+ uint8_t numTimeDomRsrcAlloc, rsrcIdx;
+
+ if(cuPdschCfg)
+ {
+ if(storePdschCfg->numTimeDomRsrcAlloc)
+ {
+ numTimeDomRsrcAlloc = cuPdschCfg->numTimeDomRsrcAlloc;
+ for(rsrcIdx =0 ; rsrcIdx<numTimeDomRsrcAlloc; rsrcIdx++)
+ {
+ if(cuPdschCfg->timeDomRsrcAllociList[rsrcIdx].k0)
+ {
+ if(storePdschCfg->timeDomRsrcAllociList[rsrcIdx].k0)
+ {
+ *(storePdschCfg->timeDomRsrcAllociList[rsrcIdx].k0) = *(cuPdschCfg->timeDomRsrcAllociList[rsrcIdx].k0);
+ if(storePdschCfg->timeDomRsrcAllociList[rsrcIdx].k0 != cuPdschCfg->timeDomRsrcAllociList[rsrcIdx].k0)
+ DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cuPdschCfg->timeDomRsrcAllociList[rsrcIdx].k0, sizeof(uint8_t));
+ }
+ else
+ {
+ (storePdschCfg->timeDomRsrcAllociList[rsrcIdx].k0) = (cuPdschCfg->timeDomRsrcAllociList[rsrcIdx].k0);
+ }
+ }
+ }
+ }
+ }
+ return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief To update DuUeCb Mac Cfg
+ *
+ * @details
+ *
+ * Function : duUpdateMacCfg
+ * Functionality: update DuUeCb MAC Cfg
+ *
+ * @params[in] DuUeCb Pointer
+ * F1UeContextSetupDb pointer
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t duUpdateMacCfg(DuMacUeCfg *macUeCfg, F1UeContextSetupDb *f1UeDb)
+{
+ uint8_t ret, lcIdx, dbIdx, numLcs, lcDelIdx, cellIdx;
+ DuMacUeCfg *oldMacUeCfg;
+ ret = ROK;
+
+ GET_CELL_IDX(macUeCfg->cellId, cellIdx);
+ if(duCb.actvCellLst[cellIdx] == NULLP)
+ {
+ DU_LOG("\nERROR --> DU APP: CellId[%d] not found", macUeCfg->cellId);
+ return RFAILED;
+ }
+ oldMacUeCfg = &duCb.actvCellLst[cellIdx]->ueCb[macUeCfg->ueId-1].duMacUeCfg;
+
+ /*Filling Cell Group Cfg*/
+ ret = procUeRecfgCellInfo(macUeCfg, &f1UeDb->duUeCfg.copyOfmacUeCfg, f1UeDb->duUeCfg.cellGrpCfg);
+#ifdef NR_DRX
+ memcpy(&macUeCfg->macCellGrpCfg.drxCfg, &f1UeDb->duUeCfg.copyOfmacUeCfg.macCellGrpCfg.drxCfg, sizeof(DrxCfg));
+#endif
+ if(ret == ROK)
+ {
+ if(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschPresent)
+ {
+ /* update k0 values */
+ fillK0Values(&f1UeDb->duUeCfg.copyOfmacUeCfg.spCellCfg.servCellCfg.initDlBwp.pdschCfg, &macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg);
+ fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg.numTimeDomRsrcAlloc,\
+ &macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg, NULL);
+ }
+ if(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschPresent)
+ {
+ fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.numTimeDomRsrcAlloc,\
+ NULL, &macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg);
+ }
+ ret = fillAmbr(NULL, f1UeDb->duUeCfg.ambrCfg, &oldMacUeCfg->ambrCfg, true);
+ duFillModulationDetails(macUeCfg, oldMacUeCfg, f1UeDb->duUeCfg.ueNrCapability);
+ }
+
+ /* Filling LC Context */
+ for(dbIdx = 0; (dbIdx < f1UeDb->duUeCfg.numMacLcs && ret == ROK); dbIdx++)
+ {
+ numLcs = macUeCfg->numLcs;
+ for(lcIdx = 0; lcIdx < numLcs; lcIdx++)
+ {
+ if(f1UeDb->duUeCfg.macLcCfg[dbIdx].lcConfig.lcId == macUeCfg->lcCfgList[lcIdx].lcConfig.lcId)
+ {
+ if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_MOD)
+ {
+ ret = fillMacLcCfgToAddMod(NULL, &f1UeDb->duUeCfg.macLcCfg[dbIdx], &macUeCfg->lcCfgList[lcIdx], true);
+ }
+ else if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_DEL)
+ {
+ /* Free memory at matched lcIdx index */
+ freeMacLcCfg(&macUeCfg->lcCfgList[lcIdx].lcConfig);
+ macUeCfg->numLcs--;
+ for(lcDelIdx = lcIdx; lcDelIdx < macUeCfg->numLcs; lcDelIdx++)
+ {
+ /* moving all elements one index ahead */
+ ret = fillMacLcCfgToAddMod(NULL, &macUeCfg->lcCfgList[lcDelIdx+1], &macUeCfg->lcCfgList[lcDelIdx], true);
+ freeMacLcCfg(&macUeCfg->lcCfgList[lcDelIdx+1].lcConfig);
+ if(ret == RFAILED)
+ {
+ DU_LOG("\nERROR --> DU APP : Failed to delete LC at Idx %d in duUpdateMacCfg()", lcDelIdx);
+ break;
+ }
+ }
+ }
+ }
+ }
+ if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_ADD)
+ {
+ ret = fillMacLcCfgToAddMod(NULL, &f1UeDb->duUeCfg.macLcCfg[dbIdx], &macUeCfg->lcCfgList[numLcs], true);
+ if(ret == RFAILED)
+ {
+ DU_LOG("\nERROR --> DU APP : Failed to add LC at Idx %d in duUpdateMacCfg()", numLcs);
+ break;
+ }
+ macUeCfg->numLcs++;
+ }
+
+ }
+ return ret;
+}
+
+/******************************************************************
+ *
+ * @brief Function to fill the RLC Lc cfg from ueSetupReqDb
+ *
+ * @details
+ *
+ * Function : fillRlcCfgToAddMod
+ *
+ * Functionality: Function to fill the RLC Lc cfg from ueSetupReqDb
+ *
+ *
+ *****************************************************************/
+
+uint8_t fillRlcCfgToAddMod(DuRlcBearerCfg *lcCfg, DuRlcBearerCfg *f1UeDbLcCfg)
+{
+ lcCfg->configType = f1UeDbLcCfg->configType;
+ lcCfg->rlcBearerCfg.rbId = f1UeDbLcCfg->rlcBearerCfg.rbId;
+ lcCfg->rlcBearerCfg.rbType = f1UeDbLcCfg->rlcBearerCfg.rbType;
+ lcCfg->rlcBearerCfg.lcId = f1UeDbLcCfg->rlcBearerCfg.lcId;
+ lcCfg->rlcBearerCfg.lcType = f1UeDbLcCfg->rlcBearerCfg.lcType;
+ lcCfg->rlcBearerCfg.rlcMode = f1UeDbLcCfg->rlcBearerCfg.rlcMode;
+
+ switch(lcCfg->rlcBearerCfg.rlcMode)
+ {
+ case RLC_AM :
+ {
+ if(!lcCfg->rlcBearerCfg.u.amCfg)
+ {
+ DU_ALLOC_SHRABL_BUF(lcCfg->rlcBearerCfg.u.amCfg, sizeof(AmBearerCfg));
+ if(!lcCfg->rlcBearerCfg.u.amCfg)
+ return RFAILED;
+ }
+ /* DL AM */
+ lcCfg->rlcBearerCfg.u.amCfg->dlAmCfg.snLenDl = f1UeDbLcCfg->rlcBearerCfg.u.amCfg->dlAmCfg.snLenDl;
+ lcCfg->rlcBearerCfg.u.amCfg->dlAmCfg.pollRetxTmr = f1UeDbLcCfg->rlcBearerCfg.u.amCfg->dlAmCfg.pollRetxTmr;
+ lcCfg->rlcBearerCfg.u.amCfg->dlAmCfg.pollPdu = f1UeDbLcCfg->rlcBearerCfg.u.amCfg->dlAmCfg.pollPdu;
+ lcCfg->rlcBearerCfg.u.amCfg->dlAmCfg.pollByte = f1UeDbLcCfg->rlcBearerCfg.u.amCfg->dlAmCfg.pollByte;
+ lcCfg->rlcBearerCfg.u.amCfg->dlAmCfg.maxRetxTh = f1UeDbLcCfg->rlcBearerCfg.u.amCfg->dlAmCfg.maxRetxTh;
+
+ /* UL AM */
+ lcCfg->rlcBearerCfg.u.amCfg->ulAmCfg.snLenUl = f1UeDbLcCfg->rlcBearerCfg.u.amCfg->ulAmCfg.snLenUl;
+ lcCfg->rlcBearerCfg.u.amCfg->ulAmCfg.reAssemTmr = f1UeDbLcCfg->rlcBearerCfg.u.amCfg->ulAmCfg.reAssemTmr;
+ lcCfg->rlcBearerCfg.u.amCfg->ulAmCfg.statProhTmr = f1UeDbLcCfg->rlcBearerCfg.u.amCfg->ulAmCfg.statProhTmr;
+ break;
+ }
+ case RLC_UM_BI_DIRECTIONAL :
+ {
+ if(!lcCfg->rlcBearerCfg.u.umBiDirCfg)
+ {
+ DU_ALLOC_SHRABL_BUF(lcCfg->rlcBearerCfg.u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
+ if(!lcCfg->rlcBearerCfg.u.umBiDirCfg)
+ return RFAILED;
+ }
+ /* UL UM BI DIR INFO */
+ lcCfg->rlcBearerCfg.u.umBiDirCfg->ulUmCfg.snLenUlUm = f1UeDbLcCfg->rlcBearerCfg.u.umBiDirCfg->ulUmCfg.snLenUlUm;
+ lcCfg->rlcBearerCfg.u.umBiDirCfg->ulUmCfg.reAssemTmr = f1UeDbLcCfg->rlcBearerCfg.u.umBiDirCfg->ulUmCfg.reAssemTmr;
+ /* DL UM BI DIR INFO */
+ lcCfg->rlcBearerCfg.u.umBiDirCfg->dlUmCfg.snLenDlUm = f1UeDbLcCfg->rlcBearerCfg.u.umBiDirCfg->dlUmCfg.snLenDlUm;
+ break;
+ }
+ case RLC_UM_UNI_DIRECTIONAL_UL :
+ {
+ if(!lcCfg->rlcBearerCfg.u.umUniDirUlCfg)
+ {
+ DU_ALLOC_SHRABL_BUF(lcCfg->rlcBearerCfg.u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
+ if(!lcCfg->rlcBearerCfg.u.umUniDirUlCfg)
+ return RFAILED;
+ }
+ lcCfg->rlcBearerCfg.u.umUniDirUlCfg->ulUmCfg.snLenUlUm = f1UeDbLcCfg->rlcBearerCfg.u.umUniDirUlCfg->ulUmCfg.snLenUlUm;
+ lcCfg->rlcBearerCfg.u.umUniDirUlCfg->ulUmCfg.reAssemTmr = f1UeDbLcCfg->rlcBearerCfg.u.umUniDirUlCfg->ulUmCfg.reAssemTmr;
+ break;
+
+ }
+ case RLC_UM_UNI_DIRECTIONAL_DL :
+ {
+ if(!lcCfg->rlcBearerCfg.u.umUniDirDlCfg)
+ {
+ DU_ALLOC_SHRABL_BUF(lcCfg->rlcBearerCfg.u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
+ if(!lcCfg->rlcBearerCfg.u.umUniDirDlCfg)
+ return RFAILED;
+ }
+ lcCfg->rlcBearerCfg.u.umUniDirDlCfg->dlUmCfg.snLenDlUm = f1UeDbLcCfg->rlcBearerCfg.u.umUniDirDlCfg->dlUmCfg.snLenDlUm;
+ break;
+ }
+ default:
+ DU_LOG("\nERROR --> DU_APP: Invalid Rlc Mode %d at fillRlcCfgToAddMod()", lcCfg->rlcBearerCfg.rlcMode);
+ return RFAILED;
+ }
+ return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief To update DuUeCb Rlc Lc Cfg
+ *
+ * @details
+ *
+ * Function : duUpdateRlcLcCfg
+ * Functionality: update DuUeCb Rlc Lc Cfg
+ *
+ * @params[in] DuUeCb Pointer
+ * F1UeContextSetupDb pointer
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t duUpdateRlcLcCfg(DuRlcUeCfg *rlcUeCfg, F1UeContextSetupDb *f1UeDb)
+{
+ uint8_t ret, lcIdx, dbIdx, numLcs, lcDelIdx;
+
+ ret = ROK;
+ for(dbIdx = 0; (dbIdx < f1UeDb->duUeCfg.numRlcLcs && ret ==ROK); dbIdx++)
+ {
+ numLcs = rlcUeCfg->numLcs;
+ for(lcIdx = 0; lcIdx < numLcs; lcIdx++)
+ {
+ if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].rlcBearerCfg.lcId == rlcUeCfg->rlcLcCfg[lcIdx].rlcBearerCfg.lcId)
+ {
+ if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_MOD)
+ {
+ ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcIdx], &f1UeDb->duUeCfg.rlcLcCfg[dbIdx]);
+ if(ret == RFAILED)
+ {
+ DU_LOG("\nERROR --> DU APP : Failed to modify LC at Idx %d in duUpdateRlcCfg()", lcDelIdx);
+ break;
+ }
+ fillSnssaiInfo(NULL, f1UeDb->duUeCfg.rlcLcCfg[dbIdx].rlcBearerCfg.snssai,\
+ &rlcUeCfg->rlcLcCfg[lcIdx].rlcBearerCfg.snssai, true);
+ }
+ else if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_DEL)
+ {
+ /* Free memory at matched lcIdx index */
+ freeRlcLcCfg(&rlcUeCfg->rlcLcCfg[lcIdx].rlcBearerCfg);
+ rlcUeCfg->numLcs--;
+ for(lcDelIdx = lcIdx; lcDelIdx < rlcUeCfg->numLcs; lcDelIdx++)
+ {
+ ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcDelIdx], &rlcUeCfg->rlcLcCfg[lcDelIdx+1]);
+ fillSnssaiInfo(NULL, rlcUeCfg->rlcLcCfg[lcDelIdx+1].rlcBearerCfg.snssai,\
+ &rlcUeCfg->rlcLcCfg[lcDelIdx].rlcBearerCfg.snssai, true);
+ freeRlcLcCfg(&rlcUeCfg->rlcLcCfg[lcDelIdx+1].rlcBearerCfg);
+ if(ret == RFAILED)
+ {
+ DU_LOG("\nERROR --> DU APP : Failed to delete LC at Idx %d in duUpdateRlcCfg()", lcDelIdx);
+ break;
+ }
+ }
+ }
+ }
+ }
+ if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_ADD)
+ {
+ ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcIdx], &f1UeDb->duUeCfg.rlcLcCfg[dbIdx]);
+ if(ret == ROK)
+ {
+ fillSnssaiInfo(NULL, f1UeDb->duUeCfg.rlcLcCfg[dbIdx].rlcBearerCfg.snssai,\
+ &rlcUeCfg->rlcLcCfg[rlcUeCfg->numLcs].rlcBearerCfg.snssai, true);
+ rlcUeCfg->numLcs++;
+ }
+ }
+ }
+ return ret;
+}
+
+/*******************************************************************
+ *
+ * @brief Function to fill Tunnel Config to Add/Mod
+ *
+ *
+ * @details
+ *
+ * Function : fillTnlCfgToAddMod
+ *
+ * Functionality: Function to fill tunnel Config to Add/Mod
+ *
+ * @params[in] Pointer to tnlCfgDb,
+ * pointer to f1TnlCfg
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t fillTnlCfgToAddMod(UpTnlCfg **ueCbTnlCfg, UpTnlCfg *f1TnlCfg)
+{
+ if(*ueCbTnlCfg)
+ {
+ DU_FREE((*ueCbTnlCfg)->tnlCfg1, sizeof(GtpTnlCfg));
+ DU_FREE(*ueCbTnlCfg, sizeof(UpTnlCfg));
+ }
+
+ if(*ueCbTnlCfg == NULLP)
+ {
+ /* copying to DuCb Tnl Cfg */
+ DU_ALLOC(*ueCbTnlCfg, sizeof(UpTnlCfg));
+ if(*ueCbTnlCfg == NULLP)
+ {
+ DU_LOG("\nERROR --> DU_APP : fillTnlCfgToAddMod: Memory Alloc failed for drbId[%d]", f1TnlCfg->drbId);
+ return RFAILED;
+ }
+ }
+ memset(*ueCbTnlCfg, 0, sizeof(UpTnlCfg));
+ (*ueCbTnlCfg)->configType = f1TnlCfg->configType;
+ (*ueCbTnlCfg)->cellId = f1TnlCfg->cellId;
+ (*ueCbTnlCfg)->ueId = f1TnlCfg->ueId;
+ (*ueCbTnlCfg)->drbId = f1TnlCfg->drbId;
+ if(f1TnlCfg->tnlCfg1)
+ {
+ if((*ueCbTnlCfg)->tnlCfg1 == NULLP)
+ {
+ DU_ALLOC((*ueCbTnlCfg)->tnlCfg1, sizeof(GtpTnlCfg));
+ if((*ueCbTnlCfg)->tnlCfg1 == NULLP)
+ {
+ DU_LOG("\nERROR --> DU_APP : fillTnlCfgToAddMod: Memory Alloc failed for tnlCfg1 for drbId[%d]", f1TnlCfg->drbId);
+ return RFAILED;
+ }
+ }
+ memset((*ueCbTnlCfg)->tnlCfg1, 0, sizeof(GtpTnlCfg));
+ (*ueCbTnlCfg)->tnlCfg1->teId = f1TnlCfg->tnlCfg1->teId;
+ (*ueCbTnlCfg)->tnlCfg1->ulTnlAddress = f1TnlCfg->tnlCfg1->ulTnlAddress;
+ (*ueCbTnlCfg)->tnlCfg1->dlTnlAddress = f1TnlCfg->tnlCfg1->dlTnlAddress;
+ }
+ return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief Processing the tunnel Request to EGTP
+ *
+ * @details
+ *
+ * Function : duProcEgtpTunnelCfg
+ *
+ * Functionality: Processing the tunnel Request to EGTP
+ *
+ * @params[in] UptnlCfg *duTnlCfg, UpTnlCfg *f1TnlCfg
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t duProcEgtpTunnelCfg(uint8_t ueCbIdx, UpTnlCfg *duTnlCfg, UpTnlCfg *f1TnlCfg)
+{
+ uint8_t ret = RFAILED, delIdx;
+
+ if(f1TnlCfg->tnlCfg1 == NULLP)
+ {
+ DU_LOG("\nERROR --> DU_APP : Tunnel config not found");
+ return ret;
+ }
+
+ if(f1TnlCfg->configType == CONFIG_ADD)
+ {
+ if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_ADD, NULLP, f1TnlCfg->tnlCfg1) == ROK)
+ {
+ if(fillTnlCfgToAddMod(&duCb.upTnlCfg[duCb.numTeId], f1TnlCfg) == ROK)
+ {
+ duCb.numTeId++;
+ ret = ROK;
+ }
+ }
+ }
+ else if(f1TnlCfg->configType == CONFIG_MOD)
+ {
+ if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_MOD, duTnlCfg->tnlCfg1->teId, f1TnlCfg->tnlCfg1) == ROK)
+ {
+ if(fillTnlCfgToAddMod(&duTnlCfg, f1TnlCfg) == ROK)
+ {
+ ret = ROK;
+ }
+ }
+ }
+ else if(f1TnlCfg->configType == CONFIG_DEL)
+ {
+ if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_DEL, duTnlCfg->tnlCfg1->teId, f1TnlCfg->tnlCfg1) == ROK)
+ {
+ /* Free memory at drbIdx */
+ duCb.numTeId--;
+ for(delIdx = ueCbIdx; delIdx < duCb.numTeId; delIdx++)
+ {
+ /* moving all elements one index ahead */
+ ret = fillTnlCfgToAddMod(&duCb.upTnlCfg[delIdx], duCb.upTnlCfg[delIdx+1]);
+ if(ret != ROK)
+ {
+ return ret;
+ }
+ }
+ if(duCb.upTnlCfg[delIdx])
+ {
+ DU_FREE(duCb.upTnlCfg[delIdx]->tnlCfg1, sizeof(GtpTnlCfg));
+ DU_FREE(duCb.upTnlCfg[delIdx], sizeof(UpTnlCfg));
+ }
+ }
+ }
+ return ret;
+}
+
+/***********************************************************************
+ *
+ * @brief Function to fill Tunnel Config
+ * and sends tunnel Req to EGTP
+ *
+ *
+ * @details
+ *
+ * Function : duUpdateTunnelCfgDb
+ *
+ * Functionality: Function to fill tunnel Config
+ * and sends tunnel Cfg Req to EGTP
+ *
+ * @params[in] ueId, cellId, DuUeCfg
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t duUpdateTunnelCfgDb(uint8_t ueId, uint8_t cellId, DuUeCfg *duUeCfg)
+{
+ uint8_t ret = ROK, drbIdx, teIdx;
+ bool drbFound = false;
+
+ /*If Add/Mod tunnels request for that DRB is successful in EGTP */
+ /*then update drbId and tunnel Info in duCb */
+ for(drbIdx=0; drbIdx < duUeCfg->numDrb; drbIdx++)
+ {
+ duUeCfg->upTnlInfo[drbIdx].cellId = cellId;
+ duUeCfg->upTnlInfo[drbIdx].ueId = ueId;
+ for(teIdx = 0; teIdx < duCb.numTeId; teIdx++)
+ {
+ if((duCb.upTnlCfg[teIdx]->ueId == duUeCfg->upTnlInfo[drbIdx].ueId) && \
+ (duCb.upTnlCfg[teIdx]->drbId == duUeCfg->upTnlInfo[drbIdx].drbId))
+ {
+ drbFound = true; /* existing DRB */
+ if(duProcEgtpTunnelCfg(teIdx, duCb.upTnlCfg[teIdx], &duUeCfg->upTnlInfo[drbIdx]) != ROK)
+ {
+ DU_LOG("\nERROR -> DU_APP : duUpdateTunnelCfgDb: Failed to modify tunnel req for Drb id[%d]",
+ duUeCfg->upTnlInfo[drbIdx].drbId);
+ ret = RFAILED;
+ }
+ break;
+ }
+ else
+ drbFound = false;
+ }
+
+ 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, 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 config response from MAC
+ *
+ * @details
+ *
+ * Function : DuProcMacUeCfgRsp
+ *
+ * Functionality: Handle UE Config response from MAC
+ *
+ * @params[in] Pointer to MacUeCfgRsp and Pst
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t DuProcMacUeCfgRsp(Pst *pst, MacUeCfgRsp *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(MacUeCfgRsp));
+ 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(MacUeCfgRsp));
+ 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(MacUeCfgRsp));
+ }
+ else
+ {
+ DU_LOG("\nERROR --> DU APP : Received MAC Ue Config Response is NULL at DuProcMacUeCfgRsp()");
+ 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 RlcUeCfg
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ *****************************************************************/
+
+uint8_t duBuildAndSendUeCreateReqToRlc(uint16_t cellId, uint8_t gnbDuUeF1apId, DuUeCfg *ueCfgDb, DuRlcUeCfg *duRlcUeCfg)
+{
+ uint8_t ret = ROK;
+ RlcUeCfg *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(RlcUeCfg));
+ if(rlcUeCfg)
+ {
+ memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
+ 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(RlcUeCfg));
+ 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 : DuProcRlcUeCfgRsp
+ *
+ * Functionality:
+ * Processes UE create Rsp received from RLC UL
+ *
+ * @params[in] Post structure
+ * Pointer to RlcCfgCfm
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ *****************************************************************/
+uint8_t DuProcRlcUeCfgRsp(Pst *pst, RlcUeCfgRsp *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(MacUeCfgRsp));
+ DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(RlcUeCfgRsp));
+ 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(RlcUeCfgRsp));
+ return RFAILED;
+ }
+ }
+ }
+ else 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(RlcUeCfgRsp));
+ 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(RlcUeCfgRsp));
+ return RFAILED;
+ }
+ }
+ }
+ }
+ else
+ {
+ DU_LOG("\nERROR --> DU_APP: RLC UE 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(RlcUeCfgRsp));
+ }
+ else
+ {
+ DU_LOG("\nERROR --> DU_APP: Received RLC Ue Config Response is NULL at DuProcRlcUeCfgRsp()");
+ 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] cellId, crnti
+ * DuUeCfg *ueCfgDb
+ * RlcUeCfg *rlcUeCfg
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t duBuildAndSendUeRecfgReqToRlc(uint8_t cellId, uint8_t gnbDuUeF1apId, uint8_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] CellGroupConfigRrc_t *macCellGrpCfg
+ * DuUeCfg *ueCfgDb
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t duBuildAndSendUeRecfgReqToMac(uint8_t cellId, uint8_t duUeF1apId, uint8_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