blob: 7b0adfd0a9214b481cff43449d477698a788db0e [file] [log] [blame]
Pau Espin Pedrolc0a250d2021-01-21 18:46:13 +01001/* nacc_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/gsm/gsm23003.h>
24
25#include <neigh_cache.h>
26
27struct GprsMs;
28struct gprs_rlcmac_tbf;
29
30enum nacc_fsm_event {
31 NACC_EV_RX_CELL_CHG_NOTIFICATION, /* data: Packet_Cell_Change_Notification_t* */
32 NACC_EV_RX_RAC_CI, /* no data passed, RAC_CI became available in neigh_cache */
33 NACC_EV_RX_SI, /* data: struct si_cache_entry* */
34 NACC_EV_CREATE_RLCMAC_MSG, /* data: struct nacc_ev_create_rlcmac_msg_ctx* */
Pau Espin Pedrol952cb3d2021-02-01 14:52:48 +010035 NACC_EV_RX_CELL_CHG_CONTINUE_ACK,
36 NACC_EV_TIMEOUT_CELL_CHG_CONTINUE, /* Poll Timeout */
Pau Espin Pedrolc0a250d2021-01-21 18:46:13 +010037};
38
39enum nacc_fsm_states {
40 NACC_ST_INITIAL,
41 NACC_ST_WAIT_RESOLVE_RAC_CI,
42 NACC_ST_WAIT_REQUEST_SI,
43 NACC_ST_TX_NEIGHBOUR_DATA,
44 NACC_ST_TX_CELL_CHG_CONTINUE,
Pau Espin Pedrol952cb3d2021-02-01 14:52:48 +010045 NACC_ST_WAIT_CELL_CHG_CONTINUE_ACK,
Pau Espin Pedrolc0a250d2021-01-21 18:46:13 +010046 NACC_ST_DONE,
47};
48
49struct nacc_fsm_ctx {
50 struct osmo_fsm_inst *fi;
51 struct GprsMs* ms; /* back pointer */
52 struct ctrl_handle *neigh_ctrl;
53 struct ctrl_connection *neigh_ctrl_conn;
54 struct neigh_cache_entry_key neigh_key; /* target cell info from MS */
55 struct osmo_cell_global_id_ps cgi_ps; /* target cell info resolved from req_{arfcn+bsic} */
56 struct si_cache_value si_info; /* SI info resolved from SGSN, to be sent to MS */
57 size_t si_info_bytes_sent; /* How many bytes out of si_info->si_len were already sent to MS */
58 size_t container_idx; /* Next container_idx to assign when sending Packet Neighbor Data message */
Pau Espin Pedrol952cb3d2021-02-01 14:52:48 +010059 uint32_t continue_poll_fn; /* Scheduled poll FN to CTRL ACK the Pkt Cell Chg Continue */
60 uint8_t continue_poll_ts; /* Scheduled poll TS to CTRL ACK the Pkt Cell Chg Continue */
Pau Espin Pedrolc0a250d2021-01-21 18:46:13 +010061};
62
63/* passed as data in NACC_EV_CREATE_RLCMAC_MSG */
64struct nacc_ev_create_rlcmac_msg_ctx {
65 struct gprs_rlcmac_tbf *tbf; /* target tbf to create messages for */
Pau Espin Pedrol952cb3d2021-02-01 14:52:48 +010066 uint32_t fn; /* FN where the created DL ctrl block is to be sent */
67 uint8_t ts; /* TS where the created DL ctrl block is to be sent */
Pau Espin Pedrolc0a250d2021-01-21 18:46:13 +010068 struct msgb *msg; /* to be filled by FSM during event processing */
69};
70
71struct nacc_fsm_ctx *nacc_fsm_alloc(struct GprsMs* ms);