removal of stack handler interface

master
Francisco Paisana 5 years ago
parent 7c364070ee
commit 5e06430455

@ -22,9 +22,7 @@
#ifndef SRSLTE_INTERFACES_COMMON_H #ifndef SRSLTE_INTERFACES_COMMON_H
#define SRSLTE_INTERFACES_COMMON_H #define SRSLTE_INTERFACES_COMMON_H
#include "srslte/common/multiqueue.h"
#include "srslte/common/security.h" #include "srslte/common/security.h"
#include "srslte/common/timers.h"
#include <string> #include <string>
namespace srslte { namespace srslte {
@ -87,18 +85,6 @@ public:
virtual int read_pdu(uint32_t lcid, uint8_t* payload, uint32_t requested_bytes) = 0; virtual int read_pdu(uint32_t lcid, uint8_t* payload, uint32_t requested_bytes) = 0;
}; };
// Generic Task Management + Timer interface for upper stack
class task_handler_interface
{
public:
virtual srslte::timer_handler::unique_timer get_unique_timer() = 0;
virtual srslte::task_multiqueue::queue_handle make_task_queue() = 0;
virtual void defer_callback(uint32_t duration_ms, std::function<void()> func) = 0;
virtual void defer_task(srslte::move_task_t func) = 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;
};
class stack_interface_phy_nr class stack_interface_phy_nr
{}; {};

