From 992d1bb02a4a39321d1e75ffe237bd5866ceb02e Mon Sep 17 00:00:00 2001 From: Fabian Eckermann Date: Thu, 30 Sep 2021 15:10:19 +0200 Subject: [PATCH] Configure PHY from RRC. --- srsenb/hdr/phy/phy.h | 3 ++- srsenb/hdr/phy/phy_interfaces.h | 1 + srsenb/src/enb_cfg_parser.cc | 42 +++++++++++++++++++++++++++++++++ srsenb/src/phy/phy.cc | 18 ++++---------- srsenb/src/stack/rrc/rrc_nr.cc | 33 ++++++-------------------- 5 files changed, 57 insertions(+), 40 deletions(-) diff --git a/srsenb/hdr/phy/phy.h b/srsenb/hdr/phy/phy.h index 95a1cbb00..bfbbbcb9c 100644 --- a/srsenb/hdr/phy/phy.h +++ b/srsenb/hdr/phy/phy.h @@ -99,7 +99,8 @@ private: bool initialized = false; - srsran_prach_cfg_t prach_cfg = {}; + srsran_prach_cfg_t prach_cfg = {}; + common_cfg_t common_cfg = {}; void parse_common_config(const phy_cfg_t& cfg); }; diff --git a/srsenb/hdr/phy/phy_interfaces.h b/srsenb/hdr/phy/phy_interfaces.h index 35dee14c2..65e3baaf4 100644 --- a/srsenb/hdr/phy/phy_interfaces.h +++ b/srsenb/hdr/phy/phy_interfaces.h @@ -43,6 +43,7 @@ struct phy_cell_cfg_nr_t { uint32_t num_ra_preambles; float gain_db; srsran_pdcch_cfg_nr_t pdcch = {}; ///< Common CORESET and Search Space configuration + srsran_prach_cfg_t prach = {}; }; typedef std::vector phy_cell_cfg_list_t; diff --git a/srsenb/src/enb_cfg_parser.cc b/srsenb/src/enb_cfg_parser.cc index 6f09b5594..2037230ef 100644 --- a/srsenb/src/enb_cfg_parser.cc +++ b/srsenb/src/enb_cfg_parser.cc @@ -1467,6 +1467,48 @@ int set_derived_args_nr(all_args_t* args_, rrc_nr_cfg_t* rrc_cfg_, phy_cfg_t* ph // duplex mode cfg.duplex_mode = band_helper.get_duplex_mode(cfg.band); + // PRACH + cfg.phy_cell.prach.is_nr = true; + cfg.phy_cell.prach.config_idx = 0; + cfg.phy_cell.prach.root_seq_idx = 0; + cfg.phy_cell.prach.freq_offset = phy_cfg_->prach_cnfg.prach_cfg_info.prach_freq_offset; + cfg.phy_cell.prach.num_ra_preambles = cfg.phy_cell.num_ra_preambles; + cfg.phy_cell.prach.hs_flag = phy_cfg_->prach_cnfg.prach_cfg_info.high_speed_flag; + cfg.phy_cell.prach.tdd_config.configured = (cfg.duplex_mode == SRSRAN_DUPLEX_MODE_TDD); + + // PDCCH + // Configure CORESET ID 1 + cfg.phy_cell.pdcch.coreset_present[1] = true; + cfg.phy_cell.pdcch.coreset[1].id = 1; + cfg.phy_cell.pdcch.coreset[1].duration = 1; + cfg.phy_cell.pdcch.coreset[1].mapping_type = srsran_coreset_mapping_type_non_interleaved; + cfg.phy_cell.pdcch.coreset[1].precoder_granularity = srsran_coreset_precoder_granularity_reg_bundle; + + // Generate frequency resources for the full BW + for (uint32_t i = 0; i < SRSRAN_CORESET_FREQ_DOMAIN_RES_SIZE; i++) { + cfg.phy_cell.pdcch.coreset[1].freq_resources[i] = i < SRSRAN_FLOOR(cfg.phy_cell.carrier.nof_prb, 6); + } + + // Configure Search Space 1 as common + cfg.phy_cell.pdcch.search_space_present[1] = true; + cfg.phy_cell.pdcch.search_space[1].id = 1; + cfg.phy_cell.pdcch.search_space[1].coreset_id = 1; + cfg.phy_cell.pdcch.search_space[1].duration = 1; + cfg.phy_cell.pdcch.search_space[1].formats[0] = srsran_dci_format_nr_0_0; // DCI format for PUSCH + cfg.phy_cell.pdcch.search_space[1].formats[1] = srsran_dci_format_nr_1_0; // DCI format for PDSCH + cfg.phy_cell.pdcch.search_space[1].nof_formats = 2; + cfg.phy_cell.pdcch.search_space[1].type = srsran_search_space_type_common_3; + + // Generate 1 candidate for each aggregation level if possible + for (uint32_t L = 0; L < SRSRAN_SEARCH_SPACE_NOF_AGGREGATION_LEVELS_NR; L++) { + cfg.phy_cell.pdcch.search_space[1].nof_candidates[L] = + SRSRAN_MIN(2, srsran_pdcch_nr_max_candidates_coreset(&cfg.phy_cell.pdcch.coreset[1], L)); + } + + cfg.phy_cell.pdcch.ra_search_space_present = true; + cfg.phy_cell.pdcch.ra_search_space = cfg.phy_cell.pdcch.search_space[1]; + cfg.phy_cell.pdcch.ra_search_space.type = srsran_search_space_type_common_1; + phy_cfg_->phy_cell_cfg_nr.push_back(cfg.phy_cell); } diff --git a/srsenb/src/phy/phy.cc b/srsenb/src/phy/phy.cc index 12713b940..7b77d11d1 100644 --- a/srsenb/src/phy/phy.cc +++ b/srsenb/src/phy/phy.cc @@ -339,17 +339,7 @@ int phy::init_nr(const phy_args_t& args, const phy_cfg_t& cfg, stack_interface_p tx_rx.set_nr_workers(nr_workers.get()); - srsran::srsran_band_helper band_helper; - - // perform initial config of PHY (during RRC init PHY isn't running yet) - static const srsran::phy_cfg_nr_t default_phy_cfg = - srsran::phy_cfg_nr_default_t{srsran::phy_cfg_nr_default_t::reference_cfg_t{}}; - srsenb::phy_interface_rrc_nr::common_cfg_t common_cfg = {}; - common_cfg.carrier = default_phy_cfg.carrier; - common_cfg.pdcch = default_phy_cfg.pdcch; - common_cfg.prach = default_phy_cfg.prach; - common_cfg.duplex_mode = SRSRAN_DUPLEX_MODE_TDD; // TODO: make dynamic - if (set_common_cfg(common_cfg) < SRSRAN_SUCCESS) { + if (nr_workers->set_common_cfg(common_cfg)) { phy_log.error("Couldn't set common PHY config"); return SRSRAN_ERROR; } @@ -357,10 +347,12 @@ int phy::init_nr(const phy_args_t& args, const phy_cfg_t& cfg, stack_interface_p return SRSRAN_SUCCESS; } -int phy::set_common_cfg(const phy_interface_rrc_nr::common_cfg_t& common_cfg) +int phy::set_common_cfg(const phy_interface_rrc_nr::common_cfg_t& common_cfg_) { if (nr_workers.get() == nullptr) { - return SRSRAN_ERROR; + // if nr_workers are not initialized yet, store the configuration in the phy + common_cfg = common_cfg_; + return SRSRAN_SUCCESS; } return nr_workers->set_common_cfg(common_cfg); diff --git a/srsenb/src/stack/rrc/rrc_nr.cc b/srsenb/src/stack/rrc/rrc_nr.cc index d6385db7e..6151669f8 100644 --- a/srsenb/src/stack/rrc/rrc_nr.cc +++ b/srsenb/src/stack/rrc/rrc_nr.cc @@ -55,8 +55,7 @@ int rrc_nr::init(const rrc_nr_cfg_t& cfg_, return SRSRAN_ERROR; } - // TODO: PHY isn't initialized at this stage yet - // config_phy(); + config_phy(); // if PHY is not yet initialized, config will be stored and applied on initialization config_mac(); logger.info("Started"); @@ -225,13 +224,12 @@ void rrc_nr::set_activity_user(uint16_t rnti) void rrc_nr::config_phy() { - static const srsran::phy_cfg_nr_t default_phy_cfg = - srsran::phy_cfg_nr_default_t{srsran::phy_cfg_nr_default_t::reference_cfg_t{}}; srsenb::phy_interface_rrc_nr::common_cfg_t common_cfg = {}; - common_cfg.carrier = default_phy_cfg.carrier; - common_cfg.pdcch = default_phy_cfg.pdcch; - common_cfg.prach = default_phy_cfg.prach; - common_cfg.duplex_mode = SRSRAN_DUPLEX_MODE_TDD; // TODO: make dynamic + common_cfg.carrier = cfg.cell_list[0].phy_cell.carrier; + common_cfg.pdcch = cfg.cell_list[0].phy_cell.pdcch; + common_cfg.prach = cfg.cell_list[0].phy_cell.prach; + common_cfg.duplex_mode = cfg.cell_list[0].duplex_mode; + if (phy->set_common_cfg(common_cfg) < SRSRAN_SUCCESS) { logger.error("Couldn't set common PHY config"); return; @@ -981,6 +979,7 @@ int rrc_nr::ue::pack_secondary_cell_group_config_common(asn1::rrc_nr::cell_group rach_cfg_common_pack.set_setup(); rach_cfg_common_pack.setup().rach_cfg_generic.msg1_fdm = rach_cfg_generic_s::msg1_fdm_opts::one; rach_cfg_common_pack.setup().rach_cfg_generic.msg1_freq_start = 1; + rach_cfg_common_pack.setup().rach_cfg_generic.prach_cfg_idx = 0; rach_cfg_common_pack.setup().rach_cfg_generic.zero_correlation_zone_cfg = 0; rach_cfg_common_pack.setup().rach_cfg_generic.preamb_rx_target_pwr = -110; rach_cfg_common_pack.setup().rach_cfg_generic.preamb_trans_max = @@ -1218,15 +1217,6 @@ int rrc_nr::ue::pack_secondary_cell_group_config_fdd(asn1::dyn_octstring& packed cell_group_cfg_pack.sp_cell_cfg.recfg_with_sync.sp_cell_cfg_common.dl_cfg_common.freq_info_dl.absolute_freq_ssb = absolute_freq_ssb; // TODO: calculate from actual DL ARFCN - // RACH config - cell_group_cfg_pack.sp_cell_cfg.recfg_with_sync.sp_cell_cfg_common.ul_cfg_common.init_ul_bwp.rach_cfg_common_present = - true; - auto& rach_cfg_common_pack = - cell_group_cfg_pack.sp_cell_cfg.recfg_with_sync.sp_cell_cfg_common.ul_cfg_common.init_ul_bwp.rach_cfg_common; - - rach_cfg_common_pack.set_setup(); - rach_cfg_common_pack.setup().rach_cfg_generic.prach_cfg_idx = 16; - // SSB config (optional) cell_group_cfg_pack.sp_cell_cfg.recfg_with_sync.sp_cell_cfg_common.ssb_positions_in_burst_present = true; auto& ssb_pos_in_burst = cell_group_cfg_pack.sp_cell_cfg.recfg_with_sync.sp_cell_cfg_common.ssb_positions_in_burst; @@ -1325,15 +1315,6 @@ int rrc_nr::ue::pack_secondary_cell_group_config_tdd(asn1::dyn_octstring& packed pdcch_cfg_common.set_setup(); pdcch_cfg_common.setup().ext = false; - // RACH config - cell_group_cfg_pack.sp_cell_cfg.recfg_with_sync.sp_cell_cfg_common.ul_cfg_common.init_ul_bwp.rach_cfg_common_present = - true; - auto& rach_cfg_common_pack = - cell_group_cfg_pack.sp_cell_cfg.recfg_with_sync.sp_cell_cfg_common.ul_cfg_common.init_ul_bwp.rach_cfg_common; - - rach_cfg_common_pack.set_setup(); - rach_cfg_common_pack.setup().rach_cfg_generic.prach_cfg_idx = 0; - // SSB config (optional) cell_group_cfg_pack.sp_cell_cfg.recfg_with_sync.sp_cell_cfg_common.ssb_positions_in_burst_present = true; auto& ssb_pos_in_burst = cell_group_cfg_pack.sp_cell_cfg.recfg_with_sync.sp_cell_cfg_common.ssb_positions_in_burst;