From 2d126371f6fc2fba819264a29de4cf69d3a77e01 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Tue, 29 Oct 2019 16:31:27 +0100 Subject: [PATCH] adopt PDCP NR to use new timer class --- lib/include/srslte/upper/pdcp_entity_base.h | 4 +++- lib/include/srslte/upper/pdcp_entity_nr.h | 6 ++--- lib/src/upper/pdcp_entity_nr.cc | 25 ++++++++++++--------- lib/test/upper/pdcp_nr_test.cc | 11 ++++++--- lib/test/upper/pdcp_nr_test.h | 2 +- 5 files changed, 29 insertions(+), 19 deletions(-) diff --git a/lib/include/srslte/upper/pdcp_entity_base.h b/lib/include/srslte/upper/pdcp_entity_base.h index 0bf6bc3c0..cb4e572c1 100644 --- a/lib/include/srslte/upper/pdcp_entity_base.h +++ b/lib/include/srslte/upper/pdcp_entity_base.h @@ -91,7 +91,7 @@ public: protected: srslte::log* log = nullptr; - srslte::timers* timers = nullptr; + srslte::timer_handler* timers = nullptr; bool active = false; uint32_t lcid = 0; @@ -136,5 +136,7 @@ inline uint32_t pdcp_entity_base::COUNT(uint32_t hfn, uint32_t sn) { return (hfn << cfg.sn_len) | sn; } + } // namespace srslte + #endif // SRSLTE_PDCP_ENTITY_BASE_H diff --git a/lib/include/srslte/upper/pdcp_entity_nr.h b/lib/include/srslte/upper/pdcp_entity_nr.h index 335ad09f3..a3f8639cd 100644 --- a/lib/include/srslte/upper/pdcp_entity_nr.h +++ b/lib/include/srslte/upper/pdcp_entity_nr.h @@ -45,7 +45,7 @@ public: void init(srsue::rlc_interface_pdcp* rlc_, srsue::rrc_interface_pdcp* rrc_, srsue::gw_interface_pdcp* gw_, - srslte::timers* timers_, + srslte::timer_handler* timers_, srslte::log* log_, uint32_t lcid_, pdcp_config_t cfg_); @@ -85,8 +85,7 @@ private: // Reordering Queue / Timers std::map reorder_queue; - srslte::timers::timer* reordering_timer = nullptr; - uint32_t reordering_timer_id = 0; + timer_handler::unique_timer reordering_timer; // Packing/Unpacking Helper functions uint32_t read_data_header(const unique_byte_buffer_t& sdu); @@ -99,6 +98,7 @@ private: void pass_to_upper_layers(unique_byte_buffer_t pdu); // Reodering callback (t-Reordering) + class reordering_callback; std::unique_ptr reordering_fnc; diff --git a/lib/src/upper/pdcp_entity_nr.cc b/lib/src/upper/pdcp_entity_nr.cc index 8c270acb3..5745cc9db 100644 --- a/lib/src/upper/pdcp_entity_nr.cc +++ b/lib/src/upper/pdcp_entity_nr.cc @@ -32,7 +32,7 @@ pdcp_entity_nr::~pdcp_entity_nr() {} void pdcp_entity_nr::init(srsue::rlc_interface_pdcp* rlc_, srsue::rrc_interface_pdcp* rrc_, srsue::gw_interface_pdcp* gw_, - srslte::timers* timers_, + srslte::timer_handler* timers_, srslte::log* log_, uint32_t lcid_, pdcp_config_t cfg_) @@ -51,10 +51,14 @@ void pdcp_entity_nr::init(srsue::rlc_interface_pdcp* rlc_, window_size = 1 << (cfg.sn_len - 1); // Timers - reordering_timer_id = timers->get_unique_id(); - reordering_timer = timers->get(reordering_timer_id); - reordering_timer->set(reordering_fnc.get(), (uint32_t)cfg.t_reordering); - + reordering_timer = timers_->get_unique_timer(); + + // configure timer + if (static_cast(cfg.t_reordering) > 0) { + reordering_timer.set(static_cast(cfg.t_reordering), + [this](uint32_t tid) { reordering_fnc->timer_expired(tid); }); + } + // Mark entity as initialized initialized = true; } @@ -203,14 +207,13 @@ void pdcp_entity_nr::write_pdu(unique_byte_buffer_t pdu) } // Handle reordering timers - if (reordering_timer->is_running() and rx_deliv >= rx_reord) { - reordering_timer->stop(); - reordering_timer->reset(); + if (reordering_timer.is_running() and rx_deliv >= rx_reord) { + reordering_timer.stop(); } - if (not reordering_timer->is_running() and rx_deliv < rx_next) { + if (not reordering_timer.is_running() and rx_deliv < rx_next) { rx_reord = rx_next; - reordering_timer->run(); + reordering_timer.run(); } } @@ -346,7 +349,7 @@ void pdcp_entity_nr::reordering_callback::timer_expired(uint32_t timer_id) if (parent->rx_deliv < parent->rx_next) { parent->rx_reord = parent->rx_next; - parent->reordering_timer->run(); + parent->reordering_timer.run(); } return; } diff --git a/lib/test/upper/pdcp_nr_test.cc b/lib/test/upper/pdcp_nr_test.cc index 125cd6042..48e037923 100644 --- a/lib/test/upper/pdcp_nr_test.cc +++ b/lib/test/upper/pdcp_nr_test.cc @@ -126,7 +126,7 @@ int test_rx(std::vector events, pdcp_nr_test_helper pdcp_hlp_rx(cfg_rx, sec_cfg, log); srslte::pdcp_entity_nr* pdcp_rx = &pdcp_hlp_rx.pdcp; gw_dummy* gw_rx = &pdcp_hlp_rx.gw; - srslte::timers* timers_rx = &pdcp_hlp_rx.timers; + srslte::timer_handler* timers_rx = &pdcp_hlp_rx.timers; pdcp_hlp_rx.set_pdcp_initial_state(init_state); // Generate test message and encript/decript SDU. @@ -457,7 +457,7 @@ int run_all_tests(srslte::byte_buffer_pool* pool) { // Setup log srslte::log_filter log("PDCP NR Test"); - log.set_level(srslte::LOG_LEVEL_DEBUG); + // log.set_level(srslte::LOG_LEVEL_DEBUG); log.set_hex_limit(128); TESTASSERT(test_tx_all(pool, &log) == 0); @@ -474,6 +474,11 @@ int run_all_tests(srslte::byte_buffer_pool* pool) int main(int argc, char** argv) { - run_all_tests(srslte::byte_buffer_pool::get_instance()); + if (run_all_tests(srslte::byte_buffer_pool::get_instance()) != SRSLTE_SUCCESS) { + fprintf(stderr, "pdcp_nr_tests() failed\n"); + return SRSLTE_ERROR; + } srslte::byte_buffer_pool::cleanup(); + + return SRSLTE_SUCCESS; } diff --git a/lib/test/upper/pdcp_nr_test.h b/lib/test/upper/pdcp_nr_test.h index 860557ff9..7c65e9bc4 100644 --- a/lib/test/upper/pdcp_nr_test.h +++ b/lib/test/upper/pdcp_nr_test.h @@ -165,11 +165,11 @@ public: pdcp.set_rx_reord(init_state.rx_reord); } + srslte::timer_handler timers; srslte::pdcp_entity_nr pdcp; rlc_dummy rlc; rrc_dummy rrc; gw_dummy gw; - srslte::timers timers; }; // Helper function to generate PDUs