adapt MAC procedures to also use MAC timers defined in mac_common.h

master
Andre Puschmann 8 years ago
parent faf120501a
commit 869786a27c

@ -98,17 +98,6 @@ public:
u_int32_t get_unique_id(); u_int32_t get_unique_id();
uint32_t get_current_tti(); uint32_t get_current_tti();
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;
static const int MAC_NOF_UPPER_TIMERS = 20; static const int MAC_NOF_UPPER_TIMERS = 20;

@ -190,8 +190,8 @@ bool demux::process_ce(srslte::sch_subh *subh) {
Info("Received TA=%d\n", subh->get_ta_cmd()); Info("Received TA=%d\n", subh->get_ta_cmd());
// Start or restart timeAlignmentTimer // Start or restart timeAlignmentTimer
timers_db->get(mac::TIME_ALIGNMENT)->reset(); timers_db->get(TIME_ALIGNMENT)->reset();
timers_db->get(mac::TIME_ALIGNMENT)->run(); timers_db->get(TIME_ALIGNMENT)->run();
break; break;
case srslte::sch_subh::PADDING: case srslte::sch_subh::PADDING:
break; break;

@ -308,7 +308,7 @@ void mac::new_grant_ul(mac_interface_phy::mac_grant_t grant, mac_interface_phy::
/* Start PHR Periodic timer on first UL grant */ /* Start PHR Periodic timer on first UL grant */
if (is_first_ul_grant) { if (is_first_ul_grant) {
is_first_ul_grant = false; is_first_ul_grant = false;
timers_db.get(mac::PHR_TIMER_PERIODIC)->run(); timers_db.get(PHR_TIMER_PERIODIC)->run();
} }
if (grant.rnti_type == SRSLTE_RNTI_USER && ra_procedure.is_contention_resolution()) { if (grant.rnti_type == SRSLTE_RNTI_USER && ra_procedure.is_contention_resolution()) {
ra_procedure.pdcch_to_crnti(true); ra_procedure.pdcch_to_crnti(true);

@ -57,10 +57,10 @@ void bsr_proc::init(rlc_interface_mac *rlc_, srslte::log* log_h_, mac_interface_
void bsr_proc::reset() void bsr_proc::reset()
{ {
timers_db->get(mac::BSR_TIMER_PERIODIC)->stop(); timers_db->get(BSR_TIMER_PERIODIC)->stop();
timers_db->get(mac::BSR_TIMER_PERIODIC)->reset(); timers_db->get(BSR_TIMER_PERIODIC)->reset();
timers_db->get(mac::BSR_TIMER_RETX)->stop(); timers_db->get(BSR_TIMER_RETX)->stop();
timers_db->get(mac::BSR_TIMER_RETX)->reset(); timers_db->get(BSR_TIMER_RETX)->reset();
reset_sr = false; reset_sr = false;
sr_is_sent = false; sr_is_sent = false;
@ -78,14 +78,14 @@ void bsr_proc::reset()
/* Process Periodic BSR */ /* Process Periodic BSR */
void bsr_proc::timer_expired(uint32_t timer_id) { void bsr_proc::timer_expired(uint32_t timer_id) {
switch(timer_id) { switch(timer_id) {
case mac::BSR_TIMER_PERIODIC: case BSR_TIMER_PERIODIC:
if (triggered_bsr_type == NONE) { if (triggered_bsr_type == NONE) {
// Check condition 4 in Sec 5.4.5 // Check condition 4 in Sec 5.4.5
triggered_bsr_type = PERIODIC; triggered_bsr_type = PERIODIC;
Debug("BSR: Triggering Periodic BSR\n"); Debug("BSR: Triggering Periodic BSR\n");
} }
break; break;
case mac::BSR_TIMER_RETX: case BSR_TIMER_RETX:
// Enable reTx of SR only if periodic timer is not infinity // 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]; int periodic = liblte_rrc_periodic_bsr_timer_num[mac_cfg->main.ulsch_cnfg.periodic_bsr_timer];
if (periodic >= 0) { if (periodic >= 0) {
@ -222,17 +222,17 @@ void bsr_proc::step(uint32_t tti)
} }
int periodic = liblte_rrc_periodic_bsr_timer_num[mac_cfg->main.ulsch_cnfg.periodic_bsr_timer]; 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(mac::BSR_TIMER_PERIODIC)->get_timeout()) if (periodic > 0 && (uint32_t)periodic != timers_db->get(BSR_TIMER_PERIODIC)->get_timeout())
{ {
timers_db->get(mac::BSR_TIMER_PERIODIC)->set(this, periodic); timers_db->get(BSR_TIMER_PERIODIC)->set(this, periodic);
timers_db->get(mac::BSR_TIMER_PERIODIC)->run(); timers_db->get(BSR_TIMER_PERIODIC)->run();
Info("BSR: Configured timer periodic %d ms\n", periodic); 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]; 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(mac::BSR_TIMER_RETX)->get_timeout()) if (retx > 0 && (uint32_t)retx != timers_db->get(BSR_TIMER_RETX)->get_timeout())
{ {
timers_db->get(mac::BSR_TIMER_RETX)->set(this, retx); timers_db->get(BSR_TIMER_RETX)->set(this, retx);
timers_db->get(mac::BSR_TIMER_RETX)->run(); timers_db->get(BSR_TIMER_RETX)->run();
Info("BSR: Configured timer reTX %d ms\n", retx); Info("BSR: Configured timer reTX %d ms\n", retx);
} }
@ -309,18 +309,18 @@ bool bsr_proc::need_to_send_bsr_on_ul_grant(uint32_t grant_size, bsr_t *bsr)
grant_size, total_data, bsr_sz); grant_size, total_data, bsr_sz);
ret = true; ret = true;
} }
if (timers_db->get(mac::BSR_TIMER_PERIODIC)->get_timeout() && bsr->format != TRUNC_BSR) { if (timers_db->get(BSR_TIMER_PERIODIC)->get_timeout() && bsr->format != TRUNC_BSR) {
timers_db->get(mac::BSR_TIMER_PERIODIC)->reset(); timers_db->get(BSR_TIMER_PERIODIC)->reset();
timers_db->get(mac::BSR_TIMER_PERIODIC)->run(); timers_db->get(BSR_TIMER_PERIODIC)->run();
} }
} }
// Cancel all triggered BSR and SR // Cancel all triggered BSR and SR
triggered_bsr_type = NONE; triggered_bsr_type = NONE;
reset_sr = true; reset_sr = true;
// Restart or Start ReTX timer // Restart or Start ReTX timer
if (timers_db->get(mac::BSR_TIMER_RETX)->get_timeout()) { if (timers_db->get(BSR_TIMER_RETX)->get_timeout()) {
timers_db->get(mac::BSR_TIMER_RETX)->reset(); timers_db->get(BSR_TIMER_RETX)->reset();
timers_db->get(mac::BSR_TIMER_RETX)->run(); timers_db->get(BSR_TIMER_RETX)->run();
} }
return ret; return ret;
} }
@ -340,9 +340,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_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]); bsr->buff_size[0], bsr->buff_size[1], bsr->buff_size[2], bsr->buff_size[3]);
if (timers_db->get(mac::BSR_TIMER_PERIODIC)->get_timeout() && bsr->format != TRUNC_BSR) { if (timers_db->get(BSR_TIMER_PERIODIC)->get_timeout() && bsr->format != TRUNC_BSR) {
timers_db->get(mac::BSR_TIMER_PERIODIC)->reset(); timers_db->get(BSR_TIMER_PERIODIC)->reset();
timers_db->get(mac::BSR_TIMER_PERIODIC)->run(); timers_db->get(BSR_TIMER_PERIODIC)->run();
} }
} }

