From 45bc123967538e51256042e6a93f7c30737d3aa2 Mon Sep 17 00:00:00 2001 From: Francisco Paisana Date: Thu, 19 Mar 2020 18:24:10 +0000 Subject: [PATCH] remove manual tti counters from the rrc --- lib/include/srslte/interfaces/ue_interfaces.h | 16 ++++++------- srsue/hdr/stack/rrc/rrc.h | 24 +++++++++---------- srsue/hdr/stack/rrc/rrc_procedures.h | 8 ++++--- srsue/hdr/stack/ue_stack_lte.h | 1 - srsue/src/stack/rrc/rrc.cc | 20 +++++++--------- srsue/src/stack/rrc/rrc_meas.cc | 2 +- srsue/src/stack/rrc/rrc_procedures.cc | 22 +++++++++++------ srsue/src/stack/ue_stack_lte.cc | 6 ++--- srsue/test/common/dummy_classes.h | 5 +++- srsue/test/upper/rrc_meas_test.cc | 14 +++++------ 10 files changed, 63 insertions(+), 55 deletions(-) diff --git a/lib/include/srslte/interfaces/ue_interfaces.h b/lib/include/srslte/interfaces/ue_interfaces.h index 2a49a08ac..df96fdbee 100644 --- a/lib/include/srslte/interfaces/ue_interfaces.h +++ b/lib/include/srslte/interfaces/ue_interfaces.h @@ -606,8 +606,15 @@ public: virtual void start_prach_configuration() = 0; }; +// Generic Task Management + Timer interface for upper stack +class task_handler_interface_lte +{ +public: + virtual srslte::timer_handler::unique_timer get_unique_timer() = 0; +}; + // STACK interface for RRC -class stack_interface_rrc +class stack_interface_rrc : public task_handler_interface_lte { public: virtual void start_cell_search() = 0; @@ -628,13 +635,6 @@ class phy_interface_stack_lte : public phy_interface_mac_lte, public phy_interfa { }; -// Generic Task Management + Timer interface for upper stack -class task_handler_interface_lte -{ -public: - virtual srslte::timer_handler::unique_timer get_unique_timer() = 0; -}; - } // namespace srsue #endif // SRSLTE_UE_INTERFACES_H diff --git a/srsue/hdr/stack/rrc/rrc.h b/srsue/hdr/stack/rrc/rrc.h index bc9a30aa5..cfc4f06dc 100644 --- a/srsue/hdr/stack/rrc/rrc.h +++ b/srsue/hdr/stack/rrc/rrc.h @@ -274,7 +274,7 @@ class rrc : public rrc_interface_nas, public srslte::timer_callback { public: - rrc(srslte::log* rrc_log_, task_handler_interface_lte* task_handler_); + rrc(srslte::log* rrc_log_, stack_interface_rrc* stack_); ~rrc(); void init(phy_interface_rrc_lte* phy_, @@ -284,7 +284,6 @@ public: nas_interface_rrc* nas_, usim_interface_rrc* usim_, gw_interface_rrc* gw_, - stack_interface_rrc* stack_, const rrc_args_t& args_); void stop(); @@ -361,17 +360,16 @@ private: void process_pcch(srslte::unique_byte_buffer_t pdu); - task_handler_interface_lte* task_handler = nullptr; - srslte::byte_buffer_pool* pool = nullptr; - srslte::log* rrc_log = nullptr; - phy_interface_rrc_lte* phy = nullptr; - mac_interface_rrc* mac = nullptr; - rlc_interface_rrc* rlc = nullptr; - pdcp_interface_rrc* pdcp = nullptr; - nas_interface_rrc* nas = nullptr; - usim_interface_rrc* usim = nullptr; - gw_interface_rrc* gw = nullptr; - stack_interface_rrc* stack = nullptr; + stack_interface_rrc* stack = nullptr; + srslte::byte_buffer_pool* pool = nullptr; + srslte::log* rrc_log = nullptr; + phy_interface_rrc_lte* phy = nullptr; + mac_interface_rrc* mac = nullptr; + rlc_interface_rrc* rlc = nullptr; + pdcp_interface_rrc* pdcp = nullptr; + nas_interface_rrc* nas = nullptr; + usim_interface_rrc* usim = nullptr; + gw_interface_rrc* gw = nullptr; srslte::unique_byte_buffer_t dedicated_info_nas; diff --git a/srsue/hdr/stack/rrc/rrc_procedures.h b/srsue/hdr/stack/rrc/rrc_procedures.h index d09cc38f9..0e236e064 100644 --- a/srsue/hdr/stack/rrc/rrc_procedures.h +++ b/srsue/hdr/stack/rrc/rrc_procedures.h @@ -240,14 +240,16 @@ public: explicit go_idle_proc(rrc* rrc_); srslte::proc_outcome_t init(); srslte::proc_outcome_t step(); + srslte::proc_outcome_t react(bool timeout); static const char* name() { return "Go Idle"; } private: - bool wait = false; - rrc* rrc_ptr; static const uint32_t rlc_flush_timeout = 2000; - uint32_t rlc_flush_counter; + rrc* rrc_ptr; + srslte::timer_handler::unique_timer rlc_flush_timer; + + bool wait = false; }; class rrc::cell_reselection_proc diff --git a/srsue/hdr/stack/ue_stack_lte.h b/srsue/hdr/stack/ue_stack_lte.h index 503011849..b08001e84 100644 --- a/srsue/hdr/stack/ue_stack_lte.h +++ b/srsue/hdr/stack/ue_stack_lte.h @@ -56,7 +56,6 @@ class ue_stack_lte final : public ue_stack_base, public stack_interface_gw, public stack_interface_mac, public stack_interface_rrc, - public task_handler_interface_lte, public srslte::thread { public: diff --git a/srsue/src/stack/rrc/rrc.cc b/srsue/src/stack/rrc/rrc.cc index f55fd71a8..0953d62d5 100644 --- a/srsue/src/stack/rrc/rrc.cc +++ b/srsue/src/stack/rrc/rrc.cc @@ -83,7 +83,8 @@ bool cell_t::is_sib_scheduled(uint32_t sib_index) const Base functions *******************************************************************************/ -rrc::rrc(srslte::log* rrc_log_, task_handler_interface_lte* task_handler_) : +rrc::rrc(srslte::log* rrc_log_, stack_interface_rrc* stack_) : + stack(stack_), state(RRC_STATE_IDLE), last_state(RRC_STATE_CONNECTED), drb_up(false), @@ -98,8 +99,7 @@ rrc::rrc(srslte::log* rrc_log_, task_handler_interface_lte* task_handler_) : plmn_searcher(this), cell_reselector(this), connection_reest(this), - serving_cell(unique_cell_t(new cell_t())), - task_handler(task_handler_) + serving_cell(unique_cell_t(new cell_t())) { measurements = std::unique_ptr(new rrc_meas(rrc_log)); } @@ -136,7 +136,6 @@ void rrc::init(phy_interface_rrc_lte* phy_, nas_interface_rrc* nas_, usim_interface_rrc* usim_, gw_interface_rrc* gw_, - stack_interface_rrc* stack_, const rrc_args_t& args_) { pool = byte_buffer_pool::get_instance(); @@ -147,7 +146,6 @@ void rrc::init(phy_interface_rrc_lte* phy_, nas = nas_; usim = usim_; gw = gw_; - stack = stack_; args = args_; @@ -156,12 +154,12 @@ void rrc::init(phy_interface_rrc_lte* phy_, security_is_activated = false; - t300 = task_handler->get_unique_timer(); - t301 = task_handler->get_unique_timer(); - t302 = task_handler->get_unique_timer(); - t310 = task_handler->get_unique_timer(); - t311 = task_handler->get_unique_timer(); - t304 = task_handler->get_unique_timer(); + t300 = stack->get_unique_timer(); + t301 = stack->get_unique_timer(); + t302 = stack->get_unique_timer(); + t310 = stack->get_unique_timer(); + t311 = stack->get_unique_timer(); + t304 = stack->get_unique_timer(); ue_identity_configured = false; diff --git a/srsue/src/stack/rrc/rrc_meas.cc b/srsue/src/stack/rrc/rrc_meas.cc index 7a1c7edf2..fc0614832 100644 --- a/srsue/src/stack/rrc/rrc_meas.cc +++ b/srsue/src/stack/rrc/rrc_meas.cc @@ -337,7 +337,7 @@ void rrc::rrc_meas::var_meas_report_list::set_measId(const uint32_t m // triggerType ‘event’ as well as for triggerType ‘periodical’ if (!varMeasReportList.at(measId).periodic_timer.is_valid() && (report_cfg.report_amount.to_number() > 1 || report_cfg.report_amount.to_number() == -1)) { - varMeasReportList.at(measId).periodic_timer = rrc_ptr->task_handler->get_unique_timer(); + varMeasReportList.at(measId).periodic_timer = rrc_ptr->stack->get_unique_timer(); varMeasReportList.at(measId).periodic_timer.set(report_cfg.report_interv.to_number()); } varMeasReportList.at(measId).report_cfg = std::move(report_cfg); diff --git a/srsue/src/stack/rrc/rrc_procedures.cc b/srsue/src/stack/rrc/rrc_procedures.cc index 6ccc5752c..1640334ef 100644 --- a/srsue/src/stack/rrc/rrc_procedures.cc +++ b/srsue/src/stack/rrc/rrc_procedures.cc @@ -242,8 +242,8 @@ compute_si_window(uint32_t tti, uint32_t sib_index, uint32_t n, uint32_t T, cons rrc::si_acquire_proc::si_acquire_proc(rrc* parent_) : rrc_ptr(parent_), log_h(parent_->rrc_log), - si_acq_timeout(rrc_ptr->task_handler->get_unique_timer()), - si_acq_retry_timer(rrc_ptr->task_handler->get_unique_timer()) + si_acq_timeout(rrc_ptr->stack->get_unique_timer()), + si_acq_retry_timer(rrc_ptr->stack->get_unique_timer()) { // SIB acquisition procedure timeout. // NOTE: The standard does not specify this timeout @@ -985,15 +985,24 @@ proc_outcome_t rrc::process_pcch_proc::react(paging_complete e) * Go Idle procedure *************************************/ -rrc::go_idle_proc::go_idle_proc(srsue::rrc* rrc_) : rrc_ptr(rrc_) {} +rrc::go_idle_proc::go_idle_proc(srsue::rrc* rrc_) : rrc_ptr(rrc_) +{ + rlc_flush_timer = rrc_ptr->stack->get_unique_timer(); + rlc_flush_timer.set(rlc_flush_timeout, [this](uint32_t tid) { rrc_ptr->idle_setter.trigger(true); }); +} proc_outcome_t rrc::go_idle_proc::init() { - rlc_flush_counter = 0; Info("Starting...\n"); return step(); } +srslte::proc_outcome_t rrc::go_idle_proc::react(bool timeout) +{ + rrc_ptr->leave_connected(); + return proc_outcome_t::success; +} + proc_outcome_t rrc::go_idle_proc::step() { if (rrc_ptr->state == RRC_STATE_IDLE) { @@ -1003,12 +1012,11 @@ proc_outcome_t rrc::go_idle_proc::step() // If the RLC SRB1 is not suspended // wait for max. 2s for RLC on SRB1 to be flushed - if (rrc_ptr->rlc->is_suspended(RB_ID_SRB1) || not rrc_ptr->rlc->has_data(RB_ID_SRB1) || - ++rlc_flush_counter > rlc_flush_timeout) { + if (rrc_ptr->rlc->is_suspended(RB_ID_SRB1) || not rrc_ptr->rlc->has_data(RB_ID_SRB1)) { rrc_ptr->leave_connected(); return proc_outcome_t::success; } else { - Debug("Postponing transition to RRC IDLE (%d ms < %d ms)\n", rlc_flush_counter, rlc_flush_timeout); + Debug("Postponing transition to RRC IDLE (%d ms < %d ms)\n", rlc_flush_timer.time_elapsed(), rlc_flush_timeout); } return proc_outcome_t::yield; } diff --git a/srsue/src/stack/ue_stack_lte.cc b/srsue/src/stack/ue_stack_lte.cc index ad75bd3f6..59157e5db 100644 --- a/srsue/src/stack/ue_stack_lte.cc +++ b/srsue/src/stack/ue_stack_lte.cc @@ -41,7 +41,7 @@ ue_stack_lte::ue_stack_lte() : mac(&mac_log), rrc(&rrc_log, this), pdcp(&timers, &pdcp_log), - nas(&timers), + nas(this), thread("STACK"), pending_tasks(512), background_tasks(2), @@ -139,7 +139,7 @@ int ue_stack_lte::init(const stack_args_t& args_, srslte::logger* logger_) rlc.init(&pdcp, &rrc, &timers, 0 /* RB_ID_SRB0 */); pdcp.init(&rlc, &rrc, gw); nas.init(usim.get(), &rrc, gw, args.nas); - rrc.init(phy, &mac, &rlc, &pdcp, &nas, usim.get(), gw, this, args.rrc); + rrc.init(phy, &mac, &rlc, &pdcp, &nas, usim.get(), gw, args.rrc); running = true; start(STACK_MAIN_THREAD_PRIO); @@ -315,9 +315,9 @@ void ue_stack_lte::run_tti_impl(uint32_t tti, uint32_t tti_jump) uint32_t next_tti = TTI_SUB(tti, (tti_jump - i - 1)); mac.run_tti(next_tti); rrc.run_tti(); - nas.run_tti(); timers.step_all(); } + nas.run_tti(); if (args.have_tti_time_stats) { std::chrono::nanoseconds dur = tti_tprof.stop(); diff --git a/srsue/test/common/dummy_classes.h b/srsue/test/common/dummy_classes.h index 3455011da..e1d695cb0 100644 --- a/srsue/test/common/dummy_classes.h +++ b/srsue/test/common/dummy_classes.h @@ -26,10 +26,13 @@ namespace srsue { -class stack_dummy : public task_handler_interface_lte +class stack_dummy : public stack_interface_rrc { public: srslte::timer_handler::unique_timer get_unique_timer() override { return timers.get_unique_timer(); } + void start_cell_search() override {} + void start_cell_select(const phy_interface_rrc_lte::phy_cell_t* cell) override {} + srslte::tti_point get_current_tti() override { return srslte::tti_point{timers.get_cur_time() % 10240}; } srslte::timer_handler timers{100}; }; diff --git a/srsue/test/upper/rrc_meas_test.cc b/srsue/test/upper/rrc_meas_test.cc index 9c9ee0555..cca528145 100644 --- a/srsue/test/upper/rrc_meas_test.cc +++ b/srsue/test/upper/rrc_meas_test.cc @@ -108,7 +108,7 @@ private: class nas_test : public srsue::nas { public: - nas_test(srslte::timer_handler* t) : srsue::nas(t) {} + nas_test(srsue::task_handler_interface_lte* t) : srsue::nas(t) {} bool is_attached() override { return false; } }; @@ -167,20 +167,20 @@ private: class rrc_test : public rrc { - srslte::timer_handler* timers = nullptr; + srsue::stack_dummy* stack = nullptr; public: - rrc_test(srslte::log* log_, stack_dummy* task_handler_) : rrc(log_, task_handler_), timers(&task_handler_->timers) + rrc_test(srslte::log* log_, stack_dummy* stack_) : rrc(log_, stack_), stack(stack_) { pool = srslte::byte_buffer_pool::get_instance(); - nastest = std::unique_ptr(new nas_test(timers)); - pdcptest = std::unique_ptr(new pdcp_test(log_, timers)); + nastest = std::unique_ptr(new nas_test(stack)); + pdcptest = std::unique_ptr(new pdcp_test(log_, &stack->timers)); }; - void init() { rrc::init(&phytest, nullptr, nullptr, pdcptest.get(), nastest.get(), nullptr, nullptr, nullptr, {}); } + void init() { rrc::init(&phytest, nullptr, nullptr, pdcptest.get(), nastest.get(), nullptr, nullptr, {}); } void run_tti(uint32_t tti_) { - timers->step_all(); + stack->timers.step_all(); rrc::run_tti(); }