From b1418abe84f847cbe004fb10153a6997aab51708 Mon Sep 17 00:00:00 2001 From: Marco Miozzo Date: Fri, 26 Oct 2012 15:57:59 +0200 Subject: [PATCH] Update RR and PF schedulers for avoiding the allocation of UEs that do not have HARQ processes available for transmitting --- src/lte/model/pf-ff-mac-scheduler.cc | 61 ++++++++++++++++++-------- src/lte/model/pf-ff-mac-scheduler.h | 8 ++++ src/lte/model/rr-ff-mac-scheduler.cc | 64 +++++++++++++++++++--------- src/lte/model/rr-ff-mac-scheduler.h | 8 ++++ 4 files changed, 102 insertions(+), 39 deletions(-) diff --git a/src/lte/model/pf-ff-mac-scheduler.cc b/src/lte/model/pf-ff-mac-scheduler.cc index d1418e4c1..52daadd66 100644 --- a/src/lte/model/pf-ff-mac-scheduler.cc +++ b/src/lte/model/pf-ff-mac-scheduler.cc @@ -467,10 +467,49 @@ PfFfMacScheduler::LcActivePerFlow (uint16_t rnti) } +uint8_t +PfFfMacScheduler::HarqProcessAvailability (uint16_t rnti) +{ + NS_LOG_FUNCTION (this << rnti); + + std::map ::iterator it = m_dlHarqCurrentProcessId.find (rnti); + if (it==m_dlHarqCurrentProcessId.end ()) + { + NS_FATAL_ERROR ("No Process Id found for this RNTI " << rnti); + } + std::map ::iterator itStat = m_dlHarqProcessesStatus.find (rnti); + if (itStat==m_dlHarqProcessesStatus.end ()) + { + NS_FATAL_ERROR ("No Process Id Statusfound for this RNTI " << rnti); + } + uint8_t i = (*it).second; + do + { + i = (i + 1) % HARQ_PROC_NUM; + // NS_LOG_DEBUG (this << " check i " << (uint16_t)i << " stat " << (uint16_t)(*itStat).second.at (i)); + } while ( ((*itStat).second.at (i)!=0)&&(i!=(*it).second)); + if ((*itStat).second.at (i)==0) + { + return (true); + } + else + { + return (false); // return a not valid harq proc id + } +} + + + uint8_t PfFfMacScheduler::UpdateHarqProcessId (uint16_t rnti) { NS_LOG_FUNCTION (this << rnti); + + if (m_harqOn == false) + { + return (0); + } + std::map ::iterator it = m_dlHarqCurrentProcessId.find (rnti); if (it==m_dlHarqCurrentProcessId.end ()) @@ -495,7 +534,7 @@ PfFfMacScheduler::UpdateHarqProcessId (uint16_t rnti) } else { - return (9); // return a not valid harq proc id + NS_FATAL_ERROR ("No HARQ process available for RNTI " << rnti << " check before update with HarqProcessAvailability"); } return ((*it).second); @@ -778,9 +817,9 @@ PfFfMacScheduler::DoSchedDlTriggerReq (const struct FfMacSchedSapProvider::Sched for (it = m_flowStatsDl.begin (); it != m_flowStatsDl.end (); it++) { std::set ::iterator itRnti = rntiAllocated.find ((*it).first); - if (itRnti != rntiAllocated.end ()) + if ((itRnti != rntiAllocated.end ())||(!HarqProcessAvailability ((*it).first))) { - // UE already allocated for HARQ -> drop it + // UE already allocated for HARQ or without HARQ process available -> drop it continue; } std::map ::iterator itCqi; @@ -891,21 +930,7 @@ PfFfMacScheduler::DoSchedDlTriggerReq (const struct FfMacSchedSapProvider::Sched // create the DlDciListElement_s DlDciListElement_s newDci; newDci.m_rnti = (*itMap).first; - if (m_harqOn == true) - { - newDci.m_harqProcess = UpdateHarqProcessId ((*itMap).first); - if (newDci.m_harqProcess>8) - { - // not valid HARQ ID -> no more HARQ proc available, stop allocation for this user - itMap++; - NS_LOG_DEBUG (this << " All HARQ process busy, drop UE allocation, RNTI " << (*itMap).first); - continue; - } - } - else - { - newDci.m_harqProcess = 0; - } + newDci.m_harqProcess = UpdateHarqProcessId ((*itMap).first); uint16_t lcActives = LcActivePerFlow ((*itMap).first); // NS_LOG_DEBUG (this << "Allocate user " << newEl.m_rnti << " rbg " << lcActives); diff --git a/src/lte/model/pf-ff-mac-scheduler.h b/src/lte/model/pf-ff-mac-scheduler.h index 5f13ee416..cacb99598 100644 --- a/src/lte/model/pf-ff-mac-scheduler.h +++ b/src/lte/model/pf-ff-mac-scheduler.h @@ -163,6 +163,14 @@ private: * \return the process id value */ uint8_t UpdateHarqProcessId (uint16_t rnti); + + /** + * \brief Return the availability of free process for the RNTI specified + * + * \param rnti the RNTI of the UE to be updated + * \return the process id value + */ + uint8_t HarqProcessAvailability (uint16_t rnti); Ptr m_amc; diff --git a/src/lte/model/rr-ff-mac-scheduler.cc b/src/lte/model/rr-ff-mac-scheduler.cc index 179320e1f..5cd537bfa 100644 --- a/src/lte/model/rr-ff-mac-scheduler.cc +++ b/src/lte/model/rr-ff-mac-scheduler.cc @@ -435,11 +435,50 @@ RrFfMacScheduler::SortRlcBufferReq (FfMacSchedSapProvider::SchedDlRlcBufferReqPa } +uint8_t +RrFfMacScheduler::HarqProcessAvailability (uint16_t rnti) +{ + NS_LOG_FUNCTION (this << rnti); + + std::map ::iterator it = m_dlHarqCurrentProcessId.find (rnti); + if (it==m_dlHarqCurrentProcessId.end ()) + { + NS_FATAL_ERROR ("No Process Id found for this RNTI " << rnti); + } + std::map ::iterator itStat = m_dlHarqProcessesStatus.find (rnti); + if (itStat==m_dlHarqProcessesStatus.end ()) + { + NS_FATAL_ERROR ("No Process Id Statusfound for this RNTI " << rnti); + } + uint8_t i = (*it).second; + do + { + i = (i + 1) % HARQ_PROC_NUM; + // NS_LOG_DEBUG (this << " check i " << (uint16_t)i << " stat " << (uint16_t)(*itStat).second.at (i)); + } while ( ((*itStat).second.at (i)!=0)&&(i!=(*it).second)); + if ((*itStat).second.at (i)==0) + { + return (true); + } + else + { + return (false); // return a not valid harq proc id + } +} + + + uint8_t RrFfMacScheduler::UpdateHarqProcessId (uint16_t rnti) { NS_LOG_FUNCTION (this << rnti); + + if (m_harqOn == false) + { + return (0); + } + std::map ::iterator it = m_dlHarqCurrentProcessId.find (rnti); if (it==m_dlHarqCurrentProcessId.end ()) { @@ -742,7 +781,9 @@ RrFfMacScheduler::DoSchedDlTriggerReq (const struct FfMacSchedSapProvider::Sched if ( (((*it).m_rlcTransmissionQueueSize > 0) || ((*it).m_rlcRetransmissionQueueSize > 0) || ((*it).m_rlcStatusPduSize > 0)) - && (itRnti == rntiAllocated.end ()) ) // UE must not be allocated for HARQ retx + && (itRnti == rntiAllocated.end ()) // UE must not be allocated for HARQ retx + && (HarqProcessAvailability ((*it).m_rnti)) ) // UE needs HARQ proc free + { std::map ::iterator itCqi = m_p10CqiRxed.find ((*it).m_rnti); uint8_t cqi = 0; @@ -843,26 +884,7 @@ RrFfMacScheduler::DoSchedDlTriggerReq (const struct FfMacSchedSapProvider::Sched // create the DlDciListElement_s DlDciListElement_s newDci; newDci.m_rnti = (*it).m_rnti; - if (m_harqOn == true) - { - newDci.m_harqProcess = UpdateHarqProcessId ((*it).m_rnti); - if (newDci.m_harqProcess>8) - { - // not valid HARQ ID -> no more HARQ proc available, stop allocation for this user - it++; - if (it == m_rlcBufferReq.end ()) - { - // restart from the first - it = m_rlcBufferReq.begin (); - } - NS_LOG_DEBUG (this << " All HARQ process busy, drop UE allocation"); - continue; - } - } - else - { - newDci.m_harqProcess = 0; - } + newDci.m_harqProcess = UpdateHarqProcessId ((*it).m_rnti); newDci.m_resAlloc = 0; newDci.m_rbBitmap = 0; std::map ::iterator itCqi = m_p10CqiRxed.find (newEl.m_rnti); diff --git a/src/lte/model/rr-ff-mac-scheduler.h b/src/lte/model/rr-ff-mac-scheduler.h index a1d5db2e5..07edf3896 100644 --- a/src/lte/model/rr-ff-mac-scheduler.h +++ b/src/lte/model/rr-ff-mac-scheduler.h @@ -148,6 +148,14 @@ private: * \return the process id value */ uint8_t UpdateHarqProcessId (uint16_t rnti); + + /** + * \brief Return the availability of free process for the RNTI specified + * + * \param rnti the RNTI of the UE to be updated + * \return the process id value + */ + uint8_t HarqProcessAvailability (uint16_t rnti); Ptr m_amc;