removal of stack handler interface

This commit is contained in:
Francisco Paisana 2020-07-09 17:54:42 +01:00
parent 7c364070ee
commit 5e06430455
30 changed files with 172 additions and 373 deletions

View File

@ -22,9 +22,7 @@
#ifndef SRSLTE_INTERFACES_COMMON_H
#define SRSLTE_INTERFACES_COMMON_H
#include "srslte/common/multiqueue.h"
#include "srslte/common/security.h"
#include "srslte/common/timers.h"
#include <string>
namespace srslte {
@ -87,18 +85,6 @@ public:
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
{};

View File

@ -25,10 +25,11 @@
#include "interfaces_common.h"
#include "multiqueue.h"
#include "thread_pool.h"
#include "timers.h"
namespace srslte {
class task_scheduler : public srslte::task_handler_interface
class task_scheduler
{
public:
explicit task_scheduler(uint32_t default_extern_tasks_size = 512,
@ -52,23 +53,20 @@ public:
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
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); }
//! Delays a task processing by duration_ms
void defer_callback(uint32_t duration_ms, std::function<void()> func) final
{
timers.defer_callback(duration_ms, func);
}
void defer_callback(uint32_t duration_ms, std::function<void()> func) { timers.defer_callback(duration_ms, func); }
//! 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
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) {
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
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
external_tasks.push(background_queue_id, std::move(task));
@ -170,6 +168,10 @@ public:
sched->notify_background_task_result(std::move(task));
}
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:
task_scheduler* sched;

View File

@ -556,10 +556,6 @@ public:
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
#endif // SRSLTE_ENB_INTERFACES_H

View File

@ -618,12 +618,10 @@ class gw_interface_stack : public gw_interface_nas, public gw_interface_rrc, pub
{};
// STACK interface for RRC
class stack_interface_rrc : public srslte::task_handler_interface
class stack_interface_rrc
{
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;
};
// Combined interface for PHY to access stack (MAC and RRC)

View File

@ -32,24 +32,10 @@ class stack_test_dummy : public stack_interface_rrc
public:
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};
}
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
void run_tti()

View File

