Split tbf_fsm as tbf_{ul,dl}_fsm
The 2 types of TBF share some parts of the implementation, but actually
half of the code is specific to one direction or another.
Since FSM are becoming (and will become even) more complex, split the
FSM implementation into 2 separate FSMs, one for each direction.
The FSM interface is kept compatible (events and states), hence code can
still operate on the tbfs on events and states which are shared.
Test output changes are mainly due to:
* FSM instance now created in subclass constructor, so order of log
lines during constructor of parent class and subclass slightly
changes.
* osmo_fsm doesn't allow having 2 FSM types with same name registered,
hence the "TBF" name has to be changed to "DL_TBF" and "UL_TBF" for
each FSM class.
* FSM classes now use DTBFUL and DTBFDL instead of DTBF for logging. Some
tests don't have those categories enabled, hence some log lines
dissappear (it's actually fine we don't care about those in the test
cases).
Change-Id: I879af3f4b3e330687d498cd59f5f4933d6ca56f0
diff --git a/src/tbf.cpp b/src/tbf.cpp
index 4aa4089..86b501e 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -115,11 +115,6 @@
memset(&m_trx_list, 0, sizeof(m_trx_list));
m_trx_list.entry = this;
- memset(&state_fsm, 0, sizeof(state_fsm));
- state_fsm.tbf = this;
- state_fi = osmo_fsm_inst_alloc(&tbf_fsm, this, &state_fsm, LOGL_INFO, NULL);
- OSMO_ASSERT(state_fi);
-
memset(&ul_ass_fsm, 0, sizeof(ul_ass_fsm));
ul_ass_fsm.tbf = this;
ul_ass_fsm.fi = osmo_fsm_inst_alloc(&tbf_ul_ass_fsm, this, &ul_ass_fsm, LOGL_INFO, NULL);
@@ -912,18 +907,23 @@
struct osmo_strbuf sb = { .buf = buf, .len = sizeof(buf) };
OSMO_STRBUF_PRINTF(sb, "|");
- if (tbf->state_fsm.state_flags & (1 << GPRS_RLCMAC_FLAG_CCCH))
- OSMO_STRBUF_PRINTF(sb, "Assignment was on CCCH|");
- if (tbf->state_fsm.state_flags & (1 << GPRS_RLCMAC_FLAG_PACCH))
- OSMO_STRBUF_PRINTF(sb, "Assignment was on PACCH|");
if (tbf->direction == GPRS_RLCMAC_UL_TBF) {
- const struct gprs_rlcmac_ul_tbf *ul_tbf = static_cast<const gprs_rlcmac_ul_tbf *>(tbf);
+ const struct gprs_rlcmac_ul_tbf *ul_tbf = tbf_as_ul_tbf_const(tbf);
+ if (ul_tbf->state_fsm.state_flags & (1 << GPRS_RLCMAC_FLAG_CCCH))
+ OSMO_STRBUF_PRINTF(sb, "Assignment was on CCCH|");
+ if (ul_tbf->state_fsm.state_flags & (1 << GPRS_RLCMAC_FLAG_PACCH))
+ OSMO_STRBUF_PRINTF(sb, "Assignment was on PACCH|");
if (ul_tbf->m_rx_counter)
OSMO_STRBUF_PRINTF(sb, "Uplink data was received|");
else
OSMO_STRBUF_PRINTF(sb, "No uplink data received yet|");
} else {
- if (tbf->state_fsm.state_flags & (1 << GPRS_RLCMAC_FLAG_DL_ACK))
+ const struct gprs_rlcmac_dl_tbf *dl_tbf = tbf_as_dl_tbf_const(tbf);
+ if (dl_tbf->state_fsm.state_flags & (1 << GPRS_RLCMAC_FLAG_CCCH))
+ OSMO_STRBUF_PRINTF(sb, "Assignment was on CCCH|");
+ if (dl_tbf->state_fsm.state_flags & (1 << GPRS_RLCMAC_FLAG_PACCH))
+ OSMO_STRBUF_PRINTF(sb, "Assignment was on PACCH|");
+ if (dl_tbf->state_fsm.state_flags & (1 << GPRS_RLCMAC_FLAG_DL_ACK))
OSMO_STRBUF_PRINTF(sb, "Downlink ACK was received|");
else
OSMO_STRBUF_PRINTF(sb, "No downlink ACK received yet|");