diff --git a/srsue/hdr/phy/scell/scell_state.h b/srsue/hdr/phy/scell/scell_state.h index 6fe33b913..76089e69a 100644 --- a/srsue/hdr/phy/scell/scell_state.h +++ b/srsue/hdr/phy/scell/scell_state.h @@ -100,7 +100,6 @@ public: std::unique_lock lock(mutex); switch (activation_state) { - case idle: // waiting for receiving a command, do nothing break; @@ -114,7 +113,6 @@ public: case transition: // Detect when the TTI has increased enough to make sure there arent workers, set the configuration if (TTI_SUB(tti, activation_tti) >= activation_margin_tti) { - // Reload cell states for (uint32_t i = 1; i < SRSRAN_MAX_CARRIERS; i++) { // Get Activation command value @@ -149,7 +147,6 @@ public: bool is_active(uint32_t cc_idx, uint32_t tti) const { - if (cc_idx == 0) { return true; } @@ -171,7 +168,6 @@ public: bool is_configured(uint32_t cc_idx) const { - if (cc_idx == 0) { return true; } @@ -185,6 +181,22 @@ public: return scell_cfg[cc_idx].status != cfg::none; } + void reset(uint32_t cc_idx) + { + if (cc_idx == 0 or cc_idx >= SRSRAN_MAX_CARRIERS) { + return; + } + + std::unique_lock lock(mutex); + + activation_state = idle; + + cfg& e = scell_cfg[cc_idx]; + e.status = cfg::none; + e.earfcn = 0; + e.pci = UINT32_MAX; + } + void reset() { std::unique_lock lock(mutex); diff --git a/srsue/src/phy/phy.cc b/srsue/src/phy/phy.cc index f0116863a..341db976e 100644 --- a/srsue/src/phy/phy.cc +++ b/srsue/src/phy/phy.cc @@ -500,10 +500,10 @@ bool phy::set_scell(srsran_cell_t cell_info, uint32_t cc_idx, uint32_t earfcn) // Set inter-frequency measurement sfsync.set_inter_frequency_measurement(cc_idx, earfcn, cell_info); - // Store secondary serving cell EARFCN and PCI - common.cell_state.configure(cc_idx, earfcn, cell_info.id); + // Reset secondary serving cell state, prevents this component carrier from executing any PHY processing + common.cell_state.reset(cc_idx); - // Reset cell configuration + // Reset secondary serving cell configuration for (uint32_t i = 0; i < args.nof_phy_threads; i++) { lte_workers[i]->reset_cell_unlocked(cc_idx); } @@ -534,6 +534,9 @@ bool phy::set_scell(srsran_cell_t cell_info, uint32_t cc_idx, uint32_t earfcn) logger_phy.info("Finished setting new SCell configuration cc_idx=%d, earfcn=%d", cc_idx, earfcn); + // Configure secondary serving cell, allows this component carrier to execute PHY processing + common.cell_state.configure(cc_idx, earfcn, cell_info.id); + stack->set_scell_complete(true); }); return true; diff --git a/srsue/src/phy/sync.cc b/srsue/src/phy/sync.cc index 9aedcaa80..aa10b9d9f 100644 --- a/srsue/src/phy/sync.cc +++ b/srsue/src/phy/sync.cc @@ -301,7 +301,6 @@ bool sync::cell_select_init(phy_cell_t new_cell) Info("Cell Select: Going to IDLE"); phy_state.go_idle(); - worker_com->reset(); // Stop intra-frequency measurements if need to change frequency if ((int)new_cell.earfcn != current_earfcn) { @@ -325,11 +324,11 @@ bool sync::cell_select_start(phy_cell_t new_cell) rrc_proc_state = PROC_SELECT_RUNNING; + // Reset SFN and cell search FSMs. They can safely be done while it is CAMPING or IDLE sfn_p.reset(); search_p.reset(); - srsran_ue_sync_reset(&ue_sync); - /* Reconfigure cell if necessary */ + // Reconfigure cell if necessary cell.id = new_cell.pci; if (not set_cell(new_cell.cfo_hz)) { Error("Cell Select: Reconfiguring cell"); @@ -796,6 +795,12 @@ bool sync::set_cell(float cfo) return false; } + // Reset UE sync. Attention: doing this reset when the FSM is NOT IDLE can cause PSS/SSS out-of-sync + srsran_ue_sync_reset(&ue_sync); + + // Reset worker once SYNC is IDLE to flush any worker states such as ACKs and pending grants + worker_com->reset(); + if (!srsran_cell_isvalid(&cell)) { Error("SYNC: Setting cell: invalid cell (nof_prb=%d, pci=%d, ports=%d)", cell.nof_prb, cell.id, cell.nof_ports); return false;