blob: 83758b12741edc44baebddf9192b731f5b950a99 [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 Freyther0e0a09c2012-12-20 19:03:18 +010022#ifndef ROLE_BSC
23#include <osmocom/gsm/lapdm.h>
24#endif
25
Holger Hans Peter Freyther8ec49522011-08-15 15:53:00 +020026struct osmo_bsc_data;
27
Harald Welte6be350c2011-05-25 13:10:08 +020028struct osmo_bsc_sccp_con;
29struct gsm_sms_queue;
30
31/* RRLP mode of operation */
32enum 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 */
40enum 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
63enum gsm_hooks {
64 GSM_HOOK_NM_SWLOAD,
65 GSM_HOOK_RR_PAGING,
66 GSM_HOOK_RR_SECURITY,
67};
68
69enum gsm_paging_event {
70 GSM_PAGING_SUCCEEDED,
71 GSM_PAGING_EXPIRED,
72 GSM_PAGING_OOM,
73 GSM_PAGING_BUSY,
74};
75
76enum bts_gprs_mode {
77 BTS_GPRS_NONE = 0,
78 BTS_GPRS_GPRS = 1,
79 BTS_GPRS_EGPRS = 2,
80};
81
82struct gsm_lchan;
83struct gsm_subscriber;
84struct gsm_mncc;
Harald Welte135a6bd2011-09-04 13:53:26 +020085struct osmo_rtp_socket;
Harald Welte6be350c2011-05-25 13:10:08 +020086struct rtp_socket;
87struct bsc_api;
88
89/* Network Management State */
90struct gsm_nm_state {
91 uint8_t operational;
92 uint8_t administrative;
93 uint8_t availability;
94};
95
Harald Welted64c0bc2011-05-30 12:07:53 +020096struct gsm_abis_mo {
Harald Welte3300c012011-06-05 13:31:33 +020097 uint8_t obj_class;
98 struct abis_om_obj_inst obj_inst;
Harald Welted64c0bc2011-05-30 12:07:53 +020099 const char *name;
100 struct gsm_nm_state nm_state;
101 struct tlv_parsed *nm_attr;
Harald Welte32bc1162011-06-06 18:58:48 +0200102 struct gsm_bts *bts;
Harald Welted64c0bc2011-05-30 12:07:53 +0200103};
104
Harald Welte6be350c2011-05-25 13:10:08 +0200105#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 */
117enum gsm_lchan_state {
118 LCHAN_S_NONE, /* channel is not active */
Holger Hans Peter Freytherded02682012-01-15 00:02:17 +0100119 LCHAN_S_ACT_REQ, /* channel activation requested */
Harald Welte6be350c2011-05-25 13:10:08 +0200120 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 Freyther638da512012-12-06 19:25:06 +0100123 LCHAN_S_BROKEN, /* channel is somehow unusable */
Harald Welte6be350c2011-05-25 13:10:08 +0200124 LCHAN_S_INACTIVE, /* channel is set inactive */
125};
126
Harald Weltec7921c92011-06-29 10:38:34 +0200127/* 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
132struct 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 Weltef3b59322011-09-06 22:14:43 +0200144
145struct amr_mode {
146 uint8_t mode;
147 uint8_t threshold;
148 uint8_t hysteresis;
149};
150struct amr_multirate_conf {
151 uint8_t gsm48_ie[2];
152 struct amr_mode mode[4];
153 uint8_t num_modes;
154};
Harald Weltec7921c92011-06-29 10:38:34 +0200155/* /BTS ONLY */
156
Harald Weltee4227982012-08-24 15:33:56 +0200157enum 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 Willmann324c8052012-12-29 12:32:30 +0100169/* State of the SAPIs in the lchan */
170enum 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 Welte6be350c2011-05-25 13:10:08 +0200178struct 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 Weltee4227982012-08-24 15:33:56 +0200189 enum lchan_csd_mode csd_mode;
Harald Welte6be350c2011-05-25 13:10:08 +0200190 /* 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 Freytherb9b828b2013-01-01 19:20:28 +0100207 int sacch_deact;
Holger Hans Peter Freytherdfcfe652011-12-27 20:49:53 +0100208
Harald Welte6be350c2011-05-25 13:10:08 +0200209 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 Welte135a6bd2011-09-04 13:53:26 +0200218#ifdef ROLE_BSC
Harald Welte6be350c2011-05-25 13:10:08 +0200219 struct rtp_socket *rtp_socket;
Harald Welte135a6bd2011-09-04 13:53:26 +0200220#else
221 struct osmo_rtp_socket *rtp_socket;
222#endif
Harald Welte6be350c2011-05-25 13:10:08 +0200223 } abis_ip;
224
Harald Welte2c1ae472011-06-26 14:13:37 +0200225 uint8_t rqd_ta;
226
Harald Welte6be350c2011-05-25 13:10:08 +0200227#ifdef ROLE_BSC
228 struct osmo_timer_list T3101;
Holger Hans Peter Freytherb3489392011-12-28 16:21:05 +0100229 struct osmo_timer_list T3109;
Harald Welte6be350c2011-05-25 13:10:08 +0200230 struct osmo_timer_list T3111;
231 struct osmo_timer_list error_timer;
Harald Weltee8bd9e82011-08-10 23:26:33 +0200232 struct osmo_timer_list act_timer;
Holger Hans Peter Freyther638da512012-12-06 19:25:06 +0100233 uint8_t error_cause;
Harald Welte6be350c2011-05-25 13:10:08 +0200234
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 Welte6be350c2011-05-25 13:10:08 +0200244
245 struct gsm_subscriber_connection *conn;
Harald Weltef6093a42011-06-25 10:02:33 +0200246#else
Daniel Willmann324c8052012-12-29 12:32:30 +0100247 /* 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. */
249 uint8_t sapis_dl[23];
250 uint8_t sapis_ul[23];
Harald Weltef6093a42011-06-25 10:02:33 +0200251 struct lapdm_channel lapdm_ch;
Harald Welte135a6bd2011-09-04 13:53:26 +0200252 struct llist_head dl_tch_queue;
Harald Welte2c1ae472011-06-26 14:13:37 +0200253 struct {
254 /* bitmask of all SI that are present/valid in si_buf */
255 uint32_t valid;
256 uint32_t last;
257 /* buffers where we put the pre-computed SI */
258 sysinfo_buf_t buf[_MAX_SYSINFO_TYPE];
259 } si;
Harald Weltec7921c92011-06-29 10:38:34 +0200260 struct {
261 uint8_t flags;
262 /* RSL measurment result number, 0 at lchan_act */
263 uint8_t res_nr;
264 /* current Tx power level of the BTS */
265 uint8_t bts_tx_pwr;
266 /* number of measurements stored in array below */
267 uint8_t num_ul_meas;
268 struct bts_ul_meas uplink[MAX_NUM_UL_MEAS];
269 /* last L1 header from the MS */
270 uint8_t l1_info[2];
271 struct {
272 uint8_t rxlev_full;
273 uint8_t rxlev_sub;
274 uint8_t rxqual_full;
275 uint8_t rxqual_sub;
276 } res;
277 } meas;
Harald Weltef3b59322011-09-06 22:14:43 +0200278 struct {
279 struct amr_multirate_conf amr_mr;
Harald Welte43290992011-09-07 12:41:38 +0200280 struct {
281 uint8_t buf[16];
282 uint8_t len;
283 } last_sid;
Harald Weltef3b59322011-09-06 22:14:43 +0200284 } tch;
Harald Welte5d52c972012-04-08 20:23:28 +0200285 /* BTS-side ciphering state (rx only, bi-directional, ...) */
286 uint8_t ciph_state;
Harald Welte46cb8512012-04-19 23:13:35 +0200287 uint8_t loopback;
Harald Welte704cb862012-06-16 14:57:08 +0800288 struct {
289 uint8_t active;
290 uint8_t ref;
291 /* T3105: PHYS INF retransmission */
292 struct osmo_timer_list t3105;
293 /* counts up to Ny1 */
294 unsigned int phys_info_count;
295 } ho;
Andreas Eversberg1af682a2013-02-20 16:06:20 +0100296 /* S counter for link loss */
297 int s;
Harald Welte6be350c2011-05-25 13:10:08 +0200298#endif
299};
300
Harald Welte6be350c2011-05-25 13:10:08 +0200301#define TS_F_PDCH_MODE 0x1000
302/* One Timeslot in a TRX */
303struct gsm_bts_trx_ts {
304 struct gsm_bts_trx *trx;
305 /* number of this timeslot at the TRX */
306 uint8_t nr;
307
308 enum gsm_phys_chan_config pchan;
309
310 unsigned int flags;
Harald Welted64c0bc2011-05-30 12:07:53 +0200311 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200312 struct tlv_parsed nm_attr;
313 uint8_t nm_chan_comb;
Harald Welte135a6482011-05-30 12:09:13 +0200314 int tsc; /* -1 == use BTS TSC */
Harald Welte6be350c2011-05-25 13:10:08 +0200315
316 struct {
317 /* Parameters below are configured by VTY */
318 int enabled;
319 uint8_t maio;
320 uint8_t hsn;
321 struct bitvec arfcns;
322 uint8_t arfcns_data[1024/8];
323 /* This is the pre-computed MA for channel assignments */
324 struct bitvec ma;
325 uint8_t ma_len; /* part of ma_data that is used */
326 uint8_t ma_data[8]; /* 10.5.2.21: max 8 bytes value part */
327 } hopping;
328
329 /* To which E1 subslot are we connected */
330 struct gsm_e1_subslot e1_link;
331
332 struct gsm_lchan lchan[TS_MAX_LCHAN];
333};
334
335/* One TRX in a BTS */
336struct gsm_bts_trx {
337 /* list header in bts->trx_list */
338 struct llist_head list;
339
340 struct gsm_bts *bts;
341 /* number of this TRX in the BTS */
342 uint8_t nr;
343 /* human readable name / description */
344 char *description;
345 /* how do we talk RSL with this TRX? */
346 struct gsm_e1_subslot rsl_e1_link;
347 uint8_t rsl_tei;
Holger Hans Peter Freyther523a99d2012-01-17 15:52:45 +0100348#ifdef ROLE_BSC
Harald Welte6be350c2011-05-25 13:10:08 +0200349 struct e1inp_sign_link *rsl_link;
Holger Hans Peter Freyther523a99d2012-01-17 15:52:45 +0100350#else
351 struct ipabis_link *rsl_link;
352#endif
Harald Welte6be350c2011-05-25 13:10:08 +0200353 /* Some BTS (specifically Ericsson RBS) have a per-TRX OML Link */
354 struct e1inp_sign_link *oml_link;
355
Harald Welted64c0bc2011-05-30 12:07:53 +0200356 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200357 struct tlv_parsed nm_attr;
358 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200359 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200360 } bb_transc;
361
362 uint16_t arfcn;
363 int nominal_power; /* in dBm */
364 unsigned int max_power_red; /* in actual dB */
365
Harald Welted134cc72011-06-07 00:12:53 +0200366 struct {
367 void *l1h;
368 } role_bts;
369
Harald Welte6be350c2011-05-25 13:10:08 +0200370 union {
371 struct {
372 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200373 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200374 } bbsig;
375 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200376 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200377 } pa;
378 } bs11;
379 struct {
380 unsigned int test_state;
381 uint8_t test_nr;
382 struct rxlev_stats rxlev_stat;
383 } ipaccess;
384 };
385 struct gsm_bts_trx_ts ts[TRX_NR_TS];
386};
387
388#define GSM_BTS_SI(bts, i) (void *)(bts->si_buf[i])
389
390enum gsm_bts_type {
391 GSM_BTS_TYPE_UNKNOWN,
392 GSM_BTS_TYPE_BS11,
393 GSM_BTS_TYPE_NANOBTS,
394 GSM_BTS_TYPE_RBS2000,
395 GSM_BTS_TYPE_HSL_FEMTO,
Dieter Spaar16646022011-07-28 00:01:50 +0200396 GSM_BTS_TYPE_NOKIA_SITE,
Harald Weltef383aa12012-07-02 19:51:55 +0200397 GSM_BTS_TYPE_OSMO_SYSMO,
Harald Weltee555c2b2012-08-17 13:02:12 +0200398 _NUM_GSM_BTS_TYPE
Harald Welte6be350c2011-05-25 13:10:08 +0200399};
400
401struct vty;
402
403struct 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 Ayusoed5cacb2011-08-17 22:44:07 +0200413 void (*e1line_bind_ops)(struct e1inp_line *line);
414
Harald Welte6be350c2011-05-25 13:10:08 +0200415 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
425enum 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 */
438struct 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
453struct gsm_envabtse {
Harald Welted64c0bc2011-05-30 12:07:53 +0200454 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200455};
456
457struct 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 Welted64c0bc2011-05-30 12:07:53 +0200467 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200468};
469
Harald Welte019f9132012-06-28 08:43:14 +0200470enum 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
485enum 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
502struct 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 Welte6be350c2011-05-25 13:10:08 +0200514enum 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 Willmann47b5b3e2011-08-05 13:51:27 +0200520enum bts_loc_fix {
521 BTS_LOC_FIX_INVALID = 0,
522 BTS_LOC_FIX_2D = 1,
523 BTS_LOC_FIX_3D = 2,
524};
525
Daniel Willmann7d109832012-05-14 18:43:23 +0200526extern const struct value_string bts_loc_fix_names[];
527
Daniel Willmann47b5b3e2011-08-05 13:51:27 +0200528struct 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 Welte6be350c2011-05-25 13:10:08 +0200537/* One BTS */
538struct gsm_bts {
539 /* list header in net->bts_list */
540 struct llist_head list;
541
Daniel Willmann47b5b3e2011-08-05 13:51:27 +0200542 /* Geographical location of the BTS */
543 struct llist_head loc_list;
544
Harald Welte6be350c2011-05-25 13:10:08 +0200545 /* 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 Welted64c0bc2011-05-30 12:07:53 +0200571
572 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200573
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 Welted64c0bc2011-05-30 12:07:53 +0200584 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200585 } 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 Bourg1c5dd2c2011-12-02 10:18:17 +0100592 /* TimeZone hours, mins, and bts specific */
Harald Welte45f91712012-07-08 16:48:11 +0200593 struct {
594 int hr;
595 int mn;
596 int override;
597 } tz;
Gus Bourg1c5dd2c2011-12-02 10:18:17 +0100598
Harald Welte6be350c2011-05-25 13:10:08 +0200599 /* 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 Welte8b291802013-03-12 13:57:05 +0100605 uint32_t rsl_ip;
Harald Welte6be350c2011-05-25 13:10:08 +0200606 } ip_access;
607 struct {
608 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200609 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200610 } cclk;
611 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200612 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200613 } rack;
614 struct gsm_envabtse envabtse[4];
615 } bs11;
616 struct {
617 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200618 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200619 struct llist_head conn_groups;
620 } is;
621 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200622 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200623 struct llist_head conn_groups;
624 } con;
625 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200626 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200627 } dp;
628 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200629 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200630 } tf;
631 } rbs2000;
632 struct {
633 unsigned long serno;
634 } hsl;
Harald Weltec8755af2011-07-28 00:22:17 +0200635 struct {
636 uint8_t bts_type;
Holger Hans Peter Freyther3e603482012-03-02 14:14:33 +0100637 unsigned int configured:1,
638 skip_reset:1,
639 did_reset:1,
640 wait_reset:1;
Harald Weltec8755af2011-07-28 00:22:17 +0200641 struct osmo_timer_list reset_timer;
642 } nokia;
Harald Welte6be350c2011-05-25 13:10:08 +0200643 };
644
645 /* Not entirely sure how ip.access specific this is */
646 struct {
647 enum bts_gprs_mode mode;
648 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200649 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200650 uint16_t nsei;
651 uint8_t timer[7];
652 } nse;
653 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200654 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200655 uint16_t bvci;
656 uint8_t timer[11];
Harald Welte019f9132012-06-28 08:43:14 +0200657 struct gprs_rlc_cfg rlc_cfg;
Harald Welte6be350c2011-05-25 13:10:08 +0200658 } cell;
659 struct gsm_bts_gprs_nsvc nsvc[2];
660 uint8_t rac;
661 } gprs;
662
663 /* RACH NM values */
664 int rach_b_thresh;
665 int rach_ldavg_slots;
666
667 /* transceivers */
668 int num_trx;
669 struct llist_head trx_list;
670
671#ifdef ROLE_BSC
672 /* Abis NM queue */
673 struct llist_head abis_queue;
674 int abis_nm_pend;
675
676 struct gsm_network *network;
677
678 /* should the channel allocator allocate channels from high TRX to TRX0,
679 * rather than starting from TRX0 and go upwards? */
680 int chan_alloc_reverse;
681
682 enum neigh_list_manual_mode neigh_list_manual_mode;
683 /* parameters from which we build SYSTEM INFORMATION */
684 struct {
685 struct gsm48_rach_control rach_control;
686 uint8_t ncc_permitted;
687 struct gsm48_cell_sel_par cell_sel_par;
688 struct gsm48_si_selection_params cell_ro_sel_par; /* rest octet */
689 struct gsm48_cell_options cell_options;
690 struct gsm48_control_channel_descr chan_desc;
691 struct bitvec neigh_list;
692 struct bitvec cell_alloc;
693 struct bitvec si5_neigh_list;
694 struct {
695 /* bitmask large enough for all possible ARFCN's */
696 uint8_t neigh_list[1024/8];
697 uint8_t cell_alloc[1024/8];
698 /* If the user wants a different neighbor list in SI5 than in SI2 */
699 uint8_t si5_neigh_list[1024/8];
700 } data;
701 } si_common;
702
703 /* do we use static (user-defined) system information messages? (bitmask) */
704 uint32_t si_mode_static;
Holger Hans Peter Freythere30d40d2012-07-20 10:27:31 +0200705
706 /* exclude the BTS from the global RF Lock handling */
707 int excl_from_rf_lock;
Harald Welte6be350c2011-05-25 13:10:08 +0200708#endif /* ROLE_BSC */
Harald Welte978714d2011-06-06 18:31:20 +0200709 void *role;
Harald Welte6be350c2011-05-25 13:10:08 +0200710};
711
712
Harald Welte3300c012011-06-05 13:31:33 +0200713struct gsm_bts *gsm_bts_alloc(void *talloc_ctx);
Harald Welte6be350c2011-05-25 13:10:08 +0200714struct gsm_bts_trx *gsm_bts_trx_alloc(struct gsm_bts *bts);
715
Harald Welte4f8ad532011-09-19 14:21:51 +0200716struct gsm_bts_trx *gsm_bts_trx_num(const struct gsm_bts *bts, int num);
Harald Welte6be350c2011-05-25 13:10:08 +0200717
Harald Welte4ab9d7c2012-08-17 12:42:06 +0200718
719const struct value_string gsm_pchant_names[10];
720const struct value_string gsm_pchant_descs[10];
721const struct value_string gsm_lchant_names[6];
Harald Welte6be350c2011-05-25 13:10:08 +0200722const char *gsm_pchan_name(enum gsm_phys_chan_config c);
723enum gsm_phys_chan_config gsm_pchan_parse(const char *name);
724const char *gsm_lchant_name(enum gsm_chan_t c);
725const char *gsm_chreq_name(enum gsm_chreq_reason_t c);
Harald Welte4f8ad532011-09-19 14:21:51 +0200726char *gsm_trx_name(const struct gsm_bts_trx *trx);
727char *gsm_ts_name(const struct gsm_bts_trx_ts *ts);
728char *gsm_lchan_name(const struct gsm_lchan *lchan);
Harald Welte6be350c2011-05-25 13:10:08 +0200729const char *gsm_lchans_name(enum gsm_lchan_state s);
730
Harald Welte6be350c2011-05-25 13:10:08 +0200731
Harald Welteb7849982011-06-29 16:49:03 +0200732void gsm_abis_mo_reset(struct gsm_abis_mo *mo);
733
Harald Welte978714d2011-06-06 18:31:20 +0200734struct gsm_abis_mo *
735gsm_objclass2mo(struct gsm_bts *bts, uint8_t obj_class,
Harald Welte4f8ad532011-09-19 14:21:51 +0200736 const struct abis_om_obj_inst *obj_inst);
Harald Welte978714d2011-06-06 18:31:20 +0200737
738struct gsm_nm_state *
739gsm_objclass2nmstate(struct gsm_bts *bts, uint8_t obj_class,
Harald Welte4f8ad532011-09-19 14:21:51 +0200740 const struct abis_om_obj_inst *obj_inst);
Harald Welte978714d2011-06-06 18:31:20 +0200741void *
742gsm_objclass2obj(struct gsm_bts *bts, uint8_t obj_class,
Harald Welte4f8ad532011-09-19 14:21:51 +0200743 const struct abis_om_obj_inst *obj_inst);
Harald Welte978714d2011-06-06 18:31:20 +0200744
Harald Welteb7849982011-06-29 16:49:03 +0200745/* reset the state of all MO in the BTS */
746void gsm_bts_mo_reset(struct gsm_bts *bts);
747
Harald Weltef6093a42011-06-25 10:02:33 +0200748uint8_t gsm_ts2chan_nr(const struct gsm_bts_trx_ts *ts, uint8_t lchan_nr);
749uint8_t gsm_lchan2chan_nr(const struct gsm_lchan *lchan);
750
Holger Hans Peter Freyther06c9da62011-06-09 21:48:49 +0200751/*
752 * help with parsing regexps
753 */
754int gsm_parse_reg(void *ctx, regex_t *reg, char **str,
755 int argc, const char **argv) __attribute__ ((warn_unused_result));
756
757
758
Harald Welte6be350c2011-05-25 13:10:08 +0200759#endif