moved RA waiting procedure to a background task of the stack thread pool

master
Francisco Paisana 5 years ago committed by Andre Puschmann
parent c413fadea9
commit 6db0e474be

@ -626,7 +626,8 @@ class gw_interface_stack : public gw_interface_nas, public gw_interface_rrc, pub
class stack_interface_mac
{
public:
virtual void process_pdus() = 0;
virtual void process_pdus() = 0;
virtual void wait_ra_completion(uint16_t rnti) = 0;
};
// Combined interface for PHY to access stack (MAC and RRC)

@ -283,8 +283,9 @@ void phy::configure_mbsfn(sib_type2_s* sib2, sib_type13_r9_s* sib13, mcch_msg_s
}
// Start GUI
void phy::start_plot() {
((sf_worker)workers[0]).start_plot();
void phy::start_plot()
{
((sf_worker*)&workers[0])->start_plot();
}
}
} // namespace srsenb

@ -102,7 +102,9 @@ public:
void get_rntis(ue_rnti_t* rntis);
void set_ho_rnti(uint16_t crnti, uint16_t target_pci);
/*********** interface for stack ******************/
void process_pdus();
void notify_ra_completed();
void start_pcap(srslte::mac_pcap* pcap);

@ -75,7 +75,8 @@ public:
mac_interface_rrc::ue_rnti_t* rntis,
srslte::timers::timer* time_alignment_timer_,
srslte::timers::timer* contention_resolution_timer_,
mux* mux_unit);
mux* mux_unit,
stack_interface_mac* stack_);
void reset();
@ -98,6 +99,8 @@ public:
bool contention_resolution_id_received(uint64_t uecri);
void start_pcap(srslte::mac_pcap* pcap);
void notify_ra_completed();
private:
void state_pdcch_setup();
void state_response_reception(uint32_t tti);
@ -143,7 +146,15 @@ private:
srslte_softbuffer_rx_t softbuffer_rar;
enum { IDLE = 0, PDCCH_SETUP, RESPONSE_RECEPTION, BACKOFF_WAIT, CONTENTION_RESOLUTION, COMPLETITION } state;
enum {
IDLE = 0,
PDCCH_SETUP,
RESPONSE_RECEPTION,
BACKOFF_WAIT,
CONTENTION_RESOLUTION,
START_WAIT_COMPLETION,
WAITING_COMPLETION
} state;
typedef enum { RA_GROUP_A, RA_GROUP_B } ra_group_t;
@ -155,12 +166,13 @@ private:
phy_interface_mac_lte* phy_h;
srslte::log* log_h;
mux *mux_unit;
srslte::mac_pcap *pcap;
rrc_interface_mac *rrc;
mux* mux_unit;
srslte::mac_pcap* pcap;
rrc_interface_mac* rrc;
stack_interface_mac* stack;
srslte::timers::timer *time_alignment_timer;
srslte::timers::timer *contention_resolution_timer;
srslte::timers::timer* time_alignment_timer;
srslte::timers::timer* contention_resolution_timer;
mac_interface_rrc::ue_rnti_t *rntis;

@ -42,6 +42,7 @@
#include "srslte/common/buffer_pool.h"
#include "srslte/common/log_filter.h"
#include "srslte/common/multiqueue.h"
#include "srslte/common/thread_pool.h"
#include "srslte/interfaces/ue_interfaces.h"
#include "srsue/hdr/ue_metrics_interface.h"
@ -114,6 +115,7 @@ public:
// Interface to upper MAC
void process_pdus() final;
void wait_ra_completion(uint16_t rnti) final;
private:
void run_thread() final;
@ -163,6 +165,7 @@ private:
};
srslte::multiqueue_handler<task_t> pending_tasks;
int sync_queue_id = -1, ue_queue_id = -1, gw_queue_id = -1, mac_queue_id = -1;
srslte::task_thread_pool background_tasks; ///< Thread pool used for long, low-priority tasks
};
} // namespace srsue

