Skip to content

Commit eaa8e15

Browse files
committed
config: added YAML writter to the gNB appplication configuration
1 parent 35e7888 commit eaa8e15

File tree

8 files changed

+175
-8
lines changed

8 files changed

+175
-8
lines changed

apps/gnb/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ add_executable(gnb
1111
gnb_appconfig_cli11_schema.cpp
1212
gnb_appconfig_validators.cpp
1313
gnb_appconfig_translators.cpp
14+
gnb_appconfig_yaml_writer.cpp
1415
adapters/e2_gateway_remote_connector.cpp
1516
)
1617

apps/gnb/gnb.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545

4646
// Include ThreadSanitizer (TSAN) options if thread sanitization is enabled.
4747
// This include is not unused - it helps prevent false alarms from the thread sanitizer.
48+
#include "gnb_appconfig_yaml_writer.h"
49+
4850
#include "srsran/support/tsan_options.h"
4951

5052
#include "apps/units/cu_cp/cu_cp_config_translators.h"
@@ -249,6 +251,7 @@ int main(int argc, char** argv)
249251

250252
config_logger.debug("NOW IT GOES THE MANUAL CONFIG");
251253
YAML::Node node;
254+
fill_gnb_appconfig_in_yaml_schema(node, gnb_cfg);
252255
fill_cu_up_config_in_yaml_schema(node, cu_up_config);
253256
fill_cu_cp_config_in_yaml_schema(node, cu_cp_config);
254257
fill_dynamic_du_unit_config_in_yaml_schema(node, du_unit_cfg);
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/*
2+
*
3+
* Copyright 2021-2024 Software Radio Systems Limited
4+
*
5+
* By using this file, you agree to the terms and conditions set
6+
* forth in the LICENSE file which can be found at the top level of
7+
* the distribution.
8+
*
9+
*/
10+
11+
#include "gnb_appconfig_yaml_writer.h"
12+
#include "apps/services/logger/logger_appconfig_yaml_writer.h"
13+
#include "gnb_appconfig.h"
14+
15+
using namespace srsran;
16+
17+
static void fill_gnb_appconfig_metrics_section(YAML::Node node, const metrics_appconfig& config)
18+
{
19+
node["pdcp_report_period"] = config.pdcp.report_period;
20+
node["enable_json_metrics"] = config.enable_json_metrics;
21+
node["addr"] = config.addr;
22+
node["port"] = config.port;
23+
node["autostart_stdout_metrics"] = config.autostart_stdout_metrics;
24+
node["stdout_metrics_period"] = config.stdout_metrics_period;
25+
}
26+
27+
static void fill_gnb_appconfig_e2_section(YAML::Node node, const e2_appconfig& config)
28+
{
29+
node["enable_du_e2"] = config.enable_du_e2;
30+
node["addr"] = config.ip_addr;
31+
node["port"] = config.port;
32+
node["bind_addr"] = config.bind_addr;
33+
node["sctp_rto_initial"] = config.sctp_rto_initial;
34+
node["sctp_rto_min"] = config.sctp_rto_min;
35+
node["sctp_rto_max"] = config.sctp_rto_max;
36+
node["sctp_init_max_attempts"] = config.sctp_init_max_attempts;
37+
node["sctp_max_init_timeo"] = config.sctp_max_init_timeo;
38+
node["e2sm_kpm_enabled"] = config.e2sm_kpm_enabled;
39+
node["e2sm_rc_enabled"] = config.e2sm_rc_enabled;
40+
}
41+
42+
static void fill_gnb_appconfig_hal_section(YAML::Node node, const std::optional<hal_appconfig>& config)
43+
{
44+
if (!config.has_value()) {
45+
return;
46+
}
47+
YAML::Node hal_node = node["hal"];
48+
hal_node["eal_args"] = config.value().eal_args;
49+
}
50+
51+
static void fill_gnb_appconfig_expert_execution_section(YAML::Node node, const expert_execution_appconfig& config)
52+
{
53+
{
54+
YAML::Node affinities_node = node["affinities"];
55+
56+
if (config.affinities.isolated_cpus.has_value()) {
57+
affinities_node["isolated_cpus"] =
58+
fmt::format("{:,}", span<const size_t>(config.affinities.isolated_cpus.value().get_cpu_ids()));
59+
}
60+
61+
if (config.affinities.low_priority_cpu_cfg.mask.any()) {
62+
affinities_node["l2_cell_cpus"] =
63+
fmt::format("{:,}", span<const size_t>(config.affinities.low_priority_cpu_cfg.mask.get_cpu_ids()));
64+
}
65+
affinities_node["low_priority_pinning"] = to_string(config.affinities.low_priority_cpu_cfg.pinning_policy);
66+
}
67+
68+
{
69+
YAML::Node threads_node = node["threads"];
70+
YAML::Node non_rt_node = threads_node["non_rt"];
71+
non_rt_node["nof_non_rt_threads"] = config.threads.non_rt_threads.nof_non_rt_threads;
72+
}
73+
}
74+
75+
static void fill_gnb_appconfig_buffer_pool_section(YAML::Node node, const buffer_pool_appconfig& config)
76+
{
77+
node["nof_segments"] = config.nof_segments;
78+
node["segment_size"] = config.segment_size;
79+
}
80+
81+
void srsran::fill_gnb_appconfig_in_yaml_schema(YAML::Node& node, const gnb_appconfig& config)
82+
{
83+
node["gnb_id"] = config.gnb_id.id;
84+
node["gnb_id_bit_length"] = static_cast<unsigned>(config.gnb_id.bit_length);
85+
node["ran_node_name"] = config.ran_node_name;
86+
87+
fill_logger_appconfig_in_yaml_schema(node, config.log_cfg);
88+
fill_gnb_appconfig_metrics_section(node["metrics"], config.metrics_cfg);
89+
fill_gnb_appconfig_e2_section(node["e2"], config.e2_cfg);
90+
fill_gnb_appconfig_hal_section(node, config.hal_config);
91+
fill_gnb_appconfig_expert_execution_section(node["expert_execution"], config.expert_execution_cfg);
92+
fill_gnb_appconfig_buffer_pool_section(node["buffer_pool"], config.buffer_pool_config);
93+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
*
3+
* Copyright 2021-2024 Software Radio Systems Limited
4+
*
5+
* By using this file, you agree to the terms and conditions set
6+
* forth in the LICENSE file which can be found at the top level of
7+
* the distribution.
8+
*
9+
*/
10+
11+
#pragma once
12+
13+
#include <yaml-cpp/yaml.h>
14+
15+
namespace srsran {
16+
17+
struct gnb_appconfig;
18+
19+
/// Fills the given node with the gNB application configuration values.
20+
void fill_gnb_appconfig_in_yaml_schema(YAML::Node& node, const gnb_appconfig& config);
21+
22+
} // namespace srsran

apps/services/logger/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
#
88

99
set(SOURCES
10-
logger_appconfig_cli11_schema.cpp
11-
logger_appconfig_validator.cpp)
10+
logger_appconfig_cli11_schema.cpp
11+
logger_appconfig_validator.cpp
12+
logger_appconfig_yaml_writer.cpp)
1213

