mirror of https://github.com/PentHertz/srsLTE.git
sched,nr: created time-domain round-robin scheduler
This commit is contained in:
parent
eecfee365b
commit
a61d59993f
|
@ -15,6 +15,7 @@
|
|||
|
||||
#include "sched_nr_cfg.h"
|
||||
#include "sched_nr_grant_allocator.h"
|
||||
#include "sched_nr_time_rr.h"
|
||||
#include "srsran/adt/pool/cached_alloc.h"
|
||||
|
||||
namespace srsenb {
|
||||
|
@ -59,6 +60,7 @@ public:
|
|||
|
||||
// channel-specific schedulers
|
||||
ra_sched ra;
|
||||
std::unique_ptr<sched_nr_base> data_sched;
|
||||
|
||||
// Stores pending allocations and PRB bitmaps
|
||||
bwp_res_grid grid;
|
||||
|
|
|
@ -1,8 +1,47 @@
|
|||
//
|
||||
// Created by xico on 30/07/21.
|
||||
//
|
||||
/**
|
||||
*
|
||||
* \section COPYRIGHT
|
||||
*
|
||||
* Copyright 2013-2021 Software Radio Systems Limited
|
||||
*
|
||||
* By using this file, you agree to the terms and conditions set
|
||||
* forth in the LICENSE file which can be found at the top level of
|
||||
* the distribution.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SRSRAN_SCHED_NR_TIME_RR_H
|
||||
#define SRSRAN_SCHED_NR_TIME_RR_H
|
||||
|
||||
#endif //SRSRAN_SCHED_NR_TIME_RR_H
|
||||
#include "sched_nr_grant_allocator.h"
|
||||
#include "srsran/common/slot_point.h"
|
||||
|
||||
namespace srsenb {
|
||||
namespace sched_nr_impl {
|
||||
|
||||
/**
|
||||
* Base class for scheduler algorithms implementations
|
||||
*/
|
||||
class sched_nr_base
|
||||
{
|
||||
public:
|
||||
virtual ~sched_nr_base() = default;
|
||||
|
||||
virtual void sched_dl_users(slot_ue_map_t& ue_db, bwp_slot_allocator& slot_alloc) = 0;
|
||||
virtual void sched_ul_users(slot_ue_map_t& ue_db, bwp_slot_allocator& slot_alloc) = 0;
|
||||
|
||||
protected:
|
||||
srslog::basic_logger& logger = srslog::fetch_basic_logger("MAC");
|
||||
};
|
||||
|
||||
class sched_nr_time_rr : public sched_nr_base
|
||||
{
|
||||
public:
|
||||
void sched_dl_users(slot_ue_map_t& ue_db, bwp_slot_allocator& slot_alloc) override;
|
||||
void sched_ul_users(slot_ue_map_t& ue_db, bwp_slot_allocator& slot_alloc) override;
|
||||
};
|
||||
|
||||
} // namespace sched_nr_impl
|
||||
} // namespace srsenb
|
||||
|
||||
#endif // SRSRAN_SCHED_NR_TIME_RR_H
|
||||
|
|
|
@ -18,6 +18,7 @@ set(SOURCES mac_nr.cc
|
|||
sched_nr_helpers.cc
|
||||
sched_nr_cell.cc
|
||||
sched_nr_rb.cc
|
||||
sched_nr_time_rr.cc
|
||||
harq_softbuffer.cc)
|
||||
|
||||
add_library(srsgnb_mac STATIC ${SOURCES})
|
||||
|
|
|
@ -153,7 +153,9 @@ int ra_sched::dl_rach_info(const dl_sched_rar_info_t& rar_info)
|
|||
return SRSRAN_SUCCESS;
|
||||
}
|
||||
|
||||
bwp_ctxt::bwp_ctxt(const bwp_params& bwp_cfg) : cfg(&bwp_cfg), ra(bwp_cfg), grid(bwp_cfg) {}
|
||||
bwp_ctxt::bwp_ctxt(const bwp_params& bwp_cfg) :
|
||||
cfg(&bwp_cfg), ra(bwp_cfg), grid(bwp_cfg), data_sched(new sched_nr_time_rr())
|
||||
{}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
|
|
@ -1,4 +1,92 @@
|
|||
//
|
||||
// Created by xico on 30/07/21.
|
||||
//
|
||||
/**
|
||||
*
|
||||
* \section COPYRIGHT
|
||||
*
|
||||
* Copyright 2013-2021 Software Radio Systems Limited
|
||||
*
|
||||
* By using this file, you agree to the terms and conditions set
|
||||
* forth in the LICENSE file which can be found at the top level of
|
||||
* the distribution.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "srsenb/hdr/stack/mac/nr/sched_nr_time_rr.h"
|
||||
|
||||
namespace srsenb {
|
||||
namespace sched_nr_impl {
|
||||
|
||||
template <typename Predicate>
|
||||
bool round_robin_apply(slot_ue_map_t& ue_db, uint32_t rr_count, Predicate p)
|
||||
{
|
||||
if (ue_db.empty()) {
|
||||
return false;
|
||||
}
|
||||
auto it = ue_db.begin();
|
||||
std::advance(it, (rr_count % ue_db.size()));
|
||||
for (uint32_t count = 0; count < ue_db.size(); ++count, ++it) {
|
||||
if (it == ue_db.end()) {
|
||||
it = ue_db.begin();
|
||||
}
|
||||
if (p(it->second)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void sched_nr_time_rr::sched_dl_users(slot_ue_map_t& ue_db, bwp_slot_allocator& slot_alloc)
|
||||
{
|
||||
// Start with retxs
|
||||
if (round_robin_apply(ue_db, slot_alloc.get_pdcch_tti().to_uint(), [&slot_alloc](slot_ue& ue) {
|
||||
if (ue.h_dl != nullptr and not ue.h_dl->empty()) {
|
||||
alloc_result res = slot_alloc.alloc_pdsch(ue, ue.h_dl->prbs());
|
||||
if (res == alloc_result::success) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
})) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Move on to new txs
|
||||
round_robin_apply(ue_db, slot_alloc.get_pdcch_tti().to_uint(), [&slot_alloc](slot_ue& ue) {
|
||||
if (ue.h_dl != nullptr and ue.h_dl->empty()) {
|
||||
alloc_result res = slot_alloc.alloc_pdsch(ue, prb_interval{0, slot_alloc.cfg.cfg.rb_width});
|
||||
if (res == alloc_result::success) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
void sched_nr_time_rr::sched_ul_users(slot_ue_map_t& ue_db, bwp_slot_allocator& slot_alloc)
|
||||
{
|
||||
// Start with retxs
|
||||
if (round_robin_apply(ue_db, slot_alloc.get_pdcch_tti().to_uint(), [&slot_alloc](slot_ue& ue) {
|
||||
if (ue.h_ul != nullptr and not ue.h_ul->empty()) {
|
||||
alloc_result res = slot_alloc.alloc_pusch(ue, ue.h_ul->prbs());
|
||||
if (res == alloc_result::success) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
})) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Move on to new txs
|
||||
round_robin_apply(ue_db, slot_alloc.get_pdcch_tti().to_uint(), [&slot_alloc](slot_ue& ue) {
|
||||
if (ue.h_ul != nullptr and ue.h_ul->empty()) {
|
||||
alloc_result res = slot_alloc.alloc_pusch(ue, prb_interval{0, slot_alloc.cfg.cfg.rb_width});
|
||||
if (res == alloc_result::success) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace sched_nr_impl
|
||||
} // namespace srsenb
|
||||
|
|
|
@ -118,16 +118,7 @@ void slot_cc_worker::alloc_dl_ues()
|
|||
if (not cfg.sched_cfg.pdsch_enabled) {
|
||||
return;
|
||||
}
|
||||
if (slot_ues.empty()) {
|
||||
return;
|
||||
}
|
||||
slot_ue& ue = slot_ues.begin()->second;
|
||||
if (ue.h_dl == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
prb_interval prbs(0, cfg.bwps[0].N_rbg);
|
||||
bwp_alloc.alloc_pdsch(ue, prbs);
|
||||
cell.bwps[0].data_sched->sched_dl_users(slot_ues, bwp_alloc);
|
||||
}
|
||||
|
||||
void slot_cc_worker::alloc_ul_ues()
|
||||
|
@ -135,16 +126,7 @@ void slot_cc_worker::alloc_ul_ues()
|
|||
if (not cfg.sched_cfg.pusch_enabled) {
|
||||
return;
|
||||
}
|
||||
if (slot_ues.empty()) {
|
||||
return;
|
||||
}
|
||||
slot_ue& ue = slot_ues.begin()->second;
|
||||
if (ue.h_ul == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
prb_interval prbs(0, cfg.bwps[0].N_rbg);
|
||||
bwp_alloc.alloc_pusch(ue, prbs);
|
||||
cell.bwps[0].data_sched->sched_ul_users(slot_ues, bwp_alloc);
|
||||
}
|
||||
|
||||
void slot_cc_worker::log_result() const
|
||||
|
|
Loading…
Reference in New Issue