SRSUE RRC: new PHY unknown sync state, cell select waits for PHY in-sync

master
Xavier Arteaga 5 years ago committed by Xavier Arteaga
parent 67935d2b99
commit b4b1ab94af

@ -260,7 +260,6 @@ class cell_t
} }
phy_interface_rrc_lte::phy_cell_t phy_cell = {}; phy_interface_rrc_lte::phy_cell_t phy_cell = {};
bool in_sync = false;
bool has_mcch = false; bool has_mcch = false;
asn1::rrc::sib_type1_s sib1; asn1::rrc::sib_type1_s sib1;
asn1::rrc::sib_type2_s sib2; asn1::rrc::sib_type2_s sib2;
@ -328,9 +327,9 @@ public:
void paging_completed(bool outcome) final; void paging_completed(bool outcome) final;
// PHY interface // PHY interface
void in_sync(); void in_sync() final;
void out_of_sync(); void out_of_sync() final;
void new_phy_meas(float rsrp, float rsrq, uint32_t tti, int earfcn, int pci); void new_phy_meas(float rsrp, float rsrq, uint32_t tti, int earfcn, int pci) final;
// MAC interface // MAC interface
void ho_ra_completed(bool ra_successful); void ho_ra_completed(bool ra_successful);
@ -390,6 +389,9 @@ private:
bool drb_up = false; bool drb_up = false;
typedef enum { phy_unknown_sync = 0, phy_in_sync, phy_out_of_sync } phy_sync_state_t;
phy_sync_state_t phy_sync_state = phy_unknown_sync;
rrc_args_t args = {}; rrc_args_t args = {};
uint32_t cell_clean_cnt = 0; uint32_t cell_clean_cnt = 0;

@ -117,6 +117,7 @@ public:
private: private:
srslte::proc_outcome_t step_cell_selection(); srslte::proc_outcome_t step_cell_selection();
srslte::proc_outcome_t step_wait_in_sync();
srslte::proc_outcome_t step_cell_search(); srslte::proc_outcome_t step_cell_search();
srslte::proc_outcome_t step_cell_config(); srslte::proc_outcome_t step_cell_config();
@ -124,7 +125,7 @@ private:
rrc* rrc_ptr; rrc* rrc_ptr;
// state variables // state variables
enum class search_state_t { cell_selection, cell_config, cell_search }; enum class search_state_t { cell_selection, wait_in_sync, cell_config, cell_search };
cs_result_t cs_result; cs_result_t cs_result;
search_state_t state; search_state_t state;
uint32_t neigh_index; uint32_t neigh_index;

