warning set 3: fixed warning realted to unused-variable and implicit-function-declaration
[o-du/l2.git] / src / 5gnrmac / lwr_mac_fsm.c
index d42b5c4..820a73f 100644 (file)
 #include "du_app_mac_inf.h"
 #include "mac.h"
 #include "rg.x"            /* typedefs for MAC */
+#include "lwr_mac_phy.h"
+#include "math.h"
 
 #define MIB_SFN_BITMASK 0xFC
+#define PDCCH_PDU_TYPE 0
+#define PDSCH_PDU_TYPE 1
 #define SSB_PDU_TYPE 3
 #define SETLENGTH(x, size) x += size
 
+extern void fapiMacConfigRsp();
+/* Global variables */
+SlotIndInfo slotIndInfo;
+uint8_t slotIndIdx;
 
-EXTERN void sendToPhy ARGS((uint8_t msgType, uint32_t msgLen, void *msg));
-SlotIndInfo slotIndInfo;   //global variable
+void lwrMacInit()
+{
+#ifdef INTEL_WLS
+   uint8_t  idx;
+
+   /* Initializing WLS free mem list */
+   slotIndIdx = 1;
+   for(idx = 0; idx < WLS_MEM_FREE_PRD; idx++)
+   {
+      cmLListInit(&wlsBlockToFreeList[idx]);
+   }
+#endif
+}
 
  /*******************************************************************
   *
@@ -1247,9 +1266,9 @@ PUBLIC void fillRssiMeas(uint8_t value, ClCellParam **cellPtr)
 
 uint32_t getParamValue(fapi_uint16_tlv_t *tlv, uint16_t type)
 {
-    uint16_t valueLen;
+    //uint16_t valueLen;
     void *posPtr;
-    valueLen = tlv->tl.length;
+    //valueLen = tlv->tl.length;
     posPtr   = &tlv->tl.tag;
     posPtr   += sizeof(tlv->tl.tag);
     posPtr   += sizeof(tlv->tl.length);
@@ -1299,12 +1318,17 @@ S16 lwr_mac_handleParamReqEvt(void *msg)
    uint32_t msgLen;      //Length of message Body
    msgLen = 0;
    fapi_param_req_t *paramReq;
+#ifdef INTEL_WLS
+   WLS_MEM_ALLOC(paramReq, sizeof(fapi_param_req_t));
+#else
    MAC_ALLOC(paramReq, sizeof(fapi_param_req_t));
+#endif
    if(paramReq != NULLP)
    {
       fillMsgHeader(&paramReq->header, FAPI_PARAM_REQUEST, msgLen);
       DU_LOG("\nLOWER MAC: sending param Req to Phy");
-      sendToPhy(paramReq->header.message_type_id, sizeof(fapi_param_req_t), (void *)paramReq);
+      LwrMacSendToPhy(paramReq->header.message_type_id, sizeof(fapi_param_req_t), (void *)paramReq);
       MAC_FREE(paramReq, sizeof(fapi_param_req_t));
       return ROK;
    }
@@ -1830,6 +1854,8 @@ S16 lwr_mac_handleParamRspEvt(void *msg)
            }
            MAC_FREE(cellParam, sizeof(ClCellParam));
            MAC_FREE(paramRsp, sizeof(fapi_param_resp_t));
+             
+           sendToLowerMac(FAPI_CONFIG_REQUEST, 0, (void *)NULL);
            return ROK;
          }
          else
@@ -1887,7 +1913,11 @@ S16 lwr_mac_handleConfigReqEvt(void *msg)
    cellParams = rgCb[inst].cell;
    macCfgParams = cellParams->macCellCfg;
    configReqSize = sizeof(fapi_config_req_t) + (macCfgParams.numTlv * sizeof(fapi_uint16_tlv_t));
+#ifdef INTEL_WLS
+   WLS_MEM_ALLOC(configReq, configReqSize);
+#else
    MAC_ALLOC(configReq, configReqSize);
+#endif
 
    if(configReq != NULL)
    {
@@ -1924,14 +1954,18 @@ S16 lwr_mac_handleConfigReqEvt(void *msg)
       fillTlvs(&configReq->tlvs[index++], FAPI_PRACH_SEQUENCE_LENGTH_TAG,      sizeof(uint8_t), macCfgParams.prachCfg.prachSeqLen, &msgLen);
       fillTlvs(&configReq->tlvs[index++], FAPI_PRACH_SUBC_SPACING_TAG,         sizeof(uint8_t), macCfgParams.prachCfg.prachSubcSpacing, &msgLen);
       fillTlvs(&configReq->tlvs[index++], FAPI_RESTRICTED_SET_CONFIG_TAG,      sizeof(uint8_t), macCfgParams.prachCfg.prachRstSetCfg, &msgLen);
-      fillTlvs(&configReq->tlvs[index++], FAPI_NUM_PRACH_FD_OCCASIONS_TAG,     sizeof(uint8_t), macCfgParams.prachCfg.prachFdm, &msgLen);
+      fillTlvs(&configReq->tlvs[index++], FAPI_NUM_PRACH_FD_OCCASIONS_TAG,
+                               sizeof(uint8_t), macCfgParams.prachCfg.msg1Fdm, &msgLen);
       fillTlvs(&configReq->tlvs[index++], FAPI_PRACH_ROOT_SEQUENCE_INDEX_TAG,  sizeof(uint16_t), macCfgParams.prachCfg.fdm[0].rootSeqIdx, &msgLen);
       fillTlvs(&configReq->tlvs[index++], FAPI_NUM_ROOT_SEQUENCES_TAG,         sizeof(uint8_t), macCfgParams.prachCfg.fdm[0].numRootSeq, &msgLen);
       fillTlvs(&configReq->tlvs[index++], FAPI_K1_TAG,                         sizeof(uint16_t), macCfgParams.prachCfg.fdm[0].k1, &msgLen);
       fillTlvs(&configReq->tlvs[index++], FAPI_PRACH_ZERO_CORR_CONF_TAG ,      sizeof(uint8_t), macCfgParams.prachCfg.fdm[0].zeroCorrZoneCfg, &msgLen);
       fillTlvs(&configReq->tlvs[index++], FAPI_NUM_UNUSED_ROOT_SEQUENCES_TAG,  sizeof(uint8_t), macCfgParams.prachCfg.fdm[0].numUnusedRootSeq, &msgLen);
+      //MAC_ALLOC(macCfgParams.prachCfg.fdm[0].unsuedRootSeq, \
+         sizeof(uint8_t)*macCfgParams.prachCfg.fdm[0].numUnusedRootSeq);
+      macCfgParams.prachCfg.fdm[0].unsuedRootSeq = (uint8_t *)malloc(sizeof(uint8_t)*macCfgParams.prachCfg.fdm[0].numUnusedRootSeq);
       fillTlvs(&configReq->tlvs[index++], FAPI_UNUSED_ROOT_SEQUENCES_TAG,
-               sizeof(uint8_t), *(macCfgParams.prachCfg.fdm[0].unsuedRootSeq), &msgLen);
+                  sizeof(uint8_t), *(macCfgParams.prachCfg.fdm[0].unsuedRootSeq), &msgLen);
       fillTlvs(&configReq->tlvs[index++], FAPI_SSB_PER_RACH_TAG,               sizeof(uint8_t), macCfgParams.prachCfg.ssbPerRach, &msgLen);
       fillTlvs(&configReq->tlvs[index++], FAPI_PRACH_MULTIPLE_CARRIERS_IN_A_BAND_TAG,  sizeof(uint8_t), macCfgParams.prachCfg.prachMultCarrBand, &msgLen);
 
@@ -1955,7 +1989,8 @@ S16 lwr_mac_handleConfigReqEvt(void *msg)
 
       fillMsgHeader(&configReq->header, FAPI_CONFIG_REQUEST, msgLen);
       DU_LOG("\nLOWER_MAC: Sending Config Request to Phy");
-      sendToPhy(configReq->header.message_type_id, msgLen, (void *)configReq);
+      /* TODO : Recheck the size / msglen to be sent to WLS_Put*/
+      LwrMacSendToPhy(configReq->header.message_type_id, msgLen, (void *)configReq);
       MAC_FREE(configReq, configReqSize);
       return ROK;
    }
@@ -1982,6 +2017,11 @@ S16 lwr_mac_handleConfigRspEvt(void *msg)
       {
          DU_LOG("\nLOWER MAC: PHY has moved to Conigured state \n");
          clGlobalCp.phyState = PHY_STATE_CONFIGURED;
+         /* TODO : 
+          * Store config response into an intermediate struture and send to MAC
+          * Support LC and LWLC for sending config rsp to MAC 
+          */
+         fapiMacConfigRsp();
          MAC_FREE(configRsp, sizeof(fapi_config_resp_t));
          return ROK;
       }
@@ -2004,16 +2044,20 @@ S16 lwr_mac_handleConfigRspEvt(void *msg)
 
 S16 lwr_mac_handleStartReqEvt(void *msg)
 {
-#ifdef FAPi
+#ifdef FAPI
    uint32_t msgLen = 0;
    fapi_start_req_t *startReq;
+#ifdef INTEL_WLS
+   WLS_MEM_ALLOC(startReq, sizeof(fapi_start_req_t));
+#else
    MAC_ALLOC(startReq, sizeof(fapi_start_req_t));
+#endif
 
    if(startReq != NULL)
    {
       fillMsgHeader(&startReq->header, FAPI_START_REQUEST, msgLen);
       DU_LOG("\nLOWER MAC: Sending Start Request to PHY");
-      sendToPhy(startReq->header.message_type_id, sizeof(fapi_start_req_t), (void *)startReq);
+      LwrMacSendToPhy(startReq->header.message_type_id, sizeof(fapi_start_req_t), (void *)startReq);
       MAC_FREE(startReq, sizeof(fapi_start_req_t));
       return ROK;
    }
@@ -2032,9 +2076,8 @@ S16 lwr_mac_handleStopReqEvt(void *msg)
 #ifdef FAPI
    /* stop TX and RX operation return PHy to configured State
       send stop.indication to l2/l3 */
-#else
-   RETVALUE(ROK);
 #endif
+   return ROK;
 }
 
 /*******************************************************************
@@ -2081,7 +2124,8 @@ PUBLIC void setMibPdu(uint8_t *mibPdu, uint32_t *val)
  ******************************************************************/
 
 S16 fillSsbPdu(fapi_dl_tti_req_pdu_t *dlTtiReqPdu, MacCellCfg *macCellCfg,
-uint32_t *msgLen)
+       MacDlSlot *currDlSlot,
+       uint32_t *msgLen, uint8_t ssbIdxCount) 
 {
    uint32_t mibPayload = 0;
    if(dlTtiReqPdu != NULL)
@@ -2089,7 +2133,7 @@ uint32_t *msgLen)
       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 = macCb.macCell->dlSlot[0].cellBroadcastInfo.ssbIdxSupported;
