blob: 1628d8fd968069455f94fbd3e1bf4dc2271f5965 [file] [log] [blame]
Neels Hofmeyr31f525e2018-05-14 18:14:15 +02001/* Handover FSM API for intra-BSC and inter-BSC Handover. */
2#pragma once
3
4#include <osmocom/bsc/debug.h>
5#include <osmocom/bsc/handover.h>
6
Neels Hofmeyr31f525e2018-05-14 18:14:15 +02007/* Terminology:
8 * Intra-Cell: stays within one BTS, this should actually be an Assignment.
9 * Intra-BSC: stays within one BSC, but moves between BTSes.
10 * Inter-BSC: moves between BSCs.
11 * Inter-BSC Out: move away from this BSC to another one.
12 * Inter-BSC In: move from another BSC to this one.
13 */
14
15enum handover_fsm_state {
16 HO_ST_NOT_STARTED,
17
18 HO_ST_WAIT_LCHAN_ACTIVE,
Neels Hofmeyr5a06da12019-03-14 04:36:40 +010019 HO_ST_WAIT_MGW_ENDPOINT_TO_MSC,
Neels Hofmeyr31f525e2018-05-14 18:14:15 +020020 HO_ST_WAIT_RR_HO_DETECT,
21 HO_ST_WAIT_RR_HO_COMPLETE,
22 HO_ST_WAIT_LCHAN_ESTABLISHED,
Neels Hofmeyr31f525e2018-05-14 18:14:15 +020023
24 /* The inter-BSC Outgoing Handover FSM has completely separate states, but since it makes sense for it
25 * to also live in conn->ho.fi, it should share the same event enum. From there it is merely
26 * cosmetic to just include the separate fairly trivial states in the same FSM definition.
27 * An inter-BSC Outgoing FSM is almost unnecessary. The sole reason is to wait whether the MSC
28 * indeed clears the conn, and if not to log and count a failed handover attempt. */
29 HO_OUT_ST_WAIT_HO_COMMAND,
30 HO_OUT_ST_WAIT_CLEAR,
31};
32
33enum handover_fsm_event {
34 HO_EV_LCHAN_ACTIVE,
35 HO_EV_LCHAN_ESTABLISHED,
36 HO_EV_LCHAN_ERROR,
Neels Hofmeyr5a06da12019-03-14 04:36:40 +010037 HO_EV_MSC_MGW_OK,
38 HO_EV_MSC_MGW_FAIL,
Neels Hofmeyr31f525e2018-05-14 18:14:15 +020039 HO_EV_RR_HO_DETECT,
40 HO_EV_RR_HO_COMPLETE,
41 HO_EV_RR_HO_FAIL,
Neels Hofmeyr31f525e2018-05-14 18:14:15 +020042 HO_EV_CONN_RELEASING,
43
44 HO_OUT_EV_BSSMAP_HO_COMMAND,
45};
46
47struct ho_out_rx_bssmap_ho_command {
48 const uint8_t *l3_info;
49 const uint8_t l3_info_len;
50};
51
52/* To be sent along with the HO_EV_RR_HO_DETECT */
53struct handover_rr_detect_data {
54 struct msgb *msg;
55 const uint8_t *access_delay;
56};
57
58void handover_fsm_init();
59
60void handover_request(struct handover_out_req *req);
61void handover_start(struct handover_out_req *req);
62void handover_start_inter_bsc_in(struct gsm_subscriber_connection *conn,
63 struct msgb *ho_request_msg);
64void handover_end(struct gsm_subscriber_connection *conn, enum handover_result result);
65
66const char *handover_status(struct gsm_subscriber_connection *conn);
67bool handover_is_sane(struct gsm_subscriber_connection *conn, struct gsm_lchan *old_lchan,
68 struct gsm_lchan *new_lchan);