[Epic-ID: ODUHIGH-406][Task-ID: ODUHIGH-423]UE context creation at RLC in Target...
[o-du/l2.git] / src / 5gnrsch / sch_ue_mgr.c
index 9008dff..85c1663 100644 (file)
@@ -72,8 +72,8 @@ void SchSendUeCfgRspToMac(uint16_t event, SchUeCfg *ueCfg, Inst inst,\
    Pst rspPst;
 
    cfgRsp->cellId = ueCfg->cellId;
+   cfgRsp->ueId = ueCfg->ueId;
    cfgRsp->crnti = ueCfg->crnti;
-   GET_UE_ID(ueCfg->crnti, cfgRsp->ueId);
    cfgRsp->rsp = result;   
 
    /* Filling response post */
@@ -259,7 +259,9 @@ uint8_t fillSchUeCb(Inst inst, SchUeCb *ueCb, SchUeCfg *ueCfg)
    bool isLcIdValid = FALSE;
 
    ueCb->ueCfg.cellId = ueCfg->cellId;
+   ueCb->ueCfg.ueId = ueCfg->ueId;
    ueCb->ueCfg.crnti = ueCfg->crnti;
+   ueCb->ueCfg.dataTransmissionAction = ueCfg->dataTransmissionInfo;
    if(ueCfg->macCellGrpCfgPres == true)
    {
       memcpy(&ueCb->ueCfg.macCellGrpCfg , &ueCfg->macCellGrpCfg, sizeof(SchMacCellGrpCfg)); 
@@ -299,7 +301,6 @@ uint8_t fillSchUeCb(Inst inst, SchUeCb *ueCb, SchUeCfg *ueCfg)
       }
    }
 
-   ueCb->state = SCH_UE_STATE_ACTIVE;
    if(ueCfg->ambrCfg)
    {
       SCH_FREE(ueCb->ueCfg.ambrCfg, sizeof(SchAmbrCfg));
@@ -505,7 +506,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;
@@ -525,34 +526,36 @@ uint8_t MacSchAddUeConfigReq(Pst *pst, SchUeCfg *ueCfg)
    cellCb = getSchCellCb(pst->event, inst, ueCfg);
 
    /* Search if UE already configured */
-   GET_UE_ID(ueCfg->crnti, ueId);
-   ueCb = &cellCb->ueCb[ueId -1];
-   if(ueCb)
-   {
-      if((ueCb->crnti == ueCfg->crnti) && (ueCb->state == SCH_UE_STATE_ACTIVE))
-      {
-         DU_LOG("\nDEBUG  -->  SCH : CRNTI %d already configured ", ueCfg->crnti);
-         SchSendUeCfgRspToMac(pst->event, ueCfg, inst, RSP_OK, &cfgRsp);
-         return ROK;
-      }
-   }
-   else
+   ueCb = &cellCb->ueCb[ueCfg->ueId - 1];
+
+   if((ueCb->crnti == ueCfg->crnti) && (ueCb->state == SCH_UE_STATE_ACTIVE))
    {
-      DU_LOG("\nERROR  -->  SCH : SchUeCb not found at MacSchAddUeConfigReq() ");
-      SchSendUeCfgRspToMac(pst->event, ueCfg, inst, RSP_NOK, &cfgRsp);
-      return RFAILED;
+      DU_LOG("\nDEBUG  -->  SCH : CRNTI %d already configured ", ueCfg->crnti);
+      SchSendUeCfgRspToMac(pst->event, ueCfg, inst, RSP_OK, &cfgRsp);
+      return ROK;
    }
 
    /* Fill received Ue Configuration in UeCb */
    memset(ueCb, 0, sizeof(SchUeCb));
-   ueCb->ueId = ueId;
+   ueCb->ueId = ueCfg->ueId;
    ueCb->crnti = ueCfg->crnti;
-   ueCb->state = SCH_UE_STATE_ACTIVE;
+
    ret = fillSchUeCb(inst, ueCb, ueCfg);
    if(ret == ROK)
    {
-      cellCb->numActvUe++;
-      SET_ONE_BIT(ueCb->ueId, cellCb->actvUeBitMap);
+      /* 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;