Changes for SR, BSR and MSG5 Handling 89/4689/3
authorBalaji Shankaran <balaji.shankaran@radisys.com>
Tue, 8 Sep 2020 15:38:29 +0000 (21:08 +0530)
committerBalaji Shankaran <balaji.shankaran@radisys.com>
Fri, 11 Sep 2020 19:01:23 +0000 (00:31 +0530)
Change-Id: If69aace3bec611bee779d44dcbec6338fe0e954a
Signed-off-by: Balaji Shankaran <balaji.shankaran@radisys.com>
56 files changed:
src/5gnrmac/lwr_mac_fsm.c
src/5gnrmac/lwr_mac_handle_phy.c
src/5gnrmac/lwr_mac_upr_inf.c
src/5gnrmac/lwr_mac_upr_inf.h
src/5gnrmac/lwr_mac_utils.h [new file with mode: 0644]
src/5gnrmac/mac.h
src/5gnrmac/mac_cfg_hdl.c
src/5gnrmac/mac_demux.c
src/5gnrmac/mac_msg_hdl.c
src/5gnrmac/mac_rach.c
src/5gnrmac/mac_slot_ind.c
src/5gnrmac/mac_stop_ind.c
src/5gnrmac/mac_ue_mgr.c
src/5gnrmac/mac_upr_inf_api.c
src/5gnrmac/mac_upr_inf_api.h
src/5gnrmac/mac_utils.c [new file with mode: 0644]
src/5gnrmac/mac_utils.h
src/5gnrmac/rg_ptui.c
src/5gnrrlc/kw_lim.c
src/5gnrrlc/kw_tmm_dl.c
src/5gnrrlc/kw_tmm_ul.c
src/5gnrrlc/kw_ul_ex_ms.c
src/5gnrrlc/kw_utl_dl.c
src/5gnrrlc/mac_stub.c
src/5gnrrlc/rlc_upr_inf_api.c [new file with mode: 0644]
src/5gnrrlc/rlc_upr_inf_api.h [new file with mode: 0644]
src/5gnrrlc/rlc_utils.c [new file with mode: 0644]
src/5gnrrlc/rlc_utils.h [new file with mode: 0644]
src/5gnrsch/rg_sch_ex_ms.c
src/5gnrsch/sch.c
src/5gnrsch/sch.h
src/5gnrsch/sch_common.c
src/5gnrsch/sch_rach.c
src/5gnrsch/sch_slot_ind.c
src/5gnrsch/sch_ue_mgr.c
src/5gnrsch/sch_utils.c
src/5gnrsch/sch_utils.h
src/cm/common_def.c [new file with mode: 0644]
src/cm/common_def.h
src/cm/du_app_mac_inf.h
src/cm/du_app_rlc_inf.c
src/cm/du_app_rlc_inf.h
src/cm/mac_sch_interface.c
src/cm/mac_sch_interface.h
src/cm/rgu.c
src/cm/rgu.x
src/du_app/du_cell_mgr.c
src/du_app/du_cfg.c
src/du_app/du_cfg.h
src/du_app/du_f1ap_msg_hdl.c
src/du_app/du_f1ap_msg_hdl.h
src/du_app/du_mgr_ex_ms.c
src/du_app/du_msg_hdl.c
src/du_app/du_ue_mgr.c
src/phy_stub/l1.h [new file with mode: 0644]
src/phy_stub/l1_bdy1.c

index 0ea9aa9..3345227 100644 (file)
@@ -2300,7 +2300,7 @@ void fillSib1DlDciPdu(fapi_dl_dci_t *dlDciPtr, PdcchCfg *sib1PdcchInfo)
        * RBLen = length of contiguously allocted RBs
        * Spec 38.214 Sec 5.1.2.2.2
        */
-      coreset0Size= sib1PdcchInfo->coreset0Cfg.coreSet0Size;
+      coreset0Size= sib1PdcchInfo->coreset0Cfg.coreSetSize;
       rbStart = 0;              /* For SIB1 */
       //rbStart = sib1PdcchInfo->dci.pdschCfg->pdschFreqAlloc.freqAlloc.startPrb;
       rbLen = sib1PdcchInfo->dci.pdschCfg->pdschFreqAlloc.freqAlloc.numPrb;
@@ -2439,7 +2439,7 @@ void fillRarDlDciPdu(fapi_dl_dci_t *dlDciPtr, PdcchCfg *rarPdcchInfo)
        */
 
       /* TODO: Fill values of coreset0Size, rbStart and rbLen */
-      coreset0Size= rarPdcchInfo->coreset0Cfg.coreSet0Size;
+      coreset0Size= rarPdcchInfo->coreset0Cfg.coreSetSize;
       rbStart = 0;              /* For SIB1 */
       //rbStart = rarPdcchInfo->dci.pdschCfg->freqAlloc.rbStart;
       rbLen = rarPdcchInfo->dci.pdschCfg->pdschFreqAlloc.freqAlloc.numPrb;
@@ -2582,7 +2582,7 @@ void fillMsg4DlDciPdu(fapi_dl_dci_t *dlDciPtr, PdcchCfg *msg4PdcchInfo,\
        */
 
       /* TODO: Fill values of coreset0Size, rbStart and rbLen */
-      coreset0Size = msg4PdcchInfo->coreset0Cfg.coreSet0Size;
+      coreset0Size = msg4PdcchInfo->coreset0Cfg.coreSetSize;
       //rbStart = msg4PdcchInfo->dci.pdschCfg->freqAlloc.rbStart;
       rbLen = msg4PdcchInfo->dci.pdschCfg->pdschFreqAlloc.freqAlloc.numPrb;
 
@@ -3660,6 +3660,280 @@ uint16_t fillUlTtiReq(SlotIndInfo currTimingInfo)
    return ROK;
 }
 
+#ifdef INTEL_FAPI
+/*******************************************************************
+ *
+ * @brief fills bsr Ul DCI PDU required for UL DCI Request to PHY
+ *
+ * @details
+ *
+ *    Function : fillUlDciPdu
+ *
+ *    Functionality:
+ *         -Fills the Ul DCI PDU, spec Ref:38.212, Table 7.3.1-1
+ *
+ * @params[in] Pointer to fapi_dl_dci_t
+ *             Pointer to DciInfo
+ * @return ROK
+ *
+ ******************************************************************/
+void fillUlDciPdu(fapi_dl_dci_t *ulDciPtr, DciInfo *schDciInfo)
+{
+   if(ulDciPtr != NULLP)
+   {
+      uint8_t numBytes;
+      uint8_t bytePos;
+      uint8_t bitPos;
+
+      uint8_t coreset1Size = 0;
+      uint16_t rbStart = 0;
+      uint16_t rbLen = 0;
+      uint8_t  dciFormatId = 0;
+      uint32_t freqDomResAssign;
+      uint8_t  timeDomResAssign;
+      uint8_t  freqHopFlag;
+      uint8_t  modNCodScheme;
+      uint8_t  ndi;
+      uint8_t  redundancyVer = 0;
+      uint8_t  harqProcessNum = 0;
+      uint8_t  puschTpc = 0;
+      uint8_t  ul_SlInd = 0;
+
+      /* Size(in bits) of each field in DCI format 0_0 */
+      uint8_t dciFormatIdSize      = 1;
+      uint8_t freqDomResAssignSize = 0;
+      uint8_t timeDomResAssignSize = 4;
+      uint8_t freqHopFlagSize      = 1;
+      uint8_t modNCodSchemeSize    = 5;
+      uint8_t ndiSize              = 1;
+      uint8_t redundancyVerSize    = 2;
+      uint8_t harqProcessNumSize   = 4;
+      uint8_t puschTpcSize         = 2;
+      uint8_t ul_SlIndSize         = 1;
+
+      ulDciPtr->rnti                          = schDciInfo->dciInfo.rnti;
+      ulDciPtr->scramblingId                  = schDciInfo->dciInfo.scramblingId;    
+      ulDciPtr->scramblingRnti                = schDciInfo->dciInfo.scramblingRnti;
+      ulDciPtr->cceIndex                      = schDciInfo->dciInfo.cceIndex;
+      ulDciPtr->aggregationLevel              = schDciInfo->dciInfo.aggregLevel;
+      ulDciPtr->pc_and_bform.numPrgs          = schDciInfo->dciInfo.beamPdcchInfo.numPrgs;
+      ulDciPtr->pc_and_bform.prgSize          = schDciInfo->dciInfo.beamPdcchInfo.prgSize;
+      ulDciPtr->pc_and_bform.digBfInterfaces  = schDciInfo->dciInfo.beamPdcchInfo.digBfInterfaces;
+      ulDciPtr->pc_and_bform.pmi_bfi[0].pmIdx = schDciInfo->dciInfo.beamPdcchInfo.prg[0].pmIdx;
+      ulDciPtr->pc_and_bform.pmi_bfi[0].beamIdx[0].beamidx = schDciInfo->dciInfo.beamPdcchInfo.prg[0].beamIdx[0];
+      ulDciPtr->beta_pdcch_1_0                = schDciInfo->dciInfo.txPdcchPower.powerValue;           
+      ulDciPtr->powerControlOfssetSS          = schDciInfo->dciInfo.txPdcchPower.powerControlOffsetSS;
+
+      /* Calculating freq domain resource allocation field value and size
+       * coreset1Size = Size of coreset 1
+       * RBStart = Starting Virtual Rsource block
+       * RBLen = length of contiguously allocted RBs
+       * Spec 38.214 Sec 5.1.2.2.2
+       */
+      if(schDciInfo->formatType == FORMAT0_0)
+      {
+         coreset1Size = schDciInfo->coresetCfg.coreSetSize;
+         rbLen = schDciInfo->format.format0_0.freqAlloc.numPrb;
+         rbStart = schDciInfo->format.format0_0.freqAlloc.startPrb;
+
+         if((rbLen >=1) && (rbLen <= coreset1Size - rbStart))
+         {
+            if((rbLen - 1) <= floor(coreset1Size / 2))
+               freqDomResAssign = (coreset1Size * (rbLen-1)) + rbStart;
+            else
+               freqDomResAssign = (coreset1Size * (coreset1Size - rbLen + 1)) \
+                                  + (coreset1Size - 1 - rbStart);
+
+            freqDomResAssignSize = ceil(log2(coreset1Size * (coreset1Size + 1) / 2));
+         }
+         /* Fetching DCI field values */
+         dciFormatId      = schDciInfo->formatType; /* DCI indentifier for UL DCI */
+         timeDomResAssign = schDciInfo->format.format0_0.rowIndex;
+         freqHopFlag      = schDciInfo->format.format0_0.freqHopFlag; 
+         modNCodScheme    = schDciInfo->format.format0_0.mcs;
+         ndi              = schDciInfo->format.format0_0.ndi; 
+         redundancyVer    = schDciInfo->format.format0_0.rv;
+         harqProcessNum   = schDciInfo->format.format0_0.harqProcId; 
+         puschTpc         = schDciInfo->format.format0_0.tpcCmd;
+         ul_SlInd         = schDciInfo->format.format0_0.sUlCfgd;
+
+         /* Reversing bits in each DCI field */
+         dciFormatId      = reverseBits(dciFormatId, dciFormatIdSize);
+         freqDomResAssign = reverseBits(freqDomResAssign, freqDomResAssignSize);
+         timeDomResAssign = reverseBits(timeDomResAssign, timeDomResAssignSize);
+         modNCodScheme    = reverseBits(modNCodScheme, modNCodSchemeSize);
+         redundancyVer    = reverseBits(redundancyVer, redundancyVerSize);
+         harqProcessNum   = reverseBits(harqProcessNum, harqProcessNumSize);
+         puschTpc         = reverseBits(puschTpc, puschTpcSize);
+         ul_SlInd         = reverseBits(ul_SlInd, ul_SlIndSize);
+      }
+      /* Calulating total number of bytes in buffer */
+      ulDciPtr->payloadSizeBits = (dciFormatIdSize + freqDomResAssignSize\
+      + timeDomResAssignSize + freqHopFlagSize + modNCodSchemeSize + ndi \
+      + redundancyVerSize + harqProcessNumSize + puschTpcSize + ul_SlIndSize);
+
+      numBytes = ulDciPtr->payloadSizeBits / 8;
+      if(ulDciPtr->payloadSizeBits % 8)
+         numBytes += 1;
+
+      if(numBytes > FAPI_DCI_PAYLOAD_BYTE_LEN)
+      {
+         DU_LOG("\nLWR_MAC : Total bytes for DCI is more than expected");
+         return;
+      }
+
+      /* Initialize buffer */
+      for(bytePos = 0; bytePos < numBytes; bytePos++)
+         ulDciPtr->payload[bytePos] = 0;
+
+      bytePos = numBytes - 1;
+      bitPos = 0;
+
+      /* Packing DCI format fields */
+      fillDlDciPayload(ulDciPtr->payload, &bytePos, &bitPos,\
+            dciFormatId, dciFormatIdSize);
+      fillDlDciPayload(ulDciPtr->payload, &bytePos, &bitPos,\
+            freqDomResAssign, freqDomResAssignSize);
+      fillDlDciPayload(ulDciPtr->payload, &bytePos, &bitPos,\
+            timeDomResAssign, timeDomResAssignSize);
+      fillDlDciPayload(ulDciPtr->payload, &bytePos, &bitPos,\
+            freqHopFlag, freqHopFlagSize);
+      fillDlDciPayload(ulDciPtr->payload, &bytePos, &bitPos,\
+            modNCodScheme, modNCodSchemeSize);
+      fillDlDciPayload(ulDciPtr->payload, &bytePos, &bitPos,\
+            ndi, ndiSize);
+      fillDlDciPayload(ulDciPtr->payload, &bytePos, &bitPos,\
+            redundancyVer, redundancyVerSize);
+      fillDlDciPayload(ulDciPtr->payload, &bytePos, &bitPos,\
+            harqProcessNum, harqProcessNumSize);
+      fillDlDciPayload(ulDciPtr->payload, &bytePos, &bitPos,\
+            puschTpc, puschTpcSize);
+      fillDlDciPayload(ulDciPtr->payload, &bytePos, &bitPos,\
+            ul_SlInd, ul_SlIndSize);
+   }
+} /* fillUlDciPdu */
+
+/*******************************************************************
+ *
+ * @brief fills PDCCH PDU required for UL DCI REQ to PHY
+ *
+ * @details
+ *
+ *    Function : fillUlDciPdcchPdu
+ *
+ *    Functionality:
+ *         -Fills the Pdcch PDU info
+ *
+ * @params[in] Pointer to FAPI DL TTI Req
+ *             Pointer to PdcchCfg
+ * @return ROK
+ *
+ ******************************************************************/
+uint8_t fillUlDciPdcchPdu(fapi_dci_pdu_t *ulDciReqPdu, DlSchedInfo *dlInfo, uint8_t coreSetType)
+{
+   if(ulDciReqPdu != NULLP)
+   {
+      memset(&ulDciReqPdu->pdcchPduConfig, 0, sizeof(fapi_dl_pdcch_pdu_t));
+      fillUlDciPdu(ulDciReqPdu->pdcchPduConfig.dlDci, dlInfo->ulGrant);
+      ulDciReqPdu->pduType                          = PDCCH_PDU_TYPE;
+      ulDciReqPdu->pdcchPduConfig.bwpSize           = dlInfo->ulGrant->bwpCfg.freqAlloc.numPrb;
+      ulDciReqPdu->pdcchPduConfig.bwpStart          = dlInfo->ulGrant->bwpCfg.freqAlloc.startPrb;
+      ulDciReqPdu->pdcchPduConfig.subCarrierSpacing = dlInfo->ulGrant->bwpCfg.subcarrierSpacing; 
+      ulDciReqPdu->pdcchPduConfig.cyclicPrefix      = dlInfo->ulGrant->bwpCfg.cyclicPrefix; 
+      ulDciReqPdu->pdcchPduConfig.startSymbolIndex  = dlInfo->ulGrant->coresetCfg.startSymbolIndex;
+      ulDciReqPdu->pdcchPduConfig.durationSymbols   = dlInfo->ulGrant->coresetCfg.durationSymbols;
+      memcpy(ulDciReqPdu->pdcchPduConfig.freqDomainResource, dlInfo->ulGrant->coresetCfg.freqDomainResource, 6);
+      ulDciReqPdu->pdcchPduConfig.cceRegMappingType = dlInfo->ulGrant->coresetCfg.cceRegMappingType;
+      ulDciReqPdu->pdcchPduConfig.regBundleSize     = dlInfo->ulGrant->coresetCfg.regBundleSize;
+      ulDciReqPdu->pdcchPduConfig.interleaverSize   = dlInfo->ulGrant->coresetCfg.interleaverSize;
+      ulDciReqPdu->pdcchPduConfig.coreSetSize       = dlInfo->ulGrant->coresetCfg.coreSetType;
+      ulDciReqPdu->pdcchPduConfig.shiftIndex        = dlInfo->ulGrant->coresetCfg.shiftIndex;
+      ulDciReqPdu->pdcchPduConfig.precoderGranularity = dlInfo->ulGrant->coresetCfg.precoderGranularity;
+      ulDciReqPdu->pdcchPduConfig.numDlDci          = 1;
+      ulDciReqPdu->pdcchPduConfig.coreSetType       = coreSetType;
+
+      /* Calculating PDU length. Considering only one Ul dci pdu for now */
+      ulDciReqPdu->pduSize = sizeof(fapi_dl_pdcch_pdu_t);
+   }
+   return ROK;
+}
+#endif
+/*******************************************************************
+ *
+ * @brief Sends UL DCI Request to PHY
+ *
+ * @details
+ *
+ *    Function : fillUlDciReq
+ *
+ *    Functionality:
+ *         -Sends FAPI Ul Dci req to PHY
+ *
+ * @params[in]  Pointer to CmLteTimingInfo
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ ******************************************************************/
+uint16_t fillUlDciReq(SlotIndInfo currTimingInfo)
+{
+#ifdef INTEL_FAPI
+   uint8_t cellIdx;
+   uint8_t  numPduEncoded = 0;
+   uint32_t msgLen  = 0;
+   uint32_t msgSize = 0;
+
+   fapi_ul_dci_req_t *ulDciReq = NULLP;
+   SlotIndInfo ulDciReqTimingInfo;
+
+   MacDlSlot *currDlSlot = NULLP;
+
+   if(lwrMacCb.phyState == PHY_STATE_RUNNING)
+   {
+      GET_CELL_IDX(currTimingInfo.cellId, cellIdx);
+      memcpy(&ulDciReqTimingInfo, &currTimingInfo, sizeof(SlotIndInfo));
+      currDlSlot = &macCb.macCell[cellIdx]->dlSlot[ulDciReqTimingInfo.slot % MAX_SLOT_SUPPORTED];
+
+      if(currDlSlot->dlInfo.ulGrant != NULLP)
+      {
+         msgSize = sizeof(fapi_ul_dci_req_t);
+         LWR_MAC_ALLOC(ulDciReq, msgSize);
+         if(ulDciReq != NULLP)
+        {
+            memset(ulDciReq, 0, msgSize);
+            ulDciReq->sfn  = ulDciReqTimingInfo.sfn;
+            ulDciReq->slot = ulDciReqTimingInfo.slot;
+            ulDciReq->numPdus = 1;  // No. of PDCCH PDUs
+            if(ulDciReq->numPdus > 0)
+            {
+               /* Fill PDCCH configuration Pdu */
+               fillUlDciPdcchPdu(&ulDciReq->pdus[numPduEncoded], &currDlSlot->dlInfo, CORESET_TYPE1);
+               numPduEncoded++;
+              /* free UL GRANT at SCH */
+              MAC_FREE(currDlSlot->dlInfo.ulGrant, sizeof(DciInfo));
+              currDlSlot->dlInfo.ulGrant = NULLP;
+              /* send UL DCI to PHY */
+               msgLen = sizeof(fapi_ul_dci_req_t) - sizeof(fapi_msg_t);
+               fillMsgHeader(&ulDciReq->header, FAPI_UL_DCI_REQUEST, msgLen);
+               LwrMacSendToPhy(ulDciReq->header.msg_id, sizeof(fapi_ul_dci_req_t), (void *)ulDciReq);
+            }
+
+        }
+         else
+         {
+            DU_LOG("\nLWR_MAC: Failed to allocate memory for UL DCI Request");
+            memset(currDlSlot, 0, sizeof(MacDlSlot));
+            return RFAILED;
+         }
+      }
+   }
+   else
+   {
+       lwr_mac_procInvalidEvt(&currTimingInfo);
+   }
+#endif
+   return ROK;
+}
+
 lwrMacFsmHdlr fapiEvtHdlr[MAX_STATE][MAX_EVENT] =
 {
    {
index 1df5ead..4efba24 100644 (file)
@@ -33,6 +33,7 @@
 #include "lwr_mac_upr_inf.h"
 #include "mac.h"
 #include "mac_utils.h"
+#include "lwr_mac_utils.h"
 
 #ifdef INTEL_FAPI
 /* Function pointer for slot indication from lower mac to mac */
@@ -74,35 +75,14 @@ packStopIndMsg sendStopIndOpts[] =
    fapiMacStopInd,
    packStopInd
 };
-/*******************************************************************
- *
- * @brief Fills post structure
- *
- * @details
- *
- *    Function : fillLwrMacToMacPst
- *
- *    Functionality:
- *     Fills post structure used to send message from lower MAC
- *     to MAC
- *
- * @params[in] Pst pointer 
- * @return ROK     - success
- *         RFAILED - failure
- *
- * ****************************************************************/
-void fillLwrMacToMacPst(Pst *pst)
+
+/* Function pointer for Uci indication from lower mac to mac */
+packMacUciIndMsg sendUciIndOpts[] =
 {
-   pst->srcProcId = 0;
-   pst->dstProcId = 0;
-   pst->srcEnt = ENTTF;
-   pst->dstEnt = ENTRG;
-   pst->srcInst = 0;
-   pst->dstInst = 0;
-   pst->region = 0;
-   pst->pool =  0; 
-   pst->selector = ODU_SELECTOR_TC;
-}
+   packMacUciInd,
+   FapiMacUciInd,
+   packMacUciInd
+};
 
 /*******************************************************************
  *
@@ -127,8 +107,7 @@ uint8_t procSlotInd(fapi_slot_ind_t *fapiSlotInd)
    uint16_t ret;
    SlotIndInfo slotInd;
 
-   fillLwrMacToMacPst(&pst);
-   pst.event = EVENT_SLOT_IND_TO_MAC;
+   FILL_PST_LWR_MAC_TO_MAC(pst, EVENT_SLOT_IND_TO_MAC);
 
    slotInd.cellId = lwrMacCb.cellCb[0].cellId; 
    slotInd.sfn = fapiSlotInd->sfn;
@@ -172,8 +151,7 @@ uint8_t procStopInd()
    lwrMacCb.cellCb[0].state = PHY_STATE_CONFIGURED;
    DU_LOG("\nLWR_MAC: PHY has moved to configured state");
 
-   fillLwrMacToMacPst(&pst);
-   pst.event = EVENT_STOP_IND_TO_MAC;
+   FILL_PST_LWR_MAC_TO_MAC(pst, EVENT_STOP_IND_TO_MAC);
 
    ret = (*sendStopIndOpts[pst.selector])(&pst, \
       lwrMacCb.cellCb[0].cellId);
@@ -223,8 +201,7 @@ uint8_t procRachInd(fapi_rach_indication_t  *fapiRachInd)
            fapiRachInd->rachPdu[pduIdx].preambleInfo[prmbleIdx].timingAdvance;
       }
    }
-   fillLwrMacToMacPst(&pst);
-   pst.event = EVENT_RACH_IND_TO_MAC;
+   FILL_PST_LWR_MAC_TO_MAC(pst, EVENT_RACH_IND_TO_MAC);
 
    (*sendRachIndOpts[pst.selector])(&pst, &rachInd);
    return ROK;
@@ -279,8 +256,7 @@ uint8_t procCrcInd(fapi_crc_ind_t  *fapiCrcInd)
       crcIndInfo->rssi = fapiCrcInd->crc[crcInfoIdx].rssi;
    }
 
-   fillLwrMacToMacPst(&pst);
-   pst.event = EVENT_CRC_IND_TO_MAC;
+   FILL_PST_LWR_MAC_TO_MAC(pst, EVENT_CRC_IND_TO_MAC);
 
    (*sendCrcIndOpts[pst.selector])(&pst, &crcInd);
    return ROK;
@@ -331,13 +307,126 @@ uint8_t procRxDataInd(fapi_rx_data_indication_t  *fapiRxDataInd)
       memcpy(pdu->pduData, fapiRxDataInd->pdus[pduIdx].pduData, pdu->pduLength);
    }
 
-   fillLwrMacToMacPst(&pst);
-   pst.event = EVENT_RX_DATA_IND_TO_MAC;
+   FILL_PST_LWR_MAC_TO_MAC(pst, EVENT_RX_DATA_IND_TO_MAC);
 
    (*sendRxDataIndOpts[pst.selector])(&pst, &rxDataInd);
    return ROK;
 }
 
+/*******************************************************************
+ *
+ * @brief Fills Uci Ind Pdu Info carried on Pucch Format 0/Format 1
+ *
+ * @details
+ *
+ *    Function : fillUciIndPucchF0F1
+ *
+ *    Functionality:
+ *       Fills Uci Ind Pdu Info carried on Pucch Format 0/Format 1
+ *
+ *@params[in] UciPucchF0F1 *
+ *            fapi_uci_o_pucch_f0f1_t *
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t fillUciIndPucchF0F1(UciPucchF0F1 *pduInfo, fapi_uci_o_pucch_f0f1_t *fapiPduInfo)
+{
+
+   uint8_t harqIdx;
+   uint8_t ret = ROK;
+   
+   pduInfo->handle        = fapiPduInfo->handle;
+   pduInfo->pduBitmap     = fapiPduInfo->pduBitmap;
+   pduInfo->pucchFormat   = fapiPduInfo->pucchFormat;
+   pduInfo->ul_cqi        = fapiPduInfo->ul_cqi;
+   pduInfo->crnti         = fapiPduInfo->rnti;
+   pduInfo->timingAdvance = fapiPduInfo->timingAdvance;
+   pduInfo->rssi          = fapiPduInfo->rssi;   
+   memcpy(pduInfo->uciBits, fapiPduInfo->uciBits, MAX_UCI_BIT_PER_TTI_IN_BYTES);
+   if(fapiPduInfo->srInfo.srIndication)
+   {
+      pduInfo->srInfo.srIndPres = fapiPduInfo->srInfo.srIndication;
+      pduInfo->srInfo.srConfdcLevel = fapiPduInfo->srInfo.srConfidenceLevel;
+
+   }
+   if(fapiPduInfo->harqInfo.numHarq)
+   {
+      pduInfo->harqInfo.numHarq = fapiPduInfo->harqInfo.numHarq;
+      pduInfo->harqInfo.harqConfdcLevel = fapiPduInfo->harqInfo.harqConfidenceLevel;
+      for(harqIdx = 0; harqIdx < pduInfo->harqInfo.numHarq; harqIdx++)
+      {
+         pduInfo->harqInfo.harqValue[harqIdx] = fapiPduInfo->harqInfo.harqValue[harqIdx];
+      }
+   }
+   return ret;
+}
+
+/*******************************************************************
+ *
+ * @brief Handles Uci indication from PHY and sends to MAC
+ *
+ * @details
+ *
+ *    Function : procUciInd
+ *
+ *    Functionality:
+ *      Handles Uci indication from PHY and sends to MAC
+ *
+ * @params[in] fapi_uci_indication_t message pointer
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t procUciInd(fapi_uci_indication_t  *fapiUciInd)
+{
+   uint8_t pduIdx;
+   uint8_t ret = ROK;
+   Pst     pst;
+   memset(&pst, 0, sizeof(Pst));
+   UciInd  macUciInd;
+   memset(&macUciInd, 0, sizeof(UciInd));
+
+   macUciInd.cellId = lwrMacCb.cellCb[0].cellId;
+   macUciInd.slotInd.sfn = fapiUciInd->sfn; 
+   macUciInd.slotInd.slot = fapiUciInd->slot;
+   macUciInd.numUcis = fapiUciInd->numUcis;
+
+   for(pduIdx = 0; pduIdx < macUciInd.numUcis; pduIdx++)
+   {
+      macUciInd.pdus[pduIdx].pduType = fapiUciInd->uciPdu[pduIdx].pduType;
+      switch(macUciInd.pdus[pduIdx].pduType)
+      {
+         case UCI_IND_PUSCH:
+         break;
+         case UCI_IND_PUCCH_F0F1:
+         {
+            UciPucchF0F1 *pduInfo = NULLP;
+            macUciInd.pdus[pduIdx].pduSize = fapiUciInd->uciPdu[pduIdx].pduSize;
+            pduInfo = &macUciInd.pdus[pduIdx].uci.uciPucchF0F1;
+            ret = fillUciIndPucchF0F1(pduInfo, &fapiUciInd->uciPdu[pduIdx].uci.uciPucchF0F1);
+         }
+         break;
+         case UCI_IND_PUCCH_F2F3F4:
+            break;
+         default:
+            DU_LOG("\nLWR_MAC: Invalid Pdu Type %d at procmacUciInd()", macUciInd.pdus[pduIdx].pduType);
+           ret = RFAILED;
+            break;
+      }
+   }
+   if(!ret)
+   {
+      FILL_PST_LWR_MAC_TO_MAC(pst, EVENT_UCI_IND_TO_MAC);
+      ret = (*sendUciIndOpts[pst.selector])(&pst, &macUciInd);
+   }
+   else
+   {
+      DU_LOG("\nLWR_MAC: Failed sending UCI Ind to MAC");
+   }
+   return ret;
+}
 #endif /* FAPI */
 
 void procPhyMessages(uint16_t msgType, uint32_t msgSize, void *msg)
