blob: 1d122eced79ff7074aaefa0a08e00e10eed753a4 [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;
Harald Welte7975ddf2016-10-16 23:44:16 +0200107 struct e1inp_ts *e1i_ts;
Harald Weltedb44f602011-02-11 18:36:18 +0100108
Pablo Neira Ayusoed5cacb2011-08-17 22:44:07 +0200109 if (subsys != SS_L_INPUT)
Harald Weltedb44f602011-02-11 18:36:18 +0100110 return 0;
111
112 switch (signal) {
Pablo Neira Ayusoed5cacb2011-08-17 22:44:07 +0200113 case S_L_INP_TEI_UP:
Harald Weltedb44f602011-02-11 18:36:18 +0100114 switch (isd->link_type) {
115 case E1INP_SIGN_OML:
Harald Welte9f0866c2011-02-13 19:44:47 +0100116 if (isd->trx->bts->type != GSM_BTS_TYPE_RBS2000)
117 break;
118 if (isd->tei == isd->trx->bts->oml_tei)
119 bootstrap_om_bts(isd->trx->bts);
120 else
121 bootstrap_om_trx(isd->trx);
Harald Weltedb44f602011-02-11 18:36:18 +0100122 break;
123 }
Harald Welte03cc8a82011-02-11 18:59:31 +0100124 break;
Harald Welte7975ddf2016-10-16 23:44:16 +0200125 case S_L_INP_TEI_DN:
126 if (isd->trx->bts->type != GSM_BTS_TYPE_RBS2000)
127 break;
128 LOGP(DNM, LOGL_NOTICE, "Line-%u TS-%u TEI-%u SAPI-%u: Link "
129 "Lost for Ericsson RBS2000. Re-starting DL Establishment\n",
130 isd->line->num, isd->ts_nr, isd->tei, isd->sapi);
131 /* Some datalink for a given TEI/SAPI went down, try to re-start it */
132 e1i_ts = &isd->line->ts[isd->ts_nr-1];
133 OSMO_ASSERT(e1i_ts->type == E1INP_TS_TYPE_SIGN);
134 lapd_sap_start(e1i_ts->lapd, isd->tei, isd->sapi);
135 break;
Pablo Neira Ayusoed5cacb2011-08-17 22:44:07 +0200136 case S_L_INP_LINE_INIT:
Andreas Eversbergc57e6ed2011-09-26 11:44:22 +0200137 case S_L_INP_LINE_NOALARM:
138 if (strcasecmp(isd->line->driver->name, "DAHDI")
139 && strcasecmp(isd->line->driver->name, "MISDN_LAPD"))
Harald Weltedb44f602011-02-11 18:36:18 +0100140 break;
Harald Welte174a51a2011-02-13 14:26:54 +0100141 start_sabm_in_line(isd->line, 1);
142 break;
Pablo Neira Ayusoed5cacb2011-08-17 22:44:07 +0200143 case S_L_INP_LINE_ALARM:
Andreas Eversbergc57e6ed2011-09-26 11:44:22 +0200144 if (strcasecmp(isd->line->driver->name, "DAHDI")
145 && strcasecmp(isd->line->driver->name, "MISDN_LAPD"))
Harald Welte174a51a2011-02-13 14:26:54 +0100146 break;
147 start_sabm_in_line(isd->line, 0);
148 break;
Harald Weltedb44f602011-02-11 18:36:18 +0100149 }
150
151 return 0;
152}
153
Harald Welte59eee422011-02-14 16:17:49 +0100154static void config_write_bts(struct vty *vty, struct gsm_bts *bts)
155{
156 abis_om2k_config_write_bts(vty, bts);
157}
158
Pablo Neira Ayuso0d2881a2011-05-14 11:32:48 +0200159static int bts_model_rbs2k_start(struct gsm_network *net);
160
Pablo Neira Ayusoed5cacb2011-08-17 22:44:07 +0200161static void bts_model_rbs2k_e1line_bind_ops(struct e1inp_line *line)
162{
163 e1inp_line_bind_ops(line, &bts_isdn_e1inp_line_ops);
164}
165
Harald Welte59eee422011-02-14 16:17:49 +0100166static struct gsm_bts_model model_rbs2k = {
167 .type = GSM_BTS_TYPE_RBS2000,
168 .name = "rbs2000",
Pablo Neira Ayuso0d2881a2011-05-14 11:32:48 +0200169 .start = bts_model_rbs2k_start,
Harald Welte59eee422011-02-14 16:17:49 +0100170 .oml_rcvmsg = &abis_om2k_rcvmsg,
171 .config_write_bts = &config_write_bts,
Pablo Neira Ayusoed5cacb2011-08-17 22:44:07 +0200172 .e1line_bind_ops = &bts_model_rbs2k_e1line_bind_ops,
Harald Welte59eee422011-02-14 16:17:49 +0100173};
174
Pablo Neira Ayuso0d2881a2011-05-14 11:32:48 +0200175static int bts_model_rbs2k_start(struct gsm_network *net)
Harald Weltedb44f602011-02-11 18:36:18 +0100176{
177 model_rbs2k.features.data = &model_rbs2k._features_data[0];
178 model_rbs2k.features.data_len = sizeof(model_rbs2k._features_data);
179
180 gsm_btsmodel_set_feature(&model_rbs2k, BTS_FEAT_HOPPING);
181 gsm_btsmodel_set_feature(&model_rbs2k, BTS_FEAT_HSCSD);
Harald Welte903aaea2014-01-19 17:10:50 +0100182 gsm_btsmodel_set_feature(&model_rbs2k, BTS_FEAT_MULTI_TSC);
Harald Weltedb44f602011-02-11 18:36:18 +0100183
Pablo Neira Ayusoed5cacb2011-08-17 22:44:07 +0200184 osmo_signal_register_handler(SS_L_INPUT, inp_sig_cb, NULL);
185 osmo_signal_register_handler(SS_L_GLOBAL, gbl_sig_cb, NULL);
Harald Weltedb44f602011-02-11 18:36:18 +0100186
Pablo Neira Ayuso0d2881a2011-05-14 11:32:48 +0200187 return 0;
188}
189
190int bts_model_rbs2k_init(void)
191{
Harald Weltedb44f602011-02-11 18:36:18 +0100192 return gsm_bts_model_register(&model_rbs2k);
193}