added task dispatch capabilities to stack interface

master
Francisco Paisana 5 years ago committed by Francisco Paisana
parent 46a1be3e76
commit de3c28e52d

@ -598,8 +598,19 @@ class gw_interface_stack : public gw_interface_nas, public gw_interface_rrc, pub
{ {
}; };
// Generic Task Management + Timer interface for upper stack
class task_handler_interface_lte
{
public:
virtual srslte::timer_handler::unique_timer get_unique_timer() = 0;
virtual srslte::task_multiqueue::queue_handler make_task_queue() = 0;
virtual void enqueue_background_task(std::function<void(uint32_t)> task) = 0;
virtual void notify_background_task_result(srslte::move_task_t task) = 0;
virtual void defer_callback(uint32_t duration_ms, std::function<void()> func) = 0;
};
// STACK interface for MAC // STACK interface for MAC
class stack_interface_mac class stack_interface_mac : public task_handler_interface_lte
{ {
public: public:
virtual void process_pdus() = 0; virtual void process_pdus() = 0;
@ -607,11 +618,9 @@ public:
virtual void start_prach_configuration() = 0; virtual void start_prach_configuration() = 0;
}; };
// Generic Task Management + Timer interface for upper stack // STACK interface for MAC
class task_handler_interface_lte class stack_interface_nas : public task_handler_interface_lte
{ {
public:
virtual srslte::timer_handler::unique_timer get_unique_timer() = 0;
}; };
// STACK interface for RRC // STACK interface for RRC

@ -56,6 +56,7 @@ class ue_stack_lte final : public ue_stack_base,
public stack_interface_gw, public stack_interface_gw,
public stack_interface_mac, public stack_interface_mac,
public stack_interface_rrc, public stack_interface_rrc,
public stack_interface_nas,
public srslte::thread public srslte::thread
{ {
public: public:
@ -128,12 +129,15 @@ public:
tti_point get_current_tti() final { return current_tti; } tti_point get_current_tti() final { return current_tti; }
// Task Handling interface // Task Handling interface
srslte::timer_handler::unique_timer get_unique_timer() override { return timers.get_unique_timer(); } srslte::timer_handler::unique_timer get_unique_timer() final { return timers.get_unique_timer(); }
srslte::task_multiqueue::queue_handler make_task_queue() final { return pending_tasks.get_queue_handler(); }
void enqueue_background_task(std::function<void(uint32_t)> f) final;
void notify_background_task_result(srslte::move_task_t task) final;
void defer_callback(uint32_t duration_ms, std::function<void()> func) final;
private: private:
void run_thread() final; void run_thread() final;
void run_tti_impl(uint32_t tti, uint32_t tti_jump); void run_tti_impl(uint32_t tti, uint32_t tti_jump);
void calc_tti_stats(const uint32_t duration_us);;
void stop_impl(); void stop_impl();
const uint32_t TTI_STAT_PERIOD = 1024; const uint32_t TTI_STAT_PERIOD = 1024;

@ -40,7 +40,7 @@ namespace srsue {
class nas : public nas_interface_rrc, public nas_interface_ue, public srslte::timer_callback class nas : public nas_interface_rrc, public nas_interface_ue, public srslte::timer_callback
{ {
public: public:
nas(srsue::task_handler_interface_lte* task_handler_); explicit nas(srsue::stack_interface_nas* task_handler_);
void init(usim_interface_nas* usim_, rrc_interface_nas* rrc_, gw_interface_nas* gw_, const nas_args_t& args_); void init(usim_interface_nas* usim_, rrc_interface_nas* rrc_, gw_interface_nas* gw_, const nas_args_t& args_);
void stop(); void stop();
void run_tti(); void run_tti();

@ -357,6 +357,26 @@ void ue_stack_lte::start_prach_configuration()
}); });
} }
/***************************
* Task Handling Interface
**************************/
void ue_stack_lte::enqueue_background_task(std::function<void(uint32_t)> f)
{
background_tasks.push_task(std::move(f));
}
void ue_stack_lte::notify_background_task_result(srslte::move_task_t task)
{
// run the notification in the stack thread
pending_tasks.push(background_queue_id, std::move(task));
}
void ue_stack_lte::defer_callback(uint32_t duration_ms, std::function<void()> func)
{
timers.defer_callback(duration_ms, func);
}
/******************** /********************
* RRC Interface * RRC Interface
*******************/ *******************/

@ -235,7 +235,7 @@ proc_outcome_t nas::rrc_connect_proc::react(nas::rrc_connect_proc::connection_re
* NAS * NAS
********************************************************************/ ********************************************************************/
nas::nas(srsue::task_handler_interface_lte* task_handler_) : nas::nas(srsue::stack_interface_nas* task_handler_) :
pool(byte_buffer_pool::get_instance()), pool(byte_buffer_pool::get_instance()),
plmn_searcher(this), plmn_searcher(this),
rrc_connector(this), rrc_connector(this),

@ -26,13 +26,23 @@
namespace srsue { namespace srsue {
class stack_dummy_interface : public stack_interface_rrc class stack_dummy_interface : public stack_interface_rrc, public stack_interface_mac, public stack_interface_nas
{ {
public: public:
srslte::timer_handler::unique_timer get_unique_timer() override { return timers.get_unique_timer(); } srslte::timer_handler::unique_timer get_unique_timer() override { return timers.get_unique_timer(); }
void start_cell_search() override {} void start_cell_search() override {}
void start_cell_select(const phy_interface_rrc_lte::phy_cell_t* cell) override {} void start_cell_select(const phy_interface_rrc_lte::phy_cell_t* cell) override {}
srslte::tti_point get_current_tti() override { return srslte::tti_point{timers.get_cur_time() % 10240}; } srslte::tti_point get_current_tti() override { return srslte::tti_point{timers.get_cur_time() % 10240}; }
srslte::task_multiqueue::queue_handler make_task_queue() final { return pending_tasks.get_queue_handler(); }
void enqueue_background_task(std::function<void(uint32_t)> f) override { f(0); }
void notify_background_task_result(srslte::move_task_t task) override { task(); }
void defer_callback(uint32_t duration_ms, std::function<void()> func) final
{
timers.defer_callback(duration_ms, func);
}
void process_pdus() override {}
void wait_ra_completion(uint16_t rnti) override {}
void start_prach_configuration() override {}
srslte::timer_handler timers{100}; srslte::timer_handler timers{100};
srslte::task_multiqueue pending_tasks; srslte::task_multiqueue pending_tasks;

@ -335,7 +335,7 @@ public:
uint32_t rach_problem = 0; uint32_t rach_problem = 0;
}; };
class stack_dummy : public stack_interface_mac class stack_dummy : public stack_dummy_interface
{ {
public: public:
void init(mac* mac_, phy_interface_mac_lte* phy_) void init(mac* mac_, phy_interface_mac_lte* phy_)

@ -108,7 +108,7 @@ private:
class nas_test : public srsue::nas class nas_test : public srsue::nas
{ {
public: public:
nas_test(srsue::task_handler_interface_lte* t) : srsue::nas(t) {} nas_test(srsue::stack_interface_nas* t) : srsue::nas(t) {}
bool is_attached() override { return false; } bool is_attached() override { return false; }
}; };

Loading…
Cancel
Save