@@ -389,6 +478,9 @@ void procPhyMessages(uint16_t msgType, uint32_t msgSize, void *msg)
         }  
       case FAPI_UCI_INDICATION:
         {
+           fapi_uci_indication_t *phyUciInd = NULLP;
+           phyUciInd = (fapi_uci_indication_t*)msg;
+           procUciInd(phyUciInd);
            break;
         }
       case FAPI_SRS_INDICATION:
index f250b51..c6a1c5e 100644 (file)
@@ -179,6 +179,33 @@ uint8_t packStopInd(Pst *pst, uint16_t cellId)
    }
 }
 
+/*******************************************************************
+ *
+ * @brief Packs and Sends UCI Ind to MAC
+ *
+ * @details
+ *
+ *    Function : packMacUciInd
+ *
+ *    Functionality:
+ *         Packs and Sends Uci Ind to MAC
+ *
+ * @params[in] Post structure pointer
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t packMacUciInd(Pst *pst, UciInd *uciInd)
+{
+   if((pst->selector == ODU_SELECTOR_LC) || (pst->selector == ODU_SELECTOR_LWLC))
+   {
+      return ROK;
+   }
+   else
+   {
+      return RFAILED;
+   }
+}
 /**********************************************************************
   End of file
  **********************************************************************/
index 0666ba2..9d6a1b5 100644 (file)
 #define MAX_CRCS_PER_SLOT       1
 #define MAX_CB_PER_TTI_IN_BYTES 1
 #define MAX_ULSCH_PDUS_PER_TTI  1
+#define MAX_ULCCH_PDUS_PER_TTI  1
+#define MAX_NUM_HARQS_PER_TTI   1
+#define MAX_HARQ_INFO_IN_BYTES 1
+#define MAX_CSI_PART1_DATA_IN_BYTES 1
+#define MAX_CSI_PART2_DATA_IN_BYTES 1
+#define MAX_UCI_PDUS_PER_TTI    1
+#define MAX_UCI_BIT_PER_TTI_IN_BYTES 2
+#define UCI_IND_PUSCH     0      /* UCI Indication carried on PUSCH */
+#define UCI_IND_PUCCH_F0F1   1   /* UCI Indication carried on PUCCH Format 0, 1 */
+#define UCI_IND_PUCCH_F2F3F4 2   /* UCI Indication carried on PUCCH Format 2, 3, 4 */
+#define SR_PDU_BITMASK    1      /* Bit Mask for SR_PDU */
+#define HARQ_PDU_BITMASK  2      /* Bit Mask for HARQ PDU */
+#define SR_NOT_DETECTED   0      /* SR not detected */
+#define SR_DETECTED       1      /* SR detected */
+#define CONFDC_LEVEL_GOOD 0      /* Confidence Level HARQ/SR */
+#define CONFDC_LEVEL_BAD  1
+#define HARQ_PASS         0
+#define HARQ_FAIL         1
+#define HARQ_NOT_PRESENT  3
 
 /* events */
 #define EVENT_RACH_IND_TO_MAC    0
@@ -33,6 +52,7 @@
 #define EVENT_RX_DATA_IND_TO_MAC 2
 #define EVENT_STOP_IND_TO_MAC    3
 #define EVENT_SLOT_IND_TO_MAC    4
+#define EVENT_UCI_IND_TO_MAC     5
 
 typedef struct rachPreamInfo
 {
@@ -99,28 +119,122 @@ typedef struct
    RxDataIndPdu  pdus[MAX_ULSCH_PDUS_PER_TTI];
 }RxDataInd;
 
+/* UCI Indication Structure */
+typedef struct 
+{
+   uint8_t  harqCrc;
+   uint16_t harqBitLen;
+   uint8_t  harqPayload[MAX_HARQ_INFO_IN_BYTES];
+}PuschHarqInfo;
+
+typedef struct
+{
+   uint8_t  csiPart1Crc;
+   uint16_t csiPart1BitLen;
+   uint8_t  csiPart1Payload[MAX_CSI_PART1_DATA_IN_BYTES];
+}PuschCsiPart1Info;
+
+typedef struct
+{
+   uint8_t  csiPart2Crc;
+   uint16_t csiPart2BitLen;
+   uint8_t  csiPart2Payload[MAX_CSI_PART2_DATA_IN_BYTES];
+}PuschCsiPart2Info;
+
+typedef struct
+{
+   uint32_t handle;
+   uint8_t  pduBitmap;
+   uint8_t  ul_cqi;
+   uint16_t crnti;
+   uint16_t timingAdvance;
+   uint16_t rssi;
+   PuschHarqInfo harqInfo; 
+   PuschCsiPart1Info csiPart1Info;
+   PuschCsiPart2Info csiPart2Info;
+}UciPusch;
+
+typedef struct
+{
+   uint8_t srIndPres;
+   uint8_t srConfdcLevel;
+}SrInfoF0F1;
+
+typedef struct
+{
+   uint8_t numHarq;
+   uint8_t harqConfdcLevel;
+   uint8_t harqValue[MAX_NUM_HARQS_PER_TTI];
+}HarqInfoF0F1;
+
+typedef struct
+{
+   uint32_t handle;
+   uint8_t pduBitmap;
+   uint8_t pucchFormat;
+   uint8_t ul_cqi;
+   uint16_t crnti;
+   uint16_t timingAdvance;
+   uint16_t rssi;         
+   uint8_t uciBits[MAX_UCI_BIT_PER_TTI_IN_BYTES];
+   SrInfoF0F1   srInfo;
+   HarqInfoF0F1 harqInfo;
+}UciPucchF0F1;
+
+typedef struct
+{
+   uint32_t handle;
+   uint8_t pduBitmap;
+   uint8_t pucchFormat;
+   uint8_t ul_cqi;
+   uint16_t crnti;
+   uint16_t timingAdvance;
+   uint16_t rssi;
+   uint16_t num_uci_bits;
+   uint8_t uciBits[MAX_UCI_BIT_PER_TTI_IN_BYTES];
+}UciPucchF2F3F4;
+
+typedef struct 
+{
+   uint16_t pduType;
+   uint16_t pduSize;
+   union
+   {
+      UciPusch      uciPusch; /*TODO: UCI Ind for PUSCH to be handled separately */
+      UciPucchF0F1  uciPucchF0F1;
+      UciPucchF2F3F4  uciPucchF2F3F4;
+   }uci;
+}UciIndPduInfo;
+
+typedef struct
+{
+   uint16_t      cellId;
+   SlotIndInfo   slotInd;
+   uint16_t      numUcis;
+   UciIndPduInfo pdus[MAX_UCI_PDUS_PER_TTI];
+}UciInd;
+
 typedef uint8_t (*packSlotIndMsg)(Pst *pst, SlotIndInfo *slotInd);
+typedef uint8_t (*packRachIndMsg)(Pst *pst, RachInd *rachInd);
+typedef uint8_t (*packCrcIndMsg)(Pst *pst, CrcInd *crcInd);
+typedef uint8_t (*packRxDataIndMsg)(Pst *pst, RxDataInd *rxDataInd);
+typedef uint8_t (*packStopIndMsg)(Pst *pst, uint16_t cellId);
+typedef uint8_t (*packMacUciIndMsg)(Pst *pst, UciInd *uciInd);
+
 uint8_t packLcSlotInd (Pst *pst, SlotIndInfo *slotInd);
 uint8_t packLwlcSlotInd (Pst *pst, SlotIndInfo *slotInd);
-
 uint8_t fapiMacSlotInd(Pst  *pst, SlotIndInfo  *slotInd);
-
-typedef uint8_t (*packRachIndMsg)(Pst *pst, RachInd *rachInd);
 uint8_t packRachInd(Pst *pst, RachInd *rachInd);
 uint8_t fapiMacRachInd(Pst *pst, RachInd *rachInd);
-
-typedef uint8_t (*packCrcIndMsg)(Pst *pst, CrcInd *crcInd);
 uint8_t packCrcInd(Pst *pst, CrcInd *crcInd);
 uint8_t fapiMacCrcInd(Pst *pst, CrcInd *crcInd);
-
-
-typedef uint8_t (*packRxDataIndMsg)(Pst *pst, RxDataInd *rxDataInd);
 uint8_t packRxDataInd(Pst *pst, RxDataInd *rxDataInd);
 uint8_t fapiMacRxDataInd(Pst *pst, RxDataInd *rxDataInd);
-
-typedef uint8_t (*packStopIndMsg)(Pst *pst, uint16_t cellId);
 uint8_t packStopInd(Pst *pst, uint16_t cellId);
 uint8_t fapiMacStopInd(Pst *pst, uint16_t cellId);
+uint8_t packMacUciInd(Pst *pst, UciInd *uciInd);
+uint8_t FapiMacUciInd(Pst *pst, UciInd *uciInd);
+
 #endif
 /**********************************************************************
   End of file
diff --git a/src/5gnrmac/lwr_mac_utils.h b/src/5gnrmac/lwr_mac_utils.h
new file mode 100644 (file)
index 0000000..0aab79b
--- /dev/null
@@ -0,0 +1,39 @@
+/*******************************************************************************
+################################################################################
+#   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.                                             #
+################################################################################
+*******************************************************************************/
+
+/* Fill Pst structure for sending msg from MAC to SCH */
+#define FILL_PST_LWR_MAC_TO_MAC(_pst, _event)               \
+{                                                           \
+   _pst.selector  = ODU_SELECTOR_TC;                        \
+   _pst.srcEnt    = ENTTF;                                  \
+   _pst.dstEnt    = ENTRG;                                  \
+   _pst.dstInst   = 0;                                      \
+   _pst.srcInst   = 0;                                      \
+   _pst.dstProcId = SFndProcId();                           \
+   _pst.srcProcId = SFndProcId();                           \
+   _pst.region = MAC_MEM_REGION;                            \
+   _pst.pool = MAC_POOL;                                    \
+   _pst.event = _event;                                     \
+   _pst.route = 0;                                          \
+   _pst.prior = 0;                                          \
+   _pst.intfVer = 0;                                        \
+}
+/**********************************************************************
+         End of file
+**********************************************************************/
index 69fa37a..88eeb87 100644 (file)
@@ -67,8 +67,8 @@
 #define SR_DELAY_TMR_2560MS   2560
 
 #define MAC_LCID_CCCH              0
-#define MAC_DEDLC_MIN_LCID         1
-#define MAC_DEDLC_MAX_LCID         32
+#define MAC_LCID_MIN               1
+#define MAC_LCID_MAX               32
 #define MAC_LCID_RESERVED_MIN      33
 #define MAC_LCID_RESERVED_MAX      51
 #define MAC_LCID_CCCH_48BIT        52
@@ -237,11 +237,13 @@ void createMacRaCb(uint16_t cellId, uint16_t crnti);
 void fillMsg4DlData(uint16_t cellId, MacDlData *dlData, uint8_t *msg4Pdu);
 void fillMacCe(MacCeInfo  *macCeData, uint8_t *msg3Pdu);
 void macMuxPdu(MacDlData *dlData, MacCeInfo *macCeData, uint8_t *msg4TxPdu, uint16_t tbSize);
-uint8_t unpackRxData(uint16_t cellId, RxDataIndPdu *rxDataIndPdu);
-uint8_t macSendUlCcchInd(uint8_t *rrcContainer, uint16_t cellId, uint16_t crnti);
+uint8_t unpackRxData(uint16_t cellId, SlotIndInfo slotInfo, RxDataIndPdu *rxDataIndPdu);
 void fillMg4Pdu(Msg4Alloc *msg4Alloc);
 void buildAndSendMuxPdu(SlotIndInfo currTimingInfo);
-
+uint8_t macProcUlCcchInd(uint16_t cellId, uint16_t crnti, uint16_t rrcContSize, uint8_t *rrcContainer);
+uint8_t macProcShortBsr(uint16_t cellId, uint16_t crnti, uint8_t lcgId, uint32_t bufferSize);
+uint8_t macProcUlData(uint16_t cellId, uint16_t rnti, SlotIndInfo slotInfo, \
+   uint8_t lcId, uint16_t pduLen, uint8_t *pdu);
 #endif
 /**********************************************************************
   End of file
index 1610062..e8c76eb 100644 (file)
@@ -20,6 +20,8 @@
 #include "common_def.h"
 #include "lrg.h"
 #include "lrg.x"
+#include "rgu.h"
+#include "rgu.x"
 #include "du_app_mac_inf.h"
 #include "mac_sch_interface.h"
 #include "lwr_mac_upr_inf.h"
index 44be3a4..fe6198b 100644 (file)
@@ -26,6 +26,8 @@
 #include "mac.h"
 #include "mac_utils.h"
 
+extern uint32_t shortBsrBytesTable[MAX_SHORT_BSR_TABLE_ENTRIES];
+
 /*******************************************************************
  *
  * @brief De-mux of MAC-Sub PDUs from Rx Data Ind Pdu
  *         RFAILED
  *
  * ****************************************************************/
-uint8_t unpackRxData(uint16_t cellId, RxDataIndPdu *rxDataIndPdu)
+uint8_t unpackRxData(uint16_t cellId, SlotIndInfo slotInfo, RxDataIndPdu *rxDataIndPdu)
 {
-   uint8_t   lcId;
-   uint8_t   idx = 0;
-   uint16_t  length;
-   uint8_t   *pdu;
-   uint16_t  pduLen;
-   uint8_t   *rxDataPdu;
-   uint16_t  cellIdx;
+   uint8_t   lcId;        /* LC ID of a sub pdu */
+   uint8_t   fBit = 0;    /* Value of F Bit in MAC sub-header */
+   uint8_t   idx = 0;     /* Iterator for received PDU */
+   uint16_t  length;      /* Length of payload in a sub-PDU */ 
+   uint8_t   *pdu;        /* Payload in sub-PDU */
+   uint16_t  pduLen;      /* Length of undecoded PDU */
+   uint8_t   *rxDataPdu;  /* Received PDU in Rx Data Ind */
+   uint16_t  cellIdx;     /* Cell Index */
+   uint8_t   ret =ROK;
 
    GET_CELL_IDX(cellId, cellIdx);
    pduLen = rxDataIndPdu->pduLength;
@@ -59,6 +63,10 @@ uint8_t unpackRxData(uint16_t cellId, RxDataIndPdu *rxDataIndPdu)
 
    while(pduLen > 0)
    {
+      /* MSB in 1st octet is Reserved bit. Hence not decoding it. 
+        2nd MSB in 1st octet is R/F bit depending upon type of payload */
+      fBit = (1 << 7) & rxDataPdu[idx];
+
       /* LC id is the 6 LSB in 1st octet */
       lcId = (~((~0) << 6)) & rxDataPdu[idx];
 
@@ -87,13 +95,43 @@ uint8_t unpackRxData(uint16_t cellId, RxDataIndPdu *rxDataIndPdu)
               memcpy(macCb.macCell[cellIdx]->macRaCb[0].msg3Pdu, pdu, length);
 
               /* Send UL-CCCH Indication to DU APP */
-              macSendUlCcchInd(pdu, macCb.macCell[cellIdx]->cellId, rxDataIndPdu->rnti); 
+              ret = macProcUlCcchInd(macCb.macCell[cellIdx]->cellId, rxDataIndPdu->rnti, length, pdu);
               break;
            }
 
-        case MAC_DEDLC_MIN_LCID ... MAC_DEDLC_MAX_LCID :
-           break;
+        case MAC_LCID_MIN ... MAC_LCID_MAX :
+           {
+              DU_LOG("\nMAC : PDU received for LC ID %d", lcId);
+
+              pduLen--;
+              idx++;
 
+              length = rxDataPdu[idx];
+              if(fBit)
+              {
+                 pduLen--;
+                 idx++;
+                 length = (length << 8) & rxDataPdu[idx];
+              }
+
+              /*  Copying the payload to send to RLC */
+              MAC_ALLOC_SHRABL_BUF(pdu, length);
+              if(!pdu)
+              {
+                 DU_LOG("\nMAC : Memory allocation failed while demuxing Rx Data PDU");
+                 return RFAILED;
+              }
+              pduLen--;
+               idx++;
+              memcpy(pdu, &rxDataPdu[idx], length);
+              pduLen -= length;
+              idx = idx + length;
+              
+              /* Send UL Data to RLC */
+              ret = macProcUlData(cellId, rxDataIndPdu->rnti, slotInfo, lcId, length, pdu);
+
+              break;
+           }
         case MAC_LCID_RESERVED_MIN ... MAC_LCID_RESERVED_MAX :
            break;
 
@@ -125,16 +163,35 @@ uint8_t unpackRxData(uint16_t cellId, RxDataIndPdu *rxDataIndPdu)
            break;
 
         case MAC_LCID_SHORT_BSR :
-           break;
+           {
+              uint8_t  lcgId         = 0;
+              uint8_t  bufferSizeIdx = 0;
+              uint8_t  crnti         = 0;
+              uint32_t bufferSize    = 0;
 
-        case MAC_LCID_LONG_BSR :
-           break;
+              pduLen--;
 
-        case MAC_LCID_PADDING :
-           {
+              idx++;
+              crnti = rxDataIndPdu->rnti;
+              /* 5 LSB bits in pdu represent buffer size */
+              bufferSizeIdx = (~((~0) << 5)) & rxDataPdu[idx];
+              /* first 3 MSB bits in pdu represent LCGID */
+              lcgId = (rxDataPdu[idx]) >> 5;
+              /* determine actual number of bytes requested */
+              bufferSize = shortBsrBytesTable[bufferSizeIdx];
+              ret = macProcShortBsr(macCb.macCell[cellIdx]->cellId, crnti, lcgId, bufferSize);
+              pduLen--;
+              idx++;
+       
               break;
            }
 
+        case MAC_LCID_LONG_BSR :
+           break;
+
+        case MAC_LCID_PADDING :
+           break;
+        
         default:
            {
               DU_LOG("\nMAC : Invalid LC Id %d", lcId);
@@ -143,11 +200,12 @@ uint8_t unpackRxData(uint16_t cellId, RxDataIndPdu *rxDataIndPdu)
       } /* End of switch */
 
       if(lcId == MAC_LCID_PADDING)
+      {
         break;
-
+      }
    } /* End of While */
 
-   return ROK;
+   return ret;
 } /* End of unpackRxData */
 
 /**********************************************************************
index a443d08..8210880 100644 (file)
@@ -45,7 +45,7 @@ uint16_t buildMacPdu(RlcMacData *dlData);
 MacSchCrcIndFunc macSchCrcIndOpts[]=
 {
    packMacSchCrcInd,
-   macSchCrcInd,
+   MacSchCrcInd,
    packMacSchCrcInd
 };
 
@@ -53,10 +53,26 @@ MacSchCrcIndFunc macSchCrcIndOpts[]=
 MacSchDlRlcBoInfoFunc macSchDlRlcBoInfoOpts[]=
 {
    packMacSchDlRlcBoInfo,
-   macSchDlRlcBoInfo,
+   MacSchDlRlcBoInfo,
    packMacSchDlRlcBoInfo
 };
 
+/* Function pointer for sending short BSR from MAC to SCH */
+MacSchBsrFunc macSchBsrOpts[]=
+{
+   packMacSchBsr,
+   MacSchBsr,
+   packMacSchBsr
+};
+
+/* Function pointer for sending SR Uci ind from MAC to SCH */
+MacSchSrUciIndFunc macSchSrUciIndOpts[]=
+{
+   packMacSchSrUciInd,
+   MacSchSrUciInd,
+   packMacSchSrUciInd
+};
+
 /*******************************************************************
  *
  * @brief Sends DL BO Info to SCH
@@ -169,7 +185,7 @@ uint8_t fapiMacRxDataInd(Pst *pst, RxDataInd *rxDataInd)
 
    for(pduIdx = 0; pduIdx < rxDataInd->numPdus; pduIdx++)
    {
-      unpackRxData(rxDataInd->cellId, &rxDataInd->pdus[pduIdx]);
+      unpackRxData(rxDataInd->cellId, rxDataInd->timingInfo, &rxDataInd->pdus[pduIdx]);
    }
    return ROK;
 }
@@ -196,6 +212,64 @@ uint16_t MacRlcProcDlData(Pst* pst, SpId spId, RlcMacData *dlData)
    return ROK;
 }
 
+/*******************************************************************
+ *
+ * @brief Builds and Sends UL Data to RLC
+ *
+ * @details
+ *
+ *    Function : macProcUlData
+ *
+ *    Functionality: Builds and Sends UL Data to RLC
+ *
+ * @params[in] CellId
+ *             CRNTI
+ *             Slot information
+ *             LC Id on which payload was received
+ *             Pointer to the payload
+ *             Length of payload
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t macProcUlData(uint16_t cellId, uint16_t rnti, SlotIndInfo slotInfo, \
+uint8_t lcId, uint16_t pduLen, uint8_t *pdu)
+{
+   Pst         pst;
+   RlcMacData  *ulData;
+
+   /* Filling RLC Ul Data*/
+   MAC_ALLOC_SHRABL_BUF(ulData, sizeof(RlcMacData));
+   if(!ulData)
+   {
+      DU_LOG("\nMAC : Memory allocation failed while sending UL data to RLC");
+      return RFAILED;
+   }
+   memset(ulData, 0, sizeof(RlcMacData));
+   ulData->cellId = cellId; 
+   ulData->rnti = rnti;
+   memcpy(&ulData->slotInfo, &slotInfo, sizeof(SlotIndInfo));
+   ulData->slotInfo.cellId = cellId;
+
+   /* Filling pdu info */
+   if(lcId == SRB1_LCID || lcId == SRB2_LCID)
+   {
+      ulData->pduInfo[ulData->numPdu].commCh = true;
+   }
+   ulData->pduInfo[ulData->numPdu].lcId = lcId;
+   ulData->pduInfo[ulData->numPdu].pduBuf = pdu;
+   ulData->pduInfo[ulData->numPdu].pduLen = pduLen;
+   ulData->numPdu++;
+
+   /* Filling Post and send to RLC */
+   memset(&pst, 0, sizeof(Pst));
+   FILL_PST_MAC_TO_RLC(pst, 0, EVTRLCULDAT);
+   MacSendUlDataToRlc(&pst, ulData);
+
+   return ROK;
+}
+
+
 /*******************************************************************
  *
  * @brief Processes BO status from RLC
@@ -347,7 +421,7 @@ uint8_t MacProcDlCcchInd(Pst *pst, DlCcchIndInfo *dlCcchIndInfo)
  *
  * @details
  *
- *    Function : macSendUlCcchInd
+ *    Function : macProcUlCcchInd
  *
  *    Functionality:
  *        MAC sends UL CCCH Ind to DU APP
@@ -358,7 +432,7 @@ uint8_t MacProcDlCcchInd(Pst *pst, DlCcchIndInfo *dlCcchIndInfo)
  *         RFAILED - failure
  *
  * ****************************************************************/
