made the number of ue payload allocations proportional to number of active carriers. Made mac::ue_db use unique_ptrs

This commit is contained in:
Francisco Paisana 2020-03-23 13:05:58 +00:00 committed by Francisco Paisana
parent 8772d8f85c
commit a2866f661b
4 changed files with 14 additions and 13 deletions

View File

@ -130,7 +130,7 @@ private:
sched_interface::dl_pdu_mch_t mch = {};
/* Map of active UEs */
std::map<uint16_t, ue*> ue_db;
std::map<uint16_t, std::unique_ptr<ue> > ue_db;
uint16_t last_rnti = 0;
uint8_t* assemble_rar(sched_interface::dl_sched_rar_grant_t* grants,

View File

@ -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<uint8_t*> cc_buffer_ptr_t; ///< List of buffer pointers for RX HARQ processes of one carrier
std::vector<cc_buffer_ptr_t> pending_buffers; ///< List of buffer pointer list for Rx
// For DL there are two buffers, one for each Transport block
std::array<std::array<std::array<srslte::unique_byte_buffer_t, SRSLTE_MAX_TB>, SRSLTE_FDD_NOF_HARQ>,
SRSLTE_MAX_CARRIERS>
// One buffer per TB per HARQ process and per carrier is needed for each UE.
std::vector<std::array<std::array<srslte::unique_byte_buffer_t, SRSLTE_MAX_TB>, SRSLTE_FDD_NOF_HARQ> >
tx_payload_buffer;
srslte::block_queue<uint32_t> pending_ta_commands;

View File

@ -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<ue>{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<ue>{new ue(SRSLTE_MRNTI, args.nof_prb, &scheduler, rrc_h, rlc_h, phy_h, log_h, cells.size())};
rrc_h->add_user(SRSLTE_MRNTI, {});
}

View File

@ -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) {