diff --git a/lib/include/srslte/upper/pdcp.h b/lib/include/srslte/upper/pdcp.h index 3950805d4..84f7f605f 100644 --- a/lib/include/srslte/upper/pdcp.h +++ b/lib/include/srslte/upper/pdcp.h @@ -32,7 +32,7 @@ namespace srslte { class pdcp : public srsue::pdcp_interface_rlc, public srsue::pdcp_interface_rrc { public: - pdcp(log* log_); + pdcp(srslte::timer_handler* timers_, log* log_); virtual ~pdcp(); void init(srsue::rlc_interface_pdcp* rlc_, srsue::rrc_interface_pdcp* rrc_, srsue::gw_interface_pdcp* gw_); void stop(); @@ -79,9 +79,10 @@ private: typedef std::map pdcp_map_t; typedef std::pair pdcp_map_pair_t; - log* pdcp_log = nullptr; - pdcp_map_t pdcp_array, pdcp_array_mrb; - pthread_rwlock_t rwlock; + srslte::timer_handler* timers = nullptr; + log* pdcp_log = nullptr; + pdcp_map_t pdcp_array, pdcp_array_mrb; + pthread_rwlock_t rwlock; bool valid_lcid(uint32_t lcid); bool valid_mch_lcid(uint32_t lcid); diff --git a/lib/include/srslte/upper/pdcp_entity_base.h b/lib/include/srslte/upper/pdcp_entity_base.h index cb4e572c1..6fde8fc6f 100644 --- a/lib/include/srslte/upper/pdcp_entity_base.h +++ b/lib/include/srslte/upper/pdcp_entity_base.h @@ -58,7 +58,7 @@ static const char pdcp_d_c_text[PDCP_D_C_N_ITEMS][20] = {"Control PDU", "Data PD class pdcp_entity_base { public: - pdcp_entity_base(); + pdcp_entity_base(srslte::timer_handler* timers_, srslte::log* log_); virtual ~pdcp_entity_base(); virtual void reset() = 0; virtual void reestablish() = 0; diff --git a/lib/include/srslte/upper/pdcp_entity_lte.h b/lib/include/srslte/upper/pdcp_entity_lte.h index a6df1f52a..921b0320d 100644 --- a/lib/include/srslte/upper/pdcp_entity_lte.h +++ b/lib/include/srslte/upper/pdcp_entity_lte.h @@ -46,14 +46,13 @@ namespace srslte { class pdcp_entity_lte final : public pdcp_entity_base { public: - pdcp_entity_lte(); + pdcp_entity_lte(srsue::rlc_interface_pdcp* rlc_, + srsue::rrc_interface_pdcp* rrc_, + srsue::gw_interface_pdcp* gw_, + srslte::timer_handler* timers_, + srslte::log* log_); ~pdcp_entity_lte(); - void init(srsue::rlc_interface_pdcp* rlc_, - srsue::rrc_interface_pdcp* rrc_, - srsue::gw_interface_pdcp* gw_, - srslte::log* log_, - uint32_t lcid_, - pdcp_config_t cfg_); + void init(uint32_t lcid_, pdcp_config_t cfg_); void reset(); void reestablish(); diff --git a/lib/include/srslte/upper/pdcp_entity_nr.h b/lib/include/srslte/upper/pdcp_entity_nr.h index a3f8639cd..c024fc0b6 100644 --- a/lib/include/srslte/upper/pdcp_entity_nr.h +++ b/lib/include/srslte/upper/pdcp_entity_nr.h @@ -40,14 +40,13 @@ namespace srslte { class pdcp_entity_nr : public pdcp_entity_base { public: - pdcp_entity_nr(); + pdcp_entity_nr(srsue::rlc_interface_pdcp* rlc_, + srsue::rrc_interface_pdcp* rrc_, + srsue::gw_interface_pdcp* gw_, + srslte::timer_handler* timers_, + srslte::log* log_); ~pdcp_entity_nr(); - void init(srsue::rlc_interface_pdcp* rlc_, - srsue::rrc_interface_pdcp* rrc_, - srsue::gw_interface_pdcp* gw_, - srslte::timer_handler* timers_, - srslte::log* log_, - uint32_t lcid_, + void init( uint32_t lcid_, pdcp_config_t cfg_); void reset(); void reestablish(); diff --git a/lib/src/upper/pdcp.cc b/lib/src/upper/pdcp.cc index 2b82e8cc7..3cddf5282 100644 --- a/lib/src/upper/pdcp.cc +++ b/lib/src/upper/pdcp.cc @@ -23,7 +23,7 @@ namespace srslte { -pdcp::pdcp(srslte::log* log_) : pdcp_log(log_) +pdcp::pdcp(srslte::timer_handler* timers_, srslte::log* log_) : timers(timers_), pdcp_log(log_) { pthread_rwlock_init(&rwlock, NULL); } @@ -124,11 +124,11 @@ void pdcp::add_bearer(uint32_t lcid, pdcp_config_t cfg) { pthread_rwlock_wrlock(&rwlock); if (not valid_lcid(lcid)) { - if (not pdcp_array.insert(pdcp_map_pair_t(lcid, new pdcp_entity_lte())).second) { + if (not pdcp_array.insert(pdcp_map_pair_t(lcid, new pdcp_entity_lte(rlc, rrc, gw, timers, pdcp_log))).second) { pdcp_log->error("Error inserting PDCP entity in to array\n."); goto unlock_and_exit; } - pdcp_array.at(lcid)->init(rlc, rrc, gw, pdcp_log, lcid, cfg); + pdcp_array.at(lcid)->init(lcid, cfg); pdcp_log->info("Add %s (lcid=%d, bearer_id=%d, sn_len=%dbits)\n", rrc->get_rb_name(lcid).c_str(), lcid, @@ -145,11 +145,11 @@ void pdcp::add_bearer_mrb(uint32_t lcid, pdcp_config_t cfg) { pthread_rwlock_wrlock(&rwlock); if (not valid_mch_lcid(lcid)) { - if (not pdcp_array_mrb.insert(pdcp_map_pair_t(lcid, new pdcp_entity_lte())).second) { + if (not pdcp_array_mrb.insert(pdcp_map_pair_t(lcid, new pdcp_entity_lte(rlc, rrc, gw, timers, pdcp_log))).second) { pdcp_log->error("Error inserting PDCP entity in to array\n."); goto unlock_and_exit; } - pdcp_array_mrb.at(lcid)->init(rlc, rrc, gw, pdcp_log, lcid, cfg); + pdcp_array_mrb.at(lcid)->init( lcid, cfg); pdcp_log->info("Add %s (lcid=%d, bearer_id=%d, sn_len=%dbits)\n", rrc->get_rb_name(lcid).c_str(), lcid, diff --git a/lib/src/upper/pdcp_entity_base.cc b/lib/src/upper/pdcp_entity_base.cc index 31f3c151a..7cacf1280 100644 --- a/lib/src/upper/pdcp_entity_base.cc +++ b/lib/src/upper/pdcp_entity_base.cc @@ -24,7 +24,7 @@ namespace srslte { -pdcp_entity_base::pdcp_entity_base() {} +pdcp_entity_base::pdcp_entity_base(srslte::timer_handler* timers_, srslte::log* log_) : log(log_), timers(timers_) {} pdcp_entity_base::~pdcp_entity_base() {} diff --git a/lib/src/upper/pdcp_entity_lte.cc b/lib/src/upper/pdcp_entity_lte.cc index 2e21c2fcd..54731c579 100644 --- a/lib/src/upper/pdcp_entity_lte.cc +++ b/lib/src/upper/pdcp_entity_lte.cc @@ -24,21 +24,22 @@ namespace srslte { -pdcp_entity_lte::pdcp_entity_lte() {} +pdcp_entity_lte::pdcp_entity_lte(srsue::rlc_interface_pdcp* rlc_, + srsue::rrc_interface_pdcp* rrc_, + srsue::gw_interface_pdcp* gw_, + srslte::timer_handler* timers_, + srslte::log* log_) : + pdcp_entity_base(timers_, log_), + rlc(rlc_), + rrc(rrc_), + gw(gw_) +{ +} pdcp_entity_lte::~pdcp_entity_lte() {} -void pdcp_entity_lte::init(srsue::rlc_interface_pdcp* rlc_, - srsue::rrc_interface_pdcp* rrc_, - srsue::gw_interface_pdcp* gw_, - srslte::log* log_, - uint32_t lcid_, - pdcp_config_t cfg_) +void pdcp_entity_lte::init(uint32_t lcid_, pdcp_config_t cfg_) { - rlc = rlc_; - rrc = rrc_; - gw = gw_; - log = log_; lcid = lcid_; cfg = cfg_; active = true; diff --git a/lib/src/upper/pdcp_entity_nr.cc b/lib/src/upper/pdcp_entity_nr.cc index 5745cc9db..490b067fd 100644 --- a/lib/src/upper/pdcp_entity_nr.cc +++ b/lib/src/upper/pdcp_entity_nr.cc @@ -25,23 +25,23 @@ namespace srslte { -pdcp_entity_nr::pdcp_entity_nr() : reordering_fnc(new pdcp_entity_nr::reordering_callback(this)) {} +pdcp_entity_nr::pdcp_entity_nr(srsue::rlc_interface_pdcp* rlc_, + srsue::rrc_interface_pdcp* rrc_, + srsue::gw_interface_pdcp* gw_, + srslte::timer_handler* timers_, + srslte::log* log_) : + pdcp_entity_base(timers_, log_), + rlc(rlc_), + rrc(rrc_), + gw(gw_), + reordering_fnc(new pdcp_entity_nr::reordering_callback(this)) +{ +} 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::timer_handler* timers_, - srslte::log* log_, - uint32_t lcid_, - pdcp_config_t cfg_) +void pdcp_entity_nr::init(uint32_t lcid_, pdcp_config_t cfg_) { - rlc = rlc_; - rrc = rrc_; - gw = gw_; - timers = timers_; - log = log_; lcid = lcid_; cfg = cfg_; active = true; @@ -51,7 +51,7 @@ void pdcp_entity_nr::init(srsue::rlc_interface_pdcp* rlc_, window_size = 1 << (cfg.sn_len - 1); // Timers - reordering_timer = timers_->get_unique_timer(); + reordering_timer = timers->get_unique_timer(); // configure timer if (static_cast(cfg.t_reordering) > 0) { diff --git a/lib/test/upper/pdcp_nr_test.h b/lib/test/upper/pdcp_nr_test.h index 7c65e9bc4..cbf4ebc55 100644 --- a/lib/test/upper/pdcp_nr_test.h +++ b/lib/test/upper/pdcp_nr_test.h @@ -148,9 +148,10 @@ public: rlc(log), rrc(log), gw(log), - timers(64) + timers(64), + pdcp(&rlc, &rrc, &gw, &timers, log) { - pdcp.init(&rlc, &rrc, &gw, &timers, log, 0, cfg); + pdcp.init(0, cfg); pdcp.config_security( sec_cfg.k_enc_rrc, sec_cfg.k_int_rrc, sec_cfg.k_enc_up, sec_cfg.k_int_up, sec_cfg.enc_algo, sec_cfg.int_algo); pdcp.enable_integrity(); @@ -165,11 +166,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::timer_handler timers; + srslte::pdcp_entity_nr pdcp; }; // Helper function to generate PDUs diff --git a/srsenb/hdr/stack/upper/pdcp.h b/srsenb/hdr/stack/upper/pdcp.h index 2b62b6d26..fa3792126 100644 --- a/srsenb/hdr/stack/upper/pdcp.h +++ b/srsenb/hdr/stack/upper/pdcp.h @@ -19,10 +19,11 @@ * */ -#include -#include "srslte/interfaces/ue_interfaces.h" +#include "srslte/common/timers.h" #include "srslte/interfaces/enb_interfaces.h" +#include "srslte/interfaces/ue_interfaces.h" #include "srslte/upper/pdcp.h" +#include #ifndef SRSENB_PDCP_H #define SRSENB_PDCP_H @@ -32,7 +33,7 @@ namespace srsenb { class pdcp : public pdcp_interface_rlc, public pdcp_interface_gtpu, public pdcp_interface_rrc { public: - pdcp(srslte::log* pdcp_log_); + pdcp(srslte::timer_handler* timers, srslte::log* pdcp_log_); virtual ~pdcp() {}; void init(rlc_interface_pdcp* rlc_, rrc_interface_pdcp* rrc_, gtpu_interface_pdcp* gtpu_); void stop(); @@ -110,6 +111,7 @@ private: rlc_interface_pdcp* rlc; rrc_interface_pdcp* rrc; gtpu_interface_pdcp* gtpu; + srslte::timer_handler* timers; srslte::log* log_h; srslte::byte_buffer_pool* pool; }; diff --git a/srsenb/src/stack/enb_stack_lte.cc b/srsenb/src/stack/enb_stack_lte.cc index 224daa238..7ec681d04 100644 --- a/srsenb/src/stack/enb_stack_lte.cc +++ b/srsenb/src/stack/enb_stack_lte.cc @@ -29,7 +29,11 @@ using namespace srslte; namespace srsenb { -enb_stack_lte::enb_stack_lte(srslte::logger* logger_) : logger(logger_), pdcp(&pdcp_log), timers(128), thread("STACK") +enb_stack_lte::enb_stack_lte(srslte::logger* logger_) : + timers(128), + logger(logger_), + pdcp(&timers, &pdcp_log), + thread("STACK") { enb_queue_id = pending_tasks.add_queue(); sync_queue_id = pending_tasks.add_queue(); diff --git a/srsenb/src/stack/upper/pdcp.cc b/srsenb/src/stack/upper/pdcp.cc index 685633236..79ae020cd 100644 --- a/srsenb/src/stack/upper/pdcp.cc +++ b/srsenb/src/stack/upper/pdcp.cc @@ -24,7 +24,12 @@ namespace srsenb { -pdcp::pdcp(srslte::log* log_) : log_h(log_), pool(srslte::byte_buffer_pool::get_instance()) {} +pdcp::pdcp(srslte::timer_handler* timers_, srslte::log* log_) : + timers(timers_), + log_h(log_), + pool(srslte::byte_buffer_pool::get_instance()) +{ +} void pdcp::init(rlc_interface_pdcp* rlc_, rrc_interface_pdcp* rrc_, gtpu_interface_pdcp* gtpu_) { @@ -50,7 +55,7 @@ void pdcp::add_user(uint16_t rnti) { pthread_rwlock_rdlock(&rwlock); if (users.count(rnti) == 0) { - srslte::pdcp* obj = new srslte::pdcp(log_h); + srslte::pdcp* obj = new srslte::pdcp(timers, log_h); obj->init(&users[rnti].rlc_itf, &users[rnti].rrc_itf, &users[rnti].gtpu_itf); users[rnti].rlc_itf.rnti = rnti; users[rnti].gtpu_itf.rnti = rnti; diff --git a/srsue/src/stack/ue_stack_lte.cc b/srsue/src/stack/ue_stack_lte.cc index 669d295da..652ef97bf 100644 --- a/srsue/src/stack/ue_stack_lte.cc +++ b/srsue/src/stack/ue_stack_lte.cc @@ -36,7 +36,7 @@ ue_stack_lte::ue_stack_lte() : rlc(&rlc_log), mac(&mac_log), rrc(&rrc_log), - pdcp(&pdcp_log), + pdcp(&timers, &pdcp_log), nas(&nas_log, &timers), thread("STACK"), pending_tasks(1024),