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

master
Francisco Paisana 5 years ago
parent fed06138b9
commit 7210c35c6c

@ -34,29 +34,29 @@ class pdcp : public pdcp_interface_rlc, public pdcp_interface_gtpu, public pdcp_
{ {
public: public:
pdcp(srslte::timer_handler* timers, srslte::log* pdcp_log_); 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 init(rlc_interface_pdcp* rlc_, rrc_interface_pdcp* rrc_, gtpu_interface_pdcp* gtpu_);
void stop(); void stop();
// pdcp_interface_rlc // 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) {} void write_pdu_mch(uint32_t lcid, srslte::unique_byte_buffer_t sdu) {}
// pdcp_interface_rrc // pdcp_interface_rrc
void reset(uint16_t rnti); void reset(uint16_t rnti) override;
void add_user(uint16_t rnti); void add_user(uint16_t rnti) override;
void rem_user(uint16_t rnti); void rem_user(uint16_t rnti) override;
void write_sdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t sdu); 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); void add_bearer(uint16_t rnti, uint32_t lcid, srslte::pdcp_config_t cnfg) override;
void config_security(uint16_t rnti, void config_security(uint16_t rnti,
uint32_t lcid, uint32_t lcid,
uint8_t* k_rrc_enc_, uint8_t* k_rrc_enc_,
uint8_t* k_rrc_int_, uint8_t* k_rrc_int_,
uint8_t* k_up_enc_, uint8_t* k_up_enc_,
srslte::CIPHERING_ALGORITHM_ID_ENUM cipher_algo_, srslte::CIPHERING_ALGORITHM_ID_ENUM cipher_algo_,
srslte::INTEGRITY_ALGORITHM_ID_ENUM integ_algo_); srslte::INTEGRITY_ALGORITHM_ID_ENUM integ_algo_) override;
void enable_integrity(uint16_t rnti, uint32_t lcid); void enable_integrity(uint16_t rnti, uint32_t lcid) override;
void enable_encryption(uint16_t rnti, uint32_t lcid); 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) bool get_bearer_status(uint16_t rnti, uint32_t lcid, uint16_t* dlsn, uint16_t* dlhfn, uint16_t* ulsn, uint16_t* ulhfn)
override; override;
@ -109,8 +109,6 @@ private:
std::map<uint32_t, user_interface> users; std::map<uint32_t, user_interface> users;
pthread_rwlock_t rwlock;
rlc_interface_pdcp* rlc; rlc_interface_pdcp* rlc;
rrc_interface_pdcp* rrc; rrc_interface_pdcp* rrc;
gtpu_interface_pdcp* gtpu; gtpu_interface_pdcp* gtpu;

