From 5b8d4c39afea7ce796ab244a0fe1096925b8188e Mon Sep 17 00:00:00 2001 From: Francisco Date: Wed, 27 Oct 2021 15:09:42 +0100 Subject: [PATCH] pdcp,lte: fix drb/srb id logging to account for dynamic mapping --- lib/include/srsran/upper/pdcp_entity_lte.h | 3 ++ lib/src/pdcp/pdcp_entity_lte.cc | 44 +++++++++++++++------- 2 files changed, 34 insertions(+), 13 deletions(-) diff --git a/lib/include/srsran/upper/pdcp_entity_lte.h b/lib/include/srsran/upper/pdcp_entity_lte.h index a8b96bb03..86c613726 100644 --- a/lib/include/srsran/upper/pdcp_entity_lte.h +++ b/lib/include/srsran/upper/pdcp_entity_lte.h @@ -156,6 +156,9 @@ private: uint32_t reordering_window = 0; uint32_t maximum_pdcp_sn = 0; + std::string get_rb_name() const; + void get_rb_name(fmt::memory_buffer& fmtbuf) const; + // PDU handlers void handle_control_pdu(srsran::unique_byte_buffer_t pdu); void handle_srb_pdu(srsran::unique_byte_buffer_t pdu); diff --git a/lib/src/pdcp/pdcp_entity_lte.cc b/lib/src/pdcp/pdcp_entity_lte.cc index af5663735..91f573aca 100644 --- a/lib/src/pdcp/pdcp_entity_lte.cc +++ b/lib/src/pdcp/pdcp_entity_lte.cc @@ -54,7 +54,7 @@ bool pdcp_entity_lte::configure(const pdcp_config_t& cnfg_) if (active) { // Already configured if (cnfg_ != cfg) { - logger.error("Bearer reconfiguration not supported. LCID=%s.", rrc->get_rb_name(lcid)); + logger.error("Bearer reconfiguration not supported. LCID=%s.", get_rb_name().c_str()); return false; } return true; @@ -79,7 +79,7 @@ bool pdcp_entity_lte::configure(const pdcp_config_t& cnfg_) // Queue Helpers maximum_allocated_sns_window = (1u << cfg.sn_len) / 2u; - logger.info("Init %s with bearer ID: %d", rrc->get_rb_name(lcid), cfg.bearer_id); + logger.info("Init %s with bearer ID: %d", get_rb_name().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, @@ -104,7 +104,7 @@ bool pdcp_entity_lte::configure(const pdcp_config_t& cnfg_) // Reestablishment procedure: 36.323 5.2 void pdcp_entity_lte::reestablish() { - logger.info("Re-establish %s with bearer ID: %d", rrc->get_rb_name(lcid), cfg.bearer_id); + logger.info("Re-establish %s with bearer ID: %d", get_rb_name().c_str(), cfg.bearer_id); // For SRBs if (is_srb()) { st.next_pdcp_tx_sn = 0; @@ -126,7 +126,7 @@ void pdcp_entity_lte::reestablish() void pdcp_entity_lte::reset() { if (active) { - logger.debug("Reset %s", rrc->get_rb_name(lcid)); + logger.debug("Reset %s", get_rb_name().c_str()); } active = false; } @@ -135,7 +135,7 @@ void pdcp_entity_lte::reset() void pdcp_entity_lte::write_sdu(unique_byte_buffer_t sdu, int upper_sn) { if (!active) { - logger.warning("Dropping %s SDU due to inactive bearer", rrc->get_rb_name(lcid)); + logger.warning("Dropping %s SDU due to inactive bearer", get_rb_name().c_str()); return; } @@ -145,7 +145,7 @@ void pdcp_entity_lte::write_sdu(unique_byte_buffer_t sdu, int upper_sn) } if (rlc->sdu_queue_is_full(lcid)) { - logger.info(sdu->msg, sdu->N_bytes, "Dropping %s SDU due to full queue", rrc->get_rb_name(lcid)); + logger.info(sdu->msg, sdu->N_bytes, "Dropping %s SDU due to full queue", get_rb_name().c_str()); return; } @@ -199,7 +199,7 @@ void pdcp_entity_lte::write_sdu(unique_byte_buffer_t sdu, int upper_sn) logger.info(sdu->msg, sdu->N_bytes, "TX %s PDU, SN=%d, integrity=%s, encryption=%s", - rrc->get_rb_name(lcid), + get_rb_name().c_str(), used_sn, srsran_direction_text[integrity_direction], srsran_direction_text[encryption_direction]); @@ -226,7 +226,7 @@ void pdcp_entity_lte::write_sdu(unique_byte_buffer_t sdu, int upper_sn) void pdcp_entity_lte::write_pdu(unique_byte_buffer_t pdu) { if (!active) { - logger.warning("Dropping %s PDU due to inactive bearer", rrc->get_rb_name(lcid)); + logger.warning("Dropping %s PDU due to inactive bearer", get_rb_name()); return; } @@ -256,7 +256,7 @@ void pdcp_entity_lte::write_pdu(unique_byte_buffer_t pdu) logger.info(pdu->msg, pdu->N_bytes, "%s Rx PDU SN=%d (%d B, integrity=%s, encryption=%s)", - rrc->get_rb_name(lcid), + get_rb_name(), sn, pdu->N_bytes, srsran_direction_text[integrity_direction], @@ -316,7 +316,7 @@ void pdcp_entity_lte::handle_srb_pdu(srsran::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]); } - logger.debug(pdu->msg, pdu->N_bytes, "%s Rx SDU SN=%d", rrc->get_rb_name(lcid), sn); + logger.debug(pdu->msg, pdu->N_bytes, "%s Rx SDU SN=%d", get_rb_name(), sn); // Extract MAC uint8_t mac[4]; @@ -325,7 +325,7 @@ void pdcp_entity_lte::handle_srb_pdu(srsran::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)) { - logger.error(pdu->msg, pdu->N_bytes, "%s Dropping PDU", rrc->get_rb_name(lcid)); + logger.error(pdu->msg, pdu->N_bytes, "%s Dropping PDU", get_rb_name()); rrc->notify_pdcp_integrity_error(lcid); return; // Discard } @@ -364,7 +364,7 @@ void pdcp_entity_lte::handle_um_drb_pdu(srsran::unique_byte_buffer_t pdu) cipher_decrypt(pdu->msg, pdu->N_bytes, count, pdu->msg); } - logger.debug(pdu->msg, pdu->N_bytes, "%s Rx PDU SN=%d", rrc->get_rb_name(lcid), sn); + logger.debug(pdu->msg, pdu->N_bytes, "%s Rx PDU SN=%d", get_rb_name(), sn); st.next_pdcp_rx_sn = sn + 1; if (st.next_pdcp_rx_sn > maximum_pdcp_sn) { @@ -428,7 +428,7 @@ void pdcp_entity_lte::handle_am_drb_pdu(srsran::unique_byte_buffer_t pdu) // Decrypt cipher_decrypt(pdu->msg, pdu->N_bytes, count, pdu->msg); - logger.debug(pdu->msg, pdu->N_bytes, "%s Rx SDU SN=%d", rrc->get_rb_name(lcid), sn); + logger.debug(pdu->msg, pdu->N_bytes, "%s Rx SDU SN=%d", get_rb_name(), sn); // Update info on last PDU submitted to upper layers st.last_submitted_pdcp_rx_sn = sn; @@ -857,6 +857,24 @@ void pdcp_entity_lte::reset_metrics() metrics.tx_notification_latency_ms = 0; } +/**************************************************************************** + * Logging helpers + ***************************************************************************/ +std::string pdcp_entity_lte::get_rb_name() const +{ + fmt::memory_buffer fmtbuf; + get_rb_name(fmtbuf); + return fmt::to_string(fmtbuf); +} +void pdcp_entity_lte::get_rb_name(fmt::memory_buffer& fmtbuf) const +{ + if (cfg.rb_type == PDCP_RB_IS_DRB) { + fmt::format_to(fmtbuf, "DRB{}", cfg.bearer_id); + } else { + fmt::format_to(fmtbuf, "SRB{}", cfg.bearer_id); + } +} + /**************************************************************************** * Undelivered SDUs queue helpers ***************************************************************************/