diff options
author | Pau Espin Pedrol <pespin@sysmocom.de> | 2021-07-26 12:33:39 +0200 |
---|---|---|
committer | Pau Espin Pedrol <pespin@sysmocom.de> | 2021-08-23 17:14:21 +0200 |
commit | efcb046ce1b922c0c466d4beb53caec263f22d50 (patch) | |
tree | b062dda99bfd34ce34a4303a13758c07a680eec8 /src | |
parent | c32c4a3648603e50b6ac4e2662e841d3a3c1b9c0 (diff) |
Move WAIT_RELEASE tbf_state transition to tbf_fsm
While at it, method maybe_start_new_window is renamed to
rcvd_dl_final_ack to make more sense out of the code.
Related: OS#2709
Change-Id: Iebd650c1036ef2d5132789778be7117ce3391c01
Diffstat (limited to 'src')
-rw-r--r-- | src/tbf_dl.cpp | 9 | ||||
-rw-r--r-- | src/tbf_dl.h | 2 | ||||
-rw-r--r-- | src/tbf_fsm.c | 28 | ||||
-rw-r--r-- | src/tbf_fsm.h | 1 |
4 files changed, 32 insertions, 8 deletions
diff --git a/src/tbf_dl.cpp b/src/tbf_dl.cpp index ed5003c9..6614366b 100644 --- a/src/tbf_dl.cpp +++ b/src/tbf_dl.cpp @@ -1219,8 +1219,9 @@ int gprs_rlcmac_dl_tbf::update_window(const uint8_t ssn, const uint8_t *rbb) } -int gprs_rlcmac_dl_tbf::maybe_start_new_window() +int gprs_rlcmac_dl_tbf::rcvd_dl_final_ack() { + osmo_fsm_inst_dispatch(this->state_fsm.fi, TBF_EV_FINAL_ACK_RECVD, NULL); release(); /* check for LLC PDU in the LLC Queue */ @@ -1241,8 +1242,6 @@ int gprs_rlcmac_dl_tbf::release() /* report all outstanding packets as received */ gprs_rlcmac_received_lost(this, received, 0); - TBF_SET_STATE(this, TBF_ST_WAIT_RELEASE); - /* start T3193 */ T_START(this, T3193, 3193, "release (DL-TBF)", true); @@ -1292,7 +1291,7 @@ int gprs_rlcmac_dl_tbf::rcvd_dl_ack(bool final_ack, unsigned first_bsn, if (final_ack) { LOGPTBFDL(this, LOGL_DEBUG, "Final ACK received.\n"); - rc = maybe_start_new_window(); + rc = rcvd_dl_final_ack(); } else if (state_is(TBF_ST_FINISHED) && m_window.window_empty()) { LOGPTBFDL(this, LOGL_NOTICE, "Received acknowledge of all blocks, but without final ack indication (don't worry)\n"); @@ -1309,7 +1308,7 @@ int gprs_rlcmac_dl_tbf::rcvd_dl_ack(bool final_ack, uint8_t ssn, uint8_t *rbb) return update_window(ssn, rbb); LOGPTBFDL(this, LOGL_DEBUG, "Final ACK received.\n"); - return maybe_start_new_window(); + return rcvd_dl_final_ack(); } bool gprs_rlcmac_dl_tbf::dl_window_stalled() const diff --git a/src/tbf_dl.h b/src/tbf_dl.h index 58d863b3..af82a0cf 100644 --- a/src/tbf_dl.h +++ b/src/tbf_dl.h @@ -110,7 +110,7 @@ protected: int index, int index2 = -1); int update_window(const uint8_t ssn, const uint8_t *rbb); int update_window(unsigned first_bsn, const struct bitvec *rbb); - int maybe_start_new_window(); + int rcvd_dl_final_ack(); bool dl_window_stalled() const; void reuse_tbf(); void start_llc_timer(); diff --git a/src/tbf_fsm.c b/src/tbf_fsm.c index 8e0649da..d1b48d56 100644 --- a/src/tbf_fsm.c +++ b/src/tbf_fsm.c @@ -48,6 +48,7 @@ const struct value_string tbf_fsm_event_names[] = { { TBF_EV_ASSIGN_READY_CCCH, "ASSIGN_READY_CCCH" }, { TBF_EV_LAST_DL_DATA_SENT, "LAST_DL_DATA_SENT" }, { TBF_EV_LAST_UL_DATA_RECVD, "LAST_UL_DATA_RECVD" }, + { TBF_EV_FINAL_ACK_RECVD, "FINAL_ACK_RECVD" }, { 0, NULL } }; @@ -147,6 +148,27 @@ static void st_flow(struct osmo_fsm_inst *fi, uint32_t event, void *data) /* All data has been sent or received, change state to FINISHED */ tbf_fsm_state_chg(fi, TBF_ST_FINISHED); break; + case TBF_EV_FINAL_ACK_RECVD: + /* We received Final Ack (DL ACK/NACK) from MS. move to + WAIT_RELEASE, we wait there for release or re-use the TBF in + case we receive more DL data to tx */ + tbf_fsm_state_chg(fi, TBF_ST_WAIT_RELEASE); + break; + default: + OSMO_ASSERT(0); + } +} + +static void st_finished(struct osmo_fsm_inst *fi, uint32_t event, void *data) +{ + //struct tbf_fsm_ctx *ctx = (struct tbf_fsm_ctx *)fi->priv; + switch (event) { + case TBF_EV_FINAL_ACK_RECVD: + /* We received Final Ack (DL ACK/NACK) from MS. move to + WAIT_RELEASE, we wait there for release or re-use the TBF in + case we receive more DL data to tx */ + tbf_fsm_state_chg(fi, TBF_ST_WAIT_RELEASE); + break; default: OSMO_ASSERT(0); } @@ -196,7 +218,8 @@ static struct osmo_fsm_state tbf_fsm_states[] = { [TBF_ST_FLOW] = { .in_event_mask = X(TBF_EV_LAST_DL_DATA_SENT) | - X(TBF_EV_LAST_UL_DATA_RECVD), + X(TBF_EV_LAST_UL_DATA_RECVD) | + X(TBF_EV_FINAL_ACK_RECVD), .out_state_mask = X(TBF_ST_FINISHED) | X(TBF_ST_WAIT_RELEASE) | @@ -206,10 +229,11 @@ static struct osmo_fsm_state tbf_fsm_states[] = { }, [TBF_ST_FINISHED] = { .in_event_mask = - 0, + X(TBF_EV_FINAL_ACK_RECVD), .out_state_mask = X(TBF_ST_WAIT_RELEASE), .name = "FINISHED", + .action = st_finished, }, [TBF_ST_WAIT_RELEASE] = { .in_event_mask = diff --git a/src/tbf_fsm.h b/src/tbf_fsm.h index ea0f58d1..1dba80ff 100644 --- a/src/tbf_fsm.h +++ b/src/tbf_fsm.h @@ -34,6 +34,7 @@ enum tbf_fsm_event { TBF_EV_ASSIGN_READY_CCCH, /* TBF Start Time timer triggered */ 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) */ + TBF_EV_FINAL_ACK_RECVD, /* DL ACK/NACK with FINAL_ACK=1 received from MS */ }; enum tbf_fsm_states { |