+ uint8_t ret, dbIdx, lcIdx, cellIdx;
+ bool lcIdFound = false;
+ MacUeCfg *duMacDb = NULLP;
+
+ ret =ROK;
+
+ if(!ueCfgDb)
+ {
+ macUeCfg->cellId = cellId;
+ macUeCfg->ueIdx = ueIdx;
+ macUeCfg->crnti = crnti;
+ fillDefaultMacCellGrpInfo(&macUeCfg->macCellGrpCfg);
+ fillDefaultPhyCellGrpInfo(&macUeCfg->phyCellGrpCfg);
+ fillDefaultSpCellGrpInfo(&macUeCfg->spCellCfg);
+ macUeCfg->ambrCfg = NULLP;
+ fillMacSrb1LcCfg(&macUeCfg->lcCfgList[0]);
+ fillDefaultModulation(macUeCfg);
+ macUeCfg->numLcs++;
+ }
+ else
+ {
+ /* Fetching MacDb from DuUeCb */
+ GET_CELL_IDX(cellId, cellIdx);
+ duMacDb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg;
+ /* Fetching MaUeCfg List for ADD/MOD/DEL */
+ macUeCfg->cellId = cellId;
+ macUeCfg->ueIdx = ueIdx;
+ macUeCfg->crnti = crnti;
+ ret = procUeReCfgCellInfo(macUeCfg, ueCfgDb->cellGrpCfg);
+ if(ret == ROK)
+ {
+ if(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschPresent)
+ {
+ 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(&macUeCfg->ambrCfg, ueCfgDb->ambrCfg);
+
+ duFillModulationDetails(macUeCfg, duMacDb, ueCfgDb->ueNrCapability);
+ }
+
+ /* Filling LC Context */
+ for(dbIdx = 0; (dbIdx < ueCfgDb->numMacLcs && ret == ROK); dbIdx++)
+ {
+ if(!ueCfgDb->macLcCfg[dbIdx].ulLcCfgPres)
+ {
+ /* Filling default UL LC config in MAC if not present */
+ ueCfgDb->macLcCfg[dbIdx].ulLcCfgPres = true;
+ fillDefaultUlLcCfg(&ueCfgDb->macLcCfg[dbIdx].ulLcCfg);
+ }
+ for(lcIdx = 0; lcIdx < duMacDb->numLcs; lcIdx++)
+ {
+ if(ueCfgDb->macLcCfg[dbIdx].lcId == duMacDb->lcCfgList[lcIdx].lcId)
+ {
+ lcIdFound = true;
+ if((ueCfgDb->macLcCfg[dbIdx].configType == CONFIG_UNKNOWN) ||
+ (ueCfgDb->macLcCfg[dbIdx].configType == CONFIG_MOD))
+ {
+ ueCfgDb->macLcCfg[dbIdx].configType = CONFIG_MOD;
+ ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[dbIdx], &ueCfgDb->macLcCfg[dbIdx]);
+ }
+ }
+ else
+ lcIdFound = false;
+ }
+ if(!lcIdFound)
+ {
+ /* ADD/DEL CONFIG */
+ ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[dbIdx], &ueCfgDb->macLcCfg[dbIdx]);
+ }
+ if(ret == ROK)
+ {
+ macUeCfg->numLcs++;
+ }
+ else
+ {
+ DU_LOG("\nERROR --> DU APP : Failed to add Lc at Idx %d in fillMacUeCfg()", dbIdx);
+ break;
+ }
+ }/*End of Outer FOR loop */
+ }
+ return ret;
+}
+
+/******************************************************************
+ *
+ * @brief Fills Rlc AM Information
+ *
+ * @details
+ *
+ * Function : fillDefaultAmInfo
+ *
+ * Functionality: Fills Rlc AM Information
+ *
+ * @params[in] AmBearerCfg *amCfg
+ * @return void
+ *
+ *****************************************************************/
+void fillDefaultAmInfo(AmBearerCfg *amCfg)
+{
+ /* DL AM */
+ amCfg->dlAmCfg.snLenDl = AM_SIZE_12;
+ amCfg->dlAmCfg.pollRetxTmr = POLL_RETX_TMR_45MS;
+ amCfg->dlAmCfg.pollPdu = POLL_PDU_TMR_INFINITY;
+ amCfg->dlAmCfg.pollByte = POLL_BYTES_INFINITY;
+ amCfg->dlAmCfg.maxRetxTh = RETX_TH_8;
+
+ /* UL AM */
+ amCfg->ulAmCfg.snLenUl = AM_SIZE_12;
+ amCfg->ulAmCfg.reAssemTmr = RE_ASM_40MS;
+ amCfg->ulAmCfg.statProhTmr = PROH_35MS;
+}
+
+/******************************************************************
+ *
+ * @brief Fills RLC UM Bi Directional Information
+ *
+ * @details
+ *
+ * Function : fillDefaultUmBiInfo
+ *
+ * Functionality: Fills RLC UM Bi Directional Information
+ *
+ * @params[in] UmBiDirBearerCfg *umBiDirCfg
+ * @return void
+ *
+ *****************************************************************/
+void fillDefaultUmBiInfo(UmBiDirBearerCfg *umBiDirCfg)
+{
+ /* UL UM BI DIR INFO */
+ umBiDirCfg->ulUmCfg.snLenUlUm = UM_SIZE_12;
+ umBiDirCfg->ulUmCfg.reAssemTmr = RE_ASM_40MS;
+
+ /* DL UM BI DIR INFO */
+ umBiDirCfg->dlUmCfg.snLenDlUm = UM_SIZE_12;
+}
+
+/******************************************************************
+ *
+ * @brief Fills RLC UM Uni Directional UL Information
+ *
+ * @details
+ *
+ * Function : fillDefaultUmUlInfo
+ *
+ * Functionality: Fills RLC UM Uni Directional Info
+ *
+ * @params[in] UmUniDirUlBearerCfg *UmUlCfg
+ * @return void
+ *
+ *****************************************************************/
+void fillDefaultUmUlInfo(UmUniDirUlBearerCfg *UmUlCfg)
+{
+ UmUlCfg->ulUmCfg.snLenUlUm = UM_SIZE_12;
+ UmUlCfg->ulUmCfg.reAssemTmr = RE_ASM_40MS;
+}
+
+/******************************************************************
+ *
+ * @brief Fills RLC UM Uni Directional DL Information
+ *
+ * @details
+ *
+ * Function : fillDefaultUmDlInfo
+ *
+ * Functionality: Fills RLC UM Uni Directional DL Info
+ *
+ * @params[in] UmUniDirDlBearerCfg *UmDlCfg
+ * @return void
+ *
+ *****************************************************************/
+void fillDefaultUmDlInfo(UmUniDirDlBearerCfg *UmDlCfg)
+{
+ UmDlCfg->dlUmCfg.snLenDlUm = UM_SIZE_12;
+}
+
+/******************************************************************
+ *
+ * @brief Builds Rlc Mode Default Configuration
+ *
+ * @details
+ *
+ * Function : fillDefaultRlcModeCfg
+ *
+ * Functionality: Builds Rlc Mode Default Configuration
+ *
+ * @params[in] rlcMode, RlcBearerCfg *lcCfg
+ * @return ROK/RFAILED
+ *
+ *****************************************************************/
+
+uint8_t fillDefaultRlcModeCfg(uint8_t rlcMode, RlcBearerCfg *lcCfg)
+{
+
+ if(lcCfg)
+ {
+ switch(rlcMode)
+ {
+ case RLC_AM :
+ {
+ if(!lcCfg->u.amCfg)
+ {
+ DU_ALLOC_SHRABL_BUF(lcCfg->u.amCfg, sizeof(AmBearerCfg));
+ if(lcCfg->u.amCfg)
+ fillDefaultAmInfo(lcCfg->u.amCfg);
+ else
+ {
+ DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at AmCfg at fillDefaultRlcModeCfg()");
+ return RFAILED;
+ }
+ }
+ break;
+ }
+ case RLC_UM_BI_DIRECTIONAL :
+ {
+ if(!lcCfg->u.umBiDirCfg)
+ {
+ DU_ALLOC_SHRABL_BUF(lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
+ if(lcCfg->u.umBiDirCfg)
+ fillDefaultUmBiInfo(lcCfg->u.umBiDirCfg);
+ else
+ {
+ DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmBiDirCfg at fillDefaultRlcModeCfg()");
+ return RFAILED;
+ }
+ }
+ break;
+ }
+ case RLC_UM_UNI_DIRECTIONAL_UL :
+ {
+ if(!lcCfg->u.umUniDirUlCfg)
+ {
+ DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
+ if(lcCfg->u.umUniDirUlCfg)
+ fillDefaultUmUlInfo(lcCfg->u.umUniDirUlCfg);
+ else
+ {
+ DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmUniDirUlCfg at fillDefaultRlcModeCfg()");
+ return RFAILED;
+ }
+ }
+ break;
+ }
+ case RLC_UM_UNI_DIRECTIONAL_DL :
+ {
+ if(!lcCfg->u.umUniDirDlCfg)
+ {
+ DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
+ if(lcCfg->u.umUniDirDlCfg)
+ fillDefaultUmDlInfo(lcCfg->u.umUniDirDlCfg);
+ else
+ {
+ DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmUniDirDlCfg at fillDefaultRlcModeCfg()");
+ return RFAILED;
+ }
+ }
+ break;
+ }
+ default:
+ DU_LOG("\nERROR --> DUAPP: Invalid rlcMode %d at extractRlcCfgToAddMod()", rlcMode);
+ return RFAILED;
+ }
+
+ }
+ else
+ {
+ DU_LOG("\nERROR --> DUAPP: Received LC Config is NULL");
+ return RFAILED;
+ }
+ return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief Function to fill Rlc Lc Cfg for SRB1
+ *
+ * @details
+ *
+ * Function : fillRlcSrb1LcCfg
+ *
+ * Functionality:
+ * Function to fill Rlc Lc Cfg for SRB1
+ *
+ * @params[in] Pointer to RlcBearerCfg
+ * @return ROK/RFAILED
+ *
+ *****************************************************************/
+
+uint8_t fillRlcSrb1LcCfg(RlcBearerCfg *rlcLcCfg)
+{
+ uint8_t ret = ROK;
+
+ rlcLcCfg->rbId = SRB1_LCID;
+ rlcLcCfg->rbType = RB_TYPE_SRB;
+ rlcLcCfg->lcId = SRB1_LCID;
+ rlcLcCfg->lcType = LCH_DCCH;
+ rlcLcCfg->rlcMode = RLC_AM;
+ rlcLcCfg->configType = CONFIG_ADD;
+ ret = fillDefaultRlcModeCfg(rlcLcCfg->rlcMode, rlcLcCfg);
+ return ret;
+}
+
+/*******************************************************************
+ *
+ * @brief Processes UE ReConfig Req to RLC UL
+ *
+ * @details
+ *
+ * Function : sendUeReCfgReqToRlc
+ *
+ * Functionality:
+ * Processes UE Reconfig Req to RLC UL
+ *
+ * @params[in] Pointer to RlcUeCfg
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ *****************************************************************/
+
+uint8_t sendUeReCfgReqToRlc(RlcUeCfg *rlcUeCfg)
+{
+ uint8_t ret;
+ Pst pst;
+
+ FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_RECONFIG_REQ);
+ if(rlcUeCfg)
+ {
+ /* Processing one Ue at a time to RLC */
+ DU_LOG("\nDEBUG --> DU_APP: Sending Ue Reconfig Request to RLC UL");
+ ret = (*packRlcUeReconfigReqOpts[pst.selector])(&pst, rlcUeCfg);
+ if(ret == RFAILED)
+ {
+ DU_LOG("\nERROR --> DU_APP : Failed to send Ue Reconfig Req to RLC at sendUeReCfgReqToRlc()");
+ DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rlcUeCfg, sizeof(RlcUeCfg));
+ }
+ }
+ else
+ {
+ DU_LOG("\nERROR --> DU_APP: Received RlcUeCfg is NULL at sendUeReCfgReqToRlc()");
+ ret = RFAILED;
+ }
+ return ret;
+}
+
+/******************************************************************
+ *
+ * @brief Fills RlcBearerCfg structure
+ *
+ * @details
+ *
+ * Function : fillRlcUeCfg
+ *
+ * Functionality: Fills Rlc Bearer Cfg
+ *
+ *
+ *****************************************************************/
+uint8_t fillRlcUeCfg(uint16_t cellId, uint8_t ueIdx,\
+ DuUeCfg *ueCfgDb, RlcUeCfg *rlcUeCfg)
+{
+ uint8_t ret, dbIdx, lcIdx, cellIdx;
+ bool lcIdFound = false;
+ RlcUeCfg *duRlcDb = NULLP;
+
+ ret = ROK;
+ if(!ueCfgDb)
+ {
+ /* Initial RB being Added */
+ rlcUeCfg->cellId = cellId;
+ rlcUeCfg->ueIdx = ueIdx;
+ ret = fillRlcSrb1LcCfg(&rlcUeCfg->rlcLcCfg[0]);
+ if(ret == ROK)
+ rlcUeCfg->numLcs++;
+ else
+ memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
+ }
+ else
+ {
+ /* Fetch RlcDb from DuUeCb */
+ GET_CELL_IDX(cellId, cellIdx);
+ duRlcDb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg;
+ /*Filling RlcUeCfg */
+ rlcUeCfg->cellId = cellId;
+ rlcUeCfg->ueIdx = ueIdx;
+ for(dbIdx = 0; (dbIdx < ueCfgDb->numRlcLcs && ret == ROK); dbIdx++)
+ {
+ ret = fillDefaultRlcModeCfg(ueCfgDb->rlcLcCfg[dbIdx].rlcMode, &ueCfgDb->rlcLcCfg[dbIdx]);
+ if(ret == RFAILED)
+ {
+ DU_LOG("\n ERROR --> DU APP : Failed to fill Rlc Mode at fillRlcUeCfg()");
+ memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
+ return ret;
+ }
+ /* Fill Rlc Ue Cfg List for ADD/MOD/DEL */
+ for(lcIdx = 0; lcIdx < duRlcDb->numLcs; lcIdx++)
+ {
+ if(ueCfgDb->rlcLcCfg[dbIdx].lcId == duRlcDb->rlcLcCfg[lcIdx].lcId)
+ {
+ lcIdFound = true;
+ if((ueCfgDb->rlcLcCfg[dbIdx].configType == CONFIG_UNKNOWN)||
+ (ueCfgDb->rlcLcCfg[dbIdx].configType == CONFIG_MOD))
+ {
+ /* MOD */
+ ueCfgDb->rlcLcCfg[dbIdx].configType = CONFIG_MOD; /* update Db for MOD type */
+ memcpy(&rlcUeCfg->rlcLcCfg[dbIdx], &ueCfgDb->rlcLcCfg[dbIdx], sizeof(RlcBearerCfg));
+ }
+ }
+ else
+ lcIdFound = false;
+ }
+ if(!lcIdFound)
+ {
+ /* ADD/ DEL Config Type */
+ memcpy(&rlcUeCfg->rlcLcCfg[dbIdx], &ueCfgDb->rlcLcCfg[dbIdx], sizeof(RlcBearerCfg));
+ }
+ rlcUeCfg->numLcs++;
+ }
+ }
+ return ret;
+}
+
+/******************************************************************
+ *
+ * @brief creates UE context
+ *
+ * @details
+ *
+ * Function : duCreateUeCb
+ *
+ * Functionality: Creates UE Conetxt
+ *
+ * @params[in] UeCcchCtxt Pointer
+ * UeIdx Pointer
+ *
+ * @return ROK - success
+ * RFAILED - failure
+ * ****************************************************************/
+uint8_t duCreateUeCb(UeCcchCtxt *ueCcchCtxt, uint32_t gnbCuUeF1apId)
+{
+ uint8_t cellIdx = 0;
+ uint8_t ret = ROK;
+ uint8_t ueIdx;