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+ }
0 commit comments