Removed cached PRACH signals

master
Xavier Arteaga 3 years ago
parent aa0c936f50
commit 1bffebe0bf

@ -41,37 +41,25 @@ public:
private: private:
bool generate_buffer(uint32_t f_idx); 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: private:
static constexpr unsigned MAX_LEN_SF = 3; static constexpr unsigned MAX_LEN_SF = 3;
static constexpr unsigned max_fs = 12; static constexpr unsigned max_fs = 12;
static constexpr unsigned max_preambles = 64; static constexpr unsigned max_preambles = 64;
srslog::basic_logger& logger; srslog::basic_logger& logger;
srsran_prach_t prach_obj = {}; srsran_prach_t prach_obj = {};
srsran_cell_t cell = {}; srsran_cell_t cell = {};
srsran_cfo_t cfo_h = {}; srsran_cfo_t cfo_h = {};
srsran_prach_cfg_t cfg = {}; srsran_prach_cfg_t cfg = {};
std::array<std::array<cf_t*, max_preambles>, max_fs> buffer = {}; cf_t* signal_buffer = nullptr;
cf_t* signal_buffer = nullptr; int preamble_idx = -1;
int preamble_idx = -1; uint32_t len = 0;
uint32_t len = 0; int allowed_subframe = 0;
int allowed_subframe = 0; int transmitted_tti = 0;
int transmitted_tti = 0; float target_power_dbm = 0;
float target_power_dbm = 0; bool mem_initiated = false;
bool mem_initiated = false; bool cell_initiated = false;
bool cell_initiated = false; mutable std::mutex mutex;
std::bitset<max_fs * max_preambles> buffer_bitmask;
mutable std::mutex mutex;
}; };
} // namespace srsue } // namespace srsue

@ -33,15 +33,6 @@ using namespace srsue;
void prach::init(uint32_t max_prb) void prach::init(uint32_t max_prb)
{ {
std::lock_guard<std::mutex> lock(mutex); std::lock_guard<std::mutex> 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)) { if (srsran_cfo_init(&cfo_h, SRSRAN_PRACH_MAX_LEN)) {
ERROR("PRACH: Error initiating CFO"); ERROR("PRACH: Error initiating CFO");
@ -50,7 +41,7 @@ void prach::init(uint32_t max_prb)
srsran_cfo_set_tol(&cfo_h, 0); 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) { if (!signal_buffer) {
perror("malloc"); perror("malloc");
return; return;
@ -71,12 +62,6 @@ void prach::stop()
return; return;
} }
for (auto& i : buffer) {
for (auto& j : i) {
free(j);
}
}
free(signal_buffer); free(signal_buffer);
srsran_cfo_free(&cfo_h); srsran_cfo_free(&cfo_h);
srsran_prach_free(&prach_obj); 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; return false;
} }
buffer_bitmask.reset();
len = prach_obj.N_seq + prach_obj.N_cp; len = prach_obj.N_seq + prach_obj.N_cp;
transmitted_tti = -1; transmitted_tti = -1;
cell_initiated = true; 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) 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; uint32_t freq_offset = cfg.freq_offset;
if (cell.frame_type == SRSRAN_TDD) { if (cell.frame_type == SRSRAN_TDD) {
freq_offset = srsran_prach_f_ra_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); 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); Error("Generating PRACH preamble %d", preamble_idx);
return false; return false;
} }
set_buffer_as_generated(f_idx, preamble_idx);
return true; return true;
} }
@ -239,13 +217,8 @@ cf_t* prach::generate(float cfo, uint32_t* nof_sf, float* target_power)
return nullptr; 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 // 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 // pad guard symbols with zeros
uint32_t nsf = SRSRAN_CEIL(len, SRSRAN_SF_LEN_PRB(cell.nof_prb)); uint32_t nsf = SRSRAN_CEIL(len, SRSRAN_SF_LEN_PRB(cell.nof_prb));

Loading…
Cancel
Save