From 27459bf706b3b8e2d11d906021ddbc16e47472f2 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Mon, 17 Sep 2018 13:10:44 +0200 Subject: [PATCH 1/2] add API to change LCID of PDCP bearers --- lib/include/srslte/upper/pdcp.h | 1 + lib/src/upper/pdcp.cc | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/lib/include/srslte/upper/pdcp.h b/lib/include/srslte/upper/pdcp.h index e4be9d548..7272f5079 100644 --- a/lib/include/srslte/upper/pdcp.h +++ b/lib/include/srslte/upper/pdcp.h @@ -61,6 +61,7 @@ public: void add_bearer(uint32_t lcid, srslte_pdcp_config_t cnfg = srslte_pdcp_config_t()); void add_bearer_mrb(uint32_t lcid, srslte_pdcp_config_t cnfg = srslte_pdcp_config_t()); void del_bearer(uint32_t lcid); + void change_lcid(uint32_t old_lcid, uint32_t new_lcid); void config_security(uint32_t lcid, uint8_t *k_enc, uint8_t *k_int, diff --git a/lib/src/upper/pdcp.cc b/lib/src/upper/pdcp.cc index c8391518b..93ac0cf15 100644 --- a/lib/src/upper/pdcp.cc +++ b/lib/src/upper/pdcp.cc @@ -187,6 +187,28 @@ void pdcp::del_bearer(uint32_t lcid) pthread_rwlock_unlock(&rwlock); } +void pdcp::change_lcid(uint32_t old_lcid, uint32_t new_lcid) +{ + pthread_rwlock_wrlock(&rwlock); + + // make sure old LCID exists and new LCID is still free + if (valid_lcid(old_lcid) && not valid_lcid(new_lcid)) { + // insert old PDCP entity into new LCID + pdcp_map_t::iterator it = pdcp_array.find(old_lcid); + pdcp_entity_interface *pdcp_entity = it->second; + if (not pdcp_array.insert(pdcp_map_pair_t(new_lcid, pdcp_entity)).second) { + pdcp_log->error("Error inserting PDCP entity into array\n."); + goto exit; + } + // erase from old position + pdcp_array.erase(it); + pdcp_log->warning("Changed LCID of PDCP bearer from %d to %d\n", old_lcid, new_lcid); + } else { + pdcp_log->error("Can't change PDCP of bearer %s from %d to %d. Bearer doesn't exist or new LCID already occupied.\n", rrc->get_rb_name(old_lcid).c_str(), old_lcid, new_lcid); + } +exit: + pthread_rwlock_unlock(&rwlock); +} void pdcp::config_security(uint32_t lcid, uint8_t *k_enc, From 10bc01a7ae5bab866c5c2bb351ad20293fc327b6 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Mon, 17 Sep 2018 13:11:03 +0200 Subject: [PATCH 2/2] add API to change LCID of RLC bearers --- lib/include/srslte/upper/rlc.h | 1 + lib/src/upper/rlc.cc | 26 +++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/lib/include/srslte/upper/rlc.h b/lib/include/srslte/upper/rlc.h index a56f48eff..8fdde468c 100644 --- a/lib/include/srslte/upper/rlc.h +++ b/lib/include/srslte/upper/rlc.h @@ -87,6 +87,7 @@ public: void add_bearer(uint32_t lcid, srslte_rlc_config_t cnfg); void add_bearer_mrb(uint32_t lcid); void del_bearer(uint32_t lcid); + void change_lcid(uint32_t old_lcid, uint32_t new_lcid); private: void reset_metrics(); diff --git a/lib/src/upper/rlc.cc b/lib/src/upper/rlc.cc index 237891430..adbaff3e3 100644 --- a/lib/src/upper/rlc.cc +++ b/lib/src/upper/rlc.cc @@ -505,13 +505,37 @@ void rlc::del_bearer(uint32_t lcid) rlc_array.erase(it); rlc_log->warning("Deleted RLC bearer %s\n", rrc->get_rb_name(lcid).c_str()); } else { - rlc_log->warning("Can't delete bearer %s. Bearer doesn't exist.\n", rrc->get_rb_name(lcid).c_str()); + rlc_log->error("Can't delete bearer %s. Bearer doesn't exist.\n", rrc->get_rb_name(lcid).c_str()); } pthread_rwlock_unlock(&rwlock); } +void rlc::change_lcid(uint32_t old_lcid, uint32_t new_lcid) +{ + pthread_rwlock_wrlock(&rwlock); + + // make sure old LCID exists and new LCID is still free + if (valid_lcid(old_lcid) && not valid_lcid(new_lcid)) { + // insert old rlc entity into new LCID + rlc_map_t::iterator it = rlc_array.find(old_lcid); + rlc_common *rlc_entity = it->second; + if (not rlc_array.insert(rlc_map_pair_t(new_lcid, rlc_entity)).second) { + rlc_log->error("Error inserting RLC entity into array\n."); + goto exit; + } + // erase from old position + rlc_array.erase(it); + rlc_log->warning("Changed LCID of RLC bearer from %d to %d\n", old_lcid, new_lcid); + } else { + rlc_log->error("Can't change LCID of bearer %s from %d to %d. Bearer doesn't exist or new LCID already occupied.\n", rrc->get_rb_name(old_lcid).c_str(), old_lcid, new_lcid); + } +exit: + pthread_rwlock_unlock(&rwlock); +} + + /******************************************************************************* Helpers (Lock must be hold when calling those) *******************************************************************************/