1 /*-
2  *   BSD LICENSE
3  *
4  *   Copyright (c) 2016 Freescale Semiconductor, Inc. All rights reserved.
5  *   Copyright 2016 NXP.
6  *
7  *   Redistribution and use in source and binary forms, with or without
8  *   modification, are permitted provided that the following conditions
9  *   are met:
10  *
11  *     * Redistributions of source code must retain the above copyright
12  *       notice, this list of conditions and the following disclaimer.
13  *     * Redistributions in binary form must reproduce the above copyright
14  *       notice, this list of conditions and the following disclaimer in
15  *       the documentation and/or other materials provided with the
16  *       distribution.
17  *     * Neither the name of Freescale Semiconductor, Inc nor the names of its
18  *       contributors may be used to endorse or promote products derived
19  *       from this software without specific prior written permission.
20  *
21  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 /**
35  * @file
36  *
37  * DPNI packet parse results - implementation internal
38  */
39 
40 #ifndef _DPAA2_HW_DPNI_ANNOT_H_
41 #define _DPAA2_HW_DPNI_ANNOT_H_
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
47 /* Annotation valid bits in FD FRC */
48 #define DPAA2_FD_FRC_FASV	0x8000
49 #define DPAA2_FD_FRC_FAEADV	0x4000
50 #define DPAA2_FD_FRC_FAPRV	0x2000
51 #define DPAA2_FD_FRC_FAIADV	0x1000
52 #define DPAA2_FD_FRC_FASWOV	0x0800
53 #define DPAA2_FD_FRC_FAICFDV	0x0400
54 
55 /* Annotation bits in FD CTRL */
56 #define DPAA2_FD_CTRL_ASAL	0x00020000      /* ASAL = 128 */
57 #define DPAA2_FD_CTRL_PTA	0x00800000
58 #define DPAA2_FD_CTRL_PTV1	0x00400000
59 
60 /* Frame annotation status */
61 struct dpaa2_fas {
62 	uint8_t reserved;
63 	uint8_t ppid;
64 	__le16 ifpid;
65 	__le32 status;
66 } __packed;
67 
68 /**
69  * HW Packet Annotation  Register structures
70  */
71 struct dpaa2_annot_hdr {
72 	/**<	word1: Frame Annotation Status (8 bytes)*/
73 	uint64_t word1;
74 
75 	/**<	word2: Time Stamp (8 bytes)*/
76 	uint64_t word2;
77 
78 	/**<	word3: Next Hdr + FAF Extension + FAF (2 + 2 + 4 bytes)*/
79 	uint64_t word3;
80 
81 	/**<	word4: Frame Annotation Flags-FAF (8 bytes) */
82 	uint64_t word4;
83 
84 	/**<	word5:
85 	 *	ShimOffset_1 + ShimOffset_2 + IPPIDOffset + EthOffset +
86 	 *	LLC+SNAPOffset + VLANTCIOffset_1 + VLANTCIOffset_n +
87 	 *	LastETypeOffset (1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 bytes)
88 	 */
89 	uint64_t word5;
90 
91 	/**<	word6:
92 	 *	PPPoEOffset + MPLSOffset_1 + MPLSOffset_n + ARPorIPOffset_1
93 	 *	+ IPOffset_norMInEncapO + GREOffset + L4Offset +
94 	 *	GTPorESPorIPSecOffset(1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 bytes)
95 	 */
96 	uint64_t word6;
97 
98 	/**<	word7:
99 	 *	RoutingHdrOfset1 + RoutingHdrOfset2 + NxtHdrOffset
100 	 *	+ IPv6FragOffset + GrossRunningSum
101 	 *	+ RunningSum(1 + 1 + 1 + 1 + 2 + 2 bytes)
102 	 */
103 	uint64_t word7;
104 
105 	/**<	word8:
106 	 *	ParseErrorcode + Soft Parsing Context (1 + 7 bytes)
107 	 */
108 	uint64_t word8;
109 };
110 
111 /**
112  * Internal Macros to get/set Packet annotation header
113  */
114 
115 /** General Macro to define a particular bit position*/
116 #define BIT_POS(x)			((uint64_t)1 << ((x)))
117 /** Set a bit in the variable */
118 #define BIT_SET_AT_POS(var, pos)	((var) |= (pos))
119 /** Reset the bit in the variable */
120 #define BIT_RESET_AT_POS(var, pos)	((var) &= ~(pos))
121 /** Check the bit is set in the variable */
122 #define BIT_ISSET_AT_POS(var, pos)	(((var) & (pos)) ? 1 : 0)
123 /**
124  * Macrso to define bit position in word3
125  */
126 #define NEXT_HDR(var)			((uint64_t)(var) & 0xFFFF000000000000)
127 #define FAF_EXTN_IPV6_ROUTE_HDR_PRESENT(var)	BIT_POS(16)
128 #define FAF_EXTN_RESERVED(var)		((uint64_t)(var) & 0x00007FFF00000000)
129 #define FAF_USER_DEFINED_RESERVED(var)	((uint64_t)(var) & 0x00000000FF000000)
130 #define SHIM_SHELL_SOFT_PARSING_ERRROR		BIT_POS(23)
131 #define PARSING_ERROR				BIT_POS(22)
132 #define L2_ETH_MAC_PRESENT			BIT_POS(21)
133 #define L2_ETH_MAC_UNICAST			BIT_POS(20)
134 #define L2_ETH_MAC_MULTICAST			BIT_POS(19)
135 #define L2_ETH_MAC_BROADCAST			BIT_POS(18)
136 #define L2_ETH_FRAME_IS_BPDU			BIT_POS(17)
137 #define L2_ETH_FCOE_PRESENT			BIT_POS(16)
138 #define L2_ETH_FIP_PRESENT			BIT_POS(15)
139 #define L2_ETH_PARSING_ERROR			BIT_POS(14)
140 #define L2_LLC_SNAP_PRESENT			BIT_POS(13)
141 #define L2_UNKNOWN_LLC_OUI			BIT_POS(12)
142 #define L2_LLC_SNAP_ERROR			BIT_POS(11)
143 #define L2_VLAN_1_PRESENT			BIT_POS(10)
144 #define L2_VLAN_N_PRESENT			BIT_POS(9)
145 #define L2_VLAN_CFI_BIT_PRESENT			BIT_POS(8)
146 #define L2_VLAN_PARSING_ERROR			BIT_POS(7)
147 #define L2_PPPOE_PPP_PRESENT			BIT_POS(6)
148 #define L2_PPPOE_PPP_PARSING_ERROR		BIT_POS(5)
149 #define L2_MPLS_1_PRESENT			BIT_POS(4)
150 #define L2_MPLS_N_PRESENT			BIT_POS(3)
151 #define L2_MPLS_PARSING_ERROR			BIT_POS(2)
152 #define L2_ARP_PRESENT				BIT_POS(1)
153 #define L2_ARP_PARSING_ERROR			BIT_POS(0)
154 /**
155  * Macrso to define bit position in word4
156  */
157 #define L2_UNKNOWN_PROTOCOL			BIT_POS(63)
158 #define L2_SOFT_PARSING_ERROR			BIT_POS(62)
159 #define L3_IPV4_1_PRESENT			BIT_POS(61)
160 #define L3_IPV4_1_UNICAST			BIT_POS(60)
161 #define L3_IPV4_1_MULTICAST			BIT_POS(59)
162 #define L3_IPV4_1_BROADCAST			BIT_POS(58)
163 #define L3_IPV4_N_PRESENT			BIT_POS(57)
164 #define L3_IPV4_N_UNICAST			BIT_POS(56)
165 #define L3_IPV4_N_MULTICAST			BIT_POS(55)
166 #define L3_IPV4_N_BROADCAST			BIT_POS(54)
167 #define L3_IPV6_1_PRESENT			BIT_POS(53)
168 #define L3_IPV6_1_UNICAST			BIT_POS(52)
169 #define L3_IPV6_1_MULTICAST			BIT_POS(51)
170 #define L3_IPV6_N_PRESENT			BIT_POS(50)
171 #define L3_IPV6_N_UNICAST			BIT_POS(49)
172 #define L3_IPV6_N_MULTICAST			BIT_POS(48)
173 #define L3_IP_1_OPT_PRESENT			BIT_POS(47)
174 #define L3_IP_1_UNKNOWN_PROTOCOL		BIT_POS(46)
175 #define L3_IP_1_MORE_FRAGMENT			BIT_POS(45)
176 #define L3_IP_1_FIRST_FRAGMENT			BIT_POS(44)
177 #define L3_IP_1_PARSING_ERROR			BIT_POS(43)
178 #define L3_IP_N_OPT_PRESENT			BIT_POS(42)
179 #define L3_IP_N_UNKNOWN_PROTOCOL		BIT_POS(41)
180 #define L3_IP_N_MORE_FRAGMENT			BIT_POS(40)
181 #define L3_IP_N_FIRST_FRAGMENT			BIT_POS(39)
182 #define L3_PROTO_ICMP_PRESENT			BIT_POS(38)
183 #define L3_PROTO_IGMP_PRESENT			BIT_POS(37)
184 #define L3_PROTO_ICMPV6_PRESENT			BIT_POS(36)
185 #define L3_PROTO_UDP_LIGHT_PRESENT		BIT_POS(35)
186 #define L3_IP_N_PARSING_ERROR			BIT_POS(34)
187 #define L3_MIN_ENCAP_PRESENT			BIT_POS(33)
188 #define L3_MIN_ENCAP_SBIT_PRESENT		BIT_POS(32)
189 #define L3_MIN_ENCAP_PARSING_ERROR		BIT_POS(31)
190 #define L3_PROTO_GRE_PRESENT			BIT_POS(30)
191 #define L3_PROTO_GRE_RBIT_PRESENT		BIT_POS(29)
192 #define L3_PROTO_GRE_PARSING_ERROR		BIT_POS(28)
193 #define L3_IP_UNKNOWN_PROTOCOL			BIT_POS(27)
194 #define L3_SOFT_PARSING_ERROR			BIT_POS(26)
195 #define L3_PROTO_UDP_PRESENT			BIT_POS(25)
196 #define L3_PROTO_UDP_PARSING_ERROR		BIT_POS(24)
197 #define L3_PROTO_TCP_PRESENT			BIT_POS(23)
198 #define L3_PROTO_TCP_OPT_PRESENT		BIT_POS(22)
199 #define L3_PROTO_TCP_CTRL_BIT_6_TO_11_PRESENT	BIT_POS(21)
200 #define L3_PROTO_TCP_CTRL_BIT_3_TO_5_PRESENT	BIT_POS(20)
201 #define L3_PROTO_TCP_PARSING_ERROR		BIT_POS(19)
202 #define L3_PROTO_IPSEC_PRESENT			BIT_POS(18)
203 #define L3_PROTO_IPSEC_ESP_PRESENT		BIT_POS(17)
204 #define L3_PROTO_IPSEC_AH_PRESENT		BIT_POS(16)
205 #define L3_PROTO_IPSEC_PARSING_ERROR		BIT_POS(15)
206 #define L3_PROTO_SCTP_PRESENT			BIT_POS(14)
207 #define L3_PROTO_SCTP_PARSING_ERROR		BIT_POS(13)
208 #define L3_PROTO_DCCP_PRESENT			BIT_POS(12)
209 #define L3_PROTO_DCCP_PARSING_ERROR		BIT_POS(11)
210 #define L4_UNKNOWN_PROTOCOL			BIT_POS(10)
211 #define L4_SOFT_PARSING_ERROR			BIT_POS(9)
212 #define L3_PROTO_GTP_PRESENT			BIT_POS(8)
213 #define L3_PROTO_GTP_PARSING_ERROR		BIT_POS(7)
214 #define L3_PROTO_ESP_PRESENT			BIT_POS(6)
215 #define L3_PROTO_ESP_PARSING_ERROR		BIT_POS(5)
216 #define L3_PROTO_ISCSI_PRESENT			BIT_POS(4)
217 #define L3_PROTO_CAPWAN__CTRL_PRESENT		BIT_POS(3)
218 #define L3_PROTO_CAPWAN__DATA_PRESENT		BIT_POS(2)
219 #define L5_SOFT_PARSING_ERROR			BIT_POS(1)
220 #define L3_IPV6_ROUTE_HDR_PRESENT		BIT_POS(0)
221 
222 /* Debug frame, otherwise supposed to be discarded */
223 #define DPAA2_ETH_FAS_DISC	      0x80000000
224 /* MACSEC frame */
225 #define DPAA2_ETH_FAS_MS		0x40000000
226 #define DPAA2_ETH_FAS_PTP	       0x08000000
227 /* Ethernet multicast frame */
228 #define DPAA2_ETH_FAS_MC		0x04000000
229 /* Ethernet broadcast frame */
230 #define DPAA2_ETH_FAS_BC		0x02000000
231 #define DPAA2_ETH_FAS_KSE	       0x00040000
232 #define DPAA2_ETH_FAS_EOFHE	     0x00020000
233 #define DPAA2_ETH_FAS_MNLE	      0x00010000
234 #define DPAA2_ETH_FAS_TIDE	      0x00008000
235 #define DPAA2_ETH_FAS_PIEE	      0x00004000
236 /* Frame length error */
237 #define DPAA2_ETH_FAS_FLE	       0x00002000
238 /* Frame physical error; our favourite pastime */
239 #define DPAA2_ETH_FAS_FPE	       0x00001000
240 #define DPAA2_ETH_FAS_PTE	       0x00000080
241 #define DPAA2_ETH_FAS_ISP	       0x00000040
242 #define DPAA2_ETH_FAS_PHE	       0x00000020
243 #define DPAA2_ETH_FAS_BLE	       0x00000010
244 /* L3 csum validation performed */
245 #define DPAA2_ETH_FAS_L3CV	      0x00000008
246 /* L3 csum error */
247 #define DPAA2_ETH_FAS_L3CE	      0x00000004
248 /* L4 csum validation performed */
249 #define DPAA2_ETH_FAS_L4CV	      0x00000002
250 /* L4 csum error */
251 #define DPAA2_ETH_FAS_L4CE	      0x00000001
252 
253 #ifdef __cplusplus
254 }
255 #endif
256 
257 #endif
258