blob: 4d368c82048d125ae067b0c60df3d7b49d5c17d1 [file] [log] [blame]
Harald Weltedb44f602011-02-11 18:36:18 +01001/* 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 Welte9a311ec2011-02-12 12:33:06 +010028#include <openbsc/abis_om2000.h>
Harald Weltedb44f602011-02-11 18:36:18 +010029#include <openbsc/e1_input.h>
30#include <openbsc/signal.h>
31
Harald Welte9a311ec2011-02-12 12:33:06 +010032#include "input/lapd.h"
Harald Weltedb44f602011-02-11 18:36:18 +010033
Harald Welte334c5ab2011-02-13 10:40:58 +010034#define SABM_INTERVAL 0, 300000
35
Harald Weltedb44f602011-02-11 18:36:18 +010036static struct gsm_bts_model model_rbs2k = {
37 .type = GSM_BTS_TYPE_RBS2000,
Harald Welte9a311ec2011-02-12 12:33:06 +010038 .name = "rbs2000",
39 .oml_rcvmsg = &abis_om2k_rcvmsg,
Harald Weltedb44f602011-02-11 18:36:18 +010040};
41
42static void bootstrap_om_rbs2k(struct gsm_bts *bts)
43{
44 LOGP(DNM, LOGL_NOTICE, "bootstrapping OML for BTS %u\n", bts->nr);
Harald Welte73541072011-02-12 13:44:14 +010045 abis_om2k_tx_start_req(bts, &om2k_mo_cf);
Harald Weltedb44f602011-02-11 18:36:18 +010046 /* FIXME */
47}
48
49static int shutdown_om(struct gsm_bts *bts)
50{
51 /* FIXME */
52 return 0;
53}
54
55/* Callback function to be called every time we receive a signal from INPUT */
56static int gbl_sig_cb(unsigned int subsys, unsigned int signal,
57 void *handler_data, void *signal_data)
58{
59 struct gsm_bts *bts;
60
61 if (subsys != SS_GLOBAL)
62 return 0;
63
64 switch (signal) {
65 case S_GLOBAL_BTS_CLOSE_OM:
66 bts = signal_data;
67 if (bts->type == GSM_BTS_TYPE_RBS2000)
68 shutdown_om(signal_data);
69 break;
70 }
71
72 return 0;
73}
74
75static void sabm_timer_cb(void *_line);
76
Harald Welteb80e14e2011-02-11 19:04:44 +010077/* FIXME: we need one per bts (or rather: per signalling TS, not one global! */
Harald Weltedb44f602011-02-11 18:36:18 +010078struct timer_list sabm_timer = {
79 .cb = &sabm_timer_cb,
80};
81
82static void sabm_timer_cb(void *_line)
83{
84 struct e1inp_ts *e1i_ts = _line;
85
Harald Welteb80e14e2011-02-11 19:04:44 +010086 /* FIXME: use the TEI that was configured via vty */
Harald Welte03cc8a82011-02-11 18:59:31 +010087 lapd_send_sabm(e1i_ts->driver.dahdi.lapd, 62, 62);
Harald Weltedb44f602011-02-11 18:36:18 +010088
Harald Welte334c5ab2011-02-13 10:40:58 +010089 bsc_schedule_timer(&sabm_timer, SABM_INTERVAL);
Harald Weltedb44f602011-02-11 18:36:18 +010090}
91
92/* Callback function to be called every time we receive a signal from INPUT */
93static int inp_sig_cb(unsigned int subsys, unsigned int signal,
94 void *handler_data, void *signal_data)
95{
96 struct input_signal_data *isd = signal_data;
97
98 if (subsys != SS_INPUT)
99 return 0;
100
101 switch (signal) {
102 case S_INP_TEI_UP:
103 switch (isd->link_type) {
104 case E1INP_SIGN_OML:
Harald Welteb80e14e2011-02-11 19:04:44 +0100105 if (isd->trx->bts->type == GSM_BTS_TYPE_RBS2000) {
106 /* FIXME: only disable the timer that belong sto this timeslot */
107 bsc_del_timer(&sabm_timer);
Harald Weltedb44f602011-02-11 18:36:18 +0100108 bootstrap_om_rbs2k(isd->trx->bts);
Harald Welteb80e14e2011-02-11 19:04:44 +0100109 }
Harald Weltedb44f602011-02-11 18:36:18 +0100110 break;
111 }
Harald Welte03cc8a82011-02-11 18:59:31 +0100112 break;
Harald Weltedb44f602011-02-11 18:36:18 +0100113 case S_INP_LINE_INIT:
114 /* Right now Ericsson RBS are only supported on DAHDI */
115 if (strcasecmp(isd->line->driver->name, "DAHDI"))
116 break;
Harald Welteb80e14e2011-02-11 19:04:44 +0100117 /* FIXME: properly determine the OML signalling timeslot,
118 * or rather: all signalling timeslots and start one timer each */
Harald Weltedb44f602011-02-11 18:36:18 +0100119 sabm_timer.data = &isd->line->ts[1-1];
Harald Welte334c5ab2011-02-13 10:40:58 +0100120 bsc_schedule_timer(&sabm_timer, SABM_INTERVAL);
Harald Weltedb44f602011-02-11 18:36:18 +0100121 break;
122 }
123
124 return 0;
125}
126
127int bts_model_rbs2k_init(void)
128{
129 model_rbs2k.features.data = &model_rbs2k._features_data[0];
130 model_rbs2k.features.data_len = sizeof(model_rbs2k._features_data);
131
132 gsm_btsmodel_set_feature(&model_rbs2k, BTS_FEAT_HOPPING);
133 gsm_btsmodel_set_feature(&model_rbs2k, BTS_FEAT_HSCSD);
134
135 register_signal_handler(SS_INPUT, inp_sig_cb, NULL);
136 register_signal_handler(SS_GLOBAL, gbl_sig_cb, NULL);
137
138 return gsm_bts_model_register(&model_rbs2k);
139}