2 *------------------------------------------------------------------
3 * Copyright (c) 2020 Intel and/or its affiliates.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *------------------------------------------------------------------
18 #ifndef _AVF_ADVANCED_FLOW_H_
19 #define _AVF_ADVANCED_FLOW_H_
21 #define AVF_SUCCESS (0)
22 #define AVF_FAILURE (-1)
24 #define BIT(a) (1UL << (a))
25 #define BIT_ULL(a) (1ULL << (a))
27 /* These macros are used to generate compilation errors if a structure/union
28 * is not exactly the correct length. It gives a divide by zero error if the
29 * structure/union is not of the correct size, otherwise it creates an enum
32 #define VIRTCHNL_CHECK_STRUCT_LEN(n, X) \
33 enum virtchnl_static_assert_enum_##X \
35 virtchnl_static_assert_##X = (n) / ((sizeof (struct X) == (n)) ? 1 : 0) \
37 #define VIRTCHNL_CHECK_UNION_LEN(n, X) \
38 enum virtchnl_static_asset_enum_##X \
40 virtchnl_static_assert_##X = (n) / ((sizeof (union X) == (n)) ? 1 : 0) \
43 /* AVF ethernet frame types */
44 #define AVF_ETHER_TYPE_IPV4 0x0800 /**< IPv4 Protocol. */
45 #define AVF_ETHER_TYPE_IPV6 0x86DD /**< IPv6 Protocol. */
47 #define VIRTCHNL_MAX_NUM_PROTO_HDRS 32
48 #define VIRTCHNL_MAX_SIZE_GEN_PACKET 1024
49 #define PROTO_HDR_SHIFT 5
50 #define PROTO_HDR_FIELD_START(proto_hdr_type) \
51 (proto_hdr_type << PROTO_HDR_SHIFT)
52 #define PROTO_HDR_FIELD_MASK ((1UL << PROTO_HDR_SHIFT) - 1)
54 /* VF use these macros to configure each protocol header.
55 * Specify which protocol headers and protocol header fields base on
56 * virtchnl_proto_hdr_type and virtchnl_proto_hdr_field.
57 * @param hdr: a struct of virtchnl_proto_hdr
58 * @param hdr_type: ETH/IPV4/TCP, etc
59 * @param field: SRC/DST/TEID/SPI, etc
61 #define VIRTCHNL_ADD_PROTO_HDR_FIELD(hdr, field) \
62 ((hdr)->field_selector |= BIT ((field) &PROTO_HDR_FIELD_MASK))
63 #define VIRTCHNL_DEL_PROTO_HDR_FIELD(hdr, field) \
64 ((hdr)->field_selector &= ~BIT ((field) &PROTO_HDR_FIELD_MASK))
65 #define VIRTCHNL_TEST_PROTO_HDR_FIELD(hdr, val) \
66 ((hdr)->field_selector & BIT ((val) &PROTO_HDR_FIELD_MASK))
67 #define VIRTCHNL_GET_PROTO_HDR_FIELD(hdr) ((hdr)->field_selector)
69 #define VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, hdr_type, field) \
70 (VIRTCHNL_ADD_PROTO_HDR_FIELD (hdr, VIRTCHNL_PROTO_HDR_##hdr_type##_##field))
71 #define VIRTCHNL_DEL_PROTO_HDR_FIELD_BIT(hdr, hdr_type, field) \
72 (VIRTCHNL_DEL_PROTO_HDR_FIELD (hdr, VIRTCHNL_PROTO_HDR_##hdr_type##_##field))
74 #define VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, hdr_type) \
75 ((hdr)->type = VIRTCHNL_PROTO_HDR_##hdr_type)
76 #define VIRTCHNL_GET_PROTO_HDR_TYPE(hdr) (((hdr)->type) >> PROTO_HDR_SHIFT)
77 #define VIRTCHNL_TEST_PROTO_HDR_TYPE(hdr, val) \
78 ((hdr)->type == ((val) >> PROTO_HDR_SHIFT))
79 #define VIRTCHNL_TEST_PROTO_HDR(hdr, val) \
80 (VIRTCHNL_TEST_PROTO_HDR_TYPE (hdr, val) && \
81 VIRTCHNL_TEST_PROTO_HDR_FIELD (hdr, val))
85 #define AVF_PROT_MAC_INNER (1ULL << 1)
86 #define AVF_PROT_MAC_OUTER (1ULL << 2)
87 #define AVF_PROT_VLAN_INNER (1ULL << 3)
88 #define AVF_PROT_VLAN_OUTER (1ULL << 4)
89 #define AVF_PROT_IPV4_INNER (1ULL << 5)
90 #define AVF_PROT_IPV4_OUTER (1ULL << 6)
91 #define AVF_PROT_IPV6_INNER (1ULL << 7)
92 #define AVF_PROT_IPV6_OUTER (1ULL << 8)
93 #define AVF_PROT_TCP_INNER (1ULL << 9)
94 #define AVF_PROT_TCP_OUTER (1ULL << 10)
95 #define AVF_PROT_UDP_INNER (1ULL << 11)
96 #define AVF_PROT_UDP_OUTER (1ULL << 12)
97 #define AVF_PROT_SCTP_INNER (1ULL << 13)
98 #define AVF_PROT_SCTP_OUTER (1ULL << 14)
99 #define AVF_PROT_ICMP4_INNER (1ULL << 15)
100 #define AVF_PROT_ICMP4_OUTER (1ULL << 16)
101 #define AVF_PROT_ICMP6_INNER (1ULL << 17)
102 #define AVF_PROT_ICMP6_OUTER (1ULL << 18)
103 #define AVF_PROT_VXLAN (1ULL << 19)
104 #define AVF_PROT_NVGRE (1ULL << 20)
105 #define AVF_PROT_GTPU (1ULL << 21)
106 #define AVF_PROT_ESP (1ULL << 22)
107 #define AVF_PROT_AH (1ULL << 23)
108 #define AVF_PROT_L2TPV3OIP (1ULL << 24)
109 #define AVF_PROT_PFCP (1ULL << 25)
113 #define AVF_SMAC (1ULL << 63)
114 #define AVF_DMAC (1ULL << 62)
115 #define AVF_ETHERTYPE (1ULL << 61)
116 #define AVF_IP_SRC (1ULL << 60)
117 #define AVF_IP_DST (1ULL << 59)
118 #define AVF_IP_PROTO (1ULL << 58)
119 #define AVF_IP_TTL (1ULL << 57)
120 #define AVF_IP_TOS (1ULL << 56)
121 #define AVF_SPORT (1ULL << 55)
122 #define AVF_DPORT (1ULL << 54)
123 #define AVF_ICMP_TYPE (1ULL << 53)
124 #define AVF_ICMP_CODE (1ULL << 52)
125 #define AVF_VXLAN_VNI (1ULL << 51)
126 #define AVF_NVGRE_TNI (1ULL << 50)
127 #define AVF_GTPU_TEID (1ULL << 49)
128 #define AVF_GTPU_QFI (1ULL << 48)
129 #define AVF_ESP_SPI (1ULL << 47)
130 #define AVF_AH_SPI (1ULL << 46)
131 #define AVF_L2TPV3OIP_SESSION_ID (1ULL << 45)
132 #define AVF_PFCP_S_FIELD (1ULL << 44)
133 #define AVF_PFCP_SEID (1ULL << 43)
137 #define AVF_INSET_NONE 0ULL
141 #define AVF_INSET_SMAC (AVF_PROT_MAC_OUTER | AVF_SMAC)
142 #define AVF_INSET_DMAC (AVF_PROT_MAC_OUTER | AVF_DMAC)
143 #define AVF_INSET_VLAN_INNER (AVF_PROT_VLAN_INNER)
144 #define AVF_INSET_VLAN_OUTER (AVF_PROT_VLAN_OUTER)
145 #define AVF_INSET_ETHERTYPE (AVF_ETHERTYPE)
147 #define AVF_INSET_IPV4_SRC (AVF_PROT_IPV4_OUTER | AVF_IP_SRC)
148 #define AVF_INSET_IPV4_DST (AVF_PROT_IPV4_OUTER | AVF_IP_DST)
149 #define AVF_INSET_IPV4_TOS (AVF_PROT_IPV4_OUTER | AVF_IP_TOS)
150 #define AVF_INSET_IPV4_PROTO (AVF_PROT_IPV4_OUTER | AVF_IP_PROTO)
151 #define AVF_INSET_IPV4_TTL (AVF_PROT_IPV4_OUTER | AVF_IP_TTL)
152 #define AVF_INSET_IPV6_SRC (AVF_PROT_IPV6_OUTER | AVF_IP_SRC)
153 #define AVF_INSET_IPV6_DST (AVF_PROT_IPV6_OUTER | AVF_IP_DST)
154 #define AVF_INSET_IPV6_NEXT_HDR (AVF_PROT_IPV6_OUTER | AVF_IP_PROTO)
155 #define AVF_INSET_IPV6_HOP_LIMIT (AVF_PROT_IPV6_OUTER | AVF_IP_TTL)
156 #define AVF_INSET_IPV6_TC (AVF_PROT_IPV6_OUTER | AVF_IP_TOS)
158 #define AVF_INSET_TCP_SRC_PORT (AVF_PROT_TCP_OUTER | AVF_SPORT)
159 #define AVF_INSET_TCP_DST_PORT (AVF_PROT_TCP_OUTER | AVF_DPORT)
160 #define AVF_INSET_UDP_SRC_PORT (AVF_PROT_UDP_OUTER | AVF_SPORT)
161 #define AVF_INSET_UDP_DST_PORT (AVF_PROT_UDP_OUTER | AVF_DPORT)
162 #define AVF_INSET_SCTP_SRC_PORT (AVF_PROT_SCTP_OUTER | AVF_SPORT)
163 #define AVF_INSET_SCTP_DST_PORT (AVF_PROT_SCTP_OUTER | AVF_DPORT)
164 #define AVF_INSET_ICMP4_SRC_PORT (AVF_PROT_ICMP4_OUTER | AVF_SPORT)
165 #define AVF_INSET_ICMP4_DST_PORT (AVF_PROT_ICMP4_OUTER | AVF_DPORT)
166 #define AVF_INSET_ICMP6_SRC_PORT (AVF_PROT_ICMP6_OUTER | AVF_SPORT)
167 #define AVF_INSET_ICMP6_DST_PORT (AVF_PROT_ICMP6_OUTER | AVF_DPORT)
168 #define AVF_INSET_ICMP4_TYPE (AVF_PROT_ICMP4_OUTER | AVF_ICMP_TYPE)
169 #define AVF_INSET_ICMP4_CODE (AVF_PROT_ICMP4_OUTER | AVF_ICMP_CODE)
170 #define AVF_INSET_ICMP6_TYPE (AVF_PROT_ICMP6_OUTER | AVF_ICMP_TYPE)
171 #define AVF_INSET_ICMP6_CODE (AVF_PROT_ICMP6_OUTER | AVF_ICMP_CODE)
172 #define AVF_INSET_GTPU_TEID (AVF_PROT_GTPU | AVF_GTPU_TEID)
173 #define AVF_INSET_GTPU_QFI (AVF_PROT_GTPU | AVF_GTPU_QFI)
174 #define AVF_INSET_ESP_SPI (AVF_PROT_ESP | AVF_ESP_SPI)
175 #define AVF_INSET_AH_SPI (AVF_PROT_AH | AVF_AH_SPI)
176 #define AVF_INSET_L2TPV3OIP_SESSION_ID \
177 (AVF_PROT_L2TPV3OIP | AVF_L2TPV3OIP_SESSION_ID)
178 #define AVF_INSET_PFCP_S_FIELD (AVF_PROT_PFCP | AVF_PFCP_S_FIELD)
179 #define AVF_INSET_PFCP_SEID (AVF_PROT_PFCP | AVF_PFCP_S_FIELD | AVF_PFCP_SEID)
181 #define AVF_ETH_RSS_IPV4 BIT_ULL (2)
182 #define AVF_ETH_RSS_FRAG_IPV4 BIT_ULL (3)
183 #define AVF_ETH_RSS_NONFRAG_IPV4_TCP BIT_ULL (4)
184 #define AVF_ETH_RSS_NONFRAG_IPV4_UDP BIT_ULL (5)
185 #define AVF_ETH_RSS_NONFRAG_IPV4_SCTP BIT_ULL (6)
186 #define AVF_ETH_RSS_NONFRAG_IPV4_OTHER BIT_ULL (7)
187 #define AVF_ETH_RSS_IPV6 BIT_ULL (8)
188 #define AVF_ETH_RSS_FRAG_IPV6 BIT_ULL (9)
189 #define AVF_ETH_RSS_NONFRAG_IPV6_TCP BIT_ULL (10)
190 #define AVF_ETH_RSS_NONFRAG_IPV6_UDP BIT_ULL (11)
191 #define AVF_ETH_RSS_NONFRAG_IPV6_SCTP BIT_ULL (12)
192 #define AVF_ETH_RSS_NONFRAG_IPV6_OTHER BIT_ULL (13)
193 #define AVF_ETH_RSS_L2_PAYLOAD BIT_ULL (14)
194 #define AVF_ETH_RSS_IPV6_EX BIT_ULL (15)
195 #define AVF_ETH_RSS_IPV6_TCP_EX BIT_ULL (16)
196 #define AVF_ETH_RSS_IPV6_UDP_EX BIT_ULL (17)
197 #define AVF_ETH_RSS_PORT BIT_ULL (18)
198 #define AVF_ETH_RSS_VXLAN BIT_ULL (19)
199 #define AVF_ETH_RSS_GENEVE BIT_ULL (20)
200 #define AVF_ETH_RSS_NVGRE BIT_ULL (21)
201 #define AVF_ETH_RSS_GTPU BIT_ULL (23)
202 #define AVF_ETH_RSS_ETH BIT_ULL (24)
203 #define AVF_ETH_RSS_S_VLAN BIT_ULL (25)
204 #define AVF_ETH_RSS_C_VLAN BIT_ULL (26)
205 #define AVF_ETH_RSS_ESP BIT_ULL (27)
206 #define AVF_ETH_RSS_AH BIT_ULL (28)
207 #define AVF_ETH_RSS_L2TPV3 BIT_ULL (29)
208 #define AVF_ETH_RSS_PFCP BIT_ULL (30)
209 #define AVF_ETH_RSS_PPPOE BIT_ULL (31)
210 #define AVF_ETH_RSS_ECPRI BIT_ULL (32)
211 #define AVF_ETH_RSS_MPLS BIT_ULL (33)
212 #define AVF_ETH_RSS_IPV4_CHKSUM BIT_ULL (34)
213 #define AVF_ETH_RSS_L4_CHKSUM BIT_ULL (35)
214 #define AVF_ETH_RSS_L2TPV2 BIT_ULL (36)
215 #define AVF_ETH_RSS_L3_SRC_ONLY BIT_ULL (63)
216 #define AVF_ETH_RSS_L3_DST_ONLY BIT_ULL (62)
217 #define AVF_ETH_RSS_L4_SRC_ONLY BIT_ULL (61)
218 #define AVF_ETH_RSS_L4_DST_ONLY BIT_ULL (60)
219 #define AVF_ETH_RSS_L2_SRC_ONLY BIT_ULL (59)
220 #define AVF_ETH_RSS_L2_DST_ONLY BIT_ULL (58)
221 #define AVF_ETH_RSS_L3_PRE32 BIT_ULL (57)
222 #define AVF_ETH_RSS_L3_PRE40 BIT_ULL (56)
223 #define AVF_ETH_RSS_L3_PRE48 BIT_ULL (55)
224 #define AVF_ETH_RSS_L3_PRE56 BIT_ULL (54)
225 #define AVF_ETH_RSS_L3_PRE64 BIT_ULL (53)
226 #define AVF_ETH_RSS_L3_PRE96 BIT_ULL (52)
228 #define foreach_avf_rss_hf \
229 _ (0, AVF_ETH_RSS_FRAG_IPV4, "ipv4-frag") \
230 _ (1, AVF_ETH_RSS_NONFRAG_IPV4_TCP, "ipv4-tcp") \
231 _ (2, AVF_ETH_RSS_NONFRAG_IPV4_UDP, "ipv4-udp") \
232 _ (3, AVF_ETH_RSS_NONFRAG_IPV4_SCTP, "ipv4-sctp") \
233 _ (4, AVF_ETH_RSS_NONFRAG_IPV4_OTHER, "ipv4-other") \
234 _ (5, AVF_ETH_RSS_IPV4, "ipv4") \
235 _ (6, AVF_ETH_RSS_IPV6_TCP_EX, "ipv6-tcp-ex") \
236 _ (7, AVF_ETH_RSS_IPV6_UDP_EX, "ipv6-udp-ex") \
237 _ (8, AVF_ETH_RSS_FRAG_IPV6, "ipv6-frag") \
238 _ (9, AVF_ETH_RSS_NONFRAG_IPV6_TCP, "ipv6-tcp") \
239 _ (10, AVF_ETH_RSS_NONFRAG_IPV6_UDP, "ipv6-udp") \
240 _ (11, AVF_ETH_RSS_NONFRAG_IPV6_SCTP, "ipv6-sctp") \
241 _ (12, AVF_ETH_RSS_NONFRAG_IPV6_OTHER, "ipv6-other") \
242 _ (13, AVF_ETH_RSS_IPV6_EX, "ipv6-ex") \
243 _ (14, AVF_ETH_RSS_IPV6, "ipv6") \
244 _ (15, AVF_ETH_RSS_L2_PAYLOAD, "l2-payload") \
245 _ (16, AVF_ETH_RSS_PORT, "port") \
246 _ (17, AVF_ETH_RSS_VXLAN, "vxlan") \
247 _ (18, AVF_ETH_RSS_GENEVE, "geneve") \
248 _ (19, AVF_ETH_RSS_NVGRE, "nvgre") \
249 _ (20, AVF_ETH_RSS_GTPU, "gtpu") \
250 _ (21, AVF_ETH_RSS_ESP, "esp") \
251 _ (22, AVF_ETH_RSS_L2TPV3, "l2tpv3") \
252 _ (60, AVF_ETH_RSS_L4_DST_ONLY, "l4-dst-only") \
253 _ (61, AVF_ETH_RSS_L4_SRC_ONLY, "l4-src-only") \
254 _ (62, AVF_ETH_RSS_L3_DST_ONLY, "l3-dst-only") \
255 _ (63, AVF_ETH_RSS_L3_SRC_ONLY, "l3-src-only")
257 /* Protocol header type within a packet segment. A segment consists of one or
258 * more protocol headers that make up a logical group of protocol headers. Each
259 * logical group of protocol headers encapsulates or is encapsulated using/by
260 * tunneling or encapsulation protocols for network virtualization.
262 enum virtchnl_proto_hdr_type
264 VIRTCHNL_PROTO_HDR_NONE,
265 VIRTCHNL_PROTO_HDR_ETH,
266 VIRTCHNL_PROTO_HDR_S_VLAN,
267 VIRTCHNL_PROTO_HDR_C_VLAN,
268 VIRTCHNL_PROTO_HDR_IPV4,
269 VIRTCHNL_PROTO_HDR_IPV6,
270 VIRTCHNL_PROTO_HDR_TCP,
271 VIRTCHNL_PROTO_HDR_UDP,
272 VIRTCHNL_PROTO_HDR_SCTP,
273 VIRTCHNL_PROTO_HDR_GTPU_IP,
274 VIRTCHNL_PROTO_HDR_GTPU_EH,
275 VIRTCHNL_PROTO_HDR_GTPU_EH_PDU_DWN,
276 VIRTCHNL_PROTO_HDR_GTPU_EH_PDU_UP,
277 VIRTCHNL_PROTO_HDR_PPPOE,
278 VIRTCHNL_PROTO_HDR_L2TPV3,
279 VIRTCHNL_PROTO_HDR_ESP,
280 VIRTCHNL_PROTO_HDR_AH,
281 VIRTCHNL_PROTO_HDR_PFCP,
282 VIRTCHNL_PROTO_HDR_GTPC,
283 VIRTCHNL_PROTO_HDR_ECPRI,
284 VIRTCHNL_PROTO_HDR_L2TPV2,
285 VIRTCHNL_PROTO_HDR_PPP,
286 /* IPv4 and IPv6 Fragment header types are only associated to
287 * VIRTCHNL_PROTO_HDR_IPV4 and VIRTCHNL_PROTO_HDR_IPV6 respectively,
288 * cannot be used independently.
290 VIRTCHNL_PROTO_HDR_IPV4_FRAG,
291 VIRTCHNL_PROTO_HDR_IPV6_EH_FRAG,
292 VIRTCHNL_PROTO_HDR_GRE,
295 /* Protocol header field within a protocol header. */
296 enum virtchnl_proto_hdr_field
299 VIRTCHNL_PROTO_HDR_ETH_SRC = PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_ETH),
300 VIRTCHNL_PROTO_HDR_ETH_DST,
301 VIRTCHNL_PROTO_HDR_ETH_ETHERTYPE,
303 VIRTCHNL_PROTO_HDR_S_VLAN_ID =
304 PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_S_VLAN),
306 VIRTCHNL_PROTO_HDR_C_VLAN_ID =
307 PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_C_VLAN),
309 VIRTCHNL_PROTO_HDR_IPV4_SRC =
310 PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_IPV4),
311 VIRTCHNL_PROTO_HDR_IPV4_DST,
312 VIRTCHNL_PROTO_HDR_IPV4_DSCP,
313 VIRTCHNL_PROTO_HDR_IPV4_TTL,
314 VIRTCHNL_PROTO_HDR_IPV4_PROT,
315 VIRTCHNL_PROTO_HDR_IPV4_CHKSUM,
317 VIRTCHNL_PROTO_HDR_IPV6_SRC =
318 PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_IPV6),
319 VIRTCHNL_PROTO_HDR_IPV6_DST,
320 VIRTCHNL_PROTO_HDR_IPV6_TC,
321 VIRTCHNL_PROTO_HDR_IPV6_HOP_LIMIT,
322 VIRTCHNL_PROTO_HDR_IPV6_PROT,
324 VIRTCHNL_PROTO_HDR_IPV6_PREFIX32_SRC,
325 VIRTCHNL_PROTO_HDR_IPV6_PREFIX32_DST,
326 VIRTCHNL_PROTO_HDR_IPV6_PREFIX40_SRC,
327 VIRTCHNL_PROTO_HDR_IPV6_PREFIX40_DST,
328 VIRTCHNL_PROTO_HDR_IPV6_PREFIX48_SRC,
329 VIRTCHNL_PROTO_HDR_IPV6_PREFIX48_DST,
330 VIRTCHNL_PROTO_HDR_IPV6_PREFIX56_SRC,
331 VIRTCHNL_PROTO_HDR_IPV6_PREFIX56_DST,
332 VIRTCHNL_PROTO_HDR_IPV6_PREFIX64_SRC,
333 VIRTCHNL_PROTO_HDR_IPV6_PREFIX64_DST,
334 VIRTCHNL_PROTO_HDR_IPV6_PREFIX96_SRC,
335 VIRTCHNL_PROTO_HDR_IPV6_PREFIX96_DST,
337 VIRTCHNL_PROTO_HDR_TCP_SRC_PORT =
338 PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_TCP),
339 VIRTCHNL_PROTO_HDR_TCP_DST_PORT,
340 VIRTCHNL_PROTO_HDR_TCP_CHKSUM,
342 VIRTCHNL_PROTO_HDR_UDP_SRC_PORT =
343 PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_UDP),
344 VIRTCHNL_PROTO_HDR_UDP_DST_PORT,
345 VIRTCHNL_PROTO_HDR_UDP_CHKSUM,
347 VIRTCHNL_PROTO_HDR_SCTP_SRC_PORT =
348 PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_SCTP),
349 VIRTCHNL_PROTO_HDR_SCTP_DST_PORT,
350 VIRTCHNL_PROTO_HDR_SCTP_CHKSUM,
352 VIRTCHNL_PROTO_HDR_GTPU_IP_TEID =
353 PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_GTPU_IP),
355 VIRTCHNL_PROTO_HDR_GTPU_EH_PDU =
356 PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_GTPU_EH),
357 VIRTCHNL_PROTO_HDR_GTPU_EH_QFI,
359 VIRTCHNL_PROTO_HDR_PPPOE_SESS_ID =
360 PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_PPPOE),
362 VIRTCHNL_PROTO_HDR_L2TPV3_SESS_ID =
363 PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_L2TPV3),
365 VIRTCHNL_PROTO_HDR_ESP_SPI = PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_ESP),
367 VIRTCHNL_PROTO_HDR_AH_SPI = PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_AH),
369 VIRTCHNL_PROTO_HDR_PFCP_S_FIELD =
370 PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_PFCP),
371 VIRTCHNL_PROTO_HDR_PFCP_SEID,
373 VIRTCHNL_PROTO_HDR_GTPC_TEID =
374 PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_GTPC),
376 VIRTCHNL_PROTO_HDR_ECPRI_MSG_TYPE =
377 PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_ECPRI),
378 VIRTCHNL_PROTO_HDR_ECPRI_PC_RTC_ID,
379 /* IPv4 Dummy Fragment */
380 VIRTCHNL_PROTO_HDR_IPV4_FRAG_PKID =
381 PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_IPV4_FRAG),
382 /* IPv6 Extension Fragment */
383 VIRTCHNL_PROTO_HDR_IPV6_EH_FRAG_PKID =
384 PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_IPV6_EH_FRAG),
386 VIRTCHNL_PROTO_HDR_GTPU_DWN_QFI =
387 PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_GTPU_EH_PDU_DWN),
388 VIRTCHNL_PROTO_HDR_GTPU_UP_QFI =
389 PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_GTPU_EH_PDU_UP),
391 VIRTCHNL_PROTO_HDR_L2TPV2_SESS_ID =
392 PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_L2TPV2),
393 VIRTCHNL_PROTO_HDR_L2TPV2_LEN_SESS_ID,
396 struct virtchnl_proto_hdr
398 enum virtchnl_proto_hdr_type type;
399 u32 field_selector; /* a bit mask to select field for header type */
402 * binary buffer in network order for specific header type.
403 * For example, if type = VIRTCHNL_PROTO_HDR_IPV4, a IPv4
404 * header is expected to be copied into the buffer.
408 VIRTCHNL_CHECK_STRUCT_LEN (72, virtchnl_proto_hdr);
410 struct virtchnl_proto_hdrs
414 * specify where protocol header start from. Must be 0 when sending a generic
415 * packet request. 0 - from the outer layer 1 - from the first inner layer 2
416 *- from the second inner layer
421 * the proto layers must < VIRTCHNL_MAX_NUM_PROTO_HDRS.
422 * Must be 0 when sending a generic packet request.
426 struct virtchnl_proto_hdr proto_hdr[VIRTCHNL_MAX_NUM_PROTO_HDRS];
430 u8 spec[VIRTCHNL_MAX_SIZE_GEN_PACKET];
431 u8 mask[VIRTCHNL_MAX_SIZE_GEN_PACKET];
436 VIRTCHNL_CHECK_STRUCT_LEN (2312, virtchnl_proto_hdrs);
438 /* VIRTCHNL_OP_CONFIG_RSS_KEY
439 * VIRTCHNL_OP_CONFIG_RSS_LUT
440 * VF sends these messages to configure RSS. Only supported if both PF
441 * and VF drivers set the VIRTCHNL_VF_OFFLOAD_RSS_PF bit during
442 * configuration negotiation. If this is the case, then the RSS fields in
443 * the VF resource struct are valid.
444 * Both the key and LUT are initialized to 0 by the PF, meaning that
445 * RSS is effectively disabled until set up by the VF.
447 struct virtchnl_rss_key
451 u8 key[1]; /* RSS hash key, packed bytes */
454 VIRTCHNL_CHECK_STRUCT_LEN (6, virtchnl_rss_key);
456 struct virtchnl_rss_lut
460 u8 lut[1]; /* RSS lookup table */
463 VIRTCHNL_CHECK_STRUCT_LEN (6, virtchnl_rss_lut);
465 /* VIRTCHNL_OP_GET_RSS_HENA_CAPS
466 * VIRTCHNL_OP_SET_RSS_HENA
467 * VF sends these messages to get and set the hash filter enable bits for RSS.
468 * By default, the PF sets these to all possible traffic types that the
469 * hardware supports. The VF can query this value if it wants to change the
470 * traffic types that are hashed by the hardware.
472 struct virtchnl_rss_hena
477 VIRTCHNL_CHECK_STRUCT_LEN (8, virtchnl_rss_hena);
479 /* Type of RSS algorithm */
480 enum virtchnl_rss_algorithm
482 VIRTCHNL_RSS_ALG_TOEPLITZ_ASYMMETRIC = 0,
483 VIRTCHNL_RSS_ALG_XOR_ASYMMETRIC = 1,
484 VIRTCHNL_RSS_ALG_TOEPLITZ_SYMMETRIC = 2,
485 VIRTCHNL_RSS_ALG_XOR_SYMMETRIC = 3,
488 struct virtchnl_rss_cfg
490 struct virtchnl_proto_hdrs proto_hdrs; /* protocol headers */
491 enum virtchnl_rss_algorithm rss_algorithm; /* rss algorithm type */
492 u8 reserved[128]; /* reserve for future */
495 VIRTCHNL_CHECK_STRUCT_LEN (2444, virtchnl_rss_cfg);
497 struct avf_pattern_match_item
499 enum avf_flow_item_type *pattern_list;
504 enum avf_flow_item_type
506 AVF_FLOW_ITEM_TYPE_END,
507 AVF_FLOW_ITEM_TYPE_VOID,
508 AVF_FLOW_ITEM_TYPE_INVERT,
509 AVF_FLOW_ITEM_TYPE_ANY,
510 AVF_FLOW_ITEM_TYPE_PORT_ID,
511 AVF_FLOW_ITEM_TYPE_RAW,
512 AVF_FLOW_ITEM_TYPE_ETH,
513 AVF_FLOW_ITEM_TYPE_VLAN,
514 AVF_FLOW_ITEM_TYPE_IPV4,
515 AVF_FLOW_ITEM_TYPE_IPV6,
516 AVF_FLOW_ITEM_TYPE_ICMP,
517 AVF_FLOW_ITEM_TYPE_UDP,
518 AVF_FLOW_ITEM_TYPE_TCP,
519 AVF_FLOW_ITEM_TYPE_SCTP,
520 AVF_FLOW_ITEM_TYPE_VXLAN,
521 AVF_FLOW_ITEM_TYPE_E_TAG,
522 AVF_FLOW_ITEM_TYPE_NVGRE,
523 AVF_FLOW_ITEM_TYPE_MPLS,
524 AVF_FLOW_ITEM_TYPE_GRE,
525 AVF_FLOW_ITEM_TYPE_FUZZY,
526 AVF_FLOW_ITEM_TYPE_GTP,
527 AVF_FLOW_ITEM_TYPE_GTPC,
528 AVF_FLOW_ITEM_TYPE_GTPU,
529 AVF_FLOW_ITEM_TYPE_ESP,
530 AVF_FLOW_ITEM_TYPE_GENEVE,
531 AVF_FLOW_ITEM_TYPE_VXLAN_GPE,
532 AVF_FLOW_ITEM_TYPE_ARP_ETH_IPV4,
533 AVF_FLOW_ITEM_TYPE_IPV6_EXT,
534 AVF_FLOW_ITEM_TYPE_ICMP6,
535 AVF_FLOW_ITEM_TYPE_ICMP6_ND_NS,
536 AVF_FLOW_ITEM_TYPE_ICMP6_ND_NA,
537 AVF_FLOW_ITEM_TYPE_ICMP6_ND_OPT,
538 AVF_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH,
539 AVF_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH,
540 AVF_FLOW_ITEM_TYPE_MARK,
541 AVF_FLOW_ITEM_TYPE_META,
542 AVF_FLOW_ITEM_TYPE_GRE_KEY,
543 AVF_FLOW_ITEM_TYPE_GTP_PSC,
544 AVF_FLOW_ITEM_TYPE_PPPOES,
545 AVF_FLOW_ITEM_TYPE_PPPOED,
546 AVF_FLOW_ITEM_TYPE_PPPOE_PROTO_ID,
547 AVF_FLOW_ITEM_TYPE_NSH,
548 AVF_FLOW_ITEM_TYPE_IGMP,
549 AVF_FLOW_ITEM_TYPE_AH,
550 AVF_FLOW_ITEM_TYPE_HIGIG2,
551 AVF_FLOW_ITEM_TYPE_TAG,
552 AVF_FLOW_ITEM_TYPE_L2TPV3OIP,
553 AVF_FLOW_ITEM_TYPE_PFCP,
554 AVF_FLOW_ITEM_TYPE_ECPRI,
555 AVF_FLOW_ITEM_TYPE_IPV6_FRAG_EXT,
556 AVF_FLOW_ITEM_TYPE_GENEVE_OPT,
557 AVF_FLOW_ITEM_TYPE_INTEGRITY,
558 AVF_FLOW_ITEM_TYPE_CONNTRACK,
559 AVF_FLOW_ITEM_TYPE_PORT_REPRESENTOR,
560 AVF_FLOW_ITEM_TYPE_REPRESENTED_PORT,
561 AVF_FLOW_ITEM_TYPE_FLEX,
562 AVF_FLOW_ITEM_TYPE_L2TPV2,
563 AVF_FLOW_ITEM_TYPE_PPP,
564 AVF_FLOW_ITEM_TYPE_GRE_OPTION,
565 AVF_FLOW_ITEM_TYPE_MACSEC,
566 AVF_FLOW_ITEM_TYPE_METER_COLOR,
569 enum avf_flow_action_type
571 AVF_FLOW_ACTION_TYPE_END,
572 AVF_FLOW_ACTION_TYPE_VOID,
573 AVF_FLOW_ACTION_TYPE_PASSTHRU,
574 AVF_FLOW_ACTION_TYPE_JUMP,
575 AVF_FLOW_ACTION_TYPE_MARK,
576 AVF_FLOW_ACTION_TYPE_FLAG,
577 AVF_FLOW_ACTION_TYPE_QUEUE,
578 AVF_FLOW_ACTION_TYPE_DROP,
579 AVF_FLOW_ACTION_TYPE_COUNT,
580 AVF_FLOW_ACTION_TYPE_RSS,
581 AVF_FLOW_ACTION_TYPE_PF,
582 AVF_FLOW_ACTION_TYPE_VF,
583 AVF_FLOW_ACTION_TYPE_PORT_ID,
584 AVF_FLOW_ACTION_TYPE_METER,
585 AVF_FLOW_ACTION_TYPE_SECURITY,
586 AVF_FLOW_ACTION_TYPE_OF_DEC_NW_TTL,
587 AVF_FLOW_ACTION_TYPE_OF_POP_VLAN,
588 AVF_FLOW_ACTION_TYPE_OF_PUSH_VLAN,
589 AVF_FLOW_ACTION_TYPE_OF_SET_VLAN_VID,
590 AVF_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP,
591 AVF_FLOW_ACTION_TYPE_OF_POP_MPLS,
592 AVF_FLOW_ACTION_TYPE_OF_PUSH_MPLS,
593 AVF_FLOW_ACTION_TYPE_VXLAN_ENCAP,
594 AVF_FLOW_ACTION_TYPE_VXLAN_DECAP,
595 AVF_FLOW_ACTION_TYPE_NVGRE_ENCAP,
596 AVF_FLOW_ACTION_TYPE_NVGRE_DECAP,
597 AVF_FLOW_ACTION_TYPE_RAW_ENCAP,
598 AVF_FLOW_ACTION_TYPE_RAW_DECAP,
599 AVF_FLOW_ACTION_TYPE_SET_IPV4_SRC,
600 AVF_FLOW_ACTION_TYPE_SET_IPV4_DST,
601 AVF_FLOW_ACTION_TYPE_SET_IPV6_SRC,
602 AVF_FLOW_ACTION_TYPE_SET_IPV6_DST,
603 AVF_FLOW_ACTION_TYPE_SET_TP_SRC,
604 AVF_FLOW_ACTION_TYPE_SET_TP_DST,
605 AVF_FLOW_ACTION_TYPE_MAC_SWAP,
606 AVF_FLOW_ACTION_TYPE_DEC_TTL,
607 AVF_FLOW_ACTION_TYPE_SET_TTL,
608 AVF_FLOW_ACTION_TYPE_SET_MAC_SRC,
609 AVF_FLOW_ACTION_TYPE_SET_MAC_DST,
610 AVF_FLOW_ACTION_TYPE_INC_TCP_SEQ,
611 AVF_FLOW_ACTION_TYPE_DEC_TCP_SEQ,
612 AVF_FLOW_ACTION_TYPE_INC_TCP_ACK,
613 AVF_FLOW_ACTION_TYPE_DEC_TCP_ACK,
614 AVF_FLOW_ACTION_TYPE_SET_TAG,
615 AVF_FLOW_ACTION_TYPE_SET_META,
616 AVF_FLOW_ACTION_TYPE_SET_IPV4_DSCP,
617 AVF_FLOW_ACTION_TYPE_SET_IPV6_DSCP,
618 AVF_FLOW_ACTION_TYPE_AGE,
619 AVF_FLOW_ACTION_TYPE_SAMPLE,
620 AVF_FLOW_ACTION_TYPE_SHARED,
621 AVF_FLOW_ACTION_TYPE_MODIFY_FIELD,
622 AVF_FLOW_ACTION_TYPE_INDIRECT,
623 AVF_FLOW_ACTION_TYPE_CONNTRACK,
624 AVF_FLOW_ACTION_TYPE_METER_COLOR,
625 AVF_FLOW_ACTION_TYPE_PORT_REPRESENTOR,
626 AVF_FLOW_ACTION_TYPE_REPRESENTED_PORT,
627 AVF_FLOW_ACTION_TYPE_METER_MARK,
628 AVF_FLOW_ACTION_TYPE_SEND_TO_KERNEL,
634 VIRTCHNL_ACTION_DROP = 0,
635 VIRTCHNL_ACTION_TC_REDIRECT,
636 VIRTCHNL_ACTION_PASSTHRU,
637 VIRTCHNL_ACTION_QUEUE,
638 VIRTCHNL_ACTION_Q_REGION,
639 VIRTCHNL_ACTION_MARK,
640 VIRTCHNL_ACTION_COUNT,
641 VIRTCHNL_ACTION_NONE,
644 /* action configuration for FDIR */
645 struct virtchnl_filter_action
647 enum virtchnl_action type;
650 /* used for queue and qgroup action */
656 /* used for count action */
659 /* share counter ID with other flow rules */
661 u32 id; /* counter ID */
663 /* used for mark action */
669 VIRTCHNL_CHECK_STRUCT_LEN (36, virtchnl_filter_action);
671 #define VIRTCHNL_MAX_NUM_ACTIONS 8
673 struct virtchnl_filter_action_set
675 /* action number must be less then VIRTCHNL_MAX_NUM_ACTIONS */
677 struct virtchnl_filter_action actions[VIRTCHNL_MAX_NUM_ACTIONS];
680 VIRTCHNL_CHECK_STRUCT_LEN (292, virtchnl_filter_action_set);
682 /* pattern and action for FDIR rule */
683 struct virtchnl_fdir_rule
685 struct virtchnl_proto_hdrs proto_hdrs;
686 struct virtchnl_filter_action_set action_set;
689 VIRTCHNL_CHECK_STRUCT_LEN (2604, virtchnl_fdir_rule);
691 /* query information to retrieve fdir rule counters.
692 * PF will fill out this structure to reset counter.
694 struct virtchnl_fdir_query_info
696 u32 match_packets_valid : 1;
697 u32 match_bytes_valid : 1;
698 u32 reserved : 30; /* Reserved, must be zero. */
700 u64 matched_packets; /* Number of packets for this rule. */
701 u64 matched_bytes; /* Number of bytes through this rule. */
704 VIRTCHNL_CHECK_STRUCT_LEN (24, virtchnl_fdir_query_info);
706 /* Status returned to VF after VF requests FDIR commands
707 * VIRTCHNL_FDIR_SUCCESS
708 * VF FDIR related request is successfully done by PF
709 * The request can be OP_ADD/DEL/QUERY_FDIR_FILTER.
711 * VIRTCHNL_FDIR_FAILURE_RULE_NORESOURCE
712 * OP_ADD_FDIR_FILTER request is failed due to no Hardware resource.
714 * VIRTCHNL_FDIR_FAILURE_RULE_EXIST
715 * OP_ADD_FDIR_FILTER request is failed due to the rule is already existed.
717 * VIRTCHNL_FDIR_FAILURE_RULE_CONFLICT
718 * OP_ADD_FDIR_FILTER request is failed due to conflict with existing rule.
720 * VIRTCHNL_FDIR_FAILURE_RULE_NONEXIST
721 * OP_DEL_FDIR_FILTER request is failed due to this rule doesn't exist.
723 * VIRTCHNL_FDIR_FAILURE_RULE_INVALID
724 * OP_ADD_FDIR_FILTER request is failed due to parameters validation
725 * or HW doesn't support.
727 * VIRTCHNL_FDIR_FAILURE_RULE_TIMEOUT
728 * OP_ADD/DEL_FDIR_FILTER request is failed due to timing out
731 * VIRTCHNL_FDIR_FAILURE_QUERY_INVALID
732 * OP_QUERY_FDIR_FILTER request is failed due to parameters validation,
733 * for example, VF query counter of a rule who has no counter action.
735 enum virtchnl_fdir_prgm_status
737 VIRTCHNL_FDIR_SUCCESS = 0,
738 VIRTCHNL_FDIR_FAILURE_RULE_NORESOURCE,
739 VIRTCHNL_FDIR_FAILURE_RULE_EXIST,
740 VIRTCHNL_FDIR_FAILURE_RULE_CONFLICT,
741 VIRTCHNL_FDIR_FAILURE_RULE_NONEXIST,
742 VIRTCHNL_FDIR_FAILURE_RULE_INVALID,
743 VIRTCHNL_FDIR_FAILURE_RULE_TIMEOUT,
744 VIRTCHNL_FDIR_FAILURE_QUERY_INVALID,
745 VIRTCHNL_FDIR_FAILURE_MAX,
748 /* VIRTCHNL_OP_ADD_FDIR_FILTER
749 * VF sends this request to PF by filling out vsi_id,
750 * validate_only and rule_cfg. PF will return flow_id
751 * if the request is successfully done and return add_status to VF.
753 struct virtchnl_fdir_add
755 u16 vsi_id; /* INPUT */
757 * 1 for validating a fdir rule, 0 for creating a fdir rule.
758 * Validate and create share one ops: VIRTCHNL_OP_ADD_FDIR_FILTER.
760 u16 validate_only; /* INPUT */
761 u32 flow_id; /* OUTPUT */
762 struct virtchnl_fdir_rule rule_cfg; /* INPUT */
763 enum virtchnl_fdir_prgm_status status; /* OUTPUT */
766 VIRTCHNL_CHECK_STRUCT_LEN (2616, virtchnl_fdir_add);
768 /* VIRTCHNL_OP_DEL_FDIR_FILTER
769 * VF sends this request to PF by filling out vsi_id
770 * and flow_id. PF will return del_status to VF.
772 struct virtchnl_fdir_del
774 u16 vsi_id; /* INPUT */
776 u32 flow_id; /* INPUT */
777 enum virtchnl_fdir_prgm_status status; /* OUTPUT */
780 VIRTCHNL_CHECK_STRUCT_LEN (12, virtchnl_fdir_del);
782 /* VIRTCHNL_OP_QUERY_FDIR_FILTER
783 * VF sends this request to PF by filling out vsi_id,
784 * flow_id and reset_counter. PF will return query_info
785 * and query_status to VF.
787 struct virtchnl_fdir_query
789 u16 vsi_id; /* INPUT */
791 u32 flow_id; /* INPUT */
792 u32 reset_counter : 1; /* INPUT */
793 struct virtchnl_fdir_query_info query_info; /* OUTPUT */
794 enum virtchnl_fdir_prgm_status status; /* OUTPUT */
798 VIRTCHNL_CHECK_STRUCT_LEN (48, virtchnl_fdir_query);
801 * Those headers used temporary, maybe OS packet
802 * definition can replace. Add flow error, pattern
803 * and action definition.
807 * Verbose error types.
809 * Most of them provide the type of the object referenced by struct
810 * rte_flow_error.cause.
812 enum avf_flow_error_type
814 AVF_FLOW_ERROR_TYPE_NONE, /**< No error. */
815 AVF_FLOW_ERROR_TYPE_UNSPECIFIED, /**< Cause unspecified. */
816 AVF_FLOW_ERROR_TYPE_HANDLE, /**< Flow rule (handle). */
817 AVF_FLOW_ERROR_TYPE_ATTR_GROUP, /**< Group field. */
818 AVF_FLOW_ERROR_TYPE_ATTR_PRIORITY, /**< Priority field. */
819 AVF_FLOW_ERROR_TYPE_ATTR_INGRESS, /**< Ingress field. */
820 AVF_FLOW_ERROR_TYPE_ATTR_EGRESS, /**< Egress field. */
821 AVF_FLOW_ERROR_TYPE_ATTR_TRANSFER, /**< Transfer field. */
822 AVF_FLOW_ERROR_TYPE_ATTR, /**< Attributes structure. */
823 AVF_FLOW_ERROR_TYPE_ITEM_NUM, /**< Pattern length. */
824 AVF_FLOW_ERROR_TYPE_ITEM_SPEC, /**< Item specification. */
825 AVF_FLOW_ERROR_TYPE_ITEM_LAST, /**< Item specification range. */
826 AVF_FLOW_ERROR_TYPE_ITEM_MASK, /**< Item specification mask. */
827 AVF_FLOW_ERROR_TYPE_ITEM, /**< Specific pattern item. */
828 AVF_FLOW_ERROR_TYPE_ACTION_NUM, /**< Number of actions. */
829 AVF_FLOW_ERROR_TYPE_ACTION_CONF, /**< Action configuration. */
830 AVF_FLOW_ERROR_TYPE_ACTION, /**< Specific action. */
834 * Verbose error structure definition.
835 * Both cause and message may be NULL regardless of the error type.
837 struct avf_flow_error
839 enum avf_flow_error_type type; /**< Cause field and error types. */
840 const void *cause; /**< Object responsible for the error. */
841 const char *message; /**< Human-readable error message. */
844 #define AVF_ETHER_ADDR_LEN 6
845 struct avf_ether_addr
847 u8 addr_bytes[AVF_ETHER_ADDR_LEN]; /**< Addr bytes in tx order */
848 } __attribute__ ((__aligned__ (2)));
850 struct avf_flow_eth_hdr
852 struct avf_ether_addr dst; /**< Destination MAC. */
853 struct avf_ether_addr src; /**< Source MAC. */
854 u16 type; /**< EtherType or TPID. */
862 u8 version_ihl; /**< version and header length */
863 u8 type_of_service; /**< type of service */
864 u16 total_length; /**< length of packet */
865 u16 packet_id; /**< packet ID */
866 u16 fragment_offset; /**< fragmentation offset */
867 u8 time_to_live; /**< time to live */
868 u8 next_proto_id; /**< protocol ID */
869 u16 hdr_checksum; /**< header checksum */
870 u32 src_addr; /**< source address */
871 u32 dst_addr; /**< destination address */
872 } __attribute__ ((__packed__));
879 u32 vtc_flow; /**< IP version, traffic class & flow label. */
880 u16 payload_len; /**< IP packet length - includes header size */
881 u8 proto; /**< Protocol, next header. */
882 u8 hop_limits; /**< Hop limits. */
883 u8 src_addr[16]; /**< IP address of source host. */
884 u8 dst_addr[16]; /**< IP address of destination host(s). */
885 } __attribute__ ((__packed__));
892 u16 src_port; /**< TCP source port. */
893 u16 dst_port; /**< TCP destination port. */
894 u32 sent_seq; /**< TX data sequence number. */
895 u32 recv_ack; /**< RX data acknowledgment sequence number. */
896 u8 data_off; /**< Data offset. */
897 u8 tcp_flags; /**< TCP flags */
898 u16 rx_win; /**< RX flow control window. */
899 u16 cksum; /**< TCP checksum. */
900 u16 tcp_urp; /**< TCP urgent pointer, if any. */
901 } __attribute__ ((__packed__));
908 u16 src_port; /**< UDP source port. */
909 u16 dst_port; /**< UDP destination port. */
910 u16 dgram_len; /**< UDP datagram length */
911 u16 dgram_cksum; /**< UDP datagram checksum */
912 } __attribute__ ((__packed__));
915 * Match IP Authentication Header (AH), RFC 4302
931 u32 spi; /**< Security Parameters Index */
932 u32 seq; /**< packet sequence number */
933 } __attribute__ ((__packed__));
947 * Matches a L2TPv3 over IP header.
949 struct avf_l2tpv3oip_hdr
951 u32 session_id; /**< Session ID. */
955 * Matches a GTP PDU extension header with type 0x85.
957 struct avf_gtp_psc_hdr
959 u8 pdu_type; /**< PDU type. */
960 u8 qfi; /**< QoS flow identifier. */
964 * Matches a GTPv1 header.
969 * Version (3b), protocol type (1b), reserved (1b),
970 * Extension header flag (1b),
971 * Sequence number flag (1b),
972 * N-PDU number flag (1b).
975 u8 msg_type; /**< Message type. */
976 u16 msg_len; /**< Message length. */
977 u32 teid; /**< Tunnel endpoint identifier. */
985 u16 src_port; /**< Source port. */
986 u16 dst_port; /**< Destin port. */
987 u32 tag; /**< Validation tag. */
988 u32 cksum; /**< Checksum. */
989 } __attribute__ ((__packed__));
992 * Hash function types.
994 enum avf_eth_hash_function
996 AVF_ETH_HASH_FUNCTION_DEFAULT = 0,
997 AVF_ETH_HASH_FUNCTION_TOEPLITZ, /**< Toeplitz */
998 AVF_ETH_HASH_FUNCTION_SIMPLE_XOR, /**< Simple XOR */
1000 * Symmetric Toeplitz: src, dst will be replaced by
1001 * xor(src, dst). For the case with src/dst only,
1002 * src or dst address will xor with zero pair.
1004 AVF_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ,
1005 AVF_ETH_HASH_FUNCTION_MAX,
1008 struct avf_flow_action_rss
1010 enum avf_eth_hash_function func; /**< RSS hash function to apply. */
1013 u64 types; /**< Specific RSS hash types (see ETH_RSS_*). */
1014 u32 key_len; /**< Hash key length in bytes. */
1015 u32 queue_num; /**< Number of entries in @p queue. */
1016 const u8 *key; /**< Hash key. */
1017 const u16 *queue; /**< Queue indices to use. */
1020 struct avf_flow_action_queue
1022 u16 index; /**< Queue index to use. */
1025 struct avf_flow_action_mark
1027 u32 id; /**< Integer value to return with packets. */
1030 struct avf_flow_action
1032 enum avf_flow_action_type type; /**< Action type. */
1033 const void *conf; /**< Pointer to action configuration object. */
1036 struct avf_flow_item
1038 enum avf_flow_item_type type; /**< Item type. */
1039 const void *spec; /**< Pointer to item specification structure. */
1040 const void *mask; /**< Bit-mask applied to spec and last. */
1041 int is_generic; /* indicate if this item is for a generic flow pattern. */
1044 struct avf_fdir_conf
1046 struct virtchnl_fdir_add add_fltr;
1047 struct virtchnl_fdir_del del_fltr;
1055 enum virthnl_adv_ops
1057 VIRTCHNL_ADV_OP_ADD_FDIR_FILTER = 0,
1058 VIRTCHNL_ADV_OP_DEL_FDIR_FILTER,
1059 VIRTCHNL_ADV_OP_QUERY_FDIR_FILTER,
1060 VIRTCHNL_ADV_OP_ADD_RSS_CFG,
1061 VIRTCHNL_ADV_OP_DEL_RSS_CFG,
1065 /* virtual channel op handler */
1066 typedef int (*avf_flow_vc_op_t) (void *vc_hdl, enum virthnl_adv_ops vc_op,
1067 void *in, u32 in_len, void *out, u32 out_len);
1069 /* virtual channel context object */
1070 struct avf_flow_vc_ctx
1072 void *vc_hdl; /* virtual channel handler */
1073 avf_flow_vc_op_t vc_op;
1077 * Create a rule cfg object.
1080 * created rule cfg object.
1082 * tunnel level where protocol header start from
1083 * 0 from moster outer layer.
1084 * 1 from first inner layer.
1085 * 2 form second inner layer.
1091 * the rx queue number of the avf
1097 int avf_fdir_rcfg_create (struct avf_fdir_conf **rcfg, int tunnel_level,
1101 * Destroy a rule cfg object.
1104 * the cfg object to destroy.
1110 int avf_fdir_rcfg_destroy (struct avf_fdir_conf *rcfg);
1113 * Set match potocol header on specific layer, it will overwrite is already be
1117 * the rule cfg object
1119 * layer of the protocol header.
1121 * protocol header type.
1127 int avf_fdir_rcfg_set_hdr (struct avf_fdir_conf *rcfg, int layer,
1128 enum virtchnl_proto_hdr_type hdr);
1131 * Set a match field on specific protocol layer, if any match field already be
1132 * set on this layer, it will be overwritten.
1135 * the rule cfg object
1137 * layer of the protocol header.
1147 int avf_fdir_rcfg_set_field (struct avf_fdir_conf *rcfg, int layer,
1148 struct avf_flow_item *item,
1149 struct avf_flow_error *error);
1152 * Set action as to queue(group), conflict with drop action.
1159 * queue group size, must be 2^n. 1 means only to single queue.
1167 int avf_fdir_rcfg_act_queue (struct avf_fdir_conf *rcfg, int queue, int size,
1171 * Set action as to queue group, conflict with drop action.
1174 * the rule cfg object
1186 int avf_fdir_parse_action_qregion (struct avf_fdir_conf *rcfg,
1187 const struct avf_flow_action *act,
1188 int act_idx, struct avf_flow_error *error);
1191 * Set action as as drop, conflict with to queue(gropu) action.
1194 * the rule cfg object
1202 int avf_fdir_rcfg_act_drop (struct avf_fdir_conf *rcfg, int act_idx);
1205 * Set action as mark, it can co-exist with to queue(group) or drop action.
1208 * the rule cfg object
1210 * a 32 bit flow mark
1218 int avf_fdir_rcfg_act_mark (struct avf_fdir_conf *rcfg, const u32 mark,
1222 * Validate a flow rule cfg, check with PF driver if the rule cfg is supportted
1226 * virtual channel context
1228 * the rule cfg object.
1234 int avf_fdir_rcfg_validate (struct avf_flow_vc_ctx *ctx,
1235 struct avf_fdir_conf *rcfg);
1238 * Create a flow rule, a FDIR rule is expected to be programmed into hardware
1242 * virtual channel context
1250 int avf_fdir_rule_create (struct avf_flow_vc_ctx *ctx,
1251 struct avf_fdir_conf *rcfg);
1254 * Destroy a flow rule.
1257 * virtual channel context
1259 * the rule cfg object.
1265 int avf_fdir_rule_destroy (struct avf_flow_vc_ctx *ctx,
1266 struct avf_fdir_conf *rcfg);
1269 * Parse avf patterns and set pattern fields.
1282 int avf_fdir_parse_pattern (struct avf_fdir_conf *rcfg,
1283 struct avf_flow_item avf_items[],
1284 struct avf_flow_error *error);
1287 * Parse avf patterns for generic flow and set pattern fields.
1300 int avf_fdir_parse_generic_pattern (struct avf_fdir_conf *rcfg,
1301 struct avf_flow_item avf_items[],
1302 struct avf_flow_error *error);
1305 * Parse flow actions, set actions.
1318 int avf_fdir_parse_action (const struct avf_flow_action actions[],
1319 struct avf_fdir_conf *rcfg,
1320 struct avf_flow_error *error);
1323 * Parse flow patterns and rss actions, set rss config.
1327 * @param avf_actions
1338 int avf_rss_parse_pattern_action (struct avf_flow_item avf_items[],
1339 struct avf_flow_action avf_actions[],
1340 struct virtchnl_rss_cfg *rss_cfg,
1341 struct avf_flow_error *error);
1344 * Create a RSS rule cfg object.
1347 * created rule cfg object.
1349 * tunnel level where protocol header start from
1350 * 0 from moster outer layer.
1351 * 1 from first inner layer.
1352 * 2 form second inner layer.
1353 * Must be 0 for generic flow.
1359 int avf_rss_cfg_create (struct virtchnl_rss_cfg **rss_cfg, int tunnel_level);
1361 int avf_rss_rcfg_destroy (struct virtchnl_rss_cfg *rss_cfg);
1364 * Create a RSS flow rule
1367 * virtual channel context
1375 int avf_rss_rule_create (struct avf_flow_vc_ctx *ctx,
1376 struct virtchnl_rss_cfg *rss_cfg);
1379 * Destroy a RSS flow rule
1382 * virtual channel context
1390 int avf_rss_rule_destroy (struct avf_flow_vc_ctx *ctx,
1391 struct virtchnl_rss_cfg *rss_cfg);
1394 * Parse generic flow pattern to get spec and mask
1405 void avf_parse_generic_pattern (struct avf_flow_item *item, u8 *pkt_buf,
1406 u8 *msk_buf, u16 spec_len);
1409 * Initialize flow error structure.
1412 * Pointer to flow error structure (may be NULL).
1414 * Related error code
1416 * Cause field and error types.
1418 * Object responsible for the error.
1420 * Human-readable error message.
1423 * Negative error code (errno value)
1425 int avf_flow_error_set (struct avf_flow_error *error, int code,
1426 enum avf_flow_error_type type, const void *cause,
1427 const char *message);
1430 * decode the error number to Verbose error string
1436 * Verbose error string
1438 char *avf_fdir_prgm_error_decode (int err_no);
1440 #endif /* _AVF_ADVANCED_FLOW_H_ */
1443 * fd.io coding-style-patch-verification: ON
1446 * eval: (c-set-style "gnu")