blob: b49a539a919cef0fbd3cc2d49d6cba1362b60218 [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;
Holger Hans Peter Freyther49976f42013-11-05 16:06:17 +010098 uint8_t procedure_pending;
Harald Welte3300c012011-06-05 13:31:33 +020099 struct abis_om_obj_inst obj_inst;
Harald Welted64c0bc2011-05-30 12:07:53 +0200100 const char *name;
101 struct gsm_nm_state nm_state;
102 struct tlv_parsed *nm_attr;
Harald Welte32bc1162011-06-06 18:58:48 +0200103 struct gsm_bts *bts;
Harald Welted64c0bc2011-05-30 12:07:53 +0200104};
105
Harald Welte6be350c2011-05-25 13:10:08 +0200106#define MAX_A5_KEY_LEN (128/8)
107#define A38_XOR_MIN_KEY_LEN 12
108#define A38_XOR_MAX_KEY_LEN 16
109#define A38_COMP128_KEY_LEN 16
110#define RSL_ENC_ALG_A5(x) (x+1)
111
112/* is the data link established? who established it? */
113#define LCHAN_SAPI_UNUSED 0
114#define LCHAN_SAPI_MS 1
115#define LCHAN_SAPI_NET 2
Andreas Eversberg7d8fa342013-12-05 13:25:06 +0100116#define LCHAN_SAPI_REL 3
Harald Welte6be350c2011-05-25 13:10:08 +0200117
118/* state of a logical channel */
119enum gsm_lchan_state {
120 LCHAN_S_NONE, /* channel is not active */
Holger Hans Peter Freytherded02682012-01-15 00:02:17 +0100121 LCHAN_S_ACT_REQ, /* channel activation requested */
Harald Welte6be350c2011-05-25 13:10:08 +0200122 LCHAN_S_ACTIVE, /* channel is active and operational */
123 LCHAN_S_REL_REQ, /* channel release has been requested */
124 LCHAN_S_REL_ERR, /* channel is in an error state */
Holger Hans Peter Freyther638da512012-12-06 19:25:06 +0100125 LCHAN_S_BROKEN, /* channel is somehow unusable */
Harald Welte6be350c2011-05-25 13:10:08 +0200126 LCHAN_S_INACTIVE, /* channel is set inactive */
127};
128
Harald Weltec7921c92011-06-29 10:38:34 +0200129/* BTS ONLY */
130#define MAX_NUM_UL_MEAS 104
131#define LC_UL_M_F_L1_VALID (1 << 0)
132#define LC_UL_M_F_RES_VALID (1 << 1)
133
134struct bts_ul_meas {
135 /* BER in units of 0.01%: 10.000 == 100% ber, 0 == 0% ber */
136 uint16_t ber10k;
137 /* timing advance offset (in quarter bits) */
138 int16_t ta_offs_qbits;
139 /* C/I ratio in dB */
140 float c_i;
141 /* flags */
142 uint8_t is_sub:1;
143 /* RSSI in dBm * -1 */
144 uint8_t inv_rssi;
145};
Harald Weltef3b59322011-09-06 22:14:43 +0200146
147struct amr_mode {
148 uint8_t mode;
149 uint8_t threshold;
150 uint8_t hysteresis;
151};
152struct amr_multirate_conf {
153 uint8_t gsm48_ie[2];
154 struct amr_mode mode[4];
155 uint8_t num_modes;
156};
Harald Weltec7921c92011-06-29 10:38:34 +0200157/* /BTS ONLY */
158
Harald Weltee4227982012-08-24 15:33:56 +0200159enum lchan_csd_mode {
160 LCHAN_CSD_M_NT,
161 LCHAN_CSD_M_T_1200_75,
162 LCHAN_CSD_M_T_600,
163 LCHAN_CSD_M_T_1200,
164 LCHAN_CSD_M_T_2400,
165 LCHAN_CSD_M_T_9600,
166 LCHAN_CSD_M_T_14400,
167 LCHAN_CSD_M_T_29000,
168 LCHAN_CSD_M_T_32000,
169};
170
Daniel Willmann324c8052012-12-29 12:32:30 +0100171/* State of the SAPIs in the lchan */
172enum lchan_sapi_state {
173 LCHAN_SAPI_S_NONE,
174 LCHAN_SAPI_S_REQ,
175 LCHAN_SAPI_S_ASSIGNED,
176 LCHAN_SAPI_S_REL,
177 LCHAN_SAPI_S_ERROR,
178};
179
Harald Welte6be350c2011-05-25 13:10:08 +0200180struct gsm_lchan {
181 /* The TS that we're part of */
182 struct gsm_bts_trx_ts *ts;
183 /* The logical subslot number in the TS */
184 uint8_t nr;
185 /* The logical channel type */
186 enum gsm_chan_t type;
187 /* RSL channel mode */
188 enum rsl_cmod_spd rsl_cmode;
189 /* If TCH, traffic channel mode */
190 enum gsm48_chan_mode tch_mode;
Harald Weltee4227982012-08-24 15:33:56 +0200191 enum lchan_csd_mode csd_mode;
Harald Welte6be350c2011-05-25 13:10:08 +0200192 /* State */
193 enum gsm_lchan_state state;
194 /* Power levels for MS and BTS */
195 uint8_t bs_power;
196 uint8_t ms_power;
197 /* Encryption information */
198 struct {
199 uint8_t alg_id;
200 uint8_t key_len;
201 uint8_t key[MAX_A5_KEY_LEN];
202 } encr;
203
204 /* AMR bits */
205 struct gsm48_multi_rate_conf mr_conf;
206
207 /* Established data link layer services */
208 uint8_t sapis[8];
Holger Hans Peter Freytherb9b828b2013-01-01 19:20:28 +0100209 int sacch_deact;
Holger Hans Peter Freytherdfcfe652011-12-27 20:49:53 +0100210
Harald Welte6be350c2011-05-25 13:10:08 +0200211 struct {
212 uint32_t bound_ip;
213 uint32_t connect_ip;
214 uint16_t bound_port;
215 uint16_t connect_port;
216 uint16_t conn_id;
217 uint8_t rtp_payload;
218 uint8_t rtp_payload2;
219 uint8_t speech_mode;
Harald Welte135a6bd2011-09-04 13:53:26 +0200220#ifdef ROLE_BSC
Harald Welte6be350c2011-05-25 13:10:08 +0200221 struct rtp_socket *rtp_socket;
Harald Welte135a6bd2011-09-04 13:53:26 +0200222#else
223 struct osmo_rtp_socket *rtp_socket;
224#endif
Harald Welte6be350c2011-05-25 13:10:08 +0200225 } abis_ip;
226
Harald Welte2c1ae472011-06-26 14:13:37 +0200227 uint8_t rqd_ta;
228
Harald Welte6be350c2011-05-25 13:10:08 +0200229#ifdef ROLE_BSC
230 struct osmo_timer_list T3101;
Holger Hans Peter Freytherb3489392011-12-28 16:21:05 +0100231 struct osmo_timer_list T3109;
Harald Welte6be350c2011-05-25 13:10:08 +0200232 struct osmo_timer_list T3111;
233 struct osmo_timer_list error_timer;
Harald Weltee8bd9e82011-08-10 23:26:33 +0200234 struct osmo_timer_list act_timer;
Andreas Eversberg7d8fa342013-12-05 13:25:06 +0100235 struct osmo_timer_list rel_work;
Holger Hans Peter Freyther638da512012-12-06 19:25:06 +0100236 uint8_t error_cause;
Harald Welte6be350c2011-05-25 13:10:08 +0200237
238 /* table of neighbor cell measurements */
239 struct neigh_meas_proc neigh_meas[MAX_NEIGH_MEAS];
240
241 /* cache of last measurement reports on this lchan */
242 struct gsm_meas_rep meas_rep[6];
243 int meas_rep_idx;
244
245 /* GSM Random Access data */
246 struct gsm48_req_ref *rqd_ref;
Harald Welte6be350c2011-05-25 13:10:08 +0200247
248 struct gsm_subscriber_connection *conn;
Harald Weltef6093a42011-06-25 10:02:33 +0200249#else
Daniel Willmann324c8052012-12-29 12:32:30 +0100250 /* Number of different GsmL1_Sapi_t used in osmo_bts_sysmo is 23.
251 * Currently we don't share these headers so this is a magic number. */
Holger Hans Peter Freyther30156e12013-04-05 18:41:45 +0200252 struct llist_head sapi_cmds;
Daniel Willmann324c8052012-12-29 12:32:30 +0100253 uint8_t sapis_dl[23];
254 uint8_t sapis_ul[23];
Harald Weltef6093a42011-06-25 10:02:33 +0200255 struct lapdm_channel lapdm_ch;
Harald Welte135a6bd2011-09-04 13:53:26 +0200256 struct llist_head dl_tch_queue;
Harald Welte2c1ae472011-06-26 14:13:37 +0200257 struct {
258 /* bitmask of all SI that are present/valid in si_buf */
259 uint32_t valid;
260 uint32_t last;
261 /* buffers where we put the pre-computed SI */
262 sysinfo_buf_t buf[_MAX_SYSINFO_TYPE];
263 } si;
Harald Weltec7921c92011-06-29 10:38:34 +0200264 struct {
265 uint8_t flags;
266 /* RSL measurment result number, 0 at lchan_act */
267 uint8_t res_nr;
268 /* current Tx power level of the BTS */
269 uint8_t bts_tx_pwr;
270 /* number of measurements stored in array below */
271 uint8_t num_ul_meas;
272 struct bts_ul_meas uplink[MAX_NUM_UL_MEAS];
273 /* last L1 header from the MS */
274 uint8_t l1_info[2];
275 struct {
276 uint8_t rxlev_full;
277 uint8_t rxlev_sub;
278 uint8_t rxqual_full;
279 uint8_t rxqual_sub;
280 } res;
281 } meas;
Harald Weltef3b59322011-09-06 22:14:43 +0200282 struct {
283 struct amr_multirate_conf amr_mr;
Harald Welte43290992011-09-07 12:41:38 +0200284 struct {
285 uint8_t buf[16];
286 uint8_t len;
287 } last_sid;
Harald Weltef3b59322011-09-06 22:14:43 +0200288 } tch;
Harald Welte5d52c972012-04-08 20:23:28 +0200289 /* BTS-side ciphering state (rx only, bi-directional, ...) */
290 uint8_t ciph_state;
Harald Welte46cb8512012-04-19 23:13:35 +0200291 uint8_t loopback;
Harald Welte704cb862012-06-16 14:57:08 +0800292 struct {
293 uint8_t active;
294 uint8_t ref;
295 /* T3105: PHYS INF retransmission */
296 struct osmo_timer_list t3105;
297 /* counts up to Ny1 */
298 unsigned int phys_info_count;
299 } ho;
Andreas Eversberg1af682a2013-02-20 16:06:20 +0100300 /* S counter for link loss */
301 int s;
Holger Hans Peter Freytherfc7a75f2013-10-25 18:58:30 +0200302 /* Kind of the release/activation. E.g. RSL or PCU */
303 int rel_act_kind;
Harald Welte6be350c2011-05-25 13:10:08 +0200304#endif
305};
306
Harald Welte6be350c2011-05-25 13:10:08 +0200307#define TS_F_PDCH_MODE 0x1000
308/* One Timeslot in a TRX */
309struct gsm_bts_trx_ts {
310 struct gsm_bts_trx *trx;
311 /* number of this timeslot at the TRX */
312 uint8_t nr;
313
314 enum gsm_phys_chan_config pchan;
315
316 unsigned int flags;
Harald Welted64c0bc2011-05-30 12:07:53 +0200317 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200318 struct tlv_parsed nm_attr;
319 uint8_t nm_chan_comb;
Harald Welte135a6482011-05-30 12:09:13 +0200320 int tsc; /* -1 == use BTS TSC */
Harald Welte6be350c2011-05-25 13:10:08 +0200321
322 struct {
323 /* Parameters below are configured by VTY */
324 int enabled;
325 uint8_t maio;
326 uint8_t hsn;
327 struct bitvec arfcns;
328 uint8_t arfcns_data[1024/8];
329 /* This is the pre-computed MA for channel assignments */
330 struct bitvec ma;
331 uint8_t ma_len; /* part of ma_data that is used */
332 uint8_t ma_data[8]; /* 10.5.2.21: max 8 bytes value part */
333 } hopping;
334
335 /* To which E1 subslot are we connected */
336 struct gsm_e1_subslot e1_link;
337
338 struct gsm_lchan lchan[TS_MAX_LCHAN];
339};
340
341/* One TRX in a BTS */
342struct gsm_bts_trx {
343 /* list header in bts->trx_list */
344 struct llist_head list;
345
346 struct gsm_bts *bts;
347 /* number of this TRX in the BTS */
348 uint8_t nr;
349 /* human readable name / description */
350 char *description;
351 /* how do we talk RSL with this TRX? */
352 struct gsm_e1_subslot rsl_e1_link;
353 uint8_t rsl_tei;
354 struct e1inp_sign_link *rsl_link;
Holger Hans Peter Freythercaa98d52013-10-06 15:52:14 +0200355
Harald Welte6be350c2011-05-25 13:10:08 +0200356 /* Some BTS (specifically Ericsson RBS) have a per-TRX OML Link */
357 struct e1inp_sign_link *oml_link;
358
Harald Welted64c0bc2011-05-30 12:07:53 +0200359 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200360 struct tlv_parsed nm_attr;
361 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200362 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200363 } bb_transc;
364
365 uint16_t arfcn;
366 int nominal_power; /* in dBm */
367 unsigned int max_power_red; /* in actual dB */
368
Harald Welted134cc72011-06-07 00:12:53 +0200369 struct {
370 void *l1h;
371 } role_bts;
372
Harald Welte6be350c2011-05-25 13:10:08 +0200373 union {
374 struct {
375 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200376 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200377 } bbsig;
378 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200379 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200380 } pa;
381 } bs11;
382 struct {
383 unsigned int test_state;
384 uint8_t test_nr;
385 struct rxlev_stats rxlev_stat;
386 } ipaccess;
387 };
388 struct gsm_bts_trx_ts ts[TRX_NR_TS];
389};
390
391#define GSM_BTS_SI(bts, i) (void *)(bts->si_buf[i])
392
393enum gsm_bts_type {
394 GSM_BTS_TYPE_UNKNOWN,
395 GSM_BTS_TYPE_BS11,
396 GSM_BTS_TYPE_NANOBTS,
397 GSM_BTS_TYPE_RBS2000,
Dieter Spaar16646022011-07-28 00:01:50 +0200398 GSM_BTS_TYPE_NOKIA_SITE,
Harald Weltef383aa12012-07-02 19:51:55 +0200399 GSM_BTS_TYPE_OSMO_SYSMO,
Harald Weltee555c2b2012-08-17 13:02:12 +0200400 _NUM_GSM_BTS_TYPE
Harald Welte6be350c2011-05-25 13:10:08 +0200401};
402
403struct vty;
404
405struct gsm_bts_model {
406 struct llist_head list;
407
408 enum gsm_bts_type type;
409 const char *name;
410
411 bool started;
412 int (*start)(struct gsm_network *net);
413 int (*oml_rcvmsg)(struct msgb *msg);
414
Pablo Neira Ayusoed5cacb2011-08-17 22:44:07 +0200415 void (*e1line_bind_ops)(struct e1inp_line *line);
416
Harald Welte6be350c2011-05-25 13:10:08 +0200417 void (*config_write_bts)(struct vty *vty, struct gsm_bts *bts);
418 void (*config_write_trx)(struct vty *vty, struct gsm_bts_trx *trx);
419 void (*config_write_ts)(struct vty *vty, struct gsm_bts_trx_ts *ts);
420
421 struct tlv_definition nm_att_tlvdef;
422
423 struct bitvec features;
424 uint8_t _features_data[128/8];
425};
426
427enum gsm_bts_features {
428 BTS_FEAT_HSCSD,
429 BTS_FEAT_GPRS,
430 BTS_FEAT_EGPRS,
431 BTS_FEAT_ECSD,
432 BTS_FEAT_HOPPING,
433};
434
435/*
436 * This keeps track of the paging status of one BTS. It
437 * includes a number of pending requests, a back pointer
438 * to the gsm_bts, a timer and some more state.
439 */
440struct gsm_bts_paging_state {
441 /* pending requests */
442 struct llist_head pending_requests;
443 struct gsm_bts *bts;
444
445 struct osmo_timer_list work_timer;
446 struct osmo_timer_list credit_timer;
447
448 /* free chans needed */
449 int free_chans_need;
450
451 /* load */
452 uint16_t available_slots;
453};
454
455struct gsm_envabtse {
Harald Welted64c0bc2011-05-30 12:07:53 +0200456 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200457};
458
459struct gsm_bts_gprs_nsvc {
460 struct gsm_bts *bts;
461 /* data read via VTY config file, to configure the BTS
462 * via OML from BSC */
463 int id;
464 uint16_t nsvci;
465 uint16_t local_port; /* on the BTS */
466 uint16_t remote_port; /* on the SGSN */
467 uint32_t remote_ip; /* on the SGSN */
468
Harald Welted64c0bc2011-05-30 12:07:53 +0200469 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200470};
471
Harald Welte019f9132012-06-28 08:43:14 +0200472enum gprs_rlc_par {
473 RLC_T3142,
474 RLC_T3169,
475 RLC_T3191,
476 RLC_T3193,
477 RLC_T3195,
478 RLC_N3101,
479 RLC_N3103,
480 RLC_N3105,
481 CV_COUNTDOWN,
482 T_DL_TBF_EXT, /* ms */
483 T_UL_TBF_EXT, /* ms */
484 _NUM_RLC_PAR
485};
486
487enum gprs_cs {
488 GPRS_CS1,
489 GPRS_CS2,
490 GPRS_CS3,
491 GPRS_CS4,
492 GPRS_MCS1,
493 GPRS_MCS2,
494 GPRS_MCS3,
495 GPRS_MCS4,
496 GPRS_MCS5,
497 GPRS_MCS6,
498 GPRS_MCS7,
499 GPRS_MCS8,
500 GPRS_MCS9,
501 _NUM_GRPS_CS
502};
503
504struct gprs_rlc_cfg {
505 uint16_t parameter[_NUM_RLC_PAR];
506 struct {
507 uint16_t repeat_time; /* ms */
508 uint8_t repeat_count;
509 } paging;
510 uint32_t cs_mask; /* bitmask of gprs_cs */
511 uint8_t initial_cs;
512 uint8_t initial_mcs;
513};
514
515
Harald Welte6be350c2011-05-25 13:10:08 +0200516enum neigh_list_manual_mode {
517 NL_MODE_AUTOMATIC = 0,
518 NL_MODE_MANUAL = 1,
519 NL_MODE_MANUAL_SI5SEP = 2, /* SI2 and SI5 have separate neighbor lists */
520};
521
Daniel Willmann47b5b3e2011-08-05 13:51:27 +0200522enum bts_loc_fix {
523 BTS_LOC_FIX_INVALID = 0,
524 BTS_LOC_FIX_2D = 1,
525 BTS_LOC_FIX_3D = 2,
526};
527
Daniel Willmann7d109832012-05-14 18:43:23 +0200528extern const struct value_string bts_loc_fix_names[];
529
Daniel Willmann47b5b3e2011-08-05 13:51:27 +0200530struct bts_location {
531 struct llist_head list;
532 time_t tstamp;
533 enum bts_loc_fix valid;
534 double lat;
535 double lon;
536 double height;
537};
538
Harald Welte6be350c2011-05-25 13:10:08 +0200539/* One BTS */
540struct gsm_bts {
541 /* list header in net->bts_list */
542 struct llist_head list;
543
Daniel Willmann47b5b3e2011-08-05 13:51:27 +0200544 /* Geographical location of the BTS */
545 struct llist_head loc_list;
546
Harald Welte6be350c2011-05-25 13:10:08 +0200547 /* number of ths BTS in network */
548 uint8_t nr;
549 /* human readable name / description */
550 char *description;
551 /* Cell Identity */
552 uint16_t cell_identity;
553 /* location area code of this BTS */
554 uint16_t location_area_code;
555 /* Training Sequence Code */
556 uint8_t tsc;
557 /* Base Station Identification Code (BSIC) */
558 uint8_t bsic;
559 /* type of BTS */
560 enum gsm_bts_type type;
561 struct gsm_bts_model *model;
562 enum gsm_band band;
563 /* maximum Tx power that the MS is permitted to use in this cell */
564 int ms_max_power;
565
566 /* how do we talk OML with this TRX? */
567 struct gsm_e1_subslot oml_e1_link;
568 uint8_t oml_tei;
569 struct e1inp_sign_link *oml_link;
570
571 /* Abis network management O&M handle */
572 struct abis_nm_h *nmh;
Harald Welted64c0bc2011-05-30 12:07:53 +0200573
574 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200575
576 /* number of this BTS on given E1 link */
577 uint8_t bts_nr;
578
579 /* paging state and control */
580 struct gsm_bts_paging_state paging;
581
582 /* CCCH is on C0 */
583 struct gsm_bts_trx *c0;
584
585 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200586 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200587 } site_mgr;
588
589 /* bitmask of all SI that are present/valid in si_buf */
590 uint32_t si_valid;
591 /* buffers where we put the pre-computed SI */
592 sysinfo_buf_t si_buf[_MAX_SYSINFO_TYPE];
593
Gus Bourg1c5dd2c2011-12-02 10:18:17 +0100594 /* TimeZone hours, mins, and bts specific */
Harald Welte45f91712012-07-08 16:48:11 +0200595 struct {
596 int hr;
597 int mn;
598 int override;
Jacob Erlbeck946d1412013-09-17 13:59:29 +0200599 int dst;
Harald Welte45f91712012-07-08 16:48:11 +0200600 } tz;
Gus Bourg1c5dd2c2011-12-02 10:18:17 +0100601
Harald Welte6be350c2011-05-25 13:10:08 +0200602 /* ip.accesss Unit ID's have Site/BTS/TRX layout */
603 union {
604 struct {
605 uint16_t site_id;
606 uint16_t bts_id;
607 uint32_t flags;
Harald Welte8b291802013-03-12 13:57:05 +0100608 uint32_t rsl_ip;
Harald Welte6be350c2011-05-25 13:10:08 +0200609 } ip_access;
610 struct {
611 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200612 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200613 } cclk;
614 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200615 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200616 } rack;
617 struct gsm_envabtse envabtse[4];
618 } bs11;
619 struct {
620 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200621 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200622 struct llist_head conn_groups;
623 } is;
624 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200625 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200626 struct llist_head conn_groups;
627 } con;
628 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200629 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200630 } dp;
631 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200632 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200633 } tf;
634 } rbs2000;
635 struct {
Harald Weltec8755af2011-07-28 00:22:17 +0200636 uint8_t bts_type;
Holger Hans Peter Freyther3e603482012-03-02 14:14:33 +0100637 unsigned int configured:1,
638 skip_reset:1,
Andreas Eversberg7d8fa342013-12-05 13:25:06 +0100639 no_loc_rel_cnf:1,
Holger Hans Peter Freyther3e603482012-03-02 14:14:33 +0100640 did_reset:1,
641 wait_reset:1;
Harald Weltec8755af2011-07-28 00:22:17 +0200642 struct osmo_timer_list reset_timer;
643 } nokia;
Harald Welte6be350c2011-05-25 13:10:08 +0200644 };
645
646 /* Not entirely sure how ip.access specific this is */
647 struct {
648 enum bts_gprs_mode mode;
649 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200650 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200651 uint16_t nsei;
652 uint8_t timer[7];
653 } nse;
654 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200655 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200656 uint16_t bvci;
657 uint8_t timer[11];
Harald Welte019f9132012-06-28 08:43:14 +0200658 struct gprs_rlc_cfg rlc_cfg;
Harald Welte6be350c2011-05-25 13:10:08 +0200659 } cell;
660 struct gsm_bts_gprs_nsvc nsvc[2];
661 uint8_t rac;
Andreas Eversberg0c8f9ca2013-03-16 16:31:26 +0100662 uint8_t net_ctrl_ord;
Harald Welte6be350c2011-05-25 13:10:08 +0200663 } gprs;
664
665 /* RACH NM values */
666 int rach_b_thresh;
667 int rach_ldavg_slots;
668
669 /* transceivers */
670 int num_trx;
671 struct llist_head trx_list;
672
673#ifdef ROLE_BSC
674 /* Abis NM queue */
675 struct llist_head abis_queue;
676 int abis_nm_pend;
677
678 struct gsm_network *network;
679
680 /* should the channel allocator allocate channels from high TRX to TRX0,
681 * rather than starting from TRX0 and go upwards? */
682 int chan_alloc_reverse;
683
684 enum neigh_list_manual_mode neigh_list_manual_mode;
685 /* parameters from which we build SYSTEM INFORMATION */
686 struct {
687 struct gsm48_rach_control rach_control;
688 uint8_t ncc_permitted;
689 struct gsm48_cell_sel_par cell_sel_par;
690 struct gsm48_si_selection_params cell_ro_sel_par; /* rest octet */
691 struct gsm48_cell_options cell_options;
692 struct gsm48_control_channel_descr chan_desc;
693 struct bitvec neigh_list;
694 struct bitvec cell_alloc;
695 struct bitvec si5_neigh_list;
696 struct {
697 /* bitmask large enough for all possible ARFCN's */
698 uint8_t neigh_list[1024/8];
699 uint8_t cell_alloc[1024/8];
700 /* If the user wants a different neighbor list in SI5 than in SI2 */
701 uint8_t si5_neigh_list[1024/8];
702 } data;
703 } si_common;
704
705 /* do we use static (user-defined) system information messages? (bitmask) */
706 uint32_t si_mode_static;
Holger Hans Peter Freythere30d40d2012-07-20 10:27:31 +0200707
708 /* exclude the BTS from the global RF Lock handling */
709 int excl_from_rf_lock;
Harald Welte6be350c2011-05-25 13:10:08 +0200710#endif /* ROLE_BSC */
Harald Welte978714d2011-06-06 18:31:20 +0200711 void *role;
Harald Welte6be350c2011-05-25 13:10:08 +0200712};
713
714
Harald Welte3300c012011-06-05 13:31:33 +0200715struct gsm_bts *gsm_bts_alloc(void *talloc_ctx);
Harald Welte6be350c2011-05-25 13:10:08 +0200716struct gsm_bts_trx *gsm_bts_trx_alloc(struct gsm_bts *bts);
717
Harald Welte4f8ad532011-09-19 14:21:51 +0200718struct gsm_bts_trx *gsm_bts_trx_num(const struct gsm_bts *bts, int num);
Harald Welte6be350c2011-05-25 13:10:08 +0200719
Harald Welte4ab9d7c2012-08-17 12:42:06 +0200720
721const struct value_string gsm_pchant_names[10];
722const struct value_string gsm_pchant_descs[10];
723const struct value_string gsm_lchant_names[6];
Harald Welte6be350c2011-05-25 13:10:08 +0200724const char *gsm_pchan_name(enum gsm_phys_chan_config c);
725enum gsm_phys_chan_config gsm_pchan_parse(const char *name);
726const char *gsm_lchant_name(enum gsm_chan_t c);
727const char *gsm_chreq_name(enum gsm_chreq_reason_t c);
Harald Welte4f8ad532011-09-19 14:21:51 +0200728char *gsm_trx_name(const struct gsm_bts_trx *trx);
729char *gsm_ts_name(const struct gsm_bts_trx_ts *ts);
730char *gsm_lchan_name(const struct gsm_lchan *lchan);
Harald Welte6be350c2011-05-25 13:10:08 +0200731const char *gsm_lchans_name(enum gsm_lchan_state s);
732
Harald Welte6be350c2011-05-25 13:10:08 +0200733
Harald Welteb7849982011-06-29 16:49:03 +0200734void gsm_abis_mo_reset(struct gsm_abis_mo *mo);
735
Harald Welte978714d2011-06-06 18:31:20 +0200736struct gsm_abis_mo *
737gsm_objclass2mo(struct gsm_bts *bts, uint8_t obj_class,
Harald Welte4f8ad532011-09-19 14:21:51 +0200738 const struct abis_om_obj_inst *obj_inst);
Harald Welte978714d2011-06-06 18:31:20 +0200739
740struct gsm_nm_state *
741gsm_objclass2nmstate(struct gsm_bts *bts, uint8_t obj_class,
Harald Welte4f8ad532011-09-19 14:21:51 +0200742 const struct abis_om_obj_inst *obj_inst);
Harald Welte978714d2011-06-06 18:31:20 +0200743void *
744gsm_objclass2obj(struct gsm_bts *bts, uint8_t obj_class,
Harald Welte4f8ad532011-09-19 14:21:51 +0200745 const struct abis_om_obj_inst *obj_inst);
Harald Welte978714d2011-06-06 18:31:20 +0200746
Harald Welteb7849982011-06-29 16:49:03 +0200747/* reset the state of all MO in the BTS */
748void gsm_bts_mo_reset(struct gsm_bts *bts);
749
Harald Weltef6093a42011-06-25 10:02:33 +0200750uint8_t gsm_ts2chan_nr(const struct gsm_bts_trx_ts *ts, uint8_t lchan_nr);
751uint8_t gsm_lchan2chan_nr(const struct gsm_lchan *lchan);
752
Holger Hans Peter Freyther06c9da62011-06-09 21:48:49 +0200753/*
754 * help with parsing regexps
755 */
756int gsm_parse_reg(void *ctx, regex_t *reg, char **str,
757 int argc, const char **argv) __attribute__ ((warn_unused_result));
758
759
760
Harald Welte6be350c2011-05-25 13:10:08 +0200761#endif