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