[EPIC-ID: ODUHIGH-488][TASK-ID: ODUHIGH-494]SCH framework update to support different...
[o-du/l2.git] / src / 5gnrsch / sch_rach.c
index 162ed15..104061a 100644 (file)
 #include "sch.h"
 #include "sch_utils.h"
 
-SchRachRsrcRspFunc SchRachRsrcRspOpts[] =
-{
-   packSchRachRsrcRsp,      /* LC */
-   MacProcSchRachRsrcRsp,   /* TC */
-   packSchRachRsrcRsp       /* LWLC */
-};
-
 /**
  * @brief Checks if PRACH can be scheduled in current slot
  *
@@ -196,7 +189,7 @@ void schPrachResAlloc(SchCellCb *cell, UlSchedInfo *ulSchedInfo, SlotTimingInfo
  *
  * @details
  *
- *     Function : MacSchRachRsrcReq
+ *     Function : SchProcRachRsrcReq
  *     
  *     This function processes RACH resorce request 
  *     from MAC for CFRA. It assigns a dedicated preamble
@@ -208,7 +201,7 @@ void schPrachResAlloc(SchCellCb *cell, UlSchedInfo *ulSchedInfo, SlotTimingInfo
  *  @return     ROK
  *              RFAILED
  **/
-uint8_t MacSchRachRsrcReq(Pst *pst, SchRachRsrcReq *schRachRsrcReq)
+uint8_t SchProcRachRsrcReq(Pst *pst, SchRachRsrcReq *schRachRsrcReq)
 {
    uint8_t      ssbIdx = 0, cfraSsbIdx = 0;
    uint8_t      firstCFPreambleIndex = 0, lastCFPreambleIndex = 0;
@@ -335,7 +328,7 @@ uint8_t MacSchRachRsrcReq(Pst *pst, SchRachRsrcReq *schRachRsrcReq)
    SCH_FREE(schRachRsrcReq, sizeof(SchRachRsrcReq));
 
    /* Send RACH resource response to MAC */
-   return (SchRachRsrcRspOpts[rspPst.selector](&rspPst, rachRsrcRsp));
+   return(MacMessageRouter(&rspPst, (void *)rachRsrcRsp));
 }
 
 /**
@@ -375,10 +368,8 @@ uint16_t calculateRaRnti(uint8_t symbolIdx, uint8_t slotIdx, uint8_t freqIdx)
  *  @param[in]  shed instance
  *  @return  void
  **/
