blob: a828937291232f317549e36f05239e51926d6b64 [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
Harald Weltedb44f602011-02-11 18:36:18 +010022
Pablo Neira Ayuso136f4532011-03-22 16:47:59 +010023#include <osmocom/gsm/tlv.h>
Harald Weltedb44f602011-02-11 18:36:18 +010024
25#include <openbsc/debug.h>
26#include <openbsc/gsm_data.h>
Harald Welte9a311ec2011-02-12 12:33:06 +010027#include <openbsc/abis_om2000.h>
Harald Welte1484d882011-03-06 22:12:24 +010028#include <openbsc/abis_nm.h>
Pablo Neira Ayusoed5cacb2011-08-17 22:44:07 +020029#include <osmocom/abis/e1_input.h>
Harald Weltedb44f602011-02-11 18:36:18 +010030#include <openbsc/signal.h>
31
Pablo Neira Ayusoed5cacb2011-08-17 22:44:07 +020032#include <osmocom/abis/lapd.h>
Harald Weltedb44f602011-02-11 18:36:18 +010033
Harald Welte9f0866c2011-02-13 19:44:47 +010034static void bootstrap_om_bts(struct gsm_bts *bts)
Harald Weltedb44f602011-02-11 18:36:18 +010035{
36 LOGP(DNM, LOGL_NOTICE, "bootstrapping OML for BTS %u\n", bts->nr);
Harald Welte591e1d72016-07-09 22:20:57 +020037
38 /* FIXME: this is global init, not bootstrapping */
39 abis_om2k_bts_init(bts);
40 abis_om2k_trx_init(bts->c0);
41
42 /* TODO: Should we wait for a Failure report? */
43 om2k_bts_fsm_start(bts);
Harald Weltedb44f602011-02-11 18:36:18 +010044}
45
Harald Welte9f0866c2011-02-13 19:44:47 +010046static void bootstrap_om_trx(struct gsm_bts_trx *trx)
47{
48 LOGP(DNM, LOGL_NOTICE, "bootstrapping OML for TRX %u/%u\n",
49 trx->bts->nr, trx->nr);
Harald Welte591e1d72016-07-09 22:20:57 +020050 /* FIXME */
Harald Welte9f0866c2011-02-13 19:44:47 +010051}
52
Harald Weltedb44f602011-02-11 18:36:18 +010053static int shutdown_om(struct gsm_bts *bts)
54{
55 /* FIXME */
56 return 0;
57}
58
Harald Weltedcf42e62011-02-13 11:58:21 +010059
60/* Tell LAPD to start start the SAP (send SABM requests) for all signalling
61 * timeslots in this line */
Harald Welte174a51a2011-02-13 14:26:54 +010062static void start_sabm_in_line(struct e1inp_line *line, int start)
Harald Weltedcf42e62011-02-13 11:58:21 +010063{
64 struct e1inp_sign_link *link;
65 int i;
66
67 for (i = 0; i < ARRAY_SIZE(line->ts); i++) {
68 struct e1inp_ts *ts = &line->ts[i];
69
70 if (ts->type != E1INP_TS_TYPE_SIGN)
71 continue;
72
73 llist_for_each_entry(link, &ts->sign.sign_links, list) {
Harald Welte174a51a2011-02-13 14:26:54 +010074 if (start)
Harald Welteb4d913d2011-08-26 19:14:55 +020075 lapd_sap_start(ts->lapd, link->tei, link->sapi);
Harald Welte174a51a2011-02-13 14:26:54 +010076 else
Harald Welteb4d913d2011-08-26 19:14:55 +020077 lapd_sap_stop(ts->lapd, link->tei, link->sapi);
Harald Weltedcf42e62011-02-13 11:58:21 +010078 }
79 }
80}
81
Harald Weltedb44f602011-02-11 18:36:18 +010082/* Callback function to be called every time we receive a signal from INPUT */
83static int gbl_sig_cb(unsigned int subsys, unsigned int signal,
84 void *handler_data, void *signal_data)
85{
86 struct gsm_bts *bts;
87
Pablo Neira Ayusoed5cacb2011-08-17 22:44:07 +020088 if (subsys != SS_L_GLOBAL)
Harald Weltedb44f602011-02-11 18:36:18 +010089 return 0;
90
91 switch (signal) {
92 case S_GLOBAL_BTS_CLOSE_OM:
93 bts = signal_data;
94 if (bts->type == GSM_BTS_TYPE_RBS2000)
95 shutdown_om(signal_data);
96 break;
97 }
98
99 return 0;
100}
101
Harald Weltedb44f602011-02-11 18:36:18 +0100102/* Callback function to be called every time we receive a signal from INPUT */
103static int inp_sig_cb(unsigned int subsys, unsigned int signal,
104 void *handler_data, void *signal_data)
105{
106 struct input_signal_data *isd = signal_data;
107
Pablo Neira Ayusoed5cacb2011-08-17 22:44:07 +0200108 if (subsys != SS_L_INPUT)
Harald Weltedb44f602011-02-11 18:36:18 +0100109 return 0;
110
111 switch (signal) {
Pablo Neira Ayusoed5cacb2011-08-17 22:44:07 +0200112 case S_L_INP_TEI_UP:
Harald Weltedb44f602011-02-11 18:36:18 +0100113 switch (isd->link_type) {
114 case E1INP_SIGN_OML:
Harald Welte9f0866c2011-02-13 19:44:47 +0100115 if (isd->trx->bts->type != GSM_BTS_TYPE_RBS2000)
116 break;
117 if (isd->tei == isd->trx->bts->oml_tei)
118 bootstrap_om_bts(isd->trx->bts);
119 else
120 bootstrap_om_trx(isd->trx);
Harald Weltedb44f602011-02-11 18:36:18 +0100121 break;
122 }
Harald Welte03cc8a82011-02-11 18:59:31 +0100123 break;
Pablo Neira Ayusoed5cacb2011-08-17 22:44:07 +0200124 case S_L_INP_LINE_INIT:
Andreas Eversbergc57e6ed2011-09-26 11:44:22 +0200125 case S_L_INP_LINE_NOALARM:
126 if (strcasecmp(isd->line->driver->name, "DAHDI")
127 && strcasecmp(isd->line->driver->name, "MISDN_LAPD"))
Harald Weltedb44f602011-02-11 18:36:18 +0100128 break;
Harald Welte174a51a2011-02-13 14:26:54 +0100129 start_sabm_in_line(isd->line, 1);
130 break;
Pablo Neira Ayusoed5cacb2011-08-17 22:44:07 +0200131 case S_L_INP_LINE_ALARM:
Andreas Eversbergc57e6ed2011-09-26 11:44:22 +0200132 if (strcasecmp(isd->line->driver->name, "DAHDI")
133 && strcasecmp(isd->line->driver->name, "MISDN_LAPD"))
Harald Welte174a51a2011-02-13 14:26:54 +0100134 break;
135 start_sabm_in_line(isd->line, 0);
136 break;
Harald Weltedb44f602011-02-11 18:36:18 +0100137 }
138
139 return 0;
140}
141
Harald Welte59eee422011-02-14 16:17:49 +0100142static void config_write_bts(struct vty *vty, struct gsm_bts *bts)
143{
144 abis_om2k_config_write_bts(vty, bts);
145}
146
Pablo Neira Ayuso0d2881a2011-05-14 11:32:48 +0200147static int bts_model_rbs2k_start(struct gsm_network *net);
148
Pablo Neira Ayusoed5cacb2011-08-17 22:44:07 +0200149static void bts_model_rbs2k_e1line_bind_ops(struct e1inp_line *line)
150{
151 e1inp_line_bind_ops(line, &bts_isdn_e1inp_line_ops);
152}
153
Harald Welte59eee422011-02-14 16:17:49 +0100154static struct gsm_bts_model model_rbs2k = {
155 .type = GSM_BTS_TYPE_RBS2000,
156 .name = "rbs2000",
Pablo Neira Ayuso0d2881a2011-05-14 11:32:48 +0200157 .start = bts_model_rbs2k_start,
Harald Welte59eee422011-02-14 16:17:49 +0100158 .oml_rcvmsg = &abis_om2k_rcvmsg,
159 .config_write_bts = &config_write_bts,
Pablo Neira Ayusoed5cacb2011-08-17 22:44:07 +0200160 .e1line_bind_ops = &bts_model_rbs2k_e1line_bind_ops,
Harald Welte59eee422011-02-14 16:17:49 +0100161};
162
Pablo Neira Ayuso0d2881a2011-05-14 11:32:48 +0200163static int bts_model_rbs2k_start(struct gsm_network *net)
Harald Weltedb44f602011-02-11 18:36:18 +0100164{
165 model_rbs2k.features.data = &model_rbs2k._features_data[0];
166 model_rbs2k.features.data_len = sizeof(model_rbs2k._features_data);
167
168 gsm_btsmodel_set_feature(&model_rbs2k, BTS_FEAT_HOPPING);
169 gsm_btsmodel_set_feature(&model_rbs2k, BTS_FEAT_HSCSD);
Harald Welte903aaea2014-01-19 17:10:50 +0100170 gsm_btsmodel_set_feature(&model_rbs2k, BTS_FEAT_MULTI_TSC);
Harald Weltedb44f602011-02-11 18:36:18 +0100171
Pablo Neira Ayusoed5cacb2011-08-17 22:44:07 +0200172 osmo_signal_register_handler(SS_L_INPUT, inp_sig_cb, NULL);
173 osmo_signal_register_handler(SS_L_GLOBAL, gbl_sig_cb, NULL);
Harald Weltedb44f602011-02-11 18:36:18 +0100174
Pablo Neira Ayuso0d2881a2011-05-14 11:32:48 +0200175 return 0;
176}
177
178int bts_model_rbs2k_init(void)
179{
Harald Weltedb44f602011-02-11 18:36:18 +0100180 return gsm_bts_model_register(&model_rbs2k);
181}