blob: 8e40a270c08e4c669f336d1980d1bb74b2edfeaa [file] [log] [blame]
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +04001#ifndef _PCUIF_PROTO_H
2#define _PCUIF_PROTO_H
3
bhargava959d1de2016-08-17 15:17:21 +05304#include <osmocom/gsm/l1sap.h>
Alexander Couzens9b5c9602020-07-28 13:47:18 +02005#include <arpa/inet.h>
bhargava959d1de2016-08-17 15:17:21 +05306
Pau Espin Pedrolc4178e52017-08-08 15:03:50 +02007#define PCU_SOCK_DEFAULT "/tmp/pcu_bts"
8
Vadim Yanitskiy8e2bd1e2020-07-21 00:54:42 +07009#define PCU_IF_VERSION 0x0a
Max0a8fae82017-03-08 18:53:30 +010010#define TXT_MAX_LEN 128
Andreas Eversberg8389fd02012-07-18 10:06:48 +020011
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +040012/* msg_type */
13#define PCU_IF_MSG_DATA_REQ 0x00 /* send data to given channel */
Andreas Eversberga9be1542012-09-27 09:23:24 +020014#define PCU_IF_MSG_DATA_CNF 0x01 /* confirm (e.g. transmission on PCH) */
Alexander Couzensd2a219e2018-02-28 02:56:12 +010015#define PCU_IF_MSG_DATA_IND 0x02 /* receive data from given channel */
Harald Welte3447c4a2017-07-11 00:06:38 +020016#define PCU_IF_MSG_SUSP_REQ 0x03 /* BTS forwards GPRS SUSP REQ to PCU */
Oliver Smithcfb63212019-09-05 17:13:33 +020017#define PCU_IF_MSG_APP_INFO_REQ 0x04 /* BTS asks PCU to transmit APP INFO via PACCH */
Andreas Eversberg8389fd02012-07-18 10:06:48 +020018#define PCU_IF_MSG_RTS_REQ 0x10 /* ready to send request */
Alexander Couzens8343b4a2018-02-28 03:03:49 +010019#define PCU_IF_MSG_DATA_CNF_DT 0x11 /* confirm (with direct tlli) */
Andreas Eversberg8389fd02012-07-18 10:06:48 +020020#define PCU_IF_MSG_RACH_IND 0x22 /* receive RACH */
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +040021#define PCU_IF_MSG_INFO_IND 0x32 /* retrieve BTS info */
22#define PCU_IF_MSG_ACT_REQ 0x40 /* activate/deactivate PDCH */
Andreas Eversberg8389fd02012-07-18 10:06:48 +020023#define PCU_IF_MSG_TIME_IND 0x52 /* GSM time indication */
Vadim Yanitskiy94dc6a82021-06-20 21:00:40 +020024#define PCU_IF_MSG_INTERF_IND 0x53 /* interference report */
Andreas Eversberg8389fd02012-07-18 10:06:48 +020025#define PCU_IF_MSG_PAG_REQ 0x60 /* paging request */
Max0a8fae82017-03-08 18:53:30 +010026#define PCU_IF_MSG_TXT_IND 0x70 /* Text indication for BTS */
Pau Espin Pedrol8c292362021-06-23 17:47:59 +020027#define PCU_IF_MSG_CONTAINER 0x80 /* Transparent container message */
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +040028
Pau Espin Pedrol5557c0a2021-09-07 14:09:50 +020029/* msg_type coming from BSC (inside PCU_IF_MSG_CONTAINER) */
30#define PCU_IF_MSG_NEIGH_ADDR_REQ 0x81 /* Neighbor Address Resolution Request */
31#define PCU_IF_MSG_NEIGH_ADDR_CNF 0x82 /* Neighbor Address Resolution Confirmation */
32
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +040033/* sapi */
34#define PCU_IF_SAPI_RACH 0x01 /* channel request on CCCH */
Andreas Eversberg8389fd02012-07-18 10:06:48 +020035#define PCU_IF_SAPI_AGCH 0x02 /* assignment on AGCH */
36#define PCU_IF_SAPI_PCH 0x03 /* paging/assignment on PCH */
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +040037#define PCU_IF_SAPI_BCCH 0x04 /* SI on BCCH */
38#define PCU_IF_SAPI_PDTCH 0x05 /* packet data/control/ccch block */
39#define PCU_IF_SAPI_PRACH 0x06 /* packet random access channel */
40#define PCU_IF_SAPI_PTCCH 0x07 /* packet TA control channel */
Alexander Couzens8343b4a2018-02-28 03:03:49 +010041#define PCU_IF_SAPI_AGCH_DT 0x08 /* assignment on AGCH but with additional TLLI */
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +040042
43/* flags */
44#define PCU_IF_FLAG_ACTIVE (1 << 0)/* BTS is active */
45#define PCU_IF_FLAG_SYSMO (1 << 1)/* access PDCH of sysmoBTS directly */
46#define PCU_IF_FLAG_CS1 (1 << 16)
47#define PCU_IF_FLAG_CS2 (1 << 17)
48#define PCU_IF_FLAG_CS3 (1 << 18)
49#define PCU_IF_FLAG_CS4 (1 << 19)
50#define PCU_IF_FLAG_MCS1 (1 << 20)
51#define PCU_IF_FLAG_MCS2 (1 << 21)
52#define PCU_IF_FLAG_MCS3 (1 << 22)
53#define PCU_IF_FLAG_MCS4 (1 << 23)
54#define PCU_IF_FLAG_MCS5 (1 << 24)
55#define PCU_IF_FLAG_MCS6 (1 << 25)
56#define PCU_IF_FLAG_MCS7 (1 << 26)
57#define PCU_IF_FLAG_MCS8 (1 << 27)
58#define PCU_IF_FLAG_MCS9 (1 << 28)
59
Alexander Couzens9b5c9602020-07-28 13:47:18 +020060/* NSVC address type */
61#define PCU_IF_ADDR_TYPE_UNSPEC 0x00 /* No address - empty entry */
62#define PCU_IF_ADDR_TYPE_IPV4 0x04 /* IPv4 address */
63#define PCU_IF_ADDR_TYPE_IPV6 0x29 /* IPv6 address */
64
Alexander Couzens5bece2a2020-10-12 02:27:22 +020065#define PCU_IF_NUM_NSVC 2
66
Max0a8fae82017-03-08 18:53:30 +010067enum gsm_pcu_if_text_type {
68 PCU_VERSION,
69 PCU_OML_ALERT,
70};
71
72struct gsm_pcu_if_txt_ind {
73 uint8_t type; /* gsm_pcu_if_text_type */
74 char text[TXT_MAX_LEN]; /* Text to be transmitted to BTS */
75} __attribute__ ((packed));
76
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +040077struct gsm_pcu_if_data {
78 uint8_t sapi;
79 uint8_t len;
80 uint8_t data[162];
81 uint32_t fn;
82 uint16_t arfcn;
83 uint8_t trx_nr;
84 uint8_t ts_nr;
85 uint8_t block_nr;
Andreas Eversberg570b44b2013-03-16 16:15:01 +010086 int8_t rssi;
Alexander Couzensd2a219e2018-02-28 02:56:12 +010087 uint16_t ber10k; /* !< \brief BER in units of 0.01% */
88 int16_t ta_offs_qbits; /* !< \brief Burst TA Offset in quarter bits */
89 int16_t lqual_cb; /* !< \brief Link quality in centiBel */
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +040090} __attribute__ ((packed));
91
Alexander Couzens8343b4a2018-02-28 03:03:49 +010092/* data confirmation with direct tlli (instead of raw mac block with tlli) */
93struct gsm_pcu_if_data_cnf_dt {
94 uint8_t sapi;
95 uint32_t tlli;
96 uint32_t fn;
97 uint16_t arfcn;
98 uint8_t trx_nr;
99 uint8_t ts_nr;
100 uint8_t block_nr;
101 int8_t rssi;
102 uint16_t ber10k; /* !< \brief BER in units of 0.01% */
103 int16_t ta_offs_qbits; /* !< \brief Burst TA Offset in quarter bits */
104 int16_t lqual_cb; /* !< \brief Link quality in centiBel */
105} __attribute__ ((packed));
106
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400107struct gsm_pcu_if_rts_req {
108 uint8_t sapi;
109 uint8_t spare[3];
110 uint32_t fn;
111 uint16_t arfcn;
112 uint8_t trx_nr;
113 uint8_t ts_nr;
114 uint8_t block_nr;
115} __attribute__ ((packed));
116
117struct gsm_pcu_if_rach_ind {
118 uint8_t sapi;
bhargava959d1de2016-08-17 15:17:21 +0530119 uint16_t ra;
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400120 int16_t qta;
121 uint32_t fn;
122 uint16_t arfcn;
bhargava959d1de2016-08-17 15:17:21 +0530123 uint8_t is_11bit;
124 uint8_t burst_type;
Vadim Yanitskiy17954da2019-10-05 23:21:33 +0700125 uint8_t trx_nr;
126 uint8_t ts_nr;
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400127} __attribute__ ((packed));
128
Vadim Yanitskiy8e2bd1e2020-07-21 00:54:42 +0700129struct gsm_pcu_if_info_ts {
130 uint8_t tsc;
131 uint8_t h;
132 uint8_t hsn;
133 uint8_t maio;
134 uint8_t ma_bit_len;
135 uint8_t ma[8];
136} __attribute__ ((packed));
137
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400138struct gsm_pcu_if_info_trx {
139 uint16_t arfcn;
Vadim Yanitskiy8e2bd1e2020-07-21 00:54:42 +0700140 uint8_t pdch_mask; /* PDCH timeslot mask */
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400141 uint8_t spare;
Andreas Eversberg8389fd02012-07-18 10:06:48 +0200142 uint32_t hlayer1;
Vadim Yanitskiy8e2bd1e2020-07-21 00:54:42 +0700143 struct gsm_pcu_if_info_ts ts[8]; /* timeslots per TRX */
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400144} __attribute__ ((packed));
145
146struct gsm_pcu_if_info_ind {
Andreas Eversberg8389fd02012-07-18 10:06:48 +0200147 uint32_t version;
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400148 uint32_t flags;
149 struct gsm_pcu_if_info_trx trx[8]; /* TRX infos per BTS */
Andreas Eversberg8389fd02012-07-18 10:06:48 +0200150 uint8_t bsic;
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400151 /* RAI */
Neels Hofmeyrbdc55fa2018-02-21 00:39:07 +0100152 uint16_t mcc, mnc;
153 uint8_t mnc_3_digits;
154 uint16_t lac, rac;
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400155 /* NSE */
156 uint16_t nsei;
157 uint8_t nse_timer[7];
158 uint8_t cell_timer[11];
Alexander Couzensd2a219e2018-02-28 02:56:12 +0100159 /* cell */
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400160 uint16_t cell_id;
161 uint16_t repeat_time;
162 uint8_t repeat_count;
163 uint16_t bvci;
164 uint8_t t3142;
165 uint8_t t3169;
166 uint8_t t3191;
167 uint8_t t3193_10ms;
168 uint8_t t3195;
169 uint8_t n3101;
170 uint8_t n3103;
171 uint8_t n3105;
172 uint8_t cv_countdown;
173 uint16_t dl_tbf_ext;
174 uint16_t ul_tbf_ext;
175 uint8_t initial_cs;
176 uint8_t initial_mcs;
177 /* NSVC */
Alexander Couzens5bece2a2020-10-12 02:27:22 +0200178 uint16_t nsvci[PCU_IF_NUM_NSVC];
179 uint16_t local_port[PCU_IF_NUM_NSVC];
180 uint16_t remote_port[PCU_IF_NUM_NSVC];
181 uint8_t address_type[PCU_IF_NUM_NSVC];
Alexander Couzens9b5c9602020-07-28 13:47:18 +0200182 union {
183 struct in_addr v4;
184 struct in6_addr v6;
Alexander Couzens5bece2a2020-10-12 02:27:22 +0200185 } remote_ip[PCU_IF_NUM_NSVC];
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400186} __attribute__ ((packed));
187
188struct gsm_pcu_if_act_req {
189 uint8_t activate;
190 uint8_t trx_nr;
191 uint8_t ts_nr;
192 uint8_t spare;
193} __attribute__ ((packed));
194
195struct gsm_pcu_if_time_ind {
196 uint32_t fn;
197} __attribute__ ((packed));
198
Andreas Eversberg8389fd02012-07-18 10:06:48 +0200199struct gsm_pcu_if_pag_req {
200 uint8_t sapi;
201 uint8_t chan_needed;
202 uint8_t identity_lv[9];
203} __attribute__ ((packed));
204
Oliver Smithcfb63212019-09-05 17:13:33 +0200205/* BTS tells PCU to [once] send given application data via PACCH to all UE with active TBF */
206struct gsm_pcu_if_app_info_req {
207 uint8_t application_type; /* 4bit field, see TS 44.060 11.2.47 */
208 uint8_t len; /* length of data */
209 uint8_t data[162]; /* random size choice; ETWS needs 56 bytes */
210} __attribute__ ((packed));
211
Harald Welte3447c4a2017-07-11 00:06:38 +0200212/* BTS tells PCU about a GPRS SUSPENSION REQUEST received on DCCH */
213struct gsm_pcu_if_susp_req {
214 uint32_t tlli;
215 uint8_t ra_id[6];
216 uint8_t cause;
217} __attribute__ ((packed));
218
Vadim Yanitskiy94dc6a82021-06-20 21:00:40 +0200219/* Interference measurements on PDCH timeslots */
220struct gsm_pcu_if_interf_ind {
221 uint8_t trx_nr;
222 uint8_t spare[3];
223 uint32_t fn;
224 uint8_t interf[8];
225} __attribute__ ((packed));
226
Pau Espin Pedrol8c292362021-06-23 17:47:59 +0200227/* Contains messages transmitted BSC<->PCU, potentially forwarded by BTS via IPA/PCU */
228struct gsm_pcu_if_container {
229 uint8_t msg_type;
230 uint8_t spare;
231 uint16_t length; /* network byte order */
232 uint8_t data[0];
233} __attribute__ ((packed));
234
Pau Espin Pedrol5557c0a2021-09-07 14:09:50 +0200235/*** Used inside container: NOTE: values must be network byte order here! ***/
236/* Neighbor Address Resolution Request */
237struct gsm_pcu_if_neigh_addr_req {
238 uint16_t local_lac;
239 uint16_t local_ci;
240 uint16_t tgt_arfcn;
241 uint8_t tgt_bsic;
242} __attribute__ ((packed));
243
244/* Neighbor Address Resolution Confirmation */
245struct gsm_pcu_if_neigh_addr_cnf {
246 struct gsm_pcu_if_neigh_addr_req orig_req;
247 uint8_t err_code; /* 0 success, !0 failed & below unset */
248 /* RAI + CI (CGI-PS): */
249 struct __attribute__ ((packed)) {
250 uint16_t mcc;
251 uint16_t mnc;
252 uint8_t mnc_3_digits;
253 uint16_t lac;
254 uint8_t rac;
255 uint16_t cell_identity;
256 } cgi_ps;
257} __attribute__ ((packed));
258
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400259struct gsm_pcu_if {
260 /* context based information */
261 uint8_t msg_type; /* message type */
262 uint8_t bts_nr; /* bts number */
263 uint8_t spare[2];
264
265 union {
266 struct gsm_pcu_if_data data_req;
Andreas Eversberga9be1542012-09-27 09:23:24 +0200267 struct gsm_pcu_if_data data_cnf;
Alexander Couzens8343b4a2018-02-28 03:03:49 +0100268 struct gsm_pcu_if_data_cnf_dt data_cnf_dt;
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400269 struct gsm_pcu_if_data data_ind;
Harald Welte3447c4a2017-07-11 00:06:38 +0200270 struct gsm_pcu_if_susp_req susp_req;
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400271 struct gsm_pcu_if_rts_req rts_req;
272 struct gsm_pcu_if_rach_ind rach_ind;
Max0a8fae82017-03-08 18:53:30 +0100273 struct gsm_pcu_if_txt_ind txt_ind;
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400274 struct gsm_pcu_if_info_ind info_ind;
275 struct gsm_pcu_if_act_req act_req;
276 struct gsm_pcu_if_time_ind time_ind;
Andreas Eversberg8389fd02012-07-18 10:06:48 +0200277 struct gsm_pcu_if_pag_req pag_req;
Oliver Smithcfb63212019-09-05 17:13:33 +0200278 struct gsm_pcu_if_app_info_req app_info_req;
Vadim Yanitskiy94dc6a82021-06-20 21:00:40 +0200279 struct gsm_pcu_if_interf_ind interf_ind;
Pau Espin Pedrol8c292362021-06-23 17:47:59 +0200280 struct gsm_pcu_if_container container;
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400281 } u;
282} __attribute__ ((packed));
283
284#endif /* _PCUIF_PROTO_H */