-uint8_t macSendUlCcchInd(uint8_t *rrcContainer, uint16_t cellId, uint16_t crnti)
+uint8_t macProcUlCcchInd(uint16_t cellId, uint16_t crnti, uint16_t rrcContSize, uint8_t *rrcContainer)
 {
    Pst pst;
    uint8_t ret = ROK;
@@ -367,12 +441,13 @@ uint8_t macSendUlCcchInd(uint8_t *rrcContainer, uint16_t cellId, uint16_t crnti)
    MAC_ALLOC_SHRABL_BUF(ulCcchIndInfo, sizeof(UlCcchIndInfo));
    if(!ulCcchIndInfo)
    {
-      DU_LOG("\nMAC: Memory failed in macSendUlCcchInd");
+      DU_LOG("\nMAC: Memory failed in macProcUlCcchInd");
       return RFAILED;
    }
 
    ulCcchIndInfo->cellId = cellId;
    ulCcchIndInfo->crnti  = crnti;
+   ulCcchIndInfo->ulCcchMsgLen = rrcContSize;
    ulCcchIndInfo->ulCcchMsg = rrcContainer;
 
    /* Fill Pst */
@@ -381,14 +456,150 @@ uint8_t macSendUlCcchInd(uint8_t *rrcContainer, uint16_t cellId, uint16_t crnti)
    if(MacDuAppUlCcchInd(&pst, ulCcchIndInfo) != ROK)
    {
       DU_LOG("\nMAC: Failed to send UL CCCH Ind to DU APP");
-      MAC_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo->ulCcchMsg,
-           strlen((const char*)ulCcchIndInfo->ulCcchMsg));
+      MAC_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo->ulCcchMsg, ulCcchIndInfo->ulCcchMsgLen);
       MAC_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo, sizeof(UlCcchIndInfo));
       ret = RFAILED;
    }
    return ret;
 }
 
+/*******************************************************************
+ *
+ * @brief Processes received short BSR
+ *
+ * @details
+ *
+ *    Function : macProcShortBsr
+ *
+ *    Functionality:
+ *        MAC sends Short BSR to SCH
+ *
+ * @params[in] cell ID
+ *             crnti
+ *             lcg ID
+ *             buffer size
+ *
+ *
+ * ****************************************************************/
+uint8_t macProcShortBsr(uint16_t cellId, uint16_t crnti, uint8_t lcgId, uint32_t bufferSize)
+{
+   Pst                  pst;
+   UlBufferStatusRptInd bsrInd;
+
+   memset(&pst, 0, sizeof(Pst));
+   memset(&bsrInd, 0, sizeof(UlBufferStatusRptInd));
+
+   bsrInd.cellId                 = cellId;
+   bsrInd.crnti                  = crnti;
+   bsrInd.bsrType                = SHORT_BSR;
+   bsrInd.numLcg                 = 1; /* short bsr reports one lcg at a time */
+   bsrInd.dataVolInfo[0].lcgId   = lcgId;
+   bsrInd.dataVolInfo[0].dataVol = bufferSize;
+
+   FILL_PST_MAC_TO_SCH(pst, EVENT_SHORT_BSR);
+   return(*macSchBsrOpts[pst.selector])(&pst, &bsrInd);
+}
+
+/*******************************************************************
+ *
+ * @brief Builds and send SR UCI Indication to SCH
+ *
+ * @details
+ *
+ *    Function : buildAndSendSrInd
+ *
+ *    Functionality:
+ *       Builds and send SR UCI Indication to SCH
+ *
+ * @params[in] SrUciIndInfo Pointer
+ *             crnti value
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t buildAndSendSrInd(UciInd *macUciInd, uint8_t crnti)
+{
+   uint16_t cellIdx;
+   Pst pst;
+   SrUciIndInfo   srUciInd;
+   memset(&pst, 0, sizeof(Pst));
+   memset(&srUciInd, 0, sizeof(SrUciIndInfo));
+
+   GET_CELL_IDX(macUciInd->cellId, cellIdx);
+   srUciInd.cellId       = macCb.macCell[cellIdx]->cellId;;
+   srUciInd.crnti        = crnti;
+   srUciInd.slotInd.sfn  = macUciInd->slotInd.sfn;
+   srUciInd.slotInd.slot = macUciInd->slotInd.slot;
+   srUciInd.numSrBits++;
+   memset(srUciInd.srPayload, 0, MAX_SR_BITS_IN_BYTES);
+
+   /* Fill Pst */
+   FILL_PST_MAC_TO_SCH(pst, EVENT_UCI_IND_TO_SCH);
+
+   return(*macSchSrUciIndOpts[pst.selector])(&pst, &srUciInd);
+}
+
+/*******************************************************************
+ *
+ * @brief Processes UCI Indication from PHY
+ *
+ * @details
+ *
+ *    Function : fapiMacUciInd
+ *
+ *    Functionality:
+ *       Processes UCI Indication from PHY
+ *
+ * @params[in] Post Structure Pointer
+ *             UCI Indication Pointer
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t FapiMacUciInd(Pst *pst, UciInd *macUciInd)
+{
+   uint8_t     pduIdx = 0;
+   uint8_t     ret = ROK;
+   uint16_t    nPdus;
+   uint16_t    crnti;
+
+   if(macUciInd)
+   {
+      nPdus = macUciInd->numUcis;
+      while(nPdus)
+      {
+         switch(macUciInd->pdus[pduIdx].pduType)
+         {
+            case UCI_IND_PUSCH:
+               break;
+            case UCI_IND_PUCCH_F0F1:
+               if(macUciInd->pdus[pduIdx].uci.uciPucchF0F1.srInfo.srIndPres)
+               {
+                  DU_LOG("\nMAC : Received SR UCI indication");
+                 crnti = macUciInd->pdus[pduIdx].uci.uciPucchF0F1.crnti; 
+                 ret = buildAndSendSrInd(macUciInd, crnti);
+               }
+               break;
+            case UCI_IND_PUCCH_F2F3F4:
+               break;
+            default:
+               DU_LOG("\nMAC: Invalid Pdu Type %d at FapiMacUciInd", macUciInd->pdus[pduIdx].pduType);
+               ret = RFAILED;
+               break;
+         }
+         pduIdx++;
+         nPdus--;
+      }
+   }
+   else
+   {
+      DU_LOG("\nMAC: Received Uci Ind is NULL at FapiMacUciInd()");
+      ret = RFAILED;
+   }
+   return ret;
+}
+
+
 /**********************************************************************
   End of file
  **********************************************************************/
index a0feae5..d153018 100644 (file)
@@ -29,7 +29,7 @@
 MacSchRachIndFunc macSchRachIndOpts[]=
 {
    packMacSchRachInd,
-   macSchRachInd,
+   MacSchRachInd,
    packMacSchRachInd
 };
 
index 103623a..11dd47e 100644 (file)
@@ -19,6 +19,8 @@
 #include "common_def.h"
 #include "lrg.h"
 #include "lrg.x"
+#include "rgu.h"
+#include "rgu.x"
 #include "du_app_mac_inf.h"
 #include "mac_sch_interface.h"
 #include "lwr_mac_upr_inf.h"
 /* Function declarations */
 extern uint16_t fillUlTtiReq(SlotIndInfo currTimingInfo);
 extern uint16_t fillDlTtiReq(SlotIndInfo currTimingInfo);
+extern uint16_t fillUlDciReq(SlotIndInfo currTimingInfo);
 
 /* function pointers for packing slot ind from mac to sch */
 MacSchSlotIndFunc macSchSlotIndOpts[] =
 {
    packMacSchSlotInd,
-   macSchSlotInd,
+   MacSchSlotInd,
    packMacSchSlotInd
 };
 
@@ -89,6 +92,12 @@ uint8_t MacProcDlAlloc(Pst *pst, DlSchedInfo *dlSchedInfo)
         msg4Alloc = dlSchedInfo->msg4Alloc;
         macCb.macCell[cellIdx]->macRaCb[0].msg4TbSize = msg4Alloc->msg4PdschCfg.codeword[0].tbSize;
       }
+      if(dlSchedInfo->ulGrant != NULLP)
+      {
+        currDlSlot = &macCb.macCell[cellIdx]->\
+           dlSlot[dlSchedInfo->schSlotValue.ulDciTime.slot];
+         currDlSlot->dlInfo.ulGrant = dlSchedInfo->ulGrant;
+      }
    }
    return ROK;
 }
@@ -300,6 +309,9 @@ uint8_t macProcSlotInd(SlotIndInfo slotInd)
 
    /* Trigger for UL TTI REQ */
    fillUlTtiReq(slotInd);
+   
+   /* Trigger for UL DCI REQ */
+   fillUlDciReq(slotInd);
 
    return ROK;
 }  /* macProcSlotInd */
index 2e1cb00..1718c38 100644 (file)
@@ -19,6 +19,8 @@
 #include "common_def.h"
 #include "lrg.h"
 #include "lrg.x"
+#include "rgu.h"
+#include "rgu.x"
 #include "du_app_mac_inf.h"
 #include "mac_sch_interface.h"
 #include "lwr_mac_upr_inf.h"
index 9a72cce..2ab31c1 100644 (file)
@@ -32,7 +32,7 @@
 MacSchUeCreateReqFunc macSchUeCreateReqOpts[] =
 {
    packMacSchUeCreateReq,    /* packing for loosely coupled */
-   macSchUeCreateReq,        /* packing for tightly coupled */
+   MacSchUeCreateReq,        /* packing for tightly coupled */
    packMacSchUeCreateReq     /* packing for light weight loosely coupled */
 };
 
@@ -720,7 +720,7 @@ uint8_t createUeCb(MacUeCfg *ueCfg)
    }
 
    /* Check if UE already configured */
-   ueCb = &macCb.macCell[cellIdx]->ueCb[ueCfg->ueIdx];
+   ueCb = &macCb.macCell[cellIdx]->ueCb[ueCfg->ueIdx -1];
    if(ueCb)
    {
       if((ueCb->ueIdx == ueCfg->ueIdx) && (ueCb->crnti == ueCfg->crnti) &&\
@@ -1010,7 +1010,7 @@ uint8_t MacProcSchUeCfgRsp(Pst *pst, SchUeCfgRsp *schCfgRsp)
    if(schCfgRsp->rsp == RSP_NOK)
    {
       DU_LOG("\nMAC : SCH UE Create Response : FAILURE [CRNTI %d]", schCfgRsp->crnti);
-      memset(&macCb.macCell[cellIdx]->ueCb[schCfgRsp->ueIdx], 0, sizeof(MacUeCb));
+      memset(&macCb.macCell[cellIdx]->ueCb[schCfgRsp->ueIdx -1], 0, sizeof(MacUeCb));
       macCb.macCell[cellIdx]->numActvUe--;
       result = MAC_DU_APP_RSP_NOK;
    }
index ac2b2c6..be8c36d 100644 (file)
@@ -19,6 +19,8 @@
 /* This file contains the definitions for Upper Interface APIs that are
  * invoked from MAC */
 #include "common_def.h"
+#include "rgu.h"
+#include "rgu.x"
 #include "du_app_mac_inf.h"
 #include "mac_upr_inf_api.h"
 
@@ -45,6 +47,14 @@ DuMacUlCcchInd packMacUlCcchIndOpts[] =
    packMacUlCcchInd
 };
 
+/* Function pointer options for UL Data to RLC */
+RlcMacUlDataFunc rlcMacSendUlDataOpts[] =
+{
+   packRlcUlData,
+   RlcProcUlData,
+   packRlcUlData
+};
+
 /*******************************************************************
  *
  * @brief Send slot indication to MAC
@@ -112,6 +122,26 @@ uint8_t MacDuAppUlCcchInd(Pst *pst, UlCcchIndInfo *ulCcchIndInfo)
    return (*packMacUlCcchIndOpts[pst->selector])(pst, ulCcchIndInfo);
 }
 
+/*******************************************************************
+ *
+ * @brief Send UL data to RLC
+ *
+ * @details
+ *
+ *    Function : MacRlcSendUlData
+ *
+ *    Functionality: Send UL data to RLC
+ *
+ * @params[in] 
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t MacSendUlDataToRlc(Pst *pst, RlcMacData *ulData)
+{
+   return (*rlcMacSendUlDataOpts[pst->selector])(pst, ulData);
+}
+
 
 /**********************************************************************
   End of file
index fb84cc1..7bda9d4 100644 (file)
@@ -22,6 +22,8 @@
 uint8_t MacDuAppSlotInd(Pst *pst, SlotIndInfo *slotInfo);
 uint8_t MacDuAppStopInd(Pst *pst, MacCellStopInfo *cellStopId);
 uint8_t MacDuAppUlCcchInd(Pst *pst, UlCcchIndInfo *ulCcchIndInfo);
+uint8_t MacSendUlDataToRlc(Pst *pst, RlcMacData *ulData);
+
 /**********************************************************************
          End of file
 **********************************************************************/
diff --git a/src/5gnrmac/mac_utils.c b/src/5gnrmac/mac_utils.c
new file mode 100644 (file)
index 0000000..8607227
--- /dev/null
@@ -0,0 +1,26 @@
+/*******************************************************************************
+################################################################################
+#   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.                                             #
+################################################################################
+ *******************************************************************************/
+/* header include files (.h) */
+#include "common_def.h"
+#include "mac_utils.h"
+
+
+uint32_t shortBsrBytesTable[MAX_SHORT_BSR_TABLE_ENTRIES] = { 0, 10, 14, 20, 28, \
+   38, 53, 74, 102, 142, 198, 276, 384, 535, 745, 1038, 1446, 2014, 2806, 3909, \
+   5446, 7587, 10570, 14726, 20516, 28581, 39818, 55474, 77284, 107669, 150000, \
+   150001 };
index 899324e..6a7c53a 100644 (file)
@@ -18,6 +18,7 @@
 
 /* Contains common utility definitions to be used at MAC */
 
+#define MAX_SHORT_BSR_TABLE_ENTRIES 32
 #define MAC_MEM_REGION   4
 #define MAC_POOL         1
 
    _pst.intfVer = 0;                                        \
 }
 
+/* Fills Pst to send msg to RLC */
+#define FILL_PST_MAC_TO_RLC(_pst, _dstInst, _event)        \
+{                                                      \
+   pst.selector  = ODU_SELECTOR_LWLC;                  \
+   pst.srcEnt    = ENTRG;                              \
+   pst.dstEnt    = ENTKW;                              \
+   pst.dstInst   = _dstInst;                           \
+   pst.srcInst   = macCb.macInst;                      \
+   pst.dstProcId = macCb.procId;                       \
+   pst.srcProcId = macCb.procId;                       \
+   pst.region    = MAC_MEM_REGION;                     \
+   pst.pool      = MAC_POOL;                           \
+   pst.event     = _event;                             \
+   pst.route     = 0;                                  \
+   pst.prior     = 0;                                  \
+   pst.intfVer   = 0;                                  \
+}
+
 /**********************************************************************
          End of file
 **********************************************************************/
index 7e81e6f..75857d0 100755 (executable)
        Portable functions corresponding to these primitives are also defined.
 */
 /* header include files (.h) */
-#include "envopt.h"        /* environment options */
-#include "envdep.h"        /* environment dependent */
-#include "envind.h"        /* environment independent */
-#include "gen.h"           /* general */
-#include "ssi.h"           /* system services */
-#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_lte.h"        /* Common LTE Defines */
+#include "common_def.h"
 #include "rg_env.h"        /* MAC Environment Defines */
 #include "crg.h"           /* CRG Interface defines */
 #include "rgr.h"           /* RGR Interface defines */
 #include "rgm.h"           /* RGM Interface defines*/
 
 /* header/extern include files (.x) */
-#include "gen.x"           /* general */
-#include "ssi.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_lte.x"        /* Common LTE Defines */
 #include "crg.x"           /* CRG Interface includes */
 #include "rgr.x"           /* RGR Interface includes */
 #include "rgu.x"           /* RGU Interface includes */
index 508a6f3..5a094dd 100755 (executable)
@@ -71,6 +71,7 @@ static int RLOG_FILE_ID=196;
 #include "kw_udx.x"
 #include "kw_dl.x"
 #include "kw_ul.x"
+#include "rlc_utils.h"
 
 #ifdef __cplusplus
 EXTERN "C" {
@@ -206,7 +207,7 @@ U8     status;
  *
 */
 
-PUBLIC S16 RlcMacProcUlData(Pst *pst, SuId suId, RlcMacData *ulData)
+uint8_t RlcProcUlData(Pst *pst, RlcMacData *ulData)
 {
    U8              idx;
    U8              lcId;                    /* Logical Channel */
@@ -215,6 +216,7 @@ PUBLIC S16 RlcMacProcUlData(Pst *pst, SuId suId, RlcMacData *ulData)
    RguLchDatInd    dLchData[RGU_MAX_LC];  /* PDU info on dedicated logical channel */
    RguDDatIndInfo  *dLchUlDat;               /* UL data on dedicated logical channel */
    RguCDatIndInfo  *cLchUlDat;               /* UL data on common logical channel */
+   uint16_t        copyLen;
 
    /* Initializing dedicated logical channel Database */
    for(idx = 0; idx < RGU_MAX_LC; idx++)
@@ -227,31 +229,40 @@ PUBLIC S16 RlcMacProcUlData(Pst *pst, SuId suId, RlcMacData *ulData)
   
    /* Seggregate PDUs received on common and dedicated channels
     * and call common channel's handler */
-   for(idx = 0; idx< ulData->nmbPdu; idx++)
+   for(idx = 0; idx< ulData->numPdu; idx++)
    {
       if(ulData->pduInfo[idx].commCh)
       {
-         RLC_SHRABL_STATIC_BUF_ALLOC(pst->region, pst->pool, cLchUlDat, sizeof(RguCDatIndInfo));
-         cmMemset((U8*)cLchUlDat, (U8)0, sizeof(RguCDatIndInfo));
-       
-         cLchUlDat->cellId = ulData->cellId;
-         cLchUlDat->rnti   = ulData->rnti;
-         cLchUlDat->lcId   = ulData->pduInfo[idx].lcId;
-         cLchUlDat->pdu    = ulData->pduInfo[idx].pduBuf;
-         
-         KwLiRguCDatInd(pst, suId, cLchUlDat);
+        RLC_SHRABL_STATIC_BUF_ALLOC(pst->region, pst->pool, cLchUlDat, sizeof(RguCDatIndInfo));
+        cmMemset((U8*)cLchUlDat, (U8)0, sizeof(RguCDatIndInfo));
+
+        cLchUlDat->cellId = ulData->cellId;
+        GET_UE_IDX(ulData->rnti, cLchUlDat->rnti);
+        cLchUlDat->lcId   = ulData->pduInfo[idx].lcId;
+
+        /* Copy fixed buffer to message */
+        if(SGetMsg(RLC_MEM_REGION_UL, RLC_POOL, &cLchUlDat->pdu) != ROK)
+        {
+           DU_LOG("\nRLC : Memory allocation failed at RlcProcUlData");
+           return RFAILED;
+        }
+        reverseFixBuf(ulData->pduInfo[idx].pduBuf, ulData->pduInfo[idx].pduLen);
+        SCpyFixMsg(ulData->pduInfo[idx].pduBuf, cLchUlDat->pdu, 0, \
+              ulData->pduInfo[idx].pduLen, (MsgLen *)&copyLen);
+
+        KwLiRguCDatInd(pst, 0, cLchUlDat);
       } 
       else
       {
-         if(!dLchPduPres)
-         {
-            RLC_SHRABL_STATIC_BUF_ALLOC(pst->region, pst->pool, dLchUlDat, sizeof(RguDDatIndInfo));
-            dLchPduPres = TRUE;
-         }
-
-         lcId = ulData->pduInfo[idx].lcId;
-         dLchData[lcId].pdu.mBuf[dLchData[lcId].pdu.numPdu] = ulData->pduInfo[idx].pduBuf;
-         dLchData[lcId].pdu.numPdu++; 
+        if(!dLchPduPres)
+        {
+           RLC_SHRABL_STATIC_BUF_ALLOC(pst->region, pst->pool, dLchUlDat, sizeof(RguDDatIndInfo));
+           dLchPduPres = TRUE;
+        }
+
+        lcId = ulData->pduInfo[idx].lcId;
+        dLchData[lcId].pdu.mBuf[dLchData[lcId].pdu.numPdu] = ulData->pduInfo[idx].pduBuf;
+        dLchData[lcId].pdu.numPdu++; 
       }
    }
  
@@ -264,21 +275,21 @@ PUBLIC S16 RlcMacProcUlData(Pst *pst, SuId suId, RlcMacData *ulData)
 
       for(idx = 0; idx < RGU_MAX_LC; idx++)
       {
-         if(dLchData[idx].pdu.numPdu)
-         {
-            cmMemcpy((U8 *)&dLchUlDat->lchData[numDLch], (U8 *)&dLchData[idx], sizeof(RguLchDatInd));
-            numDLch++;      
-         }
+        if(dLchData[idx].pdu.numPdu)
+        {
+           cmMemcpy((U8 *)&dLchUlDat->lchData[numDLch], (U8 *)&dLchData[idx], sizeof(RguLchDatInd));
+           numDLch++;      
+        }
       }
       dLchUlDat->numLch = numDLch;
-      KwLiRguDDatInd(pst, suId, dLchUlDat);
+      KwLiRguDDatInd(pst, 0, dLchUlDat);
    }
     
 
    RLC_FREE_SHRABL_BUF(pst->region, pst->pool, ulData, sizeof(RlcMacData));
    RETVALUE(ROK);
    
-}/* End of RlcMacProcUlData */
+}/* End of RlcProcUlData */
 
 PUBLIC int   rlcDDatIndRcvd;
 PUBLIC int   rlcCDatIndRcvd;
@@ -349,7 +360,7 @@ RguCDatIndInfo   *datInd;
 #endif /* (ERRCLASS & ERRCLS_DEBUG) */
 
    /* Fetch RbCb from lcId */
-   kwDbmFetchUlRbCbFromLchId(tRlcCb, 0, datInd->cellId, datInd->lcId, &rbCb);
+   kwDbmFetchUlRbCbFromLchId(tRlcCb, datInd->rnti, datInd->cellId, datInd->lcId, &rbCb);
    if (!rbCb)
    {
       RLOG_ARG1(L_ERROR, DBG_CELLID,datInd->cellId, "LcId [%d] not found",
index 5b593c9..5c8e7b9 100755 (executable)
@@ -367,11 +367,11 @@ RguCStaIndInfo   *staInd;
    }
 #endif /* ERRCLASS & ERRCLS_ADD_RES */
 
-   dlData->timeToTx.sfn = sdu->mode.tm.sfn;
-   dlData->timeToTx.slot = sdu->mode.tm.slot;
+   dlData->slotInfo.sfn = sdu->mode.tm.sfn;
+   dlData->slotInfo.slot = sdu->mode.tm.slot;
    dlData->cellId = rbCb->rlcId.cellId;
    dlData->rnti = sdu->mode.tm.rnti;
-   dlData->nmbPdu = 1;
+   dlData->numPdu = 1;
    dlData->pduInfo[0].commCh = TRUE;
    dlData->pduInfo[0].lcId = rbCb->lch.lChId;
    dlData->pduInfo[0].pduBuf =  sdu->mBuf;
index b60d717..6accebd 100755 (executable)
@@ -61,6 +61,9 @@ static int RLOG_FILE_ID=201;
 
 #include "kw.x"
 #include "kw_ul.x"
+#include "du_app_rlc_inf.h"
+#include "rlc_utils.h"
+#include "rlc_upr_inf_api.h"
 
 #if defined(PRE_DEF_UE_CTX) || defined(PRE_DEF_UE_CTX_HO)
 #ifdef EG_GEN_LOAD_5GTF
@@ -273,45 +276,53 @@ Buffer     *pdu;
 #endif
 #endif 
 {
-   KwuDatIndInfo   *datIndInfo;   /* Data Indication Information */
-   MsgLen          msgLen;
+   RlcUlRrcMsgInfo  *ulRrcMsgInfo;
+   uint16_t         msgLen;
+   uint16_t         copyLen;    /* Number of bytes copied */
+   Pst              pst;
  
    TRC2(kwTmmRcvFrmLi) 
 
-   /* Creating static memory for KwuDatIndInfo. #else will be 
-    * removed once the sanity testing is performed for all platforms */
-   KwuDatIndInfo datIndInfoTmp;
-   datIndInfo = &datIndInfoTmp;
-#if (ERRCLASS & ERRCLS_ADD_RES)
-   if ( datIndInfo == NULLP )
-   {   
-      RLOG_ARG2(L_FATAL,DBG_RBID,rbCb->rlcId.rbId,
-            "Memory Allocation failed UEID:%d CELLID:%d",
-            rbCb->rlcId.ueId,
-            rbCb->rlcId.cellId);   
-      RETVOID;
-   }
-#endif /* ERRCLASS & ERRCLS_ADD_RES */
-   KW_MEM_CPY(&(datIndInfo->rlcId),&(rbCb->rlcId),sizeof(CmLteRlcId));
-#ifdef CCPU_OPT 
-   if ( rbCb->lch.lChType == CM_LTE_LCH_CCCH ) 
-   {
-      datIndInfo->tCrnti = tCrnti;
-   }
-#endif 
    gCb->genSts.pdusRecv++;
-   SFndLenMsg(pdu, &msgLen);
+   SFndLenMsg(pdu, (MsgLen *)&msgLen);
    gCb->genSts.bytesRecv += msgLen;
    /* If trace flag is enabled send the trace indication */
    if(gCb->init.trc == TRUE)
    {
       /* Populate the trace params */
-      kwLmmSendTrc(gCb,KWU_EVT_DAT_IND, pdu);
+      kwLmmSendTrc(gCb, EVENT_UL_RRC_MSG_TRANS_TO_DU, pdu);
    }
-   KwUiKwuDatInd( &gCb->u.ulCb->kwuUlSap->pst, 
-                  //gCb->u.ulCb->kwuUlSap->suId, 
-                  datIndInfo, pdu);
-   
+  
+   /* Filling UL RRC Message Info */
+   RLC_ALLOC_SHRABL_BUF(RLC_MEM_REGION_UL, RLC_POOL,
+      ulRrcMsgInfo, sizeof(RlcUlRrcMsgInfo));
+   if (ulRrcMsgInfo)
+   {
+      ulRrcMsgInfo->cellId = rbCb->rlcId.cellId;
+      ulRrcMsgInfo->ueIdx = rbCb->rlcId.ueId;
+      ulRrcMsgInfo->lcId = rbCb->lch.lChId;
+      RLC_ALLOC_SHRABL_BUF(RLC_MEM_REGION_UL, RLC_POOL,
+         ulRrcMsgInfo->rrcMsg, msgLen);
+      if (ulRrcMsgInfo->rrcMsg)
+      {
+         SCpyMsgFix(pdu, 0, msgLen, ulRrcMsgInfo->rrcMsg, (MsgLen *)&copyLen);
+         ulRrcMsgInfo->msgLen = msgLen;
+
+         /* Sending UL RRC Message transfeer to DU APP */
+         memset(&pst, 0, sizeof(Pst));
+         FILL_PST_RLC_TO_DUAPP(pst, SFndProcId(), RLC_UL_INST, EVENT_UL_RRC_MSG_TRANS_TO_DU);
+         rlcSendUlRrcMsgToDu(&pst, ulRrcMsgInfo);
+      }
+      else
+      {
+         DU_LOG("\nRLC : Memory allocation failed");
+      }
+   }
+   else
+   {
+      DU_LOG("\nRLC : Memory allocation failed");
+   }
    RETVOID;
 }
 
index d2dab04..5fdd20a 100755 (executable)
@@ -432,7 +432,7 @@ Buffer *mBuf;           /* message buffer */
 
                case EVTRLCULDAT:    /* Dedicated Channel Data request */
                   {
-                     ret = unpackRcvdUlData(RlcMacProcUlData, pst, mBuf);
+                     ret = unpackRcvdUlData(RlcProcUlData, pst, mBuf);
                      break;
                   }
 
index 63b1886..f8cd117 100755 (executable)
@@ -261,7 +261,7 @@ RguDDatReqInfo    *datReqInfo;
       dlData->cellId = datReqInfo->cellId;
       dlData->rnti = datPerUe.rnti;
       //dlData->timeToTx = datPerUe.transId; /* Derive timing info from transId */
-      dlData->nmbPdu = 0;
+      dlData->numPdu = 0;
 
       for(tbIdx = 0; tbIdx < datPerUe.nmbOfTbs; tbIdx++)
       {
@@ -271,10 +271,10 @@ RguDDatReqInfo    *datReqInfo;
             datPerLch = datPerTb.lchData[lchIdx];
             for(pduIdx = 0; pduIdx < datPerLch.pdu.numPdu; pduIdx++)
             {
-               dlData->pduInfo[dlData->nmbPdu].commCh = FALSE;
-               dlData->pduInfo[dlData->nmbPdu].lcId = datPerLch.lcId;
-               dlData->pduInfo[dlData->nmbPdu].pduBuf = datPerLch.pdu.mBuf[pduIdx];
-               dlData->nmbPdu++;
+               dlData->pduInfo[dlData->numPdu].commCh = FALSE;
+               dlData->pduInfo[dlData->numPdu].lcId = datPerLch.lcId;
+               dlData->pduInfo[dlData->numPdu].pduBuf = datPerLch.pdu.mBuf[pduIdx];
+               dlData->numPdu++;
             }/* For per PDU */
          }/* For Data per Lch */
       }/* For Data per Tb */
