[Epic-ID: ODUHIGH-406][Task-ID: ODUHIGH-449] Fixes releate to Cell Id
[o-du/l2.git] / src / 5gnrsch / sch.c
index a0ff776..15d4dfd 100644 (file)
@@ -72,6 +72,7 @@ SchSliceReCfgRspFunc SchSliceReCfgRspOpts[] =
    MacProcSchSliceReCfgRsp,  /* TC */
    packSchSliceReCfgRsp      /* LWLC */
 };
+
 /**
  * @brief Task Initiation function. 
  *
@@ -142,9 +143,7 @@ uint8_t SchInstCfg(RgCfg *cfg, Inst  dInst)
       return LCM_REASON_INVALID_MSGTYPE;
    }
    /* Update the Pst structure for LM interface */
-   memcpy(&schCb[inst].schInit.lmPst,
-        &cfg->s.schInstCfg.genCfg.lmPst,
-        sizeof(Pst));
+   memcpy(&schCb[inst].schInit.lmPst, &cfg->s.schInstCfg.genCfg.lmPst, sizeof(Pst));
 
    schCb[inst].schInit.inst = inst;
    schCb[inst].schInit.lmPst.srcProcId = schCb[inst].schInit.procId;
@@ -170,8 +169,7 @@ uint8_t SchInstCfg(RgCfg *cfg, Inst  dInst)
 
    /* SS_MT_TMR needs to be enabled as schActvTmr needs instance information */
    /* Timer Registration request to system services */
-   if (ODU_REG_TMR_MT(schCb[inst].schInit.ent, dInst,
-           (int)schCb[inst].genCfg.tmrRes, schActvTmr) != ROK)
+   if (ODU_REG_TMR_MT(schCb[inst].schInit.ent, dInst, (int)schCb[inst].genCfg.tmrRes, schActvTmr) != ROK)
    {
       DU_LOG("\nERROR  -->  SCH : SchInstCfg(): Failed to "
            "register timer.");
@@ -868,7 +866,7 @@ uint8_t SchHdlCellCfgReq(Pst *pst, SchCellCfg *schCellCfg)
    SchCellCb *cellCb;
    SchCellCfgCfm schCellCfgCfm;
    Pst rspPst;
-   Inst inst = pst->dstInst-1
+   Inst inst = pst->dstInst - SCH_INST_START
    uint8_t coreset0Idx = 0;
    uint8_t numRbs = 0;
    uint8_t offset = 0;
@@ -965,6 +963,12 @@ uint8_t MacSchDlRlcBoInfo(Pst *pst, DlRlcBoInfo *dlBoInfo)
 
    GET_UE_ID(dlBoInfo->crnti, ueId);
    ueCb = &cell->ueCb[ueId-1];
+   if(ueCb->ueCfg.dataTransmissionAction == STOP_DATA_TRANSMISSION)
+   {
+      DU_LOG("INFO  --> SCH : DL Data transmission not allowed for UE %d", ueCb->ueCfg.ueId);
+      return ROK;
+   }
+   
    lcId  = dlBoInfo->lcId;
    CHECK_LCID(lcId, isLcIdValid);
    if(isLcIdValid == FALSE)
@@ -1000,8 +1004,6 @@ uint8_t MacSchDlRlcBoInfo(Pst *pst, DlRlcBoInfo *dlBoInfo)
    }
    else
    {
-      /* TODO : These part of changes will be corrected during DL scheduling as
-       * per K0 - K1 -K2 */
       SET_ONE_BIT(ueId, cell->boIndBitMap);
       if(ueCb->dlInfo.dlLcCtxt[lcId].lcId == lcId)
       {
@@ -1067,6 +1069,12 @@ uint8_t MacSchBsr(Pst *pst, UlBufferStatusRptInd *bsrInd)
       return RFAILED;
    }
 
+   if(ueCb->ueCfg.dataTransmissionAction == STOP_DATA_TRANSMISSION)
+   {
+      DU_LOG("\nINFO --> SCH: UL Data transmission not allowed for UE %d", ueCb->ueCfg.ueId);
+      return ROK;
+   }
+   
    ueCb->bsrRcvd = true;
    /* store dataVolume per lcg in uecb */
    for(lcgIdx = 0; lcgIdx < bsrInd->numLcg; lcgIdx++)
@@ -1117,7 +1125,11 @@ uint8_t MacSchSrUciInd(Pst *pst, SrUciIndInfo *uciInd)
       DU_LOG("\nERROR  -->  SCH : Crnti %d is inactive", uciInd->crnti);
       return ROK;  
    }
