diff --git a/lib/include/srslte/adt/bounded_vector.h b/lib/include/srslte/adt/bounded_vector.h index 918c94b05..2597c34b9 100644 --- a/lib/include/srslte/adt/bounded_vector.h +++ b/lib/include/srslte/adt/bounded_vector.h @@ -107,8 +107,8 @@ public: const T& back() const { return (*this)[size_ - 1]; } T& front() { return (*this)[0]; } const T& front() const { return (*this)[0]; } - T* data() { return &buffer[0]; } - const T* data() const { return &buffer[0]; } + T* data() { return reinterpret_cast(&buffer[0]); } + const T* data() const { return reinterpret_cast(&buffer[0]); } // Iterators iterator begin() { return reinterpret_cast(&buffer[0]); } diff --git a/lib/include/srslte/interfaces/sched_interface.h b/lib/include/srslte/interfaces/sched_interface.h index 30cfc080f..f8d3738ed 100644 --- a/lib/include/srslte/interfaces/sched_interface.h +++ b/lib/include/srslte/interfaces/sched_interface.h @@ -10,6 +10,7 @@ * */ +#include "srslte/adt/bounded_vector.h" #include "srslte/common/common.h" #include "srslte/srslte.h" #include @@ -194,12 +195,11 @@ public: srslte_dci_rar_grant_t grant; } dl_sched_rar_grant_t; - typedef struct { - uint32_t tbs; - srslte_dci_dl_t dci; - uint32_t nof_grants; - dl_sched_rar_grant_t msg3_grant[MAX_RAR_LIST]; - } dl_sched_rar_t; + struct dl_sched_rar_t { + uint32_t tbs; + srslte_dci_dl_t dci; + srslte::bounded_vector msg3_grant; + }; typedef struct { srslte_dci_dl_t dci; diff --git a/srsenb/src/stack/mac/mac.cc b/srsenb/src/stack/mac/mac.cc index 0e5ef39a8..722db3bf4 100644 --- a/srsenb/src/stack/mac/mac.cc +++ b/srsenb/src/stack/mac/mac.cc @@ -640,8 +640,11 @@ int mac::get_dl_sched(uint32_t tti_tx_dl, dl_sched_list_t& dl_sched_res_list) dl_sched_res->pdsch[n].softbuffer_tx[0] = &common_buffers[enb_cc_idx].rar_softbuffer_tx; // Assemble PDU - dl_sched_res->pdsch[n].data[0] = assemble_rar( - sched_result.rar[i].msg3_grant, sched_result.rar[i].nof_grants, i, sched_result.rar[i].tbs, tti_tx_dl); + dl_sched_res->pdsch[n].data[0] = assemble_rar(sched_result.rar[i].msg3_grant.data(), + sched_result.rar[i].msg3_grant.size(), + i, + sched_result.rar[i].tbs, + tti_tx_dl); if (pcap) { pcap->write_dl_ranti(dl_sched_res->pdsch[n].data[0], diff --git a/srsenb/src/stack/mac/sched_carrier.cc b/srsenb/src/stack/mac/sched_carrier.cc index 9a00dde14..66ae73387 100644 --- a/srsenb/src/stack/mac/sched_carrier.cc +++ b/srsenb/src/stack/mac/sched_carrier.cc @@ -233,8 +233,7 @@ void ra_sched::ul_sched(sf_sched* sf_dl_sched, sf_sched* sf_msg3_sched) const std::vector& alloc_rars = sf_dl_sched->get_allocated_rars(); for (const auto& rar : alloc_rars) { - for (uint32_t j = 0; j < rar.rar_grant.nof_grants; ++j) { - const auto& msg3grant = rar.rar_grant.msg3_grant[j]; + for (const auto& msg3grant : rar.rar_grant.msg3_grant) { uint16_t crnti = msg3grant.data.temp_crnti; auto user_it = ue_db->find(crnti); diff --git a/srsenb/src/stack/mac/sched_grid.cc b/srsenb/src/stack/mac/sched_grid.cc index be53294ba..1ddbc8f2b 100644 --- a/srsenb/src/stack/mac/sched_grid.cc +++ b/srsenb/src/stack/mac/sched_grid.cc @@ -725,7 +725,7 @@ std::pair sf_sched::alloc_rar(uint32_t aggr_lvl, cons // RAR allocation successful sched_interface::dl_sched_rar_t rar_grant = {}; - rar_grant.nof_grants = nof_grants; + rar_grant.msg3_grant.resize(nof_grants); for (uint32_t i = 0; i < nof_grants; ++i) { rar_grant.msg3_grant[i].data = rar.msg3_grant[i]; rar_grant.msg3_grant[i].grant.tpc_pusch = 3; @@ -999,11 +999,10 @@ void sf_sched::set_rar_sched_result(const pdcch_grid_t::alloc_result_t& dci_resu // Setup RAR process rar->tbs = rar_alloc.alloc_data.req_bytes; - rar->nof_grants = rar_alloc.rar_grant.nof_grants; - std::copy(&rar_alloc.rar_grant.msg3_grant[0], &rar_alloc.rar_grant.msg3_grant[rar->nof_grants], rar->msg3_grant); + rar->msg3_grant = rar_alloc.rar_grant.msg3_grant; // Print RAR allocation result - for (uint32_t i = 0; i < rar->nof_grants; ++i) { + for (uint32_t i = 0; i < rar->msg3_grant.size(); ++i) { const auto& msg3_grant = rar->msg3_grant[i]; uint16_t expected_rnti = msg3_grant.data.temp_crnti; log_h->info("SCHED: RAR, temp_crnti=0x%x, ra-rnti=%d, rbgs=%s, dci=(%d,%d), rar_grant_rba=%d, " diff --git a/srsenb/test/mac/sched_sim_ue.cc b/srsenb/test/mac/sched_sim_ue.cc index e78ee8d5f..17c38e8ef 100644 --- a/srsenb/test/mac/sched_sim_ue.cc +++ b/srsenb/test/mac/sched_sim_ue.cc @@ -198,7 +198,7 @@ void ue_sim::update_conn_state(const sf_output_res_t& sf_out) if (rar_window.contains(tti_tx_dl)) { for (uint32_t i = 0; i < dl_cc_result.nof_rar_elems; ++i) { - for (uint32_t j = 0; j < dl_cc_result.rar[i].nof_grants; ++j) { + for (uint32_t j = 0; j < dl_cc_result.rar[i].msg3_grant.size(); ++j) { const auto& data = dl_cc_result.rar[i].msg3_grant[j].data; if (data.prach_tti == (uint32_t)ctxt.prach_tti_rx.to_uint() and data.preamble_idx == ctxt.preamble_idx) { ctxt.rar_tti_rx = sf_out.tti_rx; diff --git a/srsenb/test/mac/sched_ue_ded_test_suite.cc b/srsenb/test/mac/sched_ue_ded_test_suite.cc index bf5940808..4e3018e42 100644 --- a/srsenb/test/mac/sched_ue_ded_test_suite.cc +++ b/srsenb/test/mac/sched_ue_ded_test_suite.cc @@ -229,8 +229,8 @@ int test_ra(const sim_enb_ctxt_t& enb_ctxt, const sf_output_res_t& sf_out) // Inside RAR window uint32_t nof_rars = ue.rar_tti_rx.is_valid() ? 1 : 0; for (uint32_t i = 0; i < dl_cc_res.nof_rar_elems; ++i) { - for (uint32_t j = 0; j < dl_cc_res.rar[i].nof_grants; ++j) { - const auto& data = dl_cc_res.rar[i].msg3_grant[j].data; + for (const auto& grant : dl_cc_res.rar[i].msg3_grant) { + const auto& data = grant.data; if (data.prach_tti == (uint32_t)ue.prach_tti_rx.to_uint() and data.preamble_idx == ue.preamble_idx) { CONDERROR(rnti != data.temp_crnti, "RAR grant C-RNTI does not match the expected.\n"); nof_rars++; @@ -309,7 +309,7 @@ int test_ra(const sim_enb_ctxt_t& enb_ctxt, const sf_output_res_t& sf_out) // TEST: Ensure there are no spurious RARs that do not belong to any user for (uint32_t i = 0; i < dl_cc_res.nof_rar_elems; ++i) { - for (uint32_t j = 0; j < dl_cc_res.rar[i].nof_grants; ++j) { + for (uint32_t j = 0; j < dl_cc_res.rar[i].msg3_grant.size(); ++j) { uint32_t prach_tti = dl_cc_res.rar[i].msg3_grant[j].data.prach_tti; uint32_t preamble_idx = dl_cc_res.rar[i].msg3_grant[j].data.preamble_idx; auto it = std::find_if(