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 | |
| 22 | #include <sys/types.h> |
| 23 | |
| 24 | #include <osmocore/tlv.h> |
| 25 | |
| 26 | #include <openbsc/debug.h> |
| 27 | #include <openbsc/gsm_data.h> |
Harald Welte | 2a0a963 | 2011-02-12 12:33:06 +0100 | [diff] [blame] | 28 | #include <openbsc/abis_om2000.h> |
Harald Welte | c2f27ba | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 29 | #include <openbsc/e1_input.h> |
| 30 | #include <openbsc/signal.h> |
| 31 | |
Harald Welte | 2a0a963 | 2011-02-12 12:33:06 +0100 | [diff] [blame] | 32 | #include "input/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 | 4f3644b | 2011-02-12 13:44:14 +0100 | [diff] [blame] | 37 | abis_om2k_tx_start_req(bts, &om2k_mo_cf); |
Harald Welte | c2f27ba | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 38 | /* FIXME */ |
| 39 | } |
| 40 | |
Harald Welte | 436b8cf | 2011-02-13 19:44:47 +0100 | [diff] [blame] | 41 | static void bootstrap_om_trx(struct gsm_bts_trx *trx) |
| 42 | { |
| 43 | LOGP(DNM, LOGL_NOTICE, "bootstrapping OML for TRX %u/%u\n", |
| 44 | trx->bts->nr, trx->nr); |
| 45 | /* FIXME */ |
| 46 | } |
| 47 | |
Harald Welte | c2f27ba | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 48 | static int shutdown_om(struct gsm_bts *bts) |
| 49 | { |
| 50 | /* FIXME */ |
| 51 | return 0; |
| 52 | } |
| 53 | |
Harald Welte | 0303a36 | 2011-02-13 11:58:21 +0100 | [diff] [blame] | 54 | |
| 55 | /* Tell LAPD to start start the SAP (send SABM requests) for all signalling |
| 56 | * timeslots in this line */ |
Harald Welte | 5434bfa | 2011-02-13 14:26:54 +0100 | [diff] [blame] | 57 | static void start_sabm_in_line(struct e1inp_line *line, int start) |
Harald Welte | 0303a36 | 2011-02-13 11:58:21 +0100 | [diff] [blame] | 58 | { |
| 59 | struct e1inp_sign_link *link; |
| 60 | int i; |
| 61 | |
| 62 | for (i = 0; i < ARRAY_SIZE(line->ts); i++) { |
| 63 | struct e1inp_ts *ts = &line->ts[i]; |
| 64 | |
| 65 | if (ts->type != E1INP_TS_TYPE_SIGN) |
| 66 | continue; |
| 67 | |
| 68 | llist_for_each_entry(link, &ts->sign.sign_links, list) { |
Harald Welte | 5434bfa | 2011-02-13 14:26:54 +0100 | [diff] [blame] | 69 | if (start) |
| 70 | lapd_sap_start(ts->driver.dahdi.lapd, link->tei, link->sapi); |
| 71 | else |
| 72 | lapd_sap_stop(ts->driver.dahdi.lapd, link->tei, link->sapi); |
Harald Welte | 0303a36 | 2011-02-13 11:58:21 +0100 | [diff] [blame] | 73 | } |
| 74 | } |
| 75 | } |
| 76 | |
Harald Welte | c2f27ba | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 77 | /* Callback function to be called every time we receive a signal from INPUT */ |
| 78 | static int gbl_sig_cb(unsigned int subsys, unsigned int signal, |
| 79 | void *handler_data, void *signal_data) |
| 80 | { |
| 81 | struct gsm_bts *bts; |
| 82 | |
| 83 | if (subsys != SS_GLOBAL) |
| 84 | return 0; |
| 85 | |
| 86 | switch (signal) { |
| 87 | case S_GLOBAL_BTS_CLOSE_OM: |
| 88 | bts = signal_data; |
| 89 | if (bts->type == GSM_BTS_TYPE_RBS2000) |
| 90 | shutdown_om(signal_data); |
| 91 | break; |
| 92 | } |
| 93 | |
| 94 | return 0; |
| 95 | } |
| 96 | |
Harald Welte | c2f27ba | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 97 | /* Callback function to be called every time we receive a signal from INPUT */ |
| 98 | static int inp_sig_cb(unsigned int subsys, unsigned int signal, |
| 99 | void *handler_data, void *signal_data) |
| 100 | { |
| 101 | struct input_signal_data *isd = signal_data; |
| 102 | |
| 103 | if (subsys != SS_INPUT) |
| 104 | return 0; |
| 105 | |
| 106 | switch (signal) { |
| 107 | case S_INP_TEI_UP: |
| 108 | switch (isd->link_type) { |
| 109 | case E1INP_SIGN_OML: |
Harald Welte | 436b8cf | 2011-02-13 19:44:47 +0100 | [diff] [blame] | 110 | if (isd->trx->bts->type != GSM_BTS_TYPE_RBS2000) |
| 111 | break; |
| 112 | if (isd->tei == isd->trx->bts->oml_tei) |
| 113 | bootstrap_om_bts(isd->trx->bts); |
| 114 | else |
| 115 | bootstrap_om_trx(isd->trx); |
Harald Welte | c2f27ba | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 116 | break; |
| 117 | } |
Harald Welte | f1e466a | 2011-02-11 18:59:31 +0100 | [diff] [blame] | 118 | break; |
Harald Welte | c2f27ba | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 119 | case S_INP_LINE_INIT: |
| 120 | /* Right now Ericsson RBS are only supported on DAHDI */ |
| 121 | if (strcasecmp(isd->line->driver->name, "DAHDI")) |
| 122 | break; |
Harald Welte | 5434bfa | 2011-02-13 14:26:54 +0100 | [diff] [blame] | 123 | start_sabm_in_line(isd->line, 1); |
| 124 | break; |
| 125 | case S_INP_LINE_ALARM: |
| 126 | if (strcasecmp(isd->line->driver->name, "DAHDI")) |
| 127 | break; |
| 128 | start_sabm_in_line(isd->line, 0); |
| 129 | break; |
| 130 | case S_INP_LINE_NOALARM: |
| 131 | if (strcasecmp(isd->line->driver->name, "DAHDI")) |
| 132 | break; |
| 133 | start_sabm_in_line(isd->line, 1); |
Harald Welte | c2f27ba | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 134 | break; |
| 135 | } |
| 136 | |
| 137 | return 0; |
| 138 | } |
| 139 | |
Harald Welte | bf7a534 | 2011-02-14 16:17:49 +0100 | [diff] [blame] | 140 | static void config_write_bts(struct vty *vty, struct gsm_bts *bts) |
| 141 | { |
| 142 | abis_om2k_config_write_bts(vty, bts); |
| 143 | } |
| 144 | |
| 145 | static struct gsm_bts_model model_rbs2k = { |
| 146 | .type = GSM_BTS_TYPE_RBS2000, |
| 147 | .name = "rbs2000", |
| 148 | .oml_rcvmsg = &abis_om2k_rcvmsg, |
| 149 | .config_write_bts = &config_write_bts, |
| 150 | }; |
| 151 | |
Harald Welte | c2f27ba | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 152 | int bts_model_rbs2k_init(void) |
| 153 | { |
| 154 | model_rbs2k.features.data = &model_rbs2k._features_data[0]; |
| 155 | model_rbs2k.features.data_len = sizeof(model_rbs2k._features_data); |
| 156 | |
| 157 | gsm_btsmodel_set_feature(&model_rbs2k, BTS_FEAT_HOPPING); |
| 158 | gsm_btsmodel_set_feature(&model_rbs2k, BTS_FEAT_HSCSD); |
| 159 | |
| 160 | register_signal_handler(SS_INPUT, inp_sig_cb, NULL); |
| 161 | register_signal_handler(SS_GLOBAL, gbl_sig_cb, NULL); |
| 162 | |
| 163 | return gsm_bts_model_register(&model_rbs2k); |
| 164 | } |