+uint16_t handleDlTtiReq(CmLteTimingInfo *dlTtiReqtimingInfo)
+{
+#ifdef FAPI
+ uint8_t idx;
+ uint8_t nPdu = 0;
+ uint8_t numPduEncoded = 0;
+ uint32_t msgLen = 0;
+ fapi_dl_tti_req_t *dlTtiReq = NULLP;
+ fapi_tx_data_req_t *txDataReq = NULLP;
+ RgCellCb *cellCbParams = NULLP;
+ MacDlSlot *currDlSlot = NULLP;
+ MacCellCfg macCellCfg;
+ memset(&macCellCfg, 0, sizeof(MacCellCfg));
+ Inst inst = 0;
+
+ if(clGlobalCp.phyState == PHY_STATE_RUNNING)
+ {
+ cellCbParams = rgCb[inst].cell;
+ macCellCfg = cellCbParams->macCellCfg;
+
+ if(dlTtiReqtimingInfo != NULLP)
+ {
+ LWR_MAC_ALLOC(dlTtiReq, sizeof(fapi_dl_tti_req_t));
+ if(dlTtiReq != NULLP)
+ {
+ dlTtiReq->sfn = dlTtiReqtimingInfo->sfn;
+ dlTtiReq->slot = dlTtiReqtimingInfo->slot;
+ currDlSlot = &macCb.macCell->dlSlot[dlTtiReq->slot % MAX_SLOT_SUPPORTED];
+ dlTtiReq->nPdus = calculatePduCount(&currDlSlot->dlInfo); /* get total Pdus */
+ nPdu = dlTtiReq->nPdus;
+ dlTtiReq->nGroup = 0;
+ if(dlTtiReq->nPdus > 0)
+ {
+ LWR_MAC_ALLOC(dlTtiReq->pdus, (nPdu * sizeof(fapi_dl_tti_req_pdu_t)));
+ if(!dlTtiReq->pdus)
+ {
+ DU_LOG("\nLOWER MAC: Memory allocation failed");
+ return RFAILED;
+ }
+
+ if(currDlSlot->dlInfo.isBroadcastPres)
+ {
+ if(currDlSlot->dlInfo.brdcstAlloc.ssbTrans)
+ {
+ if(dlTtiReq->pdus != NULLP)
+ {
+ for(idx = 0; idx < currDlSlot->dlInfo.brdcstAlloc.ssbIdxSupported; idx++)
+ {
+ if(idx > 0)
+ dlTtiReq->pdus++;
+ fillSsbPdu(&dlTtiReq->pdus[numPduEncoded], &macCellCfg, currDlSlot, &msgLen, idx);
+ numPduEncoded++;
+ }
+ }
+ DU_LOG("\nLOWER MAC: MIB sent..");
+ }
+ if(currDlSlot->dlInfo.brdcstAlloc.sib1Trans)
+ {
+ /* Filling SIB1 param */
+ if(numPduEncoded != nPdu)
+ {
+ fillPdcchPdu(&dlTtiReq->pdus[numPduEncoded],&currDlSlot->dlInfo.brdcstAlloc.\
+ sib1Alloc.sib1PdcchCfg, &msgLen);
+ numPduEncoded++;
+ fillPdschPdu(&dlTtiReq->pdus[numPduEncoded],&currDlSlot->dlInfo.brdcstAlloc.\
+ sib1Alloc.sib1PdschCfg, &msgLen);
+ numPduEncoded++;
+ }
+ DU_LOG("\nLOWER MAC: SIB1 sent...");
+ }
+ }
+ if(currDlSlot->dlInfo.isRarPres)
+ {
+ /* Filling RAR param */
+ fillPdcchPdu(&dlTtiReq->pdus[numPduEncoded], &currDlSlot->dlInfo.rarAlloc.rarPdcchCfg, &msgLen);
+ numPduEncoded++;
+ fillPdschPdu(&dlTtiReq->pdus[numPduEncoded], &currDlSlot->dlInfo.rarAlloc.rarPdschCfg, &msgLen);
+ numPduEncoded++;
+ DU_LOG("\nLOWER MAC: RAR sent...");
+ }
+
+ msgLen += sizeof(fapi_dl_tti_req_t) - sizeof(fapi_msg_t);
+ fillMsgHeader(&dlTtiReq->header, FAPI_DL_TTI_REQUEST, msgLen);
+ /* TODO : Recheck the size / msglen to be sent to WLS_Put*/
+ LwrMacSendToPhy(dlTtiReq->header.message_type_id, msgLen, (void *)dlTtiReq);
+
+ /* send TX_Data request message */
+ if(currDlSlot->dlInfo.brdcstAlloc.sib1Trans)
+ {
+ msgLen = 0;
+ LWR_MAC_ALLOC(txDataReq,sizeof(fapi_tx_data_req_t));
+ txDataReq->sfn = dlTtiReqtimingInfo->sfn;
+ txDataReq->slot = dlTtiReqtimingInfo->slot;
+ txDataReq->numPdus = 1;
+ LWR_MAC_ALLOC(txDataReq->pduDesc, (txDataReq->numPdus * \
+ sizeof(fapi_tx_pdu_desc_t)));
+ fillSib1TxDataReq(
+ txDataReq->pduDesc,
+ &rgCb[inst].cell->macCellCfg,
+ currDlSlot->dlInfo.brdcstAlloc.sib1Alloc.sib1PdschCfg.pduIndex,
+ &msgLen);
+ msgLen += sizeof(fapi_tx_data_req_t) - sizeof(fapi_msg_t);
+ fillMsgHeader(&txDataReq->header, FAPI_TX_DATA_REQUEST, msgLen);
+ LwrMacSendToPhy(txDataReq->header.message_type_id, msgLen,(void *)txDataReq);
+ }
+ if(currDlSlot->dlInfo.isRarPres)
+ {
+ msgLen = 0;
+ /* mux and form RAR pdu */
+ fillRarPdu(&currDlSlot->dlInfo.rarAlloc.rarInfo);
+ LWR_MAC_ALLOC(txDataReq,sizeof(fapi_tx_data_req_t));
+ txDataReq->sfn = dlTtiReqtimingInfo->sfn;
+ txDataReq->slot = dlTtiReqtimingInfo->slot;
+ txDataReq->numPdus = 1;
+ LWR_MAC_ALLOC(txDataReq->pduDesc, (txDataReq->numPdus * \
+ sizeof(fapi_tx_pdu_desc_t)));
+ fillRarTxDataReq(
+ txDataReq->pduDesc,
+ &currDlSlot->dlInfo.rarAlloc.rarInfo,
+ currDlSlot->dlInfo.rarAlloc.rarPdschCfg.pduIndex,
+ &msgLen);
+ fillMsgHeader(&txDataReq->header, FAPI_TX_DATA_REQUEST, msgLen);
+ LwrMacSendToPhy(txDataReq->header.message_type_id, msgLen,(void *)txDataReq);
+ }
+ }
+ else
+ {
+ msgLen = sizeof(fapi_dl_tti_req_t) - sizeof(fapi_msg_t);
+ fillMsgHeader(&dlTtiReq->header, FAPI_DL_TTI_REQUEST, msgLen);
+ /* TODO : Recheck the size / msglen to be sent to WLS_Put*/
+ LwrMacSendToPhy(dlTtiReq->header.message_type_id, msgLen, (void *)dlTtiReq);
+ }
+ return ROK;
+ }
+ else
+ {
+ DU_LOG("\nLOWER MAC: Failed to allocate memory for DL TTI Request");
+ return RFAILED;
+ }
+ }
+ else
+ {
+ DU_LOG("\nLOWER MAC: Current TTI Info is NULL");
+ return RFAILED;
+ }
+ }
+ else
+ {
+ lwr_mac_handleInvalidEvt(dlTtiReqtimingInfo);
+ }
+#endif
+ return ROK;
+}
+
+/***********************************************************************
+ *
+ * @brief calculates the total size to be allocated for UL TTI Req
+ *
+ * @details
+ *
+ * Function : getnPdus
+ *
+ * Functionality:
+ * -calculates the total pdu count to be allocated for UL TTI Req
+ *
+ * @params[in] Pointer to fapi Ul TTI Req
+ * Pointer to CurrUlSlot
+ * @return count
+ * ********************************************************************/
+#ifdef FAPI
+uint8_t getnPdus(fapi_ul_tti_req_t *ulTtiReq, MacUlSlot *currUlSlot)
+{
+ uint8_t pduCount = 0;
+
+ if(currUlSlot != NULLP)
+ {
+ if(currUlSlot->ulCellInfo.dataType & SCH_DATATYPE_PRACH)
+ {
+ pduCount++;
+ ulTtiReq->rachPresent = PDU_PRESENT;
+ }
+ if(currUlSlot->ulCellInfo.dataType & SCH_DATATYPE_PUSCH_UCI)
+ {
+ pduCount++;
+ ulTtiReq->nUlsch = PDU_PRESENT;
+ }
+ if(currUlSlot->ulCellInfo.dataType & SCH_DATATYPE_UCI)
+ {
+ pduCount++;
+ ulTtiReq->nUlcch = PDU_PRESENT;
+ }
+ if(currUlSlot->ulCellInfo.dataType & SCH_DATATYPE_SRS)
+ {
+ pduCount++;
+ }
+ }
+ return pduCount;
+}
+#endif
+
+/***********************************************************************
+ *
+ * @brief Set the value of zero correlation config in PRACH PDU
+ *
+ * @details
+ *
+ * Function : setNumCs
+ *
+ * Functionality:
+ * -Set the value of zero correlation config in PRACH PDU
+ *
+ * @params[in] Pointer to zero correlation config
+ * Pointer to MacCellCfg
+ * ********************************************************************/
+
+void setNumCs(uint8_t *numCs, MacCellCfg *macCellCfg)