Move gNB metrics processing to the stack thread avoiding concurrency issues in MAC and RRC.

master
faluco 3 years ago committed by Andre Puschmann
parent dadd2f7524
commit 9058ee9a5b

@ -120,7 +120,10 @@ private:
// task scheduling // task scheduling
static const int STACK_MAIN_THREAD_PRIO = 4; static const int STACK_MAIN_THREAD_PRIO = 4;
srsran::task_scheduler task_sched; srsran::task_scheduler task_sched;
srsran::task_multiqueue::queue_handle sync_task_queue, ue_task_queue, gtpu_task_queue, mac_task_queue; srsran::task_multiqueue::queue_handle sync_task_queue, ue_task_queue, gtpu_task_queue, mac_task_queue,
metrics_task_queue;
srsran::dyn_blocking_queue<stack_metrics_t> pending_stack_metrics;
// derived // derived
srsenb::mac_nr mac; srsenb::mac_nr mac;

@ -25,6 +25,7 @@ gnb_stack_nr::gnb_stack_nr(srslog::sink& log_sink) :
pdcp_logger(srslog::fetch_basic_logger("PDCP-NR", log_sink, false)), pdcp_logger(srslog::fetch_basic_logger("PDCP-NR", log_sink, false)),
rrc_logger(srslog::fetch_basic_logger("RRC-NR", log_sink, false)), rrc_logger(srslog::fetch_basic_logger("RRC-NR", log_sink, false)),
stack_logger(srslog::fetch_basic_logger("STCK-NR", log_sink, false)), stack_logger(srslog::fetch_basic_logger("STCK-NR", log_sink, false)),
pending_stack_metrics(64),
mac(&task_sched), mac(&task_sched),
rrc(&task_sched), rrc(&task_sched),
pdcp(&task_sched, pdcp_logger), pdcp(&task_sched, pdcp_logger),
@ -34,6 +35,7 @@ gnb_stack_nr::gnb_stack_nr(srslog::sink& log_sink) :
sync_task_queue = task_sched.make_task_queue(); sync_task_queue = task_sched.make_task_queue();
gtpu_task_queue = task_sched.make_task_queue(); gtpu_task_queue = task_sched.make_task_queue();
mac_task_queue = task_sched.make_task_queue(); mac_task_queue = task_sched.make_task_queue();
metrics_task_queue = task_sched.make_task_queue();
} }
gnb_stack_nr::~gnb_stack_nr() gnb_stack_nr::~gnb_stack_nr()
@ -129,9 +131,7 @@ void gnb_stack_nr::tti_clock_impl()
task_sched.tic(); task_sched.tic();
} }
void gnb_stack_nr::process_pdus() void gnb_stack_nr::process_pdus() {}
{
}
/******************************************************** /********************************************************
* *
@ -141,9 +141,22 @@ void gnb_stack_nr::process_pdus()
bool gnb_stack_nr::get_metrics(srsenb::stack_metrics_t* metrics) bool gnb_stack_nr::get_metrics(srsenb::stack_metrics_t* metrics)
{ {
mac.get_metrics(metrics->mac); // use stack thread to query metrics
rrc.get_metrics(metrics->rrc); auto ret = metrics_task_queue.try_push([this]() {
srsenb::stack_metrics_t metrics{};
mac.get_metrics(metrics.mac);
rrc.get_metrics(metrics.rrc);
if (not pending_stack_metrics.try_push(std::move(metrics))) {
stack_logger.error("Unable to push metrics to queue");
}
});
if (ret.has_value()) {
// wait for result
*metrics = pending_stack_metrics.pop_blocking();
return true; return true;
}
return false;
} }
// Temporary GW interface // Temporary GW interface

Loading…
Cancel
Save