firmware: k2xx: fix comments about flash organization
[osmocom-bb.git] / include / l1ctl_proto.h
blob79feabab1567efa301a89ba5a5457480546490c3
1 /* Messages to be sent between the different layers */
3 /* (C) 2010 by Harald Welte <laforge@gnumonks.org>
4 * (C) 2010 by Holger Hans Peter Freyther
6 * All Rights Reserved
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.
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.
20 #ifndef __L1CTL_PROTO_H__
21 #define __L1CTL_PROTO_H__
23 enum {
24 _L1CTL_NONE = 0x00,
25 L1CTL_FBSB_REQ = 0x01,
26 L1CTL_FBSB_CONF = 0x02,
27 L1CTL_DATA_IND = 0x03,
28 L1CTL_RACH_REQ = 0x04,
29 L1CTL_DM_EST_REQ = 0x05,
30 L1CTL_DATA_REQ = 0x06,
31 L1CTL_RESET_IND = 0x07,
32 L1CTL_PM_REQ = 0x08, /* power measurement */
33 L1CTL_PM_CONF = 0x09, /* power measurement */
34 L1CTL_ECHO_REQ = 0x0a,
35 L1CTL_ECHO_CONF = 0x0b,
36 L1CTL_RACH_CONF = 0x0c,
37 L1CTL_RESET_REQ = 0x0d,
38 L1CTL_RESET_CONF = 0x0e,
39 L1CTL_DATA_CONF = 0x0f,
40 L1CTL_CCCH_MODE_REQ = 0x10,
41 L1CTL_CCCH_MODE_CONF = 0x11,
42 L1CTL_DM_REL_REQ = 0x12,
43 L1CTL_PARAM_REQ = 0x13,
44 L1CTL_DM_FREQ_REQ = 0x14,
45 L1CTL_CRYPTO_REQ = 0x15,
46 L1CTL_SIM_REQ = 0x16,
47 L1CTL_SIM_CONF = 0x17,
48 L1CTL_TCH_MODE_REQ = 0x18,
49 L1CTL_TCH_MODE_CONF = 0x19,
50 L1CTL_NEIGH_PM_REQ = 0x1a,
51 L1CTL_NEIGH_PM_IND = 0x1b,
52 L1CTL_TRAFFIC_REQ = 0x1c,
53 L1CTL_TRAFFIC_CONF = 0x1d,
54 L1CTL_TRAFFIC_IND = 0x1e,
55 L1CTL_BURST_IND = 0x1f,
56 L1CTL_GPRS_UL_TBF_CFG_REQ = 0x20,
57 L1CTL_GPRS_DL_TBF_CFG_REQ = 0x21,
58 L1CTL_GPRS_UL_BLOCK_REQ = 0x22,
59 L1CTL_GPRS_DL_BLOCK_IND = 0x23,
60 /* Extended (11-bit) RACH (see 3GPP TS 05.02, section 5.2.7) */
61 L1CTL_EXT_RACH_REQ = 0x24,
62 L1CTL_GPRS_RTS_IND = 0x25,
63 L1CTL_GPRS_UL_BLOCK_CNF = 0x26,
66 enum ccch_mode {
67 CCCH_MODE_NONE = 0,
68 CCCH_MODE_NON_COMBINED,
69 CCCH_MODE_COMBINED,
70 CCCH_MODE_COMBINED_CBCH,
73 enum neigh_mode {
74 NEIGH_MODE_NONE = 0,
75 NEIGH_MODE_PM,
76 NEIGH_MODE_SB,
80 * NOTE: struct size. We do add manual padding out of the believe
81 * that it will avoid some unaligned access.
84 /* there are no more messages in a sequence */
85 #define L1CTL_F_DONE 0x01
87 struct l1ctl_hdr {
88 uint8_t msg_type;
89 uint8_t flags;
90 uint8_t padding[2];
91 uint8_t data[0];
92 } __attribute__((packed));
95 * downlink info ... down from the BTS..
97 struct l1ctl_info_dl {
98 /* GSM 08.58 channel number (9.3.1) */
99 uint8_t chan_nr;
100 /* GSM 08.58 link identifier (9.3.2) */
101 uint8_t link_id;
102 /* the ARFCN and the band. FIXME: what about MAIO? */
103 uint16_t band_arfcn;
105 uint32_t frame_nr;
107 uint8_t rx_level; /* 0 .. 63 in typical GSM notation (dBm+110) */
108 uint8_t snr; /* Signal/Noise Ration (dB) */
109 uint8_t num_biterr;
110 uint8_t fire_crc;
112 uint8_t payload[0];
113 } __attribute__((packed));
115 /* new CCCH was found. This is following the header */
116 struct l1ctl_fbsb_conf {
117 int16_t initial_freq_err;
118 uint8_t result;
119 uint8_t bsic;
120 /* FIXME: contents of cell_info ? */
121 } __attribute__((packed));
123 /* CCCH mode was changed */
124 struct l1ctl_ccch_mode_conf {
125 uint8_t ccch_mode; /* enum ccch_mode */
126 uint8_t padding[3];
127 } __attribute__((packed));
129 /* 3GPP TS 44.014, section 5.1 (Calypso specific numbers) */
130 enum l1ctl_tch_loop_mode {
131 L1CTL_TCH_LOOP_OPEN = 0x00,
132 L1CTL_TCH_LOOP_A = 0x01,
133 L1CTL_TCH_LOOP_B = 0x02,
134 L1CTL_TCH_LOOP_C = 0x03,
135 L1CTL_TCH_LOOP_D = 0x04,
136 L1CTL_TCH_LOOP_E = 0x05,
137 L1CTL_TCH_LOOP_F = 0x06,
138 L1CTL_TCH_LOOP_I = 0x07,
141 /* TCH mode was changed */
142 struct l1ctl_tch_mode_conf {
143 uint8_t tch_mode; /* enum tch_mode */
144 uint8_t audio_mode;
145 uint8_t tch_loop_mode; /* enum l1ctl_tch_loop_mode */
146 struct { /* 3GPP TS 08.58 9.3.52, 3GPP TS 44.018 10.5.2.21aa */
147 uint8_t start_codec;
148 uint8_t codecs_bitmask;
149 } amr;
150 uint8_t tch_flags;
151 } __attribute__((packed));
153 /* data on the CCCH was found. This is following the header */
154 struct l1ctl_data_ind {
155 uint8_t data[23];
156 } __attribute__((packed));
158 /* traffic from the network */
159 struct l1ctl_traffic_ind {
160 uint8_t data[0];
161 } __attribute__((packed));
164 * uplink info
166 struct l1ctl_info_ul {
167 /* GSM 08.58 channel number (9.3.1) */
168 uint8_t chan_nr;
169 /* GSM 08.58 link identifier (9.3.2) */
170 uint8_t link_id;
171 uint8_t padding[2];
173 uint8_t payload[0];
174 } __attribute__((packed));
177 * msg for FBSB_REQ
178 * the l1_info_ul header is in front
180 struct l1ctl_fbsb_req {
181 uint16_t band_arfcn;
182 uint16_t timeout; /* in TDMA frames */
184 uint16_t freq_err_thresh1;
185 uint16_t freq_err_thresh2;
187 uint8_t num_freqerr_avg;
188 uint8_t flags; /* L1CTL_FBSB_F_* */
189 uint8_t sync_info_idx;
190 uint8_t ccch_mode; /* enum ccch_mode */
191 uint8_t rxlev_exp; /* expected signal level */
192 } __attribute__((packed));
194 #define L1CTL_FBSB_F_FB0 (1 << 0)
195 #define L1CTL_FBSB_F_FB1 (1 << 1)
196 #define L1CTL_FBSB_F_SB (1 << 2)
197 #define L1CTL_FBSB_F_FB01SB (L1CTL_FBSB_F_FB0|L1CTL_FBSB_F_FB1|L1CTL_FBSB_F_SB)
200 * msg for CCCH_MODE_REQ
201 * the l1_info_ul header is in front
203 struct l1ctl_ccch_mode_req {
204 uint8_t ccch_mode; /* enum ccch_mode */
205 uint8_t padding[3];
206 } __attribute__((packed));
209 * msg for TCH_MODE_REQ
210 * the l1_info_ul header is in front
212 struct l1ctl_tch_mode_req {
213 uint8_t tch_mode; /* enum gsm48_chan_mode */
214 #define AUDIO_TX_MICROPHONE (1<<0)
215 #define AUDIO_TX_TRAFFIC_REQ (1<<1)
216 #define AUDIO_RX_SPEAKER (1<<2)
217 #define AUDIO_RX_TRAFFIC_IND (1<<3)
218 uint8_t audio_mode;
219 uint8_t tch_loop_mode; /* enum l1ctl_tch_loop_mode */
220 struct { /* 3GPP TS 08.58 9.3.52, 3GPP TS 44.018 10.5.2.21aa */
221 uint8_t start_codec;
222 uint8_t codecs_bitmask;
223 } amr;
224 uint8_t tch_flags;
225 } __attribute__((packed));
227 #define L1CTL_TCH_FLAG_RXONLY (1<<0) /* TX disabled */
229 /* the l1_info_ul header is in front */
230 struct l1ctl_rach_req {
231 uint8_t ra;
232 uint8_t combined;
233 uint16_t offset;
234 uint8_t uic;
235 } __attribute__((packed));
238 /* the l1_info_ul header is in front */
239 struct l1ctl_ext_rach_req {
240 uint16_t ra11;
241 uint8_t synch_seq;
242 uint8_t combined;
243 uint16_t offset;
244 } __attribute__((packed));
246 /* the l1_info_ul header is in front */
247 struct l1ctl_par_req {
248 int8_t ta;
249 uint8_t tx_power;
250 uint8_t padding[2];
251 } __attribute__((packed));
253 struct l1ctl_h0 {
254 uint16_t band_arfcn;
255 } __attribute__((packed));
257 struct l1ctl_h1 {
258 uint8_t hsn;
259 uint8_t maio;
260 uint8_t n;
261 uint8_t _padding[1];
262 uint16_t ma[64];
263 } __attribute__((packed));
265 struct l1ctl_dm_est_req {
266 uint8_t tsc;
267 uint8_t h;
268 union {
269 struct l1ctl_h0 h0;
270 struct l1ctl_h1 h1;
272 uint8_t tch_mode;
273 uint8_t audio_mode;
274 uint8_t tch_flags;
275 } __attribute__((packed));
277 struct l1ctl_dm_freq_req {
278 uint16_t fn;
279 uint8_t tsc;
280 uint8_t h;
281 union {
282 struct l1ctl_h0 h0;
283 struct l1ctl_h1 h1;
285 } __attribute__((packed));
287 struct l1ctl_crypto_req {
288 uint8_t algo;
289 uint8_t key_len;
290 uint8_t key[0];
291 } __attribute__((packed));
293 struct l1ctl_pm_req {
294 uint8_t type;
295 uint8_t padding[3];
297 union {
298 struct {
299 uint16_t band_arfcn_from;
300 uint16_t band_arfcn_to;
301 } range;
303 } __attribute__((packed));
305 #define BI_FLG_DUMMY (1 << 4)
306 #define BI_FLG_SACCH (1 << 5)
308 struct l1ctl_burst_ind {
309 uint32_t frame_nr;
310 uint16_t band_arfcn; /* ARFCN + band + ul indicator */
311 uint8_t chan_nr; /* GSM 08.58 channel number (9.3.1) */
312 uint8_t flags; /* BI_FLG_xxx + burst_id = 2LSBs */
313 uint8_t rx_level; /* 0 .. 63 in typical GSM notation (dBm+110) */
314 uint8_t snr; /* Reported SNR >> 8 (0-255) */
315 uint8_t bits[15]; /* 114 bits + 2 steal bits. Filled MSB first */
316 } __attribute__((packed));
318 /* a single L1CTL_PM response */
319 struct l1ctl_pm_conf {
320 uint16_t band_arfcn;
321 uint8_t pm[2];
322 } __attribute__((packed));
324 enum l1ctl_reset_type {
325 L1CTL_RES_T_BOOT, /* only _IND */
326 L1CTL_RES_T_FULL,
327 L1CTL_RES_T_SCHED,
330 /* argument to L1CTL_RESET_REQ and L1CTL_RESET_IND */
331 struct l1ctl_reset {
332 uint8_t type;
333 uint8_t pad[3];
334 } __attribute__((packed));
336 struct l1ctl_neigh_pm_req {
337 uint8_t n;
338 uint8_t padding[1];
339 uint16_t band_arfcn[64];
340 uint8_t tn[64];
341 } __attribute__((packed));
343 /* neighbour cell measurement results */
344 struct l1ctl_neigh_pm_ind {
345 uint16_t band_arfcn;
346 uint8_t pm[2];
347 uint8_t tn;
348 uint8_t padding;
349 } __attribute__((packed));
351 /* traffic data to network */
352 struct l1ctl_traffic_req {
353 uint8_t data[0];
354 } __attribute__((packed));
356 /* payload of L1CTL_GPRS_UL_TBF_CFG_REQ */
357 struct l1ctl_gprs_ul_tbf_cfg_req {
358 uint8_t tbf_ref;
359 uint8_t slotmask;
360 uint8_t padding[2];
361 uint32_t start_fn; /* TBF Starting Time (absolute Fn) */
362 } __attribute__((packed));
364 /* payload of L1CTL_GPRS_DL_TBF_CFG_REQ */
365 struct l1ctl_gprs_dl_tbf_cfg_req {
366 uint8_t tbf_ref;
367 uint8_t slotmask;
368 uint8_t dl_tfi;
369 uint8_t padding[1];
370 uint32_t start_fn; /* TBF Starting Time (absolute Fn) */
371 } __attribute__((packed));
373 /* part of L1CTL_GPRS_{UL,DL}_BLOCK_{REQ,IND} */
374 struct l1ctl_gprs_block_hdr {
375 uint32_t fn;
376 uint8_t tn;
377 uint8_t padding[3];
378 } __attribute__((packed));
380 /* payload of L1CTL_GPRS_UL_BLOCK_REQ */
381 struct l1ctl_gprs_ul_block_req {
382 struct l1ctl_gprs_block_hdr hdr;
383 uint8_t data[0];
384 } __attribute__((packed));
386 /* payload of L1CTL_GPRS_DL_BLOCK_IND */
387 struct l1ctl_gprs_dl_block_ind {
388 struct l1ctl_gprs_block_hdr hdr;
389 struct __attribute__((packed)) {
390 uint16_t ber10k; /* Bit Error Rate */
391 int16_t ci_cb; /* C/I in centiBels */
392 uint8_t rx_lev; /* RxLev 0..63 */
393 } meas;
394 uint8_t usf;
395 uint8_t data[0];
396 } __attribute__((packed));
398 /* payload of L1CTL_GPRS_RTS_IND */
399 struct l1ctl_gprs_rts_ind {
400 uint32_t fn;
401 uint8_t tn;
402 uint8_t usf;
403 } __attribute__((packed));
405 /* payload of L1CTL_GPRS_UL_BLOCK_CNF */
406 struct l1ctl_gprs_ul_block_cnf {
407 uint32_t fn;
408 uint8_t tn;
409 uint8_t data[0];
410 } __attribute__((packed));
412 #endif /* __L1CTL_PROTO_H__ */