blob: 2f3e3092c2a171c3a07aabb894cdad8a45855ada [file] [log] [blame]
Harald Welte52b1f982008-12-23 20:25:15 +00001#ifndef _GSM_DATA_H
2#define _GSM_DATA_H
3
4#include <sys/types.h>
5
Harald Welte255539c2008-12-28 02:26:27 +00006#include <openbsc/timer.h>
7
Harald Welte8470bf22008-12-25 23:28:35 +00008#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
9
Harald Welte52b1f982008-12-23 20:25:15 +000010#define GSM_MAX_BTS 8
11#define BTS_MAX_TRX 8
Harald Welte8470bf22008-12-25 23:28:35 +000012#define TS_MAX_LCHAN 8
Harald Welte52b1f982008-12-23 20:25:15 +000013
14#define HARDCODED_ARFCN 123
15
16/* communications link with a BTS */
17struct gsm_bts_link {
18 struct gsm_bts *bts;
19};
20
Harald Weltea3d04382008-12-27 17:02:56 +000021enum gsm_call_type {
22 GSM_CT_NONE,
23 GSM_CT_MO,
24 GSM_CT_MT,
25};
26
27enum gsm_call_state {
28 GSM_CSTATE_NULL,
29 GSM_CSTATE_INITIATED,
30 GSM_CSTATE_ACTIVE,
31 GSM_CSTATE_RELEASE_REQ,
32};
33
34/* One end of a call */
35struct gsm_call {
36 enum gsm_call_type type;
37 enum gsm_call_state state;
38 u_int8_t transaction_id; /* 10.3.2 */
39
40 /* the 'local' subscriber */
41 struct gsm_subscriber *subscr;
42};
43
44
Harald Welte8470bf22008-12-25 23:28:35 +000045enum gsm_phys_chan_config {
46 GSM_PCHAN_NONE,
47 GSM_PCHAN_CCCH,
48 GSM_PCHAN_CCCH_SDCCH4,
49 GSM_PCHAN_TCH_F,
50 GSM_PCHAN_TCH_H,
51 GSM_PCHAN_SDCCH8_SACCH8C,
52 GSM_PCHAN_UNKNOWN,
53};
54
55enum gsm_chan_t {
56 GSM_LCHAN_NONE,
57 GSM_LCHAN_SDCCH,
58 GSM_LCHAN_TCH_F,
59 GSM_LCHAN_TCH_H,
60 GSM_LCHAN_UNKNOWN,
61};
62
Harald Weltee14a57c2008-12-29 04:08:28 +000063
64/* Channel Request reason */
65enum gsm_chreq_reason_t {
66 GSM_CHREQ_REASON_EMERG,
67 GSM_CHREQ_REASON_PAG,
68 GSM_CHREQ_REASON_CALL,
69 GSM_CHREQ_REASON_LOCATION_UPD,
70 GSM_CHREQ_REASON_OTHER,
71};
72
Harald Welte8470bf22008-12-25 23:28:35 +000073struct gsm_lchan {
74 /* The TS that we're part of */
75 struct gsm_bts_trx_ts *ts;
76 /* The logical subslot number in the TS */
77 u_int8_t nr;
78 /* The lotical channel type */
79 enum gsm_chan_t type;
80 /* To whom we are allocated at the moment */
81 struct gsm_subscriber *subscr;
Harald Welte255539c2008-12-28 02:26:27 +000082 /* Universal timer, undefined use ;) */
83 struct timer_list timer;
Harald Weltea3d04382008-12-27 17:02:56 +000084
85 /* local end of a call, if any */
86 struct gsm_call call;
Holger Freyther3186bf22008-12-29 06:23:49 +000087
88 /* temporary user data, to be removed... and merged into gsm_call */
89 void *user_data;
Holger Freytherb7193e42008-12-29 17:44:08 +000090
91 /* use count. how many users use this channel */
92 unsigned int use_count;
93 unsigned int pending_update_request : 1;
Harald Welte8470bf22008-12-25 23:28:35 +000094};
95
Harald Welte52b1f982008-12-23 20:25:15 +000096#define BTS_TRX_F_ACTIVATED 0x0001
97/* One Timeslot in a TRX */
98struct gsm_bts_trx_ts {
99 struct gsm_bts_trx *trx;
100 /* number of this timeslot at the TRX */
101 u_int8_t nr;
102
Harald Welte8470bf22008-12-25 23:28:35 +0000103 enum gsm_phys_chan_config pchan;
104
Harald Welte52b1f982008-12-23 20:25:15 +0000105 unsigned int flags;
Harald Welte8470bf22008-12-25 23:28:35 +0000106
107 struct gsm_lchan lchan[TS_MAX_LCHAN];
Harald Welte52b1f982008-12-23 20:25:15 +0000108};
109
110/* One TRX in a BTS */
111struct gsm_bts_trx {
112 struct gsm_bts *bts;
113 /* number of this TRX in the BTS */
114 u_int8_t nr;
115
116 u_int16_t arfcn;
117 struct gsm_bts_trx_ts ts[8];
118};
119
120/* One BTS */
121struct gsm_bts {
122 struct gsm_network *network;
123 /* number of ths BTS in network */
124 u_int8_t nr;
125 /* location area code of this BTS */
126 u_int8_t location_area_code;
127
128 /* Abis network management O&M handle */
129 struct abis_nm_h *nmh;
130 /* number of this BTS on given E1 link */
131 u_int8_t bts_nr;
132
133 /* CCCH is on C0 */
134 struct gsm_bts_trx *c0;
135 /* transceivers */
136 int num_trx;
137 struct gsm_bts_trx trx[BTS_MAX_TRX+1];
138};
139
140struct gsm_ms {
141 unsigned long imei;
142};
143
144struct gsm_network {
145 /* global parameters */
Harald Welteb84e2f42008-12-28 23:42:04 +0000146 u_int16_t country_code;
147 u_int16_t network_code;
Harald Welte52b1f982008-12-23 20:25:15 +0000148
149 unsigned int num_bts;
150 /* private lists */
151 struct gsm_bts bts[GSM_MAX_BTS+1];
152 struct gsm_ms *ms;
153 struct gsm_subscriber *subscriber;
Holger Freyther07cc8d82008-12-29 06:23:46 +0000154
Holger Freytherb7193e42008-12-29 17:44:08 +0000155 /* management of the lower layers to allow the bsc to hook into it */
156 void (*update_request)(struct gsm_bts *, u_int32_t tmsi, int accepted);
Holger Freyther3186bf22008-12-29 06:23:49 +0000157 void (*channel_allocated)(struct gsm_lchan *bts, enum gsm_chreq_reason_t);
Holger Freytherb7193e42008-12-29 17:44:08 +0000158 void (*channel_deallocated)(struct gsm_lchan *bts);
Holger Freyther88ea8322008-12-29 06:23:52 +0000159 void (*channel_response)(struct gsm_lchan *, int acked);
Holger Freytherb7193e42008-12-29 17:44:08 +0000160 void (*channel_subscriber_assigned)(struct gsm_lchan *);
161 void (*call_state_changed)(struct gsm_lchan *, enum gsm_call_state new_state);
Harald Welte52b1f982008-12-23 20:25:15 +0000162};
163
Harald Welteb84e2f42008-12-28 23:42:04 +0000164struct gsm_network *gsm_network_init(unsigned int num_bts, u_int16_t country_code,
165 u_int16_t network_code);
Harald Welte8470bf22008-12-25 23:28:35 +0000166
Harald Weltead384642008-12-26 10:20:07 +0000167enum gsm_e1_event {
168 EVT_E1_NONE,
169 EVT_E1_OML_UP,
170 EVT_E1_RSL_UP,
171 EVT_E1_OML_DN,
172 EVT_E1_RSL_DN,
173};
174
Harald Welte52b1f982008-12-23 20:25:15 +0000175#endif