@ -25,10 +25,11 @@
#include "interfaces_common.h" #include "interfaces_common.h"
#include "multiqueue.h" #include "multiqueue.h"
#include "thread_pool.h" #include "thread_pool.h"
#include "timers.h"
namespace srslte { namespace srslte {
class task_scheduler : public srslte::task_handler_interface class task_scheduler
{ {
public: public:
explicit task_scheduler(uint32_t default_extern_tasks_size = 512, explicit task_scheduler(uint32_t default_extern_tasks_size = 512,
@ -52,23 +53,20 @@ public:
external_tasks.reset(); external_tasks.reset();
} }
srslte::unique_timer get_unique_timer() final { return timers.get_unique_timer(); } srslte::unique_timer get_unique_timer() { return timers.get_unique_timer(); }
//! Creates new queue for tasks coming from external thread //! Creates new queue for tasks coming from external thread
srslte::task_queue_handle make_task_queue() final { return external_tasks.get_queue_handler(); } srslte::task_queue_handle make_task_queue() { return external_tasks.get_queue_handler(); }
srslte::task_queue_handle make_task_queue(uint32_t qsize) { return external_tasks.get_queue_handler(qsize); } srslte::task_queue_handle make_task_queue(uint32_t qsize) { return external_tasks.get_queue_handler(qsize); }
//! Delays a task processing by duration_ms //! Delays a task processing by duration_ms
void defer_callback(uint32_t duration_ms, std::function<void()> func) final void defer_callback(uint32_t duration_ms, std::function<void()> func) { timers.defer_callback(duration_ms, func); }
{
timers.defer_callback(duration_ms, func);
}
//! Enqueues internal task to be run in next tic //! Enqueues internal task to be run in next tic
void defer_task(srslte::move_task_t func) final { internal_tasks.push_back(std::move(func)); } void defer_task(srslte::move_task_t func) { internal_tasks.push_back(std::move(func)); }
//! Delegates a task to a thread pool that runs in the background //! Delegates a task to a thread pool that runs in the background
void enqueue_background_task(std::function<void(uint32_t)> f) final void enqueue_background_task(std::function<void(uint32_t)> f)
{ {
if (background_tasks.nof_workers() > 0) { if (background_tasks.nof_workers() > 0) {
background_tasks.push_task(std::move(f)); background_tasks.push_task(std::move(f));
@ -79,7 +77,7 @@ public:
} }
//! Defer the handling of the result of a background task to next tic //! Defer the handling of the result of a background task to next tic
void notify_background_task_result(srslte::move_task_t task) final void notify_background_task_result(srslte::move_task_t task)
{ {
// run the notification in next tic // run the notification in next tic
external_tasks.push(background_queue_id, std::move(task)); external_tasks.push(background_queue_id, std::move(task));
@ -170,6 +168,10 @@ public:
sched->notify_background_task_result(std::move(task)); sched->notify_background_task_result(std::move(task));
} }
srslte::task_queue_handle make_task_queue() { return sched->make_task_queue(); } srslte::task_queue_handle make_task_queue() { return sched->make_task_queue(); }
void defer_callback(uint32_t duration_ms, std::function<void()> func)
{
sched->defer_callback(duration_ms, std::move(func));
}
private: private:
task_scheduler* sched; task_scheduler* sched;

@ -556,10 +556,6 @@ public:
virtual void add_gtpu_m1u_socket_handler(int fd) = 0; virtual void add_gtpu_m1u_socket_handler(int fd) = 0;
}; };
// STACK interface for MAC
class stack_interface_mac_lte : public srslte::task_handler_interface
{};
} // namespace srsenb } // namespace srsenb
#endif // SRSLTE_ENB_INTERFACES_H #endif // SRSLTE_ENB_INTERFACES_H

@ -618,11 +618,9 @@ class gw_interface_stack : public gw_interface_nas, public gw_interface_rrc, pub
{}; {};
// STACK interface for RRC // STACK interface for RRC
class stack_interface_rrc : public srslte::task_handler_interface class stack_interface_rrc
{ {
public: public:
virtual void start_cell_search() = 0;
virtual void start_cell_select(const phy_interface_rrc_lte::phy_cell_t* cell) = 0;
virtual srslte::tti_point get_current_tti() = 0; virtual srslte::tti_point get_current_tti() = 0;
}; };

@ -32,24 +32,10 @@ class stack_test_dummy : public stack_interface_rrc
public: public:
stack_test_dummy() {} stack_test_dummy() {}
srslte::timer_handler::unique_timer get_unique_timer() override { return task_sched.get_unique_timer(); }
void start_cell_search() override {}
void start_cell_select(const phy_interface_rrc_lte::phy_cell_t* cell) override {}
srslte::tti_point get_current_tti() override srslte::tti_point get_current_tti() override
{ {
return srslte::tti_point{task_sched.get_timer_handler()->get_cur_time() % 10240}; return srslte::tti_point{task_sched.get_timer_handler()->get_cur_time() % 10240};
} }
srslte::task_multiqueue::queue_handle make_task_queue() final { return task_sched.make_task_queue(); }
void enqueue_background_task(std::function<void(uint32_t)> f) override
{
task_sched.enqueue_background_task(std::move(f));
}
void notify_background_task_result(srslte::move_task_t task) override { task(); }
void defer_callback(uint32_t duration_ms, std::function<void()> func) final
{
task_sched.defer_callback(duration_ms, std::move(func));
}
void defer_task(srslte::move_task_t task) final { task_sched.defer_task(std::move(task)); }
// Testing utility functions // Testing utility functions
void run_tti() void run_tti()

@ -46,7 +46,6 @@ class enb_stack_lte final : public enb_stack_base,
public stack_interface_phy_lte, public stack_interface_phy_lte,
public stack_interface_s1ap_lte, public stack_interface_s1ap_lte,
public stack_interface_gtpu_lte, public stack_interface_gtpu_lte,
public stack_interface_mac_lte,
public srslte::thread public srslte::thread
{ {
public: public:
@ -109,14 +108,6 @@ public:
void add_gtpu_s1u_socket_handler(int fd) override; void add_gtpu_s1u_socket_handler(int fd) override;
void add_gtpu_m1u_socket_handler(int fd) override; void add_gtpu_m1u_socket_handler(int fd) override;
/* Stack-MAC interface */
srslte::unique_timer get_unique_timer() final;
srslte::task_queue_handle make_task_queue() final;
void defer_callback(uint32_t duration_ms, std::function<void()> func) final;
void enqueue_background_task(std::function<void(uint32_t)> task) final;
void notify_background_task_result(srslte::move_task_t task) final;
void defer_task(srslte::move_task_t task) final;
private: private:
static const int STACK_MAIN_THREAD_PRIO = 4; static const int STACK_MAIN_THREAD_PRIO = 4;
// thread loop // thread loop

@ -51,7 +51,6 @@ class gnb_stack_nr final : public srsenb::enb_stack_base,
public stack_interface_phy_nr, public stack_interface_phy_nr,
public stack_interface_mac, public stack_interface_mac,
public srsue::stack_interface_gw, public srsue::stack_interface_gw,
public srslte::task_handler_interface,
public srslte::thread public srslte::thread
{ {
public: public:
@ -79,14 +78,6 @@ public:
// MAC interface to trigger processing of received PDUs // MAC interface to trigger processing of received PDUs
void process_pdus() final; void process_pdus() final;
// Task Handling interface
srslte::timer_handler::unique_timer get_unique_timer() final { return task_sched.get_unique_timer(); }
srslte::task_multiqueue::queue_handle make_task_queue() final { return task_sched.make_task_queue(); }
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;
void defer_task(srslte::move_task_t task) 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);

@ -26,6 +26,7 @@
#include "scheduler_metric.h" #include "scheduler_metric.h"
#include "srslte/common/log.h" #include "srslte/common/log.h"
#include "srslte/common/mac_pcap.h" #include "srslte/common/mac_pcap.h"
#include "srslte/common/task_scheduler.h"
#include "srslte/common/threads.h" #include "srslte/common/threads.h"
#include "srslte/common/tti_sync_cv.h" #include "srslte/common/tti_sync_cv.h"
#include "srslte/interfaces/enb_interfaces.h" #include "srslte/interfaces/enb_interfaces.h"
@ -41,14 +42,13 @@ namespace srsenb {
class mac final : public mac_interface_phy_lte, public mac_interface_rlc, public mac_interface_rrc class mac final : public mac_interface_phy_lte, public mac_interface_rlc, public mac_interface_rrc
{ {
public: public:
mac(); mac(srslte::ext_task_sched_handle task_sched_);
~mac(); ~mac();
bool init(const mac_args_t& args_, bool init(const mac_args_t& args_,
const cell_list_t& cells_, const cell_list_t& cells_,
phy_interface_stack_lte* phy, phy_interface_stack_lte* phy,
rlc_interface_mac* rlc, rlc_interface_mac* rlc,
rrc_interface_mac* rrc, rrc_interface_mac* rrc,
stack_interface_mac_lte* stack_,
srslte::log_ref log_h); srslte::log_ref log_h);
void stop(); void stop();
@ -117,7 +117,7 @@ private:
phy_interface_stack_lte* phy_h = nullptr; phy_interface_stack_lte* phy_h = nullptr;
rlc_interface_mac* rlc_h = nullptr; rlc_interface_mac* rlc_h = nullptr;
rrc_interface_mac* rrc_h = nullptr; rrc_interface_mac* rrc_h = nullptr;
stack_interface_mac_lte* stack = nullptr; srslte::ext_task_sched_handle task_sched;
srslte::log_ref log_h; srslte::log_ref log_h;
cell_list_t cells = {}; cell_list_t cells = {};

@ -31,6 +31,7 @@
#include "srslte/common/common.h" #include "srslte/common/common.h"
#include "srslte/common/logmap.h" #include "srslte/common/logmap.h"
#include "srslte/common/stack_procedure.h" #include "srslte/common/stack_procedure.h"
#include "srslte/common/task_scheduler.h"
#include "srslte/common/timeout.h" #include "srslte/common/timeout.h"
#include "srslte/interfaces/enb_interfaces.h" #include "srslte/interfaces/enb_interfaces.h"
#include <map> #include <map>
@ -52,7 +53,7 @@ class rrc final : public rrc_interface_pdcp,
public rrc_interface_s1ap public rrc_interface_s1ap
{ {
public: public:
rrc(); rrc(srslte::task_sched_handle task_sched_);
~rrc(); ~rrc();
void init(const rrc_cfg_t& cfg_, void init(const rrc_cfg_t& cfg_,
@ -61,8 +62,7 @@ public:
rlc_interface_rrc* rlc, rlc_interface_rrc* rlc,
pdcp_interface_rrc* pdcp, pdcp_interface_rrc* pdcp,
s1ap_interface_rrc* s1ap, s1ap_interface_rrc* s1ap,
gtpu_interface_rrc* gtpu, gtpu_interface_rrc* gtpu);
srslte::timer_handler* timers_);
void stop(); void stop();
void get_metrics(rrc_metrics_t& m); void get_metrics(rrc_metrics_t& m);
@ -122,7 +122,7 @@ public:
private: private:
class ue; class ue;
// args // args
srslte::timer_handler* timers = nullptr; srslte::task_sched_handle task_sched;
srslte::byte_buffer_pool* pool = nullptr; srslte::byte_buffer_pool* pool = nullptr;
phy_interface_rrc_lte* phy = nullptr; phy_interface_rrc_lte* phy = nullptr;
mac_interface_rrc* mac = nullptr; mac_interface_rrc* mac = nullptr;

@ -35,6 +35,7 @@
#include "s1ap_metrics.h" #include "s1ap_metrics.h"
#include "srslte/common/network_utils.h" #include "srslte/common/network_utils.h"
#include "srslte/common/stack_procedure.h" #include "srslte/common/stack_procedure.h"
#include "srslte/common/task_scheduler.h"
#include <unordered_map> #include <unordered_map>
namespace srsenb { namespace srsenb {
@ -55,11 +56,8 @@ public:
static const uint32_t ts1_reloc_prep_timeout_ms = 10000; static const uint32_t ts1_reloc_prep_timeout_ms = 10000;
static const uint32_t ts1_reloc_overall_timeout_ms = 10000; static const uint32_t ts1_reloc_overall_timeout_ms = 10000;
s1ap(); s1ap(srslte::task_sched_handle task_sched_);
int init(s1ap_args_t args_, int init(s1ap_args_t args_, rrc_interface_s1ap* rrc_, srsenb::stack_interface_s1ap_lte* stack_);
rrc_interface_s1ap* rrc_,
srslte::timer_handler* timers_,
srsenb::stack_interface_s1ap_lte* stack_);
void stop(); void stop();
void get_metrics(s1ap_metrics_t& m); void get_metrics(s1ap_metrics_t& m);
@ -103,6 +101,7 @@ private:
srslte::log_ref s1ap_log; srslte::log_ref s1ap_log;
srslte::byte_buffer_pool* pool = nullptr; srslte::byte_buffer_pool* pool = nullptr;
srsenb::stack_interface_s1ap_lte* stack = nullptr; srsenb::stack_interface_s1ap_lte* stack = nullptr;
srslte::task_sched_handle task_sched;
srslte::socket_handler_t s1ap_socket; srslte::socket_handler_t s1ap_socket;
struct sockaddr_in mme_addr = {}; // MME address struct sockaddr_in mme_addr = {}; // MME address
@ -110,7 +109,7 @@ private:
bool running = false; bool running = false;
uint32_t next_enb_ue_s1ap_id = 1; // Next ENB-side UE identifier uint32_t next_enb_ue_s1ap_id = 1; // Next ENB-side UE identifier
uint16_t next_ue_stream_id = 1; // Next UE SCTP stream identifier uint16_t next_ue_stream_id = 1; // Next UE SCTP stream identifier
srslte::timer_handler::unique_timer mme_connect_timer, s1setup_timeout; srslte::unique_timer mme_connect_timer, s1setup_timeout;
// Protocol IEs sent with every UL S1AP message // Protocol IEs sent with every UL S1AP message
asn1::s1ap::tai_s tai; asn1::s1ap::tai_s tai;
@ -152,8 +151,7 @@ private:
class ho_prep_proc_t class ho_prep_proc_t
{ {
public: public:
struct ts1_reloc_prep_expired { struct ts1_reloc_prep_expired {};
};
ho_prep_proc_t(s1ap::ue* ue_); ho_prep_proc_t(s1ap::ue* ue_);
srslte::proc_outcome_t srslte::proc_outcome_t
init(uint32_t target_eci_, srslte::plmn_id_t target_plmn_, srslte::unique_byte_buffer_t rrc_container); init(uint32_t target_eci_, srslte::plmn_id_t target_plmn_, srslte::unique_byte_buffer_t rrc_container);
@ -208,8 +206,8 @@ private:
// state // state
bool release_requested = false; bool release_requested = false;
srslte::timer_handler::unique_timer ts1_reloc_prep; ///< TS1_{RELOCprep} - max time for HO preparation srslte::unique_timer ts1_reloc_prep; ///< TS1_{RELOCprep} - max time for HO preparation
srslte::timer_handler::unique_timer ts1_reloc_overall; ///< TS1_{RELOCOverall} srslte::unique_timer ts1_reloc_overall; ///< TS1_{RELOCOverall}
}; };
class user_list class user_list
@ -236,9 +234,6 @@ private:
}; };
user_list users; user_list users;
// timers
srslte::timer_handler* timers = nullptr;
// procedures // procedures
class s1_setup_proc_t class s1_setup_proc_t
{ {

@ -33,7 +33,10 @@ enb_stack_lte::enb_stack_lte(srslte::logger* logger_) :
task_sched(512, 0, 128), task_sched(512, 0, 128),
logger(logger_), logger(logger_),
pdcp(&task_sched, "PDCP"), pdcp(&task_sched, "PDCP"),
thread("STACK") thread("STACK"),
mac(&task_sched),
s1ap(&task_sched),
rrc(&task_sched)
{ {
enb_task_queue = task_sched.make_task_queue(); enb_task_queue = task_sched.make_task_queue();
mme_task_queue = task_sched.make_task_queue(); mme_task_queue = task_sched.make_task_queue();
@ -105,11 +108,11 @@ int enb_stack_lte::init(const stack_args_t& args_, const rrc_cfg_t& rrc_cfg_)
sync_task_queue = task_sched.make_task_queue(args.sync_queue_size); sync_task_queue = task_sched.make_task_queue(args.sync_queue_size);
// Init all layers // Init all layers
mac.init(args.mac, rrc_cfg.cell_list, phy, &rlc, &rrc, this, mac_log); mac.init(args.mac, rrc_cfg.cell_list, phy, &rlc, &rrc, mac_log);
rlc.init(&pdcp, &rrc, &mac, task_sched.get_timer_handler(), rlc_log); rlc.init(&pdcp, &rrc, &mac, task_sched.get_timer_handler(), rlc_log);
pdcp.init(&rlc, &rrc, &gtpu); pdcp.init(&rlc, &rrc, &gtpu);
rrc.init(rrc_cfg, phy, &mac, &rlc, &pdcp, &s1ap, &gtpu, task_sched.get_timer_handler()); rrc.init(rrc_cfg, phy, &mac, &rlc, &pdcp, &s1ap, &gtpu);
if (s1ap.init(args.s1ap, &rrc, task_sched.get_timer_handler(), this) != SRSLTE_SUCCESS) { if (s1ap.init(args.s1ap, &rrc, this) != SRSLTE_SUCCESS) {
stack_log->error("Couldn't initialize S1AP\n"); stack_log->error("Couldn't initialize S1AP\n");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -248,34 +251,4 @@ void enb_stack_lte::add_gtpu_m1u_socket_handler(int fd)
rx_sockets->add_socket_pdu_handler(fd, gtpu_m1u_handler); rx_sockets->add_socket_pdu_handler(fd, gtpu_m1u_handler);
} }
srslte::unique_timer enb_stack_lte::get_unique_timer()
{
return task_sched.get_unique_timer();
}
srslte::task_queue_handle enb_stack_lte::make_task_queue()
{
return task_sched.make_task_queue();
}
void enb_stack_lte::defer_callback(uint32_t duration_ms, std::function<void()> func)
{
task_sched.defer_callback(duration_ms, std::move(func));
}
void enb_stack_lte::enqueue_background_task(std::function<void(uint32_t)> task)
{
task_sched.enqueue_background_task(task);
}
void enb_stack_lte::notify_background_task_result(srslte::move_task_t task)
{
task_sched.notify_background_task_result(std::move(task));
}
void enb_stack_lte::defer_task(srslte::move_task_t task)
{
task_sched.defer_task(std::move(task));
}
} // namespace srsenb } // namespace srsenb

@ -192,29 +192,4 @@ bool gnb_stack_nr::is_lcid_enabled(uint32_t lcid)
return (lcid == args.coreless.drb_lcid); return (lcid == args.coreless.drb_lcid);
} }
/***************************
* Task Handling Interface
**************************/
void gnb_stack_nr::enqueue_background_task(std::function<void(uint32_t)> f)
{
task_sched.enqueue_background_task(std::move(f));
}
void gnb_stack_nr::notify_background_task_result(srslte::move_task_t task)
{
// run the notification in the stack thread
task_sched.notify_background_task_result(std::move(task));
}
void gnb_stack_nr::defer_callback(uint32_t duration_ms, std::function<void()> func)
{
task_sched.defer_callback(duration_ms, func);
}
void gnb_stack_nr::defer_task(srslte::move_task_t task)
{
task_sched.defer_task(std::move(task));
}
} // namespace srsenb } // namespace srsenb

@ -36,7 +36,11 @@ using namespace asn1::rrc;
namespace srsenb { namespace srsenb {
mac::mac() : rar_pdu_msg(sched_interface::MAX_RAR_LIST), rar_payload(), common_buffers(SRSLTE_MAX_CARRIERS) mac::mac(srslte::ext_task_sched_handle task_sched_) :
rar_pdu_msg(sched_interface::MAX_RAR_LIST),
rar_payload(),
common_buffers(SRSLTE_MAX_CARRIERS),
task_sched(task_sched_)
{ {
pthread_rwlock_init(&rwlock, nullptr); pthread_rwlock_init(&rwlock, nullptr);
} }
@ -52,7 +56,6 @@ bool mac::init(const mac_args_t& args_,
phy_interface_stack_lte* phy, phy_interface_stack_lte* phy,
rlc_interface_mac* rlc, rlc_interface_mac* rlc,
rrc_interface_mac* rrc, rrc_interface_mac* rrc,
stack_interface_mac_lte* stack_,
srslte::log_ref log_h_) srslte::log_ref log_h_)
{ {
started = false; started = false;
@ -61,13 +64,12 @@ bool mac::init(const mac_args_t& args_,
phy_h = phy; phy_h = phy;
rlc_h = rlc; rlc_h = rlc;
rrc_h = rrc; rrc_h = rrc;
stack = stack_;
log_h = log_h_; log_h = log_h_;
args = args_; args = args_;
cells = cells_; cells = cells_;
stack_task_queue = stack->make_task_queue(); stack_task_queue = task_sched.make_task_queue();
scheduler.init(rrc); scheduler.init(rrc);
@ -242,7 +244,7 @@ int mac::ue_rem(uint16_t rnti)
// Remove UE from the perspective of L1 // Remove UE from the perspective of L1
// Note: Let any pending retx ACK to arrive, so that PHY recognizes rnti // Note: Let any pending retx ACK to arrive, so that PHY recognizes rnti
stack->defer_callback(FDD_HARQ_DELAY_DL_MS + FDD_HARQ_DELAY_UL_MS, [this, rnti]() { task_sched.defer_callback(FDD_HARQ_DELAY_DL_MS + FDD_HARQ_DELAY_UL_MS, [this, rnti]() {
phy_h->rem_rnti(rnti); phy_h->rem_rnti(rnti);
ues_to_rem.erase(rnti); ues_to_rem.erase(rnti);
Info("User rnti=0x%x removed from MAC/PHY\n", rnti); Info("User rnti=0x%x removed from MAC/PHY\n", rnti);

@ -37,7 +37,7 @@ using namespace asn1::rrc;
namespace srsenb { namespace srsenb {
rrc::rrc() : rrc_log("RRC") rrc::rrc(srslte::task_sched_handle task_sched_) : rrc_log("RRC"), task_sched(task_sched_)
{ {
pending_paging.clear(); pending_paging.clear();
} }
@ -50,8 +50,7 @@ void rrc::init(const rrc_cfg_t& cfg_,
rlc_interface_rrc* rlc_, rlc_interface_rrc* rlc_,
pdcp_interface_rrc* pdcp_, pdcp_interface_rrc* pdcp_,
s1ap_interface_rrc* s1ap_, s1ap_interface_rrc* s1ap_,
gtpu_interface_rrc* gtpu_, gtpu_interface_rrc* gtpu_)
srslte::timer_handler* timers_)
{ {
phy = phy_; phy = phy_;
mac = mac_; mac = mac_;
@ -59,7 +58,6 @@ void rrc::init(const rrc_cfg_t& cfg_,
pdcp = pdcp_; pdcp = pdcp_;
gtpu = gtpu_; gtpu = gtpu_;
s1ap = s1ap_; s1ap = s1ap_;
timers = timers_;
pool = srslte::byte_buffer_pool::get_instance(); pool = srslte::byte_buffer_pool::get_instance();
@ -530,7 +528,7 @@ void rrc::process_release_complete(uint16_t rnti)
user_it->second->send_connection_release(); user_it->second->send_connection_release();
} }
// delay user deletion for ~50 TTI (until RRC release is sent) // delay user deletion for ~50 TTI (until RRC release is sent)
timers->defer_callback(50, [this, rnti]() { rem_user_thread(rnti); }); task_sched.defer_callback(50, [this, rnti]() { rem_user_thread(rnti); });
} else { } else {
rrc_log->error("Received ReleaseComplete for unknown rnti=0x%x\n", rnti); rrc_log->error("Received ReleaseComplete for unknown rnti=0x%x\n", rnti);
} }

@ -47,7 +47,7 @@ rrc::ue::ue(rrc* outer_rrc, uint16_t rnti_, const sched_interface::ue_cfg_t& sch
{ {
mac_ctrl.reset(new mac_controller{this, sched_ue_cfg}); mac_ctrl.reset(new mac_controller{this, sched_ue_cfg});
activity_timer = outer_rrc->timers->get_unique_timer(); activity_timer = outer_rrc->task_sched.get_unique_timer();
set_activity_timeout(MSG3_RX_TIMEOUT); // next UE response is Msg3 set_activity_timeout(MSG3_RX_TIMEOUT); // next UE response is Msg3
mobility_handler.reset(new rrc_mobility(this)); mobility_handler.reset(new rrc_mobility(this));

@ -219,24 +219,20 @@ void s1ap::s1_setup_proc_t::then(const srslte::proc_state_t& result) const
* S1AP class * S1AP class
*********************************************************/ *********************************************************/
s1ap::s1ap() : s1setup_proc(this) {} s1ap::s1ap(srslte::task_sched_handle task_sched_) : s1setup_proc(this), task_sched(task_sched_) {}
int s1ap::init(s1ap_args_t args_, int s1ap::init(s1ap_args_t args_, rrc_interface_s1ap* rrc_, srsenb::stack_interface_s1ap_lte* stack_)
rrc_interface_s1ap* rrc_,
srslte::timer_handler* timers_,
srsenb::stack_interface_s1ap_lte* stack_)
{ {
rrc = rrc_; rrc = rrc_;
args = args_; args = args_;
s1ap_log = srslte::logmap::get("S1AP"); s1ap_log = srslte::logmap::get("S1AP");
timers = timers_;
stack = stack_; stack = stack_;
pool = srslte::byte_buffer_pool::get_instance(); pool = srslte::byte_buffer_pool::get_instance();
build_tai_cgi(); build_tai_cgi();
// Setup MME reconnection timer // Setup MME reconnection timer
mme_connect_timer = timers->get_unique_timer(); mme_connect_timer = task_sched.get_unique_timer();
auto mme_connect_run = [this](uint32_t tid) { auto mme_connect_run = [this](uint32_t tid) {
if (not s1setup_proc.launch()) { if (not s1setup_proc.launch()) {
s1ap_log->error("Failed to initiate S1Setup procedure.\n"); s1ap_log->error("Failed to initiate S1Setup procedure.\n");
@ -244,7 +240,7 @@ int s1ap::init(s1ap_args_t args_,
}; };
mme_connect_timer.set(10000, mme_connect_run); mme_connect_timer.set(10000, mme_connect_run);
// Setup S1Setup timeout // Setup S1Setup timeout
s1setup_timeout = timers->get_unique_timer(); s1setup_timeout = task_sched.get_unique_timer();
uint32_t s1setup_timeout_val = 5000; uint32_t s1setup_timeout_val = 5000;
s1setup_timeout.set(s1setup_timeout_val, [this](uint32_t tid) { s1setup_timeout.set(s1setup_timeout_val, [this](uint32_t tid) {
s1_setup_proc_t::s1setupresult res; s1_setup_proc_t::s1setupresult res;
@ -1248,10 +1244,10 @@ s1ap::ue::ue(s1ap* s1ap_ptr_) : s1ap_ptr(s1ap_ptr_), s1ap_log(s1ap_ptr_->s1ap_lo
stream_id = s1ap_ptr->next_ue_stream_id; stream_id = s1ap_ptr->next_ue_stream_id;
// initialize timers // initialize timers
ts1_reloc_prep = s1ap_ptr->timers->get_unique_timer(); ts1_reloc_prep = s1ap_ptr->task_sched.get_unique_timer();
ts1_reloc_prep.set(ts1_reloc_prep_timeout_ms, ts1_reloc_prep.set(ts1_reloc_prep_timeout_ms,
[this](uint32_t tid) { ho_prep_proc.trigger(ho_prep_proc_t::ts1_reloc_prep_expired{}); }); [this](uint32_t tid) { ho_prep_proc.trigger(ho_prep_proc_t::ts1_reloc_prep_expired{}); });
ts1_reloc_overall = s1ap_ptr->timers->get_unique_timer(); ts1_reloc_overall = s1ap_ptr->task_sched.get_unique_timer();
ts1_reloc_overall.set(ts1_reloc_overall_timeout_ms, [](uint32_t tid) { /* TODO */ }); ts1_reloc_overall.set(ts1_reloc_overall_timeout_ms, [](uint32_t tid) { /* TODO */ });
} }

@ -30,14 +30,14 @@ int test_erab_setup(bool qci_exists)
{ {
printf("\n===== TEST: test_erab_setup() =====\n"); printf("\n===== TEST: test_erab_setup() =====\n");
srslte::scoped_log<srslte::test_log_filter> rrc_log("RRC "); srslte::scoped_log<srslte::test_log_filter> rrc_log("RRC ");
srslte::timer_handler timers; srslte::task_scheduler task_sched;
srslte::unique_byte_buffer_t pdu; srslte::unique_byte_buffer_t pdu;
srsenb::all_args_t args; srsenb::all_args_t args;
rrc_cfg_t cfg; rrc_cfg_t cfg;
TESTASSERT(test_helpers::parse_default_cfg(&cfg, args) == SRSLTE_SUCCESS); TESTASSERT(test_helpers::parse_default_cfg(&cfg, args) == SRSLTE_SUCCESS);
srsenb::rrc rrc; srsenb::rrc rrc{&task_sched};
mac_dummy mac; mac_dummy mac;
rlc_dummy rlc; rlc_dummy rlc;
test_dummies::pdcp_mobility_dummy pdcp; test_dummies::pdcp_mobility_dummy pdcp;
@ -46,7 +46,7 @@ int test_erab_setup(bool qci_exists)
gtpu_dummy gtpu; gtpu_dummy gtpu;
rrc_log->set_level(srslte::LOG_LEVEL_INFO); rrc_log->set_level(srslte::LOG_LEVEL_INFO);
rrc_log->set_hex_limit(1024); rrc_log->set_hex_limit(1024);
rrc.init(cfg, &phy, &mac, &rlc, &pdcp, &s1ap, &gtpu, &timers); rrc.init(cfg, &phy, &mac, &rlc, &pdcp, &s1ap, &gtpu);
uint16_t rnti = 0x46; uint16_t rnti = 0x46;
sched_interface::ue_cfg_t ue_cfg; sched_interface::ue_cfg_t ue_cfg;
@ -58,7 +58,7 @@ int test_erab_setup(bool qci_exists)
rrc_log->set_level(srslte::LOG_LEVEL_NONE); // mute all the startup log rrc_log->set_level(srslte::LOG_LEVEL_NONE); // mute all the startup log
// Do all the handshaking until the first RRC Connection Reconf // Do all the handshaking until the first RRC Connection Reconf
test_helpers::bring_rrc_to_reconf_state(rrc, timers, rnti); test_helpers::bring_rrc_to_reconf_state(rrc, *task_sched.get_timer_handler(), rnti);
rrc_log->set_level(srslte::LOG_LEVEL_DEBUG); rrc_log->set_level(srslte::LOG_LEVEL_DEBUG);
rrc_log->set_hex_limit(1024); rrc_log->set_hex_limit(1024);

@ -268,7 +268,7 @@ struct mobility_test_params {
}; };
struct mobility_tester { struct mobility_tester {
explicit mobility_tester(const mobility_test_params& args_) : args(args_) explicit mobility_tester(const mobility_test_params& args_) : args(args_), rrc(&task_sched)
{ {
rrc_log->set_level(srslte::LOG_LEVEL_INFO); rrc_log->set_level(srslte::LOG_LEVEL_INFO);
rrc_log->set_hex_limit(1024); rrc_log->set_hex_limit(1024);
@ -279,15 +279,14 @@ struct mobility_tester {
{ {
rrc_log->set_level(srslte::LOG_LEVEL_NONE); // mute all the startup log rrc_log->set_level(srslte::LOG_LEVEL_NONE); // mute all the startup log
// Do all the handshaking until the first RRC Connection Reconf // Do all the handshaking until the first RRC Connection Reconf
test_helpers::bring_rrc_to_reconf_state(rrc, timers, rnti); test_helpers::bring_rrc_to_reconf_state(rrc, *task_sched.get_timer_handler(), rnti);
rrc_log->set_level(srslte::LOG_LEVEL_INFO); rrc_log->set_level(srslte::LOG_LEVEL_INFO);
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
} }
mobility_test_params args; mobility_test_params args;
srslte::scoped_log<srslte::test_log_filter> rrc_log{"RRC"}; srslte::scoped_log<srslte::test_log_filter> rrc_log{"RRC"};
srslte::timer_handler timers; srslte::task_scheduler task_sched;
rrc_cfg_t cfg; rrc_cfg_t cfg;
srsenb::rrc rrc; srsenb::rrc rrc;
@ -300,8 +299,9 @@ struct mobility_tester {
void tic() void tic()
{ {
timers.step_all(); task_sched.tic();
rrc.tti_clock(); rrc.tti_clock();
task_sched.run_pending_tasks();
}; };
const uint16_t rnti = 0x46; const uint16_t rnti = 0x46;
@ -321,7 +321,7 @@ protected:
} }
int setup_rrc_common() int setup_rrc_common()
{ {
rrc.init(cfg, &phy, &mac, &rlc, &pdcp, &s1ap, &gtpu, &timers); rrc.init(cfg, &phy, &mac, &rlc, &pdcp, &s1ap, &gtpu);
// add user // add user
sched_interface::ue_cfg_t ue_cfg; sched_interface::ue_cfg_t ue_cfg;

@ -41,14 +41,10 @@ struct mac_nr_args_t {
class mac_nr final : public mac_interface_phy_nr, public mac_interface_rrc_nr class mac_nr final : public mac_interface_phy_nr, public mac_interface_rrc_nr
{ {
public: public:
mac_nr(); mac_nr(srslte::ext_task_sched_handle task_sched_);
~mac_nr(); ~mac_nr();
int init(const mac_nr_args_t& args_, int init(const mac_nr_args_t& args_, phy_interface_mac_nr* phy, rlc_interface_mac* rlc);
phy_interface_mac_nr* phy,
rlc_interface_mac* rlc,
srslte::timer_handler* timers_,
srslte::task_handler_interface* stack_);
void stop(); void stop();
void reset(); void reset();
@ -83,12 +79,11 @@ private:
/// Interaction with rest of the stack /// Interaction with rest of the stack
phy_interface_mac_nr* phy = nullptr; phy_interface_mac_nr* phy = nullptr;
rlc_interface_mac* rlc = nullptr; rlc_interface_mac* rlc = nullptr;
srslte::task_handler_interface* stack = nullptr; srslte::ext_task_sched_handle task_sched;
std::unique_ptr<srslte::mac_nr_pcap> pcap = nullptr; std::unique_ptr<srslte::mac_nr_pcap> pcap = nullptr;
srslte::log_ref log_h; srslte::log_ref log_h;
srslte::byte_buffer_pool* pool = nullptr; srslte::byte_buffer_pool* pool = nullptr;
srslte::timer_handler* timers = nullptr;
mac_nr_args_t args = {}; mac_nr_args_t args = {};
bool started = false; bool started = false;

@ -74,7 +74,7 @@ class rrc : public rrc_interface_nas,
public srslte::timer_callback public srslte::timer_callback
{ {
public: public:
rrc(stack_interface_rrc* stack_); rrc(stack_interface_rrc* stack_, srslte::task_sched_handle task_sched_);
~rrc(); ~rrc();
void init(phy_interface_rrc_lte* phy_, void init(phy_interface_rrc_lte* phy_,
@ -162,8 +162,11 @@ private:
srslte::block_queue<cmd_msg_t> cmd_q; srslte::block_queue<cmd_msg_t> cmd_q;
void process_pcch(srslte::unique_byte_buffer_t pdu); void process_pcch(srslte::unique_byte_buffer_t pdu);
void start_phy_cell_search();
void start_phy_cell_select(const phy_interface_rrc_lte::phy_cell_t* cell);
stack_interface_rrc* stack = nullptr; stack_interface_rrc* stack = nullptr;
srslte::task_sched_handle task_sched;
srslte::byte_buffer_pool* pool = nullptr; srslte::byte_buffer_pool* pool = nullptr;
srslte::log_ref rrc_log; srslte::log_ref rrc_log;
phy_interface_rrc_lte* phy = nullptr; phy_interface_rrc_lte* phy = nullptr;

@ -121,17 +121,9 @@ public:
bool is_lcid_enabled(uint32_t lcid) final { return pdcp.is_lcid_enabled(lcid); } bool is_lcid_enabled(uint32_t lcid) final { return pdcp.is_lcid_enabled(lcid); }
// Interface for RRC // Interface for RRC
void start_cell_search() final;
void start_cell_select(const phy_interface_rrc_lte::phy_cell_t* cell) final;
tti_point get_current_tti() final { return current_tti; } tti_point get_current_tti() final { return current_tti; }
// Task Handling interface srslte::ext_task_sched_handle get_task_sched() { return {&task_sched}; }
srslte::unique_timer get_unique_timer() final { return task_sched.get_unique_timer(); }
srslte::task_multiqueue::queue_handle make_task_queue() final { return task_sched.make_task_queue(); }
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;
void defer_task(srslte::move_task_t task) final;
private: private:
void run_thread() final; void run_thread() final;

@ -92,18 +92,8 @@ public:
bool is_lcid_enabled(uint32_t lcid) final { return pdcp->is_lcid_enabled(lcid); } bool is_lcid_enabled(uint32_t lcid) final { return pdcp->is_lcid_enabled(lcid); }
// Interface for RRC // Interface for RRC
void start_cell_search() final;
void start_cell_select(const phy_interface_rrc_lte::phy_cell_t* cell) final;
srslte::tti_point get_current_tti() { return srslte::tti_point{0}; }; srslte::tti_point get_current_tti() { return srslte::tti_point{0}; };
// Task Handling interface
srslte::timer_handler::unique_timer get_unique_timer() final { return task_sched.get_unique_timer(); }
srslte::task_multiqueue::queue_handle make_task_queue() final { return task_sched.make_task_queue(); }
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;
void defer_task(srslte::move_task_t task) 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);

@ -26,7 +26,10 @@ using namespace asn1::rrc;
namespace srsue { namespace srsue {
mac_nr::mac_nr() : pool(srslte::byte_buffer_pool::get_instance()), log_h("MAC") mac_nr::mac_nr(srslte::ext_task_sched_handle task_sched_) :
pool(srslte::byte_buffer_pool::get_instance()),
log_h("MAC"),
task_sched(task_sched_)
{ {
tx_buffer = srslte::allocate_unique_buffer(*pool); tx_buffer = srslte::allocate_unique_buffer(*pool);
rlc_buffer = srslte::allocate_unique_buffer(*pool); rlc_buffer = srslte::allocate_unique_buffer(*pool);
@ -37,20 +40,14 @@ mac_nr::~mac_nr()
stop(); stop();
} }
int mac_nr::init(const mac_nr_args_t& args_, int mac_nr::init(const mac_nr_args_t& args_, phy_interface_mac_nr* phy_, rlc_interface_mac* rlc_)
phy_interface_mac_nr* phy_,
rlc_interface_mac* rlc_,
srslte::timer_handler* timers_,
srslte::task_handler_interface* stack_)
{ {
args = args_; args = args_;
phy = phy_; phy = phy_;
rlc = rlc_; rlc = rlc_;
timers = timers_;
stack = stack_;
// Create Stack task dispatch queue // Create Stack task dispatch queue
stack_task_dispatch_queue = stack->make_task_queue(); stack_task_dispatch_queue = task_sched.make_task_queue();
// Set up pcap // Set up pcap
if (args.pcap.enable) { if (args.pcap.enable) {

@ -49,8 +49,9 @@ const static uint32_t required_sibs[NOF_REQUIRED_SIBS] = {0, 1, 2, 12}; // SIB1,
Base functions Base functions
*******************************************************************************/ *******************************************************************************/
rrc::rrc(stack_interface_rrc* stack_) : rrc::rrc(stack_interface_rrc* stack_, srslte::task_sched_handle task_sched_) :
stack(stack_), stack(stack_),
task_sched(task_sched_),
state(RRC_STATE_IDLE), state(RRC_STATE_IDLE),
last_state(RRC_STATE_CONNECTED), last_state(RRC_STATE_CONNECTED),
drb_up(false), drb_up(false),
@ -120,12 +121,12 @@ void rrc::init(phy_interface_rrc_lte* phy_,
security_is_activated = false; security_is_activated = false;
t300 = stack->get_unique_timer(); t300 = task_sched.get_unique_timer();
t301 = stack->get_unique_timer(); t301 = task_sched.get_unique_timer();
t302 = stack->get_unique_timer(); t302 = task_sched.get_unique_timer();
t310 = stack->get_unique_timer(); t310 = task_sched.get_unique_timer();
t311 = stack->get_unique_timer(); t311 = task_sched.get_unique_timer();
t304 = stack->get_unique_timer(); t304 = task_sched.get_unique_timer();
ue_identity_configured = false; ue_identity_configured = false;
@ -1365,6 +1366,26 @@ void rrc::parse_pdu_mch(uint32_t lcid, srslte::unique_byte_buffer_t pdu)
} }
} }
void rrc::start_phy_cell_search()
{
task_sched.enqueue_background_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
task_sched.notify_background_task_result([this, found_cell, ret]() { cell_search_completed(ret, found_cell); });
});
}
void rrc::start_phy_cell_select(const phy_interface_rrc_lte::phy_cell_t* cell)
{
phy_interface_rrc_lte::phy_cell_t cell_copy = *cell;
task_sched.enqueue_background_task([this, cell_copy](uint32_t worker_id) {
bool ret = phy->cell_select(&cell_copy);
// notify back RRC
task_sched.notify_background_task_result([this, ret]() { cell_select_completed(ret); });
});
}
/******************************************************************************* /*******************************************************************************
* *
* *

@ -337,7 +337,7 @@ void rrc::rrc_meas::var_meas_report_list::set_measId(const uint32_t m
// triggerType event as well as for triggerType periodical // triggerType event as well as for triggerType periodical
if (!varMeasReportList.at(measId).periodic_timer.is_valid() && if (!varMeasReportList.at(measId).periodic_timer.is_valid() &&
(report_cfg.report_amount.to_number() > 1 || report_cfg.report_amount.to_number() == -1)) { (report_cfg.report_amount.to_number() > 1 || report_cfg.report_amount.to_number() == -1)) {
varMeasReportList.at(measId).periodic_timer = rrc_ptr->stack->get_unique_timer(); varMeasReportList.at(measId).periodic_timer = rrc_ptr->task_sched.get_unique_timer();
varMeasReportList.at(measId).periodic_timer.set(report_cfg.report_interv.to_number()); varMeasReportList.at(measId).periodic_timer.set(report_cfg.report_interv.to_number());
} }
varMeasReportList.at(measId).report_cfg = std::move(report_cfg); varMeasReportList.at(measId).report_cfg = std::move(report_cfg);

@ -45,7 +45,7 @@ srslte::proc_outcome_t rrc::phy_cell_select_proc::init(const cell_t& target_cell
{ {
target_cell = &target_cell_; target_cell = &target_cell_;
Info("Starting for %s\n", target_cell->to_string().c_str()); Info("Starting for %s\n", target_cell->to_string().c_str());
rrc_ptr->stack->start_cell_select(&target_cell->phy_cell); rrc_ptr->start_phy_cell_select(&target_cell->phy_cell);
return proc_outcome_t::yield; return proc_outcome_t::yield;
} }
@ -82,7 +82,7 @@ proc_outcome_t rrc::cell_search_proc::init()
{ {
Info("Starting...\n"); Info("Starting...\n");
state = state_t::phy_cell_search; state = state_t::phy_cell_search;
rrc_ptr->stack->start_cell_search(); rrc_ptr->start_phy_cell_search();
return proc_outcome_t::yield; return proc_outcome_t::yield;
} }
@ -283,8 +283,8 @@ compute_si_window(uint32_t tti, uint32_t sib_index, uint32_t n, uint32_t T, cons
rrc::si_acquire_proc::si_acquire_proc(rrc* parent_) : rrc::si_acquire_proc::si_acquire_proc(rrc* parent_) :
rrc_ptr(parent_), rrc_ptr(parent_),
log_h(srslte::logmap::get("RRC")), log_h(srslte::logmap::get("RRC")),
si_acq_timeout(rrc_ptr->stack->get_unique_timer()), si_acq_timeout(rrc_ptr->task_sched.get_unique_timer()),
si_acq_retry_timer(rrc_ptr->stack->get_unique_timer()) si_acq_retry_timer(rrc_ptr->task_sched.get_unique_timer())
{ {
// SIB acquisition procedure timeout. // SIB acquisition procedure timeout.
// NOTE: The standard does not specify this timeout // NOTE: The standard does not specify this timeout
@ -1067,7 +1067,7 @@ proc_outcome_t rrc::process_pcch_proc::react(paging_complete e)
rrc::go_idle_proc::go_idle_proc(srsue::rrc* rrc_) : rrc_ptr(rrc_) rrc::go_idle_proc::go_idle_proc(srsue::rrc* rrc_) : rrc_ptr(rrc_)
{ {
rlc_flush_timer = rrc_ptr->stack->get_unique_timer(); rlc_flush_timer = rrc_ptr->task_sched.get_unique_timer();
rlc_flush_timer.set(rlc_flush_timeout_ms, [this](uint32_t tid) { rrc_ptr->idle_setter.trigger(true); }); rlc_flush_timer.set(rlc_flush_timeout_ms, [this](uint32_t tid) { rrc_ptr->idle_setter.trigger(true); });
} }
@ -1120,7 +1120,7 @@ void rrc::go_idle_proc::then(const srslte::proc_state_t& result)
rrc::cell_reselection_proc::cell_reselection_proc(srsue::rrc* rrc_) : rrc_ptr(rrc_) rrc::cell_reselection_proc::cell_reselection_proc(srsue::rrc* rrc_) : rrc_ptr(rrc_)
{ {
// Timer for cell reselection procedure to self-relaunch periodically // Timer for cell reselection procedure to self-relaunch periodically
reselection_timer = rrc_ptr->stack->get_unique_timer(); reselection_timer = rrc_ptr->task_sched.get_unique_timer();
reselection_timer.set(cell_reselection_periodicity_ms, [this](uint32_t tid) { reselection_timer.set(cell_reselection_periodicity_ms, [this](uint32_t tid) {
if (not rrc_ptr->cell_reselector.launch()) { if (not rrc_ptr->cell_reselector.launch()) {
rrc_ptr->rrc_log->error("Failed to initiate a Cell Reselection procedure...\n"); rrc_ptr->rrc_log->error("Failed to initiate a Cell Reselection procedure...\n");

@ -39,7 +39,7 @@ ue_stack_lte::ue_stack_lte() :
phy(nullptr), phy(nullptr),
rlc("RLC"), rlc("RLC"),
mac("MAC", &task_sched), mac("MAC", &task_sched),
rrc(this), rrc(this, &task_sched),
pdcp(&task_sched, "PDCP"), pdcp(&task_sched, "PDCP"),
nas(&task_sched), nas(&task_sched),
thread("STACK"), thread("STACK"),
@ -305,53 +305,4 @@ void ue_stack_lte::run_tti_impl(uint32_t tti, uint32_t tti_jump)
} }
} }
/***************************
* Task Handling Interface
**************************/
void ue_stack_lte::enqueue_background_task(std::function<void(uint32_t)> f)
{
task_sched.enqueue_background_task(std::move(f));
}
void ue_stack_lte::notify_background_task_result(srslte::move_task_t task)
{
// run the notification in the stack thread
task_sched.notify_background_task_result(std::move(task));
}
void ue_stack_lte::defer_callback(uint32_t duration_ms, std::function<void()> func)
{
task_sched.defer_callback(duration_ms, std::move(func));
}
void ue_stack_lte::defer_task(srslte::move_task_t task)
{
task_sched.defer_task(std::move(task));
}
/********************
* RRC Interface
*******************/
void ue_stack_lte::start_cell_search()
{
task_sched.enqueue_background_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
task_sched.notify_background_task_result([this, found_cell, ret]() { rrc.cell_search_completed(ret, found_cell); });
});
}
void ue_stack_lte::start_cell_select(const phy_interface_rrc_lte::phy_cell_t* phy_cell)
{
phy_interface_rrc_lte::phy_cell_t cell_copy = *phy_cell;
task_sched.enqueue_background_task([this, cell_copy](uint32_t worker_id) {
bool ret = phy->cell_select(&cell_copy);
// notify back RRC
task_sched.notify_background_task_result([this, ret]() { rrc.cell_select_completed(ret); });
});
}
} // namespace srsue } // namespace srsue

@ -34,7 +34,7 @@ ue_stack_nr::ue_stack_nr(srslte::logger* logger_) :
pdcp_log("PDCP"), pdcp_log("PDCP"),
pool_log("POOL") pool_log("POOL")
{ {
mac.reset(new mac_nr()); mac.reset(new mac_nr(&task_sched));
pdcp.reset(new srslte::pdcp(&task_sched, "PDCP")); pdcp.reset(new srslte::pdcp(&task_sched, "PDCP"));
rlc.reset(new srslte::rlc("RLC")); rlc.reset(new srslte::rlc("RLC"));
rrc.reset(new rrc_nr()); rrc.reset(new rrc_nr());
@ -82,7 +82,7 @@ int ue_stack_nr::init(const stack_args_t& args_)
mac_nr_args_t mac_args = {}; mac_nr_args_t mac_args = {};
mac_args.pcap = args.pcap; mac_args.pcap = args.pcap;
mac_args.drb_lcid = 4; mac_args.drb_lcid = 4;
mac->init(mac_args, phy, rlc.get(), task_sched.get_timer_handler(), this); mac->init(mac_args, phy, rlc.get());
rlc->init(pdcp.get(), rrc.get(), task_sched.get_timer_handler(), 0 /* RB_ID_SRB0 */); rlc->init(pdcp.get(), rrc.get(), task_sched.get_timer_handler(), 0 /* RB_ID_SRB0 */);
pdcp->init(rlc.get(), rrc.get(), gw); pdcp->init(rlc.get(), rrc.get(), gw);
@ -208,43 +208,4 @@ void ue_stack_nr::run_tti_impl(uint32_t tti)
task_sched.tic(); task_sched.tic();
} }
/********************
* low MAC Interface
*******************/
void ue_stack_nr::start_cell_search()
{
// not implemented
}
void ue_stack_nr::start_cell_select(const phy_interface_rrc_lte::phy_cell_t* cell)
{
// not implemented
}
/***************************
* Task Handling Interface
**************************/
void ue_stack_nr::enqueue_background_task(std::function<void(uint32_t)> f)
{
task_sched.enqueue_background_task(std::move(f));
}
void ue_stack_nr::notify_background_task_result(srslte::move_task_t task)
{
// run the notification in the stack thread
task_sched.notify_background_task_result(std::move(task));
}
void ue_stack_nr::defer_callback(uint32_t duration_ms, std::function<void()> func)
{
task_sched.defer_callback(duration_ms, std::move(func));
}
void ue_stack_nr::defer_task(srslte::move_task_t task)
{
task_sched.defer_task(std::move(task));
}
} // namespace srsue } // namespace srsue

@ -211,7 +211,7 @@ void ttcn3_ue::set_test_loop_mode(const test_loop_mode_state_t mode, const uint3
break; break;
case TEST_LOOP_MODE_B_ACTIVE: case TEST_LOOP_MODE_B_ACTIVE:
log.info("Activating Test loop mode B with %d ms PDU delay\n", ip_pdu_delay_ms_); log.info("Activating Test loop mode B with %d ms PDU delay\n", ip_pdu_delay_ms_);
pdu_delay_timer = stack->get_unique_timer(); pdu_delay_timer = stack->get_task_sched().get_unique_timer();
if (ip_pdu_delay_ms_ > 0) { if (ip_pdu_delay_ms_ > 0) {
pdu_delay_timer.set(ip_pdu_delay_ms_, [this](uint32_t tid) { timer_expired(tid); }); pdu_delay_timer.set(ip_pdu_delay_ms_, [this](uint32_t tid) { timer_expired(tid); });
} }
@ -236,7 +236,7 @@ void ttcn3_ue::send_queued_data()
if (not stack->switch_on()) { if (not stack->switch_on()) {
log.warning("Could not reestablish the connection\n"); log.warning("Could not reestablish the connection\n");
} }
stack->defer_callback(500, [&]() { send_queued_data(); }); stack->get_task_sched().defer_callback(500, [&]() { send_queued_data(); });
return; return;
} }

@ -54,7 +54,11 @@ public:
void set_config_mbsfn_mcch(const srslte::mcch_msg_t& mcch) override {} void set_config_mbsfn_mcch(const srslte::mcch_msg_t& mcch) override {}
cell_search_ret_t cell_search(phy_cell_t* cell) override { return {}; } cell_search_ret_t cell_search(phy_cell_t* cell) override { return {}; }
bool cell_is_camping() override { return false; } bool cell_is_camping() override { return false; }
bool cell_select(const phy_cell_t* cell = nullptr) override { return false; } bool cell_select(const phy_cell_t* cell = nullptr) override
{
last_selected_cell = *cell;
return true;
}
void reset() override {} void reset() override {}
void enable_pregen_signals(bool enable) override {} void enable_pregen_signals(bool enable) override {}
@ -96,6 +100,8 @@ public:
} }
} }
phy_interface_rrc_lte::phy_cell_t last_selected_cell = {};
private: private:
bool meas_reset_called = false; bool meas_reset_called = false;
std::set<uint32_t> freqs_started; std::set<uint32_t> freqs_started;
@ -104,14 +110,6 @@ private:
uint32_t serving_earfcn = 0; uint32_t serving_earfcn = 0;
}; };
class stack_test final : public stack_test_dummy
{
public:
void start_cell_select(const phy_interface_rrc_lte::phy_cell_t* cell) override { last_selected_cell = *cell; }
phy_interface_rrc_lte::phy_cell_t last_selected_cell = {};
};
class nas_test : public srsue::nas class nas_test : public srsue::nas
{ {
public: public:
@ -177,7 +175,7 @@ class rrc_test : public rrc
srsue::stack_test_dummy* stack = nullptr; srsue::stack_test_dummy* stack = nullptr;
public: public:
rrc_test(srslte::log_ref log_, stack_test_dummy* stack_) : rrc(stack_), stack(stack_) rrc_test(srslte::log_ref log_, stack_test_dummy* stack_) : rrc(stack_, &stack_->task_sched), stack(stack_)
{ {
pool = srslte::byte_buffer_pool::get_instance(); pool = srslte::byte_buffer_pool::get_instance();
nastest = std::unique_ptr<nas_test>(new nas_test(&stack->task_sched)); nastest = std::unique_ptr<nas_test>(new nas_test(&stack->task_sched));
@ -295,7 +293,7 @@ int cell_select_test()
{ {
// CHECK: The starting serving cell pci=2 is the weakest, and cell selection procedure chooses pci=1 // CHECK: The starting serving cell pci=2 is the weakest, and cell selection procedure chooses pci=1
// CHECK: phy cell selection is successful, and rrc remains in pci=1 // CHECK: phy cell selection is successful, and rrc remains in pci=1
stack_test stack; stack_test_dummy stack;
rrc_test rrctest(log1, &stack); rrc_test rrctest(log1, &stack);
rrctest.init(); rrctest.init();
rrctest.connect(); rrctest.connect();
@ -314,8 +312,9 @@ int cell_select_test()
// Start cell selection procedure. The RRC will start with strongest cell // Start cell selection procedure. The RRC will start with strongest cell
TESTASSERT(rrctest.start_cell_select() == SRSLTE_SUCCESS); TESTASSERT(rrctest.start_cell_select() == SRSLTE_SUCCESS);
TESTASSERT(stack.last_selected_cell.earfcn == 1); stack.run_pending_tasks();
TESTASSERT(stack.last_selected_cell.pci == 1); TESTASSERT(rrctest.phytest.last_selected_cell.earfcn == 1);
TESTASSERT(rrctest.phytest.last_selected_cell.pci == 1);
TESTASSERT(rrctest.has_neighbour_cell(2, 2)); TESTASSERT(rrctest.has_neighbour_cell(2, 2));
TESTASSERT(!rrctest.has_neighbour_cell(1, 1)); TESTASSERT(!rrctest.has_neighbour_cell(1, 1));
@ -330,7 +329,7 @@ int cell_select_test()
// CHECK: The starting serving cell pci=1 is the strongest, and the cell selection procedure calls phy_cell_select // CHECK: The starting serving cell pci=1 is the strongest, and the cell selection procedure calls phy_cell_select
// for pci=1. // for pci=1.
// CHECK: Cell selection fails in the phy, and rrc moves to pci=2 // CHECK: Cell selection fails in the phy, and rrc moves to pci=2
stack_test stack; stack_test_dummy stack;
rrc_test rrctest(log1, &stack); rrc_test rrctest(log1, &stack);
rrctest.init(); rrctest.init();
rrctest.connect(); rrctest.connect();
@ -343,8 +342,9 @@ int cell_select_test()
// Start cell selection procedure. The RRC will start with strongest cell // Start cell selection procedure. The RRC will start with strongest cell
TESTASSERT(rrctest.start_cell_select() == SRSLTE_SUCCESS); TESTASSERT(rrctest.start_cell_select() == SRSLTE_SUCCESS);
TESTASSERT(stack.last_selected_cell.earfcn == 1); stack.run_pending_tasks();
TESTASSERT(stack.last_selected_cell.pci == 1); TESTASSERT(rrctest.phytest.last_selected_cell.earfcn == 1);
TESTASSERT(rrctest.phytest.last_selected_cell.pci == 1);
TESTASSERT(rrctest.has_neighbour_cell(2, 2)); TESTASSERT(rrctest.has_neighbour_cell(2, 2));
TESTASSERT(!rrctest.has_neighbour_cell(1, 1)); // selected current serving cell bc it is stronger TESTASSERT(!rrctest.has_neighbour_cell(1, 1)); // selected current serving cell bc it is stronger

Loading…
Cancel
Save