Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 1 | #ifndef _GSM_DATA_SHAREDH |
| 2 | #define _GSM_DATA_SHAREDH |
| 3 | |
Holger Hans Peter Freyther | 06c9da6 | 2011-06-09 21:48:49 +0200 | [diff] [blame] | 4 | #include <regex.h> |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 5 | #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 Welte | 7ff4f0e | 2013-03-07 18:38:09 +0000 | [diff] [blame] | 16 | #include <osmocom/gsm/meas_rep.h> |
Max | c08ee71 | 2016-05-11 12:45:13 +0200 | [diff] [blame] | 17 | #include <osmocom/gsm/protocol/gsm_04_08.h> |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 18 | #include <osmocom/gsm/protocol/gsm_08_58.h> |
Harald Welte | 3300c01 | 2011-06-05 13:31:33 +0200 | [diff] [blame] | 19 | #include <osmocom/gsm/protocol/gsm_12_21.h> |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 20 | |
Harald Welte | 0eae613 | 2011-08-24 13:52:07 +0200 | [diff] [blame] | 21 | #include <osmocom/abis/e1_input.h> |
Neels Hofmeyr | c016479 | 2017-09-04 15:15:32 +0200 | [diff] [blame] | 22 | #include <osmocom/bsc/common_cs.h> |
| 23 | #include <osmocom/bsc/meas_rep.h> |
Neels Hofmeyr | f0ea05e | 2017-11-27 22:30:47 +0100 | [diff] [blame] | 24 | #include <osmocom/bsc/rest_octets.h> |
Neels Hofmeyr | ac1f143 | 2016-05-10 13:30:17 +0200 | [diff] [blame] | 25 | |
Max | 70fdd24 | 2017-06-15 15:10:53 +0200 | [diff] [blame] | 26 | /* 16 is the max. number of SI2quater messages according to 3GPP TS 44.018 Table 10.5.2.33b.1: |
| 27 | 4-bit index is used (2#1111 = 10#15) */ |
Max | 9b97b00 | 2017-06-02 10:58:26 +0200 | [diff] [blame] | 28 | #define SI2Q_MAX_NUM 16 |
| 29 | /* length in bits (for single SI2quater message) */ |
| 30 | #define SI2Q_MAX_LEN 160 |
| 31 | #define SI2Q_MIN_LEN 18 |
| 32 | |
Holger Hans Peter Freyther | 8ec4952 | 2011-08-15 15:53:00 +0200 | [diff] [blame] | 33 | struct osmo_bsc_data; |
| 34 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 35 | struct osmo_bsc_sccp_con; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 36 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 37 | /* Channel Request reason */ |
| 38 | enum gsm_chreq_reason_t { |
| 39 | GSM_CHREQ_REASON_EMERG, |
| 40 | GSM_CHREQ_REASON_PAG, |
| 41 | GSM_CHREQ_REASON_CALL, |
| 42 | GSM_CHREQ_REASON_LOCATION_UPD, |
| 43 | GSM_CHREQ_REASON_OTHER, |
Alexander Couzens | 1136811 | 2016-11-28 23:26:50 +0100 | [diff] [blame] | 44 | GSM_CHREQ_REASON_PDCH, |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 45 | }; |
| 46 | |
Max | 582e4f6 | 2016-10-18 16:19:33 +0200 | [diff] [blame] | 47 | /* lchans 0..3 are SDCCH in combined channel configuration, |
| 48 | use 4 as magic number for BCCH hack - see osmo-bts-../oml.c:opstart_compl() */ |
| 49 | #define CCCH_LCHAN 4 |
| 50 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 51 | #define TRX_NR_TS 8 |
| 52 | #define TS_MAX_LCHAN 8 |
| 53 | |
| 54 | #define HARDCODED_ARFCN 123 |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 55 | #define HARDCODED_BSIC 0x3f /* NCC = 7 / BCC = 7 */ |
| 56 | |
| 57 | /* for multi-drop config */ |
| 58 | #define HARDCODED_BTS0_TS 1 |
| 59 | #define HARDCODED_BTS1_TS 6 |
| 60 | #define HARDCODED_BTS2_TS 11 |
| 61 | |
Max | f9685c1 | 2017-03-23 12:01:07 +0100 | [diff] [blame] | 62 | #define MAX_VERSION_LENGTH 64 |
| 63 | |
Max | 7b62d54 | 2017-05-09 15:19:15 +0200 | [diff] [blame] | 64 | #define MAX_BTS_FEATURES 128 |
| 65 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 66 | enum gsm_hooks { |
| 67 | GSM_HOOK_NM_SWLOAD, |
| 68 | GSM_HOOK_RR_PAGING, |
| 69 | GSM_HOOK_RR_SECURITY, |
| 70 | }; |
| 71 | |
| 72 | enum gsm_paging_event { |
| 73 | GSM_PAGING_SUCCEEDED, |
| 74 | GSM_PAGING_EXPIRED, |
| 75 | GSM_PAGING_OOM, |
| 76 | GSM_PAGING_BUSY, |
| 77 | }; |
| 78 | |
| 79 | enum bts_gprs_mode { |
| 80 | BTS_GPRS_NONE = 0, |
| 81 | BTS_GPRS_GPRS = 1, |
| 82 | BTS_GPRS_EGPRS = 2, |
| 83 | }; |
| 84 | |
| 85 | struct gsm_lchan; |
Harald Welte | 135a6bd | 2011-09-04 13:53:26 +0200 | [diff] [blame] | 86 | struct osmo_rtp_socket; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 87 | struct rtp_socket; |
| 88 | struct bsc_api; |
| 89 | |
| 90 | /* Network Management State */ |
| 91 | struct gsm_nm_state { |
| 92 | uint8_t operational; |
| 93 | uint8_t administrative; |
| 94 | uint8_t availability; |
| 95 | }; |
| 96 | |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 97 | struct gsm_abis_mo { |
Harald Welte | 3300c01 | 2011-06-05 13:31:33 +0200 | [diff] [blame] | 98 | uint8_t obj_class; |
Holger Hans Peter Freyther | 49976f4 | 2013-11-05 16:06:17 +0100 | [diff] [blame] | 99 | uint8_t procedure_pending; |
Harald Welte | 3300c01 | 2011-06-05 13:31:33 +0200 | [diff] [blame] | 100 | struct abis_om_obj_inst obj_inst; |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 101 | const char *name; |
| 102 | struct gsm_nm_state nm_state; |
| 103 | struct tlv_parsed *nm_attr; |
Harald Welte | 32bc116 | 2011-06-06 18:58:48 +0200 | [diff] [blame] | 104 | struct gsm_bts *bts; |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 105 | }; |
| 106 | |
Harald Welte | 591e1d7 | 2016-07-09 22:20:57 +0200 | [diff] [blame] | 107 | /* Ericsson OM2000 Managed Object */ |
| 108 | struct abis_om2k_mo { |
| 109 | uint8_t class; |
| 110 | uint8_t bts; |
| 111 | uint8_t assoc_so; |
| 112 | uint8_t inst; |
| 113 | } __attribute__ ((packed)); |
| 114 | |
| 115 | struct om2k_mo { |
| 116 | struct abis_om2k_mo addr; |
| 117 | struct osmo_fsm_inst *fsm; |
| 118 | }; |
| 119 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 120 | #define A38_XOR_MIN_KEY_LEN 12 |
| 121 | #define A38_XOR_MAX_KEY_LEN 16 |
| 122 | #define A38_COMP128_KEY_LEN 16 |
| 123 | #define RSL_ENC_ALG_A5(x) (x+1) |
Max | 27c3e76 | 2016-04-20 15:57:12 +0200 | [diff] [blame] | 124 | #define MAX_EARFCN_LIST 32 |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 125 | |
| 126 | /* is the data link established? who established it? */ |
| 127 | #define LCHAN_SAPI_UNUSED 0 |
| 128 | #define LCHAN_SAPI_MS 1 |
| 129 | #define LCHAN_SAPI_NET 2 |
Andreas Eversberg | 7d8fa34 | 2013-12-05 13:25:06 +0100 | [diff] [blame] | 130 | #define LCHAN_SAPI_REL 3 |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 131 | |
| 132 | /* state of a logical channel */ |
| 133 | enum gsm_lchan_state { |
| 134 | LCHAN_S_NONE, /* channel is not active */ |
Holger Hans Peter Freyther | ded0268 | 2012-01-15 00:02:17 +0100 | [diff] [blame] | 135 | LCHAN_S_ACT_REQ, /* channel activation requested */ |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 136 | LCHAN_S_ACTIVE, /* channel is active and operational */ |
| 137 | LCHAN_S_REL_REQ, /* channel release has been requested */ |
| 138 | LCHAN_S_REL_ERR, /* channel is in an error state */ |
Holger Hans Peter Freyther | 638da51 | 2012-12-06 19:25:06 +0100 | [diff] [blame] | 139 | LCHAN_S_BROKEN, /* channel is somehow unusable */ |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 140 | LCHAN_S_INACTIVE, /* channel is set inactive */ |
| 141 | }; |
| 142 | |
Harald Welte | c7921c9 | 2011-06-29 10:38:34 +0200 | [diff] [blame] | 143 | /* BTS ONLY */ |
| 144 | #define MAX_NUM_UL_MEAS 104 |
| 145 | #define LC_UL_M_F_L1_VALID (1 << 0) |
| 146 | #define LC_UL_M_F_RES_VALID (1 << 1) |
| 147 | |
| 148 | struct bts_ul_meas { |
| 149 | /* BER in units of 0.01%: 10.000 == 100% ber, 0 == 0% ber */ |
| 150 | uint16_t ber10k; |
| 151 | /* timing advance offset (in quarter bits) */ |
| 152 | int16_t ta_offs_qbits; |
| 153 | /* C/I ratio in dB */ |
| 154 | float c_i; |
| 155 | /* flags */ |
| 156 | uint8_t is_sub:1; |
| 157 | /* RSSI in dBm * -1 */ |
| 158 | uint8_t inv_rssi; |
| 159 | }; |
Harald Welte | f3b5932 | 2011-09-06 22:14:43 +0200 | [diff] [blame] | 160 | |
Andreas Eversberg | a83d511 | 2013-12-07 18:32:28 +0100 | [diff] [blame] | 161 | struct bts_codec_conf { |
| 162 | uint8_t hr; |
| 163 | uint8_t efr; |
| 164 | uint8_t amr; |
| 165 | }; |
| 166 | |
Harald Welte | f3b5932 | 2011-09-06 22:14:43 +0200 | [diff] [blame] | 167 | struct amr_mode { |
| 168 | uint8_t mode; |
Holger Hans Peter Freyther | 615ed46 | 2015-09-24 11:30:58 +0200 | [diff] [blame] | 169 | uint8_t threshold; |
| 170 | uint8_t hysteresis; |
Harald Welte | f3b5932 | 2011-09-06 22:14:43 +0200 | [diff] [blame] | 171 | }; |
Holger Hans Peter Freyther | 615ed46 | 2015-09-24 11:30:58 +0200 | [diff] [blame] | 172 | |
Harald Welte | f3b5932 | 2011-09-06 22:14:43 +0200 | [diff] [blame] | 173 | struct amr_multirate_conf { |
| 174 | uint8_t gsm48_ie[2]; |
Holger Hans Peter Freyther | 615ed46 | 2015-09-24 11:30:58 +0200 | [diff] [blame] | 175 | struct amr_mode ms_mode[4]; |
| 176 | struct amr_mode bts_mode[4]; |
Harald Welte | f3b5932 | 2011-09-06 22:14:43 +0200 | [diff] [blame] | 177 | uint8_t num_modes; |
| 178 | }; |
Harald Welte | c7921c9 | 2011-06-29 10:38:34 +0200 | [diff] [blame] | 179 | /* /BTS ONLY */ |
| 180 | |
Harald Welte | e422798 | 2012-08-24 15:33:56 +0200 | [diff] [blame] | 181 | enum lchan_csd_mode { |
| 182 | LCHAN_CSD_M_NT, |
| 183 | LCHAN_CSD_M_T_1200_75, |
| 184 | LCHAN_CSD_M_T_600, |
| 185 | LCHAN_CSD_M_T_1200, |
| 186 | LCHAN_CSD_M_T_2400, |
| 187 | LCHAN_CSD_M_T_9600, |
| 188 | LCHAN_CSD_M_T_14400, |
| 189 | LCHAN_CSD_M_T_29000, |
| 190 | LCHAN_CSD_M_T_32000, |
| 191 | }; |
| 192 | |
Daniel Willmann | 324c805 | 2012-12-29 12:32:30 +0100 | [diff] [blame] | 193 | /* State of the SAPIs in the lchan */ |
| 194 | enum lchan_sapi_state { |
| 195 | LCHAN_SAPI_S_NONE, |
| 196 | LCHAN_SAPI_S_REQ, |
| 197 | LCHAN_SAPI_S_ASSIGNED, |
| 198 | LCHAN_SAPI_S_REL, |
| 199 | LCHAN_SAPI_S_ERROR, |
| 200 | }; |
| 201 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 202 | struct gsm_lchan { |
| 203 | /* The TS that we're part of */ |
| 204 | struct gsm_bts_trx_ts *ts; |
| 205 | /* The logical subslot number in the TS */ |
| 206 | uint8_t nr; |
| 207 | /* The logical channel type */ |
| 208 | enum gsm_chan_t type; |
| 209 | /* RSL channel mode */ |
| 210 | enum rsl_cmod_spd rsl_cmode; |
| 211 | /* If TCH, traffic channel mode */ |
| 212 | enum gsm48_chan_mode tch_mode; |
Harald Welte | e422798 | 2012-08-24 15:33:56 +0200 | [diff] [blame] | 213 | enum lchan_csd_mode csd_mode; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 214 | /* State */ |
| 215 | enum gsm_lchan_state state; |
Holger Hans Peter Freyther | 454140e | 2014-12-28 12:08:28 +0100 | [diff] [blame] | 216 | const char *broken_reason; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 217 | /* Power levels for MS and BTS */ |
| 218 | uint8_t bs_power; |
| 219 | uint8_t ms_power; |
| 220 | /* Encryption information */ |
Neels Hofmeyr | ac1f143 | 2016-05-10 13:30:17 +0200 | [diff] [blame] | 221 | struct gsm_encr encr; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 222 | |
| 223 | /* AMR bits */ |
Andreas Eversberg | 7326652 | 2014-01-19 11:47:44 +0100 | [diff] [blame] | 224 | uint8_t mr_ms_lv[7]; |
| 225 | uint8_t mr_bts_lv[7]; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 226 | |
| 227 | /* Established data link layer services */ |
| 228 | uint8_t sapis[8]; |
Holger Hans Peter Freyther | b9b828b | 2013-01-01 19:20:28 +0100 | [diff] [blame] | 229 | int sacch_deact; |
Holger Hans Peter Freyther | dfcfe65 | 2011-12-27 20:49:53 +0100 | [diff] [blame] | 230 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 231 | struct { |
| 232 | uint32_t bound_ip; |
| 233 | uint32_t connect_ip; |
| 234 | uint16_t bound_port; |
| 235 | uint16_t connect_port; |
| 236 | uint16_t conn_id; |
| 237 | uint8_t rtp_payload; |
| 238 | uint8_t rtp_payload2; |
| 239 | uint8_t speech_mode; |
| 240 | struct rtp_socket *rtp_socket; |
Philipp Maier | 39f62bb | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 241 | |
| 242 | /* info we need to postpone the AoIP |
| 243 | * assignment completed message */ |
| 244 | struct { |
| 245 | uint8_t rr_cause; |
| 246 | uint8_t chosen_channel; |
| 247 | uint8_t encr_alg_id; |
| 248 | uint8_t speech_mode; |
| 249 | bool valid; |
| 250 | } ass_compl; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 251 | } abis_ip; |
| 252 | |
Harald Welte | 2c1ae47 | 2011-06-26 14:13:37 +0200 | [diff] [blame] | 253 | uint8_t rqd_ta; |
| 254 | |
Harald Welte | c696cc2 | 2015-12-05 16:19:21 +0100 | [diff] [blame] | 255 | char *name; |
| 256 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 257 | struct osmo_timer_list T3101; |
Holger Hans Peter Freyther | b348939 | 2011-12-28 16:21:05 +0100 | [diff] [blame] | 258 | struct osmo_timer_list T3109; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 259 | struct osmo_timer_list T3111; |
| 260 | struct osmo_timer_list error_timer; |
Harald Welte | e8bd9e8 | 2011-08-10 23:26:33 +0200 | [diff] [blame] | 261 | struct osmo_timer_list act_timer; |
Andreas Eversberg | 7d8fa34 | 2013-12-05 13:25:06 +0100 | [diff] [blame] | 262 | struct osmo_timer_list rel_work; |
Holger Hans Peter Freyther | 638da51 | 2012-12-06 19:25:06 +0100 | [diff] [blame] | 263 | uint8_t error_cause; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 264 | |
| 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 Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 274 | |
| 275 | struct gsm_subscriber_connection *conn; |
Andreas Eversberg | 9df268e | 2013-10-11 13:32:30 +0200 | [diff] [blame] | 276 | |
| 277 | struct { |
| 278 | /* channel activation type and handover ref */ |
| 279 | uint8_t act_type; |
| 280 | uint8_t ho_ref; |
Neels Hofmeyr | b91e600 | 2016-07-23 19:45:15 +0200 | [diff] [blame] | 281 | struct gsm48_req_ref *rqd_ref; |
| 282 | uint8_t rqd_ta; |
Neels Hofmeyr | 6e999b7 | 2016-07-23 21:00:51 +0200 | [diff] [blame] | 283 | } dyn; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 284 | }; |
| 285 | |
Neels Hofmeyr | 2ebacce | 2016-06-14 14:08:35 +0200 | [diff] [blame] | 286 | enum { |
| 287 | TS_F_PDCH_ACTIVE = 0x1000, |
| 288 | TS_F_PDCH_ACT_PENDING = 0x2000, |
| 289 | TS_F_PDCH_DEACT_PENDING = 0x4000, |
| 290 | TS_F_PDCH_PENDING_MASK = 0x6000 /*< |
| 291 | TS_F_PDCH_ACT_PENDING | TS_F_PDCH_DEACT_PENDING */ |
| 292 | } gsm_bts_trx_ts_flags; |
| 293 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 294 | /* One Timeslot in a TRX */ |
| 295 | struct gsm_bts_trx_ts { |
| 296 | struct gsm_bts_trx *trx; |
| 297 | /* number of this timeslot at the TRX */ |
| 298 | uint8_t nr; |
| 299 | |
| 300 | enum gsm_phys_chan_config pchan; |
| 301 | |
Neels Hofmeyr | c165876 | 2016-07-23 16:14:06 +0200 | [diff] [blame] | 302 | struct { |
| 303 | enum gsm_phys_chan_config pchan_is; |
| 304 | enum gsm_phys_chan_config pchan_want; |
| 305 | struct msgb *pending_chan_activ; |
| 306 | } dyn; |
| 307 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 308 | unsigned int flags; |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 309 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 310 | struct tlv_parsed nm_attr; |
| 311 | uint8_t nm_chan_comb; |
Harald Welte | 135a648 | 2011-05-30 12:09:13 +0200 | [diff] [blame] | 312 | int tsc; /* -1 == use BTS TSC */ |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 313 | |
| 314 | struct { |
| 315 | /* Parameters below are configured by VTY */ |
| 316 | int enabled; |
| 317 | uint8_t maio; |
| 318 | uint8_t hsn; |
| 319 | struct bitvec arfcns; |
| 320 | uint8_t arfcns_data[1024/8]; |
| 321 | /* This is the pre-computed MA for channel assignments */ |
| 322 | struct bitvec ma; |
| 323 | uint8_t ma_len; /* part of ma_data that is used */ |
| 324 | uint8_t ma_data[8]; /* 10.5.2.21: max 8 bytes value part */ |
| 325 | } hopping; |
| 326 | |
| 327 | /* To which E1 subslot are we connected */ |
| 328 | struct gsm_e1_subslot e1_link; |
| 329 | |
Harald Welte | 591e1d7 | 2016-07-09 22:20:57 +0200 | [diff] [blame] | 330 | union { |
| 331 | struct { |
| 332 | struct om2k_mo om2k_mo; |
| 333 | } rbs2000; |
| 334 | }; |
| 335 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 336 | struct gsm_lchan lchan[TS_MAX_LCHAN]; |
| 337 | }; |
| 338 | |
| 339 | /* One TRX in a BTS */ |
| 340 | struct gsm_bts_trx { |
| 341 | /* list header in bts->trx_list */ |
| 342 | struct llist_head list; |
| 343 | |
| 344 | struct gsm_bts *bts; |
| 345 | /* number of this TRX in the BTS */ |
| 346 | uint8_t nr; |
| 347 | /* human readable name / description */ |
| 348 | char *description; |
| 349 | /* how do we talk RSL with this TRX? */ |
| 350 | struct gsm_e1_subslot rsl_e1_link; |
| 351 | uint8_t rsl_tei; |
| 352 | struct e1inp_sign_link *rsl_link; |
Holger Hans Peter Freyther | caa98d5 | 2013-10-06 15:52:14 +0200 | [diff] [blame] | 353 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 354 | /* Some BTS (specifically Ericsson RBS) have a per-TRX OML Link */ |
| 355 | struct e1inp_sign_link *oml_link; |
| 356 | |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 357 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 358 | struct tlv_parsed nm_attr; |
| 359 | struct { |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 360 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 361 | } bb_transc; |
| 362 | |
| 363 | uint16_t arfcn; |
| 364 | int nominal_power; /* in dBm */ |
| 365 | unsigned int max_power_red; /* in actual dB */ |
Holger Hans Peter Freyther | 9b62580 | 2014-07-30 18:20:51 +0200 | [diff] [blame] | 366 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 367 | union { |
| 368 | struct { |
| 369 | struct { |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 370 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 371 | } bbsig; |
| 372 | struct { |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 373 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 374 | } pa; |
| 375 | } bs11; |
| 376 | struct { |
| 377 | unsigned int test_state; |
| 378 | uint8_t test_nr; |
| 379 | struct rxlev_stats rxlev_stat; |
| 380 | } ipaccess; |
Harald Welte | 591e1d7 | 2016-07-09 22:20:57 +0200 | [diff] [blame] | 381 | struct { |
| 382 | struct { |
| 383 | struct om2k_mo om2k_mo; |
| 384 | } trxc; |
| 385 | struct { |
| 386 | struct om2k_mo om2k_mo; |
| 387 | } rx; |
| 388 | struct { |
| 389 | struct om2k_mo om2k_mo; |
| 390 | } tx; |
| 391 | } rbs2000; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 392 | }; |
| 393 | struct gsm_bts_trx_ts ts[TRX_NR_TS]; |
| 394 | }; |
| 395 | |
Max | 70fdd24 | 2017-06-15 15:10:53 +0200 | [diff] [blame] | 396 | #define GSM_BTS_SI2Q(bts, i) (struct gsm48_system_information_type_2quater *)((bts)->si_buf[SYSINFO_TYPE_2quater][i]) |
Max | 9b97b00 | 2017-06-02 10:58:26 +0200 | [diff] [blame] | 397 | #define GSM_BTS_HAS_SI(bts, i) ((bts)->si_valid & (1 << i)) |
Max | 70fdd24 | 2017-06-15 15:10:53 +0200 | [diff] [blame] | 398 | #define GSM_BTS_SI(bts, i) (void *)((bts)->si_buf[i][0]) |
| 399 | #define GSM_LCHAN_SI(lchan, i) (void *)((lchan)->si.buf[i][0]) |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 400 | |
| 401 | enum gsm_bts_type { |
| 402 | GSM_BTS_TYPE_UNKNOWN, |
| 403 | GSM_BTS_TYPE_BS11, |
| 404 | GSM_BTS_TYPE_NANOBTS, |
| 405 | GSM_BTS_TYPE_RBS2000, |
Dieter Spaar | 1664602 | 2011-07-28 00:01:50 +0200 | [diff] [blame] | 406 | GSM_BTS_TYPE_NOKIA_SITE, |
Max | f9685c1 | 2017-03-23 12:01:07 +0100 | [diff] [blame] | 407 | GSM_BTS_TYPE_OSMOBTS, |
Harald Welte | e555c2b | 2012-08-17 13:02:12 +0200 | [diff] [blame] | 408 | _NUM_GSM_BTS_TYPE |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 409 | }; |
| 410 | |
Max | f9685c1 | 2017-03-23 12:01:07 +0100 | [diff] [blame] | 411 | enum gsm_bts_type_variant { |
| 412 | BTS_UNKNOWN, |
| 413 | BTS_OSMO_LITECELL15, |
| 414 | BTS_OSMO_OCTPHY, |
| 415 | BTS_OSMO_SYSMO, |
| 416 | BTS_OSMO_TRX, |
| 417 | _NUM_BTS_VARIANT |
| 418 | }; |
| 419 | |
Max | 7507aef | 2017-04-10 13:59:14 +0200 | [diff] [blame] | 420 | /* Used by OML layer for BTS Attribute reporting */ |
| 421 | enum bts_attribute { |
| 422 | BTS_TYPE_VARIANT, |
| 423 | BTS_SUB_MODEL, |
Max | 33e1357 | 2017-05-29 11:48:29 +0200 | [diff] [blame] | 424 | TRX_PHY_VERSION, |
Max | 7507aef | 2017-04-10 13:59:14 +0200 | [diff] [blame] | 425 | }; |
| 426 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 427 | struct vty; |
| 428 | |
| 429 | struct gsm_bts_model { |
| 430 | struct llist_head list; |
| 431 | |
| 432 | enum gsm_bts_type type; |
Max | f9685c1 | 2017-03-23 12:01:07 +0100 | [diff] [blame] | 433 | enum gsm_bts_type_variant variant; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 434 | const char *name; |
| 435 | |
| 436 | bool started; |
| 437 | int (*start)(struct gsm_network *net); |
| 438 | int (*oml_rcvmsg)(struct msgb *msg); |
Max | 3d049d2 | 2017-10-09 17:12:53 +0200 | [diff] [blame] | 439 | char * (*oml_status)(const struct gsm_bts *bts); |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 440 | |
Pablo Neira Ayuso | ed5cacb | 2011-08-17 22:44:07 +0200 | [diff] [blame] | 441 | void (*e1line_bind_ops)(struct e1inp_line *line); |
| 442 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 443 | void (*config_write_bts)(struct vty *vty, struct gsm_bts *bts); |
| 444 | void (*config_write_trx)(struct vty *vty, struct gsm_bts_trx *trx); |
| 445 | void (*config_write_ts)(struct vty *vty, struct gsm_bts_trx_ts *ts); |
| 446 | |
| 447 | struct tlv_definition nm_att_tlvdef; |
| 448 | |
Max | aef6838 | 2017-05-31 12:15:54 +0200 | [diff] [blame] | 449 | /* features of a given BTS model set via gsm_bts_model_register() locally */ |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 450 | struct bitvec features; |
Max | 7b62d54 | 2017-05-09 15:19:15 +0200 | [diff] [blame] | 451 | uint8_t _features_data[MAX_BTS_FEATURES/8]; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 452 | }; |
| 453 | |
Max | aef6838 | 2017-05-31 12:15:54 +0200 | [diff] [blame] | 454 | /* N. B: always add new features to the end of the list (right before _NUM_BTS_FEAT) to avoid breaking compatibility |
| 455 | with BTS compiled against earlier version of this header */ |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 456 | enum gsm_bts_features { |
| 457 | BTS_FEAT_HSCSD, |
| 458 | BTS_FEAT_GPRS, |
| 459 | BTS_FEAT_EGPRS, |
| 460 | BTS_FEAT_ECSD, |
| 461 | BTS_FEAT_HOPPING, |
Harald Welte | 903aaea | 2014-01-19 17:10:50 +0100 | [diff] [blame] | 462 | BTS_FEAT_MULTI_TSC, |
Max | 1ebf23b | 2017-05-10 12:21:17 +0200 | [diff] [blame] | 463 | BTS_FEAT_OML_ALERTS, |
| 464 | BTS_FEAT_AGCH_PCH_PROP, |
| 465 | BTS_FEAT_CBCH, |
Max | aef6838 | 2017-05-31 12:15:54 +0200 | [diff] [blame] | 466 | _NUM_BTS_FEAT |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 467 | }; |
| 468 | |
Max | aef6838 | 2017-05-31 12:15:54 +0200 | [diff] [blame] | 469 | extern const struct value_string gsm_bts_features_descs[]; |
| 470 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 471 | /* |
| 472 | * This keeps track of the paging status of one BTS. It |
| 473 | * includes a number of pending requests, a back pointer |
| 474 | * to the gsm_bts, a timer and some more state. |
| 475 | */ |
| 476 | struct gsm_bts_paging_state { |
| 477 | /* pending requests */ |
| 478 | struct llist_head pending_requests; |
| 479 | struct gsm_bts *bts; |
| 480 | |
| 481 | struct osmo_timer_list work_timer; |
| 482 | struct osmo_timer_list credit_timer; |
| 483 | |
| 484 | /* free chans needed */ |
| 485 | int free_chans_need; |
| 486 | |
| 487 | /* load */ |
| 488 | uint16_t available_slots; |
| 489 | }; |
| 490 | |
| 491 | struct gsm_envabtse { |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 492 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 493 | }; |
| 494 | |
| 495 | struct gsm_bts_gprs_nsvc { |
| 496 | struct gsm_bts *bts; |
| 497 | /* data read via VTY config file, to configure the BTS |
| 498 | * via OML from BSC */ |
| 499 | int id; |
| 500 | uint16_t nsvci; |
| 501 | uint16_t local_port; /* on the BTS */ |
| 502 | uint16_t remote_port; /* on the SGSN */ |
| 503 | uint32_t remote_ip; /* on the SGSN */ |
| 504 | |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 505 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 506 | }; |
| 507 | |
Harald Welte | 019f913 | 2012-06-28 08:43:14 +0200 | [diff] [blame] | 508 | enum gprs_rlc_par { |
| 509 | RLC_T3142, |
| 510 | RLC_T3169, |
| 511 | RLC_T3191, |
| 512 | RLC_T3193, |
| 513 | RLC_T3195, |
| 514 | RLC_N3101, |
| 515 | RLC_N3103, |
| 516 | RLC_N3105, |
| 517 | CV_COUNTDOWN, |
| 518 | T_DL_TBF_EXT, /* ms */ |
| 519 | T_UL_TBF_EXT, /* ms */ |
| 520 | _NUM_RLC_PAR |
| 521 | }; |
| 522 | |
| 523 | enum gprs_cs { |
| 524 | GPRS_CS1, |
| 525 | GPRS_CS2, |
| 526 | GPRS_CS3, |
| 527 | GPRS_CS4, |
| 528 | GPRS_MCS1, |
| 529 | GPRS_MCS2, |
| 530 | GPRS_MCS3, |
| 531 | GPRS_MCS4, |
| 532 | GPRS_MCS5, |
| 533 | GPRS_MCS6, |
| 534 | GPRS_MCS7, |
| 535 | GPRS_MCS8, |
| 536 | GPRS_MCS9, |
| 537 | _NUM_GRPS_CS |
| 538 | }; |
| 539 | |
| 540 | struct gprs_rlc_cfg { |
| 541 | uint16_t parameter[_NUM_RLC_PAR]; |
| 542 | struct { |
| 543 | uint16_t repeat_time; /* ms */ |
| 544 | uint8_t repeat_count; |
| 545 | } paging; |
| 546 | uint32_t cs_mask; /* bitmask of gprs_cs */ |
| 547 | uint8_t initial_cs; |
| 548 | uint8_t initial_mcs; |
| 549 | }; |
| 550 | |
| 551 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 552 | enum neigh_list_manual_mode { |
| 553 | NL_MODE_AUTOMATIC = 0, |
| 554 | NL_MODE_MANUAL = 1, |
| 555 | NL_MODE_MANUAL_SI5SEP = 2, /* SI2 and SI5 have separate neighbor lists */ |
| 556 | }; |
| 557 | |
Daniel Willmann | 47b5b3e | 2011-08-05 13:51:27 +0200 | [diff] [blame] | 558 | enum bts_loc_fix { |
| 559 | BTS_LOC_FIX_INVALID = 0, |
| 560 | BTS_LOC_FIX_2D = 1, |
| 561 | BTS_LOC_FIX_3D = 2, |
| 562 | }; |
| 563 | |
Daniel Willmann | 7d10983 | 2012-05-14 18:43:23 +0200 | [diff] [blame] | 564 | extern const struct value_string bts_loc_fix_names[]; |
| 565 | |
Daniel Willmann | 47b5b3e | 2011-08-05 13:51:27 +0200 | [diff] [blame] | 566 | struct bts_location { |
| 567 | struct llist_head list; |
| 568 | time_t tstamp; |
| 569 | enum bts_loc_fix valid; |
| 570 | double lat; |
| 571 | double lon; |
| 572 | double height; |
| 573 | }; |
| 574 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 575 | /* One BTS */ |
| 576 | struct gsm_bts { |
| 577 | /* list header in net->bts_list */ |
| 578 | struct llist_head list; |
| 579 | |
Daniel Willmann | 47b5b3e | 2011-08-05 13:51:27 +0200 | [diff] [blame] | 580 | /* Geographical location of the BTS */ |
| 581 | struct llist_head loc_list; |
| 582 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 583 | /* number of ths BTS in network */ |
| 584 | uint8_t nr; |
| 585 | /* human readable name / description */ |
| 586 | char *description; |
| 587 | /* Cell Identity */ |
| 588 | uint16_t cell_identity; |
| 589 | /* location area code of this BTS */ |
| 590 | uint16_t location_area_code; |
Harald Welte | a2bbc5e | 2015-11-20 10:43:31 +0100 | [diff] [blame] | 591 | /* Base Station Identification Code (BSIC), lower 3 bits is BCC, |
| 592 | * which is used as TSC for the CCCH */ |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 593 | uint8_t bsic; |
| 594 | /* type of BTS */ |
| 595 | enum gsm_bts_type type; |
Max | 6d8e519 | 2017-04-11 18:23:47 +0200 | [diff] [blame] | 596 | enum gsm_bts_type_variant variant; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 597 | struct gsm_bts_model *model; |
| 598 | enum gsm_band band; |
Max | f9685c1 | 2017-03-23 12:01:07 +0100 | [diff] [blame] | 599 | char version[MAX_VERSION_LENGTH]; |
Max | 1ebf23b | 2017-05-10 12:21:17 +0200 | [diff] [blame] | 600 | char sub_model[MAX_VERSION_LENGTH]; |
Max | f9685c1 | 2017-03-23 12:01:07 +0100 | [diff] [blame] | 601 | |
Max | aef6838 | 2017-05-31 12:15:54 +0200 | [diff] [blame] | 602 | /* features of a given BTS set/reported via OML */ |
| 603 | struct bitvec features; |
| 604 | uint8_t _features_data[MAX_BTS_FEATURES/8]; |
| 605 | |
Max | f9685c1 | 2017-03-23 12:01:07 +0100 | [diff] [blame] | 606 | /* Connected PCU version (if any) */ |
| 607 | char pcu_version[MAX_VERSION_LENGTH]; |
| 608 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 609 | /* maximum Tx power that the MS is permitted to use in this cell */ |
| 610 | int ms_max_power; |
| 611 | |
| 612 | /* how do we talk OML with this TRX? */ |
| 613 | struct gsm_e1_subslot oml_e1_link; |
| 614 | uint8_t oml_tei; |
| 615 | struct e1inp_sign_link *oml_link; |
Max | d1f70ed | 2017-09-21 16:15:32 +0200 | [diff] [blame] | 616 | /* when OML link was established */ |
| 617 | time_t uptime; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 618 | |
| 619 | /* Abis network management O&M handle */ |
| 620 | struct abis_nm_h *nmh; |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 621 | |
| 622 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 623 | |
| 624 | /* number of this BTS on given E1 link */ |
| 625 | uint8_t bts_nr; |
| 626 | |
Max | c08ee71 | 2016-05-11 12:45:13 +0200 | [diff] [blame] | 627 | /* DTX features of this BTS */ |
| 628 | enum gsm48_dtx_mode dtxu; |
| 629 | bool dtxd; |
| 630 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 631 | /* paging state and control */ |
| 632 | struct gsm_bts_paging_state paging; |
| 633 | |
| 634 | /* CCCH is on C0 */ |
| 635 | struct gsm_bts_trx *c0; |
| 636 | |
| 637 | struct { |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 638 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 639 | } site_mgr; |
| 640 | |
| 641 | /* bitmask of all SI that are present/valid in si_buf */ |
| 642 | uint32_t si_valid; |
Max | 6f0e50c | 2017-04-12 15:30:54 +0200 | [diff] [blame] | 643 | /* 3GPP TS 44.018 Table 10.5.2.33b.1 INDEX and COUNT for SI2quater */ |
Max | f39d03a | 2017-05-12 17:00:30 +0200 | [diff] [blame] | 644 | uint8_t si2q_index; /* distinguish individual SI2quater messages */ |
| 645 | uint8_t si2q_count; /* si2q_index for the last (highest indexed) individual SI2quater message */ |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 646 | /* buffers where we put the pre-computed SI */ |
Max | 70fdd24 | 2017-06-15 15:10:53 +0200 | [diff] [blame] | 647 | sysinfo_buf_t si_buf[_MAX_SYSINFO_TYPE][SI2Q_MAX_NUM]; |
Max | f39d03a | 2017-05-12 17:00:30 +0200 | [diff] [blame] | 648 | /* offsets used while generating SI2quater */ |
| 649 | size_t e_offset; |
| 650 | size_t u_offset; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 651 | |
| 652 | /* ip.accesss Unit ID's have Site/BTS/TRX layout */ |
| 653 | union { |
| 654 | struct { |
| 655 | uint16_t site_id; |
| 656 | uint16_t bts_id; |
| 657 | uint32_t flags; |
Harald Welte | 8b29180 | 2013-03-12 13:57:05 +0100 | [diff] [blame] | 658 | uint32_t rsl_ip; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 659 | } ip_access; |
| 660 | struct { |
| 661 | struct { |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 662 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 663 | } cclk; |
| 664 | struct { |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 665 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 666 | } rack; |
| 667 | struct gsm_envabtse envabtse[4]; |
| 668 | } bs11; |
| 669 | struct { |
| 670 | struct { |
Harald Welte | 591e1d7 | 2016-07-09 22:20:57 +0200 | [diff] [blame] | 671 | struct om2k_mo om2k_mo; |
| 672 | struct gsm_abis_mo mo; |
| 673 | struct llist_head conn_groups; |
| 674 | } cf; |
| 675 | struct { |
| 676 | struct om2k_mo om2k_mo; |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 677 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 678 | struct llist_head conn_groups; |
| 679 | } is; |
| 680 | struct { |
Harald Welte | 591e1d7 | 2016-07-09 22:20:57 +0200 | [diff] [blame] | 681 | struct om2k_mo om2k_mo; |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 682 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 683 | struct llist_head conn_groups; |
| 684 | } con; |
| 685 | struct { |
Harald Welte | 591e1d7 | 2016-07-09 22:20:57 +0200 | [diff] [blame] | 686 | struct om2k_mo om2k_mo; |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 687 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 688 | } dp; |
| 689 | struct { |
Harald Welte | 591e1d7 | 2016-07-09 22:20:57 +0200 | [diff] [blame] | 690 | struct om2k_mo om2k_mo; |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 691 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 692 | } tf; |
Harald Welte | ce49258 | 2016-11-15 22:59:24 +0100 | [diff] [blame] | 693 | uint32_t use_superchannel:1; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 694 | } rbs2000; |
| 695 | struct { |
Harald Welte | c8755af | 2011-07-28 00:22:17 +0200 | [diff] [blame] | 696 | uint8_t bts_type; |
Holger Hans Peter Freyther | 3e60348 | 2012-03-02 14:14:33 +0100 | [diff] [blame] | 697 | unsigned int configured:1, |
| 698 | skip_reset:1, |
Andreas Eversberg | 7d8fa34 | 2013-12-05 13:25:06 +0100 | [diff] [blame] | 699 | no_loc_rel_cnf:1, |
Sipos Csaba | 56e1766 | 2015-02-07 13:27:36 +0100 | [diff] [blame] | 700 | bts_reset_timer_cnf, |
Holger Hans Peter Freyther | 3e60348 | 2012-03-02 14:14:33 +0100 | [diff] [blame] | 701 | did_reset:1, |
| 702 | wait_reset:1; |
Harald Welte | c8755af | 2011-07-28 00:22:17 +0200 | [diff] [blame] | 703 | struct osmo_timer_list reset_timer; |
| 704 | } nokia; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 705 | }; |
| 706 | |
| 707 | /* Not entirely sure how ip.access specific this is */ |
| 708 | struct { |
bhargava | 350533c | 2016-07-21 11:14:34 +0530 | [diff] [blame] | 709 | uint8_t supports_egprs_11bit_rach; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 710 | enum bts_gprs_mode mode; |
| 711 | struct { |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 712 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 713 | uint16_t nsei; |
| 714 | uint8_t timer[7]; |
| 715 | } nse; |
| 716 | struct { |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 717 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 718 | uint16_t bvci; |
| 719 | uint8_t timer[11]; |
Harald Welte | 019f913 | 2012-06-28 08:43:14 +0200 | [diff] [blame] | 720 | struct gprs_rlc_cfg rlc_cfg; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 721 | } cell; |
| 722 | struct gsm_bts_gprs_nsvc nsvc[2]; |
| 723 | uint8_t rac; |
Andreas Eversberg | 0c8f9ca | 2013-03-16 16:31:26 +0100 | [diff] [blame] | 724 | uint8_t net_ctrl_ord; |
Max | 292ec58 | 2016-07-28 11:55:37 +0200 | [diff] [blame] | 725 | bool ctrl_ack_type_use_block; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 726 | } gprs; |
| 727 | |
| 728 | /* RACH NM values */ |
| 729 | int rach_b_thresh; |
| 730 | int rach_ldavg_slots; |
| 731 | |
| 732 | /* transceivers */ |
| 733 | int num_trx; |
| 734 | struct llist_head trx_list; |
| 735 | |
Holger Hans Peter Freyther | b92a538 | 2014-11-21 10:00:39 +0100 | [diff] [blame] | 736 | /* SI related items */ |
Jacob Erlbeck | 65d114f | 2014-01-16 11:02:14 +0100 | [diff] [blame] | 737 | int force_combined_si; |
Holger Hans Peter Freyther | b92a538 | 2014-11-21 10:00:39 +0100 | [diff] [blame] | 738 | int bcch_change_mark; |
Jacob Erlbeck | 65d114f | 2014-01-16 11:02:14 +0100 | [diff] [blame] | 739 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 740 | /* Abis NM queue */ |
| 741 | struct llist_head abis_queue; |
| 742 | int abis_nm_pend; |
| 743 | |
| 744 | struct gsm_network *network; |
| 745 | |
| 746 | /* should the channel allocator allocate channels from high TRX to TRX0, |
| 747 | * rather than starting from TRX0 and go upwards? */ |
| 748 | int chan_alloc_reverse; |
| 749 | |
| 750 | enum neigh_list_manual_mode neigh_list_manual_mode; |
| 751 | /* parameters from which we build SYSTEM INFORMATION */ |
| 752 | struct { |
| 753 | struct gsm48_rach_control rach_control; |
| 754 | uint8_t ncc_permitted; |
| 755 | struct gsm48_cell_sel_par cell_sel_par; |
| 756 | struct gsm48_si_selection_params cell_ro_sel_par; /* rest octet */ |
| 757 | struct gsm48_cell_options cell_options; |
| 758 | struct gsm48_control_channel_descr chan_desc; |
| 759 | struct bitvec neigh_list; |
| 760 | struct bitvec cell_alloc; |
| 761 | struct bitvec si5_neigh_list; |
Max | 59a1bf3 | 2016-04-15 16:04:46 +0200 | [diff] [blame] | 762 | struct osmo_earfcn_si2q si2quater_neigh_list; |
Max | 26679e0 | 2016-04-20 15:57:13 +0200 | [diff] [blame] | 763 | size_t uarfcn_length; /* index for uarfcn and scramble lists */ |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 764 | struct { |
| 765 | /* bitmask large enough for all possible ARFCN's */ |
| 766 | uint8_t neigh_list[1024/8]; |
| 767 | uint8_t cell_alloc[1024/8]; |
| 768 | /* If the user wants a different neighbor list in SI5 than in SI2 */ |
| 769 | uint8_t si5_neigh_list[1024/8]; |
Max | 59a1bf3 | 2016-04-15 16:04:46 +0200 | [diff] [blame] | 770 | uint8_t meas_bw_list[MAX_EARFCN_LIST]; |
| 771 | uint16_t earfcn_list[MAX_EARFCN_LIST]; |
Max | 26679e0 | 2016-04-20 15:57:13 +0200 | [diff] [blame] | 772 | uint16_t uarfcn_list[MAX_EARFCN_LIST]; |
| 773 | uint16_t scramble_list[MAX_EARFCN_LIST]; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 774 | } data; |
| 775 | } si_common; |
Harald Welte | 42def72 | 2017-01-13 00:10:32 +0100 | [diff] [blame] | 776 | bool early_classmark_allowed; |
Pau Espin Pedrol | e8dda5f | 2017-11-23 19:06:09 +0100 | [diff] [blame] | 777 | bool early_classmark_allowed_3g; |
Harald Welte | 2f8b9d2 | 2017-06-18 11:12:13 +0300 | [diff] [blame] | 778 | /* for testing only: Have an infinitely long radio link timeout */ |
| 779 | bool infinite_radio_link_timeout; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 780 | |
| 781 | /* do we use static (user-defined) system information messages? (bitmask) */ |
| 782 | uint32_t si_mode_static; |
Holger Hans Peter Freyther | e30d40d | 2012-07-20 10:27:31 +0200 | [diff] [blame] | 783 | |
| 784 | /* exclude the BTS from the global RF Lock handling */ |
| 785 | int excl_from_rf_lock; |
Andreas Eversberg | a83d511 | 2013-12-07 18:32:28 +0100 | [diff] [blame] | 786 | |
| 787 | /* supported codecs beside FR */ |
| 788 | struct bts_codec_conf codec; |
Holger Hans Peter Freyther | c22930e | 2014-12-17 14:46:17 +0100 | [diff] [blame] | 789 | |
| 790 | /* BTS dependencies bit field */ |
| 791 | uint32_t depends_on[256/(8*4)]; |
Andreas Eversberg | 7326652 | 2014-01-19 11:47:44 +0100 | [diff] [blame] | 792 | |
| 793 | /* full and half rate multirate config */ |
| 794 | struct amr_multirate_conf mr_full; |
| 795 | struct amr_multirate_conf mr_half; |
| 796 | |
Philipp Maier | b4999b6 | 2016-10-26 15:19:41 +0200 | [diff] [blame] | 797 | /* PCU socket state */ |
Harald Welte | 8254cf7 | 2017-05-29 13:42:19 +0200 | [diff] [blame] | 798 | char *pcu_sock_path; |
Philipp Maier | b4999b6 | 2016-10-26 15:19:41 +0200 | [diff] [blame] | 799 | struct pcu_sock_state *pcu_state; |
Harald Welte | d82101e | 2017-12-09 23:07:38 +0100 | [diff] [blame] | 800 | |
| 801 | struct rate_ctr_group *bts_ctrs; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 802 | }; |
| 803 | |
| 804 | |
Neels Hofmeyr | 9c6d011 | 2017-11-28 00:13:08 +0100 | [diff] [blame] | 805 | struct gsm_bts *gsm_bts_alloc(struct gsm_network *net, uint8_t bts_num); |
Harald Welte | 1449c9f | 2014-08-24 09:50:10 +0200 | [diff] [blame] | 806 | struct gsm_bts *gsm_bts_num(struct gsm_network *net, int num); |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 807 | |
Harald Welte | 1449c9f | 2014-08-24 09:50:10 +0200 | [diff] [blame] | 808 | struct gsm_bts_trx *gsm_bts_trx_alloc(struct gsm_bts *bts); |
Harald Welte | 4f8ad53 | 2011-09-19 14:21:51 +0200 | [diff] [blame] | 809 | struct gsm_bts_trx *gsm_bts_trx_num(const struct gsm_bts *bts, int num); |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 810 | |
Max | 7507aef | 2017-04-10 13:59:14 +0200 | [diff] [blame] | 811 | enum gsm_bts_type str2btstype(const char *arg); |
| 812 | const char *btstype2str(enum gsm_bts_type type); |
| 813 | |
| 814 | enum bts_attribute str2btsattr(const char *s); |
| 815 | const char *btsatttr2str(enum bts_attribute v); |
| 816 | |
| 817 | enum gsm_bts_type_variant str2btsvariant(const char *arg); |
| 818 | const char *btsvariant2str(enum gsm_bts_type_variant v); |
Harald Welte | 4ab9d7c | 2012-08-17 12:42:06 +0200 | [diff] [blame] | 819 | |
Philipp Maier | 6f483d3 | 2017-02-24 15:18:08 +0100 | [diff] [blame] | 820 | extern const struct value_string gsm_chreq_descs[]; |
Neels Hofmeyr | 17a6bab | 2016-07-23 16:14:06 +0200 | [diff] [blame] | 821 | const struct value_string gsm_pchant_names[13]; |
| 822 | const struct value_string gsm_pchant_descs[13]; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 823 | const char *gsm_pchan_name(enum gsm_phys_chan_config c); |
| 824 | enum gsm_phys_chan_config gsm_pchan_parse(const char *name); |
| 825 | const char *gsm_lchant_name(enum gsm_chan_t c); |
| 826 | const char *gsm_chreq_name(enum gsm_chreq_reason_t c); |
Harald Welte | 4f8ad53 | 2011-09-19 14:21:51 +0200 | [diff] [blame] | 827 | char *gsm_trx_name(const struct gsm_bts_trx *trx); |
| 828 | char *gsm_ts_name(const struct gsm_bts_trx_ts *ts); |
Neels Hofmeyr | 34b8b5b | 2016-07-16 23:59:32 +0200 | [diff] [blame] | 829 | char *gsm_ts_and_pchan_name(const struct gsm_bts_trx_ts *ts); |
Harald Welte | c696cc2 | 2015-12-05 16:19:21 +0100 | [diff] [blame] | 830 | char *gsm_lchan_name_compute(const struct gsm_lchan *lchan); |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 831 | const char *gsm_lchans_name(enum gsm_lchan_state s); |
| 832 | |
Harald Welte | c696cc2 | 2015-12-05 16:19:21 +0100 | [diff] [blame] | 833 | static inline char *gsm_lchan_name(const struct gsm_lchan *lchan) |
| 834 | { |
| 835 | return lchan->name; |
| 836 | } |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 837 | |
Max | aef6838 | 2017-05-31 12:15:54 +0200 | [diff] [blame] | 838 | static inline int gsm_bts_set_feature(struct gsm_bts *bts, enum gsm_bts_features feat) |
| 839 | { |
| 840 | OSMO_ASSERT(_NUM_BTS_FEAT < MAX_BTS_FEATURES); |
| 841 | return bitvec_set_bit_pos(&bts->features, feat, 1); |
| 842 | } |
| 843 | |
| 844 | static inline bool gsm_bts_has_feature(const struct gsm_bts *bts, enum gsm_bts_features feat) |
| 845 | { |
| 846 | OSMO_ASSERT(_NUM_BTS_FEAT < MAX_BTS_FEATURES); |
| 847 | return bitvec_get_bit_pos(&bts->features, feat); |
| 848 | } |
| 849 | |
Harald Welte | b784998 | 2011-06-29 16:49:03 +0200 | [diff] [blame] | 850 | void gsm_abis_mo_reset(struct gsm_abis_mo *mo); |
| 851 | |
Harald Welte | 978714d | 2011-06-06 18:31:20 +0200 | [diff] [blame] | 852 | struct gsm_nm_state * |
| 853 | gsm_objclass2nmstate(struct gsm_bts *bts, uint8_t obj_class, |
Harald Welte | 4f8ad53 | 2011-09-19 14:21:51 +0200 | [diff] [blame] | 854 | const struct abis_om_obj_inst *obj_inst); |
Harald Welte | 978714d | 2011-06-06 18:31:20 +0200 | [diff] [blame] | 855 | void * |
| 856 | gsm_objclass2obj(struct gsm_bts *bts, uint8_t obj_class, |
Harald Welte | 4f8ad53 | 2011-09-19 14:21:51 +0200 | [diff] [blame] | 857 | const struct abis_om_obj_inst *obj_inst); |
Harald Welte | 978714d | 2011-06-06 18:31:20 +0200 | [diff] [blame] | 858 | |
Harald Welte | b784998 | 2011-06-29 16:49:03 +0200 | [diff] [blame] | 859 | /* reset the state of all MO in the BTS */ |
| 860 | void gsm_bts_mo_reset(struct gsm_bts *bts); |
| 861 | |
Neels Hofmeyr | d384110 | 2016-07-18 23:43:44 +0200 | [diff] [blame] | 862 | uint8_t gsm_pchan2chan_nr(enum gsm_phys_chan_config pchan, |
| 863 | uint8_t ts_nr, uint8_t lchan_nr); |
Harald Welte | f6093a4 | 2011-06-25 10:02:33 +0200 | [diff] [blame] | 864 | uint8_t gsm_lchan2chan_nr(const struct gsm_lchan *lchan); |
Neels Hofmeyr | d384110 | 2016-07-18 23:43:44 +0200 | [diff] [blame] | 865 | uint8_t gsm_lchan_as_pchan2chan_nr(const struct gsm_lchan *lchan, |
| 866 | enum gsm_phys_chan_config as_pchan); |
Harald Welte | f6093a4 | 2011-06-25 10:02:33 +0200 | [diff] [blame] | 867 | |
Harald Welte | 142d12d | 2014-12-29 17:47:08 +0100 | [diff] [blame] | 868 | /* return the gsm_lchan for the CBCH (if it exists at all) */ |
| 869 | struct gsm_lchan *gsm_bts_get_cbch(struct gsm_bts *bts); |
| 870 | |
Holger Hans Peter Freyther | 06c9da6 | 2011-06-09 21:48:49 +0200 | [diff] [blame] | 871 | /* |
| 872 | * help with parsing regexps |
| 873 | */ |
| 874 | int gsm_parse_reg(void *ctx, regex_t *reg, char **str, |
| 875 | int argc, const char **argv) __attribute__ ((warn_unused_result)); |
| 876 | |
Harald Welte | 1fe2412 | 2014-01-19 17:18:21 +0100 | [diff] [blame] | 877 | static inline uint8_t gsm_ts_tsc(const struct gsm_bts_trx_ts *ts) |
| 878 | { |
| 879 | if (ts->tsc != -1) |
| 880 | return ts->tsc; |
| 881 | else |
Harald Welte | a2bbc5e | 2015-11-20 10:43:31 +0100 | [diff] [blame] | 882 | return ts->trx->bts->bsic & 7; |
Harald Welte | 1fe2412 | 2014-01-19 17:18:21 +0100 | [diff] [blame] | 883 | } |
Holger Hans Peter Freyther | 06c9da6 | 2011-06-09 21:48:49 +0200 | [diff] [blame] | 884 | |
Neels Hofmeyr | 7458572 | 2016-07-23 17:38:22 +0200 | [diff] [blame] | 885 | struct gsm_lchan *rsl_lchan_lookup(struct gsm_bts_trx *trx, uint8_t chan_nr, |
| 886 | int *rc); |
Holger Hans Peter Freyther | 06c9da6 | 2011-06-09 21:48:49 +0200 | [diff] [blame] | 887 | |
Neels Hofmeyr | ec16c16 | 2016-10-17 01:03:53 +0200 | [diff] [blame] | 888 | enum gsm_phys_chan_config ts_pchan(struct gsm_bts_trx_ts *ts); |
Neels Hofmeyr | 76a0ad7 | 2016-07-29 18:12:06 +0200 | [diff] [blame] | 889 | uint8_t ts_subslots(struct gsm_bts_trx_ts *ts); |
Neels Hofmeyr | 255dbfe | 2016-09-25 15:07:01 +0200 | [diff] [blame] | 890 | bool ts_is_tch(struct gsm_bts_trx_ts *ts); |
Neels Hofmeyr | 76a0ad7 | 2016-07-29 18:12:06 +0200 | [diff] [blame] | 891 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 892 | #endif |