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 | 65bab9e | 2019-12-04 21:05:10 +0100 | [diff] [blame] | 34 | function f_rrbp_fn_delay(MacRrbp rrbp) return uint32_t { |
| 35 | select (rrbp) { |
| 36 | case (RRBP_Nplus13_mod_2715648) { return 13; } |
| 37 | case (RRBP_Nplus17_or_18_mod_2715648) { return 17; } |
| 38 | case (RRBP_Nplus21_or_22_mod_2715648) { return 21; } |
| 39 | case (RRBP_Nplus26_mod_2715648) { return 26; } |
| 40 | } |
| 41 | return 0; |
| 42 | } |
| 43 | |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 44 | /* Partof DL RLC data block and DL RLC/MAC ctrl block */ |
| 45 | type record DlMacHeader { |
| 46 | MacPayloadType payload_type, |
| 47 | MacRrbp rrbp, |
| 48 | boolean rrbp_valid, |
| 49 | uint3_t usf |
| 50 | } with { |
| 51 | variant (rrbp_valid) "FIELDLENGTH(1)" |
| 52 | }; |
| 53 | |
| 54 | /* TS 44.060 10.4.10a */ |
| 55 | type enumerated PowerReduction { |
| 56 | PWR_RED_0_to_3dB ('00'B), |
| 57 | PWR_RED_3_to_7dB ('01'B), |
| 58 | PWR_RED_7_to_10dB ('10'B), |
| 59 | PWR_RED_RESERVED ('11'B) |
| 60 | } with { variant "FIELDLENGTH(2)" }; |
| 61 | |
| 62 | /* TS 44.060 10.4.9d */ |
| 63 | type enumerated DirectionBit { |
| 64 | DIR_UPLINK_TBF ('0'B), |
| 65 | DIR_DOWNLINK_TBF ('1'B) |
| 66 | } with { variant "FIELDLENGTH(1)" }; |
| 67 | |
| 68 | type record TfiOctet { |
| 69 | /* PR, TFI, D */ |
| 70 | PowerReduction pr, |
| 71 | uint5_t tfi, |
| 72 | DirectionBit d |
| 73 | } with { variant "" }; |
| 74 | |
| 75 | type record RbsnExtOctet { |
| 76 | uint3_t rbsn_e, |
| 77 | BIT1 fs_e, |
| 78 | BIT4 spare |
| 79 | } with { variant "" }; |
| 80 | |
| 81 | type record DlCtrlOptOctets { |
| 82 | /* RBSN, RTI, FS, AC (optional, depending on mac_hdr.payload_type) */ |
| 83 | BIT1 rbsn, |
| 84 | uint5_t rti, |
| 85 | boolean fs, |
| 86 | boolean tfi_octet_present, |
| 87 | TfiOctet tfi optional, |
| 88 | RbsnExtOctet rbsn_ext optional |
| 89 | } with { |
| 90 | variant (fs) "FIELDLENGTH(1)" |
| 91 | variant (tfi_octet_present) "FIELDLENGTH(1)" |
| 92 | variant (tfi) "PRESENCE(tfi_octet_present = true)" |
| 93 | variant (rbsn_ext) "PRESENCE(rbsn='1'B, fs=false)" |
| 94 | }; |
| 95 | |
| 96 | /* TS 44.060 10.3.1 Downlink RLC/MAC control block */ |
| 97 | type record RlcmacDlCtrlBlock { |
| 98 | DlMacHeader mac_hdr, |
| 99 | DlCtrlOptOctets opt optional, |
Harald Welte | 9d34852 | 2017-08-01 00:27:39 +0200 | [diff] [blame] | 100 | RlcmacDlCtrlMsg payload |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 101 | } with { |
| 102 | variant (opt) "PRESENCE(mac_hdr.payload_type = MAC_PT_RLCMAC_OPT)" |
| 103 | }; |
| 104 | |
| 105 | external function enc_RlcmacDlCtrlBlock(in RlcmacDlCtrlBlock si) return octetstring |
| 106 | with { extension "prototype(convert) encode(RAW)" }; |
| 107 | external function dec_RlcmacDlCtrlBlock(in octetstring stream) return RlcmacDlCtrlBlock |
| 108 | with { extension "prototype(convert) decode(RAW)" }; |
| 109 | |
| 110 | type record UlMacCtrlHeader { |
Harald Welte | efbc2fc | 2017-07-31 00:05:23 +0200 | [diff] [blame] | 111 | MacPayloadType payload_type, |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 112 | BIT5 spare, |
| 113 | boolean retry |
| 114 | } with { variant (retry) "FIELDLENGTH(1)" }; |
| 115 | |
| 116 | /* TS 44.060 10.3.2 UplinkRLC/MAC control block */ |
| 117 | type record RlcmacUlCtrlBlock { |
| 118 | UlMacCtrlHeader mac_hdr, |
Harald Welte | 9d34852 | 2017-08-01 00:27:39 +0200 | [diff] [blame] | 119 | RlcmacUlCtrlMsg payload |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 120 | } with { variant "" }; |
| 121 | |
| 122 | external function enc_RlcmacUlCtrlBlock(in RlcmacUlCtrlBlock si) return octetstring |
| 123 | with { extension "prototype(convert) encode(RAW)" }; |
| 124 | external function dec_RlcmacUlCtrlBlock(in octetstring stream) return RlcmacUlCtrlBlock |
| 125 | with { extension "prototype(convert) decode(RAW)" }; |
| 126 | |
| 127 | /* a single RLC block / LLC-segment */ |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame] | 128 | type record LlcBlockHdr { |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 129 | uint6_t length_ind, |
| 130 | /* 1 = new LLC PDU starts */ |
Harald Welte | 060e27a | 2018-03-03 20:38:19 +0100 | [diff] [blame] | 131 | boolean more, |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 132 | /* 0 = another extension octet after LLC PDU, 1 = no more extension octets */ |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame] | 133 | boolean e |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 134 | } with { |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame] | 135 | variant (e) "FIELDLENGTH(1)" |
Harald Welte | cc5c115 | 2018-03-09 12:54:01 +0100 | [diff] [blame] | 136 | encode "RAW" |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 137 | }; |
Harald Welte | cc5c115 | 2018-03-09 12:54:01 +0100 | [diff] [blame] | 138 | |
| 139 | external function enc_LlcBlockHdr(in LlcBlockHdr si) return octetstring |
| 140 | with { extension "prototype(convert) encode(RAW)" }; |
| 141 | external function dec_LlcBlockHdr(in octetstring stream) return LlcBlockHdr |
| 142 | with { extension "prototype(convert) decode(RAW)" }; |
| 143 | |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame] | 144 | type record LlcBlock { |
| 145 | /* Header is only present if LI field was present */ |
Harald Welte | 060e27a | 2018-03-03 20:38:19 +0100 | [diff] [blame] | 146 | LlcBlockHdr hdr optional, |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame] | 147 | octetstring payload |
| 148 | } with { variant "" }; |
| 149 | type record of LlcBlock LlcBlocks; |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 150 | |
| 151 | /* TS 44.060 10.2.1 Downlink RLC data block */ |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame] | 152 | type record DlMacHdrDataExt { |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 153 | /* Octet 1 */ |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 154 | PowerReduction pr, |
| 155 | BIT1 spare, |
| 156 | uint4_t tfi, /* 3 or 4? */ |
| 157 | boolean fbi, |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame] | 158 | /* Octet 2 */ |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 159 | uint7_t bsn, |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame] | 160 | boolean e |
| 161 | } with { |
| 162 | variant (e) "FIELDLENGTH(1)" |
| 163 | }; |
| 164 | type record DlMacDataHeader { |
| 165 | DlMacHeader mac_hdr, |
| 166 | DlMacHdrDataExt hdr_ext |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 167 | } with { variant "" }; |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame] | 168 | type record RlcmacDlDataBlock { |
| 169 | DlMacDataHeader mac_hdr, |
| 170 | /* Octet 3..M / N: manual C++ Decoder */ |
| 171 | LlcBlocks blocks |
| 172 | } with { |
| 173 | variant "" |
| 174 | }; |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 175 | |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame] | 176 | external function enc_RlcmacDlDataBlock(in RlcmacDlDataBlock si) return octetstring; |
| 177 | external function dec_RlcmacDlDataBlock(in octetstring stream) return RlcmacDlDataBlock; |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 178 | |
| 179 | |
| 180 | /* TS 44.060 10.2.2 */ |
| 181 | type record UlMacDataHeader { |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame] | 182 | /* Octet 0 */ |
Harald Welte | efbc2fc | 2017-07-31 00:05:23 +0200 | [diff] [blame] | 183 | MacPayloadType payload_type, |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 184 | uint4_t countdown, |
| 185 | boolean stall_ind, |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame] | 186 | boolean retry, |
| 187 | /* Octet 1 */ |
| 188 | BIT1 spare, |
| 189 | boolean pfi_ind, |
| 190 | uint5_t tfi, |
| 191 | boolean tlli_ind, |
| 192 | /* Octet 2 */ |
| 193 | uint7_t bsn, |
| 194 | boolean e |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 195 | } with { |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame] | 196 | variant (stall_ind) "FIELDLENGTH(1)" |
| 197 | variant (retry) "FIELDLENGTH(1)" |
| 198 | variant (pfi_ind) "FIELDLENGTH(1)" |
| 199 | variant (tlli_ind) "FIELDLENGTH(1)" |
| 200 | variant (e) "FIELDLENGTH(1)" |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 201 | }; |
| 202 | |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 203 | type record RlcMacUlPfi { |
| 204 | uint7_t pfi, |
| 205 | boolean m |
| 206 | } with { |
| 207 | variant (m) "FIELDLENGTH(1)" |
| 208 | }; |
| 209 | |
| 210 | /* TS 44.060 10.2.2 */ |
| 211 | type record RlcmacUlDataBlock { |
| 212 | /* MAC header */ |
| 213 | UlMacDataHeader mac_hdr, |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame] | 214 | /* Octet 3 ... M (optional): manual C++ Decoder */ |
| 215 | GprsTlli tlli optional, |
| 216 | RlcMacUlPfi pfi optional, |
| 217 | LlcBlocks blocks |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 218 | } with { |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame] | 219 | variant (tlli) "PRESENCE(mac_hdr.tlli_ind = true)" |
| 220 | variant (pfi) "PRESENCE(mac_hdr.pfi_ind = true)" |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 221 | }; |
| 222 | |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame] | 223 | external function enc_RlcmacUlDataBlock(in RlcmacUlDataBlock si) return octetstring; |
| 224 | external function dec_RlcmacUlDataBlock(in octetstring stream) return RlcmacUlDataBlock; |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 225 | |
Harald Welte | efbc2fc | 2017-07-31 00:05:23 +0200 | [diff] [blame] | 226 | type union RlcmacUlBlock { |
| 227 | RlcmacUlDataBlock data, |
| 228 | RlcmacUlCtrlBlock ctrl |
| 229 | } with { |
| 230 | variant "TAG(data, mac_hdr.payload_type = MAC_PT_RLC_DATA; |
| 231 | ctrl, mac_hdr.payload_type = MAC_PT_RLCMAC_NO_OPT; |
| 232 | ctrl, mac_hdr.payload_type = MAC_PT_RLCMAC_OPT)" |
| 233 | }; |
| 234 | |
Harald Welte | 78a1af6 | 2017-07-31 17:33:56 +0200 | [diff] [blame] | 235 | /* as the sub-types (RlcmacDl*Block) are not using the RAW coder, we cannot |
| 236 | * use auto-generated functions here, as they would decode those sub-types |
| 237 | * based on the RAW coder, not baed on the manual C++ functions */ |
| 238 | external function enc_RlcmacUlBlock(in RlcmacUlBlock si) return octetstring; |
| 239 | external function dec_RlcmacUlBlock(in octetstring stream) return RlcmacUlBlock; |
Harald Welte | efbc2fc | 2017-07-31 00:05:23 +0200 | [diff] [blame] | 240 | |
| 241 | type union RlcmacDlBlock { |
| 242 | RlcmacDlDataBlock data, |
| 243 | RlcmacDlCtrlBlock ctrl |
| 244 | } with { |
| 245 | variant "TAG(data, mac_hdr.mac_hdr.payload_type = MAC_PT_RLC_DATA; |
| 246 | ctrl, mac_hdr.payload_type = MAC_PT_RLCMAC_NO_OPT; |
| 247 | ctrl, mac_hdr.payload_type = MAC_PT_RLCMAC_OPT)" |
| 248 | }; |
| 249 | |
Harald Welte | 78a1af6 | 2017-07-31 17:33:56 +0200 | [diff] [blame] | 250 | /* as the sub-types (RlcmacDl*Block) are not using the RAW coder, we cannot |
| 251 | * use auto-generated functions here, as they would decode those sub-types |
| 252 | * based on the RAW coder, not baed on the manual C++ functions */ |
| 253 | external function enc_RlcmacDlBlock(in RlcmacDlBlock si) return octetstring; |
| 254 | external function dec_RlcmacDlBlock(in octetstring stream) return RlcmacDlBlock; |
Harald Welte | efbc2fc | 2017-07-31 00:05:23 +0200 | [diff] [blame] | 255 | |
Harald Welte | 7024baa | 2018-03-02 23:37:51 +0100 | [diff] [blame] | 256 | template (value) RlcmacUlBlock ts_RLC_UL_CTRL_ACK(RlcmacUlCtrlMsg ctrl, |
| 257 | MacPayloadType pt := MAC_PT_RLCMAC_NO_OPT, |
| 258 | boolean retry := false) := { |
| 259 | ctrl := { |
| 260 | mac_hdr := { |
| 261 | payload_type := pt, |
| 262 | spare := '00000'B, |
| 263 | retry := retry |
| 264 | }, |
| 265 | payload := ctrl |
| 266 | } |
| 267 | } |
| 268 | |
Pau Espin Pedrol | a3f0a85 | 2019-12-02 19:16:26 +0100 | [diff] [blame] | 269 | /* Send Template for Downlink ACK/NACK */ |
| 270 | template RlcmacUlBlock ts_RLCMAC_DL_ACK_NACK(template uint5_t tfi, AckNackDescription andesc, boolean retry := false) := { |
| 271 | ctrl := { |
| 272 | mac_hdr := { |
| 273 | payload_type := MAC_PT_RLCMAC_NO_OPT, |
| 274 | spare := '00000'B, |
| 275 | retry := retry |
| 276 | }, |
| 277 | payload := { |
| 278 | msg_type := PACKET_DL_ACK_NACK, |
| 279 | u := { |
| 280 | dl_ack_nack := { |
| 281 | dl_tfi := tfi, |
| 282 | ack_nack_desc := andesc, |
| 283 | chreq_desc_presence := '0'B, |
| 284 | chreq_desc := omit, |
| 285 | ch_qual_rep := c_ChQualRep_default |
| 286 | } |
| 287 | } |
| 288 | } |
| 289 | } |
| 290 | } |
| 291 | |
| 292 | /* Template for uplink Data block */ |
Harald Welte | 060e27a | 2018-03-03 20:38:19 +0100 | [diff] [blame] | 293 | template RlcmacUlBlock t_RLCMAC_UL_DATA(template uint5_t tfi, template uint4_t cv, template uint7_t bsn, |
| 294 | template LlcBlocks blocks := {}, template boolean stall := false) := { |
| 295 | data := { |
| 296 | mac_hdr := { |
| 297 | payload_type := MAC_PT_RLC_DATA, |
| 298 | countdown := cv, |
| 299 | stall_ind := false, |
| 300 | retry := false, |
| 301 | spare := '0'B, |
| 302 | pfi_ind := false, |
| 303 | tfi := tfi, |
| 304 | tlli_ind := false, |
| 305 | bsn := bsn, |
| 306 | e := false |
| 307 | }, |
| 308 | tlli := omit, |
| 309 | pfi := omit, |
| 310 | blocks := blocks |
| 311 | } |
| 312 | } |
| 313 | template RlcmacUlBlock t_RLCMAC_UL_DATA_TLLI(template uint5_t tfi, template uint4_t cv, template uint7_t bsn, |
| 314 | template LlcBlocks blocks := {}, template boolean stall := false, template GprsTlli tlli) := { |
| 315 | data := { |
| 316 | mac_hdr := { |
| 317 | payload_type := MAC_PT_RLC_DATA, |
| 318 | countdown := cv, |
| 319 | stall_ind := false, |
| 320 | retry := false, |
| 321 | spare := '0'B, |
| 322 | pfi_ind := false, |
| 323 | tfi := tfi, |
| 324 | tlli_ind := true, |
| 325 | bsn := bsn, |
| 326 | e := false |
| 327 | }, |
| 328 | tlli := tlli, |
| 329 | pfi := omit, |
| 330 | blocks := blocks |
| 331 | } |
| 332 | } |
| 333 | |
| 334 | template DlMacHeader t_RLCMAC_DlMacH(template MacPayloadType pt, template MacRrbp rrbp, template |
| 335 | uint3_t usf) := { |
| 336 | payload_type := pt, |
| 337 | rrbp := rrbp, |
| 338 | rrbp_valid := ispresent(rrbp), |
| 339 | usf := usf |
| 340 | } |
| 341 | |
Oliver Smith | 8f9daab | 2019-10-09 09:27:19 +0200 | [diff] [blame] | 342 | template RlcmacDlBlock tr_RLCMAC_DUMMY_CTRL(template uint3_t usf := ?, template PageMode page_mode := ?) := { |
Pau Espin Pedrol | 596faa4 | 2019-10-04 19:31:29 +0200 | [diff] [blame] | 343 | ctrl := { |
| 344 | mac_hdr := { |
| 345 | payload_type := (MAC_PT_RLCMAC_NO_OPT, MAC_PT_RLCMAC_OPT), |
| 346 | rrbp:= ?, |
| 347 | rrbp_valid := ?, |
| 348 | usf := usf |
| 349 | }, |
| 350 | opt := *, |
| 351 | payload := { |
| 352 | msg_type := PACKET_DL_DUMMY_CTRL, |
| 353 | u := { |
| 354 | dl_dummy := { |
Oliver Smith | 8f9daab | 2019-10-09 09:27:19 +0200 | [diff] [blame] | 355 | page_mode := page_mode, |
Pau Espin Pedrol | 596faa4 | 2019-10-04 19:31:29 +0200 | [diff] [blame] | 356 | persistence_levels_present := ?, |
| 357 | persistence_levels := * |
| 358 | } |
| 359 | } |
| 360 | } |
| 361 | } |
| 362 | } |
| 363 | |
Pau Espin Pedrol | ff8da19 | 2019-12-05 17:23:58 +0100 | [diff] [blame] | 364 | template RlcmacDlBlock tr_RLCMAC_DL_PACKET_ASS(template uint3_t usf := ?) := { |
| 365 | ctrl := { |
| 366 | mac_hdr := { |
| 367 | payload_type := (MAC_PT_RLCMAC_NO_OPT, MAC_PT_RLCMAC_OPT), |
| 368 | rrbp:= ?, |
| 369 | rrbp_valid := ?, |
| 370 | usf := usf |
| 371 | }, |
| 372 | opt := *, |
| 373 | payload := { |
| 374 | msg_type := PACKET_DL_ASSIGNMENT, |
| 375 | u := { |
| 376 | dl_assignment := { |
| 377 | page_mode := ?, |
| 378 | pres1 := ?, |
| 379 | persistence_levels := *, |
| 380 | tfi_or_tlli := ? |
| 381 | } |
| 382 | } |
| 383 | } |
| 384 | } |
| 385 | } |
| 386 | |
Pau Espin Pedrol | 2165963 | 2019-12-02 19:12:08 +0100 | [diff] [blame] | 387 | /* Receive Template for Uplink ACK/NACK */ |
| 388 | template RlcmacDlBlock tr_RLCMAC_UL_ACK_NACK(template uint5_t ul_tfi, template GprsTlli tlli := ?) := { |
Harald Welte | 060e27a | 2018-03-03 20:38:19 +0100 | [diff] [blame] | 389 | ctrl := { |
| 390 | mac_hdr := { |
| 391 | payload_type := (MAC_PT_RLCMAC_NO_OPT, MAC_PT_RLCMAC_OPT), |
| 392 | rrbp:= ?, |
Vadim Yanitskiy | 0eb2662 | 2019-09-14 20:35:28 +0200 | [diff] [blame] | 393 | rrbp_valid := ?, |
Harald Welte | 060e27a | 2018-03-03 20:38:19 +0100 | [diff] [blame] | 394 | usf := ? |
| 395 | }, |
| 396 | opt := *, |
| 397 | payload := { |
| 398 | msg_type := PACKET_UL_ACK_NACK, |
| 399 | u := { |
| 400 | ul_ack_nack := { |
| 401 | page_mode := ?, |
| 402 | msg_excape := ?, |
| 403 | uplink_tfi := ul_tfi, |
| 404 | is_egprs := '0'B, |
| 405 | gprs := { |
| 406 | ch_coding_cmd := ?, |
| 407 | ack_nack_desc := ?, |
| 408 | cont_res_tlli_present := ?, |
| 409 | cont_res_tlli := tlli, |
| 410 | pkt_ta_present := ?, |
| 411 | pkt_ta := *, |
| 412 | pwr_ctrl_present := ?, |
| 413 | pwr_ctrl := * |
| 414 | } |
| 415 | } |
| 416 | } |
| 417 | } |
| 418 | } |
| 419 | } |
| 420 | |
Oliver Smith | 8f9daab | 2019-10-09 09:27:19 +0200 | [diff] [blame] | 421 | template RlcmacDlBlock tr_RLCMAC_PACKET_PAG_REQ(template uint3_t usf := ?) := { |
| 422 | ctrl := { |
| 423 | mac_hdr := { |
| 424 | payload_type := MAC_PT_RLCMAC_NO_OPT, |
| 425 | rrbp:= ?, |
| 426 | rrbp_valid := ?, |
| 427 | usf := usf |
| 428 | }, |
| 429 | opt := *, |
| 430 | payload := { |
| 431 | msg_type := PACKET_PAGING_REQUEST, |
| 432 | u := { |
| 433 | paging := { |
| 434 | page_mode := ?, |
| 435 | persistence_levels_present := ?, |
| 436 | persistence_levels := *, |
| 437 | nln_present := ?, |
| 438 | nln := *, |
| 439 | repeated_pageinfo_present := ?, |
| 440 | repeated_pageinfo := * |
| 441 | } |
| 442 | } |
| 443 | } |
| 444 | } |
| 445 | } |
| 446 | |
Harald Welte | b669ee0 | 2018-03-09 12:50:02 +0100 | [diff] [blame] | 447 | template RlcmacDlBlock tr_RLCMAC_DATA_RRBP := { |
| 448 | data := { |
| 449 | mac_hdr := { |
| 450 | mac_hdr := { |
| 451 | payload_type := MAC_PT_RLC_DATA, |
| 452 | rrbp := ?, |
| 453 | rrbp_valid := true, |
| 454 | usf := ? |
| 455 | }, |
| 456 | hdr_ext := ? |
| 457 | }, |
| 458 | blocks := ? |
| 459 | } |
| 460 | } |
| 461 | |
Harald Welte | 060e27a | 2018-03-03 20:38:19 +0100 | [diff] [blame] | 462 | /* Template for Uplink MAC Control Header */ |
| 463 | template UlMacCtrlHeader t_RLCMAC_UlMacCtrlH(template MacPayloadType pt, template boolean retry := false) := { |
| 464 | payload_type := pt, |
| 465 | spare := '00000'B, |
| 466 | retry := retry |
| 467 | } |
| 468 | |
Pau Espin Pedrol | 2165963 | 2019-12-02 19:12:08 +0100 | [diff] [blame] | 469 | /* Template for Uplink Control ACK */ |
Harald Welte | 060e27a | 2018-03-03 20:38:19 +0100 | [diff] [blame] | 470 | template RlcmacUlBlock ts_RLCMAC_CTRL_ACK(GprsTlli tlli, CtrlAck ack := MS_RCVD_TWO_RLC_SAME_RTI_DIFF_RBSN) := { |
| 471 | ctrl := { |
| 472 | mac_hdr := t_RLCMAC_UlMacCtrlH(MAC_PT_RLCMAC_NO_OPT), |
| 473 | payload := { |
| 474 | msg_type := PACKET_CONTROL_ACK, |
| 475 | u := { |
| 476 | ctrl_ack := { |
| 477 | tlli := tlli, |
| 478 | ctrl_ack := ack |
| 479 | } |
| 480 | } |
| 481 | } |
| 482 | } |
| 483 | } |
| 484 | |
| 485 | /* Template for a LlcBlock (part of a LLC frame inside RlcMac?lDataBlock */ |
| 486 | template LlcBlock t_RLCMAC_LLCBLOCK(octetstring data, boolean more := false, boolean e := true) := { |
| 487 | /* let encoder figure out the header */ |
| 488 | hdr := omit, |
| 489 | payload := data |
| 490 | } |
| 491 | |
Vadim Yanitskiy | 1bd8ec5 | 2019-10-01 05:44:52 +0700 | [diff] [blame] | 492 | /* PTCCH/D (Packet Timing Advance Control Channel) message. |
| 493 | * TODO: add a spec. reference to the message format definition. */ |
| 494 | type record PTCCHTimingAdvanceIE { |
| 495 | BIT1 spare ('0'B), |
| 496 | uint7_t ta_val |
| 497 | } with { variant "" }; |
| 498 | type record of PTCCHTimingAdvanceIE PTCCHTimingAdvanceIEs; |
| 499 | type record PTCCHDownlinkMsg { |
| 500 | PTCCHTimingAdvanceIEs ta_idx length(16), |
| 501 | octetstring padding length(7) |
| 502 | } with { variant "" }; |
| 503 | |
| 504 | external function enc_PTCCHDownlinkMsg(in PTCCHDownlinkMsg si) return octetstring |
| 505 | with { extension "prototype(convert) encode(RAW)" }; |
| 506 | external function dec_PTCCHDownlinkMsg(in octetstring stream) return PTCCHDownlinkMsg |
| 507 | with { extension "prototype(convert) decode(RAW)" }; |
| 508 | |
| 509 | template PTCCHDownlinkMsg tr_PTCCHDownlinkMsg( |
| 510 | template (present) uint7_t tai0_ta := ?, |
| 511 | template (present) uint7_t tai1_ta := ?, |
| 512 | template (present) uint7_t tai2_ta := ?, |
| 513 | template (present) uint7_t tai3_ta := ?, |
| 514 | template (present) uint7_t tai4_ta := ?, |
| 515 | template (present) uint7_t tai5_ta := ?, |
| 516 | template (present) uint7_t tai6_ta := ?, |
| 517 | template (present) uint7_t tai7_ta := ?, |
| 518 | template (present) uint7_t tai8_ta := ?, |
| 519 | template (present) uint7_t tai9_ta := ?, |
| 520 | template (present) uint7_t tai10_ta := ?, |
| 521 | template (present) uint7_t tai11_ta := ?, |
| 522 | template (present) uint7_t tai12_ta := ?, |
| 523 | template (present) uint7_t tai13_ta := ?, |
| 524 | template (present) uint7_t tai14_ta := ?, |
| 525 | template (present) uint7_t tai15_ta := ? |
| 526 | ) := { |
| 527 | ta_idx := { |
| 528 | { spare := '0'B, ta_val := tai0_ta }, |
| 529 | { spare := '0'B, ta_val := tai1_ta }, |
| 530 | { spare := '0'B, ta_val := tai2_ta }, |
| 531 | { spare := '0'B, ta_val := tai3_ta }, |
| 532 | { spare := '0'B, ta_val := tai4_ta }, |
| 533 | { spare := '0'B, ta_val := tai5_ta }, |
| 534 | { spare := '0'B, ta_val := tai6_ta }, |
| 535 | { spare := '0'B, ta_val := tai7_ta }, |
| 536 | { spare := '0'B, ta_val := tai8_ta }, |
| 537 | { spare := '0'B, ta_val := tai9_ta }, |
| 538 | { spare := '0'B, ta_val := tai10_ta }, |
| 539 | { spare := '0'B, ta_val := tai11_ta }, |
| 540 | { spare := '0'B, ta_val := tai12_ta }, |
| 541 | { spare := '0'B, ta_val := tai13_ta }, |
| 542 | { spare := '0'B, ta_val := tai14_ta }, |
| 543 | { spare := '0'B, ta_val := tai15_ta } |
| 544 | }, |
| 545 | padding := '2B2B2B2B2B2B2B'O |
| 546 | } |
| 547 | |
Harald Welte | 060e27a | 2018-03-03 20:38:19 +0100 | [diff] [blame] | 548 | |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 549 | } with { encode "RAW"; variant "FIELDORDER(msb)" } |