From: lal.harshita Date: Thu, 28 Oct 2021 11:33:46 +0000 (+0530) Subject: Round Robin Scheduling of Multi-UE [Issue-ID: ODUHIGH-387] X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=e6391c742645c17e4494d52f94fdeb66cfc99d1e;p=o-du%2Fl2.git Round Robin Scheduling of Multi-UE [Issue-ID: ODUHIGH-387] Change-Id: I12fe3c74bc3e0b519b2e3d8252190a25a0de0280 Signed-off-by: lal.harshita --- diff --git a/src/5gnrmac/lwr_mac_fsm.c b/src/5gnrmac/lwr_mac_fsm.c index 686d3fa43..9b305a178 100644 --- a/src/5gnrmac/lwr_mac_fsm.c +++ b/src/5gnrmac/lwr_mac_fsm.c @@ -2534,8 +2534,7 @@ void fillSib1DlDciPdu(fapi_dl_dci_t *dlDciPtr, PdcchCfg *sib1PdcchInfo) * Spec 38.214 Sec 5.1.2.2.2 */ coreset0Size= sib1PdcchInfo->coresetCfg.coreSetSize; - rbStart = 0; /* For SIB1 */ - //rbStart = sib1PdcchInfo->dci.pdschCfg->pdschFreqAlloc.freqAlloc.startPrb; + rbStart = sib1PdcchInfo->dci.pdschCfg->pdschFreqAlloc.freqAlloc.startPrb; rbLen = sib1PdcchInfo->dci.pdschCfg->pdschFreqAlloc.freqAlloc.numPrb; if((rbLen >=1) && (rbLen <= coreset0Size - rbStart)) @@ -2550,10 +2549,8 @@ void fillSib1DlDciPdu(fapi_dl_dci_t *dlDciPtr, PdcchCfg *sib1PdcchInfo) } /* Fetching DCI field values */ - timeDomResAssign = sib1PdcchInfo->dci.pdschCfg->pdschTimeAlloc. - rowIndex -1; - VRB2PRBMap = sib1PdcchInfo->dci.pdschCfg->pdschFreqAlloc.\ - vrbPrbMapping; + timeDomResAssign = sib1PdcchInfo->dci.pdschCfg->pdschTimeAlloc.rowIndex -1; + VRB2PRBMap = sib1PdcchInfo->dci.pdschCfg->pdschFreqAlloc.vrbPrbMapping; modNCodScheme = sib1PdcchInfo->dci.pdschCfg->codeword[0].mcsIndex; redundancyVer = sib1PdcchInfo->dci.pdschCfg->codeword[0].rvIndex; sysInfoInd = 0; /* 0 for SIB1; 1 for SI messages */ @@ -2674,7 +2671,7 @@ void fillRarDlDciPdu(fapi_dl_dci_t *dlDciPtr, PdcchCfg *rarPdcchInfo) /* TODO: Fill values of coreset0Size, rbStart and rbLen */ coreset0Size= rarPdcchInfo->coresetCfg.coreSetSize; rbStart = 0; /* For SIB1 */ - //rbStart = rarPdcchInfo->dci.pdschCfg->freqAlloc.rbStart; + rbStart = rarPdcchInfo->dci.pdschCfg->pdschFreqAlloc.freqAlloc.startPrb; rbLen = rarPdcchInfo->dci.pdschCfg->pdschFreqAlloc.freqAlloc.numPrb; if((rbLen >=1) && (rbLen <= coreset0Size - rbStart)) @@ -2689,7 +2686,7 @@ void fillRarDlDciPdu(fapi_dl_dci_t *dlDciPtr, PdcchCfg *rarPdcchInfo) } /* Fetching DCI field values */ - timeDomResAssign = rarPdcchInfo->dci.pdschCfg->pdschTimeAlloc.rowIndex -1; + timeDomResAssign = rarPdcchInfo->dci.pdschCfg->pdschTimeAlloc.rowIndex; VRB2PRBMap = rarPdcchInfo->dci.pdschCfg->pdschFreqAlloc.vrbPrbMapping; modNCodScheme = rarPdcchInfo->dci.pdschCfg->codeword[0].mcsIndex; tbScaling = 0; /* configured to 0 scaling */ @@ -2927,7 +2924,7 @@ void fillDlMsgDlDciPdu(fapi_dl_dci_t *dlDciPtr, PdcchCfg *pdcchInfo,\ * ******************************************************************/ uint8_t fillPdcchPdu(fapi_dl_tti_req_pdu_t *dlTtiReqPdu, DlSchedInfo *dlInfo, \ - RntiType rntiType, uint8_t coreSetType) + RntiType rntiType, uint8_t coreSetType, uint8_t ueIdx) { if(dlTtiReqPdu != NULLP) { @@ -2937,27 +2934,27 @@ uint8_t fillPdcchPdu(fapi_dl_tti_req_pdu_t *dlTtiReqPdu, DlSchedInfo *dlInfo, \ memset(&dlTtiReqPdu->pdu.pdcch_pdu, 0, sizeof(fapi_dl_pdcch_pdu_t)); if(rntiType == SI_RNTI_TYPE) { - pdcchInfo = &dlInfo->brdcstAlloc.sib1Alloc.sib1PdcchCfg; - bwp = &dlInfo->brdcstAlloc.sib1Alloc.bwp; - fillSib1DlDciPdu(dlTtiReqPdu->pdu.pdcch_pdu.dlDci, pdcchInfo); + pdcchInfo = &dlInfo->brdcstAlloc.sib1Alloc.sib1PdcchCfg; + bwp = &dlInfo->brdcstAlloc.sib1Alloc.bwp; + fillSib1DlDciPdu(dlTtiReqPdu->pdu.pdcch_pdu.dlDci, pdcchInfo); } else if(rntiType == RA_RNTI_TYPE) { - pdcchInfo = &dlInfo->rarAlloc->rarPdcchCfg; - bwp = &dlInfo->rarAlloc->bwp; - fillRarDlDciPdu(dlTtiReqPdu->pdu.pdcch_pdu.dlDci, pdcchInfo); + pdcchInfo = &dlInfo->rarAlloc[ueIdx]->rarPdcchCfg; + bwp = &dlInfo->rarAlloc[ueIdx]->bwp; + fillRarDlDciPdu(dlTtiReqPdu->pdu.pdcch_pdu.dlDci, pdcchInfo); } else if(rntiType == TC_RNTI_TYPE || rntiType == C_RNTI_TYPE) { pdcchInfo = &dlInfo->dlMsgAlloc->dlMsgPdcchCfg; - bwp = &dlInfo->dlMsgAlloc->bwp; + bwp = &dlInfo->dlMsgAlloc->bwp; fillDlMsgDlDciPdu(dlTtiReqPdu->pdu.pdcch_pdu.dlDci, pdcchInfo,\ - &dlInfo->dlMsgAlloc->dlMsgInfo); + &dlInfo->dlMsgAlloc->dlMsgInfo); } else { - DU_LOG("\nERROR --> LWR_MAC: Failed filling PDCCH Pdu"); - return RFAILED; + DU_LOG("\nERROR --> LWR_MAC: Failed filling PDCCH Pdu"); + return RFAILED; } dlTtiReqPdu->pduType = PDCCH_PDU_TYPE; dlTtiReqPdu->pdu.pdcch_pdu.bwpSize = bwp->freqAlloc.numPrb; @@ -2974,7 +2971,7 @@ uint8_t fillPdcchPdu(fapi_dl_tti_req_pdu_t *dlTtiReqPdu, DlSchedInfo *dlInfo, \ dlTtiReqPdu->pdu.pdcch_pdu.precoderGranularity = pdcchInfo->coresetCfg.precoderGranularity; dlTtiReqPdu->pdu.pdcch_pdu.numDlDci = pdcchInfo->numDlDci; dlTtiReqPdu->pdu.pdcch_pdu.coreSetType = coreSetType; - + /* Calculating PDU length. Considering only one dl dci pdu for now */ dlTtiReqPdu->pduSize = sizeof(fapi_dl_pdcch_pdu_t); } @@ -3079,32 +3076,37 @@ void fillPdschPdu(fapi_dl_tti_req_pdu_t *dlTtiReqPdu, PdschCfg *pdschInfo, uint8_t calcDlTtiReqPduCount(DlSchedInfo *dlInfo) { uint8_t count = 0; - uint8_t idx = 0; + uint8_t idx = 0, ueIdx=0; if(dlInfo->isBroadcastPres) { if(dlInfo->brdcstAlloc.ssbTrans) { - for(idx = 0; idx < dlInfo->brdcstAlloc.ssbIdxSupported; idx++) - { - /* SSB PDU is filled */ - count++; - } + for(idx = 0; idx < dlInfo->brdcstAlloc.ssbIdxSupported; idx++) + { + /* SSB PDU is filled */ + count++; + } } if(dlInfo->brdcstAlloc.sib1Trans) { - /* PDCCH and PDSCH PDU is filled */ - count += 2; + /* PDCCH and PDSCH PDU is filled */ + count += 2; } } - if(dlInfo->rarAlloc != NULLP) + + for(ueIdx=0; ueIdxrarAlloc->pduPres == BOTH) - count += 2; - else - count += 1; + if(dlInfo->rarAlloc[ueIdx] != NULLP) + { + /* PDCCH and PDSCH PDU is filled */ + if(dlInfo->rarAlloc[ueIdx]->pduPres == BOTH) + count += 2; + else + count += 1; + } } + if(dlInfo->dlMsgAlloc != NULLP) { /* PDCCH and PDSCH PDU is filled */ @@ -3134,16 +3136,20 @@ uint8_t calcDlTtiReqPduCount(DlSchedInfo *dlInfo) * ********************************************************************/ uint8_t calcTxDataReqPduCount(DlSchedInfo *dlInfo) { - uint8_t count = 0; + uint8_t count = 0, ueIdx=0; if(dlInfo->isBroadcastPres && dlInfo->brdcstAlloc.sib1Trans) { count++; } - if(dlInfo->rarAlloc != NULLP) + + for(ueIdx=0; ueIdxrarAlloc[ueIdx] != NULLP) && \ + ((dlInfo->rarAlloc[ueIdx]->pduPres == BOTH) || (dlInfo->rarAlloc[ueIdx]->pduPres == PDSCH_PDU))) + count++; } + if(dlInfo->dlMsgAlloc != NULLP) { if(dlInfo->dlMsgAlloc->pduPres == BOTH || dlInfo->dlMsgAlloc->pduPres == PDSCH_PDU) @@ -3359,6 +3365,7 @@ uint16_t fillDlTtiReq(SlotTimingInfo currTimingInfo) uint8_t idx =0; uint8_t nPdu = 0; uint8_t numPduEncoded = 0; + uint8_t ueIdx; uint16_t cellIdx =0; uint16_t pduIndex = 0; @@ -3440,7 +3447,7 @@ uint16_t fillDlTtiReq(SlotTimingInfo currTimingInfo) { rntiType = SI_RNTI_TYPE; fillPdcchPdu(&dlTtiReq->pdus[numPduEncoded],&currDlSlot->dlInfo,\ - rntiType, CORESET_TYPE0); + rntiType, CORESET_TYPE0, MAX_NUM_UE); numPduEncoded++; fillPdschPdu(&dlTtiReq->pdus[numPduEncoded], &currDlSlot->dlInfo.brdcstAlloc.sib1Alloc.sib1PdschCfg, @@ -3456,34 +3463,36 @@ uint16_t fillDlTtiReq(SlotTimingInfo currTimingInfo) DU_LOG("\033[0m"); } } - - if(currDlSlot->dlInfo.rarAlloc != NULLP) + + for(ueIdx=0; ueIdxdlInfo.rarAlloc->pduPres == BOTH) || \ - (currDlSlot->dlInfo.rarAlloc->pduPres == PDCCH_PDU)) + if(currDlSlot->dlInfo.rarAlloc[ueIdx] != NULLP) { - fillPdcchPdu(&dlTtiReq->pdus[numPduEncoded], \ - &currDlSlot->dlInfo, rntiType, CORESET_TYPE0); - numPduEncoded++; - } - if((currDlSlot->dlInfo.rarAlloc->pduPres == BOTH) || \ - (currDlSlot->dlInfo.rarAlloc->pduPres == PDSCH_PDU)) - { - fillPdschPdu(&dlTtiReq->pdus[numPduEncoded], - &currDlSlot->dlInfo.rarAlloc->rarPdschCfg, - currDlSlot->dlInfo.rarAlloc->bwp, - pduIndex); - numPduEncoded++; - pduIndex++; - - DU_LOG("\033[1;32m"); - DU_LOG("\nDEBUG --> LWR_MAC: RAR sent..."); - DU_LOG("\033[0m"); + /* Filling RAR param */ + rntiType = RA_RNTI_TYPE; + if((currDlSlot->dlInfo.rarAlloc[ueIdx]->pduPres == BOTH) || \ + (currDlSlot->dlInfo.rarAlloc[ueIdx]->pduPres == PDCCH_PDU)) + { + fillPdcchPdu(&dlTtiReq->pdus[numPduEncoded], \ + &currDlSlot->dlInfo, rntiType, CORESET_TYPE0, ueIdx); + numPduEncoded++; + } + if((currDlSlot->dlInfo.rarAlloc[ueIdx]->pduPres == BOTH) || \ + (currDlSlot->dlInfo.rarAlloc[ueIdx]->pduPres == PDSCH_PDU)) + { + fillPdschPdu(&dlTtiReq->pdus[numPduEncoded], + &currDlSlot->dlInfo.rarAlloc[ueIdx]->rarPdschCfg, + currDlSlot->dlInfo.rarAlloc[ueIdx]->bwp, + pduIndex); + numPduEncoded++; + pduIndex++; + + DU_LOG("\033[1;32m"); + DU_LOG("\nDEBUG --> LWR_MAC: RAR sent..."); + DU_LOG("\033[0m"); + } } } - if(currDlSlot->dlInfo.dlMsgAlloc != NULLP) { if(currDlSlot->dlInfo.dlMsgAlloc->dlMsgInfo.dlMsgPdu != NULLP) @@ -3496,14 +3505,14 @@ uint16_t fillDlTtiReq(SlotTimingInfo currTimingInfo) { rntiType = TC_RNTI_TYPE; fillPdcchPdu(&dlTtiReq->pdus[numPduEncoded], \ - &currDlSlot->dlInfo, rntiType, CORESET_TYPE0); + &currDlSlot->dlInfo, rntiType, CORESET_TYPE0, MAX_NUM_UE); } else { /* Filling other DL msg params */ rntiType = C_RNTI_TYPE; fillPdcchPdu(&dlTtiReq->pdus[numPduEncoded], \ - &currDlSlot->dlInfo, rntiType, CORESET_TYPE1); + &currDlSlot->dlInfo, rntiType, CORESET_TYPE1, MAX_NUM_UE); } numPduEncoded++; } @@ -3627,8 +3636,9 @@ uint16_t sendTxDataReq(SlotTimingInfo currTimingInfo, DlSchedInfo *dlInfo, p_fap DU_LOG("\nCall Flow: ENTMAC -> ENTLWRMAC : TX_DATA_REQ\n"); #endif - uint8_t nPdu = 0; - uint16_t cellIdx; + uint8_t nPdu = 0; + uint8_t ueIdx=0; + uint16_t cellIdx=0; uint16_t pduIndex = 0; fapi_tx_data_req_t *txDataReq =NULLP; p_fapi_api_queue_elem_t txDataElem = 0; @@ -3642,12 +3652,12 @@ uint16_t sendTxDataReq(SlotTimingInfo currTimingInfo, DlSchedInfo *dlInfo, p_fap LWR_MAC_ALLOC(txDataElem, (sizeof(fapi_api_queue_elem_t) + sizeof(fapi_tx_data_req_t))); if(txDataElem == NULLP) { - DU_LOG("\nERROR --> LWR_MAC: Failed to allocate memory for TX data Request"); - return RFAILED; + DU_LOG("\nERROR --> LWR_MAC: Failed to allocate memory for TX data Request"); + return RFAILED; } FILL_FAPI_LIST_ELEM(txDataElem, NULLP, FAPI_TX_DATA_REQUEST, 1, \ - sizeof(fapi_tx_data_req_t)); + sizeof(fapi_tx_data_req_t)); txDataReq = (fapi_tx_data_req_t *)(txDataElem +1); memset(txDataReq, 0, sizeof(fapi_tx_data_req_t)); fillMsgHeader(&txDataReq->header, FAPI_TX_DATA_REQUEST, sizeof(fapi_tx_data_req_t)); @@ -3656,22 +3666,25 @@ uint16_t sendTxDataReq(SlotTimingInfo currTimingInfo, DlSchedInfo *dlInfo, p_fap txDataReq->slot = currTimingInfo.slot; if(dlInfo->brdcstAlloc.sib1Trans) { - fillSib1TxDataReq(txDataReq->pdu_desc, pduIndex, &macCb.macCell[cellIdx]->macCellCfg, \ - dlInfo->brdcstAlloc.sib1Alloc.sib1PdschCfg); - pduIndex++; - txDataReq->num_pdus++; + fillSib1TxDataReq(txDataReq->pdu_desc, pduIndex, &macCb.macCell[cellIdx]->macCellCfg, \ + dlInfo->brdcstAlloc.sib1Alloc.sib1PdschCfg); + pduIndex++; + txDataReq->num_pdus++; } - if(dlInfo->rarAlloc != NULLP) + for(ueIdx=0; ueIdxrarAlloc->pduPres == BOTH) || (dlInfo->rarAlloc->pduPres == PDSCH_PDU)) + if(dlInfo->rarAlloc[ueIdx] != NULLP) { - fillRarTxDataReq(txDataReq->pdu_desc, pduIndex, &dlInfo->rarAlloc->rarInfo,\ - dlInfo->rarAlloc->rarPdschCfg); - pduIndex++; - txDataReq->num_pdus++; + if((dlInfo->rarAlloc[ueIdx]->pduPres == BOTH) || (dlInfo->rarAlloc[ueIdx]->pduPres == PDSCH_PDU)) + { + fillRarTxDataReq(txDataReq->pdu_desc, pduIndex, &dlInfo->rarAlloc[ueIdx]->rarInfo,\ + dlInfo->rarAlloc[ueIdx]->rarPdschCfg); + pduIndex++; + txDataReq->num_pdus++; + } + MAC_FREE(dlInfo->rarAlloc[ueIdx],sizeof(RarAlloc)); } - MAC_FREE(dlInfo->rarAlloc,sizeof(RarAlloc)); } if(dlInfo->dlMsgAlloc != NULLP) @@ -3681,7 +3694,7 @@ uint16_t sendTxDataReq(SlotTimingInfo currTimingInfo, DlSchedInfo *dlInfo, p_fap pduIndex++; txDataReq->num_pdus++; MAC_FREE(dlInfo->dlMsgAlloc->dlMsgInfo.dlMsgPdu,\ - dlInfo->dlMsgAlloc->dlMsgInfo.dlMsgPduLen); + dlInfo->dlMsgAlloc->dlMsgInfo.dlMsgPduLen); dlInfo->dlMsgAlloc->dlMsgInfo.dlMsgPdu = NULLP; MAC_FREE(dlInfo->dlMsgAlloc, sizeof(DlMsgAlloc)); } diff --git a/src/5gnrmac/mac_slot_ind.c b/src/5gnrmac/mac_slot_ind.c index dcf3cc9e6..78756cfc9 100644 --- a/src/5gnrmac/mac_slot_ind.c +++ b/src/5gnrmac/mac_slot_ind.c @@ -74,14 +74,16 @@ uint8_t MacProcDlAlloc(Pst *pst, DlSchedInfo *dlSchedInfo) &currDlSlot->dlInfo.brdcstAlloc.sib1Alloc.sib1PdschCfg; } - if(dlSchedInfo->rarAlloc != NULLP) + for(ueIdx=0; ueIdx\ - dlSlot[dlSchedInfo->schSlotValue.rarTime.slot]; - currDlSlot->dlInfo.rarAlloc = dlSchedInfo->rarAlloc; + if(dlSchedInfo->rarAlloc[ueIdx] != NULLP) + { + currDlSlot = &macCb.macCell[cellIdx]->dlSlot[dlSchedInfo->schSlotValue.rarTime.slot]; + currDlSlot->dlInfo.rarAlloc[ueIdx] = dlSchedInfo->rarAlloc[ueIdx]; - /* MUXing of RAR */ - fillRarPdu(&currDlSlot->dlInfo.rarAlloc->rarInfo); + /* MUXing of RAR */ + fillRarPdu(&currDlSlot->dlInfo.rarAlloc[ueIdx]->rarInfo); + } } if(dlSchedInfo->dlMsgAlloc != NULLP) diff --git a/src/5gnrsch/sch.c b/src/5gnrsch/sch.c index 8fd6a871d..c1c1a4328 100644 --- a/src/5gnrsch/sch.c +++ b/src/5gnrsch/sch.c @@ -664,6 +664,7 @@ uint8_t schInitCellCb(Inst inst, SchCellCfg *schCellCfg) cell->firstSsbTransmitted = false; cell->firstSib1Transmitted = false; fillSsbStartSymb(cell); + cmLListInit(&cell->ueToBeScheduled); schCb[inst].cells[inst] = cell; DU_LOG("\nINFO --> SCH : Cell init completed for cellId:%d", cell->cellId); @@ -931,6 +932,7 @@ uint8_t MacSchDlRlcBoInfo(Pst *pst, DlRlcBoInfo *dlBoInfo) #ifdef NR_TDD uint16_t slotIdx = 0; #endif + bool isLcIdValid = false; DlMsgInfo dlMsgInfo; SchUeCb *ueCb = NULLP; SchCellCb *cell = NULLP; @@ -941,7 +943,7 @@ uint8_t MacSchDlRlcBoInfo(Pst *pst, DlRlcBoInfo *dlBoInfo) DU_LOG("\nCall Flow: ENTMAC -> ENTSCH : EVENT_DL_RLC_BO_INFO_TO_SCH\n"); #endif - DU_LOG("\nDEBUG --> SCH : Received RLC BO Status indication"); + DU_LOG("\nDEBUG --> SCH : Received RLC BO Status indication LCId [%d] BO [%d]", dlBoInfo->lcId, dlBoInfo->dataVolume); cell = schCb[inst].cells[inst]; if(cell == NULLP) @@ -953,6 +955,12 @@ uint8_t MacSchDlRlcBoInfo(Pst *pst, DlRlcBoInfo *dlBoInfo) GET_UE_IDX(dlBoInfo->crnti, ueIdx); ueCb = &cell->ueCb[ueIdx-1]; lcId = dlBoInfo->lcId; + CHECK_LCID(lcId, isLcIdValid); + if(isLcIdValid == FALSE) + { + DU_LOG("ERROR --> SCH: LCID:%d is not valid", lcId); + return RFAILED; + } memset(&dlMsgInfo, 0, sizeof(DlMsgInfo)); dlMsgInfo.crnti = dlBoInfo->crnti; @@ -974,23 +982,14 @@ uint8_t MacSchDlRlcBoInfo(Pst *pst, DlRlcBoInfo *dlBoInfo) { /* TODO : These part of changes will be corrected during DL scheduling as * per K0 - K1 -K2 */ - if(lcId == SRB1_LCID || lcId == SRB2_LCID || lcId == SRB3_LCID || \ - (lcId >= MIN_DRB_LCID && lcId <= MAX_DRB_LCID)) + SET_ONE_BIT(ueIdx, cell->boIndBitMap); + if(ueCb->dlInfo.dlLcCtxt[lcId].lcId == lcId) { - SET_ONE_BIT(ueIdx, cell->boIndBitMap); - if(ueCb->dlInfo.dlLcCtxt[lcId].lcId == lcId) - { - ueCb->dlInfo.dlLcCtxt[lcId].bo = dlBoInfo->dataVolume; - } - else - { - DU_LOG("ERROR --> SCH: LCID:%d is not configured in SCH Cb",lcId); - return RFAILED; - } + ueCb->dlInfo.dlLcCtxt[lcId].bo = dlBoInfo->dataVolume; } - else if(lcId != SRB0_LCID) + else { - DU_LOG("\nERROR --> SCH : Invalid LC Id %d in MacSchDlRlcBoInfo", lcId); + DU_LOG("ERROR --> SCH: LCID:%d is not configured in SCH Cb",lcId); return RFAILED; } @@ -1372,6 +1371,58 @@ uint8_t allocatePrbUl(SchCellCb *cell, SlotTimingInfo slotTime, \ return ROK; } + +/******************************************************************* + * + * @brief Add UE to ueToBeScheduled List + * + * @details + * + * Function : addUeToBeScheduled + * + * Functionality: + * Search if UE entry present in the list + * If yes, return. + * If no, add UE to the list + * + * @params[in] Cell control block + * Ue Idx to be added + * + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +uint8_t addUeToBeScheduled(SchCellCb *cell, uint8_t ueIdToAdd) +{ + uint8_t *ueId; + CmLList *node; + + /* Search if UE entry is already present in ueToBeScheduled list. + * If yes, another entry for same UE not needed. Hence, return */ + node = cell->ueToBeScheduled.first; + while(node) + { + ueId = (uint8_t *)node->node; + if(*ueId == ueIdToAdd) + return ROK; + node = node->next; + } + + /* If UE entry not present already, add UE to the end of ueToBeScheduled list */ + SCH_ALLOC(ueId, sizeof(uint8_t)); + if(!ueId) + { + DU_LOG("\nERROR --> SCH : Memory allocation failure in addUeToBeScheduled"); + return RFAILED; + } + *ueId = ueIdToAdd; + if(addNodeToLList(&cell->ueToBeScheduled, ueId, NULLP) != ROK) + { + DU_LOG("\nERROR --> SCH : Failed to add UeIdx to cell->ueToBeScheduled list"); + return RFAILED; + } + return ROK; +} /******************************************************************************* * diff --git a/src/5gnrsch/sch.h b/src/5gnrsch/sch.h index 8212299de..544e3250d 100644 --- a/src/5gnrsch/sch.h +++ b/src/5gnrsch/sch.h @@ -140,8 +140,10 @@ typedef struct schDlSlotInfo uint8_t ssbIdxSupported; /*!< Max SSB index */ SsbInfo ssbInfo[MAX_SSB_IDX]; /*!< SSB info */ bool sib1Pres; /*!< Flag to determine if SIB1 is present in this slot */ - RarAlloc *rarAlloc; /*!< RAR allocation */ - DlMsgAlloc *dlMsgAlloc; /*!< Dl msg allocation */ + uint8_t pdcchUe; /*!< UE for which PDCCH is scheduled in this slot */ + uint8_t pdschUe; /*!< UE for which PDSCH is scheduled in this slot */ + RarAlloc *rarAlloc[MAX_NUM_UE]; /*!< RAR allocation per UE*/ + DlMsgAlloc *dlMsgAlloc; /*!< Dl msg allocation */ }SchDlSlotInfo; typedef struct schRaCb @@ -157,12 +159,14 @@ 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 */ + 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 */ }SchUlSlotInfo; /** @@ -309,6 +313,7 @@ typedef struct schCellCb uint32_t actvUeBitMap; /*! SCH : Memory Allocation failed for msg4SlotAlloc"); SCH_FREE(dciSlotAlloc, sizeof(DlMsgAlloc)); - cell->schDlSlotInfo[pdcchSlot]->rarAlloc = NULLP; + cell->schDlSlotInfo[pdcchSlot]->dlMsgAlloc = NULLP; return RFAILED; } cell->schDlSlotInfo[pdschSlot]->dlMsgAlloc = msg4SlotAlloc; diff --git a/src/5gnrsch/sch_rach.c b/src/5gnrsch/sch_rach.c index 050752c9d..199f6af8c 100644 --- a/src/5gnrsch/sch_rach.c +++ b/src/5gnrsch/sch_rach.c @@ -344,10 +344,10 @@ RaRspWindowStatus isInRaRspWindow(SchRaReq *raReq, SlotTimingInfo frameToCheck, * @param[in] Current timing of the cell * @return ROK **/ -void schProcessRaReq(SlotTimingInfo currTime, SchCellCb *cell) +bool schProcessRaReq(SchCellCb *cell, SlotTimingInfo currTime, uint8_t ueId) { bool k2Found = false; - uint8_t ueIdx = 0, k0TblIdx = 0, k2TblIdx = 0; + uint8_t k0TblIdx = 0, k2TblIdx = 0; uint8_t k0Index = 0, k2Index = 0; uint8_t k0 = 0, k2 = 0; uint8_t puschMu = 0; @@ -364,162 +364,168 @@ void schProcessRaReq(SlotTimingInfo currTime, SchCellCb *cell) SchK2TimingInfoTbl *msg3K2InfoTbl=NULLP; RaRspWindowStatus windowStatus=0; - while(ueIdx < MAX_NUM_UE) - { - if(cell->raReq[ueIdx] == NULLP) - { - ueIdx++; - continue; - } - #ifdef NR_TDD - totalCfgSlot = calculateSlotPatternLength(cell->cellCfg.ssbSchCfg.scsCommon, cell->cellCfg.tddCfg.tddPeriod); + totalCfgSlot = calculateSlotPatternLength(cell->cellCfg.ssbSchCfg.scsCommon, cell->cellCfg.tddCfg.tddPeriod); #endif - k0K1InfoTbl = &cell->cellCfg.schInitialDlBwp.k0K1InfoTbl; - msg3K2InfoTbl = &cell->cellCfg.schInitialUlBwp.msg3K2InfoTbl; - puschMu = cell->cellCfg.numerology; - msg3Delta = puschDeltaTable[puschMu]; - msg3MinSchTime = minMsg3SchTime[cell->cellCfg.numerology]; - - /* Calculating time frame to send DCI for RAR */ - ADD_DELTA_TO_TIME(currTime, dciTime, PHY_DELTA_DL + SCHED_DELTA); - dciSlot = dciTime.slot; + k0K1InfoTbl = &cell->cellCfg.schInitialDlBwp.k0K1InfoTbl; + msg3K2InfoTbl = &cell->cellCfg.schInitialUlBwp.msg3K2InfoTbl; + puschMu = cell->cellCfg.numerology; + msg3Delta = puschDeltaTable[puschMu]; + msg3MinSchTime = minMsg3SchTime[cell->cellCfg.numerology]; + + /* Calculating time frame to send DCI for RAR */ + ADD_DELTA_TO_TIME(currTime, dciTime, PHY_DELTA_DL + SCHED_DELTA); + dciSlot = dciTime.slot; #ifdef NR_TDD - /* Consider this slot for sending DCI, only if it is a DL slot */ - if(schGetSlotSymbFrmt(dciSlot, cell->slotFrmtBitMap) == DL_SLOT) + /* Consider this slot for sending DCI, only if it is a DL slot */ + if(schGetSlotSymbFrmt(dciSlot, 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; + + /* Check if this slot is within RA response window */ + windowStatus = isInRaRspWindow(cell->raReq[ueId-1], dciTime, cell->numSlots); + if(windowStatus == WITHIN_WINDOW) { - - /* Check if this slot is within RA response window */ - windowStatus = isInRaRspWindow(cell->raReq[ueIdx], dciTime, cell->numSlots); - if(windowStatus == WITHIN_WINDOW) + /* For all k0 values, search for a suitable k2 value to schedule MSG3. + * RAR DCI, RAR PDSCH and MSG3 is scheduled only if one such k0-k2 combination + * is found. Else no scheduling happens. + */ + for(k0TblIdx = 0; k0TblIdx < k0K1InfoTbl->k0k1TimingInfo[dciSlot].numK0; k0TblIdx++) { - /* For all k0 values, search for a suitable k2 value to schedule MSG3. - * RAR DCI, RAR PDSCH and MSG3 is scheduled only if one such k0-k2 combination - * is found. Else no scheduling happens. - */ - for(k0TblIdx = 0; k0TblIdx < k0K1InfoTbl->k0k1TimingInfo[dciSlot].numK0; k0TblIdx++) + k0Index = k0K1InfoTbl->k0k1TimingInfo[dciSlot].k0Indexes[k0TblIdx].k0Index; + k0 = cell->cellCfg.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[k0Index].k0; + + /* Calculating time frame to send RAR PDSCH */ + ADD_DELTA_TO_TIME(dciTime, rarTime, k0); + rarSlot = rarTime.slot; + + /* If PDSCH is already scheduled on this slot, cannot schedule PDSCH for another UE here. */ + if(cell->schDlSlotInfo[rarSlot]->pdschUe != 0) + continue; + + for(k2TblIdx = 0; k2TblIdx < msg3K2InfoTbl->k2TimingInfo[rarSlot].numK2; k2TblIdx++) { - k0Index = k0K1InfoTbl->k0k1TimingInfo[dciSlot].k0Indexes[k0TblIdx].k0Index; - k0 = cell->cellCfg.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[k0Index].k0; - - /* Calculating time frame to send RAR PDSCH */ - ADD_DELTA_TO_TIME(dciTime, rarTime, k0); - rarSlot = rarTime.slot; + k2Index = msg3K2InfoTbl->k2TimingInfo[rarSlot].k2Indexes[k2TblIdx]; + k2 = cell->cellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[k2Index].k2; - for(k2TblIdx = 0; k2TblIdx < msg3K2InfoTbl->k2TimingInfo[rarSlot].numK2; k2TblIdx++) + /* Delta is added to the slot allocation for msg3 based on 38.214 section 6.1.2.1 */ + k2 = k2 + msg3Delta; + if(k2 >= msg3MinSchTime) { - k2Index = msg3K2InfoTbl->k2TimingInfo[rarSlot].k2Indexes[k2TblIdx]; - k2 = cell->cellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[k2Index].k2; - - /* 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(rarTime, msg3Time, k2); + ADD_DELTA_TO_TIME(rarTime, msg3Time, k2); #ifdef NR_TDD - if(schGetSlotSymbFrmt(msg3Time.slot % totalCfgSlot, cell->slotFrmtBitMap) == DL_SLOT) - continue; + if(schGetSlotSymbFrmt(msg3Time.slot % totalCfgSlot, cell->slotFrmtBitMap) == DL_SLOT) + continue; #endif - k2Found = true; - break; - } - } - if(k2Found) + /* If PUSCH is already scheduled on this slot, another PUSCH + * pdu cannot be scheduled here */ + if(cell->schUlSlotInfo[msg3Time.slot]->puschUe != 0) + continue; + + k2Found = true; break; + } } + if(k2Found) + break; } - else if(windowStatus == WINDOW_EXPIRED) - { - SCH_FREE(cell->raReq[ueIdx]->rachInd, sizeof(RachIndInfo)); - SCH_FREE(cell->raReq[ueIdx], sizeof(SchRaReq)); - ueIdx++; - continue; - } + } + else if(windowStatus == WINDOW_EXPIRED) + { + SCH_FREE(cell->raReq[ueId-1]->rachInd, sizeof(RachIndInfo)); + SCH_FREE(cell->raReq[ueId-1], sizeof(SchRaReq)); + return false; + } - /* If K0-K2 combination not found, no scheduling happens */ - if(!k2Found) - { - ueIdx++; - continue; - } + /* If K0-K2 combination not found, no scheduling happens */ + if(!k2Found) + return false; - /* Allocate memory for RAR PDCCH slot, pointer will be checked at schProcessSlotInd() */ - SCH_ALLOC(dciSlotAlloc, sizeof(RarAlloc)); - if(dciSlotAlloc == NULLP) - { - DU_LOG("\nERROR --> SCH : Memory Allocation failed for dciSlotAlloc"); - return; - } - cell->schDlSlotInfo[dciSlot]->rarAlloc = dciSlotAlloc; + /* Allocate memory for RAR PDCCH slot, pointer will be checked at schProcessSlotInd() */ + SCH_ALLOC(dciSlotAlloc, sizeof(RarAlloc)); + if(dciSlotAlloc == NULLP) + { + DU_LOG("\nERROR --> SCH : Memory Allocation failed for dciSlotAlloc"); + return false; + } + cell->schDlSlotInfo[dciSlot]->rarAlloc[ueId-1] = dciSlotAlloc; - /* Fill PDCCH and PDSCH scheduling information for RAR */ - if((schFillRar(cell, rarTime, ueIdx, dciSlotAlloc, k0Index)) != ROK) - { - DU_LOG("\nERROR --> SCH: Scheduling of RAR failed in slot [%d]", rarSlot); - SCH_FREE(dciSlotAlloc, sizeof(RarAlloc)); - cell->schDlSlotInfo[dciSlot]->rarAlloc = NULLP; - return; - } + /* Fill PDCCH and PDSCH scheduling information for RAR */ + if((schFillRar(cell, rarTime, ueId, dciSlotAlloc, k0Index)) != ROK) + { + DU_LOG("\nERROR --> SCH: Scheduling of RAR failed in slot [%d]", rarSlot); + SCH_FREE(dciSlotAlloc, sizeof(RarAlloc)); + cell->schDlSlotInfo[dciSlot]->rarAlloc[ueId-1] = NULLP; + return false; + } - /* Allocate resources for msg3 */ - msg3PuschInfo = schAllocMsg3Pusch(cell->instIdx, cell->raReq[ueIdx]->rachInd->crnti, k2Index, msg3Time); - if(msg3PuschInfo) + /* Allocate resources for msg3 */ + msg3PuschInfo = schAllocMsg3Pusch(cell->instIdx, cell->raReq[ueId-1]->rachInd->crnti, k2Index, msg3Time); + if(msg3PuschInfo) + { + /* Fill RAR info */ + dciSlotAlloc->rarInfo.raRnti = cell->raReq[ueId-1]->raRnti; + dciSlotAlloc->rarInfo.tcrnti = cell->raReq[ueId-1]->rachInd->crnti; + dciSlotAlloc->rarInfo.RAPID = cell->raReq[ueId-1]->rachInd->preambleIdx; + dciSlotAlloc->rarInfo.ta = cell->raReq[ueId-1]->rachInd->timingAdv; + dciSlotAlloc->rarInfo.ulGrant.bwpSize = cell->cellCfg.schInitialUlBwp.bwp.freqAlloc.numPrb; + /* Spec 38.213, section 8.2, 0 : MSG3 PUSCH will be transmitted without frequency hopping */ + dciSlotAlloc->rarInfo.ulGrant.freqHopFlag = 0; + dciSlotAlloc->rarInfo.ulGrant.msg3FreqAlloc.startPrb = msg3PuschInfo->fdAlloc.startPrb; + dciSlotAlloc->rarInfo.ulGrant.msg3FreqAlloc.numPrb = msg3PuschInfo->fdAlloc.numPrb; + dciSlotAlloc->rarInfo.ulGrant.k2Index = k2Index; + dciSlotAlloc->rarInfo.ulGrant.mcs = msg3PuschInfo->tbInfo.mcs; + dciSlotAlloc->rarInfo.ulGrant.tpc = 3; /* TODO : Check appropriate value to be filled */ + /* Spec 38.213, section 8.2 : In a contention based random access + * procedure, the CSI request field is reserved. */ + dciSlotAlloc->rarInfo.ulGrant.csiReq = 0; + } + + /* Check if both DCI and RAR are sent in the same slot. + * If not, allocate memory RAR PDSCH slot to store RAR info + */ + if(dciSlot == rarSlot) + dciSlotAlloc->pduPres = BOTH; + else + { + /* Allocate memory to schedule rarSlot to send RAR, pointer will be checked at schProcessSlotInd() */ + SCH_ALLOC(rarSlotAlloc, sizeof(RarAlloc)); + if(rarSlotAlloc == NULLP) { - /* Fill RAR info */ - dciSlotAlloc->rarInfo.raRnti = cell->raReq[ueIdx]->raRnti; - dciSlotAlloc->rarInfo.tcrnti = cell->raReq[ueIdx]->rachInd->crnti; - dciSlotAlloc->rarInfo.RAPID = cell->raReq[ueIdx]->rachInd->preambleIdx; - dciSlotAlloc->rarInfo.ta = cell->raReq[ueIdx]->rachInd->timingAdv; - dciSlotAlloc->rarInfo.ulGrant.bwpSize = cell->cellCfg.schInitialUlBwp.bwp.freqAlloc.numPrb; - /* Spec 38.213, section 8.2, 0 : MSG3 PUSCH will be transmitted without frequency hopping */ - dciSlotAlloc->rarInfo.ulGrant.freqHopFlag = 0; - dciSlotAlloc->rarInfo.ulGrant.msg3FreqAlloc.startPrb = msg3PuschInfo->fdAlloc.startPrb; - dciSlotAlloc->rarInfo.ulGrant.msg3FreqAlloc.numPrb = msg3PuschInfo->fdAlloc.numPrb; - dciSlotAlloc->rarInfo.ulGrant.k2Index = k2Index; - dciSlotAlloc->rarInfo.ulGrant.mcs = msg3PuschInfo->tbInfo.mcs; - dciSlotAlloc->rarInfo.ulGrant.tpc = 3; /* TODO : Check appropriate value to be filled */ - /* Spec 38.213, section 8.2 : In a contention based random access - * procedure, the CSI request field is reserved. */ - dciSlotAlloc->rarInfo.ulGrant.csiReq = 0; + DU_LOG("\nERROR --> SCH : Memory Allocation failed for rarSlotAlloc"); + SCH_FREE(dciSlotAlloc, sizeof(RarAlloc)); + cell->schDlSlotInfo[dciSlot]->rarAlloc[ueId-1] = NULLP; + return false; } + cell->schDlSlotInfo[rarSlot]->rarAlloc[ueId-1] = rarSlotAlloc; - /* Check if both DCI and RAR are sent in the same slot. - * If not, allocate memory RAR PDSCH slot to store RAR info - */ - if(dciSlot == rarSlot) - dciSlotAlloc->pduPres = BOTH; - else - { - /* Allocate memory to schedule rarSlot to send RAR, pointer will be checked at schProcessSlotInd() */ - SCH_ALLOC(rarSlotAlloc, sizeof(RarAlloc)); - if(rarSlotAlloc == NULLP) - { - DU_LOG("\nERROR --> SCH : Memory Allocation failed for rarSlotAlloc"); - SCH_FREE(dciSlotAlloc, sizeof(RarAlloc)); - cell->schDlSlotInfo[dciSlot]->rarAlloc = NULLP; - return; - } - cell->schDlSlotInfo[rarSlot]->rarAlloc = rarSlotAlloc; + /* Copy all RAR info */ + memcpy(rarSlotAlloc, dciSlotAlloc, sizeof(RarAlloc)); + rarSlotAlloc->rarPdcchCfg.dci.pdschCfg = &rarSlotAlloc->rarPdschCfg; - /* Copy all RAR info */ - memcpy(rarSlotAlloc, dciSlotAlloc, sizeof(RarAlloc)); - rarSlotAlloc->rarPdcchCfg.dci.pdschCfg = &rarSlotAlloc->rarPdschCfg; + /* Assign correct PDU types in corresponding slots */ + rarSlotAlloc->pduPres = PDSCH_PDU; + dciSlotAlloc->pduPres = PDCCH_PDU; + dciSlotAlloc->pdschSlot = rarSlot; + } - /* Assign correct PDU types in corresponding slots */ - rarSlotAlloc->pduPres = PDSCH_PDU; - dciSlotAlloc->pduPres = PDCCH_PDU; - dciSlotAlloc->pdschSlot = rarSlot; - } + cell->schDlSlotInfo[dciSlot]->pdcchUe = ueId; + cell->schDlSlotInfo[rarSlot]->pdschUe = ueId; + cell->schUlSlotInfo[msg3Time.slot]->puschUe = ueId; - /* Create raCb at SCH */ - createSchRaCb(cell->raReq[ueIdx]->rachInd->crnti, cell->instIdx); + /* Create raCb at SCH */ + createSchRaCb(cell->raReq[ueId-1]->rachInd->crnti, cell->instIdx); - SCH_FREE(cell->raReq[ueIdx]->rachInd, sizeof(RachIndInfo)); - SCH_FREE(cell->raReq[ueIdx], sizeof(SchRaReq)); - } - ueIdx++; - } /* End of while(ueIdx < MAX_NUM_UE) */ + /* Remove RachInd from pending RA request list */ + SCH_FREE(cell->raReq[ueId-1]->rachInd, sizeof(RachIndInfo)); + SCH_FREE(cell->raReq[ueId-1], sizeof(SchRaReq)); + + return true; + } + return false; } /** @@ -577,9 +583,11 @@ uint8_t schProcessRachInd(RachIndInfo *rachInd, Inst schInst) /* Adding window size to window start time to get window end time */ ADD_DELTA_TO_TIME(raReq->winStartTime, raReq->winEndTime, winNumSlots); - cell->raReq[ueIdx -1] = raReq; + /* Adding UE Id to list of pending UEs to be scheduled */ + addUeToBeScheduled(cell, ueIdx); + return ROK; } @@ -598,7 +606,7 @@ uint8_t schProcessRachInd(RachIndInfo *rachInd, Inst schInst) * @param[in] offset to pointA to determine freq alloc * @return ROK **/ -uint8_t schFillRar(SchCellCb *cell, SlotTimingInfo rarTime, uint16_t ueIdx, RarAlloc *rarAlloc, uint8_t k0Index) +uint8_t schFillRar(SchCellCb *cell, SlotTimingInfo rarTime, uint16_t ueId, RarAlloc *rarAlloc, uint8_t k0Index) { uint8_t coreset0Idx = 0; uint8_t firstSymbol = 0, numSymbols = 0; @@ -648,7 +656,7 @@ uint8_t schFillRar(SchCellCb *cell, SlotTimingInfo rarTime, uint16_t ueIdx, RarA pdcch->coresetCfg.shiftIndex = cell->cellCfg.phyCellId; pdcch->coresetCfg.precoderGranularity = 0; /* sameAsRegBundle */ pdcch->numDlDci = 1; - pdcch->dci.rnti = cell->raReq[ueIdx]->raRnti; /* RA-RNTI */ + pdcch->dci.rnti = cell->raReq[ueId-1]->raRnti; /* RA-RNTI */ pdcch->dci.scramblingId = cell->cellCfg.phyCellId; pdcch->dci.scramblingRnti = 0; pdcch->dci.cceIndex = 4; /* considering SIB1 is sent at cce 0-1-2-3 */ @@ -665,7 +673,7 @@ uint8_t schFillRar(SchCellCb *cell, SlotTimingInfo rarTime, uint16_t ueIdx, RarA /* fill the PDSCH PDU */ uint8_t cwCount = 0; pdsch->pduBitmap = 0; /* PTRS and CBG params are excluded */ - pdsch->rnti = cell->raReq[ueIdx]->raRnti; /* RA-RNTI */ + pdsch->rnti = cell->raReq[ueId-1]->raRnti; /* RA-RNTI */ pdsch->pduIndex = 0; pdsch->numCodewords = 1; for(cwCount = 0; cwCount < pdsch->numCodewords; cwCount++) @@ -693,6 +701,7 @@ uint8_t schFillRar(SchCellCb *cell, SlotTimingInfo rarTime, uint16_t ueIdx, RarA pdsch->dmrs.nrOfDmrsSymbols = NUM_DMRS_SYMBOLS; pdsch->dmrs.dmrsAddPos = DMRS_ADDITIONAL_POS; + pdsch->pdschTimeAlloc.rowIndex = k0Index; pdsch->pdschTimeAlloc.timeAlloc.startSymb = initialBwp->pdschCommon.timeDomRsrcAllocList[k0Index].startSymbol; pdsch->pdschTimeAlloc.timeAlloc.numSymb = initialBwp->pdschCommon.timeDomRsrcAllocList[k0Index].lengthSymbol; diff --git a/src/5gnrsch/sch_slot_ind.c b/src/5gnrsch/sch_slot_ind.c index 913111cac..33e5f2ab9 100644 --- a/src/5gnrsch/sch_slot_ind.c +++ b/src/5gnrsch/sch_slot_ind.c @@ -290,10 +290,11 @@ uint8_t schFillBoGrantDlSchedInfo(SchCellCb *cell, DlSchedInfo *dlSchedInfo, DlM ((ueCb->dlLcPrbEst.dedLcInfo != NULL) && (ueCb->dlLcPrbEst.dedLcInfo->dedLcList.count == 0))) { DU_LOG("\nDEBUG --> SCH : No pending BO for any LC id\n"); + UNSET_ONE_BIT(ueIdx, cell->boIndBitMap); /* Free the dl ded msg info allocated in macSchDlRlcBoInfo */ SCH_FREE(dlMsgAlloc, sizeof(DlMsgAlloc)); dlSchedInfo->dlMsgAlloc = NULLP; - return ROK; + continue; } /*[Step3]: Calculate Best FREE BLOCK with MAX PRB count*/ @@ -422,12 +423,14 @@ uint8_t schFillBoGrantDlSchedInfo(SchCellCb *cell, DlSchedInfo *dlSchedInfo, DlM * ****************************************************************/ uint8_t schProcessSlotInd(SlotTimingInfo *slotInd, Inst schInst) { - uint8_t ueIdx, lcgIdx, ret = ROK; - uint16_t slot; - DlSchedInfo dlSchedInfo; + uint8_t ueId, ueIdx, lcgIdx, ret = ROK; + uint16_t slot; + bool isRarScheduled = false; + CmLList *pendingUeNode; + DlSchedInfo dlSchedInfo; DlBrdcstAlloc *dlBrdcstAlloc = NULLP; - DlMsgAlloc *dlMsgAlloc = NULLP; - SchCellCb *cell = NULLP; + DlMsgAlloc *dlMsgAlloc = NULLP; + SchCellCb *cell = NULLP; memset(&dlSchedInfo,0,sizeof(DlSchedInfo)); dlSchedInfo.dlMsgAlloc = NULLP; @@ -482,15 +485,41 @@ uint8_t schProcessSlotInd(SlotTimingInfo *slotInd, Inst schInst) } } - /* Check for Pending RA Requests */ - schProcessRaReq(*slotInd, cell); + /* Select first UE in the linked list to be scheduled next */ + pendingUeNode = cell->ueToBeScheduled.first; + if(pendingUeNode) + { + ueId = *(uint8_t *)(pendingUeNode->node); + + /* Check for Pending RA Requests */ + if(cell->raReq[ueId-1] != NULLP) + { + isRarScheduled = schProcessRaReq(cell, *slotInd, ueId); + /* If RAR scheduled for this UE, remove from linked list since no + * pending msgs for this UE */ + if(isRarScheduled) + { + SCH_FREE(pendingUeNode->node, sizeof(uint8_t)); + deleteNodeFromLList(&cell->ueToBeScheduled, pendingUeNode); + } + /* If RAR couldnt be scheduled, put this UE at the end of linked + * list to be scheduled later */ + else + { + cmLListAdd2Tail(&cell->ueToBeScheduled, cmLListDelFrm(&cell->ueToBeScheduled, pendingUeNode)); + } + } + } /* Check for RAR */ - if(cell->schDlSlotInfo[dlSchedInfo.schSlotValue.rarTime.slot]->rarAlloc != NULLP) + for(ueIdx=0; ueIdxschDlSlotInfo[slot]->rarAlloc; - cell->schDlSlotInfo[slot]->rarAlloc = NULLP; + if(cell->schDlSlotInfo[dlSchedInfo.schSlotValue.rarTime.slot]->rarAlloc[ueIdx] != NULLP) + { + slot = dlSchedInfo.schSlotValue.rarTime.slot; + dlSchedInfo.rarAlloc[ueIdx] = cell->schDlSlotInfo[slot]->rarAlloc[ueIdx]; + cell->schDlSlotInfo[slot]->rarAlloc[ueIdx] = NULLP; + } } schProcessMsg4Req(cell, *slotInd); diff --git a/src/5gnrsch/sch_ue_mgr.c b/src/5gnrsch/sch_ue_mgr.c index ce02fd4e2..5219e6afe 100644 --- a/src/5gnrsch/sch_ue_mgr.c +++ b/src/5gnrsch/sch_ue_mgr.c @@ -990,10 +990,11 @@ void deleteSchUeCb(SchUeCb *ueCb) * ****************************************************************/ uint8_t MacSchUeDeleteReq(Pst *pst, SchUeDelete *ueDelete) { - uint8_t idx=0, ueIdx=0, ret=ROK; - ErrorCause result; + uint8_t idx=0, ueId=0, ueIdToDel=0, ret=ROK; + ErrorCause result; SchCellCb *cellCb = NULLP; Inst inst = pst->dstInst - 1; + CmLList *node = NULL, *next = NULL; #ifdef CALL_FLOW_DEBUG_LOG DU_LOG("\nCall Flow: ENTMAC -> ENTSCH : EVENT_UE_DELETE_REQ_TO_SCH\n"); @@ -1015,10 +1016,25 @@ uint8_t MacSchUeDeleteReq(Pst *pst, SchUeDelete *ueDelete) } else { - GET_UE_IDX(ueDelete->crnti, ueIdx); - if(( cellCb->ueCb[ueIdx-1].crnti == ueDelete->crnti) && ( cellCb->ueCb[ueIdx-1].state == SCH_UE_STATE_ACTIVE)) + GET_UE_IDX(ueDelete->crnti, ueId); + if(( cellCb->ueCb[ueId-1].crnti == ueDelete->crnti) && ( cellCb->ueCb[ueId-1].state == SCH_UE_STATE_ACTIVE)) { - deleteSchUeCb(&cellCb->ueCb[ueIdx-1]); + deleteSchUeCb(&cellCb->ueCb[ueId-1]); + + /* Remove UE from ueToBeScheduled list */ + node = cellCb->ueToBeScheduled.first; + while(node) + { + next = node->next; + ueId = *(uint8_t *)node->node; + if(ueId == ueIdToDel) + { + SCH_FREE(node->node, sizeof(uint8_t)); + cmLListDelFrm(&cellCb->ueToBeScheduled, node); + break; + } + node = next; + } cellCb->numActvUe--; result = NOT_APPLICABLE; } @@ -1099,8 +1115,8 @@ uint8_t SchSendCellDeleteRspToMac(SchCellDelete *ueDelete, Inst inst, SchMacRsp void deleteSchCellCb(SchCellCb *cellCb) { uint8_t sliceIdx=0, slotIdx=0; - CmLListCp *list; - CmLList *node, *next; + CmLListCp *list=NULL; + CmLList *node=NULL, *next=NULL; if(cellCb->schDlSlotInfo) { @@ -1147,6 +1163,17 @@ void deleteSchCellCb(SchCellCb *cellCb) SCH_FREE(cellCb->cellCfg.snssai, cellCb->cellCfg.numSliceSupport*sizeof(Snssai*)); } SCH_FREE(cellCb->cellCfg.rrmPolicy, sizeof(SchRrmPolicy)); + + /* Remove all UE from ueToBeScheduled list and deallocate */ + node = cellCb->ueToBeScheduled.first; + while(node) + { + next = node->next; + SCH_FREE(node->node, sizeof(uint8_t)); + cmLListDelFrm(&cellCb->ueToBeScheduled, node); + node = next; + } + memset(cellCb, 0, sizeof(SchCellCb)); } diff --git a/src/cm/common_def.h b/src/cm/common_def.h index 89b5d8985..c5cd25610 100644 --- a/src/cm/common_def.h +++ b/src/cm/common_def.h @@ -57,7 +57,7 @@ /* MAX values */ #define MAX_NUM_CELL 1 #define MAX_NUM_MU 4 -#define MAX_NUM_UE 2 +#define MAX_NUM_UE 3 #define MAX_NUM_UE_PER_TTI 1 #define MAX_NUM_LC MAX_DRB_LCID + 1 /*Spec 38.331: Sec 6.4: maxLC-ID Keyword*/ #define MAX_NUM_SRB 3 /* Max. no of Srbs */ diff --git a/src/cm/mac_sch_interface.h b/src/cm/mac_sch_interface.h index 1905d651a..5f6578aca 100644 --- a/src/cm/mac_sch_interface.h +++ b/src/cm/mac_sch_interface.h @@ -946,11 +946,7 @@ typedef struct dlSchedInfo DlBrdcstAlloc brdcstAlloc; /* Allocation for RAR message */ - //uint8_t isRarPres; - RarAlloc *rarAlloc; - - /* Allocation from MSG4 */ - //Msg4Alloc *msg4Alloc; + RarAlloc *rarAlloc[MAX_NUM_UE]; /* UL grant in response to BSR */ DciInfo *ulGrant; diff --git a/src/phy_stub/phy_stub.h b/src/phy_stub/phy_stub.h index 00620a961..22d968818 100644 --- a/src/phy_stub/phy_stub.h +++ b/src/phy_stub/phy_stub.h @@ -30,6 +30,7 @@ /*UE Ids for RACH IND*/ #define UE_IDX_0 0 #define UE_IDX_1 1 +#define UE_IDX_2 2 bool slotIndicationStarted; uint16_t sfnValue; diff --git a/src/phy_stub/phy_stub_msg_hdl.c b/src/phy_stub/phy_stub_msg_hdl.c index 168ea65e4..a930709dc 100644 --- a/src/phy_stub/phy_stub_msg_hdl.c +++ b/src/phy_stub/phy_stub_msg_hdl.c @@ -1042,23 +1042,30 @@ S16 l1HdlUlTtiReq(uint16_t msgLen, void *msg) numPdus--; } + /* Send RACH Ind to L2 for first UE */ if(ueDb.ueCb[UE_IDX_0].rachIndSent == false && ulTtiReq->sfn == 16 && ulTtiReq->slot == 6) { ueDb.ueCb[UE_IDX_0].rachIndSent = true; l1BuildAndSendRachInd(ulTtiReq->slot, ulTtiReq->sfn); ueDb.numActvUe++; } - - //Following can be enabled to test with a second UE #if 0 + /* Send RACH Ind to L2 for second UE */ if(ueDb.ueCb[UE_IDX_1].rachIndSent == false && ulTtiReq->sfn == 304 && ulTtiReq->slot == 0) { ueDb.ueCb[UE_IDX_1].rachIndSent = true; l1BuildAndSendRachInd(ulTtiReq->slot, ulTtiReq->sfn); ueDb.numActvUe++; } -#endif + /* Send RACH Ind to L2 for third UE */ + if(ueDb.ueCb[UE_IDX_2].rachIndSent == false && ulTtiReq->sfn == 526 && ulTtiReq->slot == 0) + { + ueDb.ueCb[UE_IDX_2].rachIndSent = true; + l1BuildAndSendRachInd(ulTtiReq->slot, ulTtiReq->sfn); + ueDb.numActvUe++; + } +#endif MAC_FREE(msg, msgLen); #endif return ROK;