@ -330,6 +330,7 @@ bool sync::cell_select(phy_interface_rrc_lte::phy_cell_t* new_cell)
phy_state.run_sfn_sync(); phy_state.run_sfn_sync();
if (phy_state.is_camping()) { if (phy_state.is_camping()) {
Info("Cell Select: SFN synchronized. CAMPING...\n"); Info("Cell Select: SFN synchronized. CAMPING...\n");
stack->in_sync();
ret = true; ret = true;
} else { } else {
Info("Cell Select: Could not synchronize SFN\n"); Info("Cell Select: Could not synchronize SFN\n");

@ -201,6 +201,8 @@ void rrc::run_tti(uint32_t tti)
return; return;
} }
rrc_log->step(tti);
if (simulate_rlf) { if (simulate_rlf) {
radio_link_failure(); radio_link_failure();
simulate_rlf = false; simulate_rlf = false;
@ -425,7 +427,7 @@ void rrc::out_of_sync()
{ {
// CAUTION: We do not lock in this function since they are called from real-time threads // CAUTION: We do not lock in this function since they are called from real-time threads
if (serving_cell && timers && rrc_log) { if (serving_cell && timers && rrc_log) {
serving_cell->in_sync = false; phy_sync_state = phy_out_of_sync;
// upon receiving N310 consecutive "out-of-sync" indications for the PCell from lower layers while neither T300, // upon receiving N310 consecutive "out-of-sync" indications for the PCell from lower layers while neither T300,
// T301, T304 nor T311 is running: // T301, T304 nor T311 is running:
@ -452,7 +454,7 @@ void rrc::out_of_sync()
void rrc::in_sync() void rrc::in_sync()
{ {
// CAUTION: We do not lock in this function since they are called from real-time threads // CAUTION: We do not lock in this function since they are called from real-time threads
serving_cell->in_sync = true; phy_sync_state = phy_in_sync;
if (t310.is_running()) { if (t310.is_running()) {
n311_cnt++; n311_cnt++;
if (n311_cnt == N311) { if (n311_cnt == N311) {
@ -1346,7 +1348,7 @@ void rrc::start_con_restablishment(asn1::rrc::reest_cause_e cause)
void rrc::start_cell_reselection() void rrc::start_cell_reselection()
{ {
if (neighbour_cells.empty() and serving_cell->in_sync and phy->cell_is_camping()) { if (neighbour_cells.empty() and phy_sync_state == phy_in_sync and phy->cell_is_camping()) {
// don't bother with cell selection if there are no neighbours and we are already camping // don't bother with cell selection if there are no neighbours and we are already camping
return; return;
} }

@ -116,6 +116,7 @@ proc_outcome_t rrc::cell_search_proc::react(const cell_search_event_t& event)
return handle_cell_found(search_result.found_cell); return handle_cell_found(search_result.found_cell);
} }
case phy_interface_rrc_lte::cell_search_ret_t::CELL_NOT_FOUND: case phy_interface_rrc_lte::cell_search_ret_t::CELL_NOT_FOUND:
rrc_ptr->phy_sync_state = phy_unknown_sync;
Info("No cells found.\n"); Info("No cells found.\n");
// do nothing // do nothing
return proc_outcome_t::success; return proc_outcome_t::success;
@ -329,7 +330,7 @@ rrc::cell_selection_proc::cell_selection_proc(rrc* parent_) : rrc_ptr(parent_) {
*/ */
proc_outcome_t rrc::cell_selection_proc::init() proc_outcome_t rrc::cell_selection_proc::init()
{ {
if (rrc_ptr->neighbour_cells.empty() and rrc_ptr->serving_cell->in_sync and rrc_ptr->phy->cell_is_camping()) { if (rrc_ptr->neighbour_cells.empty() and rrc_ptr->phy_sync_state == phy_in_sync and rrc_ptr->phy->cell_is_camping()) {
// don't bother with cell selection if there are no neighbours and we are already camping // don't bother with cell selection if there are no neighbours and we are already camping
Debug("Skipping Cell Selection Procedure ..\n"); Debug("Skipping Cell Selection Procedure ..\n");
cs_result = cs_result_t::same_cell; cs_result = cs_result_t::same_cell;
@ -350,35 +351,30 @@ proc_outcome_t rrc::cell_selection_proc::step_cell_selection()
for (; neigh_index < rrc_ptr->neighbour_cells.size(); ++neigh_index) { for (; neigh_index < rrc_ptr->neighbour_cells.size(); ++neigh_index) {
/*TODO: CHECK that PLMN matches. Currently we don't receive SIB1 of neighbour cells /*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]->plmn_equals(selected_plmn_id) && */
if (rrc_ptr->neighbour_cells.at(neigh_index)->in_sync) { // Matches S criteria
// Matches S criteria float rsrp = rrc_ptr->neighbour_cells.at(neigh_index)->get_rsrp();
float rsrp = rrc_ptr->neighbour_cells.at(neigh_index)->get_rsrp();
if (rrc_ptr->phy_sync_state != phy_in_sync or
if (not rrc_ptr->serving_cell->in_sync or (rrc_ptr->cell_selection_criteria(rsrp) and rsrp > rrc_ptr->serving_cell->get_rsrp() + 5)) {
(rrc_ptr->cell_selection_criteria(rsrp) and rsrp > rrc_ptr->serving_cell->get_rsrp() + 5)) { // currently connected and verifies cell selection criteria
// currently connected and verifies cell selection criteria // Try to select Cell
// Try to select Cell rrc_ptr->set_serving_cell(rrc_ptr->neighbour_cells.at(neigh_index)->phy_cell);
rrc_ptr->set_serving_cell(rrc_ptr->neighbour_cells.at(neigh_index)->phy_cell); Info("Selected cell: %s\n", rrc_ptr->serving_cell->print().c_str());
Info("Selected cell: %s\n", rrc_ptr->serving_cell->print().c_str()); rrc_ptr->rrc_log->console("Selected cell: %s\n", rrc_ptr->serving_cell->print().c_str());
rrc_ptr->rrc_log->console("Selected cell: %s\n", rrc_ptr->serving_cell->print().c_str());
/* BLOCKING CALL */
/* BLOCKING CALL */ if (rrc_ptr->phy->cell_select(&rrc_ptr->serving_cell->phy_cell)) {
if (rrc_ptr->phy->cell_select(&rrc_ptr->serving_cell->phy_cell)) { Info("Wait PHY to be in-synch\n");
serv_cell_cfg_fut = rrc_ptr->serv_cell_cfg.get_future(); state = search_state_t::wait_in_sync;
if (not rrc_ptr->serv_cell_cfg.launch(rrc_ptr->ue_required_sibs)) { return proc_outcome_t::repeat;
return proc_outcome_t::error; } else {
} rrc_ptr->phy_sync_state = phy_unknown_sync;
state = search_state_t::cell_config; Error("Could not camp on serving cell.\n");
return proc_outcome_t::repeat; // Continue to next neighbour cell
} else {
rrc_ptr->serving_cell->in_sync = false;
Error("Could not camp on serving cell.\n");
// Continue to next neighbour cell
}
} }
} }
} }
if (rrc_ptr->serving_cell->in_sync) { if (rrc_ptr->phy_sync_state == phy_in_sync) {
if (not rrc_ptr->phy->cell_is_camping()) { if (not rrc_ptr->phy->cell_is_camping()) {
Info("Serving cell %s is in-sync but not camping. Selecting it...\n", rrc_ptr->serving_cell->print().c_str()); Info("Serving cell %s is in-sync but not camping. Selecting it...\n", rrc_ptr->serving_cell->print().c_str());
@ -386,7 +382,7 @@ proc_outcome_t rrc::cell_selection_proc::step_cell_selection()
if (rrc_ptr->phy->cell_select(&rrc_ptr->serving_cell->phy_cell)) { if (rrc_ptr->phy->cell_select(&rrc_ptr->serving_cell->phy_cell)) {
Info("Selected serving cell OK.\n"); Info("Selected serving cell OK.\n");
} else { } else {
rrc_ptr->serving_cell->in_sync = false; rrc_ptr->phy_sync_state = phy_unknown_sync;
Error("Could not camp on serving cell.\n"); Error("Could not camp on serving cell.\n");
return proc_outcome_t::error; return proc_outcome_t::error;
} }
@ -405,6 +401,19 @@ proc_outcome_t rrc::cell_selection_proc::step_cell_selection()
return proc_outcome_t::repeat; return proc_outcome_t::repeat;
} }
proc_outcome_t rrc::cell_selection_proc::step_wait_in_sync()
{
if (rrc_ptr->phy_sync_state == phy_in_sync) {
Info("PHY is in SYNC\n");
serv_cell_cfg_fut = rrc_ptr->serv_cell_cfg.get_future();
if (not rrc_ptr->serv_cell_cfg.launch(rrc_ptr->ue_required_sibs)) {
return proc_outcome_t::error;
}
state = search_state_t::cell_config;
}
return proc_outcome_t::yield;
}
proc_outcome_t rrc::cell_selection_proc::step_cell_search() proc_outcome_t rrc::cell_selection_proc::step_cell_search()
{ {
if (rrc_ptr->cell_searcher.run()) { if (rrc_ptr->cell_searcher.run()) {
@ -443,6 +452,8 @@ proc_outcome_t rrc::cell_selection_proc::step()
switch (state) { switch (state) {
case search_state_t::cell_selection: case search_state_t::cell_selection:
return step_cell_selection(); return step_cell_selection();
case search_state_t::wait_in_sync:
return step_wait_in_sync();
case search_state_t::cell_config: case search_state_t::cell_config:
return step_cell_config(); return step_cell_config();
case search_state_t::cell_search: case search_state_t::cell_search:
@ -684,11 +695,11 @@ srslte::proc_outcome_t rrc::connection_request_proc::react(const cell_selection_
switch (cs_ret) { switch (cs_ret) {
case cs_result_t::same_cell: case cs_result_t::same_cell:
log_h->warning("Did not reselect cell but serving cell is out-of-sync.\n"); log_h->warning("Did not reselect cell but serving cell is out-of-sync.\n");
rrc_ptr->serving_cell->in_sync = false; rrc_ptr->phy_sync_state = phy_unknown_sync;
break; break;
case cs_result_t::changed_cell: case cs_result_t::changed_cell:
log_h->warning("Selected a new cell but could not camp on. Setting out-of-sync.\n"); log_h->warning("Selected a new cell but could not camp on. Setting out-of-sync.\n");
rrc_ptr->serving_cell->in_sync = false; rrc_ptr->phy_sync_state = phy_unknown_sync;
break; break;
default: default:
log_h->warning("Could not find any suitable cell to connect\n"); log_h->warning("Could not find any suitable cell to connect\n");
@ -861,7 +872,7 @@ proc_outcome_t rrc::cell_reselection_proc::step()
case cs_result_t::same_cell: case cs_result_t::same_cell:
if (!rrc_ptr->phy->cell_is_camping()) { if (!rrc_ptr->phy->cell_is_camping()) {
Warning("Did not reselect cell but serving cell is out-of-sync.\n"); Warning("Did not reselect cell but serving cell is out-of-sync.\n");
rrc_ptr->serving_cell->in_sync = false; rrc_ptr->phy_sync_state = phy_unknown_sync;
} }
break; break;
} }
@ -945,7 +956,7 @@ srslte::proc_outcome_t rrc::connection_reest_proc::step_cell_reselection()
// Run cell reselection // Run cell reselection
if (not rrc_ptr->cell_reselector.run()) { if (not rrc_ptr->cell_reselector.run()) {
// Cell reselection finished or not started // Cell reselection finished or not started
if (rrc_ptr->serving_cell->in_sync) { if (rrc_ptr->phy_sync_state == phy_in_sync) {
// In-sync, check SIBs // In-sync, check SIBs
if (rrc_ptr->serving_cell->has_sib1() && rrc_ptr->serving_cell->has_sib2() && rrc_ptr->serving_cell->has_sib3()) { if (rrc_ptr->serving_cell->has_sib1() && rrc_ptr->serving_cell->has_sib2() && rrc_ptr->serving_cell->has_sib3()) {
Info("In-sync, SIBs available. Going to cell criteria\n"); Info("In-sync, SIBs available. Going to cell criteria\n");
@ -978,7 +989,7 @@ proc_outcome_t rrc::connection_reest_proc::step_cell_configuration()
{ {
if (not rrc_ptr->serv_cell_cfg.run()) { if (not rrc_ptr->serv_cell_cfg.run()) {
// SIBs adquisition not started or finished // SIBs adquisition not started or finished
if (rrc_ptr->serving_cell->in_sync) { if (rrc_ptr->phy_sync_state == phy_in_sync) {
// In-sync // In-sync
if (rrc_ptr->serving_cell->has_sib1() && rrc_ptr->serving_cell->has_sib2() && rrc_ptr->serving_cell->has_sib3()) { if (rrc_ptr->serving_cell->has_sib1() && rrc_ptr->serving_cell->has_sib2() && rrc_ptr->serving_cell->has_sib3()) {
// All SIBs are available // All SIBs are available

Loading…
Cancel
Save