- Upgrade to srslog the loggers in lib/mac.

- Adapted users of these classes and tests.
master
faluco 4 years ago committed by faluco
parent 9c764c299d
commit 821925a273

@ -16,6 +16,7 @@
#include "srslte/common/common.h"
#include "srslte/common/logmap.h"
#include "srslte/config.h"
#include "srslte/srslog/srslog.h"
#include <memory>
#include <stdint.h>
#include <vector>
@ -79,8 +80,8 @@ private:
bool F_bit = false;
uint8_t* sdu = nullptr;
mac_sch_pdu_nr* parent = nullptr;
srslte::log_ref log_h;
mac_sch_pdu_nr* parent = nullptr;
srslog::basic_logger& logger;
};
class mac_sch_pdu_nr

@ -15,6 +15,7 @@
#include "srslte/common/interfaces_common.h"
#include "srslte/common/logmap.h"
#include "srslte/srslog/srslog.h"
#include <sstream>
#include <stdint.h>
#include <stdio.h>
@ -118,10 +119,10 @@ template <class SubH>
class pdu
{
public:
pdu(uint32_t max_subheaders_, log_ref log_h_) :
pdu(uint32_t max_subheaders_, srslog::basic_logger& logger) :
max_subheaders(max_subheaders_),
subheaders(max_subheaders_),
log_h(log_h_),
logger(logger),
nof_subheaders(0),
cur_idx(-1),
pdu_len(0),
@ -233,12 +234,7 @@ public:
if (ret && ((ptr - init_ptr) >= (int32_t)pdu_len)) {
// stop processing last subheader indicates another one but all bytes are consumed
nof_subheaders = 0;
if (log_h) {
log_h->warning_hex(
init_ptr, pdu_len, "Corrupted MAC PDU - all bytes have been consumed (pdu_len=%d)\n", pdu_len);
} else {
srslte::console("Corrupted MAC PDU - all bytes have been consumed (pdu_len=%d)\n", pdu_len);
}
logger.warning(init_ptr, pdu_len, "Corrupted MAC PDU - all bytes have been consumed (pdu_len=%d)", pdu_len);
return SRSLTE_ERROR;
}
} while (ret && (nof_subheaders + 1) < (int)max_subheaders && ((int32_t)pdu_len > (ptr - init_ptr)));
@ -249,13 +245,7 @@ public:
// stop processing if we read payload beyond the PDU length
if ((ptr - init_ptr) > (int32_t)pdu_len) {
nof_subheaders = 0;
if (log_h) {
log_h->warning_hex(
init_ptr, pdu_len, "Corrupted MAC PDU - all bytes have been consumed (pdu_len=%d)\n", pdu_len);
} else {
srslte::console("Corrupted MAC PDU - all bytes have been consumed (pdu_len=%d)\n", pdu_len);
}
logger.warning(init_ptr, pdu_len, "Corrupted MAC PDU - all bytes have been consumed (pdu_len=%d)", pdu_len);
return SRSLTE_ERROR;
}
}
@ -263,16 +253,16 @@ public:
}
protected:
std::vector<SubH> subheaders;
uint32_t pdu_len;
uint32_t rem_len;
int cur_idx;
int nof_subheaders;
uint32_t max_subheaders;
bool pdu_is_ul;
byte_buffer_t* buffer_tx = nullptr;
int last_sdu_idx;
srslte::log_ref log_h;
std::vector<SubH> subheaders;
uint32_t pdu_len;
uint32_t rem_len;
int cur_idx;
int nof_subheaders;
uint32_t max_subheaders;
bool pdu_is_ul;
byte_buffer_t* buffer_tx = nullptr;
int last_sdu_idx;
srslog::basic_logger& logger;
/* 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)
@ -392,11 +382,11 @@ private:
class sch_pdu : public pdu<sch_subh>
{
public:
sch_pdu(uint32_t max_subh, const log_ref& log_h_) : pdu(max_subh, log_h_) {}
sch_pdu(uint32_t max_subh, srslog::basic_logger& logger) : pdu(max_subh, logger) {}
void parse_packet(uint8_t* ptr);
uint8_t* write_packet();
uint8_t* write_packet(srslte::log_ref log);
uint8_t* write_packet(srslog::basic_logger& log);
bool has_space_ce(uint32_t nbytes, bool var_len = false);
bool has_space_sdu(uint32_t nbytes);
int get_pdu_len();
@ -457,7 +447,7 @@ private:
class rar_pdu : public pdu<rar_subh>
{
public:
rar_pdu(uint32_t max_rars = 16, srslte::log_ref log_ = srslte::logmap::get("MAC"));
rar_pdu(uint32_t max_rars = 16, srslog::basic_logger& logger = srslog::fetch_basic_logger("MAC"));
void set_backoff(uint8_t bi);
bool has_backoff();
@ -474,7 +464,7 @@ private:
class mch_pdu : public sch_pdu
{
public:
mch_pdu(uint32_t max_subh, const log_ref& log_h_) : sch_pdu(max_subh, log_h_) {}
mch_pdu(uint32_t max_subh, srslog::basic_logger& logger) : sch_pdu(max_subh, logger) {}
private:
/* Prepares the PDU for parsing or writing by setting the number of subheaders to 0 and the pdu length */

@ -33,8 +33,10 @@ 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) {}
void init(process_callback* callback, log_ref log_h_);
pdu_queue(srslog::basic_logger& logger, uint32_t pool_size = DEFAULT_POOL_SIZE) :
pool(pool_size), callback(NULL), logger(logger)
{}
void init(process_callback* callback);
uint8_t* request(uint32_t len);
void deallocate(const uint8_t* pdu);
@ -61,8 +63,8 @@ private:
block_queue<pdu_t*> pdu_q;
buffer_pool<pdu_t> pool;
process_callback* callback;
log_ref log_h;
process_callback* callback;
srslog::basic_logger& logger;
};
} // namespace srslte

