moved cell search to background task thread pool, and provided a stack interface to rrc to call "start_cell_search". Once completed, the background task signals back to RRC

master
Francisco Paisana 5 years ago committed by Andre Puschmann
parent f07a9277a0
commit 2fb830fcfa

@ -632,6 +632,13 @@ public:
virtual void wait_ra_completion(uint16_t rnti) = 0; virtual void wait_ra_completion(uint16_t rnti) = 0;
}; };
// STACK interface for RRC
class stack_interface_rrc
{
public:
virtual void start_cell_search() = 0;
};
// Combined interface for PHY to access stack (MAC and RRC) // Combined interface for PHY to access stack (MAC and RRC)
class stack_interface_phy_lte : public mac_interface_phy_lte, public rrc_interface_phy_lte class stack_interface_phy_lte : public mac_interface_phy_lte, public rrc_interface_phy_lte
{ {

@ -299,6 +299,7 @@ public:
usim_interface_rrc* usim_, usim_interface_rrc* usim_,
gw_interface_rrc* gw_, gw_interface_rrc* gw_,
srslte::timers* timers_, srslte::timers* timers_,
stack_interface_rrc* stack_,
const rrc_args_t& args_); const rrc_args_t& args_);
void stop(); void stop();
@ -349,8 +350,11 @@ public:
void write_pdu_pcch(srslte::unique_byte_buffer_t pdu); void write_pdu_pcch(srslte::unique_byte_buffer_t pdu);
void write_pdu_mch(uint32_t lcid, srslte::unique_byte_buffer_t pdu); void write_pdu_mch(uint32_t lcid, srslte::unique_byte_buffer_t pdu);
private: // STACK interface
void cell_search_completed(const phy_interface_rrc_lte::cell_search_ret_t& cs_ret,
const phy_interface_rrc_lte::phy_cell_t& found_cell);
private:
typedef struct { typedef struct {
enum { PDU, PCCH, PDU_MCH, RLF, PDU_BCCH_DLSCH, STOP } command; enum { PDU, PCCH, PDU_MCH, RLF, PDU_BCCH_DLSCH, STOP } command;
srslte::unique_byte_buffer_t pdu; srslte::unique_byte_buffer_t pdu;
@ -371,6 +375,7 @@ private:
nas_interface_rrc* nas = nullptr; nas_interface_rrc* nas = nullptr;
usim_interface_rrc* usim = nullptr; usim_interface_rrc* usim = nullptr;
gw_interface_rrc* gw = nullptr; gw_interface_rrc* gw = nullptr;
stack_interface_rrc* stack = nullptr;
srslte::unique_byte_buffer_t dedicated_info_nas; srslte::unique_byte_buffer_t dedicated_info_nas;

@ -32,12 +32,17 @@ namespace srsue {
class rrc::cell_search_proc : public srslte::proc_impl_t class rrc::cell_search_proc : public srslte::proc_impl_t
{ {
public: public:
struct cell_search_event_t {
phy_interface_rrc_lte::cell_search_ret_t cs_ret;
phy_interface_rrc_lte::phy_cell_t found_cell;
};
enum class state_t { phy_cell_search, si_acquire }; enum class state_t { phy_cell_search, si_acquire };
srslte::proc_outcome_t init(rrc* parent_); srslte::proc_outcome_t init(rrc* parent_);
srslte::proc_outcome_t step() final; srslte::proc_outcome_t step() final;
srslte::proc_outcome_t trigger_event(const cell_search_event_t& event);
phy_interface_rrc_lte::cell_search_ret_t get_cs_ret() { return cs_ret; } phy_interface_rrc_lte::cell_search_ret_t get_cs_ret() { return search_result.cs_ret; }
static const char* name() { return "Cell Search"; } static const char* name() { return "Cell Search"; }
private: private:
@ -48,8 +53,8 @@ private:
srslte::log* log_h; srslte::log* log_h;
// state vars // state vars
phy_interface_rrc_lte::cell_search_ret_t cs_ret; cell_search_event_t search_result;
state_t state; state_t state;
}; };
class rrc::si_acquire_proc : public srslte::proc_impl_t class rrc::si_acquire_proc : public srslte::proc_impl_t

@ -54,6 +54,7 @@ class ue_stack_lte final : public ue_stack_base,
public stack_interface_phy_lte, public stack_interface_phy_lte,
public stack_interface_gw, public stack_interface_gw,
public stack_interface_mac, public stack_interface_mac,
public stack_interface_rrc,
public thread public thread
{ {
public: public:
@ -117,6 +118,9 @@ public:
void process_pdus() final; void process_pdus() final;
void wait_ra_completion(uint16_t rnti) final; void wait_ra_completion(uint16_t rnti) final;
// Interface for RRC
void start_cell_search() final;
private: private:
void run_thread() final; void run_thread() final;
void run_tti_impl(uint32_t tti); void run_tti_impl(uint32_t tti);

@ -98,16 +98,18 @@ void rrc::init(phy_interface_rrc_lte* phy_,
usim_interface_rrc* usim_, usim_interface_rrc* usim_,
gw_interface_rrc* gw_, gw_interface_rrc* gw_,
srslte::timers* timers_, srslte::timers* timers_,
stack_interface_rrc* stack_,
const rrc_args_t& args_) const rrc_args_t& args_)
{ {
pool = byte_buffer_pool::get_instance(); pool = byte_buffer_pool::get_instance();
phy = phy_; phy = phy_;
mac = mac_; mac = mac_;
rlc = rlc_; rlc = rlc_;
pdcp = pdcp_; pdcp = pdcp_;
nas = nas_; nas = nas_;
usim = usim_; usim = usim_;
gw = gw_; gw = gw_;
stack = stack_;
args = args_; args = args_;
@ -325,9 +327,9 @@ void rrc::plmn_select(srslte::plmn_id_t plmn_id)
* it. Sends connectionRequest message and returns if message transmitted successfully. * it. Sends connectionRequest message and returns if message transmitted successfully.
* It does not wait until completition of Connection Establishment procedure * It does not wait until completition of Connection Establishment procedure
*/ */
bool rrc::connection_request(srslte::establishment_cause_t cause, srslte::unique_byte_buffer_t dedicated_info_nas) bool rrc::connection_request(srslte::establishment_cause_t cause, srslte::unique_byte_buffer_t dedicated_info_nas_)
{ {
if (not conn_req_proc.launch(this, cause, std::move(dedicated_info_nas))) { if (not conn_req_proc.launch(this, cause, std::move(dedicated_info_nas_))) {
rrc_log->error("Failed to initiate connection request procedure\n"); rrc_log->error("Failed to initiate connection request procedure\n");
return false; return false;
} }
@ -1479,15 +1481,21 @@ void rrc::start_cell_reselection()
}); });
} }
void rrc::cell_search_completed(const phy_interface_rrc_lte::cell_search_ret_t& cs_ret,
const phy_interface_rrc_lte::phy_cell_t& found_cell)
{
cell_searcher.trigger_event(cell_search_proc::cell_search_event_t{cs_ret, found_cell});
}
/******************************************************************************* /*******************************************************************************
* *
* *
* *
* Reception of Broadcast messages (MIB and SIBs) * Reception of Broadcast messages (MIB and SIBs)
* *
* *
* *
*******************************************************************************/ *******************************************************************************/
void rrc::write_pdu_bcch_bch(unique_byte_buffer_t pdu) void rrc::write_pdu_bcch_bch(unique_byte_buffer_t pdu)
{ {
asn1::rrc::bcch_bch_msg_s bch_msg; asn1::rrc::bcch_bch_msg_s bch_msg;
@ -2847,11 +2855,12 @@ void rrc::set_rrc_default()
* *
************************************************************************/ ************************************************************************/
void rrc::rrc_meas::init(rrc *parent) { void rrc::rrc_meas::init(rrc* parent_)
this->parent = parent; {
this->log_h = parent->rrc_log; this->parent = parent_;
this->phy = parent->phy; this->log_h = parent_->rrc_log;
this->timers = parent->timers; this->phy = parent_->phy;
this->timers = parent_->timers;
s_measure_enabled = false; s_measure_enabled = false;
reset(); reset();
} }

@ -43,6 +43,7 @@ proc_outcome_t rrc::cell_search_proc::init(srsue::rrc* parent_)
Info("Starting...\n"); Info("Starting...\n");
state = state_t::phy_cell_search; state = state_t::phy_cell_search;
rrc_ptr->stack->start_cell_search();
return proc_outcome_t::repeat; return proc_outcome_t::repeat;
} }
@ -50,25 +51,8 @@ proc_outcome_t rrc::cell_search_proc::init(srsue::rrc* parent_)
proc_outcome_t rrc::cell_search_proc::step() proc_outcome_t rrc::cell_search_proc::step()
{ {
if (state == state_t::phy_cell_search) { if (state == state_t::phy_cell_search) {
// Blocks waiting for result of phy cell search // Waits for cell search to complete
phy_interface_rrc_lte::phy_cell_t new_cell; return proc_outcome_t::yield;
// BLOCKING CALL
cs_ret = rrc_ptr->phy->cell_search(&new_cell);
switch (cs_ret.found) {
case phy_interface_rrc_lte::cell_search_ret_t::CELL_FOUND: {
return handle_cell_found(new_cell);
}
case phy_interface_rrc_lte::cell_search_ret_t::CELL_NOT_FOUND:
Info("No cells found.\n");
// do nothing
return proc_outcome_t::success;
case phy_interface_rrc_lte::cell_search_ret_t::ERROR:
Error("Error while performing cell search\n");
// TODO: check what errors can happen (currently not handled in our code)
return proc_outcome_t::error;
}
} else if (state == state_t::si_acquire) { } else if (state == state_t::si_acquire) {
if (not rrc_ptr->si_acquirer.run()) { if (not rrc_ptr->si_acquirer.run()) {
// SI Acquire has completed // SI Acquire has completed
@ -121,6 +105,32 @@ proc_outcome_t rrc::cell_search_proc::handle_cell_found(const phy_interface_rrc_
return proc_outcome_t::repeat; return proc_outcome_t::repeat;
} }
proc_outcome_t rrc::cell_search_proc::trigger_event(const cell_search_event_t& event)
{
if (state != state_t::phy_cell_search) {
Error("Received unexpected cell search result\n");
return proc_outcome_t::error;
}
search_result = event;
Info("PHY cell search completed.\n");
// Transition to SI Acquire or finish
switch (search_result.cs_ret.found) {
case phy_interface_rrc_lte::cell_search_ret_t::CELL_FOUND: {
return handle_cell_found(search_result.found_cell);
}
case phy_interface_rrc_lte::cell_search_ret_t::CELL_NOT_FOUND:
Info("No cells found.\n");
// do nothing
return proc_outcome_t::success;
case phy_interface_rrc_lte::cell_search_ret_t::ERROR:
Error("Error while performing cell search\n");
// TODO: check what errors can happen (currently not handled in our code)
return proc_outcome_t::error;
}
return proc_outcome_t::yield;
}
/************************************** /**************************************
* SI Acquire Procedure * SI Acquire Procedure
*************************************/ *************************************/

@ -127,7 +127,7 @@ int ue_stack_lte::init(const stack_args_t& args_, srslte::logger* logger_)
rlc.init(&pdcp, &rrc, &timers, 0 /* RB_ID_SRB0 */); rlc.init(&pdcp, &rrc, &timers, 0 /* RB_ID_SRB0 */);
pdcp.init(&rlc, &rrc, gw); pdcp.init(&rlc, &rrc, gw);
nas.init(usim.get(), &rrc, gw, args.nas); nas.init(usim.get(), &rrc, gw, args.nas);
rrc.init(phy, &mac, &rlc, &pdcp, &nas, usim.get(), gw, &timers, args.rrc); rrc.init(phy, &mac, &rlc, &pdcp, &nas, usim.get(), gw, &timers, this, args.rrc);
running = true; running = true;
start(STACK_MAIN_THREAD_PRIO); start(STACK_MAIN_THREAD_PRIO);
@ -284,11 +284,25 @@ void ue_stack_lte::process_pdus()
void ue_stack_lte::wait_ra_completion(uint16_t rnti) void ue_stack_lte::wait_ra_completion(uint16_t rnti)
{ {
background_tasks.push_task([this, rnti](uint32_t worker_id){ background_tasks.push_task([this, rnti](uint32_t worker_id) {
phy->set_crnti(rnti); phy->set_crnti(rnti);
// signal MAC RA proc to go back to idle // signal MAC RA proc to go back to idle
mac.notify_ra_completed(); mac.notify_ra_completed();
}); });
} }
/********************
* RRC Interface
*******************/
void ue_stack_lte::start_cell_search()
{
background_tasks.push_task([this](uint32_t worker_id) {
phy_interface_rrc_lte::phy_cell_t found_cell;
phy_interface_rrc_lte::cell_search_ret_t ret = phy->cell_search(&found_cell);
// notify back RRC
rrc.cell_search_completed(ret, found_cell);
});
}
} // namespace srsue } // namespace srsue

Loading…
Cancel
Save