diff options
author | Jacob Erlbeck <jerlbeck@sysmocom.de> | 2015-03-19 13:22:07 +0100 |
---|---|---|
committer | Jacob Erlbeck <jerlbeck@sysmocom.de> | 2015-03-20 14:32:20 +0100 |
commit | 95340242ed1089e30b9a3045ea55bc9068432e0b (patch) | |
tree | 9210649bf1ff01a6257db894fd4b4de35d7d81cb /src/tbf_dl.cpp | |
parent | 612e93e36031ab2d50dd66d148f289b2e3580850 (diff) |
tbf: Refactor create_dl_acked_block
Turn the big nested if statement into a sequence of smaller ones. The
call to create_new_bsn is moved upwards.
Sponsored-by: On-Waves ehf
Diffstat (limited to 'src/tbf_dl.cpp')
-rw-r--r-- | src/tbf_dl.cpp | 84 |
1 files changed, 42 insertions, 42 deletions
diff --git a/src/tbf_dl.cpp b/src/tbf_dl.cpp index dea18bd7..55dade70 100644 --- a/src/tbf_dl.cpp +++ b/src/tbf_dl.cpp @@ -257,50 +257,50 @@ do_resend: /* if the window has stalled, or transfer is complete, * send an unacknowledged block */ - if (state_is(GPRS_RLCMAC_FINISHED) || dl_window_stalled()) { - if (state_is(GPRS_RLCMAC_FINISHED)) { - LOGP(DRLCMACDL, LOGL_DEBUG, "- Restarting at BSN %d, " - "because all blocks have been transmitted.\n", - m_window.v_a()); - bts->rlc_restarted(); - } else { - LOGP(DRLCMACDL, LOGL_NOTICE, "- Restarting at BSN %d, " - "because all window is stalled.\n", - m_window.v_a()); - bts->rlc_stalled(); - } - /* If V(S) == V(A) and finished state, we would have received - * acknowledgement of all transmitted block. In this case we - * would have transmitted the final block, and received ack - * from MS. But in this case we did not receive the final ack - * indication from MS. This should never happen if MS works - * correctly. */ - if (m_window.window_empty()) { - LOGP(DRLCMACDL, LOGL_DEBUG, "- MS acked all blocks, " - "so we re-transmit final block!\n"); - /* we just send final block again */ - int16_t index = m_window.v_s_mod(-1); - bts->rlc_resent(); - return create_dl_acked_block(fn, ts, index); - } - - /* cycle through all unacked blocks */ - int resend = m_window.mark_for_resend(); - - /* At this point there should be at least one unacked block - * to be resent. If not, this is an software error. */ - if (resend == 0) { - LOGP(DRLCMACDL, LOGL_ERROR, "Software error: " - "There are no unacknowledged blocks, but V(A) " - " != V(S). PLEASE FIX!\n"); - /* we just send final block again */ - int16_t index = m_window.v_s_mod(-1); - return create_dl_acked_block(fn, ts, index); - } - goto do_resend; + if (state_is(GPRS_RLCMAC_FINISHED)) { + LOGP(DRLCMACDL, LOGL_DEBUG, "- Restarting at BSN %d, " + "because all blocks have been transmitted.\n", + m_window.v_a()); + bts->rlc_restarted(); + } else if (dl_window_stalled()) { + LOGP(DRLCMACDL, LOGL_NOTICE, "- Restarting at BSN %d, " + "because all window is stalled.\n", + m_window.v_a()); + bts->rlc_stalled(); + } else { + /* No blocks are left */ + return create_new_bsn(fn, ts); } - return create_new_bsn(fn, ts); + /* If V(S) == V(A) and finished state, we would have received + * acknowledgement of all transmitted block. In this case we + * would have transmitted the final block, and received ack + * from MS. But in this case we did not receive the final ack + * indication from MS. This should never happen if MS works + * correctly. */ + if (m_window.window_empty()) { + LOGP(DRLCMACDL, LOGL_DEBUG, "- MS acked all blocks, " + "so we re-transmit final block!\n"); + /* we just send final block again */ + int16_t index = m_window.v_s_mod(-1); + bts->rlc_resent(); + return create_dl_acked_block(fn, ts, index); + } + + /* cycle through all unacked blocks */ + int resend = m_window.mark_for_resend(); + + /* At this point there should be at least one unacked block + * to be resent. If not, this is an software error. */ + if (resend == 0) { + LOGP(DRLCMACDL, LOGL_ERROR, "Software error: " + "There are no unacknowledged blocks, but V(A) " + " != V(S). PLEASE FIX!\n"); + /* we just send final block again */ + int16_t index = m_window.v_s_mod(-1); + return create_dl_acked_block(fn, ts, index); + } + goto do_resend; } struct msgb *gprs_rlcmac_dl_tbf::create_new_bsn(const uint32_t fn, const uint8_t ts) |