mirror of https://github.com/PentHertz/srsLTE.git
removal of srslte::timers class
This commit is contained in:
parent
9ae5563331
commit
8440126d35
|
@ -102,17 +102,6 @@ public:
|
|||
// bool do_rohc;
|
||||
};
|
||||
|
||||
class mac_interface_timers
|
||||
{
|
||||
public:
|
||||
/* Timer services with ms resolution.
|
||||
* timer_id must be lower than MAC_NOF_UPPER_TIMERS
|
||||
*/
|
||||
virtual timers::timer* timer_get(uint32_t timer_id) = 0;
|
||||
virtual void timer_release_id(uint32_t timer_id) = 0;
|
||||
virtual uint32_t timer_get_unique_id() = 0;
|
||||
};
|
||||
|
||||
class read_pdu_interface
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -48,151 +48,6 @@ public:
|
|||
virtual void timer_expired(uint32_t timer_id) = 0;
|
||||
};
|
||||
|
||||
class timers
|
||||
{
|
||||
public:
|
||||
class timer
|
||||
{
|
||||
public:
|
||||
timer(uint32_t id_ = 0)
|
||||
{
|
||||
id = id_;
|
||||
counter = 0;
|
||||
timeout = 0;
|
||||
running = false;
|
||||
callback = nullptr;
|
||||
}
|
||||
|
||||
void set(timer_callback* callback_, uint32_t timeout_)
|
||||
{
|
||||
callback = callback_;
|
||||
timeout = timeout_;
|
||||
reset();
|
||||
}
|
||||
|
||||
bool is_running() { return (counter < timeout) && running; }
|
||||
|
||||
bool is_expired() { return (timeout > 0) && (counter >= timeout); }
|
||||
|
||||
uint32_t get_timeout() { return timeout; }
|
||||
|
||||
void reset() { counter = 0; }
|
||||
|
||||
uint32_t value() { return counter; }
|
||||
|
||||
void step()
|
||||
{
|
||||
if (running) {
|
||||
counter++;
|
||||
if (is_expired()) {
|
||||
running = false;
|
||||
if (callback) {
|
||||
callback->timer_expired(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void stop() { running = false; }
|
||||
|
||||
void run() { running = true; }
|
||||
|
||||
uint32_t id;
|
||||
|
||||
private:
|
||||
timer_callback* callback;
|
||||
uint32_t timeout;
|
||||
uint32_t counter;
|
||||
bool running;
|
||||
};
|
||||
|
||||
timers(uint32_t nof_timers_) : timer_list(nof_timers_), used_timers(nof_timers_)
|
||||
{
|
||||
nof_timers = nof_timers_;
|
||||
next_timer = 0;
|
||||
nof_used_timers = 0;
|
||||
for (uint32_t i = 0; i < nof_timers; i++) {
|
||||
timer_list[i].id = i;
|
||||
used_timers[i] = false;
|
||||
}
|
||||
}
|
||||
|
||||
void step_all()
|
||||
{
|
||||
for (uint32_t i = 0; i < nof_timers; i++) {
|
||||
get(i)->step();
|
||||
}
|
||||
}
|
||||
|
||||
void stop_all()
|
||||
{
|
||||
for (uint32_t i = 0; i < nof_timers; i++) {
|
||||
get(i)->stop();
|
||||
}
|
||||
}
|
||||
|
||||
void run_all()
|
||||
{
|
||||
for (uint32_t i = 0; i < nof_timers; i++) {
|
||||
get(i)->run();
|
||||
}
|
||||
}
|
||||
|
||||
void reset_all()
|
||||
{
|
||||
for (uint32_t i = 0; i < nof_timers; i++) {
|
||||
get(i)->reset();
|
||||
}
|
||||
}
|
||||
|
||||
timer* get(uint32_t i)
|
||||
{
|
||||
if (i < nof_timers) {
|
||||
return &timer_list[i];
|
||||
} else {
|
||||
printf("Error accessing invalid timer %d (Only %d timers available)\n", i, nof_timers);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void release_id(uint32_t i)
|
||||
{
|
||||
if (nof_used_timers > 0 && i < nof_timers) {
|
||||
used_timers[i] = false;
|
||||
nof_used_timers--;
|
||||
} else {
|
||||
ERROR("Error releasing timer id=%d: nof_used_timers=%d, nof_timers=%d\n", i, nof_used_timers, nof_timers);
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t get_unique_id()
|
||||
{
|
||||
if (nof_used_timers >= nof_timers) {
|
||||
ERROR("Error getting unique timer id: no more timers available\n");
|
||||
return 0;
|
||||
} else {
|
||||
for (uint32_t i = 0; i < nof_timers; i++) {
|
||||
if (!used_timers[i]) {
|
||||
used_timers[i] = true;
|
||||
nof_used_timers++;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
ERROR("Error getting unique timer id: no more timers available but nof_used_timers=%d, nof_timers=%d\n",
|
||||
nof_used_timers,
|
||||
nof_timers);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
uint32_t next_timer;
|
||||
uint32_t nof_used_timers;
|
||||
uint32_t nof_timers;
|
||||
std::vector<timer> timer_list;
|
||||
std::vector<bool> used_timers;
|
||||
};
|
||||
|
||||
class timer_handler
|
||||
{
|
||||
constexpr static uint32_t MAX_TIMER_DURATION = std::numeric_limits<uint32_t>::max() / 4;
|
||||
|
|
|
@ -44,11 +44,7 @@ public:
|
|||
virtual bool process_pdus() = 0;
|
||||
};
|
||||
|
||||
class mac : public mac_interface_phy_lte,
|
||||
public mac_interface_rlc,
|
||||
public mac_interface_rrc,
|
||||
public srslte::mac_interface_timers,
|
||||
public pdu_process_handler
|
||||
class mac : public mac_interface_phy_lte, public mac_interface_rlc, public mac_interface_rrc, public pdu_process_handler
|
||||
{
|
||||
public:
|
||||
mac();
|
||||
|
@ -104,16 +100,11 @@ public:
|
|||
int bearer_ue_cfg(uint16_t rnti, uint32_t lc_id, sched_interface::ue_bearer_cfg_t *cfg);
|
||||
int bearer_ue_rem(uint16_t rnti, uint32_t lc_id);
|
||||
int rlc_buffer_state(uint16_t rnti, uint32_t lc_id, uint32_t tx_queue, uint32_t retx_queue);
|
||||
|
||||
bool process_pdus();
|
||||
|
||||
// Interface for upper-layer timers
|
||||
srslte::timers::timer* timer_get(uint32_t timer_id);
|
||||
void timer_release_id(uint32_t timer_id);
|
||||
u_int32_t timer_get_unique_id();
|
||||
bool process_pdus();
|
||||
|
||||
uint32_t get_current_tti();
|
||||
void get_metrics(mac_metrics_t metrics[ENB_METRICS_MAX_USERS]);
|
||||
void get_metrics(mac_metrics_t metrics[ENB_METRICS_MAX_USERS]);
|
||||
void write_mcch(asn1::rrc::sib_type2_s* sib2, asn1::rrc::sib_type13_r9_s* sib13, asn1::rrc::mcch_msg_s* mcch);
|
||||
|
||||
private:
|
||||
|
@ -176,30 +167,31 @@ private:
|
|||
asn1::rrc::sib_type13_r9_s sib13;
|
||||
|
||||
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::timers timers_db;
|
||||
void setup_timers();
|
||||
|
||||
srslte::timer_handler timers_db;
|
||||
void setup_timers();
|
||||
|
||||
// pointer to MAC PCAP object
|
||||
srslte::mac_pcap* pcap;
|
||||
|
||||
|
||||
/* Class to run upper-layer timers with normal priority */
|
||||
class timer_thread : public thread {
|
||||
class timer_thread : public thread
|
||||
{
|
||||
public:
|
||||
timer_thread(mac* parent_, srslte::timers* t) : ttisync(10240), timers(t), running(false), parent(parent_), thread("MAC_TIMER") { start(); }
|
||||
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::timers *timers;
|
||||
srslte::timer_handler *timers;
|
||||
mac *parent;
|
||||
bool running;
|
||||
};
|
||||
timer_thread timers_thread;
|
||||
timer_thread timers_thread;
|
||||
|
||||
/* Class to process MAC PDUs from DEMUX unit */
|
||||
class pdu_process : public thread {
|
||||
|
|
|
@ -841,28 +841,6 @@ void mac::tti_clock()
|
|||
timers_thread.tti_clock();
|
||||
}
|
||||
|
||||
/********************************************************
|
||||
*
|
||||
* Interface for upper layer timers
|
||||
*
|
||||
*******************************************************/
|
||||
uint32_t mac::timer_get_unique_id()
|
||||
{
|
||||
return timers_db.get_unique_id();
|
||||
}
|
||||
|
||||
void mac::timer_release_id(uint32_t timer_id)
|
||||
{
|
||||
timers_db.release_id(timer_id);
|
||||
}
|
||||
|
||||
/* Front-end to upper-layer timers */
|
||||
srslte::timers::timer* mac::timer_get(uint32_t timer_id)
|
||||
{
|
||||
return timers_db.get(timer_id);
|
||||
}
|
||||
|
||||
|
||||
/********************************************************
|
||||
*
|
||||
* Class to run timers with normal priority
|
||||
|
|
|
@ -765,12 +765,6 @@ public:
|
|||
ue->new_tb(dl_grant, (const uint8_t*)pdu->msg);
|
||||
}
|
||||
|
||||
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(); }
|
||||
|
||||
void add_srb(uint32_t lcid, pdcp_config_t pdcp_config)
|
||||
|
@ -918,7 +912,7 @@ private:
|
|||
uint32_t prach_preamble_index = 0;
|
||||
uint16_t dl_rnti = 0;
|
||||
uint16_t crnti = TTCN3_CRNTI;
|
||||
srslte::timers timers;
|
||||
srslte::timer_handler timers;
|
||||
bool last_dl_ndi[2 * FDD_HARQ_DELAY_MS] = {};
|
||||
bool last_ul_ndi[2 * FDD_HARQ_DELAY_MS] = {};
|
||||
|
||||
|
|
Loading…
Reference in New Issue