[Epic-ID: ODUHIGH-405][Task-ID: ODUHIGH-425] Changes in Ue Context Modification
[o-du/l2.git] / src / 5gnrsch / sch_ue_mgr.c
index e3e01a5..fa4ce2e 100644 (file)
@@ -72,8 +72,8 @@ void SchSendUeCfgRspToMac(uint16_t event, SchUeCfg *ueCfg, Inst inst,\
    Pst rspPst;
 
    cfgRsp->cellId = ueCfg->cellId;
+   cfgRsp->duUeF1apId = ueCfg->duUeF1apId;
    cfgRsp->crnti = ueCfg->crnti;
-   GET_UE_IDX(ueCfg->crnti, cfgRsp->ueIdx);
    cfgRsp->rsp = result;   
 
    /* Filling response post */
@@ -180,7 +180,8 @@ void fillSchUlLcCtxt(SchUlLcCtxt *ueCbLcCfg, SchLcCfg *lcCfg)
  *
  *    Functionality: Function to fill DLDedLcInfo
  *
- * @params[arg] snssai pointer,
+ * @params[arg] scheduler instance,
+ *              snssai pointer,
  *              SchRrmPolicy pointer,
  *              SchLcPrbEstimate pointer , It will be filled
  *              isDedicated pointer,(Address of isDedicated flag in LC Context)
@@ -191,11 +192,10 @@ void fillSchUlLcCtxt(SchUlLcCtxt *ueCbLcCfg, SchLcCfg *lcCfg)
  *
  * ****************************************************************/
 
-uint8_t updateDedLcInfo(Snssai *snssai, SchLcPrbEstimate *lcPrbEst,\
-                         bool *isDedicated)
+uint8_t updateDedLcInfo(Inst inst, Snssai *snssai, SchLcPrbEstimate *lcPrbEst, bool *isDedicated)
 {
    uint8_t sliceCfgIdx =0;
-   SchSliceCfg sliceCfg = schCb[0].sliceCfg;
+   SchSliceCfg sliceCfg = schCb[inst].sliceCfg;
 
    if(sliceCfg.numOfSliceConfigured)
    {
@@ -241,13 +241,14 @@ uint8_t updateDedLcInfo(Snssai *snssai, SchLcPrbEstimate *lcPrbEst,\
  *
  *    Functionality: Function to fill SchUeCb
  *
- * @params[in] SchUeCb pointer,
+ * @params[in] Scheduler instance,
+ *             SchUeCb pointer,
  *             SchUeCfg pointer
  * @return ROK/RFAILED
  *
  * ****************************************************************/
 
-uint8_t fillSchUeCb(SchUeCb *ueCb, SchUeCfg *ueCfg)
+uint8_t fillSchUeCb(Inst inst, SchUeCb *ueCb, SchUeCfg *ueCfg)
 {
    uint8_t   lcIdx, ueLcIdx;
    uint8_t   freqDomainResource[FREQ_DOM_RSRC_SIZE] = {0};
@@ -258,7 +259,9 @@ uint8_t fillSchUeCb(SchUeCb *ueCb, SchUeCfg *ueCfg)
    bool isLcIdValid = FALSE;
 
    ueCb->ueCfg.cellId = ueCfg->cellId;
+   ueCb->ueCfg.duUeF1apId = ueCfg->duUeF1apId;
    ueCb->ueCfg.crnti = ueCfg->crnti;
+   ueCb->ueCfg.dataTransmissionAction = ueCfg->dataTransmissionInfo;
    if(ueCfg->macCellGrpCfgPres == true)
    {
       memcpy(&ueCb->ueCfg.macCellGrpCfg , &ueCfg->macCellGrpCfg, sizeof(SchMacCellGrpCfg)); 
@@ -298,7 +301,6 @@ uint8_t fillSchUeCb(SchUeCb *ueCb, SchUeCfg *ueCfg)
       }
    }
 
-   ueCb->state = SCH_UE_STATE_ACTIVE;
    if(ueCfg->ambrCfg)
    {
       SCH_FREE(ueCb->ueCfg.ambrCfg, sizeof(SchAmbrCfg));
@@ -328,12 +330,12 @@ uint8_t fillSchUeCb(SchUeCb *ueCb, SchUeCfg *ueCfg)
           * 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->dlLcPrbEst),\
+            retDL = updateDedLcInfo(inst, ueCb->dlInfo.dlLcCtxt[ueLcIdx].snssai, &(ueCb->dlLcPrbEst),\
                   &(ueCb->dlInfo.dlLcCtxt[ueLcIdx].isDedicated));
          }
          if(ueCb->ulInfo.ulLcCtxt[ueLcIdx].snssai != NULLP)
          {
-            retUL =  updateDedLcInfo(ueCb->ulInfo.ulLcCtxt[ueLcIdx].snssai, &(ueCb->ulLcPrbEst),\
+            retUL =  updateDedLcInfo(inst, ueCb->ulInfo.ulLcCtxt[ueLcIdx].snssai, &(ueCb->ulLcPrbEst),\
                   &(ueCb->ulInfo.ulLcCtxt[ueLcIdx].isDedicated));
          }
 
@@ -353,7 +355,7 @@ uint8_t fillSchUeCb(SchUeCb *ueCb, SchUeCfg *ueCfg)
                /*Updating the RRM reserved pool PRB count*/
                if(ueCb->ulInfo.ulLcCtxt[ueLcIdx].snssai != NULLP)
                {
-                  retUL =  updateDedLcInfo(ueCb->ulInfo.ulLcCtxt[ueLcIdx].snssai, &(ueCb->ulLcPrbEst),\
+                  retUL =  updateDedLcInfo(inst, ueCb->ulInfo.ulLcCtxt[ueLcIdx].snssai, &(ueCb->ulLcPrbEst),\
                         &(ueCb->ulInfo.ulLcCtxt[ueLcIdx].isDedicated));
                }
                if(retUL == RFAILED)
@@ -396,7 +398,7 @@ uint8_t fillSchUeCb(SchUeCb *ueCb, SchUeCfg *ueCfg)
                /*Updating the RRM policy*/
                if(ueCb->dlInfo.dlLcCtxt[ueLcIdx].snssai != NULLP)
                {
-                  retDL = updateDedLcInfo(ueCb->dlInfo.dlLcCtxt[ueLcIdx].snssai, &(ueCb->dlLcPrbEst), \
+                  retDL = updateDedLcInfo(inst, ueCb->dlInfo.dlLcCtxt[ueLcIdx].snssai, &(ueCb->dlLcPrbEst), \
                         &(ueCb->dlInfo.dlLcCtxt[ueLcIdx].isDedicated));
                }
                if(retDL == RFAILED)
@@ -504,11 +506,11 @@ SchCellCb *getSchCellCb(uint16_t srcEvent, Inst inst, SchUeCfg *ueCfg)
  * ****************************************************************/
 uint8_t MacSchAddUeConfigReq(Pst *pst, SchUeCfg *ueCfg)
 {
-   uint8_t ueIdx, lcIdx, ret = ROK;
+   uint8_t ueId, lcIdx, ret = ROK;
    SchCellCb    *cellCb = NULLP;
    SchUeCb      *ueCb = NULLP;
    SchUeCfgRsp  cfgRsp;
-   Inst         inst = pst->dstInst - 1;
+   Inst         inst = pst->dstInst - SCH_INST_START;
    memset(&cfgRsp, 0, sizeof(SchUeCfgRsp));
   
 #ifdef CALL_FLOW_DEBUG_LOG
@@ -524,35 +526,38 @@ uint8_t MacSchAddUeConfigReq(Pst *pst, SchUeCfg *ueCfg)
    cellCb = getSchCellCb(pst->event, inst, ueCfg);
 
    /* Search if UE already configured */
-   GET_UE_IDX(ueCfg->crnti, ueIdx);
-   ueCb = &cellCb->ueCb[ueIdx -1];
-   if(ueCb)
+   if(ueCfg->crnti)
    {
-      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;
-      }
+      GET_UE_ID(ueCfg->crnti, ueId);
+      ueCb = &cellCb->ueCb[ueId -1];
    }
    else
+      ueCb = &cellCb->hoUeCb[ueCfg->duUeF1apId - 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));
-   GET_UE_IDX(ueCfg->crnti, ueIdx);
-   ueCb->ueIdx = ueIdx;
+   ueCb->ueId = ueId;
    ueCb->crnti = ueCfg->crnti;
-   ueCb->state = SCH_UE_STATE_ACTIVE;
-   ret = fillSchUeCb(ueCb, ueCfg);
+   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)
    {
-      cellCb->numActvUe++;
-      SET_ONE_BIT(ueCb->ueIdx, cellCb->actvUeBitMap);
+      if(ueCb->state == SCH_UE_STATE_ACTIVE)
+      {
+         cellCb->numActvUe++;
+         SET_ONE_BIT(ueCb->ueId, cellCb->actvUeBitMap);
+      }
       ueCb->cellCb = cellCb;
       ueCb->srRcvd = false;
       ueCb->bsrRcvd = false;
@@ -738,11 +743,11 @@ uint8_t schFillUlDci(SchUeCb *ueCb, SchPuschInfo *puschInfo, DciInfo *dciInfo)
  * ****************************************************************/
 uint8_t MacSchModUeConfigReq(Pst *pst, SchUeCfg *ueCfg)
 {
-   uint8_t ueIdx, lcIdx, ret = ROK;
+   uint8_t ueId, lcIdx, ret = ROK;
    SchCellCb    *cellCb = NULLP;
    SchUeCb      *ueCb = NULLP;
    SchUeCfgRsp  cfgRsp;
-   Inst         inst = pst->dstInst - 1;
+   Inst         inst = pst->dstInst - SCH_INST_START;
    memset(&cfgRsp, 0, sizeof(SchUeCfgRsp));
   
 #ifdef CALL_FLOW_DEBUG_LOG
@@ -758,8 +763,8 @@ uint8_t MacSchModUeConfigReq(Pst *pst, SchUeCfg *ueCfg)
    cellCb = getSchCellCb(pst->event, inst, ueCfg);
 
    /* Search if UE already configured */
-   GET_UE_IDX(ueCfg->crnti, ueIdx);
-   ueCb = &cellCb->ueCb[ueIdx -1];
+   GET_UE_ID(ueCfg->crnti, ueId);
+   ueCb = &cellCb->ueCb[ueId -1];
    
    if(!ueCb)
    {
@@ -770,7 +775,7 @@ uint8_t MacSchModUeConfigReq(Pst *pst, SchUeCfg *ueCfg)
    if((ueCb->crnti == ueCfg->crnti) && (ueCb->state == SCH_UE_STATE_ACTIVE))
    {
       /* Found the UeCb to Reconfig */
-      ret = fillSchUeCb(ueCb, ueCfg);
+      ret = fillSchUeCb(inst, ueCb, ueCfg);
       if(ret == ROK)
       {
          ueCb->cellCb = cellCb;
@@ -1005,7 +1010,7 @@ uint8_t MacSchUeDeleteReq(Pst *pst, SchUeDelete  *ueDelete)
     uint8_t      idx=0, ueId=0, ueIdToDel=0, ret=ROK;
     ErrorCause   result;
     SchCellCb    *cellCb = NULLP;
-    Inst         inst = pst->dstInst - 1;
+    Inst         inst = pst->dstInst - SCH_INST_START;
     CmLList      *node = NULL, *next = NULL;
    
 #ifdef CALL_FLOW_DEBUG_LOG
@@ -1028,7 +1033,7 @@ uint8_t MacSchUeDeleteReq(Pst *pst, SchUeDelete  *ueDelete)
     }
     else
     {
-       GET_UE_IDX(ueDelete->crnti, ueId);
+       GET_UE_ID(ueDelete->crnti, ueId);
        if(( cellCb->ueCb[ueId-1].crnti == ueDelete->crnti) && ( cellCb->ueCb[ueId-1].state == SCH_UE_STATE_ACTIVE))
        {
           deleteSchUeCb(&cellCb->ueCb[ueId-1]);
@@ -1053,7 +1058,7 @@ uint8_t MacSchUeDeleteReq(Pst *pst, SchUeDelete  *ueDelete)
        else
        {
           DU_LOG("\nERROR  -->  SCH : MacSchUeDeleteReq(): SchUeCb not found");
-          result =  INVALID_UEIDX;
+          result =  INVALID_UEID;
        }
     }
     
@@ -1209,7 +1214,7 @@ void deleteSchCellCb(SchCellCb *cellCb)
 uint8_t MacSchCellDeleteReq(Pst *pst, SchCellDelete  *cellDelete)
 {
    uint8_t   cellIdx=0, ret = RFAILED;
-   Inst      inst = pst->dstInst - 1;
+   Inst      inst = pst->dstInst - SCH_INST_START;
    SchMacRsp result= RSP_OK;
    
 #ifdef CALL_FLOW_DEBUG_LOG