From 0c983d0b54645e4d7d5d9bc2bbddb2c1ba516633 Mon Sep 17 00:00:00 2001 From: Francisco Date: Thu, 18 Nov 2021 16:39:14 +0000 Subject: [PATCH] nr,gnb,rrc: set consistent rs_power for SIB1 and phy cfg --- srsgnb/src/stack/rrc/cell_asn1_config.cc | 2 +- srsgnb/src/stack/rrc/rrc_nr_config_utils.cc | 37 ++++++++++++++------- 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/srsgnb/src/stack/rrc/cell_asn1_config.cc b/srsgnb/src/stack/rrc/cell_asn1_config.cc index 0d19a608f..2c4b1967e 100644 --- a/srsgnb/src/stack/rrc/cell_asn1_config.cc +++ b/srsgnb/src/stack/rrc/cell_asn1_config.cc @@ -1053,7 +1053,7 @@ void fill_serv_cell_cfg_common_sib(const rrc_cell_cfg_nr_t& cell_cfg, serving_ce cfg.ssb_periodicity_serving_cell.value = serving_cell_cfg_common_sib_s::ssb_periodicity_serving_cell_opts::ms20; - cfg.ss_pbch_block_pwr = -16; + cfg.ss_pbch_block_pwr = cell_cfg.phy_cell.pdsch.rs_power; } int fill_sib1_from_enb_cfg(const rrc_nr_cfg_t& cfg, uint32_t cc, asn1::rrc_nr::sib1_s& sib1) diff --git a/srsgnb/src/stack/rrc/rrc_nr_config_utils.cc b/srsgnb/src/stack/rrc/rrc_nr_config_utils.cc index 47360416f..059f96b5e 100644 --- a/srsgnb/src/stack/rrc/rrc_nr_config_utils.cc +++ b/srsgnb/src/stack/rrc/rrc_nr_config_utils.cc @@ -30,6 +30,20 @@ namespace srsenb { +template +T uninit_value() +{ + return std::numeric_limits::max(); +} + +template +void set_if_unset(T value, T& out) +{ + if (out == std::numeric_limits::max()) { + out = value; + } +} + /// Generate default phy cell configuration void generate_default_nr_phy_cell(phy_cell_cfg_nr_t& phy_cell) { @@ -44,12 +58,13 @@ void generate_default_nr_phy_cell(phy_cell_cfg_nr_t& phy_cell) phy_cell.num_ra_preambles = 52; // PRACH - phy_cell.prach.is_nr = true; - phy_cell.prach.config_idx = 8; - phy_cell.prach.root_seq_idx = 1; - phy_cell.prach.freq_offset = 1; - phy_cell.prach.num_ra_preambles = phy_cell.num_ra_preambles; - phy_cell.prach.hs_flag = false; + phy_cell.prach.is_nr = true; + phy_cell.prach.config_idx = uninit_value(); + phy_cell.prach.root_seq_idx = 1; + phy_cell.prach.freq_offset = 1; // msg1-FrequencyStart (zero not supported with current PRACH implementation) + phy_cell.prach.zero_corr_zone = uninit_value(); + phy_cell.prach.num_ra_preambles = phy_cell.num_ra_preambles; + phy_cell.prach.hs_flag = false; phy_cell.prach.tdd_config.configured = false; // PDCCH @@ -317,13 +332,11 @@ int set_derived_nr_cell_params(bool is_sa, rrc_cell_cfg_nr_t& cell) // Derive remaining PHY cell params if (is_sa) { // PRACH - cell.phy_cell.prach.config_idx = 16; - cell.phy_cell.prach.freq_offset = 1; // msg1-FrequencyStart (zero not supported with current PRACH implementation) - cell.phy_cell.prach.zero_corr_zone = 15; + set_if_unset(16u, cell.phy_cell.prach.config_idx); + set_if_unset(15u, cell.phy_cell.prach.zero_corr_zone); } else { - cell.phy_cell.prach.config_idx = 0; - cell.phy_cell.prach.freq_offset = 1; - cell.phy_cell.prach.zero_corr_zone = 0; + set_if_unset(0u, cell.phy_cell.prach.config_idx); + set_if_unset(0u, cell.phy_cell.prach.zero_corr_zone); } cell.phy_cell.prach.num_ra_preambles = cell.phy_cell.num_ra_preambles; cell.phy_cell.prach.tdd_config.configured = (cell.duplex_mode == SRSRAN_DUPLEX_MODE_TDD);