From 91664ef2beef186ef2717b0003da3afe9de839b0 Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Sun, 4 Mar 2018 11:55:58 +0100 Subject: [PATCH] Do sell reselection on IDLE by phch_recv thread instead of worker --- lib/include/srslte/interfaces/ue_interfaces.h | 2 +- srsue/hdr/phy/phch_recv.h | 7 +++++- srsue/hdr/phy/phy.h | 2 +- srsue/src/phy/phch_recv.cc | 24 ++++++++++++++----- srsue/src/phy/phy.cc | 4 ++-- srsue/src/upper/rrc.cc | 22 +++++++---------- 6 files changed, 36 insertions(+), 25 deletions(-) diff --git a/lib/include/srslte/interfaces/ue_interfaces.h b/lib/include/srslte/interfaces/ue_interfaces.h index f18a6737b..52d11416c 100644 --- a/lib/include/srslte/interfaces/ue_interfaces.h +++ b/lib/include/srslte/interfaces/ue_interfaces.h @@ -582,7 +582,7 @@ public: virtual void cell_search_start() = 0; virtual void cell_search_stop() = 0; virtual void cell_search_next() = 0; - virtual bool cell_select(uint32_t earfcn, srslte_cell_t cell) = 0; + virtual void cell_select(uint32_t earfcn, srslte_cell_t cell) = 0; virtual bool cell_handover(srslte_cell_t cell) = 0; /* Is the PHY downlink synchronized? */ diff --git a/srsue/hdr/phy/phch_recv.h b/srsue/hdr/phy/phch_recv.h index cea3004f6..b5848a6b3 100644 --- a/srsue/hdr/phy/phch_recv.h +++ b/srsue/hdr/phy/phch_recv.h @@ -63,7 +63,7 @@ public: void cell_search_start(); void cell_search_stop(); void cell_search_next(bool reset = false); - bool cell_select(uint32_t earfcn, srslte_cell_t cell); + void cell_select(uint32_t earfcn, srslte_cell_t cell); bool cell_handover(srslte_cell_t cell); void meas_reset(); @@ -103,6 +103,10 @@ private: bool set_cell(); void cell_search_inc(); + void cell_reselect(); + + uint32_t new_earfcn; + srslte_cell_t new_cell; bool running; @@ -299,6 +303,7 @@ private: IDLE = 0, CELL_SEARCH, CELL_SELECT, + CELL_RESELECT, CELL_MEASURE, CELL_CAMP, } phy_state; diff --git a/srsue/hdr/phy/phy.h b/srsue/hdr/phy/phy.h index a29480ad4..9270973c0 100644 --- a/srsue/hdr/phy/phy.h +++ b/srsue/hdr/phy/phy.h @@ -87,7 +87,7 @@ public: void cell_search_start(); void cell_search_stop(); void cell_search_next(); - bool cell_select(uint32_t earfcn, srslte_cell_t phy_cell); + void cell_select(uint32_t earfcn, srslte_cell_t phy_cell); bool cell_handover(srslte_cell_t cell); void meas_reset(); diff --git a/srsue/src/phy/phch_recv.cc b/srsue/src/phy/phch_recv.cc index 3c2e4fc1e..7a3efeab7 100644 --- a/srsue/src/phy/phch_recv.cc +++ b/srsue/src/phy/phch_recv.cc @@ -361,9 +361,21 @@ bool phch_recv::cell_handover(srslte_cell_t cell) return ret; } -bool phch_recv::cell_select(uint32_t earfcn, srslte_cell_t cell) { +/* interface from higher layers to select a new cell */ +void phch_recv::cell_select(uint32_t earfcn, srslte_cell_t cell) { - // Check if we are already camping in this cell + new_earfcn = earfcn; + new_cell = cell; + phy_state = CELL_RESELECT; +} + +/* Perform cell (re)-selection on IDLE or CAMP */ +void phch_recv::cell_reselect() +{ + uint32_t earfcn = new_earfcn; + srslte_cell_t cell = new_cell; + + // If we are already in the new cell, just resynchronize if (earfcn == current_earfcn && this->cell.id == cell.id) { log_h->info("Cell Select: Already in cell EARFCN=%d\n", earfcn); cell_search_in_progress = false; @@ -371,15 +383,14 @@ bool phch_recv::cell_select(uint32_t earfcn, srslte_cell_t cell) { set_sampling_rate(); } phy_state = CELL_SELECT; - return true; } else { + /* If we are going to a new cell, configure it */ cell_search_in_progress = false; if (earfcn != current_earfcn) { if (set_frequency()) { log_h->error("Cell Select: Configuring cell in EARFCN=%d, PCI=%d\n", earfcn, cell.id); - return false; } current_earfcn = earfcn; } @@ -390,9 +401,7 @@ bool phch_recv::cell_select(uint32_t earfcn, srslte_cell_t cell) { if (set_cell()) { log_h->info("Cell Select: Synchronizing on cell...\n"); phy_state = CELL_SELECT; - return true; } - return false; } } @@ -559,6 +568,9 @@ void phch_recv::run_thread() } } break; + case CELL_RESELECT: + cell_reselect(); + break; case CELL_SELECT: switch (sfn_p.run_subframe(&cell, &tti)) { diff --git a/srsue/src/phy/phy.cc b/srsue/src/phy/phy.cc index 3dfb5889a..a2d517a02 100644 --- a/srsue/src/phy/phy.cc +++ b/srsue/src/phy/phy.cc @@ -282,9 +282,9 @@ int phy::meas_stop(uint32_t earfcn, int pci) { return sf_recv.meas_stop(earfcn, pci); } -bool phy::cell_select(uint32_t earfcn, srslte_cell_t phy_cell) +void phy::cell_select(uint32_t earfcn, srslte_cell_t phy_cell) { - return sf_recv.cell_select(earfcn, phy_cell); + sf_recv.cell_select(earfcn, phy_cell); } bool phy::cell_handover(srslte_cell_t cell) { diff --git a/srsue/src/upper/rrc.cc b/srsue/src/upper/rrc.cc index dfb356b92..1aecb273b 100644 --- a/srsue/src/upper/rrc.cc +++ b/srsue/src/upper/rrc.cc @@ -525,20 +525,14 @@ void rrc::select_next_cell_in_plmn() { neighbour_cells[i]->in_sync) // matches S criteria { // Try to select Cell - if (phy->cell_select(neighbour_cells[i]->get_earfcn(), neighbour_cells[i]->phy_cell)) { - set_serving_cell(i); - rrc_log->info("Selected cell PCI=%d, EARFCN=%d, Cell ID=0x%x\n", - serving_cell->phy_cell.id, serving_cell->get_earfcn(), - serving_cell->get_cell_id()); - rrc_log->console("Selected cell PCI=%d, EARFCN=%d, Cell ID=0x%x\n", - serving_cell->phy_cell.id, serving_cell->get_earfcn(), - serving_cell->get_cell_id()); - } else { - // Set to out-of-sync if can't synchronize - neighbour_cells[i]->in_sync = false; - rrc_log->warning("Selecting cell EARFCN=%d, Cell ID=0x%x.\n", - neighbour_cells[i]->get_earfcn(), neighbour_cells[i]->get_cell_id()); - } + phy->cell_select(neighbour_cells[i]->get_earfcn(), neighbour_cells[i]->phy_cell); + set_serving_cell(i); + rrc_log->info("Selected cell PCI=%d, EARFCN=%d, Cell ID=0x%x\n", + serving_cell->phy_cell.id, serving_cell->get_earfcn(), + serving_cell->get_cell_id()); + rrc_log->console("Selected cell PCI=%d, EARFCN=%d, Cell ID=0x%x\n", + serving_cell->phy_cell.id, serving_cell->get_earfcn(), + serving_cell->get_cell_id()); return; } }