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 | |
Tom Tsou | 9394dbd | 2016-07-07 17:06:12 -0700 | [diff] [blame] | 12 | /* TS 04.60 10.3a.4.1.1 */ |
| 13 | struct gprs_rlc_ul_header_egprs_1 { |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 14 | #if OSMO_IS_LITTLE_ENDIAN |
Tom Tsou | 9394dbd | 2016-07-07 17:06:12 -0700 | [diff] [blame] | 15 | uint8_t r:1, |
| 16 | si:1, |
| 17 | cv:4, |
| 18 | tfi_hi:2; |
| 19 | uint8_t tfi_lo:3, |
| 20 | bsn1_hi:5; |
| 21 | uint8_t bsn1_lo:6, |
| 22 | bsn2_hi:2; |
| 23 | uint8_t bsn2_lo:8; |
| 24 | uint8_t cps:5, |
| 25 | rsb:1, |
| 26 | pi:1, |
| 27 | spare_hi:1; |
| 28 | uint8_t spare_lo:6, |
| 29 | dummy:2; |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 30 | #elif OSMO_IS_BIG_ENDIAN |
| 31 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ |
| 32 | uint8_t tfi_hi:2, cv:4, si:1, r:1; |
| 33 | uint8_t bsn1_hi:5, tfi_lo:3; |
| 34 | uint8_t bsn2_hi:2, bsn1_lo:6; |
| 35 | uint8_t bsn2_lo:8; |
| 36 | uint8_t spare_hi:1, pi:1, rsb:1, cps:5; |
| 37 | uint8_t dummy:2, spare_lo:6; |
| 38 | #endif |
Tom Tsou | 9394dbd | 2016-07-07 17:06:12 -0700 | [diff] [blame] | 39 | } __attribute__ ((packed)); |
| 40 | |
| 41 | /* TS 04.60 10.3a.4.2.1 */ |
| 42 | struct gprs_rlc_ul_header_egprs_2 { |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 43 | #if OSMO_IS_LITTLE_ENDIAN |
Tom Tsou | 9394dbd | 2016-07-07 17:06:12 -0700 | [diff] [blame] | 44 | uint8_t r:1, |
| 45 | si:1, |
| 46 | cv:4, |
| 47 | tfi_hi:2; |
| 48 | uint8_t tfi_lo:3, |
| 49 | bsn1_hi:5; |
| 50 | uint8_t bsn1_lo:6, |
| 51 | cps_hi:2; |
| 52 | uint8_t cps_lo:1, |
| 53 | rsb:1, |
| 54 | pi:1, |
| 55 | spare_hi:5; |
| 56 | uint8_t spare_lo:5, |
| 57 | dummy:3; |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 58 | #elif OSMO_IS_BIG_ENDIAN |
| 59 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ |
| 60 | uint8_t tfi_hi:2, cv:4, si:1, r:1; |
| 61 | uint8_t bsn1_hi:5, tfi_lo:3; |
| 62 | uint8_t cps_hi:2, bsn1_lo:6; |
| 63 | uint8_t spare_hi:5, pi:1, rsb:1, cps_lo:1; |
| 64 | uint8_t dummy:3, spare_lo:5; |
| 65 | #endif |
Tom Tsou | 9394dbd | 2016-07-07 17:06:12 -0700 | [diff] [blame] | 66 | } __attribute__ ((packed)); |
| 67 | |
| 68 | /* TS 04.60 10.3a.4.3.1 */ |
| 69 | struct gprs_rlc_ul_header_egprs_3 { |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 70 | #if OSMO_IS_LITTLE_ENDIAN |
Tom Tsou | 9394dbd | 2016-07-07 17:06:12 -0700 | [diff] [blame] | 71 | uint8_t r:1, |
| 72 | si:1, |
| 73 | cv:4, |
| 74 | tfi_hi:2; |
| 75 | uint8_t tfi_lo:3, |
| 76 | bsn1_hi:5; |
| 77 | uint8_t bsn1_lo:6, |
| 78 | cps_hi:2; |
| 79 | uint8_t cps_lo:2, |
| 80 | spb:2, |
| 81 | rsb:1, |
| 82 | pi:1, |
| 83 | spare:1, |
| 84 | dummy:1; |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 85 | #elif OSMO_IS_BIG_ENDIAN |
| 86 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ |
| 87 | uint8_t tfi_hi:2, cv:4, si:1, r:1; |
| 88 | uint8_t bsn1_hi:5, tfi_lo:3; |
| 89 | uint8_t cps_hi:2, bsn1_lo:6; |
| 90 | uint8_t dummy:1, spare:1, pi:1, rsb:1, spb:2, cps_lo:2; |
| 91 | #endif |
Tom Tsou | 9394dbd | 2016-07-07 17:06:12 -0700 | [diff] [blame] | 92 | } __attribute__ ((packed)); |
| 93 | |
| 94 | struct gprs_rlc_dl_header_egprs_1 { |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 95 | #if OSMO_IS_LITTLE_ENDIAN |
Tom Tsou | 9394dbd | 2016-07-07 17:06:12 -0700 | [diff] [blame] | 96 | uint8_t usf:3, |
| 97 | es_p:2, |
| 98 | rrbp:2, |
| 99 | tfi_hi:1; |
| 100 | uint8_t tfi_lo:4, |
| 101 | pr:2, |
| 102 | bsn1_hi:2; |
| 103 | uint8_t bsn1_mid:8; |
| 104 | uint8_t bsn1_lo:1, |
| 105 | bsn2_hi:7; |
| 106 | uint8_t bsn2_lo:3, |
| 107 | cps:5; |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 108 | #elif OSMO_IS_BIG_ENDIAN |
| 109 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ |
| 110 | uint8_t tfi_hi:1, rrbp:2, es_p:2, usf:3; |
| 111 | uint8_t bsn1_hi:2, pr:2, tfi_lo:4; |
| 112 | uint8_t bsn1_mid:8; |
| 113 | uint8_t bsn2_hi:7, bsn1_lo:1; |
| 114 | uint8_t cps:5, bsn2_lo:3; |
| 115 | #endif |
Tom Tsou | 9394dbd | 2016-07-07 17:06:12 -0700 | [diff] [blame] | 116 | } __attribute__ ((packed)); |
| 117 | |
| 118 | struct gprs_rlc_dl_header_egprs_2 { |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 119 | #if OSMO_IS_LITTLE_ENDIAN |
Tom Tsou | 9394dbd | 2016-07-07 17:06:12 -0700 | [diff] [blame] | 120 | uint8_t usf:3, |
| 121 | es_p:2, |
| 122 | rrbp:2, |
| 123 | tfi_hi:1; |
| 124 | uint8_t tfi_lo:4, |
| 125 | pr:2, |
| 126 | bsn1_hi:2; |
| 127 | uint8_t bsn1_mid:8; |
| 128 | uint8_t bsn1_lo:1, |
| 129 | cps:3, |
| 130 | dummy:4; |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 131 | #elif OSMO_IS_BIG_ENDIAN |
| 132 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ |
| 133 | uint8_t tfi_hi:1, rrbp:2, es_p:2, usf:3; |
| 134 | uint8_t bsn1_hi:2, pr:2, tfi_lo:4; |
| 135 | uint8_t bsn1_mid:8; |
| 136 | uint8_t dummy:4, cps:3, bsn1_lo:1; |
| 137 | #endif |
Tom Tsou | 9394dbd | 2016-07-07 17:06:12 -0700 | [diff] [blame] | 138 | } __attribute__ ((packed)); |
| 139 | |
| 140 | struct gprs_rlc_dl_header_egprs_3 { |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 141 | #if OSMO_IS_LITTLE_ENDIAN |
Tom Tsou | 9394dbd | 2016-07-07 17:06:12 -0700 | [diff] [blame] | 142 | uint8_t usf:3, |
| 143 | es_p:2, |
| 144 | rrbp:2, |
| 145 | tfi_hi:1; |
| 146 | uint8_t tfi_lo:4, |
| 147 | pr:2, |
| 148 | bsn1_hi:2; |
| 149 | uint8_t bsn1_mid:8; |
| 150 | uint8_t bsn1_lo:1, |
| 151 | cps:4, |
| 152 | spb:2, |
| 153 | dummy:1; |
Neels Hofmeyr | b260039 | 2018-11-16 00:20:39 +0100 | [diff] [blame] | 154 | #elif OSMO_IS_BIG_ENDIAN |
| 155 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ |
| 156 | uint8_t tfi_hi:1, rrbp:2, es_p:2, usf:3; |
| 157 | uint8_t bsn1_hi:2, pr:2, tfi_lo:4; |
| 158 | uint8_t bsn1_mid:8; |
| 159 | uint8_t dummy:1, spb:2, cps:4, bsn1_lo:1; |
| 160 | #endif |
Tom Tsou | 9394dbd | 2016-07-07 17:06:12 -0700 | [diff] [blame] | 161 | } __attribute__ ((packed)); |
Stefan Sperling | bd6e7a9 | 2018-07-27 15:17:09 +0200 | [diff] [blame] | 162 | |
| 163 | /* TS 03.60 Chapter 6.3.3.1: Network Mode of Operation */ |
| 164 | enum osmo_gprs_nmo { |
| 165 | GPRS_NMO_I = 0, /* CS pagin on GPRS paging or traffic channel */ |
| 166 | GPRS_NMO_II = 1, /* all paging on CCCH */ |
| 167 | GPRS_NMO_III = 2, /* no paging coordination */ |
| 168 | }; |
| 169 | |
| 170 | /* TS 04.60 12.24 */ |
| 171 | struct osmo_gprs_cell_options { |
| 172 | enum osmo_gprs_nmo nmo; |
| 173 | /* T3168: wait for packet uplink assignment message */ |
| 174 | uint32_t t3168; /* in milliseconds */ |
| 175 | /* T3192: wait for release of the TBF after reception of the final block */ |
| 176 | uint32_t t3192; /* in milliseconds */ |
| 177 | uint32_t drx_timer_max;/* in seconds */ |
| 178 | uint32_t bs_cv_max; |
| 179 | uint8_t supports_egprs_11bit_rach; |
| 180 | bool ctrl_ack_type_use_block; /* use PACKET CONTROL ACKNOWLEDGMENT */ |
| 181 | |
| 182 | uint8_t ext_info_present; |
| 183 | struct { |
| 184 | uint8_t egprs_supported; |
| 185 | uint8_t use_egprs_p_ch_req; |
| 186 | uint8_t bep_period; |
| 187 | uint8_t pfc_supported; |
| 188 | uint8_t dtm_supported; |
| 189 | uint8_t bss_paging_coordination; |
| 190 | } ext_info; |
| 191 | }; |
| 192 | |
| 193 | /* TS 04.60 Table 12.9.2 */ |
| 194 | struct osmo_gprs_power_ctrl_pars { |
| 195 | uint8_t alpha; |
| 196 | uint8_t t_avg_w; |
| 197 | uint8_t t_avg_t; |
| 198 | uint8_t pc_meas_chan; |
| 199 | uint8_t n_avg_i; |
| 200 | }; |