From a2866f661b79b49b9938c4c0e3914edeed4832ac Mon Sep 17 00:00:00 2001 From: Francisco Paisana Date: Mon, 23 Mar 2020 13:05:58 +0000 Subject: [PATCH] made the number of ue payload allocations proportional to number of active carriers. Made mac::ue_db use unique_ptrs --- srsenb/hdr/stack/mac/mac.h | 4 ++-- srsenb/hdr/stack/mac/ue.h | 8 ++++---- srsenb/src/stack/mac/mac.cc | 13 ++++++------- srsenb/src/stack/mac/ue.cc | 2 ++ 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/srsenb/hdr/stack/mac/mac.h b/srsenb/hdr/stack/mac/mac.h index 796b6aa24..994352fe9 100644 --- a/srsenb/hdr/stack/mac/mac.h +++ b/srsenb/hdr/stack/mac/mac.h @@ -130,8 +130,8 @@ private: sched_interface::dl_pdu_mch_t mch = {}; /* Map of active UEs */ - std::map ue_db; - uint16_t last_rnti = 0; + std::map > ue_db; + uint16_t last_rnti = 0; uint8_t* assemble_rar(sched_interface::dl_sched_rar_grant_t* grants, uint32_t nof_grants, diff --git a/srsenb/hdr/stack/mac/ue.h b/srsenb/hdr/stack/mac/ue.h index f91087bd3..7074313bb 100644 --- a/srsenb/hdr/stack/mac/ue.h +++ b/srsenb/hdr/stack/mac/ue.h @@ -46,6 +46,7 @@ public: rlc_interface_mac* rlc, phy_interface_stack_lte* phy_, srslte::log_ref log_, + uint32_t nof_cells_, uint32_t nof_rx_harq_proc = SRSLTE_FDD_NOF_HARQ, uint32_t nof_tx_harq_proc = SRSLTE_FDD_NOF_HARQ * SRSLTE_MAX_TB); virtual ~ue(); @@ -101,7 +102,7 @@ public: void metrics_cnt(); bool is_phy_added = false; - int read_pdu(uint32_t lcid, uint8_t* payload, uint32_t requested_bytes); + int read_pdu(uint32_t lcid, uint8_t* payload, uint32_t requested_bytes) final; private: uint32_t allocate_cc_buffers(const uint32_t num_cc = 1); ///< Add and initialize softbuffers for CC @@ -138,9 +139,8 @@ private: typedef std::vector cc_buffer_ptr_t; ///< List of buffer pointers for RX HARQ processes of one carrier std::vector pending_buffers; ///< List of buffer pointer list for Rx - // For DL there are two buffers, one for each Transport block - std::array, SRSLTE_FDD_NOF_HARQ>, - SRSLTE_MAX_CARRIERS> + // One buffer per TB per HARQ process and per carrier is needed for each UE. + std::vector, SRSLTE_FDD_NOF_HARQ> > tx_payload_buffer; srslte::block_queue pending_ta_commands; diff --git a/srsenb/src/stack/mac/mac.cc b/srsenb/src/stack/mac/mac.cc index e038a7fa3..9110fccea 100644 --- a/srsenb/src/stack/mac/mac.cc +++ b/srsenb/src/stack/mac/mac.cc @@ -100,9 +100,7 @@ void mac::stop() { srslte::rwlock_write_guard lock(rwlock); if (started) { - for (uint32_t i = 0; i < ue_db.size(); i++) { - delete ue_db[i]; - } + ue_db.clear(); for (int i = 0; i < NOF_BCCH_DLSCH_MSG; i++) { srslte_softbuffer_tx_free(&bcch_softbuffer_tx[i]); } @@ -200,7 +198,7 @@ int mac::ue_cfg(uint16_t rnti, sched_interface::ue_cfg_t* cfg) Error("User rnti=0x%x not found\n", rnti); return SRSLTE_ERROR; } - ue_ptr = it->second; + ue_ptr = it->second.get(); // Add RNTI to the PHY (pregenerate signals) now instead of after PRACH if (not ue_ptr->is_phy_added) { @@ -240,7 +238,6 @@ int mac::ue_rem(uint16_t rnti) } srslte::rwlock_write_guard lock(rwlock); if (ue_db.count(rnti)) { - delete ue_db[rnti]; ue_db.erase(rnti); Info("User rnti=0x%x removed from MAC/PHY\n", rnti); } else { @@ -457,7 +454,8 @@ void mac::rach_detected(uint32_t tti, uint32_t enb_cc_idx, uint32_t preamble_idx // Create new UE if (ue_db.count(rnti) == 0) { - ue_db[rnti] = new ue(rnti, args.nof_prb, &scheduler, rrc_h, rlc_h, phy_h, log_h, SRSLTE_FDD_NOF_HARQ); + ue_db[rnti] = + std::unique_ptr{new ue(rnti, args.nof_prb, &scheduler, rrc_h, rlc_h, phy_h, log_h, cells.size())}; } // Set PCAP if available @@ -884,7 +882,8 @@ void mac::write_mcch(sib_type2_s* sib2_, sib_type13_r9_s* sib13_, mcch_msg_s* mc mcch.pack(bref); current_mcch_length = bref.distance_bytes(&mcch_payload_buffer[1]); current_mcch_length = current_mcch_length + rlc_header_len; - ue_db[SRSLTE_MRNTI] = new ue(SRSLTE_MRNTI, args.nof_prb, &scheduler, rrc_h, rlc_h, phy_h, log_h); + ue_db[SRSLTE_MRNTI] = + std::unique_ptr{new ue(SRSLTE_MRNTI, args.nof_prb, &scheduler, rrc_h, rlc_h, phy_h, log_h, cells.size())}; rrc_h->add_user(SRSLTE_MRNTI, {}); } diff --git a/srsenb/src/stack/mac/ue.cc b/srsenb/src/stack/mac/ue.cc index 3acad9cfd..b11998ba6 100644 --- a/srsenb/src/stack/mac/ue.cc +++ b/srsenb/src/stack/mac/ue.cc @@ -41,6 +41,7 @@ ue::ue(uint16_t rnti_, rlc_interface_mac* rlc_, phy_interface_stack_lte* phy_, srslte::log_ref log_, + uint32_t nof_cells_, uint32_t nof_rx_harq_proc_, uint32_t nof_tx_harq_proc_) : rnti(rnti_), @@ -59,6 +60,7 @@ ue::ue(uint16_t rnti_, ta_fsm(this) { srslte::byte_buffer_pool* pool = srslte::byte_buffer_pool::get_instance(); + tx_payload_buffer.resize(nof_cells_); for (auto& carrier_buffers : tx_payload_buffer) { for (auto& harq_buffers : carrier_buffers) { for (srslte::unique_byte_buffer_t& tb_buffer : harq_buffers) {