@ -76,13 +76,13 @@ bool phr_proc::pathloss_changed() {
/* Trigger PHR when timers exire */ /* Trigger PHR when timers exire */
void phr_proc::timer_expired(uint32_t timer_id) { void phr_proc::timer_expired(uint32_t timer_id) {
switch(timer_id) { switch(timer_id) {
case mac::PHR_TIMER_PERIODIC: case PHR_TIMER_PERIODIC:
timers_db->get(mac::PHR_TIMER_PERIODIC)->reset(); timers_db->get(PHR_TIMER_PERIODIC)->reset();
timers_db->get(mac::PHR_TIMER_PERIODIC)->run(); timers_db->get(PHR_TIMER_PERIODIC)->run();
Debug("PHR: Triggered by timer periodic (timer expired).\n"); Debug("PHR: Triggered by timer periodic (timer expired).\n");
phr_is_triggered = true; phr_is_triggered = true;
break; break;
case mac::PHR_TIMER_PROHIBIT: case PHR_TIMER_PROHIBIT:
int pathloss_db = liblte_rrc_dl_pathloss_change_num[mac_cfg->main.phr_cnfg.dl_pathloss_change]; int pathloss_db = liblte_rrc_dl_pathloss_change_num[mac_cfg->main.phr_cnfg.dl_pathloss_change];
if (pathloss_changed()) { if (pathloss_changed()) {
Info("PHR: Triggered by pathloss difference. cur_pathloss_db=%f (timer expired)\n", last_pathloss_db); Info("PHR: Triggered by pathloss difference. cur_pathloss_db=%f (timer expired)\n", last_pathloss_db);
@ -105,8 +105,8 @@ void phr_proc::step(uint32_t tti)
if (timer_periodic != cfg_timer_periodic && cfg_timer_periodic > 0) if (timer_periodic != cfg_timer_periodic && cfg_timer_periodic > 0)
{ {
timer_periodic = cfg_timer_periodic; timer_periodic = cfg_timer_periodic;
timers_db->get(mac::PHR_TIMER_PERIODIC)->set(this, timer_periodic); timers_db->get(PHR_TIMER_PERIODIC)->set(this, timer_periodic);
timers_db->get(mac::PHR_TIMER_PERIODIC)->run(); timers_db->get(PHR_TIMER_PERIODIC)->run();
phr_is_triggered = true; phr_is_triggered = true;
Info("PHR: Configured timer periodic %d ms\n", timer_periodic); Info("PHR: Configured timer periodic %d ms\n", timer_periodic);
} }
@ -118,12 +118,12 @@ void phr_proc::step(uint32_t tti)
if (timer_prohibit != cfg_timer_prohibit && cfg_timer_prohibit > 0) if (timer_prohibit != cfg_timer_prohibit && cfg_timer_prohibit > 0)
{ {
timer_prohibit = cfg_timer_prohibit; timer_prohibit = cfg_timer_prohibit;
timers_db->get(mac::PHR_TIMER_PROHIBIT)->set(this, timer_prohibit); timers_db->get(PHR_TIMER_PROHIBIT)->set(this, timer_prohibit);
timers_db->get(mac::PHR_TIMER_PROHIBIT)->run(); timers_db->get(PHR_TIMER_PROHIBIT)->run();
Info("PHR: Configured timer prohibit %d ms\n", timer_prohibit); Info("PHR: Configured timer prohibit %d ms\n", timer_prohibit);
phr_is_triggered = true; phr_is_triggered = true;
} }
if (pathloss_changed() && timers_db->get(mac::PHR_TIMER_PROHIBIT)->is_expired()) if (pathloss_changed() && timers_db->get(PHR_TIMER_PROHIBIT)->is_expired())
{ {
Info("PHR: Triggered by pathloss difference. cur_pathloss_db=%f\n", last_pathloss_db); Info("PHR: Triggered by pathloss difference. cur_pathloss_db=%f\n", last_pathloss_db);
phr_is_triggered = true; phr_is_triggered = true;
@ -140,10 +140,10 @@ bool phr_proc::generate_phr_on_ul_grant(float *phr)
Debug("PHR: Generating PHR=%f\n", phr?*phr:0.0); Debug("PHR: Generating PHR=%f\n", phr?*phr:0.0);
timers_db->get(mac::PHR_TIMER_PERIODIC)->reset(); timers_db->get(PHR_TIMER_PERIODIC)->reset();
timers_db->get(mac::PHR_TIMER_PROHIBIT)->reset(); timers_db->get(PHR_TIMER_PROHIBIT)->reset();
timers_db->get(mac::PHR_TIMER_PERIODIC)->run(); timers_db->get(PHR_TIMER_PERIODIC)->run();
timers_db->get(mac::PHR_TIMER_PROHIBIT)->run(); timers_db->get(PHR_TIMER_PROHIBIT)->run();
phr_is_triggered = false; phr_is_triggered = false;

@ -115,7 +115,7 @@ void ra_proc::read_params() {
delta_preamble_db = delta_preamble_db_table[configIndex%5]; delta_preamble_db = delta_preamble_db_table[configIndex%5];
if (contentionResolutionTimer > 0) { if (contentionResolutionTimer > 0) {
timers_db->get(mac::CONTENTION_TIMER)->set(this, contentionResolutionTimer); timers_db->get(CONTENTION_TIMER)->set(this, contentionResolutionTimer);
} }
} }
@ -165,14 +165,14 @@ void ra_proc::process_timeadv_cmd(uint32_t ta) {
if (preambleIndex == 0) { if (preambleIndex == 0) {
// Preamble not selected by UE MAC // Preamble not selected by UE MAC
phy_h->set_timeadv_rar(ta); phy_h->set_timeadv_rar(ta);
timers_db->get(mac::TIME_ALIGNMENT)->reset(); timers_db->get(TIME_ALIGNMENT)->reset();
timers_db->get(mac::TIME_ALIGNMENT)->run(); timers_db->get(TIME_ALIGNMENT)->run();
Debug("Applying RAR TA CMD %d\n", ta); Debug("Applying RAR TA CMD %d\n", ta);
} else { } else {
// Preamble selected by UE MAC // Preamble selected by UE MAC
if (!timers_db->get(mac::TIME_ALIGNMENT)->is_running()) { if (!timers_db->get(TIME_ALIGNMENT)->is_running()) {
phy_h->set_timeadv_rar(ta); phy_h->set_timeadv_rar(ta);
timers_db->get(mac::TIME_ALIGNMENT)->run(); timers_db->get(TIME_ALIGNMENT)->run();
Debug("Applying RAR TA CMD %d\n", ta); Debug("Applying RAR TA CMD %d\n", ta);
} else { } else {
// Ignore TA CMD // Ignore TA CMD
@ -355,8 +355,8 @@ void ra_proc::tb_decoded_ok() {
state = CONTENTION_RESOLUTION; state = CONTENTION_RESOLUTION;
// Start contention resolution timer // Start contention resolution timer
timers_db->get(mac::CONTENTION_TIMER)->reset(); timers_db->get(CONTENTION_TIMER)->reset();
timers_db->get(mac::CONTENTION_TIMER)->run(); timers_db->get(CONTENTION_TIMER)->run();
} }
} else { } else {
rDebug("Found RAR for preamble %d\n", rar_pdu_msg.get()->get_rapid()); rDebug("Found RAR for preamble %d\n", rar_pdu_msg.get()->get_rapid());
@ -417,7 +417,7 @@ bool ra_proc::contention_resolution_id_received(uint64_t rx_contention_id) {
rDebug("MAC PDU Contains Contention Resolution ID CE\n"); rDebug("MAC PDU Contains Contention Resolution ID CE\n");
// MAC PDU successfully decoded and contains MAC CE contention Id // MAC PDU successfully decoded and contains MAC CE contention Id
timers_db->get(mac::CONTENTION_TIMER)->stop(); timers_db->get(CONTENTION_TIMER)->stop();
if (transmitted_contention_id == rx_contention_id) if (transmitted_contention_id == rx_contention_id)
{ {
@ -453,7 +453,7 @@ void ra_proc::step_contention_resolution() {
(started_by_pdcch && pdcch_to_crnti_received != PDCCH_CRNTI_NOT_RECEIVED)) (started_by_pdcch && pdcch_to_crnti_received != PDCCH_CRNTI_NOT_RECEIVED))
{ {
rDebug("PDCCH for C-RNTI received\n"); rDebug("PDCCH for C-RNTI received\n");
timers_db->get(mac::CONTENTION_TIMER)->stop(); timers_db->get(CONTENTION_TIMER)->stop();
rntis->temp_rnti = 0; rntis->temp_rnti = 0;
state = COMPLETION; state = COMPLETION;
} }
@ -559,7 +559,7 @@ void ra_proc::pdcch_to_crnti(bool contains_uplink_grant) {
void ra_proc::harq_retx() void ra_proc::harq_retx()
{ {
timers_db->get(mac::CONTENTION_TIMER)->reset(); timers_db->get(CONTENTION_TIMER)->reset();
} }
} }

Loading…
Cancel
Save