+      dlTtiReqPdu->u.ssb_pdu.ssbBlockIndex = currDlSlot->cellBroadcastInfo.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;
@@ -2112,7 +2156,313 @@ uint32_t *msgLen)
        return RFAILED;
     }
 }
+
+/*******************************************************************
+ *
+ * @brief fills Dl DCI PDU required for DL TTI info in MAC
+ *
+ * @details
+ *
+ *    Function : fillDlDciPdu
+ *
+ *    Functionality:
+ *         -Fills the Dl DCI PDU
+ *
+ * @params[in] Pointer to fapi_dl_dci_t
+ *             Pointer to Sib1PdcchCfg
+ * @return ROK
+ *
+ ******************************************************************/
+
+void fillDlDciPdu(fapi_dl_dci_t *dlDciPtr, Sib1PdcchCfg *sib1PdcchInfo)
+{
+   if(dlDciPtr != NULLP)
+   {
+      uint8_t numBytes;
+      uint8_t bytePos;
+      uint8_t bitPos;
+      
+      uint16_t coreset0Size;
+      uint16_t rbStart;
+      uint16_t rbLen;
+      uint32_t freqDomResAssign;
+      uint32_t timeDomResAssign;
+      uint8_t  VRB2PRBMap;
+      uint32_t modNCodScheme;
+      uint8_t  redundancyVer;
+      uint32_t sysInfoInd;
+      uint32_t reserved;
+
+      /* Size(in bits) of each field in DCI format 0_1 
+                * as mentioned in spec 38.214 */
+      uint8_t freqDomResAssignSize;
+      uint8_t timeDomResAssignSize = 4;
+      uint8_t VRB2PRBMapSize       = 1;
+      uint8_t modNCodSchemeSize    = 5;
+      uint8_t redundancyVerSize    = 2;
+      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;
+
+      /* 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
+       */
+      coreset0Size= sib1PdcchInfo->sib1Coreset0Cfg.coreSet0Size;
+               rbStart = 0;              /* For SIB1 */
+      //rbStart = sib1PdcchInfo->sib1DlDci.pdschCfg->sib1FreqAlloc.rbStart;
+      rbLen = sib1PdcchInfo->sib1DlDci.pdschCfg->sib1FreqAlloc.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 = sib1PdcchInfo->sib1DlDci.pdschCfg->sib1TimeAlloc.
+                         rowIndex -1;
+      VRB2PRBMap       = sib1PdcchInfo->sib1DlDci.pdschCfg->sib1FreqAlloc.\
+                         vrbPrbMapping;
+      modNCodScheme    = sib1PdcchInfo->sib1DlDci.pdschCfg->codeword[0].mcsIndex;
+      redundancyVer    = sib1PdcchInfo->sib1DlDci.pdschCfg->codeword[0].rvIndex;
+      sysInfoInd       = 0;           /* 0 for SIB1; 1 for SI messages */
+      reserved         = 0;
+
+      /* Reversing bits in each DCI field */
+      freqDomResAssign = reverseBits(freqDomResAssign, freqDomResAssignSize);
+      timeDomResAssign = reverseBits(timeDomResAssign, timeDomResAssignSize);
+      VRB2PRBMap       = reverseBits(VRB2PRBMap, VRB2PRBMapSize);
+      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\
+              + VRB2PRBMapSize + modNCodSchemeSize + redundancyVerSize\
+              + sysInfoIndSize + 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,\
+        redundancyVer, redundancyVerSize);
+     fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
+        sysInfoInd, sysInfoIndSize);
+     fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
+        reserved, reservedSize);
+
+   }
+} /* fillDlDciPdu */
+
+/*******************************************************************
+ *
+ * @brief fills PDCCH PDU required for DL TTI info in MAC
+ *
+ * @details
+ *
+ *    Function : fillPdcchPdu
+ *
+ *    Functionality:
+ *         -Fills the Pdcch PDU info
+ *          stored in MAC
+ *
+ * @params[in] Pointer to FAPI DL TTI Req
+ *             Pointer to Sib1PdcchCfg
+ *             Pointer to msgLen of DL TTI Info
+ * @return ROK
+ *
+ ******************************************************************/
+
+S16 fillPdcchPdu(fapi_dl_tti_req_pdu_t *dlTtiReqPdu, Sib1PdcchCfg *sib1PdcchInfo,
+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;
+#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);
+       dlTtiReqPdu->pduSize = sizeof(fapi_dl_pdcch_pdu_t);
+       SETLENGTH(*msgLen, sizeof(fapi_dl_pdcch_pdu_t));
+
+    }
+    return ROK;
+
+}
+
+/*******************************************************************
+ *
+ * @brief fills PDSCH PDU required for DL TTI info in MAC
+ *
+ * @details
+ *
+ *    Function : fillPdschPdu
+ *
+ *    Functionality:
+ *         -Fills the Pdsch PDU info
+ *          stored in MAC
+ *
+ * @params[in] Pointer to FAPI DL TTI Req
+ *             Pointer to Sib1PdschCfg
+ *             Pointer to msgLen of DL TTI Info
+ * @return ROK
+ *
+ ******************************************************************/
+
+void fillPdschPdu(fapi_dl_tti_req_pdu_t *dlTtiReqPdu, Sib1PdschCfg *sib1PdschInfo,
+uint32_t *msgLen)
+{
+    uint8_t idx;
+
+    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;
+       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.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;
+       /* 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.preCodingAndBeamforming.pmi_bfi[0]. \
+          pmIdx = sib1PdschInfo->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;
+       dlTtiReqPdu->pduSize = sizeof(fapi_dl_pdsch_pdu_t);
+       SETLENGTH(*msgLen, sizeof(fapi_dl_pdsch_pdu_t));
+
+    }
+
+}
+
+/***********************************************************************
+ *
+ * @brief calculates the total size to be allocated for DL TTI Req
+ *
+ * @details
+ *
+ *    Function : calculatePduCount
+ *
+ *    Functionality:
+ *         -calculates the total pdu count to be allocated for DL TTI Req
+ *
+ * @params[in]    DlBrdcstAlloc *cellBroadcastInfo
+ * @return count
+ *
+ * ********************************************************************/
+uint8_t calculatePduCount(DlBrdcstAlloc *cellBroadcastInfo)
+{
+   uint8_t count = 0;
+   uint8_t idx = 0;
+   if(cellBroadcastInfo->ssbTrans)
+   {
+      for(idx = 0; idx < cellBroadcastInfo->ssbIdxSupported; idx++)
+      {
+         count++;
+      }
+   }
+   if(cellBroadcastInfo->sib1Trans)
+   {
+      count += 2;
+   }
+   return count;
+}
+
+#endif
+
 /*******************************************************************
  *
  * @brief Sends DL TTI Request to PHY
@@ -2132,57 +2482,108 @@ uint32_t *msgLen)
 S16 handleDlTtiReq(CmLteTimingInfo *dlTtiReqtimingInfo)
 {
 #ifdef FAPI
-   uint32_t msgLen;
-   fapi_dl_tti_req_t *dlTtiReq;
-   fapi_dl_tti_req_pdu_t *dlTtiReqPdu;
-   RgCellCb  *cellCbParams;
+   uint8_t idx;
+       uint8_t nPdu = 0;
+   uint32_t msgLen = 0;
+   fapi_dl_tti_req_t *dlTtiReq = NULLP;
+   fapi_dl_tti_req_pdu_t *dlTtiReqPdu = NULLP;
+   RgCellCb  *cellCbParams = NULLP;
+       MacDlSlot *currDlSlot = NULLP;
    MacCellCfg macCellCfg;
+       cmMemset((U8 *)&macCellCfg, 0, sizeof(MacCellCfg));
    Inst inst = 0;
 
-   cellCbParams = rgCb[inst].cell;
-   if(dlTtiReqtimingInfo != NULLP)
+   if(clGlobalCp.phyState == PHY_STATE_RUNNING)
    {
-      MAC_ALLOC(dlTtiReq, sizeof(fapi_dl_tti_req_t));
-      if(dlTtiReq != NULLP)
+      cellCbParams = rgCb[inst].cell;
+      macCellCfg = cellCbParams->macCellCfg;
+
+      if(dlTtiReqtimingInfo != NULLP)
       {
-         /* fill the SFN and slot value from crntTime */
-         dlTtiReq->sfn = dlTtiReqtimingInfo->sfn;
-         dlTtiReq->slot = dlTtiReqtimingInfo->slot;
-         dlTtiReq->nPdus = 0;
-         dlTtiReq->nGroup = 0;
-         if(macCb.macCell->dlSlot[0].cellBroadcastInfo.ssbTrans)
+#ifdef INTEL_WLS
+         WLS_MEM_ALLOC(dlTtiReq, sizeof(fapi_dl_tti_req_t));
+#else
+         MAC_ALLOC(dlTtiReq, sizeof(fapi_dl_tti_req_t));
+#endif
+         if(dlTtiReq != NULLP)
          {
-            macCellCfg = cellCbParams->macCellCfg;
-
-            MAC_ALLOC(dlTtiReqPdu, sizeof(fapi_dl_tti_req_pdu_t));
-            if(dlTtiReqPdu != NULLP)
+            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 */
+                               nPdu = dlTtiReq->nPdus;
+            dlTtiReq->nGroup = 0;
+            if(dlTtiReq->nPdus > 0)
             {
-               fillSsbPdu(dlTtiReqPdu, &macCellCfg, &msgLen);
-               dlTtiReq->pdus = dlTtiReqPdu;
-            }
-            (dlTtiReq->nPdus)++;
-            msgLen = sizeof(fapi_dl_tti_req_t) - sizeof(fapi_msg_t);
-            fillMsgHeader(&dlTtiReq->header, FAPI_DL_TTI_REQUEST, msgLen);
-            sendToPhy(dlTtiReq->header.message_type_id, msgLen, (void *)dlTtiReq);
-            MAC_FREE(dlTtiReqPdu, sizeof(fapi_dl_tti_req_pdu_t));
+#ifdef INTEL_WLS
+               WLS_MEM_ALLOC(dlTtiReqPdu, (nPdu * sizeof(fapi_dl_tti_req_pdu_t)));
+#else
+               MAC_ALLOC(dlTtiReqPdu, (nPdu * sizeof(fapi_dl_tti_req_pdu_t)));
+#endif
+               if(currDlSlot->cellBroadcastInfo.ssbTrans)
+               {
+                 if(dlTtiReqPdu != NULLP)
+                 {
+                    for(idx = 0; idx < currDlSlot->cellBroadcastInfo.ssbIdxSupported; idx++)
+                    {
+                                                         if(idx > 0)
+                       dlTtiReq->pdus++;
+                       fillSsbPdu(dlTtiReqPdu, &macCellCfg, currDlSlot, &msgLen, idx);
+                       dlTtiReq->pdus = dlTtiReqPdu;
+                    }
+                 }
+               }
+               if(currDlSlot->cellBroadcastInfo.sib1Trans)
+               {
+                  /* Filling SIB1 param */
+                  if(dlTtiReqPdu != NULLP)
+                  {
+                     dlTtiReq->pdus++;
+                     fillPdcchPdu(dlTtiReqPdu, &currDlSlot->cellBroadcastInfo.sib1Alloc.sib1PdcchCfg, &msgLen);
+                     dlTtiReq->pdus = dlTtiReqPdu;
+                     dlTtiReq->pdus++;
+                     fillPdschPdu(dlTtiReqPdu, &currDlSlot->cellBroadcastInfo.sib1Alloc.sib1PdschCfg, &msgLen);
+                     dlTtiReq->pdus = dlTtiReqPdu;
+                  }
+               }
+               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)
+                                       {
+                  MAC_FREE(dlTtiReqPdu->u.pdcch_pdu.dlDci, sizeof(fapi_dl_dci_t));
+                                  }
+               MAC_FREE(dlTtiReqPdu, (nPdu * sizeof(fapi_dl_tti_req_pdu_t)));
+             }
+             else
+             {
+                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);
+             }
+             MAC_FREE(dlTtiReq, sizeof(fapi_dl_tti_req_t));
+             return ROK;
+         }
+         else
+         {
+            DU_LOG("\nLOWER MAC: Failed to allocate memory for DL TTI Request");
+            return RFAILED;
          }
-         MAC_FREE(dlTtiReq, sizeof(fapi_dl_tti_req_t));
-         return ROK;
       }
-               else
+      else
       {
-         DU_LOG("\nLOWER MAC: Failed to allocate memory for DL TTI Request");
+         DU_LOG("\nLOWER MAC: Current TTI Info is NULL");
          return RFAILED;
       }
    }
-       else
-       {
-          DU_LOG("\nLOWER MAC: Current TTI Info is NULL");
-      return RFAILED;
+   else
+   {
+       lwr_mac_handleInvalidEvt(dlTtiReqtimingInfo);
    }
-#else
-   return ROK;
 #endif
+   return ROK;
 }
 
 lwrMacFsmHdlr fapiEvtHdlr[MAX_STATE][MAX_EVENT] =