Holger Hans Peter Freyther | 8b457fb | 2009-08-17 06:55:10 +0200 | [diff] [blame] | 1 | /* A hackish minimal BSC (+MSC +HLR) implementation */ |
| 2 | |
Harald Welte | dcccb18 | 2010-05-16 20:52:23 +0200 | [diff] [blame] | 3 | /* (C) 2008-2010 by Harald Welte <laforge@gnumonks.org> |
Holger Hans Peter Freyther | 8b457fb | 2009-08-17 06:55:10 +0200 | [diff] [blame] | 4 | * (C) 2009 by Holger Hans Peter Freyther <zecke@selfish.org> |
| 5 | * All Rights Reserved |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License along |
| 18 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 20 | * |
| 21 | */ |
| 22 | |
| 23 | #include <openbsc/gsm_data.h> |
Harald Welte | dfe6c7d | 2010-02-20 16:24:02 +0100 | [diff] [blame] | 24 | #include <osmocore/gsm_utils.h> |
Holger Hans Peter Freyther | 8b457fb | 2009-08-17 06:55:10 +0200 | [diff] [blame] | 25 | #include <openbsc/gsm_04_08.h> |
| 26 | #include <openbsc/abis_rsl.h> |
| 27 | #include <openbsc/abis_nm.h> |
| 28 | #include <openbsc/debug.h> |
| 29 | #include <openbsc/misdn.h> |
| 30 | #include <openbsc/telnet_interface.h> |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 31 | #include <openbsc/system_information.h> |
Holger Hans Peter Freyther | 8b457fb | 2009-08-17 06:55:10 +0200 | [diff] [blame] | 32 | #include <openbsc/paging.h> |
| 33 | #include <openbsc/signal.h> |
Holger Hans Peter Freyther | 135f797 | 2010-04-15 11:21:02 +0200 | [diff] [blame] | 34 | #include <openbsc/chan_alloc.h> |
Harald Welte | dfe6c7d | 2010-02-20 16:24:02 +0100 | [diff] [blame] | 35 | #include <osmocore/talloc.h> |
Holger Hans Peter Freyther | 8b457fb | 2009-08-17 06:55:10 +0200 | [diff] [blame] | 36 | |
| 37 | /* global pointer to the gsm network data structure */ |
| 38 | extern struct gsm_network *bsc_gsmnet; |
Holger Hans Peter Freyther | 8b457fb | 2009-08-17 06:55:10 +0200 | [diff] [blame] | 39 | |
| 40 | static void patch_nm_tables(struct gsm_bts *bts); |
Holger Hans Peter Freyther | 8b457fb | 2009-08-17 06:55:10 +0200 | [diff] [blame] | 41 | |
| 42 | /* The following definitions are for OM and NM packets that we cannot yet |
| 43 | * generate by code but we just pass on */ |
| 44 | |
| 45 | // BTS Site Manager, SET ATTRIBUTES |
| 46 | |
| 47 | /* |
| 48 | Object Class: BTS Site Manager |
| 49 | Instance 1: FF |
| 50 | Instance 2: FF |
| 51 | Instance 3: FF |
| 52 | SET ATTRIBUTES |
| 53 | sAbisExternalTime: 2007/09/08 14:36:11 |
| 54 | omLAPDRelTimer: 30sec |
| 55 | shortLAPDIntTimer: 5sec |
| 56 | emergencyTimer1: 10 minutes |
| 57 | emergencyTimer2: 0 minutes |
| 58 | */ |
| 59 | |
| 60 | unsigned char msg_1[] = |
| 61 | { |
| 62 | NM_MT_BS11_SET_ATTR, NM_OC_SITE_MANAGER, 0xFF, 0xFF, 0xFF, |
| 63 | NM_ATT_BS11_ABIS_EXT_TIME, 0x07, |
| 64 | 0xD7, 0x09, 0x08, 0x0E, 0x24, 0x0B, 0xCE, |
| 65 | 0x02, |
| 66 | 0x00, 0x1E, |
| 67 | NM_ATT_BS11_SH_LAPD_INT_TIMER, |
| 68 | 0x01, 0x05, |
| 69 | 0x42, 0x02, 0x00, 0x0A, |
| 70 | 0x44, 0x02, 0x00, 0x00 |
| 71 | }; |
| 72 | |
| 73 | // BTS, SET BTS ATTRIBUTES |
| 74 | |
| 75 | /* |
| 76 | Object Class: BTS |
| 77 | BTS relat. Number: 0 |
| 78 | Instance 2: FF |
| 79 | Instance 3: FF |
| 80 | SET BTS ATTRIBUTES |
| 81 | bsIdentityCode / BSIC: |
| 82 | PLMN_colour_code: 7h |
| 83 | BS_colour_code: 7h |
| 84 | BTS Air Timer T3105: 4 ,unit 10 ms |
| 85 | btsIsHopping: FALSE |
| 86 | periodCCCHLoadIndication: 1sec |
| 87 | thresholdCCCHLoadIndication: 0% |
| 88 | cellAllocationNumber: 00h = GSM 900 |
| 89 | enableInterferenceClass: 00h = Disabled |
| 90 | fACCHQual: 6 (FACCH stealing flags minus 1) |
| 91 | intaveParameter: 31 SACCH multiframes |
| 92 | interferenceLevelBoundaries: |
| 93 | Interference Boundary 1: 0Ah |
| 94 | Interference Boundary 2: 0Fh |
| 95 | Interference Boundary 3: 14h |
| 96 | Interference Boundary 4: 19h |
| 97 | Interference Boundary 5: 1Eh |
| 98 | mSTxPwrMax: 11 |
| 99 | GSM range: 2=39dBm, 15=13dBm, stepsize 2 dBm |
| 100 | DCS1800 range: 0=30dBm, 15=0dBm, stepsize 2 dBm |
| 101 | PCS1900 range: 0=30dBm, 15=0dBm, stepsize 2 dBm |
| 102 | 30=33dBm, 31=32dBm |
| 103 | ny1: |
| 104 | Maximum number of repetitions for PHYSICAL INFORMATION message (GSM 04.08): 20 |
| 105 | powerOutputThresholds: |
| 106 | Out Power Fault Threshold: -10 dB |
| 107 | Red Out Power Threshold: - 6 dB |
| 108 | Excessive Out Power Threshold: 5 dB |
| 109 | rACHBusyThreshold: -127 dBm |
| 110 | rACHLoadAveragingSlots: 250 ,number of RACH burst periods |
| 111 | rfResourceIndicationPeriod: 125 SACCH multiframes |
| 112 | T200: |
| 113 | SDCCH: 044 in 5 ms |
| 114 | FACCH/Full rate: 031 in 5 ms |
| 115 | FACCH/Half rate: 041 in 5 ms |
| 116 | SACCH with TCH SAPI0: 090 in 10 ms |
| 117 | SACCH with SDCCH: 090 in 10 ms |
| 118 | SDCCH with SAPI3: 090 in 5 ms |
| 119 | SACCH with TCH SAPI3: 135 in 10 ms |
| 120 | tSync: 9000 units of 10 msec |
| 121 | tTrau: 9000 units of 10 msec |
| 122 | enableUmLoopTest: 00h = disabled |
| 123 | enableExcessiveDistance: 00h = Disabled |
| 124 | excessiveDistance: 64km |
| 125 | hoppingMode: 00h = baseband hopping |
| 126 | cellType: 00h = Standard Cell |
| 127 | BCCH ARFCN / bCCHFrequency: 1 |
| 128 | */ |
| 129 | |
| 130 | static unsigned char bs11_attr_bts[] = |
| 131 | { |
| 132 | NM_ATT_BSIC, HARDCODED_BSIC, |
| 133 | NM_ATT_BTS_AIR_TIMER, 0x04, |
| 134 | NM_ATT_BS11_BTSLS_HOPPING, 0x00, |
| 135 | NM_ATT_CCCH_L_I_P, 0x01, |
| 136 | NM_ATT_CCCH_L_T, 0x00, |
| 137 | NM_ATT_BS11_CELL_ALLOC_NR, NM_BS11_CANR_GSM, |
| 138 | NM_ATT_BS11_ENA_INTERF_CLASS, 0x01, |
| 139 | NM_ATT_BS11_FACCH_QUAL, 0x06, |
| 140 | /* interference avg. period in numbers of SACCH multifr */ |
| 141 | NM_ATT_INTAVE_PARAM, 0x1F, |
| 142 | NM_ATT_INTERF_BOUND, 0x0A, 0x0F, 0x14, 0x19, 0x1E, 0x7B, |
| 143 | NM_ATT_CCCH_L_T, 0x23, |
| 144 | NM_ATT_GSM_TIME, 0x28, 0x00, |
| 145 | NM_ATT_ADM_STATE, 0x03, |
| 146 | NM_ATT_RACH_B_THRESH, 0x7F, |
| 147 | NM_ATT_LDAVG_SLOTS, 0x00, 0xFA, |
| 148 | NM_ATT_BS11_RF_RES_IND_PER, 0x7D, |
| 149 | NM_ATT_T200, 0x2C, 0x1F, 0x29, 0x5A, 0x5A, 0x5A, 0x87, |
| 150 | NM_ATT_BS11_TSYNC, 0x23, 0x28, |
| 151 | NM_ATT_BS11_TTRAU, 0x23, 0x28, |
| 152 | NM_ATT_TEST_DUR, 0x01, 0x00, |
| 153 | NM_ATT_OUTST_ALARM, 0x01, 0x00, |
| 154 | NM_ATT_BS11_EXCESSIVE_DISTANCE, 0x01, 0x40, |
| 155 | NM_ATT_BS11_HOPPING_MODE, 0x01, 0x00, |
| 156 | NM_ATT_BS11_PLL, 0x01, 0x00, |
| 157 | NM_ATT_BCCH_ARFCN, 0x00, HARDCODED_ARFCN/*0x01*/, |
| 158 | }; |
| 159 | |
| 160 | // Handover Recognition, SET ATTRIBUTES |
| 161 | |
| 162 | /* |
| 163 | Illegal Contents GSM Formatted O&M Msg |
| 164 | Object Class: Handover Recognition |
| 165 | BTS relat. Number: 0 |
| 166 | Instance 2: FF |
| 167 | Instance 3: FF |
| 168 | SET ATTRIBUTES |
| 169 | enableDelayPowerBudgetHO: 00h = Disabled |
| 170 | enableDistanceHO: 00h = Disabled |
| 171 | enableInternalInterCellHandover: 00h = Disabled |
| 172 | enableInternalIntraCellHandover: 00h = Disabled |
| 173 | enablePowerBudgetHO: 00h = Disabled |
| 174 | enableRXLEVHO: 00h = Disabled |
| 175 | enableRXQUALHO: 00h = Disabled |
| 176 | hoAveragingDistance: 8 SACCH multiframes |
| 177 | hoAveragingLev: |
| 178 | A_LEV_HO: 8 SACCH multiframes |
| 179 | W_LEV_HO: 1 SACCH multiframes |
| 180 | hoAveragingPowerBudget: 16 SACCH multiframes |
| 181 | hoAveragingQual: |
| 182 | A_QUAL_HO: 8 SACCH multiframes |
| 183 | W_QUAL_HO: 2 SACCH multiframes |
| 184 | hoLowerThresholdLevDL: (10 - 110) dBm |
| 185 | hoLowerThresholdLevUL: (5 - 110) dBm |
| 186 | hoLowerThresholdQualDL: 06h = 6.4% < BER < 12.8% |
| 187 | hoLowerThresholdQualUL: 06h = 6.4% < BER < 12.8% |
| 188 | hoThresholdLevDLintra : (20 - 110) dBm |
| 189 | hoThresholdLevULintra: (20 - 110) dBm |
| 190 | hoThresholdMsRangeMax: 20 km |
| 191 | nCell: 06h |
| 192 | timerHORequest: 3 ,unit 2 SACCH multiframes |
| 193 | */ |
| 194 | |
| 195 | unsigned char msg_3[] = |
| 196 | { |
| 197 | NM_MT_BS11_SET_ATTR, NM_OC_BS11_HANDOVER, 0x00, 0xFF, 0xFF, |
| 198 | 0xD0, 0x00, /* enableDelayPowerBudgetHO */ |
| 199 | 0x64, 0x00, /* enableDistanceHO */ |
| 200 | 0x67, 0x00, /* enableInternalInterCellHandover */ |
| 201 | 0x68, 0x00, /* enableInternalInterCellHandover */ |
| 202 | 0x6A, 0x00, /* enablePowerBudgetHO */ |
| 203 | 0x6C, 0x00, /* enableRXLEVHO */ |
| 204 | 0x6D, 0x00, /* enableRXQUALHO */ |
| 205 | 0x6F, 0x08, /* hoAveragingDistance */ |
| 206 | 0x70, 0x08, 0x01, /* hoAveragingLev */ |
| 207 | 0x71, 0x10, 0x10, 0x10, |
| 208 | 0x72, 0x08, 0x02, /* hoAveragingQual */ |
| 209 | 0x73, 0x0A, /* hoLowerThresholdLevDL */ |
| 210 | 0x74, 0x05, /* hoLowerThresholdLevUL */ |
| 211 | 0x75, 0x06, /* hoLowerThresholdQualDL */ |
| 212 | 0x76, 0x06, /* hoLowerThresholdQualUL */ |
| 213 | 0x78, 0x14, /* hoThresholdLevDLintra */ |
| 214 | 0x79, 0x14, /* hoThresholdLevULintra */ |
| 215 | 0x7A, 0x14, /* hoThresholdMsRangeMax */ |
| 216 | 0x7D, 0x06, /* nCell */ |
| 217 | NM_ATT_BS11_TIMER_HO_REQUEST, 0x03, |
| 218 | 0x20, 0x01, 0x00, |
| 219 | 0x45, 0x01, 0x00, |
| 220 | 0x48, 0x01, 0x00, |
| 221 | 0x5A, 0x01, 0x00, |
| 222 | 0x5B, 0x01, 0x05, |
| 223 | 0x5E, 0x01, 0x1A, |
| 224 | 0x5F, 0x01, 0x20, |
| 225 | 0x9D, 0x01, 0x00, |
| 226 | 0x47, 0x01, 0x00, |
| 227 | 0x5C, 0x01, 0x64, |
| 228 | 0x5D, 0x01, 0x1E, |
| 229 | 0x97, 0x01, 0x20, |
| 230 | 0xF7, 0x01, 0x3C, |
| 231 | }; |
| 232 | |
| 233 | // Power Control, SET ATTRIBUTES |
| 234 | |
| 235 | /* |
| 236 | Object Class: Power Control |
| 237 | BTS relat. Number: 0 |
| 238 | Instance 2: FF |
| 239 | Instance 3: FF |
| 240 | SET ATTRIBUTES |
| 241 | enableMsPowerControl: 00h = Disabled |
| 242 | enablePowerControlRLFW: 00h = Disabled |
| 243 | pcAveragingLev: |
| 244 | A_LEV_PC: 4 SACCH multiframes |
| 245 | W_LEV_PC: 1 SACCH multiframes |
| 246 | pcAveragingQual: |
| 247 | A_QUAL_PC: 4 SACCH multiframes |
| 248 | W_QUAL_PC: 2 SACCH multiframes |
| 249 | pcLowerThresholdLevDL: 0Fh |
| 250 | pcLowerThresholdLevUL: 0Ah |
| 251 | pcLowerThresholdQualDL: 05h = 3.2% < BER < 6.4% |
| 252 | pcLowerThresholdQualUL: 05h = 3.2% < BER < 6.4% |
| 253 | pcRLFThreshold: 0Ch |
| 254 | pcUpperThresholdLevDL: 14h |
| 255 | pcUpperThresholdLevUL: 0Fh |
| 256 | pcUpperThresholdQualDL: 04h = 1.6% < BER < 3.2% |
| 257 | pcUpperThresholdQualUL: 04h = 1.6% < BER < 3.2% |
| 258 | powerConfirm: 2 ,unit 2 SACCH multiframes |
| 259 | powerControlInterval: 2 ,unit 2 SACCH multiframes |
| 260 | powerIncrStepSize: 02h = 4 dB |
| 261 | powerRedStepSize: 01h = 2 dB |
| 262 | radioLinkTimeoutBs: 64 SACCH multiframes |
| 263 | enableBSPowerControl: 00h = disabled |
| 264 | */ |
| 265 | |
| 266 | unsigned char msg_4[] = |
| 267 | { |
| 268 | NM_MT_BS11_SET_ATTR, NM_OC_BS11_PWR_CTRL, 0x00, 0xFF, 0xFF, |
| 269 | NM_ATT_BS11_ENA_MS_PWR_CTRL, 0x00, |
| 270 | NM_ATT_BS11_ENA_PWR_CTRL_RLFW, 0x00, |
| 271 | 0x7E, 0x04, 0x01, /* pcAveragingLev */ |
| 272 | 0x7F, 0x04, 0x02, /* pcAveragingQual */ |
| 273 | 0x80, 0x0F, /* pcLowerThresholdLevDL */ |
| 274 | 0x81, 0x0A, /* pcLowerThresholdLevUL */ |
| 275 | 0x82, 0x05, /* pcLowerThresholdQualDL */ |
| 276 | 0x83, 0x05, /* pcLowerThresholdQualUL */ |
| 277 | 0x84, 0x0C, /* pcRLFThreshold */ |
| 278 | 0x85, 0x14, /* pcUpperThresholdLevDL */ |
| 279 | 0x86, 0x0F, /* pcUpperThresholdLevUL */ |
| 280 | 0x87, 0x04, /* pcUpperThresholdQualDL */ |
| 281 | 0x88, 0x04, /* pcUpperThresholdQualUL */ |
| 282 | 0x89, 0x02, /* powerConfirm */ |
| 283 | 0x8A, 0x02, /* powerConfirmInterval */ |
| 284 | 0x8B, 0x02, /* powerIncrStepSize */ |
| 285 | 0x8C, 0x01, /* powerRedStepSize */ |
| 286 | 0x8D, 0x40, /* radioLinkTimeoutBs */ |
| 287 | 0x65, 0x01, 0x00 // set to 0x01 to enable BSPowerControl |
| 288 | }; |
| 289 | |
| 290 | |
| 291 | // Transceiver, SET TRX ATTRIBUTES (TRX 0) |
| 292 | |
| 293 | /* |
| 294 | Object Class: Transceiver |
| 295 | BTS relat. Number: 0 |
| 296 | Tranceiver number: 0 |
| 297 | Instance 3: FF |
| 298 | SET TRX ATTRIBUTES |
| 299 | aRFCNList (HEX): 0001 |
| 300 | txPwrMaxReduction: 00h = 30dB |
| 301 | radioMeasGran: 254 SACCH multiframes |
| 302 | radioMeasRep: 01h = enabled |
| 303 | memberOfEmergencyConfig: 01h = TRUE |
| 304 | trxArea: 00h = TRX doesn't belong to a concentric cell |
| 305 | */ |
| 306 | |
| 307 | static unsigned char bs11_attr_radio[] = |
| 308 | { |
| 309 | NM_ATT_ARFCN_LIST, 0x01, 0x00, HARDCODED_ARFCN /*0x01*/, |
| 310 | NM_ATT_RF_MAXPOWR_R, 0x00, |
| 311 | NM_ATT_BS11_RADIO_MEAS_GRAN, 0x01, 0x05, |
| 312 | NM_ATT_BS11_RADIO_MEAS_REP, 0x01, 0x01, |
| 313 | NM_ATT_BS11_EMRG_CFG_MEMBER, 0x01, 0x01, |
| 314 | NM_ATT_BS11_TRX_AREA, 0x01, 0x00, |
| 315 | }; |
| 316 | |
| 317 | static unsigned char nanobts_attr_bts[] = { |
| 318 | NM_ATT_INTERF_BOUND, 0x55, 0x5b, 0x61, 0x67, 0x6d, 0x73, |
| 319 | /* interference avg. period in numbers of SACCH multifr */ |
| 320 | NM_ATT_INTAVE_PARAM, 0x06, |
| 321 | /* conn fail based on SACCH error rate */ |
| 322 | NM_ATT_CONN_FAIL_CRIT, 0x00, 0x02, 0x01, 0x10, |
| 323 | NM_ATT_T200, 0x1e, 0x24, 0x24, 0xa8, 0x34, 0x21, 0xa8, |
| 324 | NM_ATT_MAX_TA, 0x3f, |
| 325 | NM_ATT_OVERL_PERIOD, 0x00, 0x01, 10, /* seconds */ |
| 326 | NM_ATT_CCCH_L_T, 10, /* percent */ |
| 327 | NM_ATT_CCCH_L_I_P, 1, /* seconds */ |
| 328 | NM_ATT_RACH_B_THRESH, 10, /* busy threshold in - dBm */ |
| 329 | NM_ATT_LDAVG_SLOTS, 0x03, 0xe8, /* rach load averaging 1000 slots */ |
| 330 | NM_ATT_BTS_AIR_TIMER, 128, /* miliseconds */ |
| 331 | NM_ATT_NY1, 10, /* 10 retransmissions of physical config */ |
| 332 | NM_ATT_BCCH_ARFCN, HARDCODED_ARFCN >> 8, HARDCODED_ARFCN & 0xff, |
| 333 | NM_ATT_BSIC, HARDCODED_BSIC, |
Harald Welte | 97a282b | 2010-03-14 15:37:43 +0800 | [diff] [blame] | 334 | NM_ATT_IPACC_CGI, 0, 7, 0x00, 0xf1, 0x10, 0x00, 0x01, 0x00, 0x00, |
Holger Hans Peter Freyther | 8b457fb | 2009-08-17 06:55:10 +0200 | [diff] [blame] | 335 | }; |
| 336 | |
| 337 | static unsigned char nanobts_attr_radio[] = { |
| 338 | NM_ATT_RF_MAXPOWR_R, 0x0c, /* number of -2dB reduction steps / Pn */ |
| 339 | NM_ATT_ARFCN_LIST, 0x00, 0x02, HARDCODED_ARFCN >> 8, HARDCODED_ARFCN & 0xff, |
| 340 | }; |
| 341 | |
Harald Welte | 97a282b | 2010-03-14 15:37:43 +0800 | [diff] [blame] | 342 | static unsigned char nanobts_attr_nse[] = { |
| 343 | NM_ATT_IPACC_NSEI, 0, 2, 0x03, 0x9d, /* NSEI 925 */ |
| 344 | NM_ATT_IPACC_NS_CFG, 0, 7, 3, /* (un)blocking timer (Tns-block) */ |
| 345 | 3, /* (un)blocking retries */ |
| 346 | 3, /* reset timer (Tns-reset) */ |
| 347 | 3, /* reset retries */ |
| 348 | 30, /* test timer (Tns-test) */ |
| 349 | 3, /* alive timer (Tns-alive) */ |
| 350 | 10, /* alive retrires */ |
| 351 | NM_ATT_IPACC_BSSGP_CFG, 0, 11, |
| 352 | 3, /* blockimg timer (T1) */ |
| 353 | 3, /* blocking retries */ |
| 354 | 3, /* unblocking retries */ |
| 355 | 3, /* reset timer */ |
| 356 | 3, /* reset retries */ |
| 357 | 10, /* suspend timer (T3) in 100ms */ |
| 358 | 3, /* suspend retries */ |
| 359 | 10, /* resume timer (T4) in 100ms */ |
| 360 | 3, /* resume retries */ |
| 361 | 10, /* capability update timer (T5) */ |
| 362 | 3, /* capability update retries */ |
| 363 | }; |
| 364 | |
| 365 | static unsigned char nanobts_attr_cell[] = { |
| 366 | NM_ATT_IPACC_RAC, 0, 1, 1, /* routing area code */ |
| 367 | NM_ATT_IPACC_GPRS_PAGING_CFG, 0, 2, |
| 368 | 5, /* repeat time (50ms) */ |
| 369 | 3, /* repeat count */ |
| 370 | NM_ATT_IPACC_BVCI, 0, 2, 0x03, 0x9d, /* BVCI 925 */ |
| 371 | NM_ATT_IPACC_RLC_CFG, 0, 9, |
| 372 | 20, /* T3142 */ |
| 373 | 5, /* T3169 */ |
| 374 | 5, /* T3191 */ |
| 375 | 200, /* T3193 */ |
| 376 | 5, /* T3195 */ |
| 377 | 10, /* N3101 */ |
| 378 | 4, /* N3103 */ |
| 379 | 8, /* N3105 */ |
| 380 | 15, /* RLC CV countdown */ |
Harald Welte | 439bb82 | 2010-04-18 16:50:11 +0200 | [diff] [blame] | 381 | NM_ATT_IPACC_CODING_SCHEMES, 0, 2, 0x0f, 0x00, /* CS1..CS4 */ |
Harald Welte | 97a282b | 2010-03-14 15:37:43 +0800 | [diff] [blame] | 382 | NM_ATT_IPACC_RLC_CFG_2, 0, 5, |
Harald Welte | 439bb82 | 2010-04-18 16:50:11 +0200 | [diff] [blame] | 383 | 0x00, 250, /* T downlink TBF extension (0..500) */ |
| 384 | 0x00, 250, /* T uplink TBF extension (0..500) */ |
| 385 | 2, /* CS2 */ |
Harald Welte | 97a282b | 2010-03-14 15:37:43 +0800 | [diff] [blame] | 386 | #if 0 |
| 387 | /* EDGE model only, breaks older models. |
| 388 | * Should inquire the BTS capabilities */ |
| 389 | NM_ATT_IPACC_RLC_CFG_3, 0, 1, |
| 390 | 2, /* MCS2 */ |
| 391 | #endif |
| 392 | }; |
| 393 | |
| 394 | static unsigned char nanobts_attr_nsvc0[] = { |
| 395 | NM_ATT_IPACC_NSVCI, 0, 2, 0x03, 0x9d, /* 925 */ |
| 396 | NM_ATT_IPACC_NS_LINK_CFG, 0, 8, |
| 397 | 0x59, 0xd8, /* remote udp port (23000) */ |
| 398 | 192, 168, 100, 11, /* remote ip address */ |
| 399 | 0x59, 0xd8, /* local udp port (23000) */ |
| 400 | }; |
| 401 | |
Holger Hans Peter Freyther | 8b457fb | 2009-08-17 06:55:10 +0200 | [diff] [blame] | 402 | /* Callback function to be called whenever we get a GSM 12.21 state change event */ |
| 403 | int nm_state_event(enum nm_evt evt, u_int8_t obj_class, void *obj, |
Holger Hans Peter Freyther | aa0db80 | 2010-05-13 00:37:48 +0800 | [diff] [blame] | 404 | struct gsm_nm_state *old_state, struct gsm_nm_state *new_state, |
| 405 | struct abis_om_obj_inst *obj_inst) |
Holger Hans Peter Freyther | 8b457fb | 2009-08-17 06:55:10 +0200 | [diff] [blame] | 406 | { |
| 407 | struct gsm_bts *bts; |
| 408 | struct gsm_bts_trx *trx; |
| 409 | struct gsm_bts_trx_ts *ts; |
Harald Welte | 97a282b | 2010-03-14 15:37:43 +0800 | [diff] [blame] | 410 | struct gsm_bts_gprs_nsvc *nsvc; |
Holger Hans Peter Freyther | 8b457fb | 2009-08-17 06:55:10 +0200 | [diff] [blame] | 411 | |
Harald Welte | 8406ec2 | 2009-10-20 17:31:00 +0200 | [diff] [blame] | 412 | /* This event-driven BTS setup is currently only required on nanoBTS */ |
Holger Hans Peter Freyther | 8b457fb | 2009-08-17 06:55:10 +0200 | [diff] [blame] | 413 | |
Harald Welte | 8406ec2 | 2009-10-20 17:31:00 +0200 | [diff] [blame] | 414 | /* EVT_STATECHG_ADM is called after we call chg_adm_state() and would create |
| 415 | * endless loop */ |
| 416 | if (evt != EVT_STATECHG_OPER) |
| 417 | return 0; |
| 418 | |
| 419 | switch (obj_class) { |
| 420 | case NM_OC_SITE_MANAGER: |
| 421 | bts = container_of(obj, struct gsm_bts, site_mgr); |
Sylvain Munaut | 7de6796 | 2009-12-18 17:45:45 +0100 | [diff] [blame] | 422 | if ((new_state->operational == 2 && |
| 423 | new_state->availability == NM_AVSTATE_OK) || |
| 424 | (new_state->operational == 1 && |
| 425 | new_state->availability == NM_AVSTATE_OFF_LINE)) |
Harald Welte | 8406ec2 | 2009-10-20 17:31:00 +0200 | [diff] [blame] | 426 | abis_nm_opstart(bts, obj_class, 0xff, 0xff, 0xff); |
| 427 | break; |
| 428 | case NM_OC_BTS: |
| 429 | bts = obj; |
| 430 | if (new_state->availability == NM_AVSTATE_DEPENDENCY) { |
| 431 | patch_nm_tables(bts); |
| 432 | abis_nm_set_bts_attr(bts, nanobts_attr_bts, |
| 433 | sizeof(nanobts_attr_bts)); |
| 434 | abis_nm_chg_adm_state(bts, obj_class, |
| 435 | bts->bts_nr, 0xff, 0xff, |
| 436 | NM_STATE_UNLOCKED); |
| 437 | abis_nm_opstart(bts, obj_class, |
| 438 | bts->bts_nr, 0xff, 0xff); |
| 439 | } |
| 440 | break; |
| 441 | case NM_OC_CHANNEL: |
| 442 | ts = obj; |
| 443 | trx = ts->trx; |
| 444 | if (new_state->operational == 1 && |
| 445 | new_state->availability == NM_AVSTATE_DEPENDENCY) { |
Harald Welte | 65bdc91 | 2009-10-26 20:14:33 +0100 | [diff] [blame] | 446 | patch_nm_tables(trx->bts); |
Harald Welte | 0f890b0 | 2009-10-24 09:09:05 +0200 | [diff] [blame] | 447 | enum abis_nm_chan_comb ccomb = |
| 448 | abis_nm_chcomb4pchan(ts->pchan); |
| 449 | abis_nm_set_channel_attr(ts, ccomb); |
Harald Welte | 8406ec2 | 2009-10-20 17:31:00 +0200 | [diff] [blame] | 450 | abis_nm_chg_adm_state(trx->bts, obj_class, |
| 451 | trx->bts->bts_nr, trx->nr, ts->nr, |
| 452 | NM_STATE_UNLOCKED); |
| 453 | abis_nm_opstart(trx->bts, obj_class, |
| 454 | trx->bts->bts_nr, trx->nr, ts->nr); |
| 455 | } |
| 456 | break; |
| 457 | case NM_OC_RADIO_CARRIER: |
| 458 | trx = obj; |
| 459 | if (new_state->operational == 1 && |
Harald Welte | 8406ec2 | 2009-10-20 17:31:00 +0200 | [diff] [blame] | 460 | new_state->availability == NM_AVSTATE_OK) |
| 461 | abis_nm_opstart(trx->bts, obj_class, trx->bts->bts_nr, |
| 462 | trx->nr, 0xff); |
| 463 | break; |
Harald Welte | 97a282b | 2010-03-14 15:37:43 +0800 | [diff] [blame] | 464 | case NM_OC_GPRS_NSE: |
| 465 | bts = container_of(obj, struct gsm_bts, gprs.nse); |
Harald Welte | 4511d89 | 2010-04-18 15:51:20 +0200 | [diff] [blame] | 466 | if (bts->gprs.mode == BTS_GPRS_NONE) |
Harald Welte | fa58625 | 2010-03-14 23:33:36 +0800 | [diff] [blame] | 467 | break; |
Harald Welte | 97a282b | 2010-03-14 15:37:43 +0800 | [diff] [blame] | 468 | if (new_state->availability == 5) { |
| 469 | abis_nm_ipaccess_set_attr(bts, obj_class, bts->bts_nr, |
| 470 | 0xff, 0xff, nanobts_attr_nse, |
| 471 | sizeof(nanobts_attr_nse)); |
| 472 | abis_nm_opstart(bts, obj_class, bts->bts_nr, |
| 473 | 0xff, 0xff); |
| 474 | abis_nm_chg_adm_state(bts, obj_class, bts->bts_nr, |
| 475 | 0xff, 0xff, NM_STATE_UNLOCKED); |
| 476 | } |
| 477 | break; |
| 478 | case NM_OC_GPRS_CELL: |
| 479 | bts = container_of(obj, struct gsm_bts, gprs.cell); |
Harald Welte | 4511d89 | 2010-04-18 15:51:20 +0200 | [diff] [blame] | 480 | if (bts->gprs.mode == BTS_GPRS_NONE) |
Harald Welte | fa58625 | 2010-03-14 23:33:36 +0800 | [diff] [blame] | 481 | break; |
Harald Welte | 97a282b | 2010-03-14 15:37:43 +0800 | [diff] [blame] | 482 | if (new_state->availability == 5) { |
| 483 | abis_nm_ipaccess_set_attr(bts, obj_class, bts->bts_nr, |
| 484 | 0, 0xff, nanobts_attr_cell, |
| 485 | sizeof(nanobts_attr_cell)); |
| 486 | abis_nm_opstart(bts, obj_class, bts->bts_nr, |
| 487 | 0, 0xff); |
| 488 | abis_nm_chg_adm_state(bts, obj_class, bts->bts_nr, |
| 489 | 0, 0xff, NM_STATE_UNLOCKED); |
| 490 | } |
| 491 | break; |
| 492 | case NM_OC_GPRS_NSVC: |
| 493 | nsvc = obj; |
| 494 | bts = nsvc->bts; |
Harald Welte | 4511d89 | 2010-04-18 15:51:20 +0200 | [diff] [blame] | 495 | if (bts->gprs.mode == BTS_GPRS_NONE) |
Harald Welte | fa58625 | 2010-03-14 23:33:36 +0800 | [diff] [blame] | 496 | break; |
Holger Hans Peter Freyther | a581136 | 2010-04-30 13:32:05 +0800 | [diff] [blame] | 497 | /* We skip NSVC1 since we only use NSVC0 */ |
Harald Welte | 97a282b | 2010-03-14 15:37:43 +0800 | [diff] [blame] | 498 | if (nsvc->id == 1) |
| 499 | break; |
| 500 | if (new_state->availability == NM_AVSTATE_OFF_LINE) { |
| 501 | abis_nm_ipaccess_set_attr(bts, obj_class, bts->bts_nr, |
| 502 | nsvc->id, 0xff, |
| 503 | nanobts_attr_nsvc0, |
| 504 | sizeof(nanobts_attr_nsvc0)); |
| 505 | abis_nm_opstart(bts, obj_class, bts->bts_nr, |
| 506 | nsvc->id, 0xff); |
| 507 | abis_nm_chg_adm_state(bts, obj_class, bts->bts_nr, |
| 508 | nsvc->id, 0xff, |
| 509 | NM_STATE_UNLOCKED); |
| 510 | } |
Holger Hans Peter Freyther | 8b457fb | 2009-08-17 06:55:10 +0200 | [diff] [blame] | 511 | default: |
Holger Hans Peter Freyther | 8b457fb | 2009-08-17 06:55:10 +0200 | [diff] [blame] | 512 | break; |
| 513 | } |
| 514 | return 0; |
| 515 | } |
| 516 | |
| 517 | /* Callback function to be called every time we receive a 12.21 SW activated report */ |
| 518 | static int sw_activ_rep(struct msgb *mb) |
| 519 | { |
| 520 | struct abis_om_fom_hdr *foh = msgb_l3(mb); |
Harald Welte | d004a64 | 2009-10-19 21:47:54 +0200 | [diff] [blame] | 521 | struct gsm_bts *bts = mb->trx->bts; |
| 522 | struct gsm_bts_trx *trx = gsm_bts_trx_num(bts, foh->obj_inst.trx_nr); |
| 523 | |
Harald Welte | b7bcb79 | 2009-12-23 18:24:31 +0100 | [diff] [blame] | 524 | if (!trx) |
| 525 | return -EINVAL; |
Holger Hans Peter Freyther | 8b457fb | 2009-08-17 06:55:10 +0200 | [diff] [blame] | 526 | |
| 527 | switch (foh->obj_class) { |
Holger Hans Peter Freyther | 1ce10f3 | 2009-11-19 19:18:29 +0100 | [diff] [blame] | 528 | case NM_OC_BASEB_TRANSC: |
| 529 | abis_nm_chg_adm_state(trx->bts, foh->obj_class, |
| 530 | trx->bts->bts_nr, trx->nr, 0xff, |
| 531 | NM_STATE_UNLOCKED); |
| 532 | abis_nm_opstart(trx->bts, foh->obj_class, |
| 533 | trx->bts->bts_nr, trx->nr, 0xff); |
| 534 | /* TRX software is active, tell it to initiate RSL Link */ |
| 535 | abis_nm_ipaccess_rsl_connect(trx, 0, 3003, trx->rsl_tei); |
| 536 | break; |
Holger Hans Peter Freyther | 2d501ea | 2009-11-11 11:54:24 +0100 | [diff] [blame] | 537 | case NM_OC_RADIO_CARRIER: { |
| 538 | /* |
| 539 | * Locking the radio carrier will make it go |
| 540 | * offline again and we would come here. The |
| 541 | * framework should determine that there was |
| 542 | * no change and avoid recursion. |
| 543 | * |
| 544 | * This code is here to make sure that on start |
| 545 | * a TRX remains locked. |
| 546 | */ |
Holger Hans Peter Freyther | f31e474 | 2009-12-31 03:05:52 +0100 | [diff] [blame] | 547 | int rc_state = trx->nm_state.administrative; |
Holger Hans Peter Freyther | 1ce10f3 | 2009-11-19 19:18:29 +0100 | [diff] [blame] | 548 | /* Patch ARFCN into radio attribute */ |
| 549 | nanobts_attr_radio[5] &= 0xf0; |
| 550 | nanobts_attr_radio[5] |= trx->arfcn >> 8; |
| 551 | nanobts_attr_radio[6] = trx->arfcn & 0xff; |
| 552 | abis_nm_set_radio_attr(trx, nanobts_attr_radio, |
| 553 | sizeof(nanobts_attr_radio)); |
| 554 | abis_nm_chg_adm_state(trx->bts, foh->obj_class, |
| 555 | trx->bts->bts_nr, trx->nr, 0xff, |
Holger Hans Peter Freyther | 2d501ea | 2009-11-11 11:54:24 +0100 | [diff] [blame] | 556 | rc_state); |
Holger Hans Peter Freyther | 1ce10f3 | 2009-11-19 19:18:29 +0100 | [diff] [blame] | 557 | abis_nm_opstart(trx->bts, foh->obj_class, trx->bts->bts_nr, |
| 558 | trx->nr, 0xff); |
| 559 | break; |
Holger Hans Peter Freyther | 2d501ea | 2009-11-11 11:54:24 +0100 | [diff] [blame] | 560 | } |
Holger Hans Peter Freyther | 8b457fb | 2009-08-17 06:55:10 +0200 | [diff] [blame] | 561 | } |
| 562 | return 0; |
| 563 | } |
| 564 | |
| 565 | /* Callback function for NACK on the OML NM */ |
Harald Welte | d8cfc90 | 2009-11-17 06:09:56 +0100 | [diff] [blame] | 566 | static int oml_msg_nack(u_int8_t mt) |
Holger Hans Peter Freyther | 8b457fb | 2009-08-17 06:55:10 +0200 | [diff] [blame] | 567 | { |
| 568 | if (mt == NM_MT_SET_BTS_ATTR_NACK) { |
Harald Welte | b1d4c8e | 2009-12-17 23:10:46 +0100 | [diff] [blame] | 569 | LOGP(DNM, LOGL_FATAL, "Failed to set BTS attributes. That is fatal. " |
Holger Hans Peter Freyther | 8b457fb | 2009-08-17 06:55:10 +0200 | [diff] [blame] | 570 | "Was the bts type and frequency properly specified?\n"); |
| 571 | exit(-1); |
| 572 | } |
| 573 | |
| 574 | return 0; |
| 575 | } |
| 576 | |
| 577 | /* Callback function to be called every time we receive a signal from NM */ |
| 578 | static int nm_sig_cb(unsigned int subsys, unsigned int signal, |
| 579 | void *handler_data, void *signal_data) |
| 580 | { |
Harald Welte | d8cfc90 | 2009-11-17 06:09:56 +0100 | [diff] [blame] | 581 | u_int8_t *msg_type; |
| 582 | |
Holger Hans Peter Freyther | 8b457fb | 2009-08-17 06:55:10 +0200 | [diff] [blame] | 583 | switch (signal) { |
| 584 | case S_NM_SW_ACTIV_REP: |
| 585 | return sw_activ_rep(signal_data); |
| 586 | case S_NM_NACK: |
Harald Welte | d8cfc90 | 2009-11-17 06:09:56 +0100 | [diff] [blame] | 587 | msg_type = signal_data; |
| 588 | return oml_msg_nack(*msg_type); |
Holger Hans Peter Freyther | 8b457fb | 2009-08-17 06:55:10 +0200 | [diff] [blame] | 589 | default: |
| 590 | break; |
| 591 | } |
| 592 | return 0; |
| 593 | } |
| 594 | |
| 595 | static void bootstrap_om_nanobts(struct gsm_bts *bts) |
| 596 | { |
| 597 | /* We don't do callback based bootstrapping, but event driven (see above) */ |
| 598 | } |
| 599 | |
| 600 | static void nm_reconfig_ts(struct gsm_bts_trx_ts *ts) |
| 601 | { |
| 602 | enum abis_nm_chan_comb ccomb = abis_nm_chcomb4pchan(ts->pchan); |
| 603 | struct gsm_e1_subslot *e1l = &ts->e1_link; |
| 604 | |
| 605 | abis_nm_set_channel_attr(ts, ccomb); |
| 606 | |
| 607 | if (is_ipaccess_bts(ts->trx->bts)) |
| 608 | return; |
| 609 | |
| 610 | switch (ts->pchan) { |
| 611 | case GSM_PCHAN_TCH_F: |
| 612 | case GSM_PCHAN_TCH_H: |
| 613 | abis_nm_conn_terr_traf(ts, e1l->e1_nr, e1l->e1_ts, |
| 614 | e1l->e1_ts_ss); |
| 615 | break; |
| 616 | default: |
| 617 | break; |
| 618 | } |
| 619 | } |
| 620 | |
| 621 | static void nm_reconfig_trx(struct gsm_bts_trx *trx) |
| 622 | { |
| 623 | struct gsm_e1_subslot *e1l = &trx->rsl_e1_link; |
| 624 | int i; |
| 625 | |
| 626 | patch_nm_tables(trx->bts); |
| 627 | |
| 628 | switch (trx->bts->type) { |
| 629 | case GSM_BTS_TYPE_BS11: |
| 630 | /* FIXME: discover this by fetching an attribute */ |
| 631 | #if 0 |
| 632 | trx->nominal_power = 15; /* 15dBm == 30mW PA configuration */ |
| 633 | #else |
| 634 | trx->nominal_power = 24; /* 24dBm == 250mW PA configuration */ |
| 635 | #endif |
| 636 | abis_nm_conn_terr_sign(trx, e1l->e1_nr, e1l->e1_ts, |
| 637 | e1l->e1_ts_ss); |
| 638 | abis_nm_establish_tei(trx->bts, trx->nr, e1l->e1_nr, |
| 639 | e1l->e1_ts, e1l->e1_ts_ss, trx->rsl_tei); |
| 640 | |
| 641 | /* Set Radio Attributes */ |
| 642 | if (trx == trx->bts->c0) |
| 643 | abis_nm_set_radio_attr(trx, bs11_attr_radio, |
| 644 | sizeof(bs11_attr_radio)); |
| 645 | else { |
| 646 | u_int8_t trx1_attr_radio[sizeof(bs11_attr_radio)]; |
| 647 | u_int8_t arfcn_low = trx->arfcn & 0xff; |
| 648 | u_int8_t arfcn_high = (trx->arfcn >> 8) & 0x0f; |
| 649 | memcpy(trx1_attr_radio, bs11_attr_radio, |
| 650 | sizeof(trx1_attr_radio)); |
| 651 | |
| 652 | /* patch ARFCN into TRX Attributes */ |
| 653 | trx1_attr_radio[2] &= 0xf0; |
| 654 | trx1_attr_radio[2] |= arfcn_high; |
| 655 | trx1_attr_radio[3] = arfcn_low; |
| 656 | |
| 657 | abis_nm_set_radio_attr(trx, trx1_attr_radio, |
| 658 | sizeof(trx1_attr_radio)); |
| 659 | } |
| 660 | break; |
Mike Haben | e2d8227 | 2009-10-02 12:19:34 +0100 | [diff] [blame] | 661 | case GSM_BTS_TYPE_NANOBTS: |
Harald Welte | af7b2fa | 2009-10-19 21:47:31 +0200 | [diff] [blame] | 662 | switch (trx->bts->band) { |
| 663 | case GSM_BAND_850: |
| 664 | case GSM_BAND_900: |
| 665 | trx->nominal_power = 20; |
| 666 | break; |
| 667 | case GSM_BAND_1800: |
| 668 | case GSM_BAND_1900: |
| 669 | trx->nominal_power = 23; |
| 670 | break; |
Holger Hans Peter Freyther | 555eba1 | 2009-10-22 15:46:16 +0200 | [diff] [blame] | 671 | default: |
Harald Welte | b1d4c8e | 2009-12-17 23:10:46 +0100 | [diff] [blame] | 672 | LOGP(DNM, LOGL_ERROR, "Unsupported nanoBTS GSM band %s\n", |
Harald Welte | af7b2fa | 2009-10-19 21:47:31 +0200 | [diff] [blame] | 673 | gsm_band_name(trx->bts->band)); |
| 674 | break; |
| 675 | } |
| 676 | break; |
Holger Hans Peter Freyther | 8b457fb | 2009-08-17 06:55:10 +0200 | [diff] [blame] | 677 | default: |
| 678 | break; |
| 679 | } |
| 680 | |
| 681 | for (i = 0; i < TRX_NR_TS; i++) |
| 682 | nm_reconfig_ts(&trx->ts[i]); |
| 683 | } |
| 684 | |
| 685 | static void nm_reconfig_bts(struct gsm_bts *bts) |
| 686 | { |
| 687 | struct gsm_bts_trx *trx; |
| 688 | |
| 689 | switch (bts->type) { |
| 690 | case GSM_BTS_TYPE_BS11: |
Harald Welte | ade7a14 | 2009-12-14 17:49:52 +0100 | [diff] [blame] | 691 | patch_nm_tables(bts); |
Holger Hans Peter Freyther | 8b457fb | 2009-08-17 06:55:10 +0200 | [diff] [blame] | 692 | abis_nm_raw_msg(bts, sizeof(msg_1), msg_1); /* set BTS SiteMgr attr*/ |
| 693 | abis_nm_set_bts_attr(bts, bs11_attr_bts, sizeof(bs11_attr_bts)); |
| 694 | abis_nm_raw_msg(bts, sizeof(msg_3), msg_3); /* set BTS handover attr */ |
| 695 | abis_nm_raw_msg(bts, sizeof(msg_4), msg_4); /* set BTS power control attr */ |
| 696 | break; |
| 697 | default: |
| 698 | break; |
| 699 | } |
| 700 | |
| 701 | llist_for_each_entry(trx, &bts->trx_list, list) |
| 702 | nm_reconfig_trx(trx); |
| 703 | } |
| 704 | |
| 705 | static void bootstrap_om_bs11(struct gsm_bts *bts) |
| 706 | { |
| 707 | /* stop sending event reports */ |
| 708 | abis_nm_event_reports(bts, 0); |
| 709 | |
| 710 | /* begin DB transmission */ |
| 711 | abis_nm_bs11_db_transmission(bts, 1); |
| 712 | |
| 713 | /* end DB transmission */ |
| 714 | abis_nm_bs11_db_transmission(bts, 0); |
| 715 | |
| 716 | /* Reset BTS Site manager resource */ |
| 717 | abis_nm_bs11_reset_resource(bts); |
| 718 | |
| 719 | /* begin DB transmission */ |
| 720 | abis_nm_bs11_db_transmission(bts, 1); |
| 721 | |
| 722 | /* reconfigure BTS with all TRX and all TS */ |
| 723 | nm_reconfig_bts(bts); |
| 724 | |
| 725 | /* end DB transmission */ |
| 726 | abis_nm_bs11_db_transmission(bts, 0); |
| 727 | |
| 728 | /* Reset BTS Site manager resource */ |
| 729 | abis_nm_bs11_reset_resource(bts); |
| 730 | |
| 731 | /* restart sending event reports */ |
| 732 | abis_nm_event_reports(bts, 1); |
| 733 | } |
| 734 | |
| 735 | static void bootstrap_om(struct gsm_bts *bts) |
| 736 | { |
Harald Welte | b1d4c8e | 2009-12-17 23:10:46 +0100 | [diff] [blame] | 737 | LOGP(DNM, LOGL_NOTICE, "bootstrapping OML for BTS %u\n", bts->nr); |
Holger Hans Peter Freyther | 8b457fb | 2009-08-17 06:55:10 +0200 | [diff] [blame] | 738 | |
| 739 | switch (bts->type) { |
| 740 | case GSM_BTS_TYPE_BS11: |
| 741 | bootstrap_om_bs11(bts); |
| 742 | break; |
Mike Haben | e2d8227 | 2009-10-02 12:19:34 +0100 | [diff] [blame] | 743 | case GSM_BTS_TYPE_NANOBTS: |
Holger Hans Peter Freyther | 8b457fb | 2009-08-17 06:55:10 +0200 | [diff] [blame] | 744 | bootstrap_om_nanobts(bts); |
| 745 | break; |
| 746 | default: |
Harald Welte | b1d4c8e | 2009-12-17 23:10:46 +0100 | [diff] [blame] | 747 | LOGP(DNM, LOGL_ERROR, "Unable to bootstrap OML: Unknown BTS type %d\n", bts->type); |
Holger Hans Peter Freyther | 8b457fb | 2009-08-17 06:55:10 +0200 | [diff] [blame] | 748 | } |
| 749 | } |
| 750 | |
| 751 | static int shutdown_om(struct gsm_bts *bts) |
| 752 | { |
Harald Welte | b1d4c8e | 2009-12-17 23:10:46 +0100 | [diff] [blame] | 753 | LOGP(DNM, LOGL_NOTICE, "shutting down OML for BTS %u\n", bts->nr); |
Holger Hans Peter Freyther | 8b457fb | 2009-08-17 06:55:10 +0200 | [diff] [blame] | 754 | |
| 755 | /* stop sending event reports */ |
| 756 | abis_nm_event_reports(bts, 0); |
| 757 | |
| 758 | /* begin DB transmission */ |
| 759 | abis_nm_bs11_db_transmission(bts, 1); |
| 760 | |
| 761 | /* end DB transmission */ |
| 762 | abis_nm_bs11_db_transmission(bts, 0); |
| 763 | |
| 764 | /* Reset BTS Site manager resource */ |
| 765 | abis_nm_bs11_reset_resource(bts); |
| 766 | |
| 767 | return 0; |
| 768 | } |
| 769 | |
| 770 | int bsc_shutdown_net(struct gsm_network *net) |
| 771 | { |
| 772 | struct gsm_bts *bts; |
| 773 | |
| 774 | llist_for_each_entry(bts, &net->bts_list, list) { |
| 775 | int rc; |
| 776 | rc = shutdown_om(bts); |
| 777 | if (rc < 0) |
| 778 | return rc; |
| 779 | } |
| 780 | |
| 781 | return 0; |
| 782 | } |
| 783 | |
Holger Hans Peter Freyther | 8b457fb | 2009-08-17 06:55:10 +0200 | [diff] [blame] | 784 | /* set all system information types */ |
| 785 | static int set_system_infos(struct gsm_bts_trx *trx) |
| 786 | { |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 787 | int i, rc; |
| 788 | u_int8_t si_tmp[23]; |
Harald Welte | 73d4fce | 2009-12-21 23:12:19 +0100 | [diff] [blame] | 789 | struct gsm_bts *bts = trx->bts; |
| 790 | |
| 791 | bts->si_common.cell_sel_par.ms_txpwr_max_ccch = |
| 792 | ms_pwr_ctl_lvl(bts->band, bts->ms_max_power); |
| 793 | bts->si_common.cell_sel_par.neci = bts->network->neci; |
Holger Hans Peter Freyther | 8b457fb | 2009-08-17 06:55:10 +0200 | [diff] [blame] | 794 | |
| 795 | if (trx == trx->bts->c0) { |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 796 | for (i = 1; i <= 4; i++) { |
| 797 | rc = gsm_generate_si(si_tmp, trx->bts, i); |
| 798 | if (rc < 0) |
| 799 | goto err_out; |
Harald Welte | 50e7fec | 2009-12-19 21:29:00 +0100 | [diff] [blame] | 800 | DEBUGP(DRR, "SI%2u: %s\n", i, hexdump(si_tmp, rc)); |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 801 | rsl_bcch_info(trx, i, si_tmp, sizeof(si_tmp)); |
Holger Hans Peter Freyther | 8b457fb | 2009-08-17 06:55:10 +0200 | [diff] [blame] | 802 | } |
Harald Welte | 4511d89 | 2010-04-18 15:51:20 +0200 | [diff] [blame] | 803 | if (bts->gprs.mode != BTS_GPRS_NONE) { |
Harald Welte | fa58625 | 2010-03-14 23:33:36 +0800 | [diff] [blame] | 804 | i = 13; |
| 805 | rc = gsm_generate_si(si_tmp, trx->bts, RSL_SYSTEM_INFO_13); |
| 806 | if (rc < 0) |
| 807 | goto err_out; |
| 808 | DEBUGP(DRR, "SI%2u: %s\n", i, hexdump(si_tmp, rc)); |
| 809 | rsl_bcch_info(trx, RSL_SYSTEM_INFO_13, si_tmp, rc); |
| 810 | } |
Harald Welte | 6a22c01 | 2009-12-21 17:02:32 +0100 | [diff] [blame] | 811 | } |
| 812 | |
Harald Welte | 50e7fec | 2009-12-19 21:29:00 +0100 | [diff] [blame] | 813 | i = 5; |
| 814 | rc = gsm_generate_si(si_tmp, trx->bts, RSL_SYSTEM_INFO_5); |
| 815 | if (rc < 0) |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 816 | goto err_out; |
Harald Welte | 50e7fec | 2009-12-19 21:29:00 +0100 | [diff] [blame] | 817 | DEBUGP(DRR, "SI%2u: %s\n", i, hexdump(si_tmp, rc)); |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 818 | rsl_sacch_filling(trx, RSL_SYSTEM_INFO_5, si_tmp, rc); |
| 819 | |
Harald Welte | 50e7fec | 2009-12-19 21:29:00 +0100 | [diff] [blame] | 820 | i = 6; |
| 821 | rc = gsm_generate_si(si_tmp, trx->bts, RSL_SYSTEM_INFO_6); |
| 822 | if (rc < 0) |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 823 | goto err_out; |
Harald Welte | 50e7fec | 2009-12-19 21:29:00 +0100 | [diff] [blame] | 824 | DEBUGP(DRR, "SI%2u: %s\n", i, hexdump(si_tmp, rc)); |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 825 | rsl_sacch_filling(trx, RSL_SYSTEM_INFO_6, si_tmp, rc); |
Holger Hans Peter Freyther | 8b457fb | 2009-08-17 06:55:10 +0200 | [diff] [blame] | 826 | |
| 827 | return 0; |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 828 | err_out: |
Harald Welte | b1d4c8e | 2009-12-17 23:10:46 +0100 | [diff] [blame] | 829 | LOGP(DRR, LOGL_ERROR, "Cannot generate SI %u for BTS %u, most likely " |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 830 | "a problem with neighbor cell list generation\n", |
Harald Welte | 152b626 | 2009-12-16 11:57:48 +0100 | [diff] [blame] | 831 | i, trx->bts->nr); |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 832 | return rc; |
Holger Hans Peter Freyther | 8b457fb | 2009-08-17 06:55:10 +0200 | [diff] [blame] | 833 | } |
| 834 | |
| 835 | /* |
| 836 | * Patch the various SYSTEM INFORMATION tables to update |
| 837 | * the LAI |
| 838 | */ |
| 839 | static void patch_nm_tables(struct gsm_bts *bts) |
| 840 | { |
| 841 | u_int8_t arfcn_low = bts->c0->arfcn & 0xff; |
| 842 | u_int8_t arfcn_high = (bts->c0->arfcn >> 8) & 0x0f; |
| 843 | |
| 844 | /* patch ARFCN into BTS Attributes */ |
| 845 | bs11_attr_bts[69] &= 0xf0; |
| 846 | bs11_attr_bts[69] |= arfcn_high; |
| 847 | bs11_attr_bts[70] = arfcn_low; |
| 848 | nanobts_attr_bts[42] &= 0xf0; |
| 849 | nanobts_attr_bts[42] |= arfcn_high; |
| 850 | nanobts_attr_bts[43] = arfcn_low; |
| 851 | |
| 852 | /* patch ARFCN into TRX Attributes */ |
| 853 | bs11_attr_radio[2] &= 0xf0; |
| 854 | bs11_attr_radio[2] |= arfcn_high; |
| 855 | bs11_attr_radio[3] = arfcn_low; |
Holger Hans Peter Freyther | 8b457fb | 2009-08-17 06:55:10 +0200 | [diff] [blame] | 856 | |
Holger Hans Peter Freyther | 95c2290 | 2010-04-25 23:08:39 +0800 | [diff] [blame] | 857 | /* patch the RACH attributes */ |
| 858 | if (bts->rach_b_thresh != -1) { |
| 859 | nanobts_attr_bts[33] = bts->rach_b_thresh & 0xff; |
| 860 | bs11_attr_bts[33] = bts->rach_b_thresh & 0xff; |
| 861 | } |
| 862 | |
| 863 | if (bts->rach_ldavg_slots != -1) { |
| 864 | u_int8_t avg_high = bts->rach_ldavg_slots & 0xff; |
| 865 | u_int8_t avg_low = (bts->rach_ldavg_slots >> 8) & 0x0f; |
| 866 | |
| 867 | nanobts_attr_bts[35] = avg_high; |
| 868 | nanobts_attr_bts[36] = avg_low; |
| 869 | bs11_attr_bts[35] = avg_high; |
| 870 | bs11_attr_bts[36] = avg_low; |
| 871 | } |
| 872 | |
Holger Hans Peter Freyther | 8b457fb | 2009-08-17 06:55:10 +0200 | [diff] [blame] | 873 | /* patch BSIC */ |
| 874 | bs11_attr_bts[1] = bts->bsic; |
Harald Welte | 97a282b | 2010-03-14 15:37:43 +0800 | [diff] [blame] | 875 | nanobts_attr_bts[sizeof(nanobts_attr_bts)-11] = bts->bsic; |
| 876 | |
| 877 | /* patch CGI */ |
| 878 | abis_nm_ipaccess_cgi(nanobts_attr_bts+sizeof(nanobts_attr_bts)-7, bts); |
Holger Hans Peter Freyther | 8b457fb | 2009-08-17 06:55:10 +0200 | [diff] [blame] | 879 | |
| 880 | /* patch the power reduction */ |
| 881 | bs11_attr_radio[5] = bts->c0->max_power_red / 2; |
| 882 | nanobts_attr_radio[1] = bts->c0->max_power_red / 2; |
Harald Welte | 97a282b | 2010-03-14 15:37:43 +0800 | [diff] [blame] | 883 | |
Harald Welte | a5731cf | 2010-03-22 11:48:36 +0800 | [diff] [blame] | 884 | /* patch NSEI */ |
| 885 | nanobts_attr_nse[3] = bts->gprs.nse.nsei >> 8; |
| 886 | nanobts_attr_nse[4] = bts->gprs.nse.nsei & 0xff; |
Harald Welte | 615e956 | 2010-05-11 23:50:21 +0200 | [diff] [blame] | 887 | memcpy(nanobts_attr_nse+8, bts->gprs.nse.timer, |
| 888 | ARRAY_SIZE(bts->gprs.nse.timer)); |
| 889 | memcpy(nanobts_attr_nse+18, bts->gprs.cell.timer, |
| 890 | ARRAY_SIZE(bts->gprs.cell.timer)); |
Harald Welte | a5731cf | 2010-03-22 11:48:36 +0800 | [diff] [blame] | 891 | |
Harald Welte | 97a282b | 2010-03-14 15:37:43 +0800 | [diff] [blame] | 892 | /* patch NSVCI */ |
| 893 | nanobts_attr_nsvc0[3] = bts->gprs.nsvc[0].nsvci >> 8; |
| 894 | nanobts_attr_nsvc0[4] = bts->gprs.nsvc[0].nsvci & 0xff; |
| 895 | |
Harald Welte | af38763 | 2010-03-14 23:30:30 +0800 | [diff] [blame] | 896 | /* patch IP address as SGSN IP */ |
| 897 | *(u_int16_t *)(nanobts_attr_nsvc0+8) = |
| 898 | htons(bts->gprs.nsvc[0].remote_port); |
| 899 | *(u_int32_t *)(nanobts_attr_nsvc0+10) = |
| 900 | htonl(bts->gprs.nsvc[0].remote_ip); |
| 901 | *(u_int16_t *)(nanobts_attr_nsvc0+14) = |
| 902 | htons(bts->gprs.nsvc[0].local_port); |
Harald Welte | 97a282b | 2010-03-14 15:37:43 +0800 | [diff] [blame] | 903 | |
| 904 | /* patch BVCI */ |
| 905 | nanobts_attr_cell[12] = bts->gprs.cell.bvci >> 8; |
| 906 | nanobts_attr_cell[13] = bts->gprs.cell.bvci & 0xff; |
| 907 | /* patch RAC */ |
| 908 | nanobts_attr_cell[3] = bts->gprs.rac; |
| 909 | |
Harald Welte | 439bb82 | 2010-04-18 16:50:11 +0200 | [diff] [blame] | 910 | if (bts->gprs.mode == BTS_GPRS_EGPRS) { |
| 911 | /* patch EGPRS coding schemes MCS 1..9 */ |
| 912 | nanobts_attr_cell[29] = 0x8f; |
| 913 | nanobts_attr_cell[30] = 0xff; |
| 914 | } |
Holger Hans Peter Freyther | 8b457fb | 2009-08-17 06:55:10 +0200 | [diff] [blame] | 915 | } |
| 916 | |
Holger Hans Peter Freyther | 8b457fb | 2009-08-17 06:55:10 +0200 | [diff] [blame] | 917 | static void bootstrap_rsl(struct gsm_bts_trx *trx) |
| 918 | { |
Harald Welte | b1d4c8e | 2009-12-17 23:10:46 +0100 | [diff] [blame] | 919 | LOGP(DRSL, LOGL_NOTICE, "bootstrapping RSL for BTS/TRX (%u/%u) " |
Harald Welte | 19a3f0b | 2009-12-24 13:39:34 +0100 | [diff] [blame] | 920 | "on ARFCN %u using MCC=%u MNC=%u LAC=%u CID=%u BSIC=%u TSC=%u\n", |
| 921 | trx->bts->nr, trx->nr, trx->arfcn, bsc_gsmnet->country_code, |
| 922 | bsc_gsmnet->network_code, trx->bts->location_area_code, |
| 923 | trx->bts->cell_identity, trx->bts->bsic, trx->bts->tsc); |
Holger Hans Peter Freyther | 8b457fb | 2009-08-17 06:55:10 +0200 | [diff] [blame] | 924 | set_system_infos(trx); |
| 925 | } |
| 926 | |
| 927 | void input_event(int event, enum e1inp_sign_type type, struct gsm_bts_trx *trx) |
| 928 | { |
Holger Hans Peter Freyther | 135f797 | 2010-04-15 11:21:02 +0200 | [diff] [blame] | 929 | int ts_no, lchan_no; |
| 930 | |
Holger Hans Peter Freyther | 8b457fb | 2009-08-17 06:55:10 +0200 | [diff] [blame] | 931 | switch (event) { |
| 932 | case EVT_E1_TEI_UP: |
| 933 | switch (type) { |
| 934 | case E1INP_SIGN_OML: |
| 935 | bootstrap_om(trx->bts); |
| 936 | break; |
| 937 | case E1INP_SIGN_RSL: |
| 938 | bootstrap_rsl(trx); |
| 939 | break; |
| 940 | default: |
| 941 | break; |
| 942 | } |
| 943 | break; |
| 944 | case EVT_E1_TEI_DN: |
Holger Hans Peter Freyther | 135f797 | 2010-04-15 11:21:02 +0200 | [diff] [blame] | 945 | LOGP(DMI, LOGL_ERROR, "Lost some E1 TEI link: %d %p\n", type, trx); |
| 946 | |
Holger Hans Peter Freyther | bb110f9 | 2010-04-12 10:45:52 +0200 | [diff] [blame] | 947 | if (type == E1INP_SIGN_OML) |
| 948 | counter_inc(trx->bts->network->stats.bts.oml_fail); |
| 949 | else if (type == E1INP_SIGN_RSL) |
| 950 | counter_inc(trx->bts->network->stats.bts.rsl_fail); |
| 951 | |
Holger Hans Peter Freyther | 135f797 | 2010-04-15 11:21:02 +0200 | [diff] [blame] | 952 | /* |
| 953 | * free all allocated channels. change the nm_state so the |
| 954 | * trx and trx_ts becomes unusable and chan_alloc.c can not |
| 955 | * allocate from it. |
| 956 | */ |
| 957 | for (ts_no = 0; ts_no < ARRAY_SIZE(trx->ts); ++ts_no) { |
| 958 | struct gsm_bts_trx_ts *ts = &trx->ts[ts_no]; |
| 959 | |
| 960 | for (lchan_no = 0; lchan_no < ARRAY_SIZE(ts->lchan); ++lchan_no) { |
| 961 | if (ts->lchan[lchan_no].state != GSM_LCHAN_NONE) |
| 962 | lchan_free(&ts->lchan[lchan_no]); |
| 963 | lchan_reset(&ts->lchan[lchan_no]); |
| 964 | } |
| 965 | |
| 966 | ts->nm_state.operational = 0; |
| 967 | ts->nm_state.availability = 0; |
| 968 | } |
| 969 | |
| 970 | trx->nm_state.operational = 0; |
| 971 | trx->nm_state.availability = 0; |
| 972 | trx->bb_transc.nm_state.operational = 0; |
| 973 | trx->bb_transc.nm_state.availability = 0; |
Holger Hans Peter Freyther | 8b457fb | 2009-08-17 06:55:10 +0200 | [diff] [blame] | 974 | break; |
| 975 | default: |
| 976 | break; |
| 977 | } |
| 978 | } |
| 979 | |
| 980 | static int bootstrap_bts(struct gsm_bts *bts) |
| 981 | { |
Sylvain Munaut | 50f81b0 | 2010-04-28 21:31:29 +0200 | [diff] [blame] | 982 | int i, n; |
| 983 | |
Mike Haben | e2d8227 | 2009-10-02 12:19:34 +0100 | [diff] [blame] | 984 | switch (bts->band) { |
| 985 | case GSM_BAND_1800: |
Holger Hans Peter Freyther | 8b457fb | 2009-08-17 06:55:10 +0200 | [diff] [blame] | 986 | if (bts->c0->arfcn < 512 || bts->c0->arfcn > 885) { |
Harald Welte | b1d4c8e | 2009-12-17 23:10:46 +0100 | [diff] [blame] | 987 | LOGP(DNM, LOGL_ERROR, "GSM1800 channel must be between 512-885.\n"); |
Holger Hans Peter Freyther | 8b457fb | 2009-08-17 06:55:10 +0200 | [diff] [blame] | 988 | return -EINVAL; |
| 989 | } |
| 990 | break; |
Mike Haben | e2d8227 | 2009-10-02 12:19:34 +0100 | [diff] [blame] | 991 | case GSM_BAND_1900: |
| 992 | if (bts->c0->arfcn < 512 || bts->c0->arfcn > 810) { |
Harald Welte | b1d4c8e | 2009-12-17 23:10:46 +0100 | [diff] [blame] | 993 | LOGP(DNM, LOGL_ERROR, "GSM1900 channel must be between 512-810.\n"); |
Mike Haben | e2d8227 | 2009-10-02 12:19:34 +0100 | [diff] [blame] | 994 | return -EINVAL; |
| 995 | } |
| 996 | break; |
| 997 | case GSM_BAND_900: |
Holger Hans Peter Freyther | fb0b6fc | 2010-02-09 15:44:14 +0100 | [diff] [blame] | 998 | if (bts->c0->arfcn < 1 || |
| 999 | (bts->c0->arfcn > 124 && bts->c0->arfcn < 955) || |
| 1000 | bts->c0->arfcn > 1023) { |
| 1001 | LOGP(DNM, LOGL_ERROR, "GSM900 channel must be between 1-124, 955-1023.\n"); |
Holger Hans Peter Freyther | 8b457fb | 2009-08-17 06:55:10 +0200 | [diff] [blame] | 1002 | return -EINVAL; |
| 1003 | } |
| 1004 | break; |
Mike Haben | e2d8227 | 2009-10-02 12:19:34 +0100 | [diff] [blame] | 1005 | default: |
Harald Welte | b1d4c8e | 2009-12-17 23:10:46 +0100 | [diff] [blame] | 1006 | LOGP(DNM, LOGL_ERROR, "Unsupported frequency band.\n"); |
Holger Hans Peter Freyther | 8b457fb | 2009-08-17 06:55:10 +0200 | [diff] [blame] | 1007 | return -EINVAL; |
| 1008 | } |
| 1009 | |
Harald Welte | d6aa524 | 2009-12-12 13:44:19 +0100 | [diff] [blame] | 1010 | if (bts->network->auth_policy == GSM_AUTH_POLICY_ACCEPT_ALL && |
Harald Welte | 7135501 | 2009-12-21 23:08:18 +0100 | [diff] [blame] | 1011 | !bts->si_common.rach_control.cell_bar) |
Harald Welte | a992a36 | 2009-12-21 23:36:45 +0100 | [diff] [blame] | 1012 | LOGP(DNM, LOGL_ERROR, "\nWARNING: You are running an 'accept-all' " |
Harald Welte | d6aa524 | 2009-12-12 13:44:19 +0100 | [diff] [blame] | 1013 | "network on a BTS that is not barred. This " |
| 1014 | "configuration is likely to interfere with production " |
| 1015 | "GSM networks and should only be used in a RF " |
| 1016 | "shielded environment such as a faraday cage!\n\n"); |
| 1017 | |
Holger Hans Peter Freyther | 8b457fb | 2009-08-17 06:55:10 +0200 | [diff] [blame] | 1018 | /* Control Channel Description */ |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 1019 | bts->si_common.chan_desc.att = 1; |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 1020 | bts->si_common.chan_desc.bs_pa_mfrms = RSL_BS_PA_MFRMS_5; |
Holger Hans Peter Freyther | a581136 | 2010-04-30 13:32:05 +0800 | [diff] [blame] | 1021 | /* T3212 is set from vty/config */ |
Sylvain Munaut | 50f81b0 | 2010-04-28 21:31:29 +0200 | [diff] [blame] | 1022 | |
Holger Hans Peter Freyther | a581136 | 2010-04-30 13:32:05 +0800 | [diff] [blame] | 1023 | /* Set ccch config by looking at ts config */ |
Sylvain Munaut | 50f81b0 | 2010-04-28 21:31:29 +0200 | [diff] [blame] | 1024 | for (n=0, i=0; i<8; i++) |
| 1025 | n += bts->c0->ts[i].pchan == GSM_PCHAN_CCCH ? 1 : 0; |
| 1026 | |
| 1027 | switch (n) { |
| 1028 | case 0: |
| 1029 | bts->si_common.chan_desc.ccch_conf = RSL_BCCH_CCCH_CONF_1_C; |
| 1030 | break; |
| 1031 | case 1: |
| 1032 | bts->si_common.chan_desc.ccch_conf = RSL_BCCH_CCCH_CONF_1_NC; |
| 1033 | break; |
| 1034 | case 2: |
| 1035 | bts->si_common.chan_desc.ccch_conf = RSL_BCCH_CCCH_CONF_2_NC; |
| 1036 | break; |
| 1037 | case 3: |
| 1038 | bts->si_common.chan_desc.ccch_conf = RSL_BCCH_CCCH_CONF_3_NC; |
| 1039 | break; |
| 1040 | case 4: |
| 1041 | bts->si_common.chan_desc.ccch_conf = RSL_BCCH_CCCH_CONF_4_NC; |
| 1042 | break; |
| 1043 | default: |
| 1044 | LOGP(DNM, LOGL_ERROR, "Unsupported CCCH timeslot configuration\n"); |
| 1045 | return -EINVAL; |
| 1046 | } |
Holger Hans Peter Freyther | 8b457fb | 2009-08-17 06:55:10 +0200 | [diff] [blame] | 1047 | |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 1048 | /* some defaults for our system information */ |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 1049 | bts->si_common.cell_options.radio_link_timeout = 2; /* 12 */ |
| 1050 | bts->si_common.cell_options.dtx = 2; /* MS shall not use upplink DTX */ |
| 1051 | bts->si_common.cell_options.pwrc = 0; /* PWRC not set */ |
| 1052 | |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 1053 | bts->si_common.cell_sel_par.acs = 0; |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 1054 | |
| 1055 | bts->si_common.ncc_permitted = 0xff; |
| 1056 | |
Holger Hans Peter Freyther | 8b457fb | 2009-08-17 06:55:10 +0200 | [diff] [blame] | 1057 | paging_init(bts); |
| 1058 | |
| 1059 | return 0; |
| 1060 | } |
| 1061 | |
| 1062 | int bsc_bootstrap_network(int (*mncc_recv)(struct gsm_network *, int, void *), |
| 1063 | const char *config_file) |
| 1064 | { |
Harald Welte | dcccb18 | 2010-05-16 20:52:23 +0200 | [diff] [blame] | 1065 | struct telnet_connection dummy_conn; |
Holger Hans Peter Freyther | 8b457fb | 2009-08-17 06:55:10 +0200 | [diff] [blame] | 1066 | struct gsm_bts *bts; |
| 1067 | int rc; |
| 1068 | |
| 1069 | /* initialize our data structures */ |
| 1070 | bsc_gsmnet = gsm_network_init(1, 1, mncc_recv); |
| 1071 | if (!bsc_gsmnet) |
| 1072 | return -ENOMEM; |
| 1073 | |
| 1074 | bsc_gsmnet->name_long = talloc_strdup(bsc_gsmnet, "OpenBSC"); |
| 1075 | bsc_gsmnet->name_short = talloc_strdup(bsc_gsmnet, "OpenBSC"); |
| 1076 | |
Harald Welte | dcccb18 | 2010-05-16 20:52:23 +0200 | [diff] [blame] | 1077 | /* our vty command code expects vty->priv to point to a telnet_connection */ |
| 1078 | dummy_conn.priv = bsc_gsmnet; |
| 1079 | rc = vty_read_config_file(config_file, &dummy_conn); |
Holger Hans Peter Freyther | 8b457fb | 2009-08-17 06:55:10 +0200 | [diff] [blame] | 1080 | if (rc < 0) { |
Harald Welte | b1d4c8e | 2009-12-17 23:10:46 +0100 | [diff] [blame] | 1081 | LOGP(DNM, LOGL_FATAL, "Failed to parse the config file: '%s'\n", config_file); |
Holger Hans Peter Freyther | 8b457fb | 2009-08-17 06:55:10 +0200 | [diff] [blame] | 1082 | return rc; |
| 1083 | } |
| 1084 | |
Harald Welte | dcccb18 | 2010-05-16 20:52:23 +0200 | [diff] [blame] | 1085 | rc = telnet_init(tall_bsc_ctx, bsc_gsmnet, 4242); |
| 1086 | if (rc < 0) |
| 1087 | return rc; |
| 1088 | |
Holger Hans Peter Freyther | 8b457fb | 2009-08-17 06:55:10 +0200 | [diff] [blame] | 1089 | register_signal_handler(SS_NM, nm_sig_cb, NULL); |
| 1090 | |
| 1091 | llist_for_each_entry(bts, &bsc_gsmnet->bts_list, list) { |
| 1092 | bootstrap_bts(bts); |
| 1093 | if (!is_ipaccess_bts(bts)) |
| 1094 | rc = e1_reconfig_bts(bts); |
| 1095 | |
| 1096 | if (rc < 0) |
| 1097 | exit (1); |
| 1098 | } |
| 1099 | |
| 1100 | /* initialize nanoBTS support omce */ |
| 1101 | rc = ipaccess_setup(bsc_gsmnet); |
| 1102 | |
| 1103 | return 0; |
| 1104 | } |