index 5867ecd..9b2fb09 100644 (file)
@@ -100,7 +100,7 @@ PUBLIC S16 macStubSendDlData(Pst *pst, SpId spId, RlcMacData *dlData)
 
    ulDatNum++;
    DU_LOG("\nMAC_STUB : UL data number %d", ulDatNum);
-   RlcMacProcUlData(&rspPst, 1, ulData);
+   RlcProcUlData(&rspPst, 1, ulData);
    return ROK;
 }
 
diff --git a/src/5gnrrlc/rlc_upr_inf_api.c b/src/5gnrrlc/rlc_upr_inf_api.c
new file mode 100644 (file)
index 0000000..4785fb7
--- /dev/null
@@ -0,0 +1,52 @@
+/*******************************************************************************
+################################################################################
+#   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 "common_def.h"
+#include "du_app_rlc_inf.h"
+
+/* Function pointer array for UL RRC Msg Transfer */
+RlcUlRrcMsgToDuFunc rlcSendUlRrcMsgToDuOpts[] = 
+{
+   packRlcUlRrcMsgToDu,       /* 0 - Loosely coupled */
+   DuProcRlcUlRrcMsgTrans,    /* 1 - Tightly coupled */
+   packRlcUlRrcMsgToDu        /* 2 - Light weight loosely coupled */
+};
+
+/*******************************************************************
+ *
+ * @brief Sends UL RRC Message Info to DU APP
+ *
+ * @details
+ *
+ *    Function : rlcSendUlRrcMsgToDu
+ *
+ *    Functionality:  Sends UL RRC Message Info to DU APP
+ *
+ * @params[in] Pst structure
+ *             UL RRC Msg Info
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t rlcSendUlRrcMsgToDu(Pst *pst, RlcUlRrcMsgInfo *ulRrcMsgInfo)
+{
+   return (*rlcSendUlRrcMsgToDuOpts[pst->selector])(pst, ulRrcMsgInfo);
+}
+
+/**********************************************************************
+         End of file
+**********************************************************************/
diff --git a/src/5gnrrlc/rlc_upr_inf_api.h b/src/5gnrrlc/rlc_upr_inf_api.h
new file mode 100644 (file)
index 0000000..dc1df1e
--- /dev/null
@@ -0,0 +1,23 @@
+/*******************************************************************************
+################################################################################
+#   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.                                             #
+################################################################################
+*******************************************************************************/
+
+uint8_t rlcSendUlRrcMsgToDu(Pst *pst, RlcUlRrcMsgInfo *ulRrcMsgInfo);
+
+/**********************************************************************
+         End of file
+**********************************************************************/
diff --git a/src/5gnrrlc/rlc_utils.c b/src/5gnrrlc/rlc_utils.c
new file mode 100644 (file)
index 0000000..4f154df
--- /dev/null
@@ -0,0 +1,52 @@
+/*******************************************************************************
+################################################################################
+#   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 "common_def.h"
+
+/*******************************************************************
+ *
+ * @brief Reverse fixed buffer
+ *
+ * @details
+ *
+ *    Function : reverseFixBuf
+ *
+ *    Functionality: Reverse fixed buffer
+ *
+ * @params[in] Fixed buffer to be reversed
+ *             Buffer length
+ * @return void
+ *
+ * ****************************************************************/
+void reverseFixBuf(uint8_t *buf, uint16_t len)
+{
+   uint8_t idx, revIdx;
+   uint8_t temp;
+
+   for(idx = 0, revIdx = len-1; idx < len/2; idx++, revIdx--)
+   {
+      temp = buf[idx];
+      buf[idx] = buf[revIdx];
+      buf[revIdx] = temp;
+   }
+   return;
+}
+
+/**********************************************************************
+         End of file
+**********************************************************************/
diff --git a/src/5gnrrlc/rlc_utils.h b/src/5gnrrlc/rlc_utils.h
new file mode 100644 (file)
index 0000000..b18f441
--- /dev/null
@@ -0,0 +1,57 @@
+/*******************************************************************************
+################################################################################
+#   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.                                             #
+################################################################################
+*******************************************************************************/
+
+/* Memory */
+#define RLC_MEM_REGION_UL    1
+#define RLC_MEM_REGION_DL    4
+#define RLC_POOL 1
+
+/* Inst */
+#define RLC_UL_INST   0
+#define RLC_DL_INST   1
+
+/* Fill Pst structure for sending msg from RLC to DUAPP */
+#define FILL_PST_RLC_TO_DUAPP(_pst, _procId, _srcInst, _event) \
+{                                                              \
+   _pst.selector    = ODU_SELECTOR_LWLC;                       \
+   _pst.srcEnt      = ENTKW;                                   \
+   _pst.dstEnt      = ENTDUAPP;                                \
+   _pst.dstInst     = 0;                                       \
+   _pst.srcInst     = _srcInst;                                \
+   _pst.dstProcId   = _procId;                                 \
+   _pst.srcProcId   = _procId;                                 \
+   if(_srcInst == RLC_UL_INST)                                 \
+   {                                                           \
+      _pst.region   = RLC_MEM_REGION_UL;                       \
+   }                                                           \
+   else if(_srcInst == RLC_DL_INST)                            \
+   {                                                           \
+      _pst.region   = RLC_MEM_REGION_DL;                       \
+   }                                                           \
+   _pst.pool        = RLC_POOL;                                \
+   _pst.event       = _event;                                  \
+   _pst.route       = 0;                                       \
+   _pst.prior       = 0;                                       \
+   _pst.intfVer     = 0;                                       \
+}
+
+void reverseFixBuf(uint8_t *buf, uint16_t len);
+
+/**********************************************************************
+         End of file
+**********************************************************************/
index ffebfb5..7fe891e 100755 (executable)
@@ -242,7 +242,7 @@ Buffer  *mBuf;                      /* message buffer       */
 #endif
 #endif            
             case EVENT_SLOT_IND_TO_SCH:
-               unpackMacSchSlotInd(macSchSlotInd, pst, mBuf);
+               unpackMacSchSlotInd(MacSchSlotInd, pst, mBuf);
                break;
             default:
                RGSCH_FREE_MSG(mBuf);
index a2c77ee..a16f307 100644 (file)
@@ -248,7 +248,7 @@ int SchProcGenCfgReq(Pst *pst, RgMngmt *cfg)
  *
  * @details
  *
- *     Function : macSchSlotInd 
+ *     Function : MacSchSlotInd 
  *      
  *      This API is invoked by PHY to indicate slot indication to Scheduler for
  *      a cell.
@@ -259,7 +259,7 @@ int SchProcGenCfgReq(Pst *pst, RgMngmt *cfg)
  *      -# ROK 
  *      -# RFAILED 
  **/
-uint8_t macSchSlotInd(Pst *pst, SlotIndInfo *slotInd)
+uint8_t MacSchSlotInd(Pst *pst, SlotIndInfo *slotInd)
 {
    Inst  inst = pst->dstInst-SCH_INST_START;
 
@@ -267,7 +267,7 @@ uint8_t macSchSlotInd(Pst *pst, SlotIndInfo *slotInd)
    schProcessSlotInd(slotInd, inst);
 
    return ROK;
-}  /* macSchSlotInd */
+}  /* MacSchSlotInd */
 
 /*******************************************************************
  *
@@ -275,7 +275,7 @@ uint8_t macSchSlotInd(Pst *pst, SlotIndInfo *slotInd)
  *
  * @details
  *
- *    Function : macSchRachInd
+ *    Function : MacSchRachInd
  *
  *    Functionality:
  *      Processes Rach indication from MAC
@@ -285,7 +285,7 @@ uint8_t macSchSlotInd(Pst *pst, SlotIndInfo *slotInd)
  *         RFAILED - failure
  *
  * ****************************************************************/
