From 858165f177ed89aa54a68e8ff97fcd0373aac5e7 Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Mon, 16 Mar 2020 13:35:03 +0100 Subject: [PATCH] Allocate a different PDU buffer for each carrier in MAC eNodeB (#1069) --- srsenb/hdr/stack/mac/ue.h | 10 ++++++---- srsenb/src/stack/mac/mac.cc | 3 ++- srsenb/src/stack/mac/ue.cc | 37 ++++++++++++++++++++++--------------- 3 files changed, 30 insertions(+), 20 deletions(-) diff --git a/srsenb/hdr/stack/mac/ue.h b/srsenb/hdr/stack/mac/ue.h index 28cf45b70..874d5cef9 100644 --- a/srsenb/hdr/stack/mac/ue.h +++ b/srsenb/hdr/stack/mac/ue.h @@ -63,7 +63,8 @@ public: rrc_interface_mac* rrc_, rlc_interface_mac* rlc, srslte::log* log_h); - uint8_t* generate_pdu(uint32_t harq_pid, + uint8_t* generate_pdu(uint32_t ue_cc_idx, + uint32_t harq_pid, uint32_t tb_idx, sched_interface::dl_sched_pdu_t pdu[sched_interface::MAX_RLC_PDU_LIST], uint32_t nof_pdu_elems, @@ -71,8 +72,9 @@ public: uint8_t* generate_mch_pdu(uint32_t harq_pid, sched_interface::dl_pdu_mch_t sched, uint32_t nof_pdu_elems, uint32_t grant_size); - srslte_softbuffer_tx_t* get_tx_softbuffer(const uint32_t cc_idx, const uint32_t harq_process, const uint32_t tb_idx); - srslte_softbuffer_rx_t* get_rx_softbuffer(const uint32_t cc_idx, const uint32_t tti); + srslte_softbuffer_tx_t* + get_tx_softbuffer(const uint32_t ue_cc_idx, const uint32_t harq_process, const uint32_t tb_idx); + 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 ue_cc_idx, const uint32_t tti, const uint32_t len); @@ -132,7 +134,7 @@ private: std::vector pending_buffers; ///< List of buffer pointer list for Rx // For DL there are two buffers, one for each Transport block - srslte::byte_buffer_t tx_payload_buffer[SRSLTE_FDD_NOF_HARQ][SRSLTE_MAX_TB]; + srslte::byte_buffer_t tx_payload_buffer[SRSLTE_MAX_CARRIERS][SRSLTE_FDD_NOF_HARQ][SRSLTE_MAX_TB]; srslte::block_queue pending_ta_commands; diff --git a/srsenb/src/stack/mac/mac.cc b/srsenb/src/stack/mac/mac.cc index 0bb7108e0..9c8183525 100644 --- a/srsenb/src/stack/mac/mac.cc +++ b/srsenb/src/stack/mac/mac.cc @@ -539,7 +539,8 @@ int mac::get_dl_sched(uint32_t tti, dl_sched_list_t& dl_sched_res_list) if (sched_result.data[i].nof_pdu_elems[tb] > 0) { /* Get PDU if it's a new transmission */ - dl_sched_res->pdsch[n].data[tb] = ue_db[rnti]->generate_pdu(sched_result.data[i].dci.pid, + dl_sched_res->pdsch[n].data[tb] = ue_db[rnti]->generate_pdu(sched_result.data[i].dci.ue_cc_idx, + sched_result.data[i].dci.pid, tb, sched_result.data[i].pdu[tb], sched_result.data[i].nof_pdu_elems[tb], diff --git a/srsenb/src/stack/mac/ue.cc b/srsenb/src/stack/mac/ue.cc index 379e1332d..1176e7fb3 100644 --- a/srsenb/src/stack/mac/ue.cc +++ b/srsenb/src/stack/mac/ue.cc @@ -161,14 +161,15 @@ void ue::set_lcg(uint32_t lcid, uint32_t lcg) lc_groups[lcg].push_back(lcid); } -srslte_softbuffer_rx_t* ue::get_rx_softbuffer(const uint32_t cc_idx, const uint32_t tti) +srslte_softbuffer_rx_t* ue::get_rx_softbuffer(const uint32_t ue_cc_idx, const uint32_t tti) { - return &softbuffer_rx.at(cc_idx).at(tti % nof_rx_harq_proc); + return &softbuffer_rx.at(ue_cc_idx).at(tti % nof_rx_harq_proc); } -srslte_softbuffer_tx_t* ue::get_tx_softbuffer(const uint32_t cc_idx, const uint32_t harq_process, const uint32_t tb_idx) +srslte_softbuffer_tx_t* +ue::get_tx_softbuffer(const uint32_t ue_cc_idx, const uint32_t harq_process, const uint32_t tb_idx) { - return &softbuffer_tx.at(cc_idx).at((harq_process * SRSLTE_MAX_TB + tb_idx) % nof_tx_harq_proc); + 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 ue_cc_idx, const uint32_t tti, const uint32_t len) @@ -493,7 +494,8 @@ void ue::allocate_ce(srslte::sch_pdu* pdu, uint32_t lcid) } } -uint8_t* ue::generate_pdu(uint32_t harq_pid, +uint8_t* ue::generate_pdu(uint32_t ue_cc_idx, + uint32_t harq_pid, uint32_t tb_idx, sched_interface::dl_sched_pdu_t pdu[sched_interface::MAX_RLC_PDU_LIST], uint32_t nof_pdu_elems, @@ -502,16 +504,21 @@ uint8_t* ue::generate_pdu(uint32_t harq_pid, std::lock_guard lock(mutex); uint8_t* ret = nullptr; if (rlc) { - tx_payload_buffer[harq_pid][tb_idx].clear(); - mac_msg_dl.init_tx(&tx_payload_buffer[harq_pid][tb_idx], grant_size, false); - for (uint32_t i = 0; i < nof_pdu_elems; i++) { - if (pdu[i].lcid <= srslte::sch_subh::PHR_REPORT) { - allocate_sdu(&mac_msg_dl, pdu[i].lcid, pdu[i].nbytes); - } else { - allocate_ce(&mac_msg_dl, pdu[i].lcid); + if (ue_cc_idx < SRSLTE_MAX_CARRIERS && harq_pid < SRSLTE_FDD_NOF_HARQ && tb_idx < SRSLTE_MAX_TB) { + tx_payload_buffer[ue_cc_idx][harq_pid][tb_idx].clear(); + mac_msg_dl.init_tx(&tx_payload_buffer[ue_cc_idx][harq_pid][tb_idx], grant_size, false); + for (uint32_t i = 0; i < nof_pdu_elems; i++) { + if (pdu[i].lcid <= srslte::sch_subh::PHR_REPORT) { + allocate_sdu(&mac_msg_dl, pdu[i].lcid, pdu[i].nbytes); + } else { + allocate_ce(&mac_msg_dl, pdu[i].lcid); + } } + ret = mac_msg_dl.write_packet(log_h); + } else { + log_h->error( + "Invalid parameters calling generate_pdu: cc_idx=%d, harq_pid=%d, tb_idx=%d\n", ue_cc_idx, harq_pid, tb_idx); } - ret = mac_msg_dl.write_packet(log_h); } else { std::cout << "Error ue not configured (must call config() first" << std::endl; } @@ -525,8 +532,8 @@ uint8_t* ue::generate_mch_pdu(uint32_t harq_pid, { std::lock_guard lock(mutex); uint8_t* ret = nullptr; - tx_payload_buffer[harq_pid][0].clear(); - mch_mac_msg_dl.init_tx(&tx_payload_buffer[harq_pid][0], grant_size); + tx_payload_buffer[0][harq_pid][0].clear(); + mch_mac_msg_dl.init_tx(&tx_payload_buffer[0][harq_pid][0], grant_size); for (uint32_t i = 0; i < nof_pdu_elems; i++) { if (sched.pdu[i].lcid == srslte::sch_subh::MCH_SCHED_INFO) {