l1ctl protocol: Introduce multi-part message DONE flag
[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 #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_sync_new_ccch_resp {
74         uint8_t bsic;
75         uint8_t padding[3];
76 } __attribute__((packed));
77
78 /* data on the CCCH was found. This is following the header */
79 struct l1ctl_data_ind {
80         uint8_t data[23];
81 } __attribute__((packed));
82
83 /*
84  * uplink info
85  */
86 struct l1ctl_info_ul {
87         /* GSM 08.58 channel number (9.3.1) */
88         uint8_t chan_nr;
89         /* GSM 08.58 link identifier (9.3.2) */
90         uint8_t link_id;
91
92         uint8_t tx_power;
93         uint8_t padding2;
94
95         uint8_t payload[0];
96 } __attribute__((packed));
97
98 /*
99  * msg for SYNC_NEW_CCCH_REQ
100  * the l1_info_ul header is in front
101  */
102 struct l1ctl_sync_new_ccch_req {
103         uint16_t band_arfcn;
104 } __attribute__((packed));
105
106
107 /* the l1_info_ul header is in front */
108 struct l1ctl_rach_req {
109         uint8_t ra;
110         uint8_t padding[3];
111 } __attribute__((packed));
112
113 struct l1ctl_dm_est_req {
114         uint16_t band_arfcn;
115         union {
116                 struct {
117                         uint8_t maio_high:4,
118                                  h:1,
119                                  tsc:3;
120                         uint8_t hsn:6,
121                                  maio_low:2;
122                 } h1;
123                 struct {
124                         uint8_t arfcn_high:2,
125                                  spare:2,
126                                  h:1,
127                                  tsc:3;
128                         uint8_t arfcn_low;
129                 } h0;
130         };
131 } __attribute__((packed));
132
133 struct l1ctl_pm_req {
134         uint8_t type;
135         uint8_t padding2;
136
137         union {
138                 struct {
139                         uint16_t band_arfcn_from;
140                         uint16_t band_arfcn_to;
141                 } range;
142         };
143 } __attribute__((packed));
144
145 /* a single L1CTL_PM response */
146 struct l1ctl_pm_resp {
147         uint16_t band_arfcn;
148         uint8_t pm[2];
149 } __attribute__((packed));
150
151 #endif