L1A/L23 interface (L1CTL) cleanup
[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_NEW_CCCH_REQ      1
28 #define L1CTL_NEW_CCCH_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
36 /*
37  * NOTE: struct size. We do add manual padding out of the believe
38  * that it will avoid some unaligned access.
39  */
40
41 struct l1ctl_hdr {
42         uint8_t msg_type;
43         uint8_t padding;
44         uint8_t data[0];
45 } __attribute__((packed));
46
47 /*
48  * downlink info ... down from the BTS..
49  */
50 struct l1ctl_info_dl {
51         /* GSM 08.58 channel number (9.3.1) */
52         uint8_t chan_nr;
53         /* GSM 08.58 link identifier (9.3.2) */
54         uint8_t link_id;
55
56         uint32_t frame_nr;
57
58         /* the ARFCN and the band. FIXME: what about MAIO? */
59         uint16_t band_arfcn;
60
61         uint8_t rx_level;       /* 0 .. 63 in typical GSM notation (dBm+110) */
62         uint8_t snr;            /* Signal/Noise Ration (dB) */
63         uint8_t payload[0];
64 } __attribute__((packed));
65
66 /* new CCCH was found. This is following the header */
67 struct l1ctl_sync_new_ccch_resp {
68         uint8_t bsic;
69         uint8_t padding[3];
70 } __attribute__((packed));
71
72 /* data on the CCCH was found. This is following the header */
73 struct l1ctl_data_ind {
74         uint8_t data[23];
75 } __attribute__((packed));
76
77 /*
78  * uplink info
79  */
80 struct l1ctl_info_ul {
81         /* GSM 08.58 channel number (9.3.1) */
82         uint8_t chan_nr;
83         /* GSM 08.58 link identifier (9.3.2) */
84         uint8_t link_id;
85
86         uint8_t tx_power;
87         uint8_t padding2;
88
89         uint8_t payload[0];
90 } __attribute__((packed));
91
92 /*
93  * msg for SYNC_NEW_CCCH_REQ
94  * the l1_info_ul header is in front
95  */
96 struct l1ctl_sync_new_ccch_req {
97         uint16_t band_arfcn;
98 } __attribute__((packed));
99
100
101 /* the l1_info_ul header is in front */
102 struct l1ctl_rach_req {
103         uint8_t ra;
104         uint8_t padding[3];
105 } __attribute__((packed));
106
107 struct l1ctl_dm_est_req {
108         uint16_t band_arfcn;
109         union {
110                 struct {
111                         uint8_t maio_high:4,
112                                  h:1,
113                                  tsc:3;
114                         uint8_t hsn:6,
115                                  maio_low:2;
116                 } h1;
117                 struct {
118                         uint8_t arfcn_high:2,
119                                  spare:2,
120                                  h:1,
121                                  tsc:3;
122                         uint8_t arfcn_low;
123                 } h0;
124         };
125 } __attribute__((packed));
126
127 struct l1ctl_pm_req {
128         uint8_t type;
129         uint8_t padding2;
130
131         union {
132                 struct {
133                         uint16_t band_arfcn_from;
134                         uint16_t band_arfcn_to;
135                 } range;
136         };
137 } __attribute__((packed));
138
139 #endif