@ -14,7 +14,9 @@
namespace srslte {
mac_sch_subpdu_nr::mac_sch_subpdu_nr(mac_sch_pdu_nr* parent_) : parent(parent_), log_h("MAC") {}
mac_sch_subpdu_nr::mac_sch_subpdu_nr(mac_sch_pdu_nr* parent_) :
parent(parent_), logger(srslog::fetch_basic_logger("MAC"))
{}
mac_sch_subpdu_nr::nr_lcid_sch_t mac_sch_subpdu_nr::get_type()
{
@ -69,7 +71,7 @@ int32_t mac_sch_subpdu_nr::read_subheader(const uint8_t* ptr)
}
sdu = (uint8_t*)ptr;
} else {
log_h->warning("Invalid LCID (%d) in MAC PDU\n", lcid);
logger.warning("Invalid LCID (%d) in MAC PDU", lcid);
return SRSLTE_ERROR;
}
return header_length;
@ -85,7 +87,7 @@ void mac_sch_subpdu_nr::set_sdu(const uint32_t lcid_, const uint8_t* payload_, c
F_bit = false;
sdu_length = sizeof_ce(lcid, parent->is_ulsch());
if (len_ != static_cast<uint32_t>(sdu_length)) {
log_h->warning("Invalid SDU length of UL-SCH SDU (%d != %d)\n", len_, sdu_length);
logger.warning("Invalid SDU length of UL-SCH SDU (%d != %d)", len_, sdu_length);
}
}
@ -124,7 +126,7 @@ uint32_t mac_sch_subpdu_nr::write_subpdu(const uint8_t* start_)
} else if (header_length == 1) {
// do nothing
} else {
log_h->warning("Error while packing PDU. Unsupported header length (%d)\n", header_length);
logger.warning("Error while packing PDU. Unsupported header length (%d)", header_length);
}
// copy SDU payload

