[Epic-ID: ODUHIGH-406][Task-ID: ODUHIGH-423]Filled ReconfigurationWithSync IE,
[o-du/l2.git] / src / 5gnrmac / mac_ue_mgr.c
index a201e52..4206acd 100644 (file)
@@ -1616,7 +1616,7 @@ uint8_t fillSchUeCfg(Pst *pst, SchUeCfg *schUeCfg, MacUeCfg *ueCfg)
    uint8_t ret = ROK;
 
    schUeCfg->cellId = ueCfg->cellId;
-   schUeCfg->duUeF1apId = ueCfg->duUeF1apId;
+   schUeCfg->ueId = ueCfg->ueId;
    schUeCfg->crnti = ueCfg->crnti;
    schUeCfg->dataTransmissionInfo = ueCfg->transmissionAction;
    /* Copy MAC cell group config */
@@ -1995,11 +1995,6 @@ uint8_t fillMacUeCb(MacUeCb *ueCb, MacUeCfg *ueCfg, uint8_t cellIdx)
       ueCfg->spCellCfg.servCellCfg.pdschServCellCfg.numHarqProcForPdsch; 
    }
 
-   if(ueCfg->crnti)
-      ueCb->state = UE_STATE_ACTIVE;
-   else
-      ueCb->state = UE_HANDIN_IN_PROGRESS;
-
    /*TODO: To check the bsr value during implementation */
    if(ueCfg->macCellGrpCfgPres)
    {
@@ -2034,15 +2029,15 @@ uint8_t fillMacUeCb(MacUeCb *ueCb, MacUeCfg *ueCfg, uint8_t cellIdx)
 
 uint8_t updateMacRaCb(uint16_t cellIdx, MacUeCb *ueCb)
 {
-   uint8_t ueIdx;
    /* Copy RA Cb */
-   for(ueIdx = 0; ueIdx < MAX_NUM_UE; ueIdx++)
+   if(macCb.macCell[cellIdx]->macRaCb[ueCb->ueId-1].crnti == ueCb->crnti)
    {
-      if(macCb.macCell[cellIdx]->macRaCb[ueIdx].crnti == ueCb->crnti)
-      {
-         ueCb->raCb = &macCb.macCell[cellIdx]->macRaCb[ueIdx];
-         break;
-      }
+      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;
 }
@@ -2123,16 +2118,21 @@ uint8_t createUeCb(uint8_t cellIdx, MacUeCb *ueCb, MacUeCfg *ueCfg)
       }
       else
       {
-         if(ueCb->state == UE_STATE_ACTIVE)
+         /* 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;
 }
 
 /*******************************************************************
@@ -2214,10 +2214,7 @@ uint8_t procMacUeCfgData(Pst *pst, MacUeCfg *ueCfg)
    }
 
    /* Check if UE already configured */
-   if(ueCfg->crnti)
-      ueCb = &macCb.macCell[cellIdx]->ueCb[ueCfg->ueId -1];
-   else
-      ueCb = &macCb.macCell[cellIdx]->hoUeCb[ueCfg->duUeF1apId -1];
+   ueCb = &macCb.macCell[cellIdx]->ueCb[ueCfg->ueId -1];
 
    switch(pst->event)
    {
@@ -2273,7 +2270,7 @@ uint8_t copyToTmpData(MacUeCfg *ueCfg)
    }
    memcpy(tmpData, ueCfg, sizeof(MacUeCfg));
    GET_CELL_IDX(ueCfg->cellId, cellIdx);
-   macCb.macCell[cellIdx]->ueCfgTmpData[ueCfg->duUeF1apId-1] = tmpData;
+   macCb.macCell[cellIdx]->ueCfgTmpData[ueCfg->ueId-1] = tmpData;
    return ROK;
 }
 
@@ -2302,6 +2299,13 @@ uint8_t MacProcUeCreateReq(Pst *pst, MacUeCfg *ueCfg)
 
    if(ueCfg)
    {
+      /* If CRNTI = 0, MAC must allot a CRNTI to this UE. This scenario hits in
+       * case of UE in handover */
+      if(ueCfg->crnti == 0)
+      {
+         GET_CRNTI(ueCfg->crnti, ueCfg->ueId);
+      }
+
       /*Storing received ueCfg in ueCfgTmpData */
       ret = copyToTmpData(ueCfg);
       if(ret == ROK)
@@ -2365,7 +2369,7 @@ uint8_t MacSendUeCreateRsp(MacRsp result, SchUeCfgRsp *schCfgRsp)
    /* Filling UE Config response */
    memset(cfgRsp, 0, sizeof(MacUeCfgRsp));
    cfgRsp->cellId = schCfgRsp->cellId;
-   cfgRsp->duUeF1apId = schCfgRsp->duUeF1apId;
+   cfgRsp->ueId = schCfgRsp->ueId;
    cfgRsp->result = result;
 
    /* Fill Post structure and send UE Create response*/
@@ -2405,7 +2409,7 @@ uint8_t MacSendUeReconfigRsp(MacRsp result, SchUeCfgRsp *schCfgRsp)
    /* Filling UE Config response */
    memset(cfgRsp, 0, sizeof(MacUeCfgRsp));
    cfgRsp->cellId = schCfgRsp->cellId;
-   cfgRsp->duUeF1apId = schCfgRsp->duUeF1apId;
+   cfgRsp->ueId = schCfgRsp->ueId;
    cfgRsp->result = result;
 
    /* Fill Post structure and send UE Create response*/
@@ -2432,12 +2436,12 @@ uint8_t MacSendUeReconfigRsp(MacRsp result, SchUeCfgRsp *schCfgRsp)
  *
  * ****************************************************************/
 
-MacUeCfg *getMacUeCfg(uint16_t cellIdx, uint8_t duUeF1apId)
+MacUeCfg *getMacUeCfg(uint16_t cellIdx, uint8_t ueId)
 {
    MacUeCfg *ueCfg = NULLP;
    if(macCb.macCell[cellIdx])
    {
-      ueCfg = macCb.macCell[cellIdx]->ueCfgTmpData[duUeF1apId-1];
+      ueCfg = macCb.macCell[cellIdx]->ueCfgTmpData[ueId-1];
    }
    else
    {
@@ -2487,7 +2491,7 @@ uint8_t MacProcSchUeCfgRsp(Pst *pst, SchUeCfgRsp *schCfgRsp)
 #endif
    
    GET_CELL_IDX(schCfgRsp->cellId, cellIdx);
-   ueCfg = getMacUeCfg(cellIdx, schCfgRsp->duUeF1apId);
+   ueCfg = getMacUeCfg(cellIdx, schCfgRsp->ueId);
    if(ueCfg == NULLP)
    {
       DU_LOG("\nERROR  -->  MAC : Failed to find the Mac Ue Cfg for event [%d] in MacProcSchUeCfgRsp()", pst->event);