-void createSchRaCb(SchRaReq *raReq, Inst schInst)
+void createSchRaCb(uint8_t ueId, SchRaReq *raReq, Inst schInst)
 {
-   uint8_t ueId = 0;
-
    if(raReq->isCFRA)
    {
       /* If a UE in handover has triggered CFRA, its UE CB context is already present in SCH, 
@@ -572,7 +563,7 @@ bool schProcessRaReq(Inst schInst, SchCellCb *cell, SlotTimingInfo currTime, uin
    }
 
    /* Calculating time frame to send DCI for RAR */
-   ADD_DELTA_TO_TIME(currTime, dciTime, PHY_DELTA_DL + SCHED_DELTA);
+   ADD_DELTA_TO_TIME(currTime, dciTime, PHY_DELTA_DL + SCHED_DELTA, cell->numSlots);
    dciSlot = dciTime.slot;
 #ifdef NR_TDD
    /* Consider this slot for sending DCI, only if it is a DL slot */
@@ -597,7 +588,7 @@ bool schProcessRaReq(Inst schInst, SchCellCb *cell, SlotTimingInfo currTime, uin
             k0 = cell->cellCfg.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[k0Index].k0;
 
             /* Calculating time frame to send RAR PDSCH */
-            ADD_DELTA_TO_TIME(dciTime, rarTime, k0);
+            ADD_DELTA_TO_TIME(dciTime, rarTime, k0, cell->numSlots);
             rarSlot = rarTime.slot;
             
             /* If PDSCH is already scheduled on this slot, cannot schedule PDSCH for another UE here. */
@@ -612,9 +603,9 @@ bool schProcessRaReq(Inst schInst, SchCellCb *cell, SlotTimingInfo currTime, uin
                for(k1TblIdx = 0; k1TblIdx < numK1; k1TblIdx++)
                {   
                   k1Index = k0K1InfoTbl->k0k1TimingInfo[dciTime.slot].k0Indexes[k0TblIdx].k1TimingInfo.k1Indexes[k1TblIdx];
-                  if(cell->raReq[ueId-1]->ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.pucchCfg.dlDataToUlAck)
+                  if(cell->raReq[ueId-1]->ueCb->ueCfg.spCellCfg.servCellRecfg.initUlBwp.pucchCfg.dlDataToUlAck)
                   {
-                     k1 = cell->raReq[ueId-1]->ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.pucchCfg.dlDataToUlAck->\
+                     k1 = cell->raReq[ueId-1]->ueCb->ueCfg.spCellCfg.servCellRecfg.initUlBwp.pucchCfg.dlDataToUlAck->\
                         dlDataToUlAckList[k1Index];
                   }
                   else
@@ -622,7 +613,7 @@ bool schProcessRaReq(Inst schInst, SchCellCb *cell, SlotTimingInfo currTime, uin
                      k1 = defaultUlAckTbl[k1Index];
                   }
 
-                  ADD_DELTA_TO_TIME(rarTime, pucchTime, k1);
+                  ADD_DELTA_TO_TIME(rarTime, pucchTime, k1, cell->numSlots);
 #ifdef NR_TDD
                   if(schGetSlotSymbFrmt(pucchTime.slot, cell->slotFrmtBitMap) == DL_SLOT)
                      continue;
@@ -645,7 +636,7 @@ bool schProcessRaReq(Inst schInst, SchCellCb *cell, SlotTimingInfo currTime, uin
                   k2 = k2 + msg3Delta;
                   if(k2 >= msg3MinSchTime)
                   {
-                     ADD_DELTA_TO_TIME(rarTime, msg3Time, k2);
+                     ADD_DELTA_TO_TIME(rarTime, msg3Time, k2, cell->numSlots);
 #ifdef NR_TDD
                      if(schGetSlotSymbFrmt(msg3Time.slot % totalCfgSlot, cell->slotFrmtBitMap) == DL_SLOT)
                         continue;
@@ -760,7 +751,7 @@ bool schProcessRaReq(Inst schInst, SchCellCb *cell, SlotTimingInfo currTime, uin
          cell->schUlSlotInfo[msg3Time.slot]->puschUe = ueId;
 
       /* Create raCb at SCH */
-      createSchRaCb(cell->raReq[ueId-1], schInst);
+      createSchRaCb(ueId, cell->raReq[ueId-1], schInst);
 
       /* Remove RachInd from pending RA request list */
       SCH_FREE(cell->raReq[ueId-1]->rachInd, sizeof(RachIndInfo));
@@ -776,7 +767,7 @@ bool schProcessRaReq(Inst schInst, SchCellCb *cell, SlotTimingInfo currTime, uin
  *
  * @details
  *
- *     Function : schProcessRachInd
+ *     Function : SchProcRachInd
  *     
  *     This function process rach indication
  *     
@@ -784,17 +775,20 @@ bool schProcessRaReq(Inst schInst, SchCellCb *cell, SlotTimingInfo currTime, uin
  *  @param[in]  shed instance
  *  @return  ROK
  **/
-uint8_t schProcessRachInd(RachIndInfo *rachInd, Inst schInst)
+uint8_t SchProcRachInd(Pst *pst, RachIndInfo *rachInd)
 {
-   SchCellCb *cell = schCb[schInst].cells[schInst];
    SchRaReq  *raReq = NULLP;
-   float    slotDuration;
-   uint8_t  winNumSlots;
-   uint8_t  ueId;
+   float     slotDuration;
+   uint8_t   winNumSlots;
+   uint8_t   ueId;
+   Inst      schInst = pst->dstInst-SCH_INST_START;
+   SchCellCb *cell = schCb[schInst].cells[schInst];
+
+   DU_LOG("\nINFO  -->  SCH : Received Rach indication");
 
    if(cell == NULLP)
    {
-      DU_LOG("\nERROR  -->  SCH: Failed to find cell in schProcessRachInd");
+      DU_LOG("\nERROR  -->  SCH: Failed to find cell in SchProcRachInd");
       return RFAILED;
    }
 
@@ -809,7 +803,7 @@ uint8_t schProcessRachInd(RachIndInfo *rachInd, Inst schInst)
    SCH_ALLOC(raReq, sizeof(SchRaReq));
    if(!raReq)
    {
-      DU_LOG("\nERROR  -->  SCH : Memory allocation failure in schProcessRachInd");
+      DU_LOG("\nERROR  -->  SCH : Memory allocation failure in SchProcRachInd");
       SCH_FREE(rachInd, sizeof(RachIndInfo));
       return RFAILED;
    }
@@ -832,12 +826,11 @@ uint8_t schProcessRachInd(RachIndInfo *rachInd, Inst schInst)
    winNumSlots = (float)cell->cellCfg.schRachCfg.raRspWindow / slotDuration;
    
    /* Adding window size to window start time to get window end time */
-   ADD_DELTA_TO_TIME(raReq->winStartTime, raReq->winEndTime, winNumSlots);
+   ADD_DELTA_TO_TIME(raReq->winStartTime, raReq->winEndTime, winNumSlots, cell->numSlots);
    cell->raReq[ueId -1] = raReq;
 
    /* Adding UE Id to list of pending UEs to be scheduled */
-   addUeToBeScheduled(cell, ueId);
-
+   cell->api->SchRachInd(cell, ueId);
    return ROK;
 }
 
@@ -1000,7 +993,7 @@ uint8_t schFillRar(SchCellCb *cell, SlotTimingInfo rarTime, uint16_t ueId, RarAl
  *
  * @details
  *
- *     Function : MacSchRachRsrcRel
+ *     Function : SchProcRachRsrcRel
  *     
  *     This function processes RACH resorce release
  *     from MAC after CFRA. It releases the dedicated 
@@ -1011,7 +1004,7 @@ uint8_t schFillRar(SchCellCb *cell, SlotTimingInfo rarTime, uint16_t ueId, RarAl
  *  @return     ROK
  *              RFAILED
  */
-uint8_t MacSchRachRsrcRel(Pst *pst, SchRachRsrcRel *schRachRsrcRel)
+uint8_t SchProcRachRsrcRel(Pst *pst, SchRachRsrcRel *schRachRsrcRel)
 {
    uint8_t      ret = ROK;
    uint8_t      ssbIdx = 0, cfraSsbIdx = 0;
@@ -1089,7 +1082,7 @@ void schMsg4Complete(SchUeCb *ueCb)
 {
    DU_LOG("\nINFO --> SCH: State change for ueId[%2d] to SCH_RA_STATE_MSG4_DONE\n",ueCb->ueId);
    ueCb->cellCb->raCb[ueCb->ueId-1].raState = SCH_RA_STATE_MSG4_DONE;
-   ueCb->msg4Proc = ueCb->retxMsg4HqProc = NULLP;
+   ueCb->msg4HqProc = ueCb->retxMsg4HqProc = NULLP;
 }
 /**********************************************************************
          End of file