RAR_message 70/3470/1
authorBalaji Shankaran <balaji.shankaran@radisys.com>
Sun, 26 Apr 2020 22:18:33 +0000 (03:48 +0530)
committerBalaji Shankaran <balaji.shankaran@radisys.com>
Sun, 26 Apr 2020 22:18:46 +0000 (03:48 +0530)
Change-Id: Iec71c4a99b19e17c9e5a511cc688c83c49bd7886
Signed-off-by: Balaji Shankaran <balaji.shankaran@radisys.com>
15 files changed:
src/5gnrmac/lwr_mac_fsm.c
src/5gnrmac/lwr_mac_fsm.h
src/5gnrmac/mac.h
src/5gnrmac/mac_mux.c [new file with mode: 0644]
src/5gnrmac/mac_rach.c
src/5gnrmac/mac_slot_ind.c
src/5gnrsch/sch.c
src/5gnrsch/sch.h
src/5gnrsch/sch_common.c
src/5gnrsch/sch_rach.c [new file with mode: 0644]
src/5gnrsch/sch_slot_ind.c
src/cm/mac_sch_interface.c
src/cm/mac_sch_interface.h
src/phy_stub/l1_bdy1.c
src/phy_stub/l1_bdy2.c

index 9e286b6..c0ba316 100644 (file)
@@ -2137,7 +2137,7 @@ S16 fillSsbPdu(fapi_dl_tti_req_pdu_t *dlTtiReqPdu, MacCellCfg *macCellCfg,
       dlTtiReqPdu->pduType = SSB_PDU_TYPE;     /* SSB PDU */
       dlTtiReqPdu->u.ssb_pdu.physCellId = macCellCfg->phyCellId;
       dlTtiReqPdu->u.ssb_pdu.betaPss = macCellCfg->ssbCfg.betaPss;
-      dlTtiReqPdu->u.ssb_pdu.ssbBlockIndex = currDlSlot->cellBroadcastInfo.ssbInfo[ssbIdxCount].ssbIdx;
+      dlTtiReqPdu->u.ssb_pdu.ssbBlockIndex = currDlSlot->dlInfo.brdcstAlloc.ssbInfo[ssbIdxCount].ssbIdx;
       dlTtiReqPdu->u.ssb_pdu.ssbSubCarrierOffset = macCellCfg->ssbCfg.ssbScOffset;
       /* ssbOfPdufstA to be filled in ssbCfg */
       dlTtiReqPdu->u.ssb_pdu.ssbOffsetPointA = macCellCfg->ssbCfg.ssbOffsetPointA;
@@ -2167,18 +2167,18 @@ S16 fillSsbPdu(fapi_dl_tti_req_pdu_t *dlTtiReqPdu, MacCellCfg *macCellCfg,
  *
  * @details
  *
- *    Function : fillDlDciPdu
+ *    Function : fillSib1DlDciPdu
  *
  *    Functionality:
  *         -Fills the Dl DCI PDU
  *
  * @params[in] Pointer to fapi_dl_dci_t
- *             Pointer to Sib1PdcchCfg
+ *             Pointer to PdcchCfg
  * @return ROK
  *
  ******************************************************************/
 
-void fillDlDciPdu(fapi_dl_dci_t *dlDciPtr, Sib1PdcchCfg *sib1PdcchInfo)
+void fillSib1DlDciPdu(fapi_dl_dci_t *dlDciPtr, PdcchCfg *sib1PdcchInfo)
 {
    if(dlDciPtr != NULLP)
    {
@@ -2207,18 +2207,18 @@ void fillDlDciPdu(fapi_dl_dci_t *dlDciPtr, Sib1PdcchCfg *sib1PdcchInfo)
       uint8_t sysInfoIndSize       = 1;
       uint8_t reservedSize         = 15;
 
-      dlDciPtr->rnti = sib1PdcchInfo->sib1DlDci.rnti;
-      dlDciPtr->scramblingId = sib1PdcchInfo->sib1DlDci.scramblingId;    
-      dlDciPtr->scramblingRnti = sib1PdcchInfo->sib1DlDci.scramblingRnti;
-      dlDciPtr->cceIndex = sib1PdcchInfo->sib1DlDci.cceIndex;
-      dlDciPtr->aggregationLevel = sib1PdcchInfo->sib1DlDci.aggregLevel;
-      dlDciPtr->pc_and_bform.numPrgs = sib1PdcchInfo->sib1DlDci.beamPdcchInfo.numPrgs;
-      dlDciPtr->pc_and_bform.prgSize = sib1PdcchInfo->sib1DlDci.beamPdcchInfo.prgSize;
-      dlDciPtr->pc_and_bform.digBfInterfaces = sib1PdcchInfo->sib1DlDci.beamPdcchInfo.digBfInterfaces;
-      dlDciPtr->pc_and_bform.pmi_bfi[0].pmIdx = sib1PdcchInfo->sib1DlDci.beamPdcchInfo.prg[0].pmIdx;
-      dlDciPtr->pc_and_bform.pmi_bfi[0].beamIdx[0].beamidx = sib1PdcchInfo->sib1DlDci.beamPdcchInfo.prg[0].beamIdx[0];
-      dlDciPtr->beta_pdcch_1_0 = sib1PdcchInfo->sib1DlDci.txPdcchPower.powerValue;           
-      dlDciPtr->powerControlOfssetSS = sib1PdcchInfo->sib1DlDci.txPdcchPower.powerControlOffsetSS;
+      dlDciPtr->rnti = sib1PdcchInfo->dci.rnti;
+      dlDciPtr->scramblingId = sib1PdcchInfo->dci.scramblingId;    
+      dlDciPtr->scramblingRnti = sib1PdcchInfo->dci.scramblingRnti;
+      dlDciPtr->cceIndex = sib1PdcchInfo->dci.cceIndex;
+      dlDciPtr->aggregationLevel = sib1PdcchInfo->dci.aggregLevel;
+      dlDciPtr->pc_and_bform.numPrgs = sib1PdcchInfo->dci.beamPdcchInfo.numPrgs;
+      dlDciPtr->pc_and_bform.prgSize = sib1PdcchInfo->dci.beamPdcchInfo.prgSize;
+      dlDciPtr->pc_and_bform.digBfInterfaces = sib1PdcchInfo->dci.beamPdcchInfo.digBfInterfaces;
+      dlDciPtr->pc_and_bform.pmi_bfi[0].pmIdx = sib1PdcchInfo->dci.beamPdcchInfo.prg[0].pmIdx;
+      dlDciPtr->pc_and_bform.pmi_bfi[0].beamIdx[0].beamidx = sib1PdcchInfo->dci.beamPdcchInfo.prg[0].beamIdx[0];
+      dlDciPtr->beta_pdcch_1_0 = sib1PdcchInfo->dci.txPdcchPower.powerValue;           
+      dlDciPtr->powerControlOfssetSS = sib1PdcchInfo->dci.txPdcchPower.powerControlOffsetSS;
 
       /* Calculating freq domain resource allocation field value and size
        * coreset0Size = Size of coreset 0
@@ -2226,10 +2226,10 @@ void fillDlDciPdu(fapi_dl_dci_t *dlDciPtr, Sib1PdcchCfg *sib1PdcchInfo)
        * RBLen = length of contiguously allocted RBs
        * Spec 38.214 Sec 5.1.2.2.2
        */
-      coreset0Size= sib1PdcchInfo->sib1Coreset0Cfg.coreSet0Size;
+      coreset0Size= sib1PdcchInfo->coreset0Cfg.coreSet0Size;
                rbStart = 0;              /* For SIB1 */
-      //rbStart = sib1PdcchInfo->sib1DlDci.pdschCfg->sib1FreqAlloc.rbStart;
-      rbLen = sib1PdcchInfo->sib1DlDci.pdschCfg->sib1FreqAlloc.rbSize;
+      //rbStart = sib1PdcchInfo->dci.pdschCfg->freqAlloc.rbStart;
+      rbLen = sib1PdcchInfo->dci.pdschCfg->freqAlloc.rbSize;
 
       if((rbLen >=1) && (rbLen <= coreset0Size - rbStart))
       {
@@ -2243,12 +2243,12 @@ void fillDlDciPdu(fapi_dl_dci_t *dlDciPtr, Sib1PdcchCfg *sib1PdcchInfo)
       }
 
       /* Fetching DCI field values */
-      timeDomResAssign = sib1PdcchInfo->sib1DlDci.pdschCfg->sib1TimeAlloc.
+      timeDomResAssign = sib1PdcchInfo->dci.pdschCfg->timeAlloc.
                          rowIndex -1;
-      VRB2PRBMap       = sib1PdcchInfo->sib1DlDci.pdschCfg->sib1FreqAlloc.\
+      VRB2PRBMap       = sib1PdcchInfo->dci.pdschCfg->freqAlloc.\
                          vrbPrbMapping;
-      modNCodScheme    = sib1PdcchInfo->sib1DlDci.pdschCfg->codeword[0].mcsIndex;
-      redundancyVer    = sib1PdcchInfo->sib1DlDci.pdschCfg->codeword[0].rvIndex;
+      modNCodScheme    = sib1PdcchInfo->dci.pdschCfg->codeword[0].mcsIndex;
+      redundancyVer    = sib1PdcchInfo->dci.pdschCfg->codeword[0].rvIndex;
       sysInfoInd       = 0;           /* 0 for SIB1; 1 for SI messages */
       reserved         = 0;
 
@@ -2259,7 +2259,6 @@ void fillDlDciPdu(fapi_dl_dci_t *dlDciPtr, Sib1PdcchCfg *sib1PdcchInfo)
       modNCodScheme    = reverseBits(modNCodScheme, modNCodSchemeSize);
       redundancyVer    = reverseBits(redundancyVer, redundancyVerSize);
       sysInfoInd       = reverseBits(sysInfoInd, sysInfoIndSize);
-      reserved         = reverseBits(reserved, reservedSize);
 
      /* Calulating total number of bytes in buffer */
      dlDciPtr->payloadSizeBits = freqDomResAssignSize + timeDomResAssignSize\
@@ -2300,7 +2299,138 @@ void fillDlDciPdu(fapi_dl_dci_t *dlDciPtr, Sib1PdcchCfg *sib1PdcchInfo)
         reserved, reservedSize);
 
    }
-} /* fillDlDciPdu */
+} /* fillSib1DlDciPdu */
+
+/*******************************************************************
+ *
+ * @brief fills Dl DCI PDU required for DL TTI info in MAC
+ *
+ * @details
+ *
+ *    Function : fillRarDlDciPdu
+ *
+ *    Functionality:
+ *         -Fills the Dl DCI PDU
+ *
+ * @params[in] Pointer to fapi_dl_dci_t
+ *             Pointer to PdcchCfg
+ * @return ROK
+ *
+ ******************************************************************/
+
+void fillRarDlDciPdu(fapi_dl_dci_t *dlDciPtr, PdcchCfg *rarPdcchInfo)
+{
+       if(dlDciPtr != NULLP)
+       {
+               uint8_t numBytes;
+               uint8_t bytePos;
+               uint8_t bitPos;
+
+               uint16_t coreset0Size;
+               uint16_t rbStart;
+               uint16_t rbLen;
+               uint32_t freqDomResAssign;
+               uint8_t timeDomResAssign;
+               uint8_t  VRB2PRBMap;
+               uint8_t modNCodScheme;
+               uint8_t tbScaling;
+               uint32_t reserved;
+
+               /* Size(in bits) of each field in DCI format 1_0 */
+               uint8_t freqDomResAssignSize;
+               uint8_t timeDomResAssignSize = 4;
+               uint8_t VRB2PRBMapSize       = 1;
+               uint8_t modNCodSchemeSize    = 5;
+               uint8_t tbScalingSize        = 2;
+               uint8_t reservedSize         = 16;
+
+               dlDciPtr->rnti = rarPdcchInfo->dci.rnti;
+               dlDciPtr->scramblingId = rarPdcchInfo->dci.scramblingId;    
+               dlDciPtr->scramblingRnti = rarPdcchInfo->dci.scramblingRnti;
+               dlDciPtr->cceIndex = rarPdcchInfo->dci.cceIndex;
+               dlDciPtr->aggregationLevel = rarPdcchInfo->dci.aggregLevel;
+               dlDciPtr->pc_and_bform.numPrgs = rarPdcchInfo->dci.beamPdcchInfo.numPrgs;
+               dlDciPtr->pc_and_bform.prgSize = rarPdcchInfo->dci.beamPdcchInfo.prgSize;
+               dlDciPtr->pc_and_bform.digBfInterfaces = rarPdcchInfo->dci.beamPdcchInfo.digBfInterfaces;
+               dlDciPtr->pc_and_bform.pmi_bfi[0].pmIdx = rarPdcchInfo->dci.beamPdcchInfo.prg[0].pmIdx;
+               dlDciPtr->pc_and_bform.pmi_bfi[0].beamIdx[0].beamidx = rarPdcchInfo->dci.beamPdcchInfo.prg[0].beamIdx[0];
+               dlDciPtr->beta_pdcch_1_0 = rarPdcchInfo->dci.txPdcchPower.powerValue;           
+               dlDciPtr->powerControlOfssetSS = rarPdcchInfo->dci.txPdcchPower.powerControlOffsetSS;
+
+               /* Calculating freq domain resource allocation field value and size
+                * coreset0Size = Size of coreset 0
+                * RBStart = Starting Virtual Rsource block
+                * RBLen = length of contiguously allocted RBs
+                * Spec 38.214 Sec 5.1.2.2.2
+                */
+
+               /* TODO: Fill values of coreset0Size, rbStart and rbLen */
+               coreset0Size= rarPdcchInfo->coreset0Cfg.coreSet0Size;
+               rbStart = 0;              /* For SIB1 */
+               //rbStart = rarPdcchInfo->dci.pdschCfg->freqAlloc.rbStart;
+               rbLen = rarPdcchInfo->dci.pdschCfg->freqAlloc.rbSize;
+
+               if((rbLen >=1) && (rbLen <= coreset0Size - rbStart))
+               {
+                       if((rbLen - 1) <= floor(coreset0Size / 2))
+                               freqDomResAssign = (coreset0Size * (rbLen-1)) + rbStart;
+                       else
+                               freqDomResAssign = (coreset0Size * (coreset0Size - rbLen + 1)) \
+                                                                                + (coreset0Size - 1 - rbStart);
+
+                       freqDomResAssignSize = ceil(log2(coreset0Size * (coreset0Size + 1) / 2));
+               }
+
+               /* Fetching DCI field values */
+               timeDomResAssign = rarPdcchInfo->dci.pdschCfg->timeAlloc.rowIndex -1;
+               VRB2PRBMap       = rarPdcchInfo->dci.pdschCfg->freqAlloc.vrbPrbMapping;
+               modNCodScheme    = rarPdcchInfo->dci.pdschCfg->codeword[0].mcsIndex;
+               tbScaling        = 0; /* configured to 0 scaling */
+               reserved         = 0;
+
+               /* Reversing bits in each DCI field */
+               freqDomResAssign = reverseBits(freqDomResAssign, freqDomResAssignSize);
+               timeDomResAssign = reverseBits(timeDomResAssign, timeDomResAssignSize);
+               VRB2PRBMap       = reverseBits(VRB2PRBMap, VRB2PRBMapSize);
+               modNCodScheme    = reverseBits(modNCodScheme, modNCodSchemeSize);
+               tbScaling        = reverseBits(tbScaling, tbScalingSize); 
+
+               /* Calulating total number of bytes in buffer */
+               dlDciPtr->payloadSizeBits = freqDomResAssignSize + timeDomResAssignSize\
+                                                                                        + VRB2PRBMapSize + modNCodSchemeSize + tbScalingSize + reservedSize;
+
+               numBytes = dlDciPtr->payloadSizeBits / 8;
+               if(dlDciPtr->payloadSizeBits % 8)
+                       numBytes += 1;
+
+               if(numBytes > DCI_PAYLOAD_BYTE_LEN)
+               {
+                       DU_LOG("\nLOWER MAC : Total bytes for DCI is more than expected");
+                       return;
+               }
+
+               /* Initialize buffer */
+               for(bytePos = 0; bytePos < numBytes; bytePos++)
+                       dlDciPtr->payload[bytePos] = 0;
+
+               bytePos = numBytes - 1;
+               bitPos = 0;
+
+               /* Packing DCI format fields */
+               fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
+                               freqDomResAssign, freqDomResAssignSize);
+               fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
+                               timeDomResAssign, timeDomResAssignSize);
+               fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
+                               VRB2PRBMap, VRB2PRBMapSize);
+               fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
+                               modNCodScheme, modNCodSchemeSize);
+               fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
+                               tbScaling, tbScalingSize);
+               fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
+                               reserved, reservedSize);
+       }
+} /* fillRarDlDciPdu */
 
 /*******************************************************************
  *
@@ -2315,38 +2445,46 @@ void fillDlDciPdu(fapi_dl_dci_t *dlDciPtr, Sib1PdcchCfg *sib1PdcchInfo)
  *          stored in MAC
  *
  * @params[in] Pointer to FAPI DL TTI Req
- *             Pointer to Sib1PdcchCfg
+ *             Pointer to PdcchCfg
  *             Pointer to msgLen of DL TTI Info
  * @return ROK
  *
  ******************************************************************/
 
