New upstream version 18.11-rc1
[deb_dpdk.git] / drivers / net / dpaa2 / base / dpaa2_hw_dpni_annot.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  *
3  *   Copyright (c) 2016 Freescale Semiconductor, Inc. All rights reserved.
4  *   Copyright 2016 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 }  __attribute__((__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 /* Debug frame, otherwise supposed to be discarded */
257 #define DPAA2_ETH_FAS_DISC            0x80000000
258 /* MACSEC frame */
259 #define DPAA2_ETH_FAS_MS                0x40000000
260 #define DPAA2_ETH_FAS_PTP              0x08000000
261 /* Ethernet multicast frame */
262 #define DPAA2_ETH_FAS_MC                0x04000000
263 /* Ethernet broadcast frame */
264 #define DPAA2_ETH_FAS_BC                0x02000000
265 #define DPAA2_ETH_FAS_KSE              0x00040000
266 #define DPAA2_ETH_FAS_EOFHE          0x00020000
267 #define DPAA2_ETH_FAS_MNLE            0x00010000
268 #define DPAA2_ETH_FAS_TIDE            0x00008000
269 #define DPAA2_ETH_FAS_PIEE            0x00004000
270 /* Frame length error */
271 #define DPAA2_ETH_FAS_FLE              0x00002000
272 /* Frame physical error; our favourite pastime */
273 #define DPAA2_ETH_FAS_FPE              0x00001000
274 #define DPAA2_ETH_FAS_PTE              0x00000080
275 #define DPAA2_ETH_FAS_ISP              0x00000040
276 #define DPAA2_ETH_FAS_PHE              0x00000020
277 #define DPAA2_ETH_FAS_BLE              0x00000010
278 /* L3 csum validation performed */
279 #define DPAA2_ETH_FAS_L3CV            0x00000008
280 /* L3 csum error */
281 #define DPAA2_ETH_FAS_L3CE            0x00000004
282 /* L4 csum validation performed */
283 #define DPAA2_ETH_FAS_L4CV            0x00000002
284 /* L4 csum error */
285 #define DPAA2_ETH_FAS_L4CE            0x00000001
286
287 #ifdef __cplusplus
288 }
289 #endif
290
291 #endif