1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2001-2020 Intel Corporation
5 #include "ice_common.h"
8 /* These are training packet headers used to program flow director filters. */
9 static const u8 ice_fdir_tcpv4_pkt[] = {
10 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
11 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x45, 0x00,
12 0x00, 0x28, 0x00, 0x01, 0x00, 0x00, 0x40, 0x06,
13 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x00,
16 0x20, 0x00, 0x00, 0x00, 0x00, 0x00
19 static const u8 ice_fdir_udpv4_pkt[] = {
20 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x45, 0x00,
22 0x00, 0x1C, 0x00, 0x00, 0x40, 0x00, 0x40, 0x11,
23 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28 static const u8 ice_fdir_sctpv4_pkt[] = {
29 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x45, 0x00,
31 0x00, 0x20, 0x00, 0x00, 0x40, 0x00, 0x40, 0x84,
32 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37 static const u8 ice_fdir_ipv4_pkt[] = {
38 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x45, 0x00,
40 0x00, 0x14, 0x00, 0x00, 0x40, 0x00, 0x40, 0x10,
41 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45 static const u8 ice_fdir_udp4_gtpu4_pkt[] = {
46 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x45, 0x00,
48 0x00, 0x4c, 0x00, 0x00, 0x40, 0x00, 0x40, 0x11,
49 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50 0x00, 0x00, 0x08, 0x68, 0x08, 0x68, 0x00, 0x00,
51 0x00, 0x00, 0x34, 0xff, 0x00, 0x28, 0x00, 0x00,
52 0x00, 0x00, 0x00, 0x00, 0x00, 0x85, 0x02, 0x00,
53 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x45, 0x00,
54 0x00, 0x1c, 0x00, 0x00, 0x40, 0x00, 0x40, 0x11,
55 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
56 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
60 static const u8 ice_fdir_tcp4_gtpu4_pkt[] = {
61 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
62 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x45, 0x00,
63 0x00, 0x58, 0x00, 0x00, 0x40, 0x00, 0x40, 0x11,
64 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
65 0x00, 0x00, 0x08, 0x68, 0x08, 0x68, 0x00, 0x00,
66 0x00, 0x00, 0x34, 0xff, 0x00, 0x28, 0x00, 0x00,
67 0x00, 0x00, 0x00, 0x00, 0x00, 0x85, 0x02, 0x00,
68 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x45, 0x00,
69 0x00, 0x28, 0x00, 0x00, 0x40, 0x00, 0x40, 0x06,
70 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
71 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
72 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
73 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
76 static const u8 ice_fdir_icmp4_gtpu4_pkt[] = {
77 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
78 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x45, 0x00,
79 0x00, 0x4c, 0x00, 0x00, 0x40, 0x00, 0x40, 0x11,
80 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
81 0x00, 0x00, 0x08, 0x68, 0x08, 0x68, 0x00, 0x00,
82 0x00, 0x00, 0x34, 0xff, 0x00, 0x28, 0x00, 0x00,
83 0x00, 0x00, 0x00, 0x00, 0x00, 0x85, 0x02, 0x00,
84 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x45, 0x00,
85 0x00, 0x1c, 0x00, 0x00, 0x40, 0x00, 0x40, 0x01,
86 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
87 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
91 static const u8 ice_fdir_ipv4_gtpu4_pkt[] = {
92 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
93 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x45, 0x00,
94 0x00, 0x44, 0x00, 0x00, 0x40, 0x00, 0x40, 0x11,
95 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
96 0x00, 0x00, 0x08, 0x68, 0x08, 0x68, 0x00, 0x00,
97 0x00, 0x00, 0x34, 0xff, 0x00, 0x28, 0x00, 0x00,
98 0x00, 0x00, 0x00, 0x00, 0x00, 0x85, 0x02, 0x00,
99 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x45, 0x00,
100 0x00, 0x14, 0x00, 0x00, 0x40, 0x00, 0x40, 0x00,
101 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
105 static const u8 ice_fdir_ipv4_l2tpv3_pkt[] = {
106 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
107 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x45, 0x00,
108 0x00, 0x14, 0x00, 0x00, 0x40, 0x00, 0x40, 0x73,
109 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
110 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
111 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
114 static const u8 ice_fdir_ipv6_l2tpv3_pkt[] = {
115 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
116 0x00, 0x00, 0x00, 0x00, 0x86, 0xDD, 0x60, 0x00,
117 0x00, 0x00, 0x00, 0x00, 0x73, 0x40, 0x00, 0x00,
118 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
119 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
120 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
121 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
122 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
126 static const u8 ice_fdir_ipv4_esp_pkt[] = {
127 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
128 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x45, 0x00,
129 0x00, 0x14, 0x00, 0x00, 0x40, 0x00, 0x40, 0x32,
130 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
131 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
135 static const u8 ice_fdir_ipv6_esp_pkt[] = {
136 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
137 0x00, 0x00, 0x00, 0x00, 0x86, 0xDD, 0x60, 0x00,
138 0x00, 0x00, 0x00, 0x00, 0x32, 0x40, 0x00, 0x00,
139 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
140 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
141 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
142 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
143 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
146 static const u8 ice_fdir_ipv4_ah_pkt[] = {
147 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
148 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x45, 0x00,
149 0x00, 0x14, 0x00, 0x00, 0x40, 0x00, 0x40, 0x33,
150 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
151 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
152 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
156 static const u8 ice_fdir_ipv6_ah_pkt[] = {
157 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
158 0x00, 0x00, 0x00, 0x00, 0x86, 0xDD, 0x60, 0x00,
159 0x00, 0x00, 0x00, 0x00, 0x33, 0x40, 0x00, 0x00,
160 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
161 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
162 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
163 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
164 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
165 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
168 static const u8 ice_fdir_ipv4_nat_t_esp_pkt[] = {
169 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
170 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x45, 0x00,
171 0x00, 0x1C, 0x00, 0x00, 0x40, 0x00, 0x40, 0x11,
172 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
173 0x00, 0x00, 0x00, 0x00, 0x11, 0x94, 0x00, 0x00,
174 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
178 static const u8 ice_fdir_ipv6_nat_t_esp_pkt[] = {
179 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
180 0x00, 0x00, 0x00, 0x00, 0x86, 0xDD, 0x60, 0x00,
181 0x00, 0x00, 0x00, 0x08, 0x11, 0x40, 0x00, 0x00,
182 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
183 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
184 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
185 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
186 0x11, 0x94, 0x00, 0x00, 0x00, 0x08,
189 static const u8 ice_fdir_ipv4_pfcp_node_pkt[] = {
190 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
191 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x45, 0x00,
192 0x00, 0x2C, 0x00, 0x00, 0x40, 0x00, 0x40, 0x11,
193 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
194 0x00, 0x00, 0x22, 0x65, 0x22, 0x65, 0x00, 0x00,
195 0x00, 0x00, 0x20, 0x00, 0x00, 0x10, 0x00, 0x00,
196 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
200 static const u8 ice_fdir_ipv4_pfcp_session_pkt[] = {
201 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
202 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x45, 0x00,
203 0x00, 0x2C, 0x00, 0x00, 0x40, 0x00, 0x40, 0x11,
204 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
205 0x00, 0x00, 0x22, 0x65, 0x22, 0x65, 0x00, 0x00,
206 0x00, 0x00, 0x21, 0x00, 0x00, 0x10, 0x00, 0x00,
207 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
211 static const u8 ice_fdir_ipv6_pfcp_node_pkt[] = {
212 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
213 0x00, 0x00, 0x00, 0x00, 0x86, 0xDD, 0x60, 0x00,
214 0x00, 0x00, 0x00, 0x18, 0x11, 0x40, 0x00, 0x00,
215 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
216 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
217 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
218 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x65,
219 0x22, 0x65, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00,
220 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
221 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
224 static const u8 ice_fdir_ipv6_pfcp_session_pkt[] = {
225 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
226 0x00, 0x00, 0x00, 0x00, 0x86, 0xDD, 0x60, 0x00,
227 0x00, 0x00, 0x00, 0x18, 0x11, 0x40, 0x00, 0x00,
228 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
229 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
230 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
231 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x65,
232 0x22, 0x65, 0x00, 0x00, 0x00, 0x00, 0x21, 0x00,
233 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
234 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
237 static const u8 ice_fdir_non_ip_l2_pkt[] = {
238 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
239 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
240 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
243 static const u8 ice_fdir_tcpv6_pkt[] = {
244 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
245 0x00, 0x00, 0x00, 0x00, 0x86, 0xDD, 0x60, 0x00,
246 0x00, 0x00, 0x00, 0x14, 0x06, 0x40, 0x00, 0x00,
247 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
248 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
249 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
250 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
251 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
252 0x00, 0x00, 0x50, 0x00, 0x20, 0x00, 0x00, 0x00,
256 static const u8 ice_fdir_udpv6_pkt[] = {
257 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
258 0x00, 0x00, 0x00, 0x00, 0x86, 0xDD, 0x60, 0x00,
259 0x00, 0x00, 0x00, 0x08, 0x11, 0x40, 0x00, 0x00,
260 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
261 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
262 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
263 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
264 0x00, 0x00, 0x00, 0x08, 0x00, 0x00,
267 static const u8 ice_fdir_sctpv6_pkt[] = {
268 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
269 0x00, 0x00, 0x00, 0x00, 0x86, 0xDD, 0x60, 0x00,
270 0x00, 0x00, 0x00, 0x0C, 0x84, 0x40, 0x00, 0x00,
271 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
272 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
273 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
274 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
275 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
279 static const u8 ice_fdir_ipv6_pkt[] = {
280 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
281 0x00, 0x00, 0x00, 0x00, 0x86, 0xDD, 0x60, 0x00,
282 0x00, 0x00, 0x00, 0x00, 0x3B, 0x40, 0x00, 0x00,
283 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
284 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
285 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
286 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
289 static const u8 ice_fdir_tcp4_tun_pkt[] = {
290 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
291 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x45, 0x00,
292 0x00, 0x5a, 0x00, 0x00, 0x40, 0x00, 0x40, 0x11,
293 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
294 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
295 0x00, 0x00, 0x04, 0x00, 0x00, 0x03, 0x00, 0x00,
296 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
297 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00,
298 0x45, 0x00, 0x00, 0x28, 0x00, 0x00, 0x40, 0x00,
299 0x40, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
300 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
301 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
302 0x50, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
305 static const u8 ice_fdir_udp4_tun_pkt[] = {
306 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
307 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x45, 0x00,
308 0x00, 0x4e, 0x00, 0x00, 0x40, 0x00, 0x40, 0x11,
309 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
310 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
311 0x00, 0x00, 0x04, 0x00, 0x00, 0x03, 0x00, 0x00,
312 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
313 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00,
314 0x45, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x40, 0x00,
315 0x40, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
316 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
317 0x00, 0x00, 0x00, 0x00,
320 static const u8 ice_fdir_sctp4_tun_pkt[] = {
321 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
322 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x45, 0x00,
323 0x00, 0x52, 0x00, 0x00, 0x40, 0x00, 0x40, 0x11,
324 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
325 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
326 0x00, 0x00, 0x04, 0x00, 0x00, 0x03, 0x00, 0x00,
327 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
328 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00,
329 0x45, 0x00, 0x00, 0x20, 0x00, 0x01, 0x00, 0x00,
330 0x40, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
331 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
332 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
335 static const u8 ice_fdir_ip4_tun_pkt[] = {
336 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
337 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x45, 0x00,
338 0x00, 0x46, 0x00, 0x00, 0x40, 0x00, 0x40, 0x11,
339 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
340 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
341 0x00, 0x00, 0x04, 0x00, 0x00, 0x03, 0x00, 0x00,
342 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
343 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00,
344 0x45, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00,
345 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
346 0x00, 0x00, 0x00, 0x00,
349 static const u8 ice_fdir_tcp6_tun_pkt[] = {
350 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
351 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x45, 0x00,
352 0x00, 0x6e, 0x00, 0x00, 0x40, 0x00, 0x40, 0x11,
353 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
354 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
355 0x00, 0x00, 0x04, 0x00, 0x00, 0x03, 0x00, 0x00,
356 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
357 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x86, 0xdd,
358 0x60, 0x00, 0x00, 0x00, 0x00, 0x14, 0x06, 0x40,
359 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
360 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
361 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
362 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
363 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
364 0x00, 0x00, 0x00, 0x00, 0x50, 0x00, 0x20, 0x00,
365 0x00, 0x00, 0x00, 0x00,
368 static const u8 ice_fdir_udp6_tun_pkt[] = {
369 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
370 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x45, 0x00,
371 0x00, 0x62, 0x00, 0x00, 0x40, 0x00, 0x40, 0x11,
372 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
373 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
374 0x00, 0x00, 0x04, 0x00, 0x00, 0x03, 0x00, 0x00,
375 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
376 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x86, 0xdd,
377 0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x11, 0x40,
378 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
379 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
380 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
381 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
382 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
385 static const u8 ice_fdir_sctp6_tun_pkt[] = {
386 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
387 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x45, 0x00,
388 0x00, 0x66, 0x00, 0x00, 0x40, 0x00, 0x40, 0x11,
389 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
390 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
391 0x00, 0x00, 0x04, 0x00, 0x00, 0x03, 0x00, 0x00,
392 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
393 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x86, 0xdd,
394 0x60, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x84, 0x40,
395 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
396 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
397 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
398 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
399 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
400 0x00, 0x00, 0x00, 0x00,
403 static const u8 ice_fdir_ip6_tun_pkt[] = {
404 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
405 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x45, 0x00,
406 0x00, 0x5a, 0x00, 0x00, 0x40, 0x00, 0x40, 0x11,
407 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
408 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
409 0x00, 0x00, 0x04, 0x00, 0x00, 0x03, 0x00, 0x00,
410 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
411 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x86, 0xdd,
412 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3b, 0x40,
413 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
414 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
415 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
416 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
419 /* Flow Director no-op training packet table */
420 static const struct ice_fdir_base_pkt ice_fdir_pkt[] = {
422 ICE_FLTR_PTYPE_NONF_IPV4_TCP,
423 sizeof(ice_fdir_tcpv4_pkt), ice_fdir_tcpv4_pkt,
424 sizeof(ice_fdir_tcp4_tun_pkt), ice_fdir_tcp4_tun_pkt,
427 ICE_FLTR_PTYPE_NONF_IPV4_UDP,
428 sizeof(ice_fdir_udpv4_pkt), ice_fdir_udpv4_pkt,
429 sizeof(ice_fdir_udp4_tun_pkt), ice_fdir_udp4_tun_pkt,
432 ICE_FLTR_PTYPE_NONF_IPV4_SCTP,
433 sizeof(ice_fdir_sctpv4_pkt), ice_fdir_sctpv4_pkt,
434 sizeof(ice_fdir_sctp4_tun_pkt), ice_fdir_sctp4_tun_pkt,
437 ICE_FLTR_PTYPE_NONF_IPV4_OTHER,
438 sizeof(ice_fdir_ipv4_pkt), ice_fdir_ipv4_pkt,
439 sizeof(ice_fdir_ip4_tun_pkt), ice_fdir_ip4_tun_pkt,
442 ICE_FLTR_PTYPE_NONF_IPV4_GTPU_IPV4_UDP,
443 sizeof(ice_fdir_udp4_gtpu4_pkt),
444 ice_fdir_udp4_gtpu4_pkt,
445 sizeof(ice_fdir_udp4_gtpu4_pkt),
446 ice_fdir_udp4_gtpu4_pkt,
449 ICE_FLTR_PTYPE_NONF_IPV4_GTPU_IPV4_TCP,
450 sizeof(ice_fdir_tcp4_gtpu4_pkt),
451 ice_fdir_tcp4_gtpu4_pkt,
452 sizeof(ice_fdir_tcp4_gtpu4_pkt),
453 ice_fdir_tcp4_gtpu4_pkt,
456 ICE_FLTR_PTYPE_NONF_IPV4_GTPU_IPV4_ICMP,
457 sizeof(ice_fdir_icmp4_gtpu4_pkt),
458 ice_fdir_icmp4_gtpu4_pkt,
459 sizeof(ice_fdir_icmp4_gtpu4_pkt),
460 ice_fdir_icmp4_gtpu4_pkt,
463 ICE_FLTR_PTYPE_NONF_IPV4_GTPU_IPV4_OTHER,
464 sizeof(ice_fdir_ipv4_gtpu4_pkt),
465 ice_fdir_ipv4_gtpu4_pkt,
466 sizeof(ice_fdir_ipv4_gtpu4_pkt),
467 ice_fdir_ipv4_gtpu4_pkt,
470 ICE_FLTR_PTYPE_NONF_IPV4_L2TPV3,
471 sizeof(ice_fdir_ipv4_l2tpv3_pkt), ice_fdir_ipv4_l2tpv3_pkt,
472 sizeof(ice_fdir_ipv4_l2tpv3_pkt), ice_fdir_ipv4_l2tpv3_pkt,
475 ICE_FLTR_PTYPE_NONF_IPV6_L2TPV3,
476 sizeof(ice_fdir_ipv6_l2tpv3_pkt), ice_fdir_ipv6_l2tpv3_pkt,
477 sizeof(ice_fdir_ipv6_l2tpv3_pkt), ice_fdir_ipv6_l2tpv3_pkt,
480 ICE_FLTR_PTYPE_NONF_IPV4_ESP,
481 sizeof(ice_fdir_ipv4_esp_pkt), ice_fdir_ipv4_esp_pkt,
482 sizeof(ice_fdir_ipv4_esp_pkt), ice_fdir_ipv4_esp_pkt,
485 ICE_FLTR_PTYPE_NONF_IPV6_ESP,
486 sizeof(ice_fdir_ipv6_esp_pkt), ice_fdir_ipv6_esp_pkt,
487 sizeof(ice_fdir_ipv6_esp_pkt), ice_fdir_ipv6_esp_pkt,
490 ICE_FLTR_PTYPE_NONF_IPV4_AH,
491 sizeof(ice_fdir_ipv4_ah_pkt), ice_fdir_ipv4_ah_pkt,
492 sizeof(ice_fdir_ipv4_ah_pkt), ice_fdir_ipv4_ah_pkt,
495 ICE_FLTR_PTYPE_NONF_IPV6_AH,
496 sizeof(ice_fdir_ipv6_ah_pkt), ice_fdir_ipv6_ah_pkt,
497 sizeof(ice_fdir_ipv6_ah_pkt), ice_fdir_ipv6_ah_pkt,
500 ICE_FLTR_PTYPE_NONF_IPV4_NAT_T_ESP,
501 sizeof(ice_fdir_ipv4_nat_t_esp_pkt),
502 ice_fdir_ipv4_nat_t_esp_pkt,
503 sizeof(ice_fdir_ipv4_nat_t_esp_pkt),
504 ice_fdir_ipv4_nat_t_esp_pkt,
507 ICE_FLTR_PTYPE_NONF_IPV6_NAT_T_ESP,
508 sizeof(ice_fdir_ipv6_nat_t_esp_pkt),
509 ice_fdir_ipv6_nat_t_esp_pkt,
510 sizeof(ice_fdir_ipv6_nat_t_esp_pkt),
511 ice_fdir_ipv6_nat_t_esp_pkt,
514 ICE_FLTR_PTYPE_NONF_IPV4_PFCP_NODE,
515 sizeof(ice_fdir_ipv4_pfcp_node_pkt),
516 ice_fdir_ipv4_pfcp_node_pkt,
517 sizeof(ice_fdir_ipv4_pfcp_node_pkt),
518 ice_fdir_ipv4_pfcp_node_pkt,
521 ICE_FLTR_PTYPE_NONF_IPV4_PFCP_SESSION,
522 sizeof(ice_fdir_ipv4_pfcp_session_pkt),
523 ice_fdir_ipv4_pfcp_session_pkt,
524 sizeof(ice_fdir_ipv4_pfcp_session_pkt),
525 ice_fdir_ipv4_pfcp_session_pkt,
528 ICE_FLTR_PTYPE_NONF_IPV6_PFCP_NODE,
529 sizeof(ice_fdir_ipv6_pfcp_node_pkt),
530 ice_fdir_ipv6_pfcp_node_pkt,
531 sizeof(ice_fdir_ipv6_pfcp_node_pkt),
532 ice_fdir_ipv6_pfcp_node_pkt,
535 ICE_FLTR_PTYPE_NONF_IPV6_PFCP_SESSION,
536 sizeof(ice_fdir_ipv6_pfcp_session_pkt),
537 ice_fdir_ipv6_pfcp_session_pkt,
538 sizeof(ice_fdir_ipv6_pfcp_session_pkt),
539 ice_fdir_ipv6_pfcp_session_pkt,
542 ICE_FLTR_PTYPE_NON_IP_L2,
543 sizeof(ice_fdir_non_ip_l2_pkt), ice_fdir_non_ip_l2_pkt,
544 sizeof(ice_fdir_non_ip_l2_pkt), ice_fdir_non_ip_l2_pkt,
547 ICE_FLTR_PTYPE_NONF_IPV6_TCP,
548 sizeof(ice_fdir_tcpv6_pkt), ice_fdir_tcpv6_pkt,
549 sizeof(ice_fdir_tcp6_tun_pkt), ice_fdir_tcp6_tun_pkt,
552 ICE_FLTR_PTYPE_NONF_IPV6_UDP,
553 sizeof(ice_fdir_udpv6_pkt), ice_fdir_udpv6_pkt,
554 sizeof(ice_fdir_udp6_tun_pkt), ice_fdir_udp6_tun_pkt,
557 ICE_FLTR_PTYPE_NONF_IPV6_SCTP,
558 sizeof(ice_fdir_sctpv6_pkt), ice_fdir_sctpv6_pkt,
559 sizeof(ice_fdir_sctp6_tun_pkt), ice_fdir_sctp6_tun_pkt,
562 ICE_FLTR_PTYPE_NONF_IPV6_OTHER,
563 sizeof(ice_fdir_ipv6_pkt), ice_fdir_ipv6_pkt,
564 sizeof(ice_fdir_ip6_tun_pkt), ice_fdir_ip6_tun_pkt,
568 #define ICE_FDIR_NUM_PKT ARRAY_SIZE(ice_fdir_pkt)
571 * ice_set_dflt_val_fd_desc
572 * @fd_fltr_ctx: pointer to fd filter descriptor
575 ice_set_dflt_val_fd_desc(struct ice_fd_fltr_desc_ctx *fd_fltr_ctx)
577 fd_fltr_ctx->comp_q = ICE_FXD_FLTR_QW0_COMP_Q_ZERO;
578 fd_fltr_ctx->comp_report = ICE_FXD_FLTR_QW0_COMP_REPORT_SW_FAIL;
579 fd_fltr_ctx->fd_space = ICE_FXD_FLTR_QW0_FD_SPACE_GUAR_BEST;
580 fd_fltr_ctx->cnt_ena = ICE_FXD_FLTR_QW0_STAT_ENA_PKTS;
581 fd_fltr_ctx->evict_ena = ICE_FXD_FLTR_QW0_EVICT_ENA_TRUE;
582 fd_fltr_ctx->toq = ICE_FXD_FLTR_QW0_TO_Q_EQUALS_QINDEX;
583 fd_fltr_ctx->toq_prio = ICE_FXD_FLTR_QW0_TO_Q_PRIO1;
584 fd_fltr_ctx->dpu_recipe = ICE_FXD_FLTR_QW0_DPU_RECIPE_DFLT;
585 fd_fltr_ctx->drop = ICE_FXD_FLTR_QW0_DROP_NO;
586 fd_fltr_ctx->flex_prio = ICE_FXD_FLTR_QW0_FLEX_PRI_NONE;
587 fd_fltr_ctx->flex_mdid = ICE_FXD_FLTR_QW0_FLEX_MDID0;
588 fd_fltr_ctx->flex_val = ICE_FXD_FLTR_QW0_FLEX_VAL0;
589 fd_fltr_ctx->dtype = ICE_TX_DESC_DTYPE_FLTR_PROG;
590 fd_fltr_ctx->desc_prof_prio = ICE_FXD_FLTR_QW1_PROF_PRIO_ZERO;
591 fd_fltr_ctx->desc_prof = ICE_FXD_FLTR_QW1_PROF_ZERO;
592 fd_fltr_ctx->swap = ICE_FXD_FLTR_QW1_SWAP_SET;
593 fd_fltr_ctx->fdid_prio = ICE_FXD_FLTR_QW1_FDID_PRI_ONE;
594 fd_fltr_ctx->fdid_mdid = ICE_FXD_FLTR_QW1_FDID_MDID_FD;
595 fd_fltr_ctx->fdid = ICE_FXD_FLTR_QW1_FDID_ZERO;
599 * ice_set_fd_desc_val
600 * @ctx: pointer to fd filter descriptor context
601 * @fdir_desc: populated with fd filter descriptor values
604 ice_set_fd_desc_val(struct ice_fd_fltr_desc_ctx *ctx,
605 struct ice_fltr_desc *fdir_desc)
609 /* prep QW0 of FD filter programming desc */
610 qword = ((u64)ctx->qindex << ICE_FXD_FLTR_QW0_QINDEX_S) &
611 ICE_FXD_FLTR_QW0_QINDEX_M;
612 qword |= ((u64)ctx->comp_q << ICE_FXD_FLTR_QW0_COMP_Q_S) &
613 ICE_FXD_FLTR_QW0_COMP_Q_M;
614 qword |= ((u64)ctx->comp_report << ICE_FXD_FLTR_QW0_COMP_REPORT_S) &
615 ICE_FXD_FLTR_QW0_COMP_REPORT_M;
616 qword |= ((u64)ctx->fd_space << ICE_FXD_FLTR_QW0_FD_SPACE_S) &
617 ICE_FXD_FLTR_QW0_FD_SPACE_M;
618 qword |= ((u64)ctx->cnt_index << ICE_FXD_FLTR_QW0_STAT_CNT_S) &
619 ICE_FXD_FLTR_QW0_STAT_CNT_M;
620 qword |= ((u64)ctx->cnt_ena << ICE_FXD_FLTR_QW0_STAT_ENA_S) &
621 ICE_FXD_FLTR_QW0_STAT_ENA_M;
622 qword |= ((u64)ctx->evict_ena << ICE_FXD_FLTR_QW0_EVICT_ENA_S) &
623 ICE_FXD_FLTR_QW0_EVICT_ENA_M;
624 qword |= ((u64)ctx->toq << ICE_FXD_FLTR_QW0_TO_Q_S) &
625 ICE_FXD_FLTR_QW0_TO_Q_M;
626 qword |= ((u64)ctx->toq_prio << ICE_FXD_FLTR_QW0_TO_Q_PRI_S) &
627 ICE_FXD_FLTR_QW0_TO_Q_PRI_M;
628 qword |= ((u64)ctx->dpu_recipe << ICE_FXD_FLTR_QW0_DPU_RECIPE_S) &
629 ICE_FXD_FLTR_QW0_DPU_RECIPE_M;
630 qword |= ((u64)ctx->drop << ICE_FXD_FLTR_QW0_DROP_S) &
631 ICE_FXD_FLTR_QW0_DROP_M;
632 qword |= ((u64)ctx->flex_prio << ICE_FXD_FLTR_QW0_FLEX_PRI_S) &
633 ICE_FXD_FLTR_QW0_FLEX_PRI_M;
634 qword |= ((u64)ctx->flex_mdid << ICE_FXD_FLTR_QW0_FLEX_MDID_S) &
635 ICE_FXD_FLTR_QW0_FLEX_MDID_M;
636 qword |= ((u64)ctx->flex_val << ICE_FXD_FLTR_QW0_FLEX_VAL_S) &
637 ICE_FXD_FLTR_QW0_FLEX_VAL_M;
638 fdir_desc->qidx_compq_space_stat = CPU_TO_LE64(qword);
640 /* prep QW1 of FD filter programming desc */
641 qword = ((u64)ctx->dtype << ICE_FXD_FLTR_QW1_DTYPE_S) &
642 ICE_FXD_FLTR_QW1_DTYPE_M;
643 qword |= ((u64)ctx->pcmd << ICE_FXD_FLTR_QW1_PCMD_S) &
644 ICE_FXD_FLTR_QW1_PCMD_M;
645 qword |= ((u64)ctx->desc_prof_prio << ICE_FXD_FLTR_QW1_PROF_PRI_S) &
646 ICE_FXD_FLTR_QW1_PROF_PRI_M;
647 qword |= ((u64)ctx->desc_prof << ICE_FXD_FLTR_QW1_PROF_S) &
648 ICE_FXD_FLTR_QW1_PROF_M;
649 qword |= ((u64)ctx->fd_vsi << ICE_FXD_FLTR_QW1_FD_VSI_S) &
650 ICE_FXD_FLTR_QW1_FD_VSI_M;
651 qword |= ((u64)ctx->swap << ICE_FXD_FLTR_QW1_SWAP_S) &
652 ICE_FXD_FLTR_QW1_SWAP_M;
653 qword |= ((u64)ctx->fdid_prio << ICE_FXD_FLTR_QW1_FDID_PRI_S) &
654 ICE_FXD_FLTR_QW1_FDID_PRI_M;
655 qword |= ((u64)ctx->fdid_mdid << ICE_FXD_FLTR_QW1_FDID_MDID_S) &
656 ICE_FXD_FLTR_QW1_FDID_MDID_M;
657 qword |= ((u64)ctx->fdid << ICE_FXD_FLTR_QW1_FDID_S) &
658 ICE_FXD_FLTR_QW1_FDID_M;
659 fdir_desc->dtype_cmd_vsi_fdid = CPU_TO_LE64(qword);
663 * ice_fdir_get_prgm_desc - set a fdir descriptor from a fdir filter struct
664 * @hw: pointer to the hardware structure
666 * @fdesc: filter descriptor
667 * @add: if add is true, this is an add operation, false implies delete
670 ice_fdir_get_prgm_desc(struct ice_hw *hw, struct ice_fdir_fltr *input,
671 struct ice_fltr_desc *fdesc, bool add)
673 struct ice_fd_fltr_desc_ctx fdir_fltr_ctx = { 0 };
675 /* set default context info */
676 ice_set_dflt_val_fd_desc(&fdir_fltr_ctx);
678 /* change sideband filtering values */
679 fdir_fltr_ctx.fdid = input->fltr_id;
680 if (input->dest_ctl == ICE_FLTR_PRGM_DESC_DEST_DROP_PKT) {
681 fdir_fltr_ctx.drop = ICE_FXD_FLTR_QW0_DROP_YES;
682 fdir_fltr_ctx.qindex = 0;
683 } else if (input->dest_ctl ==
684 ICE_FLTR_PRGM_DESC_DEST_DIRECT_PKT_OTHER) {
685 fdir_fltr_ctx.drop = ICE_FXD_FLTR_QW0_DROP_NO;
686 fdir_fltr_ctx.qindex = 0;
688 if (input->dest_ctl ==
689 ICE_FLTR_PRGM_DESC_DEST_DIRECT_PKT_QGROUP)
690 fdir_fltr_ctx.toq = input->q_region;
691 fdir_fltr_ctx.drop = ICE_FXD_FLTR_QW0_DROP_NO;
692 fdir_fltr_ctx.qindex = input->q_index;
694 fdir_fltr_ctx.cnt_ena = input->cnt_ena;
695 fdir_fltr_ctx.cnt_index = input->cnt_index;
696 fdir_fltr_ctx.fd_vsi = ice_get_hw_vsi_num(hw, input->dest_vsi);
697 fdir_fltr_ctx.evict_ena = ICE_FXD_FLTR_QW0_EVICT_ENA_FALSE;
698 if (input->dest_ctl == ICE_FLTR_PRGM_DESC_DEST_DIRECT_PKT_OTHER)
699 fdir_fltr_ctx.toq_prio = 0;
701 fdir_fltr_ctx.toq_prio = 3;
702 fdir_fltr_ctx.pcmd = add ? ICE_FXD_FLTR_QW1_PCMD_ADD :
703 ICE_FXD_FLTR_QW1_PCMD_REMOVE;
704 fdir_fltr_ctx.swap = ICE_FXD_FLTR_QW1_SWAP_NOT_SET;
705 fdir_fltr_ctx.comp_q = ICE_FXD_FLTR_QW0_COMP_Q_ZERO;
706 fdir_fltr_ctx.comp_report = input->comp_report;
707 fdir_fltr_ctx.fdid_prio = input->fdid_prio;
708 fdir_fltr_ctx.desc_prof = 1;
709 fdir_fltr_ctx.desc_prof_prio = 3;
710 ice_set_fd_desc_val(&fdir_fltr_ctx, fdesc);
714 * ice_alloc_fd_res_cntr - obtain counter resource for FD type
715 * @hw: pointer to the hardware structure
716 * @cntr_id: returns counter index
718 enum ice_status ice_alloc_fd_res_cntr(struct ice_hw *hw, u16 *cntr_id)
720 return ice_alloc_res_cntr(hw, ICE_AQC_RES_TYPE_FDIR_COUNTER_BLOCK,
721 ICE_AQC_RES_TYPE_FLAG_DEDICATED, 1, cntr_id);
725 * ice_free_fd_res_cntr - Free counter resource for FD type
726 * @hw: pointer to the hardware structure
727 * @cntr_id: counter index to be freed
729 enum ice_status ice_free_fd_res_cntr(struct ice_hw *hw, u16 cntr_id)
731 return ice_free_res_cntr(hw, ICE_AQC_RES_TYPE_FDIR_COUNTER_BLOCK,
732 ICE_AQC_RES_TYPE_FLAG_DEDICATED, 1, cntr_id);
736 * ice_alloc_fd_guar_item - allocate resource for FD guaranteed entries
737 * @hw: pointer to the hardware structure
738 * @cntr_id: returns counter index
739 * @num_fltr: number of filter entries to be allocated
742 ice_alloc_fd_guar_item(struct ice_hw *hw, u16 *cntr_id, u16 num_fltr)
744 return ice_alloc_res_cntr(hw, ICE_AQC_RES_TYPE_FDIR_GUARANTEED_ENTRIES,
745 ICE_AQC_RES_TYPE_FLAG_DEDICATED, num_fltr,
750 * ice_free_fd_guar_item - Free flow director guaranteed entries
751 * @hw: pointer to the hardware structure
752 * @cntr_id: counter index that needs to be freed
753 * @num_fltr: number of filters to be freed
756 ice_free_fd_guar_item(struct ice_hw *hw, u16 cntr_id, u16 num_fltr)
758 return ice_free_res_cntr(hw, ICE_AQC_RES_TYPE_FDIR_GUARANTEED_ENTRIES,
759 ICE_AQC_RES_TYPE_FLAG_DEDICATED, num_fltr,
764 * ice_alloc_fd_shrd_item - allocate resource for flow director shared entries
765 * @hw: pointer to the hardware structure
766 * @cntr_id: returns counter index
767 * @num_fltr: number of filter entries to be allocated
770 ice_alloc_fd_shrd_item(struct ice_hw *hw, u16 *cntr_id, u16 num_fltr)
772 return ice_alloc_res_cntr(hw, ICE_AQC_RES_TYPE_FDIR_SHARED_ENTRIES,
773 ICE_AQC_RES_TYPE_FLAG_DEDICATED, num_fltr,
778 * ice_free_fd_shrd_item - Free flow director shared entries
779 * @hw: pointer to the hardware structure
780 * @cntr_id: counter index that needs to be freed
781 * @num_fltr: number of filters to be freed
784 ice_free_fd_shrd_item(struct ice_hw *hw, u16 cntr_id, u16 num_fltr)
786 return ice_free_res_cntr(hw, ICE_AQC_RES_TYPE_FDIR_SHARED_ENTRIES,
787 ICE_AQC_RES_TYPE_FLAG_DEDICATED, num_fltr,
792 * ice_get_fdir_cnt_all - get the number of Flow Director filters
793 * @hw: hardware data structure
795 * Returns the number of filters available on device
797 int ice_get_fdir_cnt_all(struct ice_hw *hw)
799 return hw->func_caps.fd_fltr_guar + hw->func_caps.fd_fltr_best_effort;
803 * ice_pkt_insert_ipv6_addr - insert a be32 IPv6 address into a memory buffer.
804 * @pkt: packet buffer
805 * @offset: offset into buffer
806 * @addr: IPv6 address to convert and insert into pkt at offset
808 static void ice_pkt_insert_ipv6_addr(u8 *pkt, int offset, __be32 *addr)
812 for (idx = 0; idx < ICE_IPV6_ADDR_LEN_AS_U32; idx++)
813 ice_memcpy(pkt + offset + idx * sizeof(*addr), &addr[idx],
814 sizeof(*addr), ICE_NONDMA_TO_NONDMA);
818 * ice_pkt_insert_u6_qfi - insert a u6 value qfi into a memory buffer for gtpu
819 * @pkt: packet buffer
820 * @offset: offset into buffer
821 * @data: 8 bit value to convert and insert into pkt at offset
823 * This function is designed for inserting qfi (6 bits) for gtpu.
825 static void ice_pkt_insert_u6_qfi(u8 *pkt, int offset, u8 data)
829 ret = (data & 0x3F) + (*(pkt + offset) & 0xC0);
830 ice_memcpy(pkt + offset, &ret, sizeof(ret), ICE_NONDMA_TO_NONDMA);
834 * ice_pkt_insert_u8 - insert a u8 value into a memory buffer.
835 * @pkt: packet buffer
836 * @offset: offset into buffer
837 * @data: 8 bit value to convert and insert into pkt at offset
839 static void ice_pkt_insert_u8(u8 *pkt, int offset, u8 data)
841 ice_memcpy(pkt + offset, &data, sizeof(data), ICE_NONDMA_TO_NONDMA);
845 * ice_pkt_insert_u8_tc - insert a u8 value into a memory buffer for TC ipv6.
846 * @pkt: packet buffer
847 * @offset: offset into buffer
848 * @data: 8 bit value to convert and insert into pkt at offset
850 * This function is designed for inserting Traffic Class (TC) for IPv6,
851 * since that TC is not aligned in number of bytes. Here we split it out
852 * into two part and fill each byte with data copy from pkt, then insert
853 * the two bytes data one by one.
855 static void ice_pkt_insert_u8_tc(u8 *pkt, int offset, u8 data)
859 high = (data >> 4) + (*(pkt + offset) & 0xF0);
860 ice_memcpy(pkt + offset, &high, sizeof(high), ICE_NONDMA_TO_NONDMA);
862 low = (*(pkt + offset + 1) & 0x0F) + ((data & 0x0F) << 4);
863 ice_memcpy(pkt + offset + 1, &low, sizeof(low), ICE_NONDMA_TO_NONDMA);
867 * ice_pkt_insert_u16 - insert a be16 value into a memory buffer.
868 * @pkt: packet buffer
869 * @offset: offset into buffer
870 * @data: 16 bit value to convert and insert into pkt at offset
872 static void ice_pkt_insert_u16(u8 *pkt, int offset, __be16 data)
874 ice_memcpy(pkt + offset, &data, sizeof(data), ICE_NONDMA_TO_NONDMA);
878 * ice_pkt_insert_u32 - insert a be32 value into a memory buffer.
879 * @pkt: packet buffer
880 * @offset: offset into buffer
881 * @data: 32 bit value to convert and insert into pkt at offset
883 static void ice_pkt_insert_u32(u8 *pkt, int offset, __be32 data)
885 ice_memcpy(pkt + offset, &data, sizeof(data), ICE_NONDMA_TO_NONDMA);
889 * ice_pkt_insert_mac_addr - insert a MAC addr into a memory buffer.
890 * @pkt: packet buffer
891 * @addr: MAC address to convert and insert into pkt at offset
893 static void ice_pkt_insert_mac_addr(u8 *pkt, u8 *addr)
895 ice_memcpy(pkt, addr, ETH_ALEN, ICE_NONDMA_TO_NONDMA);
899 * ice_fdir_get_gen_prgm_pkt - generate a training packet
900 * @hw: pointer to the hardware structure
901 * @input: flow director filter data structure
902 * @pkt: pointer to return filter packet
903 * @frag: generate a fragment packet
904 * @tun: true implies generate a tunnel packet
907 ice_fdir_get_gen_prgm_pkt(struct ice_hw *hw, struct ice_fdir_fltr *input,
908 u8 *pkt, bool frag, bool tun)
910 enum ice_fltr_ptype flow;
915 if (input->flow_type == ICE_FLTR_PTYPE_NONF_IPV4_OTHER) {
916 switch (input->ip.v4.proto) {
917 case ICE_IP_PROTO_TCP:
918 flow = ICE_FLTR_PTYPE_NONF_IPV4_TCP;
920 case ICE_IP_PROTO_UDP:
921 flow = ICE_FLTR_PTYPE_NONF_IPV4_UDP;
923 case ICE_IP_PROTO_SCTP:
924 flow = ICE_FLTR_PTYPE_NONF_IPV4_SCTP;
927 flow = ICE_FLTR_PTYPE_NONF_IPV4_OTHER;
930 } else if (input->flow_type == ICE_FLTR_PTYPE_NONF_IPV6_OTHER) {
931 switch (input->ip.v6.proto) {
932 case ICE_IP_PROTO_TCP:
933 flow = ICE_FLTR_PTYPE_NONF_IPV6_TCP;
935 case ICE_IP_PROTO_UDP:
936 flow = ICE_FLTR_PTYPE_NONF_IPV6_UDP;
938 case ICE_IP_PROTO_SCTP:
939 flow = ICE_FLTR_PTYPE_NONF_IPV6_SCTP;
942 flow = ICE_FLTR_PTYPE_NONF_IPV6_OTHER;
946 flow = input->flow_type;
949 for (idx = 0; idx < ICE_FDIR_NUM_PKT; idx++)
950 if (ice_fdir_pkt[idx].flow == flow)
952 if (idx == ICE_FDIR_NUM_PKT)
953 return ICE_ERR_PARAM;
955 ice_memcpy(pkt, ice_fdir_pkt[idx].pkt,
956 ice_fdir_pkt[idx].pkt_len, ICE_NONDMA_TO_NONDMA);
959 if (!ice_get_open_tunnel_port(hw, TNL_ALL, &tnl_port))
960 return ICE_ERR_DOES_NOT_EXIST;
961 if (!ice_fdir_pkt[idx].tun_pkt)
962 return ICE_ERR_PARAM;
963 ice_memcpy(pkt, ice_fdir_pkt[idx].tun_pkt,
964 ice_fdir_pkt[idx].tun_pkt_len, ICE_NONDMA_TO_NONDMA);
965 ice_pkt_insert_u16(pkt, ICE_IPV4_UDP_DST_PORT_OFFSET,
967 loc = &pkt[ICE_FDIR_TUN_PKT_OFF];
970 /* Reverse the src and dst, since the HW expects them to be from Tx
971 * perspective. The input from user is from Rx filter perspective.
974 case ICE_FLTR_PTYPE_NONF_IPV4_TCP:
975 ice_pkt_insert_u32(loc, ICE_IPV4_DST_ADDR_OFFSET,
976 input->ip.v4.src_ip);
977 ice_pkt_insert_u16(loc, ICE_IPV4_TCP_DST_PORT_OFFSET,
978 input->ip.v4.src_port);
979 ice_pkt_insert_u32(loc, ICE_IPV4_SRC_ADDR_OFFSET,
980 input->ip.v4.dst_ip);
981 ice_pkt_insert_u16(loc, ICE_IPV4_TCP_SRC_PORT_OFFSET,
982 input->ip.v4.dst_port);
983 ice_pkt_insert_u8(loc, ICE_IPV4_TOS_OFFSET, input->ip.v4.tos);
984 ice_pkt_insert_u8(loc, ICE_IPV4_TTL_OFFSET, input->ip.v4.ttl);
985 ice_pkt_insert_mac_addr(loc, input->ext_data.dst_mac);
987 loc[20] = ICE_FDIR_IPV4_PKT_FLAG_DF;
989 case ICE_FLTR_PTYPE_NONF_IPV4_UDP:
990 ice_pkt_insert_u32(loc, ICE_IPV4_DST_ADDR_OFFSET,
991 input->ip.v4.src_ip);
992 ice_pkt_insert_u16(loc, ICE_IPV4_UDP_DST_PORT_OFFSET,
993 input->ip.v4.src_port);
994 ice_pkt_insert_u32(loc, ICE_IPV4_SRC_ADDR_OFFSET,
995 input->ip.v4.dst_ip);
996 ice_pkt_insert_u16(loc, ICE_IPV4_UDP_SRC_PORT_OFFSET,
997 input->ip.v4.dst_port);
998 ice_pkt_insert_u8(loc, ICE_IPV4_TOS_OFFSET, input->ip.v4.tos);
999 ice_pkt_insert_u8(loc, ICE_IPV4_TTL_OFFSET, input->ip.v4.ttl);
1000 ice_pkt_insert_mac_addr(loc, input->ext_data.dst_mac);
1002 case ICE_FLTR_PTYPE_NONF_IPV4_SCTP:
1003 ice_pkt_insert_u32(loc, ICE_IPV4_DST_ADDR_OFFSET,
1004 input->ip.v4.src_ip);
1005 ice_pkt_insert_u16(loc, ICE_IPV4_SCTP_DST_PORT_OFFSET,
1006 input->ip.v4.src_port);
1007 ice_pkt_insert_u32(loc, ICE_IPV4_SRC_ADDR_OFFSET,
1008 input->ip.v4.dst_ip);
1009 ice_pkt_insert_u16(loc, ICE_IPV4_SCTP_SRC_PORT_OFFSET,
1010 input->ip.v4.dst_port);
1011 ice_pkt_insert_u8(loc, ICE_IPV4_TOS_OFFSET, input->ip.v4.tos);
1012 ice_pkt_insert_u8(loc, ICE_IPV4_TTL_OFFSET, input->ip.v4.ttl);
1013 ice_pkt_insert_mac_addr(loc, input->ext_data.dst_mac);
1015 case ICE_FLTR_PTYPE_NONF_IPV4_OTHER:
1016 ice_pkt_insert_u32(loc, ICE_IPV4_DST_ADDR_OFFSET,
1017 input->ip.v4.src_ip);
1018 ice_pkt_insert_u32(loc, ICE_IPV4_SRC_ADDR_OFFSET,
1019 input->ip.v4.dst_ip);
1020 ice_pkt_insert_u8(loc, ICE_IPV4_TOS_OFFSET, input->ip.v4.tos);
1021 ice_pkt_insert_u8(loc, ICE_IPV4_TTL_OFFSET, input->ip.v4.ttl);
1022 ice_pkt_insert_u8(loc, ICE_IPV4_PROTO_OFFSET,
1023 input->ip.v4.proto);
1024 ice_pkt_insert_mac_addr(loc, input->ext_data.dst_mac);
1026 case ICE_FLTR_PTYPE_NONF_IPV4_GTPU_IPV4_UDP:
1027 case ICE_FLTR_PTYPE_NONF_IPV4_GTPU_IPV4_TCP:
1028 case ICE_FLTR_PTYPE_NONF_IPV4_GTPU_IPV4_ICMP:
1029 case ICE_FLTR_PTYPE_NONF_IPV4_GTPU_IPV4_OTHER:
1030 ice_pkt_insert_u32(loc, ICE_IPV4_SRC_ADDR_OFFSET,
1031 input->ip.v4.src_ip);
1032 ice_pkt_insert_u32(loc, ICE_IPV4_DST_ADDR_OFFSET,
1033 input->ip.v4.dst_ip);
1034 ice_pkt_insert_u32(loc, ICE_IPV4_GTPU_TEID_OFFSET,
1035 input->gtpu_data.teid);
1036 ice_pkt_insert_u6_qfi(loc, ICE_IPV4_GTPU_QFI_OFFSET,
1037 input->gtpu_data.qfi);
1039 case ICE_FLTR_PTYPE_NONF_IPV4_L2TPV3:
1040 ice_pkt_insert_u32(loc, ICE_IPV4_L2TPV3_SESS_ID_OFFSET,
1041 input->l2tpv3_data.session_id);
1043 case ICE_FLTR_PTYPE_NONF_IPV6_L2TPV3:
1044 ice_pkt_insert_u32(loc, ICE_IPV6_L2TPV3_SESS_ID_OFFSET,
1045 input->l2tpv3_data.session_id);
1047 case ICE_FLTR_PTYPE_NONF_IPV4_ESP:
1048 ice_pkt_insert_u32(loc, ICE_IPV4_ESP_SPI_OFFSET,
1049 input->ip.v4.sec_parm_idx);
1051 case ICE_FLTR_PTYPE_NONF_IPV6_ESP:
1052 ice_pkt_insert_u32(loc, ICE_IPV6_ESP_SPI_OFFSET,
1053 input->ip.v6.sec_parm_idx);
1055 case ICE_FLTR_PTYPE_NONF_IPV4_AH:
1056 ice_pkt_insert_u32(loc, ICE_IPV4_AH_SPI_OFFSET,
1057 input->ip.v4.sec_parm_idx);
1059 case ICE_FLTR_PTYPE_NONF_IPV6_AH:
1060 ice_pkt_insert_u32(loc, ICE_IPV6_AH_SPI_OFFSET,
1061 input->ip.v6.sec_parm_idx);
1063 case ICE_FLTR_PTYPE_NONF_IPV4_NAT_T_ESP:
1064 ice_pkt_insert_u32(loc, ICE_IPV4_DST_ADDR_OFFSET,
1065 input->ip.v4.src_ip);
1066 ice_pkt_insert_u32(loc, ICE_IPV4_SRC_ADDR_OFFSET,
1067 input->ip.v4.dst_ip);
1068 ice_pkt_insert_u32(loc, ICE_IPV4_NAT_T_ESP_SPI_OFFSET,
1069 input->ip.v4.sec_parm_idx);
1071 case ICE_FLTR_PTYPE_NONF_IPV6_NAT_T_ESP:
1072 ice_pkt_insert_ipv6_addr(loc, ICE_IPV6_DST_ADDR_OFFSET,
1073 input->ip.v6.src_ip);
1074 ice_pkt_insert_ipv6_addr(loc, ICE_IPV6_SRC_ADDR_OFFSET,
1075 input->ip.v6.dst_ip);
1076 ice_pkt_insert_u32(loc, ICE_IPV6_NAT_T_ESP_SPI_OFFSET,
1077 input->ip.v6.sec_parm_idx);
1079 case ICE_FLTR_PTYPE_NONF_IPV4_PFCP_NODE:
1080 case ICE_FLTR_PTYPE_NONF_IPV4_PFCP_SESSION:
1081 ice_pkt_insert_u16(loc, ICE_IPV4_UDP_SRC_PORT_OFFSET,
1082 input->ip.v4.dst_port);
1084 case ICE_FLTR_PTYPE_NONF_IPV6_PFCP_NODE:
1085 case ICE_FLTR_PTYPE_NONF_IPV6_PFCP_SESSION:
1086 ice_pkt_insert_u16(loc, ICE_IPV6_UDP_SRC_PORT_OFFSET,
1087 input->ip.v6.dst_port);
1089 case ICE_FLTR_PTYPE_NON_IP_L2:
1090 ice_pkt_insert_u16(loc, ICE_MAC_ETHTYPE_OFFSET,
1091 input->ext_data.ether_type);
1093 case ICE_FLTR_PTYPE_NONF_IPV6_TCP:
1094 ice_pkt_insert_ipv6_addr(loc, ICE_IPV6_DST_ADDR_OFFSET,
1095 input->ip.v6.src_ip);
1096 ice_pkt_insert_ipv6_addr(loc, ICE_IPV6_SRC_ADDR_OFFSET,
1097 input->ip.v6.dst_ip);
1098 ice_pkt_insert_u16(loc, ICE_IPV6_TCP_DST_PORT_OFFSET,
1099 input->ip.v6.src_port);
1100 ice_pkt_insert_u16(loc, ICE_IPV6_TCP_SRC_PORT_OFFSET,
1101 input->ip.v6.dst_port);
1102 ice_pkt_insert_u8_tc(loc, ICE_IPV6_TC_OFFSET, input->ip.v6.tc);
1103 ice_pkt_insert_u8(loc, ICE_IPV6_HLIM_OFFSET, input->ip.v6.hlim);
1104 ice_pkt_insert_mac_addr(loc, input->ext_data.dst_mac);
1106 case ICE_FLTR_PTYPE_NONF_IPV6_UDP:
1107 ice_pkt_insert_ipv6_addr(loc, ICE_IPV6_DST_ADDR_OFFSET,
1108 input->ip.v6.src_ip);
1109 ice_pkt_insert_ipv6_addr(loc, ICE_IPV6_SRC_ADDR_OFFSET,
1110 input->ip.v6.dst_ip);
1111 ice_pkt_insert_u16(loc, ICE_IPV6_UDP_DST_PORT_OFFSET,
1112 input->ip.v6.src_port);
1113 ice_pkt_insert_u16(loc, ICE_IPV6_UDP_SRC_PORT_OFFSET,
1114 input->ip.v6.dst_port);
1115 ice_pkt_insert_u8_tc(loc, ICE_IPV6_TC_OFFSET, input->ip.v6.tc);
1116 ice_pkt_insert_u8(loc, ICE_IPV6_HLIM_OFFSET, input->ip.v6.hlim);
1117 ice_pkt_insert_mac_addr(loc, input->ext_data.dst_mac);
1119 case ICE_FLTR_PTYPE_NONF_IPV6_SCTP:
1120 ice_pkt_insert_ipv6_addr(loc, ICE_IPV6_DST_ADDR_OFFSET,
1121 input->ip.v6.src_ip);
1122 ice_pkt_insert_ipv6_addr(loc, ICE_IPV6_SRC_ADDR_OFFSET,
1123 input->ip.v6.dst_ip);
1124 ice_pkt_insert_u16(loc, ICE_IPV6_SCTP_DST_PORT_OFFSET,
1125 input->ip.v6.src_port);
1126 ice_pkt_insert_u16(loc, ICE_IPV6_SCTP_SRC_PORT_OFFSET,
1127 input->ip.v6.dst_port);
1128 ice_pkt_insert_u8_tc(loc, ICE_IPV6_TC_OFFSET, input->ip.v6.tc);
1129 ice_pkt_insert_u8(loc, ICE_IPV6_HLIM_OFFSET, input->ip.v6.hlim);
1130 ice_pkt_insert_mac_addr(loc, input->ext_data.dst_mac);
1132 case ICE_FLTR_PTYPE_NONF_IPV6_OTHER:
1133 ice_pkt_insert_ipv6_addr(loc, ICE_IPV6_DST_ADDR_OFFSET,
1134 input->ip.v6.src_ip);
1135 ice_pkt_insert_ipv6_addr(loc, ICE_IPV6_SRC_ADDR_OFFSET,
1136 input->ip.v6.dst_ip);
1137 ice_pkt_insert_u8_tc(loc, ICE_IPV6_TC_OFFSET, input->ip.v6.tc);
1138 ice_pkt_insert_u8(loc, ICE_IPV6_HLIM_OFFSET, input->ip.v6.hlim);
1139 ice_pkt_insert_u8(loc, ICE_IPV6_PROTO_OFFSET,
1140 input->ip.v6.proto);
1141 ice_pkt_insert_mac_addr(loc, input->ext_data.dst_mac);
1144 return ICE_ERR_PARAM;
1147 if (input->flex_fltr)
1148 ice_pkt_insert_u16(loc, input->flex_offset, input->flex_word);
1154 * ice_fdir_get_prgm_pkt - generate a training packet
1155 * @input: flow director filter data structure
1156 * @pkt: pointer to return filter packet
1157 * @frag: generate a fragment packet
1160 ice_fdir_get_prgm_pkt(struct ice_fdir_fltr *input, u8 *pkt, bool frag)
1162 return ice_fdir_get_gen_prgm_pkt(NULL, input, pkt, frag, false);
1166 * ice_fdir_has_frag - does flow type have 2 ptypes
1169 * returns true is there is a fragment packet for this ptype
1171 bool ice_fdir_has_frag(enum ice_fltr_ptype flow)
1173 if (flow == ICE_FLTR_PTYPE_NONF_IPV4_OTHER)
1180 * ice_fdir_find_by_idx - find filter with idx
1181 * @hw: pointer to hardware structure
1182 * @fltr_idx: index to find.
1184 * Returns pointer to filter if found or null
1186 struct ice_fdir_fltr *
1187 ice_fdir_find_fltr_by_idx(struct ice_hw *hw, u32 fltr_idx)
1189 struct ice_fdir_fltr *rule;
1191 LIST_FOR_EACH_ENTRY(rule, &hw->fdir_list_head, ice_fdir_fltr,
1193 /* rule ID found in the list */
1194 if (fltr_idx == rule->fltr_id)
1196 if (fltr_idx < rule->fltr_id)
1203 * ice_fdir_list_add_fltr - add a new node to the flow director filter list
1204 * @hw: hardware structure
1205 * @fltr: filter node to add to structure
1207 void ice_fdir_list_add_fltr(struct ice_hw *hw, struct ice_fdir_fltr *fltr)
1209 struct ice_fdir_fltr *rule, *parent = NULL;
1211 LIST_FOR_EACH_ENTRY(rule, &hw->fdir_list_head, ice_fdir_fltr,
1213 /* rule ID found or pass its spot in the list */
1214 if (rule->fltr_id >= fltr->fltr_id)
1220 LIST_ADD_AFTER(&fltr->fltr_node, &parent->fltr_node);
1222 LIST_ADD(&fltr->fltr_node, &hw->fdir_list_head);
1226 * ice_fdir_update_cntrs - increment / decrement filter counter
1227 * @hw: pointer to hardware structure
1228 * @flow: filter flow type
1229 * @acl_fltr: true indicates an ACL filter
1230 * @add: true implies filters added
1233 ice_fdir_update_cntrs(struct ice_hw *hw, enum ice_fltr_ptype flow,
1234 bool acl_fltr, bool add)
1238 incr = add ? 1 : -1;
1239 hw->fdir_active_fltr += incr;
1240 if (flow == ICE_FLTR_PTYPE_NONF_NONE || flow >= ICE_FLTR_PTYPE_MAX) {
1241 ice_debug(hw, ICE_DBG_SW, "Unknown filter type %d\n", flow);
1244 hw->acl_fltr_cnt[flow] += incr;
1246 hw->fdir_fltr_cnt[flow] += incr;
1251 * ice_cmp_ipv6_addr - compare 2 IP v6 addresses
1255 * Returns 0 on equal, returns non-0 if different
1257 static int ice_cmp_ipv6_addr(__be32 *a, __be32 *b)
1259 return memcmp(a, b, 4 * sizeof(__be32));
1263 * ice_fdir_comp_rules - compare 2 filters
1264 * @a: a Flow Director filter data structure
1265 * @b: a Flow Director filter data structure
1266 * @v6: bool true if v6 filter
1268 * Returns true if the filters match
1271 ice_fdir_comp_rules(struct ice_fdir_fltr *a, struct ice_fdir_fltr *b, bool v6)
1273 enum ice_fltr_ptype flow_type = a->flow_type;
1275 /* The calling function already checks that the two filters have the
1279 if (flow_type == ICE_FLTR_PTYPE_NONF_IPV4_TCP ||
1280 flow_type == ICE_FLTR_PTYPE_NONF_IPV4_UDP ||
1281 flow_type == ICE_FLTR_PTYPE_NONF_IPV4_SCTP) {
1282 if (a->ip.v4.dst_ip == b->ip.v4.dst_ip &&
1283 a->ip.v4.src_ip == b->ip.v4.src_ip &&
1284 a->ip.v4.dst_port == b->ip.v4.dst_port &&
1285 a->ip.v4.src_port == b->ip.v4.src_port)
1287 } else if (flow_type == ICE_FLTR_PTYPE_NONF_IPV4_OTHER) {
1288 if (a->ip.v4.dst_ip == b->ip.v4.dst_ip &&
1289 a->ip.v4.src_ip == b->ip.v4.src_ip &&
1290 a->ip.v4.l4_header == b->ip.v4.l4_header &&
1291 a->ip.v4.proto == b->ip.v4.proto &&
1292 a->ip.v4.ip_ver == b->ip.v4.ip_ver &&
1293 a->ip.v4.tos == b->ip.v4.tos)
1297 if (flow_type == ICE_FLTR_PTYPE_NONF_IPV6_UDP ||
1298 flow_type == ICE_FLTR_PTYPE_NONF_IPV6_TCP ||
1299 flow_type == ICE_FLTR_PTYPE_NONF_IPV6_SCTP) {
1300 if (a->ip.v6.dst_port == b->ip.v6.dst_port &&
1301 a->ip.v6.src_port == b->ip.v6.src_port &&
1302 !ice_cmp_ipv6_addr(a->ip.v6.dst_ip,
1304 !ice_cmp_ipv6_addr(a->ip.v6.src_ip,
1307 } else if (flow_type == ICE_FLTR_PTYPE_NONF_IPV6_OTHER) {
1308 if (a->ip.v6.dst_port == b->ip.v6.dst_port &&
1309 a->ip.v6.src_port == b->ip.v6.src_port)
1318 * ice_fdir_is_dup_fltr - test if filter is already in list for PF
1319 * @hw: hardware data structure
1320 * @input: Flow Director filter data structure
1322 * Returns true if the filter is found in the list
1324 bool ice_fdir_is_dup_fltr(struct ice_hw *hw, struct ice_fdir_fltr *input)
1326 struct ice_fdir_fltr *rule;
1329 LIST_FOR_EACH_ENTRY(rule, &hw->fdir_list_head, ice_fdir_fltr,
1331 enum ice_fltr_ptype flow_type;
1333 if (rule->flow_type != input->flow_type)
1336 flow_type = input->flow_type;
1337 if (flow_type == ICE_FLTR_PTYPE_NONF_IPV4_TCP ||
1338 flow_type == ICE_FLTR_PTYPE_NONF_IPV4_UDP ||
1339 flow_type == ICE_FLTR_PTYPE_NONF_IPV4_SCTP ||
1340 flow_type == ICE_FLTR_PTYPE_NONF_IPV4_OTHER)
1341 ret = ice_fdir_comp_rules(rule, input, false);
1343 ret = ice_fdir_comp_rules(rule, input, true);
1345 if (rule->fltr_id == input->fltr_id &&
1346 rule->q_index != input->q_index)
1357 * ice_clear_vsi_fd_table - admin command to clear FD table for a VSI
1358 * @hw: hardware data structure
1359 * @vsi_num: vsi_num (HW VSI num)
1361 * Clears FD table entries by issuing admin command (direct, 0x0B06)
1362 * Must to pass valid vsi_num as returned by "AddVSI".
1364 enum ice_status ice_clear_vsi_fd_table(struct ice_hw *hw, u16 vsi_num)
1366 struct ice_aqc_clear_fd_table *cmd;
1367 struct ice_aq_desc desc;
1369 cmd = &desc.params.clear_fd_table;
1370 ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_clear_fd_table);
1371 cmd->clear_type = CL_FD_VM_VF_TYPE_VSI_IDX;
1373 cmd->vsi_index = CPU_TO_LE16(vsi_num);
1374 return ice_aq_send_cmd(hw, &desc, NULL, 0, NULL);
1378 * ice_clear_pf_fd_table - admin command to clear FD table for PF
1379 * @hw: hardware data structure
1381 * Clears FD table entries for a PF by issuing admin command (direct, 0x0B06)
1383 enum ice_status ice_clear_pf_fd_table(struct ice_hw *hw)
1385 struct ice_aqc_clear_fd_table *cmd;
1386 struct ice_aq_desc desc;
1388 cmd = &desc.params.clear_fd_table;
1389 ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_clear_fd_table);
1390 cmd->clear_type = CL_FD_VM_VF_TYPE_PF_IDX;
1391 /* vsi_index must be 0 to clear FD table for a PF */
1392 cmd->vsi_index = CPU_TO_LE16(0);
1394 return ice_aq_send_cmd(hw, &desc, NULL, 0, NULL);