Port enb specific classes to use srslog (#2155)

* - Started porting the enb PHY layer to use srslog loggers.
- Updated srslog to manage the none level.

* Finished porting enb phy layer including the NR part.

* Ported MAC, GTPU, PDCP, RLC and S1AP enb classes to use srslog.

* Use new stack logger.

* Ported the enb RRC clases to use srslog.

* Remove unused log macros.

* Replace loggers in sched, sched_carrier, sched_helpers.

* Replaced loggers in sched grid.

* Replaced loggers in sched harq.

* Replaced loggers in sched ue.

* Replaced loggers in sched ue ctrl.

* Replace loggers in sched ue ctrl TPC.

* Replaced loggers in sched subclasses.

* Replaced loggers in rrc_meascfg_test

* Configure loggers in rrc_mobility_test.

* Fix compilation errors left out after the rebase.

* - Implement a custom log sink that will serve as a test spy to intercept and count the number of error and warning log entries.
- Adapt the erab_test_setup and rrc_mobility tests to use this new class and make them pass again.

* - Remove trailing new lines introduced in the rebase.
- Ported the sched_ue_cell class to srslog.

* Remove unused log member.

* Ported mac tests to srslog.

* - Removed remaining trailing newlines from log entries.

* Fix compiler errors detected in CI.

* Fix another static variable without definition passed to log lines.

* Fixed a bug in srslog::flush that would never end when the backend queue is full.

* Fetch the RRC logger instead of injecting it in the constructor.
master
faluco 4 years ago committed by GitHub
parent 4709bacefd
commit 711438f756
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -19,6 +19,7 @@
#define SRSLTE_SIGNAL_HANDLER_H
#include "srslte/srslog/sink.h"
#include "srslte/srslog/srslog.h"
#include <signal.h>
#include <stdio.h>
@ -37,6 +38,7 @@ static void srslte_signal_handler(int signal)
switch (signal) {
case SIGALRM:
fprintf(stderr, "Couldn't stop after %ds. Forcing exit.\n", SRSLTE_TERM_TIMEOUT_S);
srslog::flush();
//:TODO: refactor the sighandler, should not depend on log utilities
if (log_sink) {
log_sink->flush();

@ -20,6 +20,8 @@
#include "srslte/common/log.h"
#include "srslte/common/log_filter.h"
#include "srslte/common/logmap.h"
#include "srslte/srslog/srslog.h"
#include <atomic>
#include <cstdio>
namespace srslte {
@ -82,6 +84,65 @@ public:
uint32_t error_counter = 0, warn_counter = 0;
};
/// This custom sink intercepts log messages to count error and warning log entries.
class log_sink_spy : public srslog::sink
{
public:
explicit log_sink_spy(std::unique_ptr<srslog::log_formatter> f) :
srslog::sink(std::move(f)), s(srslog::get_default_sink())
{
error_counter.store(0);
warning_counter.store(0);
}
/// Identifier of this custom sink.
static const char* name() { return "log_sink_spy"; }
/// Returns the number of log entries tagged as errors.
unsigned get_error_counter() const
{
// Flush to make sure all entries have been processed by the backend.
srslog::flush();
return error_counter.load();
}
/// Returns the number of log entries tagged as warnings.
unsigned get_warning_counter() const
{
// Flush to make sure all entries have been processed by the backend.
srslog::flush();
return warning_counter.load();
}
/// Resets the counters back to 0.
void reset_counters()
{
// Flush to make sure all entries have been processed by the backend.
srslog::flush();
error_counter.store(0);
warning_counter.store(0);
}
srslog::detail::error_string write(srslog::detail::memory_buffer buffer) override
{
std::string entry(buffer.data(), buffer.size());
if (entry.find("[E]") != std::string::npos) {
error_counter.fetch_add(1);
} else if (entry.find("[W]") != std::string::npos) {
warning_counter.fetch_add(1);
}
return s.write(buffer);
}
srslog::detail::error_string flush() override { return s.flush(); }
private:
srslog::sink& s;
std::atomic<unsigned> error_counter;
std::atomic<unsigned> warning_counter;
};
// specialization of test_log_filter to store last logged message
class nullsink_log : public test_log_filter
{

@ -31,8 +31,9 @@ public:
/// NOTE: Calling this function more than once has no side effects.
virtual void start() = 0;
/// Pushes a log entry into the backend.
virtual void push(log_entry&& entry) = 0;
/// Pushes a log entry into the backend. Returns true on success, otherwise
/// false.
virtual bool push(log_entry&& entry) = 0;
/// Returns true when the backend has been started, otherwise false.
virtual bool is_running() const = 0;

@ -40,32 +40,38 @@ public:
work_queue(const work_queue&) = delete;
work_queue& operator=(const work_queue&) = delete;
/// Inserts a new element into the back of the queue.
void push(const T& value)
/// Inserts a new element into the back of the queue. Returns false when the
/// queue is full, otherwise true.
bool push(const T& value)
{
cond_var.lock();
// Discard the new element if we reach the maximum capacity.
if (queue.size() > capacity) {
cond_var.unlock();
return;
return false;
}
queue.push(value);
cond_var.signal();
cond_var.unlock();
return true;
}
/// Inserts a new element into the back of the queue.
void push(T&& value)
/// Inserts a new element into the back of the queue. Returns false when the
/// queue is full, otherwise true.
bool push(T&& value)
{
cond_var.lock();
// Discard the new element if we reach the maximum capacity.
if (queue.size() > capacity) {
cond_var.unlock();
return;
return false;
}
queue.push(std::move(value));
cond_var.signal();
cond_var.unlock();
return true;
}
/// Extracts the top most element from the queue.

@ -29,14 +29,12 @@ class logger_impl : public T
static_assert(std::is_enum<Enum>::value, "Expected enum type");
using enum_base_type = typename std::underlying_type<Enum>::type;
static constexpr unsigned size = static_cast<enum_base_type>(Enum::LAST);
static constexpr unsigned size = static_cast<enum_base_type>(Enum::LAST) - 1;
public:
template <typename... Args>
explicit logger_impl(std::string id, Args&&... args) :
T{std::forward<Args>(args)...},
logger_id(std::move(id)),
channels{&args...}
T{std::forward<Args>(args)...}, logger_id(std::move(id)), channels{&args...}
{
static_assert(
sizeof...(args) == size,
@ -53,8 +51,18 @@ public:
void set_level(Enum lvl)
{
detail::scoped_lock lock(m);
// Disable all channels ...
if (lvl == Enum::none) {
for (unsigned i = 0, e = channels.size(); i != e; ++i) {
channels[i]->set_enabled(false);
}
return;
}
// ... otherwise do it selectively.
for (unsigned i = 0, e = channels.size(); i != e; ++i) {
channels[i]->set_enabled(static_cast<Enum>(i) <= lvl);
channels[i]->set_enabled(static_cast<Enum>(i + 1) <= lvl);
}
}
@ -103,8 +111,9 @@ struct is_logger<logger_impl<T, Enum>> : std::true_type {};
///
/// To create a new logger type simply follow these steps:
/// 1) Define an enum class where each element will represent a logging level.
/// Order the elements from highest to lowest logging level. The last
/// element should be called LAST as it is a sentinel value.
/// Order the elements from highest to lowest logging level. First element
/// should be "none", which represents a disabled logger.
/// The last element should be called LAST as it is a sentinel value.
/// 2) Define a struct composed by only log_channel references. Declare the
/// members in the same order as done in the enum.
/// 3) Define the new logger type by using the build_logger_type alias. Pass
@ -113,7 +122,8 @@ struct is_logger<logger_impl<T, Enum>> : std::true_type {};
/// Example to declare a logger with three logging levels: error, warning and
/// info, being error the highest logging level and info the lowest:
/// 1) Define the logging level enum:
/// enum class three_level_logger_levels { error, warning, info, LAST };
/// enum class three_level_logger_levels { none, error, warning, info, LAST
/// };
/// 2) Define the struct of three channels (same order as in the enum):
/// struct three_level_logger {
/// log_channel &error;
@ -131,7 +141,7 @@ using build_logger_type = detail::logger_impl<T, Enum>;
///
/// Basic logger with four levels.
enum class basic_levels { error, warning, info, debug, LAST };
enum class basic_levels { none, error, warning, info, debug, LAST };
struct basic_logger_channels {
log_channel& error;
log_channel& warning;
@ -140,6 +150,29 @@ struct basic_logger_channels {
};
using basic_logger = build_logger_type<basic_logger_channels, basic_levels>;
/// Translates a string to the corresponding logger basic level.
inline basic_levels str_to_basic_level(std::string s)
{
std::transform(s.begin(), s.end(), s.begin(), ::toupper);
if ("NONE" == s) {
return basic_levels::none;
}
if ("ERROR" == s) {
return basic_levels::error;
}
if ("WARNING" == s) {
return basic_levels::warning;
}
if ("INFO" == s) {
return basic_levels::info;
}
if ("DEBUG" == s) {
return basic_levels::debug;
}
return basic_levels::none;
}
} // namespace srslog
#endif // SRSLOG_LOGGER_H

@ -116,6 +116,7 @@ void srslog_error(srslog_logger* log, const char* fmt, ...);
const char* srslog_get_logger_id(srslog_logger* log);
typedef enum {
srslog_lvl_none, /**< disable logger */
srslog_lvl_error, /**< error logging level */
srslog_lvl_warning, /**< warning logging level */
srslog_lvl_info, /**< info logging level */

@ -60,7 +60,7 @@ static void format_metadata(const detail::log_entry_metadata& metadata,
// Format optional fields if present.
if (!metadata.log_name.empty()) {
fmt::format_to(buffer, "[{: <4.4}] ", metadata.log_name);
fmt::format_to(buffer, "[{: <4}] ", metadata.log_name);
}
if (metadata.log_tag != '\0') {
fmt::format_to(buffer, "[{}] ", metadata.log_tag);

@ -31,9 +31,9 @@ public:
void start() override { worker.start(); }
void push(detail::log_entry&& entry) override
bool push(detail::log_entry&& entry) override
{
queue.push(std::move(entry));
return queue.push(std::move(entry));
}
bool is_running() const override { return worker.is_running(); }

@ -201,7 +201,10 @@ void srslog::flush()
cmd.flush_cmd = std::unique_ptr<detail::flush_backend_cmd>(
new detail::flush_backend_cmd{completion_flag, std::move(sinks)});
instance.get_backend().push(std::move(cmd));
// Make sure the flush command gets into the backend, otherwise we will be
// stuck waiting forever for the command to succeed.
while (!instance.get_backend().push(std::move(cmd))) {
}
// Block the caller thread until we are signaled that the flush is completed.
while (!completion_flag) {

@ -145,6 +145,8 @@ const char* srslog_get_logger_id(srslog_logger* log)
static basic_levels convert_c_enum_to_basic_levels(srslog_log_levels lvl)
{
switch (lvl) {
case srslog_lvl_none:
return basic_levels::none;
case srslog_lvl_debug:
return basic_levels::debug;
case srslog_lvl_info:
@ -156,7 +158,7 @@ static basic_levels convert_c_enum_to_basic_levels(srslog_log_levels lvl)
}
assert(false && "Invalid enum value");
return basic_levels::error;
return basic_levels::none;
}
void srslog_set_logger_level(srslog_logger* log, srslog_log_levels lvl)

@ -26,7 +26,11 @@ class backend_spy : public detail::log_backend
public:
void start() override {}
void push(detail::log_entry&& entry) override { ++count; }
bool push(detail::log_entry&& entry) override
{
++count;
return true;
}
bool is_running() const override { return true; }

@ -62,10 +62,11 @@ class backend_spy : public detail::log_backend
public:
void start() override {}
void push(detail::log_entry&& entry) override
bool push(detail::log_entry&& entry) override
{
e = std::move(entry);
++count;
return true;
}
bool is_running() const override { return true; }

@ -21,7 +21,7 @@ static constexpr char logger_id[] = "TestLogger";
namespace {
/// Definition of a three level logger
enum class test_logger_levels { error, warning, info, LAST };
enum class test_logger_levels { none, error, warning, info, LAST };
struct test_logger_channels {
log_channel& error;
log_channel& warning;
@ -100,12 +100,31 @@ static bool when_level_is_set_to_info_then_all_are_enabled()
return true;
}
static bool when_level_is_set_to_none_then_all_are_disabled()
{
test_dummies::backend_dummy backend;
test_dummies::sink_dummy s;
log_channel error("err", s, backend);
log_channel warning("warning", s, backend);
log_channel info("info", s, backend);
test_logger logger(logger_id, error, warning, info);
logger.set_level(test_logger_levels::none);
ASSERT_EQ(logger.error.enabled(), false);
ASSERT_EQ(logger.warning.enabled(), false);
ASSERT_EQ(logger.info.enabled(), false);
return true;
}
int main()
{
TEST_FUNCTION(when_logger_is_created_then_id_matches_expected_value);
TEST_FUNCTION(when_level_is_set_to_error_then_info_and_warning_is_disabled);
TEST_FUNCTION(when_level_is_set_to_warning_then_info_is_disabled);
TEST_FUNCTION(when_level_is_set_to_info_then_all_are_enabled);
TEST_FUNCTION(when_level_is_set_to_none_then_all_are_disabled);
return 0;
}

@ -165,7 +165,7 @@ static bool when_invalid_id_with_valid_type_is_passed_then_no_logger_is_found()
}
/// Dummy logger type
enum class dummy_levels { error, LAST };
enum class dummy_levels { none, error, LAST };
struct dummy_logger_channels {
log_channel& error;
};

@ -88,7 +88,7 @@ class backend_dummy : public srslog::detail::log_backend
public:
void start() override {}
void push(srslog::detail::log_entry&& entry) override {}
bool push(srslog::detail::log_entry&& entry) override { return true; }
bool is_running() const override { return true; }
};

@ -41,6 +41,7 @@
#include "srslte/interfaces/enb_metrics_interface.h"
#include "srslte/interfaces/sched_interface.h"
#include "srslte/interfaces/ue_interfaces.h"
#include "srslte/srslog/srslog.h"
namespace srsenb {
@ -111,7 +112,7 @@ struct rrc_cfg_t;
class enb : public enb_metrics_interface, enb_command_interface
{
public:
enb();
enb(srslog::sink& log_sink);
virtual ~enb();
@ -135,7 +136,8 @@ private:
int parse_args(const all_args_t& args_, rrc_cfg_t& rrc_cfg);
srslte::logger* logger = nullptr;
srslte::log_ref log; // Own logger for eNB
srslog::sink& log_sink;
srslog::basic_logger& enb_log;
srslte::log_filter pool_log;

@ -16,6 +16,7 @@
#include <string.h>
#include "../phy_common.h"
#include "srslte/srslog/srslog.h"
#define LOG_EXECTIME
@ -25,9 +26,9 @@ namespace lte {
class cc_worker
{
public:
cc_worker();
cc_worker(srslog::basic_logger& logger);
~cc_worker();
void init(phy_common* phy, srslte::log* log_h, uint32_t cc_idx);
void init(phy_common* phy, uint32_t cc_idx);
void reset();
cf_t* get_buffer_rx(uint32_t antenna_idx);
@ -70,7 +71,7 @@ private:
int decode_pucch();
/* Common objects */
srslte::log* log_h = nullptr;
srslog::basic_logger& logger;
phy_common* phy = nullptr;
bool initiated = false;

@ -18,6 +18,7 @@
#include "../phy_common.h"
#include "cc_worker.h"
#include "srslte/srslog/srslog.h"
#include "srslte/srslte.h"
namespace srsenb {
@ -26,9 +27,9 @@ namespace lte {
class sf_worker : public srslte::thread_pool::worker
{
public:
sf_worker() = default;
sf_worker(srslog::basic_logger& logger) : logger(logger) {}
~sf_worker();
void init(phy_common* phy, srslte::log* log_h);
void init(phy_common* phy);
cf_t* get_buffer_rx(uint32_t cc_idx, uint32_t antenna_idx);
void set_time(uint32_t tti_, uint32_t tx_worker_cnt_, const srslte::rf_timestamp_t& tx_time_);
@ -53,7 +54,7 @@ private:
void work_imp() final;
/* Common objects */
srslte::log* log_h = nullptr;
srslog::basic_logger& logger;
phy_common* phy = nullptr;
bool initiated = false;
bool running = false;

@ -30,10 +30,6 @@ namespace lte {
class worker_pool
{
private:
std::vector<std::unique_ptr<srslte::log_filter> > log_vec;
srslte::thread_pool pool;
std::vector<std::unique_ptr<sf_worker> > workers;
@ -42,7 +38,7 @@ public:
uint32_t get_nof_workers() { return (uint32_t)workers.size(); }
worker_pool(uint32_t max_workers);
bool init(const phy_args_t& args, phy_common* common, srslte::logger* logger, int prio);
bool init(const phy_args_t& args, phy_common* common, srslog::sink& log_sink, int prio);
sf_worker* wait_worker(uint32_t tti);
sf_worker* wait_worker_id(uint32_t id);
void start_worker(sf_worker* w);

@ -25,6 +25,7 @@
#include "srslte/common/log.h"
#include "srslte/interfaces/gnb_interfaces.h"
#include "srslte/phy/enb/enb_dl_nr.h"
#include "srslte/srslog/srslog.h"
#include <array>
#include <vector>
@ -61,7 +62,7 @@ public:
class cc_worker
{
public:
cc_worker(uint32_t cc_idx, srslte::log* log, phy_nr_state* phy_state_);
cc_worker(uint32_t cc_idx, srslog::basic_logger& logger, phy_nr_state* phy_state_);
~cc_worker();
bool set_carrier(const srslte_carrier_nr_t* carrier);
@ -84,7 +85,7 @@ private:
uint32_t buffer_sz = 0;
phy_nr_state* phy_state;
srslte_enb_dl_nr_t enb_dl = {};
srslte::log* log_h = nullptr;
srslog::basic_logger& logger;
};
} // namespace nr

@ -25,6 +25,7 @@
#include "cc_worker.h"
#include "srsenb/hdr/phy/phy_common.h"
#include "srslte/common/thread_pool.h"
#include "srslte/srslog/srslog.h"
namespace srsenb {
namespace nr {
@ -40,7 +41,7 @@ namespace nr {
class sf_worker final : public srslte::thread_pool::worker
{
public:
sf_worker(phy_common* phy_, phy_nr_state* phy_state_, srslte::log* log);
sf_worker(phy_common* phy_, phy_nr_state* phy_state_, srslog::basic_logger& logger);
~sf_worker();
bool set_carrier_unlocked(uint32_t cc_idx, const srslte_carrier_nr_t* carrier_);
@ -59,7 +60,7 @@ private:
phy_common* phy = nullptr;
phy_nr_state* phy_state = nullptr;
srslte::log* log_h = nullptr;
srslog::basic_logger& logger;
// Temporal attributes
srslte_softbuffer_tx_t softbuffer_tx = {};

@ -30,10 +30,6 @@ namespace nr {
class worker_pool
{
private:
std::vector<std::unique_ptr<srslte::log_filter> > log_vec;
srslte::thread_pool pool;
std::vector<std::unique_ptr<sf_worker> > workers;
phy_nr_state phy_state;
@ -42,7 +38,7 @@ public:
sf_worker* operator[](std::size_t pos) { return workers.at(pos).get(); }
worker_pool(uint32_t max_workers);
bool init(const phy_args_t& args, phy_common* common, srslte::logger* logger, int prio);
bool init(const phy_args_t& args, phy_common* common, srslog::sink& log_sink, int prio);
sf_worker* wait_worker(uint32_t tti);
sf_worker* wait_worker_id(uint32_t id);
void start_worker(sf_worker* w);

@ -13,8 +13,8 @@
#ifndef SRSENB_PHY_H
#define SRSENB_PHY_H
#include "phy_common.h"
#include "lte/sf_worker.h"
#include "phy_common.h"
#include "srsenb/hdr/phy/enb_phy_base.h"
#include "srslte/common/log.h"
#include "srslte/common/log_filter.h"
@ -23,6 +23,7 @@
#include "srslte/interfaces/enb_metrics_interface.h"
#include "srslte/interfaces/radio_interfaces.h"
#include "srslte/radio/radio.h"
#include "srslte/srslog/srslog.h"
#include "txrx.h"
namespace srsenb {
@ -30,7 +31,7 @@ namespace srsenb {
class phy final : public enb_phy_base, public phy_interface_stack_lte, public srslte::phy_interface_radio
{
public:
phy(srslte::logger* logger_);
phy(srslog::sink& log_sink);
~phy();
int init(const phy_args_t& args,
@ -76,9 +77,9 @@ private:
srslte::radio_interface_phy* radio = nullptr;
srslte::logger* logger = nullptr;
std::unique_ptr<srslte::log_filter> log_h = nullptr;
std::unique_ptr<srslte::log_filter> log_phy_lib_h = nullptr;
srslog::sink& log_sink;
srslog::basic_logger& phy_log;
srslog::basic_logger& phy_lib_log;
lte::worker_pool lte_workers;
nr::worker_pool nr_workers;

@ -18,6 +18,7 @@
#include "srslte/common/log.h"
#include "srslte/common/threads.h"
#include "srslte/interfaces/enb_interfaces.h"
#include "srslte/srslog/srslog.h"
// Setting ENABLE_PRACH_GUI to non zero enables a GUI showing signal received in the PRACH window.
#define ENABLE_PRACH_GUI 0
@ -31,12 +32,14 @@ namespace srsenb {
class prach_worker : srslte::thread
{
public:
prach_worker(uint32_t cc_idx_) : buffer_pool(8), thread("PRACH_WORKER") { cc_idx = cc_idx_; }
prach_worker(uint32_t cc_idx_, srslog::basic_logger& logger) : buffer_pool(8), thread("PRACH_WORKER"), logger(logger)
{
cc_idx = cc_idx_;
}
int init(const srslte_cell_t& cell_,
const srslte_prach_cfg_t& prach_cfg_,
stack_interface_phy_lte* mac,
srslte::log* log_h,
int priority,
uint32_t nof_workers);
int new_tti(uint32_t tti, cf_t* buffer);
@ -79,8 +82,8 @@ private:
srslte::buffer_pool<sf_buffer> buffer_pool;
srslte::block_queue<sf_buffer*> pending_buffers;
srslog::basic_logger& logger;
sf_buffer* current_buffer = nullptr;
srslte::log* log_h = nullptr;
stack_interface_phy_lte* stack = nullptr;
float max_prach_offset_us = 0.0f;
bool initiated = false;
@ -106,16 +109,16 @@ public:
const srslte_cell_t& cell_,
const srslte_prach_cfg_t& prach_cfg_,
stack_interface_phy_lte* mac,
srslte::log* log_h,
srslog::basic_logger& logger,
int priority,
uint32_t nof_workers_x_cc)
{
// Create PRACH worker if required
while (cc_idx >= prach_vec.size()) {
prach_vec.push_back(std::unique_ptr<prach_worker>(new prach_worker(prach_vec.size())));
prach_vec.push_back(std::unique_ptr<prach_worker>(new prach_worker(prach_vec.size(), logger)));
}
prach_vec[cc_idx]->init(cell_, prach_cfg_, mac, log_h, priority, nof_workers_x_cc);
prach_vec[cc_idx]->init(cell_, prach_cfg_, mac, priority, nof_workers_x_cc);
}
void set_max_prach_offset_us(float delay_us)

@ -27,14 +27,13 @@ namespace srsenb {
class txrx final : public srslte::thread
{
public:
txrx();
txrx(srslog::basic_logger& logger);
bool init(stack_interface_phy_lte* stack_,
srslte::radio_interface_phy* radio_handler,
lte::worker_pool* lte_workers_,
nr::worker_pool* nr_workers_,
phy_common* worker_com,
prach_worker_pool* prach_,
srslte::log* log_h,
uint32_t prio);
void stop();
@ -43,7 +42,7 @@ private:
stack_interface_phy_lte* stack = nullptr;
srslte::radio_interface_phy* radio_h = nullptr;
srslte::log* log_h = nullptr;
srslog::basic_logger& logger;
lte::worker_pool* lte_workers = nullptr;
nr::worker_pool* nr_workers = nullptr;
prach_worker_pool* prach = nullptr;

@ -29,6 +29,7 @@
#include "enb_stack_base.h"
#include "srslte/interfaces/enb_interfaces.h"
#include "srslte/interfaces/enb_rrc_interface_types.h"
#include "srslte/srslog/srslog.h"
namespace srsenb {
@ -39,7 +40,7 @@ class enb_stack_lte final : public enb_stack_base,
public srslte::thread
{
public:
enb_stack_lte(srslte::logger* logger_);
enb_stack_lte(srslte::logger* logger_, srslog::sink& log_sink);
~enb_stack_lte() final;
// eNB stack base interface
@ -117,6 +118,14 @@ private:
stack_args_t args = {};
rrc_cfg_t rrc_cfg = {};
srslog::basic_logger &mac_logger;
srslog::basic_logger &rlc_logger;
srslog::basic_logger &pdcp_logger;
srslog::basic_logger &rrc_logger;
srslog::basic_logger &s1ap_logger;
srslog::basic_logger &gtpu_logger;
srslog::basic_logger &stack_logger;
// task handling
srslte::task_scheduler task_sched;
srslte::task_queue_handle enb_task_queue, gtpu_task_queue, mme_task_queue, sync_task_queue;

@ -24,6 +24,7 @@
#include "srslte/interfaces/enb_metrics_interface.h"
#include "srslte/interfaces/enb_rrc_interface_types.h"
#include "srslte/interfaces/sched_interface.h"
#include "srslte/srslog/srslog.h"
#include "ta.h"
#include "ue.h"
#include <vector>
@ -33,7 +34,7 @@ namespace srsenb {
class mac final : public mac_interface_phy_lte, public mac_interface_rlc, public mac_interface_rrc
{
public:
mac(srslte::ext_task_sched_handle task_sched_);
mac(srslte::ext_task_sched_handle task_sched_, srslog::basic_logger& logger);
~mac();
bool init(const mac_args_t& args_,
const cell_list_t& cells_,
@ -106,6 +107,8 @@ private:
std::mutex rnti_mutex;
srslog::basic_logger& logger;
// We use a rwlock in MAC to allow multiple workers to access MAC simultaneously. No conflicts will happen since
// access for different TTIs
pthread_rwlock_t rwlock = {};

@ -88,7 +88,6 @@ protected:
int ue_db_access(uint16_t rnti, Func, const char* func_name = nullptr);
// args
srslte::log_ref log_h;
rrc_interface_mac* rrc = nullptr;
sched_args_t sched_cfg = {};
std::vector<sched_cell_params_t> sched_cell_params;

@ -15,6 +15,7 @@
#include "sched.h"
#include "schedulers/sched_base.h"
#include "srslte/srslog/srslog.h"
namespace srsenb {
@ -50,7 +51,7 @@ private:
// args
const sched_cell_params_t* cc_cfg = nullptr;
srslte::log_ref log_h;
srslog::basic_logger& logger;
rrc_interface_mac* rrc = nullptr;
std::map<uint16_t, sched_ue>* ue_db = nullptr;
const uint32_t enb_cc_idx;
@ -114,7 +115,7 @@ public:
private:
// args
srslte::log_ref log_h;
srslog::basic_logger& logger;
const sched_cell_params_t* cc_cfg = nullptr;
std::map<uint16_t, sched_ue>* ue_db = nullptr;

@ -17,6 +17,7 @@
#include "sched_ue.h"
#include "srslte/adt/bounded_bitset.h"
#include "srslte/common/log.h"
#include "srslte/srslog/srslog.h"
#include <deque>
#include <vector>
@ -99,6 +100,8 @@ public:
};
using alloc_result_t = std::vector<const alloc_t*>;
pdcch_grid_t() : logger(srslog::fetch_basic_logger("MAC")) {}
void init(const sched_cell_params_t& cell_params_);
void new_tti(tti_point tti_rx_);
bool alloc_dci(alloc_type_t alloc_type, uint32_t aggr_idx, sched_ue* user = nullptr);
@ -147,7 +150,7 @@ private:
// consts
const sched_cell_params_t* cc_cfg = nullptr;
srslte::log_ref log_h;
srslog::basic_logger& logger;
// tti vars
tti_point tti_rx;
@ -165,6 +168,8 @@ public:
rbg_interval rbg_range;
};
sf_grid_t() : logger(srslog::fetch_basic_logger("MAC")) {}
void init(const sched_cell_params_t& cell_params_);
void new_tti(tti_point tti_rx);
dl_ctrl_alloc_t alloc_dl_ctrl(uint32_t aggr_lvl, alloc_type_t alloc_type);
@ -185,7 +190,7 @@ private:
// consts
const sched_cell_params_t* cc_cfg = nullptr;
srslte::log_ref log_h;
srslog::basic_logger& logger;
uint32_t nof_rbgs = 0;
uint32_t si_n_rbg = 0, rar_n_rbg = 0;
@ -305,7 +310,7 @@ private:
// consts
const sched_cell_params_t* cc_cfg = nullptr;
srslte::log_ref log_h;
srslog::basic_logger& logger;
sf_sched_result* cc_results; ///< Results of other CCs for the same Subframe
prbmask_t pucch_mask;

@ -16,6 +16,7 @@
#include "srsenb/hdr/stack/mac/sched_common.h"
#include "srslte/common/logmap.h"
#include "srslte/interfaces/sched_interface.h"
#include "srslte/srslog/srslog.h"
namespace srsenb {
@ -154,10 +155,14 @@ inline bool operator==(const sched_interface::ue_cfg_t::cc_cfg_t& lhs, const sch
int check_ue_cfg_correctness(const sched_interface::ue_cfg_t& ue_cfg);
/// Logs DL MAC PDU contents
void log_dl_cc_results(srslte::log_ref log_h, uint32_t enb_cc_idx, const sched_interface::dl_sched_res_t& result);
void log_dl_cc_results(srslog::basic_logger& logger,
uint32_t enb_cc_idx,
const sched_interface::dl_sched_res_t& result);
/// Logs PHICH contents
void log_phich_cc_results(srslte::log_ref log_h, uint32_t enb_cc_idx, const sched_interface::ul_sched_res_t& result);
void log_phich_cc_results(srslog::basic_logger& logger,
uint32_t enb_cc_idx,
const sched_interface::ul_sched_res_t& result);
const char* to_string(sched_interface::ue_bearer_cfg_t::direction_t dir);

@ -15,6 +15,7 @@
#include "sched_common.h"
#include "srslte/common/log.h"
#include "srslte/srslog/srslog.h"
#include <map>
#include <vector>
@ -180,7 +181,7 @@ private:
/* Args */
ue_cfg_t cfg = {};
srslte_cell_t cell = {};
mutable srslte::log_ref log_h;
srslog::basic_logger& logger;
const sched_cell_params_t* main_cc_params = nullptr;
/* Buffer states */

@ -17,6 +17,7 @@
#include "srslte/common/log.h"
#include "srslte/common/tti_point.h"
#include "srslte/interfaces/sched_interface.h"
#include "srslte/srslog/srslog.h"
namespace srsenb {
@ -54,8 +55,6 @@ protected:
srslte::tti_point tti;
int last_mcs[SRSLTE_MAX_TB];
int last_tbs[SRSLTE_MAX_TB];
srslte::log_ref log_h;
};
class dl_harq_proc : public harq_proc
@ -111,6 +110,7 @@ public:
static const bool is_async = ASYNC_DL_SCHED;
harq_entity(size_t nof_dl_harqs, size_t nof_ul_harqs);
void reset();
void new_tti(tti_point tti_rx);
@ -156,7 +156,6 @@ public:
private:
dl_harq_proc* get_oldest_dl_harq(tti_point tti_tx_dl);
srslte::log_ref log_h;
std::array<tti_point, SRSLTE_FDD_NOF_HARQ> last_ttis;
std::vector<dl_harq_proc> dl_harqs;

@ -16,6 +16,7 @@
#include "srslte/common/logmap.h"
#include "srslte/interfaces/sched_interface.h"
#include "srslte/mac/pdu.h"
#include "srslte/srslog/srslog.h"
namespace srsenb {
@ -25,6 +26,7 @@ class lch_ue_manager
constexpr static uint32_t MAX_LC = sched_interface::MAX_LC;
public:
lch_ue_manager() : logger(srslog::fetch_basic_logger("MAC")) {}
void set_cfg(const sched_interface::ue_cfg_t& cfg_);
void new_tti();
@ -72,7 +74,7 @@ private:
int alloc_tx_bytes(uint8_t lcid, int rem_bytes);
size_t prio_idx = 0;
srslte::log_ref log_h{"MAC"};
srslog::basic_logger& logger;
std::array<ue_bearer_t, sched_interface::MAX_LC> lch = {};
std::array<int, 4> lcg_bsr = {};
};

@ -78,7 +78,7 @@ struct sched_ue_cell {
private:
void enter_idle_st();
srslte::log_ref log_h{"MAC"};
srslog::basic_logger& logger;
const sched_interface::ue_cfg_t* ue_cfg = nullptr;
tti_point cfg_tti;

@ -16,6 +16,7 @@
#include "srslte/adt/accumulators.h"
#include "srslte/common/common.h"
#include "srslte/common/logmap.h"
#include "srslte/srslog/srslog.h"
namespace srsenb {
@ -124,7 +125,7 @@ private:
case 3:
return 3;
default:
srslte::logmap::get("MAC")->warning("Invalid TPC delta value=%d\n", delta);
srslog::fetch_basic_logger("MAC").warning("Invalid TPC delta value=%d", delta);
return 1;
}
}

@ -29,7 +29,7 @@ public:
virtual void sched_ul_users(std::map<uint16_t, sched_ue>& ue_db, sf_sched* tti_sched) = 0;
protected:
srslte::log_ref log_h = srslte::logmap::get("MAC");
srslog::basic_logger& logger = srslog::fetch_basic_logger("MAC");
};
/**************** Helper methods ****************/

@ -22,6 +22,7 @@
#include "srslte/interfaces/sched_interface.h"
#include "srslte/mac/pdu.h"
#include "srslte/mac/pdu_queue.h"
#include "srslte/srslog/srslog.h"
#include "ta.h"
#include <pthread.h>
#include <vector>
@ -38,6 +39,7 @@ public:
rlc_interface_mac* rlc,
phy_interface_stack_lte* phy_,
srslte::log_ref log_,
srslog::basic_logger& logger,
uint32_t nof_cells_,
uint32_t nof_rx_harq_proc = SRSLTE_FDD_NOF_HARQ,
uint32_t nof_tx_harq_proc = SRSLTE_FDD_NOF_HARQ * SRSLTE_MAX_TB);
@ -139,6 +141,7 @@ private:
rrc_interface_mac* rrc = nullptr;
phy_interface_stack_lte* phy = nullptr;
srslte::log_ref log_h;
srslog::basic_logger& logger;
sched_interface* sched = nullptr;
// Mutexes

@ -64,7 +64,7 @@ private:
int apply_basic_conn_cfg(const asn1::rrc::rr_cfg_ded_s& rr_cfg);
void apply_current_bearers_cfg();
srslte::log_ref log_h;
srslog::basic_logger& logger;
uint16_t rnti;
const ue_cell_ded_list& ue_cell_list;
const bearer_cfg_handler& bearer_list;

@ -26,6 +26,7 @@
#include "srslte/common/task_scheduler.h"
#include "srslte/common/timeout.h"
#include "srslte/interfaces/enb_interfaces.h"
#include "srslte/srslog/srslog.h"
#include <map>
#include <queue>
@ -45,7 +46,7 @@ class rrc final : public rrc_interface_pdcp,
public rrc_interface_s1ap
{
public:
rrc(srslte::task_sched_handle task_sched_);
explicit rrc(srslte::task_sched_handle task_sched_);
~rrc();
void init(const rrc_cfg_t& cfg_,
@ -121,14 +122,14 @@ public:
const std::string& msg_type)
{
static const char* dir_str[] = {"Rx", "Tx", "S1AP Tx", "S1AP Rx"};
if (rrc_log->get_level() == srslte::LOG_LEVEL_INFO) {
rrc_log->info("%s - %s %s (%zd B)\n", source.c_str(), dir_str[dir], msg_type.c_str(), pdu.size());
} else if (rrc_log->get_level() >= srslte::LOG_LEVEL_DEBUG) {
if (logger.info.enabled()) {
logger.info("%s - %s %s (%zd B)", source.c_str(), dir_str[dir], msg_type.c_str(), pdu.size());
} else if (logger.debug.enabled()) {
asn1::json_writer json_writer;
msg.to_json(json_writer);
rrc_log->debug_hex(
pdu.data(), pdu.size(), "%s - %s %s (%zd B)\n", source.c_str(), dir_str[dir], msg_type.c_str(), pdu.size());
rrc_log->debug_long("Content:\n%s\n", json_writer.to_string().c_str());
logger.debug(
pdu.data(), pdu.size(), "%s - %s %s (%zd B)", source.c_str(), dir_str[dir], msg_type.c_str(), pdu.size());
logger.debug("Content:\n%s", json_writer.to_string().c_str());
}
}
@ -144,6 +145,7 @@ private:
gtpu_interface_rrc* gtpu = nullptr;
s1ap_interface_rrc* s1ap = nullptr;
srslte::log_ref rrc_log;
srslog::basic_logger& logger;
// derived params
std::unique_ptr<enb_cell_common_list> cell_common_list;

@ -18,13 +18,24 @@
#include "srslte/common/logmap.h"
#include "srslte/interfaces/enb_interfaces.h"
#include "srslte/interfaces/enb_rrc_interface_types.h"
#include "srslte/srslog/srslog.h"
namespace srsenb {
class security_cfg_handler
{
public:
explicit security_cfg_handler(const rrc_cfg_t& cfg_) : cfg(&cfg_) {}
explicit security_cfg_handler(const rrc_cfg_t& cfg_) : cfg(&cfg_), logger(srslog::fetch_basic_logger("RRC")) {}
security_cfg_handler& operator=(const security_cfg_handler& other)
{
cfg = other.cfg;
k_enb_present = other.k_enb_present;
security_capabilities = other.security_capabilities;
std::copy(other.k_enb, other.k_enb + 32, k_enb);
sec_cfg = other.sec_cfg;
ncc = other.ncc;
return *this;
}
bool set_security_capabilities(const asn1::s1ap::ue_security_cap_s& caps);
void set_security_key(const asn1::fixed_bitstring<256, false, true>& key);
@ -40,7 +51,7 @@ public:
private:
void generate_as_keys();
srslte::log_ref log_h{"RRC"};
srslog::basic_logger& logger;
const rrc_cfg_t* cfg = nullptr;
bool k_enb_present = false;
asn1::s1ap::ue_security_cap_s security_capabilities = {};
@ -84,7 +95,7 @@ public:
std::map<uint8_t, erab_t> erabs;
private:
srslte::log_ref log_h{"RRC"};
srslog::basic_logger& logger;
uint16_t rnti = 0;
const rrc_cfg_t* cfg = nullptr;

@ -15,6 +15,7 @@
#include "rrc_config.h"
#include "srslte/common/logmap.h"
#include "srslte/srslog/srslog.h"
namespace srsenb {
@ -169,7 +170,7 @@ private:
bool alloc_pucch_cs_resources();
bool dealloc_pucch_cs_resources();
srslte::log_ref log_h{"RRC"};
srslog::basic_logger& logger;
const rrc_cfg_t& cfg;
const enb_cell_common_list& common_list;
freq_res_common_list& cell_res_list;

@ -33,7 +33,7 @@ public:
};
struct ho_cancel_ev {};
explicit rrc_mobility(srsenb::rrc::ue* outer_ue);
rrc_mobility(srsenb::rrc::ue* outer_ue);
bool fill_conn_recfg_no_ho_cmd(asn1::rrc::rrc_conn_recfg_r8_ies_s* conn_recfg);
void handle_ue_meas_report(const asn1::rrc::meas_report_s& msg);
@ -68,7 +68,7 @@ private:
rrc::ue* rrc_ue = nullptr;
rrc* rrc_enb = nullptr;
srslte::byte_buffer_pool* pool = nullptr;
srslte::log_ref rrc_log;
srslog::basic_logger& logger;
// vars
asn1::rrc::meas_cfg_s current_meas_cfg;

@ -18,6 +18,7 @@
#include "srslte/common/logmap.h"
#include "srslte/common/threads.h"
#include "srslte/interfaces/enb_interfaces.h"
#include "srslte/srslog/srslog.h"
#include "srslte/srslte.h"
#ifndef SRSENB_GTPU_H
@ -28,7 +29,7 @@ namespace srsenb {
class gtpu final : public gtpu_interface_rrc, public gtpu_interface_pdcp
{
public:
gtpu();
explicit gtpu(srslog::basic_logger& logger);
int init(std::string gtp_bind_addr_,
std::string mme_addr_,
@ -63,12 +64,13 @@ private:
std::string mme_addr;
srsenb::pdcp_interface_gtpu* pdcp = nullptr;
srslte::log_ref gtpu_log;
srslog::basic_logger& logger;
// Class to create
class m1u_handler
{
public:
explicit m1u_handler(gtpu* gtpu_) : parent(gtpu_) {}
explicit m1u_handler(gtpu* gtpu_) : parent(gtpu_), logger(parent->logger) {}
~m1u_handler();
m1u_handler(const m1u_handler&) = delete;
m1u_handler(m1u_handler&&) = delete;
@ -81,6 +83,7 @@ private:
gtpu* parent = nullptr;
pdcp_interface_gtpu* pdcp = nullptr;
srslte::log_ref gtpu_log;
srslog::basic_logger& logger;
std::string m1u_multiaddr;
std::string m1u_if_addr;

@ -13,6 +13,7 @@
#include "srslte/common/timers.h"
#include "srslte/interfaces/enb_interfaces.h"
#include "srslte/interfaces/ue_interfaces.h"
#include "srslte/srslog/srslog.h"
#include "srslte/upper/pdcp.h"
#include <map>
@ -24,7 +25,7 @@ namespace srsenb {
class pdcp : public pdcp_interface_rlc, public pdcp_interface_gtpu, public pdcp_interface_rrc
{
public:
pdcp(srslte::task_sched_handle task_sched_, const char* logname);
pdcp(srslte::task_sched_handle task_sched_, srslog::basic_logger& logger);
virtual ~pdcp() {}
void init(rlc_interface_pdcp* rlc_, rrc_interface_pdcp* rrc_, gtpu_interface_pdcp* gtpu_);
void stop();
@ -101,7 +102,7 @@ private:
rrc_interface_pdcp* rrc;
gtpu_interface_pdcp* gtpu;
srslte::task_sched_handle task_sched;
srslte::log_ref log_h;
srslog::basic_logger& logger;
srslte::byte_buffer_pool* pool;
};

@ -13,6 +13,7 @@
#include "srslte/interfaces/enb_interfaces.h"
#include "srslte/interfaces/enb_metrics_interface.h"
#include "srslte/interfaces/ue_interfaces.h"
#include "srslte/srslog/srslog.h"
#include "srslte/upper/rlc.h"
#include <map>
@ -31,11 +32,9 @@ namespace srsenb {
class rlc : public rlc_interface_mac, public rlc_interface_rrc, public rlc_interface_pdcp
{
public:
void init(pdcp_interface_rlc* pdcp_,
rrc_interface_rlc* rrc_,
mac_interface_rlc* mac_,
srslte::timer_handler* timers_,
srslte::log_ref log_h);
explicit rlc(srslog::basic_logger& logger) : logger(logger) {}
void
init(pdcp_interface_rlc* pdcp_, rrc_interface_rlc* rrc_, mac_interface_rlc* mac_, srslte::timer_handler* timers_);
void stop();
void get_metrics(rlc_metrics_t& m, const uint32_t nof_tti);
@ -92,7 +91,7 @@ private:
mac_interface_rlc* mac;
pdcp_interface_rlc* pdcp;
rrc_interface_rlc* rrc;
srslte::log_ref log_h;
srslog::basic_logger& logger;
srslte::byte_buffer_pool* pool;
srslte::timer_handler* timers;
};

@ -28,6 +28,7 @@
#include "srslte/common/network_utils.h"
#include "srslte/common/stack_procedure.h"
#include "srslte/common/task_scheduler.h"
#include "srslte/srslog/srslog.h"
#include <unordered_map>
namespace srsenb {
@ -48,7 +49,7 @@ public:
static const uint32_t ts1_reloc_prep_timeout_ms = 10000;
static const uint32_t ts1_reloc_overall_timeout_ms = 10000;
s1ap(srslte::task_sched_handle task_sched_);
s1ap(srslte::task_sched_handle task_sched_, srslog::basic_logger& logger);
int init(s1ap_args_t args_, rrc_interface_s1ap* rrc_, srsenb::stack_interface_s1ap_lte* stack_);
void stop();
void get_metrics(s1ap_metrics_t& m);
@ -98,7 +99,7 @@ private:
// args
rrc_interface_s1ap* rrc = nullptr;
s1ap_args_t args;
srslte::log_ref s1ap_log;
srslog::basic_logger& logger;
srslte::byte_buffer_pool* pool = nullptr;
srsenb::stack_interface_s1ap_lte* stack = nullptr;
srslte::task_sched_handle task_sched;
@ -207,7 +208,7 @@ private:
// args
s1ap* s1ap_ptr;
srslte::log_ref s1ap_log;
srslog::basic_logger& logger;
// state
bool release_requested = false;

@ -35,7 +35,6 @@ public:
void write_sdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t pdu) final;
private:
srslte::log_ref m_log{"SDAP"};
gtpu_interface_sdap_nr* m_gtpu = nullptr;
pdcp_interface_sdap_nr* m_pdcp = nullptr;
srsue::gw_interface_pdcp* m_gw = nullptr;

@ -24,10 +24,15 @@
namespace srsenb {
enb::enb() : started(false), pool(srslte::byte_buffer_pool::get_instance(ENB_POOL_SIZE))
enb::enb(srslog::sink& log_sink) :
started(false),
log_sink(log_sink),
enb_log(srslog::fetch_basic_logger("ENB", log_sink, false)),
pool(srslte::byte_buffer_pool::get_instance(ENB_POOL_SIZE))
{
// print build info
std::cout << std::endl << get_build_string() << std::endl;
std::cout << std::endl << get_build_string() << std::endl << std::endl;
}
enb::~enb()
@ -42,9 +47,8 @@ int enb::init(const all_args_t& args_, srslte::logger* logger_)
// Init eNB log
srslte::logmap::set_default_logger(logger);
log = srslte::logmap::get("ENB");
log->set_level(srslte::LOG_LEVEL_INFO);
log->info("%s", get_build_string().c_str());
enb_log.set_level(srslog::basic_levels::info);
enb_log.info("%s", get_build_string().c_str());
// Validate arguments
if (parse_args(args_, rrc_cfg)) {
@ -58,7 +62,7 @@ int enb::init(const all_args_t& args_, srslte::logger* logger_)
// Create layers
if (args.stack.type == "lte") {
std::unique_ptr<enb_stack_lte> lte_stack(new enb_stack_lte(logger));
std::unique_ptr<enb_stack_lte> lte_stack(new enb_stack_lte(logger, log_sink));
if (!lte_stack) {
srslte::console("Error creating eNB stack.\n");
return SRSLTE_ERROR;
@ -70,7 +74,7 @@ int enb::init(const all_args_t& args_, srslte::logger* logger_)
return SRSLTE_ERROR;
}
std::unique_ptr<srsenb::phy> lte_phy = std::unique_ptr<srsenb::phy>(new srsenb::phy(logger));
std::unique_ptr<srsenb::phy> lte_phy = std::unique_ptr<srsenb::phy>(new srsenb::phy(log_sink));
if (!lte_phy) {
srslte::console("Error creating LTE PHY instance.\n");
return SRSLTE_ERROR;
@ -139,7 +143,7 @@ int enb::init(const all_args_t& args_, srslte::logger* logger_)
radio = std::move(nr_radio);
#else
srslte::console("ERROR: 5G NR stack not compiled. Please, activate CMAKE HAVE_5GNR flag.\n");
log->error("5G NR stack not compiled. Please, activate CMAKE HAVE_5GNR flag.\n");
enb_log.error("5G NR stack not compiled. Please, activate CMAKE HAVE_5GNR flag.");
#endif
}
@ -251,7 +255,7 @@ std::string enb::get_build_info()
std::string enb::get_build_string()
{
std::stringstream ss;
ss << "Built in " << get_build_mode() << " mode using " << get_build_info() << "." << std::endl;
ss << "Built in " << get_build_mode() << " mode using " << get_build_info() << ".";
return ss.str();
}

@ -127,7 +127,7 @@ int field_carrier_freqs_info_list::parse(libconfig::Setting& root)
data->carrier_freqs_info_list.resize((uint32_t)root.getLength());
data->carrier_freqs_info_list_present = data->carrier_freqs_info_list.size() > 0;
if (data->carrier_freqs_info_list.size() > ASN1_RRC_MAX_GNFG) {
ERROR("CarrierFreqsInfoGERAN cannot have more than %d entries\n", ASN1_RRC_MAX_GNFG);
ERROR("CarrierFreqsInfoGERAN cannot have more than %d entries", ASN1_RRC_MAX_GNFG);
return -1;
}
for (uint32_t i = 0; i < data->carrier_freqs_info_list.size(); i++) {
@ -147,27 +147,27 @@ int field_carrier_freqs_info_list::parse(libconfig::Setting& root)
field_asn1_bitstring_number<asn1::fixed_bitstring<8>, uint8_t> ncc_permitted(
"ncc_permitted", &data->carrier_freqs_info_list[i].common_info.ncc_permitted);
if (ncc_permitted.parse(root[i])) {
ERROR("Error parsing `ncc_permitted` in carrier_freqs_info_lsit=%d\n", i);
ERROR("Error parsing `ncc_permitted` in carrier_freqs_info_lsit=%d", i);
return -1;
}
int q_rx_lev_min = 0;
if (!root[i].lookupValue("q_rx_lev_min", q_rx_lev_min)) {
ERROR("Missing field `q_rx_lev_min` in carrier_freqs_info_list=%d\n", i);
ERROR("Missing field `q_rx_lev_min` in carrier_freqs_info_list=%d", i);
return -1;
}
data->carrier_freqs_info_list[i].common_info.q_rx_lev_min = q_rx_lev_min;
int thresh_x_high = 0;
if (!root[i].lookupValue("thresh_x_high", thresh_x_high)) {
ERROR("Missing field `thresh_x_high` in carrier_freqs_info_list=%d\n", i);
ERROR("Missing field `thresh_x_high` in carrier_freqs_info_list=%d", i);
return -1;
}
data->carrier_freqs_info_list[i].common_info.thresh_x_high = thresh_x_high;
int thresh_x_low = 0;
if (!root[i].lookupValue("thresh_x_low", thresh_x_low)) {
ERROR("Missing field `thresh_x_low` in carrier_freqs_info_list=%d\n", i);
ERROR("Missing field `thresh_x_low` in carrier_freqs_info_list=%d", i);
return -1;
}
data->carrier_freqs_info_list[i].common_info.thresh_x_low = thresh_x_low;
@ -180,7 +180,7 @@ int field_carrier_freqs_info_list::parse(libconfig::Setting& root)
field_asn1_enum_str<asn1::rrc::band_ind_geran_e> band_ind("band_ind",
&data->carrier_freqs_info_list[i].carrier_freqs.band_ind);
if (band_ind.parse(root[i])) {
ERROR("Error parsing `band_ind` in carrier_freqs_info_list=%d\n", i);
ERROR("Error parsing `band_ind` in carrier_freqs_info_list=%d", i);
return -1;
}
@ -435,7 +435,7 @@ int field_qci::parse(libconfig::Setting& root)
field_asn1_enum_number<sn_field_len_e> sn_field_len("sn_field_length", &um_rlc->sn_field_len);
if (sn_field_len.parse(q["rlc_config"]["ul_um"])) {
ERROR("Error can't find sn_field_length in section ul_um\n");
ERROR("Error can't find sn_field_length in section ul_um");
}
}
@ -450,12 +450,12 @@ int field_qci::parse(libconfig::Setting& root)
field_asn1_enum_number<sn_field_len_e> sn_field_len("sn_field_length", &um_rlc->sn_field_len);
if (sn_field_len.parse(q["rlc_config"]["dl_um"])) {
ERROR("Error can't find sn_field_length in section dl_um\n");
ERROR("Error can't find sn_field_length in section dl_um");
}
field_asn1_enum_number<t_reordering_e> t_reordering("t_reordering", &um_rlc->t_reordering);
if (t_reordering.parse(q["rlc_config"]["dl_um"])) {
ERROR("Error can't find t_reordering in section dl_um\n");
ERROR("Error can't find t_reordering in section dl_um");
}
}
@ -465,23 +465,23 @@ int field_qci::parse(libconfig::Setting& root)
field_asn1_enum_number<t_poll_retx_e> t_poll_retx("t_poll_retx", &am_rlc->t_poll_retx);
if (t_poll_retx.parse(q["rlc_config"]["ul_am"])) {
ERROR("Error can't find t_poll_retx in section ul_am\n");
ERROR("Error can't find t_poll_retx in section ul_am");
}
field_asn1_enum_number<poll_pdu_e> poll_pdu("poll_pdu", &am_rlc->poll_pdu);
if (poll_pdu.parse(q["rlc_config"]["ul_am"])) {
ERROR("Error can't find poll_pdu in section ul_am\n");
ERROR("Error can't find poll_pdu in section ul_am");
}
field_asn1_enum_number<poll_byte_e> poll_byte("poll_byte", &am_rlc->poll_byte);
if (poll_byte.parse(q["rlc_config"]["ul_am"])) {
ERROR("Error can't find poll_byte in section ul_am\n");
ERROR("Error can't find poll_byte in section ul_am");
}
field_asn1_enum_number<ul_am_rlc_s::max_retx_thres_e_> max_retx_thresh("max_retx_thresh",
&am_rlc->max_retx_thres);
if (max_retx_thresh.parse(q["rlc_config"]["ul_am"])) {
ERROR("Error can't find max_retx_thresh in section ul_am\n");
ERROR("Error can't find max_retx_thresh in section ul_am");
}
}
@ -490,12 +490,12 @@ int field_qci::parse(libconfig::Setting& root)
field_asn1_enum_number<t_reordering_e> t_reordering("t_reordering", &am_rlc->t_reordering);
if (t_reordering.parse(q["rlc_config"]["dl_am"])) {
ERROR("Error can't find t_reordering in section dl_am\n");
ERROR("Error can't find t_reordering in section dl_am");
}
field_asn1_enum_number<t_status_prohibit_e> t_status_prohibit("t_status_prohibit", &am_rlc->t_status_prohibit);
if (t_status_prohibit.parse(q["rlc_config"]["dl_am"])) {
ERROR("Error can't find t_status_prohibit in section dl_am\n");
ERROR("Error can't find t_status_prohibit in section dl_am");
}
}
@ -509,7 +509,7 @@ int field_qci::parse(libconfig::Setting& root)
parser::field<uint8> priority("priority", &lc_cfg->prio);
if (priority.parse(q["logical_channel_config"])) {
ERROR("Error can't find logical_channel_config in section priority\n");
ERROR("Error can't find logical_channel_config in section priority");
}
field_asn1_enum_number<lc_ch_cfg_s::ul_specific_params_s_::prioritised_bit_rate_e_> prioritised_bit_rate(
@ -521,7 +521,7 @@ int field_qci::parse(libconfig::Setting& root)
field_asn1_enum_number<lc_ch_cfg_s::ul_specific_params_s_::bucket_size_dur_e_> bucket_size_duration(
"bucket_size_duration", &lc_cfg->bucket_size_dur);
if (bucket_size_duration.parse(q["logical_channel_config"])) {
ERROR("Error can't find bucket_size_duration in section logical_channel_config\n");
ERROR("Error can't find bucket_size_duration in section logical_channel_config");
}
parser::field<uint8> log_chan_group("log_chan_group", &lc_cfg->lc_ch_group);
@ -538,15 +538,15 @@ int parse_rr(all_args_t* args_, rrc_cfg_t* rrc_cfg_)
{
/* Transmission mode config section */
if (args_->enb.transmission_mode < 1 || args_->enb.transmission_mode > 4) {
ERROR("Invalid transmission mode (%d). Only indexes 1-4 are implemented.\n", args_->enb.transmission_mode);
ERROR("Invalid transmission mode (%d). Only indexes 1-4 are implemented.", args_->enb.transmission_mode);
return SRSLTE_ERROR;
} else if (args_->enb.transmission_mode == 1 && args_->enb.nof_ports > 1) {
ERROR("Invalid number of ports (%d) for transmission mode (%d). Only one antenna port is allowed.\n",
ERROR("Invalid number of ports (%d) for transmission mode (%d). Only one antenna port is allowed.",
args_->enb.nof_ports,
args_->enb.transmission_mode);
return SRSLTE_ERROR;
} else if (args_->enb.transmission_mode > 1 && args_->enb.nof_ports != 2) {
ERROR("The selected number of ports (%d) are insufficient for the selected transmission mode (%d).\n",
ERROR("The selected number of ports (%d) are insufficient for the selected transmission mode (%d).",
args_->enb.nof_ports,
args_->enb.transmission_mode);
return SRSLTE_ERROR;
@ -576,7 +576,7 @@ int parse_rr(all_args_t* args_, rrc_cfg_t* rrc_cfg_)
rrc_cfg_->antenna_info.codebook_subset_restrict.n2_tx_ant_tm4().from_number(0b111111);
break;
default:
ERROR("Unsupported transmission mode %d\n", rrc_cfg_->antenna_info.tx_mode.to_number());
ERROR("Unsupported transmission mode %d", rrc_cfg_->antenna_info.tx_mode.to_number());
return SRSLTE_ERROR;
}
@ -758,12 +758,12 @@ static int parse_cell_list(all_args_t* args, rrc_cfg_t* rrc_cfg, Setting& root)
for (auto it2 = it + 1; it2 != rrc_cfg->cell_list.end(); it2++) {
// Check RF port is not repeated
if (it->rf_port == it2->rf_port) {
ERROR("Repeated RF port for multiple cells\n");
ERROR("Repeated RF port for multiple cells");
}
// Check cell ID is not repeated
if (it->cell_id == it2->cell_id) {
ERROR("Repeated Cell identifier\n");
ERROR("Repeated Cell identifier");
}
}
}
@ -886,20 +886,20 @@ int set_derived_args(all_args_t* args_, rrc_cfg_t* rrc_cfg_, phy_cfg_t* phy_cfg_
auto& cfg = rrc_cfg_->cell_list.at(0);
if (args_->enb.dl_earfcn > 0) {
cfg.dl_earfcn = args_->enb.dl_earfcn;
ERROR("Force DL EARFCN for cell PCI=%d to %d\n", cfg.pci, cfg.dl_earfcn);
ERROR("Force DL EARFCN for cell PCI=%d to %d", cfg.pci, cfg.dl_earfcn);
}
if (args_->rf.dl_freq > 0) {
cfg.dl_freq_hz = args_->rf.dl_freq;
ERROR("Force DL freq for cell PCI=%d to %f MHz\n", cfg.pci, cfg.dl_freq_hz / 1e6f);
ERROR("Force DL freq for cell PCI=%d to %f MHz", cfg.pci, cfg.dl_freq_hz / 1e6f);
}
if (args_->rf.ul_freq > 0) {
cfg.ul_freq_hz = args_->rf.ul_freq;
ERROR("Force UL freq for cell PCI=%d to %f MHz\n", cfg.pci, cfg.ul_freq_hz / 1e6f);
ERROR("Force UL freq for cell PCI=%d to %f MHz", cfg.pci, cfg.ul_freq_hz / 1e6f);
}
} else {
// If more than one cell is defined, single EARFCN or DL freq will be ignored
if (args_->enb.dl_earfcn > 0 || args_->rf.dl_freq > 0) {
INFO("Multiple cells defined in rr.conf. Ignoring single EARFCN and/or frequency config.\n");
INFO("Multiple cells defined in rr.conf. Ignoring single EARFCN and/or frequency config.");
}
}
@ -943,10 +943,10 @@ int set_derived_args(all_args_t* args_, rrc_cfg_t* rrc_cfg_, phy_cfg_t* phy_cfg_
rrc_cfg_->cell_list.end(),
[scell_it](const cell_cfg_t& c) { return scell_it->cell_id == c.cell_id; });
if (cell_it == rrc_cfg_->cell_list.end()) {
ERROR("Scell with cell_id=0x%x is not present in rr.conf. Ignoring it.\n", scell_it->cell_id);
ERROR("Scell with cell_id=0x%x is not present in rr.conf. Ignoring it.", scell_it->cell_id);
scell_it = cfg.scell_list.erase(scell_it);
} else if (cell_it->cell_id == cfg.cell_id) {
ERROR("A cell cannot have an scell with the same cell_id=0x%x\n", cfg.cell_id);
ERROR("A cell cannot have an scell with the same cell_id=0x%x", cfg.cell_id);
return SRSLTE_ERROR;
} else {
scell_it++;
@ -960,7 +960,7 @@ int set_derived_args(all_args_t* args_, rrc_cfg_t* rrc_cfg_, phy_cfg_t* phy_cfg_
auto collision_it = std::find_if(it + 1, rrc_cfg_->cell_list.end(), is_pss_collision);
if (collision_it != rrc_cfg_->cell_list.end()) {
ERROR("The cells pci1=%d and pci2=%d will have the same PSS. Consider changing one of the cells' PCI values, "
"otherwise a UE may fail to correctly detect and distinguish them\n",
"otherwise a UE may fail to correctly detect and distinguish them",
it->pci,
collision_it->pci);
}
@ -1013,7 +1013,7 @@ int set_derived_args(all_args_t* args_, rrc_cfg_t* rrc_cfg_, phy_cfg_t* phy_cfg_
uint32_t n310 = rrc_cfg_->sibs[1].sib2().ue_timers_and_consts.n310.to_number();
uint32_t min_rrc_inactivity_timer = t310 + t311 + n310 + 50;
if (args_->general.rrc_inactivity_timer < min_rrc_inactivity_timer) {
ERROR("rrc_inactivity_timer=%d is too low. Consider setting it to a value equal or above %d\n",
ERROR("rrc_inactivity_timer=%d is too low. Consider setting it to a value equal or above %d",
args_->general.rrc_inactivity_timer,
min_rrc_inactivity_timer);
}
@ -1022,7 +1022,7 @@ int set_derived_args(all_args_t* args_, rrc_cfg_t* rrc_cfg_, phy_cfg_t* phy_cfg_
// Check number of control symbols
if (args_->stack.mac.sched.min_nof_ctrl_symbols > args_->stack.mac.sched.max_nof_ctrl_symbols) {
ERROR("Invalid minimum number of control symbols %d. Setting it to 1.\n",
ERROR("Invalid minimum number of control symbols %d. Setting it to 1.",
args_->stack.mac.sched.min_nof_ctrl_symbols);
args_->stack.mac.sched.min_nof_ctrl_symbols = 1;
}
@ -1538,7 +1538,7 @@ int parse_sibs(all_args_t* args_, rrc_cfg_t* rrc_cfg_, srsenb::phy_cfg_t* phy_co
cell_access->plmn_id_list.resize(1);
srslte::plmn_id_t plmn;
if (plmn.from_string(mcc_str + mnc_str) == SRSLTE_ERROR) {
ERROR("Could not convert %s to a plmn_id\n", (mcc_str + mnc_str).c_str());
ERROR("Could not convert %s to a plmn_id", (mcc_str + mnc_str).c_str());
return -1;
}
srslte::to_asn1(&cell_access->plmn_id_list[0].plmn_id, plmn);

@ -480,19 +480,13 @@ int main(int argc, char* argv[])
srslte_debug_handle_crash(argc, argv);
parse_args(&args, argc, argv);
// Setup logging.
log_sink = (args.log.filename == "stdout")
? srslog::create_stdout_sink()
: srslog::create_file_sink(args.log.filename, fixup_log_file_maxsize(args.log.file_max_size));
if (!log_sink) {
return SRSLTE_ERROR;
}
// Setup the default log sink.
srslog::set_default_sink(
(args.log.filename == "stdout")
? srslog::fetch_stdout_sink()
: srslog::fetch_file_sink(args.log.filename, fixup_log_file_maxsize(args.log.file_max_size)));
srslog::log_channel* chan = srslog::create_log_channel("main_channel", *log_sink);
if (!chan) {
return SRSLTE_ERROR;
}
srslte::srslog_wrapper log_wrapper(*chan);
srslte::srslog_wrapper log_wrapper(srslog::fetch_log_channel("main_channel"));
// Alarms log channel creation.
srslog::sink& alarm_sink = srslog::fetch_file_sink(args.general.alarms_filename);
@ -520,7 +514,7 @@ int main(int argc, char* argv[])
}
// Create eNB
unique_ptr<srsenb::enb> enb{new srsenb::enb};
unique_ptr<srsenb::enb> enb{new srsenb::enb(srslog::get_default_sink())};
if (enb->init(args, &log_wrapper) != SRSLTE_SUCCESS) {
enb->stop();
return SRSLTE_ERROR;

@ -18,16 +18,16 @@
#define Error(fmt, ...) \
if (SRSLTE_DEBUG_ENABLED) \
log_h->error(fmt, ##__VA_ARGS__)
logger.error(fmt, ##__VA_ARGS__)
#define Warning(fmt, ...) \
if (SRSLTE_DEBUG_ENABLED) \
log_h->warning(fmt, ##__VA_ARGS__)
logger.warning(fmt, ##__VA_ARGS__)
#define Info(fmt, ...) \
if (SRSLTE_DEBUG_ENABLED) \
log_h->info(fmt, ##__VA_ARGS__)
logger.info(fmt, ##__VA_ARGS__)
#define Debug(fmt, ...) \
if (SRSLTE_DEBUG_ENABLED) \
log_h->debug(fmt, ##__VA_ARGS__)
logger.debug(fmt, ##__VA_ARGS__)
using namespace std;
@ -46,7 +46,7 @@ using namespace asn1::rrc;
namespace srsenb {
namespace lte {
cc_worker::cc_worker()
cc_worker::cc_worker(srslog::basic_logger& logger) : logger(logger)
{
reset();
}
@ -76,10 +76,9 @@ cc_worker::~cc_worker()
FILE* f;
#endif
void cc_worker::init(phy_common* phy_, srslte::log* log_h_, uint32_t cc_idx_)
void cc_worker::init(phy_common* phy_, uint32_t cc_idx_)
{
phy = phy_;
log_h = log_h_;
cc_idx = cc_idx_;
srslte_cell_t cell = phy_->get_cell(cc_idx);
uint32_t nof_prb = phy_->get_nof_prb(cc_idx);
@ -89,32 +88,32 @@ void cc_worker::init(phy_common* phy_, srslte::log* log_h_, uint32_t cc_idx_)
for (uint32_t p = 0; p < phy->get_nof_ports(cc_idx); p++) {
signal_buffer_rx[p] = srslte_vec_cf_malloc(2 * sf_len);
if (!signal_buffer_rx[p]) {
ERROR("Error allocating memory\n");
ERROR("Error allocating memory");
return;
}
srslte_vec_cf_zero(signal_buffer_rx[p], 2 * sf_len);
signal_buffer_tx[p] = srslte_vec_cf_malloc(2 * sf_len);
if (!signal_buffer_tx[p]) {
ERROR("Error allocating memory\n");
ERROR("Error allocating memory");
return;
}
srslte_vec_cf_zero(signal_buffer_tx[p], 2 * sf_len);
}
if (srslte_enb_dl_init(&enb_dl, signal_buffer_tx, nof_prb)) {
ERROR("Error initiating ENB DL (cc=%d)\n", cc_idx);
ERROR("Error initiating ENB DL (cc=%d)", cc_idx);
return;
}
if (srslte_enb_dl_set_cell(&enb_dl, cell)) {
ERROR("Error initiating ENB DL (cc=%d)\n", cc_idx);
ERROR("Error initiating ENB DL (cc=%d)", cc_idx);
return;
}
if (srslte_enb_ul_init(&enb_ul, signal_buffer_rx[0], nof_prb)) {
ERROR("Error initiating ENB UL\n");
ERROR("Error initiating ENB UL");
return;
}
if (srslte_enb_ul_set_cell(&enb_ul, cell, &phy->dmrs_pusch_cfg, nullptr)) {
ERROR("Error initiating ENB UL\n");
ERROR("Error initiating ENB UL");
return;
}
@ -130,13 +129,13 @@ void cc_worker::init(phy_common* phy_, srslte::log* log_h_, uint32_t cc_idx_)
}
if (srslte_softbuffer_tx_init(&temp_mbsfn_softbuffer, nof_prb)) {
ERROR("Error initiating soft buffer\n");
ERROR("Error initiating soft buffer");
exit(-1);
}
srslte_softbuffer_tx_reset(&temp_mbsfn_softbuffer);
Info("Component Carrier Worker %d configured cell %d PRB\n", cc_idx, nof_prb);
Info("Component Carrier Worker %d configured cell %d PRB", cc_idx, nof_prb);
if (phy->params.pusch_8bit_decoder) {
enb_ul.pusch.llr_is_8bit = true;
@ -217,7 +216,7 @@ void cc_worker::work_ul(const srslte_ul_sf_cfg_t& ul_sf_cfg, stack_interface_phy
{
std::lock_guard<std::mutex> lock(mutex);
ul_sf = ul_sf_cfg;
log_h->step(ul_sf.tti);
logger.set_context(ul_sf.tti);
// Process UL signal
srslte_enb_ul_fft(&enb_ul);
@ -296,7 +295,7 @@ void cc_worker::decode_pusch_rnti(stack_interface_phy_lte::ul_sched_grant_t& ul_
// Compute UL grant
srslte_pusch_grant_t& grant = ul_cfg.pusch.grant;
if (srslte_ra_ul_dci_to_grant(&enb_ul.cell, &ul_sf, &ul_cfg.hopping, &ul_grant.dci, &grant)) {
Error("Computing PUSCH dci for RNTI %x\n", rnti);
Error("Computing PUSCH dci for RNTI %x", rnti);
return;
}
@ -308,7 +307,7 @@ void cc_worker::decode_pusch_rnti(stack_interface_phy_lte::ul_sched_grant_t& ul_
int rv_idx = grant.tb.rv;
grant.tb = phy->ue_db.get_last_ul_tb(rnti, cc_idx, ul_pid);
grant.tb.rv = rv_idx;
Info("Adaptive retx: rnti=0x%x, pid=%d, rv_idx=%d, mcs=%d, old_tbs=%d\n",
Info("Adaptive retx: rnti=0x%x, pid=%d, rv_idx=%d, mcs=%d, old_tbs=%d",
rnti,
ul_pid,
grant.tb.rv,
@ -322,7 +321,7 @@ void cc_worker::decode_pusch_rnti(stack_interface_phy_lte::ul_sched_grant_t& ul_
pusch_res.data = ul_grant.data;
if (pusch_res.data) {
if (srslte_enb_ul_get_pusch(&enb_ul, &ul_sf, &ul_cfg.pusch, &pusch_res)) {
Error("Decoding PUSCH for RNTI %x\n", rnti);
Error("Decoding PUSCH for RNTI %x", rnti);
return;
}
}
@ -376,10 +375,10 @@ void cc_worker::decode_pusch(stack_interface_phy_lte::ul_sched_grant_t* grants,
// Push PDU buffer
phy->stack->push_pdu(tti_rx, rnti, cc_idx, ul_cfg.pusch.grant.tb.tbs / 8, pusch_res.crc);
// Logging
if (log_h->get_level() >= srslte::LOG_LEVEL_INFO) {
if (logger.info.enabled()) {
char str[512];
srslte_pusch_rx_info(&ul_cfg.pusch, &pusch_res, &enb_ul.chest_res, str, sizeof(str));
log_h->info("PUSCH: cc=%d, %s\n", cc_idx, str);
logger.info("PUSCH: cc=%d, %s", cc_idx, str);
}
}
}
@ -400,7 +399,7 @@ int cc_worker::decode_pucch()
if (phy->ue_db.fill_uci_cfg(tti_rx, cc_idx, rnti, false, false, ul_cfg.pucch.uci_cfg)) {
// Decode PUCCH
if (srslte_enb_ul_get_pucch(&enb_ul, &ul_sf, &ul_cfg.pucch, &pucch_res)) {
ERROR("Error getting PUCCH\n");
ERROR("Error getting PUCCH");
return SRSLTE_ERROR;
}
@ -413,10 +412,10 @@ int cc_worker::decode_pucch()
}
// Logging
if (log_h->get_level() >= srslte::LOG_LEVEL_INFO) {
if (logger.info.enabled()) {
char str[512];
srslte_pucch_rx_info(&ul_cfg.pucch, &pucch_res, str, sizeof(str));
log_h->info("PUCCH: cc=%d; %s\n", cc_idx, str);
logger.info("PUCCH: cc=%d; %s", cc_idx, str);
}
// Save metrics
@ -433,7 +432,7 @@ int cc_worker::encode_phich(stack_interface_phy_lte::ul_sched_ack_t* acks, uint3
if (acks[i].rnti && ue_db.count(acks[i].rnti)) {
srslte_enb_dl_put_phich(&enb_dl, &ue_db[acks[i].rnti]->phich_grant, acks[i].ack);
Info("PHICH: rnti=0x%x, hi=%d, I_lowest=%d, n_dmrs=%d, tti_tx_dl=%d\n",
Info("PHICH: rnti=0x%x, hi=%d, I_lowest=%d, n_dmrs=%d, tti_tx_dl=%d",
acks[i].rnti,
acks[i].ack,
ue_db[acks[i].rnti]->phich_grant.n_prb_lowest,
@ -459,15 +458,15 @@ int cc_worker::encode_pdcch_ul(stack_interface_phy_lte::ul_sched_grant_t* grants
}
if (srslte_enb_dl_put_pdcch_ul(&enb_dl, &dci_cfg, &grants[i].dci)) {
ERROR("Error putting PUSCH %d\n", i);
ERROR("Error putting PUSCH %d", i);
return SRSLTE_ERROR;
}
// Logging
if (log_h->get_level() >= srslte::LOG_LEVEL_INFO) {
if (logger.info.enabled()) {
char str[512];
srslte_dci_ul_info(&grants[i].dci, str, 512);
log_h->info("PDCCH: cc=%d, %s, tti_tx_dl=%d\n", cc_idx, str, tti_tx_dl);
logger.info("PDCCH: cc=%d, %s, tti_tx_dl=%d", cc_idx, str, tti_tx_dl);
}
}
}
@ -489,15 +488,15 @@ int cc_worker::encode_pdcch_dl(stack_interface_phy_lte::dl_sched_grant_t* grants
}
if (srslte_enb_dl_put_pdcch_dl(&enb_dl, &dci_cfg, &grants[i].dci)) {
ERROR("Error putting PDCCH %d\n", i);
ERROR("Error putting PDCCH %d", i);
return SRSLTE_ERROR;
}
if (LOG_THIS(rnti) and log_h->get_level() >= srslte::LOG_LEVEL_INFO) {
if (LOG_THIS(rnti) and logger.info.enabled()) {
// Logging
char str[512];
srslte_dci_dl_info(&grants[i].dci, str, 512);
log_h->info("PDCCH: cc=%d, %s, tti_tx_dl=%d\n", cc_idx, str, tti_tx_dl);
logger.info("PDCCH: cc=%d, %s, tti_tx_dl=%d", cc_idx, str, tti_tx_dl);
}
}
}
@ -516,15 +515,15 @@ int cc_worker::encode_pmch(stack_interface_phy_lte::dl_sched_grant_t* grant, srs
// Encode PMCH
if (srslte_enb_dl_put_pmch(&enb_dl, &pmch_cfg, grant->data[0])) {
Error("Error putting PMCH\n");
Error("Error putting PMCH");
return SRSLTE_ERROR;
}
// Logging
if (log_h->get_level() >= srslte::LOG_LEVEL_INFO) {
if (logger.info.enabled()) {
char str[512];
srslte_pdsch_tx_info(&pmch_cfg.pdsch_cfg, str, 512);
log_h->info("PMCH: %s\n", str);
logger.info("PMCH: %s", str);
}
// Save metrics stats
@ -548,7 +547,7 @@ int cc_worker::encode_pdsch(stack_interface_phy_lte::dl_sched_grant_t* grants, u
// Compute DL grant
if (srslte_ra_dl_dci_to_grant(
&enb_dl.cell, &dl_sf, dl_cfg.tm, dl_cfg.pdsch.use_tbs_index_alt, &grants[i].dci, &dl_cfg.pdsch.grant)) {
Error("Computing DL grant\n");
Error("Computing DL grant");
}
// Set soft buffer
@ -558,7 +557,7 @@ int cc_worker::encode_pdsch(stack_interface_phy_lte::dl_sched_grant_t* grants, u
// Encode PDSCH
if (srslte_enb_dl_put_pdsch(&enb_dl, &dl_cfg.pdsch, grants[i].data)) {
Error("Error putting PDSCH %d\n", i);
Error("Error putting PDSCH %d", i);
return SRSLTE_ERROR;
}
@ -568,17 +567,17 @@ int cc_worker::encode_pdsch(stack_interface_phy_lte::dl_sched_grant_t* grants, u
phy->ue_db.set_ack_pending(tti_tx_ul, cc_idx, grants[i].dci);
}
if (LOG_THIS(rnti) and log_h->get_level() >= srslte::LOG_LEVEL_INFO) {
if (LOG_THIS(rnti) and logger.info.enabled()) {
// Logging
char str[512];
srslte_pdsch_tx_info(&dl_cfg.pdsch, str, 512);
log_h->info("PDSCH: cc=%d, %s, tti_tx_dl=%d\n", cc_idx, str, tti_tx_dl);
logger.info("PDSCH: cc=%d, %s, tti_tx_dl=%d", cc_idx, str, tti_tx_dl);
}
// Save metrics stats
ue_db[rnti]->metrics_dl(grants[i].dci.tb[0].mcs_idx);
} else {
Error("User rnti=0x%x not found in cc_worker=%d\n", rnti, cc_idx);
Error("User rnti=0x%x not found in cc_worker=%d", rnti, cc_idx);
}
}

@ -18,16 +18,16 @@
#define Error(fmt, ...) \
if (SRSLTE_DEBUG_ENABLED) \
log_h->error(fmt, ##__VA_ARGS__)
logger.error(fmt, ##__VA_ARGS__)
#define Warning(fmt, ...) \
if (SRSLTE_DEBUG_ENABLED) \
log_h->warning(fmt, ##__VA_ARGS__)
logger.warning(fmt, ##__VA_ARGS__)
#define Info(fmt, ...) \
if (SRSLTE_DEBUG_ENABLED) \
log_h->info(fmt, ##__VA_ARGS__)
logger.info(fmt, ##__VA_ARGS__)
#define Debug(fmt, ...) \
if (SRSLTE_DEBUG_ENABLED) \
log_h->debug(fmt, ##__VA_ARGS__)
logger.debug(fmt, ##__VA_ARGS__)
using namespace std;
@ -64,31 +64,30 @@ namespace lte {
FILE* f;
#endif
void sf_worker::init(phy_common* phy_, srslte::log* log_h_)
void sf_worker::init(phy_common* phy_)
{
phy = phy_;
log_h = log_h_;
// Initialise each component carrier workers
for (uint32_t i = 0; i < phy->get_nof_carriers_lte(); i++) {
// Create pointer
auto q = new cc_worker();
auto q = new cc_worker(logger);
// Initialise
q->init(phy, log_h, i);
q->init(phy, i);
// Create unique pointer
cc_workers.push_back(std::unique_ptr<cc_worker>(q));
}
if (srslte_softbuffer_tx_init(&temp_mbsfn_softbuffer, phy->get_nof_prb(0))) {
ERROR("Error initiating soft buffer\n");
ERROR("Error initiating soft buffer");
exit(-1);
}
srslte_softbuffer_tx_reset(&temp_mbsfn_softbuffer);
Info("Worker %d configured cell %d PRB\n", get_id(), phy->get_nof_prb(0));
Info("Worker %d configured cell %d PRB", get_id(), phy->get_nof_prb(0));
initiated = true;
running = true;
@ -188,9 +187,9 @@ void sf_worker::work_imp()
stack_interface_phy_lte* stack = phy->stack;
log_h->step(tti_rx);
logger.set_context(tti_rx);
Debug("Worker %d running\n", get_id());
Debug("Worker %d running", get_id());
// Configure UL subframe
ul_sf.tti = tti_rx;
@ -206,14 +205,14 @@ void sf_worker::work_imp()
// Get DL scheduling for the TX TTI from MAC
if (sf_type == SRSLTE_SF_NORM) {
if (stack->get_dl_sched(tti_tx_dl, dl_grants) < 0) {
Error("Getting DL scheduling from MAC\n");
Error("Getting DL scheduling from MAC");
phy->worker_end(this, tx_buffer, tx_time);
return;
}
} else {
dl_grants[0].cfi = mbsfn_cfg.non_mbsfn_region_length;
if (stack->get_mch_sched(tti_tx_dl, mbsfn_cfg.is_mcch, dl_grants)) {
Error("Getting MCH packets from MAC\n");
Error("Getting MCH packets from MAC");
phy->worker_end(this, tx_buffer, tx_time);
return;
}
@ -225,7 +224,7 @@ void sf_worker::work_imp()
// Get UL scheduling for the TX TTI from MAC
if (stack->get_ul_sched(tti_tx_ul, ul_grants_tx) < 0) {
Error("Getting UL scheduling from MAC\n");
Error("Getting UL scheduling from MAC");
phy->worker_end(this, tx_buffer, tx_time);
return;
}
@ -248,7 +247,7 @@ void sf_worker::work_imp()
phy->set_ul_grants(t_tx_ul, ul_grants_tx);
phy->set_ul_grants(t_rx, ul_grants);
Debug("Sending to radio\n");
Debug("Sending to radio");
tx_buffer.set_nof_samples(SRSLTE_SF_LEN_PRB(phy->get_nof_prb(0)));
phy->worker_end(this, tx_buffer, tx_time);

@ -25,24 +25,17 @@ namespace lte {
worker_pool::worker_pool(uint32_t max_workers) : pool(max_workers) {}
bool worker_pool::init(const phy_args_t& args, phy_common* common, srslte::logger* logger, int prio)
bool worker_pool::init(const phy_args_t& args, phy_common* common, srslog::sink& log_sink, int prio)
{
// Create logs
// Create array of pointers to phy_logs
// Add workers to workers pool and start threads.
srslog::basic_levels log_level = srslog::str_to_basic_level(args.log.phy_level);
for (uint32_t i = 0; i < args.nof_phy_threads; i++) {
auto* mylog = new srslte::log_filter;
char tmp[16];
sprintf(tmp, "PHY%d", i);
mylog->init(tmp, logger, true);
mylog->set_level(args.log.phy_level);
mylog->set_hex_limit(args.log.phy_hex_limit);
log_vec.push_back(std::unique_ptr<srslte::log_filter>(mylog));
}
auto& log = srslog::fetch_basic_logger(fmt::format("PHY{}", i), log_sink);
log.set_level(log_level);
log.set_hex_dump_max_size(args.log.phy_hex_limit);
// Add workers to workers pool and start threads
for (uint32_t i = 0; i < args.nof_phy_threads; i++) {
auto w = std::unique_ptr<lte::sf_worker>(new sf_worker());
w->init(common, (srslte::log*)log_vec[i].get());
auto w = std::unique_ptr<lte::sf_worker>(new sf_worker(log));
w->init(common);
pool.init_worker(i, w.get(), prio);
workers.push_back(std::move(w));
}

@ -24,8 +24,8 @@
namespace srsenb {
namespace nr {
cc_worker::cc_worker(uint32_t cc_idx_, srslte::log* log, phy_nr_state* phy_state_) :
cc_idx(cc_idx_), phy_state(phy_state_), log_h(log)
cc_worker::cc_worker(uint32_t cc_idx_, srslog::basic_logger& logger, phy_nr_state* phy_state_) :
cc_idx(cc_idx_), phy_state(phy_state_), logger(logger)
{
cf_t* buffer_c[SRSLTE_MAX_PORTS] = {};
@ -38,7 +38,7 @@ cc_worker::cc_worker(uint32_t cc_idx_, srslte::log* log, phy_nr_state* phy_state
}
if (srslte_enb_dl_nr_init(&enb_dl, buffer_c, &phy_state_->args.dl)) {
ERROR("Error initiating UE DL NR\n");
ERROR("Error initiating UE DL NR");
return;
}
}
@ -61,7 +61,7 @@ cc_worker::~cc_worker()
bool cc_worker::set_carrier(const srslte_carrier_nr_t* carrier)
{
if (srslte_enb_dl_nr_set_carrier(&enb_dl, carrier) < SRSLTE_SUCCESS) {
ERROR("Error setting carrier\n");
ERROR("Error setting carrier");
return false;
}
@ -70,7 +70,7 @@ bool cc_worker::set_carrier(const srslte_carrier_nr_t* carrier)
coreset.duration = 2;
if (srslte_enb_dl_nr_set_coreset(&enb_dl, &coreset) < SRSLTE_SUCCESS) {
ERROR("Error setting coreset\n");
ERROR("Error setting coreset");
return false;
}
@ -114,12 +114,12 @@ int cc_worker::encode_pdcch_dl(stack_interface_phy_nr::dl_sched_grant_t* grants,
// Put actual DCI
if (srslte_enb_dl_nr_pdcch_put(&enb_dl, &dl_slot_cfg, &grants[i].dci) < SRSLTE_SUCCESS) {
ERROR("Error putting PDCCH\n");
ERROR("Error putting PDCCH");
return SRSLTE_ERROR;
}
if (log_h->get_level() >= srslte::LOG_LEVEL_INFO) {
log_h->info("PDCCH: cc=%d, ...\n", cc_idx);
if (logger.info.enabled()) {
logger.info("PDCCH: cc=%d, ...", cc_idx);
}
}
@ -136,7 +136,7 @@ int cc_worker::encode_pdsch(stack_interface_phy_nr::dl_sched_grant_t* grants, ui
// Compute DL grant
if (srslte_ra_dl_dci_to_grant_nr(&enb_dl.carrier, &pdsch_cfg, &grants[i].dci, &pdsch_cfg.grant)) {
ERROR("Computing DL grant\n");
ERROR("Computing DL grant");
}
// Set soft buffer
@ -145,15 +145,15 @@ int cc_worker::encode_pdsch(stack_interface_phy_nr::dl_sched_grant_t* grants, ui
}
if (srslte_enb_dl_nr_pdsch_put(&enb_dl, &dl_slot_cfg, &pdsch_cfg, grants[i].data) < SRSLTE_SUCCESS) {
ERROR("Error putting PDSCH\n");
ERROR("Error putting PDSCH");
return false;
}
// Logging
if (log_h->get_level() >= srslte::LOG_LEVEL_INFO) {
if (logger.info.enabled()) {
char str[512];
srslte_enb_dl_nr_pdsch_info(&enb_dl, &pdsch_cfg, str, sizeof(str));
log_h->info("PDSCH: cc=%d, %s\n", cc_idx, str);
logger.info("PDSCH: cc=%d, %s", cc_idx, str);
}
}
@ -164,7 +164,7 @@ bool cc_worker::work_dl(const srslte_dl_slot_cfg_t& dl_sf_cfg, stack_interface_p
{
// Reset resource grid
if (srslte_enb_dl_nr_base_zero(&enb_dl) < SRSLTE_SUCCESS) {
ERROR("Error setting base to zero\n");
ERROR("Error setting base to zero");
return SRSLTE_ERROR;
}

@ -23,17 +23,17 @@
namespace srsenb {
namespace nr {
sf_worker::sf_worker(phy_common* phy_, phy_nr_state* phy_state_, srslte::log* log) :
phy(phy_), phy_state(phy_state_), log_h(log)
sf_worker::sf_worker(phy_common* phy_, phy_nr_state* phy_state_, srslog::basic_logger& logger) :
phy(phy_), phy_state(phy_state_), logger(logger)
{
for (uint32_t i = 0; i < phy_state->args.nof_carriers; i++) {
cc_worker* w = new cc_worker(i, log, phy_state);
cc_worker* w = new cc_worker(i, logger, phy_state);
cc_workers.push_back(std::unique_ptr<cc_worker>(w));
}
if (srslte_softbuffer_tx_init_guru(&softbuffer_tx, SRSLTE_SCH_NR_MAX_NOF_CB_LDPC, SRSLTE_LDPC_MAX_LEN_ENCODED_CB) <
SRSLTE_SUCCESS) {
ERROR("Error init soft-buffer\n");
ERROR("Error init soft-buffer");
return;
}
data.resize(SRSLTE_SCH_NR_MAX_NOF_CB_LDPC * SRSLTE_LDPC_MAX_LEN_ENCODED_CB / 8);
@ -80,7 +80,7 @@ uint32_t sf_worker::get_buffer_len()
void sf_worker::set_tti(uint32_t tti)
{
log_h->step(tti);
logger.set_context(tti);
for (auto& w : cc_workers) {
w->set_tti(tti);
}

@ -25,23 +25,16 @@ namespace nr {
worker_pool::worker_pool(uint32_t max_workers) : pool(max_workers) {}
bool worker_pool::init(const phy_args_t& args, phy_common* common, srslte::logger* logger, int prio)
bool worker_pool::init(const phy_args_t& args, phy_common* common, srslog::sink& log_sink, int prio)
{
// Create logs
// Create array of pointers to phy_logs
for (uint32_t i = 0; i < args.nof_phy_threads; i++) {
auto* mylog = new srslte::log_filter;
char tmp[16];
sprintf(tmp, "PHY%d", i);
mylog->init(tmp, logger, true);
mylog->set_level(args.log.phy_level);
mylog->set_hex_limit(args.log.phy_hex_limit);
log_vec.push_back(std::unique_ptr<srslte::log_filter>(mylog));
}
// Add workers to workers pool and start threads
srslog::basic_levels log_level = srslog::str_to_basic_level(args.log.phy_level);
for (uint32_t i = 0; i < args.nof_phy_threads; i++) {
auto w = new sf_worker(common, &phy_state, (srslte::log*)log_vec[i].get());
auto& log = srslog::fetch_basic_logger(fmt::format("PHY{}", i), log_sink);
log.set_level(log_level);
log.set_hex_dump_max_size(args.log.phy_hex_limit);
auto w = new sf_worker(common, &phy_state, log);
pool.init_worker(i, w, prio);
workers.push_back(std::unique_ptr<sf_worker>(w));

@ -24,16 +24,16 @@
#define Error(fmt, ...) \
if (SRSLTE_DEBUG_ENABLED) \
log_h->error(fmt, ##__VA_ARGS__)
phy_log.error(fmt, ##__VA_ARGS__)
#define Warning(fmt, ...) \
if (SRSLTE_DEBUG_ENABLED) \
log_h->warning(fmt, ##__VA_ARGS__)
phy_log.warning(fmt, ##__VA_ARGS__)
#define Info(fmt, ...) \
if (SRSLTE_DEBUG_ENABLED) \
log_h->info(fmt, ##__VA_ARGS__)
phy_log.info(fmt, ##__VA_ARGS__)
#define Debug(fmt, ...) \
if (SRSLTE_DEBUG_ENABLED) \
log_h->debug(fmt, ##__VA_ARGS__)
phy_log.debug(fmt, ##__VA_ARGS__)
using namespace std;
using namespace asn1::rrc;
@ -48,27 +48,30 @@ static void srslte_phy_handler(phy_logger_level_t log_level, void* ctx, char* st
void phy::srslte_phy_logger(phy_logger_level_t log_level, char* str)
{
if (log_phy_lib_h) {
switch (log_level) {
case LOG_LEVEL_INFO_S:
log_phy_lib_h->info(" %s", str);
phy_lib_log.info(" %s", str);
break;
case LOG_LEVEL_DEBUG_S:
log_phy_lib_h->debug(" %s", str);
phy_lib_log.debug(" %s", str);
break;
case LOG_LEVEL_ERROR_S:
log_phy_lib_h->error(" %s", str);
phy_lib_log.error(" %s", str);
break;
default:
break;
}
} else {
printf("[PHY_LIB]: %s\n", str);
}
}
phy::phy(srslte::logger* logger_) :
logger(logger_), lte_workers(MAX_WORKERS), nr_workers(MAX_WORKERS), workers_common(), nof_workers(0)
phy::phy(srslog::sink& log_sink) :
log_sink(log_sink),
phy_log(srslog::fetch_basic_logger("PHY", log_sink)),
phy_lib_log(srslog::fetch_basic_logger("PHY_LIB", log_sink)),
lte_workers(MAX_WORKERS),
nr_workers(MAX_WORKERS),
workers_common(),
nof_workers(0),
tx_rx(phy_log)
{}
phy::~phy()
@ -99,22 +102,18 @@ int phy::init(const phy_args_t& args,
{
mlockall((uint32_t)MCL_CURRENT | (uint32_t)MCL_FUTURE);
// Add PHY lib log
if (srslte::log::get_level_from_string(args.log.phy_lib_level) != srslte::LOG_LEVEL_NONE) {
log_phy_lib_h = std::unique_ptr<srslte::log_filter>(new srslte::log_filter);
log_phy_lib_h->init("PHY_LIB", logger, true);
log_phy_lib_h->set_level(args.log.phy_lib_level);
log_phy_lib_h->set_hex_limit(args.log.phy_hex_limit);
// Add PHY lib log.
srslog::basic_levels log_lvl = srslog::str_to_basic_level(args.log.phy_lib_level);
phy_lib_log.set_level(log_lvl);
phy_lib_log.set_hex_dump_max_size(args.log.phy_hex_limit);
if (log_lvl != srslog::basic_levels::none) {
srslte_phy_log_register_handler(this, srslte_phy_handler);
}
// Create default log
{
log_h = std::unique_ptr<srslte::log_filter>(new srslte::log_filter);
log_h->init("PHY", logger, true);
log_h->set_level(args.log.phy_level);
log_h->set_hex_limit(args.log.phy_hex_limit);
}
// Create default log.
phy_log.set_level(log_lvl);
phy_log.set_hex_dump_max_size(args.log.phy_hex_limit);
radio = radio_;
nof_workers = args.nof_phy_threads;
@ -126,24 +125,19 @@ int phy::init(const phy_args_t& args,
parse_common_config(cfg);
// Add workers to workers pool and start threads
lte_workers.init(args, &workers_common, logger, WORKERS_THREAD_PRIO);
nr_workers.init(args, &workers_common, logger, WORKERS_THREAD_PRIO);
lte_workers.init(args, &workers_common, log_sink, WORKERS_THREAD_PRIO);
nr_workers.init(args, &workers_common, log_sink, WORKERS_THREAD_PRIO);
// For each carrier, initialise PRACH worker
for (uint32_t cc = 0; cc < cfg.phy_cell_cfg.size(); cc++) {
prach_cfg.root_seq_idx = cfg.phy_cell_cfg[cc].root_seq_idx;
prach.init(cc,
cfg.phy_cell_cfg[cc].cell,
prach_cfg,
stack_,
log_h.get(),
PRACH_WORKER_THREAD_PRIO,
args.nof_prach_threads);
prach.init(
cc, cfg.phy_cell_cfg[cc].cell, prach_cfg, stack_, phy_log, PRACH_WORKER_THREAD_PRIO, args.nof_prach_threads);
}
prach.set_max_prach_offset_us(args.max_prach_offset_us);
// Warning this must be initialized after all workers have been added to the pool
tx_rx.init(stack_, radio, &lte_workers, &nr_workers, &workers_common, &prach, log_h.get(), SF_RECV_THREAD_PRIO);
tx_rx.init(stack_, radio, &lte_workers, &nr_workers, &workers_common, &prach, SF_RECV_THREAD_PRIO);
initialized = true;
@ -237,7 +231,7 @@ void phy::get_metrics(std::vector<phy_metrics_t>& metrics)
void phy::cmd_cell_gain(uint32_t cell_id, float gain_db)
{
Info("set_cell_gain: cell_id=%d, gain_db=%.2f\n", cell_id, gain_db);
Info("set_cell_gain: cell_id=%d, gain_db=%.2f", cell_id, gain_db);
workers_common.set_cell_gain(cell_id, gain_db);
}
@ -272,10 +266,10 @@ void phy::configure_mbsfn(srslte::sib2_mbms_t* sib2, srslte::sib13_t* sib13, con
{
if (sib2->mbsfn_sf_cfg_list_present) {
if (sib2->nof_mbsfn_sf_cfg == 0) {
Warning("SIB2 does not have any MBSFN config although it was set as present\n");
Warning("SIB2 does not have any MBSFN config although it was set as present");
} else {
if (sib2->nof_mbsfn_sf_cfg > 1) {
Warning("SIB2 has %d MBSFN subframe configs - only 1 supported\n", sib2->nof_mbsfn_sf_cfg);
Warning("SIB2 has %d MBSFN subframe configs - only 1 supported", sib2->nof_mbsfn_sf_cfg);
}
mbsfn_config.mbsfn_subfr_cnfg = sib2->mbsfn_sf_cfg_list[0];
}
@ -287,7 +281,7 @@ void phy::configure_mbsfn(srslte::sib2_mbms_t* sib2, srslte::sib13_t* sib13, con
mbsfn_config.mbsfn_notification_cnfg = sib13->notif_cfg;
if (sib13->nof_mbsfn_area_info > 0) {
if (sib13->nof_mbsfn_area_info > 1) {
Warning("SIB13 has %d MBSFN area info elements - only 1 supported\n", sib13->nof_mbsfn_area_info);
Warning("SIB13 has %d MBSFN area info elements - only 1 supported", sib13->nof_mbsfn_area_info);
}
mbsfn_config.mbsfn_area_info = sib13->mbsfn_area_info_list[0];
}

@ -17,19 +17,6 @@
#include <assert.h>
#define Error(fmt, ...) \
if (SRSLTE_DEBUG_ENABLED) \
log_h->error(fmt, ##__VA_ARGS__)
#define Warning(fmt, ...) \
if (SRSLTE_DEBUG_ENABLED) \
log_h->warning(fmt, ##__VA_ARGS__)
#define Info(fmt, ...) \
if (SRSLTE_DEBUG_ENABLED) \
log_h->info(fmt, ##__VA_ARGS__)
#define Debug(fmt, ...) \
if (SRSLTE_DEBUG_ENABLED) \
log_h->debug(fmt, ##__VA_ARGS__)
using namespace std;
using namespace asn1::rrc;

@ -129,7 +129,7 @@ uint32_t phy_ue_db::_get_uci_enb_cc_idx(uint32_t tti, uint16_t rnti) const
inline int phy_ue_db::_assert_rnti(uint16_t rnti) const
{
if (not ue_db.count(rnti)) {
ERROR("Trying to access RNTI 0x%X, it does not exist.\n", rnti);
ERROR("Trying to access RNTI 0x%X, it does not exist.", rnti);
return SRSLTE_ERROR;
}
@ -233,7 +233,7 @@ inline srslte::phy_cfg_t phy_ue_db::_get_rnti_config(uint16_t rnti, uint32_t enb
// Make sure the C-RNTI exists and the cell/carrier is configured
if (_assert_enb_cc(rnti, enb_cc_idx) != SRSLTE_SUCCESS) {
ERROR("Trying to access cell/carrier %d in RNTI 0x%X. It is not active.\n", enb_cc_idx, rnti);
ERROR("Trying to access cell/carrier %d in RNTI 0x%X. It is not active.", enb_cc_idx, rnti);
return default_cfg;
}
@ -383,7 +383,7 @@ void phy_ue_db::activate_deactivate_scell(uint16_t rnti, uint32_t ue_cc_idx, boo
// If scell is default only complain
if (activate and cell_info.state == cell_state_none) {
ERROR("RNTI 0x%X SCell %d has received an activation MAC command but it was not configured\n", rnti, ue_cc_idx);
ERROR("RNTI 0x%X SCell %d has received an activation MAC command but it was not configured", rnti, ue_cc_idx);
return;
}
// Set scell state
@ -659,7 +659,7 @@ void phy_ue_db::send_uci_data(uint32_t tti,
pmi_value = uci_value.cqi.subband_hl.pmi;
break;
default:
ERROR("CQI type=%d not implemented for PMI\n", uci_cfg.cqi.type);
ERROR("CQI type=%d not implemented for PMI", uci_cfg.cqi.type);
break;
}
stack->pmi_info(tti, rnti, cqi_cc_idx, pmi_value);

@ -18,11 +18,9 @@ namespace srsenb {
int prach_worker::init(const srslte_cell_t& cell_,
const srslte_prach_cfg_t& prach_cfg_,
stack_interface_phy_lte* stack_,
srslte::log* log_h_,
int priority,
uint32_t nof_workers_)
{
log_h = log_h_;
stack = stack_;
prach_cfg = prach_cfg_;
cell = cell_;
@ -35,7 +33,7 @@ int prach_worker::init(const srslte_cell_t& cell_,
}
if (srslte_prach_set_cfg(&prach, &prach_cfg, cell.nof_prb)) {
ERROR("Error initiating PRACH\n");
ERROR("Error initiating PRACH");
return -1;
}
@ -91,12 +89,12 @@ int prach_worker::new_tti(uint32_t tti_rx, cf_t* buffer_rx)
if (sf_cnt == 0) {
current_buffer = buffer_pool.allocate();
if (!current_buffer) {
log_h->warning("PRACH skipping tti=%d due to lack of available buffers\n", tti_rx);
logger.warning("PRACH skipping tti=%d due to lack of available buffers", tti_rx);
return 0;
}
}
if (!current_buffer) {
log_h->error("PRACH: Expected available current_buffer\n");
logger.error("PRACH: Expected available current_buffer");
return -1;
}
if (current_buffer->nof_samples + SRSLTE_SF_LEN_PRB(cell.nof_prb) < sf_buffer_sz) {
@ -108,7 +106,7 @@ int prach_worker::new_tti(uint32_t tti_rx, cf_t* buffer_rx)
current_buffer->tti = tti_rx;
}
} else {
log_h->error("PRACH: Not enough space in current_buffer\n");
logger.error("PRACH: Not enough space in current_buffer");
return -1;
}
sf_cnt++;
@ -139,13 +137,13 @@ int prach_worker::run_tti(sf_buffer* b)
prach_offsets,
prach_p2avg,
&prach_nof_det)) {
log_h->error("Error detecting PRACH\n");
logger.error("Error detecting PRACH");
return SRSLTE_ERROR;
}
if (prach_nof_det) {
for (uint32_t i = 0; i < prach_nof_det; i++) {
log_h->info("PRACH: cc=%d, %d/%d, preamble=%d, offset=%.1f us, peak2avg=%.1f, max_offset=%.1f us\n",
logger.info("PRACH: cc=%d, %d/%d, preamble=%d, offset=%.1f us, peak2avg=%.1f, max_offset=%.1f us",
cc_idx,
i,
prach_nof_det,

@ -20,22 +20,22 @@
#define Error(fmt, ...) \
if (SRSLTE_DEBUG_ENABLED) \
log_h->error(fmt, ##__VA_ARGS__)
logger.error(fmt, ##__VA_ARGS__)
#define Warning(fmt, ...) \
if (SRSLTE_DEBUG_ENABLED) \
log_h->warning(fmt, ##__VA_ARGS__)
logger.warning(fmt, ##__VA_ARGS__)
#define Info(fmt, ...) \
if (SRSLTE_DEBUG_ENABLED) \
log_h->info(fmt, ##__VA_ARGS__)
logger.info(fmt, ##__VA_ARGS__)
#define Debug(fmt, ...) \
if (SRSLTE_DEBUG_ENABLED) \
log_h->debug(fmt, ##__VA_ARGS__)
logger.debug(fmt, ##__VA_ARGS__)
using namespace std;
namespace srsenb {
txrx::txrx() : thread("TXRX")
txrx::txrx(srslog::basic_logger& logger) : thread("TXRX"), logger(logger)
{
/* Do nothing */
}
@ -46,12 +46,10 @@ bool txrx::init(stack_interface_phy_lte* stack_,
nr::worker_pool* nr_workers_,
phy_common* worker_com_,
prach_worker_pool* prach_,
srslte::log* log_h_,
uint32_t prio_)
{
stack = stack_;
radio_h = radio_h_;
log_h = log_h_;
lte_workers = lte_workers_;
nr_workers = nr_workers_;
worker_com = worker_com_;
@ -110,7 +108,7 @@ void txrx::run_thread()
ul_channel->set_srate(static_cast<uint32_t>(samp_rate));
}
log_h->info("Starting RX/TX thread nof_prb=%d, sf_len=%d\n", worker_com->get_nof_prb(0), sf_len);
logger.info("Starting RX/TX thread nof_prb=%d, sf_len=%d", worker_com->get_nof_prb(0), sf_len);
// Set TTI so that first TX is at tti=0
tti = TTI_SUB(0, FDD_HARQ_DELAY_UL_MS + 1);
@ -118,10 +116,7 @@ void txrx::run_thread()
// Main loop
while (running) {
tti = TTI_ADD(tti, 1);
if (log_h) {
log_h->step(tti);
}
logger.set_context(tti);
lte::sf_worker* lte_worker = nullptr;
if (worker_com->get_nof_carriers_lte() > 0) {
@ -173,7 +168,7 @@ void txrx::run_thread()
// Compute TX time: Any transmission happens in TTI+4 thus advance 4 ms the reception time
timestamp.add(FDD_HARQ_DELAY_UL_MS * 1e-3);
Debug("Setting TTI=%d, tx_mutex=%d, tx_time=%ld:%f to worker %d\n",
Debug("Setting TTI=%d, tx_mutex=%d, tx_time=%ld:%f to worker %d",
tti,
tx_worker_cnt,
timestamp.get(0).full_secs,

@ -20,14 +20,23 @@ using namespace srslte;
namespace srsenb {
enb_stack_lte::enb_stack_lte(srslte::logger* logger_) :
task_sched(512, 0, 128),
logger(logger_),
pdcp(&task_sched, "PDCP"),
enb_stack_lte::enb_stack_lte(srslte::logger* logger_, srslog::sink& log_sink) :
thread("STACK"),
mac(&task_sched),
s1ap(&task_sched),
rrc(&task_sched)
mac_logger(srslog::fetch_basic_logger("MAC", log_sink)),
rlc_logger(srslog::fetch_basic_logger("RLC", log_sink, false)),
pdcp_logger(srslog::fetch_basic_logger("PDCP", log_sink, false)),
rrc_logger(srslog::fetch_basic_logger("RRC", log_sink, false)),
s1ap_logger(srslog::fetch_basic_logger("S1AP", log_sink, false)),
gtpu_logger(srslog::fetch_basic_logger("GTPU", log_sink, false)),
stack_logger(srslog::fetch_basic_logger("STCK", log_sink, false)),
task_sched(512, 0, 128),
pdcp(&task_sched, pdcp_logger),
mac(&task_sched, mac_logger),
rlc(rlc_logger),
gtpu(gtpu_logger),
s1ap(&task_sched, s1ap_logger),
rrc(&task_sched),
logger(logger_)
{
enb_task_queue = task_sched.make_task_queue();
mme_task_queue = task_sched.make_task_queue();
@ -66,21 +75,35 @@ int enb_stack_lte::init(const stack_args_t& args_, const rrc_cfg_t& rrc_cfg_)
srslte::logmap::register_log(std::unique_ptr<srslte::log>{new log_filter{"MAC ", logger, true}});
mac_log->set_level(args.log.mac_level);
mac_log->set_hex_limit(args.log.mac_hex_limit);
mac_logger.set_level(srslog::str_to_basic_level(args.log.mac_level));
mac_logger.set_hex_dump_max_size(args.log.mac_hex_limit);
// Init logs
rlc_log->set_level(args.log.rlc_level);
rlc_logger.set_level(srslog::str_to_basic_level(args.log.rlc_level));
pdcp_log->set_level(args.log.pdcp_level);
pdcp_logger.set_level(srslog::str_to_basic_level(args.log.pdcp_level));
rrc_log->set_level(args.log.rrc_level);
rrc_logger.set_level(srslog::str_to_basic_level(args.log.rrc_level));
gtpu_log->set_level(args.log.gtpu_level);
gtpu_logger.set_level(srslog::str_to_basic_level(args.log.gtpu_level));
s1ap_log->set_level(args.log.s1ap_level);
s1ap_logger.set_level(srslog::str_to_basic_level(args.log.s1ap_level));
stack_log->set_level(args.log.stack_level);
stack_logger.set_level(srslog::str_to_basic_level(args.log.stack_level));
rlc_log->set_hex_limit(args.log.rlc_hex_limit);
rlc_logger.set_hex_dump_max_size(args.log.rlc_hex_limit);
pdcp_log->set_hex_limit(args.log.pdcp_hex_limit);
pdcp_logger.set_hex_dump_max_size(args.log.pdcp_hex_limit);
rrc_log->set_hex_limit(args.log.rrc_hex_limit);
rrc_logger.set_hex_dump_max_size(args.log.rrc_hex_limit);
gtpu_log->set_hex_limit(args.log.gtpu_hex_limit);
gtpu_logger.set_hex_dump_max_size(args.log.gtpu_hex_limit);
s1ap_log->set_hex_limit(args.log.s1ap_hex_limit);
s1ap_logger.set_hex_dump_max_size(args.log.s1ap_hex_limit);
stack_log->set_hex_limit(args.log.stack_hex_limit);
stack_logger.set_hex_dump_max_size(args.log.stack_hex_limit);
// Set up pcap and trace
if (args.mac_pcap.enable) {
@ -100,11 +123,11 @@ int enb_stack_lte::init(const stack_args_t& args_, const rrc_cfg_t& rrc_cfg_)
// Init all layers
mac.init(args.mac, rrc_cfg.cell_list, phy, &rlc, &rrc, mac_log);
rlc.init(&pdcp, &rrc, &mac, task_sched.get_timer_handler(), rlc_log);
rlc.init(&pdcp, &rrc, &mac, task_sched.get_timer_handler());
pdcp.init(&rlc, &rrc, &gtpu);
rrc.init(rrc_cfg, phy, &mac, &rlc, &pdcp, &s1ap, &gtpu);
if (s1ap.init(args.s1ap, &rrc, this) != SRSLTE_SUCCESS) {
stack_log->error("Couldn't initialize S1AP\n");
stack_logger.error("Couldn't initialize S1AP");
return SRSLTE_ERROR;
}
if (gtpu.init(args.s1ap.gtp_bind_addr,
@ -114,7 +137,7 @@ int enb_stack_lte::init(const stack_args_t& args_, const rrc_cfg_t& rrc_cfg_)
&pdcp,
this,
args.embms.enable)) {
stack_log->error("Couldn't initialize GTPU\n");
stack_logger.error("Couldn't initialize GTPU");
return SRSLTE_ERROR;
}

@ -27,10 +27,8 @@ using namespace asn1::rrc;
namespace srsenb {
mac::mac(srslte::ext_task_sched_handle task_sched_) :
rar_payload(),
common_buffers(SRSLTE_MAX_CARRIERS),
task_sched(task_sched_)
mac::mac(srslte::ext_task_sched_handle task_sched_, srslog::basic_logger& logger) :
logger(logger), rar_payload(), common_buffers(SRSLTE_MAX_CARRIERS), task_sched(task_sched_)
{
pthread_rwlock_init(&rwlock, nullptr);
}
@ -111,7 +109,7 @@ void mac::stop()
// Implement Section 5.9
void mac::reset()
{
Info("Resetting MAC\n");
logger.info("Resetting MAC");
last_rnti = 70;
@ -149,7 +147,7 @@ int mac::rlc_buffer_state(uint16_t rnti, uint32_t lc_id, uint32_t tx_queue, uint
ret = 0;
}
} else {
Error("User rnti=0x%x not found\n", rnti);
logger.error("User rnti=0x%x not found", rnti);
}
return ret;
}
@ -161,7 +159,7 @@ int mac::bearer_ue_cfg(uint16_t rnti, uint32_t lc_id, sched_interface::ue_bearer
if (ue_db.count(rnti)) {
ret = scheduler.bearer_ue_cfg(rnti, lc_id, *cfg);
} else {
Error("User rnti=0x%x not found\n", rnti);
logger.error("User rnti=0x%x not found", rnti);
}
return ret;
}
@ -173,7 +171,7 @@ int mac::bearer_ue_rem(uint16_t rnti, uint32_t lc_id)
if (ue_db.count(rnti)) {
ret = scheduler.bearer_ue_rem(rnti, lc_id);
} else {
Error("User rnti=0x%x not found\n", rnti);
logger.error("User rnti=0x%x not found", rnti);
}
return ret;
}
@ -191,7 +189,7 @@ int mac::ue_cfg(uint16_t rnti, sched_interface::ue_cfg_t* cfg)
auto it = ue_db.find(rnti);
ue* ue_ptr = nullptr;
if (it == ue_db.end()) {
Error("User rnti=0x%x not found\n", rnti);
logger.error("User rnti=0x%x not found", rnti);
return SRSLTE_ERROR;
}
ue_ptr = it->second.get();
@ -201,18 +199,18 @@ int mac::ue_cfg(uint16_t rnti, sched_interface::ue_cfg_t* cfg)
// Add RNTI to the PHY (pregenerate signals) now instead of after PRACH
if (not ue_ptr->is_phy_added) {
Info("Registering RNTI=0x%X to PHY...\n", rnti);
logger.info("Registering RNTI=0x%X to PHY...", rnti);
// Register new user in PHY with first CC index
if (phy_h->pregen_sequences(rnti) == SRSLTE_ERROR) {
Error("Generating sequences for UE RNTI=0x%X\n", rnti);
logger.error("Generating sequences for UE RNTI=0x%X", rnti);
}
Info("Done registering RNTI=0x%X to PHY...\n", rnti);
logger.info("Done registering RNTI=0x%X to PHY...", rnti);
ue_ptr->is_phy_added = true;
}
// Update Scheduler configuration
if (cfg != nullptr and scheduler.ue_cfg(rnti, *cfg) == SRSLTE_ERROR) {
Error("Registering new UE rnti=0x%x to SCHED\n", rnti);
logger.error("Registering new UE rnti=0x%x to SCHED", rnti);
return SRSLTE_ERROR;
}
return SRSLTE_SUCCESS;
@ -228,7 +226,7 @@ int mac::ue_rem(uint16_t rnti)
ues_to_rem[rnti] = std::move(ue_db[rnti]);
ue_db.erase(rnti);
} else {
Error("User rnti=0x%x not found\n", rnti);
logger.error("User rnti=0x%x not found", rnti);
return SRSLTE_ERROR;
}
}
@ -239,7 +237,7 @@ int mac::ue_rem(uint16_t rnti)
task_sched.defer_callback(FDD_HARQ_DELAY_DL_MS + FDD_HARQ_DELAY_UL_MS, [this, rnti]() {
phy_h->rem_rnti(rnti);
ues_to_rem.erase(rnti);
Info("User rnti=0x%x removed from MAC/PHY\n", rnti);
logger.info("User rnti=0x%x removed from MAC/PHY", rnti);
});
return SRSLTE_SUCCESS;
}
@ -288,6 +286,7 @@ void mac::get_metrics(mac_metrics_t& metrics)
int mac::ack_info(uint32_t tti_rx, uint16_t rnti, uint32_t enb_cc_idx, uint32_t tb_idx, bool ack)
{
logger.set_context(tti_rx);
log_h->step(tti_rx);
srslte::rwlock_read_guard lock(rwlock);
@ -301,7 +300,7 @@ int mac::ack_info(uint32_t tti_rx, uint16_t rnti, uint32_t enb_cc_idx, uint32_t
if (ack) {
if (nof_bytes > 64) { // do not count RLC status messages only
rrc_h->set_activity_user(rnti);
log_h->info("DL activity rnti=0x%x, n_bytes=%d\n", rnti, nof_bytes);
logger.info("DL activity rnti=0x%x, n_bytes=%d", rnti, nof_bytes);
}
}
return SRSLTE_SUCCESS;
@ -309,6 +308,7 @@ int mac::ack_info(uint32_t tti_rx, uint16_t rnti, uint32_t enb_cc_idx, uint32_t
int mac::crc_info(uint32_t tti_rx, uint16_t rnti, uint32_t enb_cc_idx, uint32_t nof_bytes, bool crc)
{
logger.set_context(tti_rx);
log_h->step(tti_rx);
srslte::rwlock_read_guard lock(rwlock);
@ -333,18 +333,18 @@ int mac::push_pdu(uint32_t tti_rx, uint16_t rnti, uint32_t enb_cc_idx, uint32_t
std::array<int, SRSLTE_MAX_CARRIERS> enb_ue_cc_map = scheduler.get_enb_ue_cc_map(rnti);
if (enb_ue_cc_map[enb_cc_idx] < 0) {
Error("User rnti=0x%x is not activated for carrier %d\n", rnti, enb_cc_idx);
logger.error("User rnti=0x%x is not activated for carrier %d", rnti, enb_cc_idx);
return SRSLTE_ERROR;
}
uint32_t ue_cc_idx = enb_ue_cc_map[enb_cc_idx];
// push the pdu through the queue if received correctly
if (crc) {
Info("Pushing PDU rnti=0x%x, tti_rx=%d, nof_bytes=%d\n", rnti, tti_rx, nof_bytes);
logger.info("Pushing PDU rnti=0x%x, tti_rx=%d, nof_bytes=%d", rnti, tti_rx, nof_bytes);
ue_db[rnti]->push_pdu(tti_rx, ue_cc_idx, nof_bytes);
stack_task_queue.push([this]() { process_pdus(); });
} else {
Debug("Discarting PDU rnti=0x%x, tti_rx=%d, nof_bytes=%d\n", rnti, tti_rx, nof_bytes);
logger.debug("Discarting PDU rnti=0x%x, tti_rx=%d, nof_bytes=%d", rnti, tti_rx, nof_bytes);
ue_db[rnti]->deallocate_pdu(tti_rx, ue_cc_idx);
}
return SRSLTE_SUCCESS;
@ -352,6 +352,7 @@ int mac::push_pdu(uint32_t tti_rx, uint16_t rnti, uint32_t enb_cc_idx, uint32_t
int mac::ri_info(uint32_t tti, uint16_t rnti, uint32_t enb_cc_idx, uint32_t ri_value)
{
logger.set_context(tti);
log_h->step(tti);
srslte::rwlock_read_guard lock(rwlock);
@ -367,6 +368,7 @@ int mac::ri_info(uint32_t tti, uint16_t rnti, uint32_t enb_cc_idx, uint32_t ri_v
int mac::pmi_info(uint32_t tti, uint16_t rnti, uint32_t enb_cc_idx, uint32_t pmi_value)
{
logger.set_context(tti);
log_h->step(tti);
srslte::rwlock_read_guard lock(rwlock);
@ -382,6 +384,7 @@ int mac::pmi_info(uint32_t tti, uint16_t rnti, uint32_t enb_cc_idx, uint32_t pmi
int mac::cqi_info(uint32_t tti, uint16_t rnti, uint32_t enb_cc_idx, uint32_t cqi_value)
{
logger.set_context(tti);
log_h->step(tti);
srslte::rwlock_read_guard lock(rwlock);
@ -397,6 +400,7 @@ int mac::cqi_info(uint32_t tti, uint16_t rnti, uint32_t enb_cc_idx, uint32_t cqi
int mac::snr_info(uint32_t tti_rx, uint16_t rnti, uint32_t enb_cc_idx, float snr, ul_channel_t ch)
{
logger.set_context(tti_rx);
log_h->step(tti_rx);
srslte::rwlock_read_guard lock(rwlock);
@ -424,6 +428,7 @@ int mac::ta_info(uint32_t tti, uint16_t rnti, float ta_us)
int mac::sr_detected(uint32_t tti, uint16_t rnti)
{
logger.set_context(tti);
log_h->step(tti);
srslte::rwlock_read_guard lock(rwlock);
@ -452,14 +457,14 @@ uint16_t mac::allocate_ue()
{
srslte::rwlock_read_guard lock(rwlock);
if (ue_db.size() >= args.max_nof_ues) {
Warning("Maximum number of connected UEs %d reached. Ignoring PRACH\n", args.max_nof_ues);
logger.warning("Maximum number of connected UEs %d reached. Ignoring PRACH", args.max_nof_ues);
return SRSLTE_INVALID_RNTI;
}
}
// Get pre-allocated UE object
if (ue_pool.empty()) {
Error("Ignoring RACH attempt. UE pool empty.\n");
logger.error("Ignoring RACH attempt. UE pool empty.");
return SRSLTE_INVALID_RNTI;
}
std::unique_ptr<ue> ue_ptr = ue_pool.wait_pop();
@ -492,7 +497,7 @@ uint16_t mac::reserve_new_crnti(const sched_interface::ue_cfg_t& ue_cfg)
// Add new user to the scheduler so that it can RX/TX SRB0
if (scheduler.ue_cfg(rnti, ue_cfg) != SRSLTE_SUCCESS) {
Error("Registering new user rnti=0x%x to SCHED\n", rnti);
logger.error("Registering new user rnti=0x%x to SCHED", rnti);
return SRSLTE_INVALID_RNTI;
}
@ -502,6 +507,7 @@ uint16_t mac::reserve_new_crnti(const sched_interface::ue_cfg_t& ue_cfg)
void mac::rach_detected(uint32_t tti, uint32_t enb_cc_idx, uint32_t preamble_idx, uint32_t time_adv)
{
static srslte::mutexed_tprof<srslte::avg_time_stats> rach_tprof("rach_tprof", "MAC", 1);
logger.set_context(tti);
log_h->step(tti);
auto rach_tprof_meas = rach_tprof.start();
@ -531,7 +537,7 @@ void mac::rach_detected(uint32_t tti, uint32_t enb_cc_idx, uint32_t preamble_idx
ue_cfg.ue_bearers[0].direction = srsenb::sched_interface::ue_bearer_cfg_t::BOTH;
ue_cfg.supported_cc_list[0].dl_cfg.tm = SRSLTE_TM1;
if (scheduler.ue_cfg(rnti, ue_cfg) != SRSLTE_SUCCESS) {
Error("Registering new user rnti=0x%x to SCHED\n", rnti);
logger.error("Registering new user rnti=0x%x to SCHED", rnti);
ue_rem(rnti);
return;
}
@ -545,12 +551,8 @@ void mac::rach_detected(uint32_t tti, uint32_t enb_cc_idx, uint32_t preamble_idx
// Trigger scheduler RACH
scheduler.dl_rach_info(enb_cc_idx, rar_info);
log_h->info("RACH: tti=%d, cc=%d, preamble=%d, offset=%d, temp_crnti=0x%x\n",
tti,
enb_cc_idx,
preamble_idx,
time_adv,
rnti);
logger.info(
"RACH: tti=%d, cc=%d, preamble=%d, offset=%d, temp_crnti=0x%x", tti, enb_cc_idx, preamble_idx, time_adv, rnti);
srslte::console("RACH: tti=%d, cc=%d, preamble=%d, offset=%d, temp_crnti=0x%x\n",
tti,
enb_cc_idx,
@ -567,7 +569,7 @@ void mac::prealloc_ue(uint32_t nof_ue)
{
for (uint32_t i = 0; i < nof_ue; i++) {
std::unique_ptr<ue> ptr = std::unique_ptr<ue>(
new ue(allocate_rnti(), args.nof_prb, &scheduler, rrc_h, rlc_h, phy_h, log_h, cells.size()));
new ue(allocate_rnti(), args.nof_prb, &scheduler, rrc_h, rlc_h, phy_h, log_h, logger, cells.size()));
ue_pool.push(std::move(ptr));
}
}
@ -578,13 +580,14 @@ int mac::get_dl_sched(uint32_t tti_tx_dl, dl_sched_list_t& dl_sched_res_list)
return 0;
}
logger.set_context(TTI_SUB(tti_tx_dl, FDD_HARQ_DELAY_UL_MS));
log_h->step(TTI_SUB(tti_tx_dl, FDD_HARQ_DELAY_UL_MS));
for (uint32_t enb_cc_idx = 0; enb_cc_idx < cell_config.size(); enb_cc_idx++) {
// Run scheduler with current info
sched_interface::dl_sched_res_t sched_result = {};
if (scheduler.dl_sched(tti_tx_dl, enb_cc_idx, sched_result) < 0) {
Error("Running scheduler\n");
logger.error("Running scheduler");
return SRSLTE_ERROR;
}
@ -624,7 +627,7 @@ int mac::get_dl_sched(uint32_t tti_tx_dl, dl_sched_list_t& dl_sched_res_list)
sched_result.data[i].tbs[tb]);
if (!dl_sched_res->pdsch[n].data[tb]) {
Error("Error! PDU was not generated (rnti=0x%04x, tb=%d)\n", rnti, tb);
logger.error("Error! PDU was not generated (rnti=0x%04x, tb=%d)", rnti, tb);
}
if (pcap) {
@ -644,7 +647,7 @@ int mac::get_dl_sched(uint32_t tti_tx_dl, dl_sched_list_t& dl_sched_res_list)
n++;
}
} else {
Warning("Invalid DL scheduling result. User 0x%x does not exist\n", rnti);
logger.warning("Invalid DL scheduling result. User 0x%x does not exist", rnti);
}
}
@ -760,6 +763,7 @@ void mac::build_mch_sched(uint32_t tbs)
int mac::get_mch_sched(uint32_t tti, bool is_mcch, dl_sched_list_t& dl_sched_res_list)
{
dl_sched_t* dl_sched_res = &dl_sched_res_list[0];
logger.set_context(tti);
log_h->step(tti);
srslte_ra_tb_t mcs = {};
srslte_ra_tb_t mcs_data = {};
@ -771,7 +775,7 @@ int mac::get_mch_sched(uint32_t tti, bool is_mcch, dl_sched_list_t& dl_sched_res
build_mch_sched(mcs_data.tbs);
mch.mcch_payload = mcch_payload_buffer;
mch.current_sf_allocation_num = 1;
Info("MCH Sched Info: LCID: %d, Stop: %d, tti is %d \n",
logger.info("MCH Sched Info: LCID: %d, Stop: %d, tti is %d ",
mch.mtch_sched[0].lcid,
mch.mtch_sched[mch.num_mtch_sched - 1].stop,
tti);
@ -856,10 +860,10 @@ uint8_t* mac::assemble_rar(sched_interface::dl_sched_rar_grant_t* grants,
}
}
Error("Assembling RAR: rar_idx=%d, pdu_len=%d, rar_payload_len=%d, nof_grants=%d\n",
logger.error("Assembling RAR: rar_idx=%d, pdu_len=%d, rar_payload_len=%d, nof_grants=%d",
rar_idx,
pdu_len,
rar_payload_len,
int(rar_payload_len),
nof_grants);
return nullptr;
}
@ -870,6 +874,7 @@ int mac::get_ul_sched(uint32_t tti_tx_ul, ul_sched_list_t& ul_sched_res_list)
return SRSLTE_SUCCESS;
}
logger.set_context(TTI_SUB(tti_tx_ul, FDD_HARQ_DELAY_UL_MS + FDD_HARQ_DELAY_DL_MS));
log_h->step(TTI_SUB(tti_tx_ul, FDD_HARQ_DELAY_UL_MS + FDD_HARQ_DELAY_DL_MS));
// Execute UE FSMs (e.g. TA)
@ -883,7 +888,7 @@ int mac::get_ul_sched(uint32_t tti_tx_ul, ul_sched_list_t& ul_sched_res_list)
// Run scheduler with current info
sched_interface::ul_sched_res_t sched_result = {};
if (scheduler.ul_sched(tti_tx_ul, enb_cc_idx, sched_result) < 0) {
Error("Running scheduler\n");
logger.error("Running scheduler");
return SRSLTE_ERROR;
}
@ -920,15 +925,15 @@ int mac::get_ul_sched(uint32_t tti_tx_ul, ul_sched_list_t& ul_sched_res_list)
if (phy_ul_sched_res->pusch[n].data) {
phy_ul_sched_res->nof_grants++;
} else {
Error("Grant for rnti=0x%x could not be allocated due to lack of buffers\n", rnti);
logger.error("Grant for rnti=0x%x could not be allocated due to lack of buffers", rnti);
}
n++;
} else {
Warning("Invalid UL scheduling result. User 0x%x does not exist\n", rnti);
logger.warning("Invalid UL scheduling result. User 0x%x does not exist", rnti);
}
} else {
Warning("Grant %d for rnti=0x%x has zero TBS\n", i, sched_result.pusch[i].dci.rnti);
logger.warning("Grant %d for rnti=0x%x has zero TBS", i, sched_result.pusch[i].dci.rnti);
}
}
@ -974,8 +979,8 @@ void mac::write_mcch(const srslte::sib2_mbms_t* sib2_,
sib13 = *sib13_;
memcpy(mcch_payload_buffer, mcch_payload, mcch_payload_length * sizeof(uint8_t));
current_mcch_length = mcch_payload_length;
ue_db[SRSLTE_MRNTI] =
std::unique_ptr<ue>{new ue(SRSLTE_MRNTI, args.nof_prb, &scheduler, rrc_h, rlc_h, phy_h, log_h, cells.size())};
ue_db[SRSLTE_MRNTI] = std::unique_ptr<ue>{
new ue(SRSLTE_MRNTI, args.nof_prb, &scheduler, rrc_h, rlc_h, phy_h, log_h, logger, cells.size())};
rrc_h->add_user(SRSLTE_MRNTI, {});
}
@ -984,7 +989,7 @@ bool mac::check_ue_exists(uint16_t rnti)
{
if (not ue_db.count(rnti)) {
if (not ues_to_rem.count(rnti)) {
Error("User rnti=0x%x not found\n", rnti);
logger.error("User rnti=0x%x not found", rnti);
}
return false;
}

@ -17,10 +17,11 @@
#include "srsenb/hdr/stack/mac/sched_carrier.h"
#include "srsenb/hdr/stack/mac/sched_helpers.h"
#include "srslte/common/logmap.h"
#include "srslte/srslog/srslog.h"
#include "srslte/srslte.h"
#define Console(fmt, ...) srslte::console(fmt, ##__VA_ARGS__)
#define Error(fmt, ...) srslte::logmap::get("MAC ")->error(fmt, ##__VA_ARGS__)
#define Error(fmt, ...) srslog::fetch_basic_logger("MAC").error(fmt, ##__VA_ARGS__)
using srslte::tti_point;
@ -32,7 +33,7 @@ namespace srsenb {
*
*******************************************************/
sched::sched() : log_h(srslte::logmap::get("MAC")) {}
sched::sched() {}
sched::~sched() {}
@ -120,7 +121,7 @@ int sched::ue_rem(uint16_t rnti)
if (ue_db.count(rnti) > 0) {
ue_db.erase(rnti);
} else {
Error("User rnti=0x%x not found\n", rnti);
Error("User rnti=0x%x not found", rnti);
return SRSLTE_ERROR;
}
return SRSLTE_SUCCESS;
@ -365,9 +366,9 @@ int sched::ue_db_access(uint16_t rnti, Func f, const char* func_name)
f(it->second);
} else {
if (func_name != nullptr) {
Error("User rnti=0x%x not found. Failed to call %s.\n", rnti, func_name);
Error("User rnti=0x%x not found. Failed to call %s.", rnti, func_name);
} else {
Error("User rnti=0x%x not found.\n", rnti);
Error("User rnti=0x%x not found.", rnti);
}
return SRSLTE_ERROR;
}

@ -130,7 +130,7 @@ void bc_sched::reset()
*******************************************************/
ra_sched::ra_sched(const sched_cell_params_t& cfg_, std::map<uint16_t, sched_ue>& ue_db_) :
cc_cfg(&cfg_), log_h(srslte::logmap::get("MAC")), ue_db(&ue_db_)
cc_cfg(&cfg_), logger(srslog::fetch_basic_logger("MAC")), ue_db(&ue_db_)
{}
// Schedules RAR
@ -152,13 +152,13 @@ void ra_sched::dl_sched(sf_sched* tti_sched)
char error_msg[128];
int len = snprintf(error_msg,
sizeof(error_msg),
"SCHED: Could not transmit RAR within the window (RA=%d, Window=%s, RAR=%d)\n",
"SCHED: Could not transmit RAR within the window (RA=%d, Window=%s, RAR=%d)",
rar.prach_tti.to_uint(),
rar_window.to_string().c_str(),
tti_tx_dl.to_uint());
error_msg[len] = '\0';
srslte::console("%s", error_msg);
log_h->error("%s", error_msg);
srslte::console("%s\n", error_msg);
logger.error("%s", error_msg);
// Remove from pending queue and get next one if window has passed already
pending_rars.pop_front();
continue;
@ -192,7 +192,7 @@ void ra_sched::dl_sched(sf_sched* tti_sched)
int ra_sched::dl_rach_info(dl_sched_rar_info_t rar_info)
{
log_h->info("SCHED: New PRACH tti=%d, preamble=%d, temp_crnti=0x%x, ta_cmd=%d, msg3_size=%d\n",
logger.info("SCHED: New PRACH tti=%d, preamble=%d, temp_crnti=0x%x, ta_cmd=%d, msg3_size=%d",
rar_info.prach_tti,
rar_info.preamble_idx,
rar_info.temp_crnti,
@ -207,7 +207,7 @@ int ra_sched::dl_rach_info(dl_sched_rar_info_t rar_info)
for (sf_sched::pending_rar_t& r : pending_rars) {
if (r.prach_tti.to_uint() == rar_info.prach_tti and ra_rnti == r.ra_rnti) {
if (r.nof_grants >= sched_interface::MAX_RAR_LIST) {
log_h->warning("PRACH ignored, as the the maximum number of RAR grants per tti has been reached\n");
logger.warning("PRACH ignored, as the the maximum number of RAR grants per tti has been reached");
return SRSLTE_ERROR;
}
r.msg3_grant[r.nof_grants] = rar_info;
@ -238,11 +238,10 @@ void ra_sched::ul_sched(sf_sched* sf_dl_sched, sf_sched* sf_msg3_sched)
uint16_t crnti = msg3grant.data.temp_crnti;
auto user_it = ue_db->find(crnti);
if (user_it != ue_db->end() and sf_msg3_sched->alloc_msg3(&user_it->second, msg3grant)) {
log_h->debug("SCHED: Queueing Msg3 for rnti=0x%x at tti=%d\n", crnti, sf_msg3_sched->get_tti_tx_ul().to_uint());
logger.debug("SCHED: Queueing Msg3 for rnti=0x%x at tti=%d", crnti, sf_msg3_sched->get_tti_tx_ul().to_uint());
} else {
log_h->error("SCHED: Failed to allocate Msg3 for rnti=0x%x at tti=%d\n",
crnti,
sf_msg3_sched->get_tti_tx_ul().to_uint());
logger.error(
"SCHED: Failed to allocate Msg3 for rnti=0x%x at tti=%d", crnti, sf_msg3_sched->get_tti_tx_ul().to_uint());
}
}
}
@ -263,7 +262,7 @@ sched::carrier_sched::carrier_sched(rrc_interface_mac* rrc_,
sched_result_list* sched_results_) :
rrc(rrc_),
ue_db(ue_db_),
log_h(srslte::logmap::get("MAC ")),
logger(srslog::fetch_basic_logger("MAC")),
enb_cc_idx(enb_cc_idx_),
prev_sched_results(sched_results_)
{
@ -290,10 +289,10 @@ void sched::carrier_sched::carrier_cfg(const sched_cell_params_t& cell_params_)
// Setup data scheduling algorithms
if (cell_params_.sched_cfg->sched_policy == "time_rr") {
sched_algo.reset(new sched_time_rr{*cc_cfg, *cell_params_.sched_cfg});
log_h->info("Using time-domain RR scheduling policy for cc=%d\n", cc_cfg->enb_cc_idx);
logger.info("Using time-domain RR scheduling policy for cc=%d", cc_cfg->enb_cc_idx);
} else {
sched_algo.reset(new sched_time_pf{*cc_cfg, *cell_params_.sched_cfg});
log_h->info("Using time-domain PF scheduling policy for cc=%d\n", cc_cfg->enb_cc_idx);
logger.info("Using time-domain PF scheduling policy for cc=%d", cc_cfg->enb_cc_idx);
}
// Initiate the tti_scheduler for each TTI
@ -361,8 +360,8 @@ const cc_sched_result& sched::carrier_sched::generate_tti_result(tti_point tti_r
user.second.finish_tti(tti_rx, enb_cc_idx);
}
log_dl_cc_results(log_h, enb_cc_idx, cc_result->dl_sched_result);
log_phich_cc_results(log_h, enb_cc_idx, cc_result->ul_sched_result);
log_dl_cc_results(logger, enb_cc_idx, cc_result->dl_sched_result);
log_phich_cc_results(logger, enb_cc_idx, cc_result->ul_sched_result);
return *cc_result;
}

@ -119,7 +119,6 @@ void pdcch_grid_t::alloc_tree_t::reset()
void pdcch_grid_t::init(const sched_cell_params_t& cell_params_)
{
cc_cfg = &cell_params_;
log_h = srslte::logmap::get("MAC ");
// init alloc trees
alloc_trees.reserve(cc_cfg->sched_cfg->max_nof_ctrl_symbols);
@ -174,7 +173,7 @@ bool pdcch_grid_t::alloc_dci(alloc_type_t alloc_type, uint32_t aggr_idx, sched_u
if (not success) {
// DCI allocation failed. go back to original CFI
if (get_cfi() != first_cfi and not set_cfi(first_cfi)) {
log_h->error("SCHED: Failed to return back to original PDCCH state\n");
logger.error("SCHED: Failed to return back to original PDCCH state");
}
return false;
}
@ -275,7 +274,7 @@ bool pdcch_grid_t::add_tree_node_leaves(alloc_tree_t& tree,
bool pdcch_grid_t::set_cfi(uint32_t cfi)
{
if (cfi < cc_cfg->sched_cfg->min_nof_ctrl_symbols or cfi > cc_cfg->sched_cfg->max_nof_ctrl_symbols) {
srslte::logmap::get("MAC")->error("Invalid CFI value. Defaulting to current CFI.\n");
logger.error("Invalid CFI value. Defaulting to current CFI.");
return false;
}
@ -379,7 +378,6 @@ std::string pdcch_grid_t::result_to_string(bool verbose) const
void sf_grid_t::init(const sched_cell_params_t& cell_params_)
{
cc_cfg = &cell_params_;
log_h = srslte::logmap::get("MAC ");
nof_rbgs = cc_cfg->nof_rbgs;
si_n_rbg = srslte::ceil_div(4, cc_cfg->P);
rar_n_rbg = srslte::ceil_div(3, cc_cfg->P);
@ -413,8 +411,8 @@ alloc_outcome_t sf_grid_t::alloc_dl(uint32_t aggr_idx, alloc_type_t alloc_type,
// Allocate DCI in PDCCH
if (not pdcch_alloc.alloc_dci(alloc_type, aggr_idx, user)) {
if (user != nullptr) {
if (log_h->get_level() == srslte::LOG_LEVEL_DEBUG) {
log_h->debug("No space in PDCCH for rnti=0x%x DL tx. Current PDCCH allocation: %s\n",
if (logger.debug.enabled()) {
logger.debug("No space in PDCCH for rnti=0x%x DL tx. Current PDCCH allocation: %s",
user->get_rnti(),
pdcch_alloc.result_to_string(true).c_str());
}
@ -437,7 +435,7 @@ sf_grid_t::dl_ctrl_alloc_t sf_grid_t::alloc_dl_ctrl(uint32_t aggr_idx, alloc_typ
if (alloc_type != alloc_type_t::DL_RAR and alloc_type != alloc_type_t::DL_BC and
alloc_type != alloc_type_t::DL_PCCH) {
log_h->error("SCHED: DL control allocations must be RAR/BC/PDCCH\n");
logger.error("SCHED: DL control allocations must be RAR/BC/PDCCH");
return {alloc_outcome_t::ERROR, range};
}
// Setup range starting from left
@ -479,8 +477,8 @@ alloc_outcome_t sf_grid_t::alloc_ul_data(sched_ue* user, prb_interval alloc, boo
uint32_t nof_bits = srslte_dci_format_sizeof(&cc_cfg->cfg.cell, nullptr, nullptr, SRSLTE_DCI_FORMAT0);
uint32_t aggr_idx = user->get_aggr_level(cc_cfg->enb_cc_idx, nof_bits);
if (not pdcch_alloc.alloc_dci(alloc_type_t::UL_DATA, aggr_idx, user)) {
if (log_h->get_level() == srslte::LOG_LEVEL_DEBUG) {
log_h->debug("No space in PDCCH for rnti=0x%x UL tx. Current PDCCH allocation: %s\n",
if (logger.debug.enabled()) {
logger.debug("No space in PDCCH for rnti=0x%x UL tx. Current PDCCH allocation: %s",
user->get_rnti(),
pdcch_alloc.result_to_string(true).c_str());
}
@ -503,7 +501,7 @@ bool sf_grid_t::reserve_ul_prbs(const prbmask_t& prbmask, bool strict)
{
bool ret = true;
if (strict and (ul_mask & prbmask).any()) {
log_h->error("There was a collision in UL channel. current mask=0x%s, new alloc mask=0x%s\n",
logger.error("There was a collision in UL channel. current mask=0x%s, new alloc mask=0x%s",
ul_mask.to_hex().c_str(),
prbmask.to_hex().c_str());
ret = false;
@ -551,7 +549,7 @@ bool sf_grid_t::find_ul_alloc(uint32_t L, prb_interval* alloc) const
* TTI resource Scheduling Methods
*******************************************************/
sf_sched::sf_sched() : log_h(srslte::logmap::get("MAC")) {}
sf_sched::sf_sched() : logger(srslog::fetch_basic_logger("MAC")) {}
void sf_sched::init(const sched_cell_params_t& cell_params_)
{
@ -586,7 +584,7 @@ void sf_sched::new_tti(tti_point tti_rx_, sf_sched_result* cc_results_)
prbmask_t prach_mask{cc_cfg->nof_prb()};
prach_mask.fill(cc_cfg->cfg.prach_freq_offset, cc_cfg->cfg.prach_freq_offset + 6);
reserve_ul_prbs(prach_mask, cc_cfg->nof_prb() != 6);
log_h->debug("SCHED: Allocated PRACH RBs for tti_tx_ul=%d. Mask: 0x%s\n",
logger.debug("SCHED: Allocated PRACH RBs for tti_tx_ul=%d. Mask: 0x%s",
to_tx_ul(tti_rx).to_uint(),
prach_mask.to_hex().c_str());
}
@ -653,7 +651,7 @@ alloc_outcome_t sf_sched::alloc_bc(uint32_t aggr_lvl, uint32_t sib_idx, uint32_t
uint32_t rv = get_rvidx(sib_ntx);
ctrl_code_t ret = alloc_dl_ctrl(aggr_lvl, sib_len, SRSLTE_SIRNTI);
if (not ret.first) {
Warning("SCHED: Could not allocate SIB=%d, L=%d, len=%d, cause=%s\n",
logger.warning("SCHED: Could not allocate SIB=%d, L=%d, len=%d, cause=%s",
sib_idx + 1,
aggr_lvl,
sib_len,
@ -673,13 +671,13 @@ alloc_outcome_t sf_sched::alloc_bc(uint32_t aggr_lvl, uint32_t sib_idx, uint32_t
alloc_outcome_t sf_sched::alloc_paging(uint32_t aggr_lvl, uint32_t paging_payload)
{
if (bc_allocs.size() >= sched_interface::MAX_BC_LIST) {
Warning("SCHED: Maximum number of Broadcast allocations reached\n");
logger.warning("SCHED: Maximum number of Broadcast allocations reached");
return alloc_outcome_t::ERROR;
}
ctrl_code_t ret = alloc_dl_ctrl(aggr_lvl, paging_payload, SRSLTE_PRNTI);
if (not ret.first) {
Warning(
"SCHED: Could not allocate Paging with payload length=%d, cause=%s\n", paging_payload, ret.first.to_string());
logger.warning(
"SCHED: Could not allocate Paging with payload length=%d, cause=%s", paging_payload, ret.first.to_string());
return ret.first;
}
@ -695,7 +693,7 @@ std::pair<alloc_outcome_t, uint32_t> sf_sched::alloc_rar(uint32_t aggr_lvl, cons
const uint32_t msg3_grant_size = 3;
std::pair<alloc_outcome_t, uint32_t> ret = {alloc_outcome_t::ERROR, 0};
if (rar_allocs.size() >= sched_interface::MAX_RAR_LIST) {
Warning("SCHED: Maximum number of RAR allocations per TTI reached.\n");
logger.warning("SCHED: Maximum number of RAR allocations per TTI reached.");
return ret;
}
@ -720,7 +718,7 @@ std::pair<alloc_outcome_t, uint32_t> sf_sched::alloc_rar(uint32_t aggr_lvl, cons
}
// if any other error, return
if (ret.first != alloc_outcome_t::SUCCESS) {
log_h->warning("SCHED: Could not allocate RAR for L=%d, cause=%s\n", aggr_lvl, ret.first.to_string());
logger.warning("SCHED: Could not allocate RAR for L=%d, cause=%s", aggr_lvl, ret.first.to_string());
return ret;
}
@ -741,7 +739,7 @@ std::pair<alloc_outcome_t, uint32_t> sf_sched::alloc_rar(uint32_t aggr_lvl, cons
break;
}
if (ret.first != alloc_outcome_t::SUCCESS) {
log_h->info("SCHED: Failed to allocate RAR due to lack of RBs\n");
logger.info("SCHED: Failed to allocate RAR due to lack of RBs");
}
return ret;
}
@ -761,12 +759,12 @@ bool is_periodic_cqi_expected(const sched_interface::ue_cfg_t& ue_cfg, tti_point
alloc_outcome_t sf_sched::alloc_dl_user(sched_ue* user, const rbgmask_t& user_mask, uint32_t pid)
{
if (data_allocs.size() >= sched_interface::MAX_DATA_LIST) {
Warning("SCHED: Maximum number of DL allocations reached\n");
logger.warning("SCHED: Maximum number of DL allocations reached");
return alloc_outcome_t::ERROR;
}
if (is_dl_alloc(user->get_rnti())) {
Warning("SCHED: Attempt to assign multiple harq pids to the same user rnti=0x%x\n", user->get_rnti());
logger.warning("SCHED: Attempt to assign multiple harq pids to the same user rnti=0x%x", user->get_rnti());
return alloc_outcome_t::ALREADY_ALLOC;
}
@ -784,7 +782,7 @@ alloc_outcome_t sf_sched::alloc_dl_user(sched_ue* user, const rbgmask_t& user_ma
// It is newTx
rbg_interval r = user->get_required_dl_rbgs(cc_cfg->enb_cc_idx);
if (r.start() > user_mask.count()) {
log_h->warning("The number of RBGs allocated to rnti=0x%x will force segmentation\n", user->get_rnti());
logger.warning("The number of RBGs allocated to rnti=0x%x will force segmentation", user->get_rnti());
return alloc_outcome_t::NOF_RB_INVALID;
}
}
@ -829,13 +827,13 @@ alloc_outcome_t sf_sched::alloc_dl_user(sched_ue* user, const rbgmask_t& user_ma
alloc_outcome_t sf_sched::alloc_ul(sched_ue* user, prb_interval alloc, ul_alloc_t::type_t alloc_type, int msg3_mcs)
{
if (ul_data_allocs.size() >= sched_interface::MAX_DATA_LIST) {
Warning("SCHED: Maximum number of UL allocations reached\n");
logger.warning("SCHED: Maximum number of UL allocations reached");
return alloc_outcome_t::ERROR;
}
// Check whether user was already allocated
if (is_ul_alloc(user->get_rnti())) {
log_h->warning("SCHED: Attempt to assign multiple ul_harq_proc to the same user rnti=0x%x\n", user->get_rnti());
logger.warning("SCHED: Attempt to assign multiple ul_harq_proc to the same user rnti=0x%x", user->get_rnti());
return alloc_outcome_t::ALREADY_ALLOC;
}
@ -884,7 +882,7 @@ alloc_outcome_t sf_sched::alloc_ul_user(sched_ue* user, prb_interval alloc)
bool sf_sched::alloc_phich(sched_ue* user, sched_interface::ul_sched_res_t* ul_sf_result)
{
if (ul_sf_result->nof_phich_elems >= sched_interface::MAX_PHICH_LIST) {
Warning("SCHED: Maximum number of PHICH allocations has been reached\n");
logger.warning("SCHED: Maximum number of PHICH allocations has been reached");
return false;
}
using phich_t = sched_interface::ul_sched_phich_t;
@ -924,7 +922,7 @@ void sf_sched::set_bc_sched_result(const pdcch_grid_t::alloc_result_t& dci_resul
// Setup BC/Paging processes
if (bc_alloc.alloc_type == alloc_type_t::DL_BC) {
if (tbs <= (int)bc_alloc.req_bytes) {
log_h->warning("SCHED: Error SIB%d, rbgs=(%d,%d), dci=(%d,%d), len=%d\n",
logger.warning("SCHED: Error SIB%d, rbgs=(%d,%d), dci=(%d,%d), len=%d",
bc_alloc.sib_idx + 1,
bc_alloc.rbg_range.start(),
bc_alloc.rbg_range.stop(),
@ -939,7 +937,7 @@ void sf_sched::set_bc_sched_result(const pdcch_grid_t::alloc_result_t& dci_resul
bc->type = sched_interface::dl_sched_bc_t::BCCH;
bc->tbs = (uint32_t)bc_alloc.req_bytes;
log_h->debug("SCHED: SIB%d, rbgs=(%d,%d), dci=(%d,%d), rv=%d, len=%d, period=%d, mcs=%d\n",
logger.debug("SCHED: SIB%d, rbgs=(%d,%d), dci=(%d,%d), rv=%d, len=%d, period=%d, mcs=%d",
bc_alloc.sib_idx + 1,
bc_alloc.rbg_range.start(),
bc_alloc.rbg_range.stop(),
@ -952,7 +950,7 @@ void sf_sched::set_bc_sched_result(const pdcch_grid_t::alloc_result_t& dci_resul
} else {
// Paging
if (tbs <= 0) {
log_h->warning("SCHED: Error Paging, rbgs=%s, dci=(%d,%d)\n",
logger.warning("SCHED: Error Paging, rbgs=%s, dci=(%d,%d)",
bc_alloc.rbg_range.to_string().c_str(),
bc->dci.location.L,
bc->dci.location.ncce);
@ -963,7 +961,7 @@ void sf_sched::set_bc_sched_result(const pdcch_grid_t::alloc_result_t& dci_resul
bc->type = sched_interface::dl_sched_bc_t::PCCH;
bc->tbs = (uint32_t)tbs;
log_h->info("SCHED: PCH, rbgs=%s, dci=(%d,%d), tbs=%d, mcs=%d\n",
logger.info("SCHED: PCH, rbgs=%s, dci=(%d,%d), tbs=%d, mcs=%d",
bc_alloc.rbg_range.to_string().c_str(),
bc->dci.location.L,
bc->dci.location.ncce,
@ -988,7 +986,7 @@ void sf_sched::set_rar_sched_result(const pdcch_grid_t::alloc_result_t& dci_resu
prb_interval prb_range = prb_interval::rbgs_to_prbs(rar_alloc.alloc_data.rbg_range, cc_cfg->nof_prb());
int tbs = generate_format1a(prb_range, rar_alloc.alloc_data.req_bytes, 0, rar_alloc.alloc_data.rnti, &rar->dci);
if (tbs <= 0) {
log_h->warning("SCHED: Error RAR, ra_rnti_idx=%d, rbgs=%s, dci=(%d,%d)\n",
logger.warning("SCHED: Error RAR, ra_rnti_idx=%d, rbgs=%s, dci=(%d,%d)",
rar_alloc.alloc_data.rnti,
rar_alloc.alloc_data.rbg_range.to_string().c_str(),
rar->dci.location.L,
@ -1004,8 +1002,8 @@ void sf_sched::set_rar_sched_result(const pdcch_grid_t::alloc_result_t& dci_resu
for (uint32_t i = 0; i < rar->msg3_grant.size(); ++i) {
const auto& msg3_grant = rar->msg3_grant[i];
uint16_t expected_rnti = msg3_grant.data.temp_crnti;
log_h->info("SCHED: RAR, temp_crnti=0x%x, ra-rnti=%d, rbgs=%s, dci=(%d,%d), rar_grant_rba=%d, "
"rar_grant_mcs=%d\n",
logger.info("SCHED: RAR, temp_crnti=0x%x, ra-rnti=%d, rbgs=%s, dci=(%d,%d), rar_grant_rba=%d, "
"rar_grant_mcs=%d",
expected_rnti,
rar_alloc.alloc_data.rnti,
rar_alloc.alloc_data.rbg_range.to_string().c_str(),
@ -1043,7 +1041,7 @@ void sf_sched::set_dl_data_sched_result(const pdcch_grid_t::alloc_result_t& dci_
data_alloc.pid, data, get_tti_tx_dl(), cc_cfg->enb_cc_idx, tti_alloc.get_cfi(), data_alloc.user_mask);
if (tbs <= 0) {
log_h->warning("SCHED: DL %s failed rnti=0x%x, pid=%d, mask=%s, tbs=%d, buffer=%d\n",
logger.warning("SCHED: DL %s failed rnti=0x%x, pid=%d, mask=%s, tbs=%d, buffer=%d",
is_newtx ? "tx" : "retx",
user->get_rnti(),
data_alloc.pid,
@ -1054,7 +1052,7 @@ void sf_sched::set_dl_data_sched_result(const pdcch_grid_t::alloc_result_t& dci_
}
// Print Resulting DL Allocation
log_h->info("SCHED: DL %s rnti=0x%x, cc=%d, pid=%d, mask=0x%s, dci=(%d,%d), n_rtx=%d, tbs=%d, buffer=%d/%d\n",
logger.info("SCHED: DL %s rnti=0x%x, cc=%d, pid=%d, mask=0x%s, dci=(%d,%d), n_rtx=%d, tbs=%d, buffer=%d/%d",
!is_newtx ? "retx" : "tx",
user->get_rnti(),
cc_cfg->enb_cc_idx,
@ -1194,7 +1192,7 @@ void sf_sched::set_ul_sched_result(const pdcch_grid_t::alloc_result_t& dci_resul
uint32_t new_pending_bytes = user->get_pending_ul_new_data(get_tti_tx_ul(), cc_cfg->enb_cc_idx);
// Allow TBS=0 in case of UCI-only PUSCH
if (tbs < 0 || (tbs == 0 && pusch->dci.tb.mcs_idx != 29)) {
log_h->warning("SCHED: Error %s %s rnti=0x%x, pid=%d, dci=(%d,%d), prb=%s, bsr=%d\n",
logger.warning("SCHED: Error %s %s rnti=0x%x, pid=%d, dci=(%d,%d), prb=%s, bsr=%d",
ul_alloc.type == ul_alloc_t::MSG3 ? "Msg3" : "UL",
ul_alloc.is_retx() ? "retx" : "tx",
user->get_rnti(),
@ -1208,7 +1206,7 @@ void sf_sched::set_ul_sched_result(const pdcch_grid_t::alloc_result_t& dci_resul
// Print Resulting UL Allocation
uint32_t old_pending_bytes = user->get_pending_ul_old_data();
log_h->info("SCHED: %s %s rnti=0x%x, cc=%d, pid=%d, dci=(%d,%d), prb=%s, n_rtx=%d, tbs=%d, bsr=%d (%d-%d)\n",
logger.info("SCHED: %s %s rnti=0x%x, cc=%d, pid=%d, dci=(%d,%d), prb=%s, n_rtx=%d, tbs=%d, bsr=%d (%d-%d)",
ul_alloc.is_msg3() ? "Msg3" : "UL",
ul_alloc.is_retx() ? "retx" : "tx",
user->get_rnti(),
@ -1236,7 +1234,7 @@ alloc_outcome_t sf_sched::alloc_msg3(sched_ue* user, const sched_interface::dl_s
alloc_outcome_t ret = alloc_ul(user, msg3_alloc, sf_sched::ul_alloc_t::MSG3, rargrant.grant.trunc_mcs);
if (not ret) {
log_h->warning("SCHED: Could not allocate msg3 within %s\n", msg3_alloc.to_string().c_str());
logger.warning("SCHED: Could not allocate msg3 within %s", msg3_alloc.to_string().c_str());
}
return ret;
}
@ -1256,7 +1254,7 @@ void sf_sched::generate_sched_results(sched_ue_list& ue_db)
if (not is_ul_alloc(ue.get_rnti()) and h != nullptr and not h->is_empty()) {
// There was a missed UL harq retx. Halt+Resume the HARQ
phich.phich = phich_t::ACK;
log_h->debug("SCHED: rnti=0x%x UL harq pid=%d is being resumed\n", ue.get_rnti(), h->get_id());
logger.debug("SCHED: rnti=0x%x UL harq pid=%d is being resumed", ue.get_rnti(), h->get_id());
}
}
}
@ -1314,11 +1312,11 @@ int sf_sched::generate_format1a(prb_interval prb_range,
}
}
if (i == 28) {
Error("Can't allocate Format 1A for TBS=%d\n", tbs);
logger.error("Can't allocate Format 1A for TBS=%d", tbs);
return -1;
}
Debug("ra_tbs=%d/%d, tbs_bytes=%d, tbs=%d, mcs=%d\n",
logger.debug("ra_tbs=%d/%d, tbs_bytes=%d, tbs=%d, mcs=%d",
srslte_ra_tbs_from_idx(mcs, 2),
srslte_ra_tbs_from_idx(mcs, 3),
tbs_bytes,

@ -15,10 +15,10 @@
#include "srslte/srslog/bundled/fmt/format.h"
#include <array>
#define Debug(fmt, ...) srslte::logmap::get("MAC")->debug(fmt, ##__VA_ARGS__)
#define Info(fmt, ...) srslte::logmap::get("MAC")->info(fmt, ##__VA_ARGS__)
#define Warning(fmt, ...) srslte::logmap::get("MAC")->warning(fmt, ##__VA_ARGS__)
#define Error(fmt, ...) srslte::logmap::get("MAC")->error(fmt, ##__VA_ARGS__)
#define Debug(fmt, ...) srslog::fetch_basic_logger("MAC").debug(fmt, ##__VA_ARGS__)
#define Info(fmt, ...) srslog::fetch_basic_logger("MAC").info(fmt, ##__VA_ARGS__)
#define Warning(fmt, ...) srslog::fetch_basic_logger("MAC").warning(fmt, ##__VA_ARGS__)
#define Error(fmt, ...) srslog::fetch_basic_logger("MAC").error(fmt, ##__VA_ARGS__)
namespace srsenb {
@ -98,36 +98,38 @@ void fill_dl_cc_result_debug(custom_mem_buffer& strbuf, const dl_sched_data_t& d
}
}
}
fmt::format_to(strbuf, "]\n");
fmt::format_to(strbuf, "]");
}
void log_dl_cc_results(srslte::log_ref log_h, uint32_t enb_cc_idx, const sched_interface::dl_sched_res_t& result)
void log_dl_cc_results(srslog::basic_logger& logger, uint32_t enb_cc_idx, const sched_interface::dl_sched_res_t& result)
{
if (log_h->get_level() < srslte::LOG_LEVEL_INFO) {
if (!logger.info.enabled()) {
return;
}
custom_mem_buffer strbuf;
for (uint32_t i = 0; i < result.nof_data_elems; ++i) {
const dl_sched_data_t& data = result.data[i];
if (log_h->get_level() == srslte::LOG_LEVEL_INFO) {
if (logger.info.enabled()) {
fill_dl_cc_result_info(strbuf, data);
} else if (log_h->get_level() == srslte::LOG_LEVEL_DEBUG) {
} else if (logger.debug.enabled()) {
fill_dl_cc_result_debug(strbuf, data);
}
}
if (strbuf.size() != 0) {
if (log_h->get_level() == srslte::LOG_LEVEL_DEBUG) {
log_h->debug("SCHED: DL MAC PDU payload cc=%d:\n%s", enb_cc_idx, fmt::to_string(strbuf).c_str());
if (logger.debug.enabled()) {
logger.debug("SCHED: DL MAC PDU payload cc=%d:\n%s", enb_cc_idx, fmt::to_string(strbuf).c_str());
} else {
log_h->info("SCHED: DL MAC CEs cc=%d: %s", enb_cc_idx, fmt::to_string(strbuf).c_str());
logger.info("SCHED: DL MAC CEs cc=%d: %s", enb_cc_idx, fmt::to_string(strbuf).c_str());
}
}
}
void log_phich_cc_results(srslte::log_ref log_h, uint32_t enb_cc_idx, const sched_interface::ul_sched_res_t& result)
void log_phich_cc_results(srslog::basic_logger& logger,
uint32_t enb_cc_idx,
const sched_interface::ul_sched_res_t& result)
{
using phich_t = sched_interface::ul_sched_phich_t;
if (log_h->get_level() < srslte::LOG_LEVEL_INFO) {
if (!logger.info.enabled()) {
return;
}
custom_mem_buffer strbuf;
@ -138,7 +140,7 @@ void log_phich_cc_results(srslte::log_ref log_h, uint32_t enb_cc_idx, const sche
fmt::format_to(strbuf, "{}rnti=0x{:0x}, val={}", prefix, phich.rnti, val);
}
if (strbuf.size() != 0) {
log_h->debug("SCHED: Allocated PHICHs, cc=%d: [%s]", enb_cc_idx, fmt::to_string(strbuf).c_str());
logger.debug("SCHED: Allocated PHICHs, cc=%d: [%s]", enb_cc_idx, fmt::to_string(strbuf).c_str());
}
}
@ -250,7 +252,7 @@ bool sched_cell_params_t::set_cfg(uint32_t enb_cc_id
// Basic cell config checks
if (cfg.si_window_ms == 0) {
Error("SCHED: Invalid si-window length 0 ms\n");
Error("SCHED: Invalid si-window length 0 ms");
return false;
}
@ -270,7 +272,7 @@ bool sched_cell_params_t::set_cfg(uint32_t enb_cc_id
((int)cfg.prach_freq_offset < cfg.nrb_pucch);
}
if (invalid_prach) {
Error("Invalid PRACH configuration: frequency offset=%d outside bandwidth limits\n", cfg.prach_freq_offset);
Error("Invalid PRACH configuration: frequency offset=%d outside bandwidth limits", cfg.prach_freq_offset);
srslte::console("Invalid PRACH configuration: frequency offset=%d outside bandwidth limits\n",
cfg.prach_freq_offset);
return false;
@ -281,7 +283,7 @@ bool sched_cell_params_t::set_cfg(uint32_t enb_cc_id
// init regs
regs.reset(new srslte_regs_t{});
if (srslte_regs_init(regs.get(), cfg.cell) != SRSLTE_SUCCESS) {
Error("Getting DCI locations\n");
Error("Getting DCI locations");
return false;
}
@ -290,7 +292,7 @@ bool sched_cell_params_t::set_cfg(uint32_t enb_cc_id
generate_cce_location(regs.get(), &common_locations[cfix], cfix + 1);
}
if (common_locations[sched_cfg->max_nof_ctrl_symbols - 1].nof_loc[2] == 0) {
Error("SCHED: Current cfi=%d is not valid for broadcast (check scheduler.max_nof_ctrl_symbols in conf file).\n",
Error("SCHED: Current cfi=%d is not valid for broadcast (check scheduler.max_nof_ctrl_symbols in conf file).",
sched_cfg->max_nof_ctrl_symbols);
srslte::console(
"SCHED: Current cfi=%d is not valid for broadcast (check scheduler.max_nof_ctrl_symbols in conf file).\n",
@ -309,7 +311,7 @@ bool sched_cell_params_t::set_cfg(uint32_t enb_cc_id
for (uint32_t cfix = 0; cfix < nof_cce_table.size(); ++cfix) {
int ret = srslte_regs_pdcch_ncce(regs.get(), cfix + 1);
if (ret < 0) {
Error("SCHED: Failed to calculate the number of CCEs in the PDCCH\n");
Error("SCHED: Failed to calculate the number of CCEs in the PDCCH");
return false;
}
nof_cce_table[cfix] = (uint32_t)ret;
@ -404,8 +406,6 @@ void generate_cce_location(srslte_regs_t* regs_,
uint32_t
get_aggr_level(uint32_t nof_bits, uint32_t dl_cqi, uint32_t max_aggr_lvl, uint32_t cell_nof_prb, bool use_tbs_index_alt)
{
static srslte::log_ref cached_log = srslte::logmap::get("MAC");
uint32_t l = 0;
float max_coderate = srslte_cqi_to_coderate(dl_cqi, use_tbs_index_alt);
float coderate;
@ -422,7 +422,7 @@ get_aggr_level(uint32_t nof_bits, uint32_t dl_cqi, uint32_t max_aggr_lvl, uint32
l++;
} while (l < l_max && factor * coderate > max_coderate);
cached_log->debug("SCHED: CQI=%d, l=%d, nof_bits=%d, coderate=%.2f, max_coderate=%.2f\n",
Debug("SCHED: CQI=%d, l=%d, nof_bits=%d, coderate=%.2f, max_coderate=%.2f",
dl_cqi,
l,
nof_bits,
@ -451,14 +451,13 @@ int check_ue_cfg_correctness(const sched_interface::ue_cfg_t& ue_cfg)
continue;
}
if (not cc1.dl_cfg.cqi_report.periodic_configured and not cc1.dl_cfg.cqi_report.aperiodic_configured) {
Warning("SCHED: No CQI configuration was provided for UE scell index=%d \n", i);
Warning("SCHED: No CQI configuration was provided for UE scell index=%d", i);
ret = SRSLTE_ERROR;
} else if (cc1.dl_cfg.cqi_report.periodic_configured) {
for (uint32_t j = i + 1; j < cc_list.size(); ++j) {
if (cc_list[j].active and cc_list[j].dl_cfg.cqi_report.periodic_configured and
cc_list[j].dl_cfg.cqi_report.pmi_idx == cc1.dl_cfg.cqi_report.pmi_idx) {
Warning(
"SCHED: The provided CQI configurations for UE scells %d and %d collide in time resources.\n", i, j);
Warning("SCHED: The provided CQI configurations for UE scells %d and %d collide in time resources.", i, j);
ret = SRSLTE_ERROR;
}
}

@ -35,7 +35,7 @@ namespace srsenb {
*
*******************************************************/
sched_ue::sched_ue() : log_h(srslte::logmap::get("MAC")) {}
sched_ue::sched_ue() : logger(srslog::fetch_basic_logger("MAC")) {}
void sched_ue::init(uint16_t rnti_, const std::vector<sched_cell_params_t>& cell_list_params_)
{
@ -44,7 +44,7 @@ void sched_ue::init(uint16_t rnti_, const std::vector<sched_cell_params_t>& cell
for (auto& c : cell_list_params_) {
cells.emplace_back(rnti_, c, current_tti);
}
Info("SCHED: Added user rnti=0x%x\n", rnti);
logger.info("SCHED: Added user rnti=0x%x", rnti);
}
void sched_ue::set_cfg(const ue_cfg_t& cfg_)
@ -55,7 +55,7 @@ void sched_ue::set_cfg(const ue_cfg_t& cfg_)
if (not cfg_.supported_cc_list.empty()) {
primary_cc_idx = cfg_.supported_cc_list[0].enb_cc_idx;
} else {
Warning("Primary cc idx not provided in scheduler ue_cfg. Defaulting to cc_idx=0\n");
logger.warning("Primary cc idx not provided in scheduler ue_cfg. Defaulting to cc_idx=0");
}
// setup primary cc
main_cc_params = cells[primary_cc_idx].cell_cfg;
@ -78,11 +78,11 @@ void sched_ue::set_cfg(const ue_cfg_t& cfg_)
c.is_scell() and (c.cc_state() == cc_st::activating or c.cc_state() == cc_st::deactivating);
}
if (prev_supported_cc_list.empty() or prev_supported_cc_list[0].enb_cc_idx != cfg.supported_cc_list[0].enb_cc_idx) {
log_h->info("SCHED: rnti=0x%x PCell is now enb_cc_idx=%d.\n", rnti, cfg.supported_cc_list[0].enb_cc_idx);
logger.info("SCHED: rnti=0x%x PCell is now enb_cc_idx=%d", rnti, cfg.supported_cc_list[0].enb_cc_idx);
}
if (scell_activation_state_changed) {
lch_handler.pending_ces.emplace_back(srslte::dl_sch_lcid::SCELL_ACTIVATION);
log_h->info("SCHED: Enqueueing SCell Activation CMD for rnti=0x%x\n", rnti);
logger.info("SCHED: Enqueueing SCell Activation CMD for rnti=0x%x", rnti);
}
check_ue_cfg_correctness(cfg);
@ -163,7 +163,7 @@ void sched_ue::mac_buffer_state(uint32_t ce_code, uint32_t nof_cmds)
lch_handler.pending_ces.push_back(cmd);
}
}
Info("SCHED: %s for rnti=0x%x needs to be scheduled\n", to_string(cmd), rnti);
logger.info("SCHED: %s for rnti=0x%x needs to be scheduled", to_string(cmd), rnti);
}
void sched_ue::set_sr()
@ -255,13 +255,13 @@ int sched_ue::set_ack_info(tti_point tti_rx, uint32_t enb_cc_idx, uint32_t tb_id
std::pair<uint32_t, int> p2 = cells[enb_cc_idx].harq_ent.set_ack_info(tti_rx, tb_idx, ack);
tbs_acked = p2.second;
if (tbs_acked > 0) {
Debug(
"SCHED: Set DL ACK=%d for rnti=0x%x, pid=%d, tb=%d, tti=%d\n", ack, rnti, p2.first, tb_idx, tti_rx.to_uint());
logger.debug(
"SCHED: Set DL ACK=%d for rnti=0x%x, pid=%d, tb=%d, tti=%d", ack, rnti, p2.first, tb_idx, tti_rx.to_uint());
} else {
Warning("SCHED: Received ACK info for unknown TTI=%d\n", tti_rx.to_uint());
logger.warning("SCHED: Received ACK info for unknown TTI=%d", tti_rx.to_uint());
}
} else {
log_h->warning("Received DL ACK for invalid cell index %d\n", enb_cc_idx);
logger.warning("Received DL ACK for invalid cell index %d", enb_cc_idx);
}
return tbs_acked;
}
@ -271,10 +271,10 @@ void sched_ue::set_ul_crc(tti_point tti_rx, uint32_t enb_cc_idx, bool crc_res)
if (cells[enb_cc_idx].cc_state() != cc_st::idle) {
int ret = cells[enb_cc_idx].harq_ent.set_ul_crc(tti_rx, 0, crc_res);
if (ret < 0) {
log_h->warning("Received UL CRC for invalid tti_rx=%d\n", (int)tti_rx.to_uint());
logger.warning("Received UL CRC for invalid tti_rx=%d", (int)tti_rx.to_uint());
}
} else {
log_h->warning("Received UL CRC for invalid cell index %d\n", enb_cc_idx);
logger.warning("Received UL CRC for invalid cell index %d", enb_cc_idx);
}
}
@ -284,7 +284,7 @@ void sched_ue::set_dl_ri(tti_point tti_rx, uint32_t enb_cc_idx, uint32_t ri)
cells[enb_cc_idx].dl_ri = ri;
cells[enb_cc_idx].dl_ri_tti_rx = tti_rx;
} else {
log_h->warning("Received DL RI for invalid cell index %d\n", enb_cc_idx);
logger.warning("Received DL RI for invalid cell index %d", enb_cc_idx);
}
}
@ -294,7 +294,7 @@ void sched_ue::set_dl_pmi(tti_point tti_rx, uint32_t enb_cc_idx, uint32_t pmi)
cells[enb_cc_idx].dl_pmi = pmi;
cells[enb_cc_idx].dl_pmi_tti_rx = tti_rx;
} else {
log_h->warning("Received DL PMI for invalid cell index %d\n", enb_cc_idx);
logger.warning("Received DL PMI for invalid cell index %d", enb_cc_idx);
}
}
@ -303,7 +303,7 @@ void sched_ue::set_dl_cqi(tti_point tti_rx, uint32_t enb_cc_idx, uint32_t cqi)
if (cells[enb_cc_idx].cc_state() != cc_st::idle) {
cells[enb_cc_idx].set_dl_cqi(tti_rx, cqi);
} else {
log_h->warning("Received DL CQI for invalid enb cell index %d\n", enb_cc_idx);
logger.warning("Received DL CQI for invalid enb cell index %d", enb_cc_idx);
}
}
@ -314,7 +314,7 @@ void sched_ue::set_ul_snr(tti_point tti_rx, uint32_t enb_cc_idx, float snr, uint
cells[enb_cc_idx].ul_cqi = srslte_cqi_from_snr(snr);
cells[enb_cc_idx].ul_cqi_tti_rx = tti_rx;
} else {
log_h->warning("Received SNR info for invalid cell index %d\n", enb_cc_idx);
logger.warning("Received SNR info for invalid cell index %d", enb_cc_idx);
}
}
@ -356,13 +356,13 @@ tbs_info sched_ue::allocate_new_dl_mac_pdu(sched::dl_sched_data_t* data,
// emptied by another allocated tb_idx.
uint32_t pending_bytes = lch_handler.get_dl_tx_total();
if (pending_bytes > 0) {
Warning("SCHED: Failed to allocate DL TB with tb_idx=%d, tbs=%d, pid=%d. Pending DL buffer data=%d\n",
logger.warning("SCHED: Failed to allocate DL TB with tb_idx=%d, tbs=%d, pid=%d. Pending DL buffer data=%d",
tb,
rem_tbs,
h->get_id(),
pending_bytes);
} else {
Info("SCHED: DL TB tb_idx=%d, tbs=%d, pid=%d did not get allocated.\n", tb, rem_tbs, h->get_id());
logger.info("SCHED: DL TB tb_idx=%d, tbs=%d, pid=%d did not get allocated.", tb, rem_tbs, h->get_id());
}
tb_info.tbs_bytes = 0;
tb_info.mcs = 0;
@ -392,7 +392,7 @@ int sched_ue::generate_dl_dci_format(uint32_t pid,
tbs = generate_format2a(pid, data, tti_tx_dl, enb_cc_idx, cfi, user_mask);
break;
default:
Error("DCI format (%d) not implemented\n", dci_format);
logger.error("DCI format (%d) not implemented", dci_format);
}
return tbs;
}
@ -422,7 +422,7 @@ int sched_ue::generate_format1(uint32_t pid,
dci->format = SRSLTE_DCI_FORMAT1A;
if (L_crb != count_prb_per_tb(user_mask)) {
// This happens if Type0 was using distributed allocation
Warning("SCHED: Can't use distributed RA due to DCI size ambiguity\n");
logger.warning("SCHED: Can't use distributed RA due to DCI size ambiguity");
}
} else {
dci->alloc_type = SRSLTE_RA_ALLOC_TYPE0;
@ -435,7 +435,7 @@ int sched_ue::generate_format1(uint32_t pid,
tbinfo = allocate_new_dl_mac_pdu(data, h, user_mask, tti_tx_dl, enb_cc_idx, cfi, 0);
} else {
h->new_retx(user_mask, 0, tti_tx_dl, &tbinfo.mcs, &tbinfo.tbs_bytes, data->dci.location.ncce);
Debug("SCHED: Alloc format1 previous mcs=%d, tbs=%d\n", tbinfo.mcs, tbinfo.tbs_bytes);
logger.debug("SCHED: Alloc format1 previous mcs=%d, tbs=%d", tbinfo.mcs, tbinfo.tbs_bytes);
}
if (tbinfo.tbs_bytes > 0) {
@ -478,7 +478,7 @@ tbs_info sched_ue::compute_mcs_and_tbs(uint32_t enb_cc_idx,
tbs_info tb = alloc_tbs_dl(cells[enb_cc_idx], nof_alloc_prbs, nof_re, req_bytes.stop());
if (tb.tbs_bytes > 0 and tb.tbs_bytes < (int)req_bytes.start()) {
log_h->info("SCHED: Could not get PRB allocation that avoids MAC CE or RLC SRB0 PDU segmentation\n");
logger.info("SCHED: Could not get PRB allocation that avoids MAC CE or RLC SRB0 PDU segmentation");
// Note: This is not a warning, because the srb0 buffer can be updated after the ue sched decision
}
@ -689,9 +689,9 @@ int sched_ue::generate_format0(sched_interface::ul_sched_data_t* data,
dci->tb.mcs_idx = tbinfo.mcs;
}
} else if (tbinfo.tbs_bytes == 0) {
log_h->warning("SCHED: No space for ULSCH while allocating format0. Discarding grant.\n");
logger.warning("SCHED: No space for ULSCH while allocating format0. Discarding grant.");
} else {
log_h->error("SCHED: Unkown error while allocating format0\n");
logger.error("SCHED: Unkown error while allocating format0");
}
}
@ -722,7 +722,7 @@ bool sched_ue::needs_cqi(uint32_t tti, uint32_t enb_cc_idx, bool will_send)
if (will_send) {
cqi_request_tti = tti;
}
Debug("SCHED: Needs_cqi, last_sent=%d, will_be_sent=%d\n", cqi_request_tti, will_send);
logger.debug("SCHED: Needs_cqi, last_sent=%d, will_be_sent=%d", cqi_request_tti, will_send);
ret = true;
}
}
@ -746,8 +746,8 @@ rbg_interval sched_ue::get_required_dl_rbgs(uint32_t enb_cc_idx)
int pending_prbs = get_required_prb_dl(cells[enb_cc_idx], to_tx_dl(current_tti), req_bytes.start());
if (pending_prbs < 0) {
// Cannot fit allocation in given PRBs
log_h->error("SCHED: DL CQI=%d does now allow fitting %d non-segmentable DL tx bytes into the cell bandwidth. "
"Consider increasing initial CQI value.\n",
logger.error("SCHED: DL CQI=%d does now allow fitting %d non-segmentable DL tx bytes into the cell bandwidth. "
"Consider increasing initial CQI value.",
cells[enb_cc_idx].dl_cqi,
req_bytes.start());
return {cellparams->nof_prb(), cellparams->nof_prb()};
@ -782,7 +782,7 @@ srslte::interval<uint32_t> sched_ue::get_requested_dl_bytes(uint32_t enb_cc_idx)
// Ensure there is space for ConRes and RRC Setup
// SRB0 is a special case due to being RLC TM (no segmentation possible)
if (not lch_handler.is_bearer_dl(0)) {
log_h->error("SRB0 must always be activated for DL\n");
logger.error("SRB0 must always be activated for DL");
return {};
}
if (cells[enb_cc_idx].cc_state() != cc_st::active) {
@ -936,7 +936,7 @@ uint32_t sched_ue::get_pending_ul_new_data(tti_point tti_tx_ul, int this_enb_cc_
pending_data = (pending_data > pending_ul_data) ? pending_data - pending_ul_data : 0;
if (pending_data > 0) {
Debug("SCHED: pending_data=%d, in_harq_data=%d, bsr=%s\n",
logger.debug("SCHED: pending_data=%d, in_harq_data=%d, bsr=%s",
pending_data,
pending_ul_data,
lch_handler.get_bsr_text().c_str());
@ -1026,7 +1026,8 @@ srslte_dci_format_t sched_ue::get_dci_format()
case sched_interface::ant_info_ded_t::tx_mode_t::tm7:
case sched_interface::ant_info_ded_t::tx_mode_t::tm8_v920:
default:
Warning("Incorrect transmission mode (rnti=%04x; tm=%d)\n", rnti, static_cast<int>(cfg.dl_ant_info.tx_mode));
logger.warning(
"Incorrect transmission mode (rnti=%04x; tm=%d)", rnti, static_cast<int>(cfg.dl_ant_info.tx_mode));
}
}
@ -1038,7 +1039,7 @@ const sched_dci_cce_t* sched_ue::get_locations(uint32_t enb_cc_idx, uint32_t cfi
if (cfi > 0 && cfi <= 3) {
return &cells[enb_cc_idx].dci_locations[cfi - 1][sf_idx];
} else {
Error("SCHED: Invalid CFI=%d\n", cfi);
logger.error("SCHED: Invalid CFI=%d", cfi);
return &cells[enb_cc_idx].dci_locations[0][sf_idx];
}
}

@ -30,7 +30,6 @@ namespace srsenb {
void harq_proc::init(uint32_t id_)
{
log_h = srslte::logmap::get("MAC ");
id = id_;
}
@ -78,13 +77,15 @@ tti_point harq_proc::get_tti() const
int harq_proc::set_ack_common(uint32_t tb_idx, bool ack_)
{
if (is_empty(tb_idx)) {
log_h->warning("Received ACK for inactive harq\n");
srslog::fetch_basic_logger("MAC").warning("Received ACK for inactive harq");
return SRSLTE_ERROR;
}
ack_state[tb_idx] = ack_;
log_h->debug("ACK=%d received pid=%d, tb_idx=%d, n_rtx=%d, max_retx=%d\n", ack_, id, tb_idx, n_rtx[tb_idx], max_retx);
srslog::fetch_basic_logger("MAC").debug(
"ACK=%d received pid=%d, tb_idx=%d, n_rtx=%d, max_retx=%d", ack_, id, tb_idx, n_rtx[tb_idx], max_retx);
if (!ack_ && (n_rtx[tb_idx] + 1 >= max_retx)) {
Info("SCHED: discarding TB=%d pid=%d, tti=%d, maximum number of retx exceeded (%d)\n",
srslog::fetch_basic_logger("MAC").info(
"SCHED: discarding TB=%d pid=%d, tti=%d, maximum number of retx exceeded (%d)",
tb_idx,
id,
tti.to_uint(),
@ -294,8 +295,7 @@ uint32_t ul_harq_proc::get_pending_data() const
* Harq Entity
*******************/
harq_entity::harq_entity(size_t nof_dl_harqs, size_t nof_ul_harqs) :
dl_harqs(nof_dl_harqs), ul_harqs(nof_ul_harqs), log_h(srslte::logmap::get("MAC "))
harq_entity::harq_entity(size_t nof_dl_harqs, size_t nof_ul_harqs) : dl_harqs(nof_dl_harqs), ul_harqs(nof_ul_harqs)
{
for (uint32_t i = 0; i < dl_harqs.size(); ++i) {
dl_harqs[i].init(i);

@ -76,11 +76,11 @@ void lch_ue_manager::new_tti()
void lch_ue_manager::config_lcid(uint32_t lc_id, const sched_interface::ue_bearer_cfg_t& bearer_cfg)
{
if (lc_id >= sched_interface::MAX_LC) {
Warning("Adding bearer with invalid logical channel id=%d\n", lc_id);
logger.warning("Adding bearer with invalid logical channel id=%d", lc_id);
return;
}
if (bearer_cfg.group >= sched_interface::MAX_LC_GROUP) {
Warning("Adding bearer with invalid logical channel group id=%d\n", bearer_cfg.group);
logger.warning("Adding bearer with invalid logical channel group id=%d", bearer_cfg.group);
return;
}
@ -96,7 +96,7 @@ void lch_ue_manager::config_lcid(uint32_t lc_id, const sched_interface::ue_beare
lch[lc_id].bucket_size = lch[lc_id].cfg.bsd * lch[lc_id].cfg.pbr;
lch[lc_id].Bj = 0;
}
Info("SCHED: bearer configured: lc_id=%d, mode=%s, prio=%d\n",
logger.info("SCHED: bearer configured: lc_id=%d, mode=%s, prio=%d",
lc_id,
to_string(lch[lc_id].cfg.direction),
lch[lc_id].cfg.priority);
@ -106,32 +106,32 @@ void lch_ue_manager::config_lcid(uint32_t lc_id, const sched_interface::ue_beare
void lch_ue_manager::ul_bsr(uint8_t lcg_id, uint32_t bsr)
{
if (lcg_id >= sched_interface::MAX_LC_GROUP) {
Warning("The provided logical channel group id=%d is not valid\n", lcg_id);
logger.warning("The provided logical channel group id=%d is not valid", lcg_id);
return;
}
lcg_bsr[lcg_id] = bsr;
Debug("SCHED: bsr=%d, lcg_id=%d, bsr=%s\n", bsr, lcg_id, get_bsr_text().c_str());
logger.debug("SCHED: bsr=%d, lcg_id=%d, bsr=%s", bsr, lcg_id, get_bsr_text().c_str());
}
void lch_ue_manager::ul_buffer_add(uint8_t lcid, uint32_t bytes)
{
if (lcid >= sched_interface::MAX_LC) {
Warning("The provided lcid=%d is not valid\n", lcid);
logger.warning("The provided lcid=%d is not valid", lcid);
return;
}
lcg_bsr[lch[lcid].cfg.group] += bytes;
Debug("SCHED: UL buffer update=%d, lcg_id=%d, bsr=%s\n", bytes, lch[lcid].cfg.group, get_bsr_text().c_str());
logger.debug("SCHED: UL buffer update=%d, lcg_id=%d, bsr=%s", bytes, lch[lcid].cfg.group, get_bsr_text().c_str());
}
void lch_ue_manager::dl_buffer_state(uint8_t lcid, uint32_t tx_queue, uint32_t retx_queue)
{
if (lcid >= sched_interface::MAX_LC) {
Warning("The provided lcid=%d is not valid\n", lcid);
logger.warning("The provided lcid=%d is not valid", lcid);
return;
}
lch[lcid].buf_retx = retx_queue;
lch[lcid].buf_tx = tx_queue;
Debug("SCHED: DL lcid=%d buffer_state=%d,%d\n", lcid, tx_queue, retx_queue);
logger.debug("SCHED: DL lcid=%d buffer_state=%d,%d", lcid, tx_queue, retx_queue);
}
int lch_ue_manager::get_max_prio_lcid() const

@ -21,6 +21,7 @@ namespace srsenb {
*******************************************************/
sched_ue_cell::sched_ue_cell(uint16_t rnti_, const sched_cell_params_t& cell_cfg_, tti_point current_tti_) :
logger(srslog::fetch_basic_logger("MAC")),
rnti(rnti_),
cell_cfg(&cell_cfg_),
dci_locations(generate_cce_location_table(rnti_, cell_cfg_)),
@ -77,7 +78,7 @@ void sched_ue_cell::set_ue_cfg(const sched_interface::ue_cfg_t& ue_cfg_)
case cc_st::active:
if (ue_cc_idx < 0 or not ue_cfg->supported_cc_list[ue_cc_idx].active) {
cc_state_ = cc_st::deactivating;
log_h->info("SCHED: Deactivating rnti=0x%x, SCellIndex=%d...\n", rnti, ue_cc_idx);
logger.info("SCHED: Deactivating rnti=0x%x, SCellIndex=%d...", rnti, ue_cc_idx);
}
break;
case cc_st::deactivating:
@ -85,7 +86,7 @@ void sched_ue_cell::set_ue_cfg(const sched_interface::ue_cfg_t& ue_cfg_)
if (ue_cc_idx > 0 and ue_cfg->supported_cc_list[ue_cc_idx].active) {
cc_state_ = cc_st::activating;
dl_cqi = 0;
log_h->info("SCHED: Activating rnti=0x%x, SCellIndex=%d...\n", rnti, ue_cc_idx);
logger.info("SCHED: Activating rnti=0x%x, SCellIndex=%d...", rnti, ue_cc_idx);
}
break;
default:
@ -136,7 +137,7 @@ void sched_ue_cell::set_dl_cqi(tti_point tti_rx, uint32_t dl_cqi_)
if (ue_cc_idx > 0 and cc_state_ == cc_st::activating and dl_cqi_rx) {
// Wait for SCell to receive a positive CQI before activating it
cc_state_ = cc_st::active;
log_h->info("SCHED: SCell index=%d is now active\n", ue_cc_idx);
logger.info("SCHED: SCell index=%d is now active", ue_cc_idx);
}
}
@ -165,7 +166,7 @@ std::tuple<int, YType, int, YType>
false_position_method(int x1, int x2, YType y0, const Callable& f, const ErrorDetect& is_error)
{
static_assert(std::is_same<YType, decltype(f(x1))>::value,
"The type of the final result and callable return do not match\n");
"The type of the final result and callable return do not match");
YType y1 = f(x1);
if (is_error(y1) or y1 >= y0) {
return std::make_tuple(x1, y1, x1, y1);

@ -95,7 +95,7 @@ uint32_t sched_time_pf::try_dl_alloc(ue_ctxt& ue_ctxt, sched_ue& ue, sf_sched* t
}
}
if (code == alloc_outcome_t::DCI_COLLISION) {
log_h->info("SCHED: Couldn't find space in PDCCH for DL tx for rnti=0x%x\n", ue.get_rnti());
logger.info("SCHED: Couldn't find space in PDCCH for DL tx for rnti=0x%x", ue.get_rnti());
}
return 0;
}
@ -152,7 +152,7 @@ uint32_t sched_time_pf::try_ul_alloc(ue_ctxt& ue_ctxt, sched_ue& ue, sf_sched* t
: 0;
}
if (code == alloc_outcome_t::DCI_COLLISION) {
log_h->info("SCHED: Couldn't find space in PDCCH for UL retx of rnti=0x%x\n", ue.get_rnti());
logger.info("SCHED: Couldn't find space in PDCCH for UL retx of rnti=0x%x", ue.get_rnti());
}
return estim_tbs_bytes;
}

@ -52,7 +52,7 @@ void sched_time_rr::sched_dl_retxs(std::map<uint16_t, sched_ue>& ue_db, sf_sched
}
alloc_outcome_t code = try_dl_retx_alloc(*tti_sched, user, *h);
if (code == alloc_outcome_t::DCI_COLLISION) {
log_h->info("SCHED: Couldn't find space in PDCCH for DL retx for rnti=0x%x\n", user.get_rnti());
logger.info("SCHED: Couldn't find space in PDCCH for DL retx for rnti=0x%x", user.get_rnti());
}
}
}
@ -81,7 +81,7 @@ void sched_time_rr::sched_dl_newtxs(std::map<uint16_t, sched_ue>& ue_db, sf_sche
// empty RBGs were found
alloc_outcome_t code = tti_sched->alloc_dl_user(&user, newtx_mask, h->get_id());
if (code == alloc_outcome_t::DCI_COLLISION) {
log_h->info("SCHED: Couldn't find space in PDCCH for DL tx for rnti=0x%x\n", user.get_rnti());
logger.info("SCHED: Couldn't find space in PDCCH for DL tx for rnti=0x%x", user.get_rnti());
}
}
}
@ -118,7 +118,7 @@ void sched_time_rr::sched_ul_retxs(std::map<uint16_t, sched_ue>& ue_db, sf_sched
}
alloc_outcome_t code = try_ul_retx_alloc(*tti_sched, user, *h);
if (code == alloc_outcome_t::DCI_COLLISION) {
log_h->info("SCHED: Couldn't find space in PDCCH for UL retx of rnti=0x%x\n", user.get_rnti());
logger.info("SCHED: Couldn't find space in PDCCH for UL retx of rnti=0x%x", user.get_rnti());
}
}
}
@ -149,7 +149,7 @@ void sched_time_rr::sched_ul_newtxs(std::map<uint16_t, sched_ue>& ue_db, sf_sche
}
alloc_outcome_t ret = tti_sched->alloc_ul_user(&user, alloc);
if (ret == alloc_outcome_t::DCI_COLLISION) {
log_h->info("SCHED: Couldn't find space in PDCCH for UL tx of rnti=0x%x\n", user.get_rnti());
logger.info("SCHED: Couldn't find space in PDCCH for UL tx of rnti=0x%x", user.get_rnti());
}
}
}

@ -28,6 +28,7 @@ ue::ue(uint16_t rnti_,
rlc_interface_mac* rlc_,
phy_interface_stack_lte* phy_,
srslte::log_ref log_,
srslog::basic_logger& logger,
uint32_t nof_cells_,
uint32_t nof_rx_harq_proc_,
uint32_t nof_tx_harq_proc_) :
@ -38,6 +39,7 @@ ue::ue(uint16_t rnti_,
rlc(rlc_),
phy(phy_),
log_h(log_),
logger(logger),
mac_msg_dl(20, log_),
mch_mac_msg_dl(10, log_),
mac_msg_ul(20, log_),
@ -143,12 +145,12 @@ void ue::start_pcap(srslte::mac_pcap* pcap_)
srslte_softbuffer_rx_t* ue::get_rx_softbuffer(const uint32_t ue_cc_idx, const uint32_t tti)
{
if ((size_t)ue_cc_idx >= softbuffer_rx.size()) {
ERROR("UE CC Index (%d/%zd) out-of-range\n", ue_cc_idx, softbuffer_rx.size());
ERROR("UE CC Index (%d/%zd) out-of-range", ue_cc_idx, softbuffer_rx.size());
return nullptr;
}
if ((size_t)nof_rx_harq_proc > softbuffer_rx.at(ue_cc_idx).size()) {
ERROR("HARQ process index (%d/%zd) out-of-range\n", nof_rx_harq_proc, softbuffer_rx.at(ue_cc_idx).size());
ERROR("HARQ process index (%d/%zd) out-of-range", nof_rx_harq_proc, softbuffer_rx.at(ue_cc_idx).size());
return nullptr;
}
@ -159,12 +161,12 @@ srslte_softbuffer_tx_t*
ue::get_tx_softbuffer(const uint32_t ue_cc_idx, const uint32_t harq_process, const uint32_t tb_idx)
{
if ((size_t)ue_cc_idx >= softbuffer_tx.size()) {
ERROR("UE CC Index (%d/%zd) out-of-range\n", ue_cc_idx, softbuffer_tx.size());
ERROR("UE CC Index (%d/%zd) out-of-range", ue_cc_idx, softbuffer_tx.size());
return nullptr;
}
if ((size_t)nof_tx_harq_proc > softbuffer_tx.at(ue_cc_idx).size()) {
ERROR("HARQ process index (%d/%zd) out-of-range\n", harq_process, softbuffer_tx.at(ue_cc_idx).size());
ERROR("HARQ process index (%d/%zd) out-of-range", harq_process, softbuffer_tx.at(ue_cc_idx).size());
return nullptr;
}
@ -182,13 +184,13 @@ uint8_t* ue::request_buffer(uint32_t tti, uint32_t ue_cc_idx, const uint32_t len
if (pdu) {
rx_used_buffers.at(ue_cc_idx).emplace(tti, pdu);
} else {
Error("UE buffers: Requesting buffer from pool\n");
logger.error("UE buffers: Requesting buffer from pool");
}
} else {
Error("UE buffers: buffer for tti=%d already allocated\n", tti);
logger.error("UE buffers: buffer for tti=%d already allocated", tti);
}
} else {
Error("UE buffers: Requesting buffer for zero bytes\n");
logger.error("UE buffers: Requesting buffer for zero bytes");
}
return pdu;
}
@ -201,7 +203,7 @@ void ue::clear_old_buffers(uint32_t tti)
for (auto& rx_buffer_cc : rx_used_buffers) {
for (auto it = rx_buffer_cc.begin(); it != rx_buffer_cc.end();) {
if (srslte_tti_interval(tti, it->first) > 20 && srslte_tti_interval(tti, it->first) < 500) {
Warning("UE buffers: Removing old buffer tti=%d, rnti=%d, now is %d, interval=%d\n",
logger.warning("UE buffers: Removing old buffer tti=%d, rnti=%d, now is %d, interval=%d",
it->first,
rnti,
tti,
@ -236,7 +238,7 @@ uint32_t ue::set_ta(int ta_)
uint32_t ta_cmd = (uint32_t)(ta_value + 31);
pending_ta_commands.try_push(ta_cmd);
nof_cmd++;
Info("Added TA CMD: rnti=0x%x, ta=%d, ta_value=%d, ta_cmd=%d\n", rnti, ta_, ta_value, ta_cmd);
logger.info("Added TA CMD: rnti=0x%x, ta=%d, ta_value=%d, ta_cmd=%d", rnti, ta_, ta_value, ta_cmd);
} while (ta_value <= -31 || ta_value >= 32);
return nof_cmd;
}
@ -249,7 +251,7 @@ void ue::process_pdu(uint8_t* pdu, uint32_t nof_bytes, srslte::pdu_queue::channe
mac_msg_ul.init_rx(nof_bytes, true);
mac_msg_ul.parse_packet(pdu);
Info("0x%x %s\n", rnti, mac_msg_ul.to_string().c_str());
logger.info("0x%x %s", rnti, mac_msg_ul.to_string().c_str());
if (pcap) {
pcap->write_ul_crnti(pdu, nof_bytes, rnti, true, last_tti, UL_CC_IDX);
@ -275,7 +277,7 @@ void ue::process_pdu(uint8_t* pdu, uint32_t nof_bytes, srslte::pdu_queue::channe
}
if (sum == 0) {
route_pdu = false;
Debug("Received all zero PDU\n");
logger.debug("Received all zero PDU");
}
}
@ -292,7 +294,7 @@ void ue::process_pdu(uint8_t* pdu, uint32_t nof_bytes, srslte::pdu_queue::channe
// Indicate RRC about successful activity if valid RLC message is received
if (mac_msg_ul.get()->get_payload_size() > 64) { // do not count RLC status messages only
rrc->set_activity_user(rnti);
log_h->debug("UL activity rnti=0x%x, n_bytes=%d\n", rnti, nof_bytes);
logger.debug("UL activity rnti=0x%x, n_bytes=%d", rnti, nof_bytes);
}
if ((int)mac_msg_ul.get()->get_payload_size() > most_data) {
@ -310,7 +312,7 @@ void ue::process_pdu(uint8_t* pdu, uint32_t nof_bytes, srslte::pdu_queue::channe
ue_cri_ptr[nbytes - i - 1] = pkt_ptr[i];
}
} else {
Error("Received CCCH UL message of invalid size=%d bytes\n", mac_msg_ul.get()->get_payload_size());
logger.error("Received CCCH UL message of invalid size=%d bytes", mac_msg_ul.get()->get_payload_size());
}
}
}
@ -331,10 +333,10 @@ void ue::process_pdu(uint8_t* pdu, uint32_t nof_bytes, srslte::pdu_queue::channe
if (!bsr_received && lcid_most_data > 2) {
// Add BSR to the LCID for which most data was received
sched->ul_buffer_add(rnti, lcid_most_data, 256);
Debug("BSR not received. Giving extra dci\n");
logger.debug("BSR not received. Giving extra dci");
}
Debug("MAC PDU processed\n");
logger.debug("MAC PDU processed");
}
void ue::deallocate_pdu(uint32_t tti, uint32_t ue_cc_idx)
@ -345,7 +347,7 @@ void ue::deallocate_pdu(uint32_t tti, uint32_t ue_cc_idx)
pdus.deallocate(rx_used_buffers.at(ue_cc_idx).at(tti));
rx_used_buffers.at(ue_cc_idx).erase(tti);
} else {
Warning("UE buffers: Null RX PDU pointer in deallocate_pdu for rnti=0x%x pid=%d cc_idx=%d\n",
logger.warning("UE buffers: Null RX PDU pointer in deallocate_pdu for rnti=0x%x pid=%d cc_idx=%d",
rnti,
tti % nof_rx_harq_proc,
ue_cc_idx);
@ -359,11 +361,11 @@ void ue::push_pdu(uint32_t tti, uint32_t ue_cc_idx, uint32_t len)
if (len > 0) {
pdus.push(rx_used_buffers.at(ue_cc_idx).at(tti), len);
} else {
Error("Error pushing PDU: null length\n");
logger.error("Error pushing PDU: null length");
}
rx_used_buffers.at(ue_cc_idx).erase(tti);
} else {
Warning("UE buffers: Null RX PDU pointer in push_pdu for rnti=0x%x pid=%d cc_idx=%d\n",
logger.warning("UE buffers: Null RX PDU pointer in push_pdu for rnti=0x%x pid=%d cc_idx=%d",
rnti,
tti % nof_rx_harq_proc,
ue_cc_idx);
@ -390,14 +392,14 @@ bool ue::process_ce(srslte::sch_subh* subh)
rrc->upd_user(rnti, old_rnti);
rnti = old_rnti;
} else {
Error("Updating user C-RNTI: rnti=0x%x already released\n", old_rnti);
logger.error("Updating user C-RNTI: rnti=0x%x already released", old_rnti);
}
break;
case srslte::ul_sch_lcid::TRUNC_BSR:
case srslte::ul_sch_lcid::SHORT_BSR:
idx = subh->get_bsr(buff_size_idx, buff_size_bytes);
if (idx == -1) {
Error("Invalid Index Passed to lc groups\n");
logger.error("Invalid Index Passed to lc groups");
break;
}
// Indicate BSR to scheduler
@ -414,7 +416,7 @@ bool ue::process_ce(srslte::sch_subh* subh)
case srslte::ul_sch_lcid::PADDING:
break;
default:
Error("CE: Invalid lcid=0x%x\n", (int)subh->ul_sch_ce_type());
logger.error("CE: Invalid lcid=0x%x", (int)subh->ul_sch_ce_type());
break;
}
return is_bsr;
@ -434,13 +436,13 @@ void ue::allocate_sdu(srslte::sch_pdu* pdu, uint32_t lcid, uint32_t total_sdu_le
int n = 1;
while (sdu_len >= min_sdu_len && n > 0) { // minimum size is a single RLC AM status PDU (2 Byte)
if (pdu->new_subh()) { // there is space for a new subheader
log_h->debug("SDU: set_sdu(), lcid=%d, sdu_len=%d, sdu_space=%d\n", lcid, sdu_len, sdu_space);
logger.debug("SDU: set_sdu(), lcid=%d, sdu_len=%d, sdu_space=%d", lcid, sdu_len, sdu_space);
n = pdu->get()->set_sdu(lcid, sdu_len, this);
if (n > 0) { // new SDU could be added
sdu_len -= n;
log_h->debug("SDU: rnti=0x%x, lcid=%d, nbytes=%d, rem_len=%d\n", rnti, lcid, n, sdu_len);
logger.debug("SDU: rnti=0x%x, lcid=%d, nbytes=%d, rem_len=%d", rnti, lcid, n, sdu_len);
} else {
Debug("Could not add SDU lcid=%d nbytes=%d, space=%d\n", lcid, sdu_len, sdu_space);
logger.debug("Could not add SDU lcid=%d nbytes=%d, space=%d", lcid, sdu_len, sdu_space);
pdu->del_subh();
}
} else {
@ -458,19 +460,19 @@ void ue::allocate_ce(srslte::sch_pdu* pdu, uint32_t lcid)
uint32_t ta_cmd = 31;
pending_ta_commands.try_pop(&ta_cmd);
if (!pdu->get()->set_ta_cmd(ta_cmd)) {
Error("CE: Setting TA CMD CE\n");
logger.error("CE: Setting TA CMD CE");
}
} else {
Error("CE: Setting TA CMD CE. No space for a subheader\n");
logger.error("CE: Setting TA CMD CE. No space for a subheader");
}
break;
case srslte::dl_sch_lcid::CON_RES_ID:
if (pdu->new_subh()) {
if (!pdu->get()->set_con_res_id(conres_id)) {
Error("CE: Setting Contention Resolution ID CE\n");
logger.error("CE: Setting Contention Resolution ID CE");
}
} else {
Error("CE: Setting Contention Resolution ID CE. No space for a subheader\n");
logger.error("CE: Setting Contention Resolution ID CE. No space for a subheader");
}
break;
case srslte::dl_sch_lcid::SCELL_ACTIVATION:
@ -481,14 +483,14 @@ void ue::allocate_ce(srslte::sch_pdu* pdu, uint32_t lcid)
// Allocate and initialize Rx/Tx softbuffers for new carriers (exclude PCell)
allocate_cc_buffers(active_scell_list.size() - 1);
} else {
Error("CE: Setting SCell Activation CE\n");
logger.error("CE: Setting SCell Activation CE");
}
} else {
Error("CE: Setting SCell Activation CE. No space for a subheader\n");
logger.error("CE: Setting SCell Activation CE. No space for a subheader");
}
break;
default:
Error("CE: Allocating CE=0x%x. Not supported\n", lcid);
logger.error("CE: Allocating CE=0x%x. Not supported", lcid);
break;
}
}
@ -514,10 +516,10 @@ uint8_t* ue::generate_pdu(uint32_t ue_cc_idx,
}
}
ret = mac_msg_dl.write_packet(log_h);
Info("0x%x %s\n", rnti, mac_msg_dl.to_string().c_str());
logger.info("0x%x %s", rnti, mac_msg_dl.to_string().c_str());
} else {
log_h->error(
"Invalid parameters calling generate_pdu: cc_idx=%d, harq_pid=%d, tb_idx=%d\n", ue_cc_idx, harq_pid, tb_idx);
logger.error(
"Invalid parameters calling generate_pdu: cc_idx=%d, harq_pid=%d, tb_idx=%d", ue_cc_idx, harq_pid, tb_idx);
}
} else {
std::cout << "Error ue not configured (must call config() first" << std::endl;

@ -82,7 +82,7 @@ mac_controller::mac_controller(uint16_t rnti_,
mac_interface_rrc* mac_,
const enb_cell_common_list& cell_common_list_,
const ue_cfg_t& sched_ue_cfg) :
log_h("RRC"),
logger(srslog::fetch_basic_logger("RRC")),
rnti(rnti_),
ue_cell_list(ue_cell_list_),
bearer_list(bearer_list_),
@ -92,7 +92,7 @@ mac_controller::mac_controller(uint16_t rnti_,
current_sched_ue_cfg(sched_ue_cfg)
{
if (current_sched_ue_cfg.supported_cc_list.empty() or not current_sched_ue_cfg.supported_cc_list[0].active) {
log_h->warning("No PCell set. Picking enb_cc_idx=0 as PCell\n");
logger.warning("No PCell set. Picking enb_cc_idx=0 as PCell");
current_sched_ue_cfg.supported_cc_list.resize(1);
current_sched_ue_cfg.supported_cc_list[0].active = true;
current_sched_ue_cfg.supported_cc_list[0].enb_cc_idx = 0;
@ -351,7 +351,7 @@ void ue_cfg_apply_phy_cfg_ded(ue_cfg_t& ue_cfg, const asn1::rrc::phys_cfg_ded_s&
if (phy_cfg.ant_info.type().value == phys_cfg_ded_s::ant_info_c_::types_opts::explicit_value) {
ue_cfg.dl_ant_info = srslte::make_ant_info_ded(phy_cfg.ant_info.explicit_value());
} else {
srslte::logmap::get("RRC")->warning("No antenna configuration provided\n");
srslog::fetch_basic_logger("RRC").warning("No antenna configuration provided");
pcell_cfg.dl_cfg.tm = SRSLTE_TM1;
ue_cfg.dl_ant_info.tx_mode = sched_interface::ant_info_ded_t::tx_mode_t::tm1;
}
@ -370,7 +370,7 @@ void ue_cfg_apply_srb_updates(ue_cfg_t& ue_cfg, const srb_to_add_mod_list_l& srb
bcfg = get_bearer_default_srb2_config();
break;
default:
srslte::logmap::get("RRC")->warning("Invalid SRB ID %d\n", (int)srb.srb_id);
srslog::fetch_basic_logger("RRC").warning("Invalid SRB ID %d", (int)srb.srb_id);
bcfg = {};
}
bcfg.direction = srsenb::sched_interface::ue_bearer_cfg_t::BOTH;
@ -450,7 +450,7 @@ void ue_cfg_apply_reconf_complete_updates(ue_cfg_t& ue_cfg,
ul_cfg.cqi_report_cfg_scell_r10.cqi_report_mode_aperiodic_r10_present;
mac_scell.aperiodic_cqi_period = ul_cfg.cqi_report_cfg_scell_r10.cqi_report_mode_aperiodic_r10.to_number();
} else {
srslte::logmap::get("RRC")->warning("Invalid Scell index %d CQI configuration\n", scell.scell_idx_r10);
srslog::fetch_basic_logger("RRC").warning("Invalid Scell index %d CQI configuration", scell.scell_idx_r10);
}
}
}
@ -476,7 +476,7 @@ void ue_cfg_apply_meas_cfg(ue_cfg_t& ue_cfg, const meas_cfg_s& meas_cfg, const r
ue_cfg.measgap_offset = setup.gap_offset.gp1();
break;
default:
srslte::logmap::get("RRC")->warning("Invalid measGap configuration\n");
srslog::fetch_basic_logger("RRC").warning("Invalid measGap configuration");
ue_cfg.measgap_period = 0;
ue_cfg.measgap_offset = 0;
}

@ -28,7 +28,8 @@ using namespace asn1::rrc;
namespace srsenb {
rrc::rrc(srslte::task_sched_handle task_sched_) : rrc_log("RRC"), task_sched(task_sched_)
rrc::rrc(srslte::task_sched_handle task_sched_) :
rrc_log("RRC"), logger(srslog::fetch_basic_logger("RRC")), task_sched(task_sched_)
{
pending_paging.clear();
ue_pool.reserve(16);
@ -72,14 +73,14 @@ void rrc::init(const rrc_cfg_t& cfg_,
uint32_t t310 = cfg.sibs[1].sib2().ue_timers_and_consts.t310.to_number();
uint32_t t311 = cfg.sibs[1].sib2().ue_timers_and_consts.t311.to_number();
uint32_t n310 = cfg.sibs[1].sib2().ue_timers_and_consts.n310.to_number();
rrc_log->info("T310 %d, T311 %d, N310 %d \n", t310, t311, n310);
logger.info("T310 %d, T311 %d, N310 %d", t310, t311, n310);
if (cfg.inactivity_timeout_ms < t310 + t311 + n310) {
srslte::console("\nWarning: Inactivity timeout is smaller than the sum of t310, t311 and n310.\n"
"This may break the UE's re-establishment procedure.\n");
rrc_log->warning("Inactivity timeout is smaller than the sum of t310, t311 and n310. This may break the UE's "
"re-establishment procedure.\n");
logger.warning("Inactivity timeout is smaller than the sum of t310, t311 and n310. This may break the UE's "
"re-establishment procedure.");
}
rrc_log->info("Inactivity timeout: %d ms\n", cfg.inactivity_timeout_ms);
logger.info("Inactivity timeout: %d ms", cfg.inactivity_timeout_ms);
running = true;
}
@ -152,7 +153,7 @@ int rrc::add_user(uint16_t rnti, const sched_interface::ue_cfg_t& sched_ue_cfg)
// only non-eMBMS RNTIs are present in user map
std::unique_ptr<ue> u{new ue(this, rnti, sched_ue_cfg)};
if (u->init() != SRSLTE_SUCCESS) {
rrc_log->error("Adding user rnti=0x%x - Failed to allocate user resources\n", rnti);
logger.error("Adding user rnti=0x%x - Failed to allocate user resources", rnti);
return SRSLTE_ERROR;
}
if (ue_pool.capacity() <= 4) {
@ -162,9 +163,9 @@ int rrc::add_user(uint16_t rnti, const sched_interface::ue_cfg_t& sched_ue_cfg)
}
rlc->add_user(rnti);
pdcp->add_user(rnti);
rrc_log->info("Added new user rnti=0x%x\n", rnti);
logger.info("Added new user rnti=0x%x", rnti);
} else {
rrc_log->error("Adding user rnti=0x%x (already exists)\n", rnti);
logger.error("Adding user rnti=0x%x (already exists)", rnti);
}
if (rnti == SRSLTE_MRNTI) {
@ -238,7 +239,7 @@ void rrc::write_dl_info(uint16_t rnti, srslte::unique_byte_buffer_t sdu)
user_it->second->send_dl_dcch(&dl_dcch_msg, std::move(sdu));
} else {
rrc_log->error("Rx SDU for unknown rnti=0x%x\n", rnti);
logger.error("Rx SDU for unknown rnti=0x%x", rnti);
}
}
@ -250,11 +251,11 @@ void rrc::release_complete(uint16_t rnti)
bool rrc::setup_ue_ctxt(uint16_t rnti, const asn1::s1ap::init_context_setup_request_s& msg)
{
rrc_log->info("Adding initial context for 0x%x\n", rnti);
logger.info("Adding initial context for 0x%x", rnti);
auto user_it = users.find(rnti);
if (user_it == users.end()) {
rrc_log->warning("Unrecognised rnti: 0x%x\n", rnti);
logger.warning("Unrecognised rnti: 0x%x", rnti);
return false;
}
@ -264,11 +265,11 @@ bool rrc::setup_ue_ctxt(uint16_t rnti, const asn1::s1ap::init_context_setup_requ
bool rrc::modify_ue_ctxt(uint16_t rnti, const asn1::s1ap::ue_context_mod_request_s& msg)
{
rrc_log->info("Modifying context for 0x%x\n", rnti);
logger.info("Modifying context for 0x%x", rnti);
auto user_it = users.find(rnti);
if (user_it == users.end()) {
rrc_log->warning("Unrecognised rnti: 0x%x\n", rnti);
logger.warning("Unrecognised rnti: 0x%x", rnti);
return false;
}
@ -277,11 +278,11 @@ bool rrc::modify_ue_ctxt(uint16_t rnti, const asn1::s1ap::ue_context_mod_request
bool rrc::setup_ue_erabs(uint16_t rnti, const asn1::s1ap::erab_setup_request_s& msg)
{
rrc_log->info("Setting up erab(s) for 0x%x\n", rnti);
logger.info("Setting up erab(s) for 0x%x", rnti);
auto user_it = users.find(rnti);
if (user_it == users.end()) {
rrc_log->warning("Unrecognised rnti: 0x%x\n", rnti);
logger.warning("Unrecognised rnti: 0x%x", rnti);
return false;
}
@ -298,11 +299,11 @@ bool rrc::setup_ue_erabs(uint16_t rnti, const asn1::s1ap::erab_setup_request_s&
bool rrc::release_erabs(uint32_t rnti)
{
rrc_log->info("Releasing E-RABs for 0x%x\n", rnti);
logger.info("Releasing E-RABs for 0x%x", rnti);
auto user_it = users.find(rnti);
if (user_it == users.end()) {
rrc_log->warning("Unrecognised rnti: 0x%x\n", rnti);
logger.warning("Unrecognised rnti: 0x%x", rnti);
return false;
}
@ -315,11 +316,11 @@ void rrc::release_erabs(uint32_t rnti,
std::vector<uint16_t>* erabs_released,
std::vector<uint16_t>* erabs_failed_to_release)
{
rrc_log->info("Releasing E-RAB for 0x%x\n", rnti);
logger.info("Releasing E-RAB for 0x%x", rnti);
auto user_it = users.find(rnti);
if (user_it == users.end()) {
rrc_log->warning("Unrecognised rnti: 0x%x\n", rnti);
logger.warning("Unrecognised rnti: 0x%x", rnti);
return;
}
@ -341,11 +342,11 @@ void rrc::modify_erabs(uint16_t rnti,
std::vector<uint16_t>* erabs_modified,
std::vector<uint16_t>* erabs_failed_to_modify)
{
rrc_log->info("Modifying E-RABs for 0x%x\n", rnti);
logger.info("Modifying E-RABs for 0x%x", rnti);
auto user_it = users.find(rnti);
if (user_it == users.end()) {
rrc_log->warning("Unrecognised rnti: 0x%x\n", rnti);
logger.warning("Unrecognised rnti: 0x%x", rnti);
return;
}
@ -374,11 +375,11 @@ bool rrc::modify_ue_erab(uint16_t rnti,
const asn1::s1ap::erab_level_qos_params_s& qos_params,
const asn1::unbounded_octstring<true>* nas_pdu)
{
rrc_log->info("Modifying E-RAB for 0x%x. E-RAB Id %d\n", rnti, erab_id);
logger.info("Modifying E-RAB for 0x%x. E-RAB Id %d", rnti, erab_id);
auto user_it = users.find(rnti);
if (user_it == users.end()) {
rrc_log->warning("Unrecognised rnti: 0x%x\n", rnti);
logger.warning("Unrecognised rnti: 0x%x", rnti);
return false;
}
@ -396,7 +397,7 @@ void rrc::add_paging_id(uint32_t ueid, const asn1::s1ap::ue_paging_id_c& ue_pagi
{
std::lock_guard<std::mutex> lock(paging_mutex);
if (pending_paging.count(ueid) > 0) {
rrc_log->warning("Received Paging for UEID=%d but not yet transmitted\n", ueid);
logger.warning("Received Paging for UEID=%d but not yet transmitted", ueid);
return;
}
@ -428,7 +429,7 @@ bool rrc::is_paging_opportunity(uint32_t tti, uint32_t* payload_len)
if (tti == paging_tti) {
*payload_len = byte_buf_paging.N_bytes;
rrc_log->debug("Sending paging to extra carriers. Payload len=%d, TTI=%d\n", *payload_len, tti);
logger.debug("Sending paging to extra carriers. Payload len=%d, TTI=%d", *payload_len, tti);
return true;
} else {
paging_tti = INVALID_TTI;
@ -470,7 +471,7 @@ bool rrc::is_paging_opportunity(uint32_t tti, uint32_t* payload_len)
int sf_idx = sf_pattern[i_s % 4][(Ns - 1) % 4];
if (sf_idx < 0) {
rrc_log->error("SF pattern is N/A for Ns=%d, i_s=%d, imsi_decimal=%d\n", Ns, i_s, ueid);
logger.error("SF pattern is N/A for Ns=%d, i_s=%d, imsi_decimal=%d", Ns, i_s, ueid);
continue;
}
@ -479,7 +480,7 @@ bool rrc::is_paging_opportunity(uint32_t tti, uint32_t* payload_len)
paging_rec->paging_record_list.push_back(u);
ue_to_remove.push_back(ueid);
n++;
rrc_log->info("Assembled paging for ue_id=%d, tti=%d\n", ueid, tti);
logger.info("Assembled paging for ue_id=%d, tti=%d", ueid, tti);
}
}
@ -492,7 +493,7 @@ bool rrc::is_paging_opportunity(uint32_t tti, uint32_t* payload_len)
byte_buf_paging.clear();
asn1::bit_ref bref(byte_buf_paging.msg, byte_buf_paging.get_tailroom());
if (pcch_msg.pack(bref) == asn1::SRSASN_ERROR_ENCODE_FAIL) {
rrc_log->error("Failed to pack PCCH\n");
logger.error("Failed to pack PCCH");
return false;
}
byte_buf_paging.N_bytes = (uint32_t)bref.distance_bytes();
@ -501,7 +502,7 @@ bool rrc::is_paging_opportunity(uint32_t tti, uint32_t* payload_len)
if (payload_len) {
*payload_len = byte_buf_paging.N_bytes;
}
rrc_log->info("Assembling PCCH payload with %d UE identities, payload_len=%d bytes, nbits=%d\n",
logger.info("Assembling PCCH payload with %d UE identities, payload_len=%d bytes, nbits=%d",
paging_rec->paging_record_list.size(),
byte_buf_paging.N_bytes,
N_bits);
@ -535,7 +536,7 @@ void rrc::set_erab_status(uint16_t rnti, const asn1::s1ap::bearers_subject_to_st
{
auto ue_it = users.find(rnti);
if (ue_it == users.end()) {
rrc_log->warning("rnti=0x%x does not exist\n", rnti);
logger.warning("rnti=0x%x does not exist", rnti);
return;
}
ue_it->second->mobility_handler->trigger(erabs);
@ -554,7 +555,7 @@ void rrc::parse_ul_ccch(uint16_t rnti, srslte::unique_byte_buffer_t pdu)
asn1::cbit_ref bref(pdu->msg, pdu->N_bytes);
if (ul_ccch_msg.unpack(bref) != asn1::SRSASN_SUCCESS or
ul_ccch_msg.msg.type().value != ul_ccch_msg_type_c::types_opts::c1) {
rrc_log->error("Failed to unpack UL-CCCH message\n");
logger.error("Failed to unpack UL-CCCH message");
return;
}
@ -566,18 +567,18 @@ void rrc::parse_ul_ccch(uint16_t rnti, srslte::unique_byte_buffer_t pdu)
if (user_it != users.end()) {
user_it->second->handle_rrc_con_req(&ul_ccch_msg.msg.c1().rrc_conn_request());
} else {
rrc_log->error("Received ConnectionSetup for rnti=0x%x without context\n", rnti);
logger.error("Received ConnectionSetup for rnti=0x%x without context", rnti);
}
break;
case ul_ccch_msg_type_c::c1_c_::types::rrc_conn_reest_request:
if (user_it != users.end()) {
user_it->second->handle_rrc_con_reest_req(&ul_ccch_msg.msg.c1().rrc_conn_reest_request());
} else {
rrc_log->error("Received ConnectionReestablishment for rnti=0x%x without context.\n", rnti);
logger.error("Received ConnectionReestablishment for rnti=0x%x without context.", rnti);
}
break;
default:
rrc_log->error("UL CCCH message not recognised\n");
logger.error("UL CCCH message not recognised");
break;
}
}
@ -591,7 +592,7 @@ void rrc::parse_ul_dcch(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer
if (user_it != users.end()) {
user_it->second->parse_ul_dcch(lcid, std::move(pdu));
} else {
rrc_log->error("Processing %s: Unknown rnti=0x%x\n", srsenb::to_string((rb_id_t)lcid), rnti);
logger.error("Processing %s: Unknown rnti=0x%x", srsenb::to_string((rb_id_t)lcid), rnti);
}
}
}
@ -599,10 +600,10 @@ void rrc::parse_ul_dcch(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer
///< User mutex must be hold by caller
void rrc::process_release_complete(uint16_t rnti)
{
rrc_log->info("Received Release Complete rnti=0x%x\n", rnti);
logger.info("Received Release Complete rnti=0x%x", rnti);
auto user_it = users.find(rnti);
if (user_it == users.end()) {
rrc_log->error("Received ReleaseComplete for unknown rnti=0x%x\n", rnti);
logger.error("Received ReleaseComplete for unknown rnti=0x%x", rnti);
return;
}
ue* u = user_it->second.get();
@ -622,7 +623,7 @@ void rrc::rem_user(uint16_t rnti)
auto user_it = users.find(rnti);
if (user_it != users.end()) {
srslte::console("Disconnecting rnti=0x%x.\n", rnti);
rrc_log->info("Disconnecting rnti=0x%x.\n", rnti);
logger.info("Disconnecting rnti=0x%x.", rnti);
/* First remove MAC and GTPU to stop processing DL/UL traffic for this user
*/
@ -634,9 +635,9 @@ void rrc::rem_user(uint16_t rnti)
pdcp->rem_user(rnti);
users.erase(rnti);
rrc_log->info("Removed user rnti=0x%x\n", rnti);
logger.info("Removed user rnti=0x%x", rnti);
} else {
rrc_log->error("Removing user rnti=0x%x (does not exist)\n", rnti);
logger.error("Removing user rnti=0x%x (does not exist)", rnti);
}
}
@ -673,7 +674,7 @@ void rrc::config_mac()
item.enable_phr_handling = cfg.cell_list[ccidx].enable_phr_handling;
item.nrb_pucch = SRSLTE_MAX(cfg.sr_cfg.nof_prb, cfg.cqi_cfg.nof_prb);
rrc_log->info("Allocating %d PRBs for PUCCH\n", item.nrb_pucch);
logger.info("Allocating %d PRBs for PUCCH", item.nrb_pucch);
// Copy base cell configuration
item.cell = cfg.cell;
@ -687,7 +688,7 @@ void rrc::config_mac()
return e.cell_id == scellitem.cell_id;
});
if (it == cfg.cell_list.end()) {
rrc_log->warning("Secondary cell 0x%x not configured\n", scellitem.cell_id);
logger.warning("Secondary cell 0x%x not configured", scellitem.cell_id);
continue;
}
sched_interface::cell_cfg_t::scell_cfg_t scellcfg;
@ -755,7 +756,7 @@ uint32_t rrc::generate_sibs()
srslte::unique_byte_buffer_t sib_buffer = srslte::allocate_unique_buffer(*pool);
asn1::bit_ref bref(sib_buffer->msg, sib_buffer->get_tailroom());
if (msg[msg_index].pack(bref) == asn1::SRSASN_ERROR_ENCODE_FAIL) {
rrc_log->error("Failed to pack SIB message %d\n", msg_index);
logger.error("Failed to pack SIB message %d", msg_index);
}
sib_buffer->N_bytes = bref.distance_bytes();
cell_ctxt->sib_buffer.push_back(std::move(sib_buffer));
@ -845,9 +846,9 @@ void rrc::configure_mbsfn_sibs()
uint16_t mbms_mcs = cfg.mbms_mcs;
if (mbms_mcs > 28) {
mbms_mcs = 28; // TS 36.213, Table 8.6.1-1
rrc_log->warning("PMCH data MCS too high, setting it to 28\n");
logger.warning("PMCH data MCS too high, setting it to 28");
}
rrc_log->debug("PMCH data MCS=%d\n", mbms_mcs);
logger.debug("PMCH data MCS=%d", mbms_mcs);
pmch_item->data_mcs = mbms_mcs;
pmch_item->mch_sched_period = srslte::pmch_info_t::mch_sched_period_t::rf64;
pmch_item->sf_alloc_end = 64 * 6;
@ -896,10 +897,10 @@ int rrc::pack_mcch()
uint16_t mbms_mcs = cfg.mbms_mcs;
if (mbms_mcs > 28) {
mbms_mcs = 28; // TS 36.213, Table 8.6.1-1
rrc_log->warning("PMCH data MCS too high, setting it to 28\n");
logger.warning("PMCH data MCS too high, setting it to 28");
}
rrc_log->debug("PMCH data MCS=%d\n", mbms_mcs);
logger.debug("PMCH data MCS=%d", mbms_mcs);
pmch_item->pmch_cfg_r9.data_mcs_r9 = mbms_mcs;
pmch_item->pmch_cfg_r9.mch_sched_period_r9 = pmch_cfg_r9_s::mch_sched_period_r9_e_::rf64;
pmch_item->pmch_cfg_r9.sf_alloc_end_r9 = 64 * 6;
@ -923,13 +924,13 @@ void rrc::tti_clock()
while (rx_pdu_queue.try_pop(&p)) {
// print Rx PDU
if (p.pdu != nullptr) {
rrc_log->info_hex(p.pdu->msg, p.pdu->N_bytes, "Rx %s PDU", to_string((rb_id_t)p.lcid));
logger.info(p.pdu->msg, p.pdu->N_bytes, "Rx %s PDU", to_string((rb_id_t)p.lcid));
}
// check if user exists
auto user_it = users.find(p.rnti);
if (user_it == users.end()) {
rrc_log->warning("Discarding PDU for removed rnti=0x%x\n", p.rnti);
logger.warning("Discarding PDU for removed rnti=0x%x", p.rnti);
continue;
}
@ -952,10 +953,10 @@ void rrc::tti_clock()
user_it->second->set_activity();
break;
case LCID_EXIT:
rrc_log->info("Exiting thread\n");
logger.info("Exiting thread");
break;
default:
rrc_log->error("Rx PDU with invalid bearer id: %d", p.lcid);
logger.error("Rx PDU with invalid bearer id: %d", p.lcid);
break;
}
}

@ -55,17 +55,17 @@ bool security_cfg_handler::set_security_capabilities(const asn1::s1ap::ue_securi
// just assume that EEA0 is always supported even this can not be explicity signaled by S1AP
sec_cfg.cipher_algo = srslte::CIPHERING_ALGORITHM_ID_EEA0;
enc_algo_found = true;
log_h->info("Selected EEA0 as RRC encryption algorithm\n");
logger.info("Selected EEA0 as RRC encryption algorithm");
break;
case srslte::CIPHERING_ALGORITHM_ID_128_EEA1:
// “first bit” 128-EEA1,
if (v.get(v.length() - srslte::CIPHERING_ALGORITHM_ID_128_EEA1)) {
sec_cfg.cipher_algo = srslte::CIPHERING_ALGORITHM_ID_128_EEA1;
enc_algo_found = true;
log_h->info("Selected EEA1 as RRC encryption algorithm\n");
logger.info("Selected EEA1 as RRC encryption algorithm");
break;
} else {
log_h->info("Failed to selected EEA1 as RRC encryption algorithm, due to unsupported algorithm\n");
logger.info("Failed to selected EEA1 as RRC encryption algorithm, due to unsupported algorithm");
}
break;
case srslte::CIPHERING_ALGORITHM_ID_128_EEA2:
@ -73,10 +73,10 @@ bool security_cfg_handler::set_security_capabilities(const asn1::s1ap::ue_securi
if (v.get(v.length() - srslte::CIPHERING_ALGORITHM_ID_128_EEA2)) {
sec_cfg.cipher_algo = srslte::CIPHERING_ALGORITHM_ID_128_EEA2;
enc_algo_found = true;
log_h->info("Selected EEA2 as RRC encryption algorithm\n");
logger.info("Selected EEA2 as RRC encryption algorithm");
break;
} else {
log_h->info("Failed to selected EEA2 as RRC encryption algorithm, due to unsupported algorithm\n");
logger.info("Failed to selected EEA2 as RRC encryption algorithm, due to unsupported algorithm");
}
break;
case srslte::CIPHERING_ALGORITHM_ID_128_EEA3:
@ -84,10 +84,10 @@ bool security_cfg_handler::set_security_capabilities(const asn1::s1ap::ue_securi
if (v.get(v.length() - srslte::CIPHERING_ALGORITHM_ID_128_EEA3)) {
sec_cfg.cipher_algo = srslte::CIPHERING_ALGORITHM_ID_128_EEA3;
enc_algo_found = true;
log_h->info("Selected EEA3 as RRC encryption algorithm\n");
logger.info("Selected EEA3 as RRC encryption algorithm");
break;
} else {
log_h->info("Failed to selected EEA2 as RRC encryption algorithm, due to unsupported algorithm\n");
logger.info("Failed to selected EEA2 as RRC encryption algorithm, due to unsupported algorithm");
}
break;
default:
@ -104,16 +104,16 @@ bool security_cfg_handler::set_security_capabilities(const asn1::s1ap::ue_securi
switch (eia_enum) {
case srslte::INTEGRITY_ALGORITHM_ID_EIA0:
// Null integrity is not supported
log_h->info("Skipping EIA0 as RRC integrity algorithm. Null integrity is not supported.\n");
logger.info("Skipping EIA0 as RRC integrity algorithm. Null integrity is not supported.");
break;
case srslte::INTEGRITY_ALGORITHM_ID_128_EIA1:
// “first bit” 128-EIA1,
if (v.get(v.length() - srslte::INTEGRITY_ALGORITHM_ID_128_EIA1)) {
sec_cfg.integ_algo = srslte::INTEGRITY_ALGORITHM_ID_128_EIA1;
integ_algo_found = true;
log_h->info("Selected EIA1 as RRC integrity algorithm.\n");
logger.info("Selected EIA1 as RRC integrity algorithm.");
} else {
log_h->info("Failed to selected EIA1 as RRC encryption algorithm, due to unsupported algorithm\n");
logger.info("Failed to selected EIA1 as RRC encryption algorithm, due to unsupported algorithm");
}
break;
case srslte::INTEGRITY_ALGORITHM_ID_128_EIA2:
@ -121,9 +121,9 @@ bool security_cfg_handler::set_security_capabilities(const asn1::s1ap::ue_securi
if (v.get(v.length() - srslte::INTEGRITY_ALGORITHM_ID_128_EIA2)) {
sec_cfg.integ_algo = srslte::INTEGRITY_ALGORITHM_ID_128_EIA2;
integ_algo_found = true;
log_h->info("Selected EIA2 as RRC integrity algorithm.\n");
logger.info("Selected EIA2 as RRC integrity algorithm.");
} else {
log_h->info("Failed to selected EIA2 as RRC encryption algorithm, due to unsupported algorithm\n");
logger.info("Failed to selected EIA2 as RRC encryption algorithm, due to unsupported algorithm");
}
break;
case srslte::INTEGRITY_ALGORITHM_ID_128_EIA3:
@ -131,9 +131,9 @@ bool security_cfg_handler::set_security_capabilities(const asn1::s1ap::ue_securi
if (v.get(v.length() - srslte::INTEGRITY_ALGORITHM_ID_128_EIA3)) {
sec_cfg.integ_algo = srslte::INTEGRITY_ALGORITHM_ID_128_EIA3;
integ_algo_found = true;
log_h->info("Selected EIA3 as RRC integrity algorithm.\n");
logger.info("Selected EIA3 as RRC integrity algorithm.");
} else {
log_h->info("Failed to selected EIA3 as RRC encryption algorithm, due to unsupported algorithm\n");
logger.info("Failed to selected EIA3 as RRC encryption algorithm, due to unsupported algorithm");
}
break;
default:
@ -149,7 +149,7 @@ bool security_cfg_handler::set_security_capabilities(const asn1::s1ap::ue_securi
if (not integ_algo_found || not enc_algo_found) {
// TODO: if no security algorithm found abort radio connection and issue
// encryption-and-or-integrity-protection-algorithms-not-supported message
log_h->error("Did not find a matching integrity or encryption algorithm with the UE\n");
logger.error("Did not find a matching integrity or encryption algorithm with the UE");
return false;
}
return true;
@ -161,7 +161,7 @@ void security_cfg_handler::set_security_key(const asn1::fixed_bitstring<256, fal
for (uint32_t i = 0; i < key.nof_octets(); ++i) {
k_enb[i] = key.data()[key.nof_octets() - 1 - i];
}
log_h->info_hex(k_enb, 32, "Key eNodeB (k_enb)");
logger.info(k_enb, 32, "Key eNodeB (k_enb)");
generate_as_keys();
}
@ -176,16 +176,16 @@ void security_cfg_handler::generate_as_keys()
security_generate_k_up(
k_enb, sec_cfg.cipher_algo, sec_cfg.integ_algo, sec_cfg.k_up_enc.data(), sec_cfg.k_up_int.data());
log_h->info_hex(k_enb, 32, "K_eNB (k_enb)");
log_h->info_hex(sec_cfg.k_rrc_enc.data(), 32, "RRC Encryption Key (k_rrc_enc)");
log_h->info_hex(sec_cfg.k_rrc_int.data(), 32, "RRC Integrity Key (k_rrc_int)");
log_h->info_hex(sec_cfg.k_up_enc.data(), 32, "UP Encryption Key (k_up_enc)");
logger.info(k_enb, 32, "K_eNB (k_enb)");
logger.info(sec_cfg.k_rrc_enc.data(), 32, "RRC Encryption Key (k_rrc_enc)");
logger.info(sec_cfg.k_rrc_int.data(), 32, "RRC Integrity Key (k_rrc_int)");
logger.info(sec_cfg.k_up_enc.data(), 32, "UP Encryption Key (k_up_enc)");
}
void security_cfg_handler::regenerate_keys_handover(uint32_t new_pci, uint32_t new_dl_earfcn)
{
log_h->info("Regenerating KeNB with PCI=0x%02x, DL-EARFCN=%d\n", new_pci, new_dl_earfcn);
log_h->info_hex(k_enb, 32, "Old K_eNB (k_enb)");
logger.info("Regenerating KeNB with PCI=0x%02x, DL-EARFCN=%d", new_pci, new_dl_earfcn);
logger.info(k_enb, 32, "Old K_eNB (k_enb)");
// Generate K_enb*
uint8_t k_enb_star[32];
srslte::security_generate_k_enb_star(k_enb, new_pci, new_dl_earfcn, k_enb_star);
@ -200,7 +200,9 @@ void security_cfg_handler::regenerate_keys_handover(uint32_t new_pci, uint32_t n
* Bearer Handler
****************************/
bearer_cfg_handler::bearer_cfg_handler(uint16_t rnti_, const rrc_cfg_t& cfg_) : rnti(rnti_), cfg(&cfg_) {}
bearer_cfg_handler::bearer_cfg_handler(uint16_t rnti_, const rrc_cfg_t& cfg_) :
rnti(rnti_), cfg(&cfg_), logger(srslog::fetch_basic_logger("RRC"))
{}
int bearer_cfg_handler::add_erab(uint8_t erab_id,
const asn1::s1ap::erab_level_qos_params_s& qos,
@ -209,22 +211,22 @@ int bearer_cfg_handler::add_erab(uint8_t
const asn1::unbounded_octstring<true>* nas_pdu)
{
if (erab_id < 5) {
log_h->error("ERAB id=%d is invalid\n", erab_id);
logger.error("ERAB id=%d is invalid", erab_id);
return SRSLTE_ERROR;
}
uint8_t lcid = erab_id - 2; // Map e.g. E-RAB 5 to LCID 3 (==DRB1)
uint8_t drbid = erab_id - 4;
if (qos.qci >= MAX_NOF_QCI) {
log_h->error("Invalid QCI=%d for ERAB_id=%d, DRB_id=%d\n", qos.qci, erab_id, drbid);
logger.error("Invalid QCI=%d for ERAB_id=%d, DRB_id=%d", qos.qci, erab_id, drbid);
return SRSLTE_ERROR;
}
if (not cfg->qci_cfg[qos.qci].configured) {
log_h->error("QCI=%d not configured\n", qos.qci);
logger.error("QCI=%d not configured", qos.qci);
return SRSLTE_ERROR;
}
if (lcid < 3 or lcid > 10) {
log_h->error("DRB logical channel ids must be within 3 and 10\n");
logger.error("DRB logical channel ids must be within 3 and 10");
return SRSLTE_ERROR;
}
@ -234,13 +236,13 @@ int bearer_cfg_handler::add_erab(uint8_t
erabs[erab_id].teid_out = teid_out;
if (addr.length() > 32) {
log_h->error("Only addresses with length <= 32 are supported\n");
logger.error("Only addresses with length <= 32 are supported");
return SRSLTE_ERROR;
}
if (nas_pdu != nullptr and nas_pdu->size() > 0) {
erab_info_list[erab_id].assign(nas_pdu->data(), nas_pdu->data() + nas_pdu->size());
log_h->info_hex(
logger.info(
&erab_info_list[erab_id][0], erab_info_list[erab_id].size(), "setup_erab nas_pdu -> erab_info rnti 0x%x", rnti);
}
@ -266,7 +268,7 @@ bool bearer_cfg_handler::release_erab(uint8_t erab_id)
{
auto it = erabs.find(erab_id);
if (it == erabs.end()) {
log_h->warning("The user rnti=0x%x does not contain ERAB-ID=%d\n", rnti, erab_id);
logger.warning("The user rnti=0x%x does not contain ERAB-ID=%d", rnti, erab_id);
return false;
}
@ -293,10 +295,10 @@ bool bearer_cfg_handler::modify_erab(uint8_t
const asn1::s1ap::erab_level_qos_params_s& qos,
const asn1::unbounded_octstring<true>* nas_pdu)
{
log_h->info("Modifying E-RAB %d\n", erab_id);
logger.info("Modifying E-RAB %d", erab_id);
std::map<uint8_t, erab_t>::iterator erab_it = erabs.find(erab_id);
if (erab_it == erabs.end()) {
log_h->error("Could not find E-RAB to modify\n");
logger.error("Could not find E-RAB to modify");
return false;
}
auto address = erab_it->second.address;
@ -315,7 +317,7 @@ void bearer_cfg_handler::add_gtpu_bearer(srsenb::gtpu_interface_rrc* gtpu, uint3
uint32_t addr_ = erab.address.to_number();
erab.teid_in = gtpu->add_bearer(rnti, erab.id - 2, addr_, erab.teid_out);
} else {
log_h->error("Adding erab_id=%d to GTPU\n", erab_id);
logger.error("Adding erab_id=%d to GTPU", erab_id);
}
}
@ -337,12 +339,12 @@ void bearer_cfg_handler::fill_pending_nas_info(asn1::rrc::rrc_conn_recfg_r8_ies_
auto it = erab_info_list.find(erab_id);
if (it != erab_info_list.end()) {
const std::vector<uint8_t>& erab_info = it->second;
log_h->info_hex(&erab_info[0], erab_info.size(), "connection_reconf erab_info -> nas_info rnti 0x%x\n", rnti);
logger.info(&erab_info[0], erab_info.size(), "connection_reconf erab_info -> nas_info rnti 0x%x", rnti);
msg->ded_info_nas_list[idx].resize(erab_info.size());
memcpy(msg->ded_info_nas_list[idx].data(), &erab_info[0], erab_info.size());
erab_info_list.erase(it);
} else {
log_h->debug("Not adding NAS message to connection reconfiguration. E-RAB id %d\n", erab_id);
logger.debug("Not adding NAS message to connection reconfiguration. E-RAB id %d", erab_id);
}
idx++;
}

@ -140,7 +140,7 @@ cell_res_common* freq_res_common_list::get_earfcn(uint32_t earfcn)
ue_cell_ded_list::ue_cell_ded_list(const rrc_cfg_t& cfg_,
freq_res_common_list& cell_res_list_,
const enb_cell_common_list& enb_common_list) :
cfg(cfg_), cell_res_list(cell_res_list_), common_list(enb_common_list)
logger(srslog::fetch_basic_logger("RRC")), cfg(cfg_), cell_res_list(cell_res_list_), common_list(enb_common_list)
{
cell_list.reserve(common_list.nof_cells());
}
@ -174,12 +174,12 @@ ue_cell_ded* ue_cell_ded_list::add_cell(uint32_t enb_cc_idx)
{
const enb_cell_common* cell_common = common_list.get_cc_idx(enb_cc_idx);
if (cell_common == nullptr) {
log_h->error("cell with enb_cc_idx=%d does not exist.\n", enb_cc_idx);
logger.error("cell with enb_cc_idx=%d does not exist.", enb_cc_idx);
return nullptr;
}
ue_cell_ded* ret = get_enb_cc_idx(enb_cc_idx);
if (ret != nullptr) {
log_h->error("UE already registered cell %d\n", enb_cc_idx);
logger.error("UE already registered cell %d", enb_cc_idx);
return nullptr;
}
@ -221,7 +221,7 @@ bool ue_cell_ded_list::alloc_cell_resources(uint32_t ue_cc_idx)
// Allocate CQI, SR, and PUCCH CS resources. If failure, do not add new cell
if (ue_cc_idx == UE_PCELL_CC_IDX) {
if (not alloc_sr_resources(cfg.sr_cfg.period)) {
log_h->error("Failed to allocate SR resources for PCell\n");
logger.error("Failed to allocate SR resources for PCell");
return false;
}
@ -233,7 +233,7 @@ bool ue_cell_ded_list::alloc_cell_resources(uint32_t ue_cc_idx)
if (ue_cc_idx == 1 and not n_pucch_cs_present) {
// Allocate resources for Format1b CS (will be optional PUCCH3/CS)
if (not alloc_pucch_cs_resources()) {
log_h->error("Error allocating PUCCH Format1b CS resource for SCell\n");
logger.error("Error allocating PUCCH Format1b CS resource for SCell");
return false;
}
} else {
@ -242,7 +242,7 @@ bool ue_cell_ded_list::alloc_cell_resources(uint32_t ue_cc_idx)
}
}
if (not alloc_cqi_resources(ue_cc_idx, cfg.cqi_cfg.period)) {
log_h->error("Failed to allocate CQIresources for cell ue_cc_idx=%d\n", ue_cc_idx);
logger.error("Failed to allocate CQIresources for cell ue_cc_idx=%d", ue_cc_idx);
return false;
}
@ -293,7 +293,7 @@ bool ue_cell_ded_list::set_cells(const std::vector<uint32_t>& enb_cc_idxs)
uint32_t enb_cc_idx = enb_cc_idxs[ue_cc_idx];
const enb_cell_common* cell_common = common_list.get_cc_idx(enb_cc_idx);
if (cell_common == nullptr) {
log_h->error("cell with enb_cc_idx=%d does not exist.\n", enb_cc_idx);
logger.error("cell with enb_cc_idx=%d does not exist.", enb_cc_idx);
break;
}
auto* prev_cell_common = cell_list[ue_cc_idx].cell_common;
@ -305,7 +305,7 @@ bool ue_cell_ded_list::set_cells(const std::vector<uint32_t>& enb_cc_idxs)
dealloc_cqi_resources(ue_cc_idx);
cell_list[ue_cc_idx] = ue_cell_ded{ue_cc_idx, *cell_common};
if (not alloc_cqi_resources(ue_cc_idx, cfg.cqi_cfg.period)) {
log_h->error("Failed to allocate CQI resources for cell ue_cc_idx=%d\n", ue_cc_idx);
logger.error("Failed to allocate CQI resources for cell ue_cc_idx=%d", ue_cc_idx);
break;
}
}
@ -324,11 +324,11 @@ bool ue_cell_ded_list::alloc_cqi_resources(uint32_t ue_cc_idx, uint32_t period)
{
ue_cell_ded* cell = get_ue_cc_idx(ue_cc_idx);
if (cell == nullptr) {
log_h->error("The user cell ue_cc_idx=%d has not been allocated\n", ue_cc_idx);
logger.error("The user cell ue_cc_idx=%d has not been allocated", ue_cc_idx);
return false;
}
if (cell->cqi_res_present) {
log_h->error("The user cqi resources for cell ue_cc_idx=%d are already allocated\n", ue_cc_idx);
logger.error("The user cqi resources for cell ue_cc_idx=%d are already allocated", ue_cc_idx);
return false;
}
@ -352,7 +352,7 @@ bool ue_cell_ded_list::alloc_cqi_resources(uint32_t ue_cc_idx, uint32_t period)
}
}
if (pucch_res->cqi_sched.nof_users[i_min][j_min] > max_users) {
log_h->error("Not enough PUCCH resources to allocate Scheduling Request\n");
logger.error("Not enough PUCCH resources to allocate Scheduling Request");
return false;
}
@ -361,7 +361,7 @@ bool ue_cell_ded_list::alloc_cqi_resources(uint32_t ue_cc_idx, uint32_t period)
// Compute I_sr
if (period != 2 && period != 5 && period != 10 && period != 20 && period != 40 && period != 80 && period != 160 &&
period != 32 && period != 64 && period != 128) {
log_h->error("Invalid CQI Report period %d ms\n", period);
logger.error("Invalid CQI Report period %d ms", period);
return false;
}
if (cfg.cqi_cfg.sf_mapping[j_min] < period) {
@ -381,7 +381,7 @@ bool ue_cell_ded_list::alloc_cqi_resources(uint32_t ue_cc_idx, uint32_t period)
}
}
} else {
log_h->error("Allocating CQI: invalid sf_idx=%d for period=%d\n", cfg.cqi_cfg.sf_mapping[j_min], period);
logger.error("Allocating CQI: invalid sf_idx=%d for period=%d", cfg.cqi_cfg.sf_mapping[j_min], period);
return false;
}
@ -399,7 +399,7 @@ bool ue_cell_ded_list::alloc_cqi_resources(uint32_t ue_cc_idx, uint32_t period)
pucch_res->cqi_sched.nof_users[i_min][j_min]++;
log_h->info("Allocated CQI resources for ue_cc_idx=%d, time-frequency slot (%d, %d), n_pucch_2=%d, pmi_cfg_idx=%d\n",
logger.info("Allocated CQI resources for ue_cc_idx=%d, time-frequency slot (%d, %d), n_pucch_2=%d, pmi_cfg_idx=%d",
ue_cc_idx,
i_min,
j_min,
@ -417,10 +417,10 @@ bool ue_cell_ded_list::dealloc_cqi_resources(uint32_t ue_cc_idx)
if (pucch_res->cqi_sched.nof_users[c->cqi_res.prb_idx][c->cqi_res.sf_idx] > 0) {
pucch_res->cqi_sched.nof_users[c->cqi_res.prb_idx][c->cqi_res.sf_idx]--;
log_h->info("Deallocated CQI resources for time-frequency slot (%d, %d)\n", c->cqi_res.prb_idx, c->cqi_res.sf_idx);
logger.info("Deallocated CQI resources for time-frequency slot (%d, %d)", c->cqi_res.prb_idx, c->cqi_res.sf_idx);
} else {
log_h->warning(
"Removing CQI resources: no users in time-frequency slot (%d, %d)\n", c->cqi_res.prb_idx, c->cqi_res.sf_idx);
logger.warning(
"Removing CQI resources: no users in time-frequency slot (%d, %d)", c->cqi_res.prb_idx, c->cqi_res.sf_idx);
}
c->cqi_res_present = false;
return true;
@ -430,11 +430,11 @@ bool ue_cell_ded_list::alloc_sr_resources(uint32_t period)
{
ue_cell_ded* cell = get_ue_cc_idx(UE_PCELL_CC_IDX);
if (cell == nullptr) {
log_h->error("The user cell pcell has not been allocated\n");
logger.error("The user cell pcell has not been allocated");
return false;
}
if (sr_res_present) {
log_h->error("The user sr resources are already allocated\n");
logger.error("The user sr resources are already allocated");
return false;
}
@ -457,19 +457,19 @@ bool ue_cell_ded_list::alloc_sr_resources(uint32_t period)
}
if (pucch_res->sr_sched.nof_users[i_min][j_min] > max_users) {
log_h->error("Not enough PUCCH resources to allocate Scheduling Request\n");
logger.error("Not enough PUCCH resources to allocate Scheduling Request");
return false;
}
// Compute I_sr
if (period != 5 && period != 10 && period != 20 && period != 40 && period != 80) {
log_h->error("Invalid SchedulingRequest period %d ms\n", period);
logger.error("Invalid SchedulingRequest period %d ms", period);
return false;
}
if (cfg.sr_cfg.sf_mapping[j_min] < period) {
sr_res.sr_I = period - 5 + cfg.sr_cfg.sf_mapping[j_min];
} else {
log_h->error("Allocating SR: invalid sf_idx=%d for period=%d\n", cfg.sr_cfg.sf_mapping[j_min], period);
logger.error("Allocating SR: invalid sf_idx=%d for period=%d", cfg.sr_cfg.sf_mapping[j_min], period);
return false;
}
@ -485,7 +485,7 @@ bool ue_cell_ded_list::alloc_sr_resources(uint32_t period)
sr_res.sr_sched_sf_idx = j_min;
sr_res_present = true;
log_h->info("Allocated SR resources in time-freq slot (%d, %d), sf_cfg_idx=%d\n",
logger.info("Allocated SR resources in time-freq slot (%d, %d), sf_cfg_idx=%d",
sr_res.sr_sched_sf_idx,
sr_res.sr_sched_prb_idx,
cfg.sr_cfg.sf_mapping[sr_res.sr_sched_sf_idx]);
@ -499,13 +499,13 @@ bool ue_cell_ded_list::dealloc_sr_resources()
if (pucch_res->sr_sched.nof_users[sr_res.sr_sched_prb_idx][sr_res.sr_sched_sf_idx] > 0) {
pucch_res->sr_sched.nof_users[sr_res.sr_sched_prb_idx][sr_res.sr_sched_sf_idx]--;
} else {
log_h->warning("Removing SR resources: no users in time-frequency slot (%d, %d)\n",
logger.warning("Removing SR resources: no users in time-frequency slot (%d, %d)",
sr_res.sr_sched_prb_idx,
sr_res.sr_sched_sf_idx);
}
log_h->info(
"Deallocated SR resources for time-frequency slot (%d, %d)\n", sr_res.sr_sched_prb_idx, sr_res.sr_sched_sf_idx);
log_h->debug("Remaining SR allocations for slot (%d, %d): %d\n",
logger.info(
"Deallocated SR resources for time-frequency slot (%d, %d)", sr_res.sr_sched_prb_idx, sr_res.sr_sched_sf_idx);
logger.debug("Remaining SR allocations for slot (%d, %d): %d",
sr_res.sr_sched_prb_idx,
sr_res.sr_sched_sf_idx,
pucch_res->sr_sched.nof_users[sr_res.sr_sched_prb_idx][sr_res.sr_sched_sf_idx]);
@ -519,11 +519,11 @@ bool ue_cell_ded_list::alloc_pucch_cs_resources()
{
ue_cell_ded* cell = get_ue_cc_idx(UE_PCELL_CC_IDX);
if (cell == nullptr) {
log_h->error("The user cell pcell has not been allocated\n");
logger.error("The user cell pcell has not been allocated");
return false;
}
if (n_pucch_cs_present) {
log_h->error("The user sr resources are already allocated\n");
logger.error("The user sr resources are already allocated");
return false;
}
@ -536,11 +536,11 @@ bool ue_cell_ded_list::alloc_pucch_cs_resources()
pucch_res->n_pucch_cs_used[i] = true;
n_pucch_cs_idx = i;
n_pucch_cs_present = true;
log_h->info("Allocated N_pucch_cs=%d\n", n_pucch_cs_idx);
logger.info("Allocated N_pucch_cs=%d", n_pucch_cs_idx);
return true;
}
}
log_h->warning("Could not allocated N_pucch_cs\n");
logger.warning("Could not allocated N_pucch_cs");
return false;
}
@ -549,7 +549,7 @@ bool ue_cell_ded_list::dealloc_pucch_cs_resources()
if (n_pucch_cs_present) {
pucch_res->n_pucch_cs_used[n_pucch_cs_idx] = false;
n_pucch_cs_present = false;
log_h->info("Deallocated N_pucch_cs=%d\n", n_pucch_cs_idx);
logger.info("Deallocated N_pucch_cs=%d", n_pucch_cs_idx);
return true;
}
return false;

@ -26,14 +26,14 @@
namespace srsenb {
#define Info(fmt, ...) rrc_log->info("Mobility: " fmt, ##__VA_ARGS__)
#define Error(fmt, ...) rrc_log->error("Mobility: " fmt, ##__VA_ARGS__)
#define Warning(fmt, ...) rrc_log->warning("Mobility: " fmt, ##__VA_ARGS__)
#define Debug(fmt, ...) rrc_log->debug("Mobility: " fmt, ##__VA_ARGS__)
#define Info(fmt, ...) logger.info("Mobility: " fmt, ##__VA_ARGS__)
#define Error(fmt, ...) logger.error("Mobility: " fmt, ##__VA_ARGS__)
#define Warning(fmt, ...) logger.warning("Mobility: " fmt, ##__VA_ARGS__)
#define Debug(fmt, ...) logger.debug("Mobility: " fmt, ##__VA_ARGS__)
#define procInfo(fmt, ...) parent->rrc_log->info("Proc \"%s\" - " fmt, name(), ##__VA_ARGS__)
#define procWarning(fmt, ...) parent->rrc_log->warning("Proc \"%s\" - " fmt, name(), ##__VA_ARGS__)
#define procError(fmt, ...) parent->rrc_log->error("Proc \"%s\" - " fmt, name(), ##__VA_ARGS__)
#define procInfo(fmt, ...) parent->logger.info("Proc \"%s\" - " fmt, name(), ##__VA_ARGS__)
#define procWarning(fmt, ...) parent->logger.warning("Proc \"%s\" - " fmt, name(), ##__VA_ARGS__)
#define procError(fmt, ...) parent->logger.error("Proc \"%s\" - " fmt, name(), ##__VA_ARGS__)
using namespace asn1::rrc;
@ -71,11 +71,11 @@ uint16_t compute_mac_i(uint16_t crnti,
asn1::bit_ref bref(varShortMAC_packed, sizeof(varShortMAC_packed));
if (var_short_mac.pack(bref) == asn1::SRSASN_ERROR_ENCODE_FAIL) { // already zeroed, so no need to align
printf("Error packing varShortMAC\n");
printf("Error packing varShortMAC");
}
uint32_t N_bytes = bref.distance_bytes();
printf("Encoded varShortMAC: cellId=0x%x, PCI=%d, rnti=0x%x (%d bytes)\n", cellid, pci, crnti, N_bytes);
printf("Encoded varShortMAC: cellId=0x%x, PCI=%d, rnti=0x%x (%d bytes)", cellid, pci, crnti, N_bytes);
// Compute MAC-I
switch (integ_algo) {
@ -98,7 +98,7 @@ uint16_t compute_mac_i(uint16_t crnti,
mac_key);
break;
default:
printf("Unsupported integrity algorithm %d.\n", integ_algo);
printf("Unsupported integrity algorithm %d.", integ_algo);
}
uint16_t short_mac_i = (((uint16_t)mac_key[2] << 8u) | (uint16_t)mac_key[3]);
@ -138,7 +138,7 @@ uint16_t rrc::start_ho_ue_resource_alloc(const asn1::s1ap::ho_request_s&
uint32_t target_eci = container.target_cell_id.cell_id.to_number();
const enb_cell_common* target_cell = cell_common_list->get_cell_id(rrc_details::eci_to_cellid(target_eci));
if (target_cell == nullptr) {
rrc_log->error("The S1-handover target cell_id=0x%x does not exist\n", rrc_details::eci_to_cellid(target_eci));
logger.error("The S1-handover target cell_id=0x%x does not exist", rrc_details::eci_to_cellid(target_eci));
return SRSLTE_INVALID_RNTI;
}
@ -153,7 +153,7 @@ uint16_t rrc::start_ho_ue_resource_alloc(const asn1::s1ap::ho_request_s&
ue_cfg.supported_cc_list[0].dl_cfg.tm = SRSLTE_TM1;
uint16_t rnti = mac->reserve_new_crnti(ue_cfg);
if (rnti == SRSLTE_INVALID_RNTI) {
rrc_log->error("Failed to allocate C-RNTI resources\n");
logger.error("Failed to allocate C-RNTI resources");
return SRSLTE_INVALID_RNTI;
}
@ -166,7 +166,7 @@ uint16_t rrc::start_ho_ue_resource_alloc(const asn1::s1ap::ho_request_s&
// /* Setup e-RABs & DRBs / establish an UL/DL S1 bearer to the S-GW */
// if (not setup_ue_erabs(rnti, msg)) {
// rrc_ptr->rrc_log->error("Failed to setup e-RABs for rnti=0x%x\n", );
// rrc_ptr->logger.error("Failed to setup e-RABs for rnti=0x%x", );
// }
// TODO: KeNB derivations
@ -187,7 +187,7 @@ rrc::ue::rrc_mobility::rrc_mobility(rrc::ue* outer_ue) :
rrc_ue(outer_ue),
rrc_enb(outer_ue->parent),
pool(outer_ue->pool),
rrc_log(outer_ue->parent->rrc_log)
logger(outer_ue->parent->logger)
{}
//! Method to add Mobility Info to a RRC Connection Reconfiguration Message
@ -209,25 +209,25 @@ bool rrc::ue::rrc_mobility::fill_conn_recfg_no_ho_cmd(asn1::rrc::rrc_conn_recfg_
void rrc::ue::rrc_mobility::handle_ue_meas_report(const meas_report_s& msg)
{
if (not is_in_state<idle_st>()) {
Info("Received a MeasReport while UE is performing Handover. Ignoring...\n");
Info("Received a MeasReport while UE is performing Handover. Ignoring...");
return;
}
// Check if meas_id is valid
const meas_results_s& meas_res = msg.crit_exts.c1().meas_report_r8().meas_results;
if (not meas_res.meas_result_neigh_cells_present) {
Info("Received a MeasReport, but the UE did not detect any cell.\n");
Info("Received a MeasReport, but the UE did not detect any cell.");
return;
}
if (meas_res.meas_result_neigh_cells.type().value !=
meas_results_s::meas_result_neigh_cells_c_::types::meas_result_list_eutra) {
Error("MeasReports regarding non-EUTRA are not supported!\n");
Error("MeasReports regarding non-EUTRA are not supported!");
return;
}
const meas_id_list& measid_list = rrc_ue->current_ue_cfg.meas_cfg.meas_id_to_add_mod_list;
const meas_obj_list& measobj_list = rrc_ue->current_ue_cfg.meas_cfg.meas_obj_to_add_mod_list;
auto measid_it = srslte::find_rrc_obj_id(measid_list, meas_res.meas_id);
if (measid_it == measid_list.end()) {
Warning("The measurement ID %d provided by the UE does not exist.\n", meas_res.meas_id);
Warning("The measurement ID %d provided by the UE does not exist.", meas_res.meas_id);
return;
}
const meas_result_list_eutra_l& eutra_report_list = meas_res.meas_result_neigh_cells.meas_result_list_eutra();
@ -249,7 +249,7 @@ void rrc::ue::rrc_mobility::handle_ue_meas_report(const meas_report_s& msg)
} else if (c != nullptr) {
meas_ev.target_eci = (rrc_enb->cfg.enb_id << 8u) + c->cell_cfg.cell_id;
} else {
rrc_log->warning("The PCI=%d inside the MeasReport is not recognized.\n", e.pci);
logger.warning("The PCI=%d inside the MeasReport is not recognized.", e.pci);
continue;
}
@ -272,7 +272,7 @@ bool rrc::ue::rrc_mobility::start_ho_preparation(uint32_t target_eci,
bool fwd_direct_path_available)
{
if (fwd_direct_path_available) {
Error("Direct tunnels not supported supported\n");
Error("Direct tunnels not supported supported");
return false;
}
@ -310,12 +310,12 @@ bool rrc::ue::rrc_mobility::start_ho_preparation(uint32_t target_eci,
uint8_t buffer[128];
asn1::bit_ref bref(&buffer[0], sizeof(buffer));
if (capitem.pack(bref) == asn1::SRSASN_ERROR_ENCODE_FAIL) {
rrc_log->error("Failed to pack UE EUTRA Capability\n");
logger.error("Failed to pack UE EUTRA Capability");
}
hoprep_r8.ue_radio_access_cap_info[0].ue_cap_rat_container.resize((uint32_t)bref.distance_bytes());
memcpy(&hoprep_r8.ue_radio_access_cap_info[0].ue_cap_rat_container[0], &buffer[0], bref.distance_bytes());
}
Debug("UE RA Category: %d\n", capitem.ue_category);
Debug("UE RA Category: %d", capitem.ue_category);
} else {
hoprep_r8.ue_radio_access_cap_info.resize(1);
hoprep_r8.ue_radio_access_cap_info[0].rat_type = asn1::rrc::rat_type_e::eutra;
@ -323,7 +323,7 @@ bool rrc::ue::rrc_mobility::start_ho_preparation(uint32_t target_eci,
srslte::unique_byte_buffer_t buffer = srslte::allocate_unique_buffer(*pool);
asn1::bit_ref bref(buffer->msg, buffer->get_tailroom());
if (rrc_ue->eutra_capabilities.pack(bref) == asn1::SRSASN_ERROR_ENCODE_FAIL) {
rrc_log->error("Failed to pack UE EUTRA Capability\n");
logger.error("Failed to pack UE EUTRA Capability");
return false;
}
hoprep_r8.ue_radio_access_cap_info[0].ue_cap_rat_container.resize(bref.distance_bytes());
@ -362,13 +362,13 @@ bool rrc::ue::rrc_mobility::start_ho_preparation(uint32_t target_eci,
srslte::unique_byte_buffer_t buffer = srslte::allocate_unique_buffer(*pool);
asn1::bit_ref bref(buffer->msg, buffer->get_tailroom());
if (hoprep.pack(bref) == asn1::SRSASN_ERROR_ENCODE_FAIL) {
Error("Failed to pack HO preparation msg\n");
Error("Failed to pack HO preparation msg");
return false;
}
buffer->N_bytes = bref.distance_bytes();
bool success = rrc_enb->s1ap->send_ho_required(rrc_ue->rnti, target_eci, target_plmn, std::move(buffer));
Info("sent s1ap msg with HO Required\n");
Info("sent s1ap msg with HO Required");
return success;
}
@ -383,7 +383,7 @@ bool rrc::ue::rrc_mobility::start_ho_preparation(uint32_t target_eci,
void rrc::ue::rrc_mobility::handle_ho_preparation_complete(bool is_success, srslte::unique_byte_buffer_t container)
{
if (not is_success) {
log_h->info("Received S1AP HandoverFailure. Aborting Handover...\n");
log_h->info("Received S1AP HandoverFailure. Aborting Handover...");
trigger(srslte::failure_ev{});
return;
}
@ -392,15 +392,15 @@ void rrc::ue::rrc_mobility::handle_ho_preparation_complete(bool is_success, srsl
{
asn1::cbit_ref bref(container->msg, container->N_bytes);
if (rrchocmd.unpack(bref) != asn1::SRSASN_SUCCESS) {
get_log()->warning("Unpacking of RRC HOCommand was unsuccessful\n");
get_log()->warning_hex(container->msg, container->N_bytes, "Received container:\n");
get_log()->warning("Unpacking of RRC HOCommand was unsuccessful");
get_log()->warning_hex(container->msg, container->N_bytes, "Received container:");
trigger(ho_cancel_ev{});
return;
}
}
if (rrchocmd.crit_exts.type().value != c1_or_crit_ext_opts::c1 or
rrchocmd.crit_exts.c1().type().value != ho_cmd_s::crit_exts_c_::c1_c_::types_opts::ho_cmd_r8) {
get_log()->warning("Only handling r8 Handover Commands\n");
get_log()->warning("Only handling r8 Handover Commands");
trigger(ho_cancel_ev{});
return;
}
@ -492,7 +492,7 @@ bool rrc::ue::rrc_mobility::start_enb_status_transfer()
b.erab_id = erab_pair.second.id;
srslte::pdcp_lte_state_t pdcp_state = {};
if (not rrc_enb->pdcp->get_bearer_state(rrc_ue->rnti, lcid, &pdcp_state)) {
Error("PDCP bearer lcid=%d for rnti=0x%x was not found\n", lcid, rrc_ue->rnti);
Error("PDCP bearer lcid=%d for rnti=0x%x was not found", lcid, rrc_ue->rnti);
return false;
}
b.dl_hfn = pdcp_state.tx_hfn;
@ -502,7 +502,7 @@ bool rrc::ue::rrc_mobility::start_enb_status_transfer()
s1ap_bearers.push_back(b);
}
Info("PDCP Bearer list sent to S1AP to initiate the eNB Status Transfer\n");
Info("PDCP Bearer list sent to S1AP to initiate the eNB Status Transfer");
return rrc_enb->s1ap->send_enb_status_transfer_proc(rrc_ue->rnti, s1ap_bearers);
}
@ -538,7 +538,7 @@ void rrc::ue::rrc_mobility::s1_source_ho_st::wait_ho_req_ack_st::enter(s1_source
{
srslte::console("Starting S1 Handover of rnti=0x%x to cellid=0x%x.\n", f->parent_fsm()->rrc_ue->rnti, ev.target_eci);
f->get_log()->info(
"Starting S1 Handover of rnti=0x%x to cellid=0x%x.\n", f->parent_fsm()->rrc_ue->rnti, ev.target_eci);
"Starting S1 Handover of rnti=0x%x to cellid=0x%x.", f->parent_fsm()->rrc_ue->rnti, ev.target_eci);
f->report = ev;
bool success = f->parent_fsm()->start_ho_preparation(f->report.target_eci, f->report.meas_obj->meas_obj_id, false);
@ -554,20 +554,20 @@ void rrc::ue::rrc_mobility::s1_source_ho_st::send_ho_cmd(wait_ho_req_ack_st& s,
{
asn1::cbit_ref bref(&ho_cmd.ho_cmd_msg[0], ho_cmd.ho_cmd_msg.size());
if (dl_dcch_msg.unpack(bref) != asn1::SRSASN_SUCCESS) {
get_log()->warning("Unpacking of RRC DL-DCCH message with HO Command was unsuccessful.\n");
get_log()->warning("Unpacking of RRC DL-DCCH message with HO Command was unsuccessful.");
trigger(ho_cancel_ev{});
return;
}
}
if (dl_dcch_msg.msg.type().value != dl_dcch_msg_type_c::types_opts::c1 or
dl_dcch_msg.msg.c1().type().value != dl_dcch_msg_type_c::c1_c_::types_opts::rrc_conn_recfg) {
get_log()->warning("HandoverCommand is expected to contain an RRC Connection Reconf message inside\n");
get_log()->warning("HandoverCommand is expected to contain an RRC Connection Reconf message inside");
trigger(ho_cancel_ev{});
return;
}
asn1::rrc::rrc_conn_recfg_s& reconf = dl_dcch_msg.msg.c1().rrc_conn_recfg();
if (not reconf.crit_exts.c1().rrc_conn_recfg_r8().mob_ctrl_info_present) {
get_log()->warning("HandoverCommand is expected to have mobility control subfield\n");
get_log()->warning("HandoverCommand is expected to have mobility control subfield");
trigger(ho_cancel_ev{});
return;
}
@ -591,7 +591,7 @@ void rrc::ue::rrc_mobility::s1_source_ho_st::handle_ho_cancel(const ho_cancel_ev
void rrc::ue::rrc_mobility::s1_source_ho_st::status_transfer_st::enter(s1_source_ho_st* f)
{
f->get_log()->info("HandoverCommand of rnti=0x%x handled successfully.\n", f->parent_fsm()->rrc_ue->rnti);
f->get_log()->info("HandoverCommand of rnti=0x%x handled successfully.", f->parent_fsm()->rrc_ue->rnti);
// TODO: Do anything with MeasCfg info within the Msg (e.g. update ue_var_meas)?
@ -613,13 +613,13 @@ void rrc::ue::rrc_mobility::handle_ho_req(idle_st& s, const ho_req_rx_ev& ho_req
asn1::cbit_ref bref{rrc_container.data(), rrc_container.size()};
asn1::rrc::ho_prep_info_s hoprep;
if (hoprep.unpack(bref) != asn1::SRSASN_SUCCESS) {
rrc_enb->rrc_log->error("Failed to decode HandoverPreparationinformation in S1AP SourceENBToTargetENBContainer\n");
rrc_enb->logger.error("Failed to decode HandoverPreparationinformation in S1AP SourceENBToTargetENBContainer");
trigger(srslte::failure_ev{});
return;
}
if (hoprep.crit_exts.type().value != c1_or_crit_ext_opts::c1 or
hoprep.crit_exts.c1().type().value != ho_prep_info_s::crit_exts_c_::c1_c_::types_opts::ho_prep_info_r8) {
rrc_enb->rrc_log->error("Only release 8 supported\n");
rrc_enb->logger.error("Only release 8 supported");
trigger(srslte::failure_ev{});
return;
}
@ -657,7 +657,7 @@ void rrc::ue::rrc_mobility::handle_ho_req(idle_st& s, const ho_req_rx_ev& ho_req
srslte::unique_byte_buffer_t ho_cmd_pdu = srslte::allocate_unique_buffer(*pool);
asn1::bit_ref bref2{ho_cmd_pdu->msg, ho_cmd_pdu->get_tailroom()};
if (dl_dcch_msg.pack(bref2) != asn1::SRSASN_SUCCESS) {
rrc_log->error("Failed to pack HandoverCommand\n");
logger.error("Failed to pack HandoverCommand");
trigger(srslte::failure_ev{});
return;
}
@ -670,7 +670,7 @@ void rrc::ue::rrc_mobility::handle_ho_req(idle_st& s, const ho_req_rx_ev& ho_req
memcpy(ho_cmd_r8.ho_cmd_msg.data(), ho_cmd_pdu->msg, bref2.distance_bytes());
bref2 = {ho_cmd_pdu->msg, ho_cmd_pdu->get_tailroom()};
if (ho_cmd.pack(bref2) != asn1::SRSASN_SUCCESS) {
rrc_log->error("Failed to pack HandoverCommand\n");
logger.error("Failed to pack HandoverCommand");
trigger(srslte::failure_ev{});
return;
}
@ -707,10 +707,10 @@ bool rrc::ue::rrc_mobility::apply_ho_prep_cfg(const ho_prep_info_r8_ies_s& ho
for (const auto& erab_item : ho_req_msg.protocol_ies.erab_to_be_setup_list_ho_req.value) {
auto& erab = erab_item.value.erab_to_be_setup_item_ho_req();
if (erab.ext) {
get_log()->warning("Not handling E-RABToBeSetupList extensions\n");
get_log()->warning("Not handling E-RABToBeSetupList extensions");
}
if (erab.transport_layer_address.length() > 32) {
get_log()->error("IPv6 addresses not currently supported\n");
get_log()->error("IPv6 addresses not currently supported");
trigger(srslte::failure_ev{});
return false;
}
@ -718,7 +718,7 @@ bool rrc::ue::rrc_mobility::apply_ho_prep_cfg(const ho_prep_info_r8_ies_s& ho
if (not erab.ie_exts_present or not erab.ie_exts.data_forwarding_not_possible_present or
erab.ie_exts.data_forwarding_not_possible.ext.value !=
asn1::s1ap::data_forwarding_not_possible_opts::data_forwarding_not_possible) {
get_log()->warning("Data Forwarding of E-RABs not supported\n");
get_log()->warning("Data Forwarding of E-RABs not supported");
}
uint32_t teid_out;
@ -740,13 +740,13 @@ bool rrc::ue::rrc_mobility::apply_ho_prep_cfg(const ho_prep_info_r8_ies_s& ho
if (cap.rat_type.value == rat_type_opts::eutra) {
asn1::cbit_ref bref(cap.ue_cap_rat_container.data(), cap.ue_cap_rat_container.size());
if (rrc_ue->eutra_capabilities.unpack(bref) != asn1::SRSASN_SUCCESS) {
rrc_log->warning("Failed to unpack UE EUTRA Capability\n");
logger.warning("Failed to unpack UE EUTRA Capability");
continue;
}
if (rrc_log->get_level() == srslte::LOG_LEVEL_DEBUG) {
if (logger.debug.enabled()) {
asn1::json_writer js{};
rrc_ue->eutra_capabilities.to_json(js);
rrc_log->debug_long("New rnti=0x%x EUTRA capabilities: %s\n", rrc_ue->rnti, js.to_string().c_str());
logger.debug("New rnti=0x%x EUTRA capabilities: %s", rrc_ue->rnti, js.to_string().c_str());
}
rrc_ue->ue_capabilities = srslte::make_rrc_ue_capabilities(rrc_ue->eutra_capabilities);
rrc_ue->eutra_capabilities_unpacked = true;
@ -771,7 +771,7 @@ bool rrc::ue::rrc_mobility::apply_ho_prep_cfg(const ho_prep_info_r8_ies_s& ho
void rrc::ue::rrc_mobility::handle_recfg_complete(wait_recfg_comp& s, const recfg_complete_ev& ev)
{
ue_cell_ded* target_cell = rrc_ue->ue_cell_list.get_ue_cc_idx(UE_PCELL_CC_IDX);
rrc_log->info("User rnti=0x%x successfully handovered to cell_id=0x%x\n",
logger.info("User rnti=0x%x successfully handovered to cell_id=0x%x",
rrc_ue->rnti,
target_cell->cell_common->cell_cfg.cell_id);
uint64_t target_eci = (rrc_enb->cfg.enb_id << 8u) + target_cell->cell_common->cell_cfg.cell_id;
@ -789,7 +789,7 @@ void rrc::ue::rrc_mobility::handle_status_transfer(s1_target_ho_st& s, const sta
const auto& erab_item = erab.value.bearers_subject_to_status_transfer_item();
auto erab_it = rrc_ue->bearer_list.get_erabs().find(erab_item.erab_id);
if (erab_it == rrc_ue->bearer_list.get_erabs().end()) {
rrc_log->warning("The E-RAB Id=%d is not recognized\n", erab_item.erab_id);
logger.warning("The E-RAB Id=%d is not recognized", erab_item.erab_id);
continue;
}
const auto& drbs = rrc_ue->bearer_list.get_established_drbs();
@ -797,7 +797,7 @@ void rrc::ue::rrc_mobility::handle_status_transfer(s1_target_ho_st& s, const sta
auto drb_it =
std::find_if(drbs.begin(), drbs.end(), [drbid](const drb_to_add_mod_s& drb) { return drb.drb_id == drbid; });
if (drb_it == drbs.end()) {
rrc_log->warning("The DRB id=%d does not exist\n", erab_item.erab_id - 4);
logger.warning("The DRB id=%d does not exist", erab_item.erab_id - 4);
}
srslte::pdcp_lte_state_t drb_state{};
@ -806,7 +806,7 @@ void rrc::ue::rrc_mobility::handle_status_transfer(s1_target_ho_st& s, const sta
drb_state.rx_hfn = erab_item.ul_coun_tvalue.hfn;
drb_state.next_pdcp_rx_sn = erab_item.ul_coun_tvalue.pdcp_sn;
drb_state.last_submitted_pdcp_rx_sn = erab_item.ul_coun_tvalue.pdcp_sn;
rrc_log->info("Setting lcid=%d PDCP state to {Tx SN: %d, Rx SN: %d}\n",
logger.info("Setting lcid=%d PDCP state to {Tx SN: %d, Rx SN: %d}",
drb_it->lc_ch_id,
drb_state.next_pdcp_tx_sn,
drb_state.next_pdcp_rx_sn);
@ -835,12 +835,12 @@ void rrc::ue::rrc_mobility::intraenb_ho_st::enter(rrc_mobility* f, const ho_meas
target_cell = f->rrc_enb->cell_common_list->get_cell_id(cell_id);
source_cell = f->rrc_ue->ue_cell_list.get_ue_cc_idx(UE_PCELL_CC_IDX)->cell_common;
if (target_cell == nullptr) {
f->log_h->error("The target cell_id=0x%x was not found in the list of eNB cells\n", cell_id);
f->log_h->error("The target cell_id=0x%x was not found in the list of eNB cells", cell_id);
f->trigger(srslte::failure_ev{});
return;
}
f->log_h->info("Starting intraeNB Handover of rnti=0x%x to 0x%x.\n", f->rrc_ue->rnti, meas_report.target_eci);
f->log_h->info("Starting intraeNB Handover of rnti=0x%x to 0x%x.", f->rrc_ue->rnti, meas_report.target_eci);
if (target_cell == nullptr) {
f->trigger(srslte::failure_ev{});
@ -875,7 +875,7 @@ void rrc::ue::rrc_mobility::intraenb_ho_st::enter(rrc_mobility* f, const ho_meas
void rrc::ue::rrc_mobility::handle_crnti_ce(intraenb_ho_st& s, const user_crnti_upd_ev& ev)
{
rrc_log->info("UE performing handover updated its temp-crnti=0x%x to rnti=0x%x\n", ev.temp_crnti, ev.crnti);
logger.info("UE performing handover updated its temp-crnti=0x%x to rnti=0x%x", ev.temp_crnti, ev.crnti);
bool is_first_crnti_ce = s.last_temp_crnti == SRSLTE_INVALID_RNTI;
s.last_temp_crnti = ev.temp_crnti;
@ -894,14 +894,14 @@ void rrc::ue::rrc_mobility::handle_crnti_ce(intraenb_ho_st& s, const user_crnti_
rrc_ue->apply_pdcp_srb_updates(rrc_ue->current_ue_cfg.rr_cfg);
rrc_ue->apply_pdcp_drb_updates(rrc_ue->current_ue_cfg.rr_cfg);
} else {
rrc_log->info("Received duplicate C-RNTI CE during rnti=0x%x handover.\n", rrc_ue->rnti);
logger.info("Received duplicate C-RNTI CE during rnti=0x%x handover.", rrc_ue->rnti);
}
}
void rrc::ue::rrc_mobility::handle_recfg_complete(intraenb_ho_st& s, const recfg_complete_ev& ev)
{
rrc_log->info(
"User rnti=0x%x successfully handovered to cell_id=0x%x\n", rrc_ue->rnti, s.target_cell->cell_cfg.cell_id);
logger.info(
"User rnti=0x%x successfully handovered to cell_id=0x%x", rrc_ue->rnti, s.target_cell->cell_cfg.cell_id);
}
} // namespace srsenb

@ -94,17 +94,15 @@ void rrc::ue::set_activity()
// re-start activity timer with current timeout value
activity_timer.run();
if (parent && parent->rrc_log) {
parent->rrc_log->debug("Activity registered for rnti=0x%x (timeout_value=%dms)\n", rnti, activity_timer.duration());
if (parent) {
parent->logger.debug("Activity registered for rnti=0x%x (timeout_value=%dms)", rnti, activity_timer.duration());
}
}
void rrc::ue::activity_timer_expired()
{
if (parent) {
if (parent->rrc_log) {
parent->rrc_log->info("Activity timer for rnti=0x%x expired after %d ms\n", rnti, activity_timer.time_elapsed());
}
parent->logger.info("Activity timer for rnti=0x%x expired after %d ms", rnti, activity_timer.time_elapsed());
if (parent->s1ap->user_exists(rnti)) {
parent->s1ap->user_release(rnti, asn1::s1ap::cause_radio_network_opts::user_inactivity);
@ -134,12 +132,12 @@ void rrc::ue::set_activity_timeout(const activity_timeout_type_t type)
deadline_ms = parent->cfg.inactivity_timeout_ms % 1000;
break;
default:
parent->rrc_log->error("Unknown timeout type %d", type);
parent->logger.error("Unknown timeout type %d", type);
}
uint32_t deadline = deadline_s * 1e3 + deadline_ms;
activity_timer.set(deadline, [this](uint32_t tid) { activity_timer_expired(); });
parent->rrc_log->debug("Setting timer for %s for rnti=0x%x to %dms\n", to_string(type).c_str(), rnti, deadline);
parent->logger.debug("Setting timer for %s for rnti=0x%x to %dms", to_string(type).c_str(), rnti, deadline);
set_activity();
}
@ -162,7 +160,7 @@ void rrc::ue::parse_ul_dcch(uint32_t lcid, srslte::unique_byte_buffer_t pdu)
asn1::cbit_ref bref(pdu->msg, pdu->N_bytes);
if (ul_dcch_msg.unpack(bref) != asn1::SRSASN_SUCCESS or
ul_dcch_msg.msg.type().value != ul_dcch_msg_type_c::types_opts::c1) {
parent->rrc_log->error("Failed to unpack UL-DCCH message\n");
parent->logger.error("Failed to unpack UL-DCCH message");
return;
}
@ -226,14 +224,14 @@ void rrc::ue::parse_ul_dcch(uint32_t lcid, srslte::unique_byte_buffer_t pdu)
if (mobility_handler != nullptr) {
mobility_handler->handle_ue_meas_report(ul_dcch_msg.msg.c1().meas_report());
} else {
parent->rrc_log->warning("Received MeasReport but no mobility configuration is available\n");
parent->logger.warning("Received MeasReport but no mobility configuration is available");
}
break;
case ul_dcch_msg_type_c::c1_c_::types::ue_info_resp_r9:
handle_ue_info_resp(ul_dcch_msg.msg.c1().ue_info_resp_r9());
break;
default:
parent->rrc_log->error("Msg: %s not supported\n", ul_dcch_msg.msg.c1().type().to_string().c_str());
parent->logger.error("Msg: %s not supported", ul_dcch_msg.msg.c1().type().to_string().c_str());
break;
}
}
@ -250,7 +248,7 @@ std::string rrc::ue::to_string(const activity_timeout_type_t& type)
void rrc::ue::handle_rrc_con_req(rrc_conn_request_s* msg)
{
if (not parent->s1ap->is_mme_connected()) {
parent->rrc_log->error("MME isn't connected. Sending Connection Reject\n");
parent->logger.error("MME isn't connected. Sending Connection Reject");
send_connection_reject();
return;
}
@ -303,7 +301,7 @@ void rrc::ue::handle_rrc_con_setup_complete(rrc_conn_setup_complete_s* msg, srsl
// Inform PHY about the configuration completion
parent->phy->complete_config(rnti);
parent->rrc_log->info("RRCConnectionSetupComplete transaction ID: %d\n", msg->rrc_transaction_id);
parent->logger.info("RRCConnectionSetupComplete transaction ID: %d", msg->rrc_transaction_id);
rrc_conn_setup_complete_r8_ies_s* msg_r8 = &msg->crit_exts.c1().rrc_conn_setup_complete_r8();
// TODO: msg->selected_plmn_id - used to select PLMN from SIB1 list
@ -353,11 +351,11 @@ void rrc::ue::send_connection_reject()
void rrc::ue::handle_rrc_con_reest_req(rrc_conn_reest_request_s* msg)
{
if (not parent->s1ap->is_mme_connected()) {
parent->rrc_log->error("MME isn't connected. Sending Connection Reject\n");
parent->logger.error("MME isn't connected. Sending Connection Reject");
send_connection_reject();
return;
}
parent->rrc_log->debug("rnti=0x%x, phyid=0x%x, smac=0x%x, cause=%s\n",
parent->logger.debug("rnti=0x%x, phyid=0x%x, smac=0x%x, cause=%s",
(uint32_t)msg->crit_exts.rrc_conn_reest_request_r8().ue_id.c_rnti.to_number(),
msg->crit_exts.rrc_conn_reest_request_r8().ue_id.pci,
(uint32_t)msg->crit_exts.rrc_conn_reest_request_r8().ue_id.short_mac_i.to_number(),
@ -370,7 +368,7 @@ void rrc::ue::handle_rrc_con_reest_req(rrc_conn_reest_request_s* msg)
// Reject unrecognized rntis, and PCIs that do not belong to eNB
if (ue_it != parent->users.end() and old_cell != nullptr and
ue_it->second->ue_cell_list.get_enb_cc_idx(old_cell->enb_cc_idx) != nullptr) {
parent->rrc_log->info("ConnectionReestablishmentRequest for rnti=0x%x. Sending Connection Reestablishment\n",
parent->logger.info("ConnectionReestablishmentRequest for rnti=0x%x. Sending Connection Reestablishment",
old_rnti);
// Cancel Handover in Target eNB if on-going
@ -390,9 +388,9 @@ void rrc::ue::handle_rrc_con_reest_req(rrc_conn_reest_request_s* msg)
old_reest_pdcp_state[lcid] = {};
parent->pdcp->get_bearer_state(old_rnti, lcid, &old_reest_pdcp_state[lcid]);
parent->rrc_log->debug("Getting PDCP state for E-RAB with LCID %d\n", lcid);
parent->rrc_log->debug("Got PDCP state: TX HFN %d, NEXT_PDCP_TX_SN %d, RX_HFN %d, NEXT_PDCP_RX_SN %d, "
"LAST_SUBMITTED_PDCP_RX_SN %d\n",
parent->logger.debug("Getting PDCP state for E-RAB with LCID %d", lcid);
parent->logger.debug("Got PDCP state: TX HFN %d, NEXT_PDCP_TX_SN %d, RX_HFN %d, NEXT_PDCP_RX_SN %d, "
"LAST_SUBMITTED_PDCP_RX_SN %d",
old_reest_pdcp_state[lcid].tx_hfn,
old_reest_pdcp_state[lcid].next_pdcp_tx_sn,
old_reest_pdcp_state[lcid].rx_hfn,
@ -404,21 +402,21 @@ void rrc::ue::handle_rrc_con_reest_req(rrc_conn_reest_request_s* msg)
eutra_capabilities = parent->users.at(old_rnti)->eutra_capabilities;
eutra_capabilities_unpacked = parent->users.at(old_rnti)->eutra_capabilities_unpacked;
ue_capabilities = parent->users.at(old_rnti)->ue_capabilities;
if (parent->rrc_log->get_level() == srslte::LOG_LEVEL_DEBUG) {
if (parent->logger.debug.enabled()) {
asn1::json_writer js{};
eutra_capabilities.to_json(js);
parent->rrc_log->debug_long("rnti=0x%x EUTRA capabilities: %s\n", rnti, js.to_string().c_str());
parent->logger.debug("rnti=0x%x EUTRA capabilities: %s", rnti, js.to_string().c_str());
}
old_reest_rnti = old_rnti;
state = RRC_STATE_WAIT_FOR_CON_REEST_COMPLETE;
set_activity_timeout(UE_INACTIVITY_TIMEOUT);
} else {
parent->rrc_log->error("Received ConnectionReestablishment for rnti=0x%x without context\n", old_rnti);
parent->logger.error("Received ConnectionReestablishment for rnti=0x%x without context", old_rnti);
send_connection_reest_rej();
}
} else {
parent->rrc_log->error("Received ReestablishmentRequest from an rnti=0x%x not in IDLE\n", rnti);
parent->logger.error("Received ReestablishmentRequest from an rnti=0x%x not in IDLE", rnti);
}
}
@ -457,7 +455,7 @@ void rrc::ue::handle_rrc_con_reest_complete(rrc_conn_reest_complete_s* msg, srsl
// Inform PHY about the configuration completion
parent->phy->complete_config(rnti);
parent->rrc_log->info("RRCConnectionReestablishComplete transaction ID: %d\n", msg->rrc_transaction_id);
parent->logger.info("RRCConnectionReestablishComplete transaction ID: %d", msg->rrc_transaction_id);
// TODO: msg->selected_plmn_id - used to select PLMN from SIB1 list
// TODO: if(msg->registered_mme_present) - the indicated MME should be used from a pool
@ -510,7 +508,7 @@ void rrc::ue::send_connection_reest_rej()
*/
void rrc::ue::send_connection_reconf(srslte::unique_byte_buffer_t pdu, bool phy_cfg_updated)
{
parent->rrc_log->debug("RRC state %d\n", state);
parent->logger.debug("RRC state %d", state);
update_scells();
@ -564,9 +562,8 @@ void rrc::ue::handle_rrc_reconf_complete(rrc_conn_recfg_complete_s* msg, srslte:
parent->phy->complete_config(rnti);
if (transaction_id != msg->rrc_transaction_id) {
parent->rrc_log->error("Expected RRCReconfigurationComplete with transaction ID: %d, got %d\n",
transaction_id,
msg->rrc_transaction_id);
parent->logger.error(
"Expected RRCReconfigurationComplete with transaction ID: %d, got %d", transaction_id, msg->rrc_transaction_id);
return;
}
@ -629,14 +626,14 @@ void rrc::ue::send_security_mode_command()
void rrc::ue::handle_security_mode_complete(security_mode_complete_s* msg)
{
parent->rrc_log->info("SecurityModeComplete transaction ID: %d\n", msg->rrc_transaction_id);
parent->logger.info("SecurityModeComplete transaction ID: %d", msg->rrc_transaction_id);
parent->pdcp->enable_encryption(rnti, RB_ID_SRB1);
}
void rrc::ue::handle_security_mode_failure(security_mode_fail_s* msg)
{
parent->rrc_log->info("SecurityModeFailure transaction ID: %d\n", msg->rrc_transaction_id);
parent->logger.info("SecurityModeFailure transaction ID: %d", msg->rrc_transaction_id);
}
/*
@ -658,29 +655,29 @@ void rrc::ue::send_ue_cap_enquiry()
bool rrc::ue::handle_ue_cap_info(ue_cap_info_s* msg)
{
parent->rrc_log->info("UECapabilityInformation transaction ID: %d\n", msg->rrc_transaction_id);
parent->logger.info("UECapabilityInformation transaction ID: %d", msg->rrc_transaction_id);
ue_cap_info_r8_ies_s* msg_r8 = &msg->crit_exts.c1().ue_cap_info_r8();
for (uint32_t i = 0; i < msg_r8->ue_cap_rat_container_list.size(); i++) {
if (msg_r8->ue_cap_rat_container_list[i].rat_type != rat_type_e::eutra) {
parent->rrc_log->warning("Not handling UE capability information for RAT type %s\n",
parent->logger.warning("Not handling UE capability information for RAT type %s",
msg_r8->ue_cap_rat_container_list[i].rat_type.to_string().c_str());
} else {
asn1::cbit_ref bref(msg_r8->ue_cap_rat_container_list[0].ue_cap_rat_container.data(),
msg_r8->ue_cap_rat_container_list[0].ue_cap_rat_container.size());
if (eutra_capabilities.unpack(bref) != asn1::SRSASN_SUCCESS) {
parent->rrc_log->error("Failed to unpack EUTRA capabilities message\n");
parent->logger.error("Failed to unpack EUTRA capabilities message");
return false;
}
if (parent->rrc_log->get_level() == srslte::LOG_LEVEL_DEBUG) {
if (parent->logger.debug.enabled()) {
asn1::json_writer js{};
eutra_capabilities.to_json(js);
parent->rrc_log->debug_long("rnti=0x%x EUTRA capabilities: %s\n", rnti, js.to_string().c_str());
parent->logger.debug("rnti=0x%x EUTRA capabilities: %s", rnti, js.to_string().c_str());
}
eutra_capabilities_unpacked = true;
ue_capabilities = srslte::make_rrc_ue_capabilities(eutra_capabilities);
parent->rrc_log->info("UE rnti: 0x%x category: %d\n", rnti, eutra_capabilities.ue_category);
parent->logger.info("UE rnti: 0x%x category: %d", rnti, eutra_capabilities.ue_category);
}
}
@ -724,40 +721,40 @@ void rrc::ue::send_connection_release()
void rrc::ue::handle_ue_init_ctxt_setup_req(const asn1::s1ap::init_context_setup_request_s& msg)
{
if (msg.protocol_ies.add_cs_fallback_ind_present) {
parent->rrc_log->warning("Not handling AdditionalCSFallbackIndicator\n");
parent->logger.warning("Not handling AdditionalCSFallbackIndicator");
}
if (msg.protocol_ies.csg_membership_status_present) {
parent->rrc_log->warning("Not handling CSGMembershipStatus\n");
parent->logger.warning("Not handling CSGMembershipStatus");
}
if (msg.protocol_ies.gummei_id_present) {
parent->rrc_log->warning("Not handling GUMMEI_ID\n");
parent->logger.warning("Not handling GUMMEI_ID");
}
if (msg.protocol_ies.ho_restrict_list_present) {
parent->rrc_log->warning("Not handling HandoverRestrictionList\n");
parent->logger.warning("Not handling HandoverRestrictionList");
}
if (msg.protocol_ies.management_based_mdt_allowed_present) {
parent->rrc_log->warning("Not handling ManagementBasedMDTAllowed\n");
parent->logger.warning("Not handling ManagementBasedMDTAllowed");
}
if (msg.protocol_ies.management_based_mdtplmn_list_present) {
parent->rrc_log->warning("Not handling ManagementBasedMDTPLMNList\n");
parent->logger.warning("Not handling ManagementBasedMDTPLMNList");
}
if (msg.protocol_ies.mme_ue_s1ap_id_minus2_present) {
parent->rrc_log->warning("Not handling MME_UE_S1AP_ID_2\n");
parent->logger.warning("Not handling MME_UE_S1AP_ID_2");
}
if (msg.protocol_ies.registered_lai_present) {
parent->rrc_log->warning("Not handling RegisteredLAI\n");
parent->logger.warning("Not handling RegisteredLAI");
}
if (msg.protocol_ies.srvcc_operation_possible_present) {
parent->rrc_log->warning("Not handling SRVCCOperationPossible\n");
parent->logger.warning("Not handling SRVCCOperationPossible");
}
if (msg.protocol_ies.subscriber_profile_idfor_rfp_present) {
parent->rrc_log->warning("Not handling SubscriberProfileIDforRFP\n");
parent->logger.warning("Not handling SubscriberProfileIDforRFP");
}
if (msg.protocol_ies.trace_activation_present) {
parent->rrc_log->warning("Not handling TraceActivation\n");
parent->logger.warning("Not handling TraceActivation");
}
if (msg.protocol_ies.ue_radio_cap_present) {
parent->rrc_log->warning("Not handling UERadioCapability\n");
parent->logger.warning("Not handling UERadioCapability");
}
set_bitrates(msg.protocol_ies.ueaggregate_maximum_bitrate.value);
@ -790,16 +787,16 @@ bool rrc::ue::handle_ue_ctxt_mod_req(const asn1::s1ap::ue_context_mod_request_s&
}
if (msg.protocol_ies.add_cs_fallback_ind_present) {
parent->rrc_log->warning("Not handling AdditionalCSFallbackIndicator\n");
parent->logger.warning("Not handling AdditionalCSFallbackIndicator");
}
if (msg.protocol_ies.csg_membership_status_present) {
parent->rrc_log->warning("Not handling CSGMembershipStatus\n");
parent->logger.warning("Not handling CSGMembershipStatus");
}
if (msg.protocol_ies.registered_lai_present) {
parent->rrc_log->warning("Not handling RegisteredLAI\n");
parent->logger.warning("Not handling RegisteredLAI");
}
if (msg.protocol_ies.subscriber_profile_idfor_rfp_present) {
parent->rrc_log->warning("Not handling SubscriberProfileIDforRFP\n");
parent->logger.warning("Not handling SubscriberProfileIDforRFP");
}
// UEAggregateMaximumBitrate
@ -847,13 +844,13 @@ bool rrc::ue::setup_erabs(const asn1::s1ap::erab_to_be_setup_list_ctxt_su_req_l&
for (const auto& item : e) {
auto& erab = item.value.erab_to_be_setup_item_ctxt_su_req();
if (erab.ext) {
parent->rrc_log->warning("Not handling E-RABToBeSetupListCtxtSURequest extensions\n");
parent->logger.warning("Not handling E-RABToBeSetupListCtxtSURequest extensions");
}
if (erab.ie_exts_present) {
parent->rrc_log->warning("Not handling E-RABToBeSetupListCtxtSURequest extensions\n");
parent->logger.warning("Not handling E-RABToBeSetupListCtxtSURequest extensions");
}
if (erab.transport_layer_address.length() > 32) {
parent->rrc_log->error("IPv6 addresses not currently supported\n");
parent->logger.error("IPv6 addresses not currently supported");
return false;
}
@ -871,13 +868,13 @@ bool rrc::ue::setup_erabs(const asn1::s1ap::erab_to_be_setup_list_bearer_su_req_
for (const auto& item : e) {
auto& erab = item.value.erab_to_be_setup_item_bearer_su_req();
if (erab.ext) {
parent->rrc_log->warning("Not handling E-RABToBeSetupListBearerSUReq extensions\n");
parent->logger.warning("Not handling E-RABToBeSetupListBearerSUReq extensions");
}
if (erab.ie_exts_present) {
parent->rrc_log->warning("Not handling E-RABToBeSetupListBearerSUReq extensions\n");
parent->logger.warning("Not handling E-RABToBeSetupListBearerSUReq extensions");
}
if (erab.transport_layer_address.length() > 32) {
parent->rrc_log->error("IPv6 addresses not currently supported\n");
parent->logger.error("IPv6 addresses not currently supported");
return false;
}
@ -970,7 +967,7 @@ void rrc::ue::update_scells()
not eutra_capabilities.non_crit_ext.non_crit_ext.non_crit_ext.rf_params_v1020_present or
eutra_capabilities.non_crit_ext.non_crit_ext.non_crit_ext.rf_params_v1020.supported_band_combination_r10.size() ==
0) {
parent->rrc_log->info("UE doesn't support CA. Skipping SCell activation\n");
parent->logger.info("UE doesn't support CA. Skipping SCell activation");
return;
}
@ -978,7 +975,7 @@ void rrc::ue::update_scells()
ue_cell_list.add_cell(scell->enb_cc_idx);
}
parent->rrc_log->info("SCells activated for rnti=0x%x\n", rnti);
parent->logger.info("SCells activated for rnti=0x%x", rnti);
}
/********************** Handover **************************/
@ -997,7 +994,7 @@ void rrc::ue::send_dl_ccch(dl_ccch_msg_s* dl_ccch_msg)
if (pdu) {
asn1::bit_ref bref(pdu->msg, pdu->get_tailroom());
if (dl_ccch_msg->pack(bref) != asn1::SRSASN_SUCCESS) {
parent->rrc_log->error_hex(pdu->msg, pdu->N_bytes, "Failed to pack DL-CCCH-Msg:\n");
parent->logger.error(pdu->msg, pdu->N_bytes, "Failed to pack DL-CCCH-Msg:");
return;
}
pdu->N_bytes = (uint32_t)bref.distance_bytes();
@ -1007,7 +1004,7 @@ void rrc::ue::send_dl_ccch(dl_ccch_msg_s* dl_ccch_msg)
parent->log_rrc_message(buf, Tx, pdu.get(), *dl_ccch_msg, dl_ccch_msg->msg.c1().type().to_string());
parent->rlc->write_sdu(rnti, RB_ID_SRB0, std::move(pdu));
} else {
parent->rrc_log->error("Allocating pdu\n");
parent->logger.error("Allocating pdu");
}
}
@ -1019,7 +1016,7 @@ bool rrc::ue::send_dl_dcch(const dl_dcch_msg_s* dl_dcch_msg, srslte::unique_byte
if (pdu) {
asn1::bit_ref bref(pdu->msg, pdu->get_tailroom());
if (dl_dcch_msg->pack(bref) == asn1::SRSASN_ERROR_ENCODE_FAIL) {
parent->rrc_log->error("Failed to encode DL-DCCH-Msg\n");
parent->logger.error("Failed to encode DL-DCCH-Msg");
return false;
}
pdu->N_bytes = (uint32_t)bref.distance_bytes();
@ -1034,7 +1031,7 @@ bool rrc::ue::send_dl_dcch(const dl_dcch_msg_s* dl_dcch_msg, srslte::unique_byte
parent->pdcp->write_sdu(rnti, lcid, std::move(pdu));
} else {
parent->rrc_log->error("Allocating pdu\n");
parent->logger.error("Allocating pdu");
return false;
}
return true;
@ -1197,8 +1194,8 @@ void rrc::ue::apply_pdcp_drb_updates(const rr_cfg_ded_s& pending_rr_cfg)
bool is_am = parent->cfg.qci_cfg[erab_pair.second.qos_params.qci].rlc_cfg.type().value ==
asn1::rrc::rlc_cfg_c::types_opts::am;
if (is_am) {
parent->rrc_log->debug("Set PDCP state: TX HFN %d, NEXT_PDCP_TX_SN %d, RX_HFN %d, NEXT_PDCP_RX_SN %d, "
"LAST_SUBMITTED_PDCP_RX_SN %d\n",
parent->logger.debug("Set PDCP state: TX HFN %d, NEXT_PDCP_TX_SN %d, RX_HFN %d, NEXT_PDCP_RX_SN %d, "
"LAST_SUBMITTED_PDCP_RX_SN %d",
old_reest_pdcp_state[lcid].tx_hfn,
old_reest_pdcp_state[lcid].next_pdcp_tx_sn,
old_reest_pdcp_state[lcid].rx_hfn,
@ -1216,11 +1213,11 @@ void rrc::ue::apply_rlc_rb_updates(const rr_cfg_ded_s& pending_rr_cfg)
parent->rlc->add_bearer(rnti, srb.srb_id, srslte::rlc_config_t::srb_config(srb.srb_id));
}
if (pending_rr_cfg.drb_to_release_list.size() > 0) {
parent->rrc_log->error("Removing DRBs not currently supported\n");
parent->logger.error("Removing DRBs not currently supported");
}
for (const drb_to_add_mod_s& drb : pending_rr_cfg.drb_to_add_mod_list) {
if (not drb.rlc_cfg_present) {
parent->rrc_log->warning("Default RLC DRB config not supported\n");
parent->logger.warning("Default RLC DRB config not supported");
}
parent->rlc->add_bearer(rnti, drb.lc_ch_id, srslte::make_rlc_config_t(drb.rlc_cfg));
}
@ -1234,7 +1231,7 @@ int rrc::ue::get_cqi(uint16_t* pmi_idx, uint16_t* n_pucch, uint32_t ue_cc_idx)
*n_pucch = c->cqi_res.pucch_res;
return SRSLTE_SUCCESS;
} else {
parent->rrc_log->error("CQI resources for ue_cc_idx=%d have not been allocated\n", ue_cc_idx);
parent->logger.error("CQI resources for ue_cc_idx=%d have not been allocated", ue_cc_idx);
return SRSLTE_ERROR;
}
}
@ -1273,7 +1270,7 @@ int rrc::ue::get_ri(uint32_t m_ri, uint16_t* ri_idx)
I_ri = 805 - N_offset_ri;
break;
default:
parent->rrc_log->error("Allocating RI: invalid m_ri=%d\n", m_ri);
parent->logger.error("Allocating RI: invalid m_ri=%d", m_ri);
}
// If ri_dix is available, copy

@ -22,7 +22,6 @@ namespace srsenb {
* measObjToAddMod
**********************************/
bool is_same_earfcn(const meas_obj_t& lhs, const meas_obj_t& rhs)
{
int freq1 = srslte::get_carrier_freq(lhs);
@ -247,7 +246,7 @@ meas_gap_cfg_c make_measgap(const meas_obj_list& measobjs, const ue_cell_ded& pc
case 0: // no meas gaps configured
break;
default:
srslte::logmap::get("RRC")->error("Error setting measurement gap.\n");
srslog::fetch_basic_logger("RRC").error("Error setting measurement gap.");
}
return meas_gap;
}
@ -285,7 +284,7 @@ bool apply_meas_gap_updates(const meas_gap_cfg_c& src_gaps,
}
break;
default:
srslte::logmap::get("RRC")->warning("MeasGap of type %s not supported\n",
srslog::fetch_basic_logger("RRC").warning("MeasGap of type %s not supported",
target_offset.type().to_string().c_str());
}
}
@ -327,9 +326,7 @@ bool fill_meascfg_enb_cfg(meas_cfg_s& meascfg, const ue_cell_ded_list& ue_cell_l
for (uint32_t ue_cc_idx = 0; ue_cc_idx < ue_cell_list.nof_cells(); ++ue_cc_idx) {
sorted_ue_cells[ue_cc_idx] = ue_cell_list.get_ue_cc_idx(ue_cc_idx);
}
std::sort(sorted_ue_cells.begin(),
sorted_ue_cells.end(),
[](const ue_cell_ded* cc1, const ue_cell_ded* cc2) {
std::sort(sorted_ue_cells.begin(), sorted_ue_cells.end(), [](const ue_cell_ded* cc1, const ue_cell_ded* cc2) {
return cc1->get_dl_earfcn() < cc2->get_dl_earfcn();
});
for (auto* cc : sorted_ue_cells) {

@ -36,7 +36,7 @@ namespace srsenb {
srb_to_add_mod_s* add_srb(srb_to_add_mod_list_l& srbs, uint8_t srb_id)
{
if (srb_id > 2 or srb_id == 0) {
srslte::logmap::get("RRC")->error("Invalid SRB id=%d\n", srb_id);
srslog::fetch_basic_logger("RRC").error("Invalid SRB id=%d", srb_id);
return nullptr;
}
@ -105,7 +105,7 @@ int16_t get_ri(uint32_t m_ri)
ri_idx = 805 - N_offset_ri;
break;
default:
srslte::logmap::get("RRC")->error("Allocating RI: invalid m_ri=%d\n", m_ri);
srslog::fetch_basic_logger("RRC").error("Allocating RI: invalid m_ri=%d", m_ri);
return -1;
}
@ -135,7 +135,7 @@ int fill_cqi_report_setup(cqi_report_cfg_s& cqi_rep, const rrc_cfg_t& enb_cfg, c
if (cqi_rep.cqi_report_periodic_present) {
const ue_cell_ded* pcell = ue_cell_list.get_ue_cc_idx(UE_PCELL_CC_IDX);
if (pcell == nullptr or not pcell->cqi_res_present) {
srslte::logmap::get("RRC")->warning("PCell CQI resources haven\'t been allocated yet\n");
srslog::fetch_basic_logger("RRC").warning("PCell CQI resources haven\'t been allocated yet");
return SRSLTE_ERROR;
}
auto& cqi_periodic = cqi_rep.cqi_report_periodic.setup();
@ -173,7 +173,7 @@ void fill_cqi_report_reconf(cqi_report_cfg_s& cqi_rep, const rrc_cfg_t& enb_cfg,
cqi_setup.ri_cfg_idx_present = true;
cqi_setup.ri_cfg_idx = ri_idx;
} else {
srslte::logmap::get("RRC")->warning("Warning: Configured wrong M_ri parameter.\n");
srslog::fetch_basic_logger("RRC").warning("Warning: Configured wrong M_ri parameter.");
}
}
}

@ -22,7 +22,7 @@
using namespace srslte;
namespace srsenb {
gtpu::gtpu() : m1u(this), gtpu_log("GTPU") {}
gtpu::gtpu(srslog::basic_logger& logger) : m1u(this), gtpu_log("GTPU"), logger(logger) {}
int gtpu::init(std::string gtp_bind_addr_,
std::string mme_addr_,
@ -43,17 +43,17 @@ int gtpu::init(std::string gtp_bind_addr_,
// Set up socket
fd = socket(AF_INET, SOCK_DGRAM, 0);
if (fd < 0) {
gtpu_log->error("Failed to create socket\n");
logger.error("Failed to create socket");
return SRSLTE_ERROR;
}
int enable = 1;
#if defined(SO_REUSEADDR)
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(int)) < 0)
gtpu_log->error("setsockopt(SO_REUSEADDR) failed\n");
logger.error("setsockopt(SO_REUSEADDR) failed");
#endif
#if defined(SO_REUSEPORT)
if (setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &enable, sizeof(int)) < 0)
gtpu_log->error("setsockopt(SO_REUSEPORT) failed\n");
logger.error("setsockopt(SO_REUSEPORT) failed");
#endif
struct sockaddr_in bindaddr;
@ -64,8 +64,8 @@ int gtpu::init(std::string gtp_bind_addr_,
if (bind(fd, (struct sockaddr*)&bindaddr, sizeof(struct sockaddr_in))) {
snprintf(errbuf, sizeof(errbuf), "%s", strerror(errno));
gtpu_log->error("Failed to bind on address %s, port %d: %s\n", gtp_bind_addr.c_str(), GTPU_PORT, errbuf);
srslte::console("Failed to bind on address %s, port %d: %s\n", gtp_bind_addr.c_str(), GTPU_PORT, errbuf);
logger.error("Failed to bind on address %s, port %d: %s", gtp_bind_addr.c_str(), int(GTPU_PORT), errbuf);
srslte::console("Failed to bind on address %s, port %d: %s\n", gtp_bind_addr.c_str(), int(GTPU_PORT), errbuf);
return SRSLTE_ERROR;
}
@ -91,21 +91,21 @@ void gtpu::stop()
// gtpu_interface_pdcp
void gtpu::write_pdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t pdu)
{
gtpu_log->info_hex(pdu->msg, pdu->N_bytes, "TX PDU, RNTI: 0x%x, LCID: %d, n_bytes=%d", rnti, lcid, pdu->N_bytes);
logger.info(pdu->msg, pdu->N_bytes, "TX PDU, RNTI: 0x%x, LCID: %d, n_bytes=%d", rnti, lcid, pdu->N_bytes);
// Check valid IP version
struct iphdr* ip_pkt = (struct iphdr*)pdu->msg;
if (ip_pkt->version != 4 && ip_pkt->version != 6) {
gtpu_log->error("Invalid IP version to SPGW\n");
logger.error("Invalid IP version to SPGW");
return;
}
if (ip_pkt->version == 4) {
if (ntohs(ip_pkt->tot_len) != pdu->N_bytes) {
gtpu_log->error("IP Len and PDU N_bytes mismatch\n");
logger.error("IP Len and PDU N_bytes mismatch");
}
gtpu_log->debug("Tx S1-U PDU -- IP version %d, Total length %d\n", ip_pkt->version, ntohs(ip_pkt->tot_len));
gtpu_log->debug("Tx S1-U PDU -- IP src addr %s\n", srslte::gtpu_ntoa(ip_pkt->saddr).c_str());
gtpu_log->debug("Tx S1-U PDU -- IP dst addr %s\n", srslte::gtpu_ntoa(ip_pkt->daddr).c_str());
logger.debug("Tx S1-U PDU -- IP version %d, Total length %d", int(ip_pkt->version), ntohs(ip_pkt->tot_len));
logger.debug("Tx S1-U PDU -- IP src addr %s", srslte::gtpu_ntoa(ip_pkt->saddr).c_str());
logger.debug("Tx S1-U PDU -- IP dst addr %s", srslte::gtpu_ntoa(ip_pkt->daddr).c_str());
}
gtpu_header_t header;
@ -120,7 +120,7 @@ void gtpu::write_pdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t
servaddr.sin_port = htons(GTPU_PORT);
if (!gtpu_write_header(&header, pdu.get(), gtpu_log)) {
gtpu_log->error("Error writing GTP-U Header. Flags 0x%x, Message Type 0x%x\n", header.flags, header.message_type);
logger.error("Error writing GTP-U Header. Flags 0x%x, Message Type 0x%x", header.flags, header.message_type);
return;
}
if (sendto(fd, pdu->msg, pdu->N_bytes, MSG_EOR, (struct sockaddr*)&servaddr, sizeof(struct sockaddr_in)) < 0) {
@ -129,21 +129,17 @@ void gtpu::write_pdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t
}
/* Warning: This function is called before calling gtpu::init() during MCCH initialization.
* If access to any element created in init (such as gtpu_log) is required, it must be considered
* the case of it being NULL.
*/
uint32_t gtpu::add_bearer(uint16_t rnti, uint32_t lcid, uint32_t addr, uint32_t teid_out)
{
// Allocate a TEID for the incoming tunnel
uint32_t teid_in = allocate_teidin(rnti, lcid);
if (gtpu_log) {
gtpu_log->info("Adding bearer for rnti: 0x%x, lcid: %d, addr: 0x%x, teid_out: 0x%x, teid_in: 0x%x\n",
logger.info("Adding bearer for rnti: 0x%x, lcid: %d, addr: 0x%x, teid_out: 0x%x, teid_in: 0x%x",
rnti,
lcid,
addr,
teid_out,
teid_in);
}
// Initialize maps if it's a new RNTI
if (rnti_bearers.count(rnti) == 0) {
@ -163,7 +159,7 @@ uint32_t gtpu::add_bearer(uint16_t rnti, uint32_t lcid, uint32_t addr, uint32_t
void gtpu::rem_bearer(uint16_t rnti, uint32_t lcid)
{
gtpu_log->info("Removing bearer for rnti: 0x%x, lcid: %d\n", rnti, lcid);
logger.info("Removing bearer for rnti: 0x%x, lcid: %d", rnti, lcid);
// Remove from TEID from map
free_teidin(rnti, lcid);
@ -186,14 +182,14 @@ void gtpu::rem_bearer(uint16_t rnti, uint32_t lcid)
void gtpu::mod_bearer_rnti(uint16_t old_rnti, uint16_t new_rnti)
{
gtpu_log->info("Modifying bearer rnti. Old rnti: 0x%x, new rnti: 0x%x\n", old_rnti, new_rnti);
logger.info("Modifying bearer rnti. Old rnti: 0x%x, new rnti: 0x%x", old_rnti, new_rnti);
if (rnti_bearers.count(new_rnti) != 0) {
gtpu_log->error("New rnti already exists, aborting.\n");
logger.error("New rnti already exists, aborting.");
return;
}
if (rnti_bearers.count(old_rnti) == 0) {
gtpu_log->error("Old rnti does not exist, aborting.\n");
logger.error("Old rnti does not exist, aborting.");
return;
}
@ -226,7 +222,7 @@ void gtpu::rem_user(uint16_t rnti)
void gtpu::handle_gtpu_s1u_rx_packet(srslte::unique_byte_buffer_t pdu, const sockaddr_in& addr)
{
gtpu_log->debug("Received %d bytes from S1-U interface\n", pdu->N_bytes);
logger.debug("Received %d bytes from S1-U interface", pdu->N_bytes);
pdu->set_timestamp();
gtpu_header_t header;
@ -254,38 +250,37 @@ void gtpu::handle_gtpu_s1u_rx_packet(srslte::unique_byte_buffer_t pdu, const soc
bool user_exists = (rnti_bearers.count(rnti) > 0);
if (not user_exists) {
gtpu_log->error("Unrecognized TEID In=%d for DL PDU. Dropping packet\n", header.teid);
logger.error("Unrecognized TEID In=%d for DL PDU. Dropping packet", header.teid);
return;
}
if (lcid < SRSENB_N_SRB || lcid >= SRSENB_N_RADIO_BEARERS) {
gtpu_log->error("Invalid LCID for DL PDU: %d - dropping packet\n", lcid);
logger.error("Invalid LCID for DL PDU: %d - dropping packet", lcid);
return;
}
gtpu_log->info_hex(
pdu->msg, pdu->N_bytes, "RX GTPU PDU rnti=0x%x, lcid=%d, n_bytes=%d", rnti, lcid, pdu->N_bytes);
logger.info(pdu->msg, pdu->N_bytes, "RX GTPU PDU rnti=0x%x, lcid=%d, n_bytes=%d", rnti, lcid, pdu->N_bytes);
struct iphdr* ip_pkt = (struct iphdr*)pdu->msg;
if (ip_pkt->version != 4 && ip_pkt->version != 6) {
gtpu_log->error("Invalid IP version to SPGW\n");
logger.error("Invalid IP version to SPGW");
return;
}
if (ip_pkt->version == 4) {
if (ntohs(ip_pkt->tot_len) != pdu->N_bytes) {
gtpu_log->error("IP Len and PDU N_bytes mismatch\n");
logger.error("IP Len and PDU N_bytes mismatch");
}
gtpu_log->debug("Rx S1-U PDU -- IP version %d, Total length %d\n", ip_pkt->version, ntohs(ip_pkt->tot_len));
gtpu_log->debug("Rx S1-U PDU -- IP src addr %s\n", srslte::gtpu_ntoa(ip_pkt->saddr).c_str());
gtpu_log->debug("Rx S1-U PDU -- IP dst addr %s\n", srslte::gtpu_ntoa(ip_pkt->daddr).c_str());
logger.debug("Rx S1-U PDU -- IP version %d, Total length %d", int(ip_pkt->version), ntohs(ip_pkt->tot_len));
logger.debug("Rx S1-U PDU -- IP src addr %s", srslte::gtpu_ntoa(ip_pkt->saddr).c_str());
logger.debug("Rx S1-U PDU -- IP dst addr %s", srslte::gtpu_ntoa(ip_pkt->daddr).c_str());
}
pdcp->write_sdu(rnti, lcid, std::move(pdu));
} break;
case GTPU_MSG_END_MARKER: {
rnti_lcid_t rnti_lcid = teidin_to_rntilcid(header.teid);
uint16_t rnti = rnti_lcid.rnti;
gtpu_log->info("Received GTPU End Marker for rnti=0x%x.\n", rnti);
logger.info("Received GTPU End Marker for rnti=0x%x.", rnti);
break;
}
default:
@ -303,7 +298,7 @@ void gtpu::handle_gtpu_m1u_rx_packet(srslte::unique_byte_buffer_t pdu, const soc
***************************************************************************/
void gtpu::error_indication(in_addr_t addr, in_port_t port, uint32_t err_teid)
{
gtpu_log->info("TX GTPU Error Indication. Seq: %d, Error TEID: %d\n", tx_seq, err_teid);
logger.info("TX GTPU Error Indication. Seq: %d, Error TEID: %d", tx_seq, err_teid);
gtpu_header_t header = {};
unique_byte_buffer_t pdu = allocate_unique_buffer(*pool);
@ -333,7 +328,7 @@ void gtpu::error_indication(in_addr_t addr, in_port_t port, uint32_t err_teid)
***************************************************************************/
void gtpu::echo_response(in_addr_t addr, in_port_t port, uint16_t seq)
{
gtpu_log->info("TX GTPU Echo Response, Seq: %d\n", seq);
logger.info("TX GTPU Echo Response, Seq: %d", seq);
gtpu_header_t header = {};
unique_byte_buffer_t pdu = allocate_unique_buffer(*pool);
@ -364,12 +359,12 @@ uint32_t gtpu::allocate_teidin(uint16_t rnti, uint16_t lcid)
{
uint32_t teid_in = ++next_teid_in;
if (teidin_to_rntilcid_map.count(teid_in) != 0) {
gtpu_log->error("TEID In already exists\n");
logger.error("TEID In already exists");
return 0;
}
rnti_lcid_t rnti_lcid = {rnti, lcid};
teidin_to_rntilcid_map[teid_in] = rnti_lcid;
gtpu_log->debug("TEID In=%d added\n", teid_in);
logger.debug("TEID In=%d added", teid_in);
return teid_in;
}
@ -378,7 +373,7 @@ void gtpu::free_teidin(uint16_t rnti, uint16_t lcid)
for (std::map<uint32_t, rnti_lcid_t>::iterator it = teidin_to_rntilcid_map.begin();
it != teidin_to_rntilcid_map.end();) {
if (it->second.rnti == rnti && it->second.lcid == lcid) {
gtpu_log->debug("TEID In=%d erased\n", it->first);
logger.debug("TEID In=%d erased", it->first);
it = teidin_to_rntilcid_map.erase(it);
} else {
it++;
@ -391,7 +386,7 @@ void gtpu::free_teidin(uint16_t rnti)
for (std::map<uint32_t, rnti_lcid_t>::iterator it = teidin_to_rntilcid_map.begin();
it != teidin_to_rntilcid_map.end();) {
if (it->second.rnti == rnti) {
gtpu_log->debug("TEID In=%d erased\n", it->first);
logger.debug("TEID In=%d erased", it->first);
it = teidin_to_rntilcid_map.erase(it);
} else {
it++;
@ -403,7 +398,7 @@ gtpu::rnti_lcid_t gtpu::teidin_to_rntilcid(uint32_t teidin)
{
rnti_lcid_t rnti_lcid = {};
if (teidin_to_rntilcid_map.count(teidin) == 0) {
gtpu_log->error("TEID=%d In does not exist.\n", teidin);
logger.error("TEID=%d In does not exist.", teidin);
return rnti_lcid;
}
rnti_lcid.rnti = teidin_to_rntilcid_map[teidin].rnti;
@ -420,7 +415,7 @@ uint32_t gtpu::rntilcid_to_teidin(uint16_t rnti, uint16_t lcid)
}
}
if (teidin == 0) {
gtpu_log->error("Could not find TEID. RNTI=0x%x, LCID=%d.\n", rnti, lcid);
logger.error("Could not find TEID. RNTI=0x%x, LCID=%d.", rnti, lcid);
}
return teidin;
}
@ -448,7 +443,7 @@ bool gtpu::m1u_handler::init(std::string m1u_multiaddr_, std::string m1u_if_addr
struct sockaddr_in bindaddr = {};
m1u_sd = socket(AF_INET, SOCK_DGRAM, 0);
if (m1u_sd < 0) {
gtpu_log->error("Failed to create M1-U sink socket\n");
logger.error("Failed to create M1-U sink socket");
return false;
}
@ -457,7 +452,7 @@ bool gtpu::m1u_handler::init(std::string m1u_multiaddr_, std::string m1u_if_addr
bindaddr.sin_addr.s_addr = htonl(INADDR_ANY); // Multicast sockets require bind to INADDR_ANY
bindaddr.sin_port = htons(GTPU_PORT + 1);
if (bind(m1u_sd, (struct sockaddr*)&bindaddr, sizeof(bindaddr)) < 0) {
gtpu_log->error("Failed to bind multicast socket\n");
logger.error("Failed to bind multicast socket");
return false;
}
@ -466,11 +461,11 @@ bool gtpu::m1u_handler::init(std::string m1u_multiaddr_, std::string m1u_if_addr
mreq.imr_multiaddr.s_addr = inet_addr(m1u_multiaddr.c_str()); // Multicast address of the service
mreq.imr_interface.s_addr = inet_addr(m1u_if_addr.c_str()); // Address of the IF the socket will listen to.
if (setsockopt(m1u_sd, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq)) < 0) {
gtpu_log->error("Register musticast group for M1-U\n");
gtpu_log->error("M1-U infterface IP: %s, M1-U Multicast Address %s\n", m1u_if_addr.c_str(), m1u_multiaddr.c_str());
logger.error("Register musticast group for M1-U");
logger.error("M1-U infterface IP: %s, M1-U Multicast Address %s", m1u_if_addr.c_str(), m1u_multiaddr.c_str());
return false;
}
gtpu_log->info("M1-U initialized\n");
logger.info("M1-U initialized");
initiated = true;
lcid_counter = 1;
@ -483,7 +478,7 @@ bool gtpu::m1u_handler::init(std::string m1u_multiaddr_, std::string m1u_if_addr
void gtpu::m1u_handler::handle_rx_packet(srslte::unique_byte_buffer_t pdu, const sockaddr_in& addr)
{
gtpu_log->debug("Received %d bytes from M1-U interface\n", pdu->N_bytes);
logger.debug("Received %d bytes from M1-U interface", pdu->N_bytes);
gtpu_header_t header;
gtpu_read_header(pdu.get(), &header, gtpu_log);

@ -15,10 +15,8 @@
namespace srsenb {
pdcp::pdcp(srslte::task_sched_handle task_sched_, const char* logname) :
task_sched(task_sched_),
log_h(logname),
pool(srslte::byte_buffer_pool::get_instance())
pdcp::pdcp(srslte::task_sched_handle task_sched_, srslog::basic_logger& logger) :
task_sched(task_sched_), logger(logger), pool(srslte::byte_buffer_pool::get_instance())
{}
void pdcp::init(rlc_interface_pdcp* rlc_, rrc_interface_pdcp* rrc_, gtpu_interface_pdcp* gtpu_)
@ -39,7 +37,7 @@ void pdcp::stop()
void pdcp::add_user(uint16_t rnti)
{
if (users.count(rnti) == 0) {
srslte::pdcp* obj = new srslte::pdcp(task_sched, log_h->get_service_name().c_str());
srslte::pdcp* obj = new srslte::pdcp(task_sched, logger.id().c_str());
obj->init(&users[rnti].rlc_itf, &users[rnti].rrc_itf, &users[rnti].gtpu_itf);
users[rnti].rlc_itf.rnti = rnti;
users[rnti].gtpu_itf.rnti = rnti;
@ -184,17 +182,17 @@ void pdcp::user_interface_rrc::write_pdu(uint32_t lcid, srslte::unique_byte_buff
void pdcp::user_interface_rrc::write_pdu_bcch_bch(srslte::unique_byte_buffer_t pdu)
{
ERROR("Error: Received BCCH from ue=%d\n", rnti);
ERROR("Error: Received BCCH from ue=%d", rnti);
}
void pdcp::user_interface_rrc::write_pdu_bcch_dlsch(srslte::unique_byte_buffer_t pdu)
{
ERROR("Error: Received BCCH from ue=%d\n", rnti);
ERROR("Error: Received BCCH from ue=%d", rnti);
}
void pdcp::user_interface_rrc::write_pdu_pcch(srslte::unique_byte_buffer_t pdu)
{
ERROR("Error: Received PCCH from ue=%d\n", rnti);
ERROR("Error: Received PCCH from ue=%d", rnti);
}
std::string pdcp::user_interface_rrc::get_rb_name(uint32_t lcid)

@ -18,12 +18,10 @@ namespace srsenb {
void rlc::init(pdcp_interface_rlc* pdcp_,
rrc_interface_rlc* rrc_,
mac_interface_rlc* mac_,
srslte::timer_handler* timers_,
srslte::log_ref log_h_)
srslte::timer_handler* timers_)
{
pdcp = pdcp_;
rrc = rrc_;
log_h = log_h_;
mac = mac_;
timers = timers_;
@ -57,7 +55,7 @@ void rlc::add_user(uint16_t rnti)
{
pthread_rwlock_rdlock(&rwlock);
if (users.count(rnti) == 0) {
std::unique_ptr<srslte::rlc> obj(new srslte::rlc(log_h->get_service_name().c_str()));
std::unique_ptr<srslte::rlc> obj(new srslte::rlc(logger.id().c_str()));
obj->init(&users[rnti],
&users[rnti],
timers,
@ -81,7 +79,7 @@ void rlc::rem_user(uint16_t rnti)
users[rnti].rlc->stop();
users.erase(rnti);
} else {
log_h->error("Removing rnti=0x%x. Already removed\n", rnti);
logger.error("Removing rnti=0x%x. Already removed", rnti);
}
pthread_rwlock_unlock(&rwlock);
}
@ -96,7 +94,7 @@ void rlc::clear_buffer(uint16_t rnti)
mac->rlc_buffer_state(rnti, i, 0, 0);
}
}
log_h->info("Cleared buffer rnti=0x%x\n", rnti);
logger.info("Cleared buffer rnti=0x%x", rnti);
}
pthread_rwlock_unlock(&rwlock);
}
@ -176,7 +174,7 @@ void rlc::reestablish(uint16_t rnti)
// This function is called by UE RLC instance every time the tx/retx buffers are updated
void rlc::update_bsr(uint32_t rnti, uint32_t lcid, uint32_t tx_queue, uint32_t retx_queue)
{
log_h->debug("Buffer state: rnti=0x%x, lcid=%d, tx_queue=%d\n", rnti, lcid, tx_queue);
logger.debug("Buffer state: rnti=0x%x, lcid=%d, tx_queue=%d", rnti, lcid, tx_queue);
mac->rlc_buffer_state(rnti, lcid, tx_queue, retx_queue);
}
@ -272,17 +270,17 @@ void rlc::user_interface::write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t
void rlc::user_interface::write_pdu_bcch_bch(srslte::unique_byte_buffer_t sdu)
{
ERROR("Error: Received BCCH from ue=%d\n", rnti);
ERROR("Error: Received BCCH from ue=%d", rnti);
}
void rlc::user_interface::write_pdu_bcch_dlsch(srslte::unique_byte_buffer_t sdu)
{
ERROR("Error: Received BCCH from ue=%d\n", rnti);
ERROR("Error: Received BCCH from ue=%d", rnti);
}
void rlc::user_interface::write_pdu_pcch(srslte::unique_byte_buffer_t sdu)
{
ERROR("Error: Received PCCH from ue=%d\n", rnti);
ERROR("Error: Received PCCH from ue=%d", rnti);
}
std::string rlc::user_interface::get_rb_name(uint32_t lcid)

@ -31,9 +31,9 @@
using srslte::s1ap_mccmnc_to_plmn;
using srslte::uint32_to_uint8;
#define procError(fmt, ...) s1ap_ptr->s1ap_log->error("Proc \"%s\" - " fmt, name(), ##__VA_ARGS__)
#define procWarning(fmt, ...) s1ap_ptr->s1ap_log->warning("Proc \"%s\" - " fmt, name(), ##__VA_ARGS__)
#define procInfo(fmt, ...) s1ap_ptr->s1ap_log->info("Proc \"%s\" - " fmt, name(), ##__VA_ARGS__)
#define procError(fmt, ...) s1ap_ptr->logger.error("Proc \"%s\" - " fmt, name(), ##__VA_ARGS__)
#define procWarning(fmt, ...) s1ap_ptr->logger.warning("Proc \"%s\" - " fmt, name(), ##__VA_ARGS__)
#define procInfo(fmt, ...) s1ap_ptr->logger.info("Proc \"%s\" - " fmt, name(), ##__VA_ARGS__)
using namespace asn1::s1ap;
@ -62,9 +62,9 @@ srslte::proc_outcome_t s1ap::ue::ho_prep_proc_t::init(uint32_t
target_eci = target_eci_;
target_plmn = target_plmn_;
procInfo("Sending HandoverRequired to MME id=%d\n", ue_ptr->ctxt.mme_ue_s1ap_id);
procInfo("Sending HandoverRequired to MME id=%d", ue_ptr->ctxt.mme_ue_s1ap_id);
if (not ue_ptr->send_ho_required(target_eci, target_plmn, std::move(rrc_container_))) {
procError("Failed to send HORequired to cell 0x%x\n", target_eci);
procError("Failed to send HORequired to cell 0x%x", target_eci);
return srslte::proc_outcome_t::error;
}
@ -76,7 +76,7 @@ srslte::proc_outcome_t s1ap::ue::ho_prep_proc_t::init(uint32_t
srslte::proc_outcome_t s1ap::ue::ho_prep_proc_t::react(ts1_reloc_prep_expired e)
{
// do nothing for now
procError("timer TS1Relocprep has expired.\n");
procError("timer TS1Relocprep has expired.");
return srslte::proc_outcome_t::error;
}
srslte::proc_outcome_t s1ap::ue::ho_prep_proc_t::react(const ho_prep_fail_s& msg)
@ -84,7 +84,7 @@ srslte::proc_outcome_t s1ap::ue::ho_prep_proc_t::react(const ho_prep_fail_s& msg
ue_ptr->ts1_reloc_prep.stop();
std::string cause = s1ap_ptr->get_cause(msg.protocol_ies.cause.value);
procError("HO preparation Failure. Cause: %s\n", cause.c_str());
procError("HO preparation Failure. Cause: %s", cause.c_str());
srslte::console("HO preparation Failure. Cause: %s\n", cause.c_str());
return srslte::proc_outcome_t::error;
@ -104,18 +104,18 @@ srslte::proc_outcome_t s1ap::ue::ho_prep_proc_t::react(const asn1::s1ap::ho_cmd_
if (msg.ext or msg.protocol_ies.target_to_source_transparent_container_secondary_present or
msg.protocol_ies.handov_type.value.value != handov_type_opts::intralte or
msg.protocol_ies.crit_diagnostics_present or msg.protocol_ies.nas_security_paramsfrom_e_utran_present) {
procWarning("Not handling HandoverCommand extensions and non-intraLTE params\n");
procWarning("Not handling HandoverCommand extensions and non-intraLTE params");
}
// Check for E-RABs that could not be admitted in the target
if (msg.protocol_ies.erab_to_release_list_ho_cmd_present) {
procWarning("Not handling E-RABtoReleaseList\n");
procWarning("Not handling E-RABtoReleaseList");
// TODO
}
// Check for E-RABs subject to being forwarded
if (msg.protocol_ies.erab_subjectto_data_forwarding_list_present) {
procWarning("Not handling E-RABSubjecttoDataForwardingList\n");
procWarning("Not handling E-RABSubjecttoDataForwardingList");
// TODO
}
@ -125,17 +125,17 @@ srslte::proc_outcome_t s1ap::ue::ho_prep_proc_t::react(const asn1::s1ap::ho_cmd_
msg.protocol_ies.target_to_source_transparent_container.value.size());
asn1::s1ap::targetenb_to_sourceenb_transparent_container_s container;
if (container.unpack(bref) != asn1::SRSASN_SUCCESS) {
procError("Failed to decode TargeteNBToSourceeNBTransparentContainer\n");
procError("Failed to decode TargeteNBToSourceeNBTransparentContainer");
return srslte::proc_outcome_t::error;
}
if (container.ie_exts_present or container.ext) {
procWarning("Not handling extensions\n");
procWarning("Not handling extensions");
}
// Create a unique buffer out of transparent container to pass to RRC
rrc_container = srslte::allocate_unique_buffer(*s1ap_ptr->pool, false);
if (rrc_container == nullptr) {
procError("Fatal Error: Couldn't allocate buffer.\n");
procError("Fatal Error: Couldn't allocate buffer.");
return srslte::proc_outcome_t::error;
}
memcpy(rrc_container->msg, container.rrc_container.data(), container.rrc_container.size());
@ -150,7 +150,7 @@ void s1ap::ue::ho_prep_proc_t::then(const srslte::proc_state_t& result)
s1ap_ptr->rrc->ho_preparation_complete(ue_ptr->ctxt.rnti, false, {});
} else {
s1ap_ptr->rrc->ho_preparation_complete(ue_ptr->ctxt.rnti, true, std::move(rrc_container));
procInfo("Completed with success\n");
procInfo("Completed with success");
}
}
@ -160,23 +160,23 @@ void s1ap::ue::ho_prep_proc_t::then(const srslte::proc_state_t& result)
srslte::proc_outcome_t s1ap::s1_setup_proc_t::init()
{
procInfo("Starting new MME connection.\n");
procInfo("Starting new MME connection.");
return start_mme_connection();
}
srslte::proc_outcome_t s1ap::s1_setup_proc_t::start_mme_connection()
{
if (not s1ap_ptr->running) {
procInfo("S1AP is not running anymore.\n");
procInfo("S1AP is not running anymore.");
return srslte::proc_outcome_t::error;
}
if (s1ap_ptr->mme_connected) {
procInfo("eNB S1AP is already connected to MME\n");
procInfo("eNB S1AP is already connected to MME");
return srslte::proc_outcome_t::success;
}
if (not s1ap_ptr->connect_mme()) {
procInfo("Failed to initiate SCTP socket. Attempting reconnection in %d seconds\n",
procInfo("Failed to initiate SCTP socket. Attempting reconnection in %d seconds",
s1ap_ptr->mme_connect_timer.duration() / 1000);
srslte::console("Failed to initiate SCTP socket. Attempting reconnection in %d seconds\n",
s1ap_ptr->mme_connect_timer.duration() / 1000);
@ -185,14 +185,14 @@ srslte::proc_outcome_t s1ap::s1_setup_proc_t::start_mme_connection()
}
if (not s1ap_ptr->setup_s1()) {
procError("S1 setup failed. Exiting...\n");
procError("S1 setup failed. Exiting...");
srslte::console("S1 setup failed\n");
s1ap_ptr->running = false;
return srslte::proc_outcome_t::error;
}
s1ap_ptr->s1setup_timeout.run();
procInfo("S1SetupRequest sent. Waiting for response...\n");
procInfo("S1SetupRequest sent. Waiting for response...");
return srslte::proc_outcome_t::yield;
}
@ -202,10 +202,10 @@ srslte::proc_outcome_t s1ap::s1_setup_proc_t::react(const srsenb::s1ap::s1_setup
s1ap_ptr->s1setup_timeout.stop();
}
if (event.success) {
procInfo("S1Setup procedure completed successfully\n");
procInfo("S1Setup procedure completed successfully");
return srslte::proc_outcome_t::success;
}
procError("S1Setup failed. Exiting...\n");
procError("S1Setup failed. Exiting...");
srslte::console("S1setup failed\n");
return srslte::proc_outcome_t::error;
}
@ -214,7 +214,7 @@ void s1ap::s1_setup_proc_t::then(const srslte::proc_state_t& result) const
{
if (result.is_error()) {
s1ap_ptr->s1ap_socket.reset();
procInfo("S1AP socket closed.\n");
procInfo("S1AP socket closed.");
}
}
@ -222,13 +222,14 @@ void s1ap::s1_setup_proc_t::then(const srslte::proc_state_t& result) const
* S1AP class
*********************************************************/
s1ap::s1ap(srslte::task_sched_handle task_sched_) : s1setup_proc(this), task_sched(task_sched_) {}
s1ap::s1ap(srslte::task_sched_handle task_sched_, srslog::basic_logger& logger) :
s1setup_proc(this), logger(logger), task_sched(task_sched_)
{}
int s1ap::init(s1ap_args_t args_, rrc_interface_s1ap* rrc_, srsenb::stack_interface_s1ap_lte* stack_)
{
rrc = rrc_;
args = args_;
s1ap_log = srslte::logmap::get("S1AP");
stack = stack_;
pool = srslte::byte_buffer_pool::get_instance();
@ -238,7 +239,7 @@ int s1ap::init(s1ap_args_t args_, rrc_interface_s1ap* rrc_, srsenb::stack_interf
mme_connect_timer = task_sched.get_unique_timer();
auto mme_connect_run = [this](uint32_t tid) {
if (not s1setup_proc.launch()) {
s1ap_log->error("Failed to initiate S1Setup procedure.\n");
logger.error("Failed to initiate S1Setup procedure.");
}
};
mme_connect_timer.set(10000, mme_connect_run);
@ -255,7 +256,7 @@ int s1ap::init(s1ap_args_t args_, rrc_interface_s1ap* rrc_, srsenb::stack_interf
running = true;
// starting MME connection
if (not s1setup_proc.launch()) {
s1ap_log->error("Failed to initiate S1Setup procedure.\n");
logger.error("Failed to initiate S1Setup procedure.");
}
return SRSLTE_SUCCESS;
@ -306,7 +307,7 @@ void s1ap::initial_ue(uint16_t rnti, asn1::s1ap::rrc_establishment_cause_e cause
ue_ptr->ctxt.rnti = rnti;
ue* u = users.add_user(std::move(ue_ptr));
if (u == nullptr) {
s1ap_log->error("Failed to add rnti=0x%x\n", rnti);
logger.error("Failed to add rnti=0x%x", rnti);
return;
}
u->send_initialuemessage(cause, std::move(pdu), false);
@ -322,7 +323,7 @@ void s1ap::initial_ue(uint16_t rnti,
ue_ptr->ctxt.rnti = rnti;
ue* u = users.add_user(std::move(ue_ptr));
if (u == nullptr) {
s1ap_log->error("Failed to add rnti=0x%x\n", rnti);
logger.error("Failed to add rnti=0x%x", rnti);
return;
}
u->send_initialuemessage(cause, std::move(pdu), true, m_tmsi, mmec);
@ -330,11 +331,11 @@ void s1ap::initial_ue(uint16_t rnti,
void s1ap::write_pdu(uint16_t rnti, srslte::unique_byte_buffer_t pdu)
{
s1ap_log->info_hex(pdu->msg, pdu->N_bytes, "Received RRC SDU");
logger.info(pdu->msg, pdu->N_bytes, "Received RRC SDU");
ue* u = users.find_ue_rnti(rnti);
if (u == nullptr) {
s1ap_log->info("The rnti=0x%x does not exist\n", rnti);
logger.info("The rnti=0x%x does not exist", rnti);
return;
}
u->send_ulnastransport(std::move(pdu));
@ -342,7 +343,7 @@ void s1ap::write_pdu(uint16_t rnti, srslte::unique_byte_buffer_t pdu)
bool s1ap::user_release(uint16_t rnti, asn1::s1ap::cause_radio_network_e cause_radio)
{
s1ap_log->info("User inactivity - RNTI:0x%x\n", rnti);
logger.info("User inactivity - RNTI:0x%x", rnti);
ue* u = users.find_ue_rnti(rnti);
if (u == nullptr) {
@ -350,7 +351,7 @@ bool s1ap::user_release(uint16_t rnti, asn1::s1ap::cause_radio_network_e cause_r
}
if (u->was_uectxtrelease_requested()) {
s1ap_log->warning("UE context for RNTI:0x%x is in zombie state. Releasing...\n", rnti);
logger.warning("UE context for RNTI:0x%x is in zombie state. Releasing...", rnti);
users.erase(u);
rrc->release_complete(rnti);
return false;
@ -372,13 +373,13 @@ bool s1ap::user_exists(uint16_t rnti)
void s1ap::user_mod(uint16_t old_rnti, uint16_t new_rnti)
{
s1ap_log->info("Modifying user context. Old rnti: 0x%x, new rnti: 0x%x\n", old_rnti, new_rnti);
logger.info("Modifying user context. Old rnti: 0x%x, new rnti: 0x%x", old_rnti, new_rnti);
if (not user_exists(old_rnti)) {
s1ap_log->error("Old rnti does not exist, aborting.\n");
logger.error("Old rnti does not exist, aborting.");
return;
}
if (user_exists(new_rnti)) {
s1ap_log->error("New rnti already exists, aborting.\n");
logger.error("New rnti already exists, aborting.");
return;
}
users.find_ue_rnti(old_rnti)->ctxt.rnti = new_rnti;
@ -401,7 +402,7 @@ void s1ap::ue_erab_setup_complete(uint16_t rnti, const asn1::s1ap::erab_setup_re
{
ue* u = users.find_ue_rnti(rnti);
if (u == nullptr) {
s1ap_log->error("rnti 0x%x not found\n", rnti);
logger.error("rnti 0x%x not found", rnti);
return;
}
u->send_erab_setup_response(res);
@ -423,7 +424,7 @@ bool s1ap::is_mme_connected()
bool s1ap::connect_mme()
{
s1ap_log->info("Connecting to MME %s:%d\n", args.mme_addr.c_str(), MME_PORT);
logger.info("Connecting to MME %s:%d", args.mme_addr.c_str(), int(MME_PORT));
// Init SCTP socket and bind it
if (not srslte::net_utils::sctp_init_client(
@ -439,7 +440,7 @@ bool s1ap::connect_mme()
// Assign a handler to rx MME packets (going to run in a different thread)
stack->add_mme_socket(s1ap_socket.fd());
s1ap_log->info("SCTP socket established with MME\n");
logger.info("SCTP socket established with MME");
return true;
}
@ -492,21 +493,21 @@ bool s1ap::handle_mme_rx_msg(srslte::unique_byte_buffer_t pdu,
if (flags & MSG_NOTIFICATION) {
// Received notification
union sctp_notification* notification = (union sctp_notification*)pdu->msg;
s1ap_log->debug("SCTP Notification %d\n", notification->sn_header.sn_type);
logger.debug("SCTP Notification %d", notification->sn_header.sn_type);
if (notification->sn_header.sn_type == SCTP_SHUTDOWN_EVENT) {
s1ap_log->info("SCTP Association Shutdown. Association: %d\n", sri.sinfo_assoc_id);
logger.info("SCTP Association Shutdown. Association: %d", sri.sinfo_assoc_id);
srslte::console("SCTP Association Shutdown. Association: %d\n", sri.sinfo_assoc_id);
stack->remove_mme_socket(s1ap_socket.get_socket());
s1ap_socket.reset();
} else if (notification->sn_header.sn_type == SCTP_PEER_ADDR_CHANGE &&
notification->sn_paddr_change.spc_state == SCTP_ADDR_UNREACHABLE) {
s1ap_log->info("SCTP peer addres unreachable. Association: %d\n", sri.sinfo_assoc_id);
logger.info("SCTP peer addres unreachable. Association: %d", sri.sinfo_assoc_id);
srslte::console("SCTP peer address unreachable. Association: %d\n", sri.sinfo_assoc_id);
stack->remove_mme_socket(s1ap_socket.get_socket());
s1ap_socket.reset();
}
} else if (pdu->N_bytes == 0) {
s1ap_log->error("SCTP return 0 bytes. Closing socket\n");
logger.error("SCTP return 0 bytes. Closing socket");
s1ap_socket.reset();
}
@ -514,12 +515,12 @@ bool s1ap::handle_mme_rx_msg(srslte::unique_byte_buffer_t pdu,
if (not s1ap_socket.is_init()) {
mme_connected = false;
if (not s1setup_proc.launch()) {
s1ap_log->error("Failed to initiate MME connection procedure.\n");
logger.error("Failed to initiate MME connection procedure.");
}
return false;
}
s1ap_log->info_hex(pdu->msg, pdu->N_bytes, "Received S1AP PDU");
logger.info(pdu->msg, pdu->N_bytes, "Received S1AP PDU");
handle_s1ap_rx_pdu(pdu.get());
return true;
}
@ -535,7 +536,7 @@ bool s1ap::handle_s1ap_rx_pdu(srslte::byte_buffer_t* pdu)
asn1::cbit_ref bref(pdu->msg, pdu->N_bytes);
if (rx_pdu.unpack(bref) != asn1::SRSASN_SUCCESS) {
s1ap_log->error("Failed to unpack received PDU\n");
logger.error("Failed to unpack received PDU");
return false;
}
@ -547,7 +548,7 @@ bool s1ap::handle_s1ap_rx_pdu(srslte::byte_buffer_t* pdu)
case s1ap_pdu_c::types_opts::unsuccessful_outcome:
return handle_unsuccessfuloutcome(rx_pdu.unsuccessful_outcome());
default:
s1ap_log->error("Unhandled PDU type %d\n", rx_pdu.type().value);
logger.error("Unhandled PDU type %d", rx_pdu.type().value);
return false;
}
@ -578,7 +579,7 @@ bool s1ap::handle_initiatingmessage(const init_msg_s& msg)
case s1ap_elem_procs_o::init_msg_c::types_opts::mme_status_transfer:
return handle_mme_status_transfer(msg.value.mme_status_transfer());
default:
s1ap_log->error("Unhandled initiating message: %s\n", msg.value.type().to_string().c_str());
logger.error("Unhandled initiating message: %s", msg.value.type().to_string().c_str());
}
return true;
}
@ -591,10 +592,10 @@ bool s1ap::handle_successfuloutcome(const successful_outcome_s& msg)
case s1ap_elem_procs_o::successful_outcome_c::types_opts::ho_cmd:
return handle_s1hocommand(msg.value.ho_cmd());
case s1ap_elem_procs_o::successful_outcome_c::types_opts::ho_cancel_ack:
s1ap_log->info("Received %s\n", msg.value.type().to_string().c_str());
logger.info("Received %s", msg.value.type().to_string().c_str());
return true;
default:
s1ap_log->error("Unhandled successful outcome message: %s\n", msg.value.type().to_string().c_str());
logger.error("Unhandled successful outcome message: %s", msg.value.type().to_string().c_str());
}
return true;
}
@ -607,14 +608,14 @@ bool s1ap::handle_unsuccessfuloutcome(const unsuccessful_outcome_s& msg)
case s1ap_elem_procs_o::unsuccessful_outcome_c::types_opts::ho_prep_fail:
return handle_hopreparationfailure(msg.value.ho_prep_fail());
default:
s1ap_log->error("Unhandled unsuccessful outcome message: %s\n", msg.value.type().to_string().c_str());
logger.error("Unhandled unsuccessful outcome message: %s", msg.value.type().to_string().c_str());
}
return true;
}
bool s1ap::handle_s1setupresponse(const asn1::s1ap::s1_setup_resp_s& msg)
{
s1ap_log->info("Received S1SetupResponse\n");
logger.info("Received S1SetupResponse");
s1setupresponse = msg;
mme_connected = true;
s1_setup_proc_t::s1setupresult res;
@ -625,9 +626,9 @@ bool s1ap::handle_s1setupresponse(const asn1::s1ap::s1_setup_resp_s& msg)
bool s1ap::handle_dlnastransport(const dl_nas_transport_s& msg)
{
s1ap_log->info("Received DownlinkNASTransport\n");
logger.info("Received DownlinkNASTransport");
if (msg.ext) {
s1ap_log->warning("Not handling S1AP message extension\n");
logger.warning("Not handling S1AP message extension");
}
ue* u = find_s1apmsg_user(msg.protocol_ies.enb_ue_s1ap_id.value.value, msg.protocol_ies.mme_ue_s1ap_id.value.value);
if (u == nullptr) {
@ -635,15 +636,15 @@ bool s1ap::handle_dlnastransport(const dl_nas_transport_s& msg)
}
if (msg.protocol_ies.ho_restrict_list_present) {
s1ap_log->warning("Not handling HandoverRestrictionList\n");
logger.warning("Not handling HandoverRestrictionList");
}
if (msg.protocol_ies.subscriber_profile_idfor_rfp_present) {
s1ap_log->warning("Not handling SubscriberProfileIDforRFP\n");
logger.warning("Not handling SubscriberProfileIDforRFP");
}
srslte::unique_byte_buffer_t pdu = srslte::allocate_unique_buffer(*pool);
if (pdu == nullptr) {
s1ap_log->error("Fatal Error: Couldn't allocate buffer in s1ap::run_thread().\n");
logger.error("Fatal Error: Couldn't allocate buffer in s1ap::run_thread().");
return false;
}
memcpy(pdu->msg, msg.protocol_ies.nas_pdu.value.data(), msg.protocol_ies.nas_pdu.value.size());
@ -654,9 +655,9 @@ bool s1ap::handle_dlnastransport(const dl_nas_transport_s& msg)
bool s1ap::handle_initialctxtsetuprequest(const init_context_setup_request_s& msg)
{
s1ap_log->info("Received InitialContextSetupRequest\n");
logger.info("Received InitialContextSetupRequest");
if (msg.ext) {
s1ap_log->warning("Not handling S1AP message extension\n");
logger.warning("Not handling S1AP message extension");
}
ue* u = find_s1apmsg_user(msg.protocol_ies.enb_ue_s1ap_id.value.value, msg.protocol_ies.mme_ue_s1ap_id.value.value);
if (u == nullptr) {
@ -687,7 +688,7 @@ bool s1ap::handle_initialctxtsetuprequest(const init_context_setup_request_s& ms
bool s1ap::handle_paging(const asn1::s1ap::paging_s& msg)
{
if (msg.ext) {
s1ap_log->warning("Not handling S1AP message extension\n");
logger.warning("Not handling S1AP message extension");
}
uint32_t ueid = msg.protocol_ies.ue_id_idx_value.value.to_number();
rrc->add_paging_id(ueid, msg.protocol_ies.ue_paging_id.value);
@ -696,9 +697,9 @@ bool s1ap::handle_paging(const asn1::s1ap::paging_s& msg)
bool s1ap::handle_erabsetuprequest(const erab_setup_request_s& msg)
{
s1ap_log->info("Received ERABSetupRequest\n");
logger.info("Received ERABSetupRequest");
if (msg.ext) {
s1ap_log->warning("Not handling S1AP message extension\n");
logger.warning("Not handling S1AP message extension");
}
ue* u = find_s1apmsg_user(msg.protocol_ies.enb_ue_s1ap_id.value.value, msg.protocol_ies.mme_ue_s1ap_id.value.value);
if (u == nullptr) {
@ -711,12 +712,12 @@ bool s1ap::handle_erabsetuprequest(const erab_setup_request_s& msg)
bool s1ap::handle_erabmodifyrequest(const erab_modify_request_s& msg)
{
s1ap_log->info("Received ERABModifyRequest\n");
logger.info("Received ERABModifyRequest");
std::vector<uint16_t> erab_successful_modified = {};
std::vector<uint16_t> erab_failed_to_modify = {};
if (msg.ext) {
s1ap_log->warning("Not handling S1AP message extension\n");
logger.warning("Not handling S1AP message extension");
}
ue* u = find_s1apmsg_user(msg.protocol_ies.enb_ue_s1ap_id.value.value, msg.protocol_ies.mme_ue_s1ap_id.value.value);
if (u == nullptr) {
@ -728,7 +729,7 @@ bool s1ap::handle_erabmodifyrequest(const erab_modify_request_s& msg)
// Send E-RAB modify response back to the MME
if (not u->send_erab_modify_response(erab_successful_modified, erab_failed_to_modify)) {
s1ap_log->info("Failed to send ERABReleaseResponse\n");
logger.info("Failed to send ERABReleaseResponse");
return false;
}
@ -737,12 +738,12 @@ bool s1ap::handle_erabmodifyrequest(const erab_modify_request_s& msg)
bool s1ap::handle_erabreleasecommand(const erab_release_cmd_s& msg)
{
s1ap_log->info("Received ERABReleaseCommand\n");
logger.info("Received ERABReleaseCommand");
std::vector<uint16_t> erab_successful_release = {};
std::vector<uint16_t> erab_failed_to_release = {};
if (msg.ext) {
s1ap_log->warning("Not handling S1AP message extension\n");
logger.warning("Not handling S1AP message extension");
}
ue* u = find_s1apmsg_user(msg.protocol_ies.enb_ue_s1ap_id.value.value, msg.protocol_ies.mme_ue_s1ap_id.value.value);
if (u == nullptr) {
@ -754,7 +755,7 @@ bool s1ap::handle_erabreleasecommand(const erab_release_cmd_s& msg)
// Send E-RAB release response back to the MME
if (not u->send_erab_release_response(erab_successful_release, erab_failed_to_release)) {
s1ap_log->info("Failed to send ERABReleaseResponse\n");
logger.info("Failed to send ERABReleaseResponse");
return false;
}
@ -763,7 +764,7 @@ bool s1ap::handle_erabreleasecommand(const erab_release_cmd_s& msg)
bool s1ap::handle_uecontextmodifyrequest(const ue_context_mod_request_s& msg)
{
s1ap_log->info("Received UeContextModificationRequest\n");
logger.info("Received UeContextModificationRequest");
ue* u = find_s1apmsg_user(msg.protocol_ies.enb_ue_s1ap_id.value.value, msg.protocol_ies.mme_ue_s1ap_id.value.value);
if (u == nullptr) {
return false;
@ -796,9 +797,9 @@ bool s1ap::handle_uecontextmodifyrequest(const ue_context_mod_request_s& msg)
bool s1ap::handle_uectxtreleasecommand(const ue_context_release_cmd_s& msg)
{
s1ap_log->info("Received UEContextReleaseCommand\n");
logger.info("Received UEContextReleaseCommand");
if (msg.ext) {
s1ap_log->warning("Not handling S1AP message extension\n");
logger.warning("Not handling S1AP message extension");
}
ue* u = nullptr;
@ -806,10 +807,10 @@ bool s1ap::handle_uectxtreleasecommand(const ue_context_release_cmd_s& msg)
auto& idpair = msg.protocol_ies.ue_s1ap_ids.value.ue_s1ap_id_pair();
if (idpair.ext) {
s1ap_log->warning("Not handling S1AP message extension\n");
logger.warning("Not handling S1AP message extension");
}
if (idpair.ie_exts_present) {
s1ap_log->warning("Not handling S1AP message iE_Extensions\n");
logger.warning("Not handling S1AP message iE_Extensions");
}
u = find_s1apmsg_user(idpair.enb_ue_s1ap_id, idpair.mme_ue_s1ap_id);
if (u == nullptr) {
@ -819,7 +820,7 @@ bool s1ap::handle_uectxtreleasecommand(const ue_context_release_cmd_s& msg)
uint32_t mme_ue_id = msg.protocol_ies.ue_s1ap_ids.value.mme_ue_s1ap_id();
u = users.find_ue_mmeid(mme_ue_id);
if (u == nullptr) {
s1ap_log->warning("UE for mme_ue_s1ap_id:%d not found - discarding message\n", mme_ue_id);
logger.warning("UE for mme_ue_s1ap_id:%d not found - discarding message", mme_ue_id);
return false;
}
}
@ -828,7 +829,7 @@ bool s1ap::handle_uectxtreleasecommand(const ue_context_release_cmd_s& msg)
rrc->release_erabs(rnti);
u->send_uectxtreleasecomplete();
users.erase(u);
s1ap_log->info("UE context for RNTI:0x%x released\n", rnti);
logger.info("UE context for RNTI:0x%x released", rnti);
rrc->release_complete(rnti);
return true;
}
@ -836,14 +837,14 @@ bool s1ap::handle_uectxtreleasecommand(const ue_context_release_cmd_s& msg)
bool s1ap::handle_s1setupfailure(const asn1::s1ap::s1_setup_fail_s& msg)
{
std::string cause = get_cause(msg.protocol_ies.cause.value);
s1ap_log->error("S1 Setup Failure. Cause: %s\n", cause.c_str());
logger.error("S1 Setup Failure. Cause: %s", cause.c_str());
srslte::console("S1 Setup Failure. Cause: %s\n", cause.c_str());
return true;
}
bool s1ap::handle_hopreparationfailure(const ho_prep_fail_s& msg)
{
s1ap_log->info("Received HO Preparation Failure\n");
logger.info("Received HO Preparation Failure");
ue* u = find_s1apmsg_user(msg.protocol_ies.enb_ue_s1ap_id.value.value, msg.protocol_ies.mme_ue_s1ap_id.value.value);
if (u == nullptr) {
return false;
@ -854,7 +855,7 @@ bool s1ap::handle_hopreparationfailure(const ho_prep_fail_s& msg)
bool s1ap::handle_s1hocommand(const asn1::s1ap::ho_cmd_s& msg)
{
s1ap_log->info("Received S1 HO Command\n");
logger.info("Received S1 HO Command");
ue* u = find_s1apmsg_user(msg.protocol_ies.enb_ue_s1ap_id.value.value, msg.protocol_ies.mme_ue_s1ap_id.value.value);
if (u == nullptr) {
return false;
@ -871,7 +872,7 @@ bool s1ap::handle_ho_request(const asn1::s1ap::ho_request_s& msg)
{
uint16_t rnti = SRSLTE_INVALID_RNTI;
s1ap_log->info("Received S1 HO Request\n");
logger.info("Received S1 HO Request");
srslte::console("Received S1 HO Request\n");
auto on_scope_exit = srslte::make_scope_exit([this, &rnti, msg]() {
@ -883,13 +884,13 @@ bool s1ap::handle_ho_request(const asn1::s1ap::ho_request_s& msg)
if (msg.ext or msg.protocol_ies.ho_restrict_list_present or
msg.protocol_ies.handov_type.value.value != handov_type_opts::intralte) {
s1ap_log->error("Not handling S1AP non-intra LTE handovers and extensions\n");
logger.error("Not handling S1AP non-intra LTE handovers and extensions");
return false;
}
// Confirm the UE does not exist in TeNB
if (users.find_ue_mmeid(msg.protocol_ies.mme_ue_s1ap_id.value.value) != nullptr) {
s1ap_log->error("The provided MME_UE_S1AP_ID=%" PRIu64 " is already connected to the cell\n",
logger.error("The provided MME_UE_S1AP_ID=%" PRIu64 " is already connected to the cell",
msg.protocol_ies.mme_ue_s1ap_id.value.value);
return false;
}
@ -907,7 +908,7 @@ bool s1ap::handle_ho_request(const asn1::s1ap::ho_request_s& msg)
asn1::cbit_ref bref{msg.protocol_ies.source_to_target_transparent_container.value.data(),
msg.protocol_ies.source_to_target_transparent_container.value.size()};
if (container.unpack(bref) != asn1::SRSASN_SUCCESS) {
s1ap_log->error("Failed to unpack SourceToTargetTransparentContainer\n");
logger.error("Failed to unpack SourceToTargetTransparentContainer");
return false;
}
@ -972,7 +973,7 @@ bool s1ap::send_ho_req_ack(const asn1::s1ap::ho_request_s& msg,
auto& pdu = ho_cmd; // reuse pdu
asn1::bit_ref bref{pdu->msg, pdu->get_tailroom()};
if (transparent_container.pack(bref) != asn1::SRSASN_SUCCESS) {
s1ap_log->error("Failed to pack TargeteNBToSourceeNBTransparentContainer\n");
logger.error("Failed to pack TargeteNBToSourceeNBTransparentContainer");
return false;
}
container.target_to_source_transparent_container.value.resize(bref.distance_bytes());
@ -983,7 +984,7 @@ bool s1ap::send_ho_req_ack(const asn1::s1ap::ho_request_s& msg,
bool s1ap::handle_mme_status_transfer(const asn1::s1ap::mme_status_transfer_s& msg)
{
s1ap_log->info("Received S1 MMEStatusTransfer\n");
logger.info("Received S1 MMEStatusTransfer");
srslte::console("Received S1 MMEStatusTransfer\n");
ue* u = find_s1apmsg_user(msg.protocol_ies.enb_ue_s1ap_id.value.value, msg.protocol_ies.mme_ue_s1ap_id.value.value);
@ -1114,7 +1115,7 @@ bool s1ap::ue::send_uectxtreleaserequest(const cause_c& cause)
}
if (!ctxt.mme_ue_s1ap_id_present) {
s1ap_log->error("Cannot send UE context release request without a MME-UE-S1AP-Id allocated.\n");
logger.error("Cannot send UE context release request without a MME-UE-S1AP-Id allocated.");
return false;
}
@ -1367,7 +1368,7 @@ bool s1ap::send_ho_required(uint16_t rnti,
// launch procedure
if (not u->ho_prep_proc.launch(target_eci, target_plmn, std::move(rrc_container))) {
s1ap_log->error("Failed to initiate an HandoverPreparation procedure for user rnti=0x%x\n", u->ctxt.rnti);
logger.error("Failed to initiate an HandoverPreparation procedure for user rnti=0x%x", u->ctxt.rnti);
return false;
}
return true;
@ -1405,13 +1406,13 @@ bool s1ap::send_enb_status_transfer_proc(uint16_t rnti, std::vector<bearer_statu
// // TODO: caps->UERadioCapability.
// liblte_s1ap_pack_s1ap_pdu(&tx_pdu, (LIBLTE_BYTE_MSG_STRUCT*)&msg);
// s1ap_log->info_hex(msg.msg, msg.N_bytes, "Sending UERadioCapabilityInfo for RNTI:0x%x", rnti);
// logger.info_hex(msg.msg, msg.N_bytes, "Sending UERadioCapabilityInfo for RNTI:0x%x", rnti);
// ssize_t n_sent = sctp_sendmsg(socket_fd, msg.msg, msg.N_bytes,
// (struct sockaddr*)&mme_addr, sizeof(struct sockaddr_in),
// htonl(PPID), 0, ue_ctxt_map[rnti]->stream_id, 0, 0);
// if(n_sent == -1) {
// s1ap_log->error("Failed to send UplinkNASTransport for RNTI:0x%x\n", rnti);
// logger.error("Failed to send UplinkNASTransport for RNTI:0x%x", rnti);
// return false;
// }
@ -1455,17 +1456,15 @@ s1ap::ue* s1ap::user_list::add_user(std::unique_ptr<s1ap::ue> user)
{
// Check for ID repetitions
if (find_ue_rnti(user->ctxt.rnti) != nullptr) {
srslte::logmap::get("S1AP")->error("The user to be added with rnti=0x%x already exists\n", user->ctxt.rnti);
srslte::logmap::get("S1AP")->error("The user to be added with rnti=0x%x already exists", user->ctxt.rnti);
return nullptr;
}
if (find_ue_enbid(user->ctxt.enb_ue_s1ap_id) != nullptr) {
srslte::logmap::get("S1AP")->error("The user to be added with enb id=%d already exists\n",
user->ctxt.enb_ue_s1ap_id);
srslte::logmap::get("S1AP")->error("The user to be added with enb id=%d already exists", user->ctxt.enb_ue_s1ap_id);
return nullptr;
}
if (find_ue_mmeid(user->ctxt.mme_ue_s1ap_id) != nullptr) {
srslte::logmap::get("S1AP")->error("The user to be added with mme id=%d already exists\n",
user->ctxt.mme_ue_s1ap_id);
srslte::logmap::get("S1AP")->error("The user to be added with mme id=%d already exists", user->ctxt.mme_ue_s1ap_id);
return nullptr;
}
auto p = users.insert(std::make_pair(user->ctxt.enb_ue_s1ap_id, std::move(user)));
@ -1476,7 +1475,7 @@ void s1ap::user_list::erase(ue* ue_ptr)
{
auto it = users.find(ue_ptr->ctxt.enb_ue_s1ap_id);
if (it == users.end()) {
srslte::logmap::get("S1AP")->error("User to be erased does not exist\n");
srslte::logmap::get("S1AP")->error("User to be erased does not exist");
return;
}
users.erase(it);
@ -1490,7 +1489,7 @@ bool s1ap::sctp_send_s1ap_pdu(const asn1::s1ap::s1ap_pdu_c& tx_pdu, uint32_t rnt
{
srslte::unique_byte_buffer_t buf = srslte::allocate_unique_buffer(*pool, false);
if (buf == nullptr) {
s1ap_log->error("Fatal Error: Couldn't allocate buffer for %s.\n", procedure_name);
logger.error("Fatal Error: Couldn't allocate buffer for %s.", procedure_name);
return false;
}
asn1::bit_ref bref(buf->msg, buf->get_tailroom());
@ -1503,9 +1502,9 @@ bool s1ap::sctp_send_s1ap_pdu(const asn1::s1ap::s1ap_pdu_c& tx_pdu, uint32_t rnt
}
if (rnti != SRSLTE_INVALID_RNTI) {
s1ap_log->info_hex(buf->msg, buf->N_bytes, "Sending %s for rnti=0x%x", procedure_name, rnti);
logger.info(buf->msg, buf->N_bytes, "Sending %s for rnti=0x%x", procedure_name, rnti);
} else {
s1ap_log->info_hex(buf->msg, buf->N_bytes, "Sending %s to MME", procedure_name);
logger.info(buf->msg, buf->N_bytes, "Sending %s to MME", procedure_name);
}
uint16_t streamid = rnti == SRSLTE_INVALID_RNTI ? NONUE_STREAM_ID : users.find_ue_rnti(rnti)->stream_id;
@ -1521,9 +1520,9 @@ bool s1ap::sctp_send_s1ap_pdu(const asn1::s1ap::s1ap_pdu_c& tx_pdu, uint32_t rnt
0);
if (n_sent == -1) {
if (rnti > 0) {
s1ap_log->error("Failed to send %s for rnti=0x%x\n", procedure_name, rnti);
logger.error("Failed to send %s for rnti=0x%x", procedure_name, rnti);
} else {
s1ap_log->error("Failed to send %s\n", procedure_name);
logger.error("Failed to send %s", procedure_name);
}
return false;
}
@ -1540,11 +1539,11 @@ s1ap::ue* s1ap::find_s1apmsg_user(uint32_t enb_id, uint32_t mme_id)
{
ue* user_ptr = users.find_ue_enbid(enb_id);
if (user_ptr == nullptr) {
s1ap_log->warning("enb_ue_s1ap_id=%d not found - discarding message\n", enb_id);
logger.warning("enb_ue_s1ap_id=%d not found - discarding message", enb_id);
return nullptr;
}
if (user_ptr->ctxt.mme_ue_s1ap_id_present and user_ptr->ctxt.mme_ue_s1ap_id != mme_id) {
s1ap_log->warning("MME_UE_S1AP_ID has changed - old:%d, new:%d\n", user_ptr->ctxt.mme_ue_s1ap_id, mme_id);
logger.warning("MME_UE_S1AP_ID has changed - old:%d, new:%d", user_ptr->ctxt.mme_ue_s1ap_id, mme_id);
}
user_ptr->ctxt.mme_ue_s1ap_id_present = true;
user_ptr->ctxt.mme_ue_s1ap_id = mme_id;
@ -1586,7 +1585,7 @@ void s1ap::start_pcap(srslte::s1ap_pcap* pcap_)
/* s1ap::ue Class
********************************************************************************/
s1ap::ue::ue(s1ap* s1ap_ptr_) : s1ap_ptr(s1ap_ptr_), s1ap_log(s1ap_ptr_->s1ap_log), ho_prep_proc(this)
s1ap::ue::ue(s1ap* s1ap_ptr_) : s1ap_ptr(s1ap_ptr_), ho_prep_proc(this), logger(s1ap_ptr->logger)
{
ctxt.enb_ue_s1ap_id = s1ap_ptr->next_enb_ue_s1ap_id++;
gettimeofday(&ctxt.init_timestamp, nullptr);
@ -1665,7 +1664,7 @@ bool s1ap::ue::send_ho_required(uint32_t target_eci,
uint8_t buffer[4096];
asn1::bit_ref bref(buffer, sizeof(buffer));
if (transparent_cntr.pack(bref) != asn1::SRSASN_SUCCESS) {
s1ap_log->error("Failed to pack transparent container of HO Required message\n");
logger.error("Failed to pack transparent container of HO Required message");
return false;
}
container.source_to_target_transparent_container.value.resize(bref.distance_bytes());
@ -1704,7 +1703,7 @@ bool s1ap::ue::send_enb_status_transfer_proc(std::vector<bearer_status_info>& be
// asn1::json_writer jw;
// asn1bearer.to_json(jw);
// printf("Bearer to add %s\n", jw.to_string().c_str());
// printf("Bearer to add %s", jw.to_string().c_str());
}
return s1ap_ptr->sctp_send_s1ap_pdu(tx_pdu, ctxt.rnti, "ENBStatusTransfer");

@ -14,7 +14,7 @@
namespace srsenb {
sdap::sdap() : m_log("SDAP") {}
sdap::sdap() {}
bool sdap::init(pdcp_interface_sdap_nr* pdcp_, gtpu_interface_sdap_nr* gtpu_, srsue::gw_interface_pdcp* gw_)
{

@ -23,20 +23,24 @@ uint32_t const seed = std::chrono::system_clock::now().time_since_epoch().count(
* Logging *
*******************/
class sched_test_log final : public srslte::test_log_filter
/// RAII style class that prints the test diagnostic info on destruction.
class sched_diagnostic_printer
{
public:
sched_test_log() : srslte::test_log_filter("TEST") { exit_on_error = true; }
~sched_test_log() override { log_diagnostics(); }
explicit sched_diagnostic_printer(srslte::log_sink_spy& s) : s(s) {}
void log_diagnostics() override
~sched_diagnostic_printer()
{
info("[TESTER] Number of assertion warnings: %u\n", warn_counter);
info("[TESTER] Number of assertion errors: %u\n", error_counter);
info("[TESTER] This was the seed: %u\n", seed);
auto& logger = srslog::fetch_basic_logger("TEST");
logger.info("[TESTER] Number of assertion warnings: %u", s.get_warning_counter());
logger.info("[TESTER] Number of assertion errors: %u", s.get_error_counter());
logger.info("[TESTER] This was the seed: %u", seed);
srslog::flush();
}
private:
srslte::log_sink_spy& s;
};
srslte::scoped_log<sched_test_log> log_global{};
/******************************
* Scheduler Tests
@ -100,7 +104,6 @@ int test_scell_activation(test_scell_activation_params params)
/* Setup simulation arguments struct */
sim_sched_args sim_args = generate_default_sim_args(nof_prb, nof_ccs);
sim_args.sim_log = log_global.get();
sim_args.start_tti = start_tti;
sim_args.default_ue_sim_cfg.ue_cfg.supported_cc_list.resize(1);
sim_args.default_ue_sim_cfg.ue_cfg.supported_cc_list[0].active = true;
@ -226,7 +229,7 @@ int test_scell_activation(test_scell_activation_params params)
TESTASSERT(tot_dl_sched_data > 0);
TESTASSERT(tot_ul_sched_data > 0);
log_global->info("[TESTER] Sim1 finished successfully\n");
srslog::fetch_basic_logger("TEST").info("[TESTER] Sim1 finished successfully");
return SRSLTE_SUCCESS;
}
@ -235,6 +238,28 @@ int main()
// Setup rand seed
set_randseed(seed);
// Setup the log spy to intercept error and warning log entries.
if (!srslog::install_custom_sink(
srslte::log_sink_spy::name(),
std::unique_ptr<srslte::log_sink_spy>(new srslte::log_sink_spy(srslog::get_default_log_formatter())))) {
return SRSLTE_ERROR;
}
auto* spy = static_cast<srslte::log_sink_spy*>(srslog::find_sink(srslte::log_sink_spy::name()));
if (!spy) {
return SRSLTE_ERROR;
}
auto& mac_log = srslog::fetch_basic_logger("MAC");
mac_log.set_level(srslog::basic_levels::info);
auto& test_log = srslog::fetch_basic_logger("TEST", *spy, false);
test_log.set_level(srslog::basic_levels::info);
// Start the log backend.
srslog::init();
sched_diagnostic_printer printer(*spy);
srslte::logmap::set_default_log_level(srslte::LOG_LEVEL_INFO);
printf("[TESTER] This is the chosen seed: %u\n", seed);
uint32_t N_runs = 20;
@ -250,5 +275,7 @@ int main()
TESTASSERT(test_scell_activation(p) == SRSLTE_SUCCESS);
}
srslog::flush();
return 0;
}

@ -27,10 +27,10 @@ int test_pusch_collisions(const sf_output_res_t& sf_out, uint32_t enb_cc_idx, co
prbmask_t ul_allocs(nof_prb);
auto try_ul_fill = [&](prb_interval alloc, const char* ch_str, bool strict = true) {
CONDERROR(alloc.stop() > nof_prb, "Allocated RBs %s out-of-bounds\n", alloc.to_string().c_str());
CONDERROR(alloc.empty(), "Allocations must have at least one PRB\n");
CONDERROR(alloc.stop() > nof_prb, "Allocated RBs %s out-of-bounds", alloc.to_string().c_str());
CONDERROR(alloc.empty(), "Allocations must have at least one PRB");
if (strict and ul_allocs.any(alloc.start(), alloc.stop())) {
TESTERROR("Collision Detected of %s alloc=%s and cumulative_mask=0x%s\n",
TESTERROR("Collision Detected of %s alloc=%s and cumulative_mask=0x%s",
ch_str,
alloc.to_string().c_str(),
ul_allocs.to_hex().c_str());
@ -62,7 +62,7 @@ int test_pusch_collisions(const sf_output_res_t& sf_out, uint32_t enb_cc_idx, co
}
CONDERROR(expected_ul_mask != nullptr and *expected_ul_mask != ul_allocs,
"The derived UL PRB mask %s does not match the expected one %s\n",
"The derived UL PRB mask %s does not match the expected one %s",
ul_allocs.to_string().c_str(),
expected_ul_mask->to_string().c_str());
@ -80,7 +80,7 @@ int extract_dl_prbmask(const srslte_cell_t& cell,
alloc_mask.reset();
CONDERROR(srslte_ra_dl_dci_to_grant(&cell, &dl_sf, SRSLTE_TM1, false, &dci, &grant) == SRSLTE_ERROR,
"Failed to decode PDSCH grant\n");
"Failed to decode PDSCH grant");
for (uint32_t j = 0; j < alloc_mask.size(); ++j) {
if (grant.prb_idx[0][j]) {
alloc_mask.set(j);
@ -100,9 +100,9 @@ int test_pdsch_collisions(const sf_output_res_t& sf_out, uint32_t enb_cc_idx, co
if (extract_dl_prbmask(cell_params.cfg.cell, dci, alloc_mask) != SRSLTE_SUCCESS) {
return SRSLTE_ERROR;
}
CONDERROR(alloc_mask.none(), "DL allocation must occupy at least one RBG.\n");
CONDERROR(alloc_mask.none(), "DL allocation must occupy at least one RBG.");
if ((dl_allocs & alloc_mask).any()) {
TESTERROR("Detected collision in the DL %s allocation (%s intersects %s)\n",
TESTERROR("Detected collision in the DL %s allocation (%s intersects %s)",
channel,
dl_allocs.to_string().c_str(),
alloc_mask.to_string().c_str());
@ -141,14 +141,14 @@ int test_pdsch_collisions(const sf_output_res_t& sf_out, uint32_t enb_cc_idx, co
for (uint32_t i = 0; i < cell_params.nof_rbgs; ++i) {
uint32_t lim = SRSLTE_MIN((i + 1) * cell_params.P, dl_allocs.size());
bool val = dl_allocs.any(i * cell_params.P, lim);
CONDERROR(rev_alloc.any(i * cell_params.P, lim) and val, "No holes can be left in an RBG\n");
CONDERROR(rev_alloc.any(i * cell_params.P, lim) and val, "No holes can be left in an RBG");
if (val) {
rbgmask.set(i);
}
}
CONDERROR(expected_rbgmask != nullptr and *expected_rbgmask != rbgmask,
"The derived DL RBG mask %s does not match the expected one %s\n",
"The derived DL RBG mask %s does not match the expected one %s",
rbgmask.to_string().c_str(),
expected_rbgmask->to_string().c_str());
@ -174,17 +174,17 @@ int test_sib_scheduling(const sf_output_res_t& sf_out, uint32_t enb_cc_idx)
/* Test if SIB1 was correctly scheduled */
auto it = std::find_if(bc_begin, bc_end, [](bc_elem& elem) { return elem.index == 0; });
CONDERROR(sib1_expected and it == bc_end, "Failed to allocate SIB1 in even sfn, sf_idx==5\n");
CONDERROR(not sib1_expected and it != bc_end, "SIB1 allocated in wrong TTI.\n");
CONDERROR(sib1_expected and it == bc_end, "Failed to allocate SIB1 in even sfn, sf_idx==5");
CONDERROR(not sib1_expected and it != bc_end, "SIB1 allocated in wrong TTI.");
/* Test if any SIB was scheduled with wrong index, tbs, or outside of its window */
for (bc_elem* bc = bc_begin; bc != bc_end; ++bc) {
if (bc->index == 0) {
continue;
}
CONDERROR(bc->index >= sched_interface::MAX_SIBS, "Invalid SIB idx=%d\n", bc->index + 1);
CONDERROR(bc->index >= sched_interface::MAX_SIBS, "Invalid SIB idx=%d", bc->index + 1);
CONDERROR(bc->tbs < cell_params.cfg.sibs[bc->index].len,
"Allocated BC process with TBS=%d < sib_len=%d\n",
"Allocated BC process with TBS=%d < sib_len=%d",
bc->tbs,
cell_params.cfg.sibs[bc->index].len);
uint32_t x = (bc->index - 1) * cell_params.cfg.si_window_ms;
@ -195,7 +195,7 @@ int test_sib_scheduling(const sf_output_res_t& sf_out, uint32_t enb_cc_idx)
}
srslte::tti_point win_start{sfn_start * 10 + sf};
srslte::tti_interval window{win_start, win_start + cell_params.cfg.si_window_ms};
CONDERROR(not window.contains(to_tx_dl(sf_out.tti_rx)), "Scheduled SIB is outside of its SIB window\n");
CONDERROR(not window.contains(to_tx_dl(sf_out.tti_rx)), "Scheduled SIB is outside of its SIB window");
}
return SRSLTE_SUCCESS;
}
@ -215,14 +215,11 @@ int test_pdcch_collisions(const sf_output_res_t& sf_out,
// Helper Function: checks if there is any collision. If not, fills the PDCCH mask
auto try_cce_fill = [&](const srslte_dci_location_t& dci_loc, const char* ch) {
uint32_t cce_start = dci_loc.ncce, cce_stop = dci_loc.ncce + (1u << dci_loc.L);
CONDERROR(dci_loc.L == 0, "The aggregation level %d is not valid\n", dci_loc.L);
CONDERROR(dci_loc.L == 0, "The aggregation level %d is not valid", dci_loc.L);
CONDERROR(
cce_start >= ncce or cce_stop > ncce, "The CCE positions (%u, %u) do not fit in PDCCH\n", cce_start, cce_stop);
CONDERROR(used_cce.any(cce_start, cce_stop),
"%s DCI collision between CCE positions (%u, %u)\n",
ch,
cce_start,
cce_stop);
cce_start >= ncce or cce_stop > ncce, "The CCE positions (%u, %u) do not fit in PDCCH", cce_start, cce_stop);
CONDERROR(
used_cce.any(cce_start, cce_stop), "%s DCI collision between CCE positions (%u, %u)", ch, cce_start, cce_stop);
used_cce.fill(cce_start, cce_stop);
return SRSLTE_SUCCESS;
};
@ -247,7 +244,7 @@ int test_pdcch_collisions(const sf_output_res_t& sf_out,
}
CONDERROR(expected_cce_mask != nullptr and *expected_cce_mask != used_cce,
"The derived PDCCH mask %s does not match the expected one %s\n",
"The derived PDCCH mask %s does not match the expected one %s",
used_cce.to_string().c_str(),
expected_cce_mask->to_string().c_str());
@ -264,18 +261,18 @@ int test_dci_content_common(const sf_output_res_t& sf_out, uint32_t enb_cc_idx)
for (uint32_t i = 0; i < ul_result.nof_dci_elems; ++i) {
const auto& pusch = ul_result.pusch[i];
uint16_t rnti = pusch.dci.rnti;
CONDERROR(pusch.tbs == 0, "Allocated PUSCH with invalid TBS=%d\n", pusch.tbs);
CONDERROR(alloc_rntis.count(rnti) > 0, "The user rnti=0x%x got allocated multiple times in UL\n", rnti);
CONDERROR(pusch.tbs == 0, "Allocated PUSCH with invalid TBS=%d", pusch.tbs);
CONDERROR(alloc_rntis.count(rnti) > 0, "The user rnti=0x%x got allocated multiple times in UL", rnti);
alloc_rntis.insert(pusch.dci.rnti);
CONDERROR(not((pusch.current_tx_nb == 0) xor (pusch.dci.tb.rv != 0)), "Number of txs incorrectly set\n");
CONDERROR(not((pusch.current_tx_nb == 0) xor (pusch.dci.tb.rv != 0)), "Number of txs incorrectly set");
if (not pusch.needs_pdcch) {
// In case of non-adaptive retx or Msg3
continue;
}
if (pusch.dci.tb.rv == 0) {
// newTx
CONDERROR(pusch.dci.format != SRSLTE_DCI_FORMAT0, "Incorrect UL DCI format\n");
CONDERROR(pusch.dci.tb.mcs_idx > 28, "Incorrect UL MCS index\n");
CONDERROR(pusch.dci.format != SRSLTE_DCI_FORMAT0, "Incorrect UL DCI format");
CONDERROR(pusch.dci.tb.mcs_idx > 28, "Incorrect UL MCS index");
}
}
@ -283,8 +280,8 @@ int test_dci_content_common(const sf_output_res_t& sf_out, uint32_t enb_cc_idx)
for (uint32_t i = 0; i < dl_result.nof_data_elems; ++i) {
auto& data = dl_result.data[i];
uint16_t rnti = data.dci.rnti;
CONDERROR(data.tbs[0] == 0 and data.tbs[1] == 0, "Allocated DL data has empty TBS\n");
CONDERROR(alloc_rntis.count(rnti) > 0, "The user rnti=0x%x got allocated multiple times in DL\n", rnti);
CONDERROR(data.tbs[0] == 0 and data.tbs[1] == 0, "Allocated DL data has empty TBS");
CONDERROR(alloc_rntis.count(rnti) > 0, "The user rnti=0x%x got allocated multiple times in DL", rnti);
alloc_rntis.insert(data.dci.rnti);
for (uint32_t tb = 0; tb < 2; ++tb) {
if (data.tbs[tb] == 0) {
@ -292,15 +289,15 @@ int test_dci_content_common(const sf_output_res_t& sf_out, uint32_t enb_cc_idx)
}
if (data.dci.tb[tb].rv == 0) {
// newTx
CONDERROR(data.nof_pdu_elems[tb] == 0, "Allocated DL grant does not have MAC SDUs\n");
CONDERROR(data.nof_pdu_elems[tb] == 0, "Allocated DL grant does not have MAC SDUs");
CONDERROR(data.nof_pdu_elems[tb] > sched_interface::MAX_RLC_PDU_LIST,
"Number of SDUs in DL grant exceeds limit\n");
"Number of SDUs in DL grant exceeds limit");
uint32_t alloc_bytes = 0;
for (uint32_t pdu = 0; pdu < data.nof_pdu_elems[tb]; ++pdu) {
alloc_bytes += data.pdu[tb][pdu].nbytes;
}
CONDERROR(alloc_bytes > data.tbs[tb], "The bytes allocated to individual MAC SDUs is larger than total TBS\n");
CONDERROR(data.dci.tb[tb].mcs_idx > 28, "Incorrect DL MCS index\n");
CONDERROR(alloc_bytes > data.tbs[tb], "The bytes allocated to individual MAC SDUs is larger than total TBS");
CONDERROR(data.dci.tb[tb].mcs_idx > 28, "Incorrect DL MCS index");
}
}
}
@ -308,18 +305,18 @@ int test_dci_content_common(const sf_output_res_t& sf_out, uint32_t enb_cc_idx)
auto& bc = dl_result.bc[i];
if (bc.type == sched_interface::dl_sched_bc_t::BCCH) {
CONDERROR(bc.tbs < cell_params.cfg.sibs[bc.index].len,
"Allocated BC process with TBS=%d < sib_len=%d\n",
"Allocated BC process with TBS=%d < sib_len=%d",
bc.tbs,
cell_params.cfg.sibs[bc.index].len);
} else if (bc.type == sched_interface::dl_sched_bc_t::PCCH) {
CONDERROR(bc.tbs == 0, "Allocated paging process with invalid TBS=%d\n", bc.tbs);
CONDERROR(bc.tbs == 0, "Allocated paging process with invalid TBS=%d", bc.tbs);
} else {
TESTERROR("Invalid broadcast process id=%d\n", (int)bc.type);
TESTERROR("Invalid broadcast process id=%d", (int)bc.type);
}
}
for (uint32_t i = 0; i < dl_result.nof_rar_elems; ++i) {
const auto& rar = dl_result.rar[i];
CONDERROR(rar.tbs == 0, "Allocated RAR process with invalid TBS=%d\n", rar.tbs);
CONDERROR(rar.tbs == 0, "Allocated RAR process with invalid TBS=%d", rar.tbs);
}
return SRSLTE_SUCCESS;

@ -128,7 +128,7 @@ int test_pdcch_one_ue()
TESTASSERT(pdcch_result[1]->total_mask == (pdcch_result[0]->current_mask | pdcch_result[1]->current_mask));
TESTASSERT(std::count(dci_locs, dci_locs + nof_dci_locs, pdcch_result[0]->dci_pos.ncce) > 0);
srslte::logmap::get("TEST")->info("PDCCH alloc result: %s\n", pdcch.result_to_string(true).c_str());
srslog::fetch_basic_logger("TEST").info("PDCCH alloc result: %s", pdcch.result_to_string(true).c_str());
}
TESTASSERT(tti_counter == nof_ttis);
@ -139,8 +139,16 @@ int main()
{
srsenb::set_randseed(seed);
printf("This is the chosen seed: %u\n", seed);
srslte::logmap::get("TEST")->set_level(srslte::LOG_LEVEL_INFO);
auto& test_log = srslog::fetch_basic_logger("TEST", false);
test_log.set_level(srslog::basic_levels::info);
// Start the log backend.
srslog::init();
TESTASSERT(test_pdcch_one_ue() == SRSLTE_SUCCESS);
srslog::flush();
printf("Success\n");
}

@ -17,10 +17,12 @@
using namespace srsenb;
const uint32_t seed = std::chrono::system_clock::now().time_since_epoch().count();
uint32_t rlc_overhead(uint32_t lcid)
{
return lcid == 0 ? 0 : 3;
}
uint32_t add_rlc_overhead(uint32_t lcid, uint32_t rlc_payload_size)
{
return rlc_payload_size + (rlc_payload_size == 0 ? 0 : rlc_overhead(lcid));
@ -190,9 +192,17 @@ int main()
{
srsenb::set_randseed(seed);
srslte::console("This is the chosen seed: %u\n", seed);
srslte::logmap::get("TEST")->set_level(srslte::LOG_LEVEL_INFO);
auto& test_log = srslog::fetch_basic_logger("TEST", false);
test_log.set_level(srslog::basic_levels::info);
// Start the log backend.
srslog::init();
TESTASSERT(test_lc_ch_pbr_infinity() == SRSLTE_SUCCESS);
TESTASSERT(test_lc_ch_pbr_finite() == SRSLTE_SUCCESS);
srslog::flush();
srslte::console("Success\n");
}

@ -40,7 +40,8 @@ bool sim_ue_ctxt_t::is_last_dl_retx(uint32_t ue_cc_idx, uint32_t pid) const
ue_sim::ue_sim(uint16_t rnti_,
const sched_interface::ue_cfg_t& ue_cfg_,
srslte::tti_point prach_tti_rx_,
uint32_t preamble_idx)
uint32_t preamble_idx) :
logger(srslog::fetch_basic_logger("MAC"))
{
ctxt.rnti = rnti_;
ctxt.prach_tti_rx = prach_tti_rx_;
@ -214,14 +215,14 @@ int sched_sim_base::add_user(uint16_t rnti, const sched_interface::ue_cfg_t& ue_
{
CONDERROR(!srslte_prach_tti_opportunity_config_fdd(
(*cell_params)[ue_cfg_.supported_cc_list[0].enb_cc_idx].prach_config, current_tti_rx.to_uint(), -1),
"New user added in a non-PRACH TTI\n");
"New user added in a non-PRACH TTI");
TESTASSERT(ue_db.count(rnti) == 0);
final_ue_cfg[rnti] = ue_cfg_;
auto rach_cfg = generate_rach_ue_cfg(ue_cfg_);
ue_db.insert(std::make_pair(rnti, ue_sim(rnti, rach_cfg, current_tti_rx, preamble_idx)));
CONDERROR(sched_ptr->ue_cfg(rnti, rach_cfg) != SRSLTE_SUCCESS, "Configuring new user rnti=0x%x to sched\n", rnti);
CONDERROR(sched_ptr->ue_cfg(rnti, rach_cfg) != SRSLTE_SUCCESS, "Configuring new user rnti=0x%x to sched", rnti);
sched_interface::dl_sched_rar_info_t rar_info = {};
rar_info.prach_tti = current_tti_rx.to_uint();
@ -236,9 +237,9 @@ int sched_sim_base::add_user(uint16_t rnti, const sched_interface::ue_cfg_t& ue_
int sched_sim_base::ue_recfg(uint16_t rnti, const sched_interface::ue_cfg_t& ue_cfg_)
{
CONDERROR(ue_db.count(rnti) == 0, "User must already exist to be configured\n");
CONDERROR(ue_db.count(rnti) == 0, "User must already exist to be configured");
ue_db.at(rnti).set_cfg(ue_cfg_);
CONDERROR(sched_ptr->ue_cfg(rnti, ue_cfg_) != SRSLTE_SUCCESS, "Configuring new user rnti=0x%x to sched\n", rnti);
CONDERROR(sched_ptr->ue_cfg(rnti, ue_cfg_) != SRSLTE_SUCCESS, "Configuring new user rnti=0x%x to sched", rnti);
return SRSLTE_SUCCESS;
}
@ -330,7 +331,7 @@ int sched_sim_base::apply_tti_events(sim_ue_ctxt_t& ue_ctxt, const ue_tti_events
auto& h = ue_ctxt.cc_list[cc_feedback.ue_cc_idx].dl_harqs[cc_feedback.dl_pid];
if (cc_feedback.dl_ack) {
log_h->info("DL ACK rnti=0x%x tti_dl_tx=%u pid=%d\n",
logger.info("DL ACK rnti=0x%x tti_dl_tx=%u pid=%d",
ue_ctxt.rnti,
to_tx_dl(h.last_tti_rx).to_uint(),
cc_feedback.dl_pid);
@ -339,7 +340,7 @@ int sched_sim_base::apply_tti_events(sim_ue_ctxt_t& ue_ctxt, const ue_tti_events
// update scheduler
if (sched_ptr->dl_ack_info(
events.tti_rx.to_uint(), ue_ctxt.rnti, enb_cc_idx, cc_feedback.tb, cc_feedback.dl_ack) < 0) {
log_h->error("The ACKed DL Harq pid=%d does not exist.\n", cc_feedback.dl_pid);
logger.error("The ACKed DL Harq pid=%d does not exist.", cc_feedback.dl_pid);
error_counter++;
}
@ -353,7 +354,7 @@ int sched_sim_base::apply_tti_events(sim_ue_ctxt_t& ue_ctxt, const ue_tti_events
auto& h = ue_ctxt.cc_list[cc_feedback.ue_cc_idx].ul_harqs[cc_feedback.dl_pid];
if (cc_feedback.ul_ack) {
log_h->info("UL ACK rnti=0x%x tti_ul_tx=%u pid=%d\n",
logger.info("UL ACK rnti=0x%x tti_ul_tx=%u pid=%d",
ue_ctxt.rnti,
to_tx_ul(h.last_tti_rx).to_uint(),
cc_feedback.ul_pid);
@ -361,7 +362,7 @@ int sched_sim_base::apply_tti_events(sim_ue_ctxt_t& ue_ctxt, const ue_tti_events
// update scheduler
if (sched_ptr->ul_crc_info(events.tti_rx.to_uint(), ue_ctxt.rnti, enb_cc_idx, cc_feedback.ul_ack) < 0) {
log_h->error("The ACKed UL Harq pid=%d does not exist.\n", cc_feedback.ul_pid);
logger.error("The ACKed UL Harq pid=%d does not exist.", cc_feedback.ul_pid);
error_counter++;
}
}

@ -15,6 +15,7 @@
#include "sched_common_test_suite.h"
#include "srslte/interfaces/sched_interface.h"
#include "srslte/srslog/srslog.h"
#include <bitset>
namespace srsenb {
@ -90,7 +91,7 @@ private:
void update_dl_harqs(const sf_output_res_t& sf_out);
void update_ul_harqs(const sf_output_res_t& sf_out);
srslte::log_ref log_h{"MAC"};
srslog::basic_logger& logger;
sim_ue_ctxt_t ctxt;
};
@ -98,7 +99,7 @@ class sched_sim_base
{
public:
sched_sim_base(sched_interface* sched_ptr_, const std::vector<sched_interface::cell_cfg_t>& cell_params_) :
sched_ptr(sched_ptr_), cell_params(&cell_params_)
logger(srslog::fetch_basic_logger("MAC")), sched_ptr(sched_ptr_), cell_params(&cell_params_)
{
sched_ptr->cell_cfg(cell_params_); // call parent cfg
}
@ -142,7 +143,7 @@ private:
int set_default_tti_events(const sim_ue_ctxt_t& ue_ctxt, ue_tti_events& pending_events);
int apply_tti_events(sim_ue_ctxt_t& ue_ctxt, const ue_tti_events& events);
srslte::log_ref log_h{"MAC"};
srslog::basic_logger& logger;
sched_interface* sched_ptr;
const std::vector<sched_interface::cell_cfg_t>* cell_params;

@ -130,14 +130,12 @@ int common_sched_tester::sim_cfg(sim_sched_args args)
sched_sim.reset(new sched_sim_random{this, sim_args0.cell_cfg});
sched_stats.reset(new sched_result_stats{sim_args0.cell_cfg});
tester_log = sim_args0.sim_log;
return SRSLTE_SUCCESS;
}
int common_sched_tester::add_user(uint16_t rnti, const ue_ctxt_test_cfg& ue_cfg_)
{
tester_log->info("Adding user rnti=0x%x\n", rnti);
logger.info("Adding user rnti=0x%x", rnti);
sched_sim->ue_sim_cfg_map[rnti] = ue_cfg_;
return sched_sim->add_user(rnti, ue_cfg_.ue_cfg, tti_info.nof_prachs++);
}
@ -149,7 +147,7 @@ int common_sched_tester::reconf_user(uint16_t rnti, const sched_interface::ue_cf
int common_sched_tester::rem_user(uint16_t rnti)
{
tester_log->info("Removing user rnti=0x%x\n", rnti);
logger.info("Removing user rnti=0x%x", rnti);
sched_sim->ue_sim_cfg_map.erase(rnti);
return sched_sim->rem_user(rnti);
}
@ -168,7 +166,7 @@ void common_sched_tester::new_test_tti()
tti_info.dl_sched_result.resize(sched_cell_params.size());
tti_info.ul_sched_result.resize(sched_cell_params.size());
tester_log->step(tti_rx.to_uint());
logger.set_context(tti_rx.to_uint());
}
int common_sched_tester::run_ue_ded_tests_and_update_ctxt(const sf_output_res_t& sf_out)
@ -215,7 +213,7 @@ int common_sched_tester::process_tti_events(const tti_ev& tti_ev)
// configure bearers
if (ue_ev.bearer_cfg != nullptr) {
CONDERROR(not sched_sim->user_exists(ue_ev.rnti), "User rnti=0x%x does not exist\n", ue_ev.rnti);
CONDERROR(not sched_sim->user_exists(ue_ev.rnti), "User rnti=0x%x does not exist", ue_ev.rnti);
// TODO: Instantiate more bearers
TESTASSERT(sched_sim->bearer_cfg(ue_ev.rnti, 0, *ue_ev.bearer_cfg) == SRSLTE_SUCCESS);
}
@ -224,7 +222,7 @@ int common_sched_tester::process_tti_events(const tti_ev& tti_ev)
// push UL SRs and DL packets
if (ue_ev.buffer_ev != nullptr) {
CONDERROR(user == nullptr, "TESTER ERROR: Trying to schedule data for user that does not exist\n");
CONDERROR(user == nullptr, "TESTER ERROR: Trying to schedule data for user that does not exist");
const auto& ue_sim_ctxt = user->get_ctxt();
if (ue_ev.buffer_ev->dl_data > 0 and ue_sim_ctxt.conres_rx) {
// If Msg4 has already been tx and there DL data to transmit
@ -249,7 +247,7 @@ int common_sched_tester::process_tti_events(const tti_ev& tti_ev)
int common_sched_tester::run_tti(const tti_ev& tti_events)
{
new_test_tti();
tester_log->info("---- tti=%u | nof_ues=%zd ----\n", tti_rx.to_uint(), ue_db.size());
logger.info("---- tti=%u | nof_ues=%zd ----", tti_rx.to_uint(), ue_db.size());
sched_sim->new_tti(tti_rx);
process_tti_events(tti_events);

@ -16,6 +16,7 @@
#include "sched_sim_ue.h"
#include "sched_test_utils.h"
#include "srsenb/hdr/stack/mac/sched.h"
#include "srslte/srslog/srslog.h"
#include <random>
namespace srsenb {
@ -78,6 +79,7 @@ public:
std::vector<sched_interface::ul_sched_res_t> ul_sched_result;
};
common_sched_tester() : logger(srslog::fetch_basic_logger("TEST")) {}
~common_sched_tester() override = default;
const ue_cfg_t* get_current_ue_cfg(uint16_t rnti) const;
@ -96,7 +98,7 @@ public:
// args
sim_sched_args sim_args0; ///< arguments used to generate TTI events
srslte::log* tester_log = nullptr;
srslog::basic_logger& logger;
// tti specific params
tti_info_t tti_info;

@ -48,34 +48,38 @@ ue_stats_t ue_tot_stats;
* Logging *
*******************/
class sched_test_log final : public srslte::test_log_filter
/// RAII style class that prints the test diagnostic info on destruction.
class sched_diagnostic_printer
{
public:
sched_test_log() : srslte::test_log_filter("TEST") { exit_on_error = true; }
~sched_test_log() override { log_diagnostics(); }
explicit sched_diagnostic_printer(srslte::log_sink_spy& s) : s(s) {}
void log_diagnostics() override
~sched_diagnostic_printer()
{
info("UE stats:\n");
info("all: {DL/UL RBs: %" PRIu32 "/%" PRIu32 ", DL/UL bitrates: %0.2f/%0.2f Mbps}\n",
auto& logger = srslog::fetch_basic_logger("TEST");
logger.info("UE stats:");
logger.info("all: {DL/UL RBs: %" PRIu32 "/%" PRIu32 ", DL/UL bitrates: %0.2f/%0.2f Mbps}",
ue_tot_stats.nof_dl_rbs,
ue_tot_stats.nof_ul_rbs,
ue_tot_stats.nof_dl_bytes * 8 * 0.001 / ue_tot_stats.nof_ttis,
ue_tot_stats.nof_ul_bytes * 8 * 0.001 / ue_tot_stats.nof_ttis);
for (auto& e : ue_stats) {
info("0x%x: {DL/UL RBs: %" PRIu32 "/%" PRIu32 ", DL/UL bitrates: %0.2f/%0.2f Mbps}\n",
for (const auto& e : ue_stats) {
logger.info("0x%x: {DL/UL RBs: %" PRIu32 "/%" PRIu32 ", DL/UL bitrates: %0.2f/%0.2f Mbps}",
e.first,
e.second.nof_dl_rbs,
e.second.nof_ul_rbs,
e.second.nof_dl_bytes * 8 * 0.001 / e.second.nof_ttis,
e.second.nof_ul_bytes * 8 * 0.001 / e.second.nof_ttis);
}
info("Number of assertion warnings: %u\n", warn_counter);
info("Number of assertion errors: %u\n", error_counter);
info("This was the seed: %u\n", seed);
logger.info("Number of assertion warnings: %u", s.get_warning_counter());
logger.info("Number of assertion errors: %u", s.get_error_counter());
logger.info("This was the seed: %u", seed);
srslog::flush();
}
private:
srslte::log_sink_spy& s;
};
srslte::scoped_log<sched_test_log> log_global{};
/*******************
* Dummies *
@ -164,10 +168,10 @@ int sched_tester::test_harqs()
uint16_t rnti = data.dci.rnti;
const srsenb::dl_harq_proc& h = ue_db[rnti].get_dl_harq(h_id, CARRIER_IDX);
CONDERROR(h.get_tti() != srsenb::to_tx_dl(tti_rx),
"The scheduled DL harq pid=%d does not a valid tti=%u\n",
"The scheduled DL harq pid=%d does not a valid tti=%u",
h_id,
srsenb::to_tx_dl(tti_rx).to_uint());
CONDERROR(h.get_n_cce() != data.dci.location.ncce, "Harq DCI location does not match with result\n");
CONDERROR(h.get_n_cce() != data.dci.location.ncce, "Harq DCI location does not match with result");
}
/* Check PHICH allocations */
@ -175,20 +179,20 @@ int sched_tester::test_harqs()
const auto& phich = tti_info.ul_sched_result[CARRIER_IDX].phich[i];
const auto& hprev = tti_data.ue_data[phich.rnti].ul_harq;
const auto* h = ue_db[phich.rnti].get_ul_harq(srsenb::to_tx_ul(tti_rx), CARRIER_IDX);
CONDERROR(not hprev.has_pending_phich(), "Alloc PHICH did not have any pending ack\n");
CONDERROR(not hprev.has_pending_phich(), "Alloc PHICH did not have any pending ack");
bool maxretx_flag = hprev.nof_retx(0) + 1 >= hprev.max_nof_retx();
if (phich.phich == sched_interface::ul_sched_phich_t::ACK) {
// The harq can be either ACKed or Resumed
if (not hprev.is_empty()) {
// In case it was resumed
CONDERROR(h == nullptr or h->is_empty(), "Cannot resume empty UL harq\n");
CONDERROR(h == nullptr or h->is_empty(), "Cannot resume empty UL harq");
for (uint32_t j = 0; j < tti_info.ul_sched_result[CARRIER_IDX].nof_dci_elems; ++j) {
auto& pusch = tti_info.ul_sched_result[CARRIER_IDX].pusch[j];
CONDERROR(pusch.dci.rnti == phich.rnti, "Cannot send PHICH::ACK for same harq that got UL grant.\n");
CONDERROR(pusch.dci.rnti == phich.rnti, "Cannot send PHICH::ACK for same harq that got UL grant.");
}
}
} else {
CONDERROR(h->get_pending_data() == 0 and !maxretx_flag, "NACKed harq has no pending data\n");
CONDERROR(h->get_pending_data() == 0 and !maxretx_flag, "NACKed harq has no pending data");
}
}
@ -285,7 +289,6 @@ sched_sim_events rand_sim_params(uint32_t nof_ttis)
sim_gen.sim_args.default_ue_sim_cfg.ue_cfg.measgap_offset = std::uniform_int_distribution<uint32_t>{
0, sim_gen.sim_args.default_ue_sim_cfg.ue_cfg.measgap_period}(srsenb::get_rand_gen());
sim_gen.sim_args.start_tti = 0;
sim_gen.sim_args.sim_log = log_global.get();
sim_gen.sim_args.sched_args.pdsch_mcs =
boolean_dist() ? -1 : std::uniform_int_distribution<>{0, 24}(srsenb::get_rand_gen());
sim_gen.sim_args.sched_args.pusch_mcs =
@ -326,9 +329,29 @@ int main()
srsenb::set_randseed(seed);
printf("This is the chosen seed: %u\n", seed);
srslte::logmap::set_default_log_level(srslte::LOG_LEVEL_INFO);
// Setup the log spy to intercept error and warning log entries.
if (!srslog::install_custom_sink(
srslte::log_sink_spy::name(),
std::unique_ptr<srslte::log_sink_spy>(new srslte::log_sink_spy(srslog::get_default_log_formatter())))) {
return SRSLTE_ERROR;
}
auto* spy = static_cast<srslte::log_sink_spy*>(srslog::find_sink(srslte::log_sink_spy::name()));
if (!spy) {
return SRSLTE_ERROR;
}
auto& mac_log = srslog::fetch_basic_logger("MAC");
mac_log.set_level(srslog::basic_levels::info);
auto& test_log = srslog::fetch_basic_logger("TEST", *spy, false);
test_log.set_level(srslog::basic_levels::info);
// Start the log backend.
srslog::init();
uint32_t N_runs = 1, nof_ttis = 10240 + 10;
sched_diagnostic_printer printer(*spy);
for (uint32_t n = 0; n < N_runs; ++n) {
printf("Sim run number: %u\n", n + 1);
sched_sim_events sim = rand_sim_params(nof_ttis);

@ -154,7 +154,6 @@ struct tti_ev {
struct sim_sched_args {
uint32_t start_tti = 0;
std::vector<srsenb::sched_interface::cell_cfg_t> cell_cfg;
srslte::log* sim_log = nullptr;
ue_ctxt_test_cfg default_ue_sim_cfg{};
srsenb::sched_interface::sched_args_t sched_args = {};
};

@ -67,28 +67,28 @@ int test_pdsch_grant(const sim_enb_ctxt_t& enb_ctxt,
const sched_interface::cell_cfg_t& cell_params = (*enb_ctxt.cell_params)[enb_cc_idx];
// TEST: Check if CC is configured and active
CONDERROR(cc_cfg == nullptr or not cc_cfg->active, "PDSCH allocation for disabled or unavailable cc\n");
CONDERROR(cc_cfg == nullptr or not cc_cfg->active, "PDSCH allocation for disabled or unavailable cc");
CONDERROR(pdsch.dci.ue_cc_idx != std::distance(&ue_ctxt.ue_cfg.supported_cc_list.front(), cc_cfg),
"Inconsistent enb_cc_idx -> ue_cc_idx mapping\n");
"Inconsistent enb_cc_idx -> ue_cc_idx mapping");
// TEST: DCI is consistent with current UE DL harq state
auto& h = ue_ctxt.cc_list[pdsch.dci.ue_cc_idx].dl_harqs[pdsch.dci.pid];
uint32_t nof_retx = get_nof_retx(pdsch.dci.tb[0].rv); // 0..3
if (h.nof_txs == 0 or h.ndi != pdsch.dci.tb[0].ndi) {
// It is newtx
CONDERROR(nof_retx != 0, "Invalid rv index for new tx\n");
CONDERROR(h.active, "DL newtx for already active DL harq pid=%d\n", h.pid);
CONDERROR(nof_retx != 0, "Invalid rv index for new tx");
CONDERROR(h.active, "DL newtx for already active DL harq pid=%d", h.pid);
} else {
// it is retx
CONDERROR(get_rvidx(h.nof_retxs + 1) != (uint32_t)pdsch.dci.tb[0].rv, "Invalid rv index for retx\n");
CONDERROR(not h.active, "retx for inactive dl harq pid=%d\n", h.pid);
CONDERROR(to_tx_dl_ack(h.last_tti_rx) > tti_rx, "harq pid=%d reused too soon\n", h.pid);
CONDERROR(get_rvidx(h.nof_retxs + 1) != (uint32_t)pdsch.dci.tb[0].rv, "Invalid rv index for retx");
CONDERROR(not h.active, "retx for inactive dl harq pid=%d", h.pid);
CONDERROR(to_tx_dl_ack(h.last_tti_rx) > tti_rx, "harq pid=%d reused too soon", h.pid);
CONDERROR(h.nof_retxs + 1 > ue_ctxt.ue_cfg.maxharq_tx,
"The number of retx=%d exceeded its max=%d\n",
"The number of retx=%d exceeded its max=%d",
h.nof_retxs + 1,
ue_ctxt.ue_cfg.maxharq_tx);
// CONDERROR(h.dci_loc.L != pdsch.dci.location.L, "Harq DCI aggregation level changed.\n");
CONDERROR(h.tbs != pdsch.tbs[0], "TBS changed during HARQ retx\n");
// CONDERROR(h.dci_loc.L != pdsch.dci.location.L, "Harq DCI aggregation level changed.");
CONDERROR(h.tbs != pdsch.tbs[0], "TBS changed during HARQ retx");
}
// TEST: max coderate is not exceeded
@ -104,7 +104,7 @@ int test_pdsch_grant(const sim_enb_ctxt_t& enb_ctxt,
srslte_mod_t mod = srslte_ra_dl_mod_from_mcs(pdsch.dci.tb[0].mcs_idx, ue_ctxt.ue_cfg.use_tbs_index_alt);
uint32_t max_Qm = ue_ctxt.ue_cfg.use_tbs_index_alt ? 8 : 6;
uint32_t Qm = std::min(max_Qm, srslte_mod_bits_x_symbol(mod));
CONDERROR(coderate > 0.930f * Qm, "Max coderate was exceeded\n");
CONDERROR(coderate > 0.930f * Qm, "Max coderate was exceeded");
}
return SRSLTE_SUCCESS;
@ -116,7 +116,7 @@ int test_dl_sched_result(const sim_enb_ctxt_t& enb_ctxt, const sf_output_res_t&
for (uint32_t i = 0; i < sf_out.dl_cc_result[cc].nof_data_elems; ++i) {
const sched_interface::dl_sched_data_t& data = sf_out.dl_cc_result[cc].data[i];
CONDERROR(
enb_ctxt.ue_db.count(data.dci.rnti) == 0, "Allocated DL grant for non-existent rnti=0x%x\n", data.dci.rnti);
enb_ctxt.ue_db.count(data.dci.rnti) == 0, "Allocated DL grant for non-existent rnti=0x%x", data.dci.rnti);
TESTASSERT(test_pdsch_grant(enb_ctxt, sf_out, cc, data) == SRSLTE_SUCCESS);
}
}
@ -137,7 +137,7 @@ int test_ul_sched_result(const sim_enb_ctxt_t& enb_ctxt, const sf_output_res_t&
CONDERROR(std::any_of(phich_begin,
phich_end,
[&enb_ctxt](const phich_t& phich) { return enb_ctxt.ue_db.count(phich.rnti) == 0; }),
"Scheduled PHICH does not have associated rnti\n");
"Scheduled PHICH does not have associated rnti");
// TEST: rnti must exist for all PUSCH
CONDERROR(std::any_of(pusch_begin,
@ -157,8 +157,8 @@ int test_ul_sched_result(const sim_enb_ctxt_t& enb_ctxt, const sf_output_res_t&
// TEST: Check that idle CCs do not receive PUSCH grants or PHICH
if (ue_cc_idx < 0 or not ue.ue_cfg.supported_cc_list[ue_cc_idx].active) {
CONDERROR(phich_ptr != nullptr, "PHICH cannot be allocated in idle cells\n");
CONDERROR(pusch_ptr != nullptr, "PUSCH cannot be allocated in idle cells\n");
CONDERROR(phich_ptr != nullptr, "PHICH cannot be allocated in idle cells");
CONDERROR(pusch_ptr != nullptr, "PUSCH cannot be allocated in idle cells");
continue;
}
@ -170,44 +170,44 @@ int test_ul_sched_result(const sim_enb_ctxt_t& enb_ctxt, const sf_output_res_t&
// TEST: Already active UL HARQs have to receive PHICH
CONDERROR(
h.active and phich_ptr == nullptr, "PHICH not received for rnti=0x%x active UL HARQ pid=%d\n", rnti, pid);
h.active and phich_ptr == nullptr, "PHICH not received for rnti=0x%x active UL HARQ pid=%d", rnti, pid);
CONDERROR(not h.active and phich_ptr != nullptr,
"PHICH for rnti=0x%x corresponds to inactive UL HARQ pid=%d\n",
"PHICH for rnti=0x%x corresponds to inactive UL HARQ pid=%d",
rnti,
pid);
// TEST: absent PUSCH grants for active UL HARQs must be either ACKs, last retx, or interrupted HARQs
if ((phich_ptr != nullptr) and (pusch_ptr == nullptr)) {
CONDERROR(not h_inactive, "PHICH NACK received for rnti=0x%x but no PUSCH retx reallocated\n", rnti);
CONDERROR(not h_inactive, "PHICH NACK received for rnti=0x%x but no PUSCH retx reallocated", rnti);
}
if (pusch_ptr != nullptr) {
CONDERROR(pusch_ptr->dci.ue_cc_idx != (uint32_t)ue_cc_idx, "Inconsistent enb_cc_idx -> ue_cc_idx mapping\n");
CONDERROR(pusch_ptr->dci.ue_cc_idx != (uint32_t)ue_cc_idx, "Inconsistent enb_cc_idx -> ue_cc_idx mapping");
// TEST: DCI is consistent with current UE UL harq state
uint32_t nof_retx = get_nof_retx(pusch_ptr->dci.tb.rv); // 0..3
if (h.nof_txs == 0 or h.ndi != pusch_ptr->dci.tb.ndi) {
// newtx
CONDERROR(nof_retx != 0, "Invalid rv index for new tx\n");
CONDERROR(pusch_ptr->current_tx_nb != 0, "UL HARQ retxs need to have been previously transmitted\n");
CONDERROR(not h_inactive, "New tx for already active UL HARQ\n");
CONDERROR(nof_retx != 0, "Invalid rv index for new tx");
CONDERROR(pusch_ptr->current_tx_nb != 0, "UL HARQ retxs need to have been previously transmitted");
CONDERROR(not h_inactive, "New tx for already active UL HARQ");
} else {
CONDERROR(pusch_ptr->current_tx_nb == 0, "UL retx has to have nof tx > 0\n");
CONDERROR(pusch_ptr->current_tx_nb == 0, "UL retx has to have nof tx > 0");
if (not h.active) {
// the HARQ is being resumed
CONDERROR(not pusch_ptr->needs_pdcch, "Resumed UL HARQs need to be signalled in PDCCH\n");
CONDERROR(not pusch_ptr->needs_pdcch, "Resumed UL HARQs need to be signalled in PDCCH");
} else {
if (pusch_ptr->needs_pdcch) {
CONDERROR(pusch_ptr->dci.type2_alloc.riv == h.riv, "Adaptive retx must change riv\n");
CONDERROR(pusch_ptr->dci.type2_alloc.riv == h.riv, "Adaptive retx must change riv");
} else {
// non-adaptive retx
CONDERROR(pusch_ptr->dci.type2_alloc.riv != h.riv, "Non-adaptive retx must keep the same riv\n");
CONDERROR(pusch_ptr->dci.type2_alloc.riv != h.riv, "Non-adaptive retx must keep the same riv");
}
}
CONDERROR(get_rvidx(h.nof_retxs + 1) != (uint32_t)pusch_ptr->dci.tb.rv, "Invalid rv index for retx\n");
CONDERROR(h.tbs != pusch_ptr->tbs, "TBS changed during HARQ retx\n");
CONDERROR(to_tx_ul(h.last_tti_rx) > sf_out.tti_rx, "UL harq pid=%d was reused too soon\n", h.pid);
CONDERROR(get_rvidx(h.nof_retxs + 1) != (uint32_t)pusch_ptr->dci.tb.rv, "Invalid rv index for retx");
CONDERROR(h.tbs != pusch_ptr->tbs, "TBS changed during HARQ retx");
CONDERROR(to_tx_ul(h.last_tti_rx) > sf_out.tti_rx, "UL harq pid=%d was reused too soon", h.pid);
}
}
}
@ -238,11 +238,11 @@ int test_ra(const sim_enb_ctxt_t& enb_ctxt, const sf_output_res_t& sf_out)
if (not rar_window.contains(tti_tx_dl)) {
CONDERROR(not ue.rar_tti_rx.is_valid() and tti_tx_dl > rar_window.stop(),
"rnti=0x%x RAR not scheduled within the RAR Window\n",
"rnti=0x%x RAR not scheduled within the RAR Window",
rnti);
for (uint32_t i = 0; i < sf_out.dl_cc_result[cc].nof_rar_elems; ++i) {
CONDERROR(sf_out.dl_cc_result[cc].rar[i].dci.rnti == rnti,
"No RAR allocations allowed outside of user RAR window\n");
"No RAR allocations allowed outside of user RAR window");
}
} else {
// Inside RAR window
@ -251,19 +251,19 @@ int test_ra(const sim_enb_ctxt_t& enb_ctxt, const sf_output_res_t& sf_out)
for (const auto& grant : dl_cc_res.rar[i].msg3_grant) {
const auto& data = grant.data;
if (data.prach_tti == (uint32_t)ue.prach_tti_rx.to_uint() and data.preamble_idx == ue.preamble_idx) {
CONDERROR(rnti != data.temp_crnti, "RAR grant C-RNTI does not match the expected.\n");
CONDERROR(rnti != data.temp_crnti, "RAR grant C-RNTI does not match the expected.");
nof_rars++;
}
}
}
CONDERROR(nof_rars > 1, "There was more than one RAR for the same user\n");
CONDERROR(nof_rars > 1, "There was more than one RAR for the same user");
}
// TEST: Msg3 was allocated
if (ue.rar_tti_rx.is_valid() and not ue.msg3_tti_rx.is_valid()) {
// RAR scheduled, Msg3 not yet scheduled
srslte::tti_point expected_msg3_tti_rx = ue.rar_tti_rx + MSG3_DELAY_MS;
CONDERROR(expected_msg3_tti_rx < sf_out.tti_rx, "No UL msg3 alloc was made\n");
CONDERROR(expected_msg3_tti_rx < sf_out.tti_rx, "No UL msg3 alloc was made");
if (expected_msg3_tti_rx == sf_out.tti_rx) {
// Msg3 should exist
@ -271,13 +271,13 @@ int test_ra(const sim_enb_ctxt_t& enb_ctxt, const sf_output_res_t& sf_out)
for (uint32_t i = 0; i < ul_cc_res.nof_dci_elems; ++i) {
if (ul_cc_res.pusch[i].dci.rnti == rnti) {
msg3_count++;
CONDERROR(ul_cc_res.pusch[i].needs_pdcch, "Msg3 allocations do not require PDCCH\n");
CONDERROR(ul_cc_res.pusch[i].needs_pdcch, "Msg3 allocations do not require PDCCH");
CONDERROR(ue.msg3_riv != ul_cc_res.pusch[i].dci.type2_alloc.riv,
"The Msg3 was not allocated in the expected PRBs.\n");
"The Msg3 was not allocated in the expected PRBs.");
}
}
CONDERROR(msg3_count == 0, "Msg3 was not transmitted.\n");
CONDERROR(msg3_count > 1, "Only one Msg3 allower per user.\n");
CONDERROR(msg3_count == 0, "Msg3 was not transmitted.");
CONDERROR(msg3_count > 1, "Only one Msg3 allower per user.");
}
}
@ -288,33 +288,33 @@ int test_ra(const sim_enb_ctxt_t& enb_ctxt, const sf_output_res_t& sf_out)
for (uint32_t i = 0; i < dl_cc_res.nof_data_elems; ++i) {
if (dl_cc_res.data[i].dci.rnti == rnti) {
CONDERROR(to_tx_dl(sf_out.tti_rx) < to_tx_ul(ue.msg3_tti_rx),
"Msg4 cannot be scheduled without Msg3 being tx\n");
"Msg4 cannot be scheduled without Msg3 being tx");
for (uint32_t j = 0; j < dl_cc_res.data[i].nof_pdu_elems[0]; ++j) {
if (dl_cc_res.data[i].pdu[0][j].lcid == (uint32_t)srslte::dl_sch_lcid::CON_RES_ID) {
// ConRes found
CONDERROR(dl_cc_res.data[i].dci.format != SRSLTE_DCI_FORMAT1 and
dl_cc_res.data[i].dci.format != SRSLTE_DCI_FORMAT1A,
"ConRes must be format1/1a\n");
"ConRes must be format1/1a");
msg4_count++;
}
}
CONDERROR(msg4_count == 0, "No ConRes CE was scheduled in Msg4\n");
CONDERROR(msg4_count == 0, "No ConRes CE was scheduled in Msg4");
}
}
CONDERROR(msg4_count > 1, "Duplicate ConRes CE for the same rnti\n");
CONDERROR(msg4_count > 1, "Duplicate ConRes CE for the same rnti");
}
if (not ue.msg4_tti_rx.is_valid()) {
// TEST: No UL allocs except for Msg3 before Msg4
for (uint32_t i = 0; i < ul_cc_res.nof_dci_elems; ++i) {
if (ul_cc_res.pusch[i].dci.rnti == rnti) {
CONDERROR(not ue.rar_tti_rx.is_valid(), "No UL allocs before RAR allowed\n");
CONDERROR(not ue.rar_tti_rx.is_valid(), "No UL allocs before RAR allowed");
srslte::tti_point expected_msg3_tti = ue.rar_tti_rx + MSG3_DELAY_MS;
CONDERROR(expected_msg3_tti > sf_out.tti_rx, "No UL allocs before Msg3 is scheduled\n");
CONDERROR(expected_msg3_tti > sf_out.tti_rx, "No UL allocs before Msg3 is scheduled");
if (expected_msg3_tti < sf_out.tti_rx) {
bool msg3_retx =
((ue.msg3_tti_rx - expected_msg3_tti) % (FDD_HARQ_DELAY_UL_MS + FDD_HARQ_DELAY_DL_MS)) == 0;
CONDERROR(not msg3_retx, "No UL txs allowed except for Msg3 before user received Msg4\n");
CONDERROR(not msg3_retx, "No UL txs allowed except for Msg3 before user received Msg4");
}
}
}
@ -322,7 +322,7 @@ int test_ra(const sim_enb_ctxt_t& enb_ctxt, const sf_output_res_t& sf_out)
// TEST: No DL allocs before Msg3
if (not ue.msg3_tti_rx.is_valid()) {
for (uint32_t i = 0; i < dl_cc_res.nof_data_elems; ++i) {
CONDERROR(dl_cc_res.data[i].dci.rnti == rnti, "No DL data allocs allowed before Msg3 is scheduled\n");
CONDERROR(dl_cc_res.data[i].dci.rnti == rnti, "No DL data allocs allowed before Msg3 is scheduled");
}
}
}
@ -339,7 +339,7 @@ int test_ra(const sim_enb_ctxt_t& enb_ctxt, const sf_output_res_t& sf_out)
return ctxt.preamble_idx == preamble_idx and ((uint32_t)ctxt.prach_tti_rx.to_uint() == prach_tti);
});
CONDERROR(it == enb_ctxt.ue_db.end(), "There was a RAR allocation with no associated user");
CONDERROR(it->second->ue_cfg.supported_cc_list[0].enb_cc_idx != cc, "The allocated RAR is in the wrong cc\n");
CONDERROR(it->second->ue_cfg.supported_cc_list[0].enb_cc_idx != cc, "The allocated RAR is in the wrong cc");
}
}
}
@ -372,12 +372,12 @@ int test_meas_gaps(const sim_enb_ctxt_t& enb_ctxt, const sf_output_res_t& sf_out
if (is_in_measgap(tti_tx_ul, ue.ue_cfg.measgap_period, ue.ue_cfg.measgap_offset) or
is_in_measgap(tti_tx_phich, ue.ue_cfg.measgap_period, ue.ue_cfg.measgap_offset)) {
const pusch_t* pusch_ptr = find_pusch_grant(rnti, ul_cc_res);
CONDERROR(pusch_ptr != nullptr, "PUSCH grants and PHICH cannot fall in UE measGap\n");
CONDERROR(pusch_ptr != nullptr, "PUSCH grants and PHICH cannot fall in UE measGap");
}
if (is_in_measgap(tti_tx_dl, ue.ue_cfg.measgap_period, ue.ue_cfg.measgap_offset) or
is_in_measgap(tti_tx_dl_ack, ue.ue_cfg.measgap_period, ue.ue_cfg.measgap_offset)) {
const pdsch_t* pdsch_ptr = find_pdsch_grant(rnti, dl_cc_res);
CONDERROR(pdsch_ptr != nullptr, "PDSCH grants and respective ACKs cannot fall in UE measGap\n");
CONDERROR(pdsch_ptr != nullptr, "PDSCH grants and respective ACKs cannot fall in UE measGap");
}
}
}

@ -9,6 +9,7 @@
* the distribution.
*
*/
#include <boost/program_options.hpp>
#include <boost/program_options/options_description.hpp>
#include <boost/program_options/parsers.hpp>
@ -49,7 +50,7 @@ public:
expired = (cvar.wait_until(lock, expire_time) == std::cv_status::timeout); \
} \
if (expired) { \
log_h.warning("Expired " #NAME " waiting\n"); \
logger.warning("Expired " #NAME " waiting"); \
} \
return received_##NAME; \
} \
@ -62,7 +63,7 @@ private:
{ \
std::unique_lock<std::mutex> lock(mutex); \
cvar.notify_all(); \
log_h.debug(#NAME " received\n"); \
logger.debug(#NAME " received"); \
received_##NAME = true; \
}
@ -71,7 +72,7 @@ class dummy_radio final : public srslte::radio_interface_phy
private:
std::mutex mutex;
std::condition_variable cvar;
srslte::log_filter log_h;
srslog::basic_logger& logger;
std::vector<srslte_ringbuffer_t*> ringbuffers_tx;
std::vector<srslte_ringbuffer_t*> ringbuffers_rx;
srslte::rf_timestamp_t ts_rx = {};
@ -102,19 +103,20 @@ private:
CALLBACK(get_info);
public:
explicit dummy_radio(uint32_t nof_channels, uint32_t nof_prb, const std::string& log_level) : log_h("RADIO")
explicit dummy_radio(uint32_t nof_channels, uint32_t nof_prb, const std::string& log_level) :
logger(srslog::fetch_basic_logger("RADIO", false))
{
log_h.set_level(log_level);
logger.set_level(srslog::str_to_basic_level(log_level));
// Allocate receive ring buffer
for (uint32_t i = 0; i < nof_channels; i++) {
auto* rb = (srslte_ringbuffer_t*)srslte_vec_malloc(sizeof(srslte_ringbuffer_t));
if (not rb) {
ERROR("Allocating ring buffer\n");
ERROR("Allocating ring buffer");
}
if (srslte_ringbuffer_init(rb, SRSLTE_SF_LEN_PRB(nof_prb) * SRSLTE_NOF_SF_X_FRAME * (uint32_t)sizeof(cf_t))) {
ERROR("Initiating ring buffer\n");
ERROR("Initiating ring buffer");
}
ringbuffers_tx.push_back(rb);
@ -124,11 +126,11 @@ public:
for (uint32_t i = 0; i < nof_channels; i++) {
auto* rb = (srslte_ringbuffer_t*)srslte_vec_malloc(sizeof(srslte_ringbuffer_t));
if (not rb) {
ERROR("Allocating ring buffer\n");
ERROR("Allocating ring buffer");
}
if (srslte_ringbuffer_init(rb, SRSLTE_SF_LEN_PRB(nof_prb) * SRSLTE_NOF_SF_X_FRAME * (uint32_t)sizeof(cf_t))) {
ERROR("Initiating ring buffer\n");
ERROR("Initiating ring buffer");
}
ringbuffers_rx.push_back(rb);
@ -158,7 +160,7 @@ public:
int err = SRSLTE_SUCCESS;
uint32_t nbytes = static_cast<uint32_t>(sizeof(cf_t)) * nof_samples;
log_h.debug("read_tx %d\n", nof_samples);
logger.debug("read_tx %d", nof_samples);
for (uint32_t i = 0; i < ringbuffers_tx.size() and i < buffers.size(); i++) {
do {
@ -173,7 +175,7 @@ public:
{
uint32_t nbytes = static_cast<uint32_t>(sizeof(cf_t)) * nof_samples;
log_h.debug("write_rx %d\n", nof_samples);
logger.debug("write_rx %d", nof_samples);
for (uint32_t i = 0; i < ringbuffers_rx.size() and i < buffers.size(); i++) {
srslte_ringbuffer_write(ringbuffers_rx[i], buffers[i], nbytes);
@ -191,7 +193,7 @@ public:
// Get number of bytes to write
uint32_t nbytes = static_cast<uint32_t>(sizeof(cf_t)) * buffer.get_nof_samples();
log_h.debug("tx %d\n", buffer.get_nof_samples());
logger.debug("tx %d", buffer.get_nof_samples());
// Write ring buffer
for (uint32_t i = 0; i < ringbuffers_tx.size() and err >= SRSLTE_SUCCESS; i++) {
@ -216,7 +218,7 @@ public:
return true;
}
log_h.info("rx_now %d\n", buffer.get_nof_samples());
logger.info("rx_now %d", buffer.get_nof_samples());
// Get number of bytes to read
uint32_t nbytes = static_cast<uint32_t>(sizeof(cf_t)) * buffer.get_nof_samples();
@ -273,7 +275,7 @@ private:
srsenb::phy_interface_rrc_lte::phy_rrc_cfg_list_t phy_rrc;
std::mutex mutex;
std::condition_variable cvar;
srslte::log_filter log_h;
srslog::basic_logger& logger;
srslte_softbuffer_tx_t softbuffer_tx = {};
srslte_softbuffer_rx_t softbuffer_rx[SRSLTE_MAX_CARRIERS][SRSLTE_FDD_NOF_HARQ] = {};
uint8_t* data = nullptr;
@ -336,13 +338,13 @@ public:
const srsenb::phy_interface_rrc_lte::phy_rrc_cfg_list_t& phy_rrc_,
const std::string& log_level,
uint16_t rnti_) :
log_h("STACK"),
logger(srslog::fetch_basic_logger("STACK", false)),
ue_rnti(rnti_),
random_gen(srslte_random_init(rnti_)),
phy_cell_cfg(phy_cfg_.phy_cell_cfg),
phy_rrc(phy_rrc_)
{
log_h.set_level(log_level);
logger.set_level(srslog::str_to_basic_level(log_level));
srslte_softbuffer_tx_init(&softbuffer_tx, SRSLTE_MAX_PRB);
for (uint32_t i = 0; i < phy_rrc.size(); i++) {
for (auto& sb : softbuffer_rx[i]) {
@ -416,7 +418,7 @@ public:
notify_sr_detected();
log_h.info("Received SR tti=%d; rnti=0x%x\n", tti, rnti);
logger.info("Received SR tti=%d; rnti=0x%x", tti, rnti);
return SRSLTE_SUCCESS;
}
@ -428,7 +430,7 @@ public:
{
notify_ri_info();
log_h.info("Received RI tti=%d; rnti=0x%x; cc_idx=%d; ri=%d;\n", tti, rnti, cc_idx, ri_value);
logger.info("Received RI tti=%d; rnti=0x%x; cc_idx=%d; ri=%d;", tti, rnti, cc_idx, ri_value);
return 0;
}
@ -436,7 +438,7 @@ public:
{
notify_pmi_info();
log_h.info("Received PMI tti=%d; rnti=0x%x; cc_idx=%d; pmi=%d;\n", tti, rnti, cc_idx, pmi_value);
logger.info("Received PMI tti=%d; rnti=0x%x; cc_idx=%d; pmi=%d;", tti, rnti, cc_idx, pmi_value);
return 0;
}
@ -450,7 +452,7 @@ public:
notify_cqi_info();
log_h.info("Received CQI tti=%d; rnti=0x%x; cc_idx=%d; cqi=%d;\n", tti, rnti, cc_idx, cqi_value);
logger.info("Received CQI tti=%d; rnti=0x%x; cc_idx=%d; cqi=%d;", tti, rnti, cc_idx, cqi_value);
return SRSLTE_SUCCESS;
}
@ -461,7 +463,7 @@ public:
}
int ta_info(uint32_t tti, uint16_t rnti, float ta_us) override
{
log_h.info("Received TA INFO tti=%d; rnti=0x%x; ta=%.1f us\n", tti, rnti, ta_us);
logger.info("Received TA INFO tti=%d; rnti=0x%x; ta=%.1f us", tti, rnti, ta_us);
notify_ta_info();
return 0;
}
@ -475,7 +477,7 @@ public:
tti_dl_info.ack = ack;
tti_dl_info_ack_queue.push(tti_dl_info);
log_h.info("Received DL ACK tti=%d; rnti=0x%x; cc=%d; tb=%d; ack=%d;\n", tti, rnti, cc_idx, tb_idx, ack);
logger.info("Received DL ACK tti=%d; rnti=0x%x; cc=%d; tb=%d; ack=%d;", tti, rnti, cc_idx, tb_idx, ack);
notify_ack_info();
return 0;
}
@ -488,14 +490,14 @@ public:
tti_ul_info.crc = crc_res;
tti_ul_info_ack_queue.push(tti_ul_info);
log_h.info("Received UL ACK tti=%d; rnti=0x%x; cc=%d; ack=%d;\n", tti, rnti, cc_idx, crc_res);
logger.info("Received UL ACK tti=%d; rnti=0x%x; cc=%d; ack=%d;", tti, rnti, cc_idx, crc_res);
notify_crc_info();
return 0;
}
int push_pdu(uint32_t tti, uint16_t rnti, uint32_t cc_idx, uint32_t nof_bytes, bool crc_res) override
{
log_h.info("Received push_pdu tti=%d; rnti=0x%x; ack=%d;\n", tti, rnti, crc_res);
logger.info("Received push_pdu tti=%d; rnti=0x%x; ack=%d;", tti, rnti, crc_res);
notify_push_pdu();
return 0;
@ -577,7 +579,7 @@ public:
uint32_t cw_count = 0;
for (uint32_t tb = 0; tb < SRSLTE_MAX_TB; tb++) {
if (sched_tb[tb]) {
log_h.debug("Transmitted DL grant tti=%d; rnti=0x%x; cc=%d; tb=%d;\n", tti, ue_rnti, cc_idx, tb);
logger.debug("Transmitted DL grant tti=%d; rnti=0x%x; cc=%d; tb=%d;", tti, ue_rnti, cc_idx, tb);
// Create Grant with maximum safe MCS
dl_sched.pdsch[0].dci.tb[tb].cw_idx = cw_count++;
@ -742,7 +744,7 @@ public:
uint32_t elapsed_tti = TTI_SUB(tti_sr_info2.tti, tti_sr_info1.tti);
// Log SR info
log_h.info("SR: tti1=%d; tti2=%d; elapsed %d;\n", tti_sr_info1.tti, tti_sr_info2.tti, elapsed_tti);
logger.info("SR: tti1=%d; tti2=%d; elapsed %d;", tti_sr_info1.tti, tti_sr_info2.tti, elapsed_tti);
// Check first TTI
TESTASSERT(tti_sr_info1.tti % 20 == 0);
@ -773,27 +775,26 @@ private:
srslte_softbuffer_tx_t softbuffer_tx = {};
uint8_t* tx_data = nullptr;
srsenb::phy_interface_rrc_lte::phy_rrc_cfg_list_t phy_rrc_cfg = {};
srslte::log_filter log_h;
srslog::basic_logger& logger;
std::map<uint32_t, uint32_t> last_ri = {};
public:
dummy_ue(dummy_radio* _radio, const srsenb::phy_cell_cfg_list_t& cell_list, std::string log_level, uint16_t rnti_) :
radio(_radio),
log_h("UPHY", nullptr, true)
radio(_radio), logger(srslog::fetch_basic_logger("UPHY"))
{
// Calculate subframe length
nof_ports = cell_list[0].cell.nof_ports;
sf_len = static_cast<uint32_t>(SRSLTE_SF_LEN_PRB(cell_list[0].cell.nof_prb));
rnti = rnti_;
log_h.set_level(std::move(log_level));
logger.set_level(srslog::str_to_basic_level(log_level));
// Initialise one buffer per eNb
for (uint32_t i = 0; i < cell_list.size() * nof_ports; i++) {
// Allocate buffers
cf_t* buffer = srslte_vec_cf_malloc(sf_len);
if (not buffer) {
ERROR("Allocating UE DL buffer\n");
ERROR("Allocating UE DL buffer");
}
buffers.push_back(buffer);
@ -808,18 +809,18 @@ public:
// Allocate UE DL
auto* ue_dl = (srslte_ue_dl_t*)srslte_vec_malloc(sizeof(srslte_ue_dl_t));
if (not ue_dl) {
ERROR("Allocatin UE DL\n");
ERROR("Allocatin UE DL");
}
ue_dl_v.push_back(ue_dl);
// Initialise UE DL
if (srslte_ue_dl_init(ue_dl, &buffers[cc_idx * nof_ports], cell.nof_prb, cell.nof_ports)) {
ERROR("Initiating UE DL\n");
ERROR("Initiating UE DL");
}
// Set Cell
if (srslte_ue_dl_set_cell(ue_dl, cell)) {
ERROR("Setting UE DL cell\n");
ERROR("Setting UE DL cell");
}
// Set RNTI
@ -828,18 +829,18 @@ public:
// Allocate UE UL
auto* ue_ul = (srslte_ue_ul_t*)srslte_vec_malloc(sizeof(srslte_ue_ul_t));
if (not ue_ul) {
ERROR("Allocatin UE UL\n");
ERROR("Allocatin UE UL");
}
ue_ul_v.push_back(ue_ul);
// Initialise UE UL
if (srslte_ue_ul_init(ue_ul, buffers[cc_idx * nof_ports], cell.nof_prb)) {
ERROR("Setting UE UL cell\n");
ERROR("Setting UE UL cell");
}
// Set cell
if (srslte_ue_ul_set_cell(ue_ul, cell)) {
ERROR("Setting UE DL cell\n");
ERROR("Setting UE DL cell");
}
// Set RNTI
@ -848,13 +849,13 @@ public:
// Initialise softbuffer
if (srslte_softbuffer_tx_init(&softbuffer_tx, cell_list[0].cell.nof_prb)) {
ERROR("Initialising Tx softbuffer\n");
ERROR("Initialising Tx softbuffer");
}
// Initialise dummy tx data
tx_data = srslte_vec_u8_malloc(SRSENB_MAX_BUFFER_SIZE_BYTES);
if (not tx_data) {
ERROR("Allocating Tx data\n");
ERROR("Allocating Tx data");
}
for (uint32_t i = 0; i < SRSENB_MAX_BUFFER_SIZE_BYTES; i++) {
@ -948,17 +949,17 @@ public:
if (nof_dl_grants) {
char str[256] = {};
srslte_dci_dl_info(dci_dl, str, sizeof(str));
log_h.info("[DL DCI] %s\n", str);
logger.info("[DL DCI] %s", str);
if (srslte_ue_dl_dci_to_pdsch_grant(
ue_dl_v[cc_idx], &sf_dl_cfg, &ue_dl_cfg, dci_dl, &ue_dl_cfg.cfg.pdsch.grant)) {
log_h.error("Converting DCI message to DL dci\n");
logger.error("Converting DCI message to DL dci");
return SRSLTE_ERROR;
}
srslte_pdsch_tx_info(&ue_dl_cfg.cfg.pdsch, str, 512);
log_h.info("[DL PDSCH %d] cc=%d, %s\n", sf_dl_cfg.tti, cc_idx, str);
logger.info("[DL PDSCH %d] cc=%d, %s", sf_dl_cfg.tti, cc_idx, str);
pdsch_ack.cc[ue_cc_idx].M = 1;
pdsch_ack.cc[ue_cc_idx].m[0].present = true;
@ -1071,7 +1072,7 @@ public:
char str[256] = {};
srslte_ue_ul_info(&ue_ul_cfg, &sf_ul_cfg, &pusch_data.uci, str, sizeof(str));
if (str[0]) {
log_h.info("[UL INFO %d] %s\n", i, str);
logger.info("[UL INFO %d] %s", i, str);
}
}
@ -1096,7 +1097,7 @@ public:
char str[256] = {};
srslte_ue_ul_info(&ue_ul_cfg, &sf_ul_cfg, &pusch_data.uci, str, sizeof(str));
if (str[0]) {
log_h.info("[UL INFO %d] %s\n", 0, str);
logger.info("[UL INFO %d] %s", 0, str);
}
}
@ -1112,7 +1113,7 @@ public:
srslte_pdsch_ack_t pdsch_ack = {};
// Set logging TTI
log_h.step(sf_dl_cfg.tti);
logger.set_context(sf_dl_cfg.tti);
// Work DL
TESTASSERT(work_dl(pdsch_ack, uci_data) == SRSLTE_SUCCESS);
@ -1187,7 +1188,7 @@ private:
unique_dummy_stack_t stack;
unique_srsenb_phy_t enb_phy;
unique_dummy_ue_phy_t ue_phy;
srslte::log_filter log_h;
srslog::basic_logger& logger;
args_t args = {}; ///< Test arguments
srsenb::phy_args_t phy_args; ///< PHY arguments
@ -1203,13 +1204,14 @@ private:
change_state_t change_state = change_state_assert;
public:
phy_test_bench(args_t& args_, srslte::logger& logger_) : log_h("TEST BENCH")
phy_test_bench(args_t& args_, srslog::sink& log_sink) :
logger(srslog::fetch_basic_logger("TEST BENCH", log_sink, false))
{
// Copy test arguments
args = args_;
// Configure logger
log_h.set_level(args.log_level);
logger.set_level(srslog::str_to_basic_level(args.log_level));
// PHY arguments
phy_args.log.phy_level = args.log_level;
@ -1301,7 +1303,7 @@ public:
stack->set_active_cell_list(args.ue_cell_list);
/// eNb PHY initialisation instance
enb_phy = unique_srsenb_phy_t(new srsenb::phy(&logger_));
enb_phy = unique_srsenb_phy_t(new srsenb::phy(log_sink));
/// Initiate eNb PHY with the given RNTI
enb_phy->init(phy_args, phy_cfg, radio.get(), stack.get());
@ -1335,7 +1337,7 @@ public:
switch (change_state) {
case change_state_assert:
if (args.period_pcell_rotate > 0 and tti_counter >= args.period_pcell_rotate) {
log_h.warning("******* Cell rotation: Disable scheduling *******\n");
logger.warning("******* Cell rotation: Disable scheduling *******");
// Disable all cells
std::vector<uint32_t> active_cells;
stack->set_active_cell_list(active_cells);
@ -1346,7 +1348,7 @@ public:
break;
case change_state_flush:
if (tti_counter >= 2 * FDD_HARQ_DELAY_DL_MS + FDD_HARQ_DELAY_UL_MS) {
log_h.warning("******* Cell rotation: Reconfigure *******\n");
logger.warning("******* Cell rotation: Reconfigure *******");
std::array<bool, SRSLTE_MAX_CARRIERS> activation = {}; ///< Activation/Deactivation vector
@ -1373,7 +1375,7 @@ public:
break;
case change_state_wait_steady:
if (tti_counter >= FDD_HARQ_DELAY_DL_MS + FDD_HARQ_DELAY_UL_MS) {
log_h.warning("******* Cell rotation: Enable scheduling *******\n");
logger.warning("******* Cell rotation: Enable scheduling *******");
std::vector<uint32_t> active_cell_list;
@ -1460,21 +1462,10 @@ int main(int argc, char** argv)
test_args.init();
// Setup logging.
srslog::sink* log_sink = srslog::create_stdout_sink();
if (!log_sink) {
return SRSLTE_ERROR;
}
srslog::log_channel* chan = srslog::create_log_channel("main_channel", *log_sink);
if (!chan) {
return SRSLTE_ERROR;
}
srslte::srslog_wrapper log_wrapper(*chan);
srslog::init();
// Create Test Bench
unique_phy_test_bench test_bench = unique_phy_test_bench(new phy_test_bench(test_args, log_wrapper));
unique_phy_test_bench test_bench = unique_phy_test_bench(new phy_test_bench(test_args, srslog::get_default_sink()));
// Run Simulation
for (uint32_t i = 0; i < test_args.duration; i++) {
@ -1483,6 +1474,8 @@ int main(int argc, char** argv)
test_bench->stop();
srslog::flush();
std::cout << "Passed" << std::endl;
return SRSLTE_SUCCESS;

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save