From 326c5bc25e710c6afb23aefc87b83160ca9fa787 Mon Sep 17 00:00:00 2001 From: Xavier Arteaga Date: Wed, 17 Feb 2021 17:51:32 +0100 Subject: [PATCH] Set secondary Serving cell synchronism bandwidth at cell selection and skip at configuration set-up --- srsue/hdr/phy/scell/scell_sync.h | 60 ++++++++++++++++++++++++++------ srsue/src/phy/sync.cc | 6 ++++ 2 files changed, 55 insertions(+), 11 deletions(-) diff --git a/srsue/hdr/phy/scell/scell_sync.h b/srsue/hdr/phy/scell/scell_sync.h index 0cdd1e261..b626c6ced 100644 --- a/srsue/hdr/phy/scell/scell_sync.h +++ b/srsue/hdr/phy/scell/scell_sync.h @@ -50,6 +50,7 @@ private: uint32_t channel = 0; srslte_sync_t find_pss = {}; int32_t sf_len = 0; + int32_t cell_id = -1; std::array temp = {}; std::mutex mutex; ///< Used for avoiding reconfiguring (set_cell) while it is searching @@ -71,7 +72,6 @@ private: // Run PSS search switch (srslte_sync_find(&find_pss, temp.data(), 0, &peak_pos)) { - case SRSLTE_SYNC_FOUND: if (callback != nullptr) { // Calculate Sample Offset from TTI difference @@ -123,6 +123,32 @@ public: ~sync() { srslte_sync_free(&find_pss); }; + void set_bw(const uint32_t nof_prb) + { + // Protect DSP objects and buffers; As it is called by asynchronous thread, it can wait to finish current processing + std::unique_lock lock(mutex); + + uint32_t symbol_sz = srslte_symbol_sz(nof_prb); + int32_t new_sf_len = SRSLTE_SF_LEN_PRB(nof_prb); + + // Skip if no BW is changed + if (new_sf_len == sf_len) { + return; + } + + // Resize + if (srslte_sync_resize(&find_pss, 2 * new_sf_len, 2 * new_sf_len, symbol_sz) != SRSLTE_SUCCESS) { + ERROR("Error setting cell sync find"); + } + + // Update values + sf_len = new_sf_len; + cell_id = -1; // Force next set_cell to set the ID + + // Reset state to idle + state = STATE_IDLE; + } + /** * Sets the cell for the synchronizer */ @@ -131,25 +157,37 @@ public: // Protect DSP objects and buffers; As it is called by asynchronous thread, it can wait to finish current processing std::unique_lock lock(mutex); - uint32_t symbol_sz = srslte_symbol_sz(cell.nof_prb); - sf_len = SRSLTE_SF_LEN_PRB(cell.nof_prb); + uint32_t symbol_sz = srslte_symbol_sz(cell.nof_prb); + int32_t new_sf_len = SRSLTE_SF_LEN_PRB(cell.nof_prb); + int32_t new_cell_id = cell.id; // Resize Sync object - if (srslte_sync_resize(&find_pss, 2 * sf_len, 2 * sf_len, symbol_sz) != SRSLTE_SUCCESS) { - ERROR("Error setting cell sync find"); + if (new_sf_len != sf_len) { + if (srslte_sync_resize(&find_pss, 2 * new_sf_len, 2 * new_sf_len, symbol_sz) != SRSLTE_SUCCESS) { + ERROR("Error setting cell sync find"); + } + + // Force cell_id set + cell_id = -1; } // Configure - srslte_sync_set_frame_type(&find_pss, cell.frame_type); - srslte_sync_set_N_id_2(&find_pss, cell.id % SRSLTE_NOF_NID_2); - srslte_sync_set_N_id_1(&find_pss, cell.id / SRSLTE_NOF_NID_2); - srslte_sync_set_cfo_ema_alpha(&find_pss, 0.1); - srslte_sync_set_em_alpha(&find_pss, 1); - srslte_sync_set_threshold(&find_pss, 3.0); + if (cell_id != new_cell_id) { + srslte_sync_set_frame_type(&find_pss, cell.frame_type); + srslte_sync_set_N_id_2(&find_pss, new_cell_id % SRSLTE_NOF_NID_2); + srslte_sync_set_N_id_1(&find_pss, new_cell_id / SRSLTE_NOF_NID_2); + srslte_sync_set_cfo_ema_alpha(&find_pss, 0.1); + srslte_sync_set_em_alpha(&find_pss, 1); + srslte_sync_set_threshold(&find_pss, 3.0); + } // Reset Temporal buffer srslte_vec_cf_zero(temp.data(), 2 * sf_len); + // Update new values + sf_len = new_sf_len; + cell_id = new_cell_id; + // Go to search PSS state = STATE_SEARCH_PSS; } diff --git a/srsue/src/phy/sync.cc b/srsue/src/phy/sync.cc index 4629a3b92..61b8bdcbe 100644 --- a/srsue/src/phy/sync.cc +++ b/srsue/src/phy/sync.cc @@ -340,6 +340,12 @@ bool sync::cell_select_start(phy_cell_t new_cell) // Reconfigure first intra-frequency measurement intra_freq_meas[0]->set_primary_cell(current_earfcn, cell); + // Reconfigure secondary serving cell synchronization assuming the same BW than the primary + // The secondary serving cell synchronization will not resize again when the SCell gets configured + for (auto& e : scell_sync) { + e.second->set_bw(cell.nof_prb); + } + // Change sampling rate if necessary if (srate_mode != SRATE_CAMP) { phy_logger.info("Cell Select: Setting CAMPING sampling rate");