From 064866459c71513d347e6a68095b4aac8bf47a0c Mon Sep 17 00:00:00 2001 From: Teodora Date: Mon, 3 Feb 2025 14:40:00 +0100 Subject: [PATCH] Add RPC for M-plane --- radio/fhi_72/mplane/CMakeLists.txt | 1 + radio/fhi_72/mplane/get-mplane.c | 47 ++++++++++++++++++++++++++++++ radio/fhi_72/mplane/get-mplane.h | 29 ++++++++++++++++++ radio/fhi_72/mplane/init-mplane.c | 14 +++++++++ radio/fhi_72/mplane/init-mplane.h | 2 ++ radio/fhi_72/oran_isolate.c | 1 + 6 files changed, 94 insertions(+) create mode 100644 radio/fhi_72/mplane/get-mplane.c create mode 100644 radio/fhi_72/mplane/get-mplane.h diff --git a/radio/fhi_72/mplane/CMakeLists.txt b/radio/fhi_72/mplane/CMakeLists.txt index f58238024e..2699beb6d9 100644 --- a/radio/fhi_72/mplane/CMakeLists.txt +++ b/radio/fhi_72/mplane/CMakeLists.txt @@ -28,6 +28,7 @@ target_sources(oran_fhlib_5g_mplane PRIVATE init-mplane.c connect-mplane.c rpc-send-recv.c + get-mplane.c ) pkg_check_modules(libyang REQUIRED libyang) diff --git a/radio/fhi_72/mplane/get-mplane.c b/radio/fhi_72/mplane/get-mplane.c new file mode 100644 index 0000000000..06aa6d0317 --- /dev/null +++ b/radio/fhi_72/mplane/get-mplane.c @@ -0,0 +1,47 @@ +/* + * 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 "get-mplane.h" +#include "rpc-send-recv.h" + +#include "common/utils/assertions.h" + +bool get_mplane(ru_session_t *ru_session, char **answer) +{ + int timeout = CLI_RPC_REPLY_TIMEOUT; + struct nc_rpc *rpc; + char *filter = NULL; // e.g. "/o-ran-delay-management:delay-management"; + NC_WD_MODE wd = NC_WD_ALL; + NC_PARAMTYPE param = NC_PARAMTYPE_CONST; + + MP_LOG_I("RPC request to RU \"%s\" = operational datastore.\n", ru_session->ru_ip_add); + rpc = nc_rpc_get(filter, wd, param); + AssertError(rpc != NULL, return false, "[MPLANE] RPC creation failed.\n"); + + bool success = rpc_send_recv((struct nc_session *)ru_session->session, rpc, wd, timeout, answer); + AssertError(success, return false, "[MPLANE] Unable to retrieve operational datastore.\n"); + + MP_LOG_I("Successfully retrieved operational datastore from RU \"%s\".\n", ru_session->ru_ip_add); + + nc_rpc_free(rpc); + + return true; +} diff --git a/radio/fhi_72/mplane/get-mplane.h b/radio/fhi_72/mplane/get-mplane.h new file mode 100644 index 0000000000..a47abdc8f5 --- /dev/null +++ b/radio/fhi_72/mplane/get-mplane.h @@ -0,0 +1,29 @@ +/* + * 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 GET_MPLANE_H +#define GET_MPLANE_H + +#include "ru-mplane-api.h" + +bool get_mplane(ru_session_t *ru_session, char **answer); + +#endif /* GET_MPLANE_H */ diff --git a/radio/fhi_72/mplane/init-mplane.c b/radio/fhi_72/mplane/init-mplane.c index 31988f3dba..cd83ccc4f6 100644 --- a/radio/fhi_72/mplane/init-mplane.c +++ b/radio/fhi_72/mplane/init-mplane.c @@ -21,6 +21,7 @@ #include "init-mplane.h" #include "radio/fhi_72/oran-params.h" +#include "get-mplane.h" #include #include @@ -129,3 +130,16 @@ bool init_mplane(ru_session_list_t *ru_session_list) return true; } + +bool manage_ru(ru_session_t *ru_session, const openair0_config_t *oai, const size_t num_rus) +{ + bool success = false; + + char *operational_ds = NULL; + success = get_mplane(ru_session, &operational_ds); + AssertError(success, return false, "[MPLANE] Unable to continue: could not get RU answer via get_mplane().\n"); + + free(operational_ds); + + return true; +} diff --git a/radio/fhi_72/mplane/init-mplane.h b/radio/fhi_72/mplane/init-mplane.h index ee558fd77d..5077908d64 100644 --- a/radio/fhi_72/mplane/init-mplane.h +++ b/radio/fhi_72/mplane/init-mplane.h @@ -27,4 +27,6 @@ bool init_mplane(ru_session_list_t *ru_session_list); +bool manage_ru(ru_session_t *ru_session, const openair0_config_t *oai, const size_t num_rus); + #endif /* OAI_MPLANE_H */ diff --git a/radio/fhi_72/oran_isolate.c b/radio/fhi_72/oran_isolate.c index a249924731..8104b1a2c2 100644 --- a/radio/fhi_72/oran_isolate.c +++ b/radio/fhi_72/oran_isolate.c @@ -302,6 +302,7 @@ __attribute__((__visibility__("default"))) int transport_init(openair0_device *d if (!ru_configured[i]) { continue; } + ru_configured[i] = manage_ru(ru_session, openair0_cfg, ru_session_list.num_rus); } #else success = get_xran_config(openair0_cfg, &fh_init, fh_config);