blob: ed63fe00417424c558393ac3a635cac839476e85 [file] [log] [blame]
Neels Hofmeyr17518fe2017-06-20 04:35:06 +02001/*! \file gsm_04_60.h
2 * General Packet Radio Service (GPRS).
Tom Tsou9394dbd2016-07-07 17:06:12 -07003 * Radio Link Control / Medium Access Control (RLC/MAC) protocol
4 * 3GPP TS 04.60 version 8.27.0 Release 1999
5 */
6
Neels Hofmeyr17518fe2017-06-20 04:35:06 +02007#pragma once
8
Tom Tsou9394dbd2016-07-07 17:06:12 -07009#include <stdint.h>
Neels Hofmeyrb2600392018-11-16 00:20:39 +010010#include <osmocom/core/endian.h>
Tom Tsou9394dbd2016-07-07 17:06:12 -070011
Tom Tsou9394dbd2016-07-07 17:06:12 -070012/* TS 04.60 10.3a.4.1.1 */
13struct gprs_rlc_ul_header_egprs_1 {
Neels Hofmeyrb2600392018-11-16 00:20:39 +010014#if OSMO_IS_LITTLE_ENDIAN
Tom Tsou9394dbd2016-07-07 17:06:12 -070015 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 Hofmeyrb2600392018-11-16 00:20:39 +010030#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 Tsou9394dbd2016-07-07 17:06:12 -070039} __attribute__ ((packed));
40
41/* TS 04.60 10.3a.4.2.1 */
42struct gprs_rlc_ul_header_egprs_2 {
Neels Hofmeyrb2600392018-11-16 00:20:39 +010043#if OSMO_IS_LITTLE_ENDIAN
Tom Tsou9394dbd2016-07-07 17:06:12 -070044 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 Hofmeyrb2600392018-11-16 00:20:39 +010058#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 Tsou9394dbd2016-07-07 17:06:12 -070066} __attribute__ ((packed));
67
68/* TS 04.60 10.3a.4.3.1 */
69struct gprs_rlc_ul_header_egprs_3 {
Neels Hofmeyrb2600392018-11-16 00:20:39 +010070#if OSMO_IS_LITTLE_ENDIAN
Tom Tsou9394dbd2016-07-07 17:06:12 -070071 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 Hofmeyrb2600392018-11-16 00:20:39 +010085#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 Tsou9394dbd2016-07-07 17:06:12 -070092} __attribute__ ((packed));
93
94struct gprs_rlc_dl_header_egprs_1 {
Neels Hofmeyrb2600392018-11-16 00:20:39 +010095#if OSMO_IS_LITTLE_ENDIAN
Tom Tsou9394dbd2016-07-07 17:06:12 -070096 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 Hofmeyrb2600392018-11-16 00:20:39 +0100108#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 Tsou9394dbd2016-07-07 17:06:12 -0700116} __attribute__ ((packed));
117
118struct gprs_rlc_dl_header_egprs_2 {
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100119#if OSMO_IS_LITTLE_ENDIAN
Tom Tsou9394dbd2016-07-07 17:06:12 -0700120 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 Hofmeyrb2600392018-11-16 00:20:39 +0100131#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 Tsou9394dbd2016-07-07 17:06:12 -0700138} __attribute__ ((packed));
139
140struct gprs_rlc_dl_header_egprs_3 {
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100141#if OSMO_IS_LITTLE_ENDIAN
Tom Tsou9394dbd2016-07-07 17:06:12 -0700142 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 Hofmeyrb2600392018-11-16 00:20:39 +0100154#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 Tsou9394dbd2016-07-07 17:06:12 -0700161} __attribute__ ((packed));
Stefan Sperlingbd6e7a92018-07-27 15:17:09 +0200162
163/* TS 03.60 Chapter 6.3.3.1: Network Mode of Operation */
164enum 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
Pau Espin Pedrol946bb952020-12-14 17:04:54 +0100170/* TS 44.060 12.24 */
Stefan Sperlingbd6e7a92018-07-27 15:17:09 +0200171struct 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;
Pau Espin Pedrol946bb952020-12-14 17:04:54 +0100190 bool ccn_active;
Stefan Sperlingbd6e7a92018-07-27 15:17:09 +0200191 } ext_info;
192};
193
194/* TS 04.60 Table 12.9.2 */
195struct osmo_gprs_power_ctrl_pars {
196 uint8_t alpha;
197 uint8_t t_avg_w;
198 uint8_t t_avg_t;
199 uint8_t pc_meas_chan;
200 uint8_t n_avg_i;
201};