xref: /linux/drivers/net/ethernet/intel/ice/ice_flow.h (revision 8be4d31cb8aaeea27bde4b7ddb26e28a89062ebf)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright (c) 2019, Intel Corporation. */
3 
4 #ifndef _ICE_FLOW_H_
5 #define _ICE_FLOW_H_
6 
7 #include <linux/net/intel/libie/pctype.h>
8 
9 #include "ice_flex_type.h"
10 #include "ice_parser.h"
11 
12 #define ICE_FLOW_ENTRY_HANDLE_INVAL	0
13 #define ICE_FLOW_FLD_OFF_INVAL		0xffff
14 
15 /* Generate flow hash field from flow field type(s) */
16 #define ICE_FLOW_HASH_ETH	\
17 	(BIT_ULL(ICE_FLOW_FIELD_IDX_ETH_DA) | \
18 	 BIT_ULL(ICE_FLOW_FIELD_IDX_ETH_SA))
19 #define ICE_FLOW_HASH_IPV4	\
20 	(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_SA) | \
21 	 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_DA))
22 #define ICE_FLOW_HASH_IPV6	\
23 	(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_SA) | \
24 	 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_DA))
25 #define ICE_FLOW_HASH_TCP_PORT	\
26 	(BIT_ULL(ICE_FLOW_FIELD_IDX_TCP_SRC_PORT) | \
27 	 BIT_ULL(ICE_FLOW_FIELD_IDX_TCP_DST_PORT))
28 #define ICE_FLOW_HASH_UDP_PORT	\
29 	(BIT_ULL(ICE_FLOW_FIELD_IDX_UDP_SRC_PORT) | \
30 	 BIT_ULL(ICE_FLOW_FIELD_IDX_UDP_DST_PORT))
31 #define ICE_FLOW_HASH_SCTP_PORT	\
32 	(BIT_ULL(ICE_FLOW_FIELD_IDX_SCTP_SRC_PORT) | \
33 	 BIT_ULL(ICE_FLOW_FIELD_IDX_SCTP_DST_PORT))
34 
35 #define ICE_HASH_INVALID	0
36 #define ICE_HASH_TCP_IPV4	(ICE_FLOW_HASH_IPV4 | ICE_FLOW_HASH_TCP_PORT)
37 #define ICE_HASH_TCP_IPV6	(ICE_FLOW_HASH_IPV6 | ICE_FLOW_HASH_TCP_PORT)
38 #define ICE_HASH_UDP_IPV4	(ICE_FLOW_HASH_IPV4 | ICE_FLOW_HASH_UDP_PORT)
39 #define ICE_HASH_UDP_IPV6	(ICE_FLOW_HASH_IPV6 | ICE_FLOW_HASH_UDP_PORT)
40 #define ICE_HASH_SCTP_IPV4	(ICE_FLOW_HASH_IPV4 | ICE_FLOW_HASH_SCTP_PORT)
41 #define ICE_HASH_SCTP_IPV6	(ICE_FLOW_HASH_IPV6 | ICE_FLOW_HASH_SCTP_PORT)
42 
43 #define ICE_FLOW_HASH_GTP_C_TEID \
44 	(BIT_ULL(ICE_FLOW_FIELD_IDX_GTPC_TEID))
45 
46 #define ICE_FLOW_HASH_GTP_C_IPV4_TEID \
47 	(ICE_FLOW_HASH_IPV4 | ICE_FLOW_HASH_GTP_C_TEID)
48 #define ICE_FLOW_HASH_GTP_C_IPV6_TEID \
49 	(ICE_FLOW_HASH_IPV6 | ICE_FLOW_HASH_GTP_C_TEID)
50 
51 #define ICE_FLOW_HASH_GTP_U_TEID \
52 	(BIT_ULL(ICE_FLOW_FIELD_IDX_GTPU_IP_TEID))
53 
54 #define ICE_FLOW_HASH_GTP_U_IPV4_TEID \
55 	(ICE_FLOW_HASH_IPV4 | ICE_FLOW_HASH_GTP_U_TEID)
56 #define ICE_FLOW_HASH_GTP_U_IPV6_TEID \
57 	(ICE_FLOW_HASH_IPV6 | ICE_FLOW_HASH_GTP_U_TEID)
58 
59 #define ICE_FLOW_HASH_GTP_U_EH_TEID \
60 	(BIT_ULL(ICE_FLOW_FIELD_IDX_GTPU_EH_TEID))
61 
62 #define ICE_FLOW_HASH_GTP_U_EH_QFI \
63 	(BIT_ULL(ICE_FLOW_FIELD_IDX_GTPU_EH_QFI))
64 
65 #define ICE_FLOW_HASH_GTP_U_IPV4_EH \
66 	(ICE_FLOW_HASH_IPV4 | ICE_FLOW_HASH_GTP_U_EH_TEID | \
67 	 ICE_FLOW_HASH_GTP_U_EH_QFI)
68 #define ICE_FLOW_HASH_GTP_U_IPV6_EH \
69 	(ICE_FLOW_HASH_IPV6 | ICE_FLOW_HASH_GTP_U_EH_TEID | \
70 	 ICE_FLOW_HASH_GTP_U_EH_QFI)
71 
72 #define ICE_FLOW_HASH_GTP_U_UP \
73 	(BIT_ULL(ICE_FLOW_FIELD_IDX_GTPU_UP_TEID))
74 #define ICE_FLOW_HASH_GTP_U_DWN \
75 	(BIT_ULL(ICE_FLOW_FIELD_IDX_GTPU_DWN_TEID))
76 
77 #define ICE_FLOW_HASH_GTP_U_IPV4_UP \
78 	(ICE_FLOW_HASH_IPV4 | ICE_FLOW_HASH_GTP_U_UP)
79 #define ICE_FLOW_HASH_GTP_U_IPV6_UP \
80 	(ICE_FLOW_HASH_IPV6 | ICE_FLOW_HASH_GTP_U_UP)
81 #define ICE_FLOW_HASH_GTP_U_IPV4_DWN \
82 	(ICE_FLOW_HASH_IPV4 | ICE_FLOW_HASH_GTP_U_DWN)
83 #define ICE_FLOW_HASH_GTP_U_IPV6_DWN \
84 	(ICE_FLOW_HASH_IPV6 | ICE_FLOW_HASH_GTP_U_DWN)
85 
86 #define ICE_FLOW_HASH_PPPOE_SESS_ID \
87 	(BIT_ULL(ICE_FLOW_FIELD_IDX_PPPOE_SESS_ID))
88 
89 #define ICE_FLOW_HASH_PPPOE_SESS_ID_ETH \
90 	(ICE_FLOW_HASH_ETH | ICE_FLOW_HASH_PPPOE_SESS_ID)
91 #define ICE_FLOW_HASH_PPPOE_TCP_ID \
92 	(ICE_FLOW_HASH_TCP_PORT | ICE_FLOW_HASH_PPPOE_SESS_ID)
93 #define ICE_FLOW_HASH_PPPOE_UDP_ID \
94 	(ICE_FLOW_HASH_UDP_PORT | ICE_FLOW_HASH_PPPOE_SESS_ID)
95 
96 #define ICE_FLOW_HASH_PFCP_SEID \
97 	(BIT_ULL(ICE_FLOW_FIELD_IDX_PFCP_SEID))
98 #define ICE_FLOW_HASH_PFCP_IPV4_SEID \
99 	(ICE_FLOW_HASH_IPV4 | ICE_FLOW_HASH_PFCP_SEID)
100 #define ICE_FLOW_HASH_PFCP_IPV6_SEID \
101 	(ICE_FLOW_HASH_IPV6 | ICE_FLOW_HASH_PFCP_SEID)
102 
103 #define ICE_FLOW_HASH_L2TPV3_SESS_ID \
104 	(BIT_ULL(ICE_FLOW_FIELD_IDX_L2TPV3_SESS_ID))
105 #define ICE_FLOW_HASH_L2TPV3_IPV4_SESS_ID \
106 	(ICE_FLOW_HASH_IPV4 | ICE_FLOW_HASH_L2TPV3_SESS_ID)
107 #define ICE_FLOW_HASH_L2TPV3_IPV6_SESS_ID \
108 	(ICE_FLOW_HASH_IPV6 | ICE_FLOW_HASH_L2TPV3_SESS_ID)
109 
110 #define ICE_FLOW_HASH_ESP_SPI \
111 	(BIT_ULL(ICE_FLOW_FIELD_IDX_ESP_SPI))
112 #define ICE_FLOW_HASH_ESP_IPV4_SPI \
113 	(ICE_FLOW_HASH_IPV4 | ICE_FLOW_HASH_ESP_SPI)
114 #define ICE_FLOW_HASH_ESP_IPV6_SPI \
115 	(ICE_FLOW_HASH_IPV6 | ICE_FLOW_HASH_ESP_SPI)
116 
117 #define ICE_FLOW_HASH_AH_SPI \
118 	(BIT_ULL(ICE_FLOW_FIELD_IDX_AH_SPI))
119 #define ICE_FLOW_HASH_AH_IPV4_SPI \
120 	(ICE_FLOW_HASH_IPV4 | ICE_FLOW_HASH_AH_SPI)
121 #define ICE_FLOW_HASH_AH_IPV6_SPI \
122 	(ICE_FLOW_HASH_IPV6 | ICE_FLOW_HASH_AH_SPI)
123 
124 #define ICE_FLOW_HASH_NAT_T_ESP_SPI \
125 	(BIT_ULL(ICE_FLOW_FIELD_IDX_NAT_T_ESP_SPI))
126 #define ICE_FLOW_HASH_NAT_T_ESP_IPV4_SPI \
127 	(ICE_FLOW_HASH_IPV4 | ICE_FLOW_HASH_NAT_T_ESP_SPI)
128 #define ICE_FLOW_HASH_NAT_T_ESP_IPV6_SPI \
129 	(ICE_FLOW_HASH_IPV6 | ICE_FLOW_HASH_NAT_T_ESP_SPI)
130 
131 /* Protocol header fields within a packet segment. A segment consists of one or
132  * more protocol headers that make up a logical group of protocol headers. Each
133  * logical group of protocol headers encapsulates or is encapsulated using/by
134  * tunneling or encapsulation protocols for network virtualization such as GRE,
135  * VxLAN, etc.
136  */
137 enum ice_flow_seg_hdr {
138 	ICE_FLOW_SEG_HDR_NONE		= 0x00000000,
139 	ICE_FLOW_SEG_HDR_ETH		= 0x00000001,
140 	ICE_FLOW_SEG_HDR_VLAN		= 0x00000002,
141 	ICE_FLOW_SEG_HDR_IPV4		= 0x00000004,
142 	ICE_FLOW_SEG_HDR_IPV6		= 0x00000008,
143 	ICE_FLOW_SEG_HDR_ARP		= 0x00000010,
144 	ICE_FLOW_SEG_HDR_ICMP		= 0x00000020,
145 	ICE_FLOW_SEG_HDR_TCP		= 0x00000040,
146 	ICE_FLOW_SEG_HDR_UDP		= 0x00000080,
147 	ICE_FLOW_SEG_HDR_SCTP		= 0x00000100,
148 	ICE_FLOW_SEG_HDR_GRE		= 0x00000200,
149 	ICE_FLOW_SEG_HDR_GTPC		= 0x00000400,
150 	ICE_FLOW_SEG_HDR_GTPC_TEID	= 0x00000800,
151 	ICE_FLOW_SEG_HDR_GTPU_IP	= 0x00001000,
152 	ICE_FLOW_SEG_HDR_GTPU_EH	= 0x00002000,
153 	ICE_FLOW_SEG_HDR_GTPU_DWN	= 0x00004000,
154 	ICE_FLOW_SEG_HDR_GTPU_UP	= 0x00008000,
155 	ICE_FLOW_SEG_HDR_PPPOE		= 0x00010000,
156 	ICE_FLOW_SEG_HDR_PFCP_NODE	= 0x00020000,
157 	ICE_FLOW_SEG_HDR_PFCP_SESSION	= 0x00040000,
158 	ICE_FLOW_SEG_HDR_L2TPV3		= 0x00080000,
159 	ICE_FLOW_SEG_HDR_ESP		= 0x00100000,
160 	ICE_FLOW_SEG_HDR_AH		= 0x00200000,
161 	ICE_FLOW_SEG_HDR_NAT_T_ESP	= 0x00400000,
162 	ICE_FLOW_SEG_HDR_ETH_NON_IP	= 0x00800000,
163 	/* The following is an additive bit for ICE_FLOW_SEG_HDR_IPV4 and
164 	 * ICE_FLOW_SEG_HDR_IPV6 which include the IPV4 other PTYPEs
165 	 */
166 	ICE_FLOW_SEG_HDR_IPV_OTHER      = 0x20000000,
167 };
168 
169 /* These segments all have the same PTYPES, but are otherwise distinguished by
170  * the value of the gtp_eh_pdu and gtp_eh_pdu_link flags:
171  *
172  *                                gtp_eh_pdu     gtp_eh_pdu_link
173  * ICE_FLOW_SEG_HDR_GTPU_IP           0              0
174  * ICE_FLOW_SEG_HDR_GTPU_EH           1              don't care
175  * ICE_FLOW_SEG_HDR_GTPU_DWN          1              0
176  * ICE_FLOW_SEG_HDR_GTPU_UP           1              1
177  */
178 #define ICE_FLOW_SEG_HDR_GTPU (ICE_FLOW_SEG_HDR_GTPU_IP | \
179 			       ICE_FLOW_SEG_HDR_GTPU_EH | \
180 			       ICE_FLOW_SEG_HDR_GTPU_DWN | \
181 			       ICE_FLOW_SEG_HDR_GTPU_UP)
182 #define ICE_FLOW_SEG_HDR_PFCP (ICE_FLOW_SEG_HDR_PFCP_NODE | \
183 			       ICE_FLOW_SEG_HDR_PFCP_SESSION)
184 
185 enum ice_flow_field {
186 	/* L2 */
187 	ICE_FLOW_FIELD_IDX_ETH_DA,
188 	ICE_FLOW_FIELD_IDX_ETH_SA,
189 	ICE_FLOW_FIELD_IDX_S_VLAN,
190 	ICE_FLOW_FIELD_IDX_C_VLAN,
191 	ICE_FLOW_FIELD_IDX_ETH_TYPE,
192 	/* L3 */
193 	ICE_FLOW_FIELD_IDX_IPV4_DSCP,
194 	ICE_FLOW_FIELD_IDX_IPV6_DSCP,
195 	ICE_FLOW_FIELD_IDX_IPV4_TTL,
196 	ICE_FLOW_FIELD_IDX_IPV4_PROT,
197 	ICE_FLOW_FIELD_IDX_IPV6_TTL,
198 	ICE_FLOW_FIELD_IDX_IPV6_PROT,
199 	ICE_FLOW_FIELD_IDX_IPV4_SA,
200 	ICE_FLOW_FIELD_IDX_IPV4_DA,
201 	ICE_FLOW_FIELD_IDX_IPV6_SA,
202 	ICE_FLOW_FIELD_IDX_IPV6_DA,
203 	/* L4 */
204 	ICE_FLOW_FIELD_IDX_TCP_SRC_PORT,
205 	ICE_FLOW_FIELD_IDX_TCP_DST_PORT,
206 	ICE_FLOW_FIELD_IDX_UDP_SRC_PORT,
207 	ICE_FLOW_FIELD_IDX_UDP_DST_PORT,
208 	ICE_FLOW_FIELD_IDX_SCTP_SRC_PORT,
209 	ICE_FLOW_FIELD_IDX_SCTP_DST_PORT,
210 	ICE_FLOW_FIELD_IDX_TCP_FLAGS,
211 	/* ARP */
212 	ICE_FLOW_FIELD_IDX_ARP_SIP,
213 	ICE_FLOW_FIELD_IDX_ARP_DIP,
214 	ICE_FLOW_FIELD_IDX_ARP_SHA,
215 	ICE_FLOW_FIELD_IDX_ARP_DHA,
216 	ICE_FLOW_FIELD_IDX_ARP_OP,
217 	/* ICMP */
218 	ICE_FLOW_FIELD_IDX_ICMP_TYPE,
219 	ICE_FLOW_FIELD_IDX_ICMP_CODE,
220 	/* GRE */
221 	ICE_FLOW_FIELD_IDX_GRE_KEYID,
222 	/* GTPC_TEID */
223 	ICE_FLOW_FIELD_IDX_GTPC_TEID,
224 	/* GTPU_IP */
225 	ICE_FLOW_FIELD_IDX_GTPU_IP_TEID,
226 	/* GTPU_EH */
227 	ICE_FLOW_FIELD_IDX_GTPU_EH_TEID,
228 	ICE_FLOW_FIELD_IDX_GTPU_EH_QFI,
229 	/* GTPU_UP */
230 	ICE_FLOW_FIELD_IDX_GTPU_UP_TEID,
231 	/* GTPU_DWN */
232 	ICE_FLOW_FIELD_IDX_GTPU_DWN_TEID,
233 	/* PPPoE */
234 	ICE_FLOW_FIELD_IDX_PPPOE_SESS_ID,
235 	/* PFCP */
236 	ICE_FLOW_FIELD_IDX_PFCP_SEID,
237 	/* L2TPv3 */
238 	ICE_FLOW_FIELD_IDX_L2TPV3_SESS_ID,
239 	/* ESP */
240 	ICE_FLOW_FIELD_IDX_ESP_SPI,
241 	/* AH */
242 	ICE_FLOW_FIELD_IDX_AH_SPI,
243 	/* NAT_T ESP */
244 	ICE_FLOW_FIELD_IDX_NAT_T_ESP_SPI,
245 	 /* The total number of enums must not exceed 64 */
246 	ICE_FLOW_FIELD_IDX_MAX
247 };
248 
249 #define ICE_FLOW_HASH_FLD_IPV4_SA	BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_SA)
250 #define ICE_FLOW_HASH_FLD_IPV6_SA	BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_SA)
251 #define ICE_FLOW_HASH_FLD_IPV4_DA	BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_DA)
252 #define ICE_FLOW_HASH_FLD_IPV6_DA	BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_DA)
253 #define ICE_FLOW_HASH_FLD_TCP_SRC_PORT	BIT_ULL(ICE_FLOW_FIELD_IDX_TCP_SRC_PORT)
254 #define ICE_FLOW_HASH_FLD_TCP_DST_PORT	BIT_ULL(ICE_FLOW_FIELD_IDX_TCP_DST_PORT)
255 #define ICE_FLOW_HASH_FLD_UDP_SRC_PORT	BIT_ULL(ICE_FLOW_FIELD_IDX_UDP_SRC_PORT)
256 #define ICE_FLOW_HASH_FLD_UDP_DST_PORT	BIT_ULL(ICE_FLOW_FIELD_IDX_UDP_DST_PORT)
257 #define ICE_FLOW_HASH_FLD_SCTP_SRC_PORT	\
258 	BIT_ULL(ICE_FLOW_FIELD_IDX_SCTP_SRC_PORT)
259 #define ICE_FLOW_HASH_FLD_SCTP_DST_PORT	\
260 	BIT_ULL(ICE_FLOW_FIELD_IDX_SCTP_DST_PORT)
261 
262 #define ICE_FLOW_HASH_FLD_GTPC_TEID	BIT_ULL(ICE_FLOW_FIELD_IDX_GTPC_TEID)
263 #define ICE_FLOW_HASH_FLD_GTPU_IP_TEID BIT_ULL(ICE_FLOW_FIELD_IDX_GTPU_IP_TEID)
264 #define ICE_FLOW_HASH_FLD_GTPU_EH_TEID BIT_ULL(ICE_FLOW_FIELD_IDX_GTPU_EH_TEID)
265 #define ICE_FLOW_HASH_FLD_GTPU_UP_TEID BIT_ULL(ICE_FLOW_FIELD_IDX_GTPU_UP_TEID)
266 #define ICE_FLOW_HASH_FLD_GTPU_DWN_TEID \
267 	BIT_ULL(ICE_FLOW_FIELD_IDX_GTPU_DWN_TEID)
268 
269 /* Supported RSS offloads  This macro is defined to support
270  * VIRTCHNL_OP_GET_RSS_HASHCFG_CAPS ops. PF driver sends the RSS hardware
271  * capabilities to the caller of this ops.
272  */
273 #define ICE_DEFAULT_RSS_HASHCFG ( \
274 	BIT_ULL(LIBIE_FILTER_PCTYPE_NONF_IPV4_UDP) | \
275 	BIT_ULL(LIBIE_FILTER_PCTYPE_NONF_IPV4_SCTP) | \
276 	BIT_ULL(LIBIE_FILTER_PCTYPE_NONF_IPV4_TCP) | \
277 	BIT_ULL(LIBIE_FILTER_PCTYPE_NONF_IPV4_OTHER) | \
278 	BIT_ULL(LIBIE_FILTER_PCTYPE_FRAG_IPV4) | \
279 	BIT_ULL(LIBIE_FILTER_PCTYPE_NONF_IPV6_UDP) | \
280 	BIT_ULL(LIBIE_FILTER_PCTYPE_NONF_IPV6_TCP) | \
281 	BIT_ULL(LIBIE_FILTER_PCTYPE_NONF_IPV6_SCTP) | \
282 	BIT_ULL(LIBIE_FILTER_PCTYPE_NONF_IPV6_OTHER) | \
283 	BIT_ULL(LIBIE_FILTER_PCTYPE_FRAG_IPV6) | \
284 	BIT_ULL(LIBIE_FILTER_PCTYPE_NONF_IPV4_TCP_SYN_NO_ACK) | \
285 	BIT_ULL(LIBIE_FILTER_PCTYPE_NONF_UNICAST_IPV4_UDP) | \
286 	BIT_ULL(LIBIE_FILTER_PCTYPE_NONF_MULTICAST_IPV4_UDP) | \
287 	BIT_ULL(LIBIE_FILTER_PCTYPE_NONF_IPV6_TCP_SYN_NO_ACK) | \
288 	BIT_ULL(LIBIE_FILTER_PCTYPE_NONF_UNICAST_IPV6_UDP) | \
289 	BIT_ULL(LIBIE_FILTER_PCTYPE_NONF_MULTICAST_IPV6_UDP))
290 
291 enum ice_rss_cfg_hdr_type {
292 	ICE_RSS_OUTER_HEADERS, /* take outer headers as inputset. */
293 	ICE_RSS_INNER_HEADERS, /* take inner headers as inputset. */
294 	/* take inner headers as inputset for packet with outer ipv4. */
295 	ICE_RSS_INNER_HEADERS_W_OUTER_IPV4,
296 	/* take inner headers as inputset for packet with outer ipv6. */
297 	ICE_RSS_INNER_HEADERS_W_OUTER_IPV6,
298 	/* take outer headers first then inner headers as inputset */
299 	ICE_RSS_ANY_HEADERS
300 };
301 
302 struct ice_vsi;
303 struct ice_rss_hash_cfg {
304 	u32 addl_hdrs; /* protocol header fields */
305 	u64 hash_flds; /* hash bit field (ICE_FLOW_HASH_*) to configure */
306 	enum ice_rss_cfg_hdr_type hdr_type; /* to specify inner or outer */
307 	bool symm; /* symmetric or asymmetric hash */
308 };
309 
310 enum ice_flow_dir {
311 	ICE_FLOW_RX		= 0x02,
312 };
313 
314 enum ice_flow_priority {
315 	ICE_FLOW_PRIO_LOW,
316 	ICE_FLOW_PRIO_NORMAL,
317 	ICE_FLOW_PRIO_HIGH
318 };
319 
320 #define ICE_FLOW_SEG_SINGLE		1
321 #define ICE_FLOW_SEG_MAX		2
322 #define ICE_FLOW_SEG_RAW_FLD_MAX	2
323 #define ICE_FLOW_SW_FIELD_VECTOR_MAX	48
324 #define ICE_FLOW_FV_EXTRACT_SZ		2
325 
326 #define ICE_FLOW_SET_HDRS(seg, val)	((seg)->hdrs |= (u32)(val))
327 
328 struct ice_flow_seg_xtrct {
329 	u8 prot_id;	/* Protocol ID of extracted header field */
330 	u16 off;	/* Starting offset of the field in header in bytes */
331 	u8 idx;		/* Index of FV entry used */
332 	u8 disp;	/* Displacement of field in bits fr. FV entry's start */
333 	u16 mask;	/* Mask for field */
334 };
335 
336 enum ice_flow_fld_match_type {
337 	ICE_FLOW_FLD_TYPE_REG,		/* Value, mask */
338 	ICE_FLOW_FLD_TYPE_RANGE,	/* Value, mask, last (upper bound) */
339 	ICE_FLOW_FLD_TYPE_PREFIX,	/* IP address, prefix, size of prefix */
340 	ICE_FLOW_FLD_TYPE_SIZE,		/* Value, mask, size of match */
341 };
342 
343 struct ice_flow_fld_loc {
344 	/* Describe offsets of field information relative to the beginning of
345 	 * input buffer provided when adding flow entries.
346 	 */
347 	u16 val;	/* Offset where the value is located */
348 	u16 mask;	/* Offset where the mask/prefix value is located */
349 	u16 last;	/* Length or offset where the upper value is located */
350 };
351 
352 struct ice_flow_fld_info {
353 	enum ice_flow_fld_match_type type;
354 	/* Location where to retrieve data from an input buffer */
355 	struct ice_flow_fld_loc src;
356 	/* Location where to put the data into the final entry buffer */
357 	struct ice_flow_fld_loc entry;
358 	struct ice_flow_seg_xtrct xtrct;
359 };
360 
361 struct ice_flow_seg_fld_raw {
362 	struct ice_flow_fld_info info;
363 	u16 off;	/* Offset from the start of the segment */
364 };
365 
366 struct ice_flow_seg_info {
367 	u32 hdrs;	/* Bitmask indicating protocol headers present */
368 	u64 match;	/* Bitmask indicating header fields to be matched */
369 	u64 range;	/* Bitmask indicating header fields matched as ranges */
370 
371 	struct ice_flow_fld_info fields[ICE_FLOW_FIELD_IDX_MAX];
372 
373 	u8 raws_cnt;	/* Number of raw fields to be matched */
374 	struct ice_flow_seg_fld_raw raws[ICE_FLOW_SEG_RAW_FLD_MAX];
375 };
376 
377 /* This structure describes a flow entry, and is tracked only in this file */
378 struct ice_flow_entry {
379 	struct list_head l_entry;
380 
381 	u64 id;
382 	struct ice_flow_prof *prof;
383 	enum ice_flow_priority priority;
384 	u16 vsi_handle;
385 };
386 
387 #define ICE_FLOW_ENTRY_HNDL(e)	((u64)(uintptr_t)e)
388 #define ICE_FLOW_ENTRY_PTR(h)	((struct ice_flow_entry *)(uintptr_t)(h))
389 
390 struct ice_flow_prof {
391 	struct list_head l_entry;
392 
393 	u64 id;
394 	enum ice_flow_dir dir;
395 	u8 segs_cnt;
396 
397 	/* Keep track of flow entries associated with this flow profile */
398 	struct mutex entries_lock;
399 	struct list_head entries;
400 
401 	struct ice_flow_seg_info segs[ICE_FLOW_SEG_MAX];
402 
403 	/* software VSI handles referenced by this flow profile */
404 	DECLARE_BITMAP(vsis, ICE_MAX_VSI);
405 
406 	bool symm; /* Symmetric Hash for RSS */
407 };
408 
409 struct ice_rss_cfg {
410 	struct list_head l_entry;
411 	/* bitmap of VSIs added to the RSS entry */
412 	DECLARE_BITMAP(vsis, ICE_MAX_VSI);
413 	struct ice_rss_hash_cfg hash;
414 };
415 
416 int
417 ice_flow_add_prof(struct ice_hw *hw, enum ice_block blk, enum ice_flow_dir dir,
418 		  struct ice_flow_seg_info *segs, u8 segs_cnt,
419 		  bool symm, struct ice_flow_prof **prof);
420 int ice_flow_rem_prof(struct ice_hw *hw, enum ice_block blk, u64 prof_id);
421 int
422 ice_flow_set_parser_prof(struct ice_hw *hw, u16 dest_vsi, u16 fdir_vsi,
423 			 struct ice_parser_profile *prof, enum ice_block blk);
424 int
425 ice_flow_add_entry(struct ice_hw *hw, enum ice_block blk, u64 prof_id,
426 		   u64 entry_id, u16 vsi, enum ice_flow_priority prio,
427 		   void *data, u64 *entry_h);
428 int ice_flow_rem_entry(struct ice_hw *hw, enum ice_block blk, u64 entry_h);
429 void
430 ice_flow_set_fld(struct ice_flow_seg_info *seg, enum ice_flow_field fld,
431 		 u16 val_loc, u16 mask_loc, u16 last_loc, bool range);
432 void
433 ice_flow_add_fld_raw(struct ice_flow_seg_info *seg, u16 off, u8 len,
434 		     u16 val_loc, u16 mask_loc);
435 int ice_flow_rem_vsi_prof(struct ice_hw *hw, u16 vsi_handle, u64 prof_id);
436 void ice_rem_vsi_rss_list(struct ice_hw *hw, u16 vsi_handle);
437 int ice_replay_rss_cfg(struct ice_hw *hw, u16 vsi_handle);
438 int ice_set_rss_cfg_symm(struct ice_hw *hw, struct ice_vsi *vsi, bool symm);
439 int ice_add_avf_rss_cfg(struct ice_hw *hw, struct ice_vsi *vsi,
440 			u64 hashed_flds);
441 int ice_rem_vsi_rss_cfg(struct ice_hw *hw, u16 vsi_handle);
442 int ice_add_rss_cfg(struct ice_hw *hw, struct ice_vsi *vsi,
443 		    const struct ice_rss_hash_cfg *cfg);
444 int ice_rem_rss_cfg(struct ice_hw *hw, u16 vsi_handle,
445 		    const struct ice_rss_hash_cfg *cfg);
446 u64 ice_get_rss_cfg(struct ice_hw *hw, u16 vsi_handle, u32 hdrs, bool *symm);
447 #endif /* _ICE_FLOW_H_ */
448