blob: 8f7260280ed0691907c81779c9024662ae57e557 [file] [log] [blame]
Philipp Maierb4999b62016-10-26 15:19:41 +02001#ifndef _PCUIF_PROTO_H
2#define _PCUIF_PROTO_H
3
Alexander Couzens1231ebe2018-02-28 02:53:18 +01004#include <osmocom/gsm/l1sap.h>
Alexander Couzens62af2922020-09-27 00:04:37 +02005#include <arpa/inet.h>
Alexander Couzens1231ebe2018-02-28 02:53:18 +01006
Alexander Couzens5fa72532020-09-27 00:15:05 +02007#define PCU_SOCK_DEFAULT "/tmp/pcu_bts"
8
Alexander Couzens97d39782020-09-26 23:52:45 +02009#define PCU_IF_VERSION 0x0a
Alexander Couzens1231ebe2018-02-28 02:53:18 +010010#define TXT_MAX_LEN 128
Philipp Maierb4999b62016-10-26 15:19:41 +020011
12/* msg_type */
13#define PCU_IF_MSG_DATA_REQ 0x00 /* send data to given channel */
14#define PCU_IF_MSG_DATA_CNF 0x01 /* confirm (e.g. transmission on PCH) */
15#define PCU_IF_MSG_DATA_IND 0x02 /* receive data from given channel */
Alexander Couzens5fa72532020-09-27 00:15:05 +020016#define PCU_IF_MSG_SUSP_REQ 0x03 /* BTS forwards GPRS SUSP REQ to PCU */
17#define PCU_IF_MSG_APP_INFO_REQ 0x04 /* BTS asks PCU to transmit APP INFO via PACCH */
Philipp Maierb4999b62016-10-26 15:19:41 +020018#define PCU_IF_MSG_RTS_REQ 0x10 /* ready to send request */
Alexander Couzens1231ebe2018-02-28 02:53:18 +010019#define PCU_IF_MSG_DATA_CNF_DT 0x11 /* confirm (with direct tlli) */
Philipp Maierb4999b62016-10-26 15:19:41 +020020#define PCU_IF_MSG_RACH_IND 0x22 /* receive RACH */
21#define PCU_IF_MSG_INFO_IND 0x32 /* retrieve BTS info */
22#define PCU_IF_MSG_ACT_REQ 0x40 /* activate/deactivate PDCH */
23#define PCU_IF_MSG_TIME_IND 0x52 /* GSM time indication */
24#define PCU_IF_MSG_PAG_REQ 0x60 /* paging request */
Alexander Couzens1231ebe2018-02-28 02:53:18 +010025#define PCU_IF_MSG_TXT_IND 0x70 /* Text indication for BTS */
Philipp Maierb4999b62016-10-26 15:19:41 +020026
27/* sapi */
28#define PCU_IF_SAPI_RACH 0x01 /* channel request on CCCH */
29#define PCU_IF_SAPI_AGCH 0x02 /* assignment on AGCH */
30#define PCU_IF_SAPI_PCH 0x03 /* paging/assignment on PCH */
31#define PCU_IF_SAPI_BCCH 0x04 /* SI on BCCH */
32#define PCU_IF_SAPI_PDTCH 0x05 /* packet data/control/ccch block */
33#define PCU_IF_SAPI_PRACH 0x06 /* packet random access channel */
34#define PCU_IF_SAPI_PTCCH 0x07 /* packet TA control channel */
Alexander Couzensf14cb352016-12-02 18:27:01 +010035#define PCU_IF_SAPI_AGCH_DT 0x08 /* assignment on AGCH but with additional TLLI */
Philipp Maierb4999b62016-10-26 15:19:41 +020036
37/* flags */
38#define PCU_IF_FLAG_ACTIVE (1 << 0)/* BTS is active */
39#define PCU_IF_FLAG_SYSMO (1 << 1)/* access PDCH of sysmoBTS directly */
40#define PCU_IF_FLAG_CS1 (1 << 16)
41#define PCU_IF_FLAG_CS2 (1 << 17)
42#define PCU_IF_FLAG_CS3 (1 << 18)
43#define PCU_IF_FLAG_CS4 (1 << 19)
44#define PCU_IF_FLAG_MCS1 (1 << 20)
45#define PCU_IF_FLAG_MCS2 (1 << 21)
46#define PCU_IF_FLAG_MCS3 (1 << 22)
47#define PCU_IF_FLAG_MCS4 (1 << 23)
48#define PCU_IF_FLAG_MCS5 (1 << 24)
49#define PCU_IF_FLAG_MCS6 (1 << 25)
50#define PCU_IF_FLAG_MCS7 (1 << 26)
51#define PCU_IF_FLAG_MCS8 (1 << 27)
52#define PCU_IF_FLAG_MCS9 (1 << 28)
53
Alexander Couzens62af2922020-09-27 00:04:37 +020054/* NSVC address type */
55#define PCU_IF_ADDR_TYPE_UNSPEC 0x00 /* No address - empty entry */
56#define PCU_IF_ADDR_TYPE_IPV4 0x04 /* IPv4 address */
57#define PCU_IF_ADDR_TYPE_IPV6 0x29 /* IPv6 address */
58
Alexander Couzens1231ebe2018-02-28 02:53:18 +010059enum gsm_pcu_if_text_type {
60 PCU_VERSION,
61 PCU_OML_ALERT,
62};
63
64struct gsm_pcu_if_txt_ind {
65 uint8_t type; /* gsm_pcu_if_text_type */
66 char text[TXT_MAX_LEN]; /* Text to be transmitted to BTS */
67} __attribute__ ((packed));
68
Philipp Maierb4999b62016-10-26 15:19:41 +020069struct gsm_pcu_if_data {
70 uint8_t sapi;
71 uint8_t len;
72 uint8_t data[162];
73 uint32_t fn;
74 uint16_t arfcn;
75 uint8_t trx_nr;
76 uint8_t ts_nr;
77 uint8_t block_nr;
78 int8_t rssi;
Alexander Couzens50eed422018-02-28 02:52:49 +010079 uint16_t ber10k; /* !< \brief BER in units of 0.01% */
Philipp Maierb4999b62016-10-26 15:19:41 +020080 int16_t ta_offs_qbits; /* !< \brief Burst TA Offset in quarter bits */
81 int16_t lqual_cb; /* !< \brief Link quality in centiBel */
82} __attribute__ ((packed));
83
Philipp Maierf8aeb2c2016-12-02 19:04:34 +010084/* data confirmation with direct tlli (instead of raw mac block with tlli) */
85struct gsm_pcu_if_data_cnf_dt {
86 uint8_t sapi;
87 uint32_t tlli;
88 uint32_t fn;
89 uint16_t arfcn;
90 uint8_t trx_nr;
91 uint8_t ts_nr;
92 uint8_t block_nr;
93 int8_t rssi;
Alexander Couzens50eed422018-02-28 02:52:49 +010094 uint16_t ber10k; /* !< \brief BER in units of 0.01% */
95 int16_t ta_offs_qbits; /* !< \brief Burst TA Offset in quarter bits */
96 int16_t lqual_cb; /* !< \brief Link quality in centiBel */
Philipp Maierf8aeb2c2016-12-02 19:04:34 +010097} __attribute__ ((packed));
98
Philipp Maierb4999b62016-10-26 15:19:41 +020099struct gsm_pcu_if_rts_req {
100 uint8_t sapi;
101 uint8_t spare[3];
102 uint32_t fn;
103 uint16_t arfcn;
104 uint8_t trx_nr;
105 uint8_t ts_nr;
106 uint8_t block_nr;
107} __attribute__ ((packed));
108
109struct gsm_pcu_if_rach_ind {
110 uint8_t sapi;
111 uint16_t ra;
112 int16_t qta;
113 uint32_t fn;
114 uint16_t arfcn;
115 uint8_t is_11bit;
Alexander Couzens50eed422018-02-28 02:52:49 +0100116 uint8_t burst_type;
Alexander Couzens5fa72532020-09-27 00:15:05 +0200117 uint8_t trx_nr;
118 uint8_t ts_nr;
Philipp Maierb4999b62016-10-26 15:19:41 +0200119} __attribute__ ((packed));
120
Alexander Couzens97d39782020-09-26 23:52:45 +0200121struct gsm_pcu_if_info_trx_ts {
122 uint8_t tsc;
123 uint8_t hopping;
124 uint8_t hsn;
125 uint8_t maio;
126 uint8_t ma_bit_len;
127 uint8_t ma[8];
128} __attribute__ ((packed));
129
Philipp Maierb4999b62016-10-26 15:19:41 +0200130struct gsm_pcu_if_info_trx {
131 uint16_t arfcn;
Alexander Couzens97d39782020-09-26 23:52:45 +0200132 uint8_t pdch_mask; /* PDCH timeslot mask */
Philipp Maierb4999b62016-10-26 15:19:41 +0200133 uint8_t spare;
Philipp Maierb4999b62016-10-26 15:19:41 +0200134 uint32_t hlayer1;
Alexander Couzens97d39782020-09-26 23:52:45 +0200135 struct gsm_pcu_if_info_trx_ts ts[8];
Philipp Maierb4999b62016-10-26 15:19:41 +0200136} __attribute__ ((packed));
137
138struct gsm_pcu_if_info_ind {
139 uint32_t version;
140 uint32_t flags;
141 struct gsm_pcu_if_info_trx trx[8]; /* TRX infos per BTS */
142 uint8_t bsic;
143 /* RAI */
Neels Hofmeyr4ac77632018-02-22 06:15:58 +0100144 uint16_t mcc, mnc;
145 uint8_t mnc_3_digits;
146 uint16_t lac, rac;
Philipp Maierb4999b62016-10-26 15:19:41 +0200147 /* NSE */
148 uint16_t nsei;
149 uint8_t nse_timer[7];
150 uint8_t cell_timer[11];
151 /* cell */
152 uint16_t cell_id;
153 uint16_t repeat_time;
154 uint8_t repeat_count;
155 uint16_t bvci;
156 uint8_t t3142;
157 uint8_t t3169;
158 uint8_t t3191;
159 uint8_t t3193_10ms;
160 uint8_t t3195;
161 uint8_t n3101;
162 uint8_t n3103;
163 uint8_t n3105;
164 uint8_t cv_countdown;
165 uint16_t dl_tbf_ext;
166 uint16_t ul_tbf_ext;
167 uint8_t initial_cs;
168 uint8_t initial_mcs;
169 /* NSVC */
170 uint16_t nsvci[2];
171 uint16_t local_port[2];
172 uint16_t remote_port[2];
Alexander Couzens62af2922020-09-27 00:04:37 +0200173 uint8_t address_type[2];
174 union {
175 struct in_addr v4;
176 struct in6_addr v6;
177 } remote_ip[2];
Philipp Maierb4999b62016-10-26 15:19:41 +0200178} __attribute__ ((packed));
179
180struct gsm_pcu_if_act_req {
181 uint8_t activate;
182 uint8_t trx_nr;
183 uint8_t ts_nr;
184 uint8_t spare;
185} __attribute__ ((packed));
186
187struct gsm_pcu_if_time_ind {
188 uint32_t fn;
189} __attribute__ ((packed));
190
191struct gsm_pcu_if_pag_req {
192 uint8_t sapi;
193 uint8_t chan_needed;
194 uint8_t identity_lv[9];
195} __attribute__ ((packed));
196
Alexander Couzens5fa72532020-09-27 00:15:05 +0200197/* BTS tells PCU to [once] send given application data via PACCH to all UE with active TBF */
198struct gsm_pcu_if_app_info_req {
199 uint8_t application_type; /* 4bit field, see TS 44.060 11.2.47 */
200 uint8_t len; /* length of data */
201 uint8_t data[162]; /* random size choice; ETWS needs 56 bytes */
202} __attribute__ ((packed));
203
204/* BTS tells PCU about a GPRS SUSPENSION REQUEST received on DCCH */
205struct gsm_pcu_if_susp_req {
206 uint32_t tlli;
207 uint8_t ra_id[6];
208 uint8_t cause;
209} __attribute__ ((packed));
210
Philipp Maierb4999b62016-10-26 15:19:41 +0200211struct gsm_pcu_if {
212 /* context based information */
213 uint8_t msg_type; /* message type */
214 uint8_t bts_nr; /* bts number */
215 uint8_t spare[2];
216
217 union {
218 struct gsm_pcu_if_data data_req;
219 struct gsm_pcu_if_data data_cnf;
Philipp Maierf8aeb2c2016-12-02 19:04:34 +0100220 struct gsm_pcu_if_data_cnf_dt data_cnf_dt;
Philipp Maierb4999b62016-10-26 15:19:41 +0200221 struct gsm_pcu_if_data data_ind;
Alexander Couzens5fa72532020-09-27 00:15:05 +0200222 struct gsm_pcu_if_susp_req susp_req;
Philipp Maierb4999b62016-10-26 15:19:41 +0200223 struct gsm_pcu_if_rts_req rts_req;
224 struct gsm_pcu_if_rach_ind rach_ind;
Alexander Couzens1231ebe2018-02-28 02:53:18 +0100225 struct gsm_pcu_if_txt_ind txt_ind;
Philipp Maierb4999b62016-10-26 15:19:41 +0200226 struct gsm_pcu_if_info_ind info_ind;
227 struct gsm_pcu_if_act_req act_req;
228 struct gsm_pcu_if_time_ind time_ind;
229 struct gsm_pcu_if_pag_req pag_req;
Alexander Couzens5fa72532020-09-27 00:15:05 +0200230 struct gsm_pcu_if_app_info_req app_info_req;
Philipp Maierb4999b62016-10-26 15:19:41 +0200231 } u;
232} __attribute__ ((packed));
233
234#endif /* _PCUIF_PROTO_H */