Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 1 | #ifndef _GSM_DATA_SHAREDH |
| 2 | #define _GSM_DATA_SHAREDH |
| 3 | |
Holger Hans Peter Freyther | 06c9da6 | 2011-06-09 21:48:49 +0200 | [diff] [blame] | 4 | #include <regex.h> |
Harald Welte | 6be350c | 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 | 3300c01 | 2011-06-05 13:31:33 +0200 | [diff] [blame] | 18 | #include <osmocom/gsm/protocol/gsm_12_21.h> |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 19 | |
Harald Welte | 0eae613 | 2011-08-24 13:52:07 +0200 | [diff] [blame] | 20 | #include <osmocom/abis/e1_input.h> |
| 21 | |
Holger Hans Peter Freyther | 8ec4952 | 2011-08-15 15:53:00 +0200 | [diff] [blame] | 22 | struct osmo_bsc_data; |
| 23 | |
Harald Welte | 6be350c | 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 | 135a6bd | 2011-09-04 13:53:26 +0200 | [diff] [blame] | 81 | struct osmo_rtp_socket; |
Harald Welte | 6be350c | 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 | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 92 | struct gsm_abis_mo { |
Harald Welte | 3300c01 | 2011-06-05 13:31:33 +0200 | [diff] [blame] | 93 | uint8_t obj_class; |
| 94 | struct abis_om_obj_inst obj_inst; |
Harald Welte | d64c0bc | 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 | 32bc116 | 2011-06-06 18:58:48 +0200 | [diff] [blame] | 98 | struct gsm_bts *bts; |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 99 | }; |
| 100 | |
Harald Welte | 6be350c | 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 | ded0268 | 2012-01-15 00:02:17 +0100 | [diff] [blame] | 115 | LCHAN_S_ACT_REQ, /* channel activation requested */ |
Harald Welte | 6be350c | 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 | c7921c9 | 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 | f3b5932 | 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 | c7921c9 | 2011-06-29 10:38:34 +0200 | [diff] [blame] | 150 | /* /BTS ONLY */ |
| 151 | |
Harald Welte | 6be350c | 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 | afa0ad1 | 2012-04-18 18:58:36 +0200 | [diff] [blame] | 180 | int sacch_deact; |
Holger Hans Peter Freyther | dfcfe65 | 2011-12-27 20:49:53 +0100 | [diff] [blame] | 181 | |
| 182 | /** GSM 08.58 9.3.20 */ |
| 183 | int release_mode; |
Harald Welte | 6be350c | 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 | 135a6bd | 2011-09-04 13:53:26 +0200 | [diff] [blame] | 194 | #ifdef ROLE_BSC |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 195 | struct rtp_socket *rtp_socket; |
Harald Welte | 135a6bd | 2011-09-04 13:53:26 +0200 | [diff] [blame] | 196 | #else |
| 197 | struct osmo_rtp_socket *rtp_socket; |
| 198 | #endif |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 199 | } abis_ip; |
| 200 | |
Harald Welte | 2c1ae47 | 2011-06-26 14:13:37 +0200 | [diff] [blame] | 201 | uint8_t rqd_ta; |
| 202 | |
Harald Welte | 6be350c | 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 | e8bd9e8 | 2011-08-10 23:26:33 +0200 | [diff] [blame] | 207 | struct osmo_timer_list act_timer; |
Harald Welte | 6be350c | 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 | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 218 | |
| 219 | struct gsm_subscriber_connection *conn; |
Harald Welte | f6093a4 | 2011-06-25 10:02:33 +0200 | [diff] [blame] | 220 | #else |
| 221 | struct lapdm_channel lapdm_ch; |
Harald Welte | 135a6bd | 2011-09-04 13:53:26 +0200 | [diff] [blame] | 222 | struct llist_head dl_tch_queue; |
Harald Welte | 2c1ae47 | 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 | c7921c9 | 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 | f3b5932 | 2011-09-06 22:14:43 +0200 | [diff] [blame] | 248 | struct { |
| 249 | struct amr_multirate_conf amr_mr; |
Harald Welte | 4329099 | 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 | f3b5932 | 2011-09-06 22:14:43 +0200 | [diff] [blame] | 254 | } tch; |
Harald Welte | 5d52c97 | 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 | 46cb851 | 2012-04-19 23:13:35 +0200 | [diff] [blame] | 257 | uint8_t loopback; |
Harald Welte | 704cb86 | 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 | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 266 | #endif |
| 267 | }; |
| 268 | |
Harald Welte | 6be350c | 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 | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 279 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 280 | struct tlv_parsed nm_attr; |
| 281 | uint8_t nm_chan_comb; |
Harald Welte | 135a648 | 2011-05-30 12:09:13 +0200 | [diff] [blame] | 282 | int tsc; /* -1 == use BTS TSC */ |
Harald Welte | 6be350c | 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 | 523a99d | 2012-01-17 15:52:45 +0100 | [diff] [blame] | 316 | #ifdef ROLE_BSC |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 317 | struct e1inp_sign_link *rsl_link; |
Holger Hans Peter Freyther | 523a99d | 2012-01-17 15:52:45 +0100 | [diff] [blame] | 318 | #else |
| 319 | struct ipabis_link *rsl_link; |
| 320 | #endif |
Harald Welte | 6be350c | 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 | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 324 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 325 | struct tlv_parsed nm_attr; |
| 326 | struct { |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 327 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 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 | d134cc7 | 2011-06-07 00:12:53 +0200 | [diff] [blame] | 334 | struct { |
| 335 | void *l1h; |
| 336 | } role_bts; |
| 337 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 338 | union { |
| 339 | struct { |
| 340 | struct { |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 341 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 342 | } bbsig; |
| 343 | struct { |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 344 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 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 | 1664602 | 2011-07-28 00:01:50 +0200 | [diff] [blame] | 364 | GSM_BTS_TYPE_NOKIA_SITE, |
Harald Welte | f383aa1 | 2012-07-02 19:51:55 +0200 | [diff] [blame^] | 365 | GSM_BTS_TYPE_OSMO_SYSMO, |
Harald Welte | 6be350c | 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 | ed5cacb | 2011-08-17 22:44:07 +0200 | [diff] [blame] | 380 | void (*e1line_bind_ops)(struct e1inp_line *line); |
| 381 | |
Harald Welte | 6be350c | 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 | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 421 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 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 | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 434 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 435 | }; |
| 436 | |
Harald Welte | 019f913 | 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 | 6be350c | 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 | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 518 | |
| 519 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 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 | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 531 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 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 | 1c5dd2c | 2011-12-02 10:18:17 +0100 | [diff] [blame] | 539 | /* TimeZone hours, mins, and bts specific */ |
| 540 | int tzhr; |
| 541 | int tzmn; |
| 542 | int tz_bts_specific; |
| 543 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 544 | /* ip.accesss Unit ID's have Site/BTS/TRX layout */ |
| 545 | union { |
| 546 | struct { |
| 547 | uint16_t site_id; |
| 548 | uint16_t bts_id; |
| 549 | uint32_t flags; |
| 550 | } ip_access; |
| 551 | struct { |
| 552 | struct { |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 553 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 554 | } cclk; |
| 555 | struct { |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 556 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 557 | } rack; |
| 558 | struct gsm_envabtse envabtse[4]; |
| 559 | } bs11; |
| 560 | struct { |
| 561 | struct { |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 562 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 563 | struct llist_head conn_groups; |
| 564 | } is; |
| 565 | struct { |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 566 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 567 | struct llist_head conn_groups; |
| 568 | } con; |
| 569 | struct { |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 570 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 571 | } dp; |
| 572 | struct { |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 573 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 574 | } tf; |
| 575 | } rbs2000; |
| 576 | struct { |
| 577 | unsigned long serno; |
| 578 | } hsl; |
Harald Welte | c8755af | 2011-07-28 00:22:17 +0200 | [diff] [blame] | 579 | struct { |
| 580 | uint8_t bts_type; |
Holger Hans Peter Freyther | 3e60348 | 2012-03-02 14:14:33 +0100 | [diff] [blame] | 581 | unsigned int configured:1, |
| 582 | skip_reset:1, |
| 583 | did_reset:1, |
| 584 | wait_reset:1; |
Harald Welte | c8755af | 2011-07-28 00:22:17 +0200 | [diff] [blame] | 585 | struct osmo_timer_list reset_timer; |
| 586 | } nokia; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 587 | }; |
| 588 | |
| 589 | /* Not entirely sure how ip.access specific this is */ |
| 590 | struct { |
| 591 | enum bts_gprs_mode mode; |
| 592 | struct { |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 593 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 594 | uint16_t nsei; |
| 595 | uint8_t timer[7]; |
| 596 | } nse; |
| 597 | struct { |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 598 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 599 | uint16_t bvci; |
| 600 | uint8_t timer[11]; |
Harald Welte | 019f913 | 2012-06-28 08:43:14 +0200 | [diff] [blame] | 601 | struct gprs_rlc_cfg rlc_cfg; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 602 | } cell; |
| 603 | struct gsm_bts_gprs_nsvc nsvc[2]; |
| 604 | uint8_t rac; |
| 605 | } gprs; |
| 606 | |
| 607 | /* RACH NM values */ |
| 608 | int rach_b_thresh; |
| 609 | int rach_ldavg_slots; |
| 610 | |
| 611 | /* transceivers */ |
| 612 | int num_trx; |
| 613 | struct llist_head trx_list; |
| 614 | |
| 615 | #ifdef ROLE_BSC |
| 616 | /* Abis NM queue */ |
| 617 | struct llist_head abis_queue; |
| 618 | int abis_nm_pend; |
| 619 | |
| 620 | struct gsm_network *network; |
| 621 | |
| 622 | /* should the channel allocator allocate channels from high TRX to TRX0, |
| 623 | * rather than starting from TRX0 and go upwards? */ |
| 624 | int chan_alloc_reverse; |
| 625 | |
| 626 | enum neigh_list_manual_mode neigh_list_manual_mode; |
| 627 | /* parameters from which we build SYSTEM INFORMATION */ |
| 628 | struct { |
| 629 | struct gsm48_rach_control rach_control; |
| 630 | uint8_t ncc_permitted; |
| 631 | struct gsm48_cell_sel_par cell_sel_par; |
| 632 | struct gsm48_si_selection_params cell_ro_sel_par; /* rest octet */ |
| 633 | struct gsm48_cell_options cell_options; |
| 634 | struct gsm48_control_channel_descr chan_desc; |
| 635 | struct bitvec neigh_list; |
| 636 | struct bitvec cell_alloc; |
| 637 | struct bitvec si5_neigh_list; |
| 638 | struct { |
| 639 | /* bitmask large enough for all possible ARFCN's */ |
| 640 | uint8_t neigh_list[1024/8]; |
| 641 | uint8_t cell_alloc[1024/8]; |
| 642 | /* If the user wants a different neighbor list in SI5 than in SI2 */ |
| 643 | uint8_t si5_neigh_list[1024/8]; |
| 644 | } data; |
| 645 | } si_common; |
| 646 | |
| 647 | /* do we use static (user-defined) system information messages? (bitmask) */ |
| 648 | uint32_t si_mode_static; |
| 649 | #endif /* ROLE_BSC */ |
Harald Welte | 978714d | 2011-06-06 18:31:20 +0200 | [diff] [blame] | 650 | void *role; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 651 | }; |
| 652 | |
| 653 | |
Harald Welte | 3300c01 | 2011-06-05 13:31:33 +0200 | [diff] [blame] | 654 | struct gsm_bts *gsm_bts_alloc(void *talloc_ctx); |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 655 | struct gsm_bts_trx *gsm_bts_trx_alloc(struct gsm_bts *bts); |
| 656 | |
Harald Welte | 4f8ad53 | 2011-09-19 14:21:51 +0200 | [diff] [blame] | 657 | struct gsm_bts_trx *gsm_bts_trx_num(const struct gsm_bts *bts, int num); |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 658 | |
| 659 | const char *gsm_pchan_name(enum gsm_phys_chan_config c); |
| 660 | enum gsm_phys_chan_config gsm_pchan_parse(const char *name); |
| 661 | const char *gsm_lchant_name(enum gsm_chan_t c); |
| 662 | const char *gsm_chreq_name(enum gsm_chreq_reason_t c); |
Harald Welte | 4f8ad53 | 2011-09-19 14:21:51 +0200 | [diff] [blame] | 663 | char *gsm_trx_name(const struct gsm_bts_trx *trx); |
| 664 | char *gsm_ts_name(const struct gsm_bts_trx_ts *ts); |
| 665 | char *gsm_lchan_name(const struct gsm_lchan *lchan); |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 666 | const char *gsm_lchans_name(enum gsm_lchan_state s); |
| 667 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 668 | |
Harald Welte | b784998 | 2011-06-29 16:49:03 +0200 | [diff] [blame] | 669 | void gsm_abis_mo_reset(struct gsm_abis_mo *mo); |
| 670 | |
Harald Welte | 978714d | 2011-06-06 18:31:20 +0200 | [diff] [blame] | 671 | struct gsm_abis_mo * |
| 672 | gsm_objclass2mo(struct gsm_bts *bts, uint8_t obj_class, |
Harald Welte | 4f8ad53 | 2011-09-19 14:21:51 +0200 | [diff] [blame] | 673 | const struct abis_om_obj_inst *obj_inst); |
Harald Welte | 978714d | 2011-06-06 18:31:20 +0200 | [diff] [blame] | 674 | |
| 675 | struct gsm_nm_state * |
| 676 | gsm_objclass2nmstate(struct gsm_bts *bts, uint8_t obj_class, |
Harald Welte | 4f8ad53 | 2011-09-19 14:21:51 +0200 | [diff] [blame] | 677 | const struct abis_om_obj_inst *obj_inst); |
Harald Welte | 978714d | 2011-06-06 18:31:20 +0200 | [diff] [blame] | 678 | void * |
| 679 | gsm_objclass2obj(struct gsm_bts *bts, uint8_t obj_class, |
Harald Welte | 4f8ad53 | 2011-09-19 14:21:51 +0200 | [diff] [blame] | 680 | const struct abis_om_obj_inst *obj_inst); |
Harald Welte | 978714d | 2011-06-06 18:31:20 +0200 | [diff] [blame] | 681 | |
Harald Welte | b784998 | 2011-06-29 16:49:03 +0200 | [diff] [blame] | 682 | /* reset the state of all MO in the BTS */ |
| 683 | void gsm_bts_mo_reset(struct gsm_bts *bts); |
| 684 | |
Harald Welte | f6093a4 | 2011-06-25 10:02:33 +0200 | [diff] [blame] | 685 | uint8_t gsm_ts2chan_nr(const struct gsm_bts_trx_ts *ts, uint8_t lchan_nr); |
| 686 | uint8_t gsm_lchan2chan_nr(const struct gsm_lchan *lchan); |
| 687 | |
Holger Hans Peter Freyther | 06c9da6 | 2011-06-09 21:48:49 +0200 | [diff] [blame] | 688 | /* |
| 689 | * help with parsing regexps |
| 690 | */ |
| 691 | int gsm_parse_reg(void *ctx, regex_t *reg, char **str, |
| 692 | int argc, const char **argv) __attribute__ ((warn_unused_result)); |
| 693 | |
| 694 | |
| 695 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 696 | #endif |