From 83e72800107026c5a7602f57f2a184151c3c96f2 Mon Sep 17 00:00:00 2001 From: Piotr Gawlowicz Date: Mon, 20 Mar 2023 22:42:10 +0100 Subject: [PATCH] e2ap: update RIC indication generation --- srsgnb/hdr/stack/ric/e2ap.h | 15 ++++----- srsgnb/hdr/stack/ric/e2sm_kpm.h | 8 ++--- srsgnb/src/stack/ric/e2ap.cc | 31 +++++++++++------- srsgnb/src/stack/ric/e2sm_kpm.cc | 4 +-- srsgnb/src/stack/ric/ric_subscription.cc | 40 ++++++++++++++++-------- 5 files changed, 61 insertions(+), 37 deletions(-) diff --git a/srsgnb/hdr/stack/ric/e2ap.h b/srsgnb/hdr/stack/ric/e2ap.h index 61037b156..c40faaac7 100644 --- a/srsgnb/hdr/stack/ric/e2ap.h +++ b/srsgnb/hdr/stack/ric/e2ap.h @@ -45,13 +45,13 @@ typedef struct { } 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; - RIC_indication_header indication_header; - RIC_indication_message indication_message; + 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 @@ -73,6 +73,7 @@ public: int process_reset_response(reset_resp_s reset_response); int get_reset_id(); bool has_setup_response() { return setup_response_received; } + bool get_func_desc(uint32_t ran_func_id, RANfunction_description& fdesc); private: srslog::basic_logger& logger; diff --git a/srsgnb/hdr/stack/ric/e2sm_kpm.h b/srsgnb/hdr/stack/ric/e2sm_kpm.h index acb6cee57..f3f6e9bdf 100644 --- a/srsgnb/hdr/stack/ric/e2sm_kpm.h +++ b/srsgnb/hdr/stack/ric/e2sm_kpm.h @@ -18,7 +18,7 @@ #ifndef RIC_E2SM_KPM_H #define RIC_E2SM_KPM_H -struct RIC_indication_header { +struct E2SM_KPM_RIC_ind_header { uint32_t collet_start_time; std::string file_formatversion; std::string sender_name; @@ -26,7 +26,7 @@ struct RIC_indication_header { std::string vendor_name; }; -struct RIC_indication_message { +struct E2SM_KPM_RIC_ind_message { asn1::e2sm_kpm::e2_sm_kpm_ind_msg_s::ind_msg_formats_c_::types ind_msg_format; asn1::e2sm_kpm::meas_data_l meas_data; asn1::e2sm_kpm::meas_info_list_l meas_info_list; @@ -46,8 +46,8 @@ public: virtual bool generate_ran_function_description(RANfunction_description& desc, srsran::unique_byte_buffer_t& buf); int process_ric_action_definition(); - bool generate_indication_header(RIC_indication_header hdr, srsran::unique_byte_buffer_t& buf); - bool generate_indication_message(RIC_indication_message msg, srsran::unique_byte_buffer_t& buf); + 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); private: srslog::basic_logger& logger; diff --git a/srsgnb/src/stack/ric/e2ap.cc b/srsgnb/src/stack/ric/e2ap.cc index fae94590a..b7fa254d9 100644 --- a/srsgnb/src/stack/ric/e2ap.cc +++ b/srsgnb/src/stack/ric/e2ap.cc @@ -15,6 +15,15 @@ e2ap::e2ap(srslog::basic_logger& logger, srsenb::e2_interface_metrics* _gnb_metr ran_functions[local_ran_function_id] = add_func; } +bool e2ap::get_func_desc(uint32_t ran_func_id, RANfunction_description& fdesc) +{ + if (ran_functions.count(ran_func_id)) { + fdesc = ran_functions.at(ran_func_id); + return true; + } + return false; +} + e2_ap_pdu_c e2ap::generate_setup_request() { e2_ap_pdu_c pdu; @@ -188,17 +197,17 @@ e2_ap_pdu_c e2ap::generate_indication(ric_indication_t& ric_indication) indication->ri_cind_type.crit = asn1::crit_opts::reject; indication->ri_cind_type.value = ric_indication.indication_type; - indication->ri_cind_hdr.crit = asn1::crit_opts::reject; - srsran::unique_byte_buffer_t header_buf = srsran::make_byte_buffer(); - e2sm_.generate_indication_header(ric_indication.indication_header, header_buf); - indication->ri_cind_hdr->resize(header_buf->N_bytes); - std::copy(header_buf->msg, header_buf->msg + header_buf->N_bytes, indication->ri_cind_hdr->data()); - - indication->ri_cind_msg.crit = asn1::crit_opts::reject; - srsran::unique_byte_buffer_t msg_buf = srsran::make_byte_buffer(); - e2sm_.generate_indication_message(ric_indication.indication_message, msg_buf); - indication->ri_cind_msg->resize(msg_buf->N_bytes); - std::copy(msg_buf->msg, msg_buf->msg + msg_buf->N_bytes, indication->ri_cind_msg->data()); + indication->ri_cind_hdr.crit = asn1::crit_opts::reject; + indication->ri_cind_hdr->resize(ric_indication.ri_cind_hdr->N_bytes); + std::copy(ric_indication.ri_cind_hdr->msg, + ric_indication.ri_cind_hdr->msg + ric_indication.ri_cind_hdr->N_bytes, + indication->ri_cind_hdr->data()); + + indication->ri_cind_msg.crit = asn1::crit_opts::reject; + indication->ri_cind_msg->resize(ric_indication.ri_cind_msg->N_bytes); + std::copy(ric_indication.ri_cind_msg->msg, + ric_indication.ri_cind_msg->msg + ric_indication.ri_cind_msg->N_bytes, + indication->ri_cind_msg->data()); return pdu; } diff --git a/srsgnb/src/stack/ric/e2sm_kpm.cc b/srsgnb/src/stack/ric/e2sm_kpm.cc index 5d015c75a..9c2e22f65 100644 --- a/srsgnb/src/stack/ric/e2sm_kpm.cc +++ b/srsgnb/src/stack/ric/e2sm_kpm.cc @@ -88,7 +88,7 @@ int e2sm_kpm::process_ric_action_definition() return 0; } -bool e2sm_kpm::generate_indication_header(RIC_indication_header hdr, srsran::unique_byte_buffer_t& buf) +bool e2sm_kpm::generate_indication_header(E2SM_KPM_RIC_ind_header hdr, srsran::unique_byte_buffer_t& buf) { using namespace asn1::e2sm_kpm; e2_sm_kpm_ind_hdr_s e2_sm_kpm_ind_hdr; @@ -108,7 +108,7 @@ bool e2sm_kpm::generate_indication_header(RIC_indication_header hdr, srsran::uni return true; } -bool e2sm_kpm::generate_indication_message(RIC_indication_message msg, srsran::unique_byte_buffer_t& buf) +bool e2sm_kpm::generate_indication_message(E2SM_KPM_RIC_ind_message msg, srsran::unique_byte_buffer_t& buf) { using namespace asn1::e2sm_kpm; e2_sm_kpm_ind_msg_s e2_sm_kpm_ind_msg; diff --git a/srsgnb/src/stack/ric/ric_subscription.cc b/srsgnb/src/stack/ric/ric_subscription.cc index 6ce87b54e..d4ef55bf7 100644 --- a/srsgnb/src/stack/ric/ric_subscription.cc +++ b/srsgnb/src/stack/ric/ric_subscription.cc @@ -70,26 +70,40 @@ void ric_client::ric_subscription::send_ric_indication() 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; - ric_indication.indication_type = ri_cind_type_opts::report; - ric_indication.indication_header.collet_start_time = 0x12345; + RANfunction_description ran_func_desc; + e2sm* sm_ptr = nullptr; + if (!parent->e2ap_.get_func_desc(ra_nfunction_id, ran_func_desc)) { + return; + } + + e2sm_kpm* sm_kpm_ptr = dynamic_cast(ran_func_desc.sm_ptr); - ric_indication.indication_message.ind_msg_format = - e2_sm_kpm_ind_msg_s::ind_msg_formats_c_::types_opts::ind_msg_format1; + 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); - ric_indication.indication_message.meas_data.resize(1); - ric_indication.indication_message.meas_data[0].meas_record.resize(5); - for (uint32_t i = 0; i < ric_indication.indication_message.meas_data[0].meas_record.size(); i++) { - ric_indication.indication_message.meas_data[0].meas_record[i].set_integer() = i * 1000; + 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_indication.indication_message.meas_info_list.resize(1); - ric_indication.indication_message.meas_info_list[0].meas_type.set_meas_name().from_string("RRU.PrbTotDl"); - ric_indication.indication_message.meas_info_list[0].label_info_list.resize(1); - ric_indication.indication_message.meas_info_list[0].label_info_list[0].meas_label.no_label_present = true; - ric_indication.indication_message.meas_info_list[0].label_info_list[0].meas_label.no_label = + 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_indication.ri_cind_msg = srsran::make_byte_buffer(); + sm_kpm_ptr->generate_indication_message(ric_ind_message, ric_indication.ri_cind_msg); + e2_ap_pdu_c send_pdu = parent->e2ap_.generate_indication(ric_indication); parent->queue_send_e2ap_pdu(send_pdu);