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 | |
| 34 | static struct gsm_bts_model model_rbs2k = { |
| 35 | .type = GSM_BTS_TYPE_RBS2000, |
Harald Welte | 2a0a963 | 2011-02-12 12:33:06 +0100 | [diff] [blame] | 36 | .name = "rbs2000", |
| 37 | .oml_rcvmsg = &abis_om2k_rcvmsg, |
Harald Welte | c2f27ba | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 38 | }; |
| 39 | |
| 40 | static void bootstrap_om_rbs2k(struct gsm_bts *bts) |
| 41 | { |
| 42 | LOGP(DNM, LOGL_NOTICE, "bootstrapping OML for BTS %u\n", bts->nr); |
| 43 | /* FIXME */ |
| 44 | } |
| 45 | |
| 46 | static int shutdown_om(struct gsm_bts *bts) |
| 47 | { |
| 48 | /* FIXME */ |
| 49 | return 0; |
| 50 | } |
| 51 | |
| 52 | /* Callback function to be called every time we receive a signal from INPUT */ |
| 53 | static int gbl_sig_cb(unsigned int subsys, unsigned int signal, |
| 54 | void *handler_data, void *signal_data) |
| 55 | { |
| 56 | struct gsm_bts *bts; |
| 57 | |
| 58 | if (subsys != SS_GLOBAL) |
| 59 | return 0; |
| 60 | |
| 61 | switch (signal) { |
| 62 | case S_GLOBAL_BTS_CLOSE_OM: |
| 63 | bts = signal_data; |
| 64 | if (bts->type == GSM_BTS_TYPE_RBS2000) |
| 65 | shutdown_om(signal_data); |
| 66 | break; |
| 67 | } |
| 68 | |
| 69 | return 0; |
| 70 | } |
| 71 | |
| 72 | static void sabm_timer_cb(void *_line); |
| 73 | |
Harald Welte | 89e466e | 2011-02-11 19:04:44 +0100 | [diff] [blame] | 74 | /* FIXME: we need one per bts (or rather: per signalling TS, not one global! */ |
Harald Welte | c2f27ba | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 75 | struct timer_list sabm_timer = { |
| 76 | .cb = &sabm_timer_cb, |
| 77 | }; |
| 78 | |
| 79 | static void sabm_timer_cb(void *_line) |
| 80 | { |
| 81 | struct e1inp_ts *e1i_ts = _line; |
| 82 | |
Harald Welte | 89e466e | 2011-02-11 19:04:44 +0100 | [diff] [blame] | 83 | /* FIXME: use the TEI that was configured via vty */ |
Harald Welte | f1e466a | 2011-02-11 18:59:31 +0100 | [diff] [blame] | 84 | lapd_send_sabm(e1i_ts->driver.dahdi.lapd, 62, 62); |
Harald Welte | c2f27ba | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 85 | |
| 86 | bsc_schedule_timer(&sabm_timer, 0, 50); |
| 87 | } |
| 88 | |
| 89 | /* Callback function to be called every time we receive a signal from INPUT */ |
| 90 | static int inp_sig_cb(unsigned int subsys, unsigned int signal, |
| 91 | void *handler_data, void *signal_data) |
| 92 | { |
| 93 | struct input_signal_data *isd = signal_data; |
| 94 | |
| 95 | if (subsys != SS_INPUT) |
| 96 | return 0; |
| 97 | |
| 98 | switch (signal) { |
| 99 | case S_INP_TEI_UP: |
| 100 | switch (isd->link_type) { |
| 101 | case E1INP_SIGN_OML: |
Harald Welte | 89e466e | 2011-02-11 19:04:44 +0100 | [diff] [blame] | 102 | if (isd->trx->bts->type == GSM_BTS_TYPE_RBS2000) { |
| 103 | /* FIXME: only disable the timer that belong sto this timeslot */ |
| 104 | bsc_del_timer(&sabm_timer); |
Harald Welte | c2f27ba | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 105 | bootstrap_om_rbs2k(isd->trx->bts); |
Harald Welte | 89e466e | 2011-02-11 19:04:44 +0100 | [diff] [blame] | 106 | } |
Harald Welte | c2f27ba | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 107 | break; |
| 108 | } |
Harald Welte | f1e466a | 2011-02-11 18:59:31 +0100 | [diff] [blame] | 109 | break; |
Harald Welte | c2f27ba | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 110 | case S_INP_LINE_INIT: |
| 111 | /* Right now Ericsson RBS are only supported on DAHDI */ |
| 112 | if (strcasecmp(isd->line->driver->name, "DAHDI")) |
| 113 | break; |
Harald Welte | 89e466e | 2011-02-11 19:04:44 +0100 | [diff] [blame] | 114 | /* FIXME: properly determine the OML signalling timeslot, |
| 115 | * or rather: all signalling timeslots and start one timer each */ |
Harald Welte | c2f27ba | 2011-02-11 18:36:18 +0100 | [diff] [blame] | 116 | sabm_timer.data = &isd->line->ts[1-1]; |
| 117 | bsc_schedule_timer(&sabm_timer, 0, 50); |
| 118 | break; |
| 119 | } |
| 120 | |
| 121 | return 0; |
| 122 | } |
| 123 | |
| 124 | int bts_model_rbs2k_init(void) |
| 125 | { |
| 126 | model_rbs2k.features.data = &model_rbs2k._features_data[0]; |
| 127 | model_rbs2k.features.data_len = sizeof(model_rbs2k._features_data); |
| 128 | |
| 129 | gsm_btsmodel_set_feature(&model_rbs2k, BTS_FEAT_HOPPING); |
| 130 | gsm_btsmodel_set_feature(&model_rbs2k, BTS_FEAT_HSCSD); |
| 131 | |
| 132 | register_signal_handler(SS_INPUT, inp_sig_cb, NULL); |
| 133 | register_signal_handler(SS_GLOBAL, gbl_sig_cb, NULL); |
| 134 | |
| 135 | return gsm_bts_model_register(&model_rbs2k); |
| 136 | } |