Ported the RLC classes to srslog in the lib dir.

master
faluco 4 years ago committed by faluco
parent f424f2e113
commit 57f66febfc

@ -86,7 +86,7 @@ private:
void reset_metrics(); void reset_metrics();
byte_buffer_pool* pool = nullptr; byte_buffer_pool* pool = nullptr;
srslte::log_ref rlc_log; srslog::basic_logger& logger;
srsue::pdcp_interface_rlc* pdcp = nullptr; srsue::pdcp_interface_rlc* pdcp = nullptr;
srsue::rrc_interface_rlc* rrc = nullptr; srsue::rrc_interface_rlc* rrc = nullptr;
srslte::timer_handler* timers = nullptr; srslte::timer_handler* timers = nullptr;

@ -69,7 +69,7 @@ struct pdcp_sdu_info_t {
class rlc_am_lte : public rlc_common class rlc_am_lte : public rlc_common
{ {
public: public:
rlc_am_lte(srslte::log_ref log_, rlc_am_lte(srslog::basic_logger& logger,
uint32_t lcid_, uint32_t lcid_,
srsue::pdcp_interface_rlc* pdcp_, srsue::pdcp_interface_rlc* pdcp_,
srsue::rrc_interface_rlc* rrc_, srsue::rrc_interface_rlc* rrc_,
@ -146,9 +146,9 @@ private:
bool poll_required(); bool poll_required();
bool do_status(); bool do_status();
rlc_am_lte* parent = nullptr; rlc_am_lte* parent = nullptr;
byte_buffer_pool* pool = nullptr; byte_buffer_pool* pool = nullptr;
srslte::log_ref log; srslog::basic_logger& logger;
/**************************************************************************** /****************************************************************************
* Configurable parameters * Configurable parameters
@ -237,9 +237,9 @@ private:
void print_rx_segments(); void print_rx_segments();
bool add_segment_and_check(rlc_amd_rx_pdu_segments_t* pdu, rlc_amd_rx_pdu_t* segment); bool add_segment_and_check(rlc_amd_rx_pdu_segments_t* pdu, rlc_amd_rx_pdu_t* segment);
rlc_am_lte* parent = nullptr; rlc_am_lte* parent = nullptr;
byte_buffer_pool* pool = nullptr; byte_buffer_pool* pool = nullptr;
srslte::log_ref log; srslog::basic_logger& logger;
/**************************************************************************** /****************************************************************************
* Configurable parameters * Configurable parameters
@ -284,7 +284,7 @@ private:
// Common variables needed/provided by parent class // Common variables needed/provided by parent class
srsue::rrc_interface_rlc* rrc = nullptr; srsue::rrc_interface_rlc* rrc = nullptr;
srslte::log_ref log; srslog::basic_logger& logger;
srsue::pdcp_interface_rlc* pdcp = nullptr; srsue::pdcp_interface_rlc* pdcp = nullptr;
srslte::timer_handler* timers = nullptr; srslte::timer_handler* timers = nullptr;
uint32_t lcid = 0; uint32_t lcid = 0;

@ -282,7 +282,7 @@ private:
// Do not block ever // Do not block ever
if (!rx_pdu_resume_queue.try_push(p)) { if (!rx_pdu_resume_queue.try_push(p)) {
srslte::logmap::get("RLC ")->warning("Dropping SDUs while bearer suspended.\n"); srslog::fetch_basic_logger("RLC").warning("Dropping SDUs while bearer suspended.");
return; return;
} }
} }
@ -292,7 +292,7 @@ private:
{ {
// Do not block ever // Do not block ever
if (not tx_sdu_resume_queue.try_push(std::move(sdu))) { if (not tx_sdu_resume_queue.try_push(std::move(sdu))) {
srslte::logmap::get("RLC ")->warning("Dropping SDUs while bearer suspended.\n"); srslog::fetch_basic_logger("RLC").warning("Dropping SDUs while bearer suspended.");
return; return;
} }
} }

@ -25,7 +25,10 @@ namespace srslte {
class rlc_tm final : public rlc_common class rlc_tm final : public rlc_common
{ {
public: public:
rlc_tm(srslte::log_ref log_, uint32_t lcid_, srsue::pdcp_interface_rlc* pdcp_, srsue::rrc_interface_rlc* rrc_); rlc_tm(srslog::basic_logger& logger,
uint32_t lcid_,
srsue::pdcp_interface_rlc* pdcp_,
srsue::rrc_interface_rlc* rrc_);
~rlc_tm() override; ~rlc_tm() override;
bool configure(const rlc_config_t& cnfg) override; bool configure(const rlc_config_t& cnfg) override;
void stop() override; void stop() override;
@ -53,7 +56,7 @@ public:
private: private:
byte_buffer_pool* pool = nullptr; byte_buffer_pool* pool = nullptr;
srslte::log_ref log; srslog::basic_logger& logger;
uint32_t lcid = 0; uint32_t lcid = 0;
srsue::pdcp_interface_rlc* pdcp = nullptr; srsue::pdcp_interface_rlc* pdcp = nullptr;
srsue::rrc_interface_rlc* rrc = nullptr; srsue::rrc_interface_rlc* rrc = nullptr;

@ -30,7 +30,7 @@ namespace srslte {
class rlc_um_base : public rlc_common class rlc_um_base : public rlc_common
{ {
public: public:
rlc_um_base(srslte::log_ref log_, rlc_um_base(srslog::basic_logger& logger,
uint32_t lcid_, uint32_t lcid_,
srsue::pdcp_interface_rlc* pdcp_, srsue::pdcp_interface_rlc* pdcp_,
srsue::rrc_interface_rlc* rrc_, srsue::rrc_interface_rlc* rrc_,
@ -82,10 +82,10 @@ protected:
virtual uint32_t get_buffer_state() = 0; virtual uint32_t get_buffer_state() = 0;
protected: protected:
byte_buffer_pool* pool = nullptr; byte_buffer_pool* pool = nullptr;
srslte::log_ref log; srslog::basic_logger& logger;
std::string rb_name; std::string rb_name;
rlc_um_base* parent = nullptr; rlc_um_base* parent = nullptr;
rlc_config_t cfg = {}; rlc_config_t cfg = {};
@ -111,7 +111,6 @@ protected:
// Receiver sub-class base // Receiver sub-class base
class rlc_um_base_rx : public timer_callback class rlc_um_base_rx : public timer_callback
{ {
public: public:
rlc_um_base_rx(rlc_um_base* parent_); rlc_um_base_rx(rlc_um_base* parent_);
virtual ~rlc_um_base_rx(); virtual ~rlc_um_base_rx();
@ -124,7 +123,7 @@ protected:
protected: protected:
byte_buffer_pool* pool = nullptr; byte_buffer_pool* pool = nullptr;
srslte::log_ref log; srslog::basic_logger& logger;
srslte::timer_handler* timers = nullptr; srslte::timer_handler* timers = 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;
@ -145,7 +144,7 @@ protected:
// Common variables needed by parent class // Common variables needed by parent class
srsue::rrc_interface_rlc* rrc = nullptr; srsue::rrc_interface_rlc* rrc = nullptr;
srsue::pdcp_interface_rlc* pdcp = nullptr; srsue::pdcp_interface_rlc* pdcp = nullptr;
srslte::log_ref log; srslog::basic_logger& logger;
srslte::timer_handler* timers = nullptr; srslte::timer_handler* timers = nullptr;
uint32_t lcid = 0; uint32_t lcid = 0;
rlc_config_t cfg = {}; rlc_config_t cfg = {};

@ -34,7 +34,7 @@ typedef struct {
class rlc_um_lte : public rlc_um_base class rlc_um_lte : public rlc_um_base
{ {
public: public:
rlc_um_lte(srslte::log_ref log_, rlc_um_lte(srslog::basic_logger& logger,
uint32_t lcid_, uint32_t lcid_,
srsue::pdcp_interface_rlc* pdcp_, srsue::pdcp_interface_rlc* pdcp_,
srsue::rrc_interface_rlc* rrc_, srsue::rrc_interface_rlc* rrc_,

@ -34,7 +34,7 @@ typedef struct {
class rlc_um_nr : public rlc_um_base class rlc_um_nr : public rlc_um_base
{ {
public: public:
rlc_um_nr(srslte::log_ref log_, rlc_um_nr(srslog::basic_logger& logger,
uint32_t lcid_, uint32_t lcid_,
srsue::pdcp_interface_rlc* pdcp_, srsue::pdcp_interface_rlc* pdcp_,
srsue::rrc_interface_rlc* rrc_, srsue::rrc_interface_rlc* rrc_,

@ -19,7 +19,7 @@
namespace srslte { namespace srslte {
rlc::rlc(const char* logname) : rlc_log(logname) rlc::rlc(const char* logname) : logger(srslog::fetch_basic_logger(logname))
{ {
pool = byte_buffer_pool::get_instance(); pool = byte_buffer_pool::get_instance();
pthread_rwlock_init(&rwlock, NULL); pthread_rwlock_init(&rwlock, NULL);
@ -109,21 +109,21 @@ void rlc::get_metrics(rlc_metrics_t& m, const uint32_t nof_tti)
double rx_rate_mbps = (nof_tti > 0) ? ((metrics.num_rx_pdu_bytes * 8 / (double)1e6) / (nof_tti / 1000.0)) : 0.0; double rx_rate_mbps = (nof_tti > 0) ? ((metrics.num_rx_pdu_bytes * 8 / (double)1e6) / (nof_tti / 1000.0)) : 0.0;
double tx_rate_mbps = (nof_tti > 0) ? ((metrics.num_tx_pdu_bytes * 8 / (double)1e6) / (nof_tti / 1000.0)) : 0.0; double tx_rate_mbps = (nof_tti > 0) ? ((metrics.num_tx_pdu_bytes * 8 / (double)1e6) / (nof_tti / 1000.0)) : 0.0;
rlc_log->info("lcid=%d, rx_rate_mbps=%4.2f (real=%4.2f), tx_rate_mbps=%4.2f (real=%4.2f)\n", logger.info("lcid=%d, rx_rate_mbps=%4.2f (real=%4.2f), tx_rate_mbps=%4.2f (real=%4.2f)",
it->first, it->first,
rx_rate_mbps, rx_rate_mbps,
rx_rate_mbps_real_time, rx_rate_mbps_real_time,
tx_rate_mbps, tx_rate_mbps,
tx_rate_mbps_real_time); tx_rate_mbps_real_time);
m.bearer[it->first] = metrics; m.bearer[it->first] = metrics;
} }
// Add multicast metrics // Add multicast metrics
for (rlc_map_t::iterator it = rlc_array_mrb.begin(); it != rlc_array_mrb.end(); ++it) { for (rlc_map_t::iterator it = rlc_array_mrb.begin(); it != rlc_array_mrb.end(); ++it) {
rlc_bearer_metrics_t metrics = it->second->get_metrics(); rlc_bearer_metrics_t metrics = it->second->get_metrics();
rlc_log->info("MCH_LCID=%d, rx_rate_mbps=%4.2f\n", logger.info("MCH_LCID=%d, rx_rate_mbps=%4.2f",
it->first, it->first,
(metrics.num_rx_pdu_bytes * 8 / static_cast<double>(1e6)) / secs.count()); (metrics.num_rx_pdu_bytes * 8 / static_cast<double>(1e6)) / secs.count());
m.bearer[it->first] = metrics; m.bearer[it->first] = metrics;
} }
@ -148,10 +148,10 @@ void rlc::reestablish()
void rlc::reestablish(uint32_t lcid) void rlc::reestablish(uint32_t lcid)
{ {
if (valid_lcid(lcid)) { if (valid_lcid(lcid)) {
rlc_log->info("Reestablishing %s\n", rrc->get_rb_name(lcid).c_str()); logger.info("Reestablishing %s", rrc->get_rb_name(lcid).c_str());
rlc_array.at(lcid)->reestablish(); rlc_array.at(lcid)->reestablish();
} else { } else {
rlc_log->warning("RLC LCID %d doesn't exist.\n", lcid); logger.warning("RLC LCID %d doesn't exist.", lcid);
} }
} }
@ -191,7 +191,7 @@ void rlc::write_sdu(uint32_t lcid, unique_byte_buffer_t sdu)
{ {
// TODO: rework build PDU logic to allow large SDUs (without concatenation) // TODO: rework build PDU logic to allow large SDUs (without concatenation)
if (sdu->N_bytes > RLC_MAX_SDU_SIZE) { if (sdu->N_bytes > RLC_MAX_SDU_SIZE) {
rlc_log->warning("Dropping too long SDU of size %d B (Max. size %d B).\n", sdu->N_bytes, RLC_MAX_SDU_SIZE); logger.warning("Dropping too long SDU of size %d B (Max. size %d B).", sdu->N_bytes, RLC_MAX_SDU_SIZE);
return; return;
} }
@ -199,7 +199,7 @@ void rlc::write_sdu(uint32_t lcid, unique_byte_buffer_t sdu)
rlc_array.at(lcid)->write_sdu_s(std::move(sdu)); rlc_array.at(lcid)->write_sdu_s(std::move(sdu));
update_bsr(lcid); update_bsr(lcid);
} else { } else {
rlc_log->warning("RLC LCID %d doesn't exist. Deallocating SDU\n", lcid); logger.warning("RLC LCID %d doesn't exist. Deallocating SDU", lcid);
} }
} }
@ -209,7 +209,7 @@ void rlc::write_sdu_mch(uint32_t lcid, unique_byte_buffer_t sdu)
rlc_array_mrb.at(lcid)->write_sdu(std::move(sdu)); rlc_array_mrb.at(lcid)->write_sdu(std::move(sdu));
update_bsr_mch(lcid); update_bsr_mch(lcid);
} else { } else {
rlc_log->warning("RLC LCID %d doesn't exist. Deallocating SDU\n", lcid); logger.warning("RLC LCID %d doesn't exist. Deallocating SDU", lcid);
} }
} }
@ -220,7 +220,7 @@ bool rlc::rb_is_um(uint32_t lcid)
if (valid_lcid(lcid)) { if (valid_lcid(lcid)) {
ret = rlc_array.at(lcid)->get_mode() == rlc_mode_t::um; ret = rlc_array.at(lcid)->get_mode() == rlc_mode_t::um;
} else { } else {
rlc_log->warning("LCID %d doesn't exist.\n", lcid); logger.warning("LCID %d doesn't exist.", lcid);
} }
return ret; return ret;
@ -232,7 +232,7 @@ void rlc::discard_sdu(uint32_t lcid, uint32_t discard_sn)
rlc_array.at(lcid)->discard_sdu(discard_sn); rlc_array.at(lcid)->discard_sdu(discard_sn);
update_bsr(lcid); update_bsr(lcid);
} else { } else {
rlc_log->warning("RLC LCID %d doesn't exist. Ignoring discard SDU\n", lcid); logger.warning("RLC LCID %d doesn't exist. Ignoring discard SDU", lcid);
} }
} }
@ -241,7 +241,7 @@ bool rlc::sdu_queue_is_full(uint32_t lcid)
if (valid_lcid(lcid)) { if (valid_lcid(lcid)) {
return rlc_array.at(lcid)->sdu_queue_is_full(); return rlc_array.at(lcid)->sdu_queue_is_full();
} }
rlc_log->warning("RLC LCID %d doesn't exist. Ignoring queue check\n", lcid); logger.warning("RLC LCID %d doesn't exist. Ignoring queue check", lcid);
return false; return false;
} }
@ -291,7 +291,7 @@ int rlc::read_pdu(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes)
ret = rlc_array.at(lcid)->read_pdu(payload, nof_bytes); ret = rlc_array.at(lcid)->read_pdu(payload, nof_bytes);
update_bsr(lcid); update_bsr(lcid);
} else { } else {
rlc_log->warning("LCID %d doesn't exist.\n", lcid); logger.warning("LCID %d doesn't exist.", lcid);
} }
return ret; return ret;
@ -306,7 +306,7 @@ int rlc::read_pdu_mch(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes)
ret = rlc_array_mrb.at(lcid)->read_pdu(payload, nof_bytes); ret = rlc_array_mrb.at(lcid)->read_pdu(payload, nof_bytes);
update_bsr_mch(lcid); update_bsr_mch(lcid);
} else { } else {
rlc_log->warning("LCID %d doesn't exist.\n", lcid); logger.warning("LCID %d doesn't exist.", lcid);
} }
return ret; return ret;
@ -319,21 +319,21 @@ void rlc::write_pdu(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes)
rlc_array.at(lcid)->write_pdu_s(payload, nof_bytes); rlc_array.at(lcid)->write_pdu_s(payload, nof_bytes);
update_bsr(lcid); update_bsr(lcid);
} else { } else {
rlc_log->warning("LCID %d doesn't exist. Dropping PDU.\n", lcid); logger.warning("LCID %d doesn't exist. Dropping PDU.", lcid);
} }
} }
// Pass directly to PDCP, no DL througput counting done // Pass directly to PDCP, no DL througput counting done
void rlc::write_pdu_bcch_bch(srslte::unique_byte_buffer_t pdu) void rlc::write_pdu_bcch_bch(srslte::unique_byte_buffer_t pdu)
{ {
rlc_log->info_hex(pdu->msg, pdu->N_bytes, "BCCH BCH message received."); logger.info(pdu->msg, pdu->N_bytes, "BCCH BCH message received.");
pdcp->write_pdu_bcch_bch(std::move(pdu)); pdcp->write_pdu_bcch_bch(std::move(pdu));
} }
// Pass directly to PDCP, no DL througput counting done // Pass directly to PDCP, no DL througput counting done
void rlc::write_pdu_bcch_dlsch(uint8_t* payload, uint32_t nof_bytes) void rlc::write_pdu_bcch_dlsch(uint8_t* payload, uint32_t nof_bytes)
{ {
rlc_log->info_hex(payload, nof_bytes, "BCCH TXSCH message received."); logger.info(payload, nof_bytes, "BCCH TXSCH message received.");
unique_byte_buffer_t buf = make_byte_buffer(); unique_byte_buffer_t buf = make_byte_buffer();
if (buf != NULL) { if (buf != NULL) {
memcpy(buf->msg, payload, nof_bytes); memcpy(buf->msg, payload, nof_bytes);
@ -341,14 +341,14 @@ void rlc::write_pdu_bcch_dlsch(uint8_t* payload, uint32_t nof_bytes)
buf->set_timestamp(); buf->set_timestamp();
pdcp->write_pdu_bcch_dlsch(std::move(buf)); pdcp->write_pdu_bcch_dlsch(std::move(buf));
} else { } else {
rlc_log->error("Fatal error: Out of buffers from the pool in write_pdu_bcch_dlsch()\n"); logger.error("Fatal error: Out of buffers from the pool in write_pdu_bcch_dlsch()");
} }
} }
// Pass directly to PDCP, no DL througput counting done // Pass directly to PDCP, no DL througput counting done
void rlc::write_pdu_pcch(srslte::unique_byte_buffer_t pdu) void rlc::write_pdu_pcch(srslte::unique_byte_buffer_t pdu)
{ {
rlc_log->info_hex(pdu->msg, pdu->N_bytes, "PCCH message received."); logger.info(pdu->msg, pdu->N_bytes, "PCCH message received.");
pdcp->write_pdu_pcch(std::move(pdu)); pdcp->write_pdu_pcch(std::move(pdu));
} }
@ -393,7 +393,7 @@ void rlc::add_bearer(uint32_t lcid, const rlc_config_t& cnfg)
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) {
rlc_log->info("Switching RLC entity type. Recreating it.\n"); logger.info("Switching RLC entity type. Recreating it.");
rlc_array.erase(lcid); rlc_array.erase(lcid);
} }
} }
@ -402,16 +402,16 @@ void rlc::add_bearer(uint32_t lcid, const rlc_config_t& cnfg)
if (cnfg.rat == srslte_rat_t::lte) { if (cnfg.rat == srslte_rat_t::lte) {
switch (cnfg.rlc_mode) { switch (cnfg.rlc_mode) {
case rlc_mode_t::tm: case rlc_mode_t::tm:
rlc_entity = new rlc_tm(rlc_log, lcid, pdcp, rrc); rlc_entity = new rlc_tm(logger, lcid, pdcp, rrc);
break; break;
case rlc_mode_t::am: case rlc_mode_t::am:
rlc_entity = new rlc_am_lte(rlc_log, lcid, pdcp, rrc, timers); rlc_entity = new rlc_am_lte(logger, lcid, pdcp, rrc, timers);
break; break;
case rlc_mode_t::um: case rlc_mode_t::um:
rlc_entity = new rlc_um_lte(rlc_log, lcid, pdcp, rrc, timers); rlc_entity = new rlc_um_lte(logger, lcid, pdcp, rrc, timers);
break; break;
default: default:
rlc_log->error("Cannot add RLC entity - invalid mode\n"); logger.error("Cannot add RLC entity - invalid mode");
return; return;
} }
if (rlc_entity != nullptr) { if (rlc_entity != nullptr) {
@ -421,38 +421,38 @@ void rlc::add_bearer(uint32_t lcid, const rlc_config_t& cnfg)
} else if (cnfg.rat == srslte_rat_t::nr) { } else if (cnfg.rat == srslte_rat_t::nr) {
switch (cnfg.rlc_mode) { switch (cnfg.rlc_mode) {
case rlc_mode_t::tm: case rlc_mode_t::tm:
rlc_entity = new rlc_tm(rlc_log, lcid, pdcp, rrc); rlc_entity = new rlc_tm(logger, lcid, pdcp, rrc);
break; break;
case rlc_mode_t::um: case rlc_mode_t::um:
rlc_entity = new rlc_um_nr(rlc_log, lcid, pdcp, rrc, timers); rlc_entity = new rlc_um_nr(logger, lcid, pdcp, rrc, timers);
break; break;
default: default:
rlc_log->error("Cannot add RLC entity - invalid mode\n"); logger.error("Cannot add RLC entity - invalid mode");
return; return;
} }
#endif #endif
} else { } else {
rlc_log->error("RAT not supported\n"); logger.error("RAT not supported");
return; 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) {
rlc_log->error("Error inserting RLC entity in to array\n."); logger.error("Error inserting RLC entity in to array.");
goto delete_and_exit; goto delete_and_exit;
} }
rlc_log->info("Added radio bearer %s in %s\n", rrc->get_rb_name(lcid).c_str(), to_string(cnfg.rlc_mode).c_str()); logger.info("Added radio bearer %s in %s", rrc->get_rb_name(lcid).c_str(), to_string(cnfg.rlc_mode).c_str());
rlc_entity = NULL; rlc_entity = NULL;
} }
// configure and add to array // configure and add to array
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 (not rlc_array.at(lcid)->configure(cnfg)) { if (not rlc_array.at(lcid)->configure(cnfg)) {
rlc_log->error("Error configuring RLC entity\n."); logger.error("Error configuring RLC entity.");
goto delete_and_exit; goto delete_and_exit;
} }
} }
rlc_log->info("Configured radio bearer %s in %s\n", rrc->get_rb_name(lcid).c_str(), to_string(cnfg.rlc_mode).c_str()); logger.info("Configured radio bearer %s in %s", rrc->get_rb_name(lcid).c_str(), to_string(cnfg.rlc_mode).c_str());
delete_and_exit: delete_and_exit:
if (rlc_entity) { if (rlc_entity) {
@ -466,22 +466,22 @@ void rlc::add_bearer_mrb(uint32_t lcid)
rlc_common* rlc_entity = NULL; rlc_common* rlc_entity = NULL;
if (not valid_lcid_mrb(lcid)) { if (not valid_lcid_mrb(lcid)) {
rlc_entity = new rlc_um_lte(rlc_log, lcid, pdcp, rrc, timers); rlc_entity = new rlc_um_lte(logger, lcid, pdcp, rrc, timers);
// configure and add to array // configure and add to array
if (not rlc_entity->configure(rlc_config_t::mch_config())) { if (not rlc_entity->configure(rlc_config_t::mch_config())) {
rlc_log->error("Error configuring RLC entity\n."); logger.error("Error configuring RLC entity.");
goto delete_and_exit; goto delete_and_exit;
} }
if (rlc_array_mrb.count(lcid) == 0) { if (rlc_array_mrb.count(lcid) == 0) {
if (not rlc_array_mrb.insert(rlc_map_pair_t(lcid, rlc_entity)).second) { if (not rlc_array_mrb.insert(rlc_map_pair_t(lcid, rlc_entity)).second) {
rlc_log->error("Error inserting RLC entity in to array\n."); logger.error("Error inserting RLC entity in to array.");
goto delete_and_exit; goto delete_and_exit;
} }
} }
rlc_log->warning("Added bearer MRB%d with mode RLC_UM\n", lcid); logger.warning("Added bearer MRB%d with mode RLC_UM", lcid);
return; return;
} else { } else {
rlc_log->warning("Bearer MRB%d already created.\n", lcid); logger.warning("Bearer MRB%d already created.", lcid);
} }
delete_and_exit: delete_and_exit:
@ -499,9 +499,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);
rlc_log->warning("Deleted RLC bearer %s\n", rrc->get_rb_name(lcid).c_str()); logger.warning("Deleted RLC bearer %s", rrc->get_rb_name(lcid).c_str());
} else { } else {
rlc_log->error("Can't delete bearer %s. Bearer doesn't exist.\n", rrc->get_rb_name(lcid).c_str()); logger.error("Can't delete bearer %s. Bearer doesn't exist.", rrc->get_rb_name(lcid).c_str());
} }
} }
@ -514,9 +514,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);
rlc_log->warning("Deleted RLC MRB bearer %s\n", rrc->get_rb_name(lcid).c_str()); logger.warning("Deleted RLC MRB bearer %s", rrc->get_rb_name(lcid).c_str());
} else { } else {
rlc_log->error("Can't delete bearer %s. Bearer doesn't exist.\n", rrc->get_rb_name(lcid).c_str()); logger.error("Can't delete bearer %s. Bearer doesn't exist.", rrc->get_rb_name(lcid).c_str());
} }
} }
@ -530,22 +530,22 @@ void rlc::change_lcid(uint32_t old_lcid, uint32_t new_lcid)
rlc_map_t::iterator it = rlc_array.find(old_lcid); rlc_map_t::iterator it = rlc_array.find(old_lcid);
rlc_common* rlc_entity = it->second; rlc_common* rlc_entity = it->second;
if (not rlc_array.insert(rlc_map_pair_t(new_lcid, rlc_entity)).second) { if (not rlc_array.insert(rlc_map_pair_t(new_lcid, rlc_entity)).second) {
rlc_log->error("Error inserting RLC entity into array\n."); logger.error("Error inserting RLC entity into array.");
return; return;
} }
// erase from old position // erase from old position
rlc_array.erase(it); rlc_array.erase(it);
if (valid_lcid(new_lcid) && not valid_lcid(old_lcid)) { if (valid_lcid(new_lcid) && not valid_lcid(old_lcid)) {
rlc_log->info("Successfully changed LCID of RLC bearer from %d to %d\n", old_lcid, new_lcid); logger.info("Successfully changed LCID of RLC bearer from %d to %d", old_lcid, new_lcid);
} else { } else {
rlc_log->error("Error during LCID change of RLC bearer from %d to %d\n", old_lcid, new_lcid); logger.error("Error during LCID change of RLC bearer from %d to %d", old_lcid, new_lcid);
} }
} else { } else {
rlc_log->error("Can't change LCID of bearer %s from %d to %d. Bearer doesn't exist or new LCID already occupied.\n", 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).c_str(), rrc->get_rb_name(old_lcid).c_str(),
old_lcid, old_lcid,
new_lcid); new_lcid);
} }
} }
@ -554,26 +554,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()) {
rlc_log->info("Suspended radio bearer %s\n", rrc->get_rb_name(lcid).c_str()); logger.info("Suspended radio bearer %s", rrc->get_rb_name(lcid).c_str());
} else { } else {
rlc_log->error("Error suspending RLC entity: bearer already suspended\n."); logger.error("Error suspending RLC entity: bearer already suspended.");
} }
} else { } else {
rlc_log->error("Suspending bearer: bearer %s not configured.\n", rrc->get_rb_name(lcid).c_str()); logger.error("Suspending bearer: bearer %s not configured.", rrc->get_rb_name(lcid).c_str());
} }
} }
void rlc::resume_bearer(uint32_t lcid) void rlc::resume_bearer(uint32_t lcid)
{ {
rlc_log->info("Resuming radio bearer %s\n", rrc->get_rb_name(lcid).c_str()); logger.info("Resuming radio bearer %s", rrc->get_rb_name(lcid).c_str());
if (valid_lcid(lcid)) { if (valid_lcid(lcid)) {
if (rlc_array.at(lcid)->resume()) { if (rlc_array.at(lcid)->resume()) {
rlc_log->info("Resumed radio bearer %s\n", rrc->get_rb_name(lcid).c_str()); logger.info("Resumed radio bearer %s", rrc->get_rb_name(lcid).c_str());
} else { } else {
rlc_log->error("Error resuming RLC entity: bearer not suspended\n."); logger.error("Error resuming RLC entity: bearer not suspended.");
} }
} else { } else {
rlc_log->error("Resuming bearer: bearer %s not configured.\n", rrc->get_rb_name(lcid).c_str()); logger.error("Resuming bearer: bearer %s not configured.", rrc->get_rb_name(lcid).c_str());
} }
} }
@ -589,7 +589,7 @@ bool rlc::has_bearer(uint32_t lcid)
bool rlc::valid_lcid(uint32_t lcid) bool rlc::valid_lcid(uint32_t lcid)
{ {
if (lcid >= SRSLTE_N_RADIO_BEARERS) { if (lcid >= SRSLTE_N_RADIO_BEARERS) {
rlc_log->error("Radio bearer id must be in [0:%d] - %d\n", SRSLTE_N_RADIO_BEARERS, lcid); logger.error("Radio bearer id must be in [0:%d] - %d", SRSLTE_N_RADIO_BEARERS, lcid);
return false; return false;
} }
@ -603,7 +603,7 @@ bool rlc::valid_lcid(uint32_t lcid)
bool rlc::valid_lcid_mrb(uint32_t lcid) bool rlc::valid_lcid_mrb(uint32_t lcid)
{ {
if (lcid >= SRSLTE_N_MCH_LCIDS) { if (lcid >= SRSLTE_N_MCH_LCIDS) {
rlc_log->error("Radio bearer id must be in [0:%d] - %d\n", SRSLTE_N_RADIO_BEARERS, lcid); logger.error("Radio bearer id must be in [0:%d] - %d", SRSLTE_N_RADIO_BEARERS, lcid);
return false; return false;
} }

File diff suppressed because it is too large Load Diff

@ -14,8 +14,11 @@
namespace srslte { namespace srslte {
rlc_tm::rlc_tm(srslte::log_ref log_, uint32_t lcid_, srsue::pdcp_interface_rlc* pdcp_, srsue::rrc_interface_rlc* rrc_) : rlc_tm::rlc_tm(srslog::basic_logger& logger,
log(log_), pdcp(pdcp_), rrc(rrc_), lcid(lcid_) uint32_t lcid_,
srsue::pdcp_interface_rlc* pdcp_,
srsue::rrc_interface_rlc* rrc_) :
logger(logger), pdcp(pdcp_), rrc(rrc_), lcid(lcid_)
{ {
pool = byte_buffer_pool::get_instance(); pool = byte_buffer_pool::get_instance();
} }
@ -28,7 +31,7 @@ rlc_tm::~rlc_tm()
bool rlc_tm::configure(const rlc_config_t& cnfg) bool rlc_tm::configure(const rlc_config_t& cnfg)
{ {
log->error("Attempted to configure TM RLC entity\n"); logger.error("Attempted to configure TM RLC entity");
return true; return true;
} }
@ -74,23 +77,23 @@ void rlc_tm::write_sdu(unique_byte_buffer_t sdu)
uint32_t nof_bytes = sdu->N_bytes; uint32_t nof_bytes = sdu->N_bytes;
srslte::error_type<unique_byte_buffer_t> ret = ul_queue.try_write(std::move(sdu)); srslte::error_type<unique_byte_buffer_t> ret = ul_queue.try_write(std::move(sdu));
if (ret) { if (ret) {
log->info_hex(msg_ptr, logger.info(msg_ptr,
nof_bytes, nof_bytes,
"%s Tx SDU, queue size=%d, bytes=%d", "%s Tx SDU, queue size=%d, bytes=%d",
rrc->get_rb_name(lcid).c_str(), rrc->get_rb_name(lcid).c_str(),
ul_queue.size(), ul_queue.size(),
ul_queue.size_bytes()); ul_queue.size_bytes());
} else { } else {
log->warning_hex(ret.error()->msg, logger.warning(ret.error()->msg,
ret.error()->N_bytes, ret.error()->N_bytes,
"[Dropped SDU] %s Tx SDU, queue size=%d, bytes=%d", "[Dropped SDU] %s Tx SDU, queue size=%d, bytes=%d",
rrc->get_rb_name(lcid).c_str(), rrc->get_rb_name(lcid).c_str(),
ul_queue.size(), ul_queue.size(),
ul_queue.size_bytes()); ul_queue.size_bytes());
} }
} else { } else {
log->warning("NULL SDU pointer in write_sdu()\n"); logger.warning("NULL SDU pointer in write_sdu()");
} }
} }
@ -99,7 +102,7 @@ void rlc_tm::discard_sdu(uint32_t discard_sn)
if (!tx_enabled) { if (!tx_enabled) {
return; return;
} }
log->warning("SDU discard not implemented on RLC TM\n"); logger.warning("SDU discard not implemented on RLC TM");
} }
bool rlc_tm::sdu_queue_is_full() bool rlc_tm::sdu_queue_is_full()
@ -132,31 +135,31 @@ int rlc_tm::read_pdu(uint8_t* payload, uint32_t nof_bytes)
{ {
uint32_t pdu_size = ul_queue.size_tail_bytes(); uint32_t pdu_size = ul_queue.size_tail_bytes();
if (pdu_size > nof_bytes) { if (pdu_size > nof_bytes) {
log->info( logger.info(
"%s Tx PDU size larger than MAC opportunity (%d > %d)\n", rrc->get_rb_name(lcid).c_str(), pdu_size, nof_bytes); "%s Tx PDU size larger than MAC opportunity (%d > %d)", rrc->get_rb_name(lcid).c_str(), pdu_size, nof_bytes);
return -1; return -1;
} }
unique_byte_buffer_t buf; unique_byte_buffer_t buf;
if (ul_queue.try_read(&buf)) { if (ul_queue.try_read(&buf)) {
pdu_size = buf->N_bytes; pdu_size = buf->N_bytes;
memcpy(payload, buf->msg, buf->N_bytes); memcpy(payload, buf->msg, buf->N_bytes);
log->debug("%s Complete SDU scheduled for tx. Stack latency: %" PRIu64 " us\n", logger.debug("%s Complete SDU scheduled for tx. Stack latency: %" PRIu64 " us",
rrc->get_rb_name(lcid).c_str(), rrc->get_rb_name(lcid).c_str(),
(uint64_t)buf->get_latency_us().count()); (uint64_t)buf->get_latency_us().count());
log->info_hex(payload, logger.info(payload,
pdu_size, pdu_size,
"%s Tx %s PDU, queue size=%d, bytes=%d", "%s Tx %s PDU, queue size=%d, bytes=%d",
rrc->get_rb_name(lcid).c_str(), rrc->get_rb_name(lcid).c_str(),
srslte::to_string(rlc_mode_t::tm).c_str(), srslte::to_string(rlc_mode_t::tm).c_str(),
ul_queue.size(), ul_queue.size(),
ul_queue.size_bytes()); ul_queue.size_bytes());
metrics.num_tx_pdu_bytes += pdu_size; metrics.num_tx_pdu_bytes += pdu_size;
return pdu_size; return pdu_size;
} else { } else {
log->warning("Queue empty while trying to read\n"); logger.warning("Queue empty while trying to read");
if (ul_queue.size_bytes() > 0) { if (ul_queue.size_bytes() > 0) {
log->warning("Corrupted queue: empty but size_bytes > 0. Resetting queue\n"); logger.warning("Corrupted queue: empty but size_bytes > 0. Resetting queue");
ul_queue.reset(); ul_queue.reset();
} }
return 0; return 0;
@ -178,7 +181,7 @@ void rlc_tm::write_pdu(uint8_t* payload, uint32_t nof_bytes)
pdcp->write_pdu(lcid, std::move(buf)); pdcp->write_pdu(lcid, std::move(buf));
} }
} else { } else {
log->error("Fatal Error: Couldn't allocate buffer in rlc_tm::write_pdu().\n"); logger.error("Fatal Error: Couldn't allocate buffer in rlc_tm::write_pdu().");
} }
} }

@ -15,12 +15,12 @@
namespace srslte { namespace srslte {
rlc_um_base::rlc_um_base(srslte::log_ref log_, rlc_um_base::rlc_um_base(srslog::basic_logger& logger,
uint32_t lcid_, uint32_t lcid_,
srsue::pdcp_interface_rlc* pdcp_, srsue::pdcp_interface_rlc* pdcp_,
srsue::rrc_interface_rlc* rrc_, srsue::rrc_interface_rlc* rrc_,
srslte::timer_handler* timers_) : srslte::timer_handler* timers_) :
log(log_), lcid(lcid_), pdcp(pdcp_), rrc(rrc_), timers(timers_), pool(byte_buffer_pool::get_instance()) logger(logger), lcid(lcid_), pdcp(pdcp_), rrc(rrc_), timers(timers_), pool(byte_buffer_pool::get_instance())
{} {}
rlc_um_base::~rlc_um_base() {} rlc_um_base::~rlc_um_base() {}
@ -80,7 +80,7 @@ void rlc_um_base::empty_queue()
void rlc_um_base::write_sdu(unique_byte_buffer_t sdu) void rlc_um_base::write_sdu(unique_byte_buffer_t sdu)
{ {
if (not tx_enabled || not tx) { if (not tx_enabled || not tx) {
log->debug("%s is currently deactivated. Dropping SDU (%d B)\n", rb_name.c_str(), sdu->N_bytes); logger.debug("%s is currently deactivated. Dropping SDU (%d B)", rb_name.c_str(), sdu->N_bytes);
metrics.num_lost_sdus++; metrics.num_lost_sdus++;
return; return;
} }
@ -97,7 +97,7 @@ void rlc_um_base::write_sdu(unique_byte_buffer_t sdu)
void rlc_um_base::discard_sdu(uint32_t discard_sn) void rlc_um_base::discard_sdu(uint32_t discard_sn)
{ {
if (not tx_enabled || not tx) { if (not tx_enabled || not tx) {
log->debug("%s is currently deactivated. Ignoring SDU discard (SN=%u)\n", rb_name.c_str(), discard_sn); logger.debug("%s is currently deactivated. Ignoring SDU discard (SN=%u)", rb_name.c_str(), discard_sn);
return; return;
} }
tx->discard_sdu(discard_sn); tx->discard_sdu(discard_sn);
@ -182,7 +182,7 @@ std::string rlc_um_base::get_rb_name(srsue::rrc_interface_rlc* rrc, uint32_t lci
rlc_um_base::rlc_um_base_rx::rlc_um_base_rx(rlc_um_base* parent_) : rlc_um_base::rlc_um_base_rx::rlc_um_base_rx(rlc_um_base* parent_) :
pool(parent_->pool), pool(parent_->pool),
log(parent_->log), logger(parent_->logger),
timers(parent_->timers), timers(parent_->timers),
pdcp(parent_->pdcp), pdcp(parent_->pdcp),
rrc(parent_->rrc), rrc(parent_->rrc),
@ -198,7 +198,7 @@ rlc_um_base::rlc_um_base_rx::~rlc_um_base_rx() {}
***************************************************************************/ ***************************************************************************/
rlc_um_base::rlc_um_base_tx::rlc_um_base_tx(rlc_um_base* parent_) : rlc_um_base::rlc_um_base_tx::rlc_um_base_tx(rlc_um_base* parent_) :
log(parent_->log), pool(parent_->pool), parent(parent_) logger(parent_->logger), pool(parent_->pool), parent(parent_)
{} {}
rlc_um_base::rlc_um_base_tx::~rlc_um_base_tx() {} rlc_um_base::rlc_um_base_tx::~rlc_um_base_tx() {}
@ -236,15 +236,15 @@ bool rlc_um_base::rlc_um_base_tx::has_data()
void rlc_um_base::rlc_um_base_tx::write_sdu(unique_byte_buffer_t sdu) void rlc_um_base::rlc_um_base_tx::write_sdu(unique_byte_buffer_t sdu)
{ {
if (sdu) { if (sdu) {
log->info_hex(sdu->msg, logger.info(sdu->msg,
sdu->N_bytes, sdu->N_bytes,
"%s Tx SDU (%d B, tx_sdu_queue_len=%d)", "%s Tx SDU (%d B, tx_sdu_queue_len=%d)",
rb_name.c_str(), rb_name.c_str(),
sdu->N_bytes, sdu->N_bytes,
tx_sdu_queue.size()); tx_sdu_queue.size());
tx_sdu_queue.write(std::move(sdu)); tx_sdu_queue.write(std::move(sdu));
} else { } else {
log->warning("NULL SDU pointer in write_sdu()\n"); logger.warning("NULL SDU pointer in write_sdu()");
} }
} }
@ -255,26 +255,26 @@ int rlc_um_base::rlc_um_base_tx::try_write_sdu(unique_byte_buffer_t sdu)
uint32_t nof_bytes = sdu->N_bytes; uint32_t nof_bytes = sdu->N_bytes;
srslte::error_type<unique_byte_buffer_t> ret = tx_sdu_queue.try_write(std::move(sdu)); srslte::error_type<unique_byte_buffer_t> ret = tx_sdu_queue.try_write(std::move(sdu));
if (ret) { if (ret) {
log->info_hex( logger.info(
msg_ptr, nof_bytes, "%s Tx SDU (%d B, tx_sdu_queue_len=%d)", rb_name.c_str(), nof_bytes, tx_sdu_queue.size()); msg_ptr, nof_bytes, "%s Tx SDU (%d B, tx_sdu_queue_len=%d)", rb_name.c_str(), nof_bytes, tx_sdu_queue.size());
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
} else { } else {
log->warning_hex(ret.error()->msg, logger.warning(ret.error()->msg,
ret.error()->N_bytes, ret.error()->N_bytes,
"[Dropped SDU] %s Tx SDU (%d B, tx_sdu_queue_len=%d)", "[Dropped SDU] %s Tx SDU (%d B, tx_sdu_queue_len=%d)",
rb_name.c_str(), rb_name.c_str(),
ret.error()->N_bytes, ret.error()->N_bytes,
tx_sdu_queue.size()); tx_sdu_queue.size());
} }
} else { } else {
log->warning("NULL SDU pointer in write_sdu()\n"); logger.warning("NULL SDU pointer in write_sdu()");
} }
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
void rlc_um_base::rlc_um_base_tx::discard_sdu(uint32_t discard_sn) void rlc_um_base::rlc_um_base_tx::discard_sdu(uint32_t discard_sn)
{ {
log->warning("RLC UM: Discard SDU not implemented yet.\n"); logger.warning("RLC UM: Discard SDU not implemented yet.");
} }
bool rlc_um_base::rlc_um_base_tx::sdu_queue_is_full() bool rlc_um_base::rlc_um_base_tx::sdu_queue_is_full()
@ -287,16 +287,16 @@ int rlc_um_base::rlc_um_base_tx::build_data_pdu(uint8_t* payload, uint32_t nof_b
unique_byte_buffer_t pdu; unique_byte_buffer_t pdu;
{ {
std::lock_guard<std::mutex> lock(mutex); std::lock_guard<std::mutex> lock(mutex);
log->debug("MAC opportunity - %d bytes\n", nof_bytes); logger.debug("MAC opportunity - %d bytes", nof_bytes);
if (tx_sdu == nullptr && tx_sdu_queue.is_empty()) { if (tx_sdu == nullptr && tx_sdu_queue.is_empty()) {
log->info("No data available to be sent\n"); logger.info("No data available to be sent");
return 0; return 0;
} }
pdu = make_byte_buffer(); pdu = make_byte_buffer();
if (!pdu || pdu->N_bytes != 0) { if (!pdu || pdu->N_bytes != 0) {
log->error("Failed to allocate PDU buffer\n"); logger.error("Failed to allocate PDU buffer");
return 0; return 0;
} }
} }

@ -17,12 +17,12 @@
namespace srslte { namespace srslte {
rlc_um_lte::rlc_um_lte(srslte::log_ref log_, rlc_um_lte::rlc_um_lte(srslog::basic_logger& logger,
uint32_t lcid_, uint32_t lcid_,
srsue::pdcp_interface_rlc* pdcp_, srsue::pdcp_interface_rlc* pdcp_,
srsue::rrc_interface_rlc* rrc_, srsue::rrc_interface_rlc* rrc_,
srslte::timer_handler* timers_) : srslte::timer_handler* timers_) :
rlc_um_base(log_, lcid_, pdcp_, rrc_, timers_) rlc_um_base(logger, lcid_, pdcp_, rrc_, timers_)
{} {}
// Warning: must call stop() to properly deallocate all buffers // Warning: must call stop() to properly deallocate all buffers
@ -49,12 +49,12 @@ bool rlc_um_lte::configure(const rlc_config_t& cnfg_)
return false; return false;
} }
log->info("%s configured in %s: t_reordering=%d ms, rx_sn_field_length=%u bits, tx_sn_field_length=%u bits\n", logger.info("%s configured in %s: t_reordering=%d ms, rx_sn_field_length=%u bits, tx_sn_field_length=%u bits",
rb_name.c_str(), rb_name.c_str(),
srslte::to_string(cnfg_.rlc_mode).c_str(), srslte::to_string(cnfg_.rlc_mode).c_str(),
cfg.um.t_reordering, cfg.um.t_reordering,
srslte::to_number(cfg.um.rx_sn_field_length), srslte::to_number(cfg.um.rx_sn_field_length),
srslte::to_number(cfg.um.tx_sn_field_length)); srslte::to_number(cfg.um.tx_sn_field_length));
rx_enabled = true; rx_enabled = true;
tx_enabled = true; tx_enabled = true;
@ -97,7 +97,7 @@ bool rlc_um_lte::rlc_um_lte_tx::configure(const rlc_config_t& cnfg_, std::string
cfg = cnfg_; cfg = cnfg_;
if (cfg.um.tx_mod == 0) { if (cfg.um.tx_mod == 0) {
log->error("Error configuring %s RLC UM: tx_mod==0\n", rb_name.c_str()); logger.error("Error configuring %s RLC UM: tx_mod==0", rb_name.c_str());
return false; return false;
} }
@ -125,10 +125,10 @@ int rlc_um_lte::rlc_um_lte_tx::build_data_pdu(unique_byte_buffer_t pdu, uint8_t*
int pdu_space = SRSLTE_MIN(nof_bytes, pdu->get_tailroom()); int pdu_space = SRSLTE_MIN(nof_bytes, pdu->get_tailroom());
if (pdu_space <= head_len + 1) { if (pdu_space <= head_len + 1) {
log->info("%s Cannot build a PDU - %d bytes available, %d bytes required for header\n", logger.info("%s Cannot build a PDU - %d bytes available, %d bytes required for header",
rb_name.c_str(), rb_name.c_str(),
nof_bytes, nof_bytes,
head_len); head_len);
return 0; return 0;
} }
@ -136,8 +136,8 @@ int rlc_um_lte::rlc_um_lte_tx::build_data_pdu(unique_byte_buffer_t pdu, uint8_t*
if (tx_sdu) { if (tx_sdu) {
uint32_t space = pdu_space - head_len; uint32_t space = pdu_space - head_len;
to_move = space >= tx_sdu->N_bytes ? tx_sdu->N_bytes : space; to_move = space >= tx_sdu->N_bytes ? tx_sdu->N_bytes : space;
log->debug( logger.debug(
"%s adding remainder of SDU segment - %d bytes of %d remaining\n", rb_name.c_str(), to_move, tx_sdu->N_bytes); "%s adding remainder of SDU segment - %d bytes of %d remaining", rb_name.c_str(), to_move, tx_sdu->N_bytes);
memcpy(pdu_ptr, tx_sdu->msg, to_move); memcpy(pdu_ptr, tx_sdu->msg, to_move);
last_li = to_move; last_li = to_move;
pdu_ptr += to_move; pdu_ptr += to_move;
@ -148,12 +148,12 @@ int rlc_um_lte::rlc_um_lte_tx::build_data_pdu(unique_byte_buffer_t pdu, uint8_t*
#ifdef ENABLE_TIMESTAMP #ifdef ENABLE_TIMESTAMP
auto latency_us = tx_sdu->get_latency_us().count(); auto latency_us = tx_sdu->get_latency_us().count();
mean_pdu_latency_us.push(latency_us); mean_pdu_latency_us.push(latency_us);
log->debug("%s Complete SDU scheduled for tx. Stack latency (last/average): %" PRIu64 "/%ld us\n", logger.debug("%s Complete SDU scheduled for tx. Stack latency (last/average): %" PRIu64 "/%ld us",
rb_name.c_str(), rb_name.c_str(),
(uint64_t)latency_us, (uint64_t)latency_us,
(long)mean_pdu_latency_us.value()); (long)mean_pdu_latency_us.value());
#else #else
log->debug("%s Complete SDU scheduled for tx.\n", rb_name.c_str()); logger.debug("%s Complete SDU scheduled for tx.", rb_name.c_str());
#endif #endif
tx_sdu.reset(); tx_sdu.reset();
} }
@ -163,7 +163,7 @@ int rlc_um_lte::rlc_um_lte_tx::build_data_pdu(unique_byte_buffer_t pdu, uint8_t*
// Pull SDUs from queue // Pull SDUs from queue
while (pdu_space > head_len + 1 && tx_sdu_queue.size() > 0) { while (pdu_space > head_len + 1 && tx_sdu_queue.size() > 0) {
log->debug("pdu_space=%d, head_len=%d\n", pdu_space, head_len); logger.debug("pdu_space=%d, head_len=%d", pdu_space, head_len);
if (last_li > 0) { if (last_li > 0) {
header.li[header.N_li++] = last_li; header.li[header.N_li++] = last_li;
} }
@ -176,7 +176,7 @@ int rlc_um_lte::rlc_um_lte_tx::build_data_pdu(unique_byte_buffer_t pdu, uint8_t*
} }
tx_sdu = tx_sdu_queue.read(); tx_sdu = tx_sdu_queue.read();
to_move = (space >= tx_sdu->N_bytes) ? tx_sdu->N_bytes : space; to_move = (space >= tx_sdu->N_bytes) ? tx_sdu->N_bytes : space;
log->debug("%s adding new SDU segment - %d bytes of %d remaining\n", rb_name.c_str(), to_move, tx_sdu->N_bytes); logger.debug("%s adding new SDU segment - %d bytes of %d remaining", rb_name.c_str(), to_move, tx_sdu->N_bytes);
memcpy(pdu_ptr, tx_sdu->msg, to_move); memcpy(pdu_ptr, tx_sdu->msg, to_move);
last_li = to_move; last_li = to_move;
pdu_ptr += to_move; pdu_ptr += to_move;
@ -187,12 +187,12 @@ int rlc_um_lte::rlc_um_lte_tx::build_data_pdu(unique_byte_buffer_t pdu, uint8_t*
#ifdef ENABLE_TIMESTAMP #ifdef ENABLE_TIMESTAMP
auto latency_us = tx_sdu->get_latency_us().count(); auto latency_us = tx_sdu->get_latency_us().count();
mean_pdu_latency_us.push(latency_us); mean_pdu_latency_us.push(latency_us);
log->debug("%s Complete SDU scheduled for tx. Stack latency (last/average): %" PRIu64 "/%ld us\n", logger.debug("%s Complete SDU scheduled for tx. Stack latency (last/average): %" PRIu64 "/%ld us",
rb_name.c_str(), rb_name.c_str(),
(uint64_t)latency_us, (uint64_t)latency_us,
(long)mean_pdu_latency_us.value()); (long)mean_pdu_latency_us.value());
#else #else
log->debug("%s Complete SDU scheduled for tx.\n", rb_name.c_str()); logger.debug("%s Complete SDU scheduled for tx.", rb_name.c_str());
#endif #endif
tx_sdu.reset(); tx_sdu.reset();
} }
@ -211,7 +211,7 @@ int rlc_um_lte::rlc_um_lte_tx::build_data_pdu(unique_byte_buffer_t pdu, uint8_t*
rlc_um_write_data_pdu_header(&header, pdu.get()); rlc_um_write_data_pdu_header(&header, pdu.get());
memcpy(payload, pdu->msg, pdu->N_bytes); memcpy(payload, pdu->msg, pdu->N_bytes);
log->info_hex(payload, pdu->N_bytes, "%s Tx PDU SN=%d (%d B)\n", rb_name.c_str(), header.sn, pdu->N_bytes); logger.info(payload, pdu->N_bytes, "%s Tx PDU SN=%d (%d B)", rb_name.c_str(), header.sn, pdu->N_bytes);
debug_state(); debug_state();
@ -220,7 +220,7 @@ int rlc_um_lte::rlc_um_lte_tx::build_data_pdu(unique_byte_buffer_t pdu, uint8_t*
void rlc_um_lte::rlc_um_lte_tx::debug_state() void rlc_um_lte::rlc_um_lte_tx::debug_state()
{ {
log->debug("%s vt_us = %d\n", rb_name.c_str(), vt_us); logger.debug("%s vt_us = %d", rb_name.c_str(), vt_us);
} }
void rlc_um_lte::rlc_um_lte_tx::reset() void rlc_um_lte::rlc_um_lte_tx::reset()
@ -243,13 +243,13 @@ bool rlc_um_lte::rlc_um_lte_rx::configure(const rlc_config_t& cnfg_, std::string
cfg = cnfg_; cfg = cnfg_;
if (cfg.um.rx_mod == 0) { if (cfg.um.rx_mod == 0) {
log->error("Error configuring %s RLC UM: rx_mod==0\n", rb_name.c_str()); logger.error("Error configuring %s RLC UM: rx_mod==0", rb_name.c_str());
return false; return false;
} }
// check timer // check timer
if (not reordering_timer.is_valid()) { if (not reordering_timer.is_valid()) {
log->error("Configuring RLC UM RX: timers not configured\n"); logger.error("Configuring RLC UM RX: timers not configured");
return false; return false;
} }
@ -298,17 +298,17 @@ void rlc_um_lte::rlc_um_lte_rx::handle_data_pdu(uint8_t* payload, uint32_t nof_b
{ {
rlc_umd_pdu_header_t header; rlc_umd_pdu_header_t header;
rlc_um_read_data_pdu_header(payload, nof_bytes, cfg.um.rx_sn_field_length, &header); rlc_um_read_data_pdu_header(payload, nof_bytes, cfg.um.rx_sn_field_length, &header);
log->info_hex(payload, nof_bytes, "%s Rx data PDU SN=%d (%d B)", rb_name.c_str(), header.sn, nof_bytes); logger.info(payload, nof_bytes, "%s Rx data PDU SN=%d (%d B)", rb_name.c_str(), header.sn, nof_bytes);
if (RX_MOD_BASE(header.sn) >= RX_MOD_BASE(vr_uh - cfg.um.rx_window_size) && if (RX_MOD_BASE(header.sn) >= RX_MOD_BASE(vr_uh - cfg.um.rx_window_size) &&
RX_MOD_BASE(header.sn) < RX_MOD_BASE(vr_ur)) { RX_MOD_BASE(header.sn) < RX_MOD_BASE(vr_ur)) {
log->info("%s SN=%d outside rx window [%d:%d] - discarding\n", rb_name.c_str(), header.sn, vr_ur, vr_uh); logger.info("%s SN=%d outside rx window [%d:%d] - discarding", rb_name.c_str(), header.sn, vr_ur, vr_uh);
return; return;
} }
std::map<uint32_t, rlc_umd_pdu_t>::iterator it = rx_window.find(header.sn); std::map<uint32_t, rlc_umd_pdu_t>::iterator it = rx_window.find(header.sn);
if (rx_window.end() != it) { if (rx_window.end() != it) {
log->info("%s Discarding duplicate SN=%d\n", rb_name.c_str(), header.sn); logger.info("%s Discarding duplicate SN=%d", rb_name.c_str(), header.sn);
return; return;
} }
@ -316,7 +316,7 @@ void rlc_um_lte::rlc_um_lte_rx::handle_data_pdu(uint8_t* payload, uint32_t nof_b
rlc_umd_pdu_t pdu = {}; rlc_umd_pdu_t pdu = {};
pdu.buf = make_byte_buffer(); pdu.buf = make_byte_buffer();
if (!pdu.buf) { if (!pdu.buf) {
log->error("Discarting packet: no space in buffer pool\n"); logger.error("Discarting packet: no space in buffer pool");
return; return;
} }
memcpy(pdu.buf->msg, payload, nof_bytes); memcpy(pdu.buf->msg, payload, nof_bytes);
@ -334,9 +334,9 @@ void rlc_um_lte::rlc_um_lte_rx::handle_data_pdu(uint8_t* payload, uint32_t nof_b
} }
// Reassemble and deliver SDUs, while updating vr_ur // Reassemble and deliver SDUs, while updating vr_ur
log->debug("Entering Reassemble from received PDU\n"); logger.debug("Entering Reassemble from received PDU");
reassemble_rx_sdus(); reassemble_rx_sdus();
log->debug("Finished reassemble from received PDU\n"); logger.debug("Finished reassemble from received PDU");
// Update reordering variables and timers // Update reordering variables and timers
if (reordering_timer.is_running()) { if (reordering_timer.is_running()) {
@ -360,32 +360,32 @@ void rlc_um_lte::rlc_um_lte_rx::reassemble_rx_sdus()
if (!rx_sdu) { if (!rx_sdu) {
rx_sdu = make_byte_buffer(); rx_sdu = make_byte_buffer();
if (!rx_sdu) { if (!rx_sdu) {
log->error("Fatal Error: Couldn't allocate buffer in rlc_um::reassemble_rx_sdus().\n"); logger.error("Fatal Error: Couldn't allocate buffer in rlc_um::reassemble_rx_sdus().");
return; return;
} }
} }
// First catch up with lower edge of reordering window // First catch up with lower edge of reordering window
while (!inside_reordering_window(vr_ur)) { while (!inside_reordering_window(vr_ur)) {
log->debug("SN=%d is not inside reordering windows\n", vr_ur); logger.debug("SN=%d is not inside reordering windows", vr_ur);
if (rx_window.end() == rx_window.find(vr_ur)) { if (rx_window.end() == rx_window.find(vr_ur)) {
log->debug("SN=%d not in rx_window. Reset received SDU\n", vr_ur); logger.debug("SN=%d not in rx_window. Reset received SDU", vr_ur);
rx_sdu->clear(); rx_sdu->clear();
} else { } else {
// Handle any SDU segments // Handle any SDU segments
for (uint32_t i = 0; i < rx_window[vr_ur].header.N_li; i++) { for (uint32_t i = 0; i < rx_window[vr_ur].header.N_li; i++) {
int len = rx_window[vr_ur].header.li[i]; int len = rx_window[vr_ur].header.li[i];
log->debug_hex(rx_window[vr_ur].buf->msg, logger.debug(rx_window[vr_ur].buf->msg,
len, len,
"Handling segment %d/%d of length %d B of SN=%d\n", "Handling segment %d/%d of length %d B of SN=%d",
i + 1, i + 1,
rx_window[vr_ur].header.N_li, rx_window[vr_ur].header.N_li,
len, len,
vr_ur); vr_ur);
// Check if we received a middle or end segment // Check if we received a middle or end segment
if (rx_sdu->N_bytes == 0 && i == 0 && !rlc_um_start_aligned(rx_window[vr_ur].header.fi)) { if (rx_sdu->N_bytes == 0 && i == 0 && !rlc_um_start_aligned(rx_window[vr_ur].header.fi)) {
log->warning("Dropping PDU %d in reassembly due to lost start segment\n", vr_ur); logger.warning("Dropping PDU %d in reassembly due to lost start segment", vr_ur);
// Advance data pointers and continue with next segment // Advance data pointers and continue with next segment
rx_window[vr_ur].buf->msg += len; rx_window[vr_ur].buf->msg += len;
rx_window[vr_ur].buf->N_bytes -= len; rx_window[vr_ur].buf->N_bytes -= len;
@ -400,18 +400,18 @@ void rlc_um_lte::rlc_um_lte_rx::reassemble_rx_sdus()
rx_window[vr_ur].buf->N_bytes -= len; rx_window[vr_ur].buf->N_bytes -= len;
if ((pdu_lost && !rlc_um_start_aligned(rx_window[vr_ur].header.fi)) || if ((pdu_lost && !rlc_um_start_aligned(rx_window[vr_ur].header.fi)) ||
(vr_ur != ((vr_ur_in_rx_sdu + 1) % cfg.um.rx_mod))) { (vr_ur != ((vr_ur_in_rx_sdu + 1) % cfg.um.rx_mod))) {
log->warning("Dropping remainder of lost PDU (lower edge middle segments, vr_ur=%d, vr_ur_in_rx_sdu=%d)\n", logger.warning("Dropping remainder of lost PDU (lower edge middle segments, vr_ur=%d, vr_ur_in_rx_sdu=%d)",
vr_ur, vr_ur,
vr_ur_in_rx_sdu); vr_ur_in_rx_sdu);
rx_sdu->clear(); rx_sdu->clear();
metrics.num_lost_pdus++; metrics.num_lost_pdus++;
} else { } else {
log->info_hex(rx_sdu->msg, logger.info(rx_sdu->msg,
rx_sdu->N_bytes, rx_sdu->N_bytes,
"%s Rx SDU vr_ur=%d, i=%d (lower edge middle segments)", "%s Rx SDU vr_ur=%d, i=%d (lower edge middle segments)",
rb_name.c_str(), rb_name.c_str(),
vr_ur, vr_ur,
i); i);
rx_sdu->set_timestamp(); rx_sdu->set_timestamp();
metrics.num_rx_sdus++; metrics.num_rx_sdus++;
metrics.num_rx_sdu_bytes += rx_sdu->N_bytes; metrics.num_rx_sdu_bytes += rx_sdu->N_bytes;
@ -422,7 +422,7 @@ void rlc_um_lte::rlc_um_lte_rx::reassemble_rx_sdus()
} }
rx_sdu = make_byte_buffer(); rx_sdu = make_byte_buffer();
if (!rx_sdu) { if (!rx_sdu) {
log->error("Fatal Error: Couldn't allocate buffer in rlc_um::reassemble_rx_sdus().\n"); logger.error("Fatal Error: Couldn't allocate buffer in rlc_um::reassemble_rx_sdus().");
return; return;
} }
} }
@ -431,21 +431,21 @@ void rlc_um_lte::rlc_um_lte_rx::reassemble_rx_sdus()
// Handle last segment // Handle last segment
if (rx_sdu->N_bytes > 0 || rlc_um_start_aligned(rx_window[vr_ur].header.fi)) { if (rx_sdu->N_bytes > 0 || rlc_um_start_aligned(rx_window[vr_ur].header.fi)) {
log->info("Writing last segment in SDU buffer. Lower edge vr_ur=%d, Buffer size=%d, segment size=%d\n", logger.info("Writing last segment in SDU buffer. Lower edge vr_ur=%d, Buffer size=%d, segment size=%d",
vr_ur, vr_ur,
rx_sdu->N_bytes, rx_sdu->N_bytes,
rx_window[vr_ur].buf->N_bytes); rx_window[vr_ur].buf->N_bytes);
memcpy(&rx_sdu->msg[rx_sdu->N_bytes], rx_window[vr_ur].buf->msg, rx_window[vr_ur].buf->N_bytes); memcpy(&rx_sdu->msg[rx_sdu->N_bytes], rx_window[vr_ur].buf->msg, rx_window[vr_ur].buf->N_bytes);
rx_sdu->N_bytes += rx_window[vr_ur].buf->N_bytes; rx_sdu->N_bytes += rx_window[vr_ur].buf->N_bytes;
vr_ur_in_rx_sdu = vr_ur; vr_ur_in_rx_sdu = vr_ur;
if (rlc_um_end_aligned(rx_window[vr_ur].header.fi)) { if (rlc_um_end_aligned(rx_window[vr_ur].header.fi)) {
if (pdu_lost && !rlc_um_start_aligned(rx_window[vr_ur].header.fi)) { if (pdu_lost && !rlc_um_start_aligned(rx_window[vr_ur].header.fi)) {
log->warning("Dropping remainder of lost PDU (lower edge last segments)\n"); logger.warning("Dropping remainder of lost PDU (lower edge last segments)");
rx_sdu->clear(); rx_sdu->clear();
metrics.num_lost_pdus++; metrics.num_lost_pdus++;
} else { } else {
log->info_hex( logger.info(
rx_sdu->msg, rx_sdu->N_bytes, "%s Rx SDU vr_ur=%d (lower edge last segments)", rb_name.c_str(), vr_ur); rx_sdu->msg, rx_sdu->N_bytes, "%s Rx SDU vr_ur=%d (lower edge last segments)", rb_name.c_str(), vr_ur);
rx_sdu->set_timestamp(); rx_sdu->set_timestamp();
metrics.num_rx_sdus++; metrics.num_rx_sdus++;
@ -457,7 +457,7 @@ void rlc_um_lte::rlc_um_lte_rx::reassemble_rx_sdus()
} }
rx_sdu = make_byte_buffer(); rx_sdu = make_byte_buffer();
if (!rx_sdu) { if (!rx_sdu) {
log->error("Fatal Error: Couldn't allocate buffer in rlc_um::reassemble_rx_sdus().\n"); logger.error("Fatal Error: Couldn't allocate buffer in rlc_um::reassemble_rx_sdus().");
return; return;
} }
} }
@ -474,11 +474,11 @@ void rlc_um_lte::rlc_um_lte_rx::reassemble_rx_sdus()
// Now update vr_ur until we reach an SN we haven't yet received // Now update vr_ur until we reach an SN we haven't yet received
while (rx_window.end() != rx_window.find(vr_ur)) { while (rx_window.end() != rx_window.find(vr_ur)) {
log->debug("Reassemble loop for vr_ur=%d\n", vr_ur); logger.debug("Reassemble loop for vr_ur=%d", vr_ur);
if (not pdu_belongs_to_rx_sdu()) { if (not pdu_belongs_to_rx_sdu()) {
log->warning( logger.warning(
"PDU SN=%d lost, stop reassambling SDU (vr_ur_in_rx_sdu=%d)\n", vr_ur_in_rx_sdu + 1, vr_ur_in_rx_sdu); "PDU SN=%d lost, stop reassambling SDU (vr_ur_in_rx_sdu=%d)", vr_ur_in_rx_sdu + 1, vr_ur_in_rx_sdu);
pdu_lost = false; // Reset flag to not prevent reassembling of further segments pdu_lost = false; // Reset flag to not prevent reassembling of further segments
rx_sdu->clear(); rx_sdu->clear();
} }
@ -486,22 +486,22 @@ void rlc_um_lte::rlc_um_lte_rx::reassemble_rx_sdus()
// Handle any SDU segments // Handle any SDU segments
for (uint32_t i = 0; i < rx_window[vr_ur].header.N_li; i++) { for (uint32_t i = 0; i < rx_window[vr_ur].header.N_li; i++) {
uint16_t len = rx_window[vr_ur].header.li[i]; uint16_t len = rx_window[vr_ur].header.li[i];
log->debug("Handling SDU segment i=%d with len=%d of vr_ur=%d N_li=%d [%s]\n", logger.debug("Handling SDU segment i=%d with len=%d of vr_ur=%d N_li=%d [%s]",
i, i,
len, len,
vr_ur, vr_ur,
rx_window[vr_ur].header.N_li, rx_window[vr_ur].header.N_li,
rlc_fi_field_text[rx_window[vr_ur].header.fi]); rlc_fi_field_text[rx_window[vr_ur].header.fi]);
// Check if the first part of the PDU is a middle or end segment // Check if the first part of the PDU is a middle or end segment
if (rx_sdu->N_bytes == 0 && i == 0 && !rlc_um_start_aligned(rx_window[vr_ur].header.fi)) { if (rx_sdu->N_bytes == 0 && i == 0 && !rlc_um_start_aligned(rx_window[vr_ur].header.fi)) {
log->warning_hex( logger.warning(
rx_window[vr_ur].buf->msg, len, "Dropping first %d B of SN=%d due to lost start segment\n", len, vr_ur); rx_window[vr_ur].buf->msg, len, "Dropping first %d B of SN=%d due to lost start segment", len, vr_ur);
if (rx_window[vr_ur].buf->N_bytes < len) { if (rx_window[vr_ur].buf->N_bytes < len) {
log->error("Dropping remaining remainder of SN=%d too (N_bytes=%u < len=%d)\n", logger.error("Dropping remaining remainder of SN=%d too (N_bytes=%u < len=%d)",
vr_ur, vr_ur,
rx_window[vr_ur].buf->N_bytes, rx_window[vr_ur].buf->N_bytes,
len); len);
goto clean_up_rx_window; goto clean_up_rx_window;
} }
@ -518,31 +518,31 @@ void rlc_um_lte::rlc_um_lte_rx::reassemble_rx_sdus()
// Check available space in SDU // Check available space in SDU
if ((uint32_t)len > rx_sdu->get_tailroom()) { if ((uint32_t)len > rx_sdu->get_tailroom()) {
log->error("Dropping PDU %d due to buffer mis-alignment (current segment len %d B, received %d B)\n", logger.error("Dropping PDU %d due to buffer mis-alignment (current segment len %d B, received %d B)",
vr_ur, vr_ur,
rx_sdu->N_bytes, rx_sdu->N_bytes,
len); len);
rx_sdu->clear(); rx_sdu->clear();
metrics.num_lost_pdus++; metrics.num_lost_pdus++;
goto clean_up_rx_window; goto clean_up_rx_window;
} }
if (not pdu_belongs_to_rx_sdu()) { if (not pdu_belongs_to_rx_sdu()) {
log->info_hex(rx_window[vr_ur].buf->msg, len, "Copying first %d bytes of new SDU\n", len); logger.info(rx_window[vr_ur].buf->msg, len, "Copying first %d bytes of new SDU", len);
log->info("Updating vr_ur_in_rx_sdu. old=%d, new=%d\n", vr_ur_in_rx_sdu, vr_ur); logger.info("Updating vr_ur_in_rx_sdu. old=%d, new=%d", vr_ur_in_rx_sdu, vr_ur);
vr_ur_in_rx_sdu = vr_ur; vr_ur_in_rx_sdu = vr_ur;
} else { } else {
log->info_hex(rx_window[vr_ur].buf->msg, logger.info(rx_window[vr_ur].buf->msg,
len, len,
"Concatenating %d bytes in to current length %d. rx_window remaining bytes=%d, " "Concatenating %d bytes in to current length %d. rx_window remaining bytes=%d, "
"vr_ur_in_rx_sdu=%d, vr_ur=%d, rx_mod=%d, last_mod=%d\n", "vr_ur_in_rx_sdu=%d, vr_ur=%d, rx_mod=%d, last_mod=%d",
len, len,
rx_sdu->N_bytes, rx_sdu->N_bytes,
rx_window[vr_ur].buf->N_bytes, rx_window[vr_ur].buf->N_bytes,
vr_ur_in_rx_sdu, vr_ur_in_rx_sdu,
vr_ur, vr_ur,
cfg.um.rx_mod, cfg.um.rx_mod,
(vr_ur_in_rx_sdu + 1) % cfg.um.rx_mod); (vr_ur_in_rx_sdu + 1) % cfg.um.rx_mod);
} }
memcpy(&rx_sdu->msg[rx_sdu->N_bytes], rx_window[vr_ur].buf->msg, len); memcpy(&rx_sdu->msg[rx_sdu->N_bytes], rx_window[vr_ur].buf->msg, len);
@ -552,12 +552,12 @@ void rlc_um_lte::rlc_um_lte_rx::reassemble_rx_sdus()
vr_ur_in_rx_sdu = vr_ur; vr_ur_in_rx_sdu = vr_ur;
if (pdu_belongs_to_rx_sdu()) { if (pdu_belongs_to_rx_sdu()) {
log->info_hex(rx_sdu->msg, logger.info(rx_sdu->msg,
rx_sdu->N_bytes, rx_sdu->N_bytes,
"%s Rx SDU vr_ur=%d, i=%d, (update vr_ur middle segments)", "%s Rx SDU vr_ur=%d, i=%d, (update vr_ur middle segments)",
rb_name.c_str(), rb_name.c_str(),
vr_ur, vr_ur,
i); i);
rx_sdu->set_timestamp(); rx_sdu->set_timestamp();
metrics.num_rx_sdus++; metrics.num_rx_sdus++;
metrics.num_rx_sdu_bytes += rx_sdu->N_bytes; metrics.num_rx_sdu_bytes += rx_sdu->N_bytes;
@ -568,13 +568,13 @@ void rlc_um_lte::rlc_um_lte_rx::reassemble_rx_sdus()
} }
rx_sdu = make_byte_buffer(); rx_sdu = make_byte_buffer();
if (!rx_sdu) { if (!rx_sdu) {
log->error("Fatal Error: Couldn't allocate buffer in rlc_um::reassemble_rx_sdus().\n"); logger.error("Fatal Error: Couldn't allocate buffer in rlc_um::reassemble_rx_sdus().");
return; return;
} }
} else { } else {
log->warning("Dropping remainder of lost PDU (update vr_ur middle segments, vr_ur=%d, vr_ur_in_rx_sdu=%d)\n", logger.warning("Dropping remainder of lost PDU (update vr_ur middle segments, vr_ur=%d, vr_ur_in_rx_sdu=%d)",
vr_ur, vr_ur,
vr_ur_in_rx_sdu); vr_ur_in_rx_sdu);
// Advance data pointers and continue with next segment // Advance data pointers and continue with next segment
rx_window[vr_ur].buf->msg += len; rx_window[vr_ur].buf->msg += len;
rx_window[vr_ur].buf->N_bytes -= len; rx_window[vr_ur].buf->N_bytes -= len;
@ -586,7 +586,7 @@ void rlc_um_lte::rlc_um_lte_rx::reassemble_rx_sdus()
// Handle last segment // Handle last segment
if (rx_sdu->N_bytes == 0 && rx_window[vr_ur].header.N_li == 0 && if (rx_sdu->N_bytes == 0 && rx_window[vr_ur].header.N_li == 0 &&
!rlc_um_start_aligned(rx_window[vr_ur].header.fi)) { !rlc_um_start_aligned(rx_window[vr_ur].header.fi)) {
log->warning("Dropping PDU %d during last segment handling due to lost start segment\n", vr_ur); logger.warning("Dropping PDU %d during last segment handling due to lost start segment", vr_ur);
rx_sdu->clear(); rx_sdu->clear();
metrics.num_lost_pdus++; metrics.num_lost_pdus++;
goto clean_up_rx_window; goto clean_up_rx_window;
@ -595,30 +595,30 @@ void rlc_um_lte::rlc_um_lte_rx::reassemble_rx_sdus()
if (rx_sdu->N_bytes < SRSLTE_MAX_BUFFER_SIZE_BYTES && if (rx_sdu->N_bytes < SRSLTE_MAX_BUFFER_SIZE_BYTES &&
rx_window[vr_ur].buf->N_bytes < SRSLTE_MAX_BUFFER_SIZE_BYTES && rx_window[vr_ur].buf->N_bytes < SRSLTE_MAX_BUFFER_SIZE_BYTES &&
rx_window[vr_ur].buf->N_bytes + rx_sdu->N_bytes < SRSLTE_MAX_BUFFER_SIZE_BYTES) { rx_window[vr_ur].buf->N_bytes + rx_sdu->N_bytes < SRSLTE_MAX_BUFFER_SIZE_BYTES) {
log->info_hex(rx_window[vr_ur].buf->msg, logger.info(rx_window[vr_ur].buf->msg,
rx_window[vr_ur].buf->N_bytes, rx_window[vr_ur].buf->N_bytes,
"Writing last segment in SDU buffer. Updating vr_ur=%d, vr_ur_in_rx_sdu=%d, Buffer size=%d, " "Writing last segment in SDU buffer. Updating vr_ur=%d, vr_ur_in_rx_sdu=%d, Buffer size=%d, "
"segment size=%d\n", "segment size=%d",
vr_ur, vr_ur,
vr_ur_in_rx_sdu, vr_ur_in_rx_sdu,
rx_sdu->N_bytes, rx_sdu->N_bytes,
rx_window[vr_ur].buf->N_bytes); rx_window[vr_ur].buf->N_bytes);
memcpy(&rx_sdu->msg[rx_sdu->N_bytes], rx_window[vr_ur].buf->msg, rx_window[vr_ur].buf->N_bytes); memcpy(&rx_sdu->msg[rx_sdu->N_bytes], rx_window[vr_ur].buf->msg, rx_window[vr_ur].buf->N_bytes);
rx_sdu->N_bytes += rx_window[vr_ur].buf->N_bytes; rx_sdu->N_bytes += rx_window[vr_ur].buf->N_bytes;
} else { } else {
log->error("Out of bounds while reassembling SDU buffer in UM: sdu_len=%d, window_buffer_len=%d, vr_ur=%d\n", logger.error("Out of bounds while reassembling SDU buffer in UM: sdu_len=%d, window_buffer_len=%d, vr_ur=%d",
rx_sdu->N_bytes, rx_sdu->N_bytes,
rx_window[vr_ur].buf->N_bytes, rx_window[vr_ur].buf->N_bytes,
vr_ur); vr_ur);
} }
vr_ur_in_rx_sdu = vr_ur; vr_ur_in_rx_sdu = vr_ur;
if (rlc_um_end_aligned(rx_window[vr_ur].header.fi)) { if (rlc_um_end_aligned(rx_window[vr_ur].header.fi)) {
if (pdu_lost && !rlc_um_start_aligned(rx_window[vr_ur].header.fi)) { if (pdu_lost && !rlc_um_start_aligned(rx_window[vr_ur].header.fi)) {
log->warning("Dropping remainder of lost PDU (update vr_ur last segments)\n"); logger.warning("Dropping remainder of lost PDU (update vr_ur last segments)");
rx_sdu->clear(); rx_sdu->clear();
metrics.num_lost_pdus++; metrics.num_lost_pdus++;
} else { } else {
log->info_hex( logger.info(
rx_sdu->msg, rx_sdu->N_bytes, "%s Rx SDU vr_ur=%d (update vr_ur last segments)", rb_name.c_str(), vr_ur); rx_sdu->msg, rx_sdu->N_bytes, "%s Rx SDU vr_ur=%d (update vr_ur last segments)", rb_name.c_str(), vr_ur);
rx_sdu->set_timestamp(); rx_sdu->set_timestamp();
metrics.num_rx_sdus++; metrics.num_rx_sdus++;
@ -630,7 +630,7 @@ void rlc_um_lte::rlc_um_lte_rx::reassemble_rx_sdus()
} }
rx_sdu = make_byte_buffer(); rx_sdu = make_byte_buffer();
if (!rx_sdu) { if (!rx_sdu) {
log->error("Fatal Error: Couldn't allocate buffer in rlc_um::reassemble_rx_sdus().\n"); logger.error("Fatal Error: Couldn't allocate buffer in rlc_um::reassemble_rx_sdus().");
return; return;
} }
} }
@ -677,9 +677,9 @@ void rlc_um_lte::rlc_um_lte_rx::timer_expired(uint32_t timeout_id)
{ {
if (reordering_timer.id() == timeout_id) { if (reordering_timer.id() == timeout_id) {
// 36.322 v10 Section 5.1.2.2.4 // 36.322 v10 Section 5.1.2.2.4
log->info("%s reordering timeout expiry - updating vr_ur and reassembling\n", rb_name.c_str()); logger.info("%s reordering timeout expiry - updating vr_ur and reassembling", rb_name.c_str());
log->warning("Lost PDU SN=%d\n", vr_ur); logger.warning("Lost PDU SN=%d", vr_ur);
pdu_lost = true; pdu_lost = true;
if (rx_sdu != NULL) { if (rx_sdu != NULL) {
@ -688,9 +688,9 @@ void rlc_um_lte::rlc_um_lte_rx::timer_expired(uint32_t timeout_id)
while (RX_MOD_BASE(vr_ur) < RX_MOD_BASE(vr_ux)) { while (RX_MOD_BASE(vr_ur) < RX_MOD_BASE(vr_ux)) {
vr_ur = (vr_ur + 1) % cfg.um.rx_mod; vr_ur = (vr_ur + 1) % cfg.um.rx_mod;
log->debug("Entering Reassemble from timeout id=%d\n", timeout_id); logger.debug("Entering Reassemble from timeout id=%d", timeout_id);
reassemble_rx_sdus(); reassemble_rx_sdus();
log->debug("Finished reassemble from timeout id=%d\n", timeout_id); logger.debug("Finished reassemble from timeout id=%d", timeout_id);
} }
if (RX_MOD_BASE(vr_uh) > RX_MOD_BASE(vr_ur)) { if (RX_MOD_BASE(vr_uh) > RX_MOD_BASE(vr_ur)) {
@ -708,7 +708,7 @@ void rlc_um_lte::rlc_um_lte_rx::timer_expired(uint32_t timeout_id)
void rlc_um_lte::rlc_um_lte_rx::debug_state() void rlc_um_lte::rlc_um_lte_rx::debug_state()
{ {
log->debug("%s vr_ur = %d, vr_ux = %d, vr_uh = %d\n", rb_name.c_str(), vr_ur, vr_ux, vr_uh); logger.debug("%s vr_ur = %d, vr_ux = %d, vr_uh = %d", rb_name.c_str(), vr_ur, vr_ux, vr_uh);
} }
/**************************************************************************** /****************************************************************************

@ -17,12 +17,12 @@
namespace srslte { namespace srslte {
rlc_um_nr::rlc_um_nr(srslte::log_ref log_, rlc_um_nr::rlc_um_nr(srslog::basic_logger& logger,
uint32_t lcid_, uint32_t lcid_,
srsue::pdcp_interface_rlc* pdcp_, srsue::pdcp_interface_rlc* pdcp_,
srsue::rrc_interface_rlc* rrc_, srsue::rrc_interface_rlc* rrc_,
srslte::timer_handler* timers_) : srslte::timer_handler* timers_) :
rlc_um_base(log_, lcid_, pdcp_, rrc_, timers_) rlc_um_base(logger, lcid_, pdcp_, rrc_, timers_)
{} {}
rlc_um_nr::~rlc_um_nr() rlc_um_nr::~rlc_um_nr()
@ -48,10 +48,10 @@ bool rlc_um_nr::configure(const rlc_config_t& cnfg_)
return false; return false;
} }
log->info("%s configured in %s: sn_field_length=%u bits\n", logger.info("%s configured in %s: sn_field_length=%u bits",
rb_name.c_str(), rb_name.c_str(),
srslte::to_string(cnfg_.rlc_mode).c_str(), srslte::to_string(cnfg_.rlc_mode).c_str(),
srslte::to_number(cfg.um_nr.sn_field_length)); srslte::to_number(cfg.um_nr.sn_field_length));
rx_enabled = true; rx_enabled = true;
tx_enabled = true; tx_enabled = true;
@ -94,7 +94,7 @@ bool rlc_um_nr::rlc_um_nr_tx::configure(const rlc_config_t& cnfg_, std::string r
cfg = cnfg_; cfg = cnfg_;
if (cfg.um_nr.mod == 0) { if (cfg.um_nr.mod == 0) {
log->error("Error configuring %s RLC UM: tx_mod==0\n", rb_name.c_str()); logger.error("Error configuring %s RLC UM: tx_mod==0", rb_name.c_str());
return false; return false;
} }
@ -120,10 +120,10 @@ int rlc_um_nr::rlc_um_nr_tx::build_data_pdu(unique_byte_buffer_t pdu, uint8_t* p
int pdu_space = SRSLTE_MIN(nof_bytes, pdu->get_tailroom()); int pdu_space = SRSLTE_MIN(nof_bytes, pdu->get_tailroom());
if (pdu_space <= head_len + 1) { if (pdu_space <= head_len + 1) {
log->warning("%s Cannot build a PDU - %d bytes available, %d bytes required for header\n", logger.warning("%s Cannot build a PDU - %d bytes available, %d bytes required for header",
rb_name.c_str(), rb_name.c_str(),
nof_bytes, nof_bytes,
head_len); head_len);
return 0; return 0;
} }
@ -131,17 +131,16 @@ int rlc_um_nr::rlc_um_nr_tx::build_data_pdu(unique_byte_buffer_t pdu, uint8_t* p
if (tx_sdu) { if (tx_sdu) {
uint32_t space = pdu_space - head_len; uint32_t space = pdu_space - head_len;
to_move = space >= tx_sdu->N_bytes ? tx_sdu->N_bytes : space; to_move = space >= tx_sdu->N_bytes ? tx_sdu->N_bytes : space;
log->debug( logger.debug(
"%s adding remainder of SDU segment - %d bytes of %d remaining\n", rb_name.c_str(), to_move, tx_sdu->N_bytes); "%s adding remainder of SDU segment - %d bytes of %d remaining", rb_name.c_str(), to_move, tx_sdu->N_bytes);
memcpy(pdu_ptr, tx_sdu->msg, to_move); memcpy(pdu_ptr, tx_sdu->msg, to_move);
pdu_ptr += to_move; pdu_ptr += to_move;
pdu->N_bytes += to_move; pdu->N_bytes += to_move;
tx_sdu->N_bytes -= to_move; tx_sdu->N_bytes -= to_move;
tx_sdu->msg += to_move; tx_sdu->msg += to_move;
if (tx_sdu->N_bytes == 0) { if (tx_sdu->N_bytes == 0) {
log->debug("%s Complete SDU scheduled for tx. Stack latency: %ld us\n", logger.debug(
rb_name.c_str(), "%s Complete SDU scheduled for tx. Stack latency: %ld us", rb_name.c_str(), tx_sdu->get_latency_us().count());
tx_sdu->get_latency_us().count());
tx_sdu.reset(); tx_sdu.reset();
header.si = rlc_nr_si_field_t::last_segment; header.si = rlc_nr_si_field_t::last_segment;
} else { } else {
@ -151,22 +150,21 @@ int rlc_um_nr::rlc_um_nr_tx::build_data_pdu(unique_byte_buffer_t pdu, uint8_t* p
header.so = next_so; header.so = next_so;
} else { } else {
// Pull SDU from queue // Pull SDU from queue
log->debug("pdu_space=%d, head_len=%d\n", pdu_space, head_len); logger.debug("pdu_space=%d, head_len=%d", pdu_space, head_len);
head_len = rlc_um_nr_packed_length(header); head_len = rlc_um_nr_packed_length(header);
tx_sdu = tx_sdu_queue.read(); tx_sdu = tx_sdu_queue.read();
uint32_t space = pdu_space - head_len; uint32_t space = pdu_space - head_len;
to_move = space >= tx_sdu->N_bytes ? tx_sdu->N_bytes : space; to_move = space >= tx_sdu->N_bytes ? tx_sdu->N_bytes : space;
log->debug("%s adding new SDU - %d bytes of %d remaining\n", rb_name.c_str(), to_move, tx_sdu->N_bytes); logger.debug("%s adding new SDU - %d bytes of %d remaining", rb_name.c_str(), to_move, tx_sdu->N_bytes);
memcpy(pdu_ptr, tx_sdu->msg, to_move); memcpy(pdu_ptr, tx_sdu->msg, to_move);
pdu_ptr += to_move; pdu_ptr += to_move;
pdu->N_bytes += to_move; pdu->N_bytes += to_move;
tx_sdu->N_bytes -= to_move; tx_sdu->N_bytes -= to_move;
tx_sdu->msg += to_move; tx_sdu->msg += to_move;
if (tx_sdu->N_bytes == 0) { if (tx_sdu->N_bytes == 0) {
log->debug("%s Complete SDU scheduled for tx. Stack latency: %ld us\n", logger.debug(
rb_name.c_str(), "%s Complete SDU scheduled for tx. Stack latency: %ld us", rb_name.c_str(), tx_sdu->get_latency_us().count());
tx_sdu->get_latency_us().count());
tx_sdu.reset(); tx_sdu.reset();
header.si = rlc_nr_si_field_t::full_sdu; header.si = rlc_nr_si_field_t::full_sdu;
} else { } else {
@ -189,7 +187,7 @@ int rlc_um_nr::rlc_um_nr_tx::build_data_pdu(unique_byte_buffer_t pdu, uint8_t* p
memcpy(payload, pdu->msg, pdu->N_bytes); memcpy(payload, pdu->msg, pdu->N_bytes);
uint32_t ret = pdu->N_bytes; uint32_t ret = pdu->N_bytes;
log->info_hex(payload, ret, "%s Tx PDU SN=%d (%d B)\n", rb_name.c_str(), header.sn, pdu->N_bytes); logger.info(payload, ret, "%s Tx PDU SN=%d (%d B)", rb_name.c_str(), header.sn, pdu->N_bytes);
debug_state(); debug_state();
@ -198,7 +196,7 @@ int rlc_um_nr::rlc_um_nr_tx::build_data_pdu(unique_byte_buffer_t pdu, uint8_t* p
void rlc_um_nr::rlc_um_nr_tx::debug_state() void rlc_um_nr::rlc_um_nr_tx::debug_state()
{ {
log->debug("%s TX_Next=%d, next_so=%d\n", rb_name.c_str(), TX_Next, next_so); logger.debug("%s TX_Next=%d, next_so=%d", rb_name.c_str(), TX_Next, next_so);
} }
void rlc_um_nr::rlc_um_nr_tx::reset() void rlc_um_nr::rlc_um_nr_tx::reset()
@ -218,13 +216,13 @@ rlc_um_nr::rlc_um_nr_rx::rlc_um_nr_rx(rlc_um_base* parent_) :
bool rlc_um_nr::rlc_um_nr_rx::configure(const rlc_config_t& cnfg_, std::string rb_name_) bool rlc_um_nr::rlc_um_nr_rx::configure(const rlc_config_t& cnfg_, std::string rb_name_)
{ {
if (cfg.um_nr.mod == 0) { if (cfg.um_nr.mod == 0) {
log->error("Error configuring %s RLC UM: rx_mod==0\n", rb_name.c_str()); logger.error("Error configuring %s RLC UM: rx_mod==0", rb_name.c_str());
return false; return false;
} }
// check timer // check timer
if (not reassembly_timer.is_valid()) { if (not reassembly_timer.is_valid()) {
log->error("Configuring RLC UM NR RX: timers not configured\n"); logger.error("Configuring RLC UM NR RX: timers not configured");
return false; return false;
} }
@ -273,9 +271,9 @@ void rlc_um_nr::rlc_um_nr_rx::timer_expired(uint32_t timeout_id)
{ {
std::lock_guard<std::mutex> lock(mutex); std::lock_guard<std::mutex> lock(mutex);
if (reassembly_timer.id() == timeout_id) { if (reassembly_timer.id() == timeout_id) {
log->info("%s reassembly timeout expiry - updating RX_Next_Reassembly and reassembling\n", rb_name.c_str()); logger.info("%s reassembly timeout expiry - updating RX_Next_Reassembly and reassembling", rb_name.c_str());
log->warning("Lost PDU SN: %d\n", RX_Next_Reassembly); logger.warning("Lost PDU SN: %d", RX_Next_Reassembly);
metrics.num_lost_pdus++; metrics.num_lost_pdus++;
if (rx_sdu != nullptr) { if (rx_sdu != nullptr) {
@ -330,7 +328,7 @@ unique_byte_buffer_t rlc_um_nr::rlc_um_nr_rx::rlc_um_nr_strip_pdu_header(const r
{ {
unique_byte_buffer_t sdu = make_byte_buffer(); unique_byte_buffer_t sdu = make_byte_buffer();
if (!sdu) { if (!sdu) {
log->error("Discarting packet: no space in buffer pool\n"); logger.error("Discarting packet: no space in buffer pool");
return nullptr; return nullptr;
} }
memcpy(sdu->msg, payload, nof_bytes); memcpy(sdu->msg, payload, nof_bytes);
@ -357,32 +355,32 @@ void rlc_um_nr::rlc_um_nr_rx::handle_rx_buffer_update(const uint32_t sn)
// iterate over received segments and try to assemble full SDU // iterate over received segments and try to assemble full SDU
auto& pdu = rx_window.at(sn); auto& pdu = rx_window.at(sn);
for (auto it = pdu.segments.begin(); it != pdu.segments.end();) { for (auto it = pdu.segments.begin(); it != pdu.segments.end();) {
log->debug("Have %s segment with SO=%d for SN=%d\n", logger.debug("Have %s segment with SO=%d for SN=%d",
to_string_short(it->second.header.si).c_str(), to_string_short(it->second.header.si).c_str(),
it->second.header.so, it->second.header.so,
it->second.header.sn); it->second.header.sn);
if (it->second.header.so == pdu.next_expected_so) { if (it->second.header.so == pdu.next_expected_so) {
if (pdu.next_expected_so == 0) { if (pdu.next_expected_so == 0) {
if (pdu.sdu == nullptr) { if (pdu.sdu == nullptr) {
// reuse buffer of first segment for final SDU // reuse buffer of first segment for final SDU
pdu.sdu = std::move(it->second.buf); pdu.sdu = std::move(it->second.buf);
pdu.next_expected_so = pdu.sdu->N_bytes; pdu.next_expected_so = pdu.sdu->N_bytes;
log->debug("Reusing first segment of SN=%d for final SDU\n", it->second.header.sn); logger.debug("Reusing first segment of SN=%d for final SDU", it->second.header.sn);
it = pdu.segments.erase(it); it = pdu.segments.erase(it);
} else { } else {
log->debug("SDU buffer already allocated. Possible retransmission of first segment.\n"); logger.debug("SDU buffer already allocated. Possible retransmission of first segment.");
if (it->second.header.so != pdu.next_expected_so) { if (it->second.header.so != pdu.next_expected_so) {
log->error("Invalid PDU. SO doesn't match. Discarting all segments of SN=%d.\n", sn); logger.error("Invalid PDU. SO doesn't match. Discarting all segments of SN=%d.", sn);
rx_window.erase(sn); rx_window.erase(sn);
return; return;
} }
} }
} else { } else {
if (it->second.buf->N_bytes > pdu.sdu->get_tailroom()) { if (it->second.buf->N_bytes > pdu.sdu->get_tailroom()) {
log->error("Cannot fit RLC PDU in SDU buffer (tailroom=%d, len=%d), dropping both. Erasing SN=%d.\n", logger.error("Cannot fit RLC PDU in SDU buffer (tailroom=%d, len=%d), dropping both. Erasing SN=%d.",
rx_sdu->get_tailroom(), rx_sdu->get_tailroom(),
it->second.buf->N_bytes, it->second.buf->N_bytes,
it->second.header.sn); it->second.header.sn);
rx_window.erase(sn); rx_window.erase(sn);
metrics.num_lost_pdus++; metrics.num_lost_pdus++;
return; return;
@ -392,12 +390,12 @@ void rlc_um_nr::rlc_um_nr_rx::handle_rx_buffer_update(const uint32_t sn)
memcpy(pdu.sdu->msg + pdu.sdu->N_bytes, it->second.buf->msg, it->second.buf->N_bytes); memcpy(pdu.sdu->msg + pdu.sdu->N_bytes, it->second.buf->msg, it->second.buf->N_bytes);
pdu.sdu->N_bytes += it->second.buf->N_bytes; pdu.sdu->N_bytes += it->second.buf->N_bytes;
pdu.next_expected_so += it->second.buf->N_bytes; pdu.next_expected_so += it->second.buf->N_bytes;
log->debug("Appended SO=%d of SN=%d\n", it->second.header.so, it->second.header.sn); logger.debug("Appended SO=%d of SN=%d", it->second.header.so, it->second.header.sn);
it = pdu.segments.erase(it); it = pdu.segments.erase(it);
if (pdu.next_expected_so == pdu.total_sdu_length) { if (pdu.next_expected_so == pdu.total_sdu_length) {
// deliver full SDU to upper layers // deliver full SDU to upper layers
log->info("Delivering %s SDU SN=%d (%d B)", rb_name.c_str(), sn, pdu.sdu->N_bytes); logger.info("Delivering %s SDU SN=%d (%d B)", rb_name.c_str(), sn, pdu.sdu->N_bytes);
pdcp->write_pdu(lcid, std::move(pdu.sdu)); pdcp->write_pdu(lcid, std::move(pdu.sdu));
// find next SN in rx buffer // find next SN in rx buffer
@ -406,7 +404,7 @@ void rlc_um_nr::rlc_um_nr_rx::handle_rx_buffer_update(const uint32_t sn)
while (RX_MOD_NR_BASE(RX_Next_Reassembly) < RX_MOD_NR_BASE(RX_Next_Highest)) { while (RX_MOD_NR_BASE(RX_Next_Reassembly) < RX_MOD_NR_BASE(RX_Next_Highest)) {
RX_Next_Reassembly = (RX_Next_Reassembly + 1) % cfg.um_nr.mod; RX_Next_Reassembly = (RX_Next_Reassembly + 1) % cfg.um_nr.mod;
} }
log->debug("Updating RX_Next_Reassembly=%d\n", RX_Next_Reassembly); logger.debug("Updating RX_Next_Reassembly=%d", RX_Next_Reassembly);
} }
// delete PDU from rx_window // delete PDU from rx_window
@ -424,16 +422,16 @@ void rlc_um_nr::rlc_um_nr_rx::handle_rx_buffer_update(const uint32_t sn)
if (not sn_in_reassembly_window(sn)) { if (not sn_in_reassembly_window(sn)) {
// update RX_Next_highest // update RX_Next_highest
RX_Next_Highest = sn + 1; RX_Next_Highest = sn + 1;
log->debug("Updating RX_Next_Highest=%d\n", RX_Next_Highest); logger.debug("Updating RX_Next_Highest=%d", RX_Next_Highest);
// drop all SNs outside of new rx window // drop all SNs outside of new rx window
for (auto it = rx_window.begin(); it != rx_window.end();) { for (auto it = rx_window.begin(); it != rx_window.end();) {
if (not sn_in_reassembly_window(it->first)) { if (not sn_in_reassembly_window(it->first)) {
log->info("%s SN: %d outside rx window [%d:%d] - discarding\n", logger.info("%s SN: %d outside rx window [%d:%d] - discarding",
rb_name.c_str(), rb_name.c_str(),
it->first, it->first,
RX_Next_Highest - cfg.um_nr.UM_Window_Size, RX_Next_Highest - cfg.um_nr.UM_Window_Size,
RX_Next_Highest); RX_Next_Highest);
it = rx_window.erase(it); it = rx_window.erase(it);
metrics.num_lost_pdus++; metrics.num_lost_pdus++;
} else { } else {
@ -446,7 +444,7 @@ void rlc_um_nr::rlc_um_nr_rx::handle_rx_buffer_update(const uint32_t sn)
for (const auto& rx_pdu : rx_window) { for (const auto& rx_pdu : rx_window) {
if (rx_pdu.first >= RX_MOD_NR_BASE(RX_Next_Highest - cfg.um_nr.UM_Window_Size)) { if (rx_pdu.first >= RX_MOD_NR_BASE(RX_Next_Highest - cfg.um_nr.UM_Window_Size)) {
RX_Next_Reassembly = rx_pdu.first; RX_Next_Reassembly = rx_pdu.first;
log->debug("Updating RX_Next_Reassembly=%d\n", RX_Next_Reassembly); logger.debug("Updating RX_Next_Reassembly=%d", RX_Next_Reassembly);
break; break;
} }
} }
@ -468,7 +466,7 @@ void rlc_um_nr::rlc_um_nr_rx::handle_rx_buffer_update(const uint32_t sn)
} }
} }
} else { } else {
log->error("SN=%d does not exist in Rx buffer\n", sn); logger.error("SN=%d does not exist in Rx buffer", sn);
} }
} }
@ -477,10 +475,10 @@ inline void rlc_um_nr::rlc_um_nr_rx::update_total_sdu_length(rlc_umd_pdu_segment
{ {
if (rx_pdu.header.si == rlc_nr_si_field_t::last_segment) { if (rx_pdu.header.si == rlc_nr_si_field_t::last_segment) {
pdu_segments.total_sdu_length = rx_pdu.header.so + rx_pdu.buf->N_bytes; pdu_segments.total_sdu_length = rx_pdu.header.so + rx_pdu.buf->N_bytes;
log->info("%s updating total SDU length for SN=%d to %d B\n", logger.info("%s updating total SDU length for SN=%d to %d B",
rb_name.c_str(), rb_name.c_str(),
rx_pdu.header.sn, rx_pdu.header.sn,
pdu_segments.total_sdu_length); pdu_segments.total_sdu_length);
} }
}; };
@ -491,7 +489,7 @@ void rlc_um_nr::rlc_um_nr_rx::handle_data_pdu(uint8_t* payload, uint32_t nof_byt
rlc_um_nr_pdu_header_t header = {}; rlc_um_nr_pdu_header_t header = {};
rlc_um_nr_read_data_pdu_header(payload, nof_bytes, cfg.um_nr.sn_field_length, &header); rlc_um_nr_read_data_pdu_header(payload, nof_bytes, cfg.um_nr.sn_field_length, &header);
log->debug_hex(payload, nof_bytes, "RX %s Rx data PDU (%d B)", rb_name.c_str(), nof_bytes); logger.debug(payload, nof_bytes, "RX %s Rx data PDU (%d B)", rb_name.c_str(), nof_bytes);
// check if PDU contains a SN // check if PDU contains a SN
if (header.si == rlc_nr_si_field_t::full_sdu) { if (header.si == rlc_nr_si_field_t::full_sdu) {
@ -499,10 +497,10 @@ void rlc_um_nr::rlc_um_nr_rx::handle_data_pdu(uint8_t* payload, uint32_t nof_byt
unique_byte_buffer_t sdu = rlc_um_nr_strip_pdu_header(header, payload, nof_bytes); unique_byte_buffer_t sdu = rlc_um_nr_strip_pdu_header(header, payload, nof_bytes);
// deliver to PDCP // deliver to PDCP
log->info("Delivering %s SDU (%d B)", rb_name.c_str(), sdu->N_bytes); logger.info("Delivering %s SDU (%d B)", rb_name.c_str(), sdu->N_bytes);
pdcp->write_pdu(lcid, std::move(sdu)); pdcp->write_pdu(lcid, std::move(sdu));
} else if (sn_invalid_for_rx_buffer(header.sn)) { } else if (sn_invalid_for_rx_buffer(header.sn)) {
log->info("%s Discarding SN=%d\n", rb_name.c_str(), header.sn); logger.info("%s Discarding SN=%d", rb_name.c_str(), header.sn);
// Nothing else to do here .. // Nothing else to do here ..
} else { } else {
// place PDU in receive buffer // place PDU in receive buffer
@ -513,21 +511,21 @@ void rlc_um_nr::rlc_um_nr_rx::handle_data_pdu(uint8_t* payload, uint32_t nof_byt
// check if this SN is already present in rx buffer // check if this SN is already present in rx buffer
if (rx_window.find(header.sn) == rx_window.end()) { if (rx_window.find(header.sn) == rx_window.end()) {
// first received segment of this SN, add to rx buffer // first received segment of this SN, add to rx buffer
log->info("%s placing %s segment of SN=%d in Rx buffer\n", logger.info("%s placing %s segment of SN=%d in Rx buffer",
rb_name.c_str(), rb_name.c_str(),
to_string_short(header.si).c_str(), to_string_short(header.si).c_str(),
header.sn); header.sn);
rlc_umd_pdu_segments_nr_t pdu_segments = {}; rlc_umd_pdu_segments_nr_t pdu_segments = {};
update_total_sdu_length(pdu_segments, rx_pdu); update_total_sdu_length(pdu_segments, rx_pdu);
pdu_segments.segments.emplace(header.so, std::move(rx_pdu)); pdu_segments.segments.emplace(header.so, std::move(rx_pdu));
rx_window[header.sn] = std::move(pdu_segments); rx_window[header.sn] = std::move(pdu_segments);
} else { } else {
// other segment for this SN already present, update received data // other segment for this SN already present, update received data
log->info("%s updating SN=%d at SO=%d with %d B\n", logger.info("%s updating SN=%d at SO=%d with %d B",
rb_name.c_str(), rb_name.c_str(),
rx_pdu.header.sn, rx_pdu.header.sn,
rx_pdu.header.so, rx_pdu.header.so,
rx_pdu.buf->N_bytes); rx_pdu.buf->N_bytes);
auto& pdu_segments = rx_window.at(header.sn); auto& pdu_segments = rx_window.at(header.sn);
@ -547,12 +545,12 @@ void rlc_um_nr::rlc_um_nr_rx::handle_data_pdu(uint8_t* payload, uint32_t nof_byt
void rlc_um_nr::rlc_um_nr_rx::debug_state() void rlc_um_nr::rlc_um_nr_rx::debug_state()
{ {
log->debug("%s RX_Next_Reassembly=%d, RX_Timer_Trigger=%d, RX_Next_Highest=%d, t_Reassembly=%s\n", logger.debug("%s RX_Next_Reassembly=%d, RX_Timer_Trigger=%d, RX_Next_Highest=%d, t_Reassembly=%s",
rb_name.c_str(), rb_name.c_str(),
RX_Next_Reassembly, RX_Next_Reassembly,
RX_Timer_Trigger, RX_Timer_Trigger,
RX_Next_Highest, RX_Next_Highest,
reassembly_timer.is_running() ? "running" : "stopped"); reassembly_timer.is_running() ? "running" : "stopped");
} }
/**************************************************************************** /****************************************************************************
* Header pack/unpack helper functions * Header pack/unpack helper functions
@ -593,7 +591,7 @@ uint32_t rlc_um_nr_read_data_pdu_header(const uint8_t* payload,
if (header->si == rlc_nr_si_field_t::first_segment) { if (header->si == rlc_nr_si_field_t::first_segment) {
// make sure two reserved bits are not set // make sure two reserved bits are not set
if (((*ptr >> 4) & 0x03) != 0) { if (((*ptr >> 4) & 0x03) != 0) {
fprintf(stderr, "Malformed PDU, reserved bits are set.\n"); fprintf(stderr, "Malformed PDU, reserved bits are set.");
return 0; return 0;
} }
} }

@ -64,6 +64,8 @@ int status_pdu_with_nacks_test1()
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
srslog::init();
TESTASSERT(simple_status_pdu_test1() == SRSLTE_SUCCESS); TESTASSERT(simple_status_pdu_test1() == SRSLTE_SUCCESS);
TESTASSERT(status_pdu_with_nacks_test1() == SRSLTE_SUCCESS); TESTASSERT(status_pdu_with_nacks_test1() == SRSLTE_SUCCESS);

@ -143,9 +143,12 @@ int test4()
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
srslog::init();
TESTASSERT(test1() == SRSLTE_SUCCESS); TESTASSERT(test1() == SRSLTE_SUCCESS);
TESTASSERT(test2() == SRSLTE_SUCCESS); TESTASSERT(test2() == SRSLTE_SUCCESS);
TESTASSERT(test3() == SRSLTE_SUCCESS); TESTASSERT(test3() == SRSLTE_SUCCESS);
TESTASSERT(test4() == SRSLTE_SUCCESS); TESTASSERT(test4() == SRSLTE_SUCCESS);
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
} }

@ -292,6 +292,8 @@ int main(int argc, char** argv)
pcap_handle->open("rlc_am_nr_pdu_test.pcap"); pcap_handle->open("rlc_am_nr_pdu_test.pcap");
#endif #endif
srslog::init();
if (rlc_am_nr_pdu_test1()) { if (rlc_am_nr_pdu_test1()) {
fprintf(stderr, "rlc_am_nr_pdu_test1() failed.\n"); fprintf(stderr, "rlc_am_nr_pdu_test1() failed.\n");
return SRSLTE_ERROR; return SRSLTE_ERROR;

@ -23,9 +23,6 @@
using namespace srsue; using namespace srsue;
using namespace srslte; using namespace srslte;
srslte::log_ref rrc_log1("RLC_AM_1");
srslte::log_ref rrc_log2("RLC_AM_2");
bool rx_is_tx(const rlc_bearer_metrics_t& rlc1_metrics, const rlc_bearer_metrics_t& rlc2_metrics) bool rx_is_tx(const rlc_bearer_metrics_t& rlc1_metrics, const rlc_bearer_metrics_t& rlc2_metrics)
{ {
if (rlc1_metrics.num_tx_pdu_bytes != rlc2_metrics.num_rx_pdu_bytes) { if (rlc1_metrics.num_tx_pdu_bytes != rlc2_metrics.num_rx_pdu_bytes) {
@ -154,8 +151,8 @@ int basic_test()
timer_handler timers(8); timer_handler timers(8);
byte_buffer_t pdu_bufs[NBUFS]; byte_buffer_t pdu_bufs[NBUFS];
rlc_am_lte rlc1(rrc_log1, 1, &tester, &tester, &timers); rlc_am_lte rlc1(srslog::fetch_basic_logger("RLC_AM_1"), 1, &tester, &tester, &timers);
rlc_am_lte rlc2(rrc_log2, 1, &tester, &tester, &timers); rlc_am_lte rlc2(srslog::fetch_basic_logger("RLC_AM_2"), 1, &tester, &tester, &timers);
// before configuring entity // before configuring entity
TESTASSERT(0 == rlc1.get_buffer_state()); TESTASSERT(0 == rlc1.get_buffer_state());
@ -211,8 +208,8 @@ int concat_test()
rlc_am_tester tester; rlc_am_tester tester;
srslte::timer_handler timers(8); srslte::timer_handler timers(8);
rlc_am_lte rlc1(rrc_log1, 1, &tester, &tester, &timers); rlc_am_lte rlc1(srslog::fetch_basic_logger("RLC_AM_1"), 1, &tester, &tester, &timers);
rlc_am_lte rlc2(rrc_log2, 1, &tester, &tester, &timers); rlc_am_lte rlc2(srslog::fetch_basic_logger("RLC_AM_2"), 1, &tester, &tester, &timers);
if (not rlc1.configure(rlc_config_t::default_rlc_am_config())) { if (not rlc1.configure(rlc_config_t::default_rlc_am_config())) {
return -1; return -1;
@ -287,8 +284,8 @@ int segment_test(bool in_seq_rx)
srslte::timer_handler timers(8); srslte::timer_handler timers(8);
int len = 0; int len = 0;
rlc_am_lte rlc1(rrc_log1, 1, &tester, &tester, &timers); rlc_am_lte rlc1(srslog::fetch_basic_logger("RLC_AM_1"), 1, &tester, &tester, &timers);
rlc_am_lte rlc2(rrc_log2, 1, &tester, &tester, &timers); rlc_am_lte rlc2(srslog::fetch_basic_logger("RLC_AM_2"), 1, &tester, &tester, &timers);
if (not rlc1.configure(rlc_config_t::default_rlc_am_config())) { if (not rlc1.configure(rlc_config_t::default_rlc_am_config())) {
return -1; return -1;
@ -382,8 +379,8 @@ int retx_test()
timer_handler timers(8); timer_handler timers(8);
int len = 0; int len = 0;
rlc_am_lte rlc1(rrc_log1, 1, &tester, &tester, &timers); rlc_am_lte rlc1(srslog::fetch_basic_logger("RLC_AM_1"), 1, &tester, &tester, &timers);
rlc_am_lte rlc2(rrc_log2, 1, &tester, &tester, &timers); rlc_am_lte rlc2(srslog::fetch_basic_logger("RLC_AM_2"), 1, &tester, &tester, &timers);
if (not rlc1.configure(rlc_config_t::default_rlc_am_config())) { if (not rlc1.configure(rlc_config_t::default_rlc_am_config())) {
return -1; return -1;
@ -518,8 +515,8 @@ int segment_retx_test()
timer_handler timers(8); timer_handler timers(8);
int len = 0; int len = 0;
rlc_am_lte rlc1(rrc_log1, 1, &tester, &tester, &timers); rlc_am_lte rlc1(srslog::fetch_basic_logger("RLC_AM_1"), 1, &tester, &tester, &timers);
rlc_am_lte rlc2(rrc_log2, 1, &tester, &tester, &timers); rlc_am_lte rlc2(srslog::fetch_basic_logger("RLC_AM_2"), 1, &tester, &tester, &timers);
if (not rlc1.configure(rlc_config_t::default_rlc_am_config())) { if (not rlc1.configure(rlc_config_t::default_rlc_am_config())) {
return -1; return -1;
@ -642,8 +639,8 @@ int resegment_test_1()
timer_handler timers(8); timer_handler timers(8);
int len = 0; int len = 0;
rlc_am_lte rlc1(rrc_log1, 1, &tester, &tester, &timers); rlc_am_lte rlc1(srslog::fetch_basic_logger("RLC_AM_1"), 1, &tester, &tester, &timers);
rlc_am_lte rlc2(rrc_log2, 1, &tester, &tester, &timers); rlc_am_lte rlc2(srslog::fetch_basic_logger("RLC_AM_2"), 1, &tester, &tester, &timers);
if (not rlc1.configure(rlc_config_t::default_rlc_am_config())) { if (not rlc1.configure(rlc_config_t::default_rlc_am_config())) {
return -1; return -1;
@ -707,7 +704,7 @@ int resegment_test_1()
TESTASSERT(12 == rlc1.get_buffer_state()); // 2 byte header + 10 data TESTASSERT(12 == rlc1.get_buffer_state()); // 2 byte header + 10 data
// Check notifications // Check notifications
rrc_log1->debug("%ld\n", tester.notified_counts.size()); srslog::fetch_basic_logger("RLC_AM_1").debug("%ld", tester.notified_counts.size());
TESTASSERT(tester.notified_counts.size() == 4); TESTASSERT(tester.notified_counts.size() == 4);
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
auto it = tester.notified_counts.find(i); auto it = tester.notified_counts.find(i);
@ -801,8 +798,8 @@ int resegment_test_2()
timer_handler timers(8); timer_handler timers(8);
int len = 0; int len = 0;
rlc_am_lte rlc1(rrc_log1, 1, &tester, &tester, &timers); rlc_am_lte rlc1(srslog::fetch_basic_logger("RLC_AM_1"), 1, &tester, &tester, &timers);
rlc_am_lte rlc2(rrc_log2, 1, &tester, &tester, &timers); rlc_am_lte rlc2(srslog::fetch_basic_logger("RLC_AM_2"), 1, &tester, &tester, &timers);
if (not rlc1.configure(rlc_config_t::default_rlc_am_config())) { if (not rlc1.configure(rlc_config_t::default_rlc_am_config())) {
return -1; return -1;
@ -934,8 +931,8 @@ int resegment_test_3()
rlc_am_tester tester; rlc_am_tester tester;
srslte::timer_handler timers(8); srslte::timer_handler timers(8);
rlc_am_lte rlc1(rrc_log1, 1, &tester, &tester, &timers); rlc_am_lte rlc1(srslog::fetch_basic_logger("RLC_AM_1"), 1, &tester, &tester, &timers);
rlc_am_lte rlc2(rrc_log2, 1, &tester, &tester, &timers); rlc_am_lte rlc2(srslog::fetch_basic_logger("RLC_AM_2"), 1, &tester, &tester, &timers);
if (not rlc1.configure(rlc_config_t::default_rlc_am_config())) { if (not rlc1.configure(rlc_config_t::default_rlc_am_config())) {
return -1; return -1;
@ -1065,8 +1062,8 @@ int resegment_test_4()
rlc_am_tester tester; rlc_am_tester tester;
srslte::timer_handler timers(8); srslte::timer_handler timers(8);
rlc_am_lte rlc1(rrc_log1, 1, &tester, &tester, &timers); rlc_am_lte rlc1(srslog::fetch_basic_logger("RLC_AM_1"), 1, &tester, &tester, &timers);
rlc_am_lte rlc2(rrc_log2, 1, &tester, &tester, &timers); rlc_am_lte rlc2(srslog::fetch_basic_logger("RLC_AM_2"), 1, &tester, &tester, &timers);
if (not rlc1.configure(rlc_config_t::default_rlc_am_config())) { if (not rlc1.configure(rlc_config_t::default_rlc_am_config())) {
return -1; return -1;
@ -1198,8 +1195,8 @@ int resegment_test_5()
rlc_am_tester tester; rlc_am_tester tester;
srslte::timer_handler timers(8); srslte::timer_handler timers(8);
rlc_am_lte rlc1(rrc_log1, 1, &tester, &tester, &timers); rlc_am_lte rlc1(srslog::fetch_basic_logger("RLC_AM_1"), 1, &tester, &tester, &timers);
rlc_am_lte rlc2(rrc_log2, 1, &tester, &tester, &timers); rlc_am_lte rlc2(srslog::fetch_basic_logger("RLC_AM_2"), 1, &tester, &tester, &timers);
if (not rlc1.configure(rlc_config_t::default_rlc_am_config())) { if (not rlc1.configure(rlc_config_t::default_rlc_am_config())) {
return -1; return -1;
@ -1326,8 +1323,8 @@ int resegment_test_6()
srslte::timer_handler timers(8); srslte::timer_handler timers(8);
int len = 0; int len = 0;
rlc_am_lte rlc1(rrc_log1, 1, &tester, &tester, &timers); rlc_am_lte rlc1(srslog::fetch_basic_logger("RLC_AM_1"), 1, &tester, &tester, &timers);
rlc_am_lte rlc2(rrc_log2, 1, &tester, &tester, &timers); rlc_am_lte rlc2(srslog::fetch_basic_logger("RLC_AM_2"), 1, &tester, &tester, &timers);
if (not rlc1.configure(rlc_config_t::default_rlc_am_config())) { if (not rlc1.configure(rlc_config_t::default_rlc_am_config())) {
return -1; return -1;
@ -1497,8 +1494,8 @@ int resegment_test_7()
#endif #endif
srslte::timer_handler timers(8); srslte::timer_handler timers(8);
rlc_am_lte rlc1(rrc_log1, 1, &tester, &tester, &timers); rlc_am_lte rlc1(srslog::fetch_basic_logger("RLC_AM_1"), 1, &tester, &tester, &timers);
rlc_am_lte rlc2(rrc_log2, 1, &tester, &tester, &timers); rlc_am_lte rlc2(srslog::fetch_basic_logger("RLC_AM_2"), 1, &tester, &tester, &timers);
if (not rlc1.configure(rlc_config_t::default_rlc_am_config())) { if (not rlc1.configure(rlc_config_t::default_rlc_am_config())) {
return -1; return -1;
@ -1685,8 +1682,8 @@ int resegment_test_8()
#endif #endif
srslte::timer_handler timers(8); srslte::timer_handler timers(8);
rlc_am_lte rlc1(rrc_log1, 1, &tester, &tester, &timers); rlc_am_lte rlc1(srslog::fetch_basic_logger("RLC_AM_1"), 1, &tester, &tester, &timers);
rlc_am_lte rlc2(rrc_log2, 1, &tester, &tester, &timers); rlc_am_lte rlc2(srslog::fetch_basic_logger("RLC_AM_2"), 1, &tester, &tester, &timers);
if (not rlc1.configure(rlc_config_t::default_rlc_am_config())) { if (not rlc1.configure(rlc_config_t::default_rlc_am_config())) {
return -1; return -1;
@ -1827,7 +1824,7 @@ bool reset_test()
srslte::timer_handler timers(8); srslte::timer_handler timers(8);
int len = 0; int len = 0;
rlc_am_lte rlc1(rrc_log1, 1, &tester, &tester, &timers); rlc_am_lte rlc1(srslog::fetch_basic_logger("RLC_AM_1"), 1, &tester, &tester, &timers);
if (not rlc1.configure(rlc_config_t::default_rlc_am_config())) { if (not rlc1.configure(rlc_config_t::default_rlc_am_config())) {
return -1; return -1;
@ -1869,7 +1866,7 @@ bool resume_test()
srslte::timer_handler timers(8); srslte::timer_handler timers(8);
int len = 0; int len = 0;
rlc_am_lte rlc1(rrc_log1, 1, &tester, &tester, &timers); rlc_am_lte rlc1(srslog::fetch_basic_logger("RLC_AM_1"), 1, &tester, &tester, &timers);
if (not rlc1.configure(rlc_config_t::default_rlc_am_config())) { if (not rlc1.configure(rlc_config_t::default_rlc_am_config())) {
return -1; return -1;
@ -1910,7 +1907,7 @@ bool stop_test()
rlc_am_tester tester; rlc_am_tester tester;
srslte::timer_handler timers(8); srslte::timer_handler timers(8);
rlc_am_lte rlc1(rrc_log1, 1, &tester, &tester, &timers); rlc_am_lte rlc1(srslog::fetch_basic_logger("RLC_AM_1"), 1, &tester, &tester, &timers);
if (not rlc1.configure(rlc_config_t::default_rlc_am_config())) { if (not rlc1.configure(rlc_config_t::default_rlc_am_config())) {
return -1; return -1;
@ -1937,8 +1934,8 @@ bool status_pdu_test()
srslte::timer_handler timers(8); srslte::timer_handler timers(8);
int len = 0; int len = 0;
rlc_am_lte rlc1(rrc_log1, 1, &tester, &tester, &timers); rlc_am_lte rlc1(srslog::fetch_basic_logger("RLC_AM_1"), 1, &tester, &tester, &timers);
rlc_am_lte rlc2(rrc_log2, 1, &tester, &tester, &timers); rlc_am_lte rlc2(srslog::fetch_basic_logger("RLC_AM_2"), 1, &tester, &tester, &timers);
if (not rlc1.configure(rlc_config_t::default_rlc_am_config())) { if (not rlc1.configure(rlc_config_t::default_rlc_am_config())) {
return -1; return -1;
@ -2049,10 +2046,14 @@ bool status_pdu_test()
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
rrc_log1->set_level(srslte::LOG_LEVEL_DEBUG); srslog::init();
rrc_log2->set_level(srslte::LOG_LEVEL_DEBUG);
rrc_log1->set_hex_limit(-1); auto& logger_rrc1 = srslog::fetch_basic_logger("RLC_AM_1", false);
rrc_log2->set_hex_limit(-1); logger_rrc1.set_level(srslog::basic_levels::debug);
logger_rrc1.set_hex_dump_max_size(-1);
auto& logger_rrc2 = srslog::fetch_basic_logger("RLC_AM_2", false);
logger_rrc2.set_level(srslog::basic_levels::debug);
logger_rrc2.set_hex_dump_max_size(-1);
if (basic_test()) { if (basic_test()) {
printf("basic_test failed\n"); printf("basic_test failed\n");
@ -2114,8 +2115,8 @@ int main(int argc, char** argv)
exit(-1); exit(-1);
}; };
rrc_log1->set_hex_limit(100); logger_rrc1.set_hex_dump_max_size(100);
rrc_log2->set_hex_limit(100); logger_rrc2.set_hex_dump_max_size(100);
if (resegment_test_7()) { if (resegment_test_7()) {
printf("resegment_test_7 failed\n"); printf("resegment_test_7 failed\n");
exit(-1); exit(-1);
@ -2125,8 +2126,8 @@ int main(int argc, char** argv)
printf("resegment_test_8 failed\n"); printf("resegment_test_8 failed\n");
exit(-1); exit(-1);
}; };
rrc_log1->set_hex_limit(-1); logger_rrc1.set_hex_dump_max_size(-1);
rrc_log2->set_hex_limit(-1); logger_rrc2.set_hex_dump_max_size(-1);
if (reset_test()) { if (reset_test()) {
printf("reset_test failed\n"); printf("reset_test failed\n");

@ -64,19 +64,20 @@ public:
int meas_obj_test() int meas_obj_test()
{ {
srslte::log_ref log1("RLC_1"); auto& logger_rlc1 = srslog::fetch_basic_logger("RLC_1", false);
srslte::log_ref log2("RLC_2"); logger_rlc1.set_level(srslog::basic_levels::debug);
log1->set_level(srslte::LOG_LEVEL_DEBUG); logger_rlc1.set_hex_dump_max_size(-1);
log2->set_level(srslte::LOG_LEVEL_DEBUG); auto& logger_rlc2 = srslog::fetch_basic_logger("RLC_2", false);
log1->set_hex_limit(-1); logger_rlc2.set_level(srslog::basic_levels::debug);
log2->set_hex_limit(-1); logger_rlc2.set_hex_dump_max_size(-1);
rlc_tester tester; rlc_tester tester;
srslte::timer_handler timers(1); srslte::timer_handler timers(1);
int len = 0; int len = 0;
rlc rlc1(log1->get_service_name().c_str()); rlc rlc1(logger_rlc1.id().c_str());
rlc rlc2(log2->get_service_name().c_str()); rlc rlc2(logger_rlc2.id().c_str());
rlc1.init(&tester, &tester, &timers, 0); rlc1.init(&tester, &tester, &timers, 0);
rlc2.init(&tester, &tester, &timers, 0); rlc2.init(&tester, &tester, &timers, 0);
@ -195,6 +196,8 @@ int meas_obj_test()
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
srslog::init();
if (meas_obj_test()) { if (meas_obj_test()) {
return -1; return -1;
} }

@ -153,14 +153,14 @@ public:
pcap(pcap_), pcap(pcap_),
lcid(lcid_), lcid(lcid_),
timers(timers_), timers(timers_),
log("MAC "), logger(srslog::fetch_basic_logger("MAC", false)),
thread("MAC_DUMMY"), thread("MAC_DUMMY"),
real_dist(0.0, 1.0), real_dist(0.0, 1.0),
mt19937(1234), mt19937(1234),
pool(byte_buffer_pool::get_instance()) pool(byte_buffer_pool::get_instance())
{ {
log.set_level(static_cast<LOG_LEVEL_ENUM>(args.log_level)); logger.set_level(static_cast<srslog::basic_levels>(args.log_level));
log.set_hex_limit(LOG_HEX_LIMIT); logger.set_hex_dump_max_size(LOG_HEX_LIMIT);
} }
void stop() void stop()
@ -227,7 +227,7 @@ private:
// Cut // Cut
if ((real_dist(mt19937) < args.pdu_cut_rate)) { if ((real_dist(mt19937) < args.pdu_cut_rate)) {
int cut_pdu_len = static_cast<int>(pdu_len * real_dist(mt19937)); int cut_pdu_len = static_cast<int>(pdu_len * real_dist(mt19937));
log.info("Cutting MAC PDU len (%d B -> %d B)\n", pdu_len, cut_pdu_len); logger.info("Cutting MAC PDU len (%d B -> %d B)", pdu_len, cut_pdu_len);
pdu_len = cut_pdu_len; pdu_len = cut_pdu_len;
} }
@ -242,7 +242,7 @@ private:
pcap->write_ul_ccch(pdu->msg, pdu_len); pcap->write_ul_ccch(pdu->msg, pdu_len);
} }
} else { } else {
log.warning_hex(pdu->msg, pdu->N_bytes, "Dropping RLC PDU (%d B)\n", pdu->N_bytes); logger.warning(pdu->msg, pdu->N_bytes, "Dropping RLC PDU (%d B)", pdu->N_bytes);
skip_action = true; // Avoid drop duplicating this PDU skip_action = true; // Avoid drop duplicating this PDU
} }
@ -251,7 +251,7 @@ private:
it++; it++;
skip_action = false; // Allow action on the next PDU skip_action = false; // Allow action on the next PDU
} else { } else {
log.warning_hex(pdu->msg, pdu->N_bytes, "Duplicating RLC PDU (%d B)\n", pdu->N_bytes); logger.warning(pdu->msg, pdu->N_bytes, "Duplicating RLC PDU (%d B)", pdu->N_bytes);
skip_action = true; // Avoid drop of this PDU skip_action = true; // Avoid drop of this PDU
} }
} }
@ -300,7 +300,7 @@ private:
stress_test_args_t args; stress_test_args_t args;
rlc_pcap* pcap; rlc_pcap* pcap;
uint32_t lcid; uint32_t lcid;
srslte::log_filter log; srslog::basic_logger& logger;
srslte::timer_handler* timers = nullptr; srslte::timer_handler* timers = nullptr;
srslte::block_queue<srslte::move_task_t> pending_tasks; srslte::block_queue<srslte::move_task_t> pending_tasks;
@ -314,10 +314,18 @@ class rlc_tester : public pdcp_interface_rlc, public rrc_interface_rlc, public t
{ {
public: public:
rlc_tester(rlc_interface_pdcp* rlc_, std::string name_, stress_test_args_t args_, uint32_t lcid_) : rlc_tester(rlc_interface_pdcp* rlc_, std::string name_, stress_test_args_t args_, uint32_t lcid_) :
log("TEST"), rlc(rlc_), run_enable(true), rx_pdus(), name(name_), args(args_), lcid(lcid_), thread("RLC_TESTER") log("TEST"),
logger(srslog::fetch_basic_logger("TEST", false)),
rlc(rlc_),
run_enable(true),
rx_pdus(),
name(name_),
args(args_),
lcid(lcid_),
thread("RLC_TESTER")
{ {
log.set_level(srslte::LOG_LEVEL_ERROR); logger.set_level(srslog::basic_levels::error);
log.set_hex_limit(LOG_HEX_LIMIT); logger.set_hex_dump_max_size(LOG_HEX_LIMIT);
} }
void stop() void stop()
@ -331,7 +339,7 @@ public:
{ {
assert(rx_lcid == lcid); assert(rx_lcid == lcid);
if (sdu->N_bytes != args.sdu_size) { if (sdu->N_bytes != args.sdu_size) {
log.error_hex(sdu->msg, sdu->N_bytes, "Received SDU with size %d, expected %d.\n", sdu->N_bytes, args.sdu_size); logger.error(sdu->msg, sdu->N_bytes, "Received SDU with size %d, expected %d.", sdu->N_bytes, args.sdu_size);
if (args.pedantic_sdu_check) { if (args.pedantic_sdu_check) {
exit(-1); exit(-1);
} }
@ -377,10 +385,11 @@ private:
} }
} }
bool run_enable; bool run_enable;
uint64_t rx_pdus; uint64_t rx_pdus;
uint32_t lcid; uint32_t lcid;
srslte::log_filter log; srslte::log_filter log;
srslog::basic_logger& logger;
std::string name; std::string name;
@ -391,12 +400,13 @@ private:
void stress_test(stress_test_args_t args) void stress_test(stress_test_args_t args)
{ {
srslte::log_ref log1("RLC_1"); auto& log1 = srslog::fetch_basic_logger("RLC_1", false);
srslte::log_ref log2("RLC_2"); log1.set_level(static_cast<srslog::basic_levels>(args.log_level));
log1->set_level(static_cast<LOG_LEVEL_ENUM>(args.log_level)); log1.set_hex_dump_max_size(LOG_HEX_LIMIT);
log2->set_level(static_cast<LOG_LEVEL_ENUM>(args.log_level)); auto& log2 = srslog::fetch_basic_logger("RLC_2", false);
log1->set_hex_limit(LOG_HEX_LIMIT); log2.set_level(static_cast<srslog::basic_levels>(args.log_level));
log2->set_hex_limit(LOG_HEX_LIMIT); log2.set_hex_dump_max_size(LOG_HEX_LIMIT);
rlc_pcap pcap; rlc_pcap pcap;
uint32_t lcid = 1; uint32_t lcid = 1;
@ -455,8 +465,8 @@ void stress_test(stress_test_args_t args)
srslte::timer_handler timers(8); srslte::timer_handler timers(8);
rlc rlc1(log1->get_service_name().c_str()); rlc rlc1(log1.id().c_str());
rlc rlc2(log2->get_service_name().c_str()); rlc rlc2(log2.id().c_str());
rlc_tester tester1(&rlc1, "tester1", args, lcid); rlc_tester tester1(&rlc1, "tester1", args, lcid);
rlc_tester tester2(&rlc2, "tester2", args, lcid); rlc_tester tester2(&rlc2, "tester2", args, lcid);
@ -539,6 +549,8 @@ int main(int argc, char** argv)
stress_test_args_t args = {}; stress_test_args_t args = {};
parse_args(&args, argc, argv); parse_args(&args, argc, argv);
srslog::init();
if (args.zero_seed) { if (args.zero_seed) {
srand(0); srand(0);
} else { } else {

@ -24,6 +24,8 @@ uint32_t PDU2_LEN = 4;
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
srslog::init();
srslte::rlc_umd_pdu_header_t h; srslte::rlc_umd_pdu_header_t h;
srslte::byte_buffer_t b1, b2; srslte::byte_buffer_t b1, b2;

@ -202,6 +202,8 @@ int main(int argc, char** argv)
pcap_handle->open("rlc_um_nr_pdu_test.pcap"); pcap_handle->open("rlc_um_nr_pdu_test.pcap");
#endif #endif
srslog::init();
if (rlc_um_nr_pdu_test1()) { if (rlc_um_nr_pdu_test1()) {
fprintf(stderr, "rlc_um_nr_pdu_test1() failed.\n"); fprintf(stderr, "rlc_um_nr_pdu_test1() failed.\n");
return SRSLTE_ERROR; return SRSLTE_ERROR;

@ -72,17 +72,17 @@ class rlc_um_nr_test_context1
{ {
public: public:
rlc_um_nr_test_context1() : rlc_um_nr_test_context1() :
log1("RLC_UM_1"), logger1(srslog::fetch_basic_logger("RLC_UM_1", false)),
log2("RLC_UM_2"), logger2(srslog::fetch_basic_logger("RLC_UM_2", false)),
timers(16), timers(16),
rlc1(log1, 3, &tester, &tester, &timers), rlc1(logger1, 3, &tester, &tester, &timers),
rlc2(log2, 3, &tester, &tester, &timers) rlc2(logger2, 3, &tester, &tester, &timers)
{ {
// setup logging // setup logging
log1->set_level(srslte::LOG_LEVEL_DEBUG); logger1.set_level(srslog::basic_levels::debug);
log2->set_level(srslte::LOG_LEVEL_DEBUG); logger1.set_hex_dump_max_size(-1);
log1->set_hex_limit(-1); logger2.set_level(srslog::basic_levels::debug);
log2->set_hex_limit(-1); logger2.set_hex_dump_max_size(-1);
// configure RLC entities // configure RLC entities
rlc_config_t cnfg = rlc_config_t::default_rlc_um_nr_config(6); rlc_config_t cnfg = rlc_config_t::default_rlc_um_nr_config(6);
@ -96,7 +96,8 @@ public:
tester.set_expected_sdu_len(1); tester.set_expected_sdu_len(1);
} }
srslte::log_ref log1, log2; srslog::basic_logger& logger1;
srslog::basic_logger& logger2;
srslte::timer_handler timers; srslte::timer_handler timers;
rlc_um_tester tester; rlc_um_tester tester;
rlc_um_nr rlc1, rlc2; rlc_um_nr rlc1, rlc2;
@ -561,6 +562,8 @@ int main(int argc, char** argv)
pcap_handle->open("rlc_um_nr_test.pcap"); pcap_handle->open("rlc_um_nr_test.pcap");
#endif #endif
srslog::init();
if (rlc_um_nr_test1()) { if (rlc_um_nr_test1()) {
fprintf(stderr, "rlc_um_nr_test1() failed.\n"); fprintf(stderr, "rlc_um_nr_test1() failed.\n");
return SRSLTE_ERROR; return SRSLTE_ERROR;

@ -34,17 +34,17 @@ class rlc_um_lte_test_context1
{ {
public: public:
rlc_um_lte_test_context1() : rlc_um_lte_test_context1() :
log1("RLC_UM_1"), logger1(srslog::fetch_basic_logger("RLC_UM_1", false)),
log2("RLC_UM_2"), logger2(srslog::fetch_basic_logger("RLC_UM_2", false)),
timers(16), timers(16),
rlc1(log1, 3, &tester, &tester, &timers), rlc1(logger1, 3, &tester, &tester, &timers),
rlc2(log2, 3, &tester, &tester, &timers) rlc2(logger2, 3, &tester, &tester, &timers)
{ {
// setup logging // setup logging
log1->set_level(srslte::LOG_LEVEL_DEBUG); logger1.set_level(srslog::basic_levels::debug);
log2->set_level(srslte::LOG_LEVEL_DEBUG); logger1.set_hex_dump_max_size(-1);
log1->set_hex_limit(-1); logger2.set_level(srslog::basic_levels::debug);
log2->set_hex_limit(-1); logger2.set_hex_dump_max_size(-1);
// configure RLC entities // configure RLC entities
rlc_config_t cnfg = rlc_config_t::default_rlc_um_config(10); rlc_config_t cnfg = rlc_config_t::default_rlc_um_config(10);
@ -58,7 +58,8 @@ public:
tester.set_expected_sdu_len(1); tester.set_expected_sdu_len(1);
} }
srslte::log_ref log1, log2; srslog::basic_logger& logger1;
srslog::basic_logger& logger2;
srslte::timer_handler timers; srslte::timer_handler timers;
rlc_um_tester tester; rlc_um_tester tester;
rlc_um_lte rlc1, rlc2; rlc_um_lte rlc1, rlc2;
@ -426,6 +427,8 @@ int pdu_pack_no_space_test()
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
srslog::init();
if (meas_obj_test()) { if (meas_obj_test()) {
return -1; return -1;
} }

Loading…
Cancel
Save