1 /* SPDX-License-Identifier: BSD-3-Clause 2 * 3 * Copyright (c) 2016 Freescale Semiconductor, Inc. All rights reserved. 4 * Copyright 2016,2019 NXP 5 * 6 */ 7 8 /** 9 * @file 10 * 11 * DPNI packet parse results - implementation internal 12 */ 13 14 #ifndef _DPAA2_HW_DPNI_ANNOT_H_ 15 #define _DPAA2_HW_DPNI_ANNOT_H_ 16 17 #ifdef __cplusplus 18 extern "C" { 19 #endif 20 21 /* Annotation valid bits in FD FRC */ 22 #define DPAA2_FD_FRC_FASV 0x8000 23 #define DPAA2_FD_FRC_FAEADV 0x4000 24 #define DPAA2_FD_FRC_FAPRV 0x2000 25 #define DPAA2_FD_FRC_FAIADV 0x1000 26 #define DPAA2_FD_FRC_FASWOV 0x0800 27 #define DPAA2_FD_FRC_FAICFDV 0x0400 28 29 /* Annotation bits in FD CTRL */ 30 #define DPAA2_FD_CTRL_ASAL 0x00020000 /* ASAL = 128 */ 31 #define DPAA2_FD_CTRL_PTA 0x00800000 32 #define DPAA2_FD_CTRL_PTV1 0x00400000 33 34 /* Frame annotation status */ 35 struct dpaa2_fas { 36 uint8_t reserved; 37 uint8_t ppid; 38 __le16 ifpid; 39 __le32 status; 40 } __rte_packed; 41 42 /** 43 * HW Packet Annotation Register structures 44 */ 45 struct dpaa2_annot_hdr { 46 /**< word1: Frame Annotation Status (8 bytes)*/ 47 uint64_t word1; 48 49 /**< word2: Time Stamp (8 bytes)*/ 50 uint64_t word2; 51 52 /**< word3: Next Hdr + FAF Extension + FAF (2 + 2 + 4 bytes)*/ 53 uint64_t word3; 54 55 /**< word4: Frame Annotation Flags-FAF (8 bytes) */ 56 uint64_t word4; 57 58 /**< word5: 59 * ShimOffset_1 + ShimOffset_2 + IPPIDOffset + EthOffset + 60 * LLC+SNAPOffset + VLANTCIOffset_1 + VLANTCIOffset_n + 61 * LastETypeOffset (1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 bytes) 62 */ 63 uint64_t word5; 64 65 /**< word6: 66 * PPPoEOffset + MPLSOffset_1 + MPLSOffset_n + ARPorIPOffset_1 67 * + IPOffset_norMInEncapO + GREOffset + L4Offset + 68 * GTPorESPorIPSecOffset(1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 bytes) 69 */ 70 uint64_t word6; 71 72 /**< word7: 73 * RoutingHdrOfset1 + RoutingHdrOfset2 + NxtHdrOffset 74 * + IPv6FragOffset + GrossRunningSum 75 * + RunningSum(1 + 1 + 1 + 1 + 2 + 2 bytes) 76 */ 77 uint64_t word7; 78 79 /**< word8: 80 * ParseErrorcode + Soft Parsing Context (1 + 7 bytes) 81 */ 82 uint64_t word8; 83 }; 84 85 /** 86 * Internal Macros to get/set Packet annotation header 87 */ 88 89 /** General Macro to define a particular bit position*/ 90 #define BIT_POS(x) ((uint64_t)1 << ((x))) 91 /** Set a bit in the variable */ 92 #define BIT_SET_AT_POS(var, pos) ((var) |= (pos)) 93 /** Reset the bit in the variable */ 94 #define BIT_RESET_AT_POS(var, pos) ((var) &= ~(pos)) 95 /** Check the bit is set in the variable */ 96 #define BIT_ISSET_AT_POS(var, pos) (((var) & (pos)) ? 1 : 0) 97 /** 98 * Macrso to define bit position in word3 99 */ 100 #define NEXT_HDR(var) ((uint64_t)(var) & 0xFFFF000000000000) 101 #define FAF_EXTN_IPV6_ROUTE_HDR_PRESENT(var) BIT_POS(16) 102 #define FAF_EXTN_RESERVED(var) ((uint64_t)(var) & 0x00007FFF00000000) 103 #define FAF_USER_DEFINED_RESERVED(var) ((uint64_t)(var) & 0x00000000FF000000) 104 #define SHIM_SHELL_SOFT_PARSING_ERRROR BIT_POS(23) 105 #define PARSING_ERROR BIT_POS(22) 106 #define L2_ETH_MAC_PRESENT BIT_POS(21) 107 #define L2_ETH_MAC_UNICAST BIT_POS(20) 108 #define L2_ETH_MAC_MULTICAST BIT_POS(19) 109 #define L2_ETH_MAC_BROADCAST BIT_POS(18) 110 #define L2_ETH_FRAME_IS_BPDU BIT_POS(17) 111 #define L2_ETH_FCOE_PRESENT BIT_POS(16) 112 #define L2_ETH_FIP_PRESENT BIT_POS(15) 113 #define L2_ETH_PARSING_ERROR BIT_POS(14) 114 #define L2_LLC_SNAP_PRESENT BIT_POS(13) 115 #define L2_UNKNOWN_LLC_OUI BIT_POS(12) 116 #define L2_LLC_SNAP_ERROR BIT_POS(11) 117 #define L2_VLAN_1_PRESENT BIT_POS(10) 118 #define L2_VLAN_N_PRESENT BIT_POS(9) 119 #define L2_VLAN_CFI_BIT_PRESENT BIT_POS(8) 120 #define L2_VLAN_PARSING_ERROR BIT_POS(7) 121 #define L2_PPPOE_PPP_PRESENT BIT_POS(6) 122 #define L2_PPPOE_PPP_PARSING_ERROR BIT_POS(5) 123 #define L2_MPLS_1_PRESENT BIT_POS(4) 124 #define L2_MPLS_N_PRESENT BIT_POS(3) 125 #define L2_MPLS_PARSING_ERROR BIT_POS(2) 126 #define L2_ARP_PRESENT BIT_POS(1) 127 #define L2_ARP_PARSING_ERROR BIT_POS(0) 128 /** 129 * Macrso to define bit position in word4 130 */ 131 #define L2_UNKNOWN_PROTOCOL BIT_POS(63) 132 #define L2_SOFT_PARSING_ERROR BIT_POS(62) 133 #define L3_IPV4_1_PRESENT BIT_POS(61) 134 #define L3_IPV4_1_UNICAST BIT_POS(60) 135 #define L3_IPV4_1_MULTICAST BIT_POS(59) 136 #define L3_IPV4_1_BROADCAST BIT_POS(58) 137 #define L3_IPV4_N_PRESENT BIT_POS(57) 138 #define L3_IPV4_N_UNICAST BIT_POS(56) 139 #define L3_IPV4_N_MULTICAST BIT_POS(55) 140 #define L3_IPV4_N_BROADCAST BIT_POS(54) 141 #define L3_IPV6_1_PRESENT BIT_POS(53) 142 #define L3_IPV6_1_UNICAST BIT_POS(52) 143 #define L3_IPV6_1_MULTICAST BIT_POS(51) 144 #define L3_IPV6_N_PRESENT BIT_POS(50) 145 #define L3_IPV6_N_UNICAST BIT_POS(49) 146 #define L3_IPV6_N_MULTICAST BIT_POS(48) 147 #define L3_IP_1_OPT_PRESENT BIT_POS(47) 148 #define L3_IP_1_UNKNOWN_PROTOCOL BIT_POS(46) 149 #define L3_IP_1_MORE_FRAGMENT BIT_POS(45) 150 #define L3_IP_1_FIRST_FRAGMENT BIT_POS(44) 151 #define L3_IP_1_PARSING_ERROR BIT_POS(43) 152 #define L3_IP_N_OPT_PRESENT BIT_POS(42) 153 #define L3_IP_N_UNKNOWN_PROTOCOL BIT_POS(41) 154 #define L3_IP_N_MORE_FRAGMENT BIT_POS(40) 155 #define L3_IP_N_FIRST_FRAGMENT BIT_POS(39) 156 #define L3_PROTO_ICMP_PRESENT BIT_POS(38) 157 #define L3_PROTO_IGMP_PRESENT BIT_POS(37) 158 #define L3_PROTO_ICMPV6_PRESENT BIT_POS(36) 159 #define L3_PROTO_UDP_LIGHT_PRESENT BIT_POS(35) 160 #define L3_IP_N_PARSING_ERROR BIT_POS(34) 161 #define L3_MIN_ENCAP_PRESENT BIT_POS(33) 162 #define L3_MIN_ENCAP_SBIT_PRESENT BIT_POS(32) 163 #define L3_MIN_ENCAP_PARSING_ERROR BIT_POS(31) 164 #define L3_PROTO_GRE_PRESENT BIT_POS(30) 165 #define L3_PROTO_GRE_RBIT_PRESENT BIT_POS(29) 166 #define L3_PROTO_GRE_PARSING_ERROR BIT_POS(28) 167 #define L3_IP_UNKNOWN_PROTOCOL BIT_POS(27) 168 #define L3_SOFT_PARSING_ERROR BIT_POS(26) 169 #define L3_PROTO_UDP_PRESENT BIT_POS(25) 170 #define L3_PROTO_UDP_PARSING_ERROR BIT_POS(24) 171 #define L3_PROTO_TCP_PRESENT BIT_POS(23) 172 #define L3_PROTO_TCP_OPT_PRESENT BIT_POS(22) 173 #define L3_PROTO_TCP_CTRL_BIT_6_TO_11_PRESENT BIT_POS(21) 174 #define L3_PROTO_TCP_CTRL_BIT_3_TO_5_PRESENT BIT_POS(20) 175 #define L3_PROTO_TCP_PARSING_ERROR BIT_POS(19) 176 #define L3_PROTO_IPSEC_PRESENT BIT_POS(18) 177 #define L3_PROTO_IPSEC_ESP_PRESENT BIT_POS(17) 178 #define L3_PROTO_IPSEC_AH_PRESENT BIT_POS(16) 179 #define L3_PROTO_IPSEC_PARSING_ERROR BIT_POS(15) 180 #define L3_PROTO_SCTP_PRESENT BIT_POS(14) 181 #define L3_PROTO_SCTP_PARSING_ERROR BIT_POS(13) 182 #define L3_PROTO_DCCP_PRESENT BIT_POS(12) 183 #define L3_PROTO_DCCP_PARSING_ERROR BIT_POS(11) 184 #define L4_UNKNOWN_PROTOCOL BIT_POS(10) 185 #define L4_SOFT_PARSING_ERROR BIT_POS(9) 186 #define L3_PROTO_GTP_PRESENT BIT_POS(8) 187 #define L3_PROTO_GTP_PARSING_ERROR BIT_POS(7) 188 #define L3_PROTO_ESP_PRESENT BIT_POS(6) 189 #define L3_PROTO_ESP_PARSING_ERROR BIT_POS(5) 190 #define L3_PROTO_ISCSI_PRESENT BIT_POS(4) 191 #define L3_PROTO_CAPWAN__CTRL_PRESENT BIT_POS(3) 192 #define L3_PROTO_CAPWAN__DATA_PRESENT BIT_POS(2) 193 #define L5_SOFT_PARSING_ERROR BIT_POS(1) 194 #define L3_IPV6_ROUTE_HDR_PRESENT BIT_POS(0) 195 196 #define DPAA2_L3_IPv4 (L3_IPV4_1_PRESENT | L3_IPV4_1_UNICAST | \ 197 L3_IP_1_UNKNOWN_PROTOCOL | L3_IP_UNKNOWN_PROTOCOL) 198 199 #define DPAA2_L3_IPv6 (L3_IPV6_1_PRESENT | L3_IPV6_1_UNICAST | \ 200 L3_IP_1_UNKNOWN_PROTOCOL | L3_IP_UNKNOWN_PROTOCOL) 201 202 #define DPAA2_L3_IPv4_TCP (L3_IPV4_1_PRESENT | L3_IPV4_1_UNICAST | \ 203 L3_PROTO_TCP_PRESENT | L3_PROTO_TCP_CTRL_BIT_6_TO_11_PRESENT | \ 204 L4_UNKNOWN_PROTOCOL) 205 206 #define DPAA2_L3_IPv4_UDP (L3_IPV4_1_PRESENT | L3_IPV4_1_UNICAST | \ 207 L3_PROTO_UDP_PRESENT | L4_UNKNOWN_PROTOCOL) 208 209 #define DPAA2_L3_IPv6_TCP (L3_IPV6_1_PRESENT | L3_IPV6_1_UNICAST | \ 210 L3_PROTO_TCP_PRESENT | L3_PROTO_TCP_CTRL_BIT_6_TO_11_PRESENT | \ 211 L4_UNKNOWN_PROTOCOL) 212 213 #define DPAA2_L3_IPv6_UDP (L3_IPV6_1_PRESENT | L3_IPV6_1_UNICAST | \ 214 L3_PROTO_UDP_PRESENT | L4_UNKNOWN_PROTOCOL) 215 216 /** 217 * Macros to get values in word5 218 */ 219 #define SHIM_OFFSET_1(var) ((uint64_t)(var) & 0xFF00000000000000) 220 #define SHIM_OFFSET_2(var) ((uint64_t)(var) & 0x00FF000000000000) 221 #define IP_PID_OFFSET(var) ((uint64_t)(var) & 0x0000FF0000000000) 222 #define ETH_OFFSET(var) ((uint64_t)(var) & 0x000000FF00000000) 223 #define LLC_SNAP_OFFSET(var) ((uint64_t)(var) & 0x00000000FF000000) 224 #define VLAN_TCI_OFFSET_1(var) ((uint64_t)(var) & 0x0000000000FF0000) 225 #define VLAN_TCI_OFFSET_N(var) ((uint64_t)(var) & 0x000000000000FF00) 226 #define LAST_ETYPE_OFFSET(var) ((uint64_t)(var) & 0x00000000000000FF) 227 228 /** 229 * Macros to get values in word6 230 */ 231 #define PPPOE_OFFSET(var) ((uint64_t)(var) & 0xFF00000000000000) 232 #define MPLS_OFFSET_1(var) ((uint64_t)(var) & 0x00FF000000000000) 233 #define MPLS_OFFSET_N(var) ((uint64_t)(var) & 0x0000FF0000000000) 234 #define ARP_OR_IP_OFFSET_1(var) ((uint64_t)(var) & 0x000000FF00000000) 235 #define IP_N_OR_MIN_ENCAP_OFFSET(var) ((uint64_t)(var) & 0x00000000FF000000) 236 #define GRE_OFFSET(var) ((uint64_t)(var) & 0x0000000000FF0000) 237 #define L4_OFFSET(var) ((uint64_t)(var) & 0x000000000000FF00) 238 #define GTP_OR_ESP_OR_IPSEC_OFFSET(var) ((uint64_t)(var) & 0x00000000000000FF) 239 240 /** 241 * Macros to get values in word7 242 */ 243 #define IPV6_ROUTING_HDR_OFFSET_1(var) ((uint64_t)(var) & 0xFF00000000000000) 244 #define IPV6_ROUTING_HDR_OFFSET_2(var) ((uint64_t)(var) & 0x00FF000000000000) 245 #define NEXT_HDR_OFFSET(var) ((uint64_t)(var) & 0x0000FF0000000000) 246 #define IPV6_FRAG_OFFSET(var) ((uint64_t)(var) & 0x000000FF00000000) 247 #define GROSS_RUNNING_SUM(var) ((uint64_t)(var) & 0x00000000FFFF0000) 248 #define RUNNING_SUM(var) ((uint64_t)(var) & 0x000000000000FFFF) 249 250 /** 251 * Macros to get values in word8 252 */ 253 #define PARSE_ERROR_CODE(var) ((uint64_t)(var) & 0xFF00000000000000) 254 #define SOFT_PARSING_CONTEXT(var) ((uint64_t)(var) & 0x00FFFFFFFFFFFFFF) 255 256 /*FAEAD offset in anmotation area*/ 257 #define DPAA2_FD_HW_ANNOT_FAEAD_OFFSET 0x58 258 259 struct dpaa2_faead { 260 uint32_t fqid; 261 uint32_t ctrl; 262 }; 263 264 /*FAEAD bits */ 265 /*A2 OMB contains valid data*/ 266 #define DPAA2_ANNOT_FAEAD_A2V 0x20000000 267 /*egress confirmation FQID in FAEAD contains valid data*/ 268 #define DPAA2_ANNOT_FAEAD_A4V 0x08000000 269 /*UPD is valid*/ 270 #define DPAA2_ANNOT_FAEAD_UPDV 0x00001000 271 /*EBDD is valid*/ 272 #define DPAA2_ANNOT_FAEAD_EBDDV 0x00002000 273 /*EBDD (External Buffer Deallocation Disable) */ 274 #define DPAA2_ANNOT_FAEAD_EBDD 0x00000020 275 /*UPD (Update prepended data)*/ 276 #define DPAA2_ANNOT_FAEAD_UPD 0x00000010 277 278 /* Debug frame, otherwise supposed to be discarded */ 279 #define DPAA2_ETH_FAS_DISC 0x80000000 280 /* MACSEC frame */ 281 #define DPAA2_ETH_FAS_MS 0x40000000 282 #define DPAA2_ETH_FAS_PTP BIT_POS(59) 283 /* Ethernet multicast frame */ 284 #define DPAA2_ETH_FAS_MC 0x04000000 285 /* Ethernet broadcast frame */ 286 #define DPAA2_ETH_FAS_BC 0x02000000 287 #define DPAA2_ETH_FAS_KSE 0x00040000 288 #define DPAA2_ETH_FAS_EOFHE 0x00020000 289 #define DPAA2_ETH_FAS_MNLE 0x00010000 290 #define DPAA2_ETH_FAS_TIDE 0x00008000 291 #define DPAA2_ETH_FAS_PIEE 0x00004000 292 /* Frame length error */ 293 #define DPAA2_ETH_FAS_FLE 0x00002000 294 /* Frame physical error; our favourite pastime */ 295 #define DPAA2_ETH_FAS_FPE 0x00001000 296 #define DPAA2_ETH_FAS_PTE 0x00000080 297 #define DPAA2_ETH_FAS_ISP 0x00000040 298 #define DPAA2_ETH_FAS_PHE 0x00000020 299 #define DPAA2_ETH_FAS_BLE 0x00000010 300 /* L3 csum validation performed */ 301 #define DPAA2_ETH_FAS_L3CV 0x00000008 302 /* L3 csum error */ 303 #define DPAA2_ETH_FAS_L3CE 0x00000004 304 /* L4 csum validation performed */ 305 #define DPAA2_ETH_FAS_L4CV 0x00000002 306 /* L4 csum error */ 307 #define DPAA2_ETH_FAS_L4CE 0x00000001 308 309 #ifdef __cplusplus 310 } 311 #endif 312 313 #endif 314