blob: 4c71a075e0e6a47f73ce4b10ccb5504ae25348f3 [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>
Harald Welte7ff4f0e2013-03-07 18:38:09 +000016#include <osmocom/gsm/meas_rep.h>
Maxc08ee712016-05-11 12:45:13 +020017#include <osmocom/gsm/protocol/gsm_04_08.h>
Harald Welte6be350c2011-05-25 13:10:08 +020018#include <osmocom/gsm/protocol/gsm_08_58.h>
Harald Welte3300c012011-06-05 13:31:33 +020019#include <osmocom/gsm/protocol/gsm_12_21.h>
Harald Welte6be350c2011-05-25 13:10:08 +020020
Harald Welte0eae6132011-08-24 13:52:07 +020021#include <osmocom/abis/e1_input.h>
22
Holger Hans Peter Freyther0e0a09c2012-12-20 19:03:18 +010023#ifndef ROLE_BSC
24#include <osmocom/gsm/lapdm.h>
25#endif
26
Neels Hofmeyrac1f1432016-05-10 13:30:17 +020027#include <openbsc/common_cs.h>
28
Max70fdd242017-06-15 15:10:53 +020029/* 16 is the max. number of SI2quater messages according to 3GPP TS 44.018 Table 10.5.2.33b.1:
30 4-bit index is used (2#1111 = 10#15) */
Max9b97b002017-06-02 10:58:26 +020031#define SI2Q_MAX_NUM 16
32/* length in bits (for single SI2quater message) */
33#define SI2Q_MAX_LEN 160
34#define SI2Q_MIN_LEN 18
35
Holger Hans Peter Freyther8ec49522011-08-15 15:53:00 +020036struct osmo_bsc_data;
37
Harald Welte6be350c2011-05-25 13:10:08 +020038struct osmo_bsc_sccp_con;
39struct gsm_sms_queue;
40
41/* RRLP mode of operation */
42enum rrlp_mode {
43 RRLP_MODE_NONE,
44 RRLP_MODE_MS_BASED,
45 RRLP_MODE_MS_PREF,
46 RRLP_MODE_ASS_PREF,
47};
48
49/* Channel Request reason */
50enum gsm_chreq_reason_t {
51 GSM_CHREQ_REASON_EMERG,
52 GSM_CHREQ_REASON_PAG,
53 GSM_CHREQ_REASON_CALL,
54 GSM_CHREQ_REASON_LOCATION_UPD,
55 GSM_CHREQ_REASON_OTHER,
Alexander Couzens11368112016-11-28 23:26:50 +010056 GSM_CHREQ_REASON_PDCH,
Harald Welte6be350c2011-05-25 13:10:08 +020057};
58
Max582e4f62016-10-18 16:19:33 +020059/* lchans 0..3 are SDCCH in combined channel configuration,
60 use 4 as magic number for BCCH hack - see osmo-bts-../oml.c:opstart_compl() */
61#define CCCH_LCHAN 4
62
Harald Welte6be350c2011-05-25 13:10:08 +020063#define TRX_NR_TS 8
64#define TS_MAX_LCHAN 8
65
66#define HARDCODED_ARFCN 123
Harald Welte6be350c2011-05-25 13:10:08 +020067#define HARDCODED_BSIC 0x3f /* NCC = 7 / BCC = 7 */
68
69/* for multi-drop config */
70#define HARDCODED_BTS0_TS 1
71#define HARDCODED_BTS1_TS 6
72#define HARDCODED_BTS2_TS 11
73
Maxf9685c12017-03-23 12:01:07 +010074#define MAX_VERSION_LENGTH 64
75
Max7b62d542017-05-09 15:19:15 +020076#define MAX_BTS_FEATURES 128
77
Harald Welte6be350c2011-05-25 13:10:08 +020078enum gsm_hooks {
79 GSM_HOOK_NM_SWLOAD,
80 GSM_HOOK_RR_PAGING,
81 GSM_HOOK_RR_SECURITY,
82};
83
84enum gsm_paging_event {
85 GSM_PAGING_SUCCEEDED,
86 GSM_PAGING_EXPIRED,
87 GSM_PAGING_OOM,
88 GSM_PAGING_BUSY,
89};
90
91enum bts_gprs_mode {
92 BTS_GPRS_NONE = 0,
93 BTS_GPRS_GPRS = 1,
94 BTS_GPRS_EGPRS = 2,
95};
96
97struct gsm_lchan;
98struct gsm_subscriber;
99struct gsm_mncc;
Harald Welte135a6bd2011-09-04 13:53:26 +0200100struct osmo_rtp_socket;
Harald Welte6be350c2011-05-25 13:10:08 +0200101struct rtp_socket;
102struct bsc_api;
103
104/* Network Management State */
105struct gsm_nm_state {
106 uint8_t operational;
107 uint8_t administrative;
108 uint8_t availability;
109};
110
Harald Welted64c0bc2011-05-30 12:07:53 +0200111struct gsm_abis_mo {
Harald Welte3300c012011-06-05 13:31:33 +0200112 uint8_t obj_class;
Holger Hans Peter Freyther49976f42013-11-05 16:06:17 +0100113 uint8_t procedure_pending;
Harald Welte3300c012011-06-05 13:31:33 +0200114 struct abis_om_obj_inst obj_inst;
Harald Welted64c0bc2011-05-30 12:07:53 +0200115 const char *name;
116 struct gsm_nm_state nm_state;
117 struct tlv_parsed *nm_attr;
Harald Welte32bc1162011-06-06 18:58:48 +0200118 struct gsm_bts *bts;
Harald Welted64c0bc2011-05-30 12:07:53 +0200119};
120
Harald Welte591e1d72016-07-09 22:20:57 +0200121/* Ericsson OM2000 Managed Object */
122struct abis_om2k_mo {
123 uint8_t class;
124 uint8_t bts;
125 uint8_t assoc_so;
126 uint8_t inst;
127} __attribute__ ((packed));
128
129struct om2k_mo {
130 struct abis_om2k_mo addr;
131 struct osmo_fsm_inst *fsm;
132};
133
Harald Welte6be350c2011-05-25 13:10:08 +0200134#define A38_XOR_MIN_KEY_LEN 12
135#define A38_XOR_MAX_KEY_LEN 16
136#define A38_COMP128_KEY_LEN 16
137#define RSL_ENC_ALG_A5(x) (x+1)
Max27c3e762016-04-20 15:57:12 +0200138#define MAX_EARFCN_LIST 32
Harald Welte6be350c2011-05-25 13:10:08 +0200139
140/* is the data link established? who established it? */
141#define LCHAN_SAPI_UNUSED 0
142#define LCHAN_SAPI_MS 1
143#define LCHAN_SAPI_NET 2
Andreas Eversberg7d8fa342013-12-05 13:25:06 +0100144#define LCHAN_SAPI_REL 3
Harald Welte6be350c2011-05-25 13:10:08 +0200145
146/* state of a logical channel */
147enum gsm_lchan_state {
148 LCHAN_S_NONE, /* channel is not active */
Holger Hans Peter Freytherded02682012-01-15 00:02:17 +0100149 LCHAN_S_ACT_REQ, /* channel activation requested */
Harald Welte6be350c2011-05-25 13:10:08 +0200150 LCHAN_S_ACTIVE, /* channel is active and operational */
151 LCHAN_S_REL_REQ, /* channel release has been requested */
152 LCHAN_S_REL_ERR, /* channel is in an error state */
Holger Hans Peter Freyther638da512012-12-06 19:25:06 +0100153 LCHAN_S_BROKEN, /* channel is somehow unusable */
Harald Welte6be350c2011-05-25 13:10:08 +0200154 LCHAN_S_INACTIVE, /* channel is set inactive */
155};
156
Harald Weltec7921c92011-06-29 10:38:34 +0200157/* BTS ONLY */
158#define MAX_NUM_UL_MEAS 104
159#define LC_UL_M_F_L1_VALID (1 << 0)
160#define LC_UL_M_F_RES_VALID (1 << 1)
161
162struct bts_ul_meas {
163 /* BER in units of 0.01%: 10.000 == 100% ber, 0 == 0% ber */
164 uint16_t ber10k;
165 /* timing advance offset (in quarter bits) */
166 int16_t ta_offs_qbits;
167 /* C/I ratio in dB */
168 float c_i;
169 /* flags */
170 uint8_t is_sub:1;
171 /* RSSI in dBm * -1 */
172 uint8_t inv_rssi;
173};
Harald Weltef3b59322011-09-06 22:14:43 +0200174
Andreas Eversberga83d5112013-12-07 18:32:28 +0100175struct bts_codec_conf {
176 uint8_t hr;
177 uint8_t efr;
178 uint8_t amr;
179};
180
Harald Weltef3b59322011-09-06 22:14:43 +0200181struct amr_mode {
182 uint8_t mode;
Holger Hans Peter Freyther615ed462015-09-24 11:30:58 +0200183 uint8_t threshold;
184 uint8_t hysteresis;
Harald Weltef3b59322011-09-06 22:14:43 +0200185};
Holger Hans Peter Freyther615ed462015-09-24 11:30:58 +0200186
Harald Weltef3b59322011-09-06 22:14:43 +0200187struct amr_multirate_conf {
188 uint8_t gsm48_ie[2];
Holger Hans Peter Freyther615ed462015-09-24 11:30:58 +0200189 struct amr_mode ms_mode[4];
190 struct amr_mode bts_mode[4];
Harald Weltef3b59322011-09-06 22:14:43 +0200191 uint8_t num_modes;
192};
Harald Weltec7921c92011-06-29 10:38:34 +0200193/* /BTS ONLY */
194
Harald Weltee4227982012-08-24 15:33:56 +0200195enum lchan_csd_mode {
196 LCHAN_CSD_M_NT,
197 LCHAN_CSD_M_T_1200_75,
198 LCHAN_CSD_M_T_600,
199 LCHAN_CSD_M_T_1200,
200 LCHAN_CSD_M_T_2400,
201 LCHAN_CSD_M_T_9600,
202 LCHAN_CSD_M_T_14400,
203 LCHAN_CSD_M_T_29000,
204 LCHAN_CSD_M_T_32000,
205};
206
Daniel Willmann324c8052012-12-29 12:32:30 +0100207/* State of the SAPIs in the lchan */
208enum lchan_sapi_state {
209 LCHAN_SAPI_S_NONE,
210 LCHAN_SAPI_S_REQ,
211 LCHAN_SAPI_S_ASSIGNED,
212 LCHAN_SAPI_S_REL,
213 LCHAN_SAPI_S_ERROR,
214};
215
Harald Welte6be350c2011-05-25 13:10:08 +0200216struct gsm_lchan {
217 /* The TS that we're part of */
218 struct gsm_bts_trx_ts *ts;
219 /* The logical subslot number in the TS */
220 uint8_t nr;
221 /* The logical channel type */
222 enum gsm_chan_t type;
223 /* RSL channel mode */
224 enum rsl_cmod_spd rsl_cmode;
225 /* If TCH, traffic channel mode */
226 enum gsm48_chan_mode tch_mode;
Harald Weltee4227982012-08-24 15:33:56 +0200227 enum lchan_csd_mode csd_mode;
Harald Welte6be350c2011-05-25 13:10:08 +0200228 /* State */
229 enum gsm_lchan_state state;
Holger Hans Peter Freyther454140e2014-12-28 12:08:28 +0100230 const char *broken_reason;
Harald Welte6be350c2011-05-25 13:10:08 +0200231 /* Power levels for MS and BTS */
232 uint8_t bs_power;
233 uint8_t ms_power;
234 /* Encryption information */
Neels Hofmeyrac1f1432016-05-10 13:30:17 +0200235 struct gsm_encr encr;
Harald Welte6be350c2011-05-25 13:10:08 +0200236
237 /* AMR bits */
Andreas Eversberg73266522014-01-19 11:47:44 +0100238 uint8_t mr_ms_lv[7];
239 uint8_t mr_bts_lv[7];
Harald Welte6be350c2011-05-25 13:10:08 +0200240
241 /* Established data link layer services */
242 uint8_t sapis[8];
Holger Hans Peter Freytherb9b828b2013-01-01 19:20:28 +0100243 int sacch_deact;
Holger Hans Peter Freytherdfcfe652011-12-27 20:49:53 +0100244
Harald Welte6be350c2011-05-25 13:10:08 +0200245 struct {
246 uint32_t bound_ip;
247 uint32_t connect_ip;
248 uint16_t bound_port;
249 uint16_t connect_port;
250 uint16_t conn_id;
251 uint8_t rtp_payload;
252 uint8_t rtp_payload2;
253 uint8_t speech_mode;
Harald Welte135a6bd2011-09-04 13:53:26 +0200254#ifdef ROLE_BSC
Harald Welte6be350c2011-05-25 13:10:08 +0200255 struct rtp_socket *rtp_socket;
Harald Welte135a6bd2011-09-04 13:53:26 +0200256#else
257 struct osmo_rtp_socket *rtp_socket;
258#endif
Harald Welte6be350c2011-05-25 13:10:08 +0200259 } abis_ip;
260
Harald Welte2c1ae472011-06-26 14:13:37 +0200261 uint8_t rqd_ta;
262
Harald Weltec696cc22015-12-05 16:19:21 +0100263 char *name;
264
Harald Welte6be350c2011-05-25 13:10:08 +0200265#ifdef ROLE_BSC
266 struct osmo_timer_list T3101;
Holger Hans Peter Freytherb3489392011-12-28 16:21:05 +0100267 struct osmo_timer_list T3109;
Harald Welte6be350c2011-05-25 13:10:08 +0200268 struct osmo_timer_list T3111;
269 struct osmo_timer_list error_timer;
Harald Weltee8bd9e82011-08-10 23:26:33 +0200270 struct osmo_timer_list act_timer;
Andreas Eversberg7d8fa342013-12-05 13:25:06 +0100271 struct osmo_timer_list rel_work;
Holger Hans Peter Freyther638da512012-12-06 19:25:06 +0100272 uint8_t error_cause;
Harald Welte6be350c2011-05-25 13:10:08 +0200273
274 /* table of neighbor cell measurements */
275 struct neigh_meas_proc neigh_meas[MAX_NEIGH_MEAS];
276
277 /* cache of last measurement reports on this lchan */
278 struct gsm_meas_rep meas_rep[6];
279 int meas_rep_idx;
280
281 /* GSM Random Access data */
282 struct gsm48_req_ref *rqd_ref;
Harald Welte6be350c2011-05-25 13:10:08 +0200283
284 struct gsm_subscriber_connection *conn;
Andreas Eversberg9df268e2013-10-11 13:32:30 +0200285
286 struct {
287 /* channel activation type and handover ref */
288 uint8_t act_type;
289 uint8_t ho_ref;
Neels Hofmeyrb91e6002016-07-23 19:45:15 +0200290 struct gsm48_req_ref *rqd_ref;
291 uint8_t rqd_ta;
Neels Hofmeyr6e999b72016-07-23 21:00:51 +0200292 } dyn;
Harald Weltef6093a42011-06-25 10:02:33 +0200293#else
Daniel Willmann324c8052012-12-29 12:32:30 +0100294 /* Number of different GsmL1_Sapi_t used in osmo_bts_sysmo is 23.
295 * Currently we don't share these headers so this is a magic number. */
Holger Hans Peter Freyther30156e12013-04-05 18:41:45 +0200296 struct llist_head sapi_cmds;
Daniel Willmann324c8052012-12-29 12:32:30 +0100297 uint8_t sapis_dl[23];
298 uint8_t sapis_ul[23];
Harald Weltef6093a42011-06-25 10:02:33 +0200299 struct lapdm_channel lapdm_ch;
Harald Welte135a6bd2011-09-04 13:53:26 +0200300 struct llist_head dl_tch_queue;
Harald Welte2c1ae472011-06-26 14:13:37 +0200301 struct {
302 /* bitmask of all SI that are present/valid in si_buf */
303 uint32_t valid;
304 uint32_t last;
Max70fdd242017-06-15 15:10:53 +0200305 /* buffers where we put the pre-computed SI:
306 SI2Q_MAX_NUM is the max number of SI2quater messages (see 3GPP TS 44.018) */
307 sysinfo_buf_t buf[_MAX_SYSINFO_TYPE][SI2Q_MAX_NUM];
Harald Welte2c1ae472011-06-26 14:13:37 +0200308 } si;
Harald Weltec7921c92011-06-29 10:38:34 +0200309 struct {
310 uint8_t flags;
311 /* RSL measurment result number, 0 at lchan_act */
312 uint8_t res_nr;
313 /* current Tx power level of the BTS */
314 uint8_t bts_tx_pwr;
315 /* number of measurements stored in array below */
316 uint8_t num_ul_meas;
317 struct bts_ul_meas uplink[MAX_NUM_UL_MEAS];
318 /* last L1 header from the MS */
319 uint8_t l1_info[2];
Harald Welte7ff4f0e2013-03-07 18:38:09 +0000320 struct gsm_meas_rep_unidir ul_res;
Harald Weltec7921c92011-06-29 10:38:34 +0200321 } meas;
Harald Weltef3b59322011-09-06 22:14:43 +0200322 struct {
323 struct amr_multirate_conf amr_mr;
Harald Welte43290992011-09-07 12:41:38 +0200324 struct {
Max1e646f02016-10-05 17:29:02 +0200325 struct osmo_fsm_inst *dl_amr_fsm;
Max1b76a032016-10-25 20:22:16 +0200326 /* TCH cache */
Max1e646f02016-10-05 17:29:02 +0200327 uint8_t cache[20];
Max1b76a032016-10-25 20:22:16 +0200328 /* FACCH cache */
329 uint8_t facch[GSM_MACBLOCK_LEN];
Harald Welte43290992011-09-07 12:41:38 +0200330 uint8_t len;
Maxf5fe31d2016-06-10 14:09:07 +0200331 uint32_t fn;
332 bool is_update;
Max1e646f02016-10-05 17:29:02 +0200333 /* set for each SID frame to detect talkspurt for codecs
334 without explicit ONSET event */
335 bool ul_sid;
336 /* indicates if DTXd was active during DL measurement
337 period */
338 bool dl_active;
339 } dtx;
Holger Hans Peter Freyther922ef5d2014-07-24 21:05:32 +0200340 uint8_t last_cmr;
Maxd7df7ae2016-06-03 12:06:26 +0200341 uint32_t last_fn;
Harald Weltef3b59322011-09-06 22:14:43 +0200342 } tch;
Maxabf53d82017-01-25 16:19:20 +0100343
344 /* 3GPP TS 48.058 § 9.3.37: [0; 255] ok, -1 means invalid*/
345 int16_t ms_t_offs;
346 /* 3GPP TS 45.010 § 1.2 round trip propagation delay (in symbols) or -1 */
347 int16_t p_offs;
348
Harald Welte5d52c972012-04-08 20:23:28 +0200349 /* BTS-side ciphering state (rx only, bi-directional, ...) */
350 uint8_t ciph_state;
Holger Hans Peter Freyther2c6b59c2014-08-09 09:43:53 +0200351 uint8_t ciph_ns;
Harald Welte46cb8512012-04-19 23:13:35 +0200352 uint8_t loopback;
Harald Welte704cb862012-06-16 14:57:08 +0800353 struct {
354 uint8_t active;
355 uint8_t ref;
356 /* T3105: PHYS INF retransmission */
357 struct osmo_timer_list t3105;
358 /* counts up to Ny1 */
359 unsigned int phys_info_count;
360 } ho;
Andreas Eversberg1af682a2013-02-20 16:06:20 +0100361 /* S counter for link loss */
362 int s;
Holger Hans Peter Freytherfc7a75f2013-10-25 18:58:30 +0200363 /* Kind of the release/activation. E.g. RSL or PCU */
364 int rel_act_kind;
Maxec744652016-05-18 16:42:16 +0200365 /* RTP header Marker bit to indicate beginning of speech after pause */
366 bool rtp_tx_marker;
Holger Hans Peter Freytherf6f86b02015-02-05 22:25:03 +0100367 /* power handling */
368 struct {
369 uint8_t current;
370 uint8_t fixed;
371 } ms_power_ctrl;
Minh-Quang Nguyenf1886232017-01-18 16:49:00 +0100372
373 struct msgb *pending_rel_ind_msg;
Harald Welte6be350c2011-05-25 13:10:08 +0200374#endif
375};
376
Neels Hofmeyr2ebacce2016-06-14 14:08:35 +0200377enum {
378 TS_F_PDCH_ACTIVE = 0x1000,
379 TS_F_PDCH_ACT_PENDING = 0x2000,
380 TS_F_PDCH_DEACT_PENDING = 0x4000,
381 TS_F_PDCH_PENDING_MASK = 0x6000 /*<
382 TS_F_PDCH_ACT_PENDING | TS_F_PDCH_DEACT_PENDING */
383} gsm_bts_trx_ts_flags;
384
Harald Welte6be350c2011-05-25 13:10:08 +0200385/* One Timeslot in a TRX */
386struct gsm_bts_trx_ts {
387 struct gsm_bts_trx *trx;
388 /* number of this timeslot at the TRX */
389 uint8_t nr;
390
391 enum gsm_phys_chan_config pchan;
392
Neels Hofmeyrc1658762016-07-23 16:14:06 +0200393 struct {
394 enum gsm_phys_chan_config pchan_is;
395 enum gsm_phys_chan_config pchan_want;
396 struct msgb *pending_chan_activ;
397 } dyn;
398
Harald Welte6be350c2011-05-25 13:10:08 +0200399 unsigned int flags;
Harald Welted64c0bc2011-05-30 12:07:53 +0200400 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200401 struct tlv_parsed nm_attr;
402 uint8_t nm_chan_comb;
Harald Welte135a6482011-05-30 12:09:13 +0200403 int tsc; /* -1 == use BTS TSC */
Harald Welte6be350c2011-05-25 13:10:08 +0200404
405 struct {
406 /* Parameters below are configured by VTY */
407 int enabled;
408 uint8_t maio;
409 uint8_t hsn;
410 struct bitvec arfcns;
411 uint8_t arfcns_data[1024/8];
412 /* This is the pre-computed MA for channel assignments */
413 struct bitvec ma;
414 uint8_t ma_len; /* part of ma_data that is used */
415 uint8_t ma_data[8]; /* 10.5.2.21: max 8 bytes value part */
416 } hopping;
417
418 /* To which E1 subslot are we connected */
419 struct gsm_e1_subslot e1_link;
420
Harald Welte591e1d72016-07-09 22:20:57 +0200421 union {
422 struct {
423 struct om2k_mo om2k_mo;
424 } rbs2000;
425 };
426
Harald Welte6be350c2011-05-25 13:10:08 +0200427 struct gsm_lchan lchan[TS_MAX_LCHAN];
428};
429
430/* One TRX in a BTS */
431struct gsm_bts_trx {
432 /* list header in bts->trx_list */
433 struct llist_head list;
434
435 struct gsm_bts *bts;
436 /* number of this TRX in the BTS */
437 uint8_t nr;
438 /* human readable name / description */
439 char *description;
440 /* how do we talk RSL with this TRX? */
441 struct gsm_e1_subslot rsl_e1_link;
442 uint8_t rsl_tei;
443 struct e1inp_sign_link *rsl_link;
Holger Hans Peter Freythercaa98d52013-10-06 15:52:14 +0200444
Harald Welte6be350c2011-05-25 13:10:08 +0200445 /* Some BTS (specifically Ericsson RBS) have a per-TRX OML Link */
446 struct e1inp_sign_link *oml_link;
447
Harald Welted64c0bc2011-05-30 12:07:53 +0200448 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200449 struct tlv_parsed nm_attr;
450 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200451 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200452 } bb_transc;
453
454 uint16_t arfcn;
455 int nominal_power; /* in dBm */
456 unsigned int max_power_red; /* in actual dB */
Holger Hans Peter Freyther9b625802014-07-30 18:20:51 +0200457
458#ifndef ROLE_BSC
Harald Welte101c5c22014-08-22 16:12:03 +0200459 struct trx_power_params power_params;
Holger Hans Peter Freytherf6f86b02015-02-05 22:25:03 +0100460 int ms_power_control;
Harald Welte6be350c2011-05-25 13:10:08 +0200461
Harald Welted134cc72011-06-07 00:12:53 +0200462 struct {
463 void *l1h;
464 } role_bts;
Holger Hans Peter Freyther9b625802014-07-30 18:20:51 +0200465#endif
Harald Welted134cc72011-06-07 00:12:53 +0200466
Harald Welte6be350c2011-05-25 13:10:08 +0200467 union {
468 struct {
469 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200470 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200471 } bbsig;
472 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200473 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200474 } pa;
475 } bs11;
476 struct {
477 unsigned int test_state;
478 uint8_t test_nr;
479 struct rxlev_stats rxlev_stat;
480 } ipaccess;
Harald Welte591e1d72016-07-09 22:20:57 +0200481 struct {
482 struct {
483 struct om2k_mo om2k_mo;
484 } trxc;
485 struct {
486 struct om2k_mo om2k_mo;
487 } rx;
488 struct {
489 struct om2k_mo om2k_mo;
490 } tx;
491 } rbs2000;
Harald Welte6be350c2011-05-25 13:10:08 +0200492 };
493 struct gsm_bts_trx_ts ts[TRX_NR_TS];
494};
495
Max70fdd242017-06-15 15:10:53 +0200496#define GSM_BTS_SI2Q(bts, i) (struct gsm48_system_information_type_2quater *)((bts)->si_buf[SYSINFO_TYPE_2quater][i])
Max9b97b002017-06-02 10:58:26 +0200497#define GSM_BTS_HAS_SI(bts, i) ((bts)->si_valid & (1 << i))
Max70fdd242017-06-15 15:10:53 +0200498#define GSM_BTS_SI(bts, i) (void *)((bts)->si_buf[i][0])
499#define GSM_LCHAN_SI(lchan, i) (void *)((lchan)->si.buf[i][0])
Harald Welte6be350c2011-05-25 13:10:08 +0200500
501enum gsm_bts_type {
502 GSM_BTS_TYPE_UNKNOWN,
503 GSM_BTS_TYPE_BS11,
504 GSM_BTS_TYPE_NANOBTS,
505 GSM_BTS_TYPE_RBS2000,
Dieter Spaar16646022011-07-28 00:01:50 +0200506 GSM_BTS_TYPE_NOKIA_SITE,
Maxf9685c12017-03-23 12:01:07 +0100507 GSM_BTS_TYPE_OSMOBTS,
Harald Weltee555c2b2012-08-17 13:02:12 +0200508 _NUM_GSM_BTS_TYPE
Harald Welte6be350c2011-05-25 13:10:08 +0200509};
510
Maxf9685c12017-03-23 12:01:07 +0100511enum gsm_bts_type_variant {
512 BTS_UNKNOWN,
513 BTS_OSMO_LITECELL15,
514 BTS_OSMO_OCTPHY,
515 BTS_OSMO_SYSMO,
516 BTS_OSMO_TRX,
517 _NUM_BTS_VARIANT
518};
519
Max7507aef2017-04-10 13:59:14 +0200520/* Used by OML layer for BTS Attribute reporting */
521enum bts_attribute {
522 BTS_TYPE_VARIANT,
523 BTS_SUB_MODEL,
Max33e13572017-05-29 11:48:29 +0200524 TRX_PHY_VERSION,
Max7507aef2017-04-10 13:59:14 +0200525};
526
Harald Welte6be350c2011-05-25 13:10:08 +0200527struct vty;
528
529struct gsm_bts_model {
530 struct llist_head list;
531
532 enum gsm_bts_type type;
Maxf9685c12017-03-23 12:01:07 +0100533 enum gsm_bts_type_variant variant;
Harald Welte6be350c2011-05-25 13:10:08 +0200534 const char *name;
535
536 bool started;
537 int (*start)(struct gsm_network *net);
538 int (*oml_rcvmsg)(struct msgb *msg);
539
Pablo Neira Ayusoed5cacb2011-08-17 22:44:07 +0200540 void (*e1line_bind_ops)(struct e1inp_line *line);
541
Harald Welte6be350c2011-05-25 13:10:08 +0200542 void (*config_write_bts)(struct vty *vty, struct gsm_bts *bts);
543 void (*config_write_trx)(struct vty *vty, struct gsm_bts_trx *trx);
544 void (*config_write_ts)(struct vty *vty, struct gsm_bts_trx_ts *ts);
545
546 struct tlv_definition nm_att_tlvdef;
547
Maxaef68382017-05-31 12:15:54 +0200548 /* features of a given BTS model set via gsm_bts_model_register() locally */
Harald Welte6be350c2011-05-25 13:10:08 +0200549 struct bitvec features;
Max7b62d542017-05-09 15:19:15 +0200550 uint8_t _features_data[MAX_BTS_FEATURES/8];
Harald Welte6be350c2011-05-25 13:10:08 +0200551};
552
Maxaef68382017-05-31 12:15:54 +0200553/* N. B: always add new features to the end of the list (right before _NUM_BTS_FEAT) to avoid breaking compatibility
554 with BTS compiled against earlier version of this header */
Harald Welte6be350c2011-05-25 13:10:08 +0200555enum gsm_bts_features {
556 BTS_FEAT_HSCSD,
557 BTS_FEAT_GPRS,
558 BTS_FEAT_EGPRS,
559 BTS_FEAT_ECSD,
560 BTS_FEAT_HOPPING,
Harald Welte903aaea2014-01-19 17:10:50 +0100561 BTS_FEAT_MULTI_TSC,
Max1ebf23b2017-05-10 12:21:17 +0200562 BTS_FEAT_OML_ALERTS,
563 BTS_FEAT_AGCH_PCH_PROP,
564 BTS_FEAT_CBCH,
Maxaef68382017-05-31 12:15:54 +0200565 _NUM_BTS_FEAT
Harald Welte6be350c2011-05-25 13:10:08 +0200566};
567
Maxaef68382017-05-31 12:15:54 +0200568extern const struct value_string gsm_bts_features_descs[];
569
Harald Welte6be350c2011-05-25 13:10:08 +0200570/*
571 * This keeps track of the paging status of one BTS. It
572 * includes a number of pending requests, a back pointer
573 * to the gsm_bts, a timer and some more state.
574 */
575struct gsm_bts_paging_state {
576 /* pending requests */
577 struct llist_head pending_requests;
578 struct gsm_bts *bts;
579
580 struct osmo_timer_list work_timer;
581 struct osmo_timer_list credit_timer;
582
583 /* free chans needed */
584 int free_chans_need;
585
586 /* load */
587 uint16_t available_slots;
588};
589
590struct gsm_envabtse {
Harald Welted64c0bc2011-05-30 12:07:53 +0200591 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200592};
593
594struct gsm_bts_gprs_nsvc {
595 struct gsm_bts *bts;
596 /* data read via VTY config file, to configure the BTS
597 * via OML from BSC */
598 int id;
599 uint16_t nsvci;
600 uint16_t local_port; /* on the BTS */
601 uint16_t remote_port; /* on the SGSN */
602 uint32_t remote_ip; /* on the SGSN */
603
Harald Welted64c0bc2011-05-30 12:07:53 +0200604 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200605};
606
Harald Welte019f9132012-06-28 08:43:14 +0200607enum gprs_rlc_par {
608 RLC_T3142,
609 RLC_T3169,
610 RLC_T3191,
611 RLC_T3193,
612 RLC_T3195,
613 RLC_N3101,
614 RLC_N3103,
615 RLC_N3105,
616 CV_COUNTDOWN,
617 T_DL_TBF_EXT, /* ms */
618 T_UL_TBF_EXT, /* ms */
619 _NUM_RLC_PAR
620};
621
622enum gprs_cs {
623 GPRS_CS1,
624 GPRS_CS2,
625 GPRS_CS3,
626 GPRS_CS4,
627 GPRS_MCS1,
628 GPRS_MCS2,
629 GPRS_MCS3,
630 GPRS_MCS4,
631 GPRS_MCS5,
632 GPRS_MCS6,
633 GPRS_MCS7,
634 GPRS_MCS8,
635 GPRS_MCS9,
636 _NUM_GRPS_CS
637};
638
639struct gprs_rlc_cfg {
640 uint16_t parameter[_NUM_RLC_PAR];
641 struct {
642 uint16_t repeat_time; /* ms */
643 uint8_t repeat_count;
644 } paging;
645 uint32_t cs_mask; /* bitmask of gprs_cs */
646 uint8_t initial_cs;
647 uint8_t initial_mcs;
648};
649
650
Harald Welte6be350c2011-05-25 13:10:08 +0200651enum neigh_list_manual_mode {
652 NL_MODE_AUTOMATIC = 0,
653 NL_MODE_MANUAL = 1,
654 NL_MODE_MANUAL_SI5SEP = 2, /* SI2 and SI5 have separate neighbor lists */
655};
656
Daniel Willmann47b5b3e2011-08-05 13:51:27 +0200657enum bts_loc_fix {
658 BTS_LOC_FIX_INVALID = 0,
659 BTS_LOC_FIX_2D = 1,
660 BTS_LOC_FIX_3D = 2,
661};
662
Daniel Willmann7d109832012-05-14 18:43:23 +0200663extern const struct value_string bts_loc_fix_names[];
664
Daniel Willmann47b5b3e2011-08-05 13:51:27 +0200665struct bts_location {
666 struct llist_head list;
667 time_t tstamp;
668 enum bts_loc_fix valid;
669 double lat;
670 double lon;
671 double height;
672};
673
Harald Welte6be350c2011-05-25 13:10:08 +0200674/* One BTS */
675struct gsm_bts {
676 /* list header in net->bts_list */
677 struct llist_head list;
678
Daniel Willmann47b5b3e2011-08-05 13:51:27 +0200679 /* Geographical location of the BTS */
680 struct llist_head loc_list;
681
Harald Welte6be350c2011-05-25 13:10:08 +0200682 /* number of ths BTS in network */
683 uint8_t nr;
684 /* human readable name / description */
685 char *description;
686 /* Cell Identity */
687 uint16_t cell_identity;
688 /* location area code of this BTS */
689 uint16_t location_area_code;
Harald Weltea2bbc5e2015-11-20 10:43:31 +0100690 /* Base Station Identification Code (BSIC), lower 3 bits is BCC,
691 * which is used as TSC for the CCCH */
Harald Welte6be350c2011-05-25 13:10:08 +0200692 uint8_t bsic;
693 /* type of BTS */
694 enum gsm_bts_type type;
Max6d8e5192017-04-11 18:23:47 +0200695 enum gsm_bts_type_variant variant;
Harald Welte6be350c2011-05-25 13:10:08 +0200696 struct gsm_bts_model *model;
697 enum gsm_band band;
Maxf9685c12017-03-23 12:01:07 +0100698 char version[MAX_VERSION_LENGTH];
Max1ebf23b2017-05-10 12:21:17 +0200699 char sub_model[MAX_VERSION_LENGTH];
Maxf9685c12017-03-23 12:01:07 +0100700
Maxaef68382017-05-31 12:15:54 +0200701 /* features of a given BTS set/reported via OML */
702 struct bitvec features;
703 uint8_t _features_data[MAX_BTS_FEATURES/8];
704
Maxf9685c12017-03-23 12:01:07 +0100705 /* Connected PCU version (if any) */
706 char pcu_version[MAX_VERSION_LENGTH];
707
Harald Welte6be350c2011-05-25 13:10:08 +0200708 /* maximum Tx power that the MS is permitted to use in this cell */
709 int ms_max_power;
710
711 /* how do we talk OML with this TRX? */
712 struct gsm_e1_subslot oml_e1_link;
713 uint8_t oml_tei;
714 struct e1inp_sign_link *oml_link;
715
716 /* Abis network management O&M handle */
717 struct abis_nm_h *nmh;
Harald Welted64c0bc2011-05-30 12:07:53 +0200718
719 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200720
721 /* number of this BTS on given E1 link */
722 uint8_t bts_nr;
723
Maxc08ee712016-05-11 12:45:13 +0200724 /* DTX features of this BTS */
725 enum gsm48_dtx_mode dtxu;
726 bool dtxd;
727
Harald Welte6be350c2011-05-25 13:10:08 +0200728 /* paging state and control */
729 struct gsm_bts_paging_state paging;
730
731 /* CCCH is on C0 */
732 struct gsm_bts_trx *c0;
733
734 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200735 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200736 } site_mgr;
737
738 /* bitmask of all SI that are present/valid in si_buf */
739 uint32_t si_valid;
Max6f0e50c2017-04-12 15:30:54 +0200740 /* 3GPP TS 44.018 Table 10.5.2.33b.1 INDEX and COUNT for SI2quater */
Maxf39d03a2017-05-12 17:00:30 +0200741 uint8_t si2q_index; /* distinguish individual SI2quater messages */
742 uint8_t si2q_count; /* si2q_index for the last (highest indexed) individual SI2quater message */
Harald Welte6be350c2011-05-25 13:10:08 +0200743 /* buffers where we put the pre-computed SI */
Max70fdd242017-06-15 15:10:53 +0200744 sysinfo_buf_t si_buf[_MAX_SYSINFO_TYPE][SI2Q_MAX_NUM];
Maxf39d03a2017-05-12 17:00:30 +0200745 /* offsets used while generating SI2quater */
746 size_t e_offset;
747 size_t u_offset;
Harald Welte6be350c2011-05-25 13:10:08 +0200748
749 /* ip.accesss Unit ID's have Site/BTS/TRX layout */
750 union {
751 struct {
752 uint16_t site_id;
753 uint16_t bts_id;
754 uint32_t flags;
Harald Welte8b291802013-03-12 13:57:05 +0100755 uint32_t rsl_ip;
Harald Welte6be350c2011-05-25 13:10:08 +0200756 } ip_access;
757 struct {
758 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200759 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200760 } cclk;
761 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200762 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200763 } rack;
764 struct gsm_envabtse envabtse[4];
765 } bs11;
766 struct {
767 struct {
Harald Welte591e1d72016-07-09 22:20:57 +0200768 struct om2k_mo om2k_mo;
769 struct gsm_abis_mo mo;
770 struct llist_head conn_groups;
771 } cf;
772 struct {
773 struct om2k_mo om2k_mo;
Harald Welted64c0bc2011-05-30 12:07:53 +0200774 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200775 struct llist_head conn_groups;
776 } is;
777 struct {
Harald Welte591e1d72016-07-09 22:20:57 +0200778 struct om2k_mo om2k_mo;
Harald Welted64c0bc2011-05-30 12:07:53 +0200779 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200780 struct llist_head conn_groups;
781 } con;
782 struct {
Harald Welte591e1d72016-07-09 22:20:57 +0200783 struct om2k_mo om2k_mo;
Harald Welted64c0bc2011-05-30 12:07:53 +0200784 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200785 } dp;
786 struct {
Harald Welte591e1d72016-07-09 22:20:57 +0200787 struct om2k_mo om2k_mo;
Harald Welted64c0bc2011-05-30 12:07:53 +0200788 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200789 } tf;
Harald Weltece492582016-11-15 22:59:24 +0100790 uint32_t use_superchannel:1;
Harald Welte6be350c2011-05-25 13:10:08 +0200791 } rbs2000;
792 struct {
Harald Weltec8755af2011-07-28 00:22:17 +0200793 uint8_t bts_type;
Holger Hans Peter Freyther3e603482012-03-02 14:14:33 +0100794 unsigned int configured:1,
795 skip_reset:1,
Andreas Eversberg7d8fa342013-12-05 13:25:06 +0100796 no_loc_rel_cnf:1,
Sipos Csaba56e17662015-02-07 13:27:36 +0100797 bts_reset_timer_cnf,
Holger Hans Peter Freyther3e603482012-03-02 14:14:33 +0100798 did_reset:1,
799 wait_reset:1;
Harald Weltec8755af2011-07-28 00:22:17 +0200800 struct osmo_timer_list reset_timer;
801 } nokia;
Harald Welte6be350c2011-05-25 13:10:08 +0200802 };
803
804 /* Not entirely sure how ip.access specific this is */
805 struct {
bhargava350533c2016-07-21 11:14:34 +0530806 uint8_t supports_egprs_11bit_rach;
Harald Welte6be350c2011-05-25 13:10:08 +0200807 enum bts_gprs_mode mode;
808 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200809 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200810 uint16_t nsei;
811 uint8_t timer[7];
812 } nse;
813 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200814 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200815 uint16_t bvci;
816 uint8_t timer[11];
Harald Welte019f9132012-06-28 08:43:14 +0200817 struct gprs_rlc_cfg rlc_cfg;
Harald Welte6be350c2011-05-25 13:10:08 +0200818 } cell;
819 struct gsm_bts_gprs_nsvc nsvc[2];
820 uint8_t rac;
Andreas Eversberg0c8f9ca2013-03-16 16:31:26 +0100821 uint8_t net_ctrl_ord;
Max292ec582016-07-28 11:55:37 +0200822 bool ctrl_ack_type_use_block;
Harald Welte6be350c2011-05-25 13:10:08 +0200823 } gprs;
824
825 /* RACH NM values */
826 int rach_b_thresh;
827 int rach_ldavg_slots;
828
829 /* transceivers */
830 int num_trx;
831 struct llist_head trx_list;
832
Holger Hans Peter Freytherb92a5382014-11-21 10:00:39 +0100833 /* SI related items */
Jacob Erlbeck65d114f2014-01-16 11:02:14 +0100834 int force_combined_si;
Holger Hans Peter Freytherb92a5382014-11-21 10:00:39 +0100835 int bcch_change_mark;
Jacob Erlbeck65d114f2014-01-16 11:02:14 +0100836
Harald Welte6be350c2011-05-25 13:10:08 +0200837#ifdef ROLE_BSC
838 /* Abis NM queue */
839 struct llist_head abis_queue;
840 int abis_nm_pend;
841
842 struct gsm_network *network;
843
844 /* should the channel allocator allocate channels from high TRX to TRX0,
845 * rather than starting from TRX0 and go upwards? */
846 int chan_alloc_reverse;
847
848 enum neigh_list_manual_mode neigh_list_manual_mode;
849 /* parameters from which we build SYSTEM INFORMATION */
850 struct {
851 struct gsm48_rach_control rach_control;
852 uint8_t ncc_permitted;
853 struct gsm48_cell_sel_par cell_sel_par;
854 struct gsm48_si_selection_params cell_ro_sel_par; /* rest octet */
855 struct gsm48_cell_options cell_options;
856 struct gsm48_control_channel_descr chan_desc;
857 struct bitvec neigh_list;
858 struct bitvec cell_alloc;
859 struct bitvec si5_neigh_list;
Max59a1bf32016-04-15 16:04:46 +0200860 struct osmo_earfcn_si2q si2quater_neigh_list;
Max26679e02016-04-20 15:57:13 +0200861 size_t uarfcn_length; /* index for uarfcn and scramble lists */
Harald Welte6be350c2011-05-25 13:10:08 +0200862 struct {
863 /* bitmask large enough for all possible ARFCN's */
864 uint8_t neigh_list[1024/8];
865 uint8_t cell_alloc[1024/8];
866 /* If the user wants a different neighbor list in SI5 than in SI2 */
867 uint8_t si5_neigh_list[1024/8];
Max59a1bf32016-04-15 16:04:46 +0200868 uint8_t meas_bw_list[MAX_EARFCN_LIST];
869 uint16_t earfcn_list[MAX_EARFCN_LIST];
Max26679e02016-04-20 15:57:13 +0200870 uint16_t uarfcn_list[MAX_EARFCN_LIST];
871 uint16_t scramble_list[MAX_EARFCN_LIST];
Harald Welte6be350c2011-05-25 13:10:08 +0200872 } data;
873 } si_common;
Harald Welte42def722017-01-13 00:10:32 +0100874 bool early_classmark_allowed;
Harald Welte2f8b9d22017-06-18 11:12:13 +0300875 /* for testing only: Have an infinitely long radio link timeout */
876 bool infinite_radio_link_timeout;
Harald Welte6be350c2011-05-25 13:10:08 +0200877
878 /* do we use static (user-defined) system information messages? (bitmask) */
879 uint32_t si_mode_static;
Holger Hans Peter Freythere30d40d2012-07-20 10:27:31 +0200880
881 /* exclude the BTS from the global RF Lock handling */
882 int excl_from_rf_lock;
Andreas Eversberga83d5112013-12-07 18:32:28 +0100883
884 /* supported codecs beside FR */
885 struct bts_codec_conf codec;
Holger Hans Peter Freytherc22930e2014-12-17 14:46:17 +0100886
887 /* BTS dependencies bit field */
888 uint32_t depends_on[256/(8*4)];
Andreas Eversberg73266522014-01-19 11:47:44 +0100889
890 /* full and half rate multirate config */
891 struct amr_multirate_conf mr_full;
892 struct amr_multirate_conf mr_half;
893
Philipp Maierb4999b62016-10-26 15:19:41 +0200894 /* PCU socket state */
Harald Welte8254cf72017-05-29 13:42:19 +0200895 char *pcu_sock_path;
Philipp Maierb4999b62016-10-26 15:19:41 +0200896 struct pcu_sock_state *pcu_state;
897
Harald Welte6be350c2011-05-25 13:10:08 +0200898#endif /* ROLE_BSC */
Harald Welte978714d2011-06-06 18:31:20 +0200899 void *role;
Harald Welte6be350c2011-05-25 13:10:08 +0200900};
901
902
Harald Welte3300c012011-06-05 13:31:33 +0200903struct gsm_bts *gsm_bts_alloc(void *talloc_ctx);
Harald Welte1449c9f2014-08-24 09:50:10 +0200904struct gsm_bts *gsm_bts_num(struct gsm_network *net, int num);
Harald Welte6be350c2011-05-25 13:10:08 +0200905
Harald Welte1449c9f2014-08-24 09:50:10 +0200906struct gsm_bts_trx *gsm_bts_trx_alloc(struct gsm_bts *bts);
Harald Welte4f8ad532011-09-19 14:21:51 +0200907struct gsm_bts_trx *gsm_bts_trx_num(const struct gsm_bts *bts, int num);
Harald Welte6be350c2011-05-25 13:10:08 +0200908
Max7507aef2017-04-10 13:59:14 +0200909enum gsm_bts_type str2btstype(const char *arg);
910const char *btstype2str(enum gsm_bts_type type);
911
912enum bts_attribute str2btsattr(const char *s);
913const char *btsatttr2str(enum bts_attribute v);
914
915enum gsm_bts_type_variant str2btsvariant(const char *arg);
916const char *btsvariant2str(enum gsm_bts_type_variant v);
Harald Welte4ab9d7c2012-08-17 12:42:06 +0200917
Philipp Maier6f483d32017-02-24 15:18:08 +0100918extern const struct value_string gsm_chreq_descs[];
Neels Hofmeyr17a6bab2016-07-23 16:14:06 +0200919const struct value_string gsm_pchant_names[13];
920const struct value_string gsm_pchant_descs[13];
Harald Welte6be350c2011-05-25 13:10:08 +0200921const char *gsm_pchan_name(enum gsm_phys_chan_config c);
922enum gsm_phys_chan_config gsm_pchan_parse(const char *name);
923const char *gsm_lchant_name(enum gsm_chan_t c);
924const char *gsm_chreq_name(enum gsm_chreq_reason_t c);
Harald Welte4f8ad532011-09-19 14:21:51 +0200925char *gsm_trx_name(const struct gsm_bts_trx *trx);
926char *gsm_ts_name(const struct gsm_bts_trx_ts *ts);
Neels Hofmeyr34b8b5b2016-07-16 23:59:32 +0200927char *gsm_ts_and_pchan_name(const struct gsm_bts_trx_ts *ts);
Harald Weltec696cc22015-12-05 16:19:21 +0100928char *gsm_lchan_name_compute(const struct gsm_lchan *lchan);
Harald Welte6be350c2011-05-25 13:10:08 +0200929const char *gsm_lchans_name(enum gsm_lchan_state s);
930
Harald Weltec696cc22015-12-05 16:19:21 +0100931static inline char *gsm_lchan_name(const struct gsm_lchan *lchan)
932{
933 return lchan->name;
934}
Harald Welte6be350c2011-05-25 13:10:08 +0200935
Maxaef68382017-05-31 12:15:54 +0200936static inline int gsm_bts_set_feature(struct gsm_bts *bts, enum gsm_bts_features feat)
937{
938 OSMO_ASSERT(_NUM_BTS_FEAT < MAX_BTS_FEATURES);
939 return bitvec_set_bit_pos(&bts->features, feat, 1);
940}
941
942static inline bool gsm_bts_has_feature(const struct gsm_bts *bts, enum gsm_bts_features feat)
943{
944 OSMO_ASSERT(_NUM_BTS_FEAT < MAX_BTS_FEATURES);
945 return bitvec_get_bit_pos(&bts->features, feat);
946}
947
Harald Welteb7849982011-06-29 16:49:03 +0200948void gsm_abis_mo_reset(struct gsm_abis_mo *mo);
949
Harald Welte978714d2011-06-06 18:31:20 +0200950struct gsm_abis_mo *
951gsm_objclass2mo(struct gsm_bts *bts, uint8_t obj_class,
Harald Welte4f8ad532011-09-19 14:21:51 +0200952 const struct abis_om_obj_inst *obj_inst);
Harald Welte978714d2011-06-06 18:31:20 +0200953
954struct gsm_nm_state *
955gsm_objclass2nmstate(struct gsm_bts *bts, uint8_t obj_class,
Harald Welte4f8ad532011-09-19 14:21:51 +0200956 const struct abis_om_obj_inst *obj_inst);
Harald Welte978714d2011-06-06 18:31:20 +0200957void *
958gsm_objclass2obj(struct gsm_bts *bts, uint8_t obj_class,
Harald Welte4f8ad532011-09-19 14:21:51 +0200959 const struct abis_om_obj_inst *obj_inst);
Harald Welte978714d2011-06-06 18:31:20 +0200960
Harald Welteb7849982011-06-29 16:49:03 +0200961/* reset the state of all MO in the BTS */
962void gsm_bts_mo_reset(struct gsm_bts *bts);
963
Neels Hofmeyrd3841102016-07-18 23:43:44 +0200964uint8_t gsm_pchan2chan_nr(enum gsm_phys_chan_config pchan,
965 uint8_t ts_nr, uint8_t lchan_nr);
Harald Weltef6093a42011-06-25 10:02:33 +0200966uint8_t gsm_lchan2chan_nr(const struct gsm_lchan *lchan);
Neels Hofmeyrd3841102016-07-18 23:43:44 +0200967uint8_t gsm_lchan_as_pchan2chan_nr(const struct gsm_lchan *lchan,
968 enum gsm_phys_chan_config as_pchan);
Harald Weltef6093a42011-06-25 10:02:33 +0200969
Harald Welte142d12d2014-12-29 17:47:08 +0100970/* return the gsm_lchan for the CBCH (if it exists at all) */
971struct gsm_lchan *gsm_bts_get_cbch(struct gsm_bts *bts);
972
Holger Hans Peter Freyther06c9da62011-06-09 21:48:49 +0200973/*
974 * help with parsing regexps
975 */
976int gsm_parse_reg(void *ctx, regex_t *reg, char **str,
977 int argc, const char **argv) __attribute__ ((warn_unused_result));
978
Harald Welte1fe24122014-01-19 17:18:21 +0100979static inline uint8_t gsm_ts_tsc(const struct gsm_bts_trx_ts *ts)
980{
981 if (ts->tsc != -1)
982 return ts->tsc;
983 else
Harald Weltea2bbc5e2015-11-20 10:43:31 +0100984 return ts->trx->bts->bsic & 7;
Harald Welte1fe24122014-01-19 17:18:21 +0100985}
Holger Hans Peter Freyther06c9da62011-06-09 21:48:49 +0200986
Neels Hofmeyr74585722016-07-23 17:38:22 +0200987struct gsm_lchan *rsl_lchan_lookup(struct gsm_bts_trx *trx, uint8_t chan_nr,
988 int *rc);
Holger Hans Peter Freyther06c9da62011-06-09 21:48:49 +0200989
Neels Hofmeyrec16c162016-10-17 01:03:53 +0200990enum gsm_phys_chan_config ts_pchan(struct gsm_bts_trx_ts *ts);
Neels Hofmeyr76a0ad72016-07-29 18:12:06 +0200991uint8_t ts_subslots(struct gsm_bts_trx_ts *ts);
Neels Hofmeyr255dbfe2016-09-25 15:07:01 +0200992bool ts_is_tch(struct gsm_bts_trx_ts *ts);
Neels Hofmeyr76a0ad72016-07-29 18:12:06 +0200993
Harald Welte6be350c2011-05-25 13:10:08 +0200994#endif