Harald Welte | c2f27ba | 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 | c2f27ba | 2011-02-11 18:36:18 +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 | c2f27ba | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 24 | |
| 25 | #include <openbsc/debug.h> |
| 26 | #include <openbsc/gsm_data.h> |
Harald Welte | 2a0a963 | 2011-02-12 12:33:06 +0100 | [diff] [blame] | 27 | #include <openbsc/abis_om2000.h> |
Harald Welte | 4faaa40 | 2011-03-06 22:12:24 +0100 | [diff] [blame] | 28 | #include <openbsc/abis_nm.h> |
Pablo Neira Ayuso | 42e41df | 2011-08-17 22:44:07 +0200 | [diff] [blame] | 29 | #include <osmocom/abis/e1_input.h> |
Harald Welte | c2f27ba | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 30 | #include <openbsc/signal.h> |
| 31 | |
Pablo Neira Ayuso | 42e41df | 2011-08-17 22:44:07 +0200 | [diff] [blame] | 32 | #include <osmocom/abis/lapd.h> |
Harald Welte | c2f27ba | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 33 | |
Harald Welte | 436b8cf | 2011-02-13 19:44:47 +0100 | [diff] [blame] | 34 | static void bootstrap_om_bts(struct gsm_bts *bts) |
Harald Welte | c2f27ba | 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 | 018877b | 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 | c2f27ba | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 44 | } |
| 45 | |
Harald Welte | 436b8cf | 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 | 018877b | 2016-07-09 22:20:57 +0200 | [diff] [blame] | 50 | /* FIXME */ |
Harald Welte | 436b8cf | 2011-02-13 19:44:47 +0100 | [diff] [blame] | 51 | } |
| 52 | |
Harald Welte | c2f27ba | 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 | 0303a36 | 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 | 5434bfa | 2011-02-13 14:26:54 +0100 | [diff] [blame] | 62 | static void start_sabm_in_line(struct e1inp_line *line, int start) |
Harald Welte | 0303a36 | 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 | 5434bfa | 2011-02-13 14:26:54 +0100 | [diff] [blame] | 74 | if (start) |
Harald Welte | e6d482e | 2011-08-26 19:14:55 +0200 | [diff] [blame] | 75 | lapd_sap_start(ts->lapd, link->tei, link->sapi); |
Harald Welte | 5434bfa | 2011-02-13 14:26:54 +0100 | [diff] [blame] | 76 | else |
Harald Welte | e6d482e | 2011-08-26 19:14:55 +0200 | [diff] [blame] | 77 | lapd_sap_stop(ts->lapd, link->tei, link->sapi); |
Harald Welte | 0303a36 | 2011-02-13 11:58:21 +0100 | [diff] [blame] | 78 | } |
| 79 | } |
| 80 | } |
| 81 | |
Harald Welte | c2f27ba | 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 | 42e41df | 2011-08-17 22:44:07 +0200 | [diff] [blame] | 88 | if (subsys != SS_L_GLOBAL) |
Harald Welte | c2f27ba | 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 | c2f27ba | 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; |
Harald Welte | 22b28b3 | 2016-10-16 23:44:16 +0200 | [diff] [blame^] | 107 | struct e1inp_ts *e1i_ts; |
Harald Welte | c2f27ba | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 108 | |
Pablo Neira Ayuso | 42e41df | 2011-08-17 22:44:07 +0200 | [diff] [blame] | 109 | if (subsys != SS_L_INPUT) |
Harald Welte | c2f27ba | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 110 | return 0; |
| 111 | |
| 112 | switch (signal) { |
Pablo Neira Ayuso | 42e41df | 2011-08-17 22:44:07 +0200 | [diff] [blame] | 113 | case S_L_INP_TEI_UP: |
Harald Welte | c2f27ba | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 114 | switch (isd->link_type) { |
| 115 | case E1INP_SIGN_OML: |
Harald Welte | 436b8cf | 2011-02-13 19:44:47 +0100 | [diff] [blame] | 116 | if (isd->trx->bts->type != GSM_BTS_TYPE_RBS2000) |
| 117 | break; |
| 118 | if (isd->tei == isd->trx->bts->oml_tei) |
| 119 | bootstrap_om_bts(isd->trx->bts); |
| 120 | else |
| 121 | bootstrap_om_trx(isd->trx); |
Harald Welte | c2f27ba | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 122 | break; |
| 123 | } |
Harald Welte | f1e466a | 2011-02-11 18:59:31 +0100 | [diff] [blame] | 124 | break; |
Harald Welte | 22b28b3 | 2016-10-16 23:44:16 +0200 | [diff] [blame^] | 125 | case S_L_INP_TEI_DN: |
| 126 | if (isd->trx->bts->type != GSM_BTS_TYPE_RBS2000) |
| 127 | break; |
| 128 | LOGP(DNM, LOGL_NOTICE, "Line-%u TS-%u TEI-%u SAPI-%u: Link " |
| 129 | "Lost for Ericsson RBS2000. Re-starting DL Establishment\n", |
| 130 | isd->line->num, isd->ts_nr, isd->tei, isd->sapi); |
| 131 | /* Some datalink for a given TEI/SAPI went down, try to re-start it */ |
| 132 | e1i_ts = &isd->line->ts[isd->ts_nr-1]; |
| 133 | OSMO_ASSERT(e1i_ts->type == E1INP_TS_TYPE_SIGN); |
| 134 | lapd_sap_start(e1i_ts->lapd, isd->tei, isd->sapi); |
| 135 | break; |
Pablo Neira Ayuso | 42e41df | 2011-08-17 22:44:07 +0200 | [diff] [blame] | 136 | case S_L_INP_LINE_INIT: |
Andreas Eversberg | 62cf798 | 2011-09-26 11:44:22 +0200 | [diff] [blame] | 137 | case S_L_INP_LINE_NOALARM: |
| 138 | if (strcasecmp(isd->line->driver->name, "DAHDI") |
| 139 | && strcasecmp(isd->line->driver->name, "MISDN_LAPD")) |
Harald Welte | c2f27ba | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 140 | break; |
Harald Welte | 5434bfa | 2011-02-13 14:26:54 +0100 | [diff] [blame] | 141 | start_sabm_in_line(isd->line, 1); |
| 142 | break; |
Pablo Neira Ayuso | 42e41df | 2011-08-17 22:44:07 +0200 | [diff] [blame] | 143 | case S_L_INP_LINE_ALARM: |
Andreas Eversberg | 62cf798 | 2011-09-26 11:44:22 +0200 | [diff] [blame] | 144 | if (strcasecmp(isd->line->driver->name, "DAHDI") |
| 145 | && strcasecmp(isd->line->driver->name, "MISDN_LAPD")) |
Harald Welte | 5434bfa | 2011-02-13 14:26:54 +0100 | [diff] [blame] | 146 | break; |
| 147 | start_sabm_in_line(isd->line, 0); |
| 148 | break; |
Harald Welte | c2f27ba | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 149 | } |
| 150 | |
| 151 | return 0; |
| 152 | } |
| 153 | |
Harald Welte | bf7a534 | 2011-02-14 16:17:49 +0100 | [diff] [blame] | 154 | static void config_write_bts(struct vty *vty, struct gsm_bts *bts) |
| 155 | { |
| 156 | abis_om2k_config_write_bts(vty, bts); |
| 157 | } |
| 158 | |
Pablo Neira Ayuso | 5bd96a7 | 2011-05-14 11:32:48 +0200 | [diff] [blame] | 159 | static int bts_model_rbs2k_start(struct gsm_network *net); |
| 160 | |
Pablo Neira Ayuso | 42e41df | 2011-08-17 22:44:07 +0200 | [diff] [blame] | 161 | static void bts_model_rbs2k_e1line_bind_ops(struct e1inp_line *line) |
| 162 | { |
| 163 | e1inp_line_bind_ops(line, &bts_isdn_e1inp_line_ops); |
| 164 | } |
| 165 | |
Harald Welte | bf7a534 | 2011-02-14 16:17:49 +0100 | [diff] [blame] | 166 | static struct gsm_bts_model model_rbs2k = { |
| 167 | .type = GSM_BTS_TYPE_RBS2000, |
| 168 | .name = "rbs2000", |
Pablo Neira Ayuso | 5bd96a7 | 2011-05-14 11:32:48 +0200 | [diff] [blame] | 169 | .start = bts_model_rbs2k_start, |
Harald Welte | bf7a534 | 2011-02-14 16:17:49 +0100 | [diff] [blame] | 170 | .oml_rcvmsg = &abis_om2k_rcvmsg, |
| 171 | .config_write_bts = &config_write_bts, |
Pablo Neira Ayuso | 42e41df | 2011-08-17 22:44:07 +0200 | [diff] [blame] | 172 | .e1line_bind_ops = &bts_model_rbs2k_e1line_bind_ops, |
Harald Welte | bf7a534 | 2011-02-14 16:17:49 +0100 | [diff] [blame] | 173 | }; |
| 174 | |
Pablo Neira Ayuso | 5bd96a7 | 2011-05-14 11:32:48 +0200 | [diff] [blame] | 175 | static int bts_model_rbs2k_start(struct gsm_network *net) |
Harald Welte | c2f27ba | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 176 | { |
| 177 | model_rbs2k.features.data = &model_rbs2k._features_data[0]; |
| 178 | model_rbs2k.features.data_len = sizeof(model_rbs2k._features_data); |
| 179 | |
| 180 | gsm_btsmodel_set_feature(&model_rbs2k, BTS_FEAT_HOPPING); |
| 181 | gsm_btsmodel_set_feature(&model_rbs2k, BTS_FEAT_HSCSD); |
Harald Welte | 499cd25 | 2014-01-19 17:10:50 +0100 | [diff] [blame] | 182 | gsm_btsmodel_set_feature(&model_rbs2k, BTS_FEAT_MULTI_TSC); |
Harald Welte | c2f27ba | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 183 | |
Pablo Neira Ayuso | 42e41df | 2011-08-17 22:44:07 +0200 | [diff] [blame] | 184 | osmo_signal_register_handler(SS_L_INPUT, inp_sig_cb, NULL); |
| 185 | osmo_signal_register_handler(SS_L_GLOBAL, gbl_sig_cb, NULL); |
Harald Welte | c2f27ba | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 186 | |
Pablo Neira Ayuso | 5bd96a7 | 2011-05-14 11:32:48 +0200 | [diff] [blame] | 187 | return 0; |
| 188 | } |
| 189 | |
| 190 | int bts_model_rbs2k_init(void) |
| 191 | { |
Harald Welte | c2f27ba | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 192 | return gsm_bts_model_register(&model_rbs2k); |
| 193 | } |