From fd1d73666c72d7d800f9b061d1bdf4d3a2949216 Mon Sep 17 00:00:00 2001 From: Francisco Date: Fri, 4 Jun 2021 17:37:58 +0100 Subject: [PATCH] bugfix,srsenb,mac: avoid sanity check for UL PDU length if CRC=KO --- srsenb/hdr/stack/mac/ue.h | 4 ++-- srsenb/src/stack/mac/mac.cc | 10 ++++++++-- srsenb/src/stack/mac/ue.cc | 7 +++---- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/srsenb/hdr/stack/mac/ue.h b/srsenb/hdr/stack/mac/ue.h index 6e43597d6..07f84955a 100644 --- a/srsenb/hdr/stack/mac/ue.h +++ b/srsenb/hdr/stack/mac/ue.h @@ -71,7 +71,7 @@ public: uint8_t* request_pdu(tti_point tti, uint32_t len); - srsran::unique_byte_buffer_t release_pdu(tti_point tti, uint32_t len); + srsran::unique_byte_buffer_t release_pdu(tti_point tti); void clear_old_pdus(tti_point current_tti); @@ -157,7 +157,7 @@ public: uint8_t* request_buffer(uint32_t tti, uint32_t ue_cc_idx, const uint32_t len); void process_pdu(srsran::unique_byte_buffer_t pdu, uint32_t grant_nof_prbs); - srsran::unique_byte_buffer_t release_pdu(uint32_t tti, uint32_t ue_cc_idx, uint32_t len); + srsran::unique_byte_buffer_t release_pdu(uint32_t tti, uint32_t ue_cc_idx); void clear_old_buffers(uint32_t tti); void metrics_read(mac_ue_metrics_t* metrics_); diff --git a/srsenb/src/stack/mac/mac.cc b/srsenb/src/stack/mac/mac.cc index 4068af05c..14fe50b55 100644 --- a/srsenb/src/stack/mac/mac.cc +++ b/srsenb/src/stack/mac/mac.cc @@ -363,7 +363,7 @@ int mac::push_pdu(uint32_t tti_rx, } uint32_t ue_cc_idx = enb_ue_cc_map[enb_cc_idx]; - srsran::unique_byte_buffer_t pdu = ue_db[rnti]->release_pdu(tti_rx, ue_cc_idx, nof_bytes); + srsran::unique_byte_buffer_t pdu = ue_db[rnti]->release_pdu(tti_rx, ue_cc_idx); if (pdu == nullptr) { logger.warning("Could not find MAC UL PDU for rnti=0x%x, cc=%d, tti=%d", rnti, enb_cc_idx, tti_rx); return SRSRAN_ERROR; @@ -372,6 +372,12 @@ int mac::push_pdu(uint32_t tti_rx, // push the pdu through the queue if received correctly if (crc) { logger.info("Pushing PDU rnti=0x%x, tti_rx=%d, nof_bytes=%d", rnti, tti_rx, nof_bytes); + srsran_expect(nof_bytes == pdu->size(), + "Inconsistent PDU length for rnti=0x%x, tti_rx=%d (%d!=%d)", + rnti, + tti_rx, + nof_bytes, + (int)pdu->size()); auto process_pdu_task = [this, rnti, ul_nof_prbs](srsran::unique_byte_buffer_t& pdu) { srsran::rwlock_read_guard lock(rwlock); if (ue_db.contains(rnti)) { @@ -830,7 +836,7 @@ void mac::build_mch_sched(uint32_t tbs) int mac::get_mch_sched(uint32_t tti, bool is_mcch, dl_sched_list_t& dl_sched_res_list) { srsran::rwlock_read_guard lock(rwlock); - dl_sched_t* dl_sched_res = &dl_sched_res_list[0]; + dl_sched_t* dl_sched_res = &dl_sched_res_list[0]; logger.set_context(tti); srsran_ra_tb_t mcs = {}; srsran_ra_tb_t mcs_data = {}; diff --git a/srsenb/src/stack/mac/ue.cc b/srsenb/src/stack/mac/ue.cc index ebbb03861..426e907ed 100644 --- a/srsenb/src/stack/mac/ue.cc +++ b/srsenb/src/stack/mac/ue.cc @@ -69,7 +69,7 @@ cc_used_buffers_map::~cc_used_buffers_map() clear(); } -srsran::unique_byte_buffer_t cc_used_buffers_map::release_pdu(tti_point tti, uint32_t len) +srsran::unique_byte_buffer_t cc_used_buffers_map::release_pdu(tti_point tti) { if (not has_tti(tti)) { return nullptr; @@ -77,7 +77,6 @@ srsran::unique_byte_buffer_t cc_used_buffers_map::release_pdu(tti_point tti, uin // Extract PDU from PDU map srsran::unique_byte_buffer_t pdu = std::move(pdu_map[tti.to_uint()]); - srsran_expect(pdu->size() == len, "UL buffers: Inconsistent UL PDU length for tti=%d", tti.to_uint()); // clear entry in map pdu_map.erase(tti.to_uint()); @@ -378,10 +377,10 @@ void ue::process_pdu(srsran::unique_byte_buffer_t pdu, uint32_t grant_nof_prbs) logger.debug("MAC PDU processed"); } -srsran::unique_byte_buffer_t ue::release_pdu(uint32_t tti, uint32_t ue_cc_idx, uint32_t len) +srsran::unique_byte_buffer_t ue::release_pdu(uint32_t tti, uint32_t ue_cc_idx) { std::lock_guard lock(rx_buffers_mutex); - return cc_buffers[ue_cc_idx].get_rx_used_buffers().release_pdu(tti_point(tti), len); + return cc_buffers[ue_cc_idx].get_rx_used_buffers().release_pdu(tti_point(tti)); } bool ue::process_ce(srsran::sch_subh* subh, uint32_t grant_nof_prbs)