[Epic-ID: ODUHIGH-405][Task-ID: ODUHIGH-448]RACH resource release at target DU and...
[o-du/l2.git] / src / du_app / du_msg_hdl.c
index 4161082..c7c9bc3 100644 (file)
@@ -58,7 +58,6 @@ DuCfgParams duCfgParam;
 uint8_t packRlcConfigReq(Pst *pst, RlcMngmt *cfg);
 uint8_t cmPkLkwCntrlReq(Pst *pst, RlcMngmt *cfg);
 uint8_t cmPkLrgCfgReq(Pst *pst, RgMngmt *cfg);
-uint8_t BuildAndSendE2SetupReq();
 uint8_t egtpHdlDatInd(EgtpMsg egtpMsg);
 uint8_t BuildAndSendDUConfigUpdate();
 uint16_t getTransId();
@@ -345,7 +344,6 @@ uint8_t duBuildRlcUsapCfg(uint8_t elemId, Ent ent, Inst inst)
 uint8_t duProcCfgComplete()
 {
    uint8_t         ret = ROK;
-   uint16_t        cellId = 0;
    uint16_t        idx;
    for(idx=0; idx< DEFAULT_CELLS; idx++)
    {
@@ -360,7 +358,7 @@ uint8_t duProcCfgComplete()
       {
          uint8_t idx1=0; 
          memset(cell, 0, sizeof(DuCellCb));
-         cell->cellId = ++cellId;
+         cell->cellId = NR_CELL_ID; //++cellId;
          memset(&cell->cellInfo.nrEcgi.plmn, 0, sizeof(Plmn));
          cell->cellInfo.nrEcgi.plmn.mcc[0] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mcc[0];
          cell->cellInfo.nrEcgi.plmn.mcc[1] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mcc[1];
@@ -384,7 +382,6 @@ uint8_t duProcCfgComplete()
          cell->cellInfo.maxUe = duCfgParam.maxUe;
          cell->cellStatus = CELL_OUT_OF_SERVICE;
          gCellStatus = CELL_DOWN;
-         cell->gnbDuUeF1apIdGenerator = 0;
          duCb.cfgCellLst[duCb.numCfgCells] = cell;
          duCb.numCfgCells++;
       }
@@ -981,15 +978,12 @@ uint8_t duSctpNtfyHdl(Buffer *mBuf, CmInetSctpNotification *ntfy)
    {
       if(BuildAndSendF1SetupReq() != ROK)
       {
-        return RFAILED;
+         return RFAILED;
       }
    }
    else if(ricParams.assocId == ntfy->u.assocChange.assocId)
    {
-      if(BuildAndSendE2SetupReq() != ROK)
-      {
-        return RFAILED;
-      }
+       return ROK;
    }
    else
    {
@@ -1455,7 +1449,13 @@ uint8_t duBuildAndSendMacCellCfg(uint16_t cellId)
    }
 
    /* store the address in the duCellCb so that we can free on confirm msg */
-   duCb.actvCellLst[cellId-1]->duMacCellCfg = duMacCellCfg;
+   if(duCb.actvCellLst[cellId-1])
+      duCb.actvCellLst[cellId-1]->duMacCellCfg = duMacCellCfg;
+   else
+   {
+      DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, duMacCellCfg, sizeof(MacCellCfg));
+      return RFAILED;
+   }
 
    /* copy the mac config structure from duCfgParams */
    memcpy(duMacCellCfg,&duCfgParam.macCellCfg,sizeof(MacCellCfg));
@@ -1489,7 +1489,7 @@ uint8_t  duHandleMacCellCfgCfm(Pst *pst, MacCellCfgCfm *macCellCfgCfm)
 
    for(actvCellIdx = 0; actvCellIdx < MAX_NUM_CELL; actvCellIdx++)
    {
-      if(macCellCfgCfm->cellId == duCb.actvCellLst[actvCellIdx]->cellId)
+      if((duCb.actvCellLst[actvCellIdx]) && (macCellCfgCfm->cellId == duCb.actvCellLst[actvCellIdx]->cellId))
       {
          duCb.actvCellLst[actvCellIdx]->duMacCellCfg = NULLP;
       }
@@ -1544,16 +1544,16 @@ uint8_t duBuildAndSendMacCellStart()
       return RFAILED;
    }
 
-   for(uint8_t id = 0; id < duCb.numActvCells; id++) 
+   for(uint8_t id = 0; id < MAX_NUM_CELL; id++) 
    {
       if(duCb.actvCellLst[id])
       {
-        cellId->cellId = duCb.actvCellLst[id]->cellId;
+         cellId->cellId = duCb.actvCellLst[id]->cellId;
 
-        /* Fill Pst */
-        FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_CELL_START);
+         /* Fill Pst */
+         FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_CELL_START);
 
-        return (*packMacCellStartOpts[pst.selector])(&pst, cellId);
+         return (*packMacCellStartOpts[pst.selector])(&pst, cellId);
       }
    }
    return ROK;
