From 86300bbeea0601e2a1be34021f438433b5f01a27 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Sat, 26 Oct 2013 18:01:35 +0200 Subject: tbf: Move the timer routine into the class The timer is used for various timeouts and there is still external client code that is calling it. In a perfect world the client code would indicate that an event has happened and the internal timer will be stopped. The best compromise is the "stop_t3191" method. It allows to add semantic verification that the timer has been running. --- src/bts.cpp | 5 ++--- src/gprs_rlcmac_data.cpp | 4 ++-- src/tbf.cpp | 16 ++++++++++------ src/tbf.h | 4 ++-- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/bts.cpp b/src/bts.cpp index 3c7ce40..089ef28 100644 --- a/src/bts.cpp +++ b/src/bts.cpp @@ -637,7 +637,7 @@ int gprs_rlcmac_pdch::rcv_control_block(struct gprs_rlcmac_bts *bts, } tbf_new_state(tbf, GPRS_RLCMAC_FLOW); /* stop pending assignment timer */ - tbf_timer_stop(tbf); + tbf->stop_timer(); if ((tbf->state_flags & (1 << GPRS_RLCMAC_FLAG_TO_DL_ASS))) { tbf->state_flags &= @@ -698,8 +698,7 @@ int gprs_rlcmac_pdch::rcv_control_block(struct gprs_rlcmac_bts *bts, } /* reset N3105 */ tbf->n3105 = 0; - /* stop timer T3191 */ - tbf_timer_stop(tbf); + tbf->stop_t3191(); tlli = tbf->tlli; LOGP(DRLCMAC, LOGL_DEBUG, "RX: [PCU <- BTS] TFI: %u TLLI: 0x%08x Packet Downlink Ack/Nack\n", tbf->tfi, tbf->tlli); tbf->poll_state = GPRS_RLCMAC_POLL_NONE; diff --git a/src/gprs_rlcmac_data.cpp b/src/gprs_rlcmac_data.cpp index 035c203..d5bebff 100644 --- a/src/gprs_rlcmac_data.cpp +++ b/src/gprs_rlcmac_data.cpp @@ -928,7 +928,7 @@ struct msgb *gprs_rlcmac_send_packet_downlink_assignment( tbf_new_state(new_tbf, GPRS_RLCMAC_FLOW); tbf_assign_control_ts(new_tbf); /* stop pending assignment timer */ - tbf_timer_stop(new_tbf); + new_tbf->stop_timer(); } debug_diagram(bts->bts, tbf->diag, "send DL-ASS"); @@ -968,7 +968,7 @@ void gprs_rlcmac_trigger_downlink_assignment( #endif /* stop pending timer */ - tbf_timer_stop(tbf); + tbf->stop_timer(); /* check for downlink tbf: */ if (old_tbf) { diff --git a/src/tbf.cpp b/src/tbf.cpp index 91db27a..21cd4ee 100644 --- a/src/tbf.cpp +++ b/src/tbf.cpp @@ -299,7 +299,7 @@ void tbf_free(struct gprs_rlcmac_tbf *tbf) "assignment. This may not happen, because the " "assignment message never gets transmitted. Please " "be shure not to free in this state. PLEASE FIX!\n"); - tbf_timer_stop(tbf); + tbf->stop_timer(); while ((msg = msgb_dequeue(&tbf->llc_queue))) msgb_free(msg); tbf_unlink_pdch(tbf); @@ -392,13 +392,17 @@ void tbf_timer_start(struct gprs_rlcmac_tbf *tbf, unsigned int T, osmo_timer_schedule(&tbf->timer, seconds, microseconds); } -void tbf_timer_stop(struct gprs_rlcmac_tbf *tbf) +void gprs_rlcmac_tbf::stop_t3191() { - if (osmo_timer_pending(&tbf->timer)) { + return stop_timer(); +} + +void gprs_rlcmac_tbf::stop_timer() +{ + if (osmo_timer_pending(&timer)) { LOGP(DRLCMAC, LOGL_DEBUG, "Stopping %s TBF=%d timer %u.\n", - (tbf->direction == GPRS_RLCMAC_UL_TBF) ? "UL" : "DL", - tbf->tfi, tbf->T); - osmo_timer_del(&tbf->timer); + (direction == GPRS_RLCMAC_UL_TBF) ? "UL" : "DL", tfi, T); + osmo_timer_del(&timer); } } diff --git a/src/tbf.h b/src/tbf.h index 5742032..3e8346c 100644 --- a/src/tbf.h +++ b/src/tbf.h @@ -103,6 +103,8 @@ struct gprs_rlcmac_tbf { int update(); void handle_timeout(); + void stop_timer(); + void stop_t3191(); struct llist_head list; uint32_t state_flags; @@ -239,8 +241,6 @@ void tbf_new_state(struct gprs_rlcmac_tbf *tbf, void tbf_timer_start(struct gprs_rlcmac_tbf *tbf, unsigned int T, unsigned int seconds, unsigned int microseconds); -void tbf_timer_stop(struct gprs_rlcmac_tbf *tbf); - inline bool gprs_rlcmac_tbf::state_is(enum gprs_rlcmac_tbf_state rhs) const { return state == rhs; -- cgit v1.2.3