Harald Welte | 59698fb | 2010-01-10 18:01:52 +0100 | [diff] [blame] | 1 | /* Siemens BS-11 specific code */ |
| 2 | |
| 3 | /* (C) 2009-2010 by Harald Welte <laforge@gnumonks.org> |
| 4 | * |
| 5 | * All Rights Reserved |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
Harald Welte | 0e3e88e | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 8 | * it under the terms of the GNU Affero General Public License as published by |
| 9 | * the Free Software Foundation; either version 3 of the License, or |
Harald Welte | 59698fb | 2010-01-10 18:01:52 +0100 | [diff] [blame] | 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 |
Harald Welte | 0e3e88e | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 15 | * GNU Affero General Public License for more details. |
Harald Welte | 59698fb | 2010-01-10 18:01:52 +0100 | [diff] [blame] | 16 | * |
Harald Welte | 0e3e88e | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 17 | * You should have received a copy of the GNU Affero General Public License |
| 18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
Harald Welte | 59698fb | 2010-01-10 18:01:52 +0100 | [diff] [blame] | 19 | * |
| 20 | */ |
| 21 | |
Harald Welte | 59698fb | 2010-01-10 18:01:52 +0100 | [diff] [blame] | 22 | |
Pablo Neira Ayuso | dd5fff4 | 2011-03-22 16:47:59 +0100 | [diff] [blame] | 23 | #include <osmocom/gsm/tlv.h> |
Harald Welte | 4c826f7 | 2011-01-14 15:55:42 +0100 | [diff] [blame] | 24 | |
| 25 | #include <openbsc/debug.h> |
| 26 | #include <openbsc/gsm_data.h> |
Harald Welte | 59698fb | 2010-01-10 18:01:52 +0100 | [diff] [blame] | 27 | #include <openbsc/abis_nm.h> |
Pablo Neira Ayuso | 42e41df | 2011-08-17 22:44:07 +0200 | [diff] [blame] | 28 | #include <osmocom/abis/e1_input.h> |
Harald Welte | 4c826f7 | 2011-01-14 15:55:42 +0100 | [diff] [blame] | 29 | #include <openbsc/signal.h> |
Harald Welte | 59698fb | 2010-01-10 18:01:52 +0100 | [diff] [blame] | 30 | |
Pablo Neira Ayuso | 5bd96a7 | 2011-05-14 11:32:48 +0200 | [diff] [blame] | 31 | static int bts_model_bs11_start(struct gsm_network *net); |
| 32 | |
Pablo Neira Ayuso | 42e41df | 2011-08-17 22:44:07 +0200 | [diff] [blame] | 33 | static void bts_model_bs11_e1line_bind_ops(struct e1inp_line *line) |
| 34 | { |
| 35 | e1inp_line_bind_ops(line, &bts_isdn_e1inp_line_ops); |
| 36 | } |
| 37 | |
Harald Welte | 59698fb | 2010-01-10 18:01:52 +0100 | [diff] [blame] | 38 | static struct gsm_bts_model model_bs11 = { |
| 39 | .type = GSM_BTS_TYPE_BS11, |
Harald Welte | 9480980 | 2011-02-12 12:29:21 +0100 | [diff] [blame] | 40 | .name = "bs11", |
Pablo Neira Ayuso | 5bd96a7 | 2011-05-14 11:32:48 +0200 | [diff] [blame] | 41 | .start = bts_model_bs11_start, |
Harald Welte | 9480980 | 2011-02-12 12:29:21 +0100 | [diff] [blame] | 42 | .oml_rcvmsg = &abis_nm_rcvmsg, |
Pablo Neira Ayuso | 42e41df | 2011-08-17 22:44:07 +0200 | [diff] [blame] | 43 | .e1line_bind_ops = bts_model_bs11_e1line_bind_ops, |
Harald Welte | 59698fb | 2010-01-10 18:01:52 +0100 | [diff] [blame] | 44 | .nm_att_tlvdef = { |
| 45 | .def = { |
| 46 | [NM_ATT_AVAIL_STATUS] = { TLV_TYPE_TLV }, |
| 47 | /* BS11 specifics */ |
| 48 | [NM_ATT_BS11_ESN_FW_CODE_NO] = { TLV_TYPE_TLV }, |
| 49 | [NM_ATT_BS11_ESN_HW_CODE_NO] = { TLV_TYPE_TLV }, |
| 50 | [NM_ATT_BS11_ESN_PCB_SERIAL] = { TLV_TYPE_TLV }, |
| 51 | [NM_ATT_BS11_BOOT_SW_VERS] = { TLV_TYPE_TLV }, |
| 52 | [0xd5] = { TLV_TYPE_TLV }, |
| 53 | [0xa8] = { TLV_TYPE_TLV }, |
| 54 | [NM_ATT_BS11_PASSWORD] = { TLV_TYPE_TLV }, |
| 55 | [NM_ATT_BS11_TXPWR] = { TLV_TYPE_TLV }, |
| 56 | [NM_ATT_BS11_RSSI_OFFS] = { TLV_TYPE_TLV }, |
| 57 | [NM_ATT_BS11_LINE_CFG] = { TLV_TYPE_TV }, |
| 58 | [NM_ATT_BS11_L1_PROT_TYPE] = { TLV_TYPE_TV }, |
| 59 | [NM_ATT_BS11_BIT_ERR_THESH] = { TLV_TYPE_FIXED, 2 }, |
| 60 | [NM_ATT_BS11_DIVERSITY] = { TLV_TYPE_TLV }, |
| 61 | [NM_ATT_BS11_LMT_LOGON_SESSION]={ TLV_TYPE_TLV }, |
| 62 | [NM_ATT_BS11_LMT_LOGIN_TIME] = { TLV_TYPE_TLV }, |
| 63 | [NM_ATT_BS11_LMT_USER_ACC_LEV] ={ TLV_TYPE_TLV }, |
| 64 | [NM_ATT_BS11_LMT_USER_NAME] = { TLV_TYPE_TLV }, |
| 65 | [NM_ATT_BS11_BTS_STATE] = { TLV_TYPE_TLV }, |
| 66 | [NM_ATT_BS11_E1_STATE] = { TLV_TYPE_TLV }, |
| 67 | [NM_ATT_BS11_PLL_MODE] = { TLV_TYPE_TLV }, |
| 68 | [NM_ATT_BS11_PLL] = { TLV_TYPE_TLV }, |
| 69 | [NM_ATT_BS11_CCLK_ACCURACY] = { TLV_TYPE_TV }, |
| 70 | [NM_ATT_BS11_CCLK_TYPE] = { TLV_TYPE_TV }, |
| 71 | [0x95] = { TLV_TYPE_FIXED, 2 }, |
| 72 | }, |
| 73 | }, |
| 74 | }; |
| 75 | |
Harald Welte | 4c826f7 | 2011-01-14 15:55:42 +0100 | [diff] [blame] | 76 | /* The following definitions are for OM and NM packets that we cannot yet |
| 77 | * generate by code but we just pass on */ |
| 78 | |
| 79 | // BTS Site Manager, SET ATTRIBUTES |
| 80 | |
| 81 | /* |
| 82 | Object Class: BTS Site Manager |
| 83 | Instance 1: FF |
| 84 | Instance 2: FF |
| 85 | Instance 3: FF |
| 86 | SET ATTRIBUTES |
| 87 | sAbisExternalTime: 2007/09/08 14:36:11 |
| 88 | omLAPDRelTimer: 30sec |
| 89 | shortLAPDIntTimer: 5sec |
| 90 | emergencyTimer1: 10 minutes |
| 91 | emergencyTimer2: 0 minutes |
| 92 | */ |
| 93 | |
| 94 | unsigned char msg_1[] = |
| 95 | { |
| 96 | NM_MT_BS11_SET_ATTR, NM_OC_SITE_MANAGER, 0xFF, 0xFF, 0xFF, |
| 97 | NM_ATT_BS11_ABIS_EXT_TIME, 0x07, |
| 98 | 0xD7, 0x09, 0x08, 0x0E, 0x24, 0x0B, 0xCE, |
| 99 | 0x02, |
| 100 | 0x00, 0x1E, |
| 101 | NM_ATT_BS11_SH_LAPD_INT_TIMER, |
| 102 | 0x01, 0x05, |
| 103 | 0x42, 0x02, 0x00, 0x0A, |
| 104 | 0x44, 0x02, 0x00, 0x00 |
| 105 | }; |
| 106 | |
| 107 | // BTS, SET BTS ATTRIBUTES |
| 108 | |
| 109 | /* |
| 110 | Object Class: BTS |
| 111 | BTS relat. Number: 0 |
| 112 | Instance 2: FF |
| 113 | Instance 3: FF |
| 114 | SET BTS ATTRIBUTES |
| 115 | bsIdentityCode / BSIC: |
| 116 | PLMN_colour_code: 7h |
| 117 | BS_colour_code: 7h |
| 118 | BTS Air Timer T3105: 4 ,unit 10 ms |
| 119 | btsIsHopping: FALSE |
| 120 | periodCCCHLoadIndication: 1sec |
| 121 | thresholdCCCHLoadIndication: 0% |
| 122 | cellAllocationNumber: 00h = GSM 900 |
| 123 | enableInterferenceClass: 00h = Disabled |
| 124 | fACCHQual: 6 (FACCH stealing flags minus 1) |
| 125 | intaveParameter: 31 SACCH multiframes |
| 126 | interferenceLevelBoundaries: |
| 127 | Interference Boundary 1: 0Ah |
| 128 | Interference Boundary 2: 0Fh |
| 129 | Interference Boundary 3: 14h |
| 130 | Interference Boundary 4: 19h |
| 131 | Interference Boundary 5: 1Eh |
| 132 | mSTxPwrMax: 11 |
| 133 | GSM range: 2=39dBm, 15=13dBm, stepsize 2 dBm |
| 134 | DCS1800 range: 0=30dBm, 15=0dBm, stepsize 2 dBm |
| 135 | PCS1900 range: 0=30dBm, 15=0dBm, stepsize 2 dBm |
| 136 | 30=33dBm, 31=32dBm |
| 137 | ny1: |
| 138 | Maximum number of repetitions for PHYSICAL INFORMATION message (GSM 04.08): 20 |
| 139 | powerOutputThresholds: |
| 140 | Out Power Fault Threshold: -10 dB |
| 141 | Red Out Power Threshold: - 6 dB |
| 142 | Excessive Out Power Threshold: 5 dB |
| 143 | rACHBusyThreshold: -127 dBm |
| 144 | rACHLoadAveragingSlots: 250 ,number of RACH burst periods |
| 145 | rfResourceIndicationPeriod: 125 SACCH multiframes |
| 146 | T200: |
| 147 | SDCCH: 044 in 5 ms |
| 148 | FACCH/Full rate: 031 in 5 ms |
| 149 | FACCH/Half rate: 041 in 5 ms |
| 150 | SACCH with TCH SAPI0: 090 in 10 ms |
| 151 | SACCH with SDCCH: 090 in 10 ms |
| 152 | SDCCH with SAPI3: 090 in 5 ms |
| 153 | SACCH with TCH SAPI3: 135 in 10 ms |
| 154 | tSync: 9000 units of 10 msec |
| 155 | tTrau: 9000 units of 10 msec |
| 156 | enableUmLoopTest: 00h = disabled |
| 157 | enableExcessiveDistance: 00h = Disabled |
| 158 | excessiveDistance: 64km |
| 159 | hoppingMode: 00h = baseband hopping |
| 160 | cellType: 00h = Standard Cell |
| 161 | BCCH ARFCN / bCCHFrequency: 1 |
| 162 | */ |
| 163 | |
| 164 | static unsigned char bs11_attr_bts[] = |
| 165 | { |
| 166 | NM_ATT_BSIC, HARDCODED_BSIC, |
| 167 | NM_ATT_BTS_AIR_TIMER, 0x04, |
| 168 | NM_ATT_BS11_BTSLS_HOPPING, 0x00, |
| 169 | NM_ATT_CCCH_L_I_P, 0x01, |
| 170 | NM_ATT_CCCH_L_T, 0x00, |
| 171 | NM_ATT_BS11_CELL_ALLOC_NR, NM_BS11_CANR_GSM, |
| 172 | NM_ATT_BS11_ENA_INTERF_CLASS, 0x01, |
| 173 | NM_ATT_BS11_FACCH_QUAL, 0x06, |
| 174 | /* interference avg. period in numbers of SACCH multifr */ |
| 175 | NM_ATT_INTAVE_PARAM, 0x1F, |
| 176 | NM_ATT_INTERF_BOUND, 0x0A, 0x0F, 0x14, 0x19, 0x1E, 0x7B, |
| 177 | NM_ATT_CCCH_L_T, 0x23, |
| 178 | NM_ATT_GSM_TIME, 0x28, 0x00, |
| 179 | NM_ATT_ADM_STATE, 0x03, |
| 180 | NM_ATT_RACH_B_THRESH, 0x7F, |
| 181 | NM_ATT_LDAVG_SLOTS, 0x00, 0xFA, |
| 182 | NM_ATT_BS11_RF_RES_IND_PER, 0x7D, |
| 183 | NM_ATT_T200, 0x2C, 0x1F, 0x29, 0x5A, 0x5A, 0x5A, 0x87, |
| 184 | NM_ATT_BS11_TSYNC, 0x23, 0x28, |
| 185 | NM_ATT_BS11_TTRAU, 0x23, 0x28, |
| 186 | NM_ATT_TEST_DUR, 0x01, 0x00, |
| 187 | NM_ATT_OUTST_ALARM, 0x01, 0x00, |
| 188 | NM_ATT_BS11_EXCESSIVE_DISTANCE, 0x01, 0x40, |
| 189 | NM_ATT_BS11_HOPPING_MODE, 0x01, 0x00, |
| 190 | NM_ATT_BS11_PLL, 0x01, 0x00, |
| 191 | NM_ATT_BCCH_ARFCN, 0x00, HARDCODED_ARFCN/*0x01*/, |
| 192 | }; |
| 193 | |
| 194 | // Handover Recognition, SET ATTRIBUTES |
| 195 | |
| 196 | /* |
| 197 | Illegal Contents GSM Formatted O&M Msg |
| 198 | Object Class: Handover Recognition |
| 199 | BTS relat. Number: 0 |
| 200 | Instance 2: FF |
| 201 | Instance 3: FF |
| 202 | SET ATTRIBUTES |
| 203 | enableDelayPowerBudgetHO: 00h = Disabled |
| 204 | enableDistanceHO: 00h = Disabled |
| 205 | enableInternalInterCellHandover: 00h = Disabled |
| 206 | enableInternalIntraCellHandover: 00h = Disabled |
| 207 | enablePowerBudgetHO: 00h = Disabled |
| 208 | enableRXLEVHO: 00h = Disabled |
| 209 | enableRXQUALHO: 00h = Disabled |
| 210 | hoAveragingDistance: 8 SACCH multiframes |
| 211 | hoAveragingLev: |
| 212 | A_LEV_HO: 8 SACCH multiframes |
| 213 | W_LEV_HO: 1 SACCH multiframes |
| 214 | hoAveragingPowerBudget: 16 SACCH multiframes |
| 215 | hoAveragingQual: |
| 216 | A_QUAL_HO: 8 SACCH multiframes |
| 217 | W_QUAL_HO: 2 SACCH multiframes |
| 218 | hoLowerThresholdLevDL: (10 - 110) dBm |
| 219 | hoLowerThresholdLevUL: (5 - 110) dBm |
| 220 | hoLowerThresholdQualDL: 06h = 6.4% < BER < 12.8% |
| 221 | hoLowerThresholdQualUL: 06h = 6.4% < BER < 12.8% |
| 222 | hoThresholdLevDLintra : (20 - 110) dBm |
| 223 | hoThresholdLevULintra: (20 - 110) dBm |
| 224 | hoThresholdMsRangeMax: 20 km |
| 225 | nCell: 06h |
| 226 | timerHORequest: 3 ,unit 2 SACCH multiframes |
| 227 | */ |
| 228 | |
| 229 | unsigned char msg_3[] = |
| 230 | { |
| 231 | NM_MT_BS11_SET_ATTR, NM_OC_BS11_HANDOVER, 0x00, 0xFF, 0xFF, |
| 232 | 0xD0, 0x00, /* enableDelayPowerBudgetHO */ |
| 233 | 0x64, 0x00, /* enableDistanceHO */ |
| 234 | 0x67, 0x00, /* enableInternalInterCellHandover */ |
| 235 | 0x68, 0x00, /* enableInternalInterCellHandover */ |
| 236 | 0x6A, 0x00, /* enablePowerBudgetHO */ |
| 237 | 0x6C, 0x00, /* enableRXLEVHO */ |
| 238 | 0x6D, 0x00, /* enableRXQUALHO */ |
| 239 | 0x6F, 0x08, /* hoAveragingDistance */ |
| 240 | 0x70, 0x08, 0x01, /* hoAveragingLev */ |
| 241 | 0x71, 0x10, 0x10, 0x10, |
| 242 | 0x72, 0x08, 0x02, /* hoAveragingQual */ |
| 243 | 0x73, 0x0A, /* hoLowerThresholdLevDL */ |
| 244 | 0x74, 0x05, /* hoLowerThresholdLevUL */ |
| 245 | 0x75, 0x06, /* hoLowerThresholdQualDL */ |
| 246 | 0x76, 0x06, /* hoLowerThresholdQualUL */ |
| 247 | 0x78, 0x14, /* hoThresholdLevDLintra */ |
| 248 | 0x79, 0x14, /* hoThresholdLevULintra */ |
| 249 | 0x7A, 0x14, /* hoThresholdMsRangeMax */ |
| 250 | 0x7D, 0x06, /* nCell */ |
| 251 | NM_ATT_BS11_TIMER_HO_REQUEST, 0x03, |
| 252 | 0x20, 0x01, 0x00, |
| 253 | 0x45, 0x01, 0x00, |
| 254 | 0x48, 0x01, 0x00, |
| 255 | 0x5A, 0x01, 0x00, |
| 256 | 0x5B, 0x01, 0x05, |
| 257 | 0x5E, 0x01, 0x1A, |
| 258 | 0x5F, 0x01, 0x20, |
| 259 | 0x9D, 0x01, 0x00, |
| 260 | 0x47, 0x01, 0x00, |
| 261 | 0x5C, 0x01, 0x64, |
| 262 | 0x5D, 0x01, 0x1E, |
| 263 | 0x97, 0x01, 0x20, |
| 264 | 0xF7, 0x01, 0x3C, |
| 265 | }; |
| 266 | |
| 267 | // Power Control, SET ATTRIBUTES |
| 268 | |
| 269 | /* |
| 270 | Object Class: Power Control |
| 271 | BTS relat. Number: 0 |
| 272 | Instance 2: FF |
| 273 | Instance 3: FF |
| 274 | SET ATTRIBUTES |
| 275 | enableMsPowerControl: 00h = Disabled |
| 276 | enablePowerControlRLFW: 00h = Disabled |
| 277 | pcAveragingLev: |
| 278 | A_LEV_PC: 4 SACCH multiframes |
| 279 | W_LEV_PC: 1 SACCH multiframes |
| 280 | pcAveragingQual: |
| 281 | A_QUAL_PC: 4 SACCH multiframes |
| 282 | W_QUAL_PC: 2 SACCH multiframes |
| 283 | pcLowerThresholdLevDL: 0Fh |
| 284 | pcLowerThresholdLevUL: 0Ah |
| 285 | pcLowerThresholdQualDL: 05h = 3.2% < BER < 6.4% |
| 286 | pcLowerThresholdQualUL: 05h = 3.2% < BER < 6.4% |
| 287 | pcRLFThreshold: 0Ch |
| 288 | pcUpperThresholdLevDL: 14h |
| 289 | pcUpperThresholdLevUL: 0Fh |
| 290 | pcUpperThresholdQualDL: 04h = 1.6% < BER < 3.2% |
| 291 | pcUpperThresholdQualUL: 04h = 1.6% < BER < 3.2% |
| 292 | powerConfirm: 2 ,unit 2 SACCH multiframes |
| 293 | powerControlInterval: 2 ,unit 2 SACCH multiframes |
| 294 | powerIncrStepSize: 02h = 4 dB |
| 295 | powerRedStepSize: 01h = 2 dB |
| 296 | radioLinkTimeoutBs: 64 SACCH multiframes |
| 297 | enableBSPowerControl: 00h = disabled |
| 298 | */ |
| 299 | |
| 300 | unsigned char msg_4[] = |
| 301 | { |
| 302 | NM_MT_BS11_SET_ATTR, NM_OC_BS11_PWR_CTRL, 0x00, 0xFF, 0xFF, |
| 303 | NM_ATT_BS11_ENA_MS_PWR_CTRL, 0x00, |
| 304 | NM_ATT_BS11_ENA_PWR_CTRL_RLFW, 0x00, |
| 305 | 0x7E, 0x04, 0x01, /* pcAveragingLev */ |
| 306 | 0x7F, 0x04, 0x02, /* pcAveragingQual */ |
| 307 | 0x80, 0x0F, /* pcLowerThresholdLevDL */ |
| 308 | 0x81, 0x0A, /* pcLowerThresholdLevUL */ |
| 309 | 0x82, 0x05, /* pcLowerThresholdQualDL */ |
| 310 | 0x83, 0x05, /* pcLowerThresholdQualUL */ |
| 311 | 0x84, 0x0C, /* pcRLFThreshold */ |
| 312 | 0x85, 0x14, /* pcUpperThresholdLevDL */ |
| 313 | 0x86, 0x0F, /* pcUpperThresholdLevUL */ |
| 314 | 0x87, 0x04, /* pcUpperThresholdQualDL */ |
| 315 | 0x88, 0x04, /* pcUpperThresholdQualUL */ |
| 316 | 0x89, 0x02, /* powerConfirm */ |
| 317 | 0x8A, 0x02, /* powerConfirmInterval */ |
| 318 | 0x8B, 0x02, /* powerIncrStepSize */ |
| 319 | 0x8C, 0x01, /* powerRedStepSize */ |
| 320 | 0x8D, 0x40, /* radioLinkTimeoutBs */ |
| 321 | 0x65, 0x01, 0x00 // set to 0x01 to enable BSPowerControl |
| 322 | }; |
| 323 | |
| 324 | |
| 325 | // Transceiver, SET TRX ATTRIBUTES (TRX 0) |
| 326 | |
| 327 | /* |
| 328 | Object Class: Transceiver |
| 329 | BTS relat. Number: 0 |
| 330 | Tranceiver number: 0 |
| 331 | Instance 3: FF |
| 332 | SET TRX ATTRIBUTES |
| 333 | aRFCNList (HEX): 0001 |
| 334 | txPwrMaxReduction: 00h = 30dB |
| 335 | radioMeasGran: 254 SACCH multiframes |
| 336 | radioMeasRep: 01h = enabled |
| 337 | memberOfEmergencyConfig: 01h = TRUE |
| 338 | trxArea: 00h = TRX doesn't belong to a concentric cell |
| 339 | */ |
| 340 | |
| 341 | static unsigned char bs11_attr_radio[] = |
| 342 | { |
| 343 | NM_ATT_ARFCN_LIST, 0x01, 0x00, HARDCODED_ARFCN /*0x01*/, |
| 344 | NM_ATT_RF_MAXPOWR_R, 0x00, |
| 345 | NM_ATT_BS11_RADIO_MEAS_GRAN, 0x01, 0x05, |
| 346 | NM_ATT_BS11_RADIO_MEAS_REP, 0x01, 0x01, |
| 347 | NM_ATT_BS11_EMRG_CFG_MEMBER, 0x01, 0x01, |
| 348 | NM_ATT_BS11_TRX_AREA, 0x01, 0x00, |
| 349 | }; |
| 350 | |
| 351 | /* |
| 352 | * Patch the various SYSTEM INFORMATION tables to update |
| 353 | * the LAI |
| 354 | */ |
| 355 | static void patch_nm_tables(struct gsm_bts *bts) |
| 356 | { |
Holger Hans Peter Freyther | 7eb8a9a | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 357 | uint8_t arfcn_low = bts->c0->arfcn & 0xff; |
| 358 | uint8_t arfcn_high = (bts->c0->arfcn >> 8) & 0x0f; |
Harald Welte | 4c826f7 | 2011-01-14 15:55:42 +0100 | [diff] [blame] | 359 | |
Harald Welte | 9b77f61 | 2012-06-03 13:01:47 +0200 | [diff] [blame] | 360 | /* T3105 attribute in units of 10ms */ |
| 361 | bs11_attr_bts[2] = bts->network->T3105 / 10; |
| 362 | |
Harald Welte | 4c826f7 | 2011-01-14 15:55:42 +0100 | [diff] [blame] | 363 | /* patch ARFCN into BTS Attributes */ |
| 364 | bs11_attr_bts[69] &= 0xf0; |
| 365 | bs11_attr_bts[69] |= arfcn_high; |
| 366 | bs11_attr_bts[70] = arfcn_low; |
| 367 | |
| 368 | /* patch ARFCN into TRX Attributes */ |
| 369 | bs11_attr_radio[2] &= 0xf0; |
| 370 | bs11_attr_radio[2] |= arfcn_high; |
| 371 | bs11_attr_radio[3] = arfcn_low; |
| 372 | |
| 373 | /* patch the RACH attributes */ |
| 374 | if (bts->rach_b_thresh != -1) |
| 375 | bs11_attr_bts[33] = bts->rach_b_thresh & 0xff; |
| 376 | |
| 377 | if (bts->rach_ldavg_slots != -1) { |
Holger Hans Peter Freyther | 7eb8a9a | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 378 | uint8_t avg_high = bts->rach_ldavg_slots & 0xff; |
| 379 | uint8_t avg_low = (bts->rach_ldavg_slots >> 8) & 0x0f; |
Harald Welte | 4c826f7 | 2011-01-14 15:55:42 +0100 | [diff] [blame] | 380 | |
| 381 | bs11_attr_bts[35] = avg_high; |
| 382 | bs11_attr_bts[36] = avg_low; |
| 383 | } |
| 384 | |
| 385 | /* patch BSIC */ |
| 386 | bs11_attr_bts[1] = bts->bsic; |
| 387 | |
| 388 | /* patch the power reduction */ |
| 389 | bs11_attr_radio[5] = bts->c0->max_power_red / 2; |
| 390 | } |
| 391 | |
| 392 | |
| 393 | static void nm_reconfig_ts(struct gsm_bts_trx_ts *ts) |
| 394 | { |
| 395 | enum abis_nm_chan_comb ccomb = abis_nm_chcomb4pchan(ts->pchan); |
| 396 | struct gsm_e1_subslot *e1l = &ts->e1_link; |
| 397 | |
| 398 | abis_nm_set_channel_attr(ts, ccomb); |
| 399 | |
| 400 | if (is_ipaccess_bts(ts->trx->bts)) |
| 401 | return; |
| 402 | |
Neels Hofmeyr | 97fe7a0 | 2016-09-27 11:53:23 +0200 | [diff] [blame] | 403 | if (ts_is_tch(ts)) |
Harald Welte | 4c826f7 | 2011-01-14 15:55:42 +0100 | [diff] [blame] | 404 | abis_nm_conn_terr_traf(ts, e1l->e1_nr, e1l->e1_ts, |
| 405 | e1l->e1_ts_ss); |
Harald Welte | 4c826f7 | 2011-01-14 15:55:42 +0100 | [diff] [blame] | 406 | } |
| 407 | |
| 408 | static void nm_reconfig_trx(struct gsm_bts_trx *trx) |
| 409 | { |
| 410 | struct gsm_e1_subslot *e1l = &trx->rsl_e1_link; |
| 411 | int i; |
| 412 | |
| 413 | patch_nm_tables(trx->bts); |
| 414 | |
| 415 | switch (trx->bts->type) { |
| 416 | case GSM_BTS_TYPE_BS11: |
| 417 | /* FIXME: discover this by fetching an attribute */ |
| 418 | #if 0 |
| 419 | trx->nominal_power = 15; /* 15dBm == 30mW PA configuration */ |
| 420 | #else |
| 421 | trx->nominal_power = 24; /* 24dBm == 250mW PA configuration */ |
| 422 | #endif |
| 423 | abis_nm_conn_terr_sign(trx, e1l->e1_nr, e1l->e1_ts, |
| 424 | e1l->e1_ts_ss); |
| 425 | abis_nm_establish_tei(trx->bts, trx->nr, e1l->e1_nr, |
| 426 | e1l->e1_ts, e1l->e1_ts_ss, trx->rsl_tei); |
| 427 | |
| 428 | /* Set Radio Attributes */ |
| 429 | if (trx == trx->bts->c0) |
| 430 | abis_nm_set_radio_attr(trx, bs11_attr_radio, |
| 431 | sizeof(bs11_attr_radio)); |
| 432 | else { |
Holger Hans Peter Freyther | 7eb8a9a | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 433 | uint8_t trx1_attr_radio[sizeof(bs11_attr_radio)]; |
| 434 | uint8_t arfcn_low = trx->arfcn & 0xff; |
| 435 | uint8_t arfcn_high = (trx->arfcn >> 8) & 0x0f; |
Harald Welte | 4c826f7 | 2011-01-14 15:55:42 +0100 | [diff] [blame] | 436 | memcpy(trx1_attr_radio, bs11_attr_radio, |
| 437 | sizeof(trx1_attr_radio)); |
| 438 | |
| 439 | /* patch ARFCN into TRX Attributes */ |
| 440 | trx1_attr_radio[2] &= 0xf0; |
| 441 | trx1_attr_radio[2] |= arfcn_high; |
| 442 | trx1_attr_radio[3] = arfcn_low; |
| 443 | |
| 444 | abis_nm_set_radio_attr(trx, trx1_attr_radio, |
| 445 | sizeof(trx1_attr_radio)); |
| 446 | } |
| 447 | break; |
| 448 | case GSM_BTS_TYPE_NANOBTS: |
| 449 | switch (trx->bts->band) { |
| 450 | case GSM_BAND_850: |
| 451 | case GSM_BAND_900: |
| 452 | trx->nominal_power = 20; |
| 453 | break; |
| 454 | case GSM_BAND_1800: |
| 455 | case GSM_BAND_1900: |
| 456 | trx->nominal_power = 23; |
| 457 | break; |
| 458 | default: |
| 459 | LOGP(DNM, LOGL_ERROR, "Unsupported nanoBTS GSM band %s\n", |
| 460 | gsm_band_name(trx->bts->band)); |
| 461 | break; |
| 462 | } |
| 463 | break; |
| 464 | default: |
| 465 | break; |
| 466 | } |
| 467 | |
| 468 | for (i = 0; i < TRX_NR_TS; i++) |
| 469 | nm_reconfig_ts(&trx->ts[i]); |
| 470 | } |
| 471 | |
| 472 | static void nm_reconfig_bts(struct gsm_bts *bts) |
| 473 | { |
| 474 | struct gsm_bts_trx *trx; |
| 475 | |
| 476 | switch (bts->type) { |
| 477 | case GSM_BTS_TYPE_BS11: |
| 478 | patch_nm_tables(bts); |
| 479 | abis_nm_raw_msg(bts, sizeof(msg_1), msg_1); /* set BTS SiteMgr attr*/ |
| 480 | abis_nm_set_bts_attr(bts, bs11_attr_bts, sizeof(bs11_attr_bts)); |
| 481 | abis_nm_raw_msg(bts, sizeof(msg_3), msg_3); /* set BTS handover attr */ |
| 482 | abis_nm_raw_msg(bts, sizeof(msg_4), msg_4); /* set BTS power control attr */ |
| 483 | break; |
| 484 | default: |
| 485 | break; |
| 486 | } |
| 487 | |
| 488 | llist_for_each_entry(trx, &bts->trx_list, list) |
| 489 | nm_reconfig_trx(trx); |
| 490 | } |
| 491 | |
| 492 | |
| 493 | static void bootstrap_om_bs11(struct gsm_bts *bts) |
| 494 | { |
| 495 | LOGP(DNM, LOGL_NOTICE, "bootstrapping OML for BTS %u\n", bts->nr); |
| 496 | |
| 497 | /* stop sending event reports */ |
| 498 | abis_nm_event_reports(bts, 0); |
| 499 | |
| 500 | /* begin DB transmission */ |
| 501 | abis_nm_bs11_db_transmission(bts, 1); |
| 502 | |
| 503 | /* end DB transmission */ |
| 504 | abis_nm_bs11_db_transmission(bts, 0); |
| 505 | |
| 506 | /* Reset BTS Site manager resource */ |
| 507 | abis_nm_bs11_reset_resource(bts); |
| 508 | |
| 509 | /* begin DB transmission */ |
| 510 | abis_nm_bs11_db_transmission(bts, 1); |
| 511 | |
| 512 | /* reconfigure BTS with all TRX and all TS */ |
| 513 | nm_reconfig_bts(bts); |
| 514 | |
| 515 | /* end DB transmission */ |
| 516 | abis_nm_bs11_db_transmission(bts, 0); |
| 517 | |
| 518 | /* Reset BTS Site manager resource */ |
| 519 | abis_nm_bs11_reset_resource(bts); |
| 520 | |
| 521 | /* restart sending event reports */ |
| 522 | abis_nm_event_reports(bts, 1); |
| 523 | } |
| 524 | |
| 525 | static int shutdown_om(struct gsm_bts *bts) |
| 526 | { |
| 527 | /* stop sending event reports */ |
| 528 | abis_nm_event_reports(bts, 0); |
| 529 | |
| 530 | /* begin DB transmission */ |
| 531 | abis_nm_bs11_db_transmission(bts, 1); |
| 532 | |
| 533 | /* end DB transmission */ |
| 534 | abis_nm_bs11_db_transmission(bts, 0); |
| 535 | |
| 536 | /* Reset BTS Site manager resource */ |
| 537 | abis_nm_bs11_reset_resource(bts); |
| 538 | |
| 539 | return 0; |
| 540 | } |
| 541 | |
| 542 | /* Callback function to be called every time we receive a signal from INPUT */ |
| 543 | static int gbl_sig_cb(unsigned int subsys, unsigned int signal, |
| 544 | void *handler_data, void *signal_data) |
| 545 | { |
| 546 | struct gsm_bts *bts; |
| 547 | |
Pablo Neira Ayuso | 42e41df | 2011-08-17 22:44:07 +0200 | [diff] [blame] | 548 | if (subsys != SS_L_GLOBAL) |
Harald Welte | 4c826f7 | 2011-01-14 15:55:42 +0100 | [diff] [blame] | 549 | return 0; |
| 550 | |
| 551 | switch (signal) { |
| 552 | case S_GLOBAL_BTS_CLOSE_OM: |
| 553 | bts = signal_data; |
| 554 | if (bts->type == GSM_BTS_TYPE_BS11) |
| 555 | shutdown_om(signal_data); |
| 556 | break; |
| 557 | } |
| 558 | |
| 559 | return 0; |
| 560 | } |
| 561 | |
| 562 | /* Callback function to be called every time we receive a signal from INPUT */ |
| 563 | static int inp_sig_cb(unsigned int subsys, unsigned int signal, |
| 564 | void *handler_data, void *signal_data) |
| 565 | { |
| 566 | struct input_signal_data *isd = signal_data; |
| 567 | |
Pablo Neira Ayuso | 42e41df | 2011-08-17 22:44:07 +0200 | [diff] [blame] | 568 | if (subsys != SS_L_INPUT) |
Harald Welte | 4c826f7 | 2011-01-14 15:55:42 +0100 | [diff] [blame] | 569 | return 0; |
| 570 | |
| 571 | switch (signal) { |
Pablo Neira Ayuso | 42e41df | 2011-08-17 22:44:07 +0200 | [diff] [blame] | 572 | case S_L_INP_TEI_UP: |
Harald Welte | 4c826f7 | 2011-01-14 15:55:42 +0100 | [diff] [blame] | 573 | switch (isd->link_type) { |
| 574 | case E1INP_SIGN_OML: |
| 575 | if (isd->trx->bts->type == GSM_BTS_TYPE_BS11) |
| 576 | bootstrap_om_bs11(isd->trx->bts); |
| 577 | break; |
| 578 | } |
| 579 | } |
| 580 | |
| 581 | return 0; |
| 582 | } |
| 583 | |
Pablo Neira Ayuso | 5bd96a7 | 2011-05-14 11:32:48 +0200 | [diff] [blame] | 584 | static int bts_model_bs11_start(struct gsm_network *net) |
Harald Welte | 59698fb | 2010-01-10 18:01:52 +0100 | [diff] [blame] | 585 | { |
Holger Hans Peter Freyther | d7090ec | 2010-06-21 18:11:37 +0800 | [diff] [blame] | 586 | model_bs11.features.data = &model_bs11._features_data[0]; |
Harald Welte | 20e275a | 2010-06-14 22:44:42 +0200 | [diff] [blame] | 587 | model_bs11.features.data_len = sizeof(model_bs11._features_data); |
| 588 | |
| 589 | gsm_btsmodel_set_feature(&model_bs11, BTS_FEAT_HOPPING); |
| 590 | gsm_btsmodel_set_feature(&model_bs11, BTS_FEAT_HSCSD); |
Harald Welte | 499cd25 | 2014-01-19 17:10:50 +0100 | [diff] [blame] | 591 | gsm_btsmodel_set_feature(&model_bs11, BTS_FEAT_MULTI_TSC); |
Harald Welte | 20e275a | 2010-06-14 22:44:42 +0200 | [diff] [blame] | 592 | |
Pablo Neira Ayuso | 42e41df | 2011-08-17 22:44:07 +0200 | [diff] [blame] | 593 | osmo_signal_register_handler(SS_L_INPUT, inp_sig_cb, NULL); |
| 594 | osmo_signal_register_handler(SS_L_GLOBAL, gbl_sig_cb, NULL); |
Harald Welte | 4c826f7 | 2011-01-14 15:55:42 +0100 | [diff] [blame] | 595 | |
Pablo Neira Ayuso | 5bd96a7 | 2011-05-14 11:32:48 +0200 | [diff] [blame] | 596 | return 0; |
| 597 | } |
| 598 | |
| 599 | int bts_model_bs11_init(void) |
| 600 | { |
Harald Welte | 59698fb | 2010-01-10 18:01:52 +0100 | [diff] [blame] | 601 | return gsm_bts_model_register(&model_bs11); |
| 602 | } |