+#endif
+ return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief Modifes the received mibPdu to uint32 bit
+ * and stores it in MacCellCfg
+ *
+ * @details
+ *
+ * Function : setMibPdu
+ *
+ * Functionality:
+ * -Sets the MibPdu
+ *
+ * @params[in] Pointer to mibPdu
+ * pointer to modified value
+ ******************************************************************/
+
+PUBLIC void setMibPdu(uint8_t *mibPdu, uint32_t *val)
+{
+ *mibPdu |= (((uint8_t)(slotIndInfo.sfn >> 2)) & MIB_SFN_BITMASK);
+ *val = (mibPdu[0] << 24 | mibPdu[1] << 16 | mibPdu[2] << 8);
+ DU_LOG("\nLOWER MAC: value filled %x", *val);
+}
+
+#ifdef FAPI
+/*******************************************************************
+ *
+ * @brief fills SSB PDU required for DL TTI info in MAC
+ *
+ * @details
+ *
+ * Function : fillSsbPdu
+ *
+ * Functionality:
+ * -Fills the SSB PDU info
+ * stored in MAC
+ *
+ * @params[in] Pointer to FAPI DL TTI Req
+ * Pointer to RgCellCb
+ * Pointer to msgLen of DL TTI Info
+ * @return ROK
+ *
+ ******************************************************************/
+
+S16 fillSsbPdu(fapi_dl_tti_req_pdu_t *dlTtiReqPdu, MacCellCfg *macCellCfg,
+ MacDlSlot *currDlSlot,
+ uint32_t *msgLen, uint8_t ssbIdxCount)
+{
+ uint32_t mibPayload = 0;
+ if(dlTtiReqPdu != NULL)
+ {
+ dlTtiReqPdu->pduType = SSB_PDU_TYPE; /* SSB PDU */
+ dlTtiReqPdu->u.ssb_pdu.physCellId = macCellCfg->phyCellId;
+ dlTtiReqPdu->u.ssb_pdu.betaPss = macCellCfg->ssbCfg.betaPss;
+ dlTtiReqPdu->u.ssb_pdu.ssbBlockIndex = currDlSlot->cellBroadcastInfo.ssbInfo[ssbIdxCount].ssbIdx;
+ dlTtiReqPdu->u.ssb_pdu.ssbSubCarrierOffset = macCellCfg->ssbCfg.ssbScOffset;
+ /* ssbOfPdufstA to be filled in ssbCfg */
+ dlTtiReqPdu->u.ssb_pdu.ssbOffsetPointA = macCellCfg->ssbCfg.ssbOffsetPointA;
+ dlTtiReqPdu->u.ssb_pdu.bchPayloadFlag = macCellCfg->ssbCfg.bchPayloadFlag;
+ /* Bit manipulation for SFN */
+ setMibPdu(macCellCfg->ssbCfg.mibPdu, &mibPayload);
+ dlTtiReqPdu->u.ssb_pdu.bchPayload.v.bchPayload = mibPayload;
+ dlTtiReqPdu->u.ssb_pdu.preCodingAndBeamforming.numPrgs = 0;
+ dlTtiReqPdu->u.ssb_pdu.preCodingAndBeamforming.prgSize = 0;
+ dlTtiReqPdu->u.ssb_pdu.preCodingAndBeamforming.digBfInterfaces = 0;
+ dlTtiReqPdu->u.ssb_pdu.preCodingAndBeamforming.pmi_bfi[0].pmIdx = 0;
+ dlTtiReqPdu->u.ssb_pdu.preCodingAndBeamforming. \
+ pmi_bfi[0].beamIdx[0].beamidx = macCellCfg->ssbCfg.beamId[0];
+ dlTtiReqPdu->pduSize = sizeof(fapi_dl_ssb_pdu_t); /* Size of SSB PDU */
+ SETLENGTH(*msgLen, sizeof(fapi_dl_ssb_pdu_t));
+ return ROK;
+ }
+ else
+ {
+ return RFAILED;
+ }
+}
+
+/*******************************************************************
+ *
+ * @brief fills Dl DCI PDU required for DL TTI info in MAC
+ *
+ * @details
+ *
+ * Function : fillDlDciPdu
+ *
+ * Functionality:
+ * -Fills the Dl DCI PDU
+ *
+ * @params[in] Pointer to fapi_dl_dci_t
+ * Pointer to Sib1PdcchCfg
+ * @return ROK
+ *
+ ******************************************************************/
+
+void fillDlDciPdu(fapi_dl_dci_t *dlDciPtr, Sib1PdcchCfg *sib1PdcchInfo)
+{
+ if(dlDciPtr != NULLP)
+ {
+ uint8_t numBytes;
+ uint8_t bytePos;
+ uint8_t bitPos;
+
+ uint16_t coreset0Size;
+ uint16_t rbStart;
+ uint16_t rbLen;
+ uint32_t freqDomResAssign;
+ uint32_t timeDomResAssign;
+ uint8_t VRB2PRBMap;
+ uint32_t modNCodScheme;
+ uint8_t redundancyVer;
+ uint32_t sysInfoInd;
+ uint32_t reserved;
+
+ /* Size(in bits) of each field in DCI format 0_1
+ * as mentioned in spec 38.214 */
+ uint8_t freqDomResAssignSize;
+ uint8_t timeDomResAssignSize = 4;
+ uint8_t VRB2PRBMapSize = 1;
+ uint8_t modNCodSchemeSize = 5;
+ uint8_t redundancyVerSize = 2;
+ uint8_t sysInfoIndSize = 1;
+ uint8_t reservedSize = 15;
+
+ dlDciPtr->rnti = sib1PdcchInfo->sib1DlDci.rnti;
+ dlDciPtr->scramblingId = sib1PdcchInfo->sib1DlDci.scramblingId;
+ dlDciPtr->scramblingRnti = sib1PdcchInfo->sib1DlDci.scramblingRnti;
+ dlDciPtr->cceIndex = sib1PdcchInfo->sib1DlDci.cceIndex;
+ dlDciPtr->aggregationLevel = sib1PdcchInfo->sib1DlDci.aggregLevel;
+ dlDciPtr->pc_and_bform.numPrgs = sib1PdcchInfo->sib1DlDci.beamPdcchInfo.numPrgs;
+ dlDciPtr->pc_and_bform.prgSize = sib1PdcchInfo->sib1DlDci.beamPdcchInfo.prgSize;
+ dlDciPtr->pc_and_bform.digBfInterfaces = sib1PdcchInfo->sib1DlDci.beamPdcchInfo.digBfInterfaces;
+ dlDciPtr->pc_and_bform.pmi_bfi[0].pmIdx = sib1PdcchInfo->sib1DlDci.beamPdcchInfo.prg[0].pmIdx;
+ dlDciPtr->pc_and_bform.pmi_bfi[0].beamIdx[0].beamidx = sib1PdcchInfo->sib1DlDci.beamPdcchInfo.prg[0].beamIdx[0];
+ dlDciPtr->beta_pdcch_1_0 = sib1PdcchInfo->sib1DlDci.txPdcchPower.powerValue;
+ dlDciPtr->powerControlOfssetSS = sib1PdcchInfo->sib1DlDci.txPdcchPower.powerControlOffsetSS;
+
+ /* Calculating freq domain resource allocation field value and size
+ * coreset0Size = Size of coreset 0
+ * RBStart = Starting Virtual Rsource block
+ * RBLen = length of contiguously allocted RBs
+ * Spec 38.214 Sec 5.1.2.2.2
+ */
+ coreset0Size= sib1PdcchInfo->sib1Coreset0Cfg.coreSet0Size;
+ rbStart = 0; /* For SIB1 */
+ //rbStart = sib1PdcchInfo->sib1DlDci.pdschCfg->sib1FreqAlloc.rbStart;
+ rbLen = sib1PdcchInfo->sib1DlDci.pdschCfg->sib1FreqAlloc.rbSize;
+
+ if((rbLen >=1) && (rbLen <= coreset0Size - rbStart))
+ {
+ if((rbLen - 1) <= floor(coreset0Size / 2))
+ freqDomResAssign = (coreset0Size * (rbLen-1)) + rbStart;
+ else
+ freqDomResAssign = (coreset0Size * (coreset0Size - rbLen + 1)) \
+ + (coreset0Size - 1 - rbStart);
+
+ freqDomResAssignSize = ceil(log2(coreset0Size * (coreset0Size + 1) / 2));
+ }
+
+ /* Fetching DCI field values */
+ timeDomResAssign = sib1PdcchInfo->sib1DlDci.pdschCfg->sib1TimeAlloc.
+ rowIndex -1;
+ VRB2PRBMap = sib1PdcchInfo->sib1DlDci.pdschCfg->sib1FreqAlloc.\
+ vrbPrbMapping;
+ modNCodScheme = sib1PdcchInfo->sib1DlDci.pdschCfg->codeword[0].mcsIndex;
+ redundancyVer = sib1PdcchInfo->sib1DlDci.pdschCfg->codeword[0].rvIndex;
+ sysInfoInd = 0; /* 0 for SIB1; 1 for SI messages */
+ reserved = 0;
+
+ /* Reversing bits in each DCI field */
+ freqDomResAssign = reverseBits(freqDomResAssign, freqDomResAssignSize);
+ timeDomResAssign = reverseBits(timeDomResAssign, timeDomResAssignSize);
+ VRB2PRBMap = reverseBits(VRB2PRBMap, VRB2PRBMapSize);
+ modNCodScheme = reverseBits(modNCodScheme, modNCodSchemeSize);
+ redundancyVer = reverseBits(redundancyVer, redundancyVerSize);
+ sysInfoInd = reverseBits(sysInfoInd, sysInfoIndSize);
+ reserved = reverseBits(reserved, reservedSize);
+
+ /* Calulating total number of bytes in buffer */
+ dlDciPtr->payloadSizeBits = freqDomResAssignSize + timeDomResAssignSize\
+ + VRB2PRBMapSize + modNCodSchemeSize + redundancyVerSize\
+ + sysInfoIndSize + reservedSize;
+
+ numBytes = dlDciPtr->payloadSizeBits / 8;
+ if(dlDciPtr->payloadSizeBits % 8)
+ numBytes += 1;
+
+ if(numBytes > DCI_PAYLOAD_BYTE_LEN)
+ {
+ DU_LOG("\nLOWER MAC : Total bytes for DCI is more than expected");
+ return;
+ }
+
+ /* Initialize buffer */
+ for(bytePos = 0; bytePos < numBytes; bytePos++)
+ dlDciPtr->payload[bytePos] = 0;
+
+ bytePos = numBytes - 1;
+ bitPos = 0;
+
+ /* Packing DCI format fields */
+ fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
+ freqDomResAssign, freqDomResAssignSize);
+ fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
+ timeDomResAssign, timeDomResAssignSize);
+ fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
+ VRB2PRBMap, VRB2PRBMapSize);
+ fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
+ modNCodScheme, modNCodSchemeSize);
+ fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
+ redundancyVer, redundancyVerSize);
+ fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
+ sysInfoInd, sysInfoIndSize);
+ fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
+ reserved, reservedSize);
+
+ }
+} /* fillDlDciPdu */
+
+/*******************************************************************
+ *
+ * @brief fills PDCCH PDU required for DL TTI info in MAC
+ *
+ * @details
+ *
+ * Function : fillPdcchPdu
+ *
+ * Functionality:
+ * -Fills the Pdcch PDU info
+ * stored in MAC
+ *
+ * @params[in] Pointer to FAPI DL TTI Req
+ * Pointer to Sib1PdcchCfg
+ * Pointer to msgLen of DL TTI Info
+ * @return ROK
+ *
+ ******************************************************************/
+
+S16 fillPdcchPdu(fapi_dl_tti_req_pdu_t *dlTtiReqPdu, Sib1PdcchCfg *sib1PdcchInfo,
+uint32_t *msgLen)
+{
+ if(dlTtiReqPdu != NULLP)
+ {
+ dlTtiReqPdu->pduType = PDCCH_PDU_TYPE;
+ dlTtiReqPdu->u.pdcch_pdu.bwpSize = sib1PdcchInfo->sib1PdcchBwpCfg.BWPSize;
+ dlTtiReqPdu->u.pdcch_pdu.bwpPart = sib1PdcchInfo->sib1PdcchBwpCfg.BWPStart;
+ dlTtiReqPdu->u.pdcch_pdu.subCarrierSpacing = sib1PdcchInfo->sib1PdcchBwpCfg.subcarrierSpacing;
+ dlTtiReqPdu->u.pdcch_pdu.cyclicPrefix = sib1PdcchInfo->sib1PdcchBwpCfg.cyclicPrefix;
+ dlTtiReqPdu->u.pdcch_pdu.startSymbolIndex = sib1PdcchInfo->sib1Coreset0Cfg.startSymbolIndex;
+ dlTtiReqPdu->u.pdcch_pdu.durationSymbols = sib1PdcchInfo->sib1Coreset0Cfg.durationSymbols;
+ memcpy(dlTtiReqPdu->u.pdcch_pdu.freqDomainResource, sib1PdcchInfo->sib1Coreset0Cfg.freqDomainResource, 6);
+ dlTtiReqPdu->u.pdcch_pdu.cceRegMappingType = sib1PdcchInfo->sib1Coreset0Cfg.cceRegMappingType;
+ dlTtiReqPdu->u.pdcch_pdu.regBundleSize = sib1PdcchInfo->sib1Coreset0Cfg.regBundleSize;
+ dlTtiReqPdu->u.pdcch_pdu.interleaverSize = sib1PdcchInfo->sib1Coreset0Cfg.interleaverSize;
+ dlTtiReqPdu->u.pdcch_pdu.coreSetSize = sib1PdcchInfo->sib1Coreset0Cfg.coreSetType;
+ dlTtiReqPdu->u.pdcch_pdu.shiftIndex = sib1PdcchInfo->sib1Coreset0Cfg.shiftIndex;
+ dlTtiReqPdu->u.pdcch_pdu.precoderGranularity = sib1PdcchInfo->sib1Coreset0Cfg.precoderGranularity;
+ dlTtiReqPdu->u.pdcch_pdu.numDlDci = sib1PdcchInfo->numDlDci;
+#ifdef INTEL_WLS
+ WLS_MEM_ALLOC(dlTtiReqPdu->u.pdcch_pdu.dlDci, sizeof(fapi_dl_dci_t));
+#else
+ MAC_ALLOC(dlTtiReqPdu->u.pdcch_pdu.dlDci, sizeof(fapi_dl_dci_t));
+#endif
+ fillDlDciPdu(dlTtiReqPdu->u.pdcch_pdu.dlDci, sib1PdcchInfo);
+ dlTtiReqPdu->pduSize = sizeof(fapi_dl_pdcch_pdu_t);
+ SETLENGTH(*msgLen, sizeof(fapi_dl_pdcch_pdu_t));
+
+ }
+ return ROK;
+
+}
+
+/*******************************************************************
+ *
+ * @brief fills PDSCH PDU required for DL TTI info in MAC
+ *
+ * @details
+ *
+ * Function : fillPdschPdu
+ *
+ * Functionality:
+ * -Fills the Pdsch PDU info
+ * stored in MAC
+ *
+ * @params[in] Pointer to FAPI DL TTI Req
+ * Pointer to Sib1PdschCfg
+ * Pointer to msgLen of DL TTI Info
+ * @return ROK
+ *
+ ******************************************************************/
+
+void fillPdschPdu(fapi_dl_tti_req_pdu_t *dlTtiReqPdu, Sib1PdschCfg *sib1PdschInfo,
+uint32_t *msgLen)
+{
+ uint8_t idx;
+
+ if(dlTtiReqPdu != NULLP)
+ {
+ dlTtiReqPdu->pduType = PDSCH_PDU_TYPE;
+ dlTtiReqPdu->u.pdsch_pdu.pduBitMap = sib1PdschInfo->pduBitmap;
+ dlTtiReqPdu->u.pdsch_pdu.rnti = sib1PdschInfo->rnti;
+ dlTtiReqPdu->u.pdsch_pdu.pduIndex = sib1PdschInfo->pduIndex;
+ dlTtiReqPdu->u.pdsch_pdu.bwpSize = sib1PdschInfo->sib1PdschBwpCfg.BWPSize;
+ dlTtiReqPdu->u.pdsch_pdu.bwpStart = sib1PdschInfo->sib1PdschBwpCfg.BWPStart;
+ dlTtiReqPdu->u.pdsch_pdu.subCarrierSpacing = sib1PdschInfo->sib1PdschBwpCfg.subcarrierSpacing;
+ dlTtiReqPdu->u.pdsch_pdu.cyclicPrefix = sib1PdschInfo->sib1PdschBwpCfg.cyclicPrefix;
+ dlTtiReqPdu->u.pdsch_pdu.nrOfCodeWords = sib1PdschInfo->numCodewords;
+ for(idx = 0; idx < MAX_CODEWORDS ; idx++)
+ {
+ dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].targetCodeRate = sib1PdschInfo->codeword[idx].targetCodeRate;
+ dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].qamModOrder = sib1PdschInfo->codeword[idx].qamModOrder;
+ dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].mcsIndex = sib1PdschInfo->codeword[idx].mcsIndex;
+ dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].mcsTable = sib1PdschInfo->codeword[idx].mcsTable;
+ dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].rvIndex = sib1PdschInfo->codeword[idx].rvIndex;
+ dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].tbSize = sib1PdschInfo->codeword[idx].tbSize;
+ }
+ dlTtiReqPdu->u.pdsch_pdu.dataScramblingId = sib1PdschInfo->dataScramblingId;
+ dlTtiReqPdu->u.pdsch_pdu.nrOfLayers = sib1PdschInfo->numLayers;
+ dlTtiReqPdu->u.pdsch_pdu.transmissionScheme = sib1PdschInfo->transmissionScheme;
+ dlTtiReqPdu->u.pdsch_pdu.refPoint = sib1PdschInfo->refPoint;
+ dlTtiReqPdu->u.pdsch_pdu.dlDmrsSymbPos = sib1PdschInfo->dmrs.dlDmrsSymbPos;
+ dlTtiReqPdu->u.pdsch_pdu.dmrsConfigType = sib1PdschInfo->dmrs.dmrsConfigType;
+ dlTtiReqPdu->u.pdsch_pdu.dlDmrsScramblingId = sib1PdschInfo->dmrs.dlDmrsScramblingId;
+ dlTtiReqPdu->u.pdsch_pdu.scid = sib1PdschInfo->dmrs.scid;
+ dlTtiReqPdu->u.pdsch_pdu.numDmrsCdmGrpsNoData = sib1PdschInfo->dmrs.numDmrsCdmGrpsNoData;
+ dlTtiReqPdu->u.pdsch_pdu.dmrsPorts = sib1PdschInfo->dmrs.dmrsPorts;
+ dlTtiReqPdu->u.pdsch_pdu.resourceAlloc = sib1PdschInfo->sib1FreqAlloc.resourceAlloc;
+ /* since we are using type-1, hence rbBitmap excluded */
+ dlTtiReqPdu->u.pdsch_pdu.rbStart = sib1PdschInfo->sib1FreqAlloc.rbStart;
+ dlTtiReqPdu->u.pdsch_pdu.rbSize = sib1PdschInfo->sib1FreqAlloc.rbSize;
+ dlTtiReqPdu->u.pdsch_pdu.vrbToPrbMapping = sib1PdschInfo->sib1FreqAlloc.vrbPrbMapping;
+ dlTtiReqPdu->u.pdsch_pdu.startSymbIndex = sib1PdschInfo->sib1TimeAlloc.startSymbolIndex;
+ dlTtiReqPdu->u.pdsch_pdu.nrOfSymbols = sib1PdschInfo->sib1TimeAlloc.numSymbols;
+ dlTtiReqPdu->u.pdsch_pdu.preCodingAndBeamforming.numPrgs = sib1PdschInfo->beamPdschInfo.numPrgs;
+ dlTtiReqPdu->u.pdsch_pdu.preCodingAndBeamforming.prgSize = sib1PdschInfo->beamPdschInfo.prgSize;
+ dlTtiReqPdu->u.pdsch_pdu.preCodingAndBeamforming.digBfInterfaces = sib1PdschInfo->beamPdschInfo.digBfInterfaces;
+ dlTtiReqPdu->u.pdsch_pdu.preCodingAndBeamforming.pmi_bfi[0]. \
+ pmIdx = sib1PdschInfo->beamPdschInfo.prg[0].pmIdx;
+ dlTtiReqPdu->u.pdsch_pdu.preCodingAndBeamforming.pmi_bfi[0]. \
+ beamIdx[0].beamidx = sib1PdschInfo->beamPdschInfo.prg[0].beamIdx[0];
+ dlTtiReqPdu->u.pdsch_pdu.powerControlOffset = sib1PdschInfo->txPdschPower.powerControlOffset;
+ dlTtiReqPdu->u.pdsch_pdu.powerControlOffsetSS = sib1PdschInfo->txPdschPower.powerControlOffsetSS;
+ dlTtiReqPdu->pduSize = sizeof(fapi_dl_pdsch_pdu_t);
+ SETLENGTH(*msgLen, sizeof(fapi_dl_pdsch_pdu_t));
+
+ }
+
+}
+
+/***********************************************************************
+ *
+ * @brief calculates the total size to be allocated for DL TTI Req
+ *
+ * @details
+ *
+ * Function : calculatePduCount
+ *
+ * Functionality:
+ * -calculates the total pdu count to be allocated for DL TTI Req
+ *
+ * @params[in] DlBrdcstAlloc *cellBroadcastInfo
+ * @return count
+ *
+ * ********************************************************************/
+uint8_t calculatePduCount(DlBrdcstAlloc *cellBroadcastInfo)
+{
+ uint8_t count = 0;
+ uint8_t idx = 0;
+ if(cellBroadcastInfo->ssbTrans)
+ {
+ for(idx = 0; idx < cellBroadcastInfo->ssbIdxSupported; idx++)
+ {
+ count++;
+ }
+ }
+ if(cellBroadcastInfo->sib1Trans)
+ {
+ count += 2;
+ }
+ return count;
+}
+
+#endif
+
+/*******************************************************************
+ *
+ * @brief Sends DL TTI Request to PHY
+ *
+ * @details
+ *
+ * Function : handleDlTtiReq
+ *
+ * Functionality:
+ * -Sends FAPI Param req to PHY
+ *
+ * @params[in] RgDlSf *dlTtiReqSlot
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+S16 handleDlTtiReq(CmLteTimingInfo *dlTtiReqtimingInfo)
+{
+#ifdef FAPI
+ uint8_t idx;
+ uint8_t nPdu = 0;
+ uint32_t msgLen = 0;
+ fapi_dl_tti_req_t *dlTtiReq = NULLP;
+ fapi_dl_tti_req_pdu_t *dlTtiReqPdu = NULLP;
+ RgCellCb *cellCbParams = NULLP;
+ MacDlSlot *currDlSlot = NULLP;
+ MacCellCfg macCellCfg;
+ memset(&macCellCfg, 0, sizeof(MacCellCfg));
+ Inst inst = 0;
+
+ if(clGlobalCp.phyState == PHY_STATE_RUNNING)
+ {
+ cellCbParams = rgCb[inst].cell;
+ macCellCfg = cellCbParams->macCellCfg;
+
+ if(dlTtiReqtimingInfo != NULLP)
+ {
+#ifdef INTEL_WLS
+ WLS_MEM_ALLOC(dlTtiReq, sizeof(fapi_dl_tti_req_t));
+#else
+ MAC_ALLOC(dlTtiReq, sizeof(fapi_dl_tti_req_t));
+#endif
+ if(dlTtiReq != NULLP)
+ {
+ dlTtiReq->sfn = dlTtiReqtimingInfo->sfn;
+ dlTtiReq->slot = dlTtiReqtimingInfo->slot;
+ currDlSlot = &macCb.macCell->dlSlot[dlTtiReq->slot % MAX_SLOT_SUPPORTED];
+ dlTtiReq->nPdus = calculatePduCount(&currDlSlot->cellBroadcastInfo); /* get total Pdus */
+ nPdu = dlTtiReq->nPdus;
+ dlTtiReq->nGroup = 0;
+ if(dlTtiReq->nPdus > 0)
+ {
+#ifdef INTEL_WLS
+ WLS_MEM_ALLOC(dlTtiReqPdu, (nPdu * sizeof(fapi_dl_tti_req_pdu_t)));
+#else
+ MAC_ALLOC(dlTtiReqPdu, (nPdu * sizeof(fapi_dl_tti_req_pdu_t)));
+#endif
+ if(currDlSlot->cellBroadcastInfo.ssbTrans)
+ {
+ if(dlTtiReqPdu != NULLP)
+ {
+ for(idx = 0; idx < currDlSlot->cellBroadcastInfo.ssbIdxSupported; idx++)
+ {
+ if(idx > 0)
+ dlTtiReq->pdus++;
+ fillSsbPdu(dlTtiReqPdu, &macCellCfg, currDlSlot, &msgLen, idx);
+ dlTtiReq->pdus = dlTtiReqPdu;
+ }
+ }
+ }
+ if(currDlSlot->cellBroadcastInfo.sib1Trans)
+ {
+ /* Filling SIB1 param */
+ if(dlTtiReqPdu != NULLP)
+ {
+ dlTtiReq->pdus++;
+ fillPdcchPdu(dlTtiReqPdu, &currDlSlot->cellBroadcastInfo.sib1Alloc.sib1PdcchCfg, &msgLen);
+ dlTtiReq->pdus = dlTtiReqPdu;
+ dlTtiReq->pdus++;
+ fillPdschPdu(dlTtiReqPdu, &currDlSlot->cellBroadcastInfo.sib1Alloc.sib1PdschCfg, &msgLen);
+ dlTtiReq->pdus = dlTtiReqPdu;
+ }
+ }
+ msgLen += sizeof(fapi_dl_tti_req_t) - sizeof(fapi_msg_t);
+ fillMsgHeader(&dlTtiReq->header, FAPI_DL_TTI_REQUEST, msgLen);
+ /* TODO : Recheck the size / msglen to be sent to WLS_Put*/
+ LwrMacSendToPhy(dlTtiReq->header.message_type_id, msgLen, (void *)dlTtiReq);
+ if(currDlSlot->cellBroadcastInfo.sib1Trans)
+ {
+ MAC_FREE(dlTtiReqPdu->u.pdcch_pdu.dlDci, sizeof(fapi_dl_dci_t));
+ }
+ MAC_FREE(dlTtiReqPdu, (nPdu * sizeof(fapi_dl_tti_req_pdu_t)));
+ }
+ else
+ {
+ msgLen = sizeof(fapi_dl_tti_req_t) - sizeof(fapi_msg_t);
+ fillMsgHeader(&dlTtiReq->header, FAPI_DL_TTI_REQUEST, msgLen);
+ /* TODO : Recheck the size / msglen to be sent to WLS_Put*/
+ LwrMacSendToPhy(dlTtiReq->header.message_type_id, msgLen, (void *)dlTtiReq);
+ }
+ MAC_FREE(dlTtiReq, sizeof(fapi_dl_tti_req_t));
+ return ROK;
+ }
+ else
+ {
+ DU_LOG("\nLOWER MAC: Failed to allocate memory for DL TTI Request");
+ return RFAILED;
+ }
+ }
+ 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)
+{
+#ifdef FAPI
+ uint8_t idx;
+ if(macCellCfg != NULLP)
+ {
+ idx = macCellCfg->prachCfg.fdm[0].zeroCorrZoneCfg;
+ *numCs = UnrestrictedSetNcsTable[idx];
+ }
+#endif
+}
+
+/***********************************************************************
+ *
+ * @brief Fills the PRACH PDU in UL TTI Request
+ *
+ * @details
+ *
+ * Function : fillPrachPdu
+ *
+ * Functionality:
+ * -Fills the PRACH PDU in UL TTI Request
+ *
+ * @params[in] Pointer to Prach Pdu
+ * Pointer to CurrUlSlot
+ * Pointer to macCellCfg
+ * Pointer to msgLen
+ * ********************************************************************/
+
+#ifdef FAPI
+void fillPrachPdu(fapi_ul_tti_req_pdu_t *ulTtiReqPdu, MacCellCfg *macCellCfg, MacUlSlot *currUlSlot, uint32_t *msgLen)
+{
+ if(ulTtiReqPdu != NULLP)
+ {
+ ulTtiReqPdu->pduType = PRACH_PDU_TYPE;
+ ulTtiReqPdu->u.prach_pdu.physCellId = macCellCfg->phyCellId;
+ ulTtiReqPdu->u.prach_pdu.numPrachOcas = currUlSlot->ulCellInfo.prachSchInfo.numPrachOcas;
+ ulTtiReqPdu->u.prach_pdu.prachFormat = \
+ currUlSlot->ulCellInfo.prachSchInfo.prachFormat;
+ ulTtiReqPdu->u.prach_pdu.numRa = currUlSlot->ulCellInfo.prachSchInfo.numRa;
+ ulTtiReqPdu->u.prach_pdu.prachStartSymbol = \
+ currUlSlot->ulCellInfo.prachSchInfo.prachStartSymb;
+ setNumCs(&ulTtiReqPdu->u.prach_pdu.numCs, macCellCfg);
+ ulTtiReqPdu->u.prach_pdu.beamforming.numPrgs = 0;
+ ulTtiReqPdu->u.prach_pdu.beamforming.prgSize = 0;
+ ulTtiReqPdu->u.prach_pdu.beamforming.digBfInterfaces = 0;
+ ulTtiReqPdu->u.prach_pdu.beamforming.pmi_bfi[0].pmIdx = 0;
+ ulTtiReqPdu->u.prach_pdu.beamforming.pmi_bfi[0].beamIdx[0].beamidx = 0;
+ ulTtiReqPdu->pduSize = sizeof(fapi_ul_prach_pdu_t);
+ SETLENGTH(*msgLen, sizeof(fapi_dl_pdsch_pdu_t));
+ }
+}
+#endif
+
+/*******************************************************************
+ *
+ * @brief Sends UL TTI Request to PHY
+ *
+ * @details
+ *
+ * Function : handleUlTtiReq
+ *
+ * Functionality:
+ * -Sends FAPI Param req to PHY
+ *
+ * @params[in] Pointer to CmLteTimingInfo
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ ******************************************************************/
+S16 handleUlTtiReq(CmLteTimingInfo *currTimingInfo)
+{
+#ifdef FAPI
+ uint32_t msgLen = 0;
+ fapi_ul_tti_req_t *ulTtiReq = NULLP;
+ fapi_ul_tti_req_pdu_t *ulTtiReqPdu = NULLP;
+ RgCellCb *cellCbParams = NULLP;
+ MacUlSlot *currUlSlot = 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(currTimingInfo != NULLP)
+ {
+#ifdef INTEL_WLS
+ WLS_MEM_ALLOC(ulTtiReq, sizeof(fapi_ul_tti_req_t));
+#else
+ MAC_ALLOC(ulTtiReq, sizeof(fapi_ul_tti_req_t));
+#endif
+ if(ulTtiReq != NULLP)
+ {
+ ulTtiReq->sfn = currTimingInfo->sfn;
+ ulTtiReq->slot = currTimingInfo->slot;
+ currUlSlot = &macCb.macCell->ulSlot[ulTtiReq->slot % MAX_SLOT_SUPPORTED];
+ ulTtiReq->nPdus = getnPdus(ulTtiReq, currUlSlot);
+ ulTtiReq->nGroup = 0;
+ if(ulTtiReq->nPdus > 0)
+ {
+#ifdef INTEL_WLS
+ WLS_MEM_ALLOC(ulTtiReqPdu, (ulTtiReq->nPdus * sizeof(fapi_ul_tti_req_pdu_t)));
+#else
+ MAC_ALLOC(ulTtiReqPdu, (ulTtiReq->nPdus * sizeof(fapi_ul_tti_req_pdu_t)));
+#endif
+ /* Fill Prach Pdu */
+ if(ulTtiReq->rachPresent)
+ {
+ if(ulTtiReqPdu != NULLP)
+ {
+ fillPrachPdu(ulTtiReqPdu, &macCellCfg, currUlSlot, &msgLen);
+ ulTtiReq->pdus = ulTtiReqPdu;
+ }
+ msgLen = sizeof(fapi_ul_tti_req_t) - sizeof(fapi_msg_t);
+ fillMsgHeader(&ulTtiReq->header, FAPI_UL_TTI_REQUEST, msgLen);
+ LwrMacSendToPhy(ulTtiReq->header.message_type_id, msgLen, (void *)ulTtiReq);
+ MAC_FREE(ulTtiReqPdu, (ulTtiReq->nPdus * sizeof(fapi_ul_tti_req_pdu_t)));
+ }
+ }
+ else
+ {
+ msgLen = sizeof(fapi_ul_tti_req_t) - sizeof(fapi_msg_t);
+ fillMsgHeader(&ulTtiReq->header, FAPI_UL_TTI_REQUEST, msgLen);
+ LwrMacSendToPhy(ulTtiReq->header.message_type_id, msgLen, (void *)ulTtiReq);
+ }
+ MAC_FREE(ulTtiReq, sizeof(fapi_ul_tti_req_t));
+ return ROK;
+ }
+ else
+ {
+ DU_LOG("\nLOWER MAC: Failed to allocate memory for UL TTI Request");
+ return RFAILED;
+ }
+ }
+ else
+ {
+ DU_LOG("\nLOWER MAC: Current TTI Info in UL is NULL");
+ return RFAILED;
+ }
+ }
+ else
+ {
+ lwr_mac_handleInvalidEvt(currTimingInfo);
+ }
+#endif
+ return ROK;