@ -84,8 +84,14 @@ bool mac::init(phy_interface_mac_lte* phy,
phr_procedure.init(phy_h, log_h, timers);
mux_unit.init(rlc_h, &bsr_procedure, &phr_procedure);
demux_unit.init(phy_h, rlc_h, this, timers->get(timer_alignment));
ra_procedure.init(
phy_h, rrc, log_h, &uernti, timers->get(timer_alignment), timers->get(contention_resolution_timer), &mux_unit);
ra_procedure.init(phy_h,
rrc,
log_h,
&uernti,
timers->get(timer_alignment),
timers->get(contention_resolution_timer),
&mux_unit,
stack_h);
sr_procedure.init(phy_h, rrc, log_h);
// Create UL/DL unique HARQ pointers
@ -467,6 +473,11 @@ void mac::process_pdus()
}
}
void mac::notify_ra_completed()
{
ra_procedure.notify_ra_completed();
}
uint32_t mac::get_current_tti()
{
return phy_h->get_current_tti();

@ -35,11 +35,15 @@
/* Random access procedure as specified in Section 5.1 of 36.321 */
namespace srsue {
const char* state_str[6] = {
"RA: INIT: ", "RA: PDCCH: ", "RA: Rx: ", "RA: Backof: ", "RA: ConRes: ", "RA: Complt: "};
const char* state_str[] = {"RA: INIT: ",
"RA: PDCCH: ",
"RA: Rx: ",
"RA: Backof: ",
"RA: ConRes: ",
"RA: WaitComplt: ",
"RA: Complt: "};
#define rError(fmt, ...) Error("%s" fmt, state_str[state], ##__VA_ARGS__)
#define rInfo(fmt, ...) Info("%s" fmt, state_str[state], ##__VA_ARGS__)
@ -58,17 +62,19 @@ void ra_proc::init(phy_interface_mac_lte* phy_h_,
mac_interface_rrc::ue_rnti_t* rntis_,
srslte::timers::timer* time_alignment_timer_,
srslte::timers::timer* contention_resolution_timer_,
mux* mux_unit_)
mux* mux_unit_,
stack_interface_mac* stack_)
{
phy_h = phy_h_;
log_h = log_h_;
rntis = rntis_;
mux_unit = mux_unit_;
rrc = rrc_;
phy_h = phy_h_;
log_h = log_h_;
rntis = rntis_;
mux_unit = mux_unit_;
rrc = rrc_;
stack = stack_;
time_alignment_timer = time_alignment_timer_;
contention_resolution_timer = contention_resolution_timer_;
srslte_softbuffer_rx_init(&softbuffer_rar, 10);
reset();
@ -145,9 +151,12 @@ void ra_proc::step(uint32_t tti_)
case CONTENTION_RESOLUTION:
state_contention_resolution();
break;
case COMPLETITION:
case START_WAIT_COMPLETION:
state_completition();
break;
case WAITING_COMPLETION:
// do nothing, bc we are waiting for the phy to finish
break;
}
}
@ -227,7 +236,19 @@ void ra_proc::state_contention_resolution()
*/
void ra_proc::state_completition()
{
phy_h->set_crnti(rntis->crnti);
state = WAITING_COMPLETION;
stack->wait_ra_completion(rntis->crnti);
// phy_h->set_crnti(rntis->crnti);
// state = IDLE;
}
void ra_proc::notify_ra_completed()
{
if (state != WAITING_COMPLETION) {
rError("Received unexpected notification of RA completion\n");
} else {
rInfo("RA waiting procedure completed\n");
}
state = IDLE;
}
@ -501,10 +522,11 @@ void ra_proc::complete()
log_h->console("Random Access Complete. c-rnti=0x%x, ta=%d\n", rntis->crnti, current_ta);
rInfo("Random Access Complete. c-rnti=0x%x, ta=%d\n", rntis->crnti, current_ta);
state = COMPLETITION;
state = START_WAIT_COMPLETION;
}
void ra_proc::start_noncont(uint32_t preamble_index, uint32_t prach_mask) {
void ra_proc::start_noncont(uint32_t preamble_index, uint32_t prach_mask)
{
next_preamble_idx = preamble_index;
next_prach_mask = prach_mask;
noncontention_enabled = true;

@ -39,12 +39,15 @@ ue_stack_lte::ue_stack_lte() :
pdcp(&pdcp_log),
nas(&nas_log),
thread("STACK"),
pending_tasks(1024)
pending_tasks(1024),
background_tasks(2)
{
ue_queue_id = pending_tasks.add_queue();
sync_queue_id = pending_tasks.add_queue();
gw_queue_id = pending_tasks.add_queue();
mac_queue_id = pending_tasks.add_queue();
background_tasks.start();
}
ue_stack_lte::~ue_stack_lte()
@ -279,4 +282,13 @@ void ue_stack_lte::process_pdus()
pending_tasks.push(mac_queue_id, task_t{[this](task_t*) { mac.process_pdus(); }});
}
void ue_stack_lte::wait_ra_completion(uint16_t rnti)
{
background_tasks.push_task([this, rnti](uint32_t worker_id){
phy->set_crnti(rnti);
// signal MAC RA proc to go back to idle
mac.notify_ra_completed();
});
}
} // namespace srsue

