blob: 4db08901d9913238ca7ba3f8fdc8636ef752e61b [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
7const char *handover_status(struct gsm_subscriber_connection *conn);
8
9/* This macro automatically includes a final \n, if omitted. */
10#define LOG_HO(conn, level, fmt, args...) do { \
11 if (conn->ho.fi) \
12 LOGPFSML(conn->ho.fi, level, "%s: " fmt, \
13 handover_status(conn), ## args); \
14 else \
15 LOGP(DHODEC, level, "%s: " fmt, \
16 handover_status(conn), ## args); \
17 } while(0)
18
19/* Terminology:
20 * Intra-Cell: stays within one BTS, this should actually be an Assignment.
21 * Intra-BSC: stays within one BSC, but moves between BTSes.
22 * Inter-BSC: moves between BSCs.
23 * Inter-BSC Out: move away from this BSC to another one.
24 * Inter-BSC In: move from another BSC to this one.
25 */
26
27enum handover_fsm_state {
28 HO_ST_NOT_STARTED,
29
30 HO_ST_WAIT_LCHAN_ACTIVE,
31 HO_ST_WAIT_RR_HO_DETECT,
32 HO_ST_WAIT_RR_HO_COMPLETE,
33 HO_ST_WAIT_LCHAN_ESTABLISHED,
34 HO_ST_WAIT_MGW_ENDPOINT_TO_MSC,
35
36 /* The inter-BSC Outgoing Handover FSM has completely separate states, but since it makes sense for it
37 * to also live in conn->ho.fi, it should share the same event enum. From there it is merely
38 * cosmetic to just include the separate fairly trivial states in the same FSM definition.
39 * An inter-BSC Outgoing FSM is almost unnecessary. The sole reason is to wait whether the MSC
40 * indeed clears the conn, and if not to log and count a failed handover attempt. */
41 HO_OUT_ST_WAIT_HO_COMMAND,
42 HO_OUT_ST_WAIT_CLEAR,
43};
44
45enum handover_fsm_event {
46 HO_EV_LCHAN_ACTIVE,
47 HO_EV_LCHAN_ESTABLISHED,
48 HO_EV_LCHAN_ERROR,
49 HO_EV_RR_HO_DETECT,
50 HO_EV_RR_HO_COMPLETE,
51 HO_EV_RR_HO_FAIL,
52 HO_EV_MSC_MGW_OK,
53 HO_EV_MSC_MGW_FAIL,
54 HO_EV_CONN_RELEASING,
55
56 HO_OUT_EV_BSSMAP_HO_COMMAND,
57};
58
59struct ho_out_rx_bssmap_ho_command {
60 const uint8_t *l3_info;
61 const uint8_t l3_info_len;
62};
63
64/* To be sent along with the HO_EV_RR_HO_DETECT */
65struct handover_rr_detect_data {
66 struct msgb *msg;
67 const uint8_t *access_delay;
68};
69
70void handover_fsm_init();
71
72void handover_request(struct handover_out_req *req);
73void handover_start(struct handover_out_req *req);
74void handover_start_inter_bsc_in(struct gsm_subscriber_connection *conn,
75 struct msgb *ho_request_msg);
76void handover_end(struct gsm_subscriber_connection *conn, enum handover_result result);
77
78const char *handover_status(struct gsm_subscriber_connection *conn);
79bool handover_is_sane(struct gsm_subscriber_connection *conn, struct gsm_lchan *old_lchan,
80 struct gsm_lchan *new_lchan);