-uint8_t macSchRachInd(Pst *pst, RachIndInfo *rachInd)
+uint8_t MacSchRachInd(Pst *pst, RachIndInfo *rachInd)
 {
    Inst  inst = pst->dstInst-SCH_INST_START;
    DU_LOG("\nSCH : Received Rach indication");
@@ -299,7 +299,7 @@ uint8_t macSchRachInd(Pst *pst, RachIndInfo *rachInd)
  *
  * @details
  *
- *    Function : macSchCrcInd
+ *    Function : MacSchCrcInd
  *
  *    Functionality:
  *      Processes CRC indication from MAC
@@ -310,7 +310,7 @@ uint8_t macSchRachInd(Pst *pst, RachIndInfo *rachInd)
  *         RFAILED - failure
  *
  * ****************************************************************/
-uint8_t macSchCrcInd(Pst *pst, CrcIndInfo *crcInd)
+uint8_t MacSchCrcInd(Pst *pst, CrcIndInfo *crcInd)
 {
    switch(crcInd->crcInd[0])
    {
@@ -333,7 +333,7 @@ uint8_t macSchCrcInd(Pst *pst, CrcIndInfo *crcInd)
  *
  * @details
  *
- *     Function : InitSchCellCb 
+ *     Function : schInitCellCb 
  *      
  *      This API is invoked after receiving schCellCfg
  *           
@@ -343,13 +343,13 @@ uint8_t macSchCrcInd(Pst *pst, CrcIndInfo *crcInd)
  *      -# ROK 
  *      -# RFAILED 
  **/
-int InitSchCellCb(Inst inst, SchCellCfg *schCellCfg)
+int schInitCellCb(Inst inst, SchCellCfg *schCellCfg)
 {
    SchCellCb *cell;
    SCH_ALLOC(cell, sizeof(SchCellCb));
    if(!cell)
    {
-      DU_LOG("\nMemory allocation failed in InitSchCellCb");
+      DU_LOG("\nMemory allocation failed in schInitCellCb");
       return RFAILED;
    }
 
@@ -375,7 +375,7 @@ int InitSchCellCb(Inst inst, SchCellCfg *schCellCfg)
       SCH_ALLOC(schDlSlotInfo, sizeof(SchDlSlotInfo));
       if(!schDlSlotInfo)
       {
-        DU_LOG("\nMemory allocation failed in InitSchCellCb");
+        DU_LOG("\nMemory allocation failed in schInitCellCb");
         return RFAILED;
       }
 
@@ -383,26 +383,12 @@ int InitSchCellCb(Inst inst, SchCellCfg *schCellCfg)
       SCH_ALLOC(schUlSlotInfo, sizeof(SchUlSlotInfo));
       if(!schUlSlotInfo)
       {
-        DU_LOG("\nMemory allocation failed in InitSchCellCb");
+        DU_LOG("\nMemory allocation failed in schInitCellCb");
         return RFAILED;
       }
 
-      memset(schDlSlotInfo, 0, sizeof(SchDlSlotInfo));
-      memset(schUlSlotInfo, 0, sizeof(SchUlSlotInfo));
-
-      schDlSlotInfo->totalPrb = schUlSlotInfo->totalPrb = MAX_NUM_RB;
-
-      for(uint8_t itr=0; itr<SCH_SYMBOL_PER_SLOT; itr++)
-      {
-        schDlSlotInfo->assignedPrb[itr] = 0;
-        schUlSlotInfo->assignedPrb[itr] = 0;
-      }
-      schUlSlotInfo->schPuschInfo = NULLP;
-
-      for(uint8_t itr=0; itr<MAX_SSB_IDX; itr++)
-      {
-        memset(&schDlSlotInfo->ssbInfo[itr], 0, sizeof(SsbInfo));
-      }
+      schInitDlSlot(schDlSlotInfo);
+      schInitUlSlot(schUlSlotInfo);
 
       cell->schDlSlotInfo[idx] = schDlSlotInfo;
       cell->schUlSlotInfo[idx] = schUlSlotInfo;
@@ -485,7 +471,7 @@ void fillSchSib1Cfg(Inst schInst, SchSib1Cfg *sib1SchCfg, uint16_t pci, \
    bwp->cyclicPrefix       = 0;              /* normal */
 
    /* fill the PDCCH PDU */
-   pdcch->coreset0Cfg.coreSet0Size = numRbs;
+   pdcch->coreset0Cfg.coreSetSize = numRbs;
    pdcch->coreset0Cfg.startSymbolIndex = firstSymbol;
    pdcch->coreset0Cfg.durationSymbols = numSymbols;
    memcpy(pdcch->coreset0Cfg.freqDomainResource,FreqDomainResource,6);
@@ -628,7 +614,7 @@ uint8_t SchHdlCellCfgReq(Pst *pst, SchCellCfg *schCellCfg)
    Pst rspPst;
    Inst inst = pst->dstInst-1; 
 
-   InitSchCellCb(inst, schCellCfg);
+   schInitCellCb(inst, schCellCfg);
    cellCb = schCb[inst].cells[inst]; //cells is of MAX_CELLS, why inst
    cellCb->macInst = pst->srcInst;
 
@@ -660,7 +646,7 @@ uint8_t SchHdlCellCfgReq(Pst *pst, SchCellCfg *schCellCfg)
  *
  * @details
  *
- *    Function : macSchDlRlcBoInfo
+ *    Function : MacSchDlRlcBoInfo
  *
  *    Functionality:
  *       Processes DL RLC BO info from MAC
@@ -670,7 +656,7 @@ uint8_t SchHdlCellCfgReq(Pst *pst, SchCellCfg *schCellCfg)
  *         RFAILED - failure
  *
  * ****************************************************************/
-uint8_t macSchDlRlcBoInfo(Pst *pst, DlRlcBOInfo *dlBoInfo)
+uint8_t MacSchDlRlcBoInfo(Pst *pst, DlRlcBOInfo *dlBoInfo)
 {
    uint16_t  lcIdx;
    Inst  inst = pst->dstInst-SCH_INST_START;
@@ -705,6 +691,77 @@ uint8_t macSchDlRlcBoInfo(Pst *pst, DlRlcBOInfo *dlBoInfo)
    return ROK;
 }
 
+/*******************************************************************
+ *
+ * @brief Processes BSR indiation from MAC
+ *
+ * @details
+ *
+ *    Function : MacSchBsr
+ *
+ *    Functionality:
+ *       Processes DL BSR from MAC
+ *
+ * @params[in]    Pst pst
+ *                UlBufferStatusRptInd bsrInd
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t MacSchBsr(Pst *pst, UlBufferStatusRptInd *bsrInd)
+{
+   Inst           schInst       = pst->dstInst-SCH_INST_START;
+   SchCellCb      *cellCb       = NULLP;
+   SchUeCb        *ueCb         = NULLP;
+   uint8_t        lcgIdx;
+
+   DU_LOG("\nSCH : Received BSR");
+
+   cellCb = schCb[schInst].cells[schInst];
+   ueCb = schGetUeCb(cellCb, bsrInd->crnti);
+
+   /* store dataVolume per lcg in uecb */
+   for(lcgIdx = 0; lcgIdx < bsrInd->numLcg; lcgIdx++)
+   {
+      ueCb->bsrInfo[lcgIdx].priority = 1; //TODO: determining LCG priority?
+      ueCb->bsrInfo[lcgIdx].dataVol = bsrInd->dataVolInfo[lcgIdx].dataVol;
+   }
+   return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief Processes SR UCI indication from MAC 
+ *
+ * @details
+ *
+ *    Function : MacSchSrUciInd
+ *
+ *    Functionality:
+ *      Processes SR UCI indication from MAC
+ *
+ * @params[in] Post structure
+ *             UCI Indication
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t MacSchSrUciInd(Pst *pst, SrUciIndInfo *uciInd)
+{
+   Inst  inst = pst->dstInst-SCH_INST_START;
+
+   SchUeCb   *ueCb; 
+   SchCellCb *cellCb = schCb[inst].cells[inst];
+
+   DU_LOG("\nSCH : Received SR");
+   ueCb = schGetUeCb(cellCb, uciInd->crnti);
+
+   if(uciInd->numSrBits)
+   {
+      ueCb->srRcvd = true;
+   }
+   return ROK;
+}
 /**********************************************************************
   End of file
  **********************************************************************/
index 101cb97..5322e8c 100644 (file)
 
 #define CRC_FAILED 0
 #define CRC_PASSED 1
+#define UL_GRANT_SIZE 224
 
-extern uint8_t schProcessRachInd(RachIndInfo *rachInd, Inst schInst);
+typedef struct schCellCb SchCellCb;
+typedef struct schUeCb SchUeCb;
 
 typedef enum
 {
@@ -97,22 +99,38 @@ typedef struct schUlSlotInfo
 {
    uint16_t     totalPrb;  /*!< Number of RBs in the cell */
    uint16_t     assignedPrb[SCH_SYMBOL_PER_SLOT]; /*!< Num RBs and corresponding symbols allocated */
+   uint8_t      puschCurrentPrb; /* Current PRB for PUSCH allocation */
    bool         puschPres; /*!< PUSCH presence field */
    SchPuschInfo *schPuschInfo; /*!< PUSCH info */
    bool         pucchPres; /*!< PUCCH presence field */
    SchPucchInfo schPucchInfo; /*!< PUCCH info */
 }SchUlSlotInfo;
 
+/**
+@brief
+* BSR info per slot per UE.
+*/
+typedef struct bsrInfo
+{
+   uint8_t    priority;  /* CG priority */
+   uint32_t   dataVol;   /* Data volume requested in bytes */
+}BsrInfo;
+
+
+
 /**
  * @brief
  * UE control block
  */
 typedef struct schUeCb
 {
-   uint16_t  ueIdx;
-   uint16_t  crnti;
-   SchUeCfg  ueCfg;
-   SchUeState  state;
+   uint16_t   ueIdx;
+   uint16_t   crnti;
+   SchUeCfg   ueCfg;
+   SchUeState state;
+   SchCellCb  *cellCb;
+   bool       srRcvd;
+   BsrInfo    bsrInfo[MAX_NUM_LOGICAL_CHANNEL_GROUPS];
 }SchUeCb;
 
 /**
@@ -157,6 +175,10 @@ uint8_t schDlRsrcAllocMsg4(Msg4Alloc *msg4Alloc, SchCellCb *cell, uint16_t slot)
 uint16_t schCalcTbSize(uint16_t payLoadSize);
 uint16_t schCalcNumPrb(uint16_t tbSize, uint16_t mcs, uint8_t numSymbols);
 uint16_t schAllocPucchResource(SchCellCb *cell, uint16_t crnti, uint16_t slot);
+uint8_t schProcessRachInd(RachIndInfo *rachInd, Inst schInst);
+uint8_t schFillUlDci(SchUeCb *ueCb, SchPuschInfo puschInfo, DciInfo *dciInfo);
+uint8_t schFillPuschAlloc(SchUeCb *ueCb, uint16_t pdcchSlot, uint32_t dataVol, SchPuschInfo *puschInfo);
+
 /**********************************************************************
   End of file
  **********************************************************************/
index c9bc50f..119cb26 100644 (file)
@@ -106,10 +106,17 @@ uint8_t schBroadcastAlloc(SchCellCb *cell, DlBrdcstAlloc *dlBrdcstAlloc,
    /* SIB1 allocation */
    if(dlBrdcstAlloc->sib1Trans)
    {
+      uint16_t tbSize         = 0;
+      uint8_t numPdschSymbols = 12; /* considering pdsch region from 2 to 13 */
+      uint8_t mcs             = 4;  /* MCS fixed to 4 */
+      uint8_t numSib1Prb      = 0;
       schDlSlotInfo->sib1Pres = true;
+
+      tbSize = schCalcTbSize(95); /* send this value to the func in bytes when considering sib1 size */
+      numSib1Prb = schCalcNumPrb(tbSize,mcs,numPdschSymbols);
       for(idx=0; idx<SCH_SYMBOL_PER_SLOT; idx++)
       {
-        schDlSlotInfo->assignedPrb[idx] = ssbStartPrb + SCH_SSB_NUM_PRB + 1 + 10; /* 10 PRBs for sib1 */
+        schDlSlotInfo->assignedPrb[idx] = ssbStartPrb + SCH_SSB_NUM_PRB + 1 + numSib1Prb; /* 10 PRBs for sib1 */
       }
       memcpy(&dlBrdcstAlloc->sib1Alloc.bwp, &cell->cellCfg.sib1SchCfg.bwp, sizeof(BwpCfg)); 
       memcpy(&dlBrdcstAlloc->sib1Alloc.sib1PdcchCfg, &cell->cellCfg.sib1SchCfg.sib1PdcchCfg, sizeof(PdcchCfg)); 
@@ -246,8 +253,8 @@ uint16_t fillPucchResourceInfo(SchPucchInfo *schPucchInfo, Inst inst)
    schPucchInfo->numHarqBits = 1; /* 1 bit for HARQ */
 
    /* set SR and UCI flag to false */
-   schPucchInfo->srFlag  = false;
-   schPucchInfo->uciFlag = false;
+   schPucchInfo->srFlag  = true;
+   schPucchInfo->uciFlag = true;
 
    return ROK;
 }
@@ -309,8 +316,8 @@ uint8_t schUlResAlloc(SchCellCb *cell, Inst schInst)
    {
       DU_LOG("\nSending UL Sch info from SCH to MAC failed");
    }
-   memset(cell->schUlSlotInfo[ulTimingInfo.slot], 0, sizeof(SchUlSlotInfo));
 
+   schInitUlSlot(schUlSlotInfo);
    return ret;
 }
 
@@ -384,7 +391,7 @@ uint8_t schDlRsrcAllocMsg4(Msg4Alloc *msg4Alloc, SchCellCb *cell, uint16_t slot)
    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.coreSet0Size = numRbs;
+   pdcch->coreset0Cfg.coreSetSize = numRbs;
    pdcch->coreset0Cfg.shiftIndex = cell->cellCfg.phyCellId;
    pdcch->coreset0Cfg.precoderGranularity = 0; /* sameAsRegBundle */
    pdcch->numDlDci = 1;
index f4c7a64..c55ac07 100644 (file)
@@ -114,6 +114,9 @@ uint8_t *msg3NumRb)
        uint8_t    startRb       = 0;
        uint8_t    numRb         = 0;
        uint8_t    idx           = 0;
+       uint8_t    mcs            = 4;
+       uint8_t    numPdschSymbols= 14;
+       uint16_t   tbSize         = 0;
 
 
    cell = schCb[schInst].cells[schInst];
@@ -127,16 +130,14 @@ uint8_t *msg3NumRb)
        msg3SlotAlloc = slot + k2 + delta;
        msg3SlotAlloc = msg3SlotAlloc % SCH_NUM_SLOTS; 
 
-       startRb = PUSCH_START_RB;
-
-       /* formula used for calculation of rbSize, 38.214 section 6.1.4.2 
-        * Ninfo = S.Nre.R.Qm.v
-        * Nre'  = Nsc.NsymPdsch-NdmrsSymb-Noh
-        * Nre   = min(156,Nre').nPrb */
-       numRb = 1; /* based on above calculation */
+        startRb = cell->schUlSlotInfo[msg3SlotAlloc]->puschCurrentPrb;
+        tbSize = schCalcTbSize(8); /* 6 bytes msg3  and 2 bytes header */
+       numRb = schCalcNumPrb(tbSize, mcs, numPdschSymbols);
 
        /* allocating 1 extra RB for now */
        numRb++;
+       /* increment PUSCH PRB */
+       cell->schUlSlotInfo[msg3SlotAlloc]->puschCurrentPrb += numRb;
 
        for(idx=startSymb; idx<symbLen; idx++)
        {
@@ -156,7 +157,7 @@ uint8_t *msg3NumRb)
        schUlSlotInfo->schPuschInfo->fdAlloc.numPrb    = numRb;
        schUlSlotInfo->schPuschInfo->tdAlloc.startSymb = startSymb;
        schUlSlotInfo->schPuschInfo->tdAlloc.numSymb   = symbLen;
-       schUlSlotInfo->schPuschInfo->tbInfo.mcs      = 4;
+       schUlSlotInfo->schPuschInfo->tbInfo.mcs        = mcs;
        schUlSlotInfo->schPuschInfo->tbInfo.ndi        = 1; /* new transmission */
        schUlSlotInfo->schPuschInfo->tbInfo.rv          = 0;
        schUlSlotInfo->schPuschInfo->tbInfo.tbSize     = 24; /*Considering 2 PRBs */
index 5ad429c..2986915 100644 (file)
@@ -139,13 +139,13 @@ void schCalcSlotValues(SlotIndInfo slotInd, SchSlotValue *schSlotValue)
 uint8_t schProcessSlotInd(SlotIndInfo *slotInd, Inst schInst)
 {
    int ret = ROK;
-   uint8_t ssb_rep;
+   uint8_t ssb_rep, ueIdx, lcgIdx;
    uint16_t slot, sfnSlot = 0;
    DlSchedInfo dlSchedInfo;
    memset(&dlSchedInfo,0,sizeof(DlSchedInfo));
    DlBrdcstAlloc *dlBrdcstAlloc = &dlSchedInfo.brdcstAlloc;
-   RarAlloc  *rarAlloc;
-   Msg4Alloc *msg4Alloc;
+   RarAlloc  *rarAlloc = NULLP;
+   Msg4Alloc *msg4Alloc = NULLP;
    dlBrdcstAlloc->ssbTrans = NO_SSB;
    dlBrdcstAlloc->sib1Trans = NO_SIB1;
 
@@ -256,7 +256,49 @@ uint8_t schProcessSlotInd(SlotIndInfo *slotInd, Inst schInst)
       SCH_FREE(cell->schDlSlotInfo[dlSchedInfo.schSlotValue.msg4Time.slot]->msg4Info, sizeof(Msg4Info));
       cell->schDlSlotInfo[dlSchedInfo.schSlotValue.msg4Time.slot]->msg4Info = NULL;
    }
-
+   /* check if UL grant must be sent in this slot for a SR/BSR that had been received */
+   for(ueIdx=0; ueIdx<cell->numActvUe; ueIdx++)
+   {
+      uint32_t totDataReq = 0; /* in bytes */
+      DciInfo  *dciInfo = NULLP;
+      SchUeCb *ueCb = NULLP;
+   
+      ueCb = &cell->ueCb[ueIdx];
+      /* check for SR */
+      if(ueCb->srRcvd)
+      {
+         totDataReq = UL_GRANT_SIZE; /*fixing so that all control msgs can be handled in SR */
+         ueCb->srRcvd = false;
+      }
+      /* check for BSR */
+      for(lcgIdx=0; lcgIdx<MAX_NUM_LOGICAL_CHANNEL_GROUPS; lcgIdx++)
+      {
+        totDataReq+= ueCb->bsrInfo[lcgIdx].dataVol;
+       ueCb->bsrInfo[lcgIdx].dataVol = 0;
+      }
+      if(totDataReq > 0) /* UL grant must be provided for this UE in this slot */
+      {
+         SchPuschInfo schPuschInfo;
+         memset(&schPuschInfo, 0, sizeof(SchPuschInfo));
+
+        SCH_ALLOC(dciInfo, sizeof(DciInfo));
+        if(!dciInfo)
+        {
+           DU_LOG("\nMAC: Memory Allocation failed for dciInfo alloc");
+           return RFAILED;
+        }
+        memset(dciInfo,0,sizeof(DciInfo));
+        /* update the SFN and SLOT */
+        memcpy(&dlSchedInfo.schSlotValue.ulDciTime, slotInd, sizeof(SlotIndInfo));
+        slot = dlSchedInfo.schSlotValue.ulDciTime.slot;
+        /* Update PUSCH allocation */
+        schFillPuschAlloc(ueCb, slot, totDataReq, &schPuschInfo);
+        /* Fill DCI for UL grant */
+        schFillUlDci(ueCb, schPuschInfo, dciInfo);
+        memcpy(&dciInfo->slotIndInfo, &dlSchedInfo.schSlotValue.ulDciTime, sizeof(SlotIndInfo));
+         dlSchedInfo.ulGrant = dciInfo;
+      }
+   }
 
    /* send msg to MAC */
    ret = sendDlAllocToMac(&dlSchedInfo, schInst);
@@ -266,9 +308,9 @@ uint8_t schProcessSlotInd(SlotIndInfo *slotInd, Inst schInst)
       RETVALUE(ret);
    }
 
+   schInitDlSlot(cell->schDlSlotInfo[slot]);
    schUlResAlloc(cell, schInst);
 
-   memset(cell->schDlSlotInfo[slot], 0, sizeof(SchDlSlotInfo));
 
    return ret;
 }
index ee6cdb1..d3fbde6 100644 (file)
@@ -79,7 +79,7 @@ void SchSendUeCfgRspToMac(SchUeCfg *ueCfg, Inst inst,\
  *
  * @details
  *
- *    Function : macSchUeCreateReq
+ *    Function : MacSchUeCreateReq
  *
  *    Functionality: Hanles Ue create request from MAC
  *
@@ -88,7 +88,7 @@ void SchSendUeCfgRspToMac(SchUeCfg *ueCfg, Inst inst,\
  *         RFAILED - failure
  *
  * ****************************************************************/
-uint8_t macSchUeCreateReq(Pst *pst, SchUeCfg *ueCfg)
+uint8_t MacSchUeCreateReq(Pst *pst, SchUeCfg *ueCfg)
 {
    uint8_t      idx;
    uint16_t     ueIdx;
@@ -131,7 +131,7 @@ uint8_t macSchUeCreateReq(Pst *pst, SchUeCfg *ueCfg)
 
    /* Search if UE already configured */
    GET_UE_IDX(ueCfg->crnti, ueIdx);
-   ueCb = &cellCb->ueCb[ueIdx];
+   ueCb = &cellCb->ueCb[ueIdx -1];
    if(ueCb)
    {
       if((ueCb->crnti == ueCfg->crnti) && (ueCb->state == SCH_UE_STATE_ACTIVE))
@@ -151,10 +151,171 @@ uint8_t macSchUeCreateReq(Pst *pst, SchUeCfg *ueCfg)
    ueCb->state = SCH_UE_STATE_ACTIVE;
    cellCb->numActvUe++;
 
+   ueCb->cellCb = cellCb;
+   ueCb->srRcvd = false;
+   for(idx=0; idx<MAX_NUM_LOGICAL_CHANNEL_GROUPS; idx++)
+      ueCb->bsrInfo[idx].dataVol = 0;
+
    SchSendUeCfgRspToMac(ueCfg, inst, RSP_OK, &cfgRsp);
    return ROK;
 }
 
+/*******************************************************************
+*
+* @brief Fills PUSCH UL allocation
+*
+* @details
+*
+*    Function : schFillPuschAlloc
+*
+*    Functionality: fills PUSCH info
+*
+* @params[in]
+* @return ROK     - success
+*         RFAILED - failure
+*
+* ****************************************************************/
+uint8_t schFillPuschAlloc(SchUeCb *ueCb, uint16_t pdcchSlot, uint32_t dataVol, SchPuschInfo *puschInfo)
+{
+  uint16_t puschSlot      = 0;
+  uint16_t startRb        = 0;
+  uint8_t  numRb          = 0;
+  uint8_t  mcs            = 4;
+  uint8_t  numPdschSymbols= 14;
+  uint16_t tbSize         = 0;
+  uint8_t  buffer         = 5;
+  uint8_t  idx            = 0;
+  SchCellCb *cellCb       = ueCb->cellCb;
+  SchUlSlotInfo *schUlSlotInfo = NULLP;
+  uint8_t  k2 = ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.puschCfg.timeDomRsrcAllocList[0].k2;
+  uint8_t  startSymb = ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.puschCfg.timeDomRsrcAllocList[0].startSymbol;
+  uint8_t  symbLen = ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.puschCfg.timeDomRsrcAllocList[0].symbolLength;
+
+  puschSlot = (pdcchSlot + k2) % SCH_NUM_SLOTS;
+
+  startRb = cellCb->schUlSlotInfo[puschSlot]->puschCurrentPrb;
+  tbSize  = schCalcTbSize((dataVol + buffer)/8); /*  2 bytes header + some buffer */
+  numRb   = schCalcNumPrb(tbSize, mcs, numPdschSymbols);
+  /* increment PUSCH PRB */
+
+  cellCb->schUlSlotInfo[puschSlot]->puschCurrentPrb += numRb;
+
+  puschInfo->harqProcId        = SCH_HARQ_PROC_ID;
+  puschInfo->resAllocType      = SCH_ALLOC_TYPE_1;
+  puschInfo->fdAlloc.startPrb  = startRb;
+  puschInfo->fdAlloc.numPrb    = numRb;
+  puschInfo->tdAlloc.startSymb = startSymb;
+  puschInfo->tdAlloc.numSymb   = symbLen;
+  puschInfo->tbInfo.mcs        = mcs;
+  puschInfo->tbInfo.ndi        = 1; /* new transmission */
+  puschInfo->tbInfo.rv         = 0;
+  puschInfo->tbInfo.tbSize     = tbSize;
+  puschInfo->dmrsMappingType   = DMRS_MAP_TYPE_A;  /* Setting Type-A */
+  puschInfo->nrOfDmrsSymbols   = NUM_DMRS_SYMBOLS;
+  puschInfo->dmrsAddPos        = DMRS_ADDITIONAL_POS;
+
+  /* Update pusch in cell */
+  for(idx=startSymb; idx<symbLen; idx++)
+  {
+     cellCb->schUlSlotInfo[puschSlot]->assignedPrb[idx] = startRb + numRb;
+  }
+
+  schUlSlotInfo = cellCb->schUlSlotInfo[puschSlot];
+
+  SCH_ALLOC(schUlSlotInfo->schPuschInfo, sizeof(SchPuschInfo));
+  if(!schUlSlotInfo->schPuschInfo)
+  {
+     DU_LOG("SCH: Memory allocation failed in schAllocMsg3Pusch");
+     return RFAILED;
+  }
+  memcpy(schUlSlotInfo->schPuschInfo, puschInfo, sizeof(SchPuschInfo));
+
+  return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief Fills DCI for UL grant
+ *
+ * @details
+ *
+ *    Function : schFillUlDci
+ *
+ *    Functionality: fills DCI for UL grant in response to BSR
+ *
+ * @params[in]
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t schFillUlDci(SchUeCb *ueCb, SchPuschInfo puschInfo, DciInfo *dciInfo)
+{
+   SchCellCb         *cellCb  = ueCb->cellCb;
+   SchControlRsrcSet coreset1 = ueCb->ueCfg.spCellCfg.servCellCfg.initDlBwp.pdcchCfg.cRSetToAddModList[0];
+
+   dciInfo->cellId = cellCb->cellId;
+   dciInfo->crnti  = ueCb->crnti;
+
+   /* fill bwp cfg */
+   dciInfo->bwpCfg.subcarrierSpacing  = cellCb->cellCfg.sib1SchCfg.bwp.subcarrierSpacing;
+   dciInfo->bwpCfg.cyclicPrefix       = cellCb->cellCfg.sib1SchCfg.bwp.cyclicPrefix;
+   dciInfo->bwpCfg.freqAlloc.startPrb = 0;
+   dciInfo->bwpCfg.freqAlloc.numPrb   = MAX_NUM_RB; /* whole of BW */
+
+   /*fill coreset cfg */
+   //Considering number of RBs in coreset1 is same as coreset0
+   dciInfo->coresetCfg.coreSetSize      = coresetIdxTable[0][1];
+   //Considering coreset1 also starts from same symbol as coreset0
+   dciInfo->coresetCfg.startSymbolIndex = searchSpaceIdxTable[0][3];
+   dciInfo->coresetCfg.durationSymbols  = coreset1.duration;
+   memcpy(dciInfo->coresetCfg.freqDomainResource, coreset1.freqDomainRsrc, FREQ_DOM_RSRC_SIZE);
+   
+   dciInfo->coresetCfg.cceRegMappingType   = coreset1.cceRegMappingType; /* non-interleaved */
+   dciInfo->coresetCfg.regBundleSize       = 6; /* must be 6 for non-interleaved */
+   dciInfo->coresetCfg.interleaverSize     = 0; /* NA for non-interleaved */
+   dciInfo->coresetCfg.coreSetType         = 1; /* non PBCH coreset */
+   dciInfo->coresetCfg.shiftIndex          = cellCb->cellCfg.phyCellId;
+   dciInfo->coresetCfg.precoderGranularity = coreset1.precoderGranularity;
+   dciInfo->coresetCfg.cceIndex            = 0; /* 0-3 for UL and 4-7 for DL */
+   dciInfo->coresetCfg.aggregationLevel    = 4; /* same as for sib1 */
+   
+   dciInfo->formatType = FORMAT0_0;
+   
+   /* fill UL grant */
+   dciInfo->format.format0_0.resourceAllocType   = puschInfo.resAllocType;
+   dciInfo->format.format0_0.freqAlloc.startPrb  = puschInfo.fdAlloc.startPrb;
+   dciInfo->format.format0_0.freqAlloc.numPrb    = puschInfo.fdAlloc.numPrb;
+   dciInfo->format.format0_0.timeAlloc.startSymb = puschInfo.tdAlloc.startSymb;
+   dciInfo->format.format0_0.timeAlloc.numSymb   = puschInfo.tdAlloc.numSymb;
+   dciInfo->format.format0_0.rowIndex            = 0; /* row Index */
+   dciInfo->format.format0_0.mcs                 = puschInfo.tbInfo.mcs;
+   dciInfo->format.format0_0.harqProcId          = puschInfo.harqProcId;
+   dciInfo->format.format0_0.puschHopFlag        = FALSE; /* disabled */
+   dciInfo->format.format0_0.freqHopFlag         = FALSE; /* disabled */
+   dciInfo->format.format0_0.ndi                 = puschInfo.tbInfo.ndi; /* new transmission */
+   dciInfo->format.format0_0.rv                  = puschInfo.tbInfo.rv;
+   dciInfo->format.format0_0.tpcCmd              = 0; //Sphoorthi TODO: check
+   dciInfo->format.format0_0.sUlCfgd             = FALSE; /* SUL not configured */
+   
+   /* Fill DCI Structure */
+   dciInfo->dciInfo.rnti                              = ueCb->crnti;
+   dciInfo->dciInfo.scramblingId                      = cellCb->cellCfg.phyCellId;
+   dciInfo->dciInfo.scramblingRnti                    = 0;
+   dciInfo->dciInfo.cceIndex                          = 0; /* 0-3 for UL and 4-7 for DL */
+   dciInfo->dciInfo.aggregLevel                       = 4;
+   dciInfo->dciInfo.beamPdcchInfo.numPrgs             = 1;
+   dciInfo->dciInfo.beamPdcchInfo.prgSize             = 1;
+   dciInfo->dciInfo.beamPdcchInfo.digBfInterfaces     = 0;
+   dciInfo->dciInfo.beamPdcchInfo.prg[0].pmIdx        = 0;
+   dciInfo->dciInfo.beamPdcchInfo.prg[0].beamIdx[0]   = 0;
+   dciInfo->dciInfo.txPdcchPower.powerValue           = 0;
+   dciInfo->dciInfo.txPdcchPower.powerControlOffsetSS = 0;
+   dciInfo->dciInfo.pdschCfg                          = NULLP; /* No DL data being sent */
+
+   return ROK;
+}
+
+
 /**********************************************************************
   End of file
  **********************************************************************/
index 344e84e..f2c9c84 100644 (file)
@@ -458,63 +458,6 @@ uint8_t pucchResourceSet[MAX_PUCCH_RES_SET_IDX][4] = {
 { 1,   0, 14,  0 }, /* index 15 */
 };
 
-/**
- * @brief frequency domain allocation function. 
- *
- * @details
- *
- *     Function: schAllocFreqDomRscType0
- *     
- *     This function does allocation in frequency domain resource.
- *     This is a bitmap defining  non-overlapping groups of 6 PRBs in ascending order.
- *     
- *  @param[in]  startPrb - start PRB from where the freq alloc starts.  
- *  @param[in]  prbSize - number of PRBs to be allocted.
- *  @param[in]  freqDomain - 6 bytes of info, each bit represents a group of 6 PRB.
- *  @return   void
- **/
-void schAllocFreqDomRscType0(uint16_t startPrb, uint16_t prbSize, uint8_t *freqDomain)
-{
-   uint8_t remBits = prbSize; /* each bit represents 6 PRBs */
-   uint8_t firstByte = 1;
-   uint8_t numBits,startBit,byteCount = 5;
-
-   while(remBits)
-   {
-      /* when the startPrb is not in this byteCount */
-      if(startPrb/8)
-      {
-         startPrb -= 8;
-         byteCount--;
-         continue;
-      }
-
-      /* max bytecount is 6 nearly equal to 45 bits*/
-      if(byteCount >= 6)
-          break;
-
-      /* when we are filling the second byte, then the start should be equal to 0 */
-      if(firstByte)
-         startBit = startPrb;
-      else
-         startBit = 0;
-
-      /* calculate the number of bits to be set in this byte */
-      if((remBits+startPrb) <= 8)
-         numBits = remBits;
-      else
-         numBits = 8 - startBit;
-
-      /* bit operation to set the bits */
-               SET_BITS_MSB((startBit % 8),numBits,freqDomain[byteCount])
-      firstByte = 0;
-
-      /* the ramaining bits should be subtracted with the numBits set in this byte */
-      remBits -= numBits;
-      byteCount--;
-   }
-}
-
 /**
  * @brief frequency domain allocation function. 
  *
@@ -530,15 +473,15 @@ void schAllocFreqDomRscType0(uint16_t startPrb, uint16_t prbSize, uint8_t *freqD
 uint16_t schCalcTbSize(uint16_t payLoadSize)
 {
    uint8_t tbsIndex = 0;
-       payLoadSize = payLoadSize*8;
+   payLoadSize = payLoadSize*8;
 
-       while(payLoadSize > tbSizeTable[tbsIndex])
-       {
-          tbsIndex++;
-       }
+   while(payLoadSize > tbSizeTable[tbsIndex])
+   {
+      tbsIndex++;
+   }
 
-       /* return the TBsize in bytes */
-       return (tbSizeTable[tbsIndex]/8);
+   /* return the TBsize in bytes */
+   return (tbSizeTable[tbsIndex]);
 }
 
 /**
@@ -559,27 +502,100 @@ uint16_t schCalcNumPrb(uint16_t tbSize, uint16_t mcs, uint8_t numSymbols)
 {
    uint16_t numPrb = 0;
    uint16_t nre = 0;
-       uint16_t nreDash = 0;
-       uint8_t  qm     = mcsTable[mcs][1];
-       uint16_t rValue = mcsTable[mcs][2];
-       uint8_t  numLayer = 1;       /* v value */
+   uint16_t nreDash = 0;
+   uint8_t  qm     = mcsTable[mcs][1];
+   uint16_t rValue = mcsTable[mcs][2];
+   uint8_t  numLayer = 1;       /* v value */
 
    /* 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                                     */
 
-       nre = ceil( (float)tbSize * 1024 / (qm * rValue * numLayer));
+   nre = ceil( (float)tbSize * 1024 / (qm * rValue * numLayer));
 
-       nreDash = ceil( (12 * numSymbols) - NUM_DMRS_SYMBOLS - 0);
+   nreDash = ceil( (12 * numSymbols) - NUM_DMRS_SYMBOLS - 0);
 
-       if (nreDash > 156)
-          nre = 156;
+   if (nreDash > 156)
+      nre = 156;
 
    numPrb = ceil((float)nre / nreDash);   
-       return numPrb;
+   return numPrb;
+}
+
+/**
+ * @brief fetching ueCb from cellCb
+ *
+ * @details
+ *
+ *     Function: schGetUeCb
+ *
+ *     This function fetched UeCb based on crnti from cellCb
+ *
+ *  @param[in]  cellCb
+ *  @param[in]  crnti
+ *  @return     ueCb
+ **/
+SchUeCb* schGetUeCb(SchCellCb *cellCb, uint16_t crnti)
+{
+   uint16_t ueIdx;
+   GET_UE_IDX(crnti, ueIdx);
+   return &(cellCb->ueCb[ueIdx -1]);
 }
 
+/**
+ * @brief initialize UL slot info
+ *
+ * @details
+ *
+ *     Function: schInitUlSlot
+ *
+ *     This function intializes UL slot of the cell
+ *
+ *  @param[in]  schUlSlotInfo
+ *  @return     void
+ **/
+void schInitUlSlot(SchUlSlotInfo *schUlSlotInfo)
+{
+   memset(schUlSlotInfo, 0, sizeof(SchUlSlotInfo));
+   schUlSlotInfo->totalPrb = MAX_NUM_RB;
+   for(uint8_t itr=0; itr<SCH_SYMBOL_PER_SLOT; itr++)
+   {
+      schUlSlotInfo->assignedPrb[itr] = 0;
+   }
+   schUlSlotInfo->puschCurrentPrb = PUSCH_START_RB;
+   schUlSlotInfo->schPuschInfo = NULLP;
+
+}
+
+/**
+ * @brief initialize DL slot info
+ *
+ * @details
+ *
+ *     Function: schInitDlSlot
+ *
+ *     This function intializes DL slot of the cell
+ *
+ *  @param[in]  schDlSlotInfo
+ *  @return     void
+ **/
+void schInitDlSlot(SchDlSlotInfo *schDlSlotInfo)
+{
+   memset(schDlSlotInfo, 0, sizeof(SchDlSlotInfo));
+   schDlSlotInfo->totalPrb = MAX_NUM_RB;
+   for(uint8_t itr=0; itr<SCH_SYMBOL_PER_SLOT; itr++)
+   {
+      schDlSlotInfo->assignedPrb[itr] = 0;
+   }
+  
+   for(uint8_t itr=0; itr<MAX_SSB_IDX; itr++)
+   {
+      memset(&schDlSlotInfo->ssbInfo[itr], 0, sizeof(SsbInfo));
+   }
+
+
+}
 /**********************************************************************
          End of file
 **********************************************************************/
index defdc54..329c70e 100644 (file)
    _pst.selector  = ODU_SELECTOR_TC;                         \
 }
 
+extern int8_t coresetIdxTable[MAX_CORESET_INDEX][4];
+extern int8_t searchSpaceIdxTable[MAX_SEARCH_SPACE_INDEX][4];
+
 /* functions declarations */
 void schAllocFreqDomRscType0(uint16_t startPrb, uint16_t prbSize, uint8_t *freqDomain);
 uint16_t schCalcTbSize(uint16_t payLoadSize);
 uint16_t schCalcNumPrb(uint16_t tbSize, uint16_t mcs, uint8_t numSymbols);
+SchUeCb* schGetUeCb(SchCellCb *cellCb, uint16_t crnti);
+void schInitUlSlot(SchUlSlotInfo *schUlSlotInfo);
+void schInitDlSlot(SchDlSlotInfo *schDlSlotInfo);
 
-extern int8_t coresetIdxTable[MAX_CORESET_INDEX][4];
-extern int8_t searchSpaceIdxTable[MAX_SEARCH_SPACE_INDEX][4];
 
 /**********************************************************************
   End of file
diff --git a/src/cm/common_def.c b/src/cm/common_def.c
new file mode 100644 (file)
index 0000000..978d0e7
--- /dev/null
@@ -0,0 +1,82 @@
+/*******************************************************************************
+################################################################################
+#   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 "common_def.h"
+
+/**
+ * @brief frequency domain allocation function. 
+ *
+ * @details
+ *
+ *     Function: schAllocFreqDomRscType0
+ *     
+ *     This function does allocation in frequency domain resource.
+ *     This is a bitmap defining  non-overlapping groups of 6 PRBs in ascending order.
+ *     
+ *  @param[in]  startPrb - start PRB from where the freq alloc starts.  
+ *  @param[in]  prbSize - number of PRBs to be allocted.
+ *  @param[in]  freqDomain - 6 bytes of info, each bit represents a group of 6 PRB.
+ *  @return   void
+ **/
+void schAllocFreqDomRscType0(uint16_t startPrb, uint16_t prbSize, uint8_t *freqDomain)
+{
+   uint8_t remBits = prbSize; /* each bit represents 6 PRBs */
+   uint8_t firstByte = 1;
+   uint8_t numBits,startBit,byteCount = 5;
+
+   while(remBits)
+   {
+      /* when the startPrb is not in this byteCount */
+      if(startPrb/8)
+      {
+         startPrb -= 8;
+         byteCount--;
+         continue;
+      }
+
+      /* max bytecount is 6 nearly equal to 45 bits*/
+      if(byteCount >= 6)
+          break;
+
+      /* when we are filling the second byte, then the start should be equal to 0 */
+      if(firstByte)
+         startBit = startPrb;
+      else
+         startBit = 0;
+
+      /* calculate the number of bits to be set in this byte */
+      if((remBits+startPrb) <= 8)
+         numBits = remBits;
+      else
+         numBits = 8 - startBit;
+
+      /* bit operation to set the bits */
+               SET_BITS_MSB((startBit % 8),numBits,freqDomain[byteCount])
+      firstByte = 0;
+
+      /* the ramaining bits should be subtracted with the numBits set in this byte */
+      remBits -= numBits;
+      byteCount--;
+   }
+}
+
+
+
+/**********************************************************************
+         End of file
+**********************************************************************/
index d09a285..f5591a4 100644 (file)
@@ -15,6 +15,9 @@
 #   limitations under the License.                                             #
 ################################################################################
 *******************************************************************************/
+#ifndef __COMMON_DEF_H__
+#define __COMMON_DEF_H__
+
 #include <stdio.h>
 #include <ctype.h>
 #include <stdlib.h>
    _cellIdx = _cellId - 1;                \
 }
 
+#define SET_BITS_MSB(_startBit, _numBits, _byte) \
+{                                                \
+   _byte = (~((0xFF) >> _numBits));              \
+       _byte >>= _startBit;                          \
+}
+
+#define SET_BITS_LSB(_startBit, _numBits, _byte) \
+{                                                \
+   _byte = (~((0xFF) << _numBits));              \
+       _byte <<= _startBit;                          \
+}
+
+
 typedef struct slotIndInfo
 {
    uint16_t cellId;
@@ -95,6 +111,9 @@ typedef struct PlmnIdentity
    uint8_t mnc[3];
 }Plmn;
 
+void schAllocFreqDomRscType0(uint16_t startPrb, uint16_t prbSize, uint8_t *freqDomain);
+
+#endif
 /**********************************************************************
   End of file
 ***********************************************************************/
index 91378c8..7901f3b 100644 (file)
@@ -615,6 +615,7 @@ typedef struct ulCcchInd
 {
    uint16_t cellId;
    uint16_t crnti;
+   uint16_t ulCcchMsgLen;
    uint8_t  *ulCcchMsg;
 }UlCcchIndInfo;
 
index ffa283f..6fd9b94 100644 (file)
@@ -17,7 +17,6 @@
 *******************************************************************************/
 
 #include "common_def.h"
-#include "du_log.h"
 #include "du_app_rlc_inf.h"
 
 /*******************************************************************
@@ -177,6 +176,83 @@ uint8_t unpackRlcUlUeCreateRsp(RlcUlDuUeCreateRsp func, Pst *pst, Buffer *mBuf)
 
    return RFAILED;
 }
+
+/*******************************************************************
+ *
+ * @brief Pack and send UL RRC message transfer from RLC to DU APP
+ *
+ * @details
+ *
+ *    Function : packRlcUlRrcMsgToDu
+ *
+ *    Functionality:
+ *       Pack and send UL RRC message transfer from RLC to DU APP
+ *
+ * @params[in] Post structure
+ *             UL RRC Msg transfer info
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t packRlcUlRrcMsgToDu(Pst *pst, RlcUlRrcMsgInfo *ulRrcMsgInfo)
+{
+   Buffer *mBuf = NULLP;
+
+   if(pst->selector == ODU_SELECTOR_LWLC)
+   {
+      if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK)
+      {
+         DU_LOG("\nRLC : Memory allocation failed at packRlcUlRrcMsgToDu");
+         return RFAILED;
+      }
+      /* pack the address of the structure */
+      CMCHKPK(cmPkPtr,(PTR)ulRrcMsgInfo, mBuf);
+      return SPstTsk(pst,mBuf);
+   }
+   else
+   {
+      DU_LOG("\nRLC: Only LWLC supported for packRlcUlRrcMsgToDu");
+   }
+   return RFAILED;
+}
+
+/*******************************************************************
+ *
+ * @brief Unpack UL RRC Msg Transfer received at DU APP from RLC
+ *
+ * @details
+ *
+ *    Function : unpackRlcUlRrcMsgToDu
+ *
+ *    Functionality:
+ *      Unpack UL RRC Msg Transfer received at DU APP from RLC
+ *
+ * @params[in]
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t unpackRlcUlRrcMsgToDu(RlcUlRrcMsgToDuFunc func, Pst *pst, Buffer *mBuf)
+{
+   if(pst->selector == ODU_SELECTOR_LWLC)
+   {
+      RlcUlRrcMsgInfo *ulRrcMsgInfo;
+      /* unpack the address of the structure */
+      CMCHKUNPK(cmUnpkPtr, (PTR *)&ulRrcMsgInfo, mBuf);
+      SPutMsg(mBuf);
+      return (*func)(pst, ulRrcMsgInfo);
+   }
+   else
+   {
+      /* Nothing to do for other selectors */
+      DU_LOG("\nRLC: Only LWLC supported for UL RRC Message transfer ");
+      SPutMsg(mBuf);
+   }
+
+   return RFAILED;
+}
+
+
 /**********************************************************************
          End of file
-**********************************************************************/
+***********************************************************************/
index 367c78f..b4330f3 100644 (file)
@@ -24,6 +24,7 @@
 #define MAX_NUM_LOGICAL_CHANNELS 11
 #define EVENT_RLC_UL_UE_CREATE_REQ  210
 #define EVENT_RLC_UL_UE_CREATE_RSP 211    /*!< Config Confirm */
