Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 1 | /* 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 Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 7 | /* 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 | |
| 15 | enum handover_fsm_state { |
| 16 | HO_ST_NOT_STARTED, |
| 17 | |
| 18 | HO_ST_WAIT_LCHAN_ACTIVE, |
Neels Hofmeyr | 5a06da1 | 2019-03-14 04:36:40 +0100 | [diff] [blame] | 19 | HO_ST_WAIT_MGW_ENDPOINT_TO_MSC, |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 20 | HO_ST_WAIT_RR_HO_DETECT, |
| 21 | HO_ST_WAIT_RR_HO_COMPLETE, |
| 22 | HO_ST_WAIT_LCHAN_ESTABLISHED, |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 23 | |
| 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 | |
| 33 | enum handover_fsm_event { |
| 34 | HO_EV_LCHAN_ACTIVE, |
| 35 | HO_EV_LCHAN_ESTABLISHED, |
| 36 | HO_EV_LCHAN_ERROR, |
Neels Hofmeyr | 5a06da1 | 2019-03-14 04:36:40 +0100 | [diff] [blame] | 37 | HO_EV_MSC_MGW_OK, |
| 38 | HO_EV_MSC_MGW_FAIL, |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 39 | HO_EV_RR_HO_DETECT, |
| 40 | HO_EV_RR_HO_COMPLETE, |
| 41 | HO_EV_RR_HO_FAIL, |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 42 | HO_EV_CONN_RELEASING, |
| 43 | |
| 44 | HO_OUT_EV_BSSMAP_HO_COMMAND, |
| 45 | }; |
| 46 | |
| 47 | struct 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 */ |
| 53 | struct handover_rr_detect_data { |
| 54 | struct msgb *msg; |
| 55 | const uint8_t *access_delay; |
| 56 | }; |
| 57 | |
| 58 | void handover_fsm_init(); |
| 59 | |
| 60 | void handover_request(struct handover_out_req *req); |
| 61 | void handover_start(struct handover_out_req *req); |
| 62 | void handover_start_inter_bsc_in(struct gsm_subscriber_connection *conn, |
| 63 | struct msgb *ho_request_msg); |
| 64 | void handover_end(struct gsm_subscriber_connection *conn, enum handover_result result); |
| 65 | |
| 66 | const char *handover_status(struct gsm_subscriber_connection *conn); |
| 67 | bool handover_is_sane(struct gsm_subscriber_connection *conn, struct gsm_lchan *old_lchan, |
| 68 | struct gsm_lchan *new_lchan); |