-S16 fillPdcchPdu(fapi_dl_tti_req_pdu_t *dlTtiReqPdu, Sib1PdcchCfg *sib1PdcchInfo,
+S16 fillPdcchPdu(fapi_dl_tti_req_pdu_t *dlTtiReqPdu, PdcchCfg *pdcchInfo,
 uint32_t *msgLen)
 {
     if(dlTtiReqPdu != NULLP)
     {
        dlTtiReqPdu->pduType = PDCCH_PDU_TYPE;
-       dlTtiReqPdu->u.pdcch_pdu.bwpSize = sib1PdcchInfo->sib1PdcchBwpCfg.BWPSize;
-       dlTtiReqPdu->u.pdcch_pdu.bwpPart = sib1PdcchInfo->sib1PdcchBwpCfg.BWPStart;
-       dlTtiReqPdu->u.pdcch_pdu.subCarrierSpacing = sib1PdcchInfo->sib1PdcchBwpCfg.subcarrierSpacing; 
-       dlTtiReqPdu->u.pdcch_pdu.cyclicPrefix = sib1PdcchInfo->sib1PdcchBwpCfg.cyclicPrefix; 
-       dlTtiReqPdu->u.pdcch_pdu.startSymbolIndex = sib1PdcchInfo->sib1Coreset0Cfg.startSymbolIndex;
-       dlTtiReqPdu->u.pdcch_pdu.durationSymbols = sib1PdcchInfo->sib1Coreset0Cfg.durationSymbols;
-       memcpy(dlTtiReqPdu->u.pdcch_pdu.freqDomainResource, sib1PdcchInfo->sib1Coreset0Cfg.freqDomainResource, 6);
-       dlTtiReqPdu->u.pdcch_pdu.cceRegMappingType = sib1PdcchInfo->sib1Coreset0Cfg.cceRegMappingType;
-       dlTtiReqPdu->u.pdcch_pdu.regBundleSize = sib1PdcchInfo->sib1Coreset0Cfg.regBundleSize;
-       dlTtiReqPdu->u.pdcch_pdu.interleaverSize = sib1PdcchInfo->sib1Coreset0Cfg.interleaverSize;
-       dlTtiReqPdu->u.pdcch_pdu.coreSetSize = sib1PdcchInfo->sib1Coreset0Cfg.coreSetType;
-       dlTtiReqPdu->u.pdcch_pdu.shiftIndex =  sib1PdcchInfo->sib1Coreset0Cfg.shiftIndex;
-       dlTtiReqPdu->u.pdcch_pdu.precoderGranularity = sib1PdcchInfo->sib1Coreset0Cfg.precoderGranularity;
-       dlTtiReqPdu->u.pdcch_pdu.numDlDci = sib1PdcchInfo->numDlDci;
+       dlTtiReqPdu->u.pdcch_pdu.bwpSize = pdcchInfo->pdcchBwpCfg.BWPSize;
+       dlTtiReqPdu->u.pdcch_pdu.bwpPart = pdcchInfo->pdcchBwpCfg.BWPStart;
+       dlTtiReqPdu->u.pdcch_pdu.subCarrierSpacing = pdcchInfo->pdcchBwpCfg.subcarrierSpacing; 
+       dlTtiReqPdu->u.pdcch_pdu.cyclicPrefix = pdcchInfo->pdcchBwpCfg.cyclicPrefix; 
+       dlTtiReqPdu->u.pdcch_pdu.startSymbolIndex = pdcchInfo->coreset0Cfg.startSymbolIndex;
+       dlTtiReqPdu->u.pdcch_pdu.durationSymbols = pdcchInfo->coreset0Cfg.durationSymbols;
+       memcpy(dlTtiReqPdu->u.pdcch_pdu.freqDomainResource, pdcchInfo->coreset0Cfg.freqDomainResource, 6);
+       dlTtiReqPdu->u.pdcch_pdu.cceRegMappingType = pdcchInfo->coreset0Cfg.cceRegMappingType;
+       dlTtiReqPdu->u.pdcch_pdu.regBundleSize = pdcchInfo->coreset0Cfg.regBundleSize;
+       dlTtiReqPdu->u.pdcch_pdu.interleaverSize = pdcchInfo->coreset0Cfg.interleaverSize;
+       dlTtiReqPdu->u.pdcch_pdu.coreSetSize = pdcchInfo->coreset0Cfg.coreSetType;
+       dlTtiReqPdu->u.pdcch_pdu.shiftIndex =  pdcchInfo->coreset0Cfg.shiftIndex;
+       dlTtiReqPdu->u.pdcch_pdu.precoderGranularity = pdcchInfo->coreset0Cfg.precoderGranularity;
+       dlTtiReqPdu->u.pdcch_pdu.numDlDci = pdcchInfo->numDlDci;
 #ifdef INTEL_WLS       
        WLS_MEM_ALLOC(dlTtiReqPdu->u.pdcch_pdu.dlDci, sizeof(fapi_dl_dci_t));
 #else
        MAC_ALLOC(dlTtiReqPdu->u.pdcch_pdu.dlDci, sizeof(fapi_dl_dci_t));
 #endif
-       fillDlDciPdu(dlTtiReqPdu->u.pdcch_pdu.dlDci, sib1PdcchInfo);
+       if(pdcchInfo->dci.rnti == SI_RNTI)
+                {
+          fillSib1DlDciPdu(dlTtiReqPdu->u.pdcch_pdu.dlDci, pdcchInfo);
+       }
+                else
+                {
+          fillRarDlDciPdu(dlTtiReqPdu->u.pdcch_pdu.dlDci, pdcchInfo);
+                }
+
        dlTtiReqPdu->pduSize = sizeof(fapi_dl_pdcch_pdu_t);
        SETLENGTH(*msgLen, sizeof(fapi_dl_pdcch_pdu_t));
 
@@ -2368,13 +2506,13 @@ uint32_t *msgLen)
  *          stored in MAC
  *
  * @params[in] Pointer to FAPI DL TTI Req
- *             Pointer to Sib1PdschCfg
+ *             Pointer to PdschCfg
  *             Pointer to msgLen of DL TTI Info
  * @return ROK
  *
  ******************************************************************/
 
-void fillPdschPdu(fapi_dl_tti_req_pdu_t *dlTtiReqPdu, Sib1PdschCfg *sib1PdschInfo,
+void fillPdschPdu(fapi_dl_tti_req_pdu_t *dlTtiReqPdu, PdschCfg *pdschInfo,
 uint32_t *msgLen)
 {
     uint8_t idx;
@@ -2382,49 +2520,49 @@ uint32_t *msgLen)
     if(dlTtiReqPdu != NULLP)
     {
        dlTtiReqPdu->pduType = PDSCH_PDU_TYPE;
-       dlTtiReqPdu->u.pdsch_pdu.pduBitMap = sib1PdschInfo->pduBitmap;
-       dlTtiReqPdu->u.pdsch_pdu.rnti = sib1PdschInfo->rnti;         
-       dlTtiReqPdu->u.pdsch_pdu.pduIndex = sib1PdschInfo->pduIndex;
-       dlTtiReqPdu->u.pdsch_pdu.bwpSize = sib1PdschInfo->sib1PdschBwpCfg.BWPSize;       
-       dlTtiReqPdu->u.pdsch_pdu.bwpStart = sib1PdschInfo->sib1PdschBwpCfg.BWPStart;
-       dlTtiReqPdu->u.pdsch_pdu.subCarrierSpacing = sib1PdschInfo->sib1PdschBwpCfg.subcarrierSpacing;
-       dlTtiReqPdu->u.pdsch_pdu.cyclicPrefix = sib1PdschInfo->sib1PdschBwpCfg.cyclicPrefix;
-       dlTtiReqPdu->u.pdsch_pdu.nrOfCodeWords = sib1PdschInfo->numCodewords;
+       dlTtiReqPdu->u.pdsch_pdu.pduBitMap = pdschInfo->pduBitmap;
+       dlTtiReqPdu->u.pdsch_pdu.rnti = pdschInfo->rnti;         
+       dlTtiReqPdu->u.pdsch_pdu.pduIndex = pdschInfo->pduIndex;
+       dlTtiReqPdu->u.pdsch_pdu.bwpSize = pdschInfo->pdschBwpCfg.BWPSize;       
+       dlTtiReqPdu->u.pdsch_pdu.bwpStart = pdschInfo->pdschBwpCfg.BWPStart;
+       dlTtiReqPdu->u.pdsch_pdu.subCarrierSpacing = pdschInfo->pdschBwpCfg.subcarrierSpacing;
+       dlTtiReqPdu->u.pdsch_pdu.cyclicPrefix = pdschInfo->pdschBwpCfg.cyclicPrefix;
+       dlTtiReqPdu->u.pdsch_pdu.nrOfCodeWords = pdschInfo->numCodewords;
        for(idx = 0; idx < MAX_CODEWORDS ; idx++)
        { 
-          dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].targetCodeRate = sib1PdschInfo->codeword[idx].targetCodeRate;
-          dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].qamModOrder = sib1PdschInfo->codeword[idx].qamModOrder;
-          dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].mcsIndex = sib1PdschInfo->codeword[idx].mcsIndex;
-          dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].mcsTable = sib1PdschInfo->codeword[idx].mcsTable;
-          dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].rvIndex = sib1PdschInfo->codeword[idx].rvIndex;
-          dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].tbSize = sib1PdschInfo->codeword[idx].tbSize;
+          dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].targetCodeRate = pdschInfo->codeword[idx].targetCodeRate;
+          dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].qamModOrder = pdschInfo->codeword[idx].qamModOrder;
+          dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].mcsIndex = pdschInfo->codeword[idx].mcsIndex;
+          dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].mcsTable = pdschInfo->codeword[idx].mcsTable;
+          dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].rvIndex = pdschInfo->codeword[idx].rvIndex;
+          dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].tbSize = pdschInfo->codeword[idx].tbSize;
        }
