Harald Welte | db44f60 | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 1 | /* Ericsson RBS-2xxx specific code */ |
| 2 | |
| 3 | /* (C) 2011 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 |
| 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 |
| 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 Affero General Public License for more details. |
| 16 | * |
| 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/>. |
| 19 | * |
| 20 | */ |
| 21 | |
Harald Welte | db44f60 | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 22 | |
Pablo Neira Ayuso | 136f453 | 2011-03-22 16:47:59 +0100 | [diff] [blame] | 23 | #include <osmocom/gsm/tlv.h> |
Harald Welte | db44f60 | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 24 | |
| 25 | #include <openbsc/debug.h> |
| 26 | #include <openbsc/gsm_data.h> |
Harald Welte | 9a311ec | 2011-02-12 12:33:06 +0100 | [diff] [blame] | 27 | #include <openbsc/abis_om2000.h> |
Harald Welte | 1484d88 | 2011-03-06 22:12:24 +0100 | [diff] [blame] | 28 | #include <openbsc/abis_nm.h> |
Pablo Neira Ayuso | ed5cacb | 2011-08-17 22:44:07 +0200 | [diff] [blame] | 29 | #include <osmocom/abis/e1_input.h> |
Harald Welte | db44f60 | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 30 | #include <openbsc/signal.h> |
| 31 | |
Pablo Neira Ayuso | ed5cacb | 2011-08-17 22:44:07 +0200 | [diff] [blame] | 32 | #include <osmocom/abis/lapd.h> |
Harald Welte | db44f60 | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 33 | |
Harald Welte | 9f0866c | 2011-02-13 19:44:47 +0100 | [diff] [blame] | 34 | static void bootstrap_om_bts(struct gsm_bts *bts) |
Harald Welte | db44f60 | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 35 | { |
| 36 | LOGP(DNM, LOGL_NOTICE, "bootstrapping OML for BTS %u\n", bts->nr); |
Harald Welte | 591e1d7 | 2016-07-09 22:20:57 +0200 | [diff] [blame] | 37 | |
| 38 | /* FIXME: this is global init, not bootstrapping */ |
| 39 | abis_om2k_bts_init(bts); |
| 40 | abis_om2k_trx_init(bts->c0); |
| 41 | |
| 42 | /* TODO: Should we wait for a Failure report? */ |
| 43 | om2k_bts_fsm_start(bts); |
Harald Welte | db44f60 | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 44 | } |
| 45 | |
Harald Welte | 9f0866c | 2011-02-13 19:44:47 +0100 | [diff] [blame] | 46 | static void bootstrap_om_trx(struct gsm_bts_trx *trx) |
| 47 | { |
| 48 | LOGP(DNM, LOGL_NOTICE, "bootstrapping OML for TRX %u/%u\n", |
| 49 | trx->bts->nr, trx->nr); |
Harald Welte | 591e1d7 | 2016-07-09 22:20:57 +0200 | [diff] [blame] | 50 | /* FIXME */ |
Harald Welte | 9f0866c | 2011-02-13 19:44:47 +0100 | [diff] [blame] | 51 | } |
| 52 | |
Harald Welte | db44f60 | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 53 | static int shutdown_om(struct gsm_bts *bts) |
| 54 | { |
| 55 | /* FIXME */ |
| 56 | return 0; |
| 57 | } |
| 58 | |
Harald Welte | dcf42e6 | 2011-02-13 11:58:21 +0100 | [diff] [blame] | 59 | |
| 60 | /* Tell LAPD to start start the SAP (send SABM requests) for all signalling |
| 61 | * timeslots in this line */ |
Harald Welte | 174a51a | 2011-02-13 14:26:54 +0100 | [diff] [blame] | 62 | static void start_sabm_in_line(struct e1inp_line *line, int start) |
Harald Welte | dcf42e6 | 2011-02-13 11:58:21 +0100 | [diff] [blame] | 63 | { |
| 64 | struct e1inp_sign_link *link; |
| 65 | int i; |
| 66 | |
| 67 | for (i = 0; i < ARRAY_SIZE(line->ts); i++) { |
| 68 | struct e1inp_ts *ts = &line->ts[i]; |
| 69 | |
| 70 | if (ts->type != E1INP_TS_TYPE_SIGN) |
| 71 | continue; |
| 72 | |
| 73 | llist_for_each_entry(link, &ts->sign.sign_links, list) { |
Harald Welte | c1efa67 | 2016-11-11 19:42:19 +0100 | [diff] [blame] | 74 | if (!ts->lapd) |
| 75 | continue; |
Philipp | 6bbcfbb | 2016-10-26 14:20:06 +0200 | [diff] [blame] | 76 | lapd_instance_set_profile(ts->lapd, |
| 77 | &lapd_profile_abis_ericsson); |
| 78 | |
Harald Welte | 174a51a | 2011-02-13 14:26:54 +0100 | [diff] [blame] | 79 | if (start) |
Harald Welte | b4d913d | 2011-08-26 19:14:55 +0200 | [diff] [blame] | 80 | lapd_sap_start(ts->lapd, link->tei, link->sapi); |
Harald Welte | 174a51a | 2011-02-13 14:26:54 +0100 | [diff] [blame] | 81 | else |
Harald Welte | b4d913d | 2011-08-26 19:14:55 +0200 | [diff] [blame] | 82 | lapd_sap_stop(ts->lapd, link->tei, link->sapi); |
Harald Welte | dcf42e6 | 2011-02-13 11:58:21 +0100 | [diff] [blame] | 83 | } |
| 84 | } |
| 85 | } |
| 86 | |
Harald Welte | db44f60 | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 87 | /* Callback function to be called every time we receive a signal from INPUT */ |
| 88 | static int gbl_sig_cb(unsigned int subsys, unsigned int signal, |
| 89 | void *handler_data, void *signal_data) |
| 90 | { |
| 91 | struct gsm_bts *bts; |
| 92 | |
Pablo Neira Ayuso | ed5cacb | 2011-08-17 22:44:07 +0200 | [diff] [blame] | 93 | if (subsys != SS_L_GLOBAL) |
Harald Welte | db44f60 | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 94 | return 0; |
| 95 | |
| 96 | switch (signal) { |
| 97 | case S_GLOBAL_BTS_CLOSE_OM: |
| 98 | bts = signal_data; |
| 99 | if (bts->type == GSM_BTS_TYPE_RBS2000) |
| 100 | shutdown_om(signal_data); |
| 101 | break; |
| 102 | } |
| 103 | |
| 104 | return 0; |
| 105 | } |
| 106 | |
Harald Welte | db44f60 | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 107 | /* Callback function to be called every time we receive a signal from INPUT */ |
| 108 | static int inp_sig_cb(unsigned int subsys, unsigned int signal, |
| 109 | void *handler_data, void *signal_data) |
| 110 | { |
| 111 | struct input_signal_data *isd = signal_data; |
Harald Welte | 7975ddf | 2016-10-16 23:44:16 +0200 | [diff] [blame] | 112 | struct e1inp_ts *e1i_ts; |
Harald Welte | db44f60 | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 113 | |
Pablo Neira Ayuso | ed5cacb | 2011-08-17 22:44:07 +0200 | [diff] [blame] | 114 | if (subsys != SS_L_INPUT) |
Harald Welte | db44f60 | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 115 | return 0; |
| 116 | |
| 117 | switch (signal) { |
Pablo Neira Ayuso | ed5cacb | 2011-08-17 22:44:07 +0200 | [diff] [blame] | 118 | case S_L_INP_TEI_UP: |
Harald Welte | db44f60 | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 119 | switch (isd->link_type) { |
| 120 | case E1INP_SIGN_OML: |
Harald Welte | 9f0866c | 2011-02-13 19:44:47 +0100 | [diff] [blame] | 121 | if (isd->trx->bts->type != GSM_BTS_TYPE_RBS2000) |
| 122 | break; |
| 123 | if (isd->tei == isd->trx->bts->oml_tei) |
| 124 | bootstrap_om_bts(isd->trx->bts); |
| 125 | else |
| 126 | bootstrap_om_trx(isd->trx); |
Harald Welte | db44f60 | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 127 | break; |
| 128 | } |
Harald Welte | 03cc8a8 | 2011-02-11 18:59:31 +0100 | [diff] [blame] | 129 | break; |
Harald Welte | 7975ddf | 2016-10-16 23:44:16 +0200 | [diff] [blame] | 130 | case S_L_INP_TEI_DN: |
| 131 | if (isd->trx->bts->type != GSM_BTS_TYPE_RBS2000) |
| 132 | break; |
| 133 | LOGP(DNM, LOGL_NOTICE, "Line-%u TS-%u TEI-%u SAPI-%u: Link " |
| 134 | "Lost for Ericsson RBS2000. Re-starting DL Establishment\n", |
| 135 | isd->line->num, isd->ts_nr, isd->tei, isd->sapi); |
| 136 | /* Some datalink for a given TEI/SAPI went down, try to re-start it */ |
| 137 | e1i_ts = &isd->line->ts[isd->ts_nr-1]; |
| 138 | OSMO_ASSERT(e1i_ts->type == E1INP_TS_TYPE_SIGN); |
| 139 | lapd_sap_start(e1i_ts->lapd, isd->tei, isd->sapi); |
| 140 | break; |
Pablo Neira Ayuso | ed5cacb | 2011-08-17 22:44:07 +0200 | [diff] [blame] | 141 | case S_L_INP_LINE_INIT: |
Andreas Eversberg | c57e6ed | 2011-09-26 11:44:22 +0200 | [diff] [blame] | 142 | case S_L_INP_LINE_NOALARM: |
| 143 | if (strcasecmp(isd->line->driver->name, "DAHDI") |
| 144 | && strcasecmp(isd->line->driver->name, "MISDN_LAPD")) |
Harald Welte | db44f60 | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 145 | break; |
Harald Welte | 174a51a | 2011-02-13 14:26:54 +0100 | [diff] [blame] | 146 | start_sabm_in_line(isd->line, 1); |
| 147 | break; |
Pablo Neira Ayuso | ed5cacb | 2011-08-17 22:44:07 +0200 | [diff] [blame] | 148 | case S_L_INP_LINE_ALARM: |
Andreas Eversberg | c57e6ed | 2011-09-26 11:44:22 +0200 | [diff] [blame] | 149 | if (strcasecmp(isd->line->driver->name, "DAHDI") |
| 150 | && strcasecmp(isd->line->driver->name, "MISDN_LAPD")) |
Harald Welte | 174a51a | 2011-02-13 14:26:54 +0100 | [diff] [blame] | 151 | break; |
| 152 | start_sabm_in_line(isd->line, 0); |
| 153 | break; |
Harald Welte | db44f60 | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 154 | } |
| 155 | |
| 156 | return 0; |
| 157 | } |
| 158 | |
Harald Welte | 59eee42 | 2011-02-14 16:17:49 +0100 | [diff] [blame] | 159 | static void config_write_bts(struct vty *vty, struct gsm_bts *bts) |
| 160 | { |
| 161 | abis_om2k_config_write_bts(vty, bts); |
| 162 | } |
| 163 | |
Pablo Neira Ayuso | 0d2881a | 2011-05-14 11:32:48 +0200 | [diff] [blame] | 164 | static int bts_model_rbs2k_start(struct gsm_network *net); |
| 165 | |
Pablo Neira Ayuso | ed5cacb | 2011-08-17 22:44:07 +0200 | [diff] [blame] | 166 | static void bts_model_rbs2k_e1line_bind_ops(struct e1inp_line *line) |
| 167 | { |
| 168 | e1inp_line_bind_ops(line, &bts_isdn_e1inp_line_ops); |
| 169 | } |
| 170 | |
Harald Welte | 59eee42 | 2011-02-14 16:17:49 +0100 | [diff] [blame] | 171 | static struct gsm_bts_model model_rbs2k = { |
| 172 | .type = GSM_BTS_TYPE_RBS2000, |
| 173 | .name = "rbs2000", |
Pablo Neira Ayuso | 0d2881a | 2011-05-14 11:32:48 +0200 | [diff] [blame] | 174 | .start = bts_model_rbs2k_start, |
Harald Welte | 59eee42 | 2011-02-14 16:17:49 +0100 | [diff] [blame] | 175 | .oml_rcvmsg = &abis_om2k_rcvmsg, |
| 176 | .config_write_bts = &config_write_bts, |
Pablo Neira Ayuso | ed5cacb | 2011-08-17 22:44:07 +0200 | [diff] [blame] | 177 | .e1line_bind_ops = &bts_model_rbs2k_e1line_bind_ops, |
Harald Welte | 59eee42 | 2011-02-14 16:17:49 +0100 | [diff] [blame] | 178 | }; |
| 179 | |
Pablo Neira Ayuso | 0d2881a | 2011-05-14 11:32:48 +0200 | [diff] [blame] | 180 | static int bts_model_rbs2k_start(struct gsm_network *net) |
Harald Welte | db44f60 | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 181 | { |
| 182 | model_rbs2k.features.data = &model_rbs2k._features_data[0]; |
| 183 | model_rbs2k.features.data_len = sizeof(model_rbs2k._features_data); |
| 184 | |
Philipp | fb89b9b | 2016-10-27 17:54:00 +0200 | [diff] [blame] | 185 | gsm_btsmodel_set_feature(&model_rbs2k, BTS_FEAT_GPRS); |
| 186 | gsm_btsmodel_set_feature(&model_rbs2k, BTS_FEAT_EGPRS); |
Harald Welte | db44f60 | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 187 | gsm_btsmodel_set_feature(&model_rbs2k, BTS_FEAT_HOPPING); |
| 188 | gsm_btsmodel_set_feature(&model_rbs2k, BTS_FEAT_HSCSD); |
Harald Welte | 903aaea | 2014-01-19 17:10:50 +0100 | [diff] [blame] | 189 | gsm_btsmodel_set_feature(&model_rbs2k, BTS_FEAT_MULTI_TSC); |
Harald Welte | db44f60 | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 190 | |
Pablo Neira Ayuso | ed5cacb | 2011-08-17 22:44:07 +0200 | [diff] [blame] | 191 | osmo_signal_register_handler(SS_L_INPUT, inp_sig_cb, NULL); |
| 192 | osmo_signal_register_handler(SS_L_GLOBAL, gbl_sig_cb, NULL); |
Harald Welte | db44f60 | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 193 | |
Pablo Neira Ayuso | 0d2881a | 2011-05-14 11:32:48 +0200 | [diff] [blame] | 194 | return 0; |
| 195 | } |
| 196 | |
| 197 | int bts_model_rbs2k_init(void) |
| 198 | { |
Harald Welte | db44f60 | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 199 | return gsm_bts_model_register(&model_rbs2k); |
| 200 | } |