Review at https://gerrit.osmocom.org/5863
TBF: make UL ack state internal * add functions/macros for setting TBF's UL ack state * add functions for checking TBF's UL ack state * update TBF test output due to extended state transition logging N. B: this should not be confused with TBF-UL state. Change-Id: I144483447d4b0b93e775da0e926ee45eb8ab39f3 Related: OS#1539 --- M src/gprs_rlcmac_sched.cpp M src/tbf.cpp M src/tbf.h M src/tbf_ul.cpp M tests/tbf/TbfTest.cpp M tests/tbf/TbfTest.err 6 files changed, 49 insertions(+), 13 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/63/5863/1 diff --git a/src/gprs_rlcmac_sched.cpp b/src/gprs_rlcmac_sched.cpp index a87217f..3f9fcb1 100644 --- a/src/gprs_rlcmac_sched.cpp +++ b/src/gprs_rlcmac_sched.cpp @@ -52,7 +52,7 @@ if (ul_tbf->poll_state == GPRS_RLCMAC_POLL_SCHED && ul_tbf->poll_fn == poll_fn) *poll_tbf = ul_tbf; - if (ul_tbf->ul_ack_state == GPRS_RLCMAC_UL_ACK_SEND_ACK) + if (ul_tbf->ul_ack_state_is(GPRS_RLCMAC_UL_ACK_SEND_ACK)) *ul_ack_tbf = ul_tbf; if (ul_tbf->dl_ass_state_is(GPRS_RLCMAC_DL_ASS_SEND_ASS)) *dl_ass_tbf = ul_tbf; diff --git a/src/tbf.cpp b/src/tbf.cpp index 6ebe77e..ef78820 100644 --- a/src/tbf.cpp +++ b/src/tbf.cpp @@ -60,6 +60,13 @@ { 0, NULL } }; +const struct value_string gprs_rlcmac_tbf_ul_ack_state_names[] = { + OSMO_VALUE_STRING(GPRS_RLCMAC_UL_ACK_NONE), + OSMO_VALUE_STRING(GPRS_RLCMAC_UL_ACK_SEND_ACK), /* send acknowledge on next RTS */ + OSMO_VALUE_STRING(GPRS_RLCMAC_UL_ACK_WAIT_ACK), /* wait for PACKET CONTROL ACK */ + { 0, NULL } +}; + static const struct value_string tbf_timers_names[] = { OSMO_VALUE_STRING(T0), OSMO_VALUE_STRING(T3169), @@ -165,7 +172,6 @@ first_ts(0), first_common_ts(0), control_ts(0xff), - ul_ack_state(GPRS_RLCMAC_UL_ACK_NONE), poll_state(GPRS_RLCMAC_POLL_NONE), poll_fn(0), poll_ts(0), @@ -185,6 +191,7 @@ state(GPRS_RLCMAC_NULL), dl_ass_state(GPRS_RLCMAC_DL_ASS_NONE), ul_ass_state(GPRS_RLCMAC_UL_ASS_NONE), + ul_ack_state(GPRS_RLCMAC_UL_ACK_NONE), m_list(this), m_ms_list(this), m_egprs_enabled(false) diff --git a/src/tbf.h b/src/tbf.h index 7cc0587..19aa41a 100644 --- a/src/tbf.h +++ b/src/tbf.h @@ -87,6 +87,8 @@ GPRS_RLCMAC_UL_ACK_WAIT_ACK, /* wait for PACKET CONTROL ACK */ }; +extern const struct value_string gprs_rlcmac_tbf_ul_ack_state_names[]; + enum gprs_rlcmac_tbf_direction { GPRS_RLCMAC_DL_TBF, GPRS_RLCMAC_UL_TBF @@ -183,6 +185,7 @@ #define TBF_SET_STATE(t, st) do { t->set_state(st, __FILE__, __LINE__); } while(0) #define TBF_SET_ASS_STATE_DL(t, st) do { t->set_ass_state_dl(st, __FILE__, __LINE__); } while(0) #define TBF_SET_ASS_STATE_UL(t, st) do { t->set_ass_state_ul(st, __FILE__, __LINE__); } while(0) +#define TBF_SET_ACK_STATE(t, st) do { t->set_ack_state(st, __FILE__, __LINE__); } while(0) #define TBF_SET_ASS_ON(t, fl, chk) do { t->set_assigned_on(fl, chk, __FILE__, __LINE__); } while(0) struct gprs_rlcmac_tbf { @@ -195,9 +198,11 @@ bool state_is_not(enum gprs_rlcmac_tbf_state rhs) const; bool dl_ass_state_is(enum gprs_rlcmac_tbf_dl_ass_state rhs) const; bool ul_ass_state_is(enum gprs_rlcmac_tbf_ul_ass_state rhs) const; + bool ul_ack_state_is(enum gprs_rlcmac_tbf_ul_ack_state rhs) const; void set_state(enum gprs_rlcmac_tbf_state new_state, const char *file, int line); void set_ass_state_dl(enum gprs_rlcmac_tbf_dl_ass_state new_state, const char *file, int line); void set_ass_state_ul(enum gprs_rlcmac_tbf_ul_ass_state new_state, const char *file, int line); + void set_ack_state(enum gprs_rlcmac_tbf_ul_ack_state new_state, const char *file, int line); void check_pending_ass(); bool check_n_clear(uint8_t state_flag); void set_assigned_on(uint8_t state_flag, bool check_ccch, const char *file, int line); @@ -279,8 +284,6 @@ gprs_llc m_llc; - enum gprs_rlcmac_tbf_ul_ack_state ul_ack_state; - enum gprs_rlcmac_tbf_poll_state poll_state; uint32_t poll_fn; /* frame number to poll */ uint8_t poll_ts; /* TS to poll */ @@ -343,6 +346,7 @@ enum gprs_rlcmac_tbf_state state; enum gprs_rlcmac_tbf_dl_ass_state dl_ass_state; enum gprs_rlcmac_tbf_ul_ass_state ul_ass_state; + enum gprs_rlcmac_tbf_ul_ack_state ul_ack_state; LListHead<gprs_rlcmac_tbf> m_list; LListHead<gprs_rlcmac_tbf> m_ms_list; bool m_egprs_enabled; @@ -383,6 +387,11 @@ inline bool gprs_rlcmac_tbf::ul_ass_state_is(enum gprs_rlcmac_tbf_ul_ass_state rhs) const { return ul_ass_state == rhs; +} + +inline bool gprs_rlcmac_tbf::ul_ack_state_is(enum gprs_rlcmac_tbf_ul_ack_state rhs) const +{ + return ul_ack_state == rhs; } inline bool gprs_rlcmac_tbf::state_is_not(enum gprs_rlcmac_tbf_state rhs) const @@ -434,6 +443,15 @@ ul_ass_state = new_state; } +inline void gprs_rlcmac_tbf::set_ack_state(enum gprs_rlcmac_tbf_ul_ack_state new_state, const char *file, int line) +{ + LOGPSRC(DRLCMAC, LOGL_DEBUG, file, line, "%s changes UL ACK state from %s to %s\n", + tbf_name(this), + get_value_string(gprs_rlcmac_tbf_ul_ack_state_names, ul_ack_state), + get_value_string(gprs_rlcmac_tbf_ul_ack_state_names, new_state)); + ul_ack_state = new_state; +} + inline void gprs_rlcmac_tbf::check_pending_ass() { if (ul_ass_state != GPRS_RLCMAC_UL_ASS_NONE) diff --git a/src/tbf_ul.cpp b/src/tbf_ul.cpp index eaf9c93..de3d247 100644 --- a/src/tbf_ul.cpp +++ b/src/tbf_ul.cpp @@ -106,8 +106,8 @@ bool gprs_rlcmac_ul_tbf::handle_ctrl_ack() { /* check if this control ack belongs to packet uplink ack */ - if (ul_ack_state == GPRS_RLCMAC_UL_ACK_WAIT_ACK) { - ul_ack_state = GPRS_RLCMAC_UL_ACK_NONE; + if (ul_ack_state_is(GPRS_RLCMAC_UL_ACK_WAIT_ACK)) { + TBF_SET_ACK_STATE(this, GPRS_RLCMAC_UL_ACK_NONE); return true; } @@ -124,7 +124,7 @@ if (final) { if (poll_state == GPRS_RLCMAC_POLL_SCHED && - ul_ack_state == GPRS_RLCMAC_UL_ACK_WAIT_ACK) { + ul_ack_state_is(GPRS_RLCMAC_UL_ACK_WAIT_ACK)) { LOGPTBFUL(this, LOGL_DEBUG, "Polling is already scheduled, so we must wait for the final uplink ack...\n"); return NULL; @@ -158,7 +158,7 @@ /* waiting for final acknowledge */ m_final_ack_sent = 1; } else - ul_ack_state = GPRS_RLCMAC_UL_ACK_NONE; + TBF_SET_ACK_STATE(this, GPRS_RLCMAC_UL_ACK_NONE); return msg; } @@ -369,9 +369,9 @@ "because %d frames received.\n", SEND_ACK_AFTER_FRAMES); } - if (ul_ack_state == GPRS_RLCMAC_UL_ACK_NONE) { + if (ul_ack_state_is(GPRS_RLCMAC_UL_ACK_NONE)) { /* trigger sending at next RTS */ - ul_ack_state = GPRS_RLCMAC_UL_ACK_SEND_ACK; + TBF_SET_ACK_STATE(this, GPRS_RLCMAC_UL_ACK_SEND_ACK); } else { /* already triggered */ LOGP(DRLCMACUL, LOGL_DEBUG, "- Sending Ack/Nack is " diff --git a/tests/tbf/TbfTest.cpp b/tests/tbf/TbfTest.cpp index 968f9eb..0ac519c 100644 --- a/tests/tbf/TbfTest.cpp +++ b/tests/tbf/TbfTest.cpp @@ -1350,7 +1350,7 @@ request_dl_rlc_block(ul_tbf, fn); check_tbf(ul_tbf); - OSMO_ASSERT(ul_tbf->ul_ack_state == GPRS_RLCMAC_UL_ACK_NONE); + OSMO_ASSERT(ul_tbf->ul_ack_state_is(GPRS_RLCMAC_UL_ACK_NONE)); ms = the_bts->ms_by_tlli(tlli); OSMO_ASSERT(ms != NULL); @@ -1434,7 +1434,7 @@ request_dl_rlc_block(ul_tbf, fn); check_tbf(ul_tbf); - OSMO_ASSERT(ul_tbf->ul_ack_state == GPRS_RLCMAC_UL_ACK_NONE); + OSMO_ASSERT(ul_tbf->ul_ack_state_is(GPRS_RLCMAC_UL_ACK_NONE)); ms = the_bts->ms_by_tlli(tlli); OSMO_ASSERT(ms != NULL); @@ -1522,7 +1522,7 @@ request_dl_rlc_block(ul_tbf, fn); check_tbf(ul_tbf); - OSMO_ASSERT(ul_tbf->ul_ack_state == GPRS_RLCMAC_UL_ACK_NONE); + OSMO_ASSERT(ul_tbf->ul_ack_state_is(GPRS_RLCMAC_UL_ACK_NONE)); ms = the_bts->ms_by_tlli(tlli); OSMO_ASSERT(ms != NULL); diff --git a/tests/tbf/TbfTest.err b/tests/tbf/TbfTest.err index 00f50b8..687ec3b 100644 --- a/tests/tbf/TbfTest.err +++ b/tests/tbf/TbfTest.err @@ -1594,6 +1594,7 @@ TBF(TFI=0 TLLI=0xf1223344 DIR=UL STATE=FLOW) changes state from FLOW to FINISHED - Scheduling Ack/Nack, because TLLI is included. - Scheduling Ack/Nack, because last block has CV==0. +TBF(TFI=0 TLLI=0xf1223344 DIR=UL STATE=FINISHED) changes UL ACK state from GPRS_RLCMAC_UL_ACK_NONE to GPRS_RLCMAC_UL_ACK_SEND_ACK Got 'TBF(TFI=0 TLLI=0xf1223344 DIR=UL STATE=FINISHED)', TA=7 Got MS: TLLI = 0xf1223344, TA = 7 ********** DL-TBF starts here ********** @@ -2257,6 +2258,7 @@ TBF(TFI=0 TLLI=0xf1223344 DIR=UL STATE=FLOW) changes state from FLOW to FINISHED - Scheduling Ack/Nack, because TLLI is included. - Scheduling Ack/Nack, because last block has CV==0. +TBF(TFI=0 TLLI=0xf1223344 DIR=UL STATE=FINISHED) changes UL ACK state from GPRS_RLCMAC_UL_ACK_NONE to GPRS_RLCMAC_UL_ACK_SEND_ACK New MS: TLLI = 0xf1223344, TA = 7, IMSI = 0011223344, LLC = 2 Sending data request: trx=0 ts=7 sapi=5 arfcn=0 fn=2654218 block=8 data=47 94 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b MS requests UL TBF on RACH, so we provide one: ra=0x73 Fn=2654167 qta=31 is_11bit=0: @@ -3627,6 +3629,7 @@ -- Frame 1 starts at offset 0, length=74, is_complete=0 - No gaps in received block, last block: BSN=1 CV=7 - Scheduling Ack/Nack, because MS is stalled. +TBF(TFI=0 TLLI=0xf1223344 DIR=UL STATE=FLOW EGPRS) changes UL ACK state from GPRS_RLCMAC_UL_ACK_NONE to GPRS_RLCMAC_UL_ACK_SEND_ACK Got RLC block, coding scheme: MCS-3, length: 42 (42)) UL data: 1f 10 40 cd 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 Got MCS-3 RLC block: R=1, SI=1, TFI=0, CPS=5, RSB=0, rc=329 @@ -6574,6 +6577,7 @@ Encoding Ack/Nack for TBF(TFI=0 TLLI=0xf1223344 DIR=UL STATE=FLOW EGPRS) (final=0) EGPRS URBB, urbb len = 0, SSN = 3, ESN_CRBB = 2, len present = yes,desc len = 15, SNS = 2048, WS = 64, V(Q) = 2, V(R) = 2, BOW, EOW Uplink Ack/Nack bit count 98, max 184, message = 40 24 01 3f 3e 24 46 68 90 87 b0 06 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b +TBF(TFI=0 TLLI=0xf1223344 DIR=UL STATE=FLOW EGPRS) changes UL ACK state from GPRS_RLCMAC_UL_ACK_NONE to GPRS_RLCMAC_UL_ACK_NONE Got RLC block, coding scheme: MCS-3, length: 42 (42)) UL data: 1d 20 40 c1 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 Got MCS-3 RLC block: R=1, SI=0, TFI=0, CPS=5, RSB=0, rc=329 @@ -6587,6 +6591,7 @@ Encoding Ack/Nack for TBF(TFI=0 TLLI=0xf1223344 DIR=UL STATE=FLOW EGPRS) (final=0) EGPRS URBB, urbb len = 2, SSN = 3, ESN_CRBB = 2, len present = yes,desc len = 17, SNS = 2048, WS = 64, V(Q) = 2, V(R) = 5, BOW, EOW Uplink Ack/Nack bit count 100, max 184, message = 40 24 01 3f 3e 24 46 68 90 88 b0 06 8b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b +TBF(TFI=0 TLLI=0xf1223344 DIR=UL STATE=FLOW EGPRS) changes UL ACK state from GPRS_RLCMAC_UL_ACK_NONE to GPRS_RLCMAC_UL_ACK_NONE Got 'TBF(TFI=0 TLLI=0xf1223344 DIR=UL STATE=FLOW EGPRS)', TA=7 Got MS: TLLI = 0xf1223344, TA = 7 ********** DL-TBF starts here ********** @@ -7391,6 +7396,7 @@ TBF(TFI=0 TLLI=0xf1223344 DIR=UL STATE=FLOW EGPRS): data_length=44, data=00 80 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 - Raising V(R) to 39 - Scheduling Ack/Nack, because 20 frames received. +TBF(TFI=0 TLLI=0xf1223344 DIR=UL STATE=FLOW EGPRS) changes UL ACK state from GPRS_RLCMAC_UL_ACK_NONE to GPRS_RLCMAC_UL_ACK_SEND_ACK Got RLC block, coding scheme: MCS-4, length: 49 (49)) UL data: 28 40 01 80 00 00 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b Got MCS-4 RLC block: R=0, SI=0, TFI=0, CPS=0, RSB=0, rc=385 @@ -8002,6 +8008,7 @@ the ucmp len=157 uclen_crbb=19 num_blocks=157 crbb length 78, and the CRBB bitmap = 1e 1e 1e 1e 1e 1e 1e 1e 1e 1e EGPRS URBB, urbb len = 94, SSN = 2, ESN_CRBB = 1, len present = No,desc len = 109, SNS = 2048, WS = 192, V(Q) = 1, V(R) = 159, BOW Uplink Ack/Nack bit count 184, max 184, message = 40 24 01 3f 3e 24 46 68 90 20 04 55 55 55 55 55 55 55 55 55 55 55 54 +TBF(TFI=0 TLLI=0xf1223344 DIR=UL STATE=FLOW EGPRS) changes UL ACK state from GPRS_RLCMAC_UL_ACK_SEND_ACK to GPRS_RLCMAC_UL_ACK_NONE Got RLC block, coding scheme: MCS-4, length: 49 (49)) UL data: 00 00 02 80 00 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b Got MCS-4 RLC block: R=0, SI=0, TFI=0, CPS=0, RSB=0, rc=385 @@ -8235,6 +8242,7 @@ TBF(TFI=0 TLLI=0xf1223344 DIR=UL STATE=FLOW EGPRS): data_length=44, data=00 80 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 - Raising V(R) to 37 - Scheduling Ack/Nack, because 20 frames received. +TBF(TFI=0 TLLI=0xf1223344 DIR=UL STATE=FLOW EGPRS) changes UL ACK state from GPRS_RLCMAC_UL_ACK_NONE to GPRS_RLCMAC_UL_ACK_SEND_ACK Got RLC block, coding scheme: MCS-4, length: 49 (49)) UL data: 28 30 01 80 00 00 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b Got MCS-4 RLC block: R=0, SI=0, TFI=0, CPS=0, RSB=0, rc=385 @@ -8248,6 +8256,7 @@ Encoding Ack/Nack for TBF(TFI=0 TLLI=0xf1223344 DIR=UL STATE=FLOW EGPRS) (final=0) EGPRS URBB, urbb len = 37, SSN = 2, ESN_CRBB = 1, len present = yes,desc len = 52, SNS = 2048, WS = 192, V(Q) = 1, V(R) = 39, BOW, EOW Uplink Ack/Nack bit count 135, max 184, message = 40 24 01 3f 3e 24 46 68 90 9a 30 04 aa aa aa aa a9 2b 2b 2b 2b 2b 2b +TBF(TFI=0 TLLI=0xf1223344 DIR=UL STATE=FLOW EGPRS) changes UL ACK state from GPRS_RLCMAC_UL_ACK_SEND_ACK to GPRS_RLCMAC_UL_ACK_NONE Got RLC block, coding scheme: MCS-4, length: 49 (49)) UL data: 00 00 02 80 00 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b Got MCS-4 RLC block: R=0, SI=0, TFI=0, CPS=0, RSB=0, rc=385 @@ -8449,6 +8458,7 @@ TBF(TFI=0 TLLI=0xf1223344 DIR=UL STATE=FLOW EGPRS): data_length=44, data=00 80 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 - Raising V(R) to 98 - Scheduling Ack/Nack, because 20 frames received. +TBF(TFI=0 TLLI=0xf1223344 DIR=UL STATE=FLOW EGPRS) changes UL ACK state from GPRS_RLCMAC_UL_ACK_NONE to GPRS_RLCMAC_UL_ACK_SEND_ACK Got RLC block, coding scheme: MCS-4, length: 49 (49)) UL data: 28 10 03 80 00 00 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b Got MCS-4 RLC block: R=0, SI=0, TFI=0, CPS=0, RSB=0, rc=385 @@ -9082,6 +9092,7 @@ EGPRS CRBB, crbb_len = 30, crbb_start_clr_code = 0 EGPRS URBB, urbb len = 0, SSN = 1, ESN_CRBB = 159, len present = yes,desc len = 53, SNS = 2048, WS = 192, V(Q) = 0, V(R) = 160, BOW, EOW Uplink Ack/Nack bit count 136, max 184, message = 40 24 01 3f 3e 24 46 68 90 9a b0 03 3c 03 c3 1b a0 2b 2b 2b 2b 2b 2b +TBF(TFI=0 TLLI=0xf1223344 DIR=UL STATE=FLOW EGPRS) changes UL ACK state from GPRS_RLCMAC_UL_ACK_SEND_ACK to GPRS_RLCMAC_UL_ACK_NONE Got RLC block, coding scheme: MCS-4, length: 49 (49)) UL data: 00 00 02 80 00 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b Got MCS-4 RLC block: R=0, SI=0, TFI=0, CPS=0, RSB=0, rc=385 -- To view, visit https://gerrit.osmocom.org/5863 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I144483447d4b0b93e775da0e926ee45eb8ab39f3 Gerrit-PatchSet: 1 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: Max <msur...@sysmocom.de>