diff options
Diffstat (limited to 'src/tbf_dl_ass_fsm.c')
-rw-r--r-- | src/tbf_dl_ass_fsm.c | 62 |
1 files changed, 37 insertions, 25 deletions
diff --git a/src/tbf_dl_ass_fsm.c b/src/tbf_dl_ass_fsm.c index 37ced616..d811b711 100644 --- a/src/tbf_dl_ass_fsm.c +++ b/src/tbf_dl_ass_fsm.c @@ -12,10 +12,6 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <unistd.h> @@ -35,13 +31,13 @@ #define X(s) (1 << (s)) -const struct osmo_tdef_state_timeout tbf_dl_ass_fsm_timeouts[32] = { +static const struct osmo_tdef_state_timeout tbf_dl_ass_fsm_timeouts[32] = { [TBF_DL_ASS_NONE] = {}, [TBF_DL_ASS_SEND_ASS] = {}, [TBF_DL_ASS_WAIT_ACK] = {}, }; -const struct value_string tbf_dl_ass_fsm_event_names[] = { +static const struct value_string tbf_dl_ass_fsm_event_names[] = { { TBF_DL_ASS_EV_SCHED_ASS, "SCHED_ASS" }, { TBF_DL_ASS_EV_CREATE_RLCMAC_MSG, "CREATE_RLCMAC_MSG" }, { TBF_DL_ASS_EV_RX_ASS_CTRL_ACK, "RX_ASS_CTRL_ACK" }, @@ -49,7 +45,16 @@ const struct value_string tbf_dl_ass_fsm_event_names[] = { { 0, NULL } }; -struct msgb *create_packet_dl_assign(const struct tbf_dl_ass_fsm_ctx *ctx, +/* Transition to a state, using the T timer defined in tbf_dl_ass_fsm_timeouts. + * The actual timeout value is in turn obtained from conn->T_defs. + * Assumes local variable fi exists. */ +#define tbf_dl_ass_fsm_state_chg(fi, NEXT_STATE) \ + osmo_tdef_fsm_inst_state_chg(fi, NEXT_STATE, \ + tbf_dl_ass_fsm_timeouts, \ + the_pcu->T_defs, \ + -1) + +static struct msgb *create_packet_dl_assign(const struct tbf_dl_ass_fsm_ctx *ctx, const struct tbf_dl_ass_ev_create_rlcmac_msg_ctx *d) { struct msgb *msg; @@ -63,9 +68,9 @@ struct msgb *create_packet_dl_assign(const struct tbf_dl_ass_fsm_ctx *ctx, bool old_tfi_is_valid = tbf_is_tfi_assigned(ctx->tbf); /* We only use this function in control TS (PACCH) so that MS can always answer the poll */ - OSMO_ASSERT(tbf_is_control_ts(ctx->tbf, d->ts)); + OSMO_ASSERT(tbf_is_control_ts(ctx->tbf, d->pdch)); - rc = tbf_check_polling(ctx->tbf, d->fn, d->ts, &new_poll_fn, &rrbp); + rc = tbf_check_polling(ctx->tbf, d->pdch, d->fn, &new_poll_fn, &rrbp); if (rc < 0) return NULL; @@ -77,9 +82,6 @@ struct msgb *create_packet_dl_assign(const struct tbf_dl_ass_fsm_ctx *ctx, return NULL; } - if (new_dl_tbf == as_dl_tbf(ctx->tbf)) - LOGPTBF(ctx->tbf, LOGL_DEBUG, "New and old TBF are the same.\n"); - if (old_tfi_is_valid && ms_tlli(ms) == GSM_RESERVED_TMSI) { LOGPTBF(ctx->tbf, LOGL_ERROR, "The old TFI is not assigned and there is no TLLI. New TBF %s\n", @@ -99,7 +101,12 @@ struct msgb *create_packet_dl_assign(const struct tbf_dl_ass_fsm_ctx *ctx, }; bitvec_unhex(&bv, DUMMY_VEC); - LOGPTBF((struct gprs_rlcmac_tbf *)new_dl_tbf, LOGL_INFO, "start Packet Downlink Assignment (PACCH)\n"); + if (ctx->tbf != (struct gprs_rlcmac_tbf *)new_dl_tbf) + LOGPTBF(ctx->tbf, LOGL_INFO, "start Packet Downlink Assignment (PACCH) for %s\n", + tbf_name((const struct gprs_rlcmac_tbf *)new_dl_tbf)); + else + LOGPTBF(ctx->tbf, LOGL_INFO, "start Packet Downlink Assignment (PACCH)\n"); + mac_control_block = (RlcMacDownlink_t *)talloc_zero(ctx->tbf, RlcMacDownlink_t); write_packet_downlink_assignment(mac_control_block, old_tfi_is_valid, tbf_tfi(ctx->tbf), (tbf_direction(ctx->tbf) == GPRS_RLCMAC_DL_TBF), @@ -115,9 +122,9 @@ struct msgb *create_packet_dl_assign(const struct tbf_dl_ass_fsm_ctx *ctx, LOGP(DTBF, LOGL_DEBUG, "------------------------- TX : Packet Downlink Assignment -------------------------\n"); bts_do_rate_ctr_inc(ms->bts, CTR_PKT_DL_ASSIGNMENT); - tbf_set_polling(ctx->tbf, new_poll_fn, d->ts, PDCH_ULC_POLL_DL_ASS); - LOGPTBFDL(ctx->tbf, LOGL_INFO, "Scheduled DL Assignment polling on PACCH (FN=%d, TS=%d)\n", - new_poll_fn, d->ts); + tbf_set_polling(ctx->tbf, d->pdch, new_poll_fn, PDCH_ULC_POLL_DL_ASS); + LOGPTBF(ctx->tbf, LOGL_INFO, "Scheduled DL Assignment polling on PACCH (FN=%d, TS=%d)\n", + new_poll_fn, d->pdch->ts_no); talloc_free(mac_control_block); return msg; @@ -183,11 +190,7 @@ static void st_wait_ack(struct osmo_fsm_inst *fi, uint32_t event, void *data) static int tbf_dl_ass_fsm_timer_cb(struct osmo_fsm_inst *fi) { - struct tbf_dl_ass_fsm_ctx *ctx = (struct tbf_dl_ass_fsm_ctx *)fi->priv; switch (fi->T) { - case -2000: - tbf_free(ctx->tbf); - break; default: OSMO_ASSERT(0); } @@ -206,7 +209,9 @@ static struct osmo_fsm_state tbf_dl_ass_fsm_states[] = { }, [TBF_DL_ASS_SEND_ASS] = { .in_event_mask = X(TBF_DL_ASS_EV_CREATE_RLCMAC_MSG), - .out_state_mask = X(TBF_DL_ASS_WAIT_ACK), + .out_state_mask = + X(TBF_DL_ASS_WAIT_ACK) | + X(TBF_DL_ASS_NONE), .name = "SEND_ASS", .action = st_send_ass, }, @@ -237,12 +242,14 @@ static __attribute__((constructor)) void tbf_dl_ass_fsm_init(void) } -struct msgb *tbf_dl_ass_create_rlcmac_msg(const struct gprs_rlcmac_tbf* tbf, uint32_t fn, uint8_t ts) +struct msgb *tbf_dl_ass_create_rlcmac_msg(const struct gprs_rlcmac_tbf *tbf, + const struct gprs_rlcmac_pdch *pdch, + uint32_t fn) { int rc; struct tbf_dl_ass_ev_create_rlcmac_msg_ctx data_ctx = { + .pdch = pdch, .fn = fn, - .ts = ts, .msg = NULL, }; @@ -252,9 +259,14 @@ struct msgb *tbf_dl_ass_create_rlcmac_msg(const struct gprs_rlcmac_tbf* tbf, uin return data_ctx.msg; } -bool tbf_dl_ass_rts(const struct gprs_rlcmac_tbf *tbf) +bool tbf_dl_ass_rts(const struct gprs_rlcmac_tbf *tbf, const struct gprs_rlcmac_pdch *pdch) { - struct osmo_fsm_inst *fi = tbf_dl_ass_fi(tbf); + struct osmo_fsm_inst *fi; + + if (!tbf_is_control_ts(tbf, pdch)) + return false; + + fi = tbf_dl_ass_fi(tbf); if (fi->state != TBF_DL_ASS_SEND_ASS) return false; |