#include "cm_lte.x" /* common tokens */
#include "tfu.x"
+/* events */
+#define EVENT_RACH_IND_TO_MAC 0
+#define EVENT_CRC_IND_TO_MAC 1
+#define EVENT_RX_DATA_IND_TO_MAC 2
+#define EVENT_STOP_IND_TO_MAC 3
+
typedef S16 (*packSlotIndMsg)(Pst *pst, SlotIndInfo *slotInd);
S16 packLcSlotInd (Pst *pst, SlotIndInfo *slotInd);
S16 packLwlcSlotInd (Pst *pst, SlotIndInfo *slotInd);
packMacSchCrcInd
};
+/* Function pointer for sending DL RLC BO Info from MAC to SCH */
+MacSchDlRlcBoInfoFunc macSchDlRlcBoInfoOpts[]=
+{
+ packMacSchDlRlcBoInfo,
+ macSchDlRlcBoInfo,
+ packMacSchDlRlcBoInfo
+};
+
+/*******************************************************************
+ *
+ * @brief Sends DL BO Info to SCH
+ *
+ * @details
+ *
+ * Function : sendDlRlcBoInfoMacToSch
+ *
+ * Functionality:
+ * Sends DL BO Info to SCH
+ *
+ * @params[in]
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ ****************************************************************/
+int sendDlRlcBoInfoMacToSch(DlRlcBOInfo *dlBoInfo)
+{
+ Pst pst;
+
+ fillMacToSchPst(&pst);
+ pst.event = EVENT_DL_RLC_BO_INFO_TO_SCH;
+
+ return(*macSchDlRlcBoInfoOpts[pst.selector])(&pst, dlBoInfo);
+}
+
/*******************************************************************
*
* @brief Sends CRC Indication to SCH
* ****************************************************************/
uint16_t MacHdlDlCcchInd(Pst *pst, DlCcchIndInfo *dlCcchIndInfo)
{
+ DlRlcBOInfo dlBoInfo;
+
DU_LOG("\nMAC : Handling DL CCCH IND");
- MAC_FREE_SHRABL_BUF(pst->region, pst->pool, dlCcchIndInfo->dlCcchMsg, strlen((const char*)dlCcchIndInfo->dlCcchMsg));
+ /* TODO : Fill DL RLC Buffer status info */
+ dlBoInfo.cellId = dlCcchIndInfo->cellId;
+ dlBoInfo.crnti = dlCcchIndInfo->crnti;
+ dlBoInfo.numLc = 0;
+
+ if(dlCcchIndInfo->msgType == RRC_SETUP)
+ {
+ dlBoInfo.numLc++;
+ dlBoInfo.boInfo[dlBoInfo.numLc].lcId = 0; // SRB 0 for msg4
+ dlBoInfo.boInfo[dlBoInfo.numLc].dataVolume = \
+ strlen((const char*)dlCcchIndInfo->dlCcchMsg);
+ }
+
+ /* TODO: Store dlCcchMsg in raCb */
+
+ sendDlRlcBoInfoMacToSch(&dlBoInfo);
+
+
+ MAC_FREE_SHRABL_BUF(pst->region, pst->pool, dlCcchIndInfo->dlCcchMsg, \
+ strlen((const char*)dlCcchIndInfo->dlCcchMsg));
MAC_FREE_SHRABL_BUF(pst->region, pst->pool, dlCcchIndInfo, sizeof(DlCcchIndInfo));
return ROK;
return ret;
}
-
-
-
/**********************************************************************
End of file
**********************************************************************/
MacDlSlot *currDlSlot =
&macCb.macCell->dlSlot[dlAlloc->slotIndInfo.slot % MAX_SLOT_SUPPORTED];
memcpy(&currDlSlot->dlInfo, dlAlloc, sizeof(DlAlloc));
+
+ if(currDlSlot->dlInfo.msg4Alloc)
+ {
+ /* TODO:
+ * Step1 : Fetch msg4 from raCb that was filled in MacHdlDlCcchInd()
+ * Step2 : Mux msg4
+ * Step3 : Store the pdu in raCb
+ */
+ }
}
return ROK;
}
#include "sch_utils.h"
#include "du_log.h"
extern SchCb schCb[SCH_MAX_INST];
-extern int8_t coresetIdxTable[MAX_CORESET_INDEX][4];
-extern int8_t searchSpaceIdxTable[MAX_SEARCH_SPACE_INDEX][4];
void SchFillCfmPst(Pst *reqPst,Pst *cfmPst,RgMngmt *cfm);
/* local defines */
SchCellCfgCfmFunc SchCellCfgCfmOpts[] =
sib1SchCfg->n0 = slotIndex;
/* calculate the PRBs */
- freqDomResourceAlloc( ((offsetPointA-offset)/6), (numRbs/6), FreqDomainResource);
+ calculatePRB( ((offsetPointA-offset)/6), (numRbs/6), FreqDomainResource);
/* fill the PDCCH PDU */
pdcch->pdcchBwpCfg.BWPSize = MAX_NUM_RB; /* whole of BW */
}
+/*******************************************************************
+ *
+ * @brief Processes DL RLC BO info from MAC
+ *
+ * @details
+ *
+ * Function : macSchDlRlcBoInfo
+ *
+ * Functionality:
+ * Processes DL RLC BO info from MAC
+ *
+ * @params[in]
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t macSchDlRlcBoInfo(Pst *pst, DlRlcBOInfo *dlBoInfo)
+{
+ uint16_t lcIdx;
+ Inst inst = pst->dstInst-SCH_INST_START;
+ 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];
+
+ for(lcIdx = 0; lcIdx < dlBoInfo->numLc; lcIdx++)
+ {
+ if(dlBoInfo->boInfo[lcIdx].lcId == CCCH_LCID)
+ {
+ SCH_ALLOC(dlAlloc->msg4Info, sizeof(Msg4Info));
+ if(!dlAlloc->msg4Info)
+ {
+ DU_LOG("\nSCH : Memory allocation failed for msg4Info");
+ dlAlloc = 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;
+ }
+ }
+
+ return ROK;
+}
+
/**********************************************************************
End of file
**********************************************************************/
SPutSBuf(SCH_MEM_REGION, SCH_POOL, \
(Data *)_datPtr, _size);
-
#define SCH_FILL_RSP_PST(_rspPst, _inst)\
{ \
_rspPst.srcProcId = SFndProcId(); \
bool sib1Pres;
bool rarPres;
RarInfo rarInfo;
+ Msg4Info *msg4Info;
}SchDlAlloc;
typedef struct schRaCb
uint8_t schBroadcastAlloc(SchCellCb *cell, DlBrdcstAlloc *dlBrdcstAlloc,uint16_t slot);
uint8_t schProcessSlotInd(SlotIndInfo *slotInd, Inst inst);
uint8_t schUlResAlloc(SchCellCb *cell, Inst schInst);
-
+uint8_t schDlRsrcAllocMsg4(Msg4Alloc *msg4Alloc, SchCellCb *cell, uint16_t slot);
/**********************************************************************
return ret;
}
+
+/*******************************************************************
+ *
+ * @brief Fills pdcch and pdsch info for msg4
+ *
+ * @details
+ *
+ * Function : schDlRsrcAllocMsg4
+ *
+ * Functionality:
+ * Fills pdcch and pdsch info for msg4
+ *
+ * @params[in]
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t schDlRsrcAllocMsg4(Msg4Alloc *msg4Alloc, SchCellCb *cell, uint16_t slot)
+{
+ uint8_t coreset0Idx = 0;
+ uint8_t numRbs = 0;
+ uint8_t firstSymbol = 0;
+ uint8_t numSymbols = 0;
+ uint8_t offset = 0;
+ uint8_t offsetPointA;
+ uint8_t FreqDomainResource[6] = {0};
+ SchBwpDlCfg *initialBwp;
+
+ PdcchCfg *pdcch = &msg4Alloc->msg4PdcchCfg;
+ PdschCfg *pdsch = &msg4Alloc->msg4PdschCfg;
+
+ initialBwp = &cell->cellCfg.schInitialDlBwp;
+ offsetPointA = cell->cellCfg.ssbSchCfg.ssbOffsetPointA;
+ coreset0Idx = initialBwp->pdcchCommon.raSearchSpace.coresetId;
+
+ /* derive the sib1 coreset0 params from table 13-1 spec 38.213 */
+ numRbs = coresetIdxTable[coreset0Idx][1];
+ numSymbols = coresetIdxTable[coreset0Idx][2];
+ offset = coresetIdxTable[coreset0Idx][3];
+
+ /* calculate time domain parameters */
+ uint16_t mask = 0x2000;
+ for(firstSymbol=0; firstSymbol<14;firstSymbol++)
+ {
+ if(initialBwp->pdcchCommon.raSearchSpace.monitoringSymbol & mask)
+ break;
+ else
+ mask = mask>>1;
+ }
+
+ /* calculate the PRBs */
+ calculatePRB( ((offsetPointA-offset)/6), (numRbs/6), FreqDomainResource);
+
+ /* 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.cceRegMappingType = 1; /* coreset0 is always interleaved */
+ pdcch->coreset0Cfg.regBundleSize = 6; /* spec-38.211 sec 7.3.2.2 */
+ pdcch->coreset0Cfg.interleaverSize = 2; /* spec-38.211 sec 7.3.2.2 */
+ pdcch->coreset0Cfg.coreSetType = 0;
+ pdcch->coreset0Cfg.coreSet0Size = numRbs;
+ pdcch->coreset0Cfg.shiftIndex = cell->cellCfg.phyCellId;
+ pdcch->coreset0Cfg.precoderGranularity = 0; /* sameAsRegBundle */
+ pdcch->numDlDci = 1;
+ pdcch->dci.rnti = cell->dlAlloc[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 */
+ pdcch->dci.aggregLevel = 4;
+ pdcch->dci.beamPdcchInfo.numPrgs = 1;
+ pdcch->dci.beamPdcchInfo.prgSize = 1;
+ pdcch->dci.beamPdcchInfo.digBfInterfaces = 0;
+ pdcch->dci.beamPdcchInfo.prg[0].pmIdx = 0;
+ pdcch->dci.beamPdcchInfo.prg[0].beamIdx[0] = 0;
+ pdcch->dci.txPdcchPower.powerValue = 0;
+ pdcch->dci.txPdcchPower.powerControlOffsetSS = 0;
+
+ /* 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->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].rvIndex = 0;
+ /* 38.214: Table 5.1.3.2-1, divided by 8 to get the value in bytes */
+ /* TODO : Calculate tbSize based of DL CCCH msg size */
+ pdsch->codeword[cwCount].tbSize = 2664/8;
+ }
+ pdsch->dataScramblingId = cell->cellCfg.phyCellId;
+ pdsch->numLayers = 1;
+ pdsch->transmissionScheme = 0;
+ pdsch->refPoint = 0;
+ pdsch->dmrs.dlDmrsSymbPos = 2;
+ pdsch->dmrs.dmrsConfigType = 0; /* type-1 */
+ pdsch->dmrs.dlDmrsScramblingId = cell->cellCfg.phyCellId;
+ pdsch->dmrs.scid = 0;
+ pdsch->dmrs.numDmrsCdmGrpsNoData = 1;
+ pdsch->dmrs.dmrsPorts = 0;
+ pdsch->freqAlloc.resourceAlloc = 1; /* RAT type-1 RIV format */
+ /* the RB numbering starts from coreset0, and PDSCH is always above SSB */
+ pdsch->freqAlloc.rbStart = offset + SCH_SSB_PRB_DURATION;
+ /* 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 */
+ /* TODO : Calculate rbSize based on tbSize calculated */
+ pdsch->freqAlloc.rbSize = 34;
+ pdsch->freqAlloc.vrbPrbMapping = 0; /* non-interleaved */
+ pdsch->timeAlloc.startSymbolIndex = 2; /* spec-38.214, Table 5.1.2.1-1 */
+ pdsch->timeAlloc.numSymbols = 12;
+ pdsch->beamPdschInfo.numPrgs = 1;
+ pdsch->beamPdschInfo.prgSize = 1;
+ pdsch->beamPdschInfo.digBfInterfaces = 0;
+ pdsch->beamPdschInfo.prg[0].pmIdx = 0;
+ pdsch->beamPdschInfo.prg[0].beamIdx[0] = 0;
+ pdsch->txPdschPower.powerControlOffset = 0;
+ pdsch->txPdschPower.powerControlOffsetSS = 0;
+
+ pdcch->dci.pdschCfg = pdsch;
+ return ROK;
+}
+
/**********************************************************************
End of file
**********************************************************************/
#include "sch_utils.h"
extern SchCb schCb[SCH_MAX_INST];
-extern int8_t coresetIdxTable[MAX_CORESET_INDEX][4];
-extern int8_t searchSpaceIdxTable[MAX_SEARCH_SPACE_INDEX][4];
extern uint8_t puschDeltaTable[MAX_MU_PUSCH];
/**
}
/* calculate the PRBs */
- freqDomResourceAlloc( ((offsetPointA-offset)/6), (numRbs/6), FreqDomainResource);
+ calculatePRB( ((offsetPointA-offset)/6), (numRbs/6), FreqDomainResource);
/* fill the PDCCH PDU */
pdcch->pdcchBwpCfg.BWPSize = initialBwp->bwp.numPrb;
#include "du_app_mac_inf.h"
#include "mac_sch_interface.h"
#include "sch.h"
+#include "sch_utils.h"
SchMacDlAllocFunc schMacDlAllocOpts[] =
{
return(*schMacDlAllocOpts[pst.selector])(&pst, dlAlloc);
}
+
/*******************************************************************
*
* @brief Handles slot indication at SCH
memset(&dlAlloc,0,sizeof(DlAlloc));
DlBrdcstAlloc *dlBrdcstAlloc = &dlAlloc.brdcstAlloc;
RarAlloc *rarAlloc = &dlAlloc.rarAlloc;
+ Msg4Alloc *msg4Alloc;
dlBrdcstAlloc->ssbTrans = NO_SSB;
dlBrdcstAlloc->sib1Trans = NO_SIB1;
cell->dlAlloc[slot]->rarPres = false;
}
+ /* check for MSG4 */
+ if(cell->dlAlloc[slot]->msg4Info)
+ {
+ SCH_ALLOC(msg4Alloc, sizeof(Msg4Alloc));
+ if(!msg4Alloc)
+ {
+ DU_LOG("\nMAC: Memory Allocation failed for msg4 alloc");
+ return RFAILED;
+ }
+
+ dlAlloc.msg4Alloc = msg4Alloc;
+
+ /* Msg4 info is copied, this was earlier filled in macSchDlRlcBoInfo */
+ memcpy(&msg4Alloc->msg4Info, cell->dlAlloc[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;
+ }
+
+
/* send msg to MAC */
ret = sendDlAllocToMac(&dlAlloc, schInst);
if(ret != ROK)
*
* @details
*
- * Function : freqDomResourceAlloc
+ * Function: canclulatePRB
*
* This function does allocation in frequency domain resource. using
* bitwise operator, the bits are set for the PRBs.
* @param[in] freqDomain - 6 bytes of info, each bit represents a group of 6 PRB.
* @return void
**/
-void freqDomResourceAlloc(uint16_t startPrb, uint16_t prbSize, uint8_t *freqDomain)
+void calculatePRB(uint16_t startPrb, uint16_t prbSize, uint8_t *freqDomain)
{
uint8_t remBits = prbSize; /* each bit represents 6 PRBs */
uint8_t firstByte = 1;
}
/* functions declarations */
-void freqDomResourceAlloc(uint16_t startPrb, uint16_t prbSize, uint8_t *freqDomain);
+void calculatePRB(uint16_t startPrb, uint16_t prbSize, uint8_t *freqDomain);
+
+extern int8_t coresetIdxTable[MAX_CORESET_INDEX][4];
+extern int8_t searchSpaceIdxTable[MAX_SEARCH_SPACE_INDEX][4];
/**********************************************************************
End of file
return ROK;
}
+/*******************************************************************
+ *
+ * @brief Pack and Send DL RLC BO Info from MAC to SCH
+ *
+ * @details
+ *
+ * Function : packMacSchDlRlcBoInfo
+ *
+ * Functionality:
+ * Pack and Send L RLC BO Info from MAC to SCH
+ *
+ * @params[in]
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t packMacSchDlRlcBoInfo(Pst *pst, DlRlcBOInfo *dlBoInfo)
+{
+ if((pst->selector == MAC_SELECTOR_LC) || (pst->selector == MAC_SELECTOR_LWLC))
+ {
+ /* TODO */
+ }
+ else
+ {
+ return RFAILED;
+ }
+ return ROK;
+}
+
/**
* @brief function to pack DL Broadcast allocation message
* from MAC to SCH
/* events */
#define EVENT_SCH_CELL_CFG 1
#define EVENT_SCH_CELL_CFG_CFM 2
-#define EVENT_DL_ALLOC 3
+#define EVENT_DL_ALLOC 3
#define EVENT_UL_SCH_INFO 4
+#define EVENT_RACH_IND_TO_SCH 5
+#define EVENT_CRC_IND_TO_SCH 6
+#define EVENT_DL_RLC_BO_INFO_TO_SCH 7
/* selector */
#define MAC_SCH_LC_SELECTOR 0
#define SCH_DATATYPE_PRACH 16
#define MAX_NUMBER_OF_CRC_IND_BITS 1
+#define MAX_NUM_LOGICAL_CHANNELS 11
+
+#define CCCH_LCID 0
/*structures*/
PdschCfg rarPdschCfg;
}RarAlloc;
+typedef struct msg4Info
+{
+ uint8_t ndi;
+ uint8_t harqProcNum;
+ uint8_t dlAssignIdx;
+ uint8_t pucchTpc;
+ uint8_t pucchResInd;
+ uint8_t harqFeedbackInd;
+ uint8_t dciFormatId;
+ uint16_t crnti;
+ uint8_t *msg4Pdu;
+ uint8_t msg4PduLen;
+}Msg4Info;
+
+typedef struct msg4Alloc
+{
+ Msg4Info msg4Info;
+ PdcchCfg msg4PdcchCfg;
+ PdschCfg msg4PdschCfg;
+}Msg4Alloc;
+
typedef struct dlAlloc
{
uint16_t cellId; /* Cell Id */
/* Allocation for RAR message */
uint8_t isRarPres;
RarAlloc rarAlloc;
+
+ /* Allocation from MSG4 */
+ Msg4Alloc *msg4Alloc;
}DlAlloc;
typedef struct tbInfo
uint8_t crcInd[MAX_NUMBER_OF_CRC_IND_BITS];
}CrcIndInfo;
+typedef struct boInfo
+{
+ uint8_t lcId;
+ uint32_t dataVolume;
+}BOInfo;
+
+typedef struct dlRlcBOInfo
+{
+ uint16_t cellId;
+ uint16_t crnti;
+ uint16_t numLc;
+ BOInfo boInfo[MAX_NUM_LOGICAL_CHANNELS];
+}DlRlcBOInfo;
+
/* function pointers */
typedef int (*MacSchCrcIndFunc)(Pst *pst, CrcIndInfo *crcInd);
int packMacSchCrcInd(Pst *pst, CrcIndInfo *crcInd);
int macSchCrcInd(Pst *pst, CrcIndInfo *crcInd);
+typedef uint8_t (*MacSchDlRlcBoInfoFunc)(Pst *pst, DlRlcBOInfo *dlBoInfo);
+uint8_t packMacSchDlRlcBoInfo(Pst *pst, DlRlcBOInfo *dlBoInfo);
+uint8_t macSchDlRlcBoInfo(Pst *pst, DlRlcBOInfo *dlBoInfo);
+
/**********************************************************************
End of file
#define EVTTFUNONRTIND 24 /*!< Non-RT indication.*/
#endif
#define EVTTFUERRIND 25 /*!< TFU Error Indication */
-#define EVENT_RACH_IND_TO_MAC 26
-#define EVENT_RACH_IND_TO_SCH 27
-#define EVENT_CRC_IND_TO_MAC 28
-#define EVENT_CRC_IND_TO_SCH 29
-#define EVENT_RX_DATA_IND_TO_MAC 30
-#define EVENT_STOP_IND_TO_MAC 31
/** @} */
#define MAX_PREAM_PER_SLOT 1 /* Max number of preamble per slot */