X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2F5gnrsch%2Fsch_common.c;h=c9bc50fd0a35ff0727e9c04e88b4a01af44f591e;hb=45d134510deb6902b870b4a0fb574b6075fba601;hp=3e14282e7f389472546a23669e576a83c7fb40af;hpb=746426865b5742eb3d79ae2457081c47c1c2c4c1;p=o-du%2Fl2.git diff --git a/src/5gnrsch/sch_common.c b/src/5gnrsch/sch_common.c index 3e14282e7..c9bc50fd0 100644 --- a/src/5gnrsch/sch_common.c +++ b/src/5gnrsch/sch_common.c @@ -31,29 +31,10 @@ File: sch_common.c /** @file sch_common.c @brief This module performs common scheduling */ -#include "stdbool.h" -#include "envopt.h" /* environment options */ -#include "envdep.h" /* environment dependent */ -#include "envind.h" /* environment independent */ -#include "gen.h" /* general layer */ -#include "ssi.h" /* system service interface */ -#include "cm_tkns.h" /* Common Token Defines */ -#include "cm_llist.h" /* Common Link List Defines */ -#include "cm_hash.h" /* Common Hash List Defines */ -#include "cm_mblk.h" /* common memory link list library */ -#include "cm_lte.h" /* Common LTE Defines */ +#include "common_def.h" #include "tfu.h" #include "lrg.h" -#include "gen.x" /* general layer typedefs */ -#include "ssi.x" /* system services typedefs */ -#include "cm5.x" /* system services */ -#include "cm_tkns.x" /* Common Token Definitions */ -#include "cm_llist.x" /* Common Link List Definitions */ -#include "cm_lib.x" /* Common Library Definitions */ -#include "cm_hash.x" /* Common Hash List Definitions */ -#include "cm_mblk.x" /* common memory link list library */ -#include "cm_lte.x" /* Common LTE Defines */ #include "tfu.x" #include "lrg.x" #include "du_log.h" @@ -61,17 +42,17 @@ File: sch_common.c #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]; extern uint16_t numRbForPrachTable[MAX_RACH_NUM_RB_IDX][5]; +extern uint8_t pucchResourceSet[MAX_PUCCH_RES_SET_IDX][4]; SchMacUlSchInfoFunc schMacUlSchInfoOpts[] = { - packSchMacUlSchInfo, - MacProcUlSchInfo, - packSchMacUlSchInfo + packSchMacUlSchInfo, + MacProcUlSchInfo, + packSchMacUlSchInfo }; /** @@ -88,53 +69,53 @@ SchMacUlSchInfoFunc schMacUlSchInfoOpts[] = * @return void **/ uint8_t schBroadcastAlloc(SchCellCb *cell, DlBrdcstAlloc *dlBrdcstAlloc, - uint16_t slot) + uint16_t slot) { - /* schedule SSB */ - uint8_t ssbStartPrb, ssbStartSymb, idx; - SchDlSlotInfo *schDlSlotInfo; - SsbInfo ssbInfo; - - schDlSlotInfo = cell->schDlSlotInfo[slot]; - if(dlBrdcstAlloc->ssbTrans) - { - ssbStartPrb = cell->cellCfg.ssbSchCfg.ssbOffsetPointA; + /* schedule SSB */ + uint8_t ssbStartPrb, ssbStartSymb, idx; + SchDlSlotInfo *schDlSlotInfo; + SsbInfo ssbInfo; + + schDlSlotInfo = cell->schDlSlotInfo[slot]; + if(dlBrdcstAlloc->ssbTrans) + { + ssbStartPrb = cell->cellCfg.ssbSchCfg.ssbOffsetPointA; ssbStartSymb = cell->ssbStartSymbArr[dlBrdcstAlloc->ssbIdxSupported-1]; /*since we are - supporting only 1 ssb beam */ - - /* Assign interface structure */ - for(idx=0; idxssbIdxSupported; idx++) - { - ssbInfo.ssbIdx = idx; - ssbInfo.fdAlloc.startPrb = ssbStartPrb; - ssbInfo.fdAlloc.numPrb = SCH_SSB_NUM_PRB; - ssbInfo.tdAlloc.startSymb = ssbStartSymb; - ssbInfo.tdAlloc.numSymb = SCH_SSB_NUM_SYMB; - dlBrdcstAlloc->ssbInfo[idx] = ssbInfo; - schDlSlotInfo->ssbInfo[idx] = ssbInfo; - } - - schDlSlotInfo->ssbPres = true; - schDlSlotInfo->ssbIdxSupported = dlBrdcstAlloc->ssbIdxSupported; - for(idx=ssbStartSymb; idxassignedPrb[idx] = ssbStartPrb + SCH_SSB_NUM_PRB + 1; /* +1 for kSsb */ - } - } - - /* SIB1 allocation */ - if(dlBrdcstAlloc->sib1Trans) - { - schDlSlotInfo->sib1Pres = true; - for(idx=0; idxassignedPrb[idx] = ssbStartPrb + SCH_SSB_NUM_PRB + 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)); - } - return ROK; + supporting only 1 ssb beam */ + + /* Assign interface structure */ + for(idx=0; idxssbIdxSupported; idx++) + { + ssbInfo.ssbIdx = idx; + ssbInfo.fdAlloc.startPrb = ssbStartPrb; + ssbInfo.fdAlloc.numPrb = SCH_SSB_NUM_PRB; + ssbInfo.tdAlloc.startSymb = ssbStartSymb; + ssbInfo.tdAlloc.numSymb = SCH_SSB_NUM_SYMB; + dlBrdcstAlloc->ssbInfo[idx] = ssbInfo; + schDlSlotInfo->ssbInfo[idx] = ssbInfo; + } + + schDlSlotInfo->ssbPres = true; + schDlSlotInfo->ssbIdxSupported = dlBrdcstAlloc->ssbIdxSupported; + for(idx=ssbStartSymb; idxassignedPrb[idx] = ssbStartPrb + SCH_SSB_NUM_PRB + 1; /* +1 for kSsb */ + } + } + + /* SIB1 allocation */ + if(dlBrdcstAlloc->sib1Trans) + { + schDlSlotInfo->sib1Pres = true; + for(idx=0; idxassignedPrb[idx] = ssbStartPrb + SCH_SSB_NUM_PRB + 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)); + } + return ROK; } /******************************************************************* @@ -155,13 +136,13 @@ uint8_t schBroadcastAlloc(SchCellCb *cell, DlBrdcstAlloc *dlBrdcstAlloc, * ****************************************************************/ int sendUlSchInfoToMac(UlSchedInfo *ulSchedInfo, Inst inst) { - Pst pst; + Pst pst; memset(&pst, 0, sizeof(Pst)); - SCH_FILL_RSP_PST(pst, inst); - pst.event = EVENT_UL_SCH_INFO; + FILL_PST_SCH_TO_MAC(pst, inst); + pst.event = EVENT_UL_SCH_INFO; - return(*schMacUlSchInfoOpts[pst.selector])(&pst, ulSchedInfo); + return(*schMacUlSchInfoOpts[pst.selector])(&pst, ulSchedInfo); } /** * @brief resource allocation for PRACH @@ -180,70 +161,95 @@ void schPrachResAlloc(SchCellCb *cell, UlSchedInfo *ulSchedInfo, SlotIndInfo pra { uint8_t puschScs; uint8_t numPrachRb = 0; - uint8_t numRa = 0; - uint8_t freqStart = 0; - uint8_t prachCfgIdx = 0; - uint8_t prachFormat = 0; - uint8_t x = 0; - uint8_t y = 0; - uint16_t prachSubframe = 0; - uint8_t prachStartSymbol = 0; - uint8_t prachOcas = 0; - uint8_t dataType = 0; - uint8_t idx = 0; - SchUlSlotInfo *schUlSlotInfo = NULLP; + uint8_t numRa = 0; + uint8_t freqStart = 0; + uint8_t prachCfgIdx = 0; + uint8_t prachFormat = 0; + uint8_t x = 0; + uint8_t y = 0; + uint16_t prachSubframe = 0; + uint8_t prachStartSymbol = 0; + uint8_t prachOcas = 0; + uint8_t dataType = 0; + uint8_t idx = 0; + SchUlSlotInfo *schUlSlotInfo = NULLP; puschScs = cell->cellCfg.schInitialUlBwp.bwp.scs; - schUlSlotInfo = cell->schUlSlotInfo[prachOccasionTimingInfo.slot]; - prachCfgIdx = cell->cellCfg.schRachCfg.prachCfgIdx; - - /* derive the prachCfgIdx table paramters */ - x = prachCfgIdxTable[prachCfgIdx][1]; - y = prachCfgIdxTable[prachCfgIdx][2]; - prachSubframe = prachCfgIdxTable[prachCfgIdx][3]; - - if((prachOccasionTimingInfo.sfn%x) == y) - { - /* check for subFrame number */ - if ((1 << prachOccasionTimingInfo.slot) & prachSubframe) - { - /* prach ocassion present in this subframe */ - - prachFormat = prachCfgIdxTable[prachCfgIdx][0]; - prachStartSymbol = prachCfgIdxTable[prachCfgIdx][4]; - prachOcas = prachCfgIdxTable[prachCfgIdx][6]; - - /* freq domain resource determination for RACH*/ - freqStart = cell->cellCfg.schRachCfg.msg1FreqStart; - /* numRa determined as 𝑛 belonging {0,1,.., M − 1}, - * where M is given by msg1Fdm */ - numRa = (cell->cellCfg.schRachCfg.msg1Fdm - 1); - for(idx=0; idxcellCfg.schRachCfg.rootSeqLen) - { - if(numRbForPrachTable[idx][1] == cell->cellCfg.schRachCfg.prachSubcSpacing) - { - if(numRbForPrachTable[idx][2] == puschScs) - { - break; - } - } - } - } - numPrachRb = numRbForPrachTable[idx][3]; - dataType |= SCH_DATATYPE_PRACH; - /* Considering first slot in the frame for PRACH */ - idx = 0; - schUlSlotInfo->assignedPrb[idx] = freqStart+numPrachRb; - } - ulSchedInfo->dataType = dataType; - /* prach info */ - ulSchedInfo->prachSchInfo.numPrachOcas = prachOcas; - ulSchedInfo->prachSchInfo.prachFormat = prachFormat; - ulSchedInfo->prachSchInfo.numRa = numRa; - ulSchedInfo->prachSchInfo.prachStartSymb = prachStartSymbol; - } + schUlSlotInfo = cell->schUlSlotInfo[prachOccasionTimingInfo.slot]; + prachCfgIdx = cell->cellCfg.schRachCfg.prachCfgIdx; + + /* derive the prachCfgIdx table paramters */ + x = prachCfgIdxTable[prachCfgIdx][1]; + y = prachCfgIdxTable[prachCfgIdx][2]; + prachSubframe = prachCfgIdxTable[prachCfgIdx][3]; + + if((prachOccasionTimingInfo.sfn%x) == y) + { + /* check for subFrame number */ + if ((1 << prachOccasionTimingInfo.slot) & prachSubframe) + { + /* prach ocassion present in this subframe */ + + prachFormat = prachCfgIdxTable[prachCfgIdx][0]; + prachStartSymbol = prachCfgIdxTable[prachCfgIdx][4]; + prachOcas = prachCfgIdxTable[prachCfgIdx][6]; + + /* freq domain resource determination for RACH*/ + freqStart = cell->cellCfg.schRachCfg.msg1FreqStart; + /* numRa determined as 𝑛 belonging {0,1,.., M − 1}, + * where M is given by msg1Fdm */ + numRa = (cell->cellCfg.schRachCfg.msg1Fdm - 1); + for(idx=0; idxcellCfg.schRachCfg.rootSeqLen) + { + if(numRbForPrachTable[idx][1] == cell->cellCfg.schRachCfg.prachSubcSpacing) + { + if(numRbForPrachTable[idx][2] == puschScs) + { + break; + } + } + } + } + numPrachRb = numRbForPrachTable[idx][3]; + dataType |= SCH_DATATYPE_PRACH; + /* Considering first slot in the frame for PRACH */ + idx = 0; + schUlSlotInfo->assignedPrb[idx] = freqStart+numPrachRb; + } + ulSchedInfo->dataType = dataType; + /* prach info */ + ulSchedInfo->prachSchInfo.numPrachOcas = prachOcas; + ulSchedInfo->prachSchInfo.prachFormat = prachFormat; + ulSchedInfo->prachSchInfo.numRa = numRa; + ulSchedInfo->prachSchInfo.prachStartSymb = prachStartSymbol; + } +} + +uint16_t fillPucchResourceInfo(SchPucchInfo *schPucchInfo, Inst inst) +{ + /* derive pucchResourceSet from schCellCfg */ + SchCellCb *cell = schCb[inst].cells[inst]; + SchPucchCfgCmn *pucchCfg = &cell->cellCfg.schInitialUlBwp.pucchCommon; + uint8_t pucchIdx = pucchCfg->pucchResourceCommon; + SchBwpParams *ulBwp = &cell->cellCfg.schInitialUlBwp.bwp; + + schPucchInfo->fdAlloc.startPrb = ulBwp->freqAlloc.startPrb + pucchResourceSet[pucchIdx][3]; + schPucchInfo->fdAlloc.numPrb = PUCCH_NUM_PRB_FORMAT_0; + schPucchInfo->tdAlloc.startSymb = pucchResourceSet[pucchIdx][1]; + schPucchInfo->tdAlloc.numSymb = pucchResourceSet[pucchIdx][2]; + schPucchInfo->pucchFormat = pucchResourceSet[pucchIdx][0]; + + /* set HARQ flag to true */ + schPucchInfo->harqFlag = true; + schPucchInfo->numHarqBits = 1; /* 1 bit for HARQ */ + + /* set SR and UCI flag to false */ + schPucchInfo->srFlag = false; + schPucchInfo->uciFlag = false; + + return ROK; } /** @@ -261,42 +267,51 @@ void schPrachResAlloc(SchCellCb *cell, UlSchedInfo *ulSchedInfo, SlotIndInfo pra uint8_t schUlResAlloc(SchCellCb *cell, Inst schInst) { int ret = ROK; - UlSchedInfo ulSchedInfo; - SchUlSlotInfo *schUlSlotInfo; + UlSchedInfo ulSchedInfo; + SchUlSlotInfo *schUlSlotInfo = NULLP; SlotIndInfo ulTimingInfo; + memset(&ulSchedInfo, 0, sizeof(UlSchedInfo)); /* add PHY delta */ ADD_DELTA_TO_TIME(cell->slotInfo,ulTimingInfo,PHY_DELTA+SCHED_DELTA); - ulSchedInfo.cellId = cell->cellId; - ulSchedInfo.slotIndInfo.sfn = ulTimingInfo.sfn; + ulSchedInfo.cellId = cell->cellId; + ulSchedInfo.slotIndInfo.cellId = ulSchedInfo.cellId; + ulSchedInfo.slotIndInfo.sfn = ulTimingInfo.sfn; ulSchedInfo.slotIndInfo.slot = ulTimingInfo.slot; /* Schedule resources for PRACH */ - schPrachResAlloc(cell, &ulSchedInfo, ulTimingInfo); + schPrachResAlloc(cell, &ulSchedInfo, ulTimingInfo); - schUlSlotInfo = cell->schUlSlotInfo[ulTimingInfo.slot]; - - if(schUlSlotInfo->schPuschInfo) - { + schUlSlotInfo = cell->schUlSlotInfo[ulTimingInfo.slot]; + if(schUlSlotInfo->schPuschInfo) + { ulSchedInfo.crnti = cell->raCb[0].tcrnti; - ulSchedInfo.dataType |= SCH_DATATYPE_PUSCH; - memcpy(&ulSchedInfo.schPuschInfo, schUlSlotInfo->schPuschInfo, - sizeof(SchPuschInfo)); - SCH_FREE(schUlSlotInfo->schPuschInfo, sizeof(SchPuschInfo)); - schUlSlotInfo->schPuschInfo = NULL; - } - - //send msg to MAC + ulSchedInfo.dataType |= SCH_DATATYPE_PUSCH; + memcpy(&ulSchedInfo.schPuschInfo, schUlSlotInfo->schPuschInfo, + sizeof(SchPuschInfo)); + SCH_FREE(schUlSlotInfo->schPuschInfo, sizeof(SchPuschInfo)); + schUlSlotInfo->schPuschInfo = NULL; + } + + if(schUlSlotInfo->pucchPres) + { + ulSchedInfo.dataType |= SCH_DATATYPE_UCI; + fillPucchResourceInfo(&schUlSlotInfo->schPucchInfo, schInst); + memcpy(&ulSchedInfo.schPucchInfo, &schUlSlotInfo->schPucchInfo, + sizeof(SchPucchInfo)); + memset(&schUlSlotInfo->schPucchInfo, 0, sizeof(SchPucchInfo)); + } + + //send msg to MAC ret = sendUlSchInfoToMac(&ulSchedInfo, schInst); if(ret != ROK) { DU_LOG("\nSending UL Sch info from SCH to MAC failed"); } - - memset(cell->schUlSlotInfo[ulTimingInfo.slot], 0, sizeof(SchUlSlotInfo)); + memset(cell->schUlSlotInfo[ulTimingInfo.slot], 0, sizeof(SchUlSlotInfo)); - return ret; + return ret; } /******************************************************************* @@ -325,7 +340,7 @@ uint8_t schDlRsrcAllocMsg4(Msg4Alloc *msg4Alloc, SchCellCb *cell, uint16_t slot) uint8_t offsetPointA; uint8_t FreqDomainResource[6] = {0}; uint16_t tbSize = 0; - uint8_t numPdschSymbols = 12; /* considering pdsch region from 2 to 13 */ + uint8_t numPdschSymbols = 12; /* considering pdsch region from 2 to 13 */ uint8_t mcs = 4; /* MCS fixed to 4 */ SchBwpDlCfg *initialBwp; @@ -347,9 +362,9 @@ uint8_t schDlRsrcAllocMsg4(Msg4Alloc *msg4Alloc, SchCellCb *cell, uint16_t slot) for(firstSymbol=0; firstSymbol<14;firstSymbol++) { if(initialBwp->pdcchCommon.commonSearchSpace.monitoringSymbol & mask) - break; + break; else - mask = mask>>1; + mask = mask>>1; } /* calculate the PRBs */ @@ -401,7 +416,7 @@ uint8_t schDlRsrcAllocMsg4(Msg4Alloc *msg4Alloc, SchCellCb *cell, uint16_t slot) 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 */ - tbSize = schCalcTbSize(2664/8); /* send this value to the func in bytes when considering msg4 size */ + tbSize = schCalcTbSize(2664/8); /* send this value to the func in bytes when considering msg4 size */ pdsch->codeword[cwCount].tbSize = tbSize; } pdsch->dataScramblingId = cell->cellCfg.phyCellId; @@ -414,6 +429,9 @@ uint8_t schDlRsrcAllocMsg4(Msg4Alloc *msg4Alloc, SchCellCb *cell, uint16_t slot) pdsch->dmrs.scid = 0; pdsch->dmrs.numDmrsCdmGrpsNoData = 1; pdsch->dmrs.dmrsPorts = 0; + pdsch->dmrs.mappingType = DMRS_MAP_TYPE_A; /* Setting to Type-A */ + pdsch->dmrs.nrOfDmrsSymbols = NUM_DMRS_SYMBOLS; + pdsch->dmrs.dmrsAddPos = DMRS_ADDITIONAL_POS; pdsch->pdschFreqAlloc.resourceAllocType = 1; /* RAT type-1 RIV format */ /* the RB numbering starts from coreset0, and PDSCH is always above SSB */ pdsch->pdschFreqAlloc.freqAlloc.startPrb = offset + SCH_SSB_NUM_PRB; @@ -428,11 +446,26 @@ uint8_t schDlRsrcAllocMsg4(Msg4Alloc *msg4Alloc, SchCellCb *cell, uint16_t slot) pdsch->beamPdschInfo.prg[0].beamIdx[0] = 0; pdsch->txPdschPower.powerControlOffset = 0; pdsch->txPdschPower.powerControlOffsetSS = 0; - + pdcch->dci.pdschCfg = pdsch; return ROK; } +uint16_t schAllocPucchResource(SchCellCb *cell,uint16_t crnti, uint16_t slot) +{ + uint8_t k1 = 1; /* dl-DataToUL-ACK RRC parameter will received from DU-APP msg4-pucch config */ + uint16_t pucchSlot = (slot + k1) % SCH_NUM_SLOTS; + SchUlSlotInfo *schUlSlotInfo = NULLP; + + schUlSlotInfo = cell->schUlSlotInfo[pucchSlot]; + memset(&schUlSlotInfo->schPucchInfo, 0, sizeof(SchPucchInfo)); + + schUlSlotInfo->pucchPres = true; + schUlSlotInfo->schPucchInfo.rnti = crnti; + + return ROK; +} + /********************************************************************** End of file **********************************************************************/