#include <stdlib.h>
#include <stdint.h>
+#include <stdbool.h>
/* header include files -- defines (.h) */
#include "envopt.h" /* environment options */
#include "mac.h"
#include "rg.x" /* typedefs for MAC */
#include "lwr_mac_phy.h"
+#include "common_def.h"
#include "math.h"
#define MIB_SFN_BITMASK 0xFC
/* Global variables */
uint8_t slotIndIdx;
-uint16_t sendTxDataReq(CmLteTimingInfo *currTimingInfo, DlAlloc *dlInfo);
+uint16_t sendTxDataReq(SlotIndInfo currTimingInfo, DlSchedInfo *dlInfo);
void lwrMacInit()
{
* @return ROK
*
******************************************************************/
-
-S16 fillPdcchPdu(fapi_dl_tti_req_pdu_t *dlTtiReqPdu, DlAlloc *dlAlloc, uint32_t *msgLen, RntiType rntiType)
+S16 fillPdcchPdu(fapi_dl_tti_req_pdu_t *dlTtiReqPdu, DlSchedInfo *dlInfo, uint32_t *msgLen, RntiType rntiType)
{
if(dlTtiReqPdu != NULLP)
{
PdcchCfg *pdcchInfo = NULLP;
+ BwpCfg *bwp = NULLP;
+
+ dlTtiReqPdu->u.pdcch_pdu.dlDci = (fapi_dl_dci_t *)(dlTtiReqPdu + \
+ (sizeof(fapi_dl_tti_req_pdu_t) - sizeof(dlTtiReqPdu->u)) + \
+ (sizeof(fapi_dl_pdcch_pdu_t) - sizeof(fapi_dl_dci_t*)));
+
if(rntiType == SI_RNTI_TYPE)
{
- pdcchInfo = &dlAlloc->brdcstAlloc.sib1Alloc.sib1PdcchCfg;
+ pdcchInfo = &dlInfo->brdcstAlloc.sib1Alloc.sib1PdcchCfg;
+ bwp = &dlInfo->brdcstAlloc.sib1Alloc.bwp;
fillSib1DlDciPdu(dlTtiReqPdu->u.pdcch_pdu.dlDci, pdcchInfo);
}
else if(rntiType == RA_RNTI_TYPE)
{
- pdcchInfo = &dlAlloc->rarAlloc.rarPdcchCfg;
+ pdcchInfo = &dlInfo->rarAlloc->rarPdcchCfg;
+ bwp = &dlInfo->rarAlloc->bwp;
fillRarDlDciPdu(dlTtiReqPdu->u.pdcch_pdu.dlDci, pdcchInfo);
}
else if(rntiType == TC_RNTI_TYPE)
{
- pdcchInfo = &dlAlloc->msg4Alloc->msg4PdcchCfg;
+ pdcchInfo = &dlInfo->msg4Alloc->msg4PdcchCfg;
+ bwp = &dlInfo->msg4Alloc->bwp;
fillMsg4DlDciPdu(dlTtiReqPdu->u.pdcch_pdu.dlDci, pdcchInfo,\
- &dlAlloc->msg4Alloc->msg4Info);
+ &dlInfo->msg4Alloc->msg4Info);
}
else
{
return RFAILED;;
}
dlTtiReqPdu->pduType = PDCCH_PDU_TYPE;
- dlTtiReqPdu->u.pdcch_pdu.bwpSize = pdcchInfo->pdcchBwpCfg.BWPSize;
- dlTtiReqPdu->u.pdcch_pdu.bwpPart = pdcchInfo->pdcchBwpCfg.BWPStart;
- dlTtiReqPdu->u.pdcch_pdu.subCarrierSpacing = pdcchInfo->pdcchBwpCfg.subcarrierSpacing;
- dlTtiReqPdu->u.pdcch_pdu.cyclicPrefix = pdcchInfo->pdcchBwpCfg.cyclicPrefix;
+ dlTtiReqPdu->u.pdcch_pdu.bwpSize = bwp->BWPSize;
+ dlTtiReqPdu->u.pdcch_pdu.bwpPart = bwp->BWPStart;
+ dlTtiReqPdu->u.pdcch_pdu.subCarrierSpacing = bwp->subcarrierSpacing;
+ dlTtiReqPdu->u.pdcch_pdu.cyclicPrefix = bwp->cyclicPrefix;
dlTtiReqPdu->u.pdcch_pdu.startSymbolIndex = pdcchInfo->coreset0Cfg.startSymbolIndex;
dlTtiReqPdu->u.pdcch_pdu.durationSymbols = pdcchInfo->coreset0Cfg.durationSymbols;
memcpy(dlTtiReqPdu->u.pdcch_pdu.freqDomainResource, pdcchInfo->coreset0Cfg.freqDomainResource, 6);
dlTtiReqPdu->u.pdcch_pdu.shiftIndex = pdcchInfo->coreset0Cfg.shiftIndex;
dlTtiReqPdu->u.pdcch_pdu.precoderGranularity = pdcchInfo->coreset0Cfg.precoderGranularity;
dlTtiReqPdu->u.pdcch_pdu.numDlDci = pdcchInfo->numDlDci;
- dlTtiReqPdu->u.pdcch_pdu.dlDci = (fapi_dl_dci_t *)(dlTtiReqPdu + \
- (sizeof(fapi_dl_tti_req_pdu_t) - sizeof(dlTtiReqPdu->u)) + \
- (sizeof(fapi_dl_pdcch_pdu_t) - sizeof(fapi_dl_dci_t*)));
/* Calculating PDU length. Considering only one dl dci pdu for now */
dlTtiReqPdu->pduSize = sizeof(fapi_dl_pdcch_pdu_t) + sizeof(fapi_dl_dci_t);
sizeof(dlTtiReqPdu->pduSize) + dlTtiReqPdu->pduSize));
}
- return ROK;
+ return ROK;
}
/*******************************************************************
******************************************************************/
void fillPdschPdu(fapi_dl_tti_req_pdu_t *dlTtiReqPdu, PdschCfg *pdschInfo,
-uint32_t *msgLen, uint16_t pduIndex)
+ BwpCfg bwp,uint32_t *msgLen, uint16_t pduIndex)
{
uint8_t idx;
dlTtiReqPdu->u.pdsch_pdu.pduBitMap = pdschInfo->pduBitmap;
dlTtiReqPdu->u.pdsch_pdu.rnti = pdschInfo->rnti;
dlTtiReqPdu->u.pdsch_pdu.pduIndex = pduIndex;
- dlTtiReqPdu->u.pdsch_pdu.bwpSize = pdschInfo->pdschBwpCfg.BWPSize;
- dlTtiReqPdu->u.pdsch_pdu.bwpStart = pdschInfo->pdschBwpCfg.BWPStart;
- dlTtiReqPdu->u.pdsch_pdu.subCarrierSpacing = pdschInfo->pdschBwpCfg.subcarrierSpacing;
- dlTtiReqPdu->u.pdsch_pdu.cyclicPrefix = pdschInfo->pdschBwpCfg.cyclicPrefix;
+ dlTtiReqPdu->u.pdsch_pdu.bwpSize = bwp.BWPSize;
+ dlTtiReqPdu->u.pdsch_pdu.bwpStart = bwp.BWPStart;
+ dlTtiReqPdu->u.pdsch_pdu.subCarrierSpacing = bwp.subcarrierSpacing;
+ dlTtiReqPdu->u.pdsch_pdu.cyclicPrefix = bwp.cyclicPrefix;
dlTtiReqPdu->u.pdsch_pdu.nrOfCodeWords = pdschInfo->numCodewords;
for(idx = 0; idx < MAX_CODEWORDS ; idx++)
{
* @return count
*
* ********************************************************************/
-uint8_t calcDlTtiReqPduCount(DlAlloc *dlInfo)
+uint8_t calcDlTtiReqPduCount(DlSchedInfo *dlInfo)
{
uint8_t count = 0;
uint8_t idx = 0;
{
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->isRarPres)
+ if(dlInfo->rarAlloc != NULLP)
{
+ /* PDCCH and PDSCH PDU is filled */
count += 2;
}
- if(dlInfo->msg4Alloc)
+ if(dlInfo->msg4Alloc != NULLP)
{
+ /* PDCCH and PDSCH PDU is filled */
count += 2;
}
* @return count
*
* ********************************************************************/
-uint8_t calcTxDataReqPduCount(DlAlloc *dlInfo)
+uint8_t calcTxDataReqPduCount(DlSchedInfo *dlInfo)
{
uint8_t count = 0;
{
count++;
}
- if(dlInfo->isRarPres)
+ if(dlInfo->rarAlloc != NULLP)
{
count++;
}
- if(dlInfo->msg4Alloc)
+ if(dlInfo->msg4Alloc != NULLP)
{
count++;
}
* RFAILED - failure
*
* ****************************************************************/
-uint16_t handleDlTtiReq(CmLteTimingInfo *currTimingInfo)
+uint16_t handleDlTtiReq(SlotIndInfo currTimingInfo)
{
#ifdef FAPI
uint8_t idx;
uint16_t pduIndex = 0;
uint32_t msgLen = 0;
uint32_t dlTtiReqMsgSize = 0;
+
fapi_dl_tti_req_t *dlTtiReq = NULLP;
+ SlotIndInfo dlTtiReqTimingInfo;
+
RgCellCb *cellCbParams = NULLP;
MacDlSlot *currDlSlot = NULLP;
MacCellCfg macCellCfg;
if(clGlobalCp.phyState == PHY_STATE_RUNNING)
{
+ /* consider phy delay */
+ ADD_DELTA_TO_TIME(currTimingInfo,dlTtiReqTimingInfo,PHY_DELTA);
+
cellCbParams = rgCb[inst].cell;
- macCellCfg = cellCbParams->macCellCfg;
-
- if(currTimingInfo != NULLP)
- {
- currDlSlot = &macCb.macCell->dlSlot[currTimingInfo->slot % MAX_SLOT_SUPPORTED];
- nPdu = calcDlTtiReqPduCount(&currDlSlot->dlInfo);
- dlTtiReqMsgSize = sizeof(fapi_dl_tti_req_t) + (nPdu * \
- sizeof(fapi_dl_tti_req_pdu_t));
- if(nPdu > 0)
- {
- if(currDlSlot->dlInfo.isBroadcastPres)
- {
- if(currDlSlot->dlInfo.brdcstAlloc.sib1Trans)
- {
- dlTtiReqMsgSize += sizeof(fapi_dl_dci_t);
- }
-
- }
- if(currDlSlot->dlInfo.isRarPres)
- {
- dlTtiReqMsgSize += sizeof(fapi_dl_dci_t);
- }
- if(currDlSlot->dlInfo.msg4Alloc)
- {
- dlTtiReqMsgSize += sizeof(fapi_dl_dci_t);
- }
- }
- LWR_MAC_ALLOC(dlTtiReq, dlTtiReqMsgSize);
- if(dlTtiReq != NULLP)
- {
- memset(dlTtiReq, 0, dlTtiReqMsgSize);
- dlTtiReq->sfn = currTimingInfo->sfn;
- dlTtiReq->slot = currTimingInfo->slot;
- dlTtiReq->nPdus = calcDlTtiReqPduCount(&currDlSlot->dlInfo); /* get total Pdus */
- nPdu = dlTtiReq->nPdus;
- dlTtiReq->nGroup = 0;
-
- if(dlTtiReq->nPdus > 0)
- {
- dlTtiReq->pdus = (fapi_dl_tti_req_pdu_t*)(dlTtiReq + \
- (sizeof(fapi_dl_tti_req_t) - sizeof(fapi_dl_tti_req_pdu_t*)));
- if(!dlTtiReq->pdus)
- {
- DU_LOG("\nLWR_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++)
- {
- fillSsbPdu(&dlTtiReq->pdus[numPduEncoded], &macCellCfg,\
- currDlSlot, &msgLen, idx, dlTtiReq->sfn);
- numPduEncoded++;
- }
- }
- printf("\033[1;31m");
- DU_LOG("\nLWR_MAC: MIB sent..");
- printf("\033[0m");
- }
- if(currDlSlot->dlInfo.brdcstAlloc.sib1Trans)
- {
- /* Filling SIB1 param */
- if(numPduEncoded != nPdu)
- {
- rntiType = SI_RNTI_TYPE;
- fillPdcchPdu(&dlTtiReq->pdus[numPduEncoded],&currDlSlot->dlInfo,\
- &msgLen, rntiType);
- numPduEncoded++;
- fillPdschPdu(&dlTtiReq->pdus[numPduEncoded],&currDlSlot->dlInfo.brdcstAlloc.\
- sib1Alloc.sib1PdschCfg, &msgLen, pduIndex);
- pduIndex++;
- numPduEncoded++;
- }
- printf("\033[1;34m");
- DU_LOG("\nLWR_MAC: SIB1 sent...");
- printf("\033[0m");
- }
- }
- if(currDlSlot->dlInfo.isRarPres)
- {
- /* Filling RAR param */
- rntiType = RA_RNTI_TYPE;
- fillRarPdu(&currDlSlot->dlInfo.rarAlloc.rarInfo);
- fillPdcchPdu(&dlTtiReq->pdus[numPduEncoded], \
- &currDlSlot->dlInfo, &msgLen, rntiType);
- numPduEncoded++;
- fillPdschPdu(&dlTtiReq->pdus[numPduEncoded], \
- &currDlSlot->dlInfo.rarAlloc.rarPdschCfg, &msgLen, pduIndex);
- numPduEncoded++;
- pduIndex++;
-
- printf("\033[1;32m");
- DU_LOG("\nLWR_MAC: RAR sent...");
- printf("\033[0m");
- }
- if(currDlSlot->dlInfo.msg4Alloc)
- {
- /* Filling Msg4 param */
- rntiType = TC_RNTI_TYPE;
- fillPdcchPdu(&dlTtiReq->pdus[numPduEncoded], \
- &currDlSlot->dlInfo, &msgLen, rntiType);
- numPduEncoded++;
- fillPdschPdu(&dlTtiReq->pdus[numPduEncoded], \
- &currDlSlot->dlInfo.msg4Alloc->msg4PdschCfg, &msgLen, pduIndex);
- numPduEncoded++;
- pduIndex++;
-
- printf("\033[1;32m");
- DU_LOG("\nLWR_MAC: MSG4 sent...");
- printf("\033[0m");
- }
- msgLen += sizeof(fapi_dl_tti_req_t) - sizeof(fapi_msg_t);
- fillMsgHeader(&dlTtiReq->header, FAPI_DL_TTI_REQUEST, msgLen);
- LwrMacSendToPhy(dlTtiReq->header.message_type_id, dlTtiReqMsgSize, \
- (void *)dlTtiReq);
-
- /* send Tx-DATA req message */
- sendTxDataReq(currTimingInfo, &currDlSlot->dlInfo);
- }
- else
- {
- msgLen = sizeof(fapi_dl_tti_req_t) - sizeof(fapi_msg_t);
- fillMsgHeader(&dlTtiReq->header, FAPI_DL_TTI_REQUEST, msgLen);
- LwrMacSendToPhy(dlTtiReq->header.message_type_id, dlTtiReqMsgSize, (void *)dlTtiReq);
- }
- return ROK;
- }
- else
- {
- DU_LOG("\nLWR_MAC: Failed to allocate memory for DL TTI Request");
- return RFAILED;
- }
- }
- else
- {
- DU_LOG("\nLWR_MAC: Current TTI Info is NULL");
- return RFAILED;
- }
- }
+ macCellCfg = cellCbParams->macCellCfg;
+
+ currDlSlot = &macCb.macCell->dlSlot[dlTtiReqTimingInfo.slot];
+ nPdu = calcDlTtiReqPduCount(&currDlSlot->dlInfo);
+ dlTtiReqMsgSize = sizeof(fapi_dl_tti_req_t) + (nPdu * \
+ sizeof(fapi_dl_tti_req_pdu_t));
+ if(nPdu > 0)
+ {
+ if(currDlSlot->dlInfo.isBroadcastPres)
+ {
+ if(currDlSlot->dlInfo.brdcstAlloc.sib1Trans)
+ {
+ dlTtiReqMsgSize += sizeof(fapi_dl_dci_t);
+ }
+ }
+ if(currDlSlot->dlInfo.rarAlloc != NULLP)
+ {
+ dlTtiReqMsgSize += sizeof(fapi_dl_dci_t);
+ }
+ if(currDlSlot->dlInfo.msg4Alloc != NULLP)
+ {
+ dlTtiReqMsgSize += sizeof(fapi_dl_dci_t);
+ }
+ }
+ LWR_MAC_ALLOC(dlTtiReq, dlTtiReqMsgSize);
+ if(dlTtiReq != NULLP)
+ {
+ memset(dlTtiReq, 0, dlTtiReqMsgSize);
+ dlTtiReq->sfn = dlTtiReqTimingInfo.sfn;
+ dlTtiReq->slot = dlTtiReqTimingInfo.slot;
+ dlTtiReq->nPdus = calcDlTtiReqPduCount(&currDlSlot->dlInfo); /* get total Pdus */
+ nPdu = dlTtiReq->nPdus;
+ dlTtiReq->nGroup = 0;
+
+ if(dlTtiReq->nPdus > 0)
+ {
+ dlTtiReq->pdus = (fapi_dl_tti_req_pdu_t*)(dlTtiReq + \
+ (sizeof(fapi_dl_tti_req_t) - sizeof(fapi_dl_tti_req_pdu_t*)));
+ if(!dlTtiReq->pdus)
+ {
+ DU_LOG("\nLWR_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++)
+ {
+ fillSsbPdu(&dlTtiReq->pdus[numPduEncoded], &macCellCfg,\
+ currDlSlot, &msgLen, idx, dlTtiReq->sfn);
+ numPduEncoded++;
+ }
+ }
+ printf("\033[1;31m");
+ DU_LOG("\nLWR_MAC: MIB sent..");
+ printf("\033[0m");
+ }
+ if(currDlSlot->dlInfo.brdcstAlloc.sib1Trans)
+ {
+ /* Filling SIB1 param */
+ if(numPduEncoded != nPdu)
+ {
+ rntiType = SI_RNTI_TYPE;
+ fillPdcchPdu(&dlTtiReq->pdus[numPduEncoded],&currDlSlot->dlInfo,\
+ &msgLen, rntiType);
+ numPduEncoded++;
+ fillPdschPdu(&dlTtiReq->pdus[numPduEncoded],
+ &currDlSlot->dlInfo.brdcstAlloc.sib1Alloc.sib1PdschCfg,
+ currDlSlot->dlInfo.brdcstAlloc.sib1Alloc.bwp,
+ &msgLen, pduIndex);
+ pduIndex++;
+ numPduEncoded++;
+ }
+ printf("\033[1;34m");
+ DU_LOG("\nLWR_MAC: SIB1 sent...");
+ printf("\033[0m");
+ }
+ }
+ if(currDlSlot->dlInfo.rarAlloc != NULLP)
+ {
+ /* Filling RAR param */
+ rntiType = RA_RNTI_TYPE;
+ fillPdcchPdu(&dlTtiReq->pdus[numPduEncoded], \
+ &currDlSlot->dlInfo, &msgLen, rntiType);
+ numPduEncoded++;
+ fillPdschPdu(&dlTtiReq->pdus[numPduEncoded],
+ &currDlSlot->dlInfo.rarAlloc->rarPdschCfg,
+ currDlSlot->dlInfo.rarAlloc->bwp,
+ &msgLen, pduIndex);
+ numPduEncoded++;
+ pduIndex++;
+
+ printf("\033[1;32m");
+ DU_LOG("\nLWR_MAC: RAR sent...");
+ printf("\033[0m");
+ }
+ if(currDlSlot->dlInfo.msg4Alloc != NULLP)
+ {
+ /* Filling Msg4 param */
+ rntiType = TC_RNTI_TYPE;
+ fillPdcchPdu(&dlTtiReq->pdus[numPduEncoded], \
+ &currDlSlot->dlInfo, &msgLen, rntiType);
+ numPduEncoded++;
+ fillPdschPdu(&dlTtiReq->pdus[numPduEncoded],
+ &currDlSlot->dlInfo.msg4Alloc->msg4PdschCfg,
+ currDlSlot->dlInfo.msg4Alloc->bwp,
+ &msgLen, pduIndex);
+ numPduEncoded++;
+ pduIndex++;
+
+ printf("\033[1;32m");
+ DU_LOG("\nLWR_MAC: MSG4 sent...");
+ printf("\033[0m");
+ }
+ msgLen += sizeof(fapi_dl_tti_req_t) - sizeof(fapi_msg_t);
+ fillMsgHeader(&dlTtiReq->header, FAPI_DL_TTI_REQUEST, msgLen);
+ LwrMacSendToPhy(dlTtiReq->header.message_type_id, dlTtiReqMsgSize, \
+ (void *)dlTtiReq);
+
+ /* send Tx-DATA req message */
+ sendTxDataReq(currTimingInfo, &currDlSlot->dlInfo);
+ }
+ else
+ {
+ msgLen = sizeof(fapi_dl_tti_req_t) - sizeof(fapi_msg_t);
+ fillMsgHeader(&dlTtiReq->header, FAPI_DL_TTI_REQUEST, msgLen);
+ LwrMacSendToPhy(dlTtiReq->header.message_type_id, dlTtiReqMsgSize, (void *)dlTtiReq);
+ }
+ return ROK;
+ }
+ else
+ {
+ DU_LOG("\nLWR_MAC: Failed to allocate memory for DL TTI Request");
+ return RFAILED;
+ }
+ }
else
{
- lwr_mac_handleInvalidEvt(currTimingInfo);
+ lwr_mac_handleInvalidEvt(&currTimingInfo);
return RFAILED;
}
#endif
* RFAILED - failure
*
* ****************************************************************/
-uint16_t sendTxDataReq(CmLteTimingInfo *currTimingInfo, DlAlloc *dlInfo)
+uint16_t sendTxDataReq(SlotIndInfo currTimingInfo, DlSchedInfo *dlInfo)
{
#ifdef FAPI
uint8_t nPdu = 0;
{
txDataReqMsgSize += rgCb[inst].cell->macCellCfg.sib1Cfg.sib1PduLen;
}
- if(dlInfo->isRarPres)
+ if(dlInfo->rarAlloc != NULLP)
{
- txDataReqMsgSize += dlInfo->rarAlloc.rarInfo.rarPduLen;
+ txDataReqMsgSize += dlInfo->rarAlloc->rarInfo.rarPduLen;
}
- if(dlInfo->msg4Alloc)
+ if(dlInfo->msg4Alloc != NULLP)
{
txDataReqMsgSize += dlInfo->msg4Alloc->msg4Info.msg4PduLen;
}
}
memset(txDataReq, 0, txDataReqMsgSize);
- txDataReq->sfn = currTimingInfo->sfn;
- txDataReq->slot = currTimingInfo->slot;
+ txDataReq->sfn = currTimingInfo.sfn;
+ txDataReq->slot = currTimingInfo.slot;
txDataReq->pduDesc = (fapi_tx_pdu_desc_t *)(txDataReq + \
(sizeof(fapi_tx_data_req_t) - sizeof(fapi_tx_pdu_desc_t *)));
pduIndex++;
txDataReq->numPdus++;
}
- if(dlInfo->isRarPres)
+ if(dlInfo->rarAlloc != NULLP)
{
- fillRarTxDataReq(txDataReq->pduDesc, &dlInfo->rarAlloc.\
- rarInfo, &msgLen, pduIndex);
+ fillRarTxDataReq(txDataReq->pduDesc, &dlInfo->rarAlloc->rarInfo, &msgLen, pduIndex);
pduIndex++;
txDataReq->numPdus++;
+
+ MAC_FREE(dlInfo->rarAlloc,sizeof(RarAlloc));
+ dlInfo->rarAlloc = NULLP;
}
- if(dlInfo->msg4Alloc)
+ if(dlInfo->msg4Alloc != NULLP)
{
fillMsg4TxDataReq(txDataReq->pduDesc, &dlInfo->msg4Alloc->\
msg4Info, &msgLen, pduIndex);
pduIndex++;
txDataReq->numPdus++;
+
+ MAC_FREE(dlInfo->msg4Alloc,sizeof(Msg4Alloc));
+ dlInfo->msg4Alloc = NULLP;
}
msgLen += sizeof(fapi_tx_data_req_t) - sizeof(fapi_msg_t);
fillMsgHeader(&txDataReq->header, FAPI_TX_DATA_REQUEST, msgLen);
if(currUlSlot != NULLP)
{
- if(currUlSlot->ulCellInfo.dataType & SCH_DATATYPE_PRACH)
+ if(currUlSlot->ulInfo.dataType & SCH_DATATYPE_PRACH)
{
pduCount++;
if(ulTtiReq)
ulTtiReq->rachPresent = PDU_PRESENT;
}
- if(currUlSlot->ulCellInfo.dataType & SCH_DATATYPE_PUSCH)
+ if(currUlSlot->ulInfo.dataType & SCH_DATATYPE_PUSCH)
{
pduCount++;
if(ulTtiReq)
ulTtiReq->nUlsch++;
}
- if(currUlSlot->ulCellInfo.dataType & SCH_DATATYPE_PUSCH_UCI)
+ if(currUlSlot->ulInfo.dataType & SCH_DATATYPE_PUSCH_UCI)
{
pduCount++;
if(ulTtiReq)
ulTtiReq->nUlsch = PDU_PRESENT;
}
- if(currUlSlot->ulCellInfo.dataType & SCH_DATATYPE_UCI)
+ if(currUlSlot->ulInfo.dataType & SCH_DATATYPE_UCI)
{
pduCount++;
if(ulTtiReq)
ulTtiReq->nUlcch = PDU_PRESENT;
}
- if(currUlSlot->ulCellInfo.dataType & SCH_DATATYPE_SRS)
+ if(currUlSlot->ulInfo.dataType & SCH_DATATYPE_SRS)
{
pduCount++;
}
{
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.numPrachOcas = currUlSlot->ulInfo.prachSchInfo.numPrachOcas;
ulTtiReqPdu->u.prach_pdu.prachFormat = \
- currUlSlot->ulCellInfo.prachSchInfo.prachFormat;
- ulTtiReqPdu->u.prach_pdu.numRa = currUlSlot->ulCellInfo.prachSchInfo.numRa;
+ currUlSlot->ulInfo.prachSchInfo.prachFormat;
+ ulTtiReqPdu->u.prach_pdu.numRa = currUlSlot->ulInfo.prachSchInfo.numRa;
ulTtiReqPdu->u.prach_pdu.prachStartSymbol = \
- currUlSlot->ulCellInfo.prachSchInfo.prachStartSymb;
+ currUlSlot->ulInfo.prachSchInfo.prachStartSymb;
setNumCs(&ulTtiReqPdu->u.prach_pdu.numCs, macCellCfg);
ulTtiReqPdu->u.prach_pdu.beamforming.numPrgs = 0;
ulTtiReqPdu->u.prach_pdu.beamforming.prgSize = 0;
{
ulTtiReqPdu->pduType = PUSCH_PDU_TYPE;
ulTtiReqPdu->u.pusch_pdu.pduBitMap = 1;
- ulTtiReqPdu->u.pusch_pdu.rnti = currUlSlot->ulCellInfo.crnti;
+ ulTtiReqPdu->u.pusch_pdu.rnti = currUlSlot->ulInfo.crnti;
/* TODO : Fill handle in raCb when scheduling pusch and access here */
ulTtiReqPdu->u.pusch_pdu.handle = 100;
ulTtiReqPdu->u.pusch_pdu.bwpSize = macCellCfg->initialUlBwp.bwp.numPrb;
ulTtiReqPdu->u.pusch_pdu.targetCodeRate = 308;
ulTtiReqPdu->u.pusch_pdu.qamModOrder = 2;
ulTtiReqPdu->u.pusch_pdu.mcsIndex = \
- currUlSlot->ulCellInfo.schPuschInfo.tbInfo.mcs;
+ currUlSlot->ulInfo.schPuschInfo.tbInfo.mcs;
ulTtiReqPdu->u.pusch_pdu.mcsTable = 0;
ulTtiReqPdu->u.pusch_pdu.transformPrecoding = 1;
- ulTtiReqPdu->u.pusch_pdu.dataScramblingId = currUlSlot->ulCellInfo.cellId;
+ ulTtiReqPdu->u.pusch_pdu.dataScramblingId = currUlSlot->ulInfo.cellId;
ulTtiReqPdu->u.pusch_pdu.nrOfLayers = 1;
ulTtiReqPdu->u.pusch_pdu.ulDmrsSymbPos = 4;
ulTtiReqPdu->u.pusch_pdu.dmrsConfigType = 0;
- ulTtiReqPdu->u.pusch_pdu.ulDmrsScramblingId = currUlSlot->ulCellInfo.cellId;
+ ulTtiReqPdu->u.pusch_pdu.ulDmrsScramblingId = currUlSlot->ulInfo.cellId;
ulTtiReqPdu->u.pusch_pdu.scid = 0;
ulTtiReqPdu->u.pusch_pdu.numDmrsCdmGrpsNoData = 1;
ulTtiReqPdu->u.pusch_pdu.dmrsPorts = 0;
ulTtiReqPdu->u.pusch_pdu.resourceAlloc = \
- currUlSlot->ulCellInfo.schPuschInfo.resAllocType;
+ currUlSlot->ulInfo.schPuschInfo.resAllocType;
ulTtiReqPdu->u.pusch_pdu.rbStart = \
- currUlSlot->ulCellInfo.schPuschInfo.fdAlloc.startPrb;
+ currUlSlot->ulInfo.schPuschInfo.fdAlloc.startPrb;
ulTtiReqPdu->u.pusch_pdu.rbSize = \
- currUlSlot->ulCellInfo.schPuschInfo.fdAlloc.numPrb;
+ currUlSlot->ulInfo.schPuschInfo.fdAlloc.numPrb;
ulTtiReqPdu->u.pusch_pdu.vrbToPrbMapping = 0;
ulTtiReqPdu->u.pusch_pdu.frequencyHopping = 0;
ulTtiReqPdu->u.pusch_pdu.txDirectCurrentLocation = 0;
ulTtiReqPdu->u.pusch_pdu.uplinkFrequencyShift7p5khz = 0;
ulTtiReqPdu->u.pusch_pdu.startSymbIndex = \
- currUlSlot->ulCellInfo.schPuschInfo.tdAlloc.startSymb;
+ currUlSlot->ulInfo.schPuschInfo.tdAlloc.startSymb;
ulTtiReqPdu->u.pusch_pdu.nrOfSymbols = \
- currUlSlot->ulCellInfo.schPuschInfo.tdAlloc.numSymb;
+ currUlSlot->ulInfo.schPuschInfo.tdAlloc.numSymb;
ulTtiReqPdu->u.pusch_pdu.puschData.rvIndex = \
- currUlSlot->ulCellInfo.schPuschInfo.tbInfo.rv;
+ currUlSlot->ulInfo.schPuschInfo.tbInfo.rv;
ulTtiReqPdu->u.pusch_pdu.puschData.harqProcessId = \
- currUlSlot->ulCellInfo.schPuschInfo.harqProcId;
+ currUlSlot->ulInfo.schPuschInfo.harqProcId;
ulTtiReqPdu->u.pusch_pdu.puschData.newDataIndicator = \
- currUlSlot->ulCellInfo.schPuschInfo.tbInfo.ndi;
+ currUlSlot->ulInfo.schPuschInfo.tbInfo.ndi;
ulTtiReqPdu->u.pusch_pdu.puschData.tbSize = \
- currUlSlot->ulCellInfo.schPuschInfo.tbInfo.tbSize;
+ currUlSlot->ulInfo.schPuschInfo.tbInfo.tbSize;
/* numCb is 0 for new transmission */
ulTtiReqPdu->u.pusch_pdu.puschData.numCb = 0;
* RFAILED - failure
*
******************************************************************/
-uint16_t handleUlTtiReq(CmLteTimingInfo *currTimingInfo)
+uint16_t handleUlTtiReq(SlotIndInfo currTimingInfo)
{
#ifdef FAPI
uint8_t pduIdx = -1;
uint32_t msgSize = 0;
fapi_ul_tti_req_t *ulTtiReq = NULLP;
+ SlotIndInfo ulTtiReqTimingInfo;
+
RgCellCb *cellCbParams = NULLP;
MacUlSlot *currUlSlot = NULLP;
MacCellCfg macCellCfg;
Inst inst = 0;
if(clGlobalCp.phyState == PHY_STATE_RUNNING)
- {
- cellCbParams = rgCb[inst].cell;
- macCellCfg = cellCbParams->macCellCfg;
-
- if(currTimingInfo != NULLP)
- {
- currUlSlot = &macCb.macCell->ulSlot[currTimingInfo->slot % MAX_SLOT_SUPPORTED];
- numPdu = getnPdus(NULL, currUlSlot);
- msgSize = sizeof(fapi_ul_tti_req_t) + (numPdu * \
- sizeof(fapi_ul_tti_req_pdu_t));
- LWR_MAC_ALLOC(ulTtiReq, msgSize);
+ {
+ cellCbParams = rgCb[inst].cell;
+ macCellCfg = cellCbParams->macCellCfg;
- if(ulTtiReq != NULLP)
- {
- memset(ulTtiReq, 0, msgSize);
- ulTtiReq->sfn = currTimingInfo->sfn;
- ulTtiReq->slot = currTimingInfo->slot;
- ulTtiReq->nPdus = getnPdus(ulTtiReq, currUlSlot);
- ulTtiReq->nGroup = 0;
- if(ulTtiReq->nPdus > 0)
- {
- ulTtiReq->pdus = (fapi_ul_tti_req_pdu_t *)(ulTtiReq + \
- (sizeof(fapi_ul_tti_req_t) - sizeof(fapi_ul_tti_req_pdu_t*)));
- /* Fill Prach Pdu */
- if(currUlSlot->ulCellInfo.dataType & SCH_DATATYPE_PRACH)
- {
- pduIdx++;
- fillPrachPdu(&ulTtiReq->pdus[pduIdx], &macCellCfg, currUlSlot, &msgLen);
- }
+ /* add PHY delta */
+ ADD_DELTA_TO_TIME(currTimingInfo,ulTtiReqTimingInfo,PHY_DELTA);
- /* Fill PUSCH PDU */
- if(currUlSlot->ulCellInfo.dataType & SCH_DATATYPE_PUSCH)
- {
- pduIdx++;
- fillPuschPdu(&ulTtiReq->pdus[pduIdx], &macCellCfg, currUlSlot, &msgLen);
- }
+ currUlSlot = &macCb.macCell->ulSlot[ulTtiReqTimingInfo.slot % MAX_SLOT_SUPPORTED];
+ numPdu = getnPdus(NULL, currUlSlot);
+ msgSize = sizeof(fapi_ul_tti_req_t) + (numPdu*sizeof(fapi_ul_tti_req_pdu_t));
+ LWR_MAC_ALLOC(ulTtiReq, msgSize);
- if((currUlSlot->ulCellInfo.dataType & SCH_DATATYPE_PRACH) || \
- (currUlSlot->ulCellInfo.dataType & SCH_DATATYPE_PUSCH))
- {
- msgLen += (sizeof(fapi_ul_tti_req_t) - sizeof(fapi_msg_t));
- fillMsgHeader(&ulTtiReq->header, FAPI_UL_TTI_REQUEST, msgLen);
-
- DU_LOG("\nLWR_MAC: Sending UL TTI Request");
- LwrMacSendToPhy(ulTtiReq->header.message_type_id, msgSize, (void *)ulTtiReq);
- }
- }
- else
- {
- msgLen = sizeof(fapi_ul_tti_req_t) - sizeof(fapi_msg_t);
- fillMsgHeader(&ulTtiReq->header, FAPI_UL_TTI_REQUEST, msgLen);
-
- DU_LOG("\nLWR_MAC: Sending UL TTI Request");
- LwrMacSendToPhy(ulTtiReq->header.message_type_id, msgSize, (void *)ulTtiReq);
- }
- memset(&currUlSlot, 0, sizeof(MacUlSlot));
- return ROK;
- }
- else
- {
- DU_LOG("\nLWR_MAC: Failed to allocate memory for UL TTI Request");
- memset(&currUlSlot, 0, sizeof(MacUlSlot));
- return RFAILED;
- }
- }
- else
- {
- DU_LOG("\nLWR_MAC: Current TTI Info in UL is NULL");
- return RFAILED;
- }
- }
+ if(ulTtiReq != NULLP)
+ {
+ memset(ulTtiReq, 0, msgSize);
+ ulTtiReq->sfn = currTimingInfo.sfn;
+ ulTtiReq->slot = currTimingInfo.slot;
+ ulTtiReq->nPdus = getnPdus(ulTtiReq, currUlSlot);
+ ulTtiReq->nGroup = 0;
+ if(ulTtiReq->nPdus > 0)
+ {
+ ulTtiReq->pdus = (fapi_ul_tti_req_pdu_t *)(ulTtiReq + \
+ (sizeof(fapi_ul_tti_req_t) - sizeof(fapi_ul_tti_req_pdu_t*)));
+ /* Fill Prach Pdu */
+ if(currUlSlot->ulInfo.dataType & SCH_DATATYPE_PRACH)
+ {
+ pduIdx++;
+ fillPrachPdu(&ulTtiReq->pdus[pduIdx], &macCellCfg, currUlSlot, &msgLen);
+ }
+
+ /* Fill PUSCH PDU */
+ if(currUlSlot->ulInfo.dataType & SCH_DATATYPE_PUSCH)
+ {
+ pduIdx++;
+ fillPuschPdu(&ulTtiReq->pdus[pduIdx], &macCellCfg, currUlSlot, &msgLen);
+ }
+
+ if((currUlSlot->ulInfo.dataType & SCH_DATATYPE_PRACH) || \
+ (currUlSlot->ulInfo.dataType & SCH_DATATYPE_PUSCH))
+ {
+ msgLen += (sizeof(fapi_ul_tti_req_t) - sizeof(fapi_msg_t));
+ fillMsgHeader(&ulTtiReq->header, FAPI_UL_TTI_REQUEST, msgLen);
+
+ DU_LOG("\nLWR_MAC: Sending UL TTI Request");
+ LwrMacSendToPhy(ulTtiReq->header.message_type_id, msgSize, (void *)ulTtiReq);
+ }
+ }
+ else
+ {
+ msgLen = sizeof(fapi_ul_tti_req_t) - sizeof(fapi_msg_t);
+ fillMsgHeader(&ulTtiReq->header, FAPI_UL_TTI_REQUEST, msgLen);
+
+ DU_LOG("\nLWR_MAC: Sending UL TTI Request");
+ LwrMacSendToPhy(ulTtiReq->header.message_type_id, msgSize, (void *)ulTtiReq);
+ }
+ memset(&currUlSlot, 0, sizeof(MacUlSlot));
+ return ROK;
+ }
+ else
+ {
+ DU_LOG("\nLWR_MAC: Failed to allocate memory for UL TTI Request");
+ memset(&currUlSlot, 0, sizeof(MacUlSlot));
+ return RFAILED;
+ }
+ }
else
{
- lwr_mac_handleInvalidEvt(currTimingInfo);
+ lwr_mac_handleInvalidEvt(&currTimingInfo);
}
#endif
return ROK;
S16 lwr_mac_handleStartReqEvt(void *msg);
S16 lwr_mac_handleStopReqEvt(void *msg);
void sendToLowerMac(U16, U32, void *);
-uint16_t handleDlTtiReq(CmLteTimingInfo *currTimingInfo);
-uint16_t handleUlTtiReq(CmLteTimingInfo *currTimingInfo);
void handlePhyMessages(uint16_t msgType, uint32_t msgSize, void *msg);
typedef S16 (*lwrMacFsmHdlr)(void *);
typedef struct macDlSlot
{
- DlAlloc dlInfo;
+ DlSchedInfo dlInfo;
}MacDlSlot;
typedef struct macUlSlot
{
- UlSchInfo ulCellInfo;
+ UlSchedInfo ulInfo;
}MacUlSlot;
typedef struct macCbInfo
*******************************************************************************/
/* header include files -- defines (.h) */
+#include <stdbool.h>
#include "envopt.h" /* environment options */
#include "envdep.h" /* environment dependent */
#include "envind.h" /* environment independent */
#include <stdlib.h>
#include <stdint.h>
+#include <stdbool.h>
/* header include files -- defines (.h) */
#include "envopt.h" /* environment options */
################################################################################
*******************************************************************************/
/* header include files (.h) */
+#include <stdbool.h>
#include "envopt.h" /* environment options */
#include "envdep.h" /* environment dependent */
#include "envind.h" /* environment independent */
uint8_t UnrestrictedSetNcsTable[MAX_ZERO_CORR_CFG_IDX] =
{0, 2, 4, 6, 8, 10, 12, 13, 15, 17, 19, 23, 27, 34, 46, 69};
-int MacProcUlSchInfo(Pst *pst, UlSchInfo *ulSchInfo)
+int MacProcUlSchInfo(Pst *pst, UlSchedInfo *ulSchedInfo)
{
- if(ulSchInfo != NULLP)
+ if(ulSchedInfo != NULLP)
{
MacUlSlot *currUlSlot =
- &macCb.macCell->ulSlot[ulSchInfo->slotIndInfo.slot % MAX_SLOT_SUPPORTED];
- memcpy(&currUlSlot->ulCellInfo, ulSchInfo, sizeof(UlSchInfo));
+ &macCb.macCell->ulSlot[ulSchedInfo->slotIndInfo.slot % MAX_SLOT_SUPPORTED];
+ memcpy(&currUlSlot->ulInfo, ulSchedInfo, sizeof(ulSchedInfo));
}
return ROK;
}
################################################################################
*******************************************************************************/
/* header include files (.h) */
+#include "stdbool.h"
#include "envopt.h" /* environment options */
#include "envdep.h" /* environment dependent */
#include "envind.h" /* environment independent */
* -# ROK
* -# RFAILED
**/
-int MacProcDlAlloc(Pst *pst, DlAlloc *dlAlloc)
+int MacProcDlAlloc(Pst *pst, DlSchedInfo *dlSchedInfo)
{
- if(dlAlloc != NULLP)
+ MacDlSlot *currDlSlot = NULLP;
+
+ if(dlSchedInfo != NULLP)
{
- MacDlSlot *currDlSlot =
- &macCb.macCell->dlSlot[dlAlloc->slotIndInfo.slot % MAX_SLOT_SUPPORTED];
- memcpy(&currDlSlot->dlInfo, dlAlloc, sizeof(DlAlloc));
-
- if(currDlSlot->dlInfo.msg4Alloc)
+ if(dlSchedInfo->isBroadcastPres)
+ {
+ currDlSlot = &macCb.macCell->dlSlot[dlSchedInfo->schSlotValue.broadcastTime.slot];
+ currDlSlot->dlInfo.isBroadcastPres = true;
+ memcpy(&currDlSlot->dlInfo.brdcstAlloc, &dlSchedInfo->brdcstAlloc, sizeof(DlBrdcstAlloc));
+ }
+
+ if(dlSchedInfo->rarAlloc != NULLP)
+ {
+ currDlSlot = &macCb.macCell->dlSlot[dlSchedInfo->schSlotValue.rarTime.slot];
+ currDlSlot->dlInfo.rarAlloc = dlSchedInfo->rarAlloc;
+
+ /* MUXing of RAR */
+ fillRarPdu(&currDlSlot->dlInfo.rarAlloc->rarInfo);
+ }
+
+ if(dlSchedInfo->msg4Alloc != NULLP)
{
+ Msg4Alloc *msg4Alloc = NULLP;
MacDlData msg4DlData;
MacCeInfo macCeData;
+
+ currDlSlot = &macCb.macCell->dlSlot[dlSchedInfo->schSlotValue.msg4Time.slot];
+ currDlSlot->dlInfo.msg4Alloc = dlSchedInfo->msg4Alloc; /* copy msg4 alloc pointer in MAC slot info */
+ msg4Alloc = dlSchedInfo->msg4Alloc;
+
memset(&msg4DlData, 0, sizeof(MacDlData));
memset(&macCeData, 0, sizeof(MacCeInfo));
- macCb.macCell->macRaCb[0].msg4TbSize = \
- dlAlloc->msg4Alloc->msg4PdschCfg.codeword[0].tbSize;
+ macCb.macCell->macRaCb[0].msg4TbSize = msg4Alloc->msg4PdschCfg.codeword[0].tbSize;
if(macCb.macCell->macRaCb[0].msg4Pdu != NULLP)
{
fillMsg4DlData(&msg4DlData);
}
}
+
+ /* MUXing for msg4 */
fillMacCe(&macCeData);
macMuxPdu(&msg4DlData, &macCeData, macCb.macCell->macRaCb[0].msg4TbSize);
- /* storing msg4 Pdu in dlAlloc */
- MAC_ALLOC(dlAlloc->msg4Alloc->msg4Info.msg4Pdu, macCb.macCell->macRaCb[0].msg4PduLen);
- if(dlAlloc->msg4Alloc->msg4Info.msg4Pdu != NULLP)
+ /* storing msg4 Pdu in macDlSlot */
+ MAC_ALLOC(msg4Alloc->msg4Info.msg4Pdu, macCb.macCell->macRaCb[0].msg4PduLen);
+ if(msg4Alloc->msg4Info.msg4Pdu != NULLP)
{
- dlAlloc->msg4Alloc->msg4Info.msg4Pdu = macCb.macCell->macRaCb[0].msg4Pdu;
- dlAlloc->msg4Alloc->msg4Info.msg4PduLen = macCb.macCell->macRaCb[0].msg4PduLen;
+ msg4Alloc->msg4Info.msg4Pdu = macCb.macCell->macRaCb[0].msg4Pdu;
+ msg4Alloc->msg4Info.msg4PduLen = macCb.macCell->macRaCb[0].msg4PduLen;
}
+
/* TODO: Free all allocated memory, after the usage */
/* MAC_FREE(macCb.macCell->macRaCb[0].msg4TxPdu, \
macCb.macCell->macRaCb[0].msg4TbSize); // TODO: To be freed after re-transmission is successful.
- MAC_FREE(dlAlloc->msg4Alloc->msg4Info.msg4Pdu,\
+ MAC_FREE(dlSchedInfo->msg4Alloc->msg4Info.msg4Pdu,\
macCb.macCell->macRaCb[0].msg4PduLen); //TODO: To be freed after lower-mac is succesfull
MAC_FREE(msg4DlData.pduInfo[0].dlPdu, macCb.macCell->macRaCb[0].msg4PduLen);
MAC_FREE(macCb.macCell->macRaCb[0].msg4Pdu, macCb.macCell->macRaCb[0].msg4PduLen); */
################################################################################
*******************************************************************************/
/* header include files (.h) */
+#include <stdbool.h>
#include "envopt.h" /* environment options */
#include "envdep.h" /* environment dependent */
#include "envind.h" /* environment independent */
static int RLOG_FILE_ID=182;
static int RLOG_MODULE_ID=4096;
/* header include files -- defines (.h) */
+#include <stdbool.h>
#include "envopt.h" /* environment options */
#include "envdep.h" /* environment dependent */
#include "envind.h" /* environment independent */
static int RLOG_MODULE_ID=4096;
/* header include files (.h) */
+#include "stdbool.h"
#include "envopt.h" /* environment options */
#include "envdep.h" /* environment dependent */
#include "envind.h" /* environment independent */
schCellCfg.schInitialDlBwp.bwp.numPrb = macCellCfg->initialDlBwp.bwp.numPrb;
schCellCfg.schInitialDlBwp.bwp.scs = macCellCfg->initialDlBwp.bwp.scs;
schCellCfg.schInitialDlBwp.bwp.cyclicPrefix = macCellCfg->initialDlBwp.bwp.cyclicPrefix;
- schCellCfg.schInitialDlBwp.pdcchCommon.raSearchSpace.searchSpaceId =
- macCellCfg->initialDlBwp.pdcchCommon.raSearchSpace.searchSpaceId;
- schCellCfg.schInitialDlBwp.pdcchCommon.raSearchSpace.coresetId =
- macCellCfg->initialDlBwp.pdcchCommon.raSearchSpace.coresetId;
- schCellCfg.schInitialDlBwp.pdcchCommon.raSearchSpace.monitoringSlot =
- macCellCfg->initialDlBwp.pdcchCommon.raSearchSpace.monitoringSlot;
- schCellCfg.schInitialDlBwp.pdcchCommon.raSearchSpace.duration =
- macCellCfg->initialDlBwp.pdcchCommon.raSearchSpace.duration;
- schCellCfg.schInitialDlBwp.pdcchCommon.raSearchSpace.monitoringSymbol =
- macCellCfg->initialDlBwp.pdcchCommon.raSearchSpace.monitoringSymbol;
- schCellCfg.schInitialDlBwp.pdcchCommon.raSearchSpace.candidate.aggLevel1 =
- macCellCfg->initialDlBwp.pdcchCommon.raSearchSpace.candidate.aggLevel1;
- schCellCfg.schInitialDlBwp.pdcchCommon.raSearchSpace.candidate.aggLevel2 =
- macCellCfg->initialDlBwp.pdcchCommon.raSearchSpace.candidate.aggLevel2;
- schCellCfg.schInitialDlBwp.pdcchCommon.raSearchSpace.candidate.aggLevel4 =
- macCellCfg->initialDlBwp.pdcchCommon.raSearchSpace.candidate.aggLevel4;
- schCellCfg.schInitialDlBwp.pdcchCommon.raSearchSpace.candidate.aggLevel8 =
- macCellCfg->initialDlBwp.pdcchCommon.raSearchSpace.candidate.aggLevel8;
- schCellCfg.schInitialDlBwp.pdcchCommon.raSearchSpace.candidate.aggLevel16 =
- macCellCfg->initialDlBwp.pdcchCommon.raSearchSpace.candidate.aggLevel16;
+ schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.searchSpaceId =
+ macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.searchSpaceId;
+ schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.coresetId =
+ macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.coresetId;
+ schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.monitoringSlot =
+ macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.monitoringSlot;
+ schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.duration =
+ macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.duration;
+ schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.monitoringSymbol =
+ macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.monitoringSymbol;
+ schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel1 =
+ macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel1;
+ schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel2 =
+ macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel2;
+ schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel4 =
+ macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel4;
+ schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel8 =
+ macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel8;
+ schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel16 =
+ macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel16;
schCellCfg.schInitialDlBwp.pdschCommon.k0 = macCellCfg->initialDlBwp.pdschCommon.k0;
schCellCfg.schInitialDlBwp.pdschCommon.mappingType =
macCellCfg->initialDlBwp.pdschCommon.mappingType;
invoked by PHY towards MAC
*/
/* header include files -- defines (.h) */
+#include <stdbool.h>
#include "envopt.h" /* environment options */
#include "envdep.h" /* environment dependent */
#include "envind.h" /* environment independent */
}
#endif
- CmLteTimingInfo timingInfo;
- RGADDTOCRNTTIME(cellCb->crntTime, timingInfo, TFU_DELTA);
/* Trigger for DL TTI REQ */
- handleDlTtiReq(&timingInfo);
+ handleDlTtiReq(slotInd);
/* Trigger for UL TTI REQ */
- handleUlTtiReq(&timingInfo);
+ handleUlTtiReq(slotInd);
dlSf = &cellCb->subFrms[(slotInd.slot % RG_NUM_SUB_FRAMES)];
#include "sch.h"
#include "sch_utils.h"
#include "du_log.h"
+#include "common_def.h"
+
extern SchCb schCb[SCH_MAX_INST];
void SchFillCfmPst(Pst *reqPst,Pst *cfmPst,RgMngmt *cfm);
/* local defines */
for(uint8_t idx=0; idx<SCH_NUM_SLOTS; idx++)
{
- SchDlAlloc *schDlAlloc;
- SchUlAlloc *schUlAlloc;
+ SchDlSlotInfo *schDlSlotInfo;
+ SchUlSlotInfo *schUlSlotInfo;
/* DL Alloc */
- SCH_ALLOC(schDlAlloc, sizeof(SchDlAlloc));
- if(!schDlAlloc)
+ SCH_ALLOC(schDlSlotInfo, sizeof(SchDlSlotInfo));
+ if(!schDlSlotInfo)
{
DU_LOG("\nMemory allocation failed in InitSchCellCb");
return RFAILED;
}
/* UL Alloc */
- SCH_ALLOC(schUlAlloc, sizeof(SchUlAlloc));
- if(!schUlAlloc)
+ SCH_ALLOC(schUlSlotInfo, sizeof(SchUlSlotInfo));
+ if(!schUlSlotInfo)
{
DU_LOG("\nMemory allocation failed in InitSchCellCb");
return RFAILED;
}
- schDlAlloc->totalPrb = schUlAlloc->totalPrb = MAX_NUM_RB;
+ schDlSlotInfo->totalPrb = schUlSlotInfo->totalPrb = MAX_NUM_RB;
for(uint8_t itr=0; itr<SCH_SYMBOL_PER_SLOT; itr++)
{
- schDlAlloc->assignedPrb[itr] = 0;
- schUlAlloc->assignedPrb[itr] = 0;
+ schDlSlotInfo->assignedPrb[itr] = 0;
+ schUlSlotInfo->assignedPrb[itr] = 0;
}
- schUlAlloc->schPuschInfo = NULLP;
+ schUlSlotInfo->schPuschInfo = NULLP;
for(uint8_t itr=0; itr<MAX_SSB_IDX; itr++)
{
- memset(&schDlAlloc->ssbInfo[itr], 0, sizeof(SsbInfo));
+ memset(&schDlSlotInfo->ssbInfo[itr], 0, sizeof(SsbInfo));
}
- cell->dlAlloc[idx] = schDlAlloc;
- cell->ulAlloc[idx] = schUlAlloc;
+ cell->schDlSlotInfo[idx] = schDlSlotInfo;
+ cell->schUlSlotInfo[idx] = schUlSlotInfo;
}
schCb[inst].cells[inst] = cell;
uint8_t firstSymbol = 0; /* need to calculate using formula mentioned in 38.213 */
uint8_t slotIndex = 0;
uint8_t FreqDomainResource[6] = {0};
+ uint16_t tbSize = 0;
+ uint8_t numPdschSymbols = 12; /* considering pdsch region from 2 to 13 */
PdcchCfg *pdcch = &(sib1SchCfg->sib1PdcchCfg);
PdschCfg *pdsch = &(sib1SchCfg->sib1PdschCfg);
+ BwpCfg *bwp = &(sib1SchCfg->bwp);
coreset0Idx = sib1SchCfg->coresetZeroIndex;
searchSpace0Idx = sib1SchCfg->searchSpaceZeroIndex;
/* calculate the PRBs */
calculatePRB( ((offsetPointA-offset)/6), (numRbs/6), FreqDomainResource);
+ /* fill BWP */
+ bwp->BWPSize = MAX_NUM_RB; /* whole of BW */
+ bwp->BWPStart = 0;
+ bwp->subcarrierSpacing = 0; /* 15Khz */
+ bwp->cyclicPrefix = 0; /* normal */
+
/* fill the PDCCH PDU */
- pdcch->pdcchBwpCfg.BWPSize = MAX_NUM_RB; /* whole of BW */
- pdcch->pdcchBwpCfg.BWPStart = 0;
- pdcch->pdcchBwpCfg.subcarrierSpacing = 0; /* 15Khz */
- pdcch->pdcchBwpCfg.cyclicPrefix = 0; /* normal */
pdcch->coreset0Cfg.coreSet0Size = numRbs;
pdcch->coreset0Cfg.startSymbolIndex = firstSymbol;
pdcch->coreset0Cfg.durationSymbols = numSymbols;
pdsch->pduBitmap = 0; /* PTRS and CBG params are excluded */
pdsch->rnti = 0xFFFF; /* SI-RNTI */
pdsch->pduIndex = 0;
- pdsch->pdschBwpCfg.BWPSize = MAX_NUM_RB; /* whole of BW */
- pdsch->pdschBwpCfg.BWPStart = 0;
pdsch->numCodewords = 1;
for(cwCount = 0; cwCount < pdsch->numCodewords; cwCount++)
{
pdsch->codeword[cwCount].mcsIndex = sib1SchCfg->sib1Mcs;
pdsch->codeword[cwCount].mcsTable = 0; /* notqam256 */
pdsch->codeword[cwCount].rvIndex = 0;
- pdsch->codeword[cwCount].tbSize = 768/8; /* 38.214: Table 5.1.3.2-1,
- devided by 8 to get the value in bytes */
+ tbSize = schCalcTbSize(sib1SchCfg->sib1PduLen);
+ pdsch->codeword[cwCount].tbSize = tbSize;
}
pdsch->dataScramblingId = pci;
pdsch->numLayers = 1;
pdsch->dmrs.dmrsPorts = 0;
pdsch->freqAlloc.resourceAlloc = 1; /* RAT type-1 RIV format */
pdsch->freqAlloc.rbStart = offset + SCH_SSB_PRB_DURATION; /* the RB numbering starts from coreset0, and PDSCH is always above SSB */
- /* 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 */
- pdsch->freqAlloc.rbSize = 10; /* This value is calculated from above formulae */
+ pdsch->freqAlloc.rbSize = schCalcNumPrb(tbSize,sib1SchCfg->sib1Mcs,numPdschSymbols);
pdsch->freqAlloc.vrbPrbMapping = 0; /* non-interleaved */
pdsch->timeAlloc.rowIndex = 1;
pdsch->timeAlloc.startSymbolIndex = 2; /* spec-38.214, Table 5.1.2.1-1 */
- pdsch->timeAlloc.numSymbols = 12;
+ pdsch->timeAlloc.numSymbols = numPdschSymbols;
pdsch->beamPdschInfo.numPrgs = 1;
pdsch->beamPdschInfo.prgSize = 1;
pdsch->beamPdschInfo.digBfInterfaces = 0;
DU_LOG("\nSCH : Received RLC BO Status indication");
SchCellCb *cell = schCb[inst].cells[inst];
- SchDlAlloc *dlAlloc = \
- cell->dlAlloc[(cell->slotInfo.slot + SCHED_DELTA) % SCH_NUM_SLOTS];
+ SchDlSlotInfo *schDlSlotInfo = \
+ cell->schDlSlotInfo[(cell->slotInfo.slot + SCHED_DELTA + PHY_DELTA) % SCH_NUM_SLOTS];
for(lcIdx = 0; lcIdx < dlBoInfo->numLc; lcIdx++)
{
if(dlBoInfo->boInfo[lcIdx].lcId == CCCH_LCID)
{
- SCH_ALLOC(dlAlloc->msg4Info, sizeof(Msg4Info));
- if(!dlAlloc->msg4Info)
+ SCH_ALLOC(schDlSlotInfo->msg4Info, sizeof(Msg4Info));
+ if(!schDlSlotInfo->msg4Info)
{
DU_LOG("\nSCH : Memory allocation failed for msg4Info");
- dlAlloc = NULL;
+ schDlSlotInfo = NULL;
return RFAILED;
}
- dlAlloc->msg4Info->crnti = dlBoInfo->crnti;
- dlAlloc->msg4Info->ndi = 1;
- dlAlloc->msg4Info->harqProcNum = 0;
- dlAlloc->msg4Info->dlAssignIdx = 0;
- dlAlloc->msg4Info->pucchTpc = 0;
- dlAlloc->msg4Info->pucchResInd = 0;
- dlAlloc->msg4Info->harqFeedbackInd = 0;
- dlAlloc->msg4Info->dciFormatId = 1;
+ schDlSlotInfo->msg4Info->crnti = dlBoInfo->crnti;
+ schDlSlotInfo->msg4Info->ndi = 1;
+ schDlSlotInfo->msg4Info->harqProcNum = 0;
+ schDlSlotInfo->msg4Info->dlAssignIdx = 0;
+ schDlSlotInfo->msg4Info->pucchTpc = 0;
+ schDlSlotInfo->msg4Info->pucchResInd = 0;
+ schDlSlotInfo->msg4Info->harqFeedbackInd = 0;
+ schDlSlotInfo->msg4Info->dciFormatId = 1;
}
}
#define SCH_MEM_REGION 4
#define SCH_POOL 1
#define SCHED_DELTA 1
-#define RAR_DELAY 1
+#define BO_DELTA 1
+#define RAR_DELAY 2
#define SCH_MAX_UE 1
#define PUSCH_START_RB 15
#define SI_RNTI 0xFFFF
* @brief
* scheduler allocationsfor DL per cell.
*/
-typedef struct schDlAlloc
+typedef struct schDlSlotInfo
{
uint16_t totalPrb; /*!< Number of RBs in the cell */
uint16_t assignedPrb[SCH_SYMBOL_PER_SLOT]; /*!< Num RBs and corresponding symbols allocated */
uint8_t ssbIdxSupported; /*!< Max SSB index */
SsbInfo ssbInfo[MAX_SSB_IDX]; /*!< SSB info */
bool sib1Pres;
- bool rarPres;
- RarInfo rarInfo;
+ //bool rarPres;
+ RarInfo *rarInfo;
Msg4Info *msg4Info;
-}SchDlAlloc;
+}SchDlSlotInfo;
typedef struct schRaCb
{
* @brief
* scheduler allocationsfor UL per cell.
*/
-typedef struct schUlAlloc
+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 */
bool puschPres; /*!< PUSCH presence field */
SchPuschInfo *schPuschInfo; /*!< PUSCH info */
-}SchUlAlloc;
+}SchUlSlotInfo;
/**
* @brief
Inst macInst; /*!< Index of the MAC instance */
uint8_t numSlots; /*!< Number of slots in current frame */
SlotIndInfo slotInfo; /*!< SFN, Slot info being processed*/
- SchDlAlloc *dlAlloc[SCH_NUM_SLOTS]; /*!< SCH resource allocations in DL */
- SchUlAlloc *ulAlloc[SCH_NUM_SLOTS]; /*!< SCH resource allocations in UL */
+ SchDlSlotInfo *schDlSlotInfo[SCH_NUM_SLOTS]; /*!< SCH resource allocations in DL */
+ SchUlSlotInfo *schUlSlotInfo[SCH_NUM_SLOTS]; /*!< SCH resource allocations in UL */
SchCellCfg cellCfg; /*!< Cell ocnfiguration */
SchRaCb raCb[SCH_MAX_UE];
}SchCellCb;
#include "mac_sch_interface.h"
#include "sch.h"
#include "sch_utils.h"
+#include "common_def.h"
extern SchCb schCb[SCH_MAX_INST];
extern uint16_t prachCfgIdxTable[MAX_PRACH_CONFIG_IDX][8];
/* schedule SSB */
uint8_t scs, ssbStartPrb, ssbStartSymb, idx;
uint8_t ssbStartSymbArr[SCH_MAX_SSB_BEAM];
- SchDlAlloc *dlAlloc;
+ SchDlSlotInfo *schDlSlotInfo;
SsbInfo ssbInfo;
- dlAlloc = cell->dlAlloc[slot];
+ schDlSlotInfo = cell->schDlSlotInfo[slot];
if(dlBrdcstAlloc->ssbTrans)
{
scs = cell->cellCfg.ssbSchCfg.scsCommon;
ssbInfo.tdAlloc.startSymb = ssbStartSymb;
ssbInfo.tdAlloc.numSymb = SCH_SSB_SYMB_DURATION;
dlBrdcstAlloc->ssbInfo[idx] = ssbInfo;
- dlAlloc->ssbInfo[idx] = ssbInfo;
-
+ schDlSlotInfo->ssbInfo[idx] = ssbInfo;
}
- dlAlloc->ssbPres = true;
- dlAlloc->ssbIdxSupported = dlBrdcstAlloc->ssbIdxSupported;
+ schDlSlotInfo->ssbPres = true;
+ schDlSlotInfo->ssbIdxSupported = dlBrdcstAlloc->ssbIdxSupported;
for(idx=ssbStartSymb; idx<ssbStartSymb+SCH_SSB_SYMB_DURATION; idx++)
{
- dlAlloc->assignedPrb[idx] = ssbStartPrb + SCH_SSB_PRB_DURATION + 1; /* +1 for kSsb */
+ schDlSlotInfo->assignedPrb[idx] = ssbStartPrb + SCH_SSB_PRB_DURATION + 1; /* +1 for kSsb */
}
-
}
/* SIB1 allocation */
if(dlBrdcstAlloc->sib1Trans)
{
- dlAlloc->sib1Pres = true;
+ schDlSlotInfo->sib1Pres = true;
for(idx=0; idx<SCH_SYMBOL_PER_SLOT; idx++)
{
- dlAlloc->assignedPrb[idx] = ssbStartPrb + SCH_SSB_PRB_DURATION + 1 + 10; /* 10 PRBs for sib1 */
+ schDlSlotInfo->assignedPrb[idx] = ssbStartPrb + SCH_SSB_PRB_DURATION + 1 + 10; /* 10 PRBs for sib1 */
}
+ memcpy(&dlBrdcstAlloc->sib1Alloc.bwp, &cell->cellCfg.sib1SchCfg.bwp, sizeof(BwpCfg));
memcpy(&dlBrdcstAlloc->sib1Alloc.sib1PdcchCfg, &cell->cellCfg.sib1SchCfg.sib1PdcchCfg, sizeof(PdcchCfg));
memcpy(&dlBrdcstAlloc->sib1Alloc.sib1PdschCfg, &cell->cellCfg.sib1SchCfg.sib1PdschCfg, sizeof(PdschCfg));
}
* RFAILED - failure
*
* ****************************************************************/
-int sendUlSchInfoToMac(UlSchInfo *ulSchInfo, Inst inst)
+int sendUlSchInfoToMac(UlSchedInfo *ulSchedInfo, Inst inst)
{
Pst pst;
SCH_FILL_RSP_PST(pst, inst);
pst.event = EVENT_UL_SCH_INFO;
- return(*schMacUlSchInfoOpts[pst.selector])(&pst, ulSchInfo);
-
+ return(*schMacUlSchInfoOpts[pst.selector])(&pst, ulSchedInfo);
}
/**
* @brief resource allocation for PRACH
* This function handles PRACH allocation
*
* @param[in] SchCellCb *cell, cell cb
- * @param[in] UlSchInfo *ulSchInfo, UL scheduling info
+ * @param[in] UlSchedInfo *ulSchedInfo, UL scheduling info
* @return void
**/
-int schPrachResAlloc(SchCellCb *cell, UlSchInfo *ulSchInfo)
+int schPrachResAlloc(SchCellCb *cell, UlSchedInfo *ulSchedInfo, SlotIndInfo prachOccasionTimingInfo)
{
uint8_t numPrachRb = 0;
uint8_t numRa = 0;
uint8_t freqStart = 0;
- uint16_t sfn = 0;
- uint16_t slot = 0;
uint8_t prachCfgIdx = 0;
uint8_t prachFormat = 0;
uint8_t x = 0;
uint8_t prachOcas = 0;
uint8_t dataType = 0;
uint8_t idx = 0;
- SchUlAlloc *ulAlloc = NULLP;
+ SchUlSlotInfo *schUlSlotInfo = NULLP;
- sfn = cell->slotInfo.sfn;
- slot = cell->slotInfo.slot;
- ulAlloc = cell->ulAlloc[cell->slotInfo.slot];
+ schUlSlotInfo = cell->schUlSlotInfo[prachOccasionTimingInfo.slot];
prachCfgIdx = cell->cellCfg.schRachCfg.prachCfgIdx;
/* derive the prachCfgIdx table paramters */
y = prachCfgIdxTable[prachCfgIdx][2];
prachSubframe = prachCfgIdxTable[prachCfgIdx][3];
- if((sfn%x) != y)
+ if((prachOccasionTimingInfo.sfn%x) != y)
{
/* prach occasion does not lie in this SFN */
DU_LOG("\nPRACH ocassion doesn't lie in this SFN");
return RFAILED;
}
/* check for subFrame number */
- if ((1 << slot) & prachSubframe)
+ if ((1 << prachOccasionTimingInfo.slot) & prachSubframe)
{
/* prach ocassion present in this subframe */
dataType |= SCH_DATATYPE_PRACH;
/* Considering first slot in the frame for PRACH */
idx = 0;
- ulAlloc->assignedPrb[idx] = freqStart+numPrachRb;
+ schUlSlotInfo->assignedPrb[idx] = freqStart+numPrachRb;
}
- /* Fill UL SCH Info */
- ulSchInfo->cellId = cell->cellId;
- ulSchInfo->slotIndInfo.sfn = sfn;
- ulSchInfo->slotIndInfo.slot = slot;
- ulSchInfo->dataType = dataType;
+ ulSchedInfo->dataType = dataType;
/* prach info */
- ulSchInfo->prachSchInfo.numPrachOcas = prachOcas;
- ulSchInfo->prachSchInfo.prachFormat = prachFormat;
- ulSchInfo->prachSchInfo.numRa = numRa;
- ulSchInfo->prachSchInfo.prachStartSymb = prachStartSymbol;
+ ulSchedInfo->prachSchInfo.numPrachOcas = prachOcas;
+ ulSchedInfo->prachSchInfo.prachFormat = prachFormat;
+ ulSchedInfo->prachSchInfo.numRa = numRa;
+ ulSchedInfo->prachSchInfo.prachStartSymb = prachStartSymbol;
return ROK;
}
uint8_t schUlResAlloc(SchCellCb *cell, Inst schInst)
{
int ret = ROK;
- UlSchInfo ulSchInfo;
- SchUlAlloc *ulAlloc;
+ UlSchedInfo ulSchedInfo;
+ SchUlSlotInfo *schUlSlotInfo;
+ SlotIndInfo ulTimingInfo;
+
+ /* add PHY delta */
+ ADD_DELTA_TO_TIME(cell->slotInfo,ulTimingInfo,PHY_DELTA+SCHED_DELTA);
+
+ ulSchedInfo.cellId = cell->cellId;
+ ulSchedInfo.slotIndInfo.sfn = ulTimingInfo.sfn;
+ ulSchedInfo.slotIndInfo.slot = ulTimingInfo.slot;
/* Schedule resources for PRACH */
- schPrachResAlloc(cell, &ulSchInfo);
+ schPrachResAlloc(cell, &ulSchedInfo, ulTimingInfo);
- ulAlloc = cell->ulAlloc[cell->slotInfo.slot];
+ schUlSlotInfo = cell->schUlSlotInfo[ulTimingInfo.slot];
- if(ulAlloc->schPuschInfo)
+ if(schUlSlotInfo->schPuschInfo)
{
- ulSchInfo.crnti = cell->raCb[0].tcrnti;
- ulSchInfo.dataType |= SCH_DATATYPE_PUSCH;
- memcpy(&ulSchInfo.schPuschInfo, ulAlloc->schPuschInfo,
+ ulSchedInfo.crnti = cell->raCb[0].tcrnti;
+ ulSchedInfo.dataType |= SCH_DATATYPE_PUSCH;
+ memcpy(&ulSchedInfo.schPuschInfo, schUlSlotInfo->schPuschInfo,
sizeof(SchPuschInfo));
- SCH_FREE(ulAlloc->schPuschInfo, sizeof(SchPuschInfo));
- ulAlloc->schPuschInfo = NULL;
+ SCH_FREE(schUlSlotInfo->schPuschInfo, sizeof(SchPuschInfo));
+ schUlSlotInfo->schPuschInfo = NULL;
}
//send msg to MAC
- ret = sendUlSchInfoToMac(&ulSchInfo, schInst);
+ ret = sendUlSchInfoToMac(&ulSchedInfo, schInst);
if(ret != ROK)
{
DU_LOG("\nSending UL Sch info from SCH to MAC failed");
PdcchCfg *pdcch = &msg4Alloc->msg4PdcchCfg;
PdschCfg *pdsch = &msg4Alloc->msg4PdschCfg;
+ BwpCfg *bwp = &msg4Alloc->bwp;
initialBwp = &cell->cellCfg.schInitialDlBwp;
offsetPointA = cell->cellCfg.ssbSchCfg.ssbOffsetPointA;
- coreset0Idx = initialBwp->pdcchCommon.raSearchSpace.coresetId;
+ coreset0Idx = initialBwp->pdcchCommon.commonSearchSpace.coresetId;
/* derive the sib1 coreset0 params from table 13-1 spec 38.213 */
numRbs = coresetIdxTable[coreset0Idx][1];
uint16_t mask = 0x2000;
for(firstSymbol=0; firstSymbol<14;firstSymbol++)
{
- if(initialBwp->pdcchCommon.raSearchSpace.monitoringSymbol & mask)
+ if(initialBwp->pdcchCommon.commonSearchSpace.monitoringSymbol & mask)
break;
else
mask = mask>>1;
/* calculate the PRBs */
calculatePRB( ((offsetPointA-offset)/6), (numRbs/6), FreqDomainResource);
+ /* fill BWP */
+ bwp->BWPSize = initialBwp->bwp.numPrb;
+ bwp->BWPStart = initialBwp->bwp.firstPrb;
+ bwp->subcarrierSpacing = initialBwp->bwp.scs;
+ bwp->cyclicPrefix = initialBwp->bwp.cyclicPrefix;
+
/* fill the PDCCH PDU */
- pdcch->pdcchBwpCfg.BWPSize = initialBwp->bwp.numPrb;
- pdcch->pdcchBwpCfg.BWPStart = initialBwp->bwp.firstPrb;
- pdcch->pdcchBwpCfg.subcarrierSpacing = initialBwp->bwp.scs;
- pdcch->pdcchBwpCfg.cyclicPrefix = initialBwp->bwp.cyclicPrefix;
pdcch->coreset0Cfg.startSymbolIndex = firstSymbol;
pdcch->coreset0Cfg.durationSymbols = numSymbols;
memcpy(pdcch->coreset0Cfg.freqDomainResource,FreqDomainResource,6);
pdcch->coreset0Cfg.shiftIndex = cell->cellCfg.phyCellId;
pdcch->coreset0Cfg.precoderGranularity = 0; /* sameAsRegBundle */
pdcch->numDlDci = 1;
- pdcch->dci.rnti = cell->dlAlloc[slot]->msg4Info->crnti;
+ pdcch->dci.rnti = cell->schDlSlotInfo[slot]->msg4Info->crnti;
pdcch->dci.scramblingId = cell->cellCfg.phyCellId;
pdcch->dci.scramblingRnti = 0;
pdcch->dci.cceIndex = 4; /* considering SIB1 is sent at cce 0-1-2-3 */
/* fill the PDSCH PDU */
uint8_t cwCount = 0;
pdsch->pduBitmap = 0; /* PTRS and CBG params are excluded */
- pdsch->rnti = cell->dlAlloc[slot]->msg4Info->crnti;
+ pdsch->rnti = cell->schDlSlotInfo[slot]->msg4Info->crnti;
pdsch->pduIndex = 0;
- pdsch->pdschBwpCfg.BWPSize = initialBwp->bwp.numPrb;
- pdsch->pdschBwpCfg.BWPStart = initialBwp->bwp.firstPrb;
pdsch->numCodewords = 1;
for(cwCount = 0; cwCount < pdsch->numCodewords; cwCount++)
{
#include "mac_sch_interface.h"
#include "sch.h"
#include "sch_utils.h"
+#include "common_def.h"
extern SchCb schCb[SCH_MAX_INST];
extern uint8_t puschDeltaTable[MAX_MU_PUSCH];
uint8_t schAllocMsg3Pusch(Inst schInst, uint16_t slot, uint16_t *msg3StartRb,
uint8_t *msg3NumRb)
{
- SchCellCb *cell = NULLP;
- SchUlAlloc *ulAlloc = NULLP;
+ SchCellCb *cell = NULLP;
+ SchUlSlotInfo *schUlSlotInfo = NULLP;
uint8_t puschMu = 0;
uint8_t msg3SlotAlloc = 0;
uint8_t delta = 0;
for(idx=startSymb; idx<symbLen; idx++)
{
- cell->ulAlloc[msg3SlotAlloc]->assignedPrb[idx] = startRb + numRb;
+ cell->schUlSlotInfo[msg3SlotAlloc]->assignedPrb[idx] = startRb + numRb;
}
- ulAlloc = cell->ulAlloc[msg3SlotAlloc];
+ schUlSlotInfo = cell->schUlSlotInfo[msg3SlotAlloc];
- SCH_ALLOC(ulAlloc->schPuschInfo, sizeof(SchPuschInfo));
- if(!ulAlloc->schPuschInfo)
+ SCH_ALLOC(schUlSlotInfo->schPuschInfo, sizeof(SchPuschInfo));
+ if(!schUlSlotInfo->schPuschInfo)
{
DU_LOG("SCH: Memory allocation failed in schAllocMsg3Pusch");
return RFAILED;
}
- ulAlloc->schPuschInfo->harqProcId = SCH_HARQ_PROC_ID;
- ulAlloc->schPuschInfo->resAllocType = SCH_ALLOC_TYPE_1;
- ulAlloc->schPuschInfo->fdAlloc.startPrb = startRb;
- ulAlloc->schPuschInfo->fdAlloc.numPrb = numRb;
- ulAlloc->schPuschInfo->tdAlloc.startSymb = startSymb;
- ulAlloc->schPuschInfo->tdAlloc.numSymb = symbLen;
- ulAlloc->schPuschInfo->tbInfo.mcs = 4;
- ulAlloc->schPuschInfo->tbInfo.ndi = 1; /* new transmission */
- ulAlloc->schPuschInfo->tbInfo.rv = 0;
- ulAlloc->schPuschInfo->tbInfo.tbSize = 24; /*Considering 2 PRBs */
+ schUlSlotInfo->schPuschInfo->harqProcId = SCH_HARQ_PROC_ID;
+ schUlSlotInfo->schPuschInfo->resAllocType = SCH_ALLOC_TYPE_1;
+ schUlSlotInfo->schPuschInfo->fdAlloc.startPrb = startRb;
+ schUlSlotInfo->schPuschInfo->fdAlloc.numPrb = numRb;
+ schUlSlotInfo->schPuschInfo->tdAlloc.startSymb = startSymb;
+ schUlSlotInfo->schPuschInfo->tdAlloc.numSymb = symbLen;
+ schUlSlotInfo->schPuschInfo->tbInfo.mcs = 4;
+ schUlSlotInfo->schPuschInfo->tbInfo.ndi = 1; /* new transmission */
+ schUlSlotInfo->schPuschInfo->tbInfo.rv = 0;
+ schUlSlotInfo->schPuschInfo->tbInfo.tbSize = 24; /*Considering 2 PRBs */
*msg3StartRb = startRb;
*msg3NumRb = numRb;
uint8_t schProcessRachInd(RachIndInfo *rachInd, Inst schInst)
{
SchCellCb *cell = schCb[schInst].cells[schInst];
+ RarInfo *rarInfo = NULLP;
uint16_t raRnti = 0;
- uint16_t slot;
+ uint16_t rarSlot = 0;
uint16_t msg3StartRb;
uint8_t msg3NumRb;
uint8_t ret = ROK;
- /* RAR will sent in the next slot */
- slot = (rachInd->timingInfo.slot+SCHED_DELTA+RAR_DELAY)%SCH_NUM_SLOTS;
- SchDlAlloc *dlAlloc = cell->dlAlloc[slot];
- RarInfo *rarInfo = &(dlAlloc->rarInfo);
+ /* RAR will sent with a delay of RAR_DELAY */
+ rarSlot = (rachInd->timingInfo.slot+RAR_DELAY+PHY_DELTA)%SCH_NUM_SLOTS;
- /* rar message presense in next slot ind and will be scheduled */
- dlAlloc->rarPres = true;
+ SchDlSlotInfo *schDlSlotInfo = cell->schDlSlotInfo[rarSlot]; /* RAR will sent in the next slot */
+ /* Allocate the rarInfo, this pointer will be checked at schProcessSlotInd function */
+ SCH_ALLOC(rarInfo, sizeof(RarInfo));
+ if(rarInfo == NULLP)
+ {
+ DU_LOG("\nMAC: Memory Allocation failed for rarInfo");
+ return RFAILED;
+ }
+
+ schDlSlotInfo->rarInfo = rarInfo;
+
/* calculate the ra-rnti value */
raRnti = calculateRaRnti(rachInd->symbolIdx,rachInd->slotIdx,rachInd->freqIdx);
createSchRaCb(rachInd->crnti,schInst);
/* allocate resources for msg3 */
- ret = schAllocMsg3Pusch(schInst, slot, &msg3StartRb, &msg3NumRb);
+ ret = schAllocMsg3Pusch(schInst, rarSlot, &msg3StartRb, &msg3NumRb);
if(ret == ROK)
{
-
/* fill RAR info */
rarInfo->raRnti = raRnti;
rarInfo->tcrnti = rachInd->crnti;
uint8_t numSymbols = 0;
uint8_t offset = 0;
uint8_t FreqDomainResource[6] = {0};
+ uint16_t tbSize = 0;
+ uint8_t numPdschSymbols = 12; /* considering pdsch region from 2 to 13 */
+ uint8_t mcs = 4; /* MCS fixed to 4 */
+
SchBwpDlCfg *initialBwp = &schCb[inst].cells[inst]->cellCfg.schInitialDlBwp;
PdcchCfg *pdcch = &rarAlloc->rarPdcchCfg;
PdschCfg *pdsch = &rarAlloc->rarPdschCfg;
+ BwpCfg *bwp = &rarAlloc->bwp;
- coreset0Idx = initialBwp->pdcchCommon.raSearchSpace.coresetId;
+ coreset0Idx = initialBwp->pdcchCommon.commonSearchSpace.coresetId;
/* derive the sib1 coreset0 params from table 13-1 spec 38.213 */
numRbs = coresetIdxTable[coreset0Idx][1];
uint16_t mask = 0x2000;
for(firstSymbol=0; firstSymbol<14;firstSymbol++)
{
- if(initialBwp->pdcchCommon.raSearchSpace.monitoringSymbol & mask)
+ if(initialBwp->pdcchCommon.commonSearchSpace.monitoringSymbol & mask)
break;
else
mask = mask>>1;
/* calculate the PRBs */
calculatePRB( ((offsetPointA-offset)/6), (numRbs/6), FreqDomainResource);
+ /* fill BWP */
+ bwp->BWPSize = initialBwp->bwp.numPrb;
+ bwp->BWPStart = initialBwp->bwp.firstPrb;
+ bwp->subcarrierSpacing = initialBwp->bwp.scs;
+ bwp->cyclicPrefix = initialBwp->bwp.cyclicPrefix;
+
/* fill the PDCCH PDU */
- pdcch->pdcchBwpCfg.BWPSize = initialBwp->bwp.numPrb;
- pdcch->pdcchBwpCfg.BWPStart = initialBwp->bwp.firstPrb;
- pdcch->pdcchBwpCfg.subcarrierSpacing = initialBwp->bwp.scs;
- pdcch->pdcchBwpCfg.cyclicPrefix = initialBwp->bwp.cyclicPrefix;
pdcch->coreset0Cfg.startSymbolIndex = firstSymbol;
pdcch->coreset0Cfg.durationSymbols = numSymbols;
memcpy(pdcch->coreset0Cfg.freqDomainResource,FreqDomainResource,6);
pdsch->pduBitmap = 0; /* PTRS and CBG params are excluded */
pdsch->rnti = raRnti; /* RA-RNTI */
pdsch->pduIndex = 0;
- pdsch->pdschBwpCfg.BWPSize = initialBwp->bwp.numPrb;
- pdsch->pdschBwpCfg.BWPStart = initialBwp->bwp.firstPrb;
pdsch->numCodewords = 1;
for(cwCount = 0; cwCount < pdsch->numCodewords; cwCount++)
{
pdsch->codeword[cwCount].targetCodeRate = 308;
pdsch->codeword[cwCount].qamModOrder = 2;
- pdsch->codeword[cwCount].mcsIndex = 4; /* mcs configured to 4 */
- pdsch->codeword[cwCount].mcsTable = 0; /* notqam256 */
+ pdsch->codeword[cwCount].mcsIndex = mcs; /* mcs configured to 4 */
+ pdsch->codeword[cwCount].mcsTable = 0; /* notqam256 */
pdsch->codeword[cwCount].rvIndex = 0;
- pdsch->codeword[cwCount].tbSize = 80/8; /* 38.214: Table 5.1.3.2-1,
- devided by 8 to get the value in bytes */
+ tbSize = schCalcTbSize(10); /* 8 bytes RAR and 2 bytes padding */
+ pdsch->codeword[cwCount].tbSize = tbSize;
}
pdsch->dataScramblingId = pci;
pdsch->numLayers = 1;
pdsch->dmrs.dmrsPorts = 0;
pdsch->freqAlloc.resourceAlloc = 1; /* RAT type-1 RIV format */
pdsch->freqAlloc.rbStart = offset + SCH_SSB_PRB_DURATION; /* the RB numbering starts from coreset0, and PDSCH is always above SSB */
- /* formula used for calculation of rbSize, 38.213 section 5.1.3.2 *
- * Ninfo = S . Nre . R . Qm . v *
- * Nre' = Nsc . NsymPdsch - NdmrsSymb - Noh *
- * Nre = min(156,Nre') . nPrb */
- pdsch->freqAlloc.rbSize = 1; /* This value is calculated from above formulae */
+ pdsch->freqAlloc.rbSize = schCalcNumPrb(tbSize,mcs,numPdschSymbols);
pdsch->freqAlloc.vrbPrbMapping = 0; /* non-interleaved */
pdsch->timeAlloc.startSymbolIndex = initialBwp->pdschCommon.startSymbol;
pdsch->timeAlloc.numSymbols = initialBwp->pdschCommon.lengthSymbol;
#include "mac_sch_interface.h"
#include "sch.h"
#include "sch_utils.h"
+#include "common_def.h"
SchMacDlAllocFunc schMacDlAllocOpts[] =
{
* RFAILED - failure
*
* ****************************************************************/
-int sendDlAllocToMac(DlAlloc *dlAlloc, Inst inst)
+int sendDlAllocToMac(DlSchedInfo *dlSchedInfo, Inst inst)
{
Pst pst;
SCH_FILL_RSP_PST(pst, inst);
pst.event = EVENT_DL_ALLOC;
- return(*schMacDlAllocOpts[pst.selector])(&pst, dlAlloc);
+ return(*schMacDlAllocOpts[pst.selector])(&pst, dlSchedInfo);
}
+
+/*******************************************************************
+ *
+ * @brief Handles slot indication at SCH
+ *
+ * @details
+ *
+ * Function : schCalcSlotValues
+ *
+ * Functionality:
+ * Handles TTI indication received from PHY
+ *
+ * @params[in]
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+void schCalcSlotValues(SlotIndInfo slotInd, SchSlotValue *schSlotValue)
+{
+ /****************************************************************
+ * PHY_DELTA - the physical layer delta *
+ * SCHED_DELTA - scheduler schedules one slot ahead *
+ * BO_DELTA - this delay is considered for BO response and *
+ * RLC buffer packet to received at MAC *
+ * lower-mac (FAPI filling) will be working on PHY_DELTA *
+ * brdcast scheduler will working on PHY_DELTA + SCHED_DELTA *
+ * RAR scheduler will working on PHY_DELTA + SCHED_DELTA *
+ * msg4 scheduler will working on PHY_DELTA + SCHED_DELTA *
+ * dedicated DL msg scheduler will working *
+ * on PHY_DELTA + SCHED_DELTA + BO_DELTA *
+ ****************************************************************/
+
+ ADD_DELTA_TO_TIME(slotInd,schSlotValue->currentTime,PHY_DELTA);
+ ADD_DELTA_TO_TIME(slotInd,schSlotValue->broadcastTime,PHY_DELTA+SCHED_DELTA);
+ ADD_DELTA_TO_TIME(slotInd,schSlotValue->rarTime,PHY_DELTA+SCHED_DELTA);
+ ADD_DELTA_TO_TIME(slotInd,schSlotValue->msg4Time,PHY_DELTA+SCHED_DELTA);
+ ADD_DELTA_TO_TIME(slotInd,schSlotValue->dlMsgTime,PHY_DELTA+SCHED_DELTA+BO_DELTA);
+}
+
/*******************************************************************
*
* @brief Handles slot indication at SCH
{
int ret = ROK;
uint8_t ssb_rep;
- uint16_t sfn = slotInd->sfn;
- uint16_t slot = slotInd->slot;
uint16_t sfnSlot = 0;
- DlAlloc dlAlloc;
- memset(&dlAlloc,0,sizeof(DlAlloc));
- DlBrdcstAlloc *dlBrdcstAlloc = &dlAlloc.brdcstAlloc;
- RarAlloc *rarAlloc = &dlAlloc.rarAlloc;
+ DlSchedInfo dlSchedInfo;
+ memset(&dlSchedInfo,0,sizeof(DlSchedInfo));
+ DlBrdcstAlloc *dlBrdcstAlloc = &dlSchedInfo.brdcstAlloc;
+ RarAlloc *rarAlloc;
Msg4Alloc *msg4Alloc;
dlBrdcstAlloc->ssbTrans = NO_SSB;
dlBrdcstAlloc->sib1Trans = NO_SIB1;
-
SchCellCb *cell = schCb[schInst].cells[schInst];
-#ifdef LTE_L2_MEAS
- glblTtiCnt++;
-#endif
-
-// schDlResAlloc(cell, slotInd);
+ schCalcSlotValues(*slotInd, &dlSchedInfo.schSlotValue);
ssb_rep = cell->cellCfg.ssbSchCfg.ssbPeriod;
memcpy(&cell->slotInfo, slotInd, sizeof(SlotIndInfo));
dlBrdcstAlloc->ssbIdxSupported = 1;
- if((slot + SCHED_DELTA) >= SCH_NUM_SLOTS)
- {
- sfn = (sfn+1)%SCH_MAX_SFN;
- }
- slot = ((slot + SCHED_DELTA) % SCH_NUM_SLOTS);
- sfnSlot = ((sfn * 10) + slot);
+ sfnSlot = ((dlSchedInfo.schSlotValue.broadcastTime.sfn * 10) +
+ dlSchedInfo.schSlotValue.broadcastTime.slot);
- dlAlloc.slotIndInfo.sfn = sfn;
- dlAlloc.slotIndInfo.slot = slot;
- dlAlloc.cellId = cell->cellId;
+ dlSchedInfo.cellId = cell->cellId;
/* Identify SSB ocassion*/
if (sfnSlot % SCH_MIB_TRANS == 0)
if(dlBrdcstAlloc->ssbTrans || dlBrdcstAlloc->sib1Trans)
{
- dlAlloc.isBroadcastPres = true;
- ret = schBroadcastAlloc(cell, dlBrdcstAlloc,slot);
+ dlSchedInfo.isBroadcastPres = true;
+ ret = schBroadcastAlloc(cell,dlBrdcstAlloc,dlSchedInfo.schSlotValue.broadcastTime.slot);
if(ret != ROK)
{
DU_LOG("\nschBroadcastAlloc failed");
}
/* check for RAR */
- if(cell->dlAlloc[slot]->rarPres == true)
+ if(cell->schDlSlotInfo[dlSchedInfo.schSlotValue.rarTime.slot]->rarInfo != NULLP)
{
- dlAlloc.isRarPres = true;
+ SCH_ALLOC(rarAlloc, sizeof(RarAlloc));
+ if(!rarAlloc)
+ {
+ DU_LOG("\nMAC: Memory Allocation failed for RAR alloc");
+ return RFAILED;
+ }
+
+ dlSchedInfo.rarAlloc = rarAlloc;
+
/* RAR info is copied, this was earlier filled in schProcessRachInd */
- memcpy(&rarAlloc->rarInfo, &cell->dlAlloc[slot]->rarInfo, sizeof(RarInfo));
+ memcpy(&rarAlloc->rarInfo,cell->schDlSlotInfo[dlSchedInfo.schSlotValue.rarTime.slot]->rarInfo, \
+ sizeof(RarInfo));
- /* pdcch and pdsch data is filled */
- schFillRar(rarAlloc,
- cell->dlAlloc[slot]->rarInfo.raRnti,
- cell->cellCfg.phyCellId,
- cell->cellCfg.ssbSchCfg.ssbOffsetPointA);
+ /* pdcch and pdsch data is filled */
+ schFillRar(rarAlloc,
+ cell->schDlSlotInfo[dlSchedInfo.schSlotValue.rarTime.slot]->rarInfo->raRnti,
+ cell->cellCfg.phyCellId,
+ cell->cellCfg.ssbSchCfg.ssbOffsetPointA);
- cell->dlAlloc[slot]->rarPres = false;
+ SCH_FREE(cell->schDlSlotInfo[dlSchedInfo.schSlotValue.rarTime.slot]->rarInfo,sizeof(RarAlloc));
+ cell->schDlSlotInfo[dlSchedInfo.schSlotValue.rarTime.slot]->rarInfo = NULLP;
}
/* check for MSG4 */
- if(cell->dlAlloc[slot]->msg4Info)
+ if(cell->schDlSlotInfo[dlSchedInfo.schSlotValue.msg4Time.slot]->msg4Info != NULLP)
{
SCH_ALLOC(msg4Alloc, sizeof(Msg4Alloc));
if(!msg4Alloc)
return RFAILED;
}
- dlAlloc.msg4Alloc = msg4Alloc;
+ dlSchedInfo.msg4Alloc = msg4Alloc;
/* Msg4 info is copied, this was earlier filled in macSchDlRlcBoInfo */
- memcpy(&msg4Alloc->msg4Info, cell->dlAlloc[slot]->msg4Info, \
+ memcpy(&msg4Alloc->msg4Info, cell->schDlSlotInfo[dlSchedInfo.schSlotValue.msg4Time.slot]->msg4Info, \
sizeof(Msg4Info));
/* pdcch and pdsch data is filled */
- schDlRsrcAllocMsg4(msg4Alloc, cell, slot);
- SCH_FREE(cell->dlAlloc[slot]->msg4Info, sizeof(Msg4Info));
- cell->dlAlloc[slot]->msg4Info = NULL;
+ schDlRsrcAllocMsg4(msg4Alloc, cell, dlSchedInfo.schSlotValue.msg4Time.slot);
+ SCH_FREE(cell->schDlSlotInfo[dlSchedInfo.schSlotValue.msg4Time.slot]->msg4Info, sizeof(Msg4Info));
+ cell->schDlSlotInfo[dlSchedInfo.schSlotValue.msg4Time.slot]->msg4Info = NULL;
}
/* send msg to MAC */
- ret = sendDlAllocToMac(&dlAlloc, schInst);
+ ret = sendDlAllocToMac(&dlSchedInfo, schInst);
if(ret != ROK)
{
DU_LOG("\nSending DL Broadcast allocation from SCH to MAC failed");
/* Defintion of delta value Table 6.1.2.1.1-5 spec 38.214 */
uint8_t puschDeltaTable[MAX_MU_PUSCH] = { 2, 3, 4, 6 };
+uint16_t tbSizeTable[TOTAL_TBSIZE_VALUES] = {
+ 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, \
+ 104, 112, 120, 128, 136, 144, 152, 160, 168, 176, \
+ 184, 192, 208, 224, 240, 256, 272, 288, 304, 320, \
+ 336, 352, 368, 384, 408, 432, 456, 480, 504, 528, \
+ 552, 576, 608, 640, 672, 704, 736, 768, 808, 848, \
+ 888, 928, 984, 1032, 1064, 1128, 1160, 1192, 1224, 1256, \
+ 1288, 1320, 1352, 1416, 1480, 1544, 1608, 1672, 1736, 1800, \
+ 1864, 1928, 2024, 2088, 2152, 2216, 2280, 2408, 2472, 2536, \
+ 2600, 2664, 2728, 2792, 2856, 2976, 3104, 3240, 3368, 3496, \
+ 3624, 3752, 3824 };
+
+uint16_t mcsTable[32][3] = {
+ { 0, 2, 120}, /* mcs index 0 */
+ { 1, 2, 157}, /* mcs index 1 */
+ { 2, 2, 193}, /* mcs index 2 */
+ { 3, 2, 251}, /* mcs index 3 */
+ { 4, 2, 308}, /* mcs index 4 */
+ { 5, 2, 379}, /* mcs index 5 */
+ { 6, 2, 449}, /* mcs index 6 */
+ { 7, 2, 526}, /* mcs index 7 */
+ { 8, 2, 602}, /* mcs index 8 */
+ { 9, 2, 679}, /* mcs index 9 */
+ { 10, 4, 340}, /* mcs index 10 */
+ { 11, 4, 378}, /* mcs index 11 */
+ { 12, 4, 434}, /* mcs index 12 */
+ { 13, 4, 490}, /* mcs index 13 */
+ { 14, 4, 553}, /* mcs index 14 */
+ { 15, 4, 616}, /* mcs index 15 */
+ { 16, 4, 658}, /* mcs index 16 */
+ { 17, 6, 438}, /* mcs index 17 */
+ { 18, 6, 466}, /* mcs index 18 */
+ { 19, 6, 517}, /* mcs index 19 */
+ { 20, 6, 567}, /* mcs index 20 */
+ { 21, 6, 616}, /* mcs index 21 */
+ { 22, 6, 666}, /* mcs index 22 */
+ { 23, 6, 719}, /* mcs index 23 */
+ { 24, 6, 772}, /* mcs index 24 */
+ { 25, 6, 822}, /* mcs index 25 */
+ { 26, 6, 873}, /* mcs index 26 */
+ { 27, 6, 910}, /* mcs index 27 */
+ { 28, 6, 948}, /* mcs index 28 */
+ { 29, 2, 0}, /* mcs index 29 */
+ { 30, 4, 0}, /* mcs index 30 */
+ { 31, 6, 0}}; /* mcs index 31 */
+
/**
* @brief frequency domain allocation function.
*
* @details
*
- * Function: canclulatePRB
+ * Function: calculatePRB
*
* This function does allocation in frequency domain resource. using
* bitwise operator, the bits are set for the PRBs.
}
}
+/**
+ * @brief frequency domain allocation function.
+ *
+ * @details
+ *
+ * Function: schCalcTbSize
+ *
+ * This function finds the TBSize from table Table 5.1.3.2-1 spec 38.214
+ *
+ * @param[in] payLoadSize - size of payload
+ * @return TBsize from the Table
+ **/
+uint16_t schCalcTbSize(uint16_t payLoadSize)
+{
+ uint8_t tbsIndex = 0;
+ payLoadSize = payLoadSize*8;
+
+ while(payLoadSize > tbSizeTable[tbsIndex])
+ {
+ tbsIndex++;
+ }
+
+ /* return the TBsize in bytes */
+ return (tbSizeTable[tbsIndex]/8);
+}
+
+/**
+ * @brief frequency domain allocation function.
+ *
+ * @details
+ *
+ * Function: schCalcNumPrb
+ *
+ * This function calculates the number of PRbs
+ *
+ * @param[in] tbSize
+ * @param[in] mcs
+ * @param[in] number of symbols
+ * @return number PRBs
+ **/
+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 */
+ uint8_t numDmrsSymbols = 12; /* considering whole of one symbols with 12 SCs for DMRS */
+
+ /* 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));
+
+ nreDash = ceil( (12 * numSymbols) - numDmrsSymbols - 0);
+
+ if (nreDash > 156)
+ nre = 156;
+
+ numPrb = ceil((float)nre / nreDash);
+ return numPrb;
+}
+
/**********************************************************************
End of file
**********************************************************************/
#define MAX_RACH_NUM_RB_IDX 16
#define MAX_PRACH_CONFIG_IDX 256
#define MAX_MU_PUSCH 4
-
+#define TOTAL_TBSIZE_VALUES 93
#define SET_BITS(_startBit, _numBits, _byte) \
{ \
_byte = (((~((~0)<<_numBits))<<_startBit)); \
--- /dev/null
+/*******************************************************************************
+################################################################################
+# 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. #
+################################################################################
+*******************************************************************************/
+
+/* 5G ORAN phy delay */
+#define PHY_DELTA 2
#define SIB1_NEW_TX_PERIOD 160
#define SIB1_REPETITION_PERIOD 20
#define CORESET_0_INDEX 0
+#define CORESET_1_INDEX 1
+#define CORESET_2_INDEX 2
+#define CORESET_3_INDEX 3
+#define CORESET_4_INDEX 4
#define SEARCHSPACE_0_INDEX 0
#define SEARCHSPACE_1_INDEX 1
+#define SEARCHSPACE_2_INDEX 2
+#define SEARCHSPACE_3_INDEX 3
+#define SEARCHSPACE_4_INDEX 4
#define SS_MONITORING_SLOT_SL1 0 /* all slots */
#define SS_MONITORING_SYMBOL 0x2000; /* symbol-0, set 14th bit */
#define SIB1_MCS 4
typedef struct pdcchConfigCommon
{
- SearchSpaceCfg raSearchSpace;
+ /* only one search space is configured during SIB1 */
+ SearchSpaceCfg commonSearchSpace;
+ uint8_t raSearchSpaceId;
}PdcchConfigCommon;
typedef struct pdschConfigCommon
/* header include files (.h) */
+#include "stdbool.h"
#include "envopt.h" /* environment options */
#include "envdep.h" /* environment dependent */
#include "envind.h" /* environment independent */
*
*
* @param[in] Pst *pst, the post structure
- * @param[in] DlAlloc *dlAlloc
+ * @param[in] DlSchedInfo *dlSchedInfo
* @return S16
* -# ROK
**/
-int packSchMacDlAlloc(Pst *pst, DlAlloc *dlAlloc)
+int packSchMacDlAlloc(Pst *pst, DlSchedInfo *dlSchedInfo)
{
return ROK;
}
*
*
* @param[in] Pst *pst, the post structure
- * @param[in] *ulSchInfo, UlSchInfo
+ * @param[in] UlSchedInfo *ulSchedInfo
* @return S16
* -# ROK
**/
-int packSchMacUlSchInfo(Pst *pst, UlSchInfo *ulSchInfo)
+int packSchMacUlSchInfo(Pst *pst, UlSchedInfo *ulSchedInfo)
{
return ROK;
}
#define MAX_NUMBER_OF_CRC_IND_BITS 1
#define MAX_NUM_LOGICAL_CHANNELS 11
-
+/* can we have a common numslot numscs between mac sch */
+#define MAX_SLOTS 10
+#define MAX_SFN 1024
#define CCCH_LCID 0
+#define ADD_DELTA_TO_TIME(crntTime, toFill, incr) \
+ if ((crntTime.slot + incr) > (MAX_SLOTS - 1)) \
+ toFill.sfn = (crntTime.sfn + 1); \
+ else \
+ toFill.sfn = crntTime.sfn; \
+ toFill.slot = (crntTime.slot + incr) % MAX_SLOTS; \
+ if (toFill.sfn >= MAX_SFN) \
+ { \
+ toFill.sfn%=MAX_SFN; \
+ } \
/*structures*/
uint16_t pduBitmap;
uint16_t rnti;
uint16_t pduIndex;
- BwpCfg pdschBwpCfg;
uint8_t numCodewords;
CodewordInfo codeword[MAX_CODEWORDS];
uint16_t dataScramblingId;
typedef struct pdcchCfg
{
- BwpCfg pdcchBwpCfg;
/* coreset-0 configuration */
CoresetCfg coreset0Cfg;
/* parameters derived in scheduler */
uint8_t n0;
+ BwpCfg bwp;
PdcchCfg sib1PdcchCfg;
PdschCfg sib1PdschCfg;
}SchSib1Cfg;
typedef struct schPdcchCfgCmn
{
- SchSearchSpaceCfg raSearchSpace;
+ SchSearchSpaceCfg commonSearchSpace;
+ uint8_t raSearchSpaceId;
}SchPdcchCfgCmn;
typedef struct schPdschCfgCmn
typedef struct sib1AllocInfo
{
+ BwpCfg bwp;
PdcchCfg sib1PdcchCfg;
PdschCfg sib1PdschCfg;
} Sib1AllocInfo;
typedef struct rarAlloc
{
RarInfo rarInfo;
+ BwpCfg bwp;
PdcchCfg rarPdcchCfg;
PdschCfg rarPdschCfg;
}RarAlloc;
typedef struct msg4Alloc
{
Msg4Info msg4Info;
+ BwpCfg bwp;
PdcchCfg msg4PdcchCfg;
PdschCfg msg4PdschCfg;
}Msg4Alloc;
-typedef struct dlAlloc
+typedef struct schSlotValue
+{
+ SlotIndInfo currentTime;
+ SlotIndInfo broadcastTime;
+ SlotIndInfo rarTime;
+ SlotIndInfo msg4Time;
+ SlotIndInfo dlMsgTime;
+}SchSlotValue;
+
+typedef struct dlSchedInfo
{
uint16_t cellId; /* Cell Id */
- SlotIndInfo slotIndInfo; /* Slot Info: sfn, slot number */
+ SchSlotValue schSlotValue;
/* Allocation for broadcast messages */
- uint8_t isBroadcastPres;
+ bool isBroadcastPres;
DlBrdcstAlloc brdcstAlloc;
/* Allocation for RAR message */
- uint8_t isRarPres;
- RarAlloc rarAlloc;
+ //uint8_t isRarPres;
+ RarAlloc *rarAlloc;
/* Allocation from MSG4 */
Msg4Alloc *msg4Alloc;
-}DlAlloc;
+}DlSchedInfo;
typedef struct tbInfo
{
}SchPuschInfo;
-typedef struct ulSchInfo
+typedef struct ulSchedInfo
{
uint16_t cellId; /* Cell Id */
uint16_t crnti; /* CRNI */
uint8_t dataType; /* Type of info being scheduled */
PrachSchInfo prachSchInfo; /* Prach scheduling info */
SchPuschInfo schPuschInfo; /* Pusch scheduling info */
-}UlSchInfo;
+}UlSchedInfo;
typedef struct rachIndInfo
{
typedef int (*SchMacDlAllocFunc) ARGS((
Pst *pst, /* Post Structure */
- DlAlloc *dlAlloc /* dl allocation Info */
+ DlSchedInfo *dlSchedInfo /* dl allocation Info */
));
typedef int (*SchMacUlSchInfoFunc) ARGS((
- Pst *pst, /* Post Structure */
- UlSchInfo *ulSchInfo /* UL Sch Info */
+ Pst *pst, /* Post Structure */
+ UlSchedInfo *ulSchedInfo /* UL Alloc Sch Info */
));
/* function declarations */
int packMacSchSlotInd(Pst *pst, SlotIndInfo *slotInd);
-int packSchMacDlAlloc(Pst *pst, DlAlloc *dlAlloc);
-int packSchMacUlSchInfo(Pst *pst, UlSchInfo *ulSchInfo);
+int packSchMacDlAlloc(Pst *pst, DlSchedInfo *dlSchedInfo);
+int packSchMacUlSchInfo(Pst *pst, UlSchedInfo *ulSchedInfo);
EXTERN int packSchCellCfg(Pst *pst, SchCellCfg *schCellCfg);
EXTERN int packSchCellCfgCfm(Pst *pst, SchCellCfgCfm *schCellCfgCfm);
-EXTERN int MacProcDlAlloc(Pst *pst, DlAlloc *dlAlloc);
+EXTERN int MacProcDlAlloc(Pst *pst, DlSchedInfo *dlSchedInfo);
EXTERN int MacProcSchCellCfg(Pst *pst, SchCellCfg *schCellCfg);
EXTERN int MacProcSchCellCfgCfm(Pst *pst, SchCellCfgCfm *schCellCfgCfm);
EXTERN int SchHdlCellCfgReq(Pst *pst, SchCellCfg *schCellCfg);
EXTERN int schActvInit(Ent entity, Inst instId, Region region, Reason reason);
EXTERN S16 SchSendCfgCfm(Pst *pst, RgMngmt *cfm);
-EXTERN int MacProcUlSchInfo(Pst *pst, UlSchInfo *ulSchInfo);
+EXTERN int MacProcUlSchInfo(Pst *pst, UlSchedInfo *ulSchedInfo);
typedef int (*MacSchRachIndFunc)(Pst *pst, RachIndInfo *rachInd);
int packMacSchRachInd(Pst *pst, RachIndInfo *rachInd);
int macSchRachInd(Pst *pst, RachIndInfo *rachInd);
duCfgParam.macCellCfg.initialDlBwp.bwp.numPrb = TOTAL_PRB_BW; /* configured to total BW */
duCfgParam.macCellCfg.initialDlBwp.bwp.scs = SUBCARRIER_SPACING; /* numerology is 0, 15Khz */
duCfgParam.macCellCfg.initialDlBwp.bwp.cyclicPrefix = NORMAL_CYCLIC_PREFIX;
- duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.raSearchSpace.searchSpaceId = SEARCHSPACE_1_INDEX;
- duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.raSearchSpace.coresetId = CORESET_0_INDEX;
- duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.raSearchSpace.monitoringSlot =
+ duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.searchSpaceId = SEARCHSPACE_1_INDEX;
+ duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.coresetId = CORESET_0_INDEX;
+ duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.monitoringSlot =
SS_MONITORING_SLOT_SL1; /* sl1 - all slots */
- duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.raSearchSpace.duration = 0;
- duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.raSearchSpace.monitoringSymbol =
+ duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.duration = 0;
+ duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.monitoringSymbol =
SS_MONITORING_SYMBOL;
- duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.raSearchSpace.
+ duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
candidate.aggLevel1 = 8;
- duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.raSearchSpace.
+ duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
candidate.aggLevel2 = 4;
- duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.raSearchSpace.
+ duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
candidate.aggLevel4 = 2;
- duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.raSearchSpace.
+ duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
candidate.aggLevel8 = 1;
- duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.raSearchSpace.
+ duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
candidate.aggLevel16 = 0;
duCfgParam.macCellCfg.initialDlBwp.pdschCommon.k0 = PDSCH_K0;
duCfgParam.macCellCfg.initialDlBwp.pdschCommon.mappingType =
PDSCH_START_SYMBOL;
duCfgParam.macCellCfg.initialDlBwp.pdschCommon.lengthSymbol =
PDSCH_LENGTH_SYMBOL;
-
- /* fill Intial DL BWP */
+ /* ra-searchSpace ID is set to 1 */
+ duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.raSearchSpaceId = SEARCHSPACE_1_INDEX;
+ /* fill Intial UL BWP */
duCfgParam.macCellCfg.initialUlBwp.bwp.firstPrb = 0;
duCfgParam.macCellCfg.initialUlBwp.bwp.numPrb = TOTAL_PRB_BW; /* configured to total BW */
duCfgParam.macCellCfg.initialUlBwp.bwp.scs = SUBCARRIER_SPACING; /* numerology is 0, 15Khz */
fapi_dl_tti_req_t *dlTtiReq;
dlTtiReq = (fapi_dl_tti_req_t *)msg;
- printf("\nPHY STUB: Received DL TTI Request");
+ printf("\nPHY STUB: DL TTI Request at sfn=%d slot=%d",dlTtiReq->sfn,dlTtiReq->slot);
#if 0
printf("\nPHY_STUB: SFN %d", dlTtiReq->sfn);
printf("\nPHY_STUB: SLOT %d", dlTtiReq->slot);
fapi_tx_data_req_t *txDataReq;
txDataReq = (fapi_tx_data_req_t *)msg;
- DU_LOG("\nPHY STUB: Received TX DATA Request");
+ DU_LOG("\nPHY STUB: TX DATA Request at sfn=%d slot=%d",txDataReq->sfn,txDataReq->slot);
MAC_FREE(txDataReq, msgLen);
#endif