add an actual Layer1 asynchronous (L1A) API that can be called from higher layers
[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         uint8_t payload[0];
84 } __attribute__((packed));
85
86 /*
87  * msg for SYNC_NEW_CCCH_REQ
88  * the l1_info_ul header is in front
89  */
90 struct l1_sync_new_ccch_req {
91         uint16_t band_arfcn;
92 } __attribute__((packed));
93
94
95 /* the l1_info_ul header is in front */
96 struct l1_rach_req {
97         uint8_t ra;
98         uint8_t padding[3];
99 } __attribute__((packed));
100
101 struct l1_dedic_mode_est_req {
102         struct l1_info_ul header;
103         uint16_t band_arfcn;
104         union {
105                 struct {
106                         uint8_t maio_high:4,
107                                  h:1,
108                                  tsc:3;
109                         uint8_t hsn:6,
110                                  maio_low:2;
111                 } h1;
112                 struct {
113                         uint8_t arfcn_high:2,
114                                  spare:2,
115                                  h:1,
116                                  tsc:3;
117                         uint8_t arfcn_low;
118                 } h0;
119         };
120 } __attribute__((packed));
121
122 /* it is like the ccch ind... unite it? */
123
124 /* the l1_info_dl header is in front */
125 struct l1_dedic_mode_data_ind {
126         uint8_t data[23];
127 } __attribute__((packed));
128
129 /* the l1_info_ul header is in front */
130 struct l1_dedic_mode_data_req {
131         uint8_t data[23];
132 } __attribute__((packed));
133
134
135 #endif