pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-pcu/+/30541 )
Change subject: tbf_ul_fsm_ctx: Properly define tbf backptr as ul_tbf ......................................................................
tbf_ul_fsm_ctx: Properly define tbf backptr as ul_tbf
Since the tbf_fsm was split recently into tbf_dl_fsm and tbf_ul_fsm, each has now its own ctx strucvture, which can hold the proper tbf subclass.
Change-Id: I7741d524a14437caf4c92b9c09e19762eb272e30 --- M src/tbf_fsm.h M src/tbf_ul.cpp M src/tbf_ul_fsm.c 3 files changed, 24 insertions(+), 21 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/41/30541/1
diff --git a/src/tbf_fsm.h b/src/tbf_fsm.h index feb9e04..a62e72d 100644 --- a/src/tbf_fsm.h +++ b/src/tbf_fsm.h @@ -63,7 +63,10 @@ };
struct tbf_ul_fsm_ctx { - struct gprs_rlcmac_tbf *tbf; /* back pointer */ + union { /* back pointer. union used to easily access superclass from ctx */ + struct gprs_rlcmac_tbf *tbf; + struct gprs_rlcmac_ul_tbf *ul_tbf; + }; uint32_t state_flags; unsigned int T_release; /* Timer to be used to end release: T3169 or T3195 */ }; diff --git a/src/tbf_ul.cpp b/src/tbf_ul.cpp index 246c0e1..43cd4f6 100644 --- a/src/tbf_ul.cpp +++ b/src/tbf_ul.cpp @@ -202,7 +202,7 @@ memset(&m_usf, USF_INVALID, sizeof(m_usf));
memset(&state_fsm, 0, sizeof(state_fsm)); - state_fsm.tbf = (struct gprs_rlcmac_tbf *)this; + state_fsm.ul_tbf = this; state_fi = osmo_fsm_inst_alloc(&tbf_ul_fsm, this, &state_fsm, LOGL_INFO, NULL); OSMO_ASSERT(state_fi);
diff --git a/src/tbf_ul_fsm.c b/src/tbf_ul_fsm.c index 9ac7ee8..fb4a256 100644 --- a/src/tbf_ul_fsm.c +++ b/src/tbf_ul_fsm.c @@ -59,22 +59,22 @@ ch = "PACCH"; break; default: - LOGPTBF(ctx->tbf, LOGL_ERROR, - "attempted to %sset unexpected ass. type %d - FIXME!\n", - set ? "" : "un", t); + LOGPTBFUL(ctx->ul_tbf, LOGL_ERROR, + "attempted to %sset unexpected ass. type %d - FIXME!\n", + set ? "" : "un", t); return; }
if (set && prev_set) - LOGPTBF(ctx->tbf, LOGL_ERROR, - "attempted to set ass. type %s which is already set.\n", ch); + LOGPTBFUL(ctx->ul_tbf, LOGL_ERROR, + "attempted to set ass. type %s which is already set.\n", ch); else if (!set && !prev_set) return;
- LOGPTBF(ctx->tbf, LOGL_INFO, "%sset ass. type %s [prev CCCH:%u, PACCH:%u]\n", - set ? "" : "un", ch, - !!(ctx->state_flags & (1 << GPRS_RLCMAC_FLAG_CCCH)), - !!(ctx->state_flags & (1 << GPRS_RLCMAC_FLAG_PACCH))); + LOGPTBFUL(ctx->ul_tbf, LOGL_INFO, "%sset ass. type %s [prev CCCH:%u, PACCH:%u]\n", + set ? "" : "un", ch, + !!(ctx->state_flags & (1 << GPRS_RLCMAC_FLAG_CCCH)), + !!(ctx->state_flags & (1 << GPRS_RLCMAC_FLAG_PACCH)));
if (set) { ctx->state_flags |= (1 << t); @@ -92,7 +92,7 @@ case TBF_EV_ASSIGN_ADD_CCCH: mod_ass_type(ctx, GPRS_RLCMAC_FLAG_CCCH, true); tbf_ul_fsm_state_chg(fi, TBF_ST_FLOW); - ul_tbf_contention_resolution_start(tbf_as_ul_tbf(ctx->tbf)); + ul_tbf_contention_resolution_start(ctx->ul_tbf); break; case TBF_EV_ASSIGN_ADD_PACCH: mod_ass_type(ctx, GPRS_RLCMAC_FLAG_PACCH, true); @@ -122,9 +122,9 @@ val = osmo_tdef_get(the_pcu->T_defs, fi->T, OSMO_TDEF_MS, -1); sec = val / 1000; micro = (val % 1000) * 1000; - LOGPTBF(ctx->tbf, LOGL_DEBUG, - "Starting timer X2001 [assignment (PACCH)] with %u sec. %u microsec\n", - sec, micro); + LOGPTBFUL(ctx->ul_tbf, LOGL_DEBUG, + "Starting timer X2001 [assignment (PACCH)] with %u sec. %u microsec\n", + sec, micro); osmo_timer_schedule(&fi->timer, sec, micro); } } @@ -144,9 +144,9 @@ tbf_assign_control_ts(ctx->tbf); if (ctx->state_flags & (1 << GPRS_RLCMAC_FLAG_CCCH)) { /* We now know that the PACCH really existed */ - LOGPTBF(ctx->tbf, LOGL_INFO, - "The TBF has been confirmed on the PACCH, " - "changed type from CCCH to PACCH\n"); + LOGPTBFUL(ctx->ul_tbf, LOGL_INFO, + "The TBF has been confirmed on the PACCH, " + "changed type from CCCH to PACCH\n"); mod_ass_type(ctx, GPRS_RLCMAC_FLAG_CCCH, false); mod_ass_type(ctx, GPRS_RLCMAC_FLAG_PACCH, true); } @@ -272,8 +272,8 @@ */ val = osmo_tdef_get(tbf_ms(ctx->tbf)->bts->T_defs_bts, ctx->T_release, OSMO_TDEF_S, -1); fi->T = ctx->T_release; - LOGPTBF(ctx->tbf, LOGL_DEBUG, "starting timer T%u with %lu sec. %u microsec\n", - ctx->T_release, val, 0); + LOGPTBFUL(ctx->ul_tbf, LOGL_DEBUG, "starting timer T%u with %lu sec. %u microsec\n", + ctx->T_release, val, 0); osmo_timer_schedule(&fi->timer, val, 0); }
@@ -287,7 +287,7 @@ struct tbf_ul_fsm_ctx *ctx = (struct tbf_ul_fsm_ctx *)fi->priv; switch (fi->T) { case -2001: - LOGPTBF(ctx->tbf, LOGL_NOTICE, "releasing due to PACCH assignment timeout.\n"); + LOGPTBFUL(ctx->ul_tbf, LOGL_NOTICE, "releasing due to PACCH assignment timeout.\n"); /* fall-through */ case 3169: case 3195: