From 4dd17aee45fabcebdce8bff469806126e1caf97c Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Wed, 21 Apr 2021 15:56:52 +0200 Subject: [PATCH] rrc/phy/nr: calculate tuning freq of NR carrier from RRC signaling params skip initial tuning to hard-coded NR frequency and use RRC-provided values to calculate center frequency --- lib/include/srsran/phy/common/phy_common_nr.h | 1 + lib/src/asn1/rrc_nr_utils.cc | 9 ++++----- lib/src/common/test/band_helper_test.cc | 2 ++ lib/src/phy/ch_estimation/test/csi_rs_test.c | 15 ++++++++------- .../phy/ch_estimation/test/dmrs_pdsch_test.c | 16 ++++++++-------- lib/src/phy/phch/test/pdcch_nr_test.c | 1 + lib/src/phy/phch/test/pdsch_nr_test.c | 16 ++++++++-------- lib/src/phy/phch/test/pucch_nr_test.c | 1 + lib/src/phy/phch/test/pusch_nr_test.c | 15 ++++++++------- lib/src/phy/phch/test/sch_nr_test.c | 15 ++++++++------- lib/test/phy/phy_dl_nr_test.c | 15 ++++++++------- srsue/src/phy/phy.cc | 17 +++++++++++++++++ srsue/src/phy/sync.cc | 5 ----- srsue/src/ue.cc | 3 --- 14 files changed, 74 insertions(+), 57 deletions(-) diff --git a/lib/include/srsran/phy/common/phy_common_nr.h b/lib/include/srsran/phy/common/phy_common_nr.h index 7a4fb454b..315538234 100644 --- a/lib/include/srsran/phy/common/phy_common_nr.h +++ b/lib/include/srsran/phy/common/phy_common_nr.h @@ -280,6 +280,7 @@ typedef struct SRSRAN_API { uint32_t pci; uint32_t absolute_frequency_ssb; uint32_t absolute_frequency_point_a; + uint32_t offset_to_carrier; ///< Offset between point A and the lowest subcarrier of the lowest RB srsran_subcarrier_spacing_t scs; uint32_t nof_prb; ///< @brief See TS 38.101-1 Table 5.3.2-1 for more details uint32_t start; diff --git a/lib/src/asn1/rrc_nr_utils.cc b/lib/src/asn1/rrc_nr_utils.cc index b706a3ced..79d3003dd 100644 --- a/lib/src/asn1/rrc_nr_utils.cc +++ b/lib/src/asn1/rrc_nr_utils.cc @@ -1182,14 +1182,12 @@ bool make_phy_carrier_cfg(const freq_info_dl_s& asn1_freq_info_dl, srsran_carrie asn1::log_warning("Option absolute_freq_ssb not present"); return false; } - uint32_t absolute_frequency_point_a = asn1_freq_info_dl.absolute_freq_point_a; if (asn1_freq_info_dl.scs_specific_carrier_list.size() != 1) { asn1::log_warning("Option absolute_freq_ssb not present"); return false; } - uint32_t nof_prb = asn1_freq_info_dl.scs_specific_carrier_list[0].carrier_bw; - srsran_subcarrier_spacing_t scs = srsran_subcarrier_spacing_15kHz; + srsran_subcarrier_spacing_t scs = srsran_subcarrier_spacing_15kHz; switch (asn1_freq_info_dl.scs_specific_carrier_list[0].subcarrier_spacing) { case subcarrier_spacing_opts::options::khz15: scs = srsran_subcarrier_spacing_15kHz; @@ -1211,8 +1209,9 @@ bool make_phy_carrier_cfg(const freq_info_dl_s& asn1_freq_info_dl, srsran_carrie } // As the carrier structure requires parameters from different objects, set fields separately out_carrier_nr->absolute_frequency_ssb = absolute_frequency_ssb; - out_carrier_nr->absolute_frequency_point_a = absolute_frequency_point_a; - out_carrier_nr->nof_prb = nof_prb; + out_carrier_nr->absolute_frequency_point_a = asn1_freq_info_dl.absolute_freq_point_a; + out_carrier_nr->offset_to_carrier = asn1_freq_info_dl.scs_specific_carrier_list[0].offset_to_carrier; + out_carrier_nr->nof_prb = asn1_freq_info_dl.scs_specific_carrier_list[0].carrier_bw; out_carrier_nr->scs = scs; return true; } diff --git a/lib/src/common/test/band_helper_test.cc b/lib/src/common/test/band_helper_test.cc index ac7e3310a..0e551fd83 100644 --- a/lib/src/common/test/band_helper_test.cc +++ b/lib/src/common/test/band_helper_test.cc @@ -18,6 +18,8 @@ int bands_test_nr() srsran::srsran_band_helper bands; TESTASSERT(bands.nr_arfcn_to_freq(632628) == 3489.42e6); + TESTASSERT(bands.nr_arfcn_to_freq(633928) == 3508.92e6); // default refPointA + TESTASSERT(bands.nr_arfcn_to_freq(634240) == 3513.6e6); // default ARFCN with freq divisible by 11.52 MHz const uint32_t max_valid_nr_arfcn = 3279165; diff --git a/lib/src/phy/ch_estimation/test/csi_rs_test.c b/lib/src/phy/ch_estimation/test/csi_rs_test.c index 606bd02bb..4552f32a1 100644 --- a/lib/src/phy/ch_estimation/test/csi_rs_test.c +++ b/lib/src/phy/ch_estimation/test/csi_rs_test.c @@ -18,13 +18,14 @@ #include static srsran_carrier_nr_t carrier = { - 1, // pci - 0, // absolute_frequency_ssb - 0, // absolute_frequency_point_a - srsran_subcarrier_spacing_15kHz, // scs - 50, // nof_prb - 0, // start - 1 // max_mimo_layers + 1, // pci + 0, // absolute_frequency_ssb + 0, // absolute_frequency_point_a + 0, // offset_to_carrier + srsran_subcarrier_spacing_15kHz, // scs + 50, // nof_prb + 0, // start + 1 // max_mimo_layers }; static float snr_dB = 20.0; diff --git a/lib/src/phy/ch_estimation/test/dmrs_pdsch_test.c b/lib/src/phy/ch_estimation/test/dmrs_pdsch_test.c index c19b711a2..af2f8f39c 100644 --- a/lib/src/phy/ch_estimation/test/dmrs_pdsch_test.c +++ b/lib/src/phy/ch_estimation/test/dmrs_pdsch_test.c @@ -20,15 +20,15 @@ #include #include - static srsran_carrier_nr_t carrier = { - 1, // pci - 0, // absolute_frequency_ssb - 0, // absolute_frequency_point_a - srsran_subcarrier_spacing_15kHz, // scs - 50, // nof_prb - 0, // start - 1 // max_mimo_layers + 1, // pci + 0, // absolute_frequency_ssb + 0, // absolute_frequency_point_a + 0, // offset_to_carrier + srsran_subcarrier_spacing_15kHz, // scs + 50, // nof_prb + 0, // start + 1 // max_mimo_layers }; typedef struct { diff --git a/lib/src/phy/phch/test/pdcch_nr_test.c b/lib/src/phy/phch/test/pdcch_nr_test.c index 5bd26d061..15d880abe 100644 --- a/lib/src/phy/phch/test/pdcch_nr_test.c +++ b/lib/src/phy/phch/test/pdcch_nr_test.c @@ -19,6 +19,7 @@ static srsran_carrier_nr_t carrier = { 1, // pci 0, // absolute_frequency_ssb 0, // absolute_frequency_point_a + 0, // offset_to_carrier srsran_subcarrier_spacing_15kHz, // scs 50, // nof_prb 0, // start diff --git a/lib/src/phy/phch/test/pdsch_nr_test.c b/lib/src/phy/phch/test/pdsch_nr_test.c index b6bd1bca3..93a6ed094 100644 --- a/lib/src/phy/phch/test/pdsch_nr_test.c +++ b/lib/src/phy/phch/test/pdsch_nr_test.c @@ -21,16 +21,16 @@ #include static srsran_carrier_nr_t carrier = { - 1, // pci - 0, // absolute_frequency_ssb - 0, // absolute_frequency_point_a - srsran_subcarrier_spacing_15kHz, // scs - SRSRAN_MAX_PRB_NR, // nof_prb - 0, // start - 1 // max_mimo_layers + 1, // pci + 0, // absolute_frequency_ssb + 0, // absolute_frequency_point_a + 0, // offset_to_carrier + srsran_subcarrier_spacing_15kHz, // scs + SRSRAN_MAX_PRB_NR, // nof_prb + 0, // start + 1 // max_mimo_layers }; - static uint32_t n_prb = 0; // Set to 0 for steering static uint32_t mcs = 30; // Set to 30 for steering static srsran_sch_cfg_nr_t pdsch_cfg = {}; diff --git a/lib/src/phy/phch/test/pucch_nr_test.c b/lib/src/phy/phch/test/pucch_nr_test.c index f2a5ed12b..455787cf7 100644 --- a/lib/src/phy/phch/test/pucch_nr_test.c +++ b/lib/src/phy/phch/test/pucch_nr_test.c @@ -26,6 +26,7 @@ static srsran_carrier_nr_t carrier = { 1, // pci 0, // absolute_frequency_ssb 0, // absolute_frequency_point_a + 0, // offset_to_carrier srsran_subcarrier_spacing_15kHz, // scs 6, // nof_prb 0, // start diff --git a/lib/src/phy/phch/test/pusch_nr_test.c b/lib/src/phy/phch/test/pusch_nr_test.c index bd72b1f09..2ccdb2286 100644 --- a/lib/src/phy/phch/test/pusch_nr_test.c +++ b/lib/src/phy/phch/test/pusch_nr_test.c @@ -20,13 +20,14 @@ #include static srsran_carrier_nr_t carrier = { - 1, // pci - 0, // absolute_frequency_ssb - 0, // absolute_frequency_point_a - srsran_subcarrier_spacing_15kHz, // scs - SRSRAN_MAX_PRB_NR, // nof_prb - 0, // start - 1 // max_mimo_layers + 1, // pci + 0, // absolute_frequency_ssb + 0, // absolute_frequency_point_a + 0, // offset_to_carrier + srsran_subcarrier_spacing_15kHz, // scs + SRSRAN_MAX_PRB_NR, // nof_prb + 0, // start + 1 // max_mimo_layers }; static uint32_t n_prb = 0; // Set to 0 for steering diff --git a/lib/src/phy/phch/test/sch_nr_test.c b/lib/src/phy/phch/test/sch_nr_test.c index 4b1859de1..67dff9105 100644 --- a/lib/src/phy/phch/test/sch_nr_test.c +++ b/lib/src/phy/phch/test/sch_nr_test.c @@ -19,13 +19,14 @@ #include static srsran_carrier_nr_t carrier = { - 1, // pci - 0, // absolute_frequency_ssb - 0, // absolute_frequency_point_a - srsran_subcarrier_spacing_15kHz, // scs - SRSRAN_MAX_PRB_NR, // nof_prb - 0, // start - 1 // max_mimo_layers + 1, // pci + 0, // absolute_frequency_ssb + 0, // absolute_frequency_point_a + 0, // offset_to_carrier + srsran_subcarrier_spacing_15kHz, // scs + SRSRAN_MAX_PRB_NR, // nof_prb + 0, // start + 1 // max_mimo_layers }; static uint32_t n_prb = 0; // Set to 0 for steering diff --git a/lib/test/phy/phy_dl_nr_test.c b/lib/test/phy/phy_dl_nr_test.c index 5e17b0ff1..72fcf3744 100644 --- a/lib/test/phy/phy_dl_nr_test.c +++ b/lib/test/phy/phy_dl_nr_test.c @@ -20,13 +20,14 @@ #include static srsran_carrier_nr_t carrier = { - 501, // pci - 0, // absolute_frequency_ssb - 0, // absolute_frequency_point_a - srsran_subcarrier_spacing_15kHz, // scs - 52, // nof_prb - 0, // start - 1 // max_mimo_layers + 501, // pci + 0, // absolute_frequency_ssb + 0, // absolute_frequency_point_a + 0, // offset_to_carrier + srsran_subcarrier_spacing_15kHz, // scs + 52, // nof_prb + 0, // start + 1 // max_mimo_layers }; static uint32_t n_prb = 0; // Set to 0 for steering diff --git a/srsue/src/phy/phy.cc b/srsue/src/phy/phy.cc index 6ce9d4f5d..2f8302669 100644 --- a/srsue/src/phy/phy.cc +++ b/srsue/src/phy/phy.cc @@ -13,6 +13,7 @@ #include #include +#include "srsran/common/band_helper.h" #include "srsran/common/standard_streams.h" #include "srsran/srsran.h" #include "srsue/hdr/phy/phy.h" @@ -634,6 +635,22 @@ void phy::set_earfcn(std::vector earfcns) bool phy::set_config(const srsran::phy_cfg_nr_t& cfg) { + // Derive actual RF frequencies for NR carrier + double abs_freq_point_a_freq = srsran::srsran_band_helper().nr_arfcn_to_freq(cfg.carrier.absolute_frequency_point_a); + + // for FR1 unit of resources blocks for freq calc is always 180kHz regardless for actual SCS of carrier + // TODO: add offset_to_carrier + double carrier_center_freq = + abs_freq_point_a_freq + + (cfg.carrier.nof_prb / 2 * SRSRAN_SUBC_SPACING_NR(srsran_subcarrier_spacing_t::srsran_subcarrier_spacing_15kHz) * + SRSRAN_NRE); + + for (uint32_t i = 0; i < common.args->nof_nr_carriers; i++) { + logger_phy.info("Tuning channel %d to %.2f GHz", i + common.args->nof_lte_carriers, carrier_center_freq / 1e6); + radio->set_rx_freq(i + common.args->nof_lte_carriers, carrier_center_freq); + radio->set_tx_freq(i + common.args->nof_lte_carriers, carrier_center_freq); + } + return nr_workers.set_config(cfg); } diff --git a/srsue/src/phy/sync.cc b/srsue/src/phy/sync.cc index 0cb69bb02..bb1e0253d 100644 --- a/srsue/src/phy/sync.cc +++ b/srsue/src/phy/sync.cc @@ -861,11 +861,6 @@ bool sync::set_frequency() radio_h->set_rx_freq(0, set_dl_freq); radio_h->set_tx_freq(0, set_ul_freq); - for (uint32_t i = 0; i < worker_com->args->nof_nr_carriers; i++) { - radio_h->set_rx_freq(i + worker_com->args->nof_lte_carriers, worker_com->args->nr_freq_hz); - radio_h->set_tx_freq(i + worker_com->args->nof_lte_carriers, worker_com->args->nr_freq_hz); - } - ul_dl_factor = (float)(set_ul_freq / set_dl_freq); srsran_ue_sync_reset(&ue_sync); diff --git a/srsue/src/ue.cc b/srsue/src/ue.cc index 0197d04a7..ac2ab2951 100644 --- a/srsue/src/ue.cc +++ b/srsue/src/ue.cc @@ -12,7 +12,6 @@ #include "srsue/hdr/ue.h" #include "srsran/build_info.h" -#include "srsran/common/band_helper.h" #include "srsran/common/string_helpers.h" #include "srsran/radio/radio.h" #include "srsran/radio/radio_null.h" @@ -251,8 +250,6 @@ int ue::parse_args(const all_args_t& args_) } } - srsran_band_helper bands_helper; - // populate NR DL ARFCNs if (args.phy.nof_nr_carriers > 0) { if (not args.stack.rrc_nr.supported_bands_nr_str.empty()) {