@ -46,7 +46,6 @@ class enb_stack_lte final : public enb_stack_base,
public stack_interface_phy_lte,
public stack_interface_s1ap_lte,
public stack_interface_gtpu_lte,
public stack_interface_mac_lte,
public srslte::thread
{
public:
@ -109,14 +108,6 @@ public:
void add_gtpu_s1u_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:
static const int STACK_MAIN_THREAD_PRIO = 4;
// thread loop

View File

@ -51,7 +51,6 @@ class gnb_stack_nr final : public srsenb::enb_stack_base,
public stack_interface_phy_nr,
public stack_interface_mac,
public srsue::stack_interface_gw,
public srslte::task_handler_interface,
public srslte::thread
{
public:
@ -79,14 +78,6 @@ public:
// MAC interface to trigger processing of received PDUs
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:
void run_thread() final;
void run_tti_impl(uint32_t tti);

View File

@ -26,6 +26,7 @@
#include "scheduler_metric.h"
#include "srslte/common/log.h"
#include "srslte/common/mac_pcap.h"
#include "srslte/common/task_scheduler.h"
#include "srslte/common/threads.h"
#include "srslte/common/tti_sync_cv.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
{
public:
mac();
mac(srslte::ext_task_sched_handle task_sched_);
~mac();
bool init(const mac_args_t& args_,
const cell_list_t& cells_,
phy_interface_stack_lte* phy,
rlc_interface_mac* rlc,
rrc_interface_mac* rrc,
stack_interface_mac_lte* stack_,
srslte::log_ref log_h);
void stop();
@ -114,11 +114,11 @@ private:
pthread_rwlock_t rwlock = {};
// Interaction with PHY
phy_interface_stack_lte* phy_h = nullptr;
rlc_interface_mac* rlc_h = nullptr;
rrc_interface_mac* rrc_h = nullptr;
stack_interface_mac_lte* stack = nullptr;
srslte::log_ref log_h;
phy_interface_stack_lte* phy_h = nullptr;
rlc_interface_mac* rlc_h = nullptr;
rrc_interface_mac* rrc_h = nullptr;
srslte::ext_task_sched_handle task_sched;
srslte::log_ref log_h;
cell_list_t cells = {};
mac_args_t args = {};
@ -153,7 +153,7 @@ private:
const static int NOF_BCCH_DLSCH_MSG = sched_interface::MAX_SIBS;
const static int pcch_payload_buffer_len = 1024;
const static int pcch_payload_buffer_len = 1024;
typedef struct {
uint8_t pcch_payload_buffer[pcch_payload_buffer_len] = {};
srslte_softbuffer_tx_t bcch_softbuffer_tx[NOF_BCCH_DLSCH_MSG] = {};

View File

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

View File

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

View File

@ -33,7 +33,10 @@ enb_stack_lte::enb_stack_lte(srslte::logger* logger_) :
task_sched(512, 0, 128),
logger(logger_),
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();
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);
// 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);
pdcp.init(&rlc, &rrc, &gtpu);
rrc.init(rrc_cfg, phy, &mac, &rlc, &pdcp, &s1ap, &gtpu, task_sched.get_timer_handler());
if (s1ap.init(args.s1ap, &rrc, task_sched.get_timer_handler(), this) != SRSLTE_SUCCESS) {
rrc.init(rrc_cfg, phy, &mac, &rlc, &pdcp, &s1ap, &gtpu);
if (s1ap.init(args.s1ap, &rrc, this) != SRSLTE_SUCCESS) {
stack_log->error("Couldn't initialize S1AP\n");
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);
}
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

View File

@ -192,29 +192,4 @@ bool gnb_stack_nr::is_lcid_enabled(uint32_t 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

View File

@ -36,7 +36,11 @@ using namespace asn1::rrc;
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);
}
@ -52,7 +56,6 @@ bool mac::init(const mac_args_t& args_,
phy_interface_stack_lte* phy,
rlc_interface_mac* rlc,
rrc_interface_mac* rrc,
stack_interface_mac_lte* stack_,
srslte::log_ref log_h_)
{
started = false;
@ -61,13 +64,12 @@ bool mac::init(const mac_args_t& args_,
phy_h = phy;
rlc_h = rlc;
rrc_h = rrc;
stack = stack_;
log_h = log_h_;
args = args_;
cells = cells_;
stack_task_queue = stack->make_task_queue();
stack_task_queue = task_sched.make_task_queue();
scheduler.init(rrc);
@ -242,7 +244,7 @@ int mac::ue_rem(uint16_t rnti)
// Remove UE from the perspective of L1
// 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);
ues_to_rem.erase(rnti);
Info("User rnti=0x%x removed from MAC/PHY\n", rnti);

View File

@ -37,7 +37,7 @@ using namespace asn1::rrc;
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();
}
@ -50,16 +50,14 @@ void rrc::init(const rrc_cfg_t& cfg_,
rlc_interface_rrc* rlc_,
pdcp_interface_rrc* pdcp_,
s1ap_interface_rrc* s1ap_,
gtpu_interface_rrc* gtpu_,
srslte::timer_handler* timers_)
gtpu_interface_rrc* gtpu_)
{
phy = phy_;
mac = mac_;
rlc = rlc_;
pdcp = pdcp_;
gtpu = gtpu_;
s1ap = s1ap_;
timers = timers_;
phy = phy_;
mac = mac_;
rlc = rlc_;
pdcp = pdcp_;
gtpu = gtpu_;
s1ap = s1ap_;
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();
}
// 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 {
rrc_log->error("Received ReleaseComplete for unknown rnti=0x%x\n", rnti);
}

View File

@ -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});
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
mobility_handler.reset(new rrc_mobility(this));

View File

