From 4da257390f58fdd6ca26ddfa576072180a5d201b Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Tue, 21 Feb 2023 14:43:17 +0100 Subject: [PATCH] rlcmac: ul_tbf: Submit event FIST_UL_DATA_SENT before LAST_UL_DATA_SENT If there's only 1 block to be sent, the LAST_UL_DATA_SENT was being sent before the FIRST_UL_DATA_SENT one, which created problems in the FSM (when adding more logic later). Furthermroe, this change also makes it send retransmission events, which makes it similar for both FIRST and LAST events. This will also be needed for T3182. Change-Id: I701dbe00ff2af62c45d862a9211b5b1120f3efa3 --- src/rlcmac/tbf_ul.c | 9 +++------ src/rlcmac/tbf_ul_fsm.c | 5 +++++ tests/rlcmac/rlcmac_prim_test.err | 11 +++++++---- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/rlcmac/tbf_ul.c b/src/rlcmac/tbf_ul.c index 60bb0a2..0cad0e9 100644 --- a/src/rlcmac/tbf_ul.c +++ b/src/rlcmac/tbf_ul.c @@ -420,10 +420,8 @@ static int create_new_bsn(struct gprs_rlcmac_ul_tbf *ul_tbf, const struct gprs_r * Specially important when X2031 is 0. */ is_final = gprs_rlcmac_llc_queue_size(llc_queue) == 0 && !gprs_rlcmac_ul_tbf_shall_keep_open(ul_tbf, bi); - if (is_final) { + if (is_final) rdbi->cv = 0; - osmo_fsm_inst_dispatch(ul_tbf->state_fsm.fi, GPRS_RLCMAC_TBF_UL_EV_LAST_UL_DATA_SENT, NULL); - } if (gprs_rlcmac_mcs_is_edge(cs)) { /* in EGPRS there's no M bit, so we need @@ -449,9 +447,6 @@ static int create_new_bsn(struct gprs_rlcmac_ul_tbf *ul_tbf, const struct gprs_r msgb_free(ul_tbf->llc_tx_msg); ul_tbf->llc_tx_msg = NULL; - if (is_final) - osmo_fsm_inst_dispatch(ul_tbf->state_fsm.fi, GPRS_RLCMAC_TBF_UL_EV_LAST_UL_DATA_SENT, NULL); - /* dequeue next LLC frame, if any */ gprs_rlcmac_ul_tbf_schedule_next_llc_frame(ul_tbf); } while (ar == GPRS_RLCMAC_AR_COMPLETED_SPACE_LEFT); @@ -870,6 +865,8 @@ static struct msgb *create_ul_acked_block(struct gprs_rlcmac_ul_tbf *ul_tbf, if (ul_tbf->n3104 == 0) osmo_fsm_inst_dispatch(ul_tbf->state_fsm.fi, GPRS_RLCMAC_TBF_UL_EV_FIRST_UL_DATA_SENT, NULL); + if (is_final) + osmo_fsm_inst_dispatch(ul_tbf->state_fsm.fi, GPRS_RLCMAC_TBF_UL_EV_LAST_UL_DATA_SENT, NULL); ul_tbf->n3104++; if (gprs_rlcmac_ul_tbf_in_contention_resolution(ul_tbf)) { unsigned int n3104_max = gprs_rlcmac_ul_tbf_n3104_max(ul_tbf); diff --git a/src/rlcmac/tbf_ul_fsm.c b/src/rlcmac/tbf_ul_fsm.c index a84859d..d36fdb6 100644 --- a/src/rlcmac/tbf_ul_fsm.c +++ b/src/rlcmac/tbf_ul_fsm.c @@ -182,6 +182,10 @@ static void st_finished(struct osmo_fsm_inst *fi, uint32_t event, void *data) osmo_timer_del(&fi->timer); fi->T = 0; break; + case GPRS_RLCMAC_TBF_UL_EV_LAST_UL_DATA_SENT: + /* If LAST_UL_DATA_SENT is received in this state, it means the + * UL TBF is retransmitting the block. We need do nothing, ignore. */ + break; case GPRS_RLCMAC_TBF_UL_EV_FINAL_ACK_RECVD: break; default: @@ -224,6 +228,7 @@ static struct osmo_fsm_state tbf_ul_fsm_states[] = { .in_event_mask = X(GPRS_RLCMAC_TBF_UL_EV_N3104_MAX) | X(GPRS_RLCMAC_TBF_UL_EV_CONTENTION_RESOLUTION_SUCCESS) | + X(GPRS_RLCMAC_TBF_UL_EV_LAST_UL_DATA_SENT) | X(GPRS_RLCMAC_TBF_UL_EV_FINAL_ACK_RECVD), .out_state_mask = X(GPRS_RLCMAC_TBF_UL_ST_NEW), diff --git a/tests/rlcmac/rlcmac_prim_test.err b/tests/rlcmac/rlcmac_prim_test.err index a690bb0..19ab56e 100644 --- a/tests/rlcmac/rlcmac_prim_test.err +++ b/tests/rlcmac/rlcmac_prim_test.err @@ -34,13 +34,13 @@ DLGLOBAL DEBUG TBF(UL:NR-0:TLLI-00002342) Sending new block at BSN 1, CS=CS-2 DLGLOBAL DEBUG -- Chunk with length 7 is less than remaining space (26): add length header to delimit LLC frame DLGLOBAL DEBUG -- Final block, so we done. DLGLOBAL DEBUG TBF(UL:NR-0:TLLI-00002342) Complete UL frame, len=0 -DLGLOBAL INFO UL_TBF{FLOW}: Received Event LAST_UL_DATA_SENT -DLGLOBAL INFO UL_TBF{FLOW}: state_chg to FINISHED DLGLOBAL DEBUG TBF(UL:NR-0:TLLI-00002342) data block (BSN 1, CS-2): 1d 00 00 23 42 11 e5 10 00 e2 18 f2 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b DLGLOBAL DEBUG TBF(UL:NR-0:TLLI-00002342) need_padding 0 spb_status 0 spb 0 (BSN1 1 BSN2 -1) DLGLOBAL DEBUG TBF(UL:NR-0:TLLI-00002342) Copying 1 RLC blocks, 1 BSNs DLGLOBAL DEBUG TBF(UL:NR-0:TLLI-00002342) Copying data unit 0 (BSN 1) DLGLOBAL DEBUG TBF(UL:NR-0:TLLI-00002342) msg block (BSN 1, CS-2): 00 00 02 1d 00 00 23 42 11 e5 10 00 e2 18 f2 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 00 +DLGLOBAL INFO UL_TBF{FLOW}: Received Event LAST_UL_DATA_SENT +DLGLOBAL INFO UL_TBF{FLOW}: state_chg to FINISHED DLGLOBAL DEBUG TBF(UL:NR-0:TLLI-00002342) N3104 inc (2) DLGLOBAL INFO Rx from lower layers: L1CTL-PDCH_DATA.indication DLGLOBAL INFO TS=7 FN=8 Rx Pkt UL ACK/NACK @@ -294,13 +294,13 @@ DLGLOBAL DEBUG TBF(UL:NR-0:TLLI-00002342) Sending new block at BSN 1, CS=CS-2 DLGLOBAL DEBUG -- Chunk with length 7 is less than remaining space (26): add length header to delimit LLC frame DLGLOBAL DEBUG -- Final block, so we done. DLGLOBAL DEBUG TBF(UL:NR-0:TLLI-00002342) Complete UL frame, len=0 -DLGLOBAL INFO UL_TBF{FLOW}: Received Event LAST_UL_DATA_SENT -DLGLOBAL INFO UL_TBF{FLOW}: state_chg to FINISHED DLGLOBAL DEBUG TBF(UL:NR-0:TLLI-00002342) data block (BSN 1, CS-2): 1d 00 00 23 42 11 e5 10 00 e2 18 f2 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b DLGLOBAL DEBUG TBF(UL:NR-0:TLLI-00002342) need_padding 0 spb_status 0 spb 0 (BSN1 1 BSN2 -1) DLGLOBAL DEBUG TBF(UL:NR-0:TLLI-00002342) Copying 1 RLC blocks, 1 BSNs DLGLOBAL DEBUG TBF(UL:NR-0:TLLI-00002342) Copying data unit 0 (BSN 1) DLGLOBAL DEBUG TBF(UL:NR-0:TLLI-00002342) msg block (BSN 1, CS-2): 00 00 02 1d 00 00 23 42 11 e5 10 00 e2 18 f2 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 00 +DLGLOBAL INFO UL_TBF{FLOW}: Received Event LAST_UL_DATA_SENT +DLGLOBAL INFO UL_TBF{FLOW}: state_chg to FINISHED DLGLOBAL DEBUG TBF(UL:NR-0:TLLI-00002342) N3104 inc (2) DLGLOBAL INFO Rx from lower layers: L1CTL-PDCH_RTS.indication DLGLOBAL DEBUG TBF(UL:NR-0:TLLI-00002342) Restarting at BSN 0, because all blocks have been transmitted. @@ -316,6 +316,7 @@ DLGLOBAL DEBUG TBF(UL:NR-0:TLLI-00002342) need_padding 0 spb_status 0 spb 0 (BSN DLGLOBAL DEBUG TBF(UL:NR-0:TLLI-00002342) Copying 1 RLC blocks, 1 BSNs DLGLOBAL DEBUG TBF(UL:NR-0:TLLI-00002342) Copying data unit 0 (BSN 1) DLGLOBAL DEBUG TBF(UL:NR-0:TLLI-00002342) msg block (BSN 1, CS-2): 00 00 02 1d 00 00 23 42 11 e5 10 00 e2 18 f2 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 00 +DLGLOBAL INFO UL_TBF{FINISHED}: Received Event LAST_UL_DATA_SENT DLGLOBAL DEBUG TBF(UL:NR-0:TLLI-00002342) N3104 inc (4) DLGLOBAL INFO Rx from lower layers: L1CTL-PDCH_RTS.indication DLGLOBAL DEBUG TBF(UL:NR-0:TLLI-00002342) Restarting at BSN 0, because all blocks have been transmitted. @@ -331,6 +332,7 @@ DLGLOBAL DEBUG TBF(UL:NR-0:TLLI-00002342) need_padding 0 spb_status 0 spb 0 (BSN DLGLOBAL DEBUG TBF(UL:NR-0:TLLI-00002342) Copying 1 RLC blocks, 1 BSNs DLGLOBAL DEBUG TBF(UL:NR-0:TLLI-00002342) Copying data unit 0 (BSN 1) DLGLOBAL DEBUG TBF(UL:NR-0:TLLI-00002342) msg block (BSN 1, CS-2): 00 00 02 1d 00 00 23 42 11 e5 10 00 e2 18 f2 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 00 +DLGLOBAL INFO UL_TBF{FINISHED}: Received Event LAST_UL_DATA_SENT DLGLOBAL DEBUG TBF(UL:NR-0:TLLI-00002342) N3104 inc (6) DLGLOBAL INFO Rx from lower layers: L1CTL-PDCH_RTS.indication DLGLOBAL DEBUG TBF(UL:NR-0:TLLI-00002342) Restarting at BSN 0, because all blocks have been transmitted. @@ -346,6 +348,7 @@ DLGLOBAL DEBUG TBF(UL:NR-0:TLLI-00002342) need_padding 0 spb_status 0 spb 0 (BSN DLGLOBAL DEBUG TBF(UL:NR-0:TLLI-00002342) Copying 1 RLC blocks, 1 BSNs DLGLOBAL DEBUG TBF(UL:NR-0:TLLI-00002342) Copying data unit 0 (BSN 1) DLGLOBAL DEBUG TBF(UL:NR-0:TLLI-00002342) msg block (BSN 1, CS-2): 00 00 02 1d 00 00 23 42 11 e5 10 00 e2 18 f2 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 00 +DLGLOBAL INFO UL_TBF{FINISHED}: Received Event LAST_UL_DATA_SENT DLGLOBAL DEBUG TBF(UL:NR-0:TLLI-00002342) N3104 inc (8) DLGLOBAL INFO Rx from lower layers: L1CTL-PDCH_RTS.indication DLGLOBAL DEBUG TBF(UL:NR-0:TLLI-00002342) Restarting at BSN 0, because all blocks have been transmitted.