Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1 | #ifndef _GSM_DATA_H |
| 2 | #define _GSM_DATA_H |
| 3 | |
Harald Welte | f142c97 | 2011-05-24 13:25:38 +0200 | [diff] [blame] | 4 | #include <stdint.h> |
Max | ddee01f | 2016-05-24 14:23:27 +0200 | [diff] [blame] | 5 | #include <regex.h> |
| 6 | #include <sys/types.h> |
Max | e6052c4 | 2016-06-30 10:25:49 +0200 | [diff] [blame] | 7 | #include <stdbool.h> |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 8 | #include <stdint.h> |
Harald Welte | f142c97 | 2011-05-24 13:25:38 +0200 | [diff] [blame] | 9 | |
| 10 | #include <osmocom/core/timer.h> |
Alexander Couzens | 20423ea | 2016-07-12 15:42:02 +0200 | [diff] [blame] | 11 | #include <osmocom/core/rate_ctr.h> |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 12 | #include <osmocom/core/select.h> |
Alexander Couzens | 20423ea | 2016-07-12 15:42:02 +0200 | [diff] [blame] | 13 | #include <osmocom/core/stats.h> |
Stefan Sperling | 81dc9e7 | 2018-02-05 17:34:36 +0100 | [diff] [blame] | 14 | #include <osmocom/core/stat_item.h> |
Philipp Maier | 8c498fc | 2018-02-21 13:24:36 +0100 | [diff] [blame] | 15 | #include <osmocom/gsm/bts_features.h> |
Neels Hofmeyr | a60f344 | 2018-02-12 16:44:32 +0100 | [diff] [blame] | 16 | #include <osmocom/gsm/protocol/gsm_08_08.h> |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 17 | #include <osmocom/gsm/gsm0808.h> |
Neels Hofmeyr | f93970b | 2018-03-05 02:09:40 +0100 | [diff] [blame] | 18 | #include <osmocom/gsm/gsm48.h> |
Harald Welte | 3561bd4 | 2018-01-28 03:04:16 +0100 | [diff] [blame] | 19 | #include <osmocom/core/fsm.h> |
Alexander Couzens | 20423ea | 2016-07-12 15:42:02 +0200 | [diff] [blame] | 20 | |
Harald Welte | 121e9a4 | 2016-04-20 13:13:19 +0200 | [diff] [blame] | 21 | #include <osmocom/crypt/auth.h> |
Harald Welte | f142c97 | 2011-05-24 13:25:38 +0200 | [diff] [blame] | 22 | |
Neels Hofmeyr | c016479 | 2017-09-04 15:15:32 +0200 | [diff] [blame] | 23 | #include <osmocom/bsc/rest_octets.h> |
Harald Welte | b96be39 | 2011-05-25 12:33:33 +0200 | [diff] [blame] | 24 | |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 25 | #include <osmocom/core/bitvec.h> |
| 26 | #include <osmocom/gsm/gsm_utils.h> |
| 27 | #include <osmocom/gsm/rxlev_stat.h> |
| 28 | #include <osmocom/gsm/protocol/gsm_08_58.h> |
| 29 | #include <osmocom/gsm/protocol/gsm_12_21.h> |
| 30 | #include <osmocom/abis/e1_input.h> |
| 31 | #include <osmocom/bsc/meas_rep.h> |
Harald Welte | 519c7e1 | 2018-01-28 02:45:46 +0100 | [diff] [blame] | 32 | #include <osmocom/bsc/bsc_msg_filter.h> |
Stefan Sperling | 6442e43 | 2018-02-06 14:44:54 +0100 | [diff] [blame] | 33 | #include <osmocom/bsc/acc_ramp.h> |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 34 | #include <osmocom/bsc/gsm_timers.h> |
| 35 | #include <osmocom/bsc/neighbor_ident.h> |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 36 | |
Neels Hofmeyr | 596c402 | 2018-06-16 19:29:50 +0200 | [diff] [blame] | 37 | #define GSM_T3122_DEFAULT 10 |
| 38 | |
Harald Welte | 74b8cdb | 2018-01-15 19:26:06 +0100 | [diff] [blame] | 39 | struct mgcp_client_conf; |
| 40 | struct mgcp_client; |
| 41 | struct mgcp_ctx; |
Neels Hofmeyr | 19bed23 | 2018-03-22 04:54:57 +0100 | [diff] [blame] | 42 | struct gsm0808_cell_id; |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 43 | struct mgw_endpoint; |
Philipp Maier | 39f62bb | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 44 | |
Holger Hans Peter Freyther | d7b22c6 | 2013-04-29 09:11:02 +0200 | [diff] [blame] | 45 | /** annotations for msgb ownership */ |
| 46 | #define __uses |
| 47 | |
Holger Hans Peter Freyther | 6f61555 | 2010-11-15 20:50:42 +0100 | [diff] [blame] | 48 | #define OBSC_NM_W_ACK_CB(__msgb) (__msgb)->cb[3] |
| 49 | |
Neels Hofmeyr | 6d804b1 | 2017-02-18 22:20:46 +0100 | [diff] [blame] | 50 | struct bsc_subscr; |
Neels Hofmeyr | 7b65688 | 2017-07-09 22:09:18 +0200 | [diff] [blame] | 51 | struct gprs_ra_id; |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 52 | struct handover; |
Holger Hans Peter Freyther | 694c82d | 2011-10-26 18:37:09 +0200 | [diff] [blame] | 53 | |
Holger Hans Peter Freyther | 9c595b7 | 2010-06-15 11:20:52 +0800 | [diff] [blame] | 54 | #define OBSC_LINKID_CB(__msgb) (__msgb)->cb[3] |
| 55 | |
Neels Hofmeyr | 0e5d807 | 2017-01-10 00:49:56 +0100 | [diff] [blame] | 56 | #define tmsi_from_string(str) strtoul(str, NULL, 10) |
| 57 | |
Max | 70fdd24 | 2017-06-15 15:10:53 +0200 | [diff] [blame] | 58 | /* 3-bit long values */ |
| 59 | #define EARFCN_PRIO_INVALID 8 |
| 60 | #define EARFCN_MEAS_BW_INVALID 8 |
| 61 | /* 5-bit long values */ |
| 62 | #define EARFCN_QRXLV_INVALID 32 |
| 63 | #define EARFCN_THRESH_LOW_INVALID 32 |
| 64 | |
Harald Welte | 8e1e3ee | 2009-02-01 13:32:45 +0000 | [diff] [blame] | 65 | struct msgb; |
| 66 | typedef int gsm_cbfn(unsigned int hooknum, |
| 67 | unsigned int event, |
| 68 | struct msgb *msg, |
| 69 | void *data, void *param); |
| 70 | |
Harald Welte | f7c28b0 | 2009-12-21 13:30:17 +0100 | [diff] [blame] | 71 | /* Maximum number of neighbor cells whose average we track */ |
| 72 | #define MAX_NEIGH_MEAS 10 |
| 73 | /* Maximum size of the averaging window for neighbor cells */ |
| 74 | #define MAX_WIN_NEIGH_AVG 10 |
Andreas Eversberg | 9869203 | 2013-06-23 10:44:34 +0200 | [diff] [blame] | 75 | /* Maximum number of report history we store */ |
| 76 | #define MAX_MEAS_REP 10 |
Harald Welte | f7c28b0 | 2009-12-21 13:30:17 +0100 | [diff] [blame] | 77 | |
| 78 | /* processed neighbor measurements for one cell */ |
| 79 | struct neigh_meas_proc { |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 80 | uint16_t arfcn; |
| 81 | uint8_t bsic; |
| 82 | uint8_t rxlev[MAX_WIN_NEIGH_AVG]; |
Harald Welte | f7c28b0 | 2009-12-21 13:30:17 +0100 | [diff] [blame] | 83 | unsigned int rxlev_cnt; |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 84 | uint8_t last_seen_nr; |
Harald Welte | f7c28b0 | 2009-12-21 13:30:17 +0100 | [diff] [blame] | 85 | }; |
| 86 | |
Harald Welte | a43e0b4 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 87 | struct gsm_classmark { |
| 88 | bool classmark1_set; |
| 89 | struct gsm48_classmark1 classmark1; |
| 90 | uint8_t classmark2_len; |
| 91 | uint8_t classmark2[3]; |
| 92 | uint8_t classmark3_len; |
| 93 | uint8_t classmark3[14]; /* if cm3 gets extended by spec, it will be truncated */ |
| 94 | }; |
| 95 | |
Harald Welte | 519c7e1 | 2018-01-28 02:45:46 +0100 | [diff] [blame] | 96 | enum subscr_sccp_state { |
| 97 | SUBSCR_SCCP_ST_NONE, |
| 98 | SUBSCR_SCCP_ST_WAIT_CONN_CONF, |
| 99 | SUBSCR_SCCP_ST_CONNECTED |
| 100 | }; |
| 101 | |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 102 | struct assignment_request { |
| 103 | bool aoip; |
| 104 | |
| 105 | uint16_t msc_assigned_cic; |
| 106 | |
| 107 | char msc_rtp_addr[INET_ADDRSTRLEN]; |
| 108 | uint16_t msc_rtp_port; |
| 109 | |
| 110 | enum gsm48_chan_mode chan_mode; |
| 111 | bool full_rate; |
Philipp Maier | c9a4f69 | 2018-09-21 14:21:50 +0200 | [diff] [blame] | 112 | uint16_t s15_s0; |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 113 | }; |
| 114 | |
| 115 | struct assignment_fsm_data { |
| 116 | struct assignment_request req; |
| 117 | bool requires_voice_stream; |
| 118 | |
| 119 | struct osmo_fsm_inst *fi; |
| 120 | struct gsm_lchan *new_lchan; |
| 121 | |
| 122 | /* Whether this assignment triggered creation of the MGW endpoint: if the assignment |
| 123 | * fails, we will release that again as soon as possible. (If false, the endpoint already |
| 124 | * existed before or isn't needed at all.)*/ |
| 125 | struct mgwep_ci *created_ci_for_msc; |
| 126 | |
| 127 | enum gsm0808_cause failure_cause; |
| 128 | enum gsm48_rr_cause rr_cause; |
| 129 | |
| 130 | bool result_rate_ctr_done; |
| 131 | }; |
| 132 | |
| 133 | enum hodec_id { |
| 134 | HODEC_NONE, |
| 135 | HODEC1 = 1, |
| 136 | HODEC2 = 2, |
| 137 | HODEC_USER, |
| 138 | HODEC_REMOTE, |
| 139 | }; |
| 140 | |
| 141 | /* For example, to count specific kinds of ongoing handovers, it is useful to be able to OR-combine |
| 142 | * scopes. */ |
| 143 | enum handover_scope { |
| 144 | HO_NO_HANDOVER = 0, |
| 145 | HO_INTRA_CELL = 0x1, |
| 146 | HO_INTRA_BSC = 0x2, |
| 147 | HO_INTER_BSC_OUT = 0x4, |
| 148 | HO_INTER_BSC_IN = 0x8, |
| 149 | HO_SCOPE_ALL = 0xffff, |
| 150 | }; |
| 151 | |
| 152 | extern const struct value_string handover_scope_names[]; |
| 153 | inline static const char *handover_scope_name(enum handover_scope val) |
| 154 | { return get_value_string(handover_scope_names, val); } |
| 155 | |
| 156 | struct handover_out_req { |
| 157 | enum hodec_id from_hodec_id; |
| 158 | struct gsm_lchan *old_lchan; |
| 159 | struct neighbor_ident_key target_nik; |
| 160 | enum gsm_chan_t new_lchan_type; /*< leave GSM_LCHAN_NONE to use same as old_lchan */ |
| 161 | }; |
| 162 | |
| 163 | struct handover_in_req { |
| 164 | struct gsm0808_channel_type ct; |
| 165 | struct gsm0808_speech_codec_list scl; |
| 166 | struct gsm0808_encrypt_info ei; |
| 167 | struct gsm_classmark classmark; |
| 168 | struct gsm0808_cell_id cell_id_serving; |
| 169 | char cell_id_serving_name[64]; |
| 170 | struct gsm0808_cell_id cell_id_target; |
| 171 | char cell_id_target_name[64]; |
| 172 | uint16_t msc_assigned_cic; |
| 173 | char msc_assigned_rtp_addr[INET_ADDRSTRLEN]; |
| 174 | uint16_t msc_assigned_rtp_port; |
| 175 | }; |
| 176 | |
| 177 | struct handover { |
| 178 | struct osmo_fsm_inst *fi; |
| 179 | |
| 180 | enum hodec_id from_hodec_id; |
| 181 | enum handover_scope scope; |
| 182 | enum gsm_chan_t new_lchan_type; |
| 183 | struct neighbor_ident_key target_cell; |
| 184 | |
| 185 | uint8_t ho_ref; |
| 186 | struct gsm_bts *new_bts; |
| 187 | struct gsm_lchan *new_lchan; |
| 188 | bool async; |
| 189 | struct handover_in_req inter_bsc_in; |
| 190 | struct mgwep_ci *created_ci_for_msc; |
| 191 | }; |
| 192 | |
Neels Hofmeyr | 378a492 | 2016-05-09 21:07:43 +0200 | [diff] [blame] | 193 | /* active radio connection of a mobile subscriber */ |
Holger Hans Peter Freyther | 68884aa | 2010-03-23 06:41:45 +0100 | [diff] [blame] | 194 | struct gsm_subscriber_connection { |
Harald Welte | a43e0b4 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 195 | /* global linked list of subscriber_connections */ |
Holger Hans Peter Freyther | 79f763f | 2010-09-16 00:53:37 +0800 | [diff] [blame] | 196 | struct llist_head entry; |
| 197 | |
Harald Welte | 3561bd4 | 2018-01-28 03:04:16 +0100 | [diff] [blame] | 198 | /* FSM instance to control the subscriber connection state (RTP, A) */ |
| 199 | struct osmo_fsm_inst *fi; |
| 200 | |
Harald Welte | a43e0b4 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 201 | /* libbsc subscriber information (if available) */ |
Neels Hofmeyr | 6d804b1 | 2017-02-18 22:20:46 +0100 | [diff] [blame] | 202 | struct bsc_subscr *bsub; |
| 203 | |
Holger Hans Peter Freyther | 18b63f4 | 2010-03-23 07:52:17 +0100 | [diff] [blame] | 204 | /* back pointers */ |
Neels Hofmeyr | 5e0b0a6 | 2016-05-09 22:33:01 +0200 | [diff] [blame] | 205 | struct gsm_network *network; |
| 206 | |
Harald Welte | 4a8ebc8 | 2017-12-18 18:34:41 +0100 | [diff] [blame] | 207 | /* the primary / currently active lchan to the BTS/subscriber */ |
| 208 | struct gsm_lchan *lchan; |
Harald Welte | 3561bd4 | 2018-01-28 03:04:16 +0100 | [diff] [blame] | 209 | |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 210 | struct assignment_fsm_data assignment; |
Holger Hans Peter Freyther | 77cd95d | 2010-11-14 16:19:48 +0100 | [diff] [blame] | 211 | |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 212 | /* handover information, if a handover is pending for this conn. */ |
| 213 | struct handover ho; |
Holger Hans Peter Freyther | 77cd95d | 2010-11-14 16:19:48 +0100 | [diff] [blame] | 214 | |
Harald Welte | 4a8ebc8 | 2017-12-18 18:34:41 +0100 | [diff] [blame] | 215 | /* buffer/cache for classmark of the ME of the subscriber */ |
Harald Welte | a43e0b4 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 216 | struct gsm_classmark classmark; |
Andreas Eversberg | 935e5d7 | 2013-06-17 11:58:30 +0200 | [diff] [blame] | 217 | |
Neels Hofmeyr | 149160f | 2018-06-16 17:20:13 +0200 | [diff] [blame] | 218 | /* Queue DTAP messages during handover/assignment (msgb_enqueue()/msgb_dequeue())*/ |
| 219 | struct llist_head dtap_queue; |
| 220 | unsigned int dtap_queue_len; |
Andreas Eversberg | 084b421 | 2013-05-30 14:12:48 +0200 | [diff] [blame] | 221 | |
Neels Hofmeyr | ec42264 | 2018-02-15 14:07:40 +0100 | [diff] [blame] | 222 | struct { |
Neels Hofmeyr | 909e972 | 2017-12-07 03:54:01 +0100 | [diff] [blame] | 223 | int failures; |
Neels Hofmeyr | ec42264 | 2018-02-15 14:07:40 +0100 | [diff] [blame] | 224 | struct penalty_timers *penalty_timers; |
| 225 | } hodec2; |
Neels Hofmeyr | a60f344 | 2018-02-12 16:44:32 +0100 | [diff] [blame] | 226 | |
| 227 | /* "Codec List (MSC Preferred)" as received by the BSSAP Assignment Request. 3GPP 48.008 |
| 228 | * 3.2.2.103 says: |
| 229 | * The "Codec List (MSC Preferred)" shall not include codecs |
| 230 | * that are not supported by the MS. |
| 231 | * i.e. by heeding the "Codec list (MSC Preferred)", we inherently heed the MS bearer |
| 232 | * capabilities, which the MSC is required to translate into the codec list. */ |
| 233 | struct gsm0808_speech_codec_list codec_list; |
Harald Welte | 519c7e1 | 2018-01-28 02:45:46 +0100 | [diff] [blame] | 234 | |
| 235 | /* flag to prevent multiple simultaneous ciphering commands */ |
| 236 | int ciphering_handled; |
| 237 | |
| 238 | /* state related to welcome USSD */ |
| 239 | uint8_t new_subscriber; |
| 240 | |
| 241 | /* state related to osmo_bsc_filter.c */ |
| 242 | struct bsc_filter_state filter_state; |
| 243 | |
| 244 | /* SCCP connection associatd with this subscriber_connection */ |
| 245 | struct { |
| 246 | /* for advanced ping/pong */ |
| 247 | int send_ping; |
| 248 | |
| 249 | /* SCCP connection realted */ |
| 250 | struct bsc_msc_data *msc; |
| 251 | |
| 252 | /* Sigtran connection ID */ |
| 253 | int conn_id; |
| 254 | enum subscr_sccp_state state; |
| 255 | } sccp; |
| 256 | |
| 257 | /* for audio handling */ |
| 258 | struct { |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 259 | uint16_t msc_assigned_cic; |
Harald Welte | 519c7e1 | 2018-01-28 02:45:46 +0100 | [diff] [blame] | 260 | |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 261 | /* RTP address where the MSC expects us to send the RTP stream coming from the BTS. */ |
| 262 | char msc_assigned_rtp_addr[INET_ADDRSTRLEN]; |
| 263 | uint16_t msc_assigned_rtp_port; |
Harald Welte | 519c7e1 | 2018-01-28 02:45:46 +0100 | [diff] [blame] | 264 | |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 265 | /* The endpoint at the MGW used to join both BTS and MSC side connections, e.g. |
| 266 | * "rtpbridge/23@mgw". */ |
| 267 | struct mgw_endpoint *mgw_endpoint; |
Harald Welte | 3561bd4 | 2018-01-28 03:04:16 +0100 | [diff] [blame] | 268 | |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 269 | /* The connection identifier of the mgw_endpoint used to transceive RTP towards the MSC. |
| 270 | * (The BTS side CI is handled by struct gsm_lchan and the lchan_fsm.) */ |
| 271 | struct mgwep_ci *mgw_endpoint_ci_msc; |
Harald Welte | 519c7e1 | 2018-01-28 02:45:46 +0100 | [diff] [blame] | 272 | } user_plane; |
Harald Welte | c997ceb | 2018-05-30 01:39:43 +0200 | [diff] [blame] | 273 | |
| 274 | /* LCLS (local call, local switch) related state */ |
| 275 | struct { |
| 276 | uint8_t global_call_ref[15]; |
| 277 | uint8_t global_call_ref_len; /* length of global_call_ref */ |
| 278 | uint8_t config; /* TS 48.008 3.2.2.116 */ |
| 279 | uint8_t control;/* TS 48.008 3.2.2.117 */ |
| 280 | /* LCLS FSM */ |
| 281 | struct osmo_fsm_inst *fi; |
| 282 | /* pointer to "other" connection, if Call Leg Relocation was successful */ |
| 283 | struct gsm_subscriber_connection *other; |
| 284 | } lcls; |
Holger Hans Peter Freyther | 68884aa | 2010-03-23 06:41:45 +0100 | [diff] [blame] | 285 | }; |
| 286 | |
Harald Welte | f142c97 | 2011-05-24 13:25:38 +0200 | [diff] [blame] | 287 | |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 288 | /* 16 is the max. number of SI2quater messages according to 3GPP TS 44.018 Table 10.5.2.33b.1: |
| 289 | 4-bit index is used (2#1111 = 10#15) */ |
| 290 | #define SI2Q_MAX_NUM 16 |
| 291 | /* length in bits (for single SI2quater message) */ |
| 292 | #define SI2Q_MAX_LEN 160 |
| 293 | #define SI2Q_MIN_LEN 18 |
| 294 | |
| 295 | struct osmo_bsc_data; |
| 296 | |
| 297 | struct osmo_bsc_sccp_con; |
| 298 | |
| 299 | /* Channel Request reason */ |
| 300 | enum gsm_chreq_reason_t { |
| 301 | GSM_CHREQ_REASON_EMERG, |
| 302 | GSM_CHREQ_REASON_PAG, |
| 303 | GSM_CHREQ_REASON_CALL, |
| 304 | GSM_CHREQ_REASON_LOCATION_UPD, |
| 305 | GSM_CHREQ_REASON_OTHER, |
| 306 | GSM_CHREQ_REASON_PDCH, |
| 307 | }; |
| 308 | |
| 309 | /* lchans 0..3 are SDCCH in combined channel configuration, |
| 310 | use 4 as magic number for BCCH hack - see osmo-bts-../oml.c:opstart_compl() */ |
| 311 | #define CCCH_LCHAN 4 |
| 312 | |
| 313 | #define TRX_NR_TS 8 |
| 314 | #define TS_MAX_LCHAN 8 |
| 315 | |
| 316 | #define HARDCODED_ARFCN 123 |
| 317 | #define HARDCODED_BSIC 0x3f /* NCC = 7 / BCC = 7 */ |
| 318 | |
| 319 | /* for multi-drop config */ |
| 320 | #define HARDCODED_BTS0_TS 1 |
| 321 | #define HARDCODED_BTS1_TS 6 |
| 322 | #define HARDCODED_BTS2_TS 11 |
| 323 | |
| 324 | #define MAX_VERSION_LENGTH 64 |
| 325 | |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 326 | enum gsm_hooks { |
| 327 | GSM_HOOK_NM_SWLOAD, |
| 328 | GSM_HOOK_RR_PAGING, |
| 329 | GSM_HOOK_RR_SECURITY, |
| 330 | }; |
| 331 | |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 332 | enum bts_gprs_mode { |
| 333 | BTS_GPRS_NONE = 0, |
| 334 | BTS_GPRS_GPRS = 1, |
| 335 | BTS_GPRS_EGPRS = 2, |
| 336 | }; |
| 337 | |
| 338 | struct gsm_lchan; |
| 339 | struct osmo_rtp_socket; |
| 340 | struct rtp_socket; |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 341 | |
| 342 | /* Network Management State */ |
| 343 | struct gsm_nm_state { |
| 344 | uint8_t operational; |
| 345 | uint8_t administrative; |
| 346 | uint8_t availability; |
| 347 | }; |
| 348 | |
| 349 | struct gsm_abis_mo { |
| 350 | uint8_t obj_class; |
| 351 | uint8_t procedure_pending; |
| 352 | struct abis_om_obj_inst obj_inst; |
| 353 | const char *name; |
| 354 | struct gsm_nm_state nm_state; |
| 355 | struct tlv_parsed *nm_attr; |
| 356 | struct gsm_bts *bts; |
| 357 | }; |
| 358 | |
| 359 | /* Ericsson OM2000 Managed Object */ |
| 360 | struct abis_om2k_mo { |
| 361 | uint8_t class; |
| 362 | uint8_t bts; |
| 363 | uint8_t assoc_so; |
| 364 | uint8_t inst; |
| 365 | } __attribute__ ((packed)); |
| 366 | |
| 367 | struct om2k_mo { |
| 368 | struct abis_om2k_mo addr; |
| 369 | struct osmo_fsm_inst *fsm; |
| 370 | }; |
| 371 | |
| 372 | #define A38_XOR_MIN_KEY_LEN 12 |
| 373 | #define A38_XOR_MAX_KEY_LEN 16 |
| 374 | #define A38_COMP128_KEY_LEN 16 |
| 375 | #define RSL_ENC_ALG_A5(x) (x+1) |
| 376 | #define MAX_EARFCN_LIST 32 |
| 377 | |
| 378 | /* is the data link established? who established it? */ |
| 379 | #define LCHAN_SAPI_UNUSED 0 |
| 380 | #define LCHAN_SAPI_MS 1 |
| 381 | #define LCHAN_SAPI_NET 2 |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 382 | |
| 383 | /* BTS ONLY */ |
| 384 | #define MAX_NUM_UL_MEAS 104 |
| 385 | #define LC_UL_M_F_L1_VALID (1 << 0) |
| 386 | #define LC_UL_M_F_RES_VALID (1 << 1) |
| 387 | |
| 388 | struct bts_ul_meas { |
| 389 | /* BER in units of 0.01%: 10.000 == 100% ber, 0 == 0% ber */ |
| 390 | uint16_t ber10k; |
| 391 | /* timing advance offset (in quarter bits) */ |
| 392 | int16_t ta_offs_qbits; |
| 393 | /* C/I ratio in dB */ |
| 394 | float c_i; |
| 395 | /* flags */ |
| 396 | uint8_t is_sub:1; |
| 397 | /* RSSI in dBm * -1 */ |
| 398 | uint8_t inv_rssi; |
| 399 | }; |
| 400 | |
| 401 | struct bts_codec_conf { |
| 402 | uint8_t hr; |
| 403 | uint8_t efr; |
| 404 | uint8_t amr; |
| 405 | }; |
| 406 | |
| 407 | struct amr_mode { |
| 408 | uint8_t mode; |
| 409 | uint8_t threshold; |
| 410 | uint8_t hysteresis; |
| 411 | }; |
| 412 | |
| 413 | struct amr_multirate_conf { |
| 414 | uint8_t gsm48_ie[2]; |
| 415 | struct amr_mode ms_mode[4]; |
| 416 | struct amr_mode bts_mode[4]; |
| 417 | uint8_t num_modes; |
| 418 | }; |
| 419 | /* /BTS ONLY */ |
| 420 | |
| 421 | enum lchan_csd_mode { |
| 422 | LCHAN_CSD_M_NT, |
| 423 | LCHAN_CSD_M_T_1200_75, |
| 424 | LCHAN_CSD_M_T_600, |
| 425 | LCHAN_CSD_M_T_1200, |
| 426 | LCHAN_CSD_M_T_2400, |
| 427 | LCHAN_CSD_M_T_9600, |
| 428 | LCHAN_CSD_M_T_14400, |
| 429 | LCHAN_CSD_M_T_29000, |
| 430 | LCHAN_CSD_M_T_32000, |
| 431 | }; |
| 432 | |
| 433 | /* State of the SAPIs in the lchan */ |
| 434 | enum lchan_sapi_state { |
| 435 | LCHAN_SAPI_S_NONE, |
| 436 | LCHAN_SAPI_S_REQ, |
| 437 | LCHAN_SAPI_S_ASSIGNED, |
| 438 | LCHAN_SAPI_S_REL, |
| 439 | LCHAN_SAPI_S_ERROR, |
| 440 | }; |
| 441 | |
Neels Hofmeyr | 92b9f2e | 2018-02-14 00:19:11 +0100 | [diff] [blame] | 442 | #define MAX_A5_KEY_LEN (128/8) |
| 443 | |
| 444 | struct gsm_encr { |
| 445 | uint8_t alg_id; |
| 446 | uint8_t key_len; |
| 447 | uint8_t key[MAX_A5_KEY_LEN]; |
| 448 | }; |
| 449 | |
Neels Hofmeyr | 8da2233 | 2018-04-11 01:43:41 +0200 | [diff] [blame] | 450 | #define LOGPLCHAN(lchan, ss, level, fmt, args...) \ |
| 451 | LOGP(ss, level, "%s (ss=%d,%s) (%s) " fmt, \ |
| 452 | lchan ? gsm_ts_and_pchan_name(lchan->ts) : "-", \ |
| 453 | lchan ? lchan->nr : 0, \ |
| 454 | lchan ? gsm_lchant_name(lchan->type) : "-", \ |
| 455 | bsc_subscr_name(lchan && lchan->conn ? lchan->conn->bsub : NULL), \ |
| 456 | ## args) |
| 457 | |
Pau Espin Pedrol | d3e8e0c | 2018-11-28 16:35:10 +0100 | [diff] [blame^] | 458 | /* Iterate lchans that have an FSM allocated based based on explicit pchan kind |
| 459 | * (GSM_PCHAN_* constant). |
| 460 | * Remark: PDCH related lchans are not handled in BSC but in PCU, so trying to |
| 461 | * iterate through GSM_PCHAN_PDCH is considered a void loop. |
| 462 | */ |
| 463 | #define ts_as_pchan_for_each_lchan(lchan, ts, as_pchan) \ |
| 464 | for (lchan = (ts)->lchan; \ |
| 465 | ((lchan - (ts)->lchan) < ARRAY_SIZE((ts)->lchan)) \ |
| 466 | && lchan->fi \ |
| 467 | && lchan->nr < pchan_subslots(as_pchan); \ |
| 468 | lchan++) |
| 469 | |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 470 | /* usage: |
| 471 | * struct gsm_lchan *lchan; |
| 472 | * struct gsm_bts_trx_ts *ts = get_some_timeslot(); |
| 473 | * ts_for_each_lchan(lchan, ts) { |
| 474 | * LOGPLCHAN(DMAIN, LOGL_DEBUG, "hello world\n"); |
| 475 | * } |
| 476 | * Iterate only those lchans that have an FSM allocated. */ |
| 477 | #define ts_for_each_lchan(lchan, ts) ts_as_pchan_for_each_lchan(lchan, ts, (ts)->pchan_is) |
| 478 | |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 479 | enum lchan_activate_mode { |
| 480 | FOR_NONE, |
| 481 | FOR_MS_CHANNEL_REQUEST, |
| 482 | FOR_ASSIGNMENT, |
| 483 | FOR_HANDOVER, |
| 484 | FOR_VTY, |
| 485 | }; |
| 486 | |
| 487 | extern const struct value_string lchan_activate_mode_names[]; |
| 488 | static inline const char *lchan_activate_mode_name(enum lchan_activate_mode activ_for) |
| 489 | { return get_value_string(lchan_activate_mode_names, activ_for); } |
| 490 | |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 491 | struct gsm_lchan { |
| 492 | /* The TS that we're part of */ |
| 493 | struct gsm_bts_trx_ts *ts; |
| 494 | /* The logical subslot number in the TS */ |
| 495 | uint8_t nr; |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 496 | char *name; |
| 497 | |
Neels Hofmeyr | eee24eb | 2018-11-06 21:39:15 +0100 | [diff] [blame] | 498 | char *last_error; |
| 499 | |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 500 | struct osmo_fsm_inst *fi; |
Neels Hofmeyr | ac85b34 | 2018-07-12 21:23:26 +0200 | [diff] [blame] | 501 | struct osmo_fsm_inst *fi_rtp; |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 502 | struct mgwep_ci *mgw_endpoint_ci_bts; |
| 503 | |
| 504 | struct { |
| 505 | enum lchan_activate_mode activ_for; |
Neels Hofmeyr | ac85b34 | 2018-07-12 21:23:26 +0200 | [diff] [blame] | 506 | bool activ_ack; /*< true as soon as RSL Chan Activ Ack is received */ |
Neels Hofmeyr | 369fba2 | 2018-11-27 01:30:50 +0100 | [diff] [blame] | 507 | bool immediate_assignment_sent; |
Neels Hofmeyr | 193c1e3 | 2018-08-27 22:06:24 +0200 | [diff] [blame] | 508 | /*! This flag ensures that when an lchan activation has succeeded, and we have already |
| 509 | * sent ACKs like Immediate Assignment or BSSMAP Assignment Complete, and if other errors |
| 510 | * occur later, e.g. during release, that we don't send a NACK out of context. */ |
| 511 | bool concluded; |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 512 | bool requires_voice_stream; |
Neels Hofmeyr | ac85b34 | 2018-07-12 21:23:26 +0200 | [diff] [blame] | 513 | bool wait_before_switching_rtp; /*< true = requires LCHAN_EV_READY_TO_SWITCH_RTP */ |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 514 | uint16_t msc_assigned_cic; |
| 515 | enum gsm0808_cause gsm0808_error_cause; |
| 516 | struct gsm_lchan *re_use_mgw_endpoint_from_lchan; |
| 517 | } activate; |
| 518 | |
Neels Hofmeyr | eee24eb | 2018-11-06 21:39:15 +0100 | [diff] [blame] | 519 | struct { |
| 520 | /* If an event to release the lchan comes in while still waiting for responses, just mark this |
| 521 | * flag, so that the lchan will gracefully release at the next sensible junction. */ |
| 522 | bool requested; |
| 523 | bool do_rr_release; |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 524 | |
Neels Hofmeyr | eee24eb | 2018-11-06 21:39:15 +0100 | [diff] [blame] | 525 | /* There is an RSL error cause of value 0, so we need a separate flag. */ |
| 526 | bool in_error; |
| 527 | /* RSL error code, RSL_ERR_* */ |
| 528 | uint8_t rsl_error_cause; |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 529 | |
Neels Hofmeyr | eee24eb | 2018-11-06 21:39:15 +0100 | [diff] [blame] | 530 | /* If a release event is being handled, ignore other ricocheting release events until that |
| 531 | * release handling has concluded. */ |
| 532 | bool in_release_handler; |
| 533 | } release; |
Neels Hofmeyr | d5df9a1 | 2018-07-20 05:35:47 +0200 | [diff] [blame] | 534 | |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 535 | /* The logical channel type */ |
| 536 | enum gsm_chan_t type; |
| 537 | /* RSL channel mode */ |
| 538 | enum rsl_cmod_spd rsl_cmode; |
| 539 | /* If TCH, traffic channel mode */ |
| 540 | enum gsm48_chan_mode tch_mode; |
| 541 | enum lchan_csd_mode csd_mode; |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 542 | /* Power levels for MS and BTS */ |
| 543 | uint8_t bs_power; |
| 544 | uint8_t ms_power; |
| 545 | /* Encryption information */ |
| 546 | struct gsm_encr encr; |
| 547 | |
| 548 | /* AMR bits */ |
| 549 | uint8_t mr_ms_lv[7]; |
| 550 | uint8_t mr_bts_lv[7]; |
| 551 | |
| 552 | /* Established data link layer services */ |
| 553 | uint8_t sapis[8]; |
| 554 | |
| 555 | struct { |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 556 | uint32_t bound_ip; /*< where the BTS receives RTP */ |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 557 | uint16_t bound_port; |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 558 | uint32_t connect_ip; /*< where the BTS sends RTP to (MGW) */ |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 559 | uint16_t connect_port; |
| 560 | uint16_t conn_id; |
| 561 | uint8_t rtp_payload; |
| 562 | uint8_t rtp_payload2; |
| 563 | uint8_t speech_mode; |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 564 | |
| 565 | /* info we need to postpone the AoIP |
| 566 | * assignment completed message */ |
| 567 | struct { |
| 568 | uint8_t rr_cause; |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 569 | bool valid; |
| 570 | } ass_compl; |
| 571 | } abis_ip; |
| 572 | |
| 573 | uint8_t rqd_ta; |
| 574 | |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 575 | /* table of neighbor cell measurements */ |
| 576 | struct neigh_meas_proc neigh_meas[MAX_NEIGH_MEAS]; |
| 577 | |
| 578 | /* cache of last measurement reports on this lchan */ |
| 579 | struct gsm_meas_rep meas_rep[MAX_MEAS_REP]; |
| 580 | int meas_rep_idx; |
| 581 | int meas_rep_count; |
Neels Hofmeyr | 35ba85c | 2018-02-12 16:47:40 +0100 | [diff] [blame] | 582 | uint8_t meas_rep_last_seen_nr; |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 583 | |
| 584 | /* GSM Random Access data */ |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 585 | /* TODO: don't allocate this, rather keep an "is_present" flag */ |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 586 | struct gsm48_req_ref *rqd_ref; |
| 587 | |
| 588 | struct gsm_subscriber_connection *conn; |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 589 | }; |
| 590 | |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 591 | /* One Timeslot in a TRX */ |
| 592 | struct gsm_bts_trx_ts { |
| 593 | struct gsm_bts_trx *trx; |
| 594 | /* number of this timeslot at the TRX */ |
| 595 | uint8_t nr; |
| 596 | |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 597 | struct osmo_fsm_inst *fi; |
| 598 | char *last_errmsg; |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 599 | |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 600 | /* vty phys_chan_config setting, not necessarily in effect in case it was changed in the telnet |
| 601 | * vty after OML activation. Gets written on vty 'write file'. */ |
| 602 | enum gsm_phys_chan_config pchan_from_config; |
| 603 | /* When the timeslot OML is established, pchan_from_config is copied here. This is the pchan |
| 604 | * currently in effect; for dynamic ts, this is the dyn kind (GSM_PCHAN_TCH_F_TCH_H_PDCH or |
| 605 | * GSM_PCHAN_TCH_F_PDCH) and does not show the pchan type currently active. */ |
| 606 | enum gsm_phys_chan_config pchan_on_init; |
| 607 | /* This is the *actual* pchan type currently active. For dynamic timeslots, this reflects either |
| 608 | * GSM_PCHAN_NONE or one of the standard GSM_PCHAN_TCH_F, GSM_PCHAN_TCH_H, GSM_PCHAN_PDCH. |
| 609 | * Callers can use this transparently without being aware of dyn ts. */ |
| 610 | enum gsm_phys_chan_config pchan_is; |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 611 | |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 612 | /* After a PDCH ACT NACK, we shall not infinitely loop to try and ACT again. |
| 613 | * Also marks a timeslot where PDCH was deactivated by VTY. This is cleared whenever a timeslot |
| 614 | * enters IN_USE state, i.e. after each TCH use we try to PDCH ACT once again. */ |
| 615 | bool pdch_act_allowed; |
| 616 | |
Neels Hofmeyr | bcdbfb7 | 2018-07-26 20:33:15 +0200 | [diff] [blame] | 617 | /* Whether TS_EV_OML_READY was received */ |
| 618 | bool is_oml_ready; |
| 619 | /* Whether TS_EV_RSL_READY was received */ |
| 620 | bool is_rsl_ready; |
| 621 | |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 622 | struct gsm_abis_mo mo; |
| 623 | struct tlv_parsed nm_attr; |
| 624 | uint8_t nm_chan_comb; |
| 625 | int tsc; /* -1 == use BTS TSC */ |
| 626 | |
| 627 | struct { |
| 628 | /* Parameters below are configured by VTY */ |
| 629 | int enabled; |
| 630 | uint8_t maio; |
| 631 | uint8_t hsn; |
| 632 | struct bitvec arfcns; |
| 633 | uint8_t arfcns_data[1024/8]; |
| 634 | /* This is the pre-computed MA for channel assignments */ |
| 635 | struct bitvec ma; |
| 636 | uint8_t ma_len; /* part of ma_data that is used */ |
| 637 | uint8_t ma_data[8]; /* 10.5.2.21: max 8 bytes value part */ |
| 638 | } hopping; |
| 639 | |
| 640 | /* To which E1 subslot are we connected */ |
| 641 | struct gsm_e1_subslot e1_link; |
| 642 | |
| 643 | union { |
| 644 | struct { |
| 645 | struct om2k_mo om2k_mo; |
| 646 | } rbs2000; |
| 647 | }; |
| 648 | |
| 649 | struct gsm_lchan lchan[TS_MAX_LCHAN]; |
| 650 | }; |
| 651 | |
| 652 | /* One TRX in a BTS */ |
| 653 | struct gsm_bts_trx { |
| 654 | /* list header in bts->trx_list */ |
| 655 | struct llist_head list; |
| 656 | |
| 657 | struct gsm_bts *bts; |
| 658 | /* number of this TRX in the BTS */ |
| 659 | uint8_t nr; |
| 660 | /* human readable name / description */ |
| 661 | char *description; |
| 662 | /* how do we talk RSL with this TRX? */ |
| 663 | struct gsm_e1_subslot rsl_e1_link; |
| 664 | uint8_t rsl_tei; |
| 665 | struct e1inp_sign_link *rsl_link; |
| 666 | |
| 667 | /* Timeout for initiating the RSL connection. */ |
| 668 | struct osmo_timer_list rsl_connect_timeout; |
| 669 | |
| 670 | /* Some BTS (specifically Ericsson RBS) have a per-TRX OML Link */ |
| 671 | struct e1inp_sign_link *oml_link; |
| 672 | |
| 673 | struct gsm_abis_mo mo; |
| 674 | struct tlv_parsed nm_attr; |
| 675 | struct { |
| 676 | struct gsm_abis_mo mo; |
| 677 | } bb_transc; |
| 678 | |
| 679 | uint16_t arfcn; |
| 680 | int nominal_power; /* in dBm */ |
| 681 | unsigned int max_power_red; /* in actual dB */ |
| 682 | |
| 683 | union { |
| 684 | struct { |
| 685 | struct { |
| 686 | struct gsm_abis_mo mo; |
| 687 | } bbsig; |
| 688 | struct { |
| 689 | struct gsm_abis_mo mo; |
| 690 | } pa; |
| 691 | } bs11; |
| 692 | struct { |
| 693 | unsigned int test_state; |
| 694 | uint8_t test_nr; |
| 695 | struct rxlev_stats rxlev_stat; |
| 696 | } ipaccess; |
| 697 | struct { |
| 698 | struct { |
| 699 | struct om2k_mo om2k_mo; |
| 700 | } trxc; |
| 701 | struct { |
| 702 | struct om2k_mo om2k_mo; |
| 703 | } rx; |
| 704 | struct { |
| 705 | struct om2k_mo om2k_mo; |
| 706 | } tx; |
| 707 | } rbs2000; |
| 708 | }; |
| 709 | struct gsm_bts_trx_ts ts[TRX_NR_TS]; |
| 710 | }; |
| 711 | |
| 712 | #define GSM_BTS_SI2Q(bts, i) (struct gsm48_system_information_type_2quater *)((bts)->si_buf[SYSINFO_TYPE_2quater][i]) |
| 713 | #define GSM_BTS_HAS_SI(bts, i) ((bts)->si_valid & (1 << i)) |
| 714 | #define GSM_BTS_SI(bts, i) (void *)((bts)->si_buf[i][0]) |
| 715 | #define GSM_LCHAN_SI(lchan, i) (void *)((lchan)->si.buf[i][0]) |
| 716 | |
| 717 | enum gsm_bts_type { |
| 718 | GSM_BTS_TYPE_UNKNOWN, |
| 719 | GSM_BTS_TYPE_BS11, |
| 720 | GSM_BTS_TYPE_NANOBTS, |
| 721 | GSM_BTS_TYPE_RBS2000, |
| 722 | GSM_BTS_TYPE_NOKIA_SITE, |
| 723 | GSM_BTS_TYPE_OSMOBTS, |
| 724 | _NUM_GSM_BTS_TYPE |
| 725 | }; |
| 726 | |
| 727 | enum gsm_bts_type_variant { |
| 728 | BTS_UNKNOWN, |
| 729 | BTS_OSMO_LITECELL15, |
| 730 | BTS_OSMO_OCTPHY, |
| 731 | BTS_OSMO_SYSMO, |
| 732 | BTS_OSMO_TRX, |
| 733 | _NUM_BTS_VARIANT |
| 734 | }; |
| 735 | |
| 736 | /* Used by OML layer for BTS Attribute reporting */ |
| 737 | enum bts_attribute { |
| 738 | BTS_TYPE_VARIANT, |
| 739 | BTS_SUB_MODEL, |
| 740 | TRX_PHY_VERSION, |
| 741 | }; |
| 742 | |
| 743 | struct vty; |
| 744 | |
| 745 | struct gsm_bts_model { |
| 746 | struct llist_head list; |
| 747 | |
| 748 | enum gsm_bts_type type; |
| 749 | enum gsm_bts_type_variant variant; |
| 750 | const char *name; |
| 751 | |
| 752 | bool started; |
| 753 | int (*start)(struct gsm_network *net); |
| 754 | int (*oml_rcvmsg)(struct msgb *msg); |
| 755 | char * (*oml_status)(const struct gsm_bts *bts); |
| 756 | |
| 757 | void (*e1line_bind_ops)(struct e1inp_line *line); |
| 758 | |
| 759 | void (*config_write_bts)(struct vty *vty, struct gsm_bts *bts); |
| 760 | void (*config_write_trx)(struct vty *vty, struct gsm_bts_trx *trx); |
| 761 | void (*config_write_ts)(struct vty *vty, struct gsm_bts_trx_ts *ts); |
| 762 | |
Pau Espin Pedrol | 167cb82 | 2018-11-19 17:48:17 +0100 | [diff] [blame] | 763 | /* Should SI2bis and SI2ter be disabled by default on this BTS model? */ |
| 764 | bool force_combined_si; |
| 765 | |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 766 | struct tlv_definition nm_att_tlvdef; |
| 767 | |
| 768 | /* features of a given BTS model set via gsm_bts_model_register() locally */ |
| 769 | struct bitvec features; |
| 770 | uint8_t _features_data[MAX_BTS_FEATURES/8]; |
| 771 | }; |
| 772 | |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 773 | |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 774 | |
| 775 | /* |
| 776 | * This keeps track of the paging status of one BTS. It |
| 777 | * includes a number of pending requests, a back pointer |
| 778 | * to the gsm_bts, a timer and some more state. |
| 779 | */ |
| 780 | struct gsm_bts_paging_state { |
| 781 | /* pending requests */ |
| 782 | struct llist_head pending_requests; |
| 783 | struct gsm_bts *bts; |
| 784 | |
| 785 | struct osmo_timer_list work_timer; |
| 786 | struct osmo_timer_list credit_timer; |
| 787 | |
| 788 | /* free chans needed */ |
| 789 | int free_chans_need; |
| 790 | |
| 791 | /* load */ |
| 792 | uint16_t available_slots; |
| 793 | }; |
| 794 | |
| 795 | struct gsm_envabtse { |
| 796 | struct gsm_abis_mo mo; |
| 797 | }; |
| 798 | |
| 799 | struct gsm_bts_gprs_nsvc { |
| 800 | struct gsm_bts *bts; |
| 801 | /* data read via VTY config file, to configure the BTS |
| 802 | * via OML from BSC */ |
| 803 | int id; |
| 804 | uint16_t nsvci; |
| 805 | uint16_t local_port; /* on the BTS */ |
| 806 | uint16_t remote_port; /* on the SGSN */ |
| 807 | uint32_t remote_ip; /* on the SGSN */ |
| 808 | |
| 809 | struct gsm_abis_mo mo; |
| 810 | }; |
| 811 | |
| 812 | enum gprs_rlc_par { |
| 813 | RLC_T3142, |
| 814 | RLC_T3169, |
| 815 | RLC_T3191, |
| 816 | RLC_T3193, |
| 817 | RLC_T3195, |
| 818 | RLC_N3101, |
| 819 | RLC_N3103, |
| 820 | RLC_N3105, |
| 821 | CV_COUNTDOWN, |
| 822 | T_DL_TBF_EXT, /* ms */ |
| 823 | T_UL_TBF_EXT, /* ms */ |
| 824 | _NUM_RLC_PAR |
| 825 | }; |
| 826 | |
| 827 | enum gprs_cs { |
| 828 | GPRS_CS1, |
| 829 | GPRS_CS2, |
| 830 | GPRS_CS3, |
| 831 | GPRS_CS4, |
| 832 | GPRS_MCS1, |
| 833 | GPRS_MCS2, |
| 834 | GPRS_MCS3, |
| 835 | GPRS_MCS4, |
| 836 | GPRS_MCS5, |
| 837 | GPRS_MCS6, |
| 838 | GPRS_MCS7, |
| 839 | GPRS_MCS8, |
| 840 | GPRS_MCS9, |
| 841 | _NUM_GRPS_CS |
| 842 | }; |
| 843 | |
| 844 | struct gprs_rlc_cfg { |
| 845 | uint16_t parameter[_NUM_RLC_PAR]; |
| 846 | struct { |
| 847 | uint16_t repeat_time; /* ms */ |
| 848 | uint8_t repeat_count; |
| 849 | } paging; |
| 850 | uint32_t cs_mask; /* bitmask of gprs_cs */ |
| 851 | uint8_t initial_cs; |
| 852 | uint8_t initial_mcs; |
| 853 | }; |
| 854 | |
| 855 | |
| 856 | enum neigh_list_manual_mode { |
| 857 | NL_MODE_AUTOMATIC = 0, |
| 858 | NL_MODE_MANUAL = 1, |
| 859 | NL_MODE_MANUAL_SI5SEP = 2, /* SI2 and SI5 have separate neighbor lists */ |
| 860 | }; |
| 861 | |
| 862 | enum bts_loc_fix { |
| 863 | BTS_LOC_FIX_INVALID = 0, |
| 864 | BTS_LOC_FIX_2D = 1, |
| 865 | BTS_LOC_FIX_3D = 2, |
| 866 | }; |
| 867 | |
| 868 | extern const struct value_string bts_loc_fix_names[]; |
| 869 | |
| 870 | struct bts_location { |
| 871 | struct llist_head list; |
| 872 | time_t tstamp; |
| 873 | enum bts_loc_fix valid; |
| 874 | double lat; |
| 875 | double lon; |
| 876 | double height; |
| 877 | }; |
| 878 | |
| 879 | /* Channel load counter */ |
| 880 | struct load_counter { |
| 881 | unsigned int total; |
| 882 | unsigned int used; |
| 883 | }; |
| 884 | |
Neels Hofmeyr | 19bed23 | 2018-03-22 04:54:57 +0100 | [diff] [blame] | 885 | /* Useful to track N-N relations between BTS, for example neighbors. */ |
| 886 | struct gsm_bts_ref { |
| 887 | struct llist_head entry; |
| 888 | struct gsm_bts *bts; |
| 889 | }; |
| 890 | |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 891 | /* One BTS */ |
| 892 | struct gsm_bts { |
| 893 | /* list header in net->bts_list */ |
| 894 | struct llist_head list; |
| 895 | |
| 896 | /* Geographical location of the BTS */ |
| 897 | struct llist_head loc_list; |
| 898 | |
| 899 | /* number of ths BTS in network */ |
| 900 | uint8_t nr; |
| 901 | /* human readable name / description */ |
| 902 | char *description; |
| 903 | /* Cell Identity */ |
| 904 | uint16_t cell_identity; |
| 905 | /* location area code of this BTS */ |
| 906 | uint16_t location_area_code; |
| 907 | /* Base Station Identification Code (BSIC), lower 3 bits is BCC, |
| 908 | * which is used as TSC for the CCCH */ |
| 909 | uint8_t bsic; |
| 910 | /* type of BTS */ |
| 911 | enum gsm_bts_type type; |
| 912 | enum gsm_bts_type_variant variant; |
| 913 | struct gsm_bts_model *model; |
| 914 | enum gsm_band band; |
| 915 | char version[MAX_VERSION_LENGTH]; |
| 916 | char sub_model[MAX_VERSION_LENGTH]; |
| 917 | |
| 918 | /* features of a given BTS set/reported via OML */ |
| 919 | struct bitvec features; |
| 920 | uint8_t _features_data[MAX_BTS_FEATURES/8]; |
| 921 | |
| 922 | /* Connected PCU version (if any) */ |
| 923 | char pcu_version[MAX_VERSION_LENGTH]; |
| 924 | |
| 925 | /* maximum Tx power that the MS is permitted to use in this cell */ |
| 926 | int ms_max_power; |
| 927 | |
| 928 | /* how do we talk OML with this TRX? */ |
| 929 | struct gsm_e1_subslot oml_e1_link; |
| 930 | uint8_t oml_tei; |
| 931 | struct e1inp_sign_link *oml_link; |
Pau Espin Pedrol | 9862bcb | 2018-08-22 21:54:12 +0200 | [diff] [blame] | 932 | /* Timer to use for deferred drop of OML link, see \ref ipaccess_drop_oml_deferred */ |
| 933 | struct osmo_timer_list oml_drop_link_timer; |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 934 | /* when OML link was established */ |
| 935 | time_t uptime; |
| 936 | |
| 937 | /* Abis network management O&M handle */ |
| 938 | struct abis_nm_h *nmh; |
| 939 | |
| 940 | struct gsm_abis_mo mo; |
| 941 | |
| 942 | /* number of this BTS on given E1 link */ |
| 943 | uint8_t bts_nr; |
| 944 | |
| 945 | /* DTX features of this BTS */ |
| 946 | enum gsm48_dtx_mode dtxu; |
| 947 | bool dtxd; |
| 948 | |
| 949 | /* paging state and control */ |
| 950 | struct gsm_bts_paging_state paging; |
| 951 | |
| 952 | /* CCCH is on C0 */ |
| 953 | struct gsm_bts_trx *c0; |
| 954 | |
| 955 | struct { |
| 956 | struct gsm_abis_mo mo; |
| 957 | } site_mgr; |
| 958 | |
| 959 | /* bitmask of all SI that are present/valid in si_buf */ |
| 960 | uint32_t si_valid; |
| 961 | /* 3GPP TS 44.018 Table 10.5.2.33b.1 INDEX and COUNT for SI2quater */ |
| 962 | uint8_t si2q_index; /* distinguish individual SI2quater messages */ |
| 963 | uint8_t si2q_count; /* si2q_index for the last (highest indexed) individual SI2quater message */ |
| 964 | /* buffers where we put the pre-computed SI */ |
| 965 | sysinfo_buf_t si_buf[_MAX_SYSINFO_TYPE][SI2Q_MAX_NUM]; |
| 966 | /* offsets used while generating SI2quater */ |
| 967 | size_t e_offset; |
| 968 | size_t u_offset; |
| 969 | |
| 970 | /* ip.accesss Unit ID's have Site/BTS/TRX layout */ |
| 971 | union { |
| 972 | struct { |
| 973 | uint16_t site_id; |
| 974 | uint16_t bts_id; |
| 975 | uint32_t flags; |
| 976 | uint32_t rsl_ip; |
| 977 | } ip_access; |
| 978 | struct { |
| 979 | struct { |
| 980 | struct gsm_abis_mo mo; |
| 981 | } cclk; |
| 982 | struct { |
| 983 | struct gsm_abis_mo mo; |
| 984 | } rack; |
| 985 | struct gsm_envabtse envabtse[4]; |
| 986 | } bs11; |
| 987 | struct { |
| 988 | struct { |
| 989 | struct om2k_mo om2k_mo; |
| 990 | struct gsm_abis_mo mo; |
| 991 | struct llist_head conn_groups; |
| 992 | } cf; |
| 993 | struct { |
| 994 | struct om2k_mo om2k_mo; |
| 995 | struct gsm_abis_mo mo; |
| 996 | struct llist_head conn_groups; |
| 997 | } is; |
| 998 | struct { |
| 999 | struct om2k_mo om2k_mo; |
| 1000 | struct gsm_abis_mo mo; |
| 1001 | struct llist_head conn_groups; |
| 1002 | } con; |
| 1003 | struct { |
| 1004 | struct om2k_mo om2k_mo; |
| 1005 | struct gsm_abis_mo mo; |
| 1006 | } dp; |
| 1007 | struct { |
| 1008 | struct om2k_mo om2k_mo; |
| 1009 | struct gsm_abis_mo mo; |
| 1010 | } tf; |
| 1011 | uint32_t use_superchannel:1; |
| 1012 | } rbs2000; |
| 1013 | struct { |
| 1014 | uint8_t bts_type; |
| 1015 | unsigned int configured:1, |
| 1016 | skip_reset:1, |
| 1017 | no_loc_rel_cnf:1, |
| 1018 | bts_reset_timer_cnf, |
| 1019 | did_reset:1, |
| 1020 | wait_reset:1; |
| 1021 | struct osmo_timer_list reset_timer; |
| 1022 | } nokia; |
| 1023 | }; |
| 1024 | |
| 1025 | /* Not entirely sure how ip.access specific this is */ |
| 1026 | struct { |
| 1027 | uint8_t supports_egprs_11bit_rach; |
| 1028 | enum bts_gprs_mode mode; |
| 1029 | struct { |
| 1030 | struct gsm_abis_mo mo; |
| 1031 | uint16_t nsei; |
| 1032 | uint8_t timer[7]; |
| 1033 | } nse; |
| 1034 | struct { |
| 1035 | struct gsm_abis_mo mo; |
| 1036 | uint16_t bvci; |
| 1037 | uint8_t timer[11]; |
| 1038 | struct gprs_rlc_cfg rlc_cfg; |
| 1039 | } cell; |
| 1040 | struct gsm_bts_gprs_nsvc nsvc[2]; |
| 1041 | uint8_t rac; |
| 1042 | uint8_t net_ctrl_ord; |
| 1043 | bool ctrl_ack_type_use_block; |
| 1044 | } gprs; |
| 1045 | |
| 1046 | /* RACH NM values */ |
| 1047 | int rach_b_thresh; |
| 1048 | int rach_ldavg_slots; |
| 1049 | |
| 1050 | /* transceivers */ |
| 1051 | int num_trx; |
| 1052 | struct llist_head trx_list; |
| 1053 | |
| 1054 | /* SI related items */ |
| 1055 | int force_combined_si; |
Pau Espin Pedrol | 167cb82 | 2018-11-19 17:48:17 +0100 | [diff] [blame] | 1056 | bool force_combined_si_set; |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 1057 | int bcch_change_mark; |
| 1058 | |
| 1059 | /* Abis NM queue */ |
| 1060 | struct llist_head abis_queue; |
| 1061 | int abis_nm_pend; |
| 1062 | |
| 1063 | struct gsm_network *network; |
| 1064 | |
| 1065 | /* should the channel allocator allocate channels from high TRX to TRX0, |
| 1066 | * rather than starting from TRX0 and go upwards? */ |
| 1067 | int chan_alloc_reverse; |
| 1068 | |
| 1069 | enum neigh_list_manual_mode neigh_list_manual_mode; |
| 1070 | /* parameters from which we build SYSTEM INFORMATION */ |
| 1071 | struct { |
| 1072 | struct gsm48_rach_control rach_control; |
| 1073 | uint8_t ncc_permitted; |
| 1074 | struct gsm48_cell_sel_par cell_sel_par; |
| 1075 | struct gsm48_si_selection_params cell_ro_sel_par; /* rest octet */ |
| 1076 | struct gsm48_cell_options cell_options; |
| 1077 | struct gsm48_control_channel_descr chan_desc; |
| 1078 | struct bitvec neigh_list; |
| 1079 | struct bitvec cell_alloc; |
| 1080 | struct bitvec si5_neigh_list; |
| 1081 | struct osmo_earfcn_si2q si2quater_neigh_list; |
| 1082 | size_t uarfcn_length; /* index for uarfcn and scramble lists */ |
| 1083 | struct { |
| 1084 | /* bitmask large enough for all possible ARFCN's */ |
| 1085 | uint8_t neigh_list[1024/8]; |
| 1086 | uint8_t cell_alloc[1024/8]; |
| 1087 | /* If the user wants a different neighbor list in SI5 than in SI2 */ |
| 1088 | uint8_t si5_neigh_list[1024/8]; |
| 1089 | uint8_t meas_bw_list[MAX_EARFCN_LIST]; |
| 1090 | uint16_t earfcn_list[MAX_EARFCN_LIST]; |
| 1091 | uint16_t uarfcn_list[MAX_EARFCN_LIST]; |
| 1092 | uint16_t scramble_list[MAX_EARFCN_LIST]; |
| 1093 | } data; |
| 1094 | } si_common; |
| 1095 | bool early_classmark_allowed; |
| 1096 | bool early_classmark_allowed_3g; |
| 1097 | /* for testing only: Have an infinitely long radio link timeout */ |
| 1098 | bool infinite_radio_link_timeout; |
| 1099 | |
| 1100 | /* do we use static (user-defined) system information messages? (bitmask) */ |
| 1101 | uint32_t si_mode_static; |
| 1102 | |
Stefan Sperling | 6442e43 | 2018-02-06 14:44:54 +0100 | [diff] [blame] | 1103 | /* access control class ramping */ |
| 1104 | struct acc_ramp acc_ramp; |
| 1105 | |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 1106 | /* exclude the BTS from the global RF Lock handling */ |
| 1107 | int excl_from_rf_lock; |
| 1108 | |
| 1109 | /* supported codecs beside FR */ |
| 1110 | struct bts_codec_conf codec; |
| 1111 | |
| 1112 | /* BTS dependencies bit field */ |
| 1113 | uint32_t depends_on[256/(8*4)]; |
| 1114 | |
| 1115 | /* full and half rate multirate config */ |
| 1116 | struct amr_multirate_conf mr_full; |
| 1117 | struct amr_multirate_conf mr_half; |
| 1118 | |
| 1119 | /* PCU socket state */ |
| 1120 | char *pcu_sock_path; |
| 1121 | struct pcu_sock_state *pcu_state; |
| 1122 | |
| 1123 | struct rate_ctr_group *bts_ctrs; |
| 1124 | struct osmo_stat_item_group *bts_statg; |
| 1125 | |
| 1126 | struct handover_cfg *ho; |
| 1127 | |
Neels Hofmeyr | 19bed23 | 2018-03-22 04:54:57 +0100 | [diff] [blame] | 1128 | /* A list of struct gsm_bts_ref, indicating neighbors of this BTS. |
| 1129 | * When the si_common neigh_list is in automatic mode, it is populated from this list as well as |
| 1130 | * gsm_network->neighbor_bss_cells. */ |
| 1131 | struct llist_head local_neighbors; |
| 1132 | |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 1133 | /* BTS-specific overrides for timer values from struct gsm_network. */ |
| 1134 | uint8_t T3122; /* ASSIGMENT REJECT wait indication */ |
| 1135 | |
| 1136 | /* Periodic channel load measurements are used to maintain T3122. */ |
| 1137 | struct load_counter chan_load_samples[7]; |
| 1138 | int chan_load_samples_idx; |
Stefan Sperling | 6442e43 | 2018-02-06 14:44:54 +0100 | [diff] [blame] | 1139 | uint8_t chan_load_avg; /* current channel load average in percent (0 - 100). */ |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 1140 | }; |
| 1141 | |
Oliver Smith | 8d8d710 | 2018-10-23 15:35:43 +0200 | [diff] [blame] | 1142 | /* One rejected BTS */ |
| 1143 | struct gsm_bts_rejected { |
| 1144 | /* list header in net->bts_rejected */ |
| 1145 | struct llist_head list; |
| 1146 | |
| 1147 | uint16_t site_id; |
| 1148 | uint16_t bts_id; |
| 1149 | char ip[INET6_ADDRSTRLEN]; |
| 1150 | time_t time; |
| 1151 | }; |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 1152 | |
Neels Hofmeyr | 958f259 | 2018-05-27 01:26:31 +0200 | [diff] [blame] | 1153 | struct gsm_network *gsm_network_init(void *ctx); |
| 1154 | |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 1155 | struct gsm_bts *gsm_bts_alloc(struct gsm_network *net, uint8_t bts_num); |
Neels Hofmeyr | 6d568ed | 2018-07-09 16:49:18 +0200 | [diff] [blame] | 1156 | struct gsm_bts *gsm_bts_num(const struct gsm_network *net, int num); |
Neels Hofmeyr | 19bed23 | 2018-03-22 04:54:57 +0100 | [diff] [blame] | 1157 | bool gsm_bts_matches_lai(const struct gsm_bts *bts, const struct osmo_location_area_id *lai); |
| 1158 | bool gsm_bts_matches_cell_id(const struct gsm_bts *bts, const struct gsm0808_cell_id *cell_id); |
| 1159 | struct gsm_bts *gsm_bts_by_cell_id(const struct gsm_network *net, |
| 1160 | const struct gsm0808_cell_id *cell_id, |
| 1161 | int match_idx); |
| 1162 | int gsm_bts_local_neighbor_add(struct gsm_bts *bts, struct gsm_bts *neighbor); |
| 1163 | int gsm_bts_local_neighbor_del(struct gsm_bts *bts, const struct gsm_bts *neighbor); |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 1164 | |
| 1165 | struct gsm_bts_trx *gsm_bts_trx_alloc(struct gsm_bts *bts); |
| 1166 | struct gsm_bts_trx *gsm_bts_trx_num(const struct gsm_bts *bts, int num); |
| 1167 | |
| 1168 | enum gsm_bts_type str2btstype(const char *arg); |
| 1169 | const char *btstype2str(enum gsm_bts_type type); |
| 1170 | |
| 1171 | enum bts_attribute str2btsattr(const char *s); |
| 1172 | const char *btsatttr2str(enum bts_attribute v); |
| 1173 | |
| 1174 | enum gsm_bts_type_variant str2btsvariant(const char *arg); |
| 1175 | const char *btsvariant2str(enum gsm_bts_type_variant v); |
| 1176 | |
| 1177 | extern const struct value_string gsm_chreq_descs[]; |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 1178 | extern const struct value_string gsm_pchant_names[]; |
| 1179 | extern const struct value_string gsm_pchant_descs[]; |
| 1180 | extern const struct value_string gsm_pchan_ids[]; |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 1181 | const char *gsm_pchan_name(enum gsm_phys_chan_config c); |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 1182 | static inline const char *gsm_pchan_id(enum gsm_phys_chan_config c) |
| 1183 | { return get_value_string(gsm_pchan_ids, c); } |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 1184 | enum gsm_phys_chan_config gsm_pchan_parse(const char *name); |
| 1185 | const char *gsm_lchant_name(enum gsm_chan_t c); |
| 1186 | const char *gsm_chreq_name(enum gsm_chreq_reason_t c); |
| 1187 | char *gsm_trx_name(const struct gsm_bts_trx *trx); |
| 1188 | char *gsm_ts_name(const struct gsm_bts_trx_ts *ts); |
| 1189 | char *gsm_ts_and_pchan_name(const struct gsm_bts_trx_ts *ts); |
| 1190 | char *gsm_lchan_name_compute(const struct gsm_lchan *lchan); |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 1191 | |
| 1192 | static inline char *gsm_lchan_name(const struct gsm_lchan *lchan) |
| 1193 | { |
| 1194 | return lchan->name; |
| 1195 | } |
| 1196 | |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 1197 | void gsm_abis_mo_reset(struct gsm_abis_mo *mo); |
| 1198 | |
| 1199 | struct gsm_nm_state * |
| 1200 | gsm_objclass2nmstate(struct gsm_bts *bts, uint8_t obj_class, |
| 1201 | const struct abis_om_obj_inst *obj_inst); |
| 1202 | void * |
| 1203 | gsm_objclass2obj(struct gsm_bts *bts, uint8_t obj_class, |
| 1204 | const struct abis_om_obj_inst *obj_inst); |
| 1205 | |
| 1206 | /* reset the state of all MO in the BTS */ |
| 1207 | void gsm_bts_mo_reset(struct gsm_bts *bts); |
| 1208 | |
| 1209 | uint8_t gsm_pchan2chan_nr(enum gsm_phys_chan_config pchan, |
| 1210 | uint8_t ts_nr, uint8_t lchan_nr); |
| 1211 | uint8_t gsm_lchan2chan_nr(const struct gsm_lchan *lchan); |
| 1212 | uint8_t gsm_lchan_as_pchan2chan_nr(const struct gsm_lchan *lchan, |
| 1213 | enum gsm_phys_chan_config as_pchan); |
| 1214 | |
Harald Welte | 251bec1 | 2018-09-09 17:14:09 +0200 | [diff] [blame] | 1215 | void gsm48_lchan2chan_desc(struct gsm48_chan_desc *cd, |
| 1216 | const struct gsm_lchan *lchan); |
Harald Welte | 24286f3 | 2018-09-09 17:17:44 +0200 | [diff] [blame] | 1217 | void gsm48_lchan2chan_desc_as_configured(struct gsm48_chan_desc *cd, const struct gsm_lchan *lchan); |
Harald Welte | 251bec1 | 2018-09-09 17:14:09 +0200 | [diff] [blame] | 1218 | |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 1219 | /* return the gsm_lchan for the CBCH (if it exists at all) */ |
| 1220 | struct gsm_lchan *gsm_bts_get_cbch(struct gsm_bts *bts); |
| 1221 | |
| 1222 | /* |
| 1223 | * help with parsing regexps |
| 1224 | */ |
| 1225 | int gsm_parse_reg(void *ctx, regex_t *reg, char **str, |
| 1226 | int argc, const char **argv) __attribute__ ((warn_unused_result)); |
| 1227 | |
| 1228 | static inline uint8_t gsm_ts_tsc(const struct gsm_bts_trx_ts *ts) |
| 1229 | { |
| 1230 | if (ts->tsc != -1) |
| 1231 | return ts->tsc; |
| 1232 | else |
| 1233 | return ts->trx->bts->bsic & 7; |
| 1234 | } |
| 1235 | |
| 1236 | struct gsm_lchan *rsl_lchan_lookup(struct gsm_bts_trx *trx, uint8_t chan_nr, |
| 1237 | int *rc); |
| 1238 | |
| 1239 | enum gsm_phys_chan_config ts_pchan(struct gsm_bts_trx_ts *ts); |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 1240 | uint8_t pchan_subslots(enum gsm_phys_chan_config pchan); |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 1241 | bool ts_is_tch(struct gsm_bts_trx_ts *ts); |
| 1242 | |
Holger Hans Peter Freyther | 68884aa | 2010-03-23 06:41:45 +0100 | [diff] [blame] | 1243 | |
Harald Welte | b794887 | 2017-12-18 18:48:21 +0100 | [diff] [blame] | 1244 | static inline struct gsm_bts *conn_get_bts(struct gsm_subscriber_connection *conn) { |
| 1245 | OSMO_ASSERT(conn->lchan); |
| 1246 | return conn->lchan->ts->trx->bts; |
| 1247 | } |
| 1248 | |
Harald Welte | d82101e | 2017-12-09 23:07:38 +0100 | [diff] [blame] | 1249 | enum { |
| 1250 | BTS_CTR_CHREQ_TOTAL, |
| 1251 | BTS_CTR_CHREQ_NO_CHANNEL, |
| 1252 | BTS_CTR_CHAN_RF_FAIL, |
| 1253 | BTS_CTR_CHAN_RLL_ERR, |
| 1254 | BTS_CTR_BTS_OML_FAIL, |
| 1255 | BTS_CTR_BTS_RSL_FAIL, |
| 1256 | BTS_CTR_CODEC_AMR_F, |
| 1257 | BTS_CTR_CODEC_AMR_H, |
| 1258 | BTS_CTR_CODEC_EFR, |
| 1259 | BTS_CTR_CODEC_V1_FR, |
| 1260 | BTS_CTR_CODEC_V1_HR, |
Harald Welte | cf9d431 | 2017-12-13 23:17:16 +0100 | [diff] [blame] | 1261 | BTS_CTR_PAGING_ATTEMPTED, |
| 1262 | BTS_CTR_PAGING_ALREADY, |
| 1263 | BTS_CTR_PAGING_RESPONDED, |
| 1264 | BTS_CTR_PAGING_EXPIRED, |
Harald Welte | 4f59892 | 2017-12-14 13:47:02 +0100 | [diff] [blame] | 1265 | BTS_CTR_CHAN_ACT_TOTAL, |
| 1266 | BTS_CTR_CHAN_ACT_NACK, |
Harald Welte | 62d9cb0 | 2017-12-14 14:00:26 +0100 | [diff] [blame] | 1267 | BTS_CTR_RSL_UNKNOWN, |
Harald Welte | 581398a | 2017-12-14 14:29:44 +0100 | [diff] [blame] | 1268 | BTS_CTR_RSL_IPA_NACK, |
Harald Welte | 00d64fd | 2017-12-14 14:34:16 +0100 | [diff] [blame] | 1269 | BTS_CTR_MODE_MODIFY_NACK, |
Harald Welte | d82101e | 2017-12-09 23:07:38 +0100 | [diff] [blame] | 1270 | }; |
| 1271 | |
| 1272 | static const struct rate_ctr_desc bts_ctr_description[] = { |
Harald Welte | 1ef46d9 | 2017-12-09 23:10:46 +0100 | [diff] [blame] | 1273 | [BTS_CTR_CHREQ_TOTAL] = {"chreq:total", "Received channel requests."}, |
| 1274 | [BTS_CTR_CHREQ_NO_CHANNEL] = {"chreq:no_channel", "Sent to MS no channel available."}, |
| 1275 | [BTS_CTR_CHAN_RF_FAIL] = {"chan:rf_fail", "Received a RF failure indication from BTS."}, |
| 1276 | [BTS_CTR_CHAN_RLL_ERR] = {"chan:rll_err", "Received a RLL failure with T200 cause from BTS."}, |
Harald Welte | d82101e | 2017-12-09 23:07:38 +0100 | [diff] [blame] | 1277 | [BTS_CTR_BTS_OML_FAIL] = {"oml_fail", "Received a TEI down on a OML link."}, |
| 1278 | [BTS_CTR_BTS_RSL_FAIL] = {"rsl_fail", "Received a TEI down on a OML link."}, |
Harald Welte | 1ef46d9 | 2017-12-09 23:10:46 +0100 | [diff] [blame] | 1279 | [BTS_CTR_CODEC_AMR_F] = {"codec:amr_f", "Count the usage of AMR/F codec by channel mode requested."}, |
| 1280 | [BTS_CTR_CODEC_AMR_H] = {"codec:amr_h", "Count the usage of AMR/H codec by channel mode requested."}, |
| 1281 | [BTS_CTR_CODEC_EFR] = {"codec:efr", "Count the usage of EFR codec by channel mode requested."}, |
| 1282 | [BTS_CTR_CODEC_V1_FR] = {"codec:fr", "Count the usage of FR codec by channel mode requested."}, |
| 1283 | [BTS_CTR_CODEC_V1_HR] = {"codec:hr", "Count the usage of HR codec by channel mode requested."}, |
Harald Welte | cf9d431 | 2017-12-13 23:17:16 +0100 | [diff] [blame] | 1284 | |
| 1285 | [BTS_CTR_PAGING_ATTEMPTED] = {"paging:attempted", "Paging attempts for a subscriber."}, |
| 1286 | [BTS_CTR_PAGING_ALREADY] = {"paging:already", "Paging attempts ignored as subsciber was already being paged."}, |
| 1287 | [BTS_CTR_PAGING_RESPONDED] = {"paging:responded", "Paging attempts with successful paging response."}, |
| 1288 | [BTS_CTR_PAGING_EXPIRED] = {"paging:expired", "Paging Request expired because of timeout T3113."}, |
Harald Welte | 4f59892 | 2017-12-14 13:47:02 +0100 | [diff] [blame] | 1289 | [BTS_CTR_CHAN_ACT_TOTAL] = {"chan_act:total", "Total number of Channel Activations."}, |
| 1290 | [BTS_CTR_CHAN_ACT_NACK] = {"chan_act:nack", "Number of Channel Activations that the BTS NACKed"}, |
Harald Welte | 62d9cb0 | 2017-12-14 14:00:26 +0100 | [diff] [blame] | 1291 | [BTS_CTR_RSL_UNKNOWN] = {"rsl:unknown", "Number of unknown/unsupported RSL messages received from BTS"}, |
Harald Welte | 581398a | 2017-12-14 14:29:44 +0100 | [diff] [blame] | 1292 | [BTS_CTR_RSL_IPA_NACK] = {"rsl:ipa_nack", "Number of IPA (RTP/dyn-PDCH) related NACKs received from BTS"}, |
Harald Welte | 00d64fd | 2017-12-14 14:34:16 +0100 | [diff] [blame] | 1293 | [BTS_CTR_MODE_MODIFY_NACK] = {"chan:mode_modify_nack", "Number of Channel Mode Modify NACKs received from BTS"}, |
Harald Welte | d82101e | 2017-12-09 23:07:38 +0100 | [diff] [blame] | 1294 | }; |
| 1295 | |
| 1296 | static const struct rate_ctr_group_desc bts_ctrg_desc = { |
| 1297 | "bts", |
| 1298 | "base transceiver station", |
| 1299 | OSMO_STATS_CLASS_GLOBAL, |
| 1300 | ARRAY_SIZE(bts_ctr_description), |
| 1301 | bts_ctr_description, |
| 1302 | }; |
Holger Hans Peter Freyther | 5ba6f48 | 2009-10-28 14:23:39 +0100 | [diff] [blame] | 1303 | |
Alexander Couzens | 20423ea | 2016-07-12 15:42:02 +0200 | [diff] [blame] | 1304 | enum { |
Stefan Sperling | 81dc9e7 | 2018-02-05 17:34:36 +0100 | [diff] [blame] | 1305 | BTS_STAT_CHAN_LOAD_AVERAGE, |
| 1306 | BTS_STAT_T3122, |
| 1307 | }; |
| 1308 | |
| 1309 | enum { |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 1310 | BSC_CTR_ASSIGNMENT_ATTEMPTED, |
| 1311 | BSC_CTR_ASSIGNMENT_COMPLETED, |
| 1312 | BSC_CTR_ASSIGNMENT_STOPPED, |
| 1313 | BSC_CTR_ASSIGNMENT_NO_CHANNEL, |
| 1314 | BSC_CTR_ASSIGNMENT_TIMEOUT, |
| 1315 | BSC_CTR_ASSIGNMENT_FAILED, |
| 1316 | BSC_CTR_ASSIGNMENT_ERROR, |
Alexander Couzens | b847a21 | 2016-08-02 11:34:11 +0200 | [diff] [blame] | 1317 | BSC_CTR_HANDOVER_ATTEMPTED, |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 1318 | BSC_CTR_HANDOVER_COMPLETED, |
| 1319 | BSC_CTR_HANDOVER_STOPPED, |
Alexander Couzens | b847a21 | 2016-08-02 11:34:11 +0200 | [diff] [blame] | 1320 | BSC_CTR_HANDOVER_NO_CHANNEL, |
| 1321 | BSC_CTR_HANDOVER_TIMEOUT, |
Alexander Couzens | b847a21 | 2016-08-02 11:34:11 +0200 | [diff] [blame] | 1322 | BSC_CTR_HANDOVER_FAILED, |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 1323 | BSC_CTR_HANDOVER_ERROR, |
| 1324 | BSC_CTR_INTER_BSC_HO_OUT_ATTEMPTED, |
| 1325 | BSC_CTR_INTER_BSC_HO_OUT_COMPLETED, |
| 1326 | BSC_CTR_INTER_BSC_HO_OUT_STOPPED, |
| 1327 | BSC_CTR_INTER_BSC_HO_OUT_TIMEOUT, |
| 1328 | BSC_CTR_INTER_BSC_HO_OUT_ERROR, |
| 1329 | BSC_CTR_INTER_BSC_HO_IN_ATTEMPTED, |
| 1330 | BSC_CTR_INTER_BSC_HO_IN_COMPLETED, |
| 1331 | BSC_CTR_INTER_BSC_HO_IN_STOPPED, |
| 1332 | BSC_CTR_INTER_BSC_HO_IN_NO_CHANNEL, |
| 1333 | BSC_CTR_INTER_BSC_HO_IN_FAILED, |
| 1334 | BSC_CTR_INTER_BSC_HO_IN_TIMEOUT, |
| 1335 | BSC_CTR_INTER_BSC_HO_IN_ERROR, |
Alexander Couzens | b847a21 | 2016-08-02 11:34:11 +0200 | [diff] [blame] | 1336 | BSC_CTR_PAGING_ATTEMPTED, |
| 1337 | BSC_CTR_PAGING_DETACHED, |
Harald Welte | cf9d431 | 2017-12-13 23:17:16 +0100 | [diff] [blame] | 1338 | BSC_CTR_PAGING_RESPONDED, |
Stefan Sperling | 7926d98 | 2018-05-17 14:52:02 +0200 | [diff] [blame] | 1339 | BSC_CTR_UNKNOWN_UNIT_ID, |
Alexander Couzens | b847a21 | 2016-08-02 11:34:11 +0200 | [diff] [blame] | 1340 | }; |
| 1341 | |
| 1342 | static const struct rate_ctr_desc bsc_ctr_description[] = { |
Neels Hofmeyr | dbb38d5 | 2018-07-11 19:53:56 +0200 | [diff] [blame] | 1343 | [BSC_CTR_ASSIGNMENT_ATTEMPTED] = {"assignment:attempted", "Assignment attempts."}, |
| 1344 | [BSC_CTR_ASSIGNMENT_COMPLETED] = {"assignment:completed", "Assignment completed."}, |
| 1345 | [BSC_CTR_ASSIGNMENT_STOPPED] = {"assignment:stopped", "Connection ended during Assignment."}, |
| 1346 | [BSC_CTR_ASSIGNMENT_NO_CHANNEL] = {"assignment:no_channel", "Failure to allocate lchan for Assignment."}, |
| 1347 | [BSC_CTR_ASSIGNMENT_TIMEOUT] = {"assignment:timeout", "Assignment timed out."}, |
| 1348 | [BSC_CTR_ASSIGNMENT_FAILED] = {"assignment:failed", "Received Assignment Failure message."}, |
| 1349 | [BSC_CTR_ASSIGNMENT_ERROR] = {"assignment:error", "Assigment failed for other reason."}, |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 1350 | |
| 1351 | [BSC_CTR_HANDOVER_ATTEMPTED] = {"handover:attempted", "Intra-BSC handover attempts."}, |
| 1352 | [BSC_CTR_HANDOVER_COMPLETED] = {"handover:completed", "Intra-BSC handover completed."}, |
| 1353 | [BSC_CTR_HANDOVER_STOPPED] = {"handover:stopped", "Connection ended during HO."}, |
| 1354 | [BSC_CTR_HANDOVER_NO_CHANNEL] = {"handover:no_channel", "Failure to allocate lchan for HO."}, |
| 1355 | [BSC_CTR_HANDOVER_TIMEOUT] = {"handover:timeout", "Handover timed out."}, |
| 1356 | [BSC_CTR_HANDOVER_FAILED] = {"handover:failed", "Received Handover Fail messages."}, |
| 1357 | [BSC_CTR_HANDOVER_ERROR] = {"handover:error", "Re-assigment failed for other reason."}, |
| 1358 | |
| 1359 | [BSC_CTR_INTER_BSC_HO_OUT_ATTEMPTED] = {"interbsc_ho_out:attempted", |
| 1360 | "Attempts to handover to remote BSS."}, |
| 1361 | [BSC_CTR_INTER_BSC_HO_OUT_COMPLETED] = {"interbsc_ho_out:completed", |
| 1362 | "Handover to remote BSS completed."}, |
| 1363 | [BSC_CTR_INTER_BSC_HO_OUT_STOPPED] = {"interbsc_ho_out:stopped", "Connection ended during HO."}, |
| 1364 | [BSC_CTR_INTER_BSC_HO_OUT_TIMEOUT] = {"interbsc_ho_out:timeout", "Handover timed out."}, |
| 1365 | [BSC_CTR_INTER_BSC_HO_OUT_ERROR] = {"interbsc_ho_out:error", |
| 1366 | "Handover to remote BSS failed for other reason."}, |
| 1367 | |
| 1368 | [BSC_CTR_INTER_BSC_HO_IN_ATTEMPTED] = {"interbsc_ho_in:attempted", |
| 1369 | "Attempts to handover from remote BSS."}, |
| 1370 | [BSC_CTR_INTER_BSC_HO_IN_COMPLETED] = {"interbsc_ho_in:completed", |
| 1371 | "Handover from remote BSS completed."}, |
| 1372 | [BSC_CTR_INTER_BSC_HO_IN_STOPPED] = {"interbsc_ho_in:stopped", "Connection ended during HO."}, |
| 1373 | [BSC_CTR_INTER_BSC_HO_IN_NO_CHANNEL] = {"interbsc_ho_in:no_channel", |
| 1374 | "Failure to allocate lchan for HO."}, |
| 1375 | [BSC_CTR_INTER_BSC_HO_IN_TIMEOUT] = {"interbsc_ho_in:timeout", "Handover from remote BSS timed out."}, |
| 1376 | [BSC_CTR_INTER_BSC_HO_IN_FAILED] = {"interbsc_ho_in:failed", "Received Handover Fail message."}, |
| 1377 | [BSC_CTR_INTER_BSC_HO_IN_ERROR] = {"interbsc_ho_in:error", |
| 1378 | "Handover from remote BSS failed for other reason."}, |
Harald Welte | cf9d431 | 2017-12-13 23:17:16 +0100 | [diff] [blame] | 1379 | |
| 1380 | [BSC_CTR_PAGING_ATTEMPTED] = {"paging:attempted", "Paging attempts for a subscriber."}, |
Stefan Sperling | 71d524c | 2018-05-17 14:38:27 +0200 | [diff] [blame] | 1381 | [BSC_CTR_PAGING_DETACHED] = {"paging:detached", "Paging request send failures because no responsible BTS was found."}, |
Harald Welte | cf9d431 | 2017-12-13 23:17:16 +0100 | [diff] [blame] | 1382 | [BSC_CTR_PAGING_RESPONDED] = {"paging:responded", "Paging attempts with successful response."}, |
Stefan Sperling | 7926d98 | 2018-05-17 14:52:02 +0200 | [diff] [blame] | 1383 | |
| 1384 | [BSC_CTR_UNKNOWN_UNIT_ID] = {"abis:unknown_unit_id", "Connection attempts from unknown IPA CCM Unit ID."}, |
Alexander Couzens | b847a21 | 2016-08-02 11:34:11 +0200 | [diff] [blame] | 1385 | }; |
| 1386 | |
Alexander Couzens | b847a21 | 2016-08-02 11:34:11 +0200 | [diff] [blame] | 1387 | |
| 1388 | |
| 1389 | static const struct rate_ctr_group_desc bsc_ctrg_desc = { |
| 1390 | "bsc", |
| 1391 | "base station controller", |
| 1392 | OSMO_STATS_CLASS_GLOBAL, |
| 1393 | ARRAY_SIZE(bsc_ctr_description), |
| 1394 | bsc_ctr_description, |
Alexander Couzens | 20423ea | 2016-07-12 15:42:02 +0200 | [diff] [blame] | 1395 | }; |
| 1396 | |
Neels Hofmeyr | 7398395 | 2016-05-10 13:29:33 +0200 | [diff] [blame] | 1397 | struct gsm_tz { |
| 1398 | int override; /* if 0, use system's time zone instead. */ |
| 1399 | int hr; /* hour */ |
| 1400 | int mn; /* minute */ |
| 1401 | int dst; /* daylight savings */ |
| 1402 | }; |
| 1403 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1404 | struct gsm_network { |
Neels Hofmeyr | ce4d88b | 2017-05-08 15:12:20 +0200 | [diff] [blame] | 1405 | /* TODO MSCSPLIT the gsm_network struct is basically a kitchen sink for |
| 1406 | * global settings and variables, "madly" mixing BSC and MSC stuff. Split |
| 1407 | * this in e.g. struct osmo_bsc and struct osmo_msc, with the things |
| 1408 | * these have in common, like country and network code, put in yet |
| 1409 | * separate structs and placed as members in osmo_bsc and osmo_msc. */ |
| 1410 | |
Neels Hofmeyr | f93970b | 2018-03-05 02:09:40 +0100 | [diff] [blame] | 1411 | struct osmo_plmn_id plmn; |
| 1412 | |
Harald Welte | 51e4bf3 | 2017-12-23 17:30:18 +0100 | [diff] [blame] | 1413 | /* bit-mask of permitted encryption algorithms. LSB=A5/0, MSB=A5/7 */ |
| 1414 | uint8_t a5_encryption_mask; |
Holger Hans Peter Freyther | f7d752f | 2009-11-16 17:12:38 +0100 | [diff] [blame] | 1415 | int neci; |
Neels Hofmeyr | 909e972 | 2017-12-07 03:54:01 +0100 | [diff] [blame] | 1416 | |
Neels Hofmeyr | e25018b | 2017-11-27 21:29:33 +0100 | [diff] [blame] | 1417 | struct handover_cfg *ho; |
Neels Hofmeyr | 909e972 | 2017-12-07 03:54:01 +0100 | [diff] [blame] | 1418 | struct { |
| 1419 | unsigned int congestion_check_interval_s; |
| 1420 | struct osmo_timer_list congestion_check_timer; |
| 1421 | } hodec2; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1422 | |
Alexander Couzens | b847a21 | 2016-08-02 11:34:11 +0200 | [diff] [blame] | 1423 | struct rate_ctr_group *bsc_ctrs; |
Harald Welte | 24ff6ee | 2009-12-22 00:41:05 +0100 | [diff] [blame] | 1424 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1425 | unsigned int num_bts; |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 1426 | struct llist_head bts_list; |
Oliver Smith | 8d8d710 | 2018-10-23 15:35:43 +0200 | [diff] [blame] | 1427 | struct llist_head bts_rejected; |
Holger Hans Peter Freyther | c4d88ad | 2009-11-21 21:18:38 +0100 | [diff] [blame] | 1428 | |
Neels Hofmeyr | 596c402 | 2018-06-16 19:29:50 +0200 | [diff] [blame] | 1429 | /* shall reference gsm_network_T[] */ |
| 1430 | struct T_def *T_defs; |
Harald Welte | eab84a1 | 2009-12-13 10:53:12 +0100 | [diff] [blame] | 1431 | |
Alexander Couzens | 547c207 | 2017-11-21 12:03:04 +0100 | [diff] [blame] | 1432 | enum gsm_chan_t ctype_by_chreq[_NUM_CHREQ_T]; |
Holger Hans Peter Freyther | 7889107 | 2010-09-06 09:36:02 +0800 | [diff] [blame] | 1433 | |
Holger Hans Peter Freyther | 76fc4a3 | 2010-09-06 09:41:50 +0800 | [diff] [blame] | 1434 | /* Use a TCH for handling requests of type paging any */ |
| 1435 | int pag_any_tch; |
| 1436 | |
Holger Hans Peter Freyther | 3e8e046 | 2010-09-15 22:29:25 +0800 | [diff] [blame] | 1437 | /* MSC data in case we are a true BSC */ |
Holger Hans Peter Freyther | 8ec4952 | 2011-08-15 15:53:00 +0200 | [diff] [blame] | 1438 | struct osmo_bsc_data *bsc_data; |
Holger Hans Peter Freyther | daee5ca | 2010-12-22 12:34:39 +0100 | [diff] [blame] | 1439 | |
Daniel Willmann | 6fc4a98 | 2011-07-22 17:55:42 +0200 | [diff] [blame] | 1440 | /* control interface */ |
| 1441 | struct ctrl_handle *ctrl; |
Neels Hofmeyr | 5f0c71b | 2016-07-23 20:15:28 +0200 | [diff] [blame] | 1442 | |
| 1443 | /* Allow or disallow TCH/F on dynamic TCH/F_TCH/H_PDCH; OS#1778 */ |
| 1444 | bool dyn_ts_allow_tch_f; |
Neels Hofmeyr | d90fa42 | 2016-05-09 21:03:12 +0200 | [diff] [blame] | 1445 | |
| 1446 | /* all active subscriber connections. */ |
| 1447 | struct llist_head subscr_conns; |
Neels Hofmeyr | 7398395 | 2016-05-10 13:29:33 +0200 | [diff] [blame] | 1448 | |
| 1449 | /* if override is nonzero, this timezone data is used for all MM |
| 1450 | * contexts. */ |
| 1451 | /* TODO: in OsmoNITB, tz-override used to be BTS-specific. To enable |
| 1452 | * BTS|RNC specific timezone overrides for multi-tz networks in |
Neels Hofmeyr | fe291de | 2017-02-23 21:06:12 +0100 | [diff] [blame] | 1453 | * OsmoMSC, this should be tied to the location area code (LAC). */ |
Neels Hofmeyr | 7398395 | 2016-05-10 13:29:33 +0200 | [diff] [blame] | 1454 | struct gsm_tz tz; |
Neels Hofmeyr | 6d804b1 | 2017-02-18 22:20:46 +0100 | [diff] [blame] | 1455 | |
| 1456 | /* List of all struct bsc_subscr used in libbsc. This llist_head is |
| 1457 | * allocated so that the llist_head pointer itself can serve as a |
| 1458 | * talloc context (useful to not have to pass the entire gsm_network |
| 1459 | * struct to the bsc_subscr_* API, and for bsc_susbscr unit tests to |
| 1460 | * not require gsm_data.h). In an MSC-without-BSC environment, this |
| 1461 | * pointer is NULL to indicate absence of a bsc_subscribers list. */ |
| 1462 | struct llist_head *bsc_subscribers; |
Harald Welte | a43e0b4 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 1463 | |
Stefan Sperling | 6cee893 | 2018-01-30 18:14:22 +0100 | [diff] [blame] | 1464 | /* Timer for periodic channel load measurements to maintain each BTS's T3122. */ |
| 1465 | struct osmo_timer_list t3122_chan_load_timer; |
| 1466 | |
Neels Hofmeyr | c29505e | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 1467 | struct { |
Philipp Maier | 39c609b | 2017-09-27 15:51:34 +0200 | [diff] [blame] | 1468 | struct mgcp_client_conf *conf; |
| 1469 | struct mgcp_client *client; |
| 1470 | } mgw; |
Neels Hofmeyr | 19bed23 | 2018-03-22 04:54:57 +0100 | [diff] [blame] | 1471 | |
| 1472 | /* Remote BSS Cell Identifier Lists */ |
| 1473 | struct neighbor_ident_list *neighbor_bss_cells; |
Harald Welte | 7e310b1 | 2009-03-30 20:56:32 +0000 | [diff] [blame] | 1474 | }; |
| 1475 | |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 1476 | struct gsm_audio_support { |
| 1477 | uint8_t hr : 1, |
| 1478 | ver : 7; |
| 1479 | }; |
| 1480 | |
Neels Hofmeyr | f93970b | 2018-03-05 02:09:40 +0100 | [diff] [blame] | 1481 | static inline const struct osmo_location_area_id *bts_lai(struct gsm_bts *bts) |
| 1482 | { |
| 1483 | static struct osmo_location_area_id lai; |
| 1484 | lai = (struct osmo_location_area_id){ |
| 1485 | .plmn = bts->network->plmn, |
| 1486 | .lac = bts->location_area_code, |
| 1487 | }; |
| 1488 | return &lai; |
| 1489 | } |
| 1490 | |
Neels Hofmeyr | c13e687 | 2016-05-11 13:53:47 +0200 | [diff] [blame] | 1491 | extern void talloc_ctx_init(void *ctx_root); |
| 1492 | |
Harald Welte | 39315c4 | 2010-01-10 18:01:52 +0100 | [diff] [blame] | 1493 | int gsm_set_bts_type(struct gsm_bts *bts, enum gsm_bts_type type); |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 1494 | |
Harald Welte | 1d014a5 | 2009-08-08 15:38:29 +0200 | [diff] [blame] | 1495 | enum gsm_bts_type parse_btstype(const char *arg); |
Holger Hans Peter Freyther | 2dceae6 | 2009-06-12 17:39:38 +0200 | [diff] [blame] | 1496 | const char *btstype2str(enum gsm_bts_type type); |
Harald Welte | be99149 | 2009-05-23 13:56:40 +0000 | [diff] [blame] | 1497 | struct gsm_bts *gsm_bts_by_lac(struct gsm_network *net, unsigned int lac, |
| 1498 | struct gsm_bts *start_bts); |
Harald Welte | 32201c1 | 2009-03-10 12:15:10 +0000 | [diff] [blame] | 1499 | |
Andreas Eversberg | 8226fa7 | 2009-06-29 15:19:38 +0200 | [diff] [blame] | 1500 | extern void *tall_bsc_ctx; |
Harald Welte | f88c8a0 | 2009-12-20 13:48:15 +0100 | [diff] [blame] | 1501 | extern int ipacc_rtp_direct; |
Harald Welte | 2cf161b | 2009-06-20 22:36:41 +0200 | [diff] [blame] | 1502 | |
Harald Welte | f383aa1 | 2012-07-02 19:51:55 +0200 | [diff] [blame] | 1503 | /* this actaully refers to the IPA transport, not the BTS model */ |
Harald Welte | 32201c1 | 2009-03-10 12:15:10 +0000 | [diff] [blame] | 1504 | static inline int is_ipaccess_bts(struct gsm_bts *bts) |
| 1505 | { |
| 1506 | switch (bts->type) { |
Mike Haben | e2d8227 | 2009-10-02 12:19:34 +0100 | [diff] [blame] | 1507 | case GSM_BTS_TYPE_NANOBTS: |
Max | f9685c1 | 2017-03-23 12:01:07 +0100 | [diff] [blame] | 1508 | case GSM_BTS_TYPE_OSMOBTS: |
Harald Welte | 32201c1 | 2009-03-10 12:15:10 +0000 | [diff] [blame] | 1509 | return 1; |
| 1510 | default: |
| 1511 | break; |
| 1512 | } |
| 1513 | return 0; |
| 1514 | } |
| 1515 | |
Holger Hans Peter Freyther | 6f6cbf7 | 2015-04-04 19:35:22 +0200 | [diff] [blame] | 1516 | static inline int is_sysmobts_v2(struct gsm_bts *bts) |
| 1517 | { |
| 1518 | switch (bts->type) { |
Max | f9685c1 | 2017-03-23 12:01:07 +0100 | [diff] [blame] | 1519 | case GSM_BTS_TYPE_OSMOBTS: |
Holger Hans Peter Freyther | 6f6cbf7 | 2015-04-04 19:35:22 +0200 | [diff] [blame] | 1520 | return 1; |
| 1521 | default: |
| 1522 | break; |
| 1523 | } |
| 1524 | return 0; |
| 1525 | } |
| 1526 | |
Harald Welte | 5b57067 | 2009-08-10 10:08:01 +0200 | [diff] [blame] | 1527 | static inline int is_siemens_bts(struct gsm_bts *bts) |
| 1528 | { |
| 1529 | switch (bts->type) { |
| 1530 | case GSM_BTS_TYPE_BS11: |
| 1531 | return 1; |
| 1532 | default: |
| 1533 | break; |
| 1534 | } |
| 1535 | |
| 1536 | return 0; |
| 1537 | } |
| 1538 | |
Andreas Eversberg | 7d8fa34 | 2013-12-05 13:25:06 +0100 | [diff] [blame] | 1539 | static inline int is_nokia_bts(struct gsm_bts *bts) |
| 1540 | { |
| 1541 | switch (bts->type) { |
| 1542 | case GSM_BTS_TYPE_NOKIA_SITE: |
| 1543 | return 1; |
| 1544 | default: |
| 1545 | break; |
| 1546 | } |
| 1547 | |
| 1548 | return 0; |
| 1549 | } |
| 1550 | |
Andreas Eversberg | dcf38e1 | 2013-12-05 14:37:11 +0100 | [diff] [blame] | 1551 | static inline int is_e1_bts(struct gsm_bts *bts) |
| 1552 | { |
| 1553 | switch (bts->type) { |
| 1554 | case GSM_BTS_TYPE_BS11: |
| 1555 | case GSM_BTS_TYPE_RBS2000: |
| 1556 | case GSM_BTS_TYPE_NOKIA_SITE: |
| 1557 | return 1; |
| 1558 | default: |
| 1559 | break; |
| 1560 | } |
| 1561 | |
| 1562 | return 0; |
| 1563 | } |
| 1564 | |
Harald Welte | 1876c31 | 2018-05-27 11:53:43 +0200 | [diff] [blame] | 1565 | extern struct gsm_network *bsc_gsmnet; |
| 1566 | |
Holger Hans Peter Freyther | 4e13a8f | 2015-01-31 22:16:00 +0100 | [diff] [blame] | 1567 | enum bts_gprs_mode bts_gprs_mode_parse(const char *arg, int *valid); |
Harald Welte | 4511d89 | 2010-04-18 15:51:20 +0200 | [diff] [blame] | 1568 | const char *bts_gprs_mode_name(enum bts_gprs_mode mode); |
Holger Hans Peter Freyther | 4e13a8f | 2015-01-31 22:16:00 +0100 | [diff] [blame] | 1569 | int bts_gprs_mode_is_compat(struct gsm_bts *bts, enum bts_gprs_mode mode); |
Harald Welte | 4511d89 | 2010-04-18 15:51:20 +0200 | [diff] [blame] | 1570 | |
Neels Hofmeyr | 4d358c0 | 2018-02-22 03:19:05 +0100 | [diff] [blame] | 1571 | void gsm48_ra_id_by_bts(struct gsm48_ra_id *buf, struct gsm_bts *bts); |
Harald Welte | 97a282b | 2010-03-14 15:37:43 +0800 | [diff] [blame] | 1572 | void gprs_ra_id_by_bts(struct gprs_ra_id *raid, struct gsm_bts *bts); |
Harald Welte | d12b0fd | 2009-12-15 21:36:05 +0100 | [diff] [blame] | 1573 | |
Harald Welte | fbda4e1 | 2010-03-04 11:04:52 +0100 | [diff] [blame] | 1574 | int gsm_bts_model_register(struct gsm_bts_model *model); |
| 1575 | |
Harald Welte | 3561bd4 | 2018-01-28 03:04:16 +0100 | [diff] [blame] | 1576 | struct gsm_subscriber_connection *bsc_subscr_con_allocate(struct gsm_network *network); |
Neels Hofmeyr | 42eb014 | 2016-05-20 17:15:44 +0200 | [diff] [blame] | 1577 | |
| 1578 | struct gsm_subscriber_connection *msc_subscr_con_allocate(struct gsm_network *network); |
| 1579 | void msc_subscr_con_free(struct gsm_subscriber_connection *conn); |
Holger Hans Peter Freyther | 2412a07 | 2010-06-28 15:47:12 +0800 | [diff] [blame] | 1580 | |
Neels Hofmeyr | 958f259 | 2018-05-27 01:26:31 +0200 | [diff] [blame] | 1581 | struct gsm_bts *gsm_bts_alloc_register(struct gsm_network *net, enum gsm_bts_type type, uint8_t bsic); |
| 1582 | struct gsm_bts *bsc_bts_alloc_register(struct gsm_network *net, enum gsm_bts_type type, uint8_t bsic); |
Harald Welte | 142d12d | 2014-12-29 17:47:08 +0100 | [diff] [blame] | 1583 | |
Harald Welte | 3300c01 | 2011-06-05 13:31:33 +0200 | [diff] [blame] | 1584 | void set_ts_e1link(struct gsm_bts_trx_ts *ts, uint8_t e1_nr, |
| 1585 | uint8_t e1_ts, uint8_t e1_ts_ss); |
| 1586 | |
Max | be356ed | 2017-09-07 19:10:09 +0200 | [diff] [blame] | 1587 | void gsm_trx_lock_rf(struct gsm_bts_trx *trx, bool locked, const char *reason); |
Harald Welte | 3300c01 | 2011-06-05 13:31:33 +0200 | [diff] [blame] | 1588 | struct gsm_bts_trx *gsm_bts_trx_by_nr(struct gsm_bts *bts, int nr); |
Holger Hans Peter Freyther | a49b2c0 | 2014-11-21 11:18:45 +0100 | [diff] [blame] | 1589 | int gsm_bts_trx_set_system_infos(struct gsm_bts_trx *trx); |
Alexander Chemeris | c36a13b | 2015-05-30 14:40:54 -0400 | [diff] [blame] | 1590 | int gsm_bts_set_system_infos(struct gsm_bts *bts); |
Harald Welte | 3300c01 | 2011-06-05 13:31:33 +0200 | [diff] [blame] | 1591 | |
Pablo Neira Ayuso | ed5cacb | 2011-08-17 22:44:07 +0200 | [diff] [blame] | 1592 | /* generic E1 line operations for all ISDN-based BTS. */ |
| 1593 | extern struct e1inp_line_ops bts_isdn_e1inp_line_ops; |
| 1594 | |
Harald Welte | e555c2b | 2012-08-17 13:02:12 +0200 | [diff] [blame] | 1595 | extern const struct value_string bts_type_names[_NUM_GSM_BTS_TYPE+1]; |
| 1596 | extern const struct value_string bts_type_descs[_NUM_GSM_BTS_TYPE+1]; |
| 1597 | |
Max | 3d049d2 | 2017-10-09 17:12:53 +0200 | [diff] [blame] | 1598 | char *get_model_oml_status(const struct gsm_bts *bts); |
| 1599 | |
Max | 25cc407 | 2017-10-10 14:50:35 +0200 | [diff] [blame] | 1600 | unsigned long long bts_uptime(const struct gsm_bts *bts); |
| 1601 | |
Holger Hans Peter Freyther | f8c4219 | 2013-01-09 17:03:27 +0100 | [diff] [blame] | 1602 | /* control interface handling */ |
| 1603 | int bsc_base_ctrl_cmds_install(void); |
| 1604 | |
Holger Hans Peter Freyther | c22930e | 2014-12-17 14:46:17 +0100 | [diff] [blame] | 1605 | /* dependency handling */ |
| 1606 | void bts_depend_mark(struct gsm_bts *bts, int dep); |
| 1607 | void bts_depend_clear(struct gsm_bts *bts, int dep); |
| 1608 | int bts_depend_check(struct gsm_bts *bts); |
Holger Hans Peter Freyther | f7e23c5 | 2014-12-17 15:44:32 +0100 | [diff] [blame] | 1609 | int bts_depend_is_depedency(struct gsm_bts *base, struct gsm_bts *other); |
Holger Hans Peter Freyther | c22930e | 2014-12-17 14:46:17 +0100 | [diff] [blame] | 1610 | |
Harald Welte | 2f8b9d2 | 2017-06-18 11:12:13 +0300 | [diff] [blame] | 1611 | int gsm_bts_get_radio_link_timeout(const struct gsm_bts *bts); |
| 1612 | void gsm_bts_set_radio_link_timeout(struct gsm_bts *bts, int value); |
| 1613 | |
Harald Welte | a43e0b4 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 1614 | bool classmark_is_r99(struct gsm_classmark *cm); |
| 1615 | |
Neels Hofmeyr | 958f259 | 2018-05-27 01:26:31 +0200 | [diff] [blame] | 1616 | bool trx_is_usable(const struct gsm_bts_trx *trx); |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 1617 | bool ts_is_usable(const struct gsm_bts_trx_ts *ts); |
Neels Hofmeyr | 958f259 | 2018-05-27 01:26:31 +0200 | [diff] [blame] | 1618 | |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 1619 | int gsm_lchan_type_by_pchan(enum gsm_phys_chan_config pchan); |
| 1620 | enum gsm_phys_chan_config gsm_pchan_by_lchan_type(enum gsm_chan_t type); |
| 1621 | |
| 1622 | void gsm_bts_all_ts_dispatch(struct gsm_bts *bts, uint32_t ts_ev, void *data); |
| 1623 | void gsm_trx_all_ts_dispatch(struct gsm_bts_trx *trx, uint32_t ts_ev, void *data); |
| 1624 | |
| 1625 | int bts_count_free_ts(struct gsm_bts *bts, enum gsm_phys_chan_config pchan); |
Neels Hofmeyr | 958f259 | 2018-05-27 01:26:31 +0200 | [diff] [blame] | 1626 | |
Philipp Maier | 89d72d8 | 2018-11-05 15:28:38 +0100 | [diff] [blame] | 1627 | struct osmo_cell_global_id *cgi_for_msc(struct bsc_msc_data *msc, struct gsm_bts *bts); |
| 1628 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 1629 | #endif /* _GSM_DATA_H */ |