diff --git a/lib/include/srsran/interfaces/nr_common_interface_types.h b/lib/include/srsran/interfaces/nr_common_interface_types.h index 1e90fe9a1..7ebbf5d96 100644 --- a/lib/include/srsran/interfaces/nr_common_interface_types.h +++ b/lib/include/srsran/interfaces/nr_common_interface_types.h @@ -16,11 +16,80 @@ namespace srsran { // NR Radio Bearer Id +// maxDRB = 29 +enum rb_id_nr_t { + NR_SRB0, + NR_SRB1, + NR_SRB2, + NR_SRB3, + NR_DRB1, + NR_DRB2, + NR_DRB3, + NR_DRB4, + NR_DRB5, + NR_DRB6, + NR_DRB7, + NR_DRB8, + NR_DRB9, + NR_DRB10, + NR_DRB11, + NR_DRB12, + NR_DRB13, + NR_DRB14, + NR_DRB15, + NR_DRB16, + NR_DRB17, + NR_DRB18, + NR_DRB19, + NR_DRB20, + NR_DRB21, + NR_DRB22, + NR_DRB23, + NR_DRB24, + NR_DRB25, + NR_DRB26, + NR_DRB27, + NR_DRB28, + NR_DRB29, + RB_ID_NR_N_ITEMS +}; -enum rb_id_nr_t { NR_SRB0, NR_SRB1, NR_SRB2, NR_SRB3, NR_DRB1, RB_ID_NR_N_ITEMS }; inline const char* to_string(rb_id_nr_t rb_id) { - const static char* names[] = {"SRB0", "SRB1", "SRB2", "SRB3", "DRB1"}; + const static char* names[] = { + "SRB0", + "SRB1", + "SRB2", + "SRB3", + "DRB1", + "DRB2", + "DRB3", + "DRB4", + "DRB5", + "DRB6", + "DRB7", + "DRB8", + "DRB9", + "DRB10", + "DRB11", + "DRB13", + "DRB14", + "DRB15", + "DRB16", + "DRB17", + "DRB18", + "DRB19", + "DRB20", + "DRB21", + "DRB22", + "DRB23", + "DRB24", + "DRB25", + "DRB26", + "DRB27", + "DRB28", + "DRB29", + }; return (rb_id < rb_id_nr_t::RB_ID_NR_N_ITEMS) ? names[rb_id] : "invalid bearer id"; } inline bool is_srb(rb_id_nr_t lcid) diff --git a/lib/include/srsran/upper/rlc.h b/lib/include/srsran/upper/rlc.h index 533cd7a11..75fff9a98 100644 --- a/lib/include/srsran/upper/rlc.h +++ b/lib/include/srsran/upper/rlc.h @@ -39,6 +39,13 @@ public: srsue::rrc_interface_rlc* rrc_, srsran::timer_handler* timers_, uint32_t lcid_); + + void init(srsue::pdcp_interface_rlc* pdcp_, + srsue::rrc_interface_rlc* rrc_, + srsue::rrc_interface_rlc* rrc_nr_, + srsran::timer_handler* timers_, + uint32_t lcid_); + void init(srsue::pdcp_interface_rlc* pdcp_, srsue::rrc_interface_rlc* rrc_, srsran::timer_handler* timers_, @@ -87,10 +94,11 @@ public: private: void reset_metrics(); - byte_buffer_pool* pool = nullptr; srslog::basic_logger& logger; + byte_buffer_pool* pool = nullptr; srsue::pdcp_interface_rlc* pdcp = nullptr; srsue::rrc_interface_rlc* rrc = nullptr; + srsue::rrc_interface_rlc* rrc_nr = nullptr; srsran::timer_handler* timers = nullptr; typedef std::map rlc_map_t; diff --git a/lib/src/upper/rlc.cc b/lib/src/upper/rlc.cc index de922121c..030c28137 100644 --- a/lib/src/upper/rlc.cc +++ b/lib/src/upper/rlc.cc @@ -45,6 +45,16 @@ rlc::~rlc() pthread_rwlock_destroy(&rwlock); } +void rlc::init(srsue::pdcp_interface_rlc* pdcp_, + srsue::rrc_interface_rlc* rrc_, + srsue::rrc_interface_rlc* rrc_nr_, + srsran::timer_handler* timers_, + uint32_t lcid_) +{ + init(pdcp_, rrc_, timers_, lcid_); + rrc_nr = rrc_nr_; +} + void rlc::init(srsue::pdcp_interface_rlc* pdcp_, srsue::rrc_interface_rlc* rrc_, srsran::timer_handler* timers_, @@ -148,7 +158,7 @@ void rlc::reestablish() void rlc::reestablish(uint32_t lcid) { if (valid_lcid(lcid)) { - logger.info("Reestablishing %s", rrc->get_rb_name(lcid)); + logger.info("Reestablishing LCID %d", lcid); rlc_array.at(lcid)->reestablish(); } else { logger.warning("RLC LCID %d doesn't exist.", lcid); @@ -395,6 +405,12 @@ void rlc::add_bearer(uint32_t lcid, const rlc_config_t& cnfg) rlc_common* rlc_entity = nullptr; + // Check this for later rrc_nr pointer access + if (cnfg.rat == srsran::srsran_rat_t::nr && rrc_nr == nullptr) { + logger.error("Cannot add/modify RLC entity - missing rrc_nr parent pointer for rat type nr"); + return; + } + if (cnfg.rlc_mode != rlc_mode_t::tm and rlc_array.find(lcid) != rlc_array.end()) { if (rlc_array[lcid]->get_mode() != cnfg.rlc_mode) { logger.info("Switching RLC entity type. Recreating it."); @@ -403,46 +419,51 @@ void rlc::add_bearer(uint32_t lcid, const rlc_config_t& cnfg) } if (not valid_lcid(lcid)) { - if (cnfg.rat == srsran_rat_t::lte) { - switch (cnfg.rlc_mode) { - case rlc_mode_t::tm: - rlc_entity = new rlc_tm(logger, lcid, pdcp, rrc); - break; - case rlc_mode_t::am: - rlc_entity = new rlc_am_lte(logger, lcid, pdcp, rrc, timers); - break; - case rlc_mode_t::um: - rlc_entity = new rlc_um_lte(logger, lcid, pdcp, rrc, timers); - break; - default: - logger.error("Cannot add RLC entity - invalid mode"); - return; - } - if (rlc_entity != nullptr) { - rlc_entity->set_bsr_callback(bsr_callback); - } - } else if (cnfg.rat == srsran_rat_t::nr) { - switch (cnfg.rlc_mode) { - case rlc_mode_t::tm: - rlc_entity = new rlc_tm(logger, lcid, pdcp, rrc); - break; - case rlc_mode_t::um: - rlc_entity = new rlc_um_nr(logger, lcid, pdcp, rrc, timers); - break; - default: - logger.error("Cannot add RLC entity - invalid mode"); - return; - } - } else { - logger.error("RAT not supported"); - return; + switch (cnfg.rat) { + case srsran_rat_t::lte: + switch (cnfg.rlc_mode) { + case rlc_mode_t::tm: + rlc_entity = new rlc_tm(logger, lcid, pdcp, rrc); + break; + case rlc_mode_t::am: + rlc_entity = new rlc_am_lte(logger, lcid, pdcp, rrc, timers); + break; + case rlc_mode_t::um: + rlc_entity = new rlc_um_lte(logger, lcid, pdcp, rrc, timers); + break; + default: + logger.error("Cannot add RLC entity - invalid mode"); + return; + } + if (rlc_entity != nullptr) { + rlc_entity->set_bsr_callback(bsr_callback); + } + break; + case srsran_rat_t::nr: + switch (cnfg.rlc_mode) { + case rlc_mode_t::tm: + rlc_entity = new rlc_tm(logger, lcid, pdcp, rrc_nr); + break; + case rlc_mode_t::um: + rlc_entity = new rlc_um_nr(logger, lcid, pdcp, rrc_nr, timers); + break; + default: + logger.error("Cannot add RLC entity - invalid mode"); + return; + } + break; + default: + logger.error("RAT not supported"); + return; } if (not rlc_array.insert(rlc_map_pair_t(lcid, rlc_entity)).second) { logger.error("Error inserting RLC entity in to array."); goto delete_and_exit; } - logger.info("Added radio bearer %s in %s", rrc->get_rb_name(lcid), to_string(cnfg.rlc_mode).c_str()); + + logger.info( + "Added %s radio bearer with LCID %d in %s", to_string(cnfg.rat), lcid, to_string(cnfg.rlc_mode).c_str()); rlc_entity = NULL; } @@ -454,7 +475,8 @@ void rlc::add_bearer(uint32_t lcid, const rlc_config_t& cnfg) } } - logger.info("Configured radio bearer %s in %s", rrc->get_rb_name(lcid), to_string(cnfg.rlc_mode).c_str()); + logger.info( + "Configured %s radio bearer with LCID %d in %s", to_string(cnfg.rat), lcid, to_string(cnfg.rlc_mode).c_str()); delete_and_exit: if (rlc_entity) { @@ -501,9 +523,9 @@ void rlc::del_bearer(uint32_t lcid) it->second->stop(); delete (it->second); rlc_array.erase(it); - logger.warning("Deleted RLC bearer %s", rrc->get_rb_name(lcid)); + logger.info("Deleted RLC bearer with LCID %d", lcid); } else { - logger.error("Can't delete bearer %s. Bearer doesn't exist.", rrc->get_rb_name(lcid)); + logger.error("Can't delete bearer with LCID %d. Bearer doesn't exist.", lcid); } } @@ -516,9 +538,9 @@ void rlc::del_bearer_mrb(uint32_t lcid) it->second->stop(); delete (it->second); rlc_array_mrb.erase(it); - logger.warning("Deleted RLC MRB bearer %s", rrc->get_rb_name(lcid)); + logger.warning("Deleted RLC MRB bearer with LCID %d", lcid); } else { - logger.error("Can't delete bearer %s. Bearer doesn't exist.", rrc->get_rb_name(lcid)); + logger.error("Can't delete bearer with LCID %d. Bearer doesn't exist.", lcid); } } @@ -544,8 +566,7 @@ void rlc::change_lcid(uint32_t old_lcid, uint32_t new_lcid) logger.error("Error during LCID change of RLC bearer from %d to %d", old_lcid, new_lcid); } } else { - logger.error("Can't change LCID of bearer %s from %d to %d. Bearer doesn't exist or new LCID already occupied.", - rrc->get_rb_name(old_lcid), + logger.error("Can't change LCID of bearer LCID %d to %d. Bearer doesn't exist or new LCID already occupied.", old_lcid, new_lcid); } @@ -556,26 +577,26 @@ void rlc::suspend_bearer(uint32_t lcid) { if (valid_lcid(lcid)) { if (rlc_array.at(lcid)->suspend()) { - logger.info("Suspended radio bearer %s", rrc->get_rb_name(lcid)); + logger.info("Suspended radio bearer with LCID %d", lcid); } else { logger.error("Error suspending RLC entity: bearer already suspended."); } } else { - logger.error("Suspending bearer: bearer %s not configured.", rrc->get_rb_name(lcid)); + logger.error("Suspending bearer: bearer with LCID %d not configured.", lcid); } } void rlc::resume_bearer(uint32_t lcid) { - logger.info("Resuming radio bearer %s", rrc->get_rb_name(lcid)); + logger.info("Resuming radio LCID %d", lcid); if (valid_lcid(lcid)) { if (rlc_array.at(lcid)->resume()) { - logger.info("Resumed radio bearer %s", rrc->get_rb_name(lcid)); + logger.info("Resumed radio LCID %d", lcid); } else { logger.error("Error resuming RLC entity: bearer not suspended."); } } else { - logger.error("Resuming bearer: bearer %s not configured.", rrc->get_rb_name(lcid)); + logger.error("Resuming bearer: bearer with LCID %d not configured.", lcid); } } diff --git a/srsue/hdr/stack/rrc/rrc_nr.h b/srsue/hdr/stack/rrc/rrc_nr.h index 0dc3a35bf..b69d1a9c5 100644 --- a/srsue/hdr/stack/rrc/rrc_nr.h +++ b/srsue/hdr/stack/rrc/rrc_nr.h @@ -173,7 +173,7 @@ private: // RRC constants and timers srsran::timer_handler* timers = nullptr; - const char* get_rb_name(uint32_t lcid) final { return srsran::to_string((srsran::rb_id_nr_t)lcid); } + const char* get_rb_name(uint32_t lcid) final; typedef enum { Srb = 0, Drb } rb_type_t; typedef struct { diff --git a/srsue/src/stack/rrc/rrc_nr.cc b/srsue/src/stack/rrc/rrc_nr.cc index 556ba516c..569aafbe1 100644 --- a/srsue/src/stack/rrc/rrc_nr.cc +++ b/srsue/src/stack/rrc/rrc_nr.cc @@ -87,6 +87,25 @@ void rrc_nr::init_core_less() } void rrc_nr::get_metrics(rrc_nr_metrics_t& m) {} +const char* rrc_nr::get_rb_name(uint32_t lcid) +{ + uint32_t offset; + if (lcid_rb.find(lcid) != lcid_rb.end()) { + // Calulate offset for rb_id table + if (lcid_rb[lcid].rb_type == Srb) { + // SRB start at 0 + offset = NR_SRB0 + lcid_rb[lcid].rb_id; + } else { + // DRB start at 1 + offset = NR_SRB3 + lcid_rb[lcid].rb_id; + } + } else { + logger.warning("Unable to find lcid: %d. Return guessed rb name."); + offset = lcid; + } + return srsran::to_string((srsran::rb_id_nr_t)offset); +} + // Timeout callback interface void rrc_nr::timer_expired(uint32_t timeout_id) { @@ -161,7 +180,7 @@ void rrc_nr::log_rrc_message(const std::string& source, bool rrc_nr::add_lcid_rb(uint32_t lcid, rb_type_t rb_type, uint32_t rbid) { if (lcid_rb.find(lcid) != lcid_rb.end()) { - logger.error("Couldn't add RB to LCID. RB %d does exist.", rbid); + logger.error("Couldn't add RB to LCID (%d). RB %d already does exist.", lcid, rbid); return false; } else { logger.info("Adding lcid %d and radio bearer ID %d with type %s ", lcid, rbid, (rb_type == Srb) ? "SRB" : "DRB"); diff --git a/srsue/src/stack/ue_stack_lte.cc b/srsue/src/stack/ue_stack_lte.cc index 991d9697e..2b44b71b8 100644 --- a/srsue/src/stack/ue_stack_lte.cc +++ b/srsue/src/stack/ue_stack_lte.cc @@ -201,7 +201,7 @@ int ue_stack_lte::init(const stack_args_t& args_) sync_task_queue = task_sched.make_task_queue(args.sync_queue_size); mac.init(phy, &rlc, &rrc); - rlc.init(&pdcp, &rrc, task_sched.get_timer_handler(), 0 /* RB_ID_SRB0 */); + rlc.init(&pdcp, &rrc, &rrc_nr, task_sched.get_timer_handler(), 0 /* RB_ID_SRB0 */); pdcp.init(&rlc, &rrc, &rrc_nr, gw); nas.init(usim.get(), &rrc, gw, args.nas);