From e413086576799fc6fb32ebc29e49695806aa9b01 Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Tue, 19 Jan 2021 12:22:36 +0100 Subject: [PATCH 1/7] Limit the number of UL buffers in MAC and deallocate old ones --- srsenb/hdr/stack/mac/ue.h | 10 +++++++--- srsenb/src/stack/mac/mac.cc | 6 +++--- srsenb/src/stack/mac/ue.cc | 35 +++++++++++++++++++++++++++++------ 3 files changed, 39 insertions(+), 12 deletions(-) diff --git a/srsenb/hdr/stack/mac/ue.h b/srsenb/hdr/stack/mac/ue.h index f8e9b7b9f..3dde41198 100644 --- a/srsenb/hdr/stack/mac/ue.h +++ b/srsenb/hdr/stack/mac/ue.h @@ -15,6 +15,7 @@ #include "mac_metrics.h" #include "srslte/common/block_queue.h" +#include "srslte/adt/circular_array.h" #include "srslte/common/log.h" #include "srslte/common/mac_pcap.h" #include "srslte/interfaces/enb_interfaces.h" @@ -71,10 +72,10 @@ public: srslte_softbuffer_rx_t* get_rx_softbuffer(const uint32_t ue_cc_idx, const uint32_t tti); bool process_pdus(); - uint8_t* request_buffer(const uint32_t len); + uint8_t* request_buffer(uint32_t tti, const uint32_t len); void process_pdu(uint8_t* pdu, uint32_t nof_bytes, srslte::pdu_queue::channel_t channel) override; - void push_pdu(const uint8_t* pdu_ptr, uint32_t len); - void deallocate_pdu(const uint8_t* pdu_ptr); + void push_pdu(uint32_t tti, const uint8_t* pdu_ptr, uint32_t len); + void deallocate_pdu(uint32_t tti, const uint8_t* pdu_ptr); void metrics_read(mac_ue_metrics_t* metrics_); void metrics_rx(bool crc, uint32_t tbs); @@ -122,6 +123,9 @@ private: std::vector, SRSLTE_FDD_NOF_HARQ> > tx_payload_buffer; + // Save 2 buffers per HARQ process + srslte::circular_array rx_used_buffers; + srslte::block_queue pending_ta_commands; ta ta_fsm; diff --git a/srsenb/src/stack/mac/mac.cc b/srsenb/src/stack/mac/mac.cc index 2b7abc3b4..0d7cd86cb 100644 --- a/srsenb/src/stack/mac/mac.cc +++ b/srsenb/src/stack/mac/mac.cc @@ -334,11 +334,11 @@ int mac::push_pdu(uint32_t tti_rx, uint16_t rnti, const uint8_t* pdu_ptr, uint32 // push the pdu through the queue if received correctly if (crc) { Info("Pushing PDU rnti=0x%x, tti_rx=%d, nof_bytes=%d\n", rnti, tti_rx, nof_bytes); - ue_db[rnti]->push_pdu(pdu_ptr, nof_bytes); + ue_db[rnti]->push_pdu(tti_rx, pdu_ptr, nof_bytes); stack_task_queue.push([this]() { process_pdus(); }); } else { Debug("Discarting PDU rnti=0x%x, tti_rx=%d, nof_bytes=%d\n", rnti, tti_rx, nof_bytes); - ue_db[rnti]->deallocate_pdu(pdu_ptr); + ue_db[rnti]->deallocate_pdu(tti_rx, pdu_ptr); } return SRSLTE_SUCCESS; } @@ -906,7 +906,7 @@ int mac::get_ul_sched(uint32_t tti_tx_ul, ul_sched_list_t& ul_sched_res_list) if (sched_result.pusch[n].current_tx_nb == 0) { srslte_softbuffer_rx_reset_tbs(phy_ul_sched_res->pusch[n].softbuffer_rx, sched_result.pusch[i].tbs * 8); } - phy_ul_sched_res->pusch[n].data = ue_db[rnti]->request_buffer(sched_result.pusch[i].tbs); + phy_ul_sched_res->pusch[n].data = ue_db[rnti]->request_buffer(tti_tx_ul, sched_result.pusch[i].tbs); if (phy_ul_sched_res->pusch[n].data) { phy_ul_sched_res->nof_grants++; } else { diff --git a/srsenb/src/stack/mac/ue.cc b/srsenb/src/stack/mac/ue.cc index d0e99c2a9..ef1b32041 100644 --- a/srsenb/src/stack/mac/ue.cc +++ b/srsenb/src/stack/mac/ue.cc @@ -161,14 +161,27 @@ ue::get_tx_softbuffer(const uint32_t ue_cc_idx, const uint32_t harq_process, con return &softbuffer_tx.at(ue_cc_idx).at((harq_process * SRSLTE_MAX_TB + tb_idx) % nof_tx_harq_proc); } -uint8_t* ue::request_buffer(const uint32_t len) +uint8_t* ue::request_buffer(uint32_t tti, const uint32_t len) { + uint8_t* pdu = nullptr; if (len > 0) { - return pdus.request(len); + pdu = pdus.request(len); + if (pdu) { + // Deallocate oldest buffer if we didn't deallocate it + if (rx_used_buffers[tti] != nullptr) { + pdus.deallocate(rx_used_buffers[tti]); + rx_used_buffers[tti] = nullptr; + log_h->warning("buffers: RX PDU of rnti=0x%x and pid=%d wasn't deallocated\n", rnti, tti % nof_rx_harq_proc); + } + rx_used_buffers[tti] = pdu; + log_h->info("RX PDU saved for pid=%d\n", tti % nof_rx_harq_proc); + } else { + log_h->error("buffers: Requesting buffer from pool\n"); + } } else { - log_h->warning("Requesting buffer for zero bytes\n"); - return nullptr; + printf("buffers: Requesting buffer for zero bytes\n"); } + return pdu; } bool ue::process_pdus() @@ -293,18 +306,28 @@ void ue::process_pdu(uint8_t* pdu, uint32_t nof_bytes, srslte::pdu_queue::channe Debug("MAC PDU processed\n"); } -void ue::deallocate_pdu(const uint8_t* pdu_ptr) +void ue::deallocate_pdu(uint32_t tti, const uint8_t* pdu_ptr) { if (pdu_ptr) { + if (rx_used_buffers[tti] == pdu_ptr) { + rx_used_buffers[tti] = nullptr; + } else { + Warning("buffers: Unexpected RX PDU pointer in deallocate_pdu for rnti=0x%x pid=%d\n", rnti, tti % nof_rx_harq_proc); + } pdus.deallocate(pdu_ptr); } else { Error("Error deallocating PDU: null ptr\n"); } } -void ue::push_pdu(const uint8_t* pdu_ptr, uint32_t len) +void ue::push_pdu(uint32_t tti, const uint8_t* pdu_ptr, uint32_t len) { if (pdu_ptr && len > 0) { + if (rx_used_buffers[tti] == pdu_ptr) { + rx_used_buffers[tti] = nullptr; + } else { + Warning("buffers: Unexpected RX PDU pointer in push_pdu for rnti=0x%x pid=%d\n", rnti, tti % nof_rx_harq_proc); + } pdus.push(pdu_ptr, len); } else { Error("Error pushing PDU: ptr=%p, len=%d\n", pdu_ptr, len); From f7d97d0d7beb390899a6f61547d8ef46bb4a6dfe Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Tue, 19 Jan 2021 15:33:11 +0100 Subject: [PATCH 2/7] Release pointer even if length is zero --- srsenb/src/stack/mac/ue.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/srsenb/src/stack/mac/ue.cc b/srsenb/src/stack/mac/ue.cc index ef1b32041..41ccc9425 100644 --- a/srsenb/src/stack/mac/ue.cc +++ b/srsenb/src/stack/mac/ue.cc @@ -322,15 +322,19 @@ void ue::deallocate_pdu(uint32_t tti, const uint8_t* pdu_ptr) void ue::push_pdu(uint32_t tti, const uint8_t* pdu_ptr, uint32_t len) { - if (pdu_ptr && len > 0) { + if (pdu_ptr) { if (rx_used_buffers[tti] == pdu_ptr) { rx_used_buffers[tti] = nullptr; } else { Warning("buffers: Unexpected RX PDU pointer in push_pdu for rnti=0x%x pid=%d\n", rnti, tti % nof_rx_harq_proc); } - pdus.push(pdu_ptr, len); + if (len > 0) { + pdus.push(pdu_ptr, len); + } else { + Error("Error pushing PDU: null length\n"); + } } else { - Error("Error pushing PDU: ptr=%p, len=%d\n", pdu_ptr, len); + Error("Error pushing PDU: null pointer\n"); } } From e5df35304d4d6574df8136c0310ff059b1a52f94 Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Tue, 19 Jan 2021 16:58:56 +0100 Subject: [PATCH 3/7] Fix issue with new way of managing ul buffers not working with CA --- .../srslte/interfaces/enb_interfaces.h | 4 +- srsenb/hdr/stack/enb_stack_lte.h | 4 +- srsenb/hdr/stack/mac/mac.h | 2 +- srsenb/hdr/stack/mac/ue.h | 8 +-- srsenb/src/phy/lte/cc_worker.cc | 2 +- srsenb/src/stack/mac/mac.cc | 16 ++++-- srsenb/src/stack/mac/ue.cc | 54 +++++++++++-------- srsenb/test/phy/enb_phy_test.cc | 2 +- 8 files changed, 54 insertions(+), 38 deletions(-) diff --git a/lib/include/srslte/interfaces/enb_interfaces.h b/lib/include/srslte/interfaces/enb_interfaces.h index b7945afb2..d93a84c9c 100644 --- a/lib/include/srslte/interfaces/enb_interfaces.h +++ b/lib/include/srslte/interfaces/enb_interfaces.h @@ -177,12 +177,12 @@ public: * * @param tti the given TTI * @param rnti the UE identifier in the eNb - * @param pdu_ptr pointer to the uplink buffer + * @param enb_cc_idx the eNb Cell/Carrier identifier * @param nof_bytes the number of grants carrierd by the PUSCH message * @param crc_res the CRC check, set to true if the message was decoded succesfully * @return SRSLTE_SUCCESS if no error occurs, SRSLTE_ERROR* if an error occurs */ - virtual int push_pdu(uint32_t tti_rx, uint16_t rnti, const uint8_t* pdu_ptr, uint32_t nof_bytes, bool crc_res) = 0; + virtual int push_pdu(uint32_t tti_rx, uint16_t rnti, uint32_t enb_cc_idx, uint32_t nof_bytes, bool crc_res) = 0; virtual int get_dl_sched(uint32_t tti, dl_sched_list_t& dl_sched_res) = 0; virtual int get_mch_sched(uint32_t tti, bool is_mcch, dl_sched_list_t& dl_sched_res) = 0; diff --git a/srsenb/hdr/stack/enb_stack_lte.h b/srsenb/hdr/stack/enb_stack_lte.h index 8929bbfc6..62d96cc68 100644 --- a/srsenb/hdr/stack/enb_stack_lte.h +++ b/srsenb/hdr/stack/enb_stack_lte.h @@ -80,9 +80,9 @@ public: { return mac.crc_info(tti, rnti, enb_cc_idx, nof_bytes, crc_res); } - int push_pdu(uint32_t tti, uint16_t rnti, const uint8_t* pdu_ptr, uint32_t nof_bytes, bool crc_res) final + int push_pdu(uint32_t tti, uint16_t rnti, uint32_t enb_cc_idx, uint32_t nof_bytes, bool crc_res) final { - return mac.push_pdu(tti, rnti, pdu_ptr, nof_bytes, crc_res); + return mac.push_pdu(tti, rnti, enb_cc_idx, nof_bytes, crc_res); } int get_dl_sched(uint32_t tti, dl_sched_list_t& dl_sched_res) final { return mac.get_dl_sched(tti, dl_sched_res); } int get_mch_sched(uint32_t tti, bool is_mcch, dl_sched_list_t& dl_sched_res) final diff --git a/srsenb/hdr/stack/mac/mac.h b/srsenb/hdr/stack/mac/mac.h index 6f6a72a08..0aa6c1832 100644 --- a/srsenb/hdr/stack/mac/mac.h +++ b/srsenb/hdr/stack/mac/mac.h @@ -56,7 +56,7 @@ public: int ta_info(uint32_t tti, uint16_t rnti, float ta_us) override; int ack_info(uint32_t tti, uint16_t rnti, uint32_t enb_cc_idx, uint32_t tb_idx, bool ack) override; int crc_info(uint32_t tti, uint16_t rnti, uint32_t enb_cc_idx, uint32_t nof_bytes, bool crc_res) override; - int push_pdu(uint32_t tti, uint16_t rnti, const uint8_t* pdu_ptr, uint32_t nof_bytes, bool crc_res) override; + int push_pdu(uint32_t tti, uint16_t rnti, uint32_t enb_cc_idx, uint32_t nof_bytes, bool crc_res) override; int get_dl_sched(uint32_t tti_tx_dl, dl_sched_list_t& dl_sched_res) override; int get_ul_sched(uint32_t tti_tx_ul, ul_sched_list_t& ul_sched_res) override; diff --git a/srsenb/hdr/stack/mac/ue.h b/srsenb/hdr/stack/mac/ue.h index 3dde41198..6eae19f1f 100644 --- a/srsenb/hdr/stack/mac/ue.h +++ b/srsenb/hdr/stack/mac/ue.h @@ -72,10 +72,10 @@ public: srslte_softbuffer_rx_t* get_rx_softbuffer(const uint32_t ue_cc_idx, const uint32_t tti); bool process_pdus(); - uint8_t* request_buffer(uint32_t tti, const uint32_t len); + uint8_t* request_buffer(uint32_t tti, uint32_t ue_cc_idx, const uint32_t len); void process_pdu(uint8_t* pdu, uint32_t nof_bytes, srslte::pdu_queue::channel_t channel) override; - void push_pdu(uint32_t tti, const uint8_t* pdu_ptr, uint32_t len); - void deallocate_pdu(uint32_t tti, const uint8_t* pdu_ptr); + void push_pdu(uint32_t tti, uint32_t ue_cc_idx, uint32_t len); + void deallocate_pdu(uint32_t tti, uint32_t ue_cc_idx); void metrics_read(mac_ue_metrics_t* metrics_); void metrics_rx(bool crc, uint32_t tbs); @@ -124,7 +124,7 @@ private: tx_payload_buffer; // Save 2 buffers per HARQ process - srslte::circular_array rx_used_buffers; + std::vector > rx_used_buffers; srslte::block_queue pending_ta_commands; ta ta_fsm; diff --git a/srsenb/src/phy/lte/cc_worker.cc b/srsenb/src/phy/lte/cc_worker.cc index 0c568d39b..1d04fd282 100644 --- a/srsenb/src/phy/lte/cc_worker.cc +++ b/srsenb/src/phy/lte/cc_worker.cc @@ -374,7 +374,7 @@ void cc_worker::decode_pusch(stack_interface_phy_lte::ul_sched_grant_t* grants, // Inform MAC about the CRC result phy->stack->crc_info(tti_rx, rnti, cc_idx, ul_cfg.pusch.grant.tb.tbs / 8, pusch_res.crc); // Push PDU buffer - phy->stack->push_pdu(tti_rx, rnti, grants[i].data, ul_cfg.pusch.grant.tb.tbs / 8, pusch_res.crc); + phy->stack->push_pdu(tti_rx, rnti, cc_idx, ul_cfg.pusch.grant.tb.tbs / 8, pusch_res.crc); // Logging if (log_h->get_level() >= srslte::LOG_LEVEL_INFO) { char str[512]; diff --git a/srsenb/src/stack/mac/mac.cc b/srsenb/src/stack/mac/mac.cc index 0d7cd86cb..953e3c116 100644 --- a/srsenb/src/stack/mac/mac.cc +++ b/srsenb/src/stack/mac/mac.cc @@ -323,7 +323,7 @@ int mac::crc_info(uint32_t tti_rx, uint16_t rnti, uint32_t enb_cc_idx, uint32_t return scheduler.ul_crc_info(tti_rx, rnti, enb_cc_idx, crc); } -int mac::push_pdu(uint32_t tti_rx, uint16_t rnti, const uint8_t* pdu_ptr, uint32_t nof_bytes, bool crc) +int mac::push_pdu(uint32_t tti_rx, uint16_t rnti, uint32_t enb_cc_idx, uint32_t nof_bytes, bool crc) { srslte::rwlock_read_guard lock(rwlock); @@ -331,14 +331,21 @@ int mac::push_pdu(uint32_t tti_rx, uint16_t rnti, const uint8_t* pdu_ptr, uint32 return SRSLTE_ERROR; } + std::array enb_ue_cc_map = scheduler.get_enb_ue_cc_map(rnti); + if (enb_ue_cc_map[enb_cc_idx] < 0) { + Error("User rnti=0x%x is not activated for carrier %d\n", rnti, enb_cc_idx); + return SRSLTE_ERROR; + } + uint32_t ue_cc_idx = enb_ue_cc_map[enb_cc_idx]; + // push the pdu through the queue if received correctly if (crc) { Info("Pushing PDU rnti=0x%x, tti_rx=%d, nof_bytes=%d\n", rnti, tti_rx, nof_bytes); - ue_db[rnti]->push_pdu(tti_rx, pdu_ptr, nof_bytes); + ue_db[rnti]->push_pdu(tti_rx, ue_cc_idx, nof_bytes); stack_task_queue.push([this]() { process_pdus(); }); } else { Debug("Discarting PDU rnti=0x%x, tti_rx=%d, nof_bytes=%d\n", rnti, tti_rx, nof_bytes); - ue_db[rnti]->deallocate_pdu(tti_rx, pdu_ptr); + ue_db[rnti]->deallocate_pdu(tti_rx, ue_cc_idx); } return SRSLTE_SUCCESS; } @@ -906,7 +913,8 @@ int mac::get_ul_sched(uint32_t tti_tx_ul, ul_sched_list_t& ul_sched_res_list) if (sched_result.pusch[n].current_tx_nb == 0) { srslte_softbuffer_rx_reset_tbs(phy_ul_sched_res->pusch[n].softbuffer_rx, sched_result.pusch[i].tbs * 8); } - phy_ul_sched_res->pusch[n].data = ue_db[rnti]->request_buffer(tti_tx_ul, sched_result.pusch[i].tbs); + phy_ul_sched_res->pusch[n].data = + ue_db[rnti]->request_buffer(tti_tx_ul, sched_result.pusch[i].dci.ue_cc_idx, sched_result.pusch[i].tbs); if (phy_ul_sched_res->pusch[n].data) { phy_ul_sched_res->nof_grants++; } else { diff --git a/srsenb/src/stack/mac/ue.cc b/srsenb/src/stack/mac/ue.cc index 41ccc9425..092a08c4a 100644 --- a/srsenb/src/stack/mac/ue.cc +++ b/srsenb/src/stack/mac/ue.cc @@ -44,6 +44,7 @@ ue::ue(uint16_t rnti_, pdus(128), nof_rx_harq_proc(nof_rx_harq_proc_), nof_tx_harq_proc(nof_tx_harq_proc_), + rx_used_buffers(nof_cells_), ta_fsm(this) { srslte::byte_buffer_pool* pool = srslte::byte_buffer_pool::get_instance(); @@ -94,6 +95,15 @@ void ue::reset() srslte_softbuffer_tx_reset(&buffer); } } + + for (auto& rx_buffers_cc : rx_used_buffers) { + for (auto& ptr : rx_buffers_cc) { + if (ptr) { + pdus.deallocate(ptr); + ptr = nullptr; + } + } + } } /** @@ -161,19 +171,19 @@ ue::get_tx_softbuffer(const uint32_t ue_cc_idx, const uint32_t harq_process, con return &softbuffer_tx.at(ue_cc_idx).at((harq_process * SRSLTE_MAX_TB + tb_idx) % nof_tx_harq_proc); } -uint8_t* ue::request_buffer(uint32_t tti, const uint32_t len) +uint8_t* ue::request_buffer(uint32_t tti, uint32_t cc_idx, const uint32_t len) { uint8_t* pdu = nullptr; if (len > 0) { pdu = pdus.request(len); if (pdu) { // Deallocate oldest buffer if we didn't deallocate it - if (rx_used_buffers[tti] != nullptr) { - pdus.deallocate(rx_used_buffers[tti]); - rx_used_buffers[tti] = nullptr; + if (rx_used_buffers.at(cc_idx)[tti] != nullptr) { + pdus.deallocate(rx_used_buffers.at(cc_idx)[tti]); + rx_used_buffers.at(cc_idx)[tti] = nullptr; log_h->warning("buffers: RX PDU of rnti=0x%x and pid=%d wasn't deallocated\n", rnti, tti % nof_rx_harq_proc); } - rx_used_buffers[tti] = pdu; + rx_used_buffers.at(cc_idx)[tti] = pdu; log_h->info("RX PDU saved for pid=%d\n", tti % nof_rx_harq_proc); } else { log_h->error("buffers: Requesting buffer from pool\n"); @@ -306,35 +316,33 @@ void ue::process_pdu(uint8_t* pdu, uint32_t nof_bytes, srslte::pdu_queue::channe Debug("MAC PDU processed\n"); } -void ue::deallocate_pdu(uint32_t tti, const uint8_t* pdu_ptr) +void ue::deallocate_pdu(uint32_t tti, uint32_t cc_idx) { - if (pdu_ptr) { - if (rx_used_buffers[tti] == pdu_ptr) { - rx_used_buffers[tti] = nullptr; - } else { - Warning("buffers: Unexpected RX PDU pointer in deallocate_pdu for rnti=0x%x pid=%d\n", rnti, tti % nof_rx_harq_proc); - } - pdus.deallocate(pdu_ptr); + if (rx_used_buffers.at(cc_idx)[tti] != nullptr) { + pdus.deallocate(rx_used_buffers.at(cc_idx)[tti]); + rx_used_buffers.at(cc_idx)[tti] = nullptr; } else { - Error("Error deallocating PDU: null ptr\n"); + Warning("buffers: Null RX PDU pointer in deallocate_pdu for rnti=0x%x pid=%d cc_idx=%d\n", + rnti, + tti % nof_rx_harq_proc, + cc_idx); } } -void ue::push_pdu(uint32_t tti, const uint8_t* pdu_ptr, uint32_t len) +void ue::push_pdu(uint32_t tti, uint32_t cc_idx, uint32_t len) { - if (pdu_ptr) { - if (rx_used_buffers[tti] == pdu_ptr) { - rx_used_buffers[tti] = nullptr; - } else { - Warning("buffers: Unexpected RX PDU pointer in push_pdu for rnti=0x%x pid=%d\n", rnti, tti % nof_rx_harq_proc); - } + if (rx_used_buffers.at(cc_idx)[tti] != nullptr) { if (len > 0) { - pdus.push(pdu_ptr, len); + pdus.push(rx_used_buffers.at(cc_idx)[tti], len); } else { Error("Error pushing PDU: null length\n"); } + rx_used_buffers.at(cc_idx)[tti] = nullptr; } else { - Error("Error pushing PDU: null pointer\n"); + Warning("buffers: Null RX PDU pointer in push_pdu for rnti=0x%x pid=%d cc_idx=%d\n", + rnti, + tti % nof_rx_harq_proc, + cc_idx); } } diff --git a/srsenb/test/phy/enb_phy_test.cc b/srsenb/test/phy/enb_phy_test.cc index eee341fe8..b6c449e6f 100644 --- a/srsenb/test/phy/enb_phy_test.cc +++ b/srsenb/test/phy/enb_phy_test.cc @@ -493,7 +493,7 @@ public: return 0; } - int push_pdu(uint32_t tti, uint16_t rnti, const uint8_t* pdu_ptr, uint32_t nof_bytes, bool crc_res) override + int push_pdu(uint32_t tti, uint16_t rnti, uint32_t cc_idx, uint32_t nof_bytes, bool crc_res) override { log_h.info("Received push_pdu tti=%d; rnti=0x%x; ack=%d;\n", tti, rnti, crc_res); notify_push_pdu(); From 7d2c1b636b79f1b8c20c463e457abb168aa6e79a Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Tue, 19 Jan 2021 15:33:11 +0100 Subject: [PATCH 4/7] Release pointer even if length is zero --- srsenb/src/stack/mac/ue.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/srsenb/src/stack/mac/ue.cc b/srsenb/src/stack/mac/ue.cc index ef1b32041..41ccc9425 100644 --- a/srsenb/src/stack/mac/ue.cc +++ b/srsenb/src/stack/mac/ue.cc @@ -322,15 +322,19 @@ void ue::deallocate_pdu(uint32_t tti, const uint8_t* pdu_ptr) void ue::push_pdu(uint32_t tti, const uint8_t* pdu_ptr, uint32_t len) { - if (pdu_ptr && len > 0) { + if (pdu_ptr) { if (rx_used_buffers[tti] == pdu_ptr) { rx_used_buffers[tti] = nullptr; } else { Warning("buffers: Unexpected RX PDU pointer in push_pdu for rnti=0x%x pid=%d\n", rnti, tti % nof_rx_harq_proc); } - pdus.push(pdu_ptr, len); + if (len > 0) { + pdus.push(pdu_ptr, len); + } else { + Error("Error pushing PDU: null length\n"); + } } else { - Error("Error pushing PDU: ptr=%p, len=%d\n", pdu_ptr, len); + Error("Error pushing PDU: null pointer\n"); } } From c1c5fa426c62005d550d498e8e958332fb45503c Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Tue, 19 Jan 2021 16:58:56 +0100 Subject: [PATCH 5/7] Fix issue with new way of managing ul buffers not working with CA --- .../srslte/interfaces/enb_interfaces.h | 4 +- srsenb/hdr/stack/enb_stack_lte.h | 4 +- srsenb/hdr/stack/mac/mac.h | 2 +- srsenb/hdr/stack/mac/ue.h | 8 +-- srsenb/src/phy/lte/cc_worker.cc | 2 +- srsenb/src/stack/mac/mac.cc | 16 ++++-- srsenb/src/stack/mac/ue.cc | 54 +++++++++++-------- srsenb/test/phy/enb_phy_test.cc | 2 +- 8 files changed, 54 insertions(+), 38 deletions(-) diff --git a/lib/include/srslte/interfaces/enb_interfaces.h b/lib/include/srslte/interfaces/enb_interfaces.h index b7945afb2..d93a84c9c 100644 --- a/lib/include/srslte/interfaces/enb_interfaces.h +++ b/lib/include/srslte/interfaces/enb_interfaces.h @@ -177,12 +177,12 @@ public: * * @param tti the given TTI * @param rnti the UE identifier in the eNb - * @param pdu_ptr pointer to the uplink buffer + * @param enb_cc_idx the eNb Cell/Carrier identifier * @param nof_bytes the number of grants carrierd by the PUSCH message * @param crc_res the CRC check, set to true if the message was decoded succesfully * @return SRSLTE_SUCCESS if no error occurs, SRSLTE_ERROR* if an error occurs */ - virtual int push_pdu(uint32_t tti_rx, uint16_t rnti, const uint8_t* pdu_ptr, uint32_t nof_bytes, bool crc_res) = 0; + virtual int push_pdu(uint32_t tti_rx, uint16_t rnti, uint32_t enb_cc_idx, uint32_t nof_bytes, bool crc_res) = 0; virtual int get_dl_sched(uint32_t tti, dl_sched_list_t& dl_sched_res) = 0; virtual int get_mch_sched(uint32_t tti, bool is_mcch, dl_sched_list_t& dl_sched_res) = 0; diff --git a/srsenb/hdr/stack/enb_stack_lte.h b/srsenb/hdr/stack/enb_stack_lte.h index 8929bbfc6..62d96cc68 100644 --- a/srsenb/hdr/stack/enb_stack_lte.h +++ b/srsenb/hdr/stack/enb_stack_lte.h @@ -80,9 +80,9 @@ public: { return mac.crc_info(tti, rnti, enb_cc_idx, nof_bytes, crc_res); } - int push_pdu(uint32_t tti, uint16_t rnti, const uint8_t* pdu_ptr, uint32_t nof_bytes, bool crc_res) final + int push_pdu(uint32_t tti, uint16_t rnti, uint32_t enb_cc_idx, uint32_t nof_bytes, bool crc_res) final { - return mac.push_pdu(tti, rnti, pdu_ptr, nof_bytes, crc_res); + return mac.push_pdu(tti, rnti, enb_cc_idx, nof_bytes, crc_res); } int get_dl_sched(uint32_t tti, dl_sched_list_t& dl_sched_res) final { return mac.get_dl_sched(tti, dl_sched_res); } int get_mch_sched(uint32_t tti, bool is_mcch, dl_sched_list_t& dl_sched_res) final diff --git a/srsenb/hdr/stack/mac/mac.h b/srsenb/hdr/stack/mac/mac.h index 6f6a72a08..0aa6c1832 100644 --- a/srsenb/hdr/stack/mac/mac.h +++ b/srsenb/hdr/stack/mac/mac.h @@ -56,7 +56,7 @@ public: int ta_info(uint32_t tti, uint16_t rnti, float ta_us) override; int ack_info(uint32_t tti, uint16_t rnti, uint32_t enb_cc_idx, uint32_t tb_idx, bool ack) override; int crc_info(uint32_t tti, uint16_t rnti, uint32_t enb_cc_idx, uint32_t nof_bytes, bool crc_res) override; - int push_pdu(uint32_t tti, uint16_t rnti, const uint8_t* pdu_ptr, uint32_t nof_bytes, bool crc_res) override; + int push_pdu(uint32_t tti, uint16_t rnti, uint32_t enb_cc_idx, uint32_t nof_bytes, bool crc_res) override; int get_dl_sched(uint32_t tti_tx_dl, dl_sched_list_t& dl_sched_res) override; int get_ul_sched(uint32_t tti_tx_ul, ul_sched_list_t& ul_sched_res) override; diff --git a/srsenb/hdr/stack/mac/ue.h b/srsenb/hdr/stack/mac/ue.h index 3dde41198..6eae19f1f 100644 --- a/srsenb/hdr/stack/mac/ue.h +++ b/srsenb/hdr/stack/mac/ue.h @@ -72,10 +72,10 @@ public: srslte_softbuffer_rx_t* get_rx_softbuffer(const uint32_t ue_cc_idx, const uint32_t tti); bool process_pdus(); - uint8_t* request_buffer(uint32_t tti, const uint32_t len); + uint8_t* request_buffer(uint32_t tti, uint32_t ue_cc_idx, const uint32_t len); void process_pdu(uint8_t* pdu, uint32_t nof_bytes, srslte::pdu_queue::channel_t channel) override; - void push_pdu(uint32_t tti, const uint8_t* pdu_ptr, uint32_t len); - void deallocate_pdu(uint32_t tti, const uint8_t* pdu_ptr); + void push_pdu(uint32_t tti, uint32_t ue_cc_idx, uint32_t len); + void deallocate_pdu(uint32_t tti, uint32_t ue_cc_idx); void metrics_read(mac_ue_metrics_t* metrics_); void metrics_rx(bool crc, uint32_t tbs); @@ -124,7 +124,7 @@ private: tx_payload_buffer; // Save 2 buffers per HARQ process - srslte::circular_array rx_used_buffers; + std::vector > rx_used_buffers; srslte::block_queue pending_ta_commands; ta ta_fsm; diff --git a/srsenb/src/phy/lte/cc_worker.cc b/srsenb/src/phy/lte/cc_worker.cc index 0c568d39b..1d04fd282 100644 --- a/srsenb/src/phy/lte/cc_worker.cc +++ b/srsenb/src/phy/lte/cc_worker.cc @@ -374,7 +374,7 @@ void cc_worker::decode_pusch(stack_interface_phy_lte::ul_sched_grant_t* grants, // Inform MAC about the CRC result phy->stack->crc_info(tti_rx, rnti, cc_idx, ul_cfg.pusch.grant.tb.tbs / 8, pusch_res.crc); // Push PDU buffer - phy->stack->push_pdu(tti_rx, rnti, grants[i].data, ul_cfg.pusch.grant.tb.tbs / 8, pusch_res.crc); + phy->stack->push_pdu(tti_rx, rnti, cc_idx, ul_cfg.pusch.grant.tb.tbs / 8, pusch_res.crc); // Logging if (log_h->get_level() >= srslte::LOG_LEVEL_INFO) { char str[512]; diff --git a/srsenb/src/stack/mac/mac.cc b/srsenb/src/stack/mac/mac.cc index 0d7cd86cb..953e3c116 100644 --- a/srsenb/src/stack/mac/mac.cc +++ b/srsenb/src/stack/mac/mac.cc @@ -323,7 +323,7 @@ int mac::crc_info(uint32_t tti_rx, uint16_t rnti, uint32_t enb_cc_idx, uint32_t return scheduler.ul_crc_info(tti_rx, rnti, enb_cc_idx, crc); } -int mac::push_pdu(uint32_t tti_rx, uint16_t rnti, const uint8_t* pdu_ptr, uint32_t nof_bytes, bool crc) +int mac::push_pdu(uint32_t tti_rx, uint16_t rnti, uint32_t enb_cc_idx, uint32_t nof_bytes, bool crc) { srslte::rwlock_read_guard lock(rwlock); @@ -331,14 +331,21 @@ int mac::push_pdu(uint32_t tti_rx, uint16_t rnti, const uint8_t* pdu_ptr, uint32 return SRSLTE_ERROR; } + std::array enb_ue_cc_map = scheduler.get_enb_ue_cc_map(rnti); + if (enb_ue_cc_map[enb_cc_idx] < 0) { + Error("User rnti=0x%x is not activated for carrier %d\n", rnti, enb_cc_idx); + return SRSLTE_ERROR; + } + uint32_t ue_cc_idx = enb_ue_cc_map[enb_cc_idx]; + // push the pdu through the queue if received correctly if (crc) { Info("Pushing PDU rnti=0x%x, tti_rx=%d, nof_bytes=%d\n", rnti, tti_rx, nof_bytes); - ue_db[rnti]->push_pdu(tti_rx, pdu_ptr, nof_bytes); + ue_db[rnti]->push_pdu(tti_rx, ue_cc_idx, nof_bytes); stack_task_queue.push([this]() { process_pdus(); }); } else { Debug("Discarting PDU rnti=0x%x, tti_rx=%d, nof_bytes=%d\n", rnti, tti_rx, nof_bytes); - ue_db[rnti]->deallocate_pdu(tti_rx, pdu_ptr); + ue_db[rnti]->deallocate_pdu(tti_rx, ue_cc_idx); } return SRSLTE_SUCCESS; } @@ -906,7 +913,8 @@ int mac::get_ul_sched(uint32_t tti_tx_ul, ul_sched_list_t& ul_sched_res_list) if (sched_result.pusch[n].current_tx_nb == 0) { srslte_softbuffer_rx_reset_tbs(phy_ul_sched_res->pusch[n].softbuffer_rx, sched_result.pusch[i].tbs * 8); } - phy_ul_sched_res->pusch[n].data = ue_db[rnti]->request_buffer(tti_tx_ul, sched_result.pusch[i].tbs); + phy_ul_sched_res->pusch[n].data = + ue_db[rnti]->request_buffer(tti_tx_ul, sched_result.pusch[i].dci.ue_cc_idx, sched_result.pusch[i].tbs); if (phy_ul_sched_res->pusch[n].data) { phy_ul_sched_res->nof_grants++; } else { diff --git a/srsenb/src/stack/mac/ue.cc b/srsenb/src/stack/mac/ue.cc index 41ccc9425..092a08c4a 100644 --- a/srsenb/src/stack/mac/ue.cc +++ b/srsenb/src/stack/mac/ue.cc @@ -44,6 +44,7 @@ ue::ue(uint16_t rnti_, pdus(128), nof_rx_harq_proc(nof_rx_harq_proc_), nof_tx_harq_proc(nof_tx_harq_proc_), + rx_used_buffers(nof_cells_), ta_fsm(this) { srslte::byte_buffer_pool* pool = srslte::byte_buffer_pool::get_instance(); @@ -94,6 +95,15 @@ void ue::reset() srslte_softbuffer_tx_reset(&buffer); } } + + for (auto& rx_buffers_cc : rx_used_buffers) { + for (auto& ptr : rx_buffers_cc) { + if (ptr) { + pdus.deallocate(ptr); + ptr = nullptr; + } + } + } } /** @@ -161,19 +171,19 @@ ue::get_tx_softbuffer(const uint32_t ue_cc_idx, const uint32_t harq_process, con return &softbuffer_tx.at(ue_cc_idx).at((harq_process * SRSLTE_MAX_TB + tb_idx) % nof_tx_harq_proc); } -uint8_t* ue::request_buffer(uint32_t tti, const uint32_t len) +uint8_t* ue::request_buffer(uint32_t tti, uint32_t cc_idx, const uint32_t len) { uint8_t* pdu = nullptr; if (len > 0) { pdu = pdus.request(len); if (pdu) { // Deallocate oldest buffer if we didn't deallocate it - if (rx_used_buffers[tti] != nullptr) { - pdus.deallocate(rx_used_buffers[tti]); - rx_used_buffers[tti] = nullptr; + if (rx_used_buffers.at(cc_idx)[tti] != nullptr) { + pdus.deallocate(rx_used_buffers.at(cc_idx)[tti]); + rx_used_buffers.at(cc_idx)[tti] = nullptr; log_h->warning("buffers: RX PDU of rnti=0x%x and pid=%d wasn't deallocated\n", rnti, tti % nof_rx_harq_proc); } - rx_used_buffers[tti] = pdu; + rx_used_buffers.at(cc_idx)[tti] = pdu; log_h->info("RX PDU saved for pid=%d\n", tti % nof_rx_harq_proc); } else { log_h->error("buffers: Requesting buffer from pool\n"); @@ -306,35 +316,33 @@ void ue::process_pdu(uint8_t* pdu, uint32_t nof_bytes, srslte::pdu_queue::channe Debug("MAC PDU processed\n"); } -void ue::deallocate_pdu(uint32_t tti, const uint8_t* pdu_ptr) +void ue::deallocate_pdu(uint32_t tti, uint32_t cc_idx) { - if (pdu_ptr) { - if (rx_used_buffers[tti] == pdu_ptr) { - rx_used_buffers[tti] = nullptr; - } else { - Warning("buffers: Unexpected RX PDU pointer in deallocate_pdu for rnti=0x%x pid=%d\n", rnti, tti % nof_rx_harq_proc); - } - pdus.deallocate(pdu_ptr); + if (rx_used_buffers.at(cc_idx)[tti] != nullptr) { + pdus.deallocate(rx_used_buffers.at(cc_idx)[tti]); + rx_used_buffers.at(cc_idx)[tti] = nullptr; } else { - Error("Error deallocating PDU: null ptr\n"); + Warning("buffers: Null RX PDU pointer in deallocate_pdu for rnti=0x%x pid=%d cc_idx=%d\n", + rnti, + tti % nof_rx_harq_proc, + cc_idx); } } -void ue::push_pdu(uint32_t tti, const uint8_t* pdu_ptr, uint32_t len) +void ue::push_pdu(uint32_t tti, uint32_t cc_idx, uint32_t len) { - if (pdu_ptr) { - if (rx_used_buffers[tti] == pdu_ptr) { - rx_used_buffers[tti] = nullptr; - } else { - Warning("buffers: Unexpected RX PDU pointer in push_pdu for rnti=0x%x pid=%d\n", rnti, tti % nof_rx_harq_proc); - } + if (rx_used_buffers.at(cc_idx)[tti] != nullptr) { if (len > 0) { - pdus.push(pdu_ptr, len); + pdus.push(rx_used_buffers.at(cc_idx)[tti], len); } else { Error("Error pushing PDU: null length\n"); } + rx_used_buffers.at(cc_idx)[tti] = nullptr; } else { - Error("Error pushing PDU: null pointer\n"); + Warning("buffers: Null RX PDU pointer in push_pdu for rnti=0x%x pid=%d cc_idx=%d\n", + rnti, + tti % nof_rx_harq_proc, + cc_idx); } } diff --git a/srsenb/test/phy/enb_phy_test.cc b/srsenb/test/phy/enb_phy_test.cc index eee341fe8..b6c449e6f 100644 --- a/srsenb/test/phy/enb_phy_test.cc +++ b/srsenb/test/phy/enb_phy_test.cc @@ -493,7 +493,7 @@ public: return 0; } - int push_pdu(uint32_t tti, uint16_t rnti, const uint8_t* pdu_ptr, uint32_t nof_bytes, bool crc_res) override + int push_pdu(uint32_t tti, uint16_t rnti, uint32_t cc_idx, uint32_t nof_bytes, bool crc_res) override { log_h.info("Received push_pdu tti=%d; rnti=0x%x; ack=%d;\n", tti, rnti, crc_res); notify_push_pdu(); From 44e411be2b682466d1c8f5c6184018bb858aca0e Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Wed, 20 Jan 2021 17:46:16 +0100 Subject: [PATCH 6/7] Track UL buffers per TTI instead of per PID and remove old ones periodically --- srsenb/hdr/stack/mac/ue.h | 4 +-- srsenb/src/stack/mac/mac.cc | 4 +++ srsenb/src/stack/mac/ue.cc | 67 +++++++++++++++++++++---------------- 3 files changed, 45 insertions(+), 30 deletions(-) diff --git a/srsenb/hdr/stack/mac/ue.h b/srsenb/hdr/stack/mac/ue.h index 6eae19f1f..120418d75 100644 --- a/srsenb/hdr/stack/mac/ue.h +++ b/srsenb/hdr/stack/mac/ue.h @@ -76,6 +76,7 @@ public: void process_pdu(uint8_t* pdu, uint32_t nof_bytes, srslte::pdu_queue::channel_t channel) override; void push_pdu(uint32_t tti, uint32_t ue_cc_idx, uint32_t len); void deallocate_pdu(uint32_t tti, uint32_t ue_cc_idx); + void clear_old_buffers(uint32_t tti); void metrics_read(mac_ue_metrics_t* metrics_); void metrics_rx(bool crc, uint32_t tbs); @@ -123,8 +124,7 @@ private: std::vector, SRSLTE_FDD_NOF_HARQ> > tx_payload_buffer; - // Save 2 buffers per HARQ process - std::vector > rx_used_buffers; + std::vector > rx_used_buffers; srslte::block_queue pending_ta_commands; ta ta_fsm; diff --git a/srsenb/src/stack/mac/mac.cc b/srsenb/src/stack/mac/mac.cc index 953e3c116..c136a81aa 100644 --- a/srsenb/src/stack/mac/mac.cc +++ b/srsenb/src/stack/mac/mac.cc @@ -940,6 +940,10 @@ int mac::get_ul_sched(uint32_t tti_tx_ul, ul_sched_list_t& ul_sched_res_list) } phy_ul_sched_res->nof_phich = sched_result.nof_phich_elems; } + // clear old buffers from all users + for (auto& u : ue_db) { + u.second->clear_old_buffers(tti_tx_ul); + } return SRSLTE_SUCCESS; } diff --git a/srsenb/src/stack/mac/ue.cc b/srsenb/src/stack/mac/ue.cc index 092a08c4a..c7fa6aa7a 100644 --- a/srsenb/src/stack/mac/ue.cc +++ b/srsenb/src/stack/mac/ue.cc @@ -77,6 +77,12 @@ ue::~ue() srslte_softbuffer_tx_free(&buffer); } } + for (auto& rx_buffers_cc : rx_used_buffers) { + for (auto& q : rx_buffers_cc) { + pdus.deallocate(q.second); + } + rx_buffers_cc.clear(); + } } void ue::reset() @@ -95,15 +101,6 @@ void ue::reset() srslte_softbuffer_tx_reset(&buffer); } } - - for (auto& rx_buffers_cc : rx_used_buffers) { - for (auto& ptr : rx_buffers_cc) { - if (ptr) { - pdus.deallocate(ptr); - ptr = nullptr; - } - } - } } /** @@ -175,25 +172,39 @@ uint8_t* ue::request_buffer(uint32_t tti, uint32_t cc_idx, const uint32_t len) { uint8_t* pdu = nullptr; if (len > 0) { - pdu = pdus.request(len); - if (pdu) { - // Deallocate oldest buffer if we didn't deallocate it - if (rx_used_buffers.at(cc_idx)[tti] != nullptr) { - pdus.deallocate(rx_used_buffers.at(cc_idx)[tti]); - rx_used_buffers.at(cc_idx)[tti] = nullptr; - log_h->warning("buffers: RX PDU of rnti=0x%x and pid=%d wasn't deallocated\n", rnti, tti % nof_rx_harq_proc); + // Deallocate oldest buffer if we didn't deallocate it + if (!rx_used_buffers.at(cc_idx).count(tti)) { + pdu = pdus.request(len); + if (pdu) { + rx_used_buffers.at(cc_idx).emplace(tti, pdu); + } else { + Error("UE buffers: Requesting buffer from pool\n"); } - rx_used_buffers.at(cc_idx)[tti] = pdu; - log_h->info("RX PDU saved for pid=%d\n", tti % nof_rx_harq_proc); } else { - log_h->error("buffers: Requesting buffer from pool\n"); + Error("UE buffers: buffer for tti=%d already allocated\n", tti); } } else { - printf("buffers: Requesting buffer for zero bytes\n"); + Error("UE buffers: Requesting buffer for zero bytes\n"); } return pdu; } +void ue::clear_old_buffers(uint32_t tti) +{ + // remove old buffers + for (auto& rx_buffer_cc : rx_used_buffers) { + for (auto it = rx_buffer_cc.begin(); it != rx_buffer_cc.end();) { + if (srslte_tti_interval(tti, it->first) > 20) { + Warning("UE buffers: Removing old buffer tti=%d, rnti=%d, now is %d\n", it->first, rnti, tti); + pdus.deallocate(it->second); + it = rx_buffer_cc.erase(it); + } else { + ++it; + } + } + } +} + bool ue::process_pdus() { return pdus.process_pdus(); @@ -318,11 +329,11 @@ void ue::process_pdu(uint8_t* pdu, uint32_t nof_bytes, srslte::pdu_queue::channe void ue::deallocate_pdu(uint32_t tti, uint32_t cc_idx) { - if (rx_used_buffers.at(cc_idx)[tti] != nullptr) { - pdus.deallocate(rx_used_buffers.at(cc_idx)[tti]); - rx_used_buffers.at(cc_idx)[tti] = nullptr; + if (rx_used_buffers.at(cc_idx).count(tti)) { + pdus.deallocate(rx_used_buffers.at(cc_idx).at(tti)); + rx_used_buffers.at(cc_idx).erase(tti); } else { - Warning("buffers: Null RX PDU pointer in deallocate_pdu for rnti=0x%x pid=%d cc_idx=%d\n", + Warning("UE buffers: Null RX PDU pointer in deallocate_pdu for rnti=0x%x pid=%d cc_idx=%d\n", rnti, tti % nof_rx_harq_proc, cc_idx); @@ -331,15 +342,15 @@ void ue::deallocate_pdu(uint32_t tti, uint32_t cc_idx) void ue::push_pdu(uint32_t tti, uint32_t cc_idx, uint32_t len) { - if (rx_used_buffers.at(cc_idx)[tti] != nullptr) { + if (rx_used_buffers.at(cc_idx).count(tti)) { if (len > 0) { - pdus.push(rx_used_buffers.at(cc_idx)[tti], len); + pdus.push(rx_used_buffers.at(cc_idx).at(tti), len); } else { Error("Error pushing PDU: null length\n"); } - rx_used_buffers.at(cc_idx)[tti] = nullptr; + rx_used_buffers.at(cc_idx).erase(tti); } else { - Warning("buffers: Null RX PDU pointer in push_pdu for rnti=0x%x pid=%d cc_idx=%d\n", + Warning("UE buffers: Null RX PDU pointer in push_pdu for rnti=0x%x pid=%d cc_idx=%d\n", rnti, tti % nof_rx_harq_proc, cc_idx); From 8c85ddea0f67087e1bc282894f85280c6b3d0d27 Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Wed, 20 Jan 2021 18:10:49 +0100 Subject: [PATCH 7/7] Fix ue_cc_idx naming convention --- srsenb/src/stack/mac/ue.cc | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/srsenb/src/stack/mac/ue.cc b/srsenb/src/stack/mac/ue.cc index c7fa6aa7a..477d1543b 100644 --- a/srsenb/src/stack/mac/ue.cc +++ b/srsenb/src/stack/mac/ue.cc @@ -168,15 +168,15 @@ ue::get_tx_softbuffer(const uint32_t ue_cc_idx, const uint32_t harq_process, con return &softbuffer_tx.at(ue_cc_idx).at((harq_process * SRSLTE_MAX_TB + tb_idx) % nof_tx_harq_proc); } -uint8_t* ue::request_buffer(uint32_t tti, uint32_t cc_idx, const uint32_t len) +uint8_t* ue::request_buffer(uint32_t tti, uint32_t ue_cc_idx, const uint32_t len) { uint8_t* pdu = nullptr; if (len > 0) { // Deallocate oldest buffer if we didn't deallocate it - if (!rx_used_buffers.at(cc_idx).count(tti)) { + if (!rx_used_buffers.at(ue_cc_idx).count(tti)) { pdu = pdus.request(len); if (pdu) { - rx_used_buffers.at(cc_idx).emplace(tti, pdu); + rx_used_buffers.at(ue_cc_idx).emplace(tti, pdu); } else { Error("UE buffers: Requesting buffer from pool\n"); } @@ -327,33 +327,33 @@ void ue::process_pdu(uint8_t* pdu, uint32_t nof_bytes, srslte::pdu_queue::channe Debug("MAC PDU processed\n"); } -void ue::deallocate_pdu(uint32_t tti, uint32_t cc_idx) +void ue::deallocate_pdu(uint32_t tti, uint32_t ue_cc_idx) { - if (rx_used_buffers.at(cc_idx).count(tti)) { - pdus.deallocate(rx_used_buffers.at(cc_idx).at(tti)); - rx_used_buffers.at(cc_idx).erase(tti); + if (rx_used_buffers.at(ue_cc_idx).count(tti)) { + pdus.deallocate(rx_used_buffers.at(ue_cc_idx).at(tti)); + rx_used_buffers.at(ue_cc_idx).erase(tti); } else { Warning("UE buffers: Null RX PDU pointer in deallocate_pdu for rnti=0x%x pid=%d cc_idx=%d\n", rnti, tti % nof_rx_harq_proc, - cc_idx); + ue_cc_idx); } } -void ue::push_pdu(uint32_t tti, uint32_t cc_idx, uint32_t len) +void ue::push_pdu(uint32_t tti, uint32_t ue_cc_idx, uint32_t len) { - if (rx_used_buffers.at(cc_idx).count(tti)) { + if (rx_used_buffers.at(ue_cc_idx).count(tti)) { if (len > 0) { - pdus.push(rx_used_buffers.at(cc_idx).at(tti), len); + pdus.push(rx_used_buffers.at(ue_cc_idx).at(tti), len); } else { Error("Error pushing PDU: null length\n"); } - rx_used_buffers.at(cc_idx).erase(tti); + rx_used_buffers.at(ue_cc_idx).erase(tti); } else { Warning("UE buffers: Null RX PDU pointer in push_pdu for rnti=0x%x pid=%d cc_idx=%d\n", rnti, tti % nof_rx_harq_proc, - cc_idx); + ue_cc_idx); } }