-       dlTtiReqPdu->u.pdsch_pdu.dataScramblingId = sib1PdschInfo->dataScramblingId;       
-       dlTtiReqPdu->u.pdsch_pdu.nrOfLayers = sib1PdschInfo->numLayers;
-       dlTtiReqPdu->u.pdsch_pdu.transmissionScheme = sib1PdschInfo->transmissionScheme;
-       dlTtiReqPdu->u.pdsch_pdu.refPoint = sib1PdschInfo->refPoint;
-       dlTtiReqPdu->u.pdsch_pdu.dlDmrsSymbPos = sib1PdschInfo->dmrs.dlDmrsSymbPos;
-       dlTtiReqPdu->u.pdsch_pdu.dmrsConfigType = sib1PdschInfo->dmrs.dmrsConfigType;
-       dlTtiReqPdu->u.pdsch_pdu.dlDmrsScramblingId = sib1PdschInfo->dmrs.dlDmrsScramblingId;
-       dlTtiReqPdu->u.pdsch_pdu.scid = sib1PdschInfo->dmrs.scid;
-       dlTtiReqPdu->u.pdsch_pdu.numDmrsCdmGrpsNoData = sib1PdschInfo->dmrs.numDmrsCdmGrpsNoData;
-       dlTtiReqPdu->u.pdsch_pdu.dmrsPorts = sib1PdschInfo->dmrs.dmrsPorts;
-       dlTtiReqPdu->u.pdsch_pdu.resourceAlloc = sib1PdschInfo->sib1FreqAlloc.resourceAlloc;
+       dlTtiReqPdu->u.pdsch_pdu.dataScramblingId = pdschInfo->dataScramblingId;       
+       dlTtiReqPdu->u.pdsch_pdu.nrOfLayers = pdschInfo->numLayers;
+       dlTtiReqPdu->u.pdsch_pdu.transmissionScheme = pdschInfo->transmissionScheme;
+       dlTtiReqPdu->u.pdsch_pdu.refPoint = pdschInfo->refPoint;
+       dlTtiReqPdu->u.pdsch_pdu.dlDmrsSymbPos = pdschInfo->dmrs.dlDmrsSymbPos;
+       dlTtiReqPdu->u.pdsch_pdu.dmrsConfigType = pdschInfo->dmrs.dmrsConfigType;
+       dlTtiReqPdu->u.pdsch_pdu.dlDmrsScramblingId = pdschInfo->dmrs.dlDmrsScramblingId;
+       dlTtiReqPdu->u.pdsch_pdu.scid = pdschInfo->dmrs.scid;
+       dlTtiReqPdu->u.pdsch_pdu.numDmrsCdmGrpsNoData = pdschInfo->dmrs.numDmrsCdmGrpsNoData;
+       dlTtiReqPdu->u.pdsch_pdu.dmrsPorts = pdschInfo->dmrs.dmrsPorts;
+       dlTtiReqPdu->u.pdsch_pdu.resourceAlloc = pdschInfo->freqAlloc.resourceAlloc;
        /* since we are using type-1, hence rbBitmap excluded */
-       dlTtiReqPdu->u.pdsch_pdu.rbStart = sib1PdschInfo->sib1FreqAlloc.rbStart;
-       dlTtiReqPdu->u.pdsch_pdu.rbSize = sib1PdschInfo->sib1FreqAlloc.rbSize;
-       dlTtiReqPdu->u.pdsch_pdu.vrbToPrbMapping = sib1PdschInfo->sib1FreqAlloc.vrbPrbMapping;
-       dlTtiReqPdu->u.pdsch_pdu.startSymbIndex = sib1PdschInfo->sib1TimeAlloc.startSymbolIndex;
-       dlTtiReqPdu->u.pdsch_pdu.nrOfSymbols = sib1PdschInfo->sib1TimeAlloc.numSymbols;
-       dlTtiReqPdu->u.pdsch_pdu.preCodingAndBeamforming.numPrgs = sib1PdschInfo->beamPdschInfo.numPrgs;
-       dlTtiReqPdu->u.pdsch_pdu.preCodingAndBeamforming.prgSize = sib1PdschInfo->beamPdschInfo.prgSize;
-       dlTtiReqPdu->u.pdsch_pdu.preCodingAndBeamforming.digBfInterfaces = sib1PdschInfo->beamPdschInfo.digBfInterfaces;
+       dlTtiReqPdu->u.pdsch_pdu.rbStart = pdschInfo->freqAlloc.rbStart;
+       dlTtiReqPdu->u.pdsch_pdu.rbSize = pdschInfo->freqAlloc.rbSize;
+       dlTtiReqPdu->u.pdsch_pdu.vrbToPrbMapping = pdschInfo->freqAlloc.vrbPrbMapping;
+       dlTtiReqPdu->u.pdsch_pdu.startSymbIndex = pdschInfo->timeAlloc.startSymbolIndex;
+       dlTtiReqPdu->u.pdsch_pdu.nrOfSymbols = pdschInfo->timeAlloc.numSymbols;
+       dlTtiReqPdu->u.pdsch_pdu.preCodingAndBeamforming.numPrgs = pdschInfo->beamPdschInfo.numPrgs;
+       dlTtiReqPdu->u.pdsch_pdu.preCodingAndBeamforming.prgSize = pdschInfo->beamPdschInfo.prgSize;
+       dlTtiReqPdu->u.pdsch_pdu.preCodingAndBeamforming.digBfInterfaces = pdschInfo->beamPdschInfo.digBfInterfaces;
        dlTtiReqPdu->u.pdsch_pdu.preCodingAndBeamforming.pmi_bfi[0]. \
-          pmIdx = sib1PdschInfo->beamPdschInfo.prg[0].pmIdx;
+          pmIdx = pdschInfo->beamPdschInfo.prg[0].pmIdx;
        dlTtiReqPdu->u.pdsch_pdu.preCodingAndBeamforming.pmi_bfi[0]. \
-          beamIdx[0].beamidx = sib1PdschInfo->beamPdschInfo.prg[0].beamIdx[0];
-       dlTtiReqPdu->u.pdsch_pdu.powerControlOffset = sib1PdschInfo->txPdschPower.powerControlOffset;  
-       dlTtiReqPdu->u.pdsch_pdu.powerControlOffsetSS = sib1PdschInfo->txPdschPower.powerControlOffsetSS;
+          beamIdx[0].beamidx = pdschInfo->beamPdschInfo.prg[0].beamIdx[0];
+       dlTtiReqPdu->u.pdsch_pdu.powerControlOffset = pdschInfo->txPdschPower.powerControlOffset;  
+       dlTtiReqPdu->u.pdsch_pdu.powerControlOffsetSS = pdschInfo->txPdschPower.powerControlOffsetSS;
        dlTtiReqPdu->pduSize = sizeof(fapi_dl_pdsch_pdu_t);
        SETLENGTH(*msgLen, sizeof(fapi_dl_pdsch_pdu_t));
 
@@ -2447,24 +2585,136 @@ uint32_t *msgLen)
  * @return count
  *
  * ********************************************************************/
