pespin has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-pcu/+/30562 )

Change subject: tbf_dl_fsm_ctx: Properly define tbf backptr as dl_tbf
......................................................................

tbf_dl_fsm_ctx: Properly define tbf backptr as dl_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: Id2571e55e1fea2918207175f2030ec026e880bc1
---
M src/bts.cpp
M src/bts.h
M src/tbf_dl.cpp
M src/tbf_dl_fsm.c
M src/tbf_fsm.h
5 files changed, 35 insertions(+), 33 deletions(-)

Approvals:
  Jenkins Builder: Verified
  fixeria: Looks good to me, but someone else must approve
  laforge: Looks good to me, approved



diff --git a/src/bts.cpp b/src/bts.cpp
index d7851a2..c6253f4 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -1074,7 +1074,7 @@
        return 0;
 }

-void bts_snd_dl_ass(struct gprs_rlcmac_bts *bts, struct gprs_rlcmac_tbf *tbf)
+void bts_snd_dl_ass(struct gprs_rlcmac_bts *bts, const struct 
gprs_rlcmac_dl_tbf *tbf)
 {
        uint8_t trx_no = tbf->trx->trx_no;
        uint8_t ts_no = tbf->first_ts;
diff --git a/src/bts.h b/src/bts.h
index d2b1f9f..085b448 100644
--- a/src/bts.h
+++ b/src/bts.h
@@ -301,7 +301,7 @@
 struct gprs_rlcmac_dl_tbf *bts_dl_tbf_by_tfi(struct gprs_rlcmac_bts *bts, 
uint8_t tfi, uint8_t trx, uint8_t ts);
 struct gprs_rlcmac_ul_tbf *bts_ul_tbf_by_tfi(struct gprs_rlcmac_bts *bts, 
uint8_t tfi, uint8_t trx, uint8_t ts);

-void bts_snd_dl_ass(struct gprs_rlcmac_bts *bts, struct gprs_rlcmac_tbf *tbf);
+void bts_snd_dl_ass(struct gprs_rlcmac_bts *bts, const struct 
gprs_rlcmac_dl_tbf *tbf);

 void bts_set_current_frame_number(struct gprs_rlcmac_bts *bts, uint32_t 
frame_number);
 void bts_set_current_block_frame_number(struct gprs_rlcmac_bts *bts, int 
frame_number);
diff --git a/src/tbf_dl.cpp b/src/tbf_dl.cpp
index ae90041..f5637f9 100644
--- a/src/tbf_dl.cpp
+++ b/src/tbf_dl.cpp
@@ -181,7 +181,7 @@
        m_dl_egprs_ctrs(NULL)
 {
        memset(&state_fsm, 0, sizeof(state_fsm));
-       state_fsm.tbf = (struct gprs_rlcmac_tbf *)this;
+       state_fsm.dl_tbf = this;
        state_fi = osmo_fsm_inst_alloc(&tbf_dl_fsm, this, &state_fsm, 
LOGL_INFO, NULL);
        OSMO_ASSERT(state_fi);
 }
diff --git a/src/tbf_dl_fsm.c b/src/tbf_dl_fsm.c
index 0cd8504..f306510 100644
--- a/src/tbf_dl_fsm.c
+++ b/src/tbf_dl_fsm.c
@@ -60,22 +60,22 @@
                ch = "PACCH";
                break;
        default:
-               LOGPTBF(ctx->tbf, LOGL_ERROR,
-                       "attempted to %sset unexpected ass. type %d - FIXME!\n",
+               LOGPTBFDL(ctx->dl_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);
+               LOGPTBFDL(ctx->dl_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)));
+       LOGPTBFDL(ctx->dl_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);
@@ -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);
+               LOGPTBFDL(ctx->dl_tbf, LOGL_DEBUG,
+                         "Starting timer X2001 [assignment (PACCH)] with %u 
sec. %u microsec\n",
+                         sec, micro);
                osmo_timer_schedule(&fi->timer, sec, micro);
        } else {
                 /* GPRS_RLCMAC_FLAG_CCCH is set, so here we submitted an DL Ass
@@ -149,9 +149,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");
+                       LOGPTBFDL(ctx->dl_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);
                }
@@ -168,9 +168,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 X2002 [assignment (AGCH)] with %u sec. 
%u microsec\n",
-                       sec, micro);
+               LOGPTBFDL(ctx->dl_tbf, LOGL_DEBUG,
+                         "Starting timer X2002 [assignment (AGCH)] with %u 
sec. %u microsec\n",
+                         sec, micro);
                osmo_timer_schedule(&fi->timer, sec, micro);
                break;
        case TBF_EV_ASSIGN_READY_CCCH:
@@ -202,11 +202,12 @@
                if ((ctx->state_flags & (1 << GPRS_RLCMAC_FLAG_CCCH))
                     && !(ctx->state_flags & (1 << GPRS_RLCMAC_FLAG_DL_ACK))) {
                        struct GprsMs *ms = tbf_ms(ctx->tbf);
-                       LOGPTBF(ctx->tbf, LOGL_DEBUG, "Re-send downlink 
assignment on PCH (IMSI=%s)\n",
-                               ms_imsi_is_valid(ms) ? ms_imsi(ms) : "");
+                       LOGPTBFDL(ctx->dl_tbf, LOGL_DEBUG,
+                                 "Re-send downlink assignment on PCH 
(IMSI=%s)\n",
+                                 ms_imsi_is_valid(ms) ? ms_imsi(ms) : "");
                        tbf_dl_fsm_state_chg(fi, TBF_ST_ASSIGN);
                        /* send immediate assignment */
-                       bts_snd_dl_ass(ms->bts, ctx->tbf);
+                       bts_snd_dl_ass(ms->bts, ctx->dl_tbf);
                }
                break;
        case TBF_EV_LAST_DL_DATA_SENT:
