From d5d876ecb033c8ecc0cc521ec1b0543597fb1af9 Mon Sep 17 00:00:00 2001 From: Piotr Gawlowicz Date: Thu, 23 Mar 2023 10:33:32 +0100 Subject: [PATCH] e2ap: send metrics to all registred e2am instances --- .../srsran/interfaces/e2_metrics_interface.h | 4 ++++ srsenb/hdr/metrics_e2.h | 4 ++++ srsenb/src/metrics_e2.cc | 21 +++++++++++++++++++ srsgnb/hdr/stack/ric/e2sm.h | 4 ++++ srsgnb/hdr/stack/ric/e2sm_kpm.h | 4 ++++ srsgnb/src/stack/ric/e2ap.cc | 3 +++ srsgnb/src/stack/ric/e2sm_kpm.cc | 9 ++++++++ 7 files changed, 49 insertions(+) diff --git a/lib/include/srsran/interfaces/e2_metrics_interface.h b/lib/include/srsran/interfaces/e2_metrics_interface.h index 0328c56d8..d09a8d53b 100644 --- a/lib/include/srsran/interfaces/e2_metrics_interface.h +++ b/lib/include/srsran/interfaces/e2_metrics_interface.h @@ -10,6 +10,7 @@ * */ +#include "srsgnb/hdr/stack/ric/e2sm.h" #include "srsran/common/common.h" #include "srsran/common/interfaces_common.h" #include "srsran/interfaces/enb_metrics_interface.h" @@ -24,6 +25,9 @@ class e2_interface_metrics { public: virtual bool pull_metrics(enb_metrics_t* m) = 0; + + virtual bool register_e2sm(e2sm* sm) = 0; + virtual bool unregister_e2sm(e2sm* sm) = 0; }; } // namespace srsenb diff --git a/srsenb/hdr/metrics_e2.h b/srsenb/hdr/metrics_e2.h index 63aea1842..873c41883 100644 --- a/srsenb/hdr/metrics_e2.h +++ b/srsenb/hdr/metrics_e2.h @@ -36,11 +36,15 @@ public: bool pull_metrics(enb_metrics_t* m) override; void stop(){}; + bool register_e2sm(e2sm* sm) override; + bool unregister_e2sm(e2sm* sm) override; + private: std::atomic do_print = {false}; uint8_t n_reports = 0; std::queue metrics_queue; enb_metrics_interface* enb = nullptr; + std::vector e2sm_vec; }; } // namespace srsenb diff --git a/srsenb/src/metrics_e2.cc b/srsenb/src/metrics_e2.cc index ffc0f897f..4be8cb701 100644 --- a/srsenb/src/metrics_e2.cc +++ b/srsenb/src/metrics_e2.cc @@ -23,6 +23,27 @@ void metrics_e2::set_metrics(const enb_metrics_t& m, const uint32_t period_usec) } else { metrics_queue.push(m); } + + // send new enb metrics to all registered SMs + for (auto sm_ : e2sm_vec) { + sm_->receive_e2_metrics_callback(m); + } +} + +bool metrics_e2::register_e2sm(e2sm* sm) +{ + e2sm_vec.push_back(sm); + return true; +} + +bool metrics_e2::unregister_e2sm(e2sm* sm) +{ + auto it = std::find(e2sm_vec.begin(), e2sm_vec.end(), sm); + if (it != e2sm_vec.end()) { + e2sm_vec.erase(it); + return true; + } + return false; } bool metrics_e2::pull_metrics(enb_metrics_t* m) diff --git a/srsgnb/hdr/stack/ric/e2sm.h b/srsgnb/hdr/stack/ric/e2sm.h index 242936812..bb2cf1ed0 100644 --- a/srsgnb/hdr/stack/ric/e2sm.h +++ b/srsgnb/hdr/stack/ric/e2sm.h @@ -13,12 +13,14 @@ #include "srsran/asn1/e2ap.h" #include "srsran/common/byte_buffer.h" +#include "srsran/interfaces/enb_metrics_interface.h" #include "srsran/srsran.h" #ifndef SRSRAN_E2SM_H #define SRSRAN_E2SM_H using namespace asn1::e2ap; +using namespace srsenb; struct RANfunction_description; @@ -67,6 +69,8 @@ public: virtual bool remove_ric_action_definition(E2AP_RIC_action_t& action_entry) = 0; virtual bool execute_action_fill_ric_indication(E2AP_RIC_action_t& action_entry, ric_indication_t& ric_indication) = 0; + virtual void receive_e2_metrics_callback(const enb_metrics_t& m) = 0; + protected: uint32_t _generate_local_action_id() { return _registered_action_id_gen++; }; diff --git a/srsgnb/hdr/stack/ric/e2sm_kpm.h b/srsgnb/hdr/stack/ric/e2sm_kpm.h index ed7a47a26..4e6d5d4b3 100644 --- a/srsgnb/hdr/stack/ric/e2sm_kpm.h +++ b/srsgnb/hdr/stack/ric/e2sm_kpm.h @@ -55,6 +55,8 @@ public: virtual bool remove_ric_action_definition(E2AP_RIC_action_t& action_entry); virtual bool execute_action_fill_ric_indication(E2AP_RIC_action_t& action_entry, ric_indication_t& ric_indication); + virtual void receive_e2_metrics_callback(const enb_metrics_t& m); + private: bool _process_ric_action_definition_format1(e2_sm_kpm_action_definition_format1_s& action_definition_format1); bool _process_ric_action_definition_format2(e2_sm_kpm_action_definition_format2_s& action_definition_format2); @@ -77,6 +79,8 @@ private: std::map registered_actions; srsran_random_t random_gen; + + enb_metrics_t last_enb_metrics; }; #endif /*E2SM_KPM*/ diff --git a/srsgnb/src/stack/ric/e2ap.cc b/srsgnb/src/stack/ric/e2ap.cc index b62b44e16..6b8b40dbc 100644 --- a/srsgnb/src/stack/ric/e2ap.cc +++ b/srsgnb/src/stack/ric/e2ap.cc @@ -10,6 +10,9 @@ e2ap::e2ap(srslog::basic_logger& logger, gnb_metrics = _gnb_metrics; e2_procedure_timeout = task_sched_ptr->get_unique_timer(); + // register SM to receive enb metrics + gnb_metrics->register_e2sm(&e2sm_); + // add SMs to map uint32_t local_ran_function_id = 147; RANfunction_description add_func; diff --git a/srsgnb/src/stack/ric/e2sm_kpm.cc b/srsgnb/src/stack/ric/e2sm_kpm.cc index 9897ac716..751931348 100644 --- a/srsgnb/src/stack/ric/e2sm_kpm.cc +++ b/srsgnb/src/stack/ric/e2sm_kpm.cc @@ -33,6 +33,15 @@ e2sm_kpm::e2sm_kpm(srslog::basic_logger& logger_) : e2sm(short_name, oid, func_d } } +void e2sm_kpm::receive_e2_metrics_callback(const enb_metrics_t& m) +{ + last_enb_metrics = m; + logger.debug("e2sm_kpm received new enb metrics, CPU0 Load: %.1f", last_enb_metrics.sys.cpu_load[0]); + + // TODO: for INSERT type of reporting check if a specified metrics exceeds predefined thresholds, + // if so then send RIC indication throught proper subscription +} + bool e2sm_kpm::generate_ran_function_description(RANfunction_description& desc, ra_nfunction_item_s& ran_func) { desc.function_shortname = short_name;