L1CTL: Include num_biterr/fire_crc in downlink info + proper alignment/padding
[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_RESP         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             8
34 #define L1CTL_PM_REQ            9       /* power measurement */
35 #define L1CTL_PM_RESP           10      /* power measurement */
36 #define L1CTL_ECHO_REQ          11
37 #define L1CTL_ECHO_RESP         12
38
39 /*
40  * NOTE: struct size. We do add manual padding out of the believe
41  * that it will avoid some unaligned access.
42  */
43
44 /* there are no more messages in a sequence */
45 #define L1CTL_F_DONE    0x01
46
47 struct l1ctl_hdr {
48         uint8_t msg_type;
49         uint8_t flags;
50         uint8_t padding[2];
51         uint8_t data[0];
52 } __attribute__((packed));
53
54 /*
55  * downlink info ... down from the BTS..
56  */
57 struct l1ctl_info_dl {
58         /* GSM 08.58 channel number (9.3.1) */
59         uint8_t chan_nr;
60         /* GSM 08.58 link identifier (9.3.2) */
61         uint8_t link_id;
62         /* the ARFCN and the band. FIXME: what about MAIO? */
63         uint16_t band_arfcn;
64
65         uint32_t frame_nr;
66
67         uint8_t rx_level;       /* 0 .. 63 in typical GSM notation (dBm+110) */
68         uint8_t snr;            /* Signal/Noise Ration (dB) */
69         uint8_t num_biterr;
70         uint8_t fire_crc;
71
72         uint8_t payload[0];
73 } __attribute__((packed));
74
75 /* new CCCH was found. This is following the header */
76 struct l1ctl_fbsb_resp {
77         int16_t initial_freq_err;
78         uint8_t result;
79         uint8_t bsic;
80         /* FIXME: contents of cell_info ? */
81 } __attribute__((packed));
82
83 /* data on the CCCH was found. This is following the header */
84 struct l1ctl_data_ind {
85         uint8_t data[23];
86 } __attribute__((packed));
87
88 /*
89  * uplink info
90  */
91 struct l1ctl_info_ul {
92         /* GSM 08.58 channel number (9.3.1) */
93         uint8_t chan_nr;
94         /* GSM 08.58 link identifier (9.3.2) */
95         uint8_t link_id;
96         uint8_t tx_power;
97         uint8_t padding2;
98
99         uint8_t payload[0];
100 } __attribute__((packed));
101
102 /*
103  * msg for FBSB_REQ
104  * the l1_info_ul header is in front
105  */
106 struct l1ctl_fbsb_req {
107         uint16_t band_arfcn;
108         uint16_t timeout;       /* in TDMA frames */
109
110         uint16_t freq_err_thresh1;
111         uint16_t freq_err_thresh2;
112
113         uint8_t num_freqerr_avg;
114         uint8_t flags;          /* L1CTL_FBSB_F_* */
115         uint8_t sync_info_idx;
116         uint8_t reserved;
117 } __attribute__((packed));
118
119 #define L1CTL_FBSB_F_FB0        (1 << 0)
120 #define L1CTL_FBSB_F_FB1        (1 << 1)
121 #define L1CTL_FBSB_F_SB         (1 << 2)
122 #define L1CTL_FBSB_F_FB01SB     (L1CTL_FBSB_F_FB0|L1CTL_FBSB_F_FB1|L1CTL_FBSB_F_SB)
123
124 /* the l1_info_ul header is in front */
125 struct l1ctl_rach_req {
126         uint8_t ra;
127         uint8_t padding[3];
128 } __attribute__((packed));
129
130 struct l1ctl_dm_est_req {
131         uint16_t band_arfcn;
132         union {
133                 struct {
134                         uint8_t maio_high:4,
135                                  h:1,
136                                  tsc:3;
137                         uint8_t hsn:6,
138                                  maio_low:2;
139                 } h1;
140                 struct {
141                         uint8_t arfcn_high:2,
142                                  spare:2,
143                                  h:1,
144                                  tsc:3;
145                         uint8_t arfcn_low;
146                 } h0;
147         };
148 } __attribute__((packed));
149
150 struct l1ctl_pm_req {
151         uint8_t type;
152         uint8_t padding[3];
153
154         union {
155                 struct {
156                         uint16_t band_arfcn_from;
157                         uint16_t band_arfcn_to;
158                 } range;
159         };
160 } __attribute__((packed));
161
162 /* a single L1CTL_PM response */
163 struct l1ctl_pm_resp {
164         uint16_t band_arfcn;
165         uint8_t pm[2];
166 } __attribute__((packed));
167
168 #endif