+#define EVENT_UL_RRC_MSG_TRANS_TO_DU  212
 
 #define RB_ID_SRB 0
 #define RB_ID_DRB 1
@@ -489,6 +490,16 @@ typedef struct rlcUeCfgRsp
    FailureReason  reason;
 }RlcUeCfgRsp;
 
+/* UL RRC Message from RLC to DU APP */
+typedef struct ulRrcMsgInfo
+{
+   uint16_t   cellId;       /* Cell Id */
+   uint16_t   ueIdx;        /* UE Index */
+   uint8_t    lcId;         /* Logical channel Id */
+   uint16_t   msgLen;       /* RRC message length (in bytes) */
+   uint8_t    *rrcMsg;      /* RRC Message (UL-DCCH Message) */
+}RlcUlRrcMsgInfo;
+
 /* Function Pointers */
 /* UE create Request from DU APP to RLC*/
 typedef uint8_t (*DuRlcUlUeCreateReq) ARGS((
@@ -500,6 +511,11 @@ typedef uint8_t (*RlcUlDuUeCreateRsp) ARGS((
    Pst          *pst,
    RlcUeCfgRsp  *ueCfgRsp));
 
+/* UL RRC Message from RLC to DU APP */
+typedef uint8_t (*RlcUlRrcMsgToDuFunc) ARGS((
+   Pst           *pst,
+   RlcUlRrcMsgInfo *ulRrcMsgInfo));
+
 /* Function Declarations */
 uint8_t packDuRlcUlUeCreateReq(Pst *pst, RlcUeCfg *ueCfg);
 uint8_t unpackRlcUlUeCreateReq(DuRlcUlUeCreateReq func, Pst *pst, Buffer *mBuf);
@@ -507,6 +523,9 @@ uint8_t RlcUlProcUeCreateReq(Pst *pst, RlcUeCfg *ueCfg);
 uint8_t packRlcUlDuUeCreateRsp(Pst *pst, RlcUeCfgRsp *ueCfgRsp);
 uint8_t unpackRlcUlUeCreateRsp(RlcUlDuUeCreateRsp func, Pst *pst, Buffer *mBuf);
 uint8_t DuProcRlcUlUeCreateRsp(Pst *pst, RlcUeCfgRsp *cfgRsp);
+uint8_t packRlcUlRrcMsgToDu(Pst *pst, RlcUlRrcMsgInfo *ulRrcMsgInfo);
+uint8_t DuProcRlcUlRrcMsgTrans(Pst *pst, RlcUlRrcMsgInfo *ulRrcMsgInfo);
+uint8_t unpackRlcUlRrcMsgToDu(RlcUlRrcMsgToDuFunc func, Pst *pst, Buffer *mBuf);
 
 #endif /* RLC_INF_H */
 
index 30a2621..b36b0fe 100644 (file)
@@ -269,6 +269,66 @@ uint8_t packSchUeCfgRsp(Pst *pst, SchUeCfgRsp *cfgRsp)
    return ROK;
 }
 
+/*******************************************************************
+ *
+ * @brief Pack and Send BSR from MAC to SCH
+ *
+ * @details
+ *
+ *    Function : packMacSchBsr
+ *
+ *    Functionality:
+ *       Pack and Send BSR from MAC to SCH
+ *
+ * @params[in]
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t packMacSchBsr(Pst *pst, UlBufferStatusRptInd *bsrInd)
+{
+   if((pst->selector == ODU_SELECTOR_LC) || (pst->selector == ODU_SELECTOR_LWLC))
+   {
+      /* TODO */
+   }
+   else
+   {
+      return RFAILED;
+   }
+   return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief Pack and Send SR UCI Ind from MAC to SCH
+ *
+ * @details
+ *
+ *    Function : packMacSrSchUciInd
+ *
+ *    Functionality:
+ *       Pack and Send SR UCI Ind from MAC to SCH
+ *
+ * @params[in] 
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t packMacSchSrUciInd(Pst *pst, SrUciIndInfo *uciInd)
+{
+   if((pst->selector == ODU_SELECTOR_LC) || (pst->selector == ODU_SELECTOR_LWLC))
+   {
+      /* TODO */
+   }
+   else
+   {
+      return RFAILED;
+   }
+   return ROK;
+}
+
+
+
 /**********************************************************************
   End of file
  **********************************************************************/
index dfd971d..bcb903b 100644 (file)
  *******************************************************************************/
 
 /* events */
-#define EVENT_SCH_CELL_CFG      1
-#define EVENT_SCH_CELL_CFG_CFM  2
-#define EVENT_DL_ALLOC          3 
-#define EVENT_UL_SCH_INFO       4 
+#define EVENT_SCH_CELL_CFG           1
+#define EVENT_SCH_CELL_CFG_CFM       2
+#define EVENT_DL_ALLOC               
+#define EVENT_UL_SCH_INFO            
 #define EVENT_RACH_IND_TO_SCH        5
 #define EVENT_CRC_IND_TO_SCH         6
 #define EVENT_DL_RLC_BO_INFO_TO_SCH  7
 #define EVENT_UE_CREATE_REQ_TO_SCH   8
 #define EVENT_UE_CREATE_RSP_TO_MAC   9
 #define EVENT_SLOT_IND_TO_SCH        10
+#define EVENT_SHORT_BSR              11
+#define EVENT_UCI_IND_TO_SCH         12
 
 /*macros*/
 #define NO_SSB 0
 #define SCH_DATATYPE_PRACH 16
 
 #define MAX_NUMBER_OF_CRC_IND_BITS 1
+#define MAX_NUMBER_OF_UCI_IND_BITS 1
+#define MAX_SR_BITS_IN_BYTES       1
 #define MAX_NUM_LOGICAL_CHANNELS   11
+#define MAX_NUM_LOGICAL_CHANNEL_GROUPS 8
 /* can we have a common numslot numscs between mac sch */
 #define MAX_SLOTS 10
 #define MAX_SFN   1024
@@ -69,6 +74,8 @@
 
 #define SD_SIZE   3
 #define CCCH_LCID  0
+#define SRB1_LCID  1
+#define SRB2_LCID  2
 
 #define ADD_DELTA_TO_TIME(crntTime, toFill, incr)          \
 {                                                          \
@@ -87,7 +94,6 @@
    }                                                       \
 }
 
-/*structures*/
 typedef enum
 {
    UNSPECIFIED_CAUSE,
@@ -315,6 +321,23 @@ typedef enum
    RSP_NOK
 }SchMacRsp;
 
+typedef enum
+{
+   SHORT_BSR,
+   LONG_BSR,
+   SHORT_TRUNCATED_BSR,
+   LONG_TRUNCATED_BSR
+}BsrType;
+
+typedef enum
+{
+   FORMAT0_0,
+   FORMAT0_1,
+   FORMAT1_0,
+   FORMAT1_1
+}FormatType;
+
+/*structures*/
 typedef struct timeDomainAlloc
 {
    uint16_t startSymb;
@@ -427,7 +450,7 @@ typedef struct pdschCfg
 
 typedef struct coresetCfg
 {
-   uint8_t coreSet0Size;
+   uint8_t coreSetSize;
    uint8_t startSymbolIndex;
    uint8_t durationSymbols;
    uint8_t freqDomainResource[6];
@@ -679,8 +702,62 @@ typedef struct schSlotValue
    SlotIndInfo rarTime;
    SlotIndInfo msg4Time;
    SlotIndInfo dlMsgTime;
+   SlotIndInfo ulDciTime;
 }SchSlotValue;
 
+typedef struct format0_0
+{
+   uint8_t         resourceAllocType;
+   /* since we are using type-1, hence rbBitmap excluded */
+   FreqDomainAlloc freqAlloc;
+   TimeDomainAlloc timeAlloc;
+   uint16_t        rowIndex;
+   uint8_t         mcs;
+   uint8_t         harqProcId;   /* HARQ Process ID */
+   bool            puschHopFlag;
+   bool            freqHopFlag;
+   uint8_t         ndi;    /* NDI */
+   uint8_t         rv;     /* Redundancy Version */
+   uint8_t         tpcCmd;
+   bool            sUlCfgd;
+}Format0_0;
+
+typedef struct format0_1
+{
+/* TBD */
+
+}Format0_1;
+
+typedef struct format1_0
+{
+/* TBD */
+
+}Format1_0;
+
+typedef struct format1_1
+{
+/* TBD */
+}Format1_1;
+
+typedef struct dciInfo
+{
+   uint16_t      cellId;   
+   uint16_t      crnti;          /* CRNI */
+   SlotIndInfo   slotIndInfo;    /* Slot Info: sfn, slot number */
+   BwpCfg        bwpCfg;         /* BWP Cfg */
+   CoresetCfg    coresetCfg;     /* Coreset1 Cfg */
+   FormatType    formatType;     /* DCI Format */
+   union
+   {
+      Format0_0  format0_0;      /* Format 0_0 */
+      Format0_1  format0_1;      /* Format 0_1 */
+      Format1_0  format1_0;      /* Format 1_0 */
+      Format1_1  format1_1;      /* Format 1_1 */
+   }format;
+   DlDCI    dciInfo;
+}DciInfo;
+
+
 typedef struct dlSchedInfo
 {
    uint16_t cellId;  /* Cell Id */
@@ -696,6 +773,10 @@ typedef struct dlSchedInfo
 
    /* Allocation from MSG4 */
    Msg4Alloc *msg4Alloc;
+
+   /* UL grant in response to BSR */
+   DciInfo    *ulGrant;
+
 }DlSchedInfo;
 
 typedef struct tbInfo
@@ -1121,6 +1202,30 @@ typedef struct schUeCfgRsp
    SchFailureCause cause;
 }SchUeCfgRsp;
 
+typedef struct dataVolInfo
+{
+   uint8_t  lcgId;
+   uint32_t dataVol;
+}DataVolInfo;
+
+typedef struct ulBufferStatusRptInd
+{
+   uint16_t    cellId;
+   uint16_t    crnti;
+   BsrType     bsrType;
+   uint8_t     numLcg;
+   DataVolInfo dataVolInfo[MAX_NUM_LOGICAL_CHANNEL_GROUPS];
+}UlBufferStatusRptInd;
+
+typedef struct srUciIndInfo
+{
+   uint16_t    cellId;
+   uint16_t    crnti;
+   SlotIndInfo slotInd;
+   uint8_t     numSrBits;
+   uint8_t     srPayload[MAX_SR_BITS_IN_BYTES];
+}SrUciIndInfo;
+
 /* function pointers */
 
 typedef uint8_t (*SchCellCfgCfmFunc)    ARGS((
@@ -1167,6 +1272,16 @@ typedef uint8_t (*MacSchSlotIndFunc) ARGS((
          Pst         *pst,          /* Post structure */
         SlotIndInfo *slotInd));    /* Slot Info */
 
+typedef uint8_t (*MacSchBsrFunc)       ARGS((
+   Pst                  *pst,
+   UlBufferStatusRptInd *bsrInd
+));
+
+typedef uint8_t (*MacSchSrUciIndFunc) ARGS(( 
+        Pst         *pst,         /* Post structure */
+        SrUciIndInfo  *uciInd));    /* UCI IND Info */
+
+
 /* function declarations */
 uint8_t packMacSchSlotInd(Pst *pst, SlotIndInfo *slotInd);
 uint8_t packSchMacDlAlloc(Pst *pst, DlSchedInfo  *dlSchedInfo);
@@ -1181,18 +1296,22 @@ uint8_t schActvInit(Ent entity, Inst instId, Region region, Reason reason);
 uint8_t SchSendCfgCfm(Pst *pst, RgMngmt *cfm);
 uint8_t MacProcUlSchInfo(Pst *pst, UlSchedInfo *ulSchedInfo);
 uint8_t packMacSchRachInd(Pst *pst, RachIndInfo *rachInd);
-uint8_t macSchRachInd(Pst *pst, RachIndInfo *rachInd);
+uint8_t MacSchRachInd(Pst *pst, RachIndInfo *rachInd);
 uint8_t packMacSchCrcInd(Pst *pst, CrcIndInfo *crcInd);
-uint8_t macSchCrcInd(Pst *pst, CrcIndInfo *crcInd);
+uint8_t MacSchCrcInd(Pst *pst, CrcIndInfo *crcInd);
 uint8_t packMacSchDlRlcBoInfo(Pst *pst, DlRlcBOInfo *dlBoInfo);
-uint8_t macSchDlRlcBoInfo(Pst *pst, DlRlcBOInfo *dlBoInfo);
+uint8_t MacSchDlRlcBoInfo(Pst *pst, DlRlcBOInfo *dlBoInfo);
 uint8_t packMacSchUeCreateReq(Pst *pst, SchUeCfg *ueCfgToSch);
-uint8_t macSchUeCreateReq(Pst *pst, SchUeCfg *ueCfgToSch);
+uint8_t MacSchUeCreateReq(Pst *pst, SchUeCfg *ueCfgToSch);
 uint8_t packSchUeCfgRsp(Pst *pst, SchUeCfgRsp *cfgRsp);
 uint8_t MacProcSchUeCfgRsp(Pst *pst, SchUeCfgRsp *cfgRsp);
-uint8_t macSchSlotInd ARGS((Pst * pst, SlotIndInfo * slotInd));
+uint8_t MacSchSlotInd ARGS((Pst * pst, SlotIndInfo * slotInd));
 uint8_t packMacSchSlotInd(Pst * pst, SlotIndInfo * slotInd);
 uint8_t unpackMacSchSlotInd(MacSchSlotIndFunc func, Pst *pst, Buffer  *mBuf);
+uint8_t packMacSchBsr(Pst *pst, UlBufferStatusRptInd *bsrInd);
+uint8_t MacSchBsr(Pst *pst, UlBufferStatusRptInd *bsrInd);
+uint8_t packMacSchSrUciInd(Pst *pst, SrUciIndInfo *uciInd);
+uint8_t MacSchSrUciInd(Pst *pst, SrUciIndInfo *uciInd);
 
 /**********************************************************************
   End of file
index a40da04..c4a796d 100755 (executable)
@@ -577,22 +577,9 @@ Buffer *mBuf
 *  @return   S16
 *      -# ROK
 **/
-#ifdef ANSI
-PUBLIC S16 packRcvdUlData
-(
-Pst* pst,
-SuId suId,
-RlcMacData  *ulData
-)
-#else
-PUBLIC S16 packRcvdUlData(pst, suId, ulData)
-Pst* pst;
-SuId suId;
-RlcMacData  *ulData;
-#endif
+uint8_t packRlcUlData(Pst* pst, RlcMacData  *ulData)
 {
    Buffer *mBuf = NULLP;
-   TRC3(packRcvdUlData)
 
    if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
 #if (ERRCLASS & ERRCLS_ADD_RES)      
@@ -633,17 +620,6 @@ RlcMacData  *ulData;
       }
       ulData = NULLP;
    }
-   if (SPkS16(suId, mBuf) != ROK) {
-#if (ERRCLASS & ERRCLS_ADD_RES)      
-      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
-          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
-          (ErrVal)ERGU037, (ErrVal)0, "Packing failed");
-#endif      
-      SPutStaticBuffer(pst->region, pst->pool, (Data *)ulData, sizeof(RlcMacData),0);
-      SPutMsg(mBuf);
-      RETVALUE(RFAILED);
-   }
-
    pst->event = (Event) EVTRLCULDAT;
    RETVALUE(SPstTsk(pst,mBuf));
 }
@@ -663,28 +639,12 @@ RlcMacData  *ulData;
 *  @return   S16
 *      -# ROK
 **/
-PUBLIC S16 unpackRcvdUlData
-(
-RlcMacUlData func,
-Pst *pst,
-Buffer *mBuf
-)
+uint8_t unpackRcvdUlData(RlcMacUlDataFunc func, Pst *pst, Buffer *mBuf)
 {
-   SuId suId;
    RlcMacData *ulData;
    
    TRC3(unpackRcvdUlData)
 
-   if (SUnpkS16(&suId, mBuf) != ROK) {
-#if (ERRCLASS & ERRCLS_ADD_RES)      
-      SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
-          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
-          (ErrVal)ERGU039, (ErrVal)0, "UnPacking failed");
-#endif      
-      SPutMsg(mBuf);
-      RETVALUE(RFAILED);
-   }
-
    if (pst->selector == ODU_SELECTOR_LWLC)
    {
       CMCHKUNPK(cmUnpkPtr,(PTR *) &ulData, mBuf);
@@ -714,7 +674,7 @@ Buffer *mBuf
       }
    }
    SPutMsg(mBuf);
-   RETVALUE((*func)(pst, suId, ulData));
+   RETVALUE((*func)(pst, ulData));
 }
 
 
@@ -2634,21 +2594,21 @@ Buffer *mBuf;
 
    TRC3(packRlcMacDataInfo);
 
-   for (i=param->nmbPdu-1; i >= 0; i--)
+   for (i=param->numPdu-1; i >= 0; i--)
    {
       msgLen = 0;
-      if (SFndLenMsg(param->pduInfo[i].pduBuf, &msgLen) != ROK)
-         RETVALUE(RFAILED);
-      if (SCatMsg(mBuf, param->pduInfo[i].pduBuf, M1M2) != ROK)
-          RETVALUE(RFAILED);      
+      //if (SFndLenMsg(param->pduInfo[i].pduBuf, &msgLen) != ROK)
+      //   RETVALUE(RFAILED);
+      //if (SCatMsg(mBuf, param->pduInfo[i].pduBuf, M1M2) != ROK)
+      //    RETVALUE(RFAILED);      
       CMCHKPK(cmPkMsgLen, msgLen, mBuf);
       CMCHKPK(cmPkLteLcId, param->pduInfo[i].lcId, mBuf);
       CMCHKPK(cmPkBool, param->pduInfo[i].commCh, mBuf);
    }
-   CMCHKPK(SPkU8, param->nmbPdu, mBuf);
+   CMCHKPK(SPkU8, param->numPdu, mBuf);
    CMCHKPK(cmPkLteRnti, param->rnti, mBuf);
    CMCHKPK(cmPkLteCellId, param->cellId, mBuf);
-   CMCHKPK(cmPkLteTimingInfo, &param->timeToTx, mBuf);
+   //CMCHKPK(cmPkLteTimingInfo, &param->timeToTx, mBuf);
    RETVALUE(ROK);
 }
 
@@ -2686,11 +2646,11 @@ Buffer *mBuf;
 
    TRC3(unpackRlcMacDataInfo);
    
-   CMCHKUNPK(cmUnpkLteTimingInfo, &param->timeToTx, mBuf);
+   //CMCHKUNPK(cmUnpkLteTimingInfo, &param->timeToTx, mBuf);
    CMCHKUNPK(cmUnpkLteCellId, &param->cellId, mBuf);
    CMCHKUNPK(cmUnpkLteRnti, &param->rnti, mBuf);
-   CMCHKUNPK(SUnpkU8, &param->nmbPdu, mBuf);
-   for (i=0; i<param->nmbPdu; i++) 
+   CMCHKUNPK(SUnpkU8, &param->numPdu, mBuf);
+   for (i=0; i<param->numPdu; i++) 
    {
       MsgLen totalMsgLen;
 
@@ -2699,8 +2659,8 @@ Buffer *mBuf;
       CMCHKUNPK(cmUnpkMsgLen, &param->pduInfo[i].pduLen, mBuf);
       if (SFndLenMsg(mBuf, &totalMsgLen) != ROK)
          RETVALUE(RFAILED);
-      if (SSegMsg(mBuf, totalMsgLen-param->pduInfo[i].pduLen, &param->pduInfo[i].pduBuf) != ROK)
-         RETVALUE(RFAILED);
+      //if (SSegMsg(mBuf, totalMsgLen-param->pduInfo[i].pduLen, &param->pduInfo[i].pduBuf) != ROK)
+      //   RETVALUE(RFAILED);
    }
    RETVALUE(ROK);
 }
index 0338cee..2283215 100755 (executable)
@@ -429,15 +429,15 @@ typedef struct rlcMacPduInfo
    Bool         commCh;   /*!<Common or Dedicated Channel */
    CmLteLcId    lcId;     /*!< Logical channel ID */
    MsgLen       pduLen;   /*!< PDU Length */
-   Buffer       *pduBuf;  /*!< RLC PDU buffer */
+   uint8_t      *pduBuf;  /*!< RLC PDU buffer */
 }RlcMacPduInfo;
 
 typedef struct rlcMacData
 {  
-   CmLteTimingInfo timeToTx;  /*!< Air interface time */
    CmLteCellId     cellId;       /*!< CELL ID */
    CmLteRnti       rnti;         /*!< Temporary CRNTI */ 
-   U8              nmbPdu;       /*!< Number of RLC PDUs */
+   SlotIndInfo     slotInfo;     /*!< Timing info */
+   U8              numPdu;       /*!< Number of RLC PDUs */
    RlcMacPduInfo   pduInfo[RGU_MAX_PDU];
 }RlcMacData;
 
@@ -491,9 +491,8 @@ typedef S16 (*RguDDatInd) ARGS((
    SuId                 suId,
    RguDDatIndInfo       *datInd));
 
