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