Moving mac timers to stack timers (#638)

* first step towards moving MAC timers to stack. Mac is still using its own timers. srslte::timers class can be restructured.

* moved timers out of the UE MAC
master
Francisco Paisana 5 years ago committed by Andre Puschmann
parent 69edee4e6c
commit 67d6a25194

@ -96,11 +96,12 @@ public:
bool running; bool running;
}; };
timers(uint32_t nof_timers_) : timer_list(nof_timers_),used_timers(nof_timers_) { timers(uint32_t nof_timers_) : timer_list(nof_timers_), used_timers(nof_timers_)
{
nof_timers = nof_timers_; nof_timers = nof_timers_;
next_timer = 0; next_timer = 0;
nof_used_timers = 0; nof_used_timers = 0;
for (uint32_t i=0;i<nof_timers;i++) { for (uint32_t i = 0; i < nof_timers; i++) {
timer_list[i].id = i; timer_list[i].id = i;
used_timers[i] = false; used_timers[i] = false;
} }

@ -45,13 +45,10 @@ class rlc
public: public:
rlc(log* rlc_log_); rlc(log* rlc_log_);
virtual ~rlc(); virtual ~rlc();
void init(srsue::pdcp_interface_rlc* pdcp_, void init(srsue::pdcp_interface_rlc* pdcp_, srsue::rrc_interface_rlc* rrc_, srslte::timers* timers_, uint32_t lcid_);
srsue::rrc_interface_rlc* rrc_,
mac_interface_timers* mac_timers_,
uint32_t lcid_);
void stop(); void stop();
void get_metrics(rlc_metrics_t &m); void get_metrics(rlc_metrics_t& m);
// PDCP interface // PDCP interface
void write_sdu(uint32_t lcid, unique_byte_buffer_t sdu, bool blocking = true); void write_sdu(uint32_t lcid, unique_byte_buffer_t sdu, bool blocking = true);
@ -92,7 +89,7 @@ private:
srslte::log* rlc_log = nullptr; srslte::log* rlc_log = nullptr;
srsue::pdcp_interface_rlc* pdcp = nullptr; srsue::pdcp_interface_rlc* pdcp = nullptr;
srsue::rrc_interface_rlc* rrc = nullptr; srsue::rrc_interface_rlc* rrc = nullptr;
srslte::mac_interface_timers* mac_timers = nullptr; srslte::timers* timers = nullptr;
typedef std::map<uint16_t, rlc_common*> rlc_map_t; typedef std::map<uint16_t, rlc_common*> rlc_map_t;
typedef std::pair<uint16_t, rlc_common*> rlc_map_pair_t; typedef std::pair<uint16_t, rlc_common*> rlc_map_pair_t;

@ -68,8 +68,7 @@ public:
uint32_t lcid_, uint32_t lcid_,
srsue::pdcp_interface_rlc* pdcp_, srsue::pdcp_interface_rlc* pdcp_,
srsue::rrc_interface_rlc* rrc_, srsue::rrc_interface_rlc* rrc_,
srslte::mac_interface_timers* mac_timers_); srslte::timers* timers_);
~rlc_am();
bool configure(rlc_config_t cfg_); bool configure(rlc_config_t cfg_);
void reestablish(); void reestablish();
void stop(); void stop();
@ -279,7 +278,7 @@ private:
srsue::rrc_interface_rlc* rrc = nullptr; srsue::rrc_interface_rlc* rrc = nullptr;
srslte::log* log = nullptr; srslte::log* log = nullptr;
srsue::pdcp_interface_rlc* pdcp = nullptr; srsue::pdcp_interface_rlc* pdcp = nullptr;
mac_interface_timers* mac_timers = nullptr; srslte::timers* timers = nullptr;
uint32_t lcid = 0; uint32_t lcid = 0;
rlc_config_t cfg = {}; rlc_config_t cfg = {};
std::string rb_name; std::string rb_name;

@ -38,7 +38,7 @@ public:
uint32_t lcid_, uint32_t lcid_,
srsue::pdcp_interface_rlc* pdcp_, srsue::pdcp_interface_rlc* pdcp_,
srsue::rrc_interface_rlc* rrc_, srsue::rrc_interface_rlc* rrc_,
srslte::mac_interface_timers* mac_timers_, srslte::timers* timers_,
uint32_t queue_len = 16); uint32_t queue_len = 16);
~rlc_tm(); ~rlc_tm();
bool configure(rlc_config_t cnfg); bool configure(rlc_config_t cnfg);

