From 6219500148bc1a628b64363d95983c31726a067c Mon Sep 17 00:00:00 2001 From: Xavier Arteaga Date: Thu, 25 Mar 2021 12:42:17 +0100 Subject: [PATCH] Added NR-RRC RACH parsing --- lib/include/srsran/asn1/rrc_nr_utils.h | 2 ++ .../interfaces/rrc_nr_interface_types.h | 9 ----- lib/src/asn1/rrc_nr_utils.cc | 34 ++++++++++++++++++- srsue/src/phy/nr/sf_worker.cc | 3 +- srsue/src/phy/nr/worker_pool.cc | 19 ++++++----- srsue/src/stack/rrc/rrc_nr.cc | 8 ++++- 6 files changed, 54 insertions(+), 21 deletions(-) diff --git a/lib/include/srsran/asn1/rrc_nr_utils.h b/lib/include/srsran/asn1/rrc_nr_utils.h index 28cc6eb82..a739a287c 100644 --- a/lib/include/srsran/asn1/rrc_nr_utils.h +++ b/lib/include/srsran/asn1/rrc_nr_utils.h @@ -61,6 +61,8 @@ void to_asn1(asn1::rrc_nr::plmn_id_s* asn1_type, const plmn_id_t& cfg); /*************************** * PHY Config **************************/ +bool make_phy_rach_cfg(const asn1::rrc_nr::rach_cfg_common_s& asn1_type, srsran_prach_cfg_t* prach_cfg); + bool make_phy_tdd_cfg(const asn1::rrc_nr::tdd_ul_dl_cfg_common_s& tdd_ul_dl_cfg_common, srsran_tdd_config_nr_t* srsran_tdd_config_nr); bool make_phy_harq_ack_cfg(const asn1::rrc_nr::phys_cell_group_cfg_s& phys_cell_group_cfg, diff --git a/lib/include/srsran/interfaces/rrc_nr_interface_types.h b/lib/include/srsran/interfaces/rrc_nr_interface_types.h index c0751687f..cc0a8efc8 100644 --- a/lib/include/srsran/interfaces/rrc_nr_interface_types.h +++ b/lib/include/srsran/interfaces/rrc_nr_interface_types.h @@ -35,15 +35,6 @@ struct phy_cfg_nr_t { phy_cfg_nr_t() { - // Default PRACH configuration - prach.is_nr = true; - prach.config_idx = 16; - prach.root_seq_idx = 1; - prach.freq_offset = 0; - prach.zero_corr_zone = 0; - prach.num_ra_preambles = 64; - prach.hs_flag = false; - // tdd-UL-DL-ConfigurationCommon // referenceSubcarrierSpacing: kHz15 (0) // pattern1 diff --git a/lib/src/asn1/rrc_nr_utils.cc b/lib/src/asn1/rrc_nr_utils.cc index 5b1b67da7..ee78d9596 100644 --- a/lib/src/asn1/rrc_nr_utils.cc +++ b/lib/src/asn1/rrc_nr_utils.cc @@ -2,7 +2,7 @@ * * \section COPYRIGHT * - * Copyright 2013-2020 Software Radio Systems Limited + * Copyright 2013-2021 Software Radio Systems Limited * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of @@ -194,6 +194,38 @@ srsran::pdcp_config_t make_drb_pdcp_config_t(const uint8_t bearer_id, bool is_ue return cfg; } +bool make_phy_rach_cfg(const rach_cfg_common_s& asn1_type, srsran_prach_cfg_t* prach_cfg) +{ + prach_cfg->is_nr = true; + prach_cfg->config_idx = asn1_type.rach_cfg_generic.prach_cfg_idx; + prach_cfg->zero_corr_zone = (uint32_t)asn1_type.rach_cfg_generic.zero_correlation_zone_cfg; + prach_cfg->num_ra_preambles = 64; // Hard-coded + prach_cfg->hs_flag = false; // Hard-coded + prach_cfg->tdd_config = {}; // Hard-coded + + // As the current PRACH is based on LTE, the freq-offset shall be subtracted 1 for aligning with NR bandwidth + // For example. A 52 PRB cell with an freq_offset of 1 will match a LTE 50 PRB cell with freq_offset of 0 + prach_cfg->freq_offset = (uint32_t)asn1_type.rach_cfg_generic.msg1_freq_start; + if (prach_cfg->freq_offset == 0) { + asn1::log_error("PRACH freq offset must be at least one"); + return false; + } + prach_cfg->freq_offset--; + + switch (prach_cfg->root_seq_idx = asn1_type.prach_root_seq_idx.type()) { + case rach_cfg_common_s::prach_root_seq_idx_c_::types_opts::l839: + prach_cfg->root_seq_idx = (uint32_t)asn1_type.prach_root_seq_idx.l839(); + break; + case rach_cfg_common_s::prach_root_seq_idx_c_::types_opts::l139: + default: + asn1::log_error("Not-implemented option for prach_root_seq_idx type %s", + asn1_type.prach_root_seq_idx.type().to_string()); + return false; + } + + return true; +}; + bool make_phy_tdd_cfg(const tdd_ul_dl_cfg_common_s& tdd_ul_dl_cfg_common, srsran_tdd_config_nr_t* in_srsran_tdd_config_nr) { diff --git a/srsue/src/phy/nr/sf_worker.cc b/srsue/src/phy/nr/sf_worker.cc index d0560096c..50dca8362 100644 --- a/srsue/src/phy/nr/sf_worker.cc +++ b/srsue/src/phy/nr/sf_worker.cc @@ -84,7 +84,8 @@ void sf_worker::work_imp() tx_buffer.set(0, prach_ptr); // Notify MAC about PRACH transmission - phy_state->stack->prach_sent(TTI_TX(tti_rx), 7, 1, 0, 0); + phy_state->stack->prach_sent( + TTI_TX(tti_rx), 0, SRSRAN_SLOT_NR_MOD(phy_state->carrier.numerology, TTI_TX(tti_rx)), 0, 0); // Transmit NR PRACH phy->worker_end(this, false, tx_buffer, dummy_ts, true); diff --git a/srsue/src/phy/nr/worker_pool.cc b/srsue/src/phy/nr/worker_pool.cc index a821299cf..7bf9c7c3e 100644 --- a/srsue/src/phy/nr/worker_pool.cc +++ b/srsue/src/phy/nr/worker_pool.cc @@ -55,15 +55,6 @@ bool worker_pool::init(const phy_args_nr_t& args, phy_common* common, stack_inte prach_buffer = std::unique_ptr(new prach(prach_log)); prach_buffer->init(phy_state.args.dl.nof_max_prb); - // Set PRACH hard-coded cell - srsran_cell_t cell = {}; - cell.nof_prb = 50; - cell.id = phy_state.carrier.id; - if (not prach_buffer->set_cell(cell, phy_state.cfg.prach)) { - prach_log.error("Setting PRACH cell"); - return false; - } - return true; } @@ -130,6 +121,16 @@ int worker_pool::set_ul_grant(std::array pac bool worker_pool::set_config(const srsran::phy_cfg_nr_t& cfg) { phy_state.cfg = cfg; + + // Set PRACH hard-coded cell + srsran_cell_t cell = {}; + cell.nof_prb = 50; + cell.id = phy_state.carrier.id; + if (not prach_buffer->set_cell(cell, phy_state.cfg.prach)) { + logger.error("Error setting PRACH cell"); + return false; + } + return true; } diff --git a/srsue/src/stack/rrc/rrc_nr.cc b/srsue/src/stack/rrc/rrc_nr.cc index 836805994..dadc003fd 100644 --- a/srsue/src/stack/rrc/rrc_nr.cc +++ b/srsue/src/stack/rrc/rrc_nr.cc @@ -734,6 +734,13 @@ bool rrc_nr::apply_ul_common_cfg(const asn1::rrc_nr::ul_cfg_common_s& ul_cfg_com rach_nr_cfg_t rach_nr_cfg = make_mac_rach_cfg(ul_cfg_common.init_ul_bwp.rach_cfg_common.setup()); phy_cfg.pdcch.ra_rnti = ul_cfg_common.init_ul_bwp.rach_cfg_common.setup().rach_cfg_generic.prach_cfg_idx; mac->set_config(rach_nr_cfg); + + // Make the RACH configuration for PHY + if (not make_phy_rach_cfg(ul_cfg_common.init_ul_bwp.rach_cfg_common.setup(), &phy_cfg.prach)) { + logger.warning("Error parsing rach_cfg_common"); + return false; + } + } else { logger.warning("Option rach_cfg_common not of type setup"); return false; @@ -882,7 +889,6 @@ bool rrc_nr::apply_sp_cell_ded_ul_pusch(const asn1::rrc_nr::pusch_cfg_s& pusch_c } else { logger.warning("Option dmrs_ul_for_pusch_map_type_a not of type setup"); return false; - return false; } } else { logger.warning("Option dmrs_ul_for_pusch_map_type_a not present");