From 7210c35c6cb903442fcccde780705bbd2a8b0603 Mon Sep 17 00:00:00 2001 From: Francisco Paisana Date: Tue, 3 Mar 2020 17:12:19 +0000 Subject: [PATCH] checked all methods of srsenb::pdcp to see if they are called by different threads. Since it is all single-threaded, I removed the locks --- srsenb/hdr/stack/upper/pdcp.h | 22 ++++++++++------------ srsenb/src/stack/rrc/rrc.cc | 1 - srsenb/src/stack/upper/pdcp.cc | 23 ----------------------- 3 files changed, 10 insertions(+), 36 deletions(-) diff --git a/srsenb/hdr/stack/upper/pdcp.h b/srsenb/hdr/stack/upper/pdcp.h index 95a4f4c0f..091026afb 100644 --- a/srsenb/hdr/stack/upper/pdcp.h +++ b/srsenb/hdr/stack/upper/pdcp.h @@ -34,29 +34,29 @@ class pdcp : public pdcp_interface_rlc, public pdcp_interface_gtpu, public pdcp_ { public: pdcp(srslte::timer_handler* timers, srslte::log* pdcp_log_); - virtual ~pdcp(){}; + virtual ~pdcp() {} void init(rlc_interface_pdcp* rlc_, rrc_interface_pdcp* rrc_, gtpu_interface_pdcp* gtpu_); void stop(); // pdcp_interface_rlc - void write_pdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t sdu); + void write_pdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t sdu) override; void write_pdu_mch(uint32_t lcid, srslte::unique_byte_buffer_t sdu) {} // pdcp_interface_rrc - void reset(uint16_t rnti); - void add_user(uint16_t rnti); - void rem_user(uint16_t rnti); - void write_sdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t sdu); - void add_bearer(uint16_t rnti, uint32_t lcid, srslte::pdcp_config_t cnfg); + void reset(uint16_t rnti) override; + void add_user(uint16_t rnti) override; + void rem_user(uint16_t rnti) override; + void write_sdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t sdu) override; + void add_bearer(uint16_t rnti, uint32_t lcid, srslte::pdcp_config_t cnfg) override; void config_security(uint16_t rnti, uint32_t lcid, uint8_t* k_rrc_enc_, uint8_t* k_rrc_int_, uint8_t* k_up_enc_, srslte::CIPHERING_ALGORITHM_ID_ENUM cipher_algo_, - srslte::INTEGRITY_ALGORITHM_ID_ENUM integ_algo_); - void enable_integrity(uint16_t rnti, uint32_t lcid); - void enable_encryption(uint16_t rnti, uint32_t lcid); + srslte::INTEGRITY_ALGORITHM_ID_ENUM integ_algo_) override; + void enable_integrity(uint16_t rnti, uint32_t lcid) override; + void enable_encryption(uint16_t rnti, uint32_t lcid) override; bool get_bearer_status(uint16_t rnti, uint32_t lcid, uint16_t* dlsn, uint16_t* dlhfn, uint16_t* ulsn, uint16_t* ulhfn) override; @@ -109,8 +109,6 @@ private: std::map users; - pthread_rwlock_t rwlock; - rlc_interface_pdcp* rlc; rrc_interface_pdcp* rrc; gtpu_interface_pdcp* gtpu; diff --git a/srsenb/src/stack/rrc/rrc.cc b/srsenb/src/stack/rrc/rrc.cc index 00d1c9118..4b8017d00 100644 --- a/srsenb/src/stack/rrc/rrc.cc +++ b/srsenb/src/stack/rrc/rrc.cc @@ -736,7 +736,6 @@ void rrc::process_release_complete(uint16_t rnti) } } -///< user mutex lock must be hold by calling function void rrc::rem_user(uint16_t rnti) { auto user_it = users.find(rnti); diff --git a/srsenb/src/stack/upper/pdcp.cc b/srsenb/src/stack/upper/pdcp.cc index 86e9327a5..167a6edf1 100644 --- a/srsenb/src/stack/upper/pdcp.cc +++ b/srsenb/src/stack/upper/pdcp.cc @@ -36,24 +36,18 @@ void pdcp::init(rlc_interface_pdcp* rlc_, rrc_interface_pdcp* rrc_, gtpu_interfa rlc = rlc_; rrc = rrc_; gtpu = gtpu_; - - pthread_rwlock_init(&rwlock, NULL); } void pdcp::stop() { - pthread_rwlock_wrlock(&rwlock); for (std::map::iterator iter = users.begin(); iter != users.end(); ++iter) { clear_user(&iter->second); } users.clear(); - pthread_rwlock_unlock(&rwlock); - pthread_rwlock_destroy(&rwlock); } void pdcp::add_user(uint16_t rnti) { - pthread_rwlock_wrlock(&rwlock); if (users.count(rnti) == 0) { srslte::pdcp* obj = new srslte::pdcp(timers, log_h); obj->init(&users[rnti].rlc_itf, &users[rnti].rrc_itf, &users[rnti].gtpu_itf); @@ -66,7 +60,6 @@ void pdcp::add_user(uint16_t rnti) users[rnti].gtpu_itf.gtpu = gtpu; users[rnti].pdcp = obj; } - pthread_rwlock_unlock(&rwlock); } // Private unlocked deallocation of user @@ -79,17 +72,14 @@ void pdcp::clear_user(user_interface* ue) void pdcp::rem_user(uint16_t rnti) { - pthread_rwlock_wrlock(&rwlock); if (users.count(rnti)) { clear_user(&users[rnti]); users.erase(rnti); } - pthread_rwlock_unlock(&rwlock); } void pdcp::add_bearer(uint16_t rnti, uint32_t lcid, srslte::pdcp_config_t cfg) { - pthread_rwlock_rdlock(&rwlock); if (users.count(rnti)) { if (rnti != SRSLTE_MRNTI) { users[rnti].pdcp->add_bearer(lcid, cfg); @@ -97,16 +87,13 @@ void pdcp::add_bearer(uint16_t rnti, uint32_t lcid, srslte::pdcp_config_t cfg) users[rnti].pdcp->add_bearer_mrb(lcid, cfg); } } - pthread_rwlock_unlock(&rwlock); } void pdcp::reset(uint16_t rnti) { - pthread_rwlock_rdlock(&rwlock); if (users.count(rnti)) { users[rnti].pdcp->reset(); } - pthread_rwlock_unlock(&rwlock); } void pdcp::config_security(uint16_t rnti, @@ -117,25 +104,19 @@ void pdcp::config_security(uint16_t rnti, srslte::CIPHERING_ALGORITHM_ID_ENUM cipher_algo_, srslte::INTEGRITY_ALGORITHM_ID_ENUM integ_algo_) { - pthread_rwlock_rdlock(&rwlock); if (users.count(rnti)) { users[rnti].pdcp->config_security(lcid, k_rrc_enc_, k_rrc_int_, k_up_enc_, cipher_algo_, integ_algo_); } - pthread_rwlock_unlock(&rwlock); } void pdcp::enable_integrity(uint16_t rnti, uint32_t lcid) { - pthread_rwlock_rdlock(&rwlock); users[rnti].pdcp->enable_integrity(lcid, srslte::DIRECTION_TXRX); - pthread_rwlock_unlock(&rwlock); } void pdcp::enable_encryption(uint16_t rnti, uint32_t lcid) { - pthread_rwlock_rdlock(&rwlock); users[rnti].pdcp->enable_encryption(lcid, srslte::DIRECTION_TXRX); - pthread_rwlock_unlock(&rwlock); } bool pdcp::get_bearer_status(uint16_t rnti, @@ -153,16 +134,13 @@ bool pdcp::get_bearer_status(uint16_t rnti, void pdcp::write_pdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t sdu) { - pthread_rwlock_rdlock(&rwlock); if (users.count(rnti)) { users[rnti].pdcp->write_pdu(lcid, std::move(sdu)); } - pthread_rwlock_unlock(&rwlock); } void pdcp::write_sdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t sdu) { - pthread_rwlock_rdlock(&rwlock); if (users.count(rnti)) { if (rnti != SRSLTE_MRNTI) { // TODO: expose blocking mode as function param @@ -171,7 +149,6 @@ void pdcp::write_sdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t users[rnti].pdcp->write_sdu_mch(lcid, std::move(sdu)); } } - pthread_rwlock_unlock(&rwlock); } void pdcp::user_interface_gtpu::write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t pdu)