@@ -1707,23 +1707,63 @@ uint8_t duHandleUlCcchInd(Pst *pst, UlCcchIndInfo *ulCcchIndInfo)
  * ****************************************************************/
 uint8_t DuProcRlcUlRrcMsgTrans(Pst *pst, RlcUlRrcMsgInfo *ulRrcMsgInfo)
 {
+   uint8_t  ret = ROK;
    DuCellCb *cellCb = NULLP;
-   DuUeCb   ueCb ={0};
+   DuUeCb   *ueCb = NULLP;
   
-   if(duGetCellCb(ulRrcMsgInfo->cellId, &cellCb) != ROK)
-      return RFAILED;
-   if(ulRrcMsgInfo->ueIdx > 0)
+   duGetCellCb(ulRrcMsgInfo->cellId, &cellCb);
+   if(cellCb)
    {
-   ueCb = cellCb->ueCb[ulRrcMsgInfo->ueIdx -1];
+      if(ulRrcMsgInfo->ueId > 0)
+      {
+         if(cellCb->ueCb[ulRrcMsgInfo->ueId -1].gnbDuUeF1apId == ulRrcMsgInfo->ueId)
+            ueCb = &cellCb->ueCb[ulRrcMsgInfo->ueId -1];
 
+         if(ueCb)
+         {
+            /* If UL message is received for a UE in handover, it signifies that UE is now
+             * attached to GNB. Hence marking this UE as active and requesting MAC to 
+             * release the dedicated RACH resources */
+            if(ueCb->ueState == UE_HANDIN_IN_PROGRESS)
+            {
+               ueCb->ueState = UE_ACTIVE;
+               cellCb->numActvUes++;
+
+               /* Release RACH resources */
+               memset(&ueCb->cfraResource, 0, sizeof(MacCfraResource));
+               if(duBuildAndSendRachRsrcRelToMac(ulRrcMsgInfo->cellId, ueCb) != ROK)
+               {
+                  DU_LOG("\nERROR  -->  DU_APP : DuProcRlcUlRrcMsgTrans() : Failed to send RACH resource release to MAC");
+               }
+            }
 
-   BuildAndSendULRRCMessageTransfer(ueCb, ulRrcMsgInfo->lcId, ulRrcMsgInfo->msgLen, \
-      ulRrcMsgInfo->rrcMsg);
+            if(BuildAndSendULRRCMessageTransfer(ueCb, ulRrcMsgInfo->lcId, ulRrcMsgInfo->msgLen, ulRrcMsgInfo->rrcMsg) != ROK)
+            {
+               DU_LOG("\nERROR  -->  DU_APP : DuProcRlcUlRrcMsgTrans() : Failed to build and send UL RRC Message Transfer");
+               ret = RFAILED;
+            }
+         }
+         else
+         {
+            DU_LOG("\nERROR  -->  DU_APP : DuProcRlcUlRrcMsgTrans() : UE ID [%d] not found", ulRrcMsgInfo->ueId);
+            ret = RFAILED;
+         }
+      }
+      else
+      {
+         DU_LOG("\nERROR  -->  DU_APP : DuProcRlcUlRrcMsgTrans() : Invalid UE ID [%d]", ulRrcMsgInfo->ueId);
+         ret = RFAILED;
+      }
+   }
+   else
+   {
+      DU_LOG("\nERROR  -->  DU_APP : DuProcRlcUlRrcMsgTrans() : Cell ID [%d] not found", ulRrcMsgInfo->cellId);
+      ret = RFAILED;
+   }
 
    DU_FREE_SHRABL_BUF(pst->region, pst->pool, ulRrcMsgInfo->rrcMsg, ulRrcMsgInfo->msgLen);
    DU_FREE_SHRABL_BUF(pst->region, pst->pool, ulRrcMsgInfo, sizeof(RlcUlRrcMsgInfo));
-   }
-   return ROK;
+   return ret;
 }
 
 /*******************************************************************
@@ -1751,7 +1791,7 @@ uint8_t DuProcRlcRrcDeliveryReport(Pst *pst, RrcDeliveryReport *rrcDeliveryRepor
    if(duGetCellCb(rrcDeliveryReport->cellId, &cellCb) != ROK)
       return RFAILED;
    
-   ueCb = cellCb->ueCb[rrcDeliveryReport->ueIdx -1];
+   ueCb = cellCb->ueCb[rrcDeliveryReport->ueId -1];
    ret = BuildAndSendRrcDeliveryReport(ueCb.gnbCuUeF1apId, ueCb.gnbDuUeF1apId,rrcDeliveryReport);
 
    DU_FREE_SHRABL_BUF(pst->region, pst->pool, rrcDeliveryReport, sizeof(RrcDeliveryReport));
@@ -1793,7 +1833,7 @@ uint8_t DuProcRlcUlUserDataTrans(Pst *pst, RlcUlUserDatInfo *ulUserData)
    for(teIdx = 0; teIdx < duCb.numTeId; teIdx++)
    {
       /*TODO: If multiple Cell Support is enables then CellId also needs to be validated alongwith ueId and DrbId*/
