move tx/rx softbuffers of mac::ue to separate cc buffer handler class

master
Francisco 4 years ago committed by Francisco Paisana
parent 2f95862932
commit cc6c9ffc51

@ -35,14 +35,27 @@ class phy_interface_stack_lte;
class cc_buffer_handler
{
public:
// List of Tx softbuffers for all HARQ processes of one carrier
using cc_softbuffer_tx_list_t = std::vector<srslte_softbuffer_tx_t>;
// List of Rx softbuffers for all HARQ processes of one carrier
using cc_softbuffer_rx_list_t = std::vector<srslte_softbuffer_rx_t>;
cc_buffer_handler();
bool empty() const { return softbuffer_tx.empty(); }
cc_softbuffer_tx_list_t& get_tx_softbuffer() { return softbuffer_tx; }
cc_softbuffer_rx_list_t& get_rx_softbuffer() { return softbuffer_rx; }
srslte::byte_buffer_t* get_tx_payload_buffer(size_t harq_pid, size_t tb)
{
return tx_payload_buffer[harq_pid][tb].get();
}
private:
cc_softbuffer_tx_list_t softbuffer_tx; ///< List of softbuffer lists for Tx
cc_softbuffer_rx_list_t softbuffer_rx; ///< List of softbuffer lists for Rx
// One buffer per TB per HARQ process and per carrier is needed for each UE.
std::array<std::array<srslte::unique_byte_buffer_t, SRSLTE_MAX_TB>, SRSLTE_FDD_NOF_HARQ> tx_payload_buffer;
};
@ -110,7 +123,7 @@ public:
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
void allocate_cc_buffers(const uint32_t num_cc = 1); ///< Add and initialize softbuffers for CC
void allocate_sdu(srslte::sch_pdu* pdu, uint32_t lcid, uint32_t sdu_len);
bool process_ce(srslte::sch_subh* subh);
@ -131,14 +144,6 @@ private:
int nof_rx_harq_proc = 0;
int nof_tx_harq_proc = 0;
typedef std::vector<srslte_softbuffer_tx_t>
cc_softbuffer_tx_list_t; ///< List of Tx softbuffers for all HARQ processes of one carrier
std::vector<cc_softbuffer_tx_list_t> softbuffer_tx; ///< List of softbuffer lists for Tx
typedef std::vector<srslte_softbuffer_rx_t>
cc_softbuffer_rx_list_t; ///< List of Rx softbuffers for all HARQ processes of one carrier
std::vector<cc_softbuffer_rx_list_t> softbuffer_rx; ///< List of softbuffer lists for Rx
std::vector<cc_buffer_handler> cc_buffers;
std::mutex rx_buffers_mutex;

