From f2694b74c9af6e308d3886cd3c75864d101de8d4 Mon Sep 17 00:00:00 2001 From: Jacob Erlbeck Date: Tue, 26 Jan 2016 21:46:26 +0100 Subject: tbf: Add check_polling/set_polling Currently the checks for and the actual polling is done in several places by copy & paste of several lines of code. This hinders changes of they polling is handled internally and also is likely source of programming mistakes. Separate this into a check_polling function, that checks whether polling is possible and returns the FN and the RRBP to be used in that case. Otherwise the cause is logged (LOGL_DEBUG) and a negative error value is returned. There are no other side effect beside the logging. If the call is successful, the set_polling method can be used to actually register the polling. Extend the encoder functions' parameters lists by an rrbp parameter. Sponsored-by: On-Waves ehf --- src/tbf_ul.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'src/tbf_ul.cpp') diff --git a/src/tbf_ul.cpp b/src/tbf_ul.cpp index 4754e11f..9e763f4c 100644 --- a/src/tbf_ul.cpp +++ b/src/tbf_ul.cpp @@ -91,19 +91,22 @@ struct msgb *gprs_rlcmac_ul_tbf::create_ul_ack(uint32_t fn, uint8_t ts) { int final = (state_is(GPRS_RLCMAC_FINISHED)); struct msgb *msg; + int rc; + unsigned int rrbp = 0; + uint32_t new_poll_fn = 0; if (final) { - if (poll_state != GPRS_RLCMAC_POLL_NONE) { + if (poll_state == GPRS_RLCMAC_POLL_SCHED && + ul_ack_state == GPRS_RLCMAC_UL_ACK_WAIT_ACK) { LOGP(DRLCMACUL, LOGL_DEBUG, "Polling is already " - "sheduled for %s, so we must wait for " - "final uplink ack...\n", tbf_name(this)); + "scheduled for %s, so we must wait for " + "the final uplink ack...\n", tbf_name(this)); return NULL; } - if (bts->sba()->find(trx->trx_no, ts, (fn + 13) % 2715648)) { - LOGP(DRLCMACUL, LOGL_DEBUG, "Polling is already " - "scheduled for single block allocation...\n"); + + rc = check_polling(fn, ts, &new_poll_fn, &rrbp); + if (rc < 0) return NULL; - } } msg = msgb_alloc(23, "rlcmac_ul_ack"); @@ -116,7 +119,7 @@ struct msgb *gprs_rlcmac_ul_tbf::create_ul_ack(uint32_t fn, uint8_t ts) } bitvec_unhex(ack_vec, "2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b"); - Encoding::write_packet_uplink_ack(bts_data(), ack_vec, this, final); + Encoding::write_packet_uplink_ack(bts_data(), ack_vec, this, final, rrbp); bitvec_pack(ack_vec, msgb_put(msg, 23)); bitvec_free(ack_vec); @@ -125,9 +128,7 @@ struct msgb *gprs_rlcmac_ul_tbf::create_ul_ack(uint32_t fn, uint8_t ts) m_contention_resolution_done = 1; if (final) { - poll_state = GPRS_RLCMAC_POLL_SCHED; - poll_fn = (fn + 13) % 2715648; - poll_ts = ts; + set_polling(new_poll_fn, ts); /* waiting for final acknowledge */ ul_ack_state = GPRS_RLCMAC_UL_ACK_WAIT_ACK; m_final_ack_sent = 1; -- cgit v1.2.3