@ -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) void rrc::rem_user(uint16_t rnti)
{ {
auto user_it = users.find(rnti); auto user_it = users.find(rnti);

@ -36,24 +36,18 @@ void pdcp::init(rlc_interface_pdcp* rlc_, rrc_interface_pdcp* rrc_, gtpu_interfa
rlc = rlc_; rlc = rlc_;
rrc = rrc_; rrc = rrc_;
gtpu = gtpu_; gtpu = gtpu_;
pthread_rwlock_init(&rwlock, NULL);
} }
void pdcp::stop() void pdcp::stop()
{ {
pthread_rwlock_wrlock(&rwlock);
for (std::map<uint32_t, user_interface>::iterator iter = users.begin(); iter != users.end(); ++iter) { for (std::map<uint32_t, user_interface>::iterator iter = users.begin(); iter != users.end(); ++iter) {
clear_user(&iter->second); clear_user(&iter->second);
} }
users.clear(); users.clear();
pthread_rwlock_unlock(&rwlock);
pthread_rwlock_destroy(&rwlock);
} }
void pdcp::add_user(uint16_t rnti) void pdcp::add_user(uint16_t rnti)
{ {
pthread_rwlock_wrlock(&rwlock);
if (users.count(rnti) == 0) { if (users.count(rnti) == 0) {
srslte::pdcp* obj = new srslte::pdcp(timers, 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); 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].gtpu_itf.gtpu = gtpu;
users[rnti].pdcp = obj; users[rnti].pdcp = obj;
} }
pthread_rwlock_unlock(&rwlock);
} }
// Private unlocked deallocation of user // Private unlocked deallocation of user
@ -79,17 +72,14 @@ void pdcp::clear_user(user_interface* ue)
void pdcp::rem_user(uint16_t rnti) void pdcp::rem_user(uint16_t rnti)
{ {
pthread_rwlock_wrlock(&rwlock);
if (users.count(rnti)) { if (users.count(rnti)) {
clear_user(&users[rnti]); clear_user(&users[rnti]);
users.erase(rnti); users.erase(rnti);
} }
pthread_rwlock_unlock(&rwlock);
} }
void pdcp::add_bearer(uint16_t rnti, uint32_t lcid, srslte::pdcp_config_t cfg) void pdcp::add_bearer(uint16_t rnti, uint32_t lcid, srslte::pdcp_config_t cfg)
{ {
pthread_rwlock_rdlock(&rwlock);
if (users.count(rnti)) { if (users.count(rnti)) {
if (rnti != SRSLTE_MRNTI) { if (rnti != SRSLTE_MRNTI) {
users[rnti].pdcp->add_bearer(lcid, cfg); 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); users[rnti].pdcp->add_bearer_mrb(lcid, cfg);
} }
} }
pthread_rwlock_unlock(&rwlock);
} }
void pdcp::reset(uint16_t rnti) void pdcp::reset(uint16_t rnti)
{ {
pthread_rwlock_rdlock(&rwlock);
if (users.count(rnti)) { if (users.count(rnti)) {
users[rnti].pdcp->reset(); users[rnti].pdcp->reset();
} }
pthread_rwlock_unlock(&rwlock);
} }
void pdcp::config_security(uint16_t rnti, 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::CIPHERING_ALGORITHM_ID_ENUM cipher_algo_,
srslte::INTEGRITY_ALGORITHM_ID_ENUM integ_algo_) srslte::INTEGRITY_ALGORITHM_ID_ENUM integ_algo_)
{ {
pthread_rwlock_rdlock(&rwlock);
if (users.count(rnti)) { if (users.count(rnti)) {
users[rnti].pdcp->config_security(lcid, k_rrc_enc_, k_rrc_int_, k_up_enc_, cipher_algo_, integ_algo_); 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) void pdcp::enable_integrity(uint16_t rnti, uint32_t lcid)
{ {
pthread_rwlock_rdlock(&rwlock);
users[rnti].pdcp->enable_integrity(lcid, srslte::DIRECTION_TXRX); users[rnti].pdcp->enable_integrity(lcid, srslte::DIRECTION_TXRX);
pthread_rwlock_unlock(&rwlock);
} }
void pdcp::enable_encryption(uint16_t rnti, uint32_t lcid) void pdcp::enable_encryption(uint16_t rnti, uint32_t lcid)
{ {
pthread_rwlock_rdlock(&rwlock);
users[rnti].pdcp->enable_encryption(lcid, srslte::DIRECTION_TXRX); users[rnti].pdcp->enable_encryption(lcid, srslte::DIRECTION_TXRX);
pthread_rwlock_unlock(&rwlock);
} }
bool pdcp::get_bearer_status(uint16_t rnti, 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) void pdcp::write_pdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t sdu)
{ {
pthread_rwlock_rdlock(&rwlock);
if (users.count(rnti)) { if (users.count(rnti)) {
users[rnti].pdcp->write_pdu(lcid, std::move(sdu)); 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) 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 (users.count(rnti)) {
if (rnti != SRSLTE_MRNTI) { if (rnti != SRSLTE_MRNTI) {
// TODO: expose blocking mode as function param // 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)); 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) void pdcp::user_interface_gtpu::write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t pdu)

Loading…
Cancel
Save