[Epic-ID: ODUHIGH-406][Task-ID: ODUHIGH-450] PAGING memory fixes
[o-du/l2.git] / src / 5gnrsch / sch_ue_mgr.c
index fa4ce2e..3db4b1c 100644 (file)
@@ -72,7 +72,7 @@ void SchSendUeCfgRspToMac(uint16_t event, SchUeCfg *ueCfg, Inst inst,\
    Pst rspPst;
 
    cfgRsp->cellId = ueCfg->cellId;
-   cfgRsp->duUeF1apId = ueCfg->duUeF1apId;
+   cfgRsp->ueId = ueCfg->ueId;
    cfgRsp->crnti = ueCfg->crnti;
    cfgRsp->rsp = result;   
 
@@ -259,7 +259,7 @@ uint8_t fillSchUeCb(Inst inst, SchUeCb *ueCb, SchUeCfg *ueCfg)
    bool isLcIdValid = FALSE;
 
    ueCb->ueCfg.cellId = ueCfg->cellId;
-   ueCb->ueCfg.duUeF1apId = ueCfg->duUeF1apId;
+   ueCb->ueCfg.ueId = ueCfg->ueId;
    ueCb->ueCfg.crnti = ueCfg->crnti;
    ueCb->ueCfg.dataTransmissionAction = ueCfg->dataTransmissionInfo;
    if(ueCfg->macCellGrpCfgPres == true)
@@ -276,6 +276,19 @@ uint8_t fillSchUeCb(Inst inst, SchUeCb *ueCb, SchUeCfg *ueCfg)
 
    if(ueCfg->spCellCfgPres == true)
    {
+      if(ueCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfgPres == true)
+      {
+         if(ueCb->ueCfg.spCellCfgPres && ueCb->ueCfg.spCellCfg.servCellCfg.initDlBwp.pdschCfgPres == true)
+         {
+            for(uint8_t idx = 0; idx < ueCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg.numTimeDomRsrcAlloc; idx++)
+            {
+               if(ueCb->ueCfg.spCellCfg.servCellCfg.initDlBwp.pdschCfg.timeDomRsrcAllociList[idx].k0 && ueCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg.timeDomRsrcAllociList[idx].k0)
+               {
+                   SCH_FREE(ueCb->ueCfg.spCellCfg.servCellCfg.initDlBwp.pdschCfg.timeDomRsrcAllociList[idx].k0, sizeof(uint8_t));  
+               }
+            }
+         }
+      }
       memcpy(&ueCb->ueCfg.spCellCfg , &ueCfg->spCellCfg, sizeof(SchSpCellCfg));
 
       covertFreqDomRsrcMapToIAPIFormat(ueCb->ueCfg.spCellCfg.servCellCfg.initDlBwp.pdcchCfg.cRSetToAddModList[0].freqDomainRsrc,\
@@ -506,7 +519,7 @@ SchCellCb *getSchCellCb(uint16_t srcEvent, Inst inst, SchUeCfg *ueCfg)
  * ****************************************************************/
 uint8_t MacSchAddUeConfigReq(Pst *pst, SchUeCfg *ueCfg)
 {
-   uint8_t ueId, lcIdx, ret = ROK;
+   uint8_t      lcIdx = 0, ret = ROK;
    SchCellCb    *cellCb = NULLP;
    SchUeCb      *ueCb = NULLP;
    SchUeCfgRsp  cfgRsp;
@@ -526,13 +539,7 @@ uint8_t MacSchAddUeConfigReq(Pst *pst, SchUeCfg *ueCfg)
    cellCb = getSchCellCb(pst->event, inst, ueCfg);
 
    /* Search if UE already configured */
-   if(ueCfg->crnti)
-   {
-      GET_UE_ID(ueCfg->crnti, ueId);
-      ueCb = &cellCb->ueCb[ueId -1];
-   }
-   else
-      ueCb = &cellCb->hoUeCb[ueCfg->duUeF1apId - 1];
+   ueCb = &cellCb->ueCb[ueCfg->ueId - 1];
 
    if((ueCb->crnti == ueCfg->crnti) && (ueCb->state == SCH_UE_STATE_ACTIVE))
    {
@@ -543,21 +550,27 @@ uint8_t MacSchAddUeConfigReq(Pst *pst, SchUeCfg *ueCfg)
 
    /* Fill received Ue Configuration in UeCb */
    memset(ueCb, 0, sizeof(SchUeCb));
-   ueCb->ueId = ueId;
+   ueCb->ueId = ueCfg->ueId;
    ueCb->crnti = ueCfg->crnti;
-   if(ueCb->crnti)
-      ueCb->state = SCH_UE_STATE_ACTIVE;
-   else
-      ueCb->state = SCH_UE_HANDIN_IN_PROGRESS;
 
    ret = fillSchUeCb(inst, ueCb, ueCfg);
    if(ret == ROK)
    {
-      if(ueCb->state == SCH_UE_STATE_ACTIVE)
+      /* If UE has initiated RACH and then UE context is created, it means UE is
+       * active now.
+       * Else if UE context is created before RACH, this means that UE is being
+       * handed-in from source DU */
+      if(cellCb->raCb[ueCb->ueId-1].tcrnti == ueCb->crnti)
       {
          cellCb->numActvUe++;
          SET_ONE_BIT(ueCb->ueId, cellCb->actvUeBitMap);
+         ueCb->state = SCH_UE_STATE_ACTIVE;
+      }
+      else
+      {
+         ueCb->state = SCH_UE_HANDIN_IN_PROGRESS;
       }
+
       ueCb->cellCb = cellCb;
       ueCb->srRcvd = false;
       ueCb->bsrRcvd = false;
@@ -1134,6 +1147,7 @@ void deleteSchCellCb(SchCellCb *cellCb)
    uint8_t sliceIdx=0, slotIdx=0;
    CmLListCp *list=NULL;
    CmLList *node=NULL, *next=NULL;
+   SchPageInfo *tempNode = NULLP;
 
    if(cellCb->schDlSlotInfo)
    {
@@ -1179,6 +1193,24 @@ void deleteSchCellCb(SchCellCb *cellCb)
       }
       SCH_FREE(cellCb->cellCfg.plmnInfoList.snssai, cellCb->cellCfg.plmnInfoList.numSliceSupport*sizeof(Snssai*));
    }
+   
+   for(uint16_t idx =0; idx<MAX_SFN; idx++)
+   {
+      list = &cellCb->pageCb.pageIndInfoRecord[idx];
+      node = list->first;
+      while(node)
+      {
+         next = node->next;
+         if(node->node)
+         {
+            tempNode = (SchPageInfo*)(node->node);
+            SCH_FREE(tempNode->pagePdu, tempNode->msgLen);
+            SCH_FREE(node->node,  sizeof(SchPageInfo));
+         }
+         deleteNodeFromLList(list, node);
+         node = next;
+      }
+   }
 
    /* Remove all UE from ueToBeScheduled list and deallocate */
    node = cellCb->ueToBeScheduled.first;