From 81b5632d96c277d5ec2d368bd1422ae61d015cfa Mon Sep 17 00:00:00 2001 From: yagoda Date: Tue, 21 Mar 2023 20:58:04 +0100 Subject: [PATCH] e2ap: adding failure message handling, implementation of e2 setup failure --- srsgnb/hdr/stack/ric/e2ap.h | 19 +++++++--- srsgnb/src/stack/ric/e2ap.cc | 57 ++++++++++++++++++++++++++---- srsgnb/src/stack/ric/ric_client.cc | 37 ++++++++++++++++--- 3 files changed, 99 insertions(+), 14 deletions(-) diff --git a/srsgnb/hdr/stack/ric/e2ap.h b/srsgnb/hdr/stack/ric/e2ap.h index 701000de0..5c615ca6d 100644 --- a/srsgnb/hdr/stack/ric/e2ap.h +++ b/srsgnb/hdr/stack/ric/e2ap.h @@ -64,23 +64,34 @@ public: e2_ap_pdu_c generate_reset_response(); int process_reset_request(reset_request_s reset_request); int process_reset_response(reset_resp_s reset_response); + + int process_e2_setup_failure(e2setup_fail_s e2setup_failure); + int process_ric_service_update_failure(ricservice_upd_fail_s ric_service_update_failure); + int process_e2_node_config_update_failure(e2node_cfg_upd_fail_s e2node_config_update_failure); + int process_e2_removal_failure(e2_removal_fail_s e2_remove_failure); + int get_reset_id(); - bool has_setup_response() { return setup_response_received; } bool get_func_desc(uint32_t ran_func_id, RANfunction_description& fdesc); + bool send_setup_request() { return !e2_established && pending_e2_setup; } private: srslog::basic_logger& logger; e2sm_kpm e2sm_; - bool setup_response_received = false; - bool pending_subscription_request = false; + bool e2_established = false; + srsran::unique_timer e2_procedure_timeout; + bool pending_e2_setup = false; + bool pending_e2_node_config_update = false; + bool pending_ric_service_update = false; + bool pending_e2_removal = false; + int setup_procedure_transaction_id = 0; uint64_t plmn_id = 0x05f510; uint64_t gnb_id = 1; global_ric_id_t global_ric_id = {}; std::map ran_functions; srsenb::e2_interface_metrics* gnb_metrics = nullptr; - bool reset_response_received = false; srsran::task_scheduler* task_sched_ptr = nullptr; + bool reset_response_received = false; int reset_transaction_id = 1; cause_c reset_cause = cause_c(); int reset_id = 1; diff --git a/srsgnb/src/stack/ric/e2ap.cc b/srsgnb/src/stack/ric/e2ap.cc index 71dd809e8..034f07f5d 100644 --- a/srsgnb/src/stack/ric/e2ap.cc +++ b/srsgnb/src/stack/ric/e2ap.cc @@ -8,6 +8,8 @@ e2ap::e2ap(srslog::basic_logger& logger, logger(logger), e2sm_(logger), task_sched_ptr(_task_sched_ptr) { gnb_metrics = _gnb_metrics; + e2_procedure_timeout = task_sched_ptr->get_unique_timer(); + // add SMs to map uint32_t local_ran_function_id = 147; RANfunction_description add_func; @@ -155,11 +157,12 @@ e2_ap_pdu_c e2ap::generate_subscription_delete_response(uint32_t ric_requestor_i int e2ap::process_setup_response(e2setup_resp_s setup_response) { - setup_response_received = true; if (setup_procedure_transaction_id == setup_response->transaction_id.value.value) { setup_procedure_transaction_id++; + e2_established = true; } else { logger.error("Received setup response with wrong transaction id"); + return SRSRAN_ERROR; } global_ric_id.plmn_id = setup_response->global_ric_id.value.plmn_id.to_number(); global_ric_id.ric_id = setup_response->global_ric_id.value.ric_id.to_number(); @@ -175,14 +178,13 @@ int e2ap::process_setup_response(e2setup_resp_s setup_response) } } } - return 0; + return SRSRAN_SUCCESS; } int e2ap::process_subscription_request(ricsubscription_request_s subscription_request) { - pending_subscription_request = true; // TODO: this function seems to be not needed - return 0; + return SRSRAN_SUCCESS; } e2_ap_pdu_c e2ap::generate_indication(ric_indication_t& ric_indication) @@ -254,7 +256,7 @@ int e2ap::process_reset_request(reset_request_s reset_request) // TO DO: Parse and store the cause for future extension of the ric client - return 0; + return SRSRAN_SUCCESS; } int e2ap::process_reset_response(reset_resp_s reset_response) @@ -262,10 +264,53 @@ int e2ap::process_reset_response(reset_resp_s reset_response) // TO DO process reset response from RIC reset_response_received = true; - return 0; + return SRSRAN_SUCCESS; } int e2ap::get_reset_id() { return reset_id; } + +// implementation of e2ap failure functions +int e2ap::process_e2_setup_failure(e2setup_fail_s e2setup_failure) +{ + if (setup_procedure_transaction_id == e2setup_failure->transaction_id.value.value) { + setup_procedure_transaction_id++; + } else { + logger.error("Received setup failure with wrong transaction id"); + } + if (e2setup_failure->tn_linfo_present) { + logger.error("Received setup failure with transport layer info"); + } + if (e2setup_failure->time_to_wait_present) { + logger.error("Received setup failure with time to wait"); + e2_procedure_timeout.set(e2setup_failure->time_to_wait.value.to_number(), [this](int trans_id) { + logger.info("E2AP procedure timeout expired transaction id %d", trans_id); + pending_e2_setup = false; + }); + e2_procedure_timeout.run(); + } + return SRSRAN_SUCCESS; +} + +int e2ap::process_e2_node_config_update_failure(e2node_cfg_upd_fail_s e2node_config_update_failure) +{ + pending_e2_node_config_update = false; + + return SRSRAN_SUCCESS; +} + +int e2ap::process_ric_service_update_failure(ricservice_upd_fail_s service_update_failure) +{ + pending_ric_service_update = false; + + return SRSRAN_SUCCESS; +} + +int e2ap::process_e2_removal_failure(e2_removal_fail_s e2removal_failure) +{ + pending_e2_removal = false; + + return SRSRAN_SUCCESS; +} diff --git a/srsgnb/src/stack/ric/ric_client.cc b/srsgnb/src/stack/ric/ric_client.cc index 67b523093..600b41ada 100644 --- a/srsgnb/src/stack/ric/ric_client.cc +++ b/srsgnb/src/stack/ric/ric_client.cc @@ -78,7 +78,7 @@ void ric_client::run_thread() using namespace asn1::e2ap; while (running) { - if (!e2ap_.has_setup_response()) { + if (e2ap_.send_setup_request()) { send_e2_msg(E2_SETUP_REQUEST); printf("e2 setup request sent\n"); } @@ -180,7 +180,7 @@ bool ric_client::handle_e2_rx_msg(srsran::unique_byte_buffer_t pdu, handle_e2_successful_outcome(pdu_c.successful_outcome()); } else if (pdu_c.type().value == e2_ap_pdu_c::types_opts::unsuccessful_outcome) { logger.info("Received E2AP Unsuccessful Outcome "); - // handle_e2_unsuccessful_outcome(pdu_c.unsuccessful_outcome()); + handle_e2_unsuccessful_outcome(pdu_c.unsuccessful_outcome()); } else { logger.warning("Received E2AP Unknown Message "); } @@ -258,8 +258,37 @@ bool ric_client::handle_e2_setup_response(e2setup_resp_s setup_response) bool ric_client::handle_e2_unsuccessful_outcome(asn1::e2ap::unsuccessful_outcome_s& unsuccessful_outcome) { using namespace asn1::e2ap; - // TODO check for different type of RIC generated unsuccessful outcomes - // eg. RIC subscription failure, RIC Reset failure, RIC control failure, RIC subscription delete failure + if (unsuccessful_outcome.value.type() == e2_ap_elem_procs_o::unsuccessful_outcome_c::types_opts::e2setup_fail) { + logger.info("Received E2AP E2 Setup Failure"); + if (e2ap_.process_e2_setup_failure(unsuccessful_outcome.value.e2setup_fail())) { + logger.error("Failed to process E2 Setup Failure \n"); + return false; + } + } else if (unsuccessful_outcome.value.type() == + e2_ap_elem_procs_o::unsuccessful_outcome_c::types_opts::e2node_cfg_upd_fail) { + logger.info("Received E2node configuration update Failure"); + if (e2ap_.process_e2_node_config_update_failure(unsuccessful_outcome.value.e2node_cfg_upd_fail())) { + logger.error("Failed to process E2node configuration update Failure \n"); + return false; + } + } else if (unsuccessful_outcome.value.type() == + e2_ap_elem_procs_o::unsuccessful_outcome_c::types_opts::ricservice_upd_fail) { + logger.info("Received E2AP RIC Service Update Failure \n"); + if (e2ap_.process_ric_service_update_failure(unsuccessful_outcome.value.ricservice_upd_fail())) { + logger.error("Failed to process RIC service update failure \n"); + return false; + } + } else if (unsuccessful_outcome.value.type() == + e2_ap_elem_procs_o::unsuccessful_outcome_c::types_opts::e2_removal_fail) { + logger.info("Received E2AP removal Unsuccessful Outcome \n"); + if (e2ap_.process_e2_removal_failure(unsuccessful_outcome.value.e2_removal_fail())) { + logger.error("Failed to process RIC service status failure \n"); + return false; + } + } else { + logger.info("Received E2AP Unknown Unsuccessful Outcome \n"); + } + return true; }