+ * @params[in] Pointer to fapi_dl_dci_t
+ * Pointer to PdcchCfg
+ * @return ROK
+ *
+ ******************************************************************/
+
+void fillSib1DlDciPdu(fapi_dl_dci_t *dlDciPtr, PdcchCfg *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->dci.rnti;
+ dlDciPtr->scramblingId = sib1PdcchInfo->dci.scramblingId;
+ dlDciPtr->scramblingRnti = sib1PdcchInfo->dci.scramblingRnti;
+ dlDciPtr->cceIndex = sib1PdcchInfo->dci.cceIndex;
+ dlDciPtr->aggregationLevel = sib1PdcchInfo->dci.aggregLevel;
+ dlDciPtr->pc_and_bform.numPrgs = sib1PdcchInfo->dci.beamPdcchInfo.numPrgs;
+ dlDciPtr->pc_and_bform.prgSize = sib1PdcchInfo->dci.beamPdcchInfo.prgSize;
+ dlDciPtr->pc_and_bform.digBfInterfaces = sib1PdcchInfo->dci.beamPdcchInfo.digBfInterfaces;
+ dlDciPtr->pc_and_bform.pmi_bfi[0].pmIdx = sib1PdcchInfo->dci.beamPdcchInfo.prg[0].pmIdx;
+ dlDciPtr->pc_and_bform.pmi_bfi[0].beamIdx[0].beamidx = sib1PdcchInfo->dci.beamPdcchInfo.prg[0].beamIdx[0];
+ dlDciPtr->beta_pdcch_1_0 = sib1PdcchInfo->dci.txPdcchPower.powerValue;
+ dlDciPtr->powerControlOfssetSS = sib1PdcchInfo->dci.txPdcchPower.powerControlOffsetSS;
+
+ /* Calculating freq domain resource allocation field value and size
+ * coreset0Size = Size of coreset 0
+ * RBStart = Starting Virtual Rsource block
+ * RBLen = length of contiguously allocted RBs
+ * Spec 38.214 Sec 5.1.2.2.2
+ */
+ coreset0Size= sib1PdcchInfo->coresetCfg.coreSetSize;
+ rbStart = 0; /* For SIB1 */
+ //rbStart = sib1PdcchInfo->dci.pdschCfg->pdschFreqAlloc.freqAlloc.startPrb;
+ rbLen = sib1PdcchInfo->dci.pdschCfg->pdschFreqAlloc.freqAlloc.numPrb;
+
+ 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->dci.pdschCfg->pdschTimeAlloc.
+ rowIndex -1;
+ VRB2PRBMap = sib1PdcchInfo->dci.pdschCfg->pdschFreqAlloc.\
+ vrbPrbMapping;
+ modNCodScheme = sib1PdcchInfo->dci.pdschCfg->codeword[0].mcsIndex;
+ redundancyVer = sib1PdcchInfo->dci.pdschCfg->codeword[0].rvIndex;
+ sysInfoInd = 0; /* 0 for SIB1; 1 for SI messages */
+ reserved = 0;
+
+ /* 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);
+
+ /* 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 > 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++)
+ 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);
+
+ }
+} /* fillSib1DlDciPdu */
+
+/*******************************************************************
+ *
+ * @brief fills Dl DCI PDU required for DL TTI info in MAC
+ *
+ * @details
+ *
+ * Function : fillRarDlDciPdu
+ *
+ * Functionality:
+ * -Fills the Dl DCI PDU
+ *
+ * @params[in] Pointer to fapi_dl_dci_t
+ * Pointer to PdcchCfg
+ * @return ROK
+ *
+ ******************************************************************/
+
+void fillRarDlDciPdu(fapi_dl_dci_t *dlDciPtr, PdcchCfg *rarPdcchInfo)
+{
+ if(dlDciPtr != NULLP)
+ {
+ uint8_t numBytes;
+ uint8_t bytePos;
+ uint8_t bitPos;
+
+ uint16_t coreset0Size;
+ uint16_t rbStart;
+ uint16_t rbLen;
+ uint32_t freqDomResAssign;
+ uint8_t timeDomResAssign;
+ uint8_t VRB2PRBMap;
+ uint8_t modNCodScheme;
+ uint8_t tbScaling;
+ uint32_t reserved;
+
+ /* Size(in bits) of each field in DCI format 1_0 */
+ uint8_t freqDomResAssignSize;
+ uint8_t timeDomResAssignSize = 4;
+ uint8_t VRB2PRBMapSize = 1;
+ uint8_t modNCodSchemeSize = 5;
+ uint8_t tbScalingSize = 2;
+ uint8_t reservedSize = 16;
+
+ dlDciPtr->rnti = rarPdcchInfo->dci.rnti;
+ dlDciPtr->scramblingId = rarPdcchInfo->dci.scramblingId;
+ dlDciPtr->scramblingRnti = rarPdcchInfo->dci.scramblingRnti;
+ dlDciPtr->cceIndex = rarPdcchInfo->dci.cceIndex;
+ dlDciPtr->aggregationLevel = rarPdcchInfo->dci.aggregLevel;
+ dlDciPtr->pc_and_bform.numPrgs = rarPdcchInfo->dci.beamPdcchInfo.numPrgs;
+ dlDciPtr->pc_and_bform.prgSize = rarPdcchInfo->dci.beamPdcchInfo.prgSize;
+ dlDciPtr->pc_and_bform.digBfInterfaces = rarPdcchInfo->dci.beamPdcchInfo.digBfInterfaces;
+ dlDciPtr->pc_and_bform.pmi_bfi[0].pmIdx = rarPdcchInfo->dci.beamPdcchInfo.prg[0].pmIdx;
+ dlDciPtr->pc_and_bform.pmi_bfi[0].beamIdx[0].beamidx = rarPdcchInfo->dci.beamPdcchInfo.prg[0].beamIdx[0];
+ dlDciPtr->beta_pdcch_1_0 = rarPdcchInfo->dci.txPdcchPower.powerValue;
+ dlDciPtr->powerControlOfssetSS = rarPdcchInfo->dci.txPdcchPower.powerControlOffsetSS;
+
+ /* Calculating freq domain resource allocation field value and size
+ * coreset0Size = Size of coreset 0
+ * RBStart = Starting Virtual Rsource block
+ * RBLen = length of contiguously allocted RBs
+ * Spec 38.214 Sec 5.1.2.2.2
+ */
+
+ /* TODO: Fill values of coreset0Size, rbStart and rbLen */
+ coreset0Size= rarPdcchInfo->coresetCfg.coreSetSize;
+ rbStart = 0; /* For SIB1 */
+ //rbStart = rarPdcchInfo->dci.pdschCfg->freqAlloc.rbStart;
+ rbLen = rarPdcchInfo->dci.pdschCfg->pdschFreqAlloc.freqAlloc.numPrb;
+
+ if((rbLen >=1) && (rbLen <= coreset0Size - rbStart))
+ {
+ if((rbLen - 1) <= floor(coreset0Size / 2))
+ freqDomResAssign = (coreset0Size * (rbLen-1)) + rbStart;
+ else
+ freqDomResAssign = (coreset0Size * (coreset0Size - rbLen + 1)) \
+ + (coreset0Size - 1 - rbStart);
+
+ freqDomResAssignSize = ceil(log2(coreset0Size * (coreset0Size + 1) / 2));
+ }
+
+ /* Fetching DCI field values */
+ timeDomResAssign = rarPdcchInfo->dci.pdschCfg->pdschTimeAlloc.rowIndex -1;
+ VRB2PRBMap = rarPdcchInfo->dci.pdschCfg->pdschFreqAlloc.vrbPrbMapping;
+ modNCodScheme = rarPdcchInfo->dci.pdschCfg->codeword[0].mcsIndex;
+ tbScaling = 0; /* configured to 0 scaling */
+ reserved = 0;
+
+ /* Reversing bits in each DCI field */
+ freqDomResAssign = reverseBits(freqDomResAssign, freqDomResAssignSize);
+ timeDomResAssign = reverseBits(timeDomResAssign, timeDomResAssignSize);
+ VRB2PRBMap = reverseBits(VRB2PRBMap, VRB2PRBMapSize);
+ modNCodScheme = reverseBits(modNCodScheme, modNCodSchemeSize);
+ tbScaling = reverseBits(tbScaling, tbScalingSize);
+
+ /* Calulating total number of bytes in buffer */
+ dlDciPtr->payloadSizeBits = freqDomResAssignSize + timeDomResAssignSize\
+ + VRB2PRBMapSize + modNCodSchemeSize + tbScalingSize + reservedSize;
+
+ numBytes = dlDciPtr->payloadSizeBits / 8;
+ if(dlDciPtr->payloadSizeBits % 8)
+ numBytes += 1;
+
+ if(numBytes > 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++)
+ dlDciPtr->payload[bytePos] = 0;
+
+ bytePos = numBytes - 1;
+ bitPos = 0;
+
+ /* Packing DCI format fields */
+ fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
+ freqDomResAssign, freqDomResAssignSize);
+ fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
+ timeDomResAssign, timeDomResAssignSize);
+ fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
+ VRB2PRBMap, VRB2PRBMapSize);
+ fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
+ modNCodScheme, modNCodSchemeSize);
+ fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
+ tbScaling, tbScalingSize);
+ fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
+ reserved, reservedSize);
+ }
+} /* fillRarDlDciPdu */
+
+/*******************************************************************
+ *
+ * @brief fills DL DCI PDU required for DL TTI info in MAC
+ *
+ * @details
+ *
+ * Function : fillDlMsgDlDciPdu
+ *
+ * Functionality:
+ * -Fills the Dl DCI PDU
+ *
+ * @params[in] Pointer to fapi_dl_dci_t
+ * Pointer to PdcchCfg
+ * @return ROK
+ *
+ ******************************************************************/
+void fillDlMsgDlDciPdu(fapi_dl_dci_t *dlDciPtr, PdcchCfg *pdcchInfo,\
+ DlMsgInfo *dlMsgInfo)
+{
+ if(dlDciPtr != NULLP)
+ {
+ uint8_t numBytes;
+ uint8_t bytePos;
+ uint8_t bitPos;
+
+ uint16_t coresetSize = 0;
+ uint16_t rbStart = 0;
+ uint16_t rbLen = 0;
+ uint8_t dciFormatId;
+ uint32_t freqDomResAssign;
+ uint8_t timeDomResAssign;
+ uint8_t VRB2PRBMap;
+ uint8_t modNCodScheme;
+ uint8_t ndi = 0;
+ uint8_t redundancyVer = 0;
+ uint8_t harqProcessNum = 0;
+ uint8_t dlAssignmentIdx = 0;
+ uint8_t pucchTpc = 0;
+ uint8_t pucchResoInd = 0;
+ uint8_t harqFeedbackInd = 0;
+
+ /* Size(in bits) of each field in DCI format 1_0 */
+ uint8_t dciFormatIdSize = 1;
+ uint8_t freqDomResAssignSize = 0;
+ uint8_t timeDomResAssignSize = 4;
+ uint8_t VRB2PRBMapSize = 1;
+ uint8_t modNCodSchemeSize = 5;
+ uint8_t ndiSize = 1;
+ uint8_t redundancyVerSize = 2;
+ uint8_t harqProcessNumSize = 4;
+ uint8_t dlAssignmentIdxSize = 2;
+ uint8_t pucchTpcSize = 2;
+ uint8_t pucchResoIndSize = 3;
+ uint8_t harqFeedbackIndSize = 3;
+
+ dlDciPtr->rnti = pdcchInfo->dci.rnti;
+ dlDciPtr->scramblingId = pdcchInfo->dci.scramblingId;
+ dlDciPtr->scramblingRnti = pdcchInfo->dci.scramblingRnti;
+ dlDciPtr->cceIndex = pdcchInfo->dci.cceIndex;
+ dlDciPtr->aggregationLevel = pdcchInfo->dci.aggregLevel;
+ dlDciPtr->pc_and_bform.numPrgs = pdcchInfo->dci.beamPdcchInfo.numPrgs;
+ dlDciPtr->pc_and_bform.prgSize = pdcchInfo->dci.beamPdcchInfo.prgSize;
+ dlDciPtr->pc_and_bform.digBfInterfaces = pdcchInfo->dci.beamPdcchInfo.digBfInterfaces;
+ dlDciPtr->pc_and_bform.pmi_bfi[0].pmIdx = pdcchInfo->dci.beamPdcchInfo.prg[0].pmIdx;
+ dlDciPtr->pc_and_bform.pmi_bfi[0].beamIdx[0].beamidx = pdcchInfo->dci.beamPdcchInfo.prg[0].beamIdx[0];
+ dlDciPtr->beta_pdcch_1_0 = pdcchInfo->dci.txPdcchPower.powerValue;
+ dlDciPtr->powerControlOfssetSS = pdcchInfo->dci.txPdcchPower.powerControlOffsetSS;
+
+ /* Calculating freq domain resource allocation field value and size
+ * coreset0Size = Size of coreset 0
+ * RBStart = Starting Virtual Rsource block
+ * RBLen = length of contiguously allocted RBs
+ * Spec 38.214 Sec 5.1.2.2.2
+ */
+ coresetSize = pdcchInfo->coresetCfg.coreSetSize;
+ rbStart = pdcchInfo->dci.pdschCfg->pdschFreqAlloc.freqAlloc.startPrb;
+ rbLen = pdcchInfo->dci.pdschCfg->pdschFreqAlloc.freqAlloc.numPrb;
+
+ if((rbLen >=1) && (rbLen <= coresetSize - rbStart))
+ {
+ if((rbLen - 1) <= floor(coresetSize / 2))
+ freqDomResAssign = (coresetSize * (rbLen-1)) + rbStart;
+ else
+ freqDomResAssign = (coresetSize * (coresetSize - rbLen + 1)) \
+ + (coresetSize - 1 - rbStart);
+
+ freqDomResAssignSize = ceil(log2(coresetSize * (coresetSize + 1) / 2));
+ }
+
+ /* Fetching DCI field values */
+ dciFormatId = dlMsgInfo->dciFormatId;; /* Always set to 1 for DL */
+ timeDomResAssign = pdcchInfo->dci.pdschCfg->pdschTimeAlloc.rowIndex -1;
+ VRB2PRBMap = pdcchInfo->dci.pdschCfg->pdschFreqAlloc.vrbPrbMapping;
+ modNCodScheme = pdcchInfo->dci.pdschCfg->codeword[0].mcsIndex;
+ ndi = dlMsgInfo->ndi;
+ redundancyVer = pdcchInfo->dci.pdschCfg->codeword[0].rvIndex;
+ harqProcessNum = dlMsgInfo->harqProcNum;
+ dlAssignmentIdx = dlMsgInfo->dlAssignIdx;
+ pucchTpc = dlMsgInfo->pucchTpc;
+ pucchResoInd = dlMsgInfo->pucchResInd;
+ harqFeedbackInd = dlMsgInfo->harqFeedbackInd;
+
+ /* Reversing bits in each DCI field */
+ dciFormatId = reverseBits(dciFormatId, dciFormatIdSize);
+ freqDomResAssign = reverseBits(freqDomResAssign, freqDomResAssignSize);
+ timeDomResAssign = reverseBits(timeDomResAssign, timeDomResAssignSize);
+ VRB2PRBMap = reverseBits(VRB2PRBMap, VRB2PRBMapSize);
+ modNCodScheme = reverseBits(modNCodScheme, modNCodSchemeSize);
+ ndi = reverseBits(ndi, ndiSize);
+ redundancyVer = reverseBits(redundancyVer, redundancyVerSize);
+ harqProcessNum = reverseBits(harqProcessNum, harqProcessNumSize);
+ dlAssignmentIdx = reverseBits(dlAssignmentIdx , dlAssignmentIdxSize);
+ pucchTpc = reverseBits(pucchTpc, pucchTpcSize);
+ pucchResoInd = reverseBits(pucchResoInd, pucchResoIndSize);
+ harqFeedbackInd = reverseBits(harqFeedbackInd, harqFeedbackIndSize);
+
+
+ /* Calulating total number of bytes in buffer */
+ dlDciPtr->payloadSizeBits = (dciFormatIdSize + freqDomResAssignSize\
+ + timeDomResAssignSize + VRB2PRBMapSize + modNCodSchemeSize\
+ + ndiSize + redundancyVerSize + harqProcessNumSize + dlAssignmentIdxSize\
+ + pucchTpcSize + pucchResoIndSize + harqFeedbackIndSize);
+
+ numBytes = dlDciPtr->payloadSizeBits / 8;
+ if(dlDciPtr->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++)
+ dlDciPtr->payload[bytePos] = 0;
+
+ bytePos = numBytes - 1;
+ bitPos = 0;
+
+ /* Packing DCI format fields */
+ fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
+ dciFormatId, dciFormatIdSize);
+ 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,\
+ ndi, ndiSize);
+ fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
+ redundancyVer, redundancyVerSize);
+ fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
+ redundancyVer, redundancyVerSize);
+ fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
+ harqProcessNum, harqProcessNumSize);
+ fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
+ dlAssignmentIdx, dlAssignmentIdxSize);
+ fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
+ pucchTpc, pucchTpcSize);
+ fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
+ pucchResoInd, pucchResoIndSize);
+ fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
+ harqFeedbackInd, harqFeedbackIndSize);
+ }
+}
+
+/*******************************************************************
+ *
+ * @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 PdcchCfg
+ * @return ROK
+ *
+ ******************************************************************/
+uint8_t fillPdcchPdu(fapi_dl_tti_req_pdu_t *dlTtiReqPdu, DlSchedInfo *dlInfo, \
+ RntiType rntiType, uint8_t coreSetType)
+{
+ if(dlTtiReqPdu != NULLP)
+ {
+ PdcchCfg *pdcchInfo = NULLP;
+ BwpCfg *bwp = NULLP;
+
+ memset(&dlTtiReqPdu->pdu.pdcch_pdu, 0, sizeof(fapi_dl_pdcch_pdu_t));
+ if(rntiType == SI_RNTI_TYPE)
+ {
+ pdcchInfo = &dlInfo->brdcstAlloc.sib1Alloc.sib1PdcchCfg;
+ bwp = &dlInfo->brdcstAlloc.sib1Alloc.bwp;
+ fillSib1DlDciPdu(dlTtiReqPdu->pdu.pdcch_pdu.dlDci, pdcchInfo);
+ }
+ else if(rntiType == RA_RNTI_TYPE)
+ {
+ pdcchInfo = &dlInfo->rarAlloc->rarPdcchCfg;
+ bwp = &dlInfo->rarAlloc->bwp;
+ fillRarDlDciPdu(dlTtiReqPdu->pdu.pdcch_pdu.dlDci, pdcchInfo);
+ }
+ else if(rntiType == TC_RNTI_TYPE || rntiType == C_RNTI_TYPE)
+ {
+ pdcchInfo = &dlInfo->dlMsgAlloc->dlMsgPdcchCfg;
+ bwp = &dlInfo->dlMsgAlloc->bwp;
+ fillDlMsgDlDciPdu(dlTtiReqPdu->pdu.pdcch_pdu.dlDci, pdcchInfo,\
+ &dlInfo->dlMsgAlloc->dlMsgInfo);
+ }
+ else
+ {
+ DU_LOG("\nLWR_MAC: Failed filling PDCCH Pdu");
+ return RFAILED;;
+ }
+ dlTtiReqPdu->pduType = PDCCH_PDU_TYPE;
+ dlTtiReqPdu->pdu.pdcch_pdu.bwpSize = bwp->freqAlloc.numPrb;
+ dlTtiReqPdu->pdu.pdcch_pdu.bwpStart = bwp->freqAlloc.startPrb;
+ dlTtiReqPdu->pdu.pdcch_pdu.subCarrierSpacing = bwp->subcarrierSpacing;
+ dlTtiReqPdu->pdu.pdcch_pdu.cyclicPrefix = bwp->cyclicPrefix;
+ dlTtiReqPdu->pdu.pdcch_pdu.startSymbolIndex = pdcchInfo->coresetCfg.startSymbolIndex;
+ dlTtiReqPdu->pdu.pdcch_pdu.durationSymbols = pdcchInfo->coresetCfg.durationSymbols;
+ memcpy(dlTtiReqPdu->pdu.pdcch_pdu.freqDomainResource, pdcchInfo->coresetCfg.freqDomainResource, 6);
+ dlTtiReqPdu->pdu.pdcch_pdu.cceRegMappingType = pdcchInfo->coresetCfg.cceRegMappingType;
+ dlTtiReqPdu->pdu.pdcch_pdu.regBundleSize = pdcchInfo->coresetCfg.regBundleSize;
+ dlTtiReqPdu->pdu.pdcch_pdu.interleaverSize = pdcchInfo->coresetCfg.interleaverSize;
+ dlTtiReqPdu->pdu.pdcch_pdu.coreSetSize = pdcchInfo->coresetCfg.coreSetType;
+ dlTtiReqPdu->pdu.pdcch_pdu.shiftIndex = pdcchInfo->coresetCfg.shiftIndex;
+ dlTtiReqPdu->pdu.pdcch_pdu.precoderGranularity = pdcchInfo->coresetCfg.precoderGranularity;
+ dlTtiReqPdu->pdu.pdcch_pdu.numDlDci = pdcchInfo->numDlDci;
+ dlTtiReqPdu->pdu.pdcch_pdu.coreSetType = coreSetType;
+
+ /* Calculating PDU length. Considering only one dl dci pdu for now */
+ dlTtiReqPdu->pduSize = 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 PdschCfg
+ * Pointer to msgLen of DL TTI Info
+ * @return ROK
+ *
+ ******************************************************************/
+
+void fillPdschPdu(fapi_dl_tti_req_pdu_t *dlTtiReqPdu, PdschCfg *pdschInfo,
+ BwpCfg bwp, uint16_t pduIndex)
+{
+ uint8_t idx;
+
+ if(dlTtiReqPdu != NULLP)
+ {
+ dlTtiReqPdu->pduType = PDSCH_PDU_TYPE;
+ memset(&dlTtiReqPdu->pdu.pdsch_pdu, 0, sizeof(fapi_dl_pdsch_pdu_t));
+ dlTtiReqPdu->pdu.pdsch_pdu.pduBitMap = pdschInfo->pduBitmap;
+ dlTtiReqPdu->pdu.pdsch_pdu.rnti = pdschInfo->rnti;
+ dlTtiReqPdu->pdu.pdsch_pdu.pdu_index = pduIndex;
+ dlTtiReqPdu->pdu.pdsch_pdu.bwpSize = bwp.freqAlloc.numPrb;
+ dlTtiReqPdu->pdu.pdsch_pdu.bwpStart = bwp.freqAlloc.startPrb;
+ dlTtiReqPdu->pdu.pdsch_pdu.subCarrierSpacing = bwp.subcarrierSpacing;
+ dlTtiReqPdu->pdu.pdsch_pdu.cyclicPrefix = bwp.cyclicPrefix;
+ dlTtiReqPdu->pdu.pdsch_pdu.nrOfCodeWords = pdschInfo->numCodewords;
+ for(idx = 0; idx < MAX_CODEWORDS ; idx++)
+ {
+ dlTtiReqPdu->pdu.pdsch_pdu.cwInfo[idx].targetCodeRate = pdschInfo->codeword[idx].targetCodeRate;
+ dlTtiReqPdu->pdu.pdsch_pdu.cwInfo[idx].qamModOrder = pdschInfo->codeword[idx].qamModOrder;
+ dlTtiReqPdu->pdu.pdsch_pdu.cwInfo[idx].mcsIndex = pdschInfo->codeword[idx].mcsIndex;
+ dlTtiReqPdu->pdu.pdsch_pdu.cwInfo[idx].mcsTable = pdschInfo->codeword[idx].mcsTable;
+ dlTtiReqPdu->pdu.pdsch_pdu.cwInfo[idx].rvIndex = pdschInfo->codeword[idx].rvIndex;
+ dlTtiReqPdu->pdu.pdsch_pdu.cwInfo[idx].tbSize = pdschInfo->codeword[idx].tbSize;
+ }
+ dlTtiReqPdu->pdu.pdsch_pdu.dataScramblingId = pdschInfo->dataScramblingId;
+ dlTtiReqPdu->pdu.pdsch_pdu.nrOfLayers = pdschInfo->numLayers;
+ dlTtiReqPdu->pdu.pdsch_pdu.transmissionScheme = pdschInfo->transmissionScheme;
+ dlTtiReqPdu->pdu.pdsch_pdu.refPoint = pdschInfo->refPoint;
+ dlTtiReqPdu->pdu.pdsch_pdu.dlDmrsSymbPos = pdschInfo->dmrs.dlDmrsSymbPos;
+ dlTtiReqPdu->pdu.pdsch_pdu.dmrsConfigType = pdschInfo->dmrs.dmrsConfigType;
+ dlTtiReqPdu->pdu.pdsch_pdu.dlDmrsScramblingId = pdschInfo->dmrs.dlDmrsScramblingId;
+ dlTtiReqPdu->pdu.pdsch_pdu.scid = pdschInfo->dmrs.scid;
+ dlTtiReqPdu->pdu.pdsch_pdu.numDmrsCdmGrpsNoData = pdschInfo->dmrs.numDmrsCdmGrpsNoData;
+ dlTtiReqPdu->pdu.pdsch_pdu.dmrsPorts = pdschInfo->dmrs.dmrsPorts;
+ dlTtiReqPdu->pdu.pdsch_pdu.resourceAlloc = pdschInfo->pdschFreqAlloc.resourceAllocType;
+ /* since we are using type-1, hence rbBitmap excluded */
+ dlTtiReqPdu->pdu.pdsch_pdu.rbStart = pdschInfo->pdschFreqAlloc.freqAlloc.startPrb;
+ dlTtiReqPdu->pdu.pdsch_pdu.rbSize = pdschInfo->pdschFreqAlloc.freqAlloc.numPrb;
+ dlTtiReqPdu->pdu.pdsch_pdu.vrbToPrbMapping = pdschInfo->pdschFreqAlloc.vrbPrbMapping;
+ dlTtiReqPdu->pdu.pdsch_pdu.startSymbIndex = pdschInfo->pdschTimeAlloc.timeAlloc.startSymb;
+ dlTtiReqPdu->pdu.pdsch_pdu.nrOfSymbols = pdschInfo->pdschTimeAlloc.timeAlloc.numSymb;
+ dlTtiReqPdu->pdu.pdsch_pdu.preCodingAndBeamforming.numPrgs = pdschInfo->beamPdschInfo.numPrgs;
+ dlTtiReqPdu->pdu.pdsch_pdu.preCodingAndBeamforming.prgSize = pdschInfo->beamPdschInfo.prgSize;
+ dlTtiReqPdu->pdu.pdsch_pdu.preCodingAndBeamforming.digBfInterfaces = pdschInfo->beamPdschInfo.digBfInterfaces;
+ dlTtiReqPdu->pdu.pdsch_pdu.preCodingAndBeamforming.pmi_bfi[0]. \
+ pmIdx = pdschInfo->beamPdschInfo.prg[0].pmIdx;
+ dlTtiReqPdu->pdu.pdsch_pdu.preCodingAndBeamforming.pmi_bfi[0]. \
+ beamIdx[0].beamidx = pdschInfo->beamPdschInfo.prg[0].beamIdx[0];
+ dlTtiReqPdu->pdu.pdsch_pdu.powerControlOffset = pdschInfo->txPdschPower.powerControlOffset;
+ dlTtiReqPdu->pdu.pdsch_pdu.powerControlOffsetSS = pdschInfo->txPdschPower.powerControlOffsetSS;
+ dlTtiReqPdu->pdu.pdsch_pdu.mappingType = pdschInfo->dmrs.mappingType;
+ dlTtiReqPdu->pdu.pdsch_pdu.nrOfDmrsSymbols = pdschInfo->dmrs.nrOfDmrsSymbols;
+ dlTtiReqPdu->pdu.pdsch_pdu.dmrsAddPos = pdschInfo->dmrs.dmrsAddPos;
+
+ dlTtiReqPdu->pduSize = sizeof(fapi_dl_pdsch_pdu_t);
+ }
+}
+
+/***********************************************************************
+ *
+ * @brief calculates the total size to be allocated for DL TTI Req
+ *
+ * @details
+ *
+ * Function : calcDlTtiReqPduCount
+ *
+ * Functionality:
+ * -calculates the total pdu count to be allocated for DL TTI Req
+ *
+ * @params[in] DlBrdcstAlloc *cellBroadcastInfo
+ * @return count
+ *
+ * ********************************************************************/
+uint8_t calcDlTtiReqPduCount(DlSchedInfo *dlInfo)
+{
+ uint8_t count = 0;
+ uint8_t idx = 0;
+
+ if(dlInfo->isBroadcastPres)
+ {
+ if(dlInfo->brdcstAlloc.ssbTrans)
+ {
+ for(idx = 0; idx < dlInfo->brdcstAlloc.ssbIdxSupported; idx++)
+ {
+ /* SSB PDU is filled */
+ count++;
+ }
+ }
+ if(dlInfo->brdcstAlloc.sib1Trans)
+ {
+ /* PDCCH and PDSCH PDU is filled */
+ count += 2;
+ }
+ }
+ if(dlInfo->rarAlloc != NULLP)
+ {
+ /* PDCCH and PDSCH PDU is filled */
+ count += 2;
+ }
+ if(dlInfo->dlMsgAlloc != NULLP)
+ {
+ /* PDCCH and PDSCH PDU is filled */
+ count += 2;
+ }
+ return count;
+}
+
+/***********************************************************************
+ *
+ * @brief calculates the total size to be allocated for DL TTI Req
+ *
+ * @details
+ *
+ * Function : calcTxDataReqPduCount
+ *
+ * Functionality:
+ * -calculates the total pdu count to be allocated for DL TTI Req
+ *
+ * @params[in] DlBrdcstAlloc *cellBroadcastInfo
+ * @return count
+ *
+ * ********************************************************************/
+uint8_t calcTxDataReqPduCount(DlSchedInfo *dlInfo)
+{
+ uint8_t count = 0;
+
+ if(dlInfo->isBroadcastPres && dlInfo->brdcstAlloc.sib1Trans)
+ {
+ count++;
+ }
+ if(dlInfo->rarAlloc != NULLP)
+ {
+ count++;
+ }
+ if(dlInfo->dlMsgAlloc != NULLP)
+ {
+ count++;
+ }
+ return count;
+}
+/***********************************************************************
+ *
+ * @brief fills the SIB1 TX-DATA request message
+ *
+ * @details
+ *
+ * Function : fillSib1TxDataReq
+ *
+ * Functionality:
+ * - fills the SIB1 TX-DATA request message
+ *
+ * @params[in] fapi_tx_pdu_desc_t *pduDesc
+ * @params[in] macCellCfg consist of SIB1 pdu
+ * @params[in] uint32_t *msgLen
+ * @params[in] uint16_t pduIndex
+ * @return ROK
+ *
+ * ********************************************************************/
+uint8_t fillSib1TxDataReq(fapi_tx_pdu_desc_t *pduDesc,MacCellCfg *macCellCfg,
+ uint16_t pduIndex)
+{
+ uint32_t pduLen = 0;
+ uint8_t *sib1TxdataValue = NULLP;
+
+ pduDesc[pduIndex].pdu_index = pduIndex;
+ pduDesc[pduIndex].num_tlvs = 1;
+
+ /* fill the TLV */
+ /* as of now, memory is allocated from SSI, later WLS memory needs to be taken */
+ pduDesc[pduIndex].tlvs[0].tl.tag = 1; /* pointer to be sent */
+ pduDesc[pduIndex].tlvs[0].tl.length = macCellCfg->sib1Cfg.sib1PduLen;
+ LWR_MAC_ALLOC(sib1TxdataValue,macCellCfg->sib1Cfg.sib1PduLen);
+ if(sib1TxdataValue == NULLP)
+ {
+ return RFAILED;
+ }
+ memcpy(sib1TxdataValue,macCellCfg->sib1Cfg.sib1Pdu,
+ macCellCfg->sib1Cfg.sib1PduLen);
+ pduDesc[pduIndex].tlvs[0].value = sib1TxdataValue;
+
+ /* The total length of the PDU description and PDU data */
+ pduLen += 8; /* size of PDU length 2 bytes, PDU index 2 bytes, numTLV 4 bytes */
+ pduLen += sizeof(fapi_uint8_ptr_tlv_t); /* only 1 TLV is present */
+ pduDesc[pduIndex].pdu_length = pduLen;
+
+#ifndef INTEL_WLS
+ MAC_FREE(sib1TxdataValue,macCellCfg->sib1Cfg.sib1PduLen);
+#endif
+
+ return ROK;
+}
+
+/***********************************************************************
+ *
+ * @brief fills the RAR TX-DATA request message
+ *
+ * @details
+ *
+ * Function : fillRarTxDataReq
+ *
+ * Functionality:
+ * - fills the RAR TX-DATA request message
+ *
+ * @params[in] fapi_tx_pdu_desc_t *pduDesc
+ * @params[in] RarInfo *rarInfo
+ * @params[in] uint32_t *msgLen
+ * @params[in] uint16_t pduIndex
+ * @return ROK
+ *
+ * ********************************************************************/
+uint8_t fillRarTxDataReq(fapi_tx_pdu_desc_t *pduDesc, RarInfo *rarInfo,
+ uint16_t pduIndex)
+{
+ uint32_t pduLen = 0;
+ uint8_t *rarTxdataValue = NULLP;
+
+ pduDesc[pduIndex].pdu_index = pduIndex;
+ pduDesc[pduIndex].num_tlvs = 1;
+
+ /* fill the TLV */
+ /* as of now, memory is allocated from SSI, later WLS memory needs to be taken */
+ pduDesc[pduIndex].tlvs[0].tl.tag = 1; /* pointer to be sent */
+ pduDesc[pduIndex].tlvs[0].tl.length = rarInfo->rarPduLen;
+ LWR_MAC_ALLOC(rarTxdataValue,rarInfo->rarPduLen);
+ if(rarTxdataValue == NULLP)
+ {
+ return RFAILED;
+ }
+ memcpy(rarTxdataValue,rarInfo->rarPdu,rarInfo->rarPduLen);
+ pduDesc[pduIndex].tlvs[0].value = rarTxdataValue;
+
+ /* The total length of the PDU description and PDU data */
+ pduLen += 8; /* size of PDU length 2 bytes, PDU index 2 bytes, numTLV 4 bytes */
+ pduLen += sizeof(fapi_uint8_ptr_tlv_t); /* only 1 TLV is present */
+ pduDesc[pduIndex].pdu_length = pduLen;
+
+ /* TODO: The pointer value which was stored, needs to be free-ed at PHY *
+ * But since we did not implement WLS, this has to be done here
+ */
+#ifndef INTEL_WLS
+ MAC_FREE(rarTxdataValue,rarInfo->rarPduLen);
+#endif
+
+ return ROK;
+}
+
+/***********************************************************************
+ *
+ * @brief fills the DL dedicated Msg TX-DATA request message
+ *
+ * @details
+ *
+ * Function : fillDlMsgTxDataReq
+ *
+ * Functionality:
+ * - fills the Dl Dedicated Msg TX-DATA request message
+ *
+ * @params[in] fapi_tx_pdu_desc_t *pduDesc
+ * @params[in] DlMsgInfo *dlMsgInfo
+ * @params[in] uint32_t *msgLen
+ * @params[in] uint16_t pduIndex
+ * @return ROK
+ *
+ * ********************************************************************/
+uint8_t fillDlMsgTxDataReq(fapi_tx_pdu_desc_t *pduDesc, DlMsgInfo *dlMsgInfo,
+ uint16_t pduIndex)
+{
+ uint32_t pduLen = 0;
+ uint8_t *dedMsgTxDataValue = NULLP;
+
+ pduDesc[pduIndex].pdu_index = pduIndex;
+ pduDesc[pduIndex].num_tlvs = 1;
+
+ /* fill the TLV */
+ /* as of now, memory is allocated from SSI, later WLS memory needs to be taken */
+ pduDesc[pduIndex].tlvs[0].tl.tag = 1; /* pointer to be sent */
+ pduDesc[pduIndex].tlvs[0].tl.length = dlMsgInfo->dlMsgPduLen;
+ LWR_MAC_ALLOC(dedMsgTxDataValue, dlMsgInfo->dlMsgPduLen);
+ if(dedMsgTxDataValue == NULLP)
+ {
+ return RFAILED;
+ }
+ memcpy(dedMsgTxDataValue, dlMsgInfo->dlMsgPdu, dlMsgInfo->dlMsgPduLen);
+ pduDesc[pduIndex].tlvs[0].value = dedMsgTxDataValue;
+
+ /* The total length of the PDU description and PDU data */
+ pduLen += 8; /* size of PDU length 2 bytes, PDU index 2 bytes, numTLV 4 bytes */
+ pduLen += sizeof(fapi_uint8_ptr_tlv_t); /* only 1 TLV is present */
+ pduDesc[pduIndex].pdu_length = pduLen;
+
+ /* TODO: The pointer value which was stored, needs to be free-ed at PHY *
+ * But since we did not implement WLS, this has to be done here
+ */
+#ifndef INTEL_WLS
+ MAC_FREE(dedMsgTxDataValue, dlMsgInfo->dlMsgPduLen);
+#endif
+
+ return ROK;
+}
+
+
+#endif /* FAPI */
+/*******************************************************************
+ *
+ * @brief Sends DL TTI Request to PHY
+ *
+ * @details
+ *
+ * Function : fillDlTtiReq
+ *
+ * Functionality:
+ * -Sends FAPI DL TTI req to PHY
+ *
+ * @params[in] timing info
+ * @return ROK - success