sched rand tester ue_sim class now handles cqi

master
Francisco 4 years ago committed by Andre Puschmann
parent 8f05982bef
commit a068ae11b0

@ -11,7 +11,6 @@
*/ */
#include "srsenb/hdr/stack/mac/sched_grid.h" #include "srsenb/hdr/stack/mac/sched_grid.h"
#include "srsenb/hdr/stack/mac/sched.h"
#include "srsenb/hdr/stack/mac/sched_helpers.h" #include "srsenb/hdr/stack/mac/sched_helpers.h"
#include "srslte/common/log_helper.h" #include "srslte/common/log_helper.h"
#include "srslte/common/logmap.h" #include "srslte/common/logmap.h"

@ -62,6 +62,11 @@ void ue_sim::set_cfg(const sched_interface::ue_cfg_t& ue_cfg_)
} }
} }
void ue_sim::bearer_cfg(uint32_t lc_id, const sched_interface::ue_bearer_cfg_t& cfg)
{
ctxt.ue_cfg.ue_bearers.at(lc_id) = cfg;
}
ue_sim::sync_tti_events ue_sim::get_pending_events(srslte::tti_point tti_rx, sched_interface* sched) ue_sim::sync_tti_events ue_sim::get_pending_events(srslte::tti_point tti_rx, sched_interface* sched)
{ {
pending_feedback.tti_rx = tti_rx; pending_feedback.tti_rx = tti_rx;
@ -78,14 +83,25 @@ ue_sim::sync_tti_events ue_sim::get_pending_events(srslte::tti_point tti_rx, sch
auto& dl_h = ctxt.cc_list[cc_feedback.ue_cc_idx].dl_harqs[pid]; auto& dl_h = ctxt.cc_list[cc_feedback.ue_cc_idx].dl_harqs[pid];
auto& ul_h = ctxt.cc_list[cc_feedback.ue_cc_idx].ul_harqs[pid]; auto& ul_h = ctxt.cc_list[cc_feedback.ue_cc_idx].ul_harqs[pid];
// Set default DL ACK
if (dl_h.active and to_tx_dl_ack(dl_h.last_tti_rx) == tti_rx) { if (dl_h.active and to_tx_dl_ack(dl_h.last_tti_rx) == tti_rx) {
cc_feedback.dl_pid = pid; cc_feedback.dl_pid = pid;
cc_feedback.dl_ack = false; // default is NACK cc_feedback.dl_ack = false; // default is NACK
} }
// Set default UL ACK
if (ul_h.active and to_tx_ul(ul_h.last_tti_rx) == tti_rx) { if (ul_h.active and to_tx_ul(ul_h.last_tti_rx) == tti_rx) {
cc_feedback.ul_pid = pid; cc_feedback.ul_pid = pid;
cc_feedback.ul_ack = false; cc_feedback.ul_ack = false;
} }
// Set default DL CQI
if (srslte_cqi_periodic_send(
&ctxt.ue_cfg.supported_cc_list[cc_feedback.ue_cc_idx].dl_cfg.cqi_report, tti_rx.to_uint(), SRSLTE_FDD)) {
cc_feedback.dl_cqi = 0;
}
// TODO: UL CQI
} }
} }
return {this, sched}; return {this, sched};
@ -133,6 +149,14 @@ void ue_sim::push_feedback(sched_interface* sched)
error_count++; error_count++;
} }
} }
if (cc_feedback.dl_cqi >= 0) {
sched->dl_cqi_info(pending_feedback.tti_rx.to_uint(), ctxt.rnti, enb_cc_idx, cc_feedback.dl_cqi);
}
if (cc_feedback.ul_cqi >= 0) {
sched->ul_snr_info(pending_feedback.tti_rx.to_uint(), ctxt.rnti, enb_cc_idx, cc_feedback.ul_cqi, 0);
}
} }
} }
@ -307,6 +331,11 @@ void ue_db_sim::ue_recfg(uint16_t rnti, const sched_interface::ue_cfg_t& ue_cfg_
ue_db.at(rnti).set_cfg(ue_cfg_); ue_db.at(rnti).set_cfg(ue_cfg_);
} }
void ue_db_sim::bearer_cfg(uint16_t rnti, uint32_t lc_id, const sched_interface::ue_bearer_cfg_t& cfg)
{
ue_db.at(rnti).bearer_cfg(lc_id, cfg);
}
void ue_db_sim::rem_user(uint16_t rnti) void ue_db_sim::rem_user(uint16_t rnti)
{ {
ue_db.erase(rnti); ue_db.erase(rnti);

@ -57,12 +57,13 @@ struct ue_tti_events {
struct cc_data { struct cc_data {
bool configured = false; bool configured = false;
uint32_t ue_cc_idx = 0; uint32_t ue_cc_idx = 0;
int dl_cqi = -1;
int dl_pid = -1; int dl_pid = -1;
bool dl_ack = false; bool dl_ack = false;
int tb = 0; int tb = 0;
int ul_pid = -1; int ul_pid = -1;
bool ul_ack = false; bool ul_ack = false;
int dl_cqi = -1;
int ul_cqi = -1;
}; };
srslte::tti_point tti_rx; srslte::tti_point tti_rx;
std::vector<cc_data> cc_list; std::vector<cc_data> cc_list;
@ -78,6 +79,7 @@ public:
uint32_t preamble_idx); uint32_t preamble_idx);
void set_cfg(const sched_interface::ue_cfg_t& ue_cfg_); void set_cfg(const sched_interface::ue_cfg_t& ue_cfg_);
void bearer_cfg(uint32_t lc_id, const sched_interface::ue_bearer_cfg_t& cfg);
int update(const sf_output_res_t& sf_out); int update(const sf_output_res_t& sf_out);
@ -124,12 +126,23 @@ public:
srslte::tti_point prach_tti_rx_, srslte::tti_point prach_tti_rx_,
uint32_t preamble_idx); uint32_t preamble_idx);
void ue_recfg(uint16_t rnti, const sched_interface::ue_cfg_t& ue_cfg_); void ue_recfg(uint16_t rnti, const sched_interface::ue_cfg_t& ue_cfg_);
void bearer_cfg(uint16_t rnti, uint32_t lc_id, const sched_interface::ue_bearer_cfg_t& cfg);
void rem_user(uint16_t rnti); void rem_user(uint16_t rnti);
void update(const sf_output_res_t& sf_out); void update(const sf_output_res_t& sf_out);
std::map<uint16_t, const sim_ue_ctxt_t*> get_ues_ctxt() const; std::map<uint16_t, const sim_ue_ctxt_t*> get_ues_ctxt() const;
ue_sim& at(uint16_t rnti) { return ue_db.at(rnti); } ue_sim& at(uint16_t rnti) { return ue_db.at(rnti); }
const ue_sim& at(uint16_t rnti) const { return ue_db.at(rnti); } const ue_sim& at(uint16_t rnti) const { return ue_db.at(rnti); }
ue_sim* find_rnti(uint16_t rnti)
{
auto it = ue_db.find(rnti);
return it != ue_db.end() ? &it->second : nullptr;
}
const ue_sim* find_rnti(uint16_t rnti) const
{
auto it = ue_db.find(rnti);
return it != ue_db.end() ? &it->second : nullptr;
}
private: private:
const std::vector<sched_interface::cell_cfg_t>* cell_params; const std::vector<sched_interface::cell_cfg_t>* cell_params;

