X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2F5gnrsch%2Fsch_ue_mgr.c;h=c8bac5c27684c16066c4dcf91543d2ae7ccb8b59;hb=8e6123e23f6d831b1fe972f8229e9594a2e92237;hp=4b56ce45a41e153bcd91e0502c5eaa46b545e0a7;hpb=3994dcf55e4311026546468e036bd4646935d81d;p=o-du%2Fl2.git diff --git a/src/5gnrsch/sch_ue_mgr.c b/src/5gnrsch/sch_ue_mgr.c index 4b56ce45a..c8bac5c27 100644 --- a/src/5gnrsch/sch_ue_mgr.c +++ b/src/5gnrsch/sch_ue_mgr.c @@ -50,6 +50,7 @@ SchCellDeleteRspFunc SchCellDeleteRspOpts[]= MacProcSchCellDeleteRsp, /* TC */ packSchCellDeleteRsp /* LWLC */ }; + /******************************************************************* * * @brief Fill and send UE cfg response to MAC @@ -171,79 +172,51 @@ void fillSchUlLcCtxt(SchUlLcCtxt *ueCbLcCfg, SchLcCfg *lcCfg) /******************************************************************* * - * @brief Function to update Sch Ul Lc Cb + * @brief Function to update/allocate dedLC Info * * @details * - * Function : updateSchUlCb - * - * Functionality: Function to update SCH Ul Lc Cb - * - * @returns void - * - * ****************************************************************/ - -void updateSchUlCb(uint8_t delIdx, SchUlCb *ulInfo) -{ - uint8_t lcIdx = 0; - - for(lcIdx = delIdx; lcIdx < ulInfo->numUlLc; lcIdx++) - { - memcpy(&ulInfo->ulLcCtxt[lcIdx], &ulInfo->ulLcCtxt[lcIdx+1], sizeof(SchUlLcCtxt)); - memset(&ulInfo->ulLcCtxt[lcIdx+1], 0, sizeof(SchUlLcCtxt)); - } - /*Leakage of Last Index*/ - /*Last index of ulLcCtxt(before deletion) should be void*/ - if(ulInfo->ulLcCtxt[ulInfo->numUlLc].snssai != NULLP) - { - DU_LOG("ERROR --> SCH: updateSchUlCb Last index:%d (Before Deletion) memory is leaking",\ - ulInfo->numUlLc); - SCH_FREE(ulInfo->ulLcCtxt[ulInfo->numUlLc].snssai, sizeof(Snssai)); - } - else - { - DU_LOG("INFO --> SCH: updateSchUlCb Last index:%d (before deletion) memory is freed successfully",\ - ulInfo->numUlLc); - - } -} - -/******************************************************************* + * Function : updateDedLcInfo * - * @brief Function to update SCH Dl Lc Cb + * Functionality: Function to fill DLDedLcInfo * - * @details + * @params[arg] snssai pointer, + * SchRrmPolicy pointer, + * SchLcPrbEstimate pointer , It will be filled + * isDedicated pointer,(Address of isDedicated flag in LC Context) * - * Function : updateSchDlCb - * - * Functionality: Function to update SCH DL Lc Cb - * - * @returns void + * @return ROK >> This LC is part of RRM MemberList. + * RFAILED >> FATAL Error + * ROKIGNORE >> This LC is not part of this RRM MemberList * * ****************************************************************/ -void updateSchDlCb(uint8_t delIdx, SchDlCb *dlInfo) +uint8_t updateDedLcInfo(Snssai *snssai, SchRrmPolicy *rrmPolicy, SchLcPrbEstimate *lcPrbEst,\ + bool *isDedicated) { - uint8_t lcIdx = 0; - - for(lcIdx = delIdx; lcIdx < dlInfo->numDlLc; lcIdx++) - { - memcpy(&dlInfo->dlLcCtxt[lcIdx], &dlInfo->dlLcCtxt[lcIdx+1], sizeof(SchDlLcCtxt)); - memset(&dlInfo->dlLcCtxt[lcIdx+1], 0, sizeof(SchDlLcCtxt)); - } - /*Leakage of Last Index*/ - /*Last index of ulLcCtxt(before deletion) should be void*/ - if(dlInfo->dlLcCtxt[dlInfo->numDlLc].snssai != NULLP) + if(memcmp(snssai, &(rrmPolicy->memberList.snssai), sizeof(Snssai)) == 0) { - DU_LOG("ERROR --> SCH: updateSchDlCb Last index:%d (before deletion) memory is leaking: Delete the S-NSSAI memory",\ - dlInfo->numDlLc); - SCH_FREE(dlInfo->dlLcCtxt[dlInfo->numDlLc].snssai, sizeof(Snssai)); + if(lcPrbEst->dedLcInfo == NULLP) + { + SCH_ALLOC(lcPrbEst->dedLcInfo, sizeof(DedicatedLCInfo)); + if(lcPrbEst->dedLcInfo == NULLP) + { + DU_LOG("\nINFO --> SCH : Memory Allocation Failed"); + return RFAILED; + } + } + /*Updating latest RrmPolicy*/ + lcPrbEst->dedLcInfo->rsvdDedicatedPRB = \ + (uint16_t)(((rrmPolicy->policyDedicatedRatio)*(MAX_NUM_RB))/100); + *isDedicated = TRUE; + DU_LOG("\nINFO --> SCH : Updated RRM policy, reservedPOOL:%d",lcPrbEst->dedLcInfo->rsvdDedicatedPRB); } + /*else case: This LcCtxt is either a Default LC or this LC is part of someother RRM_MemberList*/ else { - DU_LOG("INFO --> SCH: updateSchDlCb Last index:%d (before deletion) memory is freed successfully",\ - dlInfo->numDlLc); + DU_LOG("\nINFO --> SCH : This SNSSAI is not a part of this RRMPolicy"); } + return ROK; } /******************************************************************* @@ -265,8 +238,12 @@ void updateSchDlCb(uint8_t delIdx, SchDlCb *dlInfo) uint8_t fillSchUeCb(SchUeCb *ueCb, SchUeCfg *ueCfg) { uint8_t lcIdx, ueLcIdx; + uint8_t freqDomainResource[FREQ_DOM_RSRC_SIZE] = {0}; SchPdschCfgCmn pdschCfg; SchPucchDlDataToUlAck *dlDataToUlAck; + CmLListCp *lcLL = NULLP; + uint8_t retDL = ROK, retUL = ROK; + bool isLcIdValid = FALSE; ueCb->ueCfg.cellId = ueCfg->cellId; ueCb->ueCfg.crnti = ueCfg->crnti; @@ -285,6 +262,12 @@ uint8_t fillSchUeCb(SchUeCb *ueCb, SchUeCfg *ueCfg) if(ueCfg->spCellCfgPres == true) { memcpy(&ueCb->ueCfg.spCellCfg , &ueCfg->spCellCfg, sizeof(SchSpCellCfg)); + + covertFreqDomRsrcMapToIAPIFormat(ueCb->ueCfg.spCellCfg.servCellCfg.initDlBwp.pdcchCfg.cRSetToAddModList[0].freqDomainRsrc,\ + freqDomainResource); + memset(ueCb->ueCfg.spCellCfg.servCellCfg.initDlBwp.pdcchCfg.cRSetToAddModList[0].freqDomainRsrc, 0, FREQ_DOM_RSRC_SIZE); + memcpy(ueCb->ueCfg.spCellCfg.servCellCfg.initDlBwp.pdcchCfg.cRSetToAddModList[0].freqDomainRsrc, freqDomainResource, FREQ_DOM_RSRC_SIZE); + ueCb->ueCfg.spCellCfgPres = true; dlDataToUlAck = ueCfg->spCellCfg.servCellCfg.initUlBwp.pucchCfg.dlDataToUlAck; if(ueCb->cellCb) @@ -294,6 +277,7 @@ uint8_t fillSchUeCb(SchUeCb *ueCb, SchUeCfg *ueCfg) BuildK0K1Table(ueCb->cellCb, &ueCb->ueCfg.spCellCfg.servCellCfg.initDlBwp.k0K1InfoTbl, false, pdschCfg,\ ueCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg, dlDataToUlAck->dlDataToUlAckListCount,\ dlDataToUlAck->dlDataToUlAckList); + ueCb->ueCfg.spCellCfg.servCellCfg.initDlBwp.k0K1TblPrsnt = true; BuildK2InfoTable(ueCb->cellCb, ueCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.timeDomRsrcAllocList,\ ueCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.numTimeDomRsrcAlloc,\ NULLP, &ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.k2InfoTbl); @@ -313,55 +297,130 @@ uint8_t fillSchUeCb(SchUeCb *ueCb, SchUeCfg *ueCfg) //Updating SchUlCb and SchDlCb DB in SchUeCb for(lcIdx = 0; lcIdx < ueCfg->numLcs; lcIdx++) { + isLcIdValid = FALSE; /*Re-Initializing*/ + + ueLcIdx = ueCfg->schLcCfg[lcIdx].lcId; + CHECK_LCID(ueLcIdx, isLcIdValid); + if(isLcIdValid == FALSE) + { + DU_LOG("ERROR --> SCH: LCID:%d is not Valid",ueLcIdx); + continue; + } if(ueCfg->schLcCfg[lcIdx].configType == CONFIG_ADD) { - fillSchUlLcCtxt(&ueCb->ulInfo.ulLcCtxt[ueCb->ulInfo.numUlLc], &ueCfg->schLcCfg[lcIdx]); - ueCb->ulInfo.numUlLc++; - fillSchDlLcCtxt(&ueCb->dlInfo.dlLcCtxt[ueCb->dlInfo.numDlLc], &ueCfg->schLcCfg[lcIdx]); - ueCb->dlInfo.numDlLc++; + fillSchUlLcCtxt(&ueCb->ulInfo.ulLcCtxt[ueLcIdx], &ueCfg->schLcCfg[lcIdx]); + fillSchDlLcCtxt(&ueCb->dlInfo.dlLcCtxt[ueLcIdx], &ueCfg->schLcCfg[lcIdx]); + + /*Checking whether this LC belong to Dedicated S-NSSAI + * and Create the Dedicated LC List & Update the Reserve PRB number*/ + if(ueCb->dlInfo.dlLcCtxt[ueLcIdx].snssai != NULLP) + { + retDL = updateDedLcInfo(ueCb->dlInfo.dlLcCtxt[ueLcIdx].snssai, \ + ueCb->cellCb->cellCfg.rrmPolicy, &(ueCb->dlLcPrbEst),\ + &(ueCb->dlInfo.dlLcCtxt[ueLcIdx].isDedicated)); + } + if(ueCb->ulInfo.ulLcCtxt[ueLcIdx].snssai != NULLP) + { + retUL = updateDedLcInfo(ueCb->ulInfo.ulLcCtxt[ueLcIdx].snssai, \ + ueCb->cellCb->cellCfg.rrmPolicy, &(ueCb->ulLcPrbEst),\ + &(ueCb->ulInfo.ulLcCtxt[ueLcIdx].isDedicated)); + } + + if(retUL == RFAILED || retDL == RFAILED)/*FATAL error*/ + { + DU_LOG("\nERROR --> SCH : Failure in updateDedLcInfo"); + return RFAILED; + } } else { - for(ueLcIdx = 0; ueLcIdx < ueCb->ulInfo.numUlLc; ueLcIdx++) //searching for Lc to be Mod + if(ueCb->ulInfo.ulLcCtxt[ueLcIdx].lcId == ueCfg->schLcCfg[lcIdx].lcId) { - if(ueCb->ulInfo.ulLcCtxt[ueLcIdx].lcId == ueCfg->schLcCfg[lcIdx].lcId) + if(ueCfg->schLcCfg[lcIdx].configType == CONFIG_MOD) { - if(ueCfg->schLcCfg[lcIdx].configType == CONFIG_MOD) + fillSchUlLcCtxt(&ueCb->ulInfo.ulLcCtxt[ueLcIdx], &ueCfg->schLcCfg[lcIdx]); + /*Updating the RRM reserved pool PRB count*/ + if(ueCb->ulInfo.ulLcCtxt[ueLcIdx].snssai != NULLP) { - fillSchUlLcCtxt(&ueCb->ulInfo.ulLcCtxt[ueLcIdx], &ueCfg->schLcCfg[lcIdx]); - break; + retUL = updateDedLcInfo(ueCb->ulInfo.ulLcCtxt[ueLcIdx].snssai, \ + ueCb->cellCb->cellCfg.rrmPolicy, &(ueCb->ulLcPrbEst),\ + &(ueCb->ulInfo.ulLcCtxt[ueLcIdx].isDedicated)); } - /*BUG: ueCfg using lcIdx (Looping around numLCs in ueCfg whereas - * ueLcIdx Loops around numUlLc in SCH UL DB*/ - if(ueCfg->schLcCfg[lcIdx].configType == CONFIG_DEL) + if(retUL == RFAILED) { - memset(&ueCb->ulInfo.ulLcCtxt[ueLcIdx], 0, sizeof(SchUlLcCtxt)); - ueCb->ulInfo.numUlLc--; - updateSchUlCb(ueLcIdx, &ueCb->ulInfo); //moving arr elements one idx ahead - - break; + DU_LOG("\nERROR --> SCH : Failed in updating Ded Lc info"); + return RFAILED; + } + } + if(ueCfg->schLcCfg[lcIdx].configType == CONFIG_DEL) + { + /*Delete the LC node from the UL LC List*/ + if(ueCb->ulInfo.ulLcCtxt[ueLcIdx].isDedicated) + { + if(ueCb->ulLcPrbEst.dedLcInfo != NULLP) + { + lcLL = &(ueCb->ulLcPrbEst.dedLcInfo->dedLcList); + handleLcLList(lcLL, ueCfg->schLcCfg[lcIdx].lcId, DELETE); + if(lcLL->count == 0)/*IF No Node in DedicateLCList to be deleted*/ + { + /*Free the Dedicated LC Info structure*/ + SCH_FREE(ueCb->ulLcPrbEst.dedLcInfo, sizeof(DedicatedLCInfo)); + } + } + } + else/*Default LC list*/ + { + lcLL = &(ueCb->ulLcPrbEst.defLcList); + handleLcLList(lcLL, ueCfg->schLcCfg[lcIdx].lcId, DELETE); } + SCH_FREE(ueCb->ulInfo.ulLcCtxt[ueLcIdx].snssai, sizeof(Snssai)); + memset(&ueCb->ulInfo.ulLcCtxt[ueLcIdx], 0, sizeof(SchUlLcCtxt)); } - }/*End of inner for loop */ + }/*End of UL LC Ctxt*/ - for(ueLcIdx = 0; ueLcIdx < ueCb->dlInfo.numDlLc; ueLcIdx++) //searching for Lc to be Mod + if(ueCb->dlInfo.dlLcCtxt[ueLcIdx].lcId == ueCfg->schLcCfg[lcIdx].lcId) { - if(ueCb->dlInfo.dlLcCtxt[ueLcIdx].lcId == ueCfg->schLcCfg[lcIdx].lcId) + if(ueCfg->schLcCfg[lcIdx].configType == CONFIG_MOD) { - if(ueCfg->schLcCfg[lcIdx].configType == CONFIG_MOD) + fillSchDlLcCtxt(&ueCb->dlInfo.dlLcCtxt[ueLcIdx], &ueCfg->schLcCfg[lcIdx]); + /*Updating the RRM policy*/ + if(ueCb->dlInfo.dlLcCtxt[ueLcIdx].snssai != NULLP) { - fillSchDlLcCtxt(&ueCb->dlInfo.dlLcCtxt[ueLcIdx], &ueCfg->schLcCfg[lcIdx]); - break; + retDL = updateDedLcInfo(ueCb->dlInfo.dlLcCtxt[ueLcIdx].snssai, \ + ueCb->cellCb->cellCfg.rrmPolicy, &(ueCb->dlLcPrbEst), \ + &(ueCb->dlInfo.dlLcCtxt[ueLcIdx].isDedicated)); } - if(ueCfg->schLcCfg[lcIdx].configType == CONFIG_DEL) + if(retDL == RFAILED) { - memset(&ueCb->dlInfo.dlLcCtxt[ueLcIdx], 0, sizeof(SchDlLcCtxt)); - ueCb->dlInfo.numDlLc--; - updateSchDlCb(ueLcIdx, &ueCb->dlInfo); //moving arr elements one idx ahead - break; + DU_LOG("\nERROR --> SCH : Failed in updating Ded Lc info"); + return RFAILED; } } - }/*End of inner for loop */ + if(ueCfg->schLcCfg[lcIdx].configType == CONFIG_DEL) + { + /*Delete the LC node from the DL LC List*/ + if(ueCb->dlInfo.dlLcCtxt[ueLcIdx].isDedicated) + { + if(ueCb->dlLcPrbEst.dedLcInfo != NULLP) + { + lcLL = &(ueCb->dlLcPrbEst.dedLcInfo->dedLcList); + handleLcLList(lcLL, ueCfg->schLcCfg[lcIdx].lcId, DELETE); + if(lcLL->count == 0)/*Last Node in DedicateLCList to be deleted*/ + { + /*Free the Dedicated LC Info structure*/ + SCH_FREE(ueCb->dlLcPrbEst.dedLcInfo, sizeof(DedicatedLCInfo)); + } + } + } + else + { + lcLL = &(ueCb->dlLcPrbEst.defLcList); + handleLcLList(lcLL, ueCfg->schLcCfg[lcIdx].lcId, DELETE); + } + SCH_FREE(ueCb->dlInfo.dlLcCtxt[ueLcIdx].snssai, sizeof(Snssai)); + memset(&ueCb->dlInfo.dlLcCtxt[ueLcIdx], 0, sizeof(SchDlLcCtxt)); + } + }/*End of DL LC ctxt*/ } SCH_FREE(ueCfg->schLcCfg[lcIdx].drbQos, sizeof(SchDrbQosInfo)); @@ -510,32 +569,30 @@ uint8_t MacSchAddUeConfigReq(Pst *pst, SchUeCfg *ueCfg) * RFAILED - failure * * ****************************************************************/ -uint8_t schFillPuschAlloc(SchUeCb *ueCb, uint16_t pdcchSlot, uint32_t dataVol, SchPuschInfo *puschInfo) +uint8_t schFillPuschAlloc(SchUeCb *ueCb, SlotTimingInfo pdcchSlotTime, uint32_t dataVol, SchPuschInfo *puschInfo) { - uint16_t puschSlot = 0; uint16_t startRb = 0; uint8_t numRb = 0; uint16_t tbSize = 0; uint8_t buffer = 5; - uint8_t idx = 0; + uint8_t k2=0, startSymb=0 , symbLen=0; SchCellCb *cellCb = ueCb->cellCb; SchUlSlotInfo *schUlSlotInfo = NULLP; - uint8_t k2=0, startSymb=0 , symbLen=11; + SlotTimingInfo puschTime; + /* TODO : Scheduler to decide on which slot PUSCH is to be scheduled based on K2 Index table */ if(ueCb->ueCfg.spCellCfgPres == true) { k2 = ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.puschCfg.timeDomRsrcAllocList[0].k2; startSymb = ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.puschCfg.timeDomRsrcAllocList[0].startSymbol; symbLen = ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.puschCfg.timeDomRsrcAllocList[0].symbolLength; } - puschSlot = (pdcchSlot + k2) % cellCb->numSlots; + ADD_DELTA_TO_TIME(pdcchSlotTime, puschTime, k2); - startRb = cellCb->schUlSlotInfo[puschSlot]->puschCurrentPrb; + startRb = MAX_NUM_RB; tbSize = schCalcTbSize(dataVol + buffer); /* 2 bytes header + some buffer */ numRb = schCalcNumPrb(tbSize, ueCb->ueCfg.ulModInfo.mcsIndex, symbLen); - /* increment PUSCH PRB */ - - cellCb->schUlSlotInfo[puschSlot]->puschCurrentPrb += numRb; + allocatePrbUl(cellCb, puschTime, startSymb, symbLen, &startRb, numRb); puschInfo->crnti = ueCb->crnti; puschInfo->harqProcId = SCH_HARQ_PROC_ID; @@ -554,14 +611,7 @@ uint8_t schFillPuschAlloc(SchUeCb *ueCb, uint16_t pdcchSlot, uint32_t dataVol, S puschInfo->nrOfDmrsSymbols = NUM_DMRS_SYMBOLS; puschInfo->dmrsAddPos = DMRS_ADDITIONAL_POS; - /* Update pusch in cell */ - for(idx=startSymb; idxschUlSlotInfo[puschSlot]->assignedPrb[idx] = startRb + numRb; - } - - schUlSlotInfo = cellCb->schUlSlotInfo[puschSlot]; - + schUlSlotInfo = cellCb->schUlSlotInfo[puschTime.slot]; SCH_ALLOC(schUlSlotInfo->schPuschInfo, sizeof(SchPuschInfo)); if(!schUlSlotInfo->schPuschInfo) { @@ -857,6 +907,7 @@ void deleteSchUeCb(SchUeCb *ueCb) uint8_t timeDomRsrcIdx = 0, ueLcIdx = 0; SchPucchCfg *pucchCfg = NULLP; SchPdschConfig *pdschCfg = NULLP; + CmLListCp *lcLL = NULLP; if(ueCb) { @@ -893,14 +944,32 @@ void deleteSchUeCb(SchUeCb *ueCb) deleteSchPdschServCellCfg(&ueCb->ueCfg.spCellCfg.servCellCfg.pdschServCellCfg); } /*Need to Free the memory allocated for S-NSSAI*/ - for(ueLcIdx = 0; ueLcIdx < ueCb->ulInfo.numUlLc; ueLcIdx++) + for(ueLcIdx = 0; ueLcIdx < MAX_NUM_LC; ueLcIdx++) { SCH_FREE(ueCb->ulInfo.ulLcCtxt[ueLcIdx].snssai, sizeof(Snssai)); + SCH_FREE(ueCb->dlInfo.dlLcCtxt[ueLcIdx].snssai, sizeof(Snssai)); } - for(ueLcIdx = 0; ueLcIdx < ueCb->dlInfo.numDlLc; ueLcIdx++) + + /*Clearing out Dedicated LC list*/ + if(ueCb->dlLcPrbEst.dedLcInfo != NULLP) { - SCH_FREE(ueCb->dlInfo.dlLcCtxt[ueLcIdx].snssai, sizeof(Snssai)); + lcLL = &(ueCb->dlLcPrbEst.dedLcInfo->dedLcList); + deleteLcLL(lcLL); + SCH_FREE(ueCb->dlLcPrbEst.dedLcInfo, sizeof(DedicatedLCInfo)); } + if(ueCb->ulLcPrbEst.dedLcInfo != NULLP) + { + lcLL = &(ueCb->ulLcPrbEst.dedLcInfo->dedLcList); + deleteLcLL(lcLL); + SCH_FREE(ueCb->ulLcPrbEst.dedLcInfo, sizeof(DedicatedLCInfo)); + } + /*Deleteing the Default LC list*/ + lcLL = &(ueCb->dlLcPrbEst.defLcList); + deleteLcLL(lcLL); + + lcLL = &(ueCb->ulLcPrbEst.defLcList); + deleteLcLL(lcLL); + memset(ueCb, 0, sizeof(SchUeCb)); } } @@ -922,10 +991,11 @@ void deleteSchUeCb(SchUeCb *ueCb) * ****************************************************************/ uint8_t MacSchUeDeleteReq(Pst *pst, SchUeDelete *ueDelete) { - uint8_t idx=0, ueIdx=0, ret=ROK; - ErrorCause result; + uint8_t idx=0, ueId=0, ueIdToDel=0, ret=ROK; + ErrorCause result; SchCellCb *cellCb = NULLP; Inst inst = pst->dstInst - 1; + CmLList *node = NULL, *next = NULL; #ifdef CALL_FLOW_DEBUG_LOG DU_LOG("\nCall Flow: ENTMAC -> ENTSCH : EVENT_UE_DELETE_REQ_TO_SCH\n"); @@ -947,10 +1017,25 @@ uint8_t MacSchUeDeleteReq(Pst *pst, SchUeDelete *ueDelete) } else { - GET_UE_IDX(ueDelete->crnti, ueIdx); - if(( cellCb->ueCb[ueIdx-1].crnti == ueDelete->crnti) && ( cellCb->ueCb[ueIdx-1].state == SCH_UE_STATE_ACTIVE)) + GET_UE_IDX(ueDelete->crnti, ueId); + if(( cellCb->ueCb[ueId-1].crnti == ueDelete->crnti) && ( cellCb->ueCb[ueId-1].state == SCH_UE_STATE_ACTIVE)) { - deleteSchUeCb(&cellCb->ueCb[ueIdx-1]); + deleteSchUeCb(&cellCb->ueCb[ueId-1]); + + /* Remove UE from ueToBeScheduled list */ + node = cellCb->ueToBeScheduled.first; + while(node) + { + next = node->next; + ueId = *(uint8_t *)node->node; + if(ueId == ueIdToDel) + { + SCH_FREE(node->node, sizeof(uint8_t)); + cmLListDelFrm(&cellCb->ueToBeScheduled, node); + break; + } + node = next; + } cellCb->numActvUe--; result = NOT_APPLICABLE; } @@ -1031,18 +1116,40 @@ uint8_t SchSendCellDeleteRspToMac(SchCellDelete *ueDelete, Inst inst, SchMacRsp void deleteSchCellCb(SchCellCb *cellCb) { uint8_t sliceIdx=0, slotIdx=0; + CmLListCp *list=NULL; + CmLList *node=NULL, *next=NULL; + if(cellCb->schDlSlotInfo) { for(slotIdx=0; slotIdxnumSlots; slotIdx++) { + list = &cellCb->schDlSlotInfo[slotIdx]->prbAlloc.freePrbBlockList; + node = list->first; + while(node) + { + next = node->next; + SCH_FREE(node->node, sizeof(FreePrbBlock)); + deleteNodeFromLList(list, node); + node = next; + } SCH_FREE(cellCb->schDlSlotInfo[slotIdx], sizeof(SchDlSlotInfo)); } SCH_FREE(cellCb->schDlSlotInfo, cellCb->numSlots *sizeof(SchDlSlotInfo*)); } + if(cellCb->schUlSlotInfo) { for(slotIdx=0; slotIdxnumSlots; slotIdx++) { + list = &cellCb->schUlSlotInfo[slotIdx]->prbAlloc.freePrbBlockList; + node = list->first; + while(node) + { + next = node->next; + SCH_FREE(node->node, sizeof(FreePrbBlock)); + deleteNodeFromLList(list, node); + node = next; + } SCH_FREE(cellCb->schUlSlotInfo[slotIdx], sizeof(SchUlSlotInfo)); } SCH_FREE(cellCb->schUlSlotInfo, cellCb->numSlots * sizeof(SchUlSlotInfo*)); @@ -1057,6 +1164,17 @@ void deleteSchCellCb(SchCellCb *cellCb) SCH_FREE(cellCb->cellCfg.snssai, cellCb->cellCfg.numSliceSupport*sizeof(Snssai*)); } SCH_FREE(cellCb->cellCfg.rrmPolicy, sizeof(SchRrmPolicy)); + + /* Remove all UE from ueToBeScheduled list and deallocate */ + node = cellCb->ueToBeScheduled.first; + while(node) + { + next = node->next; + SCH_FREE(node->node, sizeof(uint8_t)); + cmLListDelFrm(&cellCb->ueToBeScheduled, node); + node = next; + } + memset(cellCb, 0, sizeof(SchCellCb)); }