blob: 63f4d33965e8c8fbfff380634fd909cd06e37113 [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>
Max43b01b02017-09-15 11:22:30 +020020#include <osmocom/msc/meas_rep.h>
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 Hofmeyr90843962017-09-04 15:04:35 +020027#include <osmocom/msc/common_cs.h>
Neels Hofmeyrac1f1432016-05-10 13:30:17 +020028
Holger Hans Peter Freyther8ec49522011-08-15 15:53:00 +020029struct osmo_bsc_data;
30
Harald Welte6be350c2011-05-25 13:10:08 +020031struct osmo_bsc_sccp_con;
32struct gsm_sms_queue;
33
34/* RRLP mode of operation */
35enum rrlp_mode {
36 RRLP_MODE_NONE,
37 RRLP_MODE_MS_BASED,
38 RRLP_MODE_MS_PREF,
39 RRLP_MODE_ASS_PREF,
40};
41
42/* Channel Request reason */
43enum gsm_chreq_reason_t {
44 GSM_CHREQ_REASON_EMERG,
45 GSM_CHREQ_REASON_PAG,
46 GSM_CHREQ_REASON_CALL,
47 GSM_CHREQ_REASON_LOCATION_UPD,
48 GSM_CHREQ_REASON_OTHER,
Alexander Couzens11368112016-11-28 23:26:50 +010049 GSM_CHREQ_REASON_PDCH,
Harald Welte6be350c2011-05-25 13:10:08 +020050};
51
Max582e4f62016-10-18 16:19:33 +020052/* lchans 0..3 are SDCCH in combined channel configuration,
53 use 4 as magic number for BCCH hack - see osmo-bts-../oml.c:opstart_compl() */
54#define CCCH_LCHAN 4
55
Harald Welte6be350c2011-05-25 13:10:08 +020056#define TRX_NR_TS 8
57#define TS_MAX_LCHAN 8
58
59#define HARDCODED_ARFCN 123
Harald Welte6be350c2011-05-25 13:10:08 +020060#define HARDCODED_BSIC 0x3f /* NCC = 7 / BCC = 7 */
61
62/* for multi-drop config */
63#define HARDCODED_BTS0_TS 1
64#define HARDCODED_BTS1_TS 6
65#define HARDCODED_BTS2_TS 11
66
Maxf9685c12017-03-23 12:01:07 +010067#define MAX_VERSION_LENGTH 64
68
Max7b62d542017-05-09 15:19:15 +020069#define MAX_BTS_FEATURES 128
70
Harald Welte6be350c2011-05-25 13:10:08 +020071enum gsm_hooks {
72 GSM_HOOK_NM_SWLOAD,
73 GSM_HOOK_RR_PAGING,
74 GSM_HOOK_RR_SECURITY,
75};
76
77enum gsm_paging_event {
78 GSM_PAGING_SUCCEEDED,
79 GSM_PAGING_EXPIRED,
80 GSM_PAGING_OOM,
81 GSM_PAGING_BUSY,
82};
83
84enum bts_gprs_mode {
85 BTS_GPRS_NONE = 0,
86 BTS_GPRS_GPRS = 1,
87 BTS_GPRS_EGPRS = 2,
88};
89
90struct gsm_lchan;
Harald Welte6be350c2011-05-25 13:10:08 +020091struct gsm_mncc;
Harald Welte135a6bd2011-09-04 13:53:26 +020092struct osmo_rtp_socket;
Harald Welte6be350c2011-05-25 13:10:08 +020093struct rtp_socket;
94struct bsc_api;
95
96/* Network Management State */
97struct gsm_nm_state {
98 uint8_t operational;
99 uint8_t administrative;
100 uint8_t availability;
101};
102
Harald Welted64c0bc2011-05-30 12:07:53 +0200103struct gsm_abis_mo {
Harald Welte3300c012011-06-05 13:31:33 +0200104 uint8_t obj_class;
Holger Hans Peter Freyther49976f42013-11-05 16:06:17 +0100105 uint8_t procedure_pending;
Harald Welte3300c012011-06-05 13:31:33 +0200106 struct abis_om_obj_inst obj_inst;
Harald Welted64c0bc2011-05-30 12:07:53 +0200107 const char *name;
108 struct gsm_nm_state nm_state;
109 struct tlv_parsed *nm_attr;
Harald Welte32bc1162011-06-06 18:58:48 +0200110 struct gsm_bts *bts;
Harald Welted64c0bc2011-05-30 12:07:53 +0200111};
112
Harald Welte591e1d72016-07-09 22:20:57 +0200113/* Ericsson OM2000 Managed Object */
114struct abis_om2k_mo {
115 uint8_t class;
116 uint8_t bts;
117 uint8_t assoc_so;
118 uint8_t inst;
119} __attribute__ ((packed));
120
121struct om2k_mo {
122 struct abis_om2k_mo addr;
123 struct osmo_fsm_inst *fsm;
124};
125
Harald Welte6be350c2011-05-25 13:10:08 +0200126#define A38_XOR_MIN_KEY_LEN 12
127#define A38_XOR_MAX_KEY_LEN 16
128#define A38_COMP128_KEY_LEN 16
129#define RSL_ENC_ALG_A5(x) (x+1)
Max27c3e762016-04-20 15:57:12 +0200130#define MAX_EARFCN_LIST 32
Harald Welte6be350c2011-05-25 13:10:08 +0200131
132/* is the data link established? who established it? */
133#define LCHAN_SAPI_UNUSED 0
134#define LCHAN_SAPI_MS 1
135#define LCHAN_SAPI_NET 2
Andreas Eversberg7d8fa342013-12-05 13:25:06 +0100136#define LCHAN_SAPI_REL 3
Harald Welte6be350c2011-05-25 13:10:08 +0200137
138/* state of a logical channel */
139enum gsm_lchan_state {
140 LCHAN_S_NONE, /* channel is not active */
Holger Hans Peter Freytherded02682012-01-15 00:02:17 +0100141 LCHAN_S_ACT_REQ, /* channel activation requested */
Harald Welte6be350c2011-05-25 13:10:08 +0200142 LCHAN_S_ACTIVE, /* channel is active and operational */
143 LCHAN_S_REL_REQ, /* channel release has been requested */
144 LCHAN_S_REL_ERR, /* channel is in an error state */
Holger Hans Peter Freyther638da512012-12-06 19:25:06 +0100145 LCHAN_S_BROKEN, /* channel is somehow unusable */
Harald Welte6be350c2011-05-25 13:10:08 +0200146 LCHAN_S_INACTIVE, /* channel is set inactive */
147};
148
Harald Weltec7921c92011-06-29 10:38:34 +0200149/* BTS ONLY */
150#define MAX_NUM_UL_MEAS 104
151#define LC_UL_M_F_L1_VALID (1 << 0)
152#define LC_UL_M_F_RES_VALID (1 << 1)
153
154struct bts_ul_meas {
155 /* BER in units of 0.01%: 10.000 == 100% ber, 0 == 0% ber */
156 uint16_t ber10k;
157 /* timing advance offset (in quarter bits) */
158 int16_t ta_offs_qbits;
159 /* C/I ratio in dB */
160 float c_i;
161 /* flags */
162 uint8_t is_sub:1;
163 /* RSSI in dBm * -1 */
164 uint8_t inv_rssi;
165};
Harald Weltef3b59322011-09-06 22:14:43 +0200166
Andreas Eversberga83d5112013-12-07 18:32:28 +0100167struct bts_codec_conf {
168 uint8_t hr;
169 uint8_t efr;
170 uint8_t amr;
171};
172
Harald Weltef3b59322011-09-06 22:14:43 +0200173struct amr_mode {
174 uint8_t mode;
Holger Hans Peter Freyther615ed462015-09-24 11:30:58 +0200175 uint8_t threshold;
176 uint8_t hysteresis;
Harald Weltef3b59322011-09-06 22:14:43 +0200177};
Holger Hans Peter Freyther615ed462015-09-24 11:30:58 +0200178
Harald Weltef3b59322011-09-06 22:14:43 +0200179struct amr_multirate_conf {
180 uint8_t gsm48_ie[2];
Holger Hans Peter Freyther615ed462015-09-24 11:30:58 +0200181 struct amr_mode ms_mode[4];
182 struct amr_mode bts_mode[4];
Harald Weltef3b59322011-09-06 22:14:43 +0200183 uint8_t num_modes;
184};
Harald Weltec7921c92011-06-29 10:38:34 +0200185/* /BTS ONLY */
186
Harald Weltee4227982012-08-24 15:33:56 +0200187enum lchan_csd_mode {
188 LCHAN_CSD_M_NT,
189 LCHAN_CSD_M_T_1200_75,
190 LCHAN_CSD_M_T_600,
191 LCHAN_CSD_M_T_1200,
192 LCHAN_CSD_M_T_2400,
193 LCHAN_CSD_M_T_9600,
194 LCHAN_CSD_M_T_14400,
195 LCHAN_CSD_M_T_29000,
196 LCHAN_CSD_M_T_32000,
197};
198
Daniel Willmann324c8052012-12-29 12:32:30 +0100199/* State of the SAPIs in the lchan */
200enum lchan_sapi_state {
201 LCHAN_SAPI_S_NONE,
202 LCHAN_SAPI_S_REQ,
203 LCHAN_SAPI_S_ASSIGNED,
204 LCHAN_SAPI_S_REL,
205 LCHAN_SAPI_S_ERROR,
206};
207
Harald Welte6be350c2011-05-25 13:10:08 +0200208struct gsm_lchan {
209 /* The TS that we're part of */
210 struct gsm_bts_trx_ts *ts;
211 /* The logical subslot number in the TS */
212 uint8_t nr;
213 /* The logical channel type */
214 enum gsm_chan_t type;
215 /* RSL channel mode */
216 enum rsl_cmod_spd rsl_cmode;
217 /* If TCH, traffic channel mode */
218 enum gsm48_chan_mode tch_mode;
Harald Weltee4227982012-08-24 15:33:56 +0200219 enum lchan_csd_mode csd_mode;
Harald Welte6be350c2011-05-25 13:10:08 +0200220 /* State */
221 enum gsm_lchan_state state;
Holger Hans Peter Freyther454140e2014-12-28 12:08:28 +0100222 const char *broken_reason;
Harald Welte6be350c2011-05-25 13:10:08 +0200223 /* Power levels for MS and BTS */
224 uint8_t bs_power;
225 uint8_t ms_power;
226 /* Encryption information */
Neels Hofmeyrac1f1432016-05-10 13:30:17 +0200227 struct gsm_encr encr;
Harald Welte6be350c2011-05-25 13:10:08 +0200228
229 /* AMR bits */
Andreas Eversberg73266522014-01-19 11:47:44 +0100230 uint8_t mr_ms_lv[7];
231 uint8_t mr_bts_lv[7];
Harald Welte6be350c2011-05-25 13:10:08 +0200232
233 /* Established data link layer services */
234 uint8_t sapis[8];
Holger Hans Peter Freytherb9b828b2013-01-01 19:20:28 +0100235 int sacch_deact;
Holger Hans Peter Freytherdfcfe652011-12-27 20:49:53 +0100236
Harald Welte6be350c2011-05-25 13:10:08 +0200237 struct {
238 uint32_t bound_ip;
239 uint32_t connect_ip;
240 uint16_t bound_port;
241 uint16_t connect_port;
242 uint16_t conn_id;
243 uint8_t rtp_payload;
244 uint8_t rtp_payload2;
245 uint8_t speech_mode;
Harald Welte135a6bd2011-09-04 13:53:26 +0200246#ifdef ROLE_BSC
Harald Welte6be350c2011-05-25 13:10:08 +0200247 struct rtp_socket *rtp_socket;
Philipp Maierfbf66102017-04-09 12:32:51 +0200248
249 /* info we need to postpone the AoIP
250 * assignment completed message */
251 struct {
252 uint8_t rr_cause;
253 uint8_t chosen_channel;
254 uint8_t encr_alg_id;
255 uint8_t speech_mode;
256 bool valid;
257 } ass_compl;
Harald Welte135a6bd2011-09-04 13:53:26 +0200258#else
259 struct osmo_rtp_socket *rtp_socket;
260#endif
Harald Welte6be350c2011-05-25 13:10:08 +0200261 } abis_ip;
262
Harald Welte2c1ae472011-06-26 14:13:37 +0200263 uint8_t rqd_ta;
264
Harald Weltec696cc22015-12-05 16:19:21 +0100265 char *name;
266
Harald Welte6be350c2011-05-25 13:10:08 +0200267#ifdef ROLE_BSC
268 struct osmo_timer_list T3101;
Holger Hans Peter Freytherb3489392011-12-28 16:21:05 +0100269 struct osmo_timer_list T3109;
Harald Welte6be350c2011-05-25 13:10:08 +0200270 struct osmo_timer_list T3111;
271 struct osmo_timer_list error_timer;
Harald Weltee8bd9e82011-08-10 23:26:33 +0200272 struct osmo_timer_list act_timer;
Andreas Eversberg7d8fa342013-12-05 13:25:06 +0100273 struct osmo_timer_list rel_work;
Holger Hans Peter Freyther638da512012-12-06 19:25:06 +0100274 uint8_t error_cause;
Harald Welte6be350c2011-05-25 13:10:08 +0200275
276 /* table of neighbor cell measurements */
277 struct neigh_meas_proc neigh_meas[MAX_NEIGH_MEAS];
278
279 /* cache of last measurement reports on this lchan */
280 struct gsm_meas_rep meas_rep[6];
281 int meas_rep_idx;
282
283 /* GSM Random Access data */
284 struct gsm48_req_ref *rqd_ref;
Harald Welte6be350c2011-05-25 13:10:08 +0200285
286 struct gsm_subscriber_connection *conn;
Andreas Eversberg9df268e2013-10-11 13:32:30 +0200287
288 struct {
289 /* channel activation type and handover ref */
290 uint8_t act_type;
291 uint8_t ho_ref;
Neels Hofmeyrb91e6002016-07-23 19:45:15 +0200292 struct gsm48_req_ref *rqd_ref;
293 uint8_t rqd_ta;
Neels Hofmeyr6e999b72016-07-23 21:00:51 +0200294 } dyn;
Harald Weltef6093a42011-06-25 10:02:33 +0200295#else
Daniel Willmann324c8052012-12-29 12:32:30 +0100296 /* Number of different GsmL1_Sapi_t used in osmo_bts_sysmo is 23.
297 * Currently we don't share these headers so this is a magic number. */
Holger Hans Peter Freyther30156e12013-04-05 18:41:45 +0200298 struct llist_head sapi_cmds;
Daniel Willmann324c8052012-12-29 12:32:30 +0100299 uint8_t sapis_dl[23];
300 uint8_t sapis_ul[23];
Harald Weltef6093a42011-06-25 10:02:33 +0200301 struct lapdm_channel lapdm_ch;
Harald Welte135a6bd2011-09-04 13:53:26 +0200302 struct llist_head dl_tch_queue;
Harald Welte2c1ae472011-06-26 14:13:37 +0200303 struct {
304 /* bitmask of all SI that are present/valid in si_buf */
305 uint32_t valid;
306 uint32_t last;
Max70fdd242017-06-15 15:10:53 +0200307 /* buffers where we put the pre-computed SI:
308 SI2Q_MAX_NUM is the max number of SI2quater messages (see 3GPP TS 44.018) */
309 sysinfo_buf_t buf[_MAX_SYSINFO_TYPE][SI2Q_MAX_NUM];
Harald Welte2c1ae472011-06-26 14:13:37 +0200310 } si;
Harald Weltec7921c92011-06-29 10:38:34 +0200311 struct {
312 uint8_t flags;
313 /* RSL measurment result number, 0 at lchan_act */
314 uint8_t res_nr;
315 /* current Tx power level of the BTS */
316 uint8_t bts_tx_pwr;
317 /* number of measurements stored in array below */
318 uint8_t num_ul_meas;
319 struct bts_ul_meas uplink[MAX_NUM_UL_MEAS];
320 /* last L1 header from the MS */
321 uint8_t l1_info[2];
Harald Welte7ff4f0e2013-03-07 18:38:09 +0000322 struct gsm_meas_rep_unidir ul_res;
Harald Weltec7921c92011-06-29 10:38:34 +0200323 } meas;
Harald Weltef3b59322011-09-06 22:14:43 +0200324 struct {
325 struct amr_multirate_conf amr_mr;
Harald Welte43290992011-09-07 12:41:38 +0200326 struct {
Max1e646f02016-10-05 17:29:02 +0200327 struct osmo_fsm_inst *dl_amr_fsm;
Max1b76a032016-10-25 20:22:16 +0200328 /* TCH cache */
Max1e646f02016-10-05 17:29:02 +0200329 uint8_t cache[20];
Max1b76a032016-10-25 20:22:16 +0200330 /* FACCH cache */
331 uint8_t facch[GSM_MACBLOCK_LEN];
Harald Welte43290992011-09-07 12:41:38 +0200332 uint8_t len;
Maxf5fe31d2016-06-10 14:09:07 +0200333 uint32_t fn;
334 bool is_update;
Max1e646f02016-10-05 17:29:02 +0200335 /* set for each SID frame to detect talkspurt for codecs
336 without explicit ONSET event */
337 bool ul_sid;
338 /* indicates if DTXd was active during DL measurement
339 period */
340 bool dl_active;
341 } dtx;
Holger Hans Peter Freyther922ef5d2014-07-24 21:05:32 +0200342 uint8_t last_cmr;
Maxd7df7ae2016-06-03 12:06:26 +0200343 uint32_t last_fn;
Harald Weltef3b59322011-09-06 22:14:43 +0200344 } tch;
Maxabf53d82017-01-25 16:19:20 +0100345
346 /* 3GPP TS 48.058 § 9.3.37: [0; 255] ok, -1 means invalid*/
347 int16_t ms_t_offs;
348 /* 3GPP TS 45.010 § 1.2 round trip propagation delay (in symbols) or -1 */
349 int16_t p_offs;
350
Harald Welte5d52c972012-04-08 20:23:28 +0200351 /* BTS-side ciphering state (rx only, bi-directional, ...) */
352 uint8_t ciph_state;
Holger Hans Peter Freyther2c6b59c2014-08-09 09:43:53 +0200353 uint8_t ciph_ns;
Harald Welte46cb8512012-04-19 23:13:35 +0200354 uint8_t loopback;
Harald Welte704cb862012-06-16 14:57:08 +0800355 struct {
356 uint8_t active;
357 uint8_t ref;
358 /* T3105: PHYS INF retransmission */
359 struct osmo_timer_list t3105;
360 /* counts up to Ny1 */
361 unsigned int phys_info_count;
362 } ho;
Andreas Eversberg1af682a2013-02-20 16:06:20 +0100363 /* S counter for link loss */
364 int s;
Holger Hans Peter Freytherfc7a75f2013-10-25 18:58:30 +0200365 /* Kind of the release/activation. E.g. RSL or PCU */
366 int rel_act_kind;
Maxec744652016-05-18 16:42:16 +0200367 /* RTP header Marker bit to indicate beginning of speech after pause */
368 bool rtp_tx_marker;
Holger Hans Peter Freytherf6f86b02015-02-05 22:25:03 +0100369 /* power handling */
370 struct {
371 uint8_t current;
372 uint8_t fixed;
373 } ms_power_ctrl;
Minh-Quang Nguyenf1886232017-01-18 16:49:00 +0100374
375 struct msgb *pending_rel_ind_msg;
Harald Welte6be350c2011-05-25 13:10:08 +0200376#endif
377};
378
Neels Hofmeyr2ebacce2016-06-14 14:08:35 +0200379enum {
380 TS_F_PDCH_ACTIVE = 0x1000,
381 TS_F_PDCH_ACT_PENDING = 0x2000,
382 TS_F_PDCH_DEACT_PENDING = 0x4000,
383 TS_F_PDCH_PENDING_MASK = 0x6000 /*<
384 TS_F_PDCH_ACT_PENDING | TS_F_PDCH_DEACT_PENDING */
385} gsm_bts_trx_ts_flags;
386
Harald Welte6be350c2011-05-25 13:10:08 +0200387/* One Timeslot in a TRX */
388struct gsm_bts_trx_ts {
389 struct gsm_bts_trx *trx;
390 /* number of this timeslot at the TRX */
391 uint8_t nr;
392
393 enum gsm_phys_chan_config pchan;
394
Neels Hofmeyrc1658762016-07-23 16:14:06 +0200395 struct {
396 enum gsm_phys_chan_config pchan_is;
397 enum gsm_phys_chan_config pchan_want;
398 struct msgb *pending_chan_activ;
399 } dyn;
400
Harald Welte6be350c2011-05-25 13:10:08 +0200401 unsigned int flags;
Harald Welted64c0bc2011-05-30 12:07:53 +0200402 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200403 struct tlv_parsed nm_attr;
404 uint8_t nm_chan_comb;
Harald Welte135a6482011-05-30 12:09:13 +0200405 int tsc; /* -1 == use BTS TSC */
Harald Welte6be350c2011-05-25 13:10:08 +0200406
407 struct {
408 /* Parameters below are configured by VTY */
409 int enabled;
410 uint8_t maio;
411 uint8_t hsn;
412 struct bitvec arfcns;
413 uint8_t arfcns_data[1024/8];
414 /* This is the pre-computed MA for channel assignments */
415 struct bitvec ma;
416 uint8_t ma_len; /* part of ma_data that is used */
417 uint8_t ma_data[8]; /* 10.5.2.21: max 8 bytes value part */
418 } hopping;
419
420 /* To which E1 subslot are we connected */
421 struct gsm_e1_subslot e1_link;
422
Harald Welte591e1d72016-07-09 22:20:57 +0200423 union {
424 struct {
425 struct om2k_mo om2k_mo;
426 } rbs2000;
427 };
428
Harald Welte6be350c2011-05-25 13:10:08 +0200429 struct gsm_lchan lchan[TS_MAX_LCHAN];
430};
431
432/* One TRX in a BTS */
433struct gsm_bts_trx {
434 /* list header in bts->trx_list */
435 struct llist_head list;
436
437 struct gsm_bts *bts;
438 /* number of this TRX in the BTS */
439 uint8_t nr;
440 /* human readable name / description */
441 char *description;
442 /* how do we talk RSL with this TRX? */
443 struct gsm_e1_subslot rsl_e1_link;
444 uint8_t rsl_tei;
445 struct e1inp_sign_link *rsl_link;
Holger Hans Peter Freythercaa98d52013-10-06 15:52:14 +0200446
Harald Welte6be350c2011-05-25 13:10:08 +0200447 /* Some BTS (specifically Ericsson RBS) have a per-TRX OML Link */
448 struct e1inp_sign_link *oml_link;
449
Harald Welted64c0bc2011-05-30 12:07:53 +0200450 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200451 struct tlv_parsed nm_attr;
452 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200453 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200454 } bb_transc;
455
456 uint16_t arfcn;
457 int nominal_power; /* in dBm */
458 unsigned int max_power_red; /* in actual dB */
Holger Hans Peter Freyther9b625802014-07-30 18:20:51 +0200459
460#ifndef ROLE_BSC
Harald Welte101c5c22014-08-22 16:12:03 +0200461 struct trx_power_params power_params;
Holger Hans Peter Freytherf6f86b02015-02-05 22:25:03 +0100462 int ms_power_control;
Harald Welte6be350c2011-05-25 13:10:08 +0200463
Harald Welted134cc72011-06-07 00:12:53 +0200464 struct {
465 void *l1h;
466 } role_bts;
Holger Hans Peter Freyther9b625802014-07-30 18:20:51 +0200467#endif
Harald Welted134cc72011-06-07 00:12:53 +0200468
Harald Welte6be350c2011-05-25 13:10:08 +0200469 union {
470 struct {
471 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200472 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200473 } bbsig;
474 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200475 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200476 } pa;
477 } bs11;
478 struct {
479 unsigned int test_state;
480 uint8_t test_nr;
481 struct rxlev_stats rxlev_stat;
482 } ipaccess;
Harald Welte591e1d72016-07-09 22:20:57 +0200483 struct {
484 struct {
485 struct om2k_mo om2k_mo;
486 } trxc;
487 struct {
488 struct om2k_mo om2k_mo;
489 } rx;
490 struct {
491 struct om2k_mo om2k_mo;
492 } tx;
493 } rbs2000;
Harald Welte6be350c2011-05-25 13:10:08 +0200494 };
495 struct gsm_bts_trx_ts ts[TRX_NR_TS];
496};
497
Harald Welte6be350c2011-05-25 13:10:08 +0200498enum gsm_bts_type {
499 GSM_BTS_TYPE_UNKNOWN,
500 GSM_BTS_TYPE_BS11,
501 GSM_BTS_TYPE_NANOBTS,
502 GSM_BTS_TYPE_RBS2000,
Dieter Spaar16646022011-07-28 00:01:50 +0200503 GSM_BTS_TYPE_NOKIA_SITE,
Maxf9685c12017-03-23 12:01:07 +0100504 GSM_BTS_TYPE_OSMOBTS,
Harald Weltee555c2b2012-08-17 13:02:12 +0200505 _NUM_GSM_BTS_TYPE
Harald Welte6be350c2011-05-25 13:10:08 +0200506};
507
Maxf9685c12017-03-23 12:01:07 +0100508enum gsm_bts_type_variant {
509 BTS_UNKNOWN,
510 BTS_OSMO_LITECELL15,
511 BTS_OSMO_OCTPHY,
512 BTS_OSMO_SYSMO,
513 BTS_OSMO_TRX,
514 _NUM_BTS_VARIANT
515};
516
Max7507aef2017-04-10 13:59:14 +0200517/* Used by OML layer for BTS Attribute reporting */
518enum bts_attribute {
519 BTS_TYPE_VARIANT,
520 BTS_SUB_MODEL,
Max33e13572017-05-29 11:48:29 +0200521 TRX_PHY_VERSION,
Max7507aef2017-04-10 13:59:14 +0200522};
523
Harald Welte6be350c2011-05-25 13:10:08 +0200524struct vty;
525
Maxaef68382017-05-31 12:15:54 +0200526/* N. B: always add new features to the end of the list (right before _NUM_BTS_FEAT) to avoid breaking compatibility
527 with BTS compiled against earlier version of this header */
Harald Welte6be350c2011-05-25 13:10:08 +0200528enum gsm_bts_features {
529 BTS_FEAT_HSCSD,
530 BTS_FEAT_GPRS,
531 BTS_FEAT_EGPRS,
532 BTS_FEAT_ECSD,
533 BTS_FEAT_HOPPING,
Harald Welte903aaea2014-01-19 17:10:50 +0100534 BTS_FEAT_MULTI_TSC,
Max1ebf23b2017-05-10 12:21:17 +0200535 BTS_FEAT_OML_ALERTS,
536 BTS_FEAT_AGCH_PCH_PROP,
537 BTS_FEAT_CBCH,
Maxaef68382017-05-31 12:15:54 +0200538 _NUM_BTS_FEAT
Harald Welte6be350c2011-05-25 13:10:08 +0200539};
540
Maxaef68382017-05-31 12:15:54 +0200541extern const struct value_string gsm_bts_features_descs[];
542
Harald Welte6be350c2011-05-25 13:10:08 +0200543/*
544 * This keeps track of the paging status of one BTS. It
545 * includes a number of pending requests, a back pointer
546 * to the gsm_bts, a timer and some more state.
547 */
548struct gsm_bts_paging_state {
549 /* pending requests */
550 struct llist_head pending_requests;
551 struct gsm_bts *bts;
552
553 struct osmo_timer_list work_timer;
554 struct osmo_timer_list credit_timer;
555
556 /* free chans needed */
557 int free_chans_need;
558
559 /* load */
560 uint16_t available_slots;
561};
562
563struct gsm_envabtse {
Harald Welted64c0bc2011-05-30 12:07:53 +0200564 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200565};
566
567struct gsm_bts_gprs_nsvc {
568 struct gsm_bts *bts;
569 /* data read via VTY config file, to configure the BTS
570 * via OML from BSC */
571 int id;
572 uint16_t nsvci;
573 uint16_t local_port; /* on the BTS */
574 uint16_t remote_port; /* on the SGSN */
575 uint32_t remote_ip; /* on the SGSN */
576
Harald Welted64c0bc2011-05-30 12:07:53 +0200577 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200578};
579
Harald Welte019f9132012-06-28 08:43:14 +0200580enum gprs_rlc_par {
581 RLC_T3142,
582 RLC_T3169,
583 RLC_T3191,
584 RLC_T3193,
585 RLC_T3195,
586 RLC_N3101,
587 RLC_N3103,
588 RLC_N3105,
589 CV_COUNTDOWN,
590 T_DL_TBF_EXT, /* ms */
591 T_UL_TBF_EXT, /* ms */
592 _NUM_RLC_PAR
593};
594
595enum gprs_cs {
596 GPRS_CS1,
597 GPRS_CS2,
598 GPRS_CS3,
599 GPRS_CS4,
600 GPRS_MCS1,
601 GPRS_MCS2,
602 GPRS_MCS3,
603 GPRS_MCS4,
604 GPRS_MCS5,
605 GPRS_MCS6,
606 GPRS_MCS7,
607 GPRS_MCS8,
608 GPRS_MCS9,
609 _NUM_GRPS_CS
610};
611
612struct gprs_rlc_cfg {
613 uint16_t parameter[_NUM_RLC_PAR];
614 struct {
615 uint16_t repeat_time; /* ms */
616 uint8_t repeat_count;
617 } paging;
618 uint32_t cs_mask; /* bitmask of gprs_cs */
619 uint8_t initial_cs;
620 uint8_t initial_mcs;
621};
622
623
Harald Welte6be350c2011-05-25 13:10:08 +0200624enum neigh_list_manual_mode {
625 NL_MODE_AUTOMATIC = 0,
626 NL_MODE_MANUAL = 1,
627 NL_MODE_MANUAL_SI5SEP = 2, /* SI2 and SI5 have separate neighbor lists */
628};
629
Daniel Willmann47b5b3e2011-08-05 13:51:27 +0200630enum bts_loc_fix {
631 BTS_LOC_FIX_INVALID = 0,
632 BTS_LOC_FIX_2D = 1,
633 BTS_LOC_FIX_3D = 2,
634};
635
Daniel Willmann7d109832012-05-14 18:43:23 +0200636extern const struct value_string bts_loc_fix_names[];
637
Daniel Willmann47b5b3e2011-08-05 13:51:27 +0200638struct bts_location {
639 struct llist_head list;
640 time_t tstamp;
641 enum bts_loc_fix valid;
642 double lat;
643 double lon;
644 double height;
645};
646
Harald Welte6be350c2011-05-25 13:10:08 +0200647/* One BTS */
648struct gsm_bts {
649 /* list header in net->bts_list */
650 struct llist_head list;
651
Daniel Willmann47b5b3e2011-08-05 13:51:27 +0200652 /* Geographical location of the BTS */
653 struct llist_head loc_list;
654
Harald Welte6be350c2011-05-25 13:10:08 +0200655 /* number of ths BTS in network */
656 uint8_t nr;
657 /* human readable name / description */
658 char *description;
659 /* Cell Identity */
660 uint16_t cell_identity;
661 /* location area code of this BTS */
662 uint16_t location_area_code;
Harald Weltea2bbc5e2015-11-20 10:43:31 +0100663 /* Base Station Identification Code (BSIC), lower 3 bits is BCC,
664 * which is used as TSC for the CCCH */
Harald Welte6be350c2011-05-25 13:10:08 +0200665 uint8_t bsic;
666 /* type of BTS */
667 enum gsm_bts_type type;
Max6d8e5192017-04-11 18:23:47 +0200668 enum gsm_bts_type_variant variant;
Maxe591d472017-09-15 13:51:39 +0200669
Harald Welte6be350c2011-05-25 13:10:08 +0200670 enum gsm_band band;
Maxf9685c12017-03-23 12:01:07 +0100671 char version[MAX_VERSION_LENGTH];
Max1ebf23b2017-05-10 12:21:17 +0200672 char sub_model[MAX_VERSION_LENGTH];
Maxf9685c12017-03-23 12:01:07 +0100673
Maxaef68382017-05-31 12:15:54 +0200674 /* features of a given BTS set/reported via OML */
675 struct bitvec features;
676 uint8_t _features_data[MAX_BTS_FEATURES/8];
677
Maxf9685c12017-03-23 12:01:07 +0100678 /* Connected PCU version (if any) */
679 char pcu_version[MAX_VERSION_LENGTH];
680
Harald Welte6be350c2011-05-25 13:10:08 +0200681 /* maximum Tx power that the MS is permitted to use in this cell */
682 int ms_max_power;
683
684 /* how do we talk OML with this TRX? */
685 struct gsm_e1_subslot oml_e1_link;
686 uint8_t oml_tei;
687 struct e1inp_sign_link *oml_link;
688
689 /* Abis network management O&M handle */
690 struct abis_nm_h *nmh;
Harald Welted64c0bc2011-05-30 12:07:53 +0200691
692 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200693
694 /* number of this BTS on given E1 link */
695 uint8_t bts_nr;
696
Maxc08ee712016-05-11 12:45:13 +0200697 /* DTX features of this BTS */
698 enum gsm48_dtx_mode dtxu;
699 bool dtxd;
700
Harald Welte6be350c2011-05-25 13:10:08 +0200701 /* paging state and control */
702 struct gsm_bts_paging_state paging;
703
704 /* CCCH is on C0 */
705 struct gsm_bts_trx *c0;
706
707 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200708 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200709 } site_mgr;
710
Harald Welte6be350c2011-05-25 13:10:08 +0200711 /* ip.accesss Unit ID's have Site/BTS/TRX layout */
712 union {
713 struct {
714 uint16_t site_id;
715 uint16_t bts_id;
716 uint32_t flags;
Harald Welte8b291802013-03-12 13:57:05 +0100717 uint32_t rsl_ip;
Harald Welte6be350c2011-05-25 13:10:08 +0200718 } ip_access;
719 struct {
720 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200721 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200722 } cclk;
723 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200724 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200725 } rack;
726 struct gsm_envabtse envabtse[4];
727 } bs11;
728 struct {
729 struct {
Harald Welte591e1d72016-07-09 22:20:57 +0200730 struct om2k_mo om2k_mo;
731 struct gsm_abis_mo mo;
732 struct llist_head conn_groups;
733 } cf;
734 struct {
735 struct om2k_mo om2k_mo;
Harald Welted64c0bc2011-05-30 12:07:53 +0200736 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200737 struct llist_head conn_groups;
738 } is;
739 struct {
Harald Welte591e1d72016-07-09 22:20:57 +0200740 struct om2k_mo om2k_mo;
Harald Welted64c0bc2011-05-30 12:07:53 +0200741 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200742 struct llist_head conn_groups;
743 } con;
744 struct {
Harald Welte591e1d72016-07-09 22:20:57 +0200745 struct om2k_mo om2k_mo;
Harald Welted64c0bc2011-05-30 12:07:53 +0200746 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200747 } dp;
748 struct {
Harald Welte591e1d72016-07-09 22:20:57 +0200749 struct om2k_mo om2k_mo;
Harald Welted64c0bc2011-05-30 12:07:53 +0200750 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200751 } tf;
Harald Weltece492582016-11-15 22:59:24 +0100752 uint32_t use_superchannel:1;
Harald Welte6be350c2011-05-25 13:10:08 +0200753 } rbs2000;
754 struct {
Harald Weltec8755af2011-07-28 00:22:17 +0200755 uint8_t bts_type;
Holger Hans Peter Freyther3e603482012-03-02 14:14:33 +0100756 unsigned int configured:1,
757 skip_reset:1,
Andreas Eversberg7d8fa342013-12-05 13:25:06 +0100758 no_loc_rel_cnf:1,
Sipos Csaba56e17662015-02-07 13:27:36 +0100759 bts_reset_timer_cnf,
Holger Hans Peter Freyther3e603482012-03-02 14:14:33 +0100760 did_reset:1,
761 wait_reset:1;
Harald Weltec8755af2011-07-28 00:22:17 +0200762 struct osmo_timer_list reset_timer;
763 } nokia;
Harald Welte6be350c2011-05-25 13:10:08 +0200764 };
765
766 /* Not entirely sure how ip.access specific this is */
767 struct {
bhargava350533c2016-07-21 11:14:34 +0530768 uint8_t supports_egprs_11bit_rach;
Harald Welte6be350c2011-05-25 13:10:08 +0200769 enum bts_gprs_mode mode;
770 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200771 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200772 uint16_t nsei;
773 uint8_t timer[7];
774 } nse;
775 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200776 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200777 uint16_t bvci;
778 uint8_t timer[11];
Harald Welte019f9132012-06-28 08:43:14 +0200779 struct gprs_rlc_cfg rlc_cfg;
Harald Welte6be350c2011-05-25 13:10:08 +0200780 } cell;
781 struct gsm_bts_gprs_nsvc nsvc[2];
782 uint8_t rac;
Andreas Eversberg0c8f9ca2013-03-16 16:31:26 +0100783 uint8_t net_ctrl_ord;
Max292ec582016-07-28 11:55:37 +0200784 bool ctrl_ack_type_use_block;
Harald Welte6be350c2011-05-25 13:10:08 +0200785 } gprs;
786
787 /* RACH NM values */
788 int rach_b_thresh;
789 int rach_ldavg_slots;
790
791 /* transceivers */
792 int num_trx;
793 struct llist_head trx_list;
794
Holger Hans Peter Freytherb92a5382014-11-21 10:00:39 +0100795 /* SI related items */
Jacob Erlbeck65d114f2014-01-16 11:02:14 +0100796 int force_combined_si;
Holger Hans Peter Freytherb92a5382014-11-21 10:00:39 +0100797 int bcch_change_mark;
Jacob Erlbeck65d114f2014-01-16 11:02:14 +0100798
Harald Welte6be350c2011-05-25 13:10:08 +0200799#ifdef ROLE_BSC
800 /* Abis NM queue */
801 struct llist_head abis_queue;
802 int abis_nm_pend;
803
804 struct gsm_network *network;
805
806 /* should the channel allocator allocate channels from high TRX to TRX0,
807 * rather than starting from TRX0 and go upwards? */
808 int chan_alloc_reverse;
809
810 enum neigh_list_manual_mode neigh_list_manual_mode;
Maxf953d8b2017-09-15 11:48:18 +0200811
Harald Welte42def722017-01-13 00:10:32 +0100812 bool early_classmark_allowed;
Harald Welte2f8b9d22017-06-18 11:12:13 +0300813 /* for testing only: Have an infinitely long radio link timeout */
814 bool infinite_radio_link_timeout;
Harald Welte6be350c2011-05-25 13:10:08 +0200815
816 /* do we use static (user-defined) system information messages? (bitmask) */
817 uint32_t si_mode_static;
Holger Hans Peter Freythere30d40d2012-07-20 10:27:31 +0200818
819 /* exclude the BTS from the global RF Lock handling */
820 int excl_from_rf_lock;
Andreas Eversberga83d5112013-12-07 18:32:28 +0100821
822 /* supported codecs beside FR */
823 struct bts_codec_conf codec;
Holger Hans Peter Freytherc22930e2014-12-17 14:46:17 +0100824
825 /* BTS dependencies bit field */
826 uint32_t depends_on[256/(8*4)];
Andreas Eversberg73266522014-01-19 11:47:44 +0100827
828 /* full and half rate multirate config */
829 struct amr_multirate_conf mr_full;
830 struct amr_multirate_conf mr_half;
831
Philipp Maierb4999b62016-10-26 15:19:41 +0200832 /* PCU socket state */
Harald Welte8254cf72017-05-29 13:42:19 +0200833 char *pcu_sock_path;
Philipp Maierb4999b62016-10-26 15:19:41 +0200834 struct pcu_sock_state *pcu_state;
835
Harald Welte6be350c2011-05-25 13:10:08 +0200836#endif /* ROLE_BSC */
Harald Welte978714d2011-06-06 18:31:20 +0200837 void *role;
Harald Welte6be350c2011-05-25 13:10:08 +0200838};
839
840
Alexander Chemeris3d18dda2017-07-11 01:42:41 +0630841struct gsm_bts *gsm_bts_alloc(void *talloc_ctx, uint8_t bts_num);
Harald Welte1449c9f2014-08-24 09:50:10 +0200842struct gsm_bts *gsm_bts_num(struct gsm_network *net, int num);
Harald Welte6be350c2011-05-25 13:10:08 +0200843
Harald Welte1449c9f2014-08-24 09:50:10 +0200844struct gsm_bts_trx *gsm_bts_trx_alloc(struct gsm_bts *bts);
Harald Welte4f8ad532011-09-19 14:21:51 +0200845struct gsm_bts_trx *gsm_bts_trx_num(const struct gsm_bts *bts, int num);
Harald Welte6be350c2011-05-25 13:10:08 +0200846
Max7507aef2017-04-10 13:59:14 +0200847enum gsm_bts_type str2btstype(const char *arg);
848const char *btstype2str(enum gsm_bts_type type);
849
850enum bts_attribute str2btsattr(const char *s);
851const char *btsatttr2str(enum bts_attribute v);
852
853enum gsm_bts_type_variant str2btsvariant(const char *arg);
854const char *btsvariant2str(enum gsm_bts_type_variant v);
Harald Welte4ab9d7c2012-08-17 12:42:06 +0200855
Philipp Maier6f483d32017-02-24 15:18:08 +0100856extern const struct value_string gsm_chreq_descs[];
Neels Hofmeyr17a6bab2016-07-23 16:14:06 +0200857const struct value_string gsm_pchant_names[13];
858const struct value_string gsm_pchant_descs[13];
Harald Welte6be350c2011-05-25 13:10:08 +0200859const char *gsm_pchan_name(enum gsm_phys_chan_config c);
860enum gsm_phys_chan_config gsm_pchan_parse(const char *name);
861const char *gsm_lchant_name(enum gsm_chan_t c);
862const char *gsm_chreq_name(enum gsm_chreq_reason_t c);
Harald Welte4f8ad532011-09-19 14:21:51 +0200863char *gsm_trx_name(const struct gsm_bts_trx *trx);
864char *gsm_ts_name(const struct gsm_bts_trx_ts *ts);
Neels Hofmeyr34b8b5b2016-07-16 23:59:32 +0200865char *gsm_ts_and_pchan_name(const struct gsm_bts_trx_ts *ts);
Harald Weltec696cc22015-12-05 16:19:21 +0100866char *gsm_lchan_name_compute(const struct gsm_lchan *lchan);
Harald Welte6be350c2011-05-25 13:10:08 +0200867const char *gsm_lchans_name(enum gsm_lchan_state s);
868
Harald Weltec696cc22015-12-05 16:19:21 +0100869static inline char *gsm_lchan_name(const struct gsm_lchan *lchan)
870{
871 return lchan->name;
872}
Harald Welte6be350c2011-05-25 13:10:08 +0200873
Maxaef68382017-05-31 12:15:54 +0200874static inline int gsm_bts_set_feature(struct gsm_bts *bts, enum gsm_bts_features feat)
875{
876 OSMO_ASSERT(_NUM_BTS_FEAT < MAX_BTS_FEATURES);
877 return bitvec_set_bit_pos(&bts->features, feat, 1);
878}
879
880static inline bool gsm_bts_has_feature(const struct gsm_bts *bts, enum gsm_bts_features feat)
881{
882 OSMO_ASSERT(_NUM_BTS_FEAT < MAX_BTS_FEATURES);
883 return bitvec_get_bit_pos(&bts->features, feat);
884}
885
Harald Welteb7849982011-06-29 16:49:03 +0200886void gsm_abis_mo_reset(struct gsm_abis_mo *mo);
887
Harald Welte978714d2011-06-06 18:31:20 +0200888struct gsm_abis_mo *
889gsm_objclass2mo(struct gsm_bts *bts, uint8_t obj_class,
Harald Welte4f8ad532011-09-19 14:21:51 +0200890 const struct abis_om_obj_inst *obj_inst);
Harald Welte978714d2011-06-06 18:31:20 +0200891
892struct gsm_nm_state *
893gsm_objclass2nmstate(struct gsm_bts *bts, uint8_t obj_class,
Harald Welte4f8ad532011-09-19 14:21:51 +0200894 const struct abis_om_obj_inst *obj_inst);
Harald Welte978714d2011-06-06 18:31:20 +0200895void *
896gsm_objclass2obj(struct gsm_bts *bts, uint8_t obj_class,
Harald Welte4f8ad532011-09-19 14:21:51 +0200897 const struct abis_om_obj_inst *obj_inst);
Harald Welte978714d2011-06-06 18:31:20 +0200898
Harald Welteb7849982011-06-29 16:49:03 +0200899/* reset the state of all MO in the BTS */
900void gsm_bts_mo_reset(struct gsm_bts *bts);
901
Neels Hofmeyrd3841102016-07-18 23:43:44 +0200902uint8_t gsm_pchan2chan_nr(enum gsm_phys_chan_config pchan,
903 uint8_t ts_nr, uint8_t lchan_nr);
Harald Weltef6093a42011-06-25 10:02:33 +0200904uint8_t gsm_lchan2chan_nr(const struct gsm_lchan *lchan);
Neels Hofmeyrd3841102016-07-18 23:43:44 +0200905uint8_t gsm_lchan_as_pchan2chan_nr(const struct gsm_lchan *lchan,
906 enum gsm_phys_chan_config as_pchan);
Harald Weltef6093a42011-06-25 10:02:33 +0200907
Harald Welte142d12d2014-12-29 17:47:08 +0100908/* return the gsm_lchan for the CBCH (if it exists at all) */
909struct gsm_lchan *gsm_bts_get_cbch(struct gsm_bts *bts);
910
Holger Hans Peter Freyther06c9da62011-06-09 21:48:49 +0200911/*
912 * help with parsing regexps
913 */
914int gsm_parse_reg(void *ctx, regex_t *reg, char **str,
915 int argc, const char **argv) __attribute__ ((warn_unused_result));
916
Harald Welte1fe24122014-01-19 17:18:21 +0100917static inline uint8_t gsm_ts_tsc(const struct gsm_bts_trx_ts *ts)
918{
919 if (ts->tsc != -1)
920 return ts->tsc;
921 else
Harald Weltea2bbc5e2015-11-20 10:43:31 +0100922 return ts->trx->bts->bsic & 7;
Harald Welte1fe24122014-01-19 17:18:21 +0100923}
Holger Hans Peter Freyther06c9da62011-06-09 21:48:49 +0200924
Neels Hofmeyr74585722016-07-23 17:38:22 +0200925struct gsm_lchan *rsl_lchan_lookup(struct gsm_bts_trx *trx, uint8_t chan_nr,
926 int *rc);
Holger Hans Peter Freyther06c9da62011-06-09 21:48:49 +0200927
Neels Hofmeyrec16c162016-10-17 01:03:53 +0200928enum gsm_phys_chan_config ts_pchan(struct gsm_bts_trx_ts *ts);
Neels Hofmeyr76a0ad72016-07-29 18:12:06 +0200929uint8_t ts_subslots(struct gsm_bts_trx_ts *ts);
Neels Hofmeyr255dbfe2016-09-25 15:07:01 +0200930bool ts_is_tch(struct gsm_bts_trx_ts *ts);
Neels Hofmeyr76a0ad72016-07-29 18:12:06 +0200931
Harald Welte6be350c2011-05-25 13:10:08 +0200932#endif