blob: a507606e809095ff1b51977a3b141134b1fa7a33 [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
Max9b97b002017-06-02 10:58:26 +020029/* 16 is the max. number of SI2quater messages according to 3GPP TS 44.018: 4-bit index is used (2#1111 = 10#15) */
30#define SI2Q_MAX_NUM 16
31/* length in bits (for single SI2quater message) */
32#define SI2Q_MAX_LEN 160
33#define SI2Q_MIN_LEN 18
34
Holger Hans Peter Freyther8ec49522011-08-15 15:53:00 +020035struct osmo_bsc_data;
36
Harald Welte6be350c2011-05-25 13:10:08 +020037struct osmo_bsc_sccp_con;
38struct gsm_sms_queue;
39
40/* RRLP mode of operation */
41enum rrlp_mode {
42 RRLP_MODE_NONE,
43 RRLP_MODE_MS_BASED,
44 RRLP_MODE_MS_PREF,
45 RRLP_MODE_ASS_PREF,
46};
47
48/* Channel Request reason */
49enum gsm_chreq_reason_t {
50 GSM_CHREQ_REASON_EMERG,
51 GSM_CHREQ_REASON_PAG,
52 GSM_CHREQ_REASON_CALL,
53 GSM_CHREQ_REASON_LOCATION_UPD,
54 GSM_CHREQ_REASON_OTHER,
Alexander Couzens11368112016-11-28 23:26:50 +010055 GSM_CHREQ_REASON_PDCH,
Harald Welte6be350c2011-05-25 13:10:08 +020056};
57
Max582e4f62016-10-18 16:19:33 +020058/* lchans 0..3 are SDCCH in combined channel configuration,
59 use 4 as magic number for BCCH hack - see osmo-bts-../oml.c:opstart_compl() */
60#define CCCH_LCHAN 4
61
Harald Welte6be350c2011-05-25 13:10:08 +020062#define TRX_NR_TS 8
63#define TS_MAX_LCHAN 8
64
65#define HARDCODED_ARFCN 123
Harald Welte6be350c2011-05-25 13:10:08 +020066#define HARDCODED_BSIC 0x3f /* NCC = 7 / BCC = 7 */
67
68/* for multi-drop config */
69#define HARDCODED_BTS0_TS 1
70#define HARDCODED_BTS1_TS 6
71#define HARDCODED_BTS2_TS 11
72
Maxf9685c12017-03-23 12:01:07 +010073#define MAX_VERSION_LENGTH 64
74
Max7b62d542017-05-09 15:19:15 +020075#define MAX_BTS_FEATURES 128
76
Harald Welte6be350c2011-05-25 13:10:08 +020077enum gsm_hooks {
78 GSM_HOOK_NM_SWLOAD,
79 GSM_HOOK_RR_PAGING,
80 GSM_HOOK_RR_SECURITY,
81};
82
83enum gsm_paging_event {
84 GSM_PAGING_SUCCEEDED,
85 GSM_PAGING_EXPIRED,
86 GSM_PAGING_OOM,
87 GSM_PAGING_BUSY,
88};
89
90enum bts_gprs_mode {
91 BTS_GPRS_NONE = 0,
92 BTS_GPRS_GPRS = 1,
93 BTS_GPRS_EGPRS = 2,
94};
95
96struct gsm_lchan;
97struct gsm_subscriber;
98struct gsm_mncc;
Harald Welte135a6bd2011-09-04 13:53:26 +020099struct osmo_rtp_socket;
Harald Welte6be350c2011-05-25 13:10:08 +0200100struct rtp_socket;
101struct bsc_api;
102
103/* Network Management State */
104struct gsm_nm_state {
105 uint8_t operational;
106 uint8_t administrative;
107 uint8_t availability;
108};
109
Harald Welted64c0bc2011-05-30 12:07:53 +0200110struct gsm_abis_mo {
Harald Welte3300c012011-06-05 13:31:33 +0200111 uint8_t obj_class;
Holger Hans Peter Freyther49976f42013-11-05 16:06:17 +0100112 uint8_t procedure_pending;
Harald Welte3300c012011-06-05 13:31:33 +0200113 struct abis_om_obj_inst obj_inst;
Harald Welted64c0bc2011-05-30 12:07:53 +0200114 const char *name;
115 struct gsm_nm_state nm_state;
116 struct tlv_parsed *nm_attr;
Harald Welte32bc1162011-06-06 18:58:48 +0200117 struct gsm_bts *bts;
Harald Welted64c0bc2011-05-30 12:07:53 +0200118};
119
Harald Welte591e1d72016-07-09 22:20:57 +0200120/* Ericsson OM2000 Managed Object */
121struct abis_om2k_mo {
122 uint8_t class;
123 uint8_t bts;
124 uint8_t assoc_so;
125 uint8_t inst;
126} __attribute__ ((packed));
127
128struct om2k_mo {
129 struct abis_om2k_mo addr;
130 struct osmo_fsm_inst *fsm;
131};
132
Harald Welte6be350c2011-05-25 13:10:08 +0200133#define A38_XOR_MIN_KEY_LEN 12
134#define A38_XOR_MAX_KEY_LEN 16
135#define A38_COMP128_KEY_LEN 16
136#define RSL_ENC_ALG_A5(x) (x+1)
Max27c3e762016-04-20 15:57:12 +0200137#define MAX_EARFCN_LIST 32
Harald Welte6be350c2011-05-25 13:10:08 +0200138
139/* is the data link established? who established it? */
140#define LCHAN_SAPI_UNUSED 0
141#define LCHAN_SAPI_MS 1
142#define LCHAN_SAPI_NET 2
Andreas Eversberg7d8fa342013-12-05 13:25:06 +0100143#define LCHAN_SAPI_REL 3
Harald Welte6be350c2011-05-25 13:10:08 +0200144
145/* state of a logical channel */
146enum gsm_lchan_state {
147 LCHAN_S_NONE, /* channel is not active */
Holger Hans Peter Freytherded02682012-01-15 00:02:17 +0100148 LCHAN_S_ACT_REQ, /* channel activation requested */
Harald Welte6be350c2011-05-25 13:10:08 +0200149 LCHAN_S_ACTIVE, /* channel is active and operational */
150 LCHAN_S_REL_REQ, /* channel release has been requested */
151 LCHAN_S_REL_ERR, /* channel is in an error state */
Holger Hans Peter Freyther638da512012-12-06 19:25:06 +0100152 LCHAN_S_BROKEN, /* channel is somehow unusable */
Harald Welte6be350c2011-05-25 13:10:08 +0200153 LCHAN_S_INACTIVE, /* channel is set inactive */
154};
155
Harald Weltec7921c92011-06-29 10:38:34 +0200156/* BTS ONLY */
157#define MAX_NUM_UL_MEAS 104
158#define LC_UL_M_F_L1_VALID (1 << 0)
159#define LC_UL_M_F_RES_VALID (1 << 1)
160
161struct bts_ul_meas {
162 /* BER in units of 0.01%: 10.000 == 100% ber, 0 == 0% ber */
163 uint16_t ber10k;
164 /* timing advance offset (in quarter bits) */
165 int16_t ta_offs_qbits;
166 /* C/I ratio in dB */
167 float c_i;
168 /* flags */
169 uint8_t is_sub:1;
170 /* RSSI in dBm * -1 */
171 uint8_t inv_rssi;
172};
Harald Weltef3b59322011-09-06 22:14:43 +0200173
Andreas Eversberga83d5112013-12-07 18:32:28 +0100174struct bts_codec_conf {
175 uint8_t hr;
176 uint8_t efr;
177 uint8_t amr;
178};
179
Harald Weltef3b59322011-09-06 22:14:43 +0200180struct amr_mode {
181 uint8_t mode;
Holger Hans Peter Freyther615ed462015-09-24 11:30:58 +0200182 uint8_t threshold;
183 uint8_t hysteresis;
Harald Weltef3b59322011-09-06 22:14:43 +0200184};
Holger Hans Peter Freyther615ed462015-09-24 11:30:58 +0200185
Harald Weltef3b59322011-09-06 22:14:43 +0200186struct amr_multirate_conf {
187 uint8_t gsm48_ie[2];
Holger Hans Peter Freyther615ed462015-09-24 11:30:58 +0200188 struct amr_mode ms_mode[4];
189 struct amr_mode bts_mode[4];
Harald Weltef3b59322011-09-06 22:14:43 +0200190 uint8_t num_modes;
191};
Harald Weltec7921c92011-06-29 10:38:34 +0200192/* /BTS ONLY */
193
Harald Weltee4227982012-08-24 15:33:56 +0200194enum lchan_csd_mode {
195 LCHAN_CSD_M_NT,
196 LCHAN_CSD_M_T_1200_75,
197 LCHAN_CSD_M_T_600,
198 LCHAN_CSD_M_T_1200,
199 LCHAN_CSD_M_T_2400,
200 LCHAN_CSD_M_T_9600,
201 LCHAN_CSD_M_T_14400,
202 LCHAN_CSD_M_T_29000,
203 LCHAN_CSD_M_T_32000,
204};
205
Daniel Willmann324c8052012-12-29 12:32:30 +0100206/* State of the SAPIs in the lchan */
207enum lchan_sapi_state {
208 LCHAN_SAPI_S_NONE,
209 LCHAN_SAPI_S_REQ,
210 LCHAN_SAPI_S_ASSIGNED,
211 LCHAN_SAPI_S_REL,
212 LCHAN_SAPI_S_ERROR,
213};
214
Harald Welte6be350c2011-05-25 13:10:08 +0200215struct gsm_lchan {
216 /* The TS that we're part of */
217 struct gsm_bts_trx_ts *ts;
218 /* The logical subslot number in the TS */
219 uint8_t nr;
220 /* The logical channel type */
221 enum gsm_chan_t type;
222 /* RSL channel mode */
223 enum rsl_cmod_spd rsl_cmode;
224 /* If TCH, traffic channel mode */
225 enum gsm48_chan_mode tch_mode;
Harald Weltee4227982012-08-24 15:33:56 +0200226 enum lchan_csd_mode csd_mode;
Harald Welte6be350c2011-05-25 13:10:08 +0200227 /* State */
228 enum gsm_lchan_state state;
Holger Hans Peter Freyther454140e2014-12-28 12:08:28 +0100229 const char *broken_reason;
Harald Welte6be350c2011-05-25 13:10:08 +0200230 /* Power levels for MS and BTS */
231 uint8_t bs_power;
232 uint8_t ms_power;
233 /* Encryption information */
Neels Hofmeyrac1f1432016-05-10 13:30:17 +0200234 struct gsm_encr encr;
Harald Welte6be350c2011-05-25 13:10:08 +0200235
236 /* AMR bits */
Andreas Eversberg73266522014-01-19 11:47:44 +0100237 uint8_t mr_ms_lv[7];
238 uint8_t mr_bts_lv[7];
Harald Welte6be350c2011-05-25 13:10:08 +0200239
240 /* Established data link layer services */
241 uint8_t sapis[8];
Holger Hans Peter Freytherb9b828b2013-01-01 19:20:28 +0100242 int sacch_deact;
Holger Hans Peter Freytherdfcfe652011-12-27 20:49:53 +0100243
Harald Welte6be350c2011-05-25 13:10:08 +0200244 struct {
245 uint32_t bound_ip;
246 uint32_t connect_ip;
247 uint16_t bound_port;
248 uint16_t connect_port;
249 uint16_t conn_id;
250 uint8_t rtp_payload;
251 uint8_t rtp_payload2;
252 uint8_t speech_mode;
Harald Welte135a6bd2011-09-04 13:53:26 +0200253#ifdef ROLE_BSC
Harald Welte6be350c2011-05-25 13:10:08 +0200254 struct rtp_socket *rtp_socket;
Harald Welte135a6bd2011-09-04 13:53:26 +0200255#else
256 struct osmo_rtp_socket *rtp_socket;
257#endif
Harald Welte6be350c2011-05-25 13:10:08 +0200258 } abis_ip;
259
Harald Welte2c1ae472011-06-26 14:13:37 +0200260 uint8_t rqd_ta;
261
Harald Weltec696cc22015-12-05 16:19:21 +0100262 char *name;
263
Harald Welte6be350c2011-05-25 13:10:08 +0200264#ifdef ROLE_BSC
265 struct osmo_timer_list T3101;
Holger Hans Peter Freytherb3489392011-12-28 16:21:05 +0100266 struct osmo_timer_list T3109;
Harald Welte6be350c2011-05-25 13:10:08 +0200267 struct osmo_timer_list T3111;
268 struct osmo_timer_list error_timer;
Harald Weltee8bd9e82011-08-10 23:26:33 +0200269 struct osmo_timer_list act_timer;
Andreas Eversberg7d8fa342013-12-05 13:25:06 +0100270 struct osmo_timer_list rel_work;
Holger Hans Peter Freyther638da512012-12-06 19:25:06 +0100271 uint8_t error_cause;
Harald Welte6be350c2011-05-25 13:10:08 +0200272
273 /* table of neighbor cell measurements */
274 struct neigh_meas_proc neigh_meas[MAX_NEIGH_MEAS];
275
276 /* cache of last measurement reports on this lchan */
277 struct gsm_meas_rep meas_rep[6];
278 int meas_rep_idx;
279
280 /* GSM Random Access data */
281 struct gsm48_req_ref *rqd_ref;
Harald Welte6be350c2011-05-25 13:10:08 +0200282
283 struct gsm_subscriber_connection *conn;
Andreas Eversberg9df268e2013-10-11 13:32:30 +0200284
285 struct {
286 /* channel activation type and handover ref */
287 uint8_t act_type;
288 uint8_t ho_ref;
Neels Hofmeyrb91e6002016-07-23 19:45:15 +0200289 struct gsm48_req_ref *rqd_ref;
290 uint8_t rqd_ta;
Neels Hofmeyr6e999b72016-07-23 21:00:51 +0200291 } dyn;
Harald Weltef6093a42011-06-25 10:02:33 +0200292#else
Daniel Willmann324c8052012-12-29 12:32:30 +0100293 /* Number of different GsmL1_Sapi_t used in osmo_bts_sysmo is 23.
294 * Currently we don't share these headers so this is a magic number. */
Holger Hans Peter Freyther30156e12013-04-05 18:41:45 +0200295 struct llist_head sapi_cmds;
Daniel Willmann324c8052012-12-29 12:32:30 +0100296 uint8_t sapis_dl[23];
297 uint8_t sapis_ul[23];
Harald Weltef6093a42011-06-25 10:02:33 +0200298 struct lapdm_channel lapdm_ch;
Harald Welte135a6bd2011-09-04 13:53:26 +0200299 struct llist_head dl_tch_queue;
Harald Welte2c1ae472011-06-26 14:13:37 +0200300 struct {
301 /* bitmask of all SI that are present/valid in si_buf */
302 uint32_t valid;
303 uint32_t last;
304 /* buffers where we put the pre-computed SI */
305 sysinfo_buf_t buf[_MAX_SYSINFO_TYPE];
306 } si;
Harald Weltec7921c92011-06-29 10:38:34 +0200307 struct {
308 uint8_t flags;
309 /* RSL measurment result number, 0 at lchan_act */
310 uint8_t res_nr;
311 /* current Tx power level of the BTS */
312 uint8_t bts_tx_pwr;
313 /* number of measurements stored in array below */
314 uint8_t num_ul_meas;
315 struct bts_ul_meas uplink[MAX_NUM_UL_MEAS];
316 /* last L1 header from the MS */
317 uint8_t l1_info[2];
Harald Welte7ff4f0e2013-03-07 18:38:09 +0000318 struct gsm_meas_rep_unidir ul_res;
Harald Weltec7921c92011-06-29 10:38:34 +0200319 } meas;
Harald Weltef3b59322011-09-06 22:14:43 +0200320 struct {
321 struct amr_multirate_conf amr_mr;
Harald Welte43290992011-09-07 12:41:38 +0200322 struct {
Max1e646f02016-10-05 17:29:02 +0200323 struct osmo_fsm_inst *dl_amr_fsm;
Max1b76a032016-10-25 20:22:16 +0200324 /* TCH cache */
Max1e646f02016-10-05 17:29:02 +0200325 uint8_t cache[20];
Max1b76a032016-10-25 20:22:16 +0200326 /* FACCH cache */
327 uint8_t facch[GSM_MACBLOCK_LEN];
Harald Welte43290992011-09-07 12:41:38 +0200328 uint8_t len;
Maxf5fe31d2016-06-10 14:09:07 +0200329 uint32_t fn;
330 bool is_update;
Max1e646f02016-10-05 17:29:02 +0200331 /* set for each SID frame to detect talkspurt for codecs
332 without explicit ONSET event */
333 bool ul_sid;
334 /* indicates if DTXd was active during DL measurement
335 period */
336 bool dl_active;
337 } dtx;
Holger Hans Peter Freyther922ef5d2014-07-24 21:05:32 +0200338 uint8_t last_cmr;
Maxd7df7ae2016-06-03 12:06:26 +0200339 uint32_t last_fn;
Harald Weltef3b59322011-09-06 22:14:43 +0200340 } tch;
Maxabf53d82017-01-25 16:19:20 +0100341
342 /* 3GPP TS 48.058 § 9.3.37: [0; 255] ok, -1 means invalid*/
343 int16_t ms_t_offs;
344 /* 3GPP TS 45.010 § 1.2 round trip propagation delay (in symbols) or -1 */
345 int16_t p_offs;
346
Harald Welte5d52c972012-04-08 20:23:28 +0200347 /* BTS-side ciphering state (rx only, bi-directional, ...) */
348 uint8_t ciph_state;
Holger Hans Peter Freyther2c6b59c2014-08-09 09:43:53 +0200349 uint8_t ciph_ns;
Harald Welte46cb8512012-04-19 23:13:35 +0200350 uint8_t loopback;
Harald Welte704cb862012-06-16 14:57:08 +0800351 struct {
352 uint8_t active;
353 uint8_t ref;
354 /* T3105: PHYS INF retransmission */
355 struct osmo_timer_list t3105;
356 /* counts up to Ny1 */
357 unsigned int phys_info_count;
358 } ho;
Andreas Eversberg1af682a2013-02-20 16:06:20 +0100359 /* S counter for link loss */
360 int s;
Holger Hans Peter Freytherfc7a75f2013-10-25 18:58:30 +0200361 /* Kind of the release/activation. E.g. RSL or PCU */
362 int rel_act_kind;
Maxec744652016-05-18 16:42:16 +0200363 /* RTP header Marker bit to indicate beginning of speech after pause */
364 bool rtp_tx_marker;
Holger Hans Peter Freytherf6f86b02015-02-05 22:25:03 +0100365 /* power handling */
366 struct {
367 uint8_t current;
368 uint8_t fixed;
369 } ms_power_ctrl;
Minh-Quang Nguyenf1886232017-01-18 16:49:00 +0100370
371 struct msgb *pending_rel_ind_msg;
Harald Welte6be350c2011-05-25 13:10:08 +0200372#endif
373};
374
Neels Hofmeyr2ebacce2016-06-14 14:08:35 +0200375enum {
376 TS_F_PDCH_ACTIVE = 0x1000,
377 TS_F_PDCH_ACT_PENDING = 0x2000,
378 TS_F_PDCH_DEACT_PENDING = 0x4000,
379 TS_F_PDCH_PENDING_MASK = 0x6000 /*<
380 TS_F_PDCH_ACT_PENDING | TS_F_PDCH_DEACT_PENDING */
381} gsm_bts_trx_ts_flags;
382
Harald Welte6be350c2011-05-25 13:10:08 +0200383/* One Timeslot in a TRX */
384struct gsm_bts_trx_ts {
385 struct gsm_bts_trx *trx;
386 /* number of this timeslot at the TRX */
387 uint8_t nr;
388
389 enum gsm_phys_chan_config pchan;
390
Neels Hofmeyrc1658762016-07-23 16:14:06 +0200391 struct {
392 enum gsm_phys_chan_config pchan_is;
393 enum gsm_phys_chan_config pchan_want;
394 struct msgb *pending_chan_activ;
395 } dyn;
396
Harald Welte6be350c2011-05-25 13:10:08 +0200397 unsigned int flags;
Harald Welted64c0bc2011-05-30 12:07:53 +0200398 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200399 struct tlv_parsed nm_attr;
400 uint8_t nm_chan_comb;
Harald Welte135a6482011-05-30 12:09:13 +0200401 int tsc; /* -1 == use BTS TSC */
Harald Welte6be350c2011-05-25 13:10:08 +0200402
403 struct {
404 /* Parameters below are configured by VTY */
405 int enabled;
406 uint8_t maio;
407 uint8_t hsn;
408 struct bitvec arfcns;
409 uint8_t arfcns_data[1024/8];
410 /* This is the pre-computed MA for channel assignments */
411 struct bitvec ma;
412 uint8_t ma_len; /* part of ma_data that is used */
413 uint8_t ma_data[8]; /* 10.5.2.21: max 8 bytes value part */
414 } hopping;
415
416 /* To which E1 subslot are we connected */
417 struct gsm_e1_subslot e1_link;
418
Harald Welte591e1d72016-07-09 22:20:57 +0200419 union {
420 struct {
421 struct om2k_mo om2k_mo;
422 } rbs2000;
423 };
424
Harald Welte6be350c2011-05-25 13:10:08 +0200425 struct gsm_lchan lchan[TS_MAX_LCHAN];
426};
427
428/* One TRX in a BTS */
429struct gsm_bts_trx {
430 /* list header in bts->trx_list */
431 struct llist_head list;
432
433 struct gsm_bts *bts;
434 /* number of this TRX in the BTS */
435 uint8_t nr;
436 /* human readable name / description */
437 char *description;
438 /* how do we talk RSL with this TRX? */
439 struct gsm_e1_subslot rsl_e1_link;
440 uint8_t rsl_tei;
441 struct e1inp_sign_link *rsl_link;
Holger Hans Peter Freythercaa98d52013-10-06 15:52:14 +0200442
Harald Welte6be350c2011-05-25 13:10:08 +0200443 /* Some BTS (specifically Ericsson RBS) have a per-TRX OML Link */
444 struct e1inp_sign_link *oml_link;
445
Harald Welted64c0bc2011-05-30 12:07:53 +0200446 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200447 struct tlv_parsed nm_attr;
448 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200449 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200450 } bb_transc;
451
452 uint16_t arfcn;
453 int nominal_power; /* in dBm */
454 unsigned int max_power_red; /* in actual dB */
Holger Hans Peter Freyther9b625802014-07-30 18:20:51 +0200455
456#ifndef ROLE_BSC
Harald Welte101c5c22014-08-22 16:12:03 +0200457 struct trx_power_params power_params;
Holger Hans Peter Freytherf6f86b02015-02-05 22:25:03 +0100458 int ms_power_control;
Harald Welte6be350c2011-05-25 13:10:08 +0200459
Harald Welted134cc72011-06-07 00:12:53 +0200460 struct {
461 void *l1h;
462 } role_bts;
Holger Hans Peter Freyther9b625802014-07-30 18:20:51 +0200463#endif
Harald Welted134cc72011-06-07 00:12:53 +0200464
Harald Welte6be350c2011-05-25 13:10:08 +0200465 union {
466 struct {
467 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200468 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200469 } bbsig;
470 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200471 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200472 } pa;
473 } bs11;
474 struct {
475 unsigned int test_state;
476 uint8_t test_nr;
477 struct rxlev_stats rxlev_stat;
478 } ipaccess;
Harald Welte591e1d72016-07-09 22:20:57 +0200479 struct {
480 struct {
481 struct om2k_mo om2k_mo;
482 } trxc;
483 struct {
484 struct om2k_mo om2k_mo;
485 } rx;
486 struct {
487 struct om2k_mo om2k_mo;
488 } tx;
489 } rbs2000;
Harald Welte6be350c2011-05-25 13:10:08 +0200490 };
491 struct gsm_bts_trx_ts ts[TRX_NR_TS];
492};
493
Maxf39d03a2017-05-12 17:00:30 +0200494#define GSM_BTS_SI2Q(bts) (struct gsm48_system_information_type_2quater *)((bts)->si_buf[SYSINFO_TYPE_2quater])
Max9b97b002017-06-02 10:58:26 +0200495#define GSM_BTS_HAS_SI(bts, i) ((bts)->si_valid & (1 << i))
Max6f0e50c2017-04-12 15:30:54 +0200496#define GSM_BTS_SI(bts, i) (void *)((bts)->si_buf[i])
497#define GSM_LCHAN_SI(lchan, i) (void *)((lchan)->si.buf[i])
Harald Welte6be350c2011-05-25 13:10:08 +0200498
499enum gsm_bts_type {
500 GSM_BTS_TYPE_UNKNOWN,
501 GSM_BTS_TYPE_BS11,
502 GSM_BTS_TYPE_NANOBTS,
503 GSM_BTS_TYPE_RBS2000,
Dieter Spaar16646022011-07-28 00:01:50 +0200504 GSM_BTS_TYPE_NOKIA_SITE,
Maxf9685c12017-03-23 12:01:07 +0100505 GSM_BTS_TYPE_OSMOBTS,
Harald Weltee555c2b2012-08-17 13:02:12 +0200506 _NUM_GSM_BTS_TYPE
Harald Welte6be350c2011-05-25 13:10:08 +0200507};
508
Maxf9685c12017-03-23 12:01:07 +0100509enum gsm_bts_type_variant {
510 BTS_UNKNOWN,
511 BTS_OSMO_LITECELL15,
512 BTS_OSMO_OCTPHY,
513 BTS_OSMO_SYSMO,
514 BTS_OSMO_TRX,
515 _NUM_BTS_VARIANT
516};
517
Max7507aef2017-04-10 13:59:14 +0200518/* Used by OML layer for BTS Attribute reporting */
519enum bts_attribute {
520 BTS_TYPE_VARIANT,
521 BTS_SUB_MODEL,
Max33e13572017-05-29 11:48:29 +0200522 TRX_PHY_VERSION,
Max7507aef2017-04-10 13:59:14 +0200523};
524
Harald Welte6be350c2011-05-25 13:10:08 +0200525struct vty;
526
527struct gsm_bts_model {
528 struct llist_head list;
529
530 enum gsm_bts_type type;
Maxf9685c12017-03-23 12:01:07 +0100531 enum gsm_bts_type_variant variant;
Harald Welte6be350c2011-05-25 13:10:08 +0200532 const char *name;
533
534 bool started;
535 int (*start)(struct gsm_network *net);
536 int (*oml_rcvmsg)(struct msgb *msg);
537
Pablo Neira Ayusoed5cacb2011-08-17 22:44:07 +0200538 void (*e1line_bind_ops)(struct e1inp_line *line);
539
Harald Welte6be350c2011-05-25 13:10:08 +0200540 void (*config_write_bts)(struct vty *vty, struct gsm_bts *bts);
541 void (*config_write_trx)(struct vty *vty, struct gsm_bts_trx *trx);
542 void (*config_write_ts)(struct vty *vty, struct gsm_bts_trx_ts *ts);
543
544 struct tlv_definition nm_att_tlvdef;
545
Maxaef68382017-05-31 12:15:54 +0200546 /* features of a given BTS model set via gsm_bts_model_register() locally */
Harald Welte6be350c2011-05-25 13:10:08 +0200547 struct bitvec features;
Max7b62d542017-05-09 15:19:15 +0200548 uint8_t _features_data[MAX_BTS_FEATURES/8];
Harald Welte6be350c2011-05-25 13:10:08 +0200549};
550
Maxaef68382017-05-31 12:15:54 +0200551/* N. B: always add new features to the end of the list (right before _NUM_BTS_FEAT) to avoid breaking compatibility
552 with BTS compiled against earlier version of this header */
Harald Welte6be350c2011-05-25 13:10:08 +0200553enum gsm_bts_features {
554 BTS_FEAT_HSCSD,
555 BTS_FEAT_GPRS,
556 BTS_FEAT_EGPRS,
557 BTS_FEAT_ECSD,
558 BTS_FEAT_HOPPING,
Harald Welte903aaea2014-01-19 17:10:50 +0100559 BTS_FEAT_MULTI_TSC,
Max1ebf23b2017-05-10 12:21:17 +0200560 BTS_FEAT_OML_ALERTS,
561 BTS_FEAT_AGCH_PCH_PROP,
562 BTS_FEAT_CBCH,
Maxaef68382017-05-31 12:15:54 +0200563 _NUM_BTS_FEAT
Harald Welte6be350c2011-05-25 13:10:08 +0200564};
565
Maxaef68382017-05-31 12:15:54 +0200566extern const struct value_string gsm_bts_features_descs[];
567
Harald Welte6be350c2011-05-25 13:10:08 +0200568/*
569 * This keeps track of the paging status of one BTS. It
570 * includes a number of pending requests, a back pointer
571 * to the gsm_bts, a timer and some more state.
572 */
573struct gsm_bts_paging_state {
574 /* pending requests */
575 struct llist_head pending_requests;
576 struct gsm_bts *bts;
577
578 struct osmo_timer_list work_timer;
579 struct osmo_timer_list credit_timer;
580
581 /* free chans needed */
582 int free_chans_need;
583
584 /* load */
585 uint16_t available_slots;
586};
587
588struct gsm_envabtse {
Harald Welted64c0bc2011-05-30 12:07:53 +0200589 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200590};
591
592struct gsm_bts_gprs_nsvc {
593 struct gsm_bts *bts;
594 /* data read via VTY config file, to configure the BTS
595 * via OML from BSC */
596 int id;
597 uint16_t nsvci;
598 uint16_t local_port; /* on the BTS */
599 uint16_t remote_port; /* on the SGSN */
600 uint32_t remote_ip; /* on the SGSN */
601
Harald Welted64c0bc2011-05-30 12:07:53 +0200602 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200603};
604
Harald Welte019f9132012-06-28 08:43:14 +0200605enum gprs_rlc_par {
606 RLC_T3142,
607 RLC_T3169,
608 RLC_T3191,
609 RLC_T3193,
610 RLC_T3195,
611 RLC_N3101,
612 RLC_N3103,
613 RLC_N3105,
614 CV_COUNTDOWN,
615 T_DL_TBF_EXT, /* ms */
616 T_UL_TBF_EXT, /* ms */
617 _NUM_RLC_PAR
618};
619
620enum gprs_cs {
621 GPRS_CS1,
622 GPRS_CS2,
623 GPRS_CS3,
624 GPRS_CS4,
625 GPRS_MCS1,
626 GPRS_MCS2,
627 GPRS_MCS3,
628 GPRS_MCS4,
629 GPRS_MCS5,
630 GPRS_MCS6,
631 GPRS_MCS7,
632 GPRS_MCS8,
633 GPRS_MCS9,
634 _NUM_GRPS_CS
635};
636
637struct gprs_rlc_cfg {
638 uint16_t parameter[_NUM_RLC_PAR];
639 struct {
640 uint16_t repeat_time; /* ms */
641 uint8_t repeat_count;
642 } paging;
643 uint32_t cs_mask; /* bitmask of gprs_cs */
644 uint8_t initial_cs;
645 uint8_t initial_mcs;
646};
647
648
Harald Welte6be350c2011-05-25 13:10:08 +0200649enum neigh_list_manual_mode {
650 NL_MODE_AUTOMATIC = 0,
651 NL_MODE_MANUAL = 1,
652 NL_MODE_MANUAL_SI5SEP = 2, /* SI2 and SI5 have separate neighbor lists */
653};
654
Daniel Willmann47b5b3e2011-08-05 13:51:27 +0200655enum bts_loc_fix {
656 BTS_LOC_FIX_INVALID = 0,
657 BTS_LOC_FIX_2D = 1,
658 BTS_LOC_FIX_3D = 2,
659};
660
Daniel Willmann7d109832012-05-14 18:43:23 +0200661extern const struct value_string bts_loc_fix_names[];
662
Daniel Willmann47b5b3e2011-08-05 13:51:27 +0200663struct bts_location {
664 struct llist_head list;
665 time_t tstamp;
666 enum bts_loc_fix valid;
667 double lat;
668 double lon;
669 double height;
670};
671
Harald Welte6be350c2011-05-25 13:10:08 +0200672/* One BTS */
673struct gsm_bts {
674 /* list header in net->bts_list */
675 struct llist_head list;
676
Daniel Willmann47b5b3e2011-08-05 13:51:27 +0200677 /* Geographical location of the BTS */
678 struct llist_head loc_list;
679
Harald Welte6be350c2011-05-25 13:10:08 +0200680 /* number of ths BTS in network */
681 uint8_t nr;
682 /* human readable name / description */
683 char *description;
684 /* Cell Identity */
685 uint16_t cell_identity;
686 /* location area code of this BTS */
687 uint16_t location_area_code;
Harald Weltea2bbc5e2015-11-20 10:43:31 +0100688 /* Base Station Identification Code (BSIC), lower 3 bits is BCC,
689 * which is used as TSC for the CCCH */
Harald Welte6be350c2011-05-25 13:10:08 +0200690 uint8_t bsic;
691 /* type of BTS */
692 enum gsm_bts_type type;
Max6d8e5192017-04-11 18:23:47 +0200693 enum gsm_bts_type_variant variant;
Harald Welte6be350c2011-05-25 13:10:08 +0200694 struct gsm_bts_model *model;
695 enum gsm_band band;
Maxf9685c12017-03-23 12:01:07 +0100696 char version[MAX_VERSION_LENGTH];
Max1ebf23b2017-05-10 12:21:17 +0200697 char sub_model[MAX_VERSION_LENGTH];
Maxf9685c12017-03-23 12:01:07 +0100698
Maxaef68382017-05-31 12:15:54 +0200699 /* features of a given BTS set/reported via OML */
700 struct bitvec features;
701 uint8_t _features_data[MAX_BTS_FEATURES/8];
702
Maxf9685c12017-03-23 12:01:07 +0100703 /* Connected PCU version (if any) */
704 char pcu_version[MAX_VERSION_LENGTH];
705
Harald Welte6be350c2011-05-25 13:10:08 +0200706 /* maximum Tx power that the MS is permitted to use in this cell */
707 int ms_max_power;
708
709 /* how do we talk OML with this TRX? */
710 struct gsm_e1_subslot oml_e1_link;
711 uint8_t oml_tei;
712 struct e1inp_sign_link *oml_link;
713
714 /* Abis network management O&M handle */
715 struct abis_nm_h *nmh;
Harald Welted64c0bc2011-05-30 12:07:53 +0200716
717 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200718
719 /* number of this BTS on given E1 link */
720 uint8_t bts_nr;
721
Maxc08ee712016-05-11 12:45:13 +0200722 /* DTX features of this BTS */
723 enum gsm48_dtx_mode dtxu;
724 bool dtxd;
725
Harald Welte6be350c2011-05-25 13:10:08 +0200726 /* paging state and control */
727 struct gsm_bts_paging_state paging;
728
729 /* CCCH is on C0 */
730 struct gsm_bts_trx *c0;
731
732 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200733 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200734 } site_mgr;
735
736 /* bitmask of all SI that are present/valid in si_buf */
737 uint32_t si_valid;
Max6f0e50c2017-04-12 15:30:54 +0200738 /* 3GPP TS 44.018 Table 10.5.2.33b.1 INDEX and COUNT for SI2quater */
Maxf39d03a2017-05-12 17:00:30 +0200739 uint8_t si2q_index; /* distinguish individual SI2quater messages */
740 uint8_t si2q_count; /* si2q_index for the last (highest indexed) individual SI2quater message */
Harald Welte6be350c2011-05-25 13:10:08 +0200741 /* buffers where we put the pre-computed SI */
742 sysinfo_buf_t si_buf[_MAX_SYSINFO_TYPE];
Maxf39d03a2017-05-12 17:00:30 +0200743 /* offsets used while generating SI2quater */
744 size_t e_offset;
745 size_t u_offset;
Harald Welte6be350c2011-05-25 13:10:08 +0200746
747 /* ip.accesss Unit ID's have Site/BTS/TRX layout */
748 union {
749 struct {
750 uint16_t site_id;
751 uint16_t bts_id;
752 uint32_t flags;
Harald Welte8b291802013-03-12 13:57:05 +0100753 uint32_t rsl_ip;
Harald Welte6be350c2011-05-25 13:10:08 +0200754 } ip_access;
755 struct {
756 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200757 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200758 } cclk;
759 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200760 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200761 } rack;
762 struct gsm_envabtse envabtse[4];
763 } bs11;
764 struct {
765 struct {
Harald Welte591e1d72016-07-09 22:20:57 +0200766 struct om2k_mo om2k_mo;
767 struct gsm_abis_mo mo;
768 struct llist_head conn_groups;
769 } cf;
770 struct {
771 struct om2k_mo om2k_mo;
Harald Welted64c0bc2011-05-30 12:07:53 +0200772 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200773 struct llist_head conn_groups;
774 } is;
775 struct {
Harald Welte591e1d72016-07-09 22:20:57 +0200776 struct om2k_mo om2k_mo;
Harald Welted64c0bc2011-05-30 12:07:53 +0200777 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200778 struct llist_head conn_groups;
779 } con;
780 struct {
Harald Welte591e1d72016-07-09 22:20:57 +0200781 struct om2k_mo om2k_mo;
Harald Welted64c0bc2011-05-30 12:07:53 +0200782 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200783 } dp;
784 struct {
Harald Welte591e1d72016-07-09 22:20:57 +0200785 struct om2k_mo om2k_mo;
Harald Welted64c0bc2011-05-30 12:07:53 +0200786 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200787 } tf;
Harald Weltece492582016-11-15 22:59:24 +0100788 uint32_t use_superchannel:1;
Harald Welte6be350c2011-05-25 13:10:08 +0200789 } rbs2000;
790 struct {
Harald Weltec8755af2011-07-28 00:22:17 +0200791 uint8_t bts_type;
Holger Hans Peter Freyther3e603482012-03-02 14:14:33 +0100792 unsigned int configured:1,
793 skip_reset:1,
Andreas Eversberg7d8fa342013-12-05 13:25:06 +0100794 no_loc_rel_cnf:1,
Sipos Csaba56e17662015-02-07 13:27:36 +0100795 bts_reset_timer_cnf,
Holger Hans Peter Freyther3e603482012-03-02 14:14:33 +0100796 did_reset:1,
797 wait_reset:1;
Harald Weltec8755af2011-07-28 00:22:17 +0200798 struct osmo_timer_list reset_timer;
799 } nokia;
Harald Welte6be350c2011-05-25 13:10:08 +0200800 };
801
802 /* Not entirely sure how ip.access specific this is */
803 struct {
bhargava350533c2016-07-21 11:14:34 +0530804 uint8_t supports_egprs_11bit_rach;
Harald Welte6be350c2011-05-25 13:10:08 +0200805 enum bts_gprs_mode mode;
806 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200807 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200808 uint16_t nsei;
809 uint8_t timer[7];
810 } nse;
811 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200812 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200813 uint16_t bvci;
814 uint8_t timer[11];
Harald Welte019f9132012-06-28 08:43:14 +0200815 struct gprs_rlc_cfg rlc_cfg;
Harald Welte6be350c2011-05-25 13:10:08 +0200816 } cell;
817 struct gsm_bts_gprs_nsvc nsvc[2];
818 uint8_t rac;
Andreas Eversberg0c8f9ca2013-03-16 16:31:26 +0100819 uint8_t net_ctrl_ord;
Max292ec582016-07-28 11:55:37 +0200820 bool ctrl_ack_type_use_block;
Harald Welte6be350c2011-05-25 13:10:08 +0200821 } gprs;
822
823 /* RACH NM values */
824 int rach_b_thresh;
825 int rach_ldavg_slots;
826
827 /* transceivers */
828 int num_trx;
829 struct llist_head trx_list;
830
Holger Hans Peter Freytherb92a5382014-11-21 10:00:39 +0100831 /* SI related items */
Jacob Erlbeck65d114f2014-01-16 11:02:14 +0100832 int force_combined_si;
Holger Hans Peter Freytherb92a5382014-11-21 10:00:39 +0100833 int bcch_change_mark;
Jacob Erlbeck65d114f2014-01-16 11:02:14 +0100834
Harald Welte6be350c2011-05-25 13:10:08 +0200835#ifdef ROLE_BSC
836 /* Abis NM queue */
837 struct llist_head abis_queue;
838 int abis_nm_pend;
839
840 struct gsm_network *network;
841
842 /* should the channel allocator allocate channels from high TRX to TRX0,
843 * rather than starting from TRX0 and go upwards? */
844 int chan_alloc_reverse;
845
846 enum neigh_list_manual_mode neigh_list_manual_mode;
847 /* parameters from which we build SYSTEM INFORMATION */
848 struct {
849 struct gsm48_rach_control rach_control;
850 uint8_t ncc_permitted;
851 struct gsm48_cell_sel_par cell_sel_par;
852 struct gsm48_si_selection_params cell_ro_sel_par; /* rest octet */
853 struct gsm48_cell_options cell_options;
854 struct gsm48_control_channel_descr chan_desc;
855 struct bitvec neigh_list;
856 struct bitvec cell_alloc;
857 struct bitvec si5_neigh_list;
Max59a1bf32016-04-15 16:04:46 +0200858 struct osmo_earfcn_si2q si2quater_neigh_list;
Max26679e02016-04-20 15:57:13 +0200859 size_t uarfcn_length; /* index for uarfcn and scramble lists */
Harald Welte6be350c2011-05-25 13:10:08 +0200860 struct {
861 /* bitmask large enough for all possible ARFCN's */
862 uint8_t neigh_list[1024/8];
863 uint8_t cell_alloc[1024/8];
864 /* If the user wants a different neighbor list in SI5 than in SI2 */
865 uint8_t si5_neigh_list[1024/8];
Max59a1bf32016-04-15 16:04:46 +0200866 uint8_t meas_bw_list[MAX_EARFCN_LIST];
867 uint16_t earfcn_list[MAX_EARFCN_LIST];
Max26679e02016-04-20 15:57:13 +0200868 uint16_t uarfcn_list[MAX_EARFCN_LIST];
869 uint16_t scramble_list[MAX_EARFCN_LIST];
Harald Welte6be350c2011-05-25 13:10:08 +0200870 } data;
871 } si_common;
Harald Welte42def722017-01-13 00:10:32 +0100872 bool early_classmark_allowed;
Harald Welte6be350c2011-05-25 13:10:08 +0200873
874 /* do we use static (user-defined) system information messages? (bitmask) */
875 uint32_t si_mode_static;
Holger Hans Peter Freythere30d40d2012-07-20 10:27:31 +0200876
877 /* exclude the BTS from the global RF Lock handling */
878 int excl_from_rf_lock;
Andreas Eversberga83d5112013-12-07 18:32:28 +0100879
880 /* supported codecs beside FR */
881 struct bts_codec_conf codec;
Holger Hans Peter Freytherc22930e2014-12-17 14:46:17 +0100882
883 /* BTS dependencies bit field */
884 uint32_t depends_on[256/(8*4)];
Andreas Eversberg73266522014-01-19 11:47:44 +0100885
886 /* full and half rate multirate config */
887 struct amr_multirate_conf mr_full;
888 struct amr_multirate_conf mr_half;
889
Philipp Maierb4999b62016-10-26 15:19:41 +0200890 /* PCU socket state */
Harald Welte8254cf72017-05-29 13:42:19 +0200891 char *pcu_sock_path;
Philipp Maierb4999b62016-10-26 15:19:41 +0200892 struct pcu_sock_state *pcu_state;
893
Harald Welte6be350c2011-05-25 13:10:08 +0200894#endif /* ROLE_BSC */
Harald Welte978714d2011-06-06 18:31:20 +0200895 void *role;
Harald Welte6be350c2011-05-25 13:10:08 +0200896};
897
898
Harald Welte3300c012011-06-05 13:31:33 +0200899struct gsm_bts *gsm_bts_alloc(void *talloc_ctx);
Harald Welte1449c9f2014-08-24 09:50:10 +0200900struct gsm_bts *gsm_bts_num(struct gsm_network *net, int num);
Harald Welte6be350c2011-05-25 13:10:08 +0200901
Harald Welte1449c9f2014-08-24 09:50:10 +0200902struct gsm_bts_trx *gsm_bts_trx_alloc(struct gsm_bts *bts);
Harald Welte4f8ad532011-09-19 14:21:51 +0200903struct gsm_bts_trx *gsm_bts_trx_num(const struct gsm_bts *bts, int num);
Harald Welte6be350c2011-05-25 13:10:08 +0200904
Max7507aef2017-04-10 13:59:14 +0200905enum gsm_bts_type str2btstype(const char *arg);
906const char *btstype2str(enum gsm_bts_type type);
907
908enum bts_attribute str2btsattr(const char *s);
909const char *btsatttr2str(enum bts_attribute v);
910
911enum gsm_bts_type_variant str2btsvariant(const char *arg);
912const char *btsvariant2str(enum gsm_bts_type_variant v);
Harald Welte4ab9d7c2012-08-17 12:42:06 +0200913
Philipp Maier6f483d32017-02-24 15:18:08 +0100914extern const struct value_string gsm_chreq_descs[];
Neels Hofmeyr17a6bab2016-07-23 16:14:06 +0200915const struct value_string gsm_pchant_names[13];
916const struct value_string gsm_pchant_descs[13];
Harald Welte6be350c2011-05-25 13:10:08 +0200917const char *gsm_pchan_name(enum gsm_phys_chan_config c);
918enum gsm_phys_chan_config gsm_pchan_parse(const char *name);
919const char *gsm_lchant_name(enum gsm_chan_t c);
920const char *gsm_chreq_name(enum gsm_chreq_reason_t c);
Harald Welte4f8ad532011-09-19 14:21:51 +0200921char *gsm_trx_name(const struct gsm_bts_trx *trx);
922char *gsm_ts_name(const struct gsm_bts_trx_ts *ts);
Neels Hofmeyr34b8b5b2016-07-16 23:59:32 +0200923char *gsm_ts_and_pchan_name(const struct gsm_bts_trx_ts *ts);
Harald Weltec696cc22015-12-05 16:19:21 +0100924char *gsm_lchan_name_compute(const struct gsm_lchan *lchan);
Harald Welte6be350c2011-05-25 13:10:08 +0200925const char *gsm_lchans_name(enum gsm_lchan_state s);
926
Harald Weltec696cc22015-12-05 16:19:21 +0100927static inline char *gsm_lchan_name(const struct gsm_lchan *lchan)
928{
929 return lchan->name;
930}
Harald Welte6be350c2011-05-25 13:10:08 +0200931
Maxaef68382017-05-31 12:15:54 +0200932static inline int gsm_bts_set_feature(struct gsm_bts *bts, enum gsm_bts_features feat)
933{
934 OSMO_ASSERT(_NUM_BTS_FEAT < MAX_BTS_FEATURES);
935 return bitvec_set_bit_pos(&bts->features, feat, 1);
936}
937
938static inline bool gsm_bts_has_feature(const struct gsm_bts *bts, enum gsm_bts_features feat)
939{
940 OSMO_ASSERT(_NUM_BTS_FEAT < MAX_BTS_FEATURES);
941 return bitvec_get_bit_pos(&bts->features, feat);
942}
943
Harald Welteb7849982011-06-29 16:49:03 +0200944void gsm_abis_mo_reset(struct gsm_abis_mo *mo);
945
Harald Welte978714d2011-06-06 18:31:20 +0200946struct gsm_abis_mo *
947gsm_objclass2mo(struct gsm_bts *bts, uint8_t obj_class,
Harald Welte4f8ad532011-09-19 14:21:51 +0200948 const struct abis_om_obj_inst *obj_inst);
Harald Welte978714d2011-06-06 18:31:20 +0200949
950struct gsm_nm_state *
951gsm_objclass2nmstate(struct gsm_bts *bts, uint8_t obj_class,
Harald Welte4f8ad532011-09-19 14:21:51 +0200952 const struct abis_om_obj_inst *obj_inst);
Harald Welte978714d2011-06-06 18:31:20 +0200953void *
954gsm_objclass2obj(struct gsm_bts *bts, uint8_t obj_class,
Harald Welte4f8ad532011-09-19 14:21:51 +0200955 const struct abis_om_obj_inst *obj_inst);
Harald Welte978714d2011-06-06 18:31:20 +0200956
Harald Welteb7849982011-06-29 16:49:03 +0200957/* reset the state of all MO in the BTS */
958void gsm_bts_mo_reset(struct gsm_bts *bts);
959
Neels Hofmeyrd3841102016-07-18 23:43:44 +0200960uint8_t gsm_pchan2chan_nr(enum gsm_phys_chan_config pchan,
961 uint8_t ts_nr, uint8_t lchan_nr);
Harald Weltef6093a42011-06-25 10:02:33 +0200962uint8_t gsm_lchan2chan_nr(const struct gsm_lchan *lchan);
Neels Hofmeyrd3841102016-07-18 23:43:44 +0200963uint8_t gsm_lchan_as_pchan2chan_nr(const struct gsm_lchan *lchan,
964 enum gsm_phys_chan_config as_pchan);
Harald Weltef6093a42011-06-25 10:02:33 +0200965
Harald Welte142d12d2014-12-29 17:47:08 +0100966/* return the gsm_lchan for the CBCH (if it exists at all) */
967struct gsm_lchan *gsm_bts_get_cbch(struct gsm_bts *bts);
968
Holger Hans Peter Freyther06c9da62011-06-09 21:48:49 +0200969/*
970 * help with parsing regexps
971 */
972int gsm_parse_reg(void *ctx, regex_t *reg, char **str,
973 int argc, const char **argv) __attribute__ ((warn_unused_result));
974
Harald Welte1fe24122014-01-19 17:18:21 +0100975static inline uint8_t gsm_ts_tsc(const struct gsm_bts_trx_ts *ts)
976{
977 if (ts->tsc != -1)
978 return ts->tsc;
979 else
Harald Weltea2bbc5e2015-11-20 10:43:31 +0100980 return ts->trx->bts->bsic & 7;
Harald Welte1fe24122014-01-19 17:18:21 +0100981}
Holger Hans Peter Freyther06c9da62011-06-09 21:48:49 +0200982
Neels Hofmeyr74585722016-07-23 17:38:22 +0200983struct gsm_lchan *rsl_lchan_lookup(struct gsm_bts_trx *trx, uint8_t chan_nr,
984 int *rc);
Holger Hans Peter Freyther06c9da62011-06-09 21:48:49 +0200985
Neels Hofmeyrec16c162016-10-17 01:03:53 +0200986enum gsm_phys_chan_config ts_pchan(struct gsm_bts_trx_ts *ts);
Neels Hofmeyr76a0ad72016-07-29 18:12:06 +0200987uint8_t ts_subslots(struct gsm_bts_trx_ts *ts);
Neels Hofmeyr255dbfe2016-09-25 15:07:01 +0200988bool ts_is_tch(struct gsm_bts_trx_ts *ts);
Neels Hofmeyr76a0ad72016-07-29 18:12:06 +0200989
Harald Welte6be350c2011-05-25 13:10:08 +0200990#endif