blob: 6cd6e49b4f62917e815568c6489edcfdf25368e3 [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;
6
7 /* TS 44.060 10.4.7 */
8 type enumerated MacPayloadType {
9 MAC_PT_RLC_DATA ('00'B),
10 MAC_PT_RLCMAC_NO_OPT ('01'B),
11 MAC_PT_RLCMAC_OPT ('10'B),
12 MAC_PT_RESERVED ('11'B)
13 } with { variant "FIELDLENGTH(2)" };
14
15 /* TS 44.060 10.4.5 */
16 type enumerated MacRrbp {
17 RRBP_Nplus13_mod_2715648 ('00'B),
18 RRBP_Nplus17_or_18_mod_2715648 ('01'B),
19 RRBP_Nplus22_or_22_mod_2715648 ('10'B),
20 RRBP_Nplus26_mod_2715648 ('11'B)
21 } with { variant "FIELDLENGTH(2)" };
22
23 /* Partof DL RLC data block and DL RLC/MAC ctrl block */
24 type record DlMacHeader {
25 MacPayloadType payload_type,
26 MacRrbp rrbp,
27 boolean rrbp_valid,
28 uint3_t usf
29 } with {
30 variant (rrbp_valid) "FIELDLENGTH(1)"
31 };
32
33 /* TS 44.060 10.4.10a */
34 type enumerated PowerReduction {
35 PWR_RED_0_to_3dB ('00'B),
36 PWR_RED_3_to_7dB ('01'B),
37 PWR_RED_7_to_10dB ('10'B),
38 PWR_RED_RESERVED ('11'B)
39 } with { variant "FIELDLENGTH(2)" };
40
41 /* TS 44.060 10.4.9d */
42 type enumerated DirectionBit {
43 DIR_UPLINK_TBF ('0'B),
44 DIR_DOWNLINK_TBF ('1'B)
45 } with { variant "FIELDLENGTH(1)" };
46
47 type record TfiOctet {
48 /* PR, TFI, D */
49 PowerReduction pr,
50 uint5_t tfi,
51 DirectionBit d
52 } with { variant "" };
53
54 type record RbsnExtOctet {
55 uint3_t rbsn_e,
56 BIT1 fs_e,
57 BIT4 spare
58 } with { variant "" };
59
60 type record DlCtrlOptOctets {
61 /* RBSN, RTI, FS, AC (optional, depending on mac_hdr.payload_type) */
62 BIT1 rbsn,
63 uint5_t rti,
64 boolean fs,
65 boolean tfi_octet_present,
66 TfiOctet tfi optional,
67 RbsnExtOctet rbsn_ext optional
68 } with {
69 variant (fs) "FIELDLENGTH(1)"
70 variant (tfi_octet_present) "FIELDLENGTH(1)"
71 variant (tfi) "PRESENCE(tfi_octet_present = true)"
72 variant (rbsn_ext) "PRESENCE(rbsn='1'B, fs=false)"
73 };
74
75 /* TS 44.060 10.3.1 Downlink RLC/MAC control block */
76 type record RlcmacDlCtrlBlock {
77 DlMacHeader mac_hdr,
78 DlCtrlOptOctets opt optional,
79 octetstring payload
80 } with {
81 variant (opt) "PRESENCE(mac_hdr.payload_type = MAC_PT_RLCMAC_OPT)"
82 };
83
84 external function enc_RlcmacDlCtrlBlock(in RlcmacDlCtrlBlock si) return octetstring
85 with { extension "prototype(convert) encode(RAW)" };
86 external function dec_RlcmacDlCtrlBlock(in octetstring stream) return RlcmacDlCtrlBlock
87 with { extension "prototype(convert) decode(RAW)" };
88
89 type record UlMacCtrlHeader {
90 MacPayloadType pt,
91 BIT5 spare,
92 boolean retry
93 } with { variant (retry) "FIELDLENGTH(1)" };
94
95 /* TS 44.060 10.3.2 UplinkRLC/MAC control block */
96 type record RlcmacUlCtrlBlock {
97 UlMacCtrlHeader mac_hdr,
98 octetstring payload
99 } with { variant "" };
100
101 external function enc_RlcmacUlCtrlBlock(in RlcmacUlCtrlBlock si) return octetstring
102 with { extension "prototype(convert) encode(RAW)" };
103 external function dec_RlcmacUlCtrlBlock(in octetstring stream) return RlcmacUlCtrlBlock
104 with { extension "prototype(convert) decode(RAW)" };
105
106 /* a single RLC block / LLC-segment */
Harald Welte43e060a2017-07-30 22:38:03 +0200107 type record LlcBlockHdr {
Harald Welte484160b2017-07-28 13:30:24 +0200108 uint6_t length_ind,
109 /* 1 = new LLC PDU starts */
110 BIT1 more,
111 /* 0 = another extension octet after LLC PDU, 1 = no more extension octets */
Harald Welte43e060a2017-07-30 22:38:03 +0200112 boolean e
Harald Welte484160b2017-07-28 13:30:24 +0200113 } with {
Harald Welte43e060a2017-07-30 22:38:03 +0200114 variant (e) "FIELDLENGTH(1)"
Harald Welte484160b2017-07-28 13:30:24 +0200115 };
Harald Welte43e060a2017-07-30 22:38:03 +0200116 type record LlcBlock {
117 /* Header is only present if LI field was present */
118 LlcBlockHdr hdr,
119 octetstring payload
120 } with { variant "" };
121 type record of LlcBlock LlcBlocks;
Harald Welte484160b2017-07-28 13:30:24 +0200122
123 /* TS 44.060 10.2.1 Downlink RLC data block */
Harald Welte43e060a2017-07-30 22:38:03 +0200124 type record DlMacHdrDataExt {
Harald Welte484160b2017-07-28 13:30:24 +0200125 /* Octet 1 */
Harald Welte484160b2017-07-28 13:30:24 +0200126 PowerReduction pr,
127 BIT1 spare,
128 uint4_t tfi, /* 3 or 4? */
129 boolean fbi,
Harald Welte43e060a2017-07-30 22:38:03 +0200130 /* Octet 2 */
Harald Welte484160b2017-07-28 13:30:24 +0200131 uint7_t bsn,
Harald Welte43e060a2017-07-30 22:38:03 +0200132 boolean e
133 } with {
134 variant (e) "FIELDLENGTH(1)"
135 };
136 type record DlMacDataHeader {
137 DlMacHeader mac_hdr,
138 DlMacHdrDataExt hdr_ext
Harald Welte484160b2017-07-28 13:30:24 +0200139 } with { variant "" };
Harald Welte43e060a2017-07-30 22:38:03 +0200140 type record RlcmacDlDataBlock {
141 DlMacDataHeader mac_hdr,
142 /* Octet 3..M / N: manual C++ Decoder */
143 LlcBlocks blocks
144 } with {
145 variant ""
146 };
Harald Welte484160b2017-07-28 13:30:24 +0200147
Harald Welte43e060a2017-07-30 22:38:03 +0200148 external function enc_RlcmacDlDataBlock(in RlcmacDlDataBlock si) return octetstring;
149 external function dec_RlcmacDlDataBlock(in octetstring stream) return RlcmacDlDataBlock;
Harald Welte484160b2017-07-28 13:30:24 +0200150
151
152 /* TS 44.060 10.2.2 */
153 type record UlMacDataHeader {
Harald Welte43e060a2017-07-30 22:38:03 +0200154 /* Octet 0 */
Harald Welte484160b2017-07-28 13:30:24 +0200155 MacPayloadType pt,
156 uint4_t countdown,
157 boolean stall_ind,
Harald Welte43e060a2017-07-30 22:38:03 +0200158 boolean retry,
159 /* Octet 1 */
160 BIT1 spare,
161 boolean pfi_ind,
162 uint5_t tfi,
163 boolean tlli_ind,
164 /* Octet 2 */
165 uint7_t bsn,
166 boolean e
Harald Welte484160b2017-07-28 13:30:24 +0200167 } with {
Harald Welte43e060a2017-07-30 22:38:03 +0200168 variant (stall_ind) "FIELDLENGTH(1)"
169 variant (retry) "FIELDLENGTH(1)"
170 variant (pfi_ind) "FIELDLENGTH(1)"
171 variant (tlli_ind) "FIELDLENGTH(1)"
172 variant (e) "FIELDLENGTH(1)"
Harald Welte484160b2017-07-28 13:30:24 +0200173 };
174
Harald Welte484160b2017-07-28 13:30:24 +0200175 type record RlcMacUlPfi {
176 uint7_t pfi,
177 boolean m
178 } with {
179 variant (m) "FIELDLENGTH(1)"
180 };
181
182 /* TS 44.060 10.2.2 */
183 type record RlcmacUlDataBlock {
184 /* MAC header */
185 UlMacDataHeader mac_hdr,
Harald Welte43e060a2017-07-30 22:38:03 +0200186 /* Octet 3 ... M (optional): manual C++ Decoder */
187 GprsTlli tlli optional,
188 RlcMacUlPfi pfi optional,
189 LlcBlocks blocks
Harald Welte484160b2017-07-28 13:30:24 +0200190 } with {
Harald Welte43e060a2017-07-30 22:38:03 +0200191 variant (tlli) "PRESENCE(mac_hdr.tlli_ind = true)"
192 variant (pfi) "PRESENCE(mac_hdr.pfi_ind = true)"
Harald Welte484160b2017-07-28 13:30:24 +0200193 };
194
Harald Welte43e060a2017-07-30 22:38:03 +0200195 external function enc_RlcmacUlDataBlock(in RlcmacUlDataBlock si) return octetstring;
196 external function dec_RlcmacUlDataBlock(in octetstring stream) return RlcmacUlDataBlock;
Harald Welte484160b2017-07-28 13:30:24 +0200197
198} with { encode "RAW"; variant "FIELDORDER(msb)" }