Addressing flow wise comments
[o-du/l2.git] / src / du_app / du_cfg.c
index f435a1c..3afa2c7 100644 (file)
@@ -180,25 +180,35 @@ S16 readMacCfg()
 
    /* PRACH configuration */
    duCfgParam.macCellCfg.prachCfg.pres = TRUE;
+       duCfgParam.macCellCfg.prachCfg.prachCfgIdx = PRACH_CONFIG_IDX;
    duCfgParam.macCellCfg.prachCfg.prachSeqLen = PRACH_SEQ_LEN;
    duCfgParam.macCellCfg.prachCfg.prachSubcSpacing = PRACH_SUBCARRIER_SPACING;
    duCfgParam.macCellCfg.prachCfg.prachRstSetCfg = PRACH_RESTRICTED_SET_CFG;
-   duCfgParam.macCellCfg.prachCfg.prachFdm = NUM_PRACH_FDM;
+   duCfgParam.macCellCfg.prachCfg.msg1Fdm = NUM_PRACH_FDM;
+       duCfgParam.macCellCfg.prachCfg.msg1FreqStart = PRACH_FREQ_START;
+       duCfgParam.macCellCfg.prachCfg.rootSeqLen    = ROOT_SEQ_LEN;
    duCfgParam.macCellCfg.prachCfg.fdm[0].rootSeqIdx = ROOT_SEQ_IDX;
    duCfgParam.macCellCfg.prachCfg.fdm[0].numRootSeq = NUM_ROOT_SEQ;
    duCfgParam.macCellCfg.prachCfg.fdm[0].k1 = 1;
    duCfgParam.macCellCfg.prachCfg.fdm[0].zeroCorrZoneCfg = ZERO_CORRELATION_ZONE_CFG;
    duCfgParam.macCellCfg.prachCfg.fdm[0].numUnusedRootSeq = NUM_UNUSED_ROOT_SEQ;
-   DU_ALLOC(duCfgParam.macCellCfg.prachCfg.fdm[0].unsuedRootSeq, NUM_UNUSED_ROOT_SEQ * sizeof(U8));
-   if(duCfgParam.macCellCfg.prachCfg.fdm[0].unsuedRootSeq == NULLP)
-   {
-      DU_LOG("\nDU_APP : Memory allocation failed");
-      RETVALUE(RFAILED);
-   }
-   *(duCfgParam.macCellCfg.prachCfg.fdm[0].unsuedRootSeq) = UNUSED_ROOT_SEQ;
+       if(duCfgParam.macCellCfg.prachCfg.fdm[0].numUnusedRootSeq != 0)
+       {
+               DU_ALLOC(duCfgParam.macCellCfg.prachCfg.fdm[0].unsuedRootSeq, 
+                               NUM_UNUSED_ROOT_SEQ * sizeof(U8));
+               if(duCfgParam.macCellCfg.prachCfg.fdm[0].unsuedRootSeq == NULLP)
+               {
+                       DU_LOG("\nDU_APP : Memory allocation failed");
+                       RETVALUE(RFAILED);
+               }
+               *(duCfgParam.macCellCfg.prachCfg.fdm[0].unsuedRootSeq) = UNUSED_ROOT_SEQ;
+       }
    duCfgParam.macCellCfg.prachCfg.ssbPerRach = SSB_PER_RACH;
    duCfgParam.macCellCfg.prachCfg.prachMultCarrBand = PRACH_MULT_CARRIER_BAND;
-
+   duCfgParam.macCellCfg.prachCfg.raContResTmr = RA_CONT_RES_TIMER;
+       duCfgParam.macCellCfg.prachCfg.rsrpThreshSsb = RSRP_THRESHOLD_SSB;
+       duCfgParam.macCellCfg.prachCfg.raRspWindow = RA_RSP_WINDOW;
+   duCfgParam.macCellCfg.prachCfg.prachRestrictedSet = PRACH_RESTRICTED_SET;
    /* TDD configuration */
    duCfgParam.macCellCfg.tddCfg.pres = TRUE;
    duCfgParam.macCellCfg.tddCfg.tddPeriod = TDD_PERIODICITY;
@@ -219,6 +229,51 @@ S16 readMacCfg()
    duCfgParam.macCellCfg.sib1Cfg.searchSpaceZeroIndex = SEARCHSPACE_0_INDEX;
    duCfgParam.macCellCfg.sib1Cfg.sib1Mcs = SIB1_MCS;
 
