l1ctl: Add definition for TRAFFIC_{REQ,CONF,IND}
[osmocom-bb.git] / include / l1ctl_proto.h
1 /* Messages to be sent between the different layers */
2
3 /* (C) 2010 by Harald Welte <laforge@gnumonks.org>
4  * (C) 2010 by Holger Hans Peter Freyther
5  *
6  * All Rights Reserved
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with this program; if not, write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21  *
22  */
23
24 #ifndef __L1CTL_PROTO_H__
25 #define __L1CTL_PROTO_H__
26
27 enum {
28         _L1CTL_NONE             = 0,
29         L1CTL_FBSB_REQ,
30         L1CTL_FBSB_CONF,
31         L1CTL_DATA_IND,
32         L1CTL_RACH_REQ,
33         L1CTL_DM_EST_REQ,
34         L1CTL_DATA_REQ,
35         L1CTL_RESET_IND,
36         L1CTL_PM_REQ,           /* power measurement */
37         L1CTL_PM_CONF,          /* power measurement */
38         L1CTL_ECHO_REQ,
39         L1CTL_ECHO_CONF,
40         L1CTL_RACH_CONF,
41         L1CTL_RESET_REQ,
42         L1CTL_RESET_CONF,
43         L1CTL_DATA_CONF,
44         L1CTL_CCCH_MODE_REQ,
45         L1CTL_CCCH_MODE_CONF,
46         L1CTL_DM_REL_REQ,
47         L1CTL_PARAM_REQ,
48         L1CTL_DM_FREQ_REQ,
49         L1CTL_CRYPTO_REQ,
50         L1CTL_SIM_REQ,
51         L1CTL_SIM_CONF,
52         L1CTL_TCH_MODE_REQ,
53         L1CTL_TCH_MODE_CONF,
54         L1CTL_NEIGH_PM_REQ,
55         L1CTL_NEIGH_PM_IND,
56         L1CTL_TRAFFIC_REQ,
57         L1CTL_TRAFFIC_CONF,
58         L1CTL_TRAFFIC_IND,
59 };
60
61 enum ccch_mode {
62         CCCH_MODE_NONE = 0,
63         CCCH_MODE_NON_COMBINED,
64         CCCH_MODE_COMBINED,
65 };
66
67 enum neigh_mode {
68         NEIGH_MODE_NONE = 0,
69         NEIGH_MODE_PM,
70         NEIGH_MODE_SB,
71 };
72
73 #define TRAFFIC_DATA_LEN        40
74
75 /*
76  * NOTE: struct size. We do add manual padding out of the believe
77  * that it will avoid some unaligned access.
78  */
79
80 /* there are no more messages in a sequence */
81 #define L1CTL_F_DONE    0x01
82
83 struct l1ctl_hdr {
84         uint8_t msg_type;
85         uint8_t flags;
86         uint8_t padding[2];
87         uint8_t data[0];
88 } __attribute__((packed));
89
90 /*
91  * downlink info ... down from the BTS..
92  */
93 struct l1ctl_info_dl {
94         /* GSM 08.58 channel number (9.3.1) */
95         uint8_t chan_nr;
96         /* GSM 08.58 link identifier (9.3.2) */
97         uint8_t link_id;
98         /* the ARFCN and the band. FIXME: what about MAIO? */
99         uint16_t band_arfcn;
100
101         uint32_t frame_nr;
102
103         uint8_t rx_level;       /* 0 .. 63 in typical GSM notation (dBm+110) */
104         uint8_t snr;            /* Signal/Noise Ration (dB) */
105         uint8_t num_biterr;
106         uint8_t fire_crc;
107
108         uint8_t payload[0];
109 } __attribute__((packed));
110
111 /* new CCCH was found. This is following the header */
112 struct l1ctl_fbsb_conf {
113         int16_t initial_freq_err;
114         uint8_t result;
115         uint8_t bsic;
116         /* FIXME: contents of cell_info ? */
117 } __attribute__((packed));
118
119 /* CCCH mode was changed */
120 struct l1ctl_ccch_mode_conf {
121         uint8_t ccch_mode;      /* enum ccch_mode */
122         uint8_t padding[3];
123 } __attribute__((packed));
124
125 /* TCH mode was changed */
126 struct l1ctl_tch_mode_conf {
127         uint8_t tch_mode;       /* enum tch_mode */
128         uint8_t padding[3];
129 } __attribute__((packed));
130
131 /* data on the CCCH was found. This is following the header */
132 struct l1ctl_data_ind {
133         uint8_t data[23];
134 } __attribute__((packed));
135
136 /* traffic from the network */
137 struct l1ctl_traffic_ind {
138         uint8_t data[TRAFFIC_DATA_LEN];
139 } __attribute__((packed));
140
141 /*
142  * uplink info
143  */
144 struct l1ctl_info_ul {
145         /* GSM 08.58 channel number (9.3.1) */
146         uint8_t chan_nr;
147         /* GSM 08.58 link identifier (9.3.2) */
148         uint8_t link_id;
149         uint8_t padding[2];
150
151         uint8_t payload[0];
152 } __attribute__((packed));
153
154 /*
155  * msg for FBSB_REQ
156  * the l1_info_ul header is in front
157  */
158 struct l1ctl_fbsb_req {
159         uint16_t band_arfcn;
160         uint16_t timeout;       /* in TDMA frames */
161
162         uint16_t freq_err_thresh1;
163         uint16_t freq_err_thresh2;
164
165         uint8_t num_freqerr_avg;
166         uint8_t flags;          /* L1CTL_FBSB_F_* */
167         uint8_t sync_info_idx;
168         uint8_t ccch_mode;      /* enum ccch_mode */
169 } __attribute__((packed));
170
171 #define L1CTL_FBSB_F_FB0        (1 << 0)
172 #define L1CTL_FBSB_F_FB1        (1 << 1)
173 #define L1CTL_FBSB_F_SB         (1 << 2)
174 #define L1CTL_FBSB_F_FB01SB     (L1CTL_FBSB_F_FB0|L1CTL_FBSB_F_FB1|L1CTL_FBSB_F_SB)
175
176 /*
177  * msg for CCCH_MODE_REQ
178  * the l1_info_ul header is in front
179  */
180 struct l1ctl_ccch_mode_req {
181         uint8_t ccch_mode;      /* enum ccch_mode */
182         uint8_t padding[3];
183 } __attribute__((packed));
184
185 /*
186  * msg for TCH_MODE_REQ
187  * the l1_info_ul header is in front
188  */
189 struct l1ctl_tch_mode_req {
190         uint8_t tch_mode;       /* enum gsm48_chan_mode */
191         uint8_t padding[3];
192 } __attribute__((packed));
193
194 /* the l1_info_ul header is in front */
195 struct l1ctl_rach_req {
196         uint8_t ra;
197         uint8_t combined;
198         uint16_t offset;
199 } __attribute__((packed));
200
201 /* the l1_info_ul header is in front */
202 struct l1ctl_par_req {
203         int8_t ta;
204         uint8_t tx_power;
205         uint8_t padding[2];
206 } __attribute__((packed));
207
208 struct l1ctl_h0 {
209         uint16_t band_arfcn;
210 } __attribute__((packed));
211
212 struct l1ctl_h1 {
213         uint8_t hsn;
214         uint8_t maio;
215         uint8_t n;
216         uint8_t _padding[1];
217         uint16_t ma[64];
218 } __attribute__((packed));
219
220 struct l1ctl_dm_est_req {
221         uint8_t tsc;
222         uint8_t h;
223         union {
224                 struct l1ctl_h0 h0;
225                 struct l1ctl_h1 h1;
226         };
227         uint8_t tch_mode;
228         uint8_t _padding[1];
229 } __attribute__((packed));
230
231 struct l1ctl_dm_freq_req {
232         uint16_t fn;
233         uint8_t tsc;
234         uint8_t h;
235         union {
236                 struct l1ctl_h0 h0;
237                 struct l1ctl_h1 h1;
238         };
239 } __attribute__((packed));
240
241 struct l1ctl_crypto_req {
242         uint8_t algo;
243         uint8_t key[0];
244 } __attribute__((packed));
245
246 struct l1ctl_pm_req {
247         uint8_t type;
248         uint8_t padding[3];
249
250         union {
251                 struct {
252                         uint16_t band_arfcn_from;
253                         uint16_t band_arfcn_to;
254                 } range;
255         };
256 } __attribute__((packed));
257
258 /* a single L1CTL_PM response */
259 struct l1ctl_pm_conf {
260         uint16_t band_arfcn;
261         uint8_t pm[2];
262 } __attribute__((packed));
263
264 enum l1ctl_reset_type {
265         L1CTL_RES_T_BOOT,       /* only _IND */
266         L1CTL_RES_T_FULL,
267         L1CTL_RES_T_SCHED,
268 };
269
270 /* argument to L1CTL_RESET_REQ and L1CTL_RESET_IND */
271 struct l1ctl_reset {
272         uint8_t type;
273         uint8_t pad[3];
274 } __attribute__((packed));
275
276 struct l1ctl_neigh_pm_req {
277         uint8_t n;
278         uint8_t padding[1];
279         uint16_t band_arfcn[64];
280 } __attribute__((packed));
281
282 /* neighbour cell measurement results */
283 struct l1ctl_neigh_pm_ind {
284         uint16_t band_arfcn;
285         uint8_t pm[2];
286 } __attribute__((packed));
287
288 /* traffic data to network */
289 struct l1ctl_traffic_req {
290         uint8_t data[TRAFFIC_DATA_LEN];
291 } __attribute__((packed));
292
293 #endif /* __L1CTL_PROTO_H__ */