blob: 99da4e75fda87b1e0e55dbde4363a87a5d0479c2 [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 Weltec1efa672016-11-11 19:42:19 +010074 if (!ts->lapd)
75 continue;
Philipp6bbcfbb2016-10-26 14:20:06 +020076 lapd_instance_set_profile(ts->lapd,
77 &lapd_profile_abis_ericsson);
78
Harald Welte174a51a2011-02-13 14:26:54 +010079 if (start)
Harald Welteb4d913d2011-08-26 19:14:55 +020080 lapd_sap_start(ts->lapd, link->tei, link->sapi);
Harald Welte174a51a2011-02-13 14:26:54 +010081 else
Harald Welteb4d913d2011-08-26 19:14:55 +020082 lapd_sap_stop(ts->lapd, link->tei, link->sapi);
Harald Weltedcf42e62011-02-13 11:58:21 +010083 }
84 }
85}
86
Harald Weltedb44f602011-02-11 18:36:18 +010087/* Callback function to be called every time we receive a signal from INPUT */
88static int gbl_sig_cb(unsigned int subsys, unsigned int signal,
89 void *handler_data, void *signal_data)
90{
91 struct gsm_bts *bts;
92
Pablo Neira Ayusoed5cacb2011-08-17 22:44:07 +020093 if (subsys != SS_L_GLOBAL)
Harald Weltedb44f602011-02-11 18:36:18 +010094 return 0;
95
96 switch (signal) {
97 case S_GLOBAL_BTS_CLOSE_OM:
98 bts = signal_data;
99 if (bts->type == GSM_BTS_TYPE_RBS2000)
100 shutdown_om(signal_data);
101 break;
102 }
103
104 return 0;
105}
106
Harald Weltedb44f602011-02-11 18:36:18 +0100107/* Callback function to be called every time we receive a signal from INPUT */
108static int inp_sig_cb(unsigned int subsys, unsigned int signal,
109 void *handler_data, void *signal_data)
110{
111 struct input_signal_data *isd = signal_data;
Harald Welte7975ddf2016-10-16 23:44:16 +0200112 struct e1inp_ts *e1i_ts;
Harald Weltedb44f602011-02-11 18:36:18 +0100113
Pablo Neira Ayusoed5cacb2011-08-17 22:44:07 +0200114 if (subsys != SS_L_INPUT)
Harald Weltedb44f602011-02-11 18:36:18 +0100115 return 0;
116
Harald Welte5f72f6f2017-05-25 19:16:40 +0200117 LOGP(DNM, LOGL_DEBUG, "%s(): Input signal '%s' received\n", __func__,
118 get_value_string(e1inp_signal_names, signal));
Harald Weltedb44f602011-02-11 18:36:18 +0100119 switch (signal) {
Pablo Neira Ayusoed5cacb2011-08-17 22:44:07 +0200120 case S_L_INP_TEI_UP:
Harald Weltedb44f602011-02-11 18:36:18 +0100121 switch (isd->link_type) {
122 case E1INP_SIGN_OML:
Harald Welte9f0866c2011-02-13 19:44:47 +0100123 if (isd->trx->bts->type != GSM_BTS_TYPE_RBS2000)
124 break;
125 if (isd->tei == isd->trx->bts->oml_tei)
126 bootstrap_om_bts(isd->trx->bts);
127 else
128 bootstrap_om_trx(isd->trx);
Harald Weltedb44f602011-02-11 18:36:18 +0100129 break;
130 }
Harald Welte03cc8a82011-02-11 18:59:31 +0100131 break;
Harald Welte7975ddf2016-10-16 23:44:16 +0200132 case S_L_INP_TEI_DN:
133 if (isd->trx->bts->type != GSM_BTS_TYPE_RBS2000)
134 break;
135 LOGP(DNM, LOGL_NOTICE, "Line-%u TS-%u TEI-%u SAPI-%u: Link "
136 "Lost for Ericsson RBS2000. Re-starting DL Establishment\n",
137 isd->line->num, isd->ts_nr, isd->tei, isd->sapi);
138 /* Some datalink for a given TEI/SAPI went down, try to re-start it */
139 e1i_ts = &isd->line->ts[isd->ts_nr-1];
140 OSMO_ASSERT(e1i_ts->type == E1INP_TS_TYPE_SIGN);
141 lapd_sap_start(e1i_ts->lapd, isd->tei, isd->sapi);
142 break;
Pablo Neira Ayusoed5cacb2011-08-17 22:44:07 +0200143 case S_L_INP_LINE_INIT:
Andreas Eversbergc57e6ed2011-09-26 11:44:22 +0200144 case S_L_INP_LINE_NOALARM:
145 if (strcasecmp(isd->line->driver->name, "DAHDI")
Alexander Couzensdfb138f2016-11-01 23:39:03 +0100146 && strcasecmp(isd->line->driver->name, "MISDN_LAPD")
147 && strcasecmp(isd->line->driver->name, "UNIXSOCKET"))
Harald Weltedb44f602011-02-11 18:36:18 +0100148 break;
Harald Welte174a51a2011-02-13 14:26:54 +0100149 start_sabm_in_line(isd->line, 1);
150 break;
Pablo Neira Ayusoed5cacb2011-08-17 22:44:07 +0200151 case S_L_INP_LINE_ALARM:
Andreas Eversbergc57e6ed2011-09-26 11:44:22 +0200152 if (strcasecmp(isd->line->driver->name, "DAHDI")
Alexander Couzensdfb138f2016-11-01 23:39:03 +0100153 && strcasecmp(isd->line->driver->name, "MISDN_LAPD")
154 && strcasecmp(isd->line->driver->name, "UNIXSOCKET"))
Harald Welte174a51a2011-02-13 14:26:54 +0100155 break;
156 start_sabm_in_line(isd->line, 0);
157 break;
Harald Weltedb44f602011-02-11 18:36:18 +0100158 }
159
160 return 0;
161}
162
Harald Welte59eee422011-02-14 16:17:49 +0100163static void config_write_bts(struct vty *vty, struct gsm_bts *bts)
164{
165 abis_om2k_config_write_bts(vty, bts);
166}
167
Pablo Neira Ayuso0d2881a2011-05-14 11:32:48 +0200168static int bts_model_rbs2k_start(struct gsm_network *net);
169
Pablo Neira Ayusoed5cacb2011-08-17 22:44:07 +0200170static void bts_model_rbs2k_e1line_bind_ops(struct e1inp_line *line)
171{
172 e1inp_line_bind_ops(line, &bts_isdn_e1inp_line_ops);
173}
174
Harald Welte59eee422011-02-14 16:17:49 +0100175static struct gsm_bts_model model_rbs2k = {
176 .type = GSM_BTS_TYPE_RBS2000,
177 .name = "rbs2000",
Pablo Neira Ayuso0d2881a2011-05-14 11:32:48 +0200178 .start = bts_model_rbs2k_start,
Harald Welte59eee422011-02-14 16:17:49 +0100179 .oml_rcvmsg = &abis_om2k_rcvmsg,
180 .config_write_bts = &config_write_bts,
Pablo Neira Ayusoed5cacb2011-08-17 22:44:07 +0200181 .e1line_bind_ops = &bts_model_rbs2k_e1line_bind_ops,
Harald Welte59eee422011-02-14 16:17:49 +0100182};
183
Pablo Neira Ayuso0d2881a2011-05-14 11:32:48 +0200184static int bts_model_rbs2k_start(struct gsm_network *net)
Harald Weltedb44f602011-02-11 18:36:18 +0100185{
186 model_rbs2k.features.data = &model_rbs2k._features_data[0];
187 model_rbs2k.features.data_len = sizeof(model_rbs2k._features_data);
188
Philippfb89b9b2016-10-27 17:54:00 +0200189 gsm_btsmodel_set_feature(&model_rbs2k, BTS_FEAT_GPRS);
190 gsm_btsmodel_set_feature(&model_rbs2k, BTS_FEAT_EGPRS);
Harald Weltedb44f602011-02-11 18:36:18 +0100191 gsm_btsmodel_set_feature(&model_rbs2k, BTS_FEAT_HOPPING);
192 gsm_btsmodel_set_feature(&model_rbs2k, BTS_FEAT_HSCSD);
Harald Welte903aaea2014-01-19 17:10:50 +0100193 gsm_btsmodel_set_feature(&model_rbs2k, BTS_FEAT_MULTI_TSC);
Harald Weltedb44f602011-02-11 18:36:18 +0100194
Pablo Neira Ayusoed5cacb2011-08-17 22:44:07 +0200195 osmo_signal_register_handler(SS_L_INPUT, inp_sig_cb, NULL);
196 osmo_signal_register_handler(SS_L_GLOBAL, gbl_sig_cb, NULL);
Harald Weltedb44f602011-02-11 18:36:18 +0100197
Pablo Neira Ayuso0d2881a2011-05-14 11:32:48 +0200198 return 0;
199}
200
201int bts_model_rbs2k_init(void)
202{
Harald Weltedb44f602011-02-11 18:36:18 +0100203 return gsm_bts_model_register(&model_rbs2k);
204}