From 9aed9ab1046cd7786f705238e05e8491954717a9 Mon Sep 17 00:00:00 2001 From: svaidhya Date: Thu, 29 Feb 2024 15:11:57 +0530 Subject: [PATCH] [Epic-ID: ODUHIGH-556][Task-ID: ODUHIGH-570] UL Candidate Sel and Res Alloc for Multi UE Change-Id: Icdb9998e7a3d5531cf7a578b1cb5b42e8bcc90e6 Signed-off-by: svaidhya --- src/5gnrmac/lwr_mac_fsm.c | 235 +++++++++++++++++++++++------------------- src/5gnrmac/mac.h | 2 +- src/5gnrmac/mac_rach.c | 2 +- src/5gnrsch/sch.c | 11 ++ src/5gnrsch/sch.h | 15 ++- src/5gnrsch/sch_common.c | 80 +++++++------- src/5gnrsch/sch_crc.c | 4 +- src/5gnrsch/sch_fcfs.c | 22 ++-- src/5gnrsch/sch_rach.c | 88 ++++++++-------- src/5gnrsch/sch_slice_based.c | 7 +- src/5gnrsch/sch_slot_ind.c | 12 +-- src/5gnrsch/sch_ue_mgr.c | 10 +- src/5gnrsch/sch_utils.c | 9 +- src/cm/mac_sch_interface.h | 10 +- 14 files changed, 280 insertions(+), 227 deletions(-) diff --git a/src/5gnrmac/lwr_mac_fsm.c b/src/5gnrmac/lwr_mac_fsm.c index 859144334..6b84d58a5 100644 --- a/src/5gnrmac/lwr_mac_fsm.c +++ b/src/5gnrmac/lwr_mac_fsm.c @@ -4201,33 +4201,42 @@ uint16_t sendTxDataReq(SlotTimingInfo currTimingInfo, MacDlSlot *dlSlot, p_fapi_ #ifdef INTEL_FAPI uint8_t getnPdus(fapi_ul_tti_req_t *ulTtiReq, MacUlSlot *currUlSlot) { - uint8_t pduCount = 0; + uint8_t pduCount = 0, ueIdx = 0; if(ulTtiReq && currUlSlot) { - if(currUlSlot->ulInfo.dataType & SCH_DATATYPE_PRACH) + if(currUlSlot->ulSchInfo.dataType & SCH_DATATYPE_PRACH) { - pduCount++; - ulTtiReq->rachPresent++; + pduCount++; } - if(currUlSlot->ulInfo.dataType & SCH_DATATYPE_PUSCH) - { - pduCount++; - ulTtiReq->nUlsch++; - } - if(currUlSlot->ulInfo.dataType & SCH_DATATYPE_PUSCH_UCI) - { - pduCount++; - ulTtiReq->nUlsch++; - } - if(currUlSlot->ulInfo.dataType & SCH_DATATYPE_UCI) + + for(ueIdx = 0; ueIdx < MAX_NUM_UE; ueIdx++) { - pduCount++; - ulTtiReq->nUlcch++; + if(currUlSlot->ulSchInfo.dataType & SCH_DATATYPE_PUSCH) + { + if(currUlSlot->ulSchInfo.schPuschInfo[ueIdx].crnti != 0) + { + pduCount++; + } + } + if(currUlSlot->ulSchInfo.dataType & SCH_DATATYPE_PUSCH_UCI) + { + if(currUlSlot->ulSchInfo.schPuschUci[ueIdx].crnti != 0) + { + pduCount++; + } + } + if(currUlSlot->ulSchInfo.dataType & SCH_DATATYPE_UCI) + { + if(currUlSlot->ulSchInfo.schPucchInfo[ueIdx].crnti != 0) + { + pduCount++; + } + } } - if(currUlSlot->ulInfo.dataType & SCH_DATATYPE_SRS) + if(currUlSlot->ulSchInfo.dataType & SCH_DATATYPE_SRS) { - pduCount++; + pduCount++; } } return pduCount; @@ -4286,12 +4295,12 @@ void fillPrachPdu(fapi_ul_tti_req_pdu_t *ulTtiReqPdu, MacCellCfg *macCellCfg, Ma ulTtiReqPdu->pduType = PRACH_PDU_TYPE; ulTtiReqPdu->pdu.prach_pdu.physCellId = macCellCfg->cellCfg.phyCellId; ulTtiReqPdu->pdu.prach_pdu.numPrachOcas = \ - currUlSlot->ulInfo.prachSchInfo.numPrachOcas; + currUlSlot->ulSchInfo.prachSchInfo.numPrachOcas; ulTtiReqPdu->pdu.prach_pdu.prachFormat = \ - currUlSlot->ulInfo.prachSchInfo.prachFormat; - ulTtiReqPdu->pdu.prach_pdu.numRa = currUlSlot->ulInfo.prachSchInfo.numRa; + currUlSlot->ulSchInfo.prachSchInfo.prachFormat; + ulTtiReqPdu->pdu.prach_pdu.numRa = currUlSlot->ulSchInfo.prachSchInfo.numRa; ulTtiReqPdu->pdu.prach_pdu.prachStartSymbol = \ - currUlSlot->ulInfo.prachSchInfo.prachStartSymb; + currUlSlot->ulSchInfo.prachSchInfo.prachStartSymb; setNumCs(&ulTtiReqPdu->pdu.prach_pdu.numCs, macCellCfg); ulTtiReqPdu->pdu.prach_pdu.beamforming.numPrgs = 0; ulTtiReqPdu->pdu.prach_pdu.beamforming.prgSize = 0; @@ -4316,14 +4325,15 @@ void fillPrachPdu(fapi_ul_tti_req_pdu_t *ulTtiReqPdu, MacCellCfg *macCellCfg, Ma * RFAILED - failure * * ****************************************************************/ -void fillPuschPdu(fapi_ul_tti_req_pdu_t *ulTtiReqPdu, fapi_vendor_ul_tti_req_pdu_t *ulTtiVendorPdu, MacCellCfg *macCellCfg, MacUlSlot *currUlSlot) +void fillPuschPdu(fapi_ul_tti_req_pdu_t *ulTtiReqPdu, fapi_vendor_ul_tti_req_pdu_t *ulTtiVendorPdu, MacCellCfg *macCellCfg,\ + SchPuschInfo *puschInfo) { if(ulTtiReqPdu != NULLP) { ulTtiReqPdu->pduType = PUSCH_PDU_TYPE; memset(&ulTtiReqPdu->pdu.pusch_pdu, 0, sizeof(fapi_ul_pusch_pdu_t)); ulTtiReqPdu->pdu.pusch_pdu.pduBitMap = 1; - ulTtiReqPdu->pdu.pusch_pdu.rnti = currUlSlot->ulInfo.crnti; + ulTtiReqPdu->pdu.pusch_pdu.rnti = puschInfo->crnti; /* TODO : Fill handle in raCb when scheduling pusch and access here */ ulTtiReqPdu->pdu.pusch_pdu.handle = 100; ulTtiReqPdu->pdu.pusch_pdu.bwpSize = macCellCfg->cellCfg.initialUlBwp.bwp.numPrb; @@ -4333,48 +4343,48 @@ void fillPuschPdu(fapi_ul_tti_req_pdu_t *ulTtiReqPdu, fapi_vendor_ul_tti_req_pdu ulTtiReqPdu->pdu.pusch_pdu.cyclicPrefix = \ macCellCfg->cellCfg.initialUlBwp.bwp.cyclicPrefix; ulTtiReqPdu->pdu.pusch_pdu.targetCodeRate = 308; - ulTtiReqPdu->pdu.pusch_pdu.qamModOrder = currUlSlot->ulInfo.schPuschInfo.tbInfo.qamOrder; - ulTtiReqPdu->pdu.pusch_pdu.mcsIndex = currUlSlot->ulInfo.schPuschInfo.tbInfo.mcs; - ulTtiReqPdu->pdu.pusch_pdu.mcsTable = currUlSlot->ulInfo.schPuschInfo.tbInfo.mcsTable; + ulTtiReqPdu->pdu.pusch_pdu.qamModOrder = puschInfo->tbInfo.qamOrder; + ulTtiReqPdu->pdu.pusch_pdu.mcsIndex = puschInfo->tbInfo.mcs; + ulTtiReqPdu->pdu.pusch_pdu.mcsTable = puschInfo->tbInfo.mcsTable; ulTtiReqPdu->pdu.pusch_pdu.transformPrecoding = 1; - ulTtiReqPdu->pdu.pusch_pdu.dataScramblingId = currUlSlot->ulInfo.cellId; + ulTtiReqPdu->pdu.pusch_pdu.dataScramblingId = macCellCfg->cellId; ulTtiReqPdu->pdu.pusch_pdu.nrOfLayers = 1; ulTtiReqPdu->pdu.pusch_pdu.ulDmrsSymbPos = 4; ulTtiReqPdu->pdu.pusch_pdu.dmrsConfigType = 0; - ulTtiReqPdu->pdu.pusch_pdu.ulDmrsScramblingId = currUlSlot->ulInfo.cellId; + ulTtiReqPdu->pdu.pusch_pdu.ulDmrsScramblingId = macCellCfg->cellId; ulTtiReqPdu->pdu.pusch_pdu.scid = 0; ulTtiReqPdu->pdu.pusch_pdu.numDmrsCdmGrpsNoData = 1; ulTtiReqPdu->pdu.pusch_pdu.dmrsPorts = 0; ulTtiReqPdu->pdu.pusch_pdu.resourceAlloc = \ - currUlSlot->ulInfo.schPuschInfo.fdAlloc.resAllocType; + puschInfo->fdAlloc.resAllocType; ulTtiReqPdu->pdu.pusch_pdu.rbStart = \ - currUlSlot->ulInfo.schPuschInfo.fdAlloc.resAlloc.type1.startPrb; + puschInfo->fdAlloc.resAlloc.type1.startPrb; ulTtiReqPdu->pdu.pusch_pdu.rbSize = \ - currUlSlot->ulInfo.schPuschInfo.fdAlloc.resAlloc.type1.numPrb; + puschInfo->fdAlloc.resAlloc.type1.numPrb; ulTtiReqPdu->pdu.pusch_pdu.vrbToPrbMapping = 0; ulTtiReqPdu->pdu.pusch_pdu.frequencyHopping = 0; ulTtiReqPdu->pdu.pusch_pdu.txDirectCurrentLocation = 0; ulTtiReqPdu->pdu.pusch_pdu.uplinkFrequencyShift7p5khz = 0; ulTtiReqPdu->pdu.pusch_pdu.startSymbIndex = \ - currUlSlot->ulInfo.schPuschInfo.tdAlloc.startSymb; + puschInfo->tdAlloc.startSymb; ulTtiReqPdu->pdu.pusch_pdu.nrOfSymbols = \ - currUlSlot->ulInfo.schPuschInfo.tdAlloc.numSymb; + puschInfo->tdAlloc.numSymb; #ifdef INTEL_FAPI ulTtiReqPdu->pdu.pusch_pdu.mappingType = \ - currUlSlot->ulInfo.schPuschInfo.dmrsMappingType; + puschInfo->dmrsMappingType; ulTtiReqPdu->pdu.pusch_pdu.nrOfDmrsSymbols = \ - currUlSlot->ulInfo.schPuschInfo.nrOfDmrsSymbols; + puschInfo->nrOfDmrsSymbols; ulTtiReqPdu->pdu.pusch_pdu.dmrsAddPos = \ - currUlSlot->ulInfo.schPuschInfo.dmrsAddPos; + puschInfo->dmrsAddPos; #endif ulTtiReqPdu->pdu.pusch_pdu.puschData.rvIndex = \ - currUlSlot->ulInfo.schPuschInfo.tbInfo.rv; + puschInfo->tbInfo.rv; ulTtiReqPdu->pdu.pusch_pdu.puschData.harqProcessId = \ - currUlSlot->ulInfo.schPuschInfo.harqProcId; + puschInfo->harqProcId; ulTtiReqPdu->pdu.pusch_pdu.puschData.newDataIndicator = \ - currUlSlot->ulInfo.schPuschInfo.tbInfo.ndi; + puschInfo->tbInfo.ndi; ulTtiReqPdu->pdu.pusch_pdu.puschData.tbSize = \ - currUlSlot->ulInfo.schPuschInfo.tbInfo.tbSize; + puschInfo->tbInfo.tbSize; /* numCb is 0 for new transmission */ ulTtiReqPdu->pdu.pusch_pdu.puschData.numCb = 0; @@ -4407,50 +4417,50 @@ void fillPuschPdu(fapi_ul_tti_req_pdu_t *ulTtiReqPdu, fapi_vendor_ul_tti_req_pdu * * ****************************************************************/ void fillPucchPdu(fapi_ul_tti_req_pdu_t *ulTtiReqPdu, fapi_vendor_ul_tti_req_pdu_t *ulTtiVendorPdu, MacCellCfg *macCellCfg,\ - MacUlSlot *currUlSlot) + SchPucchInfo *pucchInfo) { if(ulTtiReqPdu != NULLP) { ulTtiReqPdu->pduType = PUCCH_PDU_TYPE; memset(&ulTtiReqPdu->pdu.pucch_pdu, 0, sizeof(fapi_ul_pucch_pdu_t)); - ulTtiReqPdu->pdu.pucch_pdu.rnti = currUlSlot->ulInfo.crnti; + ulTtiReqPdu->pdu.pucch_pdu.rnti = pucchInfo->crnti; /* TODO : Fill handle in raCb when scheduling pucch and access here */ ulTtiReqPdu->pdu.pucch_pdu.handle = 100; ulTtiReqPdu->pdu.pucch_pdu.bwpSize = macCellCfg->cellCfg.initialUlBwp.bwp.numPrb; ulTtiReqPdu->pdu.pucch_pdu.bwpStart = macCellCfg->cellCfg.initialUlBwp.bwp.firstPrb; ulTtiReqPdu->pdu.pucch_pdu.subCarrierSpacing = macCellCfg->cellCfg.initialUlBwp.bwp.scs; ulTtiReqPdu->pdu.pucch_pdu.cyclicPrefix = macCellCfg->cellCfg.initialUlBwp.bwp.cyclicPrefix; - ulTtiReqPdu->pdu.pucch_pdu.formatType = currUlSlot->ulInfo.schPucchInfo.pucchFormat; /* Supporting PUCCH Format 0 */ + ulTtiReqPdu->pdu.pucch_pdu.formatType = pucchInfo->pucchFormat; /* Supporting PUCCH Format 0 */ ulTtiReqPdu->pdu.pucch_pdu.multiSlotTxIndicator = 0; /* No Multi Slot transmission */ - ulTtiReqPdu->pdu.pucch_pdu.prbStart = currUlSlot->ulInfo.schPucchInfo.fdAlloc.startPrb; - ulTtiReqPdu->pdu.pucch_pdu.prbSize = currUlSlot->ulInfo.schPucchInfo.fdAlloc.numPrb; - ulTtiReqPdu->pdu.pucch_pdu.startSymbolIndex = currUlSlot->ulInfo.schPucchInfo.tdAlloc.startSymb; - ulTtiReqPdu->pdu.pucch_pdu.nrOfSymbols = currUlSlot->ulInfo.schPucchInfo.tdAlloc.numSymb; - ulTtiReqPdu->pdu.pucch_pdu.freqHopFlag = currUlSlot->ulInfo.schPucchInfo.intraFreqHop; - ulTtiReqPdu->pdu.pucch_pdu.secondHopPrb = currUlSlot->ulInfo.schPucchInfo.secondPrbHop; + ulTtiReqPdu->pdu.pucch_pdu.prbStart = pucchInfo->fdAlloc.startPrb; + ulTtiReqPdu->pdu.pucch_pdu.prbSize = pucchInfo->fdAlloc.numPrb; + ulTtiReqPdu->pdu.pucch_pdu.startSymbolIndex = pucchInfo->tdAlloc.startSymb; + ulTtiReqPdu->pdu.pucch_pdu.nrOfSymbols = pucchInfo->tdAlloc.numSymb; + ulTtiReqPdu->pdu.pucch_pdu.freqHopFlag = pucchInfo->intraFreqHop; + ulTtiReqPdu->pdu.pucch_pdu.secondHopPrb = pucchInfo->secondPrbHop; ulTtiReqPdu->pdu.pucch_pdu.groupHopFlag = 0; ulTtiReqPdu->pdu.pucch_pdu.sequenceHopFlag = 0; ulTtiReqPdu->pdu.pucch_pdu.hoppingId = 0; - ulTtiReqPdu->pdu.pucch_pdu.initialCyclicShift = currUlSlot->ulInfo.schPucchInfo.initialCyclicShift; + ulTtiReqPdu->pdu.pucch_pdu.initialCyclicShift = pucchInfo->initialCyclicShift; ulTtiReqPdu->pdu.pucch_pdu.dataScramblingId = 0; /* Valid for Format 2, 3, 4 */ - ulTtiReqPdu->pdu.pucch_pdu.timeDomainOccIdx = currUlSlot->ulInfo.schPucchInfo.timeDomOCC; - ulTtiReqPdu->pdu.pucch_pdu.preDftOccIdx = currUlSlot->ulInfo.schPucchInfo.occIdx; /* Valid for Format 4 only */ - ulTtiReqPdu->pdu.pucch_pdu.preDftOccLen = currUlSlot->ulInfo.schPucchInfo.occLen; /* Valid for Format 4 only */ - ulTtiReqPdu->pdu.pucch_pdu.pi2Bpsk = currUlSlot->ulInfo.schPucchInfo.pi2BPSK; - ulTtiReqPdu->pdu.pucch_pdu.addDmrsFlag = currUlSlot->ulInfo.schPucchInfo.addDmrs;/* Valid for Format 3, 4 only */ + ulTtiReqPdu->pdu.pucch_pdu.timeDomainOccIdx = pucchInfo->timeDomOCC; + ulTtiReqPdu->pdu.pucch_pdu.preDftOccIdx = pucchInfo->occIdx; /* Valid for Format 4 only */ + ulTtiReqPdu->pdu.pucch_pdu.preDftOccLen = pucchInfo->occLen; /* Valid for Format 4 only */ + ulTtiReqPdu->pdu.pucch_pdu.pi2Bpsk = pucchInfo->pi2BPSK; + ulTtiReqPdu->pdu.pucch_pdu.addDmrsFlag = pucchInfo->addDmrs;/* Valid for Format 3, 4 only */ ulTtiReqPdu->pdu.pucch_pdu.dmrsScramblingId = 0; /* Valid for Format 2 */ ulTtiReqPdu->pdu.pucch_pdu.dmrsCyclicShift = 0; /* Valid for Format 4 */ - ulTtiReqPdu->pdu.pucch_pdu.srFlag = currUlSlot->ulInfo.schPucchInfo.srFlag; - ulTtiReqPdu->pdu.pucch_pdu.bitLenHarq = currUlSlot->ulInfo.schPucchInfo.harqInfo.harqBitLength; + ulTtiReqPdu->pdu.pucch_pdu.srFlag = pucchInfo->srFlag; + ulTtiReqPdu->pdu.pucch_pdu.bitLenHarq = pucchInfo->harqInfo.harqBitLength; ulTtiReqPdu->pdu.pucch_pdu.bitLenCsiPart1 = 0; /* Valid for Format 2, 3, 4 */ ulTtiReqPdu->pdu.pucch_pdu.bitLenCsiPart2 = 0; /* Valid for Format 2, 3, 4 */ - ulTtiReqPdu->pdu.pucch_pdu.beamforming.numPrgs = currUlSlot->ulInfo.schPucchInfo.beamPucchInfo.numPrgs; - ulTtiReqPdu->pdu.pucch_pdu.beamforming.prgSize = currUlSlot->ulInfo.schPucchInfo.beamPucchInfo.prgSize; - ulTtiReqPdu->pdu.pucch_pdu.beamforming.digBfInterface = currUlSlot->ulInfo.schPucchInfo.beamPucchInfo.digBfInterfaces; - ulTtiReqPdu->pdu.pucch_pdu.beamforming.rx_bfi[0].beamIdx[0].beamidx = currUlSlot->ulInfo.schPucchInfo.beamPucchInfo.prg[0].beamIdx[0]; + ulTtiReqPdu->pdu.pucch_pdu.beamforming.numPrgs = pucchInfo->beamPucchInfo.numPrgs; + ulTtiReqPdu->pdu.pucch_pdu.beamforming.prgSize = pucchInfo->beamPucchInfo.prgSize; + ulTtiReqPdu->pdu.pucch_pdu.beamforming.digBfInterface = pucchInfo->beamPucchInfo.digBfInterfaces; + ulTtiReqPdu->pdu.pucch_pdu.beamforming.rx_bfi[0].beamIdx[0].beamidx = pucchInfo->beamPucchInfo.prg[0].beamIdx[0]; ulTtiReqPdu->pduSize = sizeof(fapi_ul_pucch_pdu_t); @@ -4492,6 +4502,7 @@ uint16_t fillUlTtiReq(SlotTimingInfo currTimingInfo, p_fapi_api_queue_elem_t pre #ifdef INTEL_FAPI uint16_t cellIdx =0; uint8_t pduIdx = -1; + uint8_t ueIdx = 0; SlotTimingInfo ulTtiReqTimingInfo; MacUlSlot *currUlSlot = NULLP; MacCellCfg macCellCfg; @@ -4510,61 +4521,71 @@ uint16_t fillUlTtiReq(SlotTimingInfo currTimingInfo, p_fapi_api_queue_elem_t pre LWR_MAC_ALLOC(ulTtiElem, (sizeof(fapi_api_queue_elem_t) + sizeof(fapi_ul_tti_req_t))); if(ulTtiElem) { - FILL_FAPI_LIST_ELEM(ulTtiElem, NULLP, FAPI_UL_TTI_REQUEST, 1, \ - sizeof(fapi_ul_tti_req_t)); - ulTtiReq = (fapi_ul_tti_req_t *)(ulTtiElem +1); - memset(ulTtiReq, 0, sizeof(fapi_ul_tti_req_t)); - fillMsgHeader(&ulTtiReq->header, FAPI_UL_TTI_REQUEST, sizeof(fapi_ul_tti_req_t)); - ulTtiReq->sfn = ulTtiReqTimingInfo.sfn; - ulTtiReq->slot = ulTtiReqTimingInfo.slot; - ulTtiReq->nPdus = getnPdus(ulTtiReq, currUlSlot); - vendorUlTti->num_ul_pdu = ulTtiReq->nPdus; - vendorUlTti->sym = 0; - ulTtiReq->nGroup = 0; - if(ulTtiReq->nPdus > 0) - { - /* Fill Prach Pdu */ - if(currUlSlot->ulInfo.dataType & SCH_DATATYPE_PRACH) - { - pduIdx++; - fillPrachPdu(&ulTtiReq->pdus[pduIdx], &macCellCfg, currUlSlot); - ulTtiReq->rachPresent++; - } - - /* Fill PUSCH PDU */ - if(currUlSlot->ulInfo.dataType & SCH_DATATYPE_PUSCH) - { - pduIdx++; - fillPuschPdu(&ulTtiReq->pdus[pduIdx], &vendorUlTti->ul_pdus[pduIdx], &macCellCfg, currUlSlot); - ulTtiReq->nUlsch++; - } - /* Fill PUCCH PDU */ - if(currUlSlot->ulInfo.dataType & SCH_DATATYPE_UCI) - { - pduIdx++; - fillPucchPdu(&ulTtiReq->pdus[pduIdx], &vendorUlTti->ul_pdus[pduIdx], &macCellCfg, currUlSlot); - ulTtiReq->nUlcch++; - } - } + FILL_FAPI_LIST_ELEM(ulTtiElem, NULLP, FAPI_UL_TTI_REQUEST, 1, \ + sizeof(fapi_ul_tti_req_t)); + ulTtiReq = (fapi_ul_tti_req_t *)(ulTtiElem +1); + memset(ulTtiReq, 0, sizeof(fapi_ul_tti_req_t)); + fillMsgHeader(&ulTtiReq->header, FAPI_UL_TTI_REQUEST, sizeof(fapi_ul_tti_req_t)); + ulTtiReq->sfn = ulTtiReqTimingInfo.sfn; + ulTtiReq->slot = ulTtiReqTimingInfo.slot; + ulTtiReq->nPdus = getnPdus(ulTtiReq, currUlSlot); + vendorUlTti->num_ul_pdu = ulTtiReq->nPdus; + vendorUlTti->sym = 0; + ulTtiReq->nGroup = 0; + if(ulTtiReq->nPdus > 0) + { + /* Fill Prach Pdu */ + if(currUlSlot->ulSchInfo.dataType & SCH_DATATYPE_PRACH) + { + pduIdx++; + fillPrachPdu(&ulTtiReq->pdus[pduIdx], &macCellCfg, currUlSlot); + ulTtiReq->rachPresent++; + } + for(ueIdx = 0; ueIdx < MAX_NUM_UE; ueIdx++) + { + /* Fill PUSCH PDU */ + if(currUlSlot->ulSchInfo.dataType & SCH_DATATYPE_PUSCH) + { + if(currUlSlot->ulSchInfo.schPuschInfo[ueIdx].crnti != 0) + { + pduIdx++; + fillPuschPdu(&ulTtiReq->pdus[pduIdx], &vendorUlTti->ul_pdus[pduIdx], &macCellCfg, &currUlSlot->ulSchInfo.schPuschInfo[ueIdx]); + ulTtiReq->nUlsch++; + } + } + /* Fill PUCCH PDU */ + if(currUlSlot->ulSchInfo.dataType & SCH_DATATYPE_UCI) + { + if(currUlSlot->ulSchInfo.schPucchInfo[ueIdx].crnti != 0) + { + pduIdx++; + fillPucchPdu(&ulTtiReq->pdus[pduIdx], &vendorUlTti->ul_pdus[pduIdx], &macCellCfg, &currUlSlot->ulSchInfo.schPucchInfo[ueIdx]); + ulTtiReq->nUlcch++; + } + } + } + ulTtiReq->ueGrpInfo[ulTtiReq->nGroup].nUe = MAX_NUM_UE_PER_TTI; + ulTtiReq->nGroup++; + } #ifdef ODU_SLOT_IND_DEBUG_LOG - DU_LOG("\nDEBUG --> LWR_MAC: Sending UL TTI Request"); + DU_LOG("\nDEBUG --> LWR_MAC: Sending UL TTI Request"); #endif - prevElem->p_next = ulTtiElem; + prevElem->p_next = ulTtiElem; - memset(currUlSlot, 0, sizeof(MacUlSlot)); - return ROK; + memset(currUlSlot, 0, sizeof(MacUlSlot)); + return ROK; } else { - DU_LOG("\nERROR --> LWR_MAC: Failed to allocate memory for UL TTI Request"); - memset(currUlSlot, 0, sizeof(MacUlSlot)); - return RFAILED; + DU_LOG("\nERROR --> LWR_MAC: Failed to allocate memory for UL TTI Request"); + memset(currUlSlot, 0, sizeof(MacUlSlot)); + return RFAILED; } } else { - lwr_mac_procInvalidEvt(&currTimingInfo); + lwr_mac_procInvalidEvt(&currTimingInfo); } #endif return ROK; diff --git a/src/5gnrmac/mac.h b/src/5gnrmac/mac.h index 46b8a546c..aac995001 100644 --- a/src/5gnrmac/mac.h +++ b/src/5gnrmac/mac.h @@ -115,7 +115,7 @@ typedef struct macDlSlot typedef struct macUlSlot { - UlSchedInfo ulInfo; + UlSchedInfo ulSchInfo; }MacUlSlot; typedef struct macCbInfo diff --git a/src/5gnrmac/mac_rach.c b/src/5gnrmac/mac_rach.c index 5531917e3..c2196194e 100644 --- a/src/5gnrmac/mac_rach.c +++ b/src/5gnrmac/mac_rach.c @@ -475,7 +475,7 @@ uint8_t MacProcUlSchInfo(Pst *pst, UlSchedInfo *ulSchedInfo) { MacUlSlot *currUlSlot = &macCb.macCell[cellIdx]->ulSlot[ulSchedInfo->slotIndInfo.slot % macCb.macCell[cellIdx]->numOfSlots]; - memcpy(&currUlSlot->ulInfo, ulSchedInfo, sizeof(UlSchedInfo)); + memcpy(&currUlSlot->ulSchInfo, ulSchedInfo, sizeof(UlSchedInfo)); } return ROK; } diff --git a/src/5gnrsch/sch.c b/src/5gnrsch/sch.c index 8279bf6c6..e2b86d134 100644 --- a/src/5gnrsch/sch.c +++ b/src/5gnrsch/sch.c @@ -886,6 +886,7 @@ uint8_t SchSendCellDeleteRspToMac(SchCellDeleteReq *ueDelete, Inst inst, SchMac void deleteSchCellCb(SchCellCb *cellCb) { uint8_t sliceIdx=0, slotIdx=0, plmnIdx = 0; + uint8_t ueIdx = 0; CmLListCp *list=NULL; CmLList *node=NULL, *next=NULL; SchPageInfo *tempNode = NULLP; @@ -903,6 +904,12 @@ void deleteSchCellCb(SchCellCb *cellCb) deleteNodeFromLList(list, node); node = next; } + for(ueIdx = 0; ueIdx< MAX_NUM_UE; ueIdx++) + { + SCH_FREE(cellCb->schDlSlotInfo[slotIdx]->rarAlloc[ueIdx], sizeof(RarAlloc)); + SCH_FREE(cellCb->schDlSlotInfo[slotIdx]->dlMsgAlloc[ueIdx], sizeof(DlMsgSchInfo)); + } + SCH_FREE(cellCb->schDlSlotInfo[slotIdx]->ulGrant, sizeof(DciInfo)); SCH_FREE(cellCb->schDlSlotInfo[slotIdx], sizeof(SchDlSlotInfo)); } SCH_FREE(cellCb->schDlSlotInfo, cellCb->numSlots *sizeof(SchDlSlotInfo*)); @@ -921,6 +928,10 @@ void deleteSchCellCb(SchCellCb *cellCb) deleteNodeFromLList(list, node); node = next; } + for(ueIdx = 0; ueIdx< MAX_NUM_UE; ueIdx++) + { + SCH_FREE(cellCb->schUlSlotInfo[slotIdx]->schPuschInfo[ueIdx], sizeof(SchPuschInfo)); + } SCH_FREE(cellCb->schUlSlotInfo[slotIdx], sizeof(SchUlSlotInfo)); } SCH_FREE(cellCb->schUlSlotInfo, cellCb->numSlots * sizeof(SchUlSlotInfo*)); diff --git a/src/5gnrsch/sch.h b/src/5gnrsch/sch.h index b38c606b8..81fbc042b 100644 --- a/src/5gnrsch/sch.h +++ b/src/5gnrsch/sch.h @@ -362,13 +362,10 @@ typedef struct schRaCb typedef struct schUlSlotInfo { SchPrbAlloc prbAlloc; /*!< PRB allocated/available per symbol */ - uint8_t puschCurrentPrb; /*!< Current PRB for PUSCH allocation */ - bool puschPres; /*!< PUSCH presence field */ - SchPuschInfo *schPuschInfo; /*!< PUSCH info */ - bool pucchPres; /*!< PUCCH presence field */ - SchPucchInfo schPucchInfo; /*!< PUCCH info */ - uint8_t pucchUe; /*!< Store UE id for which PUCCH is scheduled */ - uint8_t puschUe; /*!< Store UE id for which PUSCH is scheduled */ + bool puschPres; + SchPuschInfo *schPuschInfo[MAX_NUM_UE]; /*!< PUSCH info */ + bool pucchPres; + SchPucchInfo schPucchInfo[MAX_NUM_UE]; /*!< PUCCH info */ }SchUlSlotInfo; /** @@ -798,7 +795,7 @@ uint8_t schUlResAlloc(SchCellCb *cell, Inst schInst); bool schCheckPrachOcc(SchCellCb *cell, SlotTimingInfo prachOccasionTimingInfo); uint8_t schCalcPrachNumRb(SchCellCb *cell); void schPrachResAlloc(SchCellCb *cell, UlSchedInfo *ulSchedInfo, SlotTimingInfo prachOccasionTimingInfo); -uint8_t schAllocPucchResource(SchCellCb *cell, SlotTimingInfo pucchTime, SchUeCb *ueCb, SchDlHqProcCb *hqP, SchPdcchAllocInfo *pdcchAllocInfo); +uint8_t schAllocPucchResource(SchCellCb *cell, uint8_t ueId, SlotTimingInfo pucchTime, SchUeCb *ueCb, SchDlHqProcCb *hqP, SchPdcchAllocInfo *pdcchAllocInfo); uint8_t schFillUlDci(SchUeCb *ueCb, SchPuschInfo *puschInfo, DciInfo *dciInfo, bool isRetx, SchUlHqProcCb *hqP); uint8_t schFillPuschAlloc(SchUeCb *ueCb, SlotTimingInfo puschTime, uint32_t tbSize, uint8_t startSymb, uint8_t symbLen, uint16_t startPrb, bool isRetx, SchUlHqProcCb *hqP); @@ -844,7 +841,7 @@ void schUpdateHarqFdbk(SchUeCb *ueCb, uint8_t numHarq, uint8_t *harqPayload,Slot /* Round Robbin Scheduler funtions*/ uint8_t schFillUlDciForMsg3Retx(SchRaCb *raCb, SchPuschInfo *puschInfo, DciInfo *dciInfo); -bool schGetMsg3K2(SchCellCb *cell, SchUlHqProcCb* msg3HqProc, uint16_t dlTime, SlotTimingInfo *msg3Time, bool isRetx); +bool schGetMsg3K2(SchCellCb *cell, uint8_t ueId, SchUlHqProcCb* msg3HqProc, uint16_t dlTime, SlotTimingInfo *msg3Time, bool isRetx); void schMsg4Complete(SchUeCb *ueCb); /* Statistics Function */ diff --git a/src/5gnrsch/sch_common.c b/src/5gnrsch/sch_common.c index 51673306c..8f1105a15 100644 --- a/src/5gnrsch/sch_common.c +++ b/src/5gnrsch/sch_common.c @@ -488,6 +488,7 @@ uint16_t fillPucchResourceInfo(SchCellCb *cell, uint8_t ueId, SchPucchInfo *schP else { DU_LOG("\nERROR --> SCH: Invalid value of r_pucch:%d (greater than 15) ", r_pucch); + memset(schPucchInfo, 0, sizeof(SchPucchInfo)); return ret; } ret = allocatePrbUl(cell, slotInfo, pucchResourceSet[pucchIdx][1], pucchResourceSet[pucchIdx][2],\ @@ -522,9 +523,7 @@ uint16_t fillPucchResourceInfo(SchCellCb *cell, uint8_t ueId, SchPucchInfo *schP uint8_t schUlResAlloc(SchCellCb *cell, Inst schInst) { int ret = ROK; -#ifdef NR_DRX - SchUeCb *ueCb; -#endif + uint8_t ueIdx = 0; UlSchedInfo ulSchedInfo; SchUlSlotInfo *schUlSlotInfo = NULLP; SlotTimingInfo ulTimingInfo; @@ -546,39 +545,38 @@ uint8_t schUlResAlloc(SchCellCb *cell, Inst schInst) schPrachResAlloc(cell, &ulSchedInfo, ulTimingInfo); schUlSlotInfo = cell->schUlSlotInfo[ulTimingInfo.slot]; - if(schUlSlotInfo->schPuschInfo) + if(schUlSlotInfo->puschPres) { - 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); - if(ueCb->ueDrxInfoPres) + ulSchedInfo.dataType |= SCH_DATATYPE_PUSCH; + for(ueIdx = 0; ueIdx < MAX_NUM_UE; ueIdx++) { - if(!ueCb->drxUeCb.drxUlUeActiveStatus) - return RFAILED; + if(schUlSlotInfo->schPuschInfo[ueIdx] != NULLP) + { + memcpy(&ulSchedInfo.schPuschInfo[ueIdx], schUlSlotInfo->schPuschInfo[ueIdx], + sizeof(SchPuschInfo)); + SCH_FREE(schUlSlotInfo->schPuschInfo[ueIdx], sizeof(SchPuschInfo)); + schUlSlotInfo->schPuschInfo[ueIdx] = NULL; + } } -#endif - ulSchedInfo.dataType |= SCH_DATATYPE_PUSCH; - memcpy(&ulSchedInfo.schPuschInfo, schUlSlotInfo->schPuschInfo, - sizeof(SchPuschInfo)); - SCH_FREE(schUlSlotInfo->schPuschInfo, sizeof(SchPuschInfo)); - schUlSlotInfo->schPuschInfo = NULL; } if(schUlSlotInfo->pucchPres) { - GET_CRNTI(ulSchedInfo.crnti, schUlSlotInfo->pucchUe); ulSchedInfo.dataType |= SCH_DATATYPE_UCI; memcpy(&ulSchedInfo.schPucchInfo, &schUlSlotInfo->schPucchInfo, - sizeof(SchPucchInfo)); - memset(&schUlSlotInfo->schPucchInfo, 0, sizeof(SchPucchInfo)); + (sizeof(SchPucchInfo) * MAX_NUM_UE)); + memset(&schUlSlotInfo->schPucchInfo, 0, (sizeof(SchPucchInfo) * MAX_NUM_UE)); } - /* Send msg to MAC */ - ret = sendUlSchInfoToMac(&ulSchedInfo, schInst); - if(ret != ROK) + if(ulSchedInfo.dataType > 0) { - DU_LOG("\nERROR --> SCH : Sending UL Sch info from SCH to MAC failed"); + /* Send msg to MAC */ + ret = sendUlSchInfoToMac(&ulSchedInfo, schInst); + if(ret != ROK) + { + DU_LOG("\nERROR --> SCH : Sending UL Sch info from SCH to MAC failed"); + } } /* Update DL PRB Usage for all stats group which requested for DL Total PRB Usage */ @@ -808,7 +806,7 @@ uint8_t schDlRsrcAllocMsg4(SchCellCb *cell, SlotTimingInfo msg4Time, uint8_t ueI * *******************************************************************/ -uint8_t schAllocPucchResource(SchCellCb *cell, SlotTimingInfo pucchTime, SchUeCb *ueCb,\ +uint8_t schAllocPucchResource(SchCellCb *cell, uint8_t ueId, SlotTimingInfo pucchTime, SchUeCb *ueCb,\ SchDlHqProcCb *hqP, SchPdcchAllocInfo *pdcchAllocInfo) { uint8_t ret = RFAILED; @@ -817,21 +815,19 @@ uint8_t schAllocPucchResource(SchCellCb *cell, SlotTimingInfo pucchTime, SchUeCb pucchSlot = pucchTime.slot; schUlSlotInfo = cell->schUlSlotInfo[pucchSlot]; - memset(&schUlSlotInfo->schPucchInfo, 0, sizeof(SchPucchInfo)); - ret = fillPucchResourceInfo(cell, schUlSlotInfo->pucchUe, &schUlSlotInfo->schPucchInfo,\ + ret = fillPucchResourceInfo(cell, ueId, &schUlSlotInfo->schPucchInfo[ueId - 1],\ pucchTime, pdcchAllocInfo); if(ret != ROK) { return ret; } - - schUlSlotInfo->pucchPres = true; + schUlSlotInfo->pucchPres = true; if(ueCb != NULLP) { /* set HARQ flag to true */ - schUlSlotInfo->schPucchInfo.harqInfo.harqBitLength = 1; /* 1 bit for HARQ */ + schUlSlotInfo->schPucchInfo[ueId - 1].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->dlSlotLnk); } @@ -1960,7 +1956,6 @@ uint8_t schProcessMsg4Req(SchCellCb *cell, SlotTimingInfo currTime, uint8_t ueId } cell->schDlSlotInfo[pdcchTime.slot]->pdcchUe = ueId; - cell->schUlSlotInfo[pucchTime.slot]->pucchUe = ueId; cell->raCb[ueId-1].msg4recvd = FALSE; if(isRetxMsg4) @@ -2114,7 +2109,8 @@ bool schProcessSrOrBsrReq(SchCellCb *cell, SlotTimingInfo currTime, uint8_t ueId if(schGetSlotSymbFrmt(puschTime.slot, cell->slotFrmtBitMap) == DL_SLOT) continue; #endif - if(cell->schUlSlotInfo[puschTime.slot]->puschUe != 0) + if((cell->schUlSlotInfo[puschTime.slot]->schPuschInfo[ueId - 1] != NULLP) + && cell->schUlSlotInfo[puschTime.slot]->schPuschInfo[ueId - 1]->crnti == ueCb->crnti) { continue; } @@ -2134,7 +2130,7 @@ bool schProcessSrOrBsrReq(SchCellCb *cell, SlotTimingInfo currTime, uint8_t ueId } else { - DU_LOG("\nDEBUG --> SCH : schProcessSrOrBsrReq(): K2 value is not found"); + /* K2 value not found*/ return false; } return true; @@ -2274,7 +2270,7 @@ uint8_t schMsg3RetxSchedulingForUe(SchRaCb *raCb) if(cell->schDlSlotInfo[dciSlot]->pdcchUe != 0) return false; - k2Found = schGetMsg3K2(cell, &raCb->msg3HqProc, dciTime.slot, &msg3Time, TRUE); + k2Found = schGetMsg3K2(cell, raCb->ueId, &raCb->msg3HqProc, dciTime.slot, &msg3Time, TRUE); if (!k2Found) { @@ -2287,9 +2283,10 @@ uint8_t schMsg3RetxSchedulingForUe(SchRaCb *raCb) return RFAILED; } cell->schDlSlotInfo[msg3Time.slot]->ulGrant = dciInfo; - SCH_ALLOC(cell->schUlSlotInfo[msg3Time.slot]->schPuschInfo, sizeof(SchPuschInfo)); + SCH_ALLOC(cell->schUlSlotInfo[msg3Time.slot]->schPuschInfo[raCb->ueId - 1], sizeof(SchPuschInfo)); + cell->schUlSlotInfo[msg3Time.slot]->puschPres = true; memset(dciInfo,0,sizeof(DciInfo)); - schFillUlDciForMsg3Retx(raCb, cell->schUlSlotInfo[msg3Time.slot]->schPuschInfo, dciInfo); + schFillUlDciForMsg3Retx(raCb, cell->schUlSlotInfo[msg3Time.slot]->schPuschInfo[raCb->ueId - 1], dciInfo); } raCb->retxMsg3HqProc = NULLP; return ROK; @@ -2313,7 +2310,7 @@ uint8_t schMsg3RetxSchedulingForUe(SchRaCb *raCb) * -# true * -# false **/ -bool schGetMsg3K2(SchCellCb *cell, SchUlHqProcCb* msg3HqProc, uint16_t dlTime, SlotTimingInfo *msg3Time, bool isRetx) +bool schGetMsg3K2(SchCellCb *cell, uint8_t ueId, SchUlHqProcCb* msg3HqProc, uint16_t dlTime, SlotTimingInfo *msg3Time, bool isRetx) { bool k2Found = false; uint8_t k2TblIdx = 0; @@ -2325,6 +2322,7 @@ bool schGetMsg3K2(SchCellCb *cell, SchUlHqProcCb* msg3HqProc, uint16_t dlTime, S #ifdef NR_TDD uint8_t totalCfgSlot = 0; #endif + uint16_t crnti = 0; SchK2TimingInfoTbl *msg3K2InfoTbl=NULLP; SlotTimingInfo currTime, msg3TempTime; currTime = cell->slotInfo; @@ -2347,7 +2345,8 @@ bool schGetMsg3K2(SchCellCb *cell, SchUlHqProcCb* msg3HqProc, uint16_t dlTime, S msg3MinSchTime = minMsg3SchTime[cell->numerology]; msg3Delta = puschDeltaTable[puschMu]; } - + + GET_UE_ID(crnti, ueId); for(k2TblIdx = 0; k2TblIdx < numK2; k2TblIdx++) { k2Index = msg3K2InfoTbl->k2TimingInfo[dlTime].k2Indexes[k2TblIdx]; @@ -2370,9 +2369,10 @@ bool schGetMsg3K2(SchCellCb *cell, SchUlHqProcCb* msg3HqProc, uint16_t dlTime, S 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) + /* If PUSCH is already scheduled on this slot for this UE, another PUSCH + * pdu cannot be scheduled here for same UE*/ + if((cell->schUlSlotInfo[msg3TempTime.slot]->schPuschInfo[ueId - 1] != NULLP) + && cell->schUlSlotInfo[msg3TempTime.slot]->schPuschInfo[ueId - 1]->crnti == crnti) continue; k2Found = true; break; diff --git a/src/5gnrsch/sch_crc.c b/src/5gnrsch/sch_crc.c index 442d552b0..a49096dac 100644 --- a/src/5gnrsch/sch_crc.c +++ b/src/5gnrsch/sch_crc.c @@ -80,13 +80,13 @@ uint8_t SchProcCrcInd(Pst *pst, CrcIndInfo *crcInd) { if (cell->ueCb[ueId-1].hqUlmap[crcInd->timingInfo.slot]->hqList.count == 0) { - DU_LOG("\n ERROR no harq stored in ul hq map at slot %d ue id %d\n",crcInd->timingInfo.slot, ueId); crcCnt++; continue; } if (cell->ueCb[ueId-1].hqUlmap[crcInd->timingInfo.slot]->hqList.first == 0) { - DU_LOG("\n ERROR NULL harq stored in ul hq map at slot %d ue id %d\n",crcInd->timingInfo.slot, ueId); + DU_LOG("\nERROR --> SCH: NULL harq stored in ul hq map at slot %d ue id %d\n",\ + crcInd->timingInfo.slot, ueId); crcCnt++; continue; } diff --git a/src/5gnrsch/sch_fcfs.c b/src/5gnrsch/sch_fcfs.c index e949f3b10..6b043d45c 100644 --- a/src/5gnrsch/sch_fcfs.c +++ b/src/5gnrsch/sch_fcfs.c @@ -906,8 +906,8 @@ uint8_t schFcfsScheduleUlLc(SlotTimingInfo dciTime, SlotTimingInfo puschTime, ui uint8_t ret = RFAILED; uint16_t startPrb = 0; uint32_t totDataReq = 0; /* in bytes */ - SchUeCb *ueCb; - SchPuschInfo *puschInfo; + SchUeCb *ueCb = NULLP; + SchPuschInfo *puschInfo = NULLP; DciInfo *dciInfo = NULLP; cell = (*hqP)->hqEnt->cell; @@ -936,16 +936,15 @@ uint8_t schFcfsScheduleUlLc(SlotTimingInfo dciTime, SlotTimingInfo puschTime, ui /* Update PUSCH allocation */ if(schFillPuschAlloc(ueCb, puschTime, totDataReq, startSymb, symbLen, startPrb, isRetx, *hqP) == ROK) { - if(cell->schUlSlotInfo[puschTime.slot]->schPuschInfo) + if(cell->schUlSlotInfo[puschTime.slot]->schPuschInfo[ueCb->ueId]) { - puschInfo = cell->schUlSlotInfo[puschTime.slot]->schPuschInfo; + puschInfo = cell->schUlSlotInfo[puschTime.slot]->schPuschInfo[ueCb->ueId]; if(puschInfo != NULLP) { /* Fill DCI for UL grant */ schFillUlDci(ueCb, puschInfo, dciInfo, isRetx, *hqP); ueCb->srRcvd = false; ueCb->bsrRcvd = false; - cell->schUlSlotInfo[puschTime.slot]->puschUe = ueCb->ueId; if(fcfsHqProcCb->lcCb.dedLcList.count != 0) updateBsrAndLcList(&(fcfsHqProcCb->lcCb.dedLcList), ueCb->bsrInfo, ROK); updateBsrAndLcList(&(fcfsHqProcCb->lcCb.defLcList), ueCb->bsrInfo, ROK); @@ -1279,7 +1278,18 @@ void schFcfsScheduleSlot(SchCellCb *cell, SlotTimingInfo *slotInd, Inst schInst) } } } - + } +#ifdef NR_DRX + if((cell->ueCb[ueId-1].ueDrxInfoPres == true) && (cell->ueCb[ueId-1].drxUeCb.drxUlUeActiveStatus != true)) + { + if(pendingUeNode->node) + { + cmLListAdd2Tail(&fcfsCell->ueToBeScheduled, cmLListDelFrm(&fcfsCell->ueToBeScheduled, pendingUeNode)); + } + } + else +#endif + { /* Scheduling of UL grant */ node = NULLP; if(fcfsUeCb) diff --git a/src/5gnrsch/sch_rach.c b/src/5gnrsch/sch_rach.c index c07a7261a..296715288 100644 --- a/src/5gnrsch/sch_rach.c +++ b/src/5gnrsch/sch_rach.c @@ -414,7 +414,7 @@ SchPuschInfo* schAllocMsg3Pusch(Inst schInst, uint16_t crnti, uint8_t k2Index, S SchCellCb *cell = NULLP; SchUlSlotInfo *schUlSlotInfo = NULLP; uint8_t mcs = DEFAULT_MCS; - uint8_t startSymb = 0; + uint8_t startSymb = 0, ueId = 0; uint8_t symbLen = 0; uint16_t startRb = 0; uint16_t numRb = 0; @@ -427,6 +427,7 @@ SchPuschInfo* schAllocMsg3Pusch(Inst schInst, uint16_t crnti, uint8_t k2Index, S return NULLP; } + GET_UE_ID(crnti, ueId); /* Allocate time-domain and frequency-domain resource for MSG3 PUSCH */ startSymb = cell->cellCfg.ulCfgCommon.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[k2Index].startSymbol; symbLen = cell->cellCfg.ulCfgCommon.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[k2Index].symbolLength; @@ -439,55 +440,56 @@ SchPuschInfo* schAllocMsg3Pusch(Inst schInst, uint16_t crnti, uint8_t k2Index, S /* Fill PUSCH scheduling details in Slot structure */ schUlSlotInfo = cell->schUlSlotInfo[msg3SlotTime.slot]; - SCH_ALLOC(schUlSlotInfo->schPuschInfo, sizeof(SchPuschInfo)); - if(!schUlSlotInfo->schPuschInfo) + SCH_ALLOC(schUlSlotInfo->schPuschInfo[ueId - 1], sizeof(SchPuschInfo)); + if(!schUlSlotInfo->schPuschInfo[ueId - 1]) { DU_LOG("\nERROR --> SCH : Memory allocation failed in schAllocMsg3Pusch"); return NULLP; } - + cell->schUlSlotInfo[msg3SlotTime.slot]->puschPres = true; tbSize = 0; /* since nPrb has been incremented, recalculating tbSize */ tbSize = schCalcTbSizeFromNPrb(numRb, mcs, NUM_PDSCH_SYMBOL); tbSize = tbSize / 8 ; /*bits to byte conversion*/ - schUlSlotInfo->schPuschInfo->harqProcId = msg3HqProc->procId; - schUlSlotInfo->schPuschInfo->fdAlloc.resAllocType = SCH_ALLOC_TYPE_1; - schUlSlotInfo->schPuschInfo->fdAlloc.resAlloc.type1.startPrb = startRb; - schUlSlotInfo->schPuschInfo->fdAlloc.resAlloc.type1.numPrb = numRb; - schUlSlotInfo->schPuschInfo->tdAlloc.startSymb = startSymb; - schUlSlotInfo->schPuschInfo->tdAlloc.numSymb = symbLen; - schUlSlotInfo->schPuschInfo->tbInfo.qamOrder = QPSK_MODULATION; /* QPSK modulation */ - schUlSlotInfo->schPuschInfo->tbInfo.mcs = mcs; - schUlSlotInfo->schPuschInfo->tbInfo.mcsTable = SCH_MCS_TABLE_QAM_64; - schUlSlotInfo->schPuschInfo->tbInfo.ndi = NEW_TRANSMISSION; /* new transmission */ - schUlSlotInfo->schPuschInfo->tbInfo.rv = 0; - schUlSlotInfo->schPuschInfo->tbInfo.tbSize = tbSize; + schUlSlotInfo->schPuschInfo[ueId - 1]->harqProcId = msg3HqProc->procId; + schUlSlotInfo->schPuschInfo[ueId - 1]->crnti = crnti; + schUlSlotInfo->schPuschInfo[ueId - 1]->fdAlloc.resAllocType = SCH_ALLOC_TYPE_1; + schUlSlotInfo->schPuschInfo[ueId - 1]->fdAlloc.resAlloc.type1.startPrb = startRb; + schUlSlotInfo->schPuschInfo[ueId - 1]->fdAlloc.resAlloc.type1.numPrb = numRb; + schUlSlotInfo->schPuschInfo[ueId - 1]->tdAlloc.startSymb = startSymb; + schUlSlotInfo->schPuschInfo[ueId - 1]->tdAlloc.numSymb = symbLen; + schUlSlotInfo->schPuschInfo[ueId - 1]->tbInfo.qamOrder = QPSK_MODULATION; /* QPSK modulation */ + schUlSlotInfo->schPuschInfo[ueId - 1]->tbInfo.mcs = mcs; + schUlSlotInfo->schPuschInfo[ueId - 1]->tbInfo.mcsTable = SCH_MCS_TABLE_QAM_64; + schUlSlotInfo->schPuschInfo[ueId - 1]->tbInfo.ndi = NEW_TRANSMISSION; /* new transmission */ + schUlSlotInfo->schPuschInfo[ueId - 1]->tbInfo.rv = 0; + schUlSlotInfo->schPuschInfo[ueId - 1]->tbInfo.tbSize = tbSize; #ifdef INTEL_FAPI - schUlSlotInfo->schPuschInfo->dmrsMappingType = DMRS_MAP_TYPE_A; /* Setting Type-A */ - schUlSlotInfo->schPuschInfo->nrOfDmrsSymbols = NUM_DMRS_SYMBOLS; - schUlSlotInfo->schPuschInfo->dmrsAddPos = DMRS_ADDITIONAL_POS; + schUlSlotInfo->schPuschInfo[ueId - 1]->dmrsMappingType = DMRS_MAP_TYPE_A; /* Setting Type-A */ + schUlSlotInfo->schPuschInfo[ueId - 1]->nrOfDmrsSymbols = NUM_DMRS_SYMBOLS; + schUlSlotInfo->schPuschInfo[ueId - 1]->dmrsAddPos = DMRS_ADDITIONAL_POS; #endif if(!isRetx) { msg3HqProc->strtSymbl = startSymb; msg3HqProc->numSymbl = symbLen; - msg3HqProc->puschResType = schUlSlotInfo->schPuschInfo->fdAlloc.resAllocType; - msg3HqProc->puschStartPrb = schUlSlotInfo->schPuschInfo->fdAlloc.resAlloc.type1.startPrb; - msg3HqProc->puschNumPrb = schUlSlotInfo->schPuschInfo->fdAlloc.resAlloc.type1.numPrb; - msg3HqProc->tbInfo.qamOrder = schUlSlotInfo->schPuschInfo->tbInfo.qamOrder; - msg3HqProc->tbInfo.iMcs = schUlSlotInfo->schPuschInfo->tbInfo.mcs; - msg3HqProc->tbInfo.mcsTable = schUlSlotInfo->schPuschInfo->tbInfo.mcsTable; - msg3HqProc->tbInfo.ndi = schUlSlotInfo->schPuschInfo->tbInfo.ndi; - msg3HqProc->tbInfo.rv = schUlSlotInfo->schPuschInfo->tbInfo.rv; - msg3HqProc->tbInfo.tbSzReq = schUlSlotInfo->schPuschInfo->tbInfo.tbSize; + msg3HqProc->puschResType = schUlSlotInfo->schPuschInfo[ueId - 1]->fdAlloc.resAllocType; + msg3HqProc->puschStartPrb = schUlSlotInfo->schPuschInfo[ueId - 1]->fdAlloc.resAlloc.type1.startPrb; + msg3HqProc->puschNumPrb = schUlSlotInfo->schPuschInfo[ueId - 1]->fdAlloc.resAlloc.type1.numPrb; + msg3HqProc->tbInfo.qamOrder = schUlSlotInfo->schPuschInfo[ueId - 1]->tbInfo.qamOrder; + msg3HqProc->tbInfo.iMcs = schUlSlotInfo->schPuschInfo[ueId - 1]->tbInfo.mcs; + msg3HqProc->tbInfo.mcsTable = schUlSlotInfo->schPuschInfo[ueId - 1]->tbInfo.mcsTable; + msg3HqProc->tbInfo.ndi = schUlSlotInfo->schPuschInfo[ueId - 1]->tbInfo.ndi; + msg3HqProc->tbInfo.rv = schUlSlotInfo->schPuschInfo[ueId - 1]->tbInfo.rv; + msg3HqProc->tbInfo.tbSzReq = schUlSlotInfo->schPuschInfo[ueId - 1]->tbInfo.tbSize; #ifdef INTEL_FAPI - msg3HqProc->dmrsMappingType = schUlSlotInfo->schPuschInfo->dmrsMappingType; - msg3HqProc->nrOfDmrsSymbols = schUlSlotInfo->schPuschInfo->nrOfDmrsSymbols; - msg3HqProc->dmrsAddPos = schUlSlotInfo->schPuschInfo->dmrsAddPos; + msg3HqProc->dmrsMappingType = schUlSlotInfo->schPuschInfo[ueId - 1]->dmrsMappingType; + msg3HqProc->nrOfDmrsSymbols = schUlSlotInfo->schPuschInfo[ueId - 1]->nrOfDmrsSymbols; + msg3HqProc->dmrsAddPos = schUlSlotInfo->schPuschInfo[ueId - 1]->dmrsAddPos; #endif } - return schUlSlotInfo->schPuschInfo; + return schUlSlotInfo->schPuschInfo[ueId - 1]; } /** @@ -546,7 +548,7 @@ bool schProcessRaReq(Inst schInst, SchCellCb *cell, SlotTimingInfo currTime, uin #ifdef NR_TDD uint8_t totalCfgSlot = 0; #endif - uint16_t dciSlot = 0, rarSlot = 0; + uint16_t dciSlot = 0, rarSlot = 0, crnti = 0; SlotTimingInfo dciTime, rarTime, msg3Time, pucchTime; RarAlloc *dciSlotAlloc = NULLP; /* Stores info for transmission of PDCCH for RAR */ RarAlloc *rarSlotAlloc = NULLP; /* Stores info for transmission of RAR PDSCH */ @@ -554,7 +556,8 @@ bool schProcessRaReq(Inst schInst, SchCellCb *cell, SlotTimingInfo currTime, uin SchK0K1TimingInfoTbl *k0K1InfoTbl=NULLP; SchK2TimingInfoTbl *msg3K2InfoTbl=NULLP; RaRspWindowStatus windowStatus=0; - + + GET_CRNTI(crnti, ueId); #ifdef NR_TDD totalCfgSlot = calculateSlotPatternLength(cell->cellCfg.ssbScs, cell->cellCfg.tddCfg.tddPeriod); #endif @@ -619,8 +622,11 @@ bool schProcessRaReq(Inst schInst, SchCellCb *cell, SlotTimingInfo currTime, uin if(schGetSlotSymbFrmt(pucchTime.slot, cell->slotFrmtBitMap) == DL_SLOT) continue; #endif - if(cell->schUlSlotInfo[pucchTime.slot]->pucchUe != 0) + /*In this pucchTime, this particular UE/CRNTI is already scheduled thus checking + * for next pucchTime for the same UE*/ + if(cell->schUlSlotInfo[pucchTime.slot]->schPucchInfo[ueId - 1].crnti == crnti) continue; + k1Found = true; break; } @@ -642,9 +648,10 @@ bool schProcessRaReq(Inst schInst, SchCellCb *cell, SlotTimingInfo currTime, uin if(schGetSlotSymbFrmt(msg3Time.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[msg3Time.slot]->puschUe != 0) + /* If PUSCH is already scheduled on this slot for this UE, another PUSCH + * pdu cannot be scheduled here for same UE*/ + if((cell->schUlSlotInfo[msg3Time.slot]->schPuschInfo[ueId - 1] != NULLP) && \ + (cell->schUlSlotInfo[msg3Time.slot]->schPuschInfo[ueId - 1]->crnti == crnti)) continue; k2Found = true; @@ -696,9 +703,9 @@ bool schProcessRaReq(Inst schInst, SchCellCb *cell, SlotTimingInfo currTime, uin if(cell->raReq[ueId-1]->isCFRA) { + cell->schUlSlotInfo[pucchTime.slot]->schPucchInfo[ueId - 1].crnti = crnti; /* Allocate resources for PUCCH */ - cell->schUlSlotInfo[pucchTime.slot]->pucchUe = ueId; - ret = schAllocPucchResource(cell, pucchTime, NULLP, NULLP, NULLP); + ret = schAllocPucchResource(cell, ueId, pucchTime, NULLP, NULLP, NULLP); if(ret == RFAILED) { SCH_FREE(dciSlotAlloc, sizeof(RarAlloc)); @@ -710,7 +717,6 @@ bool schProcessRaReq(Inst schInst, SchCellCb *cell, SlotTimingInfo currTime, uin } else { - cell->schUlSlotInfo[msg3Time.slot]->puschUe = ueId; /* Allocate resources for msg3 */ msg3PuschInfo = schAllocMsg3Pusch(schInst, cell->raReq[ueId-1]->rachInd->crnti, k2Index, msg3Time, &(cell->raCb[ueId-1].msg3HqProc), FALSE); if(msg3PuschInfo) diff --git a/src/5gnrsch/sch_slice_based.c b/src/5gnrsch/sch_slice_based.c index ece81a09b..3f2e26508 100644 --- a/src/5gnrsch/sch_slice_based.c +++ b/src/5gnrsch/sch_slice_based.c @@ -906,7 +906,7 @@ uint8_t schSliceBasedScheduleUlLc(SlotTimingInfo dciTime, SlotTimingInfo puschTi uint16_t startPrb = 0; uint32_t totDataReq = 0; /* in bytes */ SchUeCb *ueCb; - SchPuschInfo *puschInfo; + SchPuschInfo *puschInfo = NULLP; DciInfo *dciInfo = NULLP; cell = (*hqP)->hqEnt->cell; @@ -935,16 +935,15 @@ uint8_t schSliceBasedScheduleUlLc(SlotTimingInfo dciTime, SlotTimingInfo puschTi /* Update PUSCH allocation */ if(schFillPuschAlloc(ueCb, puschTime, totDataReq, startSymb, symbLen, startPrb, isRetx, *hqP) == ROK) { - if(cell->schUlSlotInfo[puschTime.slot]->schPuschInfo) + if(cell->schUlSlotInfo[puschTime.slot]->schPuschInfo[ueCb->ueId - 1]) { - puschInfo = cell->schUlSlotInfo[puschTime.slot]->schPuschInfo; + puschInfo = cell->schUlSlotInfo[puschTime.slot]->schPuschInfo[ueCb->ueId - 1]; if(puschInfo != NULLP) { /* Fill DCI for UL grant */ schFillUlDci(ueCb, puschInfo, dciInfo, isRetx, *hqP); ueCb->srRcvd = false; ueCb->bsrRcvd = false; - cell->schUlSlotInfo[puschTime.slot]->puschUe = ueCb->ueId; if(schSpcHqProcCb->lcCb.dedLcList.count != 0) updateBsrAndLcList(&(schSpcHqProcCb->lcCb.dedLcList), ueCb->bsrInfo, ROK); updateBsrAndLcList(&(schSpcHqProcCb->lcCb.defLcList), ueCb->bsrInfo, ROK); diff --git a/src/5gnrsch/sch_slot_ind.c b/src/5gnrsch/sch_slot_ind.c index 8b423b27a..1caaf8039 100644 --- a/src/5gnrsch/sch_slot_ind.c +++ b/src/5gnrsch/sch_slot_ind.c @@ -242,8 +242,6 @@ bool schFillBoGrantDlSchedInfo(SchCellCb *cell, SlotTimingInfo currTime, uint8_t } } - cell->schUlSlotInfo[pucchTime.slot]->pucchUe = ueId; - /*Re-setting the BO's of all DL LCs in this UE*/ for(lcIdx = 0; lcIdx < MAX_NUM_LC; lcIdx++) { @@ -421,6 +419,7 @@ bool findValidK0K1Value(SchCellCb *cell, SlotTimingInfo currTime, uint8_t ueId, uint8_t numK0 = 0, k0TblIdx = 0, k0Val = 0, k0Index =0 ; uint8_t k1TblIdx = 0, k1Index = 0, k1Val = 0, numK1 = 0; uint8_t ret = RFAILED; + uint16_t crnti = 0; SchUeCb *ueCb = NULLP; SchK0K1TimingInfoTbl *k0K1InfoTbl; @@ -434,6 +433,7 @@ bool findValidK0K1Value(SchCellCb *cell, SlotTimingInfo currTime, uint8_t ueId, #endif ueCb = &cell->ueCb[ueId-1]; + GET_CRNTI(crnti, ueId); if(dedMsg == true) { k0K1InfoTbl = &ueCb->k0K1InfoTbl; @@ -508,7 +508,7 @@ bool findValidK0K1Value(SchCellCb *cell, SlotTimingInfo currTime, uint8_t ueId, continue; } #endif - if(cell->schUlSlotInfo[pucchTime->slot]->pucchUe != 0) + if(cell->schUlSlotInfo[pucchTime->slot]->schPucchInfo[ueId - 1].crnti == crnti) { continue; } @@ -518,11 +518,11 @@ bool findValidK0K1Value(SchCellCb *cell, SlotTimingInfo currTime, uint8_t ueId, } pdcchTime->cellId = cell->cellId; pdschTime->cellId = cell->cellId; - - cell->schUlSlotInfo[pucchTime->slot]->pucchUe = ueId; + + cell->schUlSlotInfo[pucchTime->slot]->schPucchInfo[ueId - 1].crnti = crnti; /*Availability of PUCCH for HARQ resources*/ - ret = schAllocPucchResource(cell, *pucchTime, ueCb, hqP, pdcchAllocInfo); + ret = schAllocPucchResource(cell, ueId, *pucchTime, ueCb, hqP, pdcchAllocInfo); if(ret == RFAILED) { /*DL allocation can't go through as PUCCH is unavailable*/ diff --git a/src/5gnrsch/sch_ue_mgr.c b/src/5gnrsch/sch_ue_mgr.c index fcc671e31..907ac340d 100644 --- a/src/5gnrsch/sch_ue_mgr.c +++ b/src/5gnrsch/sch_ue_mgr.c @@ -878,6 +878,7 @@ uint8_t schFillPuschAlloc(SchUeCb *ueCb, SlotTimingInfo puschTime, uint32_t tbSi if (isRetx == FALSE) { puschInfo.harqProcId = SCH_HARQ_PROC_ID; + puschInfo.crnti = ueCb->crnti; puschInfo.fdAlloc.resAllocType = SCH_ALLOC_TYPE_1; puschInfo.fdAlloc.resAlloc.type1.startPrb = startPrb; puschInfo.fdAlloc.resAlloc.type1.numPrb = numRb; @@ -915,6 +916,7 @@ uint8_t schFillPuschAlloc(SchUeCb *ueCb, SlotTimingInfo puschTime, uint32_t tbSi else { puschInfo.harqProcId = hqP->procId; + puschInfo.crnti = ueCb->crnti; puschInfo.fdAlloc.resAllocType = hqP->puschResType; puschInfo.fdAlloc.resAlloc.type1.startPrb = hqP->puschStartPrb; puschInfo.fdAlloc.resAlloc.type1.numPrb = hqP->puschNumPrb; @@ -934,16 +936,18 @@ uint8_t schFillPuschAlloc(SchUeCb *ueCb, SlotTimingInfo puschTime, uint32_t tbSi #endif } schUlSlotInfo = cellCb->schUlSlotInfo[puschTime.slot]; - SCH_ALLOC(schUlSlotInfo->schPuschInfo, sizeof(SchPuschInfo)); - if(!schUlSlotInfo->schPuschInfo) + SCH_ALLOC(schUlSlotInfo->schPuschInfo[ueCb->ueId - 1], sizeof(SchPuschInfo)); + if(!schUlSlotInfo->schPuschInfo[ueCb->ueId - 1]) { DU_LOG("\nERROR --> SCH: Memory allocation failed in schAllocMsg3Pusch"); return RFAILED; } - memcpy(schUlSlotInfo->schPuschInfo, &puschInfo, sizeof(SchPuschInfo)); + cellCb->schUlSlotInfo[puschTime.slot]->puschPres = true; + memcpy(schUlSlotInfo->schPuschInfo[ueCb->ueId - 1], &puschInfo, sizeof(SchPuschInfo)); return ROK; } + /******************************************************************* * * @brief Fills UL DCI information for MSG3 retransmission diff --git a/src/5gnrsch/sch_utils.c b/src/5gnrsch/sch_utils.c index 8ee6fa6da..aeb8bdd03 100644 --- a/src/5gnrsch/sch_utils.c +++ b/src/5gnrsch/sch_utils.c @@ -1199,6 +1199,7 @@ SchUeCb* schGetUeCb(SchCellCb *cellCb, uint16_t crnti) **/ void schInitUlSlot(SchUlSlotInfo *schUlSlotInfo) { + uint8_t ueIdx = 0; CmLList *node = NULLP, *next = NULLP; FreePrbBlock *freeBlock; @@ -1227,9 +1228,11 @@ void schInitUlSlot(SchUlSlotInfo *schUlSlotInfo) freeBlock->endPrb = MAX_NUM_RB-1; addNodeToLList(&schUlSlotInfo->prbAlloc.freePrbBlockList, freeBlock, NULL); } - - schUlSlotInfo->puschCurrentPrb = PUSCH_START_RB; - schUlSlotInfo->schPuschInfo = NULLP; + + for(ueIdx = 0; ueIdx < MAX_NUM_UE; ueIdx++) + { + schUlSlotInfo->schPuschInfo[ueIdx] = NULLP; + } } /** diff --git a/src/cm/mac_sch_interface.h b/src/cm/mac_sch_interface.h index 0716535ca..d6d42b7df 100644 --- a/src/cm/mac_sch_interface.h +++ b/src/cm/mac_sch_interface.h @@ -1289,6 +1289,7 @@ typedef struct tbInfo typedef struct schPuschInfo { uint8_t harqProcId; /* HARQ Process ID */ + uint16_t crnti; FreqDomainAlloc fdAlloc; /* Freq domain allocation */ TimeDomainAlloc tdAlloc; /* Time domain allocation */ TbInfo tbInfo; /* TB info */ @@ -1333,6 +1334,7 @@ typedef struct schPucchFormatCfg typedef struct schPucchInfo { + uint16_t crnti; FreqDomainRsrc fdAlloc; TimeDomainAlloc tdAlloc; uint8_t srFlag; @@ -1353,6 +1355,7 @@ typedef struct schPucchInfo typedef struct schPuschUci { uint8_t harqProcId; /* HARQ Process ID */ + uint16_t crnti; FreqDomainAlloc fdAlloc; /* Freq domain allocation */ TimeDomainAlloc tdAlloc; /* Time domain allocation */ TbInfo tbInfo; /* TB information */ @@ -1364,13 +1367,12 @@ typedef struct schPuschUci typedef struct ulSchedInfo { uint16_t cellId; /* Cell Id */ - uint16_t crnti; /* CRNI */ SlotTimingInfo slotIndInfo; /* Slot Info: sfn, slot number */ uint8_t dataType; /* Type of info being scheduled */ SchPrachInfo prachSchInfo; /* Prach scheduling info */ - SchPuschInfo schPuschInfo; /* Pusch scheduling info */ - SchPuschUci schPuschUci; /* Pusch Uci */ - SchPucchInfo schPucchInfo; /* Pucch and Uci scheduling info */ + SchPuschInfo schPuschInfo[MAX_NUM_UE]; /* Pusch scheduling info */ + SchPuschUci schPuschUci[MAX_NUM_UE]; /* Pusch Uci */ + SchPucchInfo schPucchInfo[MAX_NUM_UE]; /* Pucch and Uci scheduling info */ }UlSchedInfo; /* Info of Scheduling Request to Add/Modify */ -- 2.16.6