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