From 48a7dd546ff4e621e1ddae5d0cfc52a7066e64c4 Mon Sep 17 00:00:00 2001 From: Piotr Gawlowicz Date: Tue, 21 Mar 2023 15:14:59 +0100 Subject: [PATCH] e2sm: move RIC content generation to SM --- srsgnb/hdr/stack/ric/e2ap.h | 11 ------ srsgnb/hdr/stack/ric/e2sm.h | 15 +++++++- srsgnb/hdr/stack/ric/e2sm_kpm.h | 2 + srsgnb/hdr/stack/ric/ric_subscription.h | 1 - srsgnb/src/stack/ric/e2sm_kpm.cc | 35 +++++++++++++++++ srsgnb/src/stack/ric/ric_subscription.cc | 48 +++++++----------------- 6 files changed, 64 insertions(+), 48 deletions(-) diff --git a/srsgnb/hdr/stack/ric/e2ap.h b/srsgnb/hdr/stack/ric/e2ap.h index 633a58bad..83074787b 100644 --- a/srsgnb/hdr/stack/ric/e2ap.h +++ b/srsgnb/hdr/stack/ric/e2ap.h @@ -13,7 +13,6 @@ #include "e2sm_kpm.h" #include "srsran/asn1/e2ap.h" -#include "srsran/asn1/e2sm_kpm_v2.h" #include "srsran/interfaces/e2_metrics_interface.h" #include "srsran/interfaces/enb_metrics_interface.h" #include "srsran/srsran.h" @@ -44,16 +43,6 @@ typedef struct { std::vector not_admitted_actions; } ric_subscription_reponse_t; -typedef struct { - uint32_t ric_requestor_id; - uint32_t ric_instance_id; - uint32_t ra_nfunction_id; - uint32_t ri_caction_id; - ri_cind_type_e indication_type; - srsran::unique_byte_buffer_t ri_cind_hdr; - srsran::unique_byte_buffer_t ri_cind_msg; -} ric_indication_t; - class e2ap { public: diff --git a/srsgnb/hdr/stack/ric/e2sm.h b/srsgnb/hdr/stack/ric/e2sm.h index 280a50b93..f34b9532e 100644 --- a/srsgnb/hdr/stack/ric/e2sm.h +++ b/srsgnb/hdr/stack/ric/e2sm.h @@ -34,6 +34,16 @@ struct E2AP_RIC_action { uint32_t sm_local_ric_action_id; }; +typedef struct { + uint32_t ric_requestor_id; + uint32_t ric_instance_id; + uint32_t ra_nfunction_id; + uint32_t ri_caction_id; + asn1::e2ap::ri_cind_type_e indication_type; + srsran::unique_byte_buffer_t ri_cind_hdr; + srsran::unique_byte_buffer_t ri_cind_msg; +} ric_indication_t; + class e2sm { public: @@ -51,8 +61,9 @@ public: virtual bool process_ric_event_trigger_definition(asn1::e2ap::ricsubscription_request_s subscription_request, RIC_event_trigger_definition& event_def) = 0; virtual bool process_ric_action_definition(asn1::e2ap::ri_caction_to_be_setup_item_s ric_action, - E2AP_RIC_action& action_entry) = 0; - virtual bool remove_ric_action_definition(E2AP_RIC_action& action_entry) = 0; + E2AP_RIC_action& action_entry) = 0; + virtual bool remove_ric_action_definition(E2AP_RIC_action& action_entry) = 0; + virtual bool execute_action_fill_ric_indication(E2AP_RIC_action& action_entry, ric_indication_t& ric_indication) = 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 4040c6406..f62a0dd0a 100644 --- a/srsgnb/hdr/stack/ric/e2sm_kpm.h +++ b/srsgnb/hdr/stack/ric/e2sm_kpm.h @@ -51,6 +51,8 @@ public: virtual bool process_ric_action_definition(asn1::e2ap::ri_caction_to_be_setup_item_s ric_action, E2AP_RIC_action& action_entry); virtual bool remove_ric_action_definition(E2AP_RIC_action& action_entry); + virtual bool execute_action_fill_ric_indication(E2AP_RIC_action& action_entry, ric_indication_t& ric_indication); + bool generate_indication_header(E2SM_KPM_RIC_ind_header hdr, srsran::unique_byte_buffer_t& buf); bool generate_indication_message(E2SM_KPM_RIC_ind_message msg, srsran::unique_byte_buffer_t& buf); diff --git a/srsgnb/hdr/stack/ric/ric_subscription.h b/srsgnb/hdr/stack/ric/ric_subscription.h index 9b4c873af..49b3ea6c0 100644 --- a/srsgnb/hdr/stack/ric/ric_subscription.h +++ b/srsgnb/hdr/stack/ric/ric_subscription.h @@ -42,7 +42,6 @@ private: uint32_t ric_requestor_id; uint32_t ric_instance_id; uint16_t ra_nfunction_id; - uint16_t ri_caction_id; e2sm* sm_ptr = nullptr; uint32_t reporting_period = 0; // ms diff --git a/srsgnb/src/stack/ric/e2sm_kpm.cc b/srsgnb/src/stack/ric/e2sm_kpm.cc index 7b783d517..acc5d6c4e 100644 --- a/srsgnb/src/stack/ric/e2sm_kpm.cc +++ b/srsgnb/src/stack/ric/e2sm_kpm.cc @@ -196,6 +196,41 @@ bool e2sm_kpm::remove_ric_action_definition(E2AP_RIC_action& action_entry) return false; } +bool e2sm_kpm::execute_action_fill_ric_indication(E2AP_RIC_action& action_entry, ric_indication_t& ric_indication) +{ + using namespace asn1::e2ap; + using namespace asn1::e2sm_kpm; + + ric_indication.indication_type = ri_cind_type_opts::report; + + E2SM_KPM_RIC_ind_header ric_ind_header; + ric_ind_header.collet_start_time = 0x12345; + ric_indication.ri_cind_hdr = srsran::make_byte_buffer(); + this->generate_indication_header(ric_ind_header, ric_indication.ri_cind_hdr); + + E2SM_KPM_RIC_ind_message ric_ind_message; + ric_ind_message.ind_msg_format = e2_sm_kpm_ind_msg_s::ind_msg_formats_c_::types_opts::ind_msg_format1; + + ric_ind_message.meas_data.resize(1); + ric_ind_message.meas_data[0].meas_record.resize(5); + for (uint32_t i = 0; i < ric_ind_message.meas_data[0].meas_record.size(); i++) { + ric_ind_message.meas_data[0].meas_record[i].set_integer() = i * 1000; + } + + ric_ind_message.meas_info_list.resize(1); + ric_ind_message.meas_info_list[0].meas_type.set_meas_name().from_string("RRU.PrbTotDl"); + ric_ind_message.meas_info_list[0].label_info_list.resize(1); + ric_ind_message.meas_info_list[0].label_info_list[0].meas_label.no_label_present = true; + ric_ind_message.meas_info_list[0].label_info_list[0].meas_label.no_label = + asn1::e2sm_kpm::meas_label_s::no_label_opts::true_value; + + // ric_ind_message.granul_period = 12345; // not implemented by flexric and crashes it + + ric_indication.ri_cind_msg = srsran::make_byte_buffer(); + this->generate_indication_message(ric_ind_message, ric_indication.ri_cind_msg); + return true; +} + bool e2sm_kpm::generate_indication_header(E2SM_KPM_RIC_ind_header hdr, srsran::unique_byte_buffer_t& buf) { using namespace asn1::e2sm_kpm; diff --git a/srsgnb/src/stack/ric/ric_subscription.cc b/srsgnb/src/stack/ric/ric_subscription.cc index 1db857080..7b69f8aeb 100644 --- a/srsgnb/src/stack/ric/ric_subscription.cc +++ b/srsgnb/src/stack/ric/ric_subscription.cc @@ -130,44 +130,24 @@ void ric_client::ric_subscription::delete_subscription() void ric_client::ric_subscription::send_ric_indication() { - printf("Sending RIC indication msg to RIC Requestor ID: %i\n", ric_requestor_id); - ric_indication_t ric_indication; - ric_indication.ric_requestor_id = ric_requestor_id; - ric_indication.ric_instance_id = ric_instance_id; - ric_indication.ra_nfunction_id = ra_nfunction_id; - ric_indication.ri_caction_id = ri_caction_id; - ric_indication.indication_type = ri_cind_type_opts::report; - - e2sm_kpm* sm_kpm_ptr = dynamic_cast(sm_ptr); - - E2SM_KPM_RIC_ind_header ric_ind_header; - ric_ind_header.collet_start_time = 0x12345; - ric_indication.ri_cind_hdr = srsran::make_byte_buffer(); - sm_kpm_ptr->generate_indication_header(ric_ind_header, ric_indication.ri_cind_hdr); - - E2SM_KPM_RIC_ind_message ric_ind_message; - ric_ind_message.ind_msg_format = e2_sm_kpm_ind_msg_s::ind_msg_formats_c_::types_opts::ind_msg_format1; - - ric_ind_message.meas_data.resize(1); - ric_ind_message.meas_data[0].meas_record.resize(5); - for (uint32_t i = 0; i < ric_ind_message.meas_data[0].meas_record.size(); i++) { - ric_ind_message.meas_data[0].meas_record[i].set_integer() = i * 1000; + if (sm_ptr == nullptr) { + parent->logger.error("SM pointer not set in subscription: %i\n", ric_requestor_id); + return; } - ric_ind_message.meas_info_list.resize(1); - ric_ind_message.meas_info_list[0].meas_type.set_meas_name().from_string("RRU.PrbTotDl"); - ric_ind_message.meas_info_list[0].label_info_list.resize(1); - ric_ind_message.meas_info_list[0].label_info_list[0].meas_label.no_label_present = true; - ric_ind_message.meas_info_list[0].label_info_list[0].meas_label.no_label = - asn1::e2sm_kpm::meas_label_s::no_label_opts::true_value; - - // ric_ind_message.granul_period = 12345; // not implemented by flexric and crashes it + for (auto& action : admitted_actions) { + printf("Sending RIC indication msg to RIC Requestor ID: %i\n", ric_requestor_id); + ric_indication_t ric_indication; + ric_indication.ric_requestor_id = ric_requestor_id; + ric_indication.ric_instance_id = ric_instance_id; + ric_indication.ra_nfunction_id = ra_nfunction_id; + ric_indication.ri_caction_id = action.ric_action_id; - ric_indication.ri_cind_msg = srsran::make_byte_buffer(); - sm_kpm_ptr->generate_indication_message(ric_ind_message, ric_indication.ri_cind_msg); + sm_ptr->execute_action_fill_ric_indication(action, ric_indication); - e2_ap_pdu_c send_pdu = parent->e2ap_.generate_indication(ric_indication); - parent->queue_send_e2ap_pdu(send_pdu); + e2_ap_pdu_c send_pdu = parent->e2ap_.generate_indication(ric_indication); + parent->queue_send_e2ap_pdu(send_pdu); + } // reschedule sending RIC indication reporting_timer.run();