+ if(fillInitialDlBwp(macSpCellRecfg.servCellCfg.initDlBwp, \
+ &servCellRecfg->initDlBwp) != ROK )
+ {
+ DU_LOG("\nERROR --> MAC : fillInitialDlBwp() failed");
+ return RFAILED;
+ }
+
+ servCellRecfg->numDlBwpToAddOrMod = macSpCellRecfg.servCellCfg.numDlBwpToAddOrMod;
+ if(servCellRecfg->numDlBwpToAddOrMod > MAX_NUM_BWP)
+ {
+ DU_LOG("\nERROR --> MAC : Number of DL BWP to ADD/MOD [%d] exceeds max limit [%d]",\
+ servCellRecfg->numDlBwpToAddOrMod, MAX_NUM_BWP);
+ return RFAILED;
+ }
+ for(idx = 0; idx < servCellRecfg->numDlBwpToAddOrMod; idx++)
+ {
+ memcpy(&servCellRecfg->dlBwpToAddOrModList[idx], &macSpCellRecfg.servCellCfg.dlBwpToAddOrModList[idx], sizeof(DlBwpInfo));
+ }
+ servCellRecfg->numDlBwpToRel = macSpCellRecfg.servCellCfg.numDlBwpToRel;
+ if(servCellRecfg->numDlBwpToRel > MAX_NUM_BWP)
+ {
+ DU_LOG("\nERROR --> MAC : Number of DL BWP to RELEASE [%d] exceeds max limit [%d]",\
+ servCellRecfg->numDlBwpToRel, MAX_NUM_BWP);
+ return RFAILED;
+ }
+ for(idx = 0; idx < servCellRecfg->numDlBwpToRel; idx++)
+ {
+ memcpy(&servCellRecfg->dlBwpToRelList[idx], &macSpCellRecfg.servCellCfg.dlBwpToRelList[idx], sizeof(DlBwpInfo));
+ }
+ servCellRecfg->firstActvDlBwpId = macSpCellRecfg.servCellCfg.firstActvDlBwpId;
+ servCellRecfg->defaultDlBwpId = macSpCellRecfg.servCellCfg.defaultDlBwpId;
+ servCellRecfg->bwpInactivityTmr = NULL;
+ if(macSpCellRecfg.servCellCfg.bwpInactivityTmr)
+ {
+ /* TODO : This is an optional parameter, not filled currently */
+ }
+
+ /* Fill PDSCH serving cell config */
+ if(fillPdschServCellCfg(macSpCellRecfg.servCellCfg.pdschServCellCfg, \
+ &servCellRecfg->pdschServCellCfg) != ROK)
+ {
+ DU_LOG("\nERROR --> MAC : fillPdschServCellCfg() failed");
+ return RFAILED;
+ }
+
+ /* Fill Initail UL BWP */
+ if(fillInitialUlBwp(macSpCellRecfg.servCellCfg.initUlBwp, \
+ &servCellRecfg->initUlBwp) != ROK)
+ {
+ DU_LOG("\nERROR --> MAC : fillInitialUlBwp() failed");
+ return RFAILED;
+ }
+
+ servCellRecfg->numUlBwpToAddOrMod = macSpCellRecfg.servCellCfg.numUlBwpToAddOrMod;
+ if(servCellRecfg->numUlBwpToAddOrMod > MAX_NUM_BWP)
+ {
+ DU_LOG("\nERROR --> MAC : Number of UL BWP to ADD/MOD [%d] exceeds max limit [%d]",\
+ servCellRecfg->numUlBwpToAddOrMod, MAX_NUM_BWP);
+ return RFAILED;
+ }
+ for(idx = 0; idx < servCellRecfg->numUlBwpToAddOrMod; idx++)
+ {
+ memcpy(&servCellRecfg->ulBwpToAddOrModList[idx], &macSpCellRecfg.servCellCfg.ulBwpToAddOrModList[idx], sizeof(UlBwpInfo));
+ }
+ servCellRecfg->numUlBwpToRel = macSpCellRecfg.servCellCfg.numUlBwpToRel;
+ if(servCellRecfg->numUlBwpToRel > MAX_NUM_BWP)
+ {
+ DU_LOG("\nERROR --> MAC : Number of UL BWP to RELEASE [%d] exceeds max limit [%d]",\
+ servCellRecfg->numUlBwpToRel, MAX_NUM_BWP);
+ return RFAILED;
+ }
+ for(idx = 0; idx < servCellRecfg->numUlBwpToRel; idx++)
+ {
+ memcpy(&servCellRecfg->ulBwpToRelList[idx], &macSpCellRecfg.servCellCfg.ulBwpToRelList[idx], sizeof(UlBwpInfo));
+ }
+ servCellRecfg->firstActvUlBwpId = macSpCellRecfg.servCellCfg.firstActvUlBwpId;
+
+ return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief Sends UE configuration to Scheduler
+ *
+ * @details
+ *
+ * Function : sendUeReqToSch
+ *
+ * Functionality: sends UE configuration to Scheduler
+ *
+ * @params[in] Pst and Ue configuration
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t sendUeReqToSch(Pst *pst, void *schUeCfg)
+{
+ Pst schPst;
+ switch(pst->event)
+ {
+ case EVENT_MAC_UE_CREATE_REQ:
+ {
+ SchUeCfgReq *schUeCfgReq = NULLP;
+ schUeCfgReq = (SchUeCfgReq *)schUeCfg;
+ FILL_PST_MAC_TO_SCH(schPst, EVENT_ADD_UE_CONFIG_REQ_TO_SCH);
+ return(SchMessageRouter(&schPst, (void *)schUeCfgReq));
+ }
+ case EVENT_MAC_UE_RECONFIG_REQ:
+ {
+ SchUeRecfgReq *schUeRecfgReq = NULLP;
+ schUeRecfgReq = (SchUeRecfgReq *)schUeCfg;
+ FILL_PST_MAC_TO_SCH(schPst, EVENT_MODIFY_UE_CONFIG_REQ_TO_SCH);
+ return(SchMessageRouter(&schPst, (void *)schUeRecfgReq));
+ }
+ default:
+ {
+ DU_LOG("\nERROR --> Invalid Pst received %d", pst->event);
+ return RFAILED;
+ }
+ }
+}
+
+/*******************************************************************
+ *
+ * @brief Fills Sch Drb Qos Information
+ *
+ * @details
+ *
+ * Function : fillSchDrbQosInfo
+ *
+ * Functionality: Fills Sch Drb Qos Information
+ *
+ * @params[in] macLcCfg : Logical channel Cfg at MAC
+ * schLcCfg : LC cfg to fill at scheduler
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+void fillSchDrbQosInfo(DrbQosInfo *macDrbQos, SchDrbQosInfo *schDrbQos)
+{
+ schDrbQos->fiveQiType = macDrbQos->fiveQiType;
+ if(schDrbQos->fiveQiType == SCH_QOS_NON_DYNAMIC)
+ {
+ schDrbQos->u.nonDyn5Qi.fiveQi = macDrbQos->u.nonDyn5Qi.fiveQi;
+ schDrbQos->u.nonDyn5Qi.avgWindow = macDrbQos->u.nonDyn5Qi.avgWindow;
+ schDrbQos->u.nonDyn5Qi.maxDataBurstVol = macDrbQos->u.nonDyn5Qi.maxDataBurstVol;
+ schDrbQos->u.nonDyn5Qi.priorLevel = macDrbQos->u.nonDyn5Qi.priorLevel;
+ }
+ else if(schDrbQos->fiveQiType == SCH_QOS_DYNAMIC)
+ {
+ schDrbQos->u.dyn5Qi.priorLevel = macDrbQos->u.dyn5Qi.priorLevel;
+ schDrbQos->u.dyn5Qi.packetDelayBudget = macDrbQos->u.dyn5Qi.packetDelayBudget;
+ schDrbQos->u.dyn5Qi.packetErrRateScalar= macDrbQos->u.dyn5Qi.packetErrRateScalar;
+ schDrbQos->u.dyn5Qi.packetErrRateExp = macDrbQos->u.dyn5Qi.packetErrRateExp;
+ schDrbQos->u.dyn5Qi.fiveQi = macDrbQos->u.dyn5Qi.fiveQi;
+ schDrbQos->u.dyn5Qi.delayCritical = macDrbQos->u.dyn5Qi.delayCritical;
+ schDrbQos->u.dyn5Qi.avgWindow = macDrbQos->u.dyn5Qi.avgWindow;
+ schDrbQos->u.dyn5Qi.maxDataBurstVol = macDrbQos->u.dyn5Qi.maxDataBurstVol;
+ }
+ schDrbQos->ngRanRetPri.priorityLevel = macDrbQos->ngRanRetPri.priorityLevel;
+ schDrbQos->ngRanRetPri.preEmptionCap = macDrbQos->ngRanRetPri.preEmptionCap;
+ schDrbQos->ngRanRetPri.preEmptionVul = macDrbQos->ngRanRetPri.preEmptionVul;
+ schDrbQos->grbQosFlowInfo.maxFlowBitRateDl = macDrbQos->grbQosInfo.maxFlowBitRateDl;
+ schDrbQos->grbQosFlowInfo.maxFlowBitRateUl = macDrbQos->grbQosInfo.maxFlowBitRateUl;
+ schDrbQos->grbQosFlowInfo.guarFlowBitRateDl= macDrbQos->grbQosInfo.guarFlowBitRateDl;
+ schDrbQos->grbQosFlowInfo.guarFlowBitRateUl= macDrbQos->grbQosInfo.guarFlowBitRateUl;
+ schDrbQos->pduSessionId = macDrbQos->pduSessionId;
+ schDrbQos->ulPduSessAggMaxBitRate = macDrbQos->ulPduSessAggMaxBitRate;
+}
+
+/*******************************************************************
+ *
+ * @brief Fill SCH UL logical channel configuration
+ *
+ * @details
+ *
+ * Function : fillSchUlLcCfg
+ *
+ * Functionality: Fills Sch Ul Lc configuration
+ *
+ * @params[in] macLcCfg : Logical channel Cfg at MAC
+ * schLcCfg : LC cfg to fill at scheduler
+ * @return void
+ *
+ * ****************************************************************/
+
+void fillSchUlLcCfg(SchUlLcCfg *schUlLcCfg, UlLcCfg *macUlLcCfg)
+{
+ schUlLcCfg->priority= macUlLcCfg->priority;
+ schUlLcCfg->lcGroup = macUlLcCfg->lcGroup;
+ schUlLcCfg->schReqId= macUlLcCfg->schReqId;
+ schUlLcCfg->pbr = macUlLcCfg->pbr;
+ schUlLcCfg->bsd = macUlLcCfg->bsd;
+}
+
+/*******************************************************************
+ *
+ * @brief Fill logical channel configuration
+ *
+ * @details
+ *
+ * Function : fillLogicalChannelCfg
+ *
+ * Functionality: Fill logical channel configuration
+ *
+ * @params[in] macLcCfg : Logical channel Cfg at MAC
+ * schLcCfg : LC cfg to fill at scheduler
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t fillLogicalChannelCfg(SchLcCfg *schLcCfg, LcCfg *macLcCfg)
+{
+ uint8_t sdIdx;
+ uint8_t ret = ROK;
+ schLcCfg->lcId = macLcCfg->lcId;
+ schLcCfg->dlLcCfg.lcp = macLcCfg->dlLcCfg.lcp;
+ fillSchUlLcCfg(&schLcCfg->ulLcCfg, &macLcCfg->ulLcCfg);
+
+ if(macLcCfg->drbQos)
+ {
+ if(!schLcCfg->drbQos)
+ {
+ MAC_ALLOC(schLcCfg->drbQos, sizeof(SchDrbQosInfo));
+ if(!schLcCfg->drbQos)
+ {
+ DU_LOG("\nERROR --> MAC : Memory alloc failed at drbQos at fillLogicalChannelCfg()");
+ ret = RFAILED;
+ }
+ }
+ if(ret == ROK)
+ {
+ fillSchDrbQosInfo(macLcCfg->drbQos, schLcCfg->drbQos);
+ }
+ else
+ return ret;
+ }
+ else
+ {
+ schLcCfg->drbQos = NULLP;
+ }
+
+ if(ret == ROK)
+ {
+ if(macLcCfg->snssai)
+ {
+ if(!schLcCfg->snssai)
+ {
+ MAC_ALLOC(schLcCfg->snssai, sizeof(Snssai));
+ if(!schLcCfg->snssai)
+ {
+ DU_LOG("\nERROR --> MAC : Memory alloc failed at snssai at fillLogicalChannelCfg()");
+ ret = RFAILED;
+ }
+ }
+ if(ret == ROK)
+ {
+ schLcCfg->snssai->sst = macLcCfg->snssai->sst;
+ for(sdIdx = 0; sdIdx < SD_SIZE; sdIdx++)
+ {
+ schLcCfg->snssai->sd[sdIdx] = macLcCfg->snssai->sd[sdIdx];
+ }
+ }
+ }
+ else
+ {
+ schLcCfg->snssai = NULLP;
+ }
+ }
+
+ return ret;
+}
+
+/*******************************************************************
+ *
+ * @brief Fills Logical channel Cfg List to Add
+ *
+ * @details
+ *
+ * Function : fillSchLcCfgList
+ *
+ * Functionality: Fills Logical channel Cfg List to Add
+ *
+ * @params[in] MAC UE Cb Cfg , MAC UE Configuration
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t fillSchLcCfgList(SchUeCfgReq *schUeCfg, MacUeCreateReq *ueCfg)
+{
+ uint8_t lcIdx;
+
+ for(lcIdx = 0; lcIdx < ueCfg->numLcs; lcIdx++)
+ {
+ if(fillLogicalChannelCfg(&schUeCfg->schLcCfg[lcIdx], &ueCfg->lcCfgList[lcIdx]) != ROK)
+ {
+ DU_LOG("\nERROR --> MAC : fillLogicalChannelCfg() failed for lc Idx[%d]", lcIdx);
+ return RFAILED;
+ }
+ schUeCfg->numLcsToAdd++;
+ }
+ return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief Fills Logical channel Recfg List to Add/Mod/Del
+ *
+ * @details
+ *
+ * Function : fillSchLcRecfgList
+ *
+ * Functionality: Fills Logical channel Recfg List to Add/Mod/Del
+ *
+ * @params[in] MAC UE Cb Recfg , MAC UE ReConfiguration
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t fillSchLcRecfgList(SchUeRecfgReq *schUeRecfg, MacUeRecfg *ueRecfg)
+{
+ uint8_t lcIdx;
+
+ /*LC to ADD*/
+ for(lcIdx = 0; lcIdx < ueRecfg->numLcsToAdd; lcIdx++)
+ {
+ if(fillLogicalChannelCfg(&schUeRecfg->schLcCfgAdd[lcIdx], &ueRecfg->lcCfgAdd[lcIdx]) != ROK)
+ {
+ DU_LOG("\nERROR --> MAC : fillLogicalChannelCfg() failed for lc Idx[%d]", lcIdx);
+ return RFAILED;
+ }
+ schUeRecfg->numLcsToAdd++;
+ }
+ /*LC to DEL*/
+ for(lcIdx = 0; lcIdx < ueRecfg->numLcsToDel; lcIdx++)
+ {
+ schUeRecfg->lcIdToDel[lcIdx] = ueRecfg->lcIdToDel[lcIdx];
+ schUeRecfg->numLcsToDel++;
+ }
+ /*LC to MOD*/
+ for(lcIdx = 0; lcIdx < ueRecfg->numLcsToMod; lcIdx++)
+ {
+ if(fillLogicalChannelCfg(&schUeRecfg->schLcCfgMod[lcIdx], &ueRecfg->lcCfgMod[lcIdx]) != ROK)
+ {
+ DU_LOG("\nERROR --> MAC : fillLogicalChannelCfg() failed for lc Idx[%d]", lcIdx);
+ return RFAILED;
+ }
+ schUeRecfg->numLcsToMod++;
+ }
+ return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief Fills and sends UE configuration to Scheduler
+ *
+ * @details
+ *
+ * Function : fillSchUeCfg
+ *
+ * Functionality: Fills and sends UE configuration to Scheduler
+ *
+ * @params[in] Ue configuration from DU APP
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t fillSchUeCfg(SchUeCfgReq *schUeCfg, MacUeCreateReq *ueCfg)
+{
+ uint8_t ret = ROK;
+
+ schUeCfg->cellId = ueCfg->cellId;
+ schUeCfg->crnti = ueCfg->crnti;
+ /* Copy MAC cell group config */
+ if(ueCfg->macCellGrpCfgPres == true)
+ {
+ schUeCfg->macCellGrpCfgPres = true;
+ memset(&schUeCfg->macCellGrpCfg, 0, sizeof(SchMacCellGrpCfg));
+ if(fillMacCellGroupCfg(ueCfg->macCellGrpCfg, &schUeCfg->macCellGrpCfg) != ROK)
+ {
+ DU_LOG("\nERROR --> MAC : fillMacCellGroupCfg() failed");
+ return RFAILED;
+ }
+ }
+ if(ueCfg->phyCellGrpCfgPres == true)
+ {
+ schUeCfg->phyCellGrpCfgPres = true;
+ /* Copy Physical cell group config */
+ memset(&schUeCfg->phyCellGrpCfg, 0,sizeof(SchPhyCellGrpCfg));
+ if(fillPhyCellGroupCfg(ueCfg->phyCellGrpCfg, &schUeCfg->phyCellGrpCfg) != ROK)
+ {
+ DU_LOG("\nERROR --> MAC : fillPhyCellGroupCfg() failed");
+ return RFAILED;
+ }
+ }
+
+ if(ueCfg->spCellCfgPres == true)
+ {
+ schUeCfg->spCellCfgPres = true;
+ /* Copy sp cell config */
+ memset(&schUeCfg->spCellCfg, 0, sizeof(SchSpCellCfg));
+ if(fillSpCellCfg(ueCfg->spCellCfg, &schUeCfg->spCellCfg) != ROK)
+ {
+ DU_LOG("\nERROR --> MAC : fillSpCellCfg() failed");
+ return RFAILED;
+ }
+ }
+ if(ueCfg->ambrCfg != NULLP)
+ {
+ MAC_ALLOC(schUeCfg->ambrCfg, sizeof(SchAmbrCfg));
+ if(!schUeCfg->ambrCfg)
+ {
+ DU_LOG("\nERROR --> MAC : Memory allocation failed in sendReconfigReqToSch");
+ return RFAILED;
+ }
+ schUeCfg->ambrCfg->ulBr = ueCfg->ambrCfg->ulBr;
+ }
+ else
+ {
+ schUeCfg->ambrCfg = NULLP;
+ }
+ /* Fill DL modulation infor */
+ schUeCfg->dlModInfo.modOrder = ueCfg->dlModInfo.modOrder;
+ schUeCfg->dlModInfo.mcsIndex = ueCfg->dlModInfo.mcsIndex;
+ schUeCfg->dlModInfo.mcsTable = ueCfg->dlModInfo.mcsTable;
+
+ /* Fill UL modulation infor */
+ schUeCfg->ulModInfo.modOrder = ueCfg->ulModInfo.modOrder;
+ schUeCfg->ulModInfo.mcsIndex = ueCfg->ulModInfo.mcsIndex;
+ schUeCfg->ulModInfo.mcsTable = ueCfg->ulModInfo.mcsTable;
+
+ /* Fill sch Lc Cfg to Add*/
+ ret = fillSchLcCfgList(schUeCfg, ueCfg);
+ if(ret == RFAILED)
+ {
+ DU_LOG("\nERROR --> MAC : Failed to copy LCs at fillSchUeCfg()");
+ return ret;
+ }
+
+ return ret;
+}
+
+/*******************************************************************
+ *
+ * @brief Fills and sends UE Re-configuration to Scheduler
+ *
+ * @details
+ *
+ * Function : fillSchUeRecfg
+ *
+ * Functionality: Fills and sends UE Reconfiguration to Scheduler
+ *
+ * @params[in] Ue configuration from DU APP
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t fillSchUeRecfg(SchUeRecfgReq *schUeRecfg, MacUeRecfg *ueRecfg)
+{
+ uint8_t ret = ROK;
+
+ schUeRecfg->cellId = ueRecfg->cellId;
+ schUeRecfg->crnti = ueRecfg->crnti;
+ schUeRecfg->dataTransmissionInfo = ueRecfg->transmissionAction;
+ /* Copy MAC cell group config */
+ if(ueRecfg->macCellGrpRecfgPres == true)
+ {
+ schUeRecfg->macCellGrpRecfgPres = true;
+ memset(&schUeRecfg->macCellGrpRecfg, 0, sizeof(SchMacCellGrpCfg));
+ if(fillMacCellGroupCfg(ueRecfg->macCellGrpRecfg, &schUeRecfg->macCellGrpRecfg) != ROK)
+ {
+ DU_LOG("\nERROR --> MAC : fillMacCellGroupRecfg() failed");
+ return RFAILED;
+ }
+ }
+ if(ueRecfg->phyCellGrpRecfgPres == true)
+ {
+ schUeRecfg->phyCellGrpRecfgPres = true;
+ /* Copy Physical cell group config */
+ memset(&schUeRecfg->phyCellGrpRecfg, 0,sizeof(SchPhyCellGrpCfg));
+ if(fillPhyCellGroupCfg(ueRecfg->phyCellGrpRecfg, &schUeRecfg->phyCellGrpRecfg) != ROK)
+ {
+ DU_LOG("\nERROR --> MAC : fillPhyCellGroupRecfg() failed");
+ return RFAILED;
+ }
+ }
+
+ if(ueRecfg->spCellRecfgPres == true)
+ {
+ schUeRecfg->spCellRecfgPres = true;
+ /* Copy sp cell config */
+ memset(&schUeRecfg->spCellRecfg, 0, sizeof(SchSpCellCfg));
+ if(fillSpCellRecfg(ueRecfg->spCellRecfg, &schUeRecfg->spCellRecfg) != ROK)
+ {
+ DU_LOG("\nERROR --> MAC : fillSpCellRecfg() failed");
+ return RFAILED;
+ }
+ }
+ if(ueRecfg->ambrRecfg != NULLP)
+ {
+ MAC_ALLOC(schUeRecfg->ambrRecfg, sizeof(SchAmbrCfg));
+ if(!schUeRecfg->ambrRecfg)
+ {
+ DU_LOG("\nERROR --> MAC : Memory allocation failed in sendReconfigReqToSch");
+ return RFAILED;
+ }
+ schUeRecfg->ambrRecfg->ulBr = ueRecfg->ambrRecfg->ulBr;
+ }
+ else
+ {
+ schUeRecfg->ambrRecfg = NULLP;
+ }
+ /* Fill DL modulation infor */
+ schUeRecfg->dlModInfo.modOrder = ueRecfg->dlModInfo.modOrder;
+ schUeRecfg->dlModInfo.mcsIndex = ueRecfg->dlModInfo.mcsIndex;
+ schUeRecfg->dlModInfo.mcsTable = ueRecfg->dlModInfo.mcsTable;
+
+ /* Fill UL modulation infor */
+ schUeRecfg->ulModInfo.modOrder = ueRecfg->ulModInfo.modOrder;
+ schUeRecfg->ulModInfo.mcsIndex = ueRecfg->ulModInfo.mcsIndex;
+ schUeRecfg->ulModInfo.mcsTable = ueRecfg->ulModInfo.mcsTable;
+
+ /* Fill sch Lc Cfg to Add/ Mod/ Del */
+ ret = fillSchLcRecfgList(schUeRecfg, ueRecfg);
+ if(ret == RFAILED)
+ {
+ DU_LOG("\nERROR --> MAC : Failed to copy LCs at fillSchUeRecfg()");
+ return ret;
+ }
+
+#ifdef NR_DRX
+ schUeRecfg->drxConfigIndicatorRelease = ueRecfg->drxConfigIndicatorRelease;;
+#endif
+
+ return ret;
+}
+
+/*******************************************************************
+ *
+ * @brief Update UeUlCb Lc List
+ *
+ * @details
+ *
+ * Function : updateMacUlCb
+ *
+ * Functionality: Update UeUlCb Lc List
+ *
+ * @params[in] delIdx, UeUlCb pointer
+ * @return void
+ *
+ * ****************************************************************/
+
+void updateMacUlCb(uint8_t delIdx, UeUlCb *ulCb)
+{
+ uint8_t lcIdx = 0;
+
+ for(lcIdx = delIdx; lcIdx < ulCb->numUlLc; lcIdx++)
+ {
+ /* Moving the array element to one step ahead */
+ memcpy(&ulCb->lcCb[lcIdx], &ulCb->lcCb[lcIdx+1], sizeof(UlLcCb));
+ memset(&ulCb->lcCb[lcIdx+1], 0, sizeof(UlLcCb));
+ }
+ /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
+#if 0
+ /*Checking the Memory Leakage of Last Index*/
+ if(ulCb->lcCb[ulCb->numUlLc].snssai != NULLP)
+ {
+ DU_LOG("ERROR --> MAC: updateMacUlCb Last index deleted :%d memory is leaking",\
+ ulCb->numUlLc);
+ MAC_FREE(ulCb->lcCb[ulCb->numUlLc].snssai, sizeof(Snssai));
+ }
+ else
+ {
+ DU_LOG("INFO --> MAC: updateMacUlCb Last index:%d (before deletion) memory is freed successfully",\
+ ulCb->numUlLc);
+ }
+#endif
+}
+
+/*******************************************************************
+ *
+ * @brief Update UeDlCb Lc List
+ *
+ * @details
+ *
+ * Function : updateMacDlCb
+ *
+ * Functionality: Update UeDlCb Lc List
+ *
+ * @params[in] delIdx, UeDlCb pointer
+ * @return void
+ *
+ * ****************************************************************/
+
+void updateMacDlCb(uint8_t delIdx, UeDlCb *dlCb)
+{
+ uint8_t lcIdx = 0;
+
+ for(lcIdx = delIdx; lcIdx < dlCb->numDlLc; lcIdx++)
+ {
+ /* Moving the array element to one step ahead */
+ memcpy(&dlCb->lcCb[lcIdx], &dlCb->lcCb[lcIdx+1], sizeof(DlLcCb));
+ memset(&dlCb->lcCb[lcIdx+1], 0, sizeof(DlLcCb));
+ }
+ /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
+#if 0
+ /*Checking the Memory Leakage of Last Index*/
+ if(dlCb->lcCb[dlCb->numDlLc].snssai != NULLP)
+ {
+ DU_LOG("ERROR --> MAC: updateMacDlCb Last Deleted index:%d memory is leaking",\
+ dlCb->numDlLc);
+ MAC_FREE(dlCb->lcCb[dlCb->numDlLc].snssai, sizeof(Snssai));
+ }
+ else
+ {
+ DU_LOG("INFO --> MAC: updateMacDlCb Last index:%d (before deletion) memory is freed successfully",\
+ dlCb->numDlLc);
+ }
+#endif
+}
+
+/*******************************************************************
+ *
+ * @brief Update Mac UL Lc List based on CONFIG_MOD/CONFIG_DEL
+ *
+ * @details
+ *
+ * Function : updateMacUlLcCtxt
+ *
+ * Functionality: Update UeUlCb Lc List
+ *
+ * @params[in] UeUlCb pointer [For DEL case, NULL is passed]
+ * ueLcCfg(received from DUAPP)
+ * lcIdToDel [For MOD case, Invalid Value = MAX_NUM_LC is passed]
+ * @return void
+ *
+ * ****************************************************************/
+void updateMacUlLcCtxt(UeUlCb *ulInfo, LcCfg *ueLcCfg, uint8_t lcIdToDel)
+{
+ uint8_t ueLcIdx = 0;
+
+ /*Traversing UL LC to be updated/Deleted*/
+ for(ueLcIdx = 0; ueLcIdx < ulInfo->numUlLc; ueLcIdx++)
+ {
+ if((ueLcCfg != NULLP) && (ulInfo->lcCb[ueLcIdx].lcId == ueLcCfg->lcId))
+ {
+ /*Modify UL LC CB */
+ ulInfo->lcCb[ueLcIdx].lcGrpId = ueLcCfg->ulLcCfg.lcGroup;
+
+ /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
+#if 0
+ /*Modifying/Copying PduSession ID and S-NSSAI into MAC's UECB*/
+ if(ueLcCfg->drbQos)
+ {
+ ulInfo->lcCb[ueLcIdx].pduSessionId = ueLcCfg->drbQos->pduSessionId;
+ }
+ if(ueLcCfg->snssai)
+ {
+ if(ulInfo->lcCb[ueLcIdx].snssai == NULLP)
+ {
+ MAC_ALLOC(ulInfo->lcCb[ueLcIdx].snssai, sizeof(Snssai));
+ }
+
+ memcpy(ulInfo->lcCb[ueLcIdx].snssai, ueLcCfg->snssai, sizeof(Snssai));
+ }
+#endif
+ DU_LOG("\nINFO --> MAC: Successfully Modified LC context for lcId[%d], ueLcIdx:%d",\
+ ueLcCfg->lcId,ueLcIdx);
+ break;
+ }
+ else if(lcIdToDel != MAX_NUM_LC && (ulInfo->lcCb[ueLcIdx].lcId == lcIdToDel))
+ {
+ memset(&ulInfo->lcCb[ueLcIdx], 0, sizeof(UlLcCb));
+ (ulInfo->numUlLc)--;
+ updateMacUlCb(ueLcIdx, ulInfo);
+ DU_LOG("\nINFO --> MAC: Successfully Deleted LC context for lcId[%d]", lcIdToDel);
+ break;
+ }
+ }
+}
+
+/*******************************************************************
+ *
+ * @brief Update Mac DL Lc List based on CONFIG_MOD/CONFIG_DEL
+ *
+ * @details
+ *
+ * Function : updateMacDlLcCtxt
+ *
+ * Functionality: Update UeDlCb Lc List
+ *
+ * @params[in] UeDlCb pointer [For DEL case, NULL is passed]
+ * ueLcCfg(received from DUAPP)
+ * lcIdToDel [For MOD case, Invalid Value = MAX_NUM_LC is passed]
+ * @return void
+ *
+ * ****************************************************************/
+void updateMacDlLcCtxt(UeDlCb *dlInfo, LcCfg *ueLcCfg, uint8_t lcIdToDel)
+{
+ uint8_t ueLcIdx = 0;
+
+ /*Traversing DL LC to be updated/Deleted*/
+ for(ueLcIdx = 0; ueLcIdx < dlInfo->numDlLc; ueLcIdx++)
+ {
+ if((ueLcCfg != NULLP) && (dlInfo->lcCb[ueLcIdx].lcId == ueLcCfg->lcId))
+ {
+ /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
+#if 0
+ /*Modifying/Copying PduSession ID and S-NSSAI into MAC's UECB*/
+ if(ueLcCfg->drbQos)
+ {
+ dlInfo->lcCb[ueLcIdx].pduSessionId = ueLcCfg->drbQos->pduSessionId;
+ }
+ if(ueLcCfg->snssai)
+ {
+ if(dlInfo->lcCb[ueLcIdx].snssai == NULLP)
+ {
+ MAC_ALLOC(dlInfo->lcCb[ueLcIdx].snssai, sizeof(Snssai));
+ }
+
+ memcpy(dlInfo->lcCb[ueLcIdx].snssai, ueLcCfg->snssai, sizeof(Snssai));
+ }
+#endif
+ DU_LOG("\nINFO --> MAC: Successfully Modified LC context for lcId[%d], ueLcIdx:%d",\
+ ueLcCfg->lcId,ueLcIdx);
+ break;
+ }
+ else if(lcIdToDel != MAX_NUM_LC && (dlInfo->lcCb[ueLcIdx].lcId == lcIdToDel))
+ {
+ memset(&dlInfo->lcCb[ueLcIdx], 0, sizeof(DlLcCb));
+ (dlInfo->numDlLc)--;
+ updateMacDlCb(ueLcIdx, dlInfo);
+ DU_LOG("\nINFO --> MAC: Successfully Deleted LC context for lcId[%d]", lcIdToDel);
+ break;
+ }
+ }
+}
+
+/*******************************************************************
+ *
+ * @brief Fills Logical channel Cfg List to Add/Mod/Del
+ *
+ * @details
+ *
+ * Function : fillMacLcCfgList
+ *
+ * Functionality: Fills Logical channel Cfg List to Add/Mod/Del
+ *
+ * @params[in] MAC UE Cb Cfg , MAC UE Configuration
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t fillMacLcCfgList(MacUeCb *ueCb, MacUeCreateReq *ueCfg)
+{
+ uint8_t lcIdx = 0;
+
+ for(lcIdx = 0; lcIdx < ueCfg->numLcs; lcIdx++)
+ {
+ if(ueCb->dlInfo.numDlLc < MAX_NUM_LC)
+ {
+ /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
+#if 0
+ /*Copying PduSession ID and S-NSSAI into MAC's UECB*/
+ if(ueCfg->lcCfgList[lcIdx].drbQos)
+ {
+ ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].pduSessionId = \
+ ueCfg->lcCfgList[lcIdx].drbQos->pduSessionId;
+
+ ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].pduSessionId = \
+ ueCfg->lcCfgList[lcIdx].drbQos->pduSessionId;
+ }
+ if(ueCfg->lcCfgList[lcIdx].snssai)
+ {
+ if(ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].snssai == NULLP)
+ {
+ MAC_ALLOC(ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].snssai, sizeof(Snssai));
+ }
+ if(ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].snssai == NULLP)
+ {
+ MAC_ALLOC(ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].snssai, sizeof(Snssai));
+ }
+
+ memcpy(ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].snssai, \
+ ueCfg->lcCfgList[lcIdx].snssai, sizeof(Snssai));
+
+ memcpy(ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].snssai, \
+ ueCfg->lcCfgList[lcIdx].snssai, sizeof(Snssai));
+
+ }
+#endif
+ /*Filling DL LC CB */
+ ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].lcId = ueCfg->lcCfgList[lcIdx].lcId;
+ ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].lcState = MAC_LC_STATE_ACTIVE;
+ ueCb->dlInfo.numDlLc++;
+ /*Filling UL LC CB */
+ ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].lcId = ueCfg->lcCfgList[lcIdx].lcId;
+ ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].lcGrpId = ueCfg->lcCfgList[lcIdx].ulLcCfg.lcGroup;
+ ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].lcActive = MAC_LC_STATE_ACTIVE;
+ ueCb->ulInfo.numUlLc++;
+ }
+ }
+ return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief Fills Logical channel Cfg List to Add/Mod/Del
+ *
+ * @details
+ *
+ * Function : updateMacLcCfgList
+ *
+ * Functionality: Fills Logical channel Cfg List to Add/Mod/Del
+ *
+ * @params[in] MAC UE Cb Cfg , MAC UE Configuration
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t updateMacLcCfgList(MacUeCb *ueCb, MacUeRecfg *ueRecfg)
+{
+ uint8_t lcIdx = 0;
+
+ for(lcIdx = 0; lcIdx < ueRecfg->numLcsToAdd; lcIdx++)
+ {
+ if(ueCb->dlInfo.numDlLc < MAX_NUM_LC)
+ {
+ /*Commenting as S-NSSAI and PDU session will be stored in MAC DB in future scope*/
+#if 0
+ /*Copying PduSession ID and S-NSSAI into MAC's UECB*/
+ if(ueRecfg->lcCfgList[lcIdx].drbQos)
+ {
+ ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].pduSessionId = \
+ ueRecfg->lcCfgList[lcIdx].drbQos->pduSessionId;
+
+ ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].pduSessionId = \
+ ueRecfg->lcCfgList[lcIdx].drbQos->pduSessionId;
+ }
+ if(ueRecfg->lcCfgList[lcIdx].snssai)
+ {
+ if(ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].snssai == NULLP)
+ {
+ MAC_ALLOC(ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].snssai, sizeof(Snssai));
+ }
+ if(ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].snssai == NULLP)
+ {
+ MAC_ALLOC(ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].snssai, sizeof(Snssai));
+ }
+
+ memcpy(ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].snssai, \
+ ueRecfg->lcCfgList[lcIdx].snssai, sizeof(Snssai));
+
+ memcpy(ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].snssai, \
+ ueRecfg->lcCfgList[lcIdx].snssai, sizeof(Snssai));
+
+ }
+#endif
+ /*Filling DL LC CB */
+ ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].lcId = ueRecfg->lcCfgAdd[lcIdx].lcId;
+ ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].lcState = MAC_LC_STATE_ACTIVE;
+ ueCb->dlInfo.numDlLc++;
+ /*Filling UL LC CB */
+ ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].lcId = ueRecfg->lcCfgAdd[lcIdx].lcId;
+ ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].lcGrpId = ueRecfg->lcCfgAdd[lcIdx].ulLcCfg.lcGroup;
+ ueCb->ulInfo.lcCb[ueCb->ulInfo.numUlLc].lcActive = MAC_LC_STATE_ACTIVE;
+ ueCb->ulInfo.numUlLc++;
+ }/*End of Add Config */
+ }
+ for(lcIdx = 0; lcIdx < ueRecfg->numLcsToDel; lcIdx++)
+ {
+ if(ueCb->dlInfo.numDlLc < MAX_NUM_LC)
+ {
+ updateMacUlLcCtxt(&ueCb->ulInfo, NULLP, ueRecfg->lcIdToDel[lcIdx]);
+ updateMacDlLcCtxt(&ueCb->dlInfo, NULLP, ueRecfg->lcIdToDel[lcIdx]);
+ }
+ }
+ for(lcIdx = 0; lcIdx < ueRecfg->numLcsToMod; lcIdx++)
+ {
+ if(ueCb->dlInfo.numDlLc < MAX_NUM_LC)
+ {
+ updateMacUlLcCtxt(&ueCb->ulInfo, &ueRecfg->lcCfgMod[lcIdx], MAX_NUM_LC);
+ updateMacDlLcCtxt(&ueCb->dlInfo, &ueRecfg->lcCfgMod[lcIdx], MAX_NUM_LC);
+ }
+ }
+ return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief Fills MAC UE Cb Cfg
+ *
+ * @details
+ *
+ * Function : fillMacUeCb
+ *
+ * Functionality: Fills MAC UE Cb Cfg
+ *
+ * @params[in] MAC UE Cb Cfg , MAC UE Configuration
+ * cellIdx
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t fillMacUeCb(MacUeCb *ueCb, MacUeCreateReq *ueCfg, uint8_t cellIdx)
+{
+ uint8_t ret = ROK;
+
+ ueCb->ueId = ueCfg->ueId;
+ ueCb->crnti = ueCfg->crnti;
+ ueCb->cellCb = macCb.macCell[cellIdx];
+ if(ueCfg->spCellCfgPres)
+ {
+ ueCb->dlInfo.dlHarqEnt.numHarqProcs = \
+ ueCfg->spCellCfg.servCellCfg.pdschServCellCfg.numHarqProcForPdsch;
+ }
+
+ /*TODO: To check the bsr value during implementation */
+ if(ueCfg->macCellGrpCfgPres)
+ {
+ ueCb->bsrTmrCfg.periodicTimer = ueCfg->macCellGrpCfg.bsrTmrCfg.periodicTimer;
+ ueCb->bsrTmrCfg.retxTimer = ueCfg->macCellGrpCfg.bsrTmrCfg.retxTimer;
+ ueCb->bsrTmrCfg.srDelayTimer = ueCfg->macCellGrpCfg.bsrTmrCfg.srDelayTimer;
+ }
+ ret = fillMacLcCfgList(ueCb, ueCfg);
+ if(ret == RFAILED)
+ {
+ DU_LOG("\nERROR --> MAC: Failed while filing MAC LC List at fillMacUeCb()");
+ }
+ return ret;
+}
+
+/*******************************************************************
+ *
+ * @brief Fills MAC UE Cb Cfg
+ *
+ * @details
+ *
+ * Function : updateMacUeCb
+ *
+ * Functionality: updateMacUeCbs MAC UE Cb Cfg
+ *
+ * @params[in] MAC UE Cb Recfg , MAC UE Configuration
+ * cellIdx
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t updateMacUeCb(MacUeCb *ueCb, MacUeRecfg *ueRecfg, uint8_t cellIdx)
+{
+ uint8_t ret = ROK;
+
+ ueCb->ueId = ueRecfg->ueId;
+ ueCb->crnti = ueRecfg->crnti;
+ ueCb->cellCb = macCb.macCell[cellIdx];
+ if(ueRecfg->spCellRecfgPres)
+ {
+ ueCb->dlInfo.dlHarqEnt.numHarqProcs = \
+ ueRecfg->spCellRecfg.servCellCfg.pdschServCellCfg.numHarqProcForPdsch;
+ }
+
+ /*TODO: To check the bsr value during implementation */
+ if(ueRecfg->macCellGrpRecfgPres)
+ {
+ ueCb->bsrTmrCfg.periodicTimer = ueRecfg->macCellGrpRecfg.bsrTmrCfg.periodicTimer;
+ ueCb->bsrTmrCfg.retxTimer = ueRecfg->macCellGrpRecfg.bsrTmrCfg.retxTimer;
+ ueCb->bsrTmrCfg.srDelayTimer = ueRecfg->macCellGrpRecfg.bsrTmrCfg.srDelayTimer;
+ }
+ ret = updateMacLcCfgList(ueCb, ueRecfg);
+ if(ret == RFAILED)
+ {
+ DU_LOG("\nERROR --> MAC: Failed while filing MAC LC List at updateMacUeCb()");
+ }
+ ueCb->transmissionAction = ueRecfg->transmissionAction;
+
+ return ret;
+}
+
+/*******************************************************************
+ *
+ * @brief Function to update Mac Ra Cb
+ *
+ * @details
+ *
+ * Function : updateMacRaCb
+ *
+ * Functionality: Function to update Mac Ra Cb
+ *
+ * @params[in] cellIdx, Mac Ue Cb
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t updateMacRaCb(uint16_t cellIdx, MacUeCb *ueCb)
+{
+ /* Copy RA Cb */
+ if(macCb.macCell[cellIdx]->macRaCb[ueCb->ueId-1].crnti == ueCb->crnti)
+ {
+ ueCb->raCb = &macCb.macCell[cellIdx]->macRaCb[ueCb->ueId-1];
+ }
+ else
+ {
+ DU_LOG("\nERROR --> MAC : No RA CB found for UE ID [%d]", ueCb->ueId);
+ return RFAILED;
+ }
+ return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief Function to delete Mac Ra Cb
+ *
+ * @details
+ *
+ * Function : deleteMacRaCb
+ *
+ * Functionality: Function to delete Mac Ra Cb
+ *
+ * @params[in] cellIdx, Mac Ue Cb
+ * @return void
+ *
+ * ****************************************************************/
+
+void deleteMacRaCb(uint16_t cellIdx, MacUeCb *ueCb)
+{
+ uint8_t tbIdx;
+ MacRaCbInfo *raCb = ueCb->raCb;
+
+ if(raCb && (raCb->crnti == ueCb->crnti))
+ {
+ MAC_FREE(raCb->msg4Pdu, raCb->msg4PduLen);
+ for(tbIdx = 0; tbIdx < raCb->msg4HqInfo.numTb; tbIdx++)
+ {
+ MAC_FREE(raCb->msg4HqInfo.tbInfo[tbIdx].tb, \
+ raCb->msg4HqInfo.tbInfo[tbIdx].tbSize - TX_PAYLOAD_HDR_LEN);
+ }
+ memset(raCb, 0, sizeof(MacRaCbInfo));
+ }
+}
+
+/*******************************************************************
+ *
+ * @brief Creates UE Cb
+ *
+ * @details
+ *
+ * Function : createUeCb
+ *
+ * Functionality: Creates UE Cb
+ *
+ * @params[in] MAC UE Configuration
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t createUeCb(uint8_t cellIdx, MacUeCb *ueCb, MacUeCreateReq *ueCfg)
+{
+ uint8_t ret = ROK;
+ uint8_t hqProcIdx = 0;
+
+ if((ueCb->ueId == ueCfg->ueId) && (ueCb->crnti == ueCfg->crnti)\
+ &&(ueCb->state == UE_STATE_ACTIVE))
+ {
+ DU_LOG("\nERROR --> MAC : CRNTI %d already configured ", ueCfg->crnti);
+ return ROKDUP;
+ }
+ else
+ {
+ memset(ueCb, 0, sizeof(MacUeCb));
+ ret = fillMacUeCb(ueCb, ueCfg, cellIdx);
+ if(ret != ROK)
+ {
+ DU_LOG("\nERROR --> MAC : Failed to create Ue Cb at createUeCb()");
+ return ret;
+ }
+ else
+ {
+ /* Initialize all DL HARQ PROC ID to MAX NUM OF HARQ PROC */
+ for(hqProcIdx = 0; hqProcIdx < MAX_NUM_HARQ_PROC; hqProcIdx++)
+ {
+ ueCb->dlInfo.dlHarqEnt.harqProcCb[hqProcIdx].procId = MAX_NUM_HARQ_PROC;
+ }
+
+ /* If UE has not requested for RACH yet, it means UE context is created for a
+ * UE in handover */
+ if(macCb.macCell[cellIdx]->macRaCb[ueCb->ueId-1].crnti == ueCb->crnti)
+ {
+ ueCb->state = UE_STATE_ACTIVE;
+ macCb.macCell[cellIdx]->numActvUe++;
+ updateMacRaCb(cellIdx, ueCb);
+ }
+ else
+ ueCb->state = UE_HANDIN_IN_PROGRESS;
+
+ return ROK;
+ }
+ }
+ return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief Modify UE Cb Cfg
+ *
+ * @details
+ *
+ * Function : modifyUeCb
+ *
+ * Functionality: modify UE Cb
+ *
+ * @params[in] MAC UE Configuration
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t modifyUeCb(uint8_t cellIdx, MacUeCb *ueCb, MacUeRecfg *ueRecfg)
+{
+ uint8_t ret = ROK;
+
+ if((ueCb->ueId == ueRecfg->ueId) && (ueCb->crnti == ueRecfg->crnti)\
+ &&(ueCb->state == UE_STATE_ACTIVE))
+ {
+ DU_LOG("\nINFO --> MAC : Modifying Ue config Req for CRNTI %d ", ueRecfg->crnti);
+ ret = updateMacUeCb(ueCb, ueRecfg, cellIdx);
+ if(ret != ROK)
+ {
+ DU_LOG("\nERROR --> MAC : Failed to modify MacUeCb at modifyUeCb()");
+ return ret;
+ }
+ else
+ {
+ return ROK;
+ }
+ }
+ return RFAILED;
+}
+
+
+/*******************************************************************
+ *
+ * @brief Creates UE Cb and fills ueCfg
+ *
+ * @details
+ *
+ * Function : procMacUeCfgData
+ *
+ * Functionality: Creates UE Cb and fills ueCfg
+ *
+ * @params[in] MAC UE Configuration
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t procMacUeCfgData(Pst *pst, MacUeCreateReq *ueCfg, MacUeRecfg *ueRecfg)
+{
+ uint8_t ret = ROK, ueId = 0;
+ uint16_t cellIdx, cellId;
+ MacUeCb *ueCb = NULLP;
+
+ if(ueCfg != NULLP)
+ {
+ cellId = ueCfg->cellId;
+ ueId = ueCfg->ueId;
+ }
+ else if(ueRecfg != NULLP)
+ {
+ cellId = ueRecfg->cellId;
+ ueId = ueRecfg->ueId;
+ }
+
+
+ GET_CELL_IDX(cellId, cellIdx);
+
+ /* Validate cell id */
+ if(macCb.macCell[cellIdx]->cellId != cellId)
+ {
+ DU_LOG("\nERROR --> MAC : Cell Id %d not configured", cellId);
+ return RFAILED;
+ }
+
+ /* Check if max number of UE configured */
+ if(macCb.macCell[cellIdx]->numActvUe > MAX_NUM_UE)
+ {
+ DU_LOG("\nERROR --> MAC : Max number of UE [%d] already configured", MAX_NUM_UE);
+ return RFAILED;
+ }
+
+ /* Check if UE already configured */
+ ueCb = &macCb.macCell[cellIdx]->ueCb[ueId -1];
+
+ switch(pst->event)
+ {
+ case EVENT_UE_CONFIG_RSP_TO_MAC:
+ {
+ ret = createUeCb(cellIdx, ueCb, ueCfg);
+ if(ret != ROK)
+ DU_LOG("\nERROR --> MAC: AddUeConfigReq for cellIdx :%d failed in procMacUeCfgData()", cellIdx);
+ break;
+ }
+
+ case EVENT_UE_RECONFIG_RSP_TO_MAC:
+ {
+ ret = modifyUeCb(cellIdx, ueCb, ueRecfg);
+ if(ret != ROK)
+ DU_LOG("\nERROR --> MAC: ModifyUeConfigReq for cellIdx :%d failed at procMacUeCfgData()", cellIdx);
+ break;
+ }
+
+ default:
+ break;
+ }
+
+ return ret;
+}
+
+/*******************************************************************
+ *
+ * @brief Function to store the UeCfg Data
+ *
+ * @details
+ *
+ * Function : copyToTmpData
+ *
+ * Functionality: Function to store the UeCfg Data
+ *
+ * @params[in] MacUeCreateReq pointer
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t copyToTmpData(MacUeCreateReq *ueCfg, MacUeRecfg *ueRecfg)
+{
+ uint8_t cellIdx;
+
+ if(ueCfg != NULLP)
+ {
+ MacUeCreateReq *tmpData = NULLP;
+
+ MAC_ALLOC(tmpData, sizeof(MacUeCreateReq));
+ if(!tmpData)
+ {
+ DU_LOG("\nERROR --> MAC: Memory Alloc Failed at copyToTmpData()");
+ return RFAILED;
+ }
+ memcpy(tmpData, ueCfg, sizeof(MacUeCreateReq));
+ GET_CELL_IDX(ueCfg->cellId, cellIdx);
+ macCb.macCell[cellIdx]->ueCfgTmpData[ueCfg->ueId-1] = tmpData;
+ }
+ else if(ueRecfg != NULLP)
+ {
+ MacUeRecfg *tmpData = NULLP;
+
+ MAC_ALLOC(tmpData, sizeof(MacUeRecfg));
+ if(!tmpData)
+ {
+ DU_LOG("\nERROR --> MAC: Memory Alloc Failed at copyToTmpData()");
+ return RFAILED;
+ }
+ memcpy(tmpData, ueRecfg, sizeof(MacUeRecfg));
+ GET_CELL_IDX(ueRecfg->cellId, cellIdx);
+ macCb.macCell[cellIdx]->ueRecfgTmpData[ueRecfg->ueId-1] = tmpData;
+ }
+ return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief Handles UE create requst from DU APP
+ *
+ * @details
+ *
+ * Function : MacProcUeCreateReq
+ *
+ * Functionality: Handles UE create requst from DU APP
+ *
+ * @params[in]
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t MacProcUeCreateReq(Pst *pst, MacUeCreateReq *ueCfg)
+{
+ uint8_t ret = ROK;
+ SchUeCfgReq schUeCfg;
+ memset(&schUeCfg, 0, sizeof(SchUeCfgReq));
+
+ DU_LOG("\nINFO --> MAC : UE Create Request for CRNTI[%d]", ueCfg->crnti);
+
+ if(ueCfg)