From 43b12b9ffb47afe50aefdac24e4cb0ffbfae059a Mon Sep 17 00:00:00 2001 From: Francisco Date: Fri, 8 Oct 2021 12:04:29 +0100 Subject: [PATCH] rrc,nr: transfer SSB config to both UE and NR scheduler --- lib/include/srsran/asn1/rrc_nr_utils.h | 4 +- lib/src/asn1/rrc_nr_utils.cc | 4 +- srsenb/hdr/stack/rrc/nr/cell_asn1_config.h | 2 +- srsenb/hdr/stack/rrc/rrc_nr.h | 4 +- srsenb/src/stack/rrc/nr/cell_asn1_config.cc | 65 ++++++++++++++++++++- srsenb/src/stack/rrc/rrc_nr.cc | 60 +++++-------------- 6 files changed, 84 insertions(+), 55 deletions(-) diff --git a/lib/include/srsran/asn1/rrc_nr_utils.h b/lib/include/srsran/asn1/rrc_nr_utils.h index 4a12bf14f..04477dd80 100644 --- a/lib/include/srsran/asn1/rrc_nr_utils.h +++ b/lib/include/srsran/asn1/rrc_nr_utils.h @@ -114,8 +114,8 @@ bool make_phy_carrier_cfg(const asn1::rrc_nr::freq_info_dl_s& freq_info_dl, srsr bool make_phy_ssb_cfg(const srsran_carrier_nr_t& carrier, const asn1::rrc_nr::serving_cell_cfg_common_s& serv_cell_cfg, phy_cfg_nr_t::ssb_cfg_t* ssb); -bool make_pdsch_cfg_from_serv_cell(asn1::rrc_nr::serving_cell_cfg_s& serv_cell, srsran_sch_hl_cfg_nr_t* sch_hl); -bool make_csi_cfg_from_serv_cell(asn1::rrc_nr::serving_cell_cfg_s& serv_cell, srsran_csi_hl_cfg_t* csi_hl); +bool make_pdsch_cfg_from_serv_cell(const asn1::rrc_nr::serving_cell_cfg_s& serv_cell, srsran_sch_hl_cfg_nr_t* sch_hl); +bool make_csi_cfg_from_serv_cell(const asn1::rrc_nr::serving_cell_cfg_s& serv_cell, srsran_csi_hl_cfg_t* csi_hl); /*************************** * MAC Config diff --git a/lib/src/asn1/rrc_nr_utils.cc b/lib/src/asn1/rrc_nr_utils.cc index 98ae4abba..751f8e3a5 100644 --- a/lib/src/asn1/rrc_nr_utils.cc +++ b/lib/src/asn1/rrc_nr_utils.cc @@ -1475,7 +1475,7 @@ bool make_phy_ssb_cfg(const srsran_carrier_nr_t& carrier, return true; } -bool make_pdsch_cfg_from_serv_cell(asn1::rrc_nr::serving_cell_cfg_s& serv_cell, srsran_sch_hl_cfg_nr_t* sch_hl) +bool make_pdsch_cfg_from_serv_cell(const asn1::rrc_nr::serving_cell_cfg_s& serv_cell, srsran_sch_hl_cfg_nr_t* sch_hl) { if (serv_cell.csi_meas_cfg_present and serv_cell.csi_meas_cfg.type().value == @@ -1518,7 +1518,7 @@ bool make_pdsch_cfg_from_serv_cell(asn1::rrc_nr::serving_cell_cfg_s& serv_cell, return true; } -bool make_csi_cfg_from_serv_cell(asn1::rrc_nr::serving_cell_cfg_s& serv_cell, srsran_csi_hl_cfg_t* csi_hl) +bool make_csi_cfg_from_serv_cell(const asn1::rrc_nr::serving_cell_cfg_s& serv_cell, srsran_csi_hl_cfg_t* csi_hl) { if (serv_cell.csi_meas_cfg_present and serv_cell.csi_meas_cfg.type().value == diff --git a/srsenb/hdr/stack/rrc/nr/cell_asn1_config.h b/srsenb/hdr/stack/rrc/nr/cell_asn1_config.h index 0c59c3990..f204cfd3b 100644 --- a/srsenb/hdr/stack/rrc/nr/cell_asn1_config.h +++ b/srsenb/hdr/stack/rrc/nr/cell_asn1_config.h @@ -18,7 +18,7 @@ namespace srsenb { -int fill_serv_cell_from_enb_cfg(const rrc_nr_cfg_t& cfg, asn1::rrc_nr::serving_cell_cfg_s& serv_cell); +int fill_sp_cell_cfg_from_enb_cfg(const rrc_nr_cfg_t& cfg, uint32_t cc, asn1::rrc_nr::sp_cell_cfg_s& sp_cell); } diff --git a/srsenb/hdr/stack/rrc/rrc_nr.h b/srsenb/hdr/stack/rrc/rrc_nr.h index 9c51c1c9a..4d8466c86 100644 --- a/srsenb/hdr/stack/rrc/rrc_nr.h +++ b/srsenb/hdr/stack/rrc/rrc_nr.h @@ -117,7 +117,7 @@ public: bool is_inactive() { return state == rrc_nr_state_t::RRC_INACTIVE; } bool is_endc() { return endc; } uint16_t get_eutra_rnti() { return eutra_rnti; } - void get_metrics(rrc_ue_metrics_t& ue_metrics) { ue_metrics = {}; /*TODO fill RRC metrics*/ }; + void get_metrics(rrc_ue_metrics_t& ue_metrics) { ue_metrics = {}; /*TODO fill RRC metrics*/ }; // setters int pack_rrc_reconfiguration(); @@ -172,8 +172,6 @@ public: 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); - int pack_recfg_with_sync_sp_cell_cfg_common_ssb_cfg(asn1::rrc_nr::cell_group_cfg_s& cell_group_cfg_pack); - int pack_recfg_with_sync_sp_cell_cfg_common_tdd_ul_dl_cfg_common(asn1::rrc_nr::cell_group_cfg_s& cell_group_cfg_pack); diff --git a/srsenb/src/stack/rrc/nr/cell_asn1_config.cc b/srsenb/src/stack/rrc/nr/cell_asn1_config.cc index a70d0256b..978de0cda 100644 --- a/srsenb/src/stack/rrc/nr/cell_asn1_config.cc +++ b/srsenb/src/stack/rrc/nr/cell_asn1_config.cc @@ -14,6 +14,11 @@ using namespace asn1::rrc_nr; +#define HANDLE_ERROR(ret) \ + if ((ret) != SRSRAN_SUCCESS) { \ + return SRSRAN_ERROR; \ + } + namespace srsenb { srslog::basic_logger& get_logger(const rrc_nr_cfg_t& cfg) @@ -220,11 +225,67 @@ int fill_csi_meas_from_enb_cfg(const rrc_nr_cfg_t& cfg, csi_meas_cfg_s& csi_meas int fill_serv_cell_from_enb_cfg(const rrc_nr_cfg_t& cfg, serving_cell_cfg_s& serv_cell) { serv_cell.csi_meas_cfg_present = true; - if (fill_csi_meas_from_enb_cfg(cfg, serv_cell.csi_meas_cfg.set_setup()) != SRSRAN_SUCCESS) { + HANDLE_ERROR(fill_csi_meas_from_enb_cfg(cfg, serv_cell.csi_meas_cfg.set_setup())); + + // TODO: remaining fields + + return SRSRAN_SUCCESS; +} + +/// Fill ServingCellConfigCommon with gNB config +int fill_serv_cell_common_from_enb_cfg(const rrc_nr_cfg_t& cfg, uint32_t cc, serving_cell_cfg_common_s& serv_common) +{ + auto& cell_cfg = cfg.cell_list.at(cc); + + serv_common.ss_pbch_block_pwr = 0; + serv_common.n_timing_advance_offset = asn1::rrc_nr::serving_cell_cfg_common_s::n_timing_advance_offset_opts::n0; + serv_common.dmrs_type_a_position = asn1::rrc_nr::serving_cell_cfg_common_s::dmrs_type_a_position_opts::pos2; + + serv_common.pci_present = true; + serv_common.pci = cell_cfg.phy_cell.carrier.pci; + + serv_common.ssb_periodicity_serving_cell_present = true; + if (not asn1::number_to_enum(serv_common.ssb_periodicity_serving_cell, cell_cfg.ssb_cfg.periodicity_ms)) { + get_logger(cfg).error("Config Error: Invalid SSB periodicity = %d\n", cell_cfg.ssb_cfg.periodicity_ms); return SRSRAN_ERROR; } - // TODO: remaining fields + // Fill SSB config + serv_common.ssb_positions_in_burst_present = true; + if (cfg.cell_list[cc].duplex_mode == SRSRAN_DUPLEX_MODE_FDD) { + serv_common.ssb_positions_in_burst.set_short_bitmap().from_number(0b1000); + } else { + serv_common.ssb_positions_in_burst.set_medium_bitmap().from_number(0b10000000); + } + + // Set SSB SCS + serv_common.ssb_subcarrier_spacing_present = true; + if (cfg.cell_list[cc].duplex_mode == SRSRAN_DUPLEX_MODE_FDD) { + serv_common.ssb_subcarrier_spacing = subcarrier_spacing_opts::khz15; + } else { + serv_common.ssb_subcarrier_spacing = subcarrier_spacing_opts::khz30; + } + + return SRSRAN_SUCCESS; +} + +/// Fill reconfigurationWithSync with gNB config +int fill_recfg_with_sync_from_enb_cfg(const rrc_nr_cfg_t& cfg, uint32_t cc, recfg_with_sync_s& sync) +{ + sync.sp_cell_cfg_common_present = true; + HANDLE_ERROR(fill_serv_cell_common_from_enb_cfg(cfg, cc, sync.sp_cell_cfg_common)); + + return SRSRAN_SUCCESS; +} + +/// Fill spCellConfig with gNB config +int fill_sp_cell_cfg_from_enb_cfg(const rrc_nr_cfg_t& cfg, uint32_t cc, sp_cell_cfg_s& sp_cell) +{ + sp_cell.recfg_with_sync_present = true; + 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)); return SRSRAN_SUCCESS; } diff --git a/srsenb/src/stack/rrc/rrc_nr.cc b/srsenb/src/stack/rrc/rrc_nr.cc index 15b7b2275..9901657fc 100644 --- a/srsenb/src/stack/rrc/rrc_nr.cc +++ b/srsenb/src/stack/rrc/rrc_nr.cc @@ -243,10 +243,16 @@ void rrc_nr::config_mac() std::vector sched_cells_cfg = {srsenb::get_default_cells_cfg(1)}; sched_nr_interface::cell_cfg_t& cell = sched_cells_cfg[0]; - asn1::rrc_nr::serving_cell_cfg_s serv_cell; - int ret = fill_serv_cell_from_enb_cfg(cfg, serv_cell); + // Derive ASN1 from config + asn1::rrc_nr::sp_cell_cfg_s sp_cell; + int ret = fill_sp_cell_cfg_from_enb_cfg(cfg, UE_PSCELL_CC_IDX, sp_cell); srsran_assert(ret == SRSRAN_SUCCESS, "Failed to configure cell"); - bool ret2 = srsran::make_pdsch_cfg_from_serv_cell(serv_cell, &cell.bwps[0].pdsch); + + // Derive cell config from ASN1 + bool ret2 = srsran::make_pdsch_cfg_from_serv_cell(sp_cell.sp_cell_cfg_ded, &cell.bwps[0].pdsch); + srsran_assert(ret2, "Invalid NR cell configuration."); + ret2 = srsran::make_phy_ssb_cfg( + cfg.cell_list[0].phy_cell.carrier, sp_cell.recfg_with_sync.sp_cell_cfg_common, &cell.ssb); srsran_assert(ret2, "Invalid NR cell configuration."); // FIXME: entire SI configuration, etc needs to be ported to NR @@ -941,8 +947,10 @@ int rrc_nr::ue::pack_sp_cell_cfg_ded(asn1::rrc_nr::cell_group_cfg_s& cell_group_ // Serving cell config (only to setup) pack_sp_cell_cfg_ded_pdcch_serving_cell_cfg(cell_group_cfg_pack); - // CSI meas config - fill_serv_cell_from_enb_cfg(parent->cfg, cell_group_cfg_pack.sp_cell_cfg.sp_cell_cfg_ded); + // spCellConfig + if (fill_sp_cell_cfg_from_enb_cfg(parent->cfg, UE_PSCELL_CC_IDX, cell_group_cfg_pack.sp_cell_cfg) != SRSRAN_SUCCESS) { + parent->logger.error("Failed to pack spCellConfig for rnti=0x%x", rnti); + } return SRSRAN_SUCCESS; } @@ -1086,7 +1094,7 @@ int rrc_nr::ue::pack_recfg_with_sync_sp_cell_cfg_common_ul_cfg_common_freq_info_ 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.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]; @@ -1202,26 +1210,6 @@ int rrc_nr::ue::pack_recfg_with_sync_sp_cell_cfg_common_ul_cfg_common( return SRSRAN_SUCCESS; } -int rrc_nr::ue::pack_recfg_with_sync_sp_cell_cfg_common_ssb_cfg(asn1::rrc_nr::cell_group_cfg_s& cell_group_cfg_pack) -{ - // 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; - - if (parent->cfg.cell_list[0].duplex_mode == SRSRAN_DUPLEX_MODE_FDD) { - ssb_pos_in_burst.set_short_bitmap().from_number(0b1000); - } else { - ssb_pos_in_burst.set_medium_bitmap().from_number(0b10000000); - } - - cell_group_cfg_pack.sp_cell_cfg.recfg_with_sync.sp_cell_cfg_common.ssb_periodicity_serving_cell_present = true; - // TODO: get periodicitiy from cell config - cell_group_cfg_pack.sp_cell_cfg.recfg_with_sync.sp_cell_cfg_common.ssb_periodicity_serving_cell = - serving_cell_cfg_common_s::ssb_periodicity_serving_cell_opts::ms10; - - return SRSRAN_SUCCESS; -} - int rrc_nr::ue::pack_recfg_with_sync_sp_cell_cfg_common_tdd_ul_dl_cfg_common( asn1::rrc_nr::cell_group_cfg_s& cell_group_cfg_pack) { @@ -1242,23 +1230,8 @@ int rrc_nr::ue::pack_recfg_with_sync_sp_cell_cfg_common(asn1::rrc_nr::cell_group { auto& pscell_cfg = parent->cfg.cell_list.at(UE_PSCELL_CC_IDX); - cell_group_cfg_pack.sp_cell_cfg.recfg_with_sync.sp_cell_cfg_common_present = true; - cell_group_cfg_pack.sp_cell_cfg.recfg_with_sync.sp_cell_cfg_common.ss_pbch_block_pwr = 0; - cell_group_cfg_pack.sp_cell_cfg.recfg_with_sync.sp_cell_cfg_common.n_timing_advance_offset = - asn1::rrc_nr::serving_cell_cfg_common_s::n_timing_advance_offset_opts::n0; - cell_group_cfg_pack.sp_cell_cfg.recfg_with_sync.sp_cell_cfg_common.dmrs_type_a_position = - asn1::rrc_nr::serving_cell_cfg_common_s::dmrs_type_a_position_opts::pos2; - cell_group_cfg_pack.sp_cell_cfg.recfg_with_sync.sp_cell_cfg_common.pci_present = true; - cell_group_cfg_pack.sp_cell_cfg.recfg_with_sync.sp_cell_cfg_common.pci = pscell_cfg.phy_cell.carrier.pci; - cell_group_cfg_pack.sp_cell_cfg.recfg_with_sync.sp_cell_cfg_common.ssb_subcarrier_spacing_present = true; - - if (parent->cfg.cell_list[0].duplex_mode == SRSRAN_DUPLEX_MODE_FDD) { - cell_group_cfg_pack.sp_cell_cfg.recfg_with_sync.sp_cell_cfg_common.ssb_subcarrier_spacing = - subcarrier_spacing_opts::khz15; - } else { + if (pscell_cfg.duplex_mode == SRSRAN_DUPLEX_MODE_TDD) { cell_group_cfg_pack.sp_cell_cfg.recfg_with_sync.smtc.release(); - cell_group_cfg_pack.sp_cell_cfg.recfg_with_sync.sp_cell_cfg_common.ssb_subcarrier_spacing = - subcarrier_spacing_opts::khz30; } // DL config @@ -1267,9 +1240,6 @@ int rrc_nr::ue::pack_recfg_with_sync_sp_cell_cfg_common(asn1::rrc_nr::cell_group // UL config pack_recfg_with_sync_sp_cell_cfg_common_ul_cfg_common(cell_group_cfg_pack); - // SSB config (optional) - pack_recfg_with_sync_sp_cell_cfg_common_ssb_cfg(cell_group_cfg_pack); - if (parent->cfg.cell_list[0].duplex_mode == SRSRAN_DUPLEX_MODE_TDD) { pack_recfg_with_sync_sp_cell_cfg_common_tdd_ul_dl_cfg_common(cell_group_cfg_pack); }