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 | |
| 71 | /* FIXME: we need one per bts, not one global! */ |
| 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 | |
| 80 | lapd_transmit_sabm(e1i_ts->driver.dahdi.lapd, 62, 62); |
| 81 | |
| 82 | bsc_schedule_timer(&sabm_timer, 0, 50); |
| 83 | } |
| 84 | |
| 85 | /* Callback function to be called every time we receive a signal from INPUT */ |
| 86 | static int inp_sig_cb(unsigned int subsys, unsigned int signal, |
| 87 | void *handler_data, void *signal_data) |
| 88 | { |
| 89 | struct input_signal_data *isd = signal_data; |
| 90 | |
| 91 | if (subsys != SS_INPUT) |
| 92 | return 0; |
| 93 | |
| 94 | switch (signal) { |
| 95 | case S_INP_TEI_UP: |
| 96 | switch (isd->link_type) { |
| 97 | case E1INP_SIGN_OML: |
| 98 | if (isd->trx->bts->type == GSM_BTS_TYPE_BS11) |
| 99 | bootstrap_om_rbs2k(isd->trx->bts); |
| 100 | break; |
| 101 | } |
| 102 | case S_INP_LINE_INIT: |
| 103 | /* Right now Ericsson RBS are only supported on DAHDI */ |
| 104 | if (strcasecmp(isd->line->driver->name, "DAHDI")) |
| 105 | break; |
| 106 | sabm_timer.data = &isd->line->ts[1-1]; |
| 107 | bsc_schedule_timer(&sabm_timer, 0, 50); |
| 108 | break; |
| 109 | } |
| 110 | |
| 111 | return 0; |
| 112 | } |
| 113 | |
| 114 | int bts_model_rbs2k_init(void) |
| 115 | { |
| 116 | model_rbs2k.features.data = &model_rbs2k._features_data[0]; |
| 117 | model_rbs2k.features.data_len = sizeof(model_rbs2k._features_data); |
| 118 | |
| 119 | gsm_btsmodel_set_feature(&model_rbs2k, BTS_FEAT_HOPPING); |
| 120 | gsm_btsmodel_set_feature(&model_rbs2k, BTS_FEAT_HSCSD); |
| 121 | |
| 122 | register_signal_handler(SS_INPUT, inp_sig_cb, NULL); |
| 123 | register_signal_handler(SS_GLOBAL, gbl_sig_cb, NULL); |
| 124 | |
| 125 | return gsm_bts_model_register(&model_rbs2k); |
| 126 | } |