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