blob: 2fdc7638dd6932d1277d8ef952db58a84ad6f1af [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
Harald Welte6be350c2011-05-25 13:10:08 +020060enum gsm_hooks {
61 GSM_HOOK_NM_SWLOAD,
62 GSM_HOOK_RR_PAGING,
63 GSM_HOOK_RR_SECURITY,
64};
65
66enum gsm_paging_event {
67 GSM_PAGING_SUCCEEDED,
68 GSM_PAGING_EXPIRED,
69 GSM_PAGING_OOM,
70 GSM_PAGING_BUSY,
71};
72
73enum bts_gprs_mode {
74 BTS_GPRS_NONE = 0,
75 BTS_GPRS_GPRS = 1,
76 BTS_GPRS_EGPRS = 2,
77};
78
79struct gsm_lchan;
80struct gsm_subscriber;
81struct gsm_mncc;
Harald Welte135a6bd2011-09-04 13:53:26 +020082struct osmo_rtp_socket;
Harald Welte6be350c2011-05-25 13:10:08 +020083struct rtp_socket;
84struct bsc_api;
85
86/* Network Management State */
87struct gsm_nm_state {
88 uint8_t operational;
89 uint8_t administrative;
90 uint8_t availability;
91};
92
Harald Welted64c0bc2011-05-30 12:07:53 +020093struct gsm_abis_mo {
Harald Welte3300c012011-06-05 13:31:33 +020094 uint8_t obj_class;
Holger Hans Peter Freyther49976f42013-11-05 16:06:17 +010095 uint8_t procedure_pending;
Harald Welte3300c012011-06-05 13:31:33 +020096 struct abis_om_obj_inst obj_inst;
Harald Welted64c0bc2011-05-30 12:07:53 +020097 const char *name;
98 struct gsm_nm_state nm_state;
99 struct tlv_parsed *nm_attr;
Harald Welte32bc1162011-06-06 18:58:48 +0200100 struct gsm_bts *bts;
Harald Welted64c0bc2011-05-30 12:07:53 +0200101};
102
Harald Welte6be350c2011-05-25 13:10:08 +0200103#define MAX_A5_KEY_LEN (128/8)
104#define A38_XOR_MIN_KEY_LEN 12
105#define A38_XOR_MAX_KEY_LEN 16
106#define A38_COMP128_KEY_LEN 16
107#define RSL_ENC_ALG_A5(x) (x+1)
108
109/* is the data link established? who established it? */
110#define LCHAN_SAPI_UNUSED 0
111#define LCHAN_SAPI_MS 1
112#define LCHAN_SAPI_NET 2
Andreas Eversberg7d8fa342013-12-05 13:25:06 +0100113#define LCHAN_SAPI_REL 3
Harald Welte6be350c2011-05-25 13:10:08 +0200114
115/* state of a logical channel */
116enum gsm_lchan_state {
117 LCHAN_S_NONE, /* channel is not active */
Holger Hans Peter Freytherded02682012-01-15 00:02:17 +0100118 LCHAN_S_ACT_REQ, /* channel activation requested */
Harald Welte6be350c2011-05-25 13:10:08 +0200119 LCHAN_S_ACTIVE, /* channel is active and operational */
120 LCHAN_S_REL_REQ, /* channel release has been requested */
121 LCHAN_S_REL_ERR, /* channel is in an error state */
Holger Hans Peter Freyther638da512012-12-06 19:25:06 +0100122 LCHAN_S_BROKEN, /* channel is somehow unusable */
Harald Welte6be350c2011-05-25 13:10:08 +0200123 LCHAN_S_INACTIVE, /* channel is set inactive */
124};
125
Harald Weltec7921c92011-06-29 10:38:34 +0200126/* BTS ONLY */
127#define MAX_NUM_UL_MEAS 104
128#define LC_UL_M_F_L1_VALID (1 << 0)
129#define LC_UL_M_F_RES_VALID (1 << 1)
130
131struct bts_ul_meas {
132 /* BER in units of 0.01%: 10.000 == 100% ber, 0 == 0% ber */
133 uint16_t ber10k;
134 /* timing advance offset (in quarter bits) */
135 int16_t ta_offs_qbits;
136 /* C/I ratio in dB */
137 float c_i;
138 /* flags */
139 uint8_t is_sub:1;
140 /* RSSI in dBm * -1 */
141 uint8_t inv_rssi;
142};
Harald Weltef3b59322011-09-06 22:14:43 +0200143
Andreas Eversberga83d5112013-12-07 18:32:28 +0100144struct bts_codec_conf {
145 uint8_t hr;
146 uint8_t efr;
147 uint8_t amr;
148};
149
Harald Weltef3b59322011-09-06 22:14:43 +0200150struct amr_mode {
151 uint8_t mode;
152 uint8_t threshold;
153 uint8_t hysteresis;
154};
155struct amr_multirate_conf {
156 uint8_t gsm48_ie[2];
157 struct amr_mode mode[4];
158 uint8_t num_modes;
159};
Harald Weltec7921c92011-06-29 10:38:34 +0200160/* /BTS ONLY */
161
Harald Weltee4227982012-08-24 15:33:56 +0200162enum lchan_csd_mode {
163 LCHAN_CSD_M_NT,
164 LCHAN_CSD_M_T_1200_75,
165 LCHAN_CSD_M_T_600,
166 LCHAN_CSD_M_T_1200,
167 LCHAN_CSD_M_T_2400,
168 LCHAN_CSD_M_T_9600,
169 LCHAN_CSD_M_T_14400,
170 LCHAN_CSD_M_T_29000,
171 LCHAN_CSD_M_T_32000,
172};
173
Daniel Willmann324c8052012-12-29 12:32:30 +0100174/* State of the SAPIs in the lchan */
175enum lchan_sapi_state {
176 LCHAN_SAPI_S_NONE,
177 LCHAN_SAPI_S_REQ,
178 LCHAN_SAPI_S_ASSIGNED,
179 LCHAN_SAPI_S_REL,
180 LCHAN_SAPI_S_ERROR,
181};
182
Harald Welte6be350c2011-05-25 13:10:08 +0200183struct gsm_lchan {
184 /* The TS that we're part of */
185 struct gsm_bts_trx_ts *ts;
186 /* The logical subslot number in the TS */
187 uint8_t nr;
188 /* The logical channel type */
189 enum gsm_chan_t type;
190 /* RSL channel mode */
191 enum rsl_cmod_spd rsl_cmode;
192 /* If TCH, traffic channel mode */
193 enum gsm48_chan_mode tch_mode;
Harald Weltee4227982012-08-24 15:33:56 +0200194 enum lchan_csd_mode csd_mode;
Harald Welte6be350c2011-05-25 13:10:08 +0200195 /* State */
196 enum gsm_lchan_state state;
197 /* Power levels for MS and BTS */
198 uint8_t bs_power;
199 uint8_t ms_power;
200 /* Encryption information */
201 struct {
202 uint8_t alg_id;
203 uint8_t key_len;
204 uint8_t key[MAX_A5_KEY_LEN];
205 } encr;
206
207 /* AMR bits */
208 struct gsm48_multi_rate_conf mr_conf;
209
210 /* Established data link layer services */
211 uint8_t sapis[8];
Holger Hans Peter Freytherb9b828b2013-01-01 19:20:28 +0100212 int sacch_deact;
Holger Hans Peter Freytherdfcfe652011-12-27 20:49:53 +0100213
Harald Welte6be350c2011-05-25 13:10:08 +0200214 struct {
215 uint32_t bound_ip;
216 uint32_t connect_ip;
217 uint16_t bound_port;
218 uint16_t connect_port;
219 uint16_t conn_id;
220 uint8_t rtp_payload;
221 uint8_t rtp_payload2;
222 uint8_t speech_mode;
Harald Welte135a6bd2011-09-04 13:53:26 +0200223#ifdef ROLE_BSC
Harald Welte6be350c2011-05-25 13:10:08 +0200224 struct rtp_socket *rtp_socket;
Harald Welte135a6bd2011-09-04 13:53:26 +0200225#else
226 struct osmo_rtp_socket *rtp_socket;
227#endif
Harald Welte6be350c2011-05-25 13:10:08 +0200228 } abis_ip;
229
Harald Welte2c1ae472011-06-26 14:13:37 +0200230 uint8_t rqd_ta;
231
Harald Welte6be350c2011-05-25 13:10:08 +0200232#ifdef ROLE_BSC
233 struct osmo_timer_list T3101;
Holger Hans Peter Freytherb3489392011-12-28 16:21:05 +0100234 struct osmo_timer_list T3109;
Harald Welte6be350c2011-05-25 13:10:08 +0200235 struct osmo_timer_list T3111;
236 struct osmo_timer_list error_timer;
Harald Weltee8bd9e82011-08-10 23:26:33 +0200237 struct osmo_timer_list act_timer;
Andreas Eversberg7d8fa342013-12-05 13:25:06 +0100238 struct osmo_timer_list rel_work;
Holger Hans Peter Freyther638da512012-12-06 19:25:06 +0100239 uint8_t error_cause;
Harald Welte6be350c2011-05-25 13:10:08 +0200240
241 /* table of neighbor cell measurements */
242 struct neigh_meas_proc neigh_meas[MAX_NEIGH_MEAS];
243
244 /* cache of last measurement reports on this lchan */
245 struct gsm_meas_rep meas_rep[6];
246 int meas_rep_idx;
247
248 /* GSM Random Access data */
249 struct gsm48_req_ref *rqd_ref;
Harald Welte6be350c2011-05-25 13:10:08 +0200250
251 struct gsm_subscriber_connection *conn;
Harald Weltef6093a42011-06-25 10:02:33 +0200252#else
Daniel Willmann324c8052012-12-29 12:32:30 +0100253 /* Number of different GsmL1_Sapi_t used in osmo_bts_sysmo is 23.
254 * Currently we don't share these headers so this is a magic number. */
Holger Hans Peter Freyther30156e12013-04-05 18:41:45 +0200255 struct llist_head sapi_cmds;
Daniel Willmann324c8052012-12-29 12:32:30 +0100256 uint8_t sapis_dl[23];
257 uint8_t sapis_ul[23];
Harald Weltef6093a42011-06-25 10:02:33 +0200258 struct lapdm_channel lapdm_ch;
Harald Welte135a6bd2011-09-04 13:53:26 +0200259 struct llist_head dl_tch_queue;
Harald Welte2c1ae472011-06-26 14:13:37 +0200260 struct {
261 /* bitmask of all SI that are present/valid in si_buf */
262 uint32_t valid;
263 uint32_t last;
264 /* buffers where we put the pre-computed SI */
265 sysinfo_buf_t buf[_MAX_SYSINFO_TYPE];
266 } si;
Harald Weltec7921c92011-06-29 10:38:34 +0200267 struct {
268 uint8_t flags;
269 /* RSL measurment result number, 0 at lchan_act */
270 uint8_t res_nr;
271 /* current Tx power level of the BTS */
272 uint8_t bts_tx_pwr;
273 /* number of measurements stored in array below */
274 uint8_t num_ul_meas;
275 struct bts_ul_meas uplink[MAX_NUM_UL_MEAS];
276 /* last L1 header from the MS */
277 uint8_t l1_info[2];
278 struct {
279 uint8_t rxlev_full;
280 uint8_t rxlev_sub;
281 uint8_t rxqual_full;
282 uint8_t rxqual_sub;
283 } res;
284 } meas;
Harald Weltef3b59322011-09-06 22:14:43 +0200285 struct {
286 struct amr_multirate_conf amr_mr;
Harald Welte43290992011-09-07 12:41:38 +0200287 struct {
288 uint8_t buf[16];
289 uint8_t len;
290 } last_sid;
Holger Hans Peter Freyther922ef5d2014-07-24 21:05:32 +0200291 uint8_t last_cmr;
Harald Weltef3b59322011-09-06 22:14:43 +0200292 } tch;
Harald Welte5d52c972012-04-08 20:23:28 +0200293 /* BTS-side ciphering state (rx only, bi-directional, ...) */
294 uint8_t ciph_state;
Holger Hans Peter Freyther2c6b59c2014-08-09 09:43:53 +0200295 uint8_t ciph_ns;
Harald Welte46cb8512012-04-19 23:13:35 +0200296 uint8_t loopback;
Harald Welte704cb862012-06-16 14:57:08 +0800297 struct {
298 uint8_t active;
299 uint8_t ref;
300 /* T3105: PHYS INF retransmission */
301 struct osmo_timer_list t3105;
302 /* counts up to Ny1 */
303 unsigned int phys_info_count;
304 } ho;
Andreas Eversberg1af682a2013-02-20 16:06:20 +0100305 /* S counter for link loss */
306 int s;
Holger Hans Peter Freytherfc7a75f2013-10-25 18:58:30 +0200307 /* Kind of the release/activation. E.g. RSL or PCU */
308 int rel_act_kind;
Harald Welte6be350c2011-05-25 13:10:08 +0200309#endif
310};
311
Harald Welte6be350c2011-05-25 13:10:08 +0200312#define TS_F_PDCH_MODE 0x1000
313/* One Timeslot in a TRX */
314struct gsm_bts_trx_ts {
315 struct gsm_bts_trx *trx;
316 /* number of this timeslot at the TRX */
317 uint8_t nr;
318
319 enum gsm_phys_chan_config pchan;
320
321 unsigned int flags;
Harald Welted64c0bc2011-05-30 12:07:53 +0200322 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200323 struct tlv_parsed nm_attr;
324 uint8_t nm_chan_comb;
Harald Welte135a6482011-05-30 12:09:13 +0200325 int tsc; /* -1 == use BTS TSC */
Harald Welte6be350c2011-05-25 13:10:08 +0200326
327 struct {
328 /* Parameters below are configured by VTY */
329 int enabled;
330 uint8_t maio;
331 uint8_t hsn;
332 struct bitvec arfcns;
333 uint8_t arfcns_data[1024/8];
334 /* This is the pre-computed MA for channel assignments */
335 struct bitvec ma;
336 uint8_t ma_len; /* part of ma_data that is used */
337 uint8_t ma_data[8]; /* 10.5.2.21: max 8 bytes value part */
338 } hopping;
339
340 /* To which E1 subslot are we connected */
341 struct gsm_e1_subslot e1_link;
342
343 struct gsm_lchan lchan[TS_MAX_LCHAN];
344};
345
346/* One TRX in a BTS */
347struct gsm_bts_trx {
348 /* list header in bts->trx_list */
349 struct llist_head list;
350
351 struct gsm_bts *bts;
352 /* number of this TRX in the BTS */
353 uint8_t nr;
354 /* human readable name / description */
355 char *description;
356 /* how do we talk RSL with this TRX? */
357 struct gsm_e1_subslot rsl_e1_link;
358 uint8_t rsl_tei;
359 struct e1inp_sign_link *rsl_link;
Holger Hans Peter Freythercaa98d52013-10-06 15:52:14 +0200360
Harald Welte6be350c2011-05-25 13:10:08 +0200361 /* Some BTS (specifically Ericsson RBS) have a per-TRX OML Link */
362 struct e1inp_sign_link *oml_link;
363
Harald Welted64c0bc2011-05-30 12:07:53 +0200364 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200365 struct tlv_parsed nm_attr;
366 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200367 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200368 } bb_transc;
369
370 uint16_t arfcn;
371 int nominal_power; /* in dBm */
372 unsigned int max_power_red; /* in actual dB */
Holger Hans Peter Freyther9b625802014-07-30 18:20:51 +0200373
374#ifndef ROLE_BSC
Harald Welte101c5c22014-08-22 16:12:03 +0200375 struct trx_power_params power_params;
Holger Hans Peter Freyther9b625802014-07-30 18:20:51 +0200376 struct {
377 unsigned int max_initial_power; /* in dBm */
378 uint8_t step_size; /* in dB */
379 int step_interval; /* in seconds */
380 struct osmo_timer_list step_timer;
381
382 int current_power; /* in dBm */
383 } pa;
384
Álvaro Neira Ayuso1b148ec2014-04-28 13:38:47 +0200385 unsigned int power_reduce; /* in dB */
Harald Welte6be350c2011-05-25 13:10:08 +0200386
Harald Welted134cc72011-06-07 00:12:53 +0200387 struct {
388 void *l1h;
389 } role_bts;
Holger Hans Peter Freyther9b625802014-07-30 18:20:51 +0200390#endif
Harald Welted134cc72011-06-07 00:12:53 +0200391
Harald Welte6be350c2011-05-25 13:10:08 +0200392 union {
393 struct {
394 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200395 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200396 } bbsig;
397 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200398 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200399 } pa;
400 } bs11;
401 struct {
402 unsigned int test_state;
403 uint8_t test_nr;
404 struct rxlev_stats rxlev_stat;
405 } ipaccess;
406 };
407 struct gsm_bts_trx_ts ts[TRX_NR_TS];
408};
409
410#define GSM_BTS_SI(bts, i) (void *)(bts->si_buf[i])
411
412enum gsm_bts_type {
413 GSM_BTS_TYPE_UNKNOWN,
414 GSM_BTS_TYPE_BS11,
415 GSM_BTS_TYPE_NANOBTS,
416 GSM_BTS_TYPE_RBS2000,
Dieter Spaar16646022011-07-28 00:01:50 +0200417 GSM_BTS_TYPE_NOKIA_SITE,
Harald Weltef383aa12012-07-02 19:51:55 +0200418 GSM_BTS_TYPE_OSMO_SYSMO,
Harald Weltee555c2b2012-08-17 13:02:12 +0200419 _NUM_GSM_BTS_TYPE
Harald Welte6be350c2011-05-25 13:10:08 +0200420};
421
422struct vty;
423
424struct gsm_bts_model {
425 struct llist_head list;
426
427 enum gsm_bts_type type;
428 const char *name;
429
430 bool started;
431 int (*start)(struct gsm_network *net);
432 int (*oml_rcvmsg)(struct msgb *msg);
433
Pablo Neira Ayusoed5cacb2011-08-17 22:44:07 +0200434 void (*e1line_bind_ops)(struct e1inp_line *line);
435
Harald Welte6be350c2011-05-25 13:10:08 +0200436 void (*config_write_bts)(struct vty *vty, struct gsm_bts *bts);
437 void (*config_write_trx)(struct vty *vty, struct gsm_bts_trx *trx);
438 void (*config_write_ts)(struct vty *vty, struct gsm_bts_trx_ts *ts);
439
440 struct tlv_definition nm_att_tlvdef;
441
442 struct bitvec features;
443 uint8_t _features_data[128/8];
444};
445
446enum gsm_bts_features {
447 BTS_FEAT_HSCSD,
448 BTS_FEAT_GPRS,
449 BTS_FEAT_EGPRS,
450 BTS_FEAT_ECSD,
451 BTS_FEAT_HOPPING,
Harald Welte903aaea2014-01-19 17:10:50 +0100452 BTS_FEAT_MULTI_TSC,
Harald Welte6be350c2011-05-25 13:10:08 +0200453};
454
455/*
456 * This keeps track of the paging status of one BTS. It
457 * includes a number of pending requests, a back pointer
458 * to the gsm_bts, a timer and some more state.
459 */
460struct gsm_bts_paging_state {
461 /* pending requests */
462 struct llist_head pending_requests;
463 struct gsm_bts *bts;
464
465 struct osmo_timer_list work_timer;
466 struct osmo_timer_list credit_timer;
467
468 /* free chans needed */
469 int free_chans_need;
470
471 /* load */
472 uint16_t available_slots;
473};
474
475struct gsm_envabtse {
Harald Welted64c0bc2011-05-30 12:07:53 +0200476 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200477};
478
479struct gsm_bts_gprs_nsvc {
480 struct gsm_bts *bts;
481 /* data read via VTY config file, to configure the BTS
482 * via OML from BSC */
483 int id;
484 uint16_t nsvci;
485 uint16_t local_port; /* on the BTS */
486 uint16_t remote_port; /* on the SGSN */
487 uint32_t remote_ip; /* on the SGSN */
488
Harald Welted64c0bc2011-05-30 12:07:53 +0200489 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200490};
491
Harald Welte019f9132012-06-28 08:43:14 +0200492enum gprs_rlc_par {
493 RLC_T3142,
494 RLC_T3169,
495 RLC_T3191,
496 RLC_T3193,
497 RLC_T3195,
498 RLC_N3101,
499 RLC_N3103,
500 RLC_N3105,
501 CV_COUNTDOWN,
502 T_DL_TBF_EXT, /* ms */
503 T_UL_TBF_EXT, /* ms */
504 _NUM_RLC_PAR
505};
506
507enum gprs_cs {
508 GPRS_CS1,
509 GPRS_CS2,
510 GPRS_CS3,
511 GPRS_CS4,
512 GPRS_MCS1,
513 GPRS_MCS2,
514 GPRS_MCS3,
515 GPRS_MCS4,
516 GPRS_MCS5,
517 GPRS_MCS6,
518 GPRS_MCS7,
519 GPRS_MCS8,
520 GPRS_MCS9,
521 _NUM_GRPS_CS
522};
523
524struct gprs_rlc_cfg {
525 uint16_t parameter[_NUM_RLC_PAR];
526 struct {
527 uint16_t repeat_time; /* ms */
528 uint8_t repeat_count;
529 } paging;
530 uint32_t cs_mask; /* bitmask of gprs_cs */
531 uint8_t initial_cs;
532 uint8_t initial_mcs;
533};
534
535
Harald Welte6be350c2011-05-25 13:10:08 +0200536enum neigh_list_manual_mode {
537 NL_MODE_AUTOMATIC = 0,
538 NL_MODE_MANUAL = 1,
539 NL_MODE_MANUAL_SI5SEP = 2, /* SI2 and SI5 have separate neighbor lists */
540};
541
Daniel Willmann47b5b3e2011-08-05 13:51:27 +0200542enum bts_loc_fix {
543 BTS_LOC_FIX_INVALID = 0,
544 BTS_LOC_FIX_2D = 1,
545 BTS_LOC_FIX_3D = 2,
546};
547
Daniel Willmann7d109832012-05-14 18:43:23 +0200548extern const struct value_string bts_loc_fix_names[];
549
Daniel Willmann47b5b3e2011-08-05 13:51:27 +0200550struct bts_location {
551 struct llist_head list;
552 time_t tstamp;
553 enum bts_loc_fix valid;
554 double lat;
555 double lon;
556 double height;
557};
558
Harald Welte6be350c2011-05-25 13:10:08 +0200559/* One BTS */
560struct gsm_bts {
561 /* list header in net->bts_list */
562 struct llist_head list;
563
Daniel Willmann47b5b3e2011-08-05 13:51:27 +0200564 /* Geographical location of the BTS */
565 struct llist_head loc_list;
566
Harald Welte6be350c2011-05-25 13:10:08 +0200567 /* number of ths BTS in network */
568 uint8_t nr;
569 /* human readable name / description */
570 char *description;
571 /* Cell Identity */
572 uint16_t cell_identity;
573 /* location area code of this BTS */
574 uint16_t location_area_code;
575 /* Training Sequence Code */
576 uint8_t tsc;
577 /* Base Station Identification Code (BSIC) */
578 uint8_t bsic;
579 /* type of BTS */
580 enum gsm_bts_type type;
581 struct gsm_bts_model *model;
582 enum gsm_band band;
583 /* maximum Tx power that the MS is permitted to use in this cell */
584 int ms_max_power;
585
586 /* how do we talk OML with this TRX? */
587 struct gsm_e1_subslot oml_e1_link;
588 uint8_t oml_tei;
589 struct e1inp_sign_link *oml_link;
590
591 /* Abis network management O&M handle */
592 struct abis_nm_h *nmh;
Harald Welted64c0bc2011-05-30 12:07:53 +0200593
594 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200595
596 /* number of this BTS on given E1 link */
597 uint8_t bts_nr;
598
599 /* paging state and control */
600 struct gsm_bts_paging_state paging;
601
602 /* CCCH is on C0 */
603 struct gsm_bts_trx *c0;
604
605 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200606 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200607 } site_mgr;
608
609 /* bitmask of all SI that are present/valid in si_buf */
610 uint32_t si_valid;
611 /* buffers where we put the pre-computed SI */
612 sysinfo_buf_t si_buf[_MAX_SYSINFO_TYPE];
613
Gus Bourg1c5dd2c2011-12-02 10:18:17 +0100614 /* TimeZone hours, mins, and bts specific */
Harald Welte45f91712012-07-08 16:48:11 +0200615 struct {
616 int hr;
617 int mn;
618 int override;
Jacob Erlbeck946d1412013-09-17 13:59:29 +0200619 int dst;
Harald Welte45f91712012-07-08 16:48:11 +0200620 } tz;
Gus Bourg1c5dd2c2011-12-02 10:18:17 +0100621
Harald Welte6be350c2011-05-25 13:10:08 +0200622 /* ip.accesss Unit ID's have Site/BTS/TRX layout */
623 union {
624 struct {
625 uint16_t site_id;
626 uint16_t bts_id;
627 uint32_t flags;
Harald Welte8b291802013-03-12 13:57:05 +0100628 uint32_t rsl_ip;
Harald Welte6be350c2011-05-25 13:10:08 +0200629 } ip_access;
630 struct {
631 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200632 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200633 } cclk;
634 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200635 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200636 } rack;
637 struct gsm_envabtse envabtse[4];
638 } bs11;
639 struct {
640 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200641 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200642 struct llist_head conn_groups;
643 } is;
644 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200645 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200646 struct llist_head conn_groups;
647 } con;
648 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200649 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200650 } dp;
651 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200652 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200653 } tf;
654 } rbs2000;
655 struct {
Harald Weltec8755af2011-07-28 00:22:17 +0200656 uint8_t bts_type;
Holger Hans Peter Freyther3e603482012-03-02 14:14:33 +0100657 unsigned int configured:1,
658 skip_reset:1,
Andreas Eversberg7d8fa342013-12-05 13:25:06 +0100659 no_loc_rel_cnf:1,
Holger Hans Peter Freyther3e603482012-03-02 14:14:33 +0100660 did_reset:1,
661 wait_reset:1;
Harald Weltec8755af2011-07-28 00:22:17 +0200662 struct osmo_timer_list reset_timer;
663 } nokia;
Harald Welte6be350c2011-05-25 13:10:08 +0200664 };
665
666 /* Not entirely sure how ip.access specific this is */
667 struct {
668 enum bts_gprs_mode mode;
669 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200670 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200671 uint16_t nsei;
672 uint8_t timer[7];
673 } nse;
674 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200675 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200676 uint16_t bvci;
677 uint8_t timer[11];
Harald Welte019f9132012-06-28 08:43:14 +0200678 struct gprs_rlc_cfg rlc_cfg;
Harald Welte6be350c2011-05-25 13:10:08 +0200679 } cell;
680 struct gsm_bts_gprs_nsvc nsvc[2];
681 uint8_t rac;
Andreas Eversberg0c8f9ca2013-03-16 16:31:26 +0100682 uint8_t net_ctrl_ord;
Harald Welte6be350c2011-05-25 13:10:08 +0200683 } gprs;
684
685 /* RACH NM values */
686 int rach_b_thresh;
687 int rach_ldavg_slots;
688
689 /* transceivers */
690 int num_trx;
691 struct llist_head trx_list;
692
Jacob Erlbeck65d114f2014-01-16 11:02:14 +0100693 /* SI compatibility hacks */
694 int force_combined_si;
695
Harald Welte6be350c2011-05-25 13:10:08 +0200696#ifdef ROLE_BSC
697 /* Abis NM queue */
698 struct llist_head abis_queue;
699 int abis_nm_pend;
700
701 struct gsm_network *network;
702
703 /* should the channel allocator allocate channels from high TRX to TRX0,
704 * rather than starting from TRX0 and go upwards? */
705 int chan_alloc_reverse;
706
707 enum neigh_list_manual_mode neigh_list_manual_mode;
708 /* parameters from which we build SYSTEM INFORMATION */
709 struct {
710 struct gsm48_rach_control rach_control;
711 uint8_t ncc_permitted;
712 struct gsm48_cell_sel_par cell_sel_par;
713 struct gsm48_si_selection_params cell_ro_sel_par; /* rest octet */
714 struct gsm48_cell_options cell_options;
715 struct gsm48_control_channel_descr chan_desc;
716 struct bitvec neigh_list;
717 struct bitvec cell_alloc;
718 struct bitvec si5_neigh_list;
719 struct {
720 /* bitmask large enough for all possible ARFCN's */
721 uint8_t neigh_list[1024/8];
722 uint8_t cell_alloc[1024/8];
723 /* If the user wants a different neighbor list in SI5 than in SI2 */
724 uint8_t si5_neigh_list[1024/8];
725 } data;
726 } si_common;
727
728 /* do we use static (user-defined) system information messages? (bitmask) */
729 uint32_t si_mode_static;
Holger Hans Peter Freythere30d40d2012-07-20 10:27:31 +0200730
731 /* exclude the BTS from the global RF Lock handling */
732 int excl_from_rf_lock;
Andreas Eversberga83d5112013-12-07 18:32:28 +0100733
734 /* supported codecs beside FR */
735 struct bts_codec_conf codec;
Harald Welte6be350c2011-05-25 13:10:08 +0200736#endif /* ROLE_BSC */
Harald Welte978714d2011-06-06 18:31:20 +0200737 void *role;
Harald Welte6be350c2011-05-25 13:10:08 +0200738};
739
740
Harald Welte3300c012011-06-05 13:31:33 +0200741struct gsm_bts *gsm_bts_alloc(void *talloc_ctx);
Harald Welte1449c9f2014-08-24 09:50:10 +0200742struct gsm_bts *gsm_bts_num(struct gsm_network *net, int num);
Harald Welte6be350c2011-05-25 13:10:08 +0200743
Harald Welte1449c9f2014-08-24 09:50:10 +0200744struct gsm_bts_trx *gsm_bts_trx_alloc(struct gsm_bts *bts);
Harald Welte4f8ad532011-09-19 14:21:51 +0200745struct gsm_bts_trx *gsm_bts_trx_num(const struct gsm_bts *bts, int num);
Harald Welte6be350c2011-05-25 13:10:08 +0200746
Harald Welte4ab9d7c2012-08-17 12:42:06 +0200747
748const struct value_string gsm_pchant_names[10];
749const struct value_string gsm_pchant_descs[10];
750const struct value_string gsm_lchant_names[6];
Harald Welte6be350c2011-05-25 13:10:08 +0200751const char *gsm_pchan_name(enum gsm_phys_chan_config c);
752enum gsm_phys_chan_config gsm_pchan_parse(const char *name);
753const char *gsm_lchant_name(enum gsm_chan_t c);
754const char *gsm_chreq_name(enum gsm_chreq_reason_t c);
Harald Welte4f8ad532011-09-19 14:21:51 +0200755char *gsm_trx_name(const struct gsm_bts_trx *trx);
756char *gsm_ts_name(const struct gsm_bts_trx_ts *ts);
757char *gsm_lchan_name(const struct gsm_lchan *lchan);
Harald Welte6be350c2011-05-25 13:10:08 +0200758const char *gsm_lchans_name(enum gsm_lchan_state s);
759
Harald Welte6be350c2011-05-25 13:10:08 +0200760
Harald Welteb7849982011-06-29 16:49:03 +0200761void gsm_abis_mo_reset(struct gsm_abis_mo *mo);
762
Harald Welte978714d2011-06-06 18:31:20 +0200763struct gsm_abis_mo *
764gsm_objclass2mo(struct gsm_bts *bts, uint8_t obj_class,
Harald Welte4f8ad532011-09-19 14:21:51 +0200765 const struct abis_om_obj_inst *obj_inst);
Harald Welte978714d2011-06-06 18:31:20 +0200766
767struct gsm_nm_state *
768gsm_objclass2nmstate(struct gsm_bts *bts, uint8_t obj_class,
Harald Welte4f8ad532011-09-19 14:21:51 +0200769 const struct abis_om_obj_inst *obj_inst);
Harald Welte978714d2011-06-06 18:31:20 +0200770void *
771gsm_objclass2obj(struct gsm_bts *bts, uint8_t obj_class,
Harald Welte4f8ad532011-09-19 14:21:51 +0200772 const struct abis_om_obj_inst *obj_inst);
Harald Welte978714d2011-06-06 18:31:20 +0200773
Harald Welteb7849982011-06-29 16:49:03 +0200774/* reset the state of all MO in the BTS */
775void gsm_bts_mo_reset(struct gsm_bts *bts);
776
Harald Weltef6093a42011-06-25 10:02:33 +0200777uint8_t gsm_ts2chan_nr(const struct gsm_bts_trx_ts *ts, uint8_t lchan_nr);
778uint8_t gsm_lchan2chan_nr(const struct gsm_lchan *lchan);
779
Holger Hans Peter Freyther06c9da62011-06-09 21:48:49 +0200780/*
781 * help with parsing regexps
782 */
783int gsm_parse_reg(void *ctx, regex_t *reg, char **str,
784 int argc, const char **argv) __attribute__ ((warn_unused_result));
785
Harald Welte1fe24122014-01-19 17:18:21 +0100786static inline uint8_t gsm_ts_tsc(const struct gsm_bts_trx_ts *ts)
787{
788 if (ts->tsc != -1)
789 return ts->tsc;
790 else
791 return ts->trx->bts->tsc;
792}
Holger Hans Peter Freyther06c9da62011-06-09 21:48:49 +0200793
794
Harald Welte6be350c2011-05-25 13:10:08 +0200795#endif