|
| 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 "du_appconfig_yaml_writer.h" |
| 12 | +#include "apps/services/logger/logger_appconfig_yaml_writer.h" |
| 13 | +#include "du_appconfig.h" |
| 14 | + |
| 15 | +using namespace srsran; |
| 16 | + |
| 17 | +static void fill_du_appconfig_metrics_section(YAML::Node node, const srs_du::metrics_appconfig& config) |
| 18 | +{ |
| 19 | + node["enable_json_metrics"] = config.enable_json_metrics; |
| 20 | + node["addr"] = config.addr; |
| 21 | + node["port"] = config.port; |
| 22 | + node["autostart_stdout_metrics"] = config.autostart_stdout_metrics; |
| 23 | + node["stdout_metrics_period"] = config.stdout_metrics_period; |
| 24 | +} |
| 25 | + |
| 26 | +static void fill_du_appconfig_e2_section(YAML::Node node, const e2_appconfig& config) |
| 27 | +{ |
| 28 | + node["enable_du_e2"] = config.enable_du_e2; |
| 29 | + node["addr"] = config.ip_addr; |
| 30 | + node["port"] = config.port; |
| 31 | + node["bind_addr"] = config.bind_addr; |
| 32 | + node["sctp_rto_initial"] = config.sctp_rto_initial; |
| 33 | + node["sctp_rto_min"] = config.sctp_rto_min; |
| 34 | + node["sctp_rto_max"] = config.sctp_rto_max; |
| 35 | + node["sctp_init_max_attempts"] = config.sctp_init_max_attempts; |
| 36 | + node["sctp_max_init_timeo"] = config.sctp_max_init_timeo; |
| 37 | + node["e2sm_kpm_enabled"] = config.e2sm_kpm_enabled; |
| 38 | + node["e2sm_rc_enabled"] = config.e2sm_rc_enabled; |
| 39 | +} |
| 40 | + |
| 41 | +static void fill_du_appconfig_hal_section(YAML::Node node, const std::optional<hal_appconfig>& config) |
| 42 | +{ |
| 43 | + if (!config.has_value()) { |
| 44 | + return; |
| 45 | + } |
| 46 | + YAML::Node hal_node = node["hal"]; |
| 47 | + hal_node["eal_args"] = config.value().eal_args; |
| 48 | +} |
| 49 | + |
| 50 | +static void fill_du_appconfig_expert_execution_section(YAML::Node node, const expert_execution_appconfig& config) |
| 51 | +{ |
| 52 | + { |
| 53 | + YAML::Node affinities_node = node["affinities"]; |
| 54 | + |
| 55 | + if (config.affinities.isolated_cpus.has_value()) { |
| 56 | + affinities_node["isolated_cpus"] = |
| 57 | + fmt::format("{:,}", span<const size_t>(config.affinities.isolated_cpus.value().get_cpu_ids())); |
| 58 | + } |
| 59 | + |
| 60 | + if (config.affinities.low_priority_cpu_cfg.mask.any()) { |
| 61 | + affinities_node["low_priority_cpus"] = |
| 62 | + fmt::format("{:,}", span<const size_t>(config.affinities.low_priority_cpu_cfg.mask.get_cpu_ids())); |
| 63 | + } |
| 64 | + affinities_node["low_priority_pinning"] = to_string(config.affinities.low_priority_cpu_cfg.pinning_policy); |
| 65 | + } |
| 66 | + |
| 67 | + { |
| 68 | + YAML::Node threads_node = node["threads"]; |
| 69 | + YAML::Node non_rt_node = threads_node["non_rt"]; |
| 70 | + non_rt_node["nof_non_rt_threads"] = config.threads.non_rt_threads.nof_non_rt_threads; |
| 71 | + } |
| 72 | +} |
| 73 | + |
| 74 | +static void fill_du_appconfig_buffer_pool_section(YAML::Node node, const buffer_pool_appconfig& config) |
| 75 | +{ |
| 76 | + node["nof_segments"] = config.nof_segments; |
| 77 | + node["segment_size"] = config.segment_size; |
| 78 | +} |
| 79 | + |
| 80 | +static void fill_du_appconfig_nru_section(YAML::Node node, const srs_du::nru_appconfig& config) |
| 81 | +{ |
| 82 | + node["queue_size"] = config.pdu_queue_size; |
| 83 | + node["bind_addr"] = config.bind_address; |
| 84 | +} |
| 85 | + |
| 86 | +static void fill_du_appconfig_f1ap_section(YAML::Node node, const srs_du::f1ap_appconfig& config) |
| 87 | +{ |
| 88 | + node["cu_cp_addr"] = config.cu_cp_address; |
| 89 | + node["bind_addr"] = config.bind_address; |
| 90 | +} |
| 91 | + |
| 92 | +void srsran::fill_du_appconfig_in_yaml_schema(YAML::Node& node, const du_appconfig& config) |
| 93 | +{ |
| 94 | + fill_logger_appconfig_in_yaml_schema(node, config.log_cfg); |
| 95 | + fill_du_appconfig_metrics_section(node["metrics"], config.metrics_cfg); |
| 96 | + fill_du_appconfig_e2_section(node["e2"], config.e2_cfg); |
| 97 | + fill_du_appconfig_hal_section(node, config.hal_config); |
| 98 | + fill_du_appconfig_expert_execution_section(node["expert_execution"], config.expert_execution_cfg); |
| 99 | + fill_du_appconfig_buffer_pool_section(node["buffer_pool"], config.buffer_pool_config); |
| 100 | + fill_du_appconfig_nru_section(node["nru"], config.nru_cfg); |
| 101 | + fill_du_appconfig_f1ap_section(node["f1ap"], config.f1ap_cfg); |
| 102 | +} |
0 commit comments