@ -218,11 +218,7 @@ void sch_pdu::parse_packet(uint8_t* ptr)
if (n_sub >= 0) {
subheaders[nof_subheaders - 1].set_payload_size(n_sub);
} else {
if (log_h) {
log_h->warning_hex(ptr, pdu_len, "Corrupted MAC PDU (read_len=%d, pdu_len=%d)\n", read_len, pdu_len);
} else {
srslte::console("Corrupted MAC PDU (read_len=%d, pdu_len=%d)\n", read_len, pdu_len);
}
logger.warning(ptr, pdu_len, "Corrupted MAC PDU (read_len=%d, pdu_len=%d)", read_len, pdu_len);
// reset PDU
init_(buffer_tx, pdu_len, pdu_is_ul);
@ -232,11 +228,11 @@ void sch_pdu::parse_packet(uint8_t* ptr)
uint8_t* sch_pdu::write_packet()
{
return write_packet(srslte::log_ref{"MAC "});
return write_packet(srslog::fetch_basic_logger("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_ref log_h)
uint8_t* sch_pdu::write_packet(srslog::basic_logger& log)
{
// set padding to remaining length in PDU
uint32_t num_padding = rem_len;
@ -279,7 +275,7 @@ uint8_t* sch_pdu::write_packet(srslte::log_ref log_h)
// make sure there is enough room for header
if (buffer_tx->get_headroom() < total_header_size) {
log_h->error("Not enough headroom for MAC header (%d < %d).\n", buffer_tx->get_headroom(), total_header_size);
log.error("Not enough headroom for MAC header (%d < %d).", buffer_tx->get_headroom(), total_header_size);
return nullptr;
}
@ -327,7 +323,7 @@ uint8_t* sch_pdu::write_packet(srslte::log_ref log_h)
}
if (buffer_tx->get_tailroom() < num_padding) {
log_h->error("Not enough tailroom for MAC padding (%d < %d).\n", buffer_tx->get_tailroom(), num_padding);
log.error("Not enough tailroom for MAC padding (%d < %d).", buffer_tx->get_tailroom(), num_padding);
return nullptr;
}
@ -339,69 +335,53 @@ uint8_t* sch_pdu::write_packet(srslte::log_ref log_h)
// Print warning if we have padding only
if (nof_subheaders <= 0 && nof_subheaders < (int)max_subheaders) {
log_h->debug("Writing MAC PDU with padding only (%d B)\n", pdu_len);
log.debug("Writing MAC PDU with padding only (%d B)", pdu_len);
}
// Sanity check and print if error
if (log_h) {
log_h->debug("Wrote PDU: pdu_len=%d, header_and_ce=%d (%d+%d), nof_subh=%d, last_sdu=%d, onepad=%d, multi=%d\n",
pdu_len,
header_sz + ce_payload_sz,
header_sz,
ce_payload_sz,
nof_subheaders,
last_sdu_idx,
onetwo_padding,
num_padding);
} else {
printf("Wrote PDU: pdu_len=%d, header_and_ce=%d (%d+%d), nof_subh=%d, last_sdu=%d, onepad=%d, "
"multi=%d\n",
pdu_len,
header_sz + ce_payload_sz,
header_sz,
ce_payload_sz,
nof_subheaders,
last_sdu_idx,
onetwo_padding,
num_padding);
}
log.debug("Wrote PDU: pdu_len=%d, header_and_ce=%d (%d+%d), nof_subh=%d, last_sdu=%d, onepad=%d, multi=%d",
pdu_len,
header_sz + ce_payload_sz,
header_sz,
ce_payload_sz,
nof_subheaders,
last_sdu_idx,
onetwo_padding,
num_padding);
if (buffer_tx->N_bytes != pdu_len) {
if (log_h) {
srslte::console("------------------------------\n");
srslte::console("Wrote PDU: pdu_len=%d, expected_pdu_len=%d, header_and_ce=%d (%d+%d), nof_subh=%d, last_sdu=%d, "
"onepad=%d, multi=%d\n",
buffer_tx->N_bytes,
pdu_len,
header_sz + ce_payload_sz,
header_sz,
ce_payload_sz,
nof_subheaders,
last_sdu_idx,
onetwo_padding,
num_padding);
srslte::console("------------------------------\n");
log_h->error(
"Wrote PDU: pdu_len=%d, expected_pdu_len=%d, header_and_ce=%d (%d+%d), nof_subh=%d, last_sdu=%d, onepad=%d, "
"multi=%d\n",
buffer_tx->N_bytes,
pdu_len,
header_sz + ce_payload_sz,
header_sz,
ce_payload_sz,
nof_subheaders,
last_sdu_idx,
onetwo_padding,
num_padding);
for (int i = 0; i < nof_subheaders; i++) {
log_h->error("SUBH %d is_sdu=%d, head_size=%d, payload=%d\n",
i,
subheaders[i].is_sdu(),
subheaders[i].get_header_size(i == (nof_subheaders - 1)),
subheaders[i].get_payload_size());
}
srslte::console("------------------------------\n");
srslte::console("Wrote PDU: pdu_len=%d, expected_pdu_len=%d, header_and_ce=%d (%d+%d), nof_subh=%d, last_sdu=%d, "
"onepad=%d, multi=%d\n",
buffer_tx->N_bytes,
pdu_len,
header_sz + ce_payload_sz,
header_sz,
ce_payload_sz,
nof_subheaders,
last_sdu_idx,
onetwo_padding,
num_padding);
srslte::console("------------------------------\n");
log.error(
"Wrote PDU: pdu_len=%d, expected_pdu_len=%d, header_and_ce=%d (%d+%d), nof_subh=%d, last_sdu=%d, onepad=%d, "
"multi=%d",
buffer_tx->N_bytes,
pdu_len,
header_sz + ce_payload_sz,
header_sz,
ce_payload_sz,
nof_subheaders,
last_sdu_idx,
onetwo_padding,
num_padding);
for (int i = 0; i < nof_subheaders; i++) {
log.error("SUBH %d is_sdu=%d, head_size=%d, payload=%d",
i,
subheaders[i].is_sdu(),
subheaders[i].get_header_size(i == (nof_subheaders - 1)),
subheaders[i].get_payload_size());
}
return nullptr;
@ -1023,7 +1003,7 @@ std::string rar_pdu::to_string()
return msg;
}
rar_pdu::rar_pdu(uint32_t max_rars_, srslte::log_ref log_) : pdu(max_rars_, log_)
rar_pdu::rar_pdu(uint32_t max_rars_, srslog::basic_logger& logger) : pdu(max_rars_, logger)
{
backoff_indicator = 0;
has_backoff_indicator = false;
@ -1072,11 +1052,7 @@ bool rar_pdu::write_packet(uint8_t* ptr)
int32_t payload_len = ptr - init_ptr;
int32_t pad_len = rem_len - payload_len;
if (pad_len < 0) {
if (log_h) {
log_h->warning("Error packing RAR PDU (payload_len=%d, rem_len=%d)\n", payload_len, rem_len);
} else {
srslte::console("Error packing RAR PDU (payload_len=%d, rem_len=%d)\n", payload_len, rem_len);
}
logger.warning("Error packing RAR PDU (payload_len=%d, rem_len=%d)", payload_len, rem_len);
return false;
} else {
bzero(ptr, pad_len * sizeof(uint8_t));

@ -15,31 +15,28 @@
namespace srslte {
void pdu_queue::init(process_callback* callback_, log_ref log_h_)
void pdu_queue::init(process_callback* callback_)
{
callback = callback_;
log_h = log_h_;
}
uint8_t* pdu_queue::request(uint32_t len)
{
if (len > MAX_PDU_LEN) {
ERROR("Error request buffer of invalid size %d. Max bytes %d\n", len, MAX_PDU_LEN);
ERROR("Error request buffer of invalid size %d. Max bytes %d", len, MAX_PDU_LEN);
return NULL;
}
// This function must be non-blocking. In case we run out of buffers, it shall handle the error properly
pdu_t* pdu = pool.allocate("pdu_queue::request", false);
if (pdu) {
if ((void*)pdu->ptr != (void*)pdu) {
ERROR("Fatal error in memory alignment in struct pdu_queue::pdu_t\n");
ERROR("Fatal error in memory alignment in struct pdu_queue::pdu_t");
exit(-1);
}
return pdu->ptr;
} else {
if (log_h) {
log_h->error("Not enough buffers for MAC PDU\n");
}
ERROR("Not enough buffers for MAC PDU\n");
logger.error("Not enough buffers for MAC PDU");
ERROR("Not enough buffers for MAC PDU");
return nullptr;
}
}
@ -47,7 +44,7 @@ uint8_t* pdu_queue::request(uint32_t len)
void pdu_queue::deallocate(const uint8_t* pdu)
{
if (!pool.deallocate((pdu_t*)pdu)) {
log_h->warning("Error deallocating from buffer pool in deallocate(): buffer not created in this pool.\n");
logger.warning("Error deallocating from buffer pool in deallocate(): buffer not created in this pool.");
}
}
@ -63,7 +60,7 @@ void pdu_queue::push(const uint8_t* ptr, uint32_t len, channel_t channel)
pdu->channel = channel;
pdu_q.push(pdu);
} else {
log_h->warning("Error pushing pdu: ptr is empty\n");
logger.warning("Error pushing pdu: ptr is empty");
}
}
@ -80,9 +77,7 @@ bool pdu_queue::process_pdus()
have_data = true;
}
if (cnt > 20) {
if (log_h) {
log_h->warning("PDU queue dispatched %d packets\n", cnt);
}
logger.warning("PDU queue dispatched %d packets", cnt);
printf("Warning PDU queue dispatched %d packets\n", cnt);
}
return have_data;

@ -71,10 +71,8 @@ int mac_dl_sch_pdu_unpack_and_pack_test1()
pcap_handle->write_dl_crnti_nr(tx_buffer.msg, tx_buffer.N_bytes, PCAP_CRNTI, true, PCAP_TTI);
}
srslte::log_filter log("MAC");
log.set_level(srslte::LOG_LEVEL_DEBUG);
log.set_hex_limit(100000);
log.info_hex(tx_buffer.msg, tx_buffer.N_bytes, "Generated MAC PDU (%d B)\n", tx_buffer.N_bytes);
auto& mac_logger = srslog::fetch_basic_logger("MAC");
mac_logger.info(tx_buffer.msg, tx_buffer.N_bytes, "Generated MAC PDU (%d B)", tx_buffer.N_bytes);
return SRSLTE_SUCCESS;
}
@ -140,10 +138,8 @@ int mac_dl_sch_pdu_pack_test3()
pcap_handle->write_dl_crnti_nr(tx_buffer.msg, tx_buffer.N_bytes, PCAP_CRNTI, true, PCAP_TTI);
}
srslte::log_filter log("MAC");
log.set_level(srslte::LOG_LEVEL_DEBUG);
log.set_hex_limit(100000);
log.info_hex(tx_buffer.msg, tx_buffer.N_bytes, "Generated MAC PDU (%d B)\n", tx_buffer.N_bytes);
auto& mac_logger = srslog::fetch_basic_logger("MAC");
mac_logger.info(tx_buffer.msg, tx_buffer.N_bytes, "Generated MAC PDU (%d B)", tx_buffer.N_bytes);
return SRSLTE_SUCCESS;
}
@ -179,10 +175,8 @@ int mac_dl_sch_pdu_pack_test4()
pcap_handle->write_dl_crnti_nr(tx_buffer.msg, tx_buffer.N_bytes, PCAP_CRNTI, true, PCAP_TTI);
}
srslte::log_filter log("MAC");
log.set_level(srslte::LOG_LEVEL_DEBUG);
log.set_hex_limit(100000);
log.info_hex(tx_buffer.msg, tx_buffer.N_bytes, "Generated MAC PDU (%d B)\n", tx_buffer.N_bytes);
auto& mac_logger = srslog::fetch_basic_logger("MAC");
mac_logger.info(tx_buffer.msg, tx_buffer.N_bytes, "Generated MAC PDU (%d B)", tx_buffer.N_bytes);
return SRSLTE_SUCCESS;
}
@ -224,10 +218,8 @@ int mac_dl_sch_pdu_pack_test5()
pcap_handle->write_dl_crnti_nr(tx_buffer.msg, tx_buffer.N_bytes, PCAP_CRNTI, true, PCAP_TTI);
}
srslte::log_filter log("MAC");
log.set_level(srslte::LOG_LEVEL_DEBUG);
log.set_hex_limit(100000);
log.info_hex(tx_buffer.msg, tx_buffer.N_bytes, "Generated MAC PDU (%d B)\n", tx_buffer.N_bytes);
auto& mac_logger = srslog::fetch_basic_logger("MAC");
mac_logger.info(tx_buffer.msg, tx_buffer.N_bytes, "Generated MAC PDU (%d B)", tx_buffer.N_bytes);
return SRSLTE_SUCCESS;
}
@ -272,9 +264,9 @@ int mac_rar_pdu_unpack_test7()
// | | | | | | | | |
// | R |T=1| RAPID=0 | Octet 1
// | RAR | Octet 2-8
const uint32_t tv_rapid = 0;
const uint32_t tv_ta = 180;
const uint16_t tv_tcrnti = 0x4616;
const uint32_t tv_rapid = 0;
const uint32_t tv_ta = 180;
const uint16_t tv_tcrnti = 0x4616;
const uint8_t tv_msg3_grant[mac_rar_subpdu_nr::UL_GRANT_NBITS] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00}; // unpacked UL grant
@ -418,10 +410,8 @@ int mac_ul_sch_pdu_unpack_and_pack_test2()
pcap_handle->write_ul_crnti_nr(tx_buffer.msg, tx_buffer.N_bytes, PCAP_CRNTI, true, PCAP_TTI);
}
srslte::log_filter log("MAC");
log.set_level(srslte::LOG_LEVEL_DEBUG);
log.set_hex_limit(100000);
log.info_hex(tx_buffer.msg, tx_buffer.N_bytes, "Generated MAC PDU (%d B)\n", tx_buffer.N_bytes);
auto& mac_logger = srslog::fetch_basic_logger("MAC");
mac_logger.info(tx_buffer.msg, tx_buffer.N_bytes, "Generated MAC PDU (%d B)", tx_buffer.N_bytes);
return SRSLTE_SUCCESS;
}
@ -467,10 +457,8 @@ int mac_ul_sch_pdu_unpack_and_pack_test3()
pcap_handle->write_ul_crnti_nr(tx_buffer.msg, tx_buffer.N_bytes, PCAP_CRNTI, true, PCAP_TTI);
}
srslte::log_filter log("MAC");
log.set_level(srslte::LOG_LEVEL_DEBUG);
log.set_hex_limit(100000);
log.info_hex(tx_buffer.msg, tx_buffer.N_bytes, "Generated MAC PDU (%d B)\n", tx_buffer.N_bytes);
auto& mac_logger = srslog::fetch_basic_logger("MAC");
mac_logger.info(tx_buffer.msg, tx_buffer.N_bytes, "Generated MAC PDU (%d B)", tx_buffer.N_bytes);
return SRSLTE_SUCCESS;
}
@ -507,10 +495,8 @@ int mac_ul_sch_pdu_pack_test4()
pcap_handle->write_ul_crnti_nr(tx_buffer.msg, tx_buffer.N_bytes, PCAP_CRNTI, true, PCAP_TTI);
}
srslte::log_filter log("MAC");
log.set_level(srslte::LOG_LEVEL_DEBUG);
log.set_hex_limit(100000);
log.info_hex(tx_buffer.msg, tx_buffer.N_bytes, "Generated MAC PDU (%d B)\n", tx_buffer.N_bytes);
auto& mac_logger = srslog::fetch_basic_logger("MAC");
mac_logger.info(tx_buffer.msg, tx_buffer.N_bytes, "Generated MAC PDU (%d B)", tx_buffer.N_bytes);
return SRSLTE_SUCCESS;
}
@ -544,6 +530,12 @@ int main(int argc, char** argv)
pcap_handle->open("mac_nr_pdu_test.pcap");
#endif
auto& mac_logger = srslog::fetch_basic_logger("MAC", false);
mac_logger.set_level(srslog::basic_levels::debug);
mac_logger.set_hex_dump_max_size(-1);
srslog::init();
if (mac_dl_sch_pdu_unpack_and_pack_test1()) {
fprintf(stderr, "mac_dl_sch_pdu_unpack_and_pack_test1() failed.\n");
return SRSLTE_ERROR;

@ -187,23 +187,17 @@ int mac_sch_pdu_pack_test1()
static uint8_t tv[] = {0x21, 0x08, 0x22, 0x08, 0x1f, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00};
srslte::log_filter rlc_log("RLC");
rlc_log.set_level(srslte::LOG_LEVEL_DEBUG);
rlc_log.set_hex_limit(100000);
auto& mac_logger = srslog::fetch_basic_logger("MAC");
rlc_dummy rlc;
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;
rlc.write_sdu(1, sdu_len);
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_logger);
byte_buffer_t buffer;
pdu.init_tx(&buffer, pdu_size, true);
@ -226,11 +220,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_logger) == 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_logger.info(buffer.msg, buffer.N_bytes, "MAC PDU (%d B):", buffer.N_bytes);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(buffer.msg, buffer.N_bytes, 0x1001, true, 1, 0);
@ -249,16 +243,10 @@ int mac_sch_pdu_pack_test2()
static uint8_t tv[] = {0x3f, 0x3f, 0x21, 0x08, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02};
srslte::log_filter rlc_log("RLC");
rlc_log.set_level(srslte::LOG_LEVEL_DEBUG);
rlc_log.set_hex_limit(100000);
auto& mac_logger = srslog::fetch_basic_logger("MAC");
rlc_dummy rlc;
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;
rlc.write_sdu(1, sdu_len);
@ -266,7 +254,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_logger);
byte_buffer_t buffer;
pdu.init_tx(&buffer, pdu_size, true);
@ -289,10 +277,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_logger);
// log
mac_log->info_hex(buffer.msg, buffer.N_bytes, "MAC PDU (%d B):\n", buffer.N_bytes);
mac_logger.info(buffer.msg, buffer.N_bytes, "MAC PDU (%d B):", buffer.N_bytes);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(buffer.msg, buffer.N_bytes, 0x1001, true, 1, 0);
@ -317,21 +305,17 @@ int mac_sch_pdu_pack_test3()
0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
srslte::log_filter rlc_log("RLC");
rlc_log.set_level(srslte::LOG_LEVEL_DEBUG);
rlc_log.set_hex_limit(100000);
auto& mac_logger = srslog::fetch_basic_logger("MAC");
rlc_dummy rlc;
srslte::log_ref mac_log("MAC");
// create RLC SDUs
// const uint32_t sdu_len = 130;
rlc.write_sdu(1, 8);
rlc.write_sdu(2, 130);
const uint32_t pdu_size = 150;
srslte::sch_pdu pdu(10, srslte::log_ref{"MAC"});
srslte::sch_pdu pdu(10, mac_logger);
byte_buffer_t buffer;
pdu.init_tx(&buffer, pdu_size, true);
@ -354,10 +338,10 @@ int mac_sch_pdu_pack_test3()
TESTASSERT(pdu.rem_size() == pdu_size - 138 - 3);
// write PDU
pdu.write_packet(srslte::log_ref{"MAC"});
pdu.write_packet(mac_logger);
// log
mac_log->info_hex(buffer.msg, buffer.N_bytes, "MAC PDU (%d B):\n", buffer.N_bytes);
mac_logger.info(buffer.msg, buffer.N_bytes, "MAC PDU (%d B):", buffer.N_bytes);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(buffer.msg, buffer.N_bytes, 0x1001, true, 1, 0);
@ -374,16 +358,12 @@ int mac_sch_pdu_pack_test4()
{
static uint8_t tv[] = {0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
srslte::log_filter rlc_log("RLC");
rlc_log.set_level(srslte::LOG_LEVEL_DEBUG);
rlc_log.set_hex_limit(100000);
auto& mac_logger = srslog::fetch_basic_logger("MAC");
rlc_dummy rlc;
srslte::log_ref mac_log("MAC");
const uint32_t pdu_size = 10;
srslte::sch_pdu pdu(10, srslte::log_ref{"MAC"});
srslte::sch_pdu pdu(10, mac_logger);
byte_buffer_t buffer;
pdu.init_tx(&buffer, pdu_size, true);
@ -401,13 +381,13 @@ int mac_sch_pdu_pack_test4()
pdu.del_subh();
// write PDU
pdu.write_packet(srslte::log_ref{"MAC"});
pdu.write_packet(mac_logger);
// 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_logger.info(buffer.msg, buffer.N_bytes, "MAC PDU (%d B):", buffer.N_bytes);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(buffer.msg, buffer.N_bytes, 0x1001, true, 1, 0);
@ -424,13 +404,13 @@ int mac_sch_pdu_pack_test5()
{
rlc_dummy rlc;
srslte::log_ref mac_log("MAC");
auto& mac_logger = srslog::fetch_basic_logger("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, srslte::log_ref{"MAC"});
srslte::sch_pdu pdu(10, mac_logger);
byte_buffer_t buffer;
pdu.init_tx(&buffer, pdu_size, true);
@ -445,13 +425,13 @@ int mac_sch_pdu_pack_test5()
TESTASSERT(pdu.get()->set_sdu(2, pdu_size - 1, &rlc) != 0);
// write PDU
pdu.write_packet(srslte::log_ref{"MAC"});
pdu.write_packet(mac_logger);
// 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_logger.info(buffer.msg, buffer.N_bytes, "MAC PDU (%d B):", buffer.N_bytes);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(buffer.msg, buffer.N_bytes, 0x1001, true, 1, 0);
@ -463,10 +443,10 @@ int mac_sch_pdu_pack_test5()
// Test for Long BSR CE
int mac_sch_pdu_pack_test6()
{
srslte::log_ref mac_log("MAC");
auto& mac_logger = srslog::fetch_basic_logger("MAC");
const uint32_t pdu_size = 8;
srslte::sch_pdu pdu(10, srslte::log_ref{"MAC"});
srslte::sch_pdu pdu(10, mac_logger);
uint8_t tv[pdu_size] = {0x3e, 0x1f, 0x86, 0x18, 0x61, 0x00, 0x00, 0x00}; // upper edge case
uint8_t tv2[pdu_size] = {0x3e, 0x1f, 0x04, 0x10, 0x41, 0x00, 0x00, 0x00}; // lower edge case
@ -489,7 +469,7 @@ int mac_sch_pdu_pack_test6()
TESTASSERT(pdu.get()->set_bsr(buff_size_tx, srslte::ul_sch_lcid::LONG_BSR));
// write PDU
pdu.write_packet(srslte::log_ref{"MAC"});
pdu.write_packet(mac_logger);
// compare with tv
TESTASSERT(memcmp(buffer.msg, tv, buffer.N_bytes) == 0);
@ -517,10 +497,10 @@ int mac_sch_pdu_pack_test6()
TESTASSERT(buff_size_rx[i] == buff_size_tx[i]);
}
mac_log->info("%s\n", pdu.to_string().c_str());
mac_logger.info("%s", pdu.to_string().c_str());
// log
mac_log->info_hex(buffer.msg, buffer.N_bytes, "MAC PDU (%d B):\n", buffer.N_bytes);
mac_logger.info(buffer.msg, buffer.N_bytes, "MAC PDU (%d B):", buffer.N_bytes);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(buffer.msg, buffer.N_bytes, 0x1001, true, 1, 0);
@ -545,13 +525,13 @@ int mac_sch_pdu_pack_test6()
TESTASSERT(pdu.get()->set_bsr(buff_size_tx_low_edge, srslte::ul_sch_lcid::LONG_BSR));
// write PDU
pdu.write_packet(srslte::log_ref{"MAC"});
mac_log->info("%s\n", pdu.to_string().c_str());
pdu.write_packet(mac_logger);
mac_logger.info("%s", pdu.to_string().c_str());
TESTASSERT(memcmp(buffer.msg, tv2, buffer.N_bytes) == 0);
// log
mac_log->info_hex(buffer.msg, buffer.N_bytes, "MAC PDU (%d B):\n", buffer.N_bytes);
mac_logger.info(buffer.msg, buffer.N_bytes, "MAC PDU (%d B):", buffer.N_bytes);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(buffer.msg, buffer.N_bytes, 0x1001, true, 1, 0);
@ -598,13 +578,13 @@ int mac_sch_pdu_pack_test6()
TESTASSERT(pdu.get()->set_bsr(buff_size_max_idx, srslte::ul_sch_lcid::LONG_BSR));
// write PDU
pdu.write_packet(srslte::log_ref{"MAC"});
mac_log->info("%s\n", pdu.to_string().c_str());
pdu.write_packet(mac_logger);
mac_logger.info("%s", pdu.to_string().c_str());
TESTASSERT(memcmp(buffer.msg, tv3, buffer.N_bytes) == 0);
// log
mac_log->info_hex(buffer.msg, buffer.N_bytes, "MAC PDU (%d B):\n", buffer.N_bytes);
mac_logger.info(buffer.msg, buffer.N_bytes, "MAC PDU (%d B):", buffer.N_bytes);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(buffer.msg, buffer.N_bytes, 0x1001, true, 1, 0);
@ -640,13 +620,13 @@ int mac_sch_pdu_pack_test6()
// Test for short MAC PDU containing padding only
int mac_sch_pdu_pack_test7()
{
srslte::log_ref mac_log("MAC");
auto& mac_logger = srslog::fetch_basic_logger("MAC");
rlc_dummy rlc;
rlc.write_sdu(1, 8);
const uint32_t pdu_size = 2;
srslte::sch_pdu pdu(10, srslte::log_ref{"MAC"});
srslte::sch_pdu pdu(10, mac_logger);
uint8_t tv[pdu_size] = {0x1f, 0x1f};
@ -668,13 +648,13 @@ int mac_sch_pdu_pack_test7()
pdu.del_subh();
// write PDU
pdu.write_packet(srslte::log_ref{"MAC"});
pdu.write_packet(mac_logger);
// 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_logger.info(buffer.msg, buffer.N_bytes, "MAC PDU (%d B):", buffer.N_bytes);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(buffer.msg, buffer.N_bytes, 0x1001, true, 1, 0);
@ -686,10 +666,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{"MAC"};
auto& mac_logger = srslog::fetch_basic_logger("MAC");
const uint32_t pdu_size = 2;
srslte::sch_pdu pdu(10, log_h);
srslte::sch_pdu pdu(10, mac_logger);
std::bitset<8> cc_mask(uniform_dist_u8(rand_gen));
// subheader: R|F2|E|LCID = 0|0|0|11011
@ -716,14 +696,14 @@ int mac_sch_pdu_pack_test8()
TESTASSERT(pdu.get()->set_scell_activation_cmd(cc_activ_list));
// write PDU
pdu.write_packet(log_h);
pdu.write_packet(mac_logger);
// compare with tv
TESTASSERT(memcmp(buffer.msg, tv, buffer.N_bytes) == 0);
// log
log_h->info("Activation mask chosen was 0x%x", tv[1]);
log_h->info_hex(buffer.msg, buffer.N_bytes, "MAC PDU with SCell Activation CE (%d B):\n", buffer.N_bytes);
mac_logger.info("Activation mask chosen was 0x%x", tv[1]);
mac_logger.info(buffer.msg, buffer.N_bytes, "MAC PDU with SCell Activation CE (%d B):", buffer.N_bytes);
#if HAVE_PCAP
pcap_handle->write_dl_crnti(tv, sizeof(tv), 0x1001, true, 1, 0);
@ -735,10 +715,10 @@ int mac_sch_pdu_pack_test8()
// Test for Short BSR CE
int mac_sch_pdu_pack_test9()
{
srslte::log_ref mac_log("MAC");
auto& mac_logger = srslog::fetch_basic_logger("MAC");
const uint32_t pdu_size = 3;
srslte::sch_pdu pdu(10, srslte::log_ref{"MAC"});
srslte::sch_pdu pdu(10, mac_logger);
uint8_t tv[pdu_size] = {0x3f, 0x1d, 0x09};
@ -757,13 +737,13 @@ int mac_sch_pdu_pack_test9()
TESTASSERT(pdu.new_subh() == false);
// write PDU
pdu.write_packet(srslte::log_ref{"MAC"});
pdu.write_packet(mac_logger);
// 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_logger.info(buffer.msg, buffer.N_bytes, "MAC PDU (%d B):", buffer.N_bytes);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(buffer.msg, buffer.N_bytes, 0x1001, true, 1, 0);
@ -775,10 +755,10 @@ int mac_sch_pdu_pack_test9()
// Test for Short BSR CE + PHR CE
int mac_sch_pdu_pack_test10()
{
srslte::log_ref mac_log("MAC");
auto& mac_logger = srslog::fetch_basic_logger("MAC");
const uint32_t pdu_size = 4;
srslte::sch_pdu pdu(10, srslte::log_ref{"MAC"});
srslte::sch_pdu pdu(10, mac_logger);
uint8_t tv[pdu_size] = {0x3d, 0x1a, 0x1f, 0x21};
@ -800,13 +780,13 @@ int mac_sch_pdu_pack_test10()
TESTASSERT(pdu.get()->set_phr(10.1));
// write PDU
pdu.write_packet(srslte::log_ref{"MAC"});
pdu.write_packet(mac_logger);
// 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_logger.info(buffer.msg, buffer.N_bytes, "MAC PDU (%d B):", buffer.N_bytes);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(buffer.msg, buffer.N_bytes, 0x1001, true, 1, 0);
@ -818,10 +798,10 @@ int mac_sch_pdu_pack_test10()
// Pack test for short MAC PDU, trying to add long BSR but no space left
int mac_sch_pdu_pack_test11()
{
srslte::log_ref mac_log("MAC");
auto& mac_logger = srslog::fetch_basic_logger("MAC");
const uint32_t pdu_size = 3;
srslte::sch_pdu pdu(10, srslte::log_ref{"MAC"});
srslte::sch_pdu pdu(10, mac_logger);
uint8_t tv[pdu_size] = {0x1f, 0x00, 0x00};
@ -842,13 +822,13 @@ int mac_sch_pdu_pack_test11()
pdu.del_subh();
// write PDU
pdu.write_packet(srslte::log_ref{"MAC"});
pdu.write_packet(mac_logger);
// 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_logger.info(buffer.msg, buffer.N_bytes, "MAC PDU (%d B):", buffer.N_bytes);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(buffer.msg, buffer.N_bytes, 0x1001, true, 1, 0);
@ -860,19 +840,14 @@ int mac_sch_pdu_pack_test11()
// Test for checking error cases
int mac_sch_pdu_pack_error_test()
{
srslte::log_filter rlc_log("RLC");
rlc_log.set_level(srslte::LOG_LEVEL_DEBUG);
rlc_log.set_hex_limit(100000);
rlc_dummy rlc;
srslte::log_ref mac_log("MAC");
auto& mac_logger = srslog::fetch_basic_logger("MAC");
// create RLC SDUs
rlc.write_sdu(1, 8);
const uint32_t pdu_size = 150;
srslte::sch_pdu pdu(10, srslte::log_ref{"MAC"});
srslte::sch_pdu pdu(10, mac_logger);
byte_buffer_t buffer;
pdu.init_tx(&buffer, pdu_size, true);
@ -893,7 +868,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(srslte::log_ref{"MAC"}) == nullptr);
TESTASSERT(pdu.write_packet(mac_logger) == nullptr);
// reset buffer
buffer.clear();
@ -903,13 +878,13 @@ 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(srslte::log_ref{"MAC"}));
TESTASSERT(pdu.write_packet(mac_logger));
// log
mac_log->info_hex(buffer.msg, buffer.N_bytes, "MAC PDU (%d B):\n", buffer.N_bytes);
mac_logger.info(buffer.msg, buffer.N_bytes, "MAC PDU (%d B):", buffer.N_bytes);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(buffer.msg, buffer.N_bytes, 0x1001, true, 1,0);
pcap_handle->write_ul_crnti(buffer.msg, buffer.N_bytes, 0x1001, true, 1, 0);
#endif
return SRSLTE_SUCCESS;
@ -920,10 +895,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_ref mac_log("MAC");
auto& mac_logger = srslog::fetch_basic_logger("MAC");
const uint32_t pdu_size = 30;
srslte::mch_pdu mch_pdu(10, srslte::log_ref{"MAC"});
srslte::mch_pdu mch_pdu(10, mac_logger);
byte_buffer_t buffer;
mch_pdu.init_tx(&buffer, pdu_size, true);
@ -945,13 +920,13 @@ int mac_mch_pdu_pack_test1()
mch_pdu.get()->set_sdu(1, 10, sdu1);
// write PDU
TESTASSERT(mch_pdu.write_packet(srslte::log_ref{"MAC"}) == buffer.msg);
TESTASSERT(mch_pdu.write_packet(mac_logger) == buffer.msg);
// log
mac_log->info_hex(buffer.msg, buffer.N_bytes, "MAC PDU (%d B):\n", buffer.N_bytes);
mac_logger.info(buffer.msg, buffer.N_bytes, "MAC PDU (%d B):", buffer.N_bytes);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(buffer.msg, buffer.N_bytes, 0x1001, true, 1,0);
pcap_handle->write_ul_crnti(buffer.msg, buffer.N_bytes, 0x1001, true, 1, 0);
#endif
// compare with TV
@ -969,7 +944,7 @@ int mac_sch_pdu_unpack_test1()
{
static uint8_t tv[] = {0x3f, 0x3f, 0x21, 0x3f, 0x03, 0x00, 0x04, 0x00, 0x04};
srslte::sch_pdu pdu(10, srslte::log_ref{"MAC"});
srslte::sch_pdu pdu(10, srslog::fetch_basic_logger("MAC"));
pdu.init_rx(sizeof(tv), false);
pdu.parse_packet(tv);
@ -978,7 +953,7 @@ int mac_sch_pdu_unpack_test1()
TESTASSERT(pdu.next() == false);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(tv, sizeof(tv), 0x1001, true, 1,0);
pcap_handle->write_ul_crnti(tv, sizeof(tv), 0x1001, true, 1, 0);
#endif
return SRSLTE_SUCCESS;
@ -989,7 +964,7 @@ int mac_sch_pdu_unpack_test2()
{
static uint8_t tv[] = {0x3f, 0x3f};
srslte::sch_pdu pdu(20, srslte::log_ref{"MAC"});
srslte::sch_pdu pdu(20, srslog::fetch_basic_logger("MAC"));
pdu.init_rx(sizeof(tv), false);
pdu.parse_packet(tv);
@ -998,7 +973,7 @@ int mac_sch_pdu_unpack_test2()
TESTASSERT(pdu.next() == false);
#if HAVE_PCAP
pcap_handle->write_ul_crnti(tv, sizeof(tv), 0x1001, true, 1,0);
pcap_handle->write_ul_crnti(tv, sizeof(tv), 0x1001, true, 1, 0);
#endif
return SRSLTE_SUCCESS;
@ -1009,7 +984,7 @@ int mac_sch_pdu_unpack_test3()
{
static uint8_t tv[] = {0x3d, 0x1f, 0x1f, 0x00};
srslte::sch_pdu pdu(20, srslte::log_ref{"MAC"});
srslte::sch_pdu pdu(20, srslog::fetch_basic_logger("MAC"));
pdu.init_rx(sizeof(tv), false);
pdu.parse_packet(tv);
@ -1038,10 +1013,6 @@ int mac_slsch_pdu_unpack_test1()
0x18, 0x6A, 0x07, 0x20, 0x7C, 0xE1, 0xE0, 0x04, 0x40, 0x02, 0x04, 0x80, 0x60,
0x2C, 0x00, 0x00, 0x00, 0x00, 0x00, 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);
#if HAVE_PCAP
pcap_handle->write_sl_crnti(tv, sizeof(tv), CRNTI, true, 1, 0);
#endif
@ -1055,12 +1026,14 @@ int main(int argc, char** argv)
pcap_handle = std::unique_ptr<srslte::mac_pcap>(new srslte::mac_pcap());
pcap_handle->open("mac_pdu_test.pcap");
#endif
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);
auto& mac_logger = srslog::fetch_basic_logger("MAC", false);
mac_logger.set_level(srslog::basic_levels::debug);
mac_logger.set_hex_dump_max_size(-1);
auto& rlc_logger = srslog::fetch_basic_logger("RLC", false);
rlc_logger.set_level(srslog::basic_levels::debug);
rlc_logger.set_hex_dump_max_size(-1);
srslog::init();
TESTASSERT(mac_rar_pdu_unpack_test1() == SRSLTE_SUCCESS);
TESTASSERT(mac_rar_pdu_unpack_test2() == SRSLTE_SUCCESS);

@ -40,10 +40,10 @@ ue::ue(uint16_t rnti_,
phy(phy_),
log_h(log_),
logger(logger),
mac_msg_dl(20, log_),
mch_mac_msg_dl(10, log_),
mac_msg_ul(20, log_),
pdus(128),
mac_msg_dl(20, logger),
mch_mac_msg_dl(10, logger),
mac_msg_ul(20, logger),
pdus(logger, 128),
nof_rx_harq_proc(nof_rx_harq_proc_),
nof_tx_harq_proc(nof_tx_harq_proc_),
rx_used_buffers(nof_cells_),
@ -59,7 +59,7 @@ ue::ue(uint16_t rnti_,
}
}
pdus.init(this, log_h);
pdus.init(this);
// Allocate buffer for PCell
allocate_cc_buffers();
@ -515,7 +515,7 @@ uint8_t* ue::generate_pdu(uint32_t ue_cc_idx,
allocate_ce(&mac_msg_dl, pdu[i].lcid);
}
}
ret = mac_msg_dl.write_packet(log_h);
ret = mac_msg_dl.write_packet(logger);
logger.info("0x%x %s", rnti, mac_msg_dl.to_string().c_str());
} else {
logger.error(
@ -550,7 +550,7 @@ uint8_t* ue::generate_mch_pdu(uint32_t harq_pid,
}
}
ret = mch_mac_msg_dl.write_packet(log_h);
ret = mch_mac_msg_dl.write_packet(logger);
return ret;
}

@ -34,7 +34,7 @@ public:
class demux : public srslte::pdu_queue::process_callback
{
public:
demux(srslte::log_ref log_h_, srslog::basic_logger& logger);
explicit demux(srslog::basic_logger& logger);
void init(phy_interface_mac_common* phy_h_,
rlc_interface_mac* rlc,
mac_interface_demux* mac,
@ -62,7 +62,6 @@ private:
uint8_t bcch_buffer[MAX_BCCH_PDU_LEN]; // BCCH PID has a dedicated buffer
// args
srslte::log_ref log_h;
srslog::basic_logger& logger;
phy_interface_mac_common* phy_h = nullptr;
rlc_interface_mac* rlc = nullptr;

@ -108,7 +108,6 @@ private:
rlc_interface_mac* rlc_h = nullptr;
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 = {};

@ -32,7 +32,7 @@ namespace srsue {
class mux
{
public:
mux(srslte::log_ref log_, srslog::basic_logger& logger);
explicit mux(srslog::basic_logger& logger);
~mux(){};
void reset();
void init(rlc_interface_mac* rlc, bsr_interface_mux* bsr_procedure, phr_proc* phr_procedure_);
@ -70,7 +70,6 @@ private:
// Mutex for exclusive access
std::mutex mutex;
srslte::log_ref log_h;
srslog::basic_logger& logger;
rlc_interface_mac* rlc = nullptr;
bsr_interface_mux* bsr_procedure = nullptr;

@ -21,8 +21,8 @@
namespace srsue {
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_)
demux::demux(srslog::basic_logger& logger) :
logger(logger), mac_msg(20, logger), mch_mac_msg(20, logger), pending_mac_msg(20, logger), pdus(logger)
{}
void demux::init(phy_interface_mac_common* phy_,
@ -34,7 +34,7 @@ void demux::init(phy_interface_mac_common* phy_,
rlc = rlc_;
mac = mac_;
time_alignment_timer = time_alignment_timer_;
pdus.init(this, log_h);
pdus.init(this);
}
void demux::reset()
@ -119,7 +119,6 @@ void demux::push_pdu_temp_crnti(uint8_t* buff, uint32_t nof_bytes)
*/
void demux::push_pdu(uint8_t* buff, uint32_t nof_bytes, uint32_t tti)
{
// Process Real-Time PDUs
process_sch_pdu_rt(buff, nof_bytes, tti);
@ -174,7 +173,7 @@ void demux::process_pdu(uint8_t* mac_pdu, uint32_t nof_bytes, srslte::pdu_queue:
void demux::process_sch_pdu_rt(uint8_t* buff, uint32_t nof_bytes, uint32_t tti)
{
srslte::sch_pdu mac_msg_rt(20, log_h);
srslte::sch_pdu mac_msg_rt(20, logger);
mac_msg_rt.init_rx(nof_bytes);
mac_msg_rt.parse_packet(buff);
@ -232,7 +231,6 @@ void demux::process_mch_pdu(srslte::mch_pdu* mch_msg)
{
// disgarding headers that have already been processed
while (mch_msg->next()) {
if (srslte::mch_lcid::MCH_SCHED_INFO == mch_msg->get()->mch_ce_type()) {
uint16_t stop;
uint8_t lcid;

@ -27,11 +27,10 @@
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, logger),
demux_unit(log_h, logger),
mch_msg(10, logger),
mux_unit(logger),
demux_unit(logger),
ra_procedure(logger),
sr_procedure(logger),
bsr_procedure(logger),
@ -192,7 +191,6 @@ 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!! */
@ -416,7 +414,6 @@ void mac::tb_decoded(uint32_t cc_idx, mac_grant_dl_t grant, bool ack[SRSLTE_MAX_
pcap->write_dl_pch(pch_payload_buffer, grant.tb[0].tbs, true, grant.tti, cc_idx);
}
} else {
// Assert DL HARQ entity
if (dl_harq.at(cc_idx) == nullptr) {
Error("HARQ entity %d has not been created", cc_idx);
@ -446,7 +443,6 @@ void mac::new_grant_dl(uint32_t cc_idx,
if (SRSLTE_RNTI_ISRAR(grant.rnti)) {
ra_procedure.new_grant_dl(grant, action);
} else if (grant.rnti == SRSLTE_PRNTI) {
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)", grant.tb[0].tbs, int(pch_payload_buffer_sz));

@ -23,9 +23,7 @@
namespace srsue {
mux::mux(srslte::log_ref log_, srslog::basic_logger& logger) :
pdu_msg(MAX_NOF_SUBHEADERS, log_), log_h(log_), logger(logger)
{}
mux::mux(srslog::basic_logger& logger) : logger(logger), pdu_msg(MAX_NOF_SUBHEADERS, logger) {}
void mux::init(rlc_interface_mac* rlc_, bsr_interface_mux* bsr_procedure_, phr_proc* phr_procedure_)
{
@ -287,7 +285,7 @@ uint8_t* mux::pdu_get(srslte::byte_buffer_t* payload, uint32_t pdu_sz)
bsr_procedure->update_bsr_tti_end(&bsr);
// Generate MAC PDU and save to buffer
uint8_t* ret = pdu_msg.write_packet(log_h);
uint8_t* ret = pdu_msg.write_packet(logger);
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);

@ -47,9 +47,9 @@ ttcn3_syssim::ttcn3_syssim(srslte::logger& logger_file_, srslte::logger& 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),
mac_msg_ul(20, ss_mac_logger),
mac_msg_dl(20, ss_mac_logger),
pdus(logger, 128),
logger_stdout(logger_stdout_),
logger_file(logger_file_),
old_logger(&logger_file),
@ -143,7 +143,7 @@ int ttcn3_syssim::init(const all_args_t& args_)
}
// Init common SS layers
pdus.init(this, log);
pdus.init(this);
return SRSLTE_SUCCESS;
}
@ -360,7 +360,7 @@ void ttcn3_syssim::new_tti_indication(uint64_t res)
}
// 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(logger);
if (mac_pdu_ptr != nullptr) {
if (force_lcid != -1 && lcid == 0) {
if (has_single_sdu) {
@ -1170,7 +1170,7 @@ void ttcn3_syssim::write_sdu(uint32_t lcid, unique_byte_buffer_t sdu)
{
logger.info(sdu->msg, sdu->N_bytes, "Received SDU on LCID=%d", lcid);
uint8_t* mac_pdu_ptr = mac_msg_dl.write_packet(log);
uint8_t* mac_pdu_ptr = mac_msg_dl.write_packet(logger);
logger.info(mac_pdu_ptr, mac_msg_dl.get_pdu_len(), "DL MAC PDU:");
// Prepare MAC grant for CCCH

Loading…
Cancel
Save