diff --git a/CMakeLists.txt b/CMakeLists.txt index 0b48680830..4c2baa4de3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -289,6 +289,15 @@ add_definitions(-DHAVE_NETINET_IN_H) set(E2_AGENT "OFF" CACHE STRING "O-RAN-compliant E2 Agent") set_property(CACHE E2_AGENT PROPERTY STRINGS "ON" "OFF") +set(E2AP_VERSION "E2AP_V2" CACHE STRING "E2AP version") +set_property(CACHE E2AP_VERSION PROPERTY STRINGS "E2AP_V1" "E2AP_V2" "E2AP_V3") +message(STATUS "Selected E2AP_VERSION: ${E2AP_VERSION}") + +set(KPM_VERSION "KPM_V2" CACHE STRING "The KPM SM version to use") +set_property(CACHE KPM_VERSION PROPERTY STRINGS "KPM_V2" "KPM_V3") +message(STATUS "Selected KPM Version: ${KPM_VERSION}") + + ################################################## # ASN.1 grammar C code generation & dependencies # ################################################## @@ -1409,9 +1418,11 @@ add_library(L2 ) target_link_libraries(L2 PRIVATE x2ap s1ap lte_rrc m2ap) target_link_libraries(L2 PRIVATE asn1_lte_rrc_hdrs asn1_nr_rrc_hdrs) + if(E2_AGENT) target_link_libraries(L2 PUBLIC e2_agent e2_ran_func) target_compile_definitions(L2 PRIVATE E2_AGENT) + target_compile_definitions(L2 PRIVATE ${E2AP_VERSION} ${KPM_VERSION}) endif() @@ -1443,6 +1454,7 @@ target_link_libraries(e1_pdcp_if PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs) target_link_libraries(L2_NR PRIVATE f1ap x2ap s1ap ngap nr_rrc e1ap nr_rlc) if(E2_AGENT) target_link_libraries(L2_NR PUBLIC e2_agent e2_ran_func) + target_compile_definitions(L2_NR PRIVATE ${E2AP_VERSION} ${KPM_VERSION}) target_compile_definitions(L2_NR PRIVATE E2_AGENT) endif() @@ -1965,6 +1977,7 @@ target_link_libraries(lte-softmodem PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs) if(E2_AGENT) target_compile_definitions(lte-softmodem PRIVATE E2_AGENT) + target_compile_definitions(lte-softmodem PRIVATE ${E2AP_VERSION} ${KPM_VERSION}) endif() add_executable(oairu @@ -2061,6 +2074,11 @@ target_link_libraries(nr-softmodem PRIVATE target_link_libraries(nr-softmodem PRIVATE pthread m CONFIG_LIB rt sctp) target_link_libraries(nr-softmodem PRIVATE ${T_LIB}) target_link_libraries(nr-softmodem PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs) +target_link_libraries(nr-softmodem PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs) +if(E2_AGENT) + target_compile_definitions(nr-softmodem PRIVATE ${E2AP_VERSION} ${KPM_VERSION}) +endif() + add_dependencies(nr-softmodem ldpc_orig ldpc_optim ldpc_optim8seg ldpc) diff --git a/executables/nr-softmodem.c b/executables/nr-softmodem.c index 31bde16b97..553f21a9fb 100644 --- a/executables/nr-softmodem.c +++ b/executables/nr-softmodem.c @@ -696,10 +696,13 @@ int main( int argc, char **argv ) { // OAI Wrapper e2_agent_args_t oai_args = RCconfig_NR_E2agent(); - AssertFatal(oai_args.sm_dir != NULL , "Please, specify the directory where the SMs are located in the config file, i.e., e2_agent = {near_ric_ip_addr = \"127.0.0.1\"; sm_dir = \"/usr/local/lib/flexric/\");} "); + AssertFatal(oai_args.sm_dir != NULL , "Please, specify the directory where the SMs are located in the config file, i.e., add in config file the next line: e2_agent = {near_ric_ip_addr = \"127.0.0.1\"; sm_dir = \"/usr/local/lib/flexric/\");} "); + AssertFatal(oai_args.ip != NULL , "Please, specify the IP address of the nearRT-RIC in the config file, i.e., e2_agent = {near_ric_ip_addr = \"127.0.0.1\"; sm_dir = \"/usr/local/lib/flexric/\""); - fr_args_t args = {.ip = oai_args.ip}; // init_fr_args(0, NULL); + printf("After RCconfig_NR_E2agent %s %s \n",oai_args.sm_dir, oai_args.ip ); + + fr_args_t args = { .ip = oai_args.ip }; // init_fr_args(0, NULL); memcpy(args.libs_dir, oai_args.sm_dir, 128); sleep(1); @@ -726,6 +729,7 @@ int main( int argc, char **argv ) { printf("[E2 NODE]: mcc = %d mnc = %d mnc_digit = %d nb_id = %d \n", mcc, mnc, mnc_digit_len, nb_id); + printf("[E2 NODE]: Args %s %s \n", args.ip, args.libs_dir); init_agent_api(mcc, mnc, mnc_digit_len, nb_id, cu_du_id, node_type, io, &args); // } diff --git a/openair2/E2AP/CMakeLists.txt b/openair2/E2AP/CMakeLists.txt index 865eac5ffa..c5603849a3 100644 --- a/openair2/E2AP/CMakeLists.txt +++ b/openair2/E2AP/CMakeLists.txt @@ -29,6 +29,9 @@ else() message(FATAL_ERROR "Unknown building type. Either choose a static or a dynamic library") endif() +####### +## E2AP encoding and versioning +####### set(E2AP_ENCODING "ASN" CACHE STRING "The E2AP encoding to use") set_property(CACHE E2AP_ENCODING PROPERTY STRINGS "ASN" "FLATBUFFERS") @@ -76,6 +79,35 @@ set(SM_ENCODING_GTP "PLAIN" CACHE STRING "The GTP SM encoding to use") set_property(CACHE SM_ENCODING_GTP PROPERTY STRINGS "PLAIN") message(STATUS "Selected GTP SM_ENCODING: ${SM_ENCODING_GTP}") + +if(E2AP_VERSION STREQUAL "E2AP_V1") + add_library(e2ap_ran_func_obj OBJECT + flexric/src/lib/e2ap/v1_01/e2ap_types/common/e2ap_ran_function.c ) + add_library(e2ap_plmn_obj OBJECT + flexric/src/lib/e2ap/v1_01/e2ap_types/common/e2ap_plmn.c ) + add_library(e2ap_global_node_id_obj OBJECT + flexric/src/lib/e2ap/v1_01/e2ap_types/common/e2ap_global_node_id.c ) +elseif(E2AP_VERSION STREQUAL "E2AP_V2") + add_library(e2ap_ran_func_obj OBJECT + flexric/src/lib/e2ap/v2_03/e2ap_types/common/e2ap_ran_function.c ) + add_library(e2ap_plmn_obj OBJECT + flexric/src/lib/e2ap/v2_03/e2ap_types/common/e2ap_plmn.c ) + add_library(e2ap_global_node_id_obj OBJECT + flexric/src/lib/e2ap/v2_03/e2ap_types/common/e2ap_global_node_id.c ) +elseif(E2AP_VERSION STREQUAL "E2AP_V3") + add_library(e2ap_ran_func_obj OBJECT + flexric/src/lib/e2ap/v3_01/e2ap_types/common/e2ap_ran_function.c ) + add_library(e2ap_plmn_obj OBJECT + flexric/src/lib/e2ap/v3_01/e2ap_types/common/e2ap_plmn.c ) + add_library(e2ap_global_node_id_obj OBJECT + flexric/src/lib/e2ap/v3_01/e2ap_types/common/e2ap_global_node_id.c ) +else() + message(FATAL_ERROR "E2AP Unknown version selected") +endif() + + + + ######## ### Flatbuffer ######## diff --git a/openair2/E2AP/RAN_FUNCTION/CMakeLists.txt b/openair2/E2AP/RAN_FUNCTION/CMakeLists.txt index ef92ddb0be..da550029e0 100644 --- a/openair2/E2AP/RAN_FUNCTION/CMakeLists.txt +++ b/openair2/E2AP/RAN_FUNCTION/CMakeLists.txt @@ -3,6 +3,8 @@ add_subdirectory(O-RAN) add_library(e2_ran_func STATIC init_ran_func.c + read_setup_ran.c + ../flexric/test/rnd/fill_rnd_data_e2_setup_req.c ) target_link_libraries(e2_ran_func @@ -10,3 +12,6 @@ target_link_libraries(e2_ran_func e2_ran_func_cust e2_ran_func_oran ) + +# This dependency sucks! Create pointers and forward declarations! +target_compile_definitions(e2_ran_func PRIVATE ${E2AP_VERSION} ${KPM_VERSION}) diff --git a/openair2/E2AP/RAN_FUNCTION/CUSTOMIZED/CMakeLists.txt b/openair2/E2AP/RAN_FUNCTION/CUSTOMIZED/CMakeLists.txt index bc5bfcb695..f2560ff838 100644 --- a/openair2/E2AP/RAN_FUNCTION/CUSTOMIZED/CMakeLists.txt +++ b/openair2/E2AP/RAN_FUNCTION/CUSTOMIZED/CMakeLists.txt @@ -16,3 +16,5 @@ add_library(e2_ran_func_cust STATIC ) target_link_libraries(e2_ran_func_cust PUBLIC asn1_nr_rrc nr_rrc asn1_nr_rrc_hdrs) +# This dependency sucks! Create pointers and forward declarations! +target_compile_definitions(e2_ran_func_cust PRIVATE ${E2AP_VERSION} ${KPM_VERSION} ) diff --git a/openair2/E2AP/RAN_FUNCTION/CUSTOMIZED/ran_func_gtp.c b/openair2/E2AP/RAN_FUNCTION/CUSTOMIZED/ran_func_gtp.c index 71200a1eb5..3550a80981 100644 --- a/openair2/E2AP/RAN_FUNCTION/CUSTOMIZED/ran_func_gtp.c +++ b/openair2/E2AP/RAN_FUNCTION/CUSTOMIZED/ran_func_gtp.c @@ -1,7 +1,14 @@ #include "ran_func_gtp.h" -#include "openair2/E2AP/flexric/test/rnd/fill_rnd_data_gtp.h" + #include +#include "openair2/E2AP/flexric/test/rnd/fill_rnd_data_gtp.h" +#include "common/ran_context.h" +#include "openair2/LAYER2/NR_MAC_gNB/mac_proto.h" +#include "openair2/E2AP/flexric/src/util/time_now_us.h" +#include "openair2/RRC/NR/rrc_gNB_UE_context.h" + + static const int mod_id = 0; diff --git a/openair2/E2AP/RAN_FUNCTION/CUSTOMIZED/ran_func_gtp.h b/openair2/E2AP/RAN_FUNCTION/CUSTOMIZED/ran_func_gtp.h index 5d28003c6f..0f12aa703a 100644 --- a/openair2/E2AP/RAN_FUNCTION/CUSTOMIZED/ran_func_gtp.h +++ b/openair2/E2AP/RAN_FUNCTION/CUSTOMIZED/ran_func_gtp.h @@ -2,10 +2,6 @@ #define RAN_FUNC_SM_GTP_READ_WRITE_AGENT_H #include "openair2/E2AP/flexric/src/agent/../sm/sm_io.h" -#include "common/ran_context.h" -#include "openair2/LAYER2/NR_MAC_gNB/mac_proto.h" -#include "openair2/E2AP/flexric/src/util/time_now_us.h" -#include "openair2/RRC/NR/rrc_gNB_UE_context.h" void read_gtp_sm(void*); diff --git a/openair2/E2AP/RAN_FUNCTION/CUSTOMIZED/ran_func_pdcp.c b/openair2/E2AP/RAN_FUNCTION/CUSTOMIZED/ran_func_pdcp.c index e65bd3ac0c..aa3cb39431 100644 --- a/openair2/E2AP/RAN_FUNCTION/CUSTOMIZED/ran_func_pdcp.c +++ b/openair2/E2AP/RAN_FUNCTION/CUSTOMIZED/ran_func_pdcp.c @@ -1,6 +1,17 @@ #include "ran_func_pdcp.h" -#include "openair2/E2AP/flexric/test/rnd/fill_rnd_data_pdcp.h" + #include +#include +#include + +#include "openair2/E2AP/flexric/test/rnd/fill_rnd_data_pdcp.h" +#include "common/ran_context.h" +#include "openair2/RRC/NR/rrc_gNB_UE_context.h" +#include "openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.h" +#include "openair2/LAYER2/nr_rlc/nr_rlc_oai_api.h" +#include "openair2/LAYER2/NR_MAC_gNB/mac_proto.h" +#include "openair2/E2AP/flexric/src/util/time_now_us.h" + static const int mod_id = 0; diff --git a/openair2/E2AP/RAN_FUNCTION/CUSTOMIZED/ran_func_pdcp.h b/openair2/E2AP/RAN_FUNCTION/CUSTOMIZED/ran_func_pdcp.h index ef16f3c123..01d70e8250 100644 --- a/openair2/E2AP/RAN_FUNCTION/CUSTOMIZED/ran_func_pdcp.h +++ b/openair2/E2AP/RAN_FUNCTION/CUSTOMIZED/ran_func_pdcp.h @@ -2,12 +2,6 @@ #define RAN_FUNC_SM_PDCP_READ_WRITE_AGENT_H #include "openair2/E2AP/flexric/src/agent/../sm/sm_io.h" -#include "common/ran_context.h" -#include "openair2/RRC/NR/rrc_gNB_UE_context.h" -#include "openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.h" -#include "openair2/LAYER2/nr_rlc/nr_rlc_oai_api.h" -#include "openair2/LAYER2/NR_MAC_gNB/mac_proto.h" -#include "openair2/E2AP/flexric/src/util/time_now_us.h" void read_pdcp_sm(void*); diff --git a/openair2/E2AP/RAN_FUNCTION/CUSTOMIZED/ran_func_rlc.c b/openair2/E2AP/RAN_FUNCTION/CUSTOMIZED/ran_func_rlc.c index 82c1a0b869..cb884b03ab 100644 --- a/openair2/E2AP/RAN_FUNCTION/CUSTOMIZED/ran_func_rlc.c +++ b/openair2/E2AP/RAN_FUNCTION/CUSTOMIZED/ran_func_rlc.c @@ -1,5 +1,12 @@ #include +#include +#include + #include "ran_func_rlc.h" +#include "common/ran_context.h" +#include "openair2/LAYER2/NR_MAC_gNB/mac_proto.h" +#include "openair2/LAYER2/nr_rlc/nr_rlc_oai_api.h" +#include "openair2/E2AP/flexric/src/util/time_now_us.h" #include "openair2/E2AP/flexric/test/rnd/fill_rnd_data_rlc.h" static diff --git a/openair2/E2AP/RAN_FUNCTION/CUSTOMIZED/ran_func_rlc.h b/openair2/E2AP/RAN_FUNCTION/CUSTOMIZED/ran_func_rlc.h index 0241401793..d49e56e9d3 100644 --- a/openair2/E2AP/RAN_FUNCTION/CUSTOMIZED/ran_func_rlc.h +++ b/openair2/E2AP/RAN_FUNCTION/CUSTOMIZED/ran_func_rlc.h @@ -2,11 +2,6 @@ #define RAN_FUNC_SM_RLC_READ_WRITE_AGENT_H #include "openair2/E2AP/flexric/src/agent/../sm/sm_io.h" -#include "common/ran_context.h" -#include "openair2/LAYER2/NR_MAC_gNB/mac_proto.h" -#include "openair2/LAYER2/nr_rlc/nr_rlc_oai_api.h" -#include "openair2/E2AP/flexric/src/util/time_now_us.h" - void read_rlc_sm(void*); diff --git a/openair2/E2AP/RAN_FUNCTION/O-RAN/CMakeLists.txt b/openair2/E2AP/RAN_FUNCTION/O-RAN/CMakeLists.txt index ee5ccf01d0..3a1c042785 100644 --- a/openair2/E2AP/RAN_FUNCTION/O-RAN/CMakeLists.txt +++ b/openair2/E2AP/RAN_FUNCTION/O-RAN/CMakeLists.txt @@ -7,3 +7,4 @@ add_library(e2_ran_func_oran STATIC ) target_link_libraries(e2_ran_func_oran PUBLIC asn1_nr_rrc nr_rrc asn1_nr_rrc_hdrs) +target_compile_definitions(e2_ran_func_oran PRIVATE ${E2AP_VERSION} ${KPM_VERSION}) diff --git a/openair2/E2AP/RAN_FUNCTION/O-RAN/ran_func_kpm.c b/openair2/E2AP/RAN_FUNCTION/O-RAN/ran_func_kpm.c index 37054ad8fb..ea1735fcd8 100644 --- a/openair2/E2AP/RAN_FUNCTION/O-RAN/ran_func_kpm.c +++ b/openair2/E2AP/RAN_FUNCTION/O-RAN/ran_func_kpm.c @@ -20,7 +20,7 @@ typedef struct { static -matched_ues_mac_t filter_ues_by_s_nssai_in_du_or_monolithic(test_cond_e const * condition, int64_t const value) +matched_ues_mac_t filter_ues_by_s_nssai_in_du_or_monolithic(test_cond_e const condition, int64_t const value) { matched_ues_mac_t matched_ues = {.num_ues = 0, .ue_list = calloc(MAX_MOBILES_PER_GNB, sizeof(NR_UE_info_t)) }; assert(matched_ues.ue_list != NULL && "Memory exhausted"); @@ -37,7 +37,7 @@ matched_ues_mac_t filter_ues_by_s_nssai_in_du_or_monolithic(test_cond_e const * // Filter connected UEs by S-NSSAI test condition to get list of matched UEs // note: not possible to filter - switch (*condition) + switch (condition) { case EQUAL_TEST_COND: { @@ -73,7 +73,7 @@ typedef struct { } matched_ues_rrc_t; static -matched_ues_rrc_t filter_ues_by_s_nssai_in_cu(test_cond_e const * condition, int64_t const value) +matched_ues_rrc_t filter_ues_by_s_nssai_in_cu(test_cond_e const condition, int64_t const value) { matched_ues_rrc_t matched_ues = {.num_ues = 0, .rrc_ue_id_list = calloc(MAX_MOBILES_PER_GNB, sizeof(f1_ue_data_t)) }; assert(matched_ues.rrc_ue_id_list != NULL && "Memory exhausted"); @@ -85,7 +85,7 @@ matched_ues_rrc_t filter_ues_by_s_nssai_in_cu(test_cond_e const * condition, int ngap_gNB_ue_context_t *ngap_ue_context_list = ngap_get_ue_context(ue_context_p1->ue_context.rrc_ue_id); // Filter connected UEs by S-NSSAI test condition to get list of matched UEs - switch (*condition) + switch (condition) { case EQUAL_TEST_COND: assert(ngap_ue_context_list->gNB_instance[0].s_nssai[0][0].sST == value && "Please, check the condition for S-NSSAI. At the moment, OAI supports eMBB"); @@ -104,7 +104,7 @@ matched_ues_rrc_t filter_ues_by_s_nssai_in_cu(test_cond_e const * condition, int } static -nr_rlc_statistics_t get_rlc_stats_per_drb(NR_UE_info_t * const UE) +nr_rlc_statistics_t get_rlc_stats_per_drb(NR_UE_info_t const * UE) { assert(UE != NULL); @@ -195,13 +195,14 @@ gnb_du_e2sm_t fill_gnb_du_data(const f1_ue_data_t * rrc_ue_id) return gnb_du; } - -uint32_t last_dl_rlc_pdu_total_bytes[MAX_MOBILES_PER_GNB] = {0}; -uint32_t last_ul_rlc_pdu_total_bytes[MAX_MOBILES_PER_GNB] = {0}; -uint32_t last_dl_total_prbs[MAX_MOBILES_PER_GNB] = {0}; -uint32_t last_ul_total_prbs[MAX_MOBILES_PER_GNB] = {0}; -uint32_t last_dl_pdcp_sdu_total_bytes[MAX_MOBILES_PER_GNB] = {0}; -uint32_t last_ul_pdcp_sdu_total_bytes[MAX_MOBILES_PER_GNB] = {0}; +// Bad bad bad. Create a proper exponential moving average filter or at least, only read statistics +// Avoid coupling among sublayers +static uint32_t last_dl_rlc_pdu_total_bytes[MAX_MOBILES_PER_GNB] = {0}; +static uint32_t last_ul_rlc_pdu_total_bytes[MAX_MOBILES_PER_GNB] = {0}; +static uint32_t last_dl_total_prbs[MAX_MOBILES_PER_GNB] = {0}; +static uint32_t last_ul_total_prbs[MAX_MOBILES_PER_GNB] = {0}; +static uint32_t last_dl_pdcp_sdu_total_bytes[MAX_MOBILES_PER_GNB] = {0}; +static uint32_t last_ul_pdcp_sdu_total_bytes[MAX_MOBILES_PER_GNB] = {0}; static @@ -596,18 +597,23 @@ kpm_ind_msg_format_3_t fill_kpm_ind_msg_frm_3_in_monolithic(const matched_ues_ma msg_frm_3.meas_report_per_ue[i].ind_msg_format_1 = fill_kpm_ind_msg_frm_1_in_monolithic(&matched_ues.ue_list[i], i, rrc_ue_context_list->ue_context.rrc_ue_id, act_def_fr_1); } - return msg_frm_3; } - -static -kpm_ric_ind_hdr_format_1_t fill_kpm_ind_hdr_frm_1(void) +static +kpm_ric_ind_hdr_format_1_t kpm_ind_hdr_frm_1(void) { kpm_ric_ind_hdr_format_1_t hdr_frm_1 = {0}; - hdr_frm_1.collectStartTime = time_now_us(); - + int64_t const t = time_now_us(); +#if defined KPM_V2 + hdr_frm_1.collectStartTime = t/1000000; // seconds +#elif defined KPM_V3 + hdr_frm_1.collectStartTime = t; // microseconds +#else + static_assert(0!=0, "Undefined KPM SM Version"); +#endif + hdr_frm_1.fileformat_version = NULL; // Check E2 Node NG-RAN Type @@ -617,7 +623,7 @@ kpm_ric_ind_hdr_format_1_t fill_kpm_ind_hdr_frm_1(void) hdr_frm_1.sender_name->buf = calloc(strlen("My OAI-DU") + 1, sizeof(char)); memcpy(hdr_frm_1.sender_name->buf, "My OAI-DU", strlen("My OAI-DU")); hdr_frm_1.sender_name->len = strlen("My OAI-DU"); - + hdr_frm_1.sender_type = calloc(1, sizeof(byte_array_t)); hdr_frm_1.sender_type->buf = calloc(strlen("DU") + 1, sizeof(char)); memcpy(hdr_frm_1.sender_type->buf, "DU", strlen("DU")); @@ -629,7 +635,7 @@ kpm_ric_ind_hdr_format_1_t fill_kpm_ind_hdr_frm_1(void) hdr_frm_1.sender_name->buf = calloc(strlen("My OAI-CU") + 1, sizeof(char)); memcpy(hdr_frm_1.sender_name->buf, "My OAI-CU", strlen("My OAI-CU")); hdr_frm_1.sender_name->len = strlen("My OAI-CU"); - + hdr_frm_1.sender_type = calloc(1, sizeof(byte_array_t)); hdr_frm_1.sender_type->buf = calloc(strlen("CU") + 1, sizeof(char)); memcpy(hdr_frm_1.sender_type->buf, "CU", strlen("CU")); @@ -641,14 +647,15 @@ kpm_ric_ind_hdr_format_1_t fill_kpm_ind_hdr_frm_1(void) hdr_frm_1.sender_name->buf = calloc(strlen("My OAI-MONO") + 1, sizeof(char)); memcpy(hdr_frm_1.sender_name->buf, "My OAI-MONO", strlen("My OAI-MONO")); hdr_frm_1.sender_name->len = strlen("My OAI-MONO"); - + hdr_frm_1.sender_type = calloc(1, sizeof(byte_array_t)); hdr_frm_1.sender_type->buf = calloc(strlen("MONO") + 1, sizeof(char)); memcpy(hdr_frm_1.sender_type->buf, "MONO", strlen("MONO")); hdr_frm_1.sender_type->len = strlen("MONO"); + } else { + assert(0!=0 && "Unknown node type"); } - - + hdr_frm_1.vendor_name = calloc(1, sizeof(byte_array_t)); hdr_frm_1.vendor_name->buf = calloc(strlen("OAI") + 1, sizeof(char)); memcpy(hdr_frm_1.vendor_name->buf, "OAI", strlen("OAI")); @@ -657,87 +664,125 @@ kpm_ric_ind_hdr_format_1_t fill_kpm_ind_hdr_frm_1(void) return hdr_frm_1; } -static -kpm_ind_hdr_t fill_kpm_ind_hdr(void) +kpm_ind_hdr_t kpm_ind_hdr(void) { kpm_ind_hdr_t hdr = {0}; hdr.type = FORMAT_1_INDICATION_HEADER; - hdr.kpm_ric_ind_hdr_format_1 = fill_kpm_ind_hdr_frm_1(); + hdr.kpm_ric_ind_hdr_format_1 = kpm_ind_hdr_frm_1(); return hdr; } - void read_kpm_sm(void* data) { assert(data != NULL); - //assert(data->type == KPM_STATS_V3_0); + // assert(data->type == KPM_STATS_V3_0); kpm_rd_ind_data_t* const kpm = (kpm_rd_ind_data_t*)data; - assert(kpm->act_def!= NULL && "Cannot be NULL"); + assert(kpm->act_def != NULL && "Cannot be NULL"); // 7.8 Supported RIC Styles and E2SM IE Formats // Action Definition Format 4 corresponds to Indication Message Format 3 - switch (kpm->act_def->type) - { - case FORMAT_4_ACTION_DEFINITION: - { - kpm->ind.hdr = fill_kpm_ind_hdr(); - - kpm->ind.msg.type = FORMAT_3_INDICATION_MESSAGE; + switch (kpm->act_def->type) { + case FORMAT_4_ACTION_DEFINITION: { + kpm->ind.hdr = kpm_ind_hdr(); - // Filter the UE by the test condition criteria - for (size_t i = 0; iact_def->frm_4.matching_cond_lst_len; i++) - { - switch (kpm->act_def->frm_4.matching_cond_lst[i].test_info_lst.test_cond_type) - { - case S_NSSAI_TEST_COND_TYPE: - assert(kpm->act_def->frm_4.matching_cond_lst[i].test_info_lst.S_NSSAI == TRUE_TEST_COND_TYPE && "Must be true"); - - // Check E2 Node NG-RAN Type - if (NODE_IS_DU(RC.nrrrc[0]->node_type)) - { - matched_ues_mac_t matched_ues = filter_ues_by_s_nssai_in_du_or_monolithic(kpm->act_def->frm_4.matching_cond_lst[i].test_info_lst.test_cond, *kpm->act_def->frm_4.matching_cond_lst[i].test_info_lst.int_value); - kpm->ind.msg.frm_3 = fill_kpm_ind_msg_frm_3_in_du(matched_ues, &kpm->act_def->frm_4.action_def_format_1); - } - else if (NODE_IS_CU(RC.nrrrc[0]->node_type)) - { - matched_ues_rrc_t matched_ues = filter_ues_by_s_nssai_in_cu(kpm->act_def->frm_4.matching_cond_lst[i].test_info_lst.test_cond, *kpm->act_def->frm_4.matching_cond_lst[i].test_info_lst.int_value); - kpm->ind.msg.frm_3 = fill_kpm_ind_msg_frm_3_in_cu(matched_ues, &kpm->act_def->frm_4.action_def_format_1); - } - else if (NODE_IS_MONOLITHIC(RC.nrrrc[0]->node_type)) - { - matched_ues_mac_t matched_ues = filter_ues_by_s_nssai_in_du_or_monolithic(kpm->act_def->frm_4.matching_cond_lst[i].test_info_lst.test_cond, *kpm->act_def->frm_4.matching_cond_lst[i].test_info_lst.int_value); - kpm->ind.msg.frm_3 = fill_kpm_ind_msg_frm_3_in_monolithic(matched_ues, &kpm->act_def->frm_4.action_def_format_1); - } - else - { - assert(false && "NG-RAN Type not yet implemented"); - } + kpm->ind.msg.type = FORMAT_3_INDICATION_MESSAGE; + // Filter the UE by the test condition criteria + kpm_act_def_format_4_t const* frm_4 = &kpm->act_def->frm_4; // 8.2.1.2.4 + for (size_t i = 0; i < frm_4->matching_cond_lst_len; i++) { + switch (frm_4->matching_cond_lst[i].test_info_lst.test_cond_type) { + case GBR_TEST_COND_TYPE: { + assert(0 != 0 && "Not implemented"); + break; + } + case AMBR_TEST_COND_TYPE: { + assert(0 != 0 && "Not implemented"); + break; + } + case IsStat_TEST_COND_TYPE: { + assert(0 != 0 && "Not implemented"); + break; + } + case IsCatM_TEST_COND_TYPE: { + assert(0 != 0 && "Not implemented"); + break; + } - break; - - default: - assert(false && "Test condition type not yet implemented"); + case DL_RSRP_TEST_COND_TYPE: { + assert(0 != 0 && "Not implemented"); + break; + } + + case DL_RSRQ_TEST_COND_TYPE: { + assert(0 != 0 && "Not implemented"); + break; + } + + case UL_RSRP_TEST_COND_TYPE: { + assert(0 != 0 && "Not implemented"); + break; + } + + case CQI_TEST_COND_TYPE: { + // This is a bad idea. Done only to check FlexRIC xAPP + printf("CQI not implemented!. Randomly filling the data \n"); + goto rnd_data_label; + break; + } + + case fiveQI_TEST_COND_TYPE: { + assert(0 != 0 && "Not implemented"); + break; + } + + case QCI_TEST_COND_TYPE: { + ; + assert(0 != 0 && "Not implemented"); + break; + } + case S_NSSAI_TEST_COND_TYPE: { + assert(frm_4->matching_cond_lst[i].test_info_lst.S_NSSAI == TRUE_TEST_COND_TYPE && "Must be true"); + assert(frm_4->matching_cond_lst[i].test_info_lst.test_cond != NULL && "Even though is optional.."); + assert(frm_4->matching_cond_lst[i].test_info_lst.int_value != NULL && "Even though is optional.."); + + test_cond_e const test_cond = *frm_4->matching_cond_lst[i].test_info_lst.test_cond; + int64_t const value = *frm_4->matching_cond_lst[i].test_info_lst.int_value; + // Check E2 Node NG-RAN Type + if (NODE_IS_DU(RC.nrrrc[0]->node_type)) { + matched_ues_mac_t matched_ues = filter_ues_by_s_nssai_in_du_or_monolithic(test_cond, value); + kpm->ind.msg.frm_3 = fill_kpm_ind_msg_frm_3_in_du(matched_ues, &frm_4->action_def_format_1); + } else if (NODE_IS_CU(RC.nrrrc[0]->node_type)) { + matched_ues_rrc_t matched_ues = filter_ues_by_s_nssai_in_cu(test_cond, value); + kpm->ind.msg.frm_3 = fill_kpm_ind_msg_frm_3_in_cu(matched_ues, &frm_4->action_def_format_1); + } else if (NODE_IS_MONOLITHIC(RC.nrrrc[0]->node_type)) { + matched_ues_mac_t matched_ues = filter_ues_by_s_nssai_in_du_or_monolithic(test_cond, value); + kpm->ind.msg.frm_3 = fill_kpm_ind_msg_frm_3_in_monolithic(matched_ues, &frm_4->action_def_format_1); + } else { + assert(false && "NG-RAN Type not implemented"); + } + + break; + } + + default: + assert(false && "Unknown Test condition"); + } } + break; } - break; - } - - default: - { - kpm->ind.hdr = fill_rnd_kpm_ind_hdr(); - kpm->ind.msg = fill_rnd_kpm_ind_msg(); + default: { + rnd_data_label: + kpm->ind.hdr = fill_rnd_kpm_ind_hdr(); + kpm->ind.msg = fill_rnd_kpm_ind_msg(); - break; + break; + } } - - } - } void read_kpm_setup_sm(void* e2ap) diff --git a/openair2/E2AP/RAN_FUNCTION/O-RAN/ran_func_rc.c b/openair2/E2AP/RAN_FUNCTION/O-RAN/ran_func_rc.c index 5c6777d5a3..d482cfffb6 100644 --- a/openair2/E2AP/RAN_FUNCTION/O-RAN/ran_func_rc.c +++ b/openair2/E2AP/RAN_FUNCTION/O-RAN/ran_func_rc.c @@ -2,6 +2,8 @@ #include "../../flexric/test/rnd/fill_rnd_data_rc.h" #include "../../flexric/src/sm/rc_sm/ie/ir/lst_ran_param.h" #include "../../flexric/src/sm/rc_sm/ie/ir/ran_param_list.h" +#include "../../flexric/src/agent/e2_agent_api.h" + #include #include #include diff --git a/openair2/E2AP/RAN_FUNCTION/init_ran_func.c b/openair2/E2AP/RAN_FUNCTION/init_ran_func.c index ecd1dc6ec7..e7883e1337 100644 --- a/openair2/E2AP/RAN_FUNCTION/init_ran_func.c +++ b/openair2/E2AP/RAN_FUNCTION/init_ran_func.c @@ -1,4 +1,6 @@ #include "init_ran_func.h" +#include "read_setup_ran.h" +#include "../flexric/src/agent/e2_agent_api.h" #include "CUSTOMIZED/ran_func_mac.h" #include "CUSTOMIZED/ran_func_rlc.h" #include "CUSTOMIZED/ran_func_pdcp.h" @@ -67,6 +69,10 @@ sm_io_ag_ran_t init_ran_func_ag(void) init_write_ctrl(&io.write_ctrl_tbl); init_write_subs(&io.write_subs_tbl); +#if defined(E2AP_V2) || defined(E2AP_V3) + io.read_setup_ran = read_setup_ran; +#endif + return io; } diff --git a/openair2/E2AP/RAN_FUNCTION/read_setup_ran.c b/openair2/E2AP/RAN_FUNCTION/read_setup_ran.c new file mode 100644 index 0000000000..9967a23902 --- /dev/null +++ b/openair2/E2AP/RAN_FUNCTION/read_setup_ran.c @@ -0,0 +1,42 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +#include "read_setup_ran.h" +#include "../../E2AP/flexric/src/lib/e2ap/e2ap_node_component_config_add_wrapper.h" +#include "../../E2AP/flexric/test/rnd/fill_rnd_data_e2_setup_req.h" +#include +#include + +void read_setup_ran(void* data) +{ + assert(data != NULL); +#ifdef E2AP_V1 + +#elif defined(E2AP_V2) || defined(E2AP_V3) + *((e2ap_node_component_config_add_t*)data) = fill_e2ap_node_component_config_add(); +#else + static_assert(0!=0, "Unknown E2AP version"); +#endif + +} + + + diff --git a/openair2/E2AP/RAN_FUNCTION/read_setup_ran.h b/openair2/E2AP/RAN_FUNCTION/read_setup_ran.h new file mode 100644 index 0000000000..2b4c83f2e1 --- /dev/null +++ b/openair2/E2AP/RAN_FUNCTION/read_setup_ran.h @@ -0,0 +1,27 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +#ifndef READ_SETUP_RAN_E2_AGENT_H +#define READ_SETUP_RAN_E2_AGENT_H + +void read_setup_ran(void* data); + +#endif diff --git a/openair2/E2AP/README.md b/openair2/E2AP/README.md index 5da7c33359..f5031454a3 100644 --- a/openair2/E2AP/README.md +++ b/openair2/E2AP/README.md @@ -11,7 +11,7 @@ Please see [NOTICE](NOTICE.md) file for third party software that is included in # Overview -This tutorial describes the steps of deployment 5G OAI RAN, with integrated E2 agent, and FlexRIC, O-RAN compliant nearRT-RIC. +This tutorial describes the steps of deployment 5G OAI RAN, with integrated E2 agent and a nearRT-RIC using O-RAN compliant FlexRIC. # 1. Installation @@ -29,9 +29,10 @@ This tutorial describes the steps of deployment 5G OAI RAN, with integrated E2 a ```bash git clone https://github.com/swig/swig.git cd swig + git checkout release-4.1 ./autogen.sh ./configure --prefix=/usr/ - make + make -j8 make install ``` @@ -57,12 +58,15 @@ git clone https://gitlab.eurecom.fr/oai/openairinterface5g oai cd oai/ ``` -### 2.1.2 Build OAI +### 2.1.2 Build OAI with E2 Agent + +- By default, OAI will build the E2 Agent with E2AP v2 and KPM v2. If you want a different version, edit the variable E2AP\_VERSION and KPM\_VERSION at OAI's CMakeLists.txt file. + ```bash cd cmake_targets/ ./build_oai -I -w SIMU --gNB --nrUE --build-e2 --ninja ``` -If the flexric folder is empty, try manually the following commands +If the openair2/E2AP/flexric folder is empty, try manually the following commands ```bash git submodule init @@ -74,15 +78,18 @@ git submodule update * `--gNB` is to build the `nr-softmodem` and `nr-cuup` executables and all required shared libraries * `--nrUE` is to build the `nr-uesoftmodem` executable and all required shared libraries * `--ninja` is to use the ninja build tool, which speeds up compilation - * `--build-e2` option is to use the E2 agent, integrated within gNB. + * `--build-e2` option is to use the E2 agent, integrated within RAN. ## 2.2 FlexRIC +- By default, FlexRIC will build the nearRT-RIC with E2AP v2 and KPM v2. If you want a different version, edit the variable E2AP\_VERSION and KPM\_VERSION at FlexRIC's CMakeLists.txt file. Note that OAI's and FlexRIC's E2AP\_VERSION and KPM\_VERSION need to match due to O-RAN incompatibilities among versions. + + ### 2.2.1 Clone the FlexRIC repository ```bash git clone https://gitlab.eurecom.fr/mosaic5g/flexric flexric cd flexric/ -git checkout 8ee3aca107a9da8ccf425e623bed18cd40a31fa1 +git checkout 7a55f02efaa81fe143280ad49b92cfbfc0cd3320 ``` ### 2.2.2 Build FlexRIC @@ -98,7 +105,8 @@ sudo make install By default the service model libraries will be installed in the path `/usr/local/lib/flexric` while the configuration file in `/usr/local/etc/flexric`. Available SMs in this version are: -* KPM v03.00 (xapp_kpm_moni) +* KPM v02.03 and KPM v03.00 (xapp_kpm_moni) +* RC v01.03 (xapp_kpm_rc) * GTP (xapp_gtp_moni) * MAC + RLC + PDCP (xapp_mac_rlc_pdcp_moni) @@ -106,7 +114,7 @@ If you are interested in TC and SLICE SMs, please follow the instructions at htt # 3. Start the process -In order to configure E2 agent, please, add the following block in the configuration file: +In order to configure E2 agent, please, add the following block in OAI's configuration file: ```bash e2_agent = { near_ric_ip_addr = "127.0.0.1"; diff --git a/openair2/E2AP/flexric b/openair2/E2AP/flexric index 8ee3aca107..89b2886706 160000 --- a/openair2/E2AP/flexric +++ b/openair2/E2AP/flexric @@ -1 +1 @@ -Subproject commit 8ee3aca107a9da8ccf425e623bed18cd40a31fa1 +Subproject commit 89b2886706d08957749836e590af73bd45184e55