From a77dd4e9597f70e5d35e4d2b7e17aa13b39f202a Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Mon, 25 Nov 2019 15:16:37 +0000 Subject: [PATCH] Starting to add boiler-plate code to support Discard at RLC. --- lib/include/srslte/interfaces/ue_interfaces.h | 3 ++- lib/include/srslte/upper/pdcp_entity_nr.h | 2 +- lib/include/srslte/upper/rlc_am_lte.h | 4 +++- lib/include/srslte/upper/rlc_common.h | 1 + lib/include/srslte/upper/rlc_tm.h | 1 + lib/include/srslte/upper/rlc_um_base.h | 2 ++ lib/src/upper/rlc_am_lte.cc | 17 +++++++++++++++-- lib/src/upper/rlc_tm.cc | 8 ++++++++ lib/src/upper/rlc_um_base.cc | 9 +++++++++ srsenb/hdr/stack/upper/pdcp.h | 1 + 10 files changed, 43 insertions(+), 5 deletions(-) diff --git a/lib/include/srslte/interfaces/ue_interfaces.h b/lib/include/srslte/interfaces/ue_interfaces.h index 395dd9145..f39f16be9 100644 --- a/lib/include/srslte/interfaces/ue_interfaces.h +++ b/lib/include/srslte/interfaces/ue_interfaces.h @@ -287,7 +287,8 @@ public: /* PDCP calls RLC to push an RLC SDU. SDU gets placed into the RLC buffer and MAC pulls * RLC PDUs according to TB size. */ virtual void write_sdu(uint32_t lcid, srslte::unique_byte_buffer_t sdu, bool blocking = true) = 0; - virtual bool rb_is_um(uint32_t lcid) = 0; + virtual void discard_sdu(uint32_t discard_sn) = 0; + virtual bool rb_is_um(uint32_t lcid) = 0; }; //RLC interface for MAC diff --git a/lib/include/srslte/upper/pdcp_entity_nr.h b/lib/include/srslte/upper/pdcp_entity_nr.h index 3beb1c2ec..872080f58 100644 --- a/lib/include/srslte/upper/pdcp_entity_nr.h +++ b/lib/include/srslte/upper/pdcp_entity_nr.h @@ -134,7 +134,7 @@ public: private: pdcp_entity_nr* parent; - uint32_t sn; + uint32_t discard_sn; }; /* diff --git a/lib/include/srslte/upper/rlc_am_lte.h b/lib/include/srslte/upper/rlc_am_lte.h index 72abd3b54..99ffafb4e 100644 --- a/lib/include/srslte/upper/rlc_am_lte.h +++ b/lib/include/srslte/upper/rlc_am_lte.h @@ -80,6 +80,7 @@ public: // PDCP interface void write_sdu(unique_byte_buffer_t sdu, bool blocking = true); + void discard_sdu(uint32_t pdcp_sn); // MAC interface bool has_data(); @@ -106,7 +107,8 @@ private: void stop(); void write_sdu(unique_byte_buffer_t sdu, bool blocking); - int read_pdu(uint8_t *payload, uint32_t nof_bytes); + int read_pdu(uint8_t* payload, uint32_t nof_bytes); + void discard_sdu(uint32_t discard_sn); bool has_data(); uint32_t get_buffer_state(); diff --git a/lib/include/srslte/upper/rlc_common.h b/lib/include/srslte/upper/rlc_common.h index fee78d101..2ccfecee5 100644 --- a/lib/include/srslte/upper/rlc_common.h +++ b/lib/include/srslte/upper/rlc_common.h @@ -256,6 +256,7 @@ public: // PDCP interface virtual void write_sdu(unique_byte_buffer_t sdu, bool blocking) = 0; + virtual void discard_sdu(uint32_t discard_sn) = 0; // MAC interface virtual bool has_data() = 0; diff --git a/lib/include/srslte/upper/rlc_tm.h b/lib/include/srslte/upper/rlc_tm.h index 08da7cb4f..8710e21bc 100644 --- a/lib/include/srslte/upper/rlc_tm.h +++ b/lib/include/srslte/upper/rlc_tm.h @@ -54,6 +54,7 @@ public: // PDCP interface void write_sdu(unique_byte_buffer_t sdu, bool blocking); + void discard_sdu(uint32_t discard_sn); // MAC interface bool has_data(); diff --git a/lib/include/srslte/upper/rlc_um_base.h b/lib/include/srslte/upper/rlc_um_base.h index 4ff633fe4..86e80a9e5 100644 --- a/lib/include/srslte/upper/rlc_um_base.h +++ b/lib/include/srslte/upper/rlc_um_base.h @@ -54,6 +54,7 @@ public: // PDCP interface void write_sdu(unique_byte_buffer_t sdu, bool blocking = true); + void discard_sdu(uint32_t discard_sn); // MAC interface bool has_data(); @@ -78,6 +79,7 @@ protected: void reestablish(); void empty_queue(); void write_sdu(unique_byte_buffer_t sdu); + void discard_sdu(uint32_t discard_sn); void try_write_sdu(unique_byte_buffer_t sdu); void reset_metrics(); bool has_data(); diff --git a/lib/src/upper/rlc_am_lte.cc b/lib/src/upper/rlc_am_lte.cc index de3e340e8..265fbec2c 100644 --- a/lib/src/upper/rlc_am_lte.cc +++ b/lib/src/upper/rlc_am_lte.cc @@ -122,6 +122,11 @@ void rlc_am_lte::write_sdu(unique_byte_buffer_t sdu, bool blocking) tx.write_sdu(std::move(sdu), blocking); } +void rlc_am_lte::discard_sdu(uint32_t discard_sn) +{ + tx.discard_sdu(discard_sn); +} + /**************************************************************************** * MAC interface ***************************************************************************/ @@ -337,8 +342,8 @@ void rlc_am_lte::rlc_am_lte_tx::write_sdu(unique_byte_buffer_t sdu, bool blockin tx_sdu_queue.write(std::move(sdu)); } else { // non-blocking write - uint8_t* msg_ptr = sdu->msg; - uint32_t nof_bytes = sdu->N_bytes; + uint8_t* msg_ptr = sdu->msg; + uint32_t nof_bytes = sdu->N_bytes; std::pair ret = tx_sdu_queue.try_write(std::move(sdu)); if (ret.first) { log->info_hex( @@ -358,6 +363,14 @@ void rlc_am_lte::rlc_am_lte_tx::write_sdu(unique_byte_buffer_t sdu, bool blockin } } +void rlc_am_lte::rlc_am_lte_tx::discard_sdu(uint32_t discard_sn) +{ + if (!tx_enabled) { + return; + } + log->warning("Discard SDU not implemented yet\n"); +} + int rlc_am_lte::rlc_am_lte_tx::read_pdu(uint8_t* payload, uint32_t nof_bytes) { pthread_mutex_lock(&mutex); diff --git a/lib/src/upper/rlc_tm.cc b/lib/src/upper/rlc_tm.cc index becab3444..fa89858a2 100644 --- a/lib/src/upper/rlc_tm.cc +++ b/lib/src/upper/rlc_tm.cc @@ -115,6 +115,14 @@ void rlc_tm::write_sdu(unique_byte_buffer_t sdu, bool blocking) } } +void rlc_tm::discard_sdu(uint32_t discard_sn) +{ + if (!tx_enabled) { + return; + } + log->warning("SDU discard not implemented on RLC TM\n"); +} + // MAC interface bool rlc_tm::has_data() { diff --git a/lib/src/upper/rlc_um_base.cc b/lib/src/upper/rlc_um_base.cc index 517835084..c5349f526 100644 --- a/lib/src/upper/rlc_um_base.cc +++ b/lib/src/upper/rlc_um_base.cc @@ -104,6 +104,15 @@ void rlc_um_base::write_sdu(unique_byte_buffer_t sdu, bool blocking) } } +void rlc_um_base::discard_sdu(uint32_t discard_sn) +{ + if (not tx_enabled || not tx) { + log->debug("%s is currently deactivated. Ignoring SDU discard(SN %" PRIu32 ")\n", rb_name.c_str(), discard_sn); + metrics.num_dropped_sdus++; + return; + } + tx->discard_sdu(discard_sn); +} /**************************************************************************** * MAC interface ***************************************************************************/ diff --git a/srsenb/hdr/stack/upper/pdcp.h b/srsenb/hdr/stack/upper/pdcp.h index d0d1d1009..bab7808d9 100644 --- a/srsenb/hdr/stack/upper/pdcp.h +++ b/srsenb/hdr/stack/upper/pdcp.h @@ -66,6 +66,7 @@ private: srsenb::rlc_interface_pdcp* rlc; // rlc_interface_pdcp void write_sdu(uint32_t lcid, srslte::unique_byte_buffer_t sdu, bool blocking); + void discard_sdu(uint32_t discard_sn); bool rb_is_um(uint32_t lcid); };