blob: 3ba7a4bef827fdff824a2c13053507f195bbce28 [file] [log] [blame]
Harald Welte6be350c2011-05-25 13:10:08 +02001#ifndef _GSM_DATA_SHAREDH
2#define _GSM_DATA_SHAREDH
3
Holger Hans Peter Freyther06c9da62011-06-09 21:48:49 +02004#include <regex.h>
Harald Welte6be350c2011-05-25 13:10:08 +02005#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 Welte3300c012011-06-05 13:31:33 +020018#include <osmocom/gsm/protocol/gsm_12_21.h>
Harald Welte6be350c2011-05-25 13:10:08 +020019
Harald Welte0eae6132011-08-24 13:52:07 +020020#include <osmocom/abis/e1_input.h>
21
Holger Hans Peter Freyther8ec49522011-08-15 15:53:00 +020022struct osmo_bsc_data;
23
Harald Welte6be350c2011-05-25 13:10:08 +020024struct osmo_bsc_sccp_con;
25struct gsm_sms_queue;
26
27/* RRLP mode of operation */
28enum 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 */
36enum 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
59enum gsm_hooks {
60 GSM_HOOK_NM_SWLOAD,
61 GSM_HOOK_RR_PAGING,
62 GSM_HOOK_RR_SECURITY,
63};
64
65enum gsm_paging_event {
66 GSM_PAGING_SUCCEEDED,
67 GSM_PAGING_EXPIRED,
68 GSM_PAGING_OOM,
69 GSM_PAGING_BUSY,
70};
71
72enum bts_gprs_mode {
73 BTS_GPRS_NONE = 0,
74 BTS_GPRS_GPRS = 1,
75 BTS_GPRS_EGPRS = 2,
76};
77
78struct gsm_lchan;
79struct gsm_subscriber;
80struct gsm_mncc;
Harald Welte135a6bd2011-09-04 13:53:26 +020081struct osmo_rtp_socket;
Harald Welte6be350c2011-05-25 13:10:08 +020082struct rtp_socket;
83struct bsc_api;
84
85/* Network Management State */
86struct gsm_nm_state {
87 uint8_t operational;
88 uint8_t administrative;
89 uint8_t availability;
90};
91
Harald Welted64c0bc2011-05-30 12:07:53 +020092struct gsm_abis_mo {
Harald Welte3300c012011-06-05 13:31:33 +020093 uint8_t obj_class;
94 struct abis_om_obj_inst obj_inst;
Harald Welted64c0bc2011-05-30 12:07:53 +020095 const char *name;
96 struct gsm_nm_state nm_state;
97 struct tlv_parsed *nm_attr;
Harald Welte32bc1162011-06-06 18:58:48 +020098 struct gsm_bts *bts;
Harald Welted64c0bc2011-05-30 12:07:53 +020099};
100
Harald Welte6be350c2011-05-25 13:10:08 +0200101#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 */
113enum gsm_lchan_state {
114 LCHAN_S_NONE, /* channel is not active */
Holger Hans Peter Freytherded02682012-01-15 00:02:17 +0100115 LCHAN_S_ACT_REQ, /* channel activation requested */
Harald Welte6be350c2011-05-25 13:10:08 +0200116 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 Weltec7921c92011-06-29 10:38:34 +0200122/* 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
127struct 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 Weltef3b59322011-09-06 22:14:43 +0200139
140struct amr_mode {
141 uint8_t mode;
142 uint8_t threshold;
143 uint8_t hysteresis;
144};
145struct amr_multirate_conf {
146 uint8_t gsm48_ie[2];
147 struct amr_mode mode[4];
148 uint8_t num_modes;
149};
Harald Weltec7921c92011-06-29 10:38:34 +0200150/* /BTS ONLY */
151
Harald Welte6be350c2011-05-25 13:10:08 +0200152struct 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 Freytherafa0ad12012-04-18 18:58:36 +0200180 int sacch_deact;
Holger Hans Peter Freytherdfcfe652011-12-27 20:49:53 +0100181
182 /** GSM 08.58 9.3.20 */
183 int release_mode;
Harald Welte6be350c2011-05-25 13:10:08 +0200184
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 Welte135a6bd2011-09-04 13:53:26 +0200194#ifdef ROLE_BSC
Harald Welte6be350c2011-05-25 13:10:08 +0200195 struct rtp_socket *rtp_socket;
Harald Welte135a6bd2011-09-04 13:53:26 +0200196#else
197 struct osmo_rtp_socket *rtp_socket;
198#endif
Harald Welte6be350c2011-05-25 13:10:08 +0200199 } abis_ip;
200
Harald Welte2c1ae472011-06-26 14:13:37 +0200201 uint8_t rqd_ta;
202
Harald Welte6be350c2011-05-25 13:10:08 +0200203#ifdef ROLE_BSC
204 struct osmo_timer_list T3101;
205 struct osmo_timer_list T3111;
206 struct osmo_timer_list error_timer;
Harald Weltee8bd9e82011-08-10 23:26:33 +0200207 struct osmo_timer_list act_timer;
Harald Welte6be350c2011-05-25 13:10:08 +0200208
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 Welte6be350c2011-05-25 13:10:08 +0200218
219 struct gsm_subscriber_connection *conn;
Harald Weltef6093a42011-06-25 10:02:33 +0200220#else
221 struct lapdm_channel lapdm_ch;
Harald Welte135a6bd2011-09-04 13:53:26 +0200222 struct llist_head dl_tch_queue;
Harald Welte2c1ae472011-06-26 14:13:37 +0200223 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 Weltec7921c92011-06-29 10:38:34 +0200230 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 Weltef3b59322011-09-06 22:14:43 +0200248 struct {
249 struct amr_multirate_conf amr_mr;
Harald Welte43290992011-09-07 12:41:38 +0200250 struct {
251 uint8_t buf[16];
252 uint8_t len;
253 } last_sid;
Harald Weltef3b59322011-09-06 22:14:43 +0200254 } tch;
Harald Welte5d52c972012-04-08 20:23:28 +0200255 /* BTS-side ciphering state (rx only, bi-directional, ...) */
256 uint8_t ciph_state;
Harald Welte46cb8512012-04-19 23:13:35 +0200257 uint8_t loopback;
Harald Welte704cb862012-06-16 14:57:08 +0800258 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 Welte6be350c2011-05-25 13:10:08 +0200266#endif
267};
268
Harald Welte6be350c2011-05-25 13:10:08 +0200269#define TS_F_PDCH_MODE 0x1000
270/* One Timeslot in a TRX */
271struct 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 Welted64c0bc2011-05-30 12:07:53 +0200279 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200280 struct tlv_parsed nm_attr;
281 uint8_t nm_chan_comb;
Harald Welte135a6482011-05-30 12:09:13 +0200282 int tsc; /* -1 == use BTS TSC */
Harald Welte6be350c2011-05-25 13:10:08 +0200283
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 */
304struct 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 Freyther523a99d2012-01-17 15:52:45 +0100316#ifdef ROLE_BSC
Harald Welte6be350c2011-05-25 13:10:08 +0200317 struct e1inp_sign_link *rsl_link;
Holger Hans Peter Freyther523a99d2012-01-17 15:52:45 +0100318#else
319 struct ipabis_link *rsl_link;
320#endif
Harald Welte6be350c2011-05-25 13:10:08 +0200321 /* Some BTS (specifically Ericsson RBS) have a per-TRX OML Link */
322 struct e1inp_sign_link *oml_link;
323
Harald Welted64c0bc2011-05-30 12:07:53 +0200324 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200325 struct tlv_parsed nm_attr;
326 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200327 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200328 } bb_transc;
329
330 uint16_t arfcn;
331 int nominal_power; /* in dBm */
332 unsigned int max_power_red; /* in actual dB */
333
Harald Welted134cc72011-06-07 00:12:53 +0200334 struct {
335 void *l1h;
336 } role_bts;
337
Harald Welte6be350c2011-05-25 13:10:08 +0200338 union {
339 struct {
340 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200341 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200342 } bbsig;
343 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200344 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200345 } 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
358enum 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 Spaar16646022011-07-28 00:01:50 +0200364 GSM_BTS_TYPE_NOKIA_SITE,
Harald Weltef383aa12012-07-02 19:51:55 +0200365 GSM_BTS_TYPE_OSMO_SYSMO,
Harald Welte6be350c2011-05-25 13:10:08 +0200366};
367
368struct vty;
369
370struct 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 Ayusoed5cacb2011-08-17 22:44:07 +0200380 void (*e1line_bind_ops)(struct e1inp_line *line);
381
Harald Welte6be350c2011-05-25 13:10:08 +0200382 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
392enum 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 */
405struct 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
420struct gsm_envabtse {
Harald Welted64c0bc2011-05-30 12:07:53 +0200421 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200422};
423
424struct 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 Welted64c0bc2011-05-30 12:07:53 +0200434 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200435};
436
Harald Welte019f9132012-06-28 08:43:14 +0200437enum 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
452enum 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
469struct 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 Welte6be350c2011-05-25 13:10:08 +0200481enum 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 */
488struct 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 Welted64c0bc2011-05-30 12:07:53 +0200518
519 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200520
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 Welted64c0bc2011-05-30 12:07:53 +0200531 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200532 } 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 Bourg1c5dd2c2011-12-02 10:18:17 +0100539 /* TimeZone hours, mins, and bts specific */
Harald Welte45f91712012-07-08 16:48:11 +0200540 struct {
541 int hr;
542 int mn;
543 int override;
544 } tz;
Gus Bourg1c5dd2c2011-12-02 10:18:17 +0100545
Harald Welte6be350c2011-05-25 13:10:08 +0200546 /* 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 Welted64c0bc2011-05-30 12:07:53 +0200555 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200556 } cclk;
557 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200558 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200559 } rack;
560 struct gsm_envabtse envabtse[4];
561 } bs11;
562 struct {
563 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200564 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200565 struct llist_head conn_groups;
566 } is;
567 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200568 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200569 struct llist_head conn_groups;
570 } con;
571 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200572 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200573 } dp;
574 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200575 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200576 } tf;
577 } rbs2000;
578 struct {
579 unsigned long serno;
580 } hsl;
Harald Weltec8755af2011-07-28 00:22:17 +0200581 struct {
582 uint8_t bts_type;
Holger Hans Peter Freyther3e603482012-03-02 14:14:33 +0100583 unsigned int configured:1,
584 skip_reset:1,
585 did_reset:1,
586 wait_reset:1;
Harald Weltec8755af2011-07-28 00:22:17 +0200587 struct osmo_timer_list reset_timer;
588 } nokia;
Harald Welte6be350c2011-05-25 13:10:08 +0200589 };
590
591 /* Not entirely sure how ip.access specific this is */
592 struct {
593 enum bts_gprs_mode mode;
594 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200595 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200596 uint16_t nsei;
597 uint8_t timer[7];
598 } nse;
599 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200600 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200601 uint16_t bvci;
602 uint8_t timer[11];
Harald Welte019f9132012-06-28 08:43:14 +0200603 struct gprs_rlc_cfg rlc_cfg;
Harald Welte6be350c2011-05-25 13:10:08 +0200604 } 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 Welte978714d2011-06-06 18:31:20 +0200652 void *role;
Harald Welte6be350c2011-05-25 13:10:08 +0200653};
654
655
Harald Welte3300c012011-06-05 13:31:33 +0200656struct gsm_bts *gsm_bts_alloc(void *talloc_ctx);
Harald Welte6be350c2011-05-25 13:10:08 +0200657struct gsm_bts_trx *gsm_bts_trx_alloc(struct gsm_bts *bts);
658
Harald Welte4f8ad532011-09-19 14:21:51 +0200659struct gsm_bts_trx *gsm_bts_trx_num(const struct gsm_bts *bts, int num);
Harald Welte6be350c2011-05-25 13:10:08 +0200660
Harald Welte4ab9d7c2012-08-17 12:42:06 +0200661
662const struct value_string gsm_pchant_names[10];
663const struct value_string gsm_pchant_descs[10];
664const struct value_string gsm_lchant_names[6];
Harald Welte6be350c2011-05-25 13:10:08 +0200665const char *gsm_pchan_name(enum gsm_phys_chan_config c);
666enum gsm_phys_chan_config gsm_pchan_parse(const char *name);
667const char *gsm_lchant_name(enum gsm_chan_t c);
668const char *gsm_chreq_name(enum gsm_chreq_reason_t c);
Harald Welte4f8ad532011-09-19 14:21:51 +0200669char *gsm_trx_name(const struct gsm_bts_trx *trx);
670char *gsm_ts_name(const struct gsm_bts_trx_ts *ts);
671char *gsm_lchan_name(const struct gsm_lchan *lchan);
Harald Welte6be350c2011-05-25 13:10:08 +0200672const char *gsm_lchans_name(enum gsm_lchan_state s);
673
Harald Welte6be350c2011-05-25 13:10:08 +0200674
Harald Welteb7849982011-06-29 16:49:03 +0200675void gsm_abis_mo_reset(struct gsm_abis_mo *mo);
676
Harald Welte978714d2011-06-06 18:31:20 +0200677struct gsm_abis_mo *
678gsm_objclass2mo(struct gsm_bts *bts, uint8_t obj_class,
Harald Welte4f8ad532011-09-19 14:21:51 +0200679 const struct abis_om_obj_inst *obj_inst);
Harald Welte978714d2011-06-06 18:31:20 +0200680
681struct gsm_nm_state *
682gsm_objclass2nmstate(struct gsm_bts *bts, uint8_t obj_class,
Harald Welte4f8ad532011-09-19 14:21:51 +0200683 const struct abis_om_obj_inst *obj_inst);
Harald Welte978714d2011-06-06 18:31:20 +0200684void *
685gsm_objclass2obj(struct gsm_bts *bts, uint8_t obj_class,
Harald Welte4f8ad532011-09-19 14:21:51 +0200686 const struct abis_om_obj_inst *obj_inst);
Harald Welte978714d2011-06-06 18:31:20 +0200687
Harald Welteb7849982011-06-29 16:49:03 +0200688/* reset the state of all MO in the BTS */
689void gsm_bts_mo_reset(struct gsm_bts *bts);
690
Harald Weltef6093a42011-06-25 10:02:33 +0200691uint8_t gsm_ts2chan_nr(const struct gsm_bts_trx_ts *ts, uint8_t lchan_nr);
692uint8_t gsm_lchan2chan_nr(const struct gsm_lchan *lchan);
693
Holger Hans Peter Freyther06c9da62011-06-09 21:48:49 +0200694/*
695 * help with parsing regexps
696 */
697int gsm_parse_reg(void *ctx, regex_t *reg, char **str,
698 int argc, const char **argv) __attribute__ ((warn_unused_result));
699
700
701
Harald Welte6be350c2011-05-25 13:10:08 +0200702#endif