-
+   if(ueCb->ueCfg.dataTransmissionAction == STOP_DATA_TRANSMISSION)
+   {
+      DU_LOG("\nINFO --> SCH: UL Data transmission not allowed for UE %d", ueCb->ueCfg.ueId);
+      return ROK;
+   }
    if(uciInd->numSrBits)
    {
       ueCb->srRcvd = true;
@@ -1751,7 +1763,9 @@ uint8_t addSliceCfgInSchDb(SchSliceCfg *storeSliceCfg, SchSliceCfgReq *cfgReq, S
                return RFAILED;
             }
 
-            memcpy(storeSliceCfg->listOfConfirguration[sliceIdx], cfgReq->listOfConfirguration[sliceIdx], sizeof(SchRrmPolicyOfSlice));
+            memcpy(&storeSliceCfg->listOfConfirguration[sliceIdx]->snssai, &cfgReq->listOfConfirguration[sliceIdx]->snssai, sizeof(Snssai));
+            memcpy(storeSliceCfg->listOfConfirguration[sliceIdx]->rrmPolicyRatioInfo, cfgReq->listOfConfirguration[sliceIdx]->rrmPolicyRatioInfo,
+                      sizeof(SchRrmPolicyRatio));
             sliceIdx++;
          }
       }
@@ -1818,7 +1832,7 @@ void freeSchSliceCfgReq(SchSliceCfgReq *cfgReq)
 uint8_t MacSchSliceCfgReq(Pst *pst, SchSliceCfgReq *schSliceCfgReq)
 {
    uint8_t count = 0;
-   Inst   inst = pst->dstInst - 1;
+   Inst   inst = pst->dstInst - SCH_INST_START;
    SchSliceCfgRsp sliceCfgRsp;
 
    DU_LOG("\nINFO  -->  SCH : Received Slice Cfg request from MAC");
@@ -1887,7 +1901,8 @@ uint8_t modifySliceCfgInSchDb(SchSliceCfg *storeSliceCfg, SchSliceCfgReq *cfgReq
             {
                if(!memcmp(&storeSliceCfg->listOfConfirguration[sliceIdx]->snssai, &cfgReq->listOfConfirguration[cfgIdx]->snssai, sizeof(Snssai)))
                {
-                  storeSliceCfg->listOfConfirguration[sliceIdx]->rrmPolicyRatioInfo = cfgReq->listOfConfirguration[cfgIdx]->rrmPolicyRatioInfo;
+                  memcpy(storeSliceCfg->listOfConfirguration[sliceIdx]->rrmPolicyRatioInfo, cfgReq->listOfConfirguration[cfgIdx]->rrmPolicyRatioInfo,
+                           sizeof(SchRrmPolicyRatio));
                   break;
                }
             }
@@ -1944,7 +1959,7 @@ void SchSendSliceReCfgRspToMac(Inst inst, SchSliceCfgRsp schSliceReCfgRsp)
 uint8_t MacSchSliceReCfgReq(Pst *pst, SchSliceCfgReq *schSliceReCfgReq)
 {
    uint8_t count = 0;
-   Inst   inst = pst->dstInst - 1;
+   Inst   inst = pst->dstInst - SCH_INST_START;
    SchSliceCfgRsp schSliceReCfgRsp;
 
    DU_LOG("\nINFO  -->  SCH : Received Slice ReCfg request from MAC");
@@ -2087,6 +2102,154 @@ void schCfgPdcchMonOccOfPO(SchCellCb *cell)
    }
 }
 
+/****************************************************************************
+ *
+ * @brief Storing the paging information in SCH database 
+ *
+ * @details
+ *
+ *    Function : schAddPagingIndtoList
+ *
+ *    Functionality: Storing the paging information in SCH database
+ *
+ * @params[in] CmLListCp *storedPageList, CmLList *pageIndInfo
+ *       
+ * @return ROK - sucess
+ *         RFAILED - failure
+ *        
+ *************************************************************************/
+uint8_t schAddPagingIndtoList(CmLListCp *storedPageList,void * pageIndInfo)
+{
+   CmLList  *firstNodeOfList = NULLP;
+   CmLList  *currentNodeInfo = NULLP;
+   SchPageInfo *tempNode = NULLP, *recvdNode = NULLP;
+   
+   recvdNode = (SchPageInfo*) pageIndInfo;
+   CM_LLIST_FIRST_NODE(storedPageList,firstNodeOfList);
+   
+   SCH_ALLOC(currentNodeInfo, sizeof(CmLList));
+   if(!currentNodeInfo)
+   {  
+      DU_LOG("\nERROR  --> SCH : schAddPagingIndtoList() : Memory allocation failed");
+      return RFAILED;
+   }
+   
+   currentNodeInfo->node = (PTR)pageIndInfo;
+   while(firstNodeOfList)
+   {
+      tempNode = (SchPageInfo*)(firstNodeOfList->node);
+      if ((recvdNode->TxTime.slot < tempNode->TxTime.slot))
+      {
+         cmLListInsCrnt(storedPageList, currentNodeInfo);
+         break;
+      }
+      else if ((recvdNode->TxTime.slot == tempNode->TxTime.slot))
+      {
+         DU_LOG("\nERROR  --> SCH : schAddPagingIndtoList() : Slot[%d] is already present in the list", recvdNode->TxTime.slot);
+         return RFAILED;
+      }
+      else
+      {
+         CM_LLIST_NEXT_NODE(storedPageList, firstNodeOfList);
+      }
+   } 
+   
+   if(!firstNodeOfList)
+   {
+      cmLListAdd2Tail(storedPageList, currentNodeInfo);
+   }
+   DU_LOG("\nINFO  -->  SCH : Paging information is stored successfully");
+   return ROK;
+}
+
+/****************************************************************************
+ *
+ * @brief Process paging indication at  SCH recevied form MAC 
+ *
+ * @details
+ *
+ *    Function : MacSchPagingInd
+ *
+ *    Functionality: Process paging indication at SCH recevied form MAC 
+ *
+ * @params[in] Pst *pst,  SchPageInd *pageInd 
+ *       
+ * @return void 
+ *        
+ *************************************************************************/
+uint8_t MacSchPagingInd(Pst *pst,  SchPageInd *pageInd)
+{
+   uint8_t ret = RFAILED;
+   uint16_t cellIdx = 0;
+   Inst  inst = pst->dstInst - SCH_INST_START;
+   SchCellCb *cellCb = NULLP;
+   SchPageInfo *pageInfo = NULLP;
+
+   if(pageInd)
+   {
+      DU_LOG("\nINFO  --> SCH : Received paging indication form MAC for cellId[%d]",pageInd->cellId);
+
+      /* Fetch Cell CB */
+      for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
+      {
+         if((schCb[inst].cells[cellIdx]) && (schCb[inst].cells[cellIdx]->cellId == pageInd->cellId))
+         {
+            cellCb = schCb[inst].cells[cellIdx];
+            break;
+         }
+      }
+      if(cellCb)
+      {
+         if(pageInd->i_s > cellCb->cellCfg.sib1SchCfg.pageCfg.numPO)
+         {
+            DU_LOG("\nERROR --> SCH : MacSchPagingInd(): i_s should not be greater than number of paging occasion");
+         }
+         else
+         {
+            SCH_ALLOC(pageInfo, sizeof(SchPageInfo));
+            if(pageInfo)
+            {
+               pageInfo->pf = pageInd->pf; 
+               pageInfo->i_s = pageInd->i_s;
+               pageInfo->TxTime.cellId = pageInd->cellId;
+               pageInfo->TxTime.sfn = (pageInd->pf +  cellCb->pageCb.pagMonOcc[pageInd->i_s].frameOffset) % MAX_SFN;
+               pageInfo->TxTime.slot = cellCb->pageCb.pagMonOcc[pageInd->i_s].pagingOccSlot;
+               pageInfo->mcs = DEFAULT_MCS;
+               pageInfo->msgLen =  pageInd->pduLen;
+               SCH_ALLOC(pageInfo->pagePdu, pageInfo->msgLen);
+               if(!pageInfo->pagePdu)
+               {
+                  DU_LOG("\nERROR  --> SCH : MacSchPagingInd(): Failed to allocate memory");
+               }
+               else
+               {
+                  memcpy(pageInfo->pagePdu, pageInd->pagePdu, pageInfo->msgLen);
+                  ret = schAddPagingIndtoList(&cellCb->pageCb.pageIndInfoRecord[pageInfo->TxTime.sfn], pageInfo);
+                  if(ret != ROK)
+                  {
+                     DU_LOG("\nERROR  --> SCH : MacSchPagingInd(): Failed to store paging record");
+                  }
+               }
+            }
+            else
+            {
+               DU_LOG("\nERROR  --> SCH : MacSchPagingInd(): Failed to allocate memory");
+            }
+         }
+      }
+      else
+      {
+         DU_LOG("\nERROR  -->  SCH : Cell ID [%d] not found", pageInd->cellId);
+      }
+      SCH_FREE(pageInd->pagePdu, pageInd->pduLen);
+      SCH_FREE(pageInd, sizeof(SchPageInd));
+   }
+   else
+   {
+      DU_LOG("\nERROR  --> SCH : MacSchPagingInd(): Received null pointer");
+   }
+   return ret;
+}
 /**********************************************************************
   End of file
  **********************************************************************/