Moving all common header file into common_def.h file
[o-du/l2.git] / src / 5gnrsch / sch_slot_ind.c
index bb62aa2..4a6b998 100644 (file)
@@ -31,29 +31,9 @@ File:     sch_slot_ind.c
 /** @file sch_slot_ind.c
   @brief This module processes slot indications
  */
-#include "stdbool.h"
-#include "envopt.h"        /* environment options */
-#include "envdep.h"        /* environment dependent */
-#include "envind.h"        /* environment independent */
-#include "gen.h"           /* general layer */
-#include "ssi.h"           /* system service interface */
-#include "cm_tkns.h"       /* Common Token Defines */
-#include "cm_llist.h"      /* Common Link List Defines */
-#include "cm_hash.h"       /* Common Hash List Defines */
-#include "cm_mblk.h"       /* common memory link list library */
-#include "cm_lte.h"        /* Common LTE Defines */
+#include "common_def.h"
 #include "tfu.h"
 #include "lrg.h"
-
-#include "gen.x"           /* general layer typedefs */
-#include "ssi.x"           /* system services typedefs */
-#include "cm5.x"           /* system services */
-#include "cm_tkns.x"       /* Common Token Definitions */
-#include "cm_llist.x"      /* Common Link List Definitions */
-#include "cm_lib.x"        /* Common Library Definitions */
-#include "cm_hash.x"       /* Common Hash List Definitions */
-#include "cm_mblk.x"       /* common memory link list library */
-#include "cm_lte.x"        /* Common LTE Defines */
 #include "tfu.x"
 #include "lrg.x"
 #include "du_log.h"
@@ -61,7 +41,6 @@ File:     sch_slot_ind.c
 #include "mac_sch_interface.h"
 #include "sch.h"
 #include "sch_utils.h"
-#include "common_def.h"
 
 SchMacDlAllocFunc schMacDlAllocOpts[] =
 {
@@ -161,7 +140,7 @@ uint8_t schProcessSlotInd(SlotIndInfo *slotInd, Inst schInst)
 {
    int ret = ROK;
        uint8_t ssb_rep;
-       uint16_t sfnSlot = 0;
+       uint16_t slot, sfnSlot = 0;
        DlSchedInfo dlSchedInfo;
        memset(&dlSchedInfo,0,sizeof(DlSchedInfo));
    DlBrdcstAlloc *dlBrdcstAlloc = &dlSchedInfo.brdcstAlloc;
@@ -181,6 +160,8 @@ uint8_t schProcessSlotInd(SlotIndInfo *slotInd, Inst schInst)
    sfnSlot = ((dlSchedInfo.schSlotValue.broadcastTime.sfn * 10) +
                    dlSchedInfo.schSlotValue.broadcastTime.slot);
 
+       slot = dlSchedInfo.schSlotValue.currentTime.slot;
+
        dlSchedInfo.cellId = cell->cellId;
 
        /* Identify SSB ocassion*/
@@ -214,7 +195,8 @@ uint8_t schProcessSlotInd(SlotIndInfo *slotInd, Inst schInst)
        if(dlBrdcstAlloc->ssbTrans || dlBrdcstAlloc->sib1Trans)
        {
           dlSchedInfo.isBroadcastPres = true;
-          ret = schBroadcastAlloc(cell,dlBrdcstAlloc,dlSchedInfo.schSlotValue.broadcastTime.slot);
+               slot = dlSchedInfo.schSlotValue.broadcastTime.slot;
+          ret = schBroadcastAlloc(cell,dlBrdcstAlloc,slot);
       if(ret != ROK)
       {
          DU_LOG("\nschBroadcastAlloc failed");
@@ -225,6 +207,7 @@ uint8_t schProcessSlotInd(SlotIndInfo *slotInd, Inst schInst)
    /* check for RAR */
        if(cell->schDlSlotInfo[dlSchedInfo.schSlotValue.rarTime.slot]->rarInfo != NULLP)
        {
+          slot = dlSchedInfo.schSlotValue.rarTime.slot;
       SCH_ALLOC(rarAlloc, sizeof(RarAlloc));
       if(!rarAlloc)
       {
@@ -235,22 +218,22 @@ uint8_t schProcessSlotInd(SlotIndInfo *slotInd, Inst schInst)
       dlSchedInfo.rarAlloc = rarAlloc;
 
           /* RAR info is copied, this was earlier filled in schProcessRachInd */
-      memcpy(&rarAlloc->rarInfo,cell->schDlSlotInfo[dlSchedInfo.schSlotValue.rarTime.slot]->rarInfo, \
-             sizeof(RarInfo));
+      memcpy(&rarAlloc->rarInfo,cell->schDlSlotInfo[slot]->rarInfo, sizeof(RarInfo));
 
                 /* pdcch and pdsch data is filled */
        schFillRar(rarAlloc,
-                   cell->schDlSlotInfo[dlSchedInfo.schSlotValue.rarTime.slot]->rarInfo->raRnti,
+                   cell->schDlSlotInfo[slot]->rarInfo->raRnti,
                    cell->cellCfg.phyCellId,
                    cell->cellCfg.ssbSchCfg.ssbOffsetPointA);
 
-      SCH_FREE(cell->schDlSlotInfo[dlSchedInfo.schSlotValue.rarTime.slot]->rarInfo,sizeof(RarAlloc));
-          cell->schDlSlotInfo[dlSchedInfo.schSlotValue.rarTime.slot]->rarInfo = NULLP;
+      SCH_FREE(cell->schDlSlotInfo[slot]->rarInfo,sizeof(RarAlloc));
+          cell->schDlSlotInfo[slot]->rarInfo = NULLP;
    }
 
    /* check for MSG4 */
    if(cell->schDlSlotInfo[dlSchedInfo.schSlotValue.msg4Time.slot]->msg4Info != NULLP)
    {
+           slot = dlSchedInfo.schSlotValue.msg4Time.slot;
            SCH_ALLOC(msg4Alloc, sizeof(Msg4Alloc));
                 if(!msg4Alloc)
                 {
@@ -261,11 +244,15 @@ uint8_t schProcessSlotInd(SlotIndInfo *slotInd, Inst schInst)
                 dlSchedInfo.msg4Alloc = msg4Alloc;
 
        /* Msg4 info is copied, this was earlier filled in macSchDlRlcBoInfo */
-       memcpy(&msg4Alloc->msg4Info, cell->schDlSlotInfo[dlSchedInfo.schSlotValue.msg4Time.slot]->msg4Info, \
+       memcpy(&msg4Alloc->msg4Info, cell->schDlSlotInfo[slot]->msg4Info, \
           sizeof(Msg4Info));
              
        /* pdcch and pdsch data is filled */
        schDlRsrcAllocMsg4(msg4Alloc, cell, dlSchedInfo.schSlotValue.msg4Time.slot); 
+
+                /* PUCCH resource */
+       schAllocPucchResource(cell, msg4Alloc->msg4Info.crnti, dlSchedInfo.schSlotValue.msg4Time.slot);
+
                 SCH_FREE(cell->schDlSlotInfo[dlSchedInfo.schSlotValue.msg4Time.slot]->msg4Info, sizeof(Msg4Info));
                 cell->schDlSlotInfo[dlSchedInfo.schSlotValue.msg4Time.slot]->msg4Info = NULL;
    }
@@ -281,6 +268,8 @@ uint8_t schProcessSlotInd(SlotIndInfo *slotInd, Inst schInst)
     
        schUlResAlloc(cell, schInst);
 
+       memset(cell->schDlSlotInfo[slot], 0, sizeof(SchDlSlotInfo));
+
        return ret;
 }