blob: f73721c00cd47e25d5288bb0c01a53ca2dfe593b [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 */
107
108 type record RlcBlockHdr {
109 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 */
113 BIT1 e
114 } with { variant "" };
115
116 type record RlcBlock {
117 uint6_t length_ind,
118 BIT1 more,
119 BIT1 e,
120 octetstring rlc optional
121 } with {
122 variant (rlc) "PRESENCE (more = '1'B)"
123 variant (length_ind) "LENGTHTO(length_ind, more, e, rlc)"
124 };
125
126 type record of RlcBlock RlcBlocks;
127
128 /* TS 44.060 10.2.1 Downlink RLC data block */
129 type record RlcmacDlDataBlock {
130 /* Octet 1 */
131 DlMacHeader mac_hdr,
132 /* Octet 2 */
133 PowerReduction pr,
134 BIT1 spare,
135 uint4_t tfi, /* 3 or 4? */
136 boolean fbi,
137 /* Octet 3 */
138 uint7_t bsn,
139 BIT1 e ('1'B),
140 RlcBlocks rlc_blocks
141 } with { variant "" };
142
143 external function enc_RlcmacDlDataBlock(in RlcmacDlDataBlock si) return octetstring
144 with { extension "prototype(convert) encode(RAW)" };
145 external function dec_RlcmacDlDataBlock(in octetstring stream) return RlcmacDlDataBlock
146 with { extension "prototype(convert) decode(RAW)" };
147
148
149 /* TS 44.060 10.2.2 */
150 type record UlMacDataHeader {
151 MacPayloadType pt,
152 uint4_t countdown,
153 boolean stall_ind,
154 boolean retry
155 } with {
156 variant (stall_ind) "FIELDLENGTH(1)"
157 variant (retry) "FIELDLENGTH(1)"
158 };
159
160 type record RlcMacUlTlli {
161 RlcBlockHdr hdr,
162 uint32_t tlli
163 } with {
164 variant ""
165 }
166
167 type record RlcMacUlPfi {
168 uint7_t pfi,
169 boolean m
170 } with {
171 variant (m) "FIELDLENGTH(1)"
172 };
173
174 /* TS 44.060 10.2.2 */
175 type record RlcmacUlDataBlock {
176 /* MAC header */
177 UlMacDataHeader mac_hdr,
178 /* Octet 1 */
179 BIT1 spare,
180 boolean pfi_ind,
181 uint5_t tfi,
182 boolean tlli_ind,
183 /* Octet 2 */
184 uint7_t bsn,
185 BIT1 e ('1'B),
186 /* Octet 3 (optional) */
187 RlcMacUlTlli tlli,
188 RlcMacUlPfi pfi,
189 RlcBlocks blocks
190 } with {
191 variant (tlli) "PRESENCE(tlli_ind = true)"
192 variant (pfi) "PRESENCE(pfi_ind = true)"
193 };
194
195 external function enc_RlcmacUlDataBlock(in RlcmacUlDataBlock si) return octetstring
196 with { extension "prototype(convert) encode(RAW)" };
197 external function dec_RlcmacUlDataBlock(in octetstring stream) return RlcmacUlDataBlock
198 with { extension "prototype(convert) decode(RAW)" };
199
200} with { encode "RAW"; variant "FIELDORDER(msb)" }