@ -47,7 +47,7 @@ public:
uint32_t lcid_, uint32_t lcid_,
srsue::pdcp_interface_rlc* pdcp_, srsue::pdcp_interface_rlc* pdcp_,
srsue::rrc_interface_rlc* rrc_, srsue::rrc_interface_rlc* rrc_,
mac_interface_timers* mac_timers_); srslte::timers* timers_);
~rlc_um(); ~rlc_um();
bool configure(rlc_config_t cnfg); bool configure(rlc_config_t cnfg);
void reestablish(); void reestablish();
@ -132,7 +132,7 @@ private:
uint32_t lcid_, uint32_t lcid_,
srsue::pdcp_interface_rlc* pdcp_, srsue::pdcp_interface_rlc* pdcp_,
srsue::rrc_interface_rlc* rrc_, srsue::rrc_interface_rlc* rrc_,
srslte::mac_interface_timers* mac_timers_); srslte::timers* timers_);
~rlc_um_rx(); ~rlc_um_rx();
void stop(); void stop();
void reestablish(); void reestablish();
@ -152,7 +152,7 @@ private:
byte_buffer_pool* pool = nullptr; byte_buffer_pool* pool = nullptr;
srslte::log* log = nullptr; srslte::log* log = nullptr;
mac_interface_timers* mac_timers = nullptr; srslte::timers* timers = nullptr;
std::string rb_name; std::string rb_name;
/**************************************************************************** /****************************************************************************

@ -53,12 +53,12 @@ rlc::~rlc()
void rlc::init(srsue::pdcp_interface_rlc* pdcp_, void rlc::init(srsue::pdcp_interface_rlc* pdcp_,
srsue::rrc_interface_rlc* rrc_, srsue::rrc_interface_rlc* rrc_,
mac_interface_timers* mac_timers_, srslte::timers* timers_,
uint32_t lcid_) uint32_t lcid_)
{ {
pdcp = pdcp_; pdcp = pdcp_;
rrc = rrc_; rrc = rrc_;
mac_timers = mac_timers_; timers = timers_;
default_lcid = lcid_; default_lcid = lcid_;
gettimeofday(&metrics_time[1], NULL); gettimeofday(&metrics_time[1], NULL);
@ -384,13 +384,13 @@ void rlc::add_bearer(uint32_t lcid, rlc_config_t cnfg)
if (not valid_lcid(lcid)) { if (not valid_lcid(lcid)) {
switch (cnfg.rlc_mode) { switch (cnfg.rlc_mode) {
case rlc_mode_t::tm: case rlc_mode_t::tm:
rlc_entity = new rlc_tm(rlc_log, lcid, pdcp, rrc, mac_timers); rlc_entity = new rlc_tm(rlc_log, lcid, pdcp, rrc, timers);
break; break;
case rlc_mode_t::am: case rlc_mode_t::am:
rlc_entity = new rlc_am(rlc_log, lcid, pdcp, rrc, mac_timers); rlc_entity = new rlc_am(rlc_log, lcid, pdcp, rrc, timers);
break; break;
case rlc_mode_t::um: case rlc_mode_t::um:
rlc_entity = new rlc_um(rlc_log, lcid, pdcp, rrc, mac_timers); rlc_entity = new rlc_um(rlc_log, lcid, pdcp, rrc, timers);
break; break;
default: default:
rlc_log->error("Cannot add RLC entity - invalid mode\n"); rlc_log->error("Cannot add RLC entity - invalid mode\n");
@ -428,10 +428,10 @@ unlock_and_exit:
void rlc::add_bearer_mrb(uint32_t lcid) void rlc::add_bearer_mrb(uint32_t lcid)
{ {
pthread_rwlock_wrlock(&rwlock); pthread_rwlock_wrlock(&rwlock);
rlc_common *rlc_entity = NULL; rlc_common* rlc_entity = NULL;
if (not valid_lcid_mrb(lcid)) { if (not valid_lcid_mrb(lcid)) {
rlc_entity = new rlc_um(rlc_log, lcid, pdcp, rrc, mac_timers); rlc_entity = new rlc_um(rlc_log, lcid, pdcp, rrc, timers);
// configure and add to array // configure and add to array
if (not rlc_entity->configure(rlc_config_t::mch_config())) { if (not rlc_entity->configure(rlc_config_t::mch_config())) {
rlc_log->error("Error configuring RLC entity\n."); rlc_log->error("Error configuring RLC entity\n.");

@ -36,21 +36,17 @@ rlc_am::rlc_am(srslte::log* log_,
uint32_t lcid_, uint32_t lcid_,
srsue::pdcp_interface_rlc* pdcp_, srsue::pdcp_interface_rlc* pdcp_,
srsue::rrc_interface_rlc* rrc_, srsue::rrc_interface_rlc* rrc_,
srslte::mac_interface_timers* mac_timers_) : srslte::timers* timers_) :
log(log_), log(log_),
rrc(rrc_), rrc(rrc_),
pdcp(pdcp_), pdcp(pdcp_),
mac_timers(mac_timers_), timers(timers_),
lcid(lcid_), lcid(lcid_),
tx(this), tx(this),
rx(this) rx(this)
{ {
} }
rlc_am::~rlc_am()
{
}
// Applies new configuration. Must be just reestablished or initiated // Applies new configuration. Must be just reestablished or initiated
bool rlc_am::configure(rlc_config_t cfg_) bool rlc_am::configure(rlc_config_t cfg_)
{ {
@ -170,11 +166,11 @@ rlc_am::rlc_am_tx::rlc_am_tx(rlc_am* parent_) :
log(parent_->log), log(parent_->log),
pool(byte_buffer_pool::get_instance()) pool(byte_buffer_pool::get_instance())
{ {
poll_retx_timer_id = parent->mac_timers->timer_get_unique_id(); poll_retx_timer_id = parent->timers->get_unique_id();
poll_retx_timer = parent->mac_timers->timer_get(poll_retx_timer_id); poll_retx_timer = parent->timers->get(poll_retx_timer_id);
status_prohibit_timer_id = parent->mac_timers->timer_get_unique_id(); status_prohibit_timer_id = parent->timers->get_unique_id();
status_prohibit_timer = parent->mac_timers->timer_get(status_prohibit_timer_id); status_prohibit_timer = parent->timers->get(status_prohibit_timer_id);
pthread_mutex_init(&mutex, NULL); pthread_mutex_init(&mutex, NULL);
} }
@ -182,10 +178,10 @@ rlc_am::rlc_am_tx::rlc_am_tx(rlc_am* parent_) :
rlc_am::rlc_am_tx::~rlc_am_tx() rlc_am::rlc_am_tx::~rlc_am_tx()
{ {
poll_retx_timer->stop(); poll_retx_timer->stop();
parent->mac_timers->timer_release_id(poll_retx_timer_id); parent->timers->release_id(poll_retx_timer_id);
status_prohibit_timer->stop(); status_prohibit_timer->stop();
parent->mac_timers->timer_release_id(status_prohibit_timer_id); parent->timers->release_id(status_prohibit_timer_id);
pthread_mutex_destroy(&mutex); pthread_mutex_destroy(&mutex);
} }
@ -225,11 +221,11 @@ void rlc_am::rlc_am_tx::stop()
tx_enabled = false; tx_enabled = false;
if (parent->mac_timers != NULL && poll_retx_timer != NULL) { if (parent->timers != NULL && poll_retx_timer != NULL) {
poll_retx_timer->stop(); poll_retx_timer->stop();
} }
if (parent->mac_timers != NULL && status_prohibit_timer != NULL) { if (parent->timers != NULL && status_prohibit_timer != NULL) {
status_prohibit_timer->stop(); status_prohibit_timer->stop();
} }
@ -1124,8 +1120,8 @@ rlc_am::rlc_am_rx::rlc_am_rx(rlc_am* parent_) :
pool(byte_buffer_pool::get_instance()), pool(byte_buffer_pool::get_instance()),
log(parent_->log) log(parent_->log)
{ {
reordering_timer_id = parent->mac_timers->timer_get_unique_id(); reordering_timer_id = parent->timers->get_unique_id();
reordering_timer = parent->mac_timers->timer_get(reordering_timer_id); reordering_timer = parent->timers->get(reordering_timer_id);
pthread_mutex_init(&mutex, NULL); pthread_mutex_init(&mutex, NULL);
} }
@ -1133,7 +1129,7 @@ rlc_am::rlc_am_rx::rlc_am_rx(rlc_am* parent_) :
rlc_am::rlc_am_rx::~rlc_am_rx() rlc_am::rlc_am_rx::~rlc_am_rx()
{ {
reordering_timer->stop(); reordering_timer->stop();
parent->mac_timers->timer_release_id(reordering_timer_id); parent->timers->release_id(reordering_timer_id);
pthread_mutex_destroy(&mutex); pthread_mutex_destroy(&mutex);
} }
@ -1166,7 +1162,7 @@ void rlc_am::rlc_am_rx::stop()
{ {
pthread_mutex_lock(&mutex); pthread_mutex_lock(&mutex);
if (parent->mac_timers != NULL && reordering_timer != NULL) { if (parent->timers != NULL && reordering_timer != NULL) {
reordering_timer->stop(); reordering_timer->stop();
} }

@ -27,7 +27,7 @@ rlc_tm::rlc_tm(srslte::log* log_,
uint32_t lcid_, uint32_t lcid_,
srsue::pdcp_interface_rlc* pdcp_, srsue::pdcp_interface_rlc* pdcp_,
srsue::rrc_interface_rlc* rrc_, srsue::rrc_interface_rlc* rrc_,
srslte::mac_interface_timers* mac_timers_, srslte::timers* timers_,
uint32_t queue_len_) : uint32_t queue_len_) :
ul_queue(queue_len_), ul_queue(queue_len_),
log(log_), log(log_),

@ -32,13 +32,13 @@ rlc_um::rlc_um(srslte::log* log_,
uint32_t lcid_, uint32_t lcid_,
srsue::pdcp_interface_rlc* pdcp_, srsue::pdcp_interface_rlc* pdcp_,
srsue::rrc_interface_rlc* rrc_, srsue::rrc_interface_rlc* rrc_,
mac_interface_timers* mac_timers_) : srslte::timers* timers_) :
lcid(lcid_), lcid(lcid_),
pool(byte_buffer_pool::get_instance()), pool(byte_buffer_pool::get_instance()),
rrc(rrc_), rrc(rrc_),
log(log_), log(log_),
tx(log_), tx(log_),
rx(log_, lcid_, pdcp_, rrc_, mac_timers_) rx(log_, lcid_, pdcp_, rrc_, timers_)
{ {
} }
@ -483,30 +483,28 @@ rlc_um::rlc_um_rx::rlc_um_rx(srslte::log* log_,
uint32_t lcid_, uint32_t lcid_,
srsue::pdcp_interface_rlc* pdcp_, srsue::pdcp_interface_rlc* pdcp_,
srsue::rrc_interface_rlc* rrc_, srsue::rrc_interface_rlc* rrc_,
srslte::mac_interface_timers* mac_timers_) : srslte::timers* timers_) :
pool(byte_buffer_pool::get_instance()), pool(byte_buffer_pool::get_instance()),
log(log_), log(log_),
pdcp(pdcp_), pdcp(pdcp_),
rrc(rrc_), rrc(rrc_),
mac_timers(mac_timers_), timers(timers_),
lcid(lcid_) lcid(lcid_)
{ {
reordering_timer_id = mac_timers->timer_get_unique_id(); reordering_timer_id = timers->get_unique_id();
reordering_timer = mac_timers->timer_get(reordering_timer_id); reordering_timer = timers->get(reordering_timer_id);
pthread_mutex_init(&mutex, NULL); pthread_mutex_init(&mutex, NULL);
} }
rlc_um::rlc_um_rx::~rlc_um_rx() rlc_um::rlc_um_rx::~rlc_um_rx()
{ {
reordering_timer->stop(); reordering_timer->stop();
mac_timers->timer_release_id(reordering_timer_id); timers->release_id(reordering_timer_id);
pthread_mutex_destroy(&mutex); pthread_mutex_destroy(&mutex);
} }
void rlc_um::rlc_um_rx::reestablish() void rlc_um::rlc_um_rx::reestablish()
{ {
// try to reassemble any SDUs if possible // try to reassemble any SDUs if possible

@ -34,30 +34,7 @@ using namespace srsue;
using namespace srslte; using namespace srslte;
using namespace asn1::rrc; using namespace asn1::rrc;
class mac_dummy_timers class rlc_am_tester : public pdcp_interface_rlc, public rrc_interface_rlc
:public srslte::mac_interface_timers
{
public:
mac_dummy_timers() : timers(8) {}
srslte::timers::timer* timer_get(uint32_t timer_id) {
return timers.get(timer_id);
}
void timer_release_id(uint32_t timer_id) {
timers.release_id(timer_id);
}
uint32_t timer_get_unique_id() {
return timers.get_unique_id();
}
void step_all() {
timers.step_all();
}
private:
srslte::timers timers;
};
class rlc_am_tester
:public pdcp_interface_rlc
,public rrc_interface_rlc
{ {
public: public:
rlc_am_tester(rlc_pcap *pcap_ = NULL) rlc_am_tester(rlc_pcap *pcap_ = NULL)
@ -163,7 +140,7 @@ bool basic_test()
log2.set_hex_limit(-1); log2.set_hex_limit(-1);
rlc_am_tester tester; rlc_am_tester tester;
mac_dummy_timers timers; timers timers(8);
byte_buffer_t pdu_bufs[NBUFS]; byte_buffer_t pdu_bufs[NBUFS];
rlc_am rlc1(&log1, 1, &tester, &tester, &timers); rlc_am rlc1(&log1, 1, &tester, &tester, &timers);
@ -223,7 +200,7 @@ bool concat_test()
log1.set_hex_limit(-1); log1.set_hex_limit(-1);
log2.set_hex_limit(-1); log2.set_hex_limit(-1);
rlc_am_tester tester; rlc_am_tester tester;
mac_dummy_timers timers; srslte::timers timers(8);
rlc_am rlc1(&log1, 1, &tester, &tester, &timers); rlc_am rlc1(&log1, 1, &tester, &tester, &timers);
rlc_am rlc2(&log2, 1, &tester, &tester, &timers); rlc_am rlc2(&log2, 1, &tester, &tester, &timers);
@ -288,7 +265,7 @@ bool segment_test(bool in_seq_rx)
log1.set_hex_limit(-1); log1.set_hex_limit(-1);
log2.set_hex_limit(-1); log2.set_hex_limit(-1);
rlc_am_tester tester; rlc_am_tester tester;
mac_dummy_timers timers; srslte::timers timers(8);
int len = 0; int len = 0;
rlc_am rlc1(&log1, 1, &tester, &tester, &timers); rlc_am rlc1(&log1, 1, &tester, &tester, &timers);
@ -382,7 +359,7 @@ bool retx_test()
log1.set_hex_limit(-1); log1.set_hex_limit(-1);
log2.set_hex_limit(-1); log2.set_hex_limit(-1);
rlc_am_tester tester; rlc_am_tester tester;
mac_dummy_timers timers; timers timers(8);
int len = 0; int len = 0;
rlc_am rlc1(&log1, 1, &tester, &tester, &timers); rlc_am rlc1(&log1, 1, &tester, &tester, &timers);
@ -476,7 +453,7 @@ bool resegment_test_1()
log1.set_hex_limit(-1); log1.set_hex_limit(-1);
log2.set_hex_limit(-1); log2.set_hex_limit(-1);
rlc_am_tester tester; rlc_am_tester tester;
mac_dummy_timers timers; timers timers(8);
int len = 0; int len = 0;
rlc_am rlc1(&log1, 1, &tester, &tester, &timers); rlc_am rlc1(&log1, 1, &tester, &tester, &timers);
@ -582,7 +559,7 @@ bool resegment_test_2()
log1.set_hex_limit(-1); log1.set_hex_limit(-1);
log2.set_hex_limit(-1); log2.set_hex_limit(-1);
rlc_am_tester tester; rlc_am_tester tester;
mac_dummy_timers timers; timers timers(8);
int len = 0; int len = 0;
rlc_am rlc1(&log1, 1, &tester, &tester, &timers); rlc_am rlc1(&log1, 1, &tester, &tester, &timers);
@ -685,7 +662,7 @@ bool resegment_test_3()
log1.set_hex_limit(-1); log1.set_hex_limit(-1);
log2.set_hex_limit(-1); log2.set_hex_limit(-1);
rlc_am_tester tester; rlc_am_tester tester;
mac_dummy_timers timers; srslte::timers timers(8);
rlc_am rlc1(&log1, 1, &tester, &tester, &timers); rlc_am rlc1(&log1, 1, &tester, &tester, &timers);
rlc_am rlc2(&log2, 1, &tester, &tester, &timers); rlc_am rlc2(&log2, 1, &tester, &tester, &timers);
@ -782,7 +759,7 @@ bool resegment_test_4()
log1.set_hex_limit(-1); log1.set_hex_limit(-1);
log2.set_hex_limit(-1); log2.set_hex_limit(-1);
rlc_am_tester tester; rlc_am_tester tester;
mac_dummy_timers timers; srslte::timers timers(8);
rlc_am rlc1(&log1, 1, &tester, &tester, &timers); rlc_am rlc1(&log1, 1, &tester, &tester, &timers);
rlc_am rlc2(&log2, 1, &tester, &tester, &timers); rlc_am rlc2(&log2, 1, &tester, &tester, &timers);
@ -881,7 +858,7 @@ bool resegment_test_5()
log1.set_hex_limit(-1); log1.set_hex_limit(-1);
log2.set_hex_limit(-1); log2.set_hex_limit(-1);
rlc_am_tester tester; rlc_am_tester tester;
mac_dummy_timers timers; srslte::timers timers(8);
rlc_am rlc1(&log1, 1, &tester, &tester, &timers); rlc_am rlc1(&log1, 1, &tester, &tester, &timers);
rlc_am rlc2(&log2, 1, &tester, &tester, &timers); rlc_am rlc2(&log2, 1, &tester, &tester, &timers);
@ -980,7 +957,7 @@ bool resegment_test_6()
log1.set_hex_limit(-1); log1.set_hex_limit(-1);
log2.set_hex_limit(-1); log2.set_hex_limit(-1);
rlc_am_tester tester; rlc_am_tester tester;
mac_dummy_timers timers; srslte::timers timers(8);
int len = 0; int len = 0;
rlc_am rlc1(&log1, 1, &tester, &tester, &timers); rlc_am rlc1(&log1, 1, &tester, &tester, &timers);
@ -1117,7 +1094,7 @@ bool resegment_test_7()
#else #else
rlc_am_tester tester(NULL); rlc_am_tester tester(NULL);
#endif #endif
mac_dummy_timers timers; srslte::timers timers(8);
rlc_am rlc1(&log1, 1, &tester, &tester, &timers); rlc_am rlc1(&log1, 1, &tester, &tester, &timers);
rlc_am rlc2(&log2, 1, &tester, &tester, &timers); rlc_am rlc2(&log2, 1, &tester, &tester, &timers);
@ -1290,7 +1267,7 @@ bool resegment_test_8()
#else #else
rlc_am_tester tester(NULL); rlc_am_tester tester(NULL);
#endif #endif
mac_dummy_timers timers; srslte::timers timers(8);
rlc_am rlc1(&log1, 1, &tester, &tester, &timers); rlc_am rlc1(&log1, 1, &tester, &tester, &timers);
rlc_am rlc2(&log2, 1, &tester, &tester, &timers); rlc_am rlc2(&log2, 1, &tester, &tester, &timers);
@ -1434,7 +1411,7 @@ bool reset_test()
log1.set_level(srslte::LOG_LEVEL_DEBUG); log1.set_level(srslte::LOG_LEVEL_DEBUG);
log1.set_hex_limit(-1); log1.set_hex_limit(-1);
rlc_am_tester tester; rlc_am_tester tester;
mac_dummy_timers timers; srslte::timers timers(8);
int len = 0; int len = 0;
rlc_am rlc1(&log1, 1, &tester, &tester, &timers); rlc_am rlc1(&log1, 1, &tester, &tester, &timers);
@ -1479,7 +1456,7 @@ bool resume_test()
log1.set_level(srslte::LOG_LEVEL_DEBUG); log1.set_level(srslte::LOG_LEVEL_DEBUG);
log1.set_hex_limit(-1); log1.set_hex_limit(-1);
rlc_am_tester tester; rlc_am_tester tester;
mac_dummy_timers timers; srslte::timers timers(8);
int len = 0; int len = 0;
rlc_am rlc1(&log1, 1, &tester, &tester, &timers); rlc_am rlc1(&log1, 1, &tester, &tester, &timers);
@ -1524,7 +1501,7 @@ bool stop_test()
log1.set_level(srslte::LOG_LEVEL_DEBUG); log1.set_level(srslte::LOG_LEVEL_DEBUG);
log1.set_hex_limit(-1); log1.set_hex_limit(-1);
rlc_am_tester tester; rlc_am_tester tester;
mac_dummy_timers timers; srslte::timers timers(8);
rlc_am rlc1(&log1, 1, &tester, &tester, &timers); rlc_am rlc1(&log1, 1, &tester, &tester, &timers);
@ -1556,7 +1533,7 @@ bool status_pdu_test()
log1.set_hex_limit(-1); log1.set_hex_limit(-1);
log2.set_hex_limit(-1); log2.set_hex_limit(-1);
rlc_am_tester tester; rlc_am_tester tester;
mac_dummy_timers timers; srslte::timers timers(8);
int len = 0; int len = 0;
rlc_am rlc1(&log1, 1, &tester, &tester, &timers); rlc_am rlc1(&log1, 1, &tester, &tester, &timers);

@ -37,18 +37,6 @@
using namespace srslte; using namespace srslte;
using namespace asn1::rrc; using namespace asn1::rrc;
class mac_dummy_timers : public srslte::mac_interface_timers
{
public:
srslte::timers::timer* timer_get(uint32_t timer_id) { return &t; }
uint32_t timer_get_unique_id() { return 0; }
void step() { t.step(); }
void timer_release_id(uint32_t timer_id) {}
private:
srslte::timers::timer t;
};
class rlc_tester : public srsue::pdcp_interface_rlc, public srsue::rrc_interface_rlc class rlc_tester : public srsue::pdcp_interface_rlc, public srsue::rrc_interface_rlc
{ {
public: public:
@ -92,7 +80,7 @@ int basic_test()
log1.set_hex_limit(-1); log1.set_hex_limit(-1);
log2.set_hex_limit(-1); log2.set_hex_limit(-1);
rlc_tester tester; rlc_tester tester;
mac_dummy_timers timers; srslte::timers timers(1);
int len = 0; int len = 0;

@ -111,21 +111,6 @@ void parse_args(stress_test_args_t *args, int argc, char *argv[]) {
} }
} }
// To provide timer services to RLC
class stack_dummy : public srslte::mac_interface_timers
{
public:
stack_dummy() : timers(8) {}
srslte::timers::timer* timer_get(uint32_t timer_id) { return timers.get(timer_id); }
uint32_t timer_get_unique_id() { return timers.get_unique_id(); }
void timer_release_id(uint32_t timer_id) { timers.release_id(timer_id); }
void step_timer() { timers.step_all(); }
private:
srslte::timers timers;
};
class mac_dummy : public thread class mac_dummy : public thread
{ {
public: public:
@ -133,7 +118,7 @@ public:
rlc_interface_mac* rlc2_, rlc_interface_mac* rlc2_,
stress_test_args_t args_, stress_test_args_t args_,
uint32_t lcid_, uint32_t lcid_,
stack_dummy* stack_, timers* timers_,
rlc_pcap* pcap_ = NULL) : rlc_pcap* pcap_ = NULL) :
run_enable(true), run_enable(true),
rlc1(rlc1_), rlc1(rlc1_),
@ -141,7 +126,7 @@ public:
args(args_), args(args_),
pcap(pcap_), pcap(pcap_),
lcid(lcid_), lcid(lcid_),
stack(stack_), timers(timers_),
log("MAC "), log("MAC "),
thread("MAC_DUMMY"), thread("MAC_DUMMY"),
real_dist(0.0, 1.0) real_dist(0.0, 1.0)
@ -207,7 +192,7 @@ private:
run_tti(rlc2, rlc1, false); run_tti(rlc2, rlc1, false);
// step timer // step timer
stack->step_timer(); timers->step_all();
} }
} }
@ -216,10 +201,10 @@ private:
bool run_enable; bool run_enable;
stress_test_args_t args; stress_test_args_t args;
rlc_pcap *pcap; rlc_pcap* pcap;
uint32_t lcid; uint32_t lcid;
srslte::log_filter log; srslte::log_filter log;
stack_dummy* stack = nullptr; srslte::timers* timers = nullptr;
std::mt19937 mt19937; std::mt19937 mt19937;
std::uniform_real_distribution<float> real_dist; std::uniform_real_distribution<float> real_dist;
@ -354,17 +339,17 @@ void stress_test(stress_test_args_t args)
exit(-1); exit(-1);
} }
stack_dummy stack; srslte::timers timers(8);
rlc rlc1(&log1); rlc rlc1(&log1);
rlc rlc2(&log2); rlc rlc2(&log2);
rlc_tester tester1(&rlc1, "tester1", args, lcid); rlc_tester tester1(&rlc1, "tester1", args, lcid);
rlc_tester tester2(&rlc2, "tester2", args, lcid); rlc_tester tester2(&rlc2, "tester2", args, lcid);
mac_dummy mac(&rlc1, &rlc2, args, lcid, &stack, &pcap); mac_dummy mac(&rlc1, &rlc2, args, lcid, &timers, &pcap);
rlc1.init(&tester1, &tester1, &stack, 0); rlc1.init(&tester1, &tester1, &timers, 0);
rlc2.init(&tester2, &tester2, &stack, 0); rlc2.init(&tester2, &tester2, &timers, 0);
// only add AM and UM bearers // only add AM and UM bearers
if (args.mode != "TM") { if (args.mode != "TM") {

@ -38,27 +38,7 @@ using namespace srslte;
using namespace srsue; using namespace srsue;
using namespace asn1::rrc; using namespace asn1::rrc;
class mac_dummy_timers class rlc_um_tester : public pdcp_interface_rlc, public rrc_interface_rlc
:public srslte::mac_interface_timers
{
public:
srslte::timers::timer* timer_get(uint32_t timer_id)
{
return &t;
}
uint32_t timer_get_unique_id(){return 0;}
void step()
{
t.step();
}
void timer_release_id(uint32_t timer_id) {}
private:
srslte::timers::timer t;
};
class rlc_um_tester
:public pdcp_interface_rlc
,public rrc_interface_rlc
{ {
public: public:
rlc_um_tester(){ rlc_um_tester(){
@ -104,7 +84,7 @@ int basic_test()
log1.set_hex_limit(-1); log1.set_hex_limit(-1);
log2.set_hex_limit(-1); log2.set_hex_limit(-1);
rlc_um_tester tester; rlc_um_tester tester;
mac_dummy_timers timers; srslte::timers timers(16);
int len = 0; int len = 0;
rlc_um rlc1(&log1, 3, &tester, &tester, &timers); rlc_um rlc1(&log1, 3, &tester, &tester, &timers);
@ -174,7 +154,7 @@ int loss_test()
log1.set_hex_limit(-1); log1.set_hex_limit(-1);
log2.set_hex_limit(-1); log2.set_hex_limit(-1);
rlc_um_tester tester; rlc_um_tester tester;
mac_dummy_timers timers; srslte::timers timers(16);
int len = 0; int len = 0;
rlc_um rlc1(&log1, 3, &tester, &tester, &timers); rlc_um rlc1(&log1, 3, &tester, &tester, &timers);
@ -218,8 +198,8 @@ int loss_test()
} }
// Step the reordering timer until expiry // Step the reordering timer until expiry
while(!timers.timer_get(1)->is_expired()) while (!timers.get(1)->is_expired())
timers.timer_get(1)->step(); timers.get(1)->step();
TESTASSERT(NBUFS - 1 == tester.n_sdus); TESTASSERT(NBUFS - 1 == tester.n_sdus);
@ -235,7 +215,7 @@ int basic_mbsfn_test()
log1.set_hex_limit(-1); log1.set_hex_limit(-1);
log2.set_hex_limit(-1); log2.set_hex_limit(-1);
rlc_um_tester tester; rlc_um_tester tester;
mac_dummy_timers timers; srslte::timers timers(16);
int len = 0; int len = 0;
rlc_um rlc1(&log1, 3, &tester, &tester, &timers); rlc_um rlc1(&log1, 3, &tester, &tester, &timers);
@ -307,7 +287,7 @@ int reassmble_test()
log1.set_hex_limit(-1); log1.set_hex_limit(-1);
log2.set_hex_limit(-1); log2.set_hex_limit(-1);
rlc_um_tester tester; rlc_um_tester tester;
mac_dummy_timers timers; srslte::timers timers(16);
int len = 0; int len = 0;
rlc_um rlc1(&log1, 3, &tester, &tester, &timers); rlc_um rlc1(&log1, 3, &tester, &tester, &timers);
@ -416,7 +396,7 @@ int reassmble_test2()
log1.set_hex_limit(-1); log1.set_hex_limit(-1);
log2.set_hex_limit(-1); log2.set_hex_limit(-1);
rlc_um_tester tester; rlc_um_tester tester;
mac_dummy_timers timers; srslte::timers timers(16);
int len = 0; int len = 0;
rlc_um rlc1(&log1, 3, &tester, &tester, &timers); rlc_um rlc1(&log1, 3, &tester, &tester, &timers);

@ -86,7 +86,11 @@ public:
// Radio-Link status // Radio-Link status
void rl_failure(uint16_t rnti) final { mac.rl_failure(rnti); } void rl_failure(uint16_t rnti) final { mac.rl_failure(rnti); }
void rl_ok(uint16_t rnti) final { mac.rl_ok(rnti); } void rl_ok(uint16_t rnti) final { mac.rl_ok(rnti); }
void tti_clock() final { mac.tti_clock(); } void tti_clock() final
{
timers.step_all();
mac.tti_clock();
}
private: private:
stack_args_t args = {}; stack_args_t args = {};
@ -102,6 +106,7 @@ private:
srsenb::s1ap s1ap; srsenb::s1ap s1ap;
srslte::logger* logger = nullptr; srslte::logger* logger = nullptr;
srslte::timers timers;
// Radio and PHY log are in enb.cc // Radio and PHY log are in enb.cc
srslte::log_filter mac_log; srslte::log_filter mac_log;

@ -41,9 +41,11 @@ class rlc : public rlc_interface_mac,
public rlc_interface_pdcp public rlc_interface_pdcp
{ {
public: public:
void init(pdcp_interface_rlc* pdcp_,
void init(pdcp_interface_rlc *pdcp_, rrc_interface_rlc *rrc_, mac_interface_rlc *mac_, rrc_interface_rlc* rrc_,
srslte::mac_interface_timers *mac_timers_, srslte::log *log_h); mac_interface_rlc* mac_,
srslte::timers* timers_,
srslte::log* log_h);
void stop(); void stop();
// rlc_interface_rrc // rlc_interface_rrc
@ -90,12 +92,12 @@ private:
mac_interface_rlc *mac; mac_interface_rlc *mac;
pdcp_interface_rlc *pdcp; pdcp_interface_rlc *pdcp;
rrc_interface_rlc *rrc; rrc_interface_rlc* rrc;
srslte::log *log_h; srslte::log* log_h;
srslte::byte_buffer_pool *pool; srslte::byte_buffer_pool* pool;
srslte::mac_interface_timers *mac_timers; srslte::timers* timers;
}; };
} } // namespace srsenb
#endif // SRSENB_RLC_H #endif // SRSENB_RLC_H

@ -28,7 +28,7 @@ using namespace srslte;
namespace srsenb { namespace srsenb {
enb_stack_lte::enb_stack_lte(srslte::logger* logger_) : logger(logger_), pdcp(&pdcp_log) {} enb_stack_lte::enb_stack_lte(srslte::logger* logger_) : logger(logger_), pdcp(&pdcp_log), timers(128) {}
enb_stack_lte::~enb_stack_lte() enb_stack_lte::~enb_stack_lte()
{ {
@ -115,7 +115,7 @@ int enb_stack_lte::init(const stack_args_t& args_, const rrc_cfg_t& rrc_cfg_)
// Init all layers // Init all layers
mac.init(args.mac, &cell_cfg, phy, &rlc, &rrc, &mac_log); mac.init(args.mac, &cell_cfg, phy, &rlc, &rrc, &mac_log);
rlc.init(&pdcp, &rrc, &mac, &mac, &rlc_log); rlc.init(&pdcp, &rrc, &mac, &timers, &rlc_log);
pdcp.init(&rlc, &rrc, &gtpu); pdcp.init(&rlc, &rrc, &gtpu);
rrc.init(&rrc_cfg, phy, &mac, &rlc, &pdcp, &s1ap, &gtpu, &rrc_log); rrc.init(&rrc_cfg, phy, &mac, &rlc, &pdcp, &s1ap, &gtpu, &rrc_log);
s1ap.init(args.s1ap, &rrc, &s1ap_log); s1ap.init(args.s1ap, &rrc, &s1ap_log);

@ -24,14 +24,17 @@
namespace srsenb { namespace srsenb {
void rlc::init(pdcp_interface_rlc* pdcp_, rrc_interface_rlc* rrc_, mac_interface_rlc *mac_, void rlc::init(pdcp_interface_rlc* pdcp_,
srslte::mac_interface_timers *mac_timers_, srslte::log* log_h_) rrc_interface_rlc* rrc_,
mac_interface_rlc* mac_,
srslte::timers* timers_,
srslte::log* log_h_)
{ {
pdcp = pdcp_; pdcp = pdcp_;
rrc = rrc_, rrc = rrc_;
log_h = log_h_; log_h = log_h_;
mac = mac_; mac = mac_;
mac_timers = mac_timers_; timers = timers_;
pool = srslte::byte_buffer_pool::get_instance(); pool = srslte::byte_buffer_pool::get_instance();
@ -54,7 +57,7 @@ void rlc::add_user(uint16_t rnti)
pthread_rwlock_rdlock(&rwlock); pthread_rwlock_rdlock(&rwlock);
if (users.count(rnti) == 0) { if (users.count(rnti) == 0) {
std::unique_ptr<srslte::rlc> obj(new srslte::rlc(log_h)); std::unique_ptr<srslte::rlc> obj(new srslte::rlc(log_h));
obj->init(&users[rnti], &users[rnti], mac_timers, RB_ID_SRB0); obj->init(&users[rnti], &users[rnti], timers, RB_ID_SRB0);
users[rnti].rnti = rnti; users[rnti].rnti = rnti;
users[rnti].pdcp = pdcp; users[rnti].pdcp = pdcp;
users[rnti].rrc = rrc; users[rnti].rrc = rrc;

@ -81,7 +81,7 @@ private:
fd_set m_set; fd_set m_set;
// Timer map // Timer map
std::vector<mme_timer_t> m_timers; std::vector<mme_timer_t> timers;
// Timer Methods // Timer Methods
void handle_timer_expire(int timer_fd); void handle_timer_expire(int timer_fd);

@ -132,7 +132,7 @@ void mme::run_thread()
FD_SET(s11, &m_set); FD_SET(s11, &m_set);
// Add timers to select // Add timers to select
for (std::vector<mme_timer_t>::iterator it = m_timers.begin(); it != m_timers.end(); ++it) { for (std::vector<mme_timer_t>::iterator it = timers.begin(); it != timers.end(); ++it) {
FD_SET(it->fd, &m_set); FD_SET(it->fd, &m_set);
max_fd = std::max(max_fd, it->fd); max_fd = std::max(max_fd, it->fd);
m_s1ap_log->debug("Adding Timer fd %d to fd_set\n", it->fd); m_s1ap_log->debug("Adding Timer fd %d to fd_set\n", it->fd);
@ -174,14 +174,14 @@ void mme::run_thread()
m_mme_gtpc->handle_s11_pdu(pdu); m_mme_gtpc->handle_s11_pdu(pdu);
} }
// Handle NAS Timers // Handle NAS Timers
for (std::vector<mme_timer_t>::iterator it = m_timers.begin(); it != m_timers.end();) { for (std::vector<mme_timer_t>::iterator it = timers.begin(); it != timers.end();) {
if (FD_ISSET(it->fd, &m_set)) { if (FD_ISSET(it->fd, &m_set)) {
m_s1ap_log->info("Timer expired\n"); m_s1ap_log->info("Timer expired\n");
uint64_t exp; uint64_t exp;
rd_sz = read(it->fd, &exp, sizeof(uint64_t)); rd_sz = read(it->fd, &exp, sizeof(uint64_t));
m_s1ap->expire_nas_timer(it->type, it->imsi); m_s1ap->expire_nas_timer(it->type, it->imsi);
close(it->fd); close(it->fd);
m_timers.erase(it); timers.erase(it);
} else { } else {
++it; ++it;
} }
@ -205,14 +205,14 @@ bool mme::add_nas_timer(int timer_fd, nas_timer_type type, uint64_t imsi)
timer.type = type; timer.type = type;
timer.imsi = imsi; timer.imsi = imsi;
m_timers.push_back(timer); timers.push_back(timer);
return true; return true;
} }
bool mme::is_nas_timer_running(nas_timer_type type, uint64_t imsi) bool mme::is_nas_timer_running(nas_timer_type type, uint64_t imsi)
{ {
std::vector<mme_timer_t>::iterator it; std::vector<mme_timer_t>::iterator it;
for (it = m_timers.begin(); it != m_timers.end(); ++it) { for (it = timers.begin(); it != timers.end(); ++it) {
if (it->type == type && it->imsi == imsi) { if (it->type == type && it->imsi == imsi) {
return true; // found timer return true; // found timer
} }
@ -223,12 +223,12 @@ bool mme::is_nas_timer_running(nas_timer_type type, uint64_t imsi)
bool mme::remove_nas_timer(nas_timer_type type, uint64_t imsi) bool mme::remove_nas_timer(nas_timer_type type, uint64_t imsi)
{ {
std::vector<mme_timer_t>::iterator it; std::vector<mme_timer_t>::iterator it;
for (it = m_timers.begin(); it != m_timers.end(); ++it) { for (it = timers.begin(); it != timers.end(); ++it) {
if (it->type == type && it->imsi == imsi) { if (it->type == type && it->imsi == imsi) {
break; // found timer to remove break; // found timer to remove
} }
} }
if (it == m_timers.end()) { if (it == timers.end()) {
m_s1ap_log->warning("Could not find timer to remove. IMSI %" PRIu64 ", Type %d\n", imsi, type); m_s1ap_log->warning("Could not find timer to remove. IMSI %" PRIu64 ", Type %d\n", imsi, type);
return false; return false;
} }
@ -237,7 +237,7 @@ bool mme::remove_nas_timer(nas_timer_type type, uint64_t imsi)
m_s1ap_log->debug("Removing NAS timer from MME. IMSI %" PRIu64 ", Type %d, Fd: %d\n", imsi, type, it->fd); m_s1ap_log->debug("Removing NAS timer from MME. IMSI %" PRIu64 ", Type %d, Fd: %d\n", imsi, type, it->fd);
FD_CLR(it->fd, &m_set); FD_CLR(it->fd, &m_set);
close(it->fd); close(it->fd);
m_timers.erase(it); timers.erase(it);
return true; return true;
} }

@ -51,7 +51,7 @@ class mac : public mac_interface_phy_lte,
public: public:
mac(srslte::log* log_); mac(srslte::log* log_);
~mac(); ~mac();
bool init(phy_interface_mac_lte* phy, rlc_interface_mac* rlc, rrc_interface_mac* rrc); bool init(phy_interface_mac_lte* phy, rlc_interface_mac* rlc, rrc_interface_mac* rrc, srslte::timers* timers_);
void stop(); void stop();
void get_metrics(mac_metrics_t m[SRSLTE_MAX_CARRIERS]); void get_metrics(mac_metrics_t m[SRSLTE_MAX_CARRIERS]);
@ -163,7 +163,7 @@ private:
uint32_t timer_alignment = 0; uint32_t timer_alignment = 0;
void setup_timers(int time_alignment_timer); void setup_timers(int time_alignment_timer);
void timer_alignment_expire(); void timer_alignment_expire();
srslte::timers timers; srslte::timers* timers = nullptr;
// pointer to MAC PCAP object // pointer to MAC PCAP object
srslte::mac_pcap* pcap = nullptr; srslte::mac_pcap* pcap = nullptr;

@ -296,7 +296,7 @@ public:
nas_interface_rrc* nas_, nas_interface_rrc* nas_,
usim_interface_rrc* usim_, usim_interface_rrc* usim_,
gw_interface_rrc* gw_, gw_interface_rrc* gw_,
srslte::mac_interface_timers* mac_timers_, srslte::timers* timers_,
const rrc_args_t& args_); const rrc_args_t& args_);
void stop(); void stop();
@ -407,7 +407,7 @@ private:
std::map<uint32_t, asn1::rrc::drb_to_add_mod_s> drbs; std::map<uint32_t, asn1::rrc::drb_to_add_mod_s> drbs;
// RRC constants and timers // RRC constants and timers
srslte::mac_interface_timers* mac_timers = nullptr; srslte::timers* timers = nullptr;
uint32_t n310_cnt, N310 = 0; uint32_t n310_cnt, N310 = 0;
uint32_t n311_cnt, N311 = 0; uint32_t n311_cnt, N311 = 0;
uint32_t t300, t301, t302, t310, t311, t304 = 0; uint32_t t300, t301, t302, t310, t311, t304 = 0;
@ -526,7 +526,7 @@ private:
rrc* parent = nullptr; rrc* parent = nullptr;
srslte::log* log_h = nullptr; srslte::log* log_h = nullptr;
phy_interface_rrc_lte* phy = nullptr; phy_interface_rrc_lte* phy = nullptr;
srslte::mac_interface_timers* mac_timers = nullptr; srslte::timers* timers = nullptr;
uint32_t filter_k_rsrp, filter_k_rsrq = 0; uint32_t filter_k_rsrp, filter_k_rsrq = 0;
float filter_a[NOF_MEASUREMENTS] = {}; float filter_a[NOF_MEASUREMENTS] = {};

@ -121,6 +121,9 @@ private:
bool running; bool running;
srsue::stack_args_t args; srsue::stack_args_t args;
// timers
srslte::timers timers;
// UE stack logging // UE stack logging
srslte::logger* logger = nullptr; srslte::logger* logger = nullptr;
srslte::log_filter mac_log; srslte::log_filter mac_log;

@ -38,7 +38,6 @@ using namespace asn1::rrc;
namespace srsue { namespace srsue {
mac::mac(srslte::log* log_) : mac::mac(srslte::log* log_) :
timers(64),
pdu_process_thread(&demux_unit), pdu_process_thread(&demux_unit),
mch_msg(10, log_), mch_msg(10, log_),
mux_unit(log_), mux_unit(log_),
@ -72,26 +71,27 @@ mac::~mac()
srslte_softbuffer_rx_free(&mch_softbuffer); srslte_softbuffer_rx_free(&mch_softbuffer);
} }
bool mac::init(phy_interface_mac_lte* phy, rlc_interface_mac* rlc, rrc_interface_mac* rrc) bool mac::init(phy_interface_mac_lte* phy, rlc_interface_mac* rlc, rrc_interface_mac* rrc, srslte::timers* timers_)
{ {
phy_h = phy; phy_h = phy;
rlc_h = rlc; rlc_h = rlc;
rrc_h = rrc; rrc_h = rrc;
timers = timers_;
timer_alignment = timers.get_unique_id(); timer_alignment = timers->get_unique_id();
uint32_t contention_resolution_timer = timers.get_unique_id(); uint32_t contention_resolution_timer = timers->get_unique_id();
bsr_procedure.init(rlc_h, log_h, &timers); bsr_procedure.init(rlc_h, log_h, timers);
phr_procedure.init(phy_h, log_h, &timers); phr_procedure.init(phy_h, log_h, timers);
mux_unit.init(rlc_h, &bsr_procedure, &phr_procedure); mux_unit.init(rlc_h, &bsr_procedure, &phr_procedure);
demux_unit.init(phy_h, rlc_h, this, timers.get(timer_alignment)); demux_unit.init(phy_h, rlc_h, this, timers->get(timer_alignment));
ra_procedure.init( ra_procedure.init(
phy_h, rrc, log_h, &uernti, timers.get(timer_alignment), timers.get(contention_resolution_timer), &mux_unit); phy_h, rrc, log_h, &uernti, timers->get(timer_alignment), timers->get(contention_resolution_timer), &mux_unit);
sr_procedure.init(phy_h, rrc, log_h); sr_procedure.init(phy_h, rrc, log_h);
// Create UL/DL unique HARQ pointers // Create UL/DL unique HARQ pointers
ul_harq.at(0)->init(log_h, &uernti, &ra_procedure, &mux_unit); ul_harq.at(0)->init(log_h, &uernti, &ra_procedure, &mux_unit);
dl_harq.at(0)->init(log_h, &uernti, timers.get(timer_alignment), &demux_unit); dl_harq.at(0)->init(log_h, &uernti, timers->get(timer_alignment), &demux_unit);
reset(); reset();
@ -135,7 +135,7 @@ void mac::reconfiguration(const uint32_t& cc_idx, const bool& enable)
} }
while (dl_harq.size() < cc_idx + 1) { while (dl_harq.size() < cc_idx + 1) {
auto dl = dl_harq_entity_ptr(new dl_harq_entity()); auto dl = dl_harq_entity_ptr(new dl_harq_entity());
dl->init(log_h, &uernti, timers.get(timer_alignment), &demux_unit); dl->init(log_h, &uernti, timers->get(timer_alignment), &demux_unit);
if (pcap) { if (pcap) {
dl->start_pcap(pcap); dl->start_pcap(pcap);
@ -162,7 +162,7 @@ void mac::reset()
Info("Resetting MAC\n"); Info("Resetting MAC\n");
timers.get(timer_alignment)->stop(); timers->get(timer_alignment)->stop();
timer_alignment_expire(); timer_alignment_expire();
@ -233,7 +233,6 @@ void mac::run_tti(const uint32_t tti)
ra_window_start = -1; ra_window_start = -1;
ra_window_length = -1; ra_window_length = -1;
ra_procedure.update_rar_window(&ra_window_start, &ra_window_length); ra_procedure.update_rar_window(&ra_window_start, &ra_window_length);
timers.step_all();
} }
void mac::bcch_start_rx(int si_window_start, int si_window_length) void mac::bcch_start_rx(int si_window_start, int si_window_length)
@ -509,12 +508,12 @@ void mac::new_mch_dl(srslte_pdsch_grant_t phy_grant, tb_action_dl_t* action)
void mac::setup_timers(int time_alignment_timer) void mac::setup_timers(int time_alignment_timer)
{ {
// stop currently running time alignment timer // stop currently running time alignment timer
if (timers.get(timer_alignment)->is_running()) { if (timers->get(timer_alignment)->is_running()) {
timers.get(timer_alignment)->stop(); timers->get(timer_alignment)->stop();
} }
if (time_alignment_timer > 0) { if (time_alignment_timer > 0) {
timers.get(timer_alignment)->set(this, time_alignment_timer); timers->get(timer_alignment)->set(this, time_alignment_timer);
} }
} }
@ -651,9 +650,6 @@ void mac::get_metrics(mac_metrics_t m[SRSLTE_MAX_CARRIERS])
bzero(&metrics, sizeof(mac_metrics_t) * SRSLTE_MAX_CARRIERS); bzero(&metrics, sizeof(mac_metrics_t) * SRSLTE_MAX_CARRIERS);
} }
/******************************************************** /********************************************************
* *
* Interface for timers used by upper layers * Interface for timers used by upper layers
@ -661,20 +657,19 @@ void mac::get_metrics(mac_metrics_t m[SRSLTE_MAX_CARRIERS])
*******************************************************/ *******************************************************/
srslte::timers::timer* mac::timer_get(uint32_t timer_id) srslte::timers::timer* mac::timer_get(uint32_t timer_id)
{ {
return timers.get(timer_id); return timers->get(timer_id);
} }
void mac::timer_release_id(uint32_t timer_id) void mac::timer_release_id(uint32_t timer_id)
{ {
timers.release_id(timer_id); timers->release_id(timer_id);
} }
uint32_t mac::timer_get_unique_id() uint32_t mac::timer_get_unique_id()
{ {
return timers.get_unique_id(); return timers->get_unique_id();
} }
/******************************************************** /********************************************************
* *
* Class that runs a thread to process DL MAC PDUs from * Class that runs a thread to process DL MAC PDUs from

@ -118,7 +118,7 @@ void rrc::init(phy_interface_rrc_lte* phy_,
nas_interface_rrc* nas_, nas_interface_rrc* nas_,
usim_interface_rrc* usim_, usim_interface_rrc* usim_,
gw_interface_rrc* gw_, gw_interface_rrc* gw_,
mac_interface_timers* mac_timers_, srslte::timers* timers_,
const rrc_args_t& args_) const rrc_args_t& args_)
{ {
pool = byte_buffer_pool::get_instance(); pool = byte_buffer_pool::get_instance();
@ -133,19 +133,18 @@ void rrc::init(phy_interface_rrc_lte* phy_,
args = args_; args = args_;
// Use MAC timers // Use MAC timers
mac_timers = mac_timers_; timers = timers_;
state = RRC_STATE_IDLE; state = RRC_STATE_IDLE;
plmn_is_selected = false; plmn_is_selected = false;
security_is_activated = false; security_is_activated = false;
t300 = timers->get_unique_id();
t300 = mac_timers->timer_get_unique_id(); t301 = timers->get_unique_id();
t301 = mac_timers->timer_get_unique_id(); t302 = timers->get_unique_id();
t302 = mac_timers->timer_get_unique_id(); t310 = timers->get_unique_id();
t310 = mac_timers->timer_get_unique_id(); t311 = timers->get_unique_id();
t311 = mac_timers->timer_get_unique_id(); t304 = timers->get_unique_id();
t304 = mac_timers->timer_get_unique_id();
ue_identity_configured = false; ue_identity_configured = false;
@ -448,20 +447,20 @@ void rrc::out_of_sync()
// upon receiving N310 consecutive "out-of-sync" indications for the PCell from lower layers while neither T300, // upon receiving N310 consecutive "out-of-sync" indications for the PCell from lower layers while neither T300,
// T301, T304 nor T311 is running: // T301, T304 nor T311 is running:
if (state == RRC_STATE_CONNECTED) { if (state == RRC_STATE_CONNECTED) {
if (!mac_timers->timer_get(t300)->is_running() && !mac_timers->timer_get(t301)->is_running() && if (!timers->get(t300)->is_running() && !timers->get(t301)->is_running() && !timers->get(t304)->is_running() &&
!mac_timers->timer_get(t304)->is_running() && !mac_timers->timer_get(t310)->is_running() && !timers->get(t310)->is_running() && !timers->get(t311)->is_running()) {
!mac_timers->timer_get(t311)->is_running()) {
rrc_log->info("Received out-of-sync while in state %s. n310=%d, t311=%s, t310=%s\n", rrc_log->info("Received out-of-sync while in state %s. n310=%d, t311=%s, t310=%s\n",
rrc_state_text[state], rrc_state_text[state],
n310_cnt, n310_cnt,
mac_timers->timer_get(t311)->is_running() ? "running" : "stop", timers->get(t311)->is_running() ? "running" : "stop",
mac_timers->timer_get(t310)->is_running() ? "running" : "stop"); timers->get(t310)->is_running() ? "running" : "stop");
n310_cnt++; n310_cnt++;
if (n310_cnt == N310) { if (n310_cnt == N310) {
rrc_log->info("Detected %d out-of-sync from PHY. Trying to resync. Starting T310 timer %d ms\n", rrc_log->info("Detected %d out-of-sync from PHY. Trying to resync. Starting T310 timer %d ms\n",
N310, mac_timers->timer_get(t310)->get_timeout()); N310,
mac_timers->timer_get(t310)->reset(); timers->get(t310)->get_timeout());
mac_timers->timer_get(t310)->run(); timers->get(t310)->reset();
timers->get(t310)->run();
n310_cnt = 0; n310_cnt = 0;
} }
} }
@ -473,10 +472,10 @@ void rrc::in_sync()
{ {
// CAUTION: We do not lock in this function since they are called from real-time threads // CAUTION: We do not lock in this function since they are called from real-time threads
serving_cell->in_sync = true; serving_cell->in_sync = true;
if (mac_timers->timer_get(t310)->is_running()) { if (timers->get(t310)->is_running()) {
n311_cnt++; n311_cnt++;
if (n311_cnt == N311) { if (n311_cnt == N311) {
mac_timers->timer_get(t310)->stop(); timers->get(t310)->stop();
n311_cnt = 0; n311_cnt = 0;
rrc_log->info("Detected %d in-sync from PHY. Stopping T310 timer\n", N311); rrc_log->info("Detected %d in-sync from PHY. Stopping T310 timer\n", N311);
} }
@ -1063,8 +1062,8 @@ bool rrc::ho_prepare()
} }
// Section 5.3.5.4 // Section 5.3.5.4
mac_timers->timer_get(t310)->stop(); timers->get(t310)->stop();
mac_timers->timer_get(t304)->set(this, mob_ctrl_info->t304.to_number()); timers->get(t304)->set(this, mob_ctrl_info->t304.to_number());
// Save serving cell and current configuration // Save serving cell and current configuration
ho_src_cell = *serving_cell; ho_src_cell = *serving_cell;
@ -1148,7 +1147,7 @@ void rrc::ho_ra_completed(bool ra_successful)
measurements.parse_meas_config(&mob_reconf_r8->meas_cfg); measurements.parse_meas_config(&mob_reconf_r8->meas_cfg);
} }
mac_timers->timer_get(t304)->stop(); timers->get(t304)->stop();
} }
// T304 will expiry and send ho_failure // T304 will expiry and send ho_failure
@ -1343,11 +1342,11 @@ void rrc::leave_connected()
void rrc::stop_timers() void rrc::stop_timers()
{ {
mac_timers->timer_get(t300)->stop(); timers->get(t300)->stop();
mac_timers->timer_get(t301)->stop(); timers->get(t301)->stop();
mac_timers->timer_get(t310)->stop(); timers->get(t310)->stop();
mac_timers->timer_get(t311)->stop(); timers->get(t311)->stop();
mac_timers->timer_get(t304)->stop(); timers->get(t304)->stop();
} }
/* Implementation of procedure in 3GPP 36.331 Section 5.3.7.2: Initiation /* Implementation of procedure in 3GPP 36.331 Section 5.3.7.2: Initiation
@ -1395,11 +1394,11 @@ void rrc::proc_con_restablish_request()
rrc_log->info("Resetting timers and MAC in RRC Connection Reestablishment Procedure\n"); rrc_log->info("Resetting timers and MAC in RRC Connection Reestablishment Procedure\n");
// stop timer T310, if running; // stop timer T310, if running;
mac_timers->timer_get(t310)->stop(); timers->get(t310)->stop();
// start timer T311; // start timer T311;
mac_timers->timer_get(t311)->reset(); timers->get(t311)->reset();
mac_timers->timer_get(t311)->run(); timers->get(t311)->run();
// Suspend all RB except SRB0 // Suspend all RB except SRB0
for (int i = 1; i < SRSLTE_N_RADIO_BEARERS; i++) { for (int i = 1; i < SRSLTE_N_RADIO_BEARERS; i++) {
@ -1425,7 +1424,7 @@ void rrc::proc_con_restablish_request()
} }
// Check timer... // Check timer...
if (mac_timers->timer_get(t311)->is_running()) { if (timers->get(t311)->is_running()) {
// Check for synchronism // Check for synchronism
if (serving_cell->in_sync) { if (serving_cell->in_sync) {
// Perform cell selection in accordance to 36.304 // Perform cell selection in accordance to 36.304
@ -1433,16 +1432,16 @@ void rrc::proc_con_restablish_request()
// Actions following cell reselection while T311 is running 5.3.7.3 // Actions following cell reselection while T311 is running 5.3.7.3
// Upon selecting a suitable E-UTRA cell, the UE shall: // Upon selecting a suitable E-UTRA cell, the UE shall:
rrc_log->info("Cell Selection criteria passed after %dms. Sending RRC Connection Reestablishment Request\n", rrc_log->info("Cell Selection criteria passed after %dms. Sending RRC Connection Reestablishment Request\n",
mac_timers->timer_get(t311)->value()); timers->get(t311)->value());
// stop timer T311; // stop timer T311;
mac_timers->timer_get(t301)->reset(); timers->get(t301)->reset();
// start timer T301; // start timer T301;
mac_timers->timer_get(t301)->run(); timers->get(t301)->run();
// apply the timeAlignmentTimerCommon included in SystemInformationBlockType2; // apply the timeAlignmentTimerCommon included in SystemInformationBlockType2;
mac_timers->timer_get(t311)->stop(); timers->get(t311)->stop();
// initiate transmission of the RRCConnectionReestablishmentRequest message in accordance with 5.3.7.4; // initiate transmission of the RRCConnectionReestablishmentRequest message in accordance with 5.3.7.4;
send_con_restablish_request(); send_con_restablish_request();
@ -1644,20 +1643,20 @@ void rrc::handle_sib2()
log_rr_config_common(); log_rr_config_common();
mac_timers->timer_get(t300)->set(this, sib2->ue_timers_and_consts.t300.to_number()); timers->get(t300)->set(this, sib2->ue_timers_and_consts.t300.to_number());
mac_timers->timer_get(t301)->set(this, sib2->ue_timers_and_consts.t301.to_number()); timers->get(t301)->set(this, sib2->ue_timers_and_consts.t301.to_number());
mac_timers->timer_get(t310)->set(this, sib2->ue_timers_and_consts.t310.to_number()); timers->get(t310)->set(this, sib2->ue_timers_and_consts.t310.to_number());
mac_timers->timer_get(t311)->set(this, sib2->ue_timers_and_consts.t311.to_number()); timers->get(t311)->set(this, sib2->ue_timers_and_consts.t311.to_number());
N310 = sib2->ue_timers_and_consts.n310.to_number(); N310 = sib2->ue_timers_and_consts.n310.to_number();
N311 = sib2->ue_timers_and_consts.n311.to_number(); N311 = sib2->ue_timers_and_consts.n311.to_number();
rrc_log->info("Set Constants and Timers: N310=%d, N311=%d, t300=%d, t301=%d, t310=%d, t311=%d\n", rrc_log->info("Set Constants and Timers: N310=%d, N311=%d, t300=%d, t301=%d, t310=%d, t311=%d\n",
N310, N310,
N311, N311,
mac_timers->timer_get(t300)->get_timeout(), timers->get(t300)->get_timeout(),
mac_timers->timer_get(t301)->get_timeout(), timers->get(t301)->get_timeout(),
mac_timers->timer_get(t310)->get_timeout(), timers->get(t310)->get_timeout(),
mac_timers->timer_get(t311)->get_timeout()); timers->get(t311)->get_timeout());
} }
void rrc::handle_sib3() void rrc::handle_sib3()
@ -1899,12 +1898,12 @@ void rrc::parse_dl_ccch(unique_byte_buffer_t pdu)
rrc_log->info("Received ConnectionReject. Wait time: %d\n", reject_r8->wait_time); rrc_log->info("Received ConnectionReject. Wait time: %d\n", reject_r8->wait_time);
rrc_log->console("Received ConnectionReject. Wait time: %d\n", reject_r8->wait_time); rrc_log->console("Received ConnectionReject. Wait time: %d\n", reject_r8->wait_time);
mac_timers->timer_get(t300)->stop(); timers->get(t300)->stop();
if (reject_r8->wait_time) { if (reject_r8->wait_time) {
nas->set_barring(nas_interface_rrc::BARRING_ALL); nas->set_barring(nas_interface_rrc::BARRING_ALL);
mac_timers->timer_get(t302)->set(this, reject_r8->wait_time * 1000u); timers->get(t302)->set(this, reject_r8->wait_time * 1000u);
mac_timers->timer_get(t302)->run(); timers->get(t302)->run();
} else { } else {
// Perform the actions upon expiry of T302 if wait time is zero // Perform the actions upon expiry of T302 if wait time is zero
nas->set_barring(nas_interface_rrc::BARRING_NONE); nas->set_barring(nas_interface_rrc::BARRING_NONE);
@ -2623,18 +2622,22 @@ bool rrc::apply_rr_config_dedicated(rr_cfg_ded_s* cnfg)
} }
if (cnfg->sps_cfg_present) { if (cnfg->sps_cfg_present) {
//TODO // TODO
} }
if (cnfg->rlf_timers_and_consts_r9.is_present() and cnfg->rlf_timers_and_consts_r9->type() == setup_e::setup) { if (cnfg->rlf_timers_and_consts_r9.is_present() and cnfg->rlf_timers_and_consts_r9->type() == setup_e::setup) {
mac_timers->timer_get(t301)->set(this, cnfg->rlf_timers_and_consts_r9->setup().t301_r9.to_number()); timers->get(t301)->set(this, cnfg->rlf_timers_and_consts_r9->setup().t301_r9.to_number());
mac_timers->timer_get(t310)->set(this, cnfg->rlf_timers_and_consts_r9->setup().t310_r9.to_number()); timers->get(t310)->set(this, cnfg->rlf_timers_and_consts_r9->setup().t310_r9.to_number());
mac_timers->timer_get(t311)->set(this, cnfg->rlf_timers_and_consts_r9->setup().t311_r9.to_number()); timers->get(t311)->set(this, cnfg->rlf_timers_and_consts_r9->setup().t311_r9.to_number());
N310 = cnfg->rlf_timers_and_consts_r9->setup().n310_r9.to_number(); N310 = cnfg->rlf_timers_and_consts_r9->setup().n310_r9.to_number();
N311 = cnfg->rlf_timers_and_consts_r9->setup().n311_r9.to_number(); N311 = cnfg->rlf_timers_and_consts_r9->setup().n311_r9.to_number();
rrc_log->info("Updated Constants and Timers: N310=%d, N311=%d, t300=%u, t301=%u, t310=%u, t311=%u\n", rrc_log->info("Updated Constants and Timers: N310=%d, N311=%d, t300=%u, t301=%u, t310=%u, t311=%u\n",
N310, N311, mac_timers->timer_get(t300)->get_timeout(), mac_timers->timer_get(t301)->get_timeout(), N310,
mac_timers->timer_get(t310)->get_timeout(), mac_timers->timer_get(t311)->get_timeout()); N311,
timers->get(t300)->get_timeout(),
timers->get(t301)->get_timeout(),
timers->get(t310)->get_timeout(),
timers->get(t311)->get_timeout());
} }
for (uint32_t i = 0; i < cnfg->srb_to_add_mod_list.size(); i++) { for (uint32_t i = 0; i < cnfg->srb_to_add_mod_list.size(); i++) {
// TODO: handle SRB modification // TODO: handle SRB modification
@ -2714,8 +2717,8 @@ void rrc::handle_con_setup(rrc_conn_setup_s* setup)
{ {
// Must enter CONNECT before stopping T300 // Must enter CONNECT before stopping T300
state = RRC_STATE_CONNECTED; state = RRC_STATE_CONNECTED;
mac_timers->timer_get(t300)->stop(); timers->get(t300)->stop();
mac_timers->timer_get(t302)->stop(); timers->get(t302)->stop();
rrc_log->console("RRC Connected\n"); rrc_log->console("RRC Connected\n");
// Apply the Radio Resource configuration // Apply the Radio Resource configuration
@ -2734,7 +2737,7 @@ void rrc::handle_con_setup(rrc_conn_setup_s* setup)
void rrc::handle_con_reest(rrc_conn_reest_s* setup) void rrc::handle_con_reest(rrc_conn_reest_s* setup)
{ {
mac_timers->timer_get(t301)->stop(); timers->get(t301)->stop();
// Reestablish PDCP and RLC for SRB1 // Reestablish PDCP and RLC for SRB1
pdcp->reestablish(1); pdcp->reestablish(1);
@ -2938,31 +2941,14 @@ void rrc::set_mac_default() {
apply_mac_config_dedicated_default(); apply_mac_config_dedicated_default();
} }
void rrc::set_rrc_default() { void rrc::set_rrc_default()
{
N310 = 1; N310 = 1;
N311 = 1; N311 = 1;
mac_timers->timer_get(t310)->set(this, 1000); timers->get(t310)->set(this, 1000);
mac_timers->timer_get(t311)->set(this, 1000); timers->get(t311)->set(this, 1000);
} }
/************************************************************************ /************************************************************************
* *
* *
@ -2975,7 +2961,7 @@ void rrc::rrc_meas::init(rrc *parent) {
this->parent = parent; this->parent = parent;
this->log_h = parent->rrc_log; this->log_h = parent->rrc_log;
this->phy = parent->phy; this->phy = parent->phy;
this->mac_timers = parent->mac_timers; this->timers = parent->timers;
s_measure_enabled = false; s_measure_enabled = false;
reset(); reset();
} }
@ -3138,11 +3124,11 @@ void rrc::rrc_meas::generate_report(uint32_t meas_id)
report->meas_result_neigh_cells_present = neigh_list.size() > 0; report->meas_result_neigh_cells_present = neigh_list.size() > 0;
m->nof_reports_sent++; m->nof_reports_sent++;
mac_timers->timer_get(m->periodic_timer)->stop(); timers->get(m->periodic_timer)->stop();
if (m->nof_reports_sent < cfg->amount) { if (m->nof_reports_sent < cfg->amount) {
mac_timers->timer_get(m->periodic_timer)->reset(); timers->get(m->periodic_timer)->reset();
mac_timers->timer_get(m->periodic_timer)->run(); timers->get(m->periodic_timer)->run();
} else { } else {
if (cfg->trigger_type == report_cfg_t::PERIODIC) { if (cfg->trigger_type == report_cfg_t::PERIODIC) {
m->triggered = false; m->triggered = false;
@ -3175,7 +3161,7 @@ bool rrc::rrc_meas::process_event(eutra_event_s* event, uint32_t tti, bool enter
} else if (srslte_tti_interval(tti, cell->exit_tti) >= event->time_to_trigger) { } else if (srslte_tti_interval(tti, cell->exit_tti) >= event->time_to_trigger) {
m->triggered = false; m->triggered = false;
cell->triggered = false; cell->triggered = false;
mac_timers->timer_get(m->periodic_timer)->stop(); timers->get(m->periodic_timer)->stop();
if (event) { if (event) {
if (event->event_id.type() == eutra_event_s::event_id_c_::types::event_a3 && if (event->event_id.type() == eutra_event_s::event_id_c_::types::event_a3 &&
event->event_id.event_a3().report_on_leave) { event->event_id.event_a3().report_on_leave) {
@ -3351,8 +3337,9 @@ bool rrc::rrc_meas::timer_expired(uint32_t timer_id) {
return false; return false;
} }
void rrc::rrc_meas::stop_reports(meas_t *m) { void rrc::rrc_meas::stop_reports(meas_t* m)
mac_timers->timer_get(m->periodic_timer)->stop(); {
timers->get(m->periodic_timer)->stop();
m->triggered = false; m->triggered = false;
} }
@ -3386,10 +3373,11 @@ void rrc::rrc_meas::remove_meas_report(uint32_t report_id) {
} }
} }
void rrc::rrc_meas::remove_meas_id(uint32_t measId) { void rrc::rrc_meas::remove_meas_id(uint32_t measId)
{
if (active.count(measId)) { if (active.count(measId)) {
mac_timers->timer_get(active[measId].periodic_timer)->stop(); timers->get(active[measId].periodic_timer)->stop();
mac_timers->timer_release_id(active[measId].periodic_timer); timers->release_id(active[measId].periodic_timer);
log_h->info("MEAS: Removed measId=%d\n", measId); log_h->info("MEAS: Removed measId=%d\n", measId);
active.erase(measId); active.erase(measId);
} else { } else {
@ -3397,9 +3385,10 @@ void rrc::rrc_meas::remove_meas_id(uint32_t measId) {
} }
} }
void rrc::rrc_meas::remove_meas_id(std::map<uint32_t, meas_t>::iterator it) { void rrc::rrc_meas::remove_meas_id(std::map<uint32_t, meas_t>::iterator it)
mac_timers->timer_get(it->second.periodic_timer)->stop(); {
mac_timers->timer_release_id(it->second.periodic_timer); timers->get(it->second.periodic_timer)->stop();
timers->release_id(it->second.periodic_timer);
log_h->info("MEAS: Removed measId=%d\n", it->first); log_h->info("MEAS: Removed measId=%d\n", it->first);
active.erase(it); active.erase(it);
} }
@ -3548,10 +3537,10 @@ bool rrc::rrc_meas::parse_meas_config(meas_cfg_s* cfg)
// Stop the timer if the entry exists or create the timer if not // Stop the timer if the entry exists or create the timer if not
bool is_new = false; bool is_new = false;
if (active.count(meas_id->meas_id)) { if (active.count(meas_id->meas_id)) {
mac_timers->timer_get(active[meas_id->meas_id].periodic_timer)->stop(); timers->get(active[meas_id->meas_id].periodic_timer)->stop();
} else { } else {
is_new = true; is_new = true;
active[meas_id->meas_id].periodic_timer = mac_timers->timer_get_unique_id(); active[meas_id->meas_id].periodic_timer = timers->get_unique_id();
} }
active[meas_id->meas_id].object_id = meas_id->meas_obj_id; active[meas_id->meas_id].object_id = meas_id->meas_obj_id;
active[meas_id->meas_id].report_id = meas_id->report_cfg_id; active[meas_id->meas_id].report_id = meas_id->report_cfg_id;

@ -546,7 +546,7 @@ proc_outcome_t rrc::connection_request_proc::init(rrc*
return proc_outcome_t::error; return proc_outcome_t::error;
} }
if (rrc_ptr->mac_timers->timer_get(rrc_ptr->t302)->is_running()) { if (rrc_ptr->timers->get(rrc_ptr->t302)->is_running()) {
Info("Requested RRC connection establishment while T302 is running\n"); Info("Requested RRC connection establishment while T302 is running\n");
rrc_ptr->nas->set_barring(nas_interface_rrc::BARRING_MO_DATA); rrc_ptr->nas->set_barring(nas_interface_rrc::BARRING_MO_DATA);
return proc_outcome_t::error; return proc_outcome_t::error;
@ -620,8 +620,8 @@ proc_outcome_t rrc::connection_request_proc::step()
return proc_outcome_t::error; return proc_outcome_t::error;
} }
rrc_ptr->mac_timers->timer_get(rrc_ptr->t300)->reset(); rrc_ptr->timers->get(rrc_ptr->t300)->reset();
rrc_ptr->mac_timers->timer_get(rrc_ptr->t300)->run(); rrc_ptr->timers->get(rrc_ptr->t300)->run();
// Send connectionRequest message to lower layers // Send connectionRequest message to lower layers
rrc_ptr->send_con_request(cause); rrc_ptr->send_con_request(cause);
@ -638,14 +638,14 @@ proc_outcome_t rrc::connection_request_proc::step()
} else if (state == state_t::wait_t300) { } else if (state == state_t::wait_t300) {
// Wait until t300 stops due to RRCConnectionSetup/Reject or expiry // Wait until t300 stops due to RRCConnectionSetup/Reject or expiry
if (rrc_ptr->mac_timers->timer_get(rrc_ptr->t300)->is_running()) { if (rrc_ptr->timers->get(rrc_ptr->t300)->is_running()) {
return proc_outcome_t::yield; return proc_outcome_t::yield;
} }
if (rrc_ptr->state == RRC_STATE_CONNECTED) { if (rrc_ptr->state == RRC_STATE_CONNECTED) {
// Received ConnectionSetup // Received ConnectionSetup
return proc_outcome_t::success; return proc_outcome_t::success;
} else if (rrc_ptr->mac_timers->timer_get(rrc_ptr->t300)->is_expired()) { } else if (rrc_ptr->timers->get(rrc_ptr->t300)->is_expired()) {
// T300 is expired: 5.3.3.6 // T300 is expired: 5.3.3.6
Info("Timer T300 expired: ConnectionRequest timed out\n"); Info("Timer T300 expired: ConnectionRequest timed out\n");
rrc_ptr->mac->reset(); rrc_ptr->mac->reset();

@ -27,6 +27,7 @@ using namespace srslte;
namespace srsue { namespace srsue {
ue_stack_lte::ue_stack_lte() : ue_stack_lte::ue_stack_lte() :
timers(64),
running(false), running(false),
args(), args(),
logger(nullptr), logger(nullptr),
@ -114,11 +115,11 @@ int ue_stack_lte::init(const stack_args_t& args_, srslte::logger* logger_)
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
mac.init(phy, &rlc, &rrc); mac.init(phy, &rlc, &rrc, &timers);
rlc.init(&pdcp, &rrc, &mac, 0 /* RB_ID_SRB0 */); rlc.init(&pdcp, &rrc, &timers, 0 /* RB_ID_SRB0 */);
pdcp.init(&rlc, &rrc, gw); pdcp.init(&rlc, &rrc, gw);
nas.init(usim.get(), &rrc, gw, args.nas); nas.init(usim.get(), &rrc, gw, args.nas);
rrc.init(phy, &mac, &rlc, &pdcp, &nas, usim.get(), gw, &mac, args.rrc); rrc.init(phy, &mac, &rlc, &pdcp, &nas, usim.get(), gw, &timers, args.rrc);
running = true; running = true;
start(STACK_MAIN_THREAD_PRIO); start(STACK_MAIN_THREAD_PRIO);
@ -227,6 +228,7 @@ void ue_stack_lte::run_tti_impl(uint32_t tti)
mac.run_tti(tti); mac.run_tti(tti);
rrc.run_tti(tti); rrc.run_tti(tti);
nas.run_tti(tti); nas.run_tti(tti);
timers.step_all();
} }
} // namespace srsue } // namespace srsue

