From 28dc194e2ff4d63f501eaf5d8c863b1089a15a74 Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Wed, 25 Apr 2018 19:46:10 +0200 Subject: [PATCH] Fix UE blocking on Reestablishment when Overflow --- srsue/src/phy/phch_recv.cc | 12 +++++++----- srsue/src/upper/nas.cc | 1 + srsue/src/upper/rrc.cc | 28 ++++++++++++---------------- 3 files changed, 20 insertions(+), 21 deletions(-) diff --git a/srsue/src/phy/phch_recv.cc b/srsue/src/phy/phch_recv.cc index 780f2c72a..3d8d7f3cf 100644 --- a/srsue/src/phy/phch_recv.cc +++ b/srsue/src/phy/phch_recv.cc @@ -257,19 +257,21 @@ phy_interface_rrc::cell_search_ret_t phch_recv::cell_search(phy_interface_rrc::p bool phch_recv::cell_select(phy_interface_rrc::phy_cell_t *new_cell) { pthread_mutex_lock(&rrc_mutex); + bool ret = false; + int cnt = 0; + // Move state to IDLE if (!new_cell) { Info("Cell Select: Starting cell resynchronization\n"); } else { if (!srslte_cell_isvalid(&cell)) { log_h->error("Cell Select: Invalid cell. ID=%d, PRB=%d, ports=%d\n", cell.id, cell.nof_prb, cell.nof_ports); - return false; + goto unlock; } Info("Cell Select: Starting cell selection for PCI=%d, EARFCN=%d\n", new_cell->cell.id, new_cell->earfcn); } // Wait for any pending PHICH - int cnt = 0; while(worker_com->is_any_pending_ack() && cnt < 10) { usleep(1000); cnt++; @@ -296,7 +298,7 @@ bool phch_recv::cell_select(phy_interface_rrc::phy_cell_t *new_cell) { cell = new_cell->cell; if (!set_cell()) { Error("Cell Select: Reconfiguring cell\n"); - return false; + goto unlock; } } @@ -305,7 +307,7 @@ bool phch_recv::cell_select(phy_interface_rrc::phy_cell_t *new_cell) { Info("Cell Select: Setting new frequency EARFCN=%d\n", new_cell->earfcn); if (set_frequency()) { Error("Cell Select: Setting new frequency EARFCN=%d\n", new_cell->earfcn); - return false; + goto unlock; } current_earfcn = new_cell->earfcn; } @@ -318,7 +320,6 @@ bool phch_recv::cell_select(phy_interface_rrc::phy_cell_t *new_cell) { } /* SFN synchronization */ - bool ret = false; phy_state.run_sfn_sync(); if (phy_state.is_camping()) { Info("Cell Select: SFN synchronized. CAMPING...\n"); @@ -327,6 +328,7 @@ bool phch_recv::cell_select(phy_interface_rrc::phy_cell_t *new_cell) { Info("Cell Select: Could not synchronize SFN\n"); } +unlock: pthread_mutex_unlock(&rrc_mutex); return ret; } diff --git a/srsue/src/upper/nas.cc b/srsue/src/upper/nas.cc index 291a3550f..ad8ae39a8 100644 --- a/srsue/src/upper/nas.cc +++ b/srsue/src/upper/nas.cc @@ -242,6 +242,7 @@ bool nas::rrc_connect() { } } else { nas_log->error("Could not establish RRC connection\n"); + pool->deallocate(dedicatedInfoNAS); } return false; } diff --git a/srsue/src/upper/rrc.cc b/srsue/src/upper/rrc.cc index 3f213979d..773a46a53 100644 --- a/srsue/src/upper/rrc.cc +++ b/srsue/src/upper/rrc.cc @@ -220,21 +220,11 @@ void rrc::run_tti(uint32_t tti) { // If attached but not camping on the cell, perform cell reselection if (nas->is_attached()) { rrc_log->debug("Running cell selection and reselection in IDLE\n"); - if (!cell_selection()) { - if (!serving_cell->in_sync) { - rrc_log->info("Cell selection and reselection in IDLE did not find any suitable cell. Searching again\n"); - // If can not camp on any cell, search again for new cells - phy_interface_rrc::cell_search_ret_t ret = cell_search(); - - // TODO: Should not camp on it until we have checked is a valid PLMN - if (ret.found == phy_interface_rrc::cell_search_ret_t::CELL_FOUND) { - // New cell has been selected, start receiving PCCH - mac->pcch_start_rx(); - } - } - } else { + if (cell_selection()) { // New cell has been selected, start receiving PCCH mac->pcch_start_rx(); + } else { + rrc_log->warning("Could not find any cell to camp on\n"); } } break; @@ -780,14 +770,12 @@ phy_interface_rrc::cell_search_ret_t rrc::cell_search() */ bool rrc::cell_selection() { - int candidates = 0; // Neighbour cells are sorted in descending order of RSRP for (uint32_t i = 0; i < neighbour_cells.size(); i++) { if (/*TODO: CHECK that PLMN matches. Currently we don't receive SIB1 of neighbour cells * neighbour_cells[i]->plmn_equals(selected_plmn_id) && */ neighbour_cells[i]->in_sync) // matches S criteria { - candidates++; // If currently connected, verify cell selection criteria if (!serving_cell->in_sync || (cell_selection_criteria(neighbour_cells[i]->get_rsrp()) && @@ -814,7 +802,15 @@ bool rrc::cell_selection() } } } - return false; + if (serving_cell->in_sync) { + return true; + } + // If can not find any suitable cell, search again + rrc_log->info("Cell selection and reselection in IDLE did not find any suitable cell. Searching again\n"); + // If can not camp on any cell, search again for new cells + phy_interface_rrc::cell_search_ret_t ret = cell_search(); + + return ret.found == phy_interface_rrc::cell_search_ret_t::CELL_FOUND; } // Cell selection criteria Section 5.2.3.2 of 36.304