Docs and build updates along with prachCfgTableIdx completion
[o-du/l2.git] / src / 5gnrsch / sch_common.c
index 0503785..6931f7c 100644 (file)
@@ -82,8 +82,7 @@ SchMacUlSchInfoFunc schMacUlSchInfoOpts[] =
  *     
  *     This function handles common scheduling for DL
  *     
- *  @param[in]  schCellCb *cell, cell cb
- *  @param[in]  DlBrdcstAlloc *dlBrdcstAlloc, DL brdcst allocation
+ *  @param[in]  uint8_t scs, uint8_t *ssbStartSym
  *  @return  void
  **/
 void ssbDlTdAlloc(uint8_t scs, uint8_t *ssbStartSymb)
@@ -114,7 +113,7 @@ void ssbDlTdAlloc(uint8_t scs, uint8_t *ssbStartSymb)
  *
  * @details
  *
- *     Function : schCmnDlAlloc
+ *     Function : schBroadcastAlloc
  *     
  *     This function handles common scheduling for DL
  *     
@@ -122,7 +121,8 @@ void ssbDlTdAlloc(uint8_t scs, uint8_t *ssbStartSymb)
  *  @param[in]  DlBrdcstAlloc *dlBrdcstAlloc, DL brdcst allocation
  *  @return  void
  **/
-uint8_t schCmnDlAlloc(SchCellCb *cell, DlBrdcstAlloc *dlBrdcstAlloc)
+uint8_t schBroadcastAlloc(SchCellCb *cell, DlBrdcstAlloc *dlBrdcstAlloc,
+        uint16_t slot)
 {
        /* schedule SSB */
        uint8_t scs, ssbStartPrb, ssbStartSymb, idx;
@@ -130,12 +130,11 @@ uint8_t schCmnDlAlloc(SchCellCb *cell, DlBrdcstAlloc *dlBrdcstAlloc)
        SchDlAlloc *dlAlloc;
        SsbInfo ssbInfo;
 
-       dlAlloc = cell->dlAlloc[cell->slotInfo.slot];
+       dlAlloc = cell->dlAlloc[slot];
        if(dlBrdcstAlloc->ssbTrans)
        {
                scs = cell->cellCfg.ssbSchCfg.scsCommon;
-               ssbStartPrb = \
-                  (cell->cellCfg.ssbSchCfg.ssbOffsetPointA)/SCH_NUM_SC_PRB;
+               ssbStartPrb = cell->cellCfg.ssbSchCfg.ssbOffsetPointA;
 
                memset(ssbStartSymbArr, 0, SCH_MAX_SSB_BEAM);
                ssbDlTdAlloc(scs, ssbStartSymbArr);
@@ -157,7 +156,7 @@ uint8_t schCmnDlAlloc(SchCellCb *cell, DlBrdcstAlloc *dlBrdcstAlloc)
                dlAlloc->ssbIdxSupported = dlBrdcstAlloc->ssbIdxSupported;
                for(idx=ssbStartSymb; idx<ssbStartSymb+SCH_SSB_SYMB_DURATION; idx++)
                {
-                       dlAlloc->assignedPrb[idx] = SCH_SSB_PRB_DURATION + 1; /* +1 for kSsb */
+                       dlAlloc->assignedPrb[idx] = ssbStartPrb + SCH_SSB_PRB_DURATION + 1; /* +1 for kSsb */
                }
 
        }
@@ -165,8 +164,13 @@ uint8_t schCmnDlAlloc(SchCellCb *cell, DlBrdcstAlloc *dlBrdcstAlloc)
        /* SIB1 allocation */
        if(dlBrdcstAlloc->sib1Trans)
        {
-          memcpy(&dlBrdcstAlloc->sib1Alloc.sib1PdcchCfg, &cell->cellCfg.sib1SchCfg.sib1PdcchCfg, sizeof(Sib1PdcchCfg)); 
-          memcpy(&dlBrdcstAlloc->sib1Alloc.sib1PdschCfg, &cell->cellCfg.sib1SchCfg.sib1PdschCfg, sizeof(Sib1PdschCfg)); 
+               dlAlloc->sib1Pres = true;
+               for(idx=0; idx<SCH_SYMBOL_PER_SLOT; idx++)
+               {
+                       dlAlloc->assignedPrb[idx] = ssbStartPrb + SCH_SSB_PRB_DURATION + 1 + 10; /* 10 PRBs for sib1 */
+               }
+          memcpy(&dlBrdcstAlloc->sib1Alloc.sib1PdcchCfg, &cell->cellCfg.sib1SchCfg.sib1PdcchCfg, sizeof(PdcchCfg)); 
+          memcpy(&dlBrdcstAlloc->sib1Alloc.sib1PdschCfg, &cell->cellCfg.sib1SchCfg.sib1PdschCfg, sizeof(PdschCfg)); 
        }
        return ROK;
 }
@@ -213,11 +217,11 @@ int sendUlSchInfoToMac(UlSchInfo *ulSchInfo, Inst inst)
  **/
 int schPrachResAlloc(SchCellCb *cell, UlSchInfo *ulSchInfo)
 {
-   uint8_t  numPrachRb;
-       uint8_t  numRa;
-       uint8_t  freqStart;
-       uint16_t sfn;
-       uint16_t slot;
+   uint8_t  numPrachRb = 0;
+       uint8_t  numRa = 0;
+       uint8_t  freqStart = 0;
+       uint16_t sfn = 0;
+       uint16_t slot = 0;
        uint8_t  prachCfgIdx = 0;
        uint8_t  prachFormat = 0;
        uint8_t  x = 0;
@@ -265,6 +269,7 @@ int schPrachResAlloc(SchCellCb *cell, UlSchInfo *ulSchInfo)
                           break;
                }
                numPrachRb = numRbForPrachTable[idx][3];
+               dataType |= SCH_DATATYPE_PRACH;
                /* Considering first slot in the frame for PRACH */
                idx = 0;
                ulAlloc->assignedPrb[idx] = freqStart+numPrachRb;
@@ -274,7 +279,7 @@ int schPrachResAlloc(SchCellCb *cell, UlSchInfo *ulSchInfo)
        ulSchInfo->cellId = cell->cellId;
        ulSchInfo->slotIndInfo.sfn = sfn;
    ulSchInfo->slotIndInfo.slot = slot;
-       ulSchInfo->dataType = dataType | SCH_DATATYPE_PRACH;
+       ulSchInfo->dataType = dataType;
        /* prach info */
        ulSchInfo->prachSchInfo.numPrachOcas   = prachOcas;
        ulSchInfo->prachSchInfo.prachFormat    = prachFormat;
@@ -296,7 +301,7 @@ int schPrachResAlloc(SchCellCb *cell, UlSchInfo *ulSchInfo)
  *  @param[in]  SchCellCb *cell, cellCb
  *  @return  void
  **/
-int schUlResAlloc(SchCellCb *cell, Inst schInst)
+uint8_t schUlResAlloc(SchCellCb *cell, Inst schInst)
 {
    int ret = ROK;
    UlSchInfo ulSchInfo;