Harald Welte | 3da6b3f | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 1 | #ifndef _GSM_DATA_SHAREDH |
| 2 | #define _GSM_DATA_SHAREDH |
| 3 | |
Holger Hans Peter Freyther | 1c14d96 | 2011-06-09 21:48:49 +0200 | [diff] [blame] | 4 | #include <regex.h> |
Harald Welte | 3da6b3f | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 5 | #include <stdbool.h> |
| 6 | #include <stdint.h> |
| 7 | |
| 8 | #include <osmocom/core/timer.h> |
| 9 | #include <osmocom/core/bitvec.h> |
| 10 | #include <osmocom/core/statistics.h> |
| 11 | #include <osmocom/core/utils.h> |
| 12 | #include <osmocom/gsm/gsm_utils.h> |
| 13 | #include <osmocom/gsm/tlv.h> |
| 14 | #include <osmocom/gsm/rxlev_stat.h> |
| 15 | #include <osmocom/gsm/sysinfo.h> |
| 16 | |
| 17 | #include <osmocom/gsm/protocol/gsm_08_58.h> |
Harald Welte | c788128 | 2011-06-05 13:31:33 +0200 | [diff] [blame] | 18 | #include <osmocom/gsm/protocol/gsm_12_21.h> |
Harald Welte | 3da6b3f | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 19 | |
Harald Welte | 924da55 | 2011-08-24 13:52:07 +0200 | [diff] [blame] | 20 | #include <osmocom/abis/e1_input.h> |
| 21 | |
Holger Hans Peter Freyther | 2d75d3f | 2012-12-20 19:03:18 +0100 | [diff] [blame] | 22 | #ifndef ROLE_BSC |
| 23 | #include <osmocom/gsm/lapdm.h> |
| 24 | #endif |
| 25 | |
Holger Hans Peter Freyther | 4d61417 | 2011-08-15 15:53:00 +0200 | [diff] [blame] | 26 | struct osmo_bsc_data; |
| 27 | |
Harald Welte | 3da6b3f | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 28 | struct osmo_bsc_sccp_con; |
| 29 | struct gsm_sms_queue; |
| 30 | |
| 31 | /* RRLP mode of operation */ |
| 32 | enum rrlp_mode { |
| 33 | RRLP_MODE_NONE, |
| 34 | RRLP_MODE_MS_BASED, |
| 35 | RRLP_MODE_MS_PREF, |
| 36 | RRLP_MODE_ASS_PREF, |
| 37 | }; |
| 38 | |
| 39 | /* Channel Request reason */ |
| 40 | enum gsm_chreq_reason_t { |
| 41 | GSM_CHREQ_REASON_EMERG, |
| 42 | GSM_CHREQ_REASON_PAG, |
| 43 | GSM_CHREQ_REASON_CALL, |
| 44 | GSM_CHREQ_REASON_LOCATION_UPD, |
| 45 | GSM_CHREQ_REASON_OTHER, |
| 46 | }; |
| 47 | |
| 48 | #define TRX_NR_TS 8 |
| 49 | #define TS_MAX_LCHAN 8 |
| 50 | |
| 51 | #define HARDCODED_ARFCN 123 |
| 52 | #define HARDCODED_TSC 7 |
| 53 | #define HARDCODED_BSIC 0x3f /* NCC = 7 / BCC = 7 */ |
| 54 | |
| 55 | /* for multi-drop config */ |
| 56 | #define HARDCODED_BTS0_TS 1 |
| 57 | #define HARDCODED_BTS1_TS 6 |
| 58 | #define HARDCODED_BTS2_TS 11 |
| 59 | |
| 60 | /* reserved according to GSM 03.03 ยง 2.4 */ |
| 61 | #define GSM_RESERVED_TMSI 0xFFFFFFFF |
| 62 | |
| 63 | enum gsm_hooks { |
| 64 | GSM_HOOK_NM_SWLOAD, |
| 65 | GSM_HOOK_RR_PAGING, |
| 66 | GSM_HOOK_RR_SECURITY, |
| 67 | }; |
| 68 | |
| 69 | enum gsm_paging_event { |
| 70 | GSM_PAGING_SUCCEEDED, |
| 71 | GSM_PAGING_EXPIRED, |
| 72 | GSM_PAGING_OOM, |
| 73 | GSM_PAGING_BUSY, |
| 74 | }; |
| 75 | |
| 76 | enum bts_gprs_mode { |
| 77 | BTS_GPRS_NONE = 0, |
| 78 | BTS_GPRS_GPRS = 1, |
| 79 | BTS_GPRS_EGPRS = 2, |
| 80 | }; |
| 81 | |
| 82 | struct gsm_lchan; |
| 83 | struct gsm_subscriber; |
| 84 | struct gsm_mncc; |
Harald Welte | 52bf91c | 2011-09-04 13:53:26 +0200 | [diff] [blame] | 85 | struct osmo_rtp_socket; |
Harald Welte | 3da6b3f | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 86 | struct rtp_socket; |
| 87 | struct bsc_api; |
| 88 | |
| 89 | /* Network Management State */ |
| 90 | struct gsm_nm_state { |
| 91 | uint8_t operational; |
| 92 | uint8_t administrative; |
| 93 | uint8_t availability; |
| 94 | }; |
| 95 | |
Harald Welte | 69f6f81 | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 96 | struct gsm_abis_mo { |
Harald Welte | c788128 | 2011-06-05 13:31:33 +0200 | [diff] [blame] | 97 | uint8_t obj_class; |
| 98 | struct abis_om_obj_inst obj_inst; |
Harald Welte | 69f6f81 | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 99 | const char *name; |
| 100 | struct gsm_nm_state nm_state; |
| 101 | struct tlv_parsed *nm_attr; |
Harald Welte | 01f4d6b | 2011-06-06 18:58:48 +0200 | [diff] [blame] | 102 | struct gsm_bts *bts; |
Harald Welte | 69f6f81 | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 103 | }; |
| 104 | |
Harald Welte | 3da6b3f | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 105 | #define MAX_A5_KEY_LEN (128/8) |
| 106 | #define A38_XOR_MIN_KEY_LEN 12 |
| 107 | #define A38_XOR_MAX_KEY_LEN 16 |
| 108 | #define A38_COMP128_KEY_LEN 16 |
| 109 | #define RSL_ENC_ALG_A5(x) (x+1) |
| 110 | |
| 111 | /* is the data link established? who established it? */ |
| 112 | #define LCHAN_SAPI_UNUSED 0 |
| 113 | #define LCHAN_SAPI_MS 1 |
| 114 | #define LCHAN_SAPI_NET 2 |
| 115 | |
| 116 | /* state of a logical channel */ |
| 117 | enum gsm_lchan_state { |
| 118 | LCHAN_S_NONE, /* channel is not active */ |
Holger Hans Peter Freyther | 5d880c6 | 2012-01-15 00:02:17 +0100 | [diff] [blame] | 119 | LCHAN_S_ACT_REQ, /* channel activation requested */ |
Harald Welte | 3da6b3f | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 120 | LCHAN_S_ACTIVE, /* channel is active and operational */ |
| 121 | LCHAN_S_REL_REQ, /* channel release has been requested */ |
| 122 | LCHAN_S_REL_ERR, /* channel is in an error state */ |
Holger Hans Peter Freyther | 5149c17 | 2012-12-06 19:25:06 +0100 | [diff] [blame] | 123 | LCHAN_S_BROKEN, /* channel is somehow unusable */ |
Harald Welte | 3da6b3f | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 124 | LCHAN_S_INACTIVE, /* channel is set inactive */ |
| 125 | }; |
| 126 | |
Harald Welte | 0e4f7dc | 2011-06-29 10:38:34 +0200 | [diff] [blame] | 127 | /* BTS ONLY */ |
| 128 | #define MAX_NUM_UL_MEAS 104 |
| 129 | #define LC_UL_M_F_L1_VALID (1 << 0) |
| 130 | #define LC_UL_M_F_RES_VALID (1 << 1) |
| 131 | |
| 132 | struct bts_ul_meas { |
| 133 | /* BER in units of 0.01%: 10.000 == 100% ber, 0 == 0% ber */ |
| 134 | uint16_t ber10k; |
| 135 | /* timing advance offset (in quarter bits) */ |
| 136 | int16_t ta_offs_qbits; |
| 137 | /* C/I ratio in dB */ |
| 138 | float c_i; |
| 139 | /* flags */ |
| 140 | uint8_t is_sub:1; |
| 141 | /* RSSI in dBm * -1 */ |
| 142 | uint8_t inv_rssi; |
| 143 | }; |
Harald Welte | 886a5a5 | 2011-09-06 22:14:43 +0200 | [diff] [blame] | 144 | |
| 145 | struct amr_mode { |
| 146 | uint8_t mode; |
| 147 | uint8_t threshold; |
| 148 | uint8_t hysteresis; |
| 149 | }; |
| 150 | struct amr_multirate_conf { |
| 151 | uint8_t gsm48_ie[2]; |
| 152 | struct amr_mode mode[4]; |
| 153 | uint8_t num_modes; |
| 154 | }; |
Harald Welte | 0e4f7dc | 2011-06-29 10:38:34 +0200 | [diff] [blame] | 155 | /* /BTS ONLY */ |
| 156 | |
Harald Welte | e75a47d | 2012-08-24 15:33:56 +0200 | [diff] [blame] | 157 | enum lchan_csd_mode { |
| 158 | LCHAN_CSD_M_NT, |
| 159 | LCHAN_CSD_M_T_1200_75, |
| 160 | LCHAN_CSD_M_T_600, |
| 161 | LCHAN_CSD_M_T_1200, |
| 162 | LCHAN_CSD_M_T_2400, |
| 163 | LCHAN_CSD_M_T_9600, |
| 164 | LCHAN_CSD_M_T_14400, |
| 165 | LCHAN_CSD_M_T_29000, |
| 166 | LCHAN_CSD_M_T_32000, |
| 167 | }; |
| 168 | |
Daniel Willmann | 4c2fac0 | 2012-12-29 12:32:30 +0100 | [diff] [blame] | 169 | /* State of the SAPIs in the lchan */ |
| 170 | enum lchan_sapi_state { |
| 171 | LCHAN_SAPI_S_NONE, |
| 172 | LCHAN_SAPI_S_REQ, |
| 173 | LCHAN_SAPI_S_ASSIGNED, |
| 174 | LCHAN_SAPI_S_REL, |
| 175 | LCHAN_SAPI_S_ERROR, |
| 176 | }; |
| 177 | |
Harald Welte | 3da6b3f | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 178 | struct gsm_lchan { |
| 179 | /* The TS that we're part of */ |
| 180 | struct gsm_bts_trx_ts *ts; |
| 181 | /* The logical subslot number in the TS */ |
| 182 | uint8_t nr; |
| 183 | /* The logical channel type */ |
| 184 | enum gsm_chan_t type; |
| 185 | /* RSL channel mode */ |
| 186 | enum rsl_cmod_spd rsl_cmode; |
| 187 | /* If TCH, traffic channel mode */ |
| 188 | enum gsm48_chan_mode tch_mode; |
Harald Welte | e75a47d | 2012-08-24 15:33:56 +0200 | [diff] [blame] | 189 | enum lchan_csd_mode csd_mode; |
Harald Welte | 3da6b3f | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 190 | /* State */ |
| 191 | enum gsm_lchan_state state; |
| 192 | /* Power levels for MS and BTS */ |
| 193 | uint8_t bs_power; |
| 194 | uint8_t ms_power; |
| 195 | /* Encryption information */ |
| 196 | struct { |
| 197 | uint8_t alg_id; |
| 198 | uint8_t key_len; |
| 199 | uint8_t key[MAX_A5_KEY_LEN]; |
| 200 | } encr; |
| 201 | |
| 202 | /* AMR bits */ |
| 203 | struct gsm48_multi_rate_conf mr_conf; |
| 204 | |
| 205 | /* Established data link layer services */ |
| 206 | uint8_t sapis[8]; |
Holger Hans Peter Freyther | 3596bc7 | 2013-01-01 19:20:28 +0100 | [diff] [blame] | 207 | int sacch_deact; |
Holger Hans Peter Freyther | e3be5ca | 2011-12-27 20:49:53 +0100 | [diff] [blame] | 208 | |
Harald Welte | 3da6b3f | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 209 | struct { |
| 210 | uint32_t bound_ip; |
| 211 | uint32_t connect_ip; |
| 212 | uint16_t bound_port; |
| 213 | uint16_t connect_port; |
| 214 | uint16_t conn_id; |
| 215 | uint8_t rtp_payload; |
| 216 | uint8_t rtp_payload2; |
| 217 | uint8_t speech_mode; |
Harald Welte | 52bf91c | 2011-09-04 13:53:26 +0200 | [diff] [blame] | 218 | #ifdef ROLE_BSC |
Harald Welte | 3da6b3f | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 219 | struct rtp_socket *rtp_socket; |
Harald Welte | 52bf91c | 2011-09-04 13:53:26 +0200 | [diff] [blame] | 220 | #else |
| 221 | struct osmo_rtp_socket *rtp_socket; |
| 222 | #endif |
Harald Welte | 3da6b3f | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 223 | } abis_ip; |
| 224 | |
Harald Welte | 2fa2797 | 2011-06-26 14:13:37 +0200 | [diff] [blame] | 225 | uint8_t rqd_ta; |
| 226 | |
Harald Welte | 3da6b3f | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 227 | #ifdef ROLE_BSC |
| 228 | struct osmo_timer_list T3101; |
Holger Hans Peter Freyther | 969a405 | 2011-12-28 16:21:05 +0100 | [diff] [blame] | 229 | struct osmo_timer_list T3109; |
Harald Welte | 3da6b3f | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 230 | struct osmo_timer_list T3111; |
| 231 | struct osmo_timer_list error_timer; |
Harald Welte | 32951ea | 2011-08-10 23:26:33 +0200 | [diff] [blame] | 232 | struct osmo_timer_list act_timer; |
Holger Hans Peter Freyther | 5149c17 | 2012-12-06 19:25:06 +0100 | [diff] [blame] | 233 | uint8_t error_cause; |
Harald Welte | 3da6b3f | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 234 | |
| 235 | /* table of neighbor cell measurements */ |
| 236 | struct neigh_meas_proc neigh_meas[MAX_NEIGH_MEAS]; |
| 237 | |
| 238 | /* cache of last measurement reports on this lchan */ |
| 239 | struct gsm_meas_rep meas_rep[6]; |
| 240 | int meas_rep_idx; |
| 241 | |
| 242 | /* GSM Random Access data */ |
| 243 | struct gsm48_req_ref *rqd_ref; |
Harald Welte | 3da6b3f | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 244 | |
| 245 | struct gsm_subscriber_connection *conn; |
Harald Welte | e6d51f9 | 2011-06-25 10:02:33 +0200 | [diff] [blame] | 246 | #else |
Daniel Willmann | 4c2fac0 | 2012-12-29 12:32:30 +0100 | [diff] [blame] | 247 | /* Number of different GsmL1_Sapi_t used in osmo_bts_sysmo is 23. |
| 248 | * Currently we don't share these headers so this is a magic number. */ |
Holger Hans Peter Freyther | ca46798 | 2013-04-05 18:41:45 +0200 | [diff] [blame] | 249 | struct llist_head sapi_cmds; |
Daniel Willmann | 4c2fac0 | 2012-12-29 12:32:30 +0100 | [diff] [blame] | 250 | uint8_t sapis_dl[23]; |
| 251 | uint8_t sapis_ul[23]; |
Harald Welte | e6d51f9 | 2011-06-25 10:02:33 +0200 | [diff] [blame] | 252 | struct lapdm_channel lapdm_ch; |
Harald Welte | 52bf91c | 2011-09-04 13:53:26 +0200 | [diff] [blame] | 253 | struct llist_head dl_tch_queue; |
Harald Welte | 2fa2797 | 2011-06-26 14:13:37 +0200 | [diff] [blame] | 254 | struct { |
| 255 | /* bitmask of all SI that are present/valid in si_buf */ |
| 256 | uint32_t valid; |
| 257 | uint32_t last; |
| 258 | /* buffers where we put the pre-computed SI */ |
| 259 | sysinfo_buf_t buf[_MAX_SYSINFO_TYPE]; |
| 260 | } si; |
Harald Welte | 0e4f7dc | 2011-06-29 10:38:34 +0200 | [diff] [blame] | 261 | struct { |
| 262 | uint8_t flags; |
| 263 | /* RSL measurment result number, 0 at lchan_act */ |
| 264 | uint8_t res_nr; |
| 265 | /* current Tx power level of the BTS */ |
| 266 | uint8_t bts_tx_pwr; |
| 267 | /* number of measurements stored in array below */ |
| 268 | uint8_t num_ul_meas; |
| 269 | struct bts_ul_meas uplink[MAX_NUM_UL_MEAS]; |
| 270 | /* last L1 header from the MS */ |
| 271 | uint8_t l1_info[2]; |
| 272 | struct { |
| 273 | uint8_t rxlev_full; |
| 274 | uint8_t rxlev_sub; |
| 275 | uint8_t rxqual_full; |
| 276 | uint8_t rxqual_sub; |
| 277 | } res; |
| 278 | } meas; |
Harald Welte | 886a5a5 | 2011-09-06 22:14:43 +0200 | [diff] [blame] | 279 | struct { |
| 280 | struct amr_multirate_conf amr_mr; |
Harald Welte | 9e2b33b | 2011-09-07 12:41:38 +0200 | [diff] [blame] | 281 | struct { |
| 282 | uint8_t buf[16]; |
| 283 | uint8_t len; |
| 284 | } last_sid; |
Harald Welte | 886a5a5 | 2011-09-06 22:14:43 +0200 | [diff] [blame] | 285 | } tch; |
Harald Welte | 3ac27c5 | 2012-04-08 20:23:28 +0200 | [diff] [blame] | 286 | /* BTS-side ciphering state (rx only, bi-directional, ...) */ |
| 287 | uint8_t ciph_state; |
Harald Welte | 125c1b8 | 2012-04-19 23:13:35 +0200 | [diff] [blame] | 288 | uint8_t loopback; |
Harald Welte | dddccd4 | 2012-06-16 14:57:08 +0800 | [diff] [blame] | 289 | struct { |
| 290 | uint8_t active; |
| 291 | uint8_t ref; |
| 292 | /* T3105: PHYS INF retransmission */ |
| 293 | struct osmo_timer_list t3105; |
| 294 | /* counts up to Ny1 */ |
| 295 | unsigned int phys_info_count; |
| 296 | } ho; |
Andreas Eversberg | 43924f5 | 2013-02-20 16:06:20 +0100 | [diff] [blame] | 297 | /* S counter for link loss */ |
| 298 | int s; |
Harald Welte | 3da6b3f | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 299 | #endif |
| 300 | }; |
| 301 | |
Harald Welte | 3da6b3f | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 302 | #define TS_F_PDCH_MODE 0x1000 |
| 303 | /* One Timeslot in a TRX */ |
| 304 | struct gsm_bts_trx_ts { |
| 305 | struct gsm_bts_trx *trx; |
| 306 | /* number of this timeslot at the TRX */ |
| 307 | uint8_t nr; |
| 308 | |
| 309 | enum gsm_phys_chan_config pchan; |
| 310 | |
| 311 | unsigned int flags; |
Harald Welte | 69f6f81 | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 312 | struct gsm_abis_mo mo; |
Harald Welte | 3da6b3f | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 313 | struct tlv_parsed nm_attr; |
| 314 | uint8_t nm_chan_comb; |
Harald Welte | 85771a4 | 2011-05-30 12:09:13 +0200 | [diff] [blame] | 315 | int tsc; /* -1 == use BTS TSC */ |
Harald Welte | 3da6b3f | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 316 | |
| 317 | struct { |
| 318 | /* Parameters below are configured by VTY */ |
| 319 | int enabled; |
| 320 | uint8_t maio; |
| 321 | uint8_t hsn; |
| 322 | struct bitvec arfcns; |
| 323 | uint8_t arfcns_data[1024/8]; |
| 324 | /* This is the pre-computed MA for channel assignments */ |
| 325 | struct bitvec ma; |
| 326 | uint8_t ma_len; /* part of ma_data that is used */ |
| 327 | uint8_t ma_data[8]; /* 10.5.2.21: max 8 bytes value part */ |
| 328 | } hopping; |
| 329 | |
| 330 | /* To which E1 subslot are we connected */ |
| 331 | struct gsm_e1_subslot e1_link; |
| 332 | |
| 333 | struct gsm_lchan lchan[TS_MAX_LCHAN]; |
| 334 | }; |
| 335 | |
| 336 | /* One TRX in a BTS */ |
| 337 | struct gsm_bts_trx { |
| 338 | /* list header in bts->trx_list */ |
| 339 | struct llist_head list; |
| 340 | |
| 341 | struct gsm_bts *bts; |
| 342 | /* number of this TRX in the BTS */ |
| 343 | uint8_t nr; |
| 344 | /* human readable name / description */ |
| 345 | char *description; |
| 346 | /* how do we talk RSL with this TRX? */ |
| 347 | struct gsm_e1_subslot rsl_e1_link; |
| 348 | uint8_t rsl_tei; |
Holger Hans Peter Freyther | 1ad1aa8 | 2012-01-17 15:52:45 +0100 | [diff] [blame] | 349 | #ifdef ROLE_BSC |
Harald Welte | 3da6b3f | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 350 | struct e1inp_sign_link *rsl_link; |
Holger Hans Peter Freyther | 1ad1aa8 | 2012-01-17 15:52:45 +0100 | [diff] [blame] | 351 | #else |
| 352 | struct ipabis_link *rsl_link; |
| 353 | #endif |
Harald Welte | 3da6b3f | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 354 | /* Some BTS (specifically Ericsson RBS) have a per-TRX OML Link */ |
| 355 | struct e1inp_sign_link *oml_link; |
| 356 | |
Harald Welte | 69f6f81 | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 357 | struct gsm_abis_mo mo; |
Harald Welte | 3da6b3f | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 358 | struct tlv_parsed nm_attr; |
| 359 | struct { |
Harald Welte | 69f6f81 | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 360 | struct gsm_abis_mo mo; |
Harald Welte | 3da6b3f | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 361 | } bb_transc; |
| 362 | |
| 363 | uint16_t arfcn; |
| 364 | int nominal_power; /* in dBm */ |
| 365 | unsigned int max_power_red; /* in actual dB */ |
| 366 | |
Harald Welte | 4f215d0 | 2011-06-07 00:12:53 +0200 | [diff] [blame] | 367 | struct { |
| 368 | void *l1h; |
| 369 | } role_bts; |
| 370 | |
Harald Welte | 3da6b3f | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 371 | union { |
| 372 | struct { |
| 373 | struct { |
Harald Welte | 69f6f81 | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 374 | struct gsm_abis_mo mo; |
Harald Welte | 3da6b3f | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 375 | } bbsig; |
| 376 | struct { |
Harald Welte | 69f6f81 | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 377 | struct gsm_abis_mo mo; |
Harald Welte | 3da6b3f | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 378 | } pa; |
| 379 | } bs11; |
| 380 | struct { |
| 381 | unsigned int test_state; |
| 382 | uint8_t test_nr; |
| 383 | struct rxlev_stats rxlev_stat; |
| 384 | } ipaccess; |
| 385 | }; |
| 386 | struct gsm_bts_trx_ts ts[TRX_NR_TS]; |
| 387 | }; |
| 388 | |
| 389 | #define GSM_BTS_SI(bts, i) (void *)(bts->si_buf[i]) |
| 390 | |
| 391 | enum gsm_bts_type { |
| 392 | GSM_BTS_TYPE_UNKNOWN, |
| 393 | GSM_BTS_TYPE_BS11, |
| 394 | GSM_BTS_TYPE_NANOBTS, |
| 395 | GSM_BTS_TYPE_RBS2000, |
Dieter Spaar | 49c843e | 2011-07-28 00:01:50 +0200 | [diff] [blame] | 396 | GSM_BTS_TYPE_NOKIA_SITE, |
Harald Welte | 35ac0e4 | 2012-07-02 19:51:55 +0200 | [diff] [blame] | 397 | GSM_BTS_TYPE_OSMO_SYSMO, |
Harald Welte | 85a77b1 | 2012-08-17 13:02:12 +0200 | [diff] [blame] | 398 | _NUM_GSM_BTS_TYPE |
Harald Welte | 3da6b3f | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 399 | }; |
| 400 | |
| 401 | struct vty; |
| 402 | |
| 403 | struct gsm_bts_model { |
| 404 | struct llist_head list; |
| 405 | |
| 406 | enum gsm_bts_type type; |
| 407 | const char *name; |
| 408 | |
| 409 | bool started; |
| 410 | int (*start)(struct gsm_network *net); |
| 411 | int (*oml_rcvmsg)(struct msgb *msg); |
| 412 | |
Pablo Neira Ayuso | 42e41df | 2011-08-17 22:44:07 +0200 | [diff] [blame] | 413 | void (*e1line_bind_ops)(struct e1inp_line *line); |
| 414 | |
Harald Welte | 3da6b3f | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 415 | void (*config_write_bts)(struct vty *vty, struct gsm_bts *bts); |
| 416 | void (*config_write_trx)(struct vty *vty, struct gsm_bts_trx *trx); |
| 417 | void (*config_write_ts)(struct vty *vty, struct gsm_bts_trx_ts *ts); |
| 418 | |
| 419 | struct tlv_definition nm_att_tlvdef; |
| 420 | |
| 421 | struct bitvec features; |
| 422 | uint8_t _features_data[128/8]; |
| 423 | }; |
| 424 | |
| 425 | enum gsm_bts_features { |
| 426 | BTS_FEAT_HSCSD, |
| 427 | BTS_FEAT_GPRS, |
| 428 | BTS_FEAT_EGPRS, |
| 429 | BTS_FEAT_ECSD, |
| 430 | BTS_FEAT_HOPPING, |
| 431 | }; |
| 432 | |
| 433 | /* |
| 434 | * This keeps track of the paging status of one BTS. It |
| 435 | * includes a number of pending requests, a back pointer |
| 436 | * to the gsm_bts, a timer and some more state. |
| 437 | */ |
| 438 | struct gsm_bts_paging_state { |
| 439 | /* pending requests */ |
| 440 | struct llist_head pending_requests; |
| 441 | struct gsm_bts *bts; |
| 442 | |
| 443 | struct osmo_timer_list work_timer; |
| 444 | struct osmo_timer_list credit_timer; |
| 445 | |
| 446 | /* free chans needed */ |
| 447 | int free_chans_need; |
| 448 | |
| 449 | /* load */ |
| 450 | uint16_t available_slots; |
| 451 | }; |
| 452 | |
| 453 | struct gsm_envabtse { |
Harald Welte | 69f6f81 | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 454 | struct gsm_abis_mo mo; |
Harald Welte | 3da6b3f | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 455 | }; |
| 456 | |
| 457 | struct gsm_bts_gprs_nsvc { |
| 458 | struct gsm_bts *bts; |
| 459 | /* data read via VTY config file, to configure the BTS |
| 460 | * via OML from BSC */ |
| 461 | int id; |
| 462 | uint16_t nsvci; |
| 463 | uint16_t local_port; /* on the BTS */ |
| 464 | uint16_t remote_port; /* on the SGSN */ |
| 465 | uint32_t remote_ip; /* on the SGSN */ |
| 466 | |
Harald Welte | 69f6f81 | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 467 | struct gsm_abis_mo mo; |
Harald Welte | 3da6b3f | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 468 | }; |
| 469 | |
Harald Welte | 1c6955a | 2012-06-28 08:43:14 +0200 | [diff] [blame] | 470 | enum gprs_rlc_par { |
| 471 | RLC_T3142, |
| 472 | RLC_T3169, |
| 473 | RLC_T3191, |
| 474 | RLC_T3193, |
| 475 | RLC_T3195, |
| 476 | RLC_N3101, |
| 477 | RLC_N3103, |
| 478 | RLC_N3105, |
| 479 | CV_COUNTDOWN, |
| 480 | T_DL_TBF_EXT, /* ms */ |
| 481 | T_UL_TBF_EXT, /* ms */ |
| 482 | _NUM_RLC_PAR |
| 483 | }; |
| 484 | |
| 485 | enum gprs_cs { |
| 486 | GPRS_CS1, |
| 487 | GPRS_CS2, |
| 488 | GPRS_CS3, |
| 489 | GPRS_CS4, |
| 490 | GPRS_MCS1, |
| 491 | GPRS_MCS2, |
| 492 | GPRS_MCS3, |
| 493 | GPRS_MCS4, |
| 494 | GPRS_MCS5, |
| 495 | GPRS_MCS6, |
| 496 | GPRS_MCS7, |
| 497 | GPRS_MCS8, |
| 498 | GPRS_MCS9, |
| 499 | _NUM_GRPS_CS |
| 500 | }; |
| 501 | |
| 502 | struct gprs_rlc_cfg { |
| 503 | uint16_t parameter[_NUM_RLC_PAR]; |
| 504 | struct { |
| 505 | uint16_t repeat_time; /* ms */ |
| 506 | uint8_t repeat_count; |
| 507 | } paging; |
| 508 | uint32_t cs_mask; /* bitmask of gprs_cs */ |
| 509 | uint8_t initial_cs; |
| 510 | uint8_t initial_mcs; |
| 511 | }; |
| 512 | |
| 513 | |
Harald Welte | 3da6b3f | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 514 | enum neigh_list_manual_mode { |
| 515 | NL_MODE_AUTOMATIC = 0, |
| 516 | NL_MODE_MANUAL = 1, |
| 517 | NL_MODE_MANUAL_SI5SEP = 2, /* SI2 and SI5 have separate neighbor lists */ |
| 518 | }; |
| 519 | |
Daniel Willmann | 8c3483f | 2011-08-05 13:51:27 +0200 | [diff] [blame] | 520 | enum bts_loc_fix { |
| 521 | BTS_LOC_FIX_INVALID = 0, |
| 522 | BTS_LOC_FIX_2D = 1, |
| 523 | BTS_LOC_FIX_3D = 2, |
| 524 | }; |
| 525 | |
Daniel Willmann | 2c9540c | 2012-05-14 18:43:23 +0200 | [diff] [blame] | 526 | extern const struct value_string bts_loc_fix_names[]; |
| 527 | |
Daniel Willmann | 8c3483f | 2011-08-05 13:51:27 +0200 | [diff] [blame] | 528 | struct bts_location { |
| 529 | struct llist_head list; |
| 530 | time_t tstamp; |
| 531 | enum bts_loc_fix valid; |
| 532 | double lat; |
| 533 | double lon; |
| 534 | double height; |
| 535 | }; |
| 536 | |
Harald Welte | 3da6b3f | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 537 | /* One BTS */ |
| 538 | struct gsm_bts { |
| 539 | /* list header in net->bts_list */ |
| 540 | struct llist_head list; |
| 541 | |
Daniel Willmann | 8c3483f | 2011-08-05 13:51:27 +0200 | [diff] [blame] | 542 | /* Geographical location of the BTS */ |
| 543 | struct llist_head loc_list; |
| 544 | |
Harald Welte | 3da6b3f | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 545 | /* number of ths BTS in network */ |
| 546 | uint8_t nr; |
| 547 | /* human readable name / description */ |
| 548 | char *description; |
| 549 | /* Cell Identity */ |
| 550 | uint16_t cell_identity; |
| 551 | /* location area code of this BTS */ |
| 552 | uint16_t location_area_code; |
| 553 | /* Training Sequence Code */ |
| 554 | uint8_t tsc; |
| 555 | /* Base Station Identification Code (BSIC) */ |
| 556 | uint8_t bsic; |
| 557 | /* type of BTS */ |
| 558 | enum gsm_bts_type type; |
| 559 | struct gsm_bts_model *model; |
| 560 | enum gsm_band band; |
| 561 | /* maximum Tx power that the MS is permitted to use in this cell */ |
| 562 | int ms_max_power; |
| 563 | |
| 564 | /* how do we talk OML with this TRX? */ |
| 565 | struct gsm_e1_subslot oml_e1_link; |
| 566 | uint8_t oml_tei; |
| 567 | struct e1inp_sign_link *oml_link; |
| 568 | |
| 569 | /* Abis network management O&M handle */ |
| 570 | struct abis_nm_h *nmh; |
Harald Welte | 69f6f81 | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 571 | |
| 572 | struct gsm_abis_mo mo; |
Harald Welte | 3da6b3f | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 573 | |
| 574 | /* number of this BTS on given E1 link */ |
| 575 | uint8_t bts_nr; |
| 576 | |
| 577 | /* paging state and control */ |
| 578 | struct gsm_bts_paging_state paging; |
| 579 | |
| 580 | /* CCCH is on C0 */ |
| 581 | struct gsm_bts_trx *c0; |
| 582 | |
| 583 | struct { |
Harald Welte | 69f6f81 | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 584 | struct gsm_abis_mo mo; |
Harald Welte | 3da6b3f | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 585 | } site_mgr; |
| 586 | |
| 587 | /* bitmask of all SI that are present/valid in si_buf */ |
| 588 | uint32_t si_valid; |
| 589 | /* buffers where we put the pre-computed SI */ |
| 590 | sysinfo_buf_t si_buf[_MAX_SYSINFO_TYPE]; |
| 591 | |
Gus Bourg | f9dc16b | 2011-12-02 10:18:17 +0100 | [diff] [blame] | 592 | /* TimeZone hours, mins, and bts specific */ |
Harald Welte | 5c3abf9 | 2012-07-08 16:48:11 +0200 | [diff] [blame] | 593 | struct { |
| 594 | int hr; |
| 595 | int mn; |
| 596 | int override; |
| 597 | } tz; |
Gus Bourg | f9dc16b | 2011-12-02 10:18:17 +0100 | [diff] [blame] | 598 | |
Harald Welte | 3da6b3f | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 599 | /* ip.accesss Unit ID's have Site/BTS/TRX layout */ |
| 600 | union { |
| 601 | struct { |
| 602 | uint16_t site_id; |
| 603 | uint16_t bts_id; |
| 604 | uint32_t flags; |
Harald Welte | 8b3c595 | 2013-03-12 13:57:05 +0100 | [diff] [blame] | 605 | uint32_t rsl_ip; |
Harald Welte | 3da6b3f | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 606 | } ip_access; |
| 607 | struct { |
| 608 | struct { |
Harald Welte | 69f6f81 | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 609 | struct gsm_abis_mo mo; |
Harald Welte | 3da6b3f | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 610 | } cclk; |
| 611 | struct { |
Harald Welte | 69f6f81 | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 612 | struct gsm_abis_mo mo; |
Harald Welte | 3da6b3f | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 613 | } rack; |
| 614 | struct gsm_envabtse envabtse[4]; |
| 615 | } bs11; |
| 616 | struct { |
| 617 | struct { |
Harald Welte | 69f6f81 | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 618 | struct gsm_abis_mo mo; |
Harald Welte | 3da6b3f | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 619 | struct llist_head conn_groups; |
| 620 | } is; |
| 621 | struct { |
Harald Welte | 69f6f81 | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 622 | struct gsm_abis_mo mo; |
Harald Welte | 3da6b3f | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 623 | struct llist_head conn_groups; |
| 624 | } con; |
| 625 | struct { |
Harald Welte | 69f6f81 | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 626 | struct gsm_abis_mo mo; |
Harald Welte | 3da6b3f | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 627 | } dp; |
| 628 | struct { |
Harald Welte | 69f6f81 | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 629 | struct gsm_abis_mo mo; |
Harald Welte | 3da6b3f | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 630 | } tf; |
| 631 | } rbs2000; |
| 632 | struct { |
Harald Welte | 3a070b9 | 2011-07-28 00:22:17 +0200 | [diff] [blame] | 633 | uint8_t bts_type; |
Holger Hans Peter Freyther | a6ca237 | 2012-03-02 14:14:33 +0100 | [diff] [blame] | 634 | unsigned int configured:1, |
| 635 | skip_reset:1, |
| 636 | did_reset:1, |
| 637 | wait_reset:1; |
Harald Welte | 3a070b9 | 2011-07-28 00:22:17 +0200 | [diff] [blame] | 638 | struct osmo_timer_list reset_timer; |
| 639 | } nokia; |
Harald Welte | 3da6b3f | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 640 | }; |
| 641 | |
| 642 | /* Not entirely sure how ip.access specific this is */ |
| 643 | struct { |
| 644 | enum bts_gprs_mode mode; |
| 645 | struct { |
Harald Welte | 69f6f81 | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 646 | struct gsm_abis_mo mo; |
Harald Welte | 3da6b3f | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 647 | uint16_t nsei; |
| 648 | uint8_t timer[7]; |
| 649 | } nse; |
| 650 | struct { |
Harald Welte | 69f6f81 | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 651 | struct gsm_abis_mo mo; |
Harald Welte | 3da6b3f | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 652 | uint16_t bvci; |
| 653 | uint8_t timer[11]; |
Harald Welte | 1c6955a | 2012-06-28 08:43:14 +0200 | [diff] [blame] | 654 | struct gprs_rlc_cfg rlc_cfg; |
Harald Welte | 3da6b3f | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 655 | } cell; |
| 656 | struct gsm_bts_gprs_nsvc nsvc[2]; |
| 657 | uint8_t rac; |
Andreas Eversberg | a4fa21c | 2013-03-16 16:31:26 +0100 | [diff] [blame] | 658 | uint8_t net_ctrl_ord; |
Harald Welte | 3da6b3f | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 659 | } gprs; |
| 660 | |
| 661 | /* RACH NM values */ |
| 662 | int rach_b_thresh; |
| 663 | int rach_ldavg_slots; |
| 664 | |
| 665 | /* transceivers */ |
| 666 | int num_trx; |
| 667 | struct llist_head trx_list; |
| 668 | |
| 669 | #ifdef ROLE_BSC |
| 670 | /* Abis NM queue */ |
| 671 | struct llist_head abis_queue; |
| 672 | int abis_nm_pend; |
| 673 | |
| 674 | struct gsm_network *network; |
| 675 | |
| 676 | /* should the channel allocator allocate channels from high TRX to TRX0, |
| 677 | * rather than starting from TRX0 and go upwards? */ |
| 678 | int chan_alloc_reverse; |
| 679 | |
| 680 | enum neigh_list_manual_mode neigh_list_manual_mode; |
| 681 | /* parameters from which we build SYSTEM INFORMATION */ |
| 682 | struct { |
| 683 | struct gsm48_rach_control rach_control; |
| 684 | uint8_t ncc_permitted; |
| 685 | struct gsm48_cell_sel_par cell_sel_par; |
| 686 | struct gsm48_si_selection_params cell_ro_sel_par; /* rest octet */ |
| 687 | struct gsm48_cell_options cell_options; |
| 688 | struct gsm48_control_channel_descr chan_desc; |
| 689 | struct bitvec neigh_list; |
| 690 | struct bitvec cell_alloc; |
| 691 | struct bitvec si5_neigh_list; |
| 692 | struct { |
| 693 | /* bitmask large enough for all possible ARFCN's */ |
| 694 | uint8_t neigh_list[1024/8]; |
| 695 | uint8_t cell_alloc[1024/8]; |
| 696 | /* If the user wants a different neighbor list in SI5 than in SI2 */ |
| 697 | uint8_t si5_neigh_list[1024/8]; |
| 698 | } data; |
| 699 | } si_common; |
| 700 | |
| 701 | /* do we use static (user-defined) system information messages? (bitmask) */ |
| 702 | uint32_t si_mode_static; |
Holger Hans Peter Freyther | 1079916 | 2012-07-20 10:27:31 +0200 | [diff] [blame] | 703 | |
| 704 | /* exclude the BTS from the global RF Lock handling */ |
| 705 | int excl_from_rf_lock; |
Harald Welte | 3da6b3f | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 706 | #endif /* ROLE_BSC */ |
Harald Welte | c6ed928 | 2011-06-06 18:31:20 +0200 | [diff] [blame] | 707 | void *role; |
Harald Welte | 3da6b3f | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 708 | }; |
| 709 | |
| 710 | |
Harald Welte | c788128 | 2011-06-05 13:31:33 +0200 | [diff] [blame] | 711 | struct gsm_bts *gsm_bts_alloc(void *talloc_ctx); |
Harald Welte | 3da6b3f | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 712 | struct gsm_bts_trx *gsm_bts_trx_alloc(struct gsm_bts *bts); |
| 713 | |
Harald Welte | 6073216 | 2011-09-19 14:21:51 +0200 | [diff] [blame] | 714 | struct gsm_bts_trx *gsm_bts_trx_num(const struct gsm_bts *bts, int num); |
Harald Welte | 3da6b3f | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 715 | |
Harald Welte | 2addf85 | 2012-08-17 12:42:06 +0200 | [diff] [blame] | 716 | |
| 717 | const struct value_string gsm_pchant_names[10]; |
| 718 | const struct value_string gsm_pchant_descs[10]; |
| 719 | const struct value_string gsm_lchant_names[6]; |
Harald Welte | 3da6b3f | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 720 | const char *gsm_pchan_name(enum gsm_phys_chan_config c); |
| 721 | enum gsm_phys_chan_config gsm_pchan_parse(const char *name); |
| 722 | const char *gsm_lchant_name(enum gsm_chan_t c); |
| 723 | const char *gsm_chreq_name(enum gsm_chreq_reason_t c); |
Harald Welte | 6073216 | 2011-09-19 14:21:51 +0200 | [diff] [blame] | 724 | char *gsm_trx_name(const struct gsm_bts_trx *trx); |
| 725 | char *gsm_ts_name(const struct gsm_bts_trx_ts *ts); |
| 726 | char *gsm_lchan_name(const struct gsm_lchan *lchan); |
Harald Welte | 3da6b3f | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 727 | const char *gsm_lchans_name(enum gsm_lchan_state s); |
| 728 | |
Harald Welte | 3da6b3f | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 729 | |
Harald Welte | 452119d | 2011-06-29 16:49:03 +0200 | [diff] [blame] | 730 | void gsm_abis_mo_reset(struct gsm_abis_mo *mo); |
| 731 | |
Harald Welte | c6ed928 | 2011-06-06 18:31:20 +0200 | [diff] [blame] | 732 | struct gsm_abis_mo * |
| 733 | gsm_objclass2mo(struct gsm_bts *bts, uint8_t obj_class, |
Harald Welte | 6073216 | 2011-09-19 14:21:51 +0200 | [diff] [blame] | 734 | const struct abis_om_obj_inst *obj_inst); |
Harald Welte | c6ed928 | 2011-06-06 18:31:20 +0200 | [diff] [blame] | 735 | |
| 736 | struct gsm_nm_state * |
| 737 | gsm_objclass2nmstate(struct gsm_bts *bts, uint8_t obj_class, |
Harald Welte | 6073216 | 2011-09-19 14:21:51 +0200 | [diff] [blame] | 738 | const struct abis_om_obj_inst *obj_inst); |
Harald Welte | c6ed928 | 2011-06-06 18:31:20 +0200 | [diff] [blame] | 739 | void * |
| 740 | gsm_objclass2obj(struct gsm_bts *bts, uint8_t obj_class, |
Harald Welte | 6073216 | 2011-09-19 14:21:51 +0200 | [diff] [blame] | 741 | const struct abis_om_obj_inst *obj_inst); |
Harald Welte | c6ed928 | 2011-06-06 18:31:20 +0200 | [diff] [blame] | 742 | |
Harald Welte | 452119d | 2011-06-29 16:49:03 +0200 | [diff] [blame] | 743 | /* reset the state of all MO in the BTS */ |
| 744 | void gsm_bts_mo_reset(struct gsm_bts *bts); |
| 745 | |
Harald Welte | e6d51f9 | 2011-06-25 10:02:33 +0200 | [diff] [blame] | 746 | uint8_t gsm_ts2chan_nr(const struct gsm_bts_trx_ts *ts, uint8_t lchan_nr); |
| 747 | uint8_t gsm_lchan2chan_nr(const struct gsm_lchan *lchan); |
| 748 | |
Holger Hans Peter Freyther | 1c14d96 | 2011-06-09 21:48:49 +0200 | [diff] [blame] | 749 | /* |
| 750 | * help with parsing regexps |
| 751 | */ |
| 752 | int gsm_parse_reg(void *ctx, regex_t *reg, char **str, |
| 753 | int argc, const char **argv) __attribute__ ((warn_unused_result)); |
| 754 | |
| 755 | |
| 756 | |
Harald Welte | 3da6b3f | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 757 | #endif |