1314
add_library(srsran_logger_app_service STATIC ${SOURCES})
1415
target_include_directories(srsran_logger_app_service PRIVATE ${CMAKE_SOURCE_DIR})
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
*
3+
* Copyright 2021-2024 Software Radio Systems Limited
4+
*
5+
* By using this file, you agree to the terms and conditions set
6+
* forth in the LICENSE file which can be found at the top level of
7+
* the distribution.
8+
*
9+
*/
10+
11+
#include "logger_appconfig_yaml_writer.h"
12+
#include "logger_appconfig.h"
13+
14+
using namespace srsran;
15+
16+
void srsran::fill_logger_appconfig_in_yaml_schema(YAML::Node& node, const logger_appconfig& config)
17+
{
18+
YAML::Node log_node = node["log"];
19+
log_node["filename"] = config.filename;
20+
log_node["lib_level"] = srslog::basic_level_to_string(config.lib_level);
21+
log_node["e2ap_level"] = srslog::basic_level_to_string(config.e2ap_level);
22+
log_node["config_level"] = srslog::basic_level_to_string(config.config_level);
23+
log_node["metrics_level"] = srslog::basic_level_to_string(config.metrics_level);
24+
log_node["hex_max_size"] = config.hex_max_size;
25+
26+
if (!config.tracing_filename.empty()) {
27+
log_node["tracing_filename"] = config.tracing_filename;
28+
}
29+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
*
3+
* Copyright 2021-2024 Software Radio Systems Limited
4+
*
5+
* By using this file, you agree to the terms and conditions set
6+
* forth in the LICENSE file which can be found at the top level of
7+
* the distribution.
8+
*
9+
*/
10+
11+
#pragma once
12+
13+
#include <yaml-cpp/yaml.h>
14+
15+
namespace srsran {
16+
17+
struct logger_appconfig;
18+
19+
/// Fills the given node with the logger application configuration values.
20+
void fill_logger_appconfig_in_yaml_schema(YAML::Node& node, const logger_appconfig& config);
21+
22+
} // namespace srsran

apps/units/flexible_du/du_high/du_high_config_yaml_writer.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -747,10 +747,8 @@ static YAML::Node build_du_high_testmode_section(const du_high_unit_test_mode_co
747747
return node;
748748
}
749749

750-
static YAML::Node build_du_high_e2_section(const du_high_unit_e2_config& config)
750+
static void fill_du_high_e2_section(YAML::Node node, const du_high_unit_e2_config& config)
751751
{
752-
YAML::Node node;
753-
754752
node["enable_du_e2"] = config.enable_du_e2;
755753
node["addr"] = config.ip_addr;
756754
node["port"] = config.port;
@@ -762,8 +760,6 @@ static YAML::Node build_du_high_e2_section(const du_high_unit_e2_config& config)
762760
node["sctp_max_init_timeo"] = config.sctp_max_init_timeo;
763761
node["e2sm_kpm_enabled"] = config.e2sm_kpm_enabled;
764762
node["e2sm_rc_enabled"] = config.e2sm_rc_enabled;
765-
766-
return node;
767763
}
768764

769765
void srsran::fill_du_high_config_in_yaml_schema(YAML::Node& node, const du_high_unit_config& config)
@@ -775,8 +771,8 @@ void srsran::fill_du_high_config_in_yaml_schema(YAML::Node& node, const du_high_
775771
fill_du_high_log_section(node["log"], config.loggers);
776772
fill_du_high_metrics_section(node["metrics"], config.metrics);
777773
fill_du_high_pcap_section(node["pcap"], config.pcaps);
774+
fill_du_high_e2_section(node["e2"], config.e2_cfg);
778775
node["du"] = build_du_section(config);
779-
node["e2"] = build_du_high_e2_section(config.e2_cfg);
780776
if (config.ntn_cfg) {
781777
node["ntn"] = build_du_high_ntn_section(config.ntn_cfg.value());
782778
}

0 commit comments

Comments
 (0)