enb: use circular array to access TTI and HARQ based data structures

this makes use of the new circular array to remove the need
to apply the modulo operation when safely accessing the underlying
array.
This commit is contained in:
Andre Puschmann 2020-09-03 21:16:49 +02:00 committed by faluco
parent e80aa0a553
commit 87d4a5dc9c
2 changed files with 12 additions and 10 deletions

View File

@ -25,6 +25,7 @@
#include "phy_interfaces.h"
#include <map>
#include <mutex>
#include <srslte/common/circular_array.h>
#include <srslte/interfaces/enb_interfaces.h>
#include <srslte/srslte.h>
@ -84,18 +85,19 @@ private:
cell_state_t state = cell_state_none; ///< Configuration state
uint32_t enb_cc_idx = 0; ///< Corresponding eNb cell/carrier index
uint8_t last_ri = 0; ///< Last reported rank indicator
std::array<srslte_ra_tb_t, SRSLTE_MAX_HARQ_PROC> last_tb = {}; ///< Stores last PUSCH Resource allocation
srslte::circular_array<srslte_ra_tb_t, SRSLTE_MAX_HARQ_PROC> last_tb =
{}; ///< Stores last PUSCH Resource allocation
srslte::phy_cfg_t phy_cfg; ///< Configuration, it has a default constructor
std::array<bool, TTIMOD_SZ> is_grant_available; ///< Indicates whether there is an available grant
srslte::circular_array<bool, TTIMOD_SZ> is_grant_available; ///< Indicates whether there is an available grant
} cell_info_t;
/**
* UE object stored in the PHY common database
*/
struct common_ue {
std::array<srslte_pdsch_ack_t, TTIMOD_SZ> pdsch_ack = {}; ///< Pending acknowledgements for this Cell
std::array<cell_info_t, SRSLTE_MAX_CARRIERS> cell_info = {}; ///< Cell information, indexed by ue_cell_idx
srslte::phy_cfg_t pcell_cfg_stash = {}; ///< Stashed Cell information
srslte::circular_array<srslte_pdsch_ack_t, TTIMOD_SZ> pdsch_ack = {}; ///< Pending acknowledgements for this Cell
std::array<cell_info_t, SRSLTE_MAX_CARRIERS> cell_info = {}; ///< Cell information, indexed by ue_cell_idx
srslte::phy_cfg_t pcell_cfg_stash = {}; ///< Stashed Cell information
};
/**

View File

@ -125,7 +125,7 @@ uint32_t phy_ue_db::_get_uci_enb_cc_idx(uint32_t tti, uint16_t rnti) const
{
// Find the lowest index available PUSCH grant
for (const cell_info_t& cell_info : ue_db.at(rnti).cell_info) {
if (cell_info.is_grant_available[TTIMOD(tti)]) {
if (cell_info.is_grant_available[tti]) {
return cell_info.enb_cc_idx;
}
}
@ -657,7 +657,7 @@ void phy_ue_db::set_last_ul_tb(uint16_t rnti, uint32_t enb_cc_idx, uint32_t pid,
}
// Save resource allocation
ue_db.at(rnti).cell_info[_get_ue_cc_idx(rnti, enb_cc_idx)].last_tb[pid % SRSLTE_FDD_NOF_HARQ] = tb;
ue_db.at(rnti).cell_info[_get_ue_cc_idx(rnti, enb_cc_idx)].last_tb[pid] = tb;
}
srslte_ra_tb_t phy_ue_db::get_last_ul_tb(uint16_t rnti, uint32_t enb_cc_idx, uint32_t pid) const
@ -670,7 +670,7 @@ srslte_ra_tb_t phy_ue_db::get_last_ul_tb(uint16_t rnti, uint32_t enb_cc_idx, uin
}
// Returns the latest stored UL transmission grant
return ue_db.at(rnti).cell_info[_get_ue_cc_idx(rnti, enb_cc_idx)].last_tb[pid % SRSLTE_FDD_NOF_HARQ];
return ue_db.at(rnti).cell_info[_get_ue_cc_idx(rnti, enb_cc_idx)].last_tb[pid];
}
void phy_ue_db::set_ul_grant_available(uint32_t tti, const stack_interface_phy_lte::ul_sched_list_t& ul_sched_list)
@ -680,7 +680,7 @@ void phy_ue_db::set_ul_grant_available(uint32_t tti, const stack_interface_phy_l
// Reset all available grants flags for the given TTI
for (auto& ue : ue_db) {
for (cell_info_t& cell_info : ue.second.cell_info) {
cell_info.is_grant_available[TTIMOD(tti)] = false;
cell_info.is_grant_available[tti] = false;
}
}
@ -693,7 +693,7 @@ void phy_ue_db::set_ul_grant_available(uint32_t tti, const stack_interface_phy_l
// Check that eNb Cell/Carrier is active for the given RNTI
if (_assert_active_enb_cc(rnti, enb_cc_idx) == SRSLTE_SUCCESS) {
// Rise Grant available flag
ue_db[rnti].cell_info[_get_ue_cc_idx(rnti, enb_cc_idx)].is_grant_available[TTIMOD(tti)] = true;
ue_db[rnti].cell_info[_get_ue_cc_idx(rnti, enb_cc_idx)].is_grant_available[tti] = true;
}
}
}