diff --git a/lib/src/common/phy_cfg_nr_default.cc b/lib/src/common/phy_cfg_nr_default.cc index 0cd507c7a..e412b4684 100644 --- a/lib/src/common/phy_cfg_nr_default.cc +++ b/lib/src/common/phy_cfg_nr_default.cc @@ -389,7 +389,7 @@ void phy_cfg_nr_default_t::make_harq_auto(srsran_harq_ack_cfg_hl_t& harq, void phy_cfg_nr_default_t::make_prach_default_lte(srsran_prach_cfg_t& prach) { prach.is_nr = true; - prach.config_idx = 0; + prach.config_idx = 8; prach.root_seq_idx = 0; prach.zero_corr_zone = 0; prach.freq_offset = 4; diff --git a/srsenb/hdr/phy/phy_interfaces.h b/srsenb/hdr/phy/phy_interfaces.h index db4cc89e8..dbd080d13 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_pdsch_cfg_t pdsch = {}; srsran_prach_cfg_t prach = {}; }; diff --git a/srsenb/hdr/stack/rrc/nr/rrc_config_nr.h b/srsenb/hdr/stack/rrc/nr/rrc_config_nr.h index 6cac04fe8..d7cfb6284 100644 --- a/srsenb/hdr/stack/rrc/nr/rrc_config_nr.h +++ b/srsenb/hdr/stack/rrc/nr/rrc_config_nr.h @@ -37,6 +37,8 @@ struct rrc_nr_cfg_t { rrc_nr_cfg_sr_t sr_cfg; rrc_cfg_cqi_t cqi_cfg; rrc_cell_list_nr_t cell_list; + asn1::rrc_nr::rach_cfg_common_s rach_cfg_common; + uint16_t prach_root_seq_idx_type; std::string log_name = "RRC-NR"; std::string log_level; diff --git a/srsenb/hdr/stack/rrc/rrc_nr.h b/srsenb/hdr/stack/rrc/rrc_nr.h index 6d8a47d1a..983042db0 100644 --- a/srsenb/hdr/stack/rrc/rrc_nr.h +++ b/srsenb/hdr/stack/rrc/rrc_nr.h @@ -169,8 +169,6 @@ public: int pack_recfg_with_sync(asn1::rrc_nr::cell_group_cfg_s& cell_group_cfg_pack); int pack_recfg_with_sync_sp_cell_cfg_common(asn1::rrc_nr::cell_group_cfg_s& cell_group_cfg_pack); int pack_recfg_with_sync_sp_cell_cfg_common_dl_cfg_common(asn1::rrc_nr::cell_group_cfg_s& cell_group_cfg_pack); - int pack_recfg_with_sync_sp_cell_cfg_common_dl_cfg_common_freq_info_dl( - asn1::rrc_nr::cell_group_cfg_s& cell_group_cfg_pack); int pack_recfg_with_sync_sp_cell_cfg_common_dl_cfg_common_phy_cell_group_cfg( asn1::rrc_nr::cell_group_cfg_s& cell_group_cfg_pack); @@ -179,12 +177,8 @@ public: asn1::rrc_nr::cell_group_cfg_s& cell_group_cfg_pack); int pack_recfg_with_sync_sp_cell_cfg_common_ul_cfg_common(asn1::rrc_nr::cell_group_cfg_s& cell_group_cfg_pack); - int pack_recfg_with_sync_sp_cell_cfg_common_ul_cfg_common_freq_info_ul( - asn1::rrc_nr::cell_group_cfg_s& cell_group_cfg_pack); int pack_recfg_with_sync_sp_cell_cfg_common_ul_cfg_common_init_ul_bwp( asn1::rrc_nr::cell_group_cfg_s& cell_group_cfg_pack); - int pack_recfg_with_sync_sp_cell_cfg_common_ul_cfg_common_init_ul_bwp_rach_cfg_common( - asn1::rrc_nr::cell_group_cfg_s& cell_group_cfg_pack); int pack_recfg_with_sync_sp_cell_cfg_common_ul_cfg_common_init_ul_bwp_pusch_cfg_common( asn1::rrc_nr::cell_group_cfg_s& cell_group_cfg_pack); diff --git a/srsenb/src/enb_cfg_parser.cc b/srsenb/src/enb_cfg_parser.cc index 2897f333e..863fac877 100644 --- a/srsenb/src/enb_cfg_parser.cc +++ b/srsenb/src/enb_cfg_parser.cc @@ -1437,23 +1437,77 @@ int set_derived_args(all_args_t* args_, rrc_cfg_t* rrc_cfg_, phy_cfg_t* phy_cfg_ * the PHY configuration is also updated accordingly. * * @param args_ - * @param nr_rrc_cfg + * @param nr_rrc_cfg_ * @param phy_cfg_ * @return int */ -int set_derived_args_nr(all_args_t* args_, rrc_nr_cfg_t* rrc_cfg_, phy_cfg_t* phy_cfg_) +int set_derived_args_nr(all_args_t* args_, rrc_nr_cfg_t* rrc_nr_cfg_, phy_cfg_t* phy_cfg_) { + // set rach cfg common + auto& rach_cfg_common = rrc_nr_cfg_->rach_cfg_common; + auto& rach_cfg_generic = rach_cfg_common.rach_cfg_generic; + + uint8_t msg1_fdm = 1; // TODO read from config + if (!asn1::number_to_enum(rach_cfg_generic.msg1_fdm, msg1_fdm)) { + ERROR("Config Error: Invalid msg1_fdm (%d)\n", msg1_fdm); + return SRSRAN_ERROR; + } + + rach_cfg_generic.preamb_rx_target_pwr = -110; // TODO read from config + + uint8_t preamb_trans_max = 7; // TODO read from config + if (!asn1::number_to_enum(rach_cfg_generic.preamb_trans_max, preamb_trans_max)) { + ERROR("Config Error: Invalid preamble_trans_max (%d)\n", preamb_trans_max); + return SRSRAN_ERROR; + } + + uint8_t pwr_ramp_step = 4; // TODO read from config + if (!asn1::number_to_enum(rach_cfg_generic.pwr_ramp_step, pwr_ramp_step)) { + ERROR("Config Error: Invalid pwr_ramp_step (%d)\n", pwr_ramp_step); + return SRSRAN_ERROR; + } + + uint8_t ra_resp_win_size = 10; // TODO read from config + if (!asn1::number_to_enum(rach_cfg_generic.ra_resp_win, ra_resp_win_size)) { + ERROR("Config Error: Invalid ra_resp_win_size (%d)\n", ra_resp_win_size); + return SRSRAN_ERROR; + } + + uint8_t ra_contention_resolution_timer = 64; // TODO read from config + if (!asn1::number_to_enum(rach_cfg_common.ra_contention_resolution_timer, ra_contention_resolution_timer)) { + ERROR("Config Error: Invalid mac_con_res_timer (%d)\n", ra_contention_resolution_timer); + return SRSRAN_ERROR; + } + + rrc_nr_cfg_->prach_root_seq_idx_type = 839; // TODO read from config + + std::string restricted_set_cfg = "unrestrictedSet"; // TODO read from config + asn1::rrc_nr::rach_cfg_common_s::prach_root_seq_idx_c_::types_opts root_seq_idx_type; + if (!asn1::string_to_enum(rach_cfg_common.restricted_set_cfg, restricted_set_cfg)) { + ERROR("Config Error: Invalid restricted_set_cfg (%s)\n", restricted_set_cfg.c_str()); + return SRSRAN_ERROR; + } + + rach_cfg_common.ssb_per_rach_occasion_and_cb_preambs_per_ssb_present = true; + rach_cfg_common.ssb_per_rach_occasion_and_cb_preambs_per_ssb.set_one(); // TODO read from config + + uint8_t one_opts = 64; // TODO read from config + if (!asn1::number_to_enum(rach_cfg_common.ssb_per_rach_occasion_and_cb_preambs_per_ssb.one(), one_opts)) { + ERROR("Config Error: Invalid one_opts (%d)\n", one_opts); + return SRSRAN_ERROR; + } + // Use helper class to derive NR carrier parameters srsran::srsran_band_helper band_helper; // we only support one NR cell - if (rrc_cfg_->cell_list.size() > 1) { + if (rrc_nr_cfg_->cell_list.size() > 1) { ERROR("Only a single NR cell supported."); return SRSRAN_ERROR; } // Create NR dedicated cell configuration from RRC configuration - for (auto it = rrc_cfg_->cell_list.begin(); it != rrc_cfg_->cell_list.end(); ++it) { + for (auto it = rrc_nr_cfg_->cell_list.begin(); it != rrc_nr_cfg_->cell_list.end(); ++it) { auto& cfg = *it; cfg.phy_cell.carrier.max_mimo_layers = args_->enb.nof_ports; @@ -1497,7 +1551,7 @@ int set_derived_args_nr(all_args_t* args_, rrc_nr_cfg_t* rrc_cfg_, phy_cfg_t* ph // PRACH cfg.phy_cell.prach.is_nr = true; - cfg.phy_cell.prach.config_idx = 0; + cfg.phy_cell.prach.config_idx = 8; cfg.phy_cell.prach.root_seq_idx = 0; cfg.phy_cell.prach.freq_offset = 1; cfg.phy_cell.prach.num_ra_preambles = cfg.phy_cell.num_ra_preambles; @@ -1537,6 +1591,10 @@ int set_derived_args_nr(all_args_t* args_, rrc_nr_cfg_t* rrc_cfg_, phy_cfg_t* ph 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; + // PDSCH + cfg.phy_cell.pdsch.rs_power = phy_cfg_->pdsch_cnfg.ref_sig_pwr; + cfg.phy_cell.pdsch.p_b = phy_cfg_->pdsch_cnfg.p_b; + // copy center frequencies cfg.phy_cell.carrier.dl_center_frequency_hz = cfg.phy_cell.dl_freq_hz; cfg.phy_cell.carrier.ul_center_frequency_hz = cfg.phy_cell.ul_freq_hz; diff --git a/srsenb/src/enb_cfg_parser.h b/srsenb/src/enb_cfg_parser.h index acc368fd0..569cdd4e2 100644 --- a/srsenb/src/enb_cfg_parser.h +++ b/srsenb/src/enb_cfg_parser.h @@ -40,7 +40,7 @@ namespace enb_conf_sections { int parse_cell_cfg(all_args_t* args_, srsran_cell_t* cell); int parse_cfg_files(all_args_t* args_, rrc_cfg_t* rrc_cfg_, rrc_nr_cfg_t* rrc_cfg_nr_, phy_cfg_t* phy_cfg_); int set_derived_args(all_args_t* args_, rrc_cfg_t* rrc_cfg_, phy_cfg_t* phy_cfg_, const srsran_cell_t& cell_cfg_); -int set_derived_args_nr(all_args_t* args_, rrc_nr_cfg_t* rrc_cfg_, phy_cfg_t* phy_cfg_); +int set_derived_args_nr(all_args_t* args_, rrc_nr_cfg_t* rrc_nr_cfg_, phy_cfg_t* phy_cfg_); } // namespace enb_conf_sections diff --git a/srsenb/src/stack/rrc/nr/cell_asn1_config.cc b/srsenb/src/stack/rrc/nr/cell_asn1_config.cc index f40428945..931e211b9 100644 --- a/srsenb/src/stack/rrc/nr/cell_asn1_config.cc +++ b/srsenb/src/stack/rrc/nr/cell_asn1_config.cc @@ -11,6 +11,7 @@ */ #include "srsenb/hdr/stack/rrc/nr/cell_asn1_config.h" +#include using namespace asn1::rrc_nr; @@ -221,106 +222,294 @@ int fill_csi_meas_from_enb_cfg(const rrc_nr_cfg_t& cfg, csi_meas_cfg_s& csi_meas return SRSRAN_SUCCESS; } -void fill_init_dl_bwp(const rrc_nr_cfg_t& cfg, bwp_dl_ded_s& bwp) +/// Fill InitDlBwp with gNB config +int fill_pdcch_cfg_from_enb_cfg(const rrc_nr_cfg_t& cfg, uint32_t cc, pdcch_cfg_s& pdcch_cfg) { - bwp.pdcch_cfg_present = true; - auto& pdcch_ded_setup = bwp.pdcch_cfg.set_setup(); - pdcch_ded_setup.ctrl_res_set_to_add_mod_list_present = true; - pdcch_ded_setup.ctrl_res_set_to_add_mod_list.resize(1); - pdcch_ded_setup.ctrl_res_set_to_add_mod_list[0].ctrl_res_set_id = 2; - pdcch_ded_setup.ctrl_res_set_to_add_mod_list[0].freq_domain_res.from_number( - 0b111111110000000000000000000000000000000000000); - pdcch_ded_setup.ctrl_res_set_to_add_mod_list[0].dur = 1; - pdcch_ded_setup.ctrl_res_set_to_add_mod_list[0].cce_reg_map_type.set_non_interleaved(); - pdcch_ded_setup.ctrl_res_set_to_add_mod_list[0].precoder_granularity = - asn1::rrc_nr::ctrl_res_set_s::precoder_granularity_opts::same_as_reg_bundle; + auto& cell_cfg = cfg.cell_list.at(cc); - // search spaces - pdcch_ded_setup.search_spaces_to_add_mod_list_present = true; - pdcch_ded_setup.search_spaces_to_add_mod_list.resize(1); - pdcch_ded_setup.search_spaces_to_add_mod_list[0].search_space_id = 2; - pdcch_ded_setup.search_spaces_to_add_mod_list[0].ctrl_res_set_id_present = true; - pdcch_ded_setup.search_spaces_to_add_mod_list[0].ctrl_res_set_id = 2; - pdcch_ded_setup.search_spaces_to_add_mod_list[0].monitoring_slot_periodicity_and_offset_present = true; - pdcch_ded_setup.search_spaces_to_add_mod_list[0].monitoring_slot_periodicity_and_offset.set_sl1(); - pdcch_ded_setup.search_spaces_to_add_mod_list[0].monitoring_symbols_within_slot_present = true; - pdcch_ded_setup.search_spaces_to_add_mod_list[0].monitoring_symbols_within_slot.from_number(0b10000000000000); - pdcch_ded_setup.search_spaces_to_add_mod_list[0].nrof_candidates_present = true; - pdcch_ded_setup.search_spaces_to_add_mod_list[0].nrof_candidates.aggregation_level1 = - asn1::rrc_nr::search_space_s::nrof_candidates_s_::aggregation_level1_opts::n0; - pdcch_ded_setup.search_spaces_to_add_mod_list[0].nrof_candidates.aggregation_level2 = - asn1::rrc_nr::search_space_s::nrof_candidates_s_::aggregation_level2_opts::n2; - pdcch_ded_setup.search_spaces_to_add_mod_list[0].nrof_candidates.aggregation_level4 = - asn1::rrc_nr::search_space_s::nrof_candidates_s_::aggregation_level4_opts::n2; - pdcch_ded_setup.search_spaces_to_add_mod_list[0].nrof_candidates.aggregation_level8 = - asn1::rrc_nr::search_space_s::nrof_candidates_s_::aggregation_level8_opts::n0; - pdcch_ded_setup.search_spaces_to_add_mod_list[0].nrof_candidates.aggregation_level16 = - asn1::rrc_nr::search_space_s::nrof_candidates_s_::aggregation_level16_opts::n0; - pdcch_ded_setup.search_spaces_to_add_mod_list[0].search_space_type_present = true; - pdcch_ded_setup.search_spaces_to_add_mod_list[0].search_space_type.set_ue_specific(); - pdcch_ded_setup.search_spaces_to_add_mod_list[0].search_space_type.ue_specific().dci_formats = asn1::rrc_nr:: - search_space_s::search_space_type_c_::ue_specific_s_::dci_formats_opts::formats0_minus0_and_minus1_minus0; + for (uint32_t cs_idx = 0; cs_idx < SRSRAN_UE_DL_NR_MAX_NOF_CORESET; cs_idx++) { + if (cell_cfg.phy_cell.pdcch.coreset_present[cs_idx]) { + auto& coreset_cfg = cell_cfg.phy_cell.pdcch.coreset[cs_idx]; + + pdcch_cfg.ctrl_res_set_to_add_mod_list_present = true; + + uint8_t cs_mod_list_idx = pdcch_cfg.ctrl_res_set_to_add_mod_list.size(); + pdcch_cfg.ctrl_res_set_to_add_mod_list.resize(cs_mod_list_idx + 1); + auto& ctrl_res_items = pdcch_cfg.ctrl_res_set_to_add_mod_list; + ctrl_res_items[cs_mod_list_idx].ctrl_res_set_id = coreset_cfg.id; + + std::bitset freq_domain_res; + for (uint32_t i = 0; i < SRSRAN_CORESET_FREQ_DOMAIN_RES_SIZE; i++) { + freq_domain_res[SRSRAN_CORESET_FREQ_DOMAIN_RES_SIZE - 1 - i] = coreset_cfg.freq_resources[i]; + } + + ctrl_res_items[cs_mod_list_idx].freq_domain_res.from_number(freq_domain_res.to_ulong()); + ctrl_res_items[cs_mod_list_idx].dur = coreset_cfg.duration; + + if (coreset_cfg.mapping_type == srsran_coreset_mapping_type_non_interleaved) { + ctrl_res_items[cs_mod_list_idx].cce_reg_map_type.set_non_interleaved(); + } else { + ctrl_res_items[cs_mod_list_idx].cce_reg_map_type.set_interleaved(); + } + + if (coreset_cfg.precoder_granularity == srsran_coreset_precoder_granularity_reg_bundle) { + ctrl_res_items[cs_mod_list_idx].precoder_granularity = + asn1::rrc_nr::ctrl_res_set_s::precoder_granularity_opts::same_as_reg_bundle; + } else { + ctrl_res_items[cs_mod_list_idx].precoder_granularity = + asn1::rrc_nr::ctrl_res_set_s::precoder_granularity_opts::all_contiguous_rbs; + } + } + } + + for (uint32_t ss_idx = 0; ss_idx < SRSRAN_UE_DL_NR_MAX_NOF_SEARCH_SPACE; ss_idx++) { + if (cell_cfg.phy_cell.pdcch.search_space_present[ss_idx]) { + // search spaces + auto& search_space_cfg = cell_cfg.phy_cell.pdcch.search_space[ss_idx]; + pdcch_cfg.search_spaces_to_add_mod_list_present = true; + + uint8_t ss_mod_list_idx = pdcch_cfg.search_spaces_to_add_mod_list.size(); + pdcch_cfg.search_spaces_to_add_mod_list.resize(ss_mod_list_idx + 1); + auto& search_spaces = pdcch_cfg.search_spaces_to_add_mod_list; + search_spaces[ss_mod_list_idx].search_space_id = search_space_cfg.id; + search_spaces[ss_mod_list_idx].ctrl_res_set_id_present = true; + search_spaces[ss_mod_list_idx].ctrl_res_set_id = search_space_cfg.coreset_id; + search_spaces[ss_mod_list_idx].monitoring_slot_periodicity_and_offset_present = true; + search_spaces[ss_mod_list_idx].monitoring_slot_periodicity_and_offset.set_sl1(); + search_spaces[ss_mod_list_idx].monitoring_symbols_within_slot_present = true; + search_spaces[ss_mod_list_idx].monitoring_symbols_within_slot.from_number(0b10000000000000); + search_spaces[ss_mod_list_idx].nrof_candidates_present = true; + search_spaces[ss_mod_list_idx].nrof_candidates.aggregation_level1 = + asn1::rrc_nr::search_space_s::nrof_candidates_s_::aggregation_level1_opts::n0; + search_spaces[ss_mod_list_idx].nrof_candidates.aggregation_level2 = + asn1::rrc_nr::search_space_s::nrof_candidates_s_::aggregation_level2_opts::n2; + search_spaces[ss_mod_list_idx].nrof_candidates.aggregation_level4 = + asn1::rrc_nr::search_space_s::nrof_candidates_s_::aggregation_level4_opts::n2; + search_spaces[ss_mod_list_idx].nrof_candidates.aggregation_level8 = + asn1::rrc_nr::search_space_s::nrof_candidates_s_::aggregation_level8_opts::n0; + search_spaces[ss_mod_list_idx].nrof_candidates.aggregation_level16 = + asn1::rrc_nr::search_space_s::nrof_candidates_s_::aggregation_level16_opts::n0; + search_spaces[ss_mod_list_idx].search_space_type_present = true; + + if ((search_space_cfg.type == srsran_search_space_type_common_0) or + (search_space_cfg.type == srsran_search_space_type_common_0A) or + (search_space_cfg.type == srsran_search_space_type_common_1) or + (search_space_cfg.type == srsran_search_space_type_common_2) or + (search_space_cfg.type == srsran_search_space_type_common_3)) { + search_spaces[0].search_space_type.set_common(); + + if ((search_space_cfg.formats[0] == srsran_dci_format_nr_0_0) and + (search_space_cfg.formats[1] == srsran_dci_format_nr_1_0)) { + search_spaces[ss_mod_list_idx].search_space_type.common().dci_format0_minus0_and_format1_minus0_present = + true; + } else { + get_logger(cfg).error("Config Error: Unsupported dci nr formats."); + return SRSRAN_ERROR; + } + } else { + get_logger(cfg).error("Config Error: Unsupported search space type."); + return SRSRAN_ERROR; + } + } + } + return SRSRAN_SUCCESS; +} + +/// Fill InitDlBwp with gNB config +int fill_init_dl_bwp_from_enb_cfg(const rrc_nr_cfg_t& cfg, uint32_t cc, bwp_dl_ded_s& init_dl_bwp) +{ + init_dl_bwp.pdcch_cfg_present = true; + HANDLE_ERROR(fill_pdcch_cfg_from_enb_cfg(cfg, cc, init_dl_bwp.pdcch_cfg.set_setup())); + + // TODO: ADD missing fields + + return SRSRAN_SUCCESS; } /// Fill ServingCellConfig with gNB config -int fill_serv_cell_from_enb_cfg(const rrc_nr_cfg_t& cfg, serving_cell_cfg_s& serv_cell) +int fill_serv_cell_from_enb_cfg(const rrc_nr_cfg_t& cfg, uint32_t cc, serving_cell_cfg_s& serv_cell) { serv_cell.csi_meas_cfg_present = true; HANDLE_ERROR(fill_csi_meas_from_enb_cfg(cfg, serv_cell.csi_meas_cfg.set_setup())); serv_cell.init_dl_bwp_present = true; - fill_init_dl_bwp(cfg, serv_cell.init_dl_bwp); + fill_init_dl_bwp_from_enb_cfg(cfg, cc, serv_cell.init_dl_bwp); // TODO: remaining fields return SRSRAN_SUCCESS; } -void fill_dl_cfg_common_from_enb_cfg(const rrc_nr_cfg_t& cfg, uint32_t cc, dl_cfg_common_s& dl_cfg_common) +int fill_pdcch_cfg_common_from_enb_cfg(const rrc_nr_cfg_t& cfg, uint32_t cc, pdcch_cfg_common_s& pdcch_cfg_common) { - dl_cfg_common.init_dl_bwp_present = true; - dl_cfg_common.init_dl_bwp.pdcch_cfg_common_present = true; - - auto& pdcch_cfg_setup = dl_cfg_common.init_dl_bwp.pdcch_cfg_common.set_setup(); - pdcch_cfg_setup.common_ctrl_res_set_present = true; - pdcch_cfg_setup.common_ctrl_res_set.ctrl_res_set_id = 1; - pdcch_cfg_setup.common_ctrl_res_set.freq_domain_res.from_number(0b111111110000000000000000000000000000000000000); - pdcch_cfg_setup.common_ctrl_res_set.dur = 1; - pdcch_cfg_setup.common_ctrl_res_set.cce_reg_map_type.set_non_interleaved(); - pdcch_cfg_setup.common_ctrl_res_set.precoder_granularity = + pdcch_cfg_common.common_ctrl_res_set_present = true; + pdcch_cfg_common.common_ctrl_res_set.ctrl_res_set_id = 1; + pdcch_cfg_common.common_ctrl_res_set.freq_domain_res.from_number(0b111111110000000000000000000000000000000000000); + pdcch_cfg_common.common_ctrl_res_set.dur = 1; + pdcch_cfg_common.common_ctrl_res_set.cce_reg_map_type.set_non_interleaved(); + pdcch_cfg_common.common_ctrl_res_set.precoder_granularity = asn1::rrc_nr::ctrl_res_set_s::precoder_granularity_opts::same_as_reg_bundle; // common search space list - pdcch_cfg_setup.common_search_space_list_present = true; - pdcch_cfg_setup.common_search_space_list.resize(1); - pdcch_cfg_setup.common_search_space_list[0].search_space_id = 1; - pdcch_cfg_setup.common_search_space_list[0].ctrl_res_set_id_present = true; - pdcch_cfg_setup.common_search_space_list[0].ctrl_res_set_id = 1; - pdcch_cfg_setup.common_search_space_list[0].search_space_type_present = true; - pdcch_cfg_setup.common_search_space_list[0].search_space_type.set_common(); - pdcch_cfg_setup.common_search_space_list[0].search_space_type.common().dci_format0_minus0_and_format1_minus0_present = - true; - pdcch_cfg_setup.common_search_space_list[0].nrof_candidates_present = true; - pdcch_cfg_setup.common_search_space_list[0].nrof_candidates.aggregation_level1 = + pdcch_cfg_common.common_search_space_list_present = true; + pdcch_cfg_common.common_search_space_list.resize(1); + pdcch_cfg_common.common_search_space_list[0].search_space_id = 1; + pdcch_cfg_common.common_search_space_list[0].ctrl_res_set_id_present = true; + pdcch_cfg_common.common_search_space_list[0].ctrl_res_set_id = 1; + pdcch_cfg_common.common_search_space_list[0].search_space_type_present = true; + pdcch_cfg_common.common_search_space_list[0].search_space_type.set_common(); + pdcch_cfg_common.common_search_space_list[0] + .search_space_type.common() + .dci_format0_minus0_and_format1_minus0_present = true; + pdcch_cfg_common.common_search_space_list[0].nrof_candidates_present = true; + pdcch_cfg_common.common_search_space_list[0].nrof_candidates.aggregation_level1 = asn1::rrc_nr::search_space_s::nrof_candidates_s_::aggregation_level1_opts::n1; - pdcch_cfg_setup.common_search_space_list[0].nrof_candidates.aggregation_level2 = + pdcch_cfg_common.common_search_space_list[0].nrof_candidates.aggregation_level2 = asn1::rrc_nr::search_space_s::nrof_candidates_s_::aggregation_level2_opts::n1; - pdcch_cfg_setup.common_search_space_list[0].nrof_candidates.aggregation_level4 = + pdcch_cfg_common.common_search_space_list[0].nrof_candidates.aggregation_level4 = asn1::rrc_nr::search_space_s::nrof_candidates_s_::aggregation_level4_opts::n1; - pdcch_cfg_setup.common_search_space_list[0].nrof_candidates.aggregation_level8 = + pdcch_cfg_common.common_search_space_list[0].nrof_candidates.aggregation_level8 = asn1::rrc_nr::search_space_s::nrof_candidates_s_::aggregation_level8_opts::n0; - pdcch_cfg_setup.common_search_space_list[0].nrof_candidates.aggregation_level16 = + pdcch_cfg_common.common_search_space_list[0].nrof_candidates.aggregation_level16 = asn1::rrc_nr::search_space_s::nrof_candidates_s_::aggregation_level16_opts::n0; - pdcch_cfg_setup.common_search_space_list[0].monitoring_slot_periodicity_and_offset_present = true; - pdcch_cfg_setup.common_search_space_list[0].monitoring_slot_periodicity_and_offset.set_sl1(); - pdcch_cfg_setup.common_search_space_list[0].monitoring_symbols_within_slot_present = true; - pdcch_cfg_setup.common_search_space_list[0].monitoring_symbols_within_slot.from_number(0b10000000000000); - pdcch_cfg_setup.ra_search_space_present = true; - pdcch_cfg_setup.ra_search_space = 1; + pdcch_cfg_common.common_search_space_list[0].monitoring_slot_periodicity_and_offset_present = true; + pdcch_cfg_common.common_search_space_list[0].monitoring_slot_periodicity_and_offset.set_sl1(); + pdcch_cfg_common.common_search_space_list[0].monitoring_symbols_within_slot_present = true; + pdcch_cfg_common.common_search_space_list[0].monitoring_symbols_within_slot.from_number(0b10000000000000); + pdcch_cfg_common.ra_search_space_present = true; + pdcch_cfg_common.ra_search_space = 1; if (cfg.cell_list[cc].duplex_mode == SRSRAN_DUPLEX_MODE_TDD) { - pdcch_cfg_setup.ext = false; + pdcch_cfg_common.ext = false; + } + + return SRSRAN_SUCCESS; +} + +/// Fill FrequencyInfoDL with gNB config +int fill_freq_info_dl_from_enb_cfg(const rrc_nr_cfg_t& cfg, uint32_t cc, freq_info_dl_s& freq_info_dl) +{ + auto& cell_cfg = cfg.cell_list.at(cc); + + freq_info_dl.freq_band_list.push_back(cell_cfg.band); + freq_info_dl.absolute_freq_point_a = cell_cfg.dl_absolute_freq_point_a; + freq_info_dl.absolute_freq_ssb_present = true; + freq_info_dl.absolute_freq_ssb = cell_cfg.ssb_absolute_freq_point; + + freq_info_dl.scs_specific_carrier_list.resize(1); + auto& dl_carrier = freq_info_dl.scs_specific_carrier_list[0]; + dl_carrier.offset_to_carrier = cell_cfg.phy_cell.carrier.offset_to_carrier; + + if (!asn1::number_to_enum(dl_carrier.subcarrier_spacing, + SRSRAN_SUBC_SPACING_NR(cell_cfg.phy_cell.carrier.scs) / 1000)) { + get_logger(cfg).error("Config Error: Invalid subcarrier spacing (%d).\n", + SRSRAN_SUBC_SPACING_NR(cell_cfg.phy_cell.carrier.scs)); + return SRSRAN_ERROR; } + + dl_carrier.carrier_bw = cell_cfg.phy_cell.carrier.nof_prb; + + return SRSRAN_SUCCESS; +} + +/// Fill InitDlBwp with gNB config +int fill_init_dl_bwp_common_from_enb_cfg(const rrc_nr_cfg_t& cfg, uint32_t cc, bwp_dl_common_s& init_dl_bwp) +{ + init_dl_bwp.pdcch_cfg_common_present = true; + HANDLE_ERROR(fill_pdcch_cfg_common_from_enb_cfg(cfg, cc, init_dl_bwp.pdcch_cfg_common.set_setup())); + // TODO: ADD missing fields + + return SRSRAN_SUCCESS; +} + +/// Fill DLCellConfigCommon with gNB config +int fill_dl_cfg_common_from_enb_cfg(const rrc_nr_cfg_t& cfg, uint32_t cc, dl_cfg_common_s& dl_cfg_common) +{ + dl_cfg_common.freq_info_dl_present = true; + HANDLE_ERROR(fill_freq_info_dl_from_enb_cfg(cfg, cc, dl_cfg_common.freq_info_dl)); + + dl_cfg_common.init_dl_bwp_present = true; + HANDLE_ERROR(fill_init_dl_bwp_common_from_enb_cfg(cfg, cc, dl_cfg_common.init_dl_bwp)); + + // TODO: ADD missing fields + + return SRSRAN_SUCCESS; +} + +/// Fill FrequencyInfoUL with gNB config +int fill_freq_info_ul_from_enb_cfg(const rrc_nr_cfg_t& cfg, uint32_t cc, freq_info_ul_s& freq_info_ul) +{ + auto& cell_cfg = cfg.cell_list.at(cc); + + freq_info_ul.freq_band_list_present = true; + freq_info_ul.freq_band_list.push_back(cell_cfg.band); + freq_info_ul.absolute_freq_point_a_present = true; + freq_info_ul.absolute_freq_point_a = cell_cfg.ul_absolute_freq_point_a; + freq_info_ul.scs_specific_carrier_list.resize(1); + + auto& ul_carrier = freq_info_ul.scs_specific_carrier_list[0]; + ul_carrier.offset_to_carrier = cell_cfg.phy_cell.carrier.offset_to_carrier; + + if (!asn1::number_to_enum(ul_carrier.subcarrier_spacing, + SRSRAN_SUBC_SPACING_NR(cell_cfg.phy_cell.carrier.scs) / 1000)) { + get_logger(cfg).error("Config Error: Invalid subcarrier spacing (%d).\n", + SRSRAN_SUBC_SPACING_NR(cell_cfg.phy_cell.carrier.scs)); + return SRSRAN_ERROR; + } + + ul_carrier.carrier_bw = cell_cfg.phy_cell.carrier.nof_prb; + + return SRSRAN_SUCCESS; +} + +/// Fill RachConfigCommon with gNB config +int fill_rach_cfg_common_from_enb_cfg(const rrc_nr_cfg_t& cfg, uint32_t cc, rach_cfg_common_s& rach_cfg_common) +{ + auto& cell_cfg = cfg.cell_list.at(cc); + + rach_cfg_common = cfg.rach_cfg_common; + + rach_cfg_common.rach_cfg_generic.msg1_freq_start = cell_cfg.phy_cell.prach.freq_offset; + rach_cfg_common.rach_cfg_generic.prach_cfg_idx = cell_cfg.phy_cell.prach.config_idx; + rach_cfg_common.rach_cfg_generic.zero_correlation_zone_cfg = cell_cfg.phy_cell.prach.zero_corr_zone; + + if (cfg.prach_root_seq_idx_type == 139) { + rach_cfg_common.prach_root_seq_idx.set_l139() = cell_cfg.phy_cell.prach.root_seq_idx; + } else if (cfg.prach_root_seq_idx_type == 839) { + rach_cfg_common.prach_root_seq_idx.set_l839() = cell_cfg.phy_cell.prach.root_seq_idx; + } else { + get_logger(cfg).error("Config Error: Invalid prach_root_seq_idx_type (%d)\n", cfg.prach_root_seq_idx_type); + return SRSRAN_ERROR; + } + + return SRSRAN_SUCCESS; +} + +/// Fill InitUlBwp with gNB config +int fill_init_ul_bwp_from_enb_cfg(const rrc_nr_cfg_t& cfg, uint32_t cc, bwp_ul_common_s& init_ul_bwp) +{ + init_ul_bwp.rach_cfg_common_present = true; + fill_rach_cfg_common_from_enb_cfg(cfg, cc, init_ul_bwp.rach_cfg_common.set_setup()); + + // TODO: Add missing fields + + return SRSRAN_SUCCESS; +} + +/// Fill ULCellConfigCommon with gNB config +int fill_ul_cfg_common_from_enb_cfg(const rrc_nr_cfg_t& cfg, uint32_t cc, ul_cfg_common_s& ul_cfg_common) +{ + ul_cfg_common.dummy = time_align_timer_opts::ms500; + + ul_cfg_common.freq_info_ul_present = true; + HANDLE_ERROR(fill_freq_info_ul_from_enb_cfg(cfg, cc, ul_cfg_common.freq_info_ul)); + + ul_cfg_common.init_ul_bwp_present = true; + fill_init_ul_bwp_from_enb_cfg(cfg, cc, ul_cfg_common.init_ul_bwp); + + // TODO: Add missing fields + + return SRSRAN_SUCCESS; } /// Fill ServingCellConfigCommon with gNB config @@ -328,7 +517,7 @@ int fill_serv_cell_common_from_enb_cfg(const rrc_nr_cfg_t& cfg, uint32_t cc, ser { auto& cell_cfg = cfg.cell_list.at(cc); - serv_common.ss_pbch_block_pwr = 20; + serv_common.ss_pbch_block_pwr = cell_cfg.phy_cell.pdsch.rs_power; serv_common.n_timing_advance_offset_present = true; serv_common.n_timing_advance_offset = asn1::rrc_nr::serving_cell_cfg_common_s::n_timing_advance_offset_opts::n0; serv_common.n_timing_advance_offset_present = true; @@ -371,6 +560,9 @@ int fill_serv_cell_common_from_enb_cfg(const rrc_nr_cfg_t& cfg, uint32_t cc, ser tdd_config.pattern1.nrof_ul_symbols = 0; } + serv_common.ul_cfg_common_present = true; + fill_ul_cfg_common_from_enb_cfg(cfg, cc, serv_common.ul_cfg_common); + serv_common.dl_cfg_common_present = true; fill_dl_cfg_common_from_enb_cfg(cfg, cc, serv_common.dl_cfg_common); @@ -393,7 +585,7 @@ int fill_sp_cell_cfg_from_enb_cfg(const rrc_nr_cfg_t& cfg, uint32_t cc, sp_cell_ HANDLE_ERROR(fill_recfg_with_sync_from_enb_cfg(cfg, cc, sp_cell.recfg_with_sync)); sp_cell.sp_cell_cfg_ded_present = true; - HANDLE_ERROR(fill_serv_cell_from_enb_cfg(cfg, sp_cell.sp_cell_cfg_ded)); + HANDLE_ERROR(fill_serv_cell_from_enb_cfg(cfg, cc, sp_cell.sp_cell_cfg_ded)); return SRSRAN_SUCCESS; } diff --git a/srsenb/src/stack/rrc/rrc_nr.cc b/srsenb/src/stack/rrc/rrc_nr.cc index 1d6d0c70e..b133ba333 100644 --- a/srsenb/src/stack/rrc/rrc_nr.cc +++ b/srsenb/src/stack/rrc/rrc_nr.cc @@ -1029,25 +1029,6 @@ int rrc_nr::ue::pack_sp_cell_cfg_ded(asn1::rrc_nr::cell_group_cfg_s& cell_group_ return SRSRAN_SUCCESS; } -int rrc_nr::ue::pack_recfg_with_sync_sp_cell_cfg_common_dl_cfg_common_freq_info_dl( - asn1::rrc_nr::cell_group_cfg_s& cell_group_cfg_pack) -{ - cell_group_cfg_pack.sp_cell_cfg.recfg_with_sync.sp_cell_cfg_common.dl_cfg_common.freq_info_dl_present = true; - auto& freq_info_dl = cell_group_cfg_pack.sp_cell_cfg.recfg_with_sync.sp_cell_cfg_common.dl_cfg_common.freq_info_dl; - freq_info_dl.freq_band_list.push_back(parent->cfg.cell_list[0].band); - freq_info_dl.absolute_freq_point_a = parent->cfg.cell_list[0].dl_absolute_freq_point_a; - freq_info_dl.absolute_freq_ssb_present = true; - freq_info_dl.absolute_freq_ssb = parent->cfg.cell_list[0].ssb_absolute_freq_point; - - freq_info_dl.scs_specific_carrier_list.resize(1); - auto& dl_carrier = freq_info_dl.scs_specific_carrier_list[0]; - dl_carrier.offset_to_carrier = 0; - dl_carrier.subcarrier_spacing = subcarrier_spacing_opts::khz15; - dl_carrier.carrier_bw = parent->cfg.cell_list[0].phy_cell.carrier.nof_prb; - - return SRSRAN_SUCCESS; -} - int rrc_nr::ue::pack_recfg_with_sync_sp_cell_cfg_common_dl_cfg_common_phy_cell_group_cfg( asn1::rrc_nr::cell_group_cfg_s& cell_group_cfg_pack) { @@ -1097,73 +1078,12 @@ int rrc_nr::ue::pack_recfg_with_sync_sp_cell_cfg_common_dl_cfg_common( // DL config cell_group_cfg_pack.sp_cell_cfg.recfg_with_sync.sp_cell_cfg_common.dl_cfg_common_present = true; - pack_recfg_with_sync_sp_cell_cfg_common_dl_cfg_common_freq_info_dl(cell_group_cfg_pack); pack_recfg_with_sync_sp_cell_cfg_common_dl_cfg_common_phy_cell_group_cfg(cell_group_cfg_pack); pack_recfg_with_sync_sp_cell_cfg_common_dl_cfg_init_dl_bwp(cell_group_cfg_pack); return SRSRAN_SUCCESS; } -int rrc_nr::ue::pack_recfg_with_sync_sp_cell_cfg_common_ul_cfg_common_freq_info_ul( - asn1::rrc_nr::cell_group_cfg_s& cell_group_cfg_pack) -{ - cell_group_cfg_pack.sp_cell_cfg.recfg_with_sync.sp_cell_cfg_common.ul_cfg_common.freq_info_ul_present = true; - auto& freq_info_ul = cell_group_cfg_pack.sp_cell_cfg.recfg_with_sync.sp_cell_cfg_common.ul_cfg_common.freq_info_ul; - freq_info_ul.freq_band_list_present = true; - freq_info_ul.freq_band_list.push_back(parent->cfg.cell_list[0].band); - freq_info_ul.absolute_freq_point_a_present = true; - freq_info_ul.absolute_freq_point_a = parent->cfg.cell_list[0].ul_absolute_freq_point_a; - freq_info_ul.scs_specific_carrier_list.resize(1); - - auto& ul_carrier = freq_info_ul.scs_specific_carrier_list[0]; - ul_carrier.offset_to_carrier = 0; - ul_carrier.subcarrier_spacing = subcarrier_spacing_opts::khz15; - ul_carrier.carrier_bw = parent->cfg.cell_list[0].phy_cell.carrier.nof_prb; - - return SRSRAN_SUCCESS; -} - -int rrc_nr::ue::pack_recfg_with_sync_sp_cell_cfg_common_ul_cfg_common_init_ul_bwp_rach_cfg_common( - asn1::rrc_nr::cell_group_cfg_s& cell_group_cfg_pack) -{ - // 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(); - - if (parent->cfg.cell_list[0].duplex_mode == SRSRAN_DUPLEX_MODE_FDD) { - rach_cfg_common_pack.setup().rach_cfg_generic.prach_cfg_idx = 16; - } else { - rach_cfg_common_pack.setup().rach_cfg_generic.prach_cfg_idx = 0; - } - - 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 = - asn1::rrc_nr::rach_cfg_generic_s::preamb_trans_max_opts::n7; - rach_cfg_common_pack.setup().rach_cfg_generic.pwr_ramp_step = - asn1::rrc_nr::rach_cfg_generic_s::pwr_ramp_step_opts::db4; - rach_cfg_common_pack.setup().rach_cfg_generic.ra_resp_win = asn1::rrc_nr::rach_cfg_generic_s::ra_resp_win_opts::sl10; - rach_cfg_common_pack.setup().ra_contention_resolution_timer = - asn1::rrc_nr::rach_cfg_common_s::ra_contention_resolution_timer_opts::sf64; - rach_cfg_common_pack.setup().prach_root_seq_idx.set( - asn1::rrc_nr::rach_cfg_common_s::prach_root_seq_idx_c_::types_opts::l839); - rach_cfg_common_pack.setup().prach_root_seq_idx.set_l839() = 0; // matches value in phy_cfg_nr_default_t() - rach_cfg_common_pack.setup().restricted_set_cfg = - asn1::rrc_nr::rach_cfg_common_s::restricted_set_cfg_opts::unrestricted_set; - rach_cfg_common_pack.setup().ssb_per_rach_occasion_and_cb_preambs_per_ssb_present = true; - rach_cfg_common_pack.setup().ssb_per_rach_occasion_and_cb_preambs_per_ssb.set_one(); - rach_cfg_common_pack.setup().ssb_per_rach_occasion_and_cb_preambs_per_ssb.one() = - asn1::rrc_nr::rach_cfg_common_s::ssb_per_rach_occasion_and_cb_preambs_per_ssb_c_::one_opts::n64; - - return SRSRAN_SUCCESS; -} - int rrc_nr::ue::pack_recfg_with_sync_sp_cell_cfg_common_ul_cfg_common_init_ul_bwp_pusch_cfg_common( asn1::rrc_nr::cell_group_cfg_s& cell_group_cfg_pack) { @@ -1210,7 +1130,6 @@ int rrc_nr::ue::pack_recfg_with_sync_sp_cell_cfg_common_ul_cfg_common_init_ul_bw cell_group_cfg_pack.sp_cell_cfg.recfg_with_sync.sp_cell_cfg_common.ul_cfg_common.init_ul_bwp.generic_params .subcarrier_spacing = subcarrier_spacing_opts::khz15; - pack_recfg_with_sync_sp_cell_cfg_common_ul_cfg_common_init_ul_bwp_rach_cfg_common(cell_group_cfg_pack); pack_recfg_with_sync_sp_cell_cfg_common_ul_cfg_common_init_ul_bwp_pusch_cfg_common(cell_group_cfg_pack); return SRSRAN_ERROR; @@ -1223,7 +1142,6 @@ int rrc_nr::ue::pack_recfg_with_sync_sp_cell_cfg_common_ul_cfg_common( cell_group_cfg_pack.sp_cell_cfg.recfg_with_sync.sp_cell_cfg_common.ul_cfg_common_present = true; cell_group_cfg_pack.sp_cell_cfg.recfg_with_sync.sp_cell_cfg_common.ul_cfg_common.dummy = time_align_timer_opts::ms500; - pack_recfg_with_sync_sp_cell_cfg_common_ul_cfg_common_freq_info_ul(cell_group_cfg_pack); pack_recfg_with_sync_sp_cell_cfg_common_ul_cfg_common_init_ul_bwp(cell_group_cfg_pack); return SRSRAN_SUCCESS;