now the whole ue and enb mac uses the logmap

This commit is contained in:
Francisco Paisana 2020-03-19 15:45:30 +00:00 committed by Francisco Paisana
parent 5846e64a4d
commit 82cb6baef0
43 changed files with 432 additions and 469 deletions

View File

@ -31,7 +31,6 @@
#define SRSLTE_LOG_H
#include <algorithm>
#include <map>
#include <stdint.h>
#include <string>

View File

@ -31,8 +31,6 @@
namespace srslte {
class log_filter;
class log_ref
{
using ptr_type = std::unique_ptr<log>*;
@ -40,6 +38,7 @@ class log_ref
public:
log_ref() = default;
explicit log_ref(ptr_type p) : ptr_(p) {}
explicit log_ref(const char* name);
// works like a log*
log* operator->() { return ptr_->get(); }

View File

@ -23,7 +23,7 @@
#define SRSLTE_PDU_H
#include "srslte/common/interfaces_common.h"
#include "srslte/common/log.h"
#include "srslte/common/logmap.h"
#include <stdint.h>
#include <stdio.h>
#include <vector>
@ -37,10 +37,10 @@ template <class SubH>
class pdu
{
public:
pdu(uint32_t max_subheaders_, srslte::log* log_) :
pdu(uint32_t max_subheaders_, log_ref log_h_) :
max_subheaders(max_subheaders_),
subheaders(max_subheaders_),
log(log_),
log_h(log_h_),
nof_subheaders(0),
cur_idx(-1),
pdu_len(0),
@ -138,8 +138,9 @@ public:
// stop processing last subheader indicates another one but all bytes are consume
nof_subheaders = 0;
INFO("Corrupted MAC PDU - all bytes have been consumed (pdu_len=%d)\n", pdu_len);
if (log) {
log->info_hex(init_ptr, pdu_len, "Corrupted MAC PDU - all bytes have been consumed (pdu_len=%d)\n", pdu_len);
if (log_h) {
log_h->info_hex(
init_ptr, pdu_len, "Corrupted MAC PDU - all bytes have been consumed (pdu_len=%d)\n", pdu_len);
}
}
} while (ret && (nof_subheaders + 1) < (int)max_subheaders && ((int32_t)pdu_len > (ptr - init_ptr)));
@ -159,7 +160,7 @@ protected:
bool pdu_is_ul;
byte_buffer_t* buffer_tx = nullptr;
int last_sdu_idx;
srslte::log* log = nullptr;
srslte::log_ref log_h;
/* Prepares the PDU for parsing or writing by setting the number of subheaders to 0 and the pdu length */
virtual void init_(byte_buffer_t* buffer_tx_, uint32_t pdu_len_bytes, bool is_ulsch)
@ -301,11 +302,11 @@ private:
class sch_pdu : public pdu<sch_subh>
{
public:
sch_pdu(uint32_t max_subh, srslte::log* log) : pdu(max_subh, log) {}
sch_pdu(uint32_t max_subh, const log_ref& log_h_) : pdu(max_subh, log_h_) {}
void parse_packet(uint8_t* ptr);
uint8_t* write_packet();
uint8_t* write_packet(srslte::log* log);
uint8_t* write_packet(srslte::log_ref log);
bool has_space_ce(uint32_t nbytes, bool var_len = false);
bool has_space_sdu(uint32_t nbytes);
int get_pdu_len();
@ -366,7 +367,7 @@ private:
class rar_pdu : public pdu<rar_subh>
{
public:
rar_pdu(uint32_t max_rars = 16, srslte::log* log_ = nullptr);
rar_pdu(uint32_t max_rars = 16, srslte::log_ref log_ = {});
void set_backoff(uint8_t bi);
bool has_backoff();
@ -383,7 +384,7 @@ private:
class mch_pdu : public sch_pdu
{
public:
mch_pdu(uint32_t max_subh, srslte::log* log) : sch_pdu(max_subh, log) {}
mch_pdu(uint32_t max_subh, const log_ref& log_h_) : sch_pdu(max_subh, log_h_) {}
private:
/* Prepares the PDU for parsing or writing by setting the number of subheaders to 0 and the pdu length */

View File

@ -42,8 +42,8 @@ public:
virtual void process_pdu(uint8_t* buff, uint32_t len, channel_t channel) = 0;
};
pdu_queue(uint32_t pool_size = DEFAULT_POOL_SIZE) : pool(pool_size), callback(NULL), log_h(NULL) {}
void init(process_callback* callback, log* log_h_);
pdu_queue(uint32_t pool_size = DEFAULT_POOL_SIZE) : pool(pool_size), callback(NULL) {}
void init(process_callback* callback, log_ref log_h_);
uint8_t* request(uint32_t len);
void deallocate(uint8_t* pdu);
@ -69,7 +69,7 @@ private:
buffer_pool<pdu_t> pool;
process_callback* callback;
log* log_h;
log_ref log_h;
};
} // namespace srslte

View File

@ -137,7 +137,7 @@ struct mutexed_tprof<Prof, false> {
explicit mutexed_tprof(Args&&... args)
{
}
measure start() {}
measure start() { return measure{}; }
};
struct avg_time_stats {

View File

@ -25,6 +25,11 @@
using namespace srslte;
log_ref::log_ref(const char* name)
{
ptr_ = srslte::logmap::get(name).ptr_;
}
logmap::logmap() : logger_stdout_val(new logger_stdout{})
{
default_logger = logger_stdout_val.get();

View File

@ -59,8 +59,8 @@ void sch_pdu::parse_packet(uint8_t* ptr)
subheaders[nof_subheaders - 1].set_payload_size(n_sub);
} else {
ERROR("Corrupted MAC PDU (read_len=%d, pdu_len=%d)\n", read_len, pdu_len);
if (log) {
log->info_hex(ptr, pdu_len, "Corrupted MAC PDU (read_len=%d, pdu_len=%d)\n", read_len, pdu_len);
if (log_h) {
log_h->info_hex(ptr, pdu_len, "Corrupted MAC PDU (read_len=%d, pdu_len=%d)\n", read_len, pdu_len);
}
// reset PDU
@ -71,11 +71,11 @@ void sch_pdu::parse_packet(uint8_t* ptr)
uint8_t* sch_pdu::write_packet()
{
return write_packet(NULL);
return write_packet(srslte::log_ref{"MAC "});
}
/* Writes the MAC PDU in the packet, including the MAC headers and CE payload. Section 6.1.2 */
uint8_t* sch_pdu::write_packet(srslte::log* log_h)
uint8_t* sch_pdu::write_packet(srslte::log_ref log_h)
{
// set padding to remaining length in PDU
uint32_t num_padding = rem_len;
@ -858,7 +858,7 @@ void rar_pdu::fprint(FILE* stream)
pdu::fprint(stream);
}
rar_pdu::rar_pdu(uint32_t max_rars_, srslte::log* log_) : pdu(max_rars_, log_)
rar_pdu::rar_pdu(uint32_t max_rars_, srslte::log_ref log_) : pdu(max_rars_, log_)
{
backoff_indicator = 0;
has_backoff_indicator = false;

View File

@ -28,7 +28,7 @@
namespace srslte {
void pdu_queue::init(process_callback* callback_, log* log_h_)
void pdu_queue::init(process_callback* callback_, log_ref log_h_)
{
callback = callback_;
log_h = log_h_;

View File

@ -182,9 +182,9 @@ int mac_sch_pdu_pack_test1()
rlc_dummy rlc;
srslte::log_filter mac_log("MAC");
mac_log.set_level(srslte::LOG_LEVEL_DEBUG);
mac_log.set_hex_limit(100000);
srslte::log_ref mac_log = srslte::logmap::get("MAC");
mac_log->set_level(srslte::LOG_LEVEL_DEBUG);
mac_log->set_hex_limit(100000);
// create RLC SDUs
const uint32_t sdu_len = 8;
@ -192,7 +192,7 @@ int mac_sch_pdu_pack_test1()
rlc.write_sdu(2, sdu_len);
const uint32_t pdu_size = 25;
srslte::sch_pdu pdu(10, &mac_log);
srslte::sch_pdu pdu(10, mac_log);
byte_buffer_t buffer;
pdu.init_tx(&buffer, pdu_size, true);
@ -215,11 +215,11 @@ int mac_sch_pdu_pack_test1()
TESTASSERT(pdu.rem_size() == pdu_size - 16 - 3);
// write PDU
TESTASSERT(pdu.write_packet(&mac_log) == buffer.msg);
TESTASSERT(pdu.write_packet(mac_log) == buffer.msg);
TESTASSERT(buffer.N_bytes == pdu_size);
// log
mac_log.info_hex(buffer.msg, buffer.N_bytes, "MAC PDU (%d B):\n", buffer.N_bytes);
mac_log->info_hex(buffer.msg, buffer.N_bytes, "MAC PDU (%d B):\n", buffer.N_bytes);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(buffer.msg, buffer.N_bytes, 0x1001, true, 1);
@ -244,9 +244,9 @@ int mac_sch_pdu_pack_test2()
rlc_dummy rlc;
srslte::log_filter mac_log("MAC");
mac_log.set_level(srslte::LOG_LEVEL_DEBUG);
mac_log.set_hex_limit(100000);
srslte::log_ref mac_log = srslte::logmap::get("MAC");
mac_log->set_level(srslte::LOG_LEVEL_DEBUG);
mac_log->set_hex_limit(100000);
// create RLC SDUs
const uint32_t sdu_len = 8;
@ -255,7 +255,7 @@ int mac_sch_pdu_pack_test2()
const uint32_t pdu_size = 21;
srslte::sch_pdu pdu(10, &mac_log);
srslte::sch_pdu pdu(10, mac_log);
byte_buffer_t buffer;
pdu.init_tx(&buffer, pdu_size, true);
@ -278,10 +278,10 @@ int mac_sch_pdu_pack_test2()
TESTASSERT(pdu.rem_size() == pdu_size - 16 - 3);
// write PDU
pdu.write_packet(&mac_log);
pdu.write_packet(mac_log);
// log
mac_log.info_hex(buffer.msg, buffer.N_bytes, "MAC PDU (%d B):\n", buffer.N_bytes);
mac_log->info_hex(buffer.msg, buffer.N_bytes, "MAC PDU (%d B):\n", buffer.N_bytes);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(buffer.msg, buffer.N_bytes, 0x1001, true, 1);
@ -312,9 +312,7 @@ int mac_sch_pdu_pack_test3()
rlc_dummy rlc;
srslte::log_filter mac_log("MAC");
mac_log.set_level(srslte::LOG_LEVEL_DEBUG);
mac_log.set_hex_limit(100000);
srslte::log_ref mac_log("MAC");
// create RLC SDUs
// const uint32_t sdu_len = 130;
@ -322,7 +320,7 @@ int mac_sch_pdu_pack_test3()
rlc.write_sdu(2, 130);
const uint32_t pdu_size = 150;
srslte::sch_pdu pdu(10, &mac_log);
srslte::sch_pdu pdu(10, srslte::log_ref{"MAC"});
byte_buffer_t buffer;
pdu.init_tx(&buffer, pdu_size, true);
@ -345,10 +343,10 @@ int mac_sch_pdu_pack_test3()
TESTASSERT(pdu.rem_size() == pdu_size - 138 - 3);
// write PDU
pdu.write_packet(&mac_log);
pdu.write_packet(srslte::log_ref{"MAC"});
// log
mac_log.info_hex(buffer.msg, buffer.N_bytes, "MAC PDU (%d B):\n", buffer.N_bytes);
mac_log->info_hex(buffer.msg, buffer.N_bytes, "MAC PDU (%d B):\n", buffer.N_bytes);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(buffer.msg, buffer.N_bytes, 0x1001, true, 1);
@ -371,12 +369,10 @@ int mac_sch_pdu_pack_test4()
rlc_dummy rlc;
srslte::log_filter mac_log("MAC");
mac_log.set_level(srslte::LOG_LEVEL_DEBUG);
mac_log.set_hex_limit(100000);
srslte::log_ref mac_log("MAC");
const uint32_t pdu_size = 10;
srslte::sch_pdu pdu(10, &mac_log);
srslte::sch_pdu pdu(10, srslte::log_ref{"MAC"});
byte_buffer_t buffer;
pdu.init_tx(&buffer, pdu_size, true);
@ -394,13 +390,13 @@ int mac_sch_pdu_pack_test4()
pdu.del_subh();
// write PDU
pdu.write_packet(&mac_log);
pdu.write_packet(srslte::log_ref{"MAC"});
// make sure full PDU has been written
TESTASSERT(buffer.N_bytes == pdu_size);
// log
mac_log.info_hex(buffer.msg, buffer.N_bytes, "MAC PDU (%d B):\n", buffer.N_bytes);
mac_log->info_hex(buffer.msg, buffer.N_bytes, "MAC PDU (%d B):\n", buffer.N_bytes);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(buffer.msg, buffer.N_bytes, 0x1001, true, 1);
@ -417,15 +413,13 @@ int mac_sch_pdu_pack_test5()
{
rlc_dummy rlc;
srslte::log_filter mac_log("MAC");
mac_log.set_level(srslte::LOG_LEVEL_DEBUG);
mac_log.set_hex_limit(32);
srslte::log_ref mac_log("MAC");
// write big SDU
rlc.write_sdu(2, 20000);
const uint32_t pdu_size = SRSLTE_MAX_TBSIZE_BITS / 8; // Max. DL allocation for a single TB using 256 QAM
srslte::sch_pdu pdu(10, &mac_log);
srslte::sch_pdu pdu(10, srslte::log_ref{"MAC"});
byte_buffer_t buffer;
pdu.init_tx(&buffer, pdu_size, true);
@ -440,13 +434,13 @@ int mac_sch_pdu_pack_test5()
TESTASSERT(pdu.get()->set_sdu(2, pdu_size - 1, &rlc) != 0);
// write PDU
pdu.write_packet(&mac_log);
pdu.write_packet(srslte::log_ref{"MAC"});
// make sure full PDU has been written
TESTASSERT(buffer.N_bytes == pdu_size);
// log
mac_log.info_hex(buffer.msg, buffer.N_bytes, "MAC PDU (%d B):\n", buffer.N_bytes);
mac_log->info_hex(buffer.msg, buffer.N_bytes, "MAC PDU (%d B):\n", buffer.N_bytes);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(buffer.msg, buffer.N_bytes, 0x1001, true, 1);
@ -458,12 +452,10 @@ int mac_sch_pdu_pack_test5()
// Test for BSR CE
int mac_sch_pdu_pack_test6()
{
srslte::log_filter mac_log("MAC");
mac_log.set_level(srslte::LOG_LEVEL_DEBUG);
mac_log.set_hex_limit(32);
srslte::log_ref mac_log("MAC");
const uint32_t pdu_size = 8;
srslte::sch_pdu pdu(10, &mac_log);
srslte::sch_pdu pdu(10, srslte::log_ref{"MAC"});
uint8_t tv[pdu_size] = {0x3e, 0x1f, 0x01, 0xfa, 0x7f, 0x00, 0x00, 0x00};
@ -481,13 +473,13 @@ int mac_sch_pdu_pack_test6()
TESTASSERT(pdu.get()->set_bsr(buff_size, srslte::sch_subh::LONG_BSR));
// write PDU
pdu.write_packet(&mac_log);
pdu.write_packet(srslte::log_ref{"MAC"});
// compare with tv
TESTASSERT(memcmp(buffer.msg, tv, buffer.N_bytes) == 0);
// log
mac_log.info_hex(buffer.msg, buffer.N_bytes, "MAC PDU (%d B):\n", buffer.N_bytes);
mac_log->info_hex(buffer.msg, buffer.N_bytes, "MAC PDU (%d B):\n", buffer.N_bytes);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(buffer.msg, buffer.N_bytes, 0x1001, true, 1);
@ -499,15 +491,13 @@ int mac_sch_pdu_pack_test6()
// Test for short MAC PDU containing padding only
int mac_sch_pdu_pack_test7()
{
srslte::log_filter mac_log("MAC");
mac_log.set_level(srslte::LOG_LEVEL_DEBUG);
mac_log.set_hex_limit(32);
srslte::log_ref mac_log("MAC");
rlc_dummy rlc;
rlc.write_sdu(1, 8);
const uint32_t pdu_size = 2;
srslte::sch_pdu pdu(10, &mac_log);
srslte::sch_pdu pdu(10, srslte::log_ref{"MAC"});
uint8_t tv[pdu_size] = {0x1f, 0x1f};
@ -529,13 +519,13 @@ int mac_sch_pdu_pack_test7()
pdu.del_subh();
// write PDU
pdu.write_packet(&mac_log);
pdu.write_packet(srslte::log_ref{"MAC"});
// compare with tv
TESTASSERT(memcmp(buffer.msg, tv, buffer.N_bytes) == 0);
// log
mac_log.info_hex(buffer.msg, buffer.N_bytes, "MAC PDU (%d B):\n", buffer.N_bytes);
mac_log->info_hex(buffer.msg, buffer.N_bytes, "MAC PDU (%d B):\n", buffer.N_bytes);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(buffer.msg, buffer.N_bytes, 0x1001, true, 1);
@ -547,10 +537,10 @@ int mac_sch_pdu_pack_test7()
// Test Packing of SCell Activation CE command
int mac_sch_pdu_pack_test8()
{
srslte::log_ref log_h = logmap::get("MAC");
srslte::log_ref log_h{"MAC"};
const uint32_t pdu_size = 2;
srslte::sch_pdu pdu(10, log_h.get());
srslte::sch_pdu pdu(10, log_h);
std::bitset<8> cc_mask(uniform_dist_u8(rand_gen));
// subheader: R|F2|E|LCID = 0|0|0|11011
@ -577,7 +567,7 @@ int mac_sch_pdu_pack_test8()
TESTASSERT(pdu.get()->set_scell_activation_cmd(cc_activ_list));
// write PDU
pdu.write_packet(log_h.get());
pdu.write_packet(log_h);
// compare with tv
TESTASSERT(memcmp(buffer.msg, tv, buffer.N_bytes) == 0);
@ -602,15 +592,13 @@ int mac_sch_pdu_pack_error_test()
rlc_dummy rlc;
srslte::log_filter mac_log("MAC");
mac_log.set_level(srslte::LOG_LEVEL_DEBUG);
mac_log.set_hex_limit(100000);
srslte::log_ref mac_log("MAC");
// create RLC SDUs
rlc.write_sdu(1, 8);
const uint32_t pdu_size = 150;
srslte::sch_pdu pdu(10, &mac_log);
srslte::sch_pdu pdu(10, srslte::log_ref{"MAC"});
byte_buffer_t buffer;
pdu.init_tx(&buffer, pdu_size, true);
@ -631,7 +619,7 @@ int mac_sch_pdu_pack_error_test()
TESTASSERT(pdu.get()->set_sdu(1, 8, &rlc) == SRSLTE_ERROR);
// writing PDU fails
TESTASSERT(pdu.write_packet(&mac_log) == nullptr);
TESTASSERT(pdu.write_packet(srslte::log_ref{"MAC"}) == nullptr);
// reset buffer
buffer.clear();
@ -641,10 +629,10 @@ int mac_sch_pdu_pack_error_test()
TESTASSERT(pdu.get()->set_sdu(1, 100, &rlc) == 8); // only 8 bytes in RLC buffer
// writing PDU fails
TESTASSERT(pdu.write_packet(&mac_log));
TESTASSERT(pdu.write_packet(srslte::log_ref{"MAC"}));
// log
mac_log.info_hex(buffer.msg, buffer.N_bytes, "MAC PDU (%d B):\n", buffer.N_bytes);
mac_log->info_hex(buffer.msg, buffer.N_bytes, "MAC PDU (%d B):\n", buffer.N_bytes);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(buffer.msg, buffer.N_bytes, 0x1001, true, 1);
@ -658,12 +646,10 @@ int mac_mch_pdu_pack_test1()
static uint8_t tv[] = {0x3e, 0x02, 0x20, 0x05, 0x21, 0x0a, 0x1f, 0x0f, 0xff, 0x01, 0x02, 0x03, 0x04, 0x05, 0x02,
0x04, 0x06, 0x08, 0x0a, 0x0c, 0x0e, 0x10, 0x12, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
srslte::log_filter mac_log("MAC");
mac_log.set_level(srslte::LOG_LEVEL_DEBUG);
mac_log.set_hex_limit(100000);
srslte::log_ref mac_log("MAC");
const uint32_t pdu_size = 30;
srslte::mch_pdu mch_pdu(10, &mac_log);
srslte::mch_pdu mch_pdu(10, srslte::log_ref{"MAC"});
byte_buffer_t buffer;
mch_pdu.init_tx(&buffer, pdu_size, true);
@ -685,10 +671,10 @@ int mac_mch_pdu_pack_test1()
mch_pdu.get()->set_sdu(1, 10, sdu1);
// write PDU
TESTASSERT(mch_pdu.write_packet(&mac_log) == buffer.msg);
TESTASSERT(mch_pdu.write_packet(srslte::log_ref{"MAC"}) == buffer.msg);
// log
mac_log.info_hex(buffer.msg, buffer.N_bytes, "MAC PDU (%d B):\n", buffer.N_bytes);
mac_log->info_hex(buffer.msg, buffer.N_bytes, "MAC PDU (%d B):\n", buffer.N_bytes);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(buffer.msg, buffer.N_bytes, 0x1001, true, 1);
@ -709,11 +695,7 @@ int mac_sch_pdu_unpack_test1()
{
static uint8_t tv[] = {0x3f, 0x3f, 0x21, 0x3f, 0x03, 0x00, 0x04, 0x00, 0x04};
srslte::log_filter mac_log("MAC");
mac_log.set_level(srslte::LOG_LEVEL_DEBUG);
mac_log.set_hex_limit(100000);
srslte::sch_pdu pdu(10, &mac_log);
srslte::sch_pdu pdu(10, srslte::log_ref{"MAC"});
pdu.init_rx(sizeof(tv), false);
pdu.parse_packet(tv);
@ -733,11 +715,7 @@ int mac_sch_pdu_unpack_test2()
{
static uint8_t tv[] = {0x3f, 0x3f};
srslte::log_filter mac_log("MAC");
mac_log.set_level(srslte::LOG_LEVEL_DEBUG);
mac_log.set_hex_limit(100000);
srslte::sch_pdu pdu(20, &mac_log);
srslte::sch_pdu pdu(20, srslte::log_ref{"MAC"});
pdu.init_rx(sizeof(tv), false);
pdu.parse_packet(tv);
@ -761,6 +739,10 @@ int main(int argc, char** argv)
logmap::set_default_hex_limit(100000);
logmap::set_default_log_level(LOG_LEVEL_DEBUG);
srslte::log_ref mac_log{"MAC"};
mac_log->set_level(srslte::LOG_LEVEL_DEBUG);
mac_log->set_hex_limit(100000);
if (mac_rar_pdu_unpack_test1()) {
fprintf(stderr, "mac_rar_pdu_unpack_test1 failed.\n");
return SRSLTE_ERROR;

View File

@ -149,6 +149,7 @@ private:
srslte::byte_buffer_pool* pool = nullptr;
// Radio and PHY log are in enb.cc
srslte::log_ref mac_log{"MAC "};
srslte::log_filter rlc_log;
srslte::log_filter pdcp_log;
srslte::log_filter rrc_log;

View File

@ -48,7 +48,7 @@ public:
rlc_interface_mac* rlc,
rrc_interface_mac* rrc,
stack_interface_mac_lte* stack_,
srslte::log* log_h);
srslte::log_ref log_h);
void stop();
void start_pcap(srslte::mac_pcap* pcap_);
@ -113,7 +113,7 @@ private:
rlc_interface_mac* rlc_h = nullptr;
rrc_interface_mac* rrc_h = nullptr;
stack_interface_mac_lte* stack = nullptr;
srslte::log* log_h = nullptr;
srslte::log_ref log_h;
cell_list_t cells = {};
mac_args_t args = {};

View File

@ -45,7 +45,7 @@ public:
rrc_interface_mac* rrc_,
rlc_interface_mac* rlc,
phy_interface_stack_lte* phy_,
srslte::log* log_,
srslte::log_ref log_,
uint32_t nof_rx_harq_proc = SRSLTE_FDD_NOF_HARQ,
uint32_t nof_tx_harq_proc = SRSLTE_FDD_NOF_HARQ * SRSLTE_MAX_TB);
virtual ~ue();
@ -149,10 +149,10 @@ private:
srslte::sch_pdu mac_msg_dl, mac_msg_ul;
srslte::mch_pdu mch_mac_msg_dl;
rlc_interface_mac* rlc = nullptr;
rrc_interface_mac* rrc = nullptr;
phy_interface_stack_lte* phy = nullptr;
srslte::log* log_h = nullptr;
rlc_interface_mac* rlc = nullptr;
rrc_interface_mac* rrc = nullptr;
phy_interface_stack_lte* phy = nullptr;
srslte::log_ref log_h;
sched_interface* sched = nullptr;
bool conres_id_available = false;

View File

@ -71,7 +71,6 @@ int enb_stack_lte::init(const stack_args_t& args_, const rrc_cfg_t& rrc_cfg_)
// setup logging for each layer
srslte::logmap::register_log(std::unique_ptr<srslte::log>{new log_filter{"MAC ", logger, true}});
srslte::log_ref mac_log = srslte::logmap::get("MAC ");
mac_log->set_level(args.log.mac_level);
mac_log->set_hex_limit(args.log.mac_hex_limit);
@ -111,7 +110,7 @@ int enb_stack_lte::init(const stack_args_t& args_, const rrc_cfg_t& rrc_cfg_)
rx_sockets.reset(new srslte::rx_multisocket_handler("ENBSOCKETS", &stack_log));
// Init all layers
mac.init(args.mac, rrc_cfg.cell_list, phy, &rlc, &rrc, this, mac_log.get());
mac.init(args.mac, rrc_cfg.cell_list, phy, &rlc, &rrc, this, mac_log);
rlc.init(&pdcp, &rrc, &mac, &timers, &rlc_log);
pdcp.init(&rlc, &rrc, &gtpu);
rrc.init(rrc_cfg, phy, &mac, &rlc, &pdcp, &s1ap, &gtpu, &timers, &rrc_log);

View File

@ -57,7 +57,7 @@ bool mac::init(const mac_args_t& args_,
rlc_interface_mac* rlc,
rrc_interface_mac* rrc,
stack_interface_mac_lte* stack_,
srslte::log* log_h_)
srslte::log_ref log_h_)
{
started = false;

View File

@ -40,7 +40,7 @@ ue::ue(uint16_t rnti_,
rrc_interface_mac* rrc_,
rlc_interface_mac* rlc_,
phy_interface_stack_lte* phy_,
srslte::log* log_,
srslte::log_ref log_,
uint32_t nof_rx_harq_proc_,
uint32_t nof_tx_harq_proc_) :
rnti(rnti_),

View File

@ -42,7 +42,7 @@ public:
class demux : public srslte::pdu_queue::process_callback
{
public:
demux(srslte::log* log_);
demux(srslte::log_ref log_h_);
void init(phy_interface_mac_common* phy_h_,
rlc_interface_mac* rlc,
mac_interface_demux* mac,
@ -68,6 +68,12 @@ private:
const static int MAX_BCCH_PDU_LEN = 1024;
uint8_t bcch_buffer[MAX_BCCH_PDU_LEN]; // BCCH PID has a dedicated buffer
// args
srslte::log_ref log_h;
phy_interface_mac_common* phy_h = nullptr;
rlc_interface_mac* rlc = nullptr;
mac_interface_demux* mac = nullptr;
srslte::sch_pdu mac_msg;
srslte::mch_pdu mch_mac_msg;
srslte::sch_pdu pending_mac_msg;
@ -76,15 +82,11 @@ private:
void process_sch_pdu(srslte::sch_pdu* pdu);
void process_mch_pdu(srslte::mch_pdu* pdu);
bool process_ce(srslte::sch_subh* subheader);
void parse_ta_cmd(srslte::sch_subh *subh);
void parse_ta_cmd(srslte::sch_subh* subh);
bool is_uecrid_successful;
phy_interface_mac_common* phy_h = nullptr;
srslte::log* log_h = nullptr;
srslte::timer_handler::unique_timer* time_alignment_timer = nullptr;
rlc_interface_mac* rlc = nullptr;
mac_interface_demux* mac = nullptr;
// Buffer of PDUs
srslte::pdu_queue pdus;

View File

@ -39,9 +39,7 @@ class dl_harq_entity
public:
dl_harq_entity(uint8_t cc_idx_);
bool init(srslte::log* log_h,
mac_interface_rrc::ue_rnti_t* rntis,
demux* demux_unit);
bool init(srslte::log_ref log_h, mac_interface_rrc::ue_rnti_t* rntis, demux* demux_unit);
void reset();
void start_pcap(srslte::mac_pcap* pcap_);
@ -91,7 +89,7 @@ private:
bool is_initiated;
dl_harq_entity* harq_entity;
srslte::log* log_h;
srslte::log_ref log_h;
bool is_first_tb;
bool is_new_transmission;
@ -118,14 +116,14 @@ private:
dl_sps dl_sps_assig;
std::vector<dl_harq_process> proc;
dl_harq_process bcch_proc;
demux* demux_unit = nullptr;
srslte::log* log_h = nullptr;
srslte::mac_pcap* pcap = nullptr;
mac_interface_rrc::ue_rnti_t* rntis = nullptr;
uint16_t last_temporal_crnti = 0;
int si_window_start = 0;
std::vector<dl_harq_process> proc;
dl_harq_process bcch_proc;
demux* demux_unit = nullptr;
srslte::log_ref log_h;
srslte::mac_pcap* pcap = nullptr;
mac_interface_rrc::ue_rnti_t* rntis = nullptr;
uint16_t last_temporal_crnti = 0;
int si_window_start = 0;
float average_retx = 0.0;
uint64_t nof_pkts = 0;

View File

@ -30,7 +30,7 @@
#include "proc_phr.h"
#include "proc_ra.h"
#include "proc_sr.h"
#include "srslte/common/log.h"
#include "srslte/common/logmap.h"
#include "srslte/common/mac_pcap.h"
#include "srslte/common/threads.h"
#include "srslte/common/timers.h"
@ -48,7 +48,7 @@ class mac : public mac_interface_phy_lte,
public mac_interface_demux
{
public:
mac(srslte::log* log_);
mac(const char* logname);
~mac();
bool init(phy_interface_mac_lte* phy,
rlc_interface_mac* rlc,
@ -128,7 +128,7 @@ private:
rlc_interface_mac* rlc_h = nullptr;
rrc_interface_mac* rrc_h = nullptr;
stack_interface_mac* stack_h = nullptr;
srslte::log* log_h;
srslte::log_ref log_h;
mac_interface_phy_lte::mac_phy_cfg_mbsfn_t phy_mbsfn_cfg;
// RNTI search window scheduling
@ -177,7 +177,7 @@ private:
mac_metrics_t metrics[SRSLTE_MAX_CARRIERS] = {};
bool initialized = false;
bool initialized = false;
const uint8_t PCELL_CC_IDX = 0;
};

View File

@ -53,7 +53,7 @@ namespace srsue {
class mux
{
public:
mux(srslte::log* log_);
mux(srslte::log_ref log_);
~mux(){};
void reset();
void init(rlc_interface_mac* rlc, bsr_interface_mux* bsr_procedure, phr_proc* phr_procedure_);
@ -91,7 +91,7 @@ private:
// Mutex for exclusive access
std::mutex mutex;
srslte::log* log_h = nullptr;
srslte::log_ref log_h;
rlc_interface_mac* rlc = nullptr;
bsr_interface_mux* bsr_procedure = nullptr;
phr_proc* phr_procedure = nullptr;

View File

@ -25,7 +25,7 @@
#include <map>
#include <stdint.h>
#include "srslte/common/log.h"
#include "srslte/common/logmap.h"
#include "srslte/common/timers.h"
#include "srslte/interfaces/ue_interfaces.h"
@ -55,7 +55,7 @@ class bsr_proc : public srslte::timer_callback, public bsr_interface_mux
{
public:
bsr_proc();
void init(rlc_interface_mac* rlc, srslte::log* log_h, srslte::timer_handler* timers_db);
void init(rlc_interface_mac* rlc, srslte::log_ref log_h, srslte::timer_handler* timers_db);
void step(uint32_t tti);
void reset();
void set_config(srslte::bsr_cfg_t& bsr_cfg);
@ -75,7 +75,7 @@ private:
bool reset_sr;
srslte::timer_handler* timers_db;
srslte::log* log_h;
srslte::log_ref log_h;
rlc_interface_mac* rlc;
srslte::bsr_cfg_t bsr_cfg;

View File

@ -22,7 +22,7 @@
#ifndef SRSUE_PROC_PHR_H
#define SRSUE_PROC_PHR_H
#include "srslte/common/log.h"
#include "srslte/common/logmap.h"
#include "srslte/common/timers.h"
#include "srslte/interfaces/ue_interfaces.h"
#include <stdint.h>
@ -35,7 +35,7 @@ class phr_proc : public srslte::timer_callback
{
public:
phr_proc();
void init(phy_interface_mac_lte* phy_h, srslte::log* log_h_, srslte::timer_handler* timers_db_);
void init(phy_interface_mac_lte* phy_h, srslte::log_ref log_h_, srslte::timer_handler* timers_db_);
void set_config(srslte::phr_cfg_t& cfg);
void step();
void reset();
@ -49,7 +49,7 @@ public:
private:
bool pathloss_changed();
srslte::log* log_h;
srslte::log_ref log_h;
phy_interface_mac_lte* phy_h;
srslte::timer_handler* timers_db;
srslte::phr_cfg_t phr_cfg;

View File

@ -51,7 +51,6 @@ public:
state = IDLE;
last_msg3_group = RA_GROUP_A;
phy_h = NULL;
log_h = NULL;
mux_unit = NULL;
rrc = NULL;
transmitted_contention_id = 0;
@ -68,7 +67,7 @@ public:
void init(phy_interface_mac_lte* phy_h,
rrc_interface_mac* rrc_,
srslte::log* log_h,
srslte::log_ref log_h,
mac_interface_rrc::ue_rnti_t* rntis,
srslte::timer_handler::unique_timer* time_alignment_timer_,
srslte::timer_handler::unique_timer contention_resolution_timer_,
@ -164,7 +163,7 @@ private:
void read_params();
phy_interface_mac_lte* phy_h;
srslte::log* log_h;
srslte::log_ref log_h;
mux* mux_unit;
srslte::mac_pcap* pcap;
rrc_interface_mac* rrc;

View File

@ -22,7 +22,7 @@
#ifndef SRSUE_PROC_SR_H
#define SRSUE_PROC_SR_H
#include "srslte/common/log.h"
#include "srslte/common/logmap.h"
#include "srslte/interfaces/ue_interfaces.h"
#include <stdint.h>
@ -34,7 +34,7 @@ class sr_proc
{
public:
sr_proc();
void init(phy_interface_mac_lte* phy_h, rrc_interface_mac* rrc, srslte::log* log_h);
void init(phy_interface_mac_lte* phy_h, rrc_interface_mac* rrc, srslte::log_ref log_h);
void step(uint32_t tti);
void set_config(srslte::sr_cfg_t& cfg);
void reset();
@ -51,7 +51,7 @@ private:
rrc_interface_mac* rrc;
phy_interface_mac_lte* phy_h;
srslte::log* log_h;
srslte::log_ref log_h;
bool initiated;
bool do_ra;

View File

@ -45,7 +45,7 @@ class ul_harq_entity
public:
ul_harq_entity(const uint8_t cc_idx_);
bool init(srslte::log* log_h_, mac_interface_rrc_common::ue_rnti_t* rntis_, ra_proc* ra_proc_h_, mux* mux_unit_);
bool init(srslte::log_ref log_h_, mac_interface_rrc_common::ue_rnti_t* rntis_, ra_proc* ra_proc_h_, mux* mux_unit_);
void reset();
void reset_ndi();
@ -91,7 +91,7 @@ private:
bool is_grant_configured;
bool is_initiated;
srslte::log* log_h;
srslte::log_ref log_h;
ul_harq_entity* harq_entity;
srslte_softbuffer_tx_t softbuffer;
@ -110,7 +110,7 @@ private:
mux* mux_unit = nullptr;
srslte::mac_pcap* pcap = nullptr;
srslte::log* log_h = nullptr;
srslte::log_ref log_h;
mac_interface_rrc_common::ue_rnti_t* rntis = nullptr;
srslte::ul_harq_cfg_t harq_cfg = {};

View File

@ -30,7 +30,7 @@
#include "srslte/common/block_queue.h"
#include "srslte/common/buffer_pool.h"
#include "srslte/common/common.h"
#include "srslte/common/log.h"
#include "srslte/common/logmap.h"
#include "srslte/common/security.h"
#include "srslte/common/stack_procedure.h"
#include "srslte/interfaces/ue_interfaces.h"
@ -274,7 +274,7 @@ class rrc : public rrc_interface_nas,
public srslte::timer_callback
{
public:
rrc(srslte::log* rrc_log_, stack_interface_rrc* stack_);
rrc(stack_interface_rrc* stack_);
~rrc();
void init(phy_interface_rrc_lte* phy_,
@ -362,7 +362,7 @@ private:
stack_interface_rrc* stack = nullptr;
srslte::byte_buffer_pool* pool = nullptr;
srslte::log* rrc_log = nullptr;
srslte::log_ref rrc_log;
phy_interface_rrc_lte* phy = nullptr;
mac_interface_rrc* mac = nullptr;
rlc_interface_rrc* rlc = nullptr;

View File

@ -41,7 +41,7 @@ typedef std::vector<phy_interface_rrc_lte::phy_cell_t> cell_triggered_t;
class rrc::rrc_meas
{
public:
rrc_meas(srslte::log* log_) : meas_cfg(&meas_report_list, log_), meas_report_list(&meas_cfg, log_), log_h(log_) {}
rrc_meas() : meas_cfg(&meas_report_list), meas_report_list(&meas_cfg), log_h(srslte::logmap::get("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);
@ -61,7 +61,7 @@ private:
class var_meas_report_list
{
public:
var_meas_report_list(var_meas_cfg* meas_cfg_, srslte::log* log_) : meas_cfg(meas_cfg_), log_h(log_) {}
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();
@ -85,8 +85,8 @@ private:
srslte::timer_handler::unique_timer periodic_timer = {};
};
var_meas_cfg* meas_cfg = nullptr;
srslte::log* log_h = nullptr;
rrc* rrc_ptr = nullptr;
srslte::log_ref log_h;
rrc* rrc_ptr = nullptr;
std::map<uint32_t, var_meas_report> varMeasReportList;
};
@ -95,7 +95,7 @@ private:
class var_meas_cfg
{
public:
var_meas_cfg(var_meas_report_list* meas_report_, srslte::log* log_) : meas_report(meas_report_), log_h(log_) {}
var_meas_cfg(var_meas_report_list* meas_report_) : meas_report(meas_report_), log_h(srslte::logmap::get("RRC")) {}
void init(rrc* rrc);
void reset();
phy_quant_t get_filter_a();
@ -145,14 +145,14 @@ private:
std::map<uint32_t, std::map<uint32_t, cell_trigger_state> > trigger_state;
var_meas_report_list* meas_report = nullptr;
srslte::log* log_h = nullptr;
rrc* rrc_ptr = nullptr;
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;
srslte::log* log_h = nullptr;
srslte::log_ref log_h;
rrc* rrc_ptr = nullptr;
// Static functions

View File

@ -100,8 +100,8 @@ private:
void start_si_acquire();
// conts
rrc* rrc_ptr;
srslte::log* log_h;
rrc* rrc_ptr;
srslte::log_ref log_h;
// state
srslte::timer_handler::unique_timer si_acq_timeout, si_acq_retry_timer;
@ -118,8 +118,8 @@ public:
static const char* name() { return "Serving Cell Configuration"; }
private:
rrc* rrc_ptr;
srslte::log* log_h;
rrc* rrc_ptr;
srslte::log_ref log_h;
srslte::proc_outcome_t launch_sib_acquire();
@ -176,8 +176,8 @@ public:
private:
// consts
rrc* rrc_ptr;
srslte::log* log_h;
rrc* rrc_ptr;
srslte::log_ref log_h;
// state variables
found_plmn_t found_plmns[MAX_FOUND_PLMNS];
@ -197,8 +197,8 @@ public:
private:
// const
rrc* rrc_ptr;
srslte::log* log_h;
rrc* rrc_ptr;
srslte::log_ref log_h;
// args
srslte::establishment_cause_t cause;
srslte::unique_byte_buffer_t dedicated_info_nas;
@ -225,7 +225,7 @@ public:
private:
// args
rrc* rrc_ptr;
srslte::log* log_h;
srslte::log_ref log_h;
asn1::rrc::paging_s paging;
// vars

View File

@ -142,21 +142,21 @@ private:
bool running;
srsue::stack_args_t args;
std::vector<uint32_t> proc_time;
srslte::tti_point current_tti;
// timers
srslte::timer_handler timers;
// UE stack logging
srslte::logger* logger = nullptr;
srslte::log_filter log; ///< our own log filter
srslte::log_filter mac_log;
srslte::log_filter rlc_log;
srslte::log_filter pdcp_log;
srslte::log_filter rrc_log;
srslte::log_filter usim_log;
srslte::log_filter pool_log;
srslte::logger* logger = nullptr;
srslte::log_ref stack_log; ///< our own log filter
srslte::log_ref mac_log;
srslte::log_ref rlc_log;
srslte::log_ref pdcp_log;
srslte::log_ref rrc_log;
srslte::log_ref usim_log;
srslte::log_ref nas_log;
srslte::log_ref pool_log;
// stack components
srsue::mac mac;

View File

@ -30,12 +30,12 @@
namespace srsue {
demux::demux(srslte::log* log_) :
mac_msg(20, log_),
mch_mac_msg(20, log_),
pending_mac_msg(20, log_),
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_),
rlc(NULL),
log_h(log_),
is_uecrid_successful(false),
phy_h(nullptr),
time_alignment_timer(nullptr),
@ -101,18 +101,17 @@ void demux::push_pdu_temp_crnti(uint8_t* buff, uint32_t nof_bytes)
is_uecrid_successful = false;
while (pending_mac_msg.next()) {
switch (pending_mac_msg.get()->ce_type()) {
case srslte::sch_subh::CON_RES_ID:
if (!is_uecrid_successful) {
Debug("Found Contention Resolution ID CE\n");
is_uecrid_successful = mac->contention_resolution_id_rcv(
pending_mac_msg.get()->get_con_res_id());
}
break;
case srslte::sch_subh::TA_CMD:
parse_ta_cmd(pending_mac_msg.get());
break;
default:
break;
case srslte::sch_subh::CON_RES_ID:
if (!is_uecrid_successful) {
Debug("Found Contention Resolution ID CE\n");
is_uecrid_successful = mac->contention_resolution_id_rcv(pending_mac_msg.get()->get_con_res_id());
}
break;
case srslte::sch_subh::TA_CMD:
parse_ta_cmd(pending_mac_msg.get());
break;
default:
break;
}
}
pending_mac_msg.reset();
@ -303,7 +302,8 @@ bool demux::process_ce(srslte::sch_subh* subh)
return true;
}
void demux::parse_ta_cmd(srslte::sch_subh *subh) {
void demux::parse_ta_cmd(srslte::sch_subh* subh)
{
phy_h->set_timeadv(subh->get_ta_cmd());
Info("Received TA=%d (%d/%d) \n",
subh->get_ta_cmd(),

View File

@ -34,7 +34,7 @@ namespace srsue {
dl_harq_entity::dl_harq_entity(uint8_t cc_idx_) : proc(SRSLTE_MAX_HARQ_PROC), cc_idx(cc_idx_) {}
bool dl_harq_entity::init(srslte::log* log_h_, mac_interface_rrc::ue_rnti_t* rntis_, demux* demux_unit_)
bool dl_harq_entity::init(srslte::log_ref log_h_, mac_interface_rrc::ue_rnti_t* rntis_, demux* demux_unit_)
{
demux_unit = demux_unit_;
log_h = log_h_;

View File

@ -37,7 +37,12 @@ using namespace asn1::rrc;
namespace srsue {
mac::mac(srslte::log* log_) : mch_msg(10, log_), mux_unit(log_), demux_unit(log_), pcap(nullptr), log_h(log_)
mac::mac(const char* logname) :
log_h(srslte::logmap::get(logname)),
mch_msg(10, log_h),
mux_unit(log_h),
demux_unit(log_h),
pcap(nullptr)
{
// Create PCell HARQ entities
auto ul = ul_harq_entity_ptr(new ul_harq_entity(PCELL_CC_IDX));

View File

@ -32,7 +32,7 @@
namespace srsue {
mux::mux(srslte::log* log_) : pdu_msg(MAX_NOF_SUBHEADERS, log_), log_h(log_)
mux::mux(srslte::log_ref log_) : pdu_msg(MAX_NOF_SUBHEADERS, log_), log_h(log_)
{
msg3_flush();
}

View File

@ -32,7 +32,6 @@ namespace srsue {
bsr_proc::bsr_proc()
{
log_h = NULL;
initiated = false;
current_tti = 0;
trigger_tti = 0;
@ -41,7 +40,7 @@ bsr_proc::bsr_proc()
pthread_mutex_init(&mutex, NULL);
}
void bsr_proc::init(rlc_interface_mac* rlc_, srslte::log* log_h_, srslte::timer_handler* timers_db_)
void bsr_proc::init(rlc_interface_mac* rlc_, srslte::log_ref log_h_, srslte::timer_handler* timers_db_)
{
log_h = log_h_;
rlc = rlc_;

View File

@ -38,7 +38,7 @@ phr_proc::phr_proc()
phr_cfg = {};
}
void phr_proc::init(phy_interface_mac_lte* phy_h_, srslte::log* log_h_, srslte::timer_handler* timers_db_)
void phr_proc::init(phy_interface_mac_lte* phy_h_, srslte::log_ref log_h_, srslte::timer_handler* timers_db_)
{
phy_h = phy_h_;
log_h = log_h_;

View File

@ -59,7 +59,7 @@ 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* log_h_,
srslte::log_ref log_h_,
mac_interface_rrc::ue_rnti_t* rntis_,
srslte::timer_handler::unique_timer* time_alignment_timer_,
srslte::timer_handler::unique_timer contention_resolution_timer_,

View File

@ -33,7 +33,7 @@ sr_proc::sr_proc()
initiated = false;
}
void sr_proc::init(phy_interface_mac_lte* phy_h_, rrc_interface_mac* rrc_, srslte::log* log_h_)
void sr_proc::init(phy_interface_mac_lte* phy_h_, rrc_interface_mac* rrc_, srslte::log_ref log_h_)
{
log_h = log_h_;
rrc = rrc_;

View File

@ -35,7 +35,7 @@ namespace srsue {
ul_harq_entity::ul_harq_entity(const uint8_t cc_idx_) : proc(SRSLTE_MAX_HARQ_PROC), cc_idx(cc_idx_) {}
bool ul_harq_entity::init(srslte::log* log_h_,
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_)
@ -68,9 +68,9 @@ void ul_harq_entity::reset_ndi()
}
}
void ul_harq_entity::set_config(srslte::ul_harq_cfg_t& harq_cfg)
void ul_harq_entity::set_config(srslte::ul_harq_cfg_t& harq_cfg_)
{
this->harq_cfg = harq_cfg;
harq_cfg = harq_cfg_;
}
void ul_harq_entity::start_pcap(srslte::mac_pcap* pcap_)
@ -121,7 +121,6 @@ float ul_harq_entity::get_average_retx()
ul_harq_entity::ul_harq_process::ul_harq_process()
{
log_h = NULL;
pdu_ptr = NULL;
payload_buffer = NULL;
@ -143,7 +142,7 @@ ul_harq_entity::ul_harq_process::~ul_harq_process()
}
}
bool ul_harq_entity::ul_harq_process::init(uint32_t pid, ul_harq_entity* parent)
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");
@ -153,7 +152,7 @@ bool ul_harq_entity::ul_harq_process::init(uint32_t pid, ul_harq_entity* parent)
harq_entity = parent;
log_h = harq_entity->log_h;
is_initiated = true;
this->pid = pid;
pid = pid_;
payload_buffer = std::unique_ptr<byte_buffer_t>(new byte_buffer_t);
if (!payload_buffer) {
@ -223,9 +222,11 @@ void ul_harq_entity::ul_harq_process::new_grant_ul(mac_interface_phy_lte::mac_gr
action->tb.enabled = true;
// Decide if adaptive retx or new tx. 3 checks in 5.4.2.1
} else if ((grant.rnti != harq_entity->rntis->temp_rnti && grant.tb.ndi != get_ndi()) || // If not addressed to T-CRNTI and NDI toggled
(grant.rnti == harq_entity->rntis->crnti && !has_grant()) || // If addressed to C-RNTI and buffer is empty
(grant.is_rar)) // Grant received in a RAR
} else if ((grant.rnti != harq_entity->rntis->temp_rnti &&
grant.tb.ndi != get_ndi()) || // If not addressed to T-CRNTI and NDI toggled
(grant.rnti == harq_entity->rntis->crnti &&
!has_grant()) || // If addressed to C-RNTI and buffer is empty
(grant.is_rar)) // Grant received in a RAR
{
// New transmission
reset();
@ -367,7 +368,11 @@ void ul_harq_entity::ul_harq_process::generate_new_tx(mac_interface_phy_lte::mac
current_tx_nb = 0;
current_irv = 0;
Info("UL %d: New TX%s, RV=%d, TBS=%d\n", pid, grant.rnti == harq_entity->rntis->temp_rnti ? " for Msg3" : "", get_rv(), cur_grant.tb.tbs);
Info("UL %d: New TX%s, RV=%d, TBS=%d\n",
pid,
grant.rnti == harq_entity->rntis->temp_rnti ? " for Msg3" : "",
get_rv(),
cur_grant.tb.tbs);
generate_tx(action);
}

View File

@ -83,12 +83,12 @@ bool cell_t::is_sib_scheduled(uint32_t sib_index) const
Base functions
*******************************************************************************/
rrc::rrc(srslte::log* rrc_log_, stack_interface_rrc* stack_) :
rrc::rrc(stack_interface_rrc* stack_) :
stack(stack_),
state(RRC_STATE_IDLE),
last_state(RRC_STATE_CONNECTED),
drb_up(false),
rrc_log(rrc_log_),
rrc_log(srslte::logmap::get("RRC")),
cell_searcher(this),
si_acquirer(this),
serv_cell_cfg(this),
@ -101,7 +101,7 @@ rrc::rrc(srslte::log* rrc_log_, stack_interface_rrc* stack_) :
connection_reest(this),
serving_cell(unique_cell_t(new cell_t()))
{
measurements = std::unique_ptr<rrc_meas>(new rrc_meas(rrc_log));
measurements = std::unique_ptr<rrc_meas>(new rrc_meas());
}
rrc::~rrc() = default;
@ -591,7 +591,7 @@ void rrc::log_neighbour_cells()
if (not neighbour_cells.empty()) {
const int32_t MAX_STR_LEN = 512;
char ordered[MAX_STR_LEN] = {};
int n = 0;
int n = 0;
n += snprintf(ordered, MAX_STR_LEN, "[%s", neighbour_cells[0]->to_string().c_str());
for (uint32_t i = 1; i < neighbour_cells.size(); i++) {
if (MAX_STR_LEN - n > 0) { // make sure there is still room left

View File

@ -241,7 +241,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(parent_->rrc_log),
log_h(srslte::logmap::get("RRC")),
si_acq_timeout(rrc_ptr->stack->get_unique_timer()),
si_acq_retry_timer(rrc_ptr->stack->get_unique_timer())
{
@ -363,7 +363,11 @@ proc_outcome_t rrc::si_acquire_proc::react(si_acq_timer_expired ev)
* Serving Cell Config Procedure
*************************************/
rrc::serving_cell_config_proc::serving_cell_config_proc(rrc* parent_) : rrc_ptr(parent_), log_h(parent_->rrc_log) {}
rrc::serving_cell_config_proc::serving_cell_config_proc(rrc* parent_) :
rrc_ptr(parent_),
log_h(srslte::logmap::get("RRC"))
{
}
/*
* Retrieves all required SIB or configures them if already retrieved before
@ -649,7 +653,7 @@ 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(parent_->rrc_log) {}
rrc::plmn_search_proc::plmn_search_proc(rrc* parent_) : rrc_ptr(parent_), log_h(srslte::logmap::get("RRC")) {}
proc_outcome_t rrc::plmn_search_proc::init()
{
@ -728,7 +732,11 @@ void rrc::plmn_search_proc::then(const srslte::proc_state_t& result) const
* Connection Request Procedure
*************************************/
rrc::connection_request_proc::connection_request_proc(rrc* parent_) : rrc_ptr(parent_), log_h(parent_->rrc_log) {}
rrc::connection_request_proc::connection_request_proc(rrc* parent_) :
rrc_ptr(parent_),
log_h(srslte::logmap::get("RRC"))
{
}
proc_outcome_t rrc::connection_request_proc::init(srslte::establishment_cause_t cause_,
srslte::unique_byte_buffer_t dedicated_info_nas_)
@ -892,7 +900,7 @@ srslte::proc_outcome_t rrc::connection_request_proc::react(const cell_selection_
* Process PCCH procedure
*************************************/
rrc::process_pcch_proc::process_pcch_proc(srsue::rrc* parent_) : rrc_ptr(parent_), log_h(parent_->rrc_log) {}
rrc::process_pcch_proc::process_pcch_proc(srsue::rrc* parent_) : rrc_ptr(parent_), log_h(srslte::logmap::get("RRC")) {}
proc_outcome_t rrc::process_pcch_proc::init(const asn1::rrc::paging_s& paging_)
{

View File

@ -35,12 +35,20 @@ ue_stack_lte::ue_stack_lte() :
running(false),
args(),
logger(nullptr),
stack_log("STCK"),
pool_log("POOL"),
mac_log("MAC "),
rlc_log("RLC "),
pdcp_log("PDCP"),
rrc_log("RRC "),
usim_log("USIM"),
nas_log("NAS "),
usim(nullptr),
phy(nullptr),
rlc(&rlc_log),
mac(&mac_log),
rrc(&rrc_log, this),
pdcp(&timers, &pdcp_log),
rlc(rlc_log.get()),
mac("MAC "),
rrc(this),
pdcp(&timers, pdcp_log.get()),
nas(this),
thread("STACK"),
pending_tasks(512),
@ -86,37 +94,25 @@ int ue_stack_lte::init(const stack_args_t& args_, srslte::logger* logger_)
args = args_;
logger = logger_;
// setup logging for each layer
mac_log.init("MAC ", logger, true);
rlc_log.init("RLC ", logger);
pdcp_log.init("PDCP", logger);
rrc_log.init("RRC ", logger);
usim_log.init("USIM", logger);
// init own log
stack_log->set_level(srslte::LOG_LEVEL_INFO);
pool_log->set_level(srslte::LOG_LEVEL_ERROR);
byte_buffer_pool::get_instance()->set_log(pool_log.get());
// init own logger
log.init("STCK", logger);
log.set_level(srslte::LOG_LEVEL_INFO);
pool_log.init("POOL", logger);
pool_log.set_level(srslte::LOG_LEVEL_ERROR);
byte_buffer_pool::get_instance()->set_log(&pool_log);
mac_log.set_level(args.log.mac_level);
rlc_log.set_level(args.log.rlc_level);
pdcp_log.set_level(args.log.pdcp_level);
rrc_log.set_level(args.log.rrc_level);
usim_log.set_level(args.log.usim_level);
mac_log.set_hex_limit(args.log.mac_hex_limit);
rlc_log.set_hex_limit(args.log.rlc_hex_limit);
pdcp_log.set_hex_limit(args.log.pdcp_hex_limit);
rrc_log.set_hex_limit(args.log.rrc_hex_limit);
usim_log.set_hex_limit(args.log.usim_hex_limit);
// Set NAS log
srslte::log_ref log_ptr = logmap::get("NAS");
log_ptr->set_level(args.log.nas_level);
log_ptr->set_hex_limit(args.log.nas_hex_limit);
// init layer logs
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);
rlc_log->set_level(args.log.rlc_level);
rlc_log->set_hex_limit(args.log.rlc_hex_limit);
pdcp_log->set_level(args.log.pdcp_level);
pdcp_log->set_hex_limit(args.log.pdcp_hex_limit);
rrc_log->set_level(args.log.rrc_level);
rrc_log->set_hex_limit(args.log.rrc_hex_limit);
usim_log->set_level(args.log.usim_level);
usim_log->set_hex_limit(args.log.usim_hex_limit);
nas_log->set_level(args.log.nas_level);
nas_log->set_hex_limit(args.log.nas_hex_limit);
// Set up pcap
if (args.pcap.enable) {
@ -129,9 +125,9 @@ 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);
usim = usim_base::get_instance(&args.usim, usim_log.get());
if (usim->init(&args.usim)) {
usim_log.console("Failed to initialize USIM.\n");
usim_log->console("Failed to initialize USIM.\n");
return SRSLTE_ERROR;
}
@ -217,14 +213,14 @@ bool ue_stack_lte::switch_off()
bool ue_stack_lte::enable_data()
{
// perform attach request
log.console("Turning off airplane mode.\n");
stack_log->console("Turning off airplane mode.\n");
return switch_on();
}
bool ue_stack_lte::disable_data()
{
// generate detach request
log.console("Turning on airplane mode.\n");
stack_log->console("Turning on airplane mode.\n");
int ret = nas.detach_request(false);
// schedule airplane mode off command
@ -277,7 +273,7 @@ void ue_stack_lte::write_sdu(uint32_t lcid, srslte::unique_byte_buffer_t sdu, bo
};
bool ret = pending_tasks.try_push(gw_queue_id, std::bind(task, std::move(sdu))).first;
if (not ret) {
pdcp_log.warning("GW SDU with lcid=%d was discarded.\n", lcid);
pdcp_log->warning("GW SDU with lcid=%d was discarded.\n", lcid);
}
}
@ -322,15 +318,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=%ld ms\n",
"proc_time",
std::chrono::duration_cast<std::chrono::milliseconds>(dur).count());
mac_log->warning("%s: detected long duration=%ld ms\n",
"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 (pending_tasks.size(sync_queue_id) > SYNC_QUEUE_WARN_THRESHOLD) {
log.warning("Detected slow task processing (sync_queue_len=%zd).\n", pending_tasks.size(sync_queue_id));
stack_log->warning("Detected slow task processing (sync_queue_len=%zd).\n", pending_tasks.size(sync_queue_id));
}
}

View File

@ -45,6 +45,8 @@ static std::unique_ptr<srslte::mac_pcap> pcap_handle = nullptr;
} \
}
srslte::log_ref mac_log{"MAC"};
namespace srslte {
// fake classes
@ -384,11 +386,8 @@ int mac_unpack_test()
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x13, 0x89, 0x00, 0x00};
srslte::log_filter rlc_log("RLC");
srslte::log_filter mac_log("MAC");
srslte::timer_handler timers(64);
mac_log.set_level(srslte::LOG_LEVEL_DEBUG);
mac_log.set_hex_limit(100000);
rlc_log.set_level(srslte::LOG_LEVEL_DEBUG);
rlc_log.set_hex_limit(100000);
@ -399,7 +398,7 @@ int mac_unpack_test()
stack_dummy stack;
// the actual MAC
mac mac(&mac_log);
mac mac("MAC");
stack.init(&mac, &phy);
mac.init(&phy, &rlc, &rrc, &timers, &stack);
@ -441,10 +440,6 @@ 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 mac_log("MAC");
mac_log.set_level(srslte::LOG_LEVEL_DEBUG);
mac_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);
@ -458,7 +453,7 @@ int mac_ul_sch_pdu_test1()
stack_dummy stack;
// the actual MAC
mac mac(&mac_log);
mac mac("MAC");
stack.init(&mac, &phy);
mac.init(&phy, &rlc, &rrc, &timers, &stack);
const uint16_t crnti = 0x1001;
@ -482,7 +477,7 @@ 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);
mac_log->info_hex(ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)\n", mac_grant.tb.tbs);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(ul_action.tb.payload, mac_grant.tb.tbs, 0x1001, true, 1);
#endif
@ -511,10 +506,6 @@ 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 mac_log("MAC");
mac_log.set_level(srslte::LOG_LEVEL_DEBUG);
mac_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);
@ -528,7 +519,7 @@ int mac_ul_logical_channel_prioritization_test1()
stack_dummy stack;
// the actual MAC
mac mac(&mac_log);
mac mac("MAC");
stack.init(&mac, &phy);
mac.init(&phy, &rlc, &rrc, &timers, &stack);
const uint16_t crnti = 0x1001;
@ -585,7 +576,7 @@ 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);
mac_log->info_hex(ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)\n", mac_grant.tb.tbs);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(ul_action.tb.payload, mac_grant.tb.tbs, 0x1001, true, 1);
#endif
@ -626,10 +617,6 @@ int mac_ul_logical_channel_prioritization_test2()
0x02, 0x02, 0x02, 0x02, 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, 0x00};
srslte::log_filter mac_log("MAC");
mac_log.set_level(srslte::LOG_LEVEL_DEBUG);
mac_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);
@ -643,7 +630,7 @@ int mac_ul_logical_channel_prioritization_test2()
stack_dummy stack;
// the actual MAC
mac mac(&mac_log);
mac mac("MAC");
stack.init(&mac, &phy);
mac.init(&phy, &rlc, &rrc, &timers, &stack);
const uint16_t crnti = 0x1001;
@ -700,7 +687,7 @@ 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);
mac_log->info_hex(ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)\n", mac_grant.tb.tbs);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(ul_action.tb.payload, mac_grant.tb.tbs, 0x1001, true, 1);
#endif
@ -728,10 +715,6 @@ 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 mac_log("MAC");
mac_log.set_level(srslte::LOG_LEVEL_DEBUG);
mac_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);
@ -745,7 +728,7 @@ int mac_ul_logical_channel_prioritization_test3()
stack_dummy stack;
// the actual MAC
mac mac(&mac_log);
mac mac("MAC");
stack.init(&mac, &phy);
mac.init(&phy, &rlc, &rrc, &timers, &stack);
const uint16_t crnti = 0x1001;
@ -797,7 +780,7 @@ 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);
mac_log->info_hex(ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)\n", mac_grant.tb.tbs);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(ul_action.tb.payload, mac_grant.tb.tbs, 0x1001, true, 1);
#endif
@ -818,10 +801,6 @@ int mac_ul_sch_pdu_with_short_bsr_test()
{
const uint8_t tv[] = {0x3f, 0x3d, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01};
srslte::log_filter mac_log("MAC");
mac_log.set_level(srslte::LOG_LEVEL_DEBUG);
mac_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);
@ -835,7 +814,7 @@ int mac_ul_sch_pdu_with_short_bsr_test()
stack_dummy stack;
// the actual MAC
mac mac(&mac_log);
mac mac("MAC");
stack.init(&mac, &phy);
mac.init(&phy, &rlc, &rrc, &timers, &stack);
const uint16_t crnti = 0x1001;
@ -887,7 +866,7 @@ 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);
mac_log->info_hex(ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)\n", mac_grant.tb.tbs);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(ul_action.tb.payload, mac_grant.tb.tbs, 0x1001, true, 1);
#endif
@ -906,10 +885,6 @@ int mac_ul_sch_pdu_with_short_bsr_test()
// PDU with only padding BSR (long BSR) and the rest padding
int mac_ul_sch_pdu_with_padding_bsr_test()
{
srslte::log_filter mac_log("MAC");
mac_log.set_level(srslte::LOG_LEVEL_DEBUG);
mac_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);
@ -923,7 +898,7 @@ int mac_ul_sch_pdu_with_padding_bsr_test()
stack_dummy stack;
// the actual MAC
mac mac(&mac_log);
mac mac("MAC");
stack.init(&mac, &phy);
mac.init(&phy, &rlc, &rrc, &timers, &stack);
const uint16_t crnti = 0x1001;
@ -947,7 +922,7 @@ int mac_ul_sch_pdu_with_padding_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);
mac_log->info_hex(ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)\n", mac_grant.tb.tbs);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(ul_action.tb.payload, mac_grant.tb.tbs, 0x1001, true, 1);
#endif
@ -982,7 +957,7 @@ int mac_ul_sch_pdu_with_padding_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);
mac_log->info_hex(ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)\n", mac_grant.tb.tbs);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(ul_action.tb.payload, mac_grant.tb.tbs, 0x1001, true, 1);
#endif
@ -1003,10 +978,6 @@ int mac_ul_sch_pdu_one_byte_test()
{
const uint8_t tv[] = {0x1f};
srslte::log_filter mac_log("MAC");
mac_log.set_level(srslte::LOG_LEVEL_DEBUG);
mac_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);
@ -1020,7 +991,7 @@ int mac_ul_sch_pdu_one_byte_test()
stack_dummy stack;
// the actual MAC
mac mac(&mac_log);
mac mac("MAC");
stack.init(&mac, &phy);
mac.init(&phy, &rlc, &rrc, &timers, &stack);
const uint16_t crnti = 0x1001;
@ -1044,7 +1015,7 @@ 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);
mac_log->info_hex(ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)\n", mac_grant.tb.tbs);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(ul_action.tb.payload, mac_grant.tb.tbs, 0x1001, true, 1);
#endif
@ -1065,10 +1036,6 @@ int mac_ul_sch_pdu_two_byte_test()
{
const uint8_t tv[] = {0x01, 0x01};
srslte::log_filter mac_log("MAC");
mac_log.set_level(srslte::LOG_LEVEL_DEBUG);
mac_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);
@ -1082,7 +1049,7 @@ int mac_ul_sch_pdu_two_byte_test()
stack_dummy stack;
// the actual MAC
mac mac(&mac_log);
mac mac("MAC");
stack.init(&mac, &phy);
mac.init(&phy, &rlc, &rrc, &timers, &stack);
const uint16_t crnti = 0x1001;
@ -1106,7 +1073,7 @@ 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);
mac_log->info_hex(ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)\n", mac_grant.tb.tbs);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(ul_action.tb.payload, mac_grant.tb.tbs, 0x1001, true, 1);
#endif
@ -1127,10 +1094,6 @@ int mac_ul_sch_pdu_three_byte_test()
{
const uint8_t tv[] = {0x3f, 0x01, 0x01};
srslte::log_filter mac_log("MAC");
mac_log.set_level(srslte::LOG_LEVEL_DEBUG);
mac_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);
@ -1144,7 +1107,7 @@ int mac_ul_sch_pdu_three_byte_test()
stack_dummy stack;
// the actual MAC
mac mac(&mac_log);
mac mac("MAC");
stack.init(&mac, &phy);
mac.init(&phy, &rlc, &rrc, &timers, &stack);
const uint16_t crnti = 0x1001;
@ -1168,7 +1131,7 @@ 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);
mac_log->info_hex(ul_action.tb.payload, mac_grant.tb.tbs, "Generated PDU (%d B)\n", mac_grant.tb.tbs);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(ul_action.tb.payload, mac_grant.tb.tbs, 0x1001, true, 1);
#endif
@ -1371,10 +1334,6 @@ int mac_random_access_test()
phy_log.set_level(srslte::LOG_LEVEL_DEBUG);
phy_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);
srslte::log_filter rlc_log("RLC");
rlc_log.set_level(srslte::LOG_LEVEL_DEBUG);
rlc_log.set_hex_limit(100000);
@ -1399,7 +1358,7 @@ int mac_random_access_test()
asn1::rrc::rach_cfg_common_s::ra_supervision_info_s_::mac_contention_resolution_timer_opts::sf8;
// Configure MAC
mac mac(&mac_log);
mac mac("MAC");
stack.init(&mac, &phy);
mac.init(&phy, &rlc, &rrc, &timers, &stack);
srslte::mac_cfg_t mac_cfg;
@ -1437,7 +1396,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++);
mac_log->info("\n=========== Test %d =============\n", 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, &timers));
@ -1455,7 +1414,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++);
mac_log->info("\n=========== Test %d =============\n", 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();
@ -1464,7 +1423,7 @@ int mac_random_access_test()
// Test 3: RAR received but no matching 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++);
mac_log->info("\n=========== Test %d =============\n", 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, &timers));
@ -1472,14 +1431,14 @@ 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++);
mac_log->info("\n=========== Test %d =============\n", test_id++);
phy.reset();
my_test.nof_msg3_retx = 0;
my_test.msg4_enable = true;
TESTASSERT(!run_mac_ra_test(my_test, &mac, &phy, &tti, &timers));
// 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++);
mac_log->info("\n=========== Test %d =============\n", 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;
@ -1491,7 +1450,7 @@ int mac_random_access_test()
// To trigger a new RA we have to either generate more data for DRB or wait until BSR-reTX is triggered
rlc.write_sdu(3, 100);
phy.set_crnti(0);
mac_log.info("\n=========== Test %d =============\n", test_id++);
mac_log->info("\n=========== Test %d =============\n", 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;
@ -1502,7 +1461,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++);
mac_log->info("\n=========== Test %d =============\n", test_id++);
phy.set_prach_tti(tti + phy.prach_delay);
phy.set_crnti(0);
mac.start_cont_ho();
@ -1519,7 +1478,7 @@ int mac_random_access_test()
TESTASSERT(!rrc.ho_finish_successful && rrc.ho_finish);
// 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++);
mac_log->info("\n=========== Test %d =============\n", test_id++);
phy.set_prach_tti(tti + phy.prach_delay);
phy.set_crnti(0);
mac.start_cont_ho();
@ -1535,7 +1494,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++);
mac_log->info("\n=========== Test %d =============\n", test_id++);
phy.set_prach_tti(tti + phy.prach_delay);
mac.run_tti(tti++);
timers.step_all();
@ -1553,7 +1512,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++);
mac_log->info("\n=========== Test %d =============\n", test_id++);
phy.set_prach_tti(tti + phy.prach_delay);
mac.run_tti(tti++);
timers.step_all();
@ -1582,6 +1541,9 @@ 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);
if (mac_unpack_test()) {
printf("MAC PDU unpack test failed.\n");
return -1;

View File

@ -49,8 +49,10 @@ class ttcn3_syssim : public syssim_interface_phy,
{
public:
ttcn3_syssim(srslte::logger_file* logger_file_, ttcn3_ue* ue_) :
mac_msg_ul(20, &ss_mac_log),
mac_msg_dl(20, &ss_mac_log),
log{"SS "},
ss_mac_log{"SS-MAC"},
mac_msg_ul(20, ss_mac_log),
mac_msg_dl(20, ss_mac_log),
timers(8),
pdus(128),
logger(logger_file_),
@ -80,59 +82,58 @@ public:
}
// init and configure logging
log.init("SS ", logger, true);
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);
ss_mac_log.init("SS-MAC", logger);
ss_rlc_log.init("SS-RLC", logger);
ss_pdcp_log.init("SS-PDCP", logger);
log.set_level(args.log.all_level);
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);
ss_mac_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);
log.set_hex_limit(args.log.all_hex_limit);
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);
ss_mac_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);
// Init epoll socket and add FDs
epoll_fd = epoll_create1(0);
if (epoll_fd == -1) {
log.error("Error creating epoll\n");
log->error("Error creating epoll\n");
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");
log->error("Error while adding signalfd to epoll\n");
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");
log->error("Error creating port handlers\n");
return SRSLTE_ERROR;
}
// Init SS layers
pdus.init(this, &log);
pdus.init(this, log);
rlc.init(&pdcp, this, &timers, 0 /* RB_ID_SRB0 */);
pdcp.init(&rlc, this, nullptr);
@ -146,47 +147,47 @@ public:
// UT port
int ut_fd = ut.init(this, &ut_log, listen_address, UT_PORT);
if (add_epoll(ut_fd, epoll_fd) != SRSLTE_SUCCESS) {
log.error("Error while adding UT port to epoll\n");
log->error("Error while adding UT port to epoll\n");
return SRSLTE_ERROR;
}
event_handler.insert({ut_fd, &ut});
log.console("UT handler listening on SCTP port %d\n", UT_PORT);
log->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);
if (add_epoll(sys_fd, epoll_fd) != SRSLTE_SUCCESS) {
log.error("Error while adding SYS port to epoll\n");
log->error("Error while adding SYS port to epoll\n");
return SRSLTE_ERROR;
}
event_handler.insert({sys_fd, &sys});
log.console("SYS handler listening on SCTP port %d\n", SYS_PORT);
log->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);
if (add_epoll(ip_sock_fd, epoll_fd) != SRSLTE_SUCCESS) {
log.error("Error while adding IP sock port to epoll\n");
log->error("Error while adding IP sock port to epoll\n");
return SRSLTE_ERROR;
}
event_handler.insert({ip_sock_fd, &ip_sock});
log.console("IPSOCK handler listening on SCTP port %d\n", IPSOCK_PORT);
log->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);
if (add_epoll(ip_ctrl_fd, epoll_fd) != SRSLTE_SUCCESS) {
log.error("Error while adding IP ctrl port to epoll\n");
log->error("Error while adding IP ctrl port to epoll\n");
return SRSLTE_ERROR;
}
event_handler.insert({ip_ctrl_fd, &ip_ctrl});
log.console("IPCTRL handler listening on SCTP port %d\n", IPCTRL_PORT);
log->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);
if (add_epoll(srb_fd, epoll_fd) != SRSLTE_SUCCESS) {
log.error("Error while adding SRB port to epoll\n");
log->error("Error while adding SRB port to epoll\n");
return SRSLTE_ERROR;
}
event_handler.insert({srb_fd, &srb});
log.console("SRB handler listening on SCTP port %d\n", SRB_PORT);
log->console("SRB handler listening on SCTP port %d\n", SRB_PORT);
return SRSLTE_SUCCESS;
}
@ -196,15 +197,15 @@ public:
{
tti = (tti + 1) % 10240;
log.step(tti);
log.debug("Start TTI\n");
log->step(tti);
log->debug("Start TTI\n");
ue->set_current_tti(tti);
// 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");
log->debug("Running scheduled action\n");
move_task_t task = std::move(tti_actions[tti].back());
task();
tti_actions[tti].pop_back();
@ -213,7 +214,7 @@ public:
// trying to apply pending PDCP config
if (not pending_bearer_config.empty()) {
log.debug("Trying to apply pending PDCP config\n");
log->debug("Trying to apply pending PDCP config\n");
pending_bearer_config = try_set_pdcp_security(pending_bearer_config);
}
@ -222,26 +223,26 @@ public:
ss_events_t ev = event_queue.wait_pop();
switch (ev) {
case UE_SWITCH_ON:
log.console("Switching on UE ID=%d\n", run_id);
log->console("Switching on UE ID=%d\n", run_id);
ue->switch_on();
break;
case UE_SWITCH_OFF:
log.console("Switching off UE ID=%d\n", run_id);
log->console("Switching off UE ID=%d\n", run_id);
ue->switch_off();
break;
case ENABLE_DATA:
log.console("Enabling data for UE ID=%d\n", run_id);
log->console("Enabling data for UE ID=%d\n", run_id);
ue->enable_data();
break;
case DISABLE_DATA:
log.console("Disabling data for UE ID=%d\n", run_id);
log->console("Disabling data for UE ID=%d\n", run_id);
ue->disable_data();
break;
}
}
if (pcell_idx == -1) {
log.debug("Skipping TTI. Pcell not yet selected.\n");
log->debug("Skipping TTI. Pcell not yet selected.\n");
return;
}
@ -255,7 +256,7 @@ public:
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);
log->info("Delivered SIB%d for pcell_idx=%d\n", 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) {
@ -265,12 +266,12 @@ public:
}
}
} else if (SRSLTE_RNTI_ISPA(dl_rnti)) {
log.debug("Searching for paging RNTI\n");
log->debug("Searching for paging RNTI\n");
// 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 == crnti) {
log.debug("Searching for C-RNTI=%d\n", crnti);
log->debug("Searching for C-RNTI=%d\n", crnti);
if (rar_tti != -1) {
msg3_tti = (rar_tti + 3) % 10240;
@ -287,14 +288,14 @@ public:
}
if (dl_rnti != SRSLTE_INVALID_RNTI) {
log.debug("Searching for RNTI=%d\n", dl_rnti);
log->debug("Searching for RNTI=%d\n", 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++) {
uint32_t buf_state = rlc.get_buffer_state(lcid);
// Schedule DL transmission if there is data in RLC buffer or we need to send Msg4
if ((buf_state > 0 && bearer_follow_on_map[lcid] == false) || (msg3_tti != -1 && conres_id != 0)) {
log.debug("LCID=%d, buffer_state=%d\n", lcid, buf_state);
log->debug("LCID=%d, buffer_state=%d\n", lcid, buf_state);
tx_payload_buffer.clear();
const uint32_t mac_header_size = 10; // Add MAC header (10 B for all subheaders, etc)
@ -304,13 +305,13 @@ public:
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);
log->info("CE: Added Contention Resolution ID=0x%" PRIx64 "\n", conres_id);
} else {
log.error("CE: Setting Contention Resolution ID CE\n");
log->error("CE: Setting Contention Resolution ID CE\n");
}
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");
log->error("CE: Setting Contention Resolution ID CE. No space for a subheader\n");
}
msg3_tti = -1;
}
@ -322,7 +323,7 @@ public:
if (mac_msg_dl.new_subh()) {
int n = mac_msg_dl.get()->set_sdu(lcid, buf_state, &rlc);
if (n == -1) {
log.error("Error while adding SDU (%d B) to MAC PDU\n", buf_state);
log->error("Error while adding SDU (%d B) to MAC PDU\n", buf_state);
mac_msg_dl.del_subh();
}
@ -338,18 +339,18 @@ public:
}
// Assemble entire MAC PDU
uint8_t* mac_pdu_ptr = mac_msg_dl.write_packet(&log);
uint8_t* mac_pdu_ptr = mac_msg_dl.write_packet(log);
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);
log->info("Patched lcid in mac header to: %d\n", force_lcid);
mac_pdu_ptr[0] = (mac_pdu_ptr[0] & 0xe0) | (force_lcid & 0x1f);
} else if (mac_msg_dl.nof_subh() > 1) {
log.warning(
log->warning(
"Not patching lcid to %d in mac header (nof_subh == %d)\n", 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());
log->info_hex(mac_pdu_ptr, mac_msg_dl.get_pdu_len(), "DL MAC PDU (%d B):\n", mac_msg_dl.get_pdu_len());
// Prepare MAC grant for CCCH
mac_interface_phy_lte::mac_grant_dl_t dl_grant = {};
@ -361,18 +362,18 @@ public:
ue->new_tb(dl_grant, (const uint8_t*)mac_pdu_ptr);
} else {
log.error("Error writing DL MAC PDU\n");
log->error("Error writing DL MAC PDU\n");
}
mac_msg_dl.reset();
} else if (bearer_follow_on_map[lcid]) {
log.info("Waiting for more PDUs for transmission on LCID=%d\n", lcid);
log->info("Waiting for more PDUs for transmission on LCID=%d\n", lcid);
}
}
// Check if we need to provide a UL grant as well
}
} else {
log.debug("Not handling RNTI=%d\n", dl_rnti);
log->debug("Not handling RNTI=%d\n", dl_rnti);
}
}
@ -409,8 +410,8 @@ public:
logger = logger_file;
}
log.info("Initializing UE ID=%d for TC=%s\n", run_id, tc_name.c_str());
log.console("Initializing UE ID=%d for TC=%s\n", run_id, tc_name.c_str());
log->info("Initializing UE ID=%d for TC=%s\n", run_id, tc_name.c_str());
log->console("Initializing UE ID=%d for TC=%s\n", run_id, tc_name.c_str());
// Patch UE config
local_args.stack.pcap.filename = get_filename_with_tc_name(args.stack.pcap.filename, run_id, tc_name);
@ -420,14 +421,14 @@ public:
if (ue->init(local_args, logger, this, tc_name)) {
ue->stop();
std::string err("Couldn't initialize UE.\n");
log.error("%s\n", err.c_str());
log.console("%s\n", err.c_str());
log->error("%s\n", err.c_str());
log->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");
log->error("Error while adding TTI timer to epoll\n");
}
event_handler.insert({timer_handler.get_timer_fd(), &timer_handler});
}
@ -435,8 +436,8 @@ public:
// Called from UT to terminate the testcase
void tc_end()
{
log.info("Deinitializing UE ID=%d\n", run_id);
log.console("Deinitializing UE ID=%d\n", run_id);
log->info("Deinitializing UE ID=%d\n", run_id);
log->console("Deinitializing UE ID=%d\n", run_id);
ue->stop();
// stop TTI timer
@ -469,7 +470,7 @@ public:
{
// verify that UE intends to send PRACH on current Pcell
if (cells[pcell_idx]->cell.id != cell_id) {
log.error("UE is attempting to PRACH on pci=%d, current Pcell=%d\n", cell_id, cells[pcell_idx]->cell.id);
log->error("UE is attempting to PRACH on pci=%d, current Pcell=%d\n", cell_id, cells[pcell_idx]->cell.id);
return;
}
@ -481,7 +482,7 @@ public:
// Called from PHY
void sr_req(uint32_t tti_tx)
{
log.info("Received SR from PHY\n");
log->info("Received SR from PHY\n");
sr_tti = tti_tx;
}
@ -489,11 +490,11 @@ public:
void 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_log->error("Received NULL as PDU payload. Dropping.\n");
return;
}
log.debug_hex(payload, len, "Received MAC PDU (%d B)\n", len);
log->debug_hex(payload, len, "Received MAC PDU (%d B)\n", len);
// Parse MAC
mac_msg_ul.init_rx(len, true);
@ -503,11 +504,11 @@ public:
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 PDU to LCID=%d (%d B)\n",
mac_msg_ul.get()->get_sdu_lcid(),
mac_msg_ul.get()->get_payload_size());
ss_mac_log->info_hex(mac_msg_ul.get()->get_sdu_ptr(),
mac_msg_ul.get()->get_payload_size(),
"Route PDU to LCID=%d (%d B)\n",
mac_msg_ul.get()->get_sdu_lcid(),
mac_msg_ul.get()->get_payload_size());
rlc.write_pdu(
mac_msg_ul.get()->get_sdu_lcid(), mac_msg_ul.get()->get_sdu_ptr(), mac_msg_ul.get()->get_payload_size());
@ -520,10 +521,10 @@ public:
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_log->info_hex(ue_cri_ptr, nbytes, "Contention resolution ID:\n");
} else {
ss_mac_log.error("Received CCCH UL message of invalid size=%d bytes\n",
mac_msg_ul.get()->get_payload_size());
ss_mac_log->error("Received CCCH UL message of invalid size=%d bytes\n",
mac_msg_ul.get()->get_payload_size());
}
}
}
@ -544,7 +545,7 @@ public:
// Internal function called from main thread
void send_rar(uint32_t preamble_index)
{
log.info("Sending RAR for RAPID=%d\n", preamble_index);
log->info("Sending RAR for RAPID=%d\n", preamble_index);
// Prepare RAR grant
uint8_t grant_buffer[64] = {};
@ -585,7 +586,7 @@ public:
// Internal function called from main thread
void send_msg3_grant()
{
log.info("Sending Msg3 grant for C-RNTI=%d\n", crnti);
log->info("Sending Msg3 grant for C-RNTI=%d\n", crnti);
mac_interface_phy_lte::mac_grant_ul_t ul_grant = {};
ul_grant.tb.tbs = 32;
@ -627,41 +628,41 @@ public:
switch (subh->ce_type()) {
case srslte::sch_subh::PHR_REPORT:
phr = subh->get_phr();
ss_mac_log.info("CE: Received PHR from rnti=0x%x, value=%.0f\n", rnti, phr);
ss_mac_log->info("CE: Received PHR from rnti=0x%x, value=%.0f\n", rnti, phr);
break;
case srslte::sch_subh::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_log->info("CE: Received C-RNTI from temp_rnti=0x%x, rnti=0x%x\n", rnti, old_rnti);
break;
case srslte::sch_subh::TRUNC_BSR:
case srslte::sch_subh::SHORT_BSR:
idx = subh->get_bsr(buff_size);
if (idx == -1) {
ss_mac_log.error("Invalid Index Passed to lc groups\n");
ss_mac_log->error("Invalid Index Passed to lc groups\n");
break;
}
ss_mac_log.info("CE: Received %s BSR rnti=0x%x, lcg=%d, value=%d\n",
subh->ce_type() == srslte::sch_subh::SHORT_BSR ? "Short" : "Trunc",
rnti,
idx,
buff_size[idx]);
ss_mac_log->info("CE: Received %s BSR rnti=0x%x, lcg=%d, value=%d\n",
subh->ce_type() == srslte::sch_subh::SHORT_BSR ? "Short" : "Trunc",
rnti,
idx,
buff_size[idx]);
is_bsr = true;
break;
case srslte::sch_subh::LONG_BSR:
subh->get_bsr(buff_size);
is_bsr = true;
ss_mac_log.info("CE: Received Long BSR rnti=0x%x, value=%d,%d,%d,%d\n",
rnti,
buff_size[0],
buff_size[1],
buff_size[2],
buff_size[3]);
ss_mac_log->info("CE: Received Long BSR rnti=0x%x, value=%d,%d,%d,%d\n",
rnti,
buff_size[0],
buff_size[1],
buff_size[2],
buff_size[3]);
break;
case srslte::sch_subh::PADDING:
ss_mac_log.debug("CE: Received padding for rnti=0x%x\n", rnti);
ss_mac_log->debug("CE: Received padding for rnti=0x%x\n", rnti);
break;
default:
ss_mac_log.error("CE: Invalid lcid=0x%x\n", subh->ce_type());
ss_mac_log->error("CE: Invalid lcid=0x%x\n", subh->ce_type());
break;
}
return is_bsr;
@ -674,7 +675,7 @@ public:
// 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");
log->info("UL-PID=%d NDI=%s\n", pid, last_ul_ndi[pid] ? "1" : "0");
return last_ul_ndi[pid];
}
@ -683,7 +684,7 @@ public:
// 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");
log->info("DL-PID=%d NDI=%s\n", pid, last_dl_ndi[pid] ? "1" : "0");
return last_dl_ndi[pid];
}
@ -738,7 +739,7 @@ public:
if (timing.now) {
set_cell_config_impl(cell_name, earfcn, cell, power);
} else {
log.debug("Scheduling Cell configuration of %s for TTI=%d\n", cell_name.c_str(), timing.tti);
log->debug("Scheduling Cell configuration of %s for TTI=%d\n", cell_name.c_str(), timing.tti);
tti_actions[timing.tti].push_back(
[this, cell_name, earfcn, cell, power]() { set_cell_config_impl(cell_name, earfcn, cell, power); });
}
@ -752,7 +753,7 @@ public:
// check if cell already exists
if (not syssim_has_cell(cell_name_)) {
// insert new cell
log.info("Adding cell %s with cellId=%d and power=%.2f dBm\n", cell_name_.c_str(), cell_.id, power_);
log->info("Adding cell %s with cellId=%d and power=%.2f dBm\n", cell_name_.c_str(), cell_.id, power_);
unique_syssim_cell_t cell = unique_syssim_cell_t(new syssim_cell_t);
cell->name = cell_name_;
cell->cell = cell_;
@ -761,7 +762,7 @@ public:
cells.push_back(std::move(cell));
} else {
// cell is already there
log.info("Cell already there, reconfigure\n");
log->info("Cell already there, reconfigure\n");
}
update_cell_map();
@ -783,7 +784,7 @@ public:
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);
log->debug("Scheduling Cell attenuation reconfiguration of %s for TTI=%d\n", cell_name.c_str(), timing.tti);
tti_actions[timing.tti].push_back([this, cell_name, value]() { set_cell_attenuation_impl(cell_name, value); });
}
}
@ -791,7 +792,7 @@ public:
void 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");
log->error("Can't set cell power. Cell not found.\n");
}
// update cell's power
@ -816,7 +817,7 @@ public:
phy_cell.info = ss_cell->cell;
phy_cell.power = ss_cell->initial_power - ss_cell->attenuation;
phy_cell.earfcn = ss_cell->earfcn;
log.info("Configuring cell with PCI=%d with TxPower=%.2f\n", phy_cell.info.id, phy_cell.power);
log->info("Configuring cell with PCI=%d with TxPower=%.2f\n", phy_cell.info.id, phy_cell.power);
phy_cells.push_back(phy_cell);
}
@ -830,7 +831,7 @@ public:
void 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");
log->error("Can't add BCCH to cell. Cell not found.\n");
}
// add SIB
@ -848,7 +849,7 @@ public:
// Add to SRB0 Tx queue
rlc.write_sdu(0, std::move(pdu));
} else {
log.debug("Scheduling CCCH PDU for TTI=%d\n", timing.tti);
log->debug("Scheduling CCCH PDU for TTI=%d\n", timing.tti);
auto task = [this](srslte::unique_byte_buffer_t& pdu) { rlc.write_sdu(0, std::move(pdu)); };
tti_actions[timing.tti].push_back(std::bind(task, std::move(pdu)));
}
@ -860,8 +861,10 @@ public:
if (timing.now) {
add_dcch_pdu_impl(lcid, std::move(pdu), follow_on_flag);
} else {
log.debug("Scheduling DCCH PDU for TTI=%d\n", timing.tti);
auto task = [this](uint32_t lcid, srslte::unique_byte_buffer_t& pdu, bool follow_on_flag) { add_dcch_pdu_impl(lcid, std::move(pdu), follow_on_flag); };
log->debug("Scheduling DCCH PDU for TTI=%d\n", timing.tti);
auto task = [this](uint32_t lcid, srslte::unique_byte_buffer_t& pdu, bool follow_on_flag) {
add_dcch_pdu_impl(lcid, std::move(pdu), follow_on_flag);
};
tti_actions[timing.tti].push_back(std::bind(task, lcid, std::move(pdu), follow_on_flag));
}
}
@ -869,14 +872,14 @@ public:
void add_dcch_pdu_impl(uint32_t lcid, unique_byte_buffer_t pdu, bool follow_on_flag)
{
// push to PDCP and create DL grant for it
log.info("Writing PDU (%d B) to LCID=%d\n", pdu->N_bytes, lcid);
log->info("Writing PDU (%d B) to LCID=%d\n", pdu->N_bytes, lcid);
pdcp.write_sdu(lcid, std::move(pdu), true);
bearer_follow_on_map[lcid] = follow_on_flag;
}
void add_pch_pdu(unique_byte_buffer_t pdu)
{
log.info("Received PCH PDU (%d B)\n", pdu->N_bytes);
log->info("Received PCH PDU (%d B)\n", pdu->N_bytes);
// Prepare MAC grant for PCH
mac_interface_phy_lte::mac_grant_dl_t dl_grant = {};
@ -895,21 +898,21 @@ public:
if (timing.now) {
add_srb_impl(lcid, pdcp_config);
} else {
log.debug("Scheduling SRB%d addition for TTI=%d\n", lcid, timing.tti);
log->debug("Scheduling SRB%d addition for TTI=%d\n", lcid, timing.tti);
tti_actions[timing.tti].push_back([this, lcid, pdcp_config]() { add_srb_impl(lcid, pdcp_config); });
}
}
void add_srb_impl(const uint32_t lcid, const pdcp_config_t pdcp_config)
{
log.info("Adding SRB%d\n", lcid);
log->info("Adding SRB%d\n", lcid);
pdcp.add_bearer(lcid, pdcp_config);
rlc.add_bearer(lcid, srslte::rlc_config_t::srb_config(lcid));
}
void reestablish_bearer(uint32_t lcid)
{
log.info("Reestablishing LCID=%d\n", lcid);
log->info("Reestablishing LCID=%d\n", lcid);
pdcp.reestablish(lcid);
rlc.reestablish(lcid);
}
@ -919,14 +922,14 @@ public:
if (timing.now) {
del_srb_impl(lcid);
} else {
log.debug("Scheduling SRB%d deletion for TTI=%d\n", lcid, timing.tti);
log->debug("Scheduling SRB%d deletion for TTI=%d\n", lcid, timing.tti);
tti_actions[timing.tti].push_back([this, lcid]() { del_srb_impl(lcid); });
}
}
void del_srb_impl(uint32_t lcid)
{
log.info("Deleting SRB%d\n", lcid);
log->info("Deleting SRB%d\n", lcid);
// Only delete SRB1/2
if (lcid > 0) {
pdcp.del_bearer(lcid);
@ -935,7 +938,7 @@ public:
// Reset HARQ to generate new transmissions
if (lcid == 0) {
log.info("Resetting UL/DL NDI counters\n");
log->info("Resetting UL/DL NDI counters\n");
memset(last_dl_ndi, 0, sizeof(last_dl_ndi));
memset(last_ul_ndi, 0, sizeof(last_ul_ndi));
}
@ -944,16 +947,16 @@ public:
// RRC interface for PDCP, PDCP calls RRC to push RRC SDU
void 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]->cell.id,
pdu->N_bytes);
log->info_hex(pdu->msg,
pdu->N_bytes,
"RRC SDU received for LCID=%d cell_id=%d (%d B)\n",
lcid,
cells[pcell_idx]->cell.id,
pdu->N_bytes);
// check cell ID
if (cells[pcell_idx]->cell.id > 256) {
log.error("Cell ID too large to fit in single byte.\n");
log->error("Cell ID too large to fit in single byte.\n");
return;
}
@ -972,11 +975,11 @@ public:
}
// Not supported right now
void write_pdu_bcch_bch(unique_byte_buffer_t pdu) { log.error("%s not implemented.\n", __FUNCTION__); }
void write_pdu_bcch_dlsch(unique_byte_buffer_t pdu) { log.error("%s not implemented.\n", __FUNCTION__); }
void write_pdu_pcch(unique_byte_buffer_t pdu) { log.error("%s not implemented.\n", __FUNCTION__); }
void write_pdu_mch(uint32_t lcid, unique_byte_buffer_t pdu) { log.error("%s not implemented.\n", __FUNCTION__); }
void max_retx_attempted() { log.error("%s not implemented.\n", __FUNCTION__); }
void write_pdu_bcch_bch(unique_byte_buffer_t pdu) { log->error("%s not implemented.\n", __FUNCTION__); }
void write_pdu_bcch_dlsch(unique_byte_buffer_t pdu) { log->error("%s not implemented.\n", __FUNCTION__); }
void write_pdu_pcch(unique_byte_buffer_t pdu) { log->error("%s not implemented.\n", __FUNCTION__); }
void write_pdu_mch(uint32_t lcid, unique_byte_buffer_t pdu) { log->error("%s not implemented.\n", __FUNCTION__); }
void max_retx_attempted() { log->error("%s not implemented.\n", __FUNCTION__); }
std::string get_rb_name(uint32_t lcid)
{
@ -988,11 +991,11 @@ public:
void write_sdu(uint32_t lcid, unique_byte_buffer_t sdu, bool blocking = true)
{
log.info_hex(sdu->msg, sdu->N_bytes, "Received SDU on LCID=%d\n", lcid);
log->info_hex(sdu->msg, sdu->N_bytes, "Received SDU on LCID=%d\n", lcid);
uint8_t* mac_pdu_ptr;
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");
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");
// Prepare MAC grant for CCCH
mac_interface_phy_lte::mac_grant_dl_t dl_grant = {};
@ -1021,7 +1024,7 @@ public:
if (timing.now) {
set_as_security_impl(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);
log->debug("Scheduling AS security configuration for TTI=%d\n", timing.tti);
tti_actions[timing.tti].push_back(
[this, k_rrc_enc_, k_rrc_int_, k_up_enc_, cipher_algo_, integ_algo_, bearers_]() {
set_as_security_impl(k_rrc_enc_, k_rrc_int_, k_up_enc_, cipher_algo_, integ_algo_, bearers_);
@ -1072,36 +1075,36 @@ public:
if (lcid.dl_value_valid) {
// make sure the current DL SN value match
if (lcid.dl_value == dl_sn) {
log.info("Setting AS security for LCID=%d in DL direction\n", lcid.rb_id);
log->info("Setting AS security for LCID=%d in DL direction\n", lcid.rb_id);
pdcp.config_security(lcid.rb_id, sec_cfg);
pdcp.enable_integrity(lcid.rb_id, DIRECTION_TX);
pdcp.enable_encryption(lcid.rb_id, DIRECTION_TX);
lcid.dl_value_valid = false;
} else {
log.info("Delaying AS security configuration of lcid=%d. DL: %d != %d\n", lcid.rb_id, lcid.dl_value, dl_sn);
log->info("Delaying AS security configuration of lcid=%d. DL: %d != %d\n", lcid.rb_id, lcid.dl_value, dl_sn);
}
} else {
log.debug("Downlink AS Security already applied for lcid=%d\n", lcid.rb_id);
log->debug("Downlink AS Security already applied for lcid=%d\n", lcid.rb_id);
}
if (lcid.ul_value_valid) {
// Check UL count
if (lcid.ul_value == ul_sn) {
log.info("Setting AS security for LCID=%d in UL direction\n", lcid.rb_id);
log->info("Setting AS security for LCID=%d in UL direction\n", lcid.rb_id);
pdcp.config_security(lcid.rb_id, sec_cfg);
pdcp.enable_integrity(lcid.rb_id, DIRECTION_RX);
pdcp.enable_encryption(lcid.rb_id, DIRECTION_RX);
lcid.ul_value_valid = false;
} else {
log.info("Delaying AS security configuration of lcid=%d. UL: %d != %d\n", lcid.rb_id, lcid.ul_value, ul_sn);
log->info("Delaying AS security configuration of lcid=%d. UL: %d != %d\n", lcid.rb_id, lcid.ul_value, ul_sn);
}
} else {
log.debug("Uplink AS Security already applied for lcid=%d\n", lcid.rb_id);
log->debug("Uplink AS Security already applied for lcid=%d\n", lcid.rb_id);
}
// re-consider if at least one direction needs reconfiguration
if (lcid.dl_value_valid || lcid.ul_value_valid) {
log.debug("Adding LCID=%d for later configuration (size=%zd)\n", lcid.rb_id, update_needed_list.size());
log->debug("Adding LCID=%d for later configuration (size=%zd)\n", lcid.rb_id, update_needed_list.size());
update_needed_list.push_back(lcid);
}
}
@ -1114,14 +1117,14 @@ public:
if (timing.now) {
release_as_security_impl();
} else {
log.debug("Scheduling Release of AS security for TTI=%d\n", timing.tti);
log->debug("Scheduling Release of AS security for TTI=%d\n", timing.tti);
tti_actions[timing.tti].push_back([this]() { release_as_security_impl(); });
}
}
void release_as_security_impl()
{
log.info("Releasing AS security\n");
log->info("Releasing AS security\n");
pending_bearer_config.clear();
}
@ -1131,7 +1134,7 @@ public:
for (uint32_t i = 0; i < cells.size(); ++i) {
if (cells[i]->cell.id == phy_cell.id) {
pcell_idx = i;
log.info("New PCell: PCI=%d\n", cells[pcell_idx]->cell.id);
log->info("New PCell: PCI=%d\n", cells[pcell_idx]->cell.id);
return;
}
}
@ -1148,7 +1151,7 @@ public:
pdcp.get_bearer_status(i, &bearer.dl_value, &tmp, &bearer.ul_value, &tmp);
bearer.rb_is_srb = i <= 2;
bearer.rb_id = i;
log.debug("PDCP count lcid=%d, dl=%d, ul=%d\n", bearer.rb_id, bearer.dl_value, bearer.ul_value);
log->debug("PDCP count lcid=%d, dl=%d, ul=%d\n", bearer.rb_id, bearer.dl_value, bearer.ul_value);
bearers.push_back(bearer);
}
}
@ -1174,13 +1177,13 @@ private:
srslte::logger_stdout logger_stdout;
srslte::logger_file* logger_file = nullptr;
srslte::logger* logger = nullptr;
srslte::log_filter log;
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 ss_mac_log;
srslte::log_ref ss_mac_log;
srslte::log_filter ss_rlc_log;
srslte::log_filter ss_pdcp_log;
@ -1239,8 +1242,8 @@ private:
uint64_t conres_id = 0;
// Simulator objects
srslte::rlc rlc;
srslte::pdcp pdcp;
srslte::rlc rlc;
srslte::pdcp pdcp;
std::map<uint32_t, bool> bearer_follow_on_map; ///< Indicates if for a given LCID the follow_on_flag is set or not
// security config

View File

@ -170,7 +170,7 @@ class rrc_test : public rrc
srsue::stack_dummy* stack = nullptr;
public:
rrc_test(srslte::log* log_, stack_dummy* stack_) : rrc(log_, stack_), stack(stack_)
rrc_test(srslte::log* log_, stack_dummy* stack_) : rrc(stack_), stack(stack_)
{
pool = srslte::byte_buffer_pool::get_instance();
nastest = std::unique_ptr<nas_test>(new nas_test(stack));
@ -216,7 +216,7 @@ public:
void send_ccch_msg(dl_ccch_msg_s& dl_ccch_msg)
{
srslte::unique_byte_buffer_t pdu = srslte::allocate_unique_buffer(*pool, true);
;
asn1::bit_ref bref(pdu->msg, pdu->get_tailroom());
dl_ccch_msg.pack(bref);
bref.align_bytes_zero();