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