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 _ (60, AVF_ETH_RSS_L4_DST_ONLY, "l4-dst-only") \
252 _ (61, AVF_ETH_RSS_L4_SRC_ONLY, "l4-src-only") \
253 _ (62, AVF_ETH_RSS_L3_DST_ONLY, "l3-dst-only") \
254 _ (63, AVF_ETH_RSS_L3_SRC_ONLY, "l3-src-only")
256 /* Protocol header type within a packet segment. A segment consists of one or
257 * more protocol headers that make up a logical group of protocol headers. Each
258 * logical group of protocol headers encapsulates or is encapsulated using/by
259 * tunneling or encapsulation protocols for network virtualization.
261 enum virtchnl_proto_hdr_type
263 VIRTCHNL_PROTO_HDR_NONE,
264 VIRTCHNL_PROTO_HDR_ETH,
265 VIRTCHNL_PROTO_HDR_S_VLAN,
266 VIRTCHNL_PROTO_HDR_C_VLAN,
267 VIRTCHNL_PROTO_HDR_IPV4,
268 VIRTCHNL_PROTO_HDR_IPV6,
269 VIRTCHNL_PROTO_HDR_TCP,
270 VIRTCHNL_PROTO_HDR_UDP,
271 VIRTCHNL_PROTO_HDR_SCTP,
272 VIRTCHNL_PROTO_HDR_GTPU_IP,
273 VIRTCHNL_PROTO_HDR_GTPU_EH,
274 VIRTCHNL_PROTO_HDR_GTPU_EH_PDU_DWN,
275 VIRTCHNL_PROTO_HDR_GTPU_EH_PDU_UP,
276 VIRTCHNL_PROTO_HDR_PPPOE,
277 VIRTCHNL_PROTO_HDR_L2TPV3,
278 VIRTCHNL_PROTO_HDR_ESP,
279 VIRTCHNL_PROTO_HDR_AH,
280 VIRTCHNL_PROTO_HDR_PFCP,
281 VIRTCHNL_PROTO_HDR_GTPC,
282 VIRTCHNL_PROTO_HDR_ECPRI,
283 VIRTCHNL_PROTO_HDR_L2TPV2,
284 VIRTCHNL_PROTO_HDR_PPP,
285 /* IPv4 and IPv6 Fragment header types are only associated to
286 * VIRTCHNL_PROTO_HDR_IPV4 and VIRTCHNL_PROTO_HDR_IPV6 respectively,
287 * cannot be used independently.
289 VIRTCHNL_PROTO_HDR_IPV4_FRAG,
290 VIRTCHNL_PROTO_HDR_IPV6_EH_FRAG,
291 VIRTCHNL_PROTO_HDR_GRE,
294 /* Protocol header field within a protocol header. */
295 enum virtchnl_proto_hdr_field
298 VIRTCHNL_PROTO_HDR_ETH_SRC = PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_ETH),
299 VIRTCHNL_PROTO_HDR_ETH_DST,
300 VIRTCHNL_PROTO_HDR_ETH_ETHERTYPE,
302 VIRTCHNL_PROTO_HDR_S_VLAN_ID =
303 PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_S_VLAN),
305 VIRTCHNL_PROTO_HDR_C_VLAN_ID =
306 PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_C_VLAN),
308 VIRTCHNL_PROTO_HDR_IPV4_SRC =
309 PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_IPV4),
310 VIRTCHNL_PROTO_HDR_IPV4_DST,
311 VIRTCHNL_PROTO_HDR_IPV4_DSCP,
312 VIRTCHNL_PROTO_HDR_IPV4_TTL,
313 VIRTCHNL_PROTO_HDR_IPV4_PROT,
314 VIRTCHNL_PROTO_HDR_IPV4_CHKSUM,
316 VIRTCHNL_PROTO_HDR_IPV6_SRC =
317 PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_IPV6),
318 VIRTCHNL_PROTO_HDR_IPV6_DST,
319 VIRTCHNL_PROTO_HDR_IPV6_TC,
320 VIRTCHNL_PROTO_HDR_IPV6_HOP_LIMIT,
321 VIRTCHNL_PROTO_HDR_IPV6_PROT,
323 VIRTCHNL_PROTO_HDR_IPV6_PREFIX32_SRC,
324 VIRTCHNL_PROTO_HDR_IPV6_PREFIX32_DST,
325 VIRTCHNL_PROTO_HDR_IPV6_PREFIX40_SRC,
326 VIRTCHNL_PROTO_HDR_IPV6_PREFIX40_DST,
327 VIRTCHNL_PROTO_HDR_IPV6_PREFIX48_SRC,
328 VIRTCHNL_PROTO_HDR_IPV6_PREFIX48_DST,
329 VIRTCHNL_PROTO_HDR_IPV6_PREFIX56_SRC,
330 VIRTCHNL_PROTO_HDR_IPV6_PREFIX56_DST,
331 VIRTCHNL_PROTO_HDR_IPV6_PREFIX64_SRC,
332 VIRTCHNL_PROTO_HDR_IPV6_PREFIX64_DST,
333 VIRTCHNL_PROTO_HDR_IPV6_PREFIX96_SRC,
334 VIRTCHNL_PROTO_HDR_IPV6_PREFIX96_DST,
336 VIRTCHNL_PROTO_HDR_TCP_SRC_PORT =
337 PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_TCP),
338 VIRTCHNL_PROTO_HDR_TCP_DST_PORT,
339 VIRTCHNL_PROTO_HDR_TCP_CHKSUM,
341 VIRTCHNL_PROTO_HDR_UDP_SRC_PORT =
342 PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_UDP),
343 VIRTCHNL_PROTO_HDR_UDP_DST_PORT,
344 VIRTCHNL_PROTO_HDR_UDP_CHKSUM,
346 VIRTCHNL_PROTO_HDR_SCTP_SRC_PORT =
347 PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_SCTP),
348 VIRTCHNL_PROTO_HDR_SCTP_DST_PORT,
349 VIRTCHNL_PROTO_HDR_SCTP_CHKSUM,
351 VIRTCHNL_PROTO_HDR_GTPU_IP_TEID =
352 PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_GTPU_IP),
354 VIRTCHNL_PROTO_HDR_GTPU_EH_PDU =
355 PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_GTPU_EH),
356 VIRTCHNL_PROTO_HDR_GTPU_EH_QFI,
358 VIRTCHNL_PROTO_HDR_PPPOE_SESS_ID =
359 PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_PPPOE),
361 VIRTCHNL_PROTO_HDR_L2TPV3_SESS_ID =
362 PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_L2TPV3),
364 VIRTCHNL_PROTO_HDR_ESP_SPI = PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_ESP),
366 VIRTCHNL_PROTO_HDR_AH_SPI = PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_AH),
368 VIRTCHNL_PROTO_HDR_PFCP_S_FIELD =
369 PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_PFCP),
370 VIRTCHNL_PROTO_HDR_PFCP_SEID,
372 VIRTCHNL_PROTO_HDR_GTPC_TEID =
373 PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_GTPC),
375 VIRTCHNL_PROTO_HDR_ECPRI_MSG_TYPE =
376 PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_ECPRI),
377 VIRTCHNL_PROTO_HDR_ECPRI_PC_RTC_ID,
378 /* IPv4 Dummy Fragment */
379 VIRTCHNL_PROTO_HDR_IPV4_FRAG_PKID =
380 PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_IPV4_FRAG),
381 /* IPv6 Extension Fragment */
382 VIRTCHNL_PROTO_HDR_IPV6_EH_FRAG_PKID =
383 PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_IPV6_EH_FRAG),
385 VIRTCHNL_PROTO_HDR_GTPU_DWN_QFI =
386 PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_GTPU_EH_PDU_DWN),
387 VIRTCHNL_PROTO_HDR_GTPU_UP_QFI =
388 PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_GTPU_EH_PDU_UP),
390 VIRTCHNL_PROTO_HDR_L2TPV2_SESS_ID =
391 PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_L2TPV2),
392 VIRTCHNL_PROTO_HDR_L2TPV2_LEN_SESS_ID,
395 struct virtchnl_proto_hdr
397 enum virtchnl_proto_hdr_type type;
398 u32 field_selector; /* a bit mask to select field for header type */
401 * binary buffer in network order for specific header type.
402 * For example, if type = VIRTCHNL_PROTO_HDR_IPV4, a IPv4
403 * header is expected to be copied into the buffer.
407 VIRTCHNL_CHECK_STRUCT_LEN (72, virtchnl_proto_hdr);
409 struct virtchnl_proto_hdrs
413 * specify where protocol header start from. Must be 0 when sending a generic
414 * packet request. 0 - from the outer layer 1 - from the first inner layer 2
415 *- from the second inner layer
420 * the proto layers must < VIRTCHNL_MAX_NUM_PROTO_HDRS.
421 * Must be 0 when sending a generic packet request.
425 struct virtchnl_proto_hdr proto_hdr[VIRTCHNL_MAX_NUM_PROTO_HDRS];
429 u8 spec[VIRTCHNL_MAX_SIZE_GEN_PACKET];
430 u8 mask[VIRTCHNL_MAX_SIZE_GEN_PACKET];
435 VIRTCHNL_CHECK_STRUCT_LEN (2312, virtchnl_proto_hdrs);
437 /* VIRTCHNL_OP_CONFIG_RSS_KEY
438 * VIRTCHNL_OP_CONFIG_RSS_LUT
439 * VF sends these messages to configure RSS. Only supported if both PF
440 * and VF drivers set the VIRTCHNL_VF_OFFLOAD_RSS_PF bit during
441 * configuration negotiation. If this is the case, then the RSS fields in
442 * the VF resource struct are valid.
443 * Both the key and LUT are initialized to 0 by the PF, meaning that
444 * RSS is effectively disabled until set up by the VF.
446 struct virtchnl_rss_key
450 u8 key[1]; /* RSS hash key, packed bytes */
453 VIRTCHNL_CHECK_STRUCT_LEN (6, virtchnl_rss_key);
455 struct virtchnl_rss_lut
459 u8 lut[1]; /* RSS lookup table */
462 VIRTCHNL_CHECK_STRUCT_LEN (6, virtchnl_rss_lut);
464 /* VIRTCHNL_OP_GET_RSS_HENA_CAPS
465 * VIRTCHNL_OP_SET_RSS_HENA
466 * VF sends these messages to get and set the hash filter enable bits for RSS.
467 * By default, the PF sets these to all possible traffic types that the
468 * hardware supports. The VF can query this value if it wants to change the
469 * traffic types that are hashed by the hardware.
471 struct virtchnl_rss_hena
476 VIRTCHNL_CHECK_STRUCT_LEN (8, virtchnl_rss_hena);
478 /* Type of RSS algorithm */
479 enum virtchnl_rss_algorithm
481 VIRTCHNL_RSS_ALG_TOEPLITZ_ASYMMETRIC = 0,
482 VIRTCHNL_RSS_ALG_XOR_ASYMMETRIC = 1,
483 VIRTCHNL_RSS_ALG_TOEPLITZ_SYMMETRIC = 2,
484 VIRTCHNL_RSS_ALG_XOR_SYMMETRIC = 3,
487 struct virtchnl_rss_cfg
489 struct virtchnl_proto_hdrs proto_hdrs; /* protocol headers */
490 enum virtchnl_rss_algorithm rss_algorithm; /* rss algorithm type */
491 u8 reserved[128]; /* reserve for future */
494 VIRTCHNL_CHECK_STRUCT_LEN (2444, virtchnl_rss_cfg);
496 struct avf_pattern_match_item
498 enum avf_flow_item_type *pattern_list;
503 enum avf_flow_item_type
505 AVF_FLOW_ITEM_TYPE_END,
506 AVF_FLOW_ITEM_TYPE_VOID,
507 AVF_FLOW_ITEM_TYPE_INVERT,
508 AVF_FLOW_ITEM_TYPE_ANY,
509 AVF_FLOW_ITEM_TYPE_PORT_ID,
510 AVF_FLOW_ITEM_TYPE_RAW,
511 AVF_FLOW_ITEM_TYPE_ETH,
512 AVF_FLOW_ITEM_TYPE_VLAN,
513 AVF_FLOW_ITEM_TYPE_IPV4,
514 AVF_FLOW_ITEM_TYPE_IPV6,
515 AVF_FLOW_ITEM_TYPE_ICMP,
516 AVF_FLOW_ITEM_TYPE_UDP,
517 AVF_FLOW_ITEM_TYPE_TCP,
518 AVF_FLOW_ITEM_TYPE_SCTP,
519 AVF_FLOW_ITEM_TYPE_VXLAN,
520 AVF_FLOW_ITEM_TYPE_E_TAG,
521 AVF_FLOW_ITEM_TYPE_NVGRE,
522 AVF_FLOW_ITEM_TYPE_MPLS,
523 AVF_FLOW_ITEM_TYPE_GRE,
524 AVF_FLOW_ITEM_TYPE_FUZZY,
525 AVF_FLOW_ITEM_TYPE_GTP,
526 AVF_FLOW_ITEM_TYPE_GTPC,
527 AVF_FLOW_ITEM_TYPE_GTPU,
528 AVF_FLOW_ITEM_TYPE_ESP,
529 AVF_FLOW_ITEM_TYPE_GENEVE,
530 AVF_FLOW_ITEM_TYPE_VXLAN_GPE,
531 AVF_FLOW_ITEM_TYPE_ARP_ETH_IPV4,
532 AVF_FLOW_ITEM_TYPE_IPV6_EXT,
533 AVF_FLOW_ITEM_TYPE_ICMP6,
534 AVF_FLOW_ITEM_TYPE_ICMP6_ND_NS,
535 AVF_FLOW_ITEM_TYPE_ICMP6_ND_NA,
536 AVF_FLOW_ITEM_TYPE_ICMP6_ND_OPT,
537 AVF_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH,
538 AVF_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH,
539 AVF_FLOW_ITEM_TYPE_MARK,
540 AVF_FLOW_ITEM_TYPE_META,
541 AVF_FLOW_ITEM_TYPE_GRE_KEY,
542 AVF_FLOW_ITEM_TYPE_GTP_PSC,
543 AVF_FLOW_ITEM_TYPE_PPPOES,
544 AVF_FLOW_ITEM_TYPE_PPPOED,
545 AVF_FLOW_ITEM_TYPE_PPPOE_PROTO_ID,
546 AVF_FLOW_ITEM_TYPE_NSH,
547 AVF_FLOW_ITEM_TYPE_IGMP,
548 AVF_FLOW_ITEM_TYPE_AH,
549 AVF_FLOW_ITEM_TYPE_HIGIG2,
550 AVF_FLOW_ITEM_TYPE_TAG,
551 AVF_FLOW_ITEM_TYPE_L2TPV3OIP,
552 AVF_FLOW_ITEM_TYPE_PFCP,
553 AVF_FLOW_ITEM_TYPE_ECPRI,
554 AVF_FLOW_ITEM_TYPE_IPV6_FRAG_EXT,
555 AVF_FLOW_ITEM_TYPE_GENEVE_OPT,
556 AVF_FLOW_ITEM_TYPE_INTEGRITY,
557 AVF_FLOW_ITEM_TYPE_CONNTRACK,
558 AVF_FLOW_ITEM_TYPE_PORT_REPRESENTOR,
559 AVF_FLOW_ITEM_TYPE_REPRESENTED_PORT,
560 AVF_FLOW_ITEM_TYPE_FLEX,
561 AVF_FLOW_ITEM_TYPE_L2TPV2,
562 AVF_FLOW_ITEM_TYPE_PPP,
563 AVF_FLOW_ITEM_TYPE_GRE_OPTION,
564 AVF_FLOW_ITEM_TYPE_MACSEC,
565 AVF_FLOW_ITEM_TYPE_METER_COLOR,
568 enum avf_flow_action_type
570 AVF_FLOW_ACTION_TYPE_END,
571 AVF_FLOW_ACTION_TYPE_VOID,
572 AVF_FLOW_ACTION_TYPE_PASSTHRU,
573 AVF_FLOW_ACTION_TYPE_JUMP,
574 AVF_FLOW_ACTION_TYPE_MARK,
575 AVF_FLOW_ACTION_TYPE_FLAG,
576 AVF_FLOW_ACTION_TYPE_QUEUE,
577 AVF_FLOW_ACTION_TYPE_DROP,
578 AVF_FLOW_ACTION_TYPE_COUNT,
579 AVF_FLOW_ACTION_TYPE_RSS,
580 AVF_FLOW_ACTION_TYPE_PF,
581 AVF_FLOW_ACTION_TYPE_VF,
582 AVF_FLOW_ACTION_TYPE_PORT_ID,
583 AVF_FLOW_ACTION_TYPE_METER,
584 AVF_FLOW_ACTION_TYPE_SECURITY,
585 AVF_FLOW_ACTION_TYPE_OF_DEC_NW_TTL,
586 AVF_FLOW_ACTION_TYPE_OF_POP_VLAN,
587 AVF_FLOW_ACTION_TYPE_OF_PUSH_VLAN,
588 AVF_FLOW_ACTION_TYPE_OF_SET_VLAN_VID,
589 AVF_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP,
590 AVF_FLOW_ACTION_TYPE_OF_POP_MPLS,
591 AVF_FLOW_ACTION_TYPE_OF_PUSH_MPLS,
592 AVF_FLOW_ACTION_TYPE_VXLAN_ENCAP,
593 AVF_FLOW_ACTION_TYPE_VXLAN_DECAP,
594 AVF_FLOW_ACTION_TYPE_NVGRE_ENCAP,
595 AVF_FLOW_ACTION_TYPE_NVGRE_DECAP,
596 AVF_FLOW_ACTION_TYPE_RAW_ENCAP,
597 AVF_FLOW_ACTION_TYPE_RAW_DECAP,
598 AVF_FLOW_ACTION_TYPE_SET_IPV4_SRC,
599 AVF_FLOW_ACTION_TYPE_SET_IPV4_DST,
600 AVF_FLOW_ACTION_TYPE_SET_IPV6_SRC,
601 AVF_FLOW_ACTION_TYPE_SET_IPV6_DST,
602 AVF_FLOW_ACTION_TYPE_SET_TP_SRC,
603 AVF_FLOW_ACTION_TYPE_SET_TP_DST,
604 AVF_FLOW_ACTION_TYPE_MAC_SWAP,
605 AVF_FLOW_ACTION_TYPE_DEC_TTL,
606 AVF_FLOW_ACTION_TYPE_SET_TTL,
607 AVF_FLOW_ACTION_TYPE_SET_MAC_SRC,
608 AVF_FLOW_ACTION_TYPE_SET_MAC_DST,
609 AVF_FLOW_ACTION_TYPE_INC_TCP_SEQ,
610 AVF_FLOW_ACTION_TYPE_DEC_TCP_SEQ,
611 AVF_FLOW_ACTION_TYPE_INC_TCP_ACK,
612 AVF_FLOW_ACTION_TYPE_DEC_TCP_ACK,
613 AVF_FLOW_ACTION_TYPE_SET_TAG,
614 AVF_FLOW_ACTION_TYPE_SET_META,
615 AVF_FLOW_ACTION_TYPE_SET_IPV4_DSCP,
616 AVF_FLOW_ACTION_TYPE_SET_IPV6_DSCP,
617 AVF_FLOW_ACTION_TYPE_AGE,
618 AVF_FLOW_ACTION_TYPE_SAMPLE,
619 AVF_FLOW_ACTION_TYPE_SHARED,
620 AVF_FLOW_ACTION_TYPE_MODIFY_FIELD,
621 AVF_FLOW_ACTION_TYPE_INDIRECT,
622 AVF_FLOW_ACTION_TYPE_CONNTRACK,
623 AVF_FLOW_ACTION_TYPE_METER_COLOR,
624 AVF_FLOW_ACTION_TYPE_PORT_REPRESENTOR,
625 AVF_FLOW_ACTION_TYPE_REPRESENTED_PORT,
626 AVF_FLOW_ACTION_TYPE_METER_MARK,
627 AVF_FLOW_ACTION_TYPE_SEND_TO_KERNEL,
633 VIRTCHNL_ACTION_DROP = 0,
634 VIRTCHNL_ACTION_TC_REDIRECT,
635 VIRTCHNL_ACTION_PASSTHRU,
636 VIRTCHNL_ACTION_QUEUE,
637 VIRTCHNL_ACTION_Q_REGION,
638 VIRTCHNL_ACTION_MARK,
639 VIRTCHNL_ACTION_COUNT,
640 VIRTCHNL_ACTION_NONE,
643 /* action configuration for FDIR */
644 struct virtchnl_filter_action
646 enum virtchnl_action type;
649 /* used for queue and qgroup action */
655 /* used for count action */
658 /* share counter ID with other flow rules */
660 u32 id; /* counter ID */
662 /* used for mark action */
668 VIRTCHNL_CHECK_STRUCT_LEN (36, virtchnl_filter_action);
670 #define VIRTCHNL_MAX_NUM_ACTIONS 8
672 struct virtchnl_filter_action_set
674 /* action number must be less then VIRTCHNL_MAX_NUM_ACTIONS */
676 struct virtchnl_filter_action actions[VIRTCHNL_MAX_NUM_ACTIONS];
679 VIRTCHNL_CHECK_STRUCT_LEN (292, virtchnl_filter_action_set);
681 /* pattern and action for FDIR rule */
682 struct virtchnl_fdir_rule
684 struct virtchnl_proto_hdrs proto_hdrs;
685 struct virtchnl_filter_action_set action_set;
688 VIRTCHNL_CHECK_STRUCT_LEN (2604, virtchnl_fdir_rule);
690 /* query information to retrieve fdir rule counters.
691 * PF will fill out this structure to reset counter.
693 struct virtchnl_fdir_query_info
695 u32 match_packets_valid : 1;
696 u32 match_bytes_valid : 1;
697 u32 reserved : 30; /* Reserved, must be zero. */
699 u64 matched_packets; /* Number of packets for this rule. */
700 u64 matched_bytes; /* Number of bytes through this rule. */
703 VIRTCHNL_CHECK_STRUCT_LEN (24, virtchnl_fdir_query_info);
705 /* Status returned to VF after VF requests FDIR commands
706 * VIRTCHNL_FDIR_SUCCESS
707 * VF FDIR related request is successfully done by PF
708 * The request can be OP_ADD/DEL/QUERY_FDIR_FILTER.
710 * VIRTCHNL_FDIR_FAILURE_RULE_NORESOURCE
711 * OP_ADD_FDIR_FILTER request is failed due to no Hardware resource.
713 * VIRTCHNL_FDIR_FAILURE_RULE_EXIST
714 * OP_ADD_FDIR_FILTER request is failed due to the rule is already existed.
716 * VIRTCHNL_FDIR_FAILURE_RULE_CONFLICT
717 * OP_ADD_FDIR_FILTER request is failed due to conflict with existing rule.
719 * VIRTCHNL_FDIR_FAILURE_RULE_NONEXIST
720 * OP_DEL_FDIR_FILTER request is failed due to this rule doesn't exist.
722 * VIRTCHNL_FDIR_FAILURE_RULE_INVALID
723 * OP_ADD_FDIR_FILTER request is failed due to parameters validation
724 * or HW doesn't support.
726 * VIRTCHNL_FDIR_FAILURE_RULE_TIMEOUT
727 * OP_ADD/DEL_FDIR_FILTER request is failed due to timing out
730 * VIRTCHNL_FDIR_FAILURE_QUERY_INVALID
731 * OP_QUERY_FDIR_FILTER request is failed due to parameters validation,
732 * for example, VF query counter of a rule who has no counter action.
734 enum virtchnl_fdir_prgm_status
736 VIRTCHNL_FDIR_SUCCESS = 0,
737 VIRTCHNL_FDIR_FAILURE_RULE_NORESOURCE,
738 VIRTCHNL_FDIR_FAILURE_RULE_EXIST,
739 VIRTCHNL_FDIR_FAILURE_RULE_CONFLICT,
740 VIRTCHNL_FDIR_FAILURE_RULE_NONEXIST,
741 VIRTCHNL_FDIR_FAILURE_RULE_INVALID,
742 VIRTCHNL_FDIR_FAILURE_RULE_TIMEOUT,
743 VIRTCHNL_FDIR_FAILURE_QUERY_INVALID,
744 VIRTCHNL_FDIR_FAILURE_MAX,
747 /* VIRTCHNL_OP_ADD_FDIR_FILTER
748 * VF sends this request to PF by filling out vsi_id,
749 * validate_only and rule_cfg. PF will return flow_id
750 * if the request is successfully done and return add_status to VF.
752 struct virtchnl_fdir_add
754 u16 vsi_id; /* INPUT */
756 * 1 for validating a fdir rule, 0 for creating a fdir rule.
757 * Validate and create share one ops: VIRTCHNL_OP_ADD_FDIR_FILTER.
759 u16 validate_only; /* INPUT */
760 u32 flow_id; /* OUTPUT */
761 struct virtchnl_fdir_rule rule_cfg; /* INPUT */
762 enum virtchnl_fdir_prgm_status status; /* OUTPUT */
765 VIRTCHNL_CHECK_STRUCT_LEN (2616, virtchnl_fdir_add);
767 /* VIRTCHNL_OP_DEL_FDIR_FILTER
768 * VF sends this request to PF by filling out vsi_id
769 * and flow_id. PF will return del_status to VF.
771 struct virtchnl_fdir_del
773 u16 vsi_id; /* INPUT */
775 u32 flow_id; /* INPUT */
776 enum virtchnl_fdir_prgm_status status; /* OUTPUT */
779 VIRTCHNL_CHECK_STRUCT_LEN (12, virtchnl_fdir_del);
781 /* VIRTCHNL_OP_QUERY_FDIR_FILTER
782 * VF sends this request to PF by filling out vsi_id,
783 * flow_id and reset_counter. PF will return query_info
784 * and query_status to VF.
786 struct virtchnl_fdir_query
788 u16 vsi_id; /* INPUT */
790 u32 flow_id; /* INPUT */
791 u32 reset_counter : 1; /* INPUT */
792 struct virtchnl_fdir_query_info query_info; /* OUTPUT */
793 enum virtchnl_fdir_prgm_status status; /* OUTPUT */
797 VIRTCHNL_CHECK_STRUCT_LEN (48, virtchnl_fdir_query);
800 * Those headers used temporary, maybe OS packet
801 * definition can replace. Add flow error, pattern
802 * and action definition.
806 * Verbose error types.
808 * Most of them provide the type of the object referenced by struct
809 * rte_flow_error.cause.
811 enum avf_flow_error_type
813 AVF_FLOW_ERROR_TYPE_NONE, /**< No error. */
814 AVF_FLOW_ERROR_TYPE_UNSPECIFIED, /**< Cause unspecified. */
815 AVF_FLOW_ERROR_TYPE_HANDLE, /**< Flow rule (handle). */
816 AVF_FLOW_ERROR_TYPE_ATTR_GROUP, /**< Group field. */
817 AVF_FLOW_ERROR_TYPE_ATTR_PRIORITY, /**< Priority field. */
818 AVF_FLOW_ERROR_TYPE_ATTR_INGRESS, /**< Ingress field. */
819 AVF_FLOW_ERROR_TYPE_ATTR_EGRESS, /**< Egress field. */
820 AVF_FLOW_ERROR_TYPE_ATTR_TRANSFER, /**< Transfer field. */
821 AVF_FLOW_ERROR_TYPE_ATTR, /**< Attributes structure. */
822 AVF_FLOW_ERROR_TYPE_ITEM_NUM, /**< Pattern length. */
823 AVF_FLOW_ERROR_TYPE_ITEM_SPEC, /**< Item specification. */
824 AVF_FLOW_ERROR_TYPE_ITEM_LAST, /**< Item specification range. */
825 AVF_FLOW_ERROR_TYPE_ITEM_MASK, /**< Item specification mask. */
826 AVF_FLOW_ERROR_TYPE_ITEM, /**< Specific pattern item. */
827 AVF_FLOW_ERROR_TYPE_ACTION_NUM, /**< Number of actions. */
828 AVF_FLOW_ERROR_TYPE_ACTION_CONF, /**< Action configuration. */
829 AVF_FLOW_ERROR_TYPE_ACTION, /**< Specific action. */
833 * Verbose error structure definition.
834 * Both cause and message may be NULL regardless of the error type.
836 struct avf_flow_error
838 enum avf_flow_error_type type; /**< Cause field and error types. */
839 const void *cause; /**< Object responsible for the error. */
840 const char *message; /**< Human-readable error message. */
843 #define AVF_ETHER_ADDR_LEN 6
844 struct avf_ether_addr
846 u8 addr_bytes[AVF_ETHER_ADDR_LEN]; /**< Addr bytes in tx order */
847 } __attribute__ ((__aligned__ (2)));
849 struct avf_flow_eth_hdr
851 struct avf_ether_addr dst; /**< Destination MAC. */
852 struct avf_ether_addr src; /**< Source MAC. */
853 u16 type; /**< EtherType or TPID. */
861 u8 version_ihl; /**< version and header length */
862 u8 type_of_service; /**< type of service */
863 u16 total_length; /**< length of packet */
864 u16 packet_id; /**< packet ID */
865 u16 fragment_offset; /**< fragmentation offset */
866 u8 time_to_live; /**< time to live */
867 u8 next_proto_id; /**< protocol ID */
868 u16 hdr_checksum; /**< header checksum */
869 u32 src_addr; /**< source address */
870 u32 dst_addr; /**< destination address */
871 } __attribute__ ((__packed__));
878 u32 vtc_flow; /**< IP version, traffic class & flow label. */
879 u16 payload_len; /**< IP packet length - includes header size */
880 u8 proto; /**< Protocol, next header. */
881 u8 hop_limits; /**< Hop limits. */
882 u8 src_addr[16]; /**< IP address of source host. */
883 u8 dst_addr[16]; /**< IP address of destination host(s). */
884 } __attribute__ ((__packed__));
891 u16 src_port; /**< TCP source port. */
892 u16 dst_port; /**< TCP destination port. */
893 u32 sent_seq; /**< TX data sequence number. */
894 u32 recv_ack; /**< RX data acknowledgment sequence number. */
895 u8 data_off; /**< Data offset. */
896 u8 tcp_flags; /**< TCP flags */
897 u16 rx_win; /**< RX flow control window. */
898 u16 cksum; /**< TCP checksum. */
899 u16 tcp_urp; /**< TCP urgent pointer, if any. */
900 } __attribute__ ((__packed__));
907 u16 src_port; /**< UDP source port. */
908 u16 dst_port; /**< UDP destination port. */
909 u16 dgram_len; /**< UDP datagram length */
910 u16 dgram_cksum; /**< UDP datagram checksum */
911 } __attribute__ ((__packed__));
914 * Match IP Authentication Header (AH), RFC 4302
930 u32 spi; /**< Security Parameters Index */
931 u32 seq; /**< packet sequence number */
932 } __attribute__ ((__packed__));
946 * Matches a L2TPv3 over IP header.
948 struct avf_l2tpv3oip_hdr
950 u32 session_id; /**< Session ID. */
954 * Matches a GTP PDU extension header with type 0x85.
956 struct avf_gtp_psc_hdr
958 u8 pdu_type; /**< PDU type. */
959 u8 qfi; /**< QoS flow identifier. */
963 * Matches a GTPv1 header.
968 * Version (3b), protocol type (1b), reserved (1b),
969 * Extension header flag (1b),
970 * Sequence number flag (1b),
971 * N-PDU number flag (1b).
974 u8 msg_type; /**< Message type. */
975 u16 msg_len; /**< Message length. */
976 u32 teid; /**< Tunnel endpoint identifier. */
984 u16 src_port; /**< Source port. */
985 u16 dst_port; /**< Destin port. */
986 u32 tag; /**< Validation tag. */
987 u32 cksum; /**< Checksum. */
988 } __attribute__ ((__packed__));
991 * Hash function types.
993 enum avf_eth_hash_function
995 AVF_ETH_HASH_FUNCTION_DEFAULT = 0,
996 AVF_ETH_HASH_FUNCTION_TOEPLITZ, /**< Toeplitz */
997 AVF_ETH_HASH_FUNCTION_SIMPLE_XOR, /**< Simple XOR */
999 * Symmetric Toeplitz: src, dst will be replaced by
1000 * xor(src, dst). For the case with src/dst only,
1001 * src or dst address will xor with zero pair.
1003 AVF_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ,
1004 AVF_ETH_HASH_FUNCTION_MAX,
1007 struct avf_flow_action_rss
1009 enum avf_eth_hash_function func; /**< RSS hash function to apply. */
1012 u64 types; /**< Specific RSS hash types (see ETH_RSS_*). */
1013 u32 key_len; /**< Hash key length in bytes. */
1014 u32 queue_num; /**< Number of entries in @p queue. */
1015 const u8 *key; /**< Hash key. */
1016 const u16 *queue; /**< Queue indices to use. */
1019 struct avf_flow_action_queue
1021 u16 index; /**< Queue index to use. */
1024 struct avf_flow_action_mark
1026 u32 id; /**< Integer value to return with packets. */
1029 struct avf_flow_action
1031 enum avf_flow_action_type type; /**< Action type. */
1032 const void *conf; /**< Pointer to action configuration object. */
1035 struct avf_flow_item
1037 enum avf_flow_item_type type; /**< Item type. */
1038 const void *spec; /**< Pointer to item specification structure. */
1039 const void *mask; /**< Bit-mask applied to spec and last. */
1040 int is_generic; /* indicate if this item is for a generic flow pattern. */
1043 struct avf_fdir_conf
1045 struct virtchnl_fdir_add add_fltr;
1046 struct virtchnl_fdir_del del_fltr;
1054 enum virthnl_adv_ops
1056 VIRTCHNL_ADV_OP_ADD_FDIR_FILTER = 0,
1057 VIRTCHNL_ADV_OP_DEL_FDIR_FILTER,
1058 VIRTCHNL_ADV_OP_QUERY_FDIR_FILTER,
1059 VIRTCHNL_ADV_OP_ADD_RSS_CFG,
1060 VIRTCHNL_ADV_OP_DEL_RSS_CFG,
1064 /* virtual channel op handler */
1065 typedef int (*avf_flow_vc_op_t) (void *vc_hdl, enum virthnl_adv_ops vc_op,
1066 void *in, u32 in_len, void *out, u32 out_len);
1068 /* virtual channel context object */
1069 struct avf_flow_vc_ctx
1071 void *vc_hdl; /* virtual channel handler */
1072 avf_flow_vc_op_t vc_op;
1076 * Create a rule cfg object.
1079 * created rule cfg object.
1081 * tunnel level where protocol header start from
1082 * 0 from moster outer layer.
1083 * 1 from first inner layer.
1084 * 2 form second inner layer.
1090 * the rx queue number of the avf
1096 int avf_fdir_rcfg_create (struct avf_fdir_conf **rcfg, int tunnel_level,
1100 * Destroy a rule cfg object.
1103 * the cfg object to destroy.
1109 int avf_fdir_rcfg_destroy (struct avf_fdir_conf *rcfg);
1112 * Set match potocol header on specific layer, it will overwrite is already be
1116 * the rule cfg object
1118 * layer of the protocol header.
1120 * protocol header type.
1126 int avf_fdir_rcfg_set_hdr (struct avf_fdir_conf *rcfg, int layer,
1127 enum virtchnl_proto_hdr_type hdr);
1130 * Set a match field on specific protocol layer, if any match field already be
1131 * set on this layer, it will be overwritten.
1134 * the rule cfg object
1136 * layer of the protocol header.
1146 int avf_fdir_rcfg_set_field (struct avf_fdir_conf *rcfg, int layer,
1147 struct avf_flow_item *item,
1148 struct avf_flow_error *error);
1151 * Set action as to queue(group), conflict with drop action.
1158 * queue group size, must be 2^n. 1 means only to single queue.
1166 int avf_fdir_rcfg_act_queue (struct avf_fdir_conf *rcfg, int queue, int size,
1170 * Set action as to queue group, conflict with drop action.
1173 * the rule cfg object
1185 int avf_fdir_parse_action_qregion (struct avf_fdir_conf *rcfg,
1186 const struct avf_flow_action *act,
1187 int act_idx, struct avf_flow_error *error);
1190 * Set action as as drop, conflict with to queue(gropu) action.
1193 * the rule cfg object
1201 int avf_fdir_rcfg_act_drop (struct avf_fdir_conf *rcfg, int act_idx);
1204 * Set action as mark, it can co-exist with to queue(group) or drop action.
1207 * the rule cfg object
1209 * a 32 bit flow mark
1217 int avf_fdir_rcfg_act_mark (struct avf_fdir_conf *rcfg, const u32 mark,
1221 * Validate a flow rule cfg, check with PF driver if the rule cfg is supportted
1225 * virtual channel context
1227 * the rule cfg object.
1233 int avf_fdir_rcfg_validate (struct avf_flow_vc_ctx *ctx,
1234 struct avf_fdir_conf *rcfg);
1237 * Create a flow rule, a FDIR rule is expected to be programmed into hardware
1241 * virtual channel context
1249 int avf_fdir_rule_create (struct avf_flow_vc_ctx *ctx,
1250 struct avf_fdir_conf *rcfg);
1253 * Destroy a flow rule.
1256 * virtual channel context
1258 * the rule cfg object.
1264 int avf_fdir_rule_destroy (struct avf_flow_vc_ctx *ctx,
1265 struct avf_fdir_conf *rcfg);
1268 * Parse avf patterns and set pattern fields.
1281 int avf_fdir_parse_pattern (struct avf_fdir_conf *rcfg,
1282 struct avf_flow_item avf_items[],
1283 struct avf_flow_error *error);
1286 * Parse avf patterns for generic flow and set pattern fields.
1299 int avf_fdir_parse_generic_pattern (struct avf_fdir_conf *rcfg,
1300 struct avf_flow_item avf_items[],
1301 struct avf_flow_error *error);
1304 * Parse flow actions, set actions.
1317 int avf_fdir_parse_action (const struct avf_flow_action actions[],
1318 struct avf_fdir_conf *rcfg,
1319 struct avf_flow_error *error);
1322 * Parse flow patterns and rss actions, set rss config.
1326 * @param avf_actions
1337 int avf_rss_parse_pattern_action (struct avf_flow_item avf_items[],
1338 struct avf_flow_action avf_actions[],
1339 struct virtchnl_rss_cfg *rss_cfg,
1340 struct avf_flow_error *error);
1343 * Create a RSS rule cfg object.
1346 * created rule cfg object.
1348 * tunnel level where protocol header start from
1349 * 0 from moster outer layer.
1350 * 1 from first inner layer.
1351 * 2 form second inner layer.
1352 * Must be 0 for generic flow.
1358 int avf_rss_cfg_create (struct virtchnl_rss_cfg **rss_cfg, int tunnel_level);
1360 int avf_rss_rcfg_destroy (struct virtchnl_rss_cfg *rss_cfg);
1363 * Create a RSS flow rule
1366 * virtual channel context
1374 int avf_rss_rule_create (struct avf_flow_vc_ctx *ctx,
1375 struct virtchnl_rss_cfg *rss_cfg);
1378 * Destroy a RSS flow rule
1381 * virtual channel context
1389 int avf_rss_rule_destroy (struct avf_flow_vc_ctx *ctx,
1390 struct virtchnl_rss_cfg *rss_cfg);
1393 * Parse generic flow pattern to get spec and mask
1404 void avf_parse_generic_pattern (struct avf_flow_item *item, u8 *pkt_buf,
1405 u8 *msk_buf, u16 spec_len);
1408 * Initialize flow error structure.
1411 * Pointer to flow error structure (may be NULL).
1413 * Related error code
1415 * Cause field and error types.
1417 * Object responsible for the error.
1419 * Human-readable error message.
1422 * Negative error code (errno value)
1424 int avf_flow_error_set (struct avf_flow_error *error, int code,
1425 enum avf_flow_error_type type, const void *cause,
1426 const char *message);
1429 * decode the error number to Verbose error string
1435 * Verbose error string
1437 char *avf_fdir_prgm_error_decode (int err_no);
1439 #endif /* _AVF_ADVANCED_FLOW_H_ */
1442 * fd.io coding-style-patch-verification: ON
1445 * eval: (c-set-style "gnu")