@ -16,7 +16,6 @@
#include <string.h>
#include "srsenb/hdr/stack/mac/ue.h"
#include "srslte/common/log_helper.h"
#include "srslte/interfaces/enb_phy_interfaces.h"
#include "srslte/interfaces/enb_rlc_interfaces.h"
#include "srslte/interfaces/enb_rrc_interfaces.h"
@ -71,14 +70,11 @@ ue::ue(uint16_t rnti_,
ue::~ue()
{
// Free up all softbuffers for all CCs
for (auto cc : softbuffer_rx) {
for (auto buffer : cc) {
for (auto& cc : cc_buffers) {
for (auto& buffer : cc.get_rx_softbuffer()) {
srslte_softbuffer_rx_free(&buffer);
}
}
for (auto cc : softbuffer_tx) {
for (auto buffer : cc) {
for (auto& buffer : cc.get_tx_softbuffer()) {
srslte_softbuffer_tx_free(&buffer);
}
}
@ -97,15 +93,11 @@ void ue::reset()
{
ue_metrics = {};
nof_failures = 0;
for (auto cc : softbuffer_rx) {
for (auto buffer : cc) {
for (auto& cc : cc_buffers) {
for (auto& buffer : cc.get_rx_softbuffer()) {
srslte_softbuffer_rx_reset(&buffer);
}
}
for (auto cc : softbuffer_tx) {
for (auto buffer : cc) {
for (auto& buffer : cc.get_tx_softbuffer()) {
srslte_softbuffer_tx_reset(&buffer);
}
}
@ -119,25 +111,24 @@ void ue::reset()
* @param num_cc Number of carriers to add buffers for (default 1)
* @return number of carriers
*/
uint32_t ue::allocate_cc_buffers(const uint32_t num_cc)
void ue::allocate_cc_buffers(const uint32_t num_cc)
{
for (uint32_t i = 0; i < num_cc; ++i) {
// create and init Rx buffers for Pcell
softbuffer_rx.emplace_back();
softbuffer_rx.back().resize(nof_rx_harq_proc);
for (auto& buffer : softbuffer_rx.back()) {
if (cc_buffers[i].empty()) {
// Create and init Rx buffers for Pcell
cc_buffers[i].get_rx_softbuffer().resize(nof_rx_harq_proc);
for (auto& buffer : cc_buffers[i].get_rx_softbuffer()) {
srslte_softbuffer_rx_init(&buffer, nof_prb);
}
// Create and init Tx buffers for Pcell
softbuffer_tx.emplace_back();
softbuffer_tx.back().resize(nof_tx_harq_proc);
for (auto& buffer : softbuffer_tx.back()) {
cc_buffers[i].get_tx_softbuffer().resize(nof_tx_harq_proc);
auto& harq_buffers = cc_buffers[i].get_tx_softbuffer();
for (auto& buffer : harq_buffers) {
srslte_softbuffer_tx_init(&buffer, nof_prb);
}
// don't need to reset because just initiated the buffers
}
return softbuffer_tx.size();
}
}
void ue::start_pcap(srslte::mac_pcap* pcap_)
@ -147,33 +138,23 @@ void ue::start_pcap(srslte::mac_pcap* pcap_)
srslte_softbuffer_rx_t* ue::get_rx_softbuffer(const uint32_t ue_cc_idx, const uint32_t tti)
{
if ((size_t)ue_cc_idx >= softbuffer_rx.size()) {
ERROR("UE CC Index (%d/%zd) out-of-range", ue_cc_idx, softbuffer_rx.size());
if ((size_t)ue_cc_idx >= cc_buffers.size()) {
ERROR("UE CC Index (%d/%zd) out-of-range", ue_cc_idx, cc_buffers.size());
return nullptr;
}
if ((size_t)nof_rx_harq_proc > softbuffer_rx.at(ue_cc_idx).size()) {
ERROR("HARQ process index (%d/%zd) out-of-range", nof_rx_harq_proc, softbuffer_rx.at(ue_cc_idx).size());
return nullptr;
}
return &softbuffer_rx.at(ue_cc_idx).at(tti % nof_rx_harq_proc);
return &cc_buffers.at(ue_cc_idx).get_rx_softbuffer().at(tti % nof_rx_harq_proc);
}
srslte_softbuffer_tx_t*
ue::get_tx_softbuffer(const uint32_t ue_cc_idx, const uint32_t harq_process, const uint32_t tb_idx)
{
if ((size_t)ue_cc_idx >= softbuffer_tx.size()) {
ERROR("UE CC Index (%d/%zd) out-of-range", ue_cc_idx, softbuffer_tx.size());
return nullptr;
}
if ((size_t)nof_tx_harq_proc > softbuffer_tx.at(ue_cc_idx).size()) {
ERROR("HARQ process index (%d/%zd) out-of-range", harq_process, softbuffer_tx.at(ue_cc_idx).size());
if ((size_t)ue_cc_idx >= cc_buffers.size()) {
ERROR("UE CC Index (%d/%zd) out-of-range", ue_cc_idx, cc_buffers.size());
return nullptr;
}
return &softbuffer_tx.at(ue_cc_idx).at((harq_process * SRSLTE_MAX_TB + tb_idx) % nof_tx_harq_proc);
return &cc_buffers[ue_cc_idx].get_tx_softbuffer().at((harq_process * SRSLTE_MAX_TB + tb_idx) % nof_tx_harq_proc);
}
uint8_t* ue::request_buffer(uint32_t tti, uint32_t ue_cc_idx, const uint32_t len)
@ -246,8 +227,6 @@ uint32_t ue::set_ta(int ta_)
return nof_cmd;
}
#include <assert.h>
void ue::process_pdu(uint8_t* pdu, uint32_t nof_bytes, srslte::pdu_queue::channel_t channel)
{
// Unpack ULSCH MAC PDU

Loading…
Cancel
Save