diff --git a/lib/include/srslte/upper/rlc.h b/lib/include/srslte/upper/rlc.h index 8e5a8e6f8..20f100cd0 100644 --- a/lib/include/srslte/upper/rlc.h +++ b/lib/include/srslte/upper/rlc.h @@ -48,7 +48,7 @@ public: void init(srsue::pdcp_interface_rlc* pdcp_, srsue::rrc_interface_rlc* rrc_, srsue::ue_interface* ue_, - log* rlc_log_, + srslte::log* log_, mac_interface_timers* mac_timers_, uint32_t lcid_); void stop(); diff --git a/lib/include/srslte/upper/rlc_am.h b/lib/include/srslte/upper/rlc_am.h index aa8e44984..6586b9a00 100644 --- a/lib/include/srslte/upper/rlc_am.h +++ b/lib/include/srslte/upper/rlc_am.h @@ -64,22 +64,21 @@ struct rlc_amd_retx_t{ class rlc_am : public rlc_common { public: - rlc_am(); + rlc_am(srslte::log* log_, + uint32_t lcid_, + srsue::pdcp_interface_rlc* pdcp_, + srsue::rrc_interface_rlc* rrc_, + srslte::mac_interface_timers* mac_timers_); ~rlc_am(); - void init(log *log_, - uint32_t lcid_, - srsue::pdcp_interface_rlc *pdcp_, - srsue::rrc_interface_rlc *rrc_, - mac_interface_timers *mac_timers_); bool resume(); bool configure(srslte_rlc_config_t cfg_); void reestablish(); void stop(); - void empty_queue(); - - rlc_mode_t get_mode(); - uint32_t get_bearer(); + void empty_queue(); + + rlc_mode_t get_mode(); + uint32_t get_bearer(); // PDCP interface void write_sdu(unique_byte_buffer_t sdu, bool blocking = true); @@ -103,7 +102,6 @@ private: rlc_am_tx(rlc_am* parent_); ~rlc_am_tx(); - void init(); bool configure(srslte_rlc_config_t cfg_); void empty_queue(); @@ -205,7 +203,6 @@ private: rlc_am_rx(rlc_am* parent_); ~rlc_am_rx(); - void init(); bool configure(srslte_rlc_am_config_t cfg_); void reestablish(); void stop(); @@ -280,10 +277,6 @@ private: uint32_t reordering_timer_id; }; - // Rx and Tx objects - rlc_am_tx tx; - rlc_am_rx rx; - // Common variables needed/provided by parent class srsue::rrc_interface_rlc *rrc; srslte::log *log; @@ -295,6 +288,10 @@ private: std::string rb_name; static const int poll_periodicity = 8; // After how many data PDUs a status PDU shall be requested + + // Rx and Tx objects + rlc_am_tx tx; + rlc_am_rx rx; }; /**************************************************************************** diff --git a/lib/include/srslte/upper/rlc_common.h b/lib/include/srslte/upper/rlc_common.h index 56a95a515..4b9dbcdb4 100644 --- a/lib/include/srslte/upper/rlc_common.h +++ b/lib/include/srslte/upper/rlc_common.h @@ -143,11 +143,6 @@ public: const static int RLC_BUFFER_NOF_PDU = 128; virtual ~rlc_common() {} - virtual void init(srslte::log *rlc_entity_log_, - uint32_t lcid_, - srsue::pdcp_interface_rlc *pdcp_, - srsue::rrc_interface_rlc *rrc_, - srslte::mac_interface_timers *mac_timers_) = 0; virtual bool configure(srslte_rlc_config_t cnfg) = 0; virtual bool resume() = 0; virtual void stop() = 0; diff --git a/lib/include/srslte/upper/rlc_tm.h b/lib/include/srslte/upper/rlc_tm.h index 2f4664ec5..5eb63d4eb 100644 --- a/lib/include/srslte/upper/rlc_tm.h +++ b/lib/include/srslte/upper/rlc_tm.h @@ -34,13 +34,13 @@ namespace srslte { class rlc_tm : public rlc_common { public: - rlc_tm(uint32_t queue_len = 16); + rlc_tm(srslte::log* log_, + uint32_t lcid_, + srsue::pdcp_interface_rlc* pdcp_, + srsue::rrc_interface_rlc* rrc_, + srslte::mac_interface_timers* mac_timers_, + uint32_t queue_len = 16); ~rlc_tm(); - void init(log *rlc_entity_log_, - uint32_t lcid_, - srsue::pdcp_interface_rlc *pdcp_, - srsue::rrc_interface_rlc *rrc_, - mac_interface_timers *mac_timers); bool configure(srslte_rlc_config_t cnfg); bool resume(); void stop(); diff --git a/lib/include/srslte/upper/rlc_um.h b/lib/include/srslte/upper/rlc_um.h index 318945037..0c268563d 100644 --- a/lib/include/srslte/upper/rlc_um.h +++ b/lib/include/srslte/upper/rlc_um.h @@ -43,13 +43,12 @@ class rlc_um :public rlc_common { public: - rlc_um(); + rlc_um(srslte::log* log_, + uint32_t lcid_, + srsue::pdcp_interface_rlc* pdcp_, + srsue::rrc_interface_rlc* rrc_, + mac_interface_timers* mac_timers_); ~rlc_um(); - void init(log *rlc_entity_log_, - uint32_t lcid_, - srsue::pdcp_interface_rlc *pdcp_, - srsue::rrc_interface_rlc *rrc_, - mac_interface_timers *mac_timers_); bool configure(srslte_rlc_config_t cnfg); bool resume(); void reestablish(); @@ -80,9 +79,8 @@ private: class rlc_um_tx { public: - rlc_um_tx(); + rlc_um_tx(srslte::log* log_); ~rlc_um_tx(); - void init(srslte::log *log_); bool configure(srslte_rlc_config_t cfg, std::string rb_name); int build_data_pdu(uint8_t *payload, uint32_t nof_bytes); void stop(); @@ -131,13 +129,12 @@ private: // Receiver sub-class class rlc_um_rx : public timer_callback { public: - rlc_um_rx(); + rlc_um_rx(srslte::log* log_, + uint32_t lcid_, + srsue::pdcp_interface_rlc* pdcp_, + srsue::rrc_interface_rlc* rrc_, + srslte::mac_interface_timers* mac_timers_); ~rlc_um_rx(); - void init(srslte::log *log_, - uint32_t lcid_, - srsue::pdcp_interface_rlc *pdcp_, - srsue::rrc_interface_rlc *rrc_, - srslte::mac_interface_timers *mac_timers_); void stop(); void reestablish(); bool configure(srslte_rlc_config_t cfg, std::string rb_name); @@ -202,10 +199,6 @@ private: const char* get_rb_name(); }; - // Rx and Tx objects - rlc_um_tx tx; - rlc_um_rx rx; - // Common variables needed by parent class srsue::rrc_interface_rlc *rrc; srslte::log *log; @@ -216,6 +209,10 @@ private: byte_buffer_pool *pool; std::string get_rb_name(srsue::rrc_interface_rlc *rrc, uint32_t lcid, bool is_mrb); + + // Rx and Tx objects + rlc_um_tx tx; + rlc_um_rx rx; }; /**************************************************************************** diff --git a/lib/src/upper/rlc.cc b/lib/src/upper/rlc.cc index dc44c58fb..ca363a0e7 100644 --- a/lib/src/upper/rlc.cc +++ b/lib/src/upper/rlc.cc @@ -423,13 +423,13 @@ void rlc::add_bearer(uint32_t lcid, srslte_rlc_config_t cnfg) switch(cnfg.rlc_mode) { case RLC_MODE_TM: - rlc_entity = new rlc_tm(); + rlc_entity = new rlc_tm(rlc_log, lcid, pdcp, rrc, mac_timers); break; case RLC_MODE_AM: - rlc_entity = new rlc_am(); + rlc_entity = new rlc_am(rlc_log, lcid, pdcp, rrc, mac_timers); break; case RLC_MODE_UM: - rlc_entity = new rlc_um(); + rlc_entity = new rlc_um(rlc_log, lcid, pdcp, rrc, mac_timers); break; default: rlc_log->error("Cannot add RLC entity - invalid mode\n"); @@ -437,8 +437,6 @@ void rlc::add_bearer(uint32_t lcid, srslte_rlc_config_t cnfg) } // configure and add to array - rlc_entity->init(rlc_log, lcid, pdcp, rrc, mac_timers); - if (cnfg.rlc_mode != RLC_MODE_TM) { if (rlc_entity->configure(cnfg) == false) { rlc_log->error("Error configuring RLC entity\n."); @@ -472,9 +470,8 @@ void rlc::add_bearer_mrb(uint32_t lcid) rlc_common *rlc_entity = NULL; if (not valid_lcid_mrb(lcid)) { - rlc_entity = new rlc_um(); + rlc_entity = new rlc_um(rlc_log, lcid, pdcp, rrc, mac_timers); // configure and add to array - rlc_entity->init(rlc_log, lcid, pdcp, rrc, mac_timers); if (not rlc_entity->configure(srslte_rlc_config_t::mch_config())) { rlc_log->error("Error configuring RLC entity\n."); goto delete_and_exit; @@ -568,10 +565,6 @@ void rlc::resume_bearer(uint32_t lcid) pthread_rwlock_wrlock(&rwlock); if (valid_lcid(lcid)) { - - // Need to call init again because timers have been destroyed - rlc_array.at(lcid)->init(rlc_log, lcid, pdcp, rrc, mac_timers); - if (rlc_array.at(lcid)->resume()) { rlc_log->info("Resumed radio bearer %s\n", rrc->get_rb_name(lcid).c_str()); } else { diff --git a/lib/src/upper/rlc_am.cc b/lib/src/upper/rlc_am.cc index b77507fac..169d3774c 100644 --- a/lib/src/upper/rlc_am.cc +++ b/lib/src/upper/rlc_am.cc @@ -32,17 +32,20 @@ namespace srslte { -rlc_am::rlc_am() : - tx(this), - rx(this), - log(NULL), - rrc(NULL), - pdcp(NULL), - mac_timers(NULL), - lcid(0), - rb_name(""), +rlc_am::rlc_am(srslte::log* log_, + uint32_t lcid_, + srsue::pdcp_interface_rlc* pdcp_, + srsue::rrc_interface_rlc* rrc_, + srslte::mac_interface_timers* mac_timers_) : + log(log_), + rrc(rrc_), + pdcp(pdcp_), + mac_timers(mac_timers_), + lcid(lcid_), cfg(), - has_configuration(false) + has_configuration(false), + tx(this), + rx(this) { } @@ -50,22 +53,6 @@ rlc_am::~rlc_am() { } -void rlc_am::init(srslte::log *log_, - uint32_t lcid_, - srsue::pdcp_interface_rlc *pdcp_, - srsue::rrc_interface_rlc *rrc_, - srslte::mac_interface_timers *mac_timers_) -{ - log = log_; - lcid = lcid_; - pdcp = pdcp_; - rrc = rrc_; - mac_timers = mac_timers_; - - rx.init(); - tx.init(); -} - bool rlc_am::resume() { if (not has_configuration) { @@ -196,9 +183,9 @@ void rlc_am::write_pdu(uint8_t *payload, uint32_t nof_bytes) rlc_am::rlc_am_tx::rlc_am_tx(rlc_am* parent_) : parent(parent_), - poll_retx_timer(NULL), + poll_retx_timer(nullptr), poll_retx_timer_id(0), - status_prohibit_timer(NULL), + status_prohibit_timer(nullptr), status_prohibit_timer_id(0), vt_a(0), vt_ms(RLC_AM_WINDOW_SIZE), @@ -207,31 +194,30 @@ rlc_am::rlc_am_tx::rlc_am_tx(rlc_am* parent_) : num_tx_bytes(0), pdu_without_poll(0), byte_without_poll(0), - log(NULL), + log(parent_->log), cfg(), tx_status(), pool(byte_buffer_pool::get_instance()), tx_enabled(false) { + poll_retx_timer_id = parent->mac_timers->timer_get_unique_id(); + poll_retx_timer = parent->mac_timers->timer_get(poll_retx_timer_id); + + status_prohibit_timer_id = parent->mac_timers->timer_get_unique_id(); + status_prohibit_timer = parent->mac_timers->timer_get(status_prohibit_timer_id); + pthread_mutex_init(&mutex, NULL); } rlc_am::rlc_am_tx::~rlc_am_tx() { - pthread_mutex_destroy(&mutex); -} - -void rlc_am::rlc_am_tx::init() -{ - log = parent->log; + poll_retx_timer->stop(); + parent->mac_timers->timer_release_id(poll_retx_timer_id); - if (parent->mac_timers != NULL) { - poll_retx_timer_id = parent->mac_timers->timer_get_unique_id(); - poll_retx_timer = parent->mac_timers->timer_get(poll_retx_timer_id); + status_prohibit_timer->stop(); + parent->mac_timers->timer_release_id(status_prohibit_timer_id); - status_prohibit_timer_id = parent->mac_timers->timer_get_unique_id(); - status_prohibit_timer = parent->mac_timers->timer_get(status_prohibit_timer_id); - } + pthread_mutex_destroy(&mutex); } bool rlc_am::rlc_am_tx::configure(srslte_rlc_config_t cfg_) @@ -271,14 +257,10 @@ void rlc_am::rlc_am_tx::stop() if (parent->mac_timers != NULL && poll_retx_timer != NULL) { poll_retx_timer->stop(); - parent->mac_timers->timer_release_id(poll_retx_timer_id); - poll_retx_timer = NULL; } if (parent->mac_timers != NULL && status_prohibit_timer != NULL) { status_prohibit_timer->stop(); - parent->mac_timers->timer_release_id(status_prohibit_timer_id); - status_prohibit_timer = NULL; } vt_a = 0; @@ -1170,37 +1152,34 @@ bool rlc_am::rlc_am_tx::retx_queue_has_sn(uint32_t sn) * Rx subclass implementation ***************************************************************************/ -rlc_am::rlc_am_rx::rlc_am_rx(rlc_am* parent_) - :parent(parent_) - ,pool(byte_buffer_pool::get_instance()) - ,log(NULL) - ,cfg() - ,reordering_timer(NULL) - ,reordering_timer_id(0) - ,vr_r(0) - ,vr_mr(RLC_AM_WINDOW_SIZE) - ,vr_x(0) - ,vr_ms(0) - ,vr_h(0) - ,num_rx_bytes(0) - ,poll_received(false) - ,do_status(false) -{ +rlc_am::rlc_am_rx::rlc_am_rx(rlc_am* parent_) : + parent(parent_), + pool(byte_buffer_pool::get_instance()), + log(parent_->log), + cfg(), + reordering_timer(nullptr), + reordering_timer_id(0), + vr_r(0), + vr_mr(RLC_AM_WINDOW_SIZE), + vr_x(0), + vr_ms(0), + vr_h(0), + num_rx_bytes(0), + poll_received(false), + do_status(false) +{ + reordering_timer_id = parent->mac_timers->timer_get_unique_id(); + reordering_timer = parent->mac_timers->timer_get(reordering_timer_id); + pthread_mutex_init(&mutex, NULL); } rlc_am::rlc_am_rx::~rlc_am_rx() { - pthread_mutex_destroy(&mutex); -} + reordering_timer->stop(); + parent->mac_timers->timer_release_id(reordering_timer_id); -void rlc_am::rlc_am_rx::init() -{ - log = parent->log; - if (parent->mac_timers != NULL) { - reordering_timer_id = parent->mac_timers->timer_get_unique_id(); - reordering_timer = parent->mac_timers->timer_get(reordering_timer_id); - } + pthread_mutex_destroy(&mutex); } bool rlc_am::rlc_am_rx::configure(srslte_rlc_am_config_t cfg_) @@ -1233,8 +1212,6 @@ void rlc_am::rlc_am_rx::stop() if (parent->mac_timers != NULL && reordering_timer != NULL) { reordering_timer->stop(); - parent->mac_timers->timer_release_id(reordering_timer_id); - reordering_timer = NULL; } rx_sdu.reset(); diff --git a/lib/src/upper/rlc_tm.cc b/lib/src/upper/rlc_tm.cc index 9246a4964..25725d200 100644 --- a/lib/src/upper/rlc_tm.cc +++ b/lib/src/upper/rlc_tm.cc @@ -23,13 +23,18 @@ namespace srslte { -rlc_tm::rlc_tm(uint32_t queue_len) : - ul_queue(queue_len), - tx_enabled(false), - log(NULL), - pdcp(NULL), - rrc(NULL), - lcid(0), +rlc_tm::rlc_tm(srslte::log* log_, + uint32_t lcid_, + srsue::pdcp_interface_rlc* pdcp_, + srsue::rrc_interface_rlc* rrc_, + srslte::mac_interface_timers* mac_timers_, + uint32_t queue_len_) : + ul_queue(queue_len_), + tx_enabled(true), + log(log_), + pdcp(pdcp_), + rrc(rrc_), + lcid(lcid_), num_tx_bytes(0), num_rx_bytes(0) { @@ -41,19 +46,6 @@ rlc_tm::~rlc_tm() { pool = NULL; } -void rlc_tm::init(srslte::log *log_, - uint32_t lcid_, - srsue::pdcp_interface_rlc *pdcp_, - srsue::rrc_interface_rlc *rrc_, - mac_interface_timers *mac_timers) -{ - log = log_; - lcid = lcid_; - pdcp = pdcp_; - rrc = rrc_; - tx_enabled = true; -} - bool rlc_tm::configure(srslte_rlc_config_t cnfg) { log->error("Attempted to configure TM RLC entity\n"); diff --git a/lib/src/upper/rlc_um.cc b/lib/src/upper/rlc_um.cc index 9eadc1cee..cb5ef47ab 100644 --- a/lib/src/upper/rlc_um.cc +++ b/lib/src/upper/rlc_um.cc @@ -22,7 +22,6 @@ #include "srslte/upper/rlc_um.h" #include #include -#include #define RX_MOD_BASE(x) (((x)-vr_uh-cfg.rx_window_size)%cfg.rx_mod) @@ -30,7 +29,17 @@ using namespace asn1::rrc; namespace srslte { -rlc_um::rlc_um() : lcid(0), tx(), pool(byte_buffer_pool::get_instance()), rrc(NULL), log(NULL) +rlc_um::rlc_um(srslte::log* log_, + uint32_t lcid_, + srsue::pdcp_interface_rlc* pdcp_, + srsue::rrc_interface_rlc* rrc_, + mac_interface_timers* mac_timers_) : + lcid(lcid_), + pool(byte_buffer_pool::get_instance()), + rrc(rrc_), + log(log_), + tx(log_), + rx(log_, lcid_, pdcp_, rrc_, mac_timers_) { bzero(&cfg, sizeof(srslte_rlc_um_config_t)); } @@ -41,19 +50,6 @@ rlc_um::~rlc_um() stop(); } -void rlc_um::init(srslte::log *log_, - uint32_t lcid_, - srsue::pdcp_interface_rlc *pdcp_, - srsue::rrc_interface_rlc *rrc_, - srslte::mac_interface_timers *mac_timers_) -{ - tx.init(log_); - rx.init(log_, lcid_, pdcp_, rrc_, mac_timers_); - lcid = lcid_; - rrc = rrc_; // needed to determine bearer name during configuration - log = log_; -} - bool rlc_um::resume() { if (not has_configuration) { @@ -226,9 +222,9 @@ std::string rlc_um::get_rb_name(srsue::rrc_interface_rlc *rrc, uint32_t lcid, bo * Tx subclass implementation ***************************************************************************/ -rlc_um::rlc_um_tx::rlc_um_tx() : +rlc_um::rlc_um_tx::rlc_um_tx(srslte::log* log_) : pool(byte_buffer_pool::get_instance()), - log(NULL), + log(log_), vt_us(0), tx_enabled(false), num_tx_bytes(0) @@ -243,12 +239,6 @@ rlc_um::rlc_um_tx::~rlc_um_tx() } -void rlc_um::rlc_um_tx::init(srslte::log *log_) -{ - log = log_; -} - - bool rlc_um::rlc_um_tx::configure(srslte_rlc_config_t cnfg_, std::string rb_name_) { cfg = cnfg_.um; @@ -513,42 +503,40 @@ void rlc_um::rlc_um_tx::debug_state() * Rx subclass implementation ***************************************************************************/ -rlc_um::rlc_um_rx::rlc_um_rx() - :reordering_timer(NULL) - ,reordering_timer_id(0) - ,pool(byte_buffer_pool::get_instance()) - ,log(NULL) - ,pdcp(NULL) - ,rrc(NULL) - ,vr_ur(0) - ,vr_ux (0) - ,vr_uh(0) - ,vr_ur_in_rx_sdu(0) - ,pdu_lost(false) - ,mac_timers(NULL) - ,lcid(0) - ,num_rx_bytes(0) - ,rx_enabled(false) +rlc_um::rlc_um_rx::rlc_um_rx(srslte::log* log_, + uint32_t lcid_, + srsue::pdcp_interface_rlc* pdcp_, + srsue::rrc_interface_rlc* rrc_, + srslte::mac_interface_timers* mac_timers_) : + reordering_timer(nullptr), + reordering_timer_id(0), + pool(byte_buffer_pool::get_instance()), + log(log_), + pdcp(pdcp_), + rrc(rrc_), + vr_ur(0), + vr_ux(0), + vr_uh(0), + vr_ur_in_rx_sdu(0), + pdu_lost(false), + mac_timers(mac_timers_), + lcid(lcid_), + num_rx_bytes(0), + rx_enabled(false) { + reordering_timer_id = mac_timers->timer_get_unique_id(); + reordering_timer = mac_timers->timer_get(reordering_timer_id); + pthread_mutex_init(&mutex, NULL); } rlc_um::rlc_um_rx::~rlc_um_rx() { - pthread_mutex_destroy(&mutex); -} + reordering_timer->stop(); + mac_timers->timer_release_id(reordering_timer_id); - -void rlc_um::rlc_um_rx::init(srslte::log *log_, uint32_t lcid_, srsue::pdcp_interface_rlc *pdcp_, srsue::rrc_interface_rlc *rrc_, srslte::mac_interface_timers *mac_timers_) -{ - log = log_; - lcid = lcid_; - pdcp = pdcp_; - rrc = rrc_; - mac_timers = mac_timers_; - reordering_timer_id = mac_timers->timer_get_unique_id(); - reordering_timer = mac_timers->timer_get(reordering_timer_id); + pthread_mutex_destroy(&mutex); } @@ -575,11 +563,7 @@ void rlc_um::rlc_um_rx::stop() reset(); - if (mac_timers != NULL && reordering_timer != NULL) { - reordering_timer->stop(); - mac_timers->timer_release_id(reordering_timer_id); - reordering_timer = NULL; - } + reordering_timer->stop(); pthread_mutex_unlock(&mutex); } diff --git a/lib/test/upper/rlc_am_test.cc b/lib/test/upper/rlc_am_test.cc index 62695d3f8..2d3a98152 100644 --- a/lib/test/upper/rlc_am_test.cc +++ b/lib/test/upper/rlc_am_test.cc @@ -161,20 +161,13 @@ bool basic_test() log2.set_level(srslte::LOG_LEVEL_DEBUG); log1.set_hex_limit(-1); log2.set_hex_limit(-1); + rlc_am_tester tester; mac_dummy_timers timers; byte_buffer_t pdu_bufs[NBUFS]; - rlc_am rlc1; - rlc_am rlc2; - - int len; - - log1.set_level(srslte::LOG_LEVEL_DEBUG); - log2.set_level(srslte::LOG_LEVEL_DEBUG); - - rlc1.init(&log1, 1, &tester, &tester, &timers); - rlc2.init(&log2, 1, &tester, &tester, &timers); + rlc_am rlc1(&log1, 1, &tester, &tester, &timers); + rlc_am rlc2(&log2, 1, &tester, &tester, &timers); rlc_cfg_c cnfg; cnfg.set(rlc_cfg_c::types::am); @@ -205,7 +198,7 @@ bool basic_test() // Read status PDU from RLC2 byte_buffer_t status_buf; - len = rlc2.read_pdu(status_buf.msg, 2); + int len = rlc2.read_pdu(status_buf.msg, 2); status_buf.N_bytes = len; assert(0 == rlc2.get_buffer_state()); @@ -241,16 +234,8 @@ bool concat_test() rlc_am_tester tester; mac_dummy_timers timers; - rlc_am rlc1; - rlc_am rlc2; - - int len; - - log1.set_level(srslte::LOG_LEVEL_DEBUG); - log2.set_level(srslte::LOG_LEVEL_DEBUG); - - rlc1.init(&log1, 1, &tester, &tester, &timers); - rlc2.init(&log2, 1, &tester, &tester, &timers); + rlc_am rlc1(&log1, 1, &tester, &tester, &timers); + rlc_am rlc2(&log2, 1, &tester, &tester, &timers); rlc_cfg_c cnfg; cnfg.set(rlc_cfg_c::types::am); @@ -284,7 +269,7 @@ bool concat_test() // Read 1 PDUs from RLC1 containing all 5 SDUs byte_buffer_t pdu_buf; - len = rlc1.read_pdu(pdu_buf.msg, 13); // 8 bytes for header + payload + int len = rlc1.read_pdu(pdu_buf.msg, 13); // 8 bytes for header + payload pdu_buf.N_bytes = len; assert(0 == rlc1.get_buffer_state()); @@ -322,17 +307,10 @@ bool segment_test(bool in_seq_rx) log2.set_hex_limit(-1); rlc_am_tester tester; mac_dummy_timers timers; + int len = 0; - rlc_am rlc1; - rlc_am rlc2; - - int len; - - log1.set_level(srslte::LOG_LEVEL_DEBUG); - log2.set_level(srslte::LOG_LEVEL_DEBUG); - - rlc1.init(&log1, 1, &tester, &tester, &timers); - rlc2.init(&log2, 1, &tester, &tester, &timers); + rlc_am rlc1(&log1, 1, &tester, &tester, &timers); + rlc_am rlc2(&log2, 1, &tester, &tester, &timers); rlc_cfg_c cnfg; cnfg.set(rlc_cfg_c::types::am); @@ -432,17 +410,10 @@ bool retx_test() log2.set_hex_limit(-1); rlc_am_tester tester; mac_dummy_timers timers; + int len = 0; - rlc_am rlc1; - rlc_am rlc2; - - int len; - - log1.set_level(srslte::LOG_LEVEL_DEBUG); - log2.set_level(srslte::LOG_LEVEL_DEBUG); - - rlc1.init(&log1, 1, &tester, &tester, &timers); - rlc2.init(&log2, 1, &tester, &tester, &timers); + rlc_am rlc1(&log1, 1, &tester, &tester, &timers); + rlc_am rlc2(&log2, 1, &tester, &tester, &timers); rlc_cfg_c cnfg; cnfg.set(rlc_cfg_c::types::am); @@ -541,17 +512,10 @@ bool resegment_test_1() log2.set_hex_limit(-1); rlc_am_tester tester; mac_dummy_timers timers; + int len = 0; - rlc_am rlc1; - rlc_am rlc2; - - int len; - - log1.set_level(srslte::LOG_LEVEL_DEBUG); - log2.set_level(srslte::LOG_LEVEL_DEBUG); - - rlc1.init(&log1, 1, &tester, &tester, &timers); - rlc2.init(&log2, 1, &tester, &tester, &timers); + rlc_am rlc1(&log1, 1, &tester, &tester, &timers); + rlc_am rlc2(&log2, 1, &tester, &tester, &timers); rlc_cfg_c cnfg; cnfg.set(rlc_cfg_c::types::am); @@ -663,17 +627,10 @@ bool resegment_test_2() log2.set_hex_limit(-1); rlc_am_tester tester; mac_dummy_timers timers; + int len = 0; - rlc_am rlc1; - rlc_am rlc2; - - int len; - - log1.set_level(srslte::LOG_LEVEL_DEBUG); - log2.set_level(srslte::LOG_LEVEL_DEBUG); - - rlc1.init(&log1, 1, &tester, &tester, &timers); - rlc2.init(&log2, 1, &tester, &tester, &timers); + rlc_am rlc1(&log1, 1, &tester, &tester, &timers); + rlc_am rlc2(&log2, 1, &tester, &tester, &timers); rlc_cfg_c cnfg; cnfg.set(rlc_cfg_c::types::am); @@ -783,16 +740,8 @@ bool resegment_test_3() rlc_am_tester tester; mac_dummy_timers timers; - rlc_am rlc1; - rlc_am rlc2; - - int len; - - log1.set_level(srslte::LOG_LEVEL_DEBUG); - log2.set_level(srslte::LOG_LEVEL_DEBUG); - - rlc1.init(&log1, 1, &tester, &tester, &timers); - rlc2.init(&log2, 1, &tester, &tester, &timers); + rlc_am rlc1(&log1, 1, &tester, &tester, &timers); + rlc_am rlc2(&log2, 1, &tester, &tester, &timers); rlc_cfg_c cnfg; cnfg.set(rlc_cfg_c::types::am); @@ -897,16 +846,8 @@ bool resegment_test_4() rlc_am_tester tester; mac_dummy_timers timers; - rlc_am rlc1; - rlc_am rlc2; - - int len; - - log1.set_level(srslte::LOG_LEVEL_DEBUG); - log2.set_level(srslte::LOG_LEVEL_DEBUG); - - rlc1.init(&log1, 1, &tester, &tester, &timers); - rlc2.init(&log2, 1, &tester, &tester, &timers); + rlc_am rlc1(&log1, 1, &tester, &tester, &timers); + rlc_am rlc2(&log2, 1, &tester, &tester, &timers); rlc_cfg_c cnfg; cnfg.set(rlc_cfg_c::types::am); @@ -1013,14 +954,8 @@ bool resegment_test_5() rlc_am_tester tester; mac_dummy_timers timers; - rlc_am rlc1; - rlc_am rlc2; - - log1.set_level(srslte::LOG_LEVEL_DEBUG); - log2.set_level(srslte::LOG_LEVEL_DEBUG); - - rlc1.init(&log1, 1, &tester, &tester, &timers); - rlc2.init(&log2, 1, &tester, &tester, &timers); + rlc_am rlc1(&log1, 1, &tester, &tester, &timers); + rlc_am rlc2(&log2, 1, &tester, &tester, &timers); rlc_cfg_c cnfg; cnfg.set(rlc_cfg_c::types::am); @@ -1126,17 +1061,10 @@ bool resegment_test_6() log2.set_hex_limit(-1); rlc_am_tester tester; mac_dummy_timers timers; + int len = 0; - rlc_am rlc1; - rlc_am rlc2; - - int len; - - log1.set_level(srslte::LOG_LEVEL_DEBUG); - log2.set_level(srslte::LOG_LEVEL_DEBUG); - - rlc1.init(&log1, 1, &tester, &tester, &timers); - rlc2.init(&log2, 1, &tester, &tester, &timers); + rlc_am rlc1(&log1, 1, &tester, &tester, &timers); + rlc_am rlc2(&log2, 1, &tester, &tester, &timers); rlc_cfg_c cnfg; cnfg.set(rlc_cfg_c::types::am); @@ -1280,14 +1208,8 @@ bool resegment_test_7() #endif mac_dummy_timers timers; - rlc_am rlc1; - rlc_am rlc2; - - log1.set_level(srslte::LOG_LEVEL_DEBUG); - log2.set_level(srslte::LOG_LEVEL_DEBUG); - - rlc1.init(&log1, 1, &tester, &tester, &timers); - rlc2.init(&log2, 1, &tester, &tester, &timers); + rlc_am rlc1(&log1, 1, &tester, &tester, &timers); + rlc_am rlc2(&log2, 1, &tester, &tester, &timers); rlc_cfg_c cnfg; cnfg.set(rlc_cfg_c::types::am); @@ -1468,15 +1390,8 @@ bool resegment_test_8() #endif mac_dummy_timers timers; - rlc_am rlc1; - rlc_am rlc2; - - - log1.set_level(srslte::LOG_LEVEL_DEBUG); - log2.set_level(srslte::LOG_LEVEL_DEBUG); - - rlc1.init(&log1, 1, &tester, &tester, &timers); - rlc2.init(&log2, 1, &tester, &tester, &timers); + rlc_am rlc1(&log1, 1, &tester, &tester, &timers); + rlc_am rlc2(&log2, 1, &tester, &tester, &timers); rlc_cfg_c cnfg; cnfg.set(rlc_cfg_c::types::am); @@ -1623,20 +1538,13 @@ bool resegment_test_8() bool reset_test() { srslte::log_filter log1("RLC_AM_1"); - srslte::log_filter log2("RLC_AM_2"); log1.set_level(srslte::LOG_LEVEL_DEBUG); - log2.set_level(srslte::LOG_LEVEL_DEBUG); log1.set_hex_limit(-1); - log2.set_hex_limit(-1); rlc_am_tester tester; mac_dummy_timers timers; + int len = 0; - rlc_am rlc1; - int len; - - log1.set_level(srslte::LOG_LEVEL_DEBUG); - - rlc1.init(&log1, 1, &tester, &tester, &timers); + rlc_am rlc1(&log1, 1, &tester, &tester, &timers); rlc_cfg_c cnfg; cnfg.set(rlc_cfg_c::types::am); @@ -1684,20 +1592,13 @@ bool reset_test() bool resume_test() { srslte::log_filter log1("RLC_AM_1"); - srslte::log_filter log2("RLC_AM_2"); log1.set_level(srslte::LOG_LEVEL_DEBUG); - log2.set_level(srslte::LOG_LEVEL_DEBUG); log1.set_hex_limit(-1); - log2.set_hex_limit(-1); rlc_am_tester tester; mac_dummy_timers timers; + int len = 0; - rlc_am rlc1; - int len; - - log1.set_level(srslte::LOG_LEVEL_DEBUG); - - rlc1.init(&log1, 1, &tester, &tester, &timers); + rlc_am rlc1(&log1, 1, &tester, &tester, &timers); rlc_cfg_c cnfg; cnfg.set(rlc_cfg_c::types::am); @@ -1750,11 +1651,7 @@ bool stop_test() rlc_am_tester tester; mac_dummy_timers timers; - rlc_am rlc1; - - log1.set_level(srslte::LOG_LEVEL_DEBUG); - - rlc1.init(&log1, 1, &tester, &tester, &timers); + rlc_am rlc1(&log1, 1, &tester, &tester, &timers); rlc_cfg_c cnfg; cnfg.set(rlc_cfg_c::types::am); diff --git a/lib/test/upper/rlc_stress_test.cc b/lib/test/upper/rlc_stress_test.cc index 67843c670..08c9f22c9 100644 --- a/lib/test/upper/rlc_stress_test.cc +++ b/lib/test/upper/rlc_stress_test.cc @@ -104,23 +104,37 @@ void parse_args(stress_test_args_t *args, int argc, char *argv[]) { } } -class mac_dummy - :public srslte::mac_interface_timers - ,public thread +// To provide timer services to RLC +class stack_dummy : public srslte::mac_interface_timers +{ +public: + stack_dummy() : timers(8) {} + + srslte::timers::timer* timer_get(uint32_t timer_id) { return timers.get(timer_id); } + uint32_t timer_get_unique_id() { return timers.get_unique_id(); } + void timer_release_id(uint32_t timer_id) { timers.release_id(timer_id); } + void step_timer() { timers.step_all(); } + +private: + srslte::timers timers; +}; + +class mac_dummy : public thread { public: mac_dummy(rlc_interface_mac* rlc1_, rlc_interface_mac* rlc2_, stress_test_args_t args_, uint32_t lcid_, + stack_dummy* stack_, rlc_pcap* pcap_ = NULL) : - timers(8), run_enable(true), rlc1(rlc1_), rlc2(rlc2_), args(args_), pcap(pcap_), lcid(lcid_), + stack(stack_), log("MAC "), thread("MAC_DUMMY") { @@ -134,20 +148,6 @@ public: wait_thread_finish(); } - srslte::timers::timer* timer_get(uint32_t timer_id) - { - return timers.get(timer_id); - } - uint32_t timer_get_unique_id() { - return timers.get_unique_id(); - } - void timer_release_id(uint32_t timer_id) { - timers.release_id(timer_id); - } - void step_timer() { - timers.step_all(); - } - private: void run_tti(rlc_interface_mac *tx_rlc, rlc_interface_mac *rx_rlc, bool is_dl) { @@ -193,18 +193,19 @@ private: run_tti(rlc2, rlc1, false); // step timer - step_timer(); + stack->step_timer(); } } rlc_interface_mac *rlc1; rlc_interface_mac *rlc2; - srslte::timers timers; + bool run_enable; stress_test_args_t args; rlc_pcap *pcap; uint32_t lcid; srslte::log_filter log; + stack_dummy* stack = nullptr; }; @@ -334,16 +335,18 @@ void stress_test(stress_test_args_t args) exit(-1); } + stack_dummy stack; + rlc rlc1; rlc rlc2; rlc_tester tester1(&rlc1, "tester1", args, lcid); rlc_tester tester2(&rlc2, "tester2", args, lcid); - mac_dummy mac(&rlc1, &rlc2, args, lcid, &pcap); + mac_dummy mac(&rlc1, &rlc2, args, lcid, &stack, &pcap); ue_interface ue; - rlc1.init(&tester1, &tester1, &ue, &log1, &mac, 0); - rlc2.init(&tester2, &tester2, &ue, &log2, &mac, 0); + rlc1.init(&tester1, &tester1, &ue, &log1, &stack, 0); + rlc2.init(&tester2, &tester2, &ue, &log2, &stack, 0); // only add AM and UM bearers if (args.mode != "TM") { diff --git a/lib/test/upper/rlc_um_test.cc b/lib/test/upper/rlc_um_test.cc index 5c661d8f6..5463d62ad 100644 --- a/lib/test/upper/rlc_um_test.cc +++ b/lib/test/upper/rlc_um_test.cc @@ -104,17 +104,10 @@ int basic_test() log2.set_hex_limit(-1); rlc_um_tester tester; mac_dummy_timers timers; + int len = 0; - rlc_um rlc1; - rlc_um rlc2; - - int len; - - log1.set_level(srslte::LOG_LEVEL_DEBUG); - log2.set_level(srslte::LOG_LEVEL_DEBUG); - - rlc1.init(&log1, 3, &tester, &tester, &timers); - rlc2.init(&log2, 3, &tester, &tester, &timers); + rlc_um rlc1(&log1, 3, &tester, &tester, &timers); + rlc_um rlc2(&log2, 3, &tester, &tester, &timers); rlc_cfg_c cnfg; cnfg.set(rlc_cfg_c::types::um_bi_dir); @@ -178,17 +171,10 @@ int loss_test() log2.set_hex_limit(-1); rlc_um_tester tester; mac_dummy_timers timers; + int len = 0; - rlc_um rlc1; - rlc_um rlc2; - - int len; - - log1.set_level(srslte::LOG_LEVEL_DEBUG); - log2.set_level(srslte::LOG_LEVEL_DEBUG); - - rlc1.init(&log1, 3, &tester, &tester, &timers); - rlc2.init(&log2, 3, &tester, &tester, &timers); + rlc_um rlc1(&log1, 3, &tester, &tester, &timers); + rlc_um rlc2(&log2, 3, &tester, &tester, &timers); rlc_cfg_c cnfg; cnfg.set(rlc_cfg_c::types::um_bi_dir); @@ -250,17 +236,10 @@ int basic_mbsfn_test() log2.set_hex_limit(-1); rlc_um_tester tester; mac_dummy_timers timers; + int len = 0; - rlc_um rlc1; - rlc_um rlc2; - - int len; - - log1.set_level(srslte::LOG_LEVEL_DEBUG); - log2.set_level(srslte::LOG_LEVEL_DEBUG); - - rlc1.init(&log1, 3, &tester, &tester, &timers); - rlc2.init(&log2, 3, &tester, &tester, &timers); + rlc_um rlc1(&log1, 3, &tester, &tester, &timers); + rlc_um rlc2(&log2, 3, &tester, &tester, &timers); rlc1.configure(srslte_rlc_config_t::mch_config()); rlc2.configure(srslte_rlc_config_t::mch_config()); @@ -329,17 +308,10 @@ int reassmble_test() log2.set_hex_limit(-1); rlc_um_tester tester; mac_dummy_timers timers; + int len = 0; - rlc_um rlc1; - rlc_um rlc2; - - int len; - - log1.set_level(srslte::LOG_LEVEL_DEBUG); - log2.set_level(srslte::LOG_LEVEL_DEBUG); - - rlc1.init(&log1, 3, &tester, &tester, &timers); - rlc2.init(&log2, 3, &tester, &tester, &timers); + rlc_um rlc1(&log1, 3, &tester, &tester, &timers); + rlc_um rlc2(&log2, 3, &tester, &tester, &timers); rlc_cfg_c cnfg; cnfg.set(rlc_cfg_c::types::um_bi_dir); @@ -449,17 +421,10 @@ int reassmble_test2() log2.set_hex_limit(-1); rlc_um_tester tester; mac_dummy_timers timers; + int len = 0; - rlc_um rlc1; - rlc_um rlc2; - - int len; - - log1.set_level(srslte::LOG_LEVEL_DEBUG); - log2.set_level(srslte::LOG_LEVEL_DEBUG); - - rlc1.init(&log1, 3, &tester, &tester, &timers); - rlc2.init(&log2, 3, &tester, &tester, &timers); + rlc_um rlc1(&log1, 3, &tester, &tester, &timers); + rlc_um rlc2(&log2, 3, &tester, &tester, &timers); rlc_cfg_c cnfg; cnfg.set(rlc_cfg_c::types::um_bi_dir);