diff --git a/lib/include/srsran/common/band_helper.h b/lib/include/srsran/common/band_helper.h index f354c6403..50ca48cf8 100644 --- a/lib/include/srsran/common/band_helper.h +++ b/lib/include/srsran/common/band_helper.h @@ -114,6 +114,18 @@ public: */ uint32_t get_abs_freq_point_a_arfcn(uint32_t nof_prb, uint32_t arfcn); + /** + * @brief Compute the absolute frequency of the SSB for a DL ARFCN and a band. sThis selects an SSB center frequency + * following the band SS/PBCH frequency raster provided by 38.104 table 5.4.3.1-1 as close as possible to PointA + * without letting any SS/PBCH subcarrier below PointA + * + * @param band nr frequency band. + * @param scs ssb subcarrier spacing. + * @param freq_point_a_arfcn frequency point a in arfcn notation. + * @return absolute frequency of the SSB in arfcn notation. + */ + uint32_t get_abs_freq_ssb_arfcn(uint16_t band, srsran_subcarrier_spacing_t scs, uint32_t freq_point_a_arfcn); + class sync_raster_t { protected: diff --git a/lib/src/common/band_helper.cc b/lib/src/common/band_helper.cc index f9bf798d1..3e4960d5b 100644 --- a/lib/src/common/band_helper.cc +++ b/lib/src/common/band_helper.cc @@ -133,6 +133,29 @@ double srsran_band_helper::get_abs_freq_point_a_from_center_freq(uint32_t nof_pr SRSRAN_NRE); } +uint32_t +srsran_band_helper::get_abs_freq_ssb_arfcn(uint16_t band, srsran_subcarrier_spacing_t scs, uint32_t freq_point_a_arfcn) +{ + double ssb_bw_hz = SRSRAN_SSB_BW_SUBC * SRSRAN_SUBC_SPACING_NR(scs); + + sync_raster_t sync_raster = get_sync_raster(band, scs); + if (!sync_raster.valid()) { + return 0; + } + + double abs_freq_ssb_hz = sync_raster.get_frequency(); + + while (abs_freq_ssb_hz < (nr_arfcn_to_freq(freq_point_a_arfcn) + ssb_bw_hz / 2)) { + sync_raster.next(); + if (sync_raster.end()) { + return 0; + } + abs_freq_ssb_hz = sync_raster.get_frequency(); + } + + return freq_to_nr_arfcn(abs_freq_ssb_hz); +} + srsran_ssb_patern_t srsran_band_helper::get_ssb_pattern(uint16_t band, srsran_subcarrier_spacing_t scs) const { // Look for the given band and SCS diff --git a/srsenb/src/enb_cfg_parser.cc b/srsenb/src/enb_cfg_parser.cc index f432f2df6..3e138ce47 100644 --- a/srsenb/src/enb_cfg_parser.cc +++ b/srsenb/src/enb_cfg_parser.cc @@ -1525,6 +1525,21 @@ 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; + // point a + cfg.phy_cell.carrier.dl_absolute_frequency_point_a = + band_helper.get_abs_freq_point_a_arfcn(cfg.phy_cell.carrier.nof_prb, cfg.dl_arfcn); + cfg.phy_cell.carrier.ul_absolute_frequency_point_a = + band_helper.get_abs_freq_point_a_arfcn(cfg.phy_cell.carrier.nof_prb, cfg.ul_arfcn); + + // ssb freq + if (band_helper.get_ssb_pattern(cfg.band, srsran_subcarrier_spacing_15kHz) != SRSRAN_SSB_PATTERN_INVALID) { + cfg.phy_cell.carrier.absolute_frequency_ssb = band_helper.get_abs_freq_ssb_arfcn( + cfg.band, srsran_subcarrier_spacing_15kHz, cfg.phy_cell.carrier.dl_absolute_frequency_point_a); + } else { + cfg.phy_cell.carrier.absolute_frequency_ssb = band_helper.get_abs_freq_ssb_arfcn( + cfg.band, srsran_subcarrier_spacing_30kHz, cfg.phy_cell.carrier.dl_absolute_frequency_point_a); + } + phy_cfg_->phy_cell_cfg_nr.push_back(cfg.phy_cell); } diff --git a/srsenb/src/stack/rrc/rrc_nr.cc b/srsenb/src/stack/rrc/rrc_nr.cc index 99c1259f8..2adda6c50 100644 --- a/srsenb/src/stack/rrc/rrc_nr.cc +++ b/srsenb/src/stack/rrc/rrc_nr.cc @@ -14,7 +14,6 @@ #include "srsenb/hdr/common/common_enb.h" #include "srsenb/test/mac/nr/sched_nr_cfg_generators.h" #include "srsran/asn1/rrc_nr_utils.h" -#include "srsran/common/band_helper.h" #include "srsran/common/common_nr.h" #include "srsran/common/phy_cfg_nr_default.h" #include "srsran/common/standard_streams.h" @@ -1130,35 +1129,10 @@ int rrc_nr::ue::pack_recfg_with_sync_sp_cell_cfg_common_dl_cfg_common_freq_info_ { 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); - srsran::srsran_band_helper band_helper; - freq_info_dl.absolute_freq_point_a = band_helper.get_abs_freq_point_a_arfcn( - parent->cfg.cell_list[0].phy_cell.carrier.nof_prb, parent->cfg.cell_list[0].dl_arfcn); + freq_info_dl.absolute_freq_point_a = parent->cfg.cell_list[0].phy_cell.carrier.dl_absolute_frequency_point_a; freq_info_dl.absolute_freq_ssb_present = true; - - uint32_t absolute_freq_ssb; - if (parent->cfg.cell_list[0].duplex_mode == SRSRAN_DUPLEX_MODE_FDD) { - if (parent->cfg.cell_list[0].band == 3) { // band n3 - absolute_freq_ssb = 367930; - } else if (parent->cfg.cell_list[0].band == 5) { // band n5 - absolute_freq_ssb = 176210; - } else if (parent->cfg.cell_list[0].band == 7) { // band n7 - absolute_freq_ssb = 529470; - } else { - parent->logger.error("Unsupported dl_arfcn."); - return SRSRAN_ERROR; - } - } else { - if (parent->cfg.cell_list[0].band == 78) { // band n78 - absolute_freq_ssb = 634176; - } else { - parent->logger.error("Unsupported dl_arfcn."); - return SRSRAN_ERROR; - } - } - 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 + freq_info_dl.absolute_freq_ssb = parent->cfg.cell_list[0].phy_cell.carrier.absolute_frequency_ssb; freq_info_dl.scs_specific_carrier_list.resize(1); auto& dl_carrier = freq_info_dl.scs_specific_carrier_list[0]; @@ -1284,19 +1258,13 @@ int rrc_nr::ue::pack_recfg_with_sync_sp_cell_cfg_common_dl_cfg_common( 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) { - srsran::srsran_band_helper band_helper; - cell_group_cfg_pack.sp_cell_cfg.recfg_with_sync.sp_cell_cfg_common.ul_cfg_common.freq_info_ul_present = true; - cell_group_cfg_pack.sp_cell_cfg.recfg_with_sync.sp_cell_cfg_common.ul_cfg_common.freq_info_ul.freq_band_list - .push_back(parent->cfg.cell_list[0].band); - cell_group_cfg_pack.sp_cell_cfg.recfg_with_sync.sp_cell_cfg_common.ul_cfg_common.freq_info_ul.absolute_freq_point_a = - band_helper.get_abs_freq_point_a_arfcn(parent->cfg.cell_list[0].phy_cell.carrier.nof_prb, - parent->cfg.cell_list[0].ul_arfcn); - ; - cell_group_cfg_pack.sp_cell_cfg.recfg_with_sync.sp_cell_cfg_common.ul_cfg_common.freq_info_ul - .scs_specific_carrier_list.resize(1); - auto& ul_carrier = cell_group_cfg_pack.sp_cell_cfg.recfg_with_sync.sp_cell_cfg_common.ul_cfg_common.freq_info_ul - .scs_specific_carrier_list[0]; + 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.push_back(parent->cfg.cell_list[0].band); + freq_info_ul.absolute_freq_point_a = parent->cfg.cell_list[0].phy_cell.carrier.ul_absolute_frequency_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 = 52;