modernized the scheduler code, and removed some clang-tidy warnings

master
Francisco Paisana 5 years ago
parent ad0b3ce6e2
commit 84ac16826f

@ -46,31 +46,10 @@ namespace srsenb {
class sched : public sched_interface
{
public:
// handle for DL metric
class dl_tti_sched_t
{
public:
virtual alloc_outcome_t alloc_dl_user(sched_ue* user, const rbgmask_t& user_mask, uint32_t pid) = 0;
virtual const rbgmask_t& get_dl_mask() const = 0;
virtual uint32_t get_tti_tx_dl() const = 0;
virtual uint32_t get_nof_ctrl_symbols() const = 0;
virtual bool is_dl_alloc(sched_ue* user) const = 0;
};
// handle for UL metric
class ul_tti_sched_t
{
public:
virtual alloc_outcome_t alloc_ul_user(sched_ue* user, ul_harq_proc::ul_alloc_t alloc) = 0;
virtual const prbmask_t& get_ul_mask() const = 0;
virtual uint32_t get_tti_tx_ul() const = 0;
virtual bool is_ul_alloc(sched_ue* user) const = 0;
};
/*************************************************************
*
*
* Scheduling metric interface definition
*
*
************************************************************/
class metric_dl
@ -100,41 +79,41 @@ public:
sched();
~sched();
void init(rrc_interface_mac *rrc, srslte::log *log);
void set_metric(metric_dl *dl_metric, metric_ul *ul_metric);
int cell_cfg(cell_cfg_t *cell_cfg);
void set_sched_cfg(sched_args_t *sched_cfg);
int reset();
void init(rrc_interface_mac* rrc, srslte::log* log);
void set_metric(metric_dl* dl_metric, metric_ul* ul_metric);
int cell_cfg(cell_cfg_t* cell_cfg) final;
void set_sched_cfg(sched_args_t* sched_cfg);
int reset() final;
int ue_cfg(uint16_t rnti, ue_cfg_t *ue_cfg);
int ue_rem(uint16_t rnti);
bool ue_exists(uint16_t rnti);
int ue_cfg(uint16_t rnti, ue_cfg_t* ue_cfg) final;
int ue_rem(uint16_t rnti) final;
bool ue_exists(uint16_t rnti) final;
void ue_needs_ta_cmd(uint16_t rnti, uint32_t nof_ta_cmd);
void phy_config_enabled(uint16_t rnti, bool enabled);
int bearer_ue_cfg(uint16_t rnti, uint32_t lc_id, ue_bearer_cfg_t *cfg);
int bearer_ue_rem(uint16_t rnti, uint32_t lc_id);
void phy_config_enabled(uint16_t rnti, bool enabled);
int bearer_ue_cfg(uint16_t rnti, uint32_t lc_id, ue_bearer_cfg_t* cfg) final;
int bearer_ue_rem(uint16_t rnti, uint32_t lc_id) final;
uint32_t get_ul_buffer(uint16_t rnti);
uint32_t get_dl_buffer(uint16_t rnti);
uint32_t get_ul_buffer(uint16_t rnti) final;
uint32_t get_dl_buffer(uint16_t rnti) final;
int dl_rlc_buffer_state(uint16_t rnti, uint32_t lc_id, uint32_t tx_queue, uint32_t retx_queue);
int dl_mac_buffer_state(uint16_t rnti, uint32_t ce_code);
int dl_rlc_buffer_state(uint16_t rnti, uint32_t lc_id, uint32_t tx_queue, uint32_t retx_queue) final;
int dl_mac_buffer_state(uint16_t rnti, uint32_t ce_code) final;
int dl_ant_info(uint16_t rnti, asn1::rrc::phys_cfg_ded_s::ant_info_c_* dedicated);
int dl_ack_info(uint32_t tti, uint16_t rnti, uint32_t tb_idx, bool ack);
int dl_rach_info(dl_sched_rar_info_t rar_info);
int dl_ri_info(uint32_t tti, uint16_t rnti, uint32_t ri_value);
int dl_pmi_info(uint32_t tti, uint16_t rnti, uint32_t pmi_value);
int dl_cqi_info(uint32_t tti, uint16_t rnti, uint32_t cqi_value);
int ul_crc_info(uint32_t tti, uint16_t rnti, bool crc);
int ul_sr_info(uint32_t tti, uint16_t rnti);
int ul_bsr(uint16_t rnti, uint32_t lcid, uint32_t bsr, bool set_value = true);
int ul_recv_len(uint16_t rnti, uint32_t lcid, uint32_t len);
int ul_phr(uint16_t rnti, int phr);
int ul_cqi_info(uint32_t tti, uint16_t rnti, uint32_t cqi, uint32_t ul_ch_code);
int dl_ack_info(uint32_t tti, uint16_t rnti, uint32_t tb_idx, bool ack) final;
int dl_rach_info(dl_sched_rar_info_t rar_info) final;
int dl_ri_info(uint32_t tti, uint16_t rnti, uint32_t ri_value) final;
int dl_pmi_info(uint32_t tti, uint16_t rnti, uint32_t pmi_value) final;
int dl_cqi_info(uint32_t tti, uint16_t rnti, uint32_t cqi_value) final;
int ul_crc_info(uint32_t tti, uint16_t rnti, bool crc) final;
int ul_sr_info(uint32_t tti, uint16_t rnti) override;
int ul_bsr(uint16_t rnti, uint32_t lcid, uint32_t bsr, bool set_value = true) final;
int ul_recv_len(uint16_t rnti, uint32_t lcid, uint32_t len) final;
int ul_phr(uint16_t rnti, int phr) final;
int ul_cqi_info(uint32_t tti, uint16_t rnti, uint32_t cqi, uint32_t ul_ch_code) final;
int dl_sched(uint32_t tti, dl_sched_res_t* sched_result) final;
int ul_sched(uint32_t tti, ul_sched_res_t* sched_result) final;

@ -30,10 +30,10 @@
namespace srsenb {
// Type of Allocation
//! Type of Allocation
enum class alloc_type_t { DL_BC, DL_PCCH, DL_RAR, DL_DATA, UL_DATA };
// Result of alloc attempt
//! Result of alloc attempt
struct alloc_outcome_t {
enum result_enum { SUCCESS, DCI_COLLISION, RB_COLLISION, ERROR };
result_enum result = ERROR;
@ -41,19 +41,20 @@ struct alloc_outcome_t {
alloc_outcome_t(result_enum e) : result(e) {}
operator result_enum() { return result; }
operator bool() { return result == SUCCESS; }
const char* to_string() const;
const char* to_string() const;
};
//! Class responsible for managing a PDCCH CCE grid, namely cce allocs, and avoid collisions.
class pdcch_grid_t
{
public:
struct alloc_t {
uint16_t rnti;
srslte_dci_location_t dci_pos = {0, 0};
pdcch_mask_t current_mask;
pdcch_mask_t total_mask;
pdcch_mask_t current_mask;
pdcch_mask_t total_mask;
};
typedef std::vector<const alloc_t*> alloc_result_t;
using alloc_result_t = std::vector<const alloc_t*>;
void init(srslte::log* log_,
srslte_regs_t* regs,
@ -99,10 +100,11 @@ private:
size_t nof_dci_allocs = 0;
};
//! manages a full TTI grid, namely CCE and RB allocations
class tti_grid_t
{
public:
typedef std::pair<alloc_outcome_t, rbg_range_t> ctrl_alloc_t;
using ctrl_alloc_t = std::pair<alloc_outcome_t, rbg_range_t>;
void init(srslte::log* log_, sched_interface::cell_cfg_t* cell_, const pdcch_grid_t& pdcch_grid);
void new_tti(uint32_t tti_rx_, uint32_t start_cfi);
@ -125,14 +127,14 @@ public:
uint32_t get_sf_idx() const { return pdcch_alloc.get_sf_idx(); }
private:
alloc_outcome_t alloc_dl(uint32_t aggr_lvl, alloc_type_t alloc_type, rbgmask_t alloc_mask, sched_ue* user = NULL);
alloc_outcome_t alloc_dl(uint32_t aggr_lvl, alloc_type_t alloc_type, rbgmask_t alloc_mask, sched_ue* user = nullptr);
// consts
srslte::log* log_h = nullptr;
sched_interface::cell_cfg_t* cell_cfg = nullptr;
uint32_t nof_prbs = 0;
uint32_t nof_rbgs = 0;
uint32_t si_n_rbg, rar_n_rbg = 0;
uint32_t si_n_rbg = 0, rar_n_rbg = 0;
// tti const
uint32_t tti_rx = 10241;
@ -147,6 +149,27 @@ private:
prbmask_t ul_mask = {};
};
//! generic interface used by DL scheduler algorithm
class dl_tti_sched_t
{
public:
virtual alloc_outcome_t alloc_dl_user(sched_ue* user, const rbgmask_t& user_mask, uint32_t pid) = 0;
virtual const rbgmask_t& get_dl_mask() const = 0;
virtual uint32_t get_tti_tx_dl() const = 0;
virtual uint32_t get_nof_ctrl_symbols() const = 0;
virtual bool is_dl_alloc(sched_ue* user) const = 0;
};
//! generic interface used by UL scheduler algorithm
class ul_tti_sched_t
{
public:
virtual alloc_outcome_t alloc_ul_user(sched_ue* user, ul_harq_proc::ul_alloc_t alloc) = 0;
virtual const prbmask_t& get_ul_mask() const = 0;
virtual uint32_t get_tti_tx_ul() const = 0;
virtual bool is_ul_alloc(sched_ue* user) const = 0;
};
} // namespace srsenb
#endif // SRSLTE_SCHEDULER_GRID_H

@ -32,34 +32,32 @@ class dl_metric_rr : public sched::metric_dl
public:
void set_log(srslte::log* log_) final;
void sched_users(std::map<uint16_t, sched_ue>& ue_db, sched::dl_tti_sched_t* tti_sched) final;
void sched_users(std::map<uint16_t, sched_ue>& ue_db, dl_tti_sched_t* tti_sched) final;
private:
bool find_allocation(uint32_t nof_rbg, rbgmask_t* rbgmask);
dl_harq_proc* allocate_user(sched_ue* user);
srslte::log* log_h = nullptr;
sched::dl_tti_sched_t* tti_alloc = nullptr;
srslte::log* log_h = nullptr;
dl_tti_sched_t* tti_alloc = nullptr;
};
class ul_metric_rr : public sched::metric_ul
{
public:
void set_log(srslte::log* log_) final;
void sched_users(std::map<uint16_t, sched_ue>& ue_db, sched::ul_tti_sched_t* tti_sched) final;
void sched_users(std::map<uint16_t, sched_ue>& ue_db, ul_tti_sched_t* tti_sched) final;
private:
bool find_allocation(uint32_t L, ul_harq_proc::ul_alloc_t* alloc);
ul_harq_proc* allocate_user_newtx_prbs(sched_ue* user);
ul_harq_proc* allocate_user_retx_prbs(sched_ue *user);
ul_harq_proc* allocate_user_retx_prbs(sched_ue* user);
srslte::log* log_h = nullptr;
sched::ul_tti_sched_t* tti_alloc = nullptr;
uint32_t current_tti;
srslte::log* log_h = nullptr;
ul_tti_sched_t* tti_alloc = nullptr;
uint32_t current_tti;
};
}
} // namespace srsenb
#endif // SRSENB_SCHEDULER_METRIC_H

@ -164,7 +164,7 @@ sched::tti_sched_t::alloc_rar(uint32_t aggr_lvl, const dl_sched_rar_t& rar_grant
ctrl_code_t ret = alloc_dl_ctrl(aggr_lvl, buf_rar, ra_rnti);
if (not ret.first) {
Warning("SCHED: Could not allocate RAR for L=%d, cause=%s\n", aggr_lvl, ret.first.to_string());
return {ret.first, NULL};
return {ret.first, nullptr};
}
// Allocation successful
@ -529,7 +529,8 @@ int sched::tti_sched_t::generate_format1a(
mcs = i;
tbs = srslte_ra_tbs_from_idx(i, 2);
break;
} else if (srslte_ra_tbs_from_idx(i, 3) >= tbs) {
}
if (srslte_ra_tbs_from_idx(i, 3) >= tbs) {
dci->type2_alloc.n_prb1a = srslte_ra_type2_t::SRSLTE_RA_TYPE2_NPRB1A_3;
mcs = i;
tbs = srslte_ra_tbs_from_idx(i, 3);
@ -568,10 +569,10 @@ int sched::tti_sched_t::generate_format1a(
sched::sched() : bc_aggr_level(0), rar_aggr_level(0), P(0), si_n_rbg(0), rar_n_rbg(0), nof_rbg(0)
{
current_tti = 0;
log_h = NULL;
dl_metric = NULL;
ul_metric = NULL;
rrc = NULL;
log_h = nullptr;
dl_metric = nullptr;
ul_metric = nullptr;
rrc = nullptr;
bzero(&cfg, sizeof(cfg));
bzero(&regs, sizeof(regs));
@ -584,7 +585,7 @@ sched::sched() : bc_aggr_level(0), rar_aggr_level(0), P(0), si_n_rbg(0), rar_n_r
bzero(rar_locations[i], sizeof(sched_ue::sched_dci_cce_t) * 10);
}
pthread_rwlock_init(&rwlock, NULL);
pthread_rwlock_init(&rwlock, nullptr);
reset();
}
@ -627,7 +628,7 @@ int sched::reset()
void sched::set_sched_cfg(sched_interface::sched_args_t* sched_cfg_)
{
if (sched_cfg_) {
if (sched_cfg_ != nullptr) {
sched_cfg = *sched_cfg_;
}
}
@ -651,7 +652,7 @@ int sched::cell_cfg(sched_interface::cell_cfg_t* cell_cfg)
cfg = *cell_cfg;
// Get DCI locations
if (srslte_regs_init(&regs, cfg.cell)) {
if (srslte_regs_init(&regs, cfg.cell) != LIBLTE_SUCCESS) {
Error("Getting DCI locations\n");
return SRSLTE_ERROR;
}
@ -733,7 +734,7 @@ int sched::ue_rem(uint16_t rnti)
{
int ret = 0;
pthread_rwlock_wrlock(&rwlock);
if (ue_db.count(rnti)) {
if (ue_db.count(rnti) > 0) {
ue_db.erase(rnti);
} else {
Error("User rnti=0x%x not found\n", rnti);
@ -764,7 +765,7 @@ void sched::ue_needs_ta_cmd(uint16_t rnti, uint32_t nof_ta_cmd) {
void sched::phy_config_enabled(uint16_t rnti, bool enabled)
{
pthread_rwlock_rdlock(&rwlock);
if (ue_db.count(rnti)) {
if (ue_db.count(rnti) > 0) {
ue_db[rnti].phy_config_enabled(current_tti, enabled);
} else {
Error("User rnti=0x%x not found\n", rnti);
@ -776,7 +777,7 @@ int sched::bearer_ue_cfg(uint16_t rnti, uint32_t lc_id, sched_interface::ue_bear
{
int ret = 0;
pthread_rwlock_rdlock(&rwlock);
if (ue_db.count(rnti)) {
if (ue_db.count(rnti) > 0) {
ue_db[rnti].set_bearer_cfg(lc_id, cfg_);
} else {
Error("User rnti=0x%x not found\n", rnti);
@ -790,7 +791,7 @@ int sched::bearer_ue_rem(uint16_t rnti, uint32_t lc_id)
{
int ret = 0;
pthread_rwlock_rdlock(&rwlock);
if (ue_db.count(rnti)) {
if (ue_db.count(rnti) > 0) {
ue_db[rnti].rem_bearer(lc_id);
} else {
Error("User rnti=0x%x not found\n", rnti);
@ -804,7 +805,7 @@ uint32_t sched::get_dl_buffer(uint16_t rnti)
{
uint32_t ret = 0;
pthread_rwlock_rdlock(&rwlock);
if (ue_db.count(rnti)) {
if (ue_db.count(rnti) > 0) {
ret = ue_db[rnti].get_pending_dl_new_data(current_tti);
} else {
Error("User rnti=0x%x not found\n", rnti);
@ -817,7 +818,7 @@ uint32_t sched::get_ul_buffer(uint16_t rnti)
{
uint32_t ret = 0;
pthread_rwlock_rdlock(&rwlock);
if (ue_db.count(rnti)) {
if (ue_db.count(rnti) > 0) {
ret = ue_db[rnti].get_pending_ul_new_data(current_tti);
} else {
Error("User rnti=0x%x not found\n", rnti);
@ -830,7 +831,7 @@ int sched::dl_rlc_buffer_state(uint16_t rnti, uint32_t lc_id, uint32_t tx_queue,
{
int ret = 0;
pthread_rwlock_rdlock(&rwlock);
if (ue_db.count(rnti)) {
if (ue_db.count(rnti) > 0) {
ue_db[rnti].dl_buffer_state(lc_id, tx_queue, retx_queue);
} else {
Error("User rnti=0x%x not found\n", rnti);
@ -844,7 +845,7 @@ int sched::dl_mac_buffer_state(uint16_t rnti, uint32_t ce_code)
{
int ret = 0;
pthread_rwlock_rdlock(&rwlock);
if (ue_db.count(rnti)) {
if (ue_db.count(rnti) > 0) {
ue_db[rnti].mac_buffer_state(ce_code);
} else {
Error("User rnti=0x%x not found\n", rnti);
@ -858,7 +859,7 @@ int sched::dl_ant_info(uint16_t rnti, asn1::rrc::phys_cfg_ded_s::ant_info_c_* dl
{
int ret = 0;
pthread_rwlock_rdlock(&rwlock);
if (ue_db.count(rnti)) {
if (ue_db.count(rnti) > 0) {
ue_db[rnti].set_dl_ant_info(dl_ant_info);
} else {
Error("User rnti=0x%x not found\n", rnti);
@ -872,7 +873,7 @@ int sched::dl_ack_info(uint32_t tti, uint16_t rnti, uint32_t tb_idx, bool ack)
{
int ret = 0;
pthread_rwlock_rdlock(&rwlock);
if (ue_db.count(rnti)) {
if (ue_db.count(rnti) > 0) {
ret = ue_db[rnti].set_ack_info(tti, tb_idx, ack);
} else {
Error("User rnti=0x%x not found\n", rnti);
@ -886,7 +887,7 @@ int sched::ul_crc_info(uint32_t tti, uint16_t rnti, bool crc)
{
int ret = 0;
pthread_rwlock_rdlock(&rwlock);
if (ue_db.count(rnti)) {
if (ue_db.count(rnti) > 0) {
ue_db[rnti].set_ul_crc(tti, crc);
} else {
Error("User rnti=0x%x not found\n", rnti);
@ -900,7 +901,7 @@ int sched::dl_ri_info(uint32_t tti, uint16_t rnti, uint32_t cqi_value)
{
int ret = 0;
pthread_rwlock_rdlock(&rwlock);
if (ue_db.count(rnti)) {
if (ue_db.count(rnti) > 0) {
ue_db[rnti].set_dl_ri(tti, cqi_value);
} else {
Error("User rnti=0x%x not found\n", rnti);
@ -914,7 +915,7 @@ int sched::dl_pmi_info(uint32_t tti, uint16_t rnti, uint32_t pmi_value)
{
int ret = 0;
pthread_rwlock_rdlock(&rwlock);
if (ue_db.count(rnti)) {
if (ue_db.count(rnti) > 0) {
ue_db[rnti].set_dl_pmi(tti, pmi_value);
} else {
Error("User rnti=0x%x not found\n", rnti);
@ -928,7 +929,7 @@ int sched::dl_cqi_info(uint32_t tti, uint16_t rnti, uint32_t cqi_value)
{
int ret = 0;
pthread_rwlock_rdlock(&rwlock);
if (ue_db.count(rnti)) {
if (ue_db.count(rnti) > 0) {
ue_db[rnti].set_dl_cqi(tti, cqi_value);
} else {
Error("User rnti=0x%x not found\n", rnti);
@ -950,7 +951,7 @@ int sched::ul_cqi_info(uint32_t tti, uint16_t rnti, uint32_t cqi, uint32_t ul_ch
{
int ret = 0;
pthread_rwlock_rdlock(&rwlock);
if (ue_db.count(rnti)) {
if (ue_db.count(rnti) > 0) {
ue_db[rnti].set_ul_cqi(tti, cqi, ul_ch_code);
} else {
Error("User rnti=0x%x not found\n", rnti);
@ -964,7 +965,7 @@ int sched::ul_bsr(uint16_t rnti, uint32_t lcid, uint32_t bsr, bool set_value)
{
int ret = 0;
pthread_rwlock_rdlock(&rwlock);
if (ue_db.count(rnti)) {
if (ue_db.count(rnti) > 0) {
ue_db[rnti].ul_buffer_state(lcid, bsr, set_value);
} else {
Error("User rnti=0x%x not found\n", rnti);
@ -978,7 +979,7 @@ int sched::ul_recv_len(uint16_t rnti, uint32_t lcid, uint32_t len)
{
int ret = 0;
pthread_rwlock_rdlock(&rwlock);
if (ue_db.count(rnti)) {
if (ue_db.count(rnti) > 0) {
ue_db[rnti].ul_recv_len(lcid, len);
} else {
Error("User rnti=0x%x not found\n", rnti);
@ -992,7 +993,7 @@ int sched::ul_phr(uint16_t rnti, int phr)
{
int ret = 0;
pthread_rwlock_rdlock(&rwlock);
if (ue_db.count(rnti)) {
if (ue_db.count(rnti) > 0) {
ue_db[rnti].ul_phr(phr);
} else {
Error("User rnti=0x%x not found\n", rnti);
@ -1006,7 +1007,7 @@ int sched::ul_sr_info(uint32_t tti, uint16_t rnti)
{
int ret = 0;
pthread_rwlock_rdlock(&rwlock);
if (ue_db.count(rnti)) {
if (ue_db.count(rnti) > 0) {
ue_db[rnti].set_sr();
} else {
Error("User rnti=0x%x not found\n", rnti);
@ -1024,7 +1025,7 @@ void sched::set_dl_tti_mask(uint8_t* tti_mask, uint32_t nof_sfs)
void sched::tpc_inc(uint16_t rnti)
{
pthread_rwlock_rdlock(&rwlock);
if (ue_db.count(rnti)) {
if (ue_db.count(rnti) > 0) {
ue_db[rnti].tpc_inc();
} else {
Error("User rnti=0x%x not found\n", rnti);
@ -1035,7 +1036,7 @@ void sched::tpc_inc(uint16_t rnti)
void sched::tpc_dec(uint16_t rnti)
{
pthread_rwlock_rdlock(&rwlock);
if (ue_db.count(rnti)) {
if (ue_db.count(rnti) > 0) {
ue_db[rnti].tpc_dec();
} else {
Error("User rnti=0x%x not found\n", rnti);
@ -1127,7 +1128,7 @@ void sched::dl_sched_bc(tti_sched_t* tti_sched)
/* Allocate DCIs and RBGs for each SIB */
for (int i = 0; i < MAX_SIBS; i++) {
if (cfg.sibs[i].len && pending_sibs[i].is_in_window && pending_sibs[i].n_tx < 4) {
if (cfg.sibs[i].len > 0 && pending_sibs[i].is_in_window && pending_sibs[i].n_tx < 4) {
uint32_t nof_tx = (i > 0) ? SRSLTE_MIN(CEILFRAC(cfg.si_window_ms, 10), 4) : 4;
uint32_t n_sf = (tti_sched->get_tti_tx_dl() - pending_sibs[i].window_start);
@ -1146,9 +1147,9 @@ void sched::dl_sched_bc(tti_sched_t* tti_sched)
}
/* Allocate DCIs and RBGs for paging */
if (rrc) {
if (rrc != nullptr) {
uint32_t paging_payload = 0;
if (rrc->is_paging_opportunity(current_tti, &paging_payload) and paging_payload) {
if (rrc->is_paging_opportunity(current_tti, &paging_payload) and paging_payload > 0) {
tti_sched->alloc_paging(bc_aggr_level, paging_payload);
}
}
@ -1305,7 +1306,7 @@ void sched::ul_sched_msg3(tti_sched_t* tti_sched)
}
uint16_t rnti = pending_msg3[pending_tti].rnti;
if (not ue_db.count(rnti)) {
if (ue_db.count(rnti) == 0) {
log_h->warning("SCHED: Msg3 allocated for user rnti=0x%x that no longer exists\n", rnti);
return;
}
@ -1417,6 +1418,4 @@ void sched::generate_cce_location(
}
}
}
} // namespace srsenb

@ -41,7 +41,7 @@ void dl_metric_rr::set_log(srslte::log* log_)
log_h = log_;
}
void dl_metric_rr::sched_users(std::map<uint16_t, sched_ue>& ue_db, sched::dl_tti_sched_t* tti_sched)
void dl_metric_rr::sched_users(std::map<uint16_t, sched_ue>& ue_db, dl_tti_sched_t* tti_sched)
{
typedef std::map<uint16_t, sched_ue>::iterator it_t;
@ -102,7 +102,7 @@ dl_harq_proc* dl_metric_rr::allocate_user(sched_ue* user)
return h;
} else if (code == alloc_outcome_t::DCI_COLLISION) {
// No DCIs available for this user. Move to next
return NULL;
return nullptr;
}
// If previous mask does not fit, find another with exact same number of rbgs
@ -112,7 +112,7 @@ dl_harq_proc* dl_metric_rr::allocate_user(sched_ue* user)
if (code == alloc_outcome_t::SUCCESS) {
return h;
} else if (code == alloc_outcome_t::DCI_COLLISION) {
return NULL;
return nullptr;
}
}
}
@ -138,12 +138,12 @@ dl_harq_proc* dl_metric_rr::allocate_user(sched_ue* user)
}
}
return NULL;
return nullptr;
}
/*****************************************************************
*
* Uplink Metric
* Uplink Metric
*
*****************************************************************/
@ -152,7 +152,7 @@ void ul_metric_rr::set_log(srslte::log* log_)
log_h = log_;
}
void ul_metric_rr::sched_users(std::map<uint16_t, sched_ue>& ue_db, sched::ul_tti_sched_t* tti_sched)
void ul_metric_rr::sched_users(std::map<uint16_t, sched_ue>& ue_db, ul_tti_sched_t* tti_sched)
{
typedef std::map<uint16_t, sched_ue>::iterator it_t;
@ -225,10 +225,10 @@ bool ul_metric_rr::find_allocation(uint32_t L, ul_harq_proc::ul_alloc_t* alloc)
return alloc->L == L;
}
ul_harq_proc* ul_metric_rr::allocate_user_retx_prbs(sched_ue *user)
ul_harq_proc* ul_metric_rr::allocate_user_retx_prbs(sched_ue* user)
{
if (tti_alloc->is_ul_alloc(user)) {
return NULL;
return nullptr;
}
alloc_outcome_t ret;
ul_harq_proc* h = user->get_ul_harq(current_tti);
@ -241,34 +241,36 @@ ul_harq_proc* ul_metric_rr::allocate_user_retx_prbs(sched_ue *user)
ret = tti_alloc->alloc_ul_user(user, alloc);
if (ret == alloc_outcome_t::SUCCESS) {
return h;
} else if (ret == alloc_outcome_t::DCI_COLLISION) {
}
if (ret == alloc_outcome_t::DCI_COLLISION) {
log_h->warning("SCHED: Couldn't find space in PDCCH for UL tx of rnti=0x%x\n", user->get_rnti());
return NULL;
return nullptr;
}
if (find_allocation(alloc.L, &alloc)) {
ret = tti_alloc->alloc_ul_user(user, alloc);
if (ret == alloc_outcome_t::SUCCESS) {
return h;
} else if (ret == alloc_outcome_t::DCI_COLLISION) {
}
if (ret == alloc_outcome_t::DCI_COLLISION) {
log_h->warning("SCHED: Couldn't find space in PDCCH for UL tx of rnti=0x%x\n", user->get_rnti());
}
}
}
return NULL;
return nullptr;
}
ul_harq_proc* ul_metric_rr::allocate_user_newtx_prbs(sched_ue* user)
{
if (tti_alloc->is_ul_alloc(user)) {
return NULL;
return nullptr;
}
uint32_t pending_data = user->get_pending_ul_new_data(current_tti);
ul_harq_proc* h = user->get_ul_harq(current_tti);
// find an empty PID
if (h->is_empty(0) and pending_data) {
uint32_t pending_rb = user->get_required_prb_ul(pending_data);
if (h->is_empty(0) and pending_data > 0) {
uint32_t pending_rb = user->get_required_prb_ul(pending_data);
ul_harq_proc::ul_alloc_t alloc;
find_allocation(pending_rb, &alloc);
@ -281,7 +283,7 @@ ul_harq_proc* ul_metric_rr::allocate_user_newtx_prbs(sched_ue* user)
}
}
}
return NULL;
return nullptr;
}
}
} // namespace srsenb

@ -117,15 +117,17 @@ log_tester log_out("ALL");
#define Warning(fmt, ...) \
log_out.warning(fmt, ##__VA_ARGS__); \
warn_counter++;
warn_counter++
#define TestError(fmt, ...) \
log_out.error(fmt, ##__VA_ARGS__); \
exit(-1);
exit(-1)
#define CondError(cond, fmt, ...) \
if (cond) { \
log_out.error(fmt, ##__VA_ARGS__); \
exit(-1); \
}
do { \
if (cond) { \
log_out.error(fmt, ##__VA_ARGS__); \
exit(-1); \
} \
} while (0)
/*******************
* Dummies *
@ -182,7 +184,6 @@ struct sched_tester : public srsenb::sched {
tester_user_results total_ues; ///< stores combined UL/DL buffer state
srsenb::sched_interface::ul_sched_res_t sched_result_ul;
srsenb::sched_interface::dl_sched_res_t sched_result_dl;
typedef std::map<uint16_t, tester_user_results>::iterator ue_it_t;
};
struct ue_info {
int prach_tti = -1, rar_tti = -1, msg3_tti = -1;
@ -246,7 +247,7 @@ void sched_tester::add_user(uint16_t rnti,
tester_ues.insert(std::make_pair(rnti, info));
if (ue_cfg(rnti, &ue_cfg_) != SRSLTE_SUCCESS) {
TestError("[TESTER] Registering new user rnti=0x%x to SCHED\n", rnti)
TestError("[TESTER] Registering new user rnti=0x%x to SCHED\n", rnti);
}
dl_sched_rar_info_t rar_info = {};
rar_info.prach_tti = tti_data.tti_rx;
@ -310,7 +311,7 @@ void sched_tester::process_tti_args()
if (e.second.sr_data > 0) {
uint32_t tot_ul_data = ue_db[e.first].get_pending_ul_new_data(tti_data.tti_tx_ul) + e.second.sr_data;
uint32_t lcid = 0;
ul_bsr(e.first, lcid, tot_ul_data);
ul_bsr(e.first, lcid, tot_ul_data, true);
}
if (e.second.dl_data > 0) {
uint32_t lcid = 0;
@ -599,8 +600,8 @@ void sched_tester::test_harqs()
}
for (uint32_t i = 0; i < tti_data.sched_result_ul.nof_dci_elems; ++i) {
const auto& pusch = tti_data.sched_result_ul.pusch[i];
uint16_t rnti = pusch.dci.rnti;
const auto& pusch = tti_data.sched_result_ul.pusch[i];
uint16_t rnti = pusch.dci.rnti;
const auto& ue_data = tti_data.ue_data[rnti];
const srsenb::ul_harq_proc* h = ue_db[rnti].get_ul_harq(tti_data.tti_tx_ul);
CondError(h == nullptr or h->is_empty(), "[TESTER] scheduled UL harq does not exist or is empty\n");
@ -778,7 +779,7 @@ void sched_tester::test_collisions()
}
srslte::bounded_bitset<100, true> dl_allocs(cfg.cell.nof_prb), alloc_mask(cfg.cell.nof_prb);
srslte_dl_sf_cfg_t dl_sf;
srslte_dl_sf_cfg_t dl_sf;
ZERO_OBJECT(dl_sf);
for (uint32_t i = 0; i < tti_data.sched_result_dl.nof_data_elems; ++i) {
@ -979,10 +980,10 @@ void test_scheduler_rand(srsenb::sched_interface::cell_cfg_t cell_cfg, const sch
log_out.set_level(srslte::LOG_LEVEL_INFO);
tester.sim_args = args;
srslte_cell_t& cell_cfg_phy = cell_cfg.cell;
srsenb::sched_interface::dl_sched_res_t& sched_result_dl = tester.tti_data.sched_result_dl;
srsenb::sched_interface::ul_sched_res_t& sched_result_ul = tester.tti_data.sched_result_ul;
tester.sim_args = args;
// srslte_cell_t& cell_cfg_phy = cell_cfg.cell;
// srsenb::sched_interface::dl_sched_res_t& sched_result_dl = tester.tti_data.sched_result_dl;
// srsenb::sched_interface::ul_sched_res_t& sched_result_ul = tester.tti_data.sched_result_ul;
tester.init(nullptr, &log_out);
tester.set_metric(&dl_metric, &ul_metric);

Loading…
Cancel
Save