@@ -255,14 +256,13 @@
 {
        struct tbf_dl_fsm_ctx *ctx = (struct tbf_dl_fsm_ctx *)fi->priv;
        unsigned long val_s, val_ms, val_us;
-       OSMO_ASSERT(tbf_direction(ctx->tbf) == GPRS_RLCMAC_DL_TBF);

        fi->T = 3193;
        val_ms = osmo_tdef_get(tbf_ms(ctx->tbf)->bts->T_defs_bts, fi->T, 
OSMO_TDEF_MS, -1);
        val_s = val_ms / 1000;
        val_us = (val_ms % 1000) * 1000;
-       LOGPTBF(ctx->tbf, LOGL_DEBUG, "starting timer T%u with %lu sec. %lu 
microsec\n",
-               fi->T, val_s, val_us);
+       LOGPTBFDL(ctx->dl_tbf, LOGL_DEBUG, "starting timer T%u with %lu sec. 
%lu microsec\n",
+                 fi->T, val_s, val_us);
        osmo_timer_schedule(&fi->timer, val_s, val_us);

        mod_ass_type(ctx, GPRS_RLCMAC_FLAG_CCCH, false);
@@ -299,8 +299,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);
+       LOGPTBFDL(ctx->dl_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);
 }

@@ -321,7 +321,6 @@
 static void handle_timeout_X2002(struct osmo_fsm_inst *fi)
 {
        struct tbf_dl_fsm_ctx *ctx = (struct tbf_dl_fsm_ctx *)fi->priv;
-       struct gprs_rlcmac_dl_tbf *dl_tbf = tbf_as_dl_tbf(ctx->tbf);

        if (fi->state == TBF_ST_ASSIGN) {
                tbf_assign_control_ts(ctx->tbf);
@@ -342,9 +341,9 @@
                ctx->state_flags &= GPRS_RLCMAC_FLAG_TO_MASK;

                tbf_update(ctx->tbf);
-               dl_tbf_trigger_ass_on_pacch(dl_tbf, ctx->tbf);
+               dl_tbf_trigger_ass_on_pacch(ctx->dl_tbf, ctx->tbf);
        } else
-               LOGPTBF(ctx->tbf, LOGL_NOTICE, "Continue flow after IMM.ASS 
confirm\n");
+               LOGPTBFDL(ctx->dl_tbf, LOGL_NOTICE, "Continue flow after 
IMM.ASS confirm\n");
 }

 static int tbf_dl_fsm_timer_cb(struct osmo_fsm_inst *fi)
@@ -355,7 +354,7 @@
                handle_timeout_X2002(fi);
                break;
        case -2001:
-               LOGPTBF(ctx->tbf, LOGL_NOTICE, "releasing due to PACCH 
assignment timeout.\n");
+               LOGPTBFDL(ctx->dl_tbf, LOGL_NOTICE, "releasing due to PACCH 
assignment timeout.\n");
                /* fall-through */
        case 3169:
        case 3193:
diff --git a/src/tbf_fsm.h b/src/tbf_fsm.h
index a62e72d..2bdacc5 100644
--- a/src/tbf_fsm.h
+++ b/src/tbf_fsm.h
@@ -57,7 +57,10 @@
 };

 struct tbf_dl_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_dl_tbf *dl_tbf;
+       };
        uint32_t state_flags;
        unsigned int T_release; /* Timer to be used to end release: T3169 or 
T3195 */
 };

--
To view, visit https://gerrit.osmocom.org/c/osmo-pcu/+/30562
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Change-Id: Id2571e55e1fea2918207175f2030ec026e880bc1
Gerrit-Change-Number: 30562
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <[email protected]>
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>
Gerrit-MessageType: merged

Reply via email to