virt_l1_sched_execute: talloc_free() TDMA item after unlinking it
[osmocom-bb.git] / include / l1ctl_proto.h
blob05d65deb9f37ee7d09a1c85aba2e10530b6bc7f2
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.
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.
24 #ifndef __L1CTL_PROTO_H__
25 #define __L1CTL_PROTO_H__
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 L1CTL_BURST_IND,
61 /* configure TBF for uplink/downlink */
62 L1CTL_TBF_CFG_REQ,
63 L1CTL_TBF_CFG_CONF,
65 L1CTL_DATA_TBF_REQ,
66 L1CTL_DATA_TBF_CONF,
68 /* Extended (11-bit) RACH (see 3GPP TS 05.02, section 5.2.7) */
69 L1CTL_EXT_RACH_REQ,
72 enum ccch_mode {
73 CCCH_MODE_NONE = 0,
74 CCCH_MODE_NON_COMBINED,
75 CCCH_MODE_COMBINED,
76 CCCH_MODE_COMBINED_CBCH,
79 enum neigh_mode {
80 NEIGH_MODE_NONE = 0,
81 NEIGH_MODE_PM,
82 NEIGH_MODE_SB,
85 enum l1ctl_coding_scheme {
86 L1CTL_CS_NONE,
87 L1CTL_CS1,
88 L1CTL_CS2,
89 L1CTL_CS3,
90 L1CTL_CS4,
91 L1CTL_MCS1,
92 L1CTL_MCS2,
93 L1CTL_MCS3,
94 L1CTL_MCS4,
95 L1CTL_MCS5,
96 L1CTL_MCS6,
97 L1CTL_MCS7,
98 L1CTL_MCS8,
99 L1CTL_MCS9,
103 * NOTE: struct size. We do add manual padding out of the believe
104 * that it will avoid some unaligned access.
107 /* there are no more messages in a sequence */
108 #define L1CTL_F_DONE 0x01
110 struct l1ctl_hdr {
111 uint8_t msg_type;
112 uint8_t flags;
113 uint8_t padding[2];
114 uint8_t data[0];
115 } __attribute__((packed));
118 * downlink info ... down from the BTS..
120 struct l1ctl_info_dl {
121 /* GSM 08.58 channel number (9.3.1) */
122 uint8_t chan_nr;
123 /* GSM 08.58 link identifier (9.3.2) */
124 uint8_t link_id;
125 /* the ARFCN and the band. FIXME: what about MAIO? */
126 uint16_t band_arfcn;
128 uint32_t frame_nr;
130 uint8_t rx_level; /* 0 .. 63 in typical GSM notation (dBm+110) */
131 uint8_t snr; /* Signal/Noise Ration (dB) */
132 uint8_t num_biterr;
133 uint8_t fire_crc;
135 uint8_t payload[0];
136 } __attribute__((packed));
138 /* new CCCH was found. This is following the header */
139 struct l1ctl_fbsb_conf {
140 int16_t initial_freq_err;
141 uint8_t result;
142 uint8_t bsic;
143 /* FIXME: contents of cell_info ? */
144 } __attribute__((packed));
146 /* CCCH mode was changed */
147 struct l1ctl_ccch_mode_conf {
148 uint8_t ccch_mode; /* enum ccch_mode */
149 uint8_t padding[3];
150 } __attribute__((packed));
152 /* TCH mode was changed */
153 struct l1ctl_tch_mode_conf {
154 uint8_t tch_mode; /* enum tch_mode */
155 uint8_t audio_mode;
156 uint8_t padding[2];
157 } __attribute__((packed));
159 /* data on the CCCH was found. This is following the header */
160 struct l1ctl_data_ind {
161 uint8_t data[23];
162 } __attribute__((packed));
164 /* traffic from the network */
165 struct l1ctl_traffic_ind {
166 uint8_t data[0];
167 } __attribute__((packed));
170 * uplink info
172 struct l1ctl_info_ul {
173 /* GSM 08.58 channel number (9.3.1) */
174 uint8_t chan_nr;
175 /* GSM 08.58 link identifier (9.3.2) */
176 uint8_t link_id;
177 uint8_t padding[2];
179 uint8_t payload[0];
180 } __attribute__((packed));
182 struct l1ctl_info_ul_tbf {
183 /* references l1ctl_tbf_cfg_req.tbf_nr */
184 uint8_t tbf_nr;
185 uint8_t coding_scheme;
186 uint8_t padding[2];
187 /* RLC/MAC block, size determines CS */
188 uint8_t payload[0];
189 } __attribute__((packed));
192 * msg for FBSB_REQ
193 * the l1_info_ul header is in front
195 struct l1ctl_fbsb_req {
196 uint16_t band_arfcn;
197 uint16_t timeout; /* in TDMA frames */
199 uint16_t freq_err_thresh1;
200 uint16_t freq_err_thresh2;
202 uint8_t num_freqerr_avg;
203 uint8_t flags; /* L1CTL_FBSB_F_* */
204 uint8_t sync_info_idx;
205 uint8_t ccch_mode; /* enum ccch_mode */
206 uint8_t rxlev_exp; /* expected signal level */
207 } __attribute__((packed));
209 #define L1CTL_FBSB_F_FB0 (1 << 0)
210 #define L1CTL_FBSB_F_FB1 (1 << 1)
211 #define L1CTL_FBSB_F_SB (1 << 2)
212 #define L1CTL_FBSB_F_FB01SB (L1CTL_FBSB_F_FB0|L1CTL_FBSB_F_FB1|L1CTL_FBSB_F_SB)
215 * msg for CCCH_MODE_REQ
216 * the l1_info_ul header is in front
218 struct l1ctl_ccch_mode_req {
219 uint8_t ccch_mode; /* enum ccch_mode */
220 uint8_t padding[3];
221 } __attribute__((packed));
224 * msg for TCH_MODE_REQ
225 * the l1_info_ul header is in front
227 struct l1ctl_tch_mode_req {
228 uint8_t tch_mode; /* enum gsm48_chan_mode */
229 #define AUDIO_TX_MICROPHONE (1<<0)
230 #define AUDIO_TX_TRAFFIC_REQ (1<<1)
231 #define AUDIO_RX_SPEAKER (1<<2)
232 #define AUDIO_RX_TRAFFIC_IND (1<<3)
233 uint8_t audio_mode;
234 uint8_t padding[2];
235 } __attribute__((packed));
237 /* the l1_info_ul header is in front */
238 struct l1ctl_rach_req {
239 uint8_t ra;
240 uint8_t combined;
241 uint16_t offset;
242 } __attribute__((packed));
245 /* the l1_info_ul header is in front */
246 struct l1ctl_ext_rach_req {
247 uint16_t ra11;
248 uint8_t synch_seq;
249 uint8_t combined;
250 uint16_t offset;
251 } __attribute__((packed));
253 /* the l1_info_ul header is in front */
254 struct l1ctl_par_req {
255 int8_t ta;
256 uint8_t tx_power;
257 uint8_t padding[2];
258 } __attribute__((packed));
260 struct l1ctl_h0 {
261 uint16_t band_arfcn;
262 } __attribute__((packed));
264 struct l1ctl_h1 {
265 uint8_t hsn;
266 uint8_t maio;
267 uint8_t n;
268 uint8_t _padding[1];
269 uint16_t ma[64];
270 } __attribute__((packed));
272 struct l1ctl_dm_est_req {
273 uint8_t tsc;
274 uint8_t h;
275 union {
276 struct l1ctl_h0 h0;
277 struct l1ctl_h1 h1;
279 uint8_t tch_mode;
280 uint8_t audio_mode;
281 } __attribute__((packed));
283 struct l1ctl_dm_freq_req {
284 uint16_t fn;
285 uint8_t tsc;
286 uint8_t h;
287 union {
288 struct l1ctl_h0 h0;
289 struct l1ctl_h1 h1;
291 } __attribute__((packed));
293 struct l1ctl_crypto_req {
294 uint8_t algo;
295 uint8_t key_len;
296 uint8_t key[0];
297 } __attribute__((packed));
299 struct l1ctl_pm_req {
300 uint8_t type;
301 uint8_t padding[3];
303 union {
304 struct {
305 uint16_t band_arfcn_from;
306 uint16_t band_arfcn_to;
307 } range;
309 } __attribute__((packed));
311 #define BI_FLG_DUMMY (1 << 4)
312 #define BI_FLG_SACCH (1 << 5)
314 struct l1ctl_burst_ind {
315 uint32_t frame_nr;
316 uint16_t band_arfcn; /* ARFCN + band + ul indicator */
317 uint8_t chan_nr; /* GSM 08.58 channel number (9.3.1) */
318 uint8_t flags; /* BI_FLG_xxx + burst_id = 2LSBs */
319 uint8_t rx_level; /* 0 .. 63 in typical GSM notation (dBm+110) */
320 uint8_t snr; /* Reported SNR >> 8 (0-255) */
321 uint8_t bits[15]; /* 114 bits + 2 steal bits. Filled MSB first */
322 } __attribute__((packed));
324 /* a single L1CTL_PM response */
325 struct l1ctl_pm_conf {
326 uint16_t band_arfcn;
327 uint8_t pm[2];
328 } __attribute__((packed));
330 enum l1ctl_reset_type {
331 L1CTL_RES_T_BOOT, /* only _IND */
332 L1CTL_RES_T_FULL,
333 L1CTL_RES_T_SCHED,
336 /* argument to L1CTL_RESET_REQ and L1CTL_RESET_IND */
337 struct l1ctl_reset {
338 uint8_t type;
339 uint8_t pad[3];
340 } __attribute__((packed));
342 struct l1ctl_neigh_pm_req {
343 uint8_t n;
344 uint8_t padding[1];
345 uint16_t band_arfcn[64];
346 uint8_t tn[64];
347 } __attribute__((packed));
349 /* neighbour cell measurement results */
350 struct l1ctl_neigh_pm_ind {
351 uint16_t band_arfcn;
352 uint8_t pm[2];
353 uint8_t tn;
354 uint8_t padding;
355 } __attribute__((packed));
357 /* traffic data to network */
358 struct l1ctl_traffic_req {
359 uint8_t data[0];
360 } __attribute__((packed));
362 struct l1ctl_tbf_cfg_req {
363 /* future support for multiple concurrent TBFs. 0 for now */
364 uint8_t tbf_nr;
365 /* is this about an UL TBF (1) or DL (0) */
366 uint8_t is_uplink;
367 uint8_t padding[2];
369 /* one USF for each TN, or 255 for invalid/unused */
370 uint8_t usf[8];
371 } __attribute__((packed));
373 #endif /* __L1CTL_PROTO_H__ */