adopt PDCP NR to use new timer class

master
Andre Puschmann 5 years ago
parent ac9ee9d863
commit 2d126371f6

@ -91,7 +91,7 @@ public:
protected: protected:
srslte::log* log = nullptr; srslte::log* log = nullptr;
srslte::timers* timers = nullptr; srslte::timer_handler* timers = nullptr;
bool active = false; bool active = false;
uint32_t lcid = 0; 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; return (hfn << cfg.sn_len) | sn;
} }
} // namespace srslte } // namespace srslte
#endif // SRSLTE_PDCP_ENTITY_BASE_H #endif // SRSLTE_PDCP_ENTITY_BASE_H

@ -45,7 +45,7 @@ public:
void init(srsue::rlc_interface_pdcp* rlc_, void init(srsue::rlc_interface_pdcp* rlc_,
srsue::rrc_interface_pdcp* rrc_, srsue::rrc_interface_pdcp* rrc_,
srsue::gw_interface_pdcp* gw_, srsue::gw_interface_pdcp* gw_,
srslte::timers* timers_, srslte::timer_handler* timers_,
srslte::log* log_, srslte::log* log_,
uint32_t lcid_, uint32_t lcid_,
pdcp_config_t cfg_); pdcp_config_t cfg_);
@ -85,8 +85,7 @@ private:
// Reordering Queue / Timers // Reordering Queue / Timers
std::map<uint32_t, unique_byte_buffer_t> reorder_queue; std::map<uint32_t, unique_byte_buffer_t> reorder_queue;
srslte::timers::timer* reordering_timer = nullptr; timer_handler::unique_timer reordering_timer;
uint32_t reordering_timer_id = 0;
// Packing/Unpacking Helper functions // Packing/Unpacking Helper functions
uint32_t read_data_header(const unique_byte_buffer_t& sdu); 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); void pass_to_upper_layers(unique_byte_buffer_t pdu);
// Reodering callback (t-Reordering) // Reodering callback (t-Reordering)
class reordering_callback; class reordering_callback;
std::unique_ptr<reordering_callback> reordering_fnc; std::unique_ptr<reordering_callback> reordering_fnc;

@ -32,7 +32,7 @@ pdcp_entity_nr::~pdcp_entity_nr() {}
void pdcp_entity_nr::init(srsue::rlc_interface_pdcp* rlc_, void pdcp_entity_nr::init(srsue::rlc_interface_pdcp* rlc_,
srsue::rrc_interface_pdcp* rrc_, srsue::rrc_interface_pdcp* rrc_,
srsue::gw_interface_pdcp* gw_, srsue::gw_interface_pdcp* gw_,
srslte::timers* timers_, srslte::timer_handler* timers_,
srslte::log* log_, srslte::log* log_,
uint32_t lcid_, uint32_t lcid_,
pdcp_config_t cfg_) 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); window_size = 1 << (cfg.sn_len - 1);
// Timers // Timers
reordering_timer_id = timers->get_unique_id(); reordering_timer = timers_->get_unique_timer();
reordering_timer = timers->get(reordering_timer_id);
reordering_timer->set(reordering_fnc.get(), (uint32_t)cfg.t_reordering); // configure timer
if (static_cast<uint32_t>(cfg.t_reordering) > 0) {
reordering_timer.set(static_cast<uint32_t>(cfg.t_reordering),
[this](uint32_t tid) { reordering_fnc->timer_expired(tid); });
}
// Mark entity as initialized // Mark entity as initialized
initialized = true; initialized = true;
} }
@ -203,14 +207,13 @@ void pdcp_entity_nr::write_pdu(unique_byte_buffer_t pdu)
} }
// Handle reordering timers // Handle reordering timers
if (reordering_timer->is_running() and rx_deliv >= rx_reord) { if (reordering_timer.is_running() and rx_deliv >= rx_reord) {
reordering_timer->stop(); reordering_timer.stop();
reordering_timer->reset();
} }
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; 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) { if (parent->rx_deliv < parent->rx_next) {
parent->rx_reord = parent->rx_next; parent->rx_reord = parent->rx_next;
parent->reordering_timer->run(); parent->reordering_timer.run();
} }
return; return;
} }

@ -126,7 +126,7 @@ int test_rx(std::vector<pdcp_test_event_t> events,
pdcp_nr_test_helper pdcp_hlp_rx(cfg_rx, sec_cfg, log); pdcp_nr_test_helper pdcp_hlp_rx(cfg_rx, sec_cfg, log);
srslte::pdcp_entity_nr* pdcp_rx = &pdcp_hlp_rx.pdcp; srslte::pdcp_entity_nr* pdcp_rx = &pdcp_hlp_rx.pdcp;
gw_dummy* gw_rx = &pdcp_hlp_rx.gw; 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); pdcp_hlp_rx.set_pdcp_initial_state(init_state);
// Generate test message and encript/decript SDU. // Generate test message and encript/decript SDU.
@ -457,7 +457,7 @@ int run_all_tests(srslte::byte_buffer_pool* pool)
{ {
// Setup log // Setup log
srslte::log_filter log("PDCP NR Test"); 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); log.set_hex_limit(128);
TESTASSERT(test_tx_all(pool, &log) == 0); 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) 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(); srslte::byte_buffer_pool::cleanup();
return SRSLTE_SUCCESS;
} }

@ -165,11 +165,11 @@ public:
pdcp.set_rx_reord(init_state.rx_reord); pdcp.set_rx_reord(init_state.rx_reord);
} }
srslte::timer_handler timers;
srslte::pdcp_entity_nr pdcp; srslte::pdcp_entity_nr pdcp;
rlc_dummy rlc; rlc_dummy rlc;
rrc_dummy rrc; rrc_dummy rrc;
gw_dummy gw; gw_dummy gw;
srslte::timers timers;
}; };
// Helper function to generate PDUs // Helper function to generate PDUs

Loading…
Cancel
Save