blob: 04669e2d0741ba28692bef32754da0b62d6f5ac1 [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 Hofmeyrc0164792017-09-04 15:15:32 +020027#include <osmocom/bsc/common_cs.h>
28#include <osmocom/bsc/meas_rep.h>
Neels Hofmeyrac1f1432016-05-10 13:30:17 +020029
Max70fdd242017-06-15 15:10:53 +020030/* 16 is the max. number of SI2quater messages according to 3GPP TS 44.018 Table 10.5.2.33b.1:
31 4-bit index is used (2#1111 = 10#15) */
Max9b97b002017-06-02 10:58:26 +020032#define SI2Q_MAX_NUM 16
33/* length in bits (for single SI2quater message) */
34#define SI2Q_MAX_LEN 160
35#define SI2Q_MIN_LEN 18
36
Holger Hans Peter Freyther8ec49522011-08-15 15:53:00 +020037struct osmo_bsc_data;
38
Harald Welte6be350c2011-05-25 13:10:08 +020039struct osmo_bsc_sccp_con;
40struct gsm_sms_queue;
41
42/* RRLP mode of operation */
43enum rrlp_mode {
44 RRLP_MODE_NONE,
45 RRLP_MODE_MS_BASED,
46 RRLP_MODE_MS_PREF,
47 RRLP_MODE_ASS_PREF,
48};
49
50/* Channel Request reason */
51enum gsm_chreq_reason_t {
52 GSM_CHREQ_REASON_EMERG,
53 GSM_CHREQ_REASON_PAG,
54 GSM_CHREQ_REASON_CALL,
55 GSM_CHREQ_REASON_LOCATION_UPD,
56 GSM_CHREQ_REASON_OTHER,
Alexander Couzens11368112016-11-28 23:26:50 +010057 GSM_CHREQ_REASON_PDCH,
Harald Welte6be350c2011-05-25 13:10:08 +020058};
59
Max582e4f62016-10-18 16:19:33 +020060/* lchans 0..3 are SDCCH in combined channel configuration,
61 use 4 as magic number for BCCH hack - see osmo-bts-../oml.c:opstart_compl() */
62#define CCCH_LCHAN 4
63
Harald Welte6be350c2011-05-25 13:10:08 +020064#define TRX_NR_TS 8
65#define TS_MAX_LCHAN 8
66
67#define HARDCODED_ARFCN 123
Harald Welte6be350c2011-05-25 13:10:08 +020068#define HARDCODED_BSIC 0x3f /* NCC = 7 / BCC = 7 */
69
70/* for multi-drop config */
71#define HARDCODED_BTS0_TS 1
72#define HARDCODED_BTS1_TS 6
73#define HARDCODED_BTS2_TS 11
74
Maxf9685c12017-03-23 12:01:07 +010075#define MAX_VERSION_LENGTH 64
76
Max7b62d542017-05-09 15:19:15 +020077#define MAX_BTS_FEATURES 128
78
Harald Welte6be350c2011-05-25 13:10:08 +020079enum gsm_hooks {
80 GSM_HOOK_NM_SWLOAD,
81 GSM_HOOK_RR_PAGING,
82 GSM_HOOK_RR_SECURITY,
83};
84
85enum gsm_paging_event {
86 GSM_PAGING_SUCCEEDED,
87 GSM_PAGING_EXPIRED,
88 GSM_PAGING_OOM,
89 GSM_PAGING_BUSY,
90};
91
92enum bts_gprs_mode {
93 BTS_GPRS_NONE = 0,
94 BTS_GPRS_GPRS = 1,
95 BTS_GPRS_EGPRS = 2,
96};
97
98struct gsm_lchan;
Harald Welte6be350c2011-05-25 13:10:08 +020099struct 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;
Philipp Maier39f62bb2017-04-09 12:32:51 +0200256
257 /* info we need to postpone the AoIP
258 * assignment completed message */
259 struct {
260 uint8_t rr_cause;
261 uint8_t chosen_channel;
262 uint8_t encr_alg_id;
263 uint8_t speech_mode;
264 bool valid;
265 } ass_compl;
Harald Welte135a6bd2011-09-04 13:53:26 +0200266#else
267 struct osmo_rtp_socket *rtp_socket;
268#endif
Harald Welte6be350c2011-05-25 13:10:08 +0200269 } abis_ip;
270
Harald Welte2c1ae472011-06-26 14:13:37 +0200271 uint8_t rqd_ta;
272
Harald Weltec696cc22015-12-05 16:19:21 +0100273 char *name;
274
Harald Welte6be350c2011-05-25 13:10:08 +0200275#ifdef ROLE_BSC
276 struct osmo_timer_list T3101;
Holger Hans Peter Freytherb3489392011-12-28 16:21:05 +0100277 struct osmo_timer_list T3109;
Harald Welte6be350c2011-05-25 13:10:08 +0200278 struct osmo_timer_list T3111;
279 struct osmo_timer_list error_timer;
Harald Weltee8bd9e82011-08-10 23:26:33 +0200280 struct osmo_timer_list act_timer;
Andreas Eversberg7d8fa342013-12-05 13:25:06 +0100281 struct osmo_timer_list rel_work;
Holger Hans Peter Freyther638da512012-12-06 19:25:06 +0100282 uint8_t error_cause;
Harald Welte6be350c2011-05-25 13:10:08 +0200283
284 /* table of neighbor cell measurements */
285 struct neigh_meas_proc neigh_meas[MAX_NEIGH_MEAS];
286
287 /* cache of last measurement reports on this lchan */
288 struct gsm_meas_rep meas_rep[6];
289 int meas_rep_idx;
290
291 /* GSM Random Access data */
292 struct gsm48_req_ref *rqd_ref;
Harald Welte6be350c2011-05-25 13:10:08 +0200293
294 struct gsm_subscriber_connection *conn;
Andreas Eversberg9df268e2013-10-11 13:32:30 +0200295
296 struct {
297 /* channel activation type and handover ref */
298 uint8_t act_type;
299 uint8_t ho_ref;
Neels Hofmeyrb91e6002016-07-23 19:45:15 +0200300 struct gsm48_req_ref *rqd_ref;
301 uint8_t rqd_ta;
Neels Hofmeyr6e999b72016-07-23 21:00:51 +0200302 } dyn;
Harald Weltef6093a42011-06-25 10:02:33 +0200303#else
Daniel Willmann324c8052012-12-29 12:32:30 +0100304 /* Number of different GsmL1_Sapi_t used in osmo_bts_sysmo is 23.
305 * Currently we don't share these headers so this is a magic number. */
Holger Hans Peter Freyther30156e12013-04-05 18:41:45 +0200306 struct llist_head sapi_cmds;
Daniel Willmann324c8052012-12-29 12:32:30 +0100307 uint8_t sapis_dl[23];
308 uint8_t sapis_ul[23];
Harald Weltef6093a42011-06-25 10:02:33 +0200309 struct lapdm_channel lapdm_ch;
Harald Welte135a6bd2011-09-04 13:53:26 +0200310 struct llist_head dl_tch_queue;
Harald Welte2c1ae472011-06-26 14:13:37 +0200311 struct {
312 /* bitmask of all SI that are present/valid in si_buf */
313 uint32_t valid;
314 uint32_t last;
Max70fdd242017-06-15 15:10:53 +0200315 /* buffers where we put the pre-computed SI:
316 SI2Q_MAX_NUM is the max number of SI2quater messages (see 3GPP TS 44.018) */
317 sysinfo_buf_t buf[_MAX_SYSINFO_TYPE][SI2Q_MAX_NUM];
Harald Welte2c1ae472011-06-26 14:13:37 +0200318 } si;
Harald Weltec7921c92011-06-29 10:38:34 +0200319 struct {
320 uint8_t flags;
321 /* RSL measurment result number, 0 at lchan_act */
322 uint8_t res_nr;
323 /* current Tx power level of the BTS */
324 uint8_t bts_tx_pwr;
325 /* number of measurements stored in array below */
326 uint8_t num_ul_meas;
327 struct bts_ul_meas uplink[MAX_NUM_UL_MEAS];
328 /* last L1 header from the MS */
329 uint8_t l1_info[2];
Harald Welte7ff4f0e2013-03-07 18:38:09 +0000330 struct gsm_meas_rep_unidir ul_res;
Harald Weltec7921c92011-06-29 10:38:34 +0200331 } meas;
Harald Weltef3b59322011-09-06 22:14:43 +0200332 struct {
333 struct amr_multirate_conf amr_mr;
Harald Welte43290992011-09-07 12:41:38 +0200334 struct {
Max1e646f02016-10-05 17:29:02 +0200335 struct osmo_fsm_inst *dl_amr_fsm;
Max1b76a032016-10-25 20:22:16 +0200336 /* TCH cache */
Max1e646f02016-10-05 17:29:02 +0200337 uint8_t cache[20];
Max1b76a032016-10-25 20:22:16 +0200338 /* FACCH cache */
339 uint8_t facch[GSM_MACBLOCK_LEN];
Harald Welte43290992011-09-07 12:41:38 +0200340 uint8_t len;
Maxf5fe31d2016-06-10 14:09:07 +0200341 uint32_t fn;
342 bool is_update;
Max1e646f02016-10-05 17:29:02 +0200343 /* set for each SID frame to detect talkspurt for codecs
344 without explicit ONSET event */
345 bool ul_sid;
346 /* indicates if DTXd was active during DL measurement
347 period */
348 bool dl_active;
349 } dtx;
Holger Hans Peter Freyther922ef5d2014-07-24 21:05:32 +0200350 uint8_t last_cmr;
Maxd7df7ae2016-06-03 12:06:26 +0200351 uint32_t last_fn;
Harald Weltef3b59322011-09-06 22:14:43 +0200352 } tch;
Maxabf53d82017-01-25 16:19:20 +0100353
354 /* 3GPP TS 48.058 § 9.3.37: [0; 255] ok, -1 means invalid*/
355 int16_t ms_t_offs;
356 /* 3GPP TS 45.010 § 1.2 round trip propagation delay (in symbols) or -1 */
357 int16_t p_offs;
358
Harald Welte5d52c972012-04-08 20:23:28 +0200359 /* BTS-side ciphering state (rx only, bi-directional, ...) */
360 uint8_t ciph_state;
Holger Hans Peter Freyther2c6b59c2014-08-09 09:43:53 +0200361 uint8_t ciph_ns;
Harald Welte46cb8512012-04-19 23:13:35 +0200362 uint8_t loopback;
Harald Welte704cb862012-06-16 14:57:08 +0800363 struct {
364 uint8_t active;
365 uint8_t ref;
366 /* T3105: PHYS INF retransmission */
367 struct osmo_timer_list t3105;
368 /* counts up to Ny1 */
369 unsigned int phys_info_count;
370 } ho;
Andreas Eversberg1af682a2013-02-20 16:06:20 +0100371 /* S counter for link loss */
372 int s;
Holger Hans Peter Freytherfc7a75f2013-10-25 18:58:30 +0200373 /* Kind of the release/activation. E.g. RSL or PCU */
374 int rel_act_kind;
Maxec744652016-05-18 16:42:16 +0200375 /* RTP header Marker bit to indicate beginning of speech after pause */
376 bool rtp_tx_marker;
Holger Hans Peter Freytherf6f86b02015-02-05 22:25:03 +0100377 /* power handling */
378 struct {
379 uint8_t current;
380 uint8_t fixed;
381 } ms_power_ctrl;
Minh-Quang Nguyenf1886232017-01-18 16:49:00 +0100382
383 struct msgb *pending_rel_ind_msg;
Harald Welte6be350c2011-05-25 13:10:08 +0200384#endif
385};
386
Neels Hofmeyr2ebacce2016-06-14 14:08:35 +0200387enum {
388 TS_F_PDCH_ACTIVE = 0x1000,
389 TS_F_PDCH_ACT_PENDING = 0x2000,
390 TS_F_PDCH_DEACT_PENDING = 0x4000,
391 TS_F_PDCH_PENDING_MASK = 0x6000 /*<
392 TS_F_PDCH_ACT_PENDING | TS_F_PDCH_DEACT_PENDING */
393} gsm_bts_trx_ts_flags;
394
Harald Welte6be350c2011-05-25 13:10:08 +0200395/* One Timeslot in a TRX */
396struct gsm_bts_trx_ts {
397 struct gsm_bts_trx *trx;
398 /* number of this timeslot at the TRX */
399 uint8_t nr;
400
401 enum gsm_phys_chan_config pchan;
402
Neels Hofmeyrc1658762016-07-23 16:14:06 +0200403 struct {
404 enum gsm_phys_chan_config pchan_is;
405 enum gsm_phys_chan_config pchan_want;
406 struct msgb *pending_chan_activ;
407 } dyn;
408
Harald Welte6be350c2011-05-25 13:10:08 +0200409 unsigned int flags;
Harald Welted64c0bc2011-05-30 12:07:53 +0200410 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200411 struct tlv_parsed nm_attr;
412 uint8_t nm_chan_comb;
Harald Welte135a6482011-05-30 12:09:13 +0200413 int tsc; /* -1 == use BTS TSC */
Harald Welte6be350c2011-05-25 13:10:08 +0200414
415 struct {
416 /* Parameters below are configured by VTY */
417 int enabled;
418 uint8_t maio;
419 uint8_t hsn;
420 struct bitvec arfcns;
421 uint8_t arfcns_data[1024/8];
422 /* This is the pre-computed MA for channel assignments */
423 struct bitvec ma;
424 uint8_t ma_len; /* part of ma_data that is used */
425 uint8_t ma_data[8]; /* 10.5.2.21: max 8 bytes value part */
426 } hopping;
427
428 /* To which E1 subslot are we connected */
429 struct gsm_e1_subslot e1_link;
430
Harald Welte591e1d72016-07-09 22:20:57 +0200431 union {
432 struct {
433 struct om2k_mo om2k_mo;
434 } rbs2000;
435 };
436
Harald Welte6be350c2011-05-25 13:10:08 +0200437 struct gsm_lchan lchan[TS_MAX_LCHAN];
438};
439
440/* One TRX in a BTS */
441struct gsm_bts_trx {
442 /* list header in bts->trx_list */
443 struct llist_head list;
444
445 struct gsm_bts *bts;
446 /* number of this TRX in the BTS */
447 uint8_t nr;
448 /* human readable name / description */
449 char *description;
450 /* how do we talk RSL with this TRX? */
451 struct gsm_e1_subslot rsl_e1_link;
452 uint8_t rsl_tei;
453 struct e1inp_sign_link *rsl_link;
Holger Hans Peter Freythercaa98d52013-10-06 15:52:14 +0200454
Harald Welte6be350c2011-05-25 13:10:08 +0200455 /* Some BTS (specifically Ericsson RBS) have a per-TRX OML Link */
456 struct e1inp_sign_link *oml_link;
457
Harald Welted64c0bc2011-05-30 12:07:53 +0200458 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200459 struct tlv_parsed nm_attr;
460 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200461 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200462 } bb_transc;
463
464 uint16_t arfcn;
465 int nominal_power; /* in dBm */
466 unsigned int max_power_red; /* in actual dB */
Holger Hans Peter Freyther9b625802014-07-30 18:20:51 +0200467
468#ifndef ROLE_BSC
Harald Welte101c5c22014-08-22 16:12:03 +0200469 struct trx_power_params power_params;
Holger Hans Peter Freytherf6f86b02015-02-05 22:25:03 +0100470 int ms_power_control;
Harald Welte6be350c2011-05-25 13:10:08 +0200471
Harald Welted134cc72011-06-07 00:12:53 +0200472 struct {
473 void *l1h;
474 } role_bts;
Holger Hans Peter Freyther9b625802014-07-30 18:20:51 +0200475#endif
Harald Welted134cc72011-06-07 00:12:53 +0200476
Harald Welte6be350c2011-05-25 13:10:08 +0200477 union {
478 struct {
479 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200480 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200481 } bbsig;
482 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200483 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200484 } pa;
485 } bs11;
486 struct {
487 unsigned int test_state;
488 uint8_t test_nr;
489 struct rxlev_stats rxlev_stat;
490 } ipaccess;
Harald Welte591e1d72016-07-09 22:20:57 +0200491 struct {
492 struct {
493 struct om2k_mo om2k_mo;
494 } trxc;
495 struct {
496 struct om2k_mo om2k_mo;
497 } rx;
498 struct {
499 struct om2k_mo om2k_mo;
500 } tx;
501 } rbs2000;
Harald Welte6be350c2011-05-25 13:10:08 +0200502 };
503 struct gsm_bts_trx_ts ts[TRX_NR_TS];
504};
505
Max70fdd242017-06-15 15:10:53 +0200506#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 +0200507#define GSM_BTS_HAS_SI(bts, i) ((bts)->si_valid & (1 << i))
Max70fdd242017-06-15 15:10:53 +0200508#define GSM_BTS_SI(bts, i) (void *)((bts)->si_buf[i][0])
509#define GSM_LCHAN_SI(lchan, i) (void *)((lchan)->si.buf[i][0])
Harald Welte6be350c2011-05-25 13:10:08 +0200510
511enum gsm_bts_type {
512 GSM_BTS_TYPE_UNKNOWN,
513 GSM_BTS_TYPE_BS11,
514 GSM_BTS_TYPE_NANOBTS,
515 GSM_BTS_TYPE_RBS2000,
Dieter Spaar16646022011-07-28 00:01:50 +0200516 GSM_BTS_TYPE_NOKIA_SITE,
Maxf9685c12017-03-23 12:01:07 +0100517 GSM_BTS_TYPE_OSMOBTS,
Harald Weltee555c2b2012-08-17 13:02:12 +0200518 _NUM_GSM_BTS_TYPE
Harald Welte6be350c2011-05-25 13:10:08 +0200519};
520
Maxf9685c12017-03-23 12:01:07 +0100521enum gsm_bts_type_variant {
522 BTS_UNKNOWN,
523 BTS_OSMO_LITECELL15,
524 BTS_OSMO_OCTPHY,
525 BTS_OSMO_SYSMO,
526 BTS_OSMO_TRX,
527 _NUM_BTS_VARIANT
528};
529
Max7507aef2017-04-10 13:59:14 +0200530/* Used by OML layer for BTS Attribute reporting */
531enum bts_attribute {
532 BTS_TYPE_VARIANT,
533 BTS_SUB_MODEL,
Max33e13572017-05-29 11:48:29 +0200534 TRX_PHY_VERSION,
Max7507aef2017-04-10 13:59:14 +0200535};
536
Harald Welte6be350c2011-05-25 13:10:08 +0200537struct vty;
538
539struct gsm_bts_model {
540 struct llist_head list;
541
542 enum gsm_bts_type type;
Maxf9685c12017-03-23 12:01:07 +0100543 enum gsm_bts_type_variant variant;
Harald Welte6be350c2011-05-25 13:10:08 +0200544 const char *name;
545
546 bool started;
547 int (*start)(struct gsm_network *net);
548 int (*oml_rcvmsg)(struct msgb *msg);
Max3d049d22017-10-09 17:12:53 +0200549 char * (*oml_status)(const struct gsm_bts *bts);
Harald Welte6be350c2011-05-25 13:10:08 +0200550
Pablo Neira Ayusoed5cacb2011-08-17 22:44:07 +0200551 void (*e1line_bind_ops)(struct e1inp_line *line);
552
Harald Welte6be350c2011-05-25 13:10:08 +0200553 void (*config_write_bts)(struct vty *vty, struct gsm_bts *bts);
554 void (*config_write_trx)(struct vty *vty, struct gsm_bts_trx *trx);
555 void (*config_write_ts)(struct vty *vty, struct gsm_bts_trx_ts *ts);
556
557 struct tlv_definition nm_att_tlvdef;
558
Maxaef68382017-05-31 12:15:54 +0200559 /* features of a given BTS model set via gsm_bts_model_register() locally */
Harald Welte6be350c2011-05-25 13:10:08 +0200560 struct bitvec features;
Max7b62d542017-05-09 15:19:15 +0200561 uint8_t _features_data[MAX_BTS_FEATURES/8];
Harald Welte6be350c2011-05-25 13:10:08 +0200562};
563
Maxaef68382017-05-31 12:15:54 +0200564/* N. B: always add new features to the end of the list (right before _NUM_BTS_FEAT) to avoid breaking compatibility
565 with BTS compiled against earlier version of this header */
Harald Welte6be350c2011-05-25 13:10:08 +0200566enum gsm_bts_features {
567 BTS_FEAT_HSCSD,
568 BTS_FEAT_GPRS,
569 BTS_FEAT_EGPRS,
570 BTS_FEAT_ECSD,
571 BTS_FEAT_HOPPING,
Harald Welte903aaea2014-01-19 17:10:50 +0100572 BTS_FEAT_MULTI_TSC,
Max1ebf23b2017-05-10 12:21:17 +0200573 BTS_FEAT_OML_ALERTS,
574 BTS_FEAT_AGCH_PCH_PROP,
575 BTS_FEAT_CBCH,
Maxaef68382017-05-31 12:15:54 +0200576 _NUM_BTS_FEAT
Harald Welte6be350c2011-05-25 13:10:08 +0200577};
578
Maxaef68382017-05-31 12:15:54 +0200579extern const struct value_string gsm_bts_features_descs[];
580
Harald Welte6be350c2011-05-25 13:10:08 +0200581/*
582 * This keeps track of the paging status of one BTS. It
583 * includes a number of pending requests, a back pointer
584 * to the gsm_bts, a timer and some more state.
585 */
586struct gsm_bts_paging_state {
587 /* pending requests */
588 struct llist_head pending_requests;
589 struct gsm_bts *bts;
590
591 struct osmo_timer_list work_timer;
592 struct osmo_timer_list credit_timer;
593
594 /* free chans needed */
595 int free_chans_need;
596
597 /* load */
598 uint16_t available_slots;
599};
600
601struct gsm_envabtse {
Harald Welted64c0bc2011-05-30 12:07:53 +0200602 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200603};
604
605struct gsm_bts_gprs_nsvc {
606 struct gsm_bts *bts;
607 /* data read via VTY config file, to configure the BTS
608 * via OML from BSC */
609 int id;
610 uint16_t nsvci;
611 uint16_t local_port; /* on the BTS */
612 uint16_t remote_port; /* on the SGSN */
613 uint32_t remote_ip; /* on the SGSN */
614
Harald Welted64c0bc2011-05-30 12:07:53 +0200615 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200616};
617
Harald Welte019f9132012-06-28 08:43:14 +0200618enum gprs_rlc_par {
619 RLC_T3142,
620 RLC_T3169,
621 RLC_T3191,
622 RLC_T3193,
623 RLC_T3195,
624 RLC_N3101,
625 RLC_N3103,
626 RLC_N3105,
627 CV_COUNTDOWN,
628 T_DL_TBF_EXT, /* ms */
629 T_UL_TBF_EXT, /* ms */
630 _NUM_RLC_PAR
631};
632
633enum gprs_cs {
634 GPRS_CS1,
635 GPRS_CS2,
636 GPRS_CS3,
637 GPRS_CS4,
638 GPRS_MCS1,
639 GPRS_MCS2,
640 GPRS_MCS3,
641 GPRS_MCS4,
642 GPRS_MCS5,
643 GPRS_MCS6,
644 GPRS_MCS7,
645 GPRS_MCS8,
646 GPRS_MCS9,
647 _NUM_GRPS_CS
648};
649
650struct gprs_rlc_cfg {
651 uint16_t parameter[_NUM_RLC_PAR];
652 struct {
653 uint16_t repeat_time; /* ms */
654 uint8_t repeat_count;
655 } paging;
656 uint32_t cs_mask; /* bitmask of gprs_cs */
657 uint8_t initial_cs;
658 uint8_t initial_mcs;
659};
660
661
Harald Welte6be350c2011-05-25 13:10:08 +0200662enum neigh_list_manual_mode {
663 NL_MODE_AUTOMATIC = 0,
664 NL_MODE_MANUAL = 1,
665 NL_MODE_MANUAL_SI5SEP = 2, /* SI2 and SI5 have separate neighbor lists */
666};
667
Daniel Willmann47b5b3e2011-08-05 13:51:27 +0200668enum bts_loc_fix {
669 BTS_LOC_FIX_INVALID = 0,
670 BTS_LOC_FIX_2D = 1,
671 BTS_LOC_FIX_3D = 2,
672};
673
Daniel Willmann7d109832012-05-14 18:43:23 +0200674extern const struct value_string bts_loc_fix_names[];
675
Daniel Willmann47b5b3e2011-08-05 13:51:27 +0200676struct bts_location {
677 struct llist_head list;
678 time_t tstamp;
679 enum bts_loc_fix valid;
680 double lat;
681 double lon;
682 double height;
683};
684
Harald Welte6be350c2011-05-25 13:10:08 +0200685/* One BTS */
686struct gsm_bts {
687 /* list header in net->bts_list */
688 struct llist_head list;
689
Daniel Willmann47b5b3e2011-08-05 13:51:27 +0200690 /* Geographical location of the BTS */
691 struct llist_head loc_list;
692
Harald Welte6be350c2011-05-25 13:10:08 +0200693 /* number of ths BTS in network */
694 uint8_t nr;
695 /* human readable name / description */
696 char *description;
697 /* Cell Identity */
698 uint16_t cell_identity;
699 /* location area code of this BTS */
700 uint16_t location_area_code;
Harald Weltea2bbc5e2015-11-20 10:43:31 +0100701 /* Base Station Identification Code (BSIC), lower 3 bits is BCC,
702 * which is used as TSC for the CCCH */
Harald Welte6be350c2011-05-25 13:10:08 +0200703 uint8_t bsic;
704 /* type of BTS */
705 enum gsm_bts_type type;
Max6d8e5192017-04-11 18:23:47 +0200706 enum gsm_bts_type_variant variant;
Harald Welte6be350c2011-05-25 13:10:08 +0200707 struct gsm_bts_model *model;
708 enum gsm_band band;
Maxf9685c12017-03-23 12:01:07 +0100709 char version[MAX_VERSION_LENGTH];
Max1ebf23b2017-05-10 12:21:17 +0200710 char sub_model[MAX_VERSION_LENGTH];
Maxf9685c12017-03-23 12:01:07 +0100711
Maxaef68382017-05-31 12:15:54 +0200712 /* features of a given BTS set/reported via OML */
713 struct bitvec features;
714 uint8_t _features_data[MAX_BTS_FEATURES/8];
715
Maxf9685c12017-03-23 12:01:07 +0100716 /* Connected PCU version (if any) */
717 char pcu_version[MAX_VERSION_LENGTH];
718
Harald Welte6be350c2011-05-25 13:10:08 +0200719 /* maximum Tx power that the MS is permitted to use in this cell */
720 int ms_max_power;
721
722 /* how do we talk OML with this TRX? */
723 struct gsm_e1_subslot oml_e1_link;
724 uint8_t oml_tei;
725 struct e1inp_sign_link *oml_link;
Maxd1f70ed2017-09-21 16:15:32 +0200726 /* when OML link was established */
727 time_t uptime;
Harald Welte6be350c2011-05-25 13:10:08 +0200728
729 /* Abis network management O&M handle */
730 struct abis_nm_h *nmh;
Harald Welted64c0bc2011-05-30 12:07:53 +0200731
732 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200733
734 /* number of this BTS on given E1 link */
735 uint8_t bts_nr;
736
Maxc08ee712016-05-11 12:45:13 +0200737 /* DTX features of this BTS */
738 enum gsm48_dtx_mode dtxu;
739 bool dtxd;
740
Harald Welte6be350c2011-05-25 13:10:08 +0200741 /* paging state and control */
742 struct gsm_bts_paging_state paging;
743
744 /* CCCH is on C0 */
745 struct gsm_bts_trx *c0;
746
747 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200748 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200749 } site_mgr;
750
751 /* bitmask of all SI that are present/valid in si_buf */
752 uint32_t si_valid;
Max6f0e50c2017-04-12 15:30:54 +0200753 /* 3GPP TS 44.018 Table 10.5.2.33b.1 INDEX and COUNT for SI2quater */
Maxf39d03a2017-05-12 17:00:30 +0200754 uint8_t si2q_index; /* distinguish individual SI2quater messages */
755 uint8_t si2q_count; /* si2q_index for the last (highest indexed) individual SI2quater message */
Harald Welte6be350c2011-05-25 13:10:08 +0200756 /* buffers where we put the pre-computed SI */
Max70fdd242017-06-15 15:10:53 +0200757 sysinfo_buf_t si_buf[_MAX_SYSINFO_TYPE][SI2Q_MAX_NUM];
Maxf39d03a2017-05-12 17:00:30 +0200758 /* offsets used while generating SI2quater */
759 size_t e_offset;
760 size_t u_offset;
Harald Welte6be350c2011-05-25 13:10:08 +0200761
762 /* ip.accesss Unit ID's have Site/BTS/TRX layout */
763 union {
764 struct {
765 uint16_t site_id;
766 uint16_t bts_id;
767 uint32_t flags;
Harald Welte8b291802013-03-12 13:57:05 +0100768 uint32_t rsl_ip;
Harald Welte6be350c2011-05-25 13:10:08 +0200769 } ip_access;
770 struct {
771 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200772 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200773 } cclk;
774 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200775 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200776 } rack;
777 struct gsm_envabtse envabtse[4];
778 } bs11;
779 struct {
780 struct {
Harald Welte591e1d72016-07-09 22:20:57 +0200781 struct om2k_mo om2k_mo;
782 struct gsm_abis_mo mo;
783 struct llist_head conn_groups;
784 } cf;
785 struct {
786 struct om2k_mo om2k_mo;
Harald Welted64c0bc2011-05-30 12:07:53 +0200787 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200788 struct llist_head conn_groups;
789 } is;
790 struct {
Harald Welte591e1d72016-07-09 22:20:57 +0200791 struct om2k_mo om2k_mo;
Harald Welted64c0bc2011-05-30 12:07:53 +0200792 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200793 struct llist_head conn_groups;
794 } con;
795 struct {
Harald Welte591e1d72016-07-09 22:20:57 +0200796 struct om2k_mo om2k_mo;
Harald Welted64c0bc2011-05-30 12:07:53 +0200797 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200798 } dp;
799 struct {
Harald Welte591e1d72016-07-09 22:20:57 +0200800 struct om2k_mo om2k_mo;
Harald Welted64c0bc2011-05-30 12:07:53 +0200801 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200802 } tf;
Harald Weltece492582016-11-15 22:59:24 +0100803 uint32_t use_superchannel:1;
Harald Welte6be350c2011-05-25 13:10:08 +0200804 } rbs2000;
805 struct {
Harald Weltec8755af2011-07-28 00:22:17 +0200806 uint8_t bts_type;
Holger Hans Peter Freyther3e603482012-03-02 14:14:33 +0100807 unsigned int configured:1,
808 skip_reset:1,
Andreas Eversberg7d8fa342013-12-05 13:25:06 +0100809 no_loc_rel_cnf:1,
Sipos Csaba56e17662015-02-07 13:27:36 +0100810 bts_reset_timer_cnf,
Holger Hans Peter Freyther3e603482012-03-02 14:14:33 +0100811 did_reset:1,
812 wait_reset:1;
Harald Weltec8755af2011-07-28 00:22:17 +0200813 struct osmo_timer_list reset_timer;
814 } nokia;
Harald Welte6be350c2011-05-25 13:10:08 +0200815 };
816
817 /* Not entirely sure how ip.access specific this is */
818 struct {
bhargava350533c2016-07-21 11:14:34 +0530819 uint8_t supports_egprs_11bit_rach;
Harald Welte6be350c2011-05-25 13:10:08 +0200820 enum bts_gprs_mode mode;
821 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200822 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200823 uint16_t nsei;
824 uint8_t timer[7];
825 } nse;
826 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200827 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200828 uint16_t bvci;
829 uint8_t timer[11];
Harald Welte019f9132012-06-28 08:43:14 +0200830 struct gprs_rlc_cfg rlc_cfg;
Harald Welte6be350c2011-05-25 13:10:08 +0200831 } cell;
832 struct gsm_bts_gprs_nsvc nsvc[2];
833 uint8_t rac;
Andreas Eversberg0c8f9ca2013-03-16 16:31:26 +0100834 uint8_t net_ctrl_ord;
Max292ec582016-07-28 11:55:37 +0200835 bool ctrl_ack_type_use_block;
Harald Welte6be350c2011-05-25 13:10:08 +0200836 } gprs;
837
838 /* RACH NM values */
839 int rach_b_thresh;
840 int rach_ldavg_slots;
841
842 /* transceivers */
843 int num_trx;
844 struct llist_head trx_list;
845
Holger Hans Peter Freytherb92a5382014-11-21 10:00:39 +0100846 /* SI related items */
Jacob Erlbeck65d114f2014-01-16 11:02:14 +0100847 int force_combined_si;
Holger Hans Peter Freytherb92a5382014-11-21 10:00:39 +0100848 int bcch_change_mark;
Jacob Erlbeck65d114f2014-01-16 11:02:14 +0100849
Harald Welte6be350c2011-05-25 13:10:08 +0200850#ifdef ROLE_BSC
851 /* Abis NM queue */
852 struct llist_head abis_queue;
853 int abis_nm_pend;
854
855 struct gsm_network *network;
856
857 /* should the channel allocator allocate channels from high TRX to TRX0,
858 * rather than starting from TRX0 and go upwards? */
859 int chan_alloc_reverse;
860
861 enum neigh_list_manual_mode neigh_list_manual_mode;
862 /* parameters from which we build SYSTEM INFORMATION */
863 struct {
864 struct gsm48_rach_control rach_control;
865 uint8_t ncc_permitted;
866 struct gsm48_cell_sel_par cell_sel_par;
867 struct gsm48_si_selection_params cell_ro_sel_par; /* rest octet */
868 struct gsm48_cell_options cell_options;
869 struct gsm48_control_channel_descr chan_desc;
870 struct bitvec neigh_list;
871 struct bitvec cell_alloc;
872 struct bitvec si5_neigh_list;
Max59a1bf32016-04-15 16:04:46 +0200873 struct osmo_earfcn_si2q si2quater_neigh_list;
Max26679e02016-04-20 15:57:13 +0200874 size_t uarfcn_length; /* index for uarfcn and scramble lists */
Harald Welte6be350c2011-05-25 13:10:08 +0200875 struct {
876 /* bitmask large enough for all possible ARFCN's */
877 uint8_t neigh_list[1024/8];
878 uint8_t cell_alloc[1024/8];
879 /* If the user wants a different neighbor list in SI5 than in SI2 */
880 uint8_t si5_neigh_list[1024/8];
Max59a1bf32016-04-15 16:04:46 +0200881 uint8_t meas_bw_list[MAX_EARFCN_LIST];
882 uint16_t earfcn_list[MAX_EARFCN_LIST];
Max26679e02016-04-20 15:57:13 +0200883 uint16_t uarfcn_list[MAX_EARFCN_LIST];
884 uint16_t scramble_list[MAX_EARFCN_LIST];
Harald Welte6be350c2011-05-25 13:10:08 +0200885 } data;
886 } si_common;
Harald Welte42def722017-01-13 00:10:32 +0100887 bool early_classmark_allowed;
Pau Espin Pedrole8dda5f2017-11-23 19:06:09 +0100888 bool early_classmark_allowed_3g;
Harald Welte2f8b9d22017-06-18 11:12:13 +0300889 /* for testing only: Have an infinitely long radio link timeout */
890 bool infinite_radio_link_timeout;
Harald Welte6be350c2011-05-25 13:10:08 +0200891
892 /* do we use static (user-defined) system information messages? (bitmask) */
893 uint32_t si_mode_static;
Holger Hans Peter Freythere30d40d2012-07-20 10:27:31 +0200894
895 /* exclude the BTS from the global RF Lock handling */
896 int excl_from_rf_lock;
Andreas Eversberga83d5112013-12-07 18:32:28 +0100897
898 /* supported codecs beside FR */
899 struct bts_codec_conf codec;
Holger Hans Peter Freytherc22930e2014-12-17 14:46:17 +0100900
901 /* BTS dependencies bit field */
902 uint32_t depends_on[256/(8*4)];
Andreas Eversberg73266522014-01-19 11:47:44 +0100903
904 /* full and half rate multirate config */
905 struct amr_multirate_conf mr_full;
906 struct amr_multirate_conf mr_half;
907
Philipp Maierb4999b62016-10-26 15:19:41 +0200908 /* PCU socket state */
Harald Welte8254cf72017-05-29 13:42:19 +0200909 char *pcu_sock_path;
Philipp Maierb4999b62016-10-26 15:19:41 +0200910 struct pcu_sock_state *pcu_state;
911
Harald Welte6be350c2011-05-25 13:10:08 +0200912#endif /* ROLE_BSC */
Harald Welte978714d2011-06-06 18:31:20 +0200913 void *role;
Harald Welte6be350c2011-05-25 13:10:08 +0200914};
915
916
Alexander Chemeris0796a6c2017-07-11 01:42:41 +0630917struct gsm_bts *gsm_bts_alloc(void *talloc_ctx, uint8_t bts_num);
Harald Welte1449c9f2014-08-24 09:50:10 +0200918struct gsm_bts *gsm_bts_num(struct gsm_network *net, int num);
Harald Welte6be350c2011-05-25 13:10:08 +0200919
Harald Welte1449c9f2014-08-24 09:50:10 +0200920struct gsm_bts_trx *gsm_bts_trx_alloc(struct gsm_bts *bts);
Harald Welte4f8ad532011-09-19 14:21:51 +0200921struct gsm_bts_trx *gsm_bts_trx_num(const struct gsm_bts *bts, int num);
Harald Welte6be350c2011-05-25 13:10:08 +0200922
Max7507aef2017-04-10 13:59:14 +0200923enum gsm_bts_type str2btstype(const char *arg);
924const char *btstype2str(enum gsm_bts_type type);
925
926enum bts_attribute str2btsattr(const char *s);
927const char *btsatttr2str(enum bts_attribute v);
928
929enum gsm_bts_type_variant str2btsvariant(const char *arg);
930const char *btsvariant2str(enum gsm_bts_type_variant v);
Harald Welte4ab9d7c2012-08-17 12:42:06 +0200931
Philipp Maier6f483d32017-02-24 15:18:08 +0100932extern const struct value_string gsm_chreq_descs[];
Neels Hofmeyr17a6bab2016-07-23 16:14:06 +0200933const struct value_string gsm_pchant_names[13];
934const struct value_string gsm_pchant_descs[13];
Harald Welte6be350c2011-05-25 13:10:08 +0200935const char *gsm_pchan_name(enum gsm_phys_chan_config c);
936enum gsm_phys_chan_config gsm_pchan_parse(const char *name);
937const char *gsm_lchant_name(enum gsm_chan_t c);
938const char *gsm_chreq_name(enum gsm_chreq_reason_t c);
Harald Welte4f8ad532011-09-19 14:21:51 +0200939char *gsm_trx_name(const struct gsm_bts_trx *trx);
940char *gsm_ts_name(const struct gsm_bts_trx_ts *ts);
Neels Hofmeyr34b8b5b2016-07-16 23:59:32 +0200941char *gsm_ts_and_pchan_name(const struct gsm_bts_trx_ts *ts);
Harald Weltec696cc22015-12-05 16:19:21 +0100942char *gsm_lchan_name_compute(const struct gsm_lchan *lchan);
Harald Welte6be350c2011-05-25 13:10:08 +0200943const char *gsm_lchans_name(enum gsm_lchan_state s);
944
Harald Weltec696cc22015-12-05 16:19:21 +0100945static inline char *gsm_lchan_name(const struct gsm_lchan *lchan)
946{
947 return lchan->name;
948}
Harald Welte6be350c2011-05-25 13:10:08 +0200949
Maxaef68382017-05-31 12:15:54 +0200950static inline int gsm_bts_set_feature(struct gsm_bts *bts, enum gsm_bts_features feat)
951{
952 OSMO_ASSERT(_NUM_BTS_FEAT < MAX_BTS_FEATURES);
953 return bitvec_set_bit_pos(&bts->features, feat, 1);
954}
955
956static inline bool gsm_bts_has_feature(const struct gsm_bts *bts, enum gsm_bts_features feat)
957{
958 OSMO_ASSERT(_NUM_BTS_FEAT < MAX_BTS_FEATURES);
959 return bitvec_get_bit_pos(&bts->features, feat);
960}
961
Harald Welteb7849982011-06-29 16:49:03 +0200962void gsm_abis_mo_reset(struct gsm_abis_mo *mo);
963
Harald Welte978714d2011-06-06 18:31:20 +0200964struct gsm_abis_mo *
965gsm_objclass2mo(struct gsm_bts *bts, uint8_t obj_class,
Harald Welte4f8ad532011-09-19 14:21:51 +0200966 const struct abis_om_obj_inst *obj_inst);
Harald Welte978714d2011-06-06 18:31:20 +0200967
968struct gsm_nm_state *
969gsm_objclass2nmstate(struct gsm_bts *bts, uint8_t obj_class,
Harald Welte4f8ad532011-09-19 14:21:51 +0200970 const struct abis_om_obj_inst *obj_inst);
Harald Welte978714d2011-06-06 18:31:20 +0200971void *
972gsm_objclass2obj(struct gsm_bts *bts, uint8_t obj_class,
Harald Welte4f8ad532011-09-19 14:21:51 +0200973 const struct abis_om_obj_inst *obj_inst);
Harald Welte978714d2011-06-06 18:31:20 +0200974
Harald Welteb7849982011-06-29 16:49:03 +0200975/* reset the state of all MO in the BTS */
976void gsm_bts_mo_reset(struct gsm_bts *bts);
977
Neels Hofmeyrd3841102016-07-18 23:43:44 +0200978uint8_t gsm_pchan2chan_nr(enum gsm_phys_chan_config pchan,
979 uint8_t ts_nr, uint8_t lchan_nr);
Harald Weltef6093a42011-06-25 10:02:33 +0200980uint8_t gsm_lchan2chan_nr(const struct gsm_lchan *lchan);
Neels Hofmeyrd3841102016-07-18 23:43:44 +0200981uint8_t gsm_lchan_as_pchan2chan_nr(const struct gsm_lchan *lchan,
982 enum gsm_phys_chan_config as_pchan);
Harald Weltef6093a42011-06-25 10:02:33 +0200983
Harald Welte142d12d2014-12-29 17:47:08 +0100984/* return the gsm_lchan for the CBCH (if it exists at all) */
985struct gsm_lchan *gsm_bts_get_cbch(struct gsm_bts *bts);
986
Holger Hans Peter Freyther06c9da62011-06-09 21:48:49 +0200987/*
988 * help with parsing regexps
989 */
990int gsm_parse_reg(void *ctx, regex_t *reg, char **str,
991 int argc, const char **argv) __attribute__ ((warn_unused_result));
992
Harald Welte1fe24122014-01-19 17:18:21 +0100993static inline uint8_t gsm_ts_tsc(const struct gsm_bts_trx_ts *ts)
994{
995 if (ts->tsc != -1)
996 return ts->tsc;
997 else
Harald Weltea2bbc5e2015-11-20 10:43:31 +0100998 return ts->trx->bts->bsic & 7;
Harald Welte1fe24122014-01-19 17:18:21 +0100999}
Holger Hans Peter Freyther06c9da62011-06-09 21:48:49 +02001000
Neels Hofmeyr74585722016-07-23 17:38:22 +02001001struct gsm_lchan *rsl_lchan_lookup(struct gsm_bts_trx *trx, uint8_t chan_nr,
1002 int *rc);
Holger Hans Peter Freyther06c9da62011-06-09 21:48:49 +02001003
Neels Hofmeyrec16c162016-10-17 01:03:53 +02001004enum gsm_phys_chan_config ts_pchan(struct gsm_bts_trx_ts *ts);
Neels Hofmeyr76a0ad72016-07-29 18:12:06 +02001005uint8_t ts_subslots(struct gsm_bts_trx_ts *ts);
Neels Hofmeyr255dbfe2016-09-25 15:07:01 +02001006bool ts_is_tch(struct gsm_bts_trx_ts *ts);
Neels Hofmeyr76a0ad72016-07-29 18:12:06 +02001007
Harald Welte6be350c2011-05-25 13:10:08 +02001008#endif