-      if((duCb.upTnlCfg[teIdx] != NULLP) && (duCb.upTnlCfg[teIdx]->ueIdx == ulUserData->ueIdx) && \
+      if((duCb.upTnlCfg[teIdx] != NULLP) && (duCb.upTnlCfg[teIdx]->ueId == ulUserData->ueId) && \
          (duCb.upTnlCfg[teIdx]->drbId == ulUserData->rbId))
       {
          if(duCb.upTnlCfg[teIdx]->tnlCfg1)
@@ -1893,7 +1933,6 @@ void duFreeSliceCfgRsp(Pst *pst,  MacSliceCfgRsp *cfgRsp)
       }
       DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(MacSliceCfgRsp)); 
    }
-   return ROK;
 }
 
 /*******************************************************************
@@ -1927,7 +1966,7 @@ uint8_t DuProcMacSliceCfgRsp(Pst *pst,  MacSliceCfgRsp *cfgRsp)
                     duCb.sliceState = SLICE_CONFIGURED;
                 }
             }
-            DU_LOG("\nINFO  -->  DU_APP : Slice Configuration is done sucessfully ");
+            DU_LOG("\nINFO  -->  DU_APP : Slice Configuration is done successfully ");
         }
         duFreeSliceCfgRsp(pst, cfgRsp);
     }
@@ -2113,8 +2152,8 @@ uint8_t BuildAndSendSliceReCfgReq(RrmPolicy *rrmPolicy[], uint8_t totalRrmPolicy
  **********************************************************************/
 uint8_t DuProcMacSliceReCfgRsp(Pst *pst,  MacSliceCfgRsp *reCfgRsp)
 {
-   uint8_t cfgIdx = 0, sliceIdx =0;
-   
+   uint8_t cfgIdx = 0;
+
    if(reCfgRsp)
    {
       if(reCfgRsp->listOfSliceCfgRsp)
@@ -2169,8 +2208,9 @@ uint8_t DuProcRlcSliceMetrics(Pst *pst, SlicePmList *sliceStats)
     
     for(sliceRecord = 0; sliceRecord < sliceStats->numSlice; sliceRecord++)
     {
-       DU_LOG("\nINFO   -->  DU_APP: SliceIndx:%d, DlTput %.5lf, UlTput:%.5lf", sliceStats->sliceRecord[sliceRecord].networkSliceIdentifier,\
-                        sliceStats->sliceRecord[sliceRecord].ThpDl, sliceStats->sliceRecord[sliceRecord].ThpUl);
+       DU_LOG("\nINFO   -->  DU_APP: SliceId[SST-SD]:%d-%d, DlTput %.5lf, UlTput:%.5lf", sliceStats->sliceRecord[sliceRecord].networkSliceIdentifier.sst,\
+                        sliceStats->sliceRecord[sliceRecord].networkSliceIdentifier.sd,sliceStats->sliceRecord[sliceRecord].ThpDl,\
+                        sliceStats->sliceRecord[sliceRecord].ThpUl);
     }
 #ifdef O1_ENABLE
     if(sliceStats)