Eric | 847de6d | 2022-10-27 16:54:53 +0200 | [diff] [blame] | 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 | */ |
| 19 | |
| 20 | #ifndef __L1CTL_PROTO_H__ |
| 21 | #define __L1CTL_PROTO_H__ |
| 22 | |
| 23 | enum { |
| 24 | _L1CTL_NONE = 0, |
| 25 | L1CTL_FBSB_REQ, |
| 26 | L1CTL_FBSB_CONF, |
| 27 | L1CTL_DATA_IND, |
| 28 | L1CTL_RACH_REQ, |
| 29 | L1CTL_DM_EST_REQ, |
| 30 | L1CTL_DATA_REQ, |
| 31 | L1CTL_RESET_IND, |
| 32 | L1CTL_PM_REQ, /* power measurement */ |
| 33 | L1CTL_PM_CONF, /* power measurement */ |
| 34 | L1CTL_ECHO_REQ, |
| 35 | L1CTL_ECHO_CONF, |
| 36 | L1CTL_RACH_CONF, |
| 37 | L1CTL_RESET_REQ, |
| 38 | L1CTL_RESET_CONF, |
| 39 | L1CTL_DATA_CONF, |
| 40 | L1CTL_CCCH_MODE_REQ, |
| 41 | L1CTL_CCCH_MODE_CONF, |
| 42 | L1CTL_DM_REL_REQ, |
| 43 | L1CTL_PARAM_REQ, |
| 44 | L1CTL_DM_FREQ_REQ, |
| 45 | L1CTL_CRYPTO_REQ, |
| 46 | L1CTL_SIM_REQ, |
| 47 | L1CTL_SIM_CONF, |
| 48 | L1CTL_TCH_MODE_REQ, |
| 49 | L1CTL_TCH_MODE_CONF, |
| 50 | L1CTL_NEIGH_PM_REQ, |
| 51 | L1CTL_NEIGH_PM_IND, |
| 52 | L1CTL_TRAFFIC_REQ, |
| 53 | L1CTL_TRAFFIC_CONF, |
| 54 | L1CTL_TRAFFIC_IND, |
| 55 | L1CTL_BURST_IND, |
| 56 | |
| 57 | /* configure TBF for uplink/downlink */ |
| 58 | L1CTL_TBF_CFG_REQ, |
| 59 | L1CTL_TBF_CFG_CONF, |
| 60 | |
| 61 | L1CTL_DATA_TBF_REQ, |
| 62 | L1CTL_DATA_TBF_CONF, |
| 63 | |
| 64 | /* Extended (11-bit) RACH (see 3GPP TS 05.02, section 5.2.7) */ |
| 65 | L1CTL_EXT_RACH_REQ, |
| 66 | }; |
| 67 | |
| 68 | enum ccch_mode { |
| 69 | CCCH_MODE_NONE = 0, |
| 70 | CCCH_MODE_NON_COMBINED, |
| 71 | CCCH_MODE_COMBINED, |
| 72 | CCCH_MODE_COMBINED_CBCH, |
| 73 | }; |
| 74 | |
| 75 | enum neigh_mode { |
| 76 | NEIGH_MODE_NONE = 0, |
| 77 | NEIGH_MODE_PM, |
| 78 | NEIGH_MODE_SB, |
| 79 | }; |
| 80 | |
| 81 | enum l1ctl_coding_scheme { |
| 82 | L1CTL_CS_NONE, |
| 83 | L1CTL_CS1, |
| 84 | L1CTL_CS2, |
| 85 | L1CTL_CS3, |
| 86 | L1CTL_CS4, |
| 87 | L1CTL_MCS1, |
| 88 | L1CTL_MCS2, |
| 89 | L1CTL_MCS3, |
| 90 | L1CTL_MCS4, |
| 91 | L1CTL_MCS5, |
| 92 | L1CTL_MCS6, |
| 93 | L1CTL_MCS7, |
| 94 | L1CTL_MCS8, |
| 95 | L1CTL_MCS9, |
| 96 | }; |
| 97 | |
| 98 | /* |
| 99 | * NOTE: struct size. We do add manual padding out of the believe |
| 100 | * that it will avoid some unaligned access. |
| 101 | */ |
| 102 | |
| 103 | /* there are no more messages in a sequence */ |
| 104 | #define L1CTL_F_DONE 0x01 |
| 105 | |
| 106 | struct l1ctl_hdr { |
| 107 | uint8_t msg_type; |
| 108 | uint8_t flags; |
| 109 | uint8_t padding[2]; |
| 110 | uint8_t data[0]; |
| 111 | } __attribute__((packed)); |
| 112 | |
| 113 | /* |
| 114 | * downlink info ... down from the BTS.. |
| 115 | */ |
| 116 | struct l1ctl_info_dl { |
| 117 | /* GSM 08.58 channel number (9.3.1) */ |
| 118 | uint8_t chan_nr; |
| 119 | /* GSM 08.58 link identifier (9.3.2) */ |
| 120 | uint8_t link_id; |
| 121 | /* the ARFCN and the band. FIXME: what about MAIO? */ |
| 122 | uint16_t band_arfcn; |
| 123 | |
| 124 | uint32_t frame_nr; |
| 125 | |
| 126 | uint8_t rx_level; /* 0 .. 63 in typical GSM notation (dBm+110) */ |
| 127 | uint8_t snr; /* Signal/Noise Ration (dB) */ |
| 128 | uint8_t num_biterr; |
| 129 | uint8_t fire_crc; |
| 130 | |
| 131 | uint8_t payload[0]; |
| 132 | } __attribute__((packed)); |
| 133 | |
| 134 | /* new CCCH was found. This is following the header */ |
| 135 | struct l1ctl_fbsb_conf { |
| 136 | int16_t initial_freq_err; |
| 137 | uint8_t result; |
| 138 | uint8_t bsic; |
| 139 | /* FIXME: contents of cell_info ? */ |
| 140 | } __attribute__((packed)); |
| 141 | |
| 142 | /* CCCH mode was changed */ |
| 143 | struct l1ctl_ccch_mode_conf { |
| 144 | uint8_t ccch_mode; /* enum ccch_mode */ |
| 145 | uint8_t padding[3]; |
| 146 | } __attribute__((packed)); |
| 147 | |
| 148 | /* 3GPP TS 44.014, section 5.1 (Calypso specific numbers) */ |
| 149 | enum l1ctl_tch_loop_mode { |
| 150 | L1CTL_TCH_LOOP_OPEN = 0x00, |
| 151 | L1CTL_TCH_LOOP_A = 0x01, |
| 152 | L1CTL_TCH_LOOP_B = 0x02, |
| 153 | L1CTL_TCH_LOOP_C = 0x03, |
| 154 | L1CTL_TCH_LOOP_D = 0x04, |
| 155 | L1CTL_TCH_LOOP_E = 0x05, |
| 156 | L1CTL_TCH_LOOP_F = 0x06, |
| 157 | L1CTL_TCH_LOOP_I = 0x07, |
| 158 | }; |
| 159 | |
| 160 | /* TCH mode was changed */ |
| 161 | struct l1ctl_tch_mode_conf { |
| 162 | uint8_t tch_mode; /* enum tch_mode */ |
| 163 | uint8_t audio_mode; |
| 164 | uint8_t tch_loop_mode; /* enum l1ctl_tch_loop_mode */ |
| 165 | struct { /* 3GPP TS 08.58 9.3.52, 3GPP TS 44.018 10.5.2.21aa */ |
| 166 | uint8_t start_codec; |
| 167 | uint8_t codecs_bitmask; |
| 168 | } amr; |
| 169 | } __attribute__((packed)); |
| 170 | |
| 171 | /* data on the CCCH was found. This is following the header */ |
| 172 | struct l1ctl_data_ind { |
| 173 | uint8_t data[23]; |
| 174 | } __attribute__((packed)); |
| 175 | |
| 176 | /* traffic from the network */ |
| 177 | struct l1ctl_traffic_ind { |
| 178 | uint8_t data[0]; |
| 179 | } __attribute__((packed)); |
| 180 | |
| 181 | /* |
| 182 | * uplink info |
| 183 | */ |
| 184 | struct l1ctl_info_ul { |
| 185 | /* GSM 08.58 channel number (9.3.1) */ |
| 186 | uint8_t chan_nr; |
| 187 | /* GSM 08.58 link identifier (9.3.2) */ |
| 188 | uint8_t link_id; |
| 189 | uint8_t padding[2]; |
| 190 | |
| 191 | uint8_t payload[0]; |
| 192 | } __attribute__((packed)); |
| 193 | |
| 194 | struct l1ctl_info_ul_tbf { |
| 195 | /* references l1ctl_tbf_cfg_req.tbf_nr */ |
| 196 | uint8_t tbf_nr; |
| 197 | uint8_t coding_scheme; |
| 198 | uint8_t padding[2]; |
| 199 | /* RLC/MAC block, size determines CS */ |
| 200 | uint8_t payload[0]; |
| 201 | } __attribute__((packed)); |
| 202 | |
| 203 | /* |
| 204 | * msg for FBSB_REQ |
| 205 | * the l1_info_ul header is in front |
| 206 | */ |
| 207 | struct l1ctl_fbsb_req { |
| 208 | uint16_t band_arfcn; |
| 209 | uint16_t timeout; /* in TDMA frames */ |
| 210 | |
| 211 | uint16_t freq_err_thresh1; |
| 212 | uint16_t freq_err_thresh2; |
| 213 | |
| 214 | uint8_t num_freqerr_avg; |
| 215 | uint8_t flags; /* L1CTL_FBSB_F_* */ |
| 216 | uint8_t sync_info_idx; |
| 217 | uint8_t ccch_mode; /* enum ccch_mode */ |
| 218 | uint8_t rxlev_exp; /* expected signal level */ |
| 219 | } __attribute__((packed)); |
| 220 | |
| 221 | #define L1CTL_FBSB_F_FB0 (1 << 0) |
| 222 | #define L1CTL_FBSB_F_FB1 (1 << 1) |
| 223 | #define L1CTL_FBSB_F_SB (1 << 2) |
| 224 | #define L1CTL_FBSB_F_FB01SB (L1CTL_FBSB_F_FB0|L1CTL_FBSB_F_FB1|L1CTL_FBSB_F_SB) |
| 225 | |
| 226 | /* |
| 227 | * msg for CCCH_MODE_REQ |
| 228 | * the l1_info_ul header is in front |
| 229 | */ |
| 230 | struct l1ctl_ccch_mode_req { |
| 231 | uint8_t ccch_mode; /* enum ccch_mode */ |
| 232 | uint8_t padding[3]; |
| 233 | } __attribute__((packed)); |
| 234 | |
| 235 | /* |
| 236 | * msg for TCH_MODE_REQ |
| 237 | * the l1_info_ul header is in front |
| 238 | */ |
| 239 | struct l1ctl_tch_mode_req { |
| 240 | uint8_t tch_mode; /* enum gsm48_chan_mode */ |
| 241 | #define AUDIO_TX_MICROPHONE (1<<0) |
| 242 | #define AUDIO_TX_TRAFFIC_REQ (1<<1) |
| 243 | #define AUDIO_RX_SPEAKER (1<<2) |
| 244 | #define AUDIO_RX_TRAFFIC_IND (1<<3) |
| 245 | uint8_t audio_mode; |
| 246 | uint8_t tch_loop_mode; /* enum l1ctl_tch_loop_mode */ |
| 247 | struct { /* 3GPP TS 08.58 9.3.52, 3GPP TS 44.018 10.5.2.21aa */ |
| 248 | uint8_t start_codec; |
| 249 | uint8_t codecs_bitmask; |
| 250 | } amr; |
| 251 | } __attribute__((packed)); |
| 252 | |
| 253 | /* the l1_info_ul header is in front */ |
| 254 | struct l1ctl_rach_req { |
| 255 | uint8_t ra; |
| 256 | uint8_t combined; |
| 257 | uint16_t offset; |
| 258 | } __attribute__((packed)); |
| 259 | |
| 260 | |
| 261 | /* the l1_info_ul header is in front */ |
| 262 | struct l1ctl_ext_rach_req { |
| 263 | uint16_t ra11; |
| 264 | uint8_t synch_seq; |
| 265 | uint8_t combined; |
| 266 | uint16_t offset; |
| 267 | } __attribute__((packed)); |
| 268 | |
| 269 | /* the l1_info_ul header is in front */ |
| 270 | struct l1ctl_par_req { |
| 271 | int8_t ta; |
| 272 | uint8_t tx_power; |
| 273 | uint8_t padding[2]; |
| 274 | } __attribute__((packed)); |
| 275 | |
| 276 | struct l1ctl_h0 { |
| 277 | uint16_t band_arfcn; |
| 278 | } __attribute__((packed)); |
| 279 | |
| 280 | struct l1ctl_h1 { |
| 281 | uint8_t hsn; |
| 282 | uint8_t maio; |
| 283 | uint8_t n; |
| 284 | uint8_t _padding[1]; |
| 285 | uint16_t ma[64]; |
| 286 | } __attribute__((packed)); |
| 287 | |
| 288 | struct l1ctl_dm_est_req { |
| 289 | uint8_t tsc; |
| 290 | uint8_t h; |
| 291 | union { |
| 292 | struct l1ctl_h0 h0; |
| 293 | struct l1ctl_h1 h1; |
| 294 | }; |
| 295 | uint8_t tch_mode; |
| 296 | uint8_t audio_mode; |
| 297 | } __attribute__((packed)); |
| 298 | |
| 299 | struct l1ctl_dm_freq_req { |
| 300 | uint16_t fn; |
| 301 | uint8_t tsc; |
| 302 | uint8_t h; |
| 303 | union { |
| 304 | struct l1ctl_h0 h0; |
| 305 | struct l1ctl_h1 h1; |
| 306 | }; |
| 307 | } __attribute__((packed)); |
| 308 | |
| 309 | struct l1ctl_crypto_req { |
| 310 | uint8_t algo; |
| 311 | uint8_t key_len; |
| 312 | uint8_t key[0]; |
| 313 | } __attribute__((packed)); |
| 314 | |
| 315 | struct l1ctl_pm_req { |
| 316 | uint8_t type; |
| 317 | uint8_t padding[3]; |
| 318 | |
| 319 | union { |
| 320 | struct { |
| 321 | uint16_t band_arfcn_from; |
| 322 | uint16_t band_arfcn_to; |
| 323 | } range; |
| 324 | }; |
| 325 | } __attribute__((packed)); |
| 326 | |
| 327 | #define BI_FLG_DUMMY (1 << 4) |
| 328 | #define BI_FLG_SACCH (1 << 5) |
| 329 | |
| 330 | struct l1ctl_burst_ind { |
| 331 | uint32_t frame_nr; |
| 332 | uint16_t band_arfcn; /* ARFCN + band + ul indicator */ |
| 333 | uint8_t chan_nr; /* GSM 08.58 channel number (9.3.1) */ |
| 334 | uint8_t flags; /* BI_FLG_xxx + burst_id = 2LSBs */ |
| 335 | uint8_t rx_level; /* 0 .. 63 in typical GSM notation (dBm+110) */ |
| 336 | uint8_t snr; /* Reported SNR >> 8 (0-255) */ |
| 337 | uint8_t bits[15]; /* 114 bits + 2 steal bits. Filled MSB first */ |
| 338 | } __attribute__((packed)); |
| 339 | |
| 340 | /* a single L1CTL_PM response */ |
| 341 | struct l1ctl_pm_conf { |
| 342 | uint16_t band_arfcn; |
| 343 | uint8_t pm[2]; |
| 344 | } __attribute__((packed)); |
| 345 | |
| 346 | enum l1ctl_reset_type { |
| 347 | L1CTL_RES_T_BOOT, /* only _IND */ |
| 348 | L1CTL_RES_T_FULL, |
| 349 | L1CTL_RES_T_SCHED, |
| 350 | }; |
| 351 | |
| 352 | /* argument to L1CTL_RESET_REQ and L1CTL_RESET_IND */ |
| 353 | struct l1ctl_reset { |
| 354 | uint8_t type; |
| 355 | uint8_t pad[3]; |
| 356 | } __attribute__((packed)); |
| 357 | |
| 358 | struct l1ctl_neigh_pm_req { |
| 359 | uint8_t n; |
| 360 | uint8_t padding[1]; |
| 361 | uint16_t band_arfcn[64]; |
| 362 | uint8_t tn[64]; |
| 363 | } __attribute__((packed)); |
| 364 | |
| 365 | /* neighbour cell measurement results */ |
| 366 | struct l1ctl_neigh_pm_ind { |
| 367 | uint16_t band_arfcn; |
| 368 | uint8_t pm[2]; |
| 369 | uint8_t tn; |
| 370 | uint8_t padding; |
| 371 | } __attribute__((packed)); |
| 372 | |
| 373 | /* traffic data to network */ |
| 374 | struct l1ctl_traffic_req { |
| 375 | uint8_t data[0]; |
| 376 | } __attribute__((packed)); |
| 377 | |
| 378 | struct l1ctl_tbf_cfg_req { |
| 379 | /* future support for multiple concurrent TBFs. 0 for now */ |
| 380 | uint8_t tbf_nr; |
| 381 | /* is this about an UL TBF (1) or DL (0) */ |
| 382 | uint8_t is_uplink; |
| 383 | uint8_t padding[2]; |
| 384 | |
| 385 | /* one USF for each TN, or 255 for invalid/unused */ |
| 386 | uint8_t usf[8]; |
| 387 | } __attribute__((packed)); |
| 388 | |
| 389 | #endif /* __L1CTL_PROTO_H__ */ |