diff options
Diffstat (limited to 'src/tbf_ul_ass_fsm.c')
-rw-r--r-- | src/tbf_ul_ass_fsm.c | 85 |
1 files changed, 65 insertions, 20 deletions
diff --git a/src/tbf_ul_ass_fsm.c b/src/tbf_ul_ass_fsm.c index ab23fbdb..6f88f112 100644 --- a/src/tbf_ul_ass_fsm.c +++ b/src/tbf_ul_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,14 +31,14 @@ #define X(s) (1 << (s)) -const struct osmo_tdef_state_timeout tbf_ul_ass_fsm_timeouts[32] = { +static const struct osmo_tdef_state_timeout tbf_ul_ass_fsm_timeouts[32] = { [TBF_UL_ASS_NONE] = {}, - [TBF_UL_ASS_SEND_ASS] = {}, + [TBF_UL_ASS_SEND_ASS] = { .keep_timer = true }, [TBF_UL_ASS_SEND_ASS_REJ] = {}, - [TBF_UL_ASS_WAIT_ACK] = {}, + [TBF_UL_ASS_WAIT_ACK] = { .keep_timer = true }, }; -const struct value_string tbf_ul_ass_fsm_event_names[] = { +static const struct value_string tbf_ul_ass_fsm_event_names[] = { { TBF_UL_ASS_EV_SCHED_ASS, "SCHED_ASS" }, { TBF_UL_ASS_EV_SCHED_ASS_REJ, "SCHED_ASS_REJ" }, { TBF_UL_ASS_EV_CREATE_RLCMAC_MSG, "CREATE_RLCMAC_MSG" }, @@ -52,6 +48,15 @@ const struct value_string tbf_ul_ass_fsm_event_names[] = { { 0, NULL } }; +/* Transition to a state, using the T timer defined in tbf_ul_ass_fsm_timeouts. + * The actual timeout value is in turn obtained from conn->T_defs. + * Assumes local variable fi exists. */ +#define tbf_ul_ass_fsm_state_chg(fi, NEXT_STATE) \ + osmo_tdef_fsm_inst_state_chg(fi, NEXT_STATE, \ + tbf_ul_ass_fsm_timeouts, \ + the_pcu->T_defs, \ + -1) + static struct msgb *create_packet_access_reject(const struct tbf_ul_ass_fsm_ctx *ctx) { struct msgb *msg; @@ -64,7 +69,7 @@ static struct msgb *create_packet_access_reject(const struct tbf_ul_ass_fsm_ctx bitvec_unhex(packet_access_rej, DUMMY_VEC); write_packet_access_reject(packet_access_rej, ms_tlli(ms), - osmo_tdef_get(ms->bts->T_defs_bts, 3172, OSMO_TDEF_MS, -1)); + osmo_tdef_get(ms->bts->pcu->T_defs, 3172, OSMO_TDEF_MS, -1)); bts_do_rate_ctr_inc(ms->bts, CTR_PKT_ACCESS_REJ); @@ -75,7 +80,7 @@ static struct msgb *create_packet_access_reject(const struct tbf_ul_ass_fsm_ctx } -struct msgb *create_packet_ul_assign(const struct tbf_ul_ass_fsm_ctx *ctx, +static struct msgb *create_packet_ul_assign(const struct tbf_ul_ass_fsm_ctx *ctx, const struct tbf_ul_ass_ev_create_rlcmac_msg_ctx *d) { struct msgb *msg = NULL; @@ -87,7 +92,7 @@ struct msgb *create_packet_ul_assign(const struct tbf_ul_ass_fsm_ctx *ctx, unsigned int rrbp; uint32_t new_poll_fn; - 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; @@ -110,7 +115,12 @@ struct msgb *create_packet_ul_assign(const struct tbf_ul_ass_fsm_ctx *ctx, }; bitvec_unhex(&bv, DUMMY_VEC); - LOGPTBFUL((const struct gprs_rlcmac_tbf *)new_tbf, LOGL_INFO, "start Packet Uplink Assignment (PACCH)\n"); + if (ctx->tbf != ul_tbf_as_tbf_const(new_tbf)) + LOGPTBF(ctx->tbf, LOGL_INFO, "start Packet Uplink Assignment (PACCH) for %s\n", + tbf_name(ul_tbf_as_tbf_const(new_tbf))); + else + LOGPTBF(ctx->tbf, LOGL_INFO, "start Packet Uplink Assignment (PACCH)\n"); + mac_control_block = (RlcMacDownlink_t *)talloc_zero(ctx->tbf, RlcMacDownlink_t); tlli = ms_tlli(ms); write_packet_uplink_assignment(mac_control_block, tbf_tfi(ctx->tbf), @@ -127,9 +137,9 @@ struct msgb *create_packet_ul_assign(const struct tbf_ul_ass_fsm_ctx *ctx, LOGP(DTBF, LOGL_DEBUG, "------------------------- TX : Packet Uplink Assignment -------------------------\n"); bts_do_rate_ctr_inc(ms->bts, CTR_PKT_UL_ASSIGNMENT); - tbf_set_polling(ctx->tbf, new_poll_fn, d->ts, PDCH_ULC_POLL_UL_ASS); - LOGPTBFUL(ctx->tbf, LOGL_INFO, "Scheduled UL 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_UL_ASS); + LOGPTBF(ctx->tbf, LOGL_INFO, "Scheduled UL Assignment polling on PACCH (FN=%d, TS=%d)\n", + new_poll_fn, d->pdch->ts_no); talloc_free(mac_control_block); return msg; @@ -154,7 +164,7 @@ static void st_none_on_enter(struct osmo_fsm_inst *fi, uint32_t prev_state) 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 X2000 [reject (PACCH)] with %u sec. %u microsec\n", + LOGPTBF(ctx->tbf, LOGL_DEBUG, "Starting timer X2000 [reject (PACCH)] with %u sec. %u microsec\n", sec, micro); osmo_timer_schedule(&fi->timer, sec, micro); } @@ -178,6 +188,32 @@ static void st_none(struct osmo_fsm_inst *fi, uint32_t event, void *data) } } +static void st_send_ass_on_enter(struct osmo_fsm_inst *fi, uint32_t prev_state) +{ + struct tbf_ul_ass_fsm_ctx *ctx = (struct tbf_ul_ass_fsm_ctx *)fi->priv; + unsigned long val; + unsigned int sec, micro; + struct GprsMs *ms = tbf_ms(ctx->tbf); + + /* Here it's point in time where we received PKT RES REQ or DL ACK/NACK to request a new UL TBF, + * so MS will be gone after T3168 (* 4 retrans, 8.1.1.1.2) if we are unable to seize it. + * Hence, attempt re-scheduling PKT UL ASS (states SEND_ASS<->WAIT_ACK ping-pong) until T3168 we + * announced (SI13) to the MS expires: + */ + if (prev_state == TBF_UL_ASS_NONE) { + /* tbf_free() called upon trigger */ + fi->T = 3168; + val = osmo_tdef_get(ms->bts->T_defs_bts, fi->T, OSMO_TDEF_MS, -1); + val *= 4; /* 4 PKT RES REQ retransmit */ + sec = val / 1000; + micro = (val % 1000) * 1000; + LOGPTBF(ctx->tbf, LOGL_DEBUG, "Starting timer T3168 [PKT UL ASS PACCH] with %u sec. %u microsec\n", + sec, micro); + osmo_timer_schedule(&fi->timer, sec, micro); + } + +} + static void st_send_ass(struct osmo_fsm_inst *fi, uint32_t event, void *data) { struct tbf_ul_ass_fsm_ctx *ctx = (struct tbf_ul_ass_fsm_ctx *)fi->priv; @@ -258,6 +294,7 @@ static int tbf_ul_ass_fsm_timer_cb(struct osmo_fsm_inst *fi) struct tbf_ul_ass_fsm_ctx *ctx = (struct tbf_ul_ass_fsm_ctx *)fi->priv; switch (fi->T) { case -2000: + case 3168: tbf_free(ctx->tbf); break; default: @@ -288,6 +325,7 @@ static struct osmo_fsm_state tbf_ul_ass_fsm_states[] = { X(TBF_UL_ASS_NONE), .name = "SEND_ASS", .action = st_send_ass, + .onenter = st_send_ass_on_enter, }, [TBF_UL_ASS_SEND_ASS_REJ] = { .in_event_mask = @@ -325,12 +363,14 @@ static __attribute__((constructor)) void tbf_ul_ass_fsm_init(void) } -struct msgb *tbf_ul_ass_create_rlcmac_msg(const struct gprs_rlcmac_tbf* tbf, uint32_t fn, uint8_t ts) +struct msgb *tbf_ul_ass_create_rlcmac_msg(const struct gprs_rlcmac_tbf *tbf, + const struct gprs_rlcmac_pdch *pdch, + uint32_t fn) { int rc; struct tbf_ul_ass_ev_create_rlcmac_msg_ctx data_ctx = { + .pdch = pdch, .fn = fn, - .ts = ts, .msg = NULL, }; @@ -340,8 +380,13 @@ struct msgb *tbf_ul_ass_create_rlcmac_msg(const struct gprs_rlcmac_tbf* tbf, uin return data_ctx.msg; } -bool tbf_ul_ass_rts(const struct gprs_rlcmac_tbf* tbf) +bool tbf_ul_ass_rts(const struct gprs_rlcmac_tbf *tbf, const struct gprs_rlcmac_pdch *pdch) { - struct osmo_fsm_inst *fi = tbf_ul_ass_fi(tbf); + struct osmo_fsm_inst *fi; + + if (!tbf_is_control_ts(tbf, pdch)) + return false; + + fi = tbf_ul_ass_fi(tbf); return fi->state == TBF_UL_ASS_SEND_ASS || fi->state == TBF_UL_ASS_SEND_ASS_REJ; } |