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 */ |
| 2 | module 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 Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame^] | 107 | type record LlcBlockHdr { |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 108 | 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 Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame^] | 112 | boolean e |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 113 | } with { |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame^] | 114 | variant (e) "FIELDLENGTH(1)" |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 115 | }; |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame^] | 116 | 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 Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 122 | |
| 123 | /* TS 44.060 10.2.1 Downlink RLC data block */ |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame^] | 124 | type record DlMacHdrDataExt { |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 125 | /* Octet 1 */ |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 126 | PowerReduction pr, |
| 127 | BIT1 spare, |
| 128 | uint4_t tfi, /* 3 or 4? */ |
| 129 | boolean fbi, |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame^] | 130 | /* Octet 2 */ |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 131 | uint7_t bsn, |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame^] | 132 | boolean e |
| 133 | } with { |
| 134 | variant (e) "FIELDLENGTH(1)" |
| 135 | }; |
| 136 | type record DlMacDataHeader { |
| 137 | DlMacHeader mac_hdr, |
| 138 | DlMacHdrDataExt hdr_ext |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 139 | } with { variant "" }; |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame^] | 140 | type record RlcmacDlDataBlock { |
| 141 | DlMacDataHeader mac_hdr, |
| 142 | /* Octet 3..M / N: manual C++ Decoder */ |
| 143 | LlcBlocks blocks |
| 144 | } with { |
| 145 | variant "" |
| 146 | }; |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 147 | |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame^] | 148 | external function enc_RlcmacDlDataBlock(in RlcmacDlDataBlock si) return octetstring; |
| 149 | external function dec_RlcmacDlDataBlock(in octetstring stream) return RlcmacDlDataBlock; |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 150 | |
| 151 | |
| 152 | /* TS 44.060 10.2.2 */ |
| 153 | type record UlMacDataHeader { |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame^] | 154 | /* Octet 0 */ |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 155 | MacPayloadType pt, |
| 156 | uint4_t countdown, |
| 157 | boolean stall_ind, |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame^] | 158 | 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 Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 167 | } with { |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame^] | 168 | 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 Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 173 | }; |
| 174 | |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 175 | 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 Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame^] | 186 | /* Octet 3 ... M (optional): manual C++ Decoder */ |
| 187 | GprsTlli tlli optional, |
| 188 | RlcMacUlPfi pfi optional, |
| 189 | LlcBlocks blocks |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 190 | } with { |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame^] | 191 | variant (tlli) "PRESENCE(mac_hdr.tlli_ind = true)" |
| 192 | variant (pfi) "PRESENCE(mac_hdr.pfi_ind = true)" |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 193 | }; |
| 194 | |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame^] | 195 | external function enc_RlcmacUlDataBlock(in RlcmacUlDataBlock si) return octetstring; |
| 196 | external function dec_RlcmacUlDataBlock(in octetstring stream) return RlcmacUlDataBlock; |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 197 | |
| 198 | } with { encode "RAW"; variant "FIELDORDER(msb)" } |