Neels Hofmeyr | 17518fe | 2017-06-20 04:35:06 +0200 | [diff] [blame] | 1 | /*! \file gsm_04_60.h |
| 2 | * General Packet Radio Service (GPRS). |
Tom Tsou | 9394dbd | 2016-07-07 17:06:12 -0700 | [diff] [blame] | 3 | * Radio Link Control / Medium Access Control (RLC/MAC) protocol |
| 4 | * 3GPP TS 04.60 version 8.27.0 Release 1999 |
| 5 | */ |
| 6 | |
Neels Hofmeyr | 17518fe | 2017-06-20 04:35:06 +0200 | [diff] [blame] | 7 | #pragma once |
| 8 | |
Tom Tsou | 9394dbd | 2016-07-07 17:06:12 -0700 | [diff] [blame] | 9 | #include <stdint.h> |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 10 | #include <osmocom/core/endian.h> |
Tom Tsou | 9394dbd | 2016-07-07 17:06:12 -0700 | [diff] [blame] | 11 | |
| 12 | #if OSMO_IS_LITTLE_ENDIAN == 1 |
| 13 | /* TS 04.60 10.3a.4.1.1 */ |
| 14 | struct gprs_rlc_ul_header_egprs_1 { |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 15 | #if OSMO_IS_LITTLE_ENDIAN |
Tom Tsou | 9394dbd | 2016-07-07 17:06:12 -0700 | [diff] [blame] | 16 | uint8_t r:1, |
| 17 | si:1, |
| 18 | cv:4, |
| 19 | tfi_hi:2; |
| 20 | uint8_t tfi_lo:3, |
| 21 | bsn1_hi:5; |
| 22 | uint8_t bsn1_lo:6, |
| 23 | bsn2_hi:2; |
| 24 | uint8_t bsn2_lo:8; |
| 25 | uint8_t cps:5, |
| 26 | rsb:1, |
| 27 | pi:1, |
| 28 | spare_hi:1; |
| 29 | uint8_t spare_lo:6, |
| 30 | dummy:2; |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 31 | #elif OSMO_IS_BIG_ENDIAN |
| 32 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ |
| 33 | uint8_t tfi_hi:2, cv:4, si:1, r:1; |
| 34 | uint8_t bsn1_hi:5, tfi_lo:3; |
| 35 | uint8_t bsn2_hi:2, bsn1_lo:6; |
| 36 | uint8_t bsn2_lo:8; |
| 37 | uint8_t spare_hi:1, pi:1, rsb:1, cps:5; |
| 38 | uint8_t dummy:2, spare_lo:6; |
| 39 | #endif |
Tom Tsou | 9394dbd | 2016-07-07 17:06:12 -0700 | [diff] [blame] | 40 | } __attribute__ ((packed)); |
| 41 | |
| 42 | /* TS 04.60 10.3a.4.2.1 */ |
| 43 | struct gprs_rlc_ul_header_egprs_2 { |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 44 | #if OSMO_IS_LITTLE_ENDIAN |
Tom Tsou | 9394dbd | 2016-07-07 17:06:12 -0700 | [diff] [blame] | 45 | uint8_t r:1, |
| 46 | si:1, |
| 47 | cv:4, |
| 48 | tfi_hi:2; |
| 49 | uint8_t tfi_lo:3, |
| 50 | bsn1_hi:5; |
| 51 | uint8_t bsn1_lo:6, |
| 52 | cps_hi:2; |
| 53 | uint8_t cps_lo:1, |
| 54 | rsb:1, |
| 55 | pi:1, |
| 56 | spare_hi:5; |
| 57 | uint8_t spare_lo:5, |
| 58 | dummy:3; |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 59 | #elif OSMO_IS_BIG_ENDIAN |
| 60 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ |
| 61 | uint8_t tfi_hi:2, cv:4, si:1, r:1; |
| 62 | uint8_t bsn1_hi:5, tfi_lo:3; |
| 63 | uint8_t cps_hi:2, bsn1_lo:6; |
| 64 | uint8_t spare_hi:5, pi:1, rsb:1, cps_lo:1; |
| 65 | uint8_t dummy:3, spare_lo:5; |
| 66 | #endif |
Tom Tsou | 9394dbd | 2016-07-07 17:06:12 -0700 | [diff] [blame] | 67 | } __attribute__ ((packed)); |
| 68 | |
| 69 | /* TS 04.60 10.3a.4.3.1 */ |
| 70 | struct gprs_rlc_ul_header_egprs_3 { |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 71 | #if OSMO_IS_LITTLE_ENDIAN |
Tom Tsou | 9394dbd | 2016-07-07 17:06:12 -0700 | [diff] [blame] | 72 | uint8_t r:1, |
| 73 | si:1, |
| 74 | cv:4, |
| 75 | tfi_hi:2; |
| 76 | uint8_t tfi_lo:3, |
| 77 | bsn1_hi:5; |
| 78 | uint8_t bsn1_lo:6, |
| 79 | cps_hi:2; |
| 80 | uint8_t cps_lo:2, |
| 81 | spb:2, |
| 82 | rsb:1, |
| 83 | pi:1, |
| 84 | spare:1, |
| 85 | dummy:1; |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 86 | #elif OSMO_IS_BIG_ENDIAN |
| 87 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ |
| 88 | uint8_t tfi_hi:2, cv:4, si:1, r:1; |
| 89 | uint8_t bsn1_hi:5, tfi_lo:3; |
| 90 | uint8_t cps_hi:2, bsn1_lo:6; |
| 91 | uint8_t dummy:1, spare:1, pi:1, rsb:1, spb:2, cps_lo:2; |
| 92 | #endif |
Tom Tsou | 9394dbd | 2016-07-07 17:06:12 -0700 | [diff] [blame] | 93 | } __attribute__ ((packed)); |
| 94 | |
| 95 | struct gprs_rlc_dl_header_egprs_1 { |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 96 | #if OSMO_IS_LITTLE_ENDIAN |
Tom Tsou | 9394dbd | 2016-07-07 17:06:12 -0700 | [diff] [blame] | 97 | uint8_t usf:3, |
| 98 | es_p:2, |
| 99 | rrbp:2, |
| 100 | tfi_hi:1; |
| 101 | uint8_t tfi_lo:4, |
| 102 | pr:2, |
| 103 | bsn1_hi:2; |
| 104 | uint8_t bsn1_mid:8; |
| 105 | uint8_t bsn1_lo:1, |
| 106 | bsn2_hi:7; |
| 107 | uint8_t bsn2_lo:3, |
| 108 | cps:5; |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 109 | #elif OSMO_IS_BIG_ENDIAN |
| 110 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ |
| 111 | uint8_t tfi_hi:1, rrbp:2, es_p:2, usf:3; |
| 112 | uint8_t bsn1_hi:2, pr:2, tfi_lo:4; |
| 113 | uint8_t bsn1_mid:8; |
| 114 | uint8_t bsn2_hi:7, bsn1_lo:1; |
| 115 | uint8_t cps:5, bsn2_lo:3; |
| 116 | #endif |
Tom Tsou | 9394dbd | 2016-07-07 17:06:12 -0700 | [diff] [blame] | 117 | } __attribute__ ((packed)); |
| 118 | |
| 119 | struct gprs_rlc_dl_header_egprs_2 { |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 120 | #if OSMO_IS_LITTLE_ENDIAN |
Tom Tsou | 9394dbd | 2016-07-07 17:06:12 -0700 | [diff] [blame] | 121 | uint8_t usf:3, |
| 122 | es_p:2, |
| 123 | rrbp:2, |
| 124 | tfi_hi:1; |
| 125 | uint8_t tfi_lo:4, |
| 126 | pr:2, |
| 127 | bsn1_hi:2; |
| 128 | uint8_t bsn1_mid:8; |
| 129 | uint8_t bsn1_lo:1, |
| 130 | cps:3, |
| 131 | dummy:4; |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 132 | #elif OSMO_IS_BIG_ENDIAN |
| 133 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ |
| 134 | uint8_t tfi_hi:1, rrbp:2, es_p:2, usf:3; |
| 135 | uint8_t bsn1_hi:2, pr:2, tfi_lo:4; |
| 136 | uint8_t bsn1_mid:8; |
| 137 | uint8_t dummy:4, cps:3, bsn1_lo:1; |
| 138 | #endif |
Tom Tsou | 9394dbd | 2016-07-07 17:06:12 -0700 | [diff] [blame] | 139 | } __attribute__ ((packed)); |
| 140 | |
| 141 | struct gprs_rlc_dl_header_egprs_3 { |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 142 | #if OSMO_IS_LITTLE_ENDIAN |
Tom Tsou | 9394dbd | 2016-07-07 17:06:12 -0700 | [diff] [blame] | 143 | uint8_t usf:3, |
| 144 | es_p:2, |
| 145 | rrbp:2, |
| 146 | tfi_hi:1; |
| 147 | uint8_t tfi_lo:4, |
| 148 | pr:2, |
| 149 | bsn1_hi:2; |
| 150 | uint8_t bsn1_mid:8; |
| 151 | uint8_t bsn1_lo:1, |
| 152 | cps:4, |
| 153 | spb:2, |
| 154 | dummy:1; |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 155 | #elif OSMO_IS_BIG_ENDIAN |
| 156 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ |
| 157 | uint8_t tfi_hi:1, rrbp:2, es_p:2, usf:3; |
| 158 | uint8_t bsn1_hi:2, pr:2, tfi_lo:4; |
| 159 | uint8_t bsn1_mid:8; |
| 160 | uint8_t dummy:1, spb:2, cps:4, bsn1_lo:1; |
| 161 | #endif |
Tom Tsou | 9394dbd | 2016-07-07 17:06:12 -0700 | [diff] [blame] | 162 | } __attribute__ ((packed)); |
| 163 | #else |
| 164 | /* TS 04.60 10.3a.4.1.1 */ |
| 165 | struct gprs_rlc_ul_header_egprs_1 { |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 166 | #if OSMO_IS_LITTLE_ENDIAN |
Tom Tsou | 9394dbd | 2016-07-07 17:06:12 -0700 | [diff] [blame] | 167 | uint8_t tfi_hi:2, |
| 168 | cv:4, |
| 169 | si:1, |
| 170 | r:1; |
| 171 | uint8_t bsn1_hi:5, |
| 172 | tfi_lo:3; |
| 173 | uint8_t bsn2_hi:2, |
| 174 | bsn1_lo:6; |
| 175 | uint8_t bsn2_lo:8; |
| 176 | uint8_t spare_hi:1, |
| 177 | pi:1, |
| 178 | rsb:1, |
| 179 | cps:5; |
| 180 | uint8_t dummy:2, |
| 181 | spare_lo:6; |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 182 | #elif OSMO_IS_BIG_ENDIAN |
| 183 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ |
| 184 | uint8_t r:1, si:1, cv:4, tfi_hi:2; |
| 185 | uint8_t tfi_lo:3, bsn1_hi:5; |
| 186 | uint8_t bsn1_lo:6, bsn2_hi:2; |
| 187 | uint8_t bsn2_lo:8; |
| 188 | uint8_t cps:5, rsb:1, pi:1, spare_hi:1; |
| 189 | uint8_t spare_lo:6, dummy:2; |
| 190 | #endif |
Tom Tsou | 9394dbd | 2016-07-07 17:06:12 -0700 | [diff] [blame] | 191 | } __attribute__ ((packed)); |
| 192 | |
| 193 | /* TS 04.60 10.3a.4.2.1 */ |
| 194 | struct gprs_rlc_ul_header_egprs_2 { |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 195 | #if OSMO_IS_LITTLE_ENDIAN |
Tom Tsou | 9394dbd | 2016-07-07 17:06:12 -0700 | [diff] [blame] | 196 | uint8_t tfi_hi:2, |
| 197 | cv:4, |
| 198 | si:1, |
| 199 | r:1; |
| 200 | uint8_t bsn1_hi:5, |
| 201 | tfi_lo:3; |
| 202 | uint8_t cps_hi:2, |
| 203 | bsn1_lo:6; |
| 204 | uint8_t spare_hi:5, |
| 205 | pi:1, |
| 206 | rsb:1, |
| 207 | cps_lo:1; |
| 208 | uint8_t dummy:3, |
| 209 | spare_lo:5; |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 210 | #elif OSMO_IS_BIG_ENDIAN |
| 211 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ |
| 212 | uint8_t r:1, si:1, cv:4, tfi_hi:2; |
| 213 | uint8_t tfi_lo:3, bsn1_hi:5; |
| 214 | uint8_t bsn1_lo:6, cps_hi:2; |
| 215 | uint8_t cps_lo:1, rsb:1, pi:1, spare_hi:5; |
| 216 | uint8_t spare_lo:5, dummy:3; |
| 217 | #endif |
Tom Tsou | 9394dbd | 2016-07-07 17:06:12 -0700 | [diff] [blame] | 218 | } __attribute__ ((packed)); |
| 219 | |
| 220 | /* TS 04.60 10.3a.4.3.1 */ |
| 221 | struct gprs_rlc_ul_header_egprs_3 { |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 222 | #if OSMO_IS_LITTLE_ENDIAN |
Tom Tsou | 9394dbd | 2016-07-07 17:06:12 -0700 | [diff] [blame] | 223 | uint8_t tfi_hi:2, |
| 224 | cv:4, |
| 225 | si:1, |
| 226 | r:1; |
| 227 | uint8_t bsn1_hi:5, |
| 228 | tfi_lo:3; |
| 229 | uint8_t cps_hi:2, |
| 230 | bsn1_lo:6; |
| 231 | uint8_t dummy:1, |
| 232 | spare:1, |
| 233 | pi:1, |
| 234 | rsb:1, |
| 235 | spb:2, |
| 236 | cps_lo:2; |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 237 | #elif OSMO_IS_BIG_ENDIAN |
| 238 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ |
| 239 | uint8_t r:1, si:1, cv:4, tfi_hi:2; |
| 240 | uint8_t tfi_lo:3, bsn1_hi:5; |
| 241 | uint8_t bsn1_lo:6, cps_hi:2; |
| 242 | uint8_t cps_lo:2, spb:2, rsb:1, pi:1, spare:1, dummy:1; |
| 243 | #endif |
Tom Tsou | 9394dbd | 2016-07-07 17:06:12 -0700 | [diff] [blame] | 244 | } __attribute__ ((packed)); |
| 245 | |
| 246 | struct gprs_rlc_dl_header_egprs_1 { |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 247 | #if OSMO_IS_LITTLE_ENDIAN |
Tom Tsou | 9394dbd | 2016-07-07 17:06:12 -0700 | [diff] [blame] | 248 | uint8_t tfi_hi:1, |
| 249 | rrbp:2, |
| 250 | es_p:2, |
| 251 | usf:3; |
| 252 | uint8_t bsn1_hi:2, |
| 253 | pr:2, |
| 254 | tfi_lo:4; |
| 255 | uint8_t bsn1_mid:8; |
| 256 | uint8_t bsn2_hi:7, |
| 257 | bsn1_lo:1; |
| 258 | uint8_t cps:5, |
| 259 | bsn2_lo:3; |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 260 | #elif OSMO_IS_BIG_ENDIAN |
| 261 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ |
| 262 | uint8_t usf:3, es_p:2, rrbp:2, tfi_hi:1; |
| 263 | uint8_t tfi_lo:4, pr:2, bsn1_hi:2; |
| 264 | uint8_t bsn1_mid:8; |
| 265 | uint8_t bsn1_lo:1, bsn2_hi:7; |
| 266 | uint8_t bsn2_lo:3, cps:5; |
| 267 | #endif |
Tom Tsou | 9394dbd | 2016-07-07 17:06:12 -0700 | [diff] [blame] | 268 | } __attribute__ ((packed)); |
| 269 | |
| 270 | struct gprs_rlc_dl_header_egprs_2 { |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 271 | #if OSMO_IS_LITTLE_ENDIAN |
Tom Tsou | 9394dbd | 2016-07-07 17:06:12 -0700 | [diff] [blame] | 272 | uint8_t tfi_hi:1, |
| 273 | rrbp:2, |
| 274 | es_p:2, |
| 275 | usf:3; |
| 276 | uint8_t bsn1_hi:2, |
| 277 | pr:2, |
| 278 | tfi_lo:4; |
| 279 | uint8_t bsn1_mid:8; |
| 280 | uint8_t dummy:4, |
| 281 | cps:3, |
| 282 | bsn1_lo:1; |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 283 | #elif OSMO_IS_BIG_ENDIAN |
| 284 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ |
| 285 | uint8_t usf:3, es_p:2, rrbp:2, tfi_hi:1; |
| 286 | uint8_t tfi_lo:4, pr:2, bsn1_hi:2; |
| 287 | uint8_t bsn1_mid:8; |
| 288 | uint8_t bsn1_lo:1, cps:3, dummy:4; |
| 289 | #endif |
Tom Tsou | 9394dbd | 2016-07-07 17:06:12 -0700 | [diff] [blame] | 290 | } __attribute__ ((packed)); |
| 291 | |
| 292 | struct gprs_rlc_dl_header_egprs_3 { |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 293 | #if OSMO_IS_LITTLE_ENDIAN |
Tom Tsou | 9394dbd | 2016-07-07 17:06:12 -0700 | [diff] [blame] | 294 | uint8_t tfi_hi:1, |
| 295 | rrbp:2, |
| 296 | es_p:2, |
| 297 | usf:3; |
| 298 | uint8_t bsn1_hi:2, |
| 299 | pr:2, |
| 300 | tfi_lo:4; |
| 301 | uint8_t bsn1_mid:8; |
| 302 | uint8_t dummy:1, |
| 303 | spb:2, |
| 304 | cps:4, |
| 305 | bsn1_lo:1; |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 306 | #elif OSMO_IS_BIG_ENDIAN |
| 307 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ |
| 308 | uint8_t usf:3, es_p:2, rrbp:2, tfi_hi:1; |
| 309 | uint8_t tfi_lo:4, pr:2, bsn1_hi:2; |
| 310 | uint8_t bsn1_mid:8; |
| 311 | uint8_t bsn1_lo:1, cps:4, spb:2, dummy:1; |
| 312 | #endif |
Tom Tsou | 9394dbd | 2016-07-07 17:06:12 -0700 | [diff] [blame] | 313 | } __attribute__ ((packed)); |
| 314 | #endif |
Stefan Sperling | bd6e7a9 | 2018-07-27 15:17:09 +0200 | [diff] [blame] | 315 | |
| 316 | /* TS 03.60 Chapter 6.3.3.1: Network Mode of Operation */ |
| 317 | enum osmo_gprs_nmo { |
| 318 | GPRS_NMO_I = 0, /* CS pagin on GPRS paging or traffic channel */ |
| 319 | GPRS_NMO_II = 1, /* all paging on CCCH */ |
| 320 | GPRS_NMO_III = 2, /* no paging coordination */ |
| 321 | }; |
| 322 | |
| 323 | /* TS 04.60 12.24 */ |
| 324 | struct osmo_gprs_cell_options { |
| 325 | enum osmo_gprs_nmo nmo; |
| 326 | /* T3168: wait for packet uplink assignment message */ |
| 327 | uint32_t t3168; /* in milliseconds */ |
| 328 | /* T3192: wait for release of the TBF after reception of the final block */ |
| 329 | uint32_t t3192; /* in milliseconds */ |
| 330 | uint32_t drx_timer_max;/* in seconds */ |
| 331 | uint32_t bs_cv_max; |
| 332 | uint8_t supports_egprs_11bit_rach; |
| 333 | bool ctrl_ack_type_use_block; /* use PACKET CONTROL ACKNOWLEDGMENT */ |
| 334 | |
| 335 | uint8_t ext_info_present; |
| 336 | struct { |
| 337 | uint8_t egprs_supported; |
| 338 | uint8_t use_egprs_p_ch_req; |
| 339 | uint8_t bep_period; |
| 340 | uint8_t pfc_supported; |
| 341 | uint8_t dtm_supported; |
| 342 | uint8_t bss_paging_coordination; |
| 343 | } ext_info; |
| 344 | }; |
| 345 | |
| 346 | /* TS 04.60 Table 12.9.2 */ |
| 347 | struct osmo_gprs_power_ctrl_pars { |
| 348 | uint8_t alpha; |
| 349 | uint8_t t_avg_w; |
| 350 | uint8_t t_avg_t; |
| 351 | uint8_t pc_meas_chan; |
| 352 | uint8_t n_avg_i; |
| 353 | }; |