Updated IP and Port configurations
[o-du/l2.git] / src / 5gnrsch / sch_common.c
index 3e14282..ae61c2c 100644 (file)
@@ -31,29 +31,10 @@ File:     sch_common.c
 /** @file sch_common.c
   @brief This module performs common scheduling
  */
-#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,11 +42,11 @@ File:     sch_common.c
 #include "mac_sch_interface.h"
 #include "sch.h"
 #include "sch_utils.h"
-#include "common_def.h"
 
 extern SchCb schCb[SCH_MAX_INST];
 extern uint16_t prachCfgIdxTable[MAX_PRACH_CONFIG_IDX][8];
 extern uint16_t numRbForPrachTable[MAX_RACH_NUM_RB_IDX][5];
+extern uint8_t pucchResourceSet[MAX_PUCCH_RES_SET_IDX][4];
 
 SchMacUlSchInfoFunc schMacUlSchInfoOpts[] =
 {
@@ -246,6 +227,31 @@ void schPrachResAlloc(SchCellCb *cell, UlSchedInfo *ulSchedInfo, SlotIndInfo pra
        }
 }
 
+uint16_t fillPucchResourceInfo(SchPucchInfo *schPucchInfo, Inst inst)
+{
+   /* derive pucchResourceSet from schCellCfg */
+   SchCellCb  *cell = schCb[inst].cells[inst];
+   SchPucchCfgCmn *pucchCfg = &cell->cellCfg.schInitialUlBwp.pucchCommon;
+       uint8_t pucchIdx = pucchCfg->pucchResourceCommon;
+       SchBwpParams *ulBwp = &cell->cellCfg.schInitialUlBwp.bwp;
+
+   schPucchInfo->fdAlloc.startPrb = ulBwp->freqAlloc.startPrb + pucchResourceSet[pucchIdx][3];
+   schPucchInfo->fdAlloc.numPrb = PUCCH_NUM_PRB_FORMAT_0;
+   schPucchInfo->tdAlloc.startSymb = pucchResourceSet[pucchIdx][1];
+   schPucchInfo->tdAlloc.numSymb = pucchResourceSet[pucchIdx][2];
+       schPucchInfo->pucchFormat = pucchResourceSet[pucchIdx][0];
+
+   /* set HARQ flag to true */
+   schPucchInfo->harqFlag = true;
+   schPucchInfo->numHarqBits = 1; /* 1 bit for HARQ */
+
+   /* set SR and UCI flag to false */
+   schPucchInfo->srFlag  = false;
+   schPucchInfo->uciFlag = false;
+
+   return ROK;
+}
+
 /**
  * @brief resource allocation for UL
  *
@@ -262,8 +268,9 @@ uint8_t schUlResAlloc(SchCellCb *cell, Inst schInst)
 {
    int ret = ROK;
        UlSchedInfo ulSchedInfo;
-   SchUlSlotInfo  *schUlSlotInfo;
+   SchUlSlotInfo  *schUlSlotInfo = NULLP;
    SlotIndInfo ulTimingInfo;
+       memset(&ulSchedInfo, 0, sizeof(UlSchedInfo));
 
    /* add PHY delta */
    ADD_DELTA_TO_TIME(cell->slotInfo,ulTimingInfo,PHY_DELTA+SCHED_DELTA);
@@ -276,7 +283,6 @@ uint8_t schUlResAlloc(SchCellCb *cell, Inst schInst)
        schPrachResAlloc(cell, &ulSchedInfo, ulTimingInfo);
 
        schUlSlotInfo = cell->schUlSlotInfo[ulTimingInfo.slot]; 
-       
        if(schUlSlotInfo->schPuschInfo)
        {
       ulSchedInfo.crnti = cell->raCb[0].tcrnti;
@@ -287,13 +293,21 @@ uint8_t schUlResAlloc(SchCellCb *cell, Inst schInst)
                schUlSlotInfo->schPuschInfo = NULL;
        }
 
+       if(schUlSlotInfo->pucchPres)
+       {
+               ulSchedInfo.dataType |= SCH_DATATYPE_UCI;
+               fillPucchResourceInfo(&schUlSlotInfo->schPucchInfo, schInst);
+               memcpy(&ulSchedInfo.schPucchInfo, &schUlSlotInfo->schPucchInfo,
+                               sizeof(SchPucchInfo));
+               memset(&schUlSlotInfo->schPucchInfo, 0, sizeof(SchPucchInfo));
+       }
+
        //send msg to MAC
    ret = sendUlSchInfoToMac(&ulSchedInfo, schInst);
    if(ret != ROK)
    {
       DU_LOG("\nSending UL Sch info from SCH to MAC failed");
    }
-    
        memset(cell->schUlSlotInfo[ulTimingInfo.slot], 0, sizeof(SchUlSlotInfo));
 
        return ret;
@@ -414,6 +428,9 @@ uint8_t schDlRsrcAllocMsg4(Msg4Alloc *msg4Alloc, SchCellCb *cell, uint16_t slot)
    pdsch->dmrs.scid = 0;
    pdsch->dmrs.numDmrsCdmGrpsNoData = 1;
    pdsch->dmrs.dmrsPorts = 0;
+       pdsch->dmrs.mappingType      = DMRS_MAP_TYPE_A; /* Setting to Type-A */
+       pdsch->dmrs.nrOfDmrsSymbols  = NUM_DMRS_SYMBOLS;
+       pdsch->dmrs.dmrsAddPos       = DMRS_ADDITIONAL_POS;
    pdsch->pdschFreqAlloc.resourceAllocType = 1; /* RAT type-1 RIV format */
    /* the RB numbering starts from coreset0, and PDSCH is always above SSB */
    pdsch->pdschFreqAlloc.freqAlloc.startPrb = offset + SCH_SSB_NUM_PRB;
@@ -433,6 +450,21 @@ uint8_t schDlRsrcAllocMsg4(Msg4Alloc *msg4Alloc, SchCellCb *cell, uint16_t slot)
    return ROK;
 }
 
+uint16_t schAllocPucchResource(SchCellCb *cell,uint16_t crnti, uint16_t slot)
+{
+   uint8_t k1 = 1; /* dl-DataToUL-ACK RRC parameter will received from DU-APP msg4-pucch config */
+   uint16_t pucchSlot = (slot + k1)  % SCH_NUM_SLOTS;
+       SchUlSlotInfo  *schUlSlotInfo = NULLP;
+   
+       schUlSlotInfo = cell->schUlSlotInfo[pucchSlot];
+       memset(&schUlSlotInfo->schPucchInfo, 0, sizeof(SchPucchInfo));
+
+       schUlSlotInfo->pucchPres = true;
+       schUlSlotInfo->schPucchInfo.rnti = crnti;
+
+   return ROK;
+}
+
 /**********************************************************************
   End of file
  **********************************************************************/