From 9f7ae7a2b2e5472261007dbf6ae490095c40e4d4 Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Fri, 26 Nov 2021 11:38:00 +0000 Subject: [PATCH] gnb,ngap: Added simple allocation of lcids to ngap_ue_bearer_manager. --- .../hdr/stack/ngap/ngap_ue_bearer_manager.h | 19 +++++++++++-------- .../src/stack/ngap/ngap_ue_bearer_manager.cc | 13 ++++++++++++- srsgnb/src/stack/ngap/ngap_ue_proc.cc | 4 ++-- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/srsgnb/hdr/stack/ngap/ngap_ue_bearer_manager.h b/srsgnb/hdr/stack/ngap/ngap_ue_bearer_manager.h index 91f2d9855..361e4f46f 100644 --- a/srsgnb/hdr/stack/ngap/ngap_ue_bearer_manager.h +++ b/srsgnb/hdr/stack/ngap/ngap_ue_bearer_manager.h @@ -61,13 +61,16 @@ private: std::map pdu_session_list; srslog::basic_logger& logger; - int add_gtpu_bearer(uint16_t rnti, - uint32_t pdu_session_id, - uint32_t teid_out, - asn1::bounded_bitstring<1, 160, true, true> address, - pdu_session_t::gtpu_tunnel& tunnel, // out parameter - const gtpu_interface_rrc::bearer_props* props = nullptr); - void rem_gtpu_bearer(uint16_t rnti, uint32_t pdu_session_id); + std::map next_lcid_list; // Map RNTI to next LCID to be allocated + + int add_gtpu_bearer(uint16_t rnti, + uint32_t pdu_session_id, + uint32_t teid_out, + asn1::bounded_bitstring<1, 160, true, true> address, + pdu_session_t::gtpu_tunnel& tunnel, // out parameter + const gtpu_interface_rrc::bearer_props* props = nullptr); + void rem_gtpu_bearer(uint16_t rnti, uint32_t pdu_session_id); + uint8_t allocate_lcid(uint32_t rnti); }; } // namespace srsenb -#endif // SRSENB_NGAP_UE_BEARER_MANAGER_H \ No newline at end of file +#endif // SRSENB_NGAP_UE_BEARER_MANAGER_H diff --git a/srsgnb/src/stack/ngap/ngap_ue_bearer_manager.cc b/srsgnb/src/stack/ngap/ngap_ue_bearer_manager.cc index ad336df4c..0f1c0ac4d 100644 --- a/srsgnb/src/stack/ngap/ngap_ue_bearer_manager.cc +++ b/srsgnb/src/stack/ngap/ngap_ue_bearer_manager.cc @@ -37,6 +37,8 @@ int ngap_ue_bearer_manager::add_pdu_session(uint16_t return SRSRAN_ERROR; } + lcid = allocate_lcid(rnti); + // TODO: remove lcid and just use pdu_session_id and rnti as id for GTP tunnel int rtn = add_gtpu_bearer(rnti, pdu_session_id, teid_out, addr_out, tunnel); if (rtn != SRSRAN_SUCCESS) { @@ -62,6 +64,7 @@ int ngap_ue_bearer_manager::reset_pdu_sessions(uint16_t rnti) auto pdu_session_id = iter->first; rem_gtpu_bearer(pdu_session_id, rnti); } + next_lcid_list.erase(rnti); return true; } @@ -110,4 +113,12 @@ void ngap_ue_bearer_manager::rem_gtpu_bearer(uint16_t rnti, uint32_t pdu_session gtpu->rem_bearer(rnti, it->second.lcid); } -} // namespace srsenb \ No newline at end of file +uint8_t ngap_ue_bearer_manager::allocate_lcid(uint32_t rnti) +{ + if (next_lcid_list.find(rnti) == next_lcid_list.end()) { + next_lcid_list[rnti] = 4; + } + return next_lcid_list[rnti]++; +} + +} // namespace srsenb diff --git a/srsgnb/src/stack/ngap/ngap_ue_proc.cc b/srsgnb/src/stack/ngap/ngap_ue_proc.cc index 31f7b6247..e1e820f91 100644 --- a/srsgnb/src/stack/ngap/ngap_ue_proc.cc +++ b/srsgnb/src/stack/ngap/ngap_ue_proc.cc @@ -143,8 +143,8 @@ proc_outcome_t ngap_ue_pdu_session_res_setup_proc::init(const asn1::ngap_nr::pdu // TODO: Check cause asn1::ngap_nr::cause_c cause; - uint32_t teid_in; - uint16_t lcid; + uint32_t teid_in = {}; + uint16_t lcid = {}; asn1::bounded_bitstring<1, 160, true, true> addr_in; if (bearer_manager->add_pdu_session(