blob: 8f4f839491649509c912b5d57bcc698bdbdefd00 [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.
Pau Espin Pedroldc2aaac2021-05-14 12:50:46 +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_fsm_event {
Pau Espin Pedrol33e80072021-07-22 19:20:50 +020026 TBF_EV_ASSIGN_ADD_CCCH, /* An assignment is sent over CCCH and confirmation from MS is pending */
27 TBF_EV_ASSIGN_ADD_PACCH, /* An assignment is sent over PACCH and confirmation from MS is pending */
Pau Espin Pedrol720e19e2021-07-22 19:56:37 +020028 TBF_EV_ASSIGN_ACK_PACCH, /* We received a CTRL ACK confirming assignment started on PACCH */
29 TBF_EV_ASSIGN_READY_CCCH, /* TBF Start Time timer triggered */
Pau Espin Pedrol32252902021-07-29 16:44:11 +020030 TBF_EV_ASSIGN_PCUIF_CNF, /* Transmission of IMM.ASS for DL TBF to the MS confirmed by BTS over PCUIF */
Pau Espin Pedrol338a5ae2022-10-28 18:47:44 +020031 TBF_EV_FIRST_UL_DATA_RECVD, /* UL TBF: Received first UL data from MS. Equals to Contention Resolution completed on the network side */
Pau Espin Pedrolf38a47e2022-10-28 19:06:45 +020032 TBF_EV_CONTENTION_RESOLUTION_MS_SUCCESS, /* UL TBF: Contention resolution success at the mobile station side (first UL_ACK_NACK confirming TLLI is received at the MS) */
Pau Espin Pedrol32252902021-07-29 16:44:11 +020033 TBF_EV_DL_ACKNACK_MISS, /* DL TBF: We polled for DL ACK/NACK but we received none (POLL timeout) */
Pau Espin Pedrolc32c4a32021-07-23 18:27:57 +020034 TBF_EV_LAST_DL_DATA_SENT, /* DL TBF sends RLCMAC block containing last DL avilable data buffered */
35 TBF_EV_LAST_UL_DATA_RECVD, /* UL TBF sends RLCMAC block containing last UL data (cv=0) */
Pau Espin Pedrolefcb0462021-07-26 12:33:39 +020036 TBF_EV_FINAL_ACK_RECVD, /* DL ACK/NACK with FINAL_ACK=1 received from MS */
Pau Espin Pedrol22b26d82022-10-26 15:44:14 +020037 TBF_EV_FINAL_UL_ACK_CONFIRMED, /* UL TBF: MS ACKs (CtrlAck or PktResReq) our UL ACK/NACK w/ FinalAckInd=1. data = (bool) MS requests establishment of a new UL-TBF. */
Pau Espin Pedrol55f600b2021-07-26 15:54:39 +020038 TBF_EV_MAX_N3101, /* MAX N3101 (max usf timeout) reached (UL TBF) */
39 TBF_EV_MAX_N3103, /* MAX N3103 (max Pkt Ctrl Ack for last UL ACK/NACK timeout) reached (UL TBF) */
40 TBF_EV_MAX_N3105, /* MAX N3105 (max poll timeout) reached (UL/DL TBF) */
Pau Espin Pedroldc2aaac2021-05-14 12:50:46 +020041};
42
43enum tbf_fsm_states {
Pau Espin Pedrol00430052021-10-12 12:04:03 +020044 TBF_ST_NEW = 0, /* new created TBF */
Pau Espin Pedroldc2aaac2021-05-14 12:50:46 +020045 TBF_ST_ASSIGN, /* wait for downlink assignment */
46 TBF_ST_FLOW, /* RLC/MAC flow, resource needed */
47 TBF_ST_FINISHED, /* flow finished, wait for release */
48 TBF_ST_WAIT_RELEASE,/* wait for release or restart of DL TBF */
49 TBF_ST_RELEASING, /* releasing, wait to free TBI/USF */
50};
51
52struct tbf_fsm_ctx {
Pau Espin Pedroldc2aaac2021-05-14 12:50:46 +020053 struct gprs_rlcmac_tbf* tbf; /* back pointer */
Pau Espin Pedrol33e80072021-07-22 19:20:50 +020054 uint32_t state_flags;
Pau Espin Pedrolcfb61d92021-07-26 17:17:02 +020055 unsigned int T_release; /* Timer to be used to end release: T3169 or T3195 */
Pau Espin Pedroldc2aaac2021-05-14 12:50:46 +020056};
57
Pau Espin Pedroldc2aaac2021-05-14 12:50:46 +020058extern struct osmo_fsm tbf_fsm;