Make new L1CTL_FBSB_REQ work reliably
[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 data[0];
51 } __attribute__((packed));
52
53 /*
54  * downlink info ... down from the BTS..
55  */
56 struct l1ctl_info_dl {
57         /* GSM 08.58 channel number (9.3.1) */
58         uint8_t chan_nr;
59         /* GSM 08.58 link identifier (9.3.2) */
60         uint8_t link_id;
61
62         uint32_t frame_nr;
63
64         /* the ARFCN and the band. FIXME: what about MAIO? */
65         uint16_t band_arfcn;
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 payload[0];
70 } __attribute__((packed));
71
72 /* new CCCH was found. This is following the header */
73 struct l1ctl_fbsb_resp {
74         int16_t initial_freq_err;
75         uint8_t result;
76         uint8_t bsic;
77         uint8_t padding[2];
78         /* FIXME: contents of cell_info ? */
79 } __attribute__((packed));
80
81 /* data on the CCCH was found. This is following the header */
82 struct l1ctl_data_ind {
83         uint8_t data[23];
84 } __attribute__((packed));
85
86 /*
87  * uplink info
88  */
89 struct l1ctl_info_ul {
90         /* GSM 08.58 channel number (9.3.1) */
91         uint8_t chan_nr;
92         /* GSM 08.58 link identifier (9.3.2) */
93         uint8_t link_id;
94
95         uint8_t tx_power;
96         uint8_t padding2;
97
98         uint8_t payload[0];
99 } __attribute__((packed));
100
101 /*
102  * msg for FBSB_REQ
103  * the l1_info_ul header is in front
104  */
105 struct l1ctl_fbsb_req {
106         uint16_t band_arfcn;
107         uint16_t timeout;       /* in TDMA frames */
108         uint16_t freq_err_thresh1;
109         uint16_t freq_err_thresh2;
110         uint8_t num_freqerr_avg;
111         uint8_t flags;          /* L1CTL_FBSB_F_* */
112         uint8_t sync_info_idx;
113         uint8_t reserved;
114 } __attribute__((packed));
115
116 #define L1CTL_FBSB_F_FB0        (1 << 0)
117 #define L1CTL_FBSB_F_FB1        (1 << 1)
118 #define L1CTL_FBSB_F_SB         (1 << 2)
119 #define L1CTL_FBSB_F_FB01SB     (L1CTL_FBSB_F_FB0|L1CTL_FBSB_F_FB1|L1CTL_FBSB_F_SB)
120
121 /* the l1_info_ul header is in front */
122 struct l1ctl_rach_req {
123         uint8_t ra;
124         uint8_t padding[3];
125 } __attribute__((packed));
126
127 struct l1ctl_dm_est_req {
128         uint16_t band_arfcn;
129         union {
130                 struct {
131                         uint8_t maio_high:4,
132                                  h:1,
133                                  tsc:3;
134                         uint8_t hsn:6,
135                                  maio_low:2;
136                 } h1;
137                 struct {
138                         uint8_t arfcn_high:2,
139                                  spare:2,
140                                  h:1,
141                                  tsc:3;
142                         uint8_t arfcn_low;
143                 } h0;
144         };
145 } __attribute__((packed));
146
147 struct l1ctl_pm_req {
148         uint8_t type;
149         uint8_t padding2;
150
151         union {
152                 struct {
153                         uint16_t band_arfcn_from;
154                         uint16_t band_arfcn_to;
155                 } range;
156         };
157 } __attribute__((packed));
158
159 /* a single L1CTL_PM response */
160 struct l1ctl_pm_resp {
161         uint16_t band_arfcn;
162         uint8_t pm[2];
163 } __attribute__((packed));
164
165 #endif