From f7a8b8bf94173701ddc60f898e2c38d9f2ffe4a1 Mon Sep 17 00:00:00 2001 From: Francisco Date: Fri, 9 Apr 2021 16:00:40 +0100 Subject: [PATCH] separate drb srb ids into separate enum types --- lib/include/srsran/common/lte_common.h | 71 ++++++++--------- srsenb/hdr/common/common_enb.h | 11 ++- srsenb/src/stack/rrc/mac_controller.cc | 6 +- srsenb/src/stack/rrc/rrc.cc | 8 +- srsenb/src/stack/rrc/rrc_ue.cc | 24 +++--- srsenb/src/stack/upper/rlc.cc | 4 +- srsenb/test/mac/sched_lc_ch_test.cc | 106 ++++++++++++------------- srsenb/test/mac/sched_sim_ue.cc | 2 +- srsenb/test/mac/sched_test_common.cc | 2 +- srsenb/test/mac/sched_test_utils.h | 48 +++++------ srsenb/test/upper/rrc_mobility_test.cc | 30 +++---- srsue/hdr/stack/rrc/rrc.h | 9 +-- srsue/src/stack/rrc/rrc.cc | 45 ++++++----- srsue/src/stack/rrc/rrc_procedures.cc | 2 +- 14 files changed, 180 insertions(+), 188 deletions(-) diff --git a/lib/include/srsran/common/lte_common.h b/lib/include/srsran/common/lte_common.h index e2d8f06be..289852144 100644 --- a/lib/include/srsran/common/lte_common.h +++ b/lib/include/srsran/common/lte_common.h @@ -20,48 +20,43 @@ namespace srsran { // Cell nof PRBs const std::array lte_cell_nof_prbs = {6, 15, 25, 50, 75, 100}; -inline uint32_t lte_nof_prb_to_idx(uint32_t nof_prb) + +// Radio Bearers +enum class lte_srb { srb0, srb1, srb2, count }; +const uint32_t MAX_LTE_SRB_ID = 2; +constexpr bool is_lte_srb(uint32_t lcid) +{ + return lcid <= MAX_LTE_SRB_ID; +} +inline const char* get_srb_name(lte_srb srb_id) { - switch (nof_prb) { - case 6: - return 0; - case 15: - return 1; - case 25: - return 2; - case 50: - return 3; - case 75: - return 4; - case 100: - return 5; - default: - return -1; - } + static const char* names[] = {"SRB0", "SRB1", "SRB2", "invalid SRB id"}; + return names[(uint32_t)(srb_id < lte_srb::count ? srb_id : lte_srb::count)]; +} +constexpr uint32_t srb_to_lcid(lte_srb srb_id) +{ + return static_cast(srb_id); +} +constexpr lte_srb lte_lcid_to_srb(uint32_t lcid) +{ + return static_cast(lcid); } -// Radio Bearer -enum class lte_rb { srb0, srb1, srb2, drb1, drb2, drb3, drb4, drb5, drb6, drb7, drb8, drb9, drb10, drb11, count }; -const size_t MAX_LTE_DRB_ID = 11; -const size_t MAX_LTE_SRB_ID = 2; -inline const char* get_rb_name(lte_rb rb_id) +enum class lte_drb { drb1 = 1, drb2, drb3, drb4, drb5, drb6, drb7, drb8, drb9, drb10, drb11, invalid }; +const uint32_t MAX_LTE_DRB_ID = 11; +constexpr bool is_lte_drb(uint32_t lcid) +{ + return lcid > MAX_LTE_SRB_ID and lcid <= MAX_LTE_DRB_ID + MAX_LTE_SRB_ID; +} +inline const char* get_drb_name(lte_drb drb_id) +{ + static const char* names[] = { + "DRB1", "DRB2", "DRB3", "DRB4", "DRB5", "DRB6", "DRB7", "DRB8", "DRB9", "DRB10", "DRB11", "invalid DRB id"}; + return names[(uint32_t)(drb_id < lte_drb::invalid ? drb_id : lte_drb::invalid) - 1]; +} +constexpr bool is_lte_rb(uint32_t lcid) { - static const char* names[] = {"SRB0", - "SRB1", - "SRB2", - "DRB0", - "DRB1", - "DRB2", - "DRB3", - "DRB4", - "DRB5", - "DRB6", - "DRB7", - "DRB8", - "DRB9", - "DRB10", - "invalid RB id"}; - return names[rb_id < lte_rb::count ? (size_t)rb_id : (size_t)lte_rb::count]; + return lcid <= MAX_LTE_DRB_ID + MAX_LTE_SRB_ID; } } // namespace srsran diff --git a/srsenb/hdr/common/common_enb.h b/srsenb/hdr/common/common_enb.h index 9031d3a13..7f0cde6ff 100644 --- a/srsenb/hdr/common/common_enb.h +++ b/srsenb/hdr/common/common_enb.h @@ -29,14 +29,17 @@ namespace srsenb { #define SRSENB_N_RADIO_BEARERS 11 #define SRSENB_MAX_UES 64 -using srsran::lte_rb; +using srsran::lte_drb; +using srsran::lte_srb; +using srsran::srb_to_lcid; inline const char* get_rb_name(uint32_t lcid) { - return srsran::get_rb_name(static_cast(lcid)); + return (srsran::is_lte_srb(lcid)) ? srsran::get_srb_name(srsran::lte_lcid_to_srb(lcid)) + : srsran::get_drb_name(static_cast(lcid - srsran::MAX_LTE_SRB_ID)); } -inline uint32_t rb_to_lcid(lte_rb rb_id) +constexpr uint32_t drb_to_lcid(lte_drb drb_id) { - return static_cast(rb_id); + return srb_to_lcid(lte_srb::srb2) + static_cast(drb_id); } // Cat 3 UE - Max number of DL-SCH transport block bits received within a TTI diff --git a/srsenb/src/stack/rrc/mac_controller.cc b/srsenb/src/stack/rrc/mac_controller.cc index 835d2f731..1a69b3e66 100644 --- a/srsenb/src/stack/rrc/mac_controller.cc +++ b/srsenb/src/stack/rrc/mac_controller.cc @@ -135,7 +135,7 @@ int mac_controller::handle_crnti_ce(uint32_t temp_crnti) set_drb_activation(false); // Re-activate SRBs UL (needed for ReconfComplete) - for (uint32_t i = (uint32_t)lte_rb::srb1; i <= (uint32_t)lte_rb::srb2; ++i) { + for (uint32_t i = srb_to_lcid(lte_srb::srb1); i <= srb_to_lcid(lte_srb::srb2); ++i) { current_sched_ue_cfg.ue_bearers[i] = next_sched_ue_cfg.ue_bearers[i]; } @@ -284,7 +284,7 @@ void mac_controller::handle_intraenb_ho_cmd(const asn1::rrc::rrc_conn_recfg_r8_i set_drb_activation(false); // Stop any SRB UL (including SRs) - for (uint32_t i = (uint32_t)lte_rb::srb1; i <= (uint32_t)lte_rb::srb2; ++i) { + for (uint32_t i = srb_to_lcid(lte_srb::srb1); i <= srb_to_lcid(lte_srb::srb2); ++i) { next_sched_ue_cfg.ue_bearers[i].direction = sched_interface::ue_bearer_cfg_t::DL; } @@ -315,7 +315,7 @@ void mac_controller::set_scell_activation(const std::bitset void mac_controller::set_drb_activation(bool active) { for (const drb_to_add_mod_s& drb : bearer_list.get_established_drbs()) { - current_sched_ue_cfg.ue_bearers[drb.drb_id + (uint32_t)lte_rb::srb2].direction = + current_sched_ue_cfg.ue_bearers[drb_to_lcid((lte_drb)drb.drb_id)].direction = active ? sched_interface::ue_bearer_cfg_t::BOTH : sched_interface::ue_bearer_cfg_t::IDLE; } } diff --git a/srsenb/src/stack/rrc/rrc.cc b/srsenb/src/stack/rrc/rrc.cc index 7d1ddd4cb..6bf98b923 100644 --- a/srsenb/src/stack/rrc/rrc.cc +++ b/srsenb/src/stack/rrc/rrc.cc @@ -245,7 +245,7 @@ void rrc::send_rrc_connection_reject(uint16_t rnti) char buf[32] = {}; sprintf(buf, "SRB0 - rnti=0x%x", rnti); log_rrc_message(buf, Tx, pdu.get(), dl_ccch_msg, dl_ccch_msg.msg.c1().type().to_string()); - rlc->write_sdu(rnti, rb_to_lcid(srsran::lte_rb::srb0), std::move(pdu)); + rlc->write_sdu(rnti, srb_to_lcid(lte_srb::srb0), std::move(pdu)); } /******************************************************************************* @@ -1004,11 +1004,11 @@ void rrc::tti_clock() // handle queue cmd switch (p.lcid) { - case static_cast(lte_rb::srb0): + case srb_to_lcid(lte_srb::srb0): parse_ul_ccch(p.rnti, std::move(p.pdu)); break; - case static_cast(lte_rb::srb1): - case static_cast(lte_rb::srb2): + case srb_to_lcid(lte_srb::srb1): + case srb_to_lcid(lte_srb::srb2): parse_ul_dcch(p.rnti, p.lcid, std::move(p.pdu)); break; case LCID_REM_USER: diff --git a/srsenb/src/stack/rrc/rrc_ue.cc b/srsenb/src/stack/rrc/rrc_ue.cc index 9967a64cb..b828f61d6 100644 --- a/srsenb/src/stack/rrc/rrc_ue.cc +++ b/srsenb/src/stack/rrc/rrc_ue.cc @@ -611,9 +611,9 @@ void rrc::ue::handle_rrc_con_reest_complete(rrc_conn_reest_complete_s* msg, srsr mac_ctrl.handle_con_reest_complete(); // Activate security for SRB1 - parent->pdcp->config_security(rnti, rb_to_lcid(lte_rb::srb1), ue_security_cfg.get_as_sec_cfg()); - parent->pdcp->enable_integrity(rnti, rb_to_lcid(lte_rb::srb1)); - parent->pdcp->enable_encryption(rnti, rb_to_lcid(lte_rb::srb1)); + parent->pdcp->config_security(rnti, srb_to_lcid(lte_srb::srb1), ue_security_cfg.get_as_sec_cfg()); + parent->pdcp->enable_integrity(rnti, srb_to_lcid(lte_srb::srb1)); + parent->pdcp->enable_encryption(rnti, srb_to_lcid(lte_srb::srb1)); // Reestablish current DRBs during ConnectionReconfiguration bearer_list = std::move(parent->users.at(old_reest_rnti)->bearer_list); @@ -789,8 +789,8 @@ void rrc::ue::handle_ue_info_resp(const asn1::rrc::ue_info_resp_r9_s& msg, srsra void rrc::ue::send_security_mode_command() { // Setup SRB1 security/integrity. Encryption is set on completion - parent->pdcp->config_security(rnti, rb_to_lcid(lte_rb::srb1), ue_security_cfg.get_as_sec_cfg()); - parent->pdcp->enable_integrity(rnti, rb_to_lcid(lte_rb::srb1)); + parent->pdcp->config_security(rnti, srb_to_lcid(lte_srb::srb1), ue_security_cfg.get_as_sec_cfg()); + parent->pdcp->enable_integrity(rnti, srb_to_lcid(lte_srb::srb1)); dl_dcch_msg_s dl_dcch_msg; security_mode_cmd_s* comm = &dl_dcch_msg.msg.set_c1().set_security_mode_cmd(); @@ -806,7 +806,7 @@ void rrc::ue::handle_security_mode_complete(security_mode_complete_s* msg) { parent->logger.info("SecurityModeComplete transaction ID: %d", msg->rrc_transaction_id); - parent->pdcp->enable_encryption(rnti, rb_to_lcid(lte_rb::srb1)); + parent->pdcp->enable_encryption(rnti, srb_to_lcid(lte_srb::srb1)); } void rrc::ue::handle_security_mode_failure(security_mode_fail_s* msg) @@ -1200,7 +1200,7 @@ void rrc::ue::send_dl_ccch(dl_ccch_msg_s* dl_ccch_msg, std::string* octet_str) *octet_str = asn1::octstring_to_string(pdu->msg, pdu->N_bytes); } - parent->rlc->write_sdu(rnti, rb_to_lcid(lte_rb::srb0), std::move(pdu)); + parent->rlc->write_sdu(rnti, srb_to_lcid(lte_srb::srb0), std::move(pdu)); } else { parent->logger.error("Allocating pdu"); } @@ -1219,15 +1219,15 @@ bool rrc::ue::send_dl_dcch(const dl_dcch_msg_s* dl_dcch_msg, srsran::unique_byte } pdu->N_bytes = (uint32_t)bref.distance_bytes(); - lte_rb rb = lte_rb::srb1; + lte_srb rb = lte_srb::srb1; if (dl_dcch_msg->msg.c1().type() == dl_dcch_msg_type_c::c1_c_::types_opts::dl_info_transfer) { // send messages with NAS on SRB2 if user is fully registered (after RRC reconfig complete) - rb = (parent->rlc->has_bearer(rnti, rb_to_lcid(lte_rb::srb2)) && state == RRC_STATE_REGISTERED) ? lte_rb::srb2 - : lte_rb::srb1; + rb = (parent->rlc->has_bearer(rnti, srb_to_lcid(lte_srb::srb2)) && state == RRC_STATE_REGISTERED) ? lte_srb::srb2 + : lte_srb::srb1; } char buf[32] = {}; - sprintf(buf, "%s - rnti=0x%x", srsran::get_rb_name(rb), rnti); + sprintf(buf, "%s - rnti=0x%x", srsran::get_srb_name(rb), rnti); parent->log_rrc_message(buf, Tx, pdu.get(), *dl_dcch_msg, dl_dcch_msg->msg.c1().type().to_string()); // Encode the pdu as an octet string if the user passed a valid pointer. @@ -1235,7 +1235,7 @@ bool rrc::ue::send_dl_dcch(const dl_dcch_msg_s* dl_dcch_msg, srsran::unique_byte *octet_str = asn1::octstring_to_string(pdu->msg, pdu->N_bytes); } - parent->pdcp->write_sdu(rnti, rb_to_lcid(rb), std::move(pdu)); + parent->pdcp->write_sdu(rnti, srb_to_lcid(rb), std::move(pdu)); } else { parent->logger.error("Allocating pdu"); return false; diff --git a/srsenb/src/stack/upper/rlc.cc b/srsenb/src/stack/upper/rlc.cc index 2bf7bf51f..8fe04bede 100644 --- a/srsenb/src/stack/upper/rlc.cc +++ b/srsenb/src/stack/upper/rlc.cc @@ -60,7 +60,7 @@ void rlc::add_user(uint16_t rnti) obj->init(&users[rnti], &users[rnti], timers, - rb_to_lcid(srsran::lte_rb::srb0), + srb_to_lcid(lte_srb::srb0), [rnti, this](uint32_t lcid, uint32_t tx_queue, uint32_t retx_queue) { update_bsr(rnti, lcid, tx_queue, retx_queue); }); @@ -262,7 +262,7 @@ void rlc::user_interface::max_retx_attempted() void rlc::user_interface::write_pdu(uint32_t lcid, srsran::unique_byte_buffer_t sdu) { - if (lcid == rb_to_lcid(srsran::lte_rb::srb0)) { + if (lcid == srb_to_lcid(lte_srb::srb0)) { rrc->write_pdu(rnti, lcid, std::move(sdu)); } else { pdcp->write_pdu(rnti, lcid, std::move(sdu)); diff --git a/srsenb/test/mac/sched_lc_ch_test.cc b/srsenb/test/mac/sched_lc_ch_test.cc index 1c359123b..530050e92 100644 --- a/srsenb/test/mac/sched_lc_ch_test.cc +++ b/srsenb/test/mac/sched_lc_ch_test.cc @@ -78,47 +78,47 @@ int test_lc_ch_pbr_infinity() { srsenb::lch_ue_manager lch_handler; - srsenb::sched_interface::ue_cfg_t ue_cfg = generate_default_ue_cfg(); - ue_cfg = generate_setup_ue_cfg(ue_cfg); - ue_cfg.ue_bearers[rb_to_lcid((lte_rb::srb1))] = {}; - ue_cfg.ue_bearers[rb_to_lcid((lte_rb::srb1))].direction = sched_interface::ue_bearer_cfg_t::BOTH; - ue_cfg.ue_bearers[rb_to_lcid((lte_rb::drb1))] = {}; - ue_cfg.ue_bearers[rb_to_lcid((lte_rb::drb1))].direction = sched_interface::ue_bearer_cfg_t::BOTH; - ue_cfg.ue_bearers[rb_to_lcid((lte_rb::drb1))].priority = 5; - ue_cfg.ue_bearers[rb_to_lcid((lte_rb::drb2))] = {}; - ue_cfg.ue_bearers[rb_to_lcid((lte_rb::drb2))].direction = sched_interface::ue_bearer_cfg_t::BOTH; - ue_cfg.ue_bearers[rb_to_lcid((lte_rb::drb2))].priority = 3; + srsenb::sched_interface::ue_cfg_t ue_cfg = generate_default_ue_cfg(); + ue_cfg = generate_setup_ue_cfg(ue_cfg); + ue_cfg.ue_bearers[srb_to_lcid((lte_srb::srb1))] = {}; + ue_cfg.ue_bearers[srb_to_lcid((lte_srb::srb1))].direction = sched_interface::ue_bearer_cfg_t::BOTH; + ue_cfg.ue_bearers[drb_to_lcid((lte_drb::drb1))] = {}; + ue_cfg.ue_bearers[drb_to_lcid((lte_drb::drb1))].direction = sched_interface::ue_bearer_cfg_t::BOTH; + ue_cfg.ue_bearers[drb_to_lcid((lte_drb::drb1))].priority = 5; + ue_cfg.ue_bearers[drb_to_lcid((lte_drb::drb2))] = {}; + ue_cfg.ue_bearers[drb_to_lcid((lte_drb::drb2))].direction = sched_interface::ue_bearer_cfg_t::BOTH; + ue_cfg.ue_bearers[drb_to_lcid((lte_drb::drb2))].priority = 3; lch_handler.set_cfg(ue_cfg); lch_handler.new_tti(); - lch_handler.dl_buffer_state(rb_to_lcid(lte_rb::srb1), 50000, 10000); - lch_handler.dl_buffer_state(rb_to_lcid(lte_rb::drb1), 5000, 10000); - lch_handler.dl_buffer_state(rb_to_lcid(lte_rb::drb2), 5000, 10000); + lch_handler.dl_buffer_state(srb_to_lcid(lte_srb::srb1), 50000, 10000); + lch_handler.dl_buffer_state(drb_to_lcid(lte_drb::drb1), 5000, 10000); + lch_handler.dl_buffer_state(drb_to_lcid(lte_drb::drb2), 5000, 10000); // TEST1 - retx of SRB1 is prioritized. Do not transmit other bearers until there are no SRB1 retxs - int nof_pending_bytes = lch_handler.get_dl_retx(rb_to_lcid(lte_rb::srb1)); - TESTASSERT(test_retx_until_empty(lch_handler, rb_to_lcid(lte_rb::srb1), 500) == nof_pending_bytes); + int nof_pending_bytes = lch_handler.get_dl_retx(srb_to_lcid(lte_srb::srb1)); + TESTASSERT(test_retx_until_empty(lch_handler, srb_to_lcid(lte_srb::srb1), 500) == nof_pending_bytes); // TEST2 - the DRB2 has lower prio level than SRB1, but has retxs - nof_pending_bytes = lch_handler.get_dl_retx(rb_to_lcid(lte_rb::drb2)); - TESTASSERT(test_retx_until_empty(lch_handler, rb_to_lcid(lte_rb::drb2), 500) == nof_pending_bytes); + nof_pending_bytes = lch_handler.get_dl_retx(drb_to_lcid(lte_drb::drb2)); + TESTASSERT(test_retx_until_empty(lch_handler, drb_to_lcid(lte_drb::drb2), 500) == nof_pending_bytes); // TEST3 - the DRB1 has lower prio level, but has retxs - nof_pending_bytes = lch_handler.get_dl_retx(rb_to_lcid(lte_rb::drb1)); - TESTASSERT(test_retx_until_empty(lch_handler, rb_to_lcid(lte_rb::drb1), 500) == nof_pending_bytes); + nof_pending_bytes = lch_handler.get_dl_retx(drb_to_lcid(lte_drb::drb1)); + TESTASSERT(test_retx_until_empty(lch_handler, drb_to_lcid(lte_drb::drb1), 500) == nof_pending_bytes); // TEST4 - The SRB1 newtx buffer is emptied before other bearers newtxs - nof_pending_bytes = lch_handler.get_dl_tx(rb_to_lcid(lte_rb::srb1)); - TESTASSERT(test_newtx_until_empty(lch_handler, rb_to_lcid(lte_rb::srb1), 500) == nof_pending_bytes); + nof_pending_bytes = lch_handler.get_dl_tx(srb_to_lcid(lte_srb::srb1)); + TESTASSERT(test_newtx_until_empty(lch_handler, srb_to_lcid(lte_srb::srb1), 500) == nof_pending_bytes); // TEST5 - The DRB2 newtx buffer is emptied before DRB1 newtxs - nof_pending_bytes = lch_handler.get_dl_tx(rb_to_lcid(lte_rb::drb2)); - TESTASSERT(test_newtx_until_empty(lch_handler, rb_to_lcid(lte_rb::drb2), 500) == nof_pending_bytes); + nof_pending_bytes = lch_handler.get_dl_tx(drb_to_lcid(lte_drb::drb2)); + TESTASSERT(test_newtx_until_empty(lch_handler, drb_to_lcid(lte_drb::drb2), 500) == nof_pending_bytes); // TEST6 - The DRB1 buffer is emptied - nof_pending_bytes = lch_handler.get_dl_tx(rb_to_lcid(lte_rb::drb1)); - TESTASSERT(test_newtx_until_empty(lch_handler, rb_to_lcid(lte_rb::drb1), 500) == nof_pending_bytes); + nof_pending_bytes = lch_handler.get_dl_tx(drb_to_lcid(lte_drb::drb1)); + TESTASSERT(test_newtx_until_empty(lch_handler, drb_to_lcid(lte_drb::drb1), 500) == nof_pending_bytes); return SRSRAN_SUCCESS; } @@ -128,20 +128,20 @@ int test_lc_ch_pbr_finite() srsenb::lch_ue_manager lch_handler; sched_interface::dl_sched_pdu_t pdu; - srsenb::sched_interface::ue_cfg_t ue_cfg = generate_default_ue_cfg(); - ue_cfg = generate_setup_ue_cfg(ue_cfg); - ue_cfg.ue_bearers[rb_to_lcid((lte_rb::srb1))] = {}; - ue_cfg.ue_bearers[rb_to_lcid((lte_rb::srb1))].direction = sched_interface::ue_bearer_cfg_t::BOTH; - ue_cfg.ue_bearers[rb_to_lcid((lte_rb::drb1))] = {}; - ue_cfg.ue_bearers[rb_to_lcid((lte_rb::drb1))].direction = sched_interface::ue_bearer_cfg_t::BOTH; - ue_cfg.ue_bearers[rb_to_lcid((lte_rb::drb1))].pbr = 256; // kBps - ue_cfg.ue_bearers[rb_to_lcid((lte_rb::drb1))].bsd = 50; // msec - ue_cfg.ue_bearers[rb_to_lcid((lte_rb::drb1))].priority = 5; - ue_cfg.ue_bearers[rb_to_lcid((lte_rb::drb2))] = {}; - ue_cfg.ue_bearers[rb_to_lcid((lte_rb::drb2))].direction = sched_interface::ue_bearer_cfg_t::BOTH; - ue_cfg.ue_bearers[rb_to_lcid((lte_rb::drb2))].pbr = 8; // kBps - ue_cfg.ue_bearers[rb_to_lcid((lte_rb::drb2))].bsd = 50; // msec - ue_cfg.ue_bearers[rb_to_lcid((lte_rb::drb2))].priority = 3; + srsenb::sched_interface::ue_cfg_t ue_cfg = generate_default_ue_cfg(); + ue_cfg = generate_setup_ue_cfg(ue_cfg); + ue_cfg.ue_bearers[srb_to_lcid((lte_srb::srb1))] = {}; + ue_cfg.ue_bearers[srb_to_lcid((lte_srb::srb1))].direction = sched_interface::ue_bearer_cfg_t::BOTH; + ue_cfg.ue_bearers[drb_to_lcid((lte_drb::drb1))] = {}; + ue_cfg.ue_bearers[drb_to_lcid((lte_drb::drb1))].direction = sched_interface::ue_bearer_cfg_t::BOTH; + ue_cfg.ue_bearers[drb_to_lcid((lte_drb::drb1))].pbr = 256; // kBps + ue_cfg.ue_bearers[drb_to_lcid((lte_drb::drb1))].bsd = 50; // msec + ue_cfg.ue_bearers[drb_to_lcid((lte_drb::drb1))].priority = 5; + ue_cfg.ue_bearers[drb_to_lcid((lte_drb::drb2))] = {}; + ue_cfg.ue_bearers[drb_to_lcid((lte_drb::drb2))].direction = sched_interface::ue_bearer_cfg_t::BOTH; + ue_cfg.ue_bearers[drb_to_lcid((lte_drb::drb2))].pbr = 8; // kBps + ue_cfg.ue_bearers[drb_to_lcid((lte_drb::drb2))].bsd = 50; // msec + ue_cfg.ue_bearers[drb_to_lcid((lte_drb::drb2))].priority = 3; lch_handler.set_cfg(ue_cfg); for (uint32_t i = 0; i < 50; ++i) { @@ -149,41 +149,41 @@ int test_lc_ch_pbr_finite() } // Bj={0, infinity, 0, 12800, 400} - lch_handler.dl_buffer_state(rb_to_lcid(lte_rb::srb1), 50000, 1000); - lch_handler.dl_buffer_state(rb_to_lcid(lte_rb::drb1), 50000, 1000); - lch_handler.dl_buffer_state(rb_to_lcid(lte_rb::drb2), 50000, 0); + lch_handler.dl_buffer_state(srb_to_lcid(lte_srb::srb1), 50000, 1000); + lch_handler.dl_buffer_state(drb_to_lcid(lte_drb::drb1), 50000, 1000); + lch_handler.dl_buffer_state(drb_to_lcid(lte_drb::drb2), 50000, 0); // TEST1 - SRB1 retxs are emptied first - int nof_pending_bytes = lch_handler.get_dl_retx(rb_to_lcid(lte_rb::srb1)); - TESTASSERT(test_retx_until_empty(lch_handler, rb_to_lcid(lte_rb::srb1), 500) == nof_pending_bytes); + int nof_pending_bytes = lch_handler.get_dl_retx(srb_to_lcid(lte_srb::srb1)); + TESTASSERT(test_retx_until_empty(lch_handler, srb_to_lcid(lte_srb::srb1), 500) == nof_pending_bytes); // TEST2 - DRB1 retxs are emptied - nof_pending_bytes = lch_handler.get_dl_retx(rb_to_lcid(lte_rb::drb1)); - TESTASSERT(test_retx_until_empty(lch_handler, rb_to_lcid(lte_rb::drb1), 500) == nof_pending_bytes); + nof_pending_bytes = lch_handler.get_dl_retx(drb_to_lcid(lte_drb::drb1)); + TESTASSERT(test_retx_until_empty(lch_handler, drb_to_lcid(lte_drb::drb1), 500) == nof_pending_bytes); // TEST3 - SRB1 newtxs are emptied (PBR==infinity) - nof_pending_bytes = lch_handler.get_dl_tx(rb_to_lcid(lte_rb::srb1)); - TESTASSERT(test_newtx_until_empty(lch_handler, rb_to_lcid(lte_rb::srb1), 500) == nof_pending_bytes); + nof_pending_bytes = lch_handler.get_dl_tx(srb_to_lcid(lte_srb::srb1)); + TESTASSERT(test_newtx_until_empty(lch_handler, srb_to_lcid(lte_srb::srb1), 500) == nof_pending_bytes); // TEST4 - DRB2 has higher priority so it gets allocated until Bj <= 0 - TESTASSERT(test_pdu_alloc_successful(lch_handler, pdu, rb_to_lcid(lte_rb::drb2), 200) == SRSRAN_SUCCESS); + TESTASSERT(test_pdu_alloc_successful(lch_handler, pdu, drb_to_lcid(lte_drb::drb2), 200) == SRSRAN_SUCCESS); // Bj={0, infinity, 0, 12800, 200} - TESTASSERT(test_pdu_alloc_successful(lch_handler, pdu, rb_to_lcid(lte_rb::drb2), 600) == SRSRAN_SUCCESS); + TESTASSERT(test_pdu_alloc_successful(lch_handler, pdu, drb_to_lcid(lte_drb::drb2), 600) == SRSRAN_SUCCESS); // Bj={0, infinity, 0, 256000, -400} // TEST5 - DRB1 has lower prio, but DRB2 Bj <= 0. for (uint32_t i = 0; i < 50; ++i) { lch_handler.new_tti(); - TESTASSERT(test_pdu_alloc_successful(lch_handler, pdu, rb_to_lcid(lte_rb::drb1), 50) == SRSRAN_SUCCESS); + TESTASSERT(test_pdu_alloc_successful(lch_handler, pdu, drb_to_lcid(lte_drb::drb1), 50) == SRSRAN_SUCCESS); } // TEST6 - new tti restores DRB2 Bj>=0, and DRB2 gets allocated lch_handler.new_tti(); // Bj={0, infinity, 0, 256000, 8} - TESTASSERT(test_pdu_alloc_successful(lch_handler, pdu, rb_to_lcid(lte_rb::drb2), 50) == SRSRAN_SUCCESS); + TESTASSERT(test_pdu_alloc_successful(lch_handler, pdu, drb_to_lcid(lte_drb::drb2), 50) == SRSRAN_SUCCESS); // Bj={0, infinity, 0, 256000, -42} lch_handler.new_tti(); - TESTASSERT(test_pdu_alloc_successful(lch_handler, pdu, rb_to_lcid(lte_rb::drb1), 50) == SRSRAN_SUCCESS); + TESTASSERT(test_pdu_alloc_successful(lch_handler, pdu, drb_to_lcid(lte_drb::drb1), 50) == SRSRAN_SUCCESS); return SRSRAN_SUCCESS; } diff --git a/srsenb/test/mac/sched_sim_ue.cc b/srsenb/test/mac/sched_sim_ue.cc index 65f0cb646..f359961b3 100644 --- a/srsenb/test/mac/sched_sim_ue.cc +++ b/srsenb/test/mac/sched_sim_ue.cc @@ -396,7 +396,7 @@ int sched_sim_base::apply_tti_events(sim_ue_ctxt_t& ue_ctxt, const ue_tti_events sched_interface::ue_cfg_t ue_cfg = generate_setup_ue_cfg(final_ue_cfg[ue_ctxt.rnti]); TESTASSERT(ue_recfg(ue_ctxt.rnti, ue_cfg) == SRSRAN_SUCCESS); - uint32_t lcid = rb_to_lcid(lte_rb::srb0); // Use SRB0 to schedule Msg4 + uint32_t lcid = srb_to_lcid(lte_srb::srb0); // Use SRB0 to schedule Msg4 TESTASSERT(sched_ptr->dl_rlc_buffer_state(ue_ctxt.rnti, lcid, 50, 0) == SRSRAN_SUCCESS); TESTASSERT(sched_ptr->dl_mac_buffer_state(ue_ctxt.rnti, (uint32_t)srsran::dl_sch_lcid::CON_RES_ID, 1) == SRSRAN_SUCCESS); diff --git a/srsenb/test/mac/sched_test_common.cc b/srsenb/test/mac/sched_test_common.cc index 45a3b332d..dbe1290d9 100644 --- a/srsenb/test/mac/sched_test_common.cc +++ b/srsenb/test/mac/sched_test_common.cc @@ -230,7 +230,7 @@ int common_sched_tester::process_tti_events(const tti_ev& tti_ev) const auto& ue_sim_ctxt = user->get_ctxt(); if (ue_ev.buffer_ev->dl_data > 0 and ue_sim_ctxt.conres_rx) { // If Msg4 has already been tx and there DL data to transmit - uint32_t lcid = rb_to_lcid(lte_rb::drb1); + uint32_t lcid = drb_to_lcid(lte_drb::drb1); uint32_t pending_dl_new_data = ue_db[ue_ev.rnti]->get_pending_dl_rlc_data(); // DRB is set. Update DL buffer uint32_t tot_dl_data = pending_dl_new_data + ue_ev.buffer_ev->dl_data; // TODO: derive pending based on rx diff --git a/srsenb/test/mac/sched_test_utils.h b/srsenb/test/mac/sched_test_utils.h index f272857fd..f1efd695c 100644 --- a/srsenb/test/mac/sched_test_utils.h +++ b/srsenb/test/mac/sched_test_utils.h @@ -65,15 +65,15 @@ inline srsenb::sched_interface::ue_cfg_t generate_default_ue_cfg() ue_cfg.maxharq_tx = 5; ue_cfg.supported_cc_list.resize(1); - ue_cfg.supported_cc_list[0].aperiodic_cqi_period = 40; - ue_cfg.supported_cc_list[0].enb_cc_idx = 0; - ue_cfg.supported_cc_list[0].active = true; - ue_cfg.supported_cc_list[0].dl_cfg.tm = SRSRAN_TM1; - ue_cfg.ue_bearers[rb_to_lcid(lte_rb::srb0)].direction = srsenb::sched_interface::ue_bearer_cfg_t::BOTH; - ue_cfg.ue_bearers[rb_to_lcid(lte_rb::srb1)].direction = srsenb::sched_interface::ue_bearer_cfg_t::BOTH; - ue_cfg.ue_bearers[rb_to_lcid(lte_rb::srb2)].direction = srsenb::sched_interface::ue_bearer_cfg_t::BOTH; - ue_cfg.ue_bearers[rb_to_lcid(lte_rb::drb1)].direction = srsenb::sched_interface::ue_bearer_cfg_t::BOTH; - ue_cfg.ue_bearers[rb_to_lcid(lte_rb::drb1)].group = 1; + ue_cfg.supported_cc_list[0].aperiodic_cqi_period = 40; + ue_cfg.supported_cc_list[0].enb_cc_idx = 0; + ue_cfg.supported_cc_list[0].active = true; + ue_cfg.supported_cc_list[0].dl_cfg.tm = SRSRAN_TM1; + ue_cfg.ue_bearers[srb_to_lcid(lte_srb::srb0)].direction = srsenb::sched_interface::ue_bearer_cfg_t::BOTH; + ue_cfg.ue_bearers[srb_to_lcid(lte_srb::srb1)].direction = srsenb::sched_interface::ue_bearer_cfg_t::BOTH; + ue_cfg.ue_bearers[srb_to_lcid(lte_srb::srb2)].direction = srsenb::sched_interface::ue_bearer_cfg_t::BOTH; + ue_cfg.ue_bearers[drb_to_lcid(lte_drb::drb1)].direction = srsenb::sched_interface::ue_bearer_cfg_t::BOTH; + ue_cfg.ue_bearers[drb_to_lcid(lte_drb::drb1)].group = 1; ue_cfg.pucch_cfg.sr_configured = true; ue_cfg.pucch_cfg.I_sr = 15; // periodicity of 20 msec @@ -86,18 +86,18 @@ inline srsenb::sched_interface::ue_cfg_t generate_default_ue_cfg2() { srsenb::sched_interface::ue_cfg_t ue_cfg = generate_default_ue_cfg(); - ue_cfg.ue_bearers[rb_to_lcid(lte_rb::srb1)].direction = srsenb::sched_interface::ue_bearer_cfg_t::BOTH; - ue_cfg.ue_bearers[rb_to_lcid(lte_rb::srb2)].direction = srsenb::sched_interface::ue_bearer_cfg_t::BOTH; - ue_cfg.ue_bearers[rb_to_lcid(lte_rb::drb1)].direction = srsenb::sched_interface::ue_bearer_cfg_t::BOTH; - ue_cfg.ue_bearers[rb_to_lcid(lte_rb::drb1)].group = 1; + ue_cfg.ue_bearers[srb_to_lcid(lte_srb::srb1)].direction = srsenb::sched_interface::ue_bearer_cfg_t::BOTH; + ue_cfg.ue_bearers[srb_to_lcid(lte_srb::srb2)].direction = srsenb::sched_interface::ue_bearer_cfg_t::BOTH; + ue_cfg.ue_bearers[drb_to_lcid(lte_drb::drb1)].direction = srsenb::sched_interface::ue_bearer_cfg_t::BOTH; + ue_cfg.ue_bearers[drb_to_lcid(lte_drb::drb1)].group = 1; return ue_cfg; } inline srsenb::sched_interface::ue_cfg_t generate_rach_ue_cfg(const srsenb::sched_interface::ue_cfg_t& final_cfg) { - srsenb::sched_interface::ue_cfg_t cfg = {}; - cfg.ue_bearers[rb_to_lcid(lte_rb::srb0)].direction = srsenb::sched_interface::ue_bearer_cfg_t::BOTH; + srsenb::sched_interface::ue_cfg_t cfg = {}; + cfg.ue_bearers[srb_to_lcid(lte_srb::srb0)].direction = srsenb::sched_interface::ue_bearer_cfg_t::BOTH; cfg.supported_cc_list.resize(1); cfg.supported_cc_list[0].enb_cc_idx = final_cfg.supported_cc_list[0].enb_cc_idx; cfg.supported_cc_list[0].active = true; @@ -108,10 +108,10 @@ inline srsenb::sched_interface::ue_cfg_t generate_setup_ue_cfg(const srsenb::sch { srsenb::sched_interface::ue_cfg_t cfg = generate_rach_ue_cfg(final_cfg); - cfg.maxharq_tx = final_cfg.maxharq_tx; - cfg.ue_bearers[rb_to_lcid(lte_rb::srb1)].direction = srsenb::sched_interface::ue_bearer_cfg_t::BOTH; - cfg.supported_cc_list[0].dl_cfg.tm = SRSRAN_TM1; - cfg.continuous_pusch = final_cfg.continuous_pusch; + cfg.maxharq_tx = final_cfg.maxharq_tx; + cfg.ue_bearers[srb_to_lcid(lte_srb::srb1)].direction = srsenb::sched_interface::ue_bearer_cfg_t::BOTH; + cfg.supported_cc_list[0].dl_cfg.tm = SRSRAN_TM1; + cfg.continuous_pusch = final_cfg.continuous_pusch; cfg.supported_cc_list[0].dl_cfg.cqi_report = final_cfg.supported_cc_list[0].dl_cfg.cqi_report; cfg.pucch_cfg = final_cfg.pucch_cfg; @@ -122,8 +122,8 @@ inline srsenb::sched_interface::ue_cfg_t generate_setup_ue_cfg(const srsenb::sch inline srsenb::sched_interface::ue_cfg_t generate_reconf_ue_cfg(const srsenb::sched_interface::ue_cfg_t& final_cfg) { - srsenb::sched_interface::ue_cfg_t cfg = generate_setup_ue_cfg(final_cfg); - cfg.ue_bearers[rb_to_lcid(lte_rb::srb2)] = final_cfg.ue_bearers[rb_to_lcid(lte_rb::srb1)]; + srsenb::sched_interface::ue_cfg_t cfg = generate_setup_ue_cfg(final_cfg); + cfg.ue_bearers[srb_to_lcid(lte_srb::srb2)] = final_cfg.ue_bearers[srb_to_lcid(lte_srb::srb1)]; return cfg; } @@ -257,11 +257,11 @@ struct sched_sim_event_generator { ue_sim_cfg.ue_cfg = generate_default_ue_cfg(); user->ue_sim_cfg.reset(new ue_ctxt_test_cfg{ue_sim_cfg}); // it should by now have a DRB1. Add other DRBs manually - user->ue_sim_cfg->ue_cfg.ue_bearers[rb_to_lcid(lte_rb::srb2)].direction = + user->ue_sim_cfg->ue_cfg.ue_bearers[srb_to_lcid(lte_srb::srb2)].direction = srsenb::sched_interface::ue_bearer_cfg_t::BOTH; - user->ue_sim_cfg->ue_cfg.ue_bearers[rb_to_lcid(lte_rb::drb1)].direction = + user->ue_sim_cfg->ue_cfg.ue_bearers[drb_to_lcid(lte_drb::drb1)].direction = srsenb::sched_interface::ue_bearer_cfg_t::BOTH; - user->ue_sim_cfg->ue_cfg.ue_bearers[rb_to_lcid(lte_rb::drb1)].group = 1; + user->ue_sim_cfg->ue_cfg.ue_bearers[drb_to_lcid(lte_drb::drb1)].group = 1; return user; } diff --git a/srsenb/test/upper/rrc_mobility_test.cc b/srsenb/test/upper/rrc_mobility_test.cc index efd43dca2..0c5aeaca2 100644 --- a/srsenb/test/upper/rrc_mobility_test.cc +++ b/srsenb/test/upper/rrc_mobility_test.cc @@ -296,22 +296,22 @@ int test_s1ap_tenb_mobility(mobility_test_params test_params) auto& mac_ue = tester.mac.ue_db[0x46]; TESTASSERT(mac_ue.supported_cc_list[0].active); TESTASSERT(mac_ue.supported_cc_list[0].enb_cc_idx == 0); - TESTASSERT(mac_ue.ue_bearers[rb_to_lcid(lte_rb::srb0)].direction == sched_interface::ue_bearer_cfg_t::BOTH); + TESTASSERT(mac_ue.ue_bearers[srb_to_lcid(lte_srb::srb0)].direction == sched_interface::ue_bearer_cfg_t::BOTH); // Check Security Configuration TESTASSERT(tester.pdcp.bearers.count(0x46)); - TESTASSERT(tester.pdcp.bearers[0x46].count(rb_to_lcid(lte_rb::srb1)) and - tester.pdcp.bearers[0x46].count(rb_to_lcid(lte_rb::srb2))); - TESTASSERT(tester.pdcp.bearers[0x46][rb_to_lcid(lte_rb::srb1)].enable_encryption); - TESTASSERT(tester.pdcp.bearers[0x46][rb_to_lcid(lte_rb::srb1)].enable_integrity); + TESTASSERT(tester.pdcp.bearers[0x46].count(srb_to_lcid(lte_srb::srb1)) and + tester.pdcp.bearers[0x46].count(srb_to_lcid(lte_srb::srb2))); + TESTASSERT(tester.pdcp.bearers[0x46][srb_to_lcid(lte_srb::srb1)].enable_encryption); + TESTASSERT(tester.pdcp.bearers[0x46][srb_to_lcid(lte_srb::srb1)].enable_integrity); sec_cfg.set_security_capabilities(ho_req.protocol_ies.ue_security_cap.value); sec_cfg.set_security_key(ho_req.protocol_ies.security_context.value.next_hop_param); sec_cfg.regenerate_keys_handover(tester.cfg.cell_list[0].pci, tester.cfg.cell_list[0].dl_earfcn); srsran::as_security_config_t as_sec_cfg = sec_cfg.get_as_sec_cfg(); - TESTASSERT(tester.pdcp.bearers[0x46][rb_to_lcid(lte_rb::srb1)].sec_cfg.k_rrc_int == as_sec_cfg.k_rrc_int); - TESTASSERT(tester.pdcp.bearers[0x46][rb_to_lcid(lte_rb::srb1)].sec_cfg.k_rrc_enc == as_sec_cfg.k_rrc_enc); - TESTASSERT(tester.pdcp.bearers[0x46][rb_to_lcid(lte_rb::srb1)].sec_cfg.k_up_int == as_sec_cfg.k_up_int); - TESTASSERT(tester.pdcp.bearers[0x46][rb_to_lcid(lte_rb::srb1)].sec_cfg.cipher_algo == as_sec_cfg.cipher_algo); - TESTASSERT(tester.pdcp.bearers[0x46][rb_to_lcid(lte_rb::srb1)].sec_cfg.integ_algo == as_sec_cfg.integ_algo); + TESTASSERT(tester.pdcp.bearers[0x46][srb_to_lcid(lte_srb::srb1)].sec_cfg.k_rrc_int == as_sec_cfg.k_rrc_int); + TESTASSERT(tester.pdcp.bearers[0x46][srb_to_lcid(lte_srb::srb1)].sec_cfg.k_rrc_enc == as_sec_cfg.k_rrc_enc); + TESTASSERT(tester.pdcp.bearers[0x46][srb_to_lcid(lte_srb::srb1)].sec_cfg.k_up_int == as_sec_cfg.k_up_int); + TESTASSERT(tester.pdcp.bearers[0x46][srb_to_lcid(lte_srb::srb1)].sec_cfg.cipher_algo == as_sec_cfg.cipher_algo); + TESTASSERT(tester.pdcp.bearers[0x46][srb_to_lcid(lte_srb::srb1)].sec_cfg.integ_algo == as_sec_cfg.integ_algo); // Check if S1AP Handover Request ACK send is called TESTASSERT(tester.s1ap.last_ho_req_ack.rnti == 0x46); @@ -355,11 +355,11 @@ int test_s1ap_tenb_mobility(mobility_test_params test_params) uint8_t recfg_complete[] = {0x10, 0x00}; test_helpers::copy_msg_to_buffer(pdu, recfg_complete); - tester.rrc.write_pdu(0x46, rb_to_lcid(lte_rb::srb1), std::move(pdu)); + tester.rrc.write_pdu(0x46, srb_to_lcid(lte_srb::srb1), std::move(pdu)); tester.tic(); - TESTASSERT(mac_ue.ue_bearers[rb_to_lcid(lte_rb::srb1)].direction == sched_interface::ue_bearer_cfg_t::BOTH); - TESTASSERT(mac_ue.ue_bearers[rb_to_lcid(lte_rb::srb2)].direction == sched_interface::ue_bearer_cfg_t::BOTH); - TESTASSERT(mac_ue.ue_bearers[rb_to_lcid(lte_rb::drb1)].direction == sched_interface::ue_bearer_cfg_t::BOTH); + TESTASSERT(mac_ue.ue_bearers[srb_to_lcid(lte_srb::srb1)].direction == sched_interface::ue_bearer_cfg_t::BOTH); + TESTASSERT(mac_ue.ue_bearers[srb_to_lcid(lte_srb::srb2)].direction == sched_interface::ue_bearer_cfg_t::BOTH); + TESTASSERT(mac_ue.ue_bearers[drb_to_lcid(lte_drb::drb1)].direction == sched_interface::ue_bearer_cfg_t::BOTH); TESTASSERT(mac_ue.pucch_cfg.I_sr == recfg_r8.rr_cfg_ded.phys_cfg_ded.sched_request_cfg.setup().sr_cfg_idx); TESTASSERT(mac_ue.pucch_cfg.n_pucch_sr == recfg_r8.rr_cfg_ded.phys_cfg_ded.sched_request_cfg.setup().sr_pucch_res_idx); @@ -468,7 +468,7 @@ int test_intraenb_mobility(srsran::log_sink_spy& spy, mobility_test_params test_ /* Test Case: Terminate first Handover. No extra messages should be sent DL. SR/CQI resources match recfg message */ uint8_t recfg_complete[] = {0x10, 0x00}; test_helpers::copy_msg_to_buffer(pdu, recfg_complete); - tester.rrc.write_pdu(tester.rnti, rb_to_lcid(lte_rb::srb2), std::move(pdu)); + tester.rrc.write_pdu(tester.rnti, srb_to_lcid(lte_srb::srb2), std::move(pdu)); TESTASSERT(tester.pdcp.last_sdu.sdu == nullptr); sched_interface::ue_cfg_t& ue_cfg = tester.mac.ue_db[tester.rnti]; TESTASSERT(ue_cfg.pucch_cfg.sr_configured); diff --git a/srsue/hdr/stack/rrc/rrc.h b/srsue/hdr/stack/rrc/rrc.h index 4f07a59fc..06ae6302b 100644 --- a/srsue/hdr/stack/rrc/rrc.h +++ b/srsue/hdr/stack/rrc/rrc.h @@ -217,14 +217,7 @@ private: static const std::string rb_id_str[]; - const char* get_rb_name(uint32_t lcid) - { - if (lcid < (uint32_t)srsran::lte_rb::count) { - return rb_id_str[lcid].c_str(); - } else { - return "INVALID_RB"; - } - } + const char* get_rb_name(uint32_t lcid) { return srsran::is_lte_rb(lcid) ? rb_id_str[lcid].c_str() : "invalid RB"; } // Measurements private subclass class rrc_meas; diff --git a/srsue/src/stack/rrc/rrc.cc b/srsue/src/stack/rrc/rrc.cc index 66ae37395..cdf6cf9d6 100644 --- a/srsue/src/stack/rrc/rrc.cc +++ b/srsue/src/stack/rrc/rrc.cc @@ -36,6 +36,8 @@ bool simulate_rlf = false; using namespace srsran; using namespace asn1::rrc; +using srsran::lte_srb; +using srsran::srb_to_lcid; namespace srsue { @@ -940,7 +942,7 @@ void rrc::send_con_restablish_complete() ul_dcch_msg.msg.set_c1().set_rrc_conn_reest_complete().crit_exts.set_rrc_conn_reest_complete_r8(); ul_dcch_msg.msg.c1().rrc_conn_reest_complete().rrc_transaction_id = transaction_id; - send_ul_dcch_msg((uint32_t)srsran::lte_rb::srb1, ul_dcch_msg); + send_ul_dcch_msg(srb_to_lcid(lte_srb::srb1), ul_dcch_msg); reestablishment_successful = true; } @@ -960,13 +962,12 @@ void rrc::send_con_setup_complete(srsran::unique_byte_buffer_t nas_msg) rrc_conn_setup_complete->ded_info_nas.resize(nas_msg->N_bytes); memcpy(rrc_conn_setup_complete->ded_info_nas.data(), nas_msg->msg, nas_msg->N_bytes); // TODO Check! - send_ul_dcch_msg((uint32_t)srsran::lte_rb::srb1, ul_dcch_msg); + send_ul_dcch_msg(srb_to_lcid(lte_srb::srb1), ul_dcch_msg); } void rrc::send_ul_info_transfer(unique_byte_buffer_t nas_msg) { - uint32_t lcid = - (uint32_t)(rlc->has_bearer((uint32_t)srsran::lte_rb::srb2) ? srsran::lte_rb::srb2 : srsran::lte_rb::srb1); + uint32_t lcid = (uint32_t)(rlc->has_bearer(srb_to_lcid(lte_srb::srb2)) ? lte_srb::srb2 : lte_srb::srb1); // Prepare UL INFO packet asn1::rrc::ul_dcch_msg_s ul_dcch_msg; @@ -989,7 +990,7 @@ void rrc::send_security_mode_complete() ul_dcch_msg.msg.set_c1().set_security_mode_complete().crit_exts.set_security_mode_complete_r8(); ul_dcch_msg.msg.c1().security_mode_complete().rrc_transaction_id = transaction_id; - send_ul_dcch_msg((uint32_t)srsran::lte_rb::srb1, ul_dcch_msg); + send_ul_dcch_msg(srb_to_lcid(lte_srb::srb1), ul_dcch_msg); } void rrc::send_rrc_con_reconfig_complete(bool contains_nr_complete) @@ -1017,7 +1018,7 @@ void rrc::send_rrc_con_reconfig_complete(bool contains_nr_complete) rrc_conn_recfg_complete_v1430_ies->non_crit_ext.scg_cfg_resp_nr_r15_present = true; rrc_conn_recfg_complete_v1430_ies->non_crit_ext.scg_cfg_resp_nr_r15.from_string("00"); } - send_ul_dcch_msg((uint32_t)srsran::lte_rb::srb1, ul_dcch_msg); + send_ul_dcch_msg(srb_to_lcid(lte_srb::srb1), ul_dcch_msg); } void rrc::ra_completed() @@ -1169,12 +1170,12 @@ void rrc::start_con_restablishment(reest_cause_e cause) bool rrc::srbs_flushed() { // Check SRB1 - if (rlc->has_data((uint32_t)srsran::lte_rb::srb1) && not rlc->is_suspended((uint32_t)srsran::lte_rb::srb1)) { + if (rlc->has_data(srb_to_lcid(lte_srb::srb1)) && not rlc->is_suspended(srb_to_lcid(lte_srb::srb1))) { return false; } // Check SRB2 - if (rlc->has_data((uint32_t)srsran::lte_rb::srb2) && not rlc->is_suspended((uint32_t)srsran::lte_rb::srb2)) { + if (rlc->has_data(srb_to_lcid(lte_srb::srb2)) && not rlc->is_suspended(srb_to_lcid(lte_srb::srb2))) { return false; } @@ -1188,7 +1189,7 @@ bool rrc::srbs_flushed() *******************************************************************************/ void rrc::send_srb1_msg(const ul_dcch_msg_s& msg) { - send_ul_dcch_msg((uint32_t)srsran::lte_rb::srb1, msg); + send_ul_dcch_msg(srb_to_lcid(lte_srb::srb1), msg); } std::set rrc::get_cells(const uint32_t earfcn) @@ -1562,7 +1563,7 @@ void rrc::send_ul_ccch_msg(const ul_ccch_msg_s& msg) logger.debug("Setting UE contention resolution ID: %" PRIu64 "", uecri); mac->set_contention_id(uecri); - uint32_t lcid = (uint32_t)srsran::lte_rb::srb0; + uint32_t lcid = srb_to_lcid(lte_srb::srb0); log_rrc_message(get_rb_name(lcid), Tx, pdcp_buf.get(), msg, msg.msg.c1().type().to_string()); rlc->write_sdu(lcid, std::move(pdcp_buf)); @@ -1613,12 +1614,12 @@ void rrc::write_pdu(uint32_t lcid, unique_byte_buffer_t pdu) void rrc::process_pdu(uint32_t lcid, srsran::unique_byte_buffer_t pdu) { logger.debug("RX PDU, LCID: %d", lcid); - switch (static_cast(lcid)) { - case srsran::lte_rb::srb0: + switch (static_cast(lcid)) { + case lte_srb::srb0: parse_dl_ccch(std::move(pdu)); break; - case srsran::lte_rb::srb1: - case srsran::lte_rb::srb2: + case lte_srb::srb1: + case lte_srb::srb2: parse_dl_dcch(lcid, std::move(pdu)); break; default: @@ -1637,7 +1638,7 @@ void rrc::parse_dl_ccch(unique_byte_buffer_t pdu) return; } log_rrc_message( - srsran::get_rb_name(srsran::lte_rb::srb0), Rx, pdu.get(), dl_ccch_msg, dl_ccch_msg.msg.c1().type().to_string()); + get_rb_name(srb_to_lcid(lte_srb::srb0)), Rx, pdu.get(), dl_ccch_msg, dl_ccch_msg.msg.c1().type().to_string()); dl_ccch_msg_type_c::c1_c_* c1 = &dl_ccch_msg.msg.c1(); switch (dl_ccch_msg.msg.c1().type().value) { @@ -2114,7 +2115,7 @@ void rrc::handle_ue_capability_enquiry(const ue_cap_enquiry_s& enquiry) } } - send_ul_dcch_msg((uint32_t)srsran::lte_rb::srb1, ul_dcch_msg); + send_ul_dcch_msg(srb_to_lcid(lte_srb::srb1), ul_dcch_msg); } /******************************************************************************* @@ -2551,7 +2552,7 @@ void rrc::add_srb(const srb_to_add_mod_s& srb_cnfg) { // Setup PDCP pdcp->add_bearer(srb_cnfg.srb_id, make_srb_pdcp_config_t(srb_cnfg.srb_id, true)); - if (static_cast(srsran::lte_rb::srb2) == srb_cnfg.srb_id) { + if (lte_srb::srb2 == static_cast(srb_cnfg.srb_id)) { pdcp->config_security(srb_cnfg.srb_id, sec_cfg); pdcp->enable_integrity(srb_cnfg.srb_id, DIRECTION_TXRX); pdcp->enable_encryption(srb_cnfg.srb_id, DIRECTION_TXRX); @@ -2572,16 +2573,16 @@ void rrc::add_srb(const srb_to_add_mod_s& srb_cnfg) if (srb_cnfg.lc_ch_cfg_present) { if (srb_cnfg.lc_ch_cfg.type() == srb_to_add_mod_s::lc_ch_cfg_c_::types::default_value) { // Set default SRB values as defined in Table 9.2.1 - switch (static_cast(srb_cnfg.srb_id)) { - case srsran::lte_rb::srb0: + switch (static_cast(srb_cnfg.srb_id)) { + case lte_srb::srb0: logger.error("Setting SRB0: Should not be set by RRC"); break; - case srsran::lte_rb::srb1: + case lte_srb::srb1: priority = 1; prioritized_bit_rate = -1; bucket_size_duration = 0; break; - case srsran::lte_rb::srb2: + case lte_srb::srb2: priority = 3; prioritized_bit_rate = -1; bucket_size_duration = 0; @@ -2784,7 +2785,7 @@ void rrc::nr_scg_failure_information(const scg_failure_cause_t cause) scg_fail_info_nr.crit_exts.c1().scg_fail_info_nr_r15().fail_report_scg_nr_r15_present = true; scg_fail_info_nr.crit_exts.c1().scg_fail_info_nr_r15().fail_report_scg_nr_r15.fail_type_r15 = (fail_report_scg_nr_r15_s::fail_type_r15_opts::options)cause; - send_ul_dcch_msg((uint32_t)srsran::lte_rb::srb1, ul_dcch_msg); + send_ul_dcch_msg(srb_to_lcid(lte_srb::srb1), ul_dcch_msg); } } // namespace srsue diff --git a/srsue/src/stack/rrc/rrc_procedures.cc b/srsue/src/stack/rrc/rrc_procedures.cc index f842018d1..870246320 100644 --- a/srsue/src/stack/rrc/rrc_procedures.cc +++ b/srsue/src/stack/rrc/rrc_procedures.cc @@ -1037,7 +1037,7 @@ srsran::proc_outcome_t rrc::connection_reconf_no_ho_proc::react(const bool& conf if (nas_pdu != nullptr) { memcpy(nas_pdu->msg, pdu.data(), pdu.size()); nas_pdu->N_bytes = pdu.size(); - rrc_ptr->nas->write_pdu((uint32_t)srsran::lte_rb::srb1, std::move(nas_pdu)); + rrc_ptr->nas->write_pdu(srsran::srb_to_lcid(srsran::lte_srb::srb1), std::move(nas_pdu)); } else { rrc_ptr->logger.error("Couldn't allocate PDU in %s.", __FUNCTION__); return proc_outcome_t::error;