-uint8_t calculatePduCount(DlBrdcstAlloc *cellBroadcastInfo)
+uint8_t calculatePduCount(DlAlloc *dlInfo)
 {
    uint8_t count = 0;
    uint8_t idx = 0;
-   if(cellBroadcastInfo->ssbTrans)
-   {
-      for(idx = 0; idx < cellBroadcastInfo->ssbIdxSupported; idx++)
+       if(dlInfo->isBroadcastPres)
+       {
+      if(dlInfo->brdcstAlloc.ssbTrans)
       {
-         count++;
+         for(idx = 0; idx < dlInfo->brdcstAlloc.ssbIdxSupported; idx++)
+         {
+            count++;
+         }
+      }
+      if(dlInfo->brdcstAlloc.sib1Trans)
+      {
+         count += 2;
       }
    }
-   if(cellBroadcastInfo->sib1Trans)
-   {
-      count += 2;
-   }
+       if(dlInfo->isRarPres)
+       {
+          count += 2;
+       }
    return count;
 }
 
+/***********************************************************************
+ *
+ * @brief fills the SIB1 TX-DATA request message
+ *
+ * @details
+ *
+ *    Function : fillSib1TxDataReq
+ *
+ *    Functionality:
+ *         - fills the SIB1 TX-DATA request message
+ *
+ * @params[in]    fapi_tx_pdu_desc_t *pduDesc
+ * @params[in]    MacCellCfg *macCellCfg
+ * @params[in]    uint16_t pduIndex
+ * @params[in]    uint32_t *msgLen
+ * @return ROK
+ *
+ * ********************************************************************/
+uint8_t fillSib1TxDataReq(fapi_tx_pdu_desc_t *pduDesc,MacCellCfg *macCellCfg,
+   uint16_t pduIndex, uint32_t *msgLen)
+{
+   uint32_t pduLen = 0;
+       uint32_t *sib1TxdataValue = NULLP;
+
+       pduDesc->pduIndex = pduIndex;
+       pduDesc->numTlvs = 1;
+
+       /* fill the TLV */
+       /* as of now, memory is allocated from SSI, later WLS memory needs to be taken */
+       pduDesc->tlvs[0].tl.tag = 1; /* pointer to be sent */
+       pduDesc->tlvs[0].tl.length = macCellCfg->sib1Cfg.sib1PduLen;
+   MAC_ALLOC(sib1TxdataValue,macCellCfg->sib1Cfg.sib1PduLen);
+       if(sib1TxdataValue == NULLP)
+       {
+          return RFAILED;
+       }
+       memcpy(sib1TxdataValue,macCellCfg->sib1Cfg.sib1Pdu,
+          macCellCfg->sib1Cfg.sib1PduLen);
+       pduDesc->tlvs[0].value = sib1TxdataValue;
+
+   /* The total length of the PDU description and      PDU data */
+       pduLen += 8; /* size of PDU length 2 bytes, PDU index 2 bytes, numTLV 4 bytes */
+       pduLen += sizeof(fapi_uint32_tlv_t); /* only 1 TLV is present */
+   pduDesc->pduLength = pduLen; 
+       msgLen += pduLen;
+
+       /* TODO: The pointer value which was stored, needs to be free-ed at PHY *
+        * But since we did not implement WLS, this has to be done here */
+        MAC_FREE(sib1TxdataValue,macCellCfg->sib1Cfg.sib1PduLen);
+
+       return ROK;
+}
+
+/***********************************************************************
+ *
+ * @brief fills the RAR TX-DATA request message
+ *
+ * @details
+ *
+ *    Function : fillRarTxDataReq
+ *
+ *    Functionality:
+ *         - fills the RAR TX-DATA request message
+ *
+ * @params[in]    fapi_tx_pdu_desc_t *pduDesc
+ * @params[in]    RarInfo *rarInfo
+ * @params[in]    uint16_t pduIndex
+ * @params[in]    uint32_t *msgLen
+ * @return ROK
+ *
+ * ********************************************************************/
+uint8_t fillRarTxDataReq(fapi_tx_pdu_desc_t *pduDesc, RarInfo *rarInfo,
+   uint16_t pduIndex, uint32_t *msgLen)
+{
+   uint32_t pduLen = 0;
+       uint32_t *rarTxdataValue = NULLP;
+
+       pduDesc->pduIndex = pduIndex;
+       pduDesc->numTlvs = 1;
+
+       /* fill the TLV */
+       /* as of now, memory is allocated from SSI, later WLS memory needs to be taken */
+       pduDesc->tlvs[0].tl.tag = 1; /* pointer to be sent */
+       pduDesc->tlvs[0].tl.length = rarInfo->rarPduLen;
+   MAC_ALLOC(rarTxdataValue,rarInfo->rarPduLen);
+       if(rarTxdataValue == NULLP)
+       {
+          return RFAILED;
+       }
+       memcpy(rarTxdataValue,rarInfo->rarPdu,rarInfo->rarPduLen);
+       pduDesc->tlvs[0].value = (uint32_t)rarTxdataValue;
+
+   /* The total length of the PDU description and      PDU data */
+       pduLen += 8; /* size of PDU length 2 bytes, PDU index 2 bytes, numTLV 4 bytes */
+       pduLen += sizeof(fapi_uint32_tlv_t); /* only 1 TLV is present */
+   pduDesc->pduLength = pduLen; 
+       msgLen += pduLen;
+
+       /* TODO: The pointer value which was stored, needs to be free-ed at PHY *
+        * But since we did not implement WLS, this has to be done here */
+        MAC_FREE(rarTxdataValue,rarInfo->rarPduLen);
+
+       return ROK;
+}
+
 #endif
 
 /*******************************************************************
@@ -2483,7 +2733,7 @@ uint8_t calculatePduCount(DlBrdcstAlloc *cellBroadcastInfo)
  *         RFAILED - failure
  *
  * ****************************************************************/
-S16 handleDlTtiReq(CmLteTimingInfo *dlTtiReqtimingInfo)
+uint16_t handleDlTtiReq(CmLteTimingInfo *dlTtiReqtimingInfo)
 {
 #ifdef FAPI
        uint8_t idx;
@@ -2491,7 +2741,7 @@ S16 handleDlTtiReq(CmLteTimingInfo *dlTtiReqtimingInfo)
        uint8_t numPduEncoded = 0;
        uint32_t msgLen = 0;
        fapi_dl_tti_req_t *dlTtiReq = NULLP;
-       fapi_dl_tti_req_pdu_t *dlTtiReqPdu = NULLP;
+       fapi_tx_data_req_t *txDataReq = NULLP;
        RgCellCb  *cellCbParams = NULLP;
        MacDlSlot *currDlSlot = NULLP;
        MacCellCfg macCellCfg;
@@ -2515,73 +2765,129 @@ S16 handleDlTtiReq(CmLteTimingInfo *dlTtiReqtimingInfo)
                                dlTtiReq->sfn = dlTtiReqtimingInfo->sfn;
                                dlTtiReq->slot = dlTtiReqtimingInfo->slot;
                                currDlSlot = &macCb.macCell->dlSlot[dlTtiReq->slot % MAX_SLOT_SUPPORTED];
-                               dlTtiReq->nPdus = calculatePduCount(&currDlSlot->cellBroadcastInfo);  /* get total Pdus */
+                               dlTtiReq->nPdus = calculatePduCount(&currDlSlot->dlInfo);  /* get total Pdus */
                                nPdu = dlTtiReq->nPdus;
                                dlTtiReq->nGroup = 0;
                                if(dlTtiReq->nPdus > 0)
                                {
 #ifdef INTEL_WLS
-                                       WLS_MEM_ALLOC(dlTtiReqPdu, (nPdu * sizeof(fapi_dl_tti_req_pdu_t)));
+                                       WLS_MEM_ALLOC(dlTtiReq->pdus, (nPdu * sizeof(fapi_dl_tti_req_pdu_t)));
 #else
-                                       MAC_ALLOC(dlTtiReqPdu, (nPdu * sizeof(fapi_dl_tti_req_pdu_t)));
+                                       MAC_ALLOC(dlTtiReq->pdus, (nPdu * sizeof(fapi_dl_tti_req_pdu_t)));
 #endif
-                                       if(currDlSlot->cellBroadcastInfo.ssbTrans)
+                                       if(currDlSlot->dlInfo.isBroadcastPres)
                                        {
-                                               if(dlTtiReqPdu != NULLP)
+                                               if(currDlSlot->dlInfo.brdcstAlloc.ssbTrans)
                                                {
-                                                       for(idx = 0; idx < currDlSlot->cellBroadcastInfo.ssbIdxSupported; idx++)
+                                                       if(dlTtiReq->pdus != NULLP)
                                                        {
-                                                               if(idx > 0)
-                                                                       dlTtiReq->pdus++;
-                                                               fillSsbPdu(dlTtiReqPdu, &macCellCfg, currDlSlot, &msgLen, idx);
-                                                               dlTtiReq->pdus = dlTtiReqPdu;
-                                                               numPduEncoded++;
+                                                               for(idx = 0; idx < currDlSlot->dlInfo.brdcstAlloc.ssbIdxSupported; idx++)
+                                                               {
+                                                                       if(idx > 0)
+                                                                               dlTtiReq->pdus++;
+                                                                       fillSsbPdu(&dlTtiReq->pdus[numPduEncoded], &macCellCfg, currDlSlot, &msgLen, idx);
+                                                                       numPduEncoded++;
+                                                               }
                                                        }
+                                                       DU_LOG("\nLOWER MAC: MIB sent..");
                                                }
-                                       }
-                                       if(currDlSlot->cellBroadcastInfo.sib1Trans)
-                                       {
-                                               /* Filling SIB1 param */
-                                               if(dlTtiReqPdu != NULLP)
+                                               if(currDlSlot->dlInfo.brdcstAlloc.sib1Trans)
                                                {
+                                                       /* Filling SIB1 param */
                                                        if(numPduEncoded != nPdu)
                                                        {
-                                                               dlTtiReq->pdus++;
-                                                               dlTtiReqPdu = dlTtiReq->pdus;
-                                                               fillPdcchPdu(dlTtiReqPdu, &currDlSlot->cellBroadcastInfo.\
+                                                               fillPdcchPdu(&dlTtiReq->pdus[numPduEncoded],&currDlSlot->dlInfo.brdcstAlloc.\
                                                                                sib1Alloc.sib1PdcchCfg, &msgLen);
-                                                               dlTtiReq->pdus = dlTtiReqPdu;
                                                                numPduEncoded++;
-                                                               dlTtiReq->pdus++;
-                                                               dlTtiReqPdu = dlTtiReq->pdus;
-                                                               fillPdschPdu(dlTtiReqPdu,&currDlSlot->cellBroadcastInfo.\
+                                                               fillPdschPdu(&dlTtiReq->pdus[numPduEncoded],&currDlSlot->dlInfo.brdcstAlloc.\
                                                                                sib1Alloc.sib1PdschCfg, &msgLen);
-                                                               dlTtiReq->pdus = dlTtiReqPdu;
                                                                numPduEncoded++;
                                                        }
+                                                       DU_LOG("\nLOWER MAC: SIB1 sent...");
                                                }
                                        }
+                                       if(currDlSlot->dlInfo.isRarPres)
+                                       {
+                                               /* Filling RAR param */
+                                               fillPdcchPdu(&dlTtiReq->pdus[numPduEncoded], &currDlSlot->dlInfo.rarAlloc.rarPdcchCfg, &msgLen);
+                                               numPduEncoded++;
+                                               fillPdschPdu(&dlTtiReq->pdus[numPduEncoded], &currDlSlot->dlInfo.rarAlloc.rarPdschCfg, &msgLen);
+                                               numPduEncoded++;
+                                               DU_LOG("\nLOWER MAC: RAR sent...");
+                                       }
+
                                        msgLen += sizeof(fapi_dl_tti_req_t) - sizeof(fapi_msg_t);
                                        fillMsgHeader(&dlTtiReq->header, FAPI_DL_TTI_REQUEST, msgLen);
                                        /* TODO : Recheck the size / msglen to be sent to WLS_Put*/
                                        LwrMacSendToPhy(dlTtiReq->header.message_type_id, msgLen, (void *)dlTtiReq);
-                                       if(currDlSlot->cellBroadcastInfo.sib1Trans)
+
+                                       /* FREE the allocated memories */
+                                       if(currDlSlot->dlInfo.brdcstAlloc.sib1Trans)
                                        {
-                                               if(currDlSlot->cellBroadcastInfo.ssbTrans)
+                                               if(currDlSlot->dlInfo.brdcstAlloc.ssbTrans)
+                                               {
+                                                       MAC_FREE(dlTtiReq->pdus[1].u.pdcch_pdu.dlDci, 
+                                                                       sizeof(fapi_dl_dci_t));
+                                               }
+                                               else
+                                               {
+                                                       MAC_FREE(dlTtiReq->pdus[0].u.pdcch_pdu.dlDci, 
+                                                                       sizeof(fapi_dl_dci_t));
+                                               }
+                                       }
+                                       if(currDlSlot->dlInfo.isRarPres)
+                                       {
+                                               if(currDlSlot->dlInfo.brdcstAlloc.ssbTrans)
                                                {
-
                                                        MAC_FREE(dlTtiReq->pdus[1].u.pdcch_pdu.dlDci, 
                                                                        sizeof(fapi_dl_dci_t));
                                                }
                                                else
                                                {
-
                                                        MAC_FREE(dlTtiReq->pdus[0].u.pdcch_pdu.dlDci, 
                                                                        sizeof(fapi_dl_dci_t));
                                                }
                                        }
 
-                                       MAC_FREE(dlTtiReqPdu, (nPdu * sizeof(fapi_dl_tti_req_pdu_t)));
+                                       MAC_FREE(dlTtiReq->pdus, (nPdu * sizeof(fapi_dl_tti_req_pdu_t)));
+
+               /* send TX_Data request message */
+               if(currDlSlot->dlInfo.brdcstAlloc.sib1Trans)
+               {
+                  msgLen = 0;
+                  MAC_ALLOC(txDataReq,sizeof(fapi_tx_data_req_t));
+                  txDataReq->sfn = dlTtiReqtimingInfo->sfn;
+                  txDataReq->slot = dlTtiReqtimingInfo->slot;
+                  txDataReq->numPdus = 1;
+                  fillSib1TxDataReq(
+                        &txDataReq->pduDesc,
+                        &rgCb[inst].cell->macCellCfg,
+                        currDlSlot->dlInfo.brdcstAlloc.sib1Alloc.sib1PdschCfg.pduIndex,
+                        &msgLen);
+                  msgLen += sizeof(fapi_tx_data_req_t) - sizeof(fapi_msg_t);
+                  fillMsgHeader(&txDataReq->header, FAPI_TX_DATA_REQUEST, msgLen);
+                  LwrMacSendToPhy(txDataReq->header.message_type_id, msgLen,(void *)txDataReq);
+                                               MAC_FREE(txDataReq,sizeof(fapi_tx_data_req_t));
+               }
+               if(currDlSlot->dlInfo.isRarPres)
+               {
+                  msgLen = 0;
+                                               /* mux and form RAR pdu */
+                                               fillRarPdu(&currDlSlot->dlInfo.rarAlloc.rarInfo);
+
+                  MAC_ALLOC(txDataReq,sizeof(fapi_tx_data_req_t));
+                  txDataReq->sfn = dlTtiReqtimingInfo->sfn;
+                  txDataReq->slot = dlTtiReqtimingInfo->slot;
+                  txDataReq->numPdus = 1;
+                  fillRarTxDataReq(
+                        &txDataReq->pduDesc,
+                        &currDlSlot->dlInfo.rarAlloc.rarInfo,
+                        currDlSlot->dlInfo.rarAlloc.rarPdschCfg.pduIndex,
+                        &msgLen);
+                  fillMsgHeader(&txDataReq->header, FAPI_TX_DATA_REQUEST, msgLen);
+                  LwrMacSendToPhy(txDataReq->header.message_type_id, msgLen,(void *)txDataReq);
+                                               MAC_FREE(txDataReq,sizeof(fapi_tx_data_req_t));
+               }
                                }
                                else
                                {
index ab5ebb8..86eeb03 100644 (file)
@@ -38,7 +38,7 @@ S16 lwr_mac_handleConfigRspEvt(void *msg);
 S16 lwr_mac_handleStartReqEvt(void *msg);
 S16 lwr_mac_handleStopReqEvt(void *msg);
 void sendToLowerMac(U16, U32, void *);
-S16 handleDlTtiReq(CmLteTimingInfo *dlTtiReqtimingInfo);
+uint16_t handleDlTtiReq(CmLteTimingInfo *dlTtiReqtimingInfo);
 void handlePhyMessages(uint16_t msgType, uint32_t msgSize, void *msg);
 
 typedef S16 (*lwrMacFsmHdlr)(void *);
index e0eebe0..617212b 100644 (file)
 
 #define MAX_SLOT_SUPPORTED    10 /* numerology 0 15Khz */
 #define MAX_ZERO_CORR_CFG_IDX 16 /* max zero correlation config index */
+#define SI_RNTI 0xFFFF
+#define P-RNTI  0xFFFE
 
 typedef struct macDlSlot
 {
-   DlBrdcstAlloc cellBroadcastInfo;
+   DlAlloc dlInfo;
 
 }MacDlSlot;
 
diff --git a/src/5gnrmac/mac_mux.c b/src/5gnrmac/mac_mux.c
new file mode 100644 (file)
index 0000000..d9321f4
--- /dev/null
@@ -0,0 +1,171 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2017-2019] [Radisys]                                        #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+ *******************************************************************************/
+
+#include <stdlib.h>
+#include <stdint.h>
+
+/* header include files -- defines (.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_hash.h"       /* common hash list */
+#include "cm_mblk.h"       /* common memory link list library */
+#include "cm_llist.h"      /* common linked list library */
+#include "cm_err.h"        /* common error */
+#include "cm_lte.h"        /* common LTE */
+#include "lrg.h"           /* Layer manager interface includes*/
+#include "crg.h"           /* CRG interface includes*/
+#include "rgu.h"           /* RGU interface includes*/
+#include "tfu.h"           /* TFU interface includes */
+#include "rg_sch_inf.h"    /* SCH interface includes */
+#include "rg_prg.h"       /* PRG (MAC-MAC) interface includes*/
+#include "rg_env.h"       /* MAC environmental includes*/
+#include "rg.h"           /* MAC includes*/
+#include "rg_err.h"       /* MAC error includes*/
+#include "du_log.h"
+
+/* header/extern include files (.x) */
+#include "gen.x"           /* general layer typedefs */
+#include "ssi.x"           /* system services typedefs */
+#include "cm5.x"           /* common timers */
+#include "cm_hash.x"       /* common hash list */
+#include "cm_lib.x"        /* common library */
+#include "cm_llist.x"      /* common linked list */
+#include "cm_mblk.x"       /* memory management */
+#include "cm_tkns.x"       /* common tokens */
+#include "cm_lte.x"       /* common tokens */
+#include "rgu.x"           /* RGU types */
+#include "tfu.x"           /* RGU types */
+#include "lrg.x"           /* layer management typedefs for MAC */
+#include "crg.x"           /* CRG interface includes */
+#include "rg_sch_inf.x"    /* SCH interface typedefs */
+#include "rg_prg.x"        /* PRG (MAC-MAC) Interface typedefs */
+#include "du_app_mac_inf.h"
+#include "mac.h"
+#include "rg.x"            /* typedefs for MAC */
+
+void packBytes(uint8_t *buf, uint8_t *bytePos, uint8_t *bitPos, uint32_t val, uint8_t valSize)
+{
+   uint32_t  temp;
+   uint8_t   bytePart1;
+   uint32_t  bytePart2;
+   uint8_t   bytePart1Size;
+   uint32_t  bytePart2Size;
+  
+   if(*bitPos - valSize + 1 >= 0)
+   {
+      bytePart1 = (uint8_t)val;
+      bytePart1 = (bytePart1 << (*bitPos -valSize +1));
+      buf[*bytePos] |= bytePart1;
+      if(*bitPos - valSize < 0)
+      {
+         *bitPos = 7;
+         (*bytePos)++;
+      }
+      else
+         *bitPos -= valSize;
+   }
+   else
+   {
+      temp = 0;
+      bytePart1Size = *bitPos +1;
+      bytePart2Size = valSize - bytePart1Size;
+
+      bytePart1 = (val >> bytePart2Size) << (*bitPos -bytePart1Size +1);
+      bytePart2 =  (~((~temp) << bytePart2Size)) & val;
+      buf[*bytePos] |= bytePart1;
+      (*bytePos)++;
+      *bitPos = 7;
+      packBytes(buf, bytePos, bitPos, bytePart2, bytePart2Size);
+   }  
+}
+
+void fillRarPdu(RarInfo *rarInfo)
+{
+   uint8_t   *rarPdu = rarInfo->rarPdu;
+   uint16_t  totalBits;
+   uint8_t   numBytes;
+   uint8_t   bytePos;
+   uint8_t   bitPos;
+
+   /* RAR subheader fields */
+   uint8_t   EBit;
+   uint8_t   TBit;
+   uint8_t   rapId;
+
+   /* RAR payload fields */
+   uint8_t   RBit;
+   uint16_t  timeAdv;
+   uint32_t  ulGrant;
+   uint16_t  tmpCrnti; 
+
+   /* Size(in bits) of RAR subheader files */
+   uint8_t   EBitSize = 1;
+   uint8_t   TBitSize = 1;
+   uint8_t   rapidSize = 6;
+
+   /* Size(in bits) of RAR payload fields */
+   uint8_t   RBitSize = 1;
+   uint8_t   timeAdvSize = 12;
+   uint8_t   ulGrantSize = 27;
+   uint8_t   tmpCrntiSize = 16;
+
+   /* Fill RAR pdu fields */
+   EBit = 0;
+   TBit = 1;
+   rapId = rarInfo->RAPID;
+   
+   RBit = 0;
+   timeAdv = rarInfo->ta;
+   ulGrant = 0; /* this will be done when implementing msg3 */ 
+   tmpCrnti = rarInfo->tcrnti;
+
+   /* Calulating total number of bytes in buffer */
+   totalBits = EBitSize + TBitSize + rapidSize + RBitSize + timeAdvSize \
+     + ulGrantSize + tmpCrntiSize;
+   
+   /* Calulating total number of bytes in buffer */
+   numBytes = totalBits/8;
+   if(totalBits % 8)
+      numBytes += 1;
+    
+       rarInfo->rarPduLen = numBytes;
+
+   /* Initialize buffer */
+   for(bytePos = 0; bytePos < numBytes; bytePos++)
+      rarPdu[bytePos] = 0;
+   
+   bytePos = 0;
+   bitPos = 7;
+
+   /* Packing fields into RAR PDU */
+   packBytes(rarPdu, &bytePos, &bitPos, EBit, EBitSize); 
+   packBytes(rarPdu, &bytePos, &bitPos, TBit, TBitSize);
+   packBytes(rarPdu, &bytePos, &bitPos, rapId, rapidSize);
+   packBytes(rarPdu, &bytePos, &bitPos, RBit, RBitSize);
+   packBytes(rarPdu, &bytePos, &bitPos, timeAdv, timeAdvSize);
+   packBytes(rarPdu, &bytePos, &bitPos, ulGrant, ulGrantSize);
+   packBytes(rarPdu, &bytePos, &bitPos, tmpCrnti, tmpCrntiSize);
+}
+
+/**********************************************************************
+  End of file
+ **********************************************************************/
index f2d0a71..f1b850a 100644 (file)
@@ -115,7 +115,7 @@ uint16_t fapiMacRachInd(Pst *pst, RachInd *rachInd)
    rachIndInfo->timingInfo.slot = rachInd->timingInfo.slot;
    rachIndInfo->slotIdx = rachInd->rachPdu[pduIdx].slotIdx;
    rachIndInfo->symbolIdx = rachInd->rachPdu[pduIdx].symbolIdx;
-   rachIndInfo->frequencyIdx = rachInd->rachPdu[pduIdx].freqIdx;
+   rachIndInfo->freqIdx = rachInd->rachPdu[pduIdx].freqIdx;
    rachIndInfo->preambleIdx = \
       rachInd->rachPdu[pduIdx].preamInfo[preambleIdx].preamIdx;
    rachIndInfo->timingAdv = \
index a2602b5..e80cb22 100644 (file)
 #include "du_app_mac_inf.h"
 #include "mac.h"
 
-int MacProcDlBrdcstAlloc(Pst *pst, DlBrdcstAlloc *dlBrdcstAlloc)
+int MacProcDlAlloc(Pst *pst, DlAlloc *dlAlloc)
 {
-   if(dlBrdcstAlloc != NULLP)
+   if(dlAlloc != NULLP)
    {
                MacDlSlot *currDlSlot =
-               &macCb.macCell->dlSlot[dlBrdcstAlloc->slotIndInfo.slot % MAX_SLOT_SUPPORTED];
-      memcpy(&currDlSlot->cellBroadcastInfo, dlBrdcstAlloc, sizeof(DlBrdcstAlloc)); 
+               &macCb.macCell->dlSlot[dlAlloc->slotIndInfo.slot % MAX_SLOT_SUPPORTED];
+      memcpy(&currDlSlot->dlInfo, dlAlloc, sizeof(DlAlloc)); 
    }
    return ROK;
 }
index a377201..d401bc5 100644 (file)
@@ -324,7 +324,9 @@ SlotIndInfo         *slotInd
  * ****************************************************************/
 int macSchRachInd(Pst *pst, RachIndInfo *rachInd)
 {
+   Inst  inst = pst->dstInst-SCH_INST_START;
    DU_LOG("\nSCH : Received Rach indication");
+   schProcessRachInd(rachInd, inst);
    return ROK;
 }
 
@@ -414,38 +416,38 @@ int InitSchCellCb(Inst inst, SchCellCfg *schCellCfg)
 void fillSchSib1Cfg(
 Inst         schInst,
 SchSib1Cfg   *sib1SchCfg,
-uint8_t      pci,
+uint16_t     pci,
 uint8_t      offsetPointA
 )
 {
    uint8_t coreset0Idx = 0;
    uint8_t searchSpace0Idx = 0;
-   uint8_t ssbMuxPattern = 0;
+   //uint8_t ssbMuxPattern = 0;
    uint8_t numRbs = 0;
    uint8_t numSymbols = 0;
    uint8_t offset = 0;
    uint8_t oValue = 0;
-   uint8_t numSearchSpacePerSlot = 0;
+   //uint8_t numSearchSpacePerSlot = 0;
    uint8_t mValue = 0;
    uint8_t firstSymbol = 0; /* need to calculate using formula mentioned in 38.213 */
    uint8_t slotIndex = 0;
    uint8_t FreqDomainResource[6] = {0};
 
-   Sib1PdcchCfg *pdcch = &(sib1SchCfg->sib1PdcchCfg);
-   Sib1PdschCfg *pdsch = &(sib1SchCfg->sib1PdschCfg);
+   PdcchCfg *pdcch = &(sib1SchCfg->sib1PdcchCfg);
+   PdschCfg *pdsch = &(sib1SchCfg->sib1PdschCfg);
 
    coreset0Idx     = sib1SchCfg->coresetZeroIndex;
    searchSpace0Idx = sib1SchCfg->searchSpaceZeroIndex;
 
    /* derive the sib1 coreset0 params from table 13-1 spec 38.213 */
-   ssbMuxPattern = coresetIdxTable[coreset0Idx][0];
+   //ssbMuxPattern = coresetIdxTable[coreset0Idx][0];
    numRbs        = coresetIdxTable[coreset0Idx][1];
    numSymbols    = coresetIdxTable[coreset0Idx][2];
    offset        = coresetIdxTable[coreset0Idx][3];
 
    /* derive the search space params from table 13-11 spec 38.213 */
    oValue                = searchSpaceIdxTable[searchSpace0Idx][0];
-   numSearchSpacePerSlot = searchSpaceIdxTable[searchSpace0Idx][1];
+   //numSearchSpacePerSlot = searchSpaceIdxTable[searchSpace0Idx][1];
    mValue                = searchSpaceIdxTable[searchSpace0Idx][2];
    firstSymbol           = searchSpaceIdxTable[searchSpace0Idx][3];
 
@@ -461,44 +463,44 @@ uint8_t      offsetPointA
    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->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);
-   pdcch->sib1Coreset0Cfg.cceRegMappingType = 1; /* coreset0 is always interleaved */
-   pdcch->sib1Coreset0Cfg.regBundleSize = 6;    /* spec-38.211 sec 7.3.2.2 */
-   pdcch->sib1Coreset0Cfg.interleaverSize = 2;  /* spec-38.211 sec 7.3.2.2 */
-   pdcch->sib1Coreset0Cfg.coreSetType = 0;
-   pdcch->sib1Coreset0Cfg.shiftIndex = pci;
-   pdcch->sib1Coreset0Cfg.precoderGranularity = 0; /* sameAsRegBundle */
+   pdcch->pdcchBwpCfg.BWPSize = MAX_NUM_RB; /* whole of BW */
+   pdcch->pdcchBwpCfg.BWPStart = 0;
+   pdcch->pdcchBwpCfg.subcarrierSpacing = 0;         /* 15Khz */
+   pdcch->pdcchBwpCfg.cyclicPrefix = 0;              /* normal */
+   pdcch->coreset0Cfg.coreSet0Size = numRbs;
+   pdcch->coreset0Cfg.startSymbolIndex = firstSymbol;
+   pdcch->coreset0Cfg.durationSymbols = numSymbols;
+   memcpy(pdcch->coreset0Cfg.freqDomainResource,FreqDomainResource,6);
+   pdcch->coreset0Cfg.cceRegMappingType = 1; /* coreset0 is always interleaved */
+   pdcch->coreset0Cfg.regBundleSize = 6;    /* spec-38.211 sec 7.3.2.2 */
+   pdcch->coreset0Cfg.interleaverSize = 2;  /* spec-38.211 sec 7.3.2.2 */
+   pdcch->coreset0Cfg.coreSetType = 0;
+   pdcch->coreset0Cfg.shiftIndex = pci;
+   pdcch->coreset0Cfg.precoderGranularity = 0; /* sameAsRegBundle */
    pdcch->numDlDci = 1;
-   pdcch->sib1DlDci.rnti = 0xFFFF; /* SI-RNTI */
-   pdcch->sib1DlDci.scramblingId = pci;
-   pdcch->sib1DlDci.scramblingRnti = 0;
-   pdcch->sib1DlDci.cceIndex = 0;
-   pdcch->sib1DlDci.aggregLevel = 4;
-   pdcch->sib1DlDci.beamPdcchInfo.numPrgs = 1;
-   pdcch->sib1DlDci.beamPdcchInfo.prgSize = 1;
-   pdcch->sib1DlDci.beamPdcchInfo.digBfInterfaces = 0;
-   pdcch->sib1DlDci.beamPdcchInfo.prg[0].pmIdx = 0;
-   pdcch->sib1DlDci.beamPdcchInfo.prg[0].beamIdx[0] = 0;
-   pdcch->sib1DlDci.txPdcchPower.powerValue = 0;
-   pdcch->sib1DlDci.txPdcchPower.powerControlOffsetSS = 0;
+   pdcch->dci.rnti = SI_RNTI;
+   pdcch->dci.scramblingId = pci;
+   pdcch->dci.scramblingRnti = 0;
+   pdcch->dci.cceIndex = 0;
+   pdcch->dci.aggregLevel = 4;
+   pdcch->dci.beamPdcchInfo.numPrgs = 1;
+   pdcch->dci.beamPdcchInfo.prgSize = 1;
+   pdcch->dci.beamPdcchInfo.digBfInterfaces = 0;
+   pdcch->dci.beamPdcchInfo.prg[0].pmIdx = 0;
+   pdcch->dci.beamPdcchInfo.prg[0].beamIdx[0] = 0;
+   pdcch->dci.txPdcchPower.powerValue = 0;
+   pdcch->dci.txPdcchPower.powerControlOffsetSS = 0;
        /* Storing pdschCfg pointer here. Required to access pdsch config while
        fillig up pdcch pdu */
-   pdcch->sib1DlDci.pdschCfg = pdsch; 
+   pdcch->dci.pdschCfg = pdsch; 
 
    /* fill the PDSCH PDU */
        uint8_t cwCount = 0;
    pdsch->pduBitmap = 0; /* PTRS and CBG params are excluded */
    pdsch->rnti = 0xFFFF; /* SI-RNTI */
    pdsch->pduIndex = 0;
-   pdsch->sib1PdschBwpCfg.BWPSize = MAX_NUM_RB; /* whole of BW */
-   pdsch->sib1PdschBwpCfg.BWPStart = 0;
+   pdsch->pdschBwpCfg.BWPSize = MAX_NUM_RB; /* whole of BW */
+   pdsch->pdschBwpCfg.BWPStart = 0;
    pdsch->numCodewords = 1;
        for(cwCount = 0; cwCount < pdsch->numCodewords; cwCount++)
        {
@@ -519,17 +521,17 @@ uint8_t      offsetPointA
    pdsch->dmrs.scid = 0;
    pdsch->dmrs.numDmrsCdmGrpsNoData = 1;
    pdsch->dmrs.dmrsPorts = 0;
-   pdsch->sib1FreqAlloc.resourceAlloc = 1; /* RAT type-1 RIV format */
-   pdsch->sib1FreqAlloc.rbStart = offset + SCH_SSB_PRB_DURATION; /* the RB numbering starts from coreset0, and PDSCH is always above SSB */ 
+   pdsch->freqAlloc.resourceAlloc = 1; /* RAT type-1 RIV format */
+   pdsch->freqAlloc.rbStart = offset + SCH_SSB_PRB_DURATION; /* the RB numbering starts from coreset0, and PDSCH is always above SSB */ 
        /* formula used for calculation of rbSize, 38.213 section 5.1.3.2 *
         * Ninfo = Nre . R . Qm . v                                       *
         * Nre' = Nsc . NsymPdsch - NdmrsSymb - Noh                       *
         * 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->freqAlloc.rbSize = 10; /* This value is calculated from above formulae */
+   pdsch->freqAlloc.vrbPrbMapping = 0; /* non-interleaved */
+   pdsch->timeAlloc.rowIndex = 1;
+   pdsch->timeAlloc.startSymbolIndex = 2; /* spec-38.214, Table 5.1.2.1-1 */
+   pdsch->timeAlloc.numSymbols = 12;
    pdsch->beamPdschInfo.numPrgs = 1;
    pdsch->beamPdschInfo.prgSize = 1;
    pdsch->beamPdschInfo.digBfInterfaces = 0;
index 80f873d..f419209 100644 (file)
@@ -21,6 +21,7 @@
 #define SCH_MAX_CELLS 1
 #define SCH_MAX_INST 1
 #define SCH_NUM_SLOTS 10 /*forcing this to 10 */
+#define SCH_MAX_SFN 1024
 #define MAX_NUM_RB 106 /* value for numerology 0 15Khz */
 #define SCH_MIB_TRANS 80 
 #define SCH_NUM_SC_PRB 12 /* number of SCs in a PRB */
@@ -32,6 +33,9 @@
 #define SCH_MEM_REGION     4
 #define SCH_POOL           1
 #define SCHED_DELTA 1
+#define SCH_MAX_UE 512
+#define SI_RNTI 0xFFFF
+#define P_RNIT  0xFFFE
 
 /* allocate and zero out a static buffer */
 #define SCH_ALLOC(_datPtr, _size)                                \
@@ -90,8 +94,16 @@ typedef struct schDlAlloc
    bool        ssbPres;    /*!< Flag to determine if SSB is present in this slot */
    uint8_t     ssbIdxSupported;  /*!< Max SSB index */
        SsbInfo     ssbInfo[MAX_SSB_IDX]; /*!< SSB info */
+       bool        sib1Pres;
+       bool        rarPres;
+       RarInfo     rarInfo;
 }SchDlAlloc;
 
+typedef struct schRaCb
+{
+   uint16_t tcrnti;
+}SchRaCb;
+
 /**
   * @brief
   * scheduler allocationsfor UL per cell.
@@ -117,6 +129,7 @@ typedef struct schCellCb
    SchDlAlloc    *dlAlloc[SCH_NUM_SLOTS]; /*!< SCH resource allocations in DL */
    SchUlAlloc    *ulAlloc[SCH_NUM_SLOTS]; /*!< SCH resource allocations in UL */
        SchCellCfg    cellCfg;                /*!< Cell ocnfiguration */
+       SchRaCb       raCb[SCH_MAX_UE];
 }SchCellCb;
 
 /**
@@ -134,9 +147,9 @@ typedef struct schCb
 SchCb schCb[SCH_MAX_INST];
 
 /* function declarations */
-uint8_t schCmnDlAlloc(SchCellCb *cell, DlBrdcstAlloc *dlBrdcstAlloc);
-int     schProcessSlotInd(SlotIndInfo *slotInd, Inst inst);
-int schUlResAlloc(SchCellCb *cell, Inst schInst);
+uint8_t schBroadcastAlloc(SchCellCb *cell, DlBrdcstAlloc *dlBrdcstAlloc,uint16_t slot);
+uint8_t schProcessSlotInd(SlotIndInfo *slotInd, Inst inst);
+uint8_t schUlResAlloc(SchCellCb *cell, Inst schInst);
 
 
 
index 697b820..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;
 }
@@ -297,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;
diff --git a/src/5gnrsch/sch_rach.c b/src/5gnrsch/sch_rach.c
new file mode 100644 (file)
index 0000000..abca278
--- /dev/null
@@ -0,0 +1,249 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2017-2019] [Radisys]                                        #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+/************************************************************************
+     Name:     sch_rach.c
+  
+     Type:     C source file
+  
+     Desc:     C source code for rach handling functions
+  
+     File:     sch_rach.c
+  
+**********************************************************************/
+
+/** @file sch_rach.c
+@brief This file implements the rach handling.
+*/
+
+#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 "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"
+#include "du_app_mac_inf.h"
+#include "mac_sch_interface.h"
+#include "sch.h"
+#include "sch_utils.h"
+
+extern SchCb schCb[SCH_MAX_INST];
+extern int8_t coresetIdxTable[MAX_CORESET_INDEX][4];
+extern int8_t searchSpaceIdxTable[MAX_SEARCH_SPACE_INDEX][4];
+
+uint16_t calculateRaRnti(uint8_t symbolIdx, uint8_t slotIdx, uint8_t freqIdx)
+{
+   uint16_t raRnti = 0;
+       uint8_t ulCarrierIdx = 0; /* configured to 0 */
+   raRnti = (1+symbolIdx+(14*slotIdx)+(14*80*freqIdx)+(14*80*8*ulCarrierIdx));
+       return raRnti;
+}
+
+void createSchRaCb(uint16_t tcrnti, Inst schInst)
+{
+       schCb[schInst].cells[schInst]->raCb[0].tcrnti = tcrnti;
+}
+
+uint8_t schProcessRachInd(RachIndInfo *rachInd, Inst schInst)
+{
+   SchCellCb *cell = schCb[schInst].cells[schInst];
+
+       uint16_t sfn  = rachInd->timingInfo.sfn;  /* get the current timing info */
+       uint16_t slot = rachInd->timingInfo.slot;
+       uint16_t sfnSlot = ((sfn * 10) + slot + 1); /* scheduled in the next slot */
+       uint8_t rarDelay = 0;
+
+       if(sfnSlot % cell->cellCfg.sib1SchCfg.sib1RepetitionPeriod == 0)
+       {
+          /* the next slot has SIB1 occasion, so send it after 2 slot */
+          rarDelay = 2;
+       }
+       else
+       {
+          /* send RAR in the next slot */
+          //rarDelay = 1;
+               rarDelay = 2;
+       }
+
+       if((slot+rarDelay) % SCH_NUM_SLOTS == 0)
+       {
+          sfn = (sfn+1) % SCH_MAX_SFN;
+   }
+
+       slot = ((slot + rarDelay) % SCH_NUM_SLOTS);
+
+   SchDlAlloc *dlAlloc = cell->dlAlloc[slot]; /* RAR will sent in the next slot */
+       RarInfo *rarInfo = &(dlAlloc->rarInfo);
+
+   /* rar message presense in next slot ind and will be scheduled */
+   dlAlloc->rarPres = true;
+
+   /* calculate the ra-rnti value */
+       uint16_t raRnti = 0;
+       raRnti = calculateRaRnti(rachInd->symbolIdx,rachInd->slotIdx,rachInd->freqIdx);
+   
+       /* create raCb at SCH */
+       createSchRaCb(rachInd->crnti,schInst);
+
+       /* fill RAR info */
+       rarInfo->raRnti = raRnti;
+       rarInfo->tcrnti = rachInd->crnti;
+       rarInfo->RAPID = rachInd->preambleIdx;
+       rarInfo->ta = rachInd->timingAdv;
+       rarInfo->msg3StartRb = 0; /* will be set during implementation of msg3 */
+       rarInfo->msg3NumRb = 0; /* will be set during implementation of msg3 */
+
+   return ROK;
+}
+
+uint8_t schFillRar(RarAlloc *rarAlloc, uint16_t raRnti, uint16_t pci, uint8_t offsetPointA)
+{
+   uint8_t coreset0Idx = 0;
+   uint8_t searchSpace0Idx = 0;
+   //uint8_t ssbMuxPattern = 0;
+   uint8_t numRbs = 0;
+   uint8_t numSymbols = 0;
+   uint8_t offset = 0;
+   //uint8_t oValue = 0;
+   //uint8_t numSearchSpacePerSlot = 0;
+   //uint8_t mValue = 0;
+   uint8_t firstSymbol = 0; /* need to calculate using formula mentioned in 38.213 */
+   uint8_t FreqDomainResource[6] = {0};
+
+       PdcchCfg *pdcch = &rarAlloc->rarPdcchCfg;
+       PdschCfg *pdsch = &rarAlloc->rarPdschCfg;
+
+   coreset0Idx     = 0;
+   searchSpace0Idx = 0;
+
+   /* derive the sib1 coreset0 params from table 13-1 spec 38.213 */
+   //ssbMuxPattern = coresetIdxTable[coreset0Idx][0];
+   numRbs        = coresetIdxTable[coreset0Idx][1];
+   numSymbols    = coresetIdxTable[coreset0Idx][2];
+   offset        = coresetIdxTable[coreset0Idx][3];
+
+   /* derive the search space params from table 13-11 spec 38.213 */
+   //oValue                = searchSpaceIdxTable[searchSpace0Idx][0];
+   //numSearchSpacePerSlot = searchSpaceIdxTable[searchSpace0Idx][1];
+   //mValue                = searchSpaceIdxTable[searchSpace0Idx][2];
+   firstSymbol           = searchSpaceIdxTable[searchSpace0Idx][3];
+
+   /* calculate the PRBs */
+   freqDomResourceAlloc( ((offsetPointA-offset)/6), (numRbs/6), FreqDomainResource);
+
+   /* fill the PDCCH PDU */
+   pdcch->pdcchBwpCfg.BWPSize = MAX_NUM_RB; /* whole of BW */
+   pdcch->pdcchBwpCfg.BWPStart = 0;
+   pdcch->pdcchBwpCfg.subcarrierSpacing = 0;         /* 15Khz */
+   pdcch->pdcchBwpCfg.cyclicPrefix = 0;              /* normal */
+   pdcch->coreset0Cfg.startSymbolIndex = firstSymbol;
+   pdcch->coreset0Cfg.durationSymbols = numSymbols;
+   memcpy(pdcch->coreset0Cfg.freqDomainResource,FreqDomainResource,6);
+   pdcch->coreset0Cfg.cceRegMappingType = 1; /* coreset0 is always interleaved */
+   pdcch->coreset0Cfg.regBundleSize = 6;    /* spec-38.211 sec 7.3.2.2 */
+   pdcch->coreset0Cfg.interleaverSize = 2;  /* spec-38.211 sec 7.3.2.2 */
+   pdcch->coreset0Cfg.coreSetType = 0;
+   pdcch->coreset0Cfg.shiftIndex = pci;
+   pdcch->coreset0Cfg.precoderGranularity = 0; /* sameAsRegBundle */
+   pdcch->numDlDci = 1;
+   pdcch->dci.rnti = raRnti; /* RA-RNTI */
+   pdcch->dci.scramblingId = pci;
+   pdcch->dci.scramblingRnti = 0;
+   pdcch->dci.cceIndex = 0;
+   pdcch->dci.aggregLevel = 4;
+   pdcch->dci.beamPdcchInfo.numPrgs = 1;
+   pdcch->dci.beamPdcchInfo.prgSize = 1;
+   pdcch->dci.beamPdcchInfo.digBfInterfaces = 0;
+   pdcch->dci.beamPdcchInfo.prg[0].pmIdx = 0;
+   pdcch->dci.beamPdcchInfo.prg[0].beamIdx[0] = 0;
+   pdcch->dci.txPdcchPower.powerValue = 0;
+   pdcch->dci.txPdcchPower.powerControlOffsetSS = 0;
+       pdcch->dci.pdschCfg = pdsch;
+
+   /* fill the PDSCH PDU */
+       uint8_t cwCount = 0;
+   pdsch->pduBitmap = 0; /* PTRS and CBG params are excluded */
+   pdsch->rnti = raRnti; /* RA-RNTI */
+   pdsch->pduIndex = 0;
+   pdsch->pdschBwpCfg.BWPSize = MAX_NUM_RB; /* whole of BW */
+   pdsch->pdschBwpCfg.BWPStart = 0;
+   pdsch->numCodewords = 1;
+       for(cwCount = 0; cwCount < pdsch->numCodewords; cwCount++)
+       {
+      pdsch->codeword[cwCount].targetCodeRate = 308;
+      pdsch->codeword[cwCount].qamModOrder = 2;
+      pdsch->codeword[cwCount].mcsIndex = 4; /* msc configured to 4 */
+      pdsch->codeword[cwCount].mcsTable = 0; /* notqam256 */
+      pdsch->codeword[cwCount].rvIndex = 0;
+      pdsch->codeword[cwCount].tbSize = 768;
+   }
+   pdsch->dataScramblingId = pci;
+   pdsch->numLayers = 1;
+   pdsch->transmissionScheme = 0;
+   pdsch->refPoint = 0;
+   pdsch->dmrs.dlDmrsSymbPos = 2;
+   pdsch->dmrs.dmrsConfigType = 0; /* type-1 */
+   pdsch->dmrs.dlDmrsScramblingId = pci;
+   pdsch->dmrs.scid = 0;
+   pdsch->dmrs.numDmrsCdmGrpsNoData = 1;
+   pdsch->dmrs.dmrsPorts = 0;
+   pdsch->freqAlloc.resourceAlloc = 1; /* RAT type-1 RIV format */
+   pdsch->freqAlloc.rbStart = offset + SCH_SSB_PRB_DURATION; /* the RB numbering starts from coreset0, and PDSCH is always above SSB */ 
+       /* formula used for calculation of rbSize, 38.213 section 5.1.3.2 *
+        * Ninfo = S . Nre . R . Qm . v                                   *
+        * Nre' = Nsc . NsymPdsch - NdmrsSymb - Noh                       *
+        * Nre = min(156,Nre') . nPrb                                     */
+   pdsch->freqAlloc.rbSize = 1; /* This value is calculated from above formulae */
+   pdsch->freqAlloc.vrbPrbMapping = 0; /* non-interleaved */
+   pdsch->timeAlloc.startSymbolIndex = 2; /* spec-38.214, Table 5.1.2.1-1 */
+   pdsch->timeAlloc.numSymbols = 12;
+   pdsch->beamPdschInfo.numPrgs = 1;
+   pdsch->beamPdschInfo.prgSize = 1;
+   pdsch->beamPdschInfo.digBfInterfaces = 0;
+   pdsch->beamPdschInfo.prg[0].pmIdx = 0;
+   pdsch->beamPdschInfo.prg[0].beamIdx[0] = 0;
+   pdsch->txPdschPower.powerControlOffset = 0;
+   pdsch->txPdschPower.powerControlOffsetSS = 0;
+       
+       return ROK;
+}
+
+/**********************************************************************
+         End of file
+**********************************************************************/
index 5582475..f0d539f 100644 (file)
@@ -61,11 +61,11 @@ File:     sch_slot_ind.c
 #include "mac_sch_interface.h"
 #include "sch.h"
 
-SchMacDlBrdcstAllocFunc schMacDlBrdcstAllocOpts[] =
+SchMacDlAllocFunc schMacDlAllocOpts[] =
 {
-       packSchMacDlBrdcstAlloc,
-       MacProcDlBrdcstAlloc,
-       packSchMacDlBrdcstAlloc
+       packSchMacDlAlloc,
+       MacProcDlAlloc,
+       packSchMacDlAlloc
 };
 
 extern SchCb schCb[SCH_MAX_INST];
@@ -77,7 +77,7 @@ extern SchCb schCb[SCH_MAX_INST];
  *
  * @details
  *
- *    Function : sendDlBrdcstAllocToMac
+ *    Function : sendDlAllocToMac
  *
  *    Functionality:
  *     Sends DL Broadcast Resource Allocation to MAC from SCH
@@ -87,15 +87,15 @@ extern SchCb schCb[SCH_MAX_INST];
  *         RFAILED - failure
  *
  * ****************************************************************/
-int sendDlBrdcstAllocToMac(DlBrdcstAlloc *dlBrdcstAlloc, Inst inst)
+int sendDlAllocToMac(DlAlloc *dlAlloc, Inst inst)
 {
        Pst pst;
 
    memset(&pst, 0, sizeof(Pst));
    SCH_FILL_RSP_PST(pst, inst);
-       pst.event = EVENT_DL_BRDCST_ALLOC;
+       pst.event = EVENT_DL_ALLOC;
 
-       return(*schMacDlBrdcstAllocOpts[pst.selector])(&pst, dlBrdcstAlloc);
+       return(*schMacDlAllocOpts[pst.selector])(&pst, dlAlloc);
 
 }
 /*******************************************************************
@@ -114,48 +114,52 @@ int sendDlBrdcstAllocToMac(DlBrdcstAlloc *dlBrdcstAlloc, Inst inst)
  *         RFAILED - failure
  *
  * ****************************************************************/
-int schProcessSlotInd(SlotIndInfo *slotInd, Inst schInst)
+uint8_t schProcessSlotInd(SlotIndInfo *slotInd, Inst schInst)
 {
    int ret = ROK;
        uint8_t ssb_rep;
        uint16_t sfn  = slotInd->sfn;
        uint16_t slot = slotInd->slot;
        uint16_t sfnSlot = 0;
-       DlBrdcstAlloc dlBrdcstAlloc;
-       dlBrdcstAlloc.ssbTrans = NO_SSB;
-   dlBrdcstAlloc.sib1Trans = NO_SIB1;
-       SchCellCb *cell;
+       DlAlloc dlAlloc;
+       memset(&dlAlloc,0,sizeof(DlAlloc));
+   DlBrdcstAlloc *dlBrdcstAlloc = &dlAlloc.brdcstAlloc;
+       RarAlloc *rarAlloc = &dlAlloc.rarAlloc;
+       dlBrdcstAlloc->ssbTrans = NO_SSB;
+   dlBrdcstAlloc->sib1Trans = NO_SIB1;
+       
+
+       SchCellCb *cell = schCb[schInst].cells[schInst];
 
 #ifdef LTE_L2_MEAS
    glblTtiCnt++;
 #endif
   
-       cell = schCb[schInst].cells[schInst];
 //   schDlResAlloc(cell, slotInd);
 
        ssb_rep = cell->cellCfg.ssbSchCfg.ssbPeriod;
        memcpy(&cell->slotInfo, slotInd, sizeof(SlotIndInfo));
-       dlBrdcstAlloc.cellId = cell->cellId;
-       dlBrdcstAlloc.ssbIdxSupported = 1;
+       dlBrdcstAlloc->ssbIdxSupported = 1;
 
-   if((slot + SCHED_DELTA) >= 10)
+   if((slot + SCHED_DELTA) >= SCH_NUM_SLOTS)
        {
-      sfn++;   
+      sfn = (sfn+1)%SCH_MAX_SFN;
        }
-       slot = ((slot + SCHED_DELTA) % 10 );
+       slot = ((slot + SCHED_DELTA) % SCH_NUM_SLOTS);
    sfnSlot = ((sfn * 10) + slot);
 
-       dlBrdcstAlloc.slotIndInfo.sfn = sfn;
-       dlBrdcstAlloc.slotIndInfo.slot = slot;
+       dlAlloc.slotIndInfo.sfn = sfn;
+       dlAlloc.slotIndInfo.slot = slot;
+       dlAlloc.cellId = cell->cellId;
 
        /* Identify SSB ocassion*/
        if (sfnSlot % SCH_MIB_TRANS == 0)
        {
-               dlBrdcstAlloc.ssbTrans = SSB_TRANSMISSION;
+               dlBrdcstAlloc->ssbTrans = SSB_TRANSMISSION;
        }
        else if (sfnSlot % ssb_rep == 0)
        {
-               dlBrdcstAlloc.ssbTrans = SSB_REPEAT;
+               dlBrdcstAlloc->ssbTrans = SSB_REPEAT;
        }
        else
        {
@@ -165,28 +169,46 @@ int schProcessSlotInd(SlotIndInfo *slotInd, Inst schInst)
    /* Identify SIB1 occasions */
    if(sfnSlot % cell->cellCfg.sib1SchCfg.sib1NewTxPeriod == 0)
        {
-          dlBrdcstAlloc.sib1Trans = SIB1_TRANSMISSION;
+          dlBrdcstAlloc->sib1Trans = SIB1_TRANSMISSION;
        }
        else if (sfnSlot % cell->cellCfg.sib1SchCfg.sib1RepetitionPeriod == 0)
        {
-          dlBrdcstAlloc.sib1Trans = SIB1_REPITITION;
+          dlBrdcstAlloc->sib1Trans = SIB1_REPITITION;
        }
        else
        {
           /* not SIB1 occassion */
        }
 
-       if(dlBrdcstAlloc.ssbTrans || dlBrdcstAlloc.sib1Trans)
+       if(dlBrdcstAlloc->ssbTrans || dlBrdcstAlloc->sib1Trans)
        {
-          ret = schCmnDlAlloc(cell, &dlBrdcstAlloc);
+          dlAlloc.isBroadcastPres = true;
+          ret = schBroadcastAlloc(cell, dlBrdcstAlloc,slot);
       if(ret != ROK)
       {
-         DU_LOG("\nschCmnDlAlloc failed");
+         DU_LOG("\nschBroadcastAlloc failed");
          RETVALUE(ret);
       }
    }
-       //send msg to MAC
-   ret = sendDlBrdcstAllocToMac(&dlBrdcstAlloc, schInst);
+
+   /* check for RAR */
+       if(cell->dlAlloc[slot]->rarPres == true)
+       {
+          dlAlloc.isRarPres = true;
+          /* RAR info is copied, this was earlier filled in schProcessRachInd */
+          memcpy(&rarAlloc->rarInfo, &cell->dlAlloc[slot]->rarInfo, sizeof(RarInfo));
+
+               /* pdcch and pdsch data is filled */
+      schFillRar(rarAlloc,
+                  cell->dlAlloc[slot]->rarInfo.raRnti,
+                  cell->cellCfg.phyCellId,
+                  cell->cellCfg.ssbSchCfg.ssbOffsetPointA);
+
+     cell->dlAlloc[slot]->rarPres = false;
+   }
+
+       /* send msg to MAC */
+   ret = sendDlAllocToMac(&dlAlloc, schInst);
    if(ret != ROK)
    {
       DU_LOG("\nSending DL Broadcast allocation from SCH to MAC failed");
index 1f6bfb4..8f53295 100644 (file)
@@ -75,15 +75,15 @@ int packMacSchRachInd(Pst *pst, RachIndInfo *rachInd)
  *
  * @details
  *
- *     Function : packSchMaccDlBrdcstAlloc 
+ *     Function : packSchMaccDlAlloc 
  *     
  *     
  *  @param[in]  Pst *pst, the post structure     
- *  @param[in]  *dlBrdcstAlloc, dlBroadcastAlloc
+ *  @param[in]  DlAlloc  *dlAlloc
  *  @return  S16
  *      -# ROK
  **/
-int packSchMacDlBrdcstAlloc(Pst *pst, DlBrdcstAlloc  *dlBrdcstAlloc)
+int packSchMacDlAlloc(Pst *pst, DlAlloc  *dlAlloc)
 {
        return ROK;
 }
index 5f957dc..ee9552b 100644 (file)
@@ -19,7 +19,7 @@
 /* events */
 #define EVENT_SCH_CELL_CFG      1
 #define EVENT_SCH_CELL_CFG_CFM  2
-#define EVENT_DL_BRDCST_ALLOC   3 
+#define EVENT_DL_ALLOC   3 
 #define EVENT_UL_SCH_INFO       4 
 
 /* selector */
@@ -133,12 +133,12 @@ typedef struct txPowerPdschInfo
    uint8_t powerControlOffsetSS;
 } TxPowerPdschInfo;
 
-typedef struct sib1PdschCfg
+typedef struct pdschCfg
 {
    uint16_t pduBitmap;
    uint16_t rnti;
    uint16_t pduIndex;
-   BwpCfg sib1PdschBwpCfg;
+   BwpCfg pdschBwpCfg;
    uint8_t numCodewords;
    CodewordInfo codeword[MAX_CODEWORDS];
    uint16_t dataScramblingId;
@@ -146,11 +146,11 @@ typedef struct sib1PdschCfg
    uint8_t  transmissionScheme;
    uint8_t  refPoint;
    DmrsInfo dmrs;
-   PdschFreqAlloc sib1FreqAlloc;
-   PdschTimeAlloc sib1TimeAlloc;
+   PdschFreqAlloc freqAlloc;
+   PdschTimeAlloc timeAlloc;
    BeamformingInfo beamPdschInfo;
    TxPowerPdschInfo txPdschPower;
-} Sib1PdschCfg;
+} PdschCfg;
 /* SIB1 PDSCH structures end */
 
 /* SIB1 interface structure */
@@ -186,18 +186,18 @@ typedef struct dlDCI
    uint8_t aggregLevel;
    BeamformingInfo beamPdcchInfo;
    TxPowerPdcchInfo txPdcchPower;
-   Sib1PdschCfg     *pdschCfg;
+   PdschCfg     *pdschCfg;
 } DlDCI;
 
-typedef struct sib1PdcchCfg
+typedef struct pdcchCfg
 {
-   BwpCfg sib1PdcchBwpCfg;
+   BwpCfg pdcchBwpCfg;
    /* coreset-0 configuration */
-   CoresetCfg sib1Coreset0Cfg;
+   CoresetCfg coreset0Cfg;
 
    uint16_t numDlDci;
-   DlDCI    sib1DlDci; /* as of now its only one DCI, later it will be numDlCi */
-} Sib1PdcchCfg;
+   DlDCI    dci; /* as of now its only one DCI, later it will be numDlCi */
+} PdcchCfg;
 /* end of SIB1 PDCCH structures */
 
 typedef struct
