Upgrade loggers in srsue (#2163)

* Replaced UE logger in the ue class.

* Replaced loggers in the main phy class and prach.

* Replaced loggers in phy common and ta_control.

* Replace loggers in cc and sf workers.

* Replaced loggers in intra_measure, scell_recv, search, sfn_sync, sync.

* Remove last uses of the old loggers in the main phy class.

* Remove stray newline in logs.

* Replaced loggers in ue gw.

* - Started to replace loggers in the ue stack.
- Replaced loggers in usim and pcsc.
- Adapted nas and usim tests.

* Replace loggers in nas.

* Added missing log init calls in two previously modified tests.

* Replaced logger in nas idle procs.

* Replaced loggers in nas emm state.

* Replaced loggers in tft packet filter and adapted tft test.

* Replaced loggers in main RRC class.

* Replaced loggers in RRC cell.

* Replaced loggers in RRC meas.

* Replaced loggers in rrc procedures.

* Started logger replacement in MAC layer, more precisely in demux and dl_harq classes.
Been unable to inject loggers in construction for dl_tb_process due to very weird static assertions in the std::vector code being the type not constructible which is not true, so instead use the main MAC logger directly.

* Replaced loggers in mac mux class.

* Replaced loggers in mac pro_bsr.

* Replaced loggers in mac proc phr.

* Replaced loggers in mac proc SR and RA.

* Replace loggers in mac UL HARQ.

* Replaced loggers in main ue stack class.

* Fixed nas test crashing due to a null string.

* Ported mac_test to use the new loggers.

* Removed TTI reporting for the PHY log as the old logger did.

* Replaced loggers in UE phy tests.

* Configure loggers in nas_test.

* Replaced loggers in rrc_meas_test.

* Replaced loggers in rrc_reconfig_test.

* Added missing newline in tft_test.

* Fix compilation errors in TTCN3 tests.

* Fix linker error detected in CI and warning.

* Replaced loggers in TTCN3 tests.

* Fix a text replace error in some log messages.

* Remove trailing newlines from log entries.

* Remove old logger from rrc.

* Flush backend before printing the test status.

* - Fix compilation error from previous rebase.
- Remove trailing newlines from some missing log entries.
master
faluco 4 years ago committed by GitHub
parent 42aa5c4499
commit 5981469f9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -23,7 +23,7 @@ namespace lte {
class cc_worker
{
public:
cc_worker(uint32_t cc_idx, uint32_t max_prb, phy_common* phy, srslte::log* log);
cc_worker(uint32_t cc_idx, uint32_t max_prb, phy_common* phy, srslog::basic_logger& logger);
~cc_worker();
/* Functions used by main PHY thread */
@ -86,8 +86,8 @@ private:
uint32_t get_wideband_cqi();
/* Common objects */
phy_common* phy = nullptr;
srslte::log* log_h = nullptr;
phy_common* phy = nullptr;
srslog::basic_logger& logger;
srslte_cell_t cell = {};
srslte_dl_sf_cfg_t sf_cfg_dl = {};

@ -33,7 +33,7 @@ namespace lte {
class sf_worker : public srslte::thread_pool::worker
{
public:
sf_worker(uint32_t max_prb, phy_common* phy, srslte::log* log);
sf_worker(uint32_t max_prb, phy_common* phy_, srslog::basic_logger& logger);
virtual ~sf_worker();
void reset_cell_unlocked(uint32_t cc_idx);
@ -79,7 +79,7 @@ private:
phy_common* phy = nullptr;
srslte::log* log_h = nullptr;
srslog::basic_logger& logger;
srslte_cell_t cell = {};
std::mutex cell_mutex;

@ -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;
@ -41,7 +37,7 @@ public:
sf_worker* operator[](std::size_t pos) { return workers.at(pos).get(); }
worker_pool(uint32_t max_workers);
bool init(phy_common* common, srslte::logger* logger, int prio);
bool init(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);

@ -23,6 +23,7 @@
#include "srslte/interfaces/radio_interfaces.h"
#include "srslte/interfaces/ue_interfaces.h"
#include "srslte/radio/radio.h"
#include "srslte/srslog/srslog.h"
#include "srslte/srslte.h"
#include "srsue/hdr/phy/lte/worker_pool.h"
#include "srsue/hdr/phy/nr/worker_pool.h"
@ -67,8 +68,17 @@ private:
class phy final : public ue_lte_phy_base, public srslte::thread
{
public:
explicit phy(srslte::logger* logger_) :
logger(logger_), lte_workers(MAX_WORKERS), nr_workers(MAX_WORKERS), common(), thread("PHY"){};
explicit phy(srslte::logger* logger_, srslog::sink& log_sink) :
logger(logger_),
log_sink(log_sink),
logger_phy(srslog::fetch_basic_logger("PHY", log_sink)),
logger_phy_lib(srslog::fetch_basic_logger("PHY_LIB", log_sink)),
lte_workers(MAX_WORKERS),
nr_workers(MAX_WORKERS),
common(logger_phy),
sfsync(logger_phy, logger_phy_lib),
prach_buffer(logger_phy),
thread("PHY"){};
~phy() final { stop(); }
// Init defined in base class
@ -173,10 +183,11 @@ private:
srslte::radio_interface_phy* radio = nullptr;
srslte::logger* logger = nullptr;
srslog::sink& log_sink;
std::unique_ptr<srslte::log_filter> log_h = nullptr;
std::unique_ptr<srslte::log_filter> log_phy_lib_h = nullptr;
srsue::stack_interface_phy_lte* stack = nullptr;
srslog::basic_logger& logger_phy;
srslog::basic_logger& logger_phy_lib;
srsue::stack_interface_phy_lte* stack = nullptr;
lte::worker_pool lte_workers;
nr::worker_pool nr_workers;

@ -21,6 +21,7 @@
#include "srslte/interfaces/radio_interfaces.h"
#include "srslte/interfaces/ue_interfaces.h"
#include "srslte/radio/radio.h"
#include "srslte/srslog/srslog.h"
#include "srslte/srslte.h"
#include "srsue/hdr/phy/scell/scell_state.h"
#include "ta_control.h"
@ -65,12 +66,11 @@ public:
// Time Aligment Controller, internal thread safe
ta_control ta;
phy_common();
phy_common(srslog::basic_logger& logger);
~phy_common();
void init(phy_args_t* args,
srslte::log* _log,
srslte::radio_interface_phy* _radio,
stack_interface_phy_lte* _stack,
rsrp_insync_itf* rsrp_insync);
@ -247,8 +247,8 @@ private:
bool is_pending_tx_end = false;
srslte::radio_interface_phy* radio_h = nullptr;
srslte::log* log_h = nullptr;
srslte::radio_interface_phy* radio_h = nullptr;
srslog::basic_logger& logger;
srslte::channel_ptr ul_channel = nullptr;
int rar_grant_tti = -1;

@ -16,6 +16,7 @@
#include "srslte/common/log.h"
#include "srslte/interfaces/ue_interfaces.h"
#include "srslte/radio/radio.h"
#include "srslte/srslog/srslog.h"
#include "srslte/srslte.h"
#include <bitset>
@ -24,10 +25,10 @@ namespace srsue {
class prach
{
public:
prach() = default;
prach(srslog::basic_logger& logger) : logger(logger) {}
~prach() { stop(); }
void init(uint32_t max_prb, srslte::log* log_h);
void init(uint32_t max_prb);
void stop();
bool set_cell(srslte_cell_t cell, srslte_prach_cfg_t prach_cfg);
bool prepare_to_send(uint32_t preamble_idx, int allowed_subframe = -1, float target_power_dbm = -1);
@ -55,7 +56,7 @@ private:
static constexpr unsigned max_fs = 12;
static constexpr unsigned max_preambles = 64;
srslte::log* log_h = nullptr;
srslog::basic_logger& logger;
srslte_prach_t prach_obj = {};
srslte_cell_t cell = {};
srslte_cfo_t cfo_h = {};

@ -58,7 +58,7 @@ public:
/**
* Constructor
*/
intra_measure();
intra_measure(srslog::basic_logger& logger);
/**
* Destructor
@ -69,9 +69,8 @@ public:
* Initiation function, necessary to configure main parameters
* @param common SRSUE phy_common instance pointer for providing intra_freq_meas_len_ms and intra_freq_meas_period_ms
* @param rrc SRSUE PHY->RRC interface for supplying the RRC with the measurements
* @param log_h Physical layer Logging filter pointer
*/
void init(uint32_t cc_idx, phy_common* common, meas_itf* new_cell_itf, srslte::log* log_h);
void init(uint32_t cc_idx, phy_common* common, meas_itf* new_cell_itf);
/**
* Stops the operation of this component
@ -193,19 +192,19 @@ private:
///< Internal Thread priority, low by default
const static int INTRA_FREQ_MEAS_PRIO = DEFAULT_PRIORITY + 5;
scell_recv scell = {};
meas_itf* new_cell_itf = nullptr;
srslte::log* log_h = nullptr;
uint32_t cc_idx = 0;
uint32_t current_earfcn = 0;
uint32_t current_sflen = 0;
srslte_cell_t serving_cell = {};
std::set<uint32_t> active_pci = {};
std::mutex active_pci_mutex = {};
uint32_t last_measure_tti = 0;
uint32_t intra_freq_meas_len_ms = 20;
uint32_t intra_freq_meas_period_ms = 200;
uint32_t rx_gain_offset_db = 0;
scell_recv scell;
meas_itf* new_cell_itf = nullptr;
srslog::basic_logger& logger;
uint32_t cc_idx = 0;
uint32_t current_earfcn = 0;
uint32_t current_sflen = 0;
srslte_cell_t serving_cell = {};
std::set<uint32_t> active_pci = {};
std::mutex active_pci_mutex = {};
uint32_t last_measure_tti = 0;
uint32_t intra_freq_meas_len_ms = 20;
uint32_t intra_freq_meas_period_ms = 200;
uint32_t rx_gain_offset_db = 0;
cf_t* search_buffer = nullptr;

@ -24,18 +24,20 @@ namespace scell {
class scell_recv
{
public:
void init(srslte::log* log_h, uint32_t max_sf_window);
void deinit();
void reset();
explicit scell_recv(srslog::basic_logger& logger) : logger(logger) {}
void init(uint32_t max_sf_window);
void deinit();
void reset();
std::set<uint32_t> find_cells(const cf_t* input_buffer, const srslte_cell_t serving_cell, const uint32_t nof_sf);
private:
// 36.133 9.1.2.1 for band 7
constexpr static float ABSOLUTE_RSRP_THRESHOLD_DBM = -125;
cf_t* sf_buffer[SRSLTE_MAX_PORTS];
srslte::log* log_h;
srslte_sync_t sync_find;
cf_t* sf_buffer[SRSLTE_MAX_PORTS];
srslog::basic_logger& logger;
srslte_sync_t sync_find;
uint32_t current_fft_sz;
};

@ -138,7 +138,7 @@ public:
std::unique_lock<std::mutex> lock(mutex);
if (cc_idx == 0 or cc_idx >= SRSLTE_MAX_CARRIERS) {
ERROR("CC IDX %d out-of-range\n", cc_idx);
ERROR("CC IDX %d out-of-range", cc_idx);
return;
}
@ -203,7 +203,7 @@ public:
std::unique_lock<std::mutex> lock(mutex);
if (cc_idx == 0 or cc_idx >= SRSLTE_MAX_CARRIERS) {
ERROR("CC IDX %d out-of-range\n", cc_idx);
ERROR("CC IDX %d out-of-range", cc_idx);
return 0;
}
@ -215,7 +215,7 @@ public:
std::unique_lock<std::mutex> lock(mutex);
if (cc_idx == 0 or cc_idx >= SRSLTE_MAX_CARRIERS) {
ERROR("CC IDX %d out-of-range\n", cc_idx);
ERROR("CC IDX %d out-of-range", cc_idx);
return 0;
}

@ -87,13 +87,13 @@ private:
state = STATE_IN_SYNCH;
break;
case SRSLTE_SYNC_FOUND_NOSPACE:
ERROR("No space error\n");
ERROR("No space error");
break;
case SRSLTE_SYNC_NOFOUND:
// Ignore
break;
case SRSLTE_SYNC_ERROR:
ERROR("Error finding PSS\n");
ERROR("Error finding PSS");
break;
}
@ -117,7 +117,7 @@ public:
// Initialise Find PSS object
if (srslte_sync_init(&find_pss, 2 * SRSLTE_SF_LEN_MAX, 2 * SRSLTE_SF_LEN_MAX, SRSLTE_SYMBOL_SZ_MAX) !=
SRSLTE_SUCCESS) {
ERROR("Initiating Synchronizer\n");
ERROR("Initiating Synchronizer");
}
}
@ -136,7 +136,7 @@ public:
// Resize Sync object
if (srslte_sync_resize(&find_pss, 2 * sf_len, 2 * sf_len, symbol_sz) != SRSLTE_SUCCESS) {
ERROR("Error setting cell sync find\n");
ERROR("Error setting cell sync find");
}
// Configure

@ -15,6 +15,7 @@
#include "srslte/interfaces/ue_interfaces.h"
#include "srslte/radio/radio.h"
#include "srslte/srslog/srslog.h"
#include "srslte/srslte.h"
namespace srsue {
@ -23,9 +24,9 @@ class search_callback
{
public:
virtual int radio_recv_fnc(srslte::rf_buffer_t&, srslte_timestamp_t* rx_time) = 0;
virtual void set_ue_sync_opts(srslte_ue_sync_t* q, float cfo) = 0;
virtual srslte::radio_interface_phy* get_radio() = 0;
virtual void set_rx_gain(float gain) = 0;
virtual void set_ue_sync_opts(srslte_ue_sync_t* q, float cfo) = 0;
virtual srslte::radio_interface_phy* get_radio() = 0;
virtual void set_rx_gain(float gain) = 0;
};
// Class to run cell search
@ -34,16 +35,17 @@ class search
public:
typedef enum { CELL_NOT_FOUND, CELL_FOUND, ERROR, TIMEOUT } ret_code;
explicit search(srslog::basic_logger& logger) : logger(logger) {}
~search();
void init(srslte::rf_buffer_t& buffer_, srslte::log* log_h, uint32_t nof_rx_channels, search_callback* parent);
void init(srslte::rf_buffer_t& buffer_, uint32_t nof_rx_channels, search_callback* parent);
void reset();
float get_last_cfo();
void set_agc_enable(bool enable);
ret_code run(srslte_cell_t* cell, std::array<uint8_t, SRSLTE_BCH_PAYLOAD_LEN>& bch_payload);
private:
search_callback* p = nullptr;
srslte::log* log_h = nullptr;
search_callback* p = nullptr;
srslog::basic_logger& logger;
srslte::rf_buffer_t buffer = {};
srslte_ue_cellsearch_t cs = {};
srslte_ue_mib_sync_t ue_mib_sync = {};

@ -15,6 +15,7 @@
#include "srslte/interfaces/ue_interfaces.h"
#include "srslte/radio/radio.h"
#include "srslte/srslog/srslog.h"
#include "srslte/srslte.h"
namespace srsue {
@ -24,13 +25,12 @@ class sfn_sync
{
public:
typedef enum { IDLE, SFN_FOUND, SFX0_FOUND, SFN_NOFOUND, ERROR } ret_code;
sfn_sync() = default;
explicit sfn_sync(srslog::basic_logger& logger) : logger(logger) {}
~sfn_sync();
void init(srslte_ue_sync_t* ue_sync,
const phy_args_t* phy_args_,
srslte::rf_buffer_t& buffer,
uint32_t buffer_max_samples_,
srslte::log* log_h,
uint32_t nof_subframes = SFN_SYNC_NOF_SUBFRAMES);
void reset();
bool set_cell(srslte_cell_t cell);
@ -47,14 +47,14 @@ public:
private:
const static int SFN_SYNC_NOF_SUBFRAMES = 100;
const phy_args_t* phy_args = nullptr;
uint32_t cnt = 0;
uint32_t timeout = 0;
srslte::log* log_h = nullptr;
srslte_ue_sync_t* ue_sync = nullptr;
srslte::rf_buffer_t mib_buffer = {};
uint32_t buffer_max_samples = 0;
srslte_ue_mib_t ue_mib = {};
const phy_args_t* phy_args = nullptr;
uint32_t cnt = 0;
uint32_t timeout = 0;
srslog::basic_logger& logger;
srslte_ue_sync_t* ue_sync = nullptr;
srslte::rf_buffer_t mib_buffer = {};
uint32_t buffer_max_samples = 0;
srslte_ue_mib_t ue_mib = {};
};
}; // namespace srsue

@ -47,7 +47,14 @@ class sync : public srslte::thread,
public scell::intra_measure::meas_itf
{
public:
sync() : thread("SYNC"), sf_buffer(sync_nof_rx_subframes), dummy_buffer(sync_nof_rx_subframes){};
sync(srslog::basic_logger& phy_logger, srslog::basic_logger& phy_lib_logger) :
thread("SYNC"),
search_p(phy_logger),
sfn_p(phy_logger),
phy_logger(phy_logger),
phy_lib_logger(phy_lib_logger),
sf_buffer(sync_nof_rx_subframes),
dummy_buffer(sync_nof_rx_subframes){};
~sync();
void init(srslte::radio_interface_phy* radio_,
@ -56,8 +63,6 @@ public:
lte::worker_pool* _lte_workers_pool,
nr::worker_pool* _nr_workers_pool,
phy_common* _worker_com,
srslte::log* _log_h,
srslte::log* _log_phy_lib_h,
uint32_t prio,
int sync_cpu_affinity = -1);
void stop();
@ -198,9 +203,9 @@ private:
std::vector<std::unique_ptr<scell::intra_measure> > intra_freq_meas;
// Pointers to other classes
stack_interface_phy_lte* stack = nullptr;
srslte::log* log_h = nullptr;
srslte::log* log_phy_lib_h = nullptr;
stack_interface_phy_lte* stack = nullptr;
srslog::basic_logger& phy_logger;
srslog::basic_logger& phy_lib_logger;
lte::worker_pool* lte_worker_pool = nullptr;
nr::worker_pool* nr_worker_pool = nullptr;
srslte::radio_interface_phy* radio_h = nullptr;

@ -22,18 +22,13 @@ namespace srsue {
class ta_control
{
private:
srslte::log* log_h = nullptr;
mutable std::mutex mutex;
uint32_t next_base_nta = 0;
float next_base_sec = 0.0f;
srslog::basic_logger& logger;
mutable std::mutex mutex;
uint32_t next_base_nta = 0;
float next_base_sec = 0.0f;
public:
/**
* Sets the logging instance
*
* @param loh_h_ logging instance pointer
*/
void set_logger(srslte::log* log_h_) { log_h = log_h_; }
ta_control(srslog::basic_logger& logger) : logger(logger) {}
/**
* Sets the next base time in seconds, discarding previous changes.
@ -50,10 +45,7 @@ public:
// Update base in nta
next_base_nta = static_cast<uint32_t>(roundf(next_base_sec / SRSLTE_LTE_TS));
// Log information information if available
if (log_h) {
log_h->info("PHY: Set TA base: n_ta: %d, ta_usec: %.1f\n", next_base_nta, next_base_sec * 1e6f);
}
logger.info("PHY: Set TA base: n_ta: %d, ta_usec: %.1f", next_base_nta, next_base_sec * 1e6f);
}
/**
@ -71,13 +63,10 @@ public:
// Update base in nta
next_base_nta = static_cast<uint32_t>(roundf(next_base_sec / SRSLTE_LTE_TS));
// Log information information if available
if (log_h) {
log_h->info("PHY: Set TA: ta_delta_usec: %.1f, n_ta: %d, ta_usec: %.1f\n",
ta_delta_sec * 1e6f,
next_base_nta,
next_base_sec * 1e6f);
}
logger.info("PHY: Set TA: ta_delta_usec: %.1f, n_ta: %d, ta_usec: %.1f",
ta_delta_sec * 1e6f,
next_base_nta,
next_base_sec * 1e6f);
}
/**
@ -95,11 +84,7 @@ public:
// Update base in seconds
next_base_sec = static_cast<float>(next_base_nta) * SRSLTE_LTE_TS;
// Log information information if available
if (log_h) {
log_h->info(
"PHY: Set TA RAR: ta_cmd: %d, n_ta: %d, ta_usec: %.1f\n", ta_cmd, next_base_nta, next_base_sec * 1e6f);
}
logger.info("PHY: Set TA RAR: ta_cmd: %d, n_ta: %d, ta_usec: %.1f", ta_cmd, next_base_nta, next_base_sec * 1e6f);
}
/**
@ -117,10 +102,7 @@ public:
// Update base in seconds
next_base_sec = static_cast<float>(next_base_nta) * SRSLTE_LTE_TS;
// Log information information if available
if (log_h) {
log_h->info("PHY: Set TA: ta_cmd: %d, n_ta: %d, ta_usec: %.1f\n", ta_cmd, next_base_nta, next_base_sec * 1e6f);
}
logger.info("PHY: Set TA: ta_cmd: %d, n_ta: %d, ta_usec: %.1f", ta_cmd, next_base_nta, next_base_sec * 1e6f);
}
/**

@ -18,6 +18,7 @@
#include "srslte/interfaces/ue_interfaces.h"
#include "srslte/mac/pdu.h"
#include "srslte/mac/pdu_queue.h"
#include "srslte/srslog/srslog.h"
/* Logical Channel Demultiplexing and MAC CE dissassemble */
@ -33,7 +34,7 @@ public:
class demux : public srslte::pdu_queue::process_callback
{
public:
demux(srslte::log_ref log_h_);
demux(srslte::log_ref log_h_, srslog::basic_logger& logger);
void init(phy_interface_mac_common* phy_h_,
rlc_interface_mac* rlc,
mac_interface_demux* mac,
@ -62,6 +63,7 @@ private:
// args
srslte::log_ref log_h;
srslog::basic_logger& logger;
phy_interface_mac_common* phy_h = nullptr;
rlc_interface_mac* rlc = nullptr;
mac_interface_demux* mac = nullptr;

@ -30,7 +30,7 @@ class dl_harq_entity
public:
dl_harq_entity(uint8_t cc_idx_);
bool init(srslte::log_ref log_h, mac_interface_rrc::ue_rnti_t* rntis, demux* demux_unit);
bool init(mac_interface_rrc::ue_rnti_t* rntis, demux* demux_unit);
void reset();
void start_pcap(srslte::mac_pcap* pcap_);
@ -78,9 +78,9 @@ private:
std::mutex mutex;
bool is_initiated;
dl_harq_entity* harq_entity;
srslte::log_ref log_h;
bool is_initiated;
dl_harq_entity* harq_entity;
srslog::basic_logger& logger;
bool is_first_tb;
bool is_new_transmission;
@ -110,7 +110,7 @@ private:
std::vector<dl_harq_process> proc;
dl_harq_process bcch_proc;
demux* demux_unit = nullptr;
srslte::log_ref log_h;
srslog::basic_logger& logger;
srslte::mac_pcap* pcap = nullptr;
mac_interface_rrc::ue_rnti_t* rntis = nullptr;
uint16_t last_temporal_crnti = 0;
@ -121,7 +121,7 @@ private:
uint8_t cc_idx = 0;
};
typedef std::unique_ptr<dl_harq_entity> dl_harq_entity_ptr;
typedef std::unique_ptr<dl_harq_entity> dl_harq_entity_ptr;
typedef std::array<dl_harq_entity_ptr, SRSLTE_MAX_CARRIERS> dl_harq_entity_vector;
} // namespace srsue

@ -27,6 +27,7 @@
#include "srslte/common/timers.h"
#include "srslte/common/tti_sync_cv.h"
#include "srslte/interfaces/ue_interfaces.h"
#include "srslte/srslog/srslog.h"
#include "ul_harq.h"
#include <condition_variable>
#include <mutex>
@ -108,6 +109,7 @@ private:
rrc_interface_mac* rrc_h = nullptr;
srslte::ext_task_sched_handle task_sched;
srslte::log_ref log_h;
srslog::basic_logger& logger;
mac_interface_phy_lte::mac_phy_cfg_mbsfn_t phy_mbsfn_cfg = {};
// RNTI search window scheduling

@ -24,6 +24,7 @@
#include "srslte/interfaces/mac_interface_types.h"
#include "srslte/interfaces/ue_interfaces.h"
#include "srslte/mac/pdu.h"
#include "srslte/srslog/srslog.h"
#include <mutex>
namespace srsue {
@ -31,7 +32,7 @@ namespace srsue {
class mux
{
public:
mux(srslte::log_ref log_);
mux(srslte::log_ref log_, srslog::basic_logger& logger);
~mux(){};
void reset();
void init(rlc_interface_mac* rlc, bsr_interface_mux* bsr_procedure, phr_proc* phr_procedure_);
@ -57,8 +58,8 @@ public:
void print_logical_channel_state(const std::string& info);
private:
bool has_logical_channel(const uint32_t& lcid);
bool pdu_move_to_msg3(uint32_t pdu_sz);
bool has_logical_channel(const uint32_t& lcid);
bool pdu_move_to_msg3(uint32_t pdu_sz);
uint32_t allocate_sdu(uint32_t lcid, srslte::sch_pdu* pdu, int max_sdu_sz);
bool sched_sdu(srslte::logical_channel_config_t* ch, int* sdu_space, int max_sdu_sz);
@ -69,11 +70,12 @@ private:
// Mutex for exclusive access
std::mutex mutex;
srslte::log_ref log_h;
rlc_interface_mac* rlc = nullptr;
bsr_interface_mux* bsr_procedure = nullptr;
phr_proc* phr_procedure = nullptr;
uint16_t pending_crnti_ce = 0;
srslte::log_ref log_h;
srslog::basic_logger& logger;
rlc_interface_mac* rlc = nullptr;
bsr_interface_mux* bsr_procedure = nullptr;
phr_proc* phr_procedure = nullptr;
uint16_t pending_crnti_ce = 0;
/* Msg3 Buffer */
srslte::byte_buffer_t msg_buff;

@ -20,6 +20,7 @@
#include "srslte/common/logmap.h"
#include "srslte/common/timers.h"
#include "srslte/interfaces/ue_interfaces.h"
#include "srslte/srslog/srslog.h"
/* Buffer status report procedure */
@ -49,9 +50,8 @@ public:
class bsr_proc : public srslte::timer_callback, public bsr_interface_mux
{
public:
bsr_proc();
void
init(sr_proc* sr_proc, rlc_interface_mac* rlc, srslte::log_ref log_h, srslte::ext_task_sched_handle* task_sched_);
explicit bsr_proc(srslog::basic_logger& logger) : logger(logger) {}
void init(sr_proc* sr_proc, rlc_interface_mac* rlc, srslte::ext_task_sched_handle* task_sched_);
void step(uint32_t tti);
void reset();
void set_config(srslte::bsr_cfg_t& bsr_cfg);
@ -69,7 +69,7 @@ private:
std::mutex mutex;
srslte::ext_task_sched_handle* task_sched = nullptr;
srslte::log_ref log_h;
srslog::basic_logger& logger;
rlc_interface_mac* rlc = nullptr;
sr_proc* sr = nullptr;

@ -16,6 +16,7 @@
#include "srslte/common/logmap.h"
#include "srslte/common/timers.h"
#include "srslte/interfaces/ue_interfaces.h"
#include "srslte/srslog/srslog.h"
#include <stdint.h>
/* Power headroom report procedure */
@ -25,8 +26,8 @@ namespace srsue {
class phr_proc : public srslte::timer_callback
{
public:
phr_proc();
void init(phy_interface_mac_lte* phy_h, srslte::log_ref log_h_, srslte::ext_task_sched_handle* task_sched_);
explicit phr_proc(srslog::basic_logger& logger);
void init(phy_interface_mac_lte* phy_h, srslte::ext_task_sched_handle* task_sched_);
void set_config(srslte::phr_cfg_t& cfg);
void step();
void reset();
@ -40,7 +41,7 @@ public:
private:
bool pathloss_changed();
srslte::log_ref log_h;
srslog::basic_logger& logger;
phy_interface_mac_lte* phy_h;
srslte::ext_task_sched_handle* task_sched;
srslte::phr_cfg_t phr_cfg;

@ -31,13 +31,12 @@ namespace srsue {
class ra_proc : public srslte::timer_callback
{
public:
ra_proc() : rar_pdu_msg(20){};
explicit ra_proc(srslog::basic_logger& logger) : rar_pdu_msg(20), logger(logger) {}
~ra_proc();
void init(phy_interface_mac_lte* phy_h,
rrc_interface_mac* rrc_,
srslte::log_ref log_h,
mac_interface_rrc::ue_rnti_t* rntis,
srslte::timer_handler::unique_timer* time_alignment_timer_,
mux* mux_unit,
@ -137,7 +136,7 @@ private:
void read_params();
phy_interface_mac_lte* phy_h = nullptr;
srslte::log_ref log_h;
srslog::basic_logger& logger;
mux* mux_unit = nullptr;
srslte::mac_pcap* pcap = nullptr;
rrc_interface_mac* rrc = nullptr;

@ -15,6 +15,7 @@
#include "srslte/common/logmap.h"
#include "srslte/interfaces/ue_interfaces.h"
#include "srslte/srslog/srslog.h"
#include <stdint.h>
/* Scheduling Request procedure as defined in 5.4.4 of 36.321 */
@ -27,8 +28,8 @@ class ra_proc;
class sr_proc
{
public:
sr_proc();
void init(ra_proc* ra, phy_interface_mac_lte* phy_h, rrc_interface_mac* rrc, srslte::log_ref log_h);
explicit sr_proc(srslog::basic_logger& logger);
void init(ra_proc* ra, phy_interface_mac_lte* phy_h, rrc_interface_mac* rrc);
void step(uint32_t tti);
void set_config(srslte::sr_cfg_t& cfg);
void reset();
@ -45,7 +46,7 @@ private:
ra_proc* ra;
rrc_interface_mac* rrc;
phy_interface_mac_lte* phy_h;
srslte::log_ref log_h;
srslog::basic_logger& logger;
bool initiated;
};

@ -31,7 +31,7 @@ class ul_harq_entity
public:
ul_harq_entity(const uint8_t cc_idx_);
bool init(srslte::log_ref log_h_, mac_interface_rrc_common::ue_rnti_t* rntis_, ra_proc* ra_proc_h_, mux* mux_unit_);
bool init(mac_interface_rrc_common::ue_rnti_t* rntis_, ra_proc* ra_proc_h_, mux* mux_unit_);
void reset();
void reset_ndi();
@ -77,7 +77,7 @@ private:
bool is_grant_configured;
bool is_initiated;
srslte::log_ref log_h;
srslog::basic_logger& logger;
ul_harq_entity* harq_entity;
srslte_softbuffer_tx_t softbuffer;
@ -94,9 +94,9 @@ private:
std::vector<ul_harq_process> proc;
mux* mux_unit = nullptr;
srslte::mac_pcap* pcap = nullptr;
srslte::log_ref log_h;
mux* mux_unit = nullptr;
srslte::mac_pcap* pcap = nullptr;
srslog::basic_logger& logger;
mac_interface_rrc_common::ue_rnti_t* rntis = nullptr;
srslte::ul_harq_cfg_t harq_cfg = {};
@ -108,7 +108,7 @@ private:
uint8_t cc_idx = 0;
};
typedef std::unique_ptr<ul_harq_entity> ul_harq_entity_ptr;
typedef std::unique_ptr<ul_harq_entity> ul_harq_entity_ptr;
typedef std::array<ul_harq_entity_ptr, SRSLTE_MAX_CARRIERS> ul_harq_entity_vector;
} // namespace srsue

@ -25,6 +25,7 @@
#include "srslte/common/security.h"
#include "srslte/common/stack_procedure.h"
#include "srslte/interfaces/ue_interfaces.h"
#include "srslte/srslog/srslog.h"
#include <map>
#include <math.h>
@ -175,7 +176,7 @@ private:
stack_interface_rrc* stack = nullptr;
srslte::task_sched_handle task_sched;
srslte::byte_buffer_pool* pool = nullptr;
srslte::log_ref rrc_log;
srslog::basic_logger& logger;
phy_interface_rrc_lte* phy = nullptr;
mac_interface_rrc* mac = nullptr;
rlc_interface_rrc* rlc = nullptr;
@ -288,7 +289,7 @@ private:
void process_cell_meas_nr();
void process_new_cell_meas_nr(const std::vector<phy_meas_nr_t>& meas);
srslte::block_queue<std::vector<phy_meas_nr_t> > cell_meas_nr_q;
#endif
#endif
// Cell selection/reselection functions/variables
typedef struct {

@ -20,6 +20,7 @@
#include "srslte/asn1/rrc_nr_utils.h"
#endif
#include "srslte/interfaces/ue_interfaces.h"
#include "srslte/srslog/srslog.h"
namespace srsue {
@ -178,7 +179,7 @@ public:
asn1::rrc::mcch_msg_s mcch = {};
private:
bool has_valid_sib13 = false;
bool has_valid_sib13 = false;
};
//! Universal methods to extract pci/earfcn and compare the two values
@ -242,17 +243,17 @@ public:
bool process_new_cell_meas(const std::vector<phy_meas_t>& meas,
const std::function<void(T&, const phy_meas_t&)>& filter_meas);
T* get_neighbour_cell_handle(uint32_t earfcn, uint32_t pci);
const T* get_neighbour_cell_handle(uint32_t earfcn, uint32_t pci) const;
void log_neighbour_cells() const;
std::string print_neighbour_cells() const;
std::set<uint32_t> get_neighbour_pcis(uint32_t earfcn) const;
bool has_neighbour_cell(uint32_t earfcn, uint32_t pci) const;
size_t nof_neighbours() const { return neighbour_cells.size(); }
T& operator[](size_t idx) { return *neighbour_cells[idx]; }
const T& operator[](size_t idx) const { return *neighbour_cells[idx]; }
T& at(size_t idx) { return *neighbour_cells.at(idx); }
T* find_cell(uint32_t earfcn, uint32_t pci);
T* get_neighbour_cell_handle(uint32_t earfcn, uint32_t pci);
const T* get_neighbour_cell_handle(uint32_t earfcn, uint32_t pci) const;
void log_neighbour_cells() const;
std::string print_neighbour_cells() const;
std::set<uint32_t> get_neighbour_pcis(uint32_t earfcn) const;
bool has_neighbour_cell(uint32_t earfcn, uint32_t pci) const;
size_t nof_neighbours() const { return neighbour_cells.size(); }
T& operator[](size_t idx) { return *neighbour_cells[idx]; }
const T& operator[](size_t idx) const { return *neighbour_cells[idx]; }
T& at(size_t idx) { return *neighbour_cells.at(idx); }
T* find_cell(uint32_t earfcn, uint32_t pci);
// serving cell handling
int set_serving_cell(phy_cell_t phy_cell, bool discard_serving);
@ -268,7 +269,7 @@ private:
bool add_neighbour_cell_unsorted(unique_meas_cell cell);
// args
srslte::log_ref log_h{"RRC"};
srslog::basic_logger& logger = srslog::fetch_basic_logger("RRC");
srslte::task_sched_handle task_sched;
unique_meas_cell serv_cell;

@ -35,11 +35,11 @@ meas_obj_to_add_mod_s* find_meas_obj_map(std::map<uint32_t, meas_obj_to_add_mod_
class rrc::rrc_meas
{
public:
rrc_meas() : meas_cfg(&meas_report_list), meas_report_list(&meas_cfg), log_h(srslte::logmap::get("RRC")) {}
rrc_meas() : meas_cfg(&meas_report_list), meas_report_list(&meas_cfg), logger(srslog::fetch_basic_logger("RRC")) {}
void init(rrc* rrc_ptr);
void reset();
bool parse_meas_config(const rrc_conn_recfg_r8_ies_s* meas_config, bool is_ho_reest = false, uint32_t src_earfcn = 0);
void ho_reest_actions(const uint32_t src_earfcn, const uint32_t dst_earfcn);
void ho_reest_actions(const uint32_t src_earfcn, const uint32_t dst_earfcn);
void run_tti();
void update_phy();
float rsrp_filter(const float new_value, const float avg_value);
@ -58,16 +58,16 @@ private:
class var_meas_report_list
{
public:
var_meas_report_list(var_meas_cfg* meas_cfg_) : meas_cfg(meas_cfg_), log_h(srslte::logmap::get("RRC")) {}
void init(rrc* rrc);
void generate_report(const uint32_t measId);
void remove_all_varmeas_reports();
void remove_varmeas_report(const uint32_t measId);
bool is_timer_expired(const uint32_t measId);
void set_measId(const uint32_t measId,
const uint32_t carrier_freq,
const report_cfg_eutra_s& report_cfg,
const cell_triggered_t& cell_triggered_list);
var_meas_report_list(var_meas_cfg* meas_cfg_) : meas_cfg(meas_cfg_), logger(srslog::fetch_basic_logger("RRC")) {}
void init(rrc* rrc);
void generate_report(const uint32_t measId);
void remove_all_varmeas_reports();
void remove_varmeas_report(const uint32_t measId);
bool is_timer_expired(const uint32_t measId);
void set_measId(const uint32_t measId,
const uint32_t carrier_freq,
const report_cfg_eutra_s& report_cfg,
const cell_triggered_t& cell_triggered_list);
void set_measId(const uint32_t measId,
const uint32_t carrier_freq,
@ -94,7 +94,7 @@ private:
srslte::timer_handler::unique_timer periodic_timer = {};
};
var_meas_cfg* meas_cfg = nullptr;
srslte::log_ref log_h;
srslog::basic_logger& logger;
rrc* rrc_ptr = nullptr;
std::map<uint32_t, var_meas_report> varMeasReportList;
};
@ -104,7 +104,9 @@ private:
class var_meas_cfg
{
public:
var_meas_cfg(var_meas_report_list* meas_report_) : meas_report(meas_report_), log_h(srslte::logmap::get("RRC")) {}
var_meas_cfg(var_meas_report_list* meas_report_) :
meas_report(meas_report_), logger(srslog::fetch_basic_logger("RRC"))
{}
void init(rrc* rrc);
void reset();
phy_quant_t get_filter_a();
@ -114,6 +116,7 @@ private:
bool parse_meas_config(const meas_cfg_s* meas_config, bool is_ho_reest, uint32_t src_earfcn);
void eval_triggers();
void report_triggers();
private:
void remove_varmeas_report(const uint32_t meas_id);
@ -127,7 +130,7 @@ private:
void log_debug_trigger_value_eutra(const eutra_event_s::event_id_c_& e);
void log_debug_trigger_value_interrat(const report_cfg_inter_rat_s::trigger_type_c_::event_s_::event_id_c_& e);
static bool is_rsrp(report_cfg_eutra_s::trigger_quant_opts::options q);
// Helpers
void measObject_addmod_eutra(const meas_obj_to_add_mod_s& l);
void measObject_addmod_nr_r15(const meas_obj_to_add_mod_s& l);
@ -185,15 +188,15 @@ private:
#endif
var_meas_report_list* meas_report = nullptr;
srslte::log_ref log_h;
srslog::basic_logger& logger;
rrc* rrc_ptr = nullptr;
};
std::mutex meas_cfg_mutex;
var_meas_cfg meas_cfg;
var_meas_report_list meas_report_list;
srslte::log_ref log_h;
rrc* rrc_ptr = nullptr;
std::mutex meas_cfg_mutex;
var_meas_cfg meas_cfg;
var_meas_report_list meas_report_list;
srslog::basic_logger& logger;
rrc* rrc_ptr = nullptr;
// Static functions
static uint8_t value_to_range(const report_cfg_eutra_s::trigger_quant_opts::options q, float value);

@ -12,6 +12,7 @@
#include "phy_controller.h"
#include "srslte/common/log.h"
#include "srslte/srslog/srslog.h"
#include "srsue/hdr/stack/rrc/rrc.h"
#include <map>
#include <string>
@ -77,8 +78,8 @@ private:
void start_si_acquire();
// conts
rrc* rrc_ptr;
srslte::log_ref log_h;
rrc* rrc_ptr;
srslog::basic_logger& logger;
// state
srslte::timer_handler::unique_timer si_acq_timeout, si_acq_retry_timer;
@ -95,8 +96,8 @@ public:
static const char* name() { return "Serving Cell Configuration"; }
private:
rrc* rrc_ptr;
srslte::log_ref log_h;
rrc* rrc_ptr;
srslog::basic_logger& logger;
srslte::proc_outcome_t launch_sib_acquire();
@ -159,8 +160,8 @@ public:
private:
// consts
rrc* rrc_ptr;
srslte::log_ref log_h;
rrc* rrc_ptr;
srslog::basic_logger& logger;
// state variables
found_plmn_t found_plmns[MAX_FOUND_PLMNS];
@ -180,8 +181,8 @@ public:
private:
// const
rrc* rrc_ptr;
srslte::log_ref log_h;
rrc* rrc_ptr;
srslog::basic_logger& logger;
// args
srslte::establishment_cause_t cause;
srslte::unique_byte_buffer_t dedicated_info_nas;
@ -225,9 +226,9 @@ public:
private:
// args
rrc* rrc_ptr;
srslte::log_ref log_h;
asn1::rrc::paging_s paging;
rrc* rrc_ptr;
srslog::basic_logger& logger;
asn1::rrc::paging_s paging;
// vars
uint32_t paging_idx = 0;

@ -51,7 +51,7 @@ class ue_stack_lte final : public ue_stack_base,
public srslte::thread
{
public:
ue_stack_lte();
explicit ue_stack_lte(srslog::sink& log_sink);
~ue_stack_lte();
std::string get_type() final;
@ -138,15 +138,21 @@ private:
srslte::tti_point current_tti;
// UE stack logging
srslte::logger* logger = nullptr;
srslte::log_ref stack_log{"STCK"}; ///< our own log filter
srslte::log_ref mac_log{"MAC"};
srslte::log_ref rlc_log{"RLC"};
srslte::log_ref pdcp_log{"PDCP"};
srslte::log_ref rrc_log{"RRC"};
srslte::log_ref usim_log{"USIM"};
srslte::log_ref nas_log{"NAS"};
srslte::log_ref pool_log{"POOL"};
srslte::logger* logger = nullptr;
srslte::log_ref mac_log{"MAC"};
srslte::log_ref rlc_log{"RLC"};
srslte::log_ref pdcp_log{"PDCP"};
srslte::log_ref rrc_log{"RRC"};
srslte::log_ref usim_log{"USIM"};
srslte::log_ref nas_log{"NAS"};
srslte::log_ref pool_log{"POOL"};
srslog::basic_logger& stack_logger;
srslog::basic_logger& mac_logger;
srslog::basic_logger& rlc_logger;
srslog::basic_logger& pdcp_logger;
srslog::basic_logger& rrc_logger;
srslog::basic_logger& usim_logger;
srslog::basic_logger& nas_logger;
// RAT-specific interfaces
phy_interface_stack_lte* phy = nullptr;

@ -21,6 +21,7 @@
#include "srslte/common/log_filter.h"
#include "srslte/common/threads.h"
#include "srslte/interfaces/ue_interfaces.h"
#include "srslte/srslog/srslog.h"
#include "tft_packet_filter.h"
#include <net/if.h>
@ -50,10 +51,10 @@ public:
void write_pdu_mch(uint32_t lcid, srslte::unique_byte_buffer_t pdu);
// NAS interface
int setup_if_addr(uint32_t lcid, uint8_t pdn_type, uint32_t ip_addr, uint8_t* ipv6_if_addr, char* err_str);
int apply_traffic_flow_template(const uint8_t& eps_bearer_id,
const uint8_t& lcid,
const LIBLTE_MME_TRAFFIC_FLOW_TEMPLATE_STRUCT* tft);
int setup_if_addr(uint32_t lcid, uint8_t pdn_type, uint32_t ip_addr, uint8_t* ipv6_if_addr, char* err_str);
int apply_traffic_flow_template(const uint8_t& eps_bearer_id,
const uint8_t& lcid,
const LIBLTE_MME_TRAFFIC_FLOW_TEMPLATE_STRUCT* tft);
void set_test_loop_mode(const test_loop_mode_state_t mode, const uint32_t ip_pdu_delay_ms);
// RRC interface
@ -62,9 +63,9 @@ public:
private:
static const int GW_THREAD_PRIO = -1;
stack_interface_gw* stack = nullptr;
srslte::byte_buffer_pool* pool = nullptr;
srslte::logger* logger = nullptr;
stack_interface_gw* stack = nullptr;
srslte::byte_buffer_pool* pool = nullptr;
srslte::logger* old_logger = nullptr;
gw_args_t args = {};
@ -77,13 +78,13 @@ private:
bool if_up = false;
uint32_t default_lcid = 0;
srslte::log_filter log;
srslog::basic_logger& logger;
uint32_t current_ip_addr = 0;
uint8_t current_if_id[8];
uint32_t ul_tput_bytes = 0;
uint32_t dl_tput_bytes = 0;
uint32_t ul_tput_bytes = 0;
uint32_t dl_tput_bytes = 0;
std::chrono::high_resolution_clock::time_point metrics_tp; // stores time when last metrics have been taken
void run_thread();
@ -99,7 +100,7 @@ private:
uint32_t mbsfn_ports[SRSLTE_N_MCH_LCIDS] = {}; // Target ports for MBSFN data
// TFT
tft_pdu_matcher tft_matcher;
tft_pdu_matcher tft_matcher;
};
} // namespace srsue

@ -22,6 +22,7 @@
#include "srslte/common/stack_procedure.h"
#include "srslte/common/task_scheduler.h"
#include "srslte/interfaces/ue_interfaces.h"
#include "srslte/srslog/srslog.h"
#include "srsue/hdr/stack/upper/nas_config.h"
#include "srsue/hdr/stack/upper/nas_emm_state.h"
#include "srsue/hdr/stack/upper/nas_metrics.h"
@ -73,7 +74,7 @@ public:
private:
srslte::byte_buffer_pool* pool = nullptr;
srslte::log_ref nas_log;
srslog::basic_logger& logger;
rrc_interface_nas* rrc = nullptr;
usim_interface_nas* usim = nullptr;
gw_interface_nas* gw = nullptr;
@ -158,7 +159,7 @@ private:
// Airplane mode simulation
typedef enum { DISABLED = 0, ENABLED } airplane_mode_state_t;
airplane_mode_state_t airplane_mode_state = {};
airplane_mode_state_t airplane_mode_state = {};
srslte::timer_handler::unique_timer airplane_mode_sim_timer;
// PCAP

@ -14,6 +14,7 @@
#define SRSUE_NAS_EMM_STATE_H
#include "srslte/common/logmap.h"
#include "srslte/srslog/srslog.h"
#include <atomic>
#include <string>
@ -80,7 +81,7 @@ private:
std::atomic<state_t> state{state_t::null}; // The GW might require to know the NAS state from another thread
deregistered_substate_t deregistered_substate = deregistered_substate_t::null;
registered_substate_t registered_substate = registered_substate_t::null;
srslte::log_ref nas_log{"NAS"};
srslog::basic_logger& logger = srslog::fetch_basic_logger("NAS");
};
const char* emm_state_text(emm_state_t::state_t type);

@ -33,7 +33,7 @@ static inline uint16_t to_uint16(const uint8_t* a)
class pcsc_usim : public usim_base
{
public:
pcsc_usim(srslte::log* log_);
explicit pcsc_usim(srslog::basic_logger& logger);
~pcsc_usim();
int init(usim_args_t* args);
void stop();
@ -57,10 +57,10 @@ private:
class scard
{
public:
scard() : log(NULL){};
explicit scard(srslog::basic_logger& logger) : logger(logger) {}
~scard(){};
int init(usim_args_t* args, srslte::log* log_);
int init(usim_args_t* args);
void deinit();
int select_file(unsigned short file_id, unsigned char* buf, size_t* buf_len);
@ -171,12 +171,12 @@ private:
#define SCARD_CHV1_OFFSET 13
#define SCARD_CHV1_FLAG 0x80
SCARDCONTEXT scard_context;
SCARDHANDLE scard_handle;
long unsigned scard_protocol;
sim_types_t sim_type;
bool pin1_needed;
srslte::log* log;
SCARDCONTEXT scard_context;
SCARDHANDLE scard_handle;
long unsigned scard_protocol;
sim_types_t sim_type;
bool pin1_needed;
srslog::basic_logger& logger;
};
scard sc;

@ -17,6 +17,7 @@
#include "srslte/common/buffer_pool.h"
#include "srslte/common/log.h"
#include "srslte/common/log_filter.h"
#include "srslte/srslog/srslog.h"
#include <mutex>
namespace srsue {
@ -62,36 +63,36 @@ public:
tft_packet_filter_t(uint8_t eps_bearer_id_,
uint8_t lcid_,
const LIBLTE_MME_PACKET_FILTER_STRUCT& tft_,
srslte::log* log_);
srslog::basic_logger& logger);
bool match(const srslte::unique_byte_buffer_t& pdu);
bool filter_contains(uint16_t filtertype);
uint8_t eps_bearer_id {};
uint8_t lcid = {};
uint8_t id = {};
uint8_t eval_precedence = {};
uint32_t active_filters = {};
uint32_t ipv4_remote_addr = {};
uint32_t ipv4_remote_addr_mask = {};
uint32_t ipv4_local_addr = {};
uint32_t ipv4_local_addr_mask = {};
uint8_t ipv6_remote_addr[16] = {};
uint8_t eps_bearer_id{};
uint8_t lcid = {};
uint8_t id = {};
uint8_t eval_precedence = {};
uint32_t active_filters = {};
uint32_t ipv4_remote_addr = {};
uint32_t ipv4_remote_addr_mask = {};
uint32_t ipv4_local_addr = {};
uint32_t ipv4_local_addr_mask = {};
uint8_t ipv6_remote_addr[16] = {};
uint8_t ipv6_remote_addr_mask[16] = {};
uint8_t ipv6_remote_addr_length = {};
uint8_t ipv6_local_addr[16] = {};
uint8_t ipv6_local_addr_mask[16] = {};
uint8_t ipv6_local_addr_length = {};
uint8_t protocol_id = {};
uint16_t single_local_port = {};
uint16_t local_port_range[2] = {};
uint16_t single_remote_port = {};
uint16_t remote_port_range[2] = {};
uint32_t security_parameter_index = {};
uint8_t type_of_service = {};
uint8_t type_of_service_mask = {};
uint8_t flow_label[3] = {};
uint8_t ipv6_remote_addr_length = {};
uint8_t ipv6_local_addr[16] = {};
uint8_t ipv6_local_addr_mask[16] = {};
uint8_t ipv6_local_addr_length = {};
uint8_t protocol_id = {};
uint16_t single_local_port = {};
uint16_t local_port_range[2] = {};
uint16_t single_remote_port = {};
uint16_t remote_port_range[2] = {};
uint32_t security_parameter_index = {};
uint8_t type_of_service = {};
uint8_t type_of_service_mask = {};
uint8_t flow_label[3] = {};
srslte::log* log;
srslog::basic_logger& logger;
bool match_ip(const srslte::unique_byte_buffer_t& pdu);
bool match_protocol(const srslte::unique_byte_buffer_t& pdu);
@ -106,7 +107,7 @@ public:
class tft_pdu_matcher
{
public:
tft_pdu_matcher(srslte::log_filter* log_) : log(log_){};
explicit tft_pdu_matcher(srslog::basic_logger& logger) : logger(logger) {}
~tft_pdu_matcher(){};
void set_default_lcid(const uint8_t lcid);
@ -116,7 +117,7 @@ public:
const LIBLTE_MME_TRAFFIC_FLOW_TEMPLATE_STRUCT* tft);
private:
srslte::log_filter* log = nullptr;
srslog::basic_logger& logger;
uint8_t default_lcid = 0;
std::mutex tft_mutex;
typedef std::map<uint16_t, tft_packet_filter_t> tft_filter_map_t;

@ -25,7 +25,7 @@ namespace srsue {
class usim : public usim_base
{
public:
usim(srslte::log* log_);
explicit usim(srslog::basic_logger& logger);
int init(usim_args_t* args);
void stop();

@ -17,6 +17,7 @@
#include "srslte/common/log.h"
#include "srslte/common/security.h"
#include "srslte/interfaces/ue_interfaces.h"
#include "srslte/srslog/srslog.h"
#include <string>
namespace srsue {
@ -57,9 +58,9 @@ public:
class usim_base : public usim_interface_nas, public usim_interface_rrc, public usim_interface_rrc_nr
{
public:
usim_base(srslte::log* log_);
explicit usim_base(srslog::basic_logger& logger);
virtual ~usim_base();
static std::unique_ptr<usim_base> get_instance(usim_args_t* args, srslte::log* log_);
static std::unique_ptr<usim_base> get_instance(usim_args_t* args, srslog::basic_logger& logger);
virtual int init(usim_args_t* args) = 0;
virtual void stop() = 0;
@ -104,7 +105,7 @@ protected:
bool initiated = false;
// Logging
srslte::log* log = nullptr;
srslog::basic_logger& logger;
// User data
// 3GPP 33.102 v10.0.0 Annex H

@ -28,6 +28,7 @@
#include "srslte/common/log_filter.h"
#include "srslte/interfaces/ue_interfaces.h"
#include "srslte/radio/radio.h"
#include "srslte/srslog/srslog.h"
#include "stack/ue_stack_base.h"
#include "ue_metrics_interface.h"
@ -83,7 +84,7 @@ typedef struct {
class ue : public ue_metrics_interface
{
public:
ue();
ue(srslog::sink& log_sink);
~ue();
int init(const all_args_t& args_, srslte::logger* logger_);
@ -105,8 +106,9 @@ private:
std::unique_ptr<gw> gw_inst;
// Generic logger members
srslte::logger* logger = nullptr;
srslte::log_filter log; // Own logger for UE
srslte::logger* old_logger = nullptr;
srslog::sink& log_sink;
srslog::basic_logger& logger;
all_args_t args;
srslte::byte_buffer_pool* pool = nullptr;

@ -641,6 +641,7 @@ int main(int argc, char* argv[])
return SRSLTE_ERROR;
}
srslte::srslog_wrapper log_wrapper(*chan);
srslog::set_default_sink(*log_sink);
// Start the log backend.
srslog::init();
@ -651,7 +652,7 @@ int main(int argc, char* argv[])
srslte::check_scaling_governor(args.rf.device_name);
// Create UE instance
srsue::ue ue;
srsue::ue ue(*log_sink);
if (ue.init(args, &log_wrapper)) {
ue.stop();
return SRSLTE_SUCCESS;

@ -16,16 +16,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__)
#define CURRENT_TTI (sf_cfg_dl.tti)
#define CURRENT_SFIDX (sf_cfg_dl.tti % 10)
@ -40,34 +40,34 @@ namespace lte {
*
*/
cc_worker::cc_worker(uint32_t cc_idx_, uint32_t max_prb, srsue::phy_common* phy_, srslte::log* log_h_)
cc_worker::cc_worker(uint32_t cc_idx_, uint32_t max_prb, srsue::phy_common* phy_, srslog::basic_logger& logger) :
logger(logger)
{
cc_idx = cc_idx_;
phy = phy_;
log_h = log_h_;
signal_buffer_max_samples = 3 * SRSLTE_SF_LEN_PRB(max_prb);
for (uint32_t i = 0; i < phy->args->nof_rx_ant; i++) {
signal_buffer_rx[i] = srslte_vec_cf_malloc(signal_buffer_max_samples);
if (!signal_buffer_rx[i]) {
Error("Allocating memory\n");
Error("Allocating memory");
return;
}
signal_buffer_tx[i] = srslte_vec_cf_malloc(signal_buffer_max_samples);
if (!signal_buffer_tx[i]) {
Error("Allocating memory\n");
Error("Allocating memory");
return;
}
}
if (srslte_ue_dl_init(&ue_dl, signal_buffer_rx, max_prb, phy->args->nof_rx_ant)) {
Error("Initiating UE DL\n");
Error("Initiating UE DL");
return;
}
if (srslte_ue_ul_init(&ue_ul, signal_buffer_tx[0], max_prb)) {
Error("Initiating UE UL\n");
Error("Initiating UE UL");
return;
}
@ -125,16 +125,16 @@ bool cc_worker::set_cell_unlocked(srslte_cell_t cell_)
cell = cell_;
if (srslte_ue_dl_set_cell(&ue_dl, cell)) {
Error("Setting ue_dl cell\n");
Error("Setting ue_dl cell");
return false;
}
if (srslte_ue_dl_set_mbsfn_area_id(&ue_dl, 1)) {
Error("Setting mbsfn id\n");
Error("Setting mbsfn id");
}
if (srslte_ue_ul_set_cell(&ue_ul, cell)) {
Error("Initiating UE UL\n");
Error("Initiating UE UL");
return false;
}
@ -212,7 +212,7 @@ bool cc_worker::work_dl_regular()
bool found_dl_grant = false;
if (!cell_initiated) {
log_h->warning("Trying to access cc_worker=%d while cell not initialized (DL)\n", cc_idx);
logger.warning("Trying to access cc_worker=%d while cell not initialized (DL)", cc_idx);
return false;
}
@ -242,7 +242,7 @@ bool cc_worker::work_dl_regular()
/* Do FFT and extract PDCCH LLR, or quit if no actions are required in this subframe */
if (srslte_ue_dl_decode_fft_estimate(&ue_dl, &sf_cfg_dl, &ue_dl_cfg) < 0) {
Error("Getting PDCCH FFT estimate\n");
Error("Getting PDCCH FFT estimate");
return false;
}
@ -267,7 +267,7 @@ bool cc_worker::work_dl_regular()
}
// Generate PHY grant
if (srslte_ue_dl_dci_to_pdsch_grant(&ue_dl, &sf_cfg_dl, &ue_dl_cfg, &dci_dl, &ue_dl_cfg.cfg.pdsch.grant)) {
Info("Converting DCI message to DL dci\n");
Info("Converting DCI message to DL dci");
return false;
}
@ -307,7 +307,7 @@ bool cc_worker::work_dl_mbsfn(srslte_mbsfn_cfg_t mbsfn_cfg)
mac_interface_phy_lte::tb_action_dl_t dl_action = {};
if (!cell_initiated) {
log_h->warning("Trying to access cc_worker=%d while cell not initialized (MBSFN)\n", cc_idx);
logger.warning("Trying to access cc_worker=%d while cell not initialized (MBSFN)", cc_idx);
return false;
}
@ -323,7 +323,7 @@ bool cc_worker::work_dl_mbsfn(srslte_mbsfn_cfg_t mbsfn_cfg)
/* Do FFT and extract PDCCH LLR, or quit if no actions are required in this subframe */
if (srslte_ue_dl_decode_fft_estimate(&ue_dl, &sf_cfg_dl, &ue_dl_cfg) < 0) {
Error("Getting PDCCH FFT estimate\n");
Error("Getting PDCCH FFT estimate");
return false;
}
@ -383,12 +383,12 @@ int cc_worker::decode_pdcch_dl()
/* Blind search first without cross scheduling then with it if enabled */
for (int i = 0; i < (ue_dl_cfg.cfg.dci.cif_present ? 2 : 1) && !nof_grants; i++) {
Debug("PDCCH looking for rnti=0x%x\n", dl_rnti);
Debug("PDCCH looking for rnti=0x%x", dl_rnti);
ue_dl_cfg.cfg.dci.cif_enabled = i > 0;
ue_dl_cfg.cfg.dci_common_ss = (cc_idx == 0);
nof_grants = srslte_ue_dl_find_dl_dci(&ue_dl, &sf_cfg_dl, &ue_dl_cfg, dl_rnti, dci);
if (nof_grants < 0) {
Error("Looking for DL grants\n");
Error("Looking for DL grants");
return -1;
}
}
@ -403,10 +403,10 @@ int cc_worker::decode_pdcch_dl()
phy->set_dl_pending_grant(CURRENT_TTI, dci[k].cif_present ? dci[k].cif : cc_idx, cc_idx, &dci[k]);
// Logging
if (log_h->get_level() >= srslte::LOG_LEVEL_INFO) {
if (logger.info.enabled()) {
char str[512];
srslte_dci_dl_info(&dci[k], str, 512);
log_h->info("PDCCH: cc=%d, %s, snr=%.1f dB\n", cc_idx, str, ue_dl.chest_res.snr_db);
logger.info("PDCCH: cc=%d, %s, snr=%.1f dB", cc_idx, str, ue_dl.chest_res.snr_db);
}
}
}
@ -444,7 +444,7 @@ int cc_worker::decode_pdsch(srslte_pdsch_ack_resource_t ack_resource,
// Run PDSCH decoder
if (decode_enable) {
if (srslte_ue_dl_decode_pdsch(&ue_dl, &sf_cfg_dl, &ue_dl_cfg.cfg.pdsch, pdsch_dec)) {
Error("ERROR: Decoding PDSCH\n");
Error("ERROR: Decoding PDSCH");
}
}
@ -480,10 +480,10 @@ int cc_worker::decode_pdsch(srslte_pdsch_ack_resource_t ack_resource,
phy->set_dl_metrics(cc_idx, dl_metrics);
// Logging
if (log_h->get_level() >= srslte::LOG_LEVEL_INFO) {
if (logger.info.enabled()) {
char str[512];
srslte_pdsch_rx_info(&ue_dl_cfg.cfg.pdsch, pdsch_dec, str, 512);
log_h->info("PDSCH: cc=%d, %s, snr=%.1f dB\n", cc_idx, str, ue_dl.chest_res.snr_db);
logger.info("PDSCH: cc=%d, %s, snr=%.1f dB", cc_idx, str, ue_dl.chest_res.snr_db);
}
}
@ -503,7 +503,7 @@ int cc_worker::decode_pmch(mac_interface_phy_lte::tb_action_dl_t* action, srslte
srslte_softbuffer_rx_reset_tbs(pmch_cfg.pdsch_cfg.softbuffers.rx[0], pmch_cfg.pdsch_cfg.grant.tb[0].tbs);
if (srslte_ue_dl_decode_pmch(&ue_dl, &sf_cfg_dl, &pmch_cfg, &pmch_dec)) {
Error("Decoding PMCH\n");
Error("Decoding PMCH");
return -1;
}
@ -514,7 +514,7 @@ int cc_worker::decode_pmch(mac_interface_phy_lte::tb_action_dl_t* action, srslte
dl_metrics.turbo_iters = pmch_dec.avg_iterations_block / 2;
phy->set_dl_metrics(cc_idx, dl_metrics);
Info("PMCH: l_crb=%2d, tbs=%d, mcs=%d, crc=%s, snr=%.1f dB, n_iter=%.1f\n",
Info("PMCH: l_crb=%2d, tbs=%d, mcs=%d, crc=%s, snr=%.1f dB, n_iter=%.1f",
pmch_cfg.pdsch_cfg.grant.nof_prb,
pmch_cfg.pdsch_cfg.grant.tb[0].tbs / 8,
pmch_cfg.pdsch_cfg.grant.tb[0].mcs_idx,
@ -527,7 +527,7 @@ int cc_worker::decode_pmch(mac_interface_phy_lte::tb_action_dl_t* action, srslte
}
} else {
Warning("Received dci for TBS=0\n");
Warning("Received dci for TBS=0");
}
return 0;
}
@ -543,10 +543,10 @@ void cc_worker::decode_phich()
phich_grant.I_phich = I_phich;
if (phy->get_ul_pending_ack(&sf_cfg_dl, cc_idx, &phich_grant, &dci_ul)) {
if (srslte_ue_dl_decode_phich(&ue_dl, &sf_cfg_dl, &ue_dl_cfg, &phich_grant, &phich_res)) {
Error("Decoding PHICH\n");
Error("Decoding PHICH");
}
phy->set_ul_received_ack(&sf_cfg_dl, cc_idx, phich_res.ack_value, I_phich, &dci_ul);
Info("PHICH: hi=%d, corr=%.1f, I_lowest=%d, n_dmrs=%d, I_phich=%d\n",
Info("PHICH: hi=%d, corr=%.1f, I_lowest=%d, n_dmrs=%d, I_phich=%d",
phich_res.ack_value,
phich_res.distance,
phich_grant.n_prb_lowest,
@ -578,7 +578,7 @@ bool cc_worker::work_ul(srslte_uci_data_t* uci_data)
uint32_t pid = 0;
if (!cell_initiated) {
log_h->warning("Trying to access cc_worker=%d while cell not initialized (UL)\n", cc_idx);
logger.warning("Trying to access cc_worker=%d while cell not initialized (UL)", cc_idx);
return false;
}
@ -607,14 +607,14 @@ bool cc_worker::work_ul(srslte_uci_data_t* uci_data)
// Generate PHY grant
if (srslte_ue_ul_dci_to_pusch_grant(&ue_ul, &sf_cfg_ul, &ue_ul_cfg, &dci_ul, &ue_ul_cfg.ul_cfg.pusch.grant)) {
if (log_h->get_level() >= srslte::LOG_LEVEL_INFO) {
if (logger.info.enabled()) {
char str[128];
srslte_dci_ul_info(&dci_ul, str, sizeof(str));
Info("Converting DCI message to UL grant %s\n", str);
Info("Converting DCI message to UL grant %s", str);
}
ul_grant_available = false;
} else if (ue_ul_cfg.ul_cfg.pusch.grant.tb.mod == SRSLTE_MOD_BPSK) {
Error("UL retransmission without valid stored grant.\n");
Error("UL retransmission without valid stored grant.");
ul_grant_available = false;
} else {
// Save TBS info for next retx
@ -702,7 +702,7 @@ int cc_worker::decode_pdcch_ul()
ue_dl_cfg.cfg.dci_common_ss = (cc_idx == 0);
nof_grants = srslte_ue_dl_find_ul_dci(&ue_dl, &sf_cfg_dl, &ue_dl_cfg, ul_rnti, dci);
if (nof_grants < 0) {
Error("Looking for UL grants\n");
Error("Looking for UL grants");
return -1;
}
}
@ -717,10 +717,10 @@ int cc_worker::decode_pdcch_ul()
phy->set_ul_pending_grant(&sf_cfg_dl, cc_idx_grant, &dci[k]);
// Logging
if (log_h->get_level() >= srslte::LOG_LEVEL_INFO) {
if (logger.info.enabled()) {
char str[512];
srslte_dci_ul_info(&dci[k], str, 512);
log_h->info("PDCCH: cc=%d, %s, snr=%.1f dB\n", cc_idx_grant, str, ue_dl.chest_res.snr_db);
logger.info("PDCCH: cc=%d, %s, snr=%.1f dB", cc_idx_grant, str, ue_dl.chest_res.snr_db);
}
}
}
@ -761,7 +761,7 @@ bool cc_worker::encode_uplink(mac_interface_phy_lte::tb_action_ul_t* action, srs
// Encode signal
int ret = srslte_ue_ul_encode(&ue_ul, &sf_cfg_ul, &ue_ul_cfg, &data);
if (ret < 0) {
Error("Encoding UL cc=%d\n", cc_idx);
Error("Encoding UL cc=%d", cc_idx);
}
// Store metrics
@ -773,10 +773,10 @@ bool cc_worker::encode_uplink(mac_interface_phy_lte::tb_action_ul_t* action, srs
}
// Logging
if (log_h->get_level() >= srslte::LOG_LEVEL_INFO) {
if (logger.info.enabled()) {
char str[512];
if (srslte_ue_ul_info(&ue_ul_cfg, &sf_cfg_ul, &data.uci, str, 512)) {
log_h->info("%s\n", str);
logger.info("%s", str);
}
}
@ -785,12 +785,12 @@ bool cc_worker::encode_uplink(mac_interface_phy_lte::tb_action_ul_t* action, srs
void cc_worker::set_uci_sr(srslte_uci_data_t* uci_data)
{
Debug("set_uci_sr() query: sr_enabled=%d, last_tx_tti=%d\n", phy->sr_enabled, phy->sr_last_tx_tti);
Debug("set_uci_sr() query: sr_enabled=%d, last_tx_tti=%d", phy->sr_enabled, phy->sr_last_tx_tti);
if (srslte_ue_ul_gen_sr(&ue_ul_cfg, &sf_cfg_ul, uci_data, phy->sr_enabled)) {
if (phy->sr_enabled) {
phy->sr_last_tx_tti = CURRENT_TTI_TX;
phy->sr_enabled = false;
Debug("set_uci_sr() sending SR: sr_enabled=%d, last_tx_tti=%d\n", phy->sr_enabled, phy->sr_last_tx_tti);
Debug("set_uci_sr() sending SR: sr_enabled=%d, last_tx_tti=%d", phy->sr_enabled, phy->sr_last_tx_tti);
}
}
}
@ -824,7 +824,7 @@ void cc_worker::set_uci_aperiodic_cqi(srslte_uci_data_t* uci_data)
if (ue_dl_cfg.cfg.cqi_report.aperiodic_configured) {
srslte_ue_dl_gen_cqi_aperiodic(&ue_dl, &ue_dl_cfg, get_wideband_cqi(), uci_data);
} else {
Warning("Received CQI request but aperiodic mode is not configured\n");
Warning("Received CQI request but aperiodic mode is not configured");
}
}
@ -877,9 +877,9 @@ void cc_worker::set_config_unlocked(srslte::phy_cfg_t& phy_cfg)
// Update signals
if (pregen_enabled) {
Info("Pre-generating UL signals...\n");
Info("Pre-generating UL signals...");
srslte_ue_ul_pregen_signals(&ue_ul, &ue_ul_cfg);
Info("Done pre-generating signals worker...\n");
Info("Done pre-generating signals worker...");
}
}

@ -19,16 +19,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__)
/* This is to visualize the channel response */
#ifdef ENABLE_GUI
@ -48,14 +48,13 @@ static bool plot_nr_enable = false;
namespace srsue {
namespace lte {
sf_worker::sf_worker(uint32_t max_prb, phy_common* phy_, srslte::log* log_h_)
sf_worker::sf_worker(uint32_t max_prb, phy_common* phy_, srslog::basic_logger& logger) : logger(logger)
{
phy = phy_;
log_h = log_h_;
phy = phy_;
// ue_sync in phy.cc requires a buffer for 3 subframes
for (uint32_t r = 0; r < phy->args->nof_lte_carriers; r++) {
cc_workers.push_back(new cc_worker(r, max_prb, phy, log_h));
cc_workers.push_back(new cc_worker(r, max_prb, phy, logger));
}
}
@ -75,11 +74,11 @@ bool sf_worker::set_cell_unlocked(uint32_t cc_idx, srslte_cell_t cell_)
{
if (cc_idx < cc_workers.size()) {
if (!cc_workers[cc_idx]->set_cell_unlocked(cell_)) {
Error("Setting cell for cc=%d\n", cc_idx);
Error("Setting cell for cc=%d", cc_idx);
return false;
}
} else {
Error("Setting cell for cc=%d; Not enough CC workers (%zd);\n", cc_idx, cc_workers.size());
Error("Setting cell for cc=%d; Not enough CC workers (%zd);", cc_idx, cc_workers.size());
}
if (cc_idx == 0) {
@ -113,7 +112,7 @@ void sf_worker::set_tti(uint32_t tti_)
cc_worker->set_tti(tti);
}
log_h->step(tti);
logger.set_context(tti);
}
void sf_worker::set_tx_time(const srslte::rf_timestamp_t& tx_time_)
@ -163,7 +162,7 @@ void sf_worker::set_config_unlocked(uint32_t cc_idx, srslte::phy_cfg_t phy_cfg)
cc_workers[0]->upd_config_dci_unlocked(phy_cfg.dl_cfg.dci);
}
} else {
Error("Setting config for cc=%d; Invalid cc_idx\n", cc_idx);
Error("Setting config for cc=%d; Invalid cc_idx", cc_idx);
}
}

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

@ -38,13 +38,13 @@ cc_worker::cc_worker(uint32_t cc_idx_, srslte::log* log, phy_nr_state* phy_state
}
if (srslte_ue_dl_nr_init(&ue_dl, buffer_c, &phy_state_->args.dl) < SRSLTE_SUCCESS) {
ERROR("Error initiating UE DL NR\n");
ERROR("Error initiating UE DL NR");
return;
}
if (srslte_softbuffer_rx_init_guru(&softbuffer_rx, 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);
@ -69,7 +69,7 @@ cc_worker::~cc_worker()
bool cc_worker::set_carrier(const srslte_carrier_nr_t* carrier)
{
if (srslte_ue_dl_nr_set_carrier(&ue_dl, carrier) < SRSLTE_SUCCESS) {
ERROR("Error setting carrier\n");
ERROR("Error setting carrier");
return false;
}
@ -77,7 +77,7 @@ bool cc_worker::set_carrier(const srslte_carrier_nr_t* carrier)
coreset.duration = 2;
if (srslte_ue_dl_nr_set_coreset(&ue_dl, &coreset) < SRSLTE_SUCCESS) {
ERROR("Error setting carrier\n");
ERROR("Error setting carrier");
return false;
}
@ -109,9 +109,9 @@ uint32_t cc_worker::get_buffer_len()
bool cc_worker::work_dl()
{
srslte_dci_dl_nr_t dci_dl = {};
srslte_sch_cfg_nr_t pdsch_cfg = phy_state->cfg.pdsch;
std::array<srslte_pdsch_res_nr_t, SRSLTE_MAX_CODEWORDS> pdsch_res = {};
srslte_dci_dl_nr_t dci_dl = {};
srslte_sch_cfg_nr_t pdsch_cfg = phy_state->cfg.pdsch;
std::array<srslte_pdsch_res_nr_t, SRSLTE_MAX_CODEWORDS> pdsch_res = {};
// Run FFT
srslte_ue_dl_nr_estimate_fft(&ue_dl, &dl_slot_cfg);
@ -128,12 +128,12 @@ bool cc_worker::work_dl()
srslte_dci_dl_nr_t dci_dl_rx = {};
int nof_found_dci = srslte_ue_dl_nr_find_dl_dci(&ue_dl, &search_space, &dl_slot_cfg, rnti, &dci_dl_rx, 1);
if (nof_found_dci < SRSLTE_SUCCESS) {
ERROR("Error decoding\n");
ERROR("Error decoding");
return SRSLTE_ERROR;
}
if (nof_found_dci < 1) {
ERROR("Error DCI not found\n");
ERROR("Error DCI not found");
}
dci_dl.rnti = 0x1234;
@ -145,7 +145,7 @@ bool cc_worker::work_dl()
// Compute DL grant
if (srslte_ra_dl_dci_to_grant_nr(&ue_dl.carrier, &pdsch_cfg, &dci_dl, &pdsch_cfg.grant)) {
ERROR("Computing DL grant\n");
ERROR("Computing DL grant");
}
pdsch_res[0].payload = data.data();
@ -153,7 +153,7 @@ bool cc_worker::work_dl()
srslte_softbuffer_rx_reset(pdsch_cfg.grant.tb[0].softbuffer.rx);
if (srslte_ue_dl_nr_decode_pdsch(&ue_dl, &dl_slot_cfg, &pdsch_cfg, pdsch_res.data()) < SRSLTE_SUCCESS) {
ERROR("Error decoding PDSCH\n");
ERROR("Error decoding PDSCH");
return false;
}
@ -161,7 +161,7 @@ bool cc_worker::work_dl()
if (log_h->get_level() >= srslte::LOG_LEVEL_INFO) {
char str[512];
srslte_ue_dl_nr_pdsch_info(&ue_dl, &pdsch_cfg, pdsch_res.data(), str, sizeof(str));
log_h->info("PDSCH: cc=%d, %s\n", cc_idx, str);
log_h->info("PDSCH: cc=%d, %s", cc_idx, str);
}
return true;

@ -25,16 +25,16 @@
#define Error(fmt, ...) \
if (SRSLTE_DEBUG_ENABLED) \
log_h->error(fmt, ##__VA_ARGS__)
logger_phy.error(fmt, ##__VA_ARGS__)
#define Warning(fmt, ...) \
if (SRSLTE_DEBUG_ENABLED) \
log_h->warning(fmt, ##__VA_ARGS__)
logger_phy.warning(fmt, ##__VA_ARGS__)
#define Info(fmt, ...) \
if (SRSLTE_DEBUG_ENABLED) \
log_h->info(fmt, ##__VA_ARGS__)
logger_phy.info(fmt, ##__VA_ARGS__)
#define Debug(fmt, ...) \
if (SRSLTE_DEBUG_ENABLED) \
log_h->debug(fmt, ##__VA_ARGS__)
logger_phy.debug(fmt, ##__VA_ARGS__)
using namespace std;
@ -48,22 +48,18 @@ 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);
break;
case LOG_LEVEL_DEBUG_S:
log_phy_lib_h->debug(" %s", str);
break;
case LOG_LEVEL_ERROR_S:
log_phy_lib_h->error(" %s", str);
break;
default:
break;
}
} else {
printf("[PHY_LIB]: %s\n", str);
switch (log_level) {
case LOG_LEVEL_INFO_S:
logger_phy_lib.info(" %s", str);
break;
case LOG_LEVEL_DEBUG_S:
logger_phy_lib.debug(" %s", str);
break;
case LOG_LEVEL_ERROR_S:
logger_phy_lib.error(" %s", str);
break;
default:
break;
}
}
@ -123,21 +119,16 @@ int phy::init(const phy_args_t& args_)
}
// 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);
auto lib_log_level = srslog::str_to_basic_level(args.log.phy_lib_level);
logger_phy_lib.set_level(lib_log_level);
logger_phy_lib.set_hex_dump_max_size(args.log.phy_hex_limit);
if (lib_log_level != srslog::basic_levels::none) {
srslte_phy_log_register_handler(this, srslte_phy_handler);
}
// set default logger
{
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);
}
logger_phy.set_level(srslog::str_to_basic_level(args.log.phy_level));
logger_phy.set_hex_dump_max_size(args.log.phy_hex_limit);
if (!check_args(args)) {
return false;
@ -152,24 +143,16 @@ int phy::init(const phy_args_t& args_)
void phy::run_thread()
{
std::unique_lock<std::mutex> lock(config_mutex);
prach_buffer.init(SRSLTE_MAX_PRB, log_h.get());
common.init(&args, log_h.get(), radio, stack, &sfsync);
prach_buffer.init(SRSLTE_MAX_PRB);
common.init(&args, radio, stack, &sfsync);
// Initialise workers
lte_workers.init(&common, logger, WORKERS_THREAD_PRIO);
lte_workers.init(&common, log_sink, WORKERS_THREAD_PRIO);
nr_workers.init(&common, logger, WORKERS_THREAD_PRIO);
// Warning this must be initialized after all workers have been added to the pool
sfsync.init(radio,
stack,
&prach_buffer,
&lte_workers,
&nr_workers,
&common,
log_h.get(),
log_phy_lib_h.get(),
SF_RECV_THREAD_PRIO,
args.sync_cpu_affinity);
sfsync.init(
radio, stack, &prach_buffer, &lte_workers, &nr_workers, &common, SF_RECV_THREAD_PRIO, args.sync_cpu_affinity);
// Disable UL signal pregeneration until the attachment
enable_pregen_signals(false);
@ -250,12 +233,12 @@ void phy::set_activation_deactivation_scell(uint32_t cmd, uint32_t tti)
void phy::configure_prach_params()
{
Debug("Configuring PRACH parameters\n");
Debug("Configuring PRACH parameters");
prach_cfg.tdd_config = tdd_config;
if (!prach_buffer.set_cell(selected_cell, prach_cfg)) {
Error("Configuring PRACH parameters\n");
Error("Configuring PRACH parameters");
}
}
@ -325,7 +308,7 @@ bool phy::cell_select(phy_cell_t cell)
});
return true;
} else {
log_h->warning("Could not start Cell Selection procedure\n");
logger_phy.warning("Could not start Cell Selection procedure");
return false;
}
}
@ -344,7 +327,7 @@ bool phy::cell_search()
stack->cell_search_complete(ret, found_cell);
});
} else {
log_h->warning("Could not start Cell Search procedure\n");
logger_phy.warning("Could not start Cell Search procedure");
}
return true;
}
@ -370,7 +353,7 @@ void phy::prach_send(uint32_t preamble_idx, int allowed_subframe, float target_p
common.ta.set_base_sec(ta_base_sec);
common.reset_radio();
if (!prach_buffer.prepare_to_send(preamble_idx, allowed_subframe, target_power_dbm)) {
Error("Preparing PRACH to send\n");
Error("Preparing PRACH to send");
}
}
@ -388,12 +371,12 @@ void phy::radio_overflow()
void phy::radio_failure()
{
// TODO: handle failure
Error("Radio failure.\n");
Error("Radio failure.");
}
void phy::reset()
{
Info("Resetting PHY...\n");
Info("Resetting PHY...");
common.ta.set_base_sec(0);
common.reset();
}
@ -407,7 +390,7 @@ void phy::sr_send()
{
common.sr_enabled = true;
common.sr_last_tx_tti = -1;
Debug("sr_send(): sr_enabled=%d, last_tx_tti=%d\n", common.sr_enabled, common.sr_last_tx_tti);
Debug("sr_send(): sr_enabled=%d, last_tx_tti=%d", common.sr_enabled, common.sr_last_tx_tti);
}
int phy::sr_last_tx_tti()
@ -424,7 +407,7 @@ void phy::set_crnti(uint16_t rnti)
{
// set_crnti() is an operation that takes time, run in background worker
cmd_worker.add_cmd([this, rnti]() {
log_h->info("Configuring sequences for C-RNTI=0x%x...\n", rnti);
logger_phy.info("Configuring sequences for C-RNTI=0x%x...", rnti);
for (uint32_t i = 0; i < args.nof_phy_threads; i++) {
// set_crnti is not protected so run when worker is finished
lte::sf_worker* w = lte_workers.wait_worker_id(i);
@ -433,7 +416,7 @@ void phy::set_crnti(uint16_t rnti)
w->release();
}
}
log_h->info("Finished configuring sequences for C-RNTI=0x%x.\n", rnti);
logger_phy.info("Finished configuring sequences for C-RNTI=0x%x.", rnti);
});
}
@ -467,7 +450,7 @@ bool phy::set_config(srslte::phy_cfg_t config_, uint32_t cc_idx)
return false;
}
Info("Setting configuration\n");
Info("Setting configuration");
// The PRACH configuration shall be updated only if:
// - The new configuration belongs to the primary cell
@ -478,7 +461,7 @@ bool phy::set_config(srslte::phy_cfg_t config_, uint32_t cc_idx)
// Apply configuration after the worker is finished to avoid race conditions
cmd_worker.add_cmd([this, config_, cc_idx]() {
log_h->info("Setting new PHY configuration cc_idx=%d...\n", cc_idx);
logger_phy.info("Setting new PHY configuration cc_idx=%d...", cc_idx);
for (uint32_t i = 0; i < args.nof_phy_threads; i++) {
// set_cell is not protected so run when worker is finished
lte::sf_worker* w = lte_workers.wait_worker_id(i);
@ -487,11 +470,10 @@ bool phy::set_config(srslte::phy_cfg_t config_, uint32_t cc_idx)
w->release();
}
}
log_h->info("Finished setting new PHY configuration cc_idx=%d\n", cc_idx);
logger_phy.info("Finished setting new PHY configuration cc_idx=%d", cc_idx);
// It is up to the PRACH component to detect whether the cell or the configuration have changed to reconfigure
configure_prach_params();
stack->set_config_complete(true);
});
return true;
@ -505,7 +487,7 @@ bool phy::set_scell(srslte_cell_t cell_info, uint32_t cc_idx, uint32_t earfcn)
}
if (cc_idx == 0) {
log_h->error("Received SCell configuration for invalid cc_idx=0\n");
logger_phy.error("Received SCell configuration for invalid cc_idx=0");
return false;
}
@ -518,7 +500,7 @@ bool phy::set_scell(srslte_cell_t cell_info, uint32_t cc_idx, uint32_t earfcn)
// First of all check validity of parameters
if (!srslte_cell_isvalid(&cell_info)) {
log_h->error("Received SCell configuration for an invalid cell\n");
logger_phy.error("Received SCell configuration for an invalid cell");
return false;
}
@ -538,7 +520,7 @@ bool phy::set_scell(srslte_cell_t cell_info, uint32_t cc_idx, uint32_t earfcn)
// Component carrier index zero should be reserved for PCell
// Send configuration to workers
cmd_worker.add_cmd([this, cell_info, cc_idx, earfcn, earfcn_is_different]() {
log_h->info("Setting new SCell configuration cc_idx=%d, earfcn=%d...\n", cc_idx, earfcn);
logger_phy.info("Setting new SCell configuration cc_idx=%d, earfcn=%d...", cc_idx, earfcn);
for (uint32_t i = 0; i < args.nof_phy_threads; i++) {
// set_cell is not protected so run when worker is finished
lte::sf_worker* w = lte_workers.wait_worker_id(i);
@ -559,7 +541,7 @@ bool phy::set_scell(srslte_cell_t cell_info, uint32_t cc_idx, uint32_t earfcn)
// Set secondary serving cell synchronization
sfsync.scell_sync_set(cc_idx, cell_info);
log_h->info("Finished setting new SCell configuration cc_idx=%d, earfcn=%d\n", cc_idx, earfcn);
logger_phy.info("Finished setting new SCell configuration cc_idx=%d, earfcn=%d", cc_idx, earfcn);
stack->set_scell_complete(true);
});
@ -591,7 +573,7 @@ void phy::set_config_tdd(srslte_tdd_config_t& tdd_config_)
void phy::set_config_mbsfn_sib2(srslte::mbsfn_sf_cfg_t* cfg_list, uint32_t nof_cfgs)
{
if (nof_cfgs > 1) {
Warning("SIB2 has %d MBSFN subframe configs - only 1 supported\n", nof_cfgs);
Warning("SIB2 has %d MBSFN subframe configs - only 1 supported", nof_cfgs);
}
if (nof_cfgs > 0) {
common.mbsfn_config.mbsfn_subfr_cnfg = cfg_list[0];
@ -603,7 +585,7 @@ void phy::set_config_mbsfn_sib13(const srslte::sib13_t& sib13)
{
common.mbsfn_config.mbsfn_notification_cnfg = sib13.notif_cfg;
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);
}
if (sib13.nof_mbsfn_area_info > 0) {
common.mbsfn_config.mbsfn_area_info = sib13.mbsfn_area_info_list[0];

@ -18,22 +18,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__)
namespace srsue {
static srslte::rf_buffer_t zeros_multi(1);
phy_common::phy_common()
phy_common::phy_common(srslog::basic_logger& logger) : logger(logger), ta(logger)
{
reset();
}
@ -41,20 +41,16 @@ phy_common::phy_common()
phy_common::~phy_common() = default;
void phy_common::init(phy_args_t* _args,
srslte::log* _log,
srslte::radio_interface_phy* _radio,
stack_interface_phy_lte* _stack,
rsrp_insync_itf* _chest_loop)
{
log_h = _log;
radio_h = _radio;
stack = _stack;
args = _args;
insync_itf = _chest_loop;
sr_last_tx_tti = -1;
ta.set_logger(_log);
// Instantiate UL channel emulator
if (args->ul_channel_args.enable) {
ul_channel =
@ -133,7 +129,7 @@ void phy_common::set_rar_grant(uint8_t grant_payload[SRSLTE_RAR_GRAN
#endif /* MSG3_DELAY_MS < 0 */
if (rar_grant_tti < 0) {
Error("Must call set_rar_grant_tti before set_rar_grant\n");
Error("Must call set_rar_grant_tti before set_rar_grant");
}
srslte_dci_ul_t dci_ul;
@ -141,7 +137,7 @@ void phy_common::set_rar_grant(uint8_t grant_payload[SRSLTE_RAR_GRAN
srslte_dci_rar_unpack(grant_payload, &rar_grant);
if (srslte_dci_rar_to_ul_dci(&cell, &rar_grant, &dci_ul)) {
Error("Converting RAR message to UL dci\n");
Error("Converting RAR message to UL dci");
return;
}
@ -165,12 +161,12 @@ void phy_common::set_rar_grant(uint8_t grant_payload[SRSLTE_RAR_GRAN
std::lock_guard<std::mutex> lock(pending_ul_grant_mutex);
pending_ul_grant_t& pending_grant = pending_ul_grant[0][msg3_tx_tti];
if (!pending_grant.enable) {
Debug("RAR grant rar_grant=%d, msg3_tti=%d, stored in index=%d\n", rar_grant_tti, msg3_tx_tti, TTIMOD(msg3_tx_tti));
Debug("RAR grant rar_grant=%d, msg3_tti=%d, stored in index=%d", rar_grant_tti, msg3_tx_tti, TTIMOD(msg3_tx_tti));
pending_grant.pid = ul_pidof(msg3_tx_tti, &tdd_config);
pending_grant.dci = dci_ul;
pending_grant.enable = true;
} else {
Warning("set_rar_grant: sf->tti=%d, cc=%d already in use\n", msg3_tx_tti, 0);
Warning("set_rar_grant: sf->tti=%d, cc=%d already in use", msg3_tx_tti, 0);
}
rar_grant_tti = -1;
@ -237,7 +233,7 @@ uint32_t phy_common::ul_pidof(uint32_t tti, srslte_tdd_config_t* tdd_config)
return (cycle_idx + sf_idx - 4) % 6;
}
default:
Error("Invalid SF configuration %d\n", tdd_config->sf_config);
Error("Invalid SF configuration %d", tdd_config->sf_config);
}
} else {
return tti % SRSLTE_FDD_NOF_HARQ;
@ -264,13 +260,13 @@ void phy_common::set_ul_pending_ack(srslte_ul_sf_cfg_t* sf,
pending_ack.dci_ul = *dci_ul;
pending_ack.phich_grant = phich_grant;
pending_ack.enable = true;
Debug("Set pending ACK for sf->tti=%d n_dmrs=%d, I_phich=%d, cc_idx=%d\n",
Debug("Set pending ACK for sf->tti=%d n_dmrs=%d, I_phich=%d, cc_idx=%d",
sf->tti,
phich_grant.n_dmrs,
phich_grant.I_phich,
cc_idx);
} else {
Warning("set_ul_pending_ack: sf->tti=%d, cc=%d already in use\n", sf->tti, cc_idx);
Warning("set_ul_pending_ack: sf->tti=%d, cc=%d already in use", sf->tti, cc_idx);
}
}
@ -288,7 +284,7 @@ bool phy_common::get_ul_pending_ack(srslte_dl_sf_cfg_t* sf,
*dci_ul = pending_ack.dci_ul;
ret = true;
pending_ack.enable = false;
Debug("Get pending ACK for sf->tti=%d n_dmrs=%d, I_phich=%d\n", sf->tti, phich_grant->n_dmrs, phich_grant->I_phich);
Debug("Get pending ACK for sf->tti=%d n_dmrs=%d, I_phich=%d", sf->tti, phich_grant->n_dmrs, phich_grant->I_phich);
}
return ret;
}
@ -333,9 +329,9 @@ void phy_common::set_ul_pending_grant(srslte_dl_sf_cfg_t* sf, uint32_t cc_idx, s
pending_grant.pid = pid;
pending_grant.dci = *dci;
pending_grant.enable = true;
Debug("Set ul pending grant for sf->tti=%d current_tti=%d, pid=%d\n", tti_pusch_gr(sf), sf->tti, pid);
Debug("Set ul pending grant for sf->tti=%d current_tti=%d, pid=%d", tti_pusch_gr(sf), sf->tti, pid);
} else {
Warning("set_ul_pending_grant: sf->tti=%d, cc=%d already in use\n", sf->tti, cc_idx);
Warning("set_ul_pending_grant: sf->tti=%d, cc=%d already in use", sf->tti, cc_idx);
}
}
@ -347,7 +343,7 @@ bool phy_common::get_ul_pending_grant(srslte_ul_sf_cfg_t* sf, uint32_t cc_idx, u
pending_ul_grant_t& pending_grant = pending_ul_grant[cc_idx][sf->tti];
if (pending_grant.enable) {
Debug("Reading grant sf->tti=%d idx=%d\n", sf->tti, TTIMOD(sf->tti));
Debug("Reading grant sf->tti=%d idx=%d", sf->tti, TTIMOD(sf->tti));
if (pid) {
*pid = pending_grant.pid;
}
@ -386,7 +382,7 @@ void phy_common::set_ul_received_ack(srslte_dl_sf_cfg_t* sf,
received_ack.hi_present = true;
received_ack.hi_value = ack_value;
received_ack.dci_ul = *dci_ul;
Debug("Set ul received ack for sf->tti=%d, current_tti=%d\n", tti_pusch_hi(sf), sf->tti);
Debug("Set ul received ack for sf->tti=%d, current_tti=%d", tti_pusch_hi(sf), sf->tti);
}
// SF->TTI at which PUSCH will be transmitted
@ -403,7 +399,7 @@ bool phy_common::get_ul_received_ack(srslte_ul_sf_cfg_t* sf, uint32_t cc_idx, bo
if (dci_ul) {
*dci_ul = received_ack.dci_ul;
}
Debug("Get ul received ack for current_tti=%d\n", sf->tti);
Debug("Get ul received ack for current_tti=%d", sf->tti);
received_ack.hi_present = false;
ret = true;
}
@ -424,9 +420,9 @@ void phy_common::set_dl_pending_ack(srslte_dl_sf_cfg_t* sf,
pending_ack.enable = true;
pending_ack.resource = resource;
memcpy(pending_ack.value, value, SRSLTE_MAX_CODEWORDS * sizeof(uint8_t));
Debug("Set dl pending ack for sf->tti=%d, value=%d, ncce=%d\n", sf->tti, value[0], resource.n_cce);
Debug("Set dl pending ack for sf->tti=%d, value=%d, ncce=%d", sf->tti, value[0], resource.n_cce);
} else {
Warning("pending_dl_ack: sf->tti=%d, cc=%d already in use\n", sf->tti, cc_idx);
Warning("pending_dl_ack: sf->tti=%d, cc=%d already in use", sf->tti, cc_idx);
}
}
@ -446,7 +442,7 @@ void phy_common::set_dl_pending_grant(uint32_t tti,
pending_dl_grant[tti % FDD_HARQ_DELAY_UL_MS][cc_idx].grant_cc_idx = grant_cc_idx;
pending_dl_grant[tti % FDD_HARQ_DELAY_UL_MS][cc_idx].enable = true;
} else {
Warning("set_dl_pending_grant: cc=%d already exists\n", cc_idx);
Warning("set_dl_pending_grant: cc=%d already exists", cc_idx);
}
}
@ -515,7 +511,7 @@ bool phy_common::get_dl_pending_ack(srslte_ul_sf_cfg_t* sf, uint32_t cc_idx, srs
ack->m[i].k = k;
ack->m[i].resource = pending_ack.resource;
memcpy(ack->m[i].value, pending_ack.value, SRSLTE_MAX_CODEWORDS * sizeof(uint8_t));
Debug("Get dl pending ack for sf->tti=%d, i=%d, k=%d, pdsch_tti=%d, value=%d, ncce=%d, v_dai=%d\n",
Debug("Get dl pending ack for sf->tti=%d, i=%d, k=%d, pdsch_tti=%d, value=%d, ncce=%d, v_dai=%d",
sf->tti,
i,
k,
@ -732,9 +728,9 @@ void phy_common::update_measurements(uint32_t cc_idx,
bool active = cell_state.is_configured(cc_idx);
if (active && ((sf_cfg_dl.tti % pcell_report_period) == pcell_report_period - 1)) {
phy_meas_t meas = {};
meas.rsrp = avg_rsrp_dbm[cc_idx];
meas.rsrq = avg_rsrq_db[cc_idx];
meas.cfo_hz = avg_cfo_hz[cc_idx];
meas.rsrp = avg_rsrp_dbm[cc_idx];
meas.rsrq = avg_rsrq_db[cc_idx];
meas.cfo_hz = avg_cfo_hz[cc_idx];
// Save PCI and EARFCN (if available)
if (cc_idx == 0) {
@ -749,11 +745,10 @@ void phy_common::update_measurements(uint32_t cc_idx,
// Check in-sync / out-sync conditions. Use SNR instead of SINR for RLF threshold
if (cc_idx == 0) {
if (avg_rsrp_dbm[0] > args->in_sync_rsrp_dbm_th && avg_snr_db[0] > args->in_sync_snr_db_th) {
log_h->debug(
"SNR=%.1f dB, RSRP=%.1f dBm sync=in-sync from channel estimator\n", avg_snr_db[0], avg_rsrp_dbm[0]);
logger.debug("SNR=%.1f dB, RSRP=%.1f dBm sync=in-sync from channel estimator", avg_snr_db[0], avg_rsrp_dbm[0]);
} else {
log_h->warning(
"SNR=%.1f dB RSRP=%.1f dBm, sync=out-of-sync from channel estimator\n", avg_snr_db[0], avg_rsrp_dbm[0]);
logger.warning(
"SNR=%.1f dB RSRP=%.1f dBm, sync=out-of-sync from channel estimator", avg_snr_db[0], avg_rsrp_dbm[0]);
insync = false;
}
}
@ -942,7 +937,7 @@ void phy_common::build_mch_table()
} else if (mbsfn_config.mbsfn_subfr_cnfg.nof_alloc_subfrs == srslte::mbsfn_sf_cfg_t::sf_alloc_type_t::four_frames) {
generate_mch_table(&mch_table[0], (uint32_t)mbsfn_config.mbsfn_subfr_cnfg.sf_alloc, 4u);
} else {
log_h->error("The subframe config has not been set for MBSFN\n");
logger.error("The subframe config has not been set for MBSFN");
}
// Debug
@ -951,7 +946,7 @@ void phy_common::build_mch_table()
for (uint32_t j = 0; j < 40; j++) {
ss << (int)mch_table[j] << "|";
}
Info("MCH table: %s\n", ss.str().c_str());
Info("MCH table: %s", ss.str().c_str());
}
void phy_common::build_mcch_table()
@ -965,7 +960,7 @@ void phy_common::build_mcch_table()
for (uint32_t j = 0; j < 10; j++) {
ss << (int)mcch_table[j] << "|";
}
Info("MCCH table: %s\n", ss.str().c_str());
Info("MCCH table: %s", ss.str().c_str());
sib13_configured = true;
}
@ -1056,7 +1051,7 @@ bool phy_common::is_mch_subframe(srslte_mbsfn_cfg_t* cfg, uint32_t phy_tti)
// have_mtch_stop = false;
}
}
Debug("MCH subframe TTI:%d\n", phy_tti);
Debug("MCH subframe TTI:%d", phy_tti);
}
return true;
}
@ -1071,7 +1066,7 @@ bool phy_common::is_mch_subframe(srslte_mbsfn_cfg_t* cfg, uint32_t phy_tti)
}
}
} else {
log_h->error("The subframe allocation type is not yet configured\n");
logger.error("The subframe allocation type is not yet configured");
}
}
@ -1100,7 +1095,7 @@ bool phy_common::is_mcch_subframe(srslte_mbsfn_cfg_t* cfg, uint32_t phy_tti)
cfg->mbsfn_mcs = enum_to_number(area_info.mcch_cfg.sig_mcs);
cfg->enable = true;
have_mtch_stop = false;
Debug("MCCH subframe TTI:%d\n", phy_tti);
Debug("MCCH subframe TTI:%d", phy_tti);
return true;
}
}

@ -18,23 +18,21 @@
#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 srsue;
void prach::init(uint32_t max_prb, srslte::log* log_h_)
void prach::init(uint32_t max_prb)
{
log_h = log_h_;
for (auto& i : buffer) {
for (auto& j : i) {
j = srslte_vec_cf_malloc(SRSLTE_PRACH_MAX_LEN);
@ -46,7 +44,7 @@ void prach::init(uint32_t max_prb, srslte::log* log_h_)
}
if (srslte_cfo_init(&cfo_h, SRSLTE_PRACH_MAX_LEN)) {
ERROR("PRACH: Error initiating CFO\n");
ERROR("PRACH: Error initiating CFO");
return;
}
@ -59,7 +57,7 @@ void prach::init(uint32_t max_prb, srslte::log* log_h_)
}
if (srslte_prach_init(&prach_obj, srslte_symbol_sz(max_prb))) {
Error("Initiating PRACH library\n");
Error("Initiating PRACH library");
return;
}
@ -87,7 +85,7 @@ void prach::stop()
bool prach::set_cell(srslte_cell_t cell_, srslte_prach_cfg_t prach_cfg)
{
if (!mem_initiated) {
ERROR("PRACH: Error must call init() first\n");
ERROR("PRACH: Error must call init() first");
return false;
}
@ -101,11 +99,11 @@ bool prach::set_cell(srslte_cell_t cell_, srslte_prach_cfg_t prach_cfg)
if (6 + prach_cfg.freq_offset > cell.nof_prb) {
srslte::console("Error no space for PRACH: frequency offset=%d, N_rb_ul=%d\n", prach_cfg.freq_offset, cell.nof_prb);
log_h->error("Error no space for PRACH: frequency offset=%d, N_rb_ul=%d\n", prach_cfg.freq_offset, cell.nof_prb);
logger.error("Error no space for PRACH: frequency offset=%d, N_rb_ul=%d", prach_cfg.freq_offset, cell.nof_prb);
return false;
}
Info("PRACH: cell.id=%d, configIdx=%d, rootSequence=%d, zeroCorrelationConfig=%d, freqOffset=%d\n",
Info("PRACH: cell.id=%d, configIdx=%d, rootSequence=%d, zeroCorrelationConfig=%d, freqOffset=%d",
cell.id,
prach_cfg.config_idx,
prach_cfg.root_seq_idx,
@ -113,7 +111,7 @@ bool prach::set_cell(srslte_cell_t cell_, srslte_prach_cfg_t prach_cfg)
prach_cfg.freq_offset);
if (srslte_prach_set_cfg(&prach_obj, &prach_cfg, cell.nof_prb)) {
Error("Initiating PRACH library\n");
Error("Initiating PRACH library");
return false;
}
@ -122,7 +120,7 @@ bool prach::set_cell(srslte_cell_t cell_, srslte_prach_cfg_t prach_cfg)
transmitted_tti = -1;
cell_initiated = true;
log_h->info("Finished setting new PRACH configuration.\n");
logger.info("Finished setting new PRACH configuration.");
return true;
}
@ -139,7 +137,7 @@ bool prach::generate_buffer(uint32_t f_idx)
cfg.config_idx, cfg.tdd_config.sf_config, (f_idx / 6) * 10, f_idx % 6, cfg.freq_offset, cell.nof_prb);
}
if (srslte_prach_gen(&prach_obj, preamble_idx, freq_offset, buffer[f_idx][preamble_idx])) {
Error("Generating PRACH preamble %d\n", preamble_idx);
Error("Generating PRACH preamble %d", preamble_idx);
return false;
}
@ -151,7 +149,7 @@ bool prach::generate_buffer(uint32_t f_idx)
bool prach::prepare_to_send(uint32_t preamble_idx_, int allowed_subframe_, float target_power_dbm_)
{
if (preamble_idx_ >= max_preambles) {
Error("PRACH: Invalid preamble %d\n", preamble_idx_);
Error("PRACH: Invalid preamble %d", preamble_idx_);
return false;
}
@ -159,7 +157,7 @@ bool prach::prepare_to_send(uint32_t preamble_idx_, int allowed_subframe_, float
target_power_dbm = target_power_dbm_;
allowed_subframe = allowed_subframe_;
transmitted_tti = -1;
Debug("PRACH: prepare to send preamble %d\n", preamble_idx);
Debug("PRACH: prepare to send preamble %d", preamble_idx);
return true;
}
@ -175,7 +173,7 @@ bool prach::is_ready_to_send(uint32_t current_tti_, uint32_t current_pci)
// consider the number of subframes the transmission must be anticipated
uint32_t tti_tx = TTI_TX(current_tti_);
if (srslte_prach_tti_opportunity(&prach_obj, tti_tx, allowed_subframe)) {
Debug("PRACH Buffer: Ready to send at tti: %d (now is %d)\n", tti_tx, current_tti_);
Debug("PRACH Buffer: Ready to send at tti: %d (now is %d)", tti_tx, current_tti_);
transmitted_tti = tti_tx;
return true;
}
@ -205,7 +203,7 @@ cf_t* prach::generate(float cfo, uint32_t* nof_sf, float* target_power)
{
if (!cell_initiated || preamble_idx < 0 || !nof_sf || unsigned(preamble_idx) >= max_preambles ||
!srslte_cell_isvalid(&cell) || len >= MAX_LEN_SF * 30720 || len == 0) {
Error("PRACH: Invalid parameters: cell_initiated=%d, preamble_idx=%d, cell.nof_prb=%d, len=%d\n",
Error("PRACH: Invalid parameters: cell_initiated=%d, preamble_idx=%d, cell.nof_prb=%d, len=%d",
cell_initiated,
preamble_idx,
cell.nof_prb,
@ -221,7 +219,7 @@ cf_t* prach::generate(float cfo, uint32_t* nof_sf, float* target_power)
f_idx += 6;
}
if (f_idx >= max_fs) {
Error("PRACH Buffer: Invalid f_idx=%d\n", f_idx);
Error("PRACH Buffer: Invalid f_idx=%d", f_idx);
f_idx = 0;
}
}
@ -231,7 +229,7 @@ cf_t* prach::generate(float cfo, uint32_t* nof_sf, float* target_power)
}
if (!is_buffer_generated(f_idx, preamble_idx)) {
Error("PRACH Buffer not generated: f_idx=%d preamble_idx=%d\n", f_idx, preamble_idx);
Error("PRACH Buffer not generated: f_idx=%d preamble_idx=%d", f_idx, preamble_idx);
return nullptr;
}
@ -248,7 +246,7 @@ cf_t* prach::generate(float cfo, uint32_t* nof_sf, float* target_power)
*target_power = target_power_dbm;
}
Info("PRACH: Transmitted preamble=%d, tti_tx=%d, CFO=%.2f KHz, nof_sf=%d, target_power=%.1f dBm\n",
Info("PRACH: Transmitted preamble=%d, tti_tx=%d, CFO=%.2f KHz, nof_sf=%d, target_power=%.1f dBm",
preamble_idx,
transmitted_tti,
cfo * 15,

@ -12,22 +12,23 @@
#include "srsue/hdr/phy/scell/intra_measure.h"
#define Error(fmt, ...) \
if (SRSLTE_DEBUG_ENABLED and log_h != nullptr) \
log_h->error(fmt, ##__VA_ARGS__)
if (SRSLTE_DEBUG_ENABLED) \
logger.error(fmt, ##__VA_ARGS__)
#define Warning(fmt, ...) \
if (SRSLTE_DEBUG_ENABLED and log_h != nullptr) \
log_h->warning(fmt, ##__VA_ARGS__)
if (SRSLTE_DEBUG_ENABLED) \
logger.warning(fmt, ##__VA_ARGS__)
#define Info(fmt, ...) \
if (SRSLTE_DEBUG_ENABLED and log_h != nullptr) \
log_h->info(fmt, ##__VA_ARGS__)
if (SRSLTE_DEBUG_ENABLED) \
logger.info(fmt, ##__VA_ARGS__)
#define Debug(fmt, ...) \
if (SRSLTE_DEBUG_ENABLED and log_h != nullptr) \
log_h->debug(fmt, ##__VA_ARGS__)
if (SRSLTE_DEBUG_ENABLED) \
logger.debug(fmt, ##__VA_ARGS__)
namespace srsue {
namespace scell {
intra_measure::intra_measure() : scell(), thread("SYNC_INTRA_MEASURE") {}
intra_measure::intra_measure(srslog::basic_logger& logger) : scell(logger), logger(logger), thread("SYNC_INTRA_MEASURE")
{}
intra_measure::~intra_measure()
{
@ -36,11 +37,10 @@ intra_measure::~intra_measure()
free(search_buffer);
}
void intra_measure::init(uint32_t cc_idx_, phy_common* common, meas_itf* new_cell_itf_, srslte::log* log_h_)
void intra_measure::init(uint32_t cc_idx_, phy_common* common, meas_itf* new_cell_itf_)
{
cc_idx = cc_idx_;
new_cell_itf = new_cell_itf_;
log_h = log_h_;
if (common) {
intra_freq_meas_len_ms = common->args->intra_freq_meas_len_ms;
@ -52,7 +52,7 @@ void intra_measure::init(uint32_t cc_idx_, phy_common* common, meas_itf* new_cel
srslte_refsignal_dl_sync_init(&refsignal_dl_sync);
// Start scell
scell.init(log_h, intra_freq_meas_len_ms);
scell.init(intra_freq_meas_len_ms);
search_buffer = srslte_vec_cf_malloc(intra_freq_meas_len_ms * SRSLTE_SF_LEN_PRB(SRSLTE_MAX_PRB));
@ -96,7 +96,7 @@ void intra_measure::meas_stop()
// Transition state to idle
// Ring-buffer shall not be reset, it will automatically be reset as soon as the FSM transitions to receive
state.set_state(internal_state::idle);
Info("INTRA: Disabled neighbour cell search for EARFCN %d\n", get_earfcn());
Info("INTRA: Disabled neighbour cell search for EARFCN %d", get_earfcn());
}
void intra_measure::set_cells_to_meas(const std::set<uint32_t>& pci)
@ -105,7 +105,7 @@ void intra_measure::set_cells_to_meas(const std::set<uint32_t>& pci)
active_pci = pci;
active_pci_mutex.unlock();
state.set_state(internal_state::receive);
log_h->info("INTRA: Received list of %zd neighbour cells to measure in EARFCN %d.\n", pci.size(), current_earfcn);
logger.info("INTRA: Received list of %zd neighbour cells to measure in EARFCN %d.", pci.size(), current_earfcn);
}
void intra_measure::write(uint32_t tti, cf_t* data, uint32_t nsamples)
@ -134,7 +134,7 @@ void intra_measure::write(uint32_t tti, cf_t* data, uint32_t nsamples)
// Try writing in the buffer
if (srslte_ringbuffer_write(&ring_buffer, data, nbytes) < nbytes) {
Warning("INTRA: Error writing to ringbuffer (EARFCN=%d)\n", current_earfcn);
Warning("INTRA: Error writing to ringbuffer (EARFCN=%d)", current_earfcn);
// Transition to wait, so it can keep receiving without stopping the component operation
state.set_state(internal_state::wait);
@ -201,7 +201,7 @@ void intra_measure::measure_proc()
neighbour_cells.push_back(m);
Info("INTRA: Found neighbour cell: EARFCN=%d, PCI=%03d, RSRP=%5.1f dBm, RSRQ=%5.1f, peak_idx=%5d, "
"CFO=%+.1fHz\n",
"CFO=%+.1fHz",
m.earfcn,
m.pci,
m.rsrp,

@ -19,10 +19,8 @@ namespace scell {
* Secondary cell receiver
*/
void scell_recv::init(srslte::log* _log_h, uint32_t max_sf_window)
void scell_recv::init(uint32_t max_sf_window)
{
log_h = _log_h;
// and a separate ue_sync instance
uint32_t max_fft_sz = (uint32_t)srslte_symbol_sz(100);
@ -30,13 +28,13 @@ void scell_recv::init(srslte::log* _log_h, uint32_t max_sf_window)
sf_buffer[0] = srslte_vec_cf_malloc(max_sf_size);
if (!sf_buffer[0]) {
log_h->error("Error allocating %d samples for scell\n", max_sf_size);
logger.error("Error allocating %d samples for scell", max_sf_size);
return;
}
// do this different we don't need all this search window.
if (srslte_sync_init(&sync_find, max_sf_window * max_sf_size, 5 * max_sf_size, max_fft_sz)) {
log_h->error("Error initiating sync_find\n");
logger.error("Error initiating sync_find");
return;
}
srslte_sync_set_sss_algorithm(&sync_find, SSS_FULL);
@ -80,14 +78,14 @@ scell_recv::find_cells(const cf_t* input_buffer, const srslte_cell_t serving_cel
if (fft_sz != current_fft_sz) {
if (srslte_sync_resize(&sync_find, nof_sf * sf_len, 5 * sf_len, fft_sz)) {
log_h->error("Error resizing sync nof_sf=%d, sf_len=%d, fft_sz=%d\n", nof_sf, sf_len, fft_sz);
logger.error("Error resizing sync nof_sf=%d, sf_len=%d, fft_sz=%d", nof_sf, sf_len, fft_sz);
return found_cell_ids;
}
current_fft_sz = fft_sz;
}
uint32_t peak_idx = 0;
int cell_id = 0;
uint32_t peak_idx = 0;
int cell_id = 0;
for (uint32_t n_id_2 = 0; n_id_2 < 3; n_id_2++) {
@ -109,7 +107,7 @@ scell_recv::find_cells(const cf_t* input_buffer, const srslte_cell_t serving_cel
for (uint32_t sf5_cnt = 0; sf5_cnt < nof_sf / 5; sf5_cnt++) {
sync_res = srslte_sync_find(&sync_find, input_buffer, sf5_cnt * 5 * sf_len, &peak_idx);
if (sync_res == SRSLTE_SYNC_ERROR) {
log_h->error("INTRA: Error calling sync_find()\n");
logger.error("INTRA: Error calling sync_find()");
return found_cell_ids;
}
@ -126,8 +124,8 @@ scell_recv::find_cells(const cf_t* input_buffer, const srslte_cell_t serving_cel
sss_detected = true;
}
log_h->debug("INTRA: n_id_2=%d, cnt=%d/%d, sync_res=%d, cell_id=%d, sf_idx=%d, peak_idx=%d, peak_value=%f, "
"sss_detected=%d\n",
logger.debug("INTRA: n_id_2=%d, cnt=%d/%d, sync_res=%d, cell_id=%d, sf_idx=%d, peak_idx=%d, peak_value=%f, "
"sss_detected=%d",
n_id_2,
sf5_cnt,
nof_sf / 5,
@ -143,7 +141,7 @@ scell_recv::find_cells(const cf_t* input_buffer, const srslte_cell_t serving_cel
if (sync_res == SRSLTE_SYNC_FOUND && sss_detected && cell_id >= 0) {
// We have found a new cell, add to the list
found_cell_ids.insert((uint32_t)cell_id);
log_h->debug("INTRA: Detected new cell_id=%d using PSS/SSS\n", cell_id);
logger.debug("INTRA: Detected new cell_id=%d using PSS/SSS", cell_id);
}
}
}

@ -14,16 +14,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__)
namespace srsue {
@ -45,20 +45,19 @@ search::~search()
srslte_ue_cellsearch_free(&cs);
}
void search::init(srslte::rf_buffer_t& buffer_, srslte::log* log_h_, uint32_t nof_rx_channels, search_callback* parent)
void search::init(srslte::rf_buffer_t& buffer_, uint32_t nof_rx_channels, search_callback* parent)
{
log_h = log_h_;
p = parent;
p = parent;
buffer = buffer_;
if (srslte_ue_cellsearch_init_multi(&cs, 8, radio_recv_callback, nof_rx_channels, parent)) {
Error("SYNC: Initiating UE cell search\n");
Error("SYNC: Initiating UE cell search");
}
srslte_ue_cellsearch_set_nof_valid_frames(&cs, 4);
if (srslte_ue_mib_sync_init_multi(&ue_mib_sync, radio_recv_callback, nof_rx_channels, parent)) {
Error("SYNC: Initiating UE MIB synchronization\n");
Error("SYNC: Initiating UE MIB synchronization");
}
// Set options defined in expert section
@ -87,7 +86,7 @@ void search::set_agc_enable(bool enable)
rf_info->max_rx_gain,
p->get_radio()->get_rx_gain());
} else {
ERROR("Error stop AGC not implemented\n");
ERROR("Error stop AGC not implemented");
}
}
@ -103,7 +102,7 @@ search::ret_code search::run(srslte_cell_t* cell_, std::array<uint8_t, SRSLTE_BC
uint32_t max_peak_cell = 0;
int ret = SRSLTE_ERROR;
Info("SYNC: Searching for cell...\n");
Info("SYNC: Searching for cell...");
srslte::console(".");
if (force_N_id_2 >= 0 && force_N_id_2 < 3) {
@ -114,10 +113,10 @@ search::ret_code search::run(srslte_cell_t* cell_, std::array<uint8_t, SRSLTE_BC
}
if (ret < 0) {
Error("SYNC: Error decoding MIB: Error searching PSS\n");
Error("SYNC: Error decoding MIB: Error searching PSS");
return ERROR;
} else if (ret == 0) {
Info("SYNC: Could not find any cell in this frequency\n");
Info("SYNC: Could not find any cell in this frequency");
return CELL_NOT_FOUND;
}
// Save result
@ -127,14 +126,14 @@ search::ret_code search::run(srslte_cell_t* cell_, std::array<uint8_t, SRSLTE_BC
float cfo = found_cells[max_peak_cell].cfo;
srslte::console("\n");
Info("SYNC: PSS/SSS detected: Mode=%s, PCI=%d, CFO=%.1f KHz, CP=%s\n",
Info("SYNC: PSS/SSS detected: Mode=%s, PCI=%d, CFO=%.1f KHz, CP=%s",
new_cell.frame_type ? "TDD" : "FDD",
new_cell.id,
cfo / 1000,
srslte_cp_string(new_cell.cp));
if (srslte_ue_mib_sync_set_cell(&ue_mib_sync, new_cell)) {
Error("SYNC: Setting UE MIB cell\n");
Error("SYNC: Setting UE MIB cell");
return ERROR;
}
@ -161,7 +160,7 @@ search::ret_code search::run(srslte_cell_t* cell_, std::array<uint8_t, SRSLTE_BC
new_cell.nof_ports,
cfo / 1000);
Info("SYNC: MIB Decoded: Mode=%s, PCI=%d, PRB=%d, Ports=%d, CFO=%.1f KHz\n",
Info("SYNC: MIB Decoded: Mode=%s, PCI=%d, PRB=%d, Ports=%d, CFO=%.1f KHz",
new_cell.frame_type ? "TDD" : "FDD",
new_cell.id,
new_cell.nof_prb,
@ -169,7 +168,7 @@ search::ret_code search::run(srslte_cell_t* cell_, std::array<uint8_t, SRSLTE_BC
cfo / 1000);
if (!srslte_cell_isvalid(&new_cell)) {
Error("SYNC: Detected invalid cell.\n");
Error("SYNC: Detected invalid cell.");
return CELL_NOT_FOUND;
}
@ -180,10 +179,10 @@ search::ret_code search::run(srslte_cell_t* cell_, std::array<uint8_t, SRSLTE_BC
return CELL_FOUND;
} else if (ret == 0) {
Warning("SYNC: Found PSS but could not decode PBCH\n");
Warning("SYNC: Found PSS but could not decode PBCH");
return CELL_NOT_FOUND;
} else {
Error("SYNC: Receiving MIB\n");
Error("SYNC: Receiving MIB");
return ERROR;
}
}

@ -14,16 +14,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__)
namespace srsue {
@ -36,10 +36,8 @@ void sfn_sync::init(srslte_ue_sync_t* ue_sync_,
const phy_args_t* phy_args_,
srslte::rf_buffer_t& buffer,
uint32_t buffer_max_samples_,
srslte::log* log_h_,
uint32_t nof_subframes)
{
log_h = log_h_;
ue_sync = ue_sync_;
phy_args = phy_args_;
timeout = nof_subframes;
@ -49,14 +47,14 @@ void sfn_sync::init(srslte_ue_sync_t* ue_sync_,
// MIB decoder uses a single receiver antenna in logical channel 0
if (srslte_ue_mib_init(&ue_mib, buffer.get(0), SRSLTE_MAX_PRB)) {
Error("SYNC: Initiating UE MIB decoder\n");
Error("SYNC: Initiating UE MIB decoder");
}
}
bool sfn_sync::set_cell(srslte_cell_t cell_)
{
if (srslte_ue_mib_set_cell(&ue_mib, cell_)) {
Error("SYNC: Setting cell: initiating ue_mib\n");
Error("SYNC: Setting cell: initiating ue_mib");
return false;
}
reset();
@ -76,7 +74,7 @@ sfn_sync::ret_code sfn_sync::run_subframe(srslte_cell_t*
{
int ret = srslte_ue_sync_zerocopy(ue_sync, mib_buffer.to_cf_t(), buffer_max_samples);
if (ret < 0) {
Error("SYNC: Error calling ue_sync_get_buffer.\n");
Error("SYNC: Error calling ue_sync_get_buffer.");
return ERROR;
}
@ -86,7 +84,7 @@ sfn_sync::ret_code sfn_sync::run_subframe(srslte_cell_t*
return ret2;
}
} else {
Info("SYNC: Waiting for PSS while trying to decode MIB (%d/%d)\n", cnt, timeout);
Info("SYNC: Waiting for PSS while trying to decode MIB (%d/%d)", cnt, timeout);
}
cnt++;
@ -135,19 +133,19 @@ sfn_sync::ret_code sfn_sync::decode_mib(srslte_cell_t*
// Check if SNR is below the minimum threshold
if (ue_mib.chest_res.snr_db < phy_args->in_sync_snr_db_th) {
Info("SYNC: MIB decoded, SNR is too low (%+.1f < %+.1f)\n",
Info("SYNC: MIB decoded, SNR is too low (%+.1f < %+.1f)",
ue_mib.chest_res.snr_db,
phy_args->in_sync_snr_db_th);
return SFN_NOFOUND;
}
Info("SYNC: DONE, SNR=%.1f dB, TTI=%d, sfn_offset=%d\n", ue_mib.chest_res.snr_db, *tti_cnt, sfn_offset);
Info("SYNC: DONE, SNR=%.1f dB, TTI=%d, sfn_offset=%d", ue_mib.chest_res.snr_db, *tti_cnt, sfn_offset);
}
reset();
return SFN_FOUND;
case SRSLTE_UE_MIB_NOTFOUND:
Info("SYNC: Found PSS but could not decode MIB. SNR=%.1f dB (%d/%d)\n", ue_mib.chest_res.snr_db, cnt, timeout);
Info("SYNC: Found PSS but could not decode MIB. SNR=%.1f dB (%d/%d)", ue_mib.chest_res.snr_db, cnt, timeout);
return SFN_NOFOUND;
}
}

@ -20,16 +20,16 @@
#define Error(fmt, ...) \
if (SRSLTE_DEBUG_ENABLED) \
log_h->error(fmt, ##__VA_ARGS__)
phy_logger.error(fmt, ##__VA_ARGS__)
#define Warning(fmt, ...) \
if (SRSLTE_DEBUG_ENABLED) \
log_h->warning(fmt, ##__VA_ARGS__)
phy_logger.warning(fmt, ##__VA_ARGS__)
#define Info(fmt, ...) \
if (SRSLTE_DEBUG_ENABLED) \
log_h->info(fmt, ##__VA_ARGS__)
phy_logger.info(fmt, ##__VA_ARGS__)
#define Debug(fmt, ...) \
if (SRSLTE_DEBUG_ENABLED) \
log_h->debug(fmt, ##__VA_ARGS__)
phy_logger.debug(fmt, ##__VA_ARGS__)
namespace srsue {
@ -51,14 +51,10 @@ void sync::init(srslte::radio_interface_phy* _radio,
lte::worker_pool* _lte_workers_pool,
nr::worker_pool* _nr_workers_pool,
phy_common* _worker_com,
srslte::log* _log_h,
srslte::log* _log_phy_lib_h,
uint32_t prio,
int sync_cpu_affinity)
{
radio_h = _radio;
log_h = _log_h;
log_phy_lib_h = _log_phy_lib_h;
stack = _stack;
lte_worker_pool = _lte_workers_pool;
nr_worker_pool = _nr_workers_pool;
@ -68,13 +64,13 @@ void sync::init(srslte::radio_interface_phy* _radio,
nof_rf_channels =
(worker_com->args->nof_lte_carriers + worker_com->args->nof_nr_carriers) * worker_com->args->nof_rx_ant;
if (nof_rf_channels == 0 || nof_rf_channels > SRSLTE_MAX_CHANNELS) {
Error("SYNC: Invalid number of RF channels (%d)\n", nof_rf_channels);
Error("SYNC: Invalid number of RF channels (%d)", nof_rf_channels);
return;
}
if (srslte_ue_sync_init_multi(&ue_sync, SRSLTE_MAX_PRB, false, radio_recv_callback, nof_rf_channels, this) !=
SRSLTE_SUCCESS) {
Error("SYNC: Initiating ue_sync\n");
Error("SYNC: Initiating ue_sync");
return;
}
@ -83,15 +79,15 @@ void sync::init(srslte::radio_interface_phy* _radio,
}
// Initialize cell searcher
search_p.init(sf_buffer, log_h, nof_rf_channels, this);
search_p.init(sf_buffer, nof_rf_channels, this);
// Initialize SFN synchronizer, it uses only pcell buffer
sfn_p.init(&ue_sync, worker_com->args, sf_buffer, sf_buffer.size(), log_h);
sfn_p.init(&ue_sync, worker_com->args, sf_buffer, sf_buffer.size());
// Start intra-frequency measurement
for (uint32_t i = 0; i < worker_com->args->nof_lte_carriers; i++) {
scell::intra_measure* q = new scell::intra_measure;
q->init(i, worker_com, this, log_h);
scell::intra_measure* q = new scell::intra_measure(phy_logger);
q->init(i, worker_com, this);
intra_freq_meas.push_back(std::unique_ptr<scell::intra_measure>(q));
}
@ -181,12 +177,12 @@ bool sync::cell_search_init()
std::unique_lock<std::mutex> ul(rrc_mutex);
if (rrc_proc_state != PROC_IDLE) {
Error("Cell Search: Can't start procedure. SYNC already running a procedure (%d)\n", (uint32_t)rrc_proc_state);
Error("Cell Search: Can't start procedure. SYNC already running a procedure (%d)", (uint32_t)rrc_proc_state);
return false;
}
// Move state to IDLE
Info("Cell Search: Start EARFCN index=%u/%zd\n", cellsearch_earfcn_index, worker_com->args->dl_earfcn_list.size());
Info("Cell Search: Start EARFCN index=%u/%zd", cellsearch_earfcn_index, worker_com->args->dl_earfcn_list.size());
phy_state.go_idle();
worker_com->reset();
@ -207,7 +203,7 @@ rrc_interface_phy_lte::cell_search_ret_t sync::cell_search_start(phy_cell_t* fou
ret.last_freq = rrc_interface_phy_lte::cell_search_ret_t::NO_MORE_FREQS;
if (rrc_proc_state != PROC_SEARCH_START) {
Error("Cell Search: Can't run procedure. Must call cell_search_init() first (%d)\n", (uint32_t)rrc_proc_state);
Error("Cell Search: Can't run procedure. Must call cell_search_init() first (%d)", (uint32_t)rrc_proc_state);
return ret;
}
@ -217,28 +213,28 @@ rrc_interface_phy_lte::cell_search_ret_t sync::cell_search_start(phy_cell_t* fou
srate_mode = SRATE_FIND;
radio_h->set_rx_srate(1.92e6);
radio_h->set_tx_srate(1.92e6);
Info("SYNC: Setting Cell Search sampling rate\n");
Info("SYNC: Setting Cell Search sampling rate");
}
try {
if (current_earfcn != (int)worker_com->args->dl_earfcn_list.at(cellsearch_earfcn_index)) {
current_earfcn = (int)worker_com->args->dl_earfcn_list[cellsearch_earfcn_index];
Info("Cell Search: changing frequency to EARFCN=%d\n", current_earfcn);
Info("Cell Search: changing frequency to EARFCN=%d", current_earfcn);
set_frequency();
}
} catch (const std::out_of_range& oor) {
Error("Index %d is not a valid EARFCN element.\n", cellsearch_earfcn_index);
Error("Index %d is not a valid EARFCN element.", cellsearch_earfcn_index);
return ret;
}
// Move to CELL SEARCH and wait to finish
Info("Cell Search: Setting Cell search state\n");
Info("Cell Search: Setting Cell search state");
phy_state.run_cell_search();
// Check return state
switch (cell_search_ret) {
case search::CELL_FOUND:
log_h->info("Cell Search: Found cell with PCI=%d with %d PRB\n", cell.id, cell.nof_prb);
phy_logger.info("Cell Search: Found cell with PCI=%d with %d PRB", cell.id, cell.nof_prb);
if (found_cell) {
found_cell->earfcn = current_earfcn;
found_cell->pci = cell.id;
@ -247,18 +243,18 @@ rrc_interface_phy_lte::cell_search_ret_t sync::cell_search_start(phy_cell_t* fou
ret.found = rrc_interface_phy_lte::cell_search_ret_t::CELL_FOUND;
break;
case search::CELL_NOT_FOUND:
Info("Cell Search: No cell found in this frequency\n");
Info("Cell Search: No cell found in this frequency");
ret.found = rrc_interface_phy_lte::cell_search_ret_t::CELL_NOT_FOUND;
break;
default:
Error("Cell Search: while receiving samples\n");
Error("Cell Search: while receiving samples");
radio_error();
break;
}
cellsearch_earfcn_index++;
if (cellsearch_earfcn_index >= worker_com->args->dl_earfcn_list.size()) {
Info("Cell Search: No more frequencies in the current EARFCN set\n");
Info("Cell Search: No more frequencies in the current EARFCN set");
cellsearch_earfcn_index = 0;
ret.last_freq = rrc_interface_phy_lte::cell_search_ret_t::NO_MORE_FREQS;
} else {
@ -282,17 +278,17 @@ bool sync::cell_select_init(phy_cell_t new_cell)
std::unique_lock<std::mutex> ul(rrc_mutex);
if (rrc_proc_state != PROC_IDLE) {
Error("Cell Select: Can't start procedure. SYNC already running a procedure (%d)\n", (uint32_t)rrc_proc_state);
Error("Cell Select: Can't start procedure. SYNC already running a procedure (%d)", (uint32_t)rrc_proc_state);
return false;
}
// Move state to IDLE
if (!srslte_cellid_isvalid(new_cell.pci)) {
Error("Cell Select: Invalid cell_id=%d\n", new_cell.pci);
Error("Cell Select: Invalid cell_id=%d", new_cell.pci);
return false;
}
Info("Cell Select: Going to IDLE\n");
Info("Cell Select: Going to IDLE");
phy_state.go_idle();
worker_com->reset();
@ -312,7 +308,7 @@ bool sync::cell_select_start(phy_cell_t new_cell)
bool ret = false;
if (rrc_proc_state != PROC_SELECT_START) {
Error("Cell Select: Can't run procedure. Must call cell_select_init() first (%d)\n", (uint32_t)rrc_proc_state);
Error("Cell Select: Can't run procedure. Must call cell_select_init() first (%d)", (uint32_t)rrc_proc_state);
goto clean_exit;
}
@ -325,7 +321,7 @@ bool sync::cell_select_start(phy_cell_t new_cell)
/* Reconfigure cell if necessary */
cell.id = new_cell.pci;
if (not set_cell(new_cell.cfo_hz)) {
Error("Cell Select: Reconfiguring cell\n");
Error("Cell Select: Reconfiguring cell");
goto clean_exit;
}
@ -333,9 +329,9 @@ bool sync::cell_select_start(phy_cell_t new_cell)
if ((int)new_cell.earfcn != current_earfcn) {
current_earfcn = new_cell.earfcn;
Info("Cell Select: Setting new frequency EARFCN=%d\n", new_cell.earfcn);
Info("Cell Select: Setting new frequency EARFCN=%d", new_cell.earfcn);
if (!set_frequency()) {
Error("Cell Select: Setting new frequency EARFCN=%d\n", new_cell.earfcn);
Error("Cell Select: Setting new frequency EARFCN=%d", new_cell.earfcn);
goto clean_exit;
}
}
@ -345,18 +341,18 @@ bool sync::cell_select_start(phy_cell_t new_cell)
// Change sampling rate if necessary
if (srate_mode != SRATE_CAMP) {
log_h->info("Cell Select: Setting CAMPING sampling rate\n");
phy_logger.info("Cell Select: Setting CAMPING sampling rate");
set_sampling_rate();
}
// SFN synchronization
phy_state.run_sfn_sync();
if (phy_state.is_camping()) {
Info("Cell Select: SFN synchronized. CAMPING...\n");
Info("Cell Select: SFN synchronized. CAMPING...");
stack->in_sync();
ret = true;
} else {
Info("Cell Select: Could not synchronize SFN\n");
Info("Cell Select: Could not synchronize SFN");
}
clean_exit:
@ -386,8 +382,8 @@ void sync::run_sfn_sync_state()
if (memcmp(&cell, &temp_cell, sizeof(srslte_cell_t)) != 0) {
srslte_cell_fprint(stdout, &cell, 0);
srslte_cell_fprint(stdout, &temp_cell, 0);
log_h->error("Detected cell during SFN synchronization differs from configured cell. Cell reselection to "
"cells with different MIB is not supported\n");
phy_logger.error("Detected cell during SFN synchronization differs from configured cell. Cell reselection to "
"cells with different MIB is not supported");
srslte::console("Detected cell during SFN synchronization differs from configured cell. Cell reselection "
"to cells with different MIB is not supported\n");
phy_state.state_exit(false);
@ -408,10 +404,8 @@ void sync::run_camping_in_sync_state(lte::sf_worker* lte_worker,
srslte::rf_buffer_t& sync_buffer)
{
// Update logging TTI
log_h->step(tti);
if (log_phy_lib_h != nullptr) {
log_phy_lib_h->step(tti);
}
phy_lib_logger.set_context(tti);
phy_logger.set_context(tti);
// Check tti is synched with ue_sync
if (srslte_ue_sync_get_sfidx(&ue_sync) != tti % 10) {
@ -430,7 +424,7 @@ void sync::run_camping_in_sync_state(lte::sf_worker* lte_worker,
if (is_overflow) {
force_camping_sfn_sync = true;
is_overflow = false;
log_h->info("Detected overflow, trying to resync SFN\n");
phy_logger.info("Detected overflow, trying to resync SFN");
}
// Force decode MIB if required
@ -447,19 +441,19 @@ void sync::run_camping_in_sync_state(lte::sf_worker* lte_worker,
force_camping_sfn_sync = false;
if (memcmp(&cell, &temp_cell, sizeof(srslte_cell_t)) != 0) {
log_h->error("Detected cell during SFN synchronization differs from configured cell. Cell "
"reselection to cells with different MIB is not supported\n");
phy_logger.error("Detected cell during SFN synchronization differs from configured cell. Cell "
"reselection to cells with different MIB is not supported");
srslte::console("Detected cell during SFN synchronization differs from configured cell. Cell "
"reselection to cells with different MIB is not supported\n");
} else {
log_h->info("SFN resynchronized successfully\n");
phy_logger.info("SFN resynchronized successfully");
}
} else {
log_h->warning("SFN not yet synchronized, sending out-of-sync\n");
phy_logger.warning("SFN not yet synchronized, sending out-of-sync");
}
}
Debug("SYNC: Worker %d synchronized\n", lte_worker->get_id());
Debug("SYNC: Worker %d synchronized", lte_worker->get_id());
metrics.sfo = srslte_ue_sync_get_sfo(&ue_sync);
metrics.cfo = srslte_ue_sync_get_cfo(&ue_sync);
@ -472,7 +466,7 @@ void sync::run_camping_in_sync_state(lte::sf_worker* lte_worker,
if (prach_buffer->is_ready_to_send(tti, cell.id)) {
prach_ptr = prach_buffer->generate(get_tx_cfo(), &prach_nof_sf, &prach_power);
if (prach_ptr == nullptr) {
Error("Generating PRACH\n");
Error("Generating PRACH");
}
}
@ -551,7 +545,7 @@ void sync::run_camping_state()
run_camping_in_sync_state(lte_worker, nr_worker, sync_buffer);
break;
case 0:
Warning("SYNC: Out-of-sync detected in PSS/SSS\n");
Warning("SYNC: Out-of-sync detected in PSS/SSS");
out_of_sync();
lte_worker->release();
@ -568,7 +562,7 @@ void sync::run_camping_state()
}
// Run stack
Debug("run_stack_tti: from main\n");
Debug("run_stack_tti: from main");
run_stack_tti();
}
@ -579,7 +573,7 @@ void sync::run_idle_state()
if (std::isnormal(current_srate) and current_srate > 0.0f) {
nsamples = current_srate / 1000;
}
Debug("Discarding %d samples\n", nsamples);
Debug("Discarding %d samples", nsamples);
srslte_timestamp_t rx_time = {};
dummy_buffer.set_nof_samples(nsamples);
if (radio_recv_fnc(dummy_buffer, &rx_time) == SRSLTE_SUCCESS) {
@ -591,7 +585,7 @@ void sync::run_idle_state()
}
radio_h->tx_end();
} else {
Debug("Sleeping\n");
Debug("Sleeping");
usleep(1000);
}
}
@ -599,11 +593,9 @@ void sync::run_idle_state()
void sync::run_thread()
{
while (running) {
if (log_phy_lib_h) {
log_phy_lib_h->step(tti);
}
phy_lib_logger.set_context(tti);
Debug("SYNC: state=%s, tti=%d\n", phy_state.to_string(), tti);
Debug("SYNC: state=%s, tti=%d", phy_state.to_string(), tti);
// If not camping, clear SFN sync
if (!phy_state.is_camping()) {
@ -642,7 +634,7 @@ void sync::radio_overflow()
void sync::radio_error()
{
log_h->error("SYNC: Receiving from radio.\n");
phy_logger.error("SYNC: Receiving from radio.");
// Need to find a method to effectively reset radio, reloading the driver does not work
radio_h->reset();
}
@ -662,10 +654,10 @@ void sync::in_sync()
void sync::out_of_sync()
{
// Send RRC out-of-sync signal after NOF_OUT_OF_SYNC_SF consecutive subframes
Info("Out-of-sync %d/%d\n", out_of_sync_cnt, worker_com->args->nof_out_of_sync_events);
Info("Out-of-sync %d/%d", out_of_sync_cnt, worker_com->args->nof_out_of_sync_events);
out_of_sync_cnt++;
if (out_of_sync_cnt == worker_com->args->nof_out_of_sync_events) {
Info("Sending to RRC\n");
Info("Sending to RRC");
stack->out_of_sync();
out_of_sync_cnt = 0;
in_sync_cnt = 0;
@ -692,14 +684,14 @@ void sync::set_agc_enable(bool enable)
// PHY and radio must have been initialised
if (not running or radio_h == nullptr) {
ERROR("Error setting AGC: PHY not initiated\n");
ERROR("Error setting AGC: PHY not initiated");
return;
}
// Get radio info and check it is valid
srslte_rf_info_t* rf_info = radio_h->get_info();
if (rf_info == nullptr) {
Error("Error: Radio does not provide RF information\n");
Error("Error: Radio does not provide RF information");
return;
}
@ -765,7 +757,7 @@ void sync::set_ue_sync_opts(srslte_ue_sync_t* q, float cfo)
} else if (!worker_com->args->sss_algorithm.compare("full")) {
sss_alg = SSS_FULL;
} else {
Warning("SYNC: Invalid SSS algorithm %s. Using 'full'\n", worker_com->args->sss_algorithm.c_str());
Warning("SYNC: Invalid SSS algorithm %s. Using 'full'", worker_com->args->sss_algorithm.c_str());
}
srslte_sync_set_sss_algorithm(&q->strack, (sss_alg_t)sss_alg);
srslte_sync_set_sss_algorithm(&q->sfind, (sss_alg_t)sss_alg);
@ -776,23 +768,23 @@ bool sync::set_cell(float cfo)
// Wait for SYNC thread to transition to IDLE (max. 2000ms)
uint32_t cnt = 0;
while (!phy_state.is_idle() && cnt <= 4000) {
Info("SYNC: PHY state is_idle=%d, cnt=%d\n", phy_state.is_idle(), cnt);
Info("SYNC: PHY state is_idle=%d, cnt=%d", phy_state.is_idle(), cnt);
usleep(500);
cnt++;
}
if (!phy_state.is_idle()) {
Error("Can not change Cell while not in IDLE\n");
Error("Can not change Cell while not in IDLE");
return false;
}
if (!srslte_cell_isvalid(&cell)) {
Error("SYNC: Setting cell: invalid cell (nof_prb=%d, pci=%d, ports=%d)\n", cell.nof_prb, cell.id, cell.nof_ports);
Error("SYNC: Setting cell: invalid cell (nof_prb=%d, pci=%d, ports=%d)", cell.nof_prb, cell.id, cell.nof_ports);
return false;
}
// Set cell in all objects
if (srslte_ue_sync_set_cell(&ue_sync, cell)) {
Error("SYNC: Setting cell: initiating ue_sync\n");
Error("SYNC: Setting cell: initiating ue_sync");
return false;
}
sfn_p.set_cell(cell);
@ -812,7 +804,7 @@ bool sync::set_cell(float cfo)
}
}
if (!success) {
Error("SYNC: Setting cell: initiating PHCH worker\n");
Error("SYNC: Setting cell: initiating PHCH worker");
return false;
}
@ -848,10 +840,8 @@ bool sync::set_frequency()
}
}
if (set_dl_freq > 0 && set_ul_freq > 0) {
log_h->info("SYNC: Set DL EARFCN=%d, f_dl=%.1f MHz, f_ul=%.1f MHz\n",
current_earfcn,
set_dl_freq / 1e6,
set_ul_freq / 1e6);
phy_logger.info(
"SYNC: Set DL EARFCN=%d, f_dl=%.1f MHz, f_ul=%.1f MHz", current_earfcn, set_dl_freq / 1e6, set_ul_freq / 1e6);
// Logical channel is 0
radio_h->set_rx_freq(0, set_dl_freq);
@ -868,7 +858,7 @@ bool sync::set_frequency()
return true;
} else {
log_h->error("SYNC: Cell Search: Invalid EARFCN=%d\n", current_earfcn);
phy_logger.error("SYNC: Cell Search: Invalid EARFCN=%d", current_earfcn);
return false;
}
}
@ -877,19 +867,19 @@ void sync::set_sampling_rate()
{
float new_srate = (float)srslte_sampling_freq_hz(cell.nof_prb);
if (new_srate < 0.0) {
Error("Invalid sampling rate for %d PRBs. keeping same.\n", cell.nof_prb);
Error("Invalid sampling rate for %d PRBs. keeping same.", cell.nof_prb);
return;
}
if (current_srate != new_srate || srate_mode != SRATE_CAMP) {
current_srate = new_srate;
Info("SYNC: Setting sampling rate %.2f MHz\n", current_srate / 1000000);
Info("SYNC: Setting sampling rate %.2f MHz", current_srate / 1000000);
srate_mode = SRATE_CAMP;
radio_h->set_rx_srate(current_srate);
radio_h->set_tx_srate(current_srate);
} else {
Error("Error setting sampling rate for cell with %d PRBs\n", cell.nof_prb);
Error("Error setting sampling rate for cell with %d PRBs", cell.nof_prb);
}
}
@ -933,7 +923,7 @@ int sync::radio_recv_fnc(srslte::rf_buffer_t& data, srslte_timestamp_t* rx_time)
// Run stack if the sync state is not in camping
if (not phy_state.is_camping()) {
Debug("run_stack_tti: from recv\n");
Debug("run_stack_tti: from recv");
run_stack_tti();
}
@ -954,7 +944,7 @@ int sync::radio_recv_fnc(srslte::rf_buffer_t& data, srslte_timestamp_t* rx_time)
}
}
log_h->debug("SYNC: received %d samples from radio\n", data.get_nof_samples());
phy_logger.debug("SYNC: received %d samples from radio", data.get_nof_samples());
return data.get_nof_samples();
}
@ -965,14 +955,14 @@ void sync::run_stack_tti()
if (forced_rx_time_init || srslte_timestamp_iszero(&stack_tti_ts) ||
srslte_timestamp_compare(&stack_tti_ts_new, &stack_tti_ts) < 0) {
if (srslte_timestamp_compare(&stack_tti_ts_new, &stack_tti_ts) < 0) {
log_h->warning("SYNC: radio time seems to be going backwards (rx_time=%f, tti_ts=%f)\n",
srslte_timestamp_real(&stack_tti_ts_new),
srslte_timestamp_real(&stack_tti_ts));
phy_logger.warning("SYNC: radio time seems to be going backwards (rx_time=%f, tti_ts=%f)",
srslte_timestamp_real(&stack_tti_ts_new),
srslte_timestamp_real(&stack_tti_ts));
// time-stamp will be set to rx time below and run_tti() will be called with MIN_TTI_JUMP
}
// init tti_ts with last rx time
log_h->debug("SYNC: Setting initial TTI time to %f\n", srslte_timestamp_real(&stack_tti_ts_new));
phy_logger.debug("SYNC: Setting initial TTI time to %f", srslte_timestamp_real(&stack_tti_ts_new));
srslte_timestamp_copy(&stack_tti_ts, &stack_tti_ts_new);
forced_rx_time_init = false;
}
@ -985,14 +975,14 @@ void sync::run_stack_tti()
int32_t tti_jump = static_cast<int32_t>(srslte_timestamp_uint64(&temp, 1e3));
tti_jump = SRSLTE_MAX(tti_jump, MIN_TTI_JUMP);
if (tti_jump > MAX_TTI_JUMP) {
log_h->warning("SYNC: TTI jump of %d limited to %d\n", tti_jump, MAX_TTI_JUMP);
phy_logger.warning("SYNC: TTI jump of %d limited to %d", tti_jump, int(MAX_TTI_JUMP));
tti_jump = SRSLTE_MIN(tti_jump, MAX_TTI_JUMP);
}
// Run stack
Debug("run_stack_tti: calling stack tti=%d, tti_jump=%d\n", tti, tti_jump);
Debug("run_stack_tti: calling stack tti=%d, tti_jump=%d", tti, tti_jump);
stack->run_tti(tti, tti_jump);
Debug("run_stack_tti: stack called\n");
Debug("run_stack_tti: stack called");
}
// update timestamp
@ -1025,7 +1015,7 @@ void sync::set_cells_to_meas(uint32_t earfcn_, const std::set<uint32_t>& pci)
}
}
if (!found) {
log_h->error("Neighbour cell measurement not supported in secondary carrier. EARFCN=%d\n", earfcn_);
phy_logger.error("Neighbour cell measurement not supported in secondary carrier. EARFCN=%d", earfcn_);
}
}

@ -10,10 +10,10 @@
*
*/
#define Error(fmt, ...) log_h->error(fmt, ##__VA_ARGS__)
#define Warning(fmt, ...) log_h->warning(fmt, ##__VA_ARGS__)
#define Info(fmt, ...) log_h->info(fmt, ##__VA_ARGS__)
#define Debug(fmt, ...) log_h->debug(fmt, ##__VA_ARGS__)
#define Error(fmt, ...) logger.error(fmt, ##__VA_ARGS__)
#define Warning(fmt, ...) logger.warning(fmt, ##__VA_ARGS__)
#define Info(fmt, ...) logger.info(fmt, ##__VA_ARGS__)
#define Debug(fmt, ...) logger.debug(fmt, ##__VA_ARGS__)
#include "srsue/hdr/stack/mac/demux.h"
#include "srslte/interfaces/ue_interfaces.h"
@ -21,7 +21,8 @@
namespace srsue {
demux::demux(log_ref log_h_) : log_h(log_h_), mac_msg(20, log_h_), mch_mac_msg(20, log_h_), pending_mac_msg(20, log_h_)
demux::demux(log_ref log_h_, srslog::basic_logger& logger) :
log_h(log_h_), logger(logger), mac_msg(20, log_h_), mch_mac_msg(20, log_h_), pending_mac_msg(20, log_h_)
{}
void demux::init(phy_interface_mac_common* phy_,
@ -89,7 +90,7 @@ void demux::push_pdu_temp_crnti(uint8_t* buff, uint32_t nof_bytes)
switch (pending_mac_msg.get()->dl_sch_ce_type()) {
case srslte::dl_sch_lcid::CON_RES_ID:
if (!is_uecrid_successful) {
Debug("Found Contention Resolution ID CE\n");
Debug("Found Contention Resolution ID CE");
is_uecrid_successful = mac->contention_resolution_id_rcv(pending_mac_msg.get()->get_con_res_id());
}
break;
@ -102,13 +103,13 @@ void demux::push_pdu_temp_crnti(uint8_t* buff, uint32_t nof_bytes)
}
pending_mac_msg.reset();
if (is_uecrid_successful) {
Debug("Saved MAC PDU with Temporal C-RNTI in buffer\n");
Debug("Saved MAC PDU with Temporal C-RNTI in buffer");
pdus.push(buff, nof_bytes, srslte::pdu_queue::DCH);
} else {
pdus.deallocate(buff);
}
} else {
Warning("Trying to push PDU with payload size zero\n");
Warning("Trying to push PDU with payload size zero");
}
}
@ -148,13 +149,13 @@ bool demux::process_pdus()
void demux::process_pdu(uint8_t* mac_pdu, uint32_t nof_bytes, srslte::pdu_queue::channel_t channel)
{
Debug("Processing MAC PDU channel %d\n", channel);
Debug("Processing MAC PDU channel %d", channel);
switch (channel) {
case srslte::pdu_queue::DCH:
// Unpack DLSCH MAC PDU
mac_msg.init_rx(nof_bytes);
mac_msg.parse_packet(mac_pdu);
Info("%s\n", mac_msg.to_string().c_str());
Info("%s", mac_msg.to_string().c_str());
process_sch_pdu(&mac_msg);
pdus.deallocate(mac_pdu);
break;
@ -184,7 +185,7 @@ void demux::process_sch_pdu_rt(uint8_t* buff, uint32_t nof_bytes, uint32_t tti)
} else {
// Process MAC Control Element
if (!process_ce(mac_msg_rt.get(), tti)) {
Warning("Received Subheader with invalid or unknown LCID\n");
Warning("Received Subheader with invalid or unknown LCID");
}
}
}
@ -203,21 +204,20 @@ void demux::process_sch_pdu(srslte::sch_pdu* pdu_msg)
}
if (sum == 0) {
route_pdu = false;
Warning("Received all zero PDU\n");
Warning("Received all zero PDU");
}
}
// Route logical channel
if (route_pdu) {
Debug("Delivering PDU for lcid=%d, %d bytes\n",
pdu_msg->get()->get_sdu_lcid(),
pdu_msg->get()->get_payload_size());
Debug(
"Delivering PDU for lcid=%d, %d bytes", pdu_msg->get()->get_sdu_lcid(), pdu_msg->get()->get_payload_size());
if (pdu_msg->get()->get_payload_size() < MAX_PDU_LEN) {
rlc->write_pdu(
pdu_msg->get()->get_sdu_lcid(), pdu_msg->get()->get_sdu_ptr(), pdu_msg->get()->get_payload_size());
} else {
char tmp[1024];
srslte_vec_sprint_hex(tmp, sizeof(tmp), pdu_msg->get()->get_sdu_ptr(), 32);
Error("PDU size %d exceeds maximum PDU buffer size, lcid=%d, hex=[%s]\n",
Error("PDU size %d exceeds maximum PDU buffer size, lcid=%d, hex=[%s]",
pdu_msg->get()->get_payload_size(),
pdu_msg->get()->get_sdu_lcid(),
tmp);
@ -237,17 +237,17 @@ void demux::process_mch_pdu(srslte::mch_pdu* mch_msg)
uint16_t stop;
uint8_t lcid;
if (mch_msg->get()->get_next_mch_sched_info(&lcid, &stop)) {
Info("MCH Sched Info: LCID: %d, Stop: %d, tti is %d \n", lcid, stop, phy_h->get_current_tti());
Info("MCH Sched Info: LCID: %d, Stop: %d, tti is %d ", lcid, stop, phy_h->get_current_tti());
}
}
if (mch_msg->get()->is_sdu()) {
uint32_t lcid = mch_msg->get()->get_sdu_lcid();
if (lcid >= SRSLTE_N_MCH_LCIDS) {
Error("Radio bearer id must be in [0:%d] - %d\n", SRSLTE_N_MCH_LCIDS, lcid);
Error("Radio bearer id must be in [0:%d] - %d", SRSLTE_N_MCH_LCIDS, lcid);
return;
}
Debug("Wrote MCH LCID=%d to RLC\n", lcid);
Debug("Wrote MCH LCID=%d to RLC", lcid);
if (1 == mch_lcids[lcid]) {
rlc->write_pdu_mch(lcid, mch_msg->get()->get_sdu_ptr(), mch_msg->get()->get_payload_size());
}
@ -258,10 +258,10 @@ void demux::process_mch_pdu(srslte::mch_pdu* mch_msg)
void demux::mch_start_rx(uint32_t lcid)
{
if (lcid < 32) {
Info("MCH Channel Setup: LCID=%d\n", lcid);
Info("MCH Channel Setup: LCID=%d", lcid);
mch_lcids[lcid] = 1;
} else {
Error("MCH Channel Setup: invalid LCID=%d\n", lcid);
Error("MCH Channel Setup: invalid LCID=%d", lcid);
}
}
@ -277,14 +277,14 @@ bool demux::process_ce(srslte::sch_subh* subh, uint32_t tti)
case srslte::dl_sch_lcid::SCELL_ACTIVATION: {
uint32_t cmd = (uint32_t)subh->get_activation_deactivation_cmd();
srslte::console("SCELL Activation / Deactivation CMD: %x\n", cmd);
log_h->info("SCELL Activation / Deactivation CMD: %x\n", cmd);
logger.info("SCELL Activation / Deactivation CMD: %x", cmd);
phy_h->set_activation_deactivation_scell(cmd, tti);
break;
}
case srslte::dl_sch_lcid::PADDING:
break;
default:
Error("MAC CE 0x%x not supported\n", subh->lcid_value());
Error("MAC CE 0x%x not supported", subh->lcid_value());
break;
}
return true;
@ -293,7 +293,7 @@ bool demux::process_ce(srslte::sch_subh* subh, uint32_t tti)
void demux::parse_ta_cmd(srslte::sch_subh* subh)
{
phy_h->set_timeadv(subh->get_ta_cmd());
Info("Received TA=%d (%d/%d) \n",
Info("Received TA=%d (%d/%d) ",
subh->get_ta_cmd(),
time_alignment_timer->time_elapsed(),
time_alignment_timer->duration());

@ -10,10 +10,10 @@
*
*/
#define Error(fmt, ...) log_h->error(fmt, ##__VA_ARGS__)
#define Warning(fmt, ...) log_h->warning(fmt, ##__VA_ARGS__)
#define Info(fmt, ...) log_h->info(fmt, ##__VA_ARGS__)
#define Debug(fmt, ...) log_h->debug(fmt, ##__VA_ARGS__)
#define Error(fmt, ...) logger.error(fmt, ##__VA_ARGS__)
#define Warning(fmt, ...) logger.warning(fmt, ##__VA_ARGS__)
#define Info(fmt, ...) logger.info(fmt, ##__VA_ARGS__)
#define Debug(fmt, ...) logger.debug(fmt, ##__VA_ARGS__)
#include "srsue/hdr/stack/mac/dl_harq.h"
#include "srslte/common/log.h"
@ -23,12 +23,13 @@
namespace srsue {
dl_harq_entity::dl_harq_entity(uint8_t cc_idx_) : proc(SRSLTE_MAX_HARQ_PROC), cc_idx(cc_idx_) {}
dl_harq_entity::dl_harq_entity(uint8_t cc_idx_) :
proc(SRSLTE_MAX_HARQ_PROC), logger(srslog::fetch_basic_logger("MAC")), cc_idx(cc_idx_)
{}
bool dl_harq_entity::init(srslte::log_ref log_h_, mac_interface_rrc::ue_rnti_t* rntis_, demux* demux_unit_)
bool dl_harq_entity::init(mac_interface_rrc::ue_rnti_t* rntis_, demux* demux_unit_)
{
demux_unit = demux_unit_;
log_h = log_h_;
rntis = rntis_;
for (uint32_t i = 0; i < SRSLTE_MAX_HARQ_PROC; i++) {
@ -53,7 +54,7 @@ void dl_harq_entity::new_grant_dl(mac_interface_phy_lte::mac_grant_dl_t grant,
proc_ptr = &bcch_proc;
} else {
if (grant.pid >= SRSLTE_MAX_HARQ_PROC) {
Error("Invalid PID: %d\n", grant.pid);
Error("Invalid PID: %d", grant.pid);
return;
}
proc_ptr = &proc[grant.pid];
@ -62,11 +63,11 @@ void dl_harq_entity::new_grant_dl(mac_interface_phy_lte::mac_grant_dl_t grant,
if (grant.rnti == rntis->temp_rnti && last_temporal_crnti != rntis->temp_rnti) {
last_temporal_crnti = rntis->temp_rnti;
proc_ptr->reset_ndi();
Info("Considering NDI in pid=%d to be toggled for first Temporal C-RNTI\n", grant.pid);
Info("Considering NDI in pid=%d to be toggled for first Temporal C-RNTI", grant.pid);
}
proc_ptr->new_grant_dl(grant, action);
} else {
Error("SPS not supported\n");
Error("SPS not supported");
}
}
@ -76,7 +77,7 @@ void dl_harq_entity::tb_decoded(mac_interface_phy_lte::mac_grant_dl_t grant, boo
bcch_proc.tb_decoded(grant, ack);
} else {
if (grant.pid >= SRSLTE_MAX_HARQ_PROC) {
Error("Invalid PID: %d\n", grant.pid);
Error("Invalid PID: %d", grant.pid);
return;
}
proc[grant.pid].tb_decoded(grant, ack);
@ -159,7 +160,7 @@ bool dl_harq_entity::dl_harq_process::is_sps()
return false;
}
dl_harq_entity::dl_harq_process::dl_tb_process::dl_tb_process()
dl_harq_entity::dl_harq_process::dl_tb_process::dl_tb_process() : logger(srslog::fetch_basic_logger("MAC"))
{
is_initiated = false;
ack = false;
@ -178,7 +179,7 @@ dl_harq_entity::dl_harq_process::dl_tb_process::~dl_tb_process()
bool dl_harq_entity::dl_harq_process::dl_tb_process::init(int pid, dl_harq_entity* parent, uint32_t tb_idx)
{
if (srslte_softbuffer_rx_init(&softbuffer, 110)) {
Error("Error initiating soft buffer\n");
Error("Error initiating soft buffer");
return false;
}
@ -194,7 +195,6 @@ bool dl_harq_entity::dl_harq_process::dl_tb_process::init(int pid, dl_harq_entit
is_first_tb = true;
is_initiated = true;
harq_entity = parent;
log_h = harq_entity->log_h;
return true;
}
@ -249,7 +249,7 @@ void dl_harq_entity::dl_harq_process::dl_tb_process::new_grant_dl(mac_interface_
// If this is a new transmission or the size of the TB has changed
if (is_new_transmission || (cur_grant.tb[tid].tbs != grant.tb[tid].tbs)) {
if (!is_new_transmission) {
Debug("DL PID %d: Size of dci changed during a retransmission %d!=%d\n",
Debug("DL PID %d: Size of dci changed during a retransmission %d!=%d",
pid,
cur_grant.tb[tid].tbs,
grant.tb[tid].tbs);
@ -268,7 +268,7 @@ void dl_harq_entity::dl_harq_process::dl_tb_process::new_grant_dl(mac_interface_
cur_grant = grant;
if (payload_buffer_ptr) {
Warning("DL PID %d: Allocating buffer already allocated. Deallocating.\n", pid);
Warning("DL PID %d: Allocating buffer already allocated. Deallocating.", pid);
if (!is_bcch) {
harq_entity->demux_unit->deallocate(payload_buffer_ptr);
}
@ -283,7 +283,7 @@ void dl_harq_entity::dl_harq_process::dl_tb_process::new_grant_dl(mac_interface_
action->tb[tid].payload = payload_buffer_ptr;
if (!action->tb[tid].payload) {
Error("Can't get a buffer for TBS=%d\n", cur_grant.tb[tid].tbs);
Error("Can't get a buffer for TBS=%d", cur_grant.tb[tid].tbs);
return;
}
@ -291,7 +291,7 @@ void dl_harq_entity::dl_harq_process::dl_tb_process::new_grant_dl(mac_interface_
action->tb[tid].rv = cur_grant.tb[tid].rv;
action->tb[tid].softbuffer.rx = &softbuffer;
} else {
Info("DL PID %d: Received duplicate TB%d. Discarding and retransmitting ACK (n_retx=%d, reset=%s)\n",
Info("DL PID %d: Received duplicate TB%d. Discarding and retransmitting ACK (n_retx=%d, reset=%s)",
pid,
tid,
n_retx,
@ -316,7 +316,7 @@ void dl_harq_entity::dl_harq_process::dl_tb_process::tb_decoded(mac_interface_ph
harq_entity->pcap->write_dl_sirnti(
payload_buffer_ptr, cur_grant.tb[tid].tbs, ack, cur_grant.tti, harq_entity->cc_idx);
}
Debug("Delivering PDU=%d bytes to Dissassemble and Demux unit (BCCH)\n", cur_grant.tb[tid].tbs);
Debug("Delivering PDU=%d bytes to Dissassemble and Demux unit (BCCH)", cur_grant.tb[tid].tbs);
harq_entity->demux_unit->push_pdu_bcch(payload_buffer_ptr, cur_grant.tb[tid].tbs);
} else {
if (harq_entity->pcap) {
@ -324,14 +324,14 @@ void dl_harq_entity::dl_harq_process::dl_tb_process::tb_decoded(mac_interface_ph
payload_buffer_ptr, cur_grant.tb[tid].tbs, cur_grant.rnti, ack, cur_grant.tti, harq_entity->cc_idx);
}
if (cur_grant.rnti == harq_entity->rntis->temp_rnti) {
Debug("Delivering PDU=%d bytes to Dissassemble and Demux unit (Temporal C-RNTI)\n", cur_grant.tb[tid].tbs);
Debug("Delivering PDU=%d bytes to Dissassemble and Demux unit (Temporal C-RNTI)", cur_grant.tb[tid].tbs);
harq_entity->demux_unit->push_pdu_temp_crnti(payload_buffer_ptr, cur_grant.tb[tid].tbs);
// If T-CRNTI, update ack value with result from contention resolution
*ack_ptr = harq_entity->demux_unit->get_uecrid_successful();
} else {
Debug("Delivering PDU=%d bytes to Dissassemble and Demux unit\n", cur_grant.tb[tid].tbs);
Debug("Delivering PDU=%d bytes to Dissassemble and Demux unit", cur_grant.tb[tid].tbs);
harq_entity->demux_unit->push_pdu(payload_buffer_ptr, cur_grant.tb[tid].tbs, grant.tti);
// Compute average number of retransmissions per packet
@ -345,7 +345,7 @@ void dl_harq_entity::dl_harq_process::dl_tb_process::tb_decoded(mac_interface_ph
payload_buffer_ptr = NULL;
Info("DL %d (TB %d): %s tbs=%d, rv=%d, ack=%s, ndi=%d\n",
Info("DL %d (TB %d): %s tbs=%d, rv=%d, ack=%s, ndi=%d",
pid,
tid,
is_new_transmission ? "newTX" : "reTX ",
@ -377,7 +377,7 @@ bool dl_harq_entity::dl_harq_process::dl_tb_process::calc_is_new_transmission(
is_new_transmission = false;
}
Debug("Set HARQ for %stransmission\n", is_new_transmission ? "new " : "re");
Debug("Set HARQ for %stransmission", is_new_transmission ? "new " : "re");
return is_new_transmission;
}

@ -10,10 +10,10 @@
*
*/
#define Error(fmt, ...) log_h->error(fmt, ##__VA_ARGS__)
#define Warning(fmt, ...) log_h->warning(fmt, ##__VA_ARGS__)
#define Info(fmt, ...) log_h->info(fmt, ##__VA_ARGS__)
#define Debug(fmt, ...) log_h->debug(fmt, ##__VA_ARGS__)
#define Error(fmt, ...) logger.error(fmt, ##__VA_ARGS__)
#define Warning(fmt, ...) logger.warning(fmt, ##__VA_ARGS__)
#define Info(fmt, ...) logger.info(fmt, ##__VA_ARGS__)
#define Debug(fmt, ...) logger.debug(fmt, ##__VA_ARGS__)
#include <pthread.h>
#include <string.h>
@ -28,9 +28,14 @@ namespace srsue {
mac::mac(const char* logname, ext_task_sched_handle task_sched_) :
log_h(srslte::logmap::get(logname)),
logger(srslog::fetch_basic_logger(logname)),
mch_msg(10, log_h),
mux_unit(log_h),
demux_unit(log_h),
mux_unit(log_h, logger),
demux_unit(log_h, logger),
ra_procedure(logger),
sr_procedure(logger),
bsr_procedure(logger),
phr_procedure(logger),
pcap(nullptr),
task_sched(task_sched_)
{
@ -67,16 +72,16 @@ bool mac::init(phy_interface_mac_lte* phy, rlc_interface_mac* rlc, rrc_interface
// Create Stack task dispatch queue
stack_task_dispatch_queue = task_sched.make_task_queue();
bsr_procedure.init(&sr_procedure, rlc_h, log_h, &task_sched);
phr_procedure.init(phy_h, log_h, &task_sched);
bsr_procedure.init(&sr_procedure, rlc_h, &task_sched);
phr_procedure.init(phy_h, &task_sched);
mux_unit.init(rlc_h, &bsr_procedure, &phr_procedure);
demux_unit.init(phy_h, rlc_h, this, &timer_alignment);
ra_procedure.init(phy_h, rrc, log_h, &uernti, &timer_alignment, &mux_unit, &task_sched);
sr_procedure.init(&ra_procedure, phy_h, rrc, log_h);
ra_procedure.init(phy_h, rrc, &uernti, &timer_alignment, &mux_unit, &task_sched);
sr_procedure.init(&ra_procedure, phy_h, rrc);
// Create UL/DL unique HARQ pointers
ul_harq.at(PCELL_CC_IDX)->init(log_h, &uernti, &ra_procedure, &mux_unit);
dl_harq.at(PCELL_CC_IDX)->init(log_h, &uernti, &demux_unit);
ul_harq.at(PCELL_CC_IDX)->init(&uernti, &ra_procedure, &mux_unit);
dl_harq.at(PCELL_CC_IDX)->init(&uernti, &demux_unit);
reset();
@ -120,7 +125,7 @@ void mac::reconfiguration(const uint32_t& cc_idx, const bool& enable)
if (cc_idx < SRSLTE_MAX_CARRIERS) {
if (enable and ul_harq.at(cc_idx) == nullptr) {
ul_harq_entity_ptr ul = ul_harq_entity_ptr(new ul_harq_entity(cc_idx));
ul->init(log_h, &uernti, &ra_procedure, &mux_unit);
ul->init(&uernti, &ra_procedure, &mux_unit);
ul->set_config(ul_harq_cfg);
if (pcap != nullptr) {
@ -132,7 +137,7 @@ void mac::reconfiguration(const uint32_t& cc_idx, const bool& enable)
if (enable and dl_harq.at(cc_idx) == nullptr) {
dl_harq_entity_ptr dl = dl_harq_entity_ptr(new dl_harq_entity(cc_idx));
dl->init(log_h, &uernti, &demux_unit);
dl->init(&uernti, &demux_unit);
if (pcap != nullptr) {
dl->start_pcap(pcap);
@ -148,7 +153,7 @@ void mac::reset()
{
bzero(&metrics, sizeof(mac_metrics_t));
Info("Resetting MAC\n");
Info("Resetting MAC");
timer_alignment.stop();
@ -188,11 +193,12 @@ void mac::reset()
void mac::run_tti(const uint32_t tti)
{
log_h->step(tti);
logger.set_context(tti);
/* Warning: Here order of invocation of procedures is important!! */
// Step all procedures (must follow this order)
Debug("Running MAC tti=%d\n", tti);
Debug("Running MAC tti=%d", tti);
mux_unit.step();
bsr_procedure.step(tti);
sr_procedure.step(tti);
@ -216,7 +222,7 @@ void mac::bcch_start_rx(int si_window_start_, int si_window_length_)
si_window_length = 0;
si_window_start = 0;
}
Info("SCHED: Searching for DL dci for SI-RNTI window_st=%d, window_len=%d\n", si_window_start, si_window_length);
Info("SCHED: Searching for DL dci for SI-RNTI window_st=%d, window_len=%d", si_window_start, si_window_length);
}
void mac::bcch_stop_rx()
@ -302,25 +308,25 @@ uint16_t mac::get_dl_sched_rnti(uint32_t tti)
return SRSLTE_INVALID_RNTI;
}
}
Debug("SCHED: Searching SI-RNTI, tti=%d, window start=%d, length=%d\n", tti, si_window_start, si_window_length);
Debug("SCHED: Searching SI-RNTI, tti=%d, window start=%d, length=%d", tti, si_window_start, si_window_length);
return SRSLTE_SIRNTI;
}
}
if (uernti.rar_rnti && ra_window_start > 0 && ra_window_length > 0 &&
is_in_window(tti, &ra_window_start, &ra_window_length)) {
Debug("SCHED: Searching RAR-RNTI=0x%x, tti=%d\n", uernti.rar_rnti, tti);
Debug("SCHED: Searching RAR-RNTI=0x%x, tti=%d", uernti.rar_rnti, tti);
return uernti.rar_rnti;
}
if (uernti.temp_rnti && !uernti.crnti) {
Debug("SCHED: Searching Temp-RNTI=0x%x\n", uernti.temp_rnti);
Debug("SCHED: Searching Temp-RNTI=0x%x", uernti.temp_rnti);
return uernti.temp_rnti;
}
if (uernti.crnti) {
Debug("SCHED: Searching C-RNTI=0x%x\n", uernti.crnti);
Debug("SCHED: Searching C-RNTI=0x%x", uernti.crnti);
return uernti.crnti;
}
if (p_window_start > 0) {
Debug("SCHED: Searching P-RNTI\n");
Debug("SCHED: Searching P-RNTI");
return SRSLTE_PRNTI;
}
@ -339,10 +345,10 @@ void mac::bch_decoded_ok(uint32_t cc_idx, uint8_t* payload, uint32_t len)
auto p = stack_task_dispatch_queue.try_push(std::bind(
[this](srslte::unique_byte_buffer_t& buf) { rlc_h->write_pdu_bcch_bch(std::move(buf)); }, std::move(buf)));
if (not p.first) {
Warning("Failed to dispatch rlc::write_pdu_bcch_bch task to stack\n");
Warning("Failed to dispatch rlc::write_pdu_bcch_bch task to stack");
}
} else {
log_h->error("Fatal error: Out of buffers from the pool in write_pdu_bcch_bch()\n");
logger.error("Fatal error: Out of buffers from the pool in write_pdu_bcch_bch()");
}
if (pcap) {
@ -363,7 +369,7 @@ void mac::mch_decoded(uint32_t len, bool crc)
uint8_t lcid;
if (mch_msg.get()->get_next_mch_sched_info(&lcid, &stop)) {
phy_h->set_mch_period_stop(stop);
Info("MCH Sched Info: LCID: %d, Stop: %d, tti is %d \n", lcid, stop, phy_h->get_current_tti());
Info("MCH Sched Info: LCID: %d, Stop: %d, tti is %d ", lcid, stop, phy_h->get_current_tti());
}
}
}
@ -400,10 +406,10 @@ void mac::tb_decoded(uint32_t cc_idx, mac_grant_dl_t grant, bool ack[SRSLTE_MAX_
auto ret = stack_task_dispatch_queue.try_push(std::bind(
[this](srslte::unique_byte_buffer_t& pdu) { rlc_h->write_pdu_pcch(std::move(pdu)); }, std::move(pdu)));
if (not ret.first) {
Warning("Failed to dispatch rlc::write_pdu_pcch task to stack\n");
Warning("Failed to dispatch rlc::write_pdu_pcch task to stack");
}
} else {
log_h->error("Fatal error: Out of buffers from the pool in write_pdu_pcch()\n");
logger.error("Fatal error: Out of buffers from the pool in write_pdu_pcch()");
}
if (pcap) {
@ -413,7 +419,7 @@ void mac::tb_decoded(uint32_t cc_idx, mac_grant_dl_t grant, bool ack[SRSLTE_MAX_
// Assert DL HARQ entity
if (dl_harq.at(cc_idx) == nullptr) {
Error("HARQ entity %d has not been created\n", cc_idx);
Error("HARQ entity %d has not been created", cc_idx);
return;
}
@ -443,7 +449,7 @@ void mac::new_grant_dl(uint32_t cc_idx,
bzero(action, sizeof(mac_interface_phy_lte::tb_action_dl_t));
if (grant.tb[0].tbs > pch_payload_buffer_sz) {
Error("Received dci for PCH (%d bytes) exceeds buffer (%d bytes)\n", grant.tb[0].tbs, pch_payload_buffer_sz);
Error("Received dci for PCH (%d bytes) exceeds buffer (%d bytes)", grant.tb[0].tbs, int(pch_payload_buffer_sz));
action->tb[0].enabled = false;
} else {
action->tb[0].enabled = true;
@ -459,14 +465,14 @@ void mac::new_grant_dl(uint32_t cc_idx,
}
// Assert DL HARQ entity
if (dl_harq.at(cc_idx) == nullptr) {
Error("HARQ entity %d has not been created\n", cc_idx);
Error("HARQ entity %d has not been created", cc_idx);
return;
}
dl_harq.at(cc_idx)->new_grant_dl(grant, action);
} else {
/* Discard */
Info("Discarding dci in CC %d, RNTI=0x%x\n", cc_idx, grant.rnti);
Info("Discarding dci in CC %d, RNTI=0x%x", cc_idx, grant.rnti);
}
}
@ -480,7 +486,7 @@ void mac::process_pdus()
}
});
if (not ret.first) {
Warning("Failed to dispatch mac::%s task to stack thread\n", __func__);
Warning("Failed to dispatch mac::%s task to stack thread", __func__);
}
}
@ -517,7 +523,7 @@ void mac::new_grant_ul(uint32_t cc_idx,
// Assert UL HARQ entity
if (ul_harq.at(cc_idx) == nullptr) {
Error("HARQ entity %d has not been created\n", cc_idx);
Error("HARQ entity %d has not been created", cc_idx);
return;
}
@ -557,10 +563,10 @@ void mac::setup_timers(int time_alignment_timer)
void mac::timer_expired(uint32_t timer_id)
{
if (timer_id == timer_alignment.id()) {
Info("Time Alignment Timer expired\n");
Info("Time Alignment Timer expired");
timer_alignment_expire();
} else {
Warning("Received callback from unknown timer_id=%d\n", timer_id);
Warning("Received callback from unknown timer_id=%d", timer_id);
}
}
@ -599,13 +605,13 @@ void mac::set_mbsfn_config(uint32_t nof_mbsfn_services)
// Only reset SR config
void mac::set_config(sr_cfg_t& sr_cfg)
{
Info("Setting SR configuration\n");
Info("Setting SR configuration");
sr_procedure.set_config(sr_cfg);
}
void mac::set_config(mac_cfg_t& mac_cfg)
{
Info("Setting configuration\n");
Info("Setting configuration");
// Set configuration for each module in MAC
bsr_procedure.set_config(mac_cfg.bsr_cfg);
phr_procedure.set_config(mac_cfg.phr_cfg);
@ -634,7 +640,7 @@ void mac::setup_lcid(uint32_t lcid, uint32_t lcg, uint32_t priority, int PBR_x_t
void mac::setup_lcid(const logical_channel_config_t& config)
{
Info("Logical Channel Setup: LCID=%d, LCG=%d, priority=%d, PBR=%d, BSD=%dms, bucket_size=%d\n",
Info("Logical Channel Setup: LCID=%d, LCG=%d, priority=%d, PBR=%d, BSD=%dms, bucket_size=%d",
config.lcid,
config.lcg,
config.priority,
@ -681,7 +687,7 @@ void mac::get_metrics(mac_metrics_t m[SRSLTE_MAX_CARRIERS])
dl_avg_ret /= dl_avg_ret_count;
}
Info("DL retx: %.2f \%%, perpkt: %.2f, UL retx: %.2f \%% perpkt: %.2f\n",
Info("DL retx: %.2f \%%, perpkt: %.2f, UL retx: %.2f \%% perpkt: %.2f",
rx_pkts ? ((float)100 * rx_errors / rx_pkts) : 0.0f,
dl_avg_ret,
tx_pkts ? ((float)100 * tx_errors / tx_pkts) : 0.0f,

@ -18,9 +18,7 @@ using namespace asn1::rrc;
namespace srsue {
mac_nr::mac_nr(srslte::ext_task_sched_handle task_sched_) :
pool(srslte::byte_buffer_pool::get_instance()),
log_h("MAC"),
task_sched(task_sched_)
pool(srslte::byte_buffer_pool::get_instance()), log_h("MAC"), task_sched(task_sched_)
{
tx_buffer = srslte::allocate_unique_buffer(*pool);
rlc_buffer = srslte::allocate_unique_buffer(*pool);
@ -65,7 +63,7 @@ void mac_nr::stop()
// Implement Section 5.9
void mac_nr::reset()
{
Info("Resetting MAC\n");
Info("Resetting MAC");
}
void mac_nr::run_tti(const uint32_t tti)
@ -73,7 +71,7 @@ void mac_nr::run_tti(const uint32_t tti)
log_h->step(tti);
// Step all procedures
Debug("Running MAC tti=%d\n", tti);
Debug("Running MAC tti=%d", tti);
}
uint16_t mac_nr::get_ul_sched_rnti(uint32_t tti)
@ -167,11 +165,11 @@ void mac_nr::get_ul_data(const mac_nr_grant_ul_t& grant, phy_interface_stack_nr:
// Add SDU if RLC has something to tx
if (pdu_len > 0) {
rlc_buffer->N_bytes = pdu_len;
log_h->info_hex(rlc_buffer->msg, rlc_buffer->N_bytes, "Read %d B from RLC\n", rlc_buffer->N_bytes);
log_h->info_hex(rlc_buffer->msg, rlc_buffer->N_bytes, "Read %d B from RLC", rlc_buffer->N_bytes);
// add to MAC PDU and pack
if (tx_pdu.add_sdu(args.drb_lcid, rlc_buffer->msg, rlc_buffer->N_bytes) != SRSLTE_SUCCESS) {
log_h->error("Error packing MAC PDU\n");
log_h->error("Error packing MAC PDU");
}
} else {
break;
@ -181,7 +179,7 @@ void mac_nr::get_ul_data(const mac_nr_grant_ul_t& grant, phy_interface_stack_nr:
// Pack PDU
tx_pdu.pack();
log_h->info_hex(tx_buffer->msg, tx_buffer->N_bytes, "Generated MAC PDU (%d B)\n", tx_buffer->N_bytes);
log_h->info_hex(tx_buffer->msg, tx_buffer->N_bytes, "Generated MAC PDU (%d B)", tx_buffer->N_bytes);
tx_request->data = tx_buffer->msg;
tx_request->tb_len = tx_buffer->N_bytes;
@ -198,7 +196,7 @@ void mac_nr::timer_expired(uint32_t timer_id)
void mac_nr::setup_lcid(const srslte::logical_channel_config_t& config)
{
Info("Logical Channel Setup: LCID=%d, LCG=%d, priority=%d, PBR=%d, BSD=%dms, bucket_size=%d\n",
Info("Logical Channel Setup: LCID=%d, LCG=%d, priority=%d, PBR=%d, BSD=%dms, bucket_size=%d",
config.lcid,
config.lcg,
config.priority,
@ -211,14 +209,14 @@ void mac_nr::setup_lcid(const srslte::logical_channel_config_t& config)
void mac_nr::set_config(const srslte::bsr_cfg_t& bsr_cfg)
{
Info("BSR config periodic timer %d retx timer %d\n", bsr_cfg.periodic_timer, bsr_cfg.retx_timer);
Warning("Not handling BSR config yet\n");
Info("BSR config periodic timer %d retx timer %d", bsr_cfg.periodic_timer, bsr_cfg.retx_timer);
Warning("Not handling BSR config yet");
}
void mac_nr::set_config(const srslte::sr_cfg_t& sr_cfg)
{
Info("Scheduling Request Config DSR tansmax %d\n", sr_cfg.dsr_transmax);
Warning("Not Scheduling Request Config yet\n");
Info("Scheduling Request Config DSR tansmax %d", sr_cfg.dsr_transmax);
Warning("Not Scheduling Request Config yet");
}
void mac_nr::get_metrics(mac_metrics_t m[SRSLTE_MAX_CARRIERS]) {}
@ -237,14 +235,14 @@ void mac_nr::process_pdus()
void mac_nr::handle_pdu(srslte::unique_byte_buffer_t pdu)
{
log_h->info_hex(pdu->msg, pdu->N_bytes, "Handling MAC PDU (%d B)\n", pdu->N_bytes);
log_h->info_hex(pdu->msg, pdu->N_bytes, "Handling MAC PDU (%d B)", pdu->N_bytes);
rx_pdu.init_rx();
rx_pdu.unpack(pdu->msg, pdu->N_bytes);
for (uint32_t i = 0; i < rx_pdu.get_num_subpdus(); ++i) {
srslte::mac_nr_sch_subpdu subpdu = rx_pdu.get_subpdu(i);
log_h->info("Handling subPDU %d/%d: lcid=%d, sdu_len=%d\n",
log_h->info("Handling subPDU %d/%d: lcid=%d, sdu_len=%d",
i,
rx_pdu.get_num_subpdus(),
subpdu.get_lcid(),

@ -10,10 +10,10 @@
*
*/
#define Error(fmt, ...) log_h->error(fmt, ##__VA_ARGS__)
#define Warning(fmt, ...) log_h->warning(fmt, ##__VA_ARGS__)
#define Info(fmt, ...) log_h->info(fmt, ##__VA_ARGS__)
#define Debug(fmt, ...) log_h->debug(fmt, ##__VA_ARGS__)
#define Error(fmt, ...) logger.error(fmt, ##__VA_ARGS__)
#define Warning(fmt, ...) logger.warning(fmt, ##__VA_ARGS__)
#define Info(fmt, ...) logger.info(fmt, ##__VA_ARGS__)
#define Debug(fmt, ...) logger.debug(fmt, ##__VA_ARGS__)
#include "srsue/hdr/stack/mac/mux.h"
#include "srsue/hdr/stack/mac/mac.h"
@ -23,7 +23,8 @@
namespace srsue {
mux::mux(srslte::log_ref log_) : pdu_msg(MAX_NOF_SUBHEADERS, log_), log_h(log_)
mux::mux(srslte::log_ref log_, srslog::basic_logger& logger) :
pdu_msg(MAX_NOF_SUBHEADERS, log_), log_h(log_), logger(logger)
{
msg3_flush();
}
@ -58,7 +59,7 @@ void mux::step()
channel.Bj += channel.PBR; // PBR is in kByte/s, conversion in Byte and ms not needed
}
channel.Bj = SRSLTE_MIN((uint32_t)channel.Bj, channel.bucket_size);
Debug("Update Bj: lcid=%d, Bj=%d\n", channel.lcid, channel.Bj);
Debug("Update Bj: lcid=%d, Bj=%d", channel.lcid, channel.Bj);
}
}
@ -103,7 +104,7 @@ void mux::setup_lcid(const logical_channel_config_t& config)
// warn user if there is another LCID with same prio
for (auto& channel : logical_channels) {
if (channel.priority == config.priority && channel.lcid != config.lcid) {
log_h->warning("LCID %d and %d have same priority.\n", channel.lcid, config.lcid);
logger.warning("LCID %d and %d have same priority.", channel.lcid, config.lcid);
}
}
} else {
@ -139,7 +140,7 @@ void mux::print_logical_channel_state(const std::string& info)
logline += ", sched_len=";
logline += std::to_string(channel.sched_len);
}
log_h->debug("%s\n", logline.c_str());
logger.debug("%s", logline.c_str());
}
srslte::ul_sch_lcid bsr_format_convert(bsr_proc::bsr_format_t format)
@ -169,13 +170,13 @@ uint8_t* mux::pdu_get(srslte::byte_buffer_t* payload, uint32_t pdu_sz)
if (pending_crnti_ce) {
if (pdu_msg.new_subh()) {
if (!pdu_msg.get()->set_c_rnti(pending_crnti_ce)) {
Warning("Pending C-RNTI CE could not be inserted in MAC PDU\n");
Warning("Pending C-RNTI CE could not be inserted in MAC PDU");
}
}
}
} else {
if (pending_crnti_ce) {
Warning("Pending C-RNTI CE was not inserted because message was for CCCH\n");
Warning("Pending C-RNTI CE was not inserted because message was for CCCH");
}
}
pending_crnti_ce = 0;
@ -289,8 +290,8 @@ uint8_t* mux::pdu_get(srslte::byte_buffer_t* payload, uint32_t pdu_sz)
// Generate MAC PDU and save to buffer
uint8_t* ret = pdu_msg.write_packet(log_h);
Info("%s\n", pdu_msg.to_string().c_str());
Debug("Assembled MAC PDU msg size %d/%d bytes\n", pdu_msg.get_pdu_len() - pdu_msg.rem_size(), pdu_sz);
Info("%s", pdu_msg.to_string().c_str());
Debug("Assembled MAC PDU msg size %d/%d bytes", pdu_msg.get_pdu_len() - pdu_msg.rem_size(), pdu_sz);
return ret;
}
@ -315,7 +316,7 @@ bool mux::sched_sdu(logical_channel_config_t* ch, int* sdu_space, int max_sdu_sz
*sdu_space -= sched_len; // UL-SCH subheader size is accounted for in the calling function
Debug("SDU: scheduled lcid=%d, rlc_buffer=%d, allocated=%d\n", ch->lcid, ch->buffer_len, sched_len);
Debug("SDU: scheduled lcid=%d, rlc_buffer=%d, allocated=%d", ch->lcid, ch->buffer_len, sched_len);
ch->buffer_len -= sched_len;
ch->sched_len += sched_len;
@ -338,7 +339,7 @@ uint32_t mux::allocate_sdu(uint32_t lcid, srslte::sch_pdu* pdu_msg, int max_sdu_
int sdu_len = pdu_msg->get()->set_sdu(lcid, requested_sdu_len, rlc);
if (sdu_len > 0) { // new SDU could be added
Debug("SDU: allocated lcid=%d, buffer_state=%d, request_sdu_len=%d, allocated=%d/%d, max_sdu_sz=%d, "
"remaining=%d\n",
"remaining=%d",
lcid,
buffer_state,
requested_sdu_len,
@ -352,7 +353,7 @@ uint32_t mux::allocate_sdu(uint32_t lcid, srslte::sch_pdu* pdu_msg, int max_sdu_
buffer_state = rlc->get_buffer_state(lcid);
} else {
Debug("Couldn't allocate new SDU (buffer_state=%d, requested_sdu_len=%d, sdu_len=%d, sdu_space=%d, "
"remaining=%d, get_sdu_space=%d)\n",
"remaining=%d, get_sdu_space=%d)",
buffer_state,
requested_sdu_len,
sdu_len,
@ -364,7 +365,7 @@ uint32_t mux::allocate_sdu(uint32_t lcid, srslte::sch_pdu* pdu_msg, int max_sdu_
break;
}
} else {
Debug("Couldn't add new MAC subheader (buffer_state=%d, requested_sdu_len=%d, sdu_space=%d, remaining=%d)\n",
Debug("Couldn't add new MAC subheader (buffer_state=%d, requested_sdu_len=%d, sdu_space=%d, remaining=%d)",
buffer_state,
requested_sdu_len,
sdu_space,
@ -378,9 +379,7 @@ uint32_t mux::allocate_sdu(uint32_t lcid, srslte::sch_pdu* pdu_msg, int max_sdu_
void mux::msg3_flush()
{
if (log_h) {
Debug("Msg3 buffer flushed\n");
}
Debug("Msg3 buffer flushed");
msg3_buff.clear();
msg3_has_been_transmitted = false;
msg3_pending = false;
@ -413,7 +412,7 @@ uint8_t* mux::msg3_get(srslte::byte_buffer_t* payload, uint32_t pdu_sz)
if (pdu_sz < msg3_buff.get_tailroom()) {
if (msg3_is_empty()) {
if (!pdu_get(&msg3_buff, pdu_sz)) {
Error("Moving PDU from Mux unit to Msg3 buffer\n");
Error("Moving PDU from Mux unit to Msg3 buffer");
return NULL;
}
msg3_pending = false;
@ -422,7 +421,7 @@ uint8_t* mux::msg3_get(srslte::byte_buffer_t* payload, uint32_t pdu_sz)
msg3_has_been_transmitted = true;
return payload->msg;
} else {
Error("Msg3 size exceeds buffer\n");
Error("Msg3 size exceeds buffer");
return nullptr;
}
}

@ -11,19 +11,12 @@
*/
#include "srsue/hdr/stack/mac/proc_bsr.h"
#include "srslte/common/log_helper.h"
#include "srsue/hdr/stack/mac/mux.h"
namespace srsue {
bsr_proc::bsr_proc() {}
void bsr_proc::init(sr_proc* sr_,
rlc_interface_mac* rlc_,
srslte::log_ref log_h_,
srslte::ext_task_sched_handle* task_sched_)
void bsr_proc::init(sr_proc* sr_, rlc_interface_mac* rlc_, srslte::ext_task_sched_handle* task_sched_)
{
log_h = log_h_;
rlc = rlc_;
sr = sr_;
task_sched = task_sched_;
@ -55,7 +48,7 @@ void bsr_proc::print_state()
n = srslte_print_check(str, 128, n, "%d: %d ", iter.first, iter.second.old_buffer);
}
}
Info("BSR: triggered_bsr_type=%s, LCID QUEUE status: %s\n", bsr_type_tostring(triggered_bsr_type), str);
logger.info("BSR: triggered_bsr_type=%s, LCID QUEUE status: %s", bsr_type_tostring(triggered_bsr_type), str);
}
void bsr_proc::set_trigger(srsue::bsr_proc::triggered_bsr_type_t new_trigger)
@ -64,7 +57,7 @@ void bsr_proc::set_trigger(srsue::bsr_proc::triggered_bsr_type_t new_trigger)
// Trigger SR always when Regular BSR is triggered in the current TTI. Will be cancelled if a grant is received
if (triggered_bsr_type == REGULAR) {
Debug("BSR: Triggering SR procedure\n");
logger.debug("BSR: Triggering SR procedure");
sr->start();
}
}
@ -85,11 +78,11 @@ void bsr_proc::set_config(srslte::bsr_cfg_t& bsr_cfg_)
if (bsr_cfg_.periodic_timer > 0) {
timer_periodic.set(bsr_cfg_.periodic_timer, [this](uint32_t tid) { timer_expired(tid); });
Info("BSR: Configured timer periodic %d ms\n", bsr_cfg_.periodic_timer);
logger.info("BSR: Configured timer periodic %d ms", bsr_cfg_.periodic_timer);
}
if (bsr_cfg_.retx_timer > 0) {
timer_retx.set(bsr_cfg_.retx_timer, [this](uint32_t tid) { timer_expired(tid); });
Info("BSR: Configured timer reTX %d ms\n", bsr_cfg_.retx_timer);
logger.info("BSR: Configured timer reTX %d ms", bsr_cfg_.retx_timer);
}
}
@ -102,16 +95,16 @@ void bsr_proc::timer_expired(uint32_t timer_id)
if (timer_id == timer_periodic.id()) {
if (triggered_bsr_type == NONE) {
set_trigger(PERIODIC);
Debug("BSR: Triggering Periodic BSR\n");
logger.debug("BSR: Triggering Periodic BSR");
}
// retxBSR-Timer
} else if (timer_id == timer_retx.id()) {
// Enable reTx of SR only if periodic timer is not infinity
Debug("BSR: Timer BSR reTX expired, periodic=%d, channel=%d\n", bsr_cfg.periodic_timer, check_any_channel());
logger.debug("BSR: Timer BSR reTX expired, periodic=%d, channel=%d", bsr_cfg.periodic_timer, check_any_channel());
// Triger Regular BSR if UE has available data for transmission on any channel
if (check_any_channel()) {
set_trigger(REGULAR);
Debug("BSR: Triggering BSR reTX\n");
logger.debug("BSR: Triggering BSR reTX");
}
}
}
@ -144,7 +137,7 @@ bool bsr_proc::check_highest_channel()
}
}
if (is_max_priority) {
Debug("BSR: New data for lcid=%d with maximum priority in lcg=%d\n", iter->first, i);
logger.debug("BSR: New data for lcid=%d with maximum priority in lcg=%d", iter->first, i);
return true;
}
}
@ -171,7 +164,7 @@ bool bsr_proc::check_new_data()
if (get_buffer_state_lcg(i) == 0) {
for (std::map<uint32_t, lcid_t>::iterator iter = lcgs[i].begin(); iter != lcgs[i].end(); ++iter) {
if (iter->second.new_buffer > 0) {
Debug("BSR: New data available for lcid=%d\n", iter->first);
logger.debug("BSR: New data available for lcid=%d", iter->first);
return true;
}
}
@ -251,7 +244,7 @@ bool bsr_proc::generate_bsr(bsr_t* bsr, uint32_t pdu_space)
// Restart or Start Periodic timer every time a BSR is generated and transmitted in an UL grant
if (timer_periodic.duration() && bsr->format != TRUNC_BSR) {
timer_periodic.run();
Debug("BSR: Started periodicBSR-Timer\n");
logger.debug("BSR: Started periodicBSR-Timer");
}
// reset trigger to avoid another BSR in the next UL grant
triggered_bsr_type = NONE;
@ -299,7 +292,7 @@ void bsr_proc::step(uint32_t tti)
// Regular BSR triggered if new data arrives or channel with high priority has new data
if (check_new_data() || check_highest_channel()) {
Debug("BSR: Triggering Regular BSR tti=%d\n", tti);
logger.debug("BSR: Triggering Regular BSR tti=%d", tti);
set_trigger(REGULAR);
}
@ -350,13 +343,13 @@ bool bsr_proc::need_to_send_bsr_on_ul_grant(uint32_t grant_size, uint32_t total_
}
// Cancel SR if an Uplink grant is received
Debug("BSR: Cancelling SR procedure due to uplink grant\n");
logger.debug("BSR: Cancelling SR procedure due to uplink grant");
sr->reset();
// Restart or Start ReTX timer upon indication of a grant
if (timer_retx.duration()) {
timer_retx.run();
Debug("BSR: Started retxBSR-Timer\n");
logger.debug("BSR: Started retxBSR-Timer");
}
return send_bsr;
}
@ -392,7 +385,7 @@ void bsr_proc::setup_lcid(uint32_t lcid, uint32_t new_lcg, uint32_t priority)
lcgs[new_lcg][lcid].priority = priority;
lcgs[new_lcg][lcid].old_buffer = 0;
} else {
Error("BSR: Invalid lcg=%d for lcid=%d\n", new_lcg, lcid);
logger.error("BSR: Invalid lcg=%d for lcid=%d", new_lcg, lcid);
}
}

@ -10,10 +10,10 @@
*
*/
#define Error(fmt, ...) log_h->error(fmt, ##__VA_ARGS__)
#define Warning(fmt, ...) log_h->warning(fmt, ##__VA_ARGS__)
#define Info(fmt, ...) log_h->info(fmt, ##__VA_ARGS__)
#define Debug(fmt, ...) log_h->debug(fmt, ##__VA_ARGS__)
#define Error(fmt, ...) logger.error(fmt, ##__VA_ARGS__)
#define Warning(fmt, ...) logger.warning(fmt, ##__VA_ARGS__)
#define Info(fmt, ...) logger.info(fmt, ##__VA_ARGS__)
#define Debug(fmt, ...) logger.debug(fmt, ##__VA_ARGS__)
#include "srsue/hdr/stack/mac/proc_phr.h"
#include "srslte/interfaces/ue_interfaces.h"
@ -22,17 +22,16 @@
namespace srsue {
phr_proc::phr_proc()
phr_proc::phr_proc(srslog::basic_logger& logger) : logger(logger)
{
initiated = false;
last_pathloss_db = 0;
phr_cfg = {};
}
void phr_proc::init(phy_interface_mac_lte* phy_h_, srslte::log_ref log_h_, srslte::ext_task_sched_handle* task_sched_)
void phr_proc::init(phy_interface_mac_lte* phy_h_, srslte::ext_task_sched_handle* task_sched_)
{
phy_h = phy_h_;
log_h = log_h_;
task_sched = task_sched_;
initiated = true;
@ -63,13 +62,13 @@ void phr_proc::set_config(srslte::phr_cfg_t& cfg)
timer_periodic.set(phr_cfg.periodic_timer, [this](uint32_t tid) { timer_expired(tid); });
timer_periodic.run();
phr_is_triggered = true;
Info("PHR: Configured timer periodic %d ms\n", phr_cfg.periodic_timer);
Info("PHR: Configured timer periodic %d ms", phr_cfg.periodic_timer);
}
if (phr_cfg.prohibit_timer > 0) {
timer_prohibit.set(phr_cfg.prohibit_timer, [this](uint32_t tid) { timer_expired(tid); });
timer_prohibit.run();
Info("PHR: Configured timer prohibit %d ms\n", phr_cfg.prohibit_timer);
Info("PHR: Configured timer prohibit %d ms", phr_cfg.prohibit_timer);
phr_is_triggered = true;
}
}
@ -102,21 +101,21 @@ void phr_proc::start_periodic_timer()
void phr_proc::timer_expired(uint32_t timer_id)
{
if (!phr_cfg.enabled) {
Warning("PHR: %s timer triggered but PHR has been disabled\n",
Warning("PHR: %s timer triggered but PHR has been disabled",
timer_id == timer_periodic.id() ? "Periodic" : "Prohibit");
return;
}
if (timer_id == timer_periodic.id()) {
timer_periodic.run();
Debug("PHR: Triggered by timer periodic (timer expired).\n");
Debug("PHR: Triggered by timer periodic (timer expired).");
phr_is_triggered = true;
} else if (timer_id == timer_prohibit.id()) {
if (pathloss_changed()) {
Info("PHR: Triggered by pathloss difference. cur_pathloss_db=%d (timer expired)\n", last_pathloss_db);
Info("PHR: Triggered by pathloss difference. cur_pathloss_db=%d (timer expired)", last_pathloss_db);
phr_is_triggered = true;
}
} else {
log_h->warning("Received timer callback from unknown timer_id=%d\n", timer_id);
logger.warning("Received timer callback from unknown timer_id=%d", timer_id);
}
}
@ -124,7 +123,7 @@ void phr_proc::step()
{
if (phr_cfg.enabled && initiated) {
if (pathloss_changed() && timer_prohibit.is_expired()) {
Info("PHR: Triggered by pathloss difference. cur_pathloss_db=%d\n", last_pathloss_db);
Info("PHR: Triggered by pathloss difference. cur_pathloss_db=%d", last_pathloss_db);
phr_is_triggered = true;
}
}
@ -138,7 +137,7 @@ bool phr_proc::generate_phr_on_ul_grant(float* phr)
*phr = phy_h->get_phr();
}
Debug("PHR: Generating PHR=%f\n", phr ? *phr : 0.0);
Debug("PHR: Generating PHR=%f", phr ? *phr : 0.0);
timer_periodic.run();
timer_prohibit.run();

@ -29,9 +29,10 @@ const char* state_str[] = {"RA: INIT: ",
"RA: WaitComplt: ",
"RA: Complt: "};
#define rError(fmt, ...) Error("%s" fmt, state_str[state], ##__VA_ARGS__)
#define rInfo(fmt, ...) Info("%s" fmt, state_str[state], ##__VA_ARGS__)
#define rDebug(fmt, ...) Debug("%s" fmt, state_str[state], ##__VA_ARGS__)
#define rError(fmt, ...) logger.error("%s" fmt, state_str[state], ##__VA_ARGS__)
#define rInfo(fmt, ...) logger.info("%s" fmt, state_str[state], ##__VA_ARGS__)
#define rDebug(fmt, ...) logger.debug("%s" fmt, state_str[state], ##__VA_ARGS__)
#define rWarning(fmt, ...) logger.warning("%s" fmt, state_str[state], ##__VA_ARGS__)
// Table 7.2-1. Backoff Parameter values
uint32_t backoff_table[16] = {0, 10, 20, 30, 40, 60, 80, 120, 160, 240, 320, 480, 960, 960, 960, 960};
@ -42,14 +43,12 @@ int delta_preamble_db_table[5] = {0, 0, -3, -3, 8};
// Initializes memory and pointers to other objects
void ra_proc::init(phy_interface_mac_lte* phy_h_,
rrc_interface_mac* rrc_,
srslte::log_ref log_h_,
mac_interface_rrc::ue_rnti_t* rntis_,
srslte::timer_handler::unique_timer* time_alignment_timer_,
mux* mux_unit_,
srslte::ext_task_sched_handle* task_sched_)
{
phy_h = phy_h_;
log_h = log_h_;
rntis = rntis_;
mux_unit = mux_unit_;
rrc = rrc_;
@ -158,14 +157,14 @@ void ra_proc::state_pdcch_setup()
if (info.is_transmitted) {
ra_tti = info.tti_ra;
ra_rnti = 1 + (ra_tti % 10) + (10 * info.f_id);
rInfo("seq=%d, ra-rnti=0x%x, ra-tti=%d, f_id=%d\n", sel_preamble.load(), ra_rnti, info.tti_ra, info.f_id);
rInfo("seq=%d, ra-rnti=0x%x, ra-tti=%d, f_id=%d", sel_preamble.load(), ra_rnti, info.tti_ra, info.f_id);
srslte::console(
"Random Access Transmission: seq=%d, tti=%d, ra-rnti=0x%x\n", sel_preamble.load(), info.tti_ra, ra_rnti);
rar_window_st = ra_tti + 3;
rntis->rar_rnti = ra_rnti;
state = RESPONSE_RECEPTION;
} else {
rDebug("preamble not yet transmitted\n");
rDebug("preamble not yet transmitted");
}
}
@ -178,7 +177,7 @@ void ra_proc::state_response_reception(uint32_t tti)
if (!rar_received) {
uint32_t interval = srslte_tti_interval(tti, ra_tti + 3 + rach_cfg.responseWindowSize - 1);
if (interval > 0 && interval < 100) {
Error("RA response not received within the response window\n");
logger.error("RA response not received within the response window");
response_error();
}
}
@ -215,7 +214,7 @@ void ra_proc::state_contention_resolution()
// Once Msg3 is transmitted, start contention resolution timer
if (mux_unit->msg3_is_transmitted() && !contention_resolution_timer.is_running()) {
// Start contention resolution timer
rInfo("Starting ContentionResolutionTimer=%d ms\n", contention_resolution_timer.duration());
rInfo("Starting ContentionResolutionTimer=%d ms", contention_resolution_timer.duration());
contention_resolution_timer.run();
}
}
@ -239,15 +238,14 @@ void ra_proc::notify_ra_completed(uint32_t task_id)
{
if (current_task_id == task_id) {
if (state != WAITING_COMPLETION) {
rError("Received unexpected notification of RA completion\n");
rError("Received unexpected notification of RA completion");
} else {
rInfo("RA waiting procedure completed\n");
rInfo("RA waiting procedure completed");
}
state = IDLE;
} else {
rError("Received old notification of RA completition (old task_id=%d, current_task_id=%d)\n",
task_id,
current_task_id);
rError(
"Received old notification of RA completition (old task_id=%d, current_task_id=%d)", task_id, current_task_id);
}
}
@ -295,7 +293,7 @@ void ra_proc::resource_selection()
// randomly choose preamble from [0 nof_groupA_preambles)
sel_preamble = rand() % rach_cfg.nof_groupA_preambles;
} else {
rError("Selected group preamble A but nof_groupA_preambles=0\n");
rError("Selected group preamble A but nof_groupA_preambles=0");
state = IDLE;
return;
}
@ -304,7 +302,7 @@ void ra_proc::resource_selection()
// randomly choose preamble from [nof_groupA_preambles nof_groupB_preambles)
sel_preamble = rach_cfg.nof_groupA_preambles + rand() % nof_groupB_preambles;
} else {
rError("Selected group preamble B but nof_groupA_preambles=0\n");
rError("Selected group preamble B but nof_groupA_preambles=0");
state = IDLE;
return;
}
@ -312,7 +310,7 @@ void ra_proc::resource_selection()
sel_maskIndex = 0;
}
rDebug("Selected preambleIndex=%d maskIndex=%d GroupA=%d, GroupB=%d\n",
rDebug("Selected preambleIndex=%d maskIndex=%d GroupA=%d, GroupB=%d",
sel_preamble.load(),
sel_maskIndex,
rach_cfg.nof_groupA_preambles,
@ -347,16 +345,16 @@ void ra_proc::process_timeadv_cmd(uint32_t ta)
if (time_alignment_timer->is_running()) {
time_alignment_timer->run();
}
Debug("Applying RAR TA CMD %d\n", ta);
logger.debug("Applying RAR TA CMD %d", ta);
} else {
// Preamble selected by UE MAC
if (!time_alignment_timer->is_running()) {
phy_h->set_timeadv_rar(ta);
time_alignment_timer->run();
Debug("Applying RAR TA CMD %d\n", ta);
logger.debug("Applying RAR TA CMD %d", ta);
} else {
// Ignore TA CMD
Warning("Ignoring RAR TA CMD because timeAlignmentTimer still running\n");
logger.warning("Ignoring RAR TA CMD because timeAlignmentTimer still running");
}
}
}
@ -369,7 +367,7 @@ void ra_proc::new_grant_dl(mac_interface_phy_lte::mac_grant_dl_t grant, mac_inte
bzero(action, sizeof(mac_interface_phy_lte::tb_action_dl_t));
if (grant.tb[0].tbs < MAX_RAR_PDU_LEN) {
rDebug("DL dci found RA-RNTI=%d\n", ra_rnti);
rDebug("DL dci found RA-RNTI=%d", ra_rnti);
action->tb[0].enabled = true;
action->tb[0].payload = rar_pdu_buffer;
action->tb[0].rv = grant.tb[0].rv;
@ -379,7 +377,7 @@ void ra_proc::new_grant_dl(mac_interface_phy_lte::mac_grant_dl_t grant, mac_inte
srslte_softbuffer_rx_reset(&softbuffer_rar);
}
} else {
rError("Received RAR dci exceeds buffer length (%d>%d)\n", grant.tb[0].tbs, MAX_RAR_PDU_LEN);
rError("Received RAR dci exceeds buffer length (%d>%d)", grant.tb[0].tbs, int(MAX_RAR_PDU_LEN));
}
}
@ -396,10 +394,10 @@ void ra_proc::tb_decoded_ok(const uint8_t cc_idx, const uint32_t tti)
rar_pdu_msg.init_rx(rar_grant_nbytes);
if (rar_pdu_msg.parse_packet(rar_pdu_buffer) != SRSLTE_SUCCESS) {
rError("Error decoding RAR PDU\n");
rError("Error decoding RAR PDU");
}
rDebug("RAR decoded successfully TBS=%d\n", rar_grant_nbytes);
rDebug("RAR decoded successfully TBS=%d", rar_grant_nbytes);
// Set Backoff parameter
if (rar_pdu_msg.has_backoff()) {
@ -427,7 +425,7 @@ void ra_proc::tb_decoded_ok(const uint8_t cc_idx, const uint32_t tti)
current_ta = rar_pdu_msg.get()->get_ta_cmd();
rInfo("RAPID=%d, TA=%d, T-CRNTI=0x%x\n",
rInfo("RAPID=%d, TA=%d, T-CRNTI=0x%x",
sel_preamble.load(),
rar_pdu_msg.get()->get_ta_cmd(),
rar_pdu_msg.get()->get_temp_crnti());
@ -445,7 +443,7 @@ void ra_proc::tb_decoded_ok(const uint8_t cc_idx, const uint32_t tti)
// If we have a C-RNTI, tell Mux unit to append C-RNTI CE if no CCCH SDU transmission
if (transmitted_crnti) {
rInfo("Appending C-RNTI MAC CE 0x%x in next transmission\n", transmitted_crnti.load());
rInfo("Appending C-RNTI MAC CE 0x%x in next transmission", transmitted_crnti.load());
mux_unit->append_crnti_ce_next_tx(transmitted_crnti);
}
}
@ -454,7 +452,7 @@ void ra_proc::tb_decoded_ok(const uint8_t cc_idx, const uint32_t tti)
transmitted_contention_id = rntis->contention_id;
task_queue.push([this]() {
rDebug("Waiting for Contention Resolution\n");
rDebug("Waiting for Contention Resolution");
state = CONTENTION_RESOLUTION;
});
} else {
@ -463,7 +461,7 @@ void ra_proc::tb_decoded_ok(const uint8_t cc_idx, const uint32_t tti)
}
} else {
if (rar_pdu_msg.get()->has_rapid()) {
rInfo("Found RAR for preamble %d\n", rar_pdu_msg.get()->get_rapid());
rInfo("Found RAR for preamble %d", rar_pdu_msg.get()->get_rapid());
}
}
}
@ -478,7 +476,7 @@ void ra_proc::response_error()
preambleTransmissionCounter++;
contention_resolution_timer.stop();
if (preambleTransmissionCounter >= rach_cfg.preambleTransMax + 1) {
rError("Maximum number of transmissions reached (%d)\n", rach_cfg.preambleTransMax);
rError("Maximum number of transmissions reached (%d)", rach_cfg.preambleTransMax);
rrc->ra_problem();
state = IDLE;
} else {
@ -489,10 +487,10 @@ void ra_proc::response_error()
backoff_interval = 0;
}
if (backoff_interval) {
rDebug("Backoff wait interval %d\n", backoff_interval);
rDebug("Backoff wait interval %d", backoff_interval);
state = BACKOFF_WAIT;
} else {
rInfo("Transmitting new preamble immediately (%d/%d)\n", preambleTransmissionCounter, rach_cfg.preambleTransMax);
rInfo("Transmitting new preamble immediately (%d/%d)", preambleTransmissionCounter, rach_cfg.preambleTransMax);
resource_selection();
}
}
@ -517,7 +515,7 @@ void ra_proc::complete()
rrc->ra_completed();
srslte::console("Random Access Complete. c-rnti=0x%x, ta=%d\n", rntis->crnti, current_ta);
rInfo("Random Access Complete. c-rnti=0x%x, ta=%d\n", rntis->crnti, current_ta);
rInfo("Random Access Complete. c-rnti=0x%x, ta=%d", rntis->crnti, current_ta);
state = START_WAIT_COMPLETION;
}
@ -527,10 +525,10 @@ void ra_proc::start_mac_order(uint32_t msg_len_bits)
if (state == IDLE) {
started_by_pdcch = false;
new_ra_msg_len = msg_len_bits;
rInfo("Starting PRACH by MAC order\n");
rInfo("Starting PRACH by MAC order");
initialization();
} else {
Warning("Trying to start PRACH by MAC order in invalid state (%s)\n", state_str[state]);
logger.warning("Trying to start PRACH by MAC order in invalid state (%s)", state_str[state]);
}
}
@ -538,17 +536,17 @@ void ra_proc::start_pdcch_order()
{
if (state == IDLE) {
started_by_pdcch = true;
rInfo("Starting PRACH by PDCCH order\n");
rInfo("Starting PRACH by PDCCH order");
initialization();
} else {
Warning("Trying to start PRACH by MAC order in invalid state (%s)\n", state_str[state]);
logger.warning("Trying to start PRACH by MAC order in invalid state (%s)", state_str[state]);
}
}
// Contention Resolution Timer is expired (Section 5.1.5)
void ra_proc::timer_expired(uint32_t timer_id)
{
rInfo("Contention Resolution Timer expired. Stopping PDCCH Search and going to Response Error\n");
rInfo("Contention Resolution Timer expired. Stopping PDCCH Search and going to Response Error");
response_error();
}
@ -572,10 +570,10 @@ bool ra_proc::contention_resolution_id_received_unsafe(uint64_t rx_contention_id
{
bool uecri_successful = false;
rDebug("MAC PDU Contains Contention Resolution ID CE\n");
rDebug("MAC PDU Contains Contention Resolution ID CE");
if (state != CONTENTION_RESOLUTION) {
rError("Received contention resolution in wrong state. Aborting.\n");
rError("Received contention resolution in wrong state. Aborting.");
response_error();
}
@ -587,7 +585,7 @@ bool ra_proc::contention_resolution_id_received_unsafe(uint64_t rx_contention_id
uecri_successful = true;
complete();
} else {
rInfo("Transmitted UE Contention Id differs from received Contention ID (0x%" PRIx64 " != 0x%" PRIx64 ")\n",
rInfo("Transmitted UE Contention Id differs from received Contention ID (0x%" PRIx64 " != 0x%" PRIx64 ")",
transmitted_contention_id.load(),
rx_contention_id);
@ -606,9 +604,9 @@ void ra_proc::pdcch_to_crnti(bool is_new_uplink_transmission)
{
task_queue.push([this, is_new_uplink_transmission]() {
// TS 36.321 Section 5.1.5
rDebug("PDCCH to C-RNTI received %s new UL transmission\n", is_new_uplink_transmission ? "with" : "without");
rDebug("PDCCH to C-RNTI received %s new UL transmission", is_new_uplink_transmission ? "with" : "without");
if ((!started_by_pdcch && is_new_uplink_transmission) || started_by_pdcch) {
rDebug("PDCCH for C-RNTI received\n");
rDebug("PDCCH for C-RNTI received");
contention_resolution_timer.stop();
complete();
}
@ -626,14 +624,14 @@ void ra_proc::update_rar_window(int& rar_window_start, int& rar_window_length)
rar_window_length = rach_cfg.responseWindowSize;
rar_window_start = rar_window_st;
}
rDebug("rar_window_start=%d, rar_window_length=%d\n", rar_window_start, rar_window_length);
rDebug("rar_window_start=%d, rar_window_length=%d", rar_window_start, rar_window_length);
}
// Restart timer at each Msg3 HARQ retransmission (5.1.5)
void ra_proc::harq_retx()
{
task_queue.push([this]() {
rInfo("Restarting ContentionResolutionTimer=%d ms\n", contention_resolution_timer.duration());
rInfo("Restarting ContentionResolutionTimer=%d ms", contention_resolution_timer.duration());
contention_resolution_timer.run();
});
}
@ -642,7 +640,7 @@ void ra_proc::harq_retx()
void ra_proc::harq_max_retx()
{
task_queue.push([this]() {
Warning("Contention Resolution is considered not successful. Stopping PDCCH Search and going to Response Error\n");
rWarning("Contention Resolution is considered not successful. Stopping PDCCH Search and going to Response Error");
response_error();
});
}

@ -10,24 +10,23 @@
*
*/
#define Error(fmt, ...) log_h->error(fmt, ##__VA_ARGS__)
#define Warning(fmt, ...) log_h->warning(fmt, ##__VA_ARGS__)
#define Info(fmt, ...) log_h->info(fmt, ##__VA_ARGS__)
#define Debug(fmt, ...) log_h->debug(fmt, ##__VA_ARGS__)
#define Error(fmt, ...) logger.error(fmt, ##__VA_ARGS__)
#define Warning(fmt, ...) logger.warning(fmt, ##__VA_ARGS__)
#define Info(fmt, ...) logger.info(fmt, ##__VA_ARGS__)
#define Debug(fmt, ...) logger.debug(fmt, ##__VA_ARGS__)
#include "srsue/hdr/stack/mac/proc_sr.h"
#include "srsue/hdr/stack/mac/proc_ra.h"
namespace srsue {
sr_proc::sr_proc()
sr_proc::sr_proc(srslog::basic_logger& logger) : logger(logger)
{
initiated = false;
}
void sr_proc::init(ra_proc* ra_, phy_interface_mac_lte* phy_h_, rrc_interface_mac* rrc_, srslte::log_ref log_h_)
void sr_proc::init(ra_proc* ra_, phy_interface_mac_lte* phy_h_, rrc_interface_mac* rrc_)
{
log_h = log_h_;
rrc = rrc_;
ra = ra_;
phy_h = phy_h_;
@ -43,7 +42,7 @@ void sr_proc::reset()
bool sr_proc::need_tx(uint32_t tti)
{
int last_tx_tti = phy_h->sr_last_tx_tti();
Debug("SR: need_tx(): last_tx_tti=%d, tti=%d\n", last_tx_tti, tti);
Debug("SR: need_tx(): last_tx_tti=%d, tti=%d", last_tx_tti, tti);
if (last_tx_tti >= 0) {
if (tti > (uint32_t)last_tx_tti) {
if (tti - last_tx_tti > 8) {
@ -62,11 +61,11 @@ bool sr_proc::need_tx(uint32_t tti)
void sr_proc::set_config(srslte::sr_cfg_t& cfg)
{
if (cfg.enabled && cfg.dsr_transmax == 0) {
Error("Zero is an invalid value for dsr-TransMax (n4, n8, n16, n32, n64 are supported). Disabling SR.\n");
Error("Zero is an invalid value for dsr-TransMax (n4, n8, n16, n32, n64 are supported). Disabling SR.");
return;
}
if (cfg.enabled) {
Info("SR: Set dsr_transmax=%d\n", sr_cfg.dsr_transmax);
Info("SR: Set dsr_transmax=%d", sr_cfg.dsr_transmax);
}
sr_cfg = cfg;
}
@ -79,12 +78,12 @@ void sr_proc::step(uint32_t tti)
if (sr_counter < sr_cfg.dsr_transmax) {
if (sr_counter == 0 || need_tx(tti)) {
sr_counter++;
Info("SR: Signalling PHY sr_counter=%d\n", sr_counter);
Info("SR: Signalling PHY sr_counter=%d", sr_counter);
phy_h->sr_send();
}
} else {
if (need_tx(tti)) {
Info("SR: Releasing PUCCH/SRS resources, sr_counter=%d, dsr_transmax=%d\n",
Info("SR: Releasing PUCCH/SRS resources, sr_counter=%d, dsr_transmax=%d",
sr_counter,
sr_cfg.dsr_transmax);
srslte::console("Scheduling request failed: releasing RRC connection...\n");
@ -94,7 +93,7 @@ void sr_proc::step(uint32_t tti)
}
}
} else if (ra->is_idle()) {
Info("SR: PUCCH not configured. Starting RA procedure\n");
Info("SR: PUCCH not configured. Starting RA procedure");
ra->start_mac_order();
reset();
}

@ -10,10 +10,10 @@
*
*/
#define Error(fmt, ...) log_h->error(fmt, ##__VA_ARGS__)
#define Warning(fmt, ...) log_h->warning(fmt, ##__VA_ARGS__)
#define Info(fmt, ...) log_h->info(fmt, ##__VA_ARGS__)
#define Debug(fmt, ...) log_h->debug(fmt, ##__VA_ARGS__)
#define Error(fmt, ...) logger.error(fmt, ##__VA_ARGS__)
#define Warning(fmt, ...) logger.warning(fmt, ##__VA_ARGS__)
#define Info(fmt, ...) logger.info(fmt, ##__VA_ARGS__)
#define Debug(fmt, ...) logger.debug(fmt, ##__VA_ARGS__)
#include "srsue/hdr/stack/mac/ul_harq.h"
#include "srslte/common/interfaces_common.h"
@ -24,14 +24,12 @@
namespace srsue {
ul_harq_entity::ul_harq_entity(const uint8_t cc_idx_) : proc(SRSLTE_MAX_HARQ_PROC), cc_idx(cc_idx_) {}
ul_harq_entity::ul_harq_entity(const uint8_t cc_idx_) :
proc(SRSLTE_MAX_HARQ_PROC), logger(srslog::fetch_basic_logger("MAC")), cc_idx(cc_idx_)
{}
bool ul_harq_entity::init(srslte::log_ref log_h_,
mac_interface_rrc_common::ue_rnti_t* rntis_,
ra_proc* ra_procedure_,
mux* mux_unit_)
bool ul_harq_entity::init(mac_interface_rrc_common::ue_rnti_t* rntis_, ra_proc* ra_procedure_, mux* mux_unit_)
{
log_h = log_h_;
mux_unit = mux_unit_;
ra_procedure = ra_procedure_;
rntis = rntis_;
@ -76,7 +74,7 @@ void ul_harq_entity::new_grant_ul(mac_interface_phy_lte::mac_grant_ul_t grant,
bzero(action, sizeof(mac_interface_phy_lte::tb_action_ul_t));
if (grant.pid >= SRSLTE_MAX_HARQ_PROC) {
Error("Invalid PID: %d\n", grant.pid);
Error("Invalid PID: %d", grant.pid);
return;
}
if (grant.rnti == rntis->crnti || grant.rnti == rntis->temp_rnti || SRSLTE_RNTI_ISRAR(grant.rnti)) {
@ -89,17 +87,17 @@ void ul_harq_entity::new_grant_ul(mac_interface_phy_lte::mac_grant_ul_t grant,
grant.tb.ndi = proc[grant.pid].get_ndi();
proc[grant.pid].new_grant_ul(grant, action);
} else {
Info("Not implemented\n");
Info("Not implemented");
}
} else {
Info("Received grant for unknown rnti=0x%x\n", grant.rnti);
Info("Received grant for unknown rnti=0x%x", grant.rnti);
}
}
int ul_harq_entity::get_current_tbs(uint32_t pid)
{
if (pid >= SRSLTE_MAX_HARQ_PROC) {
Error("Invalid PID: %d\n", pid);
Error("Invalid PID: %d", pid);
return 0;
}
return proc[pid].get_current_tbs();
@ -110,7 +108,7 @@ float ul_harq_entity::get_average_retx()
return average_retx;
}
ul_harq_entity::ul_harq_process::ul_harq_process()
ul_harq_entity::ul_harq_process::ul_harq_process() : logger(srslog::fetch_basic_logger("MAC"))
{
pdu_ptr = NULL;
payload_buffer = NULL;
@ -136,18 +134,17 @@ ul_harq_entity::ul_harq_process::~ul_harq_process()
bool ul_harq_entity::ul_harq_process::init(uint32_t pid_, ul_harq_entity* parent)
{
if (srslte_softbuffer_tx_init(&softbuffer, 110)) {
ERROR("Error initiating soft buffer\n");
ERROR("Error initiating soft buffer");
return false;
}
harq_entity = parent;
log_h = harq_entity->log_h;
is_initiated = true;
pid = pid_;
payload_buffer = std::unique_ptr<byte_buffer_t>(new byte_buffer_t);
if (!payload_buffer) {
Error("Allocating memory\n");
Error("Allocating memory");
return false;
}
pdu_ptr = payload_buffer->msg;
@ -187,7 +184,7 @@ void ul_harq_entity::ul_harq_process::new_grant_ul(mac_interface_phy_lte::mac_gr
// Check maximum retransmissions, do not consider last retx ACK
if (current_tx_nb >= max_retx && !grant.hi_value) {
Info("UL %d: Maximum number of ReTX reached (%d). Discarding TB.\n", pid, max_retx);
Info("UL %d: Maximum number of ReTX reached (%d). Discarding TB.", pid, max_retx);
if (grant.rnti == harq_entity->rntis->temp_rnti) {
harq_entity->ra_procedure->harq_max_retx();
}
@ -200,8 +197,7 @@ void ul_harq_entity::ul_harq_process::new_grant_ul(mac_interface_phy_lte::mac_gr
// Reset HARQ process if TB has changed
if (harq_feedback && has_grant() && grant.tb.ndi_present) {
if (grant.tb.tbs != cur_grant.tb.tbs && cur_grant.tb.tbs > 0 && grant.tb.tbs > 0) {
Debug(
"UL %d: Reset due to change of dci size last_grant=%d, new_grant=%d\n", pid, cur_grant.tb.tbs, grant.tb.tbs);
Debug("UL %d: Reset due to change of dci size last_grant=%d, new_grant=%d", pid, cur_grant.tb.tbs, grant.tb.tbs);
reset();
}
}
@ -223,22 +219,22 @@ void ul_harq_entity::ul_harq_process::new_grant_ul(mac_interface_phy_lte::mac_gr
// Check buffer size
if (grant.tb.tbs > payload_buffer_len) {
Error("Grant size exceeds payload buffer size (%d > %d)\n", grant.tb.tbs, payload_buffer_len);
Error("Grant size exceeds payload buffer size (%d > %d)", grant.tb.tbs, int(payload_buffer_len));
return;
}
// Uplink dci in a RAR and there is a PDU in the Msg3 buffer
if (grant.is_rar) {
if (harq_entity->mux_unit->msg3_is_pending()) {
Debug("Getting Msg3 buffer payload, grant size=%d bytes\n", grant.tb.tbs);
Debug("Getting Msg3 buffer payload, grant size=%d bytes", grant.tb.tbs);
pdu_ptr = harq_entity->mux_unit->msg3_get(payload_buffer.get(), grant.tb.tbs);
if (pdu_ptr) {
generate_new_tx(grant, action);
} else {
Warning("UL RAR dci available but no Msg3 on buffer\n");
Warning("UL RAR dci available but no Msg3 on buffer");
}
} else {
Warning("UL RAR available but no Msg3 pending on buffer\n");
Warning("UL RAR available but no Msg3 pending on buffer");
}
// Normal UL dci
} else {
@ -247,7 +243,7 @@ void ul_harq_entity::ul_harq_process::new_grant_ul(mac_interface_phy_lte::mac_gr
if (pdu_ptr) {
generate_new_tx(grant, action);
} else {
Warning("Uplink dci but no MAC PDU in Multiplex Unit buffer\n");
Warning("Uplink dci but no MAC PDU in Multiplex Unit buffer");
}
}
@ -258,7 +254,7 @@ void ul_harq_entity::ul_harq_process::new_grant_ul(mac_interface_phy_lte::mac_gr
// Adaptive Re-TX
generate_retx(grant, action);
} else {
Warning("UL %d: Received retransmission but no previous dci available for this PID.\n", pid);
Warning("UL %d: Received retransmission but no previous dci available for this PID.", pid);
}
if (harq_entity->pcap) {
uint16_t rnti;
@ -318,7 +314,7 @@ void ul_harq_entity::ul_harq_process::generate_retx(mac_interface_phy_lte::mac_g
current_irv = irv_of_rv[grant.tb.rv % 4];
}
Info("UL %d: Adaptive retx=%d, RV=%d, TBS=%d, HI=%s, ndi=%d, prev_ndi=%d\n",
Info("UL %d: Adaptive retx=%d, RV=%d, TBS=%d, HI=%s, ndi=%d, prev_ndi=%d",
pid,
current_tx_nb,
get_rv(),
@ -338,7 +334,7 @@ void ul_harq_entity::ul_harq_process::generate_retx(mac_interface_phy_lte::mac_g
// HARQ entity requests a non-adaptive transmission
} else if (!harq_feedback) {
// Non-adaptive retx are only sent if HI=NACK. If HI=ACK but no dci was received do not reset PID
Info("UL %d: Non-Adaptive retx=%d, RV=%d, TBS=%d, HI=%s\n",
Info("UL %d: Non-Adaptive retx=%d, RV=%d, TBS=%d, HI=%s",
pid,
current_tx_nb,
get_rv(),
@ -363,7 +359,7 @@ void ul_harq_entity::ul_harq_process::generate_new_tx(mac_interface_phy_lte::mac
action->is_rar = grant.is_rar || (grant.rnti == harq_entity->rntis->temp_rnti);
Info("UL %d: New TX%s, RV=%d, TBS=%d\n",
Info("UL %d: New TX%s, RV=%d, TBS=%d",
pid,
grant.rnti == harq_entity->rntis->temp_rnti ? " for Msg3" : "",
get_rv(),

@ -37,13 +37,13 @@ void phy_controller::in_sync()
bool phy_controller::set_cell_config(const srslte::phy_cfg_t& config, uint32_t cc_idx)
{
log_h->info("Setting PHY config for cc_idx=%d\n", cc_idx);
log_h->info("Setting PHY config for cc_idx=%d", cc_idx);
return set_cell_config(config, cc_idx, true);
}
void phy_controller::set_phy_to_default()
{
log_h->info("Setting default PHY config (common and dedicated)\n");
log_h->info("Setting default PHY config (common and dedicated)");
srslte::phy_cfg_t& default_cfg = current_cells_cfg[0];
default_cfg.set_defaults();
@ -55,7 +55,7 @@ void phy_controller::set_phy_to_default()
/// Apply default PHY config for all SCells as specified in TS 36.331 9.2.4
void phy_controller::set_phy_to_default_dedicated()
{
log_h->info("Setting default dedicated PHY config\n");
log_h->info("Setting default dedicated PHY config");
srslte::phy_cfg_t& default_cfg = current_cells_cfg[0];
default_cfg.set_defaults_dedicated();
@ -66,7 +66,7 @@ void phy_controller::set_phy_to_default_dedicated()
void phy_controller::set_phy_to_default_pucch_srs()
{
log_h->info("Setting default PHY config dedicated\n");
log_h->info("Setting default PHY config dedicated");
srslte::phy_cfg_t& default_cfg_ded = current_cells_cfg[0];
default_cfg_ded.set_defaults_pucch_sr();
@ -91,7 +91,7 @@ bool phy_controller::set_cell_config(const srslte::phy_cfg_t& cfg, uint32_t cc_i
void phy_controller::set_config_complete()
{
if (nof_pending_configs == 0) {
log_h->warning("Received more phy config complete signals than the ones scheduled\n");
log_h->warning("Received more phy config complete signals than the ones scheduled");
return;
}
nof_pending_configs--;
@ -104,12 +104,12 @@ void phy_controller::set_config_complete()
bool phy_controller::start_cell_select(const phy_cell_t& phy_cell, srslte::event_observer<bool> observer)
{
if (is_in_state<selecting_cell>()) {
log_h->warning("Failed to launch cell selection as it is already running\n");
log_h->warning("Failed to launch cell selection as it is already running");
return false;
}
trigger(cell_sel_cmd{phy_cell});
if (not is_in_state<selecting_cell>()) {
log_h->warning("Failed to launch cell selection. Current state: %s\n", current_state_name().c_str());
log_h->warning("Failed to launch cell selection. Current state: %s", current_state_name().c_str());
return false;
}
cell_selection_notifier = std::move(observer);
@ -131,7 +131,7 @@ void phy_controller::selecting_cell::enter(phy_controller* f, const cell_sel_cmd
target_cell = ev.phy_cell;
csel_res.result = false;
fsmInfo("Starting for pci=%d, earfcn=%d\n", target_cell.pci, target_cell.earfcn);
fsmInfo("Starting for pci=%d, earfcn=%d", target_cell.pci, target_cell.earfcn);
if (not f->phy->cell_select(target_cell)) {
trigger(srslte::failure_ev{});
}
@ -142,9 +142,9 @@ void phy_controller::selecting_cell::exit(phy_controller* f)
wait_in_sync_timer.stop();
if (csel_res.result) {
fsmInfo("Cell %s successfully selected\n", to_string(target_cell).c_str());
fsmInfo("Cell %s successfully selected", to_string(target_cell).c_str());
} else {
fsmWarning("Failed to select cell %s\n", to_string(target_cell).c_str());
fsmWarning("Failed to select cell %s", to_string(target_cell).c_str());
}
// Signal result back to FSM that called cell selection
@ -169,12 +169,12 @@ void phy_controller::selecting_cell::wait_in_sync::enter(selecting_cell* f)
bool phy_controller::start_cell_search(srslte::event_observer<cell_srch_res> observer)
{
if (is_in_state<searching_cell>()) {
fsmInfo("Cell search already launched.\n");
fsmInfo("Cell search already launched.");
return true;
}
trigger(cell_search_cmd{});
if (not is_in_state<searching_cell>()) {
fsmWarning("Failed to launch cell search\n");
fsmWarning("Failed to launch cell search");
return false;
}
cell_search_observers.subscribe(observer);
@ -188,7 +188,7 @@ void phy_controller::cell_search_completed(cell_search_ret_t cs_ret, phy_cell_t
void phy_controller::searching_cell::enter(phy_controller* f)
{
otherfsmInfo(f, "Initiating Cell search\n");
otherfsmInfo(f, "Initiating Cell search");
f->phy->cell_search();
}
@ -196,13 +196,13 @@ void phy_controller::handle_cell_search_res(searching_cell& s, const cell_srch_r
{
switch (result.cs_ret.found) {
case cell_search_ret_t::CELL_FOUND:
fsmInfo("PHY cell search completed. Found cell %s\n", to_string(result.found_cell).c_str());
fsmInfo("PHY cell search completed. Found cell %s", to_string(result.found_cell).c_str());
break;
case cell_search_ret_t::CELL_NOT_FOUND:
fsmWarning("PHY cell search completed. No cells found.\n");
fsmWarning("PHY cell search completed. No cells found.");
break;
default:
fsmError("Invalid cell search result\n");
fsmError("Invalid cell search result");
// TODO: check what errors can happen (currently not handled in our code)
}

File diff suppressed because it is too large Load Diff

@ -169,8 +169,7 @@ uint16_t meas_cell_eutra::get_mnc() const
********************************************/
template <class T>
meas_cell_list<T>::meas_cell_list(srslte::task_sched_handle task_sched_) :
serv_cell(new T(task_sched_.get_unique_timer())),
task_sched(task_sched_)
serv_cell(new T(task_sched_.get_unique_timer())), task_sched(task_sched_)
{}
template <class T>
@ -217,12 +216,12 @@ bool meas_cell_list<T>::add_neighbour_cell_unsorted(unique_meas_cell new_cell)
{
// Make sure cell is valid
if (!new_cell->is_valid()) {
log_h->error("Trying to add cell %s but is not valid", new_cell->to_string().c_str());
logger.error("Trying to add cell %s but is not valid", new_cell->to_string().c_str());
return false;
}
if (is_same_cell(serving_cell(), *new_cell)) {
log_h->info("Added neighbour cell %s is serving cell\n", new_cell->to_string().c_str());
logger.info("Added neighbour cell %s is serving cell", new_cell->to_string().c_str());
serv_cell = std::move(new_cell);
return true;
}
@ -233,22 +232,22 @@ bool meas_cell_list<T>::add_neighbour_cell_unsorted(unique_meas_cell new_cell)
if (std::isnormal(new_cell.get()->get_rsrp())) {
existing_cell->set_rsrp(new_cell.get()->get_rsrp());
}
log_h->info("Updated neighbour cell %s rsrp=%f\n", new_cell->to_string().c_str(), new_cell.get()->get_rsrp());
logger.info("Updated neighbour cell %s rsrp=%f", new_cell->to_string().c_str(), new_cell.get()->get_rsrp());
return true;
}
if (neighbour_cells.size() >= MAX_NEIGHBOUR_CELLS) {
// If there isn't space, keep the strongest only
if (not new_cell->greater(neighbour_cells.back().get())) {
log_h->warning("Could not add cell %s: no space in neighbours\n", new_cell->to_string().c_str());
logger.warning("Could not add cell %s: no space in neighbours", new_cell->to_string().c_str());
return false;
}
rem_last_neighbour();
}
log_h->info(
"Adding neighbour cell %s, nof_neighbours=%zd\n", new_cell->to_string().c_str(), neighbour_cells.size() + 1);
logger.info(
"Adding neighbour cell %s, nof_neighbours=%zd", new_cell->to_string().c_str(), neighbour_cells.size() + 1);
neighbour_cells.push_back(std::move(new_cell));
return true;
}
@ -257,7 +256,7 @@ void meas_cell_list<T>::rem_last_neighbour()
{
if (not neighbour_cells.empty()) {
unique_meas_cell& c = neighbour_cells.back();
log_h->debug("Delete cell %s from neighbor list.\n", c->to_string().c_str());
logger.debug("Delete cell %s from neighbor list.", c->to_string().c_str());
neighbour_cells.pop_back();
}
}
@ -301,9 +300,9 @@ void meas_cell_list<T>::log_neighbour_cells() const
}
}
}
log_h->debug("Neighbours: %s]\n", ordered);
logger.debug("Neighbours: %s]", ordered);
} else {
log_h->debug("Neighbours: Empty\n");
logger.debug("Neighbours: Empty");
}
}
@ -313,7 +312,7 @@ void meas_cell_list<T>::clean_neighbours()
{
for (auto it = neighbour_cells.begin(); it != neighbour_cells.end();) {
if (it->get()->timer.is_expired()) {
log_h->info("Neighbour PCI=%d timed out. Deleting.\n", (*it)->get_pci());
logger.info("Neighbour PCI=%d timed out. Deleting.", (*it)->get_pci());
it = neighbour_cells.erase(it);
} else {
++it;
@ -369,19 +368,19 @@ int meas_cell_list<T>::set_serving_cell(phy_cell_t phy_cell, bool discard_servin
// Remove future serving cell from neighbours to make space for current serving cell
unique_meas_cell new_serving_cell = remove_neighbour_cell(phy_cell.earfcn, phy_cell.pci);
if (new_serving_cell == nullptr) {
log_h->error("Setting serving cell: Unknown cell with earfcn=%d, PCI=%d\n", phy_cell.earfcn, phy_cell.pci);
logger.error("Setting serving cell: Unknown cell with earfcn=%d, PCI=%d", phy_cell.earfcn, phy_cell.pci);
return SRSLTE_ERROR;
}
// Set new serving cell
std::swap(serv_cell, new_serving_cell);
auto& old_serv_cell = new_serving_cell;
log_h->info("Setting serving cell %s, nof_neighbours=%zd\n", serv_cell->to_string().c_str(), nof_neighbours());
logger.info("Setting serving cell %s, nof_neighbours=%zd", serv_cell->to_string().c_str(), nof_neighbours());
// Re-add old serving cell to list of neighbours
if (old_serv_cell->is_valid() and not is_same_cell(phy_cell, *old_serv_cell) and not discard_serving) {
if (not add_meas_cell(std::move(old_serv_cell))) {
log_h->info("Serving cell not added to list of neighbours. Worse than current neighbours\n");
logger.info("Serving cell not added to list of neighbours. Worse than current neighbours");
}
}
return SRSLTE_SUCCESS;
@ -400,7 +399,7 @@ bool meas_cell_list<T>::process_new_cell_meas(const std::vector<phy_meas_t>&
if (is_serving_cell) {
c = serv_cell.get();
if (not serving_cell().is_valid()) {
log_h->error("MEAS: Received serving cell measurement but undefined or invalid\n");
logger.error("MEAS: Received serving cell measurement but undefined or invalid");
continue;
}
} else {
@ -416,7 +415,7 @@ bool meas_cell_list<T>::process_new_cell_meas(const std::vector<phy_meas_t>&
neighbour_added |= add_meas_cell(m);
}
log_h->info("MEAS: New measurement %s cell: earfcn=%d, pci=%d, rsrp=%.2f dBm, cfo=%+.1f Hz\n",
logger.info("MEAS: New measurement %s cell: earfcn=%d, pci=%d, rsrp=%.2f dBm, cfo=%+.1f Hz",
is_serving_cell ? "serving" : "neighbour",
m.earfcn,
m.pci,

@ -12,8 +12,8 @@
#include "srsue/hdr/stack/rrc/rrc_meas.h"
#include "srslte/asn1/rrc/dl_dcch_msg.h"
#include "srsue/hdr/stack/rrc/rrc.h"
#include "srslte/rrc/rrc_cfg_utils.h"
#include "srsue/hdr/stack/rrc/rrc.h"
/************************************************************************
*
@ -94,7 +94,7 @@ void rrc::rrc_meas::update_phy()
}
#endif
default:
log_h->error("Not supported\n");
logger.error("Not supported");
break;
}
// Concatenate cells indicated by enodeb with discovered neighbours
@ -253,7 +253,7 @@ void rrc::rrc_meas::var_meas_report_list::generate_report_eutra(meas_results_s*
{
meas_cell_eutra* serv_cell = rrc_ptr->get_serving_cell();
if (serv_cell == nullptr) {
log_h->warning("MEAS: Serving cell not set when evaluating triggers\n");
logger.warning("MEAS: Serving cell not set when evaluating triggers");
return;
}
@ -271,7 +271,7 @@ void rrc::rrc_meas::var_meas_report_list::generate_report_eutra(meas_results_s*
for (auto& cell : var_meas.cell_triggered_list) {
// report neighbour cells only
if (cell.pci == serv_cell->get_pci() && cell.earfcn == serv_cell->get_earfcn()) {
log_h->info("MEAS: skipping serving cell in report neighbour=%d, pci=%d, earfcn=%d, rsrp=%+.1f, rsrq=%+.1f\n",
logger.info("MEAS: skipping serving cell in report neighbour=%d, pci=%d, earfcn=%d, rsrp=%+.1f, rsrq=%+.1f",
neigh_list.size(),
cell.pci,
var_meas.carrier_freq,
@ -309,7 +309,7 @@ void rrc::rrc_meas::var_meas_report_list::generate_report_eutra(meas_results_s*
rc.meas_result.rsrp_result = value_to_range(report_cfg_eutra_s::trigger_quant_opts::rsrp, rsrp_value);
rc.meas_result.rsrq_result = value_to_range(report_cfg_eutra_s::trigger_quant_opts::rsrq, rsrq_value);
log_h->info("MEAS: Adding to report neighbour=%d, pci=%d, earfcn=%d, rsrp=%+.1f, rsrq=%+.1f\n",
logger.info("MEAS: Adding to report neighbour=%d, pci=%d, earfcn=%d, rsrp=%+.1f, rsrq=%+.1f",
neigh_list.size(),
rc.pci,
var_meas.carrier_freq,
@ -392,7 +392,7 @@ void rrc::rrc_meas::var_meas_report_list::generate_report_interrat(meas_results_
value_to_range_nr(asn1::rrc::thres_nr_r15_c::types_opts::options::nr_sinr_r15, 1.0);
}
log_h->info("MEAS: Adding to report neighbour=%d, pci=%d, earfcn=%d, rsrp=%+.1f, rsrq=%+.1f\n",
logger.info("MEAS: Adding to report neighbour=%d, pci=%d, earfcn=%d, rsrp=%+.1f, rsrq=%+.1f",
neigh_list.size(),
rc.pci_r15,
var_meas.carrier_freq,
@ -438,7 +438,7 @@ void rrc::rrc_meas::var_meas_report_list::generate_report(const uint32_t measId)
{
meas_cell_eutra* serv_cell = rrc_ptr->get_serving_cell();
if (serv_cell == nullptr) {
log_h->warning("MEAS: Serving cell not set when evaluating triggers\n");
logger.warning("MEAS: Serving cell not set when evaluating triggers");
return;
}
@ -453,7 +453,7 @@ void rrc::rrc_meas::var_meas_report_list::generate_report(const uint32_t measId)
report->meas_result_pcell.rsrq_result =
value_to_range(report_cfg_eutra_s::trigger_quant_opts::rsrq, serv_cell->get_rsrq());
log_h->info("MEAS: Generate report MeasId=%d, Pcell rsrp=%f rsrq=%f\n",
logger.info("MEAS: Generate report MeasId=%d, Pcell rsrp=%f rsrq=%f",
report->meas_id,
serv_cell->get_rsrp(),
serv_cell->get_rsrq());
@ -463,19 +463,19 @@ void rrc::rrc_meas::var_meas_report_list::generate_report(const uint32_t measId)
switch (var_meas.report_type) {
case eutra: {
log_h->debug("MEAS: Generate EUTRA report\n");
logger.debug("MEAS: Generate EUTRA report");
generate_report_eutra(report, measId);
break;
}
#ifdef HAVE_5GNR
case inter_rat: {
log_h->debug("MEAS: Generate INTER RAT NR report\n");
logger.debug("MEAS: Generate INTER RAT NR report");
generate_report_interrat(report, measId);
break;
}
#endif
default:
log_h->debug("MEAS: Not supported\n");
logger.debug("MEAS: Not supported");
break;
}
@ -630,7 +630,7 @@ void rrc::rrc_meas::var_meas_cfg::report_triggers_eutra_removing_trigger(int32_t
{
meas_cell_eutra* serv_cell = rrc_ptr->get_serving_cell();
if (serv_cell == nullptr) {
log_h->warning("MEAS: Serving cell not set when reporting triggers\n");
logger.warning("MEAS: Serving cell not set when reporting triggers");
return;
}
uint32_t serving_pci = serv_cell->get_pci();
@ -640,7 +640,7 @@ void rrc::rrc_meas::var_meas_cfg::report_triggers_eutra_removing_trigger(int32_t
auto it = cells_triggered_list.begin();
while (it != cells_triggered_list.end()) {
if (not rrc_ptr->has_neighbour_cell(it->earfcn, it->pci) and it->pci != serving_pci) {
log_h->debug("MEAS: Removing unknown PCI=%d from event trigger list\n", it->pci);
logger.debug("MEAS: Removing unknown PCI=%d from event trigger list", it->pci);
it = cells_triggered_list.erase(it);
meas_report->upd_measId(meas_id, cells_triggered_list);
@ -693,7 +693,6 @@ void rrc::rrc_meas::var_meas_cfg::report_triggers_interrat_check_new(int32_t
// initiate the measurement reporting procedure, as specified in 5.5.5;
meas_report->generate_report(meas_id);
}
}
void rrc::rrc_meas::var_meas_cfg::report_triggers_interrat_check_leaving(int32_t meas_id,
report_cfg_inter_rat_s& report_cfg)
@ -733,7 +732,7 @@ void rrc::rrc_meas::var_meas_cfg::report_triggers_interrat_removing_trigger(int3
auto it = cells_triggered_list.begin();
while (it != cells_triggered_list.end()) {
if (not rrc_ptr->has_neighbour_cell_nr(it->earfcn, it->pci)) {
log_h->debug("MEAS: Removing unknown PCI=%d from event trigger list\n", it->pci);
logger.debug("MEAS: Removing unknown PCI=%d from event trigger list", it->pci);
it = cells_triggered_list.erase(it);
meas_report->upd_measId(meas_id, cells_triggered_list);
@ -765,14 +764,14 @@ void rrc::rrc_meas::var_meas_cfg::report_triggers()
for (auto& m : measIdList) {
if (!reportConfigList.count(m.second.report_cfg_id) || !measObjectsList.count(m.second.meas_obj_id)) {
log_h->error("MEAS: Computing report triggers. MeasId=%d has invalid report or object settings\n", m.first);
logger.error("MEAS: Computing report triggers. MeasId=%d has invalid report or object settings", m.first);
continue;
}
report_cfg_to_add_mod_s& report_cfg = reportConfigList.at(m.second.report_cfg_id);
meas_obj_to_add_mod_s& meas_obj = measObjectsList.at(m.second.meas_obj_id);
log_h->debug("MEAS: Calculating reports for MeasId=%d, ObjectId=%d (Type %s), ReportId=%d (Type %s)\n",
logger.debug("MEAS: Calculating reports for MeasId=%d, ObjectId=%d (Type %s), ReportId=%d (Type %s)",
m.first,
m.second.meas_obj_id,
report_cfg.report_cfg.type().to_string().c_str(),
@ -792,7 +791,7 @@ void rrc::rrc_meas::var_meas_cfg::report_triggers()
}
#endif
else {
log_h->error("Unsupported combination of measurement object type %s and report config type %s \n",
logger.error("Unsupported combination of measurement object type %s and report config type %s ",
meas_obj.meas_obj.type().to_string().c_str(),
report_cfg.report_cfg.type().to_string().c_str());
}
@ -820,7 +819,7 @@ void rrc::rrc_meas::var_meas_cfg::eval_triggers_eutra(uint32_t meas_i
float Ms = is_rsrp(report_cfg.trigger_quant.value) ? serv_cell->get_rsrp() : serv_cell->get_rsrq();
if (!std::isnormal(Ms)) {
log_h->debug("MEAS: Serving cell Ms=%f invalid when evaluating triggers\n", Ms);
logger.debug("MEAS: Serving cell Ms=%f invalid when evaluating triggers", Ms);
return;
}
@ -853,7 +852,7 @@ void rrc::rrc_meas::var_meas_cfg::eval_triggers_eutra(uint32_t meas_i
trigger_state[meas_id][serv_cell->get_pci()].event_condition(enter_condition, exit_condition);
log_h->debug("MEAS: eventId=%s, Ms=%.2f, hyst=%.2f, Thresh=%.2f, enter_condition=%d, exit_condition=%d\n",
logger.debug("MEAS: eventId=%s, Ms=%.2f, hyst=%.2f, Thresh=%.2f, enter_condition=%d, exit_condition=%d",
event_id.type().to_string().c_str(),
Ms,
hyst,
@ -865,8 +864,8 @@ void rrc::rrc_meas::var_meas_cfg::eval_triggers_eutra(uint32_t meas_i
} else {
auto cells = rrc_ptr->get_cells(meas_obj.carrier_freq);
for (auto& pci : cells) {
log_h->debug(
"MEAS: eventId=%s, pci=%d, earfcn=%d\n", event_id.type().to_string().c_str(), pci, meas_obj.carrier_freq);
logger.debug(
"MEAS: eventId=%s, pci=%d, earfcn=%d", event_id.type().to_string().c_str(), pci, meas_obj.carrier_freq);
float Ofn = offset_val(meas_obj);
float Ocn = 0;
// If the cell was provided by the configuration, check if it has an individual q_offset
@ -918,13 +917,13 @@ void rrc::rrc_meas::var_meas_cfg::eval_triggers_eutra(uint32_t meas_i
exit_condition = (Ms - hyst > th1) && (Mn + Ofn + Ocn + hyst < th2);
break;
default:
log_h->error("Error event %s not implemented\n", event_id.type().to_string().c_str());
logger.error("Error event %s not implemented", event_id.type().to_string().c_str());
}
trigger_state[meas_id][pci].event_condition(enter_condition, exit_condition);
log_h->debug(
"MEAS: eventId=%s, pci=%d, Ms=%.2f, hyst=%.2f, Thresh=%.2f, enter_condition=%d, exit_condition=%d\n",
logger.debug(
"MEAS: eventId=%s, pci=%d, Ms=%.2f, hyst=%.2f, Thresh=%.2f, enter_condition=%d, exit_condition=%d",
event_id.type().to_string().c_str(),
pci,
Ms,
@ -943,7 +942,7 @@ void rrc::rrc_meas::var_meas_cfg::eval_triggers_interrat_nr(uint32_t
meas_obj_nr_r15_s& meas_obj)
{
if (!(report_cfg.trigger_type.type() == report_cfg_inter_rat_s::trigger_type_c_::types::event)) {
log_h->error("Unsupported trigger type for interrat nr eval\n");
logger.error("Unsupported trigger type for interrat nr eval");
return;
}
@ -959,15 +958,15 @@ void rrc::rrc_meas::var_meas_cfg::eval_triggers_interrat_nr(uint32_t
bool exit_condition = false;
float Mn = 0.0;
log_h->debug(
"MEAS: eventId=%s, pci=%d, earfcn=%d\n", event_id.type().to_string().c_str(), pci, meas_obj.carrier_freq_r15);
logger.debug(
"MEAS: eventId=%s, pci=%d, earfcn=%d", event_id.type().to_string().c_str(), pci, meas_obj.carrier_freq_r15);
if (event_id.event_b1_nr_r15().b1_thres_nr_r15.type().value == thres_nr_r15_c::types::nr_rsrp_r15) {
Mn = rrc_ptr->get_cell_rsrp_nr(meas_obj.carrier_freq_r15, pci);
thresh = range_to_value_nr(asn1::rrc::thres_nr_r15_c::types_opts::options::nr_rsrp_r15,
event_id.event_b1_nr_r15().b1_thres_nr_r15.nr_rsrp_r15());
} else {
log_h->warning("Other threshold values are not supported yet!\n");
logger.warning("Other threshold values are not supported yet!");
}
enter_condition = Mn - hyst > thresh;
@ -975,7 +974,7 @@ void rrc::rrc_meas::var_meas_cfg::eval_triggers_interrat_nr(uint32_t
trigger_state_nr[meas_id][pci].event_condition(enter_condition, exit_condition);
log_h->debug("MEAS (NR): eventId=%s, Mn=%.2f, hyst=%.2f, Thresh=%.2f, enter_condition=%d, exit_condition=%d\n",
logger.debug("MEAS (NR): eventId=%s, Mn=%.2f, hyst=%.2f, Thresh=%.2f, enter_condition=%d, exit_condition=%d",
event_id.type().to_string().c_str(),
Mn,
hyst,
@ -991,7 +990,7 @@ void rrc::rrc_meas::var_meas_cfg::eval_triggers()
meas_cell_eutra* serv_cell = rrc_ptr->get_serving_cell();
if (serv_cell == nullptr) {
log_h->warning("MEAS: Serving cell not set when evaluating triggers\n");
logger.warning("MEAS: Serving cell not set when evaluating triggers");
return;
}
@ -1014,14 +1013,14 @@ void rrc::rrc_meas::var_meas_cfg::eval_triggers()
for (auto& m : measIdList) {
if (!reportConfigList.count(m.second.report_cfg_id) || !measObjectsList.count(m.second.meas_obj_id)) {
log_h->error("MEAS: Computing report triggers. MeasId=%d has invalid report or object settings\n", m.first);
logger.error("MEAS: Computing report triggers. MeasId=%d has invalid report or object settings", m.first);
continue;
}
report_cfg_to_add_mod_s& report_cfg = reportConfigList.at(m.second.report_cfg_id);
meas_obj_to_add_mod_s& meas_obj = measObjectsList.at(m.second.meas_obj_id);
log_h->debug("MEAS: Calculating trigger for MeasId=%d, ObjectId=%d (Type %s), ReportId=%d (Type %s)\n",
logger.debug("MEAS: Calculating trigger for MeasId=%d, ObjectId=%d (Type %s), ReportId=%d (Type %s)",
m.first,
m.second.meas_obj_id,
report_cfg.report_cfg.type().to_string().c_str(),
@ -1040,7 +1039,7 @@ void rrc::rrc_meas::var_meas_cfg::eval_triggers()
m.first, report_cfg.report_cfg.report_cfg_inter_rat(), meas_obj.meas_obj.meas_obj_nr_r15());
#endif
else {
log_h->error("Unsupported combination of measurement object type %s and report config type %s \n",
logger.error("Unsupported combination of measurement object type %s and report config type %s ",
meas_obj.meas_obj.type().to_string().c_str(),
report_cfg.report_cfg.type().to_string().c_str());
}
@ -1094,17 +1093,17 @@ std::list<meas_obj_to_add_mod_s> rrc::rrc_meas::var_meas_cfg::get_active_objects
r.push_back(measObjectsList.at(m.second.meas_obj_id));
}
}
if (log_h->get_level() == LOG_LEVEL_DEBUG) {
log_h->debug("MEAS: Returning %zd active objects\n", r.size());
if (logger.debug.enabled()) {
logger.debug("MEAS: Returning %zd active objects", r.size());
for (auto& o : r) {
switch (o.meas_obj.type().value) {
case meas_obj_to_add_mod_s::meas_obj_c_::types_opts::meas_obj_eutra:
log_h->debug("MEAS: carrier_freq=%d, %u cells\n",
logger.debug("MEAS: carrier_freq=%d, %u cells",
o.meas_obj.meas_obj_eutra().carrier_freq,
o.meas_obj.meas_obj_eutra().cells_to_add_mod_list.size());
break;
case meas_obj_to_add_mod_s::meas_obj_c_::types_opts::meas_obj_nr_r15:
log_h->debug("MEAS: NR: carrier_freq=%d\n", o.meas_obj.meas_obj_nr_r15().carrier_freq_r15);
logger.debug("MEAS: NR: carrier_freq=%d", o.meas_obj.meas_obj_nr_r15().carrier_freq_r15);
default:
break;
}
@ -1117,8 +1116,7 @@ std::list<meas_obj_to_add_mod_s> rrc::rrc_meas::var_meas_cfg::get_active_objects
// Procedure upon handover or reestablishment 5.5.6.1
void rrc::rrc_meas::var_meas_cfg::ho_reest_finish(const uint32_t src_earfcn, const uint32_t dst_earfcn)
{
log_h->info(
"MEAS: Actions upon handover and reestablishment, src_earfcn=%d, dst_earfcn=%d\n", src_earfcn, dst_earfcn);
logger.info("MEAS: Actions upon handover and reestablishment, src_earfcn=%d, dst_earfcn=%d", src_earfcn, dst_earfcn);
// for each measId included in the measIdList within VarMeasConfig, if the triggerType is set to periodical, remove
// this measId from the measIdList within VarMeasConfig
@ -1137,10 +1135,10 @@ void rrc::rrc_meas::var_meas_cfg::ho_reest_finish(const uint32_t src_earfcn, con
}
}
if (log_h->get_level() == LOG_LEVEL_DEBUG) {
log_h->debug("MEAS: measId before HO\n");
if (logger.debug.enabled()) {
logger.debug("MEAS: measId before HO");
for (auto& m : measIdList) {
log_h->debug("MEAS: measId=%d, measObjectId=%d\n", m.first, m.second.meas_obj_id);
logger.debug("MEAS: measId=%d, measObjectId=%d", m.first, m.second.meas_obj_id);
}
}
@ -1152,10 +1150,11 @@ void rrc::rrc_meas::var_meas_cfg::ho_reest_finish(const uint32_t src_earfcn, con
[&src_earfcn](const std::pair<uint32_t, meas_obj_to_add_mod_s>& c) {
return c.second.meas_obj.meas_obj_eutra().carrier_freq == src_earfcn;
});
auto dst_obj = std::find_if(
measObjectsList.begin(), measObjectsList.end(), [&dst_earfcn](const std::pair<uint32_t, meas_obj_to_add_mod_s>& c) {
return c.second.meas_obj.meas_obj_eutra().carrier_freq == dst_earfcn;
});
auto dst_obj = std::find_if(measObjectsList.begin(),
measObjectsList.end(),
[&dst_earfcn](const std::pair<uint32_t, meas_obj_to_add_mod_s>& c) {
return c.second.meas_obj.meas_obj_eutra().carrier_freq == dst_earfcn;
});
if (dst_obj != measObjectsList.end()) {
for (auto& m : measIdList) {
// if the measId value is linked to the measObjectId value corresponding to the source carrier frequency
@ -1183,10 +1182,10 @@ void rrc::rrc_meas::var_meas_cfg::ho_reest_finish(const uint32_t src_earfcn, con
}
}
if (log_h->get_level() == LOG_LEVEL_DEBUG) {
log_h->debug("MEAS: measId after HO\n");
if (logger.debug.enabled()) {
logger.debug("MEAS: measId after HO");
for (auto& m : measIdList) {
log_h->debug("MEAS: measId=%d, measObjectId=%d\n", m.first, m.second.meas_obj_id);
logger.debug("MEAS: measId=%d, measObjectId=%d", m.first, m.second.meas_obj_id);
}
}
@ -1205,14 +1204,14 @@ void rrc::rrc_meas::var_meas_cfg::measObject_removal(const meas_obj_to_rem_list_
auto it = measIdList.begin();
while (it != measIdList.end()) {
if (it->second.meas_obj_id == l) {
log_h->info("MEAS: Removed measId=%d\n", it->first);
logger.info("MEAS: Removed measId=%d", it->first);
remove_varmeas_report(it->first); // Remove report before `it` is updated with the next pointer
it = measIdList.erase(it);
} else {
it++;
}
}
log_h->info("MEAS: Removed measObjectId=%d\n", l);
logger.info("MEAS: Removed measObjectId=%d", l);
}
}
}
@ -1225,7 +1224,7 @@ void rrc::rrc_meas::var_meas_cfg::measObject_addmod_eutra(const meas_obj_to_add_
measObjectsList.emplace(l.meas_obj_id, l);
}
meas_obj_eutra_s cfg_obj = l.meas_obj.meas_obj_eutra();
meas_obj_eutra_s cfg_obj = l.meas_obj.meas_obj_eutra();
measObjectsList.at(l.meas_obj_id).meas_obj_id = l.meas_obj_id;
// Assert choice will check if existing meas object is of type eutra
meas_obj_eutra_s& local_obj = measObjectsList.at(l.meas_obj_id).meas_obj.meas_obj_eutra();
@ -1240,12 +1239,12 @@ void rrc::rrc_meas::var_meas_cfg::measObject_addmod_eutra(const meas_obj_to_add_
{
// Remove cells
if (cfg_obj.cells_to_rem_list_present) {
log_h->debug("MEAS: Removing %d cells\n", cfg_obj.cells_to_rem_list.size());
logger.debug("MEAS: Removing %d cells", cfg_obj.cells_to_rem_list.size());
apply_remlist_diff(local_obj.cells_to_add_mod_list, cfg_obj.cells_to_rem_list, local_obj.cells_to_add_mod_list);
if (log_h->get_level() == LOG_LEVEL_DEBUG) {
if (logger.debug.enabled()) {
for (auto& c : local_obj.cells_to_add_mod_list) {
log_h->debug("MEAS: cell idx=%d, pci=%d, q_offset=%d\n",
logger.debug("MEAS: cell idx=%d, pci=%d, q_offset=%d",
c.cell_idx,
c.pci,
c.cell_individual_offset.to_number());
@ -1280,19 +1279,19 @@ void rrc::rrc_meas::var_meas_cfg::measObject_addmod_eutra(const meas_obj_to_add_
}
}
log_h->info("MEAS: %s objectId=%d, carrier_freq=%d, %u cells, %u black-listed cells\n",
logger.info("MEAS: %s objectId=%d, carrier_freq=%d, %u cells, %u black-listed cells",
!entry_exists ? "Added" : "Modified",
l.meas_obj_id,
local_obj.carrier_freq,
local_obj.cells_to_add_mod_list.size(),
local_obj.black_cells_to_add_mod_list.size());
if (log_h->get_level() == LOG_LEVEL_DEBUG) {
if (logger.debug.enabled()) {
for (auto& c : local_obj.cells_to_add_mod_list) {
log_h->debug(
"MEAS: cell idx=%d, pci=%d, q_offset=%d\n", c.cell_idx, c.pci, c.cell_individual_offset.to_number());
logger.debug(
"MEAS: cell idx=%d, pci=%d, q_offset=%d", c.cell_idx, c.pci, c.cell_individual_offset.to_number());
}
for (auto& b : local_obj.black_cells_to_add_mod_list) {
log_h->debug("MEAS: black-listed cell idx=%d\n", b.cell_idx);
logger.debug("MEAS: black-listed cell idx=%d", b.cell_idx);
}
}
}
@ -1305,9 +1304,9 @@ void rrc::rrc_meas::var_meas_cfg::measObject_addmod_nr_r15(const meas_obj_to_add
measObjectsList.emplace(l.meas_obj_id, l);
}
meas_obj_nr_r15_s cfg_obj = l.meas_obj.meas_obj_nr_r15();
meas_obj_nr_r15_s cfg_obj = l.meas_obj.meas_obj_nr_r15();
measObjectsList.at(l.meas_obj_id).meas_obj_id = l.meas_obj_id;
meas_obj_nr_r15_s& local_obj = measObjectsList.at(l.meas_obj_id).meas_obj.meas_obj_nr_r15();
meas_obj_nr_r15_s& local_obj = measObjectsList.at(l.meas_obj_id).meas_obj.meas_obj_nr_r15();
// if an entry with the matching measObjectId exists in the measObjectList within the VarMeasConfig
if (entry_exists) {
// Update carrier frequency0
@ -1335,14 +1334,14 @@ void rrc::rrc_meas::var_meas_cfg::measObject_addmod_nr_r15(const meas_obj_to_add
}
}
log_h->info("MEAS (NR R15): %s objectId=%d, carrier_freq=%d, %u black-listed cells\n",
logger.info("MEAS (NR R15): %s objectId=%d, carrier_freq=%d, %u black-listed cells",
!entry_exists ? "Added" : "Modified",
l.meas_obj_id,
local_obj.carrier_freq_r15,
local_obj.black_cells_to_add_mod_list_r15.size());
if (log_h->get_level() == LOG_LEVEL_DEBUG) {
if (logger.debug.enabled()) {
for (auto& b : local_obj.black_cells_to_add_mod_list_r15) {
log_h->debug("MEAS: black-listed cell idx=%d\n", b.cell_idx_r15);
logger.debug("MEAS: black-listed cell idx=%d", b.cell_idx_r15);
}
}
}
@ -1359,7 +1358,7 @@ void rrc::rrc_meas::var_meas_cfg::measObject_addmod(const meas_obj_to_add_mod_li
measObject_addmod_nr_r15(l);
break;
default:
log_h->error("Unsupported measObject type: %s\n", l.meas_obj.type().to_string().c_str());
logger.error("Unsupported measObject type: %s", l.meas_obj.type().to_string().c_str());
break;
}
}
@ -1376,14 +1375,14 @@ void rrc::rrc_meas::var_meas_cfg::reportConfig_removal(const report_cfg_to_rem_l
auto it = measIdList.begin();
while (it != measIdList.end()) {
if (it->second.report_cfg_id == l) {
log_h->info("MEAS: Removed measId=%d\n", it->first);
logger.info("MEAS: Removed measId=%d", it->first);
remove_varmeas_report(it->first); // Remove report before `it` is updated with the next pointer
it = measIdList.erase(it);
} else {
it++;
}
}
log_h->info("MEAS: Removed reportObjectId=%d\n", l);
logger.info("MEAS: Removed reportObjectId=%d", l);
}
}
}
@ -1410,11 +1409,11 @@ void rrc::rrc_meas::var_meas_cfg::reportConfig_addmod_eutra(const report_cfg_to_
const report_cfg_eutra_s& report_cfg = l.report_cfg.report_cfg_eutra();
if (!(report_cfg.trigger_type.type().value == report_cfg_eutra_s::trigger_type_c_::types_opts::event)) {
log_h->error("MEAS: Periodical reports not supported. Received in reportConfigId=%d\n", l.report_cfg_id);
logger.error("MEAS: Periodical reports not supported. Received in reportConfigId=%d", l.report_cfg_id);
return;
}
bool entry_exists = reportConfig_addmod_to_reportConfigList(l);
log_h->info("MEAS: %s reportConfig id=%d, event-type=%s, time-to-trigger=%d ms, reportInterval=%d\n",
logger.info("MEAS: %s reportConfig id=%d, event-type=%s, time-to-trigger=%d ms, reportInterval=%d",
!entry_exists ? "Added" : "Modified",
l.report_cfg_id,
report_cfg.trigger_type.event().event_id.type().to_string().c_str(),
@ -1429,11 +1428,11 @@ void rrc::rrc_meas::var_meas_cfg::reportConfig_addmod_interrat(const report_cfg_
{
const report_cfg_inter_rat_s& report_cfg = l.report_cfg.report_cfg_inter_rat();
if (!(report_cfg.trigger_type.type().value == report_cfg_inter_rat_s::trigger_type_c_::types_opts::event)) {
log_h->error("MEAS: Periodical reports not supported. Received in reportConfigId=%d\n", l.report_cfg_id);
logger.error("MEAS: Periodical reports not supported. Received in reportConfigId=%d", l.report_cfg_id);
return;
}
bool entry_exists = reportConfig_addmod_to_reportConfigList(l);
log_h->info("MEAS: Inter RAT %s reportConfig id=%d, event-type=%s, time-to-trigger=%d ms, reportInterval=%d\n",
logger.info("MEAS: Inter RAT %s reportConfig id=%d, event-type=%s, time-to-trigger=%d ms, reportInterval=%d",
!entry_exists ? "Added" : "Modified",
l.report_cfg_id,
report_cfg.trigger_type.event().event_id.type().to_string().c_str(),
@ -1454,7 +1453,7 @@ void rrc::rrc_meas::var_meas_cfg::reportConfig_addmod(const report_cfg_to_add_mo
reportConfig_addmod_interrat(l);
break;
default:
log_h->error("MEAS: Unsupported reportConfig type: %s\n", l.report_cfg.type().to_string().c_str());
logger.error("MEAS: Unsupported reportConfig type: %s", l.report_cfg.type().to_string().c_str());
break;
}
}
@ -1464,16 +1463,17 @@ void rrc::rrc_meas::var_meas_cfg::reportConfig_addmod(const report_cfg_to_add_mo
void rrc::rrc_meas::var_meas_cfg::log_debug_trigger_value_interrat(
const report_cfg_inter_rat_s::trigger_type_c_::event_s_::event_id_c_& e)
{
if (log_h->get_level() == LOG_LEVEL_DEBUG) {
if (logger.debug.enabled()) {
switch (e.type()) {
case report_cfg_inter_rat_s::trigger_type_c_::event_s_::event_id_c_::types_opts::event_b1_nr_r15: {
log_h->debug("MEAS: B1-NR-R15-threashold (%d)=%.1f dBm\n",
logger.debug("MEAS: B1-NR-R15-threashold (%d)=%.1f dBm",
e.event_b1_nr_r15().b1_thres_nr_r15.nr_rsrp_r15(),
range_to_value_nr(asn1::rrc::thres_nr_r15_c::types_opts::options::nr_rsrp_r15, e.event_b1_nr_r15().b1_thres_nr_r15.nr_rsrp_r15()));
range_to_value_nr(asn1::rrc::thres_nr_r15_c::types_opts::options::nr_rsrp_r15,
e.event_b1_nr_r15().b1_thres_nr_r15.nr_rsrp_r15()));
break;
}
default:
log_h->debug("MEAS: Unsupported inter rat trigger type %s\n", e.type().to_string().c_str());
logger.debug("MEAS: Unsupported inter rat trigger type %s", e.type().to_string().c_str());
break;
}
}
@ -1482,26 +1482,26 @@ void rrc::rrc_meas::var_meas_cfg::log_debug_trigger_value_interrat(
// Warning: Use for Test debug purposes only. Assumes thresholds in RSRP
void rrc::rrc_meas::var_meas_cfg::log_debug_trigger_value_eutra(const eutra_event_s::event_id_c_& e)
{
if (log_h->get_level() == LOG_LEVEL_DEBUG) {
if (logger.debug.enabled()) {
switch (e.type()) {
case eutra_event_s::event_id_c_::types_opts::event_a1:
log_h->debug("MEAS: A1-threshold=%.1f dBm\n",
logger.debug("MEAS: A1-threshold=%.1f dBm",
range_to_value(report_cfg_eutra_s::trigger_quant_opts::rsrp, e.event_a1().a1_thres.thres_rsrp()));
break;
case eutra_event_s::event_id_c_::types_opts::event_a2:
log_h->debug("MEAS: A2-threshold=%.1f dBm\n",
logger.debug("MEAS: A2-threshold=%.1f dBm",
range_to_value(report_cfg_eutra_s::trigger_quant_opts::rsrp, e.event_a2().a2_thres.thres_rsrp()));
break;
case eutra_event_s::event_id_c_::types_opts::event_a3:
log_h->debug("MEAS: A3-offset=%.1f dB\n",
logger.debug("MEAS: A3-offset=%.1f dB",
range_to_value(report_cfg_eutra_s::trigger_quant_opts::rsrp, e.event_a3().a3_offset));
break;
case eutra_event_s::event_id_c_::types_opts::event_a4:
log_h->debug("MEAS: A4-threshold=%.1f dBm\n",
logger.debug("MEAS: A4-threshold=%.1f dBm",
range_to_value(report_cfg_eutra_s::trigger_quant_opts::rsrp, e.event_a4().a4_thres.thres_rsrp()));
break;
default:
log_h->debug("MEAS: Unsupported\n");
logger.debug("MEAS: Unsupported");
break;
}
}
@ -1516,7 +1516,7 @@ void rrc::rrc_meas::var_meas_cfg::measId_removal(const meas_id_to_rem_list_l& li
if (measIdList.count(l)) {
measIdList.erase(l);
remove_varmeas_report(l);
log_h->info("MEAS: Removed measId=%d\n", l);
logger.info("MEAS: Removed measId=%d", l);
}
}
}
@ -1527,11 +1527,11 @@ void rrc::rrc_meas::var_meas_cfg::measId_addmod(const meas_id_to_add_mod_list_l&
for (auto& l : list) {
// configure only if report and object exists
if (reportConfigList.count(l.report_cfg_id) == 0) {
log_h->error("MEAS: Adding measId=%d, reportConfigId=%d doesn't exist\n", l.meas_id, l.report_cfg_id);
logger.error("MEAS: Adding measId=%d, reportConfigId=%d doesn't exist", l.meas_id, l.report_cfg_id);
continue;
}
if (measObjectsList.count(l.meas_obj_id) == 0) {
log_h->error("MEAS: Adding measId=%d, measObjectId=%d doesn't exist\n", l.meas_id, l.meas_obj_id);
logger.error("MEAS: Adding measId=%d, measObjectId=%d doesn't exist", l.meas_id, l.meas_obj_id);
continue;
}
// add/replace entry in VarMeasConfig. Safe to use [] operator here
@ -1540,8 +1540,8 @@ void rrc::rrc_meas::var_meas_cfg::measId_addmod(const meas_id_to_add_mod_list_l&
// remove the measurement reporting entry for this measId from the VarMeasReportList, if included
remove_varmeas_report(l.meas_id);
log_h->info(
"MEAS: AddMod measId=%d, measObjectId=%d, reportConfigId=%d\n", l.meas_id, l.meas_obj_id, l.report_cfg_id);
logger.info(
"MEAS: AddMod measId=%d, measObjectId=%d, reportConfigId=%d", l.meas_id, l.meas_obj_id, l.report_cfg_id);
}
}
@ -1565,7 +1565,7 @@ void rrc::rrc_meas::var_meas_cfg::quantity_config(const quant_cfg_s& cfg)
filter_a.rsrp = powf(0.5f, (float)k_rsrp / 4.0f);
filter_a.rsrq = powf(0.5f, (float)k_rsrq / 4.0f);
log_h->info("MEAS: Quantity configuration k_rsrp=%d, k_rsrq=%d\n", k_rsrp, k_rsrq);
logger.info("MEAS: Quantity configuration k_rsrp=%d, k_rsrq=%d", k_rsrp, k_rsrq);
// for each measId included in the measIdList within VarMeasConfig
for (auto& m : measIdList) {
@ -1632,7 +1632,7 @@ bool rrc::rrc_meas::var_meas_cfg::parse_meas_config(const meas_cfg_s* cfg, bool
ho_reest_finish(src_earfcn, target_earfcn);
}
} else {
log_h->warning("MEAS: Could not get serving cell earfcn\n");
logger.warning("MEAS: Could not get serving cell earfcn");
}
}
return true;

@ -63,7 +63,7 @@ void rrc_nr::stop()
void rrc_nr::init_core_less()
{
log_h->info("Creating dummy DRB on LCID=%d\n", args.coreless.drb_lcid);
log_h->info("Creating dummy DRB on LCID=%d", args.coreless.drb_lcid);
srslte::rlc_config_t rlc_cnfg = srslte::rlc_config_t::default_rlc_um_nr_config(6);
rlc->add_bearer(args.coreless.drb_lcid, rlc_cnfg);
@ -83,9 +83,9 @@ void rrc_nr::get_metrics(rrc_nr_metrics_t& m) {}
// Timeout callback interface
void rrc_nr::timer_expired(uint32_t timeout_id)
{
log_h->debug("[NR] Handling Timer Expired\n");
log_h->debug("[NR] Handling Timer Expired");
if (timeout_id == fake_measurement_timer.id()) {
log_h->debug("[NR] Triggered Fake Measurement\n");
log_h->debug("[NR] Triggered Fake Measurement");
phy_meas_nr_t fake_meas = {};
std::vector<phy_meas_nr_t> phy_meas_nr;
@ -113,18 +113,18 @@ void rrc_nr::log_rrc_message(const std::string& source,
const std::string& msg_type)
{
if (log_h->get_level() == srslte::LOG_LEVEL_INFO) {
log_h->info("%s - %s %s (%d B)\n", source.c_str(), (dir == Rx) ? "Rx" : "Tx", msg_type.c_str(), pdu->N_bytes);
log_h->info("%s - %s %s (%d B)", source.c_str(), (dir == Rx) ? "Rx" : "Tx", msg_type.c_str(), pdu->N_bytes);
} else if (log_h->get_level() >= srslte::LOG_LEVEL_DEBUG) {
asn1::json_writer json_writer;
msg.to_json(json_writer);
log_h->debug_hex(pdu->msg,
pdu->N_bytes,
"%s - %s %s (%d B)\n",
"%s - %s %s (%d B)",
source.c_str(),
(dir == Rx) ? "Rx" : "Tx",
msg_type.c_str(),
pdu->N_bytes);
log_h->debug_long("Content:\n%s\n", json_writer.to_string().c_str());
log_h->debug_long("Content:\n%s", json_writer.to_string().c_str());
}
}
@ -136,28 +136,28 @@ void rrc_nr::log_rrc_message(const std::string& source,
const std::string& msg_type)
{
if (log_h->get_level() == srslte::LOG_LEVEL_INFO) {
log_h->info("%s - %s %s (%d B)\n", source.c_str(), (dir == Rx) ? "Rx" : "Tx", msg_type.c_str(), oct.size());
log_h->info("%s - %s %s (%d B)", source.c_str(), (dir == Rx) ? "Rx" : "Tx", msg_type.c_str(), oct.size());
} else if (log_h->get_level() >= srslte::LOG_LEVEL_DEBUG) {
asn1::json_writer json_writer;
msg.to_json(json_writer);
log_h->debug_hex(oct.data(),
oct.size(),
"%s - %s %s (%d B)\n",
"%s - %s %s (%d B)",
source.c_str(),
(dir == Rx) ? "Rx" : "Tx",
msg_type.c_str(),
oct.size());
log_h->debug_long("Content:\n%s\n", json_writer.to_string().c_str());
log_h->debug_long("Content:\n%s", json_writer.to_string().c_str());
}
}
bool rrc_nr::add_lcid_rb(uint32_t lcid, rb_type_t rb_type, uint32_t rbid)
{
if (lcid_rb.find(lcid) != lcid_rb.end()) {
log_h->error("Couldn't add RB to LCID. RB %d does exist.\n", rbid);
log_h->error("Couldn't add RB to LCID. RB %d does exist.", rbid);
return false;
} else {
log_h->info("Adding lcid %d and radio bearer ID %d with type %s \n", lcid, rbid, (rb_type == Srb) ? "SRB" : "DRB");
log_h->info("Adding lcid %d and radio bearer ID %d with type %s ", lcid, rbid, (rb_type == Srb) ? "SRB" : "DRB");
lcid_rb[lcid].rb_id = rbid;
lcid_rb[lcid].rb_type = rb_type;
}
@ -171,7 +171,7 @@ uint32_t rrc_nr::get_lcid_for_rbid(uint32_t rb_id)
return rb.first;
}
}
log_h->error("Couldn't find LCID for rb LCID. RB %d does exist.\n", rb_id);
log_h->error("Couldn't find LCID for rb LCID. RB %d does exist.", rb_id);
return 0;
}
@ -307,7 +307,7 @@ void rrc_nr::get_eutra_nr_capabilities(srslte::byte_buffer_t* eutra_nr_caps_pdu)
#endif
log_h->debug_hex(
eutra_nr_caps_pdu->msg, eutra_nr_caps_pdu->N_bytes, "EUTRA-NR capabilities (%u B)\n", eutra_nr_caps_pdu->N_bytes);
eutra_nr_caps_pdu->msg, eutra_nr_caps_pdu->N_bytes, "EUTRA-NR capabilities (%u B)", eutra_nr_caps_pdu->N_bytes);
return;
}
@ -324,7 +324,7 @@ bool rrc_nr::rrc_reconfiguration(bool endc_release_and_add_r15,
// sanity check only for now
if (nr_secondary_cell_group_cfg_r15_present == false || sk_counter_r15_present == false ||
nr_radio_bearer_cfg1_r15_present == false) {
log_h->error("RRC NR Reconfiguration failed sanity check failed\n");
log_h->error("RRC NR Reconfiguration failed sanity check failed");
return false;
}
@ -337,7 +337,7 @@ bool rrc_nr::rrc_reconfiguration(bool endc_release_and_add_r15,
err = rrc_recfg.unpack(bref);
if (err != asn1::SRSASN_SUCCESS) {
log_h->error("Could not unpack NR reconfiguration message.\n");
log_h->error("Could not unpack NR reconfiguration message.");
return false;
}
@ -351,7 +351,7 @@ bool rrc_nr::rrc_reconfiguration(bool endc_release_and_add_r15,
err = cell_group_cfg.unpack(bref0);
if (err != asn1::SRSASN_SUCCESS) {
log_h->error("Could not unpack cell group message message.\n");
log_h->error("Could not unpack cell group message message.");
return false;
}
@ -361,7 +361,7 @@ bool rrc_nr::rrc_reconfiguration(bool endc_release_and_add_r15,
cell_group_cfg,
"Secondary Cell Group Config");
} else {
log_h->error("Reconfiguration does not contain Secondary Cell Group Config\n");
log_h->error("Reconfiguration does not contain Secondary Cell Group Config");
return false;
}
}
@ -370,7 +370,7 @@ bool rrc_nr::rrc_reconfiguration(bool endc_release_and_add_r15,
err = radio_bearer_cfg.unpack(bref1);
if (err != asn1::SRSASN_SUCCESS) {
log_h->error("Could not unpack radio bearer config.\n");
log_h->error("Could not unpack radio bearer config.");
return false;
}
@ -381,7 +381,7 @@ bool rrc_nr::rrc_reconfiguration(bool endc_release_and_add_r15,
sk_counter_r15_present,
sk_counter_r15,
radio_bearer_cfg)) {
log_h->error("Unable to launch NR RRC configuration procedure\n");
log_h->error("Unable to launch NR RRC configuration procedure");
return false;
} else {
callback_list.add_proc(conn_recfg_proc);
@ -427,7 +427,7 @@ void rrc_nr::get_nr_capabilities(srslte::byte_buffer_t* nr_caps_pdu)
}
#endif
log_h->debug_hex(nr_caps_pdu->msg, nr_caps_pdu->N_bytes, "NR capabilities (%u B)\n", nr_caps_pdu->N_bytes);
log_h->debug_hex(nr_caps_pdu->msg, nr_caps_pdu->N_bytes, "NR capabilities (%u B)", nr_caps_pdu->N_bytes);
return;
};
@ -435,15 +435,15 @@ void rrc_nr::phy_meas_stop()
{
// possbile race condition for fake_measurement timer, which might be set at the same moment as stopped => fix with
// phy integration
log_h->debug("[NR] Stopping fake measurements\n");
log_h->debug("[NR] Stopping fake measurements");
fake_measurement_timer.stop();
}
void rrc_nr::phy_set_cells_to_meas(uint32_t carrier_freq_r15)
{
log_h->debug("[NR] Measuring phy cell %d \n", carrier_freq_r15);
log_h->debug("[NR] Measuring phy cell %d ", carrier_freq_r15);
// Start timer for fake measurements
auto timer_expire_func = [this](uint32_t tid) { timer_expired(tid); };
auto timer_expire_func = [this](uint32_t tid) { timer_expired(tid); };
fake_measurement_carrier_freq_r15 = carrier_freq_r15;
fake_measurement_timer.set(10, timer_expire_func);
fake_measurement_timer.run();
@ -451,7 +451,7 @@ void rrc_nr::phy_set_cells_to_meas(uint32_t carrier_freq_r15)
void rrc_nr::configure_sk_counter(uint16_t sk_counter)
{
log_h->info("[NR] Configure new SK counter %d. Update Key for secondary gnb\n", sk_counter);
log_h->info("[NR] Configure new SK counter %d. Update Key for secondary gnb", sk_counter);
usim->generate_nr_context(sk_counter, &sec_cfg);
}
bool rrc_nr::is_config_pending()
@ -479,7 +479,7 @@ bool rrc_nr::apply_rlc_add_mod(const rlc_bearer_cfg_s& rlc_bearer_cfg)
add_lcid_rb(lc_ch_id, Srb, srb_id);
}
} else {
log_h->warning("In RLC bearer cfg does not contain served radio bearer\n");
log_h->warning("In RLC bearer cfg does not contain served radio bearer");
return false;
}
@ -490,13 +490,13 @@ bool rrc_nr::apply_rlc_add_mod(const rlc_bearer_cfg_s& rlc_bearer_cfg)
rlc_bearer_cfg.rlc_cfg.um_bi_dir().ul_um_rlc.sn_field_len_present &&
rlc_bearer_cfg.rlc_cfg.um_bi_dir().dl_um_rlc.sn_field_len !=
rlc_bearer_cfg.rlc_cfg.um_bi_dir().ul_um_rlc.sn_field_len) {
log_h->warning("NR RLC sequence number length is not the same in uplink and downlink\n");
log_h->warning("NR RLC sequence number length is not the same in uplink and downlink");
}
} else {
log_h->warning("NR RLC type is not unacknowledged mode bidirectional\n");
log_h->warning("NR RLC type is not unacknowledged mode bidirectional");
}
} else {
log_h->warning("In RLC bearer cfg does not contain rlc cfg\n");
log_h->warning("In RLC bearer cfg does not contain rlc cfg");
return false;
}
@ -517,20 +517,20 @@ bool rrc_nr::apply_mac_cell_group(const mac_cell_group_cfg_s& mac_cell_group_cfg
sr_cfg_t sr_cfg;
if (mac_cell_group_cfg.sched_request_cfg.sched_request_to_add_mod_list_present) {
if (mac_cell_group_cfg.sched_request_cfg.sched_request_to_add_mod_list.size() > 1) {
log_h->warning("Only handling 1 scheduling request index to add\n");
log_h->warning("Only handling 1 scheduling request index to add");
sr_cfg.dsr_transmax = mac_cell_group_cfg.sched_request_cfg.sched_request_to_add_mod_list[1].sr_trans_max;
mac->set_config(sr_cfg);
}
}
if (mac_cell_group_cfg.sched_request_cfg.sched_request_to_release_list_present) {
log_h->warning("Not handling sched request to release list\n");
log_h->warning("Not handling sched request to release list");
}
}
if (mac_cell_group_cfg.sched_request_cfg_present)
if (mac_cell_group_cfg.bsr_cfg_present) {
log_h->debug("Handling MAC BSR config\n");
log_h->debug("Handling MAC BSR config");
srslte::bsr_cfg_t bsr_cfg;
bsr_cfg.periodic_timer = mac_cell_group_cfg.bsr_cfg.periodic_bsr_timer.to_number();
bsr_cfg.retx_timer = mac_cell_group_cfg.bsr_cfg.retx_bsr_timer.to_number();
@ -538,15 +538,15 @@ bool rrc_nr::apply_mac_cell_group(const mac_cell_group_cfg_s& mac_cell_group_cfg
}
if (mac_cell_group_cfg.tag_cfg_present) {
log_h->warning("Not handling tag cfg in MAC cell group config\n");
log_h->warning("Not handling tag cfg in MAC cell group config");
}
if (mac_cell_group_cfg.phr_cfg_present) {
log_h->warning("Not handling phr cfg in MAC cell group config\n");
log_h->warning("Not handling phr cfg in MAC cell group config");
}
if (mac_cell_group_cfg.skip_ul_tx_dynamic) {
log_h->warning("Not handling phr cfg in skip_ul_tx_dynamic cell group config\n");
log_h->warning("Not handling phr cfg in skip_ul_tx_dynamic cell group config");
}
return true;
}
@ -554,7 +554,7 @@ bool rrc_nr::apply_mac_cell_group(const mac_cell_group_cfg_s& mac_cell_group_cfg
bool rrc_nr::apply_sp_cell_cfg(const sp_cell_cfg_s& sp_cell_cfg)
{
// TODO Setup PHY @andre and @phy interface?
log_h->warning("Not handling SP Cell config\n");
log_h->warning("Not handling SP Cell config");
return true;
}
@ -569,7 +569,7 @@ bool rrc_nr::apply_cell_group_cfg(const cell_group_cfg_s& cell_group_cfg)
apply_mac_cell_group(cell_group_cfg.mac_cell_group_cfg);
}
if (cell_group_cfg.phys_cell_group_cfg_present == true) {
log_h->warning("Not handling physical cell group config\n");
log_h->warning("Not handling physical cell group config");
}
if (cell_group_cfg.sp_cell_cfg_present) {
// apply_sp_cell_cfg(cell_group_cfg.sp_cell_cfg);
@ -580,7 +580,7 @@ bool rrc_nr::apply_cell_group_cfg(const cell_group_cfg_s& cell_group_cfg)
bool rrc_nr::apply_drb_add_mod(const drb_to_add_mod_s& drb_cfg)
{
if (!drb_cfg.pdcp_cfg_present) {
log_h->error("Cannot add DRB - incomplete configuration\n");
log_h->error("Cannot add DRB - incomplete configuration");
return false;
}
@ -588,17 +588,17 @@ bool rrc_nr::apply_drb_add_mod(const drb_to_add_mod_s& drb_cfg)
// Setup PDCP
if (!(drb_cfg.pdcp_cfg.drb_present == true)) {
log_h->error("PDCP config does not contain DRB config\n");
log_h->error("PDCP config does not contain DRB config");
return false;
}
if (!(drb_cfg.cn_assoc_present == true)) {
log_h->error("DRB config does not contain an associated cn\n");
log_h->error("DRB config does not contain an associated cn");
return false;
}
if (!(drb_cfg.cn_assoc.type() == drb_to_add_mod_s::cn_assoc_c_::types_opts::eps_bearer_id)) {
log_h->error("CN associtaion type not supported %s \n", drb_cfg.cn_assoc.type().to_string().c_str());
log_h->error("CN associtaion type not supported %s ", drb_cfg.cn_assoc.type().to_string().c_str());
return false;
}
@ -606,7 +606,7 @@ bool rrc_nr::apply_drb_add_mod(const drb_to_add_mod_s& drb_cfg)
if (drb_cfg.pdcp_cfg.drb.pdcp_sn_size_dl_present && drb_cfg.pdcp_cfg.drb.pdcp_sn_size_ul_present &&
(drb_cfg.pdcp_cfg.drb.pdcp_sn_size_ul.to_number() != drb_cfg.pdcp_cfg.drb.pdcp_sn_size_dl.to_number())) {
log_h->warning("PDCP SN size in UL and DL are not the same. make_drb_pdcp_config_t will use the DL SN size %d \n",
log_h->warning("PDCP SN size in UL and DL are not the same. make_drb_pdcp_config_t will use the DL SN size %d ",
drb_cfg.pdcp_cfg.drb.pdcp_sn_size_dl.to_number());
}
@ -622,7 +622,7 @@ bool rrc_nr::apply_security_cfg(const security_cfg_s& security_cfg)
// TODO derive correct keys
if (security_cfg.key_to_use_present) {
if (security_cfg.key_to_use.value != security_cfg_s::key_to_use_opts::options::secondary) {
log_h->warning("Only secondary key supported yet\n");
log_h->warning("Only secondary key supported yet");
}
}
@ -641,7 +641,7 @@ bool rrc_nr::apply_security_cfg(const security_cfg_s& security_cfg)
sec_cfg.cipher_algo = CIPHERING_ALGORITHM_ID_128_EEA3;
break;
default:
log_h->warning("Unsupported algorithm\n");
log_h->warning("Unsupported algorithm");
break;
}
@ -660,7 +660,7 @@ bool rrc_nr::apply_security_cfg(const security_cfg_s& security_cfg)
sec_cfg.integ_algo = INTEGRITY_ALGORITHM_ID_128_EIA3;
break;
default:
log_h->warning("Unsupported algorithm\n");
log_h->warning("Unsupported algorithm");
break;
}
}
@ -704,19 +704,19 @@ proc_outcome_t rrc_nr::connection_reconf_no_ho_proc::init(const bool
const uint32_t sk_counter_r15,
const asn1::rrc_nr::radio_bearer_cfg_s& radio_bearer_cfg)
{
Info("Starting...\n");
Info("Starting...");
Info("Applying Cell Group Cfg\n");
Info("Applying Cell Group Cfg");
if (!rrc_ptr->apply_cell_group_cfg(cell_group_cfg)) {
return proc_outcome_t::error;
}
if (sk_counter_r15_present) {
Info("Applying Cell Group Cfg\n");
Info("Applying Cell Group Cfg");
rrc_ptr->configure_sk_counter((uint16_t)sk_counter_r15);
}
Info("Applying Radio Bearer Cfg\n");
Info("Applying Radio Bearer Cfg");
if (!rrc_ptr->apply_radio_bearer_cfg(radio_bearer_cfg)) {
return proc_outcome_t::error;
}
@ -726,21 +726,21 @@ proc_outcome_t rrc_nr::connection_reconf_no_ho_proc::init(const bool
proc_outcome_t rrc_nr::connection_reconf_no_ho_proc::react(const bool& config_complete)
{
if (not config_complete) {
Error("Failed to config PHY\n");
Error("Failed to config PHY");
return proc_outcome_t::error;
}
rrc_ptr->rrc_eutra->nr_rrc_con_reconfig_complete(true);
Info("Reconfig NR return successful\n");
Info("Reconfig NR return successful");
return proc_outcome_t::success;
}
void rrc_nr::connection_reconf_no_ho_proc::then(const srslte::proc_state_t& result)
{
if (result.is_success()) {
Info("Finished %s successfully\n", name());
srslte::console("RRC NR reconfiguration successful.\n");
Info("Finished %s successfully", name());
srslte::console("RRC NR reconfiguration successful.");
return;
}

@ -17,10 +17,10 @@
#include "srsue/hdr/stack/rrc/rrc_meas.h"
#include <inttypes.h> // for printing uint64_t
#define Error(fmt, ...) rrc_ptr->rrc_log->error("Proc \"%s\" - " fmt, name(), ##__VA_ARGS__)
#define Warning(fmt, ...) rrc_ptr->rrc_log->warning("Proc \"%s\" - " fmt, name(), ##__VA_ARGS__)
#define Info(fmt, ...) rrc_ptr->rrc_log->info("Proc \"%s\" - " fmt, name(), ##__VA_ARGS__)
#define Debug(fmt, ...) rrc_ptr->rrc_log->debug("Proc \"%s\" - " fmt, name(), ##__VA_ARGS__)
#define Error(fmt, ...) rrc_ptr->logger.error("Proc \"%s\" - " fmt, name(), ##__VA_ARGS__)
#define Warning(fmt, ...) rrc_ptr->logger.warning("Proc \"%s\" - " fmt, name(), ##__VA_ARGS__)
#define Info(fmt, ...) rrc_ptr->logger.info("Proc \"%s\" - " fmt, name(), ##__VA_ARGS__)
#define Debug(fmt, ...) rrc_ptr->logger.debug("Proc \"%s\" - " fmt, name(), ##__VA_ARGS__)
namespace srsue {
@ -36,10 +36,10 @@ rrc::cell_search_proc::cell_search_proc(rrc* parent_) : rrc_ptr(parent_) {}
/* Searches for a cell in the current frequency and retrieves SIB1 if not retrieved yet */
proc_outcome_t rrc::cell_search_proc::init()
{
Info("Starting...\n");
Info("Starting...");
state = state_t::phy_cell_search;
if (not rrc_ptr->phy_ctrl->start_cell_search(rrc_ptr->cell_searcher)) {
Warning("Failed to initiate Cell Search.\n");
Warning("Failed to initiate Cell Search.");
return proc_outcome_t::error;
}
return proc_outcome_t::yield;
@ -68,22 +68,22 @@ proc_outcome_t rrc::cell_search_proc::step_si_acquire()
}
// SI Acquire has completed
if (si_acquire_fut.is_error()) {
Error("Failed SI acquire for SIB0\n");
Error("Failed SI acquire for SIB0");
search_result.cs_ret.found = cell_search_ret_t::CELL_NOT_FOUND;
return proc_outcome_t::success;
}
Info("Completed successfully\n");
Info("Completed successfully");
return proc_outcome_t::success;
}
proc_outcome_t rrc::cell_search_proc::handle_cell_found(const phy_cell_t& new_cell)
{
Info("Cell found in this frequency. Setting new serving cell EARFCN=%d PCI=%d ...\n", new_cell.earfcn, new_cell.pci);
Info("Cell found in this frequency. Setting new serving cell EARFCN=%d PCI=%d ...", new_cell.earfcn, new_cell.pci);
// Create a cell with NaN RSRP. Will be updated by new_phy_meas() during SIB search.
if (not rrc_ptr->meas_cells.add_meas_cell(
unique_cell_t(new meas_cell_eutra(new_cell, rrc_ptr->task_sched.get_unique_timer())))) {
Error("Could not add new found cell\n");
Error("Could not add new found cell");
return proc_outcome_t::error;
}
@ -92,7 +92,7 @@ proc_outcome_t rrc::cell_search_proc::handle_cell_found(const phy_cell_t& new_ce
// set new serving cell in PHY
state = state_t::phy_cell_select;
if (not rrc_ptr->phy_ctrl->start_cell_select(rrc_ptr->meas_cells.serving_cell().phy_cell, rrc_ptr->cell_searcher)) {
Error("Couldn't start phy cell selection\n");
Error("Couldn't start phy cell selection");
return proc_outcome_t::error;
}
return proc_outcome_t::yield;
@ -105,14 +105,14 @@ proc_outcome_t rrc::cell_search_proc::step_wait_measurement()
}
if (rrc_ptr->meas_cells.serving_cell().has_sib1()) {
Info("Cell has SIB1\n");
Info("Cell has SIB1");
return proc_outcome_t::success;
}
Info("Cell has no SIB1. Obtaining SIB1...\n");
Info("Cell has no SIB1. Obtaining SIB1...");
if (not rrc_ptr->si_acquirer.launch(&si_acquire_fut, 0)) {
// disallow concurrent si_acquire
Error("SI Acquire is already running...\n");
Error("SI Acquire is already running...");
return proc_outcome_t::error;
}
state = state_t::si_acquire;
@ -122,24 +122,24 @@ proc_outcome_t rrc::cell_search_proc::step_wait_measurement()
proc_outcome_t rrc::cell_search_proc::react(const bool& cs_ret)
{
if (state != state_t::phy_cell_select) {
Warning("Received unexpected cell search result\n");
Warning("Received unexpected cell search result");
return proc_outcome_t::yield;
}
if (not cs_ret) {
Error("Couldn't select new serving cell\n");
Error("Couldn't select new serving cell");
search_result.cs_ret.found = cell_search_ret_t::CELL_NOT_FOUND;
return proc_outcome_t::success;
}
if (not rrc_ptr->phy->cell_is_camping()) {
Warning("Could not camp on found cell.\n");
Warning("Could not camp on found cell.");
search_result.cs_ret.found = cell_search_ret_t::CELL_NOT_FOUND;
return proc_outcome_t::success;
}
if (not std::isnormal(rrc_ptr->meas_cells.serving_cell().get_rsrp())) {
Info("No valid measurement found for the serving cell. Wait for valid measurement...\n");
Info("No valid measurement found for the serving cell. Wait for valid measurement...");
}
state = state_t::wait_measurement;
return proc_outcome_t::yield;
@ -148,7 +148,7 @@ proc_outcome_t rrc::cell_search_proc::react(const bool& cs_ret)
proc_outcome_t rrc::cell_search_proc::react(const phy_controller::cell_srch_res& event)
{
if (state != state_t::phy_cell_search) {
Error("Received unexpected cell search result\n");
Error("Received unexpected cell search result");
return proc_outcome_t::error;
}
search_result = event;
@ -236,7 +236,7 @@ compute_si_window(uint32_t tti, uint32_t sib_index, uint32_t n, uint32_t T, cons
rrc::si_acquire_proc::si_acquire_proc(rrc* parent_) :
rrc_ptr(parent_),
log_h(srslte::logmap::get("RRC")),
logger(srslog::fetch_basic_logger("RRC")),
si_acq_timeout(rrc_ptr->task_sched.get_unique_timer()),
si_acq_retry_timer(rrc_ptr->task_sched.get_unique_timer())
{
@ -252,22 +252,22 @@ proc_outcome_t rrc::si_acquire_proc::init(uint32_t sib_index_)
{
// make sure we dont already have the SIB of interest
if (rrc_ptr->meas_cells.serving_cell().has_sib(sib_index_)) {
Info("The UE has already acquired SIB%d\n", sib_index + 1);
Info("The UE has already acquired SIB%d", sib_index + 1);
return proc_outcome_t::success;
}
Info("Starting SI Acquisition procedure for SIB%d\n", sib_index_ + 1);
Info("Starting SI Acquisition procedure for SIB%d", sib_index_ + 1);
// make sure SIB1 is captured before other SIBs
sib_index = sib_index_;
if (sib_index > 0 and not rrc_ptr->meas_cells.serving_cell().has_sib1()) {
Error("Trying to acquire SIB%d but SIB1 not received yet\n", sib_index + 1);
Error("Trying to acquire SIB%d but SIB1 not received yet", sib_index + 1);
return proc_outcome_t::error;
}
// compute the si-Periodicity and schedInfoList index
auto ret = compute_si_periodicity_and_idx(sib_index, rrc_ptr->meas_cells.serving_cell().sib1ptr());
if (ret.second < 0) {
Info("Could not find SIB%d scheduling in SIB1\n", sib_index + 1);
Info("Could not find SIB%d scheduling in SIB1", sib_index + 1);
return proc_outcome_t::error;
}
period = ret.first; // si-Periodicity
@ -289,9 +289,9 @@ void rrc::si_acquire_proc::then(const srslte::proc_state_t& result)
si_acq_timeout.stop();
if (result.is_success()) {
Info("SIB%d acquired successfully\n", sib_index + 1);
Info("SIB%d acquired successfully", sib_index + 1);
} else {
Error("Failed to acquire SIB%d\n", sib_index + 1);
Error("Failed to acquire SIB%d", sib_index + 1);
}
}
@ -305,7 +305,7 @@ void rrc::si_acquire_proc::start_si_acquire()
compute_si_window(tti.to_uint(), sib_index, sched_index, period, rrc_ptr->meas_cells.serving_cell().sib1ptr());
tti_point si_win_start = tti_point{ret.first};
if (si_win_start < tti) {
Error("The SI Window start was incorrectly calculated. si_win_start=%d, tti=%d\n",
Error("The SI Window start was incorrectly calculated. si_win_start=%d, tti=%d",
si_win_start.to_uint(),
tti.to_uint());
return;
@ -320,7 +320,7 @@ void rrc::si_acquire_proc::start_si_acquire()
si_acq_retry_timer.set(tics_until_si_retry);
si_acq_retry_timer.run();
Info("Instructed MAC to search for SIB%d, win_start=%d, win_len=%d, period=%d, sched_index=%d\n",
Info("Instructed MAC to search for SIB%d, win_start=%d, win_len=%d, period=%d, sched_index=%d",
sib_index + 1,
si_win_start.to_uint(),
si_win_len,
@ -341,16 +341,16 @@ proc_outcome_t rrc::si_acquire_proc::react(si_acq_timer_expired ev)
// retry si acquire
if (ev.timer_id == si_acq_retry_timer.id()) {
Info("SI Acquire Retry Timeout for SIB%d\n", sib_index + 1);
Info("SI Acquire Retry Timeout for SIB%d", sib_index + 1);
start_si_acquire();
return proc_outcome_t::yield;
}
// timeout. SI acquire failed
if (ev.timer_id == si_acq_timeout.id()) {
Error("Timeout while acquiring SIB%d\n", sib_index + 1);
Error("Timeout while acquiring SIB%d", sib_index + 1);
} else {
Error("Unrecognized timer id\n");
Error("Unrecognized timer id");
}
return proc_outcome_t::error;
}
@ -360,8 +360,7 @@ proc_outcome_t rrc::si_acquire_proc::react(si_acq_timer_expired ev)
*************************************/
rrc::serving_cell_config_proc::serving_cell_config_proc(rrc* parent_) :
rrc_ptr(parent_),
log_h(srslte::logmap::get("RRC"))
rrc_ptr(parent_), logger(srslog::fetch_basic_logger("RRC"))
{}
/*
@ -374,10 +373,10 @@ proc_outcome_t rrc::serving_cell_config_proc::init(const std::vector<uint32_t>&
std::sort(required_sibs.begin(), required_sibs.end());
required_sibs.erase(std::unique(required_sibs.begin(), required_sibs.end()), required_sibs.end());
Info("Starting a Serving Cell Configuration Procedure\n");
Info("Starting a Serving Cell Configuration Procedure");
if (not rrc_ptr->phy->cell_is_camping()) {
Error("Trying to configure Cell while not camping on it\n");
Error("Trying to configure Cell while not camping on it");
return proc_outcome_t::error;
}
@ -394,9 +393,9 @@ srslte::proc_outcome_t rrc::serving_cell_config_proc::launch_sib_acquire()
uint32_t required_sib = required_sibs[req_idx];
if (not rrc_ptr->meas_cells.serving_cell().has_sib(required_sib)) {
if (required_sib < 2 or rrc_ptr->meas_cells.serving_cell().is_sib_scheduled(required_sib)) {
Info("Cell has no SIB%d. Obtaining SIB%d\n", required_sib + 1, required_sib + 1);
Info("Cell has no SIB%d. Obtaining SIB%d", required_sib + 1, required_sib + 1);
if (not rrc_ptr->si_acquirer.launch(&si_acquire_fut, required_sib)) {
Error("SI Acquire is already running...\n");
Error("SI Acquire is already running...");
return proc_outcome_t::error;
}
// wait for si acquire to finish
@ -405,7 +404,7 @@ srslte::proc_outcome_t rrc::serving_cell_config_proc::launch_sib_acquire()
// SIB is not scheduled in SchedInfoList. Skipping it...
} else {
// UE had SIB already. Handle its SIB
Info("Cell has SIB%d\n", required_sib + 1);
Info("Cell has SIB%d", required_sib + 1);
switch (required_sib) {
case 1:
rrc_ptr->handle_sib2();
@ -419,7 +418,7 @@ srslte::proc_outcome_t rrc::serving_cell_config_proc::launch_sib_acquire()
}
}
Info("Serving Cell Configuration Procedure has finished successfully\n");
Info("Serving Cell Configuration Procedure has finished successfully");
return proc_outcome_t::success;
}
@ -431,7 +430,7 @@ proc_outcome_t rrc::serving_cell_config_proc::step()
uint32_t required_sib = required_sibs[req_idx];
if (si_acquire_fut.is_error() or not rrc_ptr->meas_cells.serving_cell().has_sib(required_sib)) {
if (required_sib < 2) {
log_h->warning("Serving Cell Configuration has failed\n");
logger.warning("Serving Cell Configuration has failed");
return proc_outcome_t::error;
}
}
@ -505,21 +504,21 @@ proc_outcome_t rrc::cell_selection_proc::init(std::vector<uint32_t> required_sib
// Skip cell selection if serving cell is suitable and there are no stronger neighbours in same earfcn
if (is_serv_cell_suitable() and not stronger_neigh) {
Debug("Skipping cell selection procedure as there are no stronger neighbours in same EARFCN.\n");
Debug("Skipping cell selection procedure as there are no stronger neighbours in same EARFCN.");
return set_proc_complete();
}
Info("Starting...\n");
Info("Current neighbor cells: [%s]\n", meas_cells->print_neighbour_cells().c_str());
Info("Current PHY state: %s\n", rrc_ptr->phy_ctrl->is_in_sync() ? "in-sync" : "out-of-sync");
Info("Starting...");
Info("Current neighbor cells: [%s]", meas_cells->print_neighbour_cells().c_str());
Info("Current PHY state: %s", rrc_ptr->phy_ctrl->is_in_sync() ? "in-sync" : "out-of-sync");
if (meas_cells->serving_cell().has_sib3()) {
Info("Cell selection criteria: Qrxlevmin=%f, Qrxlevminoffset=%f\n",
Info("Cell selection criteria: Qrxlevmin=%f, Qrxlevminoffset=%f",
rrc_ptr->cell_resel_cfg.Qrxlevmin,
rrc_ptr->cell_resel_cfg.Qrxlevminoffset);
} else {
Info("Cell selection criteria: not available\n");
Info("Cell selection criteria: not available");
}
Info("Current serving cell: %s\n", meas_cells->serving_cell().to_string().c_str());
Info("Current serving cell: %s", meas_cells->serving_cell().to_string().c_str());
neigh_index = 0;
cs_result = cs_result_t::no_cell;
@ -564,7 +563,7 @@ proc_outcome_t rrc::cell_selection_proc::start_next_cell_selection()
// If any of the known cells meets the selection criteria or could not be selected, search again.
if (not cell_search_called) {
Info("Could not select any known cell. Searching new cells\n");
Info("Could not select any known cell. Searching new cells");
state = search_state_t::cell_search;
cell_search_called = true;
if (not rrc_ptr->cell_searcher.launch(&cell_search_fut)) {
@ -578,7 +577,7 @@ proc_outcome_t rrc::cell_selection_proc::start_next_cell_selection()
proc_outcome_t rrc::cell_selection_proc::react(const bool& cell_selection_result)
{
if (state != search_state_t::cell_selection) {
Warning("Unexpected cell selection event received\n");
Warning("Unexpected cell selection event received");
return proc_outcome_t::yield;
}
@ -592,7 +591,7 @@ proc_outcome_t rrc::cell_selection_proc::react(const bool& cell_selection_result
}
}
Info("Cell selection criteria not passed.\n");
Info("Cell selection criteria not passed.");
discard_serving = not is_same_cell(init_serv_cell, meas_cells->serving_cell());
return start_next_cell_selection();
@ -603,7 +602,7 @@ srslte::proc_outcome_t rrc::cell_selection_proc::start_phy_cell_selection(const
if (not is_same_cell(cell, meas_cells->serving_cell())) {
rrc_ptr->set_serving_cell(cell.phy_cell, discard_serving);
discard_serving = false;
Info("Set serving cell: %s\n", meas_cells->serving_cell().to_string().c_str());
Info("Set serving cell: %s", meas_cells->serving_cell().to_string().c_str());
} else {
// in case the cell had already been selected
if (is_serv_cell_suitable()) {
@ -616,7 +615,7 @@ srslte::proc_outcome_t rrc::cell_selection_proc::start_phy_cell_selection(const
state = search_state_t::cell_selection;
if (not rrc_ptr->phy_ctrl->start_cell_select(meas_cells->serving_cell().phy_cell, rrc_ptr->cell_selector)) {
Error("Failed to launch PHY Cell Selection\n");
Error("Failed to launch PHY Cell Selection");
return set_proc_complete();
}
return proc_outcome_t::yield;
@ -624,10 +623,10 @@ srslte::proc_outcome_t rrc::cell_selection_proc::start_phy_cell_selection(const
srslte::proc_outcome_t rrc::cell_selection_proc::start_sib_acquisition()
{
Info("PHY is camping on serving cell, but SIBs need to be acquired\n");
Info("PHY is camping on serving cell, but SIBs need to be acquired");
state = search_state_t::cell_config;
if (not rrc_ptr->serv_cell_cfg.launch(&serv_cell_cfg_fut, required_sibs)) {
Warning("Failed to launch %s procedure\n", rrc_ptr->serv_cell_cfg.get()->name());
Warning("Failed to launch %s procedure", rrc_ptr->serv_cell_cfg.get()->name());
return set_proc_complete();
}
return proc_outcome_t::yield;
@ -654,7 +653,7 @@ proc_outcome_t rrc::cell_selection_proc::step_cell_config()
if (is_serv_cell_suitable()) {
return set_proc_complete();
}
Error("Failed to configure serving cell\n");
Error("Failed to configure serving cell");
return start_next_cell_selection();
}
@ -677,7 +676,7 @@ proc_outcome_t rrc::cell_selection_proc::step()
void rrc::cell_selection_proc::then(const srslte::proc_result_t<cs_result_t>& proc_result) const
{
Info("Completed with %s.\n", proc_result.is_success() ? "success" : "failure");
Info("Completed with %s.", proc_result.is_success() ? "success" : "failure");
// Inform Connection Request Procedure
rrc_ptr->task_sched.defer_task([this, proc_result]() {
if (rrc_ptr->conn_req_proc.is_busy()) {
@ -692,15 +691,15 @@ void rrc::cell_selection_proc::then(const srslte::proc_result_t<cs_result_t>& pr
* PLMN search Procedure
*************************************/
rrc::plmn_search_proc::plmn_search_proc(rrc* parent_) : rrc_ptr(parent_), log_h(srslte::logmap::get("RRC")) {}
rrc::plmn_search_proc::plmn_search_proc(rrc* parent_) : rrc_ptr(parent_), logger(srslog::fetch_basic_logger("RRC")) {}
proc_outcome_t rrc::plmn_search_proc::init()
{
Info("Starting PLMN search\n");
Info("Starting PLMN search");
nof_plmns = 0;
cell_search_fut = rrc_ptr->cell_searcher.get_future();
if (not rrc_ptr->cell_searcher.launch(&cell_search_fut)) {
Error("Failed due to fail to init cell search...\n");
Error("Failed due to fail to init cell search...");
return proc_outcome_t::error;
}
return step();
@ -720,7 +719,7 @@ proc_outcome_t rrc::plmn_search_proc::step()
if (cell_search_fut.is_error() or cell_search_fut.value()->found == cell_search_ret_t::ERROR) {
// stop search
nof_plmns = -1;
Error("Failed due to failed cell search sub-procedure\n");
Error("Failed due to failed cell search sub-procedure");
return proc_outcome_t::error;
}
@ -733,21 +732,21 @@ proc_outcome_t rrc::plmn_search_proc::step()
found_plmns[nof_plmns].tac = rrc_ptr->meas_cells.serving_cell().get_tac();
nof_plmns++;
} else {
Error("No more space for plmns (%d)\n", nof_plmns);
Error("No more space for plmns (%d)", nof_plmns);
}
}
} else {
Error("SIB1 not acquired\n");
Error("SIB1 not acquired");
}
}
if (cell_search_fut.value()->last_freq == cell_search_ret_t::NO_MORE_FREQS) {
Info("completed PLMN search\n");
Info("completed PLMN search");
return proc_outcome_t::success;
}
if (not rrc_ptr->cell_searcher.launch(&cell_search_fut)) {
Error("Failed due to fail to init cell search...\n");
Error("Failed due to fail to init cell search...");
return proc_outcome_t::error;
}
@ -759,10 +758,10 @@ void rrc::plmn_search_proc::then(const srslte::proc_state_t& result) const
{
// on cleanup, call plmn_search_completed
if (result.is_success()) {
Info("completed with success\n");
Info("completed with success");
rrc_ptr->nas->plmn_search_completed(found_plmns, nof_plmns);
} else {
Error("PLMN Search completed with an error\n");
Error("PLMN Search completed with an error");
rrc_ptr->nas->plmn_search_completed(nullptr, -1);
}
}
@ -772,8 +771,7 @@ void rrc::plmn_search_proc::then(const srslte::proc_state_t& result) const
*************************************/
rrc::connection_request_proc::connection_request_proc(rrc* parent_) :
rrc_ptr(parent_),
log_h(srslte::logmap::get("RRC"))
rrc_ptr(parent_), logger(srslog::fetch_basic_logger("RRC"))
{}
proc_outcome_t rrc::connection_request_proc::init(srslte::establishment_cause_t cause_,
@ -783,22 +781,22 @@ proc_outcome_t rrc::connection_request_proc::init(srslte::establishment_cause_t
dedicated_info_nas = std::move(dedicated_info_nas_);
if (!rrc_ptr->plmn_is_selected) {
Error("Trying to connect but PLMN not selected.\n");
Error("Trying to connect but PLMN not selected.");
return proc_outcome_t::error;
}
if (rrc_ptr->state != RRC_STATE_IDLE) {
log_h->warning("Requested RRC connection establishment while not in IDLE\n");
logger.warning("Requested RRC connection establishment while not in IDLE");
return proc_outcome_t::error;
}
if (rrc_ptr->t302.is_running()) {
Info("Requested RRC connection establishment while T302 is running\n");
Info("Requested RRC connection establishment while T302 is running");
rrc_ptr->nas->set_barring(srslte::barring_t::mo_data);
return proc_outcome_t::error;
}
Info("Initiation of Connection establishment procedure\n");
Info("Initiation of Connection establishment procedure");
cs_ret = cs_result_t::no_cell;
@ -806,12 +804,12 @@ proc_outcome_t rrc::connection_request_proc::init(srslte::establishment_cause_t
if (rrc_ptr->cell_selector.is_idle()) {
// No one is running cell selection
if (not rrc_ptr->cell_selector.launch()) {
Error("Failed to initiate cell selection procedure...\n");
Error("Failed to initiate cell selection procedure...");
return proc_outcome_t::error;
}
rrc_ptr->callback_list.add_proc(rrc_ptr->cell_selector);
} else {
Info("Cell selection proc already on-going. Wait for its result\n");
Info("Cell selection proc already on-going. Wait for its result");
}
return proc_outcome_t::yield;
}
@ -826,7 +824,7 @@ proc_outcome_t rrc::connection_request_proc::step()
return proc_outcome_t::yield;
}
if (serv_cfg_fut.is_error()) {
Error("Configuring serving cell\n");
Error("Configuring serving cell");
return proc_outcome_t::error;
}
@ -838,17 +836,17 @@ proc_outcome_t rrc::connection_request_proc::step()
// Save dedicatedInfoNAS SDU, if needed
if (dedicated_info_nas.get()) {
if (rrc_ptr->dedicated_info_nas.get()) {
Warning("Received a new dedicatedInfoNAS SDU but there was one still in queue. Removing it.\n");
Warning("Received a new dedicatedInfoNAS SDU but there was one still in queue. Removing it.");
rrc_ptr->dedicated_info_nas.reset();
}
Debug("Updating dedicatedInfoNAS in RRC\n");
Debug("Updating dedicatedInfoNAS in RRC");
rrc_ptr->dedicated_info_nas = std::move(dedicated_info_nas);
} else {
Debug("dedicatedInfoNAS has already been provided to RRC.\n");
Debug("dedicatedInfoNAS has already been provided to RRC.");
}
Info("Waiting for RRCConnectionSetup/Reject or expiry\n");
Info("Waiting for RRCConnectionSetup/Reject or expiry");
state = state_t::wait_t300;
return step();
@ -863,13 +861,13 @@ proc_outcome_t rrc::connection_request_proc::step()
return proc_outcome_t::success;
} else if (rrc_ptr->t300.is_expired()) {
// T300 is expired: 5.3.3.6
Warning("Timer T300 expired: ConnectionRequest timed out\n");
Warning("Timer T300 expired: ConnectionRequest timed out");
rrc_ptr->mac->reset();
rrc_ptr->set_mac_default();
rrc_ptr->rlc->reestablish();
} else {
// T300 is stopped but RRC not Connected is because received Reject: Section 5.3.3.8
Warning("Timer T300 stopped: Received ConnectionReject\n");
Warning("Timer T300 stopped: Received ConnectionReject");
rrc_ptr->mac->reset();
rrc_ptr->set_mac_default();
}
@ -881,11 +879,11 @@ proc_outcome_t rrc::connection_request_proc::step()
void rrc::connection_request_proc::then(const srslte::proc_state_t& result)
{
if (result.is_error()) {
log_h->warning("Could not establish connection. Deallocating dedicatedInfoNAS PDU\n");
logger.warning("Could not establish connection. Deallocating dedicatedInfoNAS PDU");
dedicated_info_nas.reset();
rrc_ptr->dedicated_info_nas.reset();
} else {
Info("Finished connection request procedure successfully.\n");
Info("Finished connection request procedure successfully.");
}
rrc_ptr->nas->connection_request_completed(result.is_success());
}
@ -910,23 +908,23 @@ srslte::proc_outcome_t rrc::connection_request_proc::react(const cell_selection_
// CCCH configuration applied already at start
// timeAlignmentCommon applied in configure_serving_cell
Info("Configuring serving cell...\n");
Info("Configuring serving cell...");
state = state_t::config_serving_cell;
if (not rrc_ptr->serv_cell_cfg.launch(&serv_cfg_fut, rrc_ptr->ue_required_sibs)) {
Error("Attach request failed to configure serving cell...\n");
Error("Attach request failed to configure serving cell...");
return proc_outcome_t::error;
}
return step();
} else {
switch (cs_ret) {
case cs_result_t::same_cell:
log_h->warning("Did not reselect cell but serving cell is out-of-sync.\n");
logger.warning("Did not reselect cell but serving cell is out-of-sync.");
break;
case cs_result_t::changed_cell:
log_h->warning("Selected a new cell but could not camp on. Setting out-of-sync.\n");
logger.warning("Selected a new cell but could not camp on. Setting out-of-sync.");
break;
default:
log_h->warning("Could not find any suitable cell to connect\n");
logger.warning("Could not find any suitable cell to connect");
}
return proc_outcome_t::error;
}
@ -941,7 +939,7 @@ rrc::connection_reconf_no_ho_proc::connection_reconf_no_ho_proc(srsue::rrc* pare
srslte::proc_outcome_t rrc::connection_reconf_no_ho_proc::init(const asn1::rrc::rrc_conn_recfg_s& recfg_)
{
Info("Starting...\n");
Info("Starting...");
rx_recfg = recfg_.crit_exts.c1().rrc_conn_recfg_r8();
// If first message after reestablishment, resume SRB2 and all DRB
@ -986,7 +984,7 @@ srslte::proc_outcome_t rrc::connection_reconf_no_ho_proc::init(const asn1::rrc::
#ifdef HAVE_5GNR
bool rtn = rrc_ptr->nr_reconfiguration_proc(rx_recfg);
if (rtn == false) {
rrc_ptr->rrc_log->error("Can not launch NR RRC Reconfiguration procedure\n");
rrc_ptr->logger.error("Can not launch NR RRC Reconfiguration procedure");
return proc_outcome_t::error;
}
has_5g_nr_reconfig = true;
@ -1002,7 +1000,7 @@ srslte::proc_outcome_t rrc::connection_reconf_no_ho_proc::init(const asn1::rrc::
srslte::proc_outcome_t rrc::connection_reconf_no_ho_proc::react(const bool& config_complete)
{
if (not config_complete) {
rrc_ptr->rrc_log->error("Failed to config PHY\n");
rrc_ptr->logger.error("Failed to config PHY");
return proc_outcome_t::error;
}
@ -1032,7 +1030,7 @@ srslte::proc_outcome_t rrc::connection_reconf_no_ho_proc::react(const bool& conf
nas_pdu->N_bytes = pdu.size();
rrc_ptr->nas->write_pdu(RB_ID_SRB1, std::move(nas_pdu));
} else {
rrc_ptr->rrc_log->error("Fatal Error: Couldn't allocate PDU in %s.\n", __FUNCTION__);
rrc_ptr->logger.error("Fatal Error: Couldn't allocate PDU in %s.", __FUNCTION__);
return proc_outcome_t::error;
}
}
@ -1046,7 +1044,7 @@ void rrc::connection_reconf_no_ho_proc::then(const srslte::proc_state_t& result)
has_5g_nr_reconfig = false;
if (result.is_success()) {
rrc_ptr->rrc_log->info("Finished %s successfully\n", name());
rrc_ptr->logger.info("Finished %s successfully", name());
return;
}
@ -1059,7 +1057,9 @@ void rrc::connection_reconf_no_ho_proc::then(const srslte::proc_state_t& result)
* Process PCCH procedure
*************************************/
rrc::process_pcch_proc::process_pcch_proc(srsue::rrc* parent_) : rrc_ptr(parent_), log_h(srslte::logmap::get("RRC")) {}
rrc::process_pcch_proc::process_pcch_proc(srsue::rrc* parent_) :
rrc_ptr(parent_), logger(srslog::fetch_basic_logger("RRC"))
{}
proc_outcome_t rrc::process_pcch_proc::init(const asn1::rrc::paging_s& paging_)
{
@ -1067,7 +1067,7 @@ proc_outcome_t rrc::process_pcch_proc::init(const asn1::rrc::paging_s& paging_)
paging_idx = 0;
state = state_t::next_record;
Info("starting...\n");
Info("starting...");
return step();
}
@ -1076,40 +1076,40 @@ proc_outcome_t rrc::process_pcch_proc::step()
if (state == state_t::next_record) {
for (; paging_idx < paging.paging_record_list.size(); ++paging_idx) {
srslte::s_tmsi_t s_tmsi_paged = srslte::make_s_tmsi_t(paging.paging_record_list[paging_idx].ue_id.s_tmsi());
Info("Received paging (%d/%d) for UE %" PRIu64 ":%" PRIu64 "\n",
Info("Received paging (%d/%d) for UE %" PRIu64 ":%" PRIu64 "",
paging_idx + 1,
paging.paging_record_list.size(),
paging.paging_record_list[paging_idx].ue_id.s_tmsi().mmec.to_number(),
paging.paging_record_list[paging_idx].ue_id.s_tmsi().m_tmsi.to_number());
if (rrc_ptr->ue_identity == s_tmsi_paged) {
if (RRC_STATE_IDLE == rrc_ptr->state) {
Info("S-TMSI match in paging message\n");
Info("S-TMSI match in paging message");
srslte::console("S-TMSI match in paging message\n");
if (not rrc_ptr->nas->paging(&s_tmsi_paged)) {
Error("Unable to start NAS paging proc\n");
Error("Unable to start NAS paging proc");
return proc_outcome_t::error;
}
state = state_t::nas_paging;
return step();
} else {
Warning("Received paging while in CONNECT\n");
Warning("Received paging while in CONNECT");
}
} else {
Info("Received paging for unknown identity\n");
Info("Received paging for unknown identity");
}
}
if (paging.sys_info_mod_present) {
Info("Received System Information notification update request.\n");
Info("Received System Information notification update request.");
// invalidate and then update all SIBs of serving cell
rrc_ptr->meas_cells.serving_cell().reset_sibs();
// create a serving cell config procedure and push it to callback list
if (not rrc_ptr->serv_cell_cfg.launch(&serv_cfg_fut, rrc_ptr->ue_required_sibs)) {
Error("Failed to initiate a serving cell configuration procedure\n");
Error("Failed to initiate a serving cell configuration procedure");
return proc_outcome_t::error;
}
} else {
Info("Completed successfully\n");
Info("Completed successfully");
return proc_outcome_t::success;
}
state = state_t::serv_cell_cfg;
@ -1122,10 +1122,10 @@ proc_outcome_t rrc::process_pcch_proc::step()
return proc_outcome_t::yield;
}
if (serv_cfg_fut.is_success()) {
Info("All SIBs of serving cell obtained successfully\n");
Info("All SIBs of serving cell obtained successfully");
return proc_outcome_t::success;
} else {
Error("While obtaining SIBs of serving cell\n");
Error("While obtaining SIBs of serving cell");
return proc_outcome_t::error;
}
}
@ -1135,16 +1135,16 @@ proc_outcome_t rrc::process_pcch_proc::step()
proc_outcome_t rrc::process_pcch_proc::react(paging_complete e)
{
if (state != state_t::nas_paging) {
Warning("Received an unexpected paging complete\n");
Warning("Received an unexpected paging complete");
return proc_outcome_t::yield;
}
if (not e.outcome) {
Info("NAS Paging has failed\n");
Info("NAS Paging has failed");
return proc_outcome_t::error;
}
paging_idx++;
state = state_t::next_record;
Info("Received paging complete event\n");
Info("Received paging complete event");
return step();
}
@ -1160,7 +1160,7 @@ rrc::go_idle_proc::go_idle_proc(srsue::rrc* rrc_) : rrc_ptr(rrc_)
proc_outcome_t rrc::go_idle_proc::init()
{
Info("Starting...\n");
Info("Starting...");
rlc_flush_timer.run();
// Do not call step() directly. Instead we defer for one TTI to avoid double-locking the RLC mutex
return proc_outcome_t::yield;
@ -1169,24 +1169,25 @@ proc_outcome_t rrc::go_idle_proc::init()
srslte::proc_outcome_t rrc::go_idle_proc::react(bool timeout)
{
rrc_ptr->leave_connected();
Info("Left connected state\n");
Info("Left connected state");
return proc_outcome_t::success;
}
proc_outcome_t rrc::go_idle_proc::step()
{
if (rrc_ptr->state == RRC_STATE_IDLE) {
Info("Interrupting as RRC has already became IDLE\n");
Info("Interrupting as RRC has already became IDLE");
return proc_outcome_t::success;
}
// wait for RLC of SRB1 and SRB2 to be flushed
if (rrc_ptr->srbs_flushed()) {
rrc_ptr->leave_connected();
Info("Left connected state\n");
Info("Left connected state");
return proc_outcome_t::success;
} else {
Debug("Postponing transition to RRC IDLE (%d ms < %d ms)\n", rlc_flush_timer.time_elapsed(), rlc_flush_timeout_ms);
Debug(
"Postponing transition to RRC IDLE (%d ms < %d ms)", rlc_flush_timer.time_elapsed(), int(rlc_flush_timeout_ms));
}
return proc_outcome_t::yield;
}
@ -1194,7 +1195,7 @@ proc_outcome_t rrc::go_idle_proc::step()
void rrc::go_idle_proc::then(const srslte::proc_state_t& result)
{
if (rrc_ptr->nas->is_registered() and not rrc_ptr->cell_reselector.launch()) {
rrc_ptr->rrc_log->error("Failed to initiate a Cell Reselection procedure...\n");
rrc_ptr->logger.error("Failed to initiate a Cell Reselection procedure...");
return;
}
rrc_ptr->callback_list.add_proc(rrc_ptr->cell_reselector);
@ -1210,7 +1211,7 @@ rrc::cell_reselection_proc::cell_reselection_proc(srsue::rrc* rrc_) : rrc_ptr(rr
reselection_timer = rrc_ptr->task_sched.get_unique_timer();
reselection_timer.set(cell_reselection_periodicity_ms, [this](uint32_t tid) {
if (not rrc_ptr->cell_reselector.launch()) {
rrc_ptr->rrc_log->error("Failed to initiate a Cell Reselection procedure...\n");
rrc_ptr->logger.error("Failed to initiate a Cell Reselection procedure...");
return;
}
rrc_ptr->callback_list.add_proc(rrc_ptr->cell_reselector);
@ -1219,9 +1220,9 @@ rrc::cell_reselection_proc::cell_reselection_proc(srsue::rrc* rrc_) : rrc_ptr(rr
proc_outcome_t rrc::cell_reselection_proc::init()
{
Info("Starting...\n");
Info("Starting...");
if (not rrc_ptr->cell_selector.launch(&cell_selection_fut)) {
Error("Failed to initiate a Cell Selection procedure...\n");
Error("Failed to initiate a Cell Selection procedure...");
return proc_outcome_t::error;
}
@ -1234,29 +1235,29 @@ proc_outcome_t rrc::cell_reselection_proc::step()
return srslte::proc_outcome_t::yield;
}
if (cell_selection_fut.is_error()) {
Error("Error while selecting a cell\n");
Error("Error while selecting a cell");
return srslte::proc_outcome_t::error;
}
cell_sel_result = *cell_selection_fut.value();
Info("Cell Selection completed. Handling its result...\n");
Info("Cell Selection completed. Handling its result...");
switch (cell_sel_result) {
case cs_result_t::changed_cell:
if (rrc_ptr->state == rrc_state_t::RRC_STATE_IDLE) {
Info("New cell has been selected, start receiving PCCH\n");
Info("New cell has been selected, start receiving PCCH");
rrc_ptr->mac->pcch_start_rx();
}
break;
case cs_result_t::no_cell:
Warning("Could not find any cell to camp on\n");
Warning("Could not find any cell to camp on");
break;
case cs_result_t::same_cell:
if (!rrc_ptr->phy->cell_is_camping()) {
Warning("Did not reselect cell but serving cell is out-of-sync.\n");
Warning("Did not reselect cell but serving cell is out-of-sync.");
}
break;
}
Info("Finished successfully\n");
Info("Finished successfully");
return srslte::proc_outcome_t::success;
}
@ -1305,7 +1306,7 @@ proc_outcome_t rrc::connection_reest_proc::init(asn1::rrc::reest_cause_e cause)
// 5.3.7.1 - Conditions for Reestablishment procedure
if (not rrc_ptr->security_is_activated or rrc_ptr->state != RRC_STATE_CONNECTED or
uernti.crnti == SRSLTE_INVALID_RNTI) {
Warning("Conditions are NOT met to start procedure.\n");
Warning("Conditions are NOT met to start procedure.");
return proc_outcome_t::error;
}
@ -1322,7 +1323,7 @@ proc_outcome_t rrc::connection_reest_proc::init(asn1::rrc::reest_cause_e cause)
}
reest_cellid = rrc_ptr->meas_cells.find_cell(reest_source_freq, reest_source_pci)->get_cell_id();
Info("Starting... cause: \"%s\", UE context: {C-RNTI=0x%x, PCI=%d, CELL ID=%d}\n",
Info("Starting... cause: \"%s\", UE context: {C-RNTI=0x%x, PCI=%d, CELL ID=%d}",
reest_cause == asn1::rrc::reest_cause_opts::recfg_fail
? "Reconfiguration failure"
: cause == asn1::rrc::reest_cause_opts::ho_fail ? "Handover failure" : "Other failure",
@ -1377,17 +1378,17 @@ bool rrc::connection_reest_proc::passes_cell_criteria() const
srslte::proc_outcome_t rrc::connection_reest_proc::cell_criteria()
{
if (not passes_cell_criteria()) {
Info("Selected Serving cell does not pass criteria. Re-launching re-selection procedure\n");
Info("Selected Serving cell does not pass criteria. Re-launching re-selection procedure");
return start_cell_selection();
}
// Upon selecting a suitable E-UTRA cell, the UE shall:
Info("Cell Selection criteria passed after %dms. Sending RRC Connection Reestablishment Request\n",
Info("Cell Selection criteria passed after %dms. Sending RRC Connection Reestablishment Request",
rrc_ptr->t311.time_elapsed());
// Note: Not explicitly defined in the specs, but UE should apply SIB1 and SIB2 configuration in order to attempt
// a PRACH to a different cell
Info("Applying SIB2 configuration\n");
Info("Applying SIB2 configuration");
rrc_ptr->handle_sib2();
// 1> stop timer T311;
@ -1411,7 +1412,7 @@ srslte::proc_outcome_t rrc::connection_reest_proc::start_cell_selection()
// Launch cell reselection
state = state_t::wait_cell_selection;
if (not rrc_ptr->cell_selector.launch(std::vector<uint32_t>{0, 1, 2})) {
Error("Failed to initiate a Cell re-selection procedure...\n");
Error("Failed to initiate a Cell re-selection procedure...");
// Wait for T311 to expire
return proc_outcome_t::yield;
}
@ -1423,14 +1424,14 @@ srslte::proc_outcome_t
rrc::connection_reest_proc::react(const cell_selection_proc::cell_selection_complete_ev& cell_selected_ev)
{
if (state != state_t::wait_cell_selection) {
Warning("Received unexpected \"%s\" completion signal\n", rrc_ptr->cell_selector.get()->name());
Warning("Received unexpected \"%s\" completion signal", rrc_ptr->cell_selector.get()->name());
return proc_outcome_t::yield;
}
// Relaunch cell selection if there is still time
if (cell_selected_ev.is_error() or not rrc_ptr->phy_ctrl->is_in_sync()) {
// Out-of-sync, relaunch reselection
Info("Serving cell is out-of-sync, re-launching re-selection procedure. T311: %d/%d ms\n",
Info("Serving cell is out-of-sync, re-launching re-selection procedure. T311: %d/%d ms",
rrc_ptr->t311.time_elapsed(),
rrc_ptr->t311.duration());
return start_cell_selection();
@ -1439,7 +1440,7 @@ rrc::connection_reest_proc::react(const cell_selection_proc::cell_selection_comp
// SIBs should be available
if (not rrc_ptr->meas_cells.serving_cell().has_sib1() or not rrc_ptr->meas_cells.serving_cell().has_sib2() or
not rrc_ptr->meas_cells.serving_cell().has_sib3()) {
Warning("SIBs missing (%d, %d, %d) after cell selection procedure\n",
Warning("SIBs missing (%d, %d, %d) after cell selection procedure",
rrc_ptr->meas_cells.serving_cell().has_sib1(),
rrc_ptr->meas_cells.serving_cell().has_sib2(),
rrc_ptr->meas_cells.serving_cell().has_sib3());
@ -1496,14 +1497,14 @@ srslte::proc_outcome_t rrc::connection_reest_proc::react(const asn1::rrc::rrc_co
// procedure ends;
rrc_ptr->send_con_restablish_complete();
Info("Finished successfully\n");
Info("Finished successfully");
return proc_outcome_t::success;
}
// 5.3.7.7 - T301 expiry or selected cell no longer suitable
srslte::proc_outcome_t rrc::connection_reest_proc::react(const t301_expiry& ev)
{
Info("Timer T301 expired: Going to RRC IDLE\n");
Info("Timer T301 expired: Going to RRC IDLE");
srslte::console("Timer T301 expired: Going to RRC IDLE\n");
rrc_ptr->start_go_idle();
@ -1512,7 +1513,7 @@ srslte::proc_outcome_t rrc::connection_reest_proc::react(const t301_expiry& ev)
srslte::proc_outcome_t rrc::connection_reest_proc::step()
{
if (rrc_ptr->t301.is_running() and not passes_cell_criteria()) {
Info("Selected cell no longer suitable: Going to RRC IDLE\n");
Info("Selected cell no longer suitable: Going to RRC IDLE");
srslte::console("Selected cell no longer suitable: Going to RRC IDLE\n");
rrc_ptr->start_go_idle();
return proc_outcome_t::error;
@ -1524,7 +1525,7 @@ srslte::proc_outcome_t rrc::connection_reest_proc::step()
srslte::proc_outcome_t rrc::connection_reest_proc::react(const asn1::rrc::rrc_conn_reest_reject_s& reject_msg)
{
srslte::console("Reestablishment Reject. Going to RRC IDLE\n");
Info("Reestablishment Reject. Going to RRC IDLE\n");
Info("Reestablishment Reject. Going to RRC IDLE");
rrc_ptr->t301.stop();
rrc_ptr->start_go_idle();
return proc_outcome_t::error;
@ -1534,7 +1535,7 @@ srslte::proc_outcome_t rrc::connection_reest_proc::react(const asn1::rrc::rrc_co
srslte::proc_outcome_t rrc::connection_reest_proc::react(const t311_expiry& ev)
{
// Abort procedure if T311 expires
Info("T311 expired during cell configuration. Going to RRC IDLE\n");
Info("T311 expired during cell configuration. Going to RRC IDLE");
rrc_ptr->start_go_idle();
return proc_outcome_t::error;
}
@ -1560,12 +1561,12 @@ rrc::ho_proc::ho_proc(srsue::rrc* rrc_) : rrc_ptr(rrc_) {}
*/
srslte::proc_outcome_t rrc::ho_proc::init(const asn1::rrc::rrc_conn_recfg_s& rrc_reconf)
{
Info("Starting...\n");
Info("Starting...");
recfg_r8 = rrc_reconf.crit_exts.c1().rrc_conn_recfg_r8();
asn1::rrc::mob_ctrl_info_s* mob_ctrl_info = &recfg_r8.mob_ctrl_info;
size_t nof_scells_active = rrc_ptr->phy_ctrl->current_config_scells().count();
Info("Received HO command to target PCell=%d\n", mob_ctrl_info->target_pci);
Info("Received HO command to target PCell=%d", mob_ctrl_info->target_pci);
srslte::console("Received HO command to target PCell=%d, NCC=%d\n",
mob_ctrl_info->target_pci,
recfg_r8.security_cfg_ho.handov_type.intra_lte().next_hop_chaining_count);
@ -1579,7 +1580,7 @@ srslte::proc_outcome_t rrc::ho_proc::init(const asn1::rrc::rrc_conn_recfg_s& rrc
target_cell = cell_to_ho->phy_cell;
} else {
srslte::console("Received HO command to unknown PCI=%d\n", mob_ctrl_info->target_pci);
Error("Could not find target cell earfcn=%d, pci=%d\n",
Error("Could not find target cell earfcn=%d, pci=%d",
rrc_ptr->meas_cells.serving_cell().get_earfcn(),
mob_ctrl_info->target_pci);
rrc_ptr->con_reconfig_failed();
@ -1599,9 +1600,9 @@ srslte::proc_outcome_t rrc::ho_proc::init(const asn1::rrc::rrc_conn_recfg_s& rrc
// starting at start synchronising to the DL of the target PCell
rrc_ptr->set_serving_cell(target_cell, false);
Info("Starting cell selection of target cell PCI=%d EARFCN=%d\n", target_cell.pci, target_cell.earfcn);
Info("Starting cell selection of target cell PCI=%d EARFCN=%d", target_cell.pci, target_cell.earfcn);
if (not rrc_ptr->phy_ctrl->start_cell_select(target_cell)) {
Error("Failed to launch the selection of target cell PCI=%d EARFCN=%d\n", target_cell.pci, target_cell.earfcn);
Error("Failed to launch the selection of target cell PCI=%d EARFCN=%d", target_cell.pci, target_cell.earfcn);
return proc_outcome_t::yield; // wait t304 expiry
}
@ -1622,7 +1623,7 @@ srslte::proc_outcome_t rrc::ho_proc::init(const asn1::rrc::rrc_conn_recfg_s& rrc
// perform radio configuration when fullConfig is enabled
if (recfg_r8.non_crit_ext.non_crit_ext.full_cfg_r9_present) {
Error("fullConfig section was present but is not supported. Ignoring it.\n");
Error("fullConfig section was present but is not supported. Ignoring it.");
}
// configure lower layers in accordance with the received radioResourceConfigCommon
@ -1632,7 +1633,7 @@ srslte::proc_outcome_t rrc::ho_proc::init(const asn1::rrc::rrc_conn_recfg_s& rrc
// configure lower layers in accordance with any additional fields, not covered in the previous, if included in the
// received mobilityControlInfo
if (recfg_r8.mob_ctrl_info.rach_cfg_ded_present) {
Info("Configuring RACH dedicated configuration with preamble_idx=%d, mask_idx=%d\n",
Info("Configuring RACH dedicated configuration with preamble_idx=%d, mask_idx=%d",
recfg_r8.mob_ctrl_info.rach_cfg_ded.ra_preamb_idx,
recfg_r8.mob_ctrl_info.rach_cfg_ded.ra_prach_mask_idx);
rrc_ptr->mac->set_rach_ded_cfg(recfg_r8.mob_ctrl_info.rach_cfg_ded.ra_preamb_idx,
@ -1660,7 +1661,7 @@ srslte::proc_outcome_t rrc::ho_proc::init(const asn1::rrc::rrc_conn_recfg_s& rrc
(srslte::CIPHERING_ALGORITHM_ID_ENUM)sec_intralte.security_algorithm_cfg.ciphering_algorithm.to_number();
rrc_ptr->sec_cfg.integ_algo =
(srslte::INTEGRITY_ALGORITHM_ID_ENUM)sec_intralte.security_algorithm_cfg.integrity_prot_algorithm.to_number();
Info("Changed Ciphering to %s and Integrity to %s\n",
Info("Changed Ciphering to %s and Integrity to %s",
srslte::ciphering_algorithm_id_text[rrc_ptr->sec_cfg.cipher_algo],
srslte::integrity_algorithm_id_text[rrc_ptr->sec_cfg.integ_algo]);
}
@ -1675,7 +1676,7 @@ srslte::proc_outcome_t rrc::ho_proc::init(const asn1::rrc::rrc_conn_recfg_s& rrc
// if the RRCConnectionReconfiguration message includes the measConfig:
if (not rrc_ptr->measurements->parse_meas_config(&recfg_r8, true, ho_src_cell.earfcn)) {
Error("Parsing measurementConfig. TODO: Send ReconfigurationReject\n");
Error("Parsing measurementConfig. TODO: Send ReconfigurationReject");
return proc_outcome_t::yield; // wait for t304 expiry
}
@ -1685,14 +1686,14 @@ srslte::proc_outcome_t rrc::ho_proc::init(const asn1::rrc::rrc_conn_recfg_s& rrc
// SCell addition/removal can take some time to compute. Enqueue in a background task and do it in the end.
rrc_ptr->apply_scell_config(&recfg_r8, false);
Info("Finished HO configuration. Waiting PHY to synchronize with target cell\n");
Info("Finished HO configuration. Waiting PHY to synchronize with target cell");
return proc_outcome_t::yield;
}
srslte::proc_outcome_t rrc::ho_proc::react(t304_expiry ev)
{
Info("HO preparation timed out. Reverting RRC security config from source cell.\n");
Info("HO preparation timed out. Reverting RRC security config from source cell.");
// revert security settings from source cell for reestablishment according to Sec 5.3.7.4
rrc_ptr->usim->restore_keys_from_failed_ho(&rrc_ptr->sec_cfg);
@ -1705,7 +1706,7 @@ srslte::proc_outcome_t rrc::ho_proc::react(t304_expiry ev)
srslte::proc_outcome_t rrc::ho_proc::react(ra_completed_ev ev)
{
if (ev.success) {
Info("Random Access completed. Applying final configuration and finishing procedure\n");
Info("Random Access completed. Applying final configuration and finishing procedure");
// TS 36.331, sec. 5.3.5.4, last "1>"
rrc_ptr->t304.stop();
@ -1720,7 +1721,7 @@ srslte::proc_outcome_t rrc::ho_proc::react(ra_completed_ev ev)
void rrc::ho_proc::then(const srslte::proc_state_t& result)
{
Info("HO to PCI=%d, EARFCN=%d %ssuccessful\n", target_cell.pci, target_cell.earfcn, result.is_success() ? "" : "un");
Info("HO to PCI=%d, EARFCN=%d %ssuccessful", target_cell.pci, target_cell.earfcn, result.is_success() ? "" : "un");
srslte::console("HO %ssuccessful\n", result.is_success() ? "" : "un");
rrc_ptr->t304.stop();

@ -22,10 +22,17 @@ using namespace srslte;
namespace srsue {
ue_stack_lte::ue_stack_lte() :
ue_stack_lte::ue_stack_lte(srslog::sink& log_sink) :
running(false),
args(),
logger(nullptr),
stack_logger(srslog::fetch_basic_logger("STCK", log_sink, false)),
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)),
usim_logger(srslog::fetch_basic_logger("USIM", log_sink, false)),
nas_logger(srslog::fetch_basic_logger("NAS", log_sink, false)),
usim(nullptr),
phy(nullptr),
rlc("RLC"),
@ -78,8 +85,8 @@ int ue_stack_lte::init(const stack_args_t& args_, srslte::logger* logger_)
logger = logger_;
// init own log
stack_log->set_level(args.log.stack_level);
stack_log->set_hex_limit(args.log.stack_hex_limit);
stack_logger.set_level(srslog::str_to_basic_level(args.log.stack_level));
stack_logger.set_hex_dump_max_size(args.log.stack_hex_limit);
pool_log->set_level(srslte::LOG_LEVEL_WARNING);
byte_buffer_pool::get_instance()->set_log(pool_log.get());
@ -87,16 +94,28 @@ int ue_stack_lte::init(const stack_args_t& args_, srslte::logger* logger_)
srslte::logmap::register_log(std::unique_ptr<srslte::log>{new srslte::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);
rlc_log->set_level(args.log.rlc_level);
rlc_log->set_hex_limit(args.log.rlc_hex_limit);
rlc_logger.set_level(srslog::str_to_basic_level(args.log.rlc_level));
rlc_logger.set_hex_dump_max_size(args.log.rlc_hex_limit);
pdcp_log->set_level(args.log.pdcp_level);
pdcp_log->set_hex_limit(args.log.pdcp_hex_limit);
pdcp_logger.set_level(srslog::str_to_basic_level(args.log.pdcp_level));
pdcp_logger.set_hex_dump_max_size(args.log.pdcp_hex_limit);
rrc_log->set_level(args.log.rrc_level);
rrc_log->set_hex_limit(args.log.rrc_hex_limit);
rrc_logger.set_level(srslog::str_to_basic_level(args.log.rrc_level));
rrc_logger.set_hex_dump_max_size(args.log.rrc_hex_limit);
usim_log->set_level(args.log.usim_level);
usim_log->set_hex_limit(args.log.usim_hex_limit);
usim_logger.set_level(srslog::str_to_basic_level(args.log.usim_level));
usim_logger.set_hex_dump_max_size(args.log.usim_hex_limit);
nas_log->set_level(args.log.nas_level);
nas_log->set_hex_limit(args.log.nas_hex_limit);
nas_logger.set_level(srslog::str_to_basic_level(args.log.nas_level));
nas_logger.set_hex_dump_max_size(args.log.nas_hex_limit);
// Set up pcap
if (args.pcap.enable) {
@ -109,7 +128,7 @@ int ue_stack_lte::init(const stack_args_t& args_, srslte::logger* logger_)
}
// Init USIM first to allow early exit in case reader couldn't be found
usim = usim_base::get_instance(&args.usim, usim_log.get());
usim = usim_base::get_instance(&args.usim, usim_logger);
if (usim->init(&args.usim)) {
srslte::console("Failed to initialize USIM.\n");
return SRSLTE_ERROR;
@ -186,7 +205,7 @@ bool ue_stack_lte::switch_off()
}
bool detach_sent = true;
if (not rrc.srbs_flushed()) {
logmap::get("NAS ")->warning("Detach couldn't be sent after %dms.\n", timeout_ms);
srslog::fetch_basic_logger("NAS").warning("Detach couldn't be sent after %dms.", timeout_ms);
detach_sent = false;
}
@ -257,7 +276,7 @@ void ue_stack_lte::write_sdu(uint32_t lcid, srslte::unique_byte_buffer_t sdu)
auto task = [this, lcid](srslte::unique_byte_buffer_t& sdu) { pdcp.write_sdu(lcid, std::move(sdu)); };
bool ret = gw_queue_id.try_push(std::bind(task, std::move(sdu))).first;
if (not ret) {
pdcp_log->warning("GW SDU with lcid=%d was discarded.\n", lcid);
pdcp_logger.warning("GW SDU with lcid=%d was discarded.", lcid);
}
}
@ -337,15 +356,15 @@ void ue_stack_lte::run_tti_impl(uint32_t tti, uint32_t tti_jump)
if (args.have_tti_time_stats) {
std::chrono::nanoseconds dur = tti_tprof.stop();
if (dur > TTI_WARN_THRESHOLD_MS) {
mac_log->warning("%s: detected long duration=%" PRId64 "ms\n",
"proc_time",
std::chrono::duration_cast<std::chrono::milliseconds>(dur).count());
mac_logger.warning("%s: detected long duration=%" PRId64 "ms",
"proc_time",
std::chrono::duration_cast<std::chrono::milliseconds>(dur).count());
}
}
// print warning if PHY pushes new TTI messages faster than we process them
if (sync_task_queue.size() > SYNC_QUEUE_WARN_THRESHOLD) {
stack_log->warning("Detected slow task processing (sync_queue_len=%zd).\n", sync_task_queue.size());
stack_logger.warning("Detected slow task processing (sync_queue_len=%zd).", sync_task_queue.size());
}
}

@ -18,12 +18,7 @@ using namespace srslte;
namespace srsue {
ue_stack_nr::ue_stack_nr(srslte::logger* logger_) :
logger(logger_),
thread("STACK"),
task_sched(64, 2, 64),
rlc_log("RLC"),
pdcp_log("PDCP"),
pool_log("POOL")
logger(logger_), thread("STACK"), task_sched(64, 2, 64), rlc_log("RLC"), pdcp_log("PDCP"), pool_log("POOL")
{
mac.reset(new mac_nr(&task_sched));
pdcp.reset(new srslte::pdcp(&task_sched, "PDCP"));
@ -165,7 +160,7 @@ void ue_stack_nr::write_sdu(uint32_t lcid, srslte::unique_byte_buffer_t sdu)
std::pair<bool, move_task_t> ret = gw_task_queue.try_push(std::bind(
[this, lcid](srslte::unique_byte_buffer_t& sdu) { pdcp->write_sdu(lcid, std::move(sdu)); }, std::move(sdu)));
if (not ret.first) {
pdcp_log->warning("GW SDU with lcid=%d was discarded.\n", lcid);
pdcp_log->warning("GW SDU with lcid=%d was discarded.", lcid);
}
}
}

@ -25,29 +25,33 @@
namespace srsue {
gw::gw() : thread("GW"), pool(srslte::byte_buffer_pool::get_instance()), tft_matcher(&log) {}
gw::gw() :
thread("GW"),
pool(srslte::byte_buffer_pool::get_instance()),
logger(srslog::fetch_basic_logger("GW", false)),
tft_matcher(logger)
{}
int gw::init(const gw_args_t& args_, srslte::logger* logger_, stack_interface_gw* stack_)
{
stack = stack_;
logger = logger_;
old_logger = logger_;
args = args_;
run_enable = true;
log.init("GW ", logger);
log.set_level(args.log.gw_level);
log.set_hex_limit(args.log.gw_hex_limit);
logger.set_level(srslog::str_to_basic_level(args.log.gw_level));
logger.set_hex_dump_max_size(args.log.gw_hex_limit);
metrics_tp = std::chrono::high_resolution_clock::now();
// MBSFN
mbsfn_sock_fd = socket(AF_INET, SOCK_DGRAM, 0);
if (mbsfn_sock_fd < 0) {
log.error("Failed to create MBSFN sink socket\n");
logger.error("Failed to create MBSFN sink socket");
return SRSLTE_ERROR;
}
if (fcntl(mbsfn_sock_fd, F_SETFL, O_NONBLOCK)) {
log.error("Failed to set non-blocking MBSFN sink socket\n");
logger.error("Failed to set non-blocking MBSFN sink socket");
return SRSLTE_ERROR;
}
@ -95,11 +99,11 @@ void gw::get_metrics(gw_metrics_t& m, const uint32_t nof_tti)
m.dl_tput_mbps = (nof_tti > 0) ? ((dl_tput_bytes * 8 / (double)1e6) / (nof_tti / 1000.0)) : 0.0;
m.ul_tput_mbps = (nof_tti > 0) ? ((ul_tput_bytes * 8 / (double)1e6) / (nof_tti / 1000.0)) : 0.0;
log.info("gw_rx_rate_mbps=%4.2f (real=%4.2f), gw_tx_rate_mbps=%4.2f (real=%4.2f)\n",
m.dl_tput_mbps,
dl_tput_mbps_real_time,
m.ul_tput_mbps,
ul_tput_mbps_real_time);
logger.info("gw_rx_rate_mbps=%4.2f (real=%4.2f), gw_tx_rate_mbps=%4.2f (real=%4.2f)",
m.dl_tput_mbps,
dl_tput_mbps_real_time,
m.ul_tput_mbps,
ul_tput_mbps_real_time);
// reset counters and store time
metrics_tp = std::chrono::high_resolution_clock::now();
@ -112,23 +116,23 @@ void gw::get_metrics(gw_metrics_t& m, const uint32_t nof_tti)
*******************************************************************************/
void gw::write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t pdu)
{
log.info_hex(pdu->msg, pdu->N_bytes, "RX PDU. Stack latency: %ld us\n", pdu->get_latency_us().count());
logger.info(pdu->msg, pdu->N_bytes, "RX PDU. Stack latency: %ld us", pdu->get_latency_us().count());
dl_tput_bytes += pdu->N_bytes;
if (!if_up) {
log.warning("TUN/TAP not up - dropping gw RX message\n");
logger.warning("TUN/TAP not up - dropping gw RX message");
} else if (pdu->N_bytes < 20) {
// Packet not large enough to hold IPv4 Header
log.warning("Packet to small to hold IPv4 header. Dropping packet with %d B\n", pdu->N_bytes);
logger.warning("Packet to small to hold IPv4 header. Dropping packet with %d B", pdu->N_bytes);
} else {
// Only handle IPv4 and IPv6 packets
struct iphdr* ip_pkt = (struct iphdr*)pdu->msg;
if (ip_pkt->version == 4 || ip_pkt->version == 6) {
int n = write(tun_fd, pdu->msg, pdu->N_bytes);
if (n > 0 && (pdu->N_bytes != (uint32_t)n)) {
log.warning("DL TUN/TAP write failure. Wanted to write %d B but only wrote %d B.\n", pdu->N_bytes, n);
logger.warning("DL TUN/TAP write failure. Wanted to write %d B but only wrote %d B.", pdu->N_bytes, n);
}
} else {
log.error("Unsupported IP version. Dropping packet with %d B\n", pdu->N_bytes);
logger.error("Unsupported IP version. Dropping packet with %d B", pdu->N_bytes);
}
}
}
@ -136,11 +140,11 @@ void gw::write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t pdu)
void gw::write_pdu_mch(uint32_t lcid, srslte::unique_byte_buffer_t pdu)
{
if (pdu->N_bytes > 2) {
log.info_hex(pdu->msg,
pdu->N_bytes,
"RX MCH PDU (%d B). Stack latency: %ld us\n",
pdu->N_bytes,
pdu->get_latency_us().count());
logger.info(pdu->msg,
pdu->N_bytes,
"RX MCH PDU (%d B). Stack latency: %ld us",
pdu->N_bytes,
pdu->get_latency_us().count());
dl_tput_bytes += pdu->N_bytes;
// Hack to drop initial 2 bytes
@ -150,11 +154,11 @@ void gw::write_pdu_mch(uint32_t lcid, srslte::unique_byte_buffer_t pdu)
memcpy(&dst_addr.s_addr, &pdu->msg[16], 4);
if (!if_up) {
log.warning("TUN/TAP not up - dropping gw RX message\n");
logger.warning("TUN/TAP not up - dropping gw RX message");
} else {
int n = write(tun_fd, pdu->msg, pdu->N_bytes);
if (n > 0 && (pdu->N_bytes != (uint32_t)n)) {
log.warning("DL TUN/TAP write failure\n");
logger.warning("DL TUN/TAP write failure");
}
}
}
@ -196,7 +200,7 @@ int gw::apply_traffic_flow_template(const uint8_t&
void gw::set_test_loop_mode(const test_loop_mode_state_t mode, const uint32_t ip_pdu_delay_ms)
{
log.error("UE test loop mode not supported\n");
logger.error("UE test loop mode not supported");
}
/*******************************************************************************
@ -219,14 +223,14 @@ void gw::run_thread()
srslte::unique_byte_buffer_t pdu = srslte::allocate_unique_buffer(*pool, true);
if (!pdu) {
log.error("Fatal Error: Couldn't allocate PDU in run_thread().\n");
logger.error("Fatal Error: Couldn't allocate PDU in run_thread().");
return;
}
const static uint32_t REGISTER_WAIT_TOUT = 40, SERVICE_WAIT_TOUT = 40; // 4 sec
uint32_t register_wait = 0, service_wait = 0;
log.info("GW IP packet receiver thread run_enable\n");
logger.info("GW IP packet receiver thread run_enable");
running = true;
while (run_enable) {
@ -234,14 +238,14 @@ void gw::run_thread()
if (SRSLTE_MAX_BUFFER_SIZE_BYTES - SRSLTE_BUFFER_HEADER_OFFSET > idx) {
N_bytes = read(tun_fd, &pdu->msg[idx], SRSLTE_MAX_BUFFER_SIZE_BYTES - SRSLTE_BUFFER_HEADER_OFFSET - idx);
} else {
log.error("GW pdu buffer full - gw receive thread exiting.\n");
logger.error("GW pdu buffer full - gw receive thread exiting.");
srslte::console("GW pdu buffer full - gw receive thread exiting.\n");
break;
}
log.debug("Read %d bytes from TUN fd=%d, idx=%d\n", N_bytes, tun_fd, idx);
logger.debug("Read %d bytes from TUN fd=%d, idx=%d", N_bytes, tun_fd, idx);
if (N_bytes <= 0) {
log.error("Failed to read from TUN interface - gw receive thread exiting.\n");
logger.error("Failed to read from TUN interface - gw receive thread exiting.");
srslte::console("Failed to read from TUN interface - gw receive thread exiting.\n");
break;
}
@ -256,19 +260,19 @@ void gw::run_thread()
} else if (ip_pkt->version == 6) {
pkt_len = ntohs(ip6_pkt->payload_len) + 40;
} else {
log.error_hex(pdu->msg, pdu->N_bytes, "Unsupported IP version. Dropping packet.\n");
logger.error(pdu->msg, pdu->N_bytes, "Unsupported IP version. Dropping packet.");
continue;
}
log.debug("IPv%d packet total length: %d Bytes\n", ip_pkt->version, pkt_len);
logger.debug("IPv%d packet total length: %d Bytes", int(ip_pkt->version), pkt_len);
// Check if entire packet was received
if (pkt_len == pdu->N_bytes) {
log.info_hex(pdu->msg, pdu->N_bytes, "TX PDU");
logger.info(pdu->msg, pdu->N_bytes, "TX PDU");
// Make sure UE is attached
while (run_enable && !stack->is_registered() && register_wait < REGISTER_WAIT_TOUT) {
if (!register_wait) {
log.info("UE is not attached, waiting for NAS attach (%d/%d)\n", register_wait, REGISTER_WAIT_TOUT);
logger.info("UE is not attached, waiting for NAS attach (%d/%d)", register_wait, REGISTER_WAIT_TOUT);
}
usleep(100000);
register_wait++;
@ -283,8 +287,8 @@ void gw::run_thread()
// Wait for service request if necessary
while (run_enable && !stack->is_lcid_enabled(default_lcid) && service_wait < SERVICE_WAIT_TOUT) {
if (!service_wait) {
log.info(
"UE does not have service, waiting for NAS service request (%d/%d)\n", service_wait, SERVICE_WAIT_TOUT);
logger.info(
"UE does not have service, waiting for NAS service request (%d/%d)", service_wait, SERVICE_WAIT_TOUT);
stack->start_service_request();
}
usleep(100000);
@ -306,7 +310,7 @@ void gw::run_thread()
do {
pdu = srslte::allocate_unique_buffer(*pool);
if (!pdu) {
log.error("Fatal Error: Couldn't allocate PDU in run_thread().\n");
logger.error("Fatal Error: Couldn't allocate PDU in run_thread().");
usleep(100000);
}
} while (!pdu);
@ -314,11 +318,11 @@ void gw::run_thread()
}
} else {
idx += N_bytes;
log.debug("Entire packet not read from socket. Total Length %d, N_Bytes %d.\n", ip_pkt->tot_len, pdu->N_bytes);
logger.debug("Entire packet not read from socket. Total Length %d, N_Bytes %d.", ip_pkt->tot_len, pdu->N_bytes);
}
}
running = false;
log.info("GW IP receiver thread exiting.\n");
logger.info("GW IP receiver thread exiting.");
}
/**************************/
@ -337,22 +341,22 @@ int gw::init_if(char* err_str)
netns_fd = open(netns.c_str(), O_RDONLY);
if (netns_fd == -1) {
err_str = strerror(errno);
log.error("Failed to find netns %s (%s): %s\n", args.netns.c_str(), netns.c_str(), err_str);
logger.error("Failed to find netns %s (%s): %s", args.netns.c_str(), netns.c_str(), err_str);
return SRSLTE_ERROR_CANT_START;
}
if (setns(netns_fd, CLONE_NEWNET) == -1) {
err_str = strerror(errno);
log.error("Failed to change netns: %s\n", err_str);
logger.error("Failed to change netns: %s", err_str);
return SRSLTE_ERROR_CANT_START;
}
}
// Construct the TUN device
tun_fd = open("/dev/net/tun", O_RDWR);
log.info("TUN file descriptor = %d\n", tun_fd);
logger.info("TUN file descriptor = %d", tun_fd);
if (0 > tun_fd) {
err_str = strerror(errno);
log.error("Failed to open TUN device: %s\n", err_str);
logger.error("Failed to open TUN device: %s", err_str);
return SRSLTE_ERROR_CANT_START;
}
@ -363,7 +367,7 @@ int gw::init_if(char* err_str)
ifr.ifr_ifrn.ifrn_name[IFNAMSIZ - 1] = 0;
if (0 > ioctl(tun_fd, TUNSETIFF, &ifr)) {
err_str = strerror(errno);
log.error("Failed to set TUN device name: %s\n", err_str);
logger.error("Failed to set TUN device name: %s", err_str);
close(tun_fd);
return SRSLTE_ERROR_CANT_START;
}
@ -372,14 +376,14 @@ int gw::init_if(char* err_str)
sock = socket(AF_INET, SOCK_DGRAM, 0);
if (0 > ioctl(sock, SIOCGIFFLAGS, &ifr)) {
err_str = strerror(errno);
log.error("Failed to bring up socket: %s\n", err_str);
logger.error("Failed to bring up socket: %s", err_str);
close(tun_fd);
return SRSLTE_ERROR_CANT_START;
}
ifr.ifr_flags |= IFF_UP | IFF_RUNNING;
if (0 > ioctl(sock, SIOCSIFFLAGS, &ifr)) {
err_str = strerror(errno);
log.error("Failed to set socket flags: %s\n", err_str);
logger.error("Failed to set socket flags: %s", err_str);
close(tun_fd);
return SRSLTE_ERROR_CANT_START;
}
@ -388,10 +392,10 @@ int gw::init_if(char* err_str)
struct in6_addr in6p;
char addr_str[INET6_ADDRSTRLEN];
if (find_ipv6_addr(&in6p)) {
log.debug("Found link-local IPv6 address: %s\n", inet_ntop(AF_INET6, &in6p, addr_str, INET6_ADDRSTRLEN));
logger.debug("Found link-local IPv6 address: %s", inet_ntop(AF_INET6, &in6p, addr_str, INET6_ADDRSTRLEN));
del_ipv6_addr(&in6p);
} else {
log.warning("Could not find link-local IPv6 address.\n");
logger.warning("Could not find link-local IPv6 address.");
}
if_up = true;
@ -403,7 +407,7 @@ int gw::setup_if_addr4(uint32_t ip_addr, char* err_str)
if (ip_addr != current_ip_addr) {
if (!if_up) {
if (init_if(err_str)) {
log.error("init_if failed\n");
logger.error("init_if failed");
return SRSLTE_ERROR_CANT_START;
}
}
@ -414,7 +418,7 @@ int gw::setup_if_addr4(uint32_t ip_addr, char* err_str)
((struct sockaddr_in*)&ifr.ifr_addr)->sin_addr.s_addr = htonl(ip_addr);
if (0 > ioctl(sock, SIOCSIFADDR, &ifr)) {
err_str = strerror(errno);
log.debug("Failed to set socket address: %s\n", err_str);
logger.debug("Failed to set socket address: %s", err_str);
close(tun_fd);
return SRSLTE_ERROR_CANT_START;
}
@ -422,7 +426,7 @@ int gw::setup_if_addr4(uint32_t ip_addr, char* err_str)
((struct sockaddr_in*)&ifr.ifr_netmask)->sin_addr.s_addr = inet_addr(args.tun_dev_netmask.c_str());
if (0 > ioctl(sock, SIOCSIFNETMASK, &ifr)) {
err_str = strerror(errno);
log.debug("Failed to set socket netmask: %s\n", err_str);
logger.debug("Failed to set socket netmask: %s", err_str);
close(tun_fd);
return SRSLTE_ERROR_CANT_START;
}
@ -447,7 +451,7 @@ int gw::setup_if_addr6(uint8_t* ipv6_if_id, char* err_str)
if (!match) {
if (!if_up) {
if (init_if(err_str)) {
log.error("init_if failed\n");
logger.error("init_if failed");
return SRSLTE_ERROR_CANT_START;
}
}
@ -457,7 +461,7 @@ int gw::setup_if_addr6(uint8_t* ipv6_if_id, char* err_str)
ifr.ifr_addr.sa_family = AF_INET6;
if (inet_pton(AF_INET6, "fe80::", (void*)&sai.sin6_addr) <= 0) {
log.error("Bad address\n");
logger.error("Bad address");
return SRSLTE_ERROR_CANT_START;
}
@ -472,7 +476,7 @@ int gw::setup_if_addr6(uint8_t* ipv6_if_id, char* err_str)
if (ioctl(sock, SIOCSIFADDR, &ifr6) < 0) {
err_str = strerror(errno);
log.error("Could not set IPv6 Link local address. Error %s\n", err_str);
logger.error("Could not set IPv6 Link local address. Error %s", err_str);
return SRSLTE_ERROR_CANT_START;
}
@ -499,19 +503,19 @@ bool gw::find_ipv6_addr(struct in6_addr* in6_out)
char buf[1024];
} req;
log.debug("Trying to obtain IPv6 addr of %s interface\n", args.tun_dev_name.c_str());
logger.debug("Trying to obtain IPv6 addr of %s interface", args.tun_dev_name.c_str());
// Get Interface Index
if_index = if_nametoindex(args.tun_dev_name.c_str());
if (if_index == 0) {
log.error("Could not find interface index\n");
logger.error("Could not find interface index");
goto err_out;
}
// Open NETLINK socket
fd = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE);
if (fd < 0) {
log.error("Error openning NETLINK socket -- %s\n", strerror(errno));
logger.error("Error openning NETLINK socket -- %s", strerror(errno));
goto err_out;
}
@ -532,18 +536,18 @@ bool gw::find_ipv6_addr(struct in6_addr* in6_out)
// Time to send and recv the message from kernel
n = send(fd, &req, req.n.nlmsg_len, 0);
if (n < 0) {
log.error("Error sending NETLINK message to kernel -- %s", strerror(errno));
logger.error("Error sending NETLINK message to kernel -- %s", strerror(errno));
goto err_out;
}
n = recv(fd, buf, sizeof(buf), 0);
if (n < 0) {
log.error("Error receiving from NETLINK socket\n");
logger.error("Error receiving from NETLINK socket");
goto err_out;
}
if (n == 0) {
log.error("Nothing received from NETLINK Socket\n");
logger.error("Nothing received from NETLINK Socket");
goto err_out;
}
@ -552,14 +556,14 @@ bool gw::find_ipv6_addr(struct in6_addr* in6_out)
// Chack NL message type
if (nlmp->nlmsg_type == NLMSG_DONE) {
log.error("Reach end of NETLINK message without finding IPv6 address.\n");
logger.error("Reach end of NETLINK message without finding IPv6 address.");
goto err_out;
}
if (nlmp->nlmsg_type == NLMSG_ERROR) {
log.error("NLMSG_ERROR in NETLINK reply\n");
logger.error("NLMSG_ERROR in NETLINK reply");
goto err_out;
}
log.debug("NETLINK message type %d\n", nlmp->nlmsg_type);
logger.debug("NETLINK message type %d", nlmp->nlmsg_type);
// Get IFA message
rtmp = (struct ifaddrmsg*)NLMSG_DATA(nlmp);
@ -603,14 +607,14 @@ void gw::del_ipv6_addr(struct in6_addr* in6p)
// Get Interface Index
if_index = if_nametoindex(args.tun_dev_name.c_str());
if (if_index == 0) {
log.error("Could not find interface index\n");
logger.error("Could not find interface index");
goto out;
}
// Open netlink socket
fd = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE);
if (fd < 0) {
log.error("Error openning NETLINK socket -- %s\n", strerror(errno));
logger.error("Error openning NETLINK socket -- %s", strerror(errno));
goto out;
}
@ -635,7 +639,7 @@ void gw::del_ipv6_addr(struct in6_addr* in6p)
status = send(fd, &req, req.n.nlmsg_len, 0);
if (status < 0) {
log.error("Error sending NETLINK message\n");
logger.error("Error sending NETLINK message");
goto out;
}

File diff suppressed because it is too large Load Diff

@ -19,7 +19,7 @@ void emm_state_t::set_null()
state = state_t::null;
deregistered_substate = deregistered_substate_t::null;
registered_substate = registered_substate_t::null;
nas_log->debug("Changed to EMM state: %s\n", get_full_state_text().c_str());
logger.debug("Changed to EMM state: %s", get_full_state_text().c_str());
}
void emm_state_t::set_deregistered(deregistered_substate_t substate)
@ -27,7 +27,7 @@ void emm_state_t::set_deregistered(deregistered_substate_t substate)
state = state_t::deregistered;
deregistered_substate = substate;
registered_substate = registered_substate_t::null;
nas_log->debug("Changed to EMM state: %s\n", get_full_state_text().c_str());
logger.debug("Changed to EMM state: %s", get_full_state_text().c_str());
}
void emm_state_t::set_deregistered_initiated()
@ -35,7 +35,7 @@ void emm_state_t::set_deregistered_initiated()
state = state_t::deregistered_initiated;
deregistered_substate = deregistered_substate_t::null;
registered_substate = registered_substate_t::null;
nas_log->debug("Changed to EMM state: %s\n", get_full_state_text().c_str());
logger.debug("Changed to EMM state: %s", get_full_state_text().c_str());
}
void emm_state_t::set_registered(registered_substate_t substate)
@ -43,7 +43,7 @@ void emm_state_t::set_registered(registered_substate_t substate)
state = state_t::registered;
deregistered_substate = deregistered_substate_t::null;
registered_substate = substate;
nas_log->debug("Changed to EMM state: %s\n", get_full_state_text().c_str());
logger.debug("Changed to EMM state: %s", get_full_state_text().c_str());
}
void emm_state_t::set_registered_initiated()
@ -51,7 +51,7 @@ void emm_state_t::set_registered_initiated()
state = state_t::registered_initiated;
deregistered_substate = deregistered_substate_t::null;
registered_substate = registered_substate_t::null;
nas_log->debug("Changed to EMM state: %s\n", get_full_state_text().c_str());
logger.debug("Changed to EMM state: %s", get_full_state_text().c_str());
}
void emm_state_t::set_tau_initiated()
@ -59,7 +59,7 @@ void emm_state_t::set_tau_initiated()
state = state_t::tau_initiated;
deregistered_substate = deregistered_substate_t::null;
registered_substate = registered_substate_t::null;
nas_log->debug("Changed to EMM state: %s\n", get_full_state_text().c_str());
logger.debug("Changed to EMM state: %s", get_full_state_text().c_str());
}
void emm_state_t::set_service_request_initiated()
@ -67,7 +67,7 @@ void emm_state_t::set_service_request_initiated()
state = state_t::service_request_initiated;
deregistered_substate = deregistered_substate_t::null;
registered_substate = registered_substate_t::null;
nas_log->debug("Changed to EMM state: %s\n", get_full_state_text().c_str());
logger.debug("Changed to EMM state: %s", get_full_state_text().c_str());
}
const std::string emm_state_t::get_full_state_text()

@ -14,9 +14,9 @@
using namespace srslte;
#define ProcError(fmt, ...) nas_ptr->nas_log->error("Proc \"%s\" - " fmt, name(), ##__VA_ARGS__)
#define ProcWarning(fmt, ...) nas_ptr->nas_log->warning("Proc \"%s\" - " fmt, name(), ##__VA_ARGS__)
#define ProcInfo(fmt, ...) nas_ptr->nas_log->info("Proc \"%s\" - " fmt, name(), ##__VA_ARGS__)
#define ProcError(fmt, ...) nas_ptr->logger.error("Proc \"%s\" - " fmt, name(), ##__VA_ARGS__)
#define ProcWarning(fmt, ...) nas_ptr->logger.warning("Proc \"%s\" - " fmt, name(), ##__VA_ARGS__)
#define ProcInfo(fmt, ...) nas_ptr->logger.info("Proc \"%s\" - " fmt, name(), ##__VA_ARGS__)
namespace srsue {
@ -30,11 +30,11 @@ proc_outcome_t nas::plmn_search_proc::init()
{
// start RRC PLMN selection
if (not nas_ptr->rrc->plmn_search()) {
ProcError("ProcError while searching for PLMNs\n");
ProcError("ProcError while searching for PLMNs");
return proc_outcome_t::error;
}
ProcInfo("Starting...\n");
ProcInfo("Starting...");
return proc_outcome_t::yield;
}
@ -45,7 +45,7 @@ proc_outcome_t nas::plmn_search_proc::step()
void nas::plmn_search_proc::then(const srslte::proc_state_t& result)
{
ProcInfo("Completed with %s\n", result.is_success() ? "success" : "failure");
ProcInfo("Completed with %s", result.is_success() ? "success" : "failure");
if (result.is_error()) {
nas_ptr->enter_emm_deregistered(emm_state_t::deregistered_substate_t::plmn_search);
@ -57,16 +57,16 @@ proc_outcome_t nas::plmn_search_proc::react(const plmn_search_complete_t& t)
// check whether the NAS state hasn't changed
if (nas_ptr->state.get_state() != emm_state_t::state_t::deregistered and
nas_ptr->state.get_deregistered_substate() != emm_state_t::deregistered_substate_t::plmn_search) {
ProcError("ProcError while searching for PLMNs\n");
ProcError("ProcError while searching for PLMNs");
return proc_outcome_t::error;
}
if (t.nof_plmns < 0) {
ProcError("Error while searching for PLMNs\n");
ProcError("Error while searching for PLMNs");
return proc_outcome_t::error;
}
if (t.nof_plmns == 0) {
ProcWarning("Did not find any PLMN in the set of frequencies.\n");
ProcWarning("Did not find any PLMN in the set of frequencies.");
return proc_outcome_t::error;
}
@ -74,8 +74,7 @@ proc_outcome_t nas::plmn_search_proc::react(const plmn_search_complete_t& t)
nas_ptr->known_plmns.clear();
for (int i = 0; i < t.nof_plmns; i++) {
nas_ptr->known_plmns.push_back(t.found_plmns[i].plmn_id);
nas_ptr->nas_log->info(
"Found PLMN: Id=%s, TAC=%d\n", t.found_plmns[i].plmn_id.to_string().c_str(), t.found_plmns[i].tac);
ProcInfo("Found PLMN: Id=%s, TAC=%d", t.found_plmns[i].plmn_id.to_string().c_str(), t.found_plmns[i].tac);
srslte::console("Found PLMN: Id=%s, TAC=%d\n", t.found_plmns[i].plmn_id.to_string().c_str(), t.found_plmns[i].tac);
}
nas_ptr->select_plmn();
@ -83,7 +82,7 @@ proc_outcome_t nas::plmn_search_proc::react(const plmn_search_complete_t& t)
// Select PLMN in request establishment of RRC connection
if (nas_ptr->state.get_state() != emm_state_t::state_t::deregistered and
nas_ptr->state.get_deregistered_substate() != emm_state_t::deregistered_substate_t::normal_service) {
ProcError("PLMN is not selected because no suitable PLMN was found\n");
ProcError("PLMN is not selected because no suitable PLMN was found");
return proc_outcome_t::error;
}

@ -22,7 +22,7 @@ using namespace srslte;
namespace srsue {
pcsc_usim::pcsc_usim(srslte::log* log_) : usim_base(log_)
pcsc_usim::pcsc_usim(srslog::basic_logger& logger) : usim_base(logger), sc(logger)
{
bzero(ck, CK_LEN);
bzero(ik, IK_LEN);
@ -41,7 +41,7 @@ int pcsc_usim::init(usim_args_t* args)
{
int ret = SRSLTE_ERROR;
if (sc.init(args, log) != SRSLTE_SUCCESS) {
if (sc.init(args) != SRSLTE_SUCCESS) {
return ret;
}
@ -49,7 +49,7 @@ int pcsc_usim::init(usim_args_t* args)
char tmp[15];
size_t tmp_len = 15; // set to max IMSI length
if (sc.get_imsi(tmp, &tmp_len)) {
log->error("Error reading IMSI from SIM.\n");
logger.error("Error reading IMSI from SIM.");
return ret;
}
imsi_str.assign(tmp, tmp_len);
@ -63,7 +63,7 @@ int pcsc_usim::init(usim_args_t* args)
imsi += imsi_c[i] - '0';
}
} else {
log->error("Invalid length for IMSI: %zu should be %d\n", imsi_str.length(), 15);
logger.error("Invalid length for IMSI: %zu should be %d", imsi_str.length(), 15);
srslte::console("Invalid length for IMSI: %zu should be %d\n", imsi_str.length(), 15);
return ret;
}
@ -77,7 +77,7 @@ int pcsc_usim::init(usim_args_t* args)
imei += imei_c[i] - '0';
}
} else {
log->error("Invalid length for IMEI: %zu should be %d\n", args->imei.length(), 15);
logger.error("Invalid length for IMEI: %zu should be %d", args->imei.length(), 15);
srslte::console("Invalid length for IMEI: %zu should be %d\n", args->imei.length(), 15);
return ret;
}
@ -104,26 +104,26 @@ auth_result_t pcsc_usim::generate_authentication_response(uint8_t* rand,
{
auth_result_t ret = AUTH_FAILED;
if (!initiated) {
ERROR("USIM not initiated!\n");
ERROR("USIM not initiated!");
return ret;
}
// Use RAND and AUTN to compute RES, CK, IK using SIM card
switch (sc.umts_auth(rand, autn_enb, res, res_len, ik, ck, auts)) {
case 0:
log->info("SCARD: USIM authentication successful.\n");
logger.info("SCARD: USIM authentication successful.");
break;
case -1:
log->error("SCARD: Failure during USIM UMTS authentication\n");
logger.error("SCARD: Failure during USIM UMTS authentication");
return ret;
case -2:
log->info("SCARD: USIM synchronization failure, AUTS generated\n");
log->debug_hex(auts, AKA_AUTS_LEN, "AUTS\n");
logger.info("SCARD: USIM synchronization failure, AUTS generated");
logger.debug(auts, AKA_AUTS_LEN, "AUTS");
memcpy(res, auts, AKA_AUTS_LEN);
*res_len = AKA_AUTS_LEN;
return AUTH_SYNCH_FAILURE;
default:
log->warning("SCARD: Unknown USIM failure.\n");
logger.warning("SCARD: Unknown USIM failure.");
return ret;
}
@ -137,13 +137,13 @@ auth_result_t pcsc_usim::generate_authentication_response(uint8_t* rand,
}
// Generate K_asme
log->debug_hex(ck, CK_LEN, "CK:\n");
log->debug_hex(ik, IK_LEN, "IK:\n");
log->debug_hex(ak, AK_LEN, "AK:\n");
log->debug_hex(sqn, SQN_LEN, "SQN:\n");
log->debug("mcc=%d, mnc=%d\n", mcc, mnc);
logger.debug(ck, CK_LEN, "CK:");
logger.debug(ik, IK_LEN, "IK:");
logger.debug(ak, AK_LEN, "AK:");
logger.debug(sqn, SQN_LEN, "SQN:");
logger.debug("mcc=%d, mnc=%d", mcc, mnc);
security_generate_k_asme(ck, ik, ak, sqn, mcc, mnc, k_asme);
log->info_hex(k_asme, KEY_LEN, "K_ASME:\n");
logger.info(k_asme, KEY_LEN, "K_ASME:");
ret = AUTH_OK;
@ -168,49 +168,48 @@ std::string pcsc_usim::get_mnc_str(const uint8_t* imsi_vec, std::string mcc_str)
********************************/
// return 0 if initialization was successfull, -1 otherwies
int pcsc_usim::scard::init(usim_args_t* args, srslte::log* log_)
int pcsc_usim::scard::init(usim_args_t* args)
{
int ret_value = SRSLTE_ERROR;
uint pos = 0; // SC reader
bool reader_found = false;
// int transaction = 1;
size_t blen;
log = log_;
long ret;
ret = SCardEstablishContext(SCARD_SCOPE_SYSTEM, NULL, NULL, &scard_context);
if (ret != SCARD_S_SUCCESS) {
log->error("SCardEstablishContext(): %s\n", pcsc_stringify_error(ret));
logger.error("SCardEstablishContext(): %s", pcsc_stringify_error(ret));
return ret_value;
}
unsigned long len = 0;
ret = SCardListReaders(scard_context, NULL, NULL, &len);
if (ret != SCARD_S_SUCCESS) {
log->error("SCardListReaders(): %s\n", pcsc_stringify_error(ret));
logger.error("SCardListReaders(): %s", pcsc_stringify_error(ret));
return ret_value;
}
char* readers = (char*)malloc(len);
if (readers == NULL) {
log->error("Malloc failed\n");
logger.error("Malloc failed");
return ret_value;
}
ret = SCardListReaders(scard_context, NULL, readers, &len);
if (ret != SCARD_S_SUCCESS) {
log->error("SCardListReaders() 2: %s\n", pcsc_stringify_error(ret));
logger.error("SCardListReaders() 2: %s", pcsc_stringify_error(ret));
goto clean_exit;
}
if (len < 3) {
log->info("No smart card readers available.\n");
logger.info("No smart card readers available.");
return ret_value;
}
/* readers: NULL-separated list of reader names, and terminating NULL */
pos = 0;
while (pos < len - 1) {
log->info("Available Card Reader: %s\n", &readers[pos]);
logger.info("Available Card Reader: %s", &readers[pos]);
while (readers[pos] != '\0' && pos < len) {
pos++;
}
@ -223,7 +222,7 @@ int pcsc_usim::scard::init(usim_args_t* args, srslte::log* log_)
// If no reader specified, test all available readers for SIM cards. Otherwise consider specified reader only.
if (args->reader.length() == 0) {
while (pos < len && !reader_found) {
log->info("Trying Card Reader: %s\n", &readers[pos]);
logger.info("Trying Card Reader: %s", &readers[pos]);
// Connect to card
ret = SCardConnect(scard_context,
&readers[pos],
@ -235,11 +234,11 @@ int pcsc_usim::scard::init(usim_args_t* args, srslte::log* log_)
reader_found = true;
} else {
if (ret == (long)SCARD_E_NO_SMARTCARD) {
log->error("No smart card inserted.\n");
logger.error("No smart card inserted.");
} else {
log->error("%s\n", pcsc_stringify_error(ret));
logger.error("%s", pcsc_stringify_error(ret));
}
log->info("Failed to use Card Reader: %s\n", &readers[pos]);
logger.info("Failed to use Card Reader: %s", &readers[pos]);
// proceed to next reader
while (pos < len && readers[pos] != '\0') {
@ -253,7 +252,7 @@ int pcsc_usim::scard::init(usim_args_t* args, srslte::log* log_)
while (pos < len && !reader_found) {
if (strcmp(&readers[pos], args->reader.c_str()) == 0) {
reader_found = true;
log->info("Card Reader found: %s\n", args->reader.c_str());
logger.info("Card Reader found: %s", args->reader.c_str());
} else {
// next reader
while (pos < len && readers[pos] != '\0') {
@ -263,7 +262,7 @@ int pcsc_usim::scard::init(usim_args_t* args, srslte::log* log_)
}
}
if (!reader_found) {
log->error("Cannot find reader: %s\n", args->reader.c_str());
logger.error("Cannot find reader: %s", args->reader.c_str());
} else {
ret = SCardConnect(scard_context,
&readers[pos],
@ -275,12 +274,12 @@ int pcsc_usim::scard::init(usim_args_t* args, srslte::log* log_)
// successfully connected to card
} else {
if (ret == (long)SCARD_E_NO_SMARTCARD) {
log->error("No smart card inserted.\n");
logger.error("No smart card inserted.");
} else {
log->error("%s\n", pcsc_stringify_error(ret));
logger.error("%s", pcsc_stringify_error(ret));
}
log->info("Failed to use Card Reader: %s\n", args->reader.c_str());
logger.info("Failed to use Card Reader: %s", args->reader.c_str());
}
}
}
@ -288,14 +287,14 @@ int pcsc_usim::scard::init(usim_args_t* args, srslte::log* log_)
free(readers);
readers = NULL;
log->info("Card=0x%x active_protocol=%lu (%s)\n",
(unsigned int)scard_handle,
(unsigned long)scard_protocol,
scard_protocol == SCARD_PROTOCOL_T0 ? "T0" : "T1");
logger.info("Card=0x%x active_protocol=%lu (%s)",
(unsigned int)scard_handle,
(unsigned long)scard_protocol,
scard_protocol == SCARD_PROTOCOL_T0 ? "T0" : "T1");
ret = SCardBeginTransaction(scard_handle);
if (ret != SCARD_S_SUCCESS) {
log->error("%s\n", pcsc_stringify_error(ret));
logger.error("%s", pcsc_stringify_error(ret));
goto clean_exit;
}
@ -303,23 +302,23 @@ int pcsc_usim::scard::init(usim_args_t* args, srslte::log* log_)
unsigned char buf[100];
blen = sizeof(buf);
if (_select_file(SCARD_FILE_MF, buf, &blen, SCARD_USIM, NULL, 0)) {
log->info("USIM is not supported. Trying to use GSM SIM");
logger.info("USIM is not supported. Trying to use GSM SIM");
sim_type = SCARD_GSM_SIM;
} else {
log->info("USIM is supported\n");
logger.info("USIM is supported");
sim_type = SCARD_USIM;
}
if (sim_type == SCARD_GSM_SIM) {
blen = sizeof(buf);
if (select_file(SCARD_FILE_MF, buf, &blen)) {
log->debug("SCARD: Failed to read MF\n");
logger.debug("SCARD: Failed to read MF");
goto clean_exit;
}
blen = sizeof(buf);
if (select_file(SCARD_FILE_GSM_DF, buf, &blen)) {
log->debug("SCARD: Failed to read GSM DF\n");
logger.debug("SCARD: Failed to read GSM DF");
goto clean_exit;
}
} else {
@ -328,19 +327,19 @@ int pcsc_usim::scard::init(usim_args_t* args, srslte::log* log_)
aid_len = get_aid(aid, sizeof(aid));
if (aid_len < 0) {
log->debug("SCARD: Failed to find AID for 3G USIM app - try to use standard 3G RID\n");
logger.debug("SCARD: Failed to find AID for 3G USIM app - try to use standard 3G RID");
memcpy(aid, "\xa0\x00\x00\x00\x87", 5);
aid_len = 5;
}
log->debug_hex(aid, aid_len, "SCARD: 3G USIM AID\n");
logger.debug(aid, aid_len, "SCARD: 3G USIM AID");
/* Select based on AID = 3G RID from EF_DIR. This is usually
* starting with A0 00 00 00 87. */
blen = sizeof(buf);
if (_select_file(0, buf, &blen, sim_type, aid, aid_len)) {
log->error("SCARD: Failed to read 3G USIM app\n");
log->error_hex(aid, aid_len, "SCARD: 3G USIM AID\n");
logger.error("SCARD: Failed to read 3G USIM app");
logger.error(aid, aid_len, "SCARD: 3G USIM AID");
goto clean_exit;
}
}
@ -349,11 +348,11 @@ int pcsc_usim::scard::init(usim_args_t* args, srslte::log* log_)
// Verify whether CHV1 (PIN1) is needed to access the card.
ret = pin_needed(buf, blen);
if (ret < 0) {
log->debug("SCARD: Failed to determine whether PIN is needed\n");
logger.debug("SCARD: Failed to determine whether PIN is needed");
goto clean_exit;
}
if (ret) {
log->debug("PIN1 needed for SIM access (retry counter=%d)\n", get_pin_retry_counter());
logger.debug("PIN1 needed for SIM access (retry counter=%d)", get_pin_retry_counter());
pin1_needed = true;
} else {
pin1_needed = false;
@ -361,7 +360,7 @@ int pcsc_usim::scard::init(usim_args_t* args, srslte::log* log_)
// stop before pin retry counter reaches zero
if (pin1_needed && get_pin_retry_counter() <= 1) {
log->error("PIN1 needed for SIM access (retry counter=%d), emergency stop.\n", get_pin_retry_counter());
logger.error("PIN1 needed for SIM access (retry counter=%d), emergency stop.", get_pin_retry_counter());
goto clean_exit;
}
@ -370,7 +369,7 @@ int pcsc_usim::scard::init(usim_args_t* args, srslte::log* log_)
// verify PIN
ret = verify_pin(args->pin.c_str());
if (ret != SCARD_S_SUCCESS) {
log->debug("SCARD: Could not verify PIN\n");
logger.debug("SCARD: Could not verify PIN");
goto clean_exit;
}
}
@ -380,7 +379,7 @@ int pcsc_usim::scard::init(usim_args_t* args, srslte::log* log_)
ret = SCardEndTransaction(scard_handle, SCARD_LEAVE_CARD);
if (ret != SCARD_S_SUCCESS) {
log->debug("SCARD: Could not end transaction: 0x%x\n", (unsigned int)ret);
logger.debug("SCARD: Could not end transaction: 0x%x", (unsigned int)ret);
goto clean_exit;
}
@ -414,9 +413,9 @@ int pcsc_usim::scard::_select_file(unsigned short file_id,
get_resp[0] = USIM_CLA;
}
log->debug("SCARD: select file %04x\n", file_id);
logger.debug("SCARD: select file %04x", file_id);
if (aid) {
log->debug_hex(aid, aidlen, "SCARD: select file by AID");
logger.debug(aid, aidlen, "SCARD: select file by AID");
if (5 + aidlen > sizeof(cmd))
return -1;
cmd[2] = 0x04; /* Select by AID */
@ -431,34 +430,34 @@ int pcsc_usim::scard::_select_file(unsigned short file_id,
len = sizeof(resp);
ret = transmit(cmd, cmdlen, resp, &len);
if (ret != SCARD_S_SUCCESS) {
log->error("SCARD: SCardTransmit failed %s\n", pcsc_stringify_error(ret));
logger.error("SCARD: SCardTransmit failed %s", pcsc_stringify_error(ret));
return -1;
}
if (len != 2) {
log->error("SCARD: unexpected resp len %d (expected 2)\n", (int)len);
logger.error("SCARD: unexpected resp len %d (expected 2)", (int)len);
return -1;
}
if (resp[0] == 0x98 && resp[1] == 0x04) {
/* Security status not satisfied (PIN_WLAN) */
log->warning("SCARD: Security status not satisfied.\n");
logger.warning("SCARD: Security status not satisfied.");
return -1;
}
if (resp[0] == 0x6e) {
log->debug("SCARD: used CLA not supported.\n");
logger.debug("SCARD: used CLA not supported.");
return -1;
}
if (resp[0] != 0x6c && resp[0] != 0x9f && resp[0] != 0x61) {
log->warning("SCARD: unexpected response 0x%02x (expected 0x61, 0x6c, or 0x9f)\n", resp[0]);
logger.warning("SCARD: unexpected response 0x%02x (expected 0x61, 0x6c, or 0x9f)", resp[0]);
return -1;
}
/* Normal ending of command; resp[1] bytes available */
get_resp[4] = resp[1];
log->debug("SCARD: trying to get response (%d bytes)\n", resp[1]);
logger.debug("SCARD: trying to get response (%d bytes)", resp[1]);
rlen = *buf_len;
ret = transmit(get_resp, sizeof(get_resp), buf, &rlen);
@ -467,7 +466,7 @@ int pcsc_usim::scard::_select_file(unsigned short file_id,
return 0;
}
log->warning("SCARD: SCardTransmit err=0x%lx\n", ret);
logger.warning("SCARD: SCardTransmit err=0x%lx", ret);
return -1;
}
@ -481,7 +480,7 @@ long pcsc_usim::scard::transmit(unsigned char* _send, size_t send_len, unsigned
long ret;
unsigned long rlen;
log->debug_hex(_send, send_len, "SCARD: scard_transmit: send\n");
logger.debug(_send, send_len, "SCARD: scard_transmit: send");
rlen = *recv_len;
ret = SCardTransmit(scard_handle,
scard_protocol == SCARD_PROTOCOL_T1 ? SCARD_PCI_T1 : SCARD_PCI_T0,
@ -492,9 +491,9 @@ long pcsc_usim::scard::transmit(unsigned char* _send, size_t send_len, unsigned
&rlen);
*recv_len = rlen;
if (ret == SCARD_S_SUCCESS) {
log->debug_hex(_recv, rlen, "SCARD: SCardTransmit: recv\n");
logger.debug(_recv, rlen, "SCARD: SCardTransmit: recv");
} else {
log->error("SCARD: SCardTransmit failed %s\n", pcsc_stringify_error(ret));
logger.error("SCARD: SCardTransmit failed %s", pcsc_stringify_error(ret));
}
return ret;
}
@ -529,7 +528,7 @@ int pcsc_usim::scard::get_pin_retry_counter()
size_t len;
uint16_t val;
log->info("SCARD: fetching PIN retry counter\n");
logger.info("SCARD: fetching PIN retry counter");
if (sim_type == SCARD_USIM)
cmd[0] = USIM_CLA;
@ -541,20 +540,20 @@ int pcsc_usim::scard::get_pin_retry_counter()
return -2;
if (len != 2) {
log->error("SCARD: failed to fetch PIN retry counter\n");
logger.error("SCARD: failed to fetch PIN retry counter");
return -1;
}
val = to_uint16(resp);
if (val == 0x63c0 || val == 0x6983) {
log->debug("SCARD: PIN has been blocked\n");
logger.debug("SCARD: PIN has been blocked");
return 0;
}
if (val >= 0x63c0 && val <= 0x63cf)
return val & 0x000f;
log->info("SCARD: Unexpected PIN retry counter response value 0x%x\n", val);
logger.info("SCARD: Unexpected PIN retry counter response value 0x%x", val);
return 0;
}
@ -577,64 +576,64 @@ int pcsc_usim::scard::get_aid(unsigned char* aid, size_t maxlen)
aid_pos = &buf[4];
blen = sizeof(buf);
if (select_file(SCARD_FILE_EF_DIR, buf, &blen)) {
log->debug("SCARD: Failed to read EF_DIR\n");
logger.debug("SCARD: Failed to read EF_DIR");
return -1;
}
log->debug_hex(buf, blen, "SCARD: EF_DIR select\n");
logger.debug(buf, blen, "SCARD: EF_DIR select");
for (rec = 1; rec < 10; rec++) {
rlen = get_record_len(rec, SIM_RECORD_MODE_ABSOLUTE);
if (rlen < 0) {
log->debug("SCARD: Failed to get EF_DIR record length\n");
logger.debug("SCARD: Failed to get EF_DIR record length");
return -1;
}
blen = sizeof(buf);
if (rlen > (int)blen) {
log->debug("SCARD: Too long EF_DIR record\n");
logger.debug("SCARD: Too long EF_DIR record");
return -1;
}
if (read_record(buf, rlen, rec, SIM_RECORD_MODE_ABSOLUTE) < 0) {
log->debug("SCARD: Failed to read EF_DIR record %d", rec);
logger.debug("SCARD: Failed to read EF_DIR record %d", rec);
return -1;
}
log->debug_hex(buf, rlen, "SCARD: EF_DIR record\n");
logger.debug(buf, rlen, "SCARD: EF_DIR record");
if (efdir->appl_template_tag != 0x61) {
log->debug("SCARD: Unexpected application template tag 0x%x", efdir->appl_template_tag);
logger.debug("SCARD: Unexpected application template tag 0x%x", efdir->appl_template_tag);
continue;
}
if (efdir->appl_template_len > rlen - 2) {
log->debug("SCARD: Too long application template (len=%d rlen=%d)", efdir->appl_template_len, rlen);
logger.debug("SCARD: Too long application template (len=%d rlen=%d)", efdir->appl_template_len, rlen);
continue;
}
if (efdir->appl_id_tag != 0x4f) {
log->debug("SCARD: Unexpected application identifier tag 0x%x", efdir->appl_id_tag);
logger.debug("SCARD: Unexpected application identifier tag 0x%x", efdir->appl_id_tag);
continue;
}
aid_len = efdir->aid_len;
if (aid_len < 1 || aid_len > 16) {
log->debug("SCARD: Invalid AID length %u\n", aid_len);
logger.debug("SCARD: Invalid AID length %u", aid_len);
continue;
}
log->debug_hex(aid_pos, aid_len, "SCARD: AID from EF_DIR record\n");
logger.debug(aid_pos, aid_len, "SCARD: AID from EF_DIR record");
if (efdir->appl_code[0] == 0x10 && efdir->appl_code[1] == 0x02) {
log->debug("SCARD: 3G USIM app found from EF_DIR record %d\n", rec);
logger.debug("SCARD: 3G USIM app found from EF_DIR record %d", rec);
break;
}
}
if (rec >= 10) {
log->debug("SCARD: 3G USIM app not found from EF_DIR records\n");
logger.debug("SCARD: 3G USIM app not found from EF_DIR records");
return -1;
}
if (aid_len > maxlen) {
log->debug("SCARD: Too long AID\n");
logger.debug("SCARD: Too long AID");
return -1;
}
@ -659,14 +658,14 @@ int pcsc_usim::scard::get_record_len(unsigned char recnum, unsigned char mode)
blen = sizeof(buf);
ret = transmit(cmd, sizeof(cmd), buf, &blen);
if (ret != SCARD_S_SUCCESS) {
log->debug("SCARD: failed to determine file length for record %d\n", recnum);
logger.debug("SCARD: failed to determine file length for record %d", recnum);
return -1;
}
log->debug_hex(buf, blen, "SCARD: file length determination response\n");
logger.debug(buf, blen, "SCARD: file length determination response");
if (blen < 2 || (buf[0] != 0x6c && buf[0] != 0x67)) {
log->error("SCARD: unexpected response to file length determination\n");
logger.error("SCARD: unexpected response to file length determination");
return -1;
}
@ -696,13 +695,13 @@ int pcsc_usim::scard::read_record(unsigned char* data, size_t len, unsigned char
return -2;
}
if (blen != len + 2) {
log->debug("SCARD: record read returned unexpected length %ld (expected %ld)\n", (long)blen, (long)len + 2);
logger.debug("SCARD: record read returned unexpected length %ld (expected %ld)", (long)blen, (long)len + 2);
free(buf);
return -3;
}
if (buf[len] != 0x90 || buf[len + 1] != 0x00) {
log->debug("SCARD: record read returned unexpected status %02x %02x (expected 90 00)\n", buf[len], buf[len + 1]);
logger.debug("SCARD: record read returned unexpected status %02x %02x (expected 90 00)", buf[len], buf[len + 1]);
free(buf);
return -4;
}
@ -733,12 +732,12 @@ int pcsc_usim::scard::get_imsi(char* imsi, size_t* len)
size_t blen, imsilen, i;
char* pos;
log->debug("SCARD: reading IMSI from (GSM) EF-IMSI\n");
logger.debug("SCARD: reading IMSI from (GSM) EF-IMSI");
blen = sizeof(buf);
if (select_file(SCARD_FILE_GSM_EF_IMSI, buf, &blen))
return -1;
if (blen < 4) {
log->warning("SCARD: too short (GSM) EF-IMSI header (len=%ld)\n", (long)blen);
logger.warning("SCARD: too short (GSM) EF-IMSI header (len=%ld)", (long)blen);
return -2;
}
@ -751,12 +750,12 @@ int pcsc_usim::scard::get_imsi(char* imsi, size_t* len)
blen = file_size;
}
if (blen < 2 || blen > sizeof(buf)) {
log->debug("SCARD: invalid IMSI file length=%ld\n", (long)blen);
logger.debug("SCARD: invalid IMSI file length=%ld", (long)blen);
return -3;
}
imsilen = (blen - 2) * 2 + 1;
log->debug("SCARD: IMSI file length=%ld imsilen=%ld\n", (long)blen, (long)imsilen);
logger.debug("SCARD: IMSI file length=%ld imsilen=%ld", (long)blen, (long)imsilen);
if (imsilen > *len) {
*len = imsilen;
return -4;
@ -808,13 +807,13 @@ int pcsc_usim::scard::read_file(unsigned char* data, size_t len)
return -2;
}
if (blen != len + 2) {
log->error("SCARD: file read returned unexpected length %ld (expected %ld)\n", (long)blen, (long)len + 2);
logger.error("SCARD: file read returned unexpected length %ld (expected %ld)", (long)blen, (long)len + 2);
free(buf);
return -3;
}
if (buf[len] != 0x90 || buf[len + 1] != 0x00) {
log->error("SCARD: file read returned unexpected status %02x %02x (expected 90 00)\n", buf[len], buf[len + 1]);
logger.error("SCARD: file read returned unexpected status %02x %02x (expected 90 00)", buf[len], buf[len + 1]);
free(buf);
return -4;
}
@ -837,7 +836,7 @@ int pcsc_usim::scard::parse_fsp_templ(unsigned char* buf, size_t buf_len, int* p
pos = buf;
end = pos + buf_len;
if (*pos != USIM_FSP_TEMPL_TAG) {
log->error("SCARD: file header did not start with FSP template tag\n");
logger.error("SCARD: file header did not start with FSP template tag");
return -1;
}
pos++;
@ -846,14 +845,14 @@ int pcsc_usim::scard::parse_fsp_templ(unsigned char* buf, size_t buf_len, int* p
if (pos[0] < end - pos)
end = pos + 1 + pos[0];
pos++;
log->debug_hex(pos, end - pos, "SCARD: file header FSP template\n");
logger.debug(pos, end - pos, "SCARD: file header FSP template");
while (end - pos >= 2) {
unsigned char type, len;
type = pos[0];
len = pos[1];
log->debug("SCARD: file header TLV 0x%02x len=%d\n", type, len);
logger.debug("SCARD: file header TLV 0x%02x len=%d", type, len);
pos += 2;
if (len > (unsigned int)(end - pos))
@ -861,51 +860,51 @@ int pcsc_usim::scard::parse_fsp_templ(unsigned char* buf, size_t buf_len, int* p
switch (type) {
case USIM_TLV_FILE_DESC:
log->debug_hex(pos, len, "SCARD: File Descriptor TLV\n");
logger.debug(pos, len, "SCARD: File Descriptor TLV");
break;
case USIM_TLV_FILE_ID:
log->debug_hex(pos, len, "SCARD: File Identifier TLV\n");
logger.debug(pos, len, "SCARD: File Identifier TLV");
break;
case USIM_TLV_DF_NAME:
log->debug_hex(pos, len, "SCARD: DF name (AID) TLV\n");
logger.debug(pos, len, "SCARD: DF name (AID) TLV");
break;
case USIM_TLV_PROPR_INFO:
log->debug_hex(pos, len, "SCARD: Proprietary information TLV\n");
logger.debug(pos, len, "SCARD: Proprietary information TLV");
break;
case USIM_TLV_LIFE_CYCLE_STATUS:
log->debug_hex(pos, len, "SCARD: Life Cycle Status Integer TLV\n");
logger.debug(pos, len, "SCARD: Life Cycle Status Integer TLV");
break;
case USIM_TLV_FILE_SIZE:
log->debug_hex(pos, len, "SCARD: File size TLV\n");
logger.debug(pos, len, "SCARD: File size TLV");
if ((len == 1 || len == 2) && file_len) {
if (len == 1) {
*file_len = (int)pos[0];
} else {
*file_len = to_uint16(pos);
}
log->debug("SCARD: file_size=%d\n", *file_len);
logger.debug("SCARD: file_size=%d", *file_len);
}
break;
case USIM_TLV_TOTAL_FILE_SIZE:
log->debug_hex(pos, len, "SCARD: Total file size TLV\n");
logger.debug(pos, len, "SCARD: Total file size TLV");
break;
case USIM_TLV_PIN_STATUS_TEMPLATE:
log->debug_hex(pos, len, "SCARD: PIN Status Template DO TLV\n");
logger.debug(pos, len, "SCARD: PIN Status Template DO TLV");
if (len >= 2 && pos[0] == USIM_PS_DO_TAG && pos[1] >= 1 && ps_do) {
log->debug("SCARD: PS_DO=0x%02x\n", pos[2]);
logger.debug("SCARD: PS_DO=0x%02x", pos[2]);
*ps_do = (int)pos[2];
}
break;
case USIM_TLV_SHORT_FILE_ID:
log->debug_hex(pos, len, "SCARD: Short File Identifier (SFI) TLV\n");
logger.debug(pos, len, "SCARD: Short File Identifier (SFI) TLV");
break;
case USIM_TLV_SECURITY_ATTR_8B:
case USIM_TLV_SECURITY_ATTR_8C:
case USIM_TLV_SECURITY_ATTR_AB:
log->debug_hex(pos, len, "SCARD: Security attribute TLV\n");
logger.debug(pos, len, "SCARD: Security attribute TLV");
break;
default:
log->debug_hex(pos, len, "SCARD: Unrecognized TLV\n");
logger.debug(pos, len, "SCARD: Unrecognized TLV");
break;
}
@ -927,16 +926,16 @@ void pcsc_usim::scard::deinit()
{
long ret;
log->debug("SCARD: deinitializing smart card interface\n");
logger.debug("SCARD: deinitializing smart card interface");
ret = SCardDisconnect(scard_handle, SCARD_UNPOWER_CARD);
if (ret != SCARD_S_SUCCESS) {
log->debug("SCARD: Failed to disconnect smart card (err=%ld)\n", ret);
logger.debug("SCARD: Failed to disconnect smart card (err=%ld)", ret);
}
ret = SCardReleaseContext(scard_context);
if (ret != SCARD_S_SUCCESS) {
log->debug("Failed to release smart card context (err=%ld)\n", ret);
logger.debug("Failed to release smart card context (err=%ld)", ret);
}
}
@ -956,12 +955,12 @@ int pcsc_usim::scard::get_mnc_len()
size_t blen;
int file_size;
log->debug("SCARD: reading MNC len from (GSM) EF-AD\n");
logger.debug("SCARD: reading MNC len from (GSM) EF-AD");
blen = sizeof(buf);
if (select_file(SCARD_FILE_GSM_EF_AD, buf, &blen))
return -1;
if (blen < 4) {
log->debug("SCARD: too short (GSM) EF-AD header (len=%ld)\n", (long)blen);
logger.debug("SCARD: too short (GSM) EF-AD header (len=%ld)", (long)blen);
return -2;
}
@ -972,11 +971,11 @@ int pcsc_usim::scard::get_mnc_len()
return -3;
}
if (file_size == 3) {
log->debug("SCARD: MNC length not available\n");
logger.debug("SCARD: MNC length not available");
return -7;
}
if (file_size < 4 || file_size > (int)sizeof(buf)) {
log->debug("SCARD: invalid file length=%ld\n", (long)file_size);
logger.debug("SCARD: invalid file length=%ld", (long)file_size);
return -4;
}
@ -984,10 +983,10 @@ int pcsc_usim::scard::get_mnc_len()
return -5;
buf[3] = buf[3] & 0x0f; /* upper nibble reserved for future use */
if (buf[3] < 2 || buf[3] > 3) {
log->debug("SCARD: invalid MNC length=%ld\n", (long)buf[3]);
logger.debug("SCARD: invalid MNC length=%ld", (long)buf[3]);
return -6;
}
log->debug("SCARD: MNC length=%ld\n", (long)buf[3]);
logger.debug("SCARD: MNC length=%ld", (long)buf[3]);
return buf[3];
}
@ -1026,12 +1025,12 @@ int pcsc_usim::scard::umts_auth(const unsigned char* _rand,
long ret;
if (sim_type == SCARD_GSM_SIM) {
log->debug("SCARD: Non-USIM card - cannot do UMTS auth\n");
logger.debug("SCARD: Non-USIM card - cannot do UMTS auth");
return -1;
}
log->debug_hex(_rand, AKA_RAND_LEN, "SCARD: UMTS auth - RAND\n");
log->debug_hex(autn, AKA_AUTN_LEN, "SCARD: UMTS auth - AUTN\n");
logger.debug(_rand, AKA_RAND_LEN, "SCARD: UMTS auth - RAND");
logger.debug(autn, AKA_AUTN_LEN, "SCARD: UMTS auth - AUTN");
cmd[5] = AKA_RAND_LEN;
memcpy(cmd + 6, _rand, AKA_RAND_LEN);
cmd[6 + AKA_RAND_LEN] = AKA_AUTN_LEN;
@ -1043,17 +1042,17 @@ int pcsc_usim::scard::umts_auth(const unsigned char* _rand,
return -1;
if (len <= sizeof(resp))
log->debug_hex(resp, len, "SCARD: UMTS alg response\n");
logger.debug(resp, len, "SCARD: UMTS alg response");
if (len == 2 && resp[0] == 0x98 && resp[1] == 0x62) {
// Authentication error, application specific
log->warning("SCARD: UMTS auth failed - MAC != XMAC\n");
logger.warning("SCARD: UMTS auth failed - MAC != XMAC");
return -1;
}
if (len != 2 || resp[0] != 0x61) {
log->warning(
"SCARD: unexpected response for UMTS auth request (len=%ld resp=%02x %02x)\n", (long)len, resp[0], resp[1]);
logger.warning(
"SCARD: unexpected response for UMTS auth request (len=%ld resp=%02x %02x)", (long)len, resp[0], resp[1]);
return -1;
}
get_resp[4] = resp[1];
@ -1063,11 +1062,11 @@ int pcsc_usim::scard::umts_auth(const unsigned char* _rand,
if (ret != SCARD_S_SUCCESS || len > sizeof(buf))
return -1;
log->debug_hex(buf, len, "SCARD: UMTS get response result\n");
logger.debug(buf, len, "SCARD: UMTS get response result");
if (len >= 2 + AKA_AUTS_LEN && buf[0] == 0xdc && buf[1] == AKA_AUTS_LEN) {
log->debug("SCARD: UMTS Synchronization-Failure\n");
logger.debug("SCARD: UMTS Synchronization-Failure");
memcpy(auts, buf + 2, AKA_AUTS_LEN);
log->debug_hex(auts, AKA_AUTS_LEN, "SCARD: AUTS\n");
logger.debug(auts, AKA_AUTS_LEN, "SCARD: AUTS");
*res_len = AKA_AUTS_LEN;
return -2;
}
@ -1078,42 +1077,42 @@ int pcsc_usim::scard::umts_auth(const unsigned char* _rand,
/* RES */
if (pos[0] > RES_MAX_LEN || pos[0] > end - pos) {
log->debug("SCARD: Invalid RES\n");
logger.debug("SCARD: Invalid RES");
return -1;
}
*res_len = *pos++;
memcpy(res, pos, *res_len);
pos += *res_len;
log->debug_hex(res, *res_len, "SCARD: RES\n");
logger.debug(res, *res_len, "SCARD: RES");
/* CK */
if (pos[0] != CK_LEN || CK_LEN > end - pos) {
log->debug("SCARD: Invalid CK\n");
logger.debug("SCARD: Invalid CK");
return -1;
}
pos++;
memcpy(ck, pos, CK_LEN);
pos += CK_LEN;
log->debug_hex(ck, CK_LEN, "SCARD: CK\n");
logger.debug(ck, CK_LEN, "SCARD: CK");
/* IK */
if (pos[0] != IK_LEN || IK_LEN > end - pos) {
log->debug("SCARD: Invalid IK\n");
logger.debug("SCARD: Invalid IK");
return -1;
}
pos++;
memcpy(ik, pos, IK_LEN);
pos += IK_LEN;
log->debug_hex(ik, IK_LEN, "SCARD: IK\n");
logger.debug(ik, IK_LEN, "SCARD: IK");
if (end > pos) {
log->debug_hex(pos, end - pos, "SCARD: Ignore extra data in end\n");
logger.debug(pos, end - pos, "SCARD: Ignore extra data in end");
}
return 0;
}
log->debug("SCARD: Unrecognized response\n");
logger.debug("SCARD: Unrecognized response");
return -1;
}
@ -1124,7 +1123,7 @@ int pcsc_usim::scard::verify_pin(const char* pin)
unsigned char cmd[5 + 8] = {SIM_CMD_VERIFY_CHV1};
size_t len;
log->debug("SCARD: verifying PIN\n");
logger.debug("SCARD: verifying PIN");
if (pin == NULL || strlen(pin) > 8)
return -1;
@ -1140,11 +1139,11 @@ int pcsc_usim::scard::verify_pin(const char* pin)
return -2;
if (len != 2 || resp[0] != 0x90 || resp[1] != 0x00) {
log->debug("SCARD: PIN verification failed\n");
logger.debug("SCARD: PIN verification failed");
return -1;
}
log->debug("SCARD: PIN verified successfully\n");
logger.debug("SCARD: PIN verified successfully");
return SCARD_S_SUCCESS;
}

@ -21,13 +21,13 @@ namespace srsue {
tft_packet_filter_t::tft_packet_filter_t(uint8_t eps_bearer_id_,
uint8_t lcid_,
const LIBLTE_MME_PACKET_FILTER_STRUCT& tft,
srslte::log* log_) :
srslog::basic_logger& logger) :
eps_bearer_id(eps_bearer_id_),
lcid(lcid_),
id(tft.id),
eval_precedence(tft.eval_precedence),
active_filters(0),
log(log_)
logger(logger)
{
int idx = 0;
uint32_t length_in_bytes = 0;
@ -160,7 +160,7 @@ tft_packet_filter_t::tft_packet_filter_t(uint8_t
break;
default:
log->error("ERROR: wrong type: 0x%02x\n", filter_type);
logger.error("ERROR: wrong type: 0x%02x", filter_type);
return;
}
}
@ -383,7 +383,7 @@ uint8_t tft_pdu_matcher::check_tft_filter_match(const srslte::unique_byte_buffer
bool match = filter_pair.second.match(pdu);
if (match) {
lcid = filter_pair.second.lcid;
log->debug("Found filter match -- EPS bearer Id %d, LCID %d\n", filter_pair.second.eps_bearer_id, lcid);
logger.debug("Found filter match -- EPS bearer Id %d, LCID %d", filter_pair.second.eps_bearer_id, lcid);
break;
}
}
@ -398,17 +398,17 @@ int tft_pdu_matcher::apply_traffic_flow_template(const uint8_t&
switch (tft->tft_op_code) {
case LIBLTE_MME_TFT_OPERATION_CODE_CREATE_NEW_TFT:
for (int i = 0; i < tft->packet_filter_list_size; i++) {
log->info("New packet filter for TFT\n");
tft_packet_filter_t filter(erab_id, lcid, tft->packet_filter_list[i], log);
logger.info("New packet filter for TFT");
tft_packet_filter_t filter(erab_id, lcid, tft->packet_filter_list[i], logger);
auto it = tft_filter_map.insert(std::make_pair(filter.eval_precedence, filter));
if (it.second == false) {
log->error("Error inserting TFT Packet Filter\n");
logger.error("Error inserting TFT Packet Filter");
return SRSLTE_ERROR_CANT_START;
}
}
break;
default:
log->error("Unhandled TFT OP code\n");
logger.error("Unhandled TFT OP code");
return SRSLTE_ERROR_CANT_START;
}
return SRSLTE_SUCCESS;

@ -18,7 +18,7 @@ using namespace srslte;
namespace srsue {
usim::usim(srslte::log* log_) : usim_base(log_) {}
usim::usim(srslog::basic_logger& logger) : usim_base(logger) {}
int usim::init(usim_args_t* args)
{
@ -36,7 +36,7 @@ int usim::init(usim_args_t* args)
if (32 == args->k.length()) {
str_to_hex(args->k, k);
} else {
log->error("Invalid length for K: %zu should be %d\n", args->k.length(), 32);
logger.error("Invalid length for K: %zu should be %d", args->k.length(), 32);
srslte::console("Invalid length for K: %zu should be %d\n", args->k.length(), 32);
}
@ -46,14 +46,14 @@ int usim::init(usim_args_t* args)
str_to_hex(args->op, op);
compute_opc(k, op, opc);
} else {
log->error("Invalid length for OP: %zu should be %d\n", args->op.length(), 32);
logger.error("Invalid length for OP: %zu should be %d", args->op.length(), 32);
srslte::console("Invalid length for OP: %zu should be %d\n", args->op.length(), 32);
}
} else {
if (32 == args->opc.length()) {
str_to_hex(args->opc, opc);
} else {
log->error("Invalid length for OPc: %zu should be %d\n", args->opc.length(), 32);
logger.error("Invalid length for OPc: %zu should be %d", args->opc.length(), 32);
srslte::console("Invalid length for OPc: %zu should be %d\n", args->opc.length(), 32);
}
}
@ -66,7 +66,7 @@ int usim::init(usim_args_t* args)
imsi += imsi_c[i] - '0';
}
} else {
log->error("Invalid length for IMSI: %zu should be %d\n", args->imsi.length(), 15);
logger.error("Invalid length for IMSI: %zu should be %d", args->imsi.length(), 15);
srslte::console("Invalid length for IMSI: %zu should be %d\n", args->imsi.length(), 15);
}
@ -77,7 +77,7 @@ int usim::init(usim_args_t* args)
imei += imei_c[i] - '0';
}
} else {
log->error("Invalid length for IMEI: %zu should be %d\n", args->imei.length(), 15);
logger.error("Invalid length for IMEI: %zu should be %d", args->imei.length(), 15);
srslte::console("Invalid length for IMEI: %zu should be %d\n", args->imei.length(), 15);
}

@ -19,19 +19,19 @@
namespace srsue {
std::unique_ptr<usim_base> usim_base::get_instance(usim_args_t* args, srslte::log* log_)
std::unique_ptr<usim_base> usim_base::get_instance(usim_args_t* args, srslog::basic_logger& logger)
{
#if HAVE_PCSC
if (args->mode == "pcsc") {
return std::unique_ptr<usim_base>(new pcsc_usim(log_));
return std::unique_ptr<usim_base>(new pcsc_usim(logger));
}
#endif
// default to soft USIM
return std::unique_ptr<usim_base>(new usim(log_));
return std::unique_ptr<usim_base>(new usim(logger));
}
usim_base::usim_base(srslte::log* _log) : log(_log) {}
usim_base::usim_base(srslog::basic_logger& logger) : logger(logger) {}
usim_base::~usim_base() {}
@ -50,12 +50,12 @@ std::string usim_base::get_imei_str()
bool usim_base::get_imsi_vec(uint8_t* imsi_, uint32_t n)
{
if (!initiated) {
log->error("USIM not initiated!\n");
logger.error("USIM not initiated!");
return false;
}
if (NULL == imsi_ || n < 15) {
log->error("Invalid parameters to get_imsi_vec\n");
logger.error("Invalid parameters to get_imsi_vec");
return false;
}
@ -70,12 +70,12 @@ bool usim_base::get_imsi_vec(uint8_t* imsi_, uint32_t n)
bool usim_base::get_imei_vec(uint8_t* imei_, uint32_t n)
{
if (!initiated) {
log->error("USIM not initiated!\n");
logger.error("USIM not initiated!");
return false;
}
if (NULL == imei_ || n < 15) {
log->error("Invalid parameters to get_imei_vec\n");
logger.error("Invalid parameters to get_imei_vec");
return false;
}
@ -100,7 +100,7 @@ std::string usim_base::get_mcc_str(const uint8_t* imsi_vec)
bool usim_base::get_home_plmn_id(srslte::plmn_id_t* home_plmn_id)
{
if (!initiated) {
log->error("USIM not initiated!\n");
logger.error("USIM not initiated!");
return false;
}
@ -112,11 +112,11 @@ bool usim_base::get_home_plmn_id(srslte::plmn_id_t* home_plmn_id)
std::string plmn_str = mcc_str + mnc_str;
if (home_plmn_id->from_string(plmn_str)) {
log->error("Error reading home PLMN from SIM.\n");
logger.error("Error reading home PLMN from SIM.");
return false;
}
log->info("Read Home PLMN Id=%s\n", home_plmn_id->to_string().c_str());
logger.info("Read Home PLMN Id=%s", home_plmn_id->to_string().c_str());
return true;
}
@ -128,7 +128,7 @@ void usim_base::generate_nas_keys(uint8_t* k_asme,
srslte::INTEGRITY_ALGORITHM_ID_ENUM integ_algo)
{
if (!initiated) {
log->error("USIM not initiated!\n");
logger.error("USIM not initiated!");
return;
}
@ -142,12 +142,12 @@ void usim_base::generate_nas_keys(uint8_t* k_asme,
void usim_base::generate_as_keys(uint8_t* k_asme_, uint32_t count_ul, srslte::as_security_config_t* sec_cfg)
{
if (!initiated) {
log->error("USIM not initiated!\n");
logger.error("USIM not initiated!");
return;
}
log->info("Generating AS Keys. NAS UL COUNT %d\n", count_ul);
log->debug_hex(k_asme_, 32, "K_asme");
logger.info("Generating AS Keys. NAS UL COUNT %d", count_ul);
logger.debug(k_asme_, 32, "K_asme");
// Generate K_enb
srslte::security_generate_k_enb(k_asme_, count_ul, k_enb_ctx.k_enb.data());
@ -174,22 +174,22 @@ void usim_base::generate_as_keys(uint8_t* k_asme_, uint32_t count_ul, srslte::as
k_enb_ctx.ncc = 0;
k_enb_ctx.is_first_ncc = true;
log->debug_hex(k_enb_ctx.k_enb.data(), 32, "Initial K_eNB");
log->debug_hex(sec_cfg->k_rrc_int.data(), sec_cfg->k_rrc_int.size(), "K_RRC_int");
log->debug_hex(sec_cfg->k_rrc_enc.data(), sec_cfg->k_rrc_enc.size(), "K_RRC_enc");
log->debug_hex(sec_cfg->k_up_int.data(), sec_cfg->k_up_int.size(), "K_UP_int");
log->debug_hex(sec_cfg->k_up_enc.data(), sec_cfg->k_up_enc.size(), "K_UP_enc");
logger.debug(k_enb_ctx.k_enb.data(), 32, "Initial K_eNB");
logger.debug(sec_cfg->k_rrc_int.data(), sec_cfg->k_rrc_int.size(), "K_RRC_int");
logger.debug(sec_cfg->k_rrc_enc.data(), sec_cfg->k_rrc_enc.size(), "K_RRC_enc");
logger.debug(sec_cfg->k_up_int.data(), sec_cfg->k_up_int.size(), "K_UP_int");
logger.debug(sec_cfg->k_up_enc.data(), sec_cfg->k_up_enc.size(), "K_UP_enc");
}
void usim_base::generate_as_keys_ho(uint32_t pci, uint32_t earfcn, int ncc, srslte::as_security_config_t* sec_cfg)
{
if (!initiated) {
log->error("USIM not initiated!\n");
logger.error("USIM not initiated!");
return;
}
log->info("Re-generating AS Keys. PCI 0x%02x, DL-EARFCN %d, NCC %d\n", pci, earfcn, ncc);
log->info_hex(k_enb_ctx.k_enb.data(), 32, "Old K_eNB");
logger.info("Re-generating AS Keys. PCI 0x%02x, DL-EARFCN %d, NCC %d", pci, earfcn, ncc);
logger.info(k_enb_ctx.k_enb.data(), 32, "Old K_eNB");
uint8_t* enb_star_key = k_enb_ctx.k_enb.data();
@ -200,14 +200,14 @@ void usim_base::generate_as_keys_ho(uint32_t pci, uint32_t earfcn, int ncc, srsl
while (k_enb_ctx.ncc != (uint32_t)ncc) {
uint8_t* sync = nullptr;
if (k_enb_ctx.is_first_ncc) {
log->debug("Using K_enb_initial for sync. 0x%02x, DL-EARFCN %d, NCC used: %d\n", pci, earfcn, k_enb_ctx.ncc);
logger.debug("Using K_enb_initial for sync. 0x%02x, DL-EARFCN %d, NCC used: %d", pci, earfcn, k_enb_ctx.ncc);
sync = k_enb_initial;
k_enb_ctx.is_first_ncc = false;
} else {
log->debug("Using NH for sync. 0x%02x, DL-EARFCN %d, NCC %d\n", pci, earfcn, k_enb_ctx.ncc);
logger.debug("Using NH for sync. 0x%02x, DL-EARFCN %d, NCC %d", pci, earfcn, k_enb_ctx.ncc);
sync = k_enb_ctx.nh.data();
}
log->debug_hex(k_enb_ctx.nh.data(), 32, "NH:");
logger.debug(k_enb_ctx.nh.data(), 32, "NH:");
// Generate NH
srslte::security_generate_nh(k_asme, sync, k_enb_ctx.nh.data());
@ -239,19 +239,19 @@ void usim_base::generate_as_keys_ho(uint32_t pci, uint32_t earfcn, int ncc, srsl
sec_cfg->k_up_enc.data(),
sec_cfg->k_up_int.data());
log->info_hex(k_enb_ctx.k_enb.data(), 32, "HO K_eNB");
log->info_hex(sec_cfg->k_rrc_enc.data(), sec_cfg->k_rrc_enc.size(), "HO K_RRC_enc");
log->info_hex(sec_cfg->k_rrc_int.data(), sec_cfg->k_rrc_int.size(), "HO K_RRC_int");
logger.info(k_enb_ctx.k_enb.data(), 32, "HO K_eNB");
logger.info(sec_cfg->k_rrc_enc.data(), sec_cfg->k_rrc_enc.size(), "HO K_RRC_enc");
logger.info(sec_cfg->k_rrc_int.data(), sec_cfg->k_rrc_int.size(), "HO K_RRC_int");
}
void usim_base::store_keys_before_ho(const srslte::as_security_config_t& as_ctx)
{
log->info("Storing AS Keys pre-handover. NCC=%d\n", k_enb_ctx.ncc);
log->info_hex(k_enb_ctx.k_enb.data(), 32, "Old K_eNB");
log->info_hex(as_ctx.k_rrc_enc.data(), as_ctx.k_rrc_enc.size(), "Old K_RRC_enc");
log->info_hex(as_ctx.k_rrc_enc.data(), as_ctx.k_rrc_enc.size(), "Old K_RRC_enc");
log->info_hex(as_ctx.k_rrc_int.data(), as_ctx.k_rrc_int.size(), "Old K_RRC_int");
log->info_hex(as_ctx.k_rrc_int.data(), as_ctx.k_rrc_int.size(), "Old K_RRC_int");
logger.info("Storing AS Keys pre-handover. NCC=%d", k_enb_ctx.ncc);
logger.info(k_enb_ctx.k_enb.data(), 32, "Old K_eNB");
logger.info(as_ctx.k_rrc_enc.data(), as_ctx.k_rrc_enc.size(), "Old K_RRC_enc");
logger.info(as_ctx.k_rrc_enc.data(), as_ctx.k_rrc_enc.size(), "Old K_RRC_enc");
logger.info(as_ctx.k_rrc_int.data(), as_ctx.k_rrc_int.size(), "Old K_RRC_int");
logger.info(as_ctx.k_rrc_int.data(), as_ctx.k_rrc_int.size(), "Old K_RRC_int");
old_k_enb_ctx = k_enb_ctx;
old_as_ctx = as_ctx;
return;
@ -259,7 +259,7 @@ void usim_base::store_keys_before_ho(const srslte::as_security_config_t& as_ctx)
void usim_base::restore_keys_from_failed_ho(srslte::as_security_config_t* as_ctx)
{
log->info("Restoring Keys from failed handover. NCC=%d\n", old_k_enb_ctx.ncc);
logger.info("Restoring Keys from failed handover. NCC=%d", old_k_enb_ctx.ncc);
*as_ctx = old_as_ctx;
k_enb_ctx = old_k_enb_ctx;
return;
@ -272,23 +272,23 @@ void usim_base::restore_keys_from_failed_ho(srslte::as_security_config_t* as_ctx
void usim_base::generate_nr_context(uint16_t sk_counter, srslte::as_security_config_t* sec_cfg)
{
if (!initiated) {
log->error("USIM not initiated!\n");
logger.error("USIM not initiated!");
return;
}
log->info("Generating Keys. SCG Counter %d\n", sk_counter);
logger.info("Generating Keys. SCG Counter %d", sk_counter);
srslte::security_generate_sk_gnb(k_enb_ctx.k_enb.data(), k_gnb_ctx.sk_gnb.data(), sk_counter);
log->info_hex(k_gnb_ctx.sk_gnb.data(), 32, "k_sk_gnb");
logger.info(k_gnb_ctx.sk_gnb.data(), 32, "k_sk_gnb");
update_nr_context(sec_cfg);
}
void usim_base::update_nr_context(srslte::as_security_config_t* sec_cfg)
{
if (!initiated) {
log->error("USIM not initiated!\n");
logger.error("USIM not initiated!");
return;
}
log->info_hex(k_gnb_ctx.sk_gnb.data(), 32, "k_sk_gnb");
logger.info(k_gnb_ctx.sk_gnb.data(), 32, "k_sk_gnb");
// Generate K_rrc_enc and K_rrc_int
security_generate_k_nr_rrc(k_gnb_ctx.sk_gnb.data(),
sec_cfg->cipher_algo,
@ -303,10 +303,10 @@ void usim_base::update_nr_context(srslte::as_security_config_t* sec_cfg)
sec_cfg->k_up_enc.data(),
sec_cfg->k_up_int.data());
log->debug_hex(sec_cfg->k_rrc_int.data(), sec_cfg->k_rrc_int.size(), "NR K_RRC_int");
log->debug_hex(sec_cfg->k_rrc_enc.data(), sec_cfg->k_rrc_enc.size(), "NR K_RRC_enc");
log->debug_hex(sec_cfg->k_up_int.data(), sec_cfg->k_up_int.size(), "NR K_UP_int");
log->debug_hex(sec_cfg->k_up_enc.data(), sec_cfg->k_up_enc.size(), "NR K_UP_enc");
logger.debug(sec_cfg->k_rrc_int.data(), sec_cfg->k_rrc_int.size(), "NR K_RRC_int");
logger.debug(sec_cfg->k_rrc_enc.data(), sec_cfg->k_rrc_enc.size(), "NR K_RRC_enc");
logger.debug(sec_cfg->k_up_int.data(), sec_cfg->k_up_int.size(), "NR K_UP_int");
logger.debug(sec_cfg->k_up_enc.data(), sec_cfg->k_up_enc.size(), "NR K_UP_enc");
}
} // namespace srsue

@ -31,10 +31,11 @@ using namespace srslte;
namespace srsue {
ue::ue() : logger(nullptr)
ue::ue(srslog::sink& log_sink) :
old_logger(nullptr), log_sink(log_sink), logger(srslog::fetch_basic_logger("UE", log_sink, false))
{
// print build info
std::cout << std::endl << get_build_string() << std::endl;
std::cout << std::endl << get_build_string() << std::endl << std::endl;
pool = byte_buffer_pool::get_instance();
}
@ -45,13 +46,12 @@ ue::~ue()
int ue::init(const all_args_t& args_, srslte::logger* logger_)
{
int ret = SRSLTE_SUCCESS;
logger = logger_;
int ret = SRSLTE_SUCCESS;
old_logger = logger_;
// Init UE log
log.init("UE ", logger);
log.set_level(srslte::LOG_LEVEL_INFO);
log.info("%s", get_build_string().c_str());
logger.set_level(srslog::basic_levels::info);
logger.info("%s", get_build_string().c_str());
// Validate arguments
if (parse_args(args_)) {
@ -61,7 +61,7 @@ int ue::init(const all_args_t& args_, srslte::logger* logger_)
// Instantiate layers and stack together our UE
if (args.stack.type == "lte") {
std::unique_ptr<ue_stack_lte> lte_stack(new ue_stack_lte());
std::unique_ptr<ue_stack_lte> lte_stack(new ue_stack_lte(log_sink));
if (!lte_stack) {
srslte::console("Error creating LTE stack instance.\n");
return SRSLTE_ERROR;
@ -73,13 +73,13 @@ int ue::init(const all_args_t& args_, srslte::logger* logger_)
return SRSLTE_ERROR;
}
std::unique_ptr<srsue::phy> lte_phy = std::unique_ptr<srsue::phy>(new srsue::phy(logger));
std::unique_ptr<srsue::phy> lte_phy = std::unique_ptr<srsue::phy>(new srsue::phy(old_logger, log_sink));
if (!lte_phy) {
srslte::console("Error creating LTE PHY instance.\n");
return SRSLTE_ERROR;
}
std::unique_ptr<srslte::radio> lte_radio = std::unique_ptr<srslte::radio>(new srslte::radio(logger));
std::unique_ptr<srslte::radio> lte_radio = std::unique_ptr<srslte::radio>(new srslte::radio(old_logger));
if (!lte_radio) {
srslte::console("Error creating radio multi instance.\n");
return SRSLTE_ERROR;
@ -97,12 +97,12 @@ int ue::init(const all_args_t& args_, srslte::logger* logger_)
ret = SRSLTE_ERROR;
}
if (lte_stack->init(args.stack, logger, lte_phy.get(), gw_ptr.get())) {
if (lte_stack->init(args.stack, old_logger, lte_phy.get(), gw_ptr.get())) {
srslte::console("Error initializing stack.\n");
ret = SRSLTE_ERROR;
}
if (gw_ptr->init(args.gw, logger, lte_stack.get())) {
if (gw_ptr->init(args.gw, old_logger, lte_stack.get())) {
srslte::console("Error initializing GW.\n");
ret = SRSLTE_ERROR;
}
@ -113,11 +113,11 @@ int ue::init(const all_args_t& args_, srslte::logger* logger_)
phy = std::move(lte_phy);
radio = std::move(lte_radio);
} else if (args.stack.type == "nr") {
log.info("Initializing NR stack.\n");
logger.info("Initializing NR stack");
#ifdef HAVE_5GNR
std::unique_ptr<srsue::ue_stack_nr> nr_stack(new srsue::ue_stack_nr(logger));
std::unique_ptr<srslte::radio_null> nr_radio(new srslte::radio_null(logger));
std::unique_ptr<srsue::vnf_phy_nr> nr_phy(new srsue::vnf_phy_nr(logger));
std::unique_ptr<srsue::ue_stack_nr> nr_stack(new srsue::ue_stack_nr(old_logger));
std::unique_ptr<srslte::radio_null> nr_radio(new srslte::radio_null(old_logger));
std::unique_ptr<srsue::vnf_phy_nr> nr_phy(new srsue::vnf_phy_nr(old_logger));
std::unique_ptr<gw> gw_ptr(new gw());
// Init layers
@ -136,7 +136,7 @@ int ue::init(const all_args_t& args_, srslte::logger* logger_)
return SRSLTE_ERROR;
}
if (gw_ptr->init(args.gw, logger, nr_stack.get())) {
if (gw_ptr->init(args.gw, old_logger, nr_stack.get())) {
srslte::console("Error initializing GW.\n");
return SRSLTE_ERROR;
}
@ -148,7 +148,7 @@ int ue::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");
logger.error("5G NR stack not compiled. Please, activate CMAKE HAVE_5GNR flag.");
#endif
} else {
srslte::console("Invalid stack type %s. Supported values are [lte].\n", args.stack.type.c_str());
@ -172,20 +172,20 @@ int ue::parse_args(const all_args_t& args_)
// carry out basic sanity checks
if (args.stack.rrc.mbms_service_id > -1) {
if (!args.phy.interpolate_subframe_enabled) {
log.error("interpolate_subframe_enabled = %d, While using MBMS, "
"please set interpolate_subframe_enabled to true\n",
args.phy.interpolate_subframe_enabled);
logger.error("interpolate_subframe_enabled = %d, While using MBMS, "
"please set interpolate_subframe_enabled to true",
args.phy.interpolate_subframe_enabled);
return SRSLTE_ERROR;
}
if (args.phy.nof_phy_threads > 2) {
log.error("nof_phy_threads = %d, While using MBMS, please set "
"number of phy threads to 1 or 2\n",
args.phy.nof_phy_threads);
logger.error("nof_phy_threads = %d, While using MBMS, please set "
"number of phy threads to 1 or 2",
args.phy.nof_phy_threads);
return SRSLTE_ERROR;
}
if ((0 == args.phy.snr_estim_alg.find("refs"))) {
log.error("snr_estim_alg = refs, While using MBMS, please set "
"algorithm to pss or empty \n");
logger.error("snr_estim_alg = refs, While using MBMS, please set "
"algorithm to pss or empty");
return SRSLTE_ERROR;
}
}
@ -210,8 +210,8 @@ int ue::parse_args(const all_args_t& args_)
// replicate some RF parameter to make them available to PHY
args.phy.nof_lte_carriers = args.rf.nof_carriers - args.phy.nof_nr_carriers;
args.phy.nof_rx_ant = args.rf.nof_antennas;
args.phy.agc_enable = args.rf.rx_gain < 0.0f;
args.phy.nof_rx_ant = args.rf.nof_antennas;
args.phy.agc_enable = args.rf.rx_gain < 0.0f;
// populate DL EARFCN list
if (not args.phy.dl_earfcn.empty()) {
@ -229,7 +229,7 @@ int ue::parse_args(const all_args_t& args_)
}
}
} else {
log.error("Error: dl_earfcn list is empty\n");
logger.error("Error: dl_earfcn list is empty");
srslte::console("Error: dl_earfcn list is empty\n");
return SRSLTE_ERROR;
}
@ -266,7 +266,7 @@ int ue::parse_args(const all_args_t& args_)
}
}
} else {
log.error("Error: dl_nr_arfcn list is empty\n");
logger.error("Error: dl_nr_arfcn list is empty");
srslte::console("Error: dl_nr_arfcn list is empty\n");
return SRSLTE_ERROR;
}
@ -345,7 +345,7 @@ std::string ue::get_build_info()
std::string ue::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();
}

@ -29,15 +29,13 @@ using namespace srslte;
static std::unique_ptr<srslte::mac_pcap> pcap_handle = nullptr;
srslte::log_ref mac_log{"MAC"};
namespace srslte {
// fake classes
class rlc_dummy : public srsue::rlc_dummy_interface
{
public:
rlc_dummy(srslte::log_filter* log_) : received_bytes(0), log(log_) {}
rlc_dummy() : received_bytes(0) {}
bool has_data_locked(const uint32_t lcid) final { return ul_queues[lcid] > 0; }
uint32_t get_buffer_state(const uint32_t lcid) final { return ul_queues[lcid]; }
int read_pdu(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes) final
@ -62,7 +60,7 @@ public:
};
void write_pdu(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes) final
{
log->debug_hex(payload, nof_bytes, "Received %d B on LCID %d\n", nof_bytes, lcid);
logger.debug(payload, nof_bytes, "Received %d B on LCID %d", nof_bytes, lcid);
received_bytes += nof_bytes;
}
@ -80,11 +78,11 @@ public:
}
private:
bool read_enable = true;
int32_t read_len = -1; // read all
uint32_t read_min = 0; // minimum "grant size" for read_pdu() to return data
uint32_t received_bytes;
srslte::log_filter* log;
bool read_enable = true;
int32_t read_len = -1; // read all
uint32_t read_min = 0; // minimum "grant size" for read_pdu() to return data
uint32_t received_bytes;
srslog::basic_logger& logger = srslog::fetch_basic_logger("RLC");
// UL queues where key is LCID and value the queue length
std::map<uint32_t, uint32_t> ul_queues;
};
@ -94,7 +92,6 @@ class phy_dummy : public phy_interface_mac_lte
public:
phy_dummy() : scell_cmd(0){};
void set_log(srslte::log* log_h_) { log_h = log_h_; }
void reset()
{
last_preamble_idx = 0;
@ -127,7 +124,7 @@ public:
last_target_power = target_power_dbm;
prach_transmitted = true;
prach_info_tx = true;
log_h->info("PRACH will be transmitted at tti=%d, preamble_idx=%d\n", prach_tti, preamble_idx);
logger.info("PRACH will be transmitted at tti=%d, preamble_idx=%d", prach_tti, preamble_idx);
}
prach_info_t prach_get_info() override
@ -139,7 +136,7 @@ public:
info.tti_ra = prach_tti;
prach_info_tx = false;
info.is_transmitted = true;
log_h->info("PRACH has been transmitted\n");
logger.info("PRACH has been transmitted");
}
}
return info;
@ -195,8 +192,7 @@ public:
memcpy(dl_action.tb[0].payload, payload, len);
// print generated PDU
log_h->info_hex(
dl_action.tb[0].payload, dl_mac_grant.tb[0].tbs, "Generated DL PDU (%d B)\n", dl_mac_grant.tb[0].tbs);
logger.info(dl_action.tb[0].payload, dl_mac_grant.tb[0].tbs, "Generated DL PDU (%d B)", dl_mac_grant.tb[0].tbs);
#if HAVE_PCAP
pcap_handle->write_dl_crnti(dl_action.tb[0].payload, dl_mac_grant.tb[0].tbs, rnti, true, 1, 0);
@ -275,7 +271,9 @@ public:
mac_h->new_grant_ul(0, ul_mac_grant, &ul_action);
// print generated PDU
log_h->info_hex(ul_action.tb.payload, ul_mac_grant.tb.tbs, "Generated UL PDU (%d B)\n", ul_mac_grant.tb.tbs);
if (ul_action.tb.payload) {
logger.info(ul_action.tb.payload, ul_mac_grant.tb.tbs, "Generated UL PDU (%d B)", ul_mac_grant.tb.tbs);
}
#if HAVE_PCAP
pcap_handle->write_ul_crnti(ul_action.tb.payload, ul_mac_grant.tb.tbs, rnti, true, 1, 0);
@ -310,7 +308,7 @@ private:
uint16_t last_crnti = 0;
srslte::log* log_h;
srslog::basic_logger& logger = srslog::fetch_basic_logger("PHY");
bool ul_ndi = false;
bool dl_ndi = false;
@ -376,14 +374,9 @@ int mac_unpack_test()
0xc3, 0xb3, 0x5c, 0xa3, 0x23, 0xad, 0x00, 0x03, 0x20, 0x1b, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x13, 0x89, 0x00, 0x00};
srslte::log_filter rlc_log("RLC");
rlc_log.set_level(srslte::LOG_LEVEL_DEBUG);
rlc_log.set_hex_limit(100000);
// dummy layers
phy_dummy phy;
rlc_dummy rlc(&rlc_log);
rlc_dummy rlc;
rrc_dummy rrc;
stack_dummy stack;
@ -428,13 +421,9 @@ int mac_ul_sch_pdu_test1()
{
const uint8_t tv[] = {0x3f, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01};
srslte::log_filter rlc_log("RLC");
rlc_log.set_level(srslte::LOG_LEVEL_DEBUG);
rlc_log.set_hex_limit(100000);
// dummy layers
phy_dummy phy;
rlc_dummy rlc(&rlc_log);
rlc_dummy rlc;
rrc_dummy rrc;
stack_dummy stack;
@ -463,7 +452,8 @@ int mac_ul_sch_pdu_test1()
mac.new_grant_ul(cc_idx, mac_grant, &ul_action);
// print generated PDU
mac_log->info_hex(ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)\n", mac_grant.tb.tbs);
srslog::fetch_basic_logger("MAC").info(
ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)", mac_grant.tb.tbs);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(ul_action.tb.payload, mac_grant.tb.tbs, 0x1001, true, 1, 0);
#endif
@ -492,13 +482,9 @@ int mac_ul_logical_channel_prioritization_test1()
const uint8_t tv[] = {0x21, 0x0a, 0x22, 0x04, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03};
srslte::log_filter rlc_log("RLC");
rlc_log.set_level(srslte::LOG_LEVEL_DEBUG);
rlc_log.set_hex_limit(100000);
// dummy layers
phy_dummy phy;
rlc_dummy rlc(&rlc_log);
rlc_dummy rlc;
rrc_dummy rrc;
stack_dummy stack;
@ -560,7 +546,8 @@ int mac_ul_logical_channel_prioritization_test1()
mac.new_grant_ul(cc_idx, mac_grant, &ul_action);
// print generated PDU
mac_log->info_hex(ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)\n", mac_grant.tb.tbs);
srslog::fetch_basic_logger("MAC").info(
ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)", mac_grant.tb.tbs);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(ul_action.tb.payload, mac_grant.tb.tbs, 0x1001, true, 1, 0);
#endif
@ -598,13 +585,9 @@ int mac_ul_logical_channel_prioritization_test2()
0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03};
srslte::log_filter rlc_log("RLC");
rlc_log.set_level(srslte::LOG_LEVEL_DEBUG);
rlc_log.set_hex_limit(100000);
// dummy layers
phy_dummy phy;
rlc_dummy rlc(&rlc_log);
rlc_dummy rlc;
rrc_dummy rrc;
stack_dummy stack;
@ -666,7 +649,8 @@ int mac_ul_logical_channel_prioritization_test2()
mac.new_grant_ul(cc_idx, mac_grant, &ul_action);
// print generated PDU
mac_log->info_hex(ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)\n", mac_grant.tb.tbs);
srslog::fetch_basic_logger("MAC").info(
ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)", mac_grant.tb.tbs);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(ul_action.tb.payload, mac_grant.tb.tbs, 0x1001, true, 1, 0);
#endif
@ -693,13 +677,9 @@ int mac_ul_logical_channel_prioritization_test3()
const uint8_t tv[] = {0x24, 0x0a, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
0x04, 0x04, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03};
srslte::log_filter rlc_log("RLC");
rlc_log.set_level(srslte::LOG_LEVEL_DEBUG);
rlc_log.set_hex_limit(100000);
// dummy layers
phy_dummy phy;
rlc_dummy rlc(&rlc_log);
rlc_dummy rlc;
rrc_dummy rrc;
stack_dummy stack;
@ -755,7 +735,8 @@ int mac_ul_logical_channel_prioritization_test3()
mac.new_grant_ul(cc_idx, mac_grant, &ul_action);
// print generated PDU
mac_log->info_hex(ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)\n", mac_grant.tb.tbs);
srslog::fetch_basic_logger("MAC").info(
ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)", mac_grant.tb.tbs);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(ul_action.tb.payload, mac_grant.tb.tbs, 0x1001, true, 1, 0);
#endif
@ -777,13 +758,9 @@ int mac_ul_logical_channel_prioritization_test4()
const uint8_t tv2[] = {0x3d, 0x04, 0x88, 0x04}; // Short BSR plus SDU for LCID4
const uint8_t tv3[] = {0x1e, 0x00, 0x12, 0x00}; // Long BSR
srslte::log_filter rlc_log("RLC");
rlc_log.set_level(srslte::LOG_LEVEL_DEBUG);
rlc_log.set_hex_limit(100000);
// dummy layers
phy_dummy phy;
rlc_dummy rlc(&rlc_log);
rlc_dummy rlc;
rrc_dummy rrc;
stack_dummy stack;
@ -844,7 +821,8 @@ int mac_ul_logical_channel_prioritization_test4()
mac.new_grant_ul(cc_idx, mac_grant, &ul_action);
// print generated PDU
mac_log->info_hex(ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)\n", mac_grant.tb.tbs);
srslog::fetch_basic_logger("MAC").info(
ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)", mac_grant.tb.tbs);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(ul_action.tb.payload, mac_grant.tb.tbs, 0x1001, true, 1, 0);
#endif
@ -874,7 +852,8 @@ int mac_ul_logical_channel_prioritization_test4()
mac.new_grant_ul(cc_idx, mac_grant, &ul_action);
// print generated PDU
mac_log->info_hex(ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)\n", mac_grant.tb.tbs);
srslog::fetch_basic_logger("MAC").info(
ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)", mac_grant.tb.tbs);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(ul_action.tb.payload, mac_grant.tb.tbs, 0x1001, true, 1, 0);
#endif
@ -906,7 +885,8 @@ int mac_ul_logical_channel_prioritization_test4()
mac.new_grant_ul(cc_idx, mac_grant, &ul_action);
// print generated PDU
mac_log->info_hex(ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)\n", mac_grant.tb.tbs);
srslog::fetch_basic_logger("MAC").info(
ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)", mac_grant.tb.tbs);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(ul_action.tb.payload, mac_grant.tb.tbs, 0x1001, true, 1, 0);
#endif
@ -926,13 +906,9 @@ int mac_ul_sch_pdu_with_short_bsr_test()
{
const uint8_t tv[] = {0x3f, 0x3d, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01};
srslte::log_filter rlc_log("RLC");
rlc_log.set_level(srslte::LOG_LEVEL_DEBUG);
rlc_log.set_hex_limit(100000);
// dummy layers
phy_dummy phy;
rlc_dummy rlc(&rlc_log);
rlc_dummy rlc;
rrc_dummy rrc;
stack_dummy stack;
@ -966,7 +942,8 @@ int mac_ul_sch_pdu_with_short_bsr_test()
mac.new_grant_ul(cc_idx, mac_grant, &ul_action);
// print generated PDU
mac_log->info_hex(ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)\n", mac_grant.tb.tbs);
srslog::fetch_basic_logger("MAC").info(
ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)", mac_grant.tb.tbs);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(ul_action.tb.payload, mac_grant.tb.tbs, 0x1001, true, 1, 0);
#endif
@ -986,13 +963,9 @@ int mac_ul_sch_pdu_with_short_bsr_zero_test()
{
const uint8_t tv[] = {0x3f, 0x3d, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01};
srslte::log_filter rlc_log("RLC");
rlc_log.set_level(srslte::LOG_LEVEL_DEBUG);
rlc_log.set_hex_limit(100000);
// dummy layers
phy_dummy phy;
rlc_dummy rlc(&rlc_log);
rlc_dummy rlc;
rrc_dummy rrc;
stack_dummy stack;
@ -1026,7 +999,8 @@ int mac_ul_sch_pdu_with_short_bsr_zero_test()
mac.new_grant_ul(cc_idx, mac_grant, &ul_action);
// print generated PDU
mac_log->info_hex(ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)\n", mac_grant.tb.tbs);
srslog::fetch_basic_logger("MAC").info(
ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)", mac_grant.tb.tbs);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(ul_action.tb.payload, mac_grant.tb.tbs, 0x1001, true, 1, 0);
#endif
@ -1045,13 +1019,9 @@ int mac_ul_sch_pdu_with_short_bsr_zero_test()
// Because there is no outstanding data, all LCGs are reported as zero
int mac_ul_sch_pdu_with_padding_long_bsr_test()
{
srslte::log_filter rlc_log("RLC");
rlc_log.set_level(srslte::LOG_LEVEL_DEBUG);
rlc_log.set_hex_limit(100000);
// dummy layers
phy_dummy phy;
rlc_dummy rlc(&rlc_log);
rlc_dummy rlc;
rrc_dummy rrc;
stack_dummy stack;
@ -1079,7 +1049,8 @@ int mac_ul_sch_pdu_with_padding_long_bsr_test()
mac.new_grant_ul(cc_idx, mac_grant, &ul_action);
// print generated PDU
mac_log->info_hex(ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)\n", mac_grant.tb.tbs);
srslog::fetch_basic_logger("MAC").info(
ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)", mac_grant.tb.tbs);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(ul_action.tb.payload, mac_grant.tb.tbs, 0x1001, true, 1, 0);
#endif
@ -1097,13 +1068,9 @@ int mac_ul_sch_pdu_with_padding_long_bsr_test()
// PDU SDU and Long BSR as padding (indicating that more data is ready to be sent)
int mac_ul_sch_pdu_with_padding_long_bsr_test2()
{
srslte::log_filter rlc_log("RLC");
rlc_log.set_level(srslte::LOG_LEVEL_DEBUG);
rlc_log.set_hex_limit(100000);
// dummy layers
phy_dummy phy;
rlc_dummy rlc(&rlc_log);
rlc_dummy rlc;
rrc_dummy rrc;
stack_dummy stack;
@ -1154,7 +1121,8 @@ int mac_ul_sch_pdu_with_padding_long_bsr_test2()
mac.new_grant_ul(cc_idx, mac_grant, &ul_action);
// print generated PDU
mac_log->info_hex(ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)\n", mac_grant.tb.tbs);
srslog::fetch_basic_logger("MAC").info(
ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)", mac_grant.tb.tbs);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(ul_action.tb.payload, mac_grant.tb.tbs, 0x1001, true, 1, 0);
#endif
@ -1173,13 +1141,9 @@ int mac_ul_sch_pdu_with_padding_long_bsr_test2()
// LCG 1 has highest priority and 100 B to transmit
int mac_ul_sch_pdu_with_padding_trunc_bsr_test()
{
srslte::log_filter rlc_log("RLC");
rlc_log.set_level(srslte::LOG_LEVEL_DEBUG);
rlc_log.set_hex_limit(100000);
// dummy layers
phy_dummy phy;
rlc_dummy rlc(&rlc_log);
rlc_dummy rlc;
rrc_dummy rrc;
stack_dummy stack;
@ -1239,7 +1203,8 @@ int mac_ul_sch_pdu_with_padding_trunc_bsr_test()
mac.new_grant_ul(cc_idx, mac_grant, &ul_action);
// print generated PDU
mac_log->info_hex(ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)\n", mac_grant.tb.tbs);
srslog::fetch_basic_logger("MAC").info(
ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)", mac_grant.tb.tbs);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(ul_action.tb.payload, mac_grant.tb.tbs, 0x1001, true, 1, 0);
#endif
@ -1261,13 +1226,9 @@ int mac_ul_sch_regular_bsr_retx_test()
const uint8_t tv2[] = {0x01, 0x01, 0x01, 0x01, 0x01}; // Second PDU is just SDU for LCID1
const uint8_t tv3[] = {0x3f, 0x1e, 0x04, 0x00, 0x1f}; // 3rd PDU is after retx Timer is expired and contains BSR again
srslte::log_filter rlc_log("RLC");
rlc_log.set_level(srslte::LOG_LEVEL_DEBUG);
rlc_log.set_hex_limit(100000);
// dummy layers
phy_dummy phy;
rlc_dummy rlc(&rlc_log);
rlc_dummy rlc;
rrc_dummy rrc;
stack_dummy stack;
@ -1325,7 +1286,8 @@ int mac_ul_sch_regular_bsr_retx_test()
mac.new_grant_ul(cc_idx, mac_grant, &ul_action);
// print generated PDU
mac_log->info_hex(ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)\n", mac_grant.tb.tbs);
srslog::fetch_basic_logger("MAC").info(
ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)", mac_grant.tb.tbs);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(ul_action.tb.payload, mac_grant.tb.tbs, 0x1001, true, 1, 0);
#endif
@ -1352,7 +1314,8 @@ int mac_ul_sch_regular_bsr_retx_test()
mac.new_grant_ul(cc_idx, mac_grant, &ul_action);
// print generated PDU
mac_log->info_hex(ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)\n", mac_grant.tb.tbs);
srslog::fetch_basic_logger("MAC").info(
ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)", mac_grant.tb.tbs);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(ul_action.tb.payload, mac_grant.tb.tbs, 0x1001, true, 1, 0);
#endif
@ -1382,7 +1345,8 @@ int mac_ul_sch_regular_bsr_retx_test()
mac.new_grant_ul(cc_idx, mac_grant, &ul_action);
// print generated PDU
mac_log->info_hex(ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)\n", mac_grant.tb.tbs);
srslog::fetch_basic_logger("MAC").info(
ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)", mac_grant.tb.tbs);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(ul_action.tb.payload, mac_grant.tb.tbs, 0x1001, true, 1, 0);
#endif
@ -1423,14 +1387,9 @@ int mac_ul_sch_periodic_bsr_test()
// 4th PDU contains LCID 1 and LCID 3 SDUs
const uint8_t tv4[] = {0x21, 0x05, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x03};
srslte::log_filter rlc_log("RLC");
rlc_log.set_level(srslte::LOG_LEVEL_DEBUG);
rlc_log.set_hex_limit(100000);
// dummy layers
phy_dummy phy;
rlc_dummy rlc(&rlc_log);
rlc_dummy rlc;
rrc_dummy rrc;
stack_dummy stack;
@ -1494,7 +1453,8 @@ int mac_ul_sch_periodic_bsr_test()
mac.new_grant_ul(cc_idx, mac_grant, &ul_action);
// print generated PDU
mac_log->info_hex(ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)\n", mac_grant.tb.tbs);
srslog::fetch_basic_logger("MAC").info(
ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)", mac_grant.tb.tbs);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(ul_action.tb.payload, mac_grant.tb.tbs, 0x1001, true, 1, 0);
#endif
@ -1530,7 +1490,8 @@ int mac_ul_sch_periodic_bsr_test()
mac.new_grant_ul(cc_idx, mac_grant, &ul_action);
// print generated PDU
mac_log->info_hex(ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)\n", mac_grant.tb.tbs);
srslog::fetch_basic_logger("MAC").info(
ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)", mac_grant.tb.tbs);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(ul_action.tb.payload, mac_grant.tb.tbs, 0x1001, true, 1, 0);
#endif
@ -1561,7 +1522,8 @@ int mac_ul_sch_periodic_bsr_test()
mac.new_grant_ul(cc_idx, mac_grant, &ul_action);
// print generated PDU
mac_log->info_hex(ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)\n", mac_grant.tb.tbs);
srslog::fetch_basic_logger("MAC").info(
ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)", mac_grant.tb.tbs);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(ul_action.tb.payload, mac_grant.tb.tbs, 0x1001, true, 1, 0);
#endif
@ -1596,7 +1558,8 @@ int mac_ul_sch_periodic_bsr_test()
mac.new_grant_ul(cc_idx, mac_grant, &ul_action);
// print generated PDU
mac_log->info_hex(ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)\n", mac_grant.tb.tbs);
srslog::fetch_basic_logger("MAC").info(
ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)", mac_grant.tb.tbs);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(ul_action.tb.payload, mac_grant.tb.tbs, 0x1001, true, 1, 0);
#endif
@ -1629,7 +1592,8 @@ int mac_ul_sch_periodic_bsr_test()
mac.new_grant_ul(cc_idx, mac_grant, &ul_action);
// print generated PDU
mac_log->info_hex(ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)\n", mac_grant.tb.tbs);
srslog::fetch_basic_logger("MAC").info(
ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)", mac_grant.tb.tbs);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(ul_action.tb.payload, mac_grant.tb.tbs, 0x1001, true, 1, 0);
#endif
@ -1658,7 +1622,8 @@ int mac_ul_sch_periodic_bsr_test()
mac.new_grant_ul(cc_idx, mac_grant, &ul_action);
// print generated PDU
mac_log->info_hex(ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)\n", mac_grant.tb.tbs);
srslog::fetch_basic_logger("MAC").info(
ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)", mac_grant.tb.tbs);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(ul_action.tb.payload, mac_grant.tb.tbs, 0x1001, true, 1, 0);
#endif
@ -1694,13 +1659,9 @@ int mac_ul_sch_trunc_bsr_test2()
// Following PDU includes only SDUs for highest priority LCID
const uint8_t tv2[] = {0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01};
srslte::log_filter rlc_log("RLC");
rlc_log.set_level(srslte::LOG_LEVEL_DEBUG);
rlc_log.set_hex_limit(100000);
// dummy layers
phy_dummy phy;
rlc_dummy rlc(&rlc_log);
rlc_dummy rlc;
rrc_dummy rrc;
stack_dummy stack;
@ -1765,7 +1726,8 @@ int mac_ul_sch_trunc_bsr_test2()
mac.new_grant_ul(cc_idx, mac_grant, &ul_action);
// print generated PDU
mac_log->info_hex(ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)\n", mac_grant.tb.tbs);
srslog::fetch_basic_logger("MAC").info(
ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)", mac_grant.tb.tbs);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(ul_action.tb.payload, mac_grant.tb.tbs, 0x1001, true, 1, 0);
#endif
@ -1794,7 +1756,8 @@ int mac_ul_sch_trunc_bsr_test2()
mac.new_grant_ul(cc_idx, mac_grant, &ul_action);
// print generated PDU
mac_log->info_hex(ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)\n", mac_grant.tb.tbs);
srslog::fetch_basic_logger("MAC").info(
ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)", mac_grant.tb.tbs);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(ul_action.tb.payload, mac_grant.tb.tbs, 0x1001, true, 1, 0);
#endif
@ -1825,7 +1788,8 @@ int mac_ul_sch_trunc_bsr_test2()
mac.new_grant_ul(cc_idx, mac_grant, &ul_action);
// print generated PDU
mac_log->info_hex(ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)\n", mac_grant.tb.tbs);
srslog::fetch_basic_logger("MAC").info(
ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)", mac_grant.tb.tbs);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(ul_action.tb.payload, mac_grant.tb.tbs, 0x1001, true, 1, 0);
#endif
@ -1845,13 +1809,9 @@ int mac_ul_sch_pdu_one_byte_test()
{
const uint8_t tv[] = {0x1f};
srslte::log_filter rlc_log("RLC");
rlc_log.set_level(srslte::LOG_LEVEL_DEBUG);
rlc_log.set_hex_limit(100000);
// dummy layers
phy_dummy phy;
rlc_dummy rlc(&rlc_log);
rlc_dummy rlc;
rrc_dummy rrc;
stack_dummy stack;
@ -1880,7 +1840,8 @@ int mac_ul_sch_pdu_one_byte_test()
mac.new_grant_ul(cc_idx, mac_grant, &ul_action);
// print generated PDU
mac_log->info_hex(ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)\n", mac_grant.tb.tbs);
srslog::fetch_basic_logger("MAC").info(
ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)", mac_grant.tb.tbs);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(ul_action.tb.payload, mac_grant.tb.tbs, 0x1001, true, 1, 0);
#endif
@ -1900,13 +1861,9 @@ int mac_ul_sch_pdu_two_byte_test()
{
const uint8_t tv[] = {0x01, 0x01};
srslte::log_filter rlc_log("RLC");
rlc_log.set_level(srslte::LOG_LEVEL_DEBUG);
rlc_log.set_hex_limit(100000);
// dummy layers
phy_dummy phy;
rlc_dummy rlc(&rlc_log);
rlc_dummy rlc;
rrc_dummy rrc;
stack_dummy stack;
@ -1935,7 +1892,8 @@ int mac_ul_sch_pdu_two_byte_test()
mac.new_grant_ul(cc_idx, mac_grant, &ul_action);
// print generated PDU
mac_log->info_hex(ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)\n", mac_grant.tb.tbs);
srslog::fetch_basic_logger("MAC").info(
ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)", mac_grant.tb.tbs);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(ul_action.tb.payload, mac_grant.tb.tbs, 0x1001, true, 1, 0);
#endif
@ -1955,13 +1913,9 @@ int mac_ul_sch_pdu_three_byte_test()
{
const uint8_t tv[] = {0x3f, 0x01, 0x01};
srslte::log_filter rlc_log("RLC");
rlc_log.set_level(srslte::LOG_LEVEL_DEBUG);
rlc_log.set_hex_limit(100000);
// dummy layers
phy_dummy phy;
rlc_dummy rlc(&rlc_log);
rlc_dummy rlc;
rrc_dummy rrc;
stack_dummy stack;
@ -1990,7 +1944,8 @@ int mac_ul_sch_pdu_three_byte_test()
mac.new_grant_ul(cc_idx, mac_grant, &ul_action);
// print generated PDU
mac_log->info_hex(ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)\n", mac_grant.tb.tbs);
srslog::fetch_basic_logger("MAC").info(
ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)", mac_grant.tb.tbs);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(ul_action.tb.payload, mac_grant.tb.tbs, 0x1001, true, 1, 0);
#endif
@ -2186,18 +2141,9 @@ int mac_random_access_test()
{
uint64_t contention_id = 0xf0f0f0f0f0f;
srslte::log_filter phy_log("PHY");
phy_log.set_level(srslte::LOG_LEVEL_DEBUG);
phy_log.set_hex_limit(100000);
srslte::log_filter rlc_log("RLC");
rlc_log.set_level(srslte::LOG_LEVEL_DEBUG);
rlc_log.set_hex_limit(100000);
// dummy layers
phy_dummy phy;
phy.set_log(&phy_log);
rlc_dummy rlc(&rlc_log);
phy_dummy phy;
rlc_dummy rlc;
rrc_dummy rrc;
stack_dummy stack;
@ -2251,7 +2197,7 @@ int mac_random_access_test()
// Test 1: No RAR is received.
// According to end of 5.1.5, UE sends up to preamb_trans_max upon which indicates RA problem to higher layers
mac_log->info("\n=========== Test %d =============\n", test_id++);
srslog::fetch_basic_logger("MAC").info("\n=========== Test %d =============", test_id++);
my_test.rach_cfg = rach_cfg;
my_test.nof_prachs = rach_cfg.ra_supervision_info.preamb_trans_max.to_number();
TESTASSERT(!run_mac_ra_test(my_test, &mac, &phy, &tti, &stack));
@ -2268,7 +2214,7 @@ int mac_random_access_test()
// Test 2: RAR received but no matching RAPID
// The UE receives a RAR without a matching RAPID on every RAR response window TTI.
// According to 5.1.5, the RA procedure is considered non successful and tries again
mac_log->info("\n=========== Test %d =============\n", test_id++);
srslog::fetch_basic_logger("MAC").info("\n=========== Test %d =============", test_id++);
my_test.rar_nof_rapid = 1;
my_test.nof_prachs = 1;
my_test.rar_nof_invalid_rapid = rach_cfg.ra_supervision_info.ra_resp_win_size.to_number();
@ -2277,7 +2223,7 @@ int mac_random_access_test()
// Test 3: RAR with valid RAPID. Test Msg3 retransmissions
// On each HARQ retx, contention resolution timer must be restarted (5.1.5)
// When max-HARQ-msg3-retx, contention not successful
mac_log->info("\n=========== Test %d =============\n", test_id++);
srslog::fetch_basic_logger("MAC").info("\n=========== Test %d =============", test_id++);
my_test.rar_nof_invalid_rapid = 0;
my_test.nof_msg3_retx = rach_cfg.max_harq_msg3_tx;
TESTASSERT(!run_mac_ra_test(my_test, &mac, &phy, &tti, &stack));
@ -2296,12 +2242,12 @@ int mac_random_access_test()
// Test 4: RAR with valid RAPID. Msg3 transmitted, Msg4 received but invalid ConRes
// Contention resolution is defined in 5.1.5. If ConResID does not match, the ConRes is considered
// not successful and tries again
mac_log->info("\n=========== Test %d =============\n", test_id++);
srslog::fetch_basic_logger("MAC").info("\n=========== Test %d =============", test_id++);
my_test.msg4_enable = true;
TESTASSERT(!run_mac_ra_test(my_test, &mac, &phy, &tti, &stack));
// Test 5: Msg4 received and valid ConRes. In this case a valid ConResID is received and RA procedure is successful
mac_log->info("\n=========== Test %d =============\n", test_id++);
srslog::fetch_basic_logger("MAC").info("\n=========== Test %d =============", test_id++);
my_test.temp_rnti++; // Temporal C-RNTI has to change to avoid duplicate
my_test.msg4_valid_conres = true;
my_test.check_ra_successful = true;
@ -2317,7 +2263,7 @@ int mac_random_access_test()
// or wait until BSR-reTX is triggered
rlc.write_sdu(1, 100);
phy.set_crnti(0);
mac_log->info("\n=========== Test %d =============\n", test_id++);
srslog::fetch_basic_logger("MAC").info("\n=========== Test %d =============", test_id++);
my_test.crnti = my_test.temp_rnti;
my_test.temp_rnti++; // Temporal C-RNTI has to change to avoid duplicate
my_test.assume_prach_transmitted = -1;
@ -2328,7 +2274,7 @@ int mac_random_access_test()
// It is similar to Test 5 because C-RNTI is available to the UE when start the RA but
// In this case we will let the procedure expire the Contention Resolution window and make sure
// and RRC HO fail signal is sent to RRC.
mac_log->info("\n=========== Test %d =============\n", test_id++);
srslog::fetch_basic_logger("MAC").info("\n=========== Test %d =============", test_id++);
rrc.ho_finish_successful = false;
phy.set_prach_tti(tti + phy.prach_delay);
phy.set_crnti(0);
@ -2346,7 +2292,7 @@ int mac_random_access_test()
TESTASSERT(rrc.rach_problem == 2);
// Test 8: Test Contention based Random Access. Same as above but we let the procedure finish successfully.
mac_log->info("\n=========== Test %d =============\n", test_id++);
srslog::fetch_basic_logger("MAC").info("\n=========== Test %d =============", test_id++);
rrc.ho_finish_successful = false;
// Reset queue to make sure BSR retriggers a SR
rlc.reset_queues();
@ -2367,7 +2313,7 @@ int mac_random_access_test()
// Test 9: Test non-Contention based HO. Used in HO but preamble is given by the network. In addition to checking
// that the given preamble is correctly passed to the PHY, in this case there is no contention.
// In this first test, no RAR is received and RA procedure fails
mac_log->info("\n=========== Test %d =============\n", test_id++);
srslog::fetch_basic_logger("MAC").info("\n=========== Test %d =============", test_id++);
rrc.ho_finish_successful = false;
// Reset queue to make sure BSR retriggers a SR
my_test.preamble_idx = 3;
@ -2388,7 +2334,7 @@ int mac_random_access_test()
// Test 10: Test non-Contention based HO. Used in HO but preamble is given by the network. We check that
// the procedure is considered successful without waiting for contention
mac_log->info("\n=========== Test %d =============\n", test_id++);
srslog::fetch_basic_logger("MAC").info("\n=========== Test %d =============", test_id++);
my_test.preamble_idx = 3;
mac.set_rach_ded_cfg(my_test.preamble_idx, 0);
stack.run_pending_tasks();
@ -2418,8 +2364,23 @@ int main(int argc, char** argv)
pcap_handle->open("mac_test.pcap");
#endif
mac_log->set_level(srslte::LOG_LEVEL_DEBUG);
mac_log->set_hex_limit(100000);
auto& mac_logger = srslog::fetch_basic_logger("MAC");
mac_logger.set_level(srslog::basic_levels::debug);
mac_logger.set_hex_dump_max_size(100000);
auto& rlc_logger = srslog::fetch_basic_logger("RLC", false);
rlc_logger.set_level(srslog::basic_levels::debug);
rlc_logger.set_hex_dump_max_size(100000);
auto& phy_logger = srslog::fetch_basic_logger("PHY", false);
phy_logger.set_level(srslog::basic_levels::none);
phy_logger.set_hex_dump_max_size(100000);
srslog::init();
srslte::log_filter rlc_log("RLC");
rlc_log.set_level(srslte::LOG_LEVEL_DEBUG);
rlc_log.set_hex_limit(100000);
srslte::log_filter mac_log("MAC");
mac_log.set_level(srslte::LOG_LEVEL_DEBUG);
mac_log.set_hex_limit(100000);
TESTASSERT(mac_unpack_test() == SRSLTE_SUCCESS);
TESTASSERT(mac_ul_sch_pdu_test1() == SRSLTE_SUCCESS);
@ -2437,7 +2398,9 @@ int main(int argc, char** argv)
TESTASSERT(mac_ul_sch_pdu_one_byte_test() == SRSLTE_SUCCESS);
TESTASSERT(mac_ul_sch_pdu_two_byte_test() == SRSLTE_SUCCESS);
TESTASSERT(mac_ul_sch_pdu_three_byte_test() == SRSLTE_SUCCESS);
phy_logger.set_level(srslog::basic_levels::debug);
TESTASSERT(mac_random_access_test() == SRSLTE_SUCCESS);
phy_logger.set_level(srslog::basic_levels::none);
return SRSLTE_SUCCESS;
}

@ -10,6 +10,7 @@
*
*/
#include "srslte/srslog/srslog.h"
#include <boost/program_options.hpp>
#include <boost/program_options/parsers.hpp>
#include <iostream>
@ -111,20 +112,20 @@ public:
for (uint32_t i = 0; i < cell_base.nof_ports; i++) {
signal_buffer[i] = srslte_vec_cf_malloc(SRSLTE_SF_LEN_PRB(cell_base.nof_prb));
if (!signal_buffer[i]) {
ERROR("Error allocating buffer\n");
ERROR("Error allocating buffer");
}
}
if (srslte_enb_dl_init(&enb_dl, signal_buffer, cell.nof_prb)) {
ERROR("Error initiating eNb downlink\n");
ERROR("Error initiating eNb downlink");
}
if (srslte_enb_dl_set_cell(&enb_dl, cell)) {
ERROR("Error setting eNb DL cell\n");
ERROR("Error setting eNb DL cell");
}
if (srslte_enb_dl_add_rnti(&enb_dl, serving_cell_pdsch_rnti)) {
ERROR("Error adding RNTI\n");
ERROR("Error adding RNTI");
}
}
@ -145,19 +146,19 @@ public:
// Put PDSCH only if it is required
if (dci && dci_cfg && softbuffer_tx && data_tx) {
if (srslte_enb_dl_put_pdcch_dl(&enb_dl, dci_cfg, dci)) {
ERROR("Error putting PDCCH sf_idx=%d\n", dl_sf->tti);
ERROR("Error putting PDCCH sf_idx=%d", dl_sf->tti);
ret = SRSLTE_ERROR;
}
// Create pdsch config
srslte_pdsch_cfg_t pdsch_cfg;
if (srslte_ra_dl_dci_to_grant(&enb_dl.cell, dl_sf, serving_cell_pdsch_tm, false, dci, &pdsch_cfg.grant)) {
ERROR("Computing DL grant sf_idx=%d\n", dl_sf->tti);
ERROR("Computing DL grant sf_idx=%d", dl_sf->tti);
ret = SRSLTE_ERROR;
}
char str[512];
srslte_dci_dl_info(dci, str, 512);
INFO("eNb PDCCH: rnti=0x%x, %s\n", serving_cell_pdsch_rnti, str);
INFO("eNb PDCCH: rnti=0x%x, %s", serving_cell_pdsch_rnti, str);
for (uint32_t i = 0; i < SRSLTE_MAX_CODEWORDS; i++) {
pdsch_cfg.softbuffers.tx[i] = softbuffer_tx[i];
@ -171,11 +172,11 @@ public:
pdsch_cfg.meas_time_en = false;
if (srslte_enb_dl_put_pdsch(&enb_dl, &pdsch_cfg, data_tx) < 0) {
ERROR("Error putting PDSCH sf_idx=%d\n", dl_sf->tti);
ERROR("Error putting PDSCH sf_idx=%d", dl_sf->tti);
ret = SRSLTE_ERROR;
}
srslte_pdsch_tx_info(&pdsch_cfg, str, 512);
INFO("eNb PDSCH: rnti=0x%x, %s\n", serving_cell_pdsch_rnti, str);
INFO("eNb PDSCH: rnti=0x%x, %s", serving_cell_pdsch_rnti, str);
}
srslte_enb_dl_gen_signal(&enb_dl);
@ -400,12 +401,14 @@ int main(int argc, char** argv)
}
// Common for simulation and over-the-air
srslog::basic_logger& logger = srslog::fetch_basic_logger("intra_measure");
srslog::init();
cf_t* baseband_buffer = srslte_vec_cf_malloc(SRSLTE_SF_LEN_MAX);
srslte::rf_timestamp_t ts = {};
srsue::scell::intra_measure intra_measure;
srslte::log_filter logger("intra_measure");
srsue::scell::intra_measure intra_measure(logger);
meas_itf_listener rrc;
srsue::phy_common common;
srsue::phy_common common(logger);
// Simulation only
std::vector<std::unique_ptr<test_enb> > test_enb_v;
@ -447,16 +450,16 @@ int main(int argc, char** argv)
const size_t nof_bytes = (6144 * 16 * 3 / 8);
softbuffer_tx[i] = (srslte_softbuffer_tx_t*)calloc(sizeof(srslte_softbuffer_tx_t), 1);
if (!softbuffer_tx[i]) {
ERROR("Error allocating softbuffer_tx\n");
ERROR("Error allocating softbuffer_tx");
}
if (srslte_softbuffer_tx_init(softbuffer_tx[i], cell_base.nof_prb)) {
ERROR("Error initiating softbuffer_tx\n");
ERROR("Error initiating softbuffer_tx");
}
data_tx[i] = srslte_vec_u8_malloc(nof_bytes);
if (!data_tx[i]) {
ERROR("Error allocating data tx\n");
ERROR("Error allocating data tx");
} else {
for (uint32_t j = 0; j < nof_bytes; j++) {
data_tx[i][j] = (uint8_t)srslte_random_uniform_int_dist(random_gen, 0, 255);
@ -473,9 +476,9 @@ int main(int argc, char** argv)
uint32_t serving_cell_id = *pcis_to_simulate.begin();
cell_base.id = serving_cell_id;
logger.set_level(intra_meas_log_level);
logger.set_level(srslog::str_to_basic_level(intra_meas_log_level));
intra_measure.init(0, &common, &rrc, &logger);
intra_measure.init(0, &common, &rrc);
intra_measure.set_primary_cell(SRSLTE_MAX(earfcn_dl, 0), cell_base);
if (earfcn_dl >= 0) {
@ -513,7 +516,7 @@ int main(int argc, char** argv)
srslte::channel::args_t channel_args;
channel_args.enable = (channel_period_s != 0);
channel_args.hst_enable = std::isnormal(channel_hst_fd_hz);
channel_args.hst_init_time_s = channel_init_time_s;
channel_args.hst_init_time_s = channel_init_time_s;
channel_args.hst_period_s = (float)channel_period_s;
channel_args.hst_fd_hz = channel_hst_fd_hz;
channel_args.delay_enable = std::isnormal(channel_delay_max_us);
@ -625,7 +628,7 @@ int main(int argc, char** argv)
dci.tb[i].cw_idx = i;
}
} else {
ERROR("Wrong transmission mode (%d)\n", serving_cell_pdsch_tm);
ERROR("Wrong transmission mode (%d)", serving_cell_pdsch_tm);
}
enb->work(&sf_cfg_dl, &dci_cfg, &dci, softbuffer_tx, data_tx, baseband_buffer, ts);
} else {
@ -676,6 +679,8 @@ int main(int argc, char** argv)
}
}
srslog::flush();
if (ret && radio == nullptr) {
printf("Error\n");
} else {

@ -37,7 +37,7 @@ public:
expired = (cvar.wait_until(lock, expire_time) == std::cv_status::timeout); \
} \
if (expired) { \
log_h.debug("Expired " #NAME " waiting\n"); \
logger.debug("Expired " #NAME " waiting"); \
} \
return received_##NAME; \
} \
@ -49,7 +49,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; \
}
@ -60,7 +60,7 @@ private:
class dummy_stack final : public srsue::stack_interface_phy_lte
{
private:
srslte::log_filter log_h;
srslog::basic_logger& logger;
uint16_t rnti = 0x3c;
std::mutex mutex;
std::condition_variable cvar;
@ -78,9 +78,9 @@ private:
public:
// Local test access methods
explicit dummy_stack(srslte::logger& logger) : log_h("stack", &logger) {}
dummy_stack() : logger(srslog::fetch_basic_logger("stack", false)) {}
void set_rnti(uint16_t rnti_) { rnti = rnti_; }
void set_loglevel(std::string& str) { log_h.set_level(str); }
void set_loglevel(std::string& str) { logger.set_level(srslog::str_to_basic_level(str)); }
void in_sync() override { notify_in_sync(); }
void out_of_sync() override { notify_out_of_sync(); }
@ -88,8 +88,7 @@ private:
{
for (auto& m : meas) {
notify_new_phy_meas();
log_h.info(
"New measurement earfcn=%d; pci=%d; rsrp=%+.1fdBm; rsrq=%+.1fdB;\n", m.earfcn, m.pci, m.rsrp, m.rsrq);
logger.info("New measurement earfcn=%d; pci=%d; rsrp=%+.1fdBm; rsrq=%+.1fdB;", m.earfcn, m.pci, m.rsrp, m.rsrq);
}
}
uint16_t get_dl_sched_rnti(uint32_t tti) override { return rnti; }
@ -110,7 +109,7 @@ private:
void run_tti(const uint32_t tti, const uint32_t tti_jump) override
{
notify_run_tti();
log_h.debug("Run TTI %d\n", tti);
logger.debug("Run TTI %d", tti);
}
void cell_search_complete(cell_search_ret_t ret, srsue::phy_cell_t found_cell) override
@ -143,7 +142,7 @@ private:
class dummy_radio : public srslte::radio_interface_phy
{
private:
srslte::log_filter log_h;
srslog::basic_logger& logger;
std::vector<srslte_ringbuffer_t> ring_buffers;
float base_srate = 0.0f;
float tx_srate = 0.0f;
@ -164,10 +163,8 @@ private:
CALLBACK(late)
public:
dummy_radio(srslte::logger& logger, uint32_t nof_channels, float base_srate_) :
log_h("radio", &logger),
ring_buffers(nof_channels),
base_srate(base_srate_)
dummy_radio(uint32_t nof_channels, float base_srate_) :
logger(srslog::fetch_basic_logger("radio", false)), ring_buffers(nof_channels), base_srate(base_srate_)
{
// Create Ring buffers
for (auto& rb : ring_buffers) {
@ -199,7 +196,7 @@ private:
}
}
void set_loglevel(std::string& str) { log_h.set_level(str); }
void set_loglevel(std::string& str) { logger.set_level(srslog::str_to_basic_level(str)); }
void write_ring_buffers(cf_t** buffer, uint32_t nsamples)
{
@ -207,7 +204,7 @@ private:
int ret = SRSLTE_SUCCESS;
do {
if (ret != SRSLTE_SUCCESS) {
log_h.error("Ring buffer write failed (full). Trying again.\n");
logger.error("Ring buffer write failed (full). Trying again.");
}
ret = srslte_ringbuffer_write_timed(&ring_buffers[i], buffer[i], (uint32_t)sizeof(cf_t) * nsamples, 1000);
} while (ret == SRSLTE_ERROR_TIMEOUT);
@ -251,9 +248,9 @@ private:
// Read base srate samples
int ret = srslte_ringbuffer_read(&ring_buffers[i], buf_ptr, (uint32_t)sizeof(cf_t) * base_nsamples);
if (ret < 0) {
log_h.error("Reading ring buffer\n");
logger.error("Reading ring buffer");
} else {
log_h.debug("-- %d samples read from ring buffer\n", base_nsamples);
logger.debug("-- %d samples read from ring buffer", base_nsamples);
}
// Only if baseband buffer is provided
@ -292,43 +289,43 @@ private:
{
std::unique_lock<std::mutex> lock(mutex);
tx_freq = (float)freq;
log_h.info("Set Tx freq to %+.0f MHz.\n", freq * 1.0e-6);
logger.info("Set Tx freq to %+.0f MHz.", freq * 1.0e-6);
}
void set_rx_freq(const uint32_t& channel_idx, const double& freq) override
{
std::unique_lock<std::mutex> lock(mutex);
rx_freq = (float)freq;
log_h.info("Set Rx freq to %+.0f MHz.\n", freq * 1.0e-6);
logger.info("Set Rx freq to %+.0f MHz.", freq * 1.0e-6);
}
void set_rx_gain_th(const float& gain) override
{
std::unique_lock<std::mutex> lock(mutex);
rx_gain = srslte_convert_dB_to_amplitude(gain);
log_h.info("Set Rx gain-th to %+.1f dB (%.6f).\n", gain, rx_gain);
logger.info("Set Rx gain-th to %+.1f dB (%.6f).", gain, rx_gain);
}
void set_tx_gain(const float& gain) override
{
std::unique_lock<std::mutex> lock(mutex);
rx_gain = srslte_convert_dB_to_amplitude(gain);
log_h.info("Set Tx gain to %+.1f dB (%.6f).\n", gain, rx_gain);
logger.info("Set Tx gain to %+.1f dB (%.6f).", gain, rx_gain);
}
void set_rx_gain(const float& gain) override
{
std::unique_lock<std::mutex> lock(mutex);
rx_gain = srslte_convert_dB_to_amplitude(gain);
log_h.info("Set Rx gain to %+.1f dB (%.6f).\n", gain, rx_gain);
logger.info("Set Rx gain to %+.1f dB (%.6f).", gain, rx_gain);
}
void set_tx_srate(const double& srate) override
{
std::unique_lock<std::mutex> lock(mutex);
tx_srate = (float)srate;
log_h.info("Set Tx sampling rate to %+.3f MHz.\n", srate * 1.0e-6);
logger.info("Set Tx sampling rate to %+.3f MHz.", srate * 1.0e-6);
}
void set_rx_srate(const double& srate) override
{
std::unique_lock<std::mutex> lock(mutex);
rx_srate = (float)srate;
log_h.info("Set Rx sampling rate to %+.3f MHz.\n", srate * 1.0e-6);
logger.info("Set Rx sampling rate to %+.3f MHz.", srate * 1.0e-6);
}
void set_channel_rx_offset(uint32_t ch, int32_t offset_samples) override{};
float get_rx_gain() override
@ -345,7 +342,7 @@ private:
};
// Common instances
srslte::log_filter log_h;
srslog::basic_logger& logger;
// Dummy instances
dummy_stack stack;
@ -368,16 +365,15 @@ private:
public:
phy_test_bench(const srsue::phy_args_t& phy_args, const srslte_cell_t& cell, srslte::logger& logger_) :
stack(logger_),
radio(logger_, cell.nof_ports, srslte_sampling_freq_hz(cell.nof_prb)),
radio(cell.nof_ports, srslte_sampling_freq_hz(cell.nof_prb)),
thread("phy_test_bench"),
log_h("test bench")
logger(srslog::fetch_basic_logger("test bench", false))
{
// Deduce physical attributes
sf_len = SRSLTE_SF_LEN_PRB(cell.nof_prb);
// Initialise UE
phy = std::unique_ptr<srsue::phy>(new srsue::phy(&logger_));
phy = std::unique_ptr<srsue::phy>(new srsue::phy(&logger_, srslog::get_default_sink()));
phy->init(phy_args, &stack, &radio);
// Initialise DL baseband buffers
@ -430,7 +426,7 @@ public:
// Free run DL
do {
log_h.debug("-- generating DL baseband SFN=%" PRId64 " TTI=%d;\n", sfn, dl_sf_cfg.tti);
logger.debug("-- generating DL baseband SFN=%" PRId64 " TTI=%d;", sfn, dl_sf_cfg.tti);
// Create empty resource grid with basic signals
srslte_enb_dl_put_base(&enb_dl, &dl_sf_cfg);
@ -480,7 +476,7 @@ public:
void set_loglevel(std::string str)
{
log_h.set_level(str);
logger.set_level(srslog::str_to_basic_level(str));
radio.set_loglevel(str);
stack.set_loglevel(str);
}
@ -506,15 +502,7 @@ int main(int argc, char** argv)
phy_args.log.phy_level = "info";
// 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);
srslte::srslog_wrapper log_wrapper(srslog::fetch_log_channel("main_channel"));
// Start the log backend.
srslog::init();

@ -35,7 +35,7 @@ public:
} cell_t;
typedef std::vector<cell_t> cell_list_t;
lte_ttcn3_phy(srslte::logger* logger_);
lte_ttcn3_phy();
~lte_ttcn3_phy() = default;
int init(const phy_args_t& args_, stack_interface_phy_lte* stack_, syssim_interface_phy* syssim_);
@ -103,8 +103,7 @@ public:
void run_tti();
private:
srslte::logger* logger = nullptr;
srslte::log_filter log;
srslog::basic_logger& logger;
// All available cells
cell_list_t cells;

@ -16,7 +16,7 @@
#include "srslte/srslog/sink.h"
/// A custom sink implementation that allows hot swapping file sinks so that loggers can write to different files
/// dynamically.
/// dynamically or other stream-like sinks like stdout.
class swappable_sink : public srslog::sink
{
public:
@ -38,6 +38,13 @@ public:
s = &srslog::fetch_file_sink(filename);
}
/// Swaps the current sink to use the stdout sink.
void swap_to_stdout()
{
srslog::flush();
s = &srslog::fetch_stdout_sink();
}
private:
srslog::sink* s;
};

@ -27,27 +27,28 @@ using namespace srslte;
class ttcn3_drb_interface : public ttcn3_port_handler
{
public:
ttcn3_drb_interface() : pool(byte_buffer_pool::get_instance()) {}
explicit ttcn3_drb_interface(srslog::basic_logger& logger) :
ttcn3_port_handler(logger), pool(byte_buffer_pool::get_instance())
{}
~ttcn3_drb_interface() = default;
int init(ss_srb_interface* syssim_, srslte::log* log_, std::string net_ip_, uint32_t net_port_)
int init(ss_srb_interface* syssim_, std::string net_ip_, uint32_t net_port_)
{
syssim = syssim_;
log = log_;
net_ip = net_ip_;
net_port = net_port_;
initialized = true;
log->debug("Initialized.\n");
logger.debug("Initialized.");
return port_listen();
}
void tx(const uint8_t* buffer, uint32_t len)
{
if (initialized) {
log->info_hex(buffer, len, "Sending %d B to Titan\n", len);
logger.info(buffer, len, "Sending %d B to Titan", len);
send(buffer, len);
} else {
log->error("Trying to transmit but port not connected.\n");
logger.error("Trying to transmit but port not connected.");
}
}
@ -55,7 +56,7 @@ private:
///< Main message handler
int handle_message(const unique_byte_array_t& rx_buf, const uint32_t n)
{
log->debug_hex(rx_buf->begin(), n, "Received %d B from remote.\n", n);
logger.debug(rx_buf->begin(), n, "Received %d B from remote.", n);
// Chop incoming msg, first two bytes are length of the JSON
// (see IPL4_EUTRA_SYSTEM_Definitions.ttcn
@ -67,7 +68,7 @@ private:
Document document;
if (document.Parse((char*)&rx_buf->at(2)).HasParseError() || document.IsObject() == false) {
log->error_hex((uint8*)&rx_buf->at(2), json_len, "Error parsing incoming data.\n");
logger.error((uint8*)&rx_buf->at(2), json_len, "Error parsing incoming data.");
return SRSLTE_ERROR;
}
@ -75,7 +76,7 @@ private:
StringBuffer buffer;
PrettyWriter<StringBuffer> writer(buffer);
document.Accept(writer);
log->info("Received JSON with %d B\n%s\n", json_len, (char*)buffer.GetString());
logger.info("Received JSON with %d B\n%s", json_len, (char*)buffer.GetString());
// check for common
assert(document.HasMember("Common"));
@ -106,9 +107,9 @@ private:
handle_sdu(document, lcid, octstr.data(), octstr.size(), ttcn3_helpers::get_follow_on_flag(document));
}
} else if ((*itr)["PduSduList"].HasMember("MacPdu")) {
log->warning("Not handling MacPdu type.");
logger.warning("Not handling MacPdu type.");
} else {
log->warning("Not handling this PduSdu type.\n");
logger.warning("Not handling this PduSdu type.");
}
}
@ -117,7 +118,7 @@ private:
void handle_sdu(Document& document, const uint16_t lcid, const uint8_t* payload, const uint16_t len, bool follow_on)
{
log->info_hex(payload, len, "Received DRB PDU (lcid=%d)\n", lcid);
logger.info(payload, len, "Received DRB PDU (lcid=%d)", lcid);
// pack into byte buffer
unique_byte_buffer_t pdu = pool_allocate_blocking;

@ -25,16 +25,15 @@ using namespace rapidjson;
class ttcn3_ip_ctrl_interface : public ttcn3_port_handler
{
public:
ttcn3_ip_ctrl_interface() = default;
explicit ttcn3_ip_ctrl_interface(srslog::basic_logger& logger) : ttcn3_port_handler(logger) {}
~ttcn3_ip_ctrl_interface() = default;
int init(srslte::log* log_, std::string net_ip_, uint32_t net_port_)
int init(std::string net_ip_, uint32_t net_port_)
{
net_ip = net_ip_;
net_port = net_port_;
log = log_;
initialized = true;
log->debug("Initialized.\n");
logger.debug("Initialized.");
return port_listen();
}
@ -42,11 +41,11 @@ private:
///< Main message handler
int handle_message(const unique_byte_array_t& rx_buf, const uint32_t n)
{
log->debug("Received %d B from remote.\n", n);
logger.debug("Received %d B from remote.", n);
Document document;
if (document.Parse((char*)rx_buf->begin()).HasParseError() || document.IsObject() == false) {
log->error_hex(rx_buf->begin(), n, "Error parsing incoming data.\n");
logger.error(rx_buf->begin(), n, "Error parsing incoming data.");
return SRSLTE_ERROR;
}
@ -54,14 +53,14 @@ private:
StringBuffer buffer;
PrettyWriter<StringBuffer> writer(buffer);
document.Accept(writer);
log->info("Received %d bytes\n%s\n", n, (char*)buffer.GetString());
logger.info("Received %d bytes\n%s", n, (char*)buffer.GetString());
// Get message
if (document.HasMember("RoutingInfo")) {
log->info("Received RoutingInfo\n");
logger.info("Received RoutingInfo");
handle_routing_info(document);
} else {
log->error("Received unknown request.\n");
logger.error("Received unknown request.");
}
return SRSLTE_SUCCESS;
@ -86,7 +85,7 @@ private:
std::string resp = ttcn3_helpers::get_drbmux_common_ind_cnf();
log->info("Sending %s to tester (%zd B)\n", resp.c_str(), resp.length());
logger.info("Sending %s to tester (%zd B)", resp.c_str(), resp.length());
send((const uint8_t*)resp.c_str(), resp.length());
}
};

@ -19,16 +19,15 @@
class ttcn3_ip_sock_interface : public ttcn3_port_handler
{
public:
ttcn3_ip_sock_interface() = default;
explicit ttcn3_ip_sock_interface(srslog::basic_logger& logger) : ttcn3_port_handler(logger) {}
~ttcn3_ip_sock_interface() = default;
int init(srslte::log* log_, std::string net_ip_, uint32_t net_port_)
int init(std::string net_ip_, uint32_t net_port_)
{
net_ip = net_ip_;
net_port = net_port_;
log = log_;
initialized = true;
log->debug("Initialized.\n");
logger.debug("Initialized.");
return port_listen();
}
@ -36,11 +35,11 @@ private:
///< Main message handler
int handle_message(const unique_byte_array_t& rx_buf, const uint32_t n)
{
log->debug("Received %d B from remote.\n", n);
logger.debug("Received %d B from remote.", n);
Document document;
if (document.Parse((char*)rx_buf->begin()).HasParseError() || document.IsObject() == false) {
log->error_hex(rx_buf->begin(), n, "Error parsing incoming data.\n");
logger.error(rx_buf->begin(), n, "Error parsing incoming data.");
return SRSLTE_ERROR;
}
@ -48,14 +47,14 @@ private:
StringBuffer buffer;
PrettyWriter<StringBuffer> writer(buffer);
document.Accept(writer);
log->info("Received %d bytes\n%s\n", n, (char*)buffer.GetString());
logger.info("Received %d bytes\n%s", n, (char*)buffer.GetString());
// Get message
if (document.HasMember("CTRL")) {
log->info("Received CTRL command.\n");
logger.info("Received CTRL command.");
handle_ctrl(document);
} else {
log->error("Received unknown request.\n");
logger.error("Received unknown request.");
}
return SRSLTE_SUCCESS;
@ -102,7 +101,7 @@ private:
// Send response
if (resp.length() > 0) {
log->info("Sending %s to tester (%zd B)\n", resp.c_str(), resp.length());
logger.info("Sending %s to tester (%zd B)", resp.c_str(), resp.length());
send((const uint8_t*)resp.c_str(), resp.length());
}
}

@ -20,6 +20,7 @@
#include "srslte/common/epoll_helper.h"
#include "srslte/common/log.h"
#include "srslte/srslog/srslog.h"
#include "ttcn3_common.h"
#include <arpa/inet.h>
#include <fcntl.h>
@ -28,7 +29,9 @@
class ttcn3_port_handler : public epoll_handler
{
public:
ttcn3_port_handler() : rx_buf(unique_byte_array_t(new byte_array_t)) {}
explicit ttcn3_port_handler(srslog::basic_logger& logger) :
logger(logger), rx_buf(unique_byte_array_t(new byte_array_t))
{}
virtual ~ttcn3_port_handler() {}
virtual int handle_message(const unique_byte_array_t& rx_buf, const uint32_t n) = 0;
@ -42,9 +45,9 @@ public:
int rd_sz =
sctp_recvmsg(fd, rx_buf->begin(), RX_BUF_SIZE, (struct sockaddr*)&client_addr, &fromlen, &sri, &msg_flags);
if (rd_sz == -1 && errno != EAGAIN) {
log->error("Error reading from SCTP socket: %s", strerror(errno));
logger.error("Error reading from SCTP socket: %s", strerror(errno));
} else if (rd_sz == -1 && errno == EAGAIN) {
log->debug("Socket timeout reached");
logger.debug("Socket timeout reached");
} else {
if (msg_flags & MSG_NOTIFICATION) {
// Received notification
@ -96,8 +99,8 @@ public:
break;
}
log->debug(
"SCTP_ASSOC_CHANGE notif: state: %s, error code: %d, out streams: %d, in streams: %d, assoc id: %d\n",
logger.debug(
"SCTP_ASSOC_CHANGE notif: state: %s, error code: %d, out streams: %d, in streams: %d, assoc id: %d",
state,
n->sac_error,
n->sac_outbound_streams,
@ -112,12 +115,12 @@ public:
return SRSLTE_ERROR;
}
struct sctp_shutdown_event* n = &notif->sn_shutdown_event;
log->debug("SCTP_SHUTDOWN_EVENT notif: assoc id: %d\n", n->sse_assoc_id);
logger.debug("SCTP_SHUTDOWN_EVENT notif: assoc id: %d", n->sse_assoc_id);
break;
}
default:
log->warning("Unhandled notification type %d\n", notif->sn_header.sn_type);
logger.warning("Unhandled notification type %d", notif->sn_header.sn_type);
break;
}
@ -128,7 +131,7 @@ public:
void send(const uint8_t* buffer, const uint32_t len)
{
if (sendto(sock_fd, buffer, len, 0, (struct sockaddr*)&client_addr, sizeof(client_addr)) == -1) {
log->error("Error sending message to tester.\n");
logger.error("Error sending message to tester.");
}
}
@ -185,7 +188,7 @@ public:
ret = bind(sock_fd, (struct sockaddr*)&bind_addr, sizeof(bind_addr));
if (ret != 0) {
close(sock_fd);
log->error("Error binding SCTP socket\n");
logger.error("Error binding SCTP socket");
srslte::console("Error binding SCTP socket\n");
return SRSLTE_ERROR;
}
@ -194,7 +197,7 @@ public:
ret = listen(sock_fd, SOMAXCONN);
if (ret != SRSLTE_SUCCESS) {
close(sock_fd);
log->error("Error in SCTP socket listen\n");
logger.error("Error in SCTP socket listen");
srslte::console("Error in SCTP socket listen\n");
return SRSLTE_ERROR;
}
@ -203,13 +206,13 @@ public:
return sock_fd;
}
bool initialized = false;
std::string net_ip = "0.0.0.0";
uint32_t net_port = 0;
int sock_fd = -1;
struct sockaddr client_addr = {};
srslte::log* log = nullptr;
unique_byte_array_t rx_buf; ///< Receive buffer for this port
bool initialized = false;
std::string net_ip = "0.0.0.0";
uint32_t net_port = 0;
int sock_fd = -1;
struct sockaddr client_addr = {};
srslog::basic_logger& logger;
unique_byte_array_t rx_buf; ///< Receive buffer for this port
};
#endif // SRSUE_TTCN3_PORT_HANDLER_H

@ -26,27 +26,28 @@ using namespace srslte;
class ttcn3_srb_interface : public ttcn3_port_handler
{
public:
ttcn3_srb_interface() : pool(byte_buffer_pool::get_instance()) {}
explicit ttcn3_srb_interface(srslog::basic_logger& logger) :
ttcn3_port_handler(logger), pool(byte_buffer_pool::get_instance())
{}
~ttcn3_srb_interface() = default;
int init(ss_srb_interface* syssim_, srslte::log* log_, std::string net_ip_, uint32_t net_port_)
int init(ss_srb_interface* syssim_, std::string net_ip_, uint32_t net_port_)
{
syssim = syssim_;
log = log_;
net_ip = net_ip_;
net_port = net_port_;
syssim = syssim_;
net_ip = net_ip_;
net_port = net_port_;
initialized = true;
log->debug("Initialized.\n");
logger.debug("Initialized.");
return port_listen();
}
void tx(const uint8_t* buffer, uint32_t len)
{
if (initialized) {
log->info_hex(buffer, len, "Sending %d B to Titan\n", len);
logger.info(buffer, len, "Sending %d B to Titan", len);
send(buffer, len);
} else {
log->error("Trying to transmit but port not connected.\n");
logger.error("Trying to transmit but port not connected.");
}
}
@ -54,7 +55,7 @@ private:
///< Main message handler
int handle_message(const unique_byte_array_t& rx_buf, const uint32_t n)
{
log->debug_hex(rx_buf->begin(), n, "Received %d B from remote.\n", n);
logger.debug(rx_buf->begin(), n, "Received %d B from remote.", n);
// Chop incoming msg, first two bytes are length of the JSON
// (see IPL4_EUTRA_SYSTEM_Definitions.ttcn
@ -66,7 +67,7 @@ private:
Document document;
if (document.Parse((char*)&rx_buf->at(2)).HasParseError() || document.IsObject() == false) {
log->error_hex((uint8*)&rx_buf->at(2), json_len, "Error parsing incoming data.\n");
logger.error((uint8*)&rx_buf->at(2), json_len, "Error parsing incoming data.");
return SRSLTE_ERROR;
}
@ -74,7 +75,7 @@ private:
StringBuffer buffer;
PrettyWriter<StringBuffer> writer(buffer);
document.Accept(writer);
log->info("Received JSON with %d B\n%s\n", json_len, (char*)buffer.GetString());
logger.info("Received JSON with %d B\n%s", json_len, (char*)buffer.GetString());
// check for common
assert(document.HasMember("Common"));
@ -92,9 +93,10 @@ private:
} else if (rrcpdu.HasMember("Dcch")) {
rx_buf_offset += 2;
uint32_t lcid = document["Common"]["RoutingInfo"]["RadioBearerId"]["Srb"].GetInt();
handle_dcch_pdu(document, lcid, &rx_buf->at(rx_buf_offset), n - rx_buf_offset, ttcn3_helpers::get_follow_on_flag(document));
handle_dcch_pdu(
document, lcid, &rx_buf->at(rx_buf_offset), n - rx_buf_offset, ttcn3_helpers::get_follow_on_flag(document));
} else {
log->error("Received unknown request.\n");
logger.error("Received unknown request.");
}
return SRSLTE_SUCCESS;
@ -103,7 +105,7 @@ private:
// Todo: move to SYSSIM
void handle_ccch_pdu(Document& document, const uint8_t* payload, const uint16_t len)
{
log->info_hex(payload, len, "Received CCCH RRC PDU\n");
logger.info(payload, len, "Received CCCH RRC PDU");
// pack into byte buffer
unique_byte_buffer_t pdu = pool_allocate_blocking;
@ -123,7 +125,7 @@ private:
void
handle_dcch_pdu(Document& document, const uint16_t lcid, const uint8_t* payload, const uint16_t len, bool follow_on)
{
log->info_hex(payload, len, "Received DCCH RRC PDU (lcid=%d)\n", lcid);
logger.info(payload, len, "Received DCCH RRC PDU (lcid=%d)", lcid);
// pack into byte buffer
unique_byte_buffer_t pdu = pool_allocate_blocking;

@ -24,17 +24,16 @@ using namespace srslte;
class ttcn3_sys_interface : public ttcn3_port_handler
{
public:
ttcn3_sys_interface(){};
explicit ttcn3_sys_interface(srslog::basic_logger& logger) : ttcn3_port_handler(logger) {}
~ttcn3_sys_interface(){};
int init(ss_sys_interface* syssim_, srslte::log* log_, std::string net_ip_, uint32_t net_port_)
int init(ss_sys_interface* syssim_, std::string net_ip_, uint32_t net_port_)
{
syssim = syssim_;
net_ip = net_ip_;
net_port = net_port_;
log = log_;
initialized = true;
log->debug("Initialized.\n");
logger.debug("Initialized.");
pool = byte_buffer_pool::get_instance();
return port_listen();
}
@ -43,7 +42,7 @@ private:
///< Main message handler
int handle_message(const unique_byte_array_t& rx_buf, const uint32_t n)
{
log->debug("Received %d B from remote.\n", n);
logger.debug("Received %d B from remote.", n);
// Chop incoming msg, first two bytes are length of the JSON
// (see IPL4_EUTRA_SYSTEM_Definitions.ttcn
@ -60,7 +59,7 @@ private:
Document document;
if (document.Parse(json).HasParseError() || document.IsObject() == false) {
log->error_hex((uint8*)json, json_len, "Error parsing incoming data.\n");
logger.error((uint8*)json, json_len, "Error parsing incoming data.");
return SRSLTE_ERROR;
}
@ -68,7 +67,7 @@ private:
StringBuffer buffer;
PrettyWriter<StringBuffer> writer(buffer);
document.Accept(writer);
log->info_long("Received %d bytes\n%s\n", json_len, (char*)buffer.GetString());
logger.info("Received %d bytes\n%s", json_len, (char*)buffer.GetString());
// check for common
assert(document.HasMember("Common"));
@ -81,34 +80,34 @@ private:
// Get request type
const Value& request = document["Request"];
if (request.HasMember("Cell")) {
log->info("Received Cell request.\n");
logger.info("Received Cell request.");
handle_request_cell(document, &rx_buf->at(rx_buf_offset), n - rx_buf_offset);
} else if (request.HasMember("L1MacIndCtrl")) {
log->info("Received L1MacIndCtrl request.\n");
logger.info("Received L1MacIndCtrl request.");
handle_request_l1_mac_ind_ctrl(document);
} else if (request.HasMember("RadioBearerList")) {
log->info("Received RadioBearerList request.\n");
logger.info("Received RadioBearerList request.");
handle_request_radio_bearer_list(document);
} else if (request.HasMember("CellAttenuationList")) {
log->info("Received CellAttenuationList request.\n");
logger.info("Received CellAttenuationList request.");
handle_request_cell_attenuation_list(document);
} else if (request.HasMember("PdcpCount")) {
log->info("Received PdcpCount request.\n");
logger.info("Received PdcpCount request.");
handle_request_pdcp_count(document);
} else if (request.HasMember("AS_Security")) {
log->info("Received AS_Security request.\n");
logger.info("Received AS_Security request.");
handle_request_as_security(document);
} else if (request.HasMember("EnquireTiming")) {
log->info("Received EnquireTiming request.\n");
logger.info("Received EnquireTiming request.");
handle_request_enquire_timing(document);
} else if (request.HasMember("Paging")) {
log->info("Received Paging request.\n");
logger.info("Received Paging request.");
handle_request_paging(document, &rx_buf->at(rx_buf_offset), n - rx_buf_offset);
} else if (request.HasMember("PdcpHandoverControl")) {
log->info("Received PdcpHandoverControl.\n");
logger.info("Received PdcpHandoverControl.");
handle_request_pdcp_handover_control(document);
} else {
log->error("Received unknown request.\n");
logger.error("Received unknown request.");
}
return SRSLTE_SUCCESS;
@ -155,7 +154,7 @@ private:
(strcmp(phy_dl_config["Phich"]["PhichConfig"]["R8"]["phich_Resource"].GetString(), "one") == 0)
? SRSLTE_PHICH_R_1
: SRSLTE_PHICH_R_1_6;
log->info("DL EARFCN is %d with n_prb=%d\n", cell.earfcn, cell.phy_cell.nof_prb);
logger.info("DL EARFCN is %d with n_prb=%d", cell.earfcn, cell.phy_cell.nof_prb);
const Value& ref_power =
document["Request"]["Cell"]["AddOrReconfigure"]["Basic"]["InitialCellPower"]["MaxReferencePower"];
@ -183,7 +182,7 @@ private:
// Now configure cell
syssim->set_cell_config(ttcn3_helpers::get_timing_info(document), cell);
log->info("Configuring attenuation of %s to %.2f dB\n", cell_name.GetString(), cell.attenuation);
logger.info("Configuring attenuation of %s to %.2f dB", cell_name.GetString(), cell.attenuation);
syssim->set_cell_attenuation(ttcn3_helpers::get_timing_info(document), cell_name.GetString(), cell.attenuation);
}
@ -200,7 +199,7 @@ private:
sib->N_bytes = tb_len;
// Push to main component
log->info_hex(sib->msg, sib->N_bytes, "Received BCCH DL-SCH for %s\n", cell_name.GetString());
logger.info(sib->msg, sib->N_bytes, "Received BCCH DL-SCH for %s", cell_name.GetString());
syssim->add_bcch_dlsch_pdu(cell_name.GetString(), std::move(sib));
consumed_bytes = payload_ptr - payload;
@ -210,7 +209,7 @@ private:
// Create response for template car_CellConfig_CNF(CellId_Type p_CellId)
std::string resp = ttcn3_helpers::get_basic_sys_req_cnf(cell_name.GetString(), "Cell");
log->info("Sending %s to tester (%zd B)\n", resp.c_str(), resp.length());
logger.info("Sending %s to tester (%zd B)", resp.c_str(), resp.length());
send((const uint8_t*)resp.c_str(), resp.length());
}
}
@ -232,10 +231,10 @@ private:
if (ttcn3_helpers::requires_confirm(document)) {
std::string resp = ttcn3_helpers::get_basic_sys_req_cnf(cell_id, "Cell");
log->info("Sending %s to tester (%zd B)\n", resp.c_str(), resp.length());
logger.info("Sending %s to tester (%zd B)", resp.c_str(), resp.length());
send((const uint8_t*)resp.c_str(), resp.length());
} else {
log->info("Skipping response for request cell active message.\n");
logger.info("Skipping response for request cell active message.");
}
}
@ -314,7 +313,7 @@ private:
handle_request_cell_active(document, payload, len);
}
} else if (document["Request"]["Cell"].HasMember("Release")) {
log->info("Received cell release command\n");
logger.info("Received cell release command");
// do nothing more
}
}
@ -340,13 +339,13 @@ private:
if (mac_ind_ctrl.HasMember("HarqError")) {
assert(mac_ind_ctrl["HarqError"].IsString());
bool harq_error = (strcmp(mac_ind_ctrl["HarqError"].GetString(), "enable") == 0) ? true : false;
log->info("Setting HarqError to %s\n", harq_error ? "True" : "False");
logger.info("Setting HarqError to %s", harq_error ? "True" : "False");
}
if (ttcn3_helpers::requires_confirm(document)) {
std::string resp = ttcn3_helpers::get_basic_sys_req_cnf(cell_id.GetString(), "L1MacIndCtrl");
log->info("Sending %s to tester (%zd B)\n", resp.c_str(), resp.length());
logger.info("Sending %s to tester (%zd B)", resp.c_str(), resp.length());
send((const uint8_t*)resp.c_str(), resp.length());
}
}
@ -385,11 +384,11 @@ private:
const Value& dlcid = aor["Mac"]["TestMode"]["Info"]["DiffLogChId"];
assert(dlcid.HasMember("LogChId"));
force_lcid = dlcid["LogChId"].GetInt();
log->info("TestMode: lcid overridden: %d\n", force_lcid);
logger.info("TestMode: lcid overridden: %d", force_lcid);
syssim->set_forced_lcid(force_lcid);
} else {
// Unset override function to use different lcid
log->info("TestMode: lcid reset\n");
logger.info("TestMode: lcid reset");
syssim->set_forced_lcid(-1);
}
if (lcid > 0) {
@ -401,10 +400,10 @@ private:
uint32_t lcid = id["Srb"].GetInt();
syssim->del_srb(ttcn3_helpers::get_timing_info(document), ttcn3_helpers::get_cell_name(document), lcid);
} else {
log->error("Unknown config.\n");
logger.error("Unknown config.");
}
} else if (id.HasMember("Drb")) {
log->info("Configure DRB%d\n", id["Drb"].GetInt());
logger.info("Configure DRB%d", id["Drb"].GetInt());
const Value& config = (*itr)["Config"];
if (config.HasMember("AddOrReconfigure")) {
@ -421,7 +420,7 @@ private:
uint32_t lcid = id["Drb"].GetInt() + 2;
syssim->del_drb(ttcn3_helpers::get_timing_info(document), ttcn3_helpers::get_cell_name(document), lcid);
} else {
log->error("Unknown config.\n");
logger.error("Unknown config.");
}
}
}
@ -429,10 +428,10 @@ private:
if (ttcn3_helpers::requires_confirm(document)) {
std::string resp = ttcn3_helpers::get_basic_sys_req_cnf(cell_id.GetString(), "RadioBearerList");
log->info("Sending %s to tester (%zd B)\n", resp.c_str(), resp.length());
logger.info("Sending %s to tester (%zd B)", resp.c_str(), resp.length());
send((const uint8_t*)resp.c_str(), resp.length());
} else {
log->info("Skipping response for radio bearer list message.\n");
logger.info("Skipping response for radio bearer list message.");
}
}
@ -475,13 +474,13 @@ private:
}
}
log->info("Configuring attenuation of %s to %.2f dB\n", id.GetString(), att_value);
logger.info("Configuring attenuation of %s to %.2f dB", id.GetString(), att_value);
syssim->set_cell_attenuation(ttcn3_helpers::get_timing_info(document), id.GetString(), att_value);
}
std::string resp = ttcn3_helpers::get_basic_sys_req_cnf(cell_id.GetString(), "CellAttenuationList");
log->info("Sending %s to tester (%zd B)\n", resp.c_str(), resp.length());
logger.info("Sending %s to tester (%zd B)", resp.c_str(), resp.length());
send((const uint8_t*)resp.c_str(), resp.length());
}
@ -510,7 +509,7 @@ private:
std::string resp = ttcn3_helpers::get_pdcp_count_response(
cell_id.GetString(), syssim->get_pdcp_count(ttcn3_helpers::get_cell_name(document)));
log->info("Sending %s to tester (%zd B)\n", resp.c_str(), resp.length());
logger.info("Sending %s to tester (%zd B)", resp.c_str(), resp.length());
send((const uint8_t*)resp.c_str(), resp.length());
}
@ -546,13 +545,13 @@ private:
} else if (int_algo_string == "eia2") {
integ_algo = srslte::INTEGRITY_ALGORITHM_ID_128_EIA2;
} else {
log->error("Unsupported integrity algorithm %s\n", int_algo_string.c_str());
logger.error("Unsupported integrity algorithm %s", int_algo_string.c_str());
}
// get integrity key
std::string integ_key_string = as_sec["StartRestart"]["Integrity"]["KRRCint"].GetString();
std::array<uint8_t, 32> k_rrc_int = get_key_from_string(integ_key_string);
log->debug_hex(k_rrc_int.data(), k_rrc_int.size(), "K_rrc_int");
logger.debug(k_rrc_int.data(), k_rrc_int.size(), "K_rrc_int");
// get enc algo
srslte::CIPHERING_ALGORITHM_ID_ENUM cipher_algo = {};
@ -564,18 +563,18 @@ private:
} else if (cipher_algo_string == "eea2") {
cipher_algo = srslte::CIPHERING_ALGORITHM_ID_128_EEA2;
} else {
log->error("Unsupported ciphering algorithm %s\n", cipher_algo_string.c_str());
logger.error("Unsupported ciphering algorithm %s", cipher_algo_string.c_str());
}
// get cipher key
std::string cipher_key_string = as_sec["StartRestart"]["Ciphering"]["KRRCenc"].GetString();
std::array<uint8_t, 32> k_rrc_enc = get_key_from_string(cipher_key_string);
log->debug_hex(k_rrc_enc.data(), k_rrc_enc.size(), "K_rrc_enc");
logger.debug(k_rrc_enc.data(), k_rrc_enc.size(), "K_rrc_enc");
// get UP enc key
std::string up_enc_key_string = as_sec["StartRestart"]["Ciphering"]["KUPenc"].GetString();
std::array<uint8_t, 32> k_up_enc = get_key_from_string(up_enc_key_string);
log->debug_hex(k_up_enc.data(), k_up_enc.size(), "K_UP_enc");
logger.debug(k_up_enc.data(), k_up_enc.size(), "K_UP_enc");
// parse ActTimeList
ttcn3_helpers::pdcp_count_map_t bearers;
@ -628,10 +627,10 @@ private:
if (config_flag.GetBool() == true) {
std::string resp = ttcn3_helpers::get_basic_sys_req_cnf(cell_id.GetString(), "AS_Security");
log->info("Sending %s to tester (%zd B)\n", resp.c_str(), resp.length());
logger.info("Sending %s to tester (%zd B)", resp.c_str(), resp.length());
send((const uint8_t*)resp.c_str(), resp.length());
} else {
log->info("Skipping response for AS_Security message.\n");
logger.info("Skipping response for AS_Security message.");
}
}
@ -666,7 +665,7 @@ private:
std::string resp =
ttcn3_helpers::get_sys_req_cnf_with_time(cell_id.GetString(), "EnquireTiming", syssim->get_tti());
log->info("Sending %s to tester (%zd B)\n", resp.c_str(), resp.length());
logger.info("Sending %s to tester (%zd B)", resp.c_str(), resp.length());
send((const uint8_t*)resp.c_str(), resp.length());
}
@ -701,16 +700,16 @@ private:
pch->N_bytes = tb_len;
// Push to main component
log->info_hex(pch->msg, pch->N_bytes, "Received PCH DL-SCH\n");
logger.info(pch->msg, pch->N_bytes, "Received PCH DL-SCH");
syssim->add_pch_pdu(std::move(pch));
if (ttcn3_helpers::requires_confirm(document)) {
std::string resp = ttcn3_helpers::get_sys_req_cnf_with_time(cell_id.GetString(), "Paging", syssim->get_tti());
log->info("Sending %s to tester (%zd B)\n", resp.c_str(), resp.length());
logger.info("Sending %s to tester (%zd B)", resp.c_str(), resp.length());
send((const uint8_t*)resp.c_str(), resp.length());
} else {
log->info("Skipping response for Paging message.\n");
logger.info("Skipping response for Paging message.");
}
}
@ -742,7 +741,7 @@ private:
if (ttcn3_helpers::requires_confirm(document)) {
std::string resp = ttcn3_helpers::get_basic_sys_req_cnf(cell_id.GetString(), "PdcpHandoverControl");
log->info("Sending %s to tester (%zd B)\n", resp.c_str(), resp.length());
logger.info("Sending %s to tester (%zd B)", resp.c_str(), resp.length());
send((const uint8_t*)resp.c_str(), resp.length());
}
}

@ -193,6 +193,18 @@ public:
ttcn3_helpers::pdcp_count_map_t get_pdcp_count(const std::string cell_name);
private:
// Logging stuff.
srslog::basic_logger& logger;
srslog::basic_logger& ut_logger;
srslog::basic_logger& sys_logger;
srslog::basic_logger& ip_sock_logger;
srslog::basic_logger& ip_ctrl_logger;
srslog::basic_logger& srb_logger;
srslog::basic_logger& drb_logger;
srslog::basic_logger& ss_mac_logger;
srslog::basic_logger& ss_rlc_logger;
srslog::basic_logger& ss_pdcp_logger;
// SYS interface
ttcn3_ut_interface ut;
ttcn3_sys_interface sys;
@ -208,20 +220,14 @@ private:
epoll_timer_handler timer_handler;
epoll_signal_handler signal_handler;
// Logging stuff
srslte::logger& logger_stdout;
srslte::logger& logger_file;
srslte::logger* logger = nullptr;
srslte::log_ref log;
srslte::log_filter ut_log;
srslte::log_filter sys_log;
srslte::log_filter ip_sock_log;
srslte::log_filter ip_ctrl_log;
srslte::log_filter srb_log;
srslte::log_filter drb_log;
srslte::log_ref ss_mac_log{"SS-MAC"};
srslte::log_ref ss_rlc_log{"SS-RLC"};
srslte::log_ref ss_pdcp_log{"SS-PDCP"};
// Logging stuff (to be removed)
srslte::logger& logger_stdout;
srslte::logger& logger_file;
srslte::logger* old_logger = nullptr;
srslte::log_ref log;
srslte::log_ref ss_mac_log{"SS-MAC"};
srslte::log_ref ss_rlc_log{"SS-RLC"};
srslte::log_ref ss_pdcp_log{"SS-PDCP"};
all_args_t args = {};

@ -70,8 +70,8 @@ private:
std::unique_ptr<ue_stack_lte> stack;
// Generic logger members
srslte::logger* logger = nullptr;
srslte::log_filter log; // Own logger for UE
srslte::logger* old_logger = nullptr;
srslog::basic_logger& logger;
test_loop_mode_state_t test_loop_mode = TEST_LOOP_INACTIVE;
srslte::timer_handler::unique_timer pdu_delay_timer;

@ -25,13 +25,12 @@ using namespace rapidjson;
class ttcn3_ut_interface : public ttcn3_port_handler
{
public:
ttcn3_ut_interface() {}
explicit ttcn3_ut_interface(srslog::basic_logger& logger) : ttcn3_port_handler(logger) {}
~ttcn3_ut_interface(){};
int init(ss_ut_interface* syssim_, srslte::log* log_, std::string net_ip_, uint32_t net_port_)
int init(ss_ut_interface* syssim_, std::string net_ip_, uint32_t net_port_)
{
syssim = syssim_;
log = log_;
net_ip = net_ip_;
net_port = net_port_;
initialized = true;
@ -45,7 +44,7 @@ private:
{
Document document;
if (document.Parse((char*)rx_buf->begin()).HasParseError() || document.IsObject() == false) {
log->error_hex(rx_buf->begin(), n, "Error parsing incoming data.\n");
logger.error(rx_buf->begin(), n, "Error parsing incoming data.");
return SRSLTE_ERROR;
}
@ -53,7 +52,7 @@ private:
StringBuffer buffer;
PrettyWriter<StringBuffer> writer(buffer);
document.Accept(writer);
log->info("Received %d bytes\n%s\n", n, (char*)buffer.GetString());
logger.info("Received %d bytes\n%s.", n, (char*)buffer.GetString());
// check for command
assert(document.HasMember("Cmd"));
@ -77,30 +76,30 @@ private:
assert(document.HasMember("CnfRequired"));
if (strcmp(mmi_cmd.GetString(), "POWER_OFF") == 0) {
log->info("Received POWER_OFF command.\n");
logger.info("Received POWER_OFF command.");
handle_power_off(document);
} else if (strcmp(mmi_cmd.GetString(), "SWITCH_ON") == 0) {
log->info("Received SWITCH_ON command.\n");
logger.info("Received SWITCH_ON command.");
syssim->switch_on_ue();
} else if (strcmp(mmi_cmd.GetString(), "SWITCH_OFF") == 0) {
log->info("Received SWITCH_OFF command.\n");
logger.info("Received SWITCH_OFF command.");
syssim->switch_off_ue();
} else {
log->error("Received unknown command: %s\n", mmi_cmd.GetString());
logger.error("Received unknown command: %s", mmi_cmd.GetString());
}
} else if (a.HasMember("AT")) {
handle_at_command(document);
} else if (a.HasMember("TC_START")) {
log->info("Received TC_START command.\n");
logger.info("Received TC_START command.");
const Value& cmd = a["TC_START"];
assert(cmd.HasMember("Name"));
const Value& tc_name = cmd["Name"];
syssim->tc_start(tc_name.GetString());
} else if (a.HasMember("TC_END")) {
log->info("Received TC_END command.\n");
logger.info("Received TC_END command.");
syssim->tc_end();
} else {
log->error("Unknown command type.\n");
logger.error("Unknown command type.");
}
return SRSLTE_SUCCESS;
@ -120,7 +119,7 @@ private:
Writer<StringBuffer> writer(buffer);
resp.Accept(writer);
log->info("Sending %s to tester (%zd B)\n", buffer.GetString(), buffer.GetSize());
logger.info("Sending %s to tester (%zd B)", buffer.GetString(), buffer.GetSize());
send((const uint8_t*)buffer.GetString(), buffer.GetSize());
}
@ -131,13 +130,13 @@ private:
// turn off data services
if (std::string(at.GetString()) == "AT+CGATT=0<CR>") {
log->info("Disabling data services\n");
logger.info("Disabling data services");
syssim->disable_data();
} else if (std::string(at.GetString()) == "AT+CGATT=1<CR>") {
log->info("Enabling data services\n");
logger.info("Enabling data services");
syssim->enable_data();
} else {
log->error("Not handling AT command %s\n", at.GetString());
logger.error("Not handling AT command %s", at.GetString());
}
}

@ -20,7 +20,7 @@ namespace srsue {
#define SUITABLE_NEIGHBOR_INTRAFREQ_RS_EPRE (-91)
#define DEFAULT_RSRQ (-3.0)
lte_ttcn3_phy::lte_ttcn3_phy(srslte::logger* logger_) : logger(logger_) {}
lte_ttcn3_phy::lte_ttcn3_phy() : logger(srslog::fetch_basic_logger("PHY")) {}
int lte_ttcn3_phy::init(const phy_args_t& args_, stack_interface_phy_lte* stack_, syssim_interface_phy* syssim_)
{
@ -38,8 +38,8 @@ int lte_ttcn3_phy::init(const phy_args_t& args_, stack_interface_phy_lte* stack_
// ue_phy_base interface
int lte_ttcn3_phy::init(const phy_args_t& args_)
{
log.init("PHY ", logger, true);
log.set_level(args_.log.phy_level);
logger.set_level(srslog::str_to_basic_level(args_.log.phy_level));
logger.set_hex_dump_max_size(-1);
return SRSLTE_SUCCESS;
}
@ -63,29 +63,29 @@ void lte_ttcn3_phy::set_config_tdd(srslte_tdd_config_t& tdd_config) {}
void lte_ttcn3_phy::enable_pregen_signals(bool enable)
{
log.debug("%s not implemented.\n", __FUNCTION__);
logger.debug("%s not implemented.", __FUNCTION__);
}
void lte_ttcn3_phy::deactivate_scells()
{
log.debug("%s not implemented.\n", __FUNCTION__);
logger.debug("%s not implemented.", __FUNCTION__);
}
void lte_ttcn3_phy::set_activation_deactivation_scell(uint32_t cmd, uint32_t tti)
{
log.debug("%s not implemented.\n", __FUNCTION__);
logger.debug("%s not implemented.", __FUNCTION__);
}
bool lte_ttcn3_phy::set_config(srslte::phy_cfg_t config, uint32_t cc_idx_)
{
log.debug("%s not implemented.\n", __FUNCTION__);
logger.debug("%s not implemented.", __FUNCTION__);
task_sched.defer_task([this]() { stack->set_config_complete(true); });
return true;
}
bool lte_ttcn3_phy::set_scell(srslte_cell_t cell_info, uint32_t cc_idx, uint32_t earfcn)
{
log.debug("%s not implemented.\n", __FUNCTION__);
logger.debug("%s not implemented.", __FUNCTION__);
task_sched.defer_task([this]() { stack->set_scell_complete(true); });
return true;
}
@ -102,7 +102,7 @@ bool lte_ttcn3_phy::cell_search()
{
std::lock_guard<std::mutex> lock(mutex);
log.info("Running cell search in PHY\n");
logger.info("Running cell search in PHY");
rrc_interface_phy_lte::cell_search_ret_t ret = {};
ret.found = rrc_interface_phy_lte::cell_search_ret_t::CELL_NOT_FOUND;
@ -111,10 +111,10 @@ bool lte_ttcn3_phy::cell_search()
if (not cells.empty() && cell_idx < cells.size()) {
// only find suitable cells
if (cells[cell_idx].power >= SUITABLE_CELL_RS_EPRE) {
log.info("Found Cell: EARFCN=%d CellId=%d power=%.2f\n",
cells[cell_idx].earfcn,
cells[cell_idx].info.id,
cells[cell_idx].power);
logger.info("Found Cell: EARFCN=%d CellId=%d power=%.2f",
cells[cell_idx].earfcn,
cells[cell_idx].info.id,
cells[cell_idx].power);
found_cell.earfcn = cells[cell_idx].earfcn;
found_cell.pci = cells[cell_idx].info.id;
ret.found = rrc_interface_phy_lte::cell_search_ret_t::CELL_FOUND;
@ -132,7 +132,7 @@ bool lte_ttcn3_phy::cell_search()
cell_idx = 0;
}
} else {
log.warning("No cells configured yet.\n");
logger.warning("No cells configured yet.");
}
stack->cell_search_complete(ret, found_cell);
@ -149,10 +149,10 @@ bool lte_ttcn3_phy::cell_select(phy_cell_t rrc_cell)
pcell = cell;
pcell_set = true;
syssim->select_cell(pcell.info);
log.info("Select PCell with %.2f on PCI=%d on EARFCN=%d.\n", cell.power, rrc_cell.pci, rrc_cell.earfcn);
logger.info("Select PCell with %.2f on PCI=%d on EARFCN=%d.", cell.power, rrc_cell.pci, rrc_cell.earfcn);
} else {
pcell_set = false;
log.error("Power of selected cell too low (%.2f < %.2f)\n", cell.power, SUITABLE_CELL_RS_EPRE);
logger.error("Power of selected cell too low (%.2f < %.2f)", cell.power, SUITABLE_CELL_RS_EPRE);
}
stack->cell_select_complete(pcell_set);
@ -160,14 +160,14 @@ bool lte_ttcn3_phy::cell_select(phy_cell_t rrc_cell)
}
}
log.error("Couldn't find RRC cell with PCI=%d on EARFCN=%d in cell map.\n", rrc_cell.pci, rrc_cell.earfcn);
logger.error("Couldn't find RRC cell with PCI=%d on EARFCN=%d in cell map.", rrc_cell.pci, rrc_cell.earfcn);
return false;
}
bool lte_ttcn3_phy::cell_is_camping()
{
if (pcell_set) {
log.info("pcell.power=%2.f\n", pcell.power);
logger.info("pcell.power=%2.f", pcell.power);
return (pcell.power >= SUITABLE_CELL_RS_EPRE);
}
return false;
@ -178,7 +178,7 @@ bool lte_ttcn3_phy::cell_is_camping()
void lte_ttcn3_phy::prach_send(uint32_t preamble_idx, int allowed_subframe, float target_power_dbm, float ta_base_sec)
{
std::lock_guard<std::mutex> lock(mutex);
log.info("Sending PRACH with preamble %d on PCID=%d\n", preamble_idx, pcell.info.id);
logger.info("Sending PRACH with preamble %d on PCID=%d", preamble_idx, pcell.info.id);
prach_tti_tx = current_tti;
ra_trans_cnt++;
@ -218,25 +218,25 @@ int lte_ttcn3_phy::sr_last_tx_tti()
/* Sets a C-RNTI allowing the PHY to pregenerate signals if necessary */
void lte_ttcn3_phy::set_crnti(uint16_t rnti)
{
log.debug("Set Temp-RNTI=%d, pregen not used\n", rnti);
logger.debug("Set Temp-RNTI=%d, pregen not used", rnti);
}
/* Time advance commands */
void lte_ttcn3_phy::set_timeadv_rar(uint32_t ta_cmd)
{
log.debug("%s not implemented.\n", __FUNCTION__);
logger.debug("%s not implemented.", __FUNCTION__);
}
void lte_ttcn3_phy::set_timeadv(uint32_t ta_cmd)
{
log.debug("%s not implemented.\n", __FUNCTION__);
logger.debug("%s not implemented.", __FUNCTION__);
}
// Sets RAR grant payload
void lte_ttcn3_phy::set_rar_grant(uint8_t grant_payload[SRSLTE_RAR_GRANT_LEN], uint16_t rnti)
{
// Empty, SYSSIM knows when to provide UL grant for Msg3
log.debug("%s not implemented.\n", __FUNCTION__);
logger.debug("%s not implemented.", __FUNCTION__);
}
// Called from the SYSSIM to configure the current TTI
@ -256,13 +256,13 @@ uint32_t lte_ttcn3_phy::get_current_tti()
float lte_ttcn3_phy::get_phr()
{
log.debug("%s not implemented.\n", __FUNCTION__);
logger.debug("%s not implemented.", __FUNCTION__);
return 0.1;
}
float lte_ttcn3_phy::get_pathloss_db()
{
log.debug("%s not implemented.\n", __FUNCTION__);
logger.debug("%s not implemented.", __FUNCTION__);
return 85.0;
}
@ -289,7 +289,7 @@ void lte_ttcn3_phy::new_tb(const srsue::mac_interface_phy_lte::mac_grant_dl_t dl
std::lock_guard<std::mutex> lock(mutex);
if (data == nullptr) {
log.error("Invalid data buffer passed\n");
logger.error("Invalid data buffer passed");
return;
}
@ -301,15 +301,15 @@ void lte_ttcn3_phy::new_tb(const srsue::mac_interface_phy_lte::mac_grant_dl_t dl
bool dl_ack[SRSLTE_MAX_CODEWORDS] = {};
if (dl_action.tb[0].enabled && dl_action.tb[0].payload != nullptr) {
log.info_hex(data,
dl_grant.tb[0].tbs,
"TB received rnti=%d, tti=%d, n_bytes=%d\n",
dl_grant.rnti,
current_tti,
dl_grant.tb[0].tbs);
logger.info(data,
dl_grant.tb[0].tbs,
"TB received rnti=%d, tti=%d, n_bytes=%d",
dl_grant.rnti,
current_tti,
dl_grant.tb[0].tbs);
if (dl_action.generate_ack) {
log.debug("Calling generate ACK callback\n");
logger.debug("Calling generate ACK callback");
// action.generate_ack_callback(action.generate_ack_callback_arg);
}
memcpy(dl_action.tb->payload, data, dl_grant.tb[0].tbs);
@ -317,9 +317,9 @@ void lte_ttcn3_phy::new_tb(const srsue::mac_interface_phy_lte::mac_grant_dl_t dl
// ACK first TB and pass up
dl_ack[0] = true;
log.info("TB processed correctly\n");
logger.info("TB processed correctly");
} else {
log.error("Couldn't get buffer for TB\n");
logger.error("Couldn't get buffer for TB");
}
stack->tb_decoded(cc_idx, dl_grant, dl_ack);
@ -327,12 +327,12 @@ void lte_ttcn3_phy::new_tb(const srsue::mac_interface_phy_lte::mac_grant_dl_t dl
void lte_ttcn3_phy::radio_overflow()
{
log.debug("%s not implemented.\n", __FUNCTION__);
logger.debug("%s not implemented.", __FUNCTION__);
}
void lte_ttcn3_phy::radio_failure()
{
log.debug("%s not implemented.\n", __FUNCTION__);
logger.debug("%s not implemented.", __FUNCTION__);
}
// Calling function set_tti() is holding mutex
@ -343,17 +343,17 @@ void lte_ttcn3_phy::run_tti()
for (auto& cell : cells) {
if (cell.power >= NON_SUITABLE_CELL_RS_EPRE) {
phy_meas_t m = {};
m.pci = cell.info.id;
m.earfcn = cell.earfcn;
m.rsrp = cell.power;
m.rsrq = DEFAULT_RSRQ;
m.pci = cell.info.id;
m.earfcn = cell.earfcn;
m.rsrp = cell.power;
m.rsrq = DEFAULT_RSRQ;
// Measurement for PCell needs to have EARFCN set to 0
if (pcell_set && m.earfcn == pcell.earfcn && m.pci == pcell.info.id) {
log.debug("Creating Pcell measurement for PCI=%d, EARFCN=%d with RSRP=%.2f\n", m.pci, m.earfcn, m.rsrp);
logger.debug("Creating Pcell measurement for PCI=%d, EARFCN=%d with RSRP=%.2f", m.pci, m.earfcn, m.rsrp);
m.earfcn = 0;
} else {
log.debug("Create cell measurement for PCI=%d, EARFCN=%d with RSRP=%.2f\n", m.pci, m.earfcn, m.rsrp);
logger.debug("Create cell measurement for PCI=%d, EARFCN=%d with RSRP=%.2f", m.pci, m.earfcn, m.rsrp);
}
phy_meas.push_back(m);
}
@ -369,10 +369,10 @@ void lte_ttcn3_phy::run_tti()
if (cell.info.id == pcell.info.id) {
// consider Pcell in-sync until reaching threshold
if (cell.power >= NON_SUITABLE_CELL_RS_EPRE) {
log.debug("PCell id=%d power=%.2f -> sync\n", pcell.info.id, cell.power);
logger.debug("PCell id=%d power=%.2f -> sync", pcell.info.id, cell.power);
stack->in_sync();
} else {
log.debug("PCell id=%d power=%.2f -> out of sync\n", pcell.info.id, cell.power);
logger.debug("PCell id=%d power=%.2f -> out of sync", pcell.info.id, cell.power);
stack->out_of_sync();
}
break; // make sure to call stack only once
@ -380,7 +380,7 @@ void lte_ttcn3_phy::run_tti()
}
}
log.step(current_tti);
logger.set_context(current_tti);
// Check for SR
if (sr_pending) {
@ -394,7 +394,7 @@ void lte_ttcn3_phy::run_tti()
void lte_ttcn3_phy::set_cells_to_meas(uint32_t earfcn, const std::set<uint32_t>& pci)
{
log.debug("%s not implemented.\n", __FUNCTION__);
logger.debug("%s not implemented.", __FUNCTION__);
}
} // namespace srsue

@ -30,19 +30,35 @@
#include <functional>
ttcn3_syssim::ttcn3_syssim(srslte::logger& logger_file_, srslte::logger& logger_stdout_, ttcn3_ue* ue_) :
logger(srslog::fetch_basic_logger("SS")),
ut_logger(srslog::fetch_basic_logger("UT", false)),
sys_logger(srslog::fetch_basic_logger("SYS", false)),
ip_sock_logger(srslog::fetch_basic_logger("IP_S", false)),
ip_ctrl_logger(srslog::fetch_basic_logger("IP_C", false)),
srb_logger(srslog::fetch_basic_logger("SRB", false)),
drb_logger(srslog::fetch_basic_logger("DRB", false)),
ss_mac_logger(srslog::fetch_basic_logger("SS-MAC", false)),
ss_rlc_logger(srslog::fetch_basic_logger("SS-RLC", false)),
ss_pdcp_logger(srslog::fetch_basic_logger("SS-PDCP", false)),
ut(ut_logger),
sys(sys_logger),
ip_sock(ip_sock_logger),
ip_ctrl(ip_ctrl_logger),
srb(srb_logger),
drb(drb_logger),
log{"SS "},
mac_msg_ul(20, ss_mac_log),
mac_msg_dl(20, ss_mac_log),
pdus(128),
logger_stdout(logger_stdout_),
logger_file(logger_file_),
logger(&logger_file),
old_logger(&logger_file),
pool(byte_buffer_pool::get_instance()),
ue(ue_),
signal_handler(&running),
timer_handler(create_tti_timer(), [&](uint64_t res) { new_tti_indication(res); })
{
if (ue->init(all_args_t{}, logger, this, "INIT_TEST") != SRSLTE_SUCCESS) {
if (ue->init(all_args_t{}, old_logger, this, "INIT_TEST") != SRSLTE_SUCCESS) {
ue->stop();
fprintf(stderr, "Couldn't initialize UE.\n");
}
@ -56,61 +72,73 @@ int ttcn3_syssim::init(const all_args_t& args_)
// Make sure to get SS logging as well
if (args.log.filename == "stdout") {
logger = &logger_stdout;
old_logger = &logger_stdout;
auto* swp_sink = srslog::find_sink(swappable_sink::name());
if (!swp_sink) {
logger.error("Unable to find the swappable sink");
srslte::console("Unable to find the swappable sink\n");
return SRSLTE_ERROR;
}
static_cast<swappable_sink*>(swp_sink)->swap_to_stdout();
}
srslte::logmap::set_default_logger(logger);
srslte::logmap::set_default_logger(old_logger);
// init and configure logging
srslte::logmap::register_log(std::unique_ptr<srslte::log>{new log_filter{"SS ", logger, true}});
ut_log.init("UT ", logger);
sys_log.init("SYS ", logger);
ip_sock_log.init("IP_S", logger);
ip_ctrl_log.init("IP_C", logger);
srb_log.init("SRB ", logger);
drb_log.init("DRB ", logger);
srslte::logmap::register_log(std::unique_ptr<srslte::log>{new log_filter{"SS-RLC", logger}});
srslte::logmap::register_log(std::unique_ptr<srslte::log>{new log_filter{"SS-PDCP", logger}});
srslte::logmap::register_log(std::unique_ptr<srslte::log>{new log_filter{"SS ", old_logger, true}});
srslte::logmap::register_log(std::unique_ptr<srslte::log>{new log_filter{"SS-RLC", old_logger}});
srslte::logmap::register_log(std::unique_ptr<srslte::log>{new log_filter{"SS-PDCP", old_logger}});
log->set_level(args.log.all_level);
ut_log.set_level(args.log.all_level);
sys_log.set_level(args.log.all_level);
ip_sock_log.set_level(args.log.all_level);
ip_ctrl_log.set_level(args.log.all_level);
srb_log.set_level(args.log.all_level);
drb_log.set_level(args.log.all_level);
ss_mac_log->set_level(args.log.all_level);
ss_rlc_log->set_level(args.log.all_level);
ss_pdcp_log->set_level(args.log.all_level);
auto logger_lvl = srslog::str_to_basic_level(args.log.all_level);
logger.set_level(logger_lvl);
ut_logger.set_level(logger_lvl);
sys_logger.set_level(logger_lvl);
ip_sock_logger.set_level(logger_lvl);
ip_ctrl_logger.set_level(logger_lvl);
srb_logger.set_level(logger_lvl);
drb_logger.set_level(logger_lvl);
ss_mac_logger.set_level(logger_lvl);
ss_rlc_logger.set_level(logger_lvl);
ss_pdcp_logger.set_level(logger_lvl);
log->set_hex_limit(args.log.all_hex_limit);
ut_log.set_hex_limit(args.log.all_hex_limit);
sys_log.set_hex_limit(args.log.all_hex_limit);
ip_sock_log.set_hex_limit(args.log.all_hex_limit);
ip_ctrl_log.set_hex_limit(args.log.all_hex_limit);
srb_log.set_hex_limit(args.log.all_hex_limit);
drb_log.set_hex_limit(args.log.all_hex_limit);
ss_mac_log->set_hex_limit(args.log.all_hex_limit);
ss_rlc_log->set_hex_limit(args.log.all_hex_limit);
ss_pdcp_log->set_hex_limit(args.log.all_hex_limit);
logger.set_hex_dump_max_size(args.log.all_hex_limit);
ut_logger.set_hex_dump_max_size(args.log.all_hex_limit);
sys_logger.set_hex_dump_max_size(args.log.all_hex_limit);
ip_sock_logger.set_hex_dump_max_size(args.log.all_hex_limit);
ip_ctrl_logger.set_hex_dump_max_size(args.log.all_hex_limit);
srb_logger.set_hex_dump_max_size(args.log.all_hex_limit);
drb_logger.set_hex_dump_max_size(args.log.all_hex_limit);
ss_mac_logger.set_hex_dump_max_size(args.log.all_hex_limit);
ss_rlc_logger.set_hex_dump_max_size(args.log.all_hex_limit);
ss_pdcp_logger.set_hex_dump_max_size(args.log.all_hex_limit);
// Init epoll socket and add FDs
epoll_fd = epoll_create1(0);
if (epoll_fd == -1) {
log->error("Error creating epoll\n");
logger.error("Error creating epoll");
return SRSLTE_ERROR;
}
// add signalfd
signal_fd = add_signalfd();
if (add_epoll(signal_fd, epoll_fd) != SRSLTE_SUCCESS) {
log->error("Error while adding signalfd to epoll\n");
logger.error("Error while adding signalfd to epoll");
return SRSLTE_ERROR;
}
event_handler.insert({signal_fd, &signal_handler});
// init system interfaces to tester
if (add_port_handler() != SRSLTE_SUCCESS) {
log->error("Error creating port handlers\n");
logger.error("Error creating port handlers");
return SRSLTE_ERROR;
}
@ -128,54 +156,54 @@ void ttcn3_syssim::set_forced_lcid(int lcid)
int ttcn3_syssim::add_port_handler()
{
// UT port
int ut_fd = ut.init(this, &ut_log, listen_address, UT_PORT);
int ut_fd = ut.init(this, listen_address, UT_PORT);
if (add_epoll(ut_fd, epoll_fd) != SRSLTE_SUCCESS) {
log->error("Error while adding UT port to epoll\n");
logger.error("Error while adding UT port to epoll");
return SRSLTE_ERROR;
}
event_handler.insert({ut_fd, &ut});
srslte::console("UT handler listening on SCTP port %d\n", UT_PORT);
// SYS port
int sys_fd = sys.init(this, &sys_log, listen_address, SYS_PORT);
int sys_fd = sys.init(this, listen_address, SYS_PORT);
if (add_epoll(sys_fd, epoll_fd) != SRSLTE_SUCCESS) {
log->error("Error while adding SYS port to epoll\n");
logger.error("Error while adding SYS port to epoll");
return SRSLTE_ERROR;
}
event_handler.insert({sys_fd, &sys});
srslte::console("SYS handler listening on SCTP port %d\n", SYS_PORT);
// IPsock port
int ip_sock_fd = ip_sock.init(&ip_sock_log, listen_address, IPSOCK_PORT);
int ip_sock_fd = ip_sock.init(listen_address, IPSOCK_PORT);
if (add_epoll(ip_sock_fd, epoll_fd) != SRSLTE_SUCCESS) {
log->error("Error while adding IP sock port to epoll\n");
logger.error("Error while adding IP sock port to epoll");
return SRSLTE_ERROR;
}
event_handler.insert({ip_sock_fd, &ip_sock});
srslte::console("IPSOCK handler listening on SCTP port %d\n", IPSOCK_PORT);
// IPctrl port
int ip_ctrl_fd = ip_ctrl.init(&ip_ctrl_log, listen_address, IPCTRL_PORT);
int ip_ctrl_fd = ip_ctrl.init(listen_address, IPCTRL_PORT);
if (add_epoll(ip_ctrl_fd, epoll_fd) != SRSLTE_SUCCESS) {
log->error("Error while adding IP ctrl port to epoll\n");
logger.error("Error while adding IP ctrl port to epoll");
return SRSLTE_ERROR;
}
event_handler.insert({ip_ctrl_fd, &ip_ctrl});
srslte::console("IPCTRL handler listening on SCTP port %d\n", IPCTRL_PORT);
// add SRB fd
int srb_fd = srb.init(this, &srb_log, listen_address, SRB_PORT);
int srb_fd = srb.init(this, listen_address, SRB_PORT);
if (add_epoll(srb_fd, epoll_fd) != SRSLTE_SUCCESS) {
log->error("Error while adding SRB port to epoll\n");
logger.error("Error while adding SRB port to epoll");
return SRSLTE_ERROR;
}
event_handler.insert({srb_fd, &srb});
srslte::console("SRB handler listening on SCTP port %d\n", SRB_PORT);
// add DRB fd
int drb_fd = drb.init(this, &drb_log, listen_address, DRB_PORT);
int drb_fd = drb.init(this, listen_address, DRB_PORT);
if (add_epoll(drb_fd, epoll_fd) != SRSLTE_SUCCESS) {
log->error("Error while adding DRB port to epoll\n");
logger.error("Error while adding DRB port to epoll");
return SRSLTE_ERROR;
}
event_handler.insert({drb_fd, &drb});
@ -190,7 +218,8 @@ void ttcn3_syssim::new_tti_indication(uint64_t res)
tti = (tti + 1) % 10240;
log->step(tti);
log->debug("Start TTI\n");
logger.set_context(tti);
logger.debug("Start TTI");
// Make sure to step SS
step_stack();
@ -201,7 +230,7 @@ void ttcn3_syssim::new_tti_indication(uint64_t res)
// check scheduled actions for this TTI
if (tti_actions.find(tti) != tti_actions.end()) {
while (!tti_actions[tti].empty()) {
log->debug("Running scheduled action\n");
logger.debug("Running scheduled action");
move_task_t task = std::move(tti_actions[tti].front());
task();
tti_actions[tti].pop();
@ -232,7 +261,7 @@ void ttcn3_syssim::new_tti_indication(uint64_t res)
}
if (pcell_idx == -1) {
log->debug("Skipping TTI. Pcell not yet selected.\n");
logger.debug("Skipping TTI. Pcell not yet selected.");
return;
}
@ -247,7 +276,7 @@ void ttcn3_syssim::new_tti_indication(uint64_t res)
dl_grant.tb[0].tbs = cells[pcell_idx]->sibs[cells[pcell_idx]->sib_idx]->N_bytes;
dl_grant.tb[0].ndi = get_ndi_for_new_dl_tx(tti);
ue->new_tb(dl_grant, cells[pcell_idx]->sibs[cells[pcell_idx]->sib_idx]->msg);
log->info("Delivered SIB%d for pcell_idx=%d\n", cells[pcell_idx]->sib_idx, pcell_idx);
logger.info("Delivered SIB%d for pcell_idx=%d", cells[pcell_idx]->sib_idx, pcell_idx);
cells[pcell_idx]->sib_idx = (cells[pcell_idx]->sib_idx + 1) % cells[pcell_idx]->sibs.size();
} else if (SRSLTE_RNTI_ISRAR(dl_rnti)) {
if (prach_tti != -1) {
@ -257,12 +286,12 @@ void ttcn3_syssim::new_tti_indication(uint64_t res)
}
}
} else if (SRSLTE_RNTI_ISPA(dl_rnti)) {
log->debug("Searching for paging RNTI\n");
logger.debug("Searching for paging RNTI");
// PCH will be triggered from SYSSIM after receiving Paging
} else if (SRSLTE_RNTI_ISUSER(dl_rnti)) {
// check if this is for contention resolution after PRACH/RAR
if (dl_rnti == cells[pcell_idx]->config.crnti) {
log->debug("Searching for C-RNTI=0x%x\n", dl_rnti);
logger.debug("Searching for C-RNTI=0x%x", dl_rnti);
if (rar_tti != -1) {
msg3_tti = (rar_tti + 3) % 10240;
@ -279,7 +308,7 @@ void ttcn3_syssim::new_tti_indication(uint64_t res)
}
if (dl_rnti != SRSLTE_INVALID_RNTI) {
log->debug("Searching for RNTI=0x%x\n", dl_rnti);
logger.debug("Searching for RNTI=0x%x", dl_rnti);
// look for DL data to be send in each bearer and provide grant accordingly
for (int lcid = 0; lcid < SRSLTE_N_RADIO_BEARERS; lcid++) {
@ -287,7 +316,7 @@ void ttcn3_syssim::new_tti_indication(uint64_t res)
// Schedule DL transmission if there is data in RLC buffer or we need to send Msg4
if ((buf_state > 0 && cells[pcell_idx]->bearer_follow_on_map[lcid] == false) ||
(msg3_tti != -1 && conres_id != 0)) {
log->debug("LCID=%d, buffer_state=%d\n", lcid, buf_state);
logger.debug("LCID=%d, buffer_state=%d", lcid, buf_state);
tx_payload_buffer.clear();
const uint32_t mac_header_size = 10; // Add MAC header (10 B for all subheaders, etc)
@ -297,13 +326,13 @@ void ttcn3_syssim::new_tti_indication(uint64_t res)
if (msg3_tti != -1 && lcid == 0 && conres_id != 0) {
if (mac_msg_dl.new_subh()) {
if (mac_msg_dl.get()->set_con_res_id(conres_id)) {
log->info("CE: Added Contention Resolution ID=0x%" PRIx64 "\n", conres_id);
logger.info("CE: Added Contention Resolution ID=0x%" PRIx64 "", conres_id);
} else {
log->error("CE: Setting Contention Resolution ID CE\n");
logger.error("CE: Setting Contention Resolution ID CE");
}
conres_id = 0; // reset CR so it's not sent twice
} else {
log->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");
}
msg3_tti = -1;
}
@ -315,7 +344,7 @@ void ttcn3_syssim::new_tti_indication(uint64_t res)
if (mac_msg_dl.new_subh()) {
int n = mac_msg_dl.get()->set_sdu(lcid, buf_state, &cells[pcell_idx]->rlc);
if (n == -1) {
log->error("Error while adding SDU (%d B) to MAC PDU\n", buf_state);
logger.error("Error while adding SDU (%d B) to MAC PDU", buf_state);
mac_msg_dl.del_subh();
}
@ -335,14 +364,14 @@ void ttcn3_syssim::new_tti_indication(uint64_t res)
if (mac_pdu_ptr != nullptr) {
if (force_lcid != -1 && lcid == 0) {
if (has_single_sdu) {
log->info("Patched lcid in mac header to: %d\n", force_lcid);
logger.info("Patched lcid in mac header to: %d", force_lcid);
mac_pdu_ptr[0] = (mac_pdu_ptr[0] & 0xe0) | (force_lcid & 0x1f);
} else if (mac_msg_dl.nof_subh() > 1) {
log->warning(
"Not patching lcid to %d in mac header (nof_subh == %d)\n", force_lcid, mac_msg_dl.nof_subh());
logger.warning(
"Not patching lcid to %d in mac header (nof_subh == %d)", force_lcid, mac_msg_dl.nof_subh());
}
}
log->info_hex(mac_pdu_ptr, mac_msg_dl.get_pdu_len(), "DL MAC PDU (%d B):\n", mac_msg_dl.get_pdu_len());
logger.info(mac_pdu_ptr, mac_msg_dl.get_pdu_len(), "DL MAC PDU (%d B):", mac_msg_dl.get_pdu_len());
// Prepare MAC grant for CCCH
mac_interface_phy_lte::mac_grant_dl_t dl_grant = {};
@ -355,18 +384,18 @@ void ttcn3_syssim::new_tti_indication(uint64_t res)
ue->new_tb(dl_grant, (const uint8_t*)mac_pdu_ptr);
} else {
log->error("Error writing DL MAC PDU\n");
logger.error("Error writing DL MAC PDU");
}
mac_msg_dl.reset();
} else if (cells[pcell_idx]->bearer_follow_on_map[lcid]) {
log->info("Waiting for more PDUs for transmission on LCID=%d\n", lcid);
logger.info("Waiting for more PDUs for transmission on LCID=%d", lcid);
}
}
// Check if we need to provide a UL grant as well
}
} else {
log->debug("Not handling RNTI=%d\n", dl_rnti);
logger.debug("Not handling RNTI=%d", dl_rnti);
}
}
@ -378,7 +407,7 @@ void ttcn3_syssim::stop()
void ttcn3_syssim::reset()
{
log->info("Resetting SS\n");
logger.info("Resetting SS");
cells.clear();
pcell_idx = -1;
}
@ -392,22 +421,24 @@ void ttcn3_syssim::tc_start(const char* name)
// Make a copy of the UE args for this run
all_args_t local_args = args;
auto* swp_sink = srslog::find_sink(swappable_sink::name());
if (!swp_sink) {
logger.error("Unable to find the swappable sink");
srslte::console("Unable to find the swappable sink\n");
return;
}
// set up logging
if (args.log.filename == "stdout") {
logger = &logger_stdout;
old_logger = &logger_stdout;
static_cast<swappable_sink*>(swp_sink)->swap_to_stdout();
} else {
const std::string& file_tc_name = get_filename_with_tc_name(local_args.log.filename, run_id, tc_name);
auto* swp_sink = srslog::find_sink(swappable_sink::name());
if (!swp_sink) {
log->error("Unable to find the swappable sink\n");
srslte::console("Unable to find the swappable sink\n");
return;
}
static_cast<swappable_sink*>(swp_sink)->swap_sink(file_tc_name);
logger = &logger_file;
old_logger = &logger_file;
}
log->info("Initializing UE ID=%d for TC=%s\n", run_id, tc_name.c_str());
logger.info("Initializing UE ID=%d for TC=%s", run_id, tc_name.c_str());
srslte::console("Initializing UE ID=%d for TC=%s\n", run_id, tc_name.c_str());
// Patch UE config
@ -415,17 +446,17 @@ void ttcn3_syssim::tc_start(const char* name)
local_args.stack.pcap.nas_filename = get_filename_with_tc_name(args.stack.pcap.nas_filename, run_id, tc_name);
// bring up UE
if (ue->init(local_args, logger, this, tc_name)) {
if (ue->init(local_args, old_logger, this, tc_name)) {
ue->stop();
std::string err("Couldn't initialize UE.\n");
log->error("%s\n", err.c_str());
std::string err("Couldn't initialize UE.");
logger.error("%s", err.c_str());
srslte::console("%s\n", err.c_str());
return;
}
// create and add TTI timer to epoll
if (add_epoll(timer_handler.get_timer_fd(), epoll_fd) != SRSLTE_SUCCESS) {
log->error("Error while adding TTI timer to epoll\n");
logger.error("Error while adding TTI timer to epoll");
}
event_handler.insert({timer_handler.get_timer_fd(), &timer_handler});
}
@ -433,7 +464,7 @@ void ttcn3_syssim::tc_start(const char* name)
// Called from UT to terminate the testcase
void ttcn3_syssim::tc_end()
{
log->info("Deinitializing UE ID=%d\n", run_id);
logger.info("Deinitializing UE ID=%d", run_id);
srslte::console("Deinitializing UE ID=%d\n", run_id);
ue->stop();
@ -477,8 +508,8 @@ void ttcn3_syssim::prach_indication(uint32_t preamble_index_, const uint32_t& ce
{
// verify that UE intends to send PRACH on current Pcell
if (cells[pcell_idx]->config.phy_cell.id != cell_id) {
log->error(
"UE is attempting to PRACH on pci=%d, current Pcell=%d\n", cell_id, cells[pcell_idx]->config.phy_cell.id);
logger.error(
"UE is attempting to PRACH on pci=%d, current Pcell=%d", cell_id, cells[pcell_idx]->config.phy_cell.id);
return;
}
@ -490,7 +521,7 @@ void ttcn3_syssim::prach_indication(uint32_t preamble_index_, const uint32_t& ce
// Called from PHY
void ttcn3_syssim::sr_req(uint32_t tti_tx)
{
log->info("Received SR from PHY\n");
logger.info("Received SR from PHY");
sr_tti = tti_tx;
}
@ -498,16 +529,16 @@ void ttcn3_syssim::sr_req(uint32_t tti_tx)
void ttcn3_syssim::tx_pdu(const uint8_t* payload, const int len, const uint32_t tx_tti)
{
if (payload == NULL) {
ss_mac_log->error("Received NULL as PDU payload. Dropping.\n");
ss_mac_logger.error("Received NULL as PDU payload. Dropping.");
return;
}
if (pcell_idx == -1) {
log->debug("Skipping TTI. Pcell not yet selected.\n");
logger.debug("Skipping TTI. Pcell not yet selected.");
return;
}
log->info_hex(payload, len, "UL MAC PDU (%d B):\n", len);
logger.info(payload, len, "UL MAC PDU (%d B):", len);
// Parse MAC
mac_msg_ul.init_rx(len, true);
@ -517,11 +548,11 @@ void ttcn3_syssim::tx_pdu(const uint8_t* payload, const int len, const uint32_t
assert(mac_msg_ul.get());
if (mac_msg_ul.get()->is_sdu()) {
// Push PDU to our own RLC (needed to handle status reporting, etc. correctly
ss_mac_log->info_hex(mac_msg_ul.get()->get_sdu_ptr(),
mac_msg_ul.get()->get_payload_size(),
"Route UL PDU to LCID=%d (%d B)\n",
mac_msg_ul.get()->get_sdu_lcid(),
mac_msg_ul.get()->get_payload_size());
ss_mac_logger.info(mac_msg_ul.get()->get_sdu_ptr(),
mac_msg_ul.get()->get_payload_size(),
"Route UL PDU to LCID=%d (%d B)",
mac_msg_ul.get()->get_sdu_lcid(),
mac_msg_ul.get()->get_payload_size());
cells[pcell_idx]->rlc.write_pdu(
mac_msg_ul.get()->get_sdu_lcid(), mac_msg_ul.get()->get_sdu_ptr(), mac_msg_ul.get()->get_payload_size());
@ -534,10 +565,10 @@ void ttcn3_syssim::tx_pdu(const uint8_t* payload, const int len, const uint32_t
for (int i = 0; i < nbytes; i++) {
ue_cri_ptr[nbytes - i - 1] = pkt_ptr[i];
}
ss_mac_log->info_hex(ue_cri_ptr, nbytes, "Contention resolution ID:\n");
ss_mac_logger.info(ue_cri_ptr, nbytes, "Contention resolution ID:");
} else {
ss_mac_log->error("Received CCCH UL message of invalid size=%d bytes\n",
mac_msg_ul.get()->get_payload_size());
ss_mac_logger.error("Received CCCH UL message of invalid size=%d bytes",
mac_msg_ul.get()->get_payload_size());
}
}
}
@ -558,7 +589,7 @@ void ttcn3_syssim::tx_pdu(const uint8_t* payload, const int len, const uint32_t
// Internal function called from main thread
void ttcn3_syssim::send_rar(uint32_t preamble_index)
{
log->info("Sending RAR for RAPID=%d\n", preamble_index);
logger.info("Sending RAR for RAPID=%d", preamble_index);
// Prepare RAR grant
uint8_t grant_buffer[64] = {};
@ -600,7 +631,7 @@ void ttcn3_syssim::send_rar(uint32_t preamble_index)
// Internal function called from main thread
void ttcn3_syssim::send_msg3_grant()
{
log->info("Sending Msg3 grant for C-RNTI=0x%x\n", cells[pcell_idx]->config.crnti);
logger.info("Sending Msg3 grant for C-RNTI=0x%x", cells[pcell_idx]->config.crnti);
mac_interface_phy_lte::mac_grant_ul_t ul_grant = {};
ul_grant.tti_tx = (tti + 3) % 10240;
@ -645,41 +676,41 @@ bool ttcn3_syssim::process_ce(srslte::sch_subh* subh)
switch (subh->ul_sch_ce_type()) {
case srslte::ul_sch_lcid::PHR_REPORT:
phr = subh->get_phr();
ss_mac_log->info("CE: Received PHR from rnti=0x%x, value=%.0f\n", rnti, phr);
ss_mac_logger.info("CE: Received PHR from rnti=0x%x, value=%.0f", rnti, phr);
break;
case srslte::ul_sch_lcid::CRNTI:
old_rnti = subh->get_c_rnti();
ss_mac_log->info("CE: Received C-RNTI from temp_rnti=0x%x, rnti=0x%x\n", rnti, old_rnti);
ss_mac_logger.info("CE: Received C-RNTI from temp_rnti=0x%x, rnti=0x%x", rnti, 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) {
ss_mac_log->error("Invalid Index Passed to lc groups\n");
ss_mac_logger.error("Invalid Index Passed to lc groups");
break;
}
ss_mac_log->info("CE: Received %s BSR rnti=0x%x, lcg=%d, value=%d\n",
subh->ul_sch_ce_type() == srslte::ul_sch_lcid::SHORT_BSR ? "Short" : "Trunc",
rnti,
idx,
buff_size_idx[idx]);
ss_mac_logger.info("CE: Received %s BSR rnti=0x%x, lcg=%d, value=%d",
subh->ul_sch_ce_type() == srslte::ul_sch_lcid::SHORT_BSR ? "Short" : "Trunc",
rnti,
idx,
buff_size_idx[idx]);
is_bsr = true;
break;
case srslte::ul_sch_lcid::LONG_BSR:
subh->get_bsr(buff_size_idx, buff_size_bytes);
is_bsr = true;
ss_mac_log->info("CE: Received Long BSR rnti=0x%x, value=%d,%d,%d,%d\n",
rnti,
buff_size_idx[0],
buff_size_idx[1],
buff_size_idx[2],
buff_size_idx[3]);
ss_mac_logger.info("CE: Received Long BSR rnti=0x%x, value=%d,%d,%d,%d",
rnti,
buff_size_idx[0],
buff_size_idx[1],
buff_size_idx[2],
buff_size_idx[3]);
break;
case srslte::ul_sch_lcid::PADDING:
ss_mac_log->debug("CE: Received padding for rnti=0x%x\n", rnti);
ss_mac_logger.debug("CE: Received padding for rnti=0x%x", rnti);
break;
default:
ss_mac_log->error("CE: Invalid lcid=0x%x\n", subh->lcid_value());
ss_mac_logger.error("CE: Invalid lcid=0x%x", subh->lcid_value());
break;
}
return is_bsr;
@ -695,7 +726,7 @@ bool ttcn3_syssim::get_ndi_for_new_ul_tx(const uint32_t tti_)
// toggle NDI to always create new Tx
const uint32_t pid = get_pid(tti_);
last_ul_ndi[pid] = !last_ul_ndi[pid];
log->info("UL-PID=%d NDI=%s\n", pid, last_ul_ndi[pid] ? "1" : "0");
logger.info("UL-PID=%d NDI=%s", pid, last_ul_ndi[pid] ? "1" : "0");
return last_ul_ndi[pid];
}
@ -704,7 +735,7 @@ bool ttcn3_syssim::get_ndi_for_new_dl_tx(const uint32_t tti_)
// toggle NDI to always create new Tx
const uint32_t pid = get_pid(tti_);
last_dl_ndi[pid] = !last_dl_ndi[pid];
log->info("DL-PID=%d NDI=%s\n", pid, last_dl_ndi[pid] ? "1" : "0");
logger.info("DL-PID=%d NDI=%s", pid, last_dl_ndi[pid] ? "1" : "0");
return last_dl_ndi[pid];
}
@ -758,7 +789,7 @@ void ttcn3_syssim::set_cell_config(const ttcn3_helpers::timing_info_t timing, co
if (timing.now) {
set_cell_config_impl(cell);
} else {
log->debug("Scheduling Cell configuration of %s for TTI=%d\n", cell.name.c_str(), timing.tti);
logger.debug("Scheduling Cell configuration of %s for TTI=%d", cell.name.c_str(), timing.tti);
tti_actions[timing.tti].push([this, cell]() { set_cell_config_impl(cell); });
}
}
@ -768,10 +799,10 @@ void ttcn3_syssim::set_cell_config_impl(const cell_config_t config)
// check if cell already exists
if (not syssim_has_cell(config.name)) {
// insert new cell
log->info("Adding cell %s with cellId=%d and initial_power=%.2f dBm\n",
config.name.c_str(),
config.phy_cell.id,
config.initial_power);
logger.info("Adding cell %s with cellId=%d and initial_power=%.2f dBm",
config.name.c_str(),
config.phy_cell.id,
config.initial_power);
unique_syssim_cell_t cell = unique_syssim_cell_t(new syssim_cell_t(this));
cell->config = config;
@ -782,7 +813,7 @@ void ttcn3_syssim::set_cell_config_impl(const cell_config_t config)
cells.push_back(std::move(cell));
} else {
// cell is already there
log->info("Cell already there, reconfigure\n");
logger.info("Cell already there, reconfigure");
// We only support (Temp-)CRNTI reconfiguration
syssim_cell_t* ss_cell = get_cell(config.name);
if (config.crnti > 0) {
@ -824,7 +855,7 @@ void ttcn3_syssim::set_cell_attenuation(const ttcn3_helpers::timing_info_t timin
if (timing.now) {
set_cell_attenuation_impl(cell_name, value);
} else {
log->debug("Scheduling Cell attenuation reconfiguration of %s for TTI=%d\n", cell_name.c_str(), timing.tti);
logger.debug("Scheduling Cell attenuation reconfiguration of %s for TTI=%d", cell_name.c_str(), timing.tti);
tti_actions[timing.tti].push([this, cell_name, value]() { set_cell_attenuation_impl(cell_name, value); });
}
}
@ -832,7 +863,7 @@ void ttcn3_syssim::set_cell_attenuation(const ttcn3_helpers::timing_info_t timin
void ttcn3_syssim::set_cell_attenuation_impl(const std::string cell_name, const float value)
{
if (not syssim_has_cell(cell_name)) {
log->error("Can't set cell power. Cell not found.\n");
logger.error("Can't set cell power. Cell not found.");
return;
}
@ -853,7 +884,7 @@ void ttcn3_syssim::update_cell_map()
phy_cell.info = ss_cell->config.phy_cell;
phy_cell.power = ss_cell->config.initial_power - ss_cell->config.attenuation;
phy_cell.earfcn = ss_cell->config.earfcn;
log->info("Configuring cell with PCI=%d with TxPower=%.2f\n", phy_cell.info.id, phy_cell.power);
logger.info("Configuring cell with PCI=%d with TxPower=%.2f", phy_cell.info.id, phy_cell.power);
phy_cells.push_back(phy_cell);
}
@ -869,7 +900,7 @@ bool ttcn3_syssim::have_valid_pcell()
void ttcn3_syssim::add_bcch_dlsch_pdu(const string cell_name, unique_byte_buffer_t pdu)
{
if (not syssim_has_cell(cell_name)) {
log->error("Can't add BCCH to cell. Cell not found.\n");
logger.error("Can't add BCCH to cell. Cell not found.");
return;
}
@ -885,7 +916,7 @@ void ttcn3_syssim::add_ccch_pdu(const ttcn3_helpers::timing_info_t timing,
// Add to SRB0 Tx queue
add_ccch_pdu_impl(cell_name, std::move(pdu));
} else {
log->debug("Scheduling CCCH PDU for TTI=%d\n", timing.tti);
logger.debug("Scheduling CCCH PDU for TTI=%d", timing.tti);
auto task = [this, cell_name](srslte::unique_byte_buffer_t& pdu) { add_ccch_pdu_impl(cell_name, std::move(pdu)); };
tti_actions[timing.tti].push(std::bind(task, std::move(pdu)));
}
@ -894,7 +925,7 @@ void ttcn3_syssim::add_ccch_pdu(const ttcn3_helpers::timing_info_t timing,
void ttcn3_syssim::add_ccch_pdu_impl(const std::string cell_name, unique_byte_buffer_t pdu)
{
if (not syssim_has_cell(cell_name)) {
log->error("Can't add CCCH to cell. Cell not found.\n");
logger.error("Can't add CCCH to cell. Cell not found.");
return;
}
@ -912,7 +943,7 @@ void ttcn3_syssim::add_dcch_pdu(const ttcn3_helpers::timing_info_t timing,
if (timing.now) {
add_dcch_pdu_impl(cell_name, lcid, std::move(pdu), follow_on_flag);
} else {
log->debug("Scheduling DCCH PDU for TTI=%d\n", timing.tti);
logger.debug("Scheduling DCCH PDU for TTI=%d", timing.tti);
auto task = [this, cell_name](uint32_t lcid, srslte::unique_byte_buffer_t& pdu, bool follow_on_flag) {
add_dcch_pdu_impl(cell_name, lcid, std::move(pdu), follow_on_flag);
};
@ -926,21 +957,21 @@ void ttcn3_syssim::add_dcch_pdu_impl(const std::string cell_name,
bool follow_on_flag)
{
if (not syssim_has_cell(cell_name)) {
log->error("Can't add CCCH to cell. Cell %s not found.\n", cell_name.c_str());
logger.error("Can't add CCCH to cell. Cell %s not found.", cell_name.c_str());
return;
}
auto cell = get_cell(cell_name);
// push to PDCP and create DL grant for it
log->info("Writing PDU (%d B) to LCID=%d\n", pdu->N_bytes, lcid);
logger.info("Writing PDU (%d B) to LCID=%d", pdu->N_bytes, lcid);
cell->pdcp.write_sdu(lcid, std::move(pdu));
cell->bearer_follow_on_map[lcid] = follow_on_flag;
}
void ttcn3_syssim::add_pch_pdu(unique_byte_buffer_t pdu)
{
log->info("Received PCH PDU (%d B)\n", pdu->N_bytes);
logger.info("Received PCH PDU (%d B)", pdu->N_bytes);
// Prepare MAC grant for PCH
mac_interface_phy_lte::mac_grant_dl_t dl_grant = {};
@ -966,7 +997,7 @@ void ttcn3_syssim::add_srb(const ttcn3_helpers::timing_info_t timing,
if (timing.now) {
add_srb_impl(cell_name, lcid, pdcp_config);
} else {
log->debug("Scheduling SRB%d addition for TTI=%d\n", lcid, timing.tti);
logger.debug("Scheduling SRB%d addition for TTI=%d", lcid, timing.tti);
tti_actions[timing.tti].push(
[this, cell_name, lcid, pdcp_config]() { add_srb_impl(cell_name, lcid, pdcp_config); });
}
@ -975,13 +1006,13 @@ void ttcn3_syssim::add_srb(const ttcn3_helpers::timing_info_t timing,
void ttcn3_syssim::add_srb_impl(const std::string cell_name, const uint32_t lcid, const pdcp_config_t pdcp_config)
{
if (not syssim_has_cell(cell_name)) {
log->error("Can't add SRB to cell. Cell %s not found.\n", cell_name.c_str());
logger.error("Can't add SRB to cell. Cell %s not found.", cell_name.c_str());
return;
}
auto cell = get_cell(cell_name);
log->info("Adding SRB%d\n", lcid);
logger.info("Adding SRB%d", lcid);
cell->pdcp.add_bearer(lcid, pdcp_config);
cell->rlc.add_bearer(lcid, srslte::rlc_config_t::srb_config(lcid));
}
@ -989,13 +1020,13 @@ void ttcn3_syssim::add_srb_impl(const std::string cell_name, const uint32_t lcid
void ttcn3_syssim::reestablish_bearer(const std::string cell_name, const uint32_t lcid)
{
if (not syssim_has_cell(cell_name)) {
log->error("Can't reestablish bearer. Cell %s not found.\n", cell_name.c_str());
logger.error("Can't reestablish bearer. Cell %s not found.", cell_name.c_str());
return;
}
auto cell = get_cell(cell_name);
log->info("Reestablishing LCID=%d\n", lcid);
logger.info("Reestablishing LCID=%d", lcid);
cell->pdcp.reestablish(lcid);
cell->rlc.reestablish(lcid);
}
@ -1005,7 +1036,7 @@ void ttcn3_syssim::del_srb(const ttcn3_helpers::timing_info_t timing, const std:
if (timing.now) {
del_srb_impl(cell_name, lcid);
} else {
log->debug("Scheduling SRB%d deletion for TTI=%d\n", lcid, timing.tti);
logger.debug("Scheduling SRB%d deletion for TTI=%d", lcid, timing.tti);
tti_actions[timing.tti].push([this, cell_name, lcid]() { del_srb_impl(cell_name, lcid); });
}
}
@ -1013,13 +1044,13 @@ void ttcn3_syssim::del_srb(const ttcn3_helpers::timing_info_t timing, const std:
void ttcn3_syssim::del_srb_impl(const std::string cell_name, const uint32_t lcid)
{
if (not syssim_has_cell(cell_name)) {
log->error("Can't delete bearer. Cell %s not found.\n", cell_name.c_str());
logger.error("Can't delete bearer. Cell %s not found.", cell_name.c_str());
return;
}
auto cell = get_cell(cell_name);
log->info("Deleting SRB%d\n", lcid);
logger.info("Deleting SRB%d", lcid);
// Only delete SRB1/2
if (lcid > 0) {
cell->pdcp.del_bearer(lcid);
@ -1035,7 +1066,7 @@ void ttcn3_syssim::add_drb(const ttcn3_helpers::timing_info_t timing,
if (timing.now) {
add_drb_impl(cell_name, lcid, pdcp_config);
} else {
log->debug("Scheduling DRB%d addition for TTI=%d\n", lcid - 2, timing.tti);
logger.debug("Scheduling DRB%d addition for TTI=%d", lcid - 2, timing.tti);
tti_actions[timing.tti].push(
[this, cell_name, lcid, pdcp_config]() { add_drb_impl(cell_name, lcid, pdcp_config); });
}
@ -1044,14 +1075,14 @@ void ttcn3_syssim::add_drb(const ttcn3_helpers::timing_info_t timing,
void ttcn3_syssim::add_drb_impl(const std::string cell_name, const uint32_t lcid, const pdcp_config_t pdcp_config)
{
if (not syssim_has_cell(cell_name)) {
log->error("Can't add DRB. Cell %s not found.\n", cell_name.c_str());
logger.error("Can't add DRB. Cell %s not found.", cell_name.c_str());
return;
}
auto cell = get_cell(cell_name);
if (lcid > 2) {
log->info("Adding DRB%d\n", lcid - 2);
logger.info("Adding DRB%d", lcid - 2);
cell->pdcp.add_bearer(lcid, pdcp_config);
cell->rlc.add_bearer(lcid, srslte::rlc_config_t::default_rlc_am_config());
}
@ -1062,7 +1093,7 @@ void ttcn3_syssim::del_drb(const ttcn3_helpers::timing_info_t timing, const std:
if (timing.now) {
del_drb_impl(cell_name, lcid);
} else {
log->debug("Scheduling DRB%d deletion for TTI=%d\n", lcid - 2, timing.tti);
logger.debug("Scheduling DRB%d deletion for TTI=%d", lcid - 2, timing.tti);
tti_actions[timing.tti].push([this, cell_name, lcid]() { del_drb_impl(cell_name, lcid); });
}
}
@ -1070,7 +1101,7 @@ void ttcn3_syssim::del_drb(const ttcn3_helpers::timing_info_t timing, const std:
void ttcn3_syssim::del_drb_impl(const std::string cell_name, const uint32_t lcid)
{
if (not syssim_has_cell(cell_name)) {
log->error("Can't delete DRB. Cell %s not found.\n", cell_name.c_str());
logger.error("Can't delete DRB. Cell %s not found.", cell_name.c_str());
return;
}
@ -1078,7 +1109,7 @@ void ttcn3_syssim::del_drb_impl(const std::string cell_name, const uint32_t lcid
// Only delete DRB
if (lcid > 2) {
log->info("Deleting DRB%d\n", lcid - 2);
logger.info("Deleting DRB%d", lcid - 2);
cell->pdcp.del_bearer(lcid);
cell->rlc.del_bearer(lcid);
}
@ -1087,12 +1118,12 @@ void ttcn3_syssim::del_drb_impl(const std::string cell_name, const uint32_t lcid
// RRC interface for PDCP, PDCP calls RRC to push RRC SDU
void ttcn3_syssim::write_pdu(uint32_t lcid, unique_byte_buffer_t pdu)
{
log->info_hex(pdu->msg,
pdu->N_bytes,
"RRC SDU received for LCID=%d cell_id=%d (%d B)\n",
lcid,
cells[pcell_idx]->config.phy_cell.id,
pdu->N_bytes);
logger.info(pdu->msg,
pdu->N_bytes,
"RRC SDU received for LCID=%d cell_id=%d (%d B)",
lcid,
cells[pcell_idx]->config.phy_cell.id,
pdu->N_bytes);
// push content to Titan
if (lcid <= 2) {
@ -1108,23 +1139,23 @@ void ttcn3_syssim::write_pdu(uint32_t lcid, unique_byte_buffer_t pdu)
// Not supported right now
void ttcn3_syssim::write_pdu_bcch_bch(unique_byte_buffer_t pdu)
{
log->error("%s not implemented.\n", __FUNCTION__);
logger.error("%s not implemented.", __FUNCTION__);
}
void ttcn3_syssim::write_pdu_bcch_dlsch(unique_byte_buffer_t pdu)
{
log->error("%s not implemented.\n", __FUNCTION__);
logger.error("%s not implemented.", __FUNCTION__);
}
void ttcn3_syssim::write_pdu_pcch(unique_byte_buffer_t pdu)
{
log->error("%s not implemented.\n", __FUNCTION__);
logger.error("%s not implemented.", __FUNCTION__);
}
void ttcn3_syssim::write_pdu_mch(uint32_t lcid, unique_byte_buffer_t pdu)
{
log->error("%s not implemented.\n", __FUNCTION__);
logger.error("%s not implemented.", __FUNCTION__);
}
void ttcn3_syssim::max_retx_attempted()
{
log->error("%s not implemented.\n", __FUNCTION__);
logger.error("%s not implemented.", __FUNCTION__);
}
std::string ttcn3_syssim::get_rb_name(uint32_t lcid)
@ -1137,10 +1168,10 @@ std::string ttcn3_syssim::get_rb_name(uint32_t lcid)
void ttcn3_syssim::write_sdu(uint32_t lcid, unique_byte_buffer_t sdu)
{
log->info_hex(sdu->msg, sdu->N_bytes, "Received SDU on LCID=%d\n", lcid);
logger.info(sdu->msg, sdu->N_bytes, "Received SDU on LCID=%d", lcid);
uint8_t* mac_pdu_ptr = mac_msg_dl.write_packet(log);
log->info_hex(mac_pdu_ptr, mac_msg_dl.get_pdu_len(), "DL MAC PDU:\n");
logger.info(mac_pdu_ptr, mac_msg_dl.get_pdu_len(), "DL MAC PDU:");
// Prepare MAC grant for CCCH
mac_interface_phy_lte::mac_grant_dl_t dl_grant = {};
@ -1179,7 +1210,7 @@ void ttcn3_syssim::set_as_security(const ttcn3_helpers::timing_info_t tim
if (timing.now) {
set_as_security_impl(cell_name, k_rrc_enc_, k_rrc_int_, k_up_enc_, cipher_algo_, integ_algo_, bearers_);
} else {
log->debug("Scheduling AS security configuration for TTI=%d\n", timing.tti);
logger.debug("Scheduling AS security configuration for TTI=%d", timing.tti);
tti_actions[timing.tti].push(
[this, cell_name, k_rrc_enc_, k_rrc_int_, k_up_enc_, cipher_algo_, integ_algo_, bearers_]() {
set_as_security_impl(cell_name, k_rrc_enc_, k_rrc_int_, k_up_enc_, cipher_algo_, integ_algo_, bearers_);
@ -1196,7 +1227,7 @@ void ttcn3_syssim::set_as_security_impl(const std::string
const ttcn3_helpers::pdcp_count_map_t bearers)
{
if (not syssim_has_cell(cell_name)) {
log->error("Can't configure AS security. Cell %s not found.\n", cell_name.c_str());
logger.error("Can't configure AS security. Cell %s not found.", cell_name.c_str());
return;
}
@ -1213,10 +1244,10 @@ void ttcn3_syssim::set_as_security_impl(const std::string
for (auto& lcid : bearers) {
cell->pdcp.config_security(lcid.rb_id, cell->sec_cfg);
log->info("Setting AS security for LCID=%d in DL direction from SN=%d onwards\n", lcid.rb_id, lcid.dl_value);
logger.info("Setting AS security for LCID=%d in DL direction from SN=%d onwards", lcid.rb_id, lcid.dl_value);
cell->pdcp.enable_security_timed(lcid.rb_id, DIRECTION_TX, lcid.dl_value);
log->info("Setting AS security for LCID=%d in UL direction from SN=%d onwards\n", lcid.rb_id, lcid.ul_value);
logger.info("Setting AS security for LCID=%d in UL direction from SN=%d onwards", lcid.rb_id, lcid.ul_value);
cell->pdcp.enable_security_timed(lcid.rb_id, DIRECTION_RX, lcid.ul_value);
}
}
@ -1226,7 +1257,7 @@ void ttcn3_syssim::release_as_security(const ttcn3_helpers::timing_info_t timing
if (timing.now) {
release_as_security_impl(cell_name);
} else {
log->debug("Scheduling Release of AS security for TTI=%d\n", timing.tti);
logger.debug("Scheduling Release of AS security for TTI=%d", timing.tti);
tti_actions[timing.tti].push([this, cell_name]() { release_as_security_impl(cell_name); });
}
}
@ -1234,13 +1265,13 @@ void ttcn3_syssim::release_as_security(const ttcn3_helpers::timing_info_t timing
void ttcn3_syssim::release_as_security_impl(const std::string cell_name)
{
if (not syssim_has_cell(cell_name)) {
log->error("Can't release AS security. Cell %s not found.\n", cell_name.c_str());
logger.error("Can't release AS security. Cell %s not found.", cell_name.c_str());
return;
}
auto cell = get_cell(cell_name);
log->info("Releasing AS security\n");
logger.info("Releasing AS security");
cell->pending_bearer_config.clear();
}
@ -1250,7 +1281,7 @@ void ttcn3_syssim::select_cell(srslte_cell_t phy_cell)
for (uint32_t i = 0; i < cells.size(); ++i) {
if (cells[i]->config.phy_cell.id == phy_cell.id) {
pcell_idx = i;
log->info("New PCell: PCI=%d\n", cells[pcell_idx]->config.phy_cell.id);
logger.info("New PCell: PCI=%d", cells[pcell_idx]->config.phy_cell.id);
return;
}
}
@ -1262,7 +1293,7 @@ ttcn3_helpers::pdcp_count_map_t ttcn3_syssim::get_pdcp_count(const std::string c
std::vector<ttcn3_helpers::pdcp_count_t> bearers;
if (not syssim_has_cell(cell_name)) {
log->error("Can't obtain PDCP count. Cell %s not found.\n", cell_name.c_str());
logger.error("Can't obtain PDCP count. Cell %s not found.", cell_name.c_str());
return bearers;
}
@ -1278,7 +1309,7 @@ ttcn3_helpers::pdcp_count_map_t ttcn3_syssim::get_pdcp_count(const std::string c
bearer.rb_id = i;
bearer.dl_value = pdcp_state.next_pdcp_tx_sn;
bearer.ul_value = pdcp_state.next_pdcp_rx_sn;
log->debug("PDCP count lcid=%d, dl=%d, ul=%d\n", bearer.rb_id, bearer.dl_value, bearer.ul_value);
logger.debug("PDCP count lcid=%d, dl=%d, ul=%d", bearer.rb_id, bearer.dl_value, bearer.ul_value);
bearers.push_back(bearer);
}
}

@ -20,16 +20,16 @@ SRSLTE_API char* srslte_get_build_info();
SRSLTE_API char* srslte_get_build_mode();
}
ttcn3_ue::ttcn3_ue() : tft_matcher(&log) {}
ttcn3_ue::ttcn3_ue() : logger(srslog::fetch_basic_logger("UE", false)), tft_matcher(logger) {}
int ttcn3_ue::init(all_args_t args, srslte::logger* logger_, syssim_interface_phy* syssim_, const std::string tc_name_)
{
logger = logger_;
old_logger = logger_;
// Init UE log
log.init("UE ", logger);
log.set_level(srslte::LOG_LEVEL_INFO);
log.info("Built in %s mode using %s.\n", srslte_get_build_mode(), srslte_get_build_info());
logger.set_level(srslog::basic_levels::info);
logger.set_hex_dump_max_size(128);
logger.info("Built in %s mode using %s.", srslte_get_build_mode(), srslte_get_build_info());
// Patch args
args.stack.nas.force_imsi_attach = true;
@ -57,13 +57,13 @@ int ttcn3_ue::init(all_args_t args, srslte::logger* logger_, syssim_interface_ph
// Instantiate layers and stack together our UE
if (args.stack.type == "lte") {
stack = std::unique_ptr<ue_stack_lte>(new ue_stack_lte());
stack = std::unique_ptr<ue_stack_lte>(new ue_stack_lte(srslog::get_default_sink()));
if (!stack) {
srslte::console("Error creating LTE stack instance.\n");
return SRSLTE_ERROR;
}
phy = std::unique_ptr<srsue::lte_ttcn3_phy>(new srsue::lte_ttcn3_phy(logger));
phy = std::unique_ptr<srsue::lte_ttcn3_phy>(new srsue::lte_ttcn3_phy);
if (!phy) {
srslte::console("Error creating LTE PHY instance.\n");
return SRSLTE_ERROR;
@ -79,7 +79,7 @@ int ttcn3_ue::init(all_args_t args, srslte::logger* logger_, syssim_interface_ph
return SRSLTE_ERROR;
}
if (stack->init(args.stack, logger, phy.get(), this)) {
if (stack->init(args.stack, old_logger, phy.get(), this)) {
srslte::console("Error initializing stack.\n");
return SRSLTE_ERROR;
}
@ -154,13 +154,13 @@ uint16_t ttcn3_ue::get_dl_sched_rnti(uint32_t tti)
void ttcn3_ue::add_mch_port(uint32_t lcid, uint32_t port) {}
void ttcn3_ue::write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t pdu)
{
log.debug_hex(pdu->msg, pdu->N_bytes, "Rx PDU (%d B) on lcid=%d\n", pdu->N_bytes, lcid);
logger.debug(pdu->msg, pdu->N_bytes, "Rx PDU (%d B) on lcid=%d", pdu->N_bytes, lcid);
switch (test_loop_mode) {
case TEST_LOOP_INACTIVE:
log.warning("Test loop inactive. Dropping PDU.\n");
logger.warning("Test loop inactive. Dropping PDU.");
break;
case TEST_LOOP_MODE_A_ACTIVE:
log.error("Test loop mode A not implemented. Dropping PDU.\n");
logger.error("Test loop mode A not implemented. Dropping PDU.");
break;
case TEST_LOOP_MODE_B_ACTIVE:
// Section 5.4.4 in TS 36.509
@ -176,7 +176,7 @@ void ttcn3_ue::write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t pdu)
}
break;
case TEST_LOOP_MODE_C_ACTIVE:
log.error("Test loop mode C not implemented. Dropping PDU.\n");
logger.error("Test loop mode C not implemented. Dropping PDU.");
break;
}
}
@ -199,21 +199,21 @@ void ttcn3_ue::set_test_loop_mode(const test_loop_mode_state_t mode, const uint3
switch (test_loop_mode) {
case TEST_LOOP_INACTIVE:
// deactivate timer
log.info("Deactivating Test Loop Mode\n");
logger.info("Deactivating Test Loop Mode");
pdu_delay_timer.release();
break;
case TEST_LOOP_MODE_A_ACTIVE:
log.error("Test loop mode A not implemented\n");
logger.error("Test loop mode A not implemented");
break;
case TEST_LOOP_MODE_B_ACTIVE:
log.info("Activating Test loop mode B with %d ms PDU delay\n", ip_pdu_delay_ms_);
logger.info("Activating Test loop mode B with %d ms PDU delay", ip_pdu_delay_ms_);
pdu_delay_timer = stack->get_task_sched().get_unique_timer();
if (ip_pdu_delay_ms_ > 0) {
pdu_delay_timer.set(ip_pdu_delay_ms_, [this](uint32_t tid) { timer_expired(tid); });
}
break;
case TEST_LOOP_MODE_C_ACTIVE:
log.error("Test loop mode A not implemented\n");
logger.error("Test loop mode A not implemented");
break;
}
}
@ -221,23 +221,23 @@ void ttcn3_ue::set_test_loop_mode(const test_loop_mode_state_t mode, const uint3
void ttcn3_ue::timer_expired(uint32_t timeout_id)
{
if (timeout_id == pdu_delay_timer.id()) {
log.info("Testmode B PDU delay timer expired\n");
logger.info("Testmode B PDU delay timer expired");
send_queued_data();
}
}
void ttcn3_ue::send_queued_data()
{
if (!stack->is_rrc_connected()) {
log.info("RRC not connected, requesting NAS attach\n");
logger.info("RRC not connected, requesting NAS attach");
if (not stack->start_service_request()) {
log.warning("Could not reestablish the connection\n");
logger.warning("Could not reestablish the connection");
}
stack->get_task_sched().defer_callback(500, [&]() { send_queued_data(); });
return;
}
for (auto& bearer_pdu_queue : pdu_queue) {
log.info("Delivering %zd buffered PDUs for LCID=%d\n", bearer_pdu_queue.second.size(), bearer_pdu_queue.first);
logger.info("Delivering %zd buffered PDUs for LCID=%d", bearer_pdu_queue.second.size(), bearer_pdu_queue.first);
while (not bearer_pdu_queue.second.empty()) {
srslte::unique_byte_buffer_t pdu;
bearer_pdu_queue.second.try_pop(&pdu);
@ -248,6 +248,6 @@ void ttcn3_ue::send_queued_data()
void ttcn3_ue::loop_back_pdu_with_tft(uint32_t input_lcid, srslte::unique_byte_buffer_t pdu)
{
log.info_hex(pdu->msg, pdu->N_bytes, "Rx PDU (%d B) on lcid=%d, looping back\n", pdu->N_bytes, input_lcid);
logger.info(pdu->msg, pdu->N_bytes, "Rx PDU (%d B) on lcid=%d, looping back", pdu->N_bytes, input_lcid);
stack->write_sdu(input_lcid, std::move(pdu));
}

@ -18,11 +18,12 @@
int if_handler_test()
{
ttcn3_ut_interface ut;
ttcn3_sys_interface sys;
ttcn3_ip_sock_interface ip_sock;
ttcn3_ip_ctrl_interface ip_ctrl;
ttcn3_srb_interface srb;
auto& logger = srslog::fetch_basic_logger("TEST", false);
ttcn3_ut_interface ut(logger);
ttcn3_sys_interface sys(logger);
ttcn3_ip_sock_interface ip_sock(logger);
ttcn3_ip_ctrl_interface ip_ctrl(logger);
ttcn3_srb_interface srb(logger);
return SRSLTE_SUCCESS;
}

@ -167,7 +167,6 @@ public:
running = false;
wait_thread_finish();
}
srslte::log_ref stack_log{"STCK"};
pdcp_interface_gw* pdcp = nullptr;
srsue::nas* nas = nullptr;
bool running = false;
@ -218,7 +217,7 @@ int security_command_test()
args.using_op = true;
// init USIM
srsue::usim usim(&usim_log);
srsue::usim usim(srslog::fetch_basic_logger("USIM"));
usim.init(&args);
{
@ -274,7 +273,7 @@ int mme_attach_request_test()
rrc_dummy rrc_dummy;
pdcp_dummy pdcp_dummy;
srsue::usim usim(&usim_log);
srsue::usim usim(srslog::fetch_basic_logger("USIM"));
usim_args_t args;
args.mode = "soft";
args.algo = "xor";
@ -358,7 +357,7 @@ int esm_info_request_test()
args.op = "63BFA50EE6523365FF14C1F45F88737D";
// init USIM
srsue::usim usim(&usim_log);
srsue::usim usim(srslog::fetch_basic_logger("USIM"));
usim.init(&args);
srslte::byte_buffer_pool* pool;
@ -410,7 +409,7 @@ int dedicated_eps_bearer_test()
args.op = "63BFA50EE6523365FF14C1F45F88737D";
// init USIM
srsue::usim usim(&usim_log);
srsue::usim usim(srslog::fetch_basic_logger("USIM"));
usim.init(&args);
srslte::byte_buffer_pool* pool = byte_buffer_pool::get_instance();
@ -476,6 +475,19 @@ int main(int argc, char** argv)
srslte::srslog_wrapper log_wrapper(*chan);
g_logger = &log_wrapper;
auto& rrc_logger = srslog::fetch_basic_logger("RRC", false);
rrc_logger.set_level(srslog::basic_levels::debug);
rrc_logger.set_hex_dump_max_size(100000);
auto& nas_logger = srslog::fetch_basic_logger("NAS", false);
nas_logger.set_level(srslog::basic_levels::debug);
nas_logger.set_hex_dump_max_size(100000);
auto& usim_logger = srslog::fetch_basic_logger("USIM", false);
usim_logger.set_level(srslog::basic_levels::debug);
usim_logger.set_hex_dump_max_size(100000);
auto& gw_logger = srslog::fetch_basic_logger("GW", false);
gw_logger.set_level(srslog::basic_levels::debug);
gw_logger.set_hex_dump_max_size(100000);
// Start the log backend.
srslog::init();

@ -10,12 +10,10 @@
*
*/
#include "srsue/hdr/stack/upper/pcsc_usim.h"
#include <assert.h>
#include <iostream>
#include "srslte/common/log_filter.h"
#include "srsue/hdr/stack/upper/pcsc_usim.h"
using namespace srsue;
using namespace std;
@ -24,9 +22,11 @@ uint8_t autn_enb[] = {0x5a, 0x17, 0x77, 0x3c, 0x62, 0x57, 0x90, 0x01, 0xcf, 0x47
int main(int argc, char** argv)
{
srslte::log_filter usim_log("USIM");
usim_log.set_level(srslte::LOG_LEVEL_DEBUG);
usim_log.set_hex_limit(100000);
srslog::basic_logger& logger = srslog::fetch_basic_logger("USIM", false);
logger.set_level(srslog::basic_levels::debug);
logger.set_hex_dump_max_size(100000);
srslog::init();
uint8_t res[16];
int res_len;
uint8_t k_asme[32];
@ -37,7 +37,7 @@ int main(int argc, char** argv)
args.pin = "6129";
args.imei = "353490069873319";
srsue::pcsc_usim usim(&usim_log);
srsue::pcsc_usim usim(logger);
if (usim.init(&args)) {
printf("Error initializing PC/SC USIM.\n");
return SRSLTE_ERROR;

@ -489,6 +489,7 @@ int meas_obj_test()
srslte::log_ref log1("RRC_MEAS");
log1->set_level(srslte::LOG_LEVEL_DEBUG);
log1->set_hex_limit(-1);
auto& rrc_meas_logger = srslog::fetch_basic_logger("RRC_MEAS");
printf("==========================================================\n");
printf("====== Object Configuration Testing ===============\n");
@ -506,7 +507,7 @@ int meas_obj_test()
rrc_conn_recfg.meas_cfg_present = true;
meas_cfg_s& meas_cfg = rrc_conn_recfg.meas_cfg;
log1->info("Test1: Remove non-existing measObject, reportConfig and measId\n");
rrc_meas_logger.info("Test1: Remove non-existing measObject, reportConfig and measId");
meas_cfg = {};
meas_cfg.meas_id_to_rem_list.push_back(3);
meas_cfg.meas_obj_to_rem_list.push_back(3);
@ -518,7 +519,7 @@ int meas_obj_test()
TESTASSERT(rrctest.send_meas_cfg(rrc_conn_recfg));
TESTASSERT(rrctest.phytest.meas_nof_freqs() == 0);
log1->info("Test2: Add measId pointing to non-existing measObject or reportConfig\n");
rrc_meas_logger.info("Test2: Add measId pointing to non-existing measObject or reportConfig");
meas_cfg = {};
meas_id_to_add_mod_s m = {};
m.meas_obj_id = 1;
@ -531,7 +532,7 @@ int meas_obj_test()
TESTASSERT(rrctest.send_meas_cfg(rrc_conn_recfg));
TESTASSERT(rrctest.phytest.meas_nof_freqs() == 0);
log1->info("Test3: Add meaObject and report of unsupported type. Setup a supported report for later use\n");
rrc_meas_logger.info("Test3: Add meaObject and report of unsupported type. Setup a supported report for later use");
meas_cfg = {};
meas_obj_to_add_mod_s obj = {};
obj.meas_obj.set_meas_obj_utra();
@ -560,7 +561,7 @@ int meas_obj_test()
TESTASSERT(rrctest.send_meas_cfg(rrc_conn_recfg));
TESTASSERT(rrctest.phytest.meas_nof_freqs() == 0);
log1->info("Test4: Add 2 measObjects and 2 measId both pointing to the same measObject \n");
rrc_meas_logger.info("Test4: Add 2 measObjects and 2 measId both pointing to the same measObject ");
meas_cfg = {};
for (int i = 0; i < 2; i++) {
m = {};
@ -596,7 +597,7 @@ int meas_obj_test()
TESTASSERT(rrctest.phytest.meas_freq_started(100));
TESTASSERT(rrctest.phytest.meas_nof_cells(100) == 0);
log1->info("Test5: Add existing objects and measId. Now add measId for 2nd cell\n");
rrc_meas_logger.info("Test5: Add existing objects and measId. Now add measId for 2nd cell");
meas_cfg = {};
m = {};
m.meas_obj_id = 2; // same object
@ -627,7 +628,7 @@ int meas_obj_test()
}
// Reconfigure 2nd object only, we should see 8 cells now
log1->info("Test6: Add 1 cell to 1st object. Mixed add/mod and removal command.\n");
rrc_meas_logger.info("Test6: Add 1 cell to 1st object. Mixed add/mod and removal command.");
meas_cfg = {};
meas_cfg.meas_obj_to_add_mod_list_present = true;
@ -681,7 +682,7 @@ int meas_obj_test()
TESTASSERT(rrctest.phytest.meas_cell_started(2, 23)); // was added
TESTASSERT(rrctest.phytest.meas_cell_started(2, 24)); // was added
log1->info("Test7: PHY finds new neighbours in frequency 1 and 2, check RRC instructs to search them\n");
rrc_meas_logger.info("Test7: PHY finds new neighbours in frequency 1 and 2, check RRC instructs to search them");
std::vector<phy_meas_t> phy_meas = {};
phy_meas.push_back({0, 0, 0.0f, 1, 31});
phy_meas.push_back({-1, 0, 0.0f, 1, 32});
@ -717,13 +718,13 @@ int meas_obj_test()
TESTASSERT(rrctest.phytest.meas_cell_started(2, 24)); // was added
TESTASSERT(rrctest.phytest.meas_cell_started(2, 31));
log1->info("Test8: Simulate a Release (reset() call) make sure resets correctly\n");
rrc_meas_logger.info("Test8: Simulate a Release (reset() call) make sure resets correctly");
rrctest.init();
rrctest.run_tti(1);
rrctest.connect();
rrctest.run_tti(1);
log1->info("Test9: Config removal\n");
rrc_meas_logger.info("Test9: Config removal");
meas_cfg = {};
meas_cfg.meas_obj_to_rem_list.push_back(1);
meas_cfg.meas_obj_to_rem_list.push_back(2);
@ -916,6 +917,7 @@ int a1event_report_test(uint32_t a1_rsrp_th,
log1->set_hex_limit(-1);
rrc_log->set_level(srslte::LOG_LEVEL_DEBUG);
rrc_log->set_hex_limit(-1);
auto& rrc_meas_logger = srslog::fetch_basic_logger("RRC_MEAS");
printf("==========================================================\n");
printf("============ Report Testing A1 ===============\n");
@ -947,20 +949,20 @@ int a1event_report_test(uint32_t a1_rsrp_th,
// Entering condition during half timeToTrigger, should not trigger measurement
for (int i = 0; i < ttt_iters / 2; i++) {
log1->info("Report %d/%d enter condition is true\n", i, ttt_iters / 2);
rrc_meas_logger.info("Report %d/%d enter condition is true", i, ttt_iters / 2);
enter_condition(rrctest, event_id, hyst, 0, {1, 2});
// Check doesn't generate measurement report
TESTASSERT(!rrctest.get_meas_res(meas_res));
}
log1->info("Report leaving enter condition\n");
rrc_meas_logger.info("Report leaving enter condition");
// Not satisfy entering condition for 1 TTI
middle_condition(rrctest, event_id, hyst, 0, {1});
TESTASSERT(!rrctest.get_meas_res(meas_res));
// Should go again all timeToTrigger, should not trigger measurement until end
for (int i = 0; i < ttt_iters; i++) {
log1->info("Report %d/%d enter condition is true\n", i, ttt_iters);
rrc_meas_logger.info("Report %d/%d enter condition is true", i, ttt_iters);
enter_condition(rrctest, event_id, hyst, 0, {1, 2});
if (i < ttt_iters - 1) {
// Check doesn't generate measurement report
@ -980,14 +982,14 @@ int a1event_report_test(uint32_t a1_rsrp_th,
// Trigger again entering condition for the same cell it shouldn't trigger a new report, just keep sending the
// periodic reports without restarting counter
for (int i = 0; i < ttt_iters; i++) {
log1->info("Report %d/%d enter condition is true\n", i, ttt_iters);
rrc_meas_logger.info("Report %d/%d enter condition is true", i, ttt_iters);
enter_condition(rrctest, event_id, hyst, 0, {1});
}
// Do not expect report if timer not expired
TESTASSERT(!rrctest.get_meas_res(meas_res));
// Wait to generate all reports
for (int i = 0; i < report_amount.to_number() - 1; i++) {
log1->info("Testing report %d/%d\n", i, report_amount.to_number());
rrc_meas_logger.info("Testing report %d/%d", i, report_amount.to_number());
int interval = report_interv.to_number();
if (i == 0) {
// already stepped these iterations
@ -998,7 +1000,7 @@ int a1event_report_test(uint32_t a1_rsrp_th,
// Exit the enter condition in the last one, should still send the last report
middle_condition(rrctest, event_id, hyst, 0, {1});
} else {
log1->info("Stepping timer %d/%d\n", j, interval);
rrc_meas_logger.info("Stepping timer %d/%d", j, interval);
rrctest.run_tti(1);
}
if (j < interval - 1) {
@ -1017,7 +1019,7 @@ int a1event_report_test(uint32_t a1_rsrp_th,
}
// Trigger again condition
for (int i = 0; i < ttt_iters; i++) {
log1->info("Report %d/%d enter condition is true\n", i, ttt_iters);
rrc_meas_logger.info("Report %d/%d enter condition is true", i, ttt_iters);
enter_condition(rrctest, event_id, hyst, 0, {1});
}
// Do not expect report
@ -1025,14 +1027,14 @@ int a1event_report_test(uint32_t a1_rsrp_th,
// Leaving condition for timeToTrigger
for (int i = 0; i < ttt_iters; i++) {
log1->info("Report %d/%d leaving condition is true\n", i, ttt_iters);
rrc_meas_logger.info("Report %d/%d leaving condition is true", i, ttt_iters);
exit_condition(rrctest, event_id, hyst, 0, {1});
// Check doesn't generate measurement report
TESTASSERT(!rrctest.get_meas_res(meas_res));
}
// Trigger again condition
for (int i = 0; i < ttt_iters; i++) {
log1->info("Report %d/%d enter condition is true\n", i, ttt_iters);
rrc_meas_logger.info("Report %d/%d enter condition is true", i, ttt_iters);
enter_condition(rrctest, event_id, hyst, 0, {1});
}
// Expect report
@ -1046,12 +1048,12 @@ int a1event_report_test(uint32_t a1_rsrp_th,
// Test A3-event reporting and management of report amount and interval
int a3event_report_test(uint32_t a3_offset, uint32_t hyst, bool report_on_leave)
{
srslte::log_ref log1("RRC_MEAS"), rrc_log("RRC");
log1->set_level(srslte::LOG_LEVEL_DEBUG);
log1->set_hex_limit(-1);
rrc_log->set_level(srslte::LOG_LEVEL_DEBUG);
rrc_log->set_hex_limit(-1);
auto& rrc_meas_logger = srslog::fetch_basic_logger("RRC_MEAS");
printf("==========================================================\n");
printf("============ Report Testing A3 ===============\n");
@ -1084,14 +1086,14 @@ int a3event_report_test(uint32_t a3_offset, uint32_t hyst, bool report_on_leave)
meas_results_s meas_res = {};
log1->info("Test no-enter condition and no trigger report \n");
rrc_meas_logger.info("Test no-enter condition and no trigger report ");
no_condition(rrctest, {0}, {1});
TESTASSERT(!rrctest.get_meas_res(meas_res));
no_condition(rrctest, {0, 1}, {1, 0});
TESTASSERT(!rrctest.get_meas_res(meas_res));
log1->info("Test enter condition triggers report. 1 neighbour cell in enter + 1 in exit \n");
rrc_meas_logger.info("Test enter condition triggers report. 1 neighbour cell in enter + 1 in exit ");
float offset = 0.5 * event_id.event_a3().a3_offset;
std::vector<float> rsrp = {};
rsrp.push_back(-60 + offset + 0.5 * hyst + (float)1e-2);
@ -1110,11 +1112,11 @@ int a3event_report_test(uint32_t a3_offset, uint32_t hyst, bool report_on_leave)
81 + (hyst + a3_offset) / 2);
// Next iteration in entering state does not trigger another report
log1->info("Test enter condition for the same cell does not trigger report\n");
rrc_meas_logger.info("Test enter condition for the same cell does not trigger report");
rrctest.run_tti(1);
TESTASSERT(!rrctest.get_meas_res(meas_res));
log1->info("Test enter condition for different earfcn triggers report\n");
rrc_meas_logger.info("Test enter condition for different earfcn triggers report");
enter_condition(rrctest, event_id, hyst, 2, {1, 3});
TESTASSERT(rrctest.get_meas_res(meas_res));
TESTASSERT(meas_res.meas_id == 2);
@ -1127,7 +1129,7 @@ int a3event_report_test(uint32_t a3_offset, uint32_t hyst, bool report_on_leave)
81 + (hyst + a3_offset) / 2);
// if a new cell enters conditions then expect another report
log1->info("Test a new cell enter condition triggers report\n");
rrc_meas_logger.info("Test a new cell enter condition triggers report");
enter_condition(rrctest, event_id, hyst, 1, {1, 3});
TESTASSERT(rrctest.get_meas_res(meas_res));
TESTASSERT(meas_res.meas_id == 1);
@ -1141,14 +1143,14 @@ int a3event_report_test(uint32_t a3_offset, uint32_t hyst, bool report_on_leave)
81 + (hyst + a3_offset) / 2);
// cell pci=0 exists condition
log1->info("Test exit condition\n");
rrc_meas_logger.info("Test exit condition");
exit_condition(rrctest, event_id, hyst, 1, {1, 0});
if (report_on_leave) {
TESTASSERT(rrctest.get_meas_res(meas_res));
}
// 2 enters again, now expect report again
log1->info("Test trigger again the cell that exited\n");
rrc_meas_logger.info("Test trigger again the cell that exited");
enter_condition(rrctest, event_id, hyst, 1, {1, 0});
TESTASSERT(rrctest.get_meas_res(meas_res));
TESTASSERT(meas_res.meas_id == 1);
@ -1187,56 +1189,62 @@ int meas_obj_inter_rat_nr_test()
obj.meas_obj_id = 2;
obj.meas_obj.set_meas_obj_nr_r15();
obj.meas_obj.meas_obj_nr_r15().ext = true;
obj.meas_obj.meas_obj_nr_r15().ext = true;
obj.meas_obj.meas_obj_nr_r15().carrier_freq_r15 = 631680;
obj.meas_obj.meas_obj_nr_r15().rs_cfg_ssb_r15.meas_timing_cfg_r15.periodicity_and_offset_r15.set_sf20_r15();
obj.meas_obj.meas_obj_nr_r15().rs_cfg_ssb_r15.meas_timing_cfg_r15.ssb_dur_r15 = asn1::rrc::mtc_ssb_nr_r15_s::ssb_dur_r15_opts::options::sf1;
obj.meas_obj.meas_obj_nr_r15().rs_cfg_ssb_r15.subcarrier_spacing_ssb_r15 = asn1::rrc::rs_cfg_ssb_nr_r15_s::subcarrier_spacing_ssb_r15_opts::options::khz30;
obj.meas_obj.meas_obj_nr_r15().rs_cfg_ssb_r15.meas_timing_cfg_r15.ssb_dur_r15 =
asn1::rrc::mtc_ssb_nr_r15_s::ssb_dur_r15_opts::options::sf1;
obj.meas_obj.meas_obj_nr_r15().rs_cfg_ssb_r15.subcarrier_spacing_ssb_r15 =
asn1::rrc::rs_cfg_ssb_nr_r15_s::subcarrier_spacing_ssb_r15_opts::options::khz30;
obj.meas_obj.meas_obj_nr_r15().quant_cfg_set_r15 = 1;
obj.meas_obj.meas_obj_nr_r15().band_nr_r15.reset(new asn1::rrc::meas_obj_nr_r15_s::band_nr_r15_c_{});
obj.meas_obj.meas_obj_nr_r15().band_nr_r15->set_setup() = 78;
meas_cfg.meas_obj_to_add_mod_list.push_back(obj);
obj = {};
obj = {};
obj.meas_obj_id = 1;
obj.meas_obj.set_meas_obj_eutra();
obj.meas_obj.meas_obj_eutra().carrier_freq = 300;
obj.meas_obj.meas_obj_eutra().allowed_meas_bw = asn1::rrc::allowed_meas_bw_opts::options::mbw100;
obj.meas_obj.meas_obj_eutra().carrier_freq = 300;
obj.meas_obj.meas_obj_eutra().allowed_meas_bw = asn1::rrc::allowed_meas_bw_opts::options::mbw100;
obj.meas_obj.meas_obj_eutra().presence_ant_port1 = true;
obj.meas_obj.meas_obj_eutra().neigh_cell_cfg.from_number(01);
obj.meas_obj.meas_obj_eutra().neigh_cell_cfg.from_number(01);
meas_cfg.meas_obj_to_add_mod_list.push_back(obj);
meas_cfg.meas_obj_to_add_mod_list_present = true;
report_cfg_to_add_mod_s rep = {};
rep.report_cfg_id = 1;
report_cfg_to_add_mod_s rep = {};
rep.report_cfg_id = 1;
rep.report_cfg.set_report_cfg_inter_rat();
rep.report_cfg.report_cfg_inter_rat().ext = true;
rep.report_cfg.report_cfg_inter_rat().trigger_type.set_event();
rep.report_cfg.report_cfg_inter_rat().trigger_type.event().event_id.set_event_b1_nr_r15();
rep.report_cfg.report_cfg_inter_rat().trigger_type.event().event_id.event_b1_nr_r15().b1_thres_nr_r15.set_nr_rsrp_r15();
rep.report_cfg.report_cfg_inter_rat()
.trigger_type.event()
.event_id.event_b1_nr_r15()
.b1_thres_nr_r15.set_nr_rsrp_r15();
rep.report_cfg.report_cfg_inter_rat().trigger_type.event().event_id.event_b1_nr_r15().b1_thres_nr_r15.nr_rsrp_r15() =
56;
rep.report_cfg.report_cfg_inter_rat().trigger_type.event().event_id.event_b1_nr_r15().report_on_leave_r15 = true;
rep.report_cfg.report_cfg_inter_rat().trigger_type.event().hysteresis = 0;
rep.report_cfg.report_cfg_inter_rat().trigger_type.event().time_to_trigger = asn1::rrc::time_to_trigger_opts::options::ms100;
rep.report_cfg.report_cfg_inter_rat().trigger_type.event().hysteresis = 0;
rep.report_cfg.report_cfg_inter_rat().trigger_type.event().time_to_trigger =
asn1::rrc::time_to_trigger_opts::options::ms100;
rep.report_cfg.report_cfg_inter_rat().max_report_cells = 8;
rep.report_cfg.report_cfg_inter_rat().report_interv = asn1::rrc::report_interv_opts::options::ms120;
rep.report_cfg.report_cfg_inter_rat().report_amount = asn1::rrc::report_cfg_inter_rat_s::report_amount_opts::r1;
rep.report_cfg.report_cfg_inter_rat().report_interv = asn1::rrc::report_interv_opts::options::ms120;
rep.report_cfg.report_cfg_inter_rat().report_amount = asn1::rrc::report_cfg_inter_rat_s::report_amount_opts::r1;
rep.report_cfg.report_cfg_inter_rat().report_quant_cell_nr_r15.reset(new asn1::rrc::report_quant_nr_r15_s{});
rep.report_cfg.report_cfg_inter_rat().report_quant_cell_nr_r15->ss_rsrp = true;
rep.report_cfg.report_cfg_inter_rat().report_quant_cell_nr_r15->ss_rsrq = true;
rep.report_cfg.report_cfg_inter_rat().report_quant_cell_nr_r15->ss_sinr = true;
rep.report_cfg.report_cfg_inter_rat().report_quant_cell_nr_r15->ss_sinr = true;
meas_cfg.report_cfg_to_add_mod_list.push_back(rep);
meas_cfg.report_cfg_to_add_mod_list_present = true;
meas_cfg.meas_id_to_add_mod_list_present = true;
meas_id_to_add_mod_s meas = {};
meas.meas_id = 1;
meas.meas_obj_id = 2;
meas.report_cfg_id = 1;
meas_id_to_add_mod_s meas = {};
meas.meas_id = 1;
meas.meas_obj_id = 2;
meas.report_cfg_id = 1;
meas_cfg.meas_id_to_add_mod_list.push_back(meas);
// Just test it doesn't crash
@ -1251,7 +1259,7 @@ int meas_obj_inter_rat_nr_test()
int ttt_iters = 100 + 1; // 100 ms
for (int i = 0; i < ttt_iters; i++) {
log1->info("Report %d/%d enter condition is true\n", i, ttt_iters);
srslog::fetch_basic_logger("RRC_MEAS").info("Report %d/%d enter condition is true", i, ttt_iters);
rrctest.add_neighbour_cell_nr(500, 631680, -60.0);
}
@ -1261,6 +1269,15 @@ int meas_obj_inter_rat_nr_test()
int main(int argc, char** argv)
{
auto& rrc_meas_logger = srslog::fetch_basic_logger("RRC_MEAS", false);
rrc_meas_logger.set_level(srslog::basic_levels::debug);
rrc_meas_logger.set_hex_dump_max_size(-1);
auto& rrc_logger = srslog::fetch_basic_logger("RRC", false);
rrc_logger.set_level(srslog::basic_levels::debug);
rrc_logger.set_hex_dump_max_size(-1);
srslog::init();
TESTASSERT(cell_select_test() == SRSLTE_SUCCESS);
TESTASSERT(meas_obj_test() == SRSLTE_SUCCESS);
TESTASSERT(meas_obj_inter_rat_nr_test() == SRSLTE_SUCCESS);

@ -13,6 +13,7 @@
#include "srslte/asn1/liblte_mme.h"
#include "srslte/asn1/rrc/dl_dcch_msg.h"
#include "srslte/common/log_filter.h"
#include "srslte/srslog/srslog.h"
#include <iostream>
#include <srslte/srslte.h>
@ -146,6 +147,14 @@ int meas_obj_test()
int main(int argc, char** argv)
{
auto& nas_logger = srslog::fetch_basic_logger("NAS", false);
nas_logger.set_level(srslog::basic_levels::debug);
nas_logger.set_hex_dump_max_size(-1);
auto& rrc_logger = srslog::fetch_basic_logger("RRC", false);
rrc_logger.set_level(srslog::basic_levels::debug);
rrc_logger.set_hex_dump_max_size(-1);
srslog::init();
TESTASSERT(meas_obj_test() == 0);
TESTASSERT(nas_test() == 0);
}

@ -105,10 +105,8 @@ uint8_t ipv6_unmatched_packet_lport[] = {
int tft_filter_test_ipv6_combined()
{
srslte::log_filter log1("TFT");
log1.set_level(srslte::LOG_LEVEL_DEBUG);
log1.set_hex_limit(128);
srslte::byte_buffer_pool* pool = srslte::byte_buffer_pool::get_instance();
srslog::basic_logger& logger = srslog::fetch_basic_logger("TFT");
srslte::byte_buffer_pool* pool = srslte::byte_buffer_pool::get_instance();
srslte::unique_byte_buffer_t ip_msg1, ip_msg2, ip_msg3, ip_msg4, ip_msg5;
ip_msg1 = allocate_unique_buffer(*pool);
ip_msg2 = allocate_unique_buffer(*pool);
@ -119,27 +117,27 @@ int tft_filter_test_ipv6_combined()
// Set IP test message
ip_msg1->N_bytes = sizeof(ipv6_matched_packet);
memcpy(ip_msg1->msg, ipv6_matched_packet, sizeof(ipv6_matched_packet));
log1.info_hex(ip_msg1->msg, ip_msg1->N_bytes, "IPv6 test message - match\n");
logger.info(ip_msg1->msg, ip_msg1->N_bytes, "IPv6 test message - match");
// Set IP test message
ip_msg2->N_bytes = sizeof(ipv6_unmatched_packet_tcp);
memcpy(ip_msg2->msg, ipv6_unmatched_packet_tcp, sizeof(ipv6_unmatched_packet_tcp));
log1.info_hex(ip_msg2->msg, ip_msg2->N_bytes, "IPv6 test message - unmatched tcp\n");
logger.info(ip_msg2->msg, ip_msg2->N_bytes, "IPv6 test message - unmatched tcp");
// Set IP test message
ip_msg3->N_bytes = sizeof(ipv6_unmatched_packet_daddr);
memcpy(ip_msg3->msg, ipv6_unmatched_packet_daddr, sizeof(ipv6_unmatched_packet_daddr));
log1.info_hex(ip_msg3->msg, ip_msg3->N_bytes, "IPv6 test message - unmatched daddr\n");
logger.info(ip_msg3->msg, ip_msg3->N_bytes, "IPv6 test message - unmatched daddr");
// Set IP test message
ip_msg4->N_bytes = sizeof(ipv6_unmatched_packet_rport);
memcpy(ip_msg4->msg, ipv6_unmatched_packet_rport, sizeof(ipv6_unmatched_packet_rport));
log1.info_hex(ip_msg4->msg, ip_msg4->N_bytes, "IPv6 test message - unmatched rport\n");
logger.info(ip_msg4->msg, ip_msg4->N_bytes, "IPv6 test message - unmatched rport");
// Set IP test message
ip_msg5->N_bytes = sizeof(ipv6_unmatched_packet_lport);
memcpy(ip_msg5->msg, ipv6_unmatched_packet_lport, sizeof(ipv6_unmatched_packet_lport));
log1.info_hex(ip_msg5->msg, ip_msg5->N_bytes, "IPv6 test message - unmatched lport\n");
logger.info(ip_msg5->msg, ip_msg5->N_bytes, "IPv6 test message - unmatched lport");
// Packet filter
LIBLTE_MME_PACKET_FILTER_STRUCT packet_filter;
@ -150,7 +148,7 @@ int tft_filter_test_ipv6_combined()
packet_filter.filter_size = sizeof(ipv6_filter);
memcpy(packet_filter.filter, ipv6_filter, sizeof(ipv6_filter));
srsue::tft_packet_filter_t filter(EPS_BEARER_ID, LCID, packet_filter, &log1);
srsue::tft_packet_filter_t filter(EPS_BEARER_ID, LCID, packet_filter, logger);
// Check filter
TESTASSERT(filter.match(ip_msg1));
@ -165,9 +163,7 @@ int tft_filter_test_ipv6_combined()
int tft_filter_test_single_local_port()
{
srslte::log_filter log1("TFT");
log1.set_level(srslte::LOG_LEVEL_DEBUG);
log1.set_hex_limit(128);
srslog::basic_logger& logger = srslog::fetch_basic_logger("TFT");
srslte::byte_buffer_pool* pool = srslte::byte_buffer_pool::get_instance();
srslte::unique_byte_buffer_t ip_msg1, ip_msg2;
@ -184,12 +180,12 @@ int tft_filter_test_single_local_port()
// Set IP test message
ip_msg1->N_bytes = ip_message_len1;
memcpy(ip_msg1->msg, ip_tst_message1, ip_message_len1);
log1.info_hex(ip_msg1->msg, ip_msg1->N_bytes, "IP test message\n");
logger.info(ip_msg1->msg, ip_msg1->N_bytes, "IP test message");
// Set IP test message
ip_msg2->N_bytes = ip_message_len2;
memcpy(ip_msg2->msg, ip_tst_message2, ip_message_len1);
log1.info_hex(ip_msg2->msg, ip_msg2->N_bytes, "IP test message\n");
logger.info(ip_msg2->msg, ip_msg2->N_bytes, "IP test message");
// Packet filter
LIBLTE_MME_PACKET_FILTER_STRUCT packet_filter;
@ -200,7 +196,7 @@ int tft_filter_test_single_local_port()
packet_filter.filter_size = 3;
memcpy(packet_filter.filter, filter_message, 3);
srsue::tft_packet_filter_t filter(EPS_BEARER_ID, LCID, packet_filter, &log1);
srsue::tft_packet_filter_t filter(EPS_BEARER_ID, LCID, packet_filter, logger);
// Check filter
TESTASSERT(filter.match(ip_msg1));
@ -212,9 +208,7 @@ int tft_filter_test_single_local_port()
int tft_filter_test_single_remote_port()
{
srslte::log_filter log1("TFT");
log1.set_level(srslte::LOG_LEVEL_DEBUG);
log1.set_hex_limit(128);
srslog::basic_logger& logger = srslog::fetch_basic_logger("TFT");
srslte::byte_buffer_pool* pool = srslte::byte_buffer_pool::get_instance();
srslte::unique_byte_buffer_t ip_msg1, ip_msg2;
@ -231,12 +225,12 @@ int tft_filter_test_single_remote_port()
// Set IP test message
ip_msg1->N_bytes = ip_message_len1;
memcpy(ip_msg1->msg, ip_tst_message1, ip_message_len1);
log1.info_hex(ip_msg1->msg, ip_msg1->N_bytes, "IP test message\n");
logger.info(ip_msg1->msg, ip_msg1->N_bytes, "IP test message");
// Set IP test message
ip_msg2->N_bytes = ip_message_len2;
memcpy(ip_msg2->msg, ip_tst_message2, ip_message_len1);
log1.info_hex(ip_msg2->msg, ip_msg2->N_bytes, "IP test message\n");
logger.info(ip_msg2->msg, ip_msg2->N_bytes, "IP test message");
// Packet filter
LIBLTE_MME_PACKET_FILTER_STRUCT packet_filter;
@ -247,7 +241,7 @@ int tft_filter_test_single_remote_port()
packet_filter.filter_size = 3;
memcpy(packet_filter.filter, filter_message, 3);
srsue::tft_packet_filter_t filter(EPS_BEARER_ID, LCID, packet_filter, &log1);
srsue::tft_packet_filter_t filter(EPS_BEARER_ID, LCID, packet_filter, logger);
// Check filter
TESTASSERT(filter.match(ip_msg1));
@ -259,9 +253,7 @@ int tft_filter_test_single_remote_port()
int tft_filter_test_ipv4_local_addr()
{
srslte::log_filter log1("TFT");
log1.set_level(srslte::LOG_LEVEL_DEBUG);
log1.set_hex_limit(128);
srslog::basic_logger& logger = srslog::fetch_basic_logger("TFT");
srslte::byte_buffer_pool* pool = srslte::byte_buffer_pool::get_instance();
srslte::unique_byte_buffer_t ip_msg1, ip_msg2;
@ -281,12 +273,12 @@ int tft_filter_test_ipv4_local_addr()
// Set IP test message
ip_msg1->N_bytes = ip_message_len1;
memcpy(ip_msg1->msg, ip_tst_message1, ip_message_len1);
log1.info_hex(ip_msg1->msg, ip_msg1->N_bytes, "IP test message\n");
logger.info(ip_msg1->msg, ip_msg1->N_bytes, "IP test message");
// Set IP test message
ip_msg2->N_bytes = ip_message_len2;
memcpy(ip_msg2->msg, ip_tst_message2, ip_message_len2);
log1.info_hex(ip_msg2->msg, ip_msg2->N_bytes, "IP test message\n");
logger.info(ip_msg1->msg, ip_msg1->N_bytes, "IP test message");
// Packet filter
LIBLTE_MME_PACKET_FILTER_STRUCT packet_filter;
@ -297,7 +289,7 @@ int tft_filter_test_ipv4_local_addr()
packet_filter.filter_size = filter_size;
memcpy(packet_filter.filter, filter_message, filter_size);
srsue::tft_packet_filter_t filter(EPS_BEARER_ID, LCID, packet_filter, &log1);
srsue::tft_packet_filter_t filter(EPS_BEARER_ID, LCID, packet_filter, logger);
// Check filter
TESTASSERT(filter.match(ip_msg1));
@ -309,9 +301,7 @@ int tft_filter_test_ipv4_local_addr()
int tft_filter_test_ipv4_remote_addr()
{
srslte::log_filter log1("TFT");
log1.set_level(srslte::LOG_LEVEL_DEBUG);
log1.set_hex_limit(128);
srslog::basic_logger& logger = srslog::fetch_basic_logger("TFT");
srslte::byte_buffer_pool* pool = srslte::byte_buffer_pool::get_instance();
srslte::unique_byte_buffer_t ip_msg1, ip_msg2;
@ -330,12 +320,12 @@ int tft_filter_test_ipv4_remote_addr()
// Set IP test message
ip_msg1->N_bytes = ip_message_len1;
memcpy(ip_msg1->msg, ip_tst_message1, ip_message_len1);
log1.info_hex(ip_msg1->msg, ip_msg1->N_bytes, "IP test message\n");
logger.info(ip_msg1->msg, ip_msg1->N_bytes, "IP test message");
// Set IP test message
ip_msg2->N_bytes = ip_message_len2;
memcpy(ip_msg2->msg, ip_tst_message2, ip_message_len2);
log1.info_hex(ip_msg2->msg, ip_msg2->N_bytes, "IP test message\n");
logger.info(ip_msg2->msg, ip_msg2->N_bytes, "IP test message");
// Packet filter
LIBLTE_MME_PACKET_FILTER_STRUCT packet_filter;
@ -346,7 +336,7 @@ int tft_filter_test_ipv4_remote_addr()
packet_filter.filter_size = filter_size;
memcpy(packet_filter.filter, filter_message, filter_size);
srsue::tft_packet_filter_t filter(EPS_BEARER_ID, LCID, packet_filter, &log1);
srsue::tft_packet_filter_t filter(EPS_BEARER_ID, LCID, packet_filter, logger);
// Check filter
TESTASSERT(filter.match(ip_msg1));
@ -358,9 +348,7 @@ int tft_filter_test_ipv4_remote_addr()
int tft_filter_test_ipv4_tos()
{
srslte::log_filter log1("TFT");
log1.set_level(srslte::LOG_LEVEL_DEBUG);
log1.set_hex_limit(128);
srslog::basic_logger& logger = srslog::fetch_basic_logger("TFT");
srslte::byte_buffer_pool* pool = srslte::byte_buffer_pool::get_instance();
srslte::unique_byte_buffer_t ip_msg1, ip_msg2;
@ -380,12 +368,12 @@ int tft_filter_test_ipv4_tos()
// Set IP test message
ip_msg1->N_bytes = ip_message_len1;
memcpy(ip_msg1->msg, ip_tst_message1, ip_message_len1);
log1.info_hex(ip_msg1->msg, ip_msg1->N_bytes, "IP test message\n");
logger.info(ip_msg1->msg, ip_msg1->N_bytes, "IP test message");
// Set IP test message
ip_msg2->N_bytes = ip_message_len2;
memcpy(ip_msg2->msg, ip_tst_message2, ip_message_len2);
log1.info_hex(ip_msg2->msg, ip_msg2->N_bytes, "IP test message\n");
logger.info(ip_msg2->msg, ip_msg2->N_bytes, "IP test message");
// Packet filter
LIBLTE_MME_PACKET_FILTER_STRUCT packet_filter;
@ -396,7 +384,7 @@ int tft_filter_test_ipv4_tos()
packet_filter.filter_size = filter_size;
memcpy(packet_filter.filter, filter_message, filter_size);
srsue::tft_packet_filter_t filter(EPS_BEARER_ID, LCID, packet_filter, &log1);
srsue::tft_packet_filter_t filter(EPS_BEARER_ID, LCID, packet_filter, logger);
// Check filter
TESTASSERT(filter.match(ip_msg1));
@ -408,6 +396,11 @@ int tft_filter_test_ipv4_tos()
int main(int argc, char** argv)
{
srslog::basic_logger& logger = srslog::fetch_basic_logger("TFT", false);
logger.set_level(srslog::basic_levels::debug);
logger.set_hex_dump_max_size(128);
srslog::init();
srslte::byte_buffer_pool::get_instance();
if (tft_filter_test_single_local_port()) {
return -1;

@ -10,10 +10,8 @@
*
*/
#include "srslte/common/log_filter.h"
#include "srslte/common/test_common.h"
#include "srsue/hdr/stack/upper/usim.h"
#include <iostream>
using namespace srsue;
@ -45,18 +43,23 @@ AUTN : d7.44.51.9b.25.aa.80.00.84.ba.37.b0.f6.73.4d.d1.
KASME : a8.27.57.5e.ea.1a.10.17.3a.a1.bf.ce.4b.0c.21.85.e0.51.ef.bd.91.7f.fe.f5.1f.74.29.61.f9.03.7a.35.
*/
uint8_t rand_enb[] = {0x88, 0x38, 0xc3, 0x55, 0xc8, 0x78, 0xaa, 0x57, 0x21, 0x49, 0xfe, 0x69, 0xdb, 0x68, 0x6b, 0x5a};
uint8_t autn_enb[] = {0xd7, 0x44, 0x51, 0x9b, 0x25, 0xaa, 0x80, 0x00, 0x84, 0xba, 0x37, 0xb0, 0xf6, 0x73, 0x4d, 0xd1};
static uint8_t rand_enb[] =
{0x88, 0x38, 0xc3, 0x55, 0xc8, 0x78, 0xaa, 0x57, 0x21, 0x49, 0xfe, 0x69, 0xdb, 0x68, 0x6b, 0x5a};
static uint8_t autn_enb[] =
{0xd7, 0x44, 0x51, 0x9b, 0x25, 0xaa, 0x80, 0x00, 0x84, 0xba, 0x37, 0xb0, 0xf6, 0x73, 0x4d, 0xd1};
uint16 mcc = 208;
uint16 mnc = 93;
static constexpr uint16 mcc = 208;
static constexpr uint16 mnc = 93;
int main(int argc, char** argv)
{
srslte::log_filter usim_log("USIM");
uint8_t res[16];
int res_len;
uint8_t k_asme[32];
auto& logger = srslog::fetch_basic_logger("USIM", false);
// Start the log backend.
srslog::init();
uint8_t res[16];
int res_len;
uint8_t k_asme[32];
usim_args_t args;
args.algo = "milenage";
@ -66,7 +69,7 @@ int main(int argc, char** argv)
args.using_op = true;
args.op = "11111111111111111111111111111111";
srsue::usim usim(&usim_log);
srsue::usim usim(logger);
usim.init(&args);
TESTASSERT(usim.generate_authentication_response(rand_enb, autn_enb, mcc, mnc, res, &res_len, k_asme) == AUTH_OK);

Loading…
Cancel
Save