renamed ue test structs

master
Francisco Paisana 5 years ago committed by Francisco Paisana
parent 1e56082214
commit 5d41fd0aec

@ -302,12 +302,14 @@ int output_sched_tester::test_all(const tti_params_t& tti_par
* User State Tester * User State Tester
***********************/ ***********************/
ue_state::ue_state(uint16_t rnti_, const sched::ue_cfg_t& ue_cfg_) : rnti(rnti_) ue_ctxt_test::ue_ctxt_test(uint16_t rnti_, uint32_t preamble_idx_, const sched::ue_cfg_t& ue_cfg_) :
rnti(rnti_),
preamble_idx(preamble_idx_)
{ {
set_cfg(ue_cfg_); set_cfg(ue_cfg_);
} }
int ue_state::set_cfg(const sched::ue_cfg_t& 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) { 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]; const auto& cc = ue_cfg_.supported_cc_list[ue_cc_idx];
@ -329,14 +331,15 @@ int ue_state::set_cfg(const sched::ue_cfg_t& ue_cfg_)
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
} }
ue_state::cc_state_t* ue_state::get_cc_state(uint32_t enb_cc_idx) ue_ctxt_test::cc_ue_ctxt_test* ue_ctxt_test::get_cc_state(uint32_t enb_cc_idx)
{ {
auto it = std::find_if( auto it = std::find_if(active_ccs.begin(), active_ccs.end(), [enb_cc_idx](const cc_ue_ctxt_test& c) {
active_ccs.begin(), active_ccs.end(), [enb_cc_idx](const cc_state_t& c) { return c.enb_cc_idx == enb_cc_idx; }); return c.enb_cc_idx == enb_cc_idx;
});
return it == active_ccs.end() ? nullptr : &(*it); return it == active_ccs.end() ? nullptr : &(*it);
} }
int ue_state::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; current_tti_rx = tti_rx;
@ -345,7 +348,7 @@ int ue_state::new_tti(sched* sched_ptr, srslte::tti_point tti_rx)
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
} }
int ue_state::fwd_pending_acks(sched* sched_ptr) int ue_ctxt_test::fwd_pending_acks(sched* sched_ptr)
{ {
/* Ack DL HARQs */ /* Ack DL HARQs */
// Checks: // Checks:
@ -392,7 +395,7 @@ int ue_state::fwd_pending_acks(sched* sched_ptr)
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
} }
int ue_state::process_sched_result(uint32_t enb_cc_idx, int ue_ctxt_test::test_sched_result(uint32_t enb_cc_idx,
const sched::dl_sched_res_t& dl_result, const sched::dl_sched_res_t& dl_result,
const sched::ul_sched_res_t& ul_result) const sched::ul_sched_res_t& ul_result)
{ {
@ -405,12 +408,12 @@ int ue_state::process_sched_result(uint32_t enb_cc_idx,
/** /**
* Sanity checks of the DCI values in the scheduling result for a given user. Current checks: * Sanity checks of the DCI values in the scheduling result for a given user. Current checks:
* - invalid ue_cc_idx<->enb_cc_idx matching in dl_result * - invalid ue_cc_idx<->enb_cc_idx matching in dl_result
* - invalid pid value * - reusing same pid too early (ACK still didn't arrive yet)
* - invalid rv value (nof retxs is incorrect) and ndi value * - invalid rv value (nof retxs is incorrect) and ndi value
*/ */
int ue_state::test_harqs(cc_result result) int ue_ctxt_test::test_harqs(cc_result result)
{ {
cc_state_t* cc = get_cc_state(result.enb_cc_idx); cc_ue_ctxt_test* cc = get_cc_state(result.enb_cc_idx);
if (cc == nullptr) { if (cc == nullptr) {
// unsupported carrier // unsupported carrier
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
@ -489,7 +492,7 @@ int ue_state::test_harqs(cc_result result)
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
} }
int ue_state::schedule_acks(cc_result result) int ue_ctxt_test::schedule_acks(cc_result result)
{ {
auto* cc = get_cc_state(result.enb_cc_idx); auto* cc = get_cc_state(result.enb_cc_idx);
if (cc == nullptr) { if (cc == nullptr) {
@ -570,9 +573,8 @@ int user_state_sched_tester::add_user(uint16_t r
cell_params[ue_cfg.supported_cc_list[0].enb_cc_idx].prach_config, tic.tti_rx(), -1), cell_params[ue_cfg.supported_cc_list[0].enb_cc_idx].prach_config, tic.tti_rx(), -1),
"New user added in a non-PRACH TTI\n"); "New user added in a non-PRACH TTI\n");
TESTASSERT(users.count(rnti) == 0); TESTASSERT(users.count(rnti) == 0);
ue_state ue{rnti, ue_cfg}; ue_ctxt_test ue{rnti, preamble_idx, ue_cfg};
ue.prach_tic = tic; ue.prach_tic = tic;
ue.preamble_idx = preamble_idx;
users.insert(std::make_pair(rnti, ue)); users.insert(std::make_pair(rnti, ue));
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
} }
@ -624,7 +626,7 @@ int user_state_sched_tester::test_ra(uint32_t enb_
for (auto& iter : users) { for (auto& iter : users) {
uint16_t rnti = iter.first; uint16_t rnti = iter.first;
ue_state& userinfo = iter.second; ue_ctxt_test& userinfo = iter.second;
uint32_t primary_cc_idx = userinfo.user_cfg.supported_cc_list[0].enb_cc_idx; uint32_t primary_cc_idx = userinfo.user_cfg.supported_cc_list[0].enb_cc_idx;
if (enb_cc_idx != primary_cc_idx) { if (enb_cc_idx != primary_cc_idx) {
@ -751,7 +753,7 @@ int user_state_sched_tester::test_ctrl_info(uint32_t
for (uint32_t j = 0; j < dl_result.rar[i].nof_grants; ++j) { for (uint32_t j = 0; j < dl_result.rar[i].nof_grants; ++j) {
uint32_t prach_tti = dl_result.rar[i].msg3_grant[j].data.prach_tti; uint32_t prach_tti = dl_result.rar[i].msg3_grant[j].data.prach_tti;
uint32_t preamble_idx = dl_result.rar[i].msg3_grant[j].data.preamble_idx; uint32_t preamble_idx = dl_result.rar[i].msg3_grant[j].data.preamble_idx;
auto it = std::find_if(users.begin(), users.end(), [&](const std::pair<uint16_t, ue_state>& u) { auto it = std::find_if(users.begin(), users.end(), [&](const std::pair<uint16_t, ue_ctxt_test>& u) {
return u.second.preamble_idx == preamble_idx and ((uint32_t)u.second.prach_tic.tti_rx() == prach_tti); return u.second.preamble_idx == preamble_idx and ((uint32_t)u.second.prach_tic.tti_rx() == prach_tti);
}); });
CONDERROR(it == users.end(), "There was a RAR allocation with no associated user"); CONDERROR(it == users.end(), "There was a RAR allocation with no associated user");
@ -791,7 +793,7 @@ int user_state_sched_tester::test_scell_activation(uint32_t
{ {
for (auto& iter : users) { for (auto& iter : users) {
uint16_t rnti = iter.first; uint16_t rnti = iter.first;
ue_state& userinfo = iter.second; ue_ctxt_test& userinfo = iter.second;
auto it = std::find_if(userinfo.user_cfg.supported_cc_list.begin(), auto it = std::find_if(userinfo.user_cfg.supported_cc_list.begin(),
userinfo.user_cfg.supported_cc_list.end(), userinfo.user_cfg.supported_cc_list.end(),
@ -833,7 +835,7 @@ int user_state_sched_tester::test_all(uint32_t enb
TESTASSERT(test_scell_activation(enb_cc_idx, dl_result, ul_result) == SRSLTE_SUCCESS); TESTASSERT(test_scell_activation(enb_cc_idx, dl_result, ul_result) == SRSLTE_SUCCESS);
for (auto& u : users) { for (auto& u : users) {
TESTASSERT(u.second.process_sched_result(enb_cc_idx, dl_result, ul_result) == SRSLTE_SUCCESS); TESTASSERT(u.second.test_sched_result(enb_cc_idx, dl_result, ul_result) == SRSLTE_SUCCESS);
} }
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;

@ -83,17 +83,20 @@ private:
using dl_sched_res_list = std::vector<sched_interface::dl_sched_res_t>; 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>; using ul_sched_res_list = std::vector<sched_interface::ul_sched_res_t>;
struct ue_state { struct ue_ctxt_test {
// args // args
srslte::log_ref log_h{"TEST"}; srslte::log_ref log_h{"TEST"};
uint32_t cqi_Npd = 10, cqi_Noffset = std::uniform_int_distribution<uint32_t>{0, 10}(get_rand_gen()); // CQI reporting uint32_t cqi_Npd = 10, cqi_Noffset = std::uniform_int_distribution<uint32_t>{0, 10}(get_rand_gen()); // CQI reporting
std::vector<float> prob_dl_ack_mask{0.5, 0.5, 1}, prob_ul_ack_mask{0.5, 0.5, 1}; std::vector<float> prob_dl_ack_mask{0.5, 0.5, 1}, prob_ul_ack_mask{0.5, 0.5, 1};
// state // prach args
uint16_t rnti; uint16_t rnti;
uint32_t preamble_idx = 0;
/* state */
srslte::tti_point current_tti_rx; srslte::tti_point current_tti_rx;
struct cc_state_t { struct cc_ue_ctxt_test {
uint32_t ue_cc_idx = 0; uint32_t ue_cc_idx = 0;
uint32_t enb_cc_idx = 0; uint32_t enb_cc_idx = 0;
// Harq State // Harq State
@ -109,21 +112,21 @@ struct ue_state {
std::array<harq_state_t, sched_ue_carrier::SCHED_MAX_HARQ_PROC> dl_harqs = {}; std::array<harq_state_t, sched_ue_carrier::SCHED_MAX_HARQ_PROC> dl_harqs = {};
std::array<harq_state_t, sched_ue_carrier::SCHED_MAX_HARQ_PROC> ul_harqs = {}; std::array<harq_state_t, sched_ue_carrier::SCHED_MAX_HARQ_PROC> ul_harqs = {};
}; };
std::vector<cc_state_t> active_ccs; std::vector<cc_ue_ctxt_test> active_ccs;
tti_counter prach_tic, rar_tic, msg3_tic, msg4_tic; tti_counter prach_tic, rar_tic, msg3_tic, msg4_tic;
bool drb_cfg_flag = false; bool drb_cfg_flag = false;
srsenb::sched_interface::ue_cfg_t user_cfg; srsenb::sched_interface::ue_cfg_t user_cfg;
uint32_t preamble_idx = 0;
uint32_t msg3_riv = 0; uint32_t msg3_riv = 0;
bool is_msg3_rx(const tti_counter& tti_rx) const { return msg3_tic.is_valid() and msg3_tic <= tti_rx; } bool is_msg3_rx(const tti_counter& tti_rx) const { return msg3_tic.is_valid() and msg3_tic <= tti_rx; }
ue_state(uint16_t rnti_, const sched::ue_cfg_t& ue_cfg_); ue_ctxt_test(uint16_t rnti_, uint32_t preamble_idx_, const sched::ue_cfg_t& ue_cfg_);
int set_cfg(const sched::ue_cfg_t& ue_cfg_); int set_cfg(const sched::ue_cfg_t& ue_cfg_);
cc_state_t* get_cc_state(uint32_t enb_cc_idx); 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 process_sched_result(uint32_t enb_cc_idx, int test_sched_result(uint32_t enb_cc_idx,
const sched::dl_sched_res_t& dl_result, const sched::dl_sched_res_t& dl_result,
const sched::ul_sched_res_t& ul_result); const sched::ul_sched_res_t& ul_result);
@ -156,7 +159,7 @@ public:
void new_tti(sched* sched_ptr, uint32_t tti_rx); void new_tti(sched* sched_ptr, uint32_t tti_rx);
bool user_exists(uint16_t rnti) const { return users.find(rnti) != users.end(); } bool user_exists(uint16_t rnti) const { return users.find(rnti) != users.end(); }
const ue_state* get_user_state(uint16_t rnti) const const ue_ctxt_test* get_user_state(uint16_t rnti) const
{ {
return users.count(rnti) > 0 ? &users.find(rnti)->second : nullptr; return users.count(rnti) > 0 ? &users.find(rnti)->second : nullptr;
} }
@ -189,7 +192,7 @@ public:
private: private:
const std::vector<srsenb::sched::cell_cfg_t>& cell_params; const std::vector<srsenb::sched::cell_cfg_t>& cell_params;
std::map<uint16_t, ue_state> users; std::map<uint16_t, ue_ctxt_test> users;
tti_counter tic; tti_counter tic;
}; };

Loading…
Cancel
Save