blob: 0586d8a3ce6910eb6751ec31ff370c7abd671af5 [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
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
Harald Welte6be350c2011-05-25 13:10:08 +020069enum gsm_hooks {
70 GSM_HOOK_NM_SWLOAD,
71 GSM_HOOK_RR_PAGING,
72 GSM_HOOK_RR_SECURITY,
73};
74
75enum gsm_paging_event {
76 GSM_PAGING_SUCCEEDED,
77 GSM_PAGING_EXPIRED,
78 GSM_PAGING_OOM,
79 GSM_PAGING_BUSY,
80};
81
82enum bts_gprs_mode {
83 BTS_GPRS_NONE = 0,
84 BTS_GPRS_GPRS = 1,
85 BTS_GPRS_EGPRS = 2,
86};
87
88struct gsm_lchan;
89struct gsm_subscriber;
90struct gsm_mncc;
Harald Welte135a6bd2011-09-04 13:53:26 +020091struct osmo_rtp_socket;
Harald Welte6be350c2011-05-25 13:10:08 +020092struct rtp_socket;
93struct bsc_api;
94
95/* Network Management State */
96struct gsm_nm_state {
97 uint8_t operational;
98 uint8_t administrative;
99 uint8_t availability;
100};
101
Harald Welted64c0bc2011-05-30 12:07:53 +0200102struct gsm_abis_mo {
Harald Welte3300c012011-06-05 13:31:33 +0200103 uint8_t obj_class;
Holger Hans Peter Freyther49976f42013-11-05 16:06:17 +0100104 uint8_t procedure_pending;
Harald Welte3300c012011-06-05 13:31:33 +0200105 struct abis_om_obj_inst obj_inst;
Harald Welted64c0bc2011-05-30 12:07:53 +0200106 const char *name;
107 struct gsm_nm_state nm_state;
108 struct tlv_parsed *nm_attr;
Harald Welte32bc1162011-06-06 18:58:48 +0200109 struct gsm_bts *bts;
Harald Welted64c0bc2011-05-30 12:07:53 +0200110};
111
Harald Welte591e1d72016-07-09 22:20:57 +0200112/* Ericsson OM2000 Managed Object */
113struct abis_om2k_mo {
114 uint8_t class;
115 uint8_t bts;
116 uint8_t assoc_so;
117 uint8_t inst;
118} __attribute__ ((packed));
119
120struct om2k_mo {
121 struct abis_om2k_mo addr;
122 struct osmo_fsm_inst *fsm;
123};
124
Harald Welte6be350c2011-05-25 13:10:08 +0200125#define A38_XOR_MIN_KEY_LEN 12
126#define A38_XOR_MAX_KEY_LEN 16
127#define A38_COMP128_KEY_LEN 16
128#define RSL_ENC_ALG_A5(x) (x+1)
Max27c3e762016-04-20 15:57:12 +0200129#define MAX_EARFCN_LIST 32
Harald Welte6be350c2011-05-25 13:10:08 +0200130
131/* is the data link established? who established it? */
132#define LCHAN_SAPI_UNUSED 0
133#define LCHAN_SAPI_MS 1
134#define LCHAN_SAPI_NET 2
Andreas Eversberg7d8fa342013-12-05 13:25:06 +0100135#define LCHAN_SAPI_REL 3
Harald Welte6be350c2011-05-25 13:10:08 +0200136
137/* state of a logical channel */
138enum gsm_lchan_state {
139 LCHAN_S_NONE, /* channel is not active */
Holger Hans Peter Freytherded02682012-01-15 00:02:17 +0100140 LCHAN_S_ACT_REQ, /* channel activation requested */
Harald Welte6be350c2011-05-25 13:10:08 +0200141 LCHAN_S_ACTIVE, /* channel is active and operational */
142 LCHAN_S_REL_REQ, /* channel release has been requested */
143 LCHAN_S_REL_ERR, /* channel is in an error state */
Holger Hans Peter Freyther638da512012-12-06 19:25:06 +0100144 LCHAN_S_BROKEN, /* channel is somehow unusable */
Harald Welte6be350c2011-05-25 13:10:08 +0200145 LCHAN_S_INACTIVE, /* channel is set inactive */
146};
147
Harald Weltec7921c92011-06-29 10:38:34 +0200148/* BTS ONLY */
149#define MAX_NUM_UL_MEAS 104
150#define LC_UL_M_F_L1_VALID (1 << 0)
151#define LC_UL_M_F_RES_VALID (1 << 1)
152
153struct bts_ul_meas {
154 /* BER in units of 0.01%: 10.000 == 100% ber, 0 == 0% ber */
155 uint16_t ber10k;
156 /* timing advance offset (in quarter bits) */
157 int16_t ta_offs_qbits;
158 /* C/I ratio in dB */
159 float c_i;
160 /* flags */
161 uint8_t is_sub:1;
162 /* RSSI in dBm * -1 */
163 uint8_t inv_rssi;
164};
Harald Weltef3b59322011-09-06 22:14:43 +0200165
Andreas Eversberga83d5112013-12-07 18:32:28 +0100166struct bts_codec_conf {
167 uint8_t hr;
168 uint8_t efr;
169 uint8_t amr;
170};
171
Harald Weltef3b59322011-09-06 22:14:43 +0200172struct amr_mode {
173 uint8_t mode;
Holger Hans Peter Freyther615ed462015-09-24 11:30:58 +0200174 uint8_t threshold;
175 uint8_t hysteresis;
Harald Weltef3b59322011-09-06 22:14:43 +0200176};
Holger Hans Peter Freyther615ed462015-09-24 11:30:58 +0200177
Harald Weltef3b59322011-09-06 22:14:43 +0200178struct amr_multirate_conf {
179 uint8_t gsm48_ie[2];
Holger Hans Peter Freyther615ed462015-09-24 11:30:58 +0200180 struct amr_mode ms_mode[4];
181 struct amr_mode bts_mode[4];
Harald Weltef3b59322011-09-06 22:14:43 +0200182 uint8_t num_modes;
183};
Harald Weltec7921c92011-06-29 10:38:34 +0200184/* /BTS ONLY */
185
Harald Weltee4227982012-08-24 15:33:56 +0200186enum lchan_csd_mode {
187 LCHAN_CSD_M_NT,
188 LCHAN_CSD_M_T_1200_75,
189 LCHAN_CSD_M_T_600,
190 LCHAN_CSD_M_T_1200,
191 LCHAN_CSD_M_T_2400,
192 LCHAN_CSD_M_T_9600,
193 LCHAN_CSD_M_T_14400,
194 LCHAN_CSD_M_T_29000,
195 LCHAN_CSD_M_T_32000,
196};
197
Daniel Willmann324c8052012-12-29 12:32:30 +0100198/* State of the SAPIs in the lchan */
199enum lchan_sapi_state {
200 LCHAN_SAPI_S_NONE,
201 LCHAN_SAPI_S_REQ,
202 LCHAN_SAPI_S_ASSIGNED,
203 LCHAN_SAPI_S_REL,
204 LCHAN_SAPI_S_ERROR,
205};
206
Harald Welte6be350c2011-05-25 13:10:08 +0200207struct gsm_lchan {
208 /* The TS that we're part of */
209 struct gsm_bts_trx_ts *ts;
210 /* The logical subslot number in the TS */
211 uint8_t nr;
212 /* The logical channel type */
213 enum gsm_chan_t type;
214 /* RSL channel mode */
215 enum rsl_cmod_spd rsl_cmode;
216 /* If TCH, traffic channel mode */
217 enum gsm48_chan_mode tch_mode;
Harald Weltee4227982012-08-24 15:33:56 +0200218 enum lchan_csd_mode csd_mode;
Harald Welte6be350c2011-05-25 13:10:08 +0200219 /* State */
220 enum gsm_lchan_state state;
Holger Hans Peter Freyther454140e2014-12-28 12:08:28 +0100221 const char *broken_reason;
Harald Welte6be350c2011-05-25 13:10:08 +0200222 /* Power levels for MS and BTS */
223 uint8_t bs_power;
224 uint8_t ms_power;
225 /* Encryption information */
Neels Hofmeyrac1f1432016-05-10 13:30:17 +0200226 struct gsm_encr encr;
Harald Welte6be350c2011-05-25 13:10:08 +0200227
228 /* AMR bits */
Andreas Eversberg73266522014-01-19 11:47:44 +0100229 uint8_t mr_ms_lv[7];
230 uint8_t mr_bts_lv[7];
Harald Welte6be350c2011-05-25 13:10:08 +0200231
232 /* Established data link layer services */
233 uint8_t sapis[8];
Holger Hans Peter Freytherb9b828b2013-01-01 19:20:28 +0100234 int sacch_deact;
Holger Hans Peter Freytherdfcfe652011-12-27 20:49:53 +0100235
Harald Welte6be350c2011-05-25 13:10:08 +0200236 struct {
237 uint32_t bound_ip;
238 uint32_t connect_ip;
239 uint16_t bound_port;
240 uint16_t connect_port;
241 uint16_t conn_id;
242 uint8_t rtp_payload;
243 uint8_t rtp_payload2;
244 uint8_t speech_mode;
Harald Welte135a6bd2011-09-04 13:53:26 +0200245#ifdef ROLE_BSC
Harald Welte6be350c2011-05-25 13:10:08 +0200246 struct rtp_socket *rtp_socket;
Harald Welte135a6bd2011-09-04 13:53:26 +0200247#else
248 struct osmo_rtp_socket *rtp_socket;
249#endif
Harald Welte6be350c2011-05-25 13:10:08 +0200250 } abis_ip;
251
Harald Welte2c1ae472011-06-26 14:13:37 +0200252 uint8_t rqd_ta;
253
Harald Weltec696cc22015-12-05 16:19:21 +0100254 char *name;
255
Harald Welte6be350c2011-05-25 13:10:08 +0200256#ifdef ROLE_BSC
257 struct osmo_timer_list T3101;
Holger Hans Peter Freytherb3489392011-12-28 16:21:05 +0100258 struct osmo_timer_list T3109;
Harald Welte6be350c2011-05-25 13:10:08 +0200259 struct osmo_timer_list T3111;
260 struct osmo_timer_list error_timer;
Harald Weltee8bd9e82011-08-10 23:26:33 +0200261 struct osmo_timer_list act_timer;
Andreas Eversberg7d8fa342013-12-05 13:25:06 +0100262 struct osmo_timer_list rel_work;
Holger Hans Peter Freyther638da512012-12-06 19:25:06 +0100263 uint8_t error_cause;
Harald Welte6be350c2011-05-25 13:10:08 +0200264
265 /* table of neighbor cell measurements */
266 struct neigh_meas_proc neigh_meas[MAX_NEIGH_MEAS];
267
268 /* cache of last measurement reports on this lchan */
269 struct gsm_meas_rep meas_rep[6];
270 int meas_rep_idx;
271
272 /* GSM Random Access data */
273 struct gsm48_req_ref *rqd_ref;
Harald Welte6be350c2011-05-25 13:10:08 +0200274
275 struct gsm_subscriber_connection *conn;
Andreas Eversberg9df268e2013-10-11 13:32:30 +0200276
277 struct {
278 /* channel activation type and handover ref */
279 uint8_t act_type;
280 uint8_t ho_ref;
Neels Hofmeyrb91e6002016-07-23 19:45:15 +0200281 struct gsm48_req_ref *rqd_ref;
282 uint8_t rqd_ta;
Neels Hofmeyr6e999b72016-07-23 21:00:51 +0200283 } dyn;
Harald Weltef6093a42011-06-25 10:02:33 +0200284#else
Daniel Willmann324c8052012-12-29 12:32:30 +0100285 /* Number of different GsmL1_Sapi_t used in osmo_bts_sysmo is 23.
286 * Currently we don't share these headers so this is a magic number. */
Holger Hans Peter Freyther30156e12013-04-05 18:41:45 +0200287 struct llist_head sapi_cmds;
Daniel Willmann324c8052012-12-29 12:32:30 +0100288 uint8_t sapis_dl[23];
289 uint8_t sapis_ul[23];
Harald Weltef6093a42011-06-25 10:02:33 +0200290 struct lapdm_channel lapdm_ch;
Harald Welte135a6bd2011-09-04 13:53:26 +0200291 struct llist_head dl_tch_queue;
Harald Welte2c1ae472011-06-26 14:13:37 +0200292 struct {
293 /* bitmask of all SI that are present/valid in si_buf */
294 uint32_t valid;
295 uint32_t last;
296 /* buffers where we put the pre-computed SI */
297 sysinfo_buf_t buf[_MAX_SYSINFO_TYPE];
298 } si;
Harald Weltec7921c92011-06-29 10:38:34 +0200299 struct {
300 uint8_t flags;
301 /* RSL measurment result number, 0 at lchan_act */
302 uint8_t res_nr;
303 /* current Tx power level of the BTS */
304 uint8_t bts_tx_pwr;
305 /* number of measurements stored in array below */
306 uint8_t num_ul_meas;
307 struct bts_ul_meas uplink[MAX_NUM_UL_MEAS];
308 /* last L1 header from the MS */
309 uint8_t l1_info[2];
Harald Welte7ff4f0e2013-03-07 18:38:09 +0000310 struct gsm_meas_rep_unidir ul_res;
Harald Weltec7921c92011-06-29 10:38:34 +0200311 } meas;
Harald Weltef3b59322011-09-06 22:14:43 +0200312 struct {
313 struct amr_multirate_conf amr_mr;
Harald Welte43290992011-09-07 12:41:38 +0200314 struct {
Max1e646f02016-10-05 17:29:02 +0200315 struct osmo_fsm_inst *dl_amr_fsm;
Max1b76a032016-10-25 20:22:16 +0200316 /* TCH cache */
Max1e646f02016-10-05 17:29:02 +0200317 uint8_t cache[20];
Max1b76a032016-10-25 20:22:16 +0200318 /* FACCH cache */
319 uint8_t facch[GSM_MACBLOCK_LEN];
Harald Welte43290992011-09-07 12:41:38 +0200320 uint8_t len;
Maxf5fe31d2016-06-10 14:09:07 +0200321 uint32_t fn;
322 bool is_update;
Max1e646f02016-10-05 17:29:02 +0200323 /* set for each SID frame to detect talkspurt for codecs
324 without explicit ONSET event */
325 bool ul_sid;
326 /* indicates if DTXd was active during DL measurement
327 period */
328 bool dl_active;
329 } dtx;
Holger Hans Peter Freyther922ef5d2014-07-24 21:05:32 +0200330 uint8_t last_cmr;
Maxd7df7ae2016-06-03 12:06:26 +0200331 uint32_t last_fn;
Harald Weltef3b59322011-09-06 22:14:43 +0200332 } tch;
Maxabf53d82017-01-25 16:19:20 +0100333
334 /* 3GPP TS 48.058 § 9.3.37: [0; 255] ok, -1 means invalid*/
335 int16_t ms_t_offs;
336 /* 3GPP TS 45.010 § 1.2 round trip propagation delay (in symbols) or -1 */
337 int16_t p_offs;
338
Harald Welte5d52c972012-04-08 20:23:28 +0200339 /* BTS-side ciphering state (rx only, bi-directional, ...) */
340 uint8_t ciph_state;
Holger Hans Peter Freyther2c6b59c2014-08-09 09:43:53 +0200341 uint8_t ciph_ns;
Harald Welte46cb8512012-04-19 23:13:35 +0200342 uint8_t loopback;
Harald Welte704cb862012-06-16 14:57:08 +0800343 struct {
344 uint8_t active;
345 uint8_t ref;
346 /* T3105: PHYS INF retransmission */
347 struct osmo_timer_list t3105;
348 /* counts up to Ny1 */
349 unsigned int phys_info_count;
350 } ho;
Andreas Eversberg1af682a2013-02-20 16:06:20 +0100351 /* S counter for link loss */
352 int s;
Holger Hans Peter Freytherfc7a75f2013-10-25 18:58:30 +0200353 /* Kind of the release/activation. E.g. RSL or PCU */
354 int rel_act_kind;
Maxec744652016-05-18 16:42:16 +0200355 /* RTP header Marker bit to indicate beginning of speech after pause */
356 bool rtp_tx_marker;
Holger Hans Peter Freytherf6f86b02015-02-05 22:25:03 +0100357 /* power handling */
358 struct {
359 uint8_t current;
360 uint8_t fixed;
361 } ms_power_ctrl;
Minh-Quang Nguyenf1886232017-01-18 16:49:00 +0100362
363 struct msgb *pending_rel_ind_msg;
Harald Welte6be350c2011-05-25 13:10:08 +0200364#endif
365};
366
Neels Hofmeyr2ebacce2016-06-14 14:08:35 +0200367enum {
368 TS_F_PDCH_ACTIVE = 0x1000,
369 TS_F_PDCH_ACT_PENDING = 0x2000,
370 TS_F_PDCH_DEACT_PENDING = 0x4000,
371 TS_F_PDCH_PENDING_MASK = 0x6000 /*<
372 TS_F_PDCH_ACT_PENDING | TS_F_PDCH_DEACT_PENDING */
373} gsm_bts_trx_ts_flags;
374
Harald Welte6be350c2011-05-25 13:10:08 +0200375/* One Timeslot in a TRX */
376struct gsm_bts_trx_ts {
377 struct gsm_bts_trx *trx;
378 /* number of this timeslot at the TRX */
379 uint8_t nr;
380
381 enum gsm_phys_chan_config pchan;
382
Neels Hofmeyrc1658762016-07-23 16:14:06 +0200383 struct {
384 enum gsm_phys_chan_config pchan_is;
385 enum gsm_phys_chan_config pchan_want;
386 struct msgb *pending_chan_activ;
387 } dyn;
388
Harald Welte6be350c2011-05-25 13:10:08 +0200389 unsigned int flags;
Harald Welted64c0bc2011-05-30 12:07:53 +0200390 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200391 struct tlv_parsed nm_attr;
392 uint8_t nm_chan_comb;
Harald Welte135a6482011-05-30 12:09:13 +0200393 int tsc; /* -1 == use BTS TSC */
Harald Welte6be350c2011-05-25 13:10:08 +0200394
395 struct {
396 /* Parameters below are configured by VTY */
397 int enabled;
398 uint8_t maio;
399 uint8_t hsn;
400 struct bitvec arfcns;
401 uint8_t arfcns_data[1024/8];
402 /* This is the pre-computed MA for channel assignments */
403 struct bitvec ma;
404 uint8_t ma_len; /* part of ma_data that is used */
405 uint8_t ma_data[8]; /* 10.5.2.21: max 8 bytes value part */
406 } hopping;
407
408 /* To which E1 subslot are we connected */
409 struct gsm_e1_subslot e1_link;
410
Harald Welte591e1d72016-07-09 22:20:57 +0200411 union {
412 struct {
413 struct om2k_mo om2k_mo;
414 } rbs2000;
415 };
416
Harald Welte6be350c2011-05-25 13:10:08 +0200417 struct gsm_lchan lchan[TS_MAX_LCHAN];
418};
419
420/* One TRX in a BTS */
421struct gsm_bts_trx {
422 /* list header in bts->trx_list */
423 struct llist_head list;
424
425 struct gsm_bts *bts;
426 /* number of this TRX in the BTS */
427 uint8_t nr;
428 /* human readable name / description */
429 char *description;
430 /* how do we talk RSL with this TRX? */
431 struct gsm_e1_subslot rsl_e1_link;
432 uint8_t rsl_tei;
433 struct e1inp_sign_link *rsl_link;
Holger Hans Peter Freythercaa98d52013-10-06 15:52:14 +0200434
Harald Welte6be350c2011-05-25 13:10:08 +0200435 /* Some BTS (specifically Ericsson RBS) have a per-TRX OML Link */
436 struct e1inp_sign_link *oml_link;
437
Harald Welted64c0bc2011-05-30 12:07:53 +0200438 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200439 struct tlv_parsed nm_attr;
440 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200441 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200442 } bb_transc;
443
444 uint16_t arfcn;
445 int nominal_power; /* in dBm */
446 unsigned int max_power_red; /* in actual dB */
Holger Hans Peter Freyther9b625802014-07-30 18:20:51 +0200447
448#ifndef ROLE_BSC
Harald Welte101c5c22014-08-22 16:12:03 +0200449 struct trx_power_params power_params;
Holger Hans Peter Freytherf6f86b02015-02-05 22:25:03 +0100450 int ms_power_control;
Harald Welte6be350c2011-05-25 13:10:08 +0200451
Harald Welted134cc72011-06-07 00:12:53 +0200452 struct {
453 void *l1h;
454 } role_bts;
Holger Hans Peter Freyther9b625802014-07-30 18:20:51 +0200455#endif
Harald Welted134cc72011-06-07 00:12:53 +0200456
Harald Welte6be350c2011-05-25 13:10:08 +0200457 union {
458 struct {
459 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200460 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200461 } bbsig;
462 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200463 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200464 } pa;
465 } bs11;
466 struct {
467 unsigned int test_state;
468 uint8_t test_nr;
469 struct rxlev_stats rxlev_stat;
470 } ipaccess;
Harald Welte591e1d72016-07-09 22:20:57 +0200471 struct {
472 struct {
473 struct om2k_mo om2k_mo;
474 } trxc;
475 struct {
476 struct om2k_mo om2k_mo;
477 } rx;
478 struct {
479 struct om2k_mo om2k_mo;
480 } tx;
481 } rbs2000;
Harald Welte6be350c2011-05-25 13:10:08 +0200482 };
483 struct gsm_bts_trx_ts ts[TRX_NR_TS];
484};
485
Max6f0e50c2017-04-12 15:30:54 +0200486#define GSM_BTS_SI(bts, i) (void *)((bts)->si_buf[i])
487#define GSM_LCHAN_SI(lchan, i) (void *)((lchan)->si.buf[i])
Harald Welte6be350c2011-05-25 13:10:08 +0200488
489enum gsm_bts_type {
490 GSM_BTS_TYPE_UNKNOWN,
491 GSM_BTS_TYPE_BS11,
492 GSM_BTS_TYPE_NANOBTS,
493 GSM_BTS_TYPE_RBS2000,
Dieter Spaar16646022011-07-28 00:01:50 +0200494 GSM_BTS_TYPE_NOKIA_SITE,
Maxf9685c12017-03-23 12:01:07 +0100495 GSM_BTS_TYPE_OSMOBTS,
Harald Weltee555c2b2012-08-17 13:02:12 +0200496 _NUM_GSM_BTS_TYPE
Harald Welte6be350c2011-05-25 13:10:08 +0200497};
498
Maxf9685c12017-03-23 12:01:07 +0100499enum gsm_bts_type_variant {
500 BTS_UNKNOWN,
501 BTS_OSMO_LITECELL15,
502 BTS_OSMO_OCTPHY,
503 BTS_OSMO_SYSMO,
504 BTS_OSMO_TRX,
505 _NUM_BTS_VARIANT
506};
507
Max7507aef2017-04-10 13:59:14 +0200508/* Used by OML layer for BTS Attribute reporting */
509enum bts_attribute {
510 BTS_TYPE_VARIANT,
511 BTS_SUB_MODEL,
512};
513
Harald Welte6be350c2011-05-25 13:10:08 +0200514struct vty;
515
516struct gsm_bts_model {
517 struct llist_head list;
518
519 enum gsm_bts_type type;
Maxf9685c12017-03-23 12:01:07 +0100520 enum gsm_bts_type_variant variant;
Harald Welte6be350c2011-05-25 13:10:08 +0200521 const char *name;
522
523 bool started;
524 int (*start)(struct gsm_network *net);
525 int (*oml_rcvmsg)(struct msgb *msg);
526
Pablo Neira Ayusoed5cacb2011-08-17 22:44:07 +0200527 void (*e1line_bind_ops)(struct e1inp_line *line);
528
Harald Welte6be350c2011-05-25 13:10:08 +0200529 void (*config_write_bts)(struct vty *vty, struct gsm_bts *bts);
530 void (*config_write_trx)(struct vty *vty, struct gsm_bts_trx *trx);
531 void (*config_write_ts)(struct vty *vty, struct gsm_bts_trx_ts *ts);
532
533 struct tlv_definition nm_att_tlvdef;
534
535 struct bitvec features;
536 uint8_t _features_data[128/8];
537};
538
539enum gsm_bts_features {
540 BTS_FEAT_HSCSD,
541 BTS_FEAT_GPRS,
542 BTS_FEAT_EGPRS,
543 BTS_FEAT_ECSD,
544 BTS_FEAT_HOPPING,
Harald Welte903aaea2014-01-19 17:10:50 +0100545 BTS_FEAT_MULTI_TSC,
Harald Welte6be350c2011-05-25 13:10:08 +0200546};
547
548/*
549 * This keeps track of the paging status of one BTS. It
550 * includes a number of pending requests, a back pointer
551 * to the gsm_bts, a timer and some more state.
552 */
553struct gsm_bts_paging_state {
554 /* pending requests */
555 struct llist_head pending_requests;
556 struct gsm_bts *bts;
557
558 struct osmo_timer_list work_timer;
559 struct osmo_timer_list credit_timer;
560
561 /* free chans needed */
562 int free_chans_need;
563
564 /* load */
565 uint16_t available_slots;
566};
567
568struct gsm_envabtse {
Harald Welted64c0bc2011-05-30 12:07:53 +0200569 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200570};
571
572struct gsm_bts_gprs_nsvc {
573 struct gsm_bts *bts;
574 /* data read via VTY config file, to configure the BTS
575 * via OML from BSC */
576 int id;
577 uint16_t nsvci;
578 uint16_t local_port; /* on the BTS */
579 uint16_t remote_port; /* on the SGSN */
580 uint32_t remote_ip; /* on the SGSN */
581
Harald Welted64c0bc2011-05-30 12:07:53 +0200582 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200583};
584
Harald Welte019f9132012-06-28 08:43:14 +0200585enum gprs_rlc_par {
586 RLC_T3142,
587 RLC_T3169,
588 RLC_T3191,
589 RLC_T3193,
590 RLC_T3195,
591 RLC_N3101,
592 RLC_N3103,
593 RLC_N3105,
594 CV_COUNTDOWN,
595 T_DL_TBF_EXT, /* ms */
596 T_UL_TBF_EXT, /* ms */
597 _NUM_RLC_PAR
598};
599
600enum gprs_cs {
601 GPRS_CS1,
602 GPRS_CS2,
603 GPRS_CS3,
604 GPRS_CS4,
605 GPRS_MCS1,
606 GPRS_MCS2,
607 GPRS_MCS3,
608 GPRS_MCS4,
609 GPRS_MCS5,
610 GPRS_MCS6,
611 GPRS_MCS7,
612 GPRS_MCS8,
613 GPRS_MCS9,
614 _NUM_GRPS_CS
615};
616
617struct gprs_rlc_cfg {
618 uint16_t parameter[_NUM_RLC_PAR];
619 struct {
620 uint16_t repeat_time; /* ms */
621 uint8_t repeat_count;
622 } paging;
623 uint32_t cs_mask; /* bitmask of gprs_cs */
624 uint8_t initial_cs;
625 uint8_t initial_mcs;
626};
627
628
Harald Welte6be350c2011-05-25 13:10:08 +0200629enum neigh_list_manual_mode {
630 NL_MODE_AUTOMATIC = 0,
631 NL_MODE_MANUAL = 1,
632 NL_MODE_MANUAL_SI5SEP = 2, /* SI2 and SI5 have separate neighbor lists */
633};
634
Daniel Willmann47b5b3e2011-08-05 13:51:27 +0200635enum bts_loc_fix {
636 BTS_LOC_FIX_INVALID = 0,
637 BTS_LOC_FIX_2D = 1,
638 BTS_LOC_FIX_3D = 2,
639};
640
Daniel Willmann7d109832012-05-14 18:43:23 +0200641extern const struct value_string bts_loc_fix_names[];
642
Daniel Willmann47b5b3e2011-08-05 13:51:27 +0200643struct bts_location {
644 struct llist_head list;
645 time_t tstamp;
646 enum bts_loc_fix valid;
647 double lat;
648 double lon;
649 double height;
650};
651
Harald Welte6be350c2011-05-25 13:10:08 +0200652/* One BTS */
653struct gsm_bts {
654 /* list header in net->bts_list */
655 struct llist_head list;
656
Daniel Willmann47b5b3e2011-08-05 13:51:27 +0200657 /* Geographical location of the BTS */
658 struct llist_head loc_list;
659
Harald Welte6be350c2011-05-25 13:10:08 +0200660 /* number of ths BTS in network */
661 uint8_t nr;
662 /* human readable name / description */
663 char *description;
664 /* Cell Identity */
665 uint16_t cell_identity;
666 /* location area code of this BTS */
667 uint16_t location_area_code;
Harald Weltea2bbc5e2015-11-20 10:43:31 +0100668 /* Base Station Identification Code (BSIC), lower 3 bits is BCC,
669 * which is used as TSC for the CCCH */
Harald Welte6be350c2011-05-25 13:10:08 +0200670 uint8_t bsic;
671 /* type of BTS */
672 enum gsm_bts_type type;
Max6d8e5192017-04-11 18:23:47 +0200673 enum gsm_bts_type_variant variant;
Harald Welte6be350c2011-05-25 13:10:08 +0200674 struct gsm_bts_model *model;
675 enum gsm_band band;
Maxf9685c12017-03-23 12:01:07 +0100676 char version[MAX_VERSION_LENGTH];
677
678 /* 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
711 /* bitmask of all SI that are present/valid in si_buf */
712 uint32_t si_valid;
Max6f0e50c2017-04-12 15:30:54 +0200713 /* 3GPP TS 44.018 Table 10.5.2.33b.1 INDEX and COUNT for SI2quater */
714 uint8_t si2q_index;
715 uint8_t si2q_count;
Harald Welte6be350c2011-05-25 13:10:08 +0200716 /* buffers where we put the pre-computed SI */
717 sysinfo_buf_t si_buf[_MAX_SYSINFO_TYPE];
718
719 /* ip.accesss Unit ID's have Site/BTS/TRX layout */
720 union {
721 struct {
722 uint16_t site_id;
723 uint16_t bts_id;
724 uint32_t flags;
Harald Welte8b291802013-03-12 13:57:05 +0100725 uint32_t rsl_ip;
Harald Welte6be350c2011-05-25 13:10:08 +0200726 } ip_access;
727 struct {
728 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200729 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200730 } cclk;
731 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200732 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200733 } rack;
734 struct gsm_envabtse envabtse[4];
735 } bs11;
736 struct {
737 struct {
Harald Welte591e1d72016-07-09 22:20:57 +0200738 struct om2k_mo om2k_mo;
739 struct gsm_abis_mo mo;
740 struct llist_head conn_groups;
741 } cf;
742 struct {
743 struct om2k_mo om2k_mo;
Harald Welted64c0bc2011-05-30 12:07:53 +0200744 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200745 struct llist_head conn_groups;
746 } is;
747 struct {
Harald Welte591e1d72016-07-09 22:20:57 +0200748 struct om2k_mo om2k_mo;
Harald Welted64c0bc2011-05-30 12:07:53 +0200749 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200750 struct llist_head conn_groups;
751 } con;
752 struct {
Harald Welte591e1d72016-07-09 22:20:57 +0200753 struct om2k_mo om2k_mo;
Harald Welted64c0bc2011-05-30 12:07:53 +0200754 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200755 } dp;
756 struct {
Harald Welte591e1d72016-07-09 22:20:57 +0200757 struct om2k_mo om2k_mo;
Harald Welted64c0bc2011-05-30 12:07:53 +0200758 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200759 } tf;
Harald Weltece492582016-11-15 22:59:24 +0100760 uint32_t use_superchannel:1;
Harald Welte6be350c2011-05-25 13:10:08 +0200761 } rbs2000;
762 struct {
Harald Weltec8755af2011-07-28 00:22:17 +0200763 uint8_t bts_type;
Holger Hans Peter Freyther3e603482012-03-02 14:14:33 +0100764 unsigned int configured:1,
765 skip_reset:1,
Andreas Eversberg7d8fa342013-12-05 13:25:06 +0100766 no_loc_rel_cnf:1,
Sipos Csaba56e17662015-02-07 13:27:36 +0100767 bts_reset_timer_cnf,
Holger Hans Peter Freyther3e603482012-03-02 14:14:33 +0100768 did_reset:1,
769 wait_reset:1;
Harald Weltec8755af2011-07-28 00:22:17 +0200770 struct osmo_timer_list reset_timer;
771 } nokia;
Harald Welte6be350c2011-05-25 13:10:08 +0200772 };
773
774 /* Not entirely sure how ip.access specific this is */
775 struct {
bhargava350533c2016-07-21 11:14:34 +0530776 uint8_t supports_egprs_11bit_rach;
Harald Welte6be350c2011-05-25 13:10:08 +0200777 enum bts_gprs_mode mode;
778 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200779 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200780 uint16_t nsei;
781 uint8_t timer[7];
782 } nse;
783 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200784 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200785 uint16_t bvci;
786 uint8_t timer[11];
Harald Welte019f9132012-06-28 08:43:14 +0200787 struct gprs_rlc_cfg rlc_cfg;
Harald Welte6be350c2011-05-25 13:10:08 +0200788 } cell;
789 struct gsm_bts_gprs_nsvc nsvc[2];
790 uint8_t rac;
Andreas Eversberg0c8f9ca2013-03-16 16:31:26 +0100791 uint8_t net_ctrl_ord;
Max292ec582016-07-28 11:55:37 +0200792 bool ctrl_ack_type_use_block;
Harald Welte6be350c2011-05-25 13:10:08 +0200793 } gprs;
794
795 /* RACH NM values */
796 int rach_b_thresh;
797 int rach_ldavg_slots;
798
799 /* transceivers */
800 int num_trx;
801 struct llist_head trx_list;
802
Holger Hans Peter Freytherb92a5382014-11-21 10:00:39 +0100803 /* SI related items */
Jacob Erlbeck65d114f2014-01-16 11:02:14 +0100804 int force_combined_si;
Holger Hans Peter Freytherb92a5382014-11-21 10:00:39 +0100805 int bcch_change_mark;
Jacob Erlbeck65d114f2014-01-16 11:02:14 +0100806
Harald Welte6be350c2011-05-25 13:10:08 +0200807#ifdef ROLE_BSC
808 /* Abis NM queue */
809 struct llist_head abis_queue;
810 int abis_nm_pend;
811
812 struct gsm_network *network;
813
814 /* should the channel allocator allocate channels from high TRX to TRX0,
815 * rather than starting from TRX0 and go upwards? */
816 int chan_alloc_reverse;
817
818 enum neigh_list_manual_mode neigh_list_manual_mode;
819 /* parameters from which we build SYSTEM INFORMATION */
820 struct {
821 struct gsm48_rach_control rach_control;
822 uint8_t ncc_permitted;
823 struct gsm48_cell_sel_par cell_sel_par;
824 struct gsm48_si_selection_params cell_ro_sel_par; /* rest octet */
825 struct gsm48_cell_options cell_options;
826 struct gsm48_control_channel_descr chan_desc;
827 struct bitvec neigh_list;
828 struct bitvec cell_alloc;
829 struct bitvec si5_neigh_list;
Max59a1bf32016-04-15 16:04:46 +0200830 struct osmo_earfcn_si2q si2quater_neigh_list;
Max26679e02016-04-20 15:57:13 +0200831 size_t uarfcn_length; /* index for uarfcn and scramble lists */
Harald Welte6be350c2011-05-25 13:10:08 +0200832 struct {
833 /* bitmask large enough for all possible ARFCN's */
834 uint8_t neigh_list[1024/8];
835 uint8_t cell_alloc[1024/8];
836 /* If the user wants a different neighbor list in SI5 than in SI2 */
837 uint8_t si5_neigh_list[1024/8];
Max59a1bf32016-04-15 16:04:46 +0200838 uint8_t meas_bw_list[MAX_EARFCN_LIST];
839 uint16_t earfcn_list[MAX_EARFCN_LIST];
Max26679e02016-04-20 15:57:13 +0200840 uint16_t uarfcn_list[MAX_EARFCN_LIST];
841 uint16_t scramble_list[MAX_EARFCN_LIST];
Harald Welte6be350c2011-05-25 13:10:08 +0200842 } data;
843 } si_common;
Harald Welte42def722017-01-13 00:10:32 +0100844 bool early_classmark_allowed;
Harald Welte6be350c2011-05-25 13:10:08 +0200845
846 /* do we use static (user-defined) system information messages? (bitmask) */
847 uint32_t si_mode_static;
Holger Hans Peter Freythere30d40d2012-07-20 10:27:31 +0200848
849 /* exclude the BTS from the global RF Lock handling */
850 int excl_from_rf_lock;
Andreas Eversberga83d5112013-12-07 18:32:28 +0100851
852 /* supported codecs beside FR */
853 struct bts_codec_conf codec;
Holger Hans Peter Freytherc22930e2014-12-17 14:46:17 +0100854
855 /* BTS dependencies bit field */
856 uint32_t depends_on[256/(8*4)];
Andreas Eversberg73266522014-01-19 11:47:44 +0100857
858 /* full and half rate multirate config */
859 struct amr_multirate_conf mr_full;
860 struct amr_multirate_conf mr_half;
861
Harald Welte6be350c2011-05-25 13:10:08 +0200862#endif /* ROLE_BSC */
Harald Welte978714d2011-06-06 18:31:20 +0200863 void *role;
Harald Welte6be350c2011-05-25 13:10:08 +0200864};
865
866
Harald Welte3300c012011-06-05 13:31:33 +0200867struct gsm_bts *gsm_bts_alloc(void *talloc_ctx);
Harald Welte1449c9f2014-08-24 09:50:10 +0200868struct gsm_bts *gsm_bts_num(struct gsm_network *net, int num);
Harald Welte6be350c2011-05-25 13:10:08 +0200869
Harald Welte1449c9f2014-08-24 09:50:10 +0200870struct gsm_bts_trx *gsm_bts_trx_alloc(struct gsm_bts *bts);
Harald Welte4f8ad532011-09-19 14:21:51 +0200871struct gsm_bts_trx *gsm_bts_trx_num(const struct gsm_bts *bts, int num);
Harald Welte6be350c2011-05-25 13:10:08 +0200872
Max7507aef2017-04-10 13:59:14 +0200873enum gsm_bts_type str2btstype(const char *arg);
874const char *btstype2str(enum gsm_bts_type type);
875
876enum bts_attribute str2btsattr(const char *s);
877const char *btsatttr2str(enum bts_attribute v);
878
879enum gsm_bts_type_variant str2btsvariant(const char *arg);
880const char *btsvariant2str(enum gsm_bts_type_variant v);
Harald Welte4ab9d7c2012-08-17 12:42:06 +0200881
Neels Hofmeyr17a6bab2016-07-23 16:14:06 +0200882const struct value_string gsm_pchant_names[13];
883const struct value_string gsm_pchant_descs[13];
Harald Welte6be350c2011-05-25 13:10:08 +0200884const char *gsm_pchan_name(enum gsm_phys_chan_config c);
885enum gsm_phys_chan_config gsm_pchan_parse(const char *name);
886const char *gsm_lchant_name(enum gsm_chan_t c);
887const char *gsm_chreq_name(enum gsm_chreq_reason_t c);
Harald Welte4f8ad532011-09-19 14:21:51 +0200888char *gsm_trx_name(const struct gsm_bts_trx *trx);
889char *gsm_ts_name(const struct gsm_bts_trx_ts *ts);
Neels Hofmeyr34b8b5b2016-07-16 23:59:32 +0200890char *gsm_ts_and_pchan_name(const struct gsm_bts_trx_ts *ts);
Harald Weltec696cc22015-12-05 16:19:21 +0100891char *gsm_lchan_name_compute(const struct gsm_lchan *lchan);
Harald Welte6be350c2011-05-25 13:10:08 +0200892const char *gsm_lchans_name(enum gsm_lchan_state s);
893
Harald Weltec696cc22015-12-05 16:19:21 +0100894static inline char *gsm_lchan_name(const struct gsm_lchan *lchan)
895{
896 return lchan->name;
897}
Harald Welte6be350c2011-05-25 13:10:08 +0200898
Harald Welteb7849982011-06-29 16:49:03 +0200899void gsm_abis_mo_reset(struct gsm_abis_mo *mo);
900
Harald Welte978714d2011-06-06 18:31:20 +0200901struct gsm_abis_mo *
902gsm_objclass2mo(struct gsm_bts *bts, uint8_t obj_class,
Harald Welte4f8ad532011-09-19 14:21:51 +0200903 const struct abis_om_obj_inst *obj_inst);
Harald Welte978714d2011-06-06 18:31:20 +0200904
905struct gsm_nm_state *
906gsm_objclass2nmstate(struct gsm_bts *bts, uint8_t obj_class,
Harald Welte4f8ad532011-09-19 14:21:51 +0200907 const struct abis_om_obj_inst *obj_inst);
Harald Welte978714d2011-06-06 18:31:20 +0200908void *
909gsm_objclass2obj(struct gsm_bts *bts, uint8_t obj_class,
Harald Welte4f8ad532011-09-19 14:21:51 +0200910 const struct abis_om_obj_inst *obj_inst);
Harald Welte978714d2011-06-06 18:31:20 +0200911
Harald Welteb7849982011-06-29 16:49:03 +0200912/* reset the state of all MO in the BTS */
913void gsm_bts_mo_reset(struct gsm_bts *bts);
914
Neels Hofmeyrd3841102016-07-18 23:43:44 +0200915uint8_t gsm_pchan2chan_nr(enum gsm_phys_chan_config pchan,
916 uint8_t ts_nr, uint8_t lchan_nr);
Harald Weltef6093a42011-06-25 10:02:33 +0200917uint8_t gsm_lchan2chan_nr(const struct gsm_lchan *lchan);
Neels Hofmeyrd3841102016-07-18 23:43:44 +0200918uint8_t gsm_lchan_as_pchan2chan_nr(const struct gsm_lchan *lchan,
919 enum gsm_phys_chan_config as_pchan);
Harald Weltef6093a42011-06-25 10:02:33 +0200920
Harald Welte142d12d2014-12-29 17:47:08 +0100921/* return the gsm_lchan for the CBCH (if it exists at all) */
922struct gsm_lchan *gsm_bts_get_cbch(struct gsm_bts *bts);
923
Holger Hans Peter Freyther06c9da62011-06-09 21:48:49 +0200924/*
925 * help with parsing regexps
926 */
927int gsm_parse_reg(void *ctx, regex_t *reg, char **str,
928 int argc, const char **argv) __attribute__ ((warn_unused_result));
929
Harald Welte1fe24122014-01-19 17:18:21 +0100930static inline uint8_t gsm_ts_tsc(const struct gsm_bts_trx_ts *ts)
931{
932 if (ts->tsc != -1)
933 return ts->tsc;
934 else
Harald Weltea2bbc5e2015-11-20 10:43:31 +0100935 return ts->trx->bts->bsic & 7;
Harald Welte1fe24122014-01-19 17:18:21 +0100936}
Holger Hans Peter Freyther06c9da62011-06-09 21:48:49 +0200937
Neels Hofmeyr74585722016-07-23 17:38:22 +0200938struct gsm_lchan *rsl_lchan_lookup(struct gsm_bts_trx *trx, uint8_t chan_nr,
939 int *rc);
Holger Hans Peter Freyther06c9da62011-06-09 21:48:49 +0200940
Neels Hofmeyrec16c162016-10-17 01:03:53 +0200941enum gsm_phys_chan_config ts_pchan(struct gsm_bts_trx_ts *ts);
Neels Hofmeyr76a0ad72016-07-29 18:12:06 +0200942uint8_t ts_subslots(struct gsm_bts_trx_ts *ts);
Neels Hofmeyr255dbfe2016-09-25 15:07:01 +0200943bool ts_is_tch(struct gsm_bts_trx_ts *ts);
Neels Hofmeyr76a0ad72016-07-29 18:12:06 +0200944
Harald Welte6be350c2011-05-25 13:10:08 +0200945#endif