created a global map of lcids to srbs/drbs for NR

master
Francisco Paisana 5 years ago committed by Francisco Paisana
parent 4cf756434f
commit 452c043370

@ -0,0 +1,50 @@
/*
* Copyright 2013-2020 Software Radio Systems Limited
*
* This file is part of srsLTE.
*
* srsLTE is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* srsLTE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* A copy of the GNU Affero General Public License can be found in
* the LICENSE file in the top-level directory of this distribution
* and at http://www.gnu.org/licenses/.
*
*/
#ifndef SRSLTE_COMMON_NR_H
#define SRSLTE_COMMON_NR_H
namespace srslte {
// NR Radio Bearer Id
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"};
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)
{
return lcid <= rb_id_nr_t::NR_SRB3;
}
inline bool is_drb(rb_id_nr_t lcid)
{
return not is_srb(lcid) and lcid <= rb_id_nr_t::RB_ID_NR_N_ITEMS;
}
inline int get_drb_id(rb_id_nr_t rb_id)
{
return is_drb(rb_id) ? (rb_id - 3) : -1;
}
} // namespace srslte
#endif // SRSLTE_NR_COMMON_INTERFACE_TYPES_H

@ -51,8 +51,11 @@ enum rb_id_t {
RB_ID_DRB8, RB_ID_DRB8,
RB_ID_N_ITEMS, RB_ID_N_ITEMS,
}; };
static const char* rb_id_text[] = inline const char* to_string(rb_id_t rb_id)
{"SRB0", "SRB1", "SRB2", "DRB1", "DRB2", "DRB3", "DRB4", "DRB5", "DRB6", "DRB7", "DRB8"}; {
const static char* names[] = {"SRB0", "SRB1", "SRB2", "DRB1", "DRB2", "DRB3", "DRB4", "DRB5", "DRB6", "DRB7", "DRB8"};
return (rb_id < RB_ID_N_ITEMS) ? names[rb_id] : "invalid bearer id";
}
// Cat 3 UE - Max number of DL-SCH transport block bits received within a TTI // Cat 3 UE - Max number of DL-SCH transport block bits received within a TTI
// 3GPP 36.306 Table 4.1.1 // 3GPP 36.306 Table 4.1.1

@ -531,7 +531,7 @@ void rrc::parse_ul_dcch(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer
if (user_it != users.end()) { if (user_it != users.end()) {
user_it->second->parse_ul_dcch(lcid, std::move(pdu)); user_it->second->parse_ul_dcch(lcid, std::move(pdu));
} else { } else {
rrc_log->error("Processing %s: Unknown rnti=0x%x\n", rb_id_text[lcid], rnti); rrc_log->error("Processing %s: Unknown rnti=0x%x\n", srsenb::to_string((rb_id_t)lcid), rnti);
} }
} }
} }
@ -797,7 +797,7 @@ void rrc::tti_clock()
while (rx_pdu_queue.try_pop(&p)) { while (rx_pdu_queue.try_pop(&p)) {
// print Rx PDU // print Rx PDU
if (p.pdu != nullptr) { if (p.pdu != nullptr) {
rrc_log->info_hex(p.pdu->msg, p.pdu->N_bytes, "Rx %s PDU", rb_id_text[p.lcid]); rrc_log->info_hex(p.pdu->msg, p.pdu->N_bytes, "Rx %s PDU", to_string((rb_id_t)p.lcid));
} }
// check if user exists // check if user exists

@ -161,7 +161,8 @@ void rrc::ue::parse_ul_dcch(uint32_t lcid, srslte::unique_byte_buffer_t pdu)
return; return;
} }
parent->log_rrc_message(rb_id_text[lcid], Rx, pdu.get(), ul_dcch_msg, ul_dcch_msg.msg.c1().type().to_string()); parent->log_rrc_message(
srsenb::to_string((rb_id_t)lcid), Rx, pdu.get(), ul_dcch_msg, ul_dcch_msg.msg.c1().type().to_string());
// reuse PDU // reuse PDU
pdu->clear(); // TODO: name collision with byte_buffer reset pdu->clear(); // TODO: name collision with byte_buffer reset

@ -193,7 +193,7 @@ void pdcp::user_interface_rrc::write_pdu_pcch(srslte::unique_byte_buffer_t pdu)
std::string pdcp::user_interface_rrc::get_rb_name(uint32_t lcid) std::string pdcp::user_interface_rrc::get_rb_name(uint32_t lcid)
{ {
return std::string(rb_id_text[lcid]); return to_string((rb_id_t)lcid);
} }
} // namespace srsenb } // namespace srsenb

@ -273,7 +273,7 @@ void rlc::user_interface::write_pdu_pcch(srslte::unique_byte_buffer_t sdu)
std::string rlc::user_interface::get_rb_name(uint32_t lcid) std::string rlc::user_interface::get_rb_name(uint32_t lcid)
{ {
return std::string(rb_id_text[lcid]); return to_string((rb_id_t)lcid);
} }
} // namespace srsenb } // namespace srsenb

@ -25,6 +25,7 @@
#include "srslte/asn1/rrc_nr_asn1.h" #include "srslte/asn1/rrc_nr_asn1.h"
#include "srslte/common/block_queue.h" #include "srslte/common/block_queue.h"
#include "srslte/common/buffer_pool.h" #include "srslte/common/buffer_pool.h"
#include "srslte/interfaces/nr_common_interface_types.h"
#include "srslte/interfaces/ue_interfaces.h" #include "srslte/interfaces/ue_interfaces.h"
#include "srslte/interfaces/ue_nr_interfaces.h" #include "srslte/interfaces/ue_nr_interfaces.h"
#include "srsue/hdr/stack/upper/gw.h" #include "srsue/hdr/stack/upper/gw.h"
@ -134,17 +135,7 @@ private:
// RRC constants and timers // RRC constants and timers
srslte::timer_handler* timers = nullptr; srslte::timer_handler* timers = nullptr;
// Radio bearers std::string get_rb_name(uint32_t lcid) final { return srslte::to_string((srslte::rb_id_nr_t)lcid); }
std::map<int, std::string> rb_id_t = {{0, "SRB0"}, {1, "SRB1"}, {2, "SRB2"}, {3, "SRB3"}, {4, "DRB1"}};
std::string get_rb_name(uint32_t lcid) final
{
if (lcid < rb_id_t.size()) {
return rb_id_t.at(lcid);
} else {
return "INVALID_RB";
}
}
bool initiated = false; bool initiated = false;
}; };

Loading…
Cancel
Save