1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2001-2021 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 ICE_FLOW_SEG_HDR_ECPRI_TP0 = 0x04000000,
187 ICE_FLOW_SEG_HDR_UDP_ECPRI_TP0 = 0x08000000,
188 ICE_FLOW_SEG_HDR_L2TPV2 = 0x10000000,
189 ICE_FLOW_SEG_HDR_PPP = 0x20000000,
190 /* The following is an additive bit for ICE_FLOW_SEG_HDR_IPV4 and
191 * ICE_FLOW_SEG_HDR_IPV6.
193 ICE_FLOW_SEG_HDR_IPV_FRAG = 0x40000000,
194 ICE_FLOW_SEG_HDR_IPV_OTHER = 0x80000000,
197 /* These segements all have the same PTYPES, but are otherwise distinguished by
198 * the value of the gtp_eh_pdu and gtp_eh_pdu_link flags:
200 * gtp_eh_pdu gtp_eh_pdu_link
201 * ICE_FLOW_SEG_HDR_GTPU_IP 0 0
202 * ICE_FLOW_SEG_HDR_GTPU_EH 1 don't care
203 * ICE_FLOW_SEG_HDR_GTPU_DWN 1 0
204 * ICE_FLOW_SEG_HDR_GTPU_UP 1 1
206 #define ICE_FLOW_SEG_HDR_GTPU (ICE_FLOW_SEG_HDR_GTPU_IP | \
207 ICE_FLOW_SEG_HDR_GTPU_EH | \
208 ICE_FLOW_SEG_HDR_GTPU_DWN | \
209 ICE_FLOW_SEG_HDR_GTPU_UP)
210 #define ICE_FLOW_SEG_HDR_PFCP (ICE_FLOW_SEG_HDR_PFCP_NODE | \
211 ICE_FLOW_SEG_HDR_PFCP_SESSION)
213 enum ice_flow_field {
215 ICE_FLOW_FIELD_IDX_ETH_DA,
216 ICE_FLOW_FIELD_IDX_ETH_SA,
217 ICE_FLOW_FIELD_IDX_S_VLAN,
218 ICE_FLOW_FIELD_IDX_C_VLAN,
219 ICE_FLOW_FIELD_IDX_ETH_TYPE,
221 ICE_FLOW_FIELD_IDX_IPV4_DSCP,
222 ICE_FLOW_FIELD_IDX_IPV6_DSCP,
223 ICE_FLOW_FIELD_IDX_IPV4_TTL,
224 ICE_FLOW_FIELD_IDX_IPV4_PROT,
225 ICE_FLOW_FIELD_IDX_IPV6_TTL,
226 ICE_FLOW_FIELD_IDX_IPV6_PROT,
227 ICE_FLOW_FIELD_IDX_IPV4_SA,
228 ICE_FLOW_FIELD_IDX_IPV4_DA,
229 ICE_FLOW_FIELD_IDX_IPV6_SA,
230 ICE_FLOW_FIELD_IDX_IPV6_DA,
231 ICE_FLOW_FIELD_IDX_IPV4_CHKSUM,
232 ICE_FLOW_FIELD_IDX_IPV4_ID,
233 ICE_FLOW_FIELD_IDX_IPV6_ID,
234 ICE_FLOW_FIELD_IDX_IPV6_PRE32_SA,
235 ICE_FLOW_FIELD_IDX_IPV6_PRE32_DA,
236 ICE_FLOW_FIELD_IDX_IPV6_PRE48_SA,
237 ICE_FLOW_FIELD_IDX_IPV6_PRE48_DA,
238 ICE_FLOW_FIELD_IDX_IPV6_PRE64_SA,
239 ICE_FLOW_FIELD_IDX_IPV6_PRE64_DA,
241 ICE_FLOW_FIELD_IDX_TCP_SRC_PORT,
242 ICE_FLOW_FIELD_IDX_TCP_DST_PORT,
243 ICE_FLOW_FIELD_IDX_UDP_SRC_PORT,
244 ICE_FLOW_FIELD_IDX_UDP_DST_PORT,
245 ICE_FLOW_FIELD_IDX_SCTP_SRC_PORT,
246 ICE_FLOW_FIELD_IDX_SCTP_DST_PORT,
247 ICE_FLOW_FIELD_IDX_TCP_FLAGS,
248 ICE_FLOW_FIELD_IDX_TCP_CHKSUM,
249 ICE_FLOW_FIELD_IDX_UDP_CHKSUM,
250 ICE_FLOW_FIELD_IDX_SCTP_CHKSUM,
252 ICE_FLOW_FIELD_IDX_ARP_SIP,
253 ICE_FLOW_FIELD_IDX_ARP_DIP,
254 ICE_FLOW_FIELD_IDX_ARP_SHA,
255 ICE_FLOW_FIELD_IDX_ARP_DHA,
256 ICE_FLOW_FIELD_IDX_ARP_OP,
258 ICE_FLOW_FIELD_IDX_ICMP_TYPE,
259 ICE_FLOW_FIELD_IDX_ICMP_CODE,
261 ICE_FLOW_FIELD_IDX_GRE_KEYID,
263 ICE_FLOW_FIELD_IDX_GTPC_TEID,
265 ICE_FLOW_FIELD_IDX_GTPU_IP_TEID,
267 ICE_FLOW_FIELD_IDX_GTPU_EH_TEID,
268 ICE_FLOW_FIELD_IDX_GTPU_EH_QFI,
270 ICE_FLOW_FIELD_IDX_GTPU_UP_TEID,
271 ICE_FLOW_FIELD_IDX_GTPU_UP_QFI,
273 ICE_FLOW_FIELD_IDX_GTPU_DWN_TEID,
274 ICE_FLOW_FIELD_IDX_GTPU_DWN_QFI,
276 ICE_FLOW_FIELD_IDX_PPPOE_SESS_ID,
278 ICE_FLOW_FIELD_IDX_PFCP_SEID,
280 ICE_FLOW_FIELD_IDX_L2TPV3_SESS_ID,
282 ICE_FLOW_FIELD_IDX_ESP_SPI,
284 ICE_FLOW_FIELD_IDX_AH_SPI,
286 ICE_FLOW_FIELD_IDX_NAT_T_ESP_SPI,
288 ICE_FLOW_FIELD_IDX_VXLAN_VNI,
290 ICE_FLOW_FIELD_IDX_ECPRI_TP0_PC_ID,
292 ICE_FLOW_FIELD_IDX_UDP_ECPRI_TP0_PC_ID,
293 /* The total number of enums must not exceed 64 */
294 ICE_FLOW_FIELD_IDX_MAX
297 /* Flow headers and fields for AVF support */
298 enum ice_flow_avf_hdr_field {
299 /* Values 0 - 28 are reserved for future use */
300 ICE_AVF_FLOW_FIELD_INVALID = 0,
301 ICE_AVF_FLOW_FIELD_UNICAST_IPV4_UDP = 29,
302 ICE_AVF_FLOW_FIELD_MULTICAST_IPV4_UDP,
303 ICE_AVF_FLOW_FIELD_IPV4_UDP,
304 ICE_AVF_FLOW_FIELD_IPV4_TCP_SYN_NO_ACK,
305 ICE_AVF_FLOW_FIELD_IPV4_TCP,
306 ICE_AVF_FLOW_FIELD_IPV4_SCTP,
307 ICE_AVF_FLOW_FIELD_IPV4_OTHER,
308 ICE_AVF_FLOW_FIELD_FRAG_IPV4,
309 /* Values 37-38 are reserved */
310 ICE_AVF_FLOW_FIELD_UNICAST_IPV6_UDP = 39,
311 ICE_AVF_FLOW_FIELD_MULTICAST_IPV6_UDP,
312 ICE_AVF_FLOW_FIELD_IPV6_UDP,
313 ICE_AVF_FLOW_FIELD_IPV6_TCP_SYN_NO_ACK,
314 ICE_AVF_FLOW_FIELD_IPV6_TCP,
315 ICE_AVF_FLOW_FIELD_IPV6_SCTP,
316 ICE_AVF_FLOW_FIELD_IPV6_OTHER,
317 ICE_AVF_FLOW_FIELD_FRAG_IPV6,
318 ICE_AVF_FLOW_FIELD_RSVD47,
319 ICE_AVF_FLOW_FIELD_FCOE_OX,
320 ICE_AVF_FLOW_FIELD_FCOE_RX,
321 ICE_AVF_FLOW_FIELD_FCOE_OTHER,
322 /* Values 51-62 are reserved */
323 ICE_AVF_FLOW_FIELD_L2_PAYLOAD = 63,
324 ICE_AVF_FLOW_FIELD_MAX
327 /* Supported RSS offloads This macro is defined to support
328 * VIRTCHNL_OP_GET_RSS_HENA_CAPS ops. PF driver sends the RSS hardware
329 * capabilities to the caller of this ops.
331 #define ICE_DEFAULT_RSS_HENA ( \
332 BIT_ULL(ICE_AVF_FLOW_FIELD_IPV4_UDP) | \
333 BIT_ULL(ICE_AVF_FLOW_FIELD_IPV4_SCTP) | \
334 BIT_ULL(ICE_AVF_FLOW_FIELD_IPV4_TCP) | \
335 BIT_ULL(ICE_AVF_FLOW_FIELD_IPV4_OTHER) | \
336 BIT_ULL(ICE_AVF_FLOW_FIELD_FRAG_IPV4) | \
337 BIT_ULL(ICE_AVF_FLOW_FIELD_IPV6_UDP) | \
338 BIT_ULL(ICE_AVF_FLOW_FIELD_IPV6_TCP) | \
339 BIT_ULL(ICE_AVF_FLOW_FIELD_IPV6_SCTP) | \
340 BIT_ULL(ICE_AVF_FLOW_FIELD_IPV6_OTHER) | \
341 BIT_ULL(ICE_AVF_FLOW_FIELD_FRAG_IPV6) | \
342 BIT_ULL(ICE_AVF_FLOW_FIELD_IPV4_TCP_SYN_NO_ACK) | \
343 BIT_ULL(ICE_AVF_FLOW_FIELD_UNICAST_IPV4_UDP) | \
344 BIT_ULL(ICE_AVF_FLOW_FIELD_MULTICAST_IPV4_UDP) | \
345 BIT_ULL(ICE_AVF_FLOW_FIELD_IPV6_TCP_SYN_NO_ACK) | \
346 BIT_ULL(ICE_AVF_FLOW_FIELD_UNICAST_IPV6_UDP) | \
347 BIT_ULL(ICE_AVF_FLOW_FIELD_MULTICAST_IPV6_UDP))
349 enum ice_rss_cfg_hdr_type {
350 ICE_RSS_OUTER_HEADERS, /* take outer headers as inputset. */
351 ICE_RSS_INNER_HEADERS, /* take inner headers as inputset. */
352 /* take inner headers as inputset for packet with outer ipv4. */
353 ICE_RSS_INNER_HEADERS_W_OUTER_IPV4,
354 /* take inner headers as inputset for packet with outer ipv6. */
355 ICE_RSS_INNER_HEADERS_W_OUTER_IPV6,
356 /* take outer headers first then inner headers as inputset */
357 /* take inner as inputset for GTPoGRE with outer ipv4 + gre. */
358 ICE_RSS_INNER_HEADERS_W_OUTER_IPV4_GRE,
359 /* take inner as inputset for GTPoGRE with outer ipv6 + gre. */
360 ICE_RSS_INNER_HEADERS_W_OUTER_IPV6_GRE,
364 struct ice_rss_hash_cfg {
365 u32 addl_hdrs; /* protocol header fields */
366 u64 hash_flds; /* hash bit field (ICE_FLOW_HASH_*) to configure */
367 enum ice_rss_cfg_hdr_type hdr_type; /* to specify inner or outer */
368 bool symm; /* symmetric or asymmetric hash */
372 ICE_FLOW_DIR_UNDEFINED = 0,
375 ICE_FLOW_TX_RX = ICE_FLOW_RX | ICE_FLOW_TX
378 enum ice_flow_priority {
380 ICE_FLOW_PRIO_NORMAL,
384 #define ICE_FLOW_SEG_SINGLE 1
385 #define ICE_FLOW_SEG_MAX 2
386 #define ICE_FLOW_SEG_RAW_FLD_MAX 2
387 #define ICE_FLOW_PROFILE_MAX 1024
388 #define ICE_FLOW_SW_FIELD_VECTOR_MAX 48
389 #define ICE_FLOW_ACL_FIELD_VECTOR_MAX 32
390 #define ICE_FLOW_FV_EXTRACT_SZ 2
392 #define ICE_FLOW_SET_HDRS(seg, val) ((seg)->hdrs |= (u32)(val))
394 struct ice_flow_seg_xtrct {
395 u8 prot_id; /* Protocol ID of extracted header field */
396 u16 off; /* Starting offset of the field in header in bytes */
397 u8 idx; /* Index of FV entry used */
398 u8 disp; /* Displacement of field in bits fr. FV entry's start */
399 u16 mask; /* Mask for field */
402 enum ice_flow_fld_match_type {
403 ICE_FLOW_FLD_TYPE_REG, /* Value, mask */
404 ICE_FLOW_FLD_TYPE_RANGE, /* Value, mask, last (upper bound) */
405 ICE_FLOW_FLD_TYPE_PREFIX, /* IP address, prefix, size of prefix */
406 ICE_FLOW_FLD_TYPE_SIZE, /* Value, mask, size of match */
409 struct ice_flow_fld_loc {
410 /* Describe offsets of field information relative to the beginning of
411 * input buffer provided when adding flow entries.
413 u16 val; /* Offset where the value is located */
414 u16 mask; /* Offset where the mask/prefix value is located */
415 u16 last; /* Length or offset where the upper value is located */
418 struct ice_flow_fld_info {
419 enum ice_flow_fld_match_type type;
420 /* Location where to retrieve data from an input buffer */
421 struct ice_flow_fld_loc src;
422 /* Location where to put the data into the final entry buffer */
423 struct ice_flow_fld_loc entry;
424 struct ice_flow_seg_xtrct xtrct;
427 struct ice_flow_seg_fld_raw {
428 struct ice_flow_fld_info info;
429 u16 off; /* Offset from the start of the segment */
432 struct ice_flow_seg_info {
433 u32 hdrs; /* Bitmask indicating protocol headers present */
434 u64 match; /* Bitmask indicating header fields to be matched */
435 u64 range; /* Bitmask indicating header fields matched as ranges */
437 struct ice_flow_fld_info fields[ICE_FLOW_FIELD_IDX_MAX];
439 u8 raws_cnt; /* Number of raw fields to be matched */
440 struct ice_flow_seg_fld_raw raws[ICE_FLOW_SEG_RAW_FLD_MAX];
443 /* This structure describes a flow entry, and is tracked only in this file */
444 struct ice_flow_entry {
445 struct LIST_ENTRY_TYPE l_entry;
448 struct ice_flow_prof *prof;
450 struct ice_flow_action *acts;
451 /* Flow entry's content */
453 /* Range buffer (For ACL only) */
454 struct ice_aqc_acl_profile_ranges *range_buf;
455 enum ice_flow_priority priority;
458 /* Entry index in the ACL's scenario */
460 #define ICE_FLOW_ACL_MAX_NUM_ACT 2
464 #define ICE_FLOW_ENTRY_HNDL(e) ((intptr_t)e)
465 #define ICE_FLOW_ENTRY_PTR(h) ((struct ice_flow_entry *)(h))
467 struct ice_flow_prof {
468 struct LIST_ENTRY_TYPE l_entry;
471 enum ice_flow_dir dir;
475 /* Keep track of flow entries associated with this flow profile */
476 struct ice_lock entries_lock;
477 struct LIST_HEAD_TYPE entries;
479 struct ice_flow_seg_info segs[ICE_FLOW_SEG_MAX];
481 /* software VSI handles referenced by this flow profile */
482 ice_declare_bitmap(vsis, ICE_MAX_VSI);
485 /* struct sw_recipe */
486 struct ice_acl_scen *scen;
489 bool symm; /* Symmetric Hash for RSS */
492 /* Default actions */
493 struct ice_flow_action *acts;
497 struct LIST_ENTRY_TYPE l_entry;
498 /* bitmap of VSIs added to the RSS entry */
499 ice_declare_bitmap(vsis, ICE_MAX_VSI);
500 struct ice_rss_hash_cfg hash;
503 enum ice_flow_action_type {
507 ICE_FLOW_ACT_CNTR_PKT,
508 ICE_FLOW_ACT_FWD_VSI,
509 ICE_FLOW_ACT_FWD_VSI_LIST, /* Should be abstracted away */
510 ICE_FLOW_ACT_FWD_QUEUE, /* Can Queues be abstracted away? */
511 ICE_FLOW_ACT_FWD_QUEUE_GROUP, /* Can Queues be abstracted away? */
515 ICE_FLOW_ACT_CNTR_BYTES,
516 ICE_FLOW_ACT_CNTR_PKT_BYTES,
517 ICE_FLOW_ACT_GENERIC_0,
518 ICE_FLOW_ACT_GENERIC_1,
519 ICE_FLOW_ACT_GENERIC_2,
520 ICE_FLOW_ACT_GENERIC_3,
521 ICE_FLOW_ACT_GENERIC_4,
522 ICE_FLOW_ACT_RPT_FLOW_ID,
523 ICE_FLOW_ACT_BUILD_PROF_IDX,
526 struct ice_flow_action {
527 enum ice_flow_action_type type;
529 struct ice_acl_act_entry acl_act;
535 ice_flow_find_prof(struct ice_hw *hw, enum ice_block blk, enum ice_flow_dir dir,
536 struct ice_flow_seg_info *segs, u8 segs_cnt);
538 ice_flow_add_prof(struct ice_hw *hw, enum ice_block blk, enum ice_flow_dir dir,
539 u64 prof_id, struct ice_flow_seg_info *segs, u8 segs_cnt,
540 struct ice_flow_action *acts, u8 acts_cnt,
541 struct ice_flow_prof **prof);
543 ice_flow_rem_prof(struct ice_hw *hw, enum ice_block blk, u64 prof_id);
545 ice_flow_assoc_prof(struct ice_hw *hw, enum ice_block blk,
546 struct ice_flow_prof *prof, u16 vsi_handle);
548 ice_flow_assoc_vsig_vsi(struct ice_hw *hw, enum ice_block blk, u16 vsi_handle,
551 ice_flow_set_hw_prof(struct ice_hw *hw, u16 dest_vsi_handle,
552 u16 fdir_vsi_handle, struct ice_parser_profile *prof,
555 ice_flow_get_hw_prof(struct ice_hw *hw, enum ice_block blk, u64 prof_id,
558 u64 ice_flow_find_entry(struct ice_hw *hw, enum ice_block blk, u64 entry_id);
560 ice_flow_add_entry(struct ice_hw *hw, enum ice_block blk, u64 prof_id,
561 u64 entry_id, u16 vsi, enum ice_flow_priority prio,
562 void *data, struct ice_flow_action *acts, u8 acts_cnt,
565 ice_flow_rem_entry(struct ice_hw *hw, enum ice_block blk, u64 entry_h);
567 ice_flow_set_fld(struct ice_flow_seg_info *seg, enum ice_flow_field fld,
568 u16 val_loc, u16 mask_loc, u16 last_loc, bool range);
570 ice_flow_set_fld_prefix(struct ice_flow_seg_info *seg, enum ice_flow_field fld,
571 u16 val_loc, u16 prefix_loc, u8 prefix_sz);
573 ice_flow_add_fld_raw(struct ice_flow_seg_info *seg, u16 off, u8 len,
574 u16 val_loc, u16 mask_loc);
575 enum ice_status ice_flow_rem_vsi_prof(struct ice_hw *hw, enum ice_block blk,
576 u16 vsi_handle, u64 prof_id);
577 void ice_rem_vsi_rss_list(struct ice_hw *hw, u16 vsi_handle);
578 enum ice_status ice_replay_rss_cfg(struct ice_hw *hw, u16 vsi_handle);
580 ice_add_avf_rss_cfg(struct ice_hw *hw, u16 vsi_handle, u64 hashed_flds);
581 enum ice_status ice_rem_vsi_rss_cfg(struct ice_hw *hw, u16 vsi_handle);
583 ice_add_rss_cfg(struct ice_hw *hw, u16 vsi_handle,
584 const struct ice_rss_hash_cfg *cfg);
586 ice_rem_rss_cfg(struct ice_hw *hw, u16 vsi_handle,
587 const struct ice_rss_hash_cfg *cfg);
588 u64 ice_get_rss_cfg(struct ice_hw *hw, u16 vsi_handle, u32 hdrs);
589 #endif /* _ICE_FLOW_H_ */