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> |
| 22 | |
Holger Hans Peter Freyther | 0e0a09c | 2012-12-20 19:03:18 +0100 | [diff] [blame] | 23 | #ifndef ROLE_BSC |
| 24 | #include <osmocom/gsm/lapdm.h> |
| 25 | #endif |
| 26 | |
Holger Hans Peter Freyther | 8ec4952 | 2011-08-15 15:53:00 +0200 | [diff] [blame] | 27 | struct osmo_bsc_data; |
| 28 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 29 | struct osmo_bsc_sccp_con; |
| 30 | struct gsm_sms_queue; |
| 31 | |
| 32 | /* RRLP mode of operation */ |
| 33 | enum rrlp_mode { |
| 34 | RRLP_MODE_NONE, |
| 35 | RRLP_MODE_MS_BASED, |
| 36 | RRLP_MODE_MS_PREF, |
| 37 | RRLP_MODE_ASS_PREF, |
| 38 | }; |
| 39 | |
| 40 | /* Channel Request reason */ |
| 41 | enum gsm_chreq_reason_t { |
| 42 | GSM_CHREQ_REASON_EMERG, |
| 43 | GSM_CHREQ_REASON_PAG, |
| 44 | GSM_CHREQ_REASON_CALL, |
| 45 | GSM_CHREQ_REASON_LOCATION_UPD, |
| 46 | GSM_CHREQ_REASON_OTHER, |
| 47 | }; |
| 48 | |
Max | 582e4f6 | 2016-10-18 16:19:33 +0200 | [diff] [blame] | 49 | /* lchans 0..3 are SDCCH in combined channel configuration, |
| 50 | use 4 as magic number for BCCH hack - see osmo-bts-../oml.c:opstart_compl() */ |
| 51 | #define CCCH_LCHAN 4 |
| 52 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 53 | #define TRX_NR_TS 8 |
| 54 | #define TS_MAX_LCHAN 8 |
| 55 | |
| 56 | #define HARDCODED_ARFCN 123 |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 57 | #define HARDCODED_BSIC 0x3f /* NCC = 7 / BCC = 7 */ |
| 58 | |
| 59 | /* for multi-drop config */ |
| 60 | #define HARDCODED_BTS0_TS 1 |
| 61 | #define HARDCODED_BTS1_TS 6 |
| 62 | #define HARDCODED_BTS2_TS 11 |
| 63 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 64 | enum gsm_hooks { |
| 65 | GSM_HOOK_NM_SWLOAD, |
| 66 | GSM_HOOK_RR_PAGING, |
| 67 | GSM_HOOK_RR_SECURITY, |
| 68 | }; |
| 69 | |
| 70 | enum gsm_paging_event { |
| 71 | GSM_PAGING_SUCCEEDED, |
| 72 | GSM_PAGING_EXPIRED, |
| 73 | GSM_PAGING_OOM, |
| 74 | GSM_PAGING_BUSY, |
| 75 | }; |
| 76 | |
| 77 | enum bts_gprs_mode { |
| 78 | BTS_GPRS_NONE = 0, |
| 79 | BTS_GPRS_GPRS = 1, |
| 80 | BTS_GPRS_EGPRS = 2, |
| 81 | }; |
| 82 | |
| 83 | struct gsm_lchan; |
| 84 | struct gsm_subscriber; |
| 85 | struct gsm_mncc; |
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 MAX_A5_KEY_LEN (128/8) |
| 121 | #define A38_XOR_MIN_KEY_LEN 12 |
| 122 | #define A38_XOR_MAX_KEY_LEN 16 |
| 123 | #define A38_COMP128_KEY_LEN 16 |
| 124 | #define RSL_ENC_ALG_A5(x) (x+1) |
Max | 27c3e76 | 2016-04-20 15:57:12 +0200 | [diff] [blame] | 125 | #define MAX_EARFCN_LIST 32 |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 126 | |
| 127 | /* is the data link established? who established it? */ |
| 128 | #define LCHAN_SAPI_UNUSED 0 |
| 129 | #define LCHAN_SAPI_MS 1 |
| 130 | #define LCHAN_SAPI_NET 2 |
Andreas Eversberg | 7d8fa34 | 2013-12-05 13:25:06 +0100 | [diff] [blame] | 131 | #define LCHAN_SAPI_REL 3 |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 132 | |
| 133 | /* state of a logical channel */ |
| 134 | enum gsm_lchan_state { |
| 135 | LCHAN_S_NONE, /* channel is not active */ |
Holger Hans Peter Freyther | ded0268 | 2012-01-15 00:02:17 +0100 | [diff] [blame] | 136 | LCHAN_S_ACT_REQ, /* channel activation requested */ |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 137 | LCHAN_S_ACTIVE, /* channel is active and operational */ |
| 138 | LCHAN_S_REL_REQ, /* channel release has been requested */ |
| 139 | LCHAN_S_REL_ERR, /* channel is in an error state */ |
Holger Hans Peter Freyther | 638da51 | 2012-12-06 19:25:06 +0100 | [diff] [blame] | 140 | LCHAN_S_BROKEN, /* channel is somehow unusable */ |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 141 | LCHAN_S_INACTIVE, /* channel is set inactive */ |
| 142 | }; |
| 143 | |
Harald Welte | c7921c9 | 2011-06-29 10:38:34 +0200 | [diff] [blame] | 144 | /* BTS ONLY */ |
| 145 | #define MAX_NUM_UL_MEAS 104 |
| 146 | #define LC_UL_M_F_L1_VALID (1 << 0) |
| 147 | #define LC_UL_M_F_RES_VALID (1 << 1) |
| 148 | |
| 149 | struct bts_ul_meas { |
| 150 | /* BER in units of 0.01%: 10.000 == 100% ber, 0 == 0% ber */ |
| 151 | uint16_t ber10k; |
| 152 | /* timing advance offset (in quarter bits) */ |
| 153 | int16_t ta_offs_qbits; |
| 154 | /* C/I ratio in dB */ |
| 155 | float c_i; |
| 156 | /* flags */ |
| 157 | uint8_t is_sub:1; |
| 158 | /* RSSI in dBm * -1 */ |
| 159 | uint8_t inv_rssi; |
| 160 | }; |
Harald Welte | f3b5932 | 2011-09-06 22:14:43 +0200 | [diff] [blame] | 161 | |
Andreas Eversberg | a83d511 | 2013-12-07 18:32:28 +0100 | [diff] [blame] | 162 | struct bts_codec_conf { |
| 163 | uint8_t hr; |
| 164 | uint8_t efr; |
| 165 | uint8_t amr; |
| 166 | }; |
| 167 | |
Harald Welte | f3b5932 | 2011-09-06 22:14:43 +0200 | [diff] [blame] | 168 | struct amr_mode { |
| 169 | uint8_t mode; |
Holger Hans Peter Freyther | 615ed46 | 2015-09-24 11:30:58 +0200 | [diff] [blame] | 170 | uint8_t threshold; |
| 171 | uint8_t hysteresis; |
Harald Welte | f3b5932 | 2011-09-06 22:14:43 +0200 | [diff] [blame] | 172 | }; |
Holger Hans Peter Freyther | 615ed46 | 2015-09-24 11:30:58 +0200 | [diff] [blame] | 173 | |
Harald Welte | f3b5932 | 2011-09-06 22:14:43 +0200 | [diff] [blame] | 174 | struct amr_multirate_conf { |
| 175 | uint8_t gsm48_ie[2]; |
Holger Hans Peter Freyther | 615ed46 | 2015-09-24 11:30:58 +0200 | [diff] [blame] | 176 | struct amr_mode ms_mode[4]; |
| 177 | struct amr_mode bts_mode[4]; |
Harald Welte | f3b5932 | 2011-09-06 22:14:43 +0200 | [diff] [blame] | 178 | uint8_t num_modes; |
| 179 | }; |
Harald Welte | c7921c9 | 2011-06-29 10:38:34 +0200 | [diff] [blame] | 180 | /* /BTS ONLY */ |
| 181 | |
Harald Welte | e422798 | 2012-08-24 15:33:56 +0200 | [diff] [blame] | 182 | enum lchan_csd_mode { |
| 183 | LCHAN_CSD_M_NT, |
| 184 | LCHAN_CSD_M_T_1200_75, |
| 185 | LCHAN_CSD_M_T_600, |
| 186 | LCHAN_CSD_M_T_1200, |
| 187 | LCHAN_CSD_M_T_2400, |
| 188 | LCHAN_CSD_M_T_9600, |
| 189 | LCHAN_CSD_M_T_14400, |
| 190 | LCHAN_CSD_M_T_29000, |
| 191 | LCHAN_CSD_M_T_32000, |
| 192 | }; |
| 193 | |
Daniel Willmann | 324c805 | 2012-12-29 12:32:30 +0100 | [diff] [blame] | 194 | /* State of the SAPIs in the lchan */ |
| 195 | enum lchan_sapi_state { |
| 196 | LCHAN_SAPI_S_NONE, |
| 197 | LCHAN_SAPI_S_REQ, |
| 198 | LCHAN_SAPI_S_ASSIGNED, |
| 199 | LCHAN_SAPI_S_REL, |
| 200 | LCHAN_SAPI_S_ERROR, |
| 201 | }; |
| 202 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 203 | struct gsm_lchan { |
| 204 | /* The TS that we're part of */ |
| 205 | struct gsm_bts_trx_ts *ts; |
| 206 | /* The logical subslot number in the TS */ |
| 207 | uint8_t nr; |
| 208 | /* The logical channel type */ |
| 209 | enum gsm_chan_t type; |
| 210 | /* RSL channel mode */ |
| 211 | enum rsl_cmod_spd rsl_cmode; |
| 212 | /* If TCH, traffic channel mode */ |
| 213 | enum gsm48_chan_mode tch_mode; |
Harald Welte | e422798 | 2012-08-24 15:33:56 +0200 | [diff] [blame] | 214 | enum lchan_csd_mode csd_mode; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 215 | /* State */ |
| 216 | enum gsm_lchan_state state; |
Holger Hans Peter Freyther | 454140e | 2014-12-28 12:08:28 +0100 | [diff] [blame] | 217 | const char *broken_reason; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 218 | /* Power levels for MS and BTS */ |
| 219 | uint8_t bs_power; |
| 220 | uint8_t ms_power; |
| 221 | /* Encryption information */ |
| 222 | struct { |
| 223 | uint8_t alg_id; |
| 224 | uint8_t key_len; |
| 225 | uint8_t key[MAX_A5_KEY_LEN]; |
| 226 | } encr; |
| 227 | |
| 228 | /* AMR bits */ |
Andreas Eversberg | 7326652 | 2014-01-19 11:47:44 +0100 | [diff] [blame] | 229 | uint8_t mr_ms_lv[7]; |
| 230 | uint8_t mr_bts_lv[7]; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 231 | |
| 232 | /* Established data link layer services */ |
| 233 | uint8_t sapis[8]; |
Holger Hans Peter Freyther | b9b828b | 2013-01-01 19:20:28 +0100 | [diff] [blame] | 234 | int sacch_deact; |
Holger Hans Peter Freyther | dfcfe65 | 2011-12-27 20:49:53 +0100 | [diff] [blame] | 235 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 236 | 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 Welte | 135a6bd | 2011-09-04 13:53:26 +0200 | [diff] [blame] | 245 | #ifdef ROLE_BSC |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 246 | struct rtp_socket *rtp_socket; |
Harald Welte | 135a6bd | 2011-09-04 13:53:26 +0200 | [diff] [blame] | 247 | #else |
| 248 | struct osmo_rtp_socket *rtp_socket; |
| 249 | #endif |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 250 | } abis_ip; |
| 251 | |
Harald Welte | 2c1ae47 | 2011-06-26 14:13:37 +0200 | [diff] [blame] | 252 | uint8_t rqd_ta; |
| 253 | |
Harald Welte | c696cc2 | 2015-12-05 16:19:21 +0100 | [diff] [blame] | 254 | char *name; |
| 255 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 256 | #ifdef ROLE_BSC |
| 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 | f6093a4 | 2011-06-25 10:02:33 +0200 | [diff] [blame] | 284 | #else |
Daniel Willmann | 324c805 | 2012-12-29 12:32:30 +0100 | [diff] [blame] | 285 | /* 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 Freyther | 30156e1 | 2013-04-05 18:41:45 +0200 | [diff] [blame] | 287 | struct llist_head sapi_cmds; |
Daniel Willmann | 324c805 | 2012-12-29 12:32:30 +0100 | [diff] [blame] | 288 | uint8_t sapis_dl[23]; |
| 289 | uint8_t sapis_ul[23]; |
Harald Welte | f6093a4 | 2011-06-25 10:02:33 +0200 | [diff] [blame] | 290 | struct lapdm_channel lapdm_ch; |
Harald Welte | 135a6bd | 2011-09-04 13:53:26 +0200 | [diff] [blame] | 291 | struct llist_head dl_tch_queue; |
Harald Welte | 2c1ae47 | 2011-06-26 14:13:37 +0200 | [diff] [blame] | 292 | 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 Welte | c7921c9 | 2011-06-29 10:38:34 +0200 | [diff] [blame] | 299 | 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 Welte | 7ff4f0e | 2013-03-07 18:38:09 +0000 | [diff] [blame] | 310 | struct gsm_meas_rep_unidir ul_res; |
Harald Welte | c7921c9 | 2011-06-29 10:38:34 +0200 | [diff] [blame] | 311 | } meas; |
Harald Welte | f3b5932 | 2011-09-06 22:14:43 +0200 | [diff] [blame] | 312 | struct { |
| 313 | struct amr_multirate_conf amr_mr; |
Harald Welte | 4329099 | 2011-09-07 12:41:38 +0200 | [diff] [blame] | 314 | struct { |
Max | 1e646f0 | 2016-10-05 17:29:02 +0200 | [diff] [blame] | 315 | struct osmo_fsm_inst *dl_amr_fsm; |
Max | 1b76a03 | 2016-10-25 20:22:16 +0200 | [diff] [blame] | 316 | /* TCH cache */ |
Max | 1e646f0 | 2016-10-05 17:29:02 +0200 | [diff] [blame] | 317 | uint8_t cache[20]; |
Max | 1b76a03 | 2016-10-25 20:22:16 +0200 | [diff] [blame] | 318 | /* FACCH cache */ |
| 319 | uint8_t facch[GSM_MACBLOCK_LEN]; |
Harald Welte | 4329099 | 2011-09-07 12:41:38 +0200 | [diff] [blame] | 320 | uint8_t len; |
Max | f5fe31d | 2016-06-10 14:09:07 +0200 | [diff] [blame] | 321 | uint32_t fn; |
| 322 | bool is_update; |
Max | 1e646f0 | 2016-10-05 17:29:02 +0200 | [diff] [blame] | 323 | /* 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 Freyther | 922ef5d | 2014-07-24 21:05:32 +0200 | [diff] [blame] | 330 | uint8_t last_cmr; |
Max | d7df7ae | 2016-06-03 12:06:26 +0200 | [diff] [blame] | 331 | uint32_t last_fn; |
Harald Welte | f3b5932 | 2011-09-06 22:14:43 +0200 | [diff] [blame] | 332 | } tch; |
Harald Welte | 5d52c97 | 2012-04-08 20:23:28 +0200 | [diff] [blame] | 333 | /* BTS-side ciphering state (rx only, bi-directional, ...) */ |
| 334 | uint8_t ciph_state; |
Holger Hans Peter Freyther | 2c6b59c | 2014-08-09 09:43:53 +0200 | [diff] [blame] | 335 | uint8_t ciph_ns; |
Harald Welte | 46cb851 | 2012-04-19 23:13:35 +0200 | [diff] [blame] | 336 | uint8_t loopback; |
Harald Welte | 704cb86 | 2012-06-16 14:57:08 +0800 | [diff] [blame] | 337 | struct { |
| 338 | uint8_t active; |
| 339 | uint8_t ref; |
| 340 | /* T3105: PHYS INF retransmission */ |
| 341 | struct osmo_timer_list t3105; |
| 342 | /* counts up to Ny1 */ |
| 343 | unsigned int phys_info_count; |
| 344 | } ho; |
Andreas Eversberg | 1af682a | 2013-02-20 16:06:20 +0100 | [diff] [blame] | 345 | /* S counter for link loss */ |
| 346 | int s; |
Holger Hans Peter Freyther | fc7a75f | 2013-10-25 18:58:30 +0200 | [diff] [blame] | 347 | /* Kind of the release/activation. E.g. RSL or PCU */ |
| 348 | int rel_act_kind; |
Max | ec74465 | 2016-05-18 16:42:16 +0200 | [diff] [blame] | 349 | /* RTP header Marker bit to indicate beginning of speech after pause */ |
| 350 | bool rtp_tx_marker; |
Holger Hans Peter Freyther | f6f86b0 | 2015-02-05 22:25:03 +0100 | [diff] [blame] | 351 | /* power handling */ |
| 352 | struct { |
| 353 | uint8_t current; |
| 354 | uint8_t fixed; |
| 355 | } ms_power_ctrl; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 356 | #endif |
| 357 | }; |
| 358 | |
Neels Hofmeyr | 2ebacce | 2016-06-14 14:08:35 +0200 | [diff] [blame] | 359 | enum { |
| 360 | TS_F_PDCH_ACTIVE = 0x1000, |
| 361 | TS_F_PDCH_ACT_PENDING = 0x2000, |
| 362 | TS_F_PDCH_DEACT_PENDING = 0x4000, |
| 363 | TS_F_PDCH_PENDING_MASK = 0x6000 /*< |
| 364 | TS_F_PDCH_ACT_PENDING | TS_F_PDCH_DEACT_PENDING */ |
| 365 | } gsm_bts_trx_ts_flags; |
| 366 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 367 | /* One Timeslot in a TRX */ |
| 368 | struct gsm_bts_trx_ts { |
| 369 | struct gsm_bts_trx *trx; |
| 370 | /* number of this timeslot at the TRX */ |
| 371 | uint8_t nr; |
| 372 | |
| 373 | enum gsm_phys_chan_config pchan; |
| 374 | |
Neels Hofmeyr | c165876 | 2016-07-23 16:14:06 +0200 | [diff] [blame] | 375 | struct { |
| 376 | enum gsm_phys_chan_config pchan_is; |
| 377 | enum gsm_phys_chan_config pchan_want; |
| 378 | struct msgb *pending_chan_activ; |
| 379 | } dyn; |
| 380 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 381 | unsigned int flags; |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 382 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 383 | struct tlv_parsed nm_attr; |
| 384 | uint8_t nm_chan_comb; |
Harald Welte | 135a648 | 2011-05-30 12:09:13 +0200 | [diff] [blame] | 385 | int tsc; /* -1 == use BTS TSC */ |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 386 | |
| 387 | struct { |
| 388 | /* Parameters below are configured by VTY */ |
| 389 | int enabled; |
| 390 | uint8_t maio; |
| 391 | uint8_t hsn; |
| 392 | struct bitvec arfcns; |
| 393 | uint8_t arfcns_data[1024/8]; |
| 394 | /* This is the pre-computed MA for channel assignments */ |
| 395 | struct bitvec ma; |
| 396 | uint8_t ma_len; /* part of ma_data that is used */ |
| 397 | uint8_t ma_data[8]; /* 10.5.2.21: max 8 bytes value part */ |
| 398 | } hopping; |
| 399 | |
| 400 | /* To which E1 subslot are we connected */ |
| 401 | struct gsm_e1_subslot e1_link; |
| 402 | |
Harald Welte | 591e1d7 | 2016-07-09 22:20:57 +0200 | [diff] [blame^] | 403 | union { |
| 404 | struct { |
| 405 | struct om2k_mo om2k_mo; |
| 406 | } rbs2000; |
| 407 | }; |
| 408 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 409 | struct gsm_lchan lchan[TS_MAX_LCHAN]; |
| 410 | }; |
| 411 | |
| 412 | /* One TRX in a BTS */ |
| 413 | struct gsm_bts_trx { |
| 414 | /* list header in bts->trx_list */ |
| 415 | struct llist_head list; |
| 416 | |
| 417 | struct gsm_bts *bts; |
| 418 | /* number of this TRX in the BTS */ |
| 419 | uint8_t nr; |
| 420 | /* human readable name / description */ |
| 421 | char *description; |
| 422 | /* how do we talk RSL with this TRX? */ |
| 423 | struct gsm_e1_subslot rsl_e1_link; |
| 424 | uint8_t rsl_tei; |
| 425 | struct e1inp_sign_link *rsl_link; |
Holger Hans Peter Freyther | caa98d5 | 2013-10-06 15:52:14 +0200 | [diff] [blame] | 426 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 427 | /* Some BTS (specifically Ericsson RBS) have a per-TRX OML Link */ |
| 428 | struct e1inp_sign_link *oml_link; |
| 429 | |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 430 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 431 | struct tlv_parsed nm_attr; |
| 432 | struct { |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 433 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 434 | } bb_transc; |
| 435 | |
| 436 | uint16_t arfcn; |
| 437 | int nominal_power; /* in dBm */ |
| 438 | unsigned int max_power_red; /* in actual dB */ |
Holger Hans Peter Freyther | 9b62580 | 2014-07-30 18:20:51 +0200 | [diff] [blame] | 439 | |
| 440 | #ifndef ROLE_BSC |
Harald Welte | 101c5c2 | 2014-08-22 16:12:03 +0200 | [diff] [blame] | 441 | struct trx_power_params power_params; |
Holger Hans Peter Freyther | f6f86b0 | 2015-02-05 22:25:03 +0100 | [diff] [blame] | 442 | int ms_power_control; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 443 | |
Harald Welte | d134cc7 | 2011-06-07 00:12:53 +0200 | [diff] [blame] | 444 | struct { |
| 445 | void *l1h; |
| 446 | } role_bts; |
Holger Hans Peter Freyther | 9b62580 | 2014-07-30 18:20:51 +0200 | [diff] [blame] | 447 | #endif |
Harald Welte | d134cc7 | 2011-06-07 00:12:53 +0200 | [diff] [blame] | 448 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 449 | union { |
| 450 | struct { |
| 451 | struct { |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 452 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 453 | } bbsig; |
| 454 | struct { |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 455 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 456 | } pa; |
| 457 | } bs11; |
| 458 | struct { |
| 459 | unsigned int test_state; |
| 460 | uint8_t test_nr; |
| 461 | struct rxlev_stats rxlev_stat; |
| 462 | } ipaccess; |
Harald Welte | 591e1d7 | 2016-07-09 22:20:57 +0200 | [diff] [blame^] | 463 | struct { |
| 464 | struct { |
| 465 | struct om2k_mo om2k_mo; |
| 466 | } trxc; |
| 467 | struct { |
| 468 | struct om2k_mo om2k_mo; |
| 469 | } rx; |
| 470 | struct { |
| 471 | struct om2k_mo om2k_mo; |
| 472 | } tx; |
| 473 | } rbs2000; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 474 | }; |
| 475 | struct gsm_bts_trx_ts ts[TRX_NR_TS]; |
| 476 | }; |
| 477 | |
| 478 | #define GSM_BTS_SI(bts, i) (void *)(bts->si_buf[i]) |
| 479 | |
| 480 | enum gsm_bts_type { |
| 481 | GSM_BTS_TYPE_UNKNOWN, |
| 482 | GSM_BTS_TYPE_BS11, |
| 483 | GSM_BTS_TYPE_NANOBTS, |
| 484 | GSM_BTS_TYPE_RBS2000, |
Dieter Spaar | 1664602 | 2011-07-28 00:01:50 +0200 | [diff] [blame] | 485 | GSM_BTS_TYPE_NOKIA_SITE, |
Harald Welte | f383aa1 | 2012-07-02 19:51:55 +0200 | [diff] [blame] | 486 | GSM_BTS_TYPE_OSMO_SYSMO, |
Harald Welte | e555c2b | 2012-08-17 13:02:12 +0200 | [diff] [blame] | 487 | _NUM_GSM_BTS_TYPE |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 488 | }; |
| 489 | |
| 490 | struct vty; |
| 491 | |
| 492 | struct gsm_bts_model { |
| 493 | struct llist_head list; |
| 494 | |
| 495 | enum gsm_bts_type type; |
| 496 | const char *name; |
| 497 | |
| 498 | bool started; |
| 499 | int (*start)(struct gsm_network *net); |
| 500 | int (*oml_rcvmsg)(struct msgb *msg); |
| 501 | |
Pablo Neira Ayuso | ed5cacb | 2011-08-17 22:44:07 +0200 | [diff] [blame] | 502 | void (*e1line_bind_ops)(struct e1inp_line *line); |
| 503 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 504 | void (*config_write_bts)(struct vty *vty, struct gsm_bts *bts); |
| 505 | void (*config_write_trx)(struct vty *vty, struct gsm_bts_trx *trx); |
| 506 | void (*config_write_ts)(struct vty *vty, struct gsm_bts_trx_ts *ts); |
| 507 | |
| 508 | struct tlv_definition nm_att_tlvdef; |
| 509 | |
| 510 | struct bitvec features; |
| 511 | uint8_t _features_data[128/8]; |
| 512 | }; |
| 513 | |
| 514 | enum gsm_bts_features { |
| 515 | BTS_FEAT_HSCSD, |
| 516 | BTS_FEAT_GPRS, |
| 517 | BTS_FEAT_EGPRS, |
| 518 | BTS_FEAT_ECSD, |
| 519 | BTS_FEAT_HOPPING, |
Harald Welte | 903aaea | 2014-01-19 17:10:50 +0100 | [diff] [blame] | 520 | BTS_FEAT_MULTI_TSC, |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 521 | }; |
| 522 | |
| 523 | /* |
| 524 | * This keeps track of the paging status of one BTS. It |
| 525 | * includes a number of pending requests, a back pointer |
| 526 | * to the gsm_bts, a timer and some more state. |
| 527 | */ |
| 528 | struct gsm_bts_paging_state { |
| 529 | /* pending requests */ |
| 530 | struct llist_head pending_requests; |
| 531 | struct gsm_bts *bts; |
| 532 | |
| 533 | struct osmo_timer_list work_timer; |
| 534 | struct osmo_timer_list credit_timer; |
| 535 | |
| 536 | /* free chans needed */ |
| 537 | int free_chans_need; |
| 538 | |
| 539 | /* load */ |
| 540 | uint16_t available_slots; |
| 541 | }; |
| 542 | |
| 543 | struct gsm_envabtse { |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 544 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 545 | }; |
| 546 | |
| 547 | struct gsm_bts_gprs_nsvc { |
| 548 | struct gsm_bts *bts; |
| 549 | /* data read via VTY config file, to configure the BTS |
| 550 | * via OML from BSC */ |
| 551 | int id; |
| 552 | uint16_t nsvci; |
| 553 | uint16_t local_port; /* on the BTS */ |
| 554 | uint16_t remote_port; /* on the SGSN */ |
| 555 | uint32_t remote_ip; /* on the SGSN */ |
| 556 | |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 557 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 558 | }; |
| 559 | |
Harald Welte | 019f913 | 2012-06-28 08:43:14 +0200 | [diff] [blame] | 560 | enum gprs_rlc_par { |
| 561 | RLC_T3142, |
| 562 | RLC_T3169, |
| 563 | RLC_T3191, |
| 564 | RLC_T3193, |
| 565 | RLC_T3195, |
| 566 | RLC_N3101, |
| 567 | RLC_N3103, |
| 568 | RLC_N3105, |
| 569 | CV_COUNTDOWN, |
| 570 | T_DL_TBF_EXT, /* ms */ |
| 571 | T_UL_TBF_EXT, /* ms */ |
| 572 | _NUM_RLC_PAR |
| 573 | }; |
| 574 | |
| 575 | enum gprs_cs { |
| 576 | GPRS_CS1, |
| 577 | GPRS_CS2, |
| 578 | GPRS_CS3, |
| 579 | GPRS_CS4, |
| 580 | GPRS_MCS1, |
| 581 | GPRS_MCS2, |
| 582 | GPRS_MCS3, |
| 583 | GPRS_MCS4, |
| 584 | GPRS_MCS5, |
| 585 | GPRS_MCS6, |
| 586 | GPRS_MCS7, |
| 587 | GPRS_MCS8, |
| 588 | GPRS_MCS9, |
| 589 | _NUM_GRPS_CS |
| 590 | }; |
| 591 | |
| 592 | struct gprs_rlc_cfg { |
| 593 | uint16_t parameter[_NUM_RLC_PAR]; |
| 594 | struct { |
| 595 | uint16_t repeat_time; /* ms */ |
| 596 | uint8_t repeat_count; |
| 597 | } paging; |
| 598 | uint32_t cs_mask; /* bitmask of gprs_cs */ |
| 599 | uint8_t initial_cs; |
| 600 | uint8_t initial_mcs; |
| 601 | }; |
| 602 | |
| 603 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 604 | enum neigh_list_manual_mode { |
| 605 | NL_MODE_AUTOMATIC = 0, |
| 606 | NL_MODE_MANUAL = 1, |
| 607 | NL_MODE_MANUAL_SI5SEP = 2, /* SI2 and SI5 have separate neighbor lists */ |
| 608 | }; |
| 609 | |
Daniel Willmann | 47b5b3e | 2011-08-05 13:51:27 +0200 | [diff] [blame] | 610 | enum bts_loc_fix { |
| 611 | BTS_LOC_FIX_INVALID = 0, |
| 612 | BTS_LOC_FIX_2D = 1, |
| 613 | BTS_LOC_FIX_3D = 2, |
| 614 | }; |
| 615 | |
Daniel Willmann | 7d10983 | 2012-05-14 18:43:23 +0200 | [diff] [blame] | 616 | extern const struct value_string bts_loc_fix_names[]; |
| 617 | |
Daniel Willmann | 47b5b3e | 2011-08-05 13:51:27 +0200 | [diff] [blame] | 618 | struct bts_location { |
| 619 | struct llist_head list; |
| 620 | time_t tstamp; |
| 621 | enum bts_loc_fix valid; |
| 622 | double lat; |
| 623 | double lon; |
| 624 | double height; |
| 625 | }; |
| 626 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 627 | /* One BTS */ |
| 628 | struct gsm_bts { |
| 629 | /* list header in net->bts_list */ |
| 630 | struct llist_head list; |
| 631 | |
Daniel Willmann | 47b5b3e | 2011-08-05 13:51:27 +0200 | [diff] [blame] | 632 | /* Geographical location of the BTS */ |
| 633 | struct llist_head loc_list; |
| 634 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 635 | /* number of ths BTS in network */ |
| 636 | uint8_t nr; |
| 637 | /* human readable name / description */ |
| 638 | char *description; |
| 639 | /* Cell Identity */ |
| 640 | uint16_t cell_identity; |
| 641 | /* location area code of this BTS */ |
| 642 | uint16_t location_area_code; |
Harald Welte | a2bbc5e | 2015-11-20 10:43:31 +0100 | [diff] [blame] | 643 | /* Base Station Identification Code (BSIC), lower 3 bits is BCC, |
| 644 | * which is used as TSC for the CCCH */ |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 645 | uint8_t bsic; |
| 646 | /* type of BTS */ |
| 647 | enum gsm_bts_type type; |
| 648 | struct gsm_bts_model *model; |
| 649 | enum gsm_band band; |
| 650 | /* maximum Tx power that the MS is permitted to use in this cell */ |
| 651 | int ms_max_power; |
| 652 | |
| 653 | /* how do we talk OML with this TRX? */ |
| 654 | struct gsm_e1_subslot oml_e1_link; |
| 655 | uint8_t oml_tei; |
| 656 | struct e1inp_sign_link *oml_link; |
| 657 | |
| 658 | /* Abis network management O&M handle */ |
| 659 | struct abis_nm_h *nmh; |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 660 | |
| 661 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 662 | |
| 663 | /* number of this BTS on given E1 link */ |
| 664 | uint8_t bts_nr; |
| 665 | |
Max | c08ee71 | 2016-05-11 12:45:13 +0200 | [diff] [blame] | 666 | /* DTX features of this BTS */ |
| 667 | enum gsm48_dtx_mode dtxu; |
| 668 | bool dtxd; |
| 669 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 670 | /* paging state and control */ |
| 671 | struct gsm_bts_paging_state paging; |
| 672 | |
| 673 | /* CCCH is on C0 */ |
| 674 | struct gsm_bts_trx *c0; |
| 675 | |
| 676 | struct { |
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 | } site_mgr; |
| 679 | |
| 680 | /* bitmask of all SI that are present/valid in si_buf */ |
| 681 | uint32_t si_valid; |
| 682 | /* buffers where we put the pre-computed SI */ |
| 683 | sysinfo_buf_t si_buf[_MAX_SYSINFO_TYPE]; |
| 684 | |
Gus Bourg | 1c5dd2c | 2011-12-02 10:18:17 +0100 | [diff] [blame] | 685 | /* TimeZone hours, mins, and bts specific */ |
Harald Welte | 45f9171 | 2012-07-08 16:48:11 +0200 | [diff] [blame] | 686 | struct { |
| 687 | int hr; |
| 688 | int mn; |
| 689 | int override; |
Jacob Erlbeck | 946d141 | 2013-09-17 13:59:29 +0200 | [diff] [blame] | 690 | int dst; |
Harald Welte | 45f9171 | 2012-07-08 16:48:11 +0200 | [diff] [blame] | 691 | } tz; |
Gus Bourg | 1c5dd2c | 2011-12-02 10:18:17 +0100 | [diff] [blame] | 692 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 693 | /* ip.accesss Unit ID's have Site/BTS/TRX layout */ |
| 694 | union { |
| 695 | struct { |
| 696 | uint16_t site_id; |
| 697 | uint16_t bts_id; |
| 698 | uint32_t flags; |
Harald Welte | 8b29180 | 2013-03-12 13:57:05 +0100 | [diff] [blame] | 699 | uint32_t rsl_ip; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 700 | } ip_access; |
| 701 | struct { |
| 702 | struct { |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 703 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 704 | } cclk; |
| 705 | struct { |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 706 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 707 | } rack; |
| 708 | struct gsm_envabtse envabtse[4]; |
| 709 | } bs11; |
| 710 | struct { |
| 711 | struct { |
Harald Welte | 591e1d7 | 2016-07-09 22:20:57 +0200 | [diff] [blame^] | 712 | struct om2k_mo om2k_mo; |
| 713 | struct gsm_abis_mo mo; |
| 714 | struct llist_head conn_groups; |
| 715 | } cf; |
| 716 | struct { |
| 717 | struct om2k_mo om2k_mo; |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 718 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 719 | struct llist_head conn_groups; |
| 720 | } is; |
| 721 | struct { |
Harald Welte | 591e1d7 | 2016-07-09 22:20:57 +0200 | [diff] [blame^] | 722 | struct om2k_mo om2k_mo; |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 723 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 724 | struct llist_head conn_groups; |
| 725 | } con; |
| 726 | struct { |
Harald Welte | 591e1d7 | 2016-07-09 22:20:57 +0200 | [diff] [blame^] | 727 | struct om2k_mo om2k_mo; |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 728 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 729 | } dp; |
| 730 | struct { |
Harald Welte | 591e1d7 | 2016-07-09 22:20:57 +0200 | [diff] [blame^] | 731 | struct om2k_mo om2k_mo; |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 732 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 733 | } tf; |
| 734 | } rbs2000; |
| 735 | struct { |
Harald Welte | c8755af | 2011-07-28 00:22:17 +0200 | [diff] [blame] | 736 | uint8_t bts_type; |
Holger Hans Peter Freyther | 3e60348 | 2012-03-02 14:14:33 +0100 | [diff] [blame] | 737 | unsigned int configured:1, |
| 738 | skip_reset:1, |
Andreas Eversberg | 7d8fa34 | 2013-12-05 13:25:06 +0100 | [diff] [blame] | 739 | no_loc_rel_cnf:1, |
Sipos Csaba | 56e1766 | 2015-02-07 13:27:36 +0100 | [diff] [blame] | 740 | bts_reset_timer_cnf, |
Holger Hans Peter Freyther | 3e60348 | 2012-03-02 14:14:33 +0100 | [diff] [blame] | 741 | did_reset:1, |
| 742 | wait_reset:1; |
Harald Welte | c8755af | 2011-07-28 00:22:17 +0200 | [diff] [blame] | 743 | struct osmo_timer_list reset_timer; |
| 744 | } nokia; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 745 | }; |
| 746 | |
| 747 | /* Not entirely sure how ip.access specific this is */ |
| 748 | struct { |
bhargava | 350533c | 2016-07-21 11:14:34 +0530 | [diff] [blame] | 749 | uint8_t supports_egprs_11bit_rach; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 750 | enum bts_gprs_mode mode; |
| 751 | struct { |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 752 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 753 | uint16_t nsei; |
| 754 | uint8_t timer[7]; |
| 755 | } nse; |
| 756 | struct { |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 757 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 758 | uint16_t bvci; |
| 759 | uint8_t timer[11]; |
Harald Welte | 019f913 | 2012-06-28 08:43:14 +0200 | [diff] [blame] | 760 | struct gprs_rlc_cfg rlc_cfg; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 761 | } cell; |
| 762 | struct gsm_bts_gprs_nsvc nsvc[2]; |
| 763 | uint8_t rac; |
Andreas Eversberg | 0c8f9ca | 2013-03-16 16:31:26 +0100 | [diff] [blame] | 764 | uint8_t net_ctrl_ord; |
Max | 292ec58 | 2016-07-28 11:55:37 +0200 | [diff] [blame] | 765 | bool ctrl_ack_type_use_block; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 766 | } gprs; |
| 767 | |
| 768 | /* RACH NM values */ |
| 769 | int rach_b_thresh; |
| 770 | int rach_ldavg_slots; |
| 771 | |
| 772 | /* transceivers */ |
| 773 | int num_trx; |
| 774 | struct llist_head trx_list; |
| 775 | |
Holger Hans Peter Freyther | b92a538 | 2014-11-21 10:00:39 +0100 | [diff] [blame] | 776 | /* SI related items */ |
Jacob Erlbeck | 65d114f | 2014-01-16 11:02:14 +0100 | [diff] [blame] | 777 | int force_combined_si; |
Holger Hans Peter Freyther | b92a538 | 2014-11-21 10:00:39 +0100 | [diff] [blame] | 778 | int bcch_change_mark; |
Jacob Erlbeck | 65d114f | 2014-01-16 11:02:14 +0100 | [diff] [blame] | 779 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 780 | #ifdef ROLE_BSC |
| 781 | /* Abis NM queue */ |
| 782 | struct llist_head abis_queue; |
| 783 | int abis_nm_pend; |
| 784 | |
| 785 | struct gsm_network *network; |
| 786 | |
| 787 | /* should the channel allocator allocate channels from high TRX to TRX0, |
| 788 | * rather than starting from TRX0 and go upwards? */ |
| 789 | int chan_alloc_reverse; |
| 790 | |
| 791 | enum neigh_list_manual_mode neigh_list_manual_mode; |
| 792 | /* parameters from which we build SYSTEM INFORMATION */ |
| 793 | struct { |
| 794 | struct gsm48_rach_control rach_control; |
| 795 | uint8_t ncc_permitted; |
| 796 | struct gsm48_cell_sel_par cell_sel_par; |
| 797 | struct gsm48_si_selection_params cell_ro_sel_par; /* rest octet */ |
| 798 | struct gsm48_cell_options cell_options; |
| 799 | struct gsm48_control_channel_descr chan_desc; |
| 800 | struct bitvec neigh_list; |
| 801 | struct bitvec cell_alloc; |
| 802 | struct bitvec si5_neigh_list; |
Max | 59a1bf3 | 2016-04-15 16:04:46 +0200 | [diff] [blame] | 803 | struct osmo_earfcn_si2q si2quater_neigh_list; |
Max | 26679e0 | 2016-04-20 15:57:13 +0200 | [diff] [blame] | 804 | size_t uarfcn_length; /* index for uarfcn and scramble lists */ |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 805 | struct { |
| 806 | /* bitmask large enough for all possible ARFCN's */ |
| 807 | uint8_t neigh_list[1024/8]; |
| 808 | uint8_t cell_alloc[1024/8]; |
| 809 | /* If the user wants a different neighbor list in SI5 than in SI2 */ |
| 810 | uint8_t si5_neigh_list[1024/8]; |
Max | 59a1bf3 | 2016-04-15 16:04:46 +0200 | [diff] [blame] | 811 | uint8_t meas_bw_list[MAX_EARFCN_LIST]; |
| 812 | uint16_t earfcn_list[MAX_EARFCN_LIST]; |
Max | 26679e0 | 2016-04-20 15:57:13 +0200 | [diff] [blame] | 813 | uint16_t uarfcn_list[MAX_EARFCN_LIST]; |
| 814 | uint16_t scramble_list[MAX_EARFCN_LIST]; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 815 | } data; |
| 816 | } si_common; |
| 817 | |
| 818 | /* do we use static (user-defined) system information messages? (bitmask) */ |
| 819 | uint32_t si_mode_static; |
Holger Hans Peter Freyther | e30d40d | 2012-07-20 10:27:31 +0200 | [diff] [blame] | 820 | |
| 821 | /* exclude the BTS from the global RF Lock handling */ |
| 822 | int excl_from_rf_lock; |
Andreas Eversberg | a83d511 | 2013-12-07 18:32:28 +0100 | [diff] [blame] | 823 | |
| 824 | /* supported codecs beside FR */ |
| 825 | struct bts_codec_conf codec; |
Holger Hans Peter Freyther | c22930e | 2014-12-17 14:46:17 +0100 | [diff] [blame] | 826 | |
| 827 | /* BTS dependencies bit field */ |
| 828 | uint32_t depends_on[256/(8*4)]; |
Andreas Eversberg | 7326652 | 2014-01-19 11:47:44 +0100 | [diff] [blame] | 829 | |
| 830 | /* full and half rate multirate config */ |
| 831 | struct amr_multirate_conf mr_full; |
| 832 | struct amr_multirate_conf mr_half; |
| 833 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 834 | #endif /* ROLE_BSC */ |
Harald Welte | 978714d | 2011-06-06 18:31:20 +0200 | [diff] [blame] | 835 | void *role; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 836 | }; |
| 837 | |
| 838 | |
Harald Welte | 3300c01 | 2011-06-05 13:31:33 +0200 | [diff] [blame] | 839 | struct gsm_bts *gsm_bts_alloc(void *talloc_ctx); |
Harald Welte | 1449c9f | 2014-08-24 09:50:10 +0200 | [diff] [blame] | 840 | struct gsm_bts *gsm_bts_num(struct gsm_network *net, int num); |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 841 | |
Harald Welte | 1449c9f | 2014-08-24 09:50:10 +0200 | [diff] [blame] | 842 | struct gsm_bts_trx *gsm_bts_trx_alloc(struct gsm_bts *bts); |
Harald Welte | 4f8ad53 | 2011-09-19 14:21:51 +0200 | [diff] [blame] | 843 | 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] | 844 | |
Harald Welte | 4ab9d7c | 2012-08-17 12:42:06 +0200 | [diff] [blame] | 845 | |
Neels Hofmeyr | 17a6bab | 2016-07-23 16:14:06 +0200 | [diff] [blame] | 846 | const struct value_string gsm_pchant_names[13]; |
| 847 | const struct value_string gsm_pchant_descs[13]; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 848 | const char *gsm_pchan_name(enum gsm_phys_chan_config c); |
| 849 | enum gsm_phys_chan_config gsm_pchan_parse(const char *name); |
| 850 | const char *gsm_lchant_name(enum gsm_chan_t c); |
| 851 | const char *gsm_chreq_name(enum gsm_chreq_reason_t c); |
Harald Welte | 4f8ad53 | 2011-09-19 14:21:51 +0200 | [diff] [blame] | 852 | char *gsm_trx_name(const struct gsm_bts_trx *trx); |
| 853 | char *gsm_ts_name(const struct gsm_bts_trx_ts *ts); |
Neels Hofmeyr | 34b8b5b | 2016-07-16 23:59:32 +0200 | [diff] [blame] | 854 | 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] | 855 | char *gsm_lchan_name_compute(const struct gsm_lchan *lchan); |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 856 | const char *gsm_lchans_name(enum gsm_lchan_state s); |
| 857 | |
Harald Welte | c696cc2 | 2015-12-05 16:19:21 +0100 | [diff] [blame] | 858 | static inline char *gsm_lchan_name(const struct gsm_lchan *lchan) |
| 859 | { |
| 860 | return lchan->name; |
| 861 | } |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 862 | |
Harald Welte | b784998 | 2011-06-29 16:49:03 +0200 | [diff] [blame] | 863 | void gsm_abis_mo_reset(struct gsm_abis_mo *mo); |
| 864 | |
Harald Welte | 978714d | 2011-06-06 18:31:20 +0200 | [diff] [blame] | 865 | struct gsm_abis_mo * |
| 866 | gsm_objclass2mo(struct gsm_bts *bts, uint8_t obj_class, |
Harald Welte | 4f8ad53 | 2011-09-19 14:21:51 +0200 | [diff] [blame] | 867 | const struct abis_om_obj_inst *obj_inst); |
Harald Welte | 978714d | 2011-06-06 18:31:20 +0200 | [diff] [blame] | 868 | |
| 869 | struct gsm_nm_state * |
| 870 | gsm_objclass2nmstate(struct gsm_bts *bts, uint8_t obj_class, |
Harald Welte | 4f8ad53 | 2011-09-19 14:21:51 +0200 | [diff] [blame] | 871 | const struct abis_om_obj_inst *obj_inst); |
Harald Welte | 978714d | 2011-06-06 18:31:20 +0200 | [diff] [blame] | 872 | void * |
| 873 | gsm_objclass2obj(struct gsm_bts *bts, uint8_t obj_class, |
Harald Welte | 4f8ad53 | 2011-09-19 14:21:51 +0200 | [diff] [blame] | 874 | const struct abis_om_obj_inst *obj_inst); |
Harald Welte | 978714d | 2011-06-06 18:31:20 +0200 | [diff] [blame] | 875 | |
Harald Welte | b784998 | 2011-06-29 16:49:03 +0200 | [diff] [blame] | 876 | /* reset the state of all MO in the BTS */ |
| 877 | void gsm_bts_mo_reset(struct gsm_bts *bts); |
| 878 | |
Neels Hofmeyr | d384110 | 2016-07-18 23:43:44 +0200 | [diff] [blame] | 879 | uint8_t gsm_pchan2chan_nr(enum gsm_phys_chan_config pchan, |
| 880 | uint8_t ts_nr, uint8_t lchan_nr); |
Harald Welte | f6093a4 | 2011-06-25 10:02:33 +0200 | [diff] [blame] | 881 | uint8_t gsm_lchan2chan_nr(const struct gsm_lchan *lchan); |
Neels Hofmeyr | d384110 | 2016-07-18 23:43:44 +0200 | [diff] [blame] | 882 | uint8_t gsm_lchan_as_pchan2chan_nr(const struct gsm_lchan *lchan, |
| 883 | enum gsm_phys_chan_config as_pchan); |
Harald Welte | f6093a4 | 2011-06-25 10:02:33 +0200 | [diff] [blame] | 884 | |
Harald Welte | 142d12d | 2014-12-29 17:47:08 +0100 | [diff] [blame] | 885 | /* return the gsm_lchan for the CBCH (if it exists at all) */ |
| 886 | struct gsm_lchan *gsm_bts_get_cbch(struct gsm_bts *bts); |
| 887 | |
Holger Hans Peter Freyther | 06c9da6 | 2011-06-09 21:48:49 +0200 | [diff] [blame] | 888 | /* |
| 889 | * help with parsing regexps |
| 890 | */ |
| 891 | int gsm_parse_reg(void *ctx, regex_t *reg, char **str, |
| 892 | int argc, const char **argv) __attribute__ ((warn_unused_result)); |
| 893 | |
Harald Welte | 1fe2412 | 2014-01-19 17:18:21 +0100 | [diff] [blame] | 894 | static inline uint8_t gsm_ts_tsc(const struct gsm_bts_trx_ts *ts) |
| 895 | { |
| 896 | if (ts->tsc != -1) |
| 897 | return ts->tsc; |
| 898 | else |
Harald Welte | a2bbc5e | 2015-11-20 10:43:31 +0100 | [diff] [blame] | 899 | return ts->trx->bts->bsic & 7; |
Harald Welte | 1fe2412 | 2014-01-19 17:18:21 +0100 | [diff] [blame] | 900 | } |
Holger Hans Peter Freyther | 06c9da6 | 2011-06-09 21:48:49 +0200 | [diff] [blame] | 901 | |
Neels Hofmeyr | 7458572 | 2016-07-23 17:38:22 +0200 | [diff] [blame] | 902 | struct gsm_lchan *rsl_lchan_lookup(struct gsm_bts_trx *trx, uint8_t chan_nr, |
| 903 | int *rc); |
Holger Hans Peter Freyther | 06c9da6 | 2011-06-09 21:48:49 +0200 | [diff] [blame] | 904 | |
Neels Hofmeyr | 76a0ad7 | 2016-07-29 18:12:06 +0200 | [diff] [blame] | 905 | uint8_t ts_subslots(struct gsm_bts_trx_ts *ts); |
Neels Hofmeyr | 255dbfe | 2016-09-25 15:07:01 +0200 | [diff] [blame] | 906 | bool ts_is_tch(struct gsm_bts_trx_ts *ts); |
Neels Hofmeyr | 76a0ad7 | 2016-07-29 18:12:06 +0200 | [diff] [blame] | 907 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 908 | #endif |