remove old tti counter class

master
Francisco Paisana 5 years ago committed by Francisco Paisana
parent 3c29bce014
commit d5f1581759

@ -57,7 +57,7 @@ sim_sched_args generate_default_sim_args(uint32_t nof_prb, uint32_t nof_ccs)
sim_args.P_retx = 0.1;
sim_args.ue_cfg = generate_default_ue_cfg();
sim_args.default_ue_sim_cfg.ue_cfg = generate_default_ue_cfg();
// setup two cells
std::vector<srsenb::sched_interface::cell_cfg_t> cell_cfg(nof_ccs, generate_default_cell_cfg(nof_prb));
@ -71,10 +71,10 @@ sim_sched_args generate_default_sim_args(uint32_t nof_prb, uint32_t nof_ccs)
sim_args.cell_cfg = std::move(cell_cfg);
/* Setup Derived Params */
sim_args.ue_cfg.supported_cc_list.resize(nof_ccs);
for (uint32_t i = 0; i < sim_args.ue_cfg.supported_cc_list.size(); ++i) {
sim_args.ue_cfg.supported_cc_list[i].active = true;
sim_args.ue_cfg.supported_cc_list[i].enb_cc_idx = i;
sim_args.default_ue_sim_cfg.ue_cfg.supported_cc_list.resize(nof_ccs);
for (uint32_t i = 0; i < sim_args.default_ue_sim_cfg.ue_cfg.supported_cc_list.size(); ++i) {
sim_args.default_ue_sim_cfg.ue_cfg.supported_cc_list[i].active = true;
sim_args.default_ue_sim_cfg.ue_cfg.supported_cc_list[i].enb_cc_idx = i;
}
return sim_args;
@ -125,9 +125,9 @@ int test_scell_activation(test_scell_activation_params params)
// Event PRACH: PRACH takes place for "rnti1", and carrier "pcell_idx"
generator.step_until(prach_tti);
tti_ev::user_cfg_ev* user = generator.add_new_default_user(duration);
user->ue_cfg->supported_cc_list[0].enb_cc_idx = cc_idxs[0];
user->rnti = rnti1;
tti_ev::user_cfg_ev* user = generator.add_new_default_user(duration);
user->ue_sim_cfg->ue_cfg.supported_cc_list[0].enb_cc_idx = cc_idxs[0];
user->rnti = rnti1;
tester.test_next_ttis(generator.tti_events);
TESTASSERT(tester.ue_tester->user_exists(rnti1));
@ -166,12 +166,13 @@ int test_scell_activation(test_scell_activation_params params)
// Event: Reconf Complete. Activate SCells. Check if CE correctly transmitted
generator.step_tti();
user = generator.user_reconf(rnti1);
*user->ue_cfg = *tester.get_current_ue_cfg(rnti1); // use current cfg as starting point, and add more supported ccs
user->ue_cfg->supported_cc_list.resize(nof_ccs);
for (uint32_t i = 0; i < user->ue_cfg->supported_cc_list.size(); ++i) {
user->ue_cfg->supported_cc_list[i].active = true;
user->ue_cfg->supported_cc_list[i].enb_cc_idx = cc_idxs[i];
user = generator.user_reconf(rnti1);
user->ue_sim_cfg->ue_cfg =
*tester.get_current_ue_cfg(rnti1); // use current cfg as starting point, and add more supported ccs
user->ue_sim_cfg->ue_cfg.supported_cc_list.resize(nof_ccs);
for (uint32_t i = 0; i < user->ue_sim_cfg->ue_cfg.supported_cc_list.size(); ++i) {
user->ue_sim_cfg->ue_cfg.supported_cc_list[i].active = true;
user->ue_sim_cfg->ue_cfg.supported_cc_list[i].enb_cc_idx = cc_idxs[i];
}
tester.test_next_ttis(generator.tti_events);
auto activ_list = tester.get_enb_ue_cc_map(rnti1);

@ -305,9 +305,8 @@ int output_sched_tester::test_all(const tti_params_t& tti_par
ue_ctxt_test::ue_ctxt_test(uint16_t rnti_,
uint32_t preamble_idx_,
srslte::tti_point prach_tti_,
const sched::ue_cfg_t& ue_cfg_,
const std::vector<srsenb::sched::cell_cfg_t>& cell_params_,
const ue_ctxt_test_cfg& cfg_) :
const ue_ctxt_test_cfg& cfg_,
const std::vector<srsenb::sched::cell_cfg_t>& cell_params_) :
sim_cfg(cfg_),
rnti(rnti_),
prach_tti(prach_tti_),
@ -315,7 +314,7 @@ ue_ctxt_test::ue_ctxt_test(uint16_t rnti_,
cell_params(cell_params_),
current_tti_rx(prach_tti_)
{
set_cfg(ue_cfg_);
set_cfg(cfg_.ue_cfg);
}
int ue_ctxt_test::set_cfg(const sched::ue_cfg_t& ue_cfg_)
@ -730,17 +729,13 @@ void user_state_sched_tester::new_tti(sched* sched_ptr, uint32_t tti_rx)
}
}
int user_state_sched_tester::add_user(uint16_t rnti,
uint32_t preamble_idx,
const srsenb::sched_interface::ue_cfg_t& ue_cfg,
const ue_ctxt_test_cfg& cfg_)
int user_state_sched_tester::add_user(uint16_t rnti, uint32_t preamble_idx, const ue_ctxt_test_cfg& cfg_)
{
CONDERROR(!srslte_prach_tti_opportunity_config_fdd(
cell_params[ue_cfg.supported_cc_list[0].enb_cc_idx].prach_config, tic.tti_rx(), -1),
cell_params[cfg_.ue_cfg.supported_cc_list[0].enb_cc_idx].prach_config, tic.to_uint(), -1),
"New user added in a non-PRACH TTI\n");
TESTASSERT(users.count(rnti) == 0);
ue_ctxt_test_cfg cfg;
ue_ctxt_test ue{rnti, preamble_idx, srslte::tti_point{tic.tti_rx()}, ue_cfg, cell_params, cfg_};
ue_ctxt_test ue{rnti, preamble_idx, srslte::tti_point{tic.to_uint()}, cfg_, cell_params};
users.insert(std::make_pair(rnti, ue));
return SRSLTE_SUCCESS;
}
@ -890,9 +885,9 @@ int common_sched_tester::sim_cfg(sim_sched_args args)
return SRSLTE_SUCCESS;
}
int common_sched_tester::add_user(uint16_t rnti, const ue_cfg_t& ue_cfg_)
int common_sched_tester::add_user(uint16_t rnti, const ue_ctxt_test_cfg& ue_cfg_)
{
CONDERROR(ue_cfg(rnti, ue_cfg_) != SRSLTE_SUCCESS, "Configuring new user rnti=0x%x to sched\n", rnti);
CONDERROR(ue_cfg(rnti, ue_cfg_.ue_cfg) != SRSLTE_SUCCESS, "Configuring new user rnti=0x%x to sched\n", rnti);
// CONDERROR(!srslte_prach_tti_opportunity_config_fdd(
// sched_cell_params[CARRIER_IDX].cfg.prach_config, tti_info.tti_params.tti_rx, -1),
// "New user added in a non-PRACH TTI\n");
@ -902,12 +897,10 @@ int common_sched_tester::add_user(uint16_t rnti, const ue_cfg_t& ue_cfg_)
rar_info.temp_crnti = rnti;
rar_info.msg3_size = 7;
rar_info.preamble_idx = tti_info.nof_prachs++;
uint32_t pcell_idx = ue_cfg_.supported_cc_list[0].enb_cc_idx;
uint32_t pcell_idx = ue_cfg_.ue_cfg.supported_cc_list[0].enb_cc_idx;
dl_rach_info(pcell_idx, rar_info);
ue_ctxt_test_cfg ue_sim_cfg{};
ue_sim_cfg.periodic_cqi = sim_args0.cqi_policy == sim_sched_args::cqi_gen_policy_t::periodic_random;
ue_tester->add_user(rnti, rar_info.preamble_idx, ue_cfg_, ue_sim_cfg);
ue_tester->add_user(rnti, rar_info.preamble_idx, ue_cfg_);
tester_log->info("Adding user rnti=0x%x\n", rnti);
return SRSLTE_SUCCESS;
@ -923,12 +916,12 @@ void common_sched_tester::rem_user(uint16_t rnti)
void common_sched_tester::new_test_tti()
{
if (not tic.is_valid()) {
tic.set_start_tti(sim_args0.start_tti);
tic = srslte::tti_point{sim_args0.start_tti};
} else {
tic++;
}
tti_info.tti_params = tti_params_t{tic.tti_rx()};
tti_info.tti_params = tti_params_t{tic.to_uint()};
tti_info.nof_prachs = 0;
tti_info.dl_sched_result.clear();
tti_info.ul_sched_result.clear();
@ -954,14 +947,14 @@ int common_sched_tester::process_tti_events(const tti_ev& tti_ev)
{
for (const tti_ev::user_cfg_ev& ue_ev : tti_ev.user_updates) {
// There is a new configuration
if (ue_ev.ue_cfg != nullptr) {
if (ue_ev.ue_sim_cfg != nullptr) {
if (not ue_tester->user_exists(ue_ev.rnti)) {
// new user
TESTASSERT(add_user(ue_ev.rnti, *ue_ev.ue_cfg) == SRSLTE_SUCCESS);
TESTASSERT(add_user(ue_ev.rnti, *ue_ev.ue_sim_cfg) == SRSLTE_SUCCESS);
} else {
// reconfiguration
TESTASSERT(ue_cfg(ue_ev.rnti, *ue_ev.ue_cfg) == SRSLTE_SUCCESS);
ue_tester->user_reconf(ue_ev.rnti, *ue_ev.ue_cfg);
TESTASSERT(ue_cfg(ue_ev.rnti, ue_ev.ue_sim_cfg->ue_cfg) == SRSLTE_SUCCESS);
ue_tester->user_reconf(ue_ev.rnti, ue_ev.ue_sim_cfg->ue_cfg);
}
}
@ -979,8 +972,7 @@ int common_sched_tester::process_tti_events(const tti_ev& tti_ev)
auto* user = ue_tester->get_user_ctxt(ue_ev.rnti);
if (user != nullptr and not user->msg4_tti.is_valid() and user->msg3_tti.is_valid() and
user->msg3_tti.to_uint() <= tic.tti_rx()) {
if (user != nullptr and not user->msg4_tti.is_valid() and user->msg3_tti.is_valid() and user->msg3_tti <= tic) {
// Msg3 has been received but Msg4 has not been yet transmitted
uint32_t pending_dl_new_data = ue_db[ue_ev.rnti].get_pending_dl_new_data();
if (pending_dl_new_data == 0) {
@ -1030,7 +1022,7 @@ int common_sched_tester::process_tti_events(const tti_ev& tti_ev)
int common_sched_tester::run_tti(const tti_ev& tti_events)
{
new_test_tti();
tester_log->info("---- tti=%u | nof_ues=%zd ----\n", tic.tti_rx(), ue_db.size());
tester_log->info("---- tti=%u | nof_ues=%zd ----\n", tic.to_uint(), ue_db.size());
ue_tester->new_tti(this, tti_info.tti_params.tti_rx);
process_tti_events(tti_events);
@ -1047,15 +1039,14 @@ int common_sched_tester::run_tti(const tti_ev& tti_events)
}
process_results();
tti_count++;
return SRSLTE_SUCCESS;
}
int common_sched_tester::test_next_ttis(const std::vector<tti_ev>& tti_events)
{
uint32_t next_idx = tic.is_valid() ? tic.total_count() - sim_args0.start_tti + 1 : 0;
for (; next_idx < tti_events.size(); ++next_idx) {
TESTASSERT(run_tti(tti_events[next_idx]) == SRSLTE_SUCCESS);
while (tti_count < tti_events.size()) {
TESTASSERT(run_tti(tti_events[tti_count]) == SRSLTE_SUCCESS);
}
return SRSLTE_SUCCESS;
}

@ -83,11 +83,6 @@ private:
using dl_sched_res_list = std::vector<sched_interface::dl_sched_res_t>;
using ul_sched_res_list = std::vector<sched_interface::ul_sched_res_t>;
struct ue_ctxt_test_cfg {
bool periodic_cqi = false;
uint32_t cqi_Npd = 10, cqi_Noffset = std::uniform_int_distribution<uint32_t>{0, 10}(get_rand_gen()); // CQI reporting
};
struct ue_ctxt_test {
// args
srslte::log_ref log_h{"TEST"};
@ -129,9 +124,8 @@ struct ue_ctxt_test {
ue_ctxt_test(uint16_t rnti_,
uint32_t preamble_idx_,
srslte::tti_point prach_tti,
const sched::ue_cfg_t& ue_cfg_,
const std::vector<srsenb::sched::cell_cfg_t>& cell_params_,
const ue_ctxt_test_cfg& cfg_);
const ue_ctxt_test_cfg& cfg_,
const std::vector<srsenb::sched::cell_cfg_t>& cell_params_);
int set_cfg(const sched::ue_cfg_t& ue_cfg_);
cc_ue_ctxt_test* get_cc_state(uint32_t enb_cc_idx);
@ -187,10 +181,7 @@ public:
}
/* Config users */
int add_user(uint16_t rnti,
uint32_t preamble_idx,
const srsenb::sched_interface::ue_cfg_t& ue_cfg,
const ue_ctxt_test_cfg& cfg);
int add_user(uint16_t rnti, uint32_t preamble_idx, const ue_ctxt_test_cfg& cfg);
int user_reconf(uint16_t rnti, const srsenb::sched_interface::ue_cfg_t& ue_cfg);
int bearer_cfg(uint16_t rnti, uint32_t lcid, const srsenb::sched_interface::ue_bearer_cfg_t& bearer_cfg);
void rem_user(uint16_t rnti);
@ -208,7 +199,7 @@ private:
const std::vector<srsenb::sched::cell_cfg_t>& cell_params;
std::map<uint16_t, ue_ctxt_test> users;
tti_counter tic;
srslte::tti_point tic;
};
class sched_result_stats
@ -252,7 +243,7 @@ public:
const ue_cfg_t* get_current_ue_cfg(uint16_t rnti) const;
int sim_cfg(sim_sched_args args);
virtual int add_user(uint16_t rnti, const ue_cfg_t& ue_cfg_);
virtual int add_user(uint16_t rnti, const ue_ctxt_test_cfg& ue_cfg_);
virtual void rem_user(uint16_t rnti);
virtual int process_results();
int process_tti_events(const tti_ev& tti_ev);
@ -265,8 +256,9 @@ public:
srslte::log* tester_log = nullptr;
// tti specific params
tti_info_t tti_info;
tti_counter tic;
tti_info_t tti_info;
srslte::tti_point tic;
uint32_t tti_count = 0;
// testers
std::vector<output_sched_tester> output_tester;

@ -295,10 +295,10 @@ int sched_tester::test_harqs()
CONDERROR(tti_data.ue_data[rnti].dl_harqs[h_id].nof_retx(0) + 1 != h.nof_retx(0),
"A dl harq of user rnti=0x%x was likely overwritten.\n",
rnti);
CONDERROR(h.nof_retx(0) >= sim_args0.ue_cfg.maxharq_tx,
CONDERROR(h.nof_retx(0) >= sim_args0.default_ue_sim_cfg.ue_cfg.maxharq_tx,
"The number of retx=%d exceeded its max=%d\n",
h.nof_retx(0),
sim_args0.ue_cfg.maxharq_tx);
sim_args0.default_ue_sim_cfg.ue_cfg.maxharq_tx);
} else { // newtx
CONDERROR(h.nof_retx(0) != 0, "A new harq was scheduled but with invalid number of retxs\n");
}
@ -451,12 +451,12 @@ sched_sim_events rand_sim_params(uint32_t nof_ttis)
sched_sim_event_generator generator;
sim_gen.sim_args.cell_cfg = {generate_default_cell_cfg(nof_prb)};
sim_gen.sim_args.ue_cfg = generate_default_ue_cfg();
sim_gen.sim_args.P_retx = 0.1;
sim_gen.sim_args.start_tti = 0;
sim_gen.sim_args.sim_log = log_global.get();
sim_gen.sim_args.cqi_policy = sim_sched_args::cqi_gen_policy_t::periodic_random;
sim_gen.sim_args.cell_cfg = {generate_default_cell_cfg(nof_prb)};
sim_gen.sim_args.default_ue_sim_cfg.ue_cfg = generate_default_ue_cfg();
sim_gen.sim_args.default_ue_sim_cfg.periodic_cqi = true;
sim_gen.sim_args.P_retx = 0.1;
sim_gen.sim_args.start_tti = 0;
sim_gen.sim_args.sim_log = log_global.get();
generator.tti_events.resize(nof_ttis);

@ -29,61 +29,6 @@
#include <chrono>
#include <unordered_map>
struct tti_counter {
tti_counter() = default;
void set_start_tti(uint32_t tti_) { counter = tti_; }
uint32_t tti_rx() const { return counter % 10240u; }
tti_counter tic_tx_dl() const { return tti_counter{counter + FDD_HARQ_DELAY_UL_MS}; }
tti_counter tic_tx_ul() const { return tti_counter{counter + FDD_HARQ_DELAY_UL_MS + FDD_HARQ_DELAY_DL_MS}; }
bool operator==(const tti_counter& other) const { return counter == other.counter; }
bool operator!=(const tti_counter& other) const { return counter != other.counter; }
bool operator<(const tti_counter& other) const { return counter < other.counter; }
bool operator<=(const tti_counter& other) const { return counter <= other.counter; }
bool operator>=(const tti_counter& other) const { return counter >= other.counter; }
bool operator>(const tti_counter& other) const { return counter > other.counter; }
uint32_t operator-(const tti_counter& other) const { return counter - other.counter; }
tti_counter& operator-=(uint32_t jump)
{
counter -= jump;
return *this;
}
tti_counter& operator+=(uint32_t jump)
{
counter += jump;
return *this;
}
tti_counter& operator+=(int32_t jump)
{
counter += jump;
return *this;
}
tti_counter& operator++() { return this->operator+=(1); }
tti_counter operator+(int32_t jump) { return tti_counter{counter + jump}; }
tti_counter operator++(int) { return tti_counter{++counter}; }
bool is_valid() const { return counter != std::numeric_limits<uint32_t>::max(); }
uint32_t total_count() const { return counter; }
private:
explicit tti_counter(uint32_t c_) : counter(c_) {}
uint32_t counter = std::numeric_limits<uint32_t>::max();
};
/***************************
* Function helpers
**************************/
template <class MapContainer, class Predicate>
void erase_if(MapContainer& c, Predicate should_remove)
{
for (auto it = c.begin(); it != c.end();) {
if (should_remove(*it)) {
it = c.erase(it);
} else {
++it;
}
}
}
/*****************************
* Setup Sched Configuration
****************************/
@ -134,6 +79,13 @@ inline srsenb::sched_interface::ue_cfg_t generate_default_ue_cfg()
* Event Types
****************************/
//! Struct with ue_cfg_t params used by the scheduler, and params used in its behavior simulation
struct ue_ctxt_test_cfg {
bool periodic_cqi = false;
uint32_t cqi_Npd = 10, cqi_Noffset = 5; // CQI reporting
srsenb::sched_interface::ue_cfg_t ue_cfg;
};
// Struct that represents all the events that take place in a TTI
struct tti_ev {
struct user_buffer_ev {
@ -143,7 +95,7 @@ struct tti_ev {
};
struct user_cfg_ev {
uint16_t rnti;
std::unique_ptr<srsenb::sched_interface::ue_cfg_t> ue_cfg; ///< optional ue_cfg call
std::unique_ptr<ue_ctxt_test_cfg> ue_sim_cfg; ///< optional ue_cfg call
std::unique_ptr<srsenb::sched_interface::ue_bearer_cfg_t> bearer_cfg; ///< optional bearer_cfg call
std::unique_ptr<user_buffer_ev> buffer_ev; ///< update of a user dl/ul buffer
bool rem_user = false; ///< whether to remove a ue
@ -154,10 +106,9 @@ struct tti_ev {
struct sim_sched_args {
uint32_t start_tti = 0;
float P_retx;
srsenb::sched_interface::ue_cfg_t ue_cfg;
std::vector<srsenb::sched_interface::cell_cfg_t> cell_cfg;
srslte::log* sim_log = nullptr;
enum class cqi_gen_policy_t { none, periodic_random } cqi_policy = cqi_gen_policy_t::none;
srslte::log* sim_log = nullptr;
ue_ctxt_test_cfg default_ue_sim_cfg;
};
// generate all events up front
@ -213,7 +164,9 @@ struct sched_sim_event_generator {
auto& user = user_updates.back();
user.rnti = next_rnti++;
// creates a user with one supported CC (PRACH stage)
user.ue_cfg.reset(new srsenb::sched_interface::ue_cfg_t{generate_default_ue_cfg()});
ue_ctxt_test_cfg ue_sim_cfg{};
ue_sim_cfg.ue_cfg = generate_default_ue_cfg();
user.ue_sim_cfg.reset(new ue_ctxt_test_cfg{ue_sim_cfg});
auto& u = current_users[user.rnti];
u.rnti = user.rnti;
u.tti_start = tti_counter;
@ -249,9 +202,11 @@ struct sched_sim_event_generator {
return nullptr;
}
tti_ev::user_cfg_ev* user = get_user_cfg(rnti);
user->ue_cfg.reset(new srsenb::sched_interface::ue_cfg_t{generate_default_ue_cfg()});
ue_ctxt_test_cfg ue_sim_cfg{};
ue_sim_cfg.ue_cfg = generate_default_ue_cfg();
user->ue_sim_cfg.reset(new ue_ctxt_test_cfg{ue_sim_cfg});
// it should by now have a DRB1. Add other DRBs manually
user->ue_cfg->ue_bearers[2].direction = srsenb::sched_interface::ue_bearer_cfg_t::BOTH;
user->ue_sim_cfg->ue_cfg.ue_bearers[2].direction = srsenb::sched_interface::ue_bearer_cfg_t::BOTH;
return user;
}

Loading…
Cancel
Save