Rach Indication
[o-du/l2.git] / src / 5gnrsch / sch.c
index ebeb195..a377201 100644 (file)
 #include "sch.h"
 #include "sch_utils.h"
 #include "du_log.h"
-
 extern SchCb schCb[SCH_MAX_INST];
 extern int8_t coresetIdxTable[MAX_CORESET_INDEX][4];
 extern int8_t searchSpaceIdxTable[MAX_SEARCH_SPACE_INDEX][4];
+void SchFillCfmPst(Pst *reqPst,Pst *cfmPst,RgMngmt *cfm);
 /* local defines */
 SchCellCfgCfmFunc SchCellCfgCfmOpts[] = 
 {
@@ -306,6 +306,28 @@ SlotIndInfo         *slotInd
    RETVALUE(ROK);
 }  /* macSchSlotInd */
 
+/*******************************************************************
+ *
+ * @brief Processes Rach indication from MAC 
+ *
+ * @details
+ *
+ *    Function : macSchRachInd
+ *
+ *    Functionality:
+ *      Processes Rach indication from MAC
+ *
+ * @params[in] 
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+int macSchRachInd(Pst *pst, RachIndInfo *rachInd)
+{
+   DU_LOG("\nSCH : Received Rach indication");
+   return ROK;
+}
+
 /**
  * @brief inti cellCb based on cellCfg
  *
@@ -347,6 +369,9 @@ int InitSchCellCb(Inst inst, SchCellCfg *schCellCfg)
    for(uint8_t idx=0; idx<SCH_NUM_SLOTS; idx++)
        {
                SchDlAlloc *schDlAlloc;
+               SchUlAlloc *schUlAlloc;
+
+      /* DL Alloc */
                SCH_ALLOC(schDlAlloc, sizeof(SchDlAlloc));
                if(!schDlAlloc)
                {
@@ -354,29 +379,41 @@ int InitSchCellCb(Inst inst, SchCellCfg *schCellCfg)
                        return RFAILED;
                }
 
-      schDlAlloc->totalPrb = MAX_NUM_RB;
+      /* UL Alloc */
+               SCH_ALLOC(schUlAlloc, sizeof(SchUlAlloc));
+               if(!schUlAlloc)
+               {
+                       DU_LOG("\nMemory allocation failed in InitSchCellCb");
+                       return RFAILED;
+               }
 
-               for(uint8_t itr=0; itr<MAX_SSB_IDX; itr++)
+      schDlAlloc->totalPrb = schUlAlloc->totalPrb = MAX_NUM_RB;
+
+               for(uint8_t itr=0; itr<SCH_SYMBOL_PER_SLOT; itr++)
                {
                        schDlAlloc->assignedPrb[itr] = 0;
+                       schUlAlloc->assignedPrb[itr] = 0;
                }
+
                for(uint8_t itr=0; itr<MAX_SSB_IDX; itr++)
                {
                        memset(&schDlAlloc->ssbInfo[itr], 0, sizeof(SsbInfo));
                }
 
                cell->dlAlloc[idx] = schDlAlloc;
+               cell->ulAlloc[idx] = schUlAlloc;
+
        }
-       schCb[inst].cells[inst] = cell; //Sphoorthi TODO: check if this works
+       schCb[inst].cells[inst] = cell;
 
    DU_LOG("\nCell init completed for cellId:%d", cell->cellId);
 
    return ROK;   
 }
 
-void fillSib1SchCfg(
+void fillSchSib1Cfg(
 Inst         schInst,
-Sib1SchCfg   *sib1SchCfg,
+SchSib1Cfg   *sib1SchCfg,
 uint8_t      pci,
 uint8_t      offsetPointA
 )
@@ -421,13 +458,14 @@ uint8_t      offsetPointA
    sib1SchCfg->n0 = slotIndex;
  
    /* calculate the PRBs */
-   freqDomResourceAlloc((offsetPointA-offset),numRbs,FreqDomainResource);
+   freqDomResourceAlloc( ((offsetPointA-offset)/6), (numRbs/6), FreqDomainResource);
 
    /* fill the PDCCH PDU */
    pdcch->sib1PdcchBwpCfg.BWPSize = MAX_NUM_RB; /* whole of BW */
    pdcch->sib1PdcchBwpCfg.BWPStart = 0;
-   pdcch->subcarrierSpacing = 0;         /* 15Khz */
-   pdcch->cyclicPrefix = 0;              /* normal */
+   pdcch->sib1PdcchBwpCfg.subcarrierSpacing = 0;         /* 15Khz */
+   pdcch->sib1PdcchBwpCfg.cyclicPrefix = 0;              /* normal */
+   pdcch->sib1Coreset0Cfg.coreSet0Size = numRbs;
    pdcch->sib1Coreset0Cfg.startSymbolIndex = firstSymbol;
    pdcch->sib1Coreset0Cfg.durationSymbols = numSymbols;
    memcpy(pdcch->sib1Coreset0Cfg.freqDomainResource,FreqDomainResource,6);
@@ -450,6 +488,9 @@ uint8_t      offsetPointA
    pdcch->sib1DlDci.beamPdcchInfo.prg[0].beamIdx[0] = 0;
    pdcch->sib1DlDci.txPdcchPower.powerValue = 0;
    pdcch->sib1DlDci.txPdcchPower.powerControlOffsetSS = 0;
+       /* Storing pdschCfg pointer here. Required to access pdsch config while
+       fillig up pdcch pdu */
+   pdcch->sib1DlDci.pdschCfg = pdsch; 
 
    /* fill the PDSCH PDU */
        uint8_t cwCount = 0;
@@ -486,6 +527,7 @@ uint8_t      offsetPointA
         * Nre = min(156,Nre') . nPrb                                     */
    pdsch->sib1FreqAlloc.rbSize = 10; /* This value is calculated from above formulae */
    pdsch->sib1FreqAlloc.vrbPrbMapping = 0; /* non-interleaved */
+   pdsch->sib1TimeAlloc.rowIndex = 1;
    pdsch->sib1TimeAlloc.startSymbolIndex = 2; /* spec-38.214, Table 5.1.2.1-1 */
    pdsch->sib1TimeAlloc.numSymbols = 12;
    pdsch->beamPdschInfo.numPrgs = 1;
@@ -528,14 +570,14 @@ SchCellCfg          *schCellCfg
        InitSchCellCb(inst, schCellCfg);
        cellCb = schCb[inst].cells[inst]; //cells is of MAX_CELLS, why inst
    cellCb->macInst = pst->srcInst;
-   memcpy(&cellCb->cellCfg, schCellCfg, sizeof(SchCellCfg));
 
    /* derive the SIB1 config parameters */
-       fillSib1SchCfg(
+       fillSchSib1Cfg(
           inst,
           &(schCellCfg->sib1SchCfg),
                schCellCfg->phyCellId,
                schCellCfg->ssbSchCfg.ssbOffsetPointA);
+   memcpy(&cellCb->cellCfg, schCellCfg, sizeof(SchCellCfg));
 
    memset(&rspPst, 0, sizeof(Pst));
    SCH_FILL_RSP_PST(rspPst, inst);