use unique_ptr for sched_ue database in scheduler. This will minimize the time spent locking while adding new users

This commit is contained in:
Francisco 2021-02-16 17:23:15 +00:00 committed by Francisco Paisana
parent 6a178693a8
commit 9546634b37
15 changed files with 102 additions and 100 deletions

View File

@ -85,14 +85,14 @@ protected:
bool is_generated(srslte::tti_point, uint32_t enb_cc_idx) const;
// Helper methods
template <typename Func>
int ue_db_access(uint16_t rnti, Func, const char* func_name = nullptr);
int ue_db_access_locked(uint16_t rnti, Func&& f, const char* func_name = nullptr);
// args
rrc_interface_mac* rrc = nullptr;
sched_args_t sched_cfg = {};
std::vector<sched_cell_params_t> sched_cell_params;
std::map<uint16_t, sched_ue> ue_db;
std::map<uint16_t, std::unique_ptr<sched_ue> > ue_db;
// independent schedulers for each carrier
std::vector<std::unique_ptr<carrier_sched> > carrier_schedulers;

View File

@ -25,10 +25,10 @@ class ra_sched;
class sched::carrier_sched
{
public:
explicit carrier_sched(rrc_interface_mac* rrc_,
std::map<uint16_t, sched_ue>* ue_db_,
uint32_t enb_cc_idx_,
sched_result_list* sched_results_);
explicit carrier_sched(rrc_interface_mac* rrc_,
std::map<uint16_t, std::unique_ptr<sched_ue> >* ue_db_,
uint32_t enb_cc_idx_,
sched_result_list* sched_results_);
~carrier_sched();
void reset();
void carrier_cfg(const sched_cell_params_t& sched_params_);
@ -50,11 +50,11 @@ private:
sf_sched* get_sf_sched(srslte::tti_point tti_rx);
// args
const sched_cell_params_t* cc_cfg = nullptr;
srslog::basic_logger& logger;
rrc_interface_mac* rrc = nullptr;
std::map<uint16_t, sched_ue>* ue_db = nullptr;
const uint32_t enb_cc_idx;
const sched_cell_params_t* cc_cfg = nullptr;
srslog::basic_logger& logger;
rrc_interface_mac* rrc = nullptr;
std::map<uint16_t, std::unique_ptr<sched_ue> >* ue_db = nullptr;
const uint32_t enb_cc_idx;
// Subframe scheduling logic
std::array<sf_sched, TTIMOD_SZ> sf_scheds;
@ -107,7 +107,7 @@ public:
using dl_sched_rar_t = sched_interface::dl_sched_rar_t;
using dl_sched_rar_grant_t = sched_interface::dl_sched_rar_grant_t;
explicit ra_sched(const sched_cell_params_t& cfg_, std::map<uint16_t, sched_ue>& ue_db_);
explicit ra_sched(const sched_cell_params_t& cfg_, sched_ue_list& ue_db_);
void dl_sched(sf_sched* tti_sched);
void ul_sched(sf_sched* sf_dl_sched, sf_sched* sf_msg3_sched);
int dl_rach_info(dl_sched_rar_info_t rar_info);
@ -115,9 +115,9 @@ public:
private:
// args
srslog::basic_logger& logger;
const sched_cell_params_t* cc_cfg = nullptr;
std::map<uint16_t, sched_ue>* ue_db = nullptr;
srslog::basic_logger& logger;
const sched_cell_params_t* cc_cfg = nullptr;
sched_ue_list* ue_db = nullptr;
std::deque<sf_sched::pending_rar_t> pending_rars;
uint32_t rar_aggr_level = 2;

View File

@ -38,8 +38,7 @@ class sched_ue
using bearer_cfg_t = sched_interface::ue_bearer_cfg_t;
public:
sched_ue();
void init(uint16_t rnti, const std::vector<sched_cell_params_t>& cell_list_params_);
sched_ue(uint16_t rnti, const std::vector<sched_cell_params_t>& cell_list_params_, const ue_cfg_t& cfg);
void new_subframe(tti_point tti_rx, uint32_t enb_cc_idx);
/*************************************************************
@ -204,7 +203,7 @@ private:
std::vector<sched_ue_cell> cells; ///< List of eNB cells that may be configured/activated/deactivated for the UE
};
using sched_ue_list = std::map<uint16_t, sched_ue>;
using sched_ue_list = std::map<uint16_t, std::unique_ptr<sched_ue> >;
} // namespace srsenb

View File

@ -25,8 +25,8 @@ class sched_base
public:
virtual ~sched_base() = default;
virtual void sched_dl_users(std::map<uint16_t, sched_ue>& ue_db, sf_sched* tti_sched) = 0;
virtual void sched_ul_users(std::map<uint16_t, sched_ue>& ue_db, sf_sched* tti_sched) = 0;
virtual void sched_dl_users(sched_ue_list& ue_db, sf_sched* tti_sched) = 0;
virtual void sched_ul_users(sched_ue_list& ue_db, sf_sched* tti_sched) = 0;
protected:
srslog::basic_logger& logger = srslog::fetch_basic_logger("MAC");

View File

@ -20,15 +20,15 @@ namespace srsenb {
class sched_time_pf final : public sched_base
{
using ue_cit_t = std::map<uint16_t, sched_ue>::const_iterator;
using ue_cit_t = sched_ue_list::const_iterator;
public:
sched_time_pf(const sched_cell_params_t& cell_params_, const sched_interface::sched_args_t& sched_args);
void sched_dl_users(std::map<uint16_t, sched_ue>& ue_db, sf_sched* tti_sched) override;
void sched_ul_users(std::map<uint16_t, sched_ue>& ue_db, sf_sched* tti_sched) override;
void sched_dl_users(sched_ue_list& ue_db, sf_sched* tti_sched) override;
void sched_ul_users(sched_ue_list& ue_db, sf_sched* tti_sched) override;
private:
void new_tti(std::map<uint16_t, sched_ue>& ue_db, sf_sched* tti_sched);
void new_tti(sched_ue_list& ue_db, sf_sched* tti_sched);
const sched_cell_params_t* cc_cfg = nullptr;
float fairness_coeff = 1;

View File

@ -23,14 +23,14 @@ class sched_time_rr final : public sched_base
public:
sched_time_rr(const sched_cell_params_t& cell_params_, const sched_interface::sched_args_t& sched_args);
void sched_dl_users(std::map<uint16_t, sched_ue>& ue_db, sf_sched* tti_sched) override;
void sched_ul_users(std::map<uint16_t, sched_ue>& ue_db, sf_sched* tti_sched) override;
void sched_dl_users(sched_ue_list& ue_db, sf_sched* tti_sched) override;
void sched_ul_users(sched_ue_list& ue_db, sf_sched* tti_sched) override;
private:
void sched_dl_retxs(std::map<uint16_t, sched_ue>& ue_db, sf_sched* tti_sched, size_t prio_idx);
void sched_dl_newtxs(std::map<uint16_t, sched_ue>& ue_db, sf_sched* tti_sched, size_t prio_idx);
void sched_ul_retxs(std::map<uint16_t, sched_ue>& ue_db, sf_sched* tti_sched, size_t prio_idx);
void sched_ul_newtxs(std::map<uint16_t, sched_ue>& ue_db, sf_sched* tti_sched, size_t prio_idx);
void sched_dl_retxs(sched_ue_list& ue_db, sf_sched* tti_sched, size_t prio_idx);
void sched_dl_newtxs(sched_ue_list& ue_db, sf_sched* tti_sched, size_t prio_idx);
void sched_ul_retxs(sched_ue_list& ue_db, sf_sched* tti_sched, size_t prio_idx);
void sched_ul_newtxs(sched_ue_list& ue_db, sf_sched* tti_sched, size_t prio_idx);
const sched_cell_params_t* cc_cfg = nullptr;
};

View File

@ -94,16 +94,20 @@ int sched::cell_cfg(const std::vector<sched_interface::cell_cfg_t>& cell_cfg)
int sched::ue_cfg(uint16_t rnti, const sched_interface::ue_cfg_t& ue_cfg)
{
std::lock_guard<std::mutex> lock(sched_mutex);
// Add or config user
auto it = ue_db.find(rnti);
if (it == ue_db.end()) {
// create new user
ue_db[rnti].init(rnti, sched_cell_params);
it = ue_db.find(rnti);
{
// config existing user
std::lock_guard<std::mutex> lock(sched_mutex);
auto it = ue_db.find(rnti);
if (it != ue_db.end()) {
it->second->set_cfg(ue_cfg);
return SRSLTE_SUCCESS;
}
}
it->second.set_cfg(ue_cfg);
// Add new user case
std::unique_ptr<sched_ue> ue{new sched_ue(rnti, sched_cell_params, ue_cfg)};
std::lock_guard<std::mutex> lock(sched_mutex);
ue_db.insert(std::make_pair(rnti, std::move(ue)));
return SRSLTE_SUCCESS;
}
@ -121,30 +125,30 @@ int sched::ue_rem(uint16_t rnti)
bool sched::ue_exists(uint16_t rnti)
{
return ue_db_access(rnti, [](sched_ue& ue) {}) >= 0;
return ue_db_access_locked(rnti, [](sched_ue& ue) {}) >= 0;
}
void sched::phy_config_enabled(uint16_t rnti, bool enabled)
{
// TODO: Check if correct use of last_tti
ue_db_access(
ue_db_access_locked(
rnti, [this, enabled](sched_ue& ue) { ue.phy_config_enabled(last_tti, enabled); }, __PRETTY_FUNCTION__);
}
int sched::bearer_ue_cfg(uint16_t rnti, uint32_t lc_id, const sched_interface::ue_bearer_cfg_t& cfg_)
{
return ue_db_access(rnti, [lc_id, cfg_](sched_ue& ue) { ue.set_bearer_cfg(lc_id, cfg_); });
return ue_db_access_locked(rnti, [lc_id, cfg_](sched_ue& ue) { ue.set_bearer_cfg(lc_id, cfg_); });
}
int sched::bearer_ue_rem(uint16_t rnti, uint32_t lc_id)
{
return ue_db_access(rnti, [lc_id](sched_ue& ue) { ue.rem_bearer(lc_id); });
return ue_db_access_locked(rnti, [lc_id](sched_ue& ue) { ue.rem_bearer(lc_id); });
}
uint32_t sched::get_dl_buffer(uint16_t rnti)
{
uint32_t ret = SRSLTE_ERROR;
ue_db_access(
ue_db_access_locked(
rnti, [&ret](sched_ue& ue) { ret = ue.get_pending_dl_rlc_data(); }, __PRETTY_FUNCTION__);
return ret;
}
@ -153,7 +157,7 @@ uint32_t sched::get_ul_buffer(uint16_t rnti)
{
// TODO: Check if correct use of last_tti
uint32_t ret = SRSLTE_ERROR;
ue_db_access(
ue_db_access_locked(
rnti,
[this, &ret](sched_ue& ue) { ret = ue.get_pending_ul_new_data(to_tx_ul(last_tti), -1); },
__PRETTY_FUNCTION__);
@ -162,18 +166,18 @@ uint32_t sched::get_ul_buffer(uint16_t rnti)
int sched::dl_rlc_buffer_state(uint16_t rnti, uint32_t lc_id, uint32_t tx_queue, uint32_t retx_queue)
{
return ue_db_access(rnti, [&](sched_ue& ue) { ue.dl_buffer_state(lc_id, tx_queue, retx_queue); });
return ue_db_access_locked(rnti, [&](sched_ue& ue) { ue.dl_buffer_state(lc_id, tx_queue, retx_queue); });
}
int sched::dl_mac_buffer_state(uint16_t rnti, uint32_t ce_code, uint32_t nof_cmds)
{
return ue_db_access(rnti, [ce_code, nof_cmds](sched_ue& ue) { ue.mac_buffer_state(ce_code, nof_cmds); });
return ue_db_access_locked(rnti, [ce_code, nof_cmds](sched_ue& ue) { ue.mac_buffer_state(ce_code, nof_cmds); });
}
int sched::dl_ack_info(uint32_t tti_rx, uint16_t rnti, uint32_t enb_cc_idx, uint32_t tb_idx, bool ack)
{
int ret = -1;
ue_db_access(
ue_db_access_locked(
rnti,
[&](sched_ue& ue) { ret = ue.set_ack_info(tti_point{tti_rx}, enb_cc_idx, tb_idx, ack); },
__PRETTY_FUNCTION__);
@ -182,25 +186,25 @@ int sched::dl_ack_info(uint32_t tti_rx, uint16_t rnti, uint32_t enb_cc_idx, uint
int sched::ul_crc_info(uint32_t tti_rx, uint16_t rnti, uint32_t enb_cc_idx, bool crc)
{
return ue_db_access(rnti,
[tti_rx, enb_cc_idx, crc](sched_ue& ue) { ue.set_ul_crc(tti_point{tti_rx}, enb_cc_idx, crc); });
return ue_db_access_locked(
rnti, [tti_rx, enb_cc_idx, crc](sched_ue& ue) { ue.set_ul_crc(tti_point{tti_rx}, enb_cc_idx, crc); });
}
int sched::dl_ri_info(uint32_t tti, uint16_t rnti, uint32_t enb_cc_idx, uint32_t ri_value)
{
return ue_db_access(
return ue_db_access_locked(
rnti, [tti, enb_cc_idx, ri_value](sched_ue& ue) { ue.set_dl_ri(tti_point{tti}, enb_cc_idx, ri_value); });
}
int sched::dl_pmi_info(uint32_t tti, uint16_t rnti, uint32_t enb_cc_idx, uint32_t pmi_value)
{
return ue_db_access(
return ue_db_access_locked(
rnti, [tti, enb_cc_idx, pmi_value](sched_ue& ue) { ue.set_dl_pmi(tti_point{tti}, enb_cc_idx, pmi_value); });
}
int sched::dl_cqi_info(uint32_t tti, uint16_t rnti, uint32_t enb_cc_idx, uint32_t cqi_value)
{
return ue_db_access(
return ue_db_access_locked(
rnti, [tti, enb_cc_idx, cqi_value](sched_ue& ue) { ue.set_dl_cqi(tti_point{tti}, enb_cc_idx, cqi_value); });
}
@ -212,28 +216,29 @@ int sched::dl_rach_info(uint32_t enb_cc_idx, dl_sched_rar_info_t rar_info)
int sched::ul_snr_info(uint32_t tti_rx, uint16_t rnti, uint32_t enb_cc_idx, float snr, uint32_t ul_ch_code)
{
return ue_db_access(rnti, [&](sched_ue& ue) { ue.set_ul_snr(tti_point{tti_rx}, enb_cc_idx, snr, ul_ch_code); });
return ue_db_access_locked(rnti,
[&](sched_ue& ue) { ue.set_ul_snr(tti_point{tti_rx}, enb_cc_idx, snr, ul_ch_code); });
}
int sched::ul_bsr(uint16_t rnti, uint32_t lcg_id, uint32_t bsr)
{
return ue_db_access(rnti, [lcg_id, bsr](sched_ue& ue) { ue.ul_buffer_state(lcg_id, bsr); });
return ue_db_access_locked(rnti, [lcg_id, bsr](sched_ue& ue) { ue.ul_buffer_state(lcg_id, bsr); });
}
int sched::ul_buffer_add(uint16_t rnti, uint32_t lcid, uint32_t bytes)
{
return ue_db_access(rnti, [lcid, bytes](sched_ue& ue) { ue.ul_buffer_add(lcid, bytes); });
return ue_db_access_locked(rnti, [lcid, bytes](sched_ue& ue) { ue.ul_buffer_add(lcid, bytes); });
}
int sched::ul_phr(uint16_t rnti, int phr)
{
return ue_db_access(
return ue_db_access_locked(
rnti, [phr](sched_ue& ue) { ue.ul_phr(phr); }, __PRETTY_FUNCTION__);
}
int sched::ul_sr_info(uint32_t tti, uint16_t rnti)
{
return ue_db_access(
return ue_db_access_locked(
rnti, [](sched_ue& ue) { ue.set_sr(); }, __PRETTY_FUNCTION__);
}
@ -247,7 +252,7 @@ std::array<int, SRSLTE_MAX_CARRIERS> sched::get_enb_ue_cc_map(uint16_t rnti)
{
std::array<int, SRSLTE_MAX_CARRIERS> ret{};
ret.fill(-1); // -1 for inactive & non-existent carriers
ue_db_access(
ue_db_access_locked(
rnti,
[this, &ret](sched_ue& ue) {
for (size_t enb_cc_idx = 0; enb_cc_idx < carrier_schedulers.size(); ++enb_cc_idx) {
@ -350,12 +355,12 @@ bool sched::is_generated(srslte::tti_point tti_rx, uint32_t enb_cc_idx) const
// Common way to access ue_db elements in a read locking way
template <typename Func>
int sched::ue_db_access(uint16_t rnti, Func f, const char* func_name)
int sched::ue_db_access_locked(uint16_t rnti, Func&& f, const char* func_name)
{
std::lock_guard<std::mutex> lock(sched_mutex);
auto it = ue_db.find(rnti);
if (it != ue_db.end()) {
f(it->second);
f(*it->second);
} else {
if (func_name != nullptr) {
Error("User rnti=0x%x not found. Failed to call %s.", rnti, func_name);

View File

@ -130,7 +130,7 @@ void bc_sched::reset()
* RAR scheduling
*******************************************************/
ra_sched::ra_sched(const sched_cell_params_t& cfg_, std::map<uint16_t, sched_ue>& ue_db_) :
ra_sched::ra_sched(const sched_cell_params_t& cfg_, sched_ue_list& ue_db_) :
cc_cfg(&cfg_), logger(srslog::fetch_basic_logger("MAC")), ue_db(&ue_db_)
{}
@ -237,7 +237,7 @@ void ra_sched::ul_sched(sf_sched* sf_dl_sched, sf_sched* sf_msg3_sched)
for (const auto& msg3grant : rar.rar_grant.msg3_grant) {
uint16_t crnti = msg3grant.data.temp_crnti;
auto user_it = ue_db->find(crnti);
if (user_it != ue_db->end() and sf_msg3_sched->alloc_msg3(&user_it->second, msg3grant)) {
if (user_it != ue_db->end() and sf_msg3_sched->alloc_msg3(user_it->second.get(), msg3grant)) {
logger.debug("SCHED: Queueing Msg3 for rnti=0x%x at tti=%d", crnti, sf_msg3_sched->get_tti_tx_ul().to_uint());
} else {
logger.error(
@ -256,10 +256,10 @@ void ra_sched::reset()
* Carrier scheduling
*******************************************************/
sched::carrier_sched::carrier_sched(rrc_interface_mac* rrc_,
std::map<uint16_t, sched_ue>* ue_db_,
uint32_t enb_cc_idx_,
sched_result_list* sched_results_) :
sched::carrier_sched::carrier_sched(rrc_interface_mac* rrc_,
sched_ue_list* ue_db_,
uint32_t enb_cc_idx_,
sched_result_list* sched_results_) :
rrc(rrc_),
ue_db(ue_db_),
logger(srslog::fetch_basic_logger("MAC")),
@ -316,7 +316,7 @@ const cc_sched_result& sched::carrier_sched::generate_tti_result(tti_point tti_r
/* Refresh UE internal buffers and subframe vars */
for (auto& user : *ue_db) {
user.second.new_subframe(tti_rx, enb_cc_idx);
user.second->new_subframe(tti_rx, enb_cc_idx);
}
/* Schedule PHICH */
@ -324,7 +324,7 @@ const cc_sched_result& sched::carrier_sched::generate_tti_result(tti_point tti_r
if (cc_result->ul_sched_result.nof_phich_elems >= MAX_PHICH_LIST) {
break;
}
tti_sched->alloc_phich(&ue_pair.second, &cc_result->ul_sched_result);
tti_sched->alloc_phich(ue_pair.second.get(), &cc_result->ul_sched_result);
}
/* Schedule DL control data */
@ -357,7 +357,7 @@ const cc_sched_result& sched::carrier_sched::generate_tti_result(tti_point tti_r
/* Reset ue harq pending ack state, clean-up blocked pids */
for (auto& user : *ue_db) {
user.second.finish_tti(tti_rx, enb_cc_idx);
user.second->finish_tti(tti_rx, enb_cc_idx);
}
log_dl_cc_results(logger, enb_cc_idx, cc_result->dl_sched_result);

View File

@ -12,7 +12,6 @@
#include "srsenb/hdr/stack/mac/sched_grid.h"
#include "srsenb/hdr/stack/mac/sched_helpers.h"
#include "srslte/common/log_helper.h"
#include "srslte/common/logmap.h"
using srslte::tti_point;
@ -784,7 +783,7 @@ void sf_sched::set_dl_data_sched_result(const pdcch_sched::alloc_result_t& dci_r
if (ue_it == ue_list.end()) {
continue;
}
sched_ue* user = &ue_it->second;
sched_ue* user = ue_it->second.get();
uint32_t data_before = user->get_requested_dl_bytes(cc_cfg->enb_cc_idx).stop();
const dl_harq_proc& dl_harq = user->get_dl_harq(data_alloc.pid, cc_cfg->enb_cc_idx);
bool is_newtx = dl_harq.is_empty();
@ -919,7 +918,7 @@ void sf_sched::set_ul_sched_result(const pdcch_sched::alloc_result_t& dci_result
if (ue_it == ue_list.end()) {
continue;
}
sched_ue* user = &ue_it->second;
sched_ue* user = ue_it->second.get();
srslte_dci_location_t cce_range = {0, 0};
if (ul_alloc.needs_pdcch()) {
@ -1001,7 +1000,7 @@ void sf_sched::generate_sched_results(sched_ue_list& ue_db)
for (uint32_t i = 0; i < cc_result->ul_sched_result.nof_phich_elems; ++i) {
auto& phich = phich_list[i];
if (phich.phich == phich_t::NACK) {
auto& ue = ue_db[phich.rnti];
auto& ue = *ue_db[phich.rnti];
ul_harq_proc* h = ue.get_ul_harq(get_tti_tx_ul(), cc_cfg->enb_cc_idx);
if (not is_ul_alloc(ue.get_rnti()) and h != nullptr and not h->is_empty()) {
// There was a missed UL harq retx. Halt+Resume the HARQ

View File

@ -35,9 +35,8 @@ namespace srsenb {
*
*******************************************************/
sched_ue::sched_ue() : logger(srslog::fetch_basic_logger("MAC")) {}
void sched_ue::init(uint16_t rnti_, const std::vector<sched_cell_params_t>& cell_list_params_)
sched_ue::sched_ue(uint16_t rnti_, const std::vector<sched_cell_params_t>& cell_list_params_, const ue_cfg_t& cfg_) :
logger(srslog::fetch_basic_logger("MAC"))
{
rnti = rnti_;
cells.reserve(cell_list_params_.size());
@ -45,6 +44,8 @@ void sched_ue::init(uint16_t rnti_, const std::vector<sched_cell_params_t>& cell
cells.emplace_back(rnti_, c, current_tti);
}
logger.info("SCHED: Added user rnti=0x%x", rnti);
set_cfg(cfg_);
}
void sched_ue::set_cfg(const ue_cfg_t& cfg_)

View File

@ -24,7 +24,7 @@ sched_time_pf::sched_time_pf(const sched_cell_params_t& cell_params_, const sche
}
}
void sched_time_pf::new_tti(std::map<uint16_t, sched_ue>& ue_db, sf_sched* tti_sched)
void sched_time_pf::new_tti(sched_ue_list& ue_db, sf_sched* tti_sched)
{
current_tti_rx = tti_point{tti_sched->get_tti_rx()};
// remove deleted users from history
@ -41,7 +41,7 @@ void sched_time_pf::new_tti(std::map<uint16_t, sched_ue>& ue_db, sf_sched* tti_s
if (it == ue_history_db.end()) {
it = ue_history_db.insert(std::make_pair(u.first, ue_ctxt{u.first, fairness_coeff})).first;
}
it->second.new_tti(*cc_cfg, u.second, tti_sched);
it->second.new_tti(*cc_cfg, *u.second, tti_sched);
if (it->second.dl_newtx_h != nullptr or it->second.dl_retx_h != nullptr) {
dl_queue.push(&it->second);
}
@ -55,7 +55,7 @@ void sched_time_pf::new_tti(std::map<uint16_t, sched_ue>& ue_db, sf_sched* tti_s
* Dowlink
*****************************************************************/
void sched_time_pf::sched_dl_users(std::map<uint16_t, sched_ue>& ue_db, sf_sched* tti_sched)
void sched_time_pf::sched_dl_users(sched_ue_list& ue_db, sf_sched* tti_sched)
{
srslte::tti_point tti_rx{tti_sched->get_tti_rx()};
if (current_tti_rx != tti_rx) {
@ -64,7 +64,7 @@ void sched_time_pf::sched_dl_users(std::map<uint16_t, sched_ue>& ue_db, sf_sched
while (not dl_queue.empty()) {
ue_ctxt& ue = *dl_queue.top();
ue.save_dl_alloc(try_dl_alloc(ue, ue_db[ue.rnti], tti_sched), 0.01);
ue.save_dl_alloc(try_dl_alloc(ue, *ue_db[ue.rnti], tti_sched), 0.01);
dl_queue.pop();
}
}
@ -97,7 +97,7 @@ uint32_t sched_time_pf::try_dl_alloc(ue_ctxt& ue_ctxt, sched_ue& ue, sf_sched* t
* Uplink
*****************************************************************/
void sched_time_pf::sched_ul_users(std::map<uint16_t, sched_ue>& ue_db, sf_sched* tti_sched)
void sched_time_pf::sched_ul_users(sched_ue_list& ue_db, sf_sched* tti_sched)
{
srslte::tti_point tti_rx{tti_sched->get_tti_rx()};
if (current_tti_rx != tti_rx) {
@ -106,7 +106,7 @@ void sched_time_pf::sched_ul_users(std::map<uint16_t, sched_ue>& ue_db, sf_sched
while (not ul_queue.empty()) {
ue_ctxt& ue = *ul_queue.top();
ue.save_ul_alloc(try_ul_alloc(ue, ue_db[ue.rnti], tti_sched), 0.01);
ue.save_ul_alloc(try_ul_alloc(ue, *ue_db[ue.rnti], tti_sched), 0.01);
ul_queue.pop();
}
}

View File

@ -24,7 +24,7 @@ sched_time_rr::sched_time_rr(const sched_cell_params_t& cell_params_, const sche
* Dowlink
*****************************************************************/
void sched_time_rr::sched_dl_users(std::map<uint16_t, sched_ue>& ue_db, sf_sched* tti_sched)
void sched_time_rr::sched_dl_users(sched_ue_list& ue_db, sf_sched* tti_sched)
{
if (ue_db.empty()) {
return;
@ -36,7 +36,7 @@ void sched_time_rr::sched_dl_users(std::map<uint16_t, sched_ue>& ue_db, sf_sched
sched_dl_newtxs(ue_db, tti_sched, priority_idx);
}
void sched_time_rr::sched_dl_retxs(std::map<uint16_t, sched_ue>& ue_db, sf_sched* tti_sched, size_t prio_idx)
void sched_time_rr::sched_dl_retxs(sched_ue_list& ue_db, sf_sched* tti_sched, size_t prio_idx)
{
auto iter = ue_db.begin();
std::advance(iter, prio_idx);
@ -44,7 +44,7 @@ void sched_time_rr::sched_dl_retxs(std::map<uint16_t, sched_ue>& ue_db, sf_sched
if (iter == ue_db.end()) {
iter = ue_db.begin(); // wrap around
}
sched_ue& user = iter->second;
sched_ue& user = *iter->second;
const dl_harq_proc* h = get_dl_retx_harq(user, tti_sched);
// Check if there is a pending retx
if (h == nullptr) {
@ -57,7 +57,7 @@ void sched_time_rr::sched_dl_retxs(std::map<uint16_t, sched_ue>& ue_db, sf_sched
}
}
void sched_time_rr::sched_dl_newtxs(std::map<uint16_t, sched_ue>& ue_db, sf_sched* tti_sched, size_t prio_idx)
void sched_time_rr::sched_dl_newtxs(sched_ue_list& ue_db, sf_sched* tti_sched, size_t prio_idx)
{
auto iter = ue_db.begin();
std::advance(iter, prio_idx);
@ -65,7 +65,7 @@ void sched_time_rr::sched_dl_newtxs(std::map<uint16_t, sched_ue>& ue_db, sf_sche
if (iter == ue_db.end()) {
iter = ue_db.begin(); // wrap around
}
sched_ue& user = iter->second;
sched_ue& user = *iter->second;
if (user.enb_to_ue_cc_idx(cc_cfg->enb_cc_idx) < 0) {
continue;
}
@ -84,7 +84,7 @@ void sched_time_rr::sched_dl_newtxs(std::map<uint16_t, sched_ue>& ue_db, sf_sche
* Uplink
*****************************************************************/
void sched_time_rr::sched_ul_users(std::map<uint16_t, sched_ue>& ue_db, sf_sched* tti_sched)
void sched_time_rr::sched_ul_users(sched_ue_list& ue_db, sf_sched* tti_sched)
{
if (ue_db.empty()) {
return;
@ -95,7 +95,7 @@ void sched_time_rr::sched_ul_users(std::map<uint16_t, sched_ue>& ue_db, sf_sched
sched_ul_newtxs(ue_db, tti_sched, priority_idx);
}
void sched_time_rr::sched_ul_retxs(std::map<uint16_t, sched_ue>& ue_db, sf_sched* tti_sched, size_t prio_idx)
void sched_time_rr::sched_ul_retxs(sched_ue_list& ue_db, sf_sched* tti_sched, size_t prio_idx)
{
auto iter = ue_db.begin();
std::advance(iter, prio_idx);
@ -103,7 +103,7 @@ void sched_time_rr::sched_ul_retxs(std::map<uint16_t, sched_ue>& ue_db, sf_sched
if (iter == ue_db.end()) {
iter = ue_db.begin(); // wrap around
}
sched_ue& user = iter->second;
sched_ue& user = *iter->second;
const ul_harq_proc* h = get_ul_retx_harq(user, tti_sched);
// Check if there is a pending retx
if (h == nullptr) {
@ -116,7 +116,7 @@ void sched_time_rr::sched_ul_retxs(std::map<uint16_t, sched_ue>& ue_db, sf_sched
}
}
void sched_time_rr::sched_ul_newtxs(std::map<uint16_t, sched_ue>& ue_db, sf_sched* tti_sched, size_t prio_idx)
void sched_time_rr::sched_ul_newtxs(sched_ue_list& ue_db, sf_sched* tti_sched, size_t prio_idx)
{
auto iter = ue_db.begin();
std::advance(iter, prio_idx);
@ -124,7 +124,7 @@ void sched_time_rr::sched_ul_newtxs(std::map<uint16_t, sched_ue>& ue_db, sf_sche
if (iter == ue_db.end()) {
iter = ue_db.begin(); // wrap around
}
sched_ue& user = iter->second;
sched_ue& user = *iter->second;
const ul_harq_proc* h = get_ul_newtx_harq(user, tti_sched);
// Check if there is a empty harq
if (h == nullptr) {

View File

@ -46,9 +46,7 @@ int test_pdcch_one_ue()
TESTASSERT(cell_params[ENB_CC_IDX].set_cfg(ENB_CC_IDX, cell_cfg, sched_args));
pdcch_sched pdcch;
sched_ue sched_ue{};
sched_ue.init(rnti, cell_params);
sched_ue.set_cfg(ue_cfg);
sched_ue sched_ue{rnti, cell_params, ue_cfg};
pdcch.init(cell_params[PCell_IDX]);
TESTASSERT(pdcch.nof_alloc_combinations() == 0);

View File

@ -227,7 +227,7 @@ int common_sched_tester::process_tti_events(const tti_ev& tti_ev)
if (ue_ev.buffer_ev->dl_data > 0 and ue_sim_ctxt.conres_rx) {
// If Msg4 has already been tx and there DL data to transmit
uint32_t lcid = RB_ID_DRB1;
uint32_t pending_dl_new_data = ue_db[ue_ev.rnti].get_pending_dl_rlc_data();
uint32_t pending_dl_new_data = ue_db[ue_ev.rnti]->get_pending_dl_rlc_data();
// DRB is set. Update DL buffer
uint32_t tot_dl_data = pending_dl_new_data + ue_ev.buffer_ev->dl_data; // TODO: derive pending based on rx
dl_rlc_buffer_state(ue_ev.rnti, lcid, tot_dl_data, 0); // TODO: Check retx_queue
@ -235,7 +235,7 @@ int common_sched_tester::process_tti_events(const tti_ev& tti_ev)
if (ue_ev.buffer_ev->sr_data > 0 and ue_sim_ctxt.conres_rx) {
uint32_t tot_ul_data =
ue_db[ue_ev.rnti].get_pending_ul_new_data(to_tx_ul(tti_rx), -1) + ue_ev.buffer_ev->sr_data;
ue_db[ue_ev.rnti]->get_pending_ul_new_data(to_tx_ul(tti_rx), -1) + ue_ev.buffer_ev->sr_data;
uint32_t lcg = 1;
ul_bsr(ue_ev.rnti, lcg, tot_ul_data);
}

View File

@ -128,7 +128,7 @@ void sched_tester::before_sched()
// check pending data buffers
for (auto& it : ue_db) {
uint16_t rnti = it.first;
srsenb::sched_ue* user = &it.second;
srsenb::sched_ue* user = it.second.get();
tester_user_results d;
tti_data.ue_data.insert(std::make_pair(rnti, d));
@ -165,7 +165,7 @@ int sched_tester::test_harqs()
const auto& data = tti_info.dl_sched_result[CARRIER_IDX].data[i];
uint32_t h_id = data.dci.pid;
uint16_t rnti = data.dci.rnti;
const srsenb::dl_harq_proc& h = ue_db[rnti].get_dl_harq(h_id, CARRIER_IDX);
const srsenb::dl_harq_proc& h = ue_db[rnti]->get_dl_harq(h_id, CARRIER_IDX);
CONDERROR(h.get_tti() != srsenb::to_tx_dl(tti_rx),
"The scheduled DL harq pid=%d does not a valid tti=%u",
h_id,
@ -177,7 +177,7 @@ int sched_tester::test_harqs()
for (uint32_t i = 0; i < tti_info.ul_sched_result[CARRIER_IDX].nof_phich_elems; ++i) {
const auto& phich = tti_info.ul_sched_result[CARRIER_IDX].phich[i];
const auto& hprev = tti_data.ue_data[phich.rnti].ul_harq;
const auto* h = ue_db[phich.rnti].get_ul_harq(srsenb::to_tx_ul(tti_rx), CARRIER_IDX);
const auto* h = ue_db[phich.rnti]->get_ul_harq(srsenb::to_tx_ul(tti_rx), CARRIER_IDX);
CONDERROR(not hprev.has_pending_phich(), "Alloc PHICH did not have any pending ack");
bool maxretx_flag = hprev.nof_retx(0) + 1 >= hprev.max_nof_retx();
if (phich.phich == sched_interface::ul_sched_phich_t::ACK) {