-typedef S16 (*RlcMacUlData) ARGS((
+typedef uint8_t (*RlcMacUlDataFunc) ARGS((
    Pst*                 pst,
-   SuId                 suId,
    RlcMacData           *ulData));
 /** @brief Status Response from RLC to MAC to 
  * inform the BO report for common channels */
@@ -708,9 +707,8 @@ EXTERN S16 RlcMacSendDlData ARGS((
 /** @brief Handler toprocess UL data from MAC and
  * forwarding to appropriate common/dedicated
  * channel's handler */
-EXTERN S16 RlcMacProcUlData ARGS((
+EXTERN uint8_t RlcProcUlData ARGS((
    Pst*           pst,
-   SuId           suId,
    RlcMacData   *ulData
 ));
 
@@ -880,15 +878,14 @@ EXTERN S16 cmUnpkRguCDatInd ARGS((
 ));
 /** @brief Data Indication from MAC to RLC to 
  * forward the data received for dedicated channels*/
-EXTERN S16 packRcvdUlData ARGS((
+EXTERN uint8_t packRlcUlData ARGS((
    Pst*                 pst,
-   SuId                 suId,
    RlcMacData  *    ulData
 ));
 /** @brief Data Indication from MAC to RLC to 
  * forward the data received for dedicated channels*/
-EXTERN S16 unpackRcvdUlData ARGS((
-   RlcMacUlData         func,
+EXTERN uint8_t unpackRcvdUlData ARGS((
+   RlcMacUlDataFunc     func,
    Pst*                 pst,
    Buffer               *mBuf
 ));
index c7f17e6..0a719af 100644 (file)
@@ -27,7 +27,6 @@
 #include "E2AP-PDU.h"
 #include<ProtocolIE-Field.h>
 #include "F1AP-PDU.h"
-#include "du_f1ap_msg_hdl.h"
 #include "du_e2ap_msg_hdl.h"
 #include "du_app_mac_inf.h"
 #include "du_app_rlc_inf.h"
@@ -35,6 +34,7 @@
 #include "du_mgr.h"
 #include "odu_common_codec.h"
 #include "du_cell_mgr.h"
+#include "du_f1ap_msg_hdl.h"
 
 extern DuCfgParams duCfgParam;
 extern S16 duBuildAndSendMacCellCfg();
index 607d621..f90f851 100644 (file)
@@ -133,7 +133,7 @@ S16 readMacCfg()
    /* DL carrier configuration */
    duCfgParam.macCellCfg.dlCarrCfg.pres = TRUE;
    duCfgParam.macCellCfg.dlCarrCfg.bw = BANDWIDTH;
-   duCfgParam.macCellCfg.dlCarrCfg.freq = NR_ARFCN;
+   duCfgParam.macCellCfg.dlCarrCfg.freq = NR_DL_ARFCN;
    duCfgParam.macCellCfg.dlCarrCfg.k0[0] = 1;
    duCfgParam.macCellCfg.dlCarrCfg.k0[1] = 1;
    duCfgParam.macCellCfg.dlCarrCfg.k0[2] = 1;
@@ -148,8 +148,8 @@ S16 readMacCfg()
 
    /* UL Carrier configuration */
    duCfgParam.macCellCfg.ulCarrCfg.pres = TRUE;
-   duCfgParam.macCellCfg.ulCarrCfg.bw = SUL_ARFCN;
-   duCfgParam.macCellCfg.ulCarrCfg.freq = NR_ARFCN;
+   duCfgParam.macCellCfg.ulCarrCfg.bw = BANDWIDTH;
+   duCfgParam.macCellCfg.ulCarrCfg.freq = NR_UL_ARFCN;
    duCfgParam.macCellCfg.ulCarrCfg.k0[0] = 1;
    duCfgParam.macCellCfg.ulCarrCfg.k0[1] = 1;
    duCfgParam.macCellCfg.ulCarrCfg.k0[2] = 1;
@@ -624,7 +624,7 @@ S16 readCfg()
       duCfgParam.srvdCellLst[i].duCellInfo.tac = DU_TAC;
       duCfgParam.srvdCellLst[i].duCellInfo.epsTac = DU_TAC; //to check and fill
       /* NR Mode info */
-      duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.nrArfcn = NR_ARFCN;
+      duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.nrArfcn = NR_UL_ARFCN;
       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulArfcn = SUL_ARFCN;
       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulTxBw.nrScs = SCS_120;
       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulTxBw.nrb = NRB_66;
@@ -653,7 +653,7 @@ S16 readCfg()
            duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.freqBand[j].sulBand[k] = SUL_BAND;
         }
       }
-      duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.nrArfcn = NR_ARFCN;
+      duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.nrArfcn = NR_DL_ARFCN;
       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulArfcn = SUL_ARFCN;
       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulTxBw.nrScs = SCS_120;
       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulTxBw.nrb = NRB_66;
index 0fe2e1f..db3af6d 100644 (file)
@@ -43,7 +43,8 @@
 #define PLMN_MNC1 8
 #define PLMN_MNC2 0
 #define PLMN_SIZE 3
-#define NR_ARFCN  2079427
+#define NR_DL_ARFCN 385627
+#define NR_UL_ARFCN 386687
 #define SUL_ARFCN 100
 #define NR_FREQ_BAND 257
 #define NR_FREQ_BAND_IND 78
@@ -75,6 +76,8 @@
 #define BANDWIDTH 20
 #define DMRS_TYPE_A_POS 2
 #define NUM_SYMBOLS_PER_SLOT 14       /* Number of symbols within a slot */
+#define CORESET0_END_PRB   48
+#define CORESET1_NUM_PRB   24
 
 /* MACRO defines for PRACH Configuration */
 #define PRACH_CONFIG_IDX   88
 #define PDCCH_SRCH_SPC_TWO_AGG_LVL8_CANDIDATE 2   /* Num of candidate at aggregation level 8 */
 #define PDCCH_SRCH_SPC_TWO_AGG_LVL16_CANDIDATE 1  /* Num of candidate at aggregation level 16 */
 #define PDCCH_SRCH_SPC_TWO_UE_SPEC_DCI_FORMAT  0  /* format 0-0 and 1-0 */
-#define PDCCH_FREQ_DOM_RSRC 255          /* Frequency domain Resource Value */
 #define PDCCH_SYMBOL_WITHIN_SLOT 128     /* Symbol within Slot Value */
 
 
 #define SIB1_VALUE_TAG 10
 
-/* MACRCO Ddefine for PDSCH Configuration */
+/* MACRO Ddefine for PDSCH Configuration */
 #define PDSCH_K0  0
 #define PDSCH_START_SYMBOL  2
 #define PDSCH_LENGTH_SYMBOL 12
index 165bace..054e390 100644 (file)
@@ -24,6 +24,7 @@
 #include "lrg.x"
 #include "du_app_mac_inf.h"
 #include "du_cfg.h"
+#include "du_app_rlc_inf.h"
 #include "E2AP-PDU.h"
 #include "du_mgr_main.h"
 #include "du_utils.h"
@@ -69,6 +70,7 @@
 #include "ProtocolExtensionField.h"
 #include "F1AP-PDU.h"
 #include "odu_common_codec.h"
+#include "du_mgr.h"
 #include "du_f1ap_msg_hdl.h"
 
 S16 procGNBDUCfgUpdAck(F1AP_PDU_t *f1apMsg);
@@ -1176,7 +1178,7 @@ uint8_t BuildAndSendF1SetupReq()
 
                ret=ROK;
       break;
-   }while(1);
+   }while(true);
 
        FreeF1SetupReq(f1apMsg);
        
@@ -1220,7 +1222,7 @@ uint8_t BuildAndSendDUConfigUpdate()
    uint8_t ret= RFAILED;
    uint8_t i;
 
-       while(1)
+       while(true)
        {
            DU_LOG("\nF1AP : Building DU config update\n");
                 /* Allocate the memory for F1DuCfg */
@@ -1933,6 +1935,12 @@ void FreeULRRCMessageTransfer( F1AP_PDU_t *f1apMsg)
                  {
                      if(ulRRCMsg->protocolIEs.list.array[idx1] != NULLP)
                      {
+                        if(ulRRCMsg->protocolIEs.list.array[idx1]->value.present ==
+                           ULRRCMessageTransferIEs__value_PR_RRCContainer)
+                        {
+                           DU_FREE(ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.buf,
+                              ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.size);
+                        }
                          DU_FREE(ulRRCMsg->protocolIEs.list.array[idx1],sizeof(ULRRCMessageTransferIEs_t));
                      }
                  }
@@ -1960,124 +1968,135 @@ void FreeULRRCMessageTransfer( F1AP_PDU_t *f1apMsg)
  *         RFAILED - failure
  *
  * ****************************************************************/
-uint8_t BuildAndSendULRRCMessageTransfer()
+uint8_t BuildAndSendULRRCMessageTransfer(DuUeCb  ueCb, uint8_t lcId, \
+    uint16_t msgLen, uint8_t *rrcMsg)
 {
-       uint8_t   elementCnt;
-       uint8_t   idx1;
-       uint8_t   idx;
-       F1AP_PDU_t                              *f1apMsg = NULL;
+   uint8_t   elementCnt;
+   uint8_t   idx1;
+   uint8_t   idx;
+   F1AP_PDU_t                  *f1apMsg = NULL;
    ULRRCMessageTransfer_t      *ulRRCMsg;
-       asn_enc_rval_t                          encRetVal;        /* Encoder return value */
+   asn_enc_rval_t              encRetVal;        /* Encoder return value */
    uint8_t ret =RFAILED;
-       while(1)
-       {
-          DU_LOG("\n F1AP : Building UL RRC Message Transfer Message\n");
+   while(true)
+   {
+      DU_LOG("\n F1AP : Building UL RRC Message Transfer Message\n");
 
-          DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
-          if(f1apMsg == NULLP)
-          {
-                  DU_LOG(" F1AP : Memory allocation for F1AP-PDU failed");
-                       break;
-          }
+      DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
+      if(f1apMsg == NULLP)
+      {
+        DU_LOG(" F1AP : Memory allocation for F1AP-PDU failed");
+        break;
+      }
 
-          f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
-       DU_ALLOC(f1apMsg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
-          if(f1apMsg->choice.initiatingMessage == NULLP)
-          {
-                  DU_LOG(" F1AP : Memory allocation for        F1AP-PDU failed");
-                       break;
-          }
-       f1apMsg->choice.initiatingMessage->procedureCode = \
-                                                                                               ProcedureCode_id_ULRRCMessageTransfer;
-          f1apMsg->choice.initiatingMessage->criticality = Criticality_ignore;
-          f1apMsg->choice.initiatingMessage->value.present = \
-                                                               InitiatingMessage__value_PR_ULRRCMessageTransfer;
-          ulRRCMsg =
-                   &f1apMsg->choice.initiatingMessage->value.choice.ULRRCMessageTransfer;
-          elementCnt = 3;
-       ulRRCMsg->protocolIEs.list.count = elementCnt;
-          ulRRCMsg->protocolIEs.list.size = \
-                                                                       elementCnt * sizeof(ULRRCMessageTransferIEs_t *);
-
-           /* Initialize the F1Setup members */
-          DU_ALLOC(ulRRCMsg->protocolIEs.list.array, ulRRCMsg->protocolIEs.list.size);
-          if(ulRRCMsg->protocolIEs.list.array == NULLP)
-          {
-                   DU_LOG(" F1AP : Memory allocation for UL RRC MessageTransferIEs failed");
-                        break;
-       }
-          for(idx=0; idx<elementCnt; idx++)
-          {
-                  DU_ALLOC(ulRRCMsg->protocolIEs.list.array[idx],sizeof(ULRRCMessageTransferIEs_t));
-               if(ulRRCMsg->protocolIEs.list.array[idx] == NULLP)
-                  {
-                          break;
-                  }
-          }
+      f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
+      DU_ALLOC(f1apMsg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
+      if(f1apMsg->choice.initiatingMessage == NULLP)
+      {
+        DU_LOG(" F1AP : Memory allocation for  F1AP-PDU failed");
+        break;
+      }
+      f1apMsg->choice.initiatingMessage->procedureCode = ProcedureCode_id_ULRRCMessageTransfer;
+      f1apMsg->choice.initiatingMessage->criticality = Criticality_ignore;
+      f1apMsg->choice.initiatingMessage->value.present = \
+       InitiatingMessage__value_PR_ULRRCMessageTransfer;
+      ulRRCMsg =
+        &f1apMsg->choice.initiatingMessage->value.choice.ULRRCMessageTransfer;
+      elementCnt = 4;
+      ulRRCMsg->protocolIEs.list.count = elementCnt;
+      ulRRCMsg->protocolIEs.list.size = \
+       elementCnt * sizeof(ULRRCMessageTransferIEs_t *);
 
-          idx1 = 0;
+      /* Initialize the F1Setup members */
+      DU_ALLOC(ulRRCMsg->protocolIEs.list.array, ulRRCMsg->protocolIEs.list.size);
+      if(ulRRCMsg->protocolIEs.list.array == NULLP)
+      {
+        DU_LOG(" F1AP : Memory allocation for UL RRC MessageTransferIEs failed");
+        break;
+      }
+      for(idx=0; idx<elementCnt; idx++)
+      {
+        DU_ALLOC(ulRRCMsg->protocolIEs.list.array[idx],sizeof(ULRRCMessageTransferIEs_t));
+        if(ulRRCMsg->protocolIEs.list.array[idx] == NULLP)
+        {
+           break;
+        }
+      }
 
-           /*GNB CU UE F1AP ID*/
-          ulRRCMsg->protocolIEs.list.array[idx1]->id   = \
-                                                                                ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
-          ulRRCMsg->protocolIEs.list.array[idx1]->criticality  =       Criticality_reject;
-          ulRRCMsg->protocolIEs.list.array[idx1]->value.present = \
-                               ULRRCMessageTransferIEs__value_PR_GNB_CU_UE_F1AP_ID;
-       ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.GNB_CU_UE_F1AP_ID = CU_ID;
-
-          /*GNB DU UE F1AP ID*/
-          idx1++;
-       ulRRCMsg->protocolIEs.list.array[idx1]->id      = \
-                                                                                ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
-          ulRRCMsg->protocolIEs.list.array[idx1]->criticality  =       Criticality_reject;
-          ulRRCMsg->protocolIEs.list.array[idx1]->value.present = \
-                               ULRRCMessageTransferIEs__value_PR_GNB_DU_UE_F1AP_ID;
-          ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.GNB_DU_UE_F1AP_ID = DU_ID;
-
-          /*SRBID*/
-          idx1++;
-          ulRRCMsg->protocolIEs.list.array[idx1]->id   = \
-                                                                                                                ProtocolIE_ID_id_SRBID;
-          ulRRCMsg->protocolIEs.list.array[idx1]->criticality  =       Criticality_reject;
-          ulRRCMsg->protocolIEs.list.array[idx1]->value.present = \
-                                                               ULRRCMessageTransferIEs__value_PR_SRBID;
-          ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.SRBID = UL_SRBID;
-
-          /*RRCContainer*/
-          //YET TO FILL
-
-          xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
-
-          /* Encode the F1SetupRequest type as APER */
-          cmMemset((uint8_t *)encBuf, 0, ENC_BUF_MAX_LEN);
-          encBufSize = 0;
-          encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,\
-                       encBuf);
-          /* Encode results */
-          if(encRetVal.encoded == ENCODE_FAIL)
-          {
-                    DU_LOG( "\n F1AP : Could not encode ULRRCMessageTransfer structure (at %s)\n",\
-                               encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
-                         break;
-          }
-          else
-          {
-                   DU_LOG("\n F1AP : Created APER encoded buffer for ULRRCMessageTransfer\n");
-                   for(int i=0; i< encBufSize; i++)
-                   {
-                            printf("%x",encBuf[i]);
-                   }
-          }
+      idx1 = 0;
+
+      /*GNB CU UE F1AP ID*/
+      ulRRCMsg->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
+      ulRRCMsg->protocolIEs.list.array[idx1]->criticality = Criticality_reject;
+      ulRRCMsg->protocolIEs.list.array[idx1]->value.present = \
+       ULRRCMessageTransferIEs__value_PR_GNB_CU_UE_F1AP_ID;
+      ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.GNB_CU_UE_F1AP_ID = ueCb.gnbCuUeF1apId;
+
+      /*GNB DU UE F1AP ID*/
+      idx1++;
+      ulRRCMsg->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
+      ulRRCMsg->protocolIEs.list.array[idx1]->criticality = Criticality_reject;
+      ulRRCMsg->protocolIEs.list.array[idx1]->value.present = \
+         ULRRCMessageTransferIEs__value_PR_GNB_DU_UE_F1AP_ID;
+      ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.GNB_DU_UE_F1AP_ID = ueCb.gnbDuUeF1apId;
+
+      /*SRBID*/
+      idx1++;
+      ulRRCMsg->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_SRBID;
+      ulRRCMsg->protocolIEs.list.array[idx1]->criticality = Criticality_reject;
+      ulRRCMsg->protocolIEs.list.array[idx1]->value.present = \
+       ULRRCMessageTransferIEs__value_PR_SRBID;
+      ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.SRBID = lcId;
+
+      /*RRCContainer*/
+      idx1++;
+      ulRRCMsg->protocolIEs.list.array[idx1]->id  = ProtocolIE_ID_id_RRCContainer;
+      ulRRCMsg->protocolIEs.list.array[idx1]->criticality = Criticality_reject;
+      ulRRCMsg->protocolIEs.list.array[idx1]->value.present = \
+         ULRRCMessageTransferIEs__value_PR_RRCContainer;
+      ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.size = msgLen;
+      DU_ALLOC(ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.buf,
+         ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.size)
+      if(!ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.buf)
+      {
+         DU_LOG(" F1AP : Memory allocation for BuildAndSendULRRCMessageTransfer failed");
+         break;
+      }
+      memcpy(ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.buf, \
+         rrcMsg, ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.size);
 
-          /* Sending  msg  */
-          if(SendF1APMsg(DU_APP_MEM_REGION,DU_POOL)    !=      ROK)
-          {
-                   DU_LOG("\n F1AP : Sending   UL RRC Message Transfer Failed");
-                        break;
-               }
+      xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
+
+      /* Encode the F1SetupRequest type as APER */
+      cmMemset((uint8_t *)encBuf, 0, ENC_BUF_MAX_LEN);
+      encBufSize = 0;
+      encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,\
+           encBuf);
+      /* Encode results */
+      if(encRetVal.encoded == ENCODE_FAIL)
+      {
+        DU_LOG( "\n F1AP : Could not encode ULRRCMessageTransfer structure (at %s)\n",\
+              encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
+        break;
+      }
+      else
+      {
+        DU_LOG("\n F1AP : Created APER encoded buffer for ULRRCMessageTransfer\n");
+        for(int i=0; i< encBufSize; i++)
+        {
+           printf("%x",encBuf[i]);
+        }
+      }
+
+      /* Sending  msg  */
+      if(SendF1APMsg(DU_APP_MEM_REGION,DU_POOL)        !=      ROK)
+      {
+        DU_LOG("\n F1AP : Sending      UL RRC Message Transfer Failed");
+        break;
+      }
       ret = ROK;
-               break;
-       }
+      break;
+   }
    FreeULRRCMessageTransfer(f1apMsg);
 
        return ret;
@@ -2509,10 +2528,11 @@ struct PDCCH_Config__controlResourceSetToAddModList *controlRSetList
 {
    uint8_t idx;
    uint8_t elementCnt;
-       uint8_t numBytes;
-       uint8_t byteIdx;
-       uint8_t bitsUnused;
+   uint8_t numBytes, bitsUnused;
    struct ControlResourceSet *controlRSet;
+   uint8_t freqDomainResource[FREQ_DOM_RSRC_SIZE] = {0};
+   uint8_t coreset0EndPrb, coreset1StartPrb, coreset1NumPrb;
+
 
    elementCnt = 1;
    controlRSetList->list.count = elementCnt;
@@ -2529,7 +2549,7 @@ struct PDCCH_Config__controlResourceSetToAddModList *controlRSetList
 
    for(idx = 0; idx < elementCnt; idx++)
    {
-          controlRSetList->list.array[idx] = NULLP;
+      controlRSetList->list.array[idx] = NULLP;
       DU_ALLOC(controlRSetList->list.array[idx], sizeof(struct ControlResourceSet));
       if(!controlRSetList->list.array[idx])
       {
@@ -2548,7 +2568,7 @@ struct PDCCH_Config__controlResourceSetToAddModList *controlRSetList
         * 3 LSBs unsued
         * Bit string stored ff0000000000
         */
-       numBytes = 6;
+   numBytes = 6;
    bitsUnused = 3;
    controlRSet->frequencyDomainResources.size = numBytes * sizeof(uint8_t);
 
@@ -2560,13 +2580,15 @@ struct PDCCH_Config__controlResourceSetToAddModList *controlRSetList
           DU_LOG("\nF1AP : Memory allocation failed in BuildControlRSetToAddModList");
                return RFAILED;
    }
-   byteIdx = 0;
-       controlRSet->frequencyDomainResources.buf[byteIdx] = PDCCH_FREQ_DOM_RSRC; /* setting 8 MSBs i.e. ff */
-   for(byteIdx = 1; byteIdx < numBytes; byteIdx++)
-       {
-          controlRSet->frequencyDomainResources.buf[byteIdx] = 0;
-       }
-       controlRSet->frequencyDomainResources.bits_unused = bitsUnused;
+
+   memset(controlRSet->frequencyDomainResources.buf, 0, FREQ_DOM_RSRC_SIZE);
+   coreset0EndPrb = CORESET0_END_PRB;
+   coreset1StartPrb = coreset0EndPrb + 6;
+   coreset1NumPrb = CORESET1_NUM_PRB;
+   /* calculate the PRBs */
+   schAllocFreqDomRscType0(((coreset1StartPrb)/6), (coreset1NumPrb/6), freqDomainResource);
+   memcpy(controlRSet->frequencyDomainResources.buf, freqDomainResource, FREQ_DOM_RSRC_SIZE);
+   controlRSet->frequencyDomainResources.bits_unused = bitsUnused;
 
    controlRSet->duration = PDCCH_CTRL_RSRC_SET_ONE_DURATION;
    controlRSet->cce_REG_MappingType.present = \
@@ -4880,7 +4902,7 @@ uint8_t BuildDuToCuRrcContainer(DUtoCURRCContainer_t *duToCuRrcContainer)
        asn_enc_rval_t        encRetVal;
        uint8_t               ret = RFAILED;
 
-       while(1)
+       while(true)
        {
                cellGrpCfg.cellGroupId = CELL_GRP_ID;
 
@@ -4996,7 +5018,7 @@ uint8_t BuildDuToCuRrcContainer(DUtoCURRCContainer_t *duToCuRrcContainer)
  *
  * ****************************************************************/
 uint8_t BuildAndSendInitialRrcMsgTransfer(uint32_t gnbDuUeF1apId, uint16_t crnti,
-               uint8_t *rrcContainer)
+       uint16_t rrcContSize, uint8_t *rrcContainer)
 {
    uint8_t   ret;
        uint8_t   elementCnt;
@@ -5007,7 +5029,7 @@ uint8_t BuildAndSendInitialRrcMsgTransfer(uint32_t gnbDuUeF1apId, uint16_t crnti
        InitialULRRCMessageTransfer_t *initULRRCMsg=NULLP;
    asn_enc_rval_t                encRetVal;
        bool  checkvar=false;
-       while(1)
+       while(true)
        {
             DU_LOG("\n F1AP : Building RRC Setup Request\n");
                  DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
@@ -5093,18 +5115,17 @@ uint8_t BuildAndSendInitialRrcMsgTransfer(uint32_t gnbDuUeF1apId, uint16_t crnti
                        initULRRCMsg->protocolIEs.list.array[idx1]->value.present =\
                                 InitialULRRCMessageTransferIEs__value_PR_RRCContainer;
                                                                
-                       initULRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.size =\
-                                                     strlen((const char*)rrcContainer);
-         DU_ALLOC(initULRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.buf,
-                                       initULRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.size)
+                       initULRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.size = rrcContSize;
+                       DU_ALLOC(initULRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.buf,
+                             initULRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.size)
                        if(!initULRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.buf)
                        {
-                     DU_LOG(" F1AP : Memory allocation for RRCSetupRequestMessageTransferIEs failed");
+                          DU_LOG(" F1AP : Memory allocation for RRCSetupRequestMessageTransferIEs failed");
                                break;
 
                        }
-         memcpy(initULRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.buf, rrcContainer,
-                                       initULRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.size);
+                       memcpy(initULRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.buf, rrcContainer,
+                             initULRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.size);
 
 
                        /*DUtoCURRCContainer*/
@@ -6050,7 +6071,7 @@ uint8_t BuildAndSendUESetReq()
        asn_enc_rval_t                                          encRetVal;        /* Encoder return value */
    uint8_t ret= RFAILED;
        uint8_t ret1;
-       while(1)
+       while(true)
        {
            DU_LOG("\n F1AP : Building UE Context Setup Request\n");
 
index 82cd5a9..d187043 100644 (file)
@@ -32,7 +32,10 @@ void F1APMsgHdlr(Buffer *mBuf);
 uint8_t procF1SetupRsp(F1AP_PDU_t *f1apMsg);
 uint8_t BuildAndSendF1SetupReq();
 uint8_t BuildAndSendDUConfigUpdate();
-uint8_t BuildAndSendInitialRrcMsgTransfer(uint32_t gnbDuUeF1apId, uint16_t crnti, uint8_t *rrcContainer);
+uint8_t BuildAndSendInitialRrcMsgTransfer(uint32_t gnbDuUeF1apId, uint16_t crnti, uint16_t rrcContSize, 
+          uint8_t *rrcContainer);
+uint8_t BuildAndSendULRRCMessageTransfer(DuUeCb  ueCb, uint8_t lcId,  uint16_t msgLen, uint8_t *rrcMsg);
+
 /**********************************************************************
          End of file
 **********************************************************************/
index 42c173d..881bd7e 100644 (file)
@@ -178,6 +178,11 @@ S16 duActvTsk(Pst *pst, Buffer *mBuf)
                     ret = unpackRlcUlUeCreateRsp(DuProcRlcUlUeCreateRsp, pst, mBuf);
                     break;
                  }
+              case EVENT_UL_RRC_MSG_TRANS_TO_DU:
+                 {
+                    ret = unpackRlcUlRrcMsgToDu(DuProcRlcUlRrcMsgTrans, pst, mBuf);
+                    break;
+                  }
               default:
                  {
                     DU_LOG("\nDU_APP : Invalid event %d received at duActvTsk from ENTKW", \
index 4e267e9..38c7ea4 100644 (file)
@@ -28,6 +28,7 @@
 #include "du_app_mac_inf.h"
 #include "du_app_rlc_inf.h"
 #include "du_cfg.h"
+#include "du_app_rlc_inf.h"
 #include "du_mgr.h"
 #include "du_sctp.h"
 #include "F1AP-PDU.h"
@@ -1822,6 +1823,34 @@ uint8_t duHandleUlCcchInd(Pst *pst, UlCcchIndInfo *ulCcchIndInfo)
    return (duProcUlCcchInd(ulCcchIndInfo));
 }
 
+/*******************************************************************
+ *
+ * @brief Process UL RRC Message from RLC
+ *
+ * @details
+ *
+ *    Function : DuProcRlcUlRrcMsgTrans
+ *
+ *    Functionality: Process UL RRC Message from RLC
+ *
+ * @params[in] Post structure
+ *             UL RRC Message Info
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t DuProcRlcUlRrcMsgTrans(Pst *pst, RlcUlRrcMsgInfo *ulRrcMsgInfo)
+{
+   DuUeCb   ueCb;
+   
+   ueCb = duCb.actvCellLst[ulRrcMsgInfo->cellId -1]->ueCb[ulRrcMsgInfo->ueIdx -1];
+   BuildAndSendULRRCMessageTransfer(ueCb, ulRrcMsgInfo->lcId, ulRrcMsgInfo->msgLen, \
+      ulRrcMsgInfo->rrcMsg);
+
+   DU_FREE_SHRABL_BUF(pst->region, pst->pool, ulRrcMsgInfo->rrcMsg, ulRrcMsgInfo->msgLen);
+   DU_FREE_SHRABL_BUF(pst->region, pst->pool, ulRrcMsgInfo, sizeof(RlcUlRrcMsgInfo));
+   return ROK;
+}
 
 /**********************************************************************
   End of file
index 4f547f2..d094005 100644 (file)
@@ -32,8 +32,8 @@
 #include "du_utils.h"
 #include<ProtocolIE-Field.h>
 #include "F1AP-PDU.h"
-#include "du_f1ap_msg_hdl.h"
 #include "du_mgr.h"
+#include "du_f1ap_msg_hdl.h"
 #include "du_ue_mgr.h"
 
 #ifdef EGTP_TEST
@@ -152,7 +152,7 @@ uint8_t duHdlRlcUlData(Pst *pst, KwuDatIndInfo* datInd, Buffer *mBuf)
  *         RFAILED - failure
  *
  * ****************************************************************/
-uint8_t duBuildAndSendDlCcchInd(uint16_t cellId, uint16_t crnti, \
+uint8_t duBuildAndSendDlCcchInd(uint16_t *cellId, uint16_t *crnti, \
       DlCcchMsgType msgType, uint8_t *dlCcchMsg, uint16_t dlCcchMsgSize)
 {
    uint8_t ret                  = ROK;
@@ -171,8 +171,8 @@ uint8_t duBuildAndSendDlCcchInd(uint16_t cellId, uint16_t crnti, \
       return RFAILED;
    }
 
-   dlCcchIndInfo->cellId = cellId;
-   dlCcchIndInfo->crnti = crnti;
+   dlCcchIndInfo->cellId = *cellId;
+   dlCcchIndInfo->crnti = *crnti;
    dlCcchIndInfo->msgType = msgType;
    dlCcchIndInfo->dlCcchMsgLen = dlCcchMsgSize;
 
@@ -294,7 +294,7 @@ uint8_t procDlRrcMsgTrans(F1AP_PDU_t *f1apMsg)
    }
    if(srbId == SRB_ID_1) //RRC connection setup
    {
-      ret = duBuildAndSendDlCcchInd(cellId, crnti, RRC_SETUP, dlCcchMsg, dlCcchMsgSize);
+      ret = duBuildAndSendDlCcchInd(&cellId, &crnti, RRC_SETUP, dlCcchMsg, dlCcchMsgSize);
       if(ret)
       {
         DU_LOG("\nDU_APP: Falied at duBuildAndSendDlCcchInd()");
@@ -371,14 +371,14 @@ uint8_t duProcUlCcchInd(UlCcchIndInfo *ulCcchIndInfo)
 
    duCb.numUe++;
 
-   ret = (BuildAndSendInitialRrcMsgTransfer(gnbDuUeF1apId, ulCcchIndInfo->crnti,
+   ret = (BuildAndSendInitialRrcMsgTransfer(gnbDuUeF1apId, ulCcchIndInfo->crnti, ulCcchIndInfo->ulCcchMsgLen,
            ulCcchIndInfo->ulCcchMsg));
    if(ret != ROK)
    {
       DU_LOG("\nDU_APP : BuildAndSendInitialRrcMsgTransfer failed");
    }
 
-   DU_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo->ulCcchMsg, strlen((const char*)ulCcchIndInfo->ulCcchMsg));
+   DU_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo->ulCcchMsg, ulCcchIndInfo->ulCcchMsgLen);
    DU_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo, sizeof(UlCcchIndInfo));
 
    return ret;
@@ -400,6 +400,9 @@ uint8_t duProcUlCcchInd(UlCcchIndInfo *ulCcchIndInfo)
 void fillInitDlBwp(InitialDlBwp *initDlBwp)
 {
    uint8_t idx = 0;
+   uint8_t freqDomainResource[FREQ_DOM_RSRC_SIZE] = {0};
+   uint8_t coreset0EndPrb, coreset1StartPrb, coreset1NumPrb;
+
 
    if(initDlBwp)
    {
@@ -415,8 +418,14 @@ void fillInitDlBwp(InitialDlBwp *initDlBwp)
               PDCCH_CTRL_RSRC_SET_ONE_ID;
            memset(initDlBwp->pdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, 0,\
               FREQ_DOM_RSRC_SIZE); 
-           initDlBwp->pdcchCfg.cRSetToAddModList[idx].freqDomainRsrc[idx] =\
-              PDCCH_FREQ_DOM_RSRC;
+           coreset0EndPrb = CORESET0_END_PRB;
+           coreset1StartPrb = coreset0EndPrb +6;
+           coreset1NumPrb = CORESET1_NUM_PRB;
+           /* calculate the PRBs */
+           schAllocFreqDomRscType0(((coreset1StartPrb)/6), (coreset1NumPrb/6), freqDomainResource);
+           memcpy(initDlBwp->pdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, freqDomainResource,
+              FREQ_DOM_RSRC_SIZE);
+
            initDlBwp->pdcchCfg.cRSetToAddModList[idx].duration = \
               PDCCH_CTRL_RSRC_SET_ONE_DURATION;
            initDlBwp->pdcchCfg.cRSetToAddModList[idx].cceRegMappingType = \
@@ -929,21 +938,21 @@ uint8_t duCreateUeCb(UeCcchCtxt *ueCcchCtxt, uint32_t gnbCuUeF1apId)
         GET_UE_IDX(ueCcchCtxt->crnti, ueIdx);
         DU_LOG("\nDU_APP: Filling UeCb for ueIdx [%d]", ueIdx);
 
-        duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId = ueCcchCtxt->gnbDuUeF1apId;
-        duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId = gnbCuUeF1apId;
-        duCb.actvCellLst[cellIdx]->ueCb[ueIdx].ueState       = UE_ACTIVE;
+        duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbDuUeF1apId = ueCcchCtxt->gnbDuUeF1apId;
+        duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbCuUeF1apId = gnbCuUeF1apId;
+        duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].ueState       = UE_ACTIVE;
 
         /* Filling Mac Ue Config */ 
-        memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx].macUeCfg, 0, sizeof(MacUeCfg));
+        memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg, 0, sizeof(MacUeCfg));
          ret = duBuildAndSendUeCreateReqToMac(ueCcchCtxt->cellId, ueIdx, ueCcchCtxt->crnti,\
-                &duCb.actvCellLst[cellIdx]->ueCb[ueIdx].macUeCfg);
+                &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg);
          if(ret)
             DU_LOG("\nDU_APP: Failed to send UE create request to MAC");
          
         /* Filling Rlc Ue Config */
-         memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx].rlcUeCfg, 0, sizeof(RlcUeCfg));
+         memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg, 0, sizeof(RlcUeCfg));
          ret = duBuildAndSendUeCreateReqToRlc(ueCcchCtxt->cellId, ueIdx, \
-                &duCb.actvCellLst[cellIdx]->ueCb[ueIdx].rlcUeCfg);
+                &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg);
          if(ret)
             DU_LOG("\nDU_APP: Failed to send UE create request to RLC");
 
@@ -989,8 +998,9 @@ uint8_t duBuildAndSendUeCreateReqToMac(uint16_t cellId, uint8_t ueIdx,\
    if(macUeCfg)
    {
       memset(macUeCfg, 0, sizeof(MacUeCfg));
-      memcpy(macUeCfg, &duCb.actvCellLst[cellId - 1]->ueCb[ueIdx].macUeCfg, sizeof(MacUeCfg));
+      memcpy(macUeCfg, &duCb.actvCellLst[cellId - 1]->ueCb[ueIdx -1].macUeCfg, sizeof(MacUeCfg));
       DU_LOG("\nDU_APP: Sending UE create request to MAC");
+
       /* Processing one Ue at a time to MAC */
       ret = (*packMacUeCreateReqOpts[pst.selector])(&pst, macUeCfg);
       if(ret)
diff --git a/src/phy_stub/l1.h b/src/phy_stub/l1.h
new file mode 100644 (file)
index 0000000..908c470
--- /dev/null
@@ -0,0 +1,48 @@
+/*******************************************************************************
+################################################################################
+#   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.                                             #
+################################################################################
+*******************************************************************************/
+
+#define MAX_SLOT_VALUE   9
+#define MAX_SFN_VALUE    1023
+#define NR_PCI            1
+#define SLOT_DELAY       3
+
+uint16_t sfnValue = 0;
+uint16_t slotValue = 0;
+bool     rachIndSent = false;
+bool     msg3Sent = false;
+bool     msg5ShortBsrSent = false;
+bool     msg5Sent = false;
+
+typedef enum
+{
+   MSG_TYPE_MSG3,
+   MSG_TYPE_SHORT_BSR,
+   MSG_TYPE_MSG5
+}MsgType;
+
+void phyToMac ARGS((uint16_t msgType, uint32_t msgLen,void *msg));
+#ifdef INTEL_FAPI
+void fillTlvs ARGS((fapi_uint16_tlv_t *tlv, uint16_t tag, uint16_t
+length, uint16_t value, uint32_t *msgLen));
+void fillMsgHeader ARGS((fapi_msg_t *hdr, uint16_t msgType, uint16_t msgLen));
+#endif
+void procPhyMessages(uint16_t msgType, uint32_t msgSize, void *msg);
+
+/**********************************************************************
+         End of file
+**********************************************************************/
index 37ea8df..4b1792b 100644 (file)
 #include "lphy_stub.h"
 #include "lwr_mac_upr_inf.h"
 #include "mac_utils.h"
-
-#define MAX_SLOT_VALUE   9
-#define MAX_SFN_VALUE    1023
-#define NR_PCI            1
-
-uint16_t sfnValue = 0;
-uint16_t slotValue = 0;
-bool     rachIndSent = false;
-
-EXTERN void phyToMac ARGS((uint16_t msgType, uint32_t msgLen,void *msg));
-#ifdef INTEL_FAPI
-EXTERN void fillTlvs ARGS((fapi_uint16_tlv_t *tlv, uint16_t tag, uint16_t
-length, uint16_t value, uint32_t *msgLen));
-EXTERN void fillMsgHeader ARGS((fapi_msg_t *hdr, uint16_t msgType, uint16_t msgLen));
-#endif
-EXTERN void procPhyMessages(uint16_t msgType, uint32_t msgSize, void *msg);
+#include "l1.h"
 
 /*******************************************************************
  *
@@ -355,6 +340,24 @@ uint16_t l1BuildAndSendRxDataInd(uint16_t slot, uint16_t sfn, fapi_ul_pusch_pdu_
    uint8_t  *pdu;
    uint16_t byteIdx = 0;
    uint32_t msgLen = 0;
+   MsgType type;
+
+   if(!msg3Sent)
+   {
+      msg3Sent = true;
+      type = MSG_TYPE_MSG3;
+   }
+   else if(!msg5ShortBsrSent)
+   {
+      msg5ShortBsrSent = true;
+      type = MSG_TYPE_SHORT_BSR;
+   }
+   else if(!msg5Sent)
+   {
+      msg5Sent = true;
+      type = MSG_TYPE_MSG5;
+   }
+
 
    MAC_ALLOC(rxDataInd, sizeof(fapi_rx_data_indication_t));
    if(!rxDataInd)
@@ -374,7 +377,7 @@ uint16_t l1BuildAndSendRxDataInd(uint16_t slot, uint16_t sfn, fapi_ul_pusch_pdu_
    pduInfo->handle = puschPdu.handle;
    pduInfo->rnti = puschPdu.rnti;
    pduInfo->harqId = puschPdu.puschData.harqProcessId;
-   pduInfo->pdu_length = puschPdu.puschData.tbSize;
+   pduInfo->pdu_length = puschPdu.puschData.tbSize ;
    pduInfo->ul_cqi = 0;
    pduInfo->timingAdvance = 0;
    pduInfo->rssi = 0;
@@ -388,21 +391,80 @@ uint16_t l1BuildAndSendRxDataInd(uint16_t slot, uint16_t sfn, fapi_ul_pusch_pdu_
       return RFAILED;
    }
 
-   /* Harcoded Initial RRC setup Request */
+   /* Filling PDU */
    pdu = (uint8_t *)pduInfo->pduData;
-   pdu[byteIdx++] = 0;
-   pdu[byteIdx++] = 181;
-   pdu[byteIdx++] = 99;
-   pdu[byteIdx++] = 20;
-   pdu[byteIdx++] = 170;
-   pdu[byteIdx++] = 132;
-   pdu[byteIdx++] = 96;
-
-   /* Harcoding the pad bytes */
-   pdu[byteIdx++] = 63;
-
-   for(; byteIdx < pduInfo->pdu_length; byteIdx++)
-      pdu[byteIdx] = 0;
+
+   switch(type)
+   {
+      case MSG_TYPE_MSG3: 
+        {
+           /* For Initial RRC setup Request,
+              MAC subheader format is R/R/LCId (1byte)
+              LCId is CCCH(0)
+              From 38.321 section 6.1.1
+            */
+           pdu[byteIdx++] = 0;
+           /* Hardcoding MAC PDU */
+           pdu[byteIdx++] = 181;
+           pdu[byteIdx++] = 99;
+           pdu[byteIdx++] = 20;
+           pdu[byteIdx++] = 170;
+           pdu[byteIdx++] = 132;
+           pdu[byteIdx++] = 96;
+
+           break;
+        }
+
+      case MSG_TYPE_SHORT_BSR:
+        {
+           uint8_t lcgId = 0;
+           uint8_t bufferSizeIdx = 6;
+
+           /* For Short BSR
+              MAC subheader format is R/R/LcId (1Byte)
+              LCId is 61
+              From 38.321 section 6.1.1
+            */
+           pdu[byteIdx++] = 61;    // LCID
+           pdu[byteIdx++] = (lcgId << 5) | bufferSizeIdx;
+
+           break;
+        }
+
+      case MSG_TYPE_MSG5:
+        {
+           uint8_t  msg5PduLen = 33;
+           /* For RRC setup complete
+              MAC subheader format is R/F/LCId/L (2/3 bytes)
+              LCId is 1 for SRB1
+              L is length of PDU i.e 6bytes here 
+              From 38.321 section 6.1.1
+            */
+           uint8_t msg5[] = {1, msg5PduLen, 0, 0, 16, 0, 5, 223, 128, 16, 94, \
+              64, 3, 64, 89, 61, 138, 64, 0, 0, 0, 4, 0, 0, 4, 68, 11, 128, \
+              184, 56, 0, 0, 0, 0, 0};
+
+           msg5PduLen += 2;  /* 2bytes of header */
+           memcpy(pdu, &msg5, msg5PduLen);
+           byteIdx += msg5PduLen; /* 2 bytes of header */
+        }
+
+      default:
+        break;
+   } /* End of switch(type) */
+   /* Filling MAC SDU for Padding bytes*/
+   if(byteIdx < pduInfo->pdu_length)
+   {
+      /* For Padding
+        MAC subheader format is R/R/LCId (1byte)
+        LCId is 63 for padding
+        From 38.321 section 6.1.1
+       */
+      pdu[byteIdx++] = 63;
+
+      for(; byteIdx < pduInfo->pdu_length; byteIdx++)
+        pdu[byteIdx] = 0;
+   }
    msgLen += pduInfo->pdu_length;
 
    fillMsgHeader(&rxDataInd->header, FAPI_RX_DATA_INDICATION, msgLen);
@@ -663,6 +725,156 @@ PUBLIC S16 l1HdlTxDataReq(uint16_t msgLen, void *msg)
 #endif
    return ROK;
 }
+
+#ifdef INTEL_FAPI
+/*******************************************************************
+ *
+ * @brief Fills Uci Ind Pdu Info carried on Pucch Format 0/Format 1
+ *
+ * @details
+ *
+ *    Function : fillPucchF0F1PduInfo
+ *
+ *    Functionality:
+ *       Fills Uci Ind Pdu Info carried on Pucch Format 0/Format 1 
+ *
+ * @params[in] fapi_uci_o_pucch_f0f1_t *
+ *             pucchPdu
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t fillPucchF0F1PduInfo(fapi_uci_o_pucch_f0f1_t *pduInfo, fapi_ul_pucch_pdu_t pucchPdu)
+{
+   uint8_t idx = 0;
+
+   pduInfo->handle = pucchPdu.handle;
+   pduInfo->pduBitmap = 1;  //hardcoded for SR
+   pduInfo->pucchFormat = pucchPdu.formatType;
+   pduInfo->ul_cqi = 0;
+   pduInfo->rnti = pucchPdu.rnti;
+   pduInfo->timingAdvance = 0;
+   pduInfo->rssi = 0;
+   pduInfo->uciBits[idx] = 0;   //TODO: FAPI spec ver. 222.10.01 has no info about UCI Bits
+   if(pduInfo->pduBitmap & SR_PDU_BITMASK)
+   {
+      pduInfo->srInfo.srIndication = SR_DETECTED;
+      pduInfo->srInfo.srConfidenceLevel = CONFDC_LEVEL_GOOD;
+   }
+   if(pduInfo->pduBitmap & HARQ_PDU_BITMASK)
+   {
+      pduInfo->harqInfo.numHarq++;
+      pduInfo->harqInfo.harqConfidenceLevel = CONFDC_LEVEL_GOOD;
+      for(idx = 0; idx < pduInfo->harqInfo.numHarq; idx++)
+      {
+         pduInfo->harqInfo.harqValue[idx] = HARQ_PASS;
+      }
+   }
+   return ROK;
+}
+/*******************************************************************
+ *
+ * @brief Fills UCI Pdu Information
+ *
+ * @details
+ *
+ *    Function : fillUciPduInfo
+ *
+ *    Functionality:
+ *       Fills UCI Pdu Information
+ *
+ * @params[in] Pointer to uciPdu
+ *             pucchPdu
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t fillUciPduInfo(fapi_uci_pdu_info_t *uciPdu, fapi_ul_pucch_pdu_t pucchPdu)
+{
+   uint8_t ret = ROK;
+
+   /*TODO: The pduType is hardcoded here to support 
+     UCI Ind for PUCCH forat0/format1. This is to be
+     modified when we get SR form UE */
+   uciPdu->pduType = UCI_IND_PUCCH_F0F1;
+   switch(uciPdu->pduType)
+   {
+      case UCI_IND_PUSCH:
+         break;
+      case UCI_IND_PUCCH_F0F1:
+         {
+            fapi_uci_o_pucch_f0f1_t *pduInfo = NULLP;
+
+            pduInfo = &uciPdu->uci.uciPucchF0F1;
+            ret = fillPucchF0F1PduInfo(pduInfo, pucchPdu);
+            uciPdu->pduSize = sizeof(fapi_uci_o_pucch_f0f1_t);
+         }
+         break;
+      case UCI_IND_PUCCH_F2F3F4:
+         break;
+      default:
+         DU_LOG("\nPHY_STUB: Invalid Pdu Type %d", uciPdu->pduType);
+         break;
+   }
+   return ret;
+}
+
+/*******************************************************************
+ *
+ * @brief Build and send Uci indication
+ *
+ * @details
+ *
+ *    Function : l1BuildAndSendUciInd
+ *
+ *    Functionality:
+ *       Build and send Uci indication
+ *
+ * @params[in] SFN
+ *             Slot
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t l1BuildAndSendUciInd(uint16_t slot, uint16_t sfn, fapi_ul_pucch_pdu_t pucchPdu)
+{
+   uint8_t uciIdx = 0;
+   uint8_t nUciPdus = 0;
+   uint8_t ret = ROK;
+   uint32_t msgLen = 0;
+   fapi_uci_indication_t *uciInd =  NULLP;
+
+   MAC_ALLOC(uciInd, sizeof(fapi_uci_indication_t));
+   if(!uciInd)
+   {
+      printf("\nPHY_STUB: Memory allocation failed for UCI Indication");
+      return RFAILED;
+   }
+   memset(uciInd, 0, sizeof(fapi_uci_indication_t));
+   uciInd->sfn = sfn;
+   uciInd->slot = slot;
+   uciInd->numUcis = 1;   //consdering the UCI Ind for SR
+   nUciPdus = uciInd->numUcis;
+   while(nUciPdus)
+   {
+      ret = fillUciPduInfo(&uciInd->uciPdu[uciIdx], pucchPdu);
+      uciIdx++;
+      nUciPdus--;
+   }
+   if(ret == ROK)
+   {
+      msgLen = sizeof(fapi_uci_indication_t)- sizeof(fapi_msg_t);
+      fillMsgHeader(&uciInd->header, FAPI_UCI_INDICATION, msgLen);
+
+      /* Sending UCI indication to MAC */
+      DU_LOG("\nPHY STUB: Sending UCI Indication to MAC");
+      procPhyMessages(uciInd->header.msg_id, sizeof(fapi_uci_indication_t), (void *)uciInd);
+   }
+   MAC_FREE(uciInd, sizeof(fapi_uci_indication_t));
+   return ret;
+}
+#endif
+
 /*******************************************************************
  *
  * @brief Handles Ul Tti request received from MAC
@@ -684,8 +896,8 @@ PUBLIC S16 l1HdlTxDataReq(uint16_t msgLen, void *msg)
 PUBLIC S16 l1HdlUlTtiReq(uint16_t msgLen, void *msg)
 {
 #ifdef INTEL_FAPI
-   fapi_ul_tti_req_t *ulTtiReq;
-
+   fapi_ul_tti_req_t *ulTtiReq = NULLP;
+   
    DU_LOG("\nPHY STUB: Received UL TTI Request");
 
    ulTtiReq = (fapi_ul_tti_req_t *)msg;
@@ -710,6 +922,8 @@ PUBLIC S16 l1HdlUlTtiReq(uint16_t msgLen, void *msg)
       if(ulTtiReq->pdus[numPdus-1].pduType == 2)
       {
         DU_LOG("\nPHY STUB: PUCCH PDU");
+        l1BuildAndSendUciInd((ulTtiReq->slot + SLOT_DELAY), ulTtiReq->sfn, \
+              ulTtiReq->pdus[numPdus-1].pdu.pucch_pdu); 
       }
       numPdus--;
    }
@@ -803,6 +1017,152 @@ PUBLIC S16 l1HdlStopReq(uint32_t msgLen, void *msg)
    return ROK;
 }
 
+/*******************************************************************
+ *
+ * @brief Build And Send Rx Data Ind for Msg5
+ *
+ * @details
+ *
+ *    Function : l1BuildAndSendMsg5
+ *
+ *    Functionality: Build And Send Rx Data Ind for Msg5
+ *
+ * @params[in] SFN
+ *             Slot
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t l1BuildAndSendMsg5(uint16_t sfn, uint16_t slot)
+{   
+#ifdef INTEL_FAPI
+   uint8_t idx = 0;
+   fapi_rx_data_indication_t *rxDataInd;
+   fapi_pdu_ind_info_t       *pduInfo;
+   uint8_t  *pdu;
+   uint16_t byteIdx = 0;
+   uint32_t msgLen = 0;
+
+   MAC_ALLOC(rxDataInd, sizeof(fapi_rx_data_indication_t));
+   if(!rxDataInd)
+   {
+      printf("\nPHY_STUB: Memory allocation failed for Rx Data Indication for msg5");
+      return RFAILED;
+   }
+   memset(rxDataInd, 0, sizeof(fapi_rx_data_indication_t));
+
+   /* TODO: Fill the required values */
+   msgLen = sizeof(fapi_rx_data_indication_t) - sizeof(fapi_msg_t);
+   rxDataInd->sfn = sfn;
+   rxDataInd->slot = slot;
+   rxDataInd->numPdus = 1;
+
+   pduInfo = &rxDataInd->pdus[idx];
+   pduInfo->handle = 100;
+   pduInfo->rnti = 100;
+   pduInfo->harqId = 1;
+   pduInfo->pdu_length = 25;
+   pduInfo->ul_cqi = 0;
+   pduInfo->timingAdvance = 0;
+   pduInfo->rssi = 0;
+
+   /* Filling pdu with random values for testing */
+   pduInfo->pduData = NULL;
+   MAC_ALLOC(pduInfo->pduData, pduInfo->pdu_length);
+   if(!pduInfo->pduData)
+   {
+      printf("\nPHY_STUB: Memory allocation failed for Rx Data Pdu");
+      return RFAILED;
+   }
+
+   /* Filling PDU */
+   pdu = (uint8_t *)pduInfo->pduData;
+
+   uint8_t  msg5PduLen = 33;
+   /* For RRC setup complete
+      MAC subheader format is R/F/LCId/L (2/3 bytes)
+      LCId is 1 for SRB1
+      L is length of PDU i.e 6bytes here
+      From 38.321 section 6.1.1
+    */
+   uint8_t msg5[] = {1, msg5PduLen, 0, 0, 16, 0, 5, 223, 128, 16, 94, \
+      64, 3, 64, 89, 61, 138, 64, 0, 0, 0, 4, 0, 0, 4, 68, 11, 128, \
+        184, 56, 0, 0, 0, 0, 0};
+
+   msg5PduLen += 2;  /* 2bytes of header */
+   memcpy(pdu, &msg5, msg5PduLen);
+   byteIdx += msg5PduLen; /* 2 bytes of header */
+
+   /* Filling MAC SDU for Padding bytes*/
+   if(byteIdx < pduInfo->pdu_length)
+   {
+      /* For Padding
+        MAC subheader format is R/R/LCId (1byte)
+        LCId is 63 for padding
+        From 38.321 section 6.1.1
+       */
+      pdu[byteIdx++] = 63;
+
+      for(; byteIdx < pduInfo->pdu_length; byteIdx++)
+        pdu[byteIdx] = 0;
+   }
+   msgLen += pduInfo->pdu_length;
+
+   fillMsgHeader(&rxDataInd->header, FAPI_RX_DATA_INDICATION, msgLen);
+
+   /* Sending Rx data indication to MAC */
+   DU_LOG("\nPHY STUB: Sending Rx data Indication to MAC");
+   procPhyMessages(rxDataInd->header.msg_id, sizeof(fapi_rx_data_indication_t), (void *)rxDataInd);
+
+   if(pduInfo->pdu_length)
+      MAC_FREE(pduInfo->pduData, pduInfo->pdu_length);
+   MAC_FREE(rxDataInd, sizeof(fapi_rx_data_indication_t));
+#endif
+   return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief Handles Ul Dci request received from MAC
+ *
+ * @details
+ *
+ *    Function : l1HdlUlDciReq
+ *
+ *    Functionality:
+ *          -Handles Ul Dci request received from MAC
+ *
+ * @params[in]   Message length
+ *               Ul Dci request message pointer
+ *
+ * @return void
+ *
+ * ****************************************************************/
+
+PUBLIC S16 l1HdlUlDciReq(uint16_t msgLen, void *msg)
+{
+#ifdef INTEL_FAPI
+   fapi_ul_dci_req_t *ulDciReq = NULLP;
+
+   ulDciReq = (fapi_ul_dci_req_t *)msg;
+   uint8_t numPdus = ulDciReq->numPdus;
+
+   while(numPdus)
+   {
+      if(ulDciReq->pdus[numPdus-1].pduType == 0)
+      {
+        DU_LOG("\nPHY STUB: Received UL DCI Request for PDCCH PDU");
+        //l1BuildAndSendMsg5(ulDciReq->sfn, ulDciReq->slot);
+        //msg5Sent = true;
+      }
+      numPdus--;
+   }
+
+   MAC_FREE(ulDciReq, msgLen);
+#endif
+   return ROK;
+}
+
 /*******************************************************************
  *
  * @brief Receives message from MAC
@@ -848,6 +1208,9 @@ void l1ProcessFapiRequest(uint8_t msgType, uint32_t msgLen, void *msg)
       case FAPI_STOP_REQUEST:
         l1HdlStopReq(msgLen, msg);
         break;
+      case FAPI_UL_DCI_REQUEST:
+        l1HdlUlDciReq(msgLen, msg);
+        break;
       default:
         DU_LOG("\nPHY_STUB: Invalid message type[%x] received at PHY", msgType);
         break;