@ -48,61 +48,11 @@ std::default_random_engine& ::srsenb::get_rand_gen()
* User State Tester * User State Tester
***********************/ ***********************/
ue_ctxt_test::ue_ctxt_test(uint16_t rnti_, ue_ctxt_test::ue_ctxt_test(const ue_ctxt_test_cfg& cfg_, ue_sim& ue_ctxt_) : sim_cfg(cfg_), ue_ctxt(&ue_ctxt_) {}
srslte::tti_point prach_tti_,
const ue_ctxt_test_cfg& cfg_,
ue_sim& ue_ctxt_) :
sim_cfg(cfg_), rnti(rnti_), current_tti_rx(prach_tti_), ue_ctxt(&ue_ctxt_)
{
set_cfg(cfg_.ue_cfg);
}
int ue_ctxt_test::set_cfg(const sched::ue_cfg_t& ue_cfg_)
{
for (uint32_t ue_cc_idx = 0; ue_cc_idx < ue_cfg_.supported_cc_list.size(); ++ue_cc_idx) {
const auto& cc = ue_cfg_.supported_cc_list[ue_cc_idx];
if (ue_cc_idx >= active_ccs.size()) {
// new cell
active_ccs.emplace_back();
active_ccs.back().ue_cc_idx = active_ccs.size() - 1;
active_ccs.back().enb_cc_idx = cc.enb_cc_idx;
} else {
CONDERROR(cc.enb_cc_idx != active_ccs[ue_cc_idx].enb_cc_idx, "changing ccs not supported\n");
}
}
user_cfg = ue_cfg_;
return SRSLTE_SUCCESS;
}
ue_ctxt_test::cc_ue_ctxt_test* ue_ctxt_test::get_cc_state(uint32_t enb_cc_idx)
{
auto it = std::find_if(active_ccs.begin(), active_ccs.end(), [enb_cc_idx](const cc_ue_ctxt_test& c) {
return c.enb_cc_idx == enb_cc_idx;
});
return it == active_ccs.end() ? nullptr : &(*it);
}
int ue_ctxt_test::new_tti(sched* sched_ptr, srslte::tti_point tti_rx) int ue_ctxt_test::new_tti(sched* sched_ptr, srslte::tti_point tti_rx)
{ {
current_tti_rx = tti_rx; auto pending_feedback = ue_ctxt->get_pending_events(tti_rx, sched_ptr);
TESTASSERT(fwd_ue_feedback(sched_ptr) == SRSLTE_SUCCESS);
if (sim_cfg.periodic_cqi and (tti_rx.to_uint() % sim_cfg.cqi_Npd) == sim_cfg.cqi_Noffset) {
for (auto& cc : active_ccs) {
sched_ptr->dl_cqi_info(
tti_rx.to_uint(), rnti, cc.enb_cc_idx, std::uniform_int_distribution<uint32_t>{5, 24}(get_rand_gen()));
sched_ptr->ul_snr_info(
tti_rx.to_uint(), rnti, cc.enb_cc_idx, std::uniform_int_distribution<uint32_t>{5, 40}(get_rand_gen()), 0);
}
}
return SRSLTE_SUCCESS;
}
int ue_ctxt_test::fwd_ue_feedback(sched* sched_ptr)
{
auto pending_feedback = ue_ctxt->get_pending_events(current_tti_rx, sched_ptr);
for (uint32_t enb_cc_idx = 0; enb_cc_idx < pending_feedback->cc_list.size(); ++enb_cc_idx) { for (uint32_t enb_cc_idx = 0; enb_cc_idx < pending_feedback->cc_list.size(); ++enb_cc_idx) {
auto& cc_feedback = pending_feedback->cc_list[enb_cc_idx]; auto& cc_feedback = pending_feedback->cc_list[enb_cc_idx];
@ -121,50 +71,15 @@ int ue_ctxt_test::fwd_ue_feedback(sched* sched_ptr)
auto& h = ue_ctxt->get_ctxt().cc_list[cc_feedback.ue_cc_idx].ul_harqs[cc_feedback.ul_pid]; auto& h = ue_ctxt->get_ctxt().cc_list[cc_feedback.ue_cc_idx].ul_harqs[cc_feedback.ul_pid];
cc_feedback.ul_ack = randf() < sim_cfg.prob_ul_ack_mask[h.nof_retxs % sim_cfg.prob_ul_ack_mask.size()]; cc_feedback.ul_ack = randf() < sim_cfg.prob_ul_ack_mask[h.nof_retxs % sim_cfg.prob_ul_ack_mask.size()];
} }
}
return SRSLTE_SUCCESS; // DL CQI
} if (cc_feedback.dl_cqi >= 0) {
cc_feedback.dl_cqi = std::uniform_int_distribution<uint32_t>{5, 24}(get_rand_gen());
int ue_ctxt_test::test_sched_result(uint32_t enb_cc_idx,
const sched::dl_sched_res_t& dl_result,
const sched::ul_sched_res_t& ul_result)
{
cc_result result{enb_cc_idx, &dl_result, &ul_result};
TESTASSERT(test_scell_activation(result) == SRSLTE_SUCCESS);
return SRSLTE_SUCCESS;
}
/**
* Tests whether the SCells are correctly activated. Individual tests:
* - no DL and UL allocations in inactive carriers
*/
int ue_ctxt_test::test_scell_activation(cc_result result)
{
auto cc_it =
std::find_if(user_cfg.supported_cc_list.begin(),
user_cfg.supported_cc_list.end(),
[&result](const sched::ue_cfg_t::cc_cfg_t& cc) { return cc.enb_cc_idx == result.enb_cc_idx; });
if (cc_it == user_cfg.supported_cc_list.end() or not cc_it->active) {
// cell not active. Ensure data allocations are not made
for (uint32_t i = 0; i < result.dl_result->nof_data_elems; ++i) {
CONDERROR(result.dl_result->data[i].dci.rnti == rnti, "Allocated user in inactive carrier\n");
} }
for (uint32_t i = 0; i < result.ul_result->nof_dci_elems; ++i) {
CONDERROR(result.ul_result->pusch[i].dci.rnti == rnti, "Allocated user in inactive carrier\n"); // UL CQI
} if (cc_feedback.ul_cqi >= 0) {
} else { cc_feedback.ul_cqi = std::uniform_int_distribution<uint32_t>{5, 40}(get_rand_gen());
uint32_t ue_cc_idx = std::distance(user_cfg.supported_cc_list.begin(), cc_it);
for (uint32_t i = 0; i < result.dl_result->nof_data_elems; ++i) {
if (result.dl_result->data[i].dci.rnti == rnti) {
CONDERROR(result.dl_result->data[i].dci.ue_cc_idx != ue_cc_idx, "User cell index was incorrectly set\n");
}
}
for (uint32_t i = 0; i < result.ul_result->nof_dci_elems; ++i) {
if (result.ul_result->pusch[i].dci.rnti == rnti) {
CONDERROR(result.ul_result->pusch[i].dci.ue_cc_idx != ue_cc_idx, "The user cell index was incorrectly set\n");
}
} }
} }
@ -187,7 +102,7 @@ int user_state_sched_tester::add_user(uint16_t rnti, uint32_t preamble_idx, cons
TESTASSERT(users.count(rnti) == 0); TESTASSERT(users.count(rnti) == 0);
sim_users.add_user(rnti, generate_rach_ue_cfg(cfg_.ue_cfg), tic, preamble_idx); sim_users.add_user(rnti, generate_rach_ue_cfg(cfg_.ue_cfg), tic, preamble_idx);
ue_ctxt_test ue{rnti, tic, cfg_, sim_users.at(rnti)}; ue_ctxt_test ue{cfg_, sim_users.at(rnti)};
users.insert(std::make_pair(rnti, ue)); users.insert(std::make_pair(rnti, ue));
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
@ -196,7 +111,6 @@ int user_state_sched_tester::add_user(uint16_t rnti, uint32_t preamble_idx, cons
int user_state_sched_tester::user_reconf(uint16_t rnti, const srsenb::sched_interface::ue_cfg_t& ue_cfg) int user_state_sched_tester::user_reconf(uint16_t rnti, const srsenb::sched_interface::ue_cfg_t& ue_cfg)
{ {
TESTASSERT(users.count(rnti) > 0); TESTASSERT(users.count(rnti) > 0);
users.at(rnti).set_cfg(ue_cfg);
sim_users.ue_recfg(rnti, ue_cfg); sim_users.ue_recfg(rnti, ue_cfg);
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
} }
@ -205,12 +119,13 @@ int user_state_sched_tester::bearer_cfg(uint16_t
uint32_t lcid, uint32_t lcid,
const srsenb::sched_interface::ue_bearer_cfg_t& bearer_cfg) const srsenb::sched_interface::ue_bearer_cfg_t& bearer_cfg)
{ {
auto it = users.find(rnti); sim_users.bearer_cfg(rnti, lcid, bearer_cfg);
ue_sim* ue = sim_users.find_rnti(rnti);
auto it = users.find(rnti);
TESTASSERT(it != users.end()); TESTASSERT(it != users.end());
it->second.user_cfg.ue_bearers[lcid] = bearer_cfg; users.at(rnti).drb_cfg_flag = false;
users.at(rnti).drb_cfg_flag = false; for (uint32_t i = 2; i < ue->get_ctxt().ue_cfg.ue_bearers.size(); ++i) {
for (uint32_t i = 2; i < it->second.user_cfg.ue_bearers.size(); ++i) { if (ue->get_ctxt().ue_cfg.ue_bearers[i].direction != sched_interface::ue_bearer_cfg_t::IDLE) {
if (it->second.user_cfg.ue_bearers[i].direction != sched_interface::ue_bearer_cfg_t::IDLE) {
users.at(rnti).drb_cfg_flag = true; users.at(rnti).drb_cfg_flag = true;
} }
} }
@ -234,13 +149,6 @@ int user_state_sched_tester::test_all(const sf_output_res_t& sf_out)
// Update Simulated UEs state // Update Simulated UEs state
sim_users.update(sf_out); sim_users.update(sf_out);
for (uint32_t enb_cc_idx = 0; enb_cc_idx < enb_ctxt.cell_params->size(); ++enb_cc_idx) {
for (auto& u : users) {
TESTASSERT(u.second.test_sched_result(
enb_cc_idx, sf_out.dl_cc_result[enb_cc_idx], sf_out.ul_cc_result[enb_cc_idx]) == SRSLTE_SUCCESS);
}
}
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
} }
@ -402,7 +310,7 @@ int common_sched_tester::process_tti_events(const tti_ev& tti_ev)
to_tx_ul(ue_sim_ctxt.msg3_tti_rx) <= tti_rx) { to_tx_ul(ue_sim_ctxt.msg3_tti_rx) <= tti_rx) {
// Msg3 has been received but Msg4 has not been yet transmitted // Msg3 has been received but Msg4 has not been yet transmitted
// Setup default UE config // Setup default UE config
reconf_user(user->rnti, generate_setup_ue_cfg(sim_args0.default_ue_sim_cfg.ue_cfg)); reconf_user(ue_sim_ctxt.rnti, generate_setup_ue_cfg(sim_args0.default_ue_sim_cfg.ue_cfg));
// Schedule RRC Setup and ConRes CE // Schedule RRC Setup and ConRes CE
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();
@ -427,7 +335,7 @@ int common_sched_tester::process_tti_events(const tti_ev& tti_ev)
if (user->drb_cfg_flag or pending_dl_new_data == 0) { if (user->drb_cfg_flag or pending_dl_new_data == 0) {
// If RRCSetup finished // If RRCSetup finished
if (not user->drb_cfg_flag) { if (not user->drb_cfg_flag) {
reconf_user(user->rnti, sim_args0.default_ue_sim_cfg.ue_cfg); reconf_user(ue_sim_ctxt.rnti, sim_args0.default_ue_sim_cfg.ue_cfg);
// setup lcid==drb1 bearer // setup lcid==drb1 bearer
sched::ue_bearer_cfg_t cfg = {}; sched::ue_bearer_cfg_t cfg = {};
cfg.direction = ue_bearer_cfg_t::BOTH; cfg.direction = ue_bearer_cfg_t::BOTH;

@ -40,42 +40,13 @@ struct ue_ctxt_test {
srslte::log_ref log_h{"TEST"}; srslte::log_ref log_h{"TEST"};
ue_ctxt_test_cfg sim_cfg; ue_ctxt_test_cfg sim_cfg;
// prach args ue_sim* ue_ctxt;
uint16_t rnti;
/* state */
srsenb::sched_interface::ue_cfg_t user_cfg;
srslte::tti_point current_tti_rx;
struct cc_ue_ctxt_test {
uint32_t ue_cc_idx = 0;
uint32_t enb_cc_idx = 0;
};
std::vector<cc_ue_ctxt_test> active_ccs;
ue_sim* ue_ctxt;
bool drb_cfg_flag = false; bool drb_cfg_flag = false;
ue_ctxt_test(uint16_t rnti_, srslte::tti_point prach_tti, const ue_ctxt_test_cfg& cfg_, ue_sim& ue_ctxt_); ue_ctxt_test(const ue_ctxt_test_cfg& cfg_, ue_sim& ue_ctxt_);
int set_cfg(const sched::ue_cfg_t& ue_cfg_);
cc_ue_ctxt_test* get_cc_state(uint32_t enb_cc_idx);
int new_tti(sched* sched_ptr, srslte::tti_point tti_rx); int new_tti(sched* sched_ptr, srslte::tti_point tti_rx);
int test_sched_result(uint32_t enb_cc_idx,
const sched::dl_sched_res_t& dl_result,
const sched::ul_sched_res_t& ul_result);
private:
int fwd_ue_feedback(sched* sched_ptr);
struct cc_result {
uint32_t enb_cc_idx;
const sched::dl_sched_res_t* dl_result;
const sched::ul_sched_res_t* ul_result;
};
//! Test correct activation of SCells
int test_scell_activation(cc_result result);
}; };
class user_state_sched_tester class user_state_sched_tester
@ -93,7 +64,7 @@ public:
} }
const sched::ue_cfg_t* get_user_cfg(uint16_t rnti) const const sched::ue_cfg_t* get_user_cfg(uint16_t rnti) const
{ {
return users.count(rnti) > 0 ? &users.find(rnti)->second.user_cfg : nullptr; return users.count(rnti) > 0 ? &sim_users.at(rnti).get_ctxt().ue_cfg : nullptr;
} }
/* Config users */ /* Config users */

Loading…
Cancel
Save