blob: a03dd860f1a4046b7a276ecb925907a386e5bc1d [file] [log] [blame]
Harald Welte484160b2017-07-28 13:30:24 +02001/* TITAN REW encode/decode definitions for 3GPP TS 44.060 RLC/MAC Blocks */
2module RLCMAC_Types {
3 import from General_Types all;
4 import from Osmocom_Types all;
5 import from GSM_Types all;
Harald Welte9d348522017-08-01 00:27:39 +02006 import from RLCMAC_CSN1_Types all;
Harald Welte484160b2017-07-28 13:30:24 +02007
8 /* TS 44.060 10.4.7 */
9 type enumerated MacPayloadType {
10 MAC_PT_RLC_DATA ('00'B),
11 MAC_PT_RLCMAC_NO_OPT ('01'B),
12 MAC_PT_RLCMAC_OPT ('10'B),
13 MAC_PT_RESERVED ('11'B)
14 } with { variant "FIELDLENGTH(2)" };
15
16 /* TS 44.060 10.4.5 */
17 type enumerated MacRrbp {
18 RRBP_Nplus13_mod_2715648 ('00'B),
19 RRBP_Nplus17_or_18_mod_2715648 ('01'B),
20 RRBP_Nplus22_or_22_mod_2715648 ('10'B),
21 RRBP_Nplus26_mod_2715648 ('11'B)
22 } with { variant "FIELDLENGTH(2)" };
23
24 /* Partof DL RLC data block and DL RLC/MAC ctrl block */
25 type record DlMacHeader {
26 MacPayloadType payload_type,
27 MacRrbp rrbp,
28 boolean rrbp_valid,
29 uint3_t usf
30 } with {
31 variant (rrbp_valid) "FIELDLENGTH(1)"
32 };
33
34 /* TS 44.060 10.4.10a */
35 type enumerated PowerReduction {
36 PWR_RED_0_to_3dB ('00'B),
37 PWR_RED_3_to_7dB ('01'B),
38 PWR_RED_7_to_10dB ('10'B),
39 PWR_RED_RESERVED ('11'B)
40 } with { variant "FIELDLENGTH(2)" };
41
42 /* TS 44.060 10.4.9d */
43 type enumerated DirectionBit {
44 DIR_UPLINK_TBF ('0'B),
45 DIR_DOWNLINK_TBF ('1'B)
46 } with { variant "FIELDLENGTH(1)" };
47
48 type record TfiOctet {
49 /* PR, TFI, D */
50 PowerReduction pr,
51 uint5_t tfi,
52 DirectionBit d
53 } with { variant "" };
54
55 type record RbsnExtOctet {
56 uint3_t rbsn_e,
57 BIT1 fs_e,
58 BIT4 spare
59 } with { variant "" };
60
61 type record DlCtrlOptOctets {
62 /* RBSN, RTI, FS, AC (optional, depending on mac_hdr.payload_type) */
63 BIT1 rbsn,
64 uint5_t rti,
65 boolean fs,
66 boolean tfi_octet_present,
67 TfiOctet tfi optional,
68 RbsnExtOctet rbsn_ext optional
69 } with {
70 variant (fs) "FIELDLENGTH(1)"
71 variant (tfi_octet_present) "FIELDLENGTH(1)"
72 variant (tfi) "PRESENCE(tfi_octet_present = true)"
73 variant (rbsn_ext) "PRESENCE(rbsn='1'B, fs=false)"
74 };
75
76 /* TS 44.060 10.3.1 Downlink RLC/MAC control block */
77 type record RlcmacDlCtrlBlock {
78 DlMacHeader mac_hdr,
79 DlCtrlOptOctets opt optional,
Harald Welte9d348522017-08-01 00:27:39 +020080 RlcmacDlCtrlMsg payload
Harald Welte484160b2017-07-28 13:30:24 +020081 } with {
82 variant (opt) "PRESENCE(mac_hdr.payload_type = MAC_PT_RLCMAC_OPT)"
83 };
84
85 external function enc_RlcmacDlCtrlBlock(in RlcmacDlCtrlBlock si) return octetstring
86 with { extension "prototype(convert) encode(RAW)" };
87 external function dec_RlcmacDlCtrlBlock(in octetstring stream) return RlcmacDlCtrlBlock
88 with { extension "prototype(convert) decode(RAW)" };
89
90 type record UlMacCtrlHeader {
Harald Welteefbc2fc2017-07-31 00:05:23 +020091 MacPayloadType payload_type,
Harald Welte484160b2017-07-28 13:30:24 +020092 BIT5 spare,
93 boolean retry
94 } with { variant (retry) "FIELDLENGTH(1)" };
95
96 /* TS 44.060 10.3.2 UplinkRLC/MAC control block */
97 type record RlcmacUlCtrlBlock {
98 UlMacCtrlHeader mac_hdr,
Harald Welte9d348522017-08-01 00:27:39 +020099 RlcmacUlCtrlMsg payload
Harald Welte484160b2017-07-28 13:30:24 +0200100 } with { variant "" };
101
102 external function enc_RlcmacUlCtrlBlock(in RlcmacUlCtrlBlock si) return octetstring
103 with { extension "prototype(convert) encode(RAW)" };
104 external function dec_RlcmacUlCtrlBlock(in octetstring stream) return RlcmacUlCtrlBlock
105 with { extension "prototype(convert) decode(RAW)" };
106
107 /* a single RLC block / LLC-segment */
Harald Welte43e060a2017-07-30 22:38:03 +0200108 type record LlcBlockHdr {
Harald Welte484160b2017-07-28 13:30:24 +0200109 uint6_t length_ind,
110 /* 1 = new LLC PDU starts */
111 BIT1 more,
112 /* 0 = another extension octet after LLC PDU, 1 = no more extension octets */
Harald Welte43e060a2017-07-30 22:38:03 +0200113 boolean e
Harald Welte484160b2017-07-28 13:30:24 +0200114 } with {
Harald Welte43e060a2017-07-30 22:38:03 +0200115 variant (e) "FIELDLENGTH(1)"
Harald Welte484160b2017-07-28 13:30:24 +0200116 };
Harald Welte43e060a2017-07-30 22:38:03 +0200117 type record LlcBlock {
118 /* Header is only present if LI field was present */
119 LlcBlockHdr hdr,
120 octetstring payload
121 } with { variant "" };
122 type record of LlcBlock LlcBlocks;
Harald Welte484160b2017-07-28 13:30:24 +0200123
124 /* TS 44.060 10.2.1 Downlink RLC data block */
Harald Welte43e060a2017-07-30 22:38:03 +0200125 type record DlMacHdrDataExt {
Harald Welte484160b2017-07-28 13:30:24 +0200126 /* Octet 1 */
Harald Welte484160b2017-07-28 13:30:24 +0200127 PowerReduction pr,
128 BIT1 spare,
129 uint4_t tfi, /* 3 or 4? */
130 boolean fbi,
Harald Welte43e060a2017-07-30 22:38:03 +0200131 /* Octet 2 */
Harald Welte484160b2017-07-28 13:30:24 +0200132 uint7_t bsn,
Harald Welte43e060a2017-07-30 22:38:03 +0200133 boolean e
134 } with {
135 variant (e) "FIELDLENGTH(1)"
136 };
137 type record DlMacDataHeader {
138 DlMacHeader mac_hdr,
139 DlMacHdrDataExt hdr_ext
Harald Welte484160b2017-07-28 13:30:24 +0200140 } with { variant "" };
Harald Welte43e060a2017-07-30 22:38:03 +0200141 type record RlcmacDlDataBlock {
142 DlMacDataHeader mac_hdr,
143 /* Octet 3..M / N: manual C++ Decoder */
144 LlcBlocks blocks
145 } with {
146 variant ""
147 };
Harald Welte484160b2017-07-28 13:30:24 +0200148
Harald Welte43e060a2017-07-30 22:38:03 +0200149 external function enc_RlcmacDlDataBlock(in RlcmacDlDataBlock si) return octetstring;
150 external function dec_RlcmacDlDataBlock(in octetstring stream) return RlcmacDlDataBlock;
Harald Welte484160b2017-07-28 13:30:24 +0200151
152
153 /* TS 44.060 10.2.2 */
154 type record UlMacDataHeader {
Harald Welte43e060a2017-07-30 22:38:03 +0200155 /* Octet 0 */
Harald Welteefbc2fc2017-07-31 00:05:23 +0200156 MacPayloadType payload_type,
Harald Welte484160b2017-07-28 13:30:24 +0200157 uint4_t countdown,
158 boolean stall_ind,
Harald Welte43e060a2017-07-30 22:38:03 +0200159 boolean retry,
160 /* Octet 1 */
161 BIT1 spare,
162 boolean pfi_ind,
163 uint5_t tfi,
164 boolean tlli_ind,
165 /* Octet 2 */
166 uint7_t bsn,
167 boolean e
Harald Welte484160b2017-07-28 13:30:24 +0200168 } with {
Harald Welte43e060a2017-07-30 22:38:03 +0200169 variant (stall_ind) "FIELDLENGTH(1)"
170 variant (retry) "FIELDLENGTH(1)"
171 variant (pfi_ind) "FIELDLENGTH(1)"
172 variant (tlli_ind) "FIELDLENGTH(1)"
173 variant (e) "FIELDLENGTH(1)"
Harald Welte484160b2017-07-28 13:30:24 +0200174 };
175
Harald Welte484160b2017-07-28 13:30:24 +0200176 type record RlcMacUlPfi {
177 uint7_t pfi,
178 boolean m
179 } with {
180 variant (m) "FIELDLENGTH(1)"
181 };
182
183 /* TS 44.060 10.2.2 */
184 type record RlcmacUlDataBlock {
185 /* MAC header */
186 UlMacDataHeader mac_hdr,
Harald Welte43e060a2017-07-30 22:38:03 +0200187 /* Octet 3 ... M (optional): manual C++ Decoder */
188 GprsTlli tlli optional,
189 RlcMacUlPfi pfi optional,
190 LlcBlocks blocks
Harald Welte484160b2017-07-28 13:30:24 +0200191 } with {
Harald Welte43e060a2017-07-30 22:38:03 +0200192 variant (tlli) "PRESENCE(mac_hdr.tlli_ind = true)"
193 variant (pfi) "PRESENCE(mac_hdr.pfi_ind = true)"
Harald Welte484160b2017-07-28 13:30:24 +0200194 };
195
Harald Welte43e060a2017-07-30 22:38:03 +0200196 external function enc_RlcmacUlDataBlock(in RlcmacUlDataBlock si) return octetstring;
197 external function dec_RlcmacUlDataBlock(in octetstring stream) return RlcmacUlDataBlock;
Harald Welte484160b2017-07-28 13:30:24 +0200198
Harald Welteefbc2fc2017-07-31 00:05:23 +0200199 type union RlcmacUlBlock {
200 RlcmacUlDataBlock data,
201 RlcmacUlCtrlBlock ctrl
202 } with {
203 variant "TAG(data, mac_hdr.payload_type = MAC_PT_RLC_DATA;
204 ctrl, mac_hdr.payload_type = MAC_PT_RLCMAC_NO_OPT;
205 ctrl, mac_hdr.payload_type = MAC_PT_RLCMAC_OPT)"
206 };
207
Harald Welte78a1af62017-07-31 17:33:56 +0200208 /* as the sub-types (RlcmacDl*Block) are not using the RAW coder, we cannot
209 * use auto-generated functions here, as they would decode those sub-types
210 * based on the RAW coder, not baed on the manual C++ functions */
211 external function enc_RlcmacUlBlock(in RlcmacUlBlock si) return octetstring;
212 external function dec_RlcmacUlBlock(in octetstring stream) return RlcmacUlBlock;
Harald Welteefbc2fc2017-07-31 00:05:23 +0200213
214 type union RlcmacDlBlock {
215 RlcmacDlDataBlock data,
216 RlcmacDlCtrlBlock ctrl
217 } with {
218 variant "TAG(data, mac_hdr.mac_hdr.payload_type = MAC_PT_RLC_DATA;
219 ctrl, mac_hdr.payload_type = MAC_PT_RLCMAC_NO_OPT;
220 ctrl, mac_hdr.payload_type = MAC_PT_RLCMAC_OPT)"
221 };
222
Harald Welte78a1af62017-07-31 17:33:56 +0200223 /* as the sub-types (RlcmacDl*Block) are not using the RAW coder, we cannot
224 * use auto-generated functions here, as they would decode those sub-types
225 * based on the RAW coder, not baed on the manual C++ functions */
226 external function enc_RlcmacDlBlock(in RlcmacDlBlock si) return octetstring;
227 external function dec_RlcmacDlBlock(in octetstring stream) return RlcmacDlBlock;
Harald Welteefbc2fc2017-07-31 00:05:23 +0200228
Harald Welte484160b2017-07-28 13:30:24 +0200229} with { encode "RAW"; variant "FIELDORDER(msb)" }