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 | 174a51a | 2011-02-13 14:26:54 +0100 | [diff] [blame] | 74 | if (start) |
Harald Welte | b4d913d | 2011-08-26 19:14:55 +0200 | [diff] [blame] | 75 | lapd_sap_start(ts->lapd, link->tei, link->sapi); |
Harald Welte | 174a51a | 2011-02-13 14:26:54 +0100 | [diff] [blame] | 76 | else |
Harald Welte | b4d913d | 2011-08-26 19:14:55 +0200 | [diff] [blame] | 77 | lapd_sap_stop(ts->lapd, link->tei, link->sapi); |
Harald Welte | dcf42e6 | 2011-02-13 11:58:21 +0100 | [diff] [blame] | 78 | } |
| 79 | } |
| 80 | } |
| 81 | |
Harald Welte | db44f60 | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 82 | /* Callback function to be called every time we receive a signal from INPUT */ |
| 83 | static int gbl_sig_cb(unsigned int subsys, unsigned int signal, |
| 84 | void *handler_data, void *signal_data) |
| 85 | { |
| 86 | struct gsm_bts *bts; |
| 87 | |
Pablo Neira Ayuso | ed5cacb | 2011-08-17 22:44:07 +0200 | [diff] [blame] | 88 | if (subsys != SS_L_GLOBAL) |
Harald Welte | db44f60 | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 89 | return 0; |
| 90 | |
| 91 | switch (signal) { |
| 92 | case S_GLOBAL_BTS_CLOSE_OM: |
| 93 | bts = signal_data; |
| 94 | if (bts->type == GSM_BTS_TYPE_RBS2000) |
| 95 | shutdown_om(signal_data); |
| 96 | break; |
| 97 | } |
| 98 | |
| 99 | return 0; |
| 100 | } |
| 101 | |
Harald Welte | db44f60 | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 102 | /* Callback function to be called every time we receive a signal from INPUT */ |
| 103 | static int inp_sig_cb(unsigned int subsys, unsigned int signal, |
| 104 | void *handler_data, void *signal_data) |
| 105 | { |
| 106 | struct input_signal_data *isd = signal_data; |
| 107 | |
Pablo Neira Ayuso | ed5cacb | 2011-08-17 22:44:07 +0200 | [diff] [blame] | 108 | if (subsys != SS_L_INPUT) |
Harald Welte | db44f60 | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 109 | return 0; |
| 110 | |
| 111 | switch (signal) { |
Pablo Neira Ayuso | ed5cacb | 2011-08-17 22:44:07 +0200 | [diff] [blame] | 112 | case S_L_INP_TEI_UP: |
Harald Welte | db44f60 | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 113 | switch (isd->link_type) { |
| 114 | case E1INP_SIGN_OML: |
Harald Welte | 9f0866c | 2011-02-13 19:44:47 +0100 | [diff] [blame] | 115 | if (isd->trx->bts->type != GSM_BTS_TYPE_RBS2000) |
| 116 | break; |
| 117 | if (isd->tei == isd->trx->bts->oml_tei) |
| 118 | bootstrap_om_bts(isd->trx->bts); |
| 119 | else |
| 120 | bootstrap_om_trx(isd->trx); |
Harald Welte | db44f60 | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 121 | break; |
| 122 | } |
Harald Welte | 03cc8a8 | 2011-02-11 18:59:31 +0100 | [diff] [blame] | 123 | break; |
Pablo Neira Ayuso | ed5cacb | 2011-08-17 22:44:07 +0200 | [diff] [blame] | 124 | case S_L_INP_LINE_INIT: |
Andreas Eversberg | c57e6ed | 2011-09-26 11:44:22 +0200 | [diff] [blame] | 125 | case S_L_INP_LINE_NOALARM: |
| 126 | if (strcasecmp(isd->line->driver->name, "DAHDI") |
| 127 | && strcasecmp(isd->line->driver->name, "MISDN_LAPD")) |
Harald Welte | db44f60 | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 128 | break; |
Harald Welte | 174a51a | 2011-02-13 14:26:54 +0100 | [diff] [blame] | 129 | start_sabm_in_line(isd->line, 1); |
| 130 | break; |
Pablo Neira Ayuso | ed5cacb | 2011-08-17 22:44:07 +0200 | [diff] [blame] | 131 | case S_L_INP_LINE_ALARM: |
Andreas Eversberg | c57e6ed | 2011-09-26 11:44:22 +0200 | [diff] [blame] | 132 | if (strcasecmp(isd->line->driver->name, "DAHDI") |
| 133 | && strcasecmp(isd->line->driver->name, "MISDN_LAPD")) |
Harald Welte | 174a51a | 2011-02-13 14:26:54 +0100 | [diff] [blame] | 134 | break; |
| 135 | start_sabm_in_line(isd->line, 0); |
| 136 | break; |
Harald Welte | db44f60 | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 137 | } |
| 138 | |
| 139 | return 0; |
| 140 | } |
| 141 | |
Harald Welte | 59eee42 | 2011-02-14 16:17:49 +0100 | [diff] [blame] | 142 | static void config_write_bts(struct vty *vty, struct gsm_bts *bts) |
| 143 | { |
| 144 | abis_om2k_config_write_bts(vty, bts); |
| 145 | } |
| 146 | |
Pablo Neira Ayuso | 0d2881a | 2011-05-14 11:32:48 +0200 | [diff] [blame] | 147 | static int bts_model_rbs2k_start(struct gsm_network *net); |
| 148 | |
Pablo Neira Ayuso | ed5cacb | 2011-08-17 22:44:07 +0200 | [diff] [blame] | 149 | static void bts_model_rbs2k_e1line_bind_ops(struct e1inp_line *line) |
| 150 | { |
| 151 | e1inp_line_bind_ops(line, &bts_isdn_e1inp_line_ops); |
| 152 | } |
| 153 | |
Harald Welte | 59eee42 | 2011-02-14 16:17:49 +0100 | [diff] [blame] | 154 | static struct gsm_bts_model model_rbs2k = { |
| 155 | .type = GSM_BTS_TYPE_RBS2000, |
| 156 | .name = "rbs2000", |
Pablo Neira Ayuso | 0d2881a | 2011-05-14 11:32:48 +0200 | [diff] [blame] | 157 | .start = bts_model_rbs2k_start, |
Harald Welte | 59eee42 | 2011-02-14 16:17:49 +0100 | [diff] [blame] | 158 | .oml_rcvmsg = &abis_om2k_rcvmsg, |
| 159 | .config_write_bts = &config_write_bts, |
Pablo Neira Ayuso | ed5cacb | 2011-08-17 22:44:07 +0200 | [diff] [blame] | 160 | .e1line_bind_ops = &bts_model_rbs2k_e1line_bind_ops, |
Harald Welte | 59eee42 | 2011-02-14 16:17:49 +0100 | [diff] [blame] | 161 | }; |
| 162 | |
Pablo Neira Ayuso | 0d2881a | 2011-05-14 11:32:48 +0200 | [diff] [blame] | 163 | static int bts_model_rbs2k_start(struct gsm_network *net) |
Harald Welte | db44f60 | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 164 | { |
| 165 | model_rbs2k.features.data = &model_rbs2k._features_data[0]; |
| 166 | model_rbs2k.features.data_len = sizeof(model_rbs2k._features_data); |
| 167 | |
| 168 | gsm_btsmodel_set_feature(&model_rbs2k, BTS_FEAT_HOPPING); |
| 169 | gsm_btsmodel_set_feature(&model_rbs2k, BTS_FEAT_HSCSD); |
Harald Welte | 903aaea | 2014-01-19 17:10:50 +0100 | [diff] [blame] | 170 | gsm_btsmodel_set_feature(&model_rbs2k, BTS_FEAT_MULTI_TSC); |
Harald Welte | db44f60 | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 171 | |
Pablo Neira Ayuso | ed5cacb | 2011-08-17 22:44:07 +0200 | [diff] [blame] | 172 | osmo_signal_register_handler(SS_L_INPUT, inp_sig_cb, NULL); |
| 173 | osmo_signal_register_handler(SS_L_GLOBAL, gbl_sig_cb, NULL); |
Harald Welte | db44f60 | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 174 | |
Pablo Neira Ayuso | 0d2881a | 2011-05-14 11:32:48 +0200 | [diff] [blame] | 175 | return 0; |
| 176 | } |
| 177 | |
| 178 | int bts_model_rbs2k_init(void) |
| 179 | { |
Harald Welte | db44f60 | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 180 | return gsm_bts_model_register(&model_rbs2k); |
| 181 | } |