diff options
author | Jacob Erlbeck <jerlbeck@sysmocom.de> | 2015-09-01 11:20:29 +0200 |
---|---|---|
committer | Jacob Erlbeck <jerlbeck@sysmocom.de> | 2015-09-01 11:49:04 +0200 |
commit | 91ff7d1864f0248ab5f45047069c09d7843212ca (patch) | |
tree | 48ace6cb13ba8df31b63a0c50f134bb985fc7a5c /src | |
parent | 9659d593073dfb6711f2ed9ad7bee4ca454db784 (diff) |
tbf: Refactor reuse_tbf into releasing and DL TBF establishment
Currently reuse_tbf (partly) resets the old DL TBF and uses its PACCH
to establish a new DL TBF. The method can not be used with UL TBFs.
This commit replaces the reuse_tbf method into a
gprs_rlcmac_dl_tbf:release method which triggers the TBF's timer
based deletion (so that the TFI is still reserved for some time) and
a gprs_rlcmac_tbf::establish_dl_tbf_on_pacch which can establish DL
TBFs on existing PACCHs of either DL or UL TBFs.
Sponsored-by: On-Waves ehf
Diffstat (limited to 'src')
-rw-r--r-- | src/tbf.cpp | 21 | ||||
-rw-r--r-- | src/tbf.h | 2 | ||||
-rw-r--r-- | src/tbf_dl.cpp | 59 |
3 files changed, 47 insertions, 35 deletions
diff --git a/src/tbf.cpp b/src/tbf.cpp index 42d522bd..b604c683 100644 --- a/src/tbf.cpp +++ b/src/tbf.cpp @@ -960,6 +960,27 @@ void gprs_rlcmac_tbf::free_all(struct gprs_rlcmac_pdch *pdch) } } +int gprs_rlcmac_tbf::establish_dl_tbf_on_pacch() +{ + struct gprs_rlcmac_dl_tbf *new_tbf = NULL; + + bts->tbf_reused(); + + new_tbf = tbf_alloc_dl_tbf(bts->bts_data(), ms(), + this->trx->trx_no, ms_class(), 0); + + if (!new_tbf) { + LOGP(DRLCMAC, LOGL_NOTICE, "No PDCH resource\n"); + return -1; + } + + LOGP(DRLCMAC, LOGL_DEBUG, "%s Trigger downlink assignment on PACCH\n", + tbf_name(this)); + bts->trigger_dl_ass(new_tbf, this); + + return 0; +} + int gprs_rlcmac_tbf::extract_tlli(const uint8_t *data, const size_t len) { struct gprs_rlcmac_tbf *dl_tbf = NULL; @@ -137,6 +137,7 @@ struct gprs_rlcmac_tbf { void handle_timeout(); void stop_timer(); void stop_t3191(); + int establish_dl_tbf_on_pacch(); void poll_timeout(); @@ -337,6 +338,7 @@ struct gprs_rlcmac_dl_tbf : public gprs_rlcmac_tbf { int frames_since_last_poll(unsigned fn) const; int frames_since_last_drain(unsigned fn) const; bool keep_open(unsigned fn) const; + int release(); bool is_control_ts(uint8_t ts) const { return ts == control_ts; diff --git a/src/tbf_dl.cpp b/src/tbf_dl.cpp index b57e10e0..aabe8e3e 100644 --- a/src/tbf_dl.cpp +++ b/src/tbf_dl.cpp @@ -118,7 +118,7 @@ int gprs_rlcmac_dl_tbf::append_data(const uint8_t ms_class, "%s in WAIT RELEASE state " "(T3193), so reuse TBF\n", tbf_name(this)); tbf_update_ms_class(this, ms_class); - reuse_tbf(); + establish_dl_tbf_on_pacch(); } return 0; @@ -833,9 +833,20 @@ int gprs_rlcmac_dl_tbf::update_window(const uint8_t ssn, const uint8_t *rbb) int gprs_rlcmac_dl_tbf::maybe_start_new_window() { + release(); + + /* check for LLC PDU in the LLC Queue */ + if (llc_queue()->size() > 0) + /* we have more data so we will re-use this tbf */ + establish_dl_tbf_on_pacch(); + + return 0; +} + +int gprs_rlcmac_dl_tbf::release() +{ uint16_t received; - LOGP(DRLCMACDL, LOGL_DEBUG, "- Final ACK received.\n"); /* range V(A)..V(S)-1 */ received = m_window.count_unacked(); @@ -849,50 +860,28 @@ int gprs_rlcmac_dl_tbf::maybe_start_new_window() bts_data()->t3193_msec / 1000, (bts_data()->t3193_msec % 1000) * 1000); - /* check for LLC PDU in the LLC Queue */ - if (have_data()) - /* we have more data so we will re-use this tbf */ - reuse_tbf(); + /* reset rlc states */ + m_tx_counter = 0; + m_wait_confirm = 0; + m_window.reset(); + + /* keep to flags */ + state_flags &= GPRS_RLCMAC_FLAG_TO_MASK; + state_flags &= ~(1 << GPRS_RLCMAC_FLAG_CCCH); return 0; } + int gprs_rlcmac_dl_tbf::rcvd_dl_ack(uint8_t final_ack, uint8_t ssn, uint8_t *rbb) { LOGP(DRLCMACDL, LOGL_DEBUG, "%s downlink acknowledge\n", tbf_name(this)); if (!final_ack) return update_window(ssn, rbb); - return maybe_start_new_window(); -} - -void gprs_rlcmac_dl_tbf::reuse_tbf() -{ - struct gprs_rlcmac_dl_tbf *new_tbf = NULL; - - bts->tbf_reused(); - - new_tbf = tbf_alloc_dl_tbf(bts->bts_data(), ms(), - this->trx->trx_no, ms_class(), 0); - - if (!new_tbf) { - LOGP(DRLCMAC, LOGL_NOTICE, "No PDCH resource\n"); - return; - } - - /* reset rlc states */ - m_tx_counter = 0; - m_wait_confirm = 0; - m_window.reset(); - - /* keep to flags */ - state_flags &= GPRS_RLCMAC_FLAG_TO_MASK; - state_flags &= ~(1 << GPRS_RLCMAC_FLAG_CCCH); - LOGP(DRLCMAC, LOGL_DEBUG, "%s Trigger dowlink assignment on PACCH, " - "because another LLC PDU has arrived in between\n", - tbf_name(this)); - bts->trigger_dl_ass(new_tbf, this); + LOGP(DRLCMACDL, LOGL_DEBUG, "- Final ACK received.\n"); + return maybe_start_new_window(); } bool gprs_rlcmac_dl_tbf::dl_window_stalled() const |