[l1ctl] Introducing L1CTL_FREQ_REQ to change frequency hopping sequence
[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 };
50
51 enum ccch_mode {
52         CCCH_MODE_NONE = 0,
53         CCCH_MODE_NON_COMBINED,
54         CCCH_MODE_COMBINED,
55 };
56
57 /*
58  * NOTE: struct size. We do add manual padding out of the believe
59  * that it will avoid some unaligned access.
60  */
61
62 /* there are no more messages in a sequence */
63 #define L1CTL_F_DONE    0x01
64
65 struct l1ctl_hdr {
66         uint8_t msg_type;
67         uint8_t flags;
68         uint8_t padding[2];
69         uint8_t data[0];
70 } __attribute__((packed));
71
72 /*
73  * downlink info ... down from the BTS..
74  */
75 struct l1ctl_info_dl {
76         /* GSM 08.58 channel number (9.3.1) */
77         uint8_t chan_nr;
78         /* GSM 08.58 link identifier (9.3.2) */
79         uint8_t link_id;
80         /* the ARFCN and the band. FIXME: what about MAIO? */
81         uint16_t band_arfcn;
82
83         uint32_t frame_nr;
84
85         uint8_t rx_level;       /* 0 .. 63 in typical GSM notation (dBm+110) */
86         uint8_t snr;            /* Signal/Noise Ration (dB) */
87         uint8_t num_biterr;
88         uint8_t fire_crc;
89
90         uint8_t payload[0];
91 } __attribute__((packed));
92
93 /* new CCCH was found. This is following the header */
94 struct l1ctl_fbsb_conf {
95         int16_t initial_freq_err;
96         uint8_t result;
97         uint8_t bsic;
98         /* FIXME: contents of cell_info ? */
99 } __attribute__((packed));
100
101 /* CCCH mode was changed */
102 struct l1ctl_ccch_mode_conf {
103         uint8_t ccch_mode;      /* enum ccch_mode */
104         uint8_t padding[3];
105 } __attribute__((packed));
106
107 /* data on the CCCH was found. This is following the header */
108 struct l1ctl_data_ind {
109         uint8_t data[23];
110 } __attribute__((packed));
111
112 /*
113  * uplink info
114  */
115 struct l1ctl_info_ul {
116         /* GSM 08.58 channel number (9.3.1) */
117         uint8_t chan_nr;
118         /* GSM 08.58 link identifier (9.3.2) */
119         uint8_t link_id;
120         uint8_t padding[2];
121
122         uint8_t payload[0];
123 } __attribute__((packed));
124
125 /*
126  * msg for FBSB_REQ
127  * the l1_info_ul header is in front
128  */
129 struct l1ctl_fbsb_req {
130         uint16_t band_arfcn;
131         uint16_t timeout;       /* in TDMA frames */
132
133         uint16_t freq_err_thresh1;
134         uint16_t freq_err_thresh2;
135
136         uint8_t num_freqerr_avg;
137         uint8_t flags;          /* L1CTL_FBSB_F_* */
138         uint8_t sync_info_idx;
139         uint8_t ccch_mode;      /* enum ccch_mode */
140 } __attribute__((packed));
141
142 #define L1CTL_FBSB_F_FB0        (1 << 0)
143 #define L1CTL_FBSB_F_FB1        (1 << 1)
144 #define L1CTL_FBSB_F_SB         (1 << 2)
145 #define L1CTL_FBSB_F_FB01SB     (L1CTL_FBSB_F_FB0|L1CTL_FBSB_F_FB1|L1CTL_FBSB_F_SB)
146
147 /*
148  * msg for CCCH_MODE_REQ
149  * the l1_info_ul header is in front
150  */
151 struct l1ctl_ccch_mode_req {
152         uint8_t ccch_mode;      /* enum ccch_mode */
153         uint8_t padding[3];
154 } __attribute__((packed));
155
156 /* the l1_info_ul header is in front */
157 struct l1ctl_rach_req {
158         uint8_t ra;
159         uint8_t fn51;
160         uint8_t mf_off;
161         uint8_t padding[1];
162 } __attribute__((packed));
163
164 /* the l1_info_ul header is in front */
165 struct l1ctl_par_req {
166         int8_t ta;
167         uint8_t tx_power;
168         uint8_t padding[2];
169 } __attribute__((packed));
170
171 struct l1ctl_h0 {
172         uint16_t band_arfcn;
173 } __attribute__((packed));
174
175 struct l1ctl_h1 {
176         uint8_t hsn;
177         uint8_t maio;
178         uint8_t n;
179         uint8_t _padding[1];
180         uint16_t ma[64];
181 } __attribute__((packed));
182
183 struct l1ctl_dm_est_req {
184         uint8_t tsc;
185         uint8_t h;
186         union {
187                 struct l1ctl_h0 h0;
188                 struct l1ctl_h1 h1;
189         };
190 } __attribute__((packed));
191
192 struct l1ctl_dm_freq_req {
193         uint16_t fn;
194         uint8_t tsc;
195         uint8_t h;
196         union {
197                 struct l1ctl_h0 h0;
198                 struct l1ctl_h1 h1;
199         };
200 } __attribute__((packed));
201
202 struct l1ctl_pm_req {
203         uint8_t type;
204         uint8_t padding[3];
205
206         union {
207                 struct {
208                         uint16_t band_arfcn_from;
209                         uint16_t band_arfcn_to;
210                 } range;
211         };
212 } __attribute__((packed));
213
214 /* a single L1CTL_PM response */
215 struct l1ctl_pm_conf {
216         uint16_t band_arfcn;
217         uint8_t pm[2];
218 } __attribute__((packed));
219
220 enum l1ctl_reset_type {
221         L1CTL_RES_T_BOOT,       /* only _IND */
222         L1CTL_RES_T_FULL,
223         L1CTL_RES_T_SCHED,
224 };
225
226 /* argument to L1CTL_RESET_REQ and L1CTL_RESET_IND */
227 struct l1ctl_reset {
228         uint8_t type;
229         uint8_t pad[3];
230 } __attribute__((packed));
231
232 #endif /* __L1CTL_PROTO_H__ */