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