pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-pcu/+/29930 )
Change subject: tbf_fsm: Introduce new event TBF_EV_FIRST_UL_DATA_RECVD ......................................................................
tbf_fsm: Introduce new event TBF_EV_FIRST_UL_DATA_RECVD
This allows easier tracking of this event. It will also extended later on with more logic which is better placed in tbf_fsm.
Change-Id: I5c935914e13db3928c32621ec04eb2760367615d --- M src/tbf_fsm.c M src/tbf_fsm.h M src/tbf_ul.cpp M src/tbf_ul_ack_fsm.c M tests/tbf/TbfTest.err 5 files changed, 27 insertions(+), 5 deletions(-)
Approvals: Jenkins Builder: Verified laforge: Looks good to me, but someone else must approve osmith: Looks good to me, but someone else must approve pespin: Looks good to me, approved
diff --git a/src/tbf_fsm.c b/src/tbf_fsm.c index a8e7886..b236d27 100644 --- a/src/tbf_fsm.c +++ b/src/tbf_fsm.c @@ -25,6 +25,8 @@ #include <encoding.h> #include <bts.h>
+#include <bts_pch_timer.h> + #define X(s) (1 << (s))
const struct osmo_tdef_state_timeout tbf_fsm_timeouts[32] = { @@ -42,6 +44,7 @@ { TBF_EV_ASSIGN_ACK_PACCH, "ASSIGN_ACK_PACCH" }, { TBF_EV_ASSIGN_READY_CCCH, "ASSIGN_READY_CCCH" }, { TBF_EV_ASSIGN_PCUIF_CNF, "ASSIGN_PCUIF_CNF" }, + { TBF_EV_FIRST_UL_DATA_RECVD, "FIRST_UL_DATA_RECVD" }, { TBF_EV_DL_ACKNACK_MISS, "DL_ACKNACK_MISS" }, { TBF_EV_LAST_DL_DATA_SENT, "LAST_DL_DATA_SENT" }, { TBF_EV_LAST_UL_DATA_RECVD, "LAST_UL_DATA_RECVD" }, @@ -204,8 +207,17 @@ static void st_flow(struct osmo_fsm_inst *fi, uint32_t event, void *data) { struct tbf_fsm_ctx *ctx = (struct tbf_fsm_ctx *)fi->priv; + struct GprsMs *ms = tbf_ms(ctx->tbf);
switch (event) { + case TBF_EV_FIRST_UL_DATA_RECVD: + OSMO_ASSERT(tbf_direction(ctx->tbf) == GPRS_RLCMAC_UL_TBF); + /* TS 44.060 7a.2.1.1: "The contention resolution is completed on + * the network side when the network receives an RLC data block that + * comprises the TLLI value that identifies the mobile station and the + * TFI value associated with the TBF." */ + bts_pch_timer_stop(ms->bts, ms); + break; case TBF_EV_DL_ACKNACK_MISS: OSMO_ASSERT(tbf_direction(ctx->tbf) == GPRS_RLCMAC_DL_TBF); /* DL TBF: we missed a DL ACK/NACK. If we started assignment @@ -455,6 +467,7 @@ }, [TBF_ST_FLOW] = { .in_event_mask = + X(TBF_EV_FIRST_UL_DATA_RECVD) | X(TBF_EV_DL_ACKNACK_MISS) | X(TBF_EV_LAST_DL_DATA_SENT) | X(TBF_EV_LAST_UL_DATA_RECVD) | diff --git a/src/tbf_fsm.h b/src/tbf_fsm.h index 22266e7..903bcd7 100644 --- a/src/tbf_fsm.h +++ b/src/tbf_fsm.h @@ -28,6 +28,7 @@ TBF_EV_ASSIGN_ACK_PACCH, /* We received a CTRL ACK confirming assignment started on PACCH */ TBF_EV_ASSIGN_READY_CCCH, /* TBF Start Time timer triggered */ TBF_EV_ASSIGN_PCUIF_CNF, /* Transmission of IMM.ASS for DL TBF to the MS confirmed by BTS over PCUIF */ + TBF_EV_FIRST_UL_DATA_RECVD, /* UL TBF: Received first UL data from MS. Equals to Contention Resolution completed on the network side */ TBF_EV_DL_ACKNACK_MISS, /* DL TBF: We polled for DL ACK/NACK but we received none (POLL timeout) */ TBF_EV_LAST_DL_DATA_SENT, /* DL TBF sends RLCMAC block containing last DL avilable data buffered */ TBF_EV_LAST_UL_DATA_RECVD, /* UL TBF sends RLCMAC block containing last UL data (cv=0) */ diff --git a/src/tbf_ul.cpp b/src/tbf_ul.cpp index 910bfb4..40129ec 100644 --- a/src/tbf_ul.cpp +++ b/src/tbf_ul.cpp @@ -398,7 +398,7 @@ "Decoded premier TLLI=0x%08x of UL DATA TFI=%d.\n", new_tlli, rlc->tfi); ms_update_announced_tlli(ms(), new_tlli); - bts_pch_timer_stop(bts, ms()); + osmo_fsm_inst_dispatch(this->state_fsm.fi, TBF_EV_FIRST_UL_DATA_RECVD, NULL); } else if (new_tlli != GSM_RESERVED_TMSI && new_tlli != tlli()) { LOGPTBFUL(this, LOGL_NOTICE, "Decoded TLLI=%08x mismatch on UL DATA TFI=%d. (Ignoring due to contention resolution)\n", diff --git a/src/tbf_ul_ack_fsm.c b/src/tbf_ul_ack_fsm.c index 8ec2199..b0506d1 100644 --- a/src/tbf_ul_ack_fsm.c +++ b/src/tbf_ul_ack_fsm.c @@ -80,10 +80,15 @@ /* TS 44.060 7a.2.1.1: "The contention resolution is completed on * the network side when the network receives an RLC data block that * comprises the TLLI value that identifies the mobile station and the - * TFI value associated with the TBF." - * However, it's handier for us to mark contention resolution success - * here since according to spec upon rx UL ACK is the time at which MS - * realizes contention resolution succeeds. */ + * TFI value associated with the TBF." (see TBF_EV_FIRST_UL_DATA_RECVD). + * + * However, it's handier for us to mark contention resolution success here + * since upon rx UL ACK is the time at which MS realizes contention resolution + * succeeds: + * TS 44.060 7.1.2.3: "The contention resolution is successfully completed + * on the mobile station side when the mobile station receives a + * PACKET UPLINK ACK/NACK" + */ if (ms_tlli(ms) != GSM_RESERVED_TMSI) ul_tbf_contention_resolution_success(ctx->tbf);
diff --git a/tests/tbf/TbfTest.err b/tests/tbf/TbfTest.err index 6a7ca38..27ed39b 100644 --- a/tests/tbf/TbfTest.err +++ b/tests/tbf/TbfTest.err @@ -1832,6 +1832,7 @@ TBF(TFI=0 TLLI=0xffffffff DIR=UL STATE=FLOW) data_length=20, data=f1 22 33 44 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 TBF(TFI=0 TLLI=0xffffffff DIR=UL STATE=FLOW) Decoded premier TLLI=0xf1223344 of UL DATA TFI=0. Modifying MS object, UL TLLI: 0xffffffff -> 0xf1223344, not yet confirmed +TBF(UL-TFI_0){FLOW}: Received Event FIRST_UL_DATA_RECVD TBF(TFI=0 TLLI=0xf1223344 DIR=UL STATE=FLOW) Assembling frames: (len=20) TBF(TFI=0 TLLI=0xf1223344 DIR=UL STATE=FLOW) Frame 1 starts at offset 4, length=16, is_complete=1 TBF(TFI=0 TLLI=0xf1223344 DIR=UL STATE=FLOW) complete UL frame len=16 @@ -1893,6 +1894,7 @@ TBF(TFI=0 TLLI=0xffffffff DIR=UL STATE=FLOW) data_length=20, data=f1 22 33 44 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 TBF(TFI=0 TLLI=0xffffffff DIR=UL STATE=FLOW) Decoded premier TLLI=0xf1223344 of UL DATA TFI=0. Modifying MS object, UL TLLI: 0xffffffff -> 0xf1223344, not yet confirmed +TBF(UL-TFI_0){FLOW}: Received Event FIRST_UL_DATA_RECVD TBF(TFI=0 TLLI=0xf1223344 DIR=UL STATE=FLOW) Assembling frames: (len=20) TBF(TFI=0 TLLI=0xf1223344 DIR=UL STATE=FLOW) Frame 1 starts at offset 4, length=16, is_complete=1 TBF(TFI=0 TLLI=0xf1223344 DIR=UL STATE=FLOW) complete UL frame len=16 @@ -2669,6 +2671,7 @@ DL_ASS_TBF(DL-TFI_0){NONE}: Deallocated MS(TLLI=0xf1223344, IMSI=0011223344, TA=7, 1/0,) Clearing MS object MS(TLLI=0xffffffff, IMSI=, TA=7, 1/0,) Destroying MS object +TBF(UL-TFI_0){FLOW}: Received Event FIRST_UL_DATA_RECVD TBF(TFI=0 TLLI=0xf1223344 DIR=UL STATE=FLOW) Assembling frames: (len=20) TBF(TFI=0 TLLI=0xf1223344 DIR=UL STATE=FLOW) Frame 1 starts at offset 4, length=16, is_complete=1 TBF(TFI=0 TLLI=0xf1223344 DIR=UL STATE=FLOW) complete UL frame len=16