Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 1 | /* TITAN REW encode/decode definitions for 3GPP TS 44.060 RLC/MAC Blocks */ |
Harald Welte | 34b5a95 | 2019-05-27 11:54:11 +0200 | [diff] [blame] | 2 | |
| 3 | /* (C) 2017-2018 Harald Welte <laforge@gnumonks.org> |
| 4 | * All rights reserved. |
| 5 | * |
| 6 | * Released under the terms of GNU General Public License, Version 2 or |
| 7 | * (at your option) any later version. |
| 8 | * |
| 9 | * SPDX-License-Identifier: GPL-2.0-or-later |
| 10 | */ |
| 11 | |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 12 | module RLCMAC_Types { |
| 13 | import from General_Types all; |
| 14 | import from Osmocom_Types all; |
| 15 | import from GSM_Types all; |
Harald Welte | 9d34852 | 2017-08-01 00:27:39 +0200 | [diff] [blame] | 16 | import from RLCMAC_CSN1_Types all; |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 17 | |
| 18 | /* TS 44.060 10.4.7 */ |
| 19 | type enumerated MacPayloadType { |
| 20 | MAC_PT_RLC_DATA ('00'B), |
| 21 | MAC_PT_RLCMAC_NO_OPT ('01'B), |
| 22 | MAC_PT_RLCMAC_OPT ('10'B), |
| 23 | MAC_PT_RESERVED ('11'B) |
| 24 | } with { variant "FIELDLENGTH(2)" }; |
| 25 | |
| 26 | /* TS 44.060 10.4.5 */ |
| 27 | type enumerated MacRrbp { |
| 28 | RRBP_Nplus13_mod_2715648 ('00'B), |
| 29 | RRBP_Nplus17_or_18_mod_2715648 ('01'B), |
Harald Welte | 1cd673d | 2018-03-02 21:41:31 +0100 | [diff] [blame] | 30 | RRBP_Nplus21_or_22_mod_2715648 ('10'B), |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 31 | RRBP_Nplus26_mod_2715648 ('11'B) |
| 32 | } with { variant "FIELDLENGTH(2)" }; |
| 33 | |
Pau Espin Pedrol | 372af7a | 2020-04-27 17:32:01 +0200 | [diff] [blame] | 34 | type enumerated EgprsHeaderType { |
| 35 | RLCMAC_HDR_TYPE_1, |
| 36 | RLCMAC_HDR_TYPE_2, |
| 37 | RLCMAC_HDR_TYPE_3 |
| 38 | }; |
| 39 | |
Pau Espin Pedrol | dc9666f | 2020-03-18 20:30:16 +0100 | [diff] [blame] | 40 | type enumerated CodingScheme { |
| 41 | CS_1, |
| 42 | CS_2, |
| 43 | CS_3, |
| 44 | CS_4, |
Pau Espin Pedrol | 372af7a | 2020-04-27 17:32:01 +0200 | [diff] [blame] | 45 | MCS_0, |
Pau Espin Pedrol | dc9666f | 2020-03-18 20:30:16 +0100 | [diff] [blame] | 46 | MCS_1, |
| 47 | MCS_2, |
| 48 | MCS_3, |
| 49 | MCS_4, |
| 50 | MCS_5, |
| 51 | MCS_6, |
| 52 | MCS_7, |
| 53 | MCS_8, |
| 54 | MCS_9 |
| 55 | //MCS5_7, ? |
| 56 | // MCS6_9 ? |
| 57 | }; |
Pau Espin Pedrol | 27d6af5 | 2020-04-30 20:13:32 +0200 | [diff] [blame] | 58 | type record of CodingScheme CodingSchemeArray; |
Pau Espin Pedrol | dc9666f | 2020-03-18 20:30:16 +0100 | [diff] [blame] | 59 | |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 60 | /* Partof DL RLC data block and DL RLC/MAC ctrl block */ |
| 61 | type record DlMacHeader { |
| 62 | MacPayloadType payload_type, |
| 63 | MacRrbp rrbp, |
| 64 | boolean rrbp_valid, |
| 65 | uint3_t usf |
| 66 | } with { |
| 67 | variant (rrbp_valid) "FIELDLENGTH(1)" |
| 68 | }; |
| 69 | |
| 70 | /* TS 44.060 10.4.10a */ |
| 71 | type enumerated PowerReduction { |
| 72 | PWR_RED_0_to_3dB ('00'B), |
| 73 | PWR_RED_3_to_7dB ('01'B), |
| 74 | PWR_RED_7_to_10dB ('10'B), |
| 75 | PWR_RED_RESERVED ('11'B) |
| 76 | } with { variant "FIELDLENGTH(2)" }; |
| 77 | |
| 78 | /* TS 44.060 10.4.9d */ |
| 79 | type enumerated DirectionBit { |
| 80 | DIR_UPLINK_TBF ('0'B), |
| 81 | DIR_DOWNLINK_TBF ('1'B) |
| 82 | } with { variant "FIELDLENGTH(1)" }; |
| 83 | |
| 84 | type record TfiOctet { |
| 85 | /* PR, TFI, D */ |
| 86 | PowerReduction pr, |
| 87 | uint5_t tfi, |
| 88 | DirectionBit d |
| 89 | } with { variant "" }; |
| 90 | |
| 91 | type record RbsnExtOctet { |
| 92 | uint3_t rbsn_e, |
| 93 | BIT1 fs_e, |
| 94 | BIT4 spare |
| 95 | } with { variant "" }; |
| 96 | |
| 97 | type record DlCtrlOptOctets { |
| 98 | /* RBSN, RTI, FS, AC (optional, depending on mac_hdr.payload_type) */ |
| 99 | BIT1 rbsn, |
| 100 | uint5_t rti, |
| 101 | boolean fs, |
| 102 | boolean tfi_octet_present, |
| 103 | TfiOctet tfi optional, |
| 104 | RbsnExtOctet rbsn_ext optional |
| 105 | } with { |
| 106 | variant (fs) "FIELDLENGTH(1)" |
| 107 | variant (tfi_octet_present) "FIELDLENGTH(1)" |
| 108 | variant (tfi) "PRESENCE(tfi_octet_present = true)" |
| 109 | variant (rbsn_ext) "PRESENCE(rbsn='1'B, fs=false)" |
| 110 | }; |
| 111 | |
| 112 | /* TS 44.060 10.3.1 Downlink RLC/MAC control block */ |
| 113 | type record RlcmacDlCtrlBlock { |
| 114 | DlMacHeader mac_hdr, |
| 115 | DlCtrlOptOctets opt optional, |
Harald Welte | 9d34852 | 2017-08-01 00:27:39 +0200 | [diff] [blame] | 116 | RlcmacDlCtrlMsg payload |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 117 | } with { |
Pau Espin Pedrol | cb00c52 | 2020-11-06 19:52:05 +0100 | [diff] [blame] | 118 | /* Automatic padding by RAW encoder seems to causing problems |
| 119 | * due to padding sequence 2b inserted shifted from octet |
| 120 | * boundary on some messags. See UL CTRL blocks in TC_t3193. |
| 121 | * See 3GPP TS 44.060 Figure 11.1 (below) |
| 122 | * variant "PADDING(184), PADDING_PATTERN('00101011'B)" */ |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 123 | variant (opt) "PRESENCE(mac_hdr.payload_type = MAC_PT_RLCMAC_OPT)" |
| 124 | }; |
| 125 | |
| 126 | external function enc_RlcmacDlCtrlBlock(in RlcmacDlCtrlBlock si) return octetstring |
| 127 | with { extension "prototype(convert) encode(RAW)" }; |
| 128 | external function dec_RlcmacDlCtrlBlock(in octetstring stream) return RlcmacDlCtrlBlock |
| 129 | with { extension "prototype(convert) decode(RAW)" }; |
| 130 | |
| 131 | type record UlMacCtrlHeader { |
Harald Welte | efbc2fc | 2017-07-31 00:05:23 +0200 | [diff] [blame] | 132 | MacPayloadType payload_type, |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 133 | BIT5 spare, |
| 134 | boolean retry |
| 135 | } with { variant (retry) "FIELDLENGTH(1)" }; |
| 136 | |
| 137 | /* TS 44.060 10.3.2 UplinkRLC/MAC control block */ |
| 138 | type record RlcmacUlCtrlBlock { |
| 139 | UlMacCtrlHeader mac_hdr, |
Harald Welte | 9d34852 | 2017-08-01 00:27:39 +0200 | [diff] [blame] | 140 | RlcmacUlCtrlMsg payload |
Pau Espin Pedrol | cb00c52 | 2020-11-06 19:52:05 +0100 | [diff] [blame] | 141 | } with { |
| 142 | /* Automatic padding by RAW encoder seems to causing problems |
| 143 | * due to padding sequence 2b inserted shifted from octet |
| 144 | * boundary on some messags. See UL CTRL blocks in TC_t3193. |
| 145 | * See 3GPP TS 44.060 Figure 11.1 (below) |
| 146 | * variant "PADDING(184), PADDING_PATTERN('00101011'B)" */ |
| 147 | variant "" |
| 148 | }; |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 149 | |
| 150 | external function enc_RlcmacUlCtrlBlock(in RlcmacUlCtrlBlock si) return octetstring |
| 151 | with { extension "prototype(convert) encode(RAW)" }; |
| 152 | external function dec_RlcmacUlCtrlBlock(in octetstring stream) return RlcmacUlCtrlBlock |
| 153 | with { extension "prototype(convert) decode(RAW)" }; |
| 154 | |
| 155 | /* a single RLC block / LLC-segment */ |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame] | 156 | type record LlcBlockHdr { |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 157 | uint6_t length_ind, |
| 158 | /* 1 = new LLC PDU starts */ |
Harald Welte | 060e27a | 2018-03-03 20:38:19 +0100 | [diff] [blame] | 159 | boolean more, |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 160 | /* 0 = another extension octet after LLC PDU, 1 = no more extension octets */ |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame] | 161 | boolean e |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 162 | } with { |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame] | 163 | variant (e) "FIELDLENGTH(1)" |
Harald Welte | cc5c115 | 2018-03-09 12:54:01 +0100 | [diff] [blame] | 164 | encode "RAW" |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 165 | }; |
Harald Welte | cc5c115 | 2018-03-09 12:54:01 +0100 | [diff] [blame] | 166 | |
| 167 | external function enc_LlcBlockHdr(in LlcBlockHdr si) return octetstring |
| 168 | with { extension "prototype(convert) encode(RAW)" }; |
| 169 | external function dec_LlcBlockHdr(in octetstring stream) return LlcBlockHdr |
| 170 | with { extension "prototype(convert) decode(RAW)" }; |
| 171 | |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame] | 172 | type record LlcBlock { |
| 173 | /* Header is only present if LI field was present */ |
Harald Welte | 060e27a | 2018-03-03 20:38:19 +0100 | [diff] [blame] | 174 | LlcBlockHdr hdr optional, |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame] | 175 | octetstring payload |
| 176 | } with { variant "" }; |
| 177 | type record of LlcBlock LlcBlocks; |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 178 | |
| 179 | /* TS 44.060 10.2.1 Downlink RLC data block */ |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame] | 180 | type record DlMacHdrDataExt { |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 181 | /* Octet 1 */ |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 182 | PowerReduction pr, |
| 183 | BIT1 spare, |
| 184 | uint4_t tfi, /* 3 or 4? */ |
| 185 | boolean fbi, |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame] | 186 | /* Octet 2 */ |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 187 | uint7_t bsn, |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame] | 188 | boolean e |
| 189 | } with { |
| 190 | variant (e) "FIELDLENGTH(1)" |
| 191 | }; |
| 192 | type record DlMacDataHeader { |
| 193 | DlMacHeader mac_hdr, |
| 194 | DlMacHdrDataExt hdr_ext |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 195 | } with { variant "" }; |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame] | 196 | type record RlcmacDlDataBlock { |
Pau Espin Pedrol | 5abfded | 2020-11-03 17:30:44 +0100 | [diff] [blame] | 197 | CodingScheme cs, /* Provided by C++ Decoder */ |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame] | 198 | DlMacDataHeader mac_hdr, |
| 199 | /* Octet 3..M / N: manual C++ Decoder */ |
| 200 | LlcBlocks blocks |
| 201 | } with { |
| 202 | variant "" |
| 203 | }; |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 204 | |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame] | 205 | external function enc_RlcmacDlDataBlock(in RlcmacDlDataBlock si) return octetstring; |
| 206 | external function dec_RlcmacDlDataBlock(in octetstring stream) return RlcmacDlDataBlock; |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 207 | |
| 208 | |
Pau Espin Pedrol | 372af7a | 2020-04-27 17:32:01 +0200 | [diff] [blame] | 209 | /* a single RLC block / LLC-segment */ |
| 210 | type record EgprsLlcBlockHdr { |
| 211 | uint7_t length_ind, |
| 212 | /* 0 = another extension octet after LLC PDU, 1 = no more extension octets */ |
| 213 | boolean e |
| 214 | } with { |
| 215 | variant (e) "FIELDLENGTH(1)" |
| 216 | encode "RAW" |
| 217 | }; |
| 218 | |
| 219 | external function enc_EgprsLlcBlockHdr(in EgprsLlcBlockHdr si) return octetstring |
| 220 | with { extension "prototype(convert) encode(RAW)" }; |
| 221 | external function dec_EgprsLlcBlockHdr(in octetstring stream) return EgprsLlcBlockHdr |
| 222 | with { extension "prototype(convert) decode(RAW)" }; |
| 223 | |
| 224 | type record EgprsLlcBlock { |
| 225 | /* Header is only present if LI field was present */ |
| 226 | EgprsLlcBlockHdr hdr optional, |
| 227 | octetstring payload |
| 228 | } with { variant "" }; |
| 229 | type record of EgprsLlcBlock EgprsLlcBlocks; |
| 230 | |
| 231 | /* TS 44.060 10.3a.1.1 EGPRS downlink RLC data block, manual c++ encoder/decoder */ |
| 232 | type record EgprsDlMacDataHeader { |
| 233 | EgprsHeaderType header_type, /* Set internally by decoder */ |
| 234 | uint5_t tfi, |
| 235 | MacRrbp rrbp, |
| 236 | BIT2 esp, |
| 237 | uint3_t usf, |
Pau Espin Pedrol | 081b168 | 2020-11-06 17:15:52 +0100 | [diff] [blame] | 238 | uint11_t bsn1, |
Pau Espin Pedrol | 372af7a | 2020-04-27 17:32:01 +0200 | [diff] [blame] | 239 | uint8_t bsn2_offset, |
| 240 | uint2_t pr, /* power reduction */ |
| 241 | uint2_t spb, |
| 242 | uint4_t cps |
| 243 | } with { variant "" }; |
| 244 | /* Manual C++ Decoder: */ |
| 245 | type record RlcmacDlEgprsDataBlock { |
Pau Espin Pedrol | 5abfded | 2020-11-03 17:30:44 +0100 | [diff] [blame] | 246 | CodingScheme mcs, /* Provided by C++ Decoder */ |
Pau Espin Pedrol | 372af7a | 2020-04-27 17:32:01 +0200 | [diff] [blame] | 247 | EgprsDlMacDataHeader mac_hdr, |
| 248 | boolean fbi, |
| 249 | boolean e, |
| 250 | EgprsLlcBlocks blocks |
| 251 | } with { |
| 252 | variant (fbi) "FIELDLENGTH(1)" |
| 253 | variant (e) "FIELDLENGTH(1)" |
| 254 | }; |
| 255 | |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 256 | /* TS 44.060 10.2.2 */ |
| 257 | type record UlMacDataHeader { |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame] | 258 | /* Octet 0 */ |
Harald Welte | efbc2fc | 2017-07-31 00:05:23 +0200 | [diff] [blame] | 259 | MacPayloadType payload_type, |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 260 | uint4_t countdown, |
| 261 | boolean stall_ind, |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame] | 262 | boolean retry, |
| 263 | /* Octet 1 */ |
| 264 | BIT1 spare, |
| 265 | boolean pfi_ind, |
| 266 | uint5_t tfi, |
| 267 | boolean tlli_ind, |
| 268 | /* Octet 2 */ |
| 269 | uint7_t bsn, |
| 270 | boolean e |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 271 | } with { |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame] | 272 | variant (stall_ind) "FIELDLENGTH(1)" |
| 273 | variant (retry) "FIELDLENGTH(1)" |
| 274 | variant (pfi_ind) "FIELDLENGTH(1)" |
| 275 | variant (tlli_ind) "FIELDLENGTH(1)" |
| 276 | variant (e) "FIELDLENGTH(1)" |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 277 | }; |
| 278 | |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 279 | type record RlcMacUlPfi { |
| 280 | uint7_t pfi, |
| 281 | boolean m |
| 282 | } with { |
| 283 | variant (m) "FIELDLENGTH(1)" |
| 284 | }; |
| 285 | |
Pau Espin Pedrol | 372af7a | 2020-04-27 17:32:01 +0200 | [diff] [blame] | 286 | /* TS 44.060 10.3a.1.1 10.3a.4 EGPRS Uplink RLC/MAC header, manual c++ encoder/decoder */ |
| 287 | type record EgprsUlMacDataHeader { |
| 288 | EgprsHeaderType header_type, /* Set internally by decoder */ |
| 289 | uint5_t tfi, |
| 290 | uint4_t countdown, |
| 291 | BIT1 foi_si, |
| 292 | BIT1 r_ri, |
| 293 | uint11_t bsn1, |
Pau Espin Pedrol | 081b168 | 2020-11-06 17:15:52 +0100 | [diff] [blame] | 294 | uint8_t bsn2_offset, |
Pau Espin Pedrol | 372af7a | 2020-04-27 17:32:01 +0200 | [diff] [blame] | 295 | uint4_t cps, |
| 296 | boolean pfi_ind, |
| 297 | BIT1 rsb, |
| 298 | BIT2 spb |
| 299 | } with { |
| 300 | variant (pfi_ind) "FIELDLENGTH(1)" |
| 301 | }; |
| 302 | /* Manual C++ Decoder: 10.3a.2.1 EGPRS Uplink RLC data block */ |
| 303 | type record RlcmacUlEgprsDataBlock { |
Pau Espin Pedrol | 5abfded | 2020-11-03 17:30:44 +0100 | [diff] [blame] | 304 | CodingScheme mcs, /* Provided by C++ Decoder */ |
Pau Espin Pedrol | 372af7a | 2020-04-27 17:32:01 +0200 | [diff] [blame] | 305 | EgprsUlMacDataHeader mac_hdr, |
| 306 | boolean tlli_ind, |
| 307 | boolean e, |
| 308 | /* Octet 3 ... M (optional): manual C++ Decoder */ |
| 309 | GprsTlli tlli optional, |
| 310 | RlcMacUlPfi pfi optional, |
| 311 | EgprsLlcBlocks blocks |
| 312 | } with { |
| 313 | variant (tlli_ind) "FIELDLENGTH(1)" |
| 314 | variant (e) "FIELDLENGTH(1)" |
| 315 | }; |
| 316 | |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 317 | /* TS 44.060 10.2.2 */ |
| 318 | type record RlcmacUlDataBlock { |
Pau Espin Pedrol | 5abfded | 2020-11-03 17:30:44 +0100 | [diff] [blame] | 319 | CodingScheme cs, /* Provided by C++ Decoder */ |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 320 | /* MAC header */ |
| 321 | UlMacDataHeader mac_hdr, |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame] | 322 | /* Octet 3 ... M (optional): manual C++ Decoder */ |
| 323 | GprsTlli tlli optional, |
| 324 | RlcMacUlPfi pfi optional, |
| 325 | LlcBlocks blocks |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 326 | } with { |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame] | 327 | variant (tlli) "PRESENCE(mac_hdr.tlli_ind = true)" |
| 328 | variant (pfi) "PRESENCE(mac_hdr.pfi_ind = true)" |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 329 | }; |
| 330 | |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame] | 331 | external function enc_RlcmacUlDataBlock(in RlcmacUlDataBlock si) return octetstring; |
| 332 | external function dec_RlcmacUlDataBlock(in octetstring stream) return RlcmacUlDataBlock; |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 333 | |
Harald Welte | efbc2fc | 2017-07-31 00:05:23 +0200 | [diff] [blame] | 334 | type union RlcmacUlBlock { |
| 335 | RlcmacUlDataBlock data, |
Pau Espin Pedrol | 372af7a | 2020-04-27 17:32:01 +0200 | [diff] [blame] | 336 | RlcmacUlEgprsDataBlock data_egprs, |
Harald Welte | efbc2fc | 2017-07-31 00:05:23 +0200 | [diff] [blame] | 337 | RlcmacUlCtrlBlock ctrl |
| 338 | } with { |
| 339 | variant "TAG(data, mac_hdr.payload_type = MAC_PT_RLC_DATA; |
Pau Espin Pedrol | 372af7a | 2020-04-27 17:32:01 +0200 | [diff] [blame] | 340 | ctrl, {mac_hdr.payload_type = MAC_PT_RLCMAC_NO_OPT, |
| 341 | mac_hdr.payload_type = MAC_PT_RLCMAC_OPT}; |
| 342 | data_egprs, {mac_hdr.header_type = RLCMAC_HDR_TYPE_1, |
| 343 | mac_hdr.header_type = RLCMAC_HDR_TYPE_2, |
| 344 | mac_hdr.header_type = RLCMAC_HDR_TYPE_3} |
| 345 | )" |
Harald Welte | efbc2fc | 2017-07-31 00:05:23 +0200 | [diff] [blame] | 346 | }; |
| 347 | |
Harald Welte | 78a1af6 | 2017-07-31 17:33:56 +0200 | [diff] [blame] | 348 | /* as the sub-types (RlcmacDl*Block) are not using the RAW coder, we cannot |
| 349 | * use auto-generated functions here, as they would decode those sub-types |
| 350 | * based on the RAW coder, not baed on the manual C++ functions */ |
| 351 | external function enc_RlcmacUlBlock(in RlcmacUlBlock si) return octetstring; |
| 352 | external function dec_RlcmacUlBlock(in octetstring stream) return RlcmacUlBlock; |
Harald Welte | efbc2fc | 2017-07-31 00:05:23 +0200 | [diff] [blame] | 353 | |
| 354 | type union RlcmacDlBlock { |
| 355 | RlcmacDlDataBlock data, |
Pau Espin Pedrol | 372af7a | 2020-04-27 17:32:01 +0200 | [diff] [blame] | 356 | RlcmacDlEgprsDataBlock data_egprs, |
Harald Welte | efbc2fc | 2017-07-31 00:05:23 +0200 | [diff] [blame] | 357 | RlcmacDlCtrlBlock ctrl |
| 358 | } with { |
| 359 | variant "TAG(data, mac_hdr.mac_hdr.payload_type = MAC_PT_RLC_DATA; |
Pau Espin Pedrol | 372af7a | 2020-04-27 17:32:01 +0200 | [diff] [blame] | 360 | ctrl, {mac_hdr.payload_type = MAC_PT_RLCMAC_NO_OPT, |
| 361 | mac_hdr.payload_type = MAC_PT_RLCMAC_OPT}; |
| 362 | data_egprs, {mac_hdr.header_type = RLCMAC_HDR_TYPE_1, |
| 363 | mac_hdr.header_type = RLCMAC_HDR_TYPE_2, |
| 364 | mac_hdr.header_type = RLCMAC_HDR_TYPE_3} |
| 365 | )" |
Harald Welte | efbc2fc | 2017-07-31 00:05:23 +0200 | [diff] [blame] | 366 | }; |
| 367 | |
Harald Welte | 78a1af6 | 2017-07-31 17:33:56 +0200 | [diff] [blame] | 368 | /* as the sub-types (RlcmacDl*Block) are not using the RAW coder, we cannot |
| 369 | * use auto-generated functions here, as they would decode those sub-types |
| 370 | * based on the RAW coder, not baed on the manual C++ functions */ |
| 371 | external function enc_RlcmacDlBlock(in RlcmacDlBlock si) return octetstring; |
| 372 | external function dec_RlcmacDlBlock(in octetstring stream) return RlcmacDlBlock; |
Harald Welte | efbc2fc | 2017-07-31 00:05:23 +0200 | [diff] [blame] | 373 | |
Pau Espin Pedrol | fe3ae51 | 2020-04-28 18:05:59 +0200 | [diff] [blame] | 374 | /************************ |
| 375 | * PTCCH/D (Packet Timing Advance Control Channel) message. |
| 376 | * TODO: add a spec. reference to the message format definition. |
| 377 | *************************/ |
Vadim Yanitskiy | 1bd8ec5 | 2019-10-01 05:44:52 +0700 | [diff] [blame] | 378 | type record PTCCHTimingAdvanceIE { |
| 379 | BIT1 spare ('0'B), |
| 380 | uint7_t ta_val |
| 381 | } with { variant "" }; |
| 382 | type record of PTCCHTimingAdvanceIE PTCCHTimingAdvanceIEs; |
| 383 | type record PTCCHDownlinkMsg { |
| 384 | PTCCHTimingAdvanceIEs ta_idx length(16), |
| 385 | octetstring padding length(7) |
| 386 | } with { variant "" }; |
| 387 | |
| 388 | external function enc_PTCCHDownlinkMsg(in PTCCHDownlinkMsg si) return octetstring |
| 389 | with { extension "prototype(convert) encode(RAW)" }; |
| 390 | external function dec_PTCCHDownlinkMsg(in octetstring stream) return PTCCHDownlinkMsg |
| 391 | with { extension "prototype(convert) decode(RAW)" }; |
| 392 | |
| 393 | template PTCCHDownlinkMsg tr_PTCCHDownlinkMsg( |
| 394 | template (present) uint7_t tai0_ta := ?, |
| 395 | template (present) uint7_t tai1_ta := ?, |
| 396 | template (present) uint7_t tai2_ta := ?, |
| 397 | template (present) uint7_t tai3_ta := ?, |
| 398 | template (present) uint7_t tai4_ta := ?, |
| 399 | template (present) uint7_t tai5_ta := ?, |
| 400 | template (present) uint7_t tai6_ta := ?, |
| 401 | template (present) uint7_t tai7_ta := ?, |
| 402 | template (present) uint7_t tai8_ta := ?, |
| 403 | template (present) uint7_t tai9_ta := ?, |
| 404 | template (present) uint7_t tai10_ta := ?, |
| 405 | template (present) uint7_t tai11_ta := ?, |
| 406 | template (present) uint7_t tai12_ta := ?, |
| 407 | template (present) uint7_t tai13_ta := ?, |
| 408 | template (present) uint7_t tai14_ta := ?, |
| 409 | template (present) uint7_t tai15_ta := ? |
| 410 | ) := { |
| 411 | ta_idx := { |
| 412 | { spare := '0'B, ta_val := tai0_ta }, |
| 413 | { spare := '0'B, ta_val := tai1_ta }, |
| 414 | { spare := '0'B, ta_val := tai2_ta }, |
| 415 | { spare := '0'B, ta_val := tai3_ta }, |
| 416 | { spare := '0'B, ta_val := tai4_ta }, |
| 417 | { spare := '0'B, ta_val := tai5_ta }, |
| 418 | { spare := '0'B, ta_val := tai6_ta }, |
| 419 | { spare := '0'B, ta_val := tai7_ta }, |
| 420 | { spare := '0'B, ta_val := tai8_ta }, |
| 421 | { spare := '0'B, ta_val := tai9_ta }, |
| 422 | { spare := '0'B, ta_val := tai10_ta }, |
| 423 | { spare := '0'B, ta_val := tai11_ta }, |
| 424 | { spare := '0'B, ta_val := tai12_ta }, |
| 425 | { spare := '0'B, ta_val := tai13_ta }, |
| 426 | { spare := '0'B, ta_val := tai14_ta }, |
| 427 | { spare := '0'B, ta_val := tai15_ta } |
| 428 | }, |
| 429 | padding := '2B2B2B2B2B2B2B'O |
| 430 | } |
| 431 | |
Harald Welte | 060e27a | 2018-03-03 20:38:19 +0100 | [diff] [blame] | 432 | |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 433 | } with { encode "RAW"; variant "FIELDORDER(msb)" } |