remove const_casts from scheduler. Fix ODR issue

master
Francisco Paisana 5 years ago
parent e9a599857a
commit ec1f1cc677

@ -215,10 +215,10 @@ SRSLTE_API int srslte_dci_msg_unpack_pdsch(srslte_cell_t* cell,
srslte_dci_msg_t* msg, srslte_dci_msg_t* msg,
srslte_dci_dl_t* dci); srslte_dci_dl_t* dci);
SRSLTE_API uint32_t srslte_dci_format_sizeof(srslte_cell_t* cell, SRSLTE_API uint32_t srslte_dci_format_sizeof(const srslte_cell_t* cell,
srslte_dl_sf_cfg_t* sf, srslte_dl_sf_cfg_t* sf,
srslte_dci_cfg_t* cfg, srslte_dci_cfg_t* cfg,
srslte_dci_format_t format); srslte_dci_format_t format);
SRSLTE_API void srslte_dci_dl_fprint(FILE* f, srslte_dci_dl_t* dci, uint32_t nof_prb); SRSLTE_API void srslte_dci_dl_fprint(FILE* f, srslte_dci_dl_t* dci, uint32_t nof_prb);

@ -44,7 +44,7 @@
**************************************************/ **************************************************/
/** Functions to generate a grant from a received DCI */ /** Functions to generate a grant from a received DCI */
SRSLTE_API int srslte_ra_dl_dci_to_grant(srslte_cell_t* cell, SRSLTE_API int srslte_ra_dl_dci_to_grant(const srslte_cell_t* cell,
srslte_dl_sf_cfg_t* sf, srslte_dl_sf_cfg_t* sf,
srslte_tm_t tm, srslte_tm_t tm,
bool pdsch_use_tbs_index_alt, bool pdsch_use_tbs_index_alt,
@ -57,12 +57,15 @@ srslte_ra_dl_grant_to_grant_prb_allocation(srslte_dci_dl_t* dci, srslte_pdsch_gr
/** Functions used by the eNodeB scheduler */ /** Functions used by the eNodeB scheduler */
SRSLTE_API uint32_t srslte_ra_dl_approx_nof_re(srslte_cell_t* cell, uint32_t nof_prb, uint32_t nof_ctrl_symbols); SRSLTE_API uint32_t srslte_ra_dl_approx_nof_re(srslte_cell_t* cell, uint32_t nof_prb, uint32_t nof_ctrl_symbols);
SRSLTE_API uint32_t srslte_ra_dl_grant_nof_re(srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf, srslte_pdsch_grant_t* grant); SRSLTE_API uint32_t srslte_ra_dl_grant_nof_re(const srslte_cell_t* cell,
srslte_dl_sf_cfg_t* sf,
srslte_pdsch_grant_t* grant);
/** Others */ /** Others */
SRSLTE_API int srslte_dl_fill_ra_mcs(srslte_ra_tb_t* tb, int last_tbs, uint32_t nprb, bool pdsch_use_tbs_index_alt); SRSLTE_API int srslte_dl_fill_ra_mcs(srslte_ra_tb_t* tb, int last_tbs, uint32_t nprb, bool pdsch_use_tbs_index_alt);
SRSLTE_API void srslte_ra_dl_compute_nof_re(srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf, srslte_pdsch_grant_t* grant); SRSLTE_API void
srslte_ra_dl_compute_nof_re(const srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf, srslte_pdsch_grant_t* grant);
SRSLTE_API uint32_t srslte_ra_dl_info(srslte_pdsch_grant_t* grant, char* info_str, uint32_t len); SRSLTE_API uint32_t srslte_ra_dl_info(srslte_pdsch_grant_t* grant, char* info_str, uint32_t len);

@ -111,7 +111,7 @@ static bool is_ambiguous_size(uint32_t size)
/********************************** /**********************************
* PAYLOAD sizeof functions * PAYLOAD sizeof functions
* ********************************/ * ********************************/
static uint32_t dci_format0_sizeof_(srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf, srslte_dci_cfg_t* cfg) static uint32_t dci_format0_sizeof_(const srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf, srslte_dci_cfg_t* cfg)
{ {
uint32_t n = 0; uint32_t n = 0;
@ -156,7 +156,7 @@ static uint32_t dci_format0_sizeof_(srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf,
return n; return n;
} }
static uint32_t dci_format1A_sizeof(srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf, srslte_dci_cfg_t* cfg) static uint32_t dci_format1A_sizeof(const srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf, srslte_dci_cfg_t* cfg)
{ {
uint32_t n = 0; uint32_t n = 0;
@ -202,7 +202,7 @@ static uint32_t dci_format1A_sizeof(srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf,
return n; return n;
} }
static uint32_t dci_format0_sizeof(srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf, srslte_dci_cfg_t* cfg) static uint32_t dci_format0_sizeof(const srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf, srslte_dci_cfg_t* cfg)
{ {
uint32_t n = dci_format0_sizeof_(cell, sf, cfg); uint32_t n = dci_format0_sizeof_(cell, sf, cfg);
while (n < dci_format1A_sizeof(cell, sf, cfg)) { while (n < dci_format1A_sizeof(cell, sf, cfg)) {
@ -211,7 +211,7 @@ static uint32_t dci_format0_sizeof(srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf,
return n; return n;
} }
static uint32_t dci_format1_sizeof(srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf, srslte_dci_cfg_t* cfg) static uint32_t dci_format1_sizeof(const srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf, srslte_dci_cfg_t* cfg)
{ {
uint32_t n = (uint32_t)ceilf((float)cell->nof_prb / srslte_ra_type0_P(cell->nof_prb)) + 5 + HARQ_PID_LEN + 1 + 2 + 2 + uint32_t n = (uint32_t)ceilf((float)cell->nof_prb / srslte_ra_type0_P(cell->nof_prb)) + 5 + HARQ_PID_LEN + 1 + 2 + 2 +
@ -225,7 +225,7 @@ static uint32_t dci_format1_sizeof(srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf,
return n; return n;
} }
static uint32_t dci_format1C_sizeof(srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf, srslte_dci_cfg_t* cfg) static uint32_t dci_format1C_sizeof(const srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf, srslte_dci_cfg_t* cfg)
{ {
uint32_t n_vrb_dl_gap1 = srslte_ra_type2_n_vrb_dl(cell->nof_prb, true); uint32_t n_vrb_dl_gap1 = srslte_ra_type2_n_vrb_dl(cell->nof_prb, true);
uint32_t n_step = srslte_ra_type2_n_rb_step(cell->nof_prb); uint32_t n_step = srslte_ra_type2_n_rb_step(cell->nof_prb);
@ -246,7 +246,7 @@ static uint32_t tpmi_bits(uint32_t nof_ports)
} }
} }
static uint32_t dci_format1B_sizeof(srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf, srslte_dci_cfg_t* cfg) static uint32_t dci_format1B_sizeof(const srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf, srslte_dci_cfg_t* cfg)
{ {
uint32_t n = 0; uint32_t n = 0;
@ -292,7 +292,7 @@ static uint32_t dci_format1B_sizeof(srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf,
return n; return n;
} }
static uint32_t dci_format1D_sizeof(srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf, srslte_dci_cfg_t* cfg) static uint32_t dci_format1D_sizeof(const srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf, srslte_dci_cfg_t* cfg)
{ {
// same size as format1B // same size as format1B
return dci_format1B_sizeof(cell, sf, cfg); return dci_format1B_sizeof(cell, sf, cfg);
@ -308,7 +308,7 @@ static uint32_t precoding_bits_f2(uint32_t nof_ports)
} }
} }
static uint32_t dci_format2_sizeof(srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf, srslte_dci_cfg_t* cfg) static uint32_t dci_format2_sizeof(const srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf, srslte_dci_cfg_t* cfg)
{ {
uint32_t n = (uint32_t)ceilf((float)cell->nof_prb / srslte_ra_type0_P(cell->nof_prb)) + 2 + HARQ_PID_LEN + 1 + uint32_t n = (uint32_t)ceilf((float)cell->nof_prb / srslte_ra_type0_P(cell->nof_prb)) + 2 + HARQ_PID_LEN + 1 +
2 * (5 + 1 + 2) + precoding_bits_f2(cell->nof_ports) + (cfg->cif_enabled ? 3 : 0) + (IS_TDD ? 2 : 0); 2 * (5 + 1 + 2) + precoding_bits_f2(cell->nof_ports) + (cfg->cif_enabled ? 3 : 0) + (IS_TDD ? 2 : 0);
@ -331,7 +331,7 @@ static uint32_t precoding_bits_f2a(uint32_t nof_ports)
} }
} }
static uint32_t dci_format2A_sizeof(srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf, srslte_dci_cfg_t* cfg) static uint32_t dci_format2A_sizeof(const srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf, srslte_dci_cfg_t* cfg)
{ {
uint32_t n = (uint32_t)ceilf((float)cell->nof_prb / srslte_ra_type0_P(cell->nof_prb)) + 2 + HARQ_PID_LEN + 1 + uint32_t n = (uint32_t)ceilf((float)cell->nof_prb / srslte_ra_type0_P(cell->nof_prb)) + 2 + HARQ_PID_LEN + 1 +
2 * (5 + 1 + 2) + precoding_bits_f2a(cell->nof_ports) + (cfg->cif_enabled ? 3 : 0) + (IS_TDD ? 2 : 0); 2 * (5 + 1 + 2) + precoding_bits_f2a(cell->nof_ports) + (cfg->cif_enabled ? 3 : 0) + (IS_TDD ? 2 : 0);
@ -344,7 +344,7 @@ static uint32_t dci_format2A_sizeof(srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf,
return n; return n;
} }
static uint32_t dci_format2B_sizeof(srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf, srslte_dci_cfg_t* cfg) static uint32_t dci_format2B_sizeof(const srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf, srslte_dci_cfg_t* cfg)
{ {
uint32_t n = (uint32_t)ceilf((float)cell->nof_prb / srslte_ra_type0_P(cell->nof_prb)) + 2 + HARQ_PID_LEN + 1 + uint32_t n = (uint32_t)ceilf((float)cell->nof_prb / srslte_ra_type0_P(cell->nof_prb)) + 2 + HARQ_PID_LEN + 1 +
2 * (5 + 1 + 2) + (cfg->cif_enabled ? 3 : 0) + (IS_TDD ? 2 : 0); 2 * (5 + 1 + 2) + (cfg->cif_enabled ? 3 : 0) + (IS_TDD ? 2 : 0);
@ -357,8 +357,10 @@ static uint32_t dci_format2B_sizeof(srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf,
return n; return n;
} }
uint32_t uint32_t srslte_dci_format_sizeof(const srslte_cell_t* cell,
srslte_dci_format_sizeof(srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf, srslte_dci_cfg_t* cfg, srslte_dci_format_t format) srslte_dl_sf_cfg_t* sf,
srslte_dci_cfg_t* cfg,
srslte_dci_format_t format)
{ {
srslte_dl_sf_cfg_t _sf; srslte_dl_sf_cfg_t _sf;
if (sf == NULL) { if (sf == NULL) {

@ -45,7 +45,7 @@ const int tbs_format1c_table[32] = {40, 56, 72, 120, 136, 144, 176, 208
**********/ **********/
/* Returns the number of RE in a PRB in a slot and subframe */ /* Returns the number of RE in a PRB in a slot and subframe */
static uint32_t ra_re_x_prb(srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf, uint32_t slot, uint32_t prb_idx) static uint32_t ra_re_x_prb(const srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf, uint32_t slot, uint32_t prb_idx)
{ {
uint32_t subframe = sf->tti % 10; uint32_t subframe = sf->tti % 10;
@ -441,7 +441,7 @@ static int dl_dci_compute_tb(bool pdsch_use_tbs_index_alt, srslte_dci_dl_t* dci,
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
} }
void srslte_ra_dl_compute_nof_re(srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf, srslte_pdsch_grant_t* grant) void srslte_ra_dl_compute_nof_re(const srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf, srslte_pdsch_grant_t* grant)
{ {
// Compute number of RE // Compute number of RE
grant->nof_re = srslte_ra_dl_grant_nof_re(cell, sf, grant); grant->nof_re = srslte_ra_dl_grant_nof_re(cell, sf, grant);
@ -468,7 +468,8 @@ void srslte_ra_dl_compute_nof_re(srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf, sr
} }
/* Determine MIMO type based on number of cell ports and receive antennas, transport blocks and pinfo */ /* Determine MIMO type based on number of cell ports and receive antennas, transport blocks and pinfo */
static int config_mimo_type(srslte_cell_t* cell, srslte_tm_t tm, srslte_dci_dl_t* dci, srslte_pdsch_grant_t* grant) static int
config_mimo_type(const srslte_cell_t* cell, srslte_tm_t tm, srslte_dci_dl_t* dci, srslte_pdsch_grant_t* grant)
{ {
grant->tx_scheme = SRSLTE_TXSCHEME_PORT0; grant->tx_scheme = SRSLTE_TXSCHEME_PORT0;
bool valid_config = true; bool valid_config = true;
@ -525,7 +526,7 @@ static int config_mimo_type(srslte_cell_t* cell, srslte_tm_t tm, srslte_dci_dl_t
} }
/* Translates Precoding Information (pinfo) to Precoding matrix Index (pmi) as 3GPP 36.212 Table 5.3.3.1.5-4 */ /* Translates Precoding Information (pinfo) to Precoding matrix Index (pmi) as 3GPP 36.212 Table 5.3.3.1.5-4 */
static int config_mimo_pmi(srslte_cell_t* cell, srslte_dci_dl_t* dci, srslte_pdsch_grant_t* grant) static int config_mimo_pmi(const srslte_cell_t* cell, srslte_dci_dl_t* dci, srslte_pdsch_grant_t* grant)
{ {
uint32_t nof_tb = grant->nof_tb; uint32_t nof_tb = grant->nof_tb;
if (grant->tx_scheme == SRSLTE_TXSCHEME_SPATIALMUX) { if (grant->tx_scheme == SRSLTE_TXSCHEME_SPATIALMUX) {
@ -556,7 +557,7 @@ static int config_mimo_pmi(srslte_cell_t* cell, srslte_dci_dl_t* dci, srslte_pds
} }
/* Determine number of MIMO layers */ /* Determine number of MIMO layers */
static int config_mimo_layers(srslte_cell_t* cell, srslte_dci_dl_t* dci, srslte_pdsch_grant_t* grant) static int config_mimo_layers(const srslte_cell_t* cell, srslte_dci_dl_t* dci, srslte_pdsch_grant_t* grant)
{ {
uint32_t nof_tb = grant->nof_tb; uint32_t nof_tb = grant->nof_tb;
switch (grant->tx_scheme) { switch (grant->tx_scheme) {
@ -599,7 +600,7 @@ static int config_mimo_layers(srslte_cell_t* cell, srslte_dci_dl_t* dci, srslte_
return 0; return 0;
} }
static int config_mimo(srslte_cell_t* cell, srslte_tm_t tm, srslte_dci_dl_t* dci, srslte_pdsch_grant_t* grant) static int config_mimo(const srslte_cell_t* cell, srslte_tm_t tm, srslte_dci_dl_t* dci, srslte_pdsch_grant_t* grant)
{ {
if (config_mimo_type(cell, tm, dci, grant)) { if (config_mimo_type(cell, tm, dci, grant)) {
@ -626,7 +627,7 @@ static int config_mimo(srslte_cell_t* cell, srslte_tm_t tm, srslte_dci_dl_t* dci
**********/ **********/
/** Compute the DL grant parameters */ /** Compute the DL grant parameters */
int srslte_ra_dl_dci_to_grant(srslte_cell_t* cell, int srslte_ra_dl_dci_to_grant(const srslte_cell_t* cell,
srslte_dl_sf_cfg_t* sf, srslte_dl_sf_cfg_t* sf,
srslte_tm_t tm, srslte_tm_t tm,
bool pdsch_use_tbs_index_alt, bool pdsch_use_tbs_index_alt,
@ -684,7 +685,7 @@ uint32_t srslte_ra_dl_approx_nof_re(srslte_cell_t* cell, uint32_t nof_prb, uint3
} }
/* Computes the number of RE for each PRB in the prb_dist structure */ /* Computes the number of RE for each PRB in the prb_dist structure */
uint32_t srslte_ra_dl_grant_nof_re(srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf, srslte_pdsch_grant_t* grant) uint32_t srslte_ra_dl_grant_nof_re(const srslte_cell_t* cell, srslte_dl_sf_cfg_t* sf, srslte_pdsch_grant_t* grant)
{ {
uint32_t j, s; uint32_t j, s;
// Compute number of RE per PRB // Compute number of RE per PRB

@ -91,13 +91,13 @@ using prbmask_t = srslte::bounded_bitset<100, true>;
namespace sched_utils { namespace sched_utils {
uint32_t aggr_level(uint32_t aggr_idx) inline uint32_t aggr_level(uint32_t aggr_idx)
{ {
return 1u << aggr_idx; return 1u << aggr_idx;
} }
//! Obtain rvidx from nof retxs. This value is stored in DCI //! Obtain rvidx from nof retxs. This value is stored in DCI
uint32_t get_rvidx(uint32_t retx_idx) inline uint32_t get_rvidx(uint32_t retx_idx)
{ {
const static uint32_t rv_idx[4] = {0, 2, 3, 1}; const static uint32_t rv_idx[4] = {0, 2, 3, 1};
return rv_idx[retx_idx % 4]; return rv_idx[retx_idx % 4];

@ -342,9 +342,8 @@ sf_grid_t::dl_ctrl_alloc_t sf_grid_t::alloc_dl_ctrl(uint32_t aggr_lvl, alloc_typ
alloc_outcome_t sf_grid_t::alloc_dl_data(sched_ue* user, const rbgmask_t& user_mask) alloc_outcome_t sf_grid_t::alloc_dl_data(sched_ue* user, const rbgmask_t& user_mask)
{ {
srslte_dci_format_t dci_format = user->get_dci_format(); srslte_dci_format_t dci_format = user->get_dci_format();
uint32_t nof_bits = uint32_t nof_bits = srslte_dci_format_sizeof(&cc_cfg->cfg.cell, nullptr, nullptr, dci_format);
srslte_dci_format_sizeof(const_cast<srslte_cell_t*>(&cc_cfg->cfg.cell), nullptr, nullptr, dci_format); uint32_t aggr_level = user->get_ue_carrier(cc_cfg->enb_cc_idx)->get_aggr_level(nof_bits);
uint32_t aggr_level = user->get_ue_carrier(cc_cfg->enb_cc_idx)->get_aggr_level(nof_bits);
return alloc_dl(aggr_level, alloc_type_t::DL_DATA, user_mask, user); return alloc_dl(aggr_level, alloc_type_t::DL_DATA, user_mask, user);
} }
@ -362,8 +361,7 @@ alloc_outcome_t sf_grid_t::alloc_ul_data(sched_ue* user, ul_harq_proc::ul_alloc_
// Generate PDCCH except for RAR and non-adaptive retx // Generate PDCCH except for RAR and non-adaptive retx
if (needs_pdcch) { if (needs_pdcch) {
uint32_t nof_bits = uint32_t nof_bits = srslte_dci_format_sizeof(&cc_cfg->cfg.cell, nullptr, nullptr, SRSLTE_DCI_FORMAT0);
srslte_dci_format_sizeof(const_cast<srslte_cell_t*>(&cc_cfg->cfg.cell), nullptr, nullptr, SRSLTE_DCI_FORMAT0);
uint32_t aggr_idx = user->get_ue_carrier(cc_cfg->enb_cc_idx)->get_aggr_level(nof_bits); uint32_t aggr_idx = user->get_ue_carrier(cc_cfg->enb_cc_idx)->get_aggr_level(nof_bits);
if (not pdcch_alloc.alloc_dci(alloc_type_t::UL_DATA, aggr_idx, user)) { if (not pdcch_alloc.alloc_dci(alloc_type_t::UL_DATA, aggr_idx, user)) {
if (log_h->get_level() == srslte::LOG_LEVEL_DEBUG) { if (log_h->get_level() == srslte::LOG_LEVEL_DEBUG) {

@ -303,14 +303,12 @@ int srsenb::extract_dl_prbmask(const srslte_cell_t& cell,
srslte::bounded_bitset<100, true>* alloc_mask) srslte::bounded_bitset<100, true>* alloc_mask)
{ {
srslte_pdsch_grant_t grant; srslte_pdsch_grant_t grant;
srslte_dl_sf_cfg_t dl_sf = {}; srslte_dl_sf_cfg_t dl_sf = {};
srslte_dci_dl_t* dci_dyn = const_cast<srslte_dci_dl_t*>(&dci); // TODO
srslte_cell_t* cell_dyn = const_cast<srslte_cell_t*>(&cell);
alloc_mask->resize(cell.nof_prb); alloc_mask->resize(cell.nof_prb);
alloc_mask->reset(); alloc_mask->reset();
CONDERROR(srslte_ra_dl_dci_to_grant(cell_dyn, &dl_sf, SRSLTE_TM1, false, dci_dyn, &grant) == SRSLTE_ERROR, CONDERROR(srslte_ra_dl_dci_to_grant(&cell, &dl_sf, SRSLTE_TM1, false, &dci, &grant) == SRSLTE_ERROR,
"Failed to decode PDSCH grant\n"); "Failed to decode PDSCH grant\n");
for (uint32_t j = 0; j < alloc_mask->size(); ++j) { for (uint32_t j = 0; j < alloc_mask->size(); ++j) {
if (grant.prb_idx[0][j]) { if (grant.prb_idx[0][j]) {

Loading…
Cancel
Save