removed threads from eNB MAC

master
Francisco Paisana 5 years ago
parent 151159e2c6
commit 73e06a0858

@ -94,8 +94,6 @@ public:
// Radio-Link status // Radio-Link status
virtual void rl_failure(uint16_t rnti) = 0; virtual void rl_failure(uint16_t rnti) = 0;
virtual void rl_ok(uint16_t rnti) = 0; virtual void rl_ok(uint16_t rnti) = 0;
virtual void tti_clock() = 0;
}; };
/* Interface MAC -> PHY */ /* Interface MAC -> PHY */
@ -313,6 +311,8 @@ public:
// Combined interface for PHY to access stack (MAC and RRC) // Combined interface for PHY to access stack (MAC and RRC)
class stack_interface_phy_lte : public mac_interface_phy_lte class stack_interface_phy_lte : public mac_interface_phy_lte
{ {
public:
virtual void tti_clock() = 0;
}; };
// Combined interface for stack (MAC and RRC) to access PHY // Combined interface for stack (MAC and RRC) to access PHY
@ -351,6 +351,13 @@ public:
virtual void add_gtpu_m1u_socket_handler(int fd) = 0; virtual void add_gtpu_m1u_socket_handler(int fd) = 0;
}; };
// STACK interface for MAC
class stack_interface_mac_lte
{
public:
virtual void process_pdus() = 0;
};
} // namespace srsenb } // namespace srsenb
#endif // SRSLTE_ENB_INTERFACES_H #endif // SRSLTE_ENB_INTERFACES_H

@ -47,6 +47,7 @@ class enb_stack_lte final : public enb_stack_base,
public stack_interface_phy_lte, public stack_interface_phy_lte,
public stack_interface_s1ap_lte, public stack_interface_s1ap_lte,
public stack_interface_gtpu_lte, public stack_interface_gtpu_lte,
public stack_interface_mac_lte,
public thread public thread
{ {
public: public:
@ -99,6 +100,9 @@ public:
void add_gtpu_s1u_socket_handler(int fd) override; void add_gtpu_s1u_socket_handler(int fd) override;
void add_gtpu_m1u_socket_handler(int fd) override; void add_gtpu_m1u_socket_handler(int fd) override;
/* Stack-MAC interface */
void process_pdus();
private: private:
static const int STACK_MAIN_THREAD_PRIO = -1; // Use default high-priority below UHD static const int STACK_MAIN_THREAD_PRIO = -1; // Use default high-priority below UHD
// thread loop // thread loop
@ -157,7 +161,7 @@ private:
void operator()() { func(this); } void operator()() { func(this); }
}; };
srslte::multiqueue_handler<task_t> pending_tasks; srslte::multiqueue_handler<task_t> pending_tasks;
int enb_queue_id = -1, sync_queue_id = -1, mme_queue_id = -1, gtpu_queue_id = -1; int enb_queue_id = -1, sync_queue_id = -1, mme_queue_id = -1, gtpu_queue_id = -1, mac_queue_id = -1;
}; };
} // namespace srsenb } // namespace srsenb

