blob: fa25f3aa1ca5061d51cbc5f09e33f8cdc4e9103d [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
34static struct gsm_bts_model model_rbs2k = {
35 .type = GSM_BTS_TYPE_RBS2000,
Harald Welte9a311ec2011-02-12 12:33:06 +010036 .name = "rbs2000",
37 .oml_rcvmsg = &abis_om2k_rcvmsg,
Harald Weltedb44f602011-02-11 18:36:18 +010038};
39
Harald Welte9f0866c2011-02-13 19:44:47 +010040static void bootstrap_om_bts(struct gsm_bts *bts)
Harald Weltedb44f602011-02-11 18:36:18 +010041{
42 LOGP(DNM, LOGL_NOTICE, "bootstrapping OML for BTS %u\n", bts->nr);
Harald Welte73541072011-02-12 13:44:14 +010043 abis_om2k_tx_start_req(bts, &om2k_mo_cf);
Harald Weltedb44f602011-02-11 18:36:18 +010044 /* FIXME */
45}
46
Harald Welte9f0866c2011-02-13 19:44:47 +010047static void bootstrap_om_trx(struct gsm_bts_trx *trx)
48{
49 LOGP(DNM, LOGL_NOTICE, "bootstrapping OML for TRX %u/%u\n",
50 trx->bts->nr, trx->nr);
51 /* FIXME */
52}
53
Harald Weltedb44f602011-02-11 18:36:18 +010054static int shutdown_om(struct gsm_bts *bts)
55{
56 /* FIXME */
57 return 0;
58}
59
Harald Weltedcf42e62011-02-13 11:58:21 +010060
61/* Tell LAPD to start start the SAP (send SABM requests) for all signalling
62 * timeslots in this line */
Harald Welte174a51a2011-02-13 14:26:54 +010063static void start_sabm_in_line(struct e1inp_line *line, int start)
Harald Weltedcf42e62011-02-13 11:58:21 +010064{
65 struct e1inp_sign_link *link;
66 int i;
67
68 for (i = 0; i < ARRAY_SIZE(line->ts); i++) {
69 struct e1inp_ts *ts = &line->ts[i];
70
71 if (ts->type != E1INP_TS_TYPE_SIGN)
72 continue;
73
74 llist_for_each_entry(link, &ts->sign.sign_links, list) {
Harald Welte174a51a2011-02-13 14:26:54 +010075 if (start)
76 lapd_sap_start(ts->driver.dahdi.lapd, link->tei, link->sapi);
77 else
78 lapd_sap_stop(ts->driver.dahdi.lapd, link->tei, link->sapi);
Harald Weltedcf42e62011-02-13 11:58:21 +010079 }
80 }
81}
82
Harald Weltedb44f602011-02-11 18:36:18 +010083/* Callback function to be called every time we receive a signal from INPUT */
84static int gbl_sig_cb(unsigned int subsys, unsigned int signal,
85 void *handler_data, void *signal_data)
86{
87 struct gsm_bts *bts;
88
89 if (subsys != SS_GLOBAL)
90 return 0;
91
92 switch (signal) {
93 case S_GLOBAL_BTS_CLOSE_OM:
94 bts = signal_data;
95 if (bts->type == GSM_BTS_TYPE_RBS2000)
96 shutdown_om(signal_data);
97 break;
98 }
99
100 return 0;
101}
102
Harald Weltedb44f602011-02-11 18:36:18 +0100103/* Callback function to be called every time we receive a signal from INPUT */
104static int inp_sig_cb(unsigned int subsys, unsigned int signal,
105 void *handler_data, void *signal_data)
106{
107 struct input_signal_data *isd = signal_data;
108
109 if (subsys != SS_INPUT)
110 return 0;
111
112 switch (signal) {
113 case S_INP_TEI_UP:
114 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 Weltedb44f602011-02-11 18:36:18 +0100125 case S_INP_LINE_INIT:
126 /* Right now Ericsson RBS are only supported on DAHDI */
127 if (strcasecmp(isd->line->driver->name, "DAHDI"))
128 break;
Harald Welte174a51a2011-02-13 14:26:54 +0100129 start_sabm_in_line(isd->line, 1);
130 break;
131 case S_INP_LINE_ALARM:
132 if (strcasecmp(isd->line->driver->name, "DAHDI"))
133 break;
134 start_sabm_in_line(isd->line, 0);
135 break;
136 case S_INP_LINE_NOALARM:
137 if (strcasecmp(isd->line->driver->name, "DAHDI"))
138 break;
139 start_sabm_in_line(isd->line, 1);
Harald Weltedb44f602011-02-11 18:36:18 +0100140 break;
141 }
142
143 return 0;
144}
145
146int bts_model_rbs2k_init(void)
147{
148 model_rbs2k.features.data = &model_rbs2k._features_data[0];
149 model_rbs2k.features.data_len = sizeof(model_rbs2k._features_data);
150
151 gsm_btsmodel_set_feature(&model_rbs2k, BTS_FEAT_HOPPING);
152 gsm_btsmodel_set_feature(&model_rbs2k, BTS_FEAT_HSCSD);
153
154 register_signal_handler(SS_INPUT, inp_sig_cb, NULL);
155 register_signal_handler(SS_GLOBAL, gbl_sig_cb, NULL);
156
157 return gsm_bts_model_register(&model_rbs2k);
158}