diff --git a/srsgnb/hdr/stack/ric/e2sm_kpm_common.h b/srsgnb/hdr/stack/ric/e2sm_kpm_common.h index 9a2a873f6..086a82ed1 100644 --- a/srsgnb/hdr/stack/ric/e2sm_kpm_common.h +++ b/srsgnb/hdr/stack/ric/e2sm_kpm_common.h @@ -49,6 +49,8 @@ enum e2sm_kpm_label_enum { UNKNOWN_LABEL = 0x8000 }; +std::string e2sm_kpm_label_2_str(e2sm_kpm_label_enum label); + /* Scopes supported for a metric */ enum e2sm_kpm_metric_scope_enum { ENB_LEVEL = 0x0001, diff --git a/srsgnb/src/stack/ric/CMakeLists.txt b/srsgnb/src/stack/ric/CMakeLists.txt index 0082f7333..86ba74dbd 100644 --- a/srsgnb/src/stack/ric/CMakeLists.txt +++ b/srsgnb/src/stack/ric/CMakeLists.txt @@ -1,4 +1,4 @@ -set(SOURCES ric_client.cc ric_subscription.cc e2ap.cc e2sm_kpm.cc e2sm_kpm_report_service.cc) +set(SOURCES ric_client.cc ric_subscription.cc e2ap.cc e2sm_kpm_common.cc e2sm_kpm.cc e2sm_kpm_report_service.cc) add_library(srsgnb_ric STATIC ${SOURCES}) target_link_libraries(srsgnb_ric srsran_asn1 ric_e2) diff --git a/srsgnb/src/stack/ric/e2sm_kpm.cc b/srsgnb/src/stack/ric/e2sm_kpm.cc index b8be3f4de..5696bcaa5 100644 --- a/srsgnb/src/stack/ric/e2sm_kpm.cc +++ b/srsgnb/src/stack/ric/e2sm_kpm.cc @@ -238,7 +238,7 @@ bool e2sm_kpm::generate_ric_indication_content(E2AP_RIC_action_t& action_entry, return false; } - ric_indication.indication_type = ri_cind_type_opts::report; + ric_indication.indication_type = ri_cind_type_opts::report; // header is the same for all RIC service styles, i.e., type 1 ric_indication.ri_cind_hdr = srsran::make_byte_buffer(); diff --git a/srsgnb/src/stack/ric/e2sm_kpm_common.cc b/srsgnb/src/stack/ric/e2sm_kpm_common.cc new file mode 100644 index 000000000..49f808381 --- /dev/null +++ b/srsgnb/src/stack/ric/e2sm_kpm_common.cc @@ -0,0 +1,32 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2022 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. + * + * + */ + +#include "srsgnb/hdr/stack/ric/e2sm_kpm_common.h" + +std::string e2sm_kpm_label_2_str(e2sm_kpm_label_enum label) +{ + switch (label) { + case NO_LABEL: + return "NO_LABEL"; + case MIN_LABEL: + return "MIN_LABEL"; + case MAX_LABEL: + return "MAX_LABEL"; + case AVG_LABEL: + return "AVG_LABEL"; + case SUM_LABEL: + return "SUM_LABEL"; + default: + return "UNKNOWN_LABEL"; + } +} \ No newline at end of file diff --git a/srsgnb/src/stack/ric/e2sm_kpm_report_service.cc b/srsgnb/src/stack/ric/e2sm_kpm_report_service.cc index d019b8d67..8633c8f0a 100644 --- a/srsgnb/src/stack/ric/e2sm_kpm_report_service.cc +++ b/srsgnb/src/stack/ric/e2sm_kpm_report_service.cc @@ -192,6 +192,7 @@ bool e2sm_kpm_report_service_style1::process_ric_action_definition(e2sm_kpm* } } + std::map admitted_metrics; meas_info_list = action_definition.meas_info_list; for (uint32_t i = 0; i < meas_info_list.size(); i++) { std::string meas_name = meas_info_list[i].meas_type.meas_name().to_string(); @@ -201,30 +202,61 @@ bool e2sm_kpm_report_service_style1::process_ric_action_definition(e2sm_kpm* return false; } - printf("Admitted action: measurement name: \"%s\" with the following labels: \n", meas_name.c_str()); - // TODO: add all labels defined in e2sm_kpm doc, if at least one label not supported do not admit action? + uint32_t nof_labels = 0; + // TODO: add all labels defined in e2sm_kpm doc, make this part generic and put to base class for (uint32_t l = 0; l < meas_info_list[i].label_info_list.size(); l++) { if (meas_info_list[i].label_info_list[l].meas_label.no_label_present) { if (metric_definition.supported_labels & NO_LABEL) { - printf("--- Label %i: NO LABEL\n", i); + nof_labels++; + admitted_metrics[meas_name] = NO_LABEL; + } else { + printf("Unsupported label: NO_LABEL for metric \"%s\" --> do not admit action\n", meas_name.c_str()); + return false; } } if (meas_info_list[i].label_info_list[l].meas_label.min_present) { if (metric_definition.supported_labels & MIN_LABEL) { - printf("--- Label %i: MIN\n", i); + nof_labels++; + admitted_metrics[meas_name] = MIN_LABEL; + } else { + printf("Unsupported label: MIN_LABEL for metric \"%s\" --> do not admit action\n", meas_name.c_str()); + return false; } } if (meas_info_list[i].label_info_list[l].meas_label.max_present) { if (metric_definition.supported_labels & MAX_LABEL) { - printf("--- Label %i: MAX\n", i); + nof_labels++; + admitted_metrics[meas_name] = MAX_LABEL; + } else { + printf("Unsupported label: MAX_LABEL for metric \"%s\" --> do not admit action\n", meas_name.c_str()); + return false; } } if (meas_info_list[i].label_info_list[l].meas_label.avg_present) { if (metric_definition.supported_labels & AVG_LABEL) { - printf("--- Label %i: AVG\n", i); + nof_labels++; + admitted_metrics[meas_name] = AVG_LABEL; + } else { + printf("Unsupported label: AVG_LABEL for metric \"%s\" --> do not admit action\n", meas_name.c_str()); + return false; } } } + + // Note: currently we use labels as choice (i.e., only one can be present) as documentation is not clear about it + if (nof_labels > 1) { + printf("Only one label per metric can be present, meas: \"%s\" has %i labels --> do not admit action\n", + meas_name.c_str(), + nof_labels); + return false; + } + } + + printf("Admitted action with the following metrics and labels: \n"); + for (const auto& it : admitted_metrics) { + std::string meas_name = it.first; + std::string label_str = e2sm_kpm_label_2_str(it.second); + printf("--- Metric: \"%s\" with label: %s\n", meas_name.c_str(), label_str.c_str()); } return true;