Philipp Maier | b4999b6 | 2016-10-26 15:19:41 +0200 | [diff] [blame] | 1 | #ifndef _PCUIF_PROTO_H |
| 2 | #define _PCUIF_PROTO_H |
| 3 | |
Alexander Couzens | 1231ebe | 2018-02-28 02:53:18 +0100 | [diff] [blame] | 4 | #include <osmocom/gsm/l1sap.h> |
Alexander Couzens | 62af292 | 2020-09-27 00:04:37 +0200 | [diff] [blame] | 5 | #include <arpa/inet.h> |
Alexander Couzens | 1231ebe | 2018-02-28 02:53:18 +0100 | [diff] [blame] | 6 | |
Alexander Couzens | 5fa7253 | 2020-09-27 00:15:05 +0200 | [diff] [blame] | 7 | #define PCU_SOCK_DEFAULT "/tmp/pcu_bts" |
| 8 | |
Alexander Couzens | 97d3978 | 2020-09-26 23:52:45 +0200 | [diff] [blame] | 9 | #define PCU_IF_VERSION 0x0a |
Alexander Couzens | 1231ebe | 2018-02-28 02:53:18 +0100 | [diff] [blame] | 10 | #define TXT_MAX_LEN 128 |
Philipp Maier | b4999b6 | 2016-10-26 15:19:41 +0200 | [diff] [blame] | 11 | |
| 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 Couzens | 5fa7253 | 2020-09-27 00:15:05 +0200 | [diff] [blame] | 16 | #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 Maier | b4999b6 | 2016-10-26 15:19:41 +0200 | [diff] [blame] | 18 | #define PCU_IF_MSG_RTS_REQ 0x10 /* ready to send request */ |
Alexander Couzens | 1231ebe | 2018-02-28 02:53:18 +0100 | [diff] [blame] | 19 | #define PCU_IF_MSG_DATA_CNF_DT 0x11 /* confirm (with direct tlli) */ |
Philipp Maier | b4999b6 | 2016-10-26 15:19:41 +0200 | [diff] [blame] | 20 | #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 Couzens | 1231ebe | 2018-02-28 02:53:18 +0100 | [diff] [blame] | 25 | #define PCU_IF_MSG_TXT_IND 0x70 /* Text indication for BTS */ |
Philipp Maier | b4999b6 | 2016-10-26 15:19:41 +0200 | [diff] [blame] | 26 | |
| 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 Couzens | f14cb35 | 2016-12-02 18:27:01 +0100 | [diff] [blame] | 35 | #define PCU_IF_SAPI_AGCH_DT 0x08 /* assignment on AGCH but with additional TLLI */ |
Philipp Maier | b4999b6 | 2016-10-26 15:19:41 +0200 | [diff] [blame] | 36 | |
| 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 Couzens | 62af292 | 2020-09-27 00:04:37 +0200 | [diff] [blame] | 54 | /* 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 Couzens | 1231ebe | 2018-02-28 02:53:18 +0100 | [diff] [blame] | 59 | enum gsm_pcu_if_text_type { |
| 60 | PCU_VERSION, |
| 61 | PCU_OML_ALERT, |
| 62 | }; |
| 63 | |
| 64 | struct 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 Maier | b4999b6 | 2016-10-26 15:19:41 +0200 | [diff] [blame] | 69 | struct 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 Couzens | 50eed42 | 2018-02-28 02:52:49 +0100 | [diff] [blame] | 79 | uint16_t ber10k; /* !< \brief BER in units of 0.01% */ |
Philipp Maier | b4999b6 | 2016-10-26 15:19:41 +0200 | [diff] [blame] | 80 | 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 Maier | f8aeb2c | 2016-12-02 19:04:34 +0100 | [diff] [blame] | 84 | /* data confirmation with direct tlli (instead of raw mac block with tlli) */ |
| 85 | struct 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 Couzens | 50eed42 | 2018-02-28 02:52:49 +0100 | [diff] [blame] | 94 | 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 Maier | f8aeb2c | 2016-12-02 19:04:34 +0100 | [diff] [blame] | 97 | } __attribute__ ((packed)); |
| 98 | |
Philipp Maier | b4999b6 | 2016-10-26 15:19:41 +0200 | [diff] [blame] | 99 | struct 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 | |
| 109 | struct 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 Couzens | 50eed42 | 2018-02-28 02:52:49 +0100 | [diff] [blame] | 116 | uint8_t burst_type; |
Alexander Couzens | 5fa7253 | 2020-09-27 00:15:05 +0200 | [diff] [blame] | 117 | uint8_t trx_nr; |
| 118 | uint8_t ts_nr; |
Philipp Maier | b4999b6 | 2016-10-26 15:19:41 +0200 | [diff] [blame] | 119 | } __attribute__ ((packed)); |
| 120 | |
Alexander Couzens | 97d3978 | 2020-09-26 23:52:45 +0200 | [diff] [blame] | 121 | struct 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 Maier | b4999b6 | 2016-10-26 15:19:41 +0200 | [diff] [blame] | 130 | struct gsm_pcu_if_info_trx { |
| 131 | uint16_t arfcn; |
Alexander Couzens | 97d3978 | 2020-09-26 23:52:45 +0200 | [diff] [blame] | 132 | uint8_t pdch_mask; /* PDCH timeslot mask */ |
Philipp Maier | b4999b6 | 2016-10-26 15:19:41 +0200 | [diff] [blame] | 133 | uint8_t spare; |
Philipp Maier | b4999b6 | 2016-10-26 15:19:41 +0200 | [diff] [blame] | 134 | uint32_t hlayer1; |
Alexander Couzens | 97d3978 | 2020-09-26 23:52:45 +0200 | [diff] [blame] | 135 | struct gsm_pcu_if_info_trx_ts ts[8]; |
Philipp Maier | b4999b6 | 2016-10-26 15:19:41 +0200 | [diff] [blame] | 136 | } __attribute__ ((packed)); |
| 137 | |
| 138 | struct 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 Hofmeyr | 4ac7763 | 2018-02-22 06:15:58 +0100 | [diff] [blame] | 144 | uint16_t mcc, mnc; |
| 145 | uint8_t mnc_3_digits; |
| 146 | uint16_t lac, rac; |
Philipp Maier | b4999b6 | 2016-10-26 15:19:41 +0200 | [diff] [blame] | 147 | /* 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 Couzens | 62af292 | 2020-09-27 00:04:37 +0200 | [diff] [blame] | 173 | uint8_t address_type[2]; |
| 174 | union { |
| 175 | struct in_addr v4; |
| 176 | struct in6_addr v6; |
| 177 | } remote_ip[2]; |
Philipp Maier | b4999b6 | 2016-10-26 15:19:41 +0200 | [diff] [blame] | 178 | } __attribute__ ((packed)); |
| 179 | |
| 180 | struct 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 | |
| 187 | struct gsm_pcu_if_time_ind { |
| 188 | uint32_t fn; |
| 189 | } __attribute__ ((packed)); |
| 190 | |
| 191 | struct 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 Couzens | 5fa7253 | 2020-09-27 00:15:05 +0200 | [diff] [blame] | 197 | /* BTS tells PCU to [once] send given application data via PACCH to all UE with active TBF */ |
| 198 | struct 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 */ |
| 205 | struct gsm_pcu_if_susp_req { |
| 206 | uint32_t tlli; |
| 207 | uint8_t ra_id[6]; |
| 208 | uint8_t cause; |
| 209 | } __attribute__ ((packed)); |
| 210 | |
Philipp Maier | b4999b6 | 2016-10-26 15:19:41 +0200 | [diff] [blame] | 211 | struct 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 Maier | f8aeb2c | 2016-12-02 19:04:34 +0100 | [diff] [blame] | 220 | struct gsm_pcu_if_data_cnf_dt data_cnf_dt; |
Philipp Maier | b4999b6 | 2016-10-26 15:19:41 +0200 | [diff] [blame] | 221 | struct gsm_pcu_if_data data_ind; |
Alexander Couzens | 5fa7253 | 2020-09-27 00:15:05 +0200 | [diff] [blame] | 222 | struct gsm_pcu_if_susp_req susp_req; |
Philipp Maier | b4999b6 | 2016-10-26 15:19:41 +0200 | [diff] [blame] | 223 | struct gsm_pcu_if_rts_req rts_req; |
| 224 | struct gsm_pcu_if_rach_ind rach_ind; |
Alexander Couzens | 1231ebe | 2018-02-28 02:53:18 +0100 | [diff] [blame] | 225 | struct gsm_pcu_if_txt_ind txt_ind; |
Philipp Maier | b4999b6 | 2016-10-26 15:19:41 +0200 | [diff] [blame] | 226 | 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 Couzens | 5fa7253 | 2020-09-27 00:15:05 +0200 | [diff] [blame] | 230 | struct gsm_pcu_if_app_info_req app_info_req; |
Philipp Maier | b4999b6 | 2016-10-26 15:19:41 +0200 | [diff] [blame] | 231 | } u; |
| 232 | } __attribute__ ((packed)); |
| 233 | |
| 234 | #endif /* _PCUIF_PROTO_H */ |