@ -22,29 +22,21 @@
#ifndef SRSENB_MAC_H #ifndef SRSENB_MAC_H
#define SRSENB_MAC_H #define SRSENB_MAC_H
#include <vector> #include "scheduler.h"
#include "scheduler_metric.h"
#include "srslte/common/log.h" #include "srslte/common/log.h"
#include "srslte/common/timers.h" #include "srslte/common/mac_pcap.h"
#include "srslte/interfaces/enb_interfaces.h"
#include "srslte/interfaces/sched_interface.h"
#include "srslte/common/tti_sync_cv.h"
#include "srslte/common/threads.h" #include "srslte/common/threads.h"
#include "srslte/common/tti_sync_cv.h" #include "srslte/common/tti_sync_cv.h"
#include "srslte/common/mac_pcap.h" #include "srslte/interfaces/enb_interfaces.h"
#include "scheduler.h"
#include "scheduler_metric.h"
#include "srslte/interfaces/enb_metrics_interface.h" #include "srslte/interfaces/enb_metrics_interface.h"
#include "srslte/interfaces/sched_interface.h"
#include "ue.h" #include "ue.h"
#include <vector>
namespace srsenb { namespace srsenb {
class pdu_process_handler class mac : public mac_interface_phy_lte, public mac_interface_rlc, public mac_interface_rrc
{
public:
virtual bool process_pdus() = 0;
};
class mac : public mac_interface_phy_lte, public mac_interface_rlc, public mac_interface_rrc, public pdu_process_handler
{ {
public: public:
mac(); mac();
@ -54,6 +46,7 @@ public:
phy_interface_stack_lte* phy, phy_interface_stack_lte* phy,
rlc_interface_mac* rlc, rlc_interface_mac* rlc,
rrc_interface_mac* rrc, rrc_interface_mac* rrc,
stack_interface_mac_lte* stack_,
srslte::log* log_h); srslte::log* log_h);
void stop(); void stop();
@ -82,7 +75,6 @@ public:
void build_mch_sched(uint32_t tbs); void build_mch_sched(uint32_t tbs);
void rl_failure(uint16_t rnti); void rl_failure(uint16_t rnti);
void rl_ok(uint16_t rnti); void rl_ok(uint16_t rnti);
void tti_clock();
/******** Interface from RRC (RRC -> MAC) ****************/ /******** Interface from RRC (RRC -> MAC) ****************/
/* Provides cell configuration including SIB periodicity, etc. */ /* Provides cell configuration including SIB periodicity, etc. */
@ -122,6 +114,7 @@ private:
phy_interface_stack_lte* phy_h; phy_interface_stack_lte* phy_h;
rlc_interface_mac* rlc_h; rlc_interface_mac* rlc_h;
rrc_interface_mac* rrc_h; rrc_interface_mac* rrc_h;
stack_interface_mac_lte* stack;
srslte::log* log_h; srslte::log* log_h;
srslte_cell_t cell; srslte_cell_t cell;
@ -169,46 +162,8 @@ private:
const static int mtch_payload_len = 10000; const static int mtch_payload_len = 10000;
uint8_t mtch_payload_buffer[mtch_payload_len]; uint8_t mtch_payload_buffer[mtch_payload_len];
/* Functions for MAC Timers */
srslte::timer_handler timers_db;
void setup_timers();
// pointer to MAC PCAP object // pointer to MAC PCAP object
srslte::mac_pcap* pcap; srslte::mac_pcap* pcap;
/* Class to run upper-layer timers with normal priority */
class timer_thread : public thread
{
public:
timer_thread(mac* parent_, srslte::timer_handler* t) : ttisync(10240), timers(t), running(false), parent(parent_), thread("MAC_TIMER") { start(); }
void tti_clock();
void stop();
private:
void run_thread();
srslte::tti_sync_cv ttisync;
srslte::timer_handler *timers;
mac *parent;
bool running;
};
timer_thread timers_thread;
/* Class to process MAC PDUs from DEMUX unit */
class pdu_process : public thread {
public:
pdu_process(pdu_process_handler *h);
void notify();
void stop();
private:
void run_thread();
bool running;
bool have_data;
pthread_mutex_t mutex;
pthread_cond_t cvar;
pdu_process_handler *handler;
};
pdu_process pdu_process_thread;
}; };
} // namespace srsenb } // namespace srsenb

@ -35,6 +35,7 @@ enb_stack_lte::enb_stack_lte(srslte::logger* logger_) : logger(logger_), pdcp(&p
sync_queue_id = pending_tasks.add_queue(); sync_queue_id = pending_tasks.add_queue();
mme_queue_id = pending_tasks.add_queue(); mme_queue_id = pending_tasks.add_queue();
gtpu_queue_id = pending_tasks.add_queue(); gtpu_queue_id = pending_tasks.add_queue();
mac_queue_id = pending_tasks.add_queue();
pool = byte_buffer_pool::get_instance(); pool = byte_buffer_pool::get_instance();
} }
@ -130,7 +131,7 @@ int enb_stack_lte::init(const stack_args_t& args_, const rrc_cfg_t& rrc_cfg_)
rx_sockets.reset(new srslte::rx_multisocket_handler("ENBSOCKETS", &stack_log)); rx_sockets.reset(new srslte::rx_multisocket_handler("ENBSOCKETS", &stack_log));
// 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, this, &mac_log);
rlc.init(&pdcp, &rrc, &mac, &timers, &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, &timers, &rrc_log); rrc.init(&rrc_cfg, phy, &mac, &rlc, &pdcp, &s1ap, &gtpu, &timers, &rrc_log);
@ -158,7 +159,6 @@ void enb_stack_lte::tti_clock()
void enb_stack_lte::tti_clock_impl() void enb_stack_lte::tti_clock_impl()
{ {
timers.step_all(); timers.step_all();
mac.tti_clock();
rrc.tti_clock(); rrc.tti_clock();
} }
@ -193,6 +193,7 @@ void enb_stack_lte::stop_impl()
pending_tasks.erase_queue(enb_queue_id); pending_tasks.erase_queue(enb_queue_id);
pending_tasks.erase_queue(mme_queue_id); pending_tasks.erase_queue(mme_queue_id);
pending_tasks.erase_queue(gtpu_queue_id); pending_tasks.erase_queue(gtpu_queue_id);
pending_tasks.erase_queue(mac_queue_id);
started = false; started = false;
} }
@ -261,4 +262,9 @@ void enb_stack_lte::add_gtpu_m1u_socket_handler(int fd)
rx_sockets->add_socket_pdu_handler(fd, gtpu_m1u_handler); rx_sockets->add_socket_pdu_handler(fd, gtpu_m1u_handler);
} }
void enb_stack_lte::process_pdus()
{
pending_tasks.push(mac_queue_id, task_t{[this](task_t*) { mac.process_pdus(); }});
}
} // namespace srsenb } // namespace srsenb

