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; |
Harald Welte | 9d34852 | 2017-08-01 00:27:39 +0200 | [diff] [blame^] | 6 | import from RLCMAC_CSN1_Types all; |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 7 | |
| 8 | /* TS 44.060 10.4.7 */ |
| 9 | type enumerated MacPayloadType { |
| 10 | MAC_PT_RLC_DATA ('00'B), |
| 11 | MAC_PT_RLCMAC_NO_OPT ('01'B), |
| 12 | MAC_PT_RLCMAC_OPT ('10'B), |
| 13 | MAC_PT_RESERVED ('11'B) |
| 14 | } with { variant "FIELDLENGTH(2)" }; |
| 15 | |
| 16 | /* TS 44.060 10.4.5 */ |
| 17 | type enumerated MacRrbp { |
| 18 | RRBP_Nplus13_mod_2715648 ('00'B), |
| 19 | RRBP_Nplus17_or_18_mod_2715648 ('01'B), |
| 20 | RRBP_Nplus22_or_22_mod_2715648 ('10'B), |
| 21 | RRBP_Nplus26_mod_2715648 ('11'B) |
| 22 | } with { variant "FIELDLENGTH(2)" }; |
| 23 | |
| 24 | /* Partof DL RLC data block and DL RLC/MAC ctrl block */ |
| 25 | type record DlMacHeader { |
| 26 | MacPayloadType payload_type, |
| 27 | MacRrbp rrbp, |
| 28 | boolean rrbp_valid, |
| 29 | uint3_t usf |
| 30 | } with { |
| 31 | variant (rrbp_valid) "FIELDLENGTH(1)" |
| 32 | }; |
| 33 | |
| 34 | /* TS 44.060 10.4.10a */ |
| 35 | type enumerated PowerReduction { |
| 36 | PWR_RED_0_to_3dB ('00'B), |
| 37 | PWR_RED_3_to_7dB ('01'B), |
| 38 | PWR_RED_7_to_10dB ('10'B), |
| 39 | PWR_RED_RESERVED ('11'B) |
| 40 | } with { variant "FIELDLENGTH(2)" }; |
| 41 | |
| 42 | /* TS 44.060 10.4.9d */ |
| 43 | type enumerated DirectionBit { |
| 44 | DIR_UPLINK_TBF ('0'B), |
| 45 | DIR_DOWNLINK_TBF ('1'B) |
| 46 | } with { variant "FIELDLENGTH(1)" }; |
| 47 | |
| 48 | type record TfiOctet { |
| 49 | /* PR, TFI, D */ |
| 50 | PowerReduction pr, |
| 51 | uint5_t tfi, |
| 52 | DirectionBit d |
| 53 | } with { variant "" }; |
| 54 | |
| 55 | type record RbsnExtOctet { |
| 56 | uint3_t rbsn_e, |
| 57 | BIT1 fs_e, |
| 58 | BIT4 spare |
| 59 | } with { variant "" }; |
| 60 | |
| 61 | type record DlCtrlOptOctets { |
| 62 | /* RBSN, RTI, FS, AC (optional, depending on mac_hdr.payload_type) */ |
| 63 | BIT1 rbsn, |
| 64 | uint5_t rti, |
| 65 | boolean fs, |
| 66 | boolean tfi_octet_present, |
| 67 | TfiOctet tfi optional, |
| 68 | RbsnExtOctet rbsn_ext optional |
| 69 | } with { |
| 70 | variant (fs) "FIELDLENGTH(1)" |
| 71 | variant (tfi_octet_present) "FIELDLENGTH(1)" |
| 72 | variant (tfi) "PRESENCE(tfi_octet_present = true)" |
| 73 | variant (rbsn_ext) "PRESENCE(rbsn='1'B, fs=false)" |
| 74 | }; |
| 75 | |
| 76 | /* TS 44.060 10.3.1 Downlink RLC/MAC control block */ |
| 77 | type record RlcmacDlCtrlBlock { |
| 78 | DlMacHeader mac_hdr, |
| 79 | DlCtrlOptOctets opt optional, |
Harald Welte | 9d34852 | 2017-08-01 00:27:39 +0200 | [diff] [blame^] | 80 | RlcmacDlCtrlMsg payload |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 81 | } with { |
| 82 | variant (opt) "PRESENCE(mac_hdr.payload_type = MAC_PT_RLCMAC_OPT)" |
| 83 | }; |
| 84 | |
| 85 | external function enc_RlcmacDlCtrlBlock(in RlcmacDlCtrlBlock si) return octetstring |
| 86 | with { extension "prototype(convert) encode(RAW)" }; |
| 87 | external function dec_RlcmacDlCtrlBlock(in octetstring stream) return RlcmacDlCtrlBlock |
| 88 | with { extension "prototype(convert) decode(RAW)" }; |
| 89 | |
| 90 | type record UlMacCtrlHeader { |
Harald Welte | efbc2fc | 2017-07-31 00:05:23 +0200 | [diff] [blame] | 91 | MacPayloadType payload_type, |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 92 | BIT5 spare, |
| 93 | boolean retry |
| 94 | } with { variant (retry) "FIELDLENGTH(1)" }; |
| 95 | |
| 96 | /* TS 44.060 10.3.2 UplinkRLC/MAC control block */ |
| 97 | type record RlcmacUlCtrlBlock { |
| 98 | UlMacCtrlHeader mac_hdr, |
Harald Welte | 9d34852 | 2017-08-01 00:27:39 +0200 | [diff] [blame^] | 99 | RlcmacUlCtrlMsg payload |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 100 | } with { variant "" }; |
| 101 | |
| 102 | external function enc_RlcmacUlCtrlBlock(in RlcmacUlCtrlBlock si) return octetstring |
| 103 | with { extension "prototype(convert) encode(RAW)" }; |
| 104 | external function dec_RlcmacUlCtrlBlock(in octetstring stream) return RlcmacUlCtrlBlock |
| 105 | with { extension "prototype(convert) decode(RAW)" }; |
| 106 | |
| 107 | /* a single RLC block / LLC-segment */ |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame] | 108 | type record LlcBlockHdr { |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 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 */ |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame] | 113 | boolean e |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 114 | } with { |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame] | 115 | variant (e) "FIELDLENGTH(1)" |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 116 | }; |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame] | 117 | type record LlcBlock { |
| 118 | /* Header is only present if LI field was present */ |
| 119 | LlcBlockHdr hdr, |
| 120 | octetstring payload |
| 121 | } with { variant "" }; |
| 122 | type record of LlcBlock LlcBlocks; |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 123 | |
| 124 | /* TS 44.060 10.2.1 Downlink RLC data block */ |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame] | 125 | type record DlMacHdrDataExt { |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 126 | /* Octet 1 */ |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 127 | PowerReduction pr, |
| 128 | BIT1 spare, |
| 129 | uint4_t tfi, /* 3 or 4? */ |
| 130 | boolean fbi, |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame] | 131 | /* Octet 2 */ |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 132 | uint7_t bsn, |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame] | 133 | boolean e |
| 134 | } with { |
| 135 | variant (e) "FIELDLENGTH(1)" |
| 136 | }; |
| 137 | type record DlMacDataHeader { |
| 138 | DlMacHeader mac_hdr, |
| 139 | DlMacHdrDataExt hdr_ext |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 140 | } with { variant "" }; |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame] | 141 | type record RlcmacDlDataBlock { |
| 142 | DlMacDataHeader mac_hdr, |
| 143 | /* Octet 3..M / N: manual C++ Decoder */ |
| 144 | LlcBlocks blocks |
| 145 | } with { |
| 146 | variant "" |
| 147 | }; |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 148 | |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame] | 149 | external function enc_RlcmacDlDataBlock(in RlcmacDlDataBlock si) return octetstring; |
| 150 | external function dec_RlcmacDlDataBlock(in octetstring stream) return RlcmacDlDataBlock; |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 151 | |
| 152 | |
| 153 | /* TS 44.060 10.2.2 */ |
| 154 | type record UlMacDataHeader { |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame] | 155 | /* Octet 0 */ |
Harald Welte | efbc2fc | 2017-07-31 00:05:23 +0200 | [diff] [blame] | 156 | MacPayloadType payload_type, |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 157 | uint4_t countdown, |
| 158 | boolean stall_ind, |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame] | 159 | boolean retry, |
| 160 | /* Octet 1 */ |
| 161 | BIT1 spare, |
| 162 | boolean pfi_ind, |
| 163 | uint5_t tfi, |
| 164 | boolean tlli_ind, |
| 165 | /* Octet 2 */ |
| 166 | uint7_t bsn, |
| 167 | boolean e |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 168 | } with { |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame] | 169 | variant (stall_ind) "FIELDLENGTH(1)" |
| 170 | variant (retry) "FIELDLENGTH(1)" |
| 171 | variant (pfi_ind) "FIELDLENGTH(1)" |
| 172 | variant (tlli_ind) "FIELDLENGTH(1)" |
| 173 | variant (e) "FIELDLENGTH(1)" |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 174 | }; |
| 175 | |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 176 | type record RlcMacUlPfi { |
| 177 | uint7_t pfi, |
| 178 | boolean m |
| 179 | } with { |
| 180 | variant (m) "FIELDLENGTH(1)" |
| 181 | }; |
| 182 | |
| 183 | /* TS 44.060 10.2.2 */ |
| 184 | type record RlcmacUlDataBlock { |
| 185 | /* MAC header */ |
| 186 | UlMacDataHeader mac_hdr, |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame] | 187 | /* Octet 3 ... M (optional): manual C++ Decoder */ |
| 188 | GprsTlli tlli optional, |
| 189 | RlcMacUlPfi pfi optional, |
| 190 | LlcBlocks blocks |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 191 | } with { |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame] | 192 | variant (tlli) "PRESENCE(mac_hdr.tlli_ind = true)" |
| 193 | variant (pfi) "PRESENCE(mac_hdr.pfi_ind = true)" |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 194 | }; |
| 195 | |
Harald Welte | 43e060a | 2017-07-30 22:38:03 +0200 | [diff] [blame] | 196 | external function enc_RlcmacUlDataBlock(in RlcmacUlDataBlock si) return octetstring; |
| 197 | external function dec_RlcmacUlDataBlock(in octetstring stream) return RlcmacUlDataBlock; |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 198 | |
Harald Welte | efbc2fc | 2017-07-31 00:05:23 +0200 | [diff] [blame] | 199 | type union RlcmacUlBlock { |
| 200 | RlcmacUlDataBlock data, |
| 201 | RlcmacUlCtrlBlock ctrl |
| 202 | } with { |
| 203 | variant "TAG(data, mac_hdr.payload_type = MAC_PT_RLC_DATA; |
| 204 | ctrl, mac_hdr.payload_type = MAC_PT_RLCMAC_NO_OPT; |
| 205 | ctrl, mac_hdr.payload_type = MAC_PT_RLCMAC_OPT)" |
| 206 | }; |
| 207 | |
Harald Welte | 78a1af6 | 2017-07-31 17:33:56 +0200 | [diff] [blame] | 208 | /* as the sub-types (RlcmacDl*Block) are not using the RAW coder, we cannot |
| 209 | * use auto-generated functions here, as they would decode those sub-types |
| 210 | * based on the RAW coder, not baed on the manual C++ functions */ |
| 211 | external function enc_RlcmacUlBlock(in RlcmacUlBlock si) return octetstring; |
| 212 | external function dec_RlcmacUlBlock(in octetstring stream) return RlcmacUlBlock; |
Harald Welte | efbc2fc | 2017-07-31 00:05:23 +0200 | [diff] [blame] | 213 | |
| 214 | type union RlcmacDlBlock { |
| 215 | RlcmacDlDataBlock data, |
| 216 | RlcmacDlCtrlBlock ctrl |
| 217 | } with { |
| 218 | variant "TAG(data, mac_hdr.mac_hdr.payload_type = MAC_PT_RLC_DATA; |
| 219 | ctrl, mac_hdr.payload_type = MAC_PT_RLCMAC_NO_OPT; |
| 220 | ctrl, mac_hdr.payload_type = MAC_PT_RLCMAC_OPT)" |
| 221 | }; |
| 222 | |
Harald Welte | 78a1af6 | 2017-07-31 17:33:56 +0200 | [diff] [blame] | 223 | /* as the sub-types (RlcmacDl*Block) are not using the RAW coder, we cannot |
| 224 | * use auto-generated functions here, as they would decode those sub-types |
| 225 | * based on the RAW coder, not baed on the manual C++ functions */ |
| 226 | external function enc_RlcmacDlBlock(in RlcmacDlBlock si) return octetstring; |
| 227 | external function dec_RlcmacDlBlock(in octetstring stream) return RlcmacDlBlock; |
Harald Welte | efbc2fc | 2017-07-31 00:05:23 +0200 | [diff] [blame] | 228 | |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 229 | } with { encode "RAW"; variant "FIELDORDER(msb)" } |