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 PROTO_HDR_SHIFT 5
49 #define PROTO_HDR_FIELD_START(proto_hdr_type) \
50 (proto_hdr_type << PROTO_HDR_SHIFT)
51 #define PROTO_HDR_FIELD_MASK ((1UL << PROTO_HDR_SHIFT) - 1)
53 /* VF use these macros to configure each protocol header.
54 * Specify which protocol headers and protocol header fields base on
55 * virtchnl_proto_hdr_type and virtchnl_proto_hdr_field.
56 * @param hdr: a struct of virtchnl_proto_hdr
57 * @param hdr_type: ETH/IPV4/TCP, etc
58 * @param field: SRC/DST/TEID/SPI, etc
60 #define VIRTCHNL_ADD_PROTO_HDR_FIELD(hdr, field) \
61 ((hdr)->field_selector |= BIT ((field) &PROTO_HDR_FIELD_MASK))
62 #define VIRTCHNL_DEL_PROTO_HDR_FIELD(hdr, field) \
63 ((hdr)->field_selector &= ~BIT ((field) &PROTO_HDR_FIELD_MASK))
64 #define VIRTCHNL_TEST_PROTO_HDR_FIELD(hdr, val) \
65 ((hdr)->field_selector & BIT ((val) &PROTO_HDR_FIELD_MASK))
66 #define VIRTCHNL_GET_PROTO_HDR_FIELD(hdr) ((hdr)->field_selector)
68 #define VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, hdr_type, field) \
69 (VIRTCHNL_ADD_PROTO_HDR_FIELD (hdr, VIRTCHNL_PROTO_HDR_##hdr_type##_##field))
70 #define VIRTCHNL_DEL_PROTO_HDR_FIELD_BIT(hdr, hdr_type, field) \
71 (VIRTCHNL_DEL_PROTO_HDR_FIELD (hdr, VIRTCHNL_PROTO_HDR_##hdr_type##_##field))
73 #define VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, hdr_type) \
74 ((hdr)->type = VIRTCHNL_PROTO_HDR_##hdr_type)
75 #define VIRTCHNL_GET_PROTO_HDR_TYPE(hdr) (((hdr)->type) >> PROTO_HDR_SHIFT)
76 #define VIRTCHNL_TEST_PROTO_HDR_TYPE(hdr, val) \
77 ((hdr)->type == ((val) >> PROTO_HDR_SHIFT))
78 #define VIRTCHNL_TEST_PROTO_HDR(hdr, val) \
79 (VIRTCHNL_TEST_PROTO_HDR_TYPE (hdr, val) && \
80 VIRTCHNL_TEST_PROTO_HDR_FIELD (hdr, val))
84 #define AVF_PROT_MAC_INNER (1ULL << 1)
85 #define AVF_PROT_MAC_OUTER (1ULL << 2)
86 #define AVF_PROT_VLAN_INNER (1ULL << 3)
87 #define AVF_PROT_VLAN_OUTER (1ULL << 4)
88 #define AVF_PROT_IPV4_INNER (1ULL << 5)
89 #define AVF_PROT_IPV4_OUTER (1ULL << 6)
90 #define AVF_PROT_IPV6_INNER (1ULL << 7)
91 #define AVF_PROT_IPV6_OUTER (1ULL << 8)
92 #define AVF_PROT_TCP_INNER (1ULL << 9)
93 #define AVF_PROT_TCP_OUTER (1ULL << 10)
94 #define AVF_PROT_UDP_INNER (1ULL << 11)
95 #define AVF_PROT_UDP_OUTER (1ULL << 12)
96 #define AVF_PROT_SCTP_INNER (1ULL << 13)
97 #define AVF_PROT_SCTP_OUTER (1ULL << 14)
98 #define AVF_PROT_ICMP4_INNER (1ULL << 15)
99 #define AVF_PROT_ICMP4_OUTER (1ULL << 16)
100 #define AVF_PROT_ICMP6_INNER (1ULL << 17)
101 #define AVF_PROT_ICMP6_OUTER (1ULL << 18)
102 #define AVF_PROT_VXLAN (1ULL << 19)
103 #define AVF_PROT_NVGRE (1ULL << 20)
104 #define AVF_PROT_GTPU (1ULL << 21)
105 #define AVF_PROT_ESP (1ULL << 22)
106 #define AVF_PROT_AH (1ULL << 23)
107 #define AVF_PROT_L2TPV3OIP (1ULL << 24)
108 #define AVF_PROT_PFCP (1ULL << 25)
112 #define AVF_SMAC (1ULL << 63)
113 #define AVF_DMAC (1ULL << 62)
114 #define AVF_ETHERTYPE (1ULL << 61)
115 #define AVF_IP_SRC (1ULL << 60)
116 #define AVF_IP_DST (1ULL << 59)
117 #define AVF_IP_PROTO (1ULL << 58)
118 #define AVF_IP_TTL (1ULL << 57)
119 #define AVF_IP_TOS (1ULL << 56)
120 #define AVF_SPORT (1ULL << 55)
121 #define AVF_DPORT (1ULL << 54)
122 #define AVF_ICMP_TYPE (1ULL << 53)
123 #define AVF_ICMP_CODE (1ULL << 52)
124 #define AVF_VXLAN_VNI (1ULL << 51)
125 #define AVF_NVGRE_TNI (1ULL << 50)
126 #define AVF_GTPU_TEID (1ULL << 49)
127 #define AVF_GTPU_QFI (1ULL << 48)
128 #define AVF_ESP_SPI (1ULL << 47)
129 #define AVF_AH_SPI (1ULL << 46)
130 #define AVF_L2TPV3OIP_SESSION_ID (1ULL << 45)
131 #define AVF_PFCP_S_FIELD (1ULL << 44)
132 #define AVF_PFCP_SEID (1ULL << 43)
136 #define AVF_INSET_NONE 0ULL
140 #define AVF_INSET_SMAC (AVF_PROT_MAC_OUTER | AVF_SMAC)
141 #define AVF_INSET_DMAC (AVF_PROT_MAC_OUTER | AVF_DMAC)
142 #define AVF_INSET_VLAN_INNER (AVF_PROT_VLAN_INNER)
143 #define AVF_INSET_VLAN_OUTER (AVF_PROT_VLAN_OUTER)
144 #define AVF_INSET_ETHERTYPE (AVF_ETHERTYPE)
146 #define AVF_INSET_IPV4_SRC (AVF_PROT_IPV4_OUTER | AVF_IP_SRC)
147 #define AVF_INSET_IPV4_DST (AVF_PROT_IPV4_OUTER | AVF_IP_DST)
148 #define AVF_INSET_IPV4_TOS (AVF_PROT_IPV4_OUTER | AVF_IP_TOS)
149 #define AVF_INSET_IPV4_PROTO (AVF_PROT_IPV4_OUTER | AVF_IP_PROTO)
150 #define AVF_INSET_IPV4_TTL (AVF_PROT_IPV4_OUTER | AVF_IP_TTL)
151 #define AVF_INSET_IPV6_SRC (AVF_PROT_IPV6_OUTER | AVF_IP_SRC)
152 #define AVF_INSET_IPV6_DST (AVF_PROT_IPV6_OUTER | AVF_IP_DST)
153 #define AVF_INSET_IPV6_NEXT_HDR (AVF_PROT_IPV6_OUTER | AVF_IP_PROTO)
154 #define AVF_INSET_IPV6_HOP_LIMIT (AVF_PROT_IPV6_OUTER | AVF_IP_TTL)
155 #define AVF_INSET_IPV6_TC (AVF_PROT_IPV6_OUTER | AVF_IP_TOS)
157 #define AVF_INSET_TCP_SRC_PORT (AVF_PROT_TCP_OUTER | AVF_SPORT)
158 #define AVF_INSET_TCP_DST_PORT (AVF_PROT_TCP_OUTER | AVF_DPORT)
159 #define AVF_INSET_UDP_SRC_PORT (AVF_PROT_UDP_OUTER | AVF_SPORT)
160 #define AVF_INSET_UDP_DST_PORT (AVF_PROT_UDP_OUTER | AVF_DPORT)
161 #define AVF_INSET_SCTP_SRC_PORT (AVF_PROT_SCTP_OUTER | AVF_SPORT)
162 #define AVF_INSET_SCTP_DST_PORT (AVF_PROT_SCTP_OUTER | AVF_DPORT)
163 #define AVF_INSET_ICMP4_SRC_PORT (AVF_PROT_ICMP4_OUTER | AVF_SPORT)
164 #define AVF_INSET_ICMP4_DST_PORT (AVF_PROT_ICMP4_OUTER | AVF_DPORT)
165 #define AVF_INSET_ICMP6_SRC_PORT (AVF_PROT_ICMP6_OUTER | AVF_SPORT)
166 #define AVF_INSET_ICMP6_DST_PORT (AVF_PROT_ICMP6_OUTER | AVF_DPORT)
167 #define AVF_INSET_ICMP4_TYPE (AVF_PROT_ICMP4_OUTER | AVF_ICMP_TYPE)
168 #define AVF_INSET_ICMP4_CODE (AVF_PROT_ICMP4_OUTER | AVF_ICMP_CODE)
169 #define AVF_INSET_ICMP6_TYPE (AVF_PROT_ICMP6_OUTER | AVF_ICMP_TYPE)
170 #define AVF_INSET_ICMP6_CODE (AVF_PROT_ICMP6_OUTER | AVF_ICMP_CODE)
171 #define AVF_INSET_GTPU_TEID (AVF_PROT_GTPU | AVF_GTPU_TEID)
172 #define AVF_INSET_GTPU_QFI (AVF_PROT_GTPU | AVF_GTPU_QFI)
173 #define AVF_INSET_ESP_SPI (AVF_PROT_ESP | AVF_ESP_SPI)
174 #define AVF_INSET_AH_SPI (AVF_PROT_AH | AVF_AH_SPI)
175 #define AVF_INSET_L2TPV3OIP_SESSION_ID \
176 (AVF_PROT_L2TPV3OIP | AVF_L2TPV3OIP_SESSION_ID)
177 #define AVF_INSET_PFCP_S_FIELD (AVF_PROT_PFCP | AVF_PFCP_S_FIELD)
178 #define AVF_INSET_PFCP_SEID (AVF_PROT_PFCP | AVF_PFCP_S_FIELD | AVF_PFCP_SEID)
180 /* Protocol header type within a packet segment. A segment consists of one or
181 * more protocol headers that make up a logical group of protocol headers. Each
182 * logical group of protocol headers encapsulates or is encapsulated using/by
183 * tunneling or encapsulation protocols for network virtualization.
185 enum virtchnl_proto_hdr_type
187 VIRTCHNL_PROTO_HDR_NONE,
188 VIRTCHNL_PROTO_HDR_ETH,
189 VIRTCHNL_PROTO_HDR_S_VLAN,
190 VIRTCHNL_PROTO_HDR_C_VLAN,
191 VIRTCHNL_PROTO_HDR_IPV4,
192 VIRTCHNL_PROTO_HDR_IPV6,
193 VIRTCHNL_PROTO_HDR_TCP,
194 VIRTCHNL_PROTO_HDR_UDP,
195 VIRTCHNL_PROTO_HDR_SCTP,
196 VIRTCHNL_PROTO_HDR_GTPU_IP,
197 VIRTCHNL_PROTO_HDR_GTPU_EH,
198 VIRTCHNL_PROTO_HDR_GTPU_EH_PDU_DWN,
199 VIRTCHNL_PROTO_HDR_GTPU_EH_PDU_UP,
200 VIRTCHNL_PROTO_HDR_PPPOE,
201 VIRTCHNL_PROTO_HDR_L2TPV3,
202 VIRTCHNL_PROTO_HDR_ESP,
203 VIRTCHNL_PROTO_HDR_AH,
204 VIRTCHNL_PROTO_HDR_PFCP,
207 /* Protocol header field within a protocol header. */
208 enum virtchnl_proto_hdr_field
211 VIRTCHNL_PROTO_HDR_ETH_SRC = PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_ETH),
212 VIRTCHNL_PROTO_HDR_ETH_DST,
213 VIRTCHNL_PROTO_HDR_ETH_ETHERTYPE,
215 VIRTCHNL_PROTO_HDR_S_VLAN_ID =
216 PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_S_VLAN),
218 VIRTCHNL_PROTO_HDR_C_VLAN_ID =
219 PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_C_VLAN),
221 VIRTCHNL_PROTO_HDR_IPV4_SRC =
222 PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_IPV4),
223 VIRTCHNL_PROTO_HDR_IPV4_DST,
224 VIRTCHNL_PROTO_HDR_IPV4_DSCP,
225 VIRTCHNL_PROTO_HDR_IPV4_TTL,
226 VIRTCHNL_PROTO_HDR_IPV4_PROT,
228 VIRTCHNL_PROTO_HDR_IPV6_SRC =
229 PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_IPV6),
230 VIRTCHNL_PROTO_HDR_IPV6_DST,
231 VIRTCHNL_PROTO_HDR_IPV6_TC,
232 VIRTCHNL_PROTO_HDR_IPV6_HOP_LIMIT,
233 VIRTCHNL_PROTO_HDR_IPV6_PROT,
235 VIRTCHNL_PROTO_HDR_TCP_SRC_PORT =
236 PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_TCP),
237 VIRTCHNL_PROTO_HDR_TCP_DST_PORT,
239 VIRTCHNL_PROTO_HDR_UDP_SRC_PORT =
240 PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_UDP),
241 VIRTCHNL_PROTO_HDR_UDP_DST_PORT,
243 VIRTCHNL_PROTO_HDR_SCTP_SRC_PORT =
244 PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_SCTP),
245 VIRTCHNL_PROTO_HDR_SCTP_DST_PORT,
247 VIRTCHNL_PROTO_HDR_GTPU_IP_TEID =
248 PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_GTPU_IP),
250 VIRTCHNL_PROTO_HDR_GTPU_EH_PDU =
251 PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_GTPU_EH),
252 VIRTCHNL_PROTO_HDR_GTPU_EH_QFI,
254 VIRTCHNL_PROTO_HDR_PPPOE_SESS_ID =
255 PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_PPPOE),
257 VIRTCHNL_PROTO_HDR_L2TPV3_SESS_ID =
258 PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_L2TPV3),
260 VIRTCHNL_PROTO_HDR_ESP_SPI = PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_ESP),
262 VIRTCHNL_PROTO_HDR_AH_SPI = PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_AH),
264 VIRTCHNL_PROTO_HDR_PFCP_S_FIELD =
265 PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_PFCP),
266 VIRTCHNL_PROTO_HDR_PFCP_SEID,
269 struct virtchnl_proto_hdr
271 enum virtchnl_proto_hdr_type type;
272 u32 field_selector; /* a bit mask to select field for header type */
275 * binary buffer in network order for specific header type.
276 * For example, if type = VIRTCHNL_PROTO_HDR_IPV4, a IPv4
277 * header is expected to be copied into the buffer.
281 VIRTCHNL_CHECK_STRUCT_LEN (72, virtchnl_proto_hdr);
283 struct virtchnl_proto_hdrs
287 * specify where protocol header start from.
288 * 0 - from the outer layer
289 * 1 - from the first inner layer
290 * 2 - from the second inner layer
293 int count; /* the proto layers must < VIRTCHNL_MAX_NUM_PROTO_HDRS */
294 struct virtchnl_proto_hdr proto_hdr[VIRTCHNL_MAX_NUM_PROTO_HDRS];
297 VIRTCHNL_CHECK_STRUCT_LEN (2312, virtchnl_proto_hdrs);
299 /* VIRTCHNL_OP_CONFIG_RSS_KEY
300 * VIRTCHNL_OP_CONFIG_RSS_LUT
301 * VF sends these messages to configure RSS. Only supported if both PF
302 * and VF drivers set the VIRTCHNL_VF_OFFLOAD_RSS_PF bit during
303 * configuration negotiation. If this is the case, then the RSS fields in
304 * the VF resource struct are valid.
305 * Both the key and LUT are initialized to 0 by the PF, meaning that
306 * RSS is effectively disabled until set up by the VF.
308 struct virtchnl_rss_key
312 u8 key[1]; /* RSS hash key, packed bytes */
315 VIRTCHNL_CHECK_STRUCT_LEN (6, virtchnl_rss_key);
317 struct virtchnl_rss_lut
321 u8 lut[1]; /* RSS lookup table */
324 VIRTCHNL_CHECK_STRUCT_LEN (6, virtchnl_rss_lut);
326 /* VIRTCHNL_OP_GET_RSS_HENA_CAPS
327 * VIRTCHNL_OP_SET_RSS_HENA
328 * VF sends these messages to get and set the hash filter enable bits for RSS.
329 * By default, the PF sets these to all possible traffic types that the
330 * hardware supports. The VF can query this value if it wants to change the
331 * traffic types that are hashed by the hardware.
333 struct virtchnl_rss_hena
338 VIRTCHNL_CHECK_STRUCT_LEN (8, virtchnl_rss_hena);
340 /* Type of RSS algorithm */
341 enum virtchnl_rss_algorithm
343 VIRTCHNL_RSS_ALG_TOEPLITZ_ASYMMETRIC = 0,
344 VIRTCHNL_RSS_ALG_XOR_ASYMMETRIC = 1,
345 VIRTCHNL_RSS_ALG_TOEPLITZ_SYMMETRIC = 2,
346 VIRTCHNL_RSS_ALG_XOR_SYMMETRIC = 3,
349 struct virtchnl_rss_cfg
351 struct virtchnl_proto_hdrs proto_hdrs; /* protocol headers */
352 enum virtchnl_rss_algorithm rss_algorithm; /* rss algorithm type */
353 u8 reserved[128]; /* reserve for future */
356 VIRTCHNL_CHECK_STRUCT_LEN (2444, virtchnl_rss_cfg);
361 VIRTCHNL_ACTION_DROP = 0,
362 VIRTCHNL_ACTION_TC_REDIRECT,
363 VIRTCHNL_ACTION_PASSTHRU,
364 VIRTCHNL_ACTION_QUEUE,
365 VIRTCHNL_ACTION_Q_REGION,
366 VIRTCHNL_ACTION_MARK,
367 VIRTCHNL_ACTION_COUNT,
368 VIRTCHNL_ACTION_NONE,
371 /* action configuration for FDIR */
372 struct virtchnl_filter_action
374 enum virtchnl_action type;
377 /* used for queue and qgroup action */
383 /* used for count action */
386 /* share counter ID with other flow rules */
388 u32 id; /* counter ID */
390 /* used for mark action */
396 VIRTCHNL_CHECK_STRUCT_LEN (36, virtchnl_filter_action);
398 #define VIRTCHNL_MAX_NUM_ACTIONS 8
400 struct virtchnl_filter_action_set
402 /* action number must be less then VIRTCHNL_MAX_NUM_ACTIONS */
404 struct virtchnl_filter_action actions[VIRTCHNL_MAX_NUM_ACTIONS];
407 VIRTCHNL_CHECK_STRUCT_LEN (292, virtchnl_filter_action_set);
409 /* pattern and action for FDIR rule */
410 struct virtchnl_fdir_rule
412 struct virtchnl_proto_hdrs proto_hdrs;
413 struct virtchnl_filter_action_set action_set;
416 VIRTCHNL_CHECK_STRUCT_LEN (2604, virtchnl_fdir_rule);
418 /* query information to retrieve fdir rule counters.
419 * PF will fill out this structure to reset counter.
421 struct virtchnl_fdir_query_info
423 u32 match_packets_valid : 1;
424 u32 match_bytes_valid : 1;
425 u32 reserved : 30; /* Reserved, must be zero. */
427 u64 matched_packets; /* Number of packets for this rule. */
428 u64 matched_bytes; /* Number of bytes through this rule. */
431 VIRTCHNL_CHECK_STRUCT_LEN (24, virtchnl_fdir_query_info);
433 /* Status returned to VF after VF requests FDIR commands
434 * VIRTCHNL_FDIR_SUCCESS
435 * VF FDIR related request is successfully done by PF
436 * The request can be OP_ADD/DEL/QUERY_FDIR_FILTER.
438 * VIRTCHNL_FDIR_FAILURE_RULE_NORESOURCE
439 * OP_ADD_FDIR_FILTER request is failed due to no Hardware resource.
441 * VIRTCHNL_FDIR_FAILURE_RULE_EXIST
442 * OP_ADD_FDIR_FILTER request is failed due to the rule is already existed.
444 * VIRTCHNL_FDIR_FAILURE_RULE_CONFLICT
445 * OP_ADD_FDIR_FILTER request is failed due to conflict with existing rule.
447 * VIRTCHNL_FDIR_FAILURE_RULE_NONEXIST
448 * OP_DEL_FDIR_FILTER request is failed due to this rule doesn't exist.
450 * VIRTCHNL_FDIR_FAILURE_RULE_INVALID
451 * OP_ADD_FDIR_FILTER request is failed due to parameters validation
452 * or HW doesn't support.
454 * VIRTCHNL_FDIR_FAILURE_RULE_TIMEOUT
455 * OP_ADD/DEL_FDIR_FILTER request is failed due to timing out
458 * VIRTCHNL_FDIR_FAILURE_QUERY_INVALID
459 * OP_QUERY_FDIR_FILTER request is failed due to parameters validation,
460 * for example, VF query counter of a rule who has no counter action.
462 enum virtchnl_fdir_prgm_status
464 VIRTCHNL_FDIR_SUCCESS = 0,
465 VIRTCHNL_FDIR_FAILURE_RULE_NORESOURCE,
466 VIRTCHNL_FDIR_FAILURE_RULE_EXIST,
467 VIRTCHNL_FDIR_FAILURE_RULE_CONFLICT,
468 VIRTCHNL_FDIR_FAILURE_RULE_NONEXIST,
469 VIRTCHNL_FDIR_FAILURE_RULE_INVALID,
470 VIRTCHNL_FDIR_FAILURE_RULE_TIMEOUT,
471 VIRTCHNL_FDIR_FAILURE_QUERY_INVALID,
472 VIRTCHNL_FDIR_FAILURE_MAX,
475 /* VIRTCHNL_OP_ADD_FDIR_FILTER
476 * VF sends this request to PF by filling out vsi_id,
477 * validate_only and rule_cfg. PF will return flow_id
478 * if the request is successfully done and return add_status to VF.
480 struct virtchnl_fdir_add
482 u16 vsi_id; /* INPUT */
484 * 1 for validating a fdir rule, 0 for creating a fdir rule.
485 * Validate and create share one ops: VIRTCHNL_OP_ADD_FDIR_FILTER.
487 u16 validate_only; /* INPUT */
488 u32 flow_id; /* OUTPUT */
489 struct virtchnl_fdir_rule rule_cfg; /* INPUT */
490 enum virtchnl_fdir_prgm_status status; /* OUTPUT */
493 VIRTCHNL_CHECK_STRUCT_LEN (2616, virtchnl_fdir_add);
495 /* VIRTCHNL_OP_DEL_FDIR_FILTER
496 * VF sends this request to PF by filling out vsi_id
497 * and flow_id. PF will return del_status to VF.
499 struct virtchnl_fdir_del
501 u16 vsi_id; /* INPUT */
503 u32 flow_id; /* INPUT */
504 enum virtchnl_fdir_prgm_status status; /* OUTPUT */
507 VIRTCHNL_CHECK_STRUCT_LEN (12, virtchnl_fdir_del);
509 /* VIRTCHNL_OP_QUERY_FDIR_FILTER
510 * VF sends this request to PF by filling out vsi_id,
511 * flow_id and reset_counter. PF will return query_info
512 * and query_status to VF.
514 struct virtchnl_fdir_query
516 u16 vsi_id; /* INPUT */
518 u32 flow_id; /* INPUT */
519 u32 reset_counter : 1; /* INPUT */
520 struct virtchnl_fdir_query_info query_info; /* OUTPUT */
521 enum virtchnl_fdir_prgm_status status; /* OUTPUT */
525 VIRTCHNL_CHECK_STRUCT_LEN (48, virtchnl_fdir_query);
528 * Those headers used temporary, maybe OS packet
529 * definition can replace. Add flow error, pattern
530 * and action definition.
534 * Verbose error types.
536 * Most of them provide the type of the object referenced by struct
537 * rte_flow_error.cause.
539 enum avf_flow_error_type
541 AVF_FLOW_ERROR_TYPE_NONE, /**< No error. */
542 AVF_FLOW_ERROR_TYPE_UNSPECIFIED, /**< Cause unspecified. */
543 AVF_FLOW_ERROR_TYPE_HANDLE, /**< Flow rule (handle). */
544 AVF_FLOW_ERROR_TYPE_ATTR_GROUP, /**< Group field. */
545 AVF_FLOW_ERROR_TYPE_ATTR_PRIORITY, /**< Priority field. */
546 AVF_FLOW_ERROR_TYPE_ATTR_INGRESS, /**< Ingress field. */
547 AVF_FLOW_ERROR_TYPE_ATTR_EGRESS, /**< Egress field. */
548 AVF_FLOW_ERROR_TYPE_ATTR_TRANSFER, /**< Transfer field. */
549 AVF_FLOW_ERROR_TYPE_ATTR, /**< Attributes structure. */
550 AVF_FLOW_ERROR_TYPE_ITEM_NUM, /**< Pattern length. */
551 AVF_FLOW_ERROR_TYPE_ITEM_SPEC, /**< Item specification. */
552 AVF_FLOW_ERROR_TYPE_ITEM_LAST, /**< Item specification range. */
553 AVF_FLOW_ERROR_TYPE_ITEM_MASK, /**< Item specification mask. */
554 AVF_FLOW_ERROR_TYPE_ITEM, /**< Specific pattern item. */
555 AVF_FLOW_ERROR_TYPE_ACTION_NUM, /**< Number of actions. */
556 AVF_FLOW_ERROR_TYPE_ACTION_CONF, /**< Action configuration. */
557 AVF_FLOW_ERROR_TYPE_ACTION, /**< Specific action. */
561 * Verbose error structure definition.
562 * Both cause and message may be NULL regardless of the error type.
564 struct avf_flow_error
566 enum avf_flow_error_type type; /**< Cause field and error types. */
567 const void *cause; /**< Object responsible for the error. */
568 const char *message; /**< Human-readable error message. */
571 #define AVF_ETHER_ADDR_LEN 6
572 struct avf_ether_addr
574 u8 addr_bytes[AVF_ETHER_ADDR_LEN]; /**< Addr bytes in tx order */
575 } __attribute__ ((__aligned__ (2)));
577 struct avf_flow_eth_hdr
579 struct avf_ether_addr dst; /**< Destination MAC. */
580 struct avf_ether_addr src; /**< Source MAC. */
581 u16 type; /**< EtherType or TPID. */
589 u8 version_ihl; /**< version and header length */
590 u8 type_of_service; /**< type of service */
591 u16 total_length; /**< length of packet */
592 u16 packet_id; /**< packet ID */
593 u16 fragment_offset; /**< fragmentation offset */
594 u8 time_to_live; /**< time to live */
595 u8 next_proto_id; /**< protocol ID */
596 u16 hdr_checksum; /**< header checksum */
597 u32 src_addr; /**< source address */
598 u32 dst_addr; /**< destination address */
599 } __attribute__ ((__packed__));
606 u32 vtc_flow; /**< IP version, traffic class & flow label. */
607 u16 payload_len; /**< IP packet length - includes header size */
608 u8 proto; /**< Protocol, next header. */
609 u8 hop_limits; /**< Hop limits. */
610 u8 src_addr[16]; /**< IP address of source host. */
611 u8 dst_addr[16]; /**< IP address of destination host(s). */
612 } __attribute__ ((__packed__));
619 u16 src_port; /**< TCP source port. */
620 u16 dst_port; /**< TCP destination port. */
621 u32 sent_seq; /**< TX data sequence number. */
622 u32 recv_ack; /**< RX data acknowledgment sequence number. */
623 u8 data_off; /**< Data offset. */
624 u8 tcp_flags; /**< TCP flags */
625 u16 rx_win; /**< RX flow control window. */
626 u16 cksum; /**< TCP checksum. */
627 u16 tcp_urp; /**< TCP urgent pointer, if any. */
628 } __attribute__ ((__packed__));
635 u16 src_port; /**< UDP source port. */
636 u16 dst_port; /**< UDP destination port. */
637 u16 dgram_len; /**< UDP datagram length */
638 u16 dgram_cksum; /**< UDP datagram checksum */
639 } __attribute__ ((__packed__));
642 * Match IP Authentication Header (AH), RFC 4302
658 u32 spi; /**< Security Parameters Index */
659 u32 seq; /**< packet sequence number */
660 } __attribute__ ((__packed__));
674 * Matches a L2TPv3 over IP header.
676 struct avf_l2tpv3oip_hdr
678 u32 session_id; /**< Session ID. */
682 * Matches a GTP PDU extension header with type 0x85.
684 struct avf_gtp_psc_hdr
686 u8 pdu_type; /**< PDU type. */
687 u8 qfi; /**< QoS flow identifier. */
691 * Matches a GTPv1 header.
696 * Version (3b), protocol type (1b), reserved (1b),
697 * Extension header flag (1b),
698 * Sequence number flag (1b),
699 * N-PDU number flag (1b).
702 u8 msg_type; /**< Message type. */
703 u16 msg_len; /**< Message length. */
704 u32 teid; /**< Tunnel endpoint identifier. */
712 u16 src_port; /**< Source port. */
713 u16 dst_port; /**< Destin port. */
714 u32 tag; /**< Validation tag. */
715 u32 cksum; /**< Checksum. */
716 } __attribute__ ((__packed__));
719 * Hash function types.
721 enum avf_eth_hash_function
723 AVF_ETH_HASH_FUNCTION_DEFAULT = 0,
724 AVF_ETH_HASH_FUNCTION_TOEPLITZ, /**< Toeplitz */
725 AVF_ETH_HASH_FUNCTION_SIMPLE_XOR, /**< Simple XOR */
727 * Symmetric Toeplitz: src, dst will be replaced by
728 * xor(src, dst). For the case with src/dst only,
729 * src or dst address will xor with zero pair.
731 AVF_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ,
732 AVF_ETH_HASH_FUNCTION_MAX,
735 struct avf_flow_action_rss
737 enum avf_eth_hash_function func; /**< RSS hash function to apply. */
740 u64 types; /**< Specific RSS hash types (see ETH_RSS_*). */
741 u32 key_len; /**< Hash key length in bytes. */
742 u32 queue_num; /**< Number of entries in @p queue. */
743 const u8 *key; /**< Hash key. */
744 const u16 *queue; /**< Queue indices to use. */
747 struct avf_flow_action_queue
749 u16 index; /**< Queue index to use. */
752 struct avf_flow_action_mark
754 u32 id; /**< Integer value to return with packets. */
757 struct avf_flow_action
759 enum virtchnl_action type; /**< Action type. */
760 const void *conf; /**< Pointer to action configuration object. */
765 enum virtchnl_proto_hdr_type type; /**< Item type. */
766 const void *spec; /**< Pointer to item specification structure. */
767 const void *mask; /**< Bit-mask applied to spec and last. */
772 struct virtchnl_fdir_add add_fltr;
773 struct virtchnl_fdir_del del_fltr;
783 VIRTCHNL_ADV_OP_ADD_FDIR_FILTER = 0,
784 VIRTCHNL_ADV_OP_DEL_FDIR_FILTER,
785 VIRTCHNL_ADV_OP_QUERY_FDIR_FILTER,
789 /* virtual channel op handler */
790 typedef int (*avf_fdir_vc_op_t) (void *vc_hdl, enum virthnl_adv_ops vc_op,
791 void *in, u32 in_len, void *out, u32 out_len);
793 /* virtual channel context object */
794 struct avf_fdir_vc_ctx
796 void *vc_hdl; /* virtual channel handler */
797 avf_fdir_vc_op_t vc_op;
801 * Create a rule cfg object.
804 * created rule cfg object.
806 * tunnel level where protocol header start from
807 * 0 from moster outer layer.
808 * 1 from first inner layer.
809 * 2 form second inner layer.
815 * the rx queue number of the avf
821 int avf_fdir_rcfg_create (struct avf_fdir_conf **rcfg, int tunnel_level,
825 * Destroy a rule cfg object.
828 * the cfg object to destroy.
834 int avf_fdir_rcfg_destroy (struct avf_fdir_conf *rcfg);
837 * Set match potocol header on specific layer, it will overwrite is already be
841 * the rule cfg object
843 * layer of the protocol header.
845 * protocol header type.
851 int avf_fdir_rcfg_set_hdr (struct avf_fdir_conf *rcfg, int layer,
852 enum virtchnl_proto_hdr_type hdr);
855 * Set a match field on specific protocol layer, if any match field already be
856 * set on this layer, it will be overwritten.
859 * the rule cfg object
861 * layer of the protocol header.
871 int avf_fdir_rcfg_set_field (struct avf_fdir_conf *rcfg, int layer,
872 struct avf_flow_item *item,
873 struct avf_flow_error *error);
876 * Set action as to queue(group), conflict with drop action.
883 * queue group size, must be 2^n. 1 means only to single queue.
891 int avf_fdir_rcfg_act_queue (struct avf_fdir_conf *rcfg, int queue, int size,
895 * Set action as to queue group, conflict with drop action.
898 * the rule cfg object
910 int avf_fdir_parse_action_qregion (struct avf_fdir_conf *rcfg,
911 const struct avf_flow_action *act,
912 int act_idx, struct avf_flow_error *error);
915 * Set action as as drop, conflict with to queue(gropu) action.
918 * the rule cfg object
926 int avf_fdir_rcfg_act_drop (struct avf_fdir_conf *rcfg, int act_idx);
929 * Set action as mark, it can co-exist with to queue(group) or drop action.
932 * the rule cfg object
942 int avf_fdir_rcfg_act_mark (struct avf_fdir_conf *rcfg, const u32 mark,
946 * Validate a flow rule cfg, check with PF driver if the rule cfg is supportted
950 * virtual channel context
952 * the rule cfg object.
958 int avf_fdir_rcfg_validate (struct avf_fdir_vc_ctx *ctx,
959 struct avf_fdir_conf *rcfg);
962 * Create a flow rule, a FDIR rule is expected to be programmed into hardware
966 * virtual channel context
974 int avf_fdir_rule_create (struct avf_fdir_vc_ctx *ctx,
975 struct avf_fdir_conf *rcfg);
978 * Destroy a flow rule.
981 * virtual channel context
983 * the rule cfg object.
989 int avf_fdir_rule_destroy (struct avf_fdir_vc_ctx *ctx,
990 struct avf_fdir_conf *rcfg);
993 * Parse avf patterns and set pattern fields.
1006 int avf_fdir_parse_pattern (struct avf_fdir_conf *rcfg,
1007 struct avf_flow_item avf_items[],
1008 struct avf_flow_error *error);
1011 * Parse flow actions, set actions.
1024 int avf_fdir_parse_action (const struct avf_flow_action actions[],
1025 struct avf_fdir_conf *rcfg,
1026 struct avf_flow_error *error);
1029 * Initialize flow error structure.
1032 * Pointer to flow error structure (may be NULL).
1034 * Related error code
1036 * Cause field and error types.
1038 * Object responsible for the error.
1040 * Human-readable error message.
1043 * Negative error code (errno value)
1045 int avf_flow_error_set (struct avf_flow_error *error, int code,
1046 enum avf_flow_error_type type, const void *cause,
1047 const char *message);
1050 * decode the error number to Verbose error string
1056 * Verbose error string
1058 char *avf_fdir_prgm_error_decode (int err_no);
1060 #endif /* _AVF_ADVANCED_FLOW_H_ */
1063 * fd.io coding-style-patch-verification: ON
1066 * eval: (c-set-style "gnu")