From f424f2e1137f9665c72339b11cac02ecfe0592ef Mon Sep 17 00:00:00 2001 From: faluco Date: Wed, 10 Feb 2021 11:47:56 +0100 Subject: [PATCH] - Upgraded PDCP classes in lib to use srslog. - Update tests to new changes. --- lib/include/srslte/upper/pdcp.h | 2 +- lib/include/srslte/upper/pdcp_entity_base.h | 10 +- lib/include/srslte/upper/pdcp_entity_lte.h | 2 +- lib/include/srslte/upper/pdcp_entity_nr.h | 2 +- lib/src/upper/pdcp.cc | 71 ++++++------- lib/src/upper/pdcp_entity_base.cc | 90 ++++++++-------- lib/src/upper/pdcp_entity_lte.cc | 110 ++++++++++---------- lib/src/upper/pdcp_entity_nr.cc | 54 +++++----- lib/test/upper/pdcp_base_test.h | 25 ++--- lib/test/upper/pdcp_lte_test.h | 12 +-- lib/test/upper/pdcp_lte_test_rx.cc | 59 ++++++----- lib/test/upper/pdcp_nr_test.h | 12 +-- lib/test/upper/pdcp_nr_test_discard_sdu.cc | 20 ++-- lib/test/upper/pdcp_nr_test_rx.cc | 40 +++---- lib/test/upper/pdcp_nr_test_tx.cc | 58 ++++++----- 15 files changed, 294 insertions(+), 273 deletions(-) diff --git a/lib/include/srslte/upper/pdcp.h b/lib/include/srslte/upper/pdcp.h index e823cca3e..9d4422c32 100644 --- a/lib/include/srslte/upper/pdcp.h +++ b/lib/include/srslte/upper/pdcp.h @@ -66,7 +66,7 @@ private: srsue::rrc_interface_pdcp* rrc = nullptr; srsue::gw_interface_pdcp* gw = nullptr; srslte::task_sched_handle task_sched; - srslte::log_ref pdcp_log; + srslog::basic_logger& logger; std::map > pdcp_array, pdcp_array_mrb; diff --git a/lib/include/srslte/upper/pdcp_entity_base.h b/lib/include/srslte/upper/pdcp_entity_base.h index 7785e014c..b4b18868e 100644 --- a/lib/include/srslte/upper/pdcp_entity_base.h +++ b/lib/include/srslte/upper/pdcp_entity_base.h @@ -52,7 +52,7 @@ static const char pdcp_d_c_text[PDCP_D_C_N_ITEMS][20] = {"Control PDU", "Data PD class pdcp_entity_base { public: - pdcp_entity_base(task_sched_handle task_sched_, srslte::log_ref log_); + pdcp_entity_base(task_sched_handle task_sched_, srslog::basic_logger& logger); pdcp_entity_base(pdcp_entity_base&&) = default; virtual ~pdcp_entity_base(); virtual void reset() = 0; @@ -73,7 +73,7 @@ public: } else { integrity_direction = direction; } - log->debug("LCID=%d, integrity=%s\n", lcid, srslte_direction_text[integrity_direction]); + logger.debug("LCID=%d, integrity=%s", lcid, srslte_direction_text[integrity_direction]); } void enable_encryption(srslte_direction_t direction = DIRECTION_TXRX) @@ -86,7 +86,7 @@ public: } else { encryption_direction = direction; } - log->debug("LCID=%d encryption=%s\n", lcid, srslte_direction_text[integrity_direction]); + logger.debug("LCID=%d encryption=%s", lcid, srslte_direction_text[integrity_direction]); } void enable_security_timed(srslte_direction_t direction, uint32_t sn) @@ -99,7 +99,7 @@ public: enable_security_rx_sn = sn; break; default: - log->error("Timed security activation for direction %s not supported.\n", srslte_direction_text[direction]); + logger.error("Timed security activation for direction %s not supported.", srslte_direction_text[direction]); break; } } @@ -124,7 +124,7 @@ public: uint32_t COUNT(uint32_t hfn, uint32_t sn); protected: - srslte::log_ref log; + srslog::basic_logger& logger; srslte::task_sched_handle task_sched; bool active = false; diff --git a/lib/include/srslte/upper/pdcp_entity_lte.h b/lib/include/srslte/upper/pdcp_entity_lte.h index 35819a60c..f8a191f7b 100644 --- a/lib/include/srslte/upper/pdcp_entity_lte.h +++ b/lib/include/srslte/upper/pdcp_entity_lte.h @@ -41,7 +41,7 @@ public: srsue::rrc_interface_pdcp* rrc_, srsue::gw_interface_pdcp* gw_, srslte::task_sched_handle task_sched_, - srslte::log_ref log_, + srslog::basic_logger& logger, uint32_t lcid_, pdcp_config_t cfg_); ~pdcp_entity_lte() override; diff --git a/lib/include/srslte/upper/pdcp_entity_nr.h b/lib/include/srslte/upper/pdcp_entity_nr.h index 7232d7209..f973243bd 100644 --- a/lib/include/srslte/upper/pdcp_entity_nr.h +++ b/lib/include/srslte/upper/pdcp_entity_nr.h @@ -37,7 +37,7 @@ public: srsue::rrc_interface_pdcp* rrc_, srsue::gw_interface_pdcp* gw_, srslte::task_sched_handle task_sched_, - srslte::log_ref log_, + srslog::basic_logger& logger, uint32_t lcid, pdcp_config_t cfg_); ~pdcp_entity_nr() final; diff --git a/lib/src/upper/pdcp.cc b/lib/src/upper/pdcp.cc index fcdcf7543..3a89f64b8 100644 --- a/lib/src/upper/pdcp.cc +++ b/lib/src/upper/pdcp.cc @@ -17,7 +17,9 @@ namespace srslte { -pdcp::pdcp(srslte::task_sched_handle task_sched_, const char* logname) : task_sched(task_sched_), pdcp_log(logname) {} +pdcp::pdcp(srslte::task_sched_handle task_sched_, const char* logname) : + task_sched(task_sched_), logger(srslog::fetch_basic_logger(logname)) +{} pdcp::~pdcp() { @@ -79,7 +81,7 @@ void pdcp::write_sdu(uint32_t lcid, unique_byte_buffer_t sdu) if (valid_lcid(lcid)) { pdcp_array.at(lcid)->write_sdu(std::move(sdu)); } else { - pdcp_log->warning("Writing sdu: lcid=%d. Deallocating sdu\n", lcid); + logger.warning("Writing sdu: lcid=%d. Deallocating sdu", lcid); } } @@ -98,29 +100,29 @@ void pdcp::add_bearer(uint32_t lcid, pdcp_config_t cfg) // create NR entity for 18bit SN length #ifdef HAVE_5GNR - entity.reset(new pdcp_entity_nr{rlc, rrc, gw, task_sched, pdcp_log, lcid, cfg}); + entity.reset(new pdcp_entity_nr{rlc, rrc, gw, task_sched, logger, lcid, cfg}); #else - pdcp_log->error("Invalid PDCP configuration.\n"); + logger.error("Invalid PDCP configuration."); return; #endif } else { - entity.reset(new pdcp_entity_lte{rlc, rrc, gw, task_sched, pdcp_log, lcid, cfg}); + entity.reset(new pdcp_entity_lte{rlc, rrc, gw, task_sched, logger, lcid, cfg}); } if (not pdcp_array.insert(std::make_pair(lcid, std::move(entity))).second) { - pdcp_log->error("Error inserting PDCP entity in to array.\n"); + logger.error("Error inserting PDCP entity in to array."); return; } - pdcp_log->info("Add %s (lcid=%d, bearer_id=%d, sn_len=%dbits)\n", - rrc->get_rb_name(lcid).c_str(), - lcid, - cfg.bearer_id, - cfg.sn_len); + logger.info("Add %s (lcid=%d, bearer_id=%d, sn_len=%dbits)", + rrc->get_rb_name(lcid).c_str(), + lcid, + cfg.bearer_id, + cfg.sn_len); { std::lock_guard lock(cache_mutex); valid_lcids_cached.insert(lcid); } } else { - pdcp_log->info("Bearer %s already configured.\n", rrc->get_rb_name(lcid).c_str()); + logger.info("Bearer %s already configured.", rrc->get_rb_name(lcid).c_str()); } } @@ -128,20 +130,20 @@ void pdcp::add_bearer_mrb(uint32_t lcid, pdcp_config_t cfg) { if (not valid_mch_lcid(lcid)) { if (not pdcp_array_mrb - .insert(std::make_pair(lcid, - std::unique_ptr( - new pdcp_entity_lte(rlc, rrc, gw, task_sched, pdcp_log, lcid, cfg)))) + .insert(std::make_pair( + lcid, + std::unique_ptr(new pdcp_entity_lte(rlc, rrc, gw, task_sched, logger, lcid, cfg)))) .second) { - pdcp_log->error("Error inserting PDCP entity in to array\n."); + logger.error("Error inserting PDCP entity in to array."); return; } - pdcp_log->info("Add %s (lcid=%d, bearer_id=%d, sn_len=%dbits)\n", - rrc->get_rb_name(lcid).c_str(), - lcid, - cfg.bearer_id, - cfg.sn_len); + logger.info("Add %s (lcid=%d, bearer_id=%d, sn_len=%dbits)", + rrc->get_rb_name(lcid).c_str(), + lcid, + cfg.bearer_id, + cfg.sn_len); } else { - pdcp_log->warning("Bearer %s already configured. Reconfiguration not supported\n", rrc->get_rb_name(lcid).c_str()); + logger.warning("Bearer %s already configured. Reconfiguration not supported", rrc->get_rb_name(lcid).c_str()); } } @@ -153,9 +155,9 @@ void pdcp::del_bearer(uint32_t lcid) } if (valid_lcid(lcid)) { pdcp_array.erase(lcid); - pdcp_log->warning("Deleted PDCP bearer %s\n", rrc->get_rb_name(lcid).c_str()); + logger.warning("Deleted PDCP bearer %s", rrc->get_rb_name(lcid).c_str()); } else { - pdcp_log->warning("Can't delete bearer %s. Bearer doesn't exist.\n", rrc->get_rb_name(lcid).c_str()); + logger.warning("Can't delete bearer %s. Bearer doesn't exist.", rrc->get_rb_name(lcid).c_str()); } } @@ -168,20 +170,19 @@ void pdcp::change_lcid(uint32_t old_lcid, uint32_t new_lcid) auto it = pdcp_array.find(old_lcid); std::unique_ptr pdcp_entity = std::move(it->second); if (not pdcp_array.insert(std::make_pair(new_lcid, std::move(pdcp_entity))).second) { - pdcp_log->error("Error inserting PDCP entity into array\n."); + logger.error("Error inserting PDCP entity into array."); return; } // erase from old position pdcp_array.erase(it); valid_lcids_cached.erase(old_lcid); valid_lcids_cached.insert(new_lcid); - pdcp_log->warning("Changed LCID of PDCP bearer from %d to %d\n", old_lcid, new_lcid); + logger.warning("Changed LCID of PDCP bearer from %d to %d", old_lcid, new_lcid); } else { - pdcp_log->error( - "Can't change PDCP of bearer %s from %d to %d. Bearer doesn't exist or new LCID already occupied.\n", - rrc->get_rb_name(old_lcid).c_str(), - old_lcid, - new_lcid); + logger.error("Can't change PDCP of bearer %s from %d to %d. Bearer doesn't exist or new LCID already occupied.", + rrc->get_rb_name(old_lcid).c_str(), + old_lcid, + new_lcid); } } @@ -254,7 +255,7 @@ void pdcp::write_pdu(uint32_t lcid, unique_byte_buffer_t pdu) if (valid_lcid(lcid)) { pdcp_array.at(lcid)->write_pdu(std::move(pdu)); } else { - pdcp_log->warning("Writing pdu: lcid=%d. Deallocating pdu\n", lcid); + logger.warning("Writing pdu: lcid=%d. Deallocating pdu", lcid); } } @@ -287,14 +288,14 @@ void pdcp::notify_delivery(uint32_t lcid, const std::vector& pdcp_sns) if (valid_lcid(lcid)) { pdcp_array.at(lcid)->notify_delivery(pdcp_sns); } else { - pdcp_log->warning("Could not notify delivery: lcid=%d, nof_sn=%ld.\n", lcid, pdcp_sns.size()); + logger.warning("Could not notify delivery: lcid=%d, nof_sn=%ld.", lcid, pdcp_sns.size()); } } bool pdcp::valid_lcid(uint32_t lcid) { if (lcid >= SRSLTE_N_RADIO_BEARERS) { - pdcp_log->error("Radio bearer id must be in [0:%d] - %d", SRSLTE_N_RADIO_BEARERS, lcid); + logger.error("Radio bearer id must be in [0:%d] - %d", SRSLTE_N_RADIO_BEARERS, lcid); return false; } @@ -304,7 +305,7 @@ bool pdcp::valid_lcid(uint32_t lcid) bool pdcp::valid_mch_lcid(uint32_t lcid) { if (lcid >= SRSLTE_N_MCH_LCIDS) { - pdcp_log->error("Radio bearer id must be in [0:%d] - %d", SRSLTE_N_RADIO_BEARERS, lcid); + logger.error("Radio bearer id must be in [0:%d] - %d", SRSLTE_N_RADIO_BEARERS, lcid); return false; } diff --git a/lib/src/upper/pdcp_entity_base.cc b/lib/src/upper/pdcp_entity_base.cc index ffa1538b9..22a3db98f 100644 --- a/lib/src/upper/pdcp_entity_base.cc +++ b/lib/src/upper/pdcp_entity_base.cc @@ -17,8 +17,8 @@ namespace srslte { -pdcp_entity_base::pdcp_entity_base(task_sched_handle task_sched_, srslte::log_ref log_) : - log(log_), task_sched(task_sched_) +pdcp_entity_base::pdcp_entity_base(task_sched_handle task_sched_, srslog::basic_logger& logger) : + logger(logger), task_sched(task_sched_) {} pdcp_entity_base::~pdcp_entity_base() {} @@ -27,14 +27,14 @@ void pdcp_entity_base::config_security(as_security_config_t sec_cfg_) { sec_cfg = sec_cfg_; - log->info("Configuring security with %s and %s\n", - integrity_algorithm_id_text[sec_cfg.integ_algo], - ciphering_algorithm_id_text[sec_cfg.cipher_algo]); + logger.info("Configuring security with %s and %s", + integrity_algorithm_id_text[sec_cfg.integ_algo], + ciphering_algorithm_id_text[sec_cfg.cipher_algo]); - log->debug_hex(sec_cfg.k_rrc_enc.data(), 32, "K_rrc_enc"); - log->debug_hex(sec_cfg.k_up_enc.data(), 32, "K_up_enc"); - log->debug_hex(sec_cfg.k_rrc_int.data(), 32, "K_rrc_int"); - log->debug_hex(sec_cfg.k_up_int.data(), 32, "K_up_int"); + logger.debug(sec_cfg.k_rrc_enc.data(), 32, "K_rrc_enc"); + logger.debug(sec_cfg.k_up_enc.data(), 32, "K_up_enc"); + logger.debug(sec_cfg.k_rrc_int.data(), 32, "K_rrc_int"); + logger.debug(sec_cfg.k_up_int.data(), 32, "K_up_int"); } /**************************************************************************** @@ -67,13 +67,13 @@ void pdcp_entity_base::integrity_generate(uint8_t* msg, uint32_t msg_len, uint32 break; } - log->debug("Integrity gen input: COUNT %" PRIu32 ", Bearer ID %d, Direction %s\n", - count, - cfg.bearer_id, - (cfg.tx_direction == SECURITY_DIRECTION_DOWNLINK ? "Downlink" : "Uplink")); - log->debug_hex(k_int, 32, "Integrity gen key:"); - log->debug_hex(msg, msg_len, "Integrity gen input msg:"); - log->debug_hex(mac, 4, "MAC (generated)"); + logger.debug("Integrity gen input: COUNT %" PRIu32 ", Bearer ID %d, Direction %s", + count, + cfg.bearer_id, + (cfg.tx_direction == SECURITY_DIRECTION_DOWNLINK ? "Downlink" : "Uplink")); + logger.debug(k_int, 32, "Integrity gen key:"); + logger.debug(msg, msg_len, "Integrity gen input msg:"); + logger.debug(mac, 4, "MAC (generated)"); } bool pdcp_entity_base::integrity_verify(uint8_t* msg, uint32_t msg_len, uint32_t count, uint8_t* mac) @@ -105,24 +105,24 @@ bool pdcp_entity_base::integrity_verify(uint8_t* msg, uint32_t msg_len, uint32_t break; } - log->debug("Integrity check input: COUNT %" PRIu32 ", Bearer ID %d, Direction %s\n", - count, - cfg.bearer_id, - cfg.rx_direction == SECURITY_DIRECTION_DOWNLINK ? "Downlink" : "Uplink"); - log->debug_hex(k_int, 32, "Integrity check key:"); - log->debug_hex(msg, msg_len, "Integrity check input msg:"); + logger.debug("Integrity check input: COUNT %" PRIu32 ", Bearer ID %d, Direction %s", + count, + cfg.bearer_id, + cfg.rx_direction == SECURITY_DIRECTION_DOWNLINK ? "Downlink" : "Uplink"); + logger.debug(k_int, 32, "Integrity check key:"); + logger.debug(msg, msg_len, "Integrity check input msg:"); if (sec_cfg.integ_algo != INTEGRITY_ALGORITHM_ID_EIA0) { for (uint8_t i = 0; i < 4; i++) { if (mac[i] != mac_exp[i]) { - log->error_hex(mac_exp, 4, "MAC mismatch (expected)"); - log->error_hex(mac, 4, "MAC mismatch (found)"); + logger.error(mac_exp, 4, "MAC mismatch (expected)"); + logger.error(mac, 4, "MAC mismatch (found)"); is_valid = false; break; } } if (is_valid) { - log->info_hex(mac_exp, 4, "MAC match"); + logger.info(mac_exp, 4, "MAC match"); } } @@ -141,12 +141,12 @@ void pdcp_entity_base::cipher_encrypt(uint8_t* msg, uint32_t msg_len, uint32_t c k_enc = sec_cfg.k_up_enc.data(); } - log->debug("Cipher encrypt input: COUNT: %" PRIu32 ", Bearer ID: %d, Direction %s\n", - count, - cfg.bearer_id, - cfg.tx_direction == SECURITY_DIRECTION_DOWNLINK ? "Downlink" : "Uplink"); - log->debug_hex(k_enc, 32, "Cipher encrypt key:"); - log->debug_hex(msg, msg_len, "Cipher encrypt input msg"); + logger.debug("Cipher encrypt input: COUNT: %" PRIu32 ", Bearer ID: %d, Direction %s", + count, + cfg.bearer_id, + cfg.tx_direction == SECURITY_DIRECTION_DOWNLINK ? "Downlink" : "Uplink"); + logger.debug(k_enc, 32, "Cipher encrypt key:"); + logger.debug(msg, msg_len, "Cipher encrypt input msg"); switch (sec_cfg.cipher_algo) { case CIPHERING_ALGORITHM_ID_EEA0: @@ -166,7 +166,7 @@ void pdcp_entity_base::cipher_encrypt(uint8_t* msg, uint32_t msg_len, uint32_t c default: break; } - log->debug_hex(ct, msg_len, "Cipher encrypt output msg"); + logger.debug(ct, msg_len, "Cipher encrypt output msg"); } void pdcp_entity_base::cipher_decrypt(uint8_t* ct, uint32_t ct_len, uint32_t count, uint8_t* msg) @@ -181,12 +181,12 @@ void pdcp_entity_base::cipher_decrypt(uint8_t* ct, uint32_t ct_len, uint32_t cou k_enc = sec_cfg.k_up_enc.data(); } - log->debug("Cipher decrypt input: COUNT: %" PRIu32 ", Bearer ID: %d, Direction %s\n", - count, - cfg.bearer_id, - (cfg.rx_direction == SECURITY_DIRECTION_DOWNLINK) ? "Downlink" : "Uplink"); - log->debug_hex(k_enc, 32, "Cipher decrypt key:"); - log->debug_hex(ct, ct_len, "Cipher decrypt input msg"); + logger.debug("Cipher decrypt input: COUNT: %" PRIu32 ", Bearer ID: %d, Direction %s", + count, + cfg.bearer_id, + (cfg.rx_direction == SECURITY_DIRECTION_DOWNLINK) ? "Downlink" : "Uplink"); + logger.debug(k_enc, 32, "Cipher decrypt key:"); + logger.debug(ct, ct_len, "Cipher decrypt input msg"); switch (sec_cfg.cipher_algo) { case CIPHERING_ALGORITHM_ID_EEA0: @@ -206,7 +206,7 @@ void pdcp_entity_base::cipher_decrypt(uint8_t* ct, uint32_t ct_len, uint32_t cou default: break; } - log->debug_hex(msg, ct_len, "Cipher decrypt output msg"); + logger.debug(msg, ct_len, "Cipher decrypt output msg"); } /**************************************************************************** @@ -223,7 +223,7 @@ uint32_t pdcp_entity_base::read_data_header(const unique_byte_buffer_t& pdu) { // Check PDU is long enough to extract header if (pdu->N_bytes <= cfg.hdr_len_bytes) { - log->error("PDU too small to extract header\n"); + logger.error("PDU too small to extract header"); return 0; } @@ -246,7 +246,7 @@ uint32_t pdcp_entity_base::read_data_header(const unique_byte_buffer_t& pdu) rcvd_sn_32 = SN(rcvd_sn_32); break; default: - log->error("Cannot extract RCVD_SN, invalid SN length configured: %d\n", cfg.sn_len); + logger.error("Cannot extract RCVD_SN, invalid SN length configured: %d", cfg.sn_len); } return rcvd_sn_32; @@ -262,7 +262,7 @@ void pdcp_entity_base::write_data_header(const srslte::unique_byte_buffer_t& sdu { // Add room for header if (cfg.hdr_len_bytes > sdu->get_headroom()) { - log->error("Not enough space to add header\n"); + logger.error("Not enough space to add header"); return; } sdu->msg -= cfg.hdr_len_bytes; @@ -290,7 +290,7 @@ void pdcp_entity_base::write_data_header(const srslte::unique_byte_buffer_t& sdu sdu->msg[0] |= 0x80; // Data PDU and SN LEN 18 implies DRB, D flag must be present break; default: - log->error("Invalid SN length configuration: %d bits\n", cfg.sn_len); + logger.error("Invalid SN length configuration: %d bits", cfg.sn_len); } } @@ -298,7 +298,7 @@ void pdcp_entity_base::extract_mac(const unique_byte_buffer_t& pdu, uint8_t* mac { // Check enough space for MAC if (pdu->N_bytes < 4) { - log->error("PDU too small to extract MAC-I\n"); + logger.error("PDU too small to extract MAC-I"); return; } @@ -311,7 +311,7 @@ void pdcp_entity_base::append_mac(const unique_byte_buffer_t& sdu, uint8_t* mac) { // Check enough space for MAC if (sdu->N_bytes + 4 > sdu->get_tailroom()) { - log->error("Not enough space to add MAC-I\n"); + logger.error("Not enough space to add MAC-I"); return; } diff --git a/lib/src/upper/pdcp_entity_lte.cc b/lib/src/upper/pdcp_entity_lte.cc index 196b97b17..d351b81a8 100644 --- a/lib/src/upper/pdcp_entity_lte.cc +++ b/lib/src/upper/pdcp_entity_lte.cc @@ -19,10 +19,10 @@ pdcp_entity_lte::pdcp_entity_lte(srsue::rlc_interface_pdcp* rlc_, srsue::rrc_interface_pdcp* rrc_, srsue::gw_interface_pdcp* gw_, srslte::task_sched_handle task_sched_, - srslte::log_ref log_, + srslog::basic_logger& logger, uint32_t lcid_, pdcp_config_t cfg_) : - pdcp_entity_base(task_sched_, log_), rlc(rlc_), rrc(rrc_), gw(gw_) + pdcp_entity_base(task_sched_, logger), rlc(rlc_), rrc(rrc_), gw(gw_) { lcid = lcid_; cfg = cfg_; @@ -43,13 +43,13 @@ pdcp_entity_lte::pdcp_entity_lte(srsue::rlc_interface_pdcp* rlc_, maximum_pdcp_sn = (1 << cfg.sn_len) - 1; st.last_submitted_pdcp_rx_sn = maximum_pdcp_sn; - log->info("Init %s with bearer ID: %d\n", rrc->get_rb_name(lcid).c_str(), cfg.bearer_id); - log->info("SN len bits: %d, SN len bytes: %d, reordering window: %d, Maximum SN: %d, discard timer: %d ms\n", - cfg.sn_len, - cfg.hdr_len_bytes, - reordering_window, - maximum_pdcp_sn, - static_cast(cfg.discard_timer)); + logger.info("Init %s with bearer ID: %d", rrc->get_rb_name(lcid).c_str(), cfg.bearer_id); + logger.info("SN len bits: %d, SN len bytes: %d, reordering window: %d, Maximum SN: %d, discard timer: %d ms", + cfg.sn_len, + cfg.hdr_len_bytes, + reordering_window, + maximum_pdcp_sn, + static_cast(cfg.discard_timer)); // Check supported config if (!check_valid_config()) { @@ -65,7 +65,7 @@ pdcp_entity_lte::~pdcp_entity_lte() // Reestablishment procedure: 36.323 5.2 void pdcp_entity_lte::reestablish() { - log->info("Re-establish %s with bearer ID: %d\n", rrc->get_rb_name(lcid).c_str(), cfg.bearer_id); + logger.info("Re-establish %s with bearer ID: %d", rrc->get_rb_name(lcid).c_str(), cfg.bearer_id); // For SRBs if (is_srb()) { st.next_pdcp_tx_sn = 0; @@ -86,8 +86,8 @@ void pdcp_entity_lte::reestablish() // Used to stop/pause the entity (called on RRC conn release) void pdcp_entity_lte::reset() { - if (active and log) { - log->debug("Reset %s\n", rrc->get_rb_name(lcid).c_str()); + if (active) { + logger.debug("Reset %s", rrc->get_rb_name(lcid).c_str()); } active = false; } @@ -96,7 +96,7 @@ void pdcp_entity_lte::reset() void pdcp_entity_lte::write_sdu(unique_byte_buffer_t sdu) { if (rlc->sdu_queue_is_full(lcid)) { - log->info_hex(sdu->msg, sdu->N_bytes, "Dropping %s SDU due to full queue", rrc->get_rb_name(lcid).c_str()); + logger.info(sdu->msg, sdu->N_bytes, "Dropping %s SDU due to full queue", rrc->get_rb_name(lcid).c_str()); return; } @@ -128,13 +128,13 @@ void pdcp_entity_lte::write_sdu(unique_byte_buffer_t sdu) &sdu->msg[cfg.hdr_len_bytes], sdu->N_bytes - cfg.hdr_len_bytes, tx_count, &sdu->msg[cfg.hdr_len_bytes]); } - log->info_hex(sdu->msg, - sdu->N_bytes, - "TX %s PDU, SN=%d, integrity=%s, encryption=%s", - rrc->get_rb_name(lcid).c_str(), - st.next_pdcp_tx_sn, - srslte_direction_text[integrity_direction], - srslte_direction_text[encryption_direction]); + logger.info(sdu->msg, + sdu->N_bytes, + "TX %s PDU, SN=%d, integrity=%s, encryption=%s", + rrc->get_rb_name(lcid).c_str(), + st.next_pdcp_tx_sn, + srslte_direction_text[integrity_direction], + srslte_direction_text[encryption_direction]); // Set SDU metadata for RLC AM sdu->md.pdcp_sn = st.next_pdcp_tx_sn; @@ -154,13 +154,13 @@ void pdcp_entity_lte::write_pdu(unique_byte_buffer_t pdu) { // drop control PDUs if (is_drb() && is_control_pdu(pdu)) { - log->info("Dropping PDCP control PDU\n"); + logger.info("Dropping PDCP control PDU"); return; } // Sanity check if (pdu->N_bytes <= cfg.hdr_len_bytes) { - log->error("PDCP PDU smaller than required header size.\n"); + logger.error("PDCP PDU smaller than required header size."); return; } @@ -174,14 +174,14 @@ void pdcp_entity_lte::write_pdu(unique_byte_buffer_t pdu) enable_security_rx_sn = -1; } - log->info_hex(pdu->msg, - pdu->N_bytes, - "%s Rx PDU SN=%d (%d B, integrity=%s, encryption=%s)", - rrc->get_rb_name(lcid).c_str(), - sn, - pdu->N_bytes, - srslte_direction_text[integrity_direction], - srslte_direction_text[encryption_direction]); + logger.info(pdu->msg, + pdu->N_bytes, + "%s Rx PDU SN=%d (%d B, integrity=%s, encryption=%s)", + rrc->get_rb_name(lcid).c_str(), + sn, + pdu->N_bytes, + srslte_direction_text[integrity_direction], + srslte_direction_text[encryption_direction]); if (is_srb()) { handle_srb_pdu(std::move(pdu)); @@ -190,7 +190,7 @@ void pdcp_entity_lte::write_pdu(unique_byte_buffer_t pdu) } else if (is_drb() && !rlc->rb_is_um(lcid)) { handle_am_drb_pdu(std::move(pdu)); } else { - log->error("Invalid PDCP/RLC configuration"); + logger.error("Invalid PDCP/RLC configuration"); } } @@ -204,7 +204,7 @@ void pdcp_entity_lte::handle_srb_pdu(srslte::unique_byte_buffer_t pdu) // Read SN from header uint32_t sn = read_data_header(pdu); - log->debug("RX SRB PDU. Next_PDCP_RX_SN %d, SN %d", st.next_pdcp_rx_sn, sn); + logger.debug("RX SRB PDU. Next_PDCP_RX_SN %d, SN %d", st.next_pdcp_rx_sn, sn); // Estimate COUNT for integrity check and decryption uint32_t count; @@ -219,7 +219,7 @@ void pdcp_entity_lte::handle_srb_pdu(srslte::unique_byte_buffer_t pdu) cipher_decrypt(&pdu->msg[cfg.hdr_len_bytes], pdu->N_bytes - cfg.hdr_len_bytes, count, &pdu->msg[cfg.hdr_len_bytes]); } - log->debug_hex(pdu->msg, pdu->N_bytes, "%s Rx SDU SN=%d", rrc->get_rb_name(lcid).c_str(), sn); + logger.debug(pdu->msg, pdu->N_bytes, "%s Rx SDU SN=%d", rrc->get_rb_name(lcid).c_str(), sn); // Extract MAC uint8_t mac[4]; @@ -228,7 +228,7 @@ void pdcp_entity_lte::handle_srb_pdu(srslte::unique_byte_buffer_t pdu) // Perfrom integrity checks if (integrity_direction == DIRECTION_RX || integrity_direction == DIRECTION_TXRX) { if (not integrity_verify(pdu->msg, pdu->N_bytes, count, mac)) { - log->error_hex(pdu->msg, pdu->N_bytes, "%s Dropping PDU", rrc->get_rb_name(lcid).c_str()); + logger.error(pdu->msg, pdu->N_bytes, "%s Dropping PDU", rrc->get_rb_name(lcid).c_str()); return; // Discard } } @@ -266,7 +266,7 @@ void pdcp_entity_lte::handle_um_drb_pdu(srslte::unique_byte_buffer_t pdu) cipher_decrypt(pdu->msg, pdu->N_bytes, count, pdu->msg); } - log->debug_hex(pdu->msg, pdu->N_bytes, "%s Rx PDU SN=%d", rrc->get_rb_name(lcid).c_str(), sn); + logger.debug(pdu->msg, pdu->N_bytes, "%s Rx PDU SN=%d", rrc->get_rb_name(lcid).c_str(), sn); st.next_pdcp_rx_sn = sn + 1; if (st.next_pdcp_rx_sn > maximum_pdcp_sn) { @@ -288,35 +288,35 @@ void pdcp_entity_lte::handle_am_drb_pdu(srslte::unique_byte_buffer_t pdu) int32_t sn_diff_last_submit = sn - st.last_submitted_pdcp_rx_sn; int32_t sn_diff_next_pdcp_rx_sn = sn - st.next_pdcp_rx_sn; - log->debug("RX HFN: %d, SN=%d, Last_Submitted_PDCP_RX_SN=%d, Next_PDCP_RX_SN=%d\n", - st.rx_hfn, - sn, - st.last_submitted_pdcp_rx_sn, - st.next_pdcp_rx_sn); + logger.debug("RX HFN: %d, SN=%d, Last_Submitted_PDCP_RX_SN=%d, Next_PDCP_RX_SN=%d", + st.rx_hfn, + sn, + st.last_submitted_pdcp_rx_sn, + st.next_pdcp_rx_sn); // Handle PDU uint32_t count = 0; if ((0 <= sn_diff_last_submit && sn_diff_last_submit > (int32_t)reordering_window) || (0 <= last_submit_diff_sn && last_submit_diff_sn < (int32_t)reordering_window)) { // discard - log->debug("Discarding SN=%d (sn_diff_last_submit=%d, last_submit_diff_sn=%d, reordering_window=%d)\n", - sn, - sn_diff_last_submit, - last_submit_diff_sn, - reordering_window); + logger.debug("Discarding SN=%d (sn_diff_last_submit=%d, last_submit_diff_sn=%d, reordering_window=%d)", + sn, + sn_diff_last_submit, + last_submit_diff_sn, + reordering_window); return; // Discard } if ((int32_t)(st.next_pdcp_rx_sn - sn) > (int32_t)reordering_window) { - log->debug("(Next_PDCP_RX_SN - SN) is larger than re-ordering window.\n"); + logger.debug("(Next_PDCP_RX_SN - SN) is larger than re-ordering window."); st.rx_hfn++; count = (st.rx_hfn << cfg.sn_len) | sn; st.next_pdcp_rx_sn = sn + 1; } else if (sn_diff_next_pdcp_rx_sn >= (int32_t)reordering_window) { - log->debug("(SN - Next_PDCP_RX_SN) is larger or equal than re-ordering window.\n"); + logger.debug("(SN - Next_PDCP_RX_SN) is larger or equal than re-ordering window."); count = ((st.rx_hfn - 1) << cfg.sn_len) | sn; } else if (sn >= st.next_pdcp_rx_sn) { - log->debug("SN is larger or equal than Next_PDCP_RX_SN.\n"); + logger.debug("SN is larger or equal than Next_PDCP_RX_SN."); count = (st.rx_hfn << cfg.sn_len) | sn; st.next_pdcp_rx_sn = sn + 1; if (st.next_pdcp_rx_sn > maximum_pdcp_sn) { @@ -324,13 +324,13 @@ void pdcp_entity_lte::handle_am_drb_pdu(srslte::unique_byte_buffer_t pdu) st.rx_hfn++; } } else if (sn < st.next_pdcp_rx_sn) { - log->debug("SN is smaller than Next_PDCP_RX_SN.\n"); + logger.debug("SN is smaller than Next_PDCP_RX_SN."); count = (st.rx_hfn << cfg.sn_len) | sn; } // Decrypt cipher_decrypt(pdu->msg, pdu->N_bytes, count, pdu->msg); - log->debug_hex(pdu->msg, pdu->N_bytes, "%s Rx SDU SN=%d", rrc->get_rb_name(lcid).c_str(), sn); + logger.debug(pdu->msg, pdu->N_bytes, "%s Rx SDU SN=%d", rrc->get_rb_name(lcid).c_str(), sn); // Update info on last PDU submitted to upper layers st.last_submitted_pdcp_rx_sn = sn; @@ -344,7 +344,7 @@ void pdcp_entity_lte::handle_am_drb_pdu(srslte::unique_byte_buffer_t pdu) ***************************************************************************/ void pdcp_entity_lte::notify_delivery(const std::vector& pdcp_sns) { - log->debug("Received delivery notification from RLC. Number of PDU notified=%ld\n", pdcp_sns.size()); + logger.debug("Received delivery notification from RLC. Number of PDU notified=%ld", pdcp_sns.size()); } /**************************************************************************** @@ -353,19 +353,19 @@ void pdcp_entity_lte::notify_delivery(const std::vector& pdcp_sns) bool pdcp_entity_lte::check_valid_config() { if (cfg.sn_len != PDCP_SN_LEN_5 && cfg.sn_len != PDCP_SN_LEN_7 && cfg.sn_len != PDCP_SN_LEN_12) { - log->error("Trying to configure bearer with invalid SN LEN=%d\n", cfg.sn_len); + logger.error("Trying to configure bearer with invalid SN LEN=%d", cfg.sn_len); return false; } if (cfg.sn_len == PDCP_SN_LEN_5 && is_drb()) { - log->error("Trying to configure DRB bearer with SN LEN of 5\n"); + logger.error("Trying to configure DRB bearer with SN LEN of 5"); return false; } if (cfg.sn_len == PDCP_SN_LEN_7 && (is_srb() || !rlc->rb_is_um(lcid))) { - log->error("Trying to configure SRB or RLC AM bearer with SN LEN of 7\n"); + logger.error("Trying to configure SRB or RLC AM bearer with SN LEN of 7"); return false; } if (cfg.sn_len == PDCP_SN_LEN_12 && is_srb()) { - log->error("Trying to configure SRB with SN LEN of 12.\n"); + logger.error("Trying to configure SRB with SN LEN of 12."); return false; } return true; diff --git a/lib/src/upper/pdcp_entity_nr.cc b/lib/src/upper/pdcp_entity_nr.cc index ee0fedf79..5140014ae 100644 --- a/lib/src/upper/pdcp_entity_nr.cc +++ b/lib/src/upper/pdcp_entity_nr.cc @@ -19,10 +19,10 @@ pdcp_entity_nr::pdcp_entity_nr(srsue::rlc_interface_pdcp* rlc_, srsue::rrc_interface_pdcp* rrc_, srsue::gw_interface_pdcp* gw_, srslte::task_sched_handle task_sched_, - srslte::log_ref log_, + srslog::basic_logger& logger, uint32_t lcid_, pdcp_config_t cfg_) : - pdcp_entity_base(task_sched_, log_), + pdcp_entity_base(task_sched_, logger), rlc(rlc_), rrc(rrc_), gw(gw_), @@ -50,7 +50,7 @@ pdcp_entity_nr::~pdcp_entity_nr() {} // Reestablishment procedure: 38.323 5.2 void pdcp_entity_nr::reestablish() { - log->info("Re-establish %s with bearer ID: %d\n", rrc->get_rb_name(lcid).c_str(), cfg.bearer_id); + logger.info("Re-establish %s with bearer ID: %d", rrc->get_rb_name(lcid).c_str(), cfg.bearer_id); // TODO } @@ -58,23 +58,23 @@ void pdcp_entity_nr::reestablish() void pdcp_entity_nr::reset() { active = false; - log->debug("Reset %s\n", rrc->get_rb_name(lcid).c_str()); + logger.debug("Reset %s", rrc->get_rb_name(lcid).c_str()); } // SDAP/RRC interface void pdcp_entity_nr::write_sdu(unique_byte_buffer_t sdu) { // Log SDU - log->info_hex(sdu->msg, - sdu->N_bytes, - "TX %s SDU, integrity=%s, encryption=%s", - rrc->get_rb_name(lcid).c_str(), - srslte_direction_text[integrity_direction], - srslte_direction_text[encryption_direction]); + logger.info(sdu->msg, + sdu->N_bytes, + "TX %s SDU, integrity=%s, encryption=%s", + rrc->get_rb_name(lcid).c_str(), + srslte_direction_text[integrity_direction], + srslte_direction_text[encryption_direction]); // Check for COUNT overflow if (tx_overflow) { - log->warning("TX_NEXT has overflowed. Dropping packet\n"); + logger.warning("TX_NEXT has overflowed. Dropping packet"); return; } if (tx_next + 1 == 0) { @@ -88,7 +88,7 @@ void pdcp_entity_nr::write_sdu(unique_byte_buffer_t sdu) discard_timer.set(static_cast(cfg.discard_timer), discard_fnc); discard_timer.run(); discard_timers_map.insert(std::make_pair(tx_next, std::move(discard_timer))); - log->debug("Discard Timer set for SN %u. Timeout: %ums\n", tx_next, static_cast(cfg.discard_timer)); + logger.debug("Discard Timer set for SN %u. Timeout: %ums", tx_next, static_cast(cfg.discard_timer)); } // Perform header compression TODO @@ -121,13 +121,13 @@ void pdcp_entity_nr::write_sdu(unique_byte_buffer_t sdu) void pdcp_entity_nr::write_pdu(unique_byte_buffer_t pdu) { // Log PDU - log->info_hex(pdu->msg, - pdu->N_bytes, - "RX %s PDU (%d B), integrity=%s, encryption=%s", - rrc->get_rb_name(lcid).c_str(), - pdu->N_bytes, - srslte_direction_text[integrity_direction], - srslte_direction_text[encryption_direction]); + logger.info(pdu->msg, + pdu->N_bytes, + "RX %s PDU (%d B), integrity=%s, encryption=%s", + rrc->get_rb_name(lcid).c_str(), + pdu->N_bytes, + srslte_direction_text[integrity_direction], + srslte_direction_text[encryption_direction]); // Sanity check if (pdu->N_bytes <= cfg.hdr_len_bytes) { @@ -153,7 +153,7 @@ void pdcp_entity_nr::write_pdu(unique_byte_buffer_t pdu) } rcvd_count = COUNT(rcvd_hfn, rcvd_sn); - log->debug("RCVD_HFN %u RCVD_SN %u, RCVD_COUNT %u\n", rcvd_hfn, rcvd_sn, rcvd_count); + logger.debug("RCVD_HFN %u RCVD_SN %u, RCVD_COUNT %u", rcvd_hfn, rcvd_sn, rcvd_count); // Decripting cipher_decrypt(pdu->msg, pdu->N_bytes, rcvd_count, pdu->msg); @@ -166,8 +166,8 @@ void pdcp_entity_nr::write_pdu(unique_byte_buffer_t pdu) // Check valid rcvd_count if (rcvd_count < rx_deliv) { - log->debug("Out-of-order after time-out, duplicate or COUNT wrap-around\n"); - log->debug("RCVD_COUNT %u, RCVD_COUNT %u\n", rcvd_count, rx_deliv); + logger.debug("Out-of-order after time-out, duplicate or COUNT wrap-around"); + logger.debug("RCVD_COUNT %u, RCVD_COUNT %u", rcvd_count, rx_deliv); return; // Invalid count, drop. } @@ -205,7 +205,7 @@ void pdcp_entity_nr::write_pdu(unique_byte_buffer_t pdu) // Notification of delivery void pdcp_entity_nr::notify_delivery(const std::vector& pdcp_sns) { - log->debug("Received delivery notification from RLC. Nof SNs=%ld\n", pdcp_sns.size()); + logger.debug("Received delivery notification from RLC. Nof SNs=%ld", pdcp_sns.size()); } /* @@ -219,11 +219,11 @@ void pdcp_entity_nr::deliver_all_consecutive_counts() for (std::map::iterator it = reorder_queue.begin(); it != reorder_queue.end() && it->first == rx_deliv; reorder_queue.erase(it++)) { - log->debug("Delivering SDU with RCVD_COUNT %u\n", it->first); + logger.debug("Delivering SDU with RCVD_COUNT %u", it->first); // Check RX_DELIV overflow if (rx_overflow) { - log->warning("RX_DELIV has overflowed. Droping packet\n"); + logger.warning("RX_DELIV has overflowed. Droping packet"); return; } if (rx_deliv + 1 == 0) { @@ -244,7 +244,7 @@ void pdcp_entity_nr::deliver_all_consecutive_counts() // Reordering Timer Callback (t-reordering) void pdcp_entity_nr::reordering_callback::operator()(uint32_t timer_id) { - parent->log->debug("Reordering timer expired\n"); + parent->logger.debug("Reordering timer expired"); // Deliver all PDCP SDU(s) with associeted COUNT value(s) < RX_REORD for (std::map::iterator it = parent->reorder_queue.begin(); @@ -266,7 +266,7 @@ void pdcp_entity_nr::reordering_callback::operator()(uint32_t timer_id) // Discard Timer Callback (discardTimer) void pdcp_entity_nr::discard_callback::operator()(uint32_t timer_id) { - parent->log->debug("Discard timer expired for PDU with SN = %d\n", discard_sn); + parent->logger.debug("Discard timer expired for PDU with SN = %d", discard_sn); // Notify the RLC of the discard. It's the RLC to actually discard, if no segment was transmitted yet. parent->rlc->discard_sdu(parent->lcid, discard_sn); diff --git a/lib/test/upper/pdcp_base_test.h b/lib/test/upper/pdcp_base_test.h index d212031c5..59b9e2c4d 100644 --- a/lib/test/upper/pdcp_base_test.h +++ b/lib/test/upper/pdcp_base_test.h @@ -34,32 +34,31 @@ int compare_two_packets(const srslte::unique_byte_buffer_t& msg1, const srslte:: class rlc_dummy : public srsue::rlc_interface_pdcp { public: - rlc_dummy(srslte::log_ref log_) : log(log_) {} + explicit rlc_dummy(srslog::basic_logger& logger) : logger(logger) {} void get_last_sdu(const srslte::unique_byte_buffer_t& pdu) { memcpy(pdu->msg, last_pdcp_pdu->msg, last_pdcp_pdu->N_bytes); pdu->N_bytes = last_pdcp_pdu->N_bytes; - return; } void write_sdu(uint32_t lcid, srslte::unique_byte_buffer_t sdu) { - log->info_hex(sdu->msg, sdu->N_bytes, "RLC SDU"); + logger.info(sdu->msg, sdu->N_bytes, "RLC SDU"); last_pdcp_pdu.swap(sdu); rx_count++; } void discard_sdu(uint32_t lcid, uint32_t discard_sn) { - log->info("Notifing RLC to discard SDU (SN=%u)\n", discard_sn); + logger.info("Notifing RLC to discard SDU (SN=%u)", discard_sn); discard_count++; - log->info("Discard_count=%" PRIu64 "\n", discard_count); + logger.info("Discard_count=%" PRIu64 "", discard_count); } uint64_t rx_count = 0; uint64_t discard_count = 0; private: - srslte::log_ref log; + srslog::basic_logger& logger; srslte::unique_byte_buffer_t last_pdcp_pdu; bool rb_is_um(uint32_t lcid) { return false; } @@ -69,7 +68,7 @@ private: class rrc_dummy : public srsue::rrc_interface_pdcp { public: - rrc_dummy(srslte::log_ref log_) { log = log_; } + explicit rrc_dummy(srslog::basic_logger& logger) : logger(logger) {} void write_pdu_bcch_bch(srslte::unique_byte_buffer_t pdu) {} void write_pdu_bcch_dlsch(srslte::unique_byte_buffer_t pdu) {} @@ -78,7 +77,7 @@ public: std::string get_rb_name(uint32_t lcid) { return "None"; } - srslte::log_ref log; + srslog::basic_logger& logger; // Members for testing uint32_t rx_count = 0; @@ -89,12 +88,11 @@ public: { memcpy(pdu->msg, last_pdu->msg, last_pdu->N_bytes); pdu->N_bytes = last_pdu->N_bytes; - return; } void write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t pdu) { - log->info_hex(pdu->msg, pdu->N_bytes, "RRC PDU"); + logger.info(pdu->msg, pdu->N_bytes, "RRC PDU"); rx_count++; last_pdu.swap(pdu); } @@ -103,7 +101,7 @@ public: class gw_dummy : public srsue::gw_interface_pdcp { public: - gw_dummy(srslte::log_ref log_) : log(log_) {} + explicit gw_dummy(srslog::basic_logger& logger) : logger(logger) {} void write_pdu_mch(uint32_t lcid, srslte::unique_byte_buffer_t pdu) {} uint32_t rx_count = 0; @@ -112,17 +110,16 @@ public: { memcpy(pdu->msg, last_pdu->msg, last_pdu->N_bytes); pdu->N_bytes = last_pdu->N_bytes; - return; } void write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t pdu) { - log->info_hex(pdu->msg, pdu->N_bytes, "GW PDU"); + logger.info(pdu->msg, pdu->N_bytes, "GW PDU"); rx_count++; last_pdu.swap(pdu); } private: - srslte::log_ref log; + srslog::basic_logger& logger; srslte::unique_byte_buffer_t last_pdu; }; diff --git a/lib/test/upper/pdcp_lte_test.h b/lib/test/upper/pdcp_lte_test.h index 5311f6a1a..430f2faf8 100644 --- a/lib/test/upper/pdcp_lte_test.h +++ b/lib/test/upper/pdcp_lte_test.h @@ -59,8 +59,8 @@ srslte::pdcp_lte_state_t normal_init_state = {}; class pdcp_lte_test_helper { public: - pdcp_lte_test_helper(srslte::pdcp_config_t cfg, srslte::as_security_config_t sec_cfg_, srslte::log_ref log) : - rlc(log), rrc(log), gw(log), pdcp(&rlc, &rrc, &gw, &stack.task_sched, log, 0, cfg) + pdcp_lte_test_helper(srslte::pdcp_config_t cfg, srslte::as_security_config_t sec_cfg_, srslog::basic_logger& logger) : + rlc(logger), rrc(logger), gw(logger), pdcp(&rlc, &rrc, &gw, &stack.task_sched, logger, 0, cfg) { pdcp.config_security(sec_cfg_); pdcp.enable_integrity(srslte::DIRECTION_TXRX); @@ -82,7 +82,7 @@ srslte::unique_byte_buffer_t gen_expected_pdu(const srslte::unique_byte_buffer_t uint8_t pdcp_sn_len, srslte::pdcp_rb_type_t rb_type, srslte::as_security_config_t sec_cfg, - srslte::log_ref log) + srslog::basic_logger& logger) { srslte::pdcp_config_t cfg = {1, rb_type, @@ -92,7 +92,7 @@ srslte::unique_byte_buffer_t gen_expected_pdu(const srslte::unique_byte_buffer_t srslte::pdcp_t_reordering_t::ms500, srslte::pdcp_discard_timer_t::infinity}; - pdcp_lte_test_helper pdcp_hlp(cfg, sec_cfg, log); + pdcp_lte_test_helper pdcp_hlp(cfg, sec_cfg, logger); srslte::pdcp_entity_lte* pdcp = &pdcp_hlp.pdcp; rlc_dummy* rlc = &pdcp_hlp.rlc; @@ -116,12 +116,12 @@ std::vector gen_expected_pdus_vector(const srslte::unique_byt uint8_t pdcp_sn_len, srslte::pdcp_rb_type_t rb_type, srslte::as_security_config_t sec_cfg_, - srslte::log_ref log) + srslog::basic_logger& logger) { std::vector pdu_vec; for (uint32_t tx_next : tx_nexts) { pdcp_test_event_t event; - event.pkt = gen_expected_pdu(in_sdu, tx_next, pdcp_sn_len, rb_type, sec_cfg_, log); + event.pkt = gen_expected_pdu(in_sdu, tx_next, pdcp_sn_len, rb_type, sec_cfg_, logger); event.ticks = 0; pdu_vec.push_back(std::move(event)); } diff --git a/lib/test/upper/pdcp_lte_test_rx.cc b/lib/test/upper/pdcp_lte_test_rx.cc index 25145bc01..cb3f14f89 100644 --- a/lib/test/upper/pdcp_lte_test_rx.cc +++ b/lib/test/upper/pdcp_lte_test_rx.cc @@ -21,7 +21,7 @@ int test_rx(std::vector events, srslte::pdcp_rb_type_t rb_type, uint32_t n_sdus_exp, const srslte::unique_byte_buffer_t& sdu_exp, - srslte::log_ref log) + srslog::basic_logger& logger) { srslte::pdcp_config_t cfg_rx = {1, @@ -32,7 +32,7 @@ int test_rx(std::vector events, srslte::pdcp_t_reordering_t::ms500, srslte::pdcp_discard_timer_t::infinity}; - pdcp_lte_test_helper pdcp_hlp_rx(cfg_rx, sec_cfg, log); + pdcp_lte_test_helper pdcp_hlp_rx(cfg_rx, sec_cfg, logger); srslte::pdcp_entity_lte* pdcp_rx = &pdcp_hlp_rx.pdcp; gw_dummy* gw_rx = &pdcp_hlp_rx.gw; rrc_dummy* rrc_rx = &pdcp_hlp_rx.rrc; @@ -72,7 +72,7 @@ int test_rx(std::vector events, * RX Test: PDCP Entity with SN LEN = 5 and 12. * PDCP entity configured with EIA2 and EEA2 */ -int test_rx_all(srslte::log_ref log) +int test_rx_all(srslog::basic_logger& logger) { // Test SDUs srslte::unique_byte_buffer_t tst_sdu1 = srslte::make_byte_buffer(); // SDU 1 @@ -88,14 +88,17 @@ int test_rx_all(srslte::log_ref log) { std::vector test1_counts(2); // Test two packets std::iota(test1_counts.begin(), test1_counts.end(), 31); // Starting at COUNT 31 - std::vector test1_pdus = - gen_expected_pdus_vector(tst_sdu1, test1_counts, srslte::PDCP_SN_LEN_5, srslte::PDCP_RB_IS_SRB, sec_cfg, log); + std::vector test1_pdus = gen_expected_pdus_vector( + tst_sdu1, test1_counts, srslte::PDCP_SN_LEN_5, srslte::PDCP_RB_IS_SRB, sec_cfg, logger); srslte::pdcp_lte_state_t test1_init_state = { .next_pdcp_tx_sn = 0, .tx_hfn = 0, .rx_hfn = 0, .next_pdcp_rx_sn = 31, .last_submitted_pdcp_rx_sn = 30}; - TESTASSERT( - test_rx( - std::move(test1_pdus), test1_init_state, srslte::PDCP_SN_LEN_5, srslte::PDCP_RB_IS_SRB, 2, tst_sdu1, log) == - 0); + TESTASSERT(test_rx(std::move(test1_pdus), + test1_init_state, + srslte::PDCP_SN_LEN_5, + srslte::PDCP_RB_IS_SRB, + 2, + tst_sdu1, + logger) == 0); } /* @@ -106,14 +109,17 @@ int test_rx_all(srslte::log_ref log) { std::vector test_counts(2); // Test two packets std::iota(test_counts.begin(), test_counts.end(), 4095); // Starting at COUNT 4095 - std::vector test_pdus = - gen_expected_pdus_vector(tst_sdu1, test_counts, srslte::PDCP_SN_LEN_12, srslte::PDCP_RB_IS_DRB, sec_cfg, log); + std::vector test_pdus = gen_expected_pdus_vector( + tst_sdu1, test_counts, srslte::PDCP_SN_LEN_12, srslte::PDCP_RB_IS_DRB, sec_cfg, logger); srslte::pdcp_lte_state_t test_init_state = { .next_pdcp_tx_sn = 0, .tx_hfn = 0, .rx_hfn = 0, .next_pdcp_rx_sn = 4095, .last_submitted_pdcp_rx_sn = 4094}; - TESTASSERT( - test_rx( - std::move(test_pdus), test_init_state, srslte::PDCP_SN_LEN_12, srslte::PDCP_RB_IS_DRB, 2, tst_sdu1, log) == - 0); + TESTASSERT(test_rx(std::move(test_pdus), + test_init_state, + srslte::PDCP_SN_LEN_12, + srslte::PDCP_RB_IS_DRB, + 2, + tst_sdu1, + logger) == 0); } /* @@ -123,8 +129,8 @@ int test_rx_all(srslte::log_ref log) { std::vector test_counts(2); // Test two packets std::iota(test_counts.begin(), test_counts.end(), 31); // Starting at COUNT 31 - std::vector test_pdus = - gen_expected_pdus_vector(tst_sdu1, test_counts, srslte::PDCP_SN_LEN_12, srslte::PDCP_RB_IS_DRB, sec_cfg, log); + std::vector test_pdus = gen_expected_pdus_vector( + tst_sdu1, test_counts, srslte::PDCP_SN_LEN_12, srslte::PDCP_RB_IS_DRB, sec_cfg, logger); srslte::pdcp_lte_state_t test_init_state = { .next_pdcp_tx_sn = 0, .tx_hfn = 0, .rx_hfn = 0, .next_pdcp_rx_sn = 32, .last_submitted_pdcp_rx_sn = 31}; TESTASSERT(test_rx(std::move(test_pdus), @@ -133,7 +139,7 @@ int test_rx_all(srslte::log_ref log) srslte::PDCP_RB_IS_DRB, test_counts.size() - 1, tst_sdu1, - log) == 0); + logger) == 0); } return SRSLTE_SUCCESS; @@ -141,7 +147,7 @@ int test_rx_all(srslte::log_ref log) // Basic test to verify the correct handling of PDCP status PDUs on DRBs // As long as we don't implement status reporting, the PDU shall be dropped -int test_rx_control_pdu(srslte::log_ref log) +int test_rx_control_pdu(srslog::basic_logger& logger) { const uint8_t pdcp_status_report_long[] = {0x0a, 0xc9, 0x3c}; @@ -158,7 +164,8 @@ int test_rx_control_pdu(srslte::log_ref log) srslte::pdcp_lte_state_t test_init_state = { .next_pdcp_tx_sn = 0, .tx_hfn = 0, .rx_hfn = 0, .next_pdcp_rx_sn = 32, .last_submitted_pdcp_rx_sn = 31}; TESTASSERT( - test_rx(std::move(pdu_vec), test_init_state, srslte::PDCP_SN_LEN_12, srslte::PDCP_RB_IS_DRB, 0, tst_sdu1, log) == + test_rx( + std::move(pdu_vec), test_init_state, srslte::PDCP_SN_LEN_12, srslte::PDCP_RB_IS_DRB, 0, tst_sdu1, logger) == 0); return SRSLTE_SUCCESS; @@ -168,18 +175,20 @@ int test_rx_control_pdu(srslte::log_ref log) int run_all_tests() { // Setup log - srslte::log_ref log("PDCP LTE Test RX"); - log->set_level(srslte::LOG_LEVEL_DEBUG); - log->set_hex_limit(128); + auto& logger = srslog::fetch_basic_logger("PDCP LTE Test RX", false); + logger.set_level(srslog::basic_levels::debug); + logger.set_hex_dump_max_size(128); - TESTASSERT(test_rx_all(log) == 0); - TESTASSERT(test_rx_control_pdu(log) == 0); + TESTASSERT(test_rx_all(logger) == 0); + TESTASSERT(test_rx_control_pdu(logger) == 0); return 0; } int main() { + srslog::init(); + if (run_all_tests() != SRSLTE_SUCCESS) { fprintf(stderr, "pdcp_nr_tests_rx() failed\n"); return SRSLTE_ERROR; diff --git a/lib/test/upper/pdcp_nr_test.h b/lib/test/upper/pdcp_nr_test.h index e2bce5bfa..cd7910378 100644 --- a/lib/test/upper/pdcp_nr_test.h +++ b/lib/test/upper/pdcp_nr_test.h @@ -87,8 +87,8 @@ pdcp_initial_state near_wraparound_init_state = {.tx_next = 4294967295, class pdcp_nr_test_helper { public: - pdcp_nr_test_helper(srslte::pdcp_config_t cfg, srslte::as_security_config_t sec_cfg_, srslte::log_ref log) : - rlc(log), rrc(log), gw(log), pdcp(&rlc, &rrc, &gw, &stack.task_sched, log, 0, cfg) + pdcp_nr_test_helper(srslte::pdcp_config_t cfg, srslte::as_security_config_t sec_cfg_, srslog::basic_logger& logger) : + rlc(logger), rrc(logger), gw(logger), pdcp(&rlc, &rrc, &gw, &stack.task_sched, logger, 0, cfg) { pdcp.config_security(sec_cfg_); pdcp.enable_integrity(srslte::DIRECTION_TXRX); @@ -115,7 +115,7 @@ srslte::unique_byte_buffer_t gen_expected_pdu(const srslte::unique_byte_buffer_t uint32_t count, uint8_t pdcp_sn_len, srslte::as_security_config_t sec_cfg, - srslte::log_ref log) + srslog::basic_logger& logger) { srslte::pdcp_config_t cfg = {1, srslte::PDCP_RB_IS_DRB, @@ -125,7 +125,7 @@ srslte::unique_byte_buffer_t gen_expected_pdu(const srslte::unique_byte_buffer_t srslte::pdcp_t_reordering_t::ms500, srslte::pdcp_discard_timer_t::infinity}; - pdcp_nr_test_helper pdcp_hlp(cfg, sec_cfg, log); + pdcp_nr_test_helper pdcp_hlp(cfg, sec_cfg, logger); srslte::pdcp_entity_nr* pdcp = &pdcp_hlp.pdcp; rlc_dummy* rlc = &pdcp_hlp.rlc; @@ -147,12 +147,12 @@ std::vector gen_expected_pdus_vector(const srslte::unique_byt const std::vector& tx_nexts, uint8_t pdcp_sn_len, srslte::as_security_config_t sec_cfg_, - srslte::log_ref log) + srslog::basic_logger& logger) { std::vector pdu_vec; for (uint32_t tx_next : tx_nexts) { pdcp_test_event_t event; - event.pkt = gen_expected_pdu(in_sdu, tx_next, pdcp_sn_len, sec_cfg_, log); + event.pkt = gen_expected_pdu(in_sdu, tx_next, pdcp_sn_len, sec_cfg_, logger); event.ticks = 0; pdu_vec.push_back(std::move(event)); } diff --git a/lib/test/upper/pdcp_nr_test_discard_sdu.cc b/lib/test/upper/pdcp_nr_test_discard_sdu.cc index 1fb59cb32..9b45d7973 100644 --- a/lib/test/upper/pdcp_nr_test_discard_sdu.cc +++ b/lib/test/upper/pdcp_nr_test_discard_sdu.cc @@ -18,7 +18,7 @@ int test_tx_sdu_discard(const pdcp_initial_state& init_state, srslte::pdcp_discard_timer_t discard_timeout, bool imediate_notify, - srslte::log_ref log) + srslog::basic_logger& logger) { srslte::pdcp_config_t cfg = {1, srslte::PDCP_RB_IS_DRB, @@ -28,7 +28,7 @@ int test_tx_sdu_discard(const pdcp_initial_state& init_state, srslte::pdcp_t_reordering_t::ms500, discard_timeout}; - pdcp_nr_test_helper pdcp_hlp(cfg, sec_cfg, log); + pdcp_nr_test_helper pdcp_hlp(cfg, sec_cfg, logger); srslte::pdcp_entity_nr* pdcp = &pdcp_hlp.pdcp; rlc_dummy* rlc = &pdcp_hlp.rlc; srsue::stack_test_dummy* stack = &pdcp_hlp.stack; @@ -72,19 +72,19 @@ int test_tx_sdu_discard(const pdcp_initial_state& init_state, * TX Test: PDCP Entity with SN LEN = 12 and 18. * PDCP entity configured with EIA2 and EEA2 */ -int test_tx_discard_all(srslte::log_ref log) +int test_tx_discard_all(srslog::basic_logger& logger) { /* * TX Test 1: PDCP Entity with SN LEN = 12 * Test TX PDU discard. */ - TESTASSERT(test_tx_sdu_discard(normal_init_state, srslte::pdcp_discard_timer_t::ms50, false, log) == 0); + TESTASSERT(test_tx_sdu_discard(normal_init_state, srslte::pdcp_discard_timer_t::ms50, false, logger) == 0); /* * TX Test 2: PDCP Entity with SN LEN = 12 * Test TX PDU discard. */ - // TESTASSERT(test_tx_sdu_discard(normal_init_state, srslte::pdcp_discard_timer_t::ms50, true, log) == 0); + // TESTASSERT(test_tx_sdu_discard(normal_init_state, srslte::pdcp_discard_timer_t::ms50, true, logger) == 0); return 0; } @@ -92,16 +92,18 @@ int test_tx_discard_all(srslte::log_ref log) int run_all_tests() { // Setup log - srslte::log_ref log("PDCP NR Test"); - log->set_level(srslte::LOG_LEVEL_DEBUG); - log->set_hex_limit(128); + auto& logger = srslog::fetch_basic_logger("PDCP NR Test", false); + logger.set_level(srslog::basic_levels::debug); + logger.set_hex_dump_max_size(128); - TESTASSERT(test_tx_discard_all(log) == 0); + TESTASSERT(test_tx_discard_all(logger) == 0); return 0; } int main() { + srslog::init(); + if (run_all_tests() != SRSLTE_SUCCESS) { fprintf(stderr, "pdcp_nr_tests() failed\n"); return SRSLTE_ERROR; diff --git a/lib/test/upper/pdcp_nr_test_rx.cc b/lib/test/upper/pdcp_nr_test_rx.cc index 864e25535..e06b892e7 100644 --- a/lib/test/upper/pdcp_nr_test_rx.cc +++ b/lib/test/upper/pdcp_nr_test_rx.cc @@ -20,7 +20,7 @@ int test_rx(std::vector events, uint8_t pdcp_sn_len, uint32_t n_sdus_exp, const srslte::unique_byte_buffer_t& sdu_exp, - srslte::log_ref log) + srslog::basic_logger& logger) { srslte::pdcp_config_t cfg_rx = {1, @@ -31,7 +31,7 @@ int test_rx(std::vector events, srslte::pdcp_t_reordering_t::ms500, srslte::pdcp_discard_timer_t::infinity}; - pdcp_nr_test_helper pdcp_hlp_rx(cfg_rx, sec_cfg, log); + pdcp_nr_test_helper pdcp_hlp_rx(cfg_rx, sec_cfg, logger); srslte::pdcp_entity_nr* pdcp_rx = &pdcp_hlp_rx.pdcp; gw_dummy* gw_rx = &pdcp_hlp_rx.gw; srsue::stack_test_dummy* stack = &pdcp_hlp_rx.stack; @@ -58,7 +58,7 @@ int test_rx(std::vector events, * RX Test: PDCP Entity with SN LEN = 12 and 18. * PDCP entity configured with EIA2 and EEA2 */ -int test_rx_all(srslte::log_ref log) +int test_rx_all(srslog::basic_logger& logger) { // Test SDUs srslte::unique_byte_buffer_t tst_sdu1 = srslte::make_byte_buffer(); // SDU 1 @@ -75,9 +75,9 @@ int test_rx_all(srslte::log_ref log) std::vector test1_counts(2); // Test two packets std::iota(test1_counts.begin(), test1_counts.end(), 4095); // Starting at COUNT 4095 std::vector test1_pdus = - gen_expected_pdus_vector(tst_sdu1, test1_counts, srslte::PDCP_SN_LEN_12, sec_cfg, log); + gen_expected_pdus_vector(tst_sdu1, test1_counts, srslte::PDCP_SN_LEN_12, sec_cfg, logger); pdcp_initial_state test1_init_state = {.tx_next = 4095, .rx_next = 4095, .rx_deliv = 4095, .rx_reord = 0}; - TESTASSERT(test_rx(std::move(test1_pdus), test1_init_state, srslte::PDCP_SN_LEN_12, 2, tst_sdu1, log) == 0); + TESTASSERT(test_rx(std::move(test1_pdus), test1_init_state, srslte::PDCP_SN_LEN_12, 2, tst_sdu1, logger) == 0); } /* * RX Test 2: PDCP Entity with SN LEN = 12 @@ -89,10 +89,10 @@ int test_rx_all(srslte::log_ref log) std::vector test2_counts(2); // Test two packets std::iota(test2_counts.begin(), test2_counts.end(), 4294967295); // Starting at COUNT 4294967295 std::vector test2_pdus = - gen_expected_pdus_vector(tst_sdu1, test2_counts, srslte::PDCP_SN_LEN_12, sec_cfg, log); + gen_expected_pdus_vector(tst_sdu1, test2_counts, srslte::PDCP_SN_LEN_12, sec_cfg, logger); pdcp_initial_state test2_init_state = { .tx_next = 4294967295, .rx_next = 4294967295, .rx_deliv = 4294967295, .rx_reord = 0}; - TESTASSERT(test_rx(std::move(test2_pdus), test2_init_state, srslte::PDCP_SN_LEN_12, 1, tst_sdu1, log) == 0); + TESTASSERT(test_rx(std::move(test2_pdus), test2_init_state, srslte::PDCP_SN_LEN_12, 1, tst_sdu1, logger) == 0); } /* * RX Test 3: PDCP Entity with SN LEN = 18 @@ -103,9 +103,9 @@ int test_rx_all(srslte::log_ref log) std::vector test3_counts(2); // Test two packets std::iota(test3_counts.begin(), test3_counts.end(), 262144); // Starting at COUNT 262144 std::vector test3_pdus = - gen_expected_pdus_vector(tst_sdu1, test3_counts, srslte::PDCP_SN_LEN_18, sec_cfg, log); + gen_expected_pdus_vector(tst_sdu1, test3_counts, srslte::PDCP_SN_LEN_18, sec_cfg, logger); pdcp_initial_state test3_init_state = {.tx_next = 262144, .rx_next = 262144, .rx_deliv = 262144, .rx_reord = 0}; - TESTASSERT(test_rx(std::move(test3_pdus), test3_init_state, srslte::PDCP_SN_LEN_18, 2, tst_sdu1, log) == 0); + TESTASSERT(test_rx(std::move(test3_pdus), test3_init_state, srslte::PDCP_SN_LEN_18, 2, tst_sdu1, logger) == 0); } /* @@ -117,10 +117,10 @@ int test_rx_all(srslte::log_ref log) std::vector test4_counts(2); // Test two packets std::iota(test4_counts.begin(), test4_counts.end(), 4294967295); // Starting at COUNT 4294967295 std::vector test4_pdus = - gen_expected_pdus_vector(tst_sdu1, test4_counts, srslte::PDCP_SN_LEN_18, sec_cfg, log); + gen_expected_pdus_vector(tst_sdu1, test4_counts, srslte::PDCP_SN_LEN_18, sec_cfg, logger); pdcp_initial_state test4_init_state = { .tx_next = 4294967295, .rx_next = 4294967295, .rx_deliv = 4294967295, .rx_reord = 0}; - TESTASSERT(test_rx(std::move(test4_pdus), test4_init_state, srslte::PDCP_SN_LEN_18, 1, tst_sdu1, log) == 0); + TESTASSERT(test_rx(std::move(test4_pdus), test4_init_state, srslte::PDCP_SN_LEN_18, 1, tst_sdu1, logger) == 0); } /* @@ -144,7 +144,7 @@ int test_rx_all(srslte::log_ref log) // Write PDUs out of order (first the pdu with COUNT 1 and COUNT 0 after) test5_pdus.push_back(std::move(event_pdu2)); test5_pdus.push_back(std::move(event_pdu1)); - TESTASSERT(test_rx(std::move(test5_pdus), test5_init_state, srslte::PDCP_SN_LEN_12, 2, tst_sdu2, log) == 0); + TESTASSERT(test_rx(std::move(test5_pdus), test5_init_state, srslte::PDCP_SN_LEN_12, 2, tst_sdu2, logger) == 0); } /* @@ -168,7 +168,7 @@ int test_rx_all(srslte::log_ref log) // Write PDUs out of order (first the pdu with COUNT 1 and COUNT 0 after) test6_pdus.push_back(std::move(event_pdu2)); test6_pdus.push_back(std::move(event_pdu1)); - TESTASSERT(test_rx(std::move(test6_pdus), test6_init_state, srslte::PDCP_SN_LEN_18, 2, tst_sdu2, log) == 0); + TESTASSERT(test_rx(std::move(test6_pdus), test6_init_state, srslte::PDCP_SN_LEN_18, 2, tst_sdu2, logger) == 0); } /* @@ -187,7 +187,7 @@ int test_rx_all(srslte::log_ref log) // Write PDUs out of order (first the pdu with COUNT 1 and COUNT 0 after) test7_pdus.push_back(std::move(event_pdu1)); - TESTASSERT(test_rx(std::move(test7_pdus), test7_init_state, srslte::PDCP_SN_LEN_12, 1, tst_sdu2, log) == 0); + TESTASSERT(test_rx(std::move(test7_pdus), test7_init_state, srslte::PDCP_SN_LEN_12, 1, tst_sdu2, logger) == 0); } /* @@ -211,7 +211,7 @@ int test_rx_all(srslte::log_ref log) // Write PDUs out of order (first the pdu with COUNT 1 and COUNT 0 after) test8_pdus.push_back(std::move(event_pdu1)); test8_pdus.push_back(std::move(event_pdu2)); - TESTASSERT(test_rx(std::move(test8_pdus), test8_init_state, srslte::PDCP_SN_LEN_12, 1, tst_sdu1, log) == 0); + TESTASSERT(test_rx(std::move(test8_pdus), test8_init_state, srslte::PDCP_SN_LEN_12, 1, tst_sdu1, logger) == 0); } return 0; } @@ -220,16 +220,18 @@ int test_rx_all(srslte::log_ref log) int run_all_tests() { // Setup log - srslte::log_ref log("PDCP NR Test RX"); - log->set_level(srslte::LOG_LEVEL_DEBUG); - log->set_hex_limit(128); + auto& logger = srslog::fetch_basic_logger("PDCP NR Test RX", false); + logger.set_level(srslog::basic_levels::debug); + logger.set_hex_dump_max_size(128); - TESTASSERT(test_rx_all(log) == 0); + TESTASSERT(test_rx_all(logger) == 0); return 0; } int main() { + srslog::init(); + if (run_all_tests() != SRSLTE_SUCCESS) { fprintf(stderr, "pdcp_nr_tests_rx() failed\n"); return SRSLTE_ERROR; diff --git a/lib/test/upper/pdcp_nr_test_tx.cc b/lib/test/upper/pdcp_nr_test_tx.cc index 0a4e67495..7f167dfd5 100644 --- a/lib/test/upper/pdcp_nr_test_tx.cc +++ b/lib/test/upper/pdcp_nr_test_tx.cc @@ -20,7 +20,7 @@ int test_tx(uint32_t n_packets, uint8_t pdcp_sn_len, uint64_t n_pdus_exp, srslte::unique_byte_buffer_t pdu_exp, - srslte::log_ref log) + srslog::basic_logger& logger) { srslte::pdcp_config_t cfg = {1, srslte::PDCP_RB_IS_DRB, @@ -30,7 +30,7 @@ int test_tx(uint32_t n_packets, srslte::pdcp_t_reordering_t::ms500, srslte::pdcp_discard_timer_t::infinity}; - pdcp_nr_test_helper pdcp_hlp(cfg, sec_cfg, log); + pdcp_nr_test_helper pdcp_hlp(cfg, sec_cfg, logger); srslte::pdcp_entity_nr* pdcp = &pdcp_hlp.pdcp; rlc_dummy* rlc = &pdcp_hlp.rlc; @@ -56,7 +56,7 @@ int test_tx(uint32_t n_packets, * TX Test: PDCP Entity with SN LEN = 12 and 18. * PDCP entity configured with EIA2 and EEA2 */ -int test_tx_all(srslte::log_ref log) +int test_tx_all(srslog::basic_logger& logger) { uint64_t n_packets; /* @@ -69,7 +69,8 @@ int test_tx_all(srslte::log_ref log) srslte::unique_byte_buffer_t pdu_exp_count0_len12 = srslte::make_byte_buffer(); pdu_exp_count0_len12->append_bytes(pdu1_count0_snlen12, sizeof(pdu1_count0_snlen12)); TESTASSERT( - test_tx(n_packets, normal_init_state, srslte::PDCP_SN_LEN_12, n_packets, std::move(pdu_exp_count0_len12), log) == + test_tx( + n_packets, normal_init_state, srslte::PDCP_SN_LEN_12, n_packets, std::move(pdu_exp_count0_len12), logger) == 0); /* @@ -81,10 +82,12 @@ int test_tx_all(srslte::log_ref log) n_packets = 2049; srslte::unique_byte_buffer_t pdu_exp_count2048_len12 = srslte::make_byte_buffer(); pdu_exp_count2048_len12->append_bytes(pdu1_count2048_snlen12, sizeof(pdu1_count2048_snlen12)); - TESTASSERT( - test_tx( - n_packets, normal_init_state, srslte::PDCP_SN_LEN_12, n_packets, std::move(pdu_exp_count2048_len12), log) == - 0); + TESTASSERT(test_tx(n_packets, + normal_init_state, + srslte::PDCP_SN_LEN_12, + n_packets, + std::move(pdu_exp_count2048_len12), + logger) == 0); /* * TX Test 3: PDCP Entity with SN LEN = 12 @@ -95,10 +98,12 @@ int test_tx_all(srslte::log_ref log) n_packets = 4097; srslte::unique_byte_buffer_t pdu_exp_count4096_len12 = srslte::make_byte_buffer(); pdu_exp_count4096_len12->append_bytes(pdu1_count4096_snlen12, sizeof(pdu1_count4096_snlen12)); - TESTASSERT( - test_tx( - n_packets, normal_init_state, srslte::PDCP_SN_LEN_12, n_packets, std::move(pdu_exp_count4096_len12), log) == - 0); + TESTASSERT(test_tx(n_packets, + normal_init_state, + srslte::PDCP_SN_LEN_12, + n_packets, + std::move(pdu_exp_count4096_len12), + logger) == 0); /* * TX Test 4: PDCP Entity with SN LEN = 18 @@ -110,7 +115,8 @@ int test_tx_all(srslte::log_ref log) srslte::unique_byte_buffer_t pdu_exp_count0_len18 = srslte::make_byte_buffer(); pdu_exp_count0_len18->append_bytes(pdu1_count0_snlen18, sizeof(pdu1_count0_snlen18)); TESTASSERT( - test_tx(n_packets, normal_init_state, srslte::PDCP_SN_LEN_18, n_packets, std::move(pdu_exp_count0_len18), log) == + test_tx( + n_packets, normal_init_state, srslte::PDCP_SN_LEN_18, n_packets, std::move(pdu_exp_count0_len18), logger) == 0); /* @@ -124,7 +130,7 @@ int test_tx_all(srslte::log_ref log) pdu_exp_sn131072_len18->append_bytes(pdu1_count131072_snlen18, sizeof(pdu1_count131072_snlen18)); TESTASSERT( test_tx( - n_packets, normal_init_state, srslte::PDCP_SN_LEN_18, n_packets, std::move(pdu_exp_sn131072_len18), log) == + n_packets, normal_init_state, srslte::PDCP_SN_LEN_18, n_packets, std::move(pdu_exp_sn131072_len18), logger) == 0); /* @@ -136,10 +142,12 @@ int test_tx_all(srslte::log_ref log) n_packets = 262145; srslte::unique_byte_buffer_t pdu_exp_count262144_len18 = srslte::make_byte_buffer(); pdu_exp_count262144_len18->append_bytes(pdu1_count262144_snlen18, sizeof(pdu1_count262144_snlen18)); - TESTASSERT( - test_tx( - n_packets, normal_init_state, srslte::PDCP_SN_LEN_18, n_packets, std::move(pdu_exp_count262144_len18), log) == - 0); + TESTASSERT(test_tx(n_packets, + normal_init_state, + srslte::PDCP_SN_LEN_18, + n_packets, + std::move(pdu_exp_count262144_len18), + logger) == 0); /* * TX Test 7: PDCP Entity with SN LEN = 12 @@ -154,7 +162,7 @@ int test_tx_all(srslte::log_ref log) srslte::PDCP_SN_LEN_12, 1, std::move(pdu_exp_count4294967295_len12), - log) == 0); + logger) == 0); /* * TX Test 8: PDCP Entity with SN LEN = 18 @@ -169,7 +177,7 @@ int test_tx_all(srslte::log_ref log) srslte::PDCP_SN_LEN_18, 1, std::move(pdu_exp_count4294967295_len18), - log) == 0); + logger) == 0); return 0; } @@ -177,16 +185,18 @@ int test_tx_all(srslte::log_ref log) int run_all_tests() { // Setup log - srslte::log_ref log("PDCP NR Test TX"); - log->set_level(srslte::LOG_LEVEL_DEBUG); - log->set_hex_limit(128); + auto& logger = srslog::fetch_basic_logger("PDCP NR Test TX", false); + logger.set_level(srslog::basic_levels::debug); + logger.set_hex_dump_max_size(128); - TESTASSERT(test_tx_all(log) == 0); + TESTASSERT(test_tx_all(logger) == 0); return 0; } int main() { + srslog::init(); + if (run_all_tests() != SRSLTE_SUCCESS) { fprintf(stderr, "pdcp_nr_tests_tx() failed\n"); return SRSLTE_ERROR;