sched: use circular buffer instead of deque to handle pending RACHs

master
Francisco Paisana 2 years ago committed by Justin Tallon
parent 150bfb6185
commit ac2d0beedd

@ -15,6 +15,7 @@
#include "sched.h" #include "sched.h"
#include "schedulers/sched_base.h" #include "schedulers/sched_base.h"
#include "srsran/adt/circular_buffer.h"
#include "srsran/adt/pool/cached_alloc.h" #include "srsran/adt/pool/cached_alloc.h"
#include "srsran/srslog/srslog.h" #include "srsran/srslog/srslog.h"
@ -131,9 +132,9 @@ private:
const sched_cell_params_t* cc_cfg = nullptr; const sched_cell_params_t* cc_cfg = nullptr;
sched_ue_list* ue_db = nullptr; sched_ue_list* ue_db = nullptr;
srsran::deque<pending_rar_t> pending_rars; srsran::dyn_circular_buffer<pending_rar_t> pending_rars;
uint32_t rar_aggr_level = 2; uint32_t rar_aggr_level = 2;
static const uint32_t PRACH_RAR_OFFSET = 3; // TS 36.321 Sec. 5.1.4 static const uint32_t PRACH_RAR_OFFSET = 3; // TS 36.321 Sec. 5.1.4
}; };
} // namespace srsenb } // namespace srsenb

@ -28,7 +28,8 @@ using srsran::tti_point;
bc_sched::bc_sched(const sched_cell_params_t& cfg_, srsenb::rrc_interface_mac* rrc_) : bc_sched::bc_sched(const sched_cell_params_t& cfg_, srsenb::rrc_interface_mac* rrc_) :
cc_cfg(&cfg_), rrc(rrc_), logger(srslog::fetch_basic_logger("MAC")) cc_cfg(&cfg_), rrc(rrc_), logger(srslog::fetch_basic_logger("MAC"))
{} {
}
void bc_sched::dl_sched(sf_sched* tti_sched) void bc_sched::dl_sched(sf_sched* tti_sched)
{ {
@ -169,8 +170,9 @@ void bc_sched::reset()
*******************************************************/ *******************************************************/
ra_sched::ra_sched(const sched_cell_params_t& cfg_, sched_ue_list& ue_db_) : ra_sched::ra_sched(const sched_cell_params_t& cfg_, sched_ue_list& ue_db_) :
cc_cfg(&cfg_), logger(srslog::fetch_basic_logger("MAC")), ue_db(&ue_db_) cc_cfg(&cfg_), logger(srslog::fetch_basic_logger("MAC")), ue_db(&ue_db_), pending_rars(16)
{} {
}
alloc_result ra_sched::allocate_pending_rar(sf_sched* tti_sched, const pending_rar_t& rar, uint32_t& nof_grants_alloc) alloc_result ra_sched::allocate_pending_rar(sf_sched* tti_sched, const pending_rar_t& rar, uint32_t& nof_grants_alloc)
{ {
@ -205,8 +207,10 @@ void ra_sched::dl_sched(sf_sched* tti_sched)
tti_point tti_tx_dl = tti_sched->get_tti_tx_dl(); tti_point tti_tx_dl = tti_sched->get_tti_tx_dl();
rar_aggr_level = 2; rar_aggr_level = 2;
for (auto it = pending_rars.begin(); it != pending_rars.end();) { for (auto& rar : pending_rars) {
auto& rar = *it; if (rar.msg3_grant.empty()) {
continue;
}
// In case of RAR outside RAR window: // In case of RAR outside RAR window:
// - if window has passed, discard RAR // - if window has passed, discard RAR
@ -223,7 +227,7 @@ void ra_sched::dl_sched(sf_sched* tti_sched)
tti_tx_dl); tti_tx_dl);
srsran::console("%s\n", srsran::to_c_str(str_buffer)); srsran::console("%s\n", srsran::to_c_str(str_buffer));
logger.warning("%s", srsran::to_c_str(str_buffer)); logger.warning("%s", srsran::to_c_str(str_buffer));
it = pending_rars.erase(it); rar.msg3_grant.clear(); // mark as handled.
continue; continue;
} }
return; return;
@ -239,7 +243,7 @@ void ra_sched::dl_sched(sf_sched* tti_sched)
// - otherwise, erase only Msg3 grants that were allocated, and stop iteration // - otherwise, erase only Msg3 grants that were allocated, and stop iteration
if (nof_rar_allocs == rar.msg3_grant.size()) { if (nof_rar_allocs == rar.msg3_grant.size()) {
it = pending_rars.erase(it); rar.msg3_grant.clear(); // mark as handled.
} else { } else {
std::copy(rar.msg3_grant.begin() + nof_rar_allocs, rar.msg3_grant.end(), rar.msg3_grant.begin()); std::copy(rar.msg3_grant.begin() + nof_rar_allocs, rar.msg3_grant.end(), rar.msg3_grant.begin());
rar.msg3_grant.resize(rar.msg3_grant.size() - nof_rar_allocs); rar.msg3_grant.resize(rar.msg3_grant.size() - nof_rar_allocs);
@ -252,9 +256,13 @@ void ra_sched::dl_sched(sf_sched* tti_sched)
if (ret != alloc_result::no_cch_space) { if (ret != alloc_result::no_cch_space) {
break; break;
} }
++it;
} }
} }
// Pop elements at the front that have been handled.
while (not pending_rars.empty() and pending_rars.begin()->msg3_grant.empty()) {
pending_rars.pop();
}
} }
int ra_sched::dl_rach_info(dl_sched_rar_info_t rar_info) int ra_sched::dl_rach_info(dl_sched_rar_info_t rar_info)
@ -287,7 +295,10 @@ int ra_sched::dl_rach_info(dl_sched_rar_info_t rar_info)
p.ra_rnti = ra_rnti; p.ra_rnti = ra_rnti;
p.prach_tti = tti_point{rar_info.prach_tti}; p.prach_tti = tti_point{rar_info.prach_tti};
p.msg3_grant.push_back(rar_info); p.msg3_grant.push_back(rar_info);
pending_rars.push_back(p); if (not pending_rars.try_push(p)) {
logger.warning("SCHED: Unable to handle RAR ra-rnti=0x%x, as the maximum number of pending RARs has been reached",
ra_rnti);
}
return SRSRAN_SUCCESS; return SRSRAN_SUCCESS;
} }

Loading…
Cancel
Save