mirror of https://github.com/PentHertz/srsLTE.git
simplified MAC timers. Unified mac and upper timers in same background task
This commit is contained in:
parent
5359c42b46
commit
6556941e6d
|
@ -71,9 +71,9 @@ public:
|
|||
/* Timer services with ms resolution.
|
||||
* timer_id must be lower than MAC_NOF_UPPER_TIMERS
|
||||
*/
|
||||
virtual timers::timer* get(uint32_t timer_id) = 0;
|
||||
virtual void free(uint32_t timer_id) = 0;
|
||||
virtual uint32_t get_unique_id() = 0;
|
||||
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
|
||||
|
|
|
@ -74,7 +74,7 @@ public:
|
|||
}
|
||||
void step() {
|
||||
if (running) {
|
||||
counter++;
|
||||
counter++;
|
||||
if (is_expired()) {
|
||||
running = false;
|
||||
if (callback) {
|
||||
|
|
|
@ -125,7 +125,8 @@ private:
|
|||
* Timers
|
||||
* Ref: 3GPP TS 36.322 v10.0.0 Section 7
|
||||
***************************************************************************/
|
||||
uint32_t reordering_timeout_id;
|
||||
srslte::timers::timer *reordering_timer;
|
||||
uint32_t reordering_timer_id;
|
||||
|
||||
bool pdu_lost;
|
||||
|
||||
|
|
|
@ -62,7 +62,8 @@ void rlc_um::init(srslte::log *log_,
|
|||
pdcp = pdcp_;
|
||||
rrc = rrc_;
|
||||
mac_timers = mac_timers_;
|
||||
reordering_timeout_id = mac_timers->get_unique_id();
|
||||
reordering_timer_id = mac_timers->timer_get_unique_id();
|
||||
reordering_timer = mac_timers->timer_get(reordering_timer_id);
|
||||
}
|
||||
|
||||
void rlc_um::configure(srslte_rlc_config_t cnfg_)
|
||||
|
@ -105,7 +106,7 @@ void rlc_um::empty_queue() {
|
|||
void rlc_um::stop()
|
||||
{
|
||||
reset();
|
||||
mac_timers->free(reordering_timeout_id);
|
||||
mac_timers->timer_release_id(reordering_timer_id);
|
||||
}
|
||||
|
||||
void rlc_um::reset()
|
||||
|
@ -125,7 +126,7 @@ void rlc_um::reset()
|
|||
if(tx_sdu)
|
||||
tx_sdu->reset();
|
||||
if(mac_timers)
|
||||
mac_timers->get(reordering_timeout_id)->stop();
|
||||
reordering_timer->stop();
|
||||
|
||||
// Drop all messages in RX window
|
||||
std::map<uint32_t, rlc_umd_pdu_t>::iterator it;
|
||||
|
@ -209,7 +210,7 @@ void rlc_um::write_pdu(uint8_t *payload, uint32_t nof_bytes)
|
|||
|
||||
void rlc_um::timer_expired(uint32_t timeout_id)
|
||||
{
|
||||
if(reordering_timeout_id == timeout_id)
|
||||
if(reordering_timer_id == timeout_id)
|
||||
{
|
||||
pthread_mutex_lock(&mutex);
|
||||
|
||||
|
@ -227,11 +228,11 @@ void rlc_um::timer_expired(uint32_t timeout_id)
|
|||
reassemble_rx_sdus();
|
||||
log->debug("Finished reassemble from timeout id=%d\n", timeout_id);
|
||||
}
|
||||
mac_timers->get(reordering_timeout_id)->stop();
|
||||
reordering_timer->stop();
|
||||
if(RX_MOD_BASE(vr_uh) > RX_MOD_BASE(vr_ur))
|
||||
{
|
||||
mac_timers->get(reordering_timeout_id)->set(this, cfg.t_reordering);
|
||||
mac_timers->get(reordering_timeout_id)->run();
|
||||
reordering_timer->set(this, cfg.t_reordering);
|
||||
reordering_timer->run();
|
||||
vr_ux = vr_uh;
|
||||
}
|
||||
|
||||
|
@ -242,7 +243,7 @@ void rlc_um::timer_expired(uint32_t timeout_id)
|
|||
|
||||
bool rlc_um::reordering_timeout_running()
|
||||
{
|
||||
return mac_timers->get(reordering_timeout_id)->is_running();
|
||||
return reordering_timer->is_running();
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -404,20 +405,20 @@ void rlc_um::handle_data_pdu(uint8_t *payload, uint32_t nof_bytes)
|
|||
log->debug("Finished reassemble from received PDU\n");
|
||||
|
||||
// Update reordering variables and timers
|
||||
if(mac_timers->get(reordering_timeout_id)->is_running())
|
||||
if(reordering_timer->is_running())
|
||||
{
|
||||
if(RX_MOD_BASE(vr_ux) <= RX_MOD_BASE(vr_ur) ||
|
||||
(!inside_reordering_window(vr_ux) && vr_ux != vr_uh))
|
||||
{
|
||||
mac_timers->get(reordering_timeout_id)->stop();
|
||||
reordering_timer->stop();
|
||||
}
|
||||
}
|
||||
if(!mac_timers->get(reordering_timeout_id)->is_running())
|
||||
if(!reordering_timer->is_running())
|
||||
{
|
||||
if(RX_MOD_BASE(vr_uh) > RX_MOD_BASE(vr_ur))
|
||||
{
|
||||
mac_timers->get(reordering_timeout_id)->set(this, cfg.t_reordering);
|
||||
mac_timers->get(reordering_timeout_id)->run();
|
||||
reordering_timer->set(this, cfg.t_reordering);
|
||||
reordering_timer->run();
|
||||
vr_ux = vr_uh;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,12 +38,12 @@ class mac_dummy_timers
|
|||
:public srslte::mac_interface_timers
|
||||
{
|
||||
public:
|
||||
srslte::timers::timer* get(uint32_t timer_id)
|
||||
srslte::timers::timer* timer_get(uint32_t timer_id)
|
||||
{
|
||||
return &t;
|
||||
}
|
||||
uint32_t get_unique_id(){return 0;}
|
||||
void free(uint32_t id){}
|
||||
uint32_t timer_get_unique_id(){return 0;}
|
||||
void timer_release_id(uint32_t id){}
|
||||
|
||||
private:
|
||||
srslte::timers::timer t;
|
||||
|
|
|
@ -38,16 +38,16 @@ class mac_dummy_timers
|
|||
:public srslte::mac_interface_timers
|
||||
{
|
||||
public:
|
||||
srslte::timers::timer* get(uint32_t timer_id)
|
||||
srslte::timers::timer* timer_get(uint32_t timer_id)
|
||||
{
|
||||
return &t;
|
||||
}
|
||||
uint32_t get_unique_id(){return 0;}
|
||||
uint32_t timer_get_unique_id(){return 0;}
|
||||
void step()
|
||||
{
|
||||
t.step();
|
||||
}
|
||||
void free(uint32_t timer_id) {}
|
||||
void timer_release_id(uint32_t timer_id) {}
|
||||
private:
|
||||
srslte::timers::timer t;
|
||||
};
|
||||
|
@ -205,8 +205,8 @@ void loss_test()
|
|||
}
|
||||
|
||||
// Step the reordering timer until expiry
|
||||
while(!timers.get(1)->is_expired())
|
||||
timers.get(1)->step();
|
||||
while(!timers.timer_get(1)->is_expired())
|
||||
timers.timer_get(1)->step();
|
||||
|
||||
assert(NBUFS-1 == tester.n_sdus);
|
||||
}
|
||||
|
|
|
@ -102,14 +102,11 @@ public:
|
|||
int rlc_buffer_state(uint16_t rnti, uint32_t lc_id, uint32_t tx_queue, uint32_t retx_queue);
|
||||
|
||||
bool process_pdus();
|
||||
|
||||
void timer_expired(uint32_t timer_id);
|
||||
|
||||
srslte::timers::timer* get(uint32_t timer_id);
|
||||
void free(uint32_t timer_id);
|
||||
u_int32_t get_unique_id();
|
||||
|
||||
const static int NOF_MAC_TIMERS = 20;
|
||||
// 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();
|
||||
|
||||
uint32_t get_current_tti();
|
||||
void get_metrics(mac_metrics_t metrics[ENB_METRICS_MAX_USERS]);
|
||||
|
@ -182,22 +179,18 @@ private:
|
|||
|
||||
|
||||
/* Class to run upper-layer timers with normal priority */
|
||||
class upper_timers : public thread {
|
||||
public:
|
||||
upper_timers() : timers_db(NOF_MAC_TIMERS),ttisync(10240) {start();}
|
||||
class timer_thread : public thread {
|
||||
public:
|
||||
timer_thread(srslte::timers *t) : ttisync(10240),timers(t),running(false) {start();}
|
||||
void tti_clock();
|
||||
void stop();
|
||||
void reset();
|
||||
srslte::timers::timer* get(uint32_t timer_id);
|
||||
void free(uint32_t timer_id);
|
||||
uint32_t get_unique_id();
|
||||
private:
|
||||
void run_thread();
|
||||
srslte::timers timers_db;
|
||||
srslte::tti_sync_cv ttisync;
|
||||
srslte::timers *timers;
|
||||
bool running;
|
||||
};
|
||||
upper_timers upper_timers_thread;
|
||||
timer_thread timers_thread;
|
||||
|
||||
/* Class to process MAC PDUs from DEMUX unit */
|
||||
class pdu_process : public thread {
|
||||
|
|
|
@ -42,7 +42,8 @@
|
|||
|
||||
namespace srsenb {
|
||||
|
||||
mac::mac() : timers_db((uint32_t) NOF_MAC_TIMERS),
|
||||
mac::mac() : timers_db(128),
|
||||
timers_thread(&timers_db),
|
||||
rar_pdu_msg(sched_interface::MAX_RAR_LIST),
|
||||
pdu_process_thread(this)
|
||||
{
|
||||
|
@ -99,7 +100,7 @@ void mac::stop()
|
|||
srslte_softbuffer_tx_free(&pcch_softbuffer_tx);
|
||||
srslte_softbuffer_tx_free(&rar_softbuffer_tx);
|
||||
started = false;
|
||||
upper_timers_thread.stop();
|
||||
timers_thread.stop();
|
||||
pdu_process_thread.stop();
|
||||
}
|
||||
|
||||
|
@ -109,8 +110,7 @@ void mac::reset()
|
|||
Info("Resetting MAC\n");
|
||||
|
||||
timers_db.stop_all();
|
||||
upper_timers_thread.reset();
|
||||
|
||||
|
||||
tti = 0;
|
||||
last_rnti = 70;
|
||||
|
||||
|
@ -119,23 +119,6 @@ void mac::reset()
|
|||
|
||||
}
|
||||
|
||||
uint32_t mac::get_unique_id()
|
||||
{
|
||||
return upper_timers_thread.get_unique_id();
|
||||
}
|
||||
|
||||
void mac::free(uint32_t timer_id)
|
||||
{
|
||||
upper_timers_thread.free(timer_id);
|
||||
}
|
||||
|
||||
/* Front-end to upper-layer timers */
|
||||
srslte::timers::timer* mac::get(uint32_t timer_id)
|
||||
{
|
||||
return upper_timers_thread.get(timer_id);
|
||||
}
|
||||
|
||||
|
||||
void mac::start_pcap(srslte::mac_pcap* pcap_)
|
||||
{
|
||||
pcap = pcap_;
|
||||
|
@ -645,57 +628,59 @@ void mac::log_step_dl(uint32_t tti)
|
|||
|
||||
void mac::tti_clock()
|
||||
{
|
||||
upper_timers_thread.tti_clock();
|
||||
timers_thread.tti_clock();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/********************************************************
|
||||
*
|
||||
* Class to run upper-layer timers with normal priority
|
||||
* Interface for upper layer timers
|
||||
*
|
||||
*******************************************************/
|
||||
void mac::upper_timers::run_thread()
|
||||
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
|
||||
*
|
||||
*******************************************************/
|
||||
void mac::timer_thread::run_thread()
|
||||
{
|
||||
running=true;
|
||||
ttisync.set_producer_cntr(0);
|
||||
ttisync.resync();
|
||||
while(running) {
|
||||
ttisync.wait();
|
||||
timers_db.step_all();
|
||||
timers->step_all();
|
||||
}
|
||||
}
|
||||
|
||||
void mac::upper_timers::free(uint32_t timer_id)
|
||||
{
|
||||
timers_db.release_id(timer_id);
|
||||
}
|
||||
|
||||
srslte::timers::timer* mac::upper_timers::get(uint32_t timer_id)
|
||||
{
|
||||
if (timer_id < NOF_MAC_TIMERS) {
|
||||
return timers_db.get(timer_id);
|
||||
} else {
|
||||
fprintf(stderr, "Error requested invalid timer id=%d\n", timer_id);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t mac::upper_timers::get_unique_id()
|
||||
{
|
||||
return timers_db.get_unique_id();
|
||||
}
|
||||
|
||||
void mac::upper_timers::stop()
|
||||
void mac::timer_thread::stop()
|
||||
{
|
||||
running=false;
|
||||
ttisync.increase();
|
||||
wait_thread_finish();
|
||||
}
|
||||
void mac::upper_timers::reset()
|
||||
{
|
||||
timers_db.stop_all();
|
||||
}
|
||||
|
||||
void mac::upper_timers::tti_clock()
|
||||
void mac::timer_thread::tti_clock()
|
||||
{
|
||||
ttisync.increase();
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ class demux : public srslte::pdu_queue::process_callback
|
|||
{
|
||||
public:
|
||||
demux(uint8_t nof_harq_proc_);
|
||||
void init(phy_interface_mac_common* phy_h_, rlc_interface_mac *rlc, srslte::log* log_h_, srslte::timers* timers_db_);
|
||||
void init(phy_interface_mac_common* phy_h_, rlc_interface_mac *rlc, srslte::log* log_h_, srslte::timers::timer* time_alignment_timer);
|
||||
|
||||
bool process_pdus();
|
||||
uint8_t* request_buffer(uint32_t pid, uint32_t len);
|
||||
|
@ -74,7 +74,7 @@ private:
|
|||
|
||||
phy_interface_mac_common *phy_h;
|
||||
srslte::log *log_h;
|
||||
srslte::timers *timers_db;
|
||||
srslte::timers::timer *time_alignment_timer;
|
||||
rlc_interface_mac *rlc;
|
||||
uint8_t nof_harq_proc;
|
||||
|
||||
|
|
|
@ -35,7 +35,6 @@
|
|||
#include "srslte/common/log.h"
|
||||
#include "srslte/common/timers.h"
|
||||
#include "mac/demux.h"
|
||||
#include "mac/mac_common.h"
|
||||
#include "mac/dl_sps.h"
|
||||
#include "srslte/common/mac_pcap.h"
|
||||
|
||||
|
@ -58,9 +57,9 @@ public:
|
|||
pcap = NULL;
|
||||
}
|
||||
|
||||
bool init(srslte::log *log_h_, srslte::timers *timers_, demux *demux_unit_)
|
||||
bool init(srslte::log *log_h_, srslte::timers::timer *timer_aligment_timer_, demux *demux_unit_)
|
||||
{
|
||||
timers_db = timers_;
|
||||
timer_aligment_timer = timer_aligment_timer_;
|
||||
demux_unit = demux_unit_;
|
||||
si_window_start = 0;
|
||||
log_h = log_h_;
|
||||
|
@ -102,7 +101,7 @@ public:
|
|||
} else {
|
||||
if (grant.is_sps_release) {
|
||||
dl_sps_assig.clear();
|
||||
if (timers_db->get(TIME_ALIGNMENT)->is_running()) {
|
||||
if (timer_aligment_timer->is_running()) {
|
||||
//phy_h->send_sps_ack();
|
||||
Warning("PHY Send SPS ACK not implemented\n");
|
||||
}
|
||||
|
@ -282,7 +281,7 @@ private:
|
|||
Warning("DL PID %d: Received duplicate TB. Discarting and retransmitting ACK\n", pid);
|
||||
}
|
||||
|
||||
if (pid == HARQ_BCCH_PID || harq_entity->timers_db->get(TIME_ALIGNMENT)->is_expired()) {
|
||||
if (pid == HARQ_BCCH_PID || harq_entity->timer_aligment_timer->is_expired()) {
|
||||
// Do not generate ACK
|
||||
Debug("Not generating ACK\n");
|
||||
action->generate_ack = false;
|
||||
|
@ -397,7 +396,7 @@ private:
|
|||
|
||||
|
||||
std::vector<dl_harq_process> proc;
|
||||
srslte::timers *timers_db;
|
||||
srslte::timers::timer *timer_aligment_timer;
|
||||
demux *demux_unit;
|
||||
srslte::log *log_h;
|
||||
srslte::mac_pcap *pcap;
|
||||
|
|
|
@ -48,9 +48,9 @@ namespace srsue {
|
|||
class mac
|
||||
:public mac_interface_phy
|
||||
,public mac_interface_rrc
|
||||
,public srslte::timer_callback
|
||||
,public srslte::mac_interface_timers
|
||||
,public thread
|
||||
,public srslte::timer_callback
|
||||
{
|
||||
public:
|
||||
mac();
|
||||
|
@ -90,17 +90,19 @@ public:
|
|||
void set_contention_id(uint64_t uecri);
|
||||
|
||||
void get_rntis(ue_rnti_t *rntis);
|
||||
|
||||
void timer_expired(uint32_t timer_id);
|
||||
|
||||
void start_pcap(srslte::mac_pcap* pcap);
|
||||
|
||||
srslte::timers::timer* get(uint32_t timer_id);
|
||||
void free(uint32_t timer_id);
|
||||
u_int32_t get_unique_id();
|
||||
// Timer callback interface
|
||||
void timer_expired(uint32_t timer_id);
|
||||
|
||||
uint32_t get_current_tti();
|
||||
|
||||
static const int MAC_NOF_UPPER_TIMERS = 20;
|
||||
|
||||
// Interface for upper-layer timers
|
||||
srslte::timers::timer* timer_get(uint32_t timer_id);
|
||||
void timer_release_id(uint32_t timer_id);
|
||||
uint32_t timer_get_unique_id();
|
||||
|
||||
|
||||
private:
|
||||
void run_thread();
|
||||
|
@ -145,13 +147,32 @@ private:
|
|||
/* Buffers for PCH reception (not included in DL HARQ) */
|
||||
const static uint32_t pch_payload_buffer_sz = 8*1024;
|
||||
srslte_softbuffer_rx_t pch_softbuffer;
|
||||
uint8_t pch_payload_buffer[pch_payload_buffer_sz];
|
||||
|
||||
uint8_t pch_payload_buffer[pch_payload_buffer_sz];
|
||||
|
||||
|
||||
/* class that runs a thread to trigger timer callbacks in low priority */
|
||||
class timer_thread : public thread {
|
||||
public:
|
||||
timer_thread(srslte::timers *timers_) : ttisync(10240),running(false),timers(timers_) {start();}
|
||||
void tti_clock();
|
||||
void stop();
|
||||
private:
|
||||
bool running;
|
||||
void run_thread();
|
||||
srslte::tti_sync_cv ttisync;
|
||||
srslte::timers *timers;
|
||||
};
|
||||
|
||||
|
||||
/* Functions for MAC Timers */
|
||||
srslte::timers timers_db;
|
||||
uint32_t timer_alignment;
|
||||
uint32_t contention_resolution_timer;
|
||||
void setup_timers();
|
||||
void timeAlignmentTimerExpire();
|
||||
|
||||
void timer_alignment_expire();
|
||||
srslte::timers timers;
|
||||
timer_thread timers_thread;
|
||||
|
||||
|
||||
// pointer to MAC PCAP object
|
||||
srslte::mac_pcap* pcap;
|
||||
bool is_first_ul_grant;
|
||||
|
@ -159,23 +180,6 @@ private:
|
|||
|
||||
mac_metrics_t metrics;
|
||||
|
||||
|
||||
/* Class to run upper-layer timers with normal priority */
|
||||
class upper_timers : public periodic_thread {
|
||||
public:
|
||||
upper_timers();
|
||||
void reset();
|
||||
void free(uint32_t timer_id);
|
||||
srslte::timers::timer* get(uint32_t timer_id);
|
||||
uint32_t get_unique_id();
|
||||
private:
|
||||
void run_period();
|
||||
srslte::timers timers_db;
|
||||
};
|
||||
upper_timers upper_timers_thread;
|
||||
|
||||
|
||||
|
||||
/* Class to process MAC PDUs from DEMUX unit */
|
||||
class pdu_process : public thread {
|
||||
public:
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* \section COPYRIGHT
|
||||
*
|
||||
* Copyright 2013-2015 Software Radio Systems Limited
|
||||
*
|
||||
* \section LICENSE
|
||||
*
|
||||
* This file is part of the srsUE library.
|
||||
*
|
||||
* srsUE is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* srsUE is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* A copy of the GNU Affero General Public License can be found in
|
||||
* the LICENSE file in the top-level directory of this distribution
|
||||
* and at http://www.gnu.org/licenses/.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MAC_COMMON_H
|
||||
#define MAC_COMMON_H
|
||||
|
||||
namespace srsue {
|
||||
|
||||
typedef enum {
|
||||
HARQ_RTT,
|
||||
TIME_ALIGNMENT,
|
||||
CONTENTION_TIMER,
|
||||
BSR_TIMER_PERIODIC,
|
||||
BSR_TIMER_RETX,
|
||||
PHR_TIMER_PERIODIC,
|
||||
PHR_TIMER_PROHIBIT,
|
||||
NOF_MAC_TIMERS
|
||||
} mac_timers_t;
|
||||
|
||||
} // namespace srsue
|
||||
|
||||
#endif // MAC_COMMON_H
|
|
@ -81,6 +81,9 @@ private:
|
|||
bool generate_bsr(bsr_t *bsr, uint32_t nof_padding_bytes);
|
||||
char* bsr_type_tostring(triggered_bsr_type_t type);
|
||||
char* bsr_format_tostring(bsr_format_t format);
|
||||
|
||||
uint32_t timer_periodic_id;
|
||||
uint32_t timer_retx_id;
|
||||
};
|
||||
|
||||
} // namespace srsue
|
||||
|
|
|
@ -49,7 +49,9 @@ public:
|
|||
|
||||
bool generate_phr_on_ul_grant(float *phr);
|
||||
void timer_expired(uint32_t timer_id);
|
||||
|
||||
|
||||
void start_timer();
|
||||
|
||||
private:
|
||||
|
||||
bool pathloss_changed();
|
||||
|
@ -59,11 +61,15 @@ private:
|
|||
phy_interface_mac* phy_h;
|
||||
srslte::timers* timers_db;
|
||||
bool initiated;
|
||||
int timer_prohibit;
|
||||
int timer_periodic;
|
||||
int timer_prohibit_value;
|
||||
int timer_periodic_value;
|
||||
int dl_pathloss_change;
|
||||
int last_pathloss_db;
|
||||
bool phr_is_triggered;
|
||||
|
||||
uint32_t timer_periodic_id;
|
||||
uint32_t timer_prohibit_id;
|
||||
|
||||
};
|
||||
|
||||
} // namespace srsue
|
||||
|
|
|
@ -59,8 +59,7 @@ class ra_proc : public srslte::timer_callback
|
|||
phy_h = NULL;
|
||||
log_h = NULL;
|
||||
mac_cfg = NULL;
|
||||
timers_db = NULL;
|
||||
mux_unit = NULL;
|
||||
mux_unit = NULL;
|
||||
demux_unit = NULL;
|
||||
rrc = NULL;
|
||||
transmitted_contention_id = 0;
|
||||
|
@ -69,7 +68,10 @@ class ra_proc : public srslte::timer_callback
|
|||
started_by_pdcch = false;
|
||||
rar_grant_nbytes = 0;
|
||||
rar_grant_tti = 0;
|
||||
msg3_flushed = false;
|
||||
msg3_flushed = false;
|
||||
|
||||
time_alignment_timer = NULL;
|
||||
contention_resolution_timer = NULL;
|
||||
};
|
||||
|
||||
~ra_proc();
|
||||
|
@ -78,8 +80,9 @@ class ra_proc : public srslte::timer_callback
|
|||
rrc_interface_mac *rrc_,
|
||||
srslte::log *log_h,
|
||||
mac_interface_rrc::ue_rnti_t *rntis,
|
||||
mac_interface_rrc::mac_cfg_t *mac_cfg,
|
||||
srslte::timers *timers_db,
|
||||
mac_interface_rrc::mac_cfg_t *mac_cfg,
|
||||
srslte::timers::timer* time_alignment_timer_,
|
||||
srslte::timers::timer* contention_resolution_timer_,
|
||||
mux *mux_unit,
|
||||
demux *demux_unit);
|
||||
void reset();
|
||||
|
@ -101,9 +104,9 @@ class ra_proc : public srslte::timer_callback
|
|||
void start_pcap(srslte::mac_pcap* pcap);
|
||||
private:
|
||||
static bool uecrid_callback(void *arg, uint64_t uecri);
|
||||
|
||||
|
||||
bool contention_resolution_id_received(uint64_t uecri);
|
||||
void process_timeadv_cmd(uint32_t ta_cmd);
|
||||
void process_timeadv_cmd(uint32_t ta_cmd);
|
||||
void step_initialization();
|
||||
void step_resource_selection();
|
||||
void step_preamble_transmission();
|
||||
|
@ -114,14 +117,14 @@ private:
|
|||
void step_contention_resolution();
|
||||
void step_completition();
|
||||
|
||||
// Buffer to receive RAR PDU
|
||||
// Buffer to receive RAR PDU
|
||||
static const uint32_t MAX_RAR_PDU_LEN = 2048;
|
||||
uint8_t rar_pdu_buffer[MAX_RAR_PDU_LEN];
|
||||
srslte::rar_pdu rar_pdu_msg;
|
||||
|
||||
srslte::rar_pdu rar_pdu_msg;
|
||||
|
||||
// Random Access parameters provided by higher layers defined in 5.1.1
|
||||
uint32_t configIndex;
|
||||
uint32_t nof_preambles;
|
||||
uint32_t nof_preambles;
|
||||
uint32_t nof_groupA_preambles;
|
||||
uint32_t nof_groupB_preambles;
|
||||
uint32_t messagePowerOffsetGroupB;
|
||||
|
@ -130,26 +133,25 @@ private:
|
|||
uint32_t powerRampingStep;
|
||||
uint32_t preambleTransMax;
|
||||
uint32_t iniReceivedTargetPower;
|
||||
int delta_preamble_db;
|
||||
uint32_t contentionResolutionTimer;
|
||||
uint32_t maskIndex;
|
||||
int preambleIndex;
|
||||
uint32_t new_ra_msg_len;
|
||||
|
||||
int delta_preamble_db;
|
||||
uint32_t contentionResolutionTimer;
|
||||
uint32_t maskIndex;
|
||||
int preambleIndex;
|
||||
uint32_t new_ra_msg_len;
|
||||
|
||||
// Internal variables
|
||||
uint32_t preambleTransmissionCounter;
|
||||
uint32_t backoff_param_ms;
|
||||
uint32_t sel_maskIndex;
|
||||
uint32_t sel_preamble;
|
||||
uint32_t preambleTransmissionCounter;
|
||||
uint32_t backoff_param_ms;
|
||||
uint32_t sel_maskIndex;
|
||||
uint32_t sel_preamble;
|
||||
uint32_t backoff_interval_start;
|
||||
uint32_t backoff_inteval;
|
||||
int received_target_power_dbm;
|
||||
uint32_t ra_rnti;
|
||||
uint32_t current_ta;
|
||||
|
||||
srslte_softbuffer_rx_t softbuffer_rar;
|
||||
|
||||
|
||||
int received_target_power_dbm;
|
||||
uint32_t ra_rnti;
|
||||
uint32_t current_ta;
|
||||
|
||||
srslte_softbuffer_rx_t softbuffer_rar;
|
||||
|
||||
enum {
|
||||
IDLE = 0,
|
||||
INITIALIZATION, // Section 5.1.1
|
||||
|
@ -163,36 +165,38 @@ private:
|
|||
COMPLETION, // Section 5.1.6
|
||||
COMPLETION_DONE,
|
||||
RA_PROBLEM // Section 5.1.5 last part
|
||||
} state;
|
||||
|
||||
} state;
|
||||
|
||||
typedef enum {RA_GROUP_A, RA_GROUP_B} ra_group_t;
|
||||
|
||||
ra_group_t last_msg3_group;
|
||||
bool msg3_transmitted;
|
||||
bool first_rar_received;
|
||||
|
||||
ra_group_t last_msg3_group;
|
||||
bool msg3_transmitted;
|
||||
bool first_rar_received;
|
||||
void read_params();
|
||||
|
||||
|
||||
phy_interface_mac *phy_h;
|
||||
srslte::log *log_h;
|
||||
srslte::timers *timers_db;
|
||||
mux *mux_unit;
|
||||
demux *demux_unit;
|
||||
srslte::mac_pcap *pcap;
|
||||
rrc_interface_mac *rrc;
|
||||
|
||||
srslte::timers::timer *time_alignment_timer;
|
||||
srslte::timers::timer *contention_resolution_timer;
|
||||
|
||||
mac_interface_rrc::ue_rnti_t *rntis;
|
||||
mac_interface_rrc::mac_cfg_t *mac_cfg;
|
||||
|
||||
|
||||
uint64_t transmitted_contention_id;
|
||||
uint16_t transmitted_crnti;
|
||||
|
||||
uint16_t transmitted_crnti;
|
||||
|
||||
enum {
|
||||
PDCCH_CRNTI_NOT_RECEIVED = 0,
|
||||
PDCCH_CRNTI_UL_GRANT,
|
||||
PDCCH_CRNTI_DL_GRANT
|
||||
PDCCH_CRNTI_NOT_RECEIVED = 0,
|
||||
PDCCH_CRNTI_UL_GRANT,
|
||||
PDCCH_CRNTI_DL_GRANT
|
||||
} pdcch_to_crnti_received;
|
||||
|
||||
bool started_by_pdcch;
|
||||
bool started_by_pdcch;
|
||||
uint32_t rar_grant_nbytes;
|
||||
uint32_t rar_grant_tti;
|
||||
bool msg3_flushed;
|
||||
|
|
|
@ -35,7 +35,6 @@
|
|||
#include "srslte/interfaces/ue_interfaces.h"
|
||||
#include "srslte/common/log.h"
|
||||
#include "mac/mux.h"
|
||||
#include "mac/mac_common.h"
|
||||
#include "mac/ul_sps.h"
|
||||
#include "srslte/common/mac_pcap.h"
|
||||
#include "srslte/common/timers.h"
|
||||
|
@ -55,9 +54,10 @@ public:
|
|||
|
||||
ul_harq_entity() : proc(N)
|
||||
{
|
||||
pcap = NULL;
|
||||
timers_db = NULL;
|
||||
mux_unit = NULL;
|
||||
contention_timer = NULL;
|
||||
|
||||
pcap = NULL;
|
||||
mux_unit = NULL;
|
||||
log_h = NULL;
|
||||
params = NULL;
|
||||
rntis = NULL;
|
||||
|
@ -68,14 +68,14 @@ public:
|
|||
bool init(srslte::log *log_h_,
|
||||
mac_interface_rrc_common::ue_rnti_t *rntis_,
|
||||
mac_interface_rrc_common::ul_harq_params_t *params_,
|
||||
srslte::timers* timers_db_,
|
||||
srslte::timers::timer* contention_timer_,
|
||||
mux *mux_unit_)
|
||||
{
|
||||
log_h = log_h_;
|
||||
mux_unit = mux_unit_;
|
||||
params = params_;
|
||||
rntis = rntis_;
|
||||
timers_db = timers_db_;
|
||||
contention_timer = contention_timer_;
|
||||
for (uint32_t i=0;i<N;i++) {
|
||||
if (!proc[i].init(i, this)) {
|
||||
return false;
|
||||
|
@ -350,7 +350,7 @@ private:
|
|||
|
||||
// On every Msg3 retransmission, restart mac-ContentionResolutionTimer as defined in Section 5.1.5
|
||||
if (is_msg3) {
|
||||
harq_entity->timers_db->get(CONTENTION_TIMER)->reset();
|
||||
harq_entity->contention_timer->reset();
|
||||
}
|
||||
|
||||
harq_entity->mux_unit->pusch_retx(tti_tx, pid);
|
||||
|
@ -415,7 +415,7 @@ private:
|
|||
|
||||
ul_sps ul_sps_assig;
|
||||
|
||||
srslte::timers *timers_db;
|
||||
srslte::timers::timer *contention_timer;
|
||||
mux *mux_unit;
|
||||
std::vector<ul_harq_process> proc;
|
||||
srslte::log *log_h;
|
||||
|
|
|
@ -40,12 +40,12 @@ demux::demux(uint8_t nof_harq_proc_) : mac_msg(20), pending_mac_msg(20), nof_har
|
|||
{
|
||||
}
|
||||
|
||||
void demux::init(phy_interface_mac_common* phy_h_, rlc_interface_mac *rlc_, srslte::log* log_h_, srslte::timers* timers_db_)
|
||||
void demux::init(phy_interface_mac_common* phy_h_, rlc_interface_mac *rlc_, srslte::log* log_h_, srslte::timers::timer* time_alignment_timer_)
|
||||
{
|
||||
phy_h = phy_h_;
|
||||
log_h = log_h_;
|
||||
rlc = rlc_;
|
||||
timers_db = timers_db_;
|
||||
rlc = rlc_;
|
||||
time_alignment_timer = time_alignment_timer_;
|
||||
pdus.init(this, log_h);
|
||||
}
|
||||
|
||||
|
@ -190,8 +190,8 @@ bool demux::process_ce(srslte::sch_subh *subh) {
|
|||
Info("Received TA=%d\n", subh->get_ta_cmd());
|
||||
|
||||
// Start or restart timeAlignmentTimer
|
||||
timers_db->get(TIME_ALIGNMENT)->reset();
|
||||
timers_db->get(TIME_ALIGNMENT)->run();
|
||||
time_alignment_timer->reset();
|
||||
time_alignment_timer->run();
|
||||
break;
|
||||
case srslte::sch_subh::PADDING:
|
||||
break;
|
||||
|
|
|
@ -42,56 +42,60 @@
|
|||
namespace srsue {
|
||||
|
||||
mac::mac() : ttisync(10240),
|
||||
timers_db((uint32_t) NOF_MAC_TIMERS),
|
||||
timers(64),
|
||||
timers_thread(&timers),
|
||||
mux_unit(MAC_NOF_HARQ_PROC),
|
||||
demux_unit(SRSLTE_MAX_TB*MAC_NOF_HARQ_PROC),
|
||||
pdu_process_thread(&demux_unit)
|
||||
{
|
||||
started = false;
|
||||
pcap = NULL;
|
||||
started = false;
|
||||
pcap = NULL;
|
||||
bzero(&metrics, sizeof(mac_metrics_t));
|
||||
}
|
||||
|
||||
|
||||
bool mac::init(phy_interface_mac *phy, rlc_interface_mac *rlc, rrc_interface_mac *rrc, srslte::log *log_h_)
|
||||
{
|
||||
started = false;
|
||||
started = false;
|
||||
phy_h = phy;
|
||||
rlc_h = rlc;
|
||||
rrc_h = rrc;
|
||||
log_h = log_h_;
|
||||
tti = 0;
|
||||
is_synchronized = false;
|
||||
last_temporal_crnti = 0;
|
||||
phy_rnti = 0;
|
||||
|
||||
rlc_h = rlc;
|
||||
rrc_h = rrc;
|
||||
log_h = log_h_;
|
||||
tti = 0;
|
||||
is_synchronized = false;
|
||||
last_temporal_crnti = 0;
|
||||
phy_rnti = 0;
|
||||
|
||||
srslte_softbuffer_rx_init(&pch_softbuffer, 100);
|
||||
|
||||
bsr_procedure.init( rlc_h, log_h, &config, &timers_db);
|
||||
phr_procedure.init(phy_h, log_h, &config, &timers_db);
|
||||
|
||||
timer_alignment = timers.get_unique_id();
|
||||
contention_resolution_timer = timers.get_unique_id();
|
||||
|
||||
bsr_procedure.init( rlc_h, log_h, &config, &timers);
|
||||
phr_procedure.init(phy_h, log_h, &config, &timers);
|
||||
mux_unit.init ( rlc_h, log_h, &bsr_procedure, &phr_procedure);
|
||||
demux_unit.init (phy_h, rlc_h, log_h, &timers_db);
|
||||
ra_procedure.init (phy_h, rrc, log_h, &uernti, &config, &timers_db, &mux_unit, &demux_unit);
|
||||
demux_unit.init (phy_h, rlc_h, log_h, timers.get(timer_alignment));
|
||||
ra_procedure.init (phy_h, rrc, log_h, &uernti, &config, timers.get(timer_alignment), timers.get(contention_resolution_timer), &mux_unit, &demux_unit);
|
||||
sr_procedure.init (phy_h, rrc, log_h, &config);
|
||||
ul_harq.init ( log_h, &uernti, &config.ul_harq_params, &timers_db, &mux_unit);
|
||||
dl_harq.init ( log_h, &timers_db, &demux_unit);
|
||||
ul_harq.init ( log_h, &uernti, &config.ul_harq_params, timers.get(contention_resolution_timer), &mux_unit);
|
||||
dl_harq.init ( log_h, timers.get(timer_alignment), &demux_unit);
|
||||
|
||||
reset();
|
||||
|
||||
started = true;
|
||||
|
||||
started = true;
|
||||
start(MAC_MAIN_THREAD_PRIO);
|
||||
|
||||
|
||||
return started;
|
||||
|
||||
|
||||
return started;
|
||||
}
|
||||
|
||||
void mac::stop()
|
||||
{
|
||||
srslte_softbuffer_rx_free(&pch_softbuffer);
|
||||
|
||||
started = false;
|
||||
started = false;
|
||||
ttisync.increase();
|
||||
upper_timers_thread.thread_cancel();
|
||||
pdu_process_thread.stop();
|
||||
timers_thread.stop();
|
||||
wait_thread_finish();
|
||||
}
|
||||
|
||||
|
@ -116,8 +120,7 @@ void mac::reset()
|
|||
|
||||
Info("Resetting MAC\n");
|
||||
|
||||
timers_db.stop_all();
|
||||
upper_timers_thread.reset();
|
||||
timers.stop_all();
|
||||
|
||||
ul_harq.reset_ndi();
|
||||
|
||||
|
@ -157,7 +160,8 @@ void mac::run_thread() {
|
|||
tti = phy_h->get_current_tti();
|
||||
|
||||
log_h->step(tti);
|
||||
timers_db.step_all();
|
||||
|
||||
timers_thread.tti_clock();
|
||||
|
||||
// Step all procedures
|
||||
bsr_procedure.step(tti);
|
||||
|
@ -297,7 +301,7 @@ void mac::new_grant_ul(mac_interface_phy::mac_grant_t grant, mac_interface_phy::
|
|||
/* Start PHR Periodic timer on first UL grant */
|
||||
if (is_first_ul_grant) {
|
||||
is_first_ul_grant = false;
|
||||
timers_db.get(PHR_TIMER_PERIODIC)->run();
|
||||
phr_procedure.start_timer();
|
||||
}
|
||||
if (grant.rnti_type == SRSLTE_RNTI_USER && ra_procedure.is_contention_resolution()) {
|
||||
ra_procedure.pdcch_to_crnti(true);
|
||||
|
@ -343,25 +347,23 @@ void mac::setup_timers()
|
|||
{
|
||||
int value = liblte_rrc_time_alignment_timer_num[config.main.time_alignment_timer];
|
||||
if (value > 0) {
|
||||
timers_db.get(TIME_ALIGNMENT)->set(this, value);
|
||||
timers.get(timer_alignment)->set(this, value);
|
||||
}
|
||||
}
|
||||
|
||||
void mac::timer_expired(uint32_t timer_id)
|
||||
{
|
||||
switch(timer_id) {
|
||||
case TIME_ALIGNMENT:
|
||||
timeAlignmentTimerExpire();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
if(timer_id == timer_alignment) {
|
||||
timer_alignment_expire();
|
||||
} else {
|
||||
Warning("Received callback from unknown timer_id=%d\n", timer_id);
|
||||
}
|
||||
}
|
||||
|
||||
/* Function called on expiry of TimeAlignmentTimer */
|
||||
void mac::timeAlignmentTimerExpire()
|
||||
void mac::timer_alignment_expire()
|
||||
{
|
||||
printf("timeAlignmentTimer has expired value=%d ms\n", timers_db.get(TIME_ALIGNMENT)->get_timeout());
|
||||
printf("TimeAlignment timer has expired value=%d ms\n", timers.get(timer_alignment)->get_timeout());
|
||||
rrc_h->release_pucch_srs();
|
||||
dl_harq.reset();
|
||||
ul_harq.reset();
|
||||
|
@ -414,24 +416,7 @@ void mac::setup_lcid(uint32_t lcid, uint32_t lcg, uint32_t priority, int PBR_x_t
|
|||
bsr_procedure.set_priority(lcid, priority);
|
||||
}
|
||||
|
||||
uint32_t mac::get_unique_id()
|
||||
{
|
||||
return upper_timers_thread.get_unique_id();
|
||||
}
|
||||
|
||||
/* Front-end to upper-layer timers */
|
||||
srslte::timers::timer* mac::get(uint32_t timer_id)
|
||||
{
|
||||
return upper_timers_thread.get(timer_id);
|
||||
}
|
||||
|
||||
void mac::free(uint32_t timer_id)
|
||||
{
|
||||
upper_timers_thread.free(timer_id);
|
||||
}
|
||||
|
||||
|
||||
void mac::get_metrics(mac_metrics_t &m)
|
||||
void mac::get_metrics(mac_metrics_t &m)
|
||||
{
|
||||
Info("DL retx: %.2f \%%, perpkt: %.2f, UL retx: %.2f \%% perpkt: %.2f\n",
|
||||
metrics.rx_pkts?((float) 100*metrics.rx_errors/metrics.rx_pkts):0.0,
|
||||
|
@ -445,47 +430,59 @@ void mac::free(uint32_t timer_id)
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/********************************************************
|
||||
*
|
||||
* Class to run upper-layer timers with normal priority
|
||||
* Interface for timers used by upper layers
|
||||
*
|
||||
*******************************************************/
|
||||
|
||||
mac::upper_timers::upper_timers() : timers_db(MAC_NOF_UPPER_TIMERS)
|
||||
srslte::timers::timer* mac::timer_get(uint32_t timer_id)
|
||||
{
|
||||
start_periodic(1000, MAC_MAIN_THREAD_PRIO+1);
|
||||
return timers.get(timer_id);
|
||||
}
|
||||
|
||||
void mac::upper_timers::run_period()
|
||||
void mac::timer_release_id(uint32_t timer_id)
|
||||
{
|
||||
timers_db.step_all();
|
||||
timers.release_id(timer_id);
|
||||
}
|
||||
|
||||
srslte::timers::timer* mac::upper_timers::get(uint32_t timer_id)
|
||||
uint32_t mac::timer_get_unique_id()
|
||||
{
|
||||
return timers_db.get(timer_id%MAC_NOF_UPPER_TIMERS);
|
||||
}
|
||||
|
||||
uint32_t mac::upper_timers::get_unique_id()
|
||||
{
|
||||
return timers_db.get_unique_id();
|
||||
}
|
||||
|
||||
void mac::upper_timers::reset()
|
||||
{
|
||||
timers_db.stop_all();
|
||||
return timers.get_unique_id();
|
||||
}
|
||||
|
||||
|
||||
void mac::upper_timers::free(uint32_t timer_id)
|
||||
/********************************************************
|
||||
*
|
||||
* Class that runs timers in lower priority
|
||||
*
|
||||
*******************************************************/
|
||||
void mac::timer_thread::tti_clock()
|
||||
{
|
||||
timers_db.release_id(timer_id);
|
||||
ttisync.increase();
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/********************************************************
|
||||
/********************************************************
|
||||
*
|
||||
* Class that runs a thread to process DL MAC PDUs from
|
||||
* DEMUX unit
|
||||
|
|
|
@ -50,17 +50,21 @@ void bsr_proc::init(rlc_interface_mac *rlc_, srslte::log* log_h_, mac_interface_
|
|||
log_h = log_h_;
|
||||
rlc = rlc_;
|
||||
mac_cfg = mac_cfg_;
|
||||
timers_db = timers_db_;
|
||||
timers_db = timers_db_;
|
||||
|
||||
timer_periodic_id = timers_db->get_unique_id();
|
||||
timer_retx_id = timers_db->get_unique_id();
|
||||
|
||||
reset();
|
||||
initiated = true;
|
||||
}
|
||||
|
||||
void bsr_proc::reset()
|
||||
{
|
||||
timers_db->get(BSR_TIMER_PERIODIC)->stop();
|
||||
timers_db->get(BSR_TIMER_PERIODIC)->reset();
|
||||
timers_db->get(BSR_TIMER_RETX)->stop();
|
||||
timers_db->get(BSR_TIMER_RETX)->reset();
|
||||
timers_db->get(timer_periodic_id)->stop();
|
||||
timers_db->get(timer_periodic_id)->reset();
|
||||
timers_db->get(timer_retx_id)->stop();
|
||||
timers_db->get(timer_retx_id)->reset();
|
||||
|
||||
reset_sr = false;
|
||||
sr_is_sent = false;
|
||||
|
@ -77,23 +81,20 @@ void bsr_proc::reset()
|
|||
|
||||
/* Process Periodic BSR */
|
||||
void bsr_proc::timer_expired(uint32_t timer_id) {
|
||||
switch(timer_id) {
|
||||
case BSR_TIMER_PERIODIC:
|
||||
if (triggered_bsr_type == NONE) {
|
||||
// Check condition 4 in Sec 5.4.5
|
||||
triggered_bsr_type = PERIODIC;
|
||||
Debug("BSR: Triggering Periodic BSR\n");
|
||||
}
|
||||
break;
|
||||
case BSR_TIMER_RETX:
|
||||
// Enable reTx of SR only if periodic timer is not infinity
|
||||
int periodic = liblte_rrc_periodic_bsr_timer_num[mac_cfg->main.ulsch_cnfg.periodic_bsr_timer];
|
||||
if (periodic >= 0) {
|
||||
triggered_bsr_type = REGULAR;
|
||||
Debug("BSR: Triggering BSR reTX\n");
|
||||
sr_is_sent = false;
|
||||
}
|
||||
break;
|
||||
if(timer_id == timer_periodic_id) {
|
||||
if (triggered_bsr_type == NONE) {
|
||||
// Check condition 4 in Sec 5.4.5
|
||||
triggered_bsr_type = PERIODIC;
|
||||
Debug("BSR: Triggering Periodic BSR\n");
|
||||
}
|
||||
} else if (timer_id == timer_retx_id) {
|
||||
// Enable reTx of SR only if periodic timer is not infinity
|
||||
int periodic = liblte_rrc_periodic_bsr_timer_num[mac_cfg->main.ulsch_cnfg.periodic_bsr_timer];
|
||||
if (periodic >= 0) {
|
||||
triggered_bsr_type = REGULAR;
|
||||
Debug("BSR: Triggering BSR reTX\n");
|
||||
sr_is_sent = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -222,17 +223,17 @@ void bsr_proc::step(uint32_t tti)
|
|||
}
|
||||
|
||||
int periodic = liblte_rrc_periodic_bsr_timer_num[mac_cfg->main.ulsch_cnfg.periodic_bsr_timer];
|
||||
if (periodic > 0 && (uint32_t)periodic != timers_db->get(BSR_TIMER_PERIODIC)->get_timeout())
|
||||
if (periodic > 0 && (uint32_t)periodic != timers_db->get(timer_periodic_id)->get_timeout())
|
||||
{
|
||||
timers_db->get(BSR_TIMER_PERIODIC)->set(this, periodic);
|
||||
timers_db->get(BSR_TIMER_PERIODIC)->run();
|
||||
timers_db->get(timer_periodic_id)->set(this, periodic);
|
||||
timers_db->get(timer_periodic_id)->run();
|
||||
Info("BSR: Configured timer periodic %d ms\n", periodic);
|
||||
}
|
||||
int retx = liblte_rrc_retransmission_bsr_timer_num[mac_cfg->main.ulsch_cnfg.retx_bsr_timer];
|
||||
if (retx > 0 && (uint32_t)retx != timers_db->get(BSR_TIMER_RETX)->get_timeout())
|
||||
if (retx > 0 && (uint32_t)retx != timers_db->get(timer_retx_id)->get_timeout())
|
||||
{
|
||||
timers_db->get(BSR_TIMER_RETX)->set(this, retx);
|
||||
timers_db->get(BSR_TIMER_RETX)->run();
|
||||
timers_db->get(timer_retx_id)->set(this, retx);
|
||||
timers_db->get(timer_retx_id)->run();
|
||||
Info("BSR: Configured timer reTX %d ms\n", retx);
|
||||
}
|
||||
|
||||
|
@ -309,18 +310,18 @@ bool bsr_proc::need_to_send_bsr_on_ul_grant(uint32_t grant_size, bsr_t *bsr)
|
|||
grant_size, total_data, bsr_sz);
|
||||
ret = true;
|
||||
}
|
||||
if (timers_db->get(BSR_TIMER_PERIODIC)->get_timeout() && bsr->format != TRUNC_BSR) {
|
||||
timers_db->get(BSR_TIMER_PERIODIC)->reset();
|
||||
timers_db->get(BSR_TIMER_PERIODIC)->run();
|
||||
if (timers_db->get(timer_periodic_id)->get_timeout() && bsr->format != TRUNC_BSR) {
|
||||
timers_db->get(timer_periodic_id)->reset();
|
||||
timers_db->get(timer_periodic_id)->run();
|
||||
}
|
||||
}
|
||||
// Cancel all triggered BSR and SR
|
||||
triggered_bsr_type = NONE;
|
||||
reset_sr = true;
|
||||
// Restart or Start ReTX timer
|
||||
if (timers_db->get(BSR_TIMER_RETX)->get_timeout()) {
|
||||
timers_db->get(BSR_TIMER_RETX)->reset();
|
||||
timers_db->get(BSR_TIMER_RETX)->run();
|
||||
if (timers_db->get(timer_retx_id)->get_timeout()) {
|
||||
timers_db->get(timer_retx_id)->reset();
|
||||
timers_db->get(timer_retx_id)->run();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -340,9 +341,9 @@ bool bsr_proc::generate_padding_bsr(uint32_t nof_padding_bytes, bsr_t *bsr)
|
|||
bsr_type_tostring(triggered_bsr_type), bsr_format_tostring(bsr->format),
|
||||
bsr->buff_size[0], bsr->buff_size[1], bsr->buff_size[2], bsr->buff_size[3]);
|
||||
|
||||
if (timers_db->get(BSR_TIMER_PERIODIC)->get_timeout() && bsr->format != TRUNC_BSR) {
|
||||
timers_db->get(BSR_TIMER_PERIODIC)->reset();
|
||||
timers_db->get(BSR_TIMER_PERIODIC)->run();
|
||||
if (timers_db->get(timer_periodic_id)->get_timeout() && bsr->format != TRUNC_BSR) {
|
||||
timers_db->get(timer_periodic_id)->reset();
|
||||
timers_db->get(timer_periodic_id)->run();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -49,14 +49,18 @@ void phr_proc::init(phy_interface_mac* phy_h_, srslte::log* log_h_, mac_interfac
|
|||
mac_cfg = mac_cfg_;
|
||||
timers_db = timers_db_;
|
||||
initiated = true;
|
||||
|
||||
timer_periodic_id = timers_db->get_unique_id();
|
||||
timer_prohibit_id = timers_db->get_unique_id();
|
||||
|
||||
reset();
|
||||
}
|
||||
|
||||
void phr_proc::reset()
|
||||
{
|
||||
phr_is_triggered = false;
|
||||
timer_periodic = -2;
|
||||
timer_prohibit = -2;
|
||||
timer_periodic_value = -2;
|
||||
timer_prohibit_value = -2;
|
||||
dl_pathloss_change = -2;
|
||||
}
|
||||
|
||||
|
@ -72,23 +76,26 @@ bool phr_proc::pathloss_changed() {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void phr_proc::start_timer() {
|
||||
timers_db->get(timer_periodic_id)->run();
|
||||
}
|
||||
|
||||
/* Trigger PHR when timers exire */
|
||||
void phr_proc::timer_expired(uint32_t timer_id) {
|
||||
switch(timer_id) {
|
||||
case PHR_TIMER_PERIODIC:
|
||||
timers_db->get(PHR_TIMER_PERIODIC)->reset();
|
||||
timers_db->get(PHR_TIMER_PERIODIC)->run();
|
||||
Debug("PHR: Triggered by timer periodic (timer expired).\n");
|
||||
phr_is_triggered = true;
|
||||
break;
|
||||
case PHR_TIMER_PROHIBIT:
|
||||
int pathloss_db = liblte_rrc_dl_pathloss_change_num[mac_cfg->main.phr_cnfg.dl_pathloss_change];
|
||||
if (pathloss_changed()) {
|
||||
Info("PHR: Triggered by pathloss difference. cur_pathloss_db=%f (timer expired)\n", last_pathloss_db);
|
||||
phr_is_triggered = true;
|
||||
}
|
||||
break;
|
||||
if(timer_id == timer_periodic_id) {
|
||||
timers_db->get(timer_periodic_id)->reset();
|
||||
timers_db->get(timer_periodic_id)->run();
|
||||
Debug("PHR: Triggered by timer periodic (timer expired).\n");
|
||||
phr_is_triggered = true;
|
||||
} else if (timer_id == timer_prohibit_id) {
|
||||
int pathloss_db = liblte_rrc_dl_pathloss_change_num[mac_cfg->main.phr_cnfg.dl_pathloss_change];
|
||||
if (pathloss_changed()) {
|
||||
Info("PHR: Triggered by pathloss difference. cur_pathloss_db=%f (timer expired)\n", last_pathloss_db);
|
||||
phr_is_triggered = true;
|
||||
}
|
||||
} else {
|
||||
log_h->warning("Received timer callback from unknown timer_id=%d\n", timer_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -102,28 +109,28 @@ void phr_proc::step(uint32_t tti)
|
|||
int cfg_timer_periodic = liblte_rrc_periodic_phr_timer_num[mac_cfg->main.phr_cnfg.periodic_phr_timer];
|
||||
|
||||
// Setup timers and trigger PHR when configuration changed by higher layers
|
||||
if (timer_periodic != cfg_timer_periodic && cfg_timer_periodic > 0)
|
||||
if (timer_periodic_value != cfg_timer_periodic && cfg_timer_periodic > 0)
|
||||
{
|
||||
timer_periodic = cfg_timer_periodic;
|
||||
timers_db->get(PHR_TIMER_PERIODIC)->set(this, timer_periodic);
|
||||
timers_db->get(PHR_TIMER_PERIODIC)->run();
|
||||
timer_periodic_value = cfg_timer_periodic;
|
||||
timers_db->get(timer_periodic_id)->set(this, timer_periodic_value);
|
||||
timers_db->get(timer_periodic_id)->run();
|
||||
phr_is_triggered = true;
|
||||
Info("PHR: Configured timer periodic %d ms\n", timer_periodic);
|
||||
Info("PHR: Configured timer periodic %d ms\n", timer_periodic_value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int cfg_timer_prohibit = liblte_rrc_prohibit_phr_timer_num[mac_cfg->main.phr_cnfg.prohibit_phr_timer];
|
||||
|
||||
if (timer_prohibit != cfg_timer_prohibit && cfg_timer_prohibit > 0)
|
||||
if (timer_prohibit_value != cfg_timer_prohibit && cfg_timer_prohibit > 0)
|
||||
{
|
||||
timer_prohibit = cfg_timer_prohibit;
|
||||
timers_db->get(PHR_TIMER_PROHIBIT)->set(this, timer_prohibit);
|
||||
timers_db->get(PHR_TIMER_PROHIBIT)->run();
|
||||
Info("PHR: Configured timer prohibit %d ms\n", timer_prohibit);
|
||||
timer_prohibit_value = cfg_timer_prohibit;
|
||||
timers_db->get(timer_prohibit_id)->set(this, timer_prohibit_value);
|
||||
timers_db->get(timer_prohibit_id)->run();
|
||||
Info("PHR: Configured timer prohibit %d ms\n", timer_prohibit_value);
|
||||
phr_is_triggered = true;
|
||||
}
|
||||
if (pathloss_changed() && timers_db->get(PHR_TIMER_PROHIBIT)->is_expired())
|
||||
if (pathloss_changed() && timers_db->get(timer_prohibit_id)->is_expired())
|
||||
{
|
||||
Info("PHR: Triggered by pathloss difference. cur_pathloss_db=%f\n", last_pathloss_db);
|
||||
phr_is_triggered = true;
|
||||
|
@ -140,10 +147,10 @@ bool phr_proc::generate_phr_on_ul_grant(float *phr)
|
|||
|
||||
Debug("PHR: Generating PHR=%f\n", phr?*phr:0.0);
|
||||
|
||||
timers_db->get(PHR_TIMER_PERIODIC)->reset();
|
||||
timers_db->get(PHR_TIMER_PROHIBIT)->reset();
|
||||
timers_db->get(PHR_TIMER_PERIODIC)->run();
|
||||
timers_db->get(PHR_TIMER_PROHIBIT)->run();
|
||||
timers_db->get(timer_periodic_id)->reset();
|
||||
timers_db->get(timer_prohibit_id)->reset();
|
||||
timers_db->get(timer_periodic_id)->run();
|
||||
timers_db->get(timer_prohibit_id)->run();
|
||||
|
||||
phr_is_triggered = false;
|
||||
|
||||
|
|
|
@ -53,7 +53,8 @@ void ra_proc::init(phy_interface_mac* phy_h_,
|
|||
srslte::log* log_h_,
|
||||
mac_interface_rrc::ue_rnti_t *rntis_,
|
||||
mac_interface_rrc::mac_cfg_t *mac_cfg_,
|
||||
srslte::timers* timers_db_,
|
||||
srslte::timers::timer* time_alignment_timer_,
|
||||
srslte::timers::timer* contention_resolution_timer_,
|
||||
mux* mux_unit_,
|
||||
demux* demux_unit_)
|
||||
{
|
||||
|
@ -61,10 +62,13 @@ void ra_proc::init(phy_interface_mac* phy_h_,
|
|||
log_h = log_h_;
|
||||
mac_cfg = mac_cfg_;
|
||||
rntis = rntis_;
|
||||
timers_db = timers_db_;
|
||||
mux_unit = mux_unit_;
|
||||
demux_unit= demux_unit_;
|
||||
rrc = rrc_;
|
||||
rrc = rrc_;
|
||||
|
||||
time_alignment_timer = time_alignment_timer_;
|
||||
contention_resolution_timer = contention_resolution_timer_;
|
||||
|
||||
srslte_softbuffer_rx_init(&softbuffer_rar, 10);
|
||||
|
||||
// Tell demux to call us when a UE CRID is received
|
||||
|
@ -119,7 +123,7 @@ void ra_proc::read_params() {
|
|||
delta_preamble_db = delta_preamble_db_table[configIndex%5];
|
||||
|
||||
if (contentionResolutionTimer > 0) {
|
||||
timers_db->get(CONTENTION_TIMER)->set(this, contentionResolutionTimer);
|
||||
contention_resolution_timer->set(this, contentionResolutionTimer);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -169,14 +173,14 @@ void ra_proc::process_timeadv_cmd(uint32_t ta) {
|
|||
if (preambleIndex == 0) {
|
||||
// Preamble not selected by UE MAC
|
||||
phy_h->set_timeadv_rar(ta);
|
||||
timers_db->get(TIME_ALIGNMENT)->reset();
|
||||
timers_db->get(TIME_ALIGNMENT)->run();
|
||||
time_alignment_timer->reset();
|
||||
time_alignment_timer->run();
|
||||
Debug("Applying RAR TA CMD %d\n", ta);
|
||||
} else {
|
||||
// Preamble selected by UE MAC
|
||||
if (!timers_db->get(TIME_ALIGNMENT)->is_running()) {
|
||||
if (!time_alignment_timer->is_running()) {
|
||||
phy_h->set_timeadv_rar(ta);
|
||||
timers_db->get(TIME_ALIGNMENT)->run();
|
||||
time_alignment_timer->run();
|
||||
Debug("Applying RAR TA CMD %d\n", ta);
|
||||
} else {
|
||||
// Ignore TA CMD
|
||||
|
@ -361,8 +365,8 @@ void ra_proc::tb_decoded_ok() {
|
|||
state = CONTENTION_RESOLUTION;
|
||||
|
||||
// Start contention resolution timer
|
||||
timers_db->get(CONTENTION_TIMER)->reset();
|
||||
timers_db->get(CONTENTION_TIMER)->run();
|
||||
contention_resolution_timer->reset();
|
||||
contention_resolution_timer->run();
|
||||
}
|
||||
} else {
|
||||
rDebug("Found RAR for preamble %d\n", rar_pdu_msg.get()->get_rapid());
|
||||
|
@ -423,7 +427,7 @@ bool ra_proc::contention_resolution_id_received(uint64_t rx_contention_id) {
|
|||
rDebug("MAC PDU Contains Contention Resolution ID CE\n");
|
||||
|
||||
// MAC PDU successfully decoded and contains MAC CE contention Id
|
||||
timers_db->get(CONTENTION_TIMER)->stop();
|
||||
contention_resolution_timer->stop();
|
||||
|
||||
if (transmitted_contention_id == rx_contention_id)
|
||||
{
|
||||
|
@ -459,7 +463,7 @@ void ra_proc::step_contention_resolution() {
|
|||
(started_by_pdcch && pdcch_to_crnti_received != PDCCH_CRNTI_NOT_RECEIVED))
|
||||
{
|
||||
rDebug("PDCCH for C-RNTI received\n");
|
||||
timers_db->get(CONTENTION_TIMER)->stop();
|
||||
contention_resolution_timer->stop();
|
||||
rntis->temp_rnti = 0;
|
||||
state = COMPLETION;
|
||||
}
|
||||
|
@ -571,7 +575,7 @@ void ra_proc::pdcch_to_crnti(bool contains_uplink_grant) {
|
|||
|
||||
void ra_proc::harq_retx()
|
||||
{
|
||||
timers_db->get(CONTENTION_TIMER)->reset();
|
||||
contention_resolution_timer->reset();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -93,9 +93,9 @@ void rrc::init(phy_interface_rrc *phy_,
|
|||
pthread_mutex_init(&mutex, NULL);
|
||||
|
||||
ue_category = SRSLTE_UE_CATEGORY;
|
||||
t301 = mac_timers->get_unique_id();
|
||||
t310 = mac_timers->get_unique_id();
|
||||
t311 = mac_timers->get_unique_id();
|
||||
t301 = mac_timers->timer_get_unique_id();
|
||||
t310 = mac_timers->timer_get_unique_id();
|
||||
t311 = mac_timers->timer_get_unique_id();
|
||||
|
||||
transaction_id = 0;
|
||||
|
||||
|
@ -233,9 +233,9 @@ void rrc::run_thread() {
|
|||
set_phy_default();
|
||||
set_mac_default();
|
||||
mac->pcch_start_rx();
|
||||
mac_timers->get(t311)->run();
|
||||
mac_timers->get(t310)->stop();
|
||||
mac_timers->get(t311)->stop();
|
||||
mac_timers->timer_get(t311)->run();
|
||||
mac_timers->timer_get(t310)->stop();
|
||||
mac_timers->timer_get(t311)->stop();
|
||||
state = RRC_STATE_IDLE;
|
||||
break;
|
||||
default:
|
||||
|
@ -475,11 +475,11 @@ void rrc::cell_found(uint32_t earfcn, srslte_cell_t phy_cell, float rsrp) {
|
|||
// Detection of physical layer problems (5.3.11.1)
|
||||
void rrc::out_of_sync() {
|
||||
current_cell->in_sync = false;
|
||||
if (!mac_timers->get(t311)->is_running() && !mac_timers->get(t310)->is_running()) {
|
||||
if (!mac_timers->timer_get(t311)->is_running() && !mac_timers->timer_get(t310)->is_running()) {
|
||||
n310_cnt++;
|
||||
if (n310_cnt == N310) {
|
||||
mac_timers->get(t310)->reset();
|
||||
mac_timers->get(t310)->run();
|
||||
mac_timers->timer_get(t310)->reset();
|
||||
mac_timers->timer_get(t310)->run();
|
||||
n310_cnt = 0;
|
||||
rrc_log->info("Detected %d out-of-sync from PHY. Starting T310 timer\n", N310);
|
||||
}
|
||||
|
@ -489,10 +489,10 @@ void rrc::out_of_sync() {
|
|||
// Recovery of physical layer problems (5.3.11.2)
|
||||
void rrc::in_sync() {
|
||||
current_cell->in_sync = true;
|
||||
if (mac_timers->get(t310)->is_running()) {
|
||||
if (mac_timers->timer_get(t310)->is_running()) {
|
||||
n311_cnt++;
|
||||
if (n311_cnt == N311) {
|
||||
mac_timers->get(t310)->stop();
|
||||
mac_timers->timer_get(t310)->stop();
|
||||
n311_cnt = 0;
|
||||
rrc_log->info("Detected %d in-sync from PHY. Stopping T310 timer\n", N311);
|
||||
}
|
||||
|
@ -652,9 +652,9 @@ void rrc::send_con_restablish_request() {
|
|||
|
||||
rrc_log->info("Initiating RRC Connection Reestablishment Procedure\n");
|
||||
rrc_log->console("RRC Connection Reestablishment\n");
|
||||
mac_timers->get(t310)->stop();
|
||||
mac_timers->get(t311)->reset();
|
||||
mac_timers->get(t311)->run();
|
||||
mac_timers->timer_get(t310)->stop();
|
||||
mac_timers->timer_get(t311)->reset();
|
||||
mac_timers->timer_get(t311)->run();
|
||||
|
||||
set_phy_default();
|
||||
mac->reset();
|
||||
|
@ -667,9 +667,9 @@ void rrc::send_con_restablish_request() {
|
|||
usleep(10000);
|
||||
timeout_cnt++;
|
||||
}
|
||||
mac_timers->get(t301)->reset();
|
||||
mac_timers->get(t301)->run();
|
||||
mac_timers->get(t311)->stop();
|
||||
mac_timers->timer_get(t301)->reset();
|
||||
mac_timers->timer_get(t301)->run();
|
||||
mac_timers->timer_get(t311)->stop();
|
||||
rrc_log->info("Cell Selection finished. Initiating transmission of RRC Connection Reestablishment Request\n");
|
||||
|
||||
// Byte align and pack the message bits for PDCP
|
||||
|
@ -1337,15 +1337,15 @@ void rrc::apply_sib2_configs(LIBLTE_RRC_SYS_INFO_BLOCK_TYPE_2_STRUCT *sib2) {
|
|||
liblte_rrc_srs_subfr_config_num[sib2->rr_config_common_sib.srs_ul_cnfg.subfr_cnfg],
|
||||
sib2->rr_config_common_sib.srs_ul_cnfg.ack_nack_simul_tx ? "yes" : "no");
|
||||
|
||||
mac_timers->get(t301)->set(this, liblte_rrc_t301_num[sib2->ue_timers_and_constants.t301]);
|
||||
mac_timers->get(t310)->set(this, liblte_rrc_t310_num[sib2->ue_timers_and_constants.t310]);
|
||||
mac_timers->get(t311)->set(this, liblte_rrc_t311_num[sib2->ue_timers_and_constants.t311]);
|
||||
mac_timers->timer_get(t301)->set(this, liblte_rrc_t301_num[sib2->ue_timers_and_constants.t301]);
|
||||
mac_timers->timer_get(t310)->set(this, liblte_rrc_t310_num[sib2->ue_timers_and_constants.t310]);
|
||||
mac_timers->timer_get(t311)->set(this, liblte_rrc_t311_num[sib2->ue_timers_and_constants.t311]);
|
||||
N310 = liblte_rrc_n310_num[sib2->ue_timers_and_constants.n310];
|
||||
N311 = liblte_rrc_n311_num[sib2->ue_timers_and_constants.n311];
|
||||
|
||||
rrc_log->info("Set Constants and Timers: N310=%d, N311=%d, t301=%d, t310=%d, t311=%d\n",
|
||||
N310, N311, mac_timers->get(t301)->get_timeout(),
|
||||
mac_timers->get(t310)->get_timeout(), mac_timers->get(t311)->get_timeout());
|
||||
N310, N311, mac_timers->timer_get(t301)->get_timeout(),
|
||||
mac_timers->timer_get(t310)->get_timeout(), mac_timers->timer_get(t311)->get_timeout());
|
||||
|
||||
}
|
||||
|
||||
|
@ -1583,7 +1583,7 @@ void rrc::handle_con_setup(LIBLTE_RRC_CONNECTION_SETUP_STRUCT *setup) {
|
|||
|
||||
/* Reception of RRCConnectionReestablishment by the UE 5.3.7.5 */
|
||||
void rrc::handle_con_reest(LIBLTE_RRC_CONNECTION_REESTABLISHMENT_STRUCT *setup) {
|
||||
mac_timers->get(t301)->stop();
|
||||
mac_timers->timer_get(t301)->stop();
|
||||
|
||||
// TODO: Restablish DRB1. Not done because never was suspended
|
||||
|
||||
|
@ -1740,8 +1740,8 @@ void rrc::set_mac_default() {
|
|||
void rrc::set_rrc_default() {
|
||||
N310 = 1;
|
||||
N311 = 1;
|
||||
mac_timers->get(t310)->set(this, 1000);
|
||||
mac_timers->get(t311)->set(this, 1000);
|
||||
mac_timers->timer_get(t310)->set(this, 1000);
|
||||
mac_timers->timer_get(t311)->set(this, 1000);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue