Add rrc_nr to rlc init function

This commit is contained in:
David Rupprecht 2021-04-13 14:23:00 +02:00 committed by Andre Puschmann
parent 6b41ae7e8b
commit 91ff8a2e6d
6 changed files with 170 additions and 53 deletions

View File

@ -16,11 +16,80 @@
namespace srsran { namespace srsran {
// NR Radio Bearer Id // 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) 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"; 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) inline bool is_srb(rb_id_nr_t lcid)

View File

@ -39,6 +39,13 @@ public:
srsue::rrc_interface_rlc* rrc_, srsue::rrc_interface_rlc* rrc_,
srsran::timer_handler* timers_, srsran::timer_handler* timers_,
uint32_t lcid_); 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_, void init(srsue::pdcp_interface_rlc* pdcp_,
srsue::rrc_interface_rlc* rrc_, srsue::rrc_interface_rlc* rrc_,
srsran::timer_handler* timers_, srsran::timer_handler* timers_,
@ -87,10 +94,11 @@ public:
private: private:
void reset_metrics(); void reset_metrics();
byte_buffer_pool* pool = nullptr;
srslog::basic_logger& logger; srslog::basic_logger& logger;
byte_buffer_pool* pool = nullptr;
srsue::pdcp_interface_rlc* pdcp = nullptr; srsue::pdcp_interface_rlc* pdcp = nullptr;
srsue::rrc_interface_rlc* rrc = nullptr; srsue::rrc_interface_rlc* rrc = nullptr;
srsue::rrc_interface_rlc* rrc_nr = nullptr;
srsran::timer_handler* timers = nullptr; srsran::timer_handler* timers = nullptr;
typedef std::map<uint16_t, rlc_common*> rlc_map_t; typedef std::map<uint16_t, rlc_common*> rlc_map_t;

View File

@ -45,6 +45,16 @@ rlc::~rlc()
pthread_rwlock_destroy(&rwlock); 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_, void rlc::init(srsue::pdcp_interface_rlc* pdcp_,
srsue::rrc_interface_rlc* rrc_, srsue::rrc_interface_rlc* rrc_,
srsran::timer_handler* timers_, srsran::timer_handler* timers_,
@ -148,7 +158,7 @@ void rlc::reestablish()
void rlc::reestablish(uint32_t lcid) void rlc::reestablish(uint32_t lcid)
{ {
if (valid_lcid(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(); rlc_array.at(lcid)->reestablish();
} else { } else {
logger.warning("RLC LCID %d doesn't exist.", lcid); 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; 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 (cnfg.rlc_mode != rlc_mode_t::tm and rlc_array.find(lcid) != rlc_array.end()) {
if (rlc_array[lcid]->get_mode() != cnfg.rlc_mode) { if (rlc_array[lcid]->get_mode() != cnfg.rlc_mode) {
logger.info("Switching RLC entity type. Recreating it."); 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 (not valid_lcid(lcid)) {
if (cnfg.rat == srsran_rat_t::lte) { switch (cnfg.rat) {
switch (cnfg.rlc_mode) { case srsran_rat_t::lte:
case rlc_mode_t::tm: switch (cnfg.rlc_mode) {
rlc_entity = new rlc_tm(logger, lcid, pdcp, rrc); case rlc_mode_t::tm:
break; rlc_entity = new rlc_tm(logger, lcid, pdcp, rrc);
case rlc_mode_t::am: break;
rlc_entity = new rlc_am_lte(logger, lcid, pdcp, rrc, timers); case rlc_mode_t::am:
break; rlc_entity = new rlc_am_lte(logger, lcid, pdcp, rrc, timers);
case rlc_mode_t::um: break;
rlc_entity = new rlc_um_lte(logger, lcid, pdcp, rrc, timers); case rlc_mode_t::um:
break; rlc_entity = new rlc_um_lte(logger, lcid, pdcp, rrc, timers);
default: break;
logger.error("Cannot add RLC entity - invalid mode"); default:
return; logger.error("Cannot add RLC entity - invalid mode");
} return;
if (rlc_entity != nullptr) { }
rlc_entity->set_bsr_callback(bsr_callback); if (rlc_entity != nullptr) {
} rlc_entity->set_bsr_callback(bsr_callback);
} else if (cnfg.rat == srsran_rat_t::nr) { }
switch (cnfg.rlc_mode) { break;
case rlc_mode_t::tm: case srsran_rat_t::nr:
rlc_entity = new rlc_tm(logger, lcid, pdcp, rrc); switch (cnfg.rlc_mode) {
break; case rlc_mode_t::tm:
case rlc_mode_t::um: rlc_entity = new rlc_tm(logger, lcid, pdcp, rrc_nr);
rlc_entity = new rlc_um_nr(logger, lcid, pdcp, rrc, timers); break;
break; case rlc_mode_t::um:
default: rlc_entity = new rlc_um_nr(logger, lcid, pdcp, rrc_nr, timers);
logger.error("Cannot add RLC entity - invalid mode"); break;
return; default:
} logger.error("Cannot add RLC entity - invalid mode");
} else { return;
logger.error("RAT not supported"); }
return; break;
default:
logger.error("RAT not supported");
return;
} }
if (not rlc_array.insert(rlc_map_pair_t(lcid, rlc_entity)).second) { if (not rlc_array.insert(rlc_map_pair_t(lcid, rlc_entity)).second) {
logger.error("Error inserting RLC entity in to array."); logger.error("Error inserting RLC entity in to array.");
goto delete_and_exit; 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; 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: delete_and_exit:
if (rlc_entity) { if (rlc_entity) {
@ -501,9 +523,9 @@ void rlc::del_bearer(uint32_t lcid)
it->second->stop(); it->second->stop();
delete (it->second); delete (it->second);
rlc_array.erase(it); 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 { } 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(); it->second->stop();
delete (it->second); delete (it->second);
rlc_array_mrb.erase(it); 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 { } 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); logger.error("Error during LCID change of RLC bearer from %d to %d", old_lcid, new_lcid);
} }
} else { } else {
logger.error("Can't change LCID of bearer %s from %d to %d. Bearer doesn't exist or new LCID already occupied.", logger.error("Can't change LCID of bearer LCID %d to %d. Bearer doesn't exist or new LCID already occupied.",
rrc->get_rb_name(old_lcid),
old_lcid, old_lcid,
new_lcid); new_lcid);
} }
@ -556,26 +577,26 @@ void rlc::suspend_bearer(uint32_t lcid)
{ {
if (valid_lcid(lcid)) { if (valid_lcid(lcid)) {
if (rlc_array.at(lcid)->suspend()) { 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 { } else {
logger.error("Error suspending RLC entity: bearer already suspended."); logger.error("Error suspending RLC entity: bearer already suspended.");
} }
} else { } 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) 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 (valid_lcid(lcid)) {
if (rlc_array.at(lcid)->resume()) { 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 { } else {
logger.error("Error resuming RLC entity: bearer not suspended."); logger.error("Error resuming RLC entity: bearer not suspended.");
} }
} else { } 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);
} }
} }

View File

@ -173,7 +173,7 @@ private:
// RRC constants and timers // RRC constants and timers
srsran::timer_handler* timers = nullptr; 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 enum { Srb = 0, Drb } rb_type_t;
typedef struct { typedef struct {

View File

@ -87,6 +87,25 @@ void rrc_nr::init_core_less()
} }
void rrc_nr::get_metrics(rrc_nr_metrics_t& m) {} 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 // Timeout callback interface
void rrc_nr::timer_expired(uint32_t timeout_id) 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) 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()) { 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; return false;
} else { } else {
logger.info("Adding lcid %d and radio bearer ID %d with type %s ", lcid, rbid, (rb_type == Srb) ? "SRB" : "DRB"); logger.info("Adding lcid %d and radio bearer ID %d with type %s ", lcid, rbid, (rb_type == Srb) ? "SRB" : "DRB");

View File

@ -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); sync_task_queue = task_sched.make_task_queue(args.sync_queue_size);
mac.init(phy, &rlc, &rrc); 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); pdcp.init(&rlc, &rrc, &rrc_nr, gw);
nas.init(usim.get(), &rrc, gw, args.nas); nas.init(usim.get(), &rrc, gw, args.nas);