From 4890ee98758f4b37a90db6903d986510cc123b48 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Tue, 25 Jan 2022 21:43:42 +0100 Subject: [PATCH] ue,rrc: add RRC metrics and fix stdout --- srsue/hdr/stack/rrc_nr/rrc_nr.h | 11 +-------- srsue/hdr/stack/rrc_nr/rrc_nr_metrics.h | 32 +++++++++++++++++++++++++ srsue/hdr/ue_metrics_interface.h | 3 ++- srsue/src/metrics_stdout.cc | 23 +++++++++++------- srsue/src/stack/rrc_nr/rrc_nr.cc | 8 +++++-- srsue/src/stack/ue_stack_lte.cc | 1 + 6 files changed, 56 insertions(+), 22 deletions(-) create mode 100644 srsue/hdr/stack/rrc_nr/rrc_nr_metrics.h diff --git a/srsue/hdr/stack/rrc_nr/rrc_nr.h b/srsue/hdr/stack/rrc_nr/rrc_nr.h index fc9b3c6cc..f01525f4b 100644 --- a/srsue/hdr/stack/rrc_nr/rrc_nr.h +++ b/srsue/hdr/stack/rrc_nr/rrc_nr.h @@ -15,6 +15,7 @@ #include "../rrc/rrc_cell.h" #include "rrc_nr_config.h" +#include "rrc_nr_metrics.h" #include "srsran/adt/circular_map.h" #include "srsran/asn1/rrc_nr.h" #include "srsran/asn1/rrc_nr_utils.h" @@ -35,8 +36,6 @@ class usim_interface_rrc_nr; class pdcp_interface_rrc; class rlc_interface_rrc; -struct rrc_nr_metrics_t {}; - class rrc_nr final : public rrc_interface_phy_nr, public rrc_interface_pdcp, public rrc_interface_rlc, @@ -185,14 +184,6 @@ private: uint32_t sim_measurement_carrier_freq_r15; srsran::timer_handler::unique_timer sim_measurement_timer; - /// RRC states (3GPP 38.331 v15.5.1 Sec 4.2.1) - enum rrc_nr_state_t { - RRC_NR_STATE_IDLE = 0, - RRC_NR_STATE_CONNECTED, - RRC_NR_STATE_CONNECTED_INACTIVE, - RRC_NR_STATE_N_ITEMS, - }; - const static char* rrc_nr_state_text[RRC_NR_STATE_N_ITEMS]; rrc_nr_state_t state = RRC_NR_STATE_IDLE; uint8_t transaction_id = 0; diff --git a/srsue/hdr/stack/rrc_nr/rrc_nr_metrics.h b/srsue/hdr/stack/rrc_nr/rrc_nr_metrics.h new file mode 100644 index 000000000..a224f9708 --- /dev/null +++ b/srsue/hdr/stack/rrc_nr/rrc_nr_metrics.h @@ -0,0 +1,32 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +#ifndef SRSUE_RRC_NR_METRICS_H +#define SRSUE_RRC_NR_METRICS_H + +namespace srsue { + +/// RRC states (3GPP 38.331 v15.5.1 Sec 4.2.1) +enum rrc_nr_state_t { + RRC_NR_STATE_IDLE = 0, + RRC_NR_STATE_CONNECTED, + RRC_NR_STATE_CONNECTED_INACTIVE, + RRC_NR_STATE_N_ITEMS, +}; + +struct rrc_nr_metrics_t { + rrc_nr_state_t state; +}; + +} // namespace srsue + +#endif // SRSUE_RRC_NR_METRICS_H diff --git a/srsue/hdr/ue_metrics_interface.h b/srsue/hdr/ue_metrics_interface.h index 7a42cc3f1..0fdf09957 100644 --- a/srsue/hdr/ue_metrics_interface.h +++ b/srsue/hdr/ue_metrics_interface.h @@ -22,6 +22,7 @@ #include "srsran/system/sys_metrics.h" #include "stack/mac/mac_metrics.h" #include "stack/rrc/rrc_metrics.h" +#include "stack/rrc_nr/rrc_nr_metrics.h" #include "stack/upper/gw_metrics.h" #include "stack/upper/nas_metrics.h" @@ -34,7 +35,7 @@ typedef struct { srsran::rlc_metrics_t rlc; nas_metrics_t nas; rrc_metrics_t rrc; - rrc_metrics_t rrc_nr; + rrc_nr_metrics_t rrc_nr; } stack_metrics_t; typedef struct { diff --git a/srsue/src/metrics_stdout.cc b/srsue/src/metrics_stdout.cc index 3f7533df9..b03f760a1 100644 --- a/srsue/src/metrics_stdout.cc +++ b/srsue/src/metrics_stdout.cc @@ -181,7 +181,7 @@ void metrics_stdout::set_metrics(const ue_metrics_t& metrics, const uint32_t per return; } - if (metrics.stack.rrc.state != RRC_STATE_CONNECTED) { + if (metrics.stack.rrc.state != RRC_STATE_CONNECTED && metrics.stack.rrc_nr.state != RRC_NR_STATE_CONNECTED) { fmt::print("--- disconnected ---\n"); return; } @@ -193,25 +193,30 @@ void metrics_stdout::set_metrics(const ue_metrics_t& metrics, const uint32_t per display_neighbours |= metrics.stack.rrc.neighbour_cells.size() > 0; } - bool is_nr = metrics.phy_nr.nof_active_cc > 0; + bool has_lte = metrics.phy.nof_active_cc > 0; + bool has_nr = metrics.phy_nr.nof_active_cc > 0; // print table header every 10 reports if (++n_reports > 10) { - print_table(display_neighbours, is_nr); + print_table(display_neighbours, has_nr); } // also print table header if neighbours are added/removed in between if (display_neighbours != table_has_neighbours) { - print_table(display_neighbours, is_nr); + print_table(display_neighbours, has_nr); } - for (uint32_t r = 0; r < metrics.phy.nof_active_cc; r++) { - set_metrics_helper(metrics.phy, metrics.stack.mac, metrics.stack.rrc, display_neighbours, r, false, !is_nr); + if (has_lte) { + for (uint32_t r = 0; r < metrics.phy.nof_active_cc; r++) { + set_metrics_helper(metrics.phy, metrics.stack.mac, metrics.stack.rrc, display_neighbours, r, false, !has_nr); + } } - for (uint32_t r = 0; r < metrics.phy_nr.nof_active_cc; r++) { - // Assumption LTE is followed by the NR carriers. - set_metrics_helper(metrics.phy_nr, metrics.stack.mac_nr, metrics.stack.rrc, display_neighbours, r, true, !is_nr); + if (has_nr) { + for (uint32_t r = 0; r < metrics.phy_nr.nof_active_cc; r++) { + // Assumption LTE is followed by the NR carriers. + set_metrics_helper(metrics.phy_nr, metrics.stack.mac_nr, metrics.stack.rrc, display_neighbours, r, true, !has_nr); + } } if (metrics.rf.rf_error) { diff --git a/srsue/src/stack/rrc_nr/rrc_nr.cc b/srsue/src/stack/rrc_nr/rrc_nr.cc index 2dbde5a8c..581641188 100644 --- a/srsue/src/stack/rrc_nr/rrc_nr.cc +++ b/srsue/src/stack/rrc_nr/rrc_nr.cc @@ -25,7 +25,7 @@ using namespace asn1; using namespace srsran; namespace srsue { -const char* rrc_nr::rrc_nr_state_text[] = {"IDLE", "CONNECTED", "CONNECTED-INACTIVE"}; +const static char* rrc_nr_state_text[] = {"IDLE", "CONNECTED", "CONNECTED-INACTIVE"}; rrc_nr::rrc_nr(srsran::task_sched_handle task_sched_) : logger(srslog::fetch_basic_logger("RRC-NR")), @@ -101,7 +101,11 @@ void rrc_nr::init_core_less() pdcp->add_bearer(args.coreless.drb_lcid, pdcp_cnfg); return; } -void rrc_nr::get_metrics(rrc_nr_metrics_t& m) {} + +void rrc_nr::get_metrics(rrc_nr_metrics_t& m) +{ + m.state = state; +} const char* rrc_nr::get_rb_name(uint32_t lcid) { diff --git a/srsue/src/stack/ue_stack_lte.cc b/srsue/src/stack/ue_stack_lte.cc index 15bff495b..63ddada6e 100644 --- a/srsue/src/stack/ue_stack_lte.cc +++ b/srsue/src/stack/ue_stack_lte.cc @@ -350,6 +350,7 @@ bool ue_stack_lte::get_metrics(stack_metrics_t* metrics) rlc.get_metrics(metrics.rlc, metrics.mac[0].nof_tti); nas.get_metrics(&metrics.nas); rrc.get_metrics(metrics.rrc); + rrc_nr.get_metrics(metrics.rrc_nr); pending_stack_metrics.push(metrics); }); // wait for result