@ -219,24 +219,20 @@ void s1ap::s1_setup_proc_t::then(const srslte::proc_state_t& result) const
* 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_,
rrc_interface_s1ap* rrc_,
srslte::timer_handler* timers_,
srsenb::stack_interface_s1ap_lte* stack_)
int s1ap::init(s1ap_args_t args_, rrc_interface_s1ap* rrc_, srsenb::stack_interface_s1ap_lte* stack_)
{
rrc = rrc_;
args = args_;
s1ap_log = srslte::logmap::get("S1AP");
timers = timers_;
stack = stack_;
pool = srslte::byte_buffer_pool::get_instance();
build_tai_cgi();
// 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) {
if (not s1setup_proc.launch()) {
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);
// Setup S1Setup timeout
s1setup_timeout = timers->get_unique_timer();
s1setup_timeout = task_sched.get_unique_timer();
uint32_t s1setup_timeout_val = 5000;
s1setup_timeout.set(s1setup_timeout_val, [this](uint32_t tid) {
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;
// 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,
[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 */ });
}

View File

@ -30,14 +30,14 @@ int test_erab_setup(bool qci_exists)
{
printf("\n===== TEST: test_erab_setup() =====\n");
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;
srsenb::all_args_t args;
rrc_cfg_t cfg;
TESTASSERT(test_helpers::parse_default_cfg(&cfg, args) == SRSLTE_SUCCESS);
srsenb::rrc rrc;
srsenb::rrc rrc{&task_sched};
mac_dummy mac;
rlc_dummy rlc;
test_dummies::pdcp_mobility_dummy pdcp;
@ -46,7 +46,7 @@ int test_erab_setup(bool qci_exists)
gtpu_dummy gtpu;
rrc_log->set_level(srslte::LOG_LEVEL_INFO);
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;
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
// 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_hex_limit(1024);

View File

@ -268,7 +268,7 @@ struct mobility_test_params {
};
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_hex_limit(1024);
@ -279,15 +279,14 @@ struct mobility_tester {
{
rrc_log->set_level(srslte::LOG_LEVEL_NONE); // mute all the startup log
// 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);
return SRSLTE_SUCCESS;
}
mobility_test_params args;
mobility_test_params args;
srslte::scoped_log<srslte::test_log_filter> rrc_log{"RRC"};
srslte::timer_handler timers;
srslte::task_scheduler task_sched;
rrc_cfg_t cfg;
srsenb::rrc rrc;
@ -300,8 +299,9 @@ struct mobility_tester {
void tic()
{
timers.step_all();
task_sched.tic();
rrc.tti_clock();
task_sched.run_pending_tasks();
};
const uint16_t rnti = 0x46;
@ -321,7 +321,7 @@ protected:
}
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
sched_interface::ue_cfg_t ue_cfg;

View File

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

View File

@ -74,7 +74,7 @@ class rrc : public rrc_interface_nas,
public srslte::timer_callback
{
public:
rrc(stack_interface_rrc* stack_);
rrc(stack_interface_rrc* stack_, srslte::task_sched_handle task_sched_);
~rrc();
void init(phy_interface_rrc_lte* phy_,
@ -162,9 +162,12 @@ private:
srslte::block_queue<cmd_msg_t> cmd_q;
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;
srslte::byte_buffer_pool* pool = nullptr;
srslte::task_sched_handle task_sched;
srslte::byte_buffer_pool* pool = nullptr;
srslte::log_ref rrc_log;
phy_interface_rrc_lte* phy = nullptr;
mac_interface_rrc* mac = nullptr;

View File

@ -121,17 +121,9 @@ public:
bool is_lcid_enabled(uint32_t lcid) final { return pdcp.is_lcid_enabled(lcid); }
// 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; }
// Task Handling interface
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;
srslte::ext_task_sched_handle get_task_sched() { return {&task_sched}; }
private:
void run_thread() final;

View File

@ -92,18 +92,8 @@ public:
bool is_lcid_enabled(uint32_t lcid) final { return pdcp->is_lcid_enabled(lcid); }
// 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}; };
// 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:
void run_thread() final;
void run_tti_impl(uint32_t tti);

View File

@ -26,7 +26,10 @@ using namespace asn1::rrc;
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);
rlc_buffer = srslte::allocate_unique_buffer(*pool);
@ -37,20 +40,14 @@ mac_nr::~mac_nr()
stop();
}
int mac_nr::init(const mac_nr_args_t& args_,
phy_interface_mac_nr* phy_,
rlc_interface_mac* rlc_,
srslte::timer_handler* timers_,
srslte::task_handler_interface* stack_)
int mac_nr::init(const mac_nr_args_t& args_, phy_interface_mac_nr* phy_, rlc_interface_mac* rlc_)
{
args = args_;
phy = phy_;
rlc = rlc_;
timers = timers_;
stack = stack_;
args = args_;
phy = phy_;
rlc = rlc_;
// 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
if (args.pcap.enable) {

View File

@ -49,8 +49,9 @@ const static uint32_t required_sibs[NOF_REQUIRED_SIBS] = {0, 1, 2, 12}; // SIB1,
Base functions
*******************************************************************************/
rrc::rrc(stack_interface_rrc* stack_) :
rrc::rrc(stack_interface_rrc* stack_, srslte::task_sched_handle task_sched_) :
stack(stack_),
task_sched(task_sched_),
state(RRC_STATE_IDLE),
last_state(RRC_STATE_CONNECTED),
drb_up(false),
@ -120,12 +121,12 @@ void rrc::init(phy_interface_rrc_lte* phy_,
security_is_activated = false;
t300 = stack->get_unique_timer();
t301 = stack->get_unique_timer();
t302 = stack->get_unique_timer();
t310 = stack->get_unique_timer();
t311 = stack->get_unique_timer();
t304 = stack->get_unique_timer();
t300 = task_sched.get_unique_timer();
t301 = task_sched.get_unique_timer();
t302 = task_sched.get_unique_timer();
t310 = task_sched.get_unique_timer();
t311 = task_sched.get_unique_timer();
t304 = task_sched.get_unique_timer();
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); });
});
}
/*******************************************************************************
*
*

View File

@ -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
if (!varMeasReportList.at(measId).periodic_timer.is_valid() &&
(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).report_cfg = std::move(report_cfg);

View File

@ -45,7 +45,7 @@ srslte::proc_outcome_t rrc::phy_cell_select_proc::init(const cell_t& target_cell
{
target_cell = &target_cell_;
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;
}
@ -82,7 +82,7 @@ proc_outcome_t rrc::cell_search_proc::init()
{
Info("Starting...\n");
state = state_t::phy_cell_search;
rrc_ptr->stack->start_cell_search();
rrc_ptr->start_phy_cell_search();
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_ptr(parent_),
log_h(srslte::logmap::get("RRC")),
si_acq_timeout(rrc_ptr->stack->get_unique_timer()),
si_acq_retry_timer(rrc_ptr->stack->get_unique_timer())
si_acq_timeout(rrc_ptr->task_sched.get_unique_timer()),
si_acq_retry_timer(rrc_ptr->task_sched.get_unique_timer())
{
// SIB acquisition procedure 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_)
{
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); });
}
@ -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_)
{
// 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) {
if (not rrc_ptr->cell_reselector.launch()) {
rrc_ptr->rrc_log->error("Failed to initiate a Cell Reselection procedure...\n");

View File

@ -39,7 +39,7 @@ ue_stack_lte::ue_stack_lte() :
phy(nullptr),
rlc("RLC"),
mac("MAC", &task_sched),
rrc(this),
rrc(this, &task_sched),
pdcp(&task_sched, "PDCP"),
nas(&task_sched),
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

View File

@ -34,7 +34,7 @@ ue_stack_nr::ue_stack_nr(srslte::logger* logger_) :
pdcp_log("PDCP"),
pool_log("POOL")
{
mac.reset(new mac_nr());
mac.reset(new mac_nr(&task_sched));
pdcp.reset(new srslte::pdcp(&task_sched, "PDCP"));
rlc.reset(new srslte::rlc("RLC"));
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_args.pcap = args.pcap;
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 */);
pdcp->init(rlc.get(), rrc.get(), gw);
@ -208,43 +208,4 @@ void ue_stack_nr::run_tti_impl(uint32_t tti)
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

View File

@ -211,7 +211,7 @@ void ttcn3_ue::set_test_loop_mode(const test_loop_mode_state_t mode, const uint3
break;
case TEST_LOOP_MODE_B_ACTIVE:
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) {
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()) {
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;
}

View File

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