@ -349,6 +349,7 @@ int mac_unpack_test()
srslte::log_filter rlc_log("RLC"); srslte::log_filter rlc_log("RLC");
srslte::log_filter mac_log("MAC"); srslte::log_filter mac_log("MAC");
srslte::timers timers(64);
mac_log.set_level(srslte::LOG_LEVEL_DEBUG); mac_log.set_level(srslte::LOG_LEVEL_DEBUG);
mac_log.set_hex_limit(100000); mac_log.set_hex_limit(100000);
@ -362,7 +363,7 @@ int mac_unpack_test()
// the actual MAC // the actual MAC
mac mac(&mac_log); mac mac(&mac_log);
mac.init(&phy, &rlc, &rrc); mac.init(&phy, &rlc, &rrc, &timers);
// create dummy DL action and grant and push MAC PDU // create dummy DL action and grant and push MAC PDU
mac_interface_phy_lte::tb_action_dl_t dl_action; mac_interface_phy_lte::tb_action_dl_t dl_action;
@ -385,6 +386,7 @@ int mac_unpack_test()
// make sure MAC PDU thread picks up before stopping // make sure MAC PDU thread picks up before stopping
sleep(1); sleep(1);
mac.run_tti(0); mac.run_tti(0);
timers.step_all();
mac.stop(); mac.stop();
// check length of both received RLC PDUs // check length of both received RLC PDUs
@ -409,6 +411,8 @@ int mac_ul_sch_pdu_test1()
rlc_log.set_level(srslte::LOG_LEVEL_DEBUG); rlc_log.set_level(srslte::LOG_LEVEL_DEBUG);
rlc_log.set_hex_limit(100000); rlc_log.set_hex_limit(100000);
srslte::timers timers(64);
// dummy layers // dummy layers
phy_dummy phy; phy_dummy phy;
rlc_dummy rlc(&rlc_log); rlc_dummy rlc(&rlc_log);
@ -416,7 +420,7 @@ int mac_ul_sch_pdu_test1()
// the actual MAC // the actual MAC
mac mac(&mac_log); mac mac(&mac_log);
mac.init(&phy, &rlc, &rrc); mac.init(&phy, &rlc, &rrc, &timers);
const uint16_t crnti = 0x1001; const uint16_t crnti = 0x1001;
mac.set_ho_rnti(crnti, 0); mac.set_ho_rnti(crnti, 0);
@ -475,6 +479,8 @@ int mac_ul_logical_channel_prioritization_test1()
rlc_log.set_level(srslte::LOG_LEVEL_DEBUG); rlc_log.set_level(srslte::LOG_LEVEL_DEBUG);
rlc_log.set_hex_limit(100000); rlc_log.set_hex_limit(100000);
srslte::timers timers(64);
// dummy layers // dummy layers
phy_dummy phy; phy_dummy phy;
rlc_dummy rlc(&rlc_log); rlc_dummy rlc(&rlc_log);
@ -482,7 +488,7 @@ int mac_ul_logical_channel_prioritization_test1()
// the actual MAC // the actual MAC
mac mac(&mac_log); mac mac(&mac_log);
mac.init(&phy, &rlc, &rrc); mac.init(&phy, &rlc, &rrc, &timers);
const uint16_t crnti = 0x1001; const uint16_t crnti = 0x1001;
mac.set_ho_rnti(crnti, 0); mac.set_ho_rnti(crnti, 0);
@ -586,6 +592,8 @@ int mac_ul_logical_channel_prioritization_test2()
rlc_log.set_level(srslte::LOG_LEVEL_DEBUG); rlc_log.set_level(srslte::LOG_LEVEL_DEBUG);
rlc_log.set_hex_limit(100000); rlc_log.set_hex_limit(100000);
srslte::timers timers(64);
// dummy layers // dummy layers
phy_dummy phy; phy_dummy phy;
rlc_dummy rlc(&rlc_log); rlc_dummy rlc(&rlc_log);
@ -593,7 +601,7 @@ int mac_ul_logical_channel_prioritization_test2()
// the actual MAC // the actual MAC
mac mac(&mac_log); mac mac(&mac_log);
mac.init(&phy, &rlc, &rrc); mac.init(&phy, &rlc, &rrc, &timers);
const uint16_t crnti = 0x1001; const uint16_t crnti = 0x1001;
mac.set_ho_rnti(crnti, 0); mac.set_ho_rnti(crnti, 0);
@ -684,6 +692,8 @@ int mac_ul_logical_channel_prioritization_test3()
rlc_log.set_level(srslte::LOG_LEVEL_DEBUG); rlc_log.set_level(srslte::LOG_LEVEL_DEBUG);
rlc_log.set_hex_limit(100000); rlc_log.set_hex_limit(100000);
srslte::timers timers(64);
// dummy layers // dummy layers
phy_dummy phy; phy_dummy phy;
rlc_dummy rlc(&rlc_log); rlc_dummy rlc(&rlc_log);
@ -691,7 +701,7 @@ int mac_ul_logical_channel_prioritization_test3()
// the actual MAC // the actual MAC
mac mac(&mac_log); mac mac(&mac_log);
mac.init(&phy, &rlc, &rrc); mac.init(&phy, &rlc, &rrc, &timers);
const uint16_t crnti = 0x1001; const uint16_t crnti = 0x1001;
mac.set_ho_rnti(crnti, 0); mac.set_ho_rnti(crnti, 0);
@ -770,6 +780,8 @@ int mac_ul_sch_pdu_with_short_bsr_test()
rlc_log.set_level(srslte::LOG_LEVEL_DEBUG); rlc_log.set_level(srslte::LOG_LEVEL_DEBUG);
rlc_log.set_hex_limit(100000); rlc_log.set_hex_limit(100000);
srslte::timers timers(64);
// dummy layers // dummy layers
phy_dummy phy; phy_dummy phy;
rlc_dummy rlc(&rlc_log); rlc_dummy rlc(&rlc_log);
@ -777,7 +789,7 @@ int mac_ul_sch_pdu_with_short_bsr_test()
// the actual MAC // the actual MAC
mac mac(&mac_log); mac mac(&mac_log);
mac.init(&phy, &rlc, &rrc); mac.init(&phy, &rlc, &rrc, &timers);
const uint16_t crnti = 0x1001; const uint16_t crnti = 0x1001;
mac.set_ho_rnti(crnti, 0); mac.set_ho_rnti(crnti, 0);
@ -854,6 +866,8 @@ int mac_ul_sch_pdu_with_padding_bsr_test()
rlc_log.set_level(srslte::LOG_LEVEL_DEBUG); rlc_log.set_level(srslte::LOG_LEVEL_DEBUG);
rlc_log.set_hex_limit(100000); rlc_log.set_hex_limit(100000);
srslte::timers timers(64);
// dummy layers // dummy layers
phy_dummy phy; phy_dummy phy;
rlc_dummy rlc(&rlc_log); rlc_dummy rlc(&rlc_log);
@ -861,7 +875,7 @@ int mac_ul_sch_pdu_with_padding_bsr_test()
// the actual MAC // the actual MAC
mac mac(&mac_log); mac mac(&mac_log);
mac.init(&phy, &rlc, &rrc); mac.init(&phy, &rlc, &rrc, &timers);
const uint16_t crnti = 0x1001; const uint16_t crnti = 0x1001;
mac.set_ho_rnti(crnti, 0); mac.set_ho_rnti(crnti, 0);
@ -947,6 +961,8 @@ int mac_ul_sch_pdu_one_byte_test()
rlc_log.set_level(srslte::LOG_LEVEL_DEBUG); rlc_log.set_level(srslte::LOG_LEVEL_DEBUG);
rlc_log.set_hex_limit(100000); rlc_log.set_hex_limit(100000);
srslte::timers timers(64);
// dummy layers // dummy layers
phy_dummy phy; phy_dummy phy;
rlc_dummy rlc(&rlc_log); rlc_dummy rlc(&rlc_log);
@ -954,7 +970,7 @@ int mac_ul_sch_pdu_one_byte_test()
// the actual MAC // the actual MAC
mac mac(&mac_log); mac mac(&mac_log);
mac.init(&phy, &rlc, &rrc); mac.init(&phy, &rlc, &rrc, &timers);
const uint16_t crnti = 0x1001; const uint16_t crnti = 0x1001;
mac.set_ho_rnti(crnti, 0); mac.set_ho_rnti(crnti, 0);
@ -1005,6 +1021,8 @@ int mac_ul_sch_pdu_two_byte_test()
rlc_log.set_level(srslte::LOG_LEVEL_DEBUG); rlc_log.set_level(srslte::LOG_LEVEL_DEBUG);
rlc_log.set_hex_limit(100000); rlc_log.set_hex_limit(100000);
srslte::timers timers(64);
// dummy layers // dummy layers
phy_dummy phy; phy_dummy phy;
rlc_dummy rlc(&rlc_log); rlc_dummy rlc(&rlc_log);
@ -1012,7 +1030,7 @@ int mac_ul_sch_pdu_two_byte_test()
// the actual MAC // the actual MAC
mac mac(&mac_log); mac mac(&mac_log);
mac.init(&phy, &rlc, &rrc); mac.init(&phy, &rlc, &rrc, &timers);
const uint16_t crnti = 0x1001; const uint16_t crnti = 0x1001;
mac.set_ho_rnti(crnti, 0); mac.set_ho_rnti(crnti, 0);
@ -1063,6 +1081,8 @@ int mac_ul_sch_pdu_three_byte_test()
rlc_log.set_level(srslte::LOG_LEVEL_DEBUG); rlc_log.set_level(srslte::LOG_LEVEL_DEBUG);
rlc_log.set_hex_limit(100000); rlc_log.set_hex_limit(100000);
srslte::timers timers(64);
// dummy layers // dummy layers
phy_dummy phy; phy_dummy phy;
rlc_dummy rlc(&rlc_log); rlc_dummy rlc(&rlc_log);
@ -1070,7 +1090,7 @@ int mac_ul_sch_pdu_three_byte_test()
// the actual MAC // the actual MAC
mac mac(&mac_log); mac mac(&mac_log);
mac.init(&phy, &rlc, &rrc); mac.init(&phy, &rlc, &rrc, &timers);
const uint16_t crnti = 0x1001; const uint16_t crnti = 0x1001;
mac.set_ho_rnti(crnti, 0); mac.set_ho_rnti(crnti, 0);
@ -1126,7 +1146,7 @@ struct ra_test {
struct ra_test test; struct ra_test test;
int run_mac_ra_test(struct ra_test test, mac* mac, phy_dummy* phy, uint32_t* tti_state) int run_mac_ra_test(struct ra_test test, mac* mac, phy_dummy* phy, uint32_t* tti_state, srslte::timers* timers)
{ {
uint32_t tti = *tti_state; uint32_t tti = *tti_state;
@ -1148,6 +1168,7 @@ int run_mac_ra_test(struct ra_test test, mac* mac, phy_dummy* phy, uint32_t* tti
if (test.assume_prach_transmitted != (int)j) { if (test.assume_prach_transmitted != (int)j) {
phy->set_prach_tti(tti + phy->prach_delay); phy->set_prach_tti(tti + phy->prach_delay);
mac->run_tti(tti++); mac->run_tti(tti++);
timers->step_all();
} }
// Check MAC instructs PHY to transmit PRACH // Check MAC instructs PHY to transmit PRACH
@ -1167,6 +1188,7 @@ int run_mac_ra_test(struct ra_test test, mac* mac, phy_dummy* phy, uint32_t* tti
mac->run_tti(tti); mac->run_tti(tti);
TESTASSERT(!SRSLTE_RNTI_ISRAR(mac->get_dl_sched_rnti(tti))); TESTASSERT(!SRSLTE_RNTI_ISRAR(mac->get_dl_sched_rnti(tti)));
tti++; tti++;
timers->step_all();
} }
bool rapid_found = false; bool rapid_found = false;
@ -1175,6 +1197,7 @@ int run_mac_ra_test(struct ra_test test, mac* mac, phy_dummy* phy, uint32_t* tti
mac->run_tti(tti); mac->run_tti(tti);
TESTASSERT(mac->get_dl_sched_rnti(tti) == phy->get_rar_rnti()); TESTASSERT(mac->get_dl_sched_rnti(tti) == phy->get_rar_rnti());
tti++; tti++;
timers->step_all();
// Receive RAR // Receive RAR
if (test.rar_nof_rapid > 0) { if (test.rar_nof_rapid > 0) {
@ -1200,6 +1223,7 @@ int run_mac_ra_test(struct ra_test test, mac* mac, phy_dummy* phy, uint32_t* tti
mac->run_tti(tti); mac->run_tti(tti);
TESTASSERT(mac->get_dl_sched_rnti(tti) == (test.crnti ? test.crnti : test.temp_rnti)); TESTASSERT(mac->get_dl_sched_rnti(tti) == (test.crnti ? test.crnti : test.temp_rnti));
tti++; tti++;
timers->step_all();
} }
if (i == test.rach_cfg.max_harq_msg3_tx) { if (i == test.rach_cfg.max_harq_msg3_tx) {
@ -1222,6 +1246,7 @@ int run_mac_ra_test(struct ra_test test, mac* mac, phy_dummy* phy, uint32_t* tti
mac->run_tti(tti); mac->run_tti(tti);
TESTASSERT(mac->get_dl_sched_rnti(tti) == (test.crnti ? test.crnti : test.temp_rnti)); TESTASSERT(mac->get_dl_sched_rnti(tti) == (test.crnti ? test.crnti : test.temp_rnti));
tti++; tti++;
timers->step_all();
if (test.msg4_enable) { if (test.msg4_enable) {
if (test.crnti) { if (test.crnti) {
@ -1258,6 +1283,7 @@ int run_mac_ra_test(struct ra_test test, mac* mac, phy_dummy* phy, uint32_t* tti
phy->set_prach_tti(tti + phy->prach_delay, false); phy->set_prach_tti(tti + phy->prach_delay, false);
TESTASSERT(mac->get_dl_sched_rnti(tti) != temp_rnti); TESTASSERT(mac->get_dl_sched_rnti(tti) != temp_rnti);
mac->run_tti(tti++); mac->run_tti(tti++);
timers->step_all();
} }
} }
@ -1267,6 +1293,7 @@ int run_mac_ra_test(struct ra_test test, mac* mac, phy_dummy* phy, uint32_t* tti
TESTASSERT(phy->get_crnti() == (test.crnti ? test.crnti : test.temp_rnti)); TESTASSERT(phy->get_crnti() == (test.crnti ? test.crnti : test.temp_rnti));
TESTASSERT(mac->get_dl_sched_rnti(tti) == (test.crnti ? test.crnti : test.temp_rnti)); TESTASSERT(mac->get_dl_sched_rnti(tti) == (test.crnti ? test.crnti : test.temp_rnti));
tti++; tti++;
timers->step_all();
} }
*tti_state = tti; *tti_state = tti;
@ -1296,6 +1323,8 @@ int mac_random_access_test()
rlc_log.set_level(srslte::LOG_LEVEL_DEBUG); rlc_log.set_level(srslte::LOG_LEVEL_DEBUG);
rlc_log.set_hex_limit(100000); rlc_log.set_hex_limit(100000);
srslte::timers timers(64);
// dummy layers // dummy layers
phy_dummy phy; phy_dummy phy;
phy.set_log(&phy_log); phy.set_log(&phy_log);
@ -1314,7 +1343,7 @@ int mac_random_access_test()
// Configure MAC // Configure MAC
mac mac(&mac_log); mac mac(&mac_log);
mac.init(&phy, &rlc, &rrc); mac.init(&phy, &rlc, &rrc, &timers);
mac_interface_rrc::mac_cfg_t mac_cfg; mac_interface_rrc::mac_cfg_t mac_cfg;
mac_cfg.set_rach_cfg_common(rach_cfg); mac_cfg.set_rach_cfg_common(rach_cfg);
mac.set_config(mac_cfg); mac.set_config(mac_cfg);
@ -1353,11 +1382,12 @@ int mac_random_access_test()
mac_log.info("\n=========== Test %d =============\n", test_id++); mac_log.info("\n=========== Test %d =============\n", test_id++);
my_test.rach_cfg = rach_cfg; my_test.rach_cfg = rach_cfg;
my_test.nof_prachs = rach_cfg.ra_supervision_info.preamb_trans_max.to_number(); my_test.nof_prachs = rach_cfg.ra_supervision_info.preamb_trans_max.to_number();
TESTASSERT(!run_mac_ra_test(my_test, &mac, &phy, &tti)); TESTASSERT(!run_mac_ra_test(my_test, &mac, &phy, &tti, &timers));
// Make sure it triggers RRC signal // Make sure it triggers RRC signal
mac.run_tti(tti++); mac.run_tti(tti++);
TESTASSERT(rrc.rach_problem == 1); TESTASSERT(rrc.rach_problem == 1);
timers.step_all();
// Reset MAC // Reset MAC
mac.reset(); mac.reset();
@ -1371,7 +1401,7 @@ int mac_random_access_test()
my_test.rar_nof_rapid = 1; my_test.rar_nof_rapid = 1;
my_test.nof_prachs = 1; my_test.nof_prachs = 1;
my_test.rar_nof_invalid_rapid = rach_cfg.ra_supervision_info.ra_resp_win_size.to_number(); my_test.rar_nof_invalid_rapid = rach_cfg.ra_supervision_info.ra_resp_win_size.to_number();
TESTASSERT(!run_mac_ra_test(my_test, &mac, &phy, &tti)); TESTASSERT(!run_mac_ra_test(my_test, &mac, &phy, &tti, &timers));
// Test 3: RAR received but no matching RAPID. Test Msg3 retransmissions // Test 3: RAR received but no matching RAPID. Test Msg3 retransmissions
// On each HARQ retx, contention resolution timer must be restarted (5.1.5) // On each HARQ retx, contention resolution timer must be restarted (5.1.5)
@ -1379,7 +1409,7 @@ int mac_random_access_test()
mac_log.info("\n=========== Test %d =============\n", test_id++); mac_log.info("\n=========== Test %d =============\n", test_id++);
my_test.rar_nof_invalid_rapid = 0; my_test.rar_nof_invalid_rapid = 0;
my_test.nof_msg3_retx = rach_cfg.max_harq_msg3_tx; my_test.nof_msg3_retx = rach_cfg.max_harq_msg3_tx;
TESTASSERT(!run_mac_ra_test(my_test, &mac, &phy, &tti)); TESTASSERT(!run_mac_ra_test(my_test, &mac, &phy, &tti, &timers));
// Test 4: RAR with valid RAPID. Msg3 transmitted, Msg4 received but invalid ConRes // Test 4: RAR with valid RAPID. Msg3 transmitted, Msg4 received but invalid ConRes
// Contention resolution is defined in 5.1.5. If ConResID does not match, the ConRes is considered // Contention resolution is defined in 5.1.5. If ConResID does not match, the ConRes is considered
@ -1388,7 +1418,7 @@ int mac_random_access_test()
phy.reset(); phy.reset();
my_test.nof_msg3_retx = 0; my_test.nof_msg3_retx = 0;
my_test.msg4_enable = true; my_test.msg4_enable = true;
TESTASSERT(!run_mac_ra_test(my_test, &mac, &phy, &tti)); TESTASSERT(!run_mac_ra_test(my_test, &mac, &phy, &tti, &timers));
// Test 5: Msg4 received and valid ConRes. In this case a valid ConResID is received and RA procedure is successful // Test 5: Msg4 received and valid ConRes. In this case a valid ConResID is received and RA procedure is successful
mac_log.info("\n=========== Test %d =============\n", test_id++); mac_log.info("\n=========== Test %d =============\n", test_id++);
@ -1396,7 +1426,7 @@ int mac_random_access_test()
my_test.msg4_valid_conres = true; my_test.msg4_valid_conres = true;
my_test.check_ra_successful = true; my_test.check_ra_successful = true;
my_test.assume_prach_transmitted = 0; my_test.assume_prach_transmitted = 0;
TESTASSERT(!run_mac_ra_test(my_test, &mac, &phy, &tti)); TESTASSERT(!run_mac_ra_test(my_test, &mac, &phy, &tti, &timers));
// Test 6: RA with existing C-RNTI (Sends C-RNTI MAC CE) // Test 6: RA with existing C-RNTI (Sends C-RNTI MAC CE)
// The transmission of C-RNTI MAC CE is only done if no CCCH is present (5.1.4). // The transmission of C-RNTI MAC CE is only done if no CCCH is present (5.1.4).
@ -1408,7 +1438,7 @@ int mac_random_access_test()
my_test.temp_rnti++; // Temporal C-RNTI has to change to avoid duplicate my_test.temp_rnti++; // Temporal C-RNTI has to change to avoid duplicate
my_test.assume_prach_transmitted = -1; my_test.assume_prach_transmitted = -1;
my_test.send_valid_ul_grant = true; my_test.send_valid_ul_grant = true;
TESTASSERT(!run_mac_ra_test(my_test, &mac, &phy, &tti)); TESTASSERT(!run_mac_ra_test(my_test, &mac, &phy, &tti, &timers));
// Test 7: Test Contention based Random Access. This is used eg in HO where preamble is chosen by UE. // Test 7: Test Contention based Random Access. This is used eg in HO where preamble is chosen by UE.
// It is similar to Test 5 because C-RNTI is available to the UE when start the RA but // It is similar to Test 5 because C-RNTI is available to the UE when start the RA but
@ -1419,6 +1449,7 @@ int mac_random_access_test()
phy.set_crnti(0); phy.set_crnti(0);
mac.start_cont_ho(); mac.start_cont_ho();
mac.run_tti(tti++); mac.run_tti(tti++);
timers.step_all();
rrc.ho_finish = false; rrc.ho_finish = false;
my_test.nof_prachs = rach_cfg.ra_supervision_info.preamb_trans_max.to_number(); my_test.nof_prachs = rach_cfg.ra_supervision_info.preamb_trans_max.to_number();
my_test.temp_rnti++; // Temporal C-RNTI has to change to avoid duplicate my_test.temp_rnti++; // Temporal C-RNTI has to change to avoid duplicate
@ -1426,7 +1457,7 @@ int mac_random_access_test()
my_test.assume_prach_transmitted = 0; my_test.assume_prach_transmitted = 0;
my_test.check_ra_successful = false; my_test.check_ra_successful = false;
my_test.send_valid_ul_grant = false; my_test.send_valid_ul_grant = false;
TESTASSERT(!run_mac_ra_test(my_test, &mac, &phy, &tti)); TESTASSERT(!run_mac_ra_test(my_test, &mac, &phy, &tti, &timers));
TESTASSERT(!rrc.ho_finish_successful && rrc.ho_finish); TESTASSERT(!rrc.ho_finish_successful && rrc.ho_finish);
// Test 8: Test Contention based Random Access. Same as above but we let the procedure finish successfully. // Test 8: Test Contention based Random Access. Same as above but we let the procedure finish successfully.
@ -1435,11 +1466,12 @@ int mac_random_access_test()
phy.set_crnti(0); phy.set_crnti(0);
mac.start_cont_ho(); mac.start_cont_ho();
mac.run_tti(tti++); mac.run_tti(tti++);
timers.step_all();
rrc.ho_finish = false; rrc.ho_finish = false;
my_test.nof_prachs = 1; my_test.nof_prachs = 1;
my_test.temp_rnti++; // Temporal C-RNTI has to change to avoid duplicate my_test.temp_rnti++; // Temporal C-RNTI has to change to avoid duplicate
my_test.send_valid_ul_grant = true; my_test.send_valid_ul_grant = true;
TESTASSERT(!run_mac_ra_test(my_test, &mac, &phy, &tti)); TESTASSERT(!run_mac_ra_test(my_test, &mac, &phy, &tti, &timers));
TESTASSERT(rrc.ho_finish_successful && rrc.ho_finish); TESTASSERT(rrc.ho_finish_successful && rrc.ho_finish);
// Test 9: Test non-Contention based HO. Used in HO but preamble is given by the network. In addition to checking // Test 9: Test non-Contention based HO. Used in HO but preamble is given by the network. In addition to checking
@ -1448,6 +1480,7 @@ int mac_random_access_test()
mac_log.info("\n=========== Test %d =============\n", test_id++); mac_log.info("\n=========== Test %d =============\n", test_id++);
phy.set_prach_tti(tti + phy.prach_delay); phy.set_prach_tti(tti + phy.prach_delay);
mac.run_tti(tti++); mac.run_tti(tti++);
timers.step_all();
phy.set_crnti(0); phy.set_crnti(0);
rrc.ho_finish = false; rrc.ho_finish = false;
my_test.preamble_idx = 3; my_test.preamble_idx = 3;
@ -1455,8 +1488,9 @@ int mac_random_access_test()
my_test.nof_prachs = rach_cfg.ra_supervision_info.preamb_trans_max.to_number(); my_test.nof_prachs = rach_cfg.ra_supervision_info.preamb_trans_max.to_number();
my_test.rar_nof_invalid_rapid = rach_cfg.ra_supervision_info.ra_resp_win_size.to_number(); my_test.rar_nof_invalid_rapid = rach_cfg.ra_supervision_info.ra_resp_win_size.to_number();
my_test.temp_rnti++; // Temporal C-RNTI has to change to avoid duplicate my_test.temp_rnti++; // Temporal C-RNTI has to change to avoid duplicate
TESTASSERT(!run_mac_ra_test(my_test, &mac, &phy, &tti)); TESTASSERT(!run_mac_ra_test(my_test, &mac, &phy, &tti, &timers));
mac.run_tti(tti++); mac.run_tti(tti++);
timers.step_all();
TESTASSERT(!rrc.ho_finish_successful && rrc.ho_finish); TESTASSERT(!rrc.ho_finish_successful && rrc.ho_finish);
// Test 10: Test non-Contention based HO. Used in HO but preamble is given by the network. We check that // Test 10: Test non-Contention based HO. Used in HO but preamble is given by the network. We check that
@ -1464,6 +1498,7 @@ int mac_random_access_test()
mac_log.info("\n=========== Test %d =============\n", test_id++); mac_log.info("\n=========== Test %d =============\n", test_id++);
phy.set_prach_tti(tti + phy.prach_delay); phy.set_prach_tti(tti + phy.prach_delay);
mac.run_tti(tti++); mac.run_tti(tti++);
timers.step_all();
phy.set_crnti(0); phy.set_crnti(0);
rrc.ho_finish = false; rrc.ho_finish = false;
my_test.preamble_idx = 3; my_test.preamble_idx = 3;
@ -1472,8 +1507,9 @@ int mac_random_access_test()
my_test.rar_nof_invalid_rapid = 0; my_test.rar_nof_invalid_rapid = 0;
my_test.check_ra_successful = true; my_test.check_ra_successful = true;
my_test.temp_rnti++; // Temporal C-RNTI has to change to avoid duplicate my_test.temp_rnti++; // Temporal C-RNTI has to change to avoid duplicate
TESTASSERT(!run_mac_ra_test(my_test, &mac, &phy, &tti)); TESTASSERT(!run_mac_ra_test(my_test, &mac, &phy, &tti, &timers));
mac.run_tti(tti++); mac.run_tti(tti++);
timers.step_all();
TESTASSERT(rrc.ho_finish_successful && rrc.ho_finish); TESTASSERT(rrc.ho_finish_successful && rrc.ho_finish);
mac.stop(); mac.stop();

Loading…
Cancel
Save