1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2001-2020 Intel Corporation
8 #include "ice_flex_type.h"
11 #define ICE_IPV4_MAKE_PREFIX_MASK(prefix) ((u32)(~0) << (32 - (prefix)))
12 #define ICE_FLOW_PROF_ID_INVAL 0xfffffffffffffffful
13 #define ICE_FLOW_PROF_ID_BYPASS 0
14 #define ICE_FLOW_PROF_ID_DEFAULT 1
15 #define ICE_FLOW_ENTRY_HANDLE_INVAL 0
16 #define ICE_FLOW_VSI_INVAL 0xffff
17 #define ICE_FLOW_FLD_OFF_INVAL 0xffff
19 /* Generate flow hash field from flow field type(s) */
20 #define ICE_FLOW_HASH_ETH \
21 (BIT_ULL(ICE_FLOW_FIELD_IDX_ETH_DA) | \
22 BIT_ULL(ICE_FLOW_FIELD_IDX_ETH_SA))
23 #define ICE_FLOW_HASH_IPV4 \
24 (BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_SA) | \
25 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_DA))
26 #define ICE_FLOW_HASH_IPV6 \
27 (BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_SA) | \
28 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_DA))
29 #define ICE_FLOW_HASH_IPV6_PRE32 \
30 (BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_PRE32_SA) | \
31 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_PRE32_DA))
32 #define ICE_FLOW_HASH_IPV6_PRE48 \
33 (BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_PRE48_SA) | \
34 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_PRE48_DA))
35 #define ICE_FLOW_HASH_IPV6_PRE64 \
36 (BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_PRE64_SA) | \
37 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_PRE64_DA))
38 #define ICE_FLOW_HASH_TCP_PORT \
39 (BIT_ULL(ICE_FLOW_FIELD_IDX_TCP_SRC_PORT) | \
40 BIT_ULL(ICE_FLOW_FIELD_IDX_TCP_DST_PORT))
41 #define ICE_FLOW_HASH_UDP_PORT \
42 (BIT_ULL(ICE_FLOW_FIELD_IDX_UDP_SRC_PORT) | \
43 BIT_ULL(ICE_FLOW_FIELD_IDX_UDP_DST_PORT))
44 #define ICE_FLOW_HASH_SCTP_PORT \
45 (BIT_ULL(ICE_FLOW_FIELD_IDX_SCTP_SRC_PORT) | \
46 BIT_ULL(ICE_FLOW_FIELD_IDX_SCTP_DST_PORT))
48 #define ICE_HASH_INVALID 0
49 #define ICE_HASH_TCP_IPV4 (ICE_FLOW_HASH_IPV4 | ICE_FLOW_HASH_TCP_PORT)
50 #define ICE_HASH_TCP_IPV6 (ICE_FLOW_HASH_IPV6 | ICE_FLOW_HASH_TCP_PORT)
51 #define ICE_HASH_UDP_IPV4 (ICE_FLOW_HASH_IPV4 | ICE_FLOW_HASH_UDP_PORT)
52 #define ICE_HASH_UDP_IPV6 (ICE_FLOW_HASH_IPV6 | ICE_FLOW_HASH_UDP_PORT)
53 #define ICE_HASH_SCTP_IPV4 (ICE_FLOW_HASH_IPV4 | ICE_FLOW_HASH_SCTP_PORT)
54 #define ICE_HASH_SCTP_IPV6 (ICE_FLOW_HASH_IPV6 | ICE_FLOW_HASH_SCTP_PORT)
56 #define ICE_HASH_TCP_IPV6_PRE32 \
57 (ICE_FLOW_HASH_IPV6_PRE32 | ICE_FLOW_HASH_TCP_PORT)
58 #define ICE_HASH_UDP_IPV6_PRE32 \
59 (ICE_FLOW_HASH_IPV6_PRE32 | ICE_FLOW_HASH_UDP_PORT)
60 #define ICE_HASH_SCTP_IPV6_PRE32 \
61 (ICE_FLOW_HASH_IPV6_PRE32 | ICE_FLOW_HASH_SCTP_PORT)
62 #define ICE_HASH_TCP_IPV6_PRE48 \
63 (ICE_FLOW_HASH_IPV6_PRE48 | ICE_FLOW_HASH_TCP_PORT)
64 #define ICE_HASH_UDP_IPV6_PRE48 \
65 (ICE_FLOW_HASH_IPV6_PRE48 | ICE_FLOW_HASH_UDP_PORT)
66 #define ICE_HASH_SCTP_IPV6_PRE48 \
67 (ICE_FLOW_HASH_IPV6_PRE48 | ICE_FLOW_HASH_SCTP_PORT)
68 #define ICE_HASH_TCP_IPV6_PRE64 \
69 (ICE_FLOW_HASH_IPV6_PRE64 | ICE_FLOW_HASH_TCP_PORT)
70 #define ICE_HASH_UDP_IPV6_PRE64 \
71 (ICE_FLOW_HASH_IPV6_PRE64 | ICE_FLOW_HASH_UDP_PORT)
72 #define ICE_HASH_SCTP_IPV6_PRE64 \
73 (ICE_FLOW_HASH_IPV6_PRE64 | ICE_FLOW_HASH_SCTP_PORT)
75 #define ICE_FLOW_HASH_VXLAN_VNI \
76 (BIT_ULL(ICE_FLOW_FIELD_IDX_VXLAN_VNI))
78 #define ICE_FLOW_HASH_GTP_TEID \
79 (BIT_ULL(ICE_FLOW_FIELD_IDX_GTPC_TEID))
81 #define ICE_FLOW_HASH_GTP_IPV4_TEID \
82 (ICE_FLOW_HASH_IPV4 | ICE_FLOW_HASH_GTP_TEID)
83 #define ICE_FLOW_HASH_GTP_IPV6_TEID \
84 (ICE_FLOW_HASH_IPV6 | ICE_FLOW_HASH_GTP_TEID)
86 #define ICE_FLOW_HASH_GTP_U_TEID \
87 (BIT_ULL(ICE_FLOW_FIELD_IDX_GTPU_IP_TEID))
89 #define ICE_FLOW_HASH_GTP_U_IPV4_TEID \
90 (ICE_FLOW_HASH_IPV4 | ICE_FLOW_HASH_GTP_U_TEID)
91 #define ICE_FLOW_HASH_GTP_U_IPV6_TEID \
92 (ICE_FLOW_HASH_IPV6 | ICE_FLOW_HASH_GTP_U_TEID)
94 #define ICE_FLOW_HASH_GTP_U_EH_TEID \
95 (BIT_ULL(ICE_FLOW_FIELD_IDX_GTPU_EH_TEID))
97 #define ICE_FLOW_HASH_GTP_U_EH_QFI \
98 (BIT_ULL(ICE_FLOW_FIELD_IDX_GTPU_EH_QFI))
100 #define ICE_FLOW_HASH_GTP_U_IPV4_EH \
101 (ICE_FLOW_HASH_IPV4 | ICE_FLOW_HASH_GTP_U_EH_TEID | \
102 ICE_FLOW_HASH_GTP_U_EH_QFI)
103 #define ICE_FLOW_HASH_GTP_U_IPV6_EH \
104 (ICE_FLOW_HASH_IPV6 | ICE_FLOW_HASH_GTP_U_EH_TEID | \
105 ICE_FLOW_HASH_GTP_U_EH_QFI)
107 #define ICE_FLOW_HASH_PPPOE_SESS_ID \
108 (BIT_ULL(ICE_FLOW_FIELD_IDX_PPPOE_SESS_ID))
110 #define ICE_FLOW_HASH_PPPOE_SESS_ID_ETH \
111 (ICE_FLOW_HASH_ETH | ICE_FLOW_HASH_PPPOE_SESS_ID)
112 #define ICE_FLOW_HASH_PPPOE_TCP_ID \
113 (ICE_FLOW_HASH_TCP_PORT | ICE_FLOW_HASH_PPPOE_SESS_ID)
114 #define ICE_FLOW_HASH_PPPOE_UDP_ID \
115 (ICE_FLOW_HASH_UDP_PORT | ICE_FLOW_HASH_PPPOE_SESS_ID)
117 #define ICE_FLOW_HASH_PFCP_SEID \
118 (BIT_ULL(ICE_FLOW_FIELD_IDX_PFCP_SEID))
119 #define ICE_FLOW_HASH_PFCP_IPV4_SEID \
120 (ICE_FLOW_HASH_IPV4 | ICE_FLOW_HASH_PFCP_SEID)
121 #define ICE_FLOW_HASH_PFCP_IPV6_SEID \
122 (ICE_FLOW_HASH_IPV6 | ICE_FLOW_HASH_PFCP_SEID)
124 #define ICE_FLOW_HASH_L2TPV3_SESS_ID \
125 (BIT_ULL(ICE_FLOW_FIELD_IDX_L2TPV3_SESS_ID))
126 #define ICE_FLOW_HASH_L2TPV3_IPV4_SESS_ID \
127 (ICE_FLOW_HASH_IPV4 | ICE_FLOW_HASH_L2TPV3_SESS_ID)
128 #define ICE_FLOW_HASH_L2TPV3_IPV6_SESS_ID \
129 (ICE_FLOW_HASH_IPV6 | ICE_FLOW_HASH_L2TPV3_SESS_ID)
131 #define ICE_FLOW_HASH_ESP_SPI \
132 (BIT_ULL(ICE_FLOW_FIELD_IDX_ESP_SPI))
133 #define ICE_FLOW_HASH_ESP_IPV4_SPI \
134 (ICE_FLOW_HASH_IPV4 | ICE_FLOW_HASH_ESP_SPI)
135 #define ICE_FLOW_HASH_ESP_IPV6_SPI \
136 (ICE_FLOW_HASH_IPV6 | ICE_FLOW_HASH_ESP_SPI)
138 #define ICE_FLOW_HASH_AH_SPI \
139 (BIT_ULL(ICE_FLOW_FIELD_IDX_AH_SPI))
140 #define ICE_FLOW_HASH_AH_IPV4_SPI \
141 (ICE_FLOW_HASH_IPV4 | ICE_FLOW_HASH_AH_SPI)
142 #define ICE_FLOW_HASH_AH_IPV6_SPI \
143 (ICE_FLOW_HASH_IPV6 | ICE_FLOW_HASH_AH_SPI)
145 #define ICE_FLOW_HASH_NAT_T_ESP_SPI \
146 (BIT_ULL(ICE_FLOW_FIELD_IDX_NAT_T_ESP_SPI))
147 #define ICE_FLOW_HASH_NAT_T_ESP_IPV4_SPI \
148 (ICE_FLOW_HASH_IPV4 | ICE_FLOW_HASH_NAT_T_ESP_SPI)
149 #define ICE_FLOW_HASH_NAT_T_ESP_IPV6_SPI \
150 (ICE_FLOW_HASH_IPV6 | ICE_FLOW_HASH_NAT_T_ESP_SPI)
152 /* Protocol header fields within a packet segment. A segment consists of one or
153 * more protocol headers that make up a logical group of protocol headers. Each
154 * logical group of protocol headers encapsulates or is encapsulated using/by
155 * tunneling or encapsulation protocols for network virtualization such as GRE,
158 enum ice_flow_seg_hdr {
159 ICE_FLOW_SEG_HDR_NONE = 0x00000000,
160 ICE_FLOW_SEG_HDR_ETH = 0x00000001,
161 ICE_FLOW_SEG_HDR_VLAN = 0x00000002,
162 ICE_FLOW_SEG_HDR_IPV4 = 0x00000004,
163 ICE_FLOW_SEG_HDR_IPV6 = 0x00000008,
164 ICE_FLOW_SEG_HDR_ARP = 0x00000010,
165 ICE_FLOW_SEG_HDR_ICMP = 0x00000020,
166 ICE_FLOW_SEG_HDR_TCP = 0x00000040,
167 ICE_FLOW_SEG_HDR_UDP = 0x00000080,
168 ICE_FLOW_SEG_HDR_SCTP = 0x00000100,
169 ICE_FLOW_SEG_HDR_GRE = 0x00000200,
170 ICE_FLOW_SEG_HDR_GTPC = 0x00000400,
171 ICE_FLOW_SEG_HDR_GTPC_TEID = 0x00000800,
172 ICE_FLOW_SEG_HDR_GTPU_IP = 0x00001000,
173 ICE_FLOW_SEG_HDR_GTPU_EH = 0x00002000,
174 ICE_FLOW_SEG_HDR_GTPU_DWN = 0x00004000,
175 ICE_FLOW_SEG_HDR_GTPU_UP = 0x00008000,
176 ICE_FLOW_SEG_HDR_PPPOE = 0x00010000,
177 ICE_FLOW_SEG_HDR_PFCP_NODE = 0x00020000,
178 ICE_FLOW_SEG_HDR_PFCP_SESSION = 0x00040000,
179 ICE_FLOW_SEG_HDR_L2TPV3 = 0x00080000,
180 ICE_FLOW_SEG_HDR_ESP = 0x00100000,
181 ICE_FLOW_SEG_HDR_AH = 0x00200000,
182 ICE_FLOW_SEG_HDR_NAT_T_ESP = 0x00400000,
183 ICE_FLOW_SEG_HDR_ETH_NON_IP = 0x00800000,
184 ICE_FLOW_SEG_HDR_GTPU_NON_IP = 0x01000000,
185 ICE_FLOW_SEG_HDR_VXLAN = 0x02000000,
186 /* The following is an additive bit for ICE_FLOW_SEG_HDR_IPV4 and
187 * ICE_FLOW_SEG_HDR_IPV6 which include the IPV4 other PTYPEs
189 ICE_FLOW_SEG_HDR_IPV_OTHER = 0x20000000,
192 /* These segements all have the same PTYPES, but are otherwise distinguished by
193 * the value of the gtp_eh_pdu and gtp_eh_pdu_link flags:
195 * gtp_eh_pdu gtp_eh_pdu_link
196 * ICE_FLOW_SEG_HDR_GTPU_IP 0 0
197 * ICE_FLOW_SEG_HDR_GTPU_EH 1 don't care
198 * ICE_FLOW_SEG_HDR_GTPU_DWN 1 0
199 * ICE_FLOW_SEG_HDR_GTPU_UP 1 1
201 #define ICE_FLOW_SEG_HDR_GTPU (ICE_FLOW_SEG_HDR_GTPU_IP | \
202 ICE_FLOW_SEG_HDR_GTPU_EH | \
203 ICE_FLOW_SEG_HDR_GTPU_DWN | \
204 ICE_FLOW_SEG_HDR_GTPU_UP)
205 #define ICE_FLOW_SEG_HDR_PFCP (ICE_FLOW_SEG_HDR_PFCP_NODE | \
206 ICE_FLOW_SEG_HDR_PFCP_SESSION)
208 enum ice_flow_field {
210 ICE_FLOW_FIELD_IDX_ETH_DA,
211 ICE_FLOW_FIELD_IDX_ETH_SA,
212 ICE_FLOW_FIELD_IDX_S_VLAN,
213 ICE_FLOW_FIELD_IDX_C_VLAN,
214 ICE_FLOW_FIELD_IDX_ETH_TYPE,
216 ICE_FLOW_FIELD_IDX_IPV4_DSCP,
217 ICE_FLOW_FIELD_IDX_IPV6_DSCP,
218 ICE_FLOW_FIELD_IDX_IPV4_TTL,
219 ICE_FLOW_FIELD_IDX_IPV4_PROT,
220 ICE_FLOW_FIELD_IDX_IPV6_TTL,
221 ICE_FLOW_FIELD_IDX_IPV6_PROT,
222 ICE_FLOW_FIELD_IDX_IPV4_SA,
223 ICE_FLOW_FIELD_IDX_IPV4_DA,
224 ICE_FLOW_FIELD_IDX_IPV6_SA,
225 ICE_FLOW_FIELD_IDX_IPV6_DA,
226 ICE_FLOW_FIELD_IDX_IPV6_PRE32_SA,
227 ICE_FLOW_FIELD_IDX_IPV6_PRE32_DA,
228 ICE_FLOW_FIELD_IDX_IPV6_PRE48_SA,
229 ICE_FLOW_FIELD_IDX_IPV6_PRE48_DA,
230 ICE_FLOW_FIELD_IDX_IPV6_PRE64_SA,
231 ICE_FLOW_FIELD_IDX_IPV6_PRE64_DA,
233 ICE_FLOW_FIELD_IDX_TCP_SRC_PORT,
234 ICE_FLOW_FIELD_IDX_TCP_DST_PORT,
235 ICE_FLOW_FIELD_IDX_UDP_SRC_PORT,
236 ICE_FLOW_FIELD_IDX_UDP_DST_PORT,
237 ICE_FLOW_FIELD_IDX_SCTP_SRC_PORT,
238 ICE_FLOW_FIELD_IDX_SCTP_DST_PORT,
239 ICE_FLOW_FIELD_IDX_TCP_FLAGS,
241 ICE_FLOW_FIELD_IDX_ARP_SIP,
242 ICE_FLOW_FIELD_IDX_ARP_DIP,
243 ICE_FLOW_FIELD_IDX_ARP_SHA,
244 ICE_FLOW_FIELD_IDX_ARP_DHA,
245 ICE_FLOW_FIELD_IDX_ARP_OP,
247 ICE_FLOW_FIELD_IDX_ICMP_TYPE,
248 ICE_FLOW_FIELD_IDX_ICMP_CODE,
250 ICE_FLOW_FIELD_IDX_GRE_KEYID,
252 ICE_FLOW_FIELD_IDX_GTPC_TEID,
254 ICE_FLOW_FIELD_IDX_GTPU_IP_TEID,
256 ICE_FLOW_FIELD_IDX_GTPU_EH_TEID,
257 ICE_FLOW_FIELD_IDX_GTPU_EH_QFI,
259 ICE_FLOW_FIELD_IDX_GTPU_UP_TEID,
261 ICE_FLOW_FIELD_IDX_GTPU_DWN_TEID,
263 ICE_FLOW_FIELD_IDX_PPPOE_SESS_ID,
265 ICE_FLOW_FIELD_IDX_PFCP_SEID,
267 ICE_FLOW_FIELD_IDX_L2TPV3_SESS_ID,
269 ICE_FLOW_FIELD_IDX_ESP_SPI,
271 ICE_FLOW_FIELD_IDX_AH_SPI,
273 ICE_FLOW_FIELD_IDX_NAT_T_ESP_SPI,
275 ICE_FLOW_FIELD_IDX_VXLAN_VNI,
276 /* The total number of enums must not exceed 64 */
277 ICE_FLOW_FIELD_IDX_MAX
280 /* Flow headers and fields for AVF support */
281 enum ice_flow_avf_hdr_field {
282 /* Values 0 - 28 are reserved for future use */
283 ICE_AVF_FLOW_FIELD_INVALID = 0,
284 ICE_AVF_FLOW_FIELD_UNICAST_IPV4_UDP = 29,
285 ICE_AVF_FLOW_FIELD_MULTICAST_IPV4_UDP,
286 ICE_AVF_FLOW_FIELD_IPV4_UDP,
287 ICE_AVF_FLOW_FIELD_IPV4_TCP_SYN_NO_ACK,
288 ICE_AVF_FLOW_FIELD_IPV4_TCP,
289 ICE_AVF_FLOW_FIELD_IPV4_SCTP,
290 ICE_AVF_FLOW_FIELD_IPV4_OTHER,
291 ICE_AVF_FLOW_FIELD_FRAG_IPV4,
292 /* Values 37-38 are reserved */
293 ICE_AVF_FLOW_FIELD_UNICAST_IPV6_UDP = 39,
294 ICE_AVF_FLOW_FIELD_MULTICAST_IPV6_UDP,
295 ICE_AVF_FLOW_FIELD_IPV6_UDP,
296 ICE_AVF_FLOW_FIELD_IPV6_TCP_SYN_NO_ACK,
297 ICE_AVF_FLOW_FIELD_IPV6_TCP,
298 ICE_AVF_FLOW_FIELD_IPV6_SCTP,
299 ICE_AVF_FLOW_FIELD_IPV6_OTHER,
300 ICE_AVF_FLOW_FIELD_FRAG_IPV6,
301 ICE_AVF_FLOW_FIELD_RSVD47,
302 ICE_AVF_FLOW_FIELD_FCOE_OX,
303 ICE_AVF_FLOW_FIELD_FCOE_RX,
304 ICE_AVF_FLOW_FIELD_FCOE_OTHER,
305 /* Values 51-62 are reserved */
306 ICE_AVF_FLOW_FIELD_L2_PAYLOAD = 63,
307 ICE_AVF_FLOW_FIELD_MAX
310 /* Supported RSS offloads This macro is defined to support
311 * VIRTCHNL_OP_GET_RSS_HENA_CAPS ops. PF driver sends the RSS hardware
312 * capabilities to the caller of this ops.
314 #define ICE_DEFAULT_RSS_HENA ( \
315 BIT_ULL(ICE_AVF_FLOW_FIELD_IPV4_UDP) | \
316 BIT_ULL(ICE_AVF_FLOW_FIELD_IPV4_SCTP) | \
317 BIT_ULL(ICE_AVF_FLOW_FIELD_IPV4_TCP) | \
318 BIT_ULL(ICE_AVF_FLOW_FIELD_IPV4_OTHER) | \
319 BIT_ULL(ICE_AVF_FLOW_FIELD_FRAG_IPV4) | \
320 BIT_ULL(ICE_AVF_FLOW_FIELD_IPV6_UDP) | \
321 BIT_ULL(ICE_AVF_FLOW_FIELD_IPV6_TCP) | \
322 BIT_ULL(ICE_AVF_FLOW_FIELD_IPV6_SCTP) | \
323 BIT_ULL(ICE_AVF_FLOW_FIELD_IPV6_OTHER) | \
324 BIT_ULL(ICE_AVF_FLOW_FIELD_FRAG_IPV6) | \
325 BIT_ULL(ICE_AVF_FLOW_FIELD_IPV4_TCP_SYN_NO_ACK) | \
326 BIT_ULL(ICE_AVF_FLOW_FIELD_UNICAST_IPV4_UDP) | \
327 BIT_ULL(ICE_AVF_FLOW_FIELD_MULTICAST_IPV4_UDP) | \
328 BIT_ULL(ICE_AVF_FLOW_FIELD_IPV6_TCP_SYN_NO_ACK) | \
329 BIT_ULL(ICE_AVF_FLOW_FIELD_UNICAST_IPV6_UDP) | \
330 BIT_ULL(ICE_AVF_FLOW_FIELD_MULTICAST_IPV6_UDP))
332 enum ice_rss_cfg_hdr_type {
333 ICE_RSS_OUTER_HEADERS, /* take outer headers as inputset. */
334 ICE_RSS_INNER_HEADERS, /* take inner headers as inputset. */
335 /* take inner headers as inputset for packet with outer ipv4. */
336 ICE_RSS_INNER_HEADERS_W_OUTER_IPV4,
337 /* take inner headers as inputset for packet with outer ipv6. */
338 ICE_RSS_INNER_HEADERS_W_OUTER_IPV6,
339 /* take outer headers first then inner headers as inputset */
343 struct ice_rss_hash_cfg {
344 u32 addl_hdrs; /* protocol header fields */
345 u64 hash_flds; /* hash bit field (ICE_FLOW_HASH_*) to configure */
346 enum ice_rss_cfg_hdr_type hdr_type; /* to specify inner or outer */
347 bool symm; /* symmetric or asymmetric hash */
351 ICE_FLOW_DIR_UNDEFINED = 0,
354 ICE_FLOW_TX_RX = ICE_FLOW_RX | ICE_FLOW_TX
357 enum ice_flow_priority {
359 ICE_FLOW_PRIO_NORMAL,
363 #define ICE_FLOW_SEG_SINGLE 1
364 #define ICE_FLOW_SEG_MAX 2
365 #define ICE_FLOW_SEG_RAW_FLD_MAX 2
366 #define ICE_FLOW_PROFILE_MAX 1024
367 #define ICE_FLOW_SW_FIELD_VECTOR_MAX 48
368 #define ICE_FLOW_ACL_FIELD_VECTOR_MAX 32
369 #define ICE_FLOW_FV_EXTRACT_SZ 2
371 #define ICE_FLOW_SET_HDRS(seg, val) ((seg)->hdrs |= (u32)(val))
373 struct ice_flow_seg_xtrct {
374 u8 prot_id; /* Protocol ID of extracted header field */
375 u16 off; /* Starting offset of the field in header in bytes */
376 u8 idx; /* Index of FV entry used */
377 u8 disp; /* Displacement of field in bits fr. FV entry's start */
378 u16 mask; /* Mask for field */
381 enum ice_flow_fld_match_type {
382 ICE_FLOW_FLD_TYPE_REG, /* Value, mask */
383 ICE_FLOW_FLD_TYPE_RANGE, /* Value, mask, last (upper bound) */
384 ICE_FLOW_FLD_TYPE_PREFIX, /* IP address, prefix, size of prefix */
385 ICE_FLOW_FLD_TYPE_SIZE, /* Value, mask, size of match */
388 struct ice_flow_fld_loc {
389 /* Describe offsets of field information relative to the beginning of
390 * input buffer provided when adding flow entries.
392 u16 val; /* Offset where the value is located */
393 u16 mask; /* Offset where the mask/prefix value is located */
394 u16 last; /* Length or offset where the upper value is located */
397 struct ice_flow_fld_info {
398 enum ice_flow_fld_match_type type;
399 /* Location where to retrieve data from an input buffer */
400 struct ice_flow_fld_loc src;
401 /* Location where to put the data into the final entry buffer */
402 struct ice_flow_fld_loc entry;
403 struct ice_flow_seg_xtrct xtrct;
406 struct ice_flow_seg_fld_raw {
407 struct ice_flow_fld_info info;
408 u16 off; /* Offset from the start of the segment */
411 struct ice_flow_seg_info {
412 u32 hdrs; /* Bitmask indicating protocol headers present */
413 u64 match; /* Bitmask indicating header fields to be matched */
414 u64 range; /* Bitmask indicating header fields matched as ranges */
416 struct ice_flow_fld_info fields[ICE_FLOW_FIELD_IDX_MAX];
418 u8 raws_cnt; /* Number of raw fields to be matched */
419 struct ice_flow_seg_fld_raw raws[ICE_FLOW_SEG_RAW_FLD_MAX];
422 /* This structure describes a flow entry, and is tracked only in this file */
423 struct ice_flow_entry {
424 struct LIST_ENTRY_TYPE l_entry;
427 struct ice_flow_prof *prof;
429 struct ice_flow_action *acts;
430 /* Flow entry's content */
432 /* Range buffer (For ACL only) */
433 struct ice_aqc_acl_profile_ranges *range_buf;
434 enum ice_flow_priority priority;
437 /* Entry index in the ACL's scenario */
439 #define ICE_FLOW_ACL_MAX_NUM_ACT 2
443 #define ICE_FLOW_ENTRY_HNDL(e) ((unsigned long)e)
444 #define ICE_FLOW_ENTRY_PTR(h) ((struct ice_flow_entry *)(h))
446 struct ice_flow_prof {
447 struct LIST_ENTRY_TYPE l_entry;
450 enum ice_flow_dir dir;
454 /* Keep track of flow entries associated with this flow profile */
455 struct ice_lock entries_lock;
456 struct LIST_HEAD_TYPE entries;
458 struct ice_flow_seg_info segs[ICE_FLOW_SEG_MAX];
460 /* software VSI handles referenced by this flow profile */
461 ice_declare_bitmap(vsis, ICE_MAX_VSI);
464 /* struct sw_recipe */
465 struct ice_acl_scen *scen;
468 bool symm; /* Symmetric Hash for RSS */
471 /* Default actions */
472 struct ice_flow_action *acts;
476 struct LIST_ENTRY_TYPE l_entry;
477 /* bitmap of VSIs added to the RSS entry */
478 ice_declare_bitmap(vsis, ICE_MAX_VSI);
479 struct ice_rss_hash_cfg hash;
482 enum ice_flow_action_type {
486 ICE_FLOW_ACT_CNTR_PKT,
487 ICE_FLOW_ACT_FWD_VSI,
488 ICE_FLOW_ACT_FWD_VSI_LIST, /* Should be abstracted away */
489 ICE_FLOW_ACT_FWD_QUEUE, /* Can Queues be abstracted away? */
490 ICE_FLOW_ACT_FWD_QUEUE_GROUP, /* Can Queues be abstracted away? */
494 ICE_FLOW_ACT_CNTR_BYTES,
495 ICE_FLOW_ACT_CNTR_PKT_BYTES,
496 ICE_FLOW_ACT_GENERIC_0,
497 ICE_FLOW_ACT_GENERIC_1,
498 ICE_FLOW_ACT_GENERIC_2,
499 ICE_FLOW_ACT_GENERIC_3,
500 ICE_FLOW_ACT_GENERIC_4,
501 ICE_FLOW_ACT_RPT_FLOW_ID,
502 ICE_FLOW_ACT_BUILD_PROF_IDX,
505 struct ice_flow_action {
506 enum ice_flow_action_type type;
508 struct ice_acl_act_entry acl_act;
514 ice_flow_find_prof(struct ice_hw *hw, enum ice_block blk, enum ice_flow_dir dir,
515 struct ice_flow_seg_info *segs, u8 segs_cnt);
517 ice_flow_add_prof(struct ice_hw *hw, enum ice_block blk, enum ice_flow_dir dir,
518 u64 prof_id, struct ice_flow_seg_info *segs, u8 segs_cnt,
519 struct ice_flow_action *acts, u8 acts_cnt,
520 struct ice_flow_prof **prof);
522 ice_flow_rem_prof(struct ice_hw *hw, enum ice_block blk, u64 prof_id);
524 ice_flow_assoc_prof(struct ice_hw *hw, enum ice_block blk,
525 struct ice_flow_prof *prof, u16 vsi_handle);
527 ice_flow_assoc_vsig_vsi(struct ice_hw *hw, enum ice_block blk, u16 vsi_handle,
530 ice_flow_get_hw_prof(struct ice_hw *hw, enum ice_block blk, u64 prof_id,
533 u64 ice_flow_find_entry(struct ice_hw *hw, enum ice_block blk, u64 entry_id);
535 ice_flow_add_entry(struct ice_hw *hw, enum ice_block blk, u64 prof_id,
536 u64 entry_id, u16 vsi, enum ice_flow_priority prio,
537 void *data, struct ice_flow_action *acts, u8 acts_cnt,
540 ice_flow_rem_entry(struct ice_hw *hw, enum ice_block blk, u64 entry_h);
542 ice_flow_set_fld(struct ice_flow_seg_info *seg, enum ice_flow_field fld,
543 u16 val_loc, u16 mask_loc, u16 last_loc, bool range);
545 ice_flow_set_fld_prefix(struct ice_flow_seg_info *seg, enum ice_flow_field fld,
546 u16 val_loc, u16 prefix_loc, u8 prefix_sz);
548 ice_flow_add_fld_raw(struct ice_flow_seg_info *seg, u16 off, u8 len,
549 u16 val_loc, u16 mask_loc);
550 void ice_rem_vsi_rss_list(struct ice_hw *hw, u16 vsi_handle);
551 enum ice_status ice_replay_rss_cfg(struct ice_hw *hw, u16 vsi_handle);
553 ice_add_avf_rss_cfg(struct ice_hw *hw, u16 vsi_handle, u64 hashed_flds);
554 enum ice_status ice_rem_vsi_rss_cfg(struct ice_hw *hw, u16 vsi_handle);
556 ice_add_rss_cfg(struct ice_hw *hw, u16 vsi_handle,
557 const struct ice_rss_hash_cfg *cfg);
559 ice_rem_rss_cfg(struct ice_hw *hw, u16 vsi_handle,
560 const struct ice_rss_hash_cfg *cfg);
561 u64 ice_get_rss_cfg(struct ice_hw *hw, u16 vsi_handle, u32 hdrs);
562 #endif /* _ICE_FLOW_H_ */