pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-pcu/+/33524 )
Change subject: ms_need_dl_tbf(): Fix state checks and document function ......................................................................
ms_need_dl_tbf(): Fix state checks and document function
A new state TBF_ST_WAIT_REUSE_TFI was added lately in dl_tbf_fsm, which allows differentiating the time where the MS is listening on PACCH after having sent last DL ACK/NACK, and time where it should already be in idle mode. In the former, the ms_need_dl_tbf() should return false since the MS is still ongoing in packet-active mode (and new data incoming from SGSN will trigger new DL TBF assignment over PACCH as needed), while in the later we want to start a new PCH assignment.
Fixes: 40a297f3b0c8e1670d46a4974750dd3335bc7885 Change-Id: I96f311480d036859511c6ba825ccd36bdc71190b --- M src/gprs_ms.h 1 file changed, 41 insertions(+), 3 deletions(-)
Approvals: Jenkins Builder: Verified osmith: Looks good to me, approved
diff --git a/src/gprs_ms.h b/src/gprs_ms.h index ef1cc4e..276733c 100644 --- a/src/gprs_ms.h +++ b/src/gprs_ms.h @@ -157,11 +157,30 @@ return &ms->llc_queue; }
+/* Function used in code where a ul_tbf related event occurs and hence its state + * changes, which in turn may change the entire MS state (eg becoming reachable + * over PCH or PACCH) and the caller may want to know if it is a good time to + * assign a DL TBF (and whether we have DL data to send) */ static inline bool ms_need_dl_tbf(struct GprsMs *ms) { - if (ms_dl_tbf(ms) != NULL && - tbf_state((const struct gprs_rlcmac_tbf *)ms_dl_tbf(ms)) != TBF_ST_WAIT_RELEASE) - return false; + struct gprs_rlcmac_dl_tbf *dl_tbf = ms_dl_tbf(ms); + if (dl_tbf) { + switch (tbf_state(dl_tbf_as_tbf(dl_tbf))) { + case TBF_ST_NEW: + case TBF_ST_ASSIGN: + case TBF_ST_FLOW: + case TBF_ST_FINISHED: + case TBF_ST_WAIT_RELEASE: + return false; /* TBF in use, hence no need for new DL TBF */ + case TBF_ST_WAIT_REUSE_TFI: + case TBF_ST_RELEASING: + /* TBF cannot be used to send further data, a new one + * may be needed, check below */ + break; + default: + OSMO_ASSERT(0); + } + }
return llc_queue_size(ms_llc_queue(ms)) > 0; }