@ -330,11 +330,21 @@ public:
class stack_dummy : public stack_interface_mac
{
public:
void init(mac* mac_) { mac_h = mac_; }
void init(mac* mac_, phy_interface_mac_lte* phy_)
{
mac_h = mac_;
phy_h = phy_;
}
void process_pdus() final { mac_h->process_pdus(); }
void wait_ra_completion(uint16_t rnti) final
{
phy_h->set_crnti(rnti);
mac_h->notify_ra_completed();
}
private:
mac* mac_h = nullptr;
phy_interface_mac_lte* phy_h;
mac* mac_h = nullptr;
};
} // namespace srslte
@ -376,7 +386,7 @@ int mac_unpack_test()
// the actual MAC
mac mac(&mac_log);
stack.init(&mac);
stack.init(&mac, &phy);
mac.init(&phy, &rlc, &rrc, &timers, &stack);
// create dummy DL action and grant and push MAC PDU
@ -435,7 +445,7 @@ int mac_ul_sch_pdu_test1()
// the actual MAC
mac mac(&mac_log);
stack.init(&mac);
stack.init(&mac, &phy);
mac.init(&phy, &rlc, &rrc, &timers, &stack);
const uint16_t crnti = 0x1001;
mac.set_ho_rnti(crnti, 0);
@ -505,7 +515,7 @@ int mac_ul_logical_channel_prioritization_test1()
// the actual MAC
mac mac(&mac_log);
stack.init(&mac);
stack.init(&mac, &phy);
mac.init(&phy, &rlc, &rrc, &timers, &stack);
const uint16_t crnti = 0x1001;
mac.set_ho_rnti(crnti, 0);
@ -620,7 +630,7 @@ int mac_ul_logical_channel_prioritization_test2()
// the actual MAC
mac mac(&mac_log);
stack.init(&mac);
stack.init(&mac, &phy);
mac.init(&phy, &rlc, &rrc, &timers, &stack);
const uint16_t crnti = 0x1001;
mac.set_ho_rnti(crnti, 0);
@ -722,7 +732,7 @@ int mac_ul_logical_channel_prioritization_test3()
// the actual MAC
mac mac(&mac_log);
stack.init(&mac);
stack.init(&mac, &phy);
mac.init(&phy, &rlc, &rrc, &timers, &stack);
const uint16_t crnti = 0x1001;
mac.set_ho_rnti(crnti, 0);
@ -812,7 +822,7 @@ int mac_ul_sch_pdu_with_short_bsr_test()
// the actual MAC
mac mac(&mac_log);
stack.init(&mac);
stack.init(&mac, &phy);
mac.init(&phy, &rlc, &rrc, &timers, &stack);
const uint16_t crnti = 0x1001;
mac.set_ho_rnti(crnti, 0);
@ -900,7 +910,7 @@ int mac_ul_sch_pdu_with_padding_bsr_test()
// the actual MAC
mac mac(&mac_log);
stack.init(&mac);
stack.init(&mac, &phy);
mac.init(&phy, &rlc, &rrc, &timers, &stack);
const uint16_t crnti = 0x1001;
mac.set_ho_rnti(crnti, 0);
@ -997,7 +1007,7 @@ int mac_ul_sch_pdu_one_byte_test()
// the actual MAC
mac mac(&mac_log);
stack.init(&mac);
stack.init(&mac, &phy);
mac.init(&phy, &rlc, &rrc, &timers, &stack);
const uint16_t crnti = 0x1001;
mac.set_ho_rnti(crnti, 0);
@ -1059,7 +1069,7 @@ int mac_ul_sch_pdu_two_byte_test()
// the actual MAC
mac mac(&mac_log);
stack.init(&mac);
stack.init(&mac, &phy);
mac.init(&phy, &rlc, &rrc, &timers, &stack);
const uint16_t crnti = 0x1001;
mac.set_ho_rnti(crnti, 0);
@ -1121,7 +1131,7 @@ int mac_ul_sch_pdu_three_byte_test()
// the actual MAC
mac mac(&mac_log);
stack.init(&mac);
stack.init(&mac, &phy);
mac.init(&phy, &rlc, &rrc, &timers, &stack);
const uint16_t crnti = 0x1001;
mac.set_ho_rnti(crnti, 0);
@ -1376,7 +1386,7 @@ int mac_random_access_test()
// Configure MAC
mac mac(&mac_log);
stack.init(&mac);
stack.init(&mac, &phy);
mac.init(&phy, &rlc, &rrc, &timers, &stack);
srslte::mac_cfg_t mac_cfg;
set_mac_cfg_t_rach_cfg_common(&mac_cfg, rach_cfg);

Loading…
Cancel
Save