@@ -212,8 +212,8 @@ typedef struct
        
        /* parameters derived in scheduler */
        uint8_t n0;
-   Sib1PdcchCfg sib1PdcchCfg;
-   Sib1PdschCfg sib1PdschCfg;
+   PdcchCfg sib1PdcchCfg;
+   PdschCfg sib1PdschCfg;
 }SchSib1Cfg;
 
 typedef struct schRachCfg
@@ -270,8 +270,8 @@ typedef struct ssbInfo
 
 typedef struct sib1AllocInfo
 {
-   Sib1PdcchCfg sib1PdcchCfg;
-   Sib1PdschCfg sib1PdschCfg;
+   PdcchCfg sib1PdcchCfg;
+   PdschCfg sib1PdschCfg;
 } Sib1AllocInfo;
 
 typedef struct prachSchInfo
@@ -285,8 +285,6 @@ typedef struct prachSchInfo
 /* Interface structure signifying DL broadcast allocation for SSB, SIB1 */
 typedef struct dlBrdcstAlloc
 {
-   uint16_t cellId;  /* Cell Id */
-       SlotIndInfo slotIndInfo; /* Slot Info: sfn, slot number */
        /* Ssb transmission is determined as follows:
         * 0 : No tranamission
         * 1 : SSB Transmission
@@ -302,7 +300,38 @@ typedef struct dlBrdcstAlloc
        Sib1AllocInfo sib1Alloc;
 }DlBrdcstAlloc;
 
-/* Interface structure signifying DL broadcast allocation for SSB, SIB1 */
+typedef struct rarInfo
+{
+   uint16_t raRnti;
+       uint8_t  RAPID;
+       uint16_t ta;
+       uint16_t msg3StartRb;
+       uint8_t  msg3NumRb;
+       uint16_t tcrnti;
+       uint8_t rarPdu[8];
+       uint8_t rarPduLen;
+}RarInfo;
+
+typedef struct rarAlloc
+{
+   RarInfo rarInfo;
+   PdcchCfg rarPdcchCfg;
+   PdschCfg rarPdschCfg;
+}RarAlloc;
+
+typedef struct dlAlloc
+{
+   uint16_t cellId;  /* Cell Id */
+       SlotIndInfo slotIndInfo; /* Slot Info: sfn, slot number */
+
+       /* Allocation for broadcast messages */
+   uint8_t isBroadcastPres;
+       DlBrdcstAlloc brdcstAlloc;
+
+       /* Allocation for RAR message */
+       uint8_t isRarPres;
+       RarAlloc rarAlloc;
+}DlAlloc;
 typedef struct ulSchInfo
 {
    uint16_t      cellId;         /* Cell Id */
@@ -318,7 +347,7 @@ typedef struct rachIndInfo
    SlotIndInfo timingInfo;
    uint8_t     slotIdx;
    uint8_t     symbolIdx;
-   uint8_t     frequencyIdx;
+   uint8_t     freqIdx;
    uint8_t     preambleIdx;
    uint16_t    timingAdv;
 }RachIndInfo;
@@ -335,9 +364,9 @@ typedef int (*SchCellCfgFunc)    ARGS((
    SchCellCfg  *schCellCfg     /* Cell Cfg  */
 ));
 
-typedef int (*SchMacDlBrdcstAllocFunc)     ARGS((                     
-   Pst            *pst,           /* Post Structure */                         
-   DlBrdcstAlloc  *dlBrdcstAlloc    /* DL Broadcast Info */                      
+typedef int (*SchMacDlAllocFunc)     ARGS((                     
+   Pst            *pst,       /* Post Structure */                         
+   DlAlloc        *dlAlloc    /* dl allocation Info */                      
 ));
 
 typedef int (*SchMacUlSchInfoFunc)     ARGS((                     
@@ -347,12 +376,12 @@ typedef int (*SchMacUlSchInfoFunc)     ARGS((
 
 /* function declarations */
 int packMacSchSlotInd(Pst *pst, SlotIndInfo *slotInd);
-int packSchMacDlBrdcstAlloc(Pst *pst, DlBrdcstAlloc  *dlBrdcstAlloc);
+int packSchMacDlAlloc(Pst *pst, DlAlloc  *dlAlloc);
 int packSchMacUlSchInfo(Pst *pst, UlSchInfo *ulSchInfo);
 EXTERN int packSchCellCfg(Pst *pst, SchCellCfg  *schCellCfg);
 EXTERN int packSchCellCfgCfm(Pst *pst, SchCellCfgCfm  *schCellCfgCfm);
 
-EXTERN int MacProcDlBrdcstAlloc(Pst *pst, DlBrdcstAlloc *dlBrdcstAlloc);
+EXTERN int MacProcDlAlloc(Pst *pst, DlAlloc *dlAlloc);
 EXTERN int MacProcSchCellCfg(Pst *pst, SchCellCfg  *schCellCfg);
 EXTERN int MacProcSchCellCfgCfm(Pst *pst, SchCellCfgCfm  *schCellCfgCfm);
 EXTERN int SchHdlCellCfgReq(Pst *pst, SchCellCfg *schCellCfg);
index 2f3d27a..e964900 100644 (file)
@@ -356,7 +356,7 @@ PUBLIC uint16_t l1BuildAndSendSlotIndication()
       slotIndMsg->sfn = sfnValue;
       slotIndMsg->slot = slotValue;
       fillMsgHeader(&slotIndMsg->header, FAPI_SLOT_INDICATION, sizeof(fapi_slot_ind_t));
-      DU_LOG("\nPHY_STUB: [%d:%d] ",sfnValue,slotValue);
+      DU_LOG("\n\nPHY_STUB: SLOT indication [%d:%d]",sfnValue,slotValue);
       handlePhyMessages(slotIndMsg->header.message_type_id, sizeof(fapi_slot_ind_t), (void*)slotIndMsg);
       SPutSBuf(0, 0, (Data *)slotIndMsg, sizeof(slotIndMsg));
    }
@@ -438,27 +438,52 @@ PUBLIC S16 l1HdlDlTtiReq(uint16_t msgLen, void *msg)
    printf("\nPHY_STUB: bchPayloadFlag      %d",        dlTtiReq->pdus->u.ssb_pdu.bchPayloadFlag);
    printf("\nPHY_STUB: bchPayload          %x",        dlTtiReq->pdus->u.ssb_pdu.bchPayload);
 #endif
-   uint8_t numPdus = dlTtiReq->nPdus;
-       if(numPdus == 0)
+       uint8_t pduCount = 0;
+       if(dlTtiReq->nPdus == 0)
        {
                DU_LOG("\nPHY_STUB: No PDU in DL TTI Request");
    }
-       while(numPdus)
+       for(pduCount=0; pduCount<dlTtiReq->nPdus; pduCount++)
        {
-               if(dlTtiReq->pdus->pduType == 3) //SSB_PDU_TYPE
+               if(dlTtiReq->pdus[pduCount].pduType == 3) //SSB_PDU_TYPE
                        DU_LOG("\nPHY_STUB: SSB PDU");
-               else if(dlTtiReq->pdus->pduType == 0)
-                       DU_LOG("\nPHY_STUB: SIB1 PDCCH PDU");
-               else if(dlTtiReq->pdus->pduType == 1)
-                  DU_LOG("\nPHY_STUB: SIB1 PDSCH PDU");
-
-               numPdus--;
+               else if(dlTtiReq->pdus[pduCount].pduType == 0)
+                       DU_LOG("\nPHY_STUB: PDCCH PDU");
+               else if(dlTtiReq->pdus[pduCount].pduType == 1)
+                  DU_LOG("\nPHY_STUB: PDSCH PDU");
        }
-   MAC_FREE(dlTtiReq, sizeof(fapi_dl_tti_req_t));
 #endif
    return ROK;
 }
 
+/*******************************************************************
+*
+* @brief Handles tx_data request received from MAC
+*
+* @details
+*
+*    Function : l1HdlTxDataReq
+*
+*    Functionality:
+*          -Handles tx_data request received from MAC
+*
+* @params[in]   Message length
+*               tx_data request message pointer
+*
+* @return void
+*
+* ****************************************************************/
+
+PUBLIC S16 l1HdlTxDataReq(uint16_t msgLen, void *msg)
+{
+#ifdef FAPI
+   DU_LOG("\nPHY STUB: Received TX DATA Request");
+
+   fapi_tx_data_req_t *txDataReq;
+   txDataReq = (fapi_dl_tti_req_t *)msg;
+#endif
+   return ROK;
+}
 /*******************************************************************
 *
 * @brief Handles Ul Tti request received from MAC
@@ -503,7 +528,6 @@ PUBLIC S16 l1HdlUlTtiReq(uint16_t msgLen, void *msg)
       l1BuildAndSendRachInd(ulTtiReq->slot, ulTtiReq->sfn);
    }
 
-       MAC_FREE(ulTtiReq, sizeof(fapi_ul_tti_req_t));
 #endif
    return ROK;
 }
@@ -544,6 +568,9 @@ void l1ProcessFapiRequest(uint8_t msgType, uint32_t msgLen, void *msg)
       case FAPI_DL_TTI_REQUEST:
          l1HdlDlTtiReq(msgLen, msg);
          break;
+      case FAPI_TX_DATA_REQUEST:
+         l1HdlTxDataReq(msgLen, msg);
+         break;
       case FAPI_UL_TTI_REQUEST:
          l1HdlUlTtiReq(msgLen, msg);
          break;
index d45ede3..8e79dba 100644 (file)
@@ -32,7 +32,6 @@ void *GenerateTicks(void *arg)
    while(counter)
    {
       sleep(1);
-      DU_LOG("\n\nPHY_STUB: SLOT indication");
       /* Send Slot indication indication to lower mac */
       l1BuildAndSendSlotIndication();
       counter--;