From 1bffebe0bfc7954081e8ef83f9e4ebbc79f521b4 Mon Sep 17 00:00:00 2001 From: Xavier Arteaga Date: Thu, 7 Oct 2021 16:59:00 +0200 Subject: [PATCH] Removed cached PRACH signals --- srsue/hdr/phy/prach.h | 40 ++++++++++++++-------------------------- srsue/src/phy/prach.cc | 33 +++------------------------------ 2 files changed, 17 insertions(+), 56 deletions(-) diff --git a/srsue/hdr/phy/prach.h b/srsue/hdr/phy/prach.h index cfe9a272d..f858f3266 100644 --- a/srsue/hdr/phy/prach.h +++ b/srsue/hdr/phy/prach.h @@ -41,37 +41,25 @@ public: private: bool generate_buffer(uint32_t f_idx); - bool is_buffer_generated(uint32_t f_idx, uint32_t preamble_index) const - { - return buffer_bitmask.test(f_idx * 64 + preamble_index); - } - - void set_buffer_as_generated(uint32_t f_idx, uint32_t preamble_index) - { - buffer_bitmask.set(f_idx * 64 + preamble_index); - } - private: static constexpr unsigned MAX_LEN_SF = 3; static constexpr unsigned max_fs = 12; static constexpr unsigned max_preambles = 64; - srslog::basic_logger& logger; - srsran_prach_t prach_obj = {}; - srsran_cell_t cell = {}; - srsran_cfo_t cfo_h = {}; - srsran_prach_cfg_t cfg = {}; - std::array, max_fs> buffer = {}; - cf_t* signal_buffer = nullptr; - int preamble_idx = -1; - uint32_t len = 0; - int allowed_subframe = 0; - int transmitted_tti = 0; - float target_power_dbm = 0; - bool mem_initiated = false; - bool cell_initiated = false; - std::bitset buffer_bitmask; - mutable std::mutex mutex; + srslog::basic_logger& logger; + srsran_prach_t prach_obj = {}; + srsran_cell_t cell = {}; + srsran_cfo_t cfo_h = {}; + srsran_prach_cfg_t cfg = {}; + cf_t* signal_buffer = nullptr; + int preamble_idx = -1; + uint32_t len = 0; + int allowed_subframe = 0; + int transmitted_tti = 0; + float target_power_dbm = 0; + bool mem_initiated = false; + bool cell_initiated = false; + mutable std::mutex mutex; }; } // namespace srsue diff --git a/srsue/src/phy/prach.cc b/srsue/src/phy/prach.cc index f227ddf12..8425f7e34 100644 --- a/srsue/src/phy/prach.cc +++ b/srsue/src/phy/prach.cc @@ -33,15 +33,6 @@ using namespace srsue; void prach::init(uint32_t max_prb) { std::lock_guard lock(mutex); - for (auto& i : buffer) { - for (auto& j : i) { - j = srsran_vec_cf_malloc(SRSRAN_PRACH_MAX_LEN); - if (!j) { - perror("malloc"); - return; - } - } - } if (srsran_cfo_init(&cfo_h, SRSRAN_PRACH_MAX_LEN)) { ERROR("PRACH: Error initiating CFO"); @@ -50,7 +41,7 @@ void prach::init(uint32_t max_prb) srsran_cfo_set_tol(&cfo_h, 0); - signal_buffer = srsran_vec_cf_malloc(MAX_LEN_SF * 30720U); + signal_buffer = srsran_vec_cf_malloc(SRSRAN_MAX(MAX_LEN_SF * 30720U, SRSRAN_PRACH_MAX_LEN)); if (!signal_buffer) { perror("malloc"); return; @@ -71,12 +62,6 @@ void prach::stop() return; } - for (auto& i : buffer) { - for (auto& j : i) { - free(j); - } - } - free(signal_buffer); srsran_cfo_free(&cfo_h); srsran_prach_free(&prach_obj); @@ -118,7 +103,6 @@ bool prach::set_cell(srsran_cell_t cell_, srsran_prach_cfg_t prach_cfg) return false; } - buffer_bitmask.reset(); len = prach_obj.N_seq + prach_obj.N_cp; transmitted_tti = -1; cell_initiated = true; @@ -130,22 +114,16 @@ bool prach::set_cell(srsran_cell_t cell_, srsran_prach_cfg_t prach_cfg) bool prach::generate_buffer(uint32_t f_idx) { - if (is_buffer_generated(f_idx, preamble_idx)) { - return true; - } - uint32_t freq_offset = cfg.freq_offset; if (cell.frame_type == SRSRAN_TDD) { freq_offset = srsran_prach_f_ra_tdd( cfg.config_idx, cfg.tdd_config.sf_config, (f_idx / 6) * 10, f_idx % 6, cfg.freq_offset, cell.nof_prb); } - if (srsran_prach_gen(&prach_obj, preamble_idx, freq_offset, buffer[f_idx][preamble_idx])) { + if (srsran_prach_gen(&prach_obj, preamble_idx, freq_offset, signal_buffer)) { Error("Generating PRACH preamble %d", preamble_idx); return false; } - set_buffer_as_generated(f_idx, preamble_idx); - return true; } @@ -239,13 +217,8 @@ cf_t* prach::generate(float cfo, uint32_t* nof_sf, float* target_power) return nullptr; } - if (!is_buffer_generated(f_idx, preamble_idx)) { - Error("PRACH Buffer not generated: f_idx=%d preamble_idx=%d", f_idx, preamble_idx); - return nullptr; - } - // Correct CFO before transmission - srsran_cfo_correct(&cfo_h, buffer[f_idx][preamble_idx], signal_buffer, cfo / srsran_symbol_sz(cell.nof_prb)); + srsran_cfo_correct(&cfo_h, signal_buffer, signal_buffer, cfo / srsran_symbol_sz(cell.nof_prb)); // pad guard symbols with zeros uint32_t nsf = SRSRAN_CEIL(len, SRSRAN_SF_LEN_PRB(cell.nof_prb));