@ -38,9 +38,7 @@ using namespace asn1::rrc;
namespace srsenb { namespace srsenb {
mac::mac() : timers_db(128), timers_thread(this, &timers_db), last_rnti(0), mac::mac() : last_rnti(0), rar_pdu_msg(sched_interface::MAX_RAR_LIST), rar_payload()
rar_pdu_msg(sched_interface::MAX_RAR_LIST), rar_payload(),
pdu_process_thread(this)
{ {
started = false; started = false;
pcap = NULL; pcap = NULL;
@ -71,6 +69,7 @@ bool mac::init(const mac_args_t& args_,
phy_interface_stack_lte* phy, phy_interface_stack_lte* phy,
rlc_interface_mac* rlc, rlc_interface_mac* rlc,
rrc_interface_mac* rrc, rrc_interface_mac* rrc,
stack_interface_mac_lte* stack_,
srslte::log* log_h_) srslte::log* log_h_)
{ {
started = false; started = false;
@ -79,6 +78,7 @@ bool mac::init(const mac_args_t& args_,
phy_h = phy; phy_h = phy;
rlc_h = rlc; rlc_h = rlc;
rrc_h = rrc; rrc_h = rrc;
stack = stack_;
log_h = log_h_; log_h = log_h_;
args = args_; args = args_;
@ -122,8 +122,6 @@ void mac::stop()
srslte_softbuffer_tx_free(&pcch_softbuffer_tx); srslte_softbuffer_tx_free(&pcch_softbuffer_tx);
srslte_softbuffer_tx_free(&rar_softbuffer_tx); srslte_softbuffer_tx_free(&rar_softbuffer_tx);
started = false; started = false;
timers_thread.stop();
pdu_process_thread.stop();
} }
pthread_rwlock_unlock(&rwlock); pthread_rwlock_unlock(&rwlock);
} }
@ -133,8 +131,6 @@ void mac::reset()
{ {
Info("Resetting MAC\n"); Info("Resetting MAC\n");
timers_db.stop_all();
last_rnti = 70; last_rnti = 70;
/* Setup scheduler */ /* Setup scheduler */
@ -353,7 +349,7 @@ int mac::crc_info(uint32_t tti, uint16_t rnti, uint32_t nof_bytes, bool crc)
if (crc) { if (crc) {
Info("Pushing PDU rnti=%d, tti=%d, nof_bytes=%d\n", rnti, tti, nof_bytes); Info("Pushing PDU rnti=%d, tti=%d, nof_bytes=%d\n", rnti, tti, nof_bytes);
ue_db[rnti]->push_pdu(tti, nof_bytes); ue_db[rnti]->push_pdu(tti, nof_bytes);
pdu_process_thread.notify(); stack->process_pdus();
} else { } else {
ue_db[rnti]->deallocate_pdu(tti); ue_db[rnti]->deallocate_pdu(tti);
} }
@ -836,95 +832,12 @@ int mac::get_ul_sched(uint32_t tti, ul_sched_t *ul_sched_res)
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
} }
void mac::tti_clock()
{
timers_thread.tti_clock();
}
/********************************************************
*
* Class to run timers with normal priority
*
*******************************************************/
void mac::timer_thread::run_thread()
{
running = true;
ttisync.set_producer_cntr(0);
ttisync.resync();
while(running) {
ttisync.wait();
timers->step_all();
}
}
void mac::timer_thread::stop()
{
running = false;
ttisync.increase();
wait_thread_finish();
}
void mac::timer_thread::tti_clock()
{
ttisync.increase();
}
/********************************************************
*
* Class that runs a thread to process DL MAC PDUs from
* DEMUX unit
*
*******************************************************/
mac::pdu_process::pdu_process(pdu_process_handler* h) : running(false), thread("MAC_PDU_PROCESS")
{
handler = h;
pthread_mutex_init(&mutex, NULL);
pthread_cond_init(&cvar, NULL);
have_data = false;
start(MAC_PDU_THREAD_PRIO);
}
void mac::pdu_process::stop()
{
pthread_mutex_lock(&mutex);
running = false;
pthread_cond_signal(&cvar);
pthread_mutex_unlock(&mutex);
wait_thread_finish();
}
void mac::pdu_process::notify()
{
pthread_mutex_lock(&mutex);
have_data = true;
pthread_cond_signal(&cvar);
pthread_mutex_unlock(&mutex);
}
void mac::pdu_process::run_thread()
{
running = true;
while(running) {
have_data = handler->process_pdus();
if (!have_data) {
pthread_mutex_lock(&mutex);
while(!have_data && running) {
pthread_cond_wait(&cvar, &mutex);
}
pthread_mutex_unlock(&mutex);
}
}
}
bool mac::process_pdus() bool mac::process_pdus()
{ {
pthread_rwlock_rdlock(&rwlock); pthread_rwlock_rdlock(&rwlock);
bool ret = false; bool ret = false;
for (auto& u : ue_db) { for (auto& u : ue_db) {
ret = ret | u.second->process_pdus(); ret |= u.second->process_pdus();
} }
pthread_rwlock_unlock(&rwlock); pthread_rwlock_unlock(&rwlock);
return ret; return ret;

Loading…
Cancel
Save