blob: 8a612f26c790f5b81e91caac230ac12989403273 [file] [log] [blame]
Pau Espin Pedrol6ad11a62021-07-27 12:27:08 +02001/* tbf_ul_ass_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.
Pau Espin Pedrol6ad11a62021-07-27 12:27:08 +020015 */
16#pragma once
17
18#include <osmocom/core/fsm.h>
19#include <osmocom/core/tdef.h>
20
21#include <gprs_pcu.h>
22
23struct gprs_rlcmac_tbf;
24
25enum tbf_ul_ass_fsm_event {
26 TBF_UL_ASS_EV_SCHED_ASS, /* Tx Uplink Assignment is pending */
27 TBF_UL_ASS_EV_SCHED_ASS_REJ, /* Tx Uplink Assignment is pending */
28 TBF_UL_ASS_EV_CREATE_RLCMAC_MSG, /* Scheduler wants to gen+Tx the Ass (rej): data=tbf_ul_ass_ev_create_rlcmac_msg_ctx */
29 TBF_UL_ASS_EV_RX_ASS_CTRL_ACK, /* Received CTRL ACK answering poll set on Pkt Ul Ass */
30 TBF_UL_ASS_EV_ASS_POLL_TIMEOUT, /* Pdch Ul Controller signals timeout for poll set on Pkt Ul Ass */
Pau Espin Pedrolb3291bc2021-10-14 19:21:38 +020031 TBF_UL_ASS_EV_ABORT, /* TBF is starting to be RELEASED, drop in progress assignment */
Pau Espin Pedrol6ad11a62021-07-27 12:27:08 +020032};
33
34enum tbf_ul_ass_fsm_states {
35 TBF_UL_ASS_NONE = 0,
36 TBF_UL_ASS_SEND_ASS, /* send uplink assignment on next RTS */
37 TBF_UL_ASS_SEND_ASS_REJ, /* send assignment reject next RTS */
38 TBF_UL_ASS_WAIT_ACK, /* wait for PACKET CONTROL ACK */
39};
40
41struct tbf_ul_ass_fsm_ctx {
42 struct osmo_fsm_inst *fi;
43 struct gprs_rlcmac_tbf* tbf; /* back pointer */
44};
45
46extern const struct osmo_tdef_state_timeout tbf_ul_ass_fsm_timeouts[32];
47/* Transition to a state, using the T timer defined in tbf_ul_ass_fsm_timeouts.
48 * The actual timeout value is in turn obtained from conn->T_defs.
49 * Assumes local variable fi exists. */
50#define tbf_ul_ass_fsm_state_chg(fi, NEXT_STATE) \
51 osmo_tdef_fsm_inst_state_chg(fi, NEXT_STATE, \
52 tbf_ul_ass_fsm_timeouts, \
53 the_pcu->T_defs, \
54 -1)
55
56extern struct osmo_fsm tbf_ul_ass_fsm;
57
58
59/* passed as data in TBF_UL_ASS_EV_CREATE_RLCMAC_MSG */
60struct tbf_ul_ass_ev_create_rlcmac_msg_ctx {
61 uint32_t fn; /* FN where the created DL ctrl block is to be sent */
62 uint8_t ts; /* TS where the created DL ctrl block is to be sent */
63 struct msgb *msg; /* to be filled by FSM during event processing */
64};
65
66
67struct msgb *tbf_ul_ass_create_rlcmac_msg(const struct gprs_rlcmac_tbf* tbf, uint32_t fn, uint8_t ts);
68bool tbf_ul_ass_rts(const struct gprs_rlcmac_tbf* tbf);