Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 1 | #ifndef _PCUIF_PROTO_H |
| 2 | #define _PCUIF_PROTO_H |
| 3 | |
bhargava | 959d1de | 2016-08-17 15:17:21 +0530 | [diff] [blame] | 4 | #include <osmocom/gsm/l1sap.h> |
Alexander Couzens | 9b5c960 | 2020-07-28 13:47:18 +0200 | [diff] [blame] | 5 | #include <arpa/inet.h> |
bhargava | 959d1de | 2016-08-17 15:17:21 +0530 | [diff] [blame] | 6 | |
Pau Espin Pedrol | c4178e5 | 2017-08-08 15:03:50 +0200 | [diff] [blame] | 7 | #define PCU_SOCK_DEFAULT "/tmp/pcu_bts" |
| 8 | |
Vadim Yanitskiy | 8e2bd1e | 2020-07-21 00:54:42 +0700 | [diff] [blame] | 9 | #define PCU_IF_VERSION 0x0a |
Max | 0a8fae8 | 2017-03-08 18:53:30 +0100 | [diff] [blame] | 10 | #define TXT_MAX_LEN 128 |
Andreas Eversberg | 8389fd0 | 2012-07-18 10:06:48 +0200 | [diff] [blame] | 11 | |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 12 | /* msg_type */ |
| 13 | #define PCU_IF_MSG_DATA_REQ 0x00 /* send data to given channel */ |
Andreas Eversberg | a9be154 | 2012-09-27 09:23:24 +0200 | [diff] [blame] | 14 | #define PCU_IF_MSG_DATA_CNF 0x01 /* confirm (e.g. transmission on PCH) */ |
Alexander Couzens | d2a219e | 2018-02-28 02:56:12 +0100 | [diff] [blame] | 15 | #define PCU_IF_MSG_DATA_IND 0x02 /* receive data from given channel */ |
Harald Welte | 3447c4a | 2017-07-11 00:06:38 +0200 | [diff] [blame] | 16 | #define PCU_IF_MSG_SUSP_REQ 0x03 /* BTS forwards GPRS SUSP REQ to PCU */ |
Oliver Smith | cfb6321 | 2019-09-05 17:13:33 +0200 | [diff] [blame] | 17 | #define PCU_IF_MSG_APP_INFO_REQ 0x04 /* BTS asks PCU to transmit APP INFO via PACCH */ |
Andreas Eversberg | 8389fd0 | 2012-07-18 10:06:48 +0200 | [diff] [blame] | 18 | #define PCU_IF_MSG_RTS_REQ 0x10 /* ready to send request */ |
Alexander Couzens | 8343b4a | 2018-02-28 03:03:49 +0100 | [diff] [blame] | 19 | #define PCU_IF_MSG_DATA_CNF_DT 0x11 /* confirm (with direct tlli) */ |
Andreas Eversberg | 8389fd0 | 2012-07-18 10:06:48 +0200 | [diff] [blame] | 20 | #define PCU_IF_MSG_RACH_IND 0x22 /* receive RACH */ |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 21 | #define PCU_IF_MSG_INFO_IND 0x32 /* retrieve BTS info */ |
| 22 | #define PCU_IF_MSG_ACT_REQ 0x40 /* activate/deactivate PDCH */ |
Andreas Eversberg | 8389fd0 | 2012-07-18 10:06:48 +0200 | [diff] [blame] | 23 | #define PCU_IF_MSG_TIME_IND 0x52 /* GSM time indication */ |
Vadim Yanitskiy | 94dc6a8 | 2021-06-20 21:00:40 +0200 | [diff] [blame] | 24 | #define PCU_IF_MSG_INTERF_IND 0x53 /* interference report */ |
Andreas Eversberg | 8389fd0 | 2012-07-18 10:06:48 +0200 | [diff] [blame] | 25 | #define PCU_IF_MSG_PAG_REQ 0x60 /* paging request */ |
Max | 0a8fae8 | 2017-03-08 18:53:30 +0100 | [diff] [blame] | 26 | #define PCU_IF_MSG_TXT_IND 0x70 /* Text indication for BTS */ |
Pau Espin Pedrol | 8c29236 | 2021-06-23 17:47:59 +0200 | [diff] [blame] | 27 | #define PCU_IF_MSG_CONTAINER 0x80 /* Transparent container message */ |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 28 | |
Pau Espin Pedrol | 5557c0a | 2021-09-07 14:09:50 +0200 | [diff] [blame^] | 29 | /* 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 Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 33 | /* sapi */ |
| 34 | #define PCU_IF_SAPI_RACH 0x01 /* channel request on CCCH */ |
Andreas Eversberg | 8389fd0 | 2012-07-18 10:06:48 +0200 | [diff] [blame] | 35 | #define PCU_IF_SAPI_AGCH 0x02 /* assignment on AGCH */ |
| 36 | #define PCU_IF_SAPI_PCH 0x03 /* paging/assignment on PCH */ |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 37 | #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 Couzens | 8343b4a | 2018-02-28 03:03:49 +0100 | [diff] [blame] | 41 | #define PCU_IF_SAPI_AGCH_DT 0x08 /* assignment on AGCH but with additional TLLI */ |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 42 | |
| 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 Couzens | 9b5c960 | 2020-07-28 13:47:18 +0200 | [diff] [blame] | 60 | /* 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 Couzens | 5bece2a | 2020-10-12 02:27:22 +0200 | [diff] [blame] | 65 | #define PCU_IF_NUM_NSVC 2 |
| 66 | |
Max | 0a8fae8 | 2017-03-08 18:53:30 +0100 | [diff] [blame] | 67 | enum gsm_pcu_if_text_type { |
| 68 | PCU_VERSION, |
| 69 | PCU_OML_ALERT, |
| 70 | }; |
| 71 | |
| 72 | struct 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 Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 77 | struct 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 Eversberg | 570b44b | 2013-03-16 16:15:01 +0100 | [diff] [blame] | 86 | int8_t rssi; |
Alexander Couzens | d2a219e | 2018-02-28 02:56:12 +0100 | [diff] [blame] | 87 | 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 Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 90 | } __attribute__ ((packed)); |
| 91 | |
Alexander Couzens | 8343b4a | 2018-02-28 03:03:49 +0100 | [diff] [blame] | 92 | /* data confirmation with direct tlli (instead of raw mac block with tlli) */ |
| 93 | struct 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 Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 107 | struct 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 | |
| 117 | struct gsm_pcu_if_rach_ind { |
| 118 | uint8_t sapi; |
bhargava | 959d1de | 2016-08-17 15:17:21 +0530 | [diff] [blame] | 119 | uint16_t ra; |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 120 | int16_t qta; |
| 121 | uint32_t fn; |
| 122 | uint16_t arfcn; |
bhargava | 959d1de | 2016-08-17 15:17:21 +0530 | [diff] [blame] | 123 | uint8_t is_11bit; |
| 124 | uint8_t burst_type; |
Vadim Yanitskiy | 17954da | 2019-10-05 23:21:33 +0700 | [diff] [blame] | 125 | uint8_t trx_nr; |
| 126 | uint8_t ts_nr; |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 127 | } __attribute__ ((packed)); |
| 128 | |
Vadim Yanitskiy | 8e2bd1e | 2020-07-21 00:54:42 +0700 | [diff] [blame] | 129 | struct 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 Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 138 | struct gsm_pcu_if_info_trx { |
| 139 | uint16_t arfcn; |
Vadim Yanitskiy | 8e2bd1e | 2020-07-21 00:54:42 +0700 | [diff] [blame] | 140 | uint8_t pdch_mask; /* PDCH timeslot mask */ |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 141 | uint8_t spare; |
Andreas Eversberg | 8389fd0 | 2012-07-18 10:06:48 +0200 | [diff] [blame] | 142 | uint32_t hlayer1; |
Vadim Yanitskiy | 8e2bd1e | 2020-07-21 00:54:42 +0700 | [diff] [blame] | 143 | struct gsm_pcu_if_info_ts ts[8]; /* timeslots per TRX */ |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 144 | } __attribute__ ((packed)); |
| 145 | |
| 146 | struct gsm_pcu_if_info_ind { |
Andreas Eversberg | 8389fd0 | 2012-07-18 10:06:48 +0200 | [diff] [blame] | 147 | uint32_t version; |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 148 | uint32_t flags; |
| 149 | struct gsm_pcu_if_info_trx trx[8]; /* TRX infos per BTS */ |
Andreas Eversberg | 8389fd0 | 2012-07-18 10:06:48 +0200 | [diff] [blame] | 150 | uint8_t bsic; |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 151 | /* RAI */ |
Neels Hofmeyr | bdc55fa | 2018-02-21 00:39:07 +0100 | [diff] [blame] | 152 | uint16_t mcc, mnc; |
| 153 | uint8_t mnc_3_digits; |
| 154 | uint16_t lac, rac; |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 155 | /* NSE */ |
| 156 | uint16_t nsei; |
| 157 | uint8_t nse_timer[7]; |
| 158 | uint8_t cell_timer[11]; |
Alexander Couzens | d2a219e | 2018-02-28 02:56:12 +0100 | [diff] [blame] | 159 | /* cell */ |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 160 | 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 Couzens | 5bece2a | 2020-10-12 02:27:22 +0200 | [diff] [blame] | 178 | 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 Couzens | 9b5c960 | 2020-07-28 13:47:18 +0200 | [diff] [blame] | 182 | union { |
| 183 | struct in_addr v4; |
| 184 | struct in6_addr v6; |
Alexander Couzens | 5bece2a | 2020-10-12 02:27:22 +0200 | [diff] [blame] | 185 | } remote_ip[PCU_IF_NUM_NSVC]; |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 186 | } __attribute__ ((packed)); |
| 187 | |
| 188 | struct 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 | |
| 195 | struct gsm_pcu_if_time_ind { |
| 196 | uint32_t fn; |
| 197 | } __attribute__ ((packed)); |
| 198 | |
Andreas Eversberg | 8389fd0 | 2012-07-18 10:06:48 +0200 | [diff] [blame] | 199 | struct 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 Smith | cfb6321 | 2019-09-05 17:13:33 +0200 | [diff] [blame] | 205 | /* BTS tells PCU to [once] send given application data via PACCH to all UE with active TBF */ |
| 206 | struct 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 Welte | 3447c4a | 2017-07-11 00:06:38 +0200 | [diff] [blame] | 212 | /* BTS tells PCU about a GPRS SUSPENSION REQUEST received on DCCH */ |
| 213 | struct gsm_pcu_if_susp_req { |
| 214 | uint32_t tlli; |
| 215 | uint8_t ra_id[6]; |
| 216 | uint8_t cause; |
| 217 | } __attribute__ ((packed)); |
| 218 | |
Vadim Yanitskiy | 94dc6a8 | 2021-06-20 21:00:40 +0200 | [diff] [blame] | 219 | /* Interference measurements on PDCH timeslots */ |
| 220 | struct 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 Pedrol | 8c29236 | 2021-06-23 17:47:59 +0200 | [diff] [blame] | 227 | /* Contains messages transmitted BSC<->PCU, potentially forwarded by BTS via IPA/PCU */ |
| 228 | struct 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 Pedrol | 5557c0a | 2021-09-07 14:09:50 +0200 | [diff] [blame^] | 235 | /*** Used inside container: NOTE: values must be network byte order here! ***/ |
| 236 | /* Neighbor Address Resolution Request */ |
| 237 | struct 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 */ |
| 245 | struct 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 Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 259 | struct 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 Eversberg | a9be154 | 2012-09-27 09:23:24 +0200 | [diff] [blame] | 267 | struct gsm_pcu_if_data data_cnf; |
Alexander Couzens | 8343b4a | 2018-02-28 03:03:49 +0100 | [diff] [blame] | 268 | struct gsm_pcu_if_data_cnf_dt data_cnf_dt; |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 269 | struct gsm_pcu_if_data data_ind; |
Harald Welte | 3447c4a | 2017-07-11 00:06:38 +0200 | [diff] [blame] | 270 | struct gsm_pcu_if_susp_req susp_req; |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 271 | struct gsm_pcu_if_rts_req rts_req; |
| 272 | struct gsm_pcu_if_rach_ind rach_ind; |
Max | 0a8fae8 | 2017-03-08 18:53:30 +0100 | [diff] [blame] | 273 | struct gsm_pcu_if_txt_ind txt_ind; |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 274 | 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 Eversberg | 8389fd0 | 2012-07-18 10:06:48 +0200 | [diff] [blame] | 277 | struct gsm_pcu_if_pag_req pag_req; |
Oliver Smith | cfb6321 | 2019-09-05 17:13:33 +0200 | [diff] [blame] | 278 | struct gsm_pcu_if_app_info_req app_info_req; |
Vadim Yanitskiy | 94dc6a8 | 2021-06-20 21:00:40 +0200 | [diff] [blame] | 279 | struct gsm_pcu_if_interf_ind interf_ind; |
Pau Espin Pedrol | 8c29236 | 2021-06-23 17:47:59 +0200 | [diff] [blame] | 280 | struct gsm_pcu_if_container container; |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 281 | } u; |
| 282 | } __attribute__ ((packed)); |
| 283 | |
| 284 | #endif /* _PCUIF_PROTO_H */ |