From faf1cf69759a4c53fc07eef5d7aa827fb71ea420 Mon Sep 17 00:00:00 2001 From: yagoda Date: Mon, 20 Apr 2020 17:33:40 +0200 Subject: [PATCH] limiting prach search space to number of prachs set in sib2 --- lib/include/srslte/phy/phch/prach.h | 3 ++- lib/src/phy/phch/prach.c | 17 ++++++++++++----- lib/src/phy/phch/test/prach_test.c | 21 +++++++++++---------- lib/src/phy/phch/test/prach_test_multi.c | 22 ++++++++++++---------- lib/src/phy/phch/test/prach_test_usrp.c | 12 +++++++----- srsenb/hdr/phy/phy_interfaces.h | 1 + srsenb/src/enb_cfg_parser.cc | 2 ++ srsenb/src/phy/phy.cc | 12 ++++++------ 8 files changed, 53 insertions(+), 37 deletions(-) diff --git a/lib/include/srslte/phy/phch/prach.h b/lib/include/srslte/phy/phch/prach.h index 7b3036873..0a3ee56bb 100644 --- a/lib/include/srslte/phy/phch/prach.h +++ b/lib/include/srslte/phy/phch/prach.h @@ -93,7 +93,7 @@ typedef struct SRSLTE_API { uint32_t deadzone; float peak_values[65]; uint32_t peak_offsets[65]; - + uint32_t num_ra_preambles; srslte_tdd_config_t tdd_config; uint32_t current_prach_idx; @@ -114,6 +114,7 @@ typedef struct { uint32_t root_seq_idx; uint32_t zero_corr_zone; uint32_t freq_offset; + uint32_t num_ra_preambles; bool hs_flag; srslte_tdd_config_t tdd_config; } srslte_prach_cfg_t; diff --git a/lib/src/phy/phch/prach.c b/lib/src/phy/phch/prach.c index 0ddab93af..0e3534c89 100644 --- a/lib/src/phy/phch/prach.c +++ b/lib/src/phy/phch/prach.c @@ -52,7 +52,8 @@ int srslte_prach_set_cell_(srslte_prach_t* p, uint32_t root_seq_index, bool high_speed_flag, uint32_t zero_corr_zone_config, - srslte_tdd_config_t* tdd_config); + srslte_tdd_config_t* tdd_config, + uint32_t num_ra_preambles); uint32_t srslte_prach_get_preamble_format(uint32_t config_idx) { @@ -334,7 +335,8 @@ int srslte_prach_set_cfg(srslte_prach_t* p, srslte_prach_cfg_t* cfg, uint32_t no cfg->root_seq_idx, cfg->hs_flag, cfg->zero_corr_zone, - &cfg->tdd_config); + &cfg->tdd_config, + cfg->num_ra_preambles); } int srslte_prach_init(srslte_prach_t* p, uint32_t max_N_ifft_ul) @@ -402,7 +404,8 @@ int srslte_prach_set_cell_(srslte_prach_t* p, uint32_t root_seq_index, bool high_speed_flag, uint32_t zero_corr_zone_config, - srslte_tdd_config_t* tdd_config) + srslte_tdd_config_t* tdd_config, + uint32_t num_ra_preambles) { int ret = SRSLTE_ERROR; if (p != NULL && N_ifft_ul < 2049 && config_idx < 64 && root_seq_index < MAX_ROOTS) { @@ -418,6 +421,7 @@ int srslte_prach_set_cell_(srslte_prach_t* p, p->hs = high_speed_flag; p->zczc = zero_corr_zone_config; p->detect_factor = PRACH_DETECT_FACTOR; + p->num_ra_preambles = num_ra_preambles; if (tdd_config) { p->tdd_config = *tdd_config; } @@ -463,7 +467,10 @@ int srslte_prach_set_cell_(srslte_prach_t* p, // Generate our 64 sequences p->N_roots = 0; srslte_prach_gen_seqs(p); - + // Ensure num_ra_preambles is valid, if not assign default value + if (p->num_ra_preambles < 4 || p->num_ra_preambles > 64) { + p->num_ra_preambles = p->N_roots; + } // Generate sequence FFTs for (int i = 0; i < N_SEQS; i++) { srslte_dft_run(&p->zc_fft, p->seqs[i], p->dft_seqs[i]); @@ -597,7 +604,7 @@ int srslte_prach_detect_offset(srslte_prach_t* p, memcpy(p->prach_bins, &p->signal_fft[begin], p->N_zc * sizeof(cf_t)); - for (int i = 0; i < p->N_roots; i++) { + for (int i = 0; i < p->num_ra_preambles; i++) { cf_t* root_spec = p->dft_seqs[p->root_seqs_idx[i]]; srslte_vec_prod_conj_ccc(p->prach_bins, root_spec, p->corr_spec, p->N_zc); diff --git a/lib/src/phy/phch/test/prach_test.c b/lib/src/phy/phch/test/prach_test.c index f38113903..51a271d51 100644 --- a/lib/src/phy/phch/test/prach_test.c +++ b/lib/src/phy/phch/test/prach_test.c @@ -32,11 +32,11 @@ #define MAX_LEN 70176 -uint32_t nof_prb = 50; -uint32_t config_idx = 3; -uint32_t root_seq_idx = 0; -uint32_t zero_corr_zone = 15; - +uint32_t nof_prb = 50; +uint32_t config_idx = 3; +uint32_t root_seq_idx = 0; +uint32_t zero_corr_zone = 15; +uint32_t num_ra_preambles = 0; // use default void usage(char* prog) { printf("Usage: %s\n", prog); @@ -82,11 +82,12 @@ int main(int argc, char** argv) srslte_prach_cfg_t prach_cfg; ZERO_OBJECT(prach_cfg); - prach_cfg.config_idx = config_idx; - prach_cfg.hs_flag = high_speed_flag; - prach_cfg.freq_offset = 0; - prach_cfg.root_seq_idx = root_seq_idx; - prach_cfg.zero_corr_zone = zero_corr_zone; + prach_cfg.config_idx = config_idx; + prach_cfg.hs_flag = high_speed_flag; + prach_cfg.freq_offset = 0; + prach_cfg.root_seq_idx = root_seq_idx; + prach_cfg.zero_corr_zone = zero_corr_zone; + prach_cfg.num_ra_preambles = num_ra_preambles; if (srslte_prach_init(&prach, srslte_symbol_sz(nof_prb))) { return -1; diff --git a/lib/src/phy/phch/test/prach_test_multi.c b/lib/src/phy/phch/test/prach_test_multi.c index d3c36958f..a94fe510d 100644 --- a/lib/src/phy/phch/test/prach_test_multi.c +++ b/lib/src/phy/phch/test/prach_test_multi.c @@ -32,11 +32,12 @@ #define MAX_LEN 70176 -uint32_t nof_prb = 6; -uint32_t preamble_format = 0; -uint32_t root_seq_idx = 0; -uint32_t zero_corr_zone = 1; -uint32_t n_seqs = 64; +uint32_t nof_prb = 6; +uint32_t preamble_format = 0; +uint32_t root_seq_idx = 0; +uint32_t zero_corr_zone = 1; +uint32_t n_seqs = 64; +uint32_t num_ra_preambles = 0; // use default void usage(char* prog) { @@ -89,11 +90,12 @@ int main(int argc, char** argv) srslte_prach_cfg_t prach_cfg; ZERO_OBJECT(prach_cfg); - prach_cfg.config_idx = preamble_format; - prach_cfg.hs_flag = high_speed_flag; - prach_cfg.freq_offset = 0; - prach_cfg.root_seq_idx = root_seq_idx; - prach_cfg.zero_corr_zone = zero_corr_zone; + prach_cfg.config_idx = preamble_format; + prach_cfg.hs_flag = high_speed_flag; + prach_cfg.freq_offset = 0; + prach_cfg.root_seq_idx = root_seq_idx; + prach_cfg.zero_corr_zone = zero_corr_zone; + prach_cfg.num_ra_preambles = num_ra_preambles; if (srslte_prach_init(&prach, srslte_symbol_sz(nof_prb))) { return -1; diff --git a/lib/src/phy/phch/test/prach_test_usrp.c b/lib/src/phy/phch/test/prach_test_usrp.c index 00d56fddc..f088e6b51 100644 --- a/lib/src/phy/phch/test/prach_test_usrp.c +++ b/lib/src/phy/phch/test/prach_test_usrp.c @@ -40,6 +40,7 @@ uint32_t frequency_offset = 0; uint32_t zero_corr_zone = 11; float timeadv = 0; uint32_t nof_frames = 20; +uint32_t num_ra_preambles = 0; // use default float uhd_rx_gain = 40, uhd_tx_gain = 60, uhd_freq = 2.4e9; char* uhd_args = ""; @@ -130,11 +131,12 @@ int main(int argc, char** argv) srslte_prach_cfg_t prach_cfg; ZERO_OBJECT(prach_cfg); - prach_cfg.config_idx = preamble_format; - prach_cfg.hs_flag = high_speed_flag; - prach_cfg.freq_offset = 0; - prach_cfg.root_seq_idx = root_seq_idx; - prach_cfg.zero_corr_zone = zero_corr_zone; + prach_cfg.config_idx = preamble_format; + prach_cfg.hs_flag = high_speed_flag; + prach_cfg.freq_offset = 0; + prach_cfg.root_seq_idx = root_seq_idx; + prach_cfg.zero_corr_zone = zero_corr_zone; + prach_cfg.num_ra_preambles = num_ra_preambles; if (srslte_prach_init(&prach, srslte_symbol_sz(nof_prb))) { return -1; diff --git a/srsenb/hdr/phy/phy_interfaces.h b/srsenb/hdr/phy/phy_interfaces.h index 68419c660..be287abe7 100644 --- a/srsenb/hdr/phy/phy_interfaces.h +++ b/srsenb/hdr/phy/phy_interfaces.h @@ -37,6 +37,7 @@ struct phy_cell_cfg_t { double dl_freq_hz; double ul_freq_hz; uint32_t root_seq_idx; + uint32_t num_ra_preambles; }; typedef std::vector phy_cell_cfg_list_t; diff --git a/srsenb/src/enb_cfg_parser.cc b/srsenb/src/enb_cfg_parser.cc index c9b7df072..3ecac6fb8 100644 --- a/srsenb/src/enb_cfg_parser.cc +++ b/srsenb/src/enb_cfg_parser.cc @@ -916,6 +916,8 @@ int set_derived_args(all_args_t* args_, rrc_cfg_t* rrc_cfg_, phy_cfg_t* phy_cfg_ phy_cell_cfg.cell_id = cfg.cell_id; phy_cell_cfg.root_seq_idx = cfg.root_seq_idx; phy_cell_cfg.rf_port = cfg.rf_port; + phy_cell_cfg.num_ra_preambles = + rrc_cfg_->sibs[1].sib2().rr_cfg_common.rach_cfg_common.preamb_info.nof_ra_preambs.to_number(); if (cfg.dl_freq_hz > 0) { phy_cell_cfg.dl_freq_hz = cfg.dl_freq_hz; diff --git a/srsenb/src/phy/phy.cc b/srsenb/src/phy/phy.cc index 87d212b92..06148550d 100644 --- a/srsenb/src/phy/phy.cc +++ b/srsenb/src/phy/phy.cc @@ -62,12 +62,12 @@ phy::~phy() void phy::parse_common_config(const phy_cfg_t& cfg) { // PRACH configuration - prach_cfg.config_idx = cfg.prach_cnfg.prach_cfg_info.prach_cfg_idx; - prach_cfg.hs_flag = cfg.prach_cnfg.prach_cfg_info.high_speed_flag; - prach_cfg.root_seq_idx = cfg.prach_cnfg.root_seq_idx; - prach_cfg.zero_corr_zone = cfg.prach_cnfg.prach_cfg_info.zero_correlation_zone_cfg; - prach_cfg.freq_offset = cfg.prach_cnfg.prach_cfg_info.prach_freq_offset; - + prach_cfg.config_idx = cfg.prach_cnfg.prach_cfg_info.prach_cfg_idx; + prach_cfg.hs_flag = cfg.prach_cnfg.prach_cfg_info.high_speed_flag; + prach_cfg.root_seq_idx = cfg.prach_cnfg.root_seq_idx; + prach_cfg.zero_corr_zone = cfg.prach_cnfg.prach_cfg_info.zero_correlation_zone_cfg; + prach_cfg.freq_offset = cfg.prach_cnfg.prach_cfg_info.prach_freq_offset; + prach_cfg.num_ra_preambles = cfg.phy_cell_cfg.at(0).num_ra_preambles; // DMRS workers_common.dmrs_pusch_cfg.cyclic_shift = cfg.pusch_cnfg.ul_ref_sigs_pusch.cyclic_shift; workers_common.dmrs_pusch_cfg.delta_ss = cfg.pusch_cnfg.ul_ref_sigs_pusch.group_assign_pusch;