blob: a3050c0751c3ba83cda4bf8117d9673cac9ce6a1 [file] [log] [blame]
Pau Espin Pedroldc2aaac2021-05-14 12:50:46 +02001/* tbf_fsm.h
2 *
3 * Copyright (C) 2021 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
4 * Author: Pau Espin Pedrol <pespin@sysmocom.de>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 */
20#pragma once
21
22#include <osmocom/core/fsm.h>
23#include <osmocom/core/tdef.h>
24
25#include <gprs_pcu.h>
26
27struct gprs_rlcmac_tbf;
28
29enum tbf_fsm_event {
Pau Espin Pedrol33e80072021-07-22 19:20:50 +020030 TBF_EV_ASSIGN_ADD_CCCH, /* An assignment is sent over CCCH and confirmation from MS is pending */
31 TBF_EV_ASSIGN_ADD_PACCH, /* An assignment is sent over PACCH and confirmation from MS is pending */
32 TBF_EV_ASSIGN_DEL_CCCH, /* An assignment previously sent over CCCH has been confirmed by MS */
Pau Espin Pedrol720e19e2021-07-22 19:56:37 +020033 TBF_EV_ASSIGN_ACK_PACCH, /* We received a CTRL ACK confirming assignment started on PACCH */
34 TBF_EV_ASSIGN_READY_CCCH, /* TBF Start Time timer triggered */
Pau Espin Pedroldc2aaac2021-05-14 12:50:46 +020035};
36
37enum tbf_fsm_states {
38 TBF_ST_NULL = 0, /* new created TBF */
39 TBF_ST_ASSIGN, /* wait for downlink assignment */
40 TBF_ST_FLOW, /* RLC/MAC flow, resource needed */
41 TBF_ST_FINISHED, /* flow finished, wait for release */
42 TBF_ST_WAIT_RELEASE,/* wait for release or restart of DL TBF */
43 TBF_ST_RELEASING, /* releasing, wait to free TBI/USF */
44};
45
46struct tbf_fsm_ctx {
47 struct osmo_fsm_inst *fi;
48 struct gprs_rlcmac_tbf* tbf; /* back pointer */
Pau Espin Pedrol33e80072021-07-22 19:20:50 +020049 uint32_t state_flags;
Pau Espin Pedroldc2aaac2021-05-14 12:50:46 +020050};
51
52extern const struct osmo_tdef_state_timeout tbf_fsm_timeouts[32];
53/* Transition to a state, using the T timer defined in assignment_fsm_timeouts.
54 * The actual timeout value is in turn obtained from conn->T_defs.
55 * Assumes local variable fi exists. */
56#define tbf_fsm_state_chg(fi, NEXT_STATE) \
57 osmo_tdef_fsm_inst_state_chg(fi, NEXT_STATE, \
58 tbf_fsm_timeouts, \
59 the_pcu->T_defs, \
60 -1)
61
62extern struct osmo_fsm tbf_fsm;