Initial import of OsmocomBB into git repository
[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 SYNC_NEW_CCCH_REQ       1
28 #define SYNC_NEW_CCCH_RESP      2
29 #define CCCH_INFO_IND           3
30 #define CCCH_RACH_REQ           4
31 #define DEDIC_MODE_EST_REQ      5
32 #define DEDIC_MODE_DATA_IND     6
33 #define DEDIC_MODE_DATA_REQ     7
34 #define LAYER1_RESET            8
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 gsm_time {
42         uint32_t        fn;     /* FN count */
43         uint16_t        t1;     /* FN div (26*51) */
44         uint8_t         t2;     /* FN modulo 26 */
45         uint8_t         t3;     /* FN modulo 51 */
46         uint8_t         tc;
47 };
48
49 /*
50  * downlink info ... down from the BTS..
51  */
52 struct l1_info_dl {
53         uint8_t msg_type;
54         uint8_t padding;
55         /* the ARFCN and the band. */
56         uint16_t band_arfcn;
57
58         struct gsm_time time;
59         uint8_t rx_level;
60         uint16_t snr[4];
61 } __attribute__((packed));
62
63 /* new CCCH was found. This is following the header */
64 struct l1_sync_new_ccch_resp {
65         uint8_t bsic;
66         uint8_t padding[3];
67 } __attribute__((packed));
68
69 /* data on the CCCH was found. This is following the header */
70 struct l1_ccch_info_ind {
71         uint8_t data[23];
72 } __attribute__((packed));
73
74 /*
75  * uplink info
76  */
77 struct l1_info_ul {
78         uint8_t msg_type;
79         uint8_t padding;
80         uint8_t tx_power;
81         uint8_t channel_number;
82         uint32_t tdma_frame;
83 } __attribute__((packed));
84
85 /*
86  * msg for SYNC_NEW_CCCH_REQ
87  * the l1_info_ul header is in front
88  */
89 struct l1_sync_new_ccch_req {
90         uint16_t band_arfcn;
91 } __attribute__((packed));
92
93
94 /* the l1_info_ul header is in front */
95 struct l1_rach_req {
96         uint8_t ra;
97         uint8_t padding[3];
98 } __attribute__((packed));
99
100 struct l1_dedic_mode_est_req {
101         struct l1_info_ul header;
102         uint16_t band_arfcn;
103         union {
104                 struct {
105                         uint8_t maio_high:4,
106                                  h:1,
107                                  tsc:3;
108                         uint8_t hsn:6,
109                                  maio_low:2;
110                 } h1;
111                 struct {
112                         uint8_t arfcn_high:2,
113                                  spare:2,
114                                  h:1,
115                                  tsc:3;
116                         uint8_t arfcn_low;
117                 } h0;
118         };
119 } __attribute__((packed));
120
121 /* it is like the ccch ind... unite it? */
122
123 /* the l1_info_dl header is in front */
124 struct l1_dedic_mode_data_ind {
125         uint8_t data[23];
126 } __attribute__((packed));
127
128 /* the l1_info_ul header is in front */
129 struct l1_dedic_mode_data_req {
130         uint8_t data[23];
131 } __attribute__((packed));
132
133
134 #endif