6c47246bb54c439fa2a99afd65055cc91934cc2c
[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 l1a_l23_interface_h
25 #define l1a_l23_interface_h
26
27 #define L1CTL_FBSB_REQ          1
28 #define L1CTL_FBSB_CONF         2
29 #define L1CTL_DATA_IND          3
30 #define L1CTL_RACH_REQ          4
31 #define L1CTL_DM_EST_REQ        5
32 #define L1CTL_DATA_REQ          7
33 #define L1CTL_RESET_IND         8
34 #define L1CTL_PM_REQ            9       /* power measurement */
35 #define L1CTL_PM_CONF           10      /* power measurement */
36 #define L1CTL_ECHO_REQ          11
37 #define L1CTL_ECHO_CONF         12
38 #define L1CTL_RACH_CONF         13
39 #define L1CTL_RESET_REQ         14
40 #define L1CTL_RESET_CONF        15
41 #define L1CTL_DATA_CONF         16
42 #define L1CTL_CCCH_MODE_REQ     17
43 #define L1CTL_CCCH_MODE_CONF    18
44 #define L1CTL_DM_REL_REQ        19
45 #define L1CTL_PARAM_REQ         20
46
47 enum ccch_mode {
48         CCCH_MODE_NONE = 0,
49         CCCH_MODE_NON_COMBINED,
50         CCCH_MODE_COMBINED,
51 };
52
53 /*
54  * NOTE: struct size. We do add manual padding out of the believe
55  * that it will avoid some unaligned access.
56  */
57
58 /* there are no more messages in a sequence */
59 #define L1CTL_F_DONE    0x01
60
61 struct l1ctl_hdr {
62         uint8_t msg_type;
63         uint8_t flags;
64         uint8_t padding[2];
65         uint8_t data[0];
66 } __attribute__((packed));
67
68 /*
69  * downlink info ... down from the BTS..
70  */
71 struct l1ctl_info_dl {
72         /* GSM 08.58 channel number (9.3.1) */
73         uint8_t chan_nr;
74         /* GSM 08.58 link identifier (9.3.2) */
75         uint8_t link_id;
76         /* the ARFCN and the band. FIXME: what about MAIO? */
77         uint16_t band_arfcn;
78
79         uint32_t frame_nr;
80
81         uint8_t rx_level;       /* 0 .. 63 in typical GSM notation (dBm+110) */
82         uint8_t snr;            /* Signal/Noise Ration (dB) */
83         uint8_t num_biterr;
84         uint8_t fire_crc;
85
86         uint8_t payload[0];
87 } __attribute__((packed));
88
89 /* new CCCH was found. This is following the header */
90 struct l1ctl_fbsb_conf {
91         int16_t initial_freq_err;
92         uint8_t result;
93         uint8_t bsic;
94         /* FIXME: contents of cell_info ? */
95 } __attribute__((packed));
96
97 /* CCCH mode was changed */
98 struct l1ctl_ccch_mode_conf {
99         uint8_t ccch_mode;      /* enum ccch_mode */
100         uint8_t padding[3];
101 } __attribute__((packed));
102
103 /* data on the CCCH was found. This is following the header */
104 struct l1ctl_data_ind {
105         uint8_t data[23];
106 } __attribute__((packed));
107
108 /*
109  * uplink info
110  */
111 struct l1ctl_info_ul {
112         /* GSM 08.58 channel number (9.3.1) */
113         uint8_t chan_nr;
114         /* GSM 08.58 link identifier (9.3.2) */
115         uint8_t link_id;
116         uint8_t padding[2];
117
118         uint8_t payload[0];
119 } __attribute__((packed));
120
121 /*
122  * msg for FBSB_REQ
123  * the l1_info_ul header is in front
124  */
125 struct l1ctl_fbsb_req {
126         uint16_t band_arfcn;
127         uint16_t timeout;       /* in TDMA frames */
128
129         uint16_t freq_err_thresh1;
130         uint16_t freq_err_thresh2;
131
132         uint8_t num_freqerr_avg;
133         uint8_t flags;          /* L1CTL_FBSB_F_* */
134         uint8_t sync_info_idx;
135         uint8_t ccch_mode;      /* enum ccch_mode */
136 } __attribute__((packed));
137
138 #define L1CTL_FBSB_F_FB0        (1 << 0)
139 #define L1CTL_FBSB_F_FB1        (1 << 1)
140 #define L1CTL_FBSB_F_SB         (1 << 2)
141 #define L1CTL_FBSB_F_FB01SB     (L1CTL_FBSB_F_FB0|L1CTL_FBSB_F_FB1|L1CTL_FBSB_F_SB)
142
143 /*
144  * msg for CCCH_MODE_REQ
145  * the l1_info_ul header is in front
146  */
147 struct l1ctl_ccch_mode_req {
148         uint8_t ccch_mode;      /* enum ccch_mode */
149         uint8_t padding[3];
150 } __attribute__((packed));
151
152 /* the l1_info_ul header is in front */
153 struct l1ctl_rach_req {
154         uint8_t ra;
155         uint8_t fn51;
156         uint8_t mf_off;
157         uint8_t padding[1];
158 } __attribute__((packed));
159
160 /* the l1_info_ul header is in front */
161 struct l1ctl_par_req {
162         int8_t ta;
163         uint8_t tx_power;
164         uint8_t padding[2];
165 } __attribute__((packed));
166
167 struct l1ctl_dm_est_req {
168         uint8_t tsc;
169         uint8_t h;
170         union {
171                 struct {
172                         uint16_t band_arfcn;
173                 } h0;
174                 struct {
175                         uint8_t hsn;
176                         uint8_t maio;
177                         uint8_t n;
178                         uint8_t _padding[1];
179                         uint16_t ma[64];
180                 } h1;
181         };
182 } __attribute__((packed));
183
184 struct l1ctl_pm_req {
185         uint8_t type;
186         uint8_t padding[3];
187
188         union {
189                 struct {
190                         uint16_t band_arfcn_from;
191                         uint16_t band_arfcn_to;
192                 } range;
193         };
194 } __attribute__((packed));
195
196 /* a single L1CTL_PM response */
197 struct l1ctl_pm_conf {
198         uint16_t band_arfcn;
199         uint8_t pm[2];
200 } __attribute__((packed));
201
202 enum l1ctl_reset_type {
203         L1CTL_RES_T_BOOT,       /* only _IND */
204         L1CTL_RES_T_FULL,
205         L1CTL_RES_T_SCHED,
206 };
207
208 /* argument to L1CTL_RESET_REQ and L1CTL_RESET_IND */
209 struct l1ctl_reset {
210         uint8_t type;
211         uint8_t pad[3];
212 } __attribute__((packed));
213
214 #endif