+
+   /* fill Intial DL BWP */
+   duCfgParam.macCellCfg.initialDlBwp.bwp.firstPrb = 0;
+   duCfgParam.macCellCfg.initialDlBwp.bwp.numPrb = TOTAL_PRB_BW; /* configured to total BW */
+   duCfgParam.macCellCfg.initialDlBwp.bwp.scs = SUBCARRIER_SPACING; /* numerology is 0, 15Khz */
+   duCfgParam.macCellCfg.initialDlBwp.bwp.cyclicPrefix = NORMAL_CYCLIC_PREFIX;
+   duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.searchSpaceId = SEARCHSPACE_1_INDEX;
+   duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.coresetId = CORESET_0_INDEX;
+   duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.monitoringSlot =
+          SS_MONITORING_SLOT_SL1; /* sl1 - all slots */
+   duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.duration = 0;
+   duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.monitoringSymbol =
+          SS_MONITORING_SYMBOL;
+   duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
+          candidate.aggLevel1  = 8;
+   duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
+          candidate.aggLevel2  = 4;
+   duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
+          candidate.aggLevel4  = 2;
+   duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
+          candidate.aggLevel8  = 1;
+   duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
+          candidate.aggLevel16 = 0;
+   duCfgParam.macCellCfg.initialDlBwp.pdschCommon.k0 = PDSCH_K0;
+       duCfgParam.macCellCfg.initialDlBwp.pdschCommon.mappingType = 
+          PDSCH_MAPPING_TYPE_A;
+       duCfgParam.macCellCfg.initialDlBwp.pdschCommon.startSymbol = 
+          PDSCH_START_SYMBOL;
+       duCfgParam.macCellCfg.initialDlBwp.pdschCommon.lengthSymbol =
+          PDSCH_LENGTH_SYMBOL;
+       /* ra-searchSpace ID is set to 1 */
+   duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.raSearchSpaceId = SEARCHSPACE_1_INDEX;
+   /* fill Intial UL BWP */
+   duCfgParam.macCellCfg.initialUlBwp.bwp.firstPrb = 0;
+   duCfgParam.macCellCfg.initialUlBwp.bwp.numPrb = TOTAL_PRB_BW; /* configured to total BW */
+   duCfgParam.macCellCfg.initialUlBwp.bwp.scs = SUBCARRIER_SPACING; /* numerology is 0, 15Khz */
+   duCfgParam.macCellCfg.initialUlBwp.bwp.cyclicPrefix = NORMAL_CYCLIC_PREFIX;
+   duCfgParam.macCellCfg.initialUlBwp.puschCommon.k2 = PUSCH_K2;
+       duCfgParam.macCellCfg.initialUlBwp.puschCommon.mappingType = 
+          PUSCH_MAPPING_TYPE_A;
+       duCfgParam.macCellCfg.initialUlBwp.puschCommon.startSymbol = 
+          PUSCH_START_SYMBOL;
+       duCfgParam.macCellCfg.initialUlBwp.puschCommon.lengthSymbol =
+          PUSCH_LENGTH_SYMBOL;
+
    /* This should be calculated based on
       (number of mandatory parameters) + (number of otional parameters being filled) */
    duCfgParam.macCellCfg.numTlv = 39;
@@ -250,6 +305,35 @@ S16 fillDuPort(U16 *duPort)
        RETVALUE(ROK);
 }
 
+/*******************************************************************
+*
+* @brief Configures the DU Parameters
+*
+* @details
+*
+*    Function : calcSliv
+*
+*    Functionality:
+*       - calculate SLIV value from start and length field
+*
+* @params[in] start symbol
+* @params[in] length of symbols
+* @return SLIV value
+*
+* ****************************************************************/
+uint16_t calcSliv(uint8_t startSymbol, uint8_t lengthSymbol)
+{
+   uint16_t sliv = 0;
+       if((lengthSymbol-1) <= 7)
+       {
+          sliv = 14 * (lengthSymbol-1) + startSymbol;
+       }
+       else
+       {
+          sliv = 14 * (14-lengthSymbol+1) + (14-1-startSymbol);
+       }
+       return sliv;
+}
 
 
 /*******************************************************************
@@ -315,7 +399,7 @@ S16 fillServCellCfgCommSib(SrvCellCfgCommSib *srvCellCfgComm)
    pdschCfg.k0 = PDSCH_K0;
    pdschCfg.mapType = \
       PDSCH_TimeDomainResourceAllocation__mappingType_typeA;
-   pdschCfg.startSymbAndLen = PDSCH_START_SYMB_AND_LEN;
+   pdschCfg.sliv = calcSliv(PDSCH_START_SYMBOL,PDSCH_LENGTH_SYMBOL);
    srvCellCfgComm->dlCfg.pdschCfg = pdschCfg;
 
    /* Configuring BCCH Config for SIB1 */
@@ -361,9 +445,9 @@ S16 fillServCellCfgCommSib(SrvCellCfgCommSib *srvCellCfgComm)
 
    /* Configuring PUSCH Config Common for SIB1 */
    puschCfg.present = BWP_UplinkCommon__pusch_ConfigCommon_PR_setup;
-   puschCfg.k2 = PUSCH_K0;
+   puschCfg.k2 = PUSCH_K2;
    puschCfg.mapType = PUSCH_TimeDomainResourceAllocation__mappingType_typeA;
-   puschCfg.startSymbAndLen = PUSCH_START_SYMB_AND_LEN;
+   puschCfg.sliv = calcSliv(PUSCH_START_SYMBOL,PUSCH_LENGTH_SYMBOL);
    puschCfg.msg3DeltaPreamble = PUSCH_MSG3_DELTA_PREAMBLE;
    puschCfg.p0NominalWithGrant = PUSCH_P0_NOMINAL_WITH_GRANT;
    srvCellCfgComm->ulCfg.puschCfg = puschCfg;
@@ -618,8 +702,8 @@ S16 readCfg()
          DU_LOG("\nDU_APP: Memory allocation failure");
                        return RFAILED;
                }
-               strcpy(duCfgParam.srvdCellLst[i].duSysInfo.mibMsg, encBuf);
-                duCfgParam.srvdCellLst[i].duSysInfo.mibLen = encBufSize;
+      strcpy((char *)duCfgParam.srvdCellLst[i].duSysInfo.mibMsg, encBuf);
+      duCfgParam.srvdCellLst[i].duSysInfo.mibLen = encBufSize;
 
       /*gnb DU System Info mib msg*/
       BuildSib1Msg();