X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2F5gnrsch%2Fsch_common.c;h=6b01730c041e94cbd31b137b009d2ffa14c9f9ee;hb=b864875ccd95278bcfcc40187def1ed7a6fb8aa4;hp=c8a6cca950d2be3963ab506c2bd16f70f820b86c;hpb=ca0353e5cb5699aecb6840efe9572934a1150e2b;p=o-du%2Fl2.git diff --git a/src/5gnrsch/sch_common.c b/src/5gnrsch/sch_common.c index c8a6cca95..6b01730c0 100644 --- a/src/5gnrsch/sch_common.c +++ b/src/5gnrsch/sch_common.c @@ -43,13 +43,6 @@ File: sch_common.c #include "sch.h" #include "sch_utils.h" -SchMacUlSchInfoFunc schMacUlSchInfoOpts[] = -{ - packSchMacUlSchInfo, - MacProcUlSchInfo, - packSchMacUlSchInfo -}; - /** * @brief common resource allocation for SSB * @@ -84,7 +77,7 @@ uint8_t schBroadcastSsbAlloc(SchCellCb *cell, SlotTimingInfo slotTime, DlBrdcstA } schDlSlotInfo = cell->schDlSlotInfo[slotTime.slot]; - ssbStartPrb = cell->cellCfg.ssbSchCfg.ssbOffsetPointA; //+Kssb + ssbStartPrb = cell->cellCfg.ssbSubcOffset; //+Kssb ssbStartSymb = cell->ssbStartSymbArr[dlBrdcstAlloc->ssbIdxSupported-1]; /*since we are supporting only 1 ssb beam */ /* Assign interface structure */ @@ -128,8 +121,8 @@ uint8_t schBroadcastSib1Alloc(SchCellCb *cell, SlotTimingInfo slotTime, DlBrdcst { uint8_t dmrsStartSymbol, startSymbol, numSymbol ; DmrsInfo dmrs; - FreqDomainAlloc freqAlloc; - TimeDomainAlloc timeAlloc; + PdschFreqAlloc freqAlloc; + PdschTimeAlloc timeAlloc; SchDlSlotInfo *schDlSlotInfo = NULLP; if(cell == NULL) @@ -143,10 +136,11 @@ uint8_t schBroadcastSib1Alloc(SchCellCb *cell, SlotTimingInfo slotTime, DlBrdcst DU_LOG("\nERROR --> SCH: schBroadcastSsbAlloc() : dlBrdcstAlloc is NULL"); return RFAILED; } - - dmrs = cell->cellCfg.sib1SchCfg.sib1PdschCfg.dmrs; - freqAlloc = cell->cellCfg.sib1SchCfg.sib1PdschCfg.pdschFreqAlloc.freqAlloc; - timeAlloc = cell->cellCfg.sib1SchCfg.sib1PdschCfg.pdschTimeAlloc.timeAlloc; + + dlBrdcstAlloc->crnti = SI_RNTI; + dmrs = cell->sib1SchCfg.sib1PdcchCfg.dci.pdschCfg->dmrs; + freqAlloc = cell->sib1SchCfg.sib1PdcchCfg.dci.pdschCfg->pdschFreqAlloc; + timeAlloc = cell->sib1SchCfg.sib1PdcchCfg.dci.pdschCfg->pdschTimeAlloc; schDlSlotInfo = cell->schDlSlotInfo[slotTime.slot]; /* Find total symbols used including DMRS */ @@ -172,10 +166,8 @@ uint8_t schBroadcastSib1Alloc(SchCellCb *cell, SlotTimingInfo slotTime, DlBrdcst return RFAILED; } - 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)); - dlBrdcstAlloc->sib1Alloc.sib1PdcchCfg.dci.pdschCfg = &dlBrdcstAlloc->sib1Alloc.sib1PdschCfg; + memcpy(&dlBrdcstAlloc->sib1Alloc.bwp, &cell->sib1SchCfg.bwp, sizeof(BwpCfg)); + memcpy(&dlBrdcstAlloc->sib1Alloc.sib1PdcchCfg, &cell->sib1SchCfg.sib1PdcchCfg, sizeof(PdcchCfg)); schDlSlotInfo->sib1Pres = true; return ROK; } @@ -204,7 +196,7 @@ int sendUlSchInfoToMac(UlSchedInfo *ulSchedInfo, Inst inst) FILL_PST_SCH_TO_MAC(pst, inst); pst.event = EVENT_UL_SCH_INFO; - return(*schMacUlSchInfoOpts[pst.selector])(&pst, ulSchedInfo); + return(MacMessageRouter(&pst, (void *)ulSchedInfo)); } /** @@ -224,7 +216,7 @@ void fillPucchFormat0(SchPucchInfo *ulSchedPucch, SchPucchResrcInfo *resrcInfo) { if(resrcInfo->SchPucchFormat.format0) { - ulSchedPucch->fdAlloc.numPrb = PUCCH_NUM_PRB_FORMAT_0_1_4; + ulSchedPucch->fdAlloc.resAlloc.type1.numPrb = PUCCH_NUM_PRB_FORMAT_0_1_4; ulSchedPucch->pucchFormat = PUCCH_FORMAT_0; ulSchedPucch->initialCyclicShift = resrcInfo->SchPucchFormat.format0->initialCyclicShift; ulSchedPucch->tdAlloc.numSymb = resrcInfo->SchPucchFormat.format0->numSymbols; @@ -249,7 +241,7 @@ void fillPucchFormat1(SchPucchInfo *ulSchedPucch, SchPucchResrcInfo *resrcInfo) { if(resrcInfo->SchPucchFormat.format1) { - ulSchedPucch->fdAlloc.numPrb = PUCCH_NUM_PRB_FORMAT_0_1_4; + ulSchedPucch->fdAlloc.resAlloc.type1.numPrb = PUCCH_NUM_PRB_FORMAT_0_1_4; ulSchedPucch->pucchFormat = PUCCH_FORMAT_1; ulSchedPucch->initialCyclicShift = resrcInfo->SchPucchFormat.format1->initialCyclicShift; ulSchedPucch->tdAlloc.numSymb = resrcInfo->SchPucchFormat.format1->numSymbols; @@ -281,23 +273,24 @@ uint8_t fillUlSchedPucchFormat(uint8_t pucchFormat, SchPucchInfo *ulSchedPucch,\ { case PUCCH_FORMAT_0: { - if(resrcInfo) + if(resrcInfo) fillPucchFormat0(ulSchedPucch, resrcInfo); return ret; - } + } case PUCCH_FORMAT_1: { - if(resrcInfo) - { + if(resrcInfo) + { fillPucchFormat1(ulSchedPucch, resrcInfo); - } - if(formatCfg) - { - memcpy(&ulSchedPucch->cmnFormatCfg, formatCfg, sizeof(SchPucchFormatCfg)); - } - return ret; - }/* To Add support for more Pucch Format */ - + } + if(formatCfg) + { + ulSchedPucch->addDmrs = formatCfg->addDmrs; + ulSchedPucch->pi2BPSK = formatCfg->pi2BPSK; + } + return ret; + }/* To Add support for more Pucch Format */ + default: DU_LOG("\nERROR --> SCH : Invalid PUCCH format[%d] in fillUlSchedPucchFormatCfg()", pucchFormat); ret = RFAILED; @@ -341,7 +334,7 @@ uint8_t fillUlSchedPucchDedicatedCfg(SchCellCb *cell, SchPucchCfg *pucchDedCfg,\ { ulSchedPucch->intraFreqHop = pucchDedCfg->resrc->resrcToAddModList[resrcIdx].intraFreqHop; ulSchedPucch->secondPrbHop = pucchDedCfg->resrc->resrcToAddModList[resrcIdx].secondPrbHop; - ulSchedPucch->fdAlloc.startPrb = pucchDedCfg->resrc->resrcToAddModList[resrcIdx].startPrb; + ulSchedPucch->fdAlloc.resAlloc.type1.startPrb = pucchDedCfg->resrc->resrcToAddModList[resrcIdx].startPrb; ulSchedPucch->pucchFormat = pucchDedCfg->resrc->resrcToAddModList[resrcIdx].pucchFormat; ret = fillUlSchedPucchFormat(ulSchedPucch->pucchFormat, ulSchedPucch,\ &pucchDedCfg->resrc->resrcToAddModList[resrcIdx], NULLP); @@ -364,7 +357,6 @@ uint8_t fillUlSchedPucchDedicatedCfg(SchCellCb *cell, SchPucchCfg *pucchDedCfg,\ if(pucchDedCfg->format1) { - memset(&ulSchedPucch->cmnFormatCfg, 0, sizeof(SchPucchFormatCfg)); ret = fillUlSchedPucchFormat(ulSchedPucch->pucchFormat, ulSchedPucch, NULLP, pucchDedCfg->format1); if(ret == RFAILED) return ret; @@ -382,14 +374,12 @@ uint8_t fillUlSchedPucchDedicatedCfg(SchCellCb *cell, SchPucchCfg *pucchDedCfg,\ { srPeriodicity = pucchDedCfg->schedReq->schedAddModList[schedReqIdx].periodicity; srOffset = pucchDedCfg->schedReq->schedAddModList[schedReqIdx].offset; - break; + break; } if(((numSlots * slotInfo->sfn + slotInfo->slot - srOffset) % srPeriodicity) == 0) { ulSchedPucch->srFlag = true; - ulSchedPucch->uciFlag = true; } - ulSchedPucch->harqFlag = true;//check how to enable? } return ret; } @@ -407,9 +397,9 @@ uint8_t fillUlSchedPucchDedicatedCfg(SchCellCb *cell, SchPucchCfg *pucchDedCfg,\ * @return ROK/RFAILED **/ -uint16_t fillPucchResourceInfo(SchPucchInfo *schPucchInfo, Inst inst, SlotTimingInfo slotInfo) +uint16_t fillPucchResourceInfo(uint8_t ueId, SchPucchInfo *schPucchInfo, Inst inst, SlotTimingInfo slotInfo) { - uint8_t ret = ROK, ueId = 0, ueIdx = 0, pucchIdx = 0; + uint8_t ret = ROK, ueIdx = 0, pucchIdx = 0; SchCellCb *cell = schCb[inst].cells[inst]; SchPucchCfgCmn *pucchCfg = NULLP; SchBwpParams *ulBwp = NULLP; @@ -418,10 +408,9 @@ uint16_t fillPucchResourceInfo(SchPucchInfo *schPucchInfo, Inst inst, SlotTiming #endif uint16_t startPrb; - GET_UE_ID(schPucchInfo->rnti, ueId); ueIdx = ueId -1; #ifdef NR_DRX - ueCb = schGetUeCb(cell, schPucchInfo->rnti); + ueCb = &(cell->ueCb[ueIdx]); if(ueCb->ueDrxInfoPres) { if(!ueCb->drxUeCb.drxUlUeActiveStatus) @@ -444,23 +433,22 @@ uint16_t fillPucchResourceInfo(SchPucchInfo *schPucchInfo, Inst inst, SlotTiming { /* fill pucch common cfg */ /* derive pucchResourceSet from schCellCfg */ - pucchCfg = &cell->cellCfg.schInitialUlBwp.pucchCommon; + pucchCfg = &cell->cellCfg.ulCfgCommon.schInitialUlBwp.pucchCommon; pucchIdx = pucchCfg->pucchResourceCommon; - ulBwp = &cell->cellCfg.schInitialUlBwp.bwp; + ulBwp = &cell->cellCfg.ulCfgCommon.schInitialUlBwp.bwp; startPrb = ulBwp->freqAlloc.startPrb + pucchResourceSet[pucchIdx][3]; ret = allocatePrbUl(cell, slotInfo, pucchResourceSet[pucchIdx][1], pucchResourceSet[pucchIdx][2],\ &startPrb, PUCCH_NUM_PRB_FORMAT_0_1_4); if (ret == ROK) { - schPucchInfo->fdAlloc.startPrb = ulBwp->freqAlloc.startPrb + pucchResourceSet[pucchIdx][3]; - schPucchInfo->fdAlloc.numPrb = PUCCH_NUM_PRB_FORMAT_0_1_4; + schPucchInfo->fdAlloc.resAlloc.type1.startPrb = ulBwp->freqAlloc.startPrb + pucchResourceSet[pucchIdx][3]; + schPucchInfo->fdAlloc.resAlloc.type1.numPrb = PUCCH_NUM_PRB_FORMAT_0_1_4; schPucchInfo->tdAlloc.startSymb = pucchResourceSet[pucchIdx][1]; schPucchInfo->tdAlloc.numSymb = pucchResourceSet[pucchIdx][2]; schPucchInfo->pucchFormat = pucchResourceSet[pucchIdx][0]; /* set SR and UCI flag to false */ schPucchInfo->srFlag = true; - schPucchInfo->uciFlag = true; } } return ROK; @@ -504,7 +492,7 @@ uint8_t schUlResAlloc(SchCellCb *cell, Inst schInst) schUlSlotInfo = cell->schUlSlotInfo[ulTimingInfo.slot]; if(schUlSlotInfo->schPuschInfo) { - ulSchedInfo.crnti = schUlSlotInfo->schPuschInfo->crnti; + GET_CRNTI(ulSchedInfo.crnti, schUlSlotInfo->puschUe); /* Check the ue drx status if the UE is active for uplink scheduling or not */ #ifdef NR_DRX ueCb = schGetUeCb(cell, ulSchedInfo.crnti); @@ -523,7 +511,8 @@ uint8_t schUlResAlloc(SchCellCb *cell, Inst schInst) if(schUlSlotInfo->pucchPres) { - ret = fillPucchResourceInfo(&schUlSlotInfo->schPucchInfo, schInst, ulTimingInfo); + GET_CRNTI(ulSchedInfo.crnti, schUlSlotInfo->pucchUe); + ret = fillPucchResourceInfo(schUlSlotInfo->pucchUe, &schUlSlotInfo->schPucchInfo, schInst, ulTimingInfo); if (ret == ROK) { ulSchedInfo.dataType |= SCH_DATATYPE_UCI; @@ -596,7 +585,7 @@ uint8_t schDlRsrcAllocMsg4(SchCellCb *cell, SlotTimingInfo msg4Time, uint8_t ueI } msg4Alloc = &dlMsgAlloc->dlMsgSchedInfo[dlMsgAlloc->numSchedInfo]; - initialBwp = &cell->cellCfg.schInitialDlBwp; + initialBwp = &cell->cellCfg.dlCfgCommon.schInitialDlBwp; pdcch = &msg4Alloc->dlMsgPdcchCfg; pdsch = &msg4Alloc->dlMsgPdschCfg; bwp = &msg4Alloc->bwp; @@ -629,7 +618,7 @@ uint8_t schDlRsrcAllocMsg4(SchCellCb *cell, SlotTimingInfo msg4Time, uint8_t ueI pdcch->coresetCfg.startSymbolIndex = firstSymbol; pdcch->coresetCfg.durationSymbols = numSymbols; memcpy(pdcch->coresetCfg.freqDomainResource, \ - cell->cellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.freqDomainRsrc, FREQ_DOM_RSRC_SIZE); + cell->cellCfg.dlCfgCommon.schInitialDlBwp.pdcchCommon.commonSearchSpace.freqDomainRsrc, FREQ_DOM_RSRC_SIZE); pdcch->coresetCfg.cceRegMappingType = 1; /* coreset0 is always interleaved */ pdcch->coresetCfg.regBundleSize = 6; /* spec-38.211 sec 7.3.2.2 */ @@ -649,7 +638,7 @@ uint8_t schDlRsrcAllocMsg4(SchCellCb *cell, SlotTimingInfo msg4Time, uint8_t ueI 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.beta_pdcch_1_0 = 0; pdcch->dci.txPdcchPower.powerControlOffsetSS = 0; pdcch->dci.pdschCfg = pdsch; @@ -692,12 +681,12 @@ uint8_t schDlRsrcAllocMsg4(SchCellCb *cell, SlotTimingInfo msg4Time, uint8_t ueI pdsch->dmrs.nrOfDmrsSymbols = NUM_DMRS_SYMBOLS; pdsch->dmrs.dmrsAddPos = DMRS_ADDITIONAL_POS; - pdsch->pdschTimeAlloc.timeAlloc.startSymb = pdschStartSymbol; - pdsch->pdschTimeAlloc.timeAlloc.numSymb = pdschNumSymbols; + pdsch->pdschTimeAlloc.startSymb = pdschStartSymbol; + pdsch->pdschTimeAlloc.numSymb = pdschNumSymbols; pdsch->pdschFreqAlloc.resourceAllocType = 1; /* RAT type-1 RIV format */ - pdsch->pdschFreqAlloc.freqAlloc.startPrb = MAX_NUM_RB; - pdsch->pdschFreqAlloc.freqAlloc.numPrb = schCalcNumPrb(tbSize, mcs, pdschNumSymbols); + pdsch->pdschFreqAlloc.startPrb = MAX_NUM_RB; + pdsch->pdschFreqAlloc.numPrb = schCalcNumPrb(tbSize, mcs, pdschNumSymbols); pdsch->pdschFreqAlloc.vrbPrbMapping = 0; /* non-interleaved */ /* Find total symbols occupied including DMRS */ @@ -706,19 +695,19 @@ uint8_t schDlRsrcAllocMsg4(SchCellCb *cell, SlotTimingInfo msg4Time, uint8_t ueI * in that case only PDSCH symbols are marked as occupied */ if(dmrsStartSymbol == MAX_SYMB_PER_SLOT) { - startSymbol = pdsch->pdschTimeAlloc.timeAlloc.startSymb; - numSymbol = pdsch->pdschTimeAlloc.timeAlloc.numSymb; + startSymbol = pdsch->pdschTimeAlloc.startSymb; + numSymbol = pdsch->pdschTimeAlloc.numSymb; } /* If DMRS symbol is found, mark DMRS and PDSCH symbols as occupied */ else { startSymbol = dmrsStartSymbol; - numSymbol = pdsch->dmrs.nrOfDmrsSymbols + pdsch->pdschTimeAlloc.timeAlloc.numSymb; + numSymbol = pdsch->dmrs.nrOfDmrsSymbols + pdsch->pdschTimeAlloc.numSymb; } /* Allocate the number of PRBs required for RAR PDSCH */ if((allocatePrbDl(cell, msg4Time, startSymbol, numSymbol,\ - &pdsch->pdschFreqAlloc.freqAlloc.startPrb, pdsch->pdschFreqAlloc.freqAlloc.numPrb)) != ROK) + &pdsch->pdschFreqAlloc.startPrb, pdsch->pdschFreqAlloc.numPrb)) != ROK) { DU_LOG("\nERROR --> SCH : Resource allocation failed for MSG4"); return RFAILED; @@ -765,12 +754,10 @@ uint16_t schAllocPucchResource(SchCellCb *cell, SlotTimingInfo pucchTime, uint16 memset(&schUlSlotInfo->schPucchInfo, 0, sizeof(SchPucchInfo)); schUlSlotInfo->pucchPres = true; - schUlSlotInfo->schPucchInfo.rnti = crnti; if(ueCb != NULLP) { /* set HARQ flag to true */ - schUlSlotInfo->schPucchInfo.harqFlag = true; - schUlSlotInfo->schPucchInfo.numHarqBits = 1; /* 1 bit for HARQ */ + schUlSlotInfo->schPucchInfo.harqInfo.harqBitLength = 1; /* 1 bit for HARQ */ ADD_DELTA_TO_TIME(pucchTime, pucchTime, 3, cell->numSlots); /* SLOT_DELAY=3 */ cmLListAdd2Tail(&(ueCb->hqDlmap[pucchTime.slot]->hqList), &hqP->ulSlotLnk); } @@ -822,8 +809,8 @@ uint8_t schDlRsrcAllocDlMsg(SchCellCb *cell, SlotTimingInfo slotTime, uint16_t c /* fill BWP */ bwp->freqAlloc.numPrb = MAX_NUM_RB; bwp->freqAlloc.startPrb = 0; - bwp->subcarrierSpacing = cell->cellCfg.sib1SchCfg.bwp.subcarrierSpacing; - bwp->cyclicPrefix = cell->cellCfg.sib1SchCfg.bwp.cyclicPrefix; + bwp->subcarrierSpacing = cell->sib1SchCfg.bwp.subcarrierSpacing; + bwp->cyclicPrefix = cell->sib1SchCfg.bwp.cyclicPrefix; /* fill the PDCCH PDU */ //Considering coreset1 also starts from same symbol as coreset0 @@ -849,7 +836,7 @@ uint8_t schDlRsrcAllocDlMsg(SchCellCb *cell, SlotTimingInfo slotTime, uint16_t c 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.beta_pdcch_1_0 = 0; pdcch->dci.txPdcchPower.powerControlOffsetSS = 0; /* fill the PDSCH PDU */ @@ -887,13 +874,13 @@ uint8_t schDlRsrcAllocDlMsg(SchCellCb *cell, SlotTimingInfo slotTime, uint16_t c pdsch->dmrs.nrOfDmrsSymbols = NUM_DMRS_SYMBOLS; pdsch->dmrs.dmrsAddPos = pdschCfg.dmrsDlCfgForPdschMapTypeA.addPos; - pdsch->pdschTimeAlloc.timeAlloc.startSymb = pdschStartSymbol; - pdsch->pdschTimeAlloc.timeAlloc.numSymb = pdschNumSymbols; + pdsch->pdschTimeAlloc.startSymb = pdschStartSymbol; + pdsch->pdschTimeAlloc.numSymb = pdschNumSymbols; pdsch->pdschFreqAlloc.vrbPrbMapping = 0; /* non-interleaved */ pdsch->pdschFreqAlloc.resourceAllocType = 1; /* RAT type-1 RIV format */ - pdsch->pdschFreqAlloc.freqAlloc.startPrb = startPRB; /*Start PRB will be already known*/ - pdsch->pdschFreqAlloc.freqAlloc.numPrb = schCalcNumPrb(tbSize, ueCb.ueCfg.dlModInfo.mcsIndex, pdschNumSymbols); + pdsch->pdschFreqAlloc.startPrb = startPRB; /*Start PRB will be already known*/ + pdsch->pdschFreqAlloc.numPrb = schCalcNumPrb(tbSize, ueCb.ueCfg.dlModInfo.mcsIndex, pdschNumSymbols); /* Find total symbols occupied including DMRS */ dmrsStartSymbol = findDmrsStartSymbol(pdsch->dmrs.dlDmrsSymbPos); @@ -901,19 +888,19 @@ uint8_t schDlRsrcAllocDlMsg(SchCellCb *cell, SlotTimingInfo slotTime, uint16_t c * in that case only PDSCH symbols are marked as occupied */ if(dmrsStartSymbol == MAX_SYMB_PER_SLOT) { - startSymbol = pdsch->pdschTimeAlloc.timeAlloc.startSymb; - numSymbol = pdsch->pdschTimeAlloc.timeAlloc.numSymb; + startSymbol = pdsch->pdschTimeAlloc.startSymb; + numSymbol = pdsch->pdschTimeAlloc.numSymb; } /* If DMRS symbol is found, mark DMRS and PDSCH symbols as occupied */ else { startSymbol = dmrsStartSymbol; - numSymbol = pdsch->dmrs.nrOfDmrsSymbols + pdsch->pdschTimeAlloc.timeAlloc.numSymb; + numSymbol = pdsch->dmrs.nrOfDmrsSymbols + pdsch->pdschTimeAlloc.numSymb; } /* Allocate the number of PRBs required for DL PDSCH */ if((allocatePrbDl(cell, slotTime, startSymbol, numSymbol,\ - &pdsch->pdschFreqAlloc.freqAlloc.startPrb, pdsch->pdschFreqAlloc.freqAlloc.numPrb)) != ROK) + &pdsch->pdschFreqAlloc.startPrb, pdsch->pdschFreqAlloc.numPrb)) != ROK) { DU_LOG("\nERROR --> SCH : allocatePrbDl() failed for DL MSG"); return RFAILED; @@ -1085,7 +1072,7 @@ SchPdschConfig pdschDedCfg, uint8_t ulAckListCount, uint8_t *UlAckTbl) /* Initialization the K0K1 structure, total num of slot and calculating the slot pattern length. */ memset(k0K1InfoTbl, 0, sizeof(SchK0K1TimingInfoTbl)); k0K1InfoTbl->tblSize = cell->numSlots; - totalCfgSlot = calculateSlotPatternLength(cell->cellCfg.ssbSchCfg.scsCommon, cell->cellCfg.tddCfg.tddPeriod); + totalCfgSlot = calculateSlotPatternLength(cell->cellCfg.scsCommon, cell->cellCfg.tddCfg.tddPeriod); /* Storing time domain resource allocation list based on common or * dedicated configuration availability. */ @@ -1115,7 +1102,8 @@ SchPdschConfig pdschDedCfg, uint8_t ulAckListCount, uint8_t *UlAckTbl) { continue; } - + + ulSlotPresent = false; /* Storing K0 , start symbol and length symbol for further processing. * If K0 value is not available then we can fill the default values * given in spec 38.331. */ @@ -1156,14 +1144,21 @@ SchPdschConfig pdschDedCfg, uint8_t ulAckListCount, uint8_t *UlAckTbl) { for(checkSymbol = startSymbol; checkSymbolcellCfg.tddCfg.slotCfg[tmpSlot][checkSymbol]; + slotCfg = cell->slotCfg[tmpSlot][checkSymbol]; if(slotCfg == UL_SLOT) { - continue; + ulSlotPresent = true; + break; } } + if(ulSlotPresent == true) + { + continue; + } } + ulSlotPresent = false; //Re-initializing + /* If current slot + k0 + k1 is a DL slot then skip the slot * else if it is UL slot then store the information * else if it is FLEXI slot then check the symbols, it must have @@ -1184,7 +1179,7 @@ SchPdschConfig pdschDedCfg, uint8_t ulAckListCount, uint8_t *UlAckTbl) { for(checkSymbol = 0; checkSymbol< MAX_SYMB_PER_SLOT;checkSymbol++) { - if(cell->cellCfg.tddCfg.slotCfg[tmpSlot][checkSymbol] == UL_SLOT) + if(cell->slotCfg[tmpSlot][checkSymbol] == UL_SYMBOL) { ulSlotPresent = true; break; @@ -1307,7 +1302,7 @@ SchK2TimingInfoTbl *msg3K2InfoTbl, SchK2TimingInfoTbl *k2InfoTbl) k2InfoTbl->tblSize = cell->numSlots; if(msg3K2InfoTbl) msg3K2InfoTbl->tblSize = cell->numSlots; - totalCfgSlot = calculateSlotPatternLength(cell->cellCfg.ssbSchCfg.scsCommon, cell->cellCfg.tddCfg.tddPeriod); + totalCfgSlot = calculateSlotPatternLength(cell->cellCfg.scsCommon, cell->cellCfg.tddCfg.tddPeriod); /* Checking all possible indexes for K2. */ for(slotIdx = 0; slotIdx < cell->numSlots; slotIdx++) @@ -1325,7 +1320,7 @@ SchK2TimingInfoTbl *msg3K2InfoTbl, SchK2TimingInfoTbl *k2InfoTbl) k2Val = timeDomRsrcAllocList[k2Index].k2; if(!k2Val) { - switch(cell->cellCfg.ssbSchCfg.scsCommon) + switch(cell->cellCfg.scsCommon) { case SCS_15KHZ: k2Val = DEFAULT_K2_VALUE_FOR_SCS15; @@ -1356,7 +1351,7 @@ SchK2TimingInfoTbl *msg3K2InfoTbl, SchK2TimingInfoTbl *k2InfoTbl) dlSymbolPresent = false; for(checkSymbol= startSymbol; checkSymbolcellCfg.tddCfg.slotCfg[k2TmpVal][checkSymbol]; + currentSymbol = cell->slotCfg[k2TmpVal][checkSymbol]; if(currentSymbol == DL_SLOT || currentSymbol == FLEXI_SLOT) { dlSymbolPresent = true; @@ -1392,7 +1387,7 @@ SchK2TimingInfoTbl *msg3K2InfoTbl, SchK2TimingInfoTbl *k2InfoTbl) dlSymbolPresent = false; for(checkSymbol= startSymbol; checkSymbolcellCfg.tddCfg.slotCfg[msg3K2TmpVal][checkSymbol]; + currentSymbol = cell->slotCfg[msg3K2TmpVal][checkSymbol]; if(currentSymbol == DL_SLOT || currentSymbol == FLEXI_SLOT) { dlSymbolPresent = true; @@ -1652,11 +1647,7 @@ void updateGrantSizeForBoRpt(CmLListCp *lcLL, DlMsgAlloc *dlMsgAlloc,\ lcNode->lcId,lcNode->reqBO, dlMsgSchInfo->numLc, *accumalatedBOSize); dlMsgSchInfo->numLc++; - /*The LC has been fully allocated, clean it*/ - if(lcNode->reqBO == 0) - { - handleLcLList(lcLL, lcNode->lcId, DELETE); - } + handleLcLList(lcLL, lcNode->lcId, DELETE); } else if(bsrInfo != NULLP) { @@ -1847,137 +1838,64 @@ uint8_t schProcessMsg4Req(SchCellCb *cell, SlotTimingInfo currTime, uint8_t ueId /******************************************************************* * - * @brief Handler to calculate TBS size for BSR requested + * @brief sch Process pending Sr or Bsr Req * * @details * - * Function : schCalculateUlTbs - * - * Functionality: Function will note the required TBS for each LCGIDX and use - * the Priority LCG List and RRM policy to allocate the TBS size + * Function : updateBsrAndLcList * - * @params [in] ueCb (Pointer to UE CB) - * [in] puschTime (Time slot where PUSCH will be sent) - * [in] symbLen (No of Symbols used for PUSCH transmission) - * [out] startPrb(Pointer to startPRB which will be calculated while - * finding the best Free Block) - * [out] totTBS(Pointer to total TBS size) - * [in] isRetx (to indicate retransmission) - * [in] hqP (UL Harq process pointer) + * Functionality: + * Updating the BSRInfo in UECB and Lclist * - * @return uint8_t : ROK > Scheduling of UL grant is successful - * RFAILED > vice versa + * @params[in] SchCellCb *cell, SlotTimingInfo currTime + * @return ROK - success + * RFAILED - failure * - * ****************************************************************/ -uint8_t schCalculateUlTbs(SchUeCb *ueCb, SlotTimingInfo puschTime, uint8_t symbLen,\ - uint16_t *startPrb, uint32_t *totTBS, bool isRetx, SchUlHqProcCb *hqP) + *******************************************************************/ +void updateBsrAndLcList(CmLListCp *lcLL, BsrInfo *bsrInfo, uint8_t status) { - uint16_t mcsIdx = 0; - CmLListCp *lcLL = NULLP; - uint16_t lcgIdx = 0, lcId =0, maxFreePRB = 0; - uint16_t rsvdDedicatedPRB; - *startPrb = 0; - *totTBS = 0; + CmLList *node = NULLP, *next = NULLP; + LcInfo *lcNode = NULLP; - /* check for BSR */ - for(lcgIdx=0; lcgIdxbsrInfo[lcgIdx].dataVol == 0) - { - continue; - } - - /*TODO: lcgIdx and LCID has been implemented as one to one mapping. - * Need to check the mapping to figure out the LCID and lcgIdx once L2 - * spec specifies any logic*/ - lcId = lcgIdx; - if(ueCb->ulInfo.ulLcCtxt[lcId].isDedicated) - { - lcLL = &(hqP->ulLcPrbEst.dedLcList); - rsvdDedicatedPRB = ueCb->ulInfo.ulLcCtxt[lcId].rsvdDedicatedPRB; - } - else - { - lcLL = &(hqP->ulLcPrbEst.defLcList); - } - - /*[Step2]: Update the reqPRB and Payloadsize for this LC in the appropriate List*/ - if(updateLcListReqPRB(lcLL, lcId, ueCb->bsrInfo[lcgIdx].dataVol) != ROK) - { - DU_LOG("\nERROR --> SCH: LcgId:%d updation failed",lcId); - return RFAILED; - } + DU_LOG("\nERROR --> SCH: LcList not present"); + return; } - if ((hqP->ulLcPrbEst.defLcList.count == 0) && (hqP->ulLcPrbEst.dedLcList.count == 0)) + if(lcLL->count) { - if( (ueCb->srRcvd) || (isRetx) ) - { - *startPrb = MAX_NUM_RB; - *totTBS = schCalcTbSize(UL_GRANT_SIZE); - } - /*Returning true when NO Grant is there for UE as this is not scheduling - * error*/ - return ROK; + node = lcLL->first; } - - maxFreePRB = searchLargestFreeBlock(ueCb->cellCb, puschTime, startPrb, DIR_UL); - - /*[Step4]: Estimation of PRB and BO which can be allocated to each LC in - * the list based on RRM policy*/ - - /*Either this UE contains no reservedPRB pool fir dedicated S-NSSAI or - * Num of Free PRB available is not enough to reserve Dedicated PRBs*/ - if(maxFreePRB != 0) + else { - mcsIdx = ueCb->ueCfg.ulModInfo.mcsIndex; - if((hqP->ulLcPrbEst.dedLcList.count == 0) || ((maxFreePRB < rsvdDedicatedPRB))) - { - hqP->ulLcPrbEst.sharedNumPrb = maxFreePRB; - DU_LOG("\nDEBUG --> SCH : UL Only Default Slice is scheduled, sharedPRB Count:%d",\ - hqP->ulLcPrbEst.sharedNumPrb); - - /*PRB Alloc for Default LCs*/ - prbAllocUsingRRMPolicy(&(hqP->ulLcPrbEst.defLcList), FALSE, mcsIdx, symbLen,\ - &(hqP->ulLcPrbEst.sharedNumPrb), NULLP, NULLP,&(ueCb->srRcvd)); - } - else - { - hqP->ulLcPrbEst.sharedNumPrb = maxFreePRB - rsvdDedicatedPRB; - - /*PRB Alloc for Dedicated LCs*/ - prbAllocUsingRRMPolicy(&(hqP->ulLcPrbEst.dedLcList), TRUE, mcsIdx, symbLen,\ - &(hqP->ulLcPrbEst.sharedNumPrb), &(rsvdDedicatedPRB),\ - NULLP,&(ueCb->srRcvd)); - - /*PRB Alloc for Default LCs*/ - prbAllocUsingRRMPolicy(&(hqP->ulLcPrbEst.defLcList), FALSE, mcsIdx, symbLen, \ - &(hqP->ulLcPrbEst.sharedNumPrb), &(rsvdDedicatedPRB),\ - NULLP,&(ueCb->srRcvd)); - } + /*lcLL is empty*/ + return; } - /*[Step5]:Traverse each LCID in LcList to calculate the exact Scheduled Bytes - * using allocated BO per LC and Update dlMsgAlloc(BO report for MAC*/ - if(hqP->ulLcPrbEst.dedLcList.count != 0) - updateGrantSizeForBoRpt(&(hqP->ulLcPrbEst.dedLcList), NULLP, ueCb->bsrInfo, totTBS); - updateGrantSizeForBoRpt(&(hqP->ulLcPrbEst.defLcList), NULLP, ueCb->bsrInfo, totTBS); - - /*Below case will hit if NO LC(s) are allocated due to resource crunch*/ - if (*totTBS == 0) + while(node) { - if(maxFreePRB == 0) + next = node->next; + lcNode = (LcInfo *)node->node; + if(lcNode != NULLP) { - DU_LOG("\nERROR --> SCH : NO FREE PRB!!"); + /*Only when Status is OK then allocation is marked as ZERO and reqBO + * is updated in UE's DB. If Failure, then allocation is added to reqBO + * and same is updated in Ue's DB inside BSR Info structure*/ + if(status == ROK) + { + lcNode->allocBO = 0; + } + + lcNode->reqBO += lcNode->allocBO; + bsrInfo[lcNode->lcId].dataVol = lcNode->reqBO; + if(lcNode->reqBO == 0) + { + handleLcLList(lcLL, lcNode->lcId, DELETE); + } } - else - { - /*Schedule the LC for next slot*/ - DU_LOG("\nDEBUG --> SCH : No LC has been scheduled"); - } - return RFAILED; - } - return ROK; + node = next; + } } /******************************************************************* @@ -2000,14 +1918,9 @@ uint8_t schCalculateUlTbs(SchUeCb *ueCb, SlotTimingInfo puschTime, uint8_t symbL bool schProcessSrOrBsrReq(SchCellCb *cell, SlotTimingInfo currTime, uint8_t ueId, bool isRetx, SchUlHqProcCb **hqP) { bool k2Found = FALSE; - uint8_t ret = RFAILED; uint8_t startSymb = 0, symbLen = 0; uint8_t k2TblIdx = 0, k2Index = 0, k2Val = 0; - uint16_t startPrb = 0; - uint32_t totDataReq = 0; /* in bytes */ SchUeCb *ueCb; - SchPuschInfo *puschInfo; - DciInfo *dciInfo = NULLP; SchK2TimingInfoTbl *k2InfoTbl=NULLP; SlotTimingInfo dciTime, puschTime; @@ -2042,7 +1955,7 @@ bool schProcessSrOrBsrReq(SchCellCb *cell, SlotTimingInfo currTime, uint8_t ueId if(ueCb->ueCfg.spCellCfg.servCellRecfg.initUlBwp.k2TblPrsnt) k2InfoTbl = &ueCb->ueCfg.spCellCfg.servCellRecfg.initUlBwp.k2InfoTbl; else - k2InfoTbl = &cell->cellCfg.schInitialUlBwp.k2InfoTbl; + k2InfoTbl = &cell->k2InfoTbl; for(k2TblIdx = 0; k2TblIdx < k2InfoTbl->k2TimingInfo[dciTime.slot].numK2; k2TblIdx++) { @@ -2050,9 +1963,9 @@ bool schProcessSrOrBsrReq(SchCellCb *cell, SlotTimingInfo currTime, uint8_t ueId if(!ueCb->ueCfg.spCellCfg.servCellRecfg.initUlBwp.k2TblPrsnt) { - k2Val = cell->cellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[k2Index].k2; - startSymb = cell->cellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[k2Index].startSymbol; - symbLen = cell->cellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[k2Index].symbolLength; + k2Val = cell->cellCfg.ulCfgCommon.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[k2Index].k2; + startSymb = cell->cellCfg.ulCfgCommon.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[k2Index].startSymbol; + symbLen = cell->cellCfg.ulCfgCommon.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[k2Index].symbolLength; } else { @@ -2082,52 +1995,8 @@ bool schProcessSrOrBsrReq(SchCellCb *cell, SlotTimingInfo currTime, uint8_t ueId if(k2Found == true) { - ret = schCalculateUlTbs(ueCb, puschTime, symbLen, &startPrb, &totDataReq, isRetx, *hqP); - - if(totDataReq > 0 && ret == ROK) - { - SCH_ALLOC(dciInfo, sizeof(DciInfo)); - if(!dciInfo) - { - DU_LOG("\nERROR --> SCH : Memory Allocation failed for dciInfo alloc"); - if(isRetx != TRUE) - { - if((*hqP)->ulLcPrbEst.dedLcList.count != 0) - updateBsrAndLcList(&((*hqP)->ulLcPrbEst.dedLcList), ueCb->bsrInfo, RFAILED); - - updateBsrAndLcList(&((*hqP)->ulLcPrbEst.defLcList), ueCb->bsrInfo, RFAILED); - } - return false; - } - cell->schDlSlotInfo[dciTime.slot]->ulGrant = dciInfo; - memset(dciInfo,0,sizeof(DciInfo)); - - /* Update PUSCH allocation */ - if(schFillPuschAlloc(ueCb, puschTime, totDataReq, startSymb, symbLen, startPrb, isRetx, *hqP) == ROK) - { - if(cell->schUlSlotInfo[puschTime.slot]->schPuschInfo) - { - puschInfo = cell->schUlSlotInfo[puschTime.slot]->schPuschInfo; - if(puschInfo != NULLP) - { - /* Fill DCI for UL grant */ - schFillUlDci(ueCb, puschInfo, dciInfo, isRetx, *hqP); - memcpy(&dciInfo->slotIndInfo, &dciTime, sizeof(SlotTimingInfo)); - ueCb->srRcvd = false; - ueCb->bsrRcvd = false; - cell->schUlSlotInfo[puschTime.slot]->puschUe = ueId; - if((*hqP)->ulLcPrbEst.dedLcList.count != 0) - updateBsrAndLcList(&((*hqP)->ulLcPrbEst.dedLcList), ueCb->bsrInfo, ROK); - updateBsrAndLcList(&((*hqP)->ulLcPrbEst.defLcList), ueCb->bsrInfo, ROK); - cmLListAdd2Tail(&(ueCb->hqUlmap[puschTime.slot]->hqList), &(*hqP)->ulSlotLnk); - return true; - } - } - } - if((*hqP)->ulLcPrbEst.dedLcList.count != 0) - updateBsrAndLcList(&((*hqP)->ulLcPrbEst.dedLcList), ueCb->bsrInfo, RFAILED); - updateBsrAndLcList(&((*hqP)->ulLcPrbEst.defLcList), ueCb->bsrInfo, RFAILED); - } + if(cell->api->SchScheduleUlLc(dciTime, puschTime, startSymb, symbLen, isRetx, hqP) != ROK) + return false; } else { @@ -2137,69 +2006,6 @@ bool schProcessSrOrBsrReq(SchCellCb *cell, SlotTimingInfo currTime, uint8_t ueId return true; } - -/******************************************************************* - * - * @brief sch Process pending Sr or Bsr Req - * - * @details - * - * Function : updateBsrAndLcList - * - * Functionality: - * Updating the BSRInfo in UECB and Lclist - * - * @params[in] SchCellCb *cell, SlotTimingInfo currTime - * @return ROK - success - * RFAILED - failure - * - *******************************************************************/ -void updateBsrAndLcList(CmLListCp *lcLL, BsrInfo *bsrInfo, uint8_t status) -{ - CmLList *node = NULLP, *next = NULLP; - LcInfo *lcNode = NULLP; - - if(lcLL == NULLP) - { - DU_LOG("\nERROR --> SCH: LcList not present"); - return; - } - - if(lcLL->count) - { - node = lcLL->first; - } - else - { - /*lcLL is empty*/ - return; - } - - while(node) - { - next = node->next; - lcNode = (LcInfo *)node->node; - if(lcNode != NULLP) - { - /*Only when Status is OK then allocation is marked as ZERO and reqBO - * is updated in UE's DB. If Failure, then allocation is added to reqBO - * and same is updated in Ue's DB inside BSR Info structure*/ - if(status == ROK) - { - lcNode->allocBO = 0; - } - - lcNode->reqBO += lcNode->allocBO; - bsrInfo[lcNode->lcId].dataVol = lcNode->reqBO; - if(lcNode->reqBO == 0) - { - handleLcLList(lcLL, lcNode->lcId, DELETE); - } - } - node = next; - } -} - /******************************************************************************** * * @brief Increment the Slot by a input factor @@ -2287,13 +2093,13 @@ uint8_t schFillPagePdschCfg(SchCellCb *cell, PdschCfg *pagePdschCfg, SlotTimingI pagePdschCfg->pdschFreqAlloc.resourceAllocType = 1; /* RAT type-1 RIV format */ /* the RB numbering starts from coreset0, and PDSCH is always above SSB */ - pagePdschCfg->pdschFreqAlloc.freqAlloc.startPrb = startPrb; - pagePdschCfg->pdschFreqAlloc.freqAlloc.numPrb = schCalcNumPrb(tbSize, mcs, NUM_PDSCH_SYMBOL); + pagePdschCfg->pdschFreqAlloc.startPrb = startPrb; + pagePdschCfg->pdschFreqAlloc.numPrb = schCalcNumPrb(tbSize, mcs, NUM_PDSCH_SYMBOL); pagePdschCfg->pdschFreqAlloc.vrbPrbMapping = 0; /* non-interleaved */ pagePdschCfg->pdschTimeAlloc.rowIndex = 1; /* This is Intel's requirement. PDSCH should start after PDSCH DRMS symbol */ - pagePdschCfg->pdschTimeAlloc.timeAlloc.startSymb = 3; /* spec-38.214, Table 5.1.2.1-1 */ - pagePdschCfg->pdschTimeAlloc.timeAlloc.numSymb = NUM_PDSCH_SYMBOL; + pagePdschCfg->pdschTimeAlloc.startSymb = 3; /* spec-38.214, Table 5.1.2.1-1 */ + pagePdschCfg->pdschTimeAlloc.numSymb = NUM_PDSCH_SYMBOL; /* Find total symbols occupied including DMRS */ dmrsStartSymbol = findDmrsStartSymbol(pagePdschCfg->dmrs.dlDmrsSymbPos); @@ -2301,19 +2107,19 @@ uint8_t schFillPagePdschCfg(SchCellCb *cell, PdschCfg *pagePdschCfg, SlotTimingI * in that case only PDSCH symbols are marked as occupied */ if(dmrsStartSymbol == MAX_SYMB_PER_SLOT) { - startSymbol = pagePdschCfg->pdschTimeAlloc.timeAlloc.startSymb; - numSymbol = pagePdschCfg->pdschTimeAlloc.timeAlloc.numSymb; + startSymbol = pagePdschCfg->pdschTimeAlloc.startSymb; + numSymbol = pagePdschCfg->pdschTimeAlloc.numSymb; } /* If DMRS symbol is found, mark DMRS and PDSCH symbols as occupied */ else { startSymbol = dmrsStartSymbol; - numSymbol = pagePdschCfg->dmrs.nrOfDmrsSymbols + pagePdschCfg->pdschTimeAlloc.timeAlloc.numSymb; + numSymbol = pagePdschCfg->dmrs.nrOfDmrsSymbols + pagePdschCfg->pdschTimeAlloc.numSymb; } /* Allocate the number of PRBs required for DL PDSCH */ if((allocatePrbDl(cell, slotTime, startSymbol, numSymbol,\ - &pagePdschCfg->pdschFreqAlloc.freqAlloc.startPrb, pagePdschCfg->pdschFreqAlloc.freqAlloc.numPrb)) != ROK) + &pagePdschCfg->pdschFreqAlloc.startPrb, pagePdschCfg->pdschFreqAlloc.numPrb)) != ROK) { DU_LOG("\nERROR --> SCH : allocatePrbDl() failed for DL MSG"); return RFAILED; @@ -2330,6 +2136,155 @@ uint8_t schFillPagePdschCfg(SchCellCb *cell, PdschCfg *pagePdschCfg, SlotTimingI return ROK; } +/** + * @brief Handles retransmission for MSG3 + * + * @details + * + * Function : schMsg3RetxSchedulingForUe + * + * This function handles retransmission for MSG3 + * + * @param[in] SchRaCb *raCb, RA cb pointer + * @return + * -# ROK + * -# RFAILED + **/ +uint8_t schMsg3RetxSchedulingForUe(SchRaCb *raCb) +{ + bool k2Found = false; + uint16_t dciSlot = 0; + SlotTimingInfo dciTime, msg3Time; + SchCellCb *cell = NULLP; + SlotTimingInfo currTime; + DciInfo *dciInfo = NULLP; + cell = raCb->cell; + currTime = cell->slotInfo; + + /* Calculating time frame to send DCI for MSG3 Retx*/ + ADD_DELTA_TO_TIME(currTime, dciTime, PHY_DELTA_DL + SCHED_DELTA, cell->numSlots); +#ifdef NR_TDD + /* Consider this slot for sending DCI, only if it is a DL slot */ + if(schGetSlotSymbFrmt(dciSlot, raCb->cell->slotFrmtBitMap) == DL_SLOT) +#endif + { + /* If PDCCH is already scheduled on this slot, cannot schedule PDSCH for another UE here. */ + if(cell->schDlSlotInfo[dciSlot]->pdcchUe != 0) + return false; + + k2Found = schGetMsg3K2(cell, &raCb->msg3HqProc, dciTime.slot, &msg3Time, TRUE); + + if (!k2Found) + { + return RFAILED; + } + SCH_ALLOC(dciInfo, sizeof(DciInfo)); + if(!dciInfo) + { + DU_LOG("\nERROR --> SCH : Memory Allocation failed for dciInfo alloc"); + return RFAILED; + } + cell->schDlSlotInfo[msg3Time.slot]->ulGrant = dciInfo; + SCH_ALLOC(cell->schUlSlotInfo[msg3Time.slot]->schPuschInfo, sizeof(SchPuschInfo)); + memset(dciInfo,0,sizeof(DciInfo)); + schFillUlDciForMsg3Retx(raCb, cell->schUlSlotInfo[msg3Time.slot]->schPuschInfo, dciInfo); + } + raCb->retxMsg3HqProc = NULLP; + return ROK; +} + +/** + * @brief Get K2 value for MSG3 + * + * @details + * + * Function : schGetMsg3K2 + * + * This function gets K2 for MSG3 + * + * @param[in] SchCellCb *cell, Cell cb struc pointer + * @param[in] SchUlHqProcCb* msg3HqProc, msg3 harq proc pointer + * @param[in] uint16_t dlTime, DL time of scheduling + * @param[in] SlotTimingInfo *msg3Time, MSG3 timing info + * @param[in] bool isRetx, indicates MSG3 retransmission + * @return + * -# true + * -# false + **/ +bool schGetMsg3K2(SchCellCb *cell, SchUlHqProcCb* msg3HqProc, uint16_t dlTime, SlotTimingInfo *msg3Time, bool isRetx) +{ + bool k2Found = false; + uint8_t k2TblIdx = 0; + uint8_t k2Index = 0; + uint8_t k2 = 0; + uint8_t numK2 = 0; + uint8_t puschMu = 0; + uint8_t msg3Delta = 0, msg3MinSchTime = 0; +#ifdef NR_TDD + uint8_t totalCfgSlot = 0; +#endif + SchK2TimingInfoTbl *msg3K2InfoTbl=NULLP; + SlotTimingInfo currTime, msg3TempTime; + currTime = cell->slotInfo; + puschMu = cell->cellCfg.numerology; + + if (isRetx) + { + if(!msg3HqProc) + return false; + + numK2 = cell->k2InfoTbl.k2TimingInfo[dlTime].numK2; + msg3K2InfoTbl = &cell->msg3K2InfoTbl; + msg3MinSchTime = 0; + msg3Delta = 0; + } + else + { + numK2 = cell->msg3K2InfoTbl.k2TimingInfo[dlTime].numK2; + msg3K2InfoTbl = &cell->k2InfoTbl; + msg3MinSchTime = minMsg3SchTime[cell->cellCfg.numerology]; + msg3Delta = puschDeltaTable[puschMu]; + } + + for(k2TblIdx = 0; k2TblIdx < numK2; k2TblIdx++) + { + k2Index = msg3K2InfoTbl->k2TimingInfo[dlTime].k2Indexes[k2TblIdx]; + + k2 = cell->cellCfg.ulCfgCommon.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[k2Index].k2; + if (isRetx) + { + if ((msg3HqProc->strtSymbl != cell->cellCfg.ulCfgCommon.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[k2Index].startSymbol) || + (msg3HqProc->numSymbl != cell->cellCfg.ulCfgCommon.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[k2Index].symbolLength)) + { + continue; + } + } + /* Delta is added to the slot allocation for msg3 based on 38.214 section 6.1.2.1 */ + k2 = k2 + msg3Delta; + if(k2 >= msg3MinSchTime) + { + ADD_DELTA_TO_TIME(currTime, msg3TempTime, k2, cell->numSlots); +#ifdef NR_TDD + if(schGetSlotSymbFrmt(msg3TempTime.slot % totalCfgSlot, cell->slotFrmtBitMap) == DL_SLOT) + continue; +#endif + /* If PUSCH is already scheduled on this slot, another PUSCH + * pdu cannot be scheduled here */ + if(cell->schUlSlotInfo[msg3TempTime.slot]->puschUe != 0) + continue; + k2Found = true; + break; + } + } + if (k2Found == true) + { + msg3Time->slot = msg3TempTime.slot; + msg3Time->sfn = msg3TempTime.sfn; + msg3Time->slot = msg3TempTime.slot; + } + return k2Found; +} + /********************************************************************** End of file **********************************************************************/