blob: b150e1d2ab2f91220b31a9db8a9933f1248d6a81 [file] [log] [blame]
Harald Welte1fa60c82009-02-09 18:13:26 +00001#include <string.h>
2#include <errno.h>
3
4#include <openbsc/gsm_data.h>
5#include <openbsc/e1_input.h>
Harald Welte39a1b712009-02-10 17:17:09 +00006#include <openbsc/trau_mux.h>
Harald Welte1fa60c82009-02-09 18:13:26 +00007
8#define SAPI_L2ML 0
9#define SAPI_OML 62
10#define SAPI_RSL 0 /* 63 ? */
11
12#define TEI_L2ML 127
13#define TEI_OML 25
14#define TEI_RSL 1
15
16/* do some compiled-in configuration for our BTS/E1 setup */
17int e1_config(struct gsm_bts *bts)
18{
19 struct e1inp_line *line;
20 struct e1inp_ts *sign_ts;
21 struct e1inp_sign_link *oml_link, *rsl_link;
22
23 line = malloc(sizeof(*line));
24 if (!line)
25 return -ENOMEM;
26 memset(line, 0, sizeof(*line));
27
28 /* create E1 timeslots for signalling and TRAU frames */
29 e1inp_ts_config(&line->ts[1-1], line, E1INP_TS_TYPE_SIGN);
30 e1inp_ts_config(&line->ts[2-1], line, E1INP_TS_TYPE_TRAU);
Harald Welte93d3f372009-02-18 03:27:14 +000031 //e1inp_ts_config(&line->ts[3-1], line, E1INP_TS_TYPE_TRAU);
Harald Welte1fa60c82009-02-09 18:13:26 +000032
33 /* create signalling links for TS1 */
34 sign_ts = &line->ts[1-1];
35 oml_link = e1inp_sign_link_create(sign_ts, E1INP_SIGN_OML,
36 bts->c0, TEI_OML, SAPI_OML);
37 rsl_link = e1inp_sign_link_create(sign_ts, E1INP_SIGN_RSL,
38 bts->c0, TEI_RSL, SAPI_RSL);
39
40 /* create back-links from bts/trx */
41 bts->oml_link = oml_link;
42 bts->c0->rsl_link = rsl_link;
43
Harald Welte11fa29c2009-02-19 17:24:39 +000044 /* enable subchannel demuxer on TS2 */
45 subch_demux_activate(&line->ts[2-1].trau.demux, 1);
46 subch_demux_activate(&line->ts[2-1].trau.demux, 2);
47 subch_demux_activate(&line->ts[2-1].trau.demux, 3);
Harald Welte93d3f372009-02-18 03:27:14 +000048
Harald Welte11fa29c2009-02-19 17:24:39 +000049#if 0
50 /* enable subchannel demuxer on TS3 */
51 subch_demux_activate(&line->ts[3-1].trau.demux, 0);
52 subch_demux_activate(&line->ts[3-1].trau.demux, 1);
53 subch_demux_activate(&line->ts[3-1].trau.demux, 2);
54 subch_demux_activate(&line->ts[3-1].trau.demux, 3);
55#endif
56
Harald Welte39a1b712009-02-10 17:17:09 +000057#ifdef HAVE_TRX1
58 /* create E1 timeslots for TRAU frames of TRX1 */
Harald Welte1fa60c82009-02-09 18:13:26 +000059 e1inp_ts_config(&line->ts[4-1], line, E1INP_TS_TYPE_TRAU);
60 e1inp_ts_config(&line->ts[5-1], line, E1INP_TS_TYPE_TRAU);
61
Harald Welte39a1b712009-02-10 17:17:09 +000062 /* create RSL signalling link for TRX1 */
Harald Welte1fa60c82009-02-09 18:13:26 +000063 sign_ts = &line->ts[1-1];
64 rsl_link = e1inp_sign_link_create(sign_ts, E1INP_SIGN_RSL,
65 &bts->trx[1], TEI_RSL+1, SAPI_RSL);
66 /* create back-links from trx */
67 bts->trx[1].rsl_link = rsl_link;
68#endif
69
70 return mi_setup(0, line, NULL);
71}
Harald Welte5fd8a542009-02-13 02:43:36 +000072
73/* do some compiled-in configuration for our BTS/E1 setup */
74int ia_config(struct gsm_bts *bts)
75{
76 struct e1inp_line *line;
Harald Welte5c1e4582009-02-15 11:57:29 +000077 struct e1inp_ts *sign_ts, *rsl_ts;
Harald Welte5fd8a542009-02-13 02:43:36 +000078 struct e1inp_sign_link *oml_link, *rsl_link;
79
80 line = malloc(sizeof(*line));
81 if (!line)
82 return -ENOMEM;
83 memset(line, 0, sizeof(*line));
84
85 /* create E1 timeslots for signalling and TRAU frames */
86 e1inp_ts_config(&line->ts[1-1], line, E1INP_TS_TYPE_SIGN);
Harald Welte5c1e4582009-02-15 11:57:29 +000087 e1inp_ts_config(&line->ts[2-1], line, E1INP_TS_TYPE_SIGN);
Harald Welte5fd8a542009-02-13 02:43:36 +000088
89 /* create signalling links for TS1 */
90 sign_ts = &line->ts[1-1];
Harald Welte5c1e4582009-02-15 11:57:29 +000091 rsl_ts = &line->ts[2-1];
Harald Welte5fd8a542009-02-13 02:43:36 +000092 oml_link = e1inp_sign_link_create(sign_ts, E1INP_SIGN_OML,
93 bts->c0, 0, 0xff);
Harald Welte5c1e4582009-02-15 11:57:29 +000094 rsl_link = e1inp_sign_link_create(rsl_ts, E1INP_SIGN_RSL,
Harald Welte5fd8a542009-02-13 02:43:36 +000095 bts->c0, 0, 0);
96
97 /* create back-links from bts/trx */
98 bts->oml_link = oml_link;
99 bts->c0->rsl_link = rsl_link;
100
101 return ipaccess_setup(line);
102}