avf: support generic flow
[vpp.git] / src / plugins / avf / avf_advanced_flow.h
1 /*
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:
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
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  *------------------------------------------------------------------
16  */
17
18 #ifndef _AVF_ADVANCED_FLOW_H_
19 #define _AVF_ADVANCED_FLOW_H_
20
21 #define AVF_SUCCESS (0)
22 #define AVF_FAILURE (-1)
23
24 #define BIT(a)     (1UL << (a))
25 #define BIT_ULL(a) (1ULL << (a))
26
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
30  * that is never used.
31  */
32 #define VIRTCHNL_CHECK_STRUCT_LEN(n, X)                                       \
33   enum virtchnl_static_assert_enum_##X                                        \
34   {                                                                           \
35     virtchnl_static_assert_##X = (n) / ((sizeof (struct X) == (n)) ? 1 : 0)   \
36   }
37 #define VIRTCHNL_CHECK_UNION_LEN(n, X)                                        \
38   enum virtchnl_static_asset_enum_##X                                         \
39   {                                                                           \
40     virtchnl_static_assert_##X = (n) / ((sizeof (union X) == (n)) ? 1 : 0)    \
41   }
42
43 /* AVF ethernet frame types */
44 #define AVF_ETHER_TYPE_IPV4 0x0800 /**< IPv4 Protocol. */
45 #define AVF_ETHER_TYPE_IPV6 0x86DD /**< IPv6 Protocol. */
46
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)
53
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
60  */
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)
68
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))
73
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))
82
83 /* protocol */
84
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)
110
111 /* field */
112
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)
134
135 /* input set */
136
137 #define AVF_INSET_NONE 0ULL
138
139 /* non-tunnel */
140
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)
146
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)
157
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)
180
181 /* Protocol header type within a packet segment. A segment consists of one or
182  * more protocol headers that make up a logical group of protocol headers. Each
183  * logical group of protocol headers encapsulates or is encapsulated using/by
184  * tunneling or encapsulation protocols for network virtualization.
185  */
186 enum virtchnl_proto_hdr_type
187 {
188   VIRTCHNL_PROTO_HDR_NONE,
189   VIRTCHNL_PROTO_HDR_ETH,
190   VIRTCHNL_PROTO_HDR_S_VLAN,
191   VIRTCHNL_PROTO_HDR_C_VLAN,
192   VIRTCHNL_PROTO_HDR_IPV4,
193   VIRTCHNL_PROTO_HDR_IPV6,
194   VIRTCHNL_PROTO_HDR_TCP,
195   VIRTCHNL_PROTO_HDR_UDP,
196   VIRTCHNL_PROTO_HDR_SCTP,
197   VIRTCHNL_PROTO_HDR_GTPU_IP,
198   VIRTCHNL_PROTO_HDR_GTPU_EH,
199   VIRTCHNL_PROTO_HDR_GTPU_EH_PDU_DWN,
200   VIRTCHNL_PROTO_HDR_GTPU_EH_PDU_UP,
201   VIRTCHNL_PROTO_HDR_PPPOE,
202   VIRTCHNL_PROTO_HDR_L2TPV3,
203   VIRTCHNL_PROTO_HDR_ESP,
204   VIRTCHNL_PROTO_HDR_AH,
205   VIRTCHNL_PROTO_HDR_PFCP,
206 };
207
208 /* Protocol header field within a protocol header. */
209 enum virtchnl_proto_hdr_field
210 {
211   /* ETHER */
212   VIRTCHNL_PROTO_HDR_ETH_SRC = PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_ETH),
213   VIRTCHNL_PROTO_HDR_ETH_DST,
214   VIRTCHNL_PROTO_HDR_ETH_ETHERTYPE,
215   /* S-VLAN */
216   VIRTCHNL_PROTO_HDR_S_VLAN_ID =
217     PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_S_VLAN),
218   /* C-VLAN */
219   VIRTCHNL_PROTO_HDR_C_VLAN_ID =
220     PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_C_VLAN),
221   /* IPV4 */
222   VIRTCHNL_PROTO_HDR_IPV4_SRC =
223     PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_IPV4),
224   VIRTCHNL_PROTO_HDR_IPV4_DST,
225   VIRTCHNL_PROTO_HDR_IPV4_DSCP,
226   VIRTCHNL_PROTO_HDR_IPV4_TTL,
227   VIRTCHNL_PROTO_HDR_IPV4_PROT,
228   /* IPV6 */
229   VIRTCHNL_PROTO_HDR_IPV6_SRC =
230     PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_IPV6),
231   VIRTCHNL_PROTO_HDR_IPV6_DST,
232   VIRTCHNL_PROTO_HDR_IPV6_TC,
233   VIRTCHNL_PROTO_HDR_IPV6_HOP_LIMIT,
234   VIRTCHNL_PROTO_HDR_IPV6_PROT,
235   /* TCP */
236   VIRTCHNL_PROTO_HDR_TCP_SRC_PORT =
237     PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_TCP),
238   VIRTCHNL_PROTO_HDR_TCP_DST_PORT,
239   /* UDP */
240   VIRTCHNL_PROTO_HDR_UDP_SRC_PORT =
241     PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_UDP),
242   VIRTCHNL_PROTO_HDR_UDP_DST_PORT,
243   /* SCTP */
244   VIRTCHNL_PROTO_HDR_SCTP_SRC_PORT =
245     PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_SCTP),
246   VIRTCHNL_PROTO_HDR_SCTP_DST_PORT,
247   /* GTPU_IP */
248   VIRTCHNL_PROTO_HDR_GTPU_IP_TEID =
249     PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_GTPU_IP),
250   /* GTPU_EH */
251   VIRTCHNL_PROTO_HDR_GTPU_EH_PDU =
252     PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_GTPU_EH),
253   VIRTCHNL_PROTO_HDR_GTPU_EH_QFI,
254   /* PPPOE */
255   VIRTCHNL_PROTO_HDR_PPPOE_SESS_ID =
256     PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_PPPOE),
257   /* L2TPV3 */
258   VIRTCHNL_PROTO_HDR_L2TPV3_SESS_ID =
259     PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_L2TPV3),
260   /* ESP */
261   VIRTCHNL_PROTO_HDR_ESP_SPI = PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_ESP),
262   /* AH */
263   VIRTCHNL_PROTO_HDR_AH_SPI = PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_AH),
264   /* PFCP */
265   VIRTCHNL_PROTO_HDR_PFCP_S_FIELD =
266     PROTO_HDR_FIELD_START (VIRTCHNL_PROTO_HDR_PFCP),
267   VIRTCHNL_PROTO_HDR_PFCP_SEID,
268 };
269
270 struct virtchnl_proto_hdr
271 {
272   enum virtchnl_proto_hdr_type type;
273   u32 field_selector; /* a bit mask to select field for header type */
274   u8 buffer[64];
275   /**
276    * binary buffer in network order for specific header type.
277    * For example, if type = VIRTCHNL_PROTO_HDR_IPV4, a IPv4
278    * header is expected to be copied into the buffer.
279    */
280 };
281
282 VIRTCHNL_CHECK_STRUCT_LEN (72, virtchnl_proto_hdr);
283
284 struct virtchnl_proto_hdrs
285 {
286   u8 tunnel_level;
287   /**
288    * specify where protocol header start from. Must be 0 when sending a generic
289    * packet request. 0 - from the outer layer 1 - from the first inner layer 2
290    *- from the second inner layer
291    * ....
292    **/
293   int count;
294   /**
295    * the proto layers must < VIRTCHNL_MAX_NUM_PROTO_HDRS.
296    * Must be 0 when sending a generic packet request.
297    **/
298   union
299   {
300     struct virtchnl_proto_hdr proto_hdr[VIRTCHNL_MAX_NUM_PROTO_HDRS];
301     struct
302     {
303       u16 pkt_len;
304       u8 spec[VIRTCHNL_MAX_SIZE_GEN_PACKET];
305       u8 mask[VIRTCHNL_MAX_SIZE_GEN_PACKET];
306     } raw;
307   };
308 };
309
310 VIRTCHNL_CHECK_STRUCT_LEN (2312, virtchnl_proto_hdrs);
311
312 /* VIRTCHNL_OP_CONFIG_RSS_KEY
313  * VIRTCHNL_OP_CONFIG_RSS_LUT
314  * VF sends these messages to configure RSS. Only supported if both PF
315  * and VF drivers set the VIRTCHNL_VF_OFFLOAD_RSS_PF bit during
316  * configuration negotiation. If this is the case, then the RSS fields in
317  * the VF resource struct are valid.
318  * Both the key and LUT are initialized to 0 by the PF, meaning that
319  * RSS is effectively disabled until set up by the VF.
320  */
321 struct virtchnl_rss_key
322 {
323   u16 vsi_id;
324   u16 key_len;
325   u8 key[1]; /* RSS hash key, packed bytes */
326 };
327
328 VIRTCHNL_CHECK_STRUCT_LEN (6, virtchnl_rss_key);
329
330 struct virtchnl_rss_lut
331 {
332   u16 vsi_id;
333   u16 lut_entries;
334   u8 lut[1]; /* RSS lookup table */
335 };
336
337 VIRTCHNL_CHECK_STRUCT_LEN (6, virtchnl_rss_lut);
338
339 /* VIRTCHNL_OP_GET_RSS_HENA_CAPS
340  * VIRTCHNL_OP_SET_RSS_HENA
341  * VF sends these messages to get and set the hash filter enable bits for RSS.
342  * By default, the PF sets these to all possible traffic types that the
343  * hardware supports. The VF can query this value if it wants to change the
344  * traffic types that are hashed by the hardware.
345  */
346 struct virtchnl_rss_hena
347 {
348   u64 hena;
349 };
350
351 VIRTCHNL_CHECK_STRUCT_LEN (8, virtchnl_rss_hena);
352
353 /* Type of RSS algorithm */
354 enum virtchnl_rss_algorithm
355 {
356   VIRTCHNL_RSS_ALG_TOEPLITZ_ASYMMETRIC = 0,
357   VIRTCHNL_RSS_ALG_XOR_ASYMMETRIC = 1,
358   VIRTCHNL_RSS_ALG_TOEPLITZ_SYMMETRIC = 2,
359   VIRTCHNL_RSS_ALG_XOR_SYMMETRIC = 3,
360 };
361
362 struct virtchnl_rss_cfg
363 {
364   struct virtchnl_proto_hdrs proto_hdrs;     /* protocol headers */
365   enum virtchnl_rss_algorithm rss_algorithm; /* rss algorithm type */
366   u8 reserved[128];                          /* reserve for future */
367 };
368
369 VIRTCHNL_CHECK_STRUCT_LEN (2444, virtchnl_rss_cfg);
370
371 enum virtchnl_action
372 {
373   /* action types */
374   VIRTCHNL_ACTION_DROP = 0,
375   VIRTCHNL_ACTION_TC_REDIRECT,
376   VIRTCHNL_ACTION_PASSTHRU,
377   VIRTCHNL_ACTION_QUEUE,
378   VIRTCHNL_ACTION_Q_REGION,
379   VIRTCHNL_ACTION_MARK,
380   VIRTCHNL_ACTION_COUNT,
381   VIRTCHNL_ACTION_NONE,
382 };
383
384 /* action configuration for FDIR */
385 struct virtchnl_filter_action
386 {
387   enum virtchnl_action type;
388   union
389   {
390     /* used for queue and qgroup action */
391     struct
392     {
393       u16 index;
394       u8 region;
395     } queue;
396     /* used for count action */
397     struct
398     {
399       /* share counter ID with other flow rules */
400       u8 shared;
401       u32 id; /* counter ID */
402     } count;
403     /* used for mark action */
404     u32 mark_id;
405     u8 reserve[32];
406   } act_conf;
407 };
408
409 VIRTCHNL_CHECK_STRUCT_LEN (36, virtchnl_filter_action);
410
411 #define VIRTCHNL_MAX_NUM_ACTIONS 8
412
413 struct virtchnl_filter_action_set
414 {
415   /* action number must be less then VIRTCHNL_MAX_NUM_ACTIONS */
416   int count;
417   struct virtchnl_filter_action actions[VIRTCHNL_MAX_NUM_ACTIONS];
418 };
419
420 VIRTCHNL_CHECK_STRUCT_LEN (292, virtchnl_filter_action_set);
421
422 /* pattern and action for FDIR rule */
423 struct virtchnl_fdir_rule
424 {
425   struct virtchnl_proto_hdrs proto_hdrs;
426   struct virtchnl_filter_action_set action_set;
427 };
428
429 VIRTCHNL_CHECK_STRUCT_LEN (2604, virtchnl_fdir_rule);
430
431 /* query information to retrieve fdir rule counters.
432  * PF will fill out this structure to reset counter.
433  */
434 struct virtchnl_fdir_query_info
435 {
436   u32 match_packets_valid : 1;
437   u32 match_bytes_valid : 1;
438   u32 reserved : 30; /* Reserved, must be zero. */
439   u32 pad;
440   u64 matched_packets; /* Number of packets for this rule. */
441   u64 matched_bytes;   /* Number of bytes through this rule. */
442 };
443
444 VIRTCHNL_CHECK_STRUCT_LEN (24, virtchnl_fdir_query_info);
445
446 /* Status returned to VF after VF requests FDIR commands
447  * VIRTCHNL_FDIR_SUCCESS
448  * VF FDIR related request is successfully done by PF
449  * The request can be OP_ADD/DEL/QUERY_FDIR_FILTER.
450  *
451  * VIRTCHNL_FDIR_FAILURE_RULE_NORESOURCE
452  * OP_ADD_FDIR_FILTER request is failed due to no Hardware resource.
453  *
454  * VIRTCHNL_FDIR_FAILURE_RULE_EXIST
455  * OP_ADD_FDIR_FILTER request is failed due to the rule is already existed.
456  *
457  * VIRTCHNL_FDIR_FAILURE_RULE_CONFLICT
458  * OP_ADD_FDIR_FILTER request is failed due to conflict with existing rule.
459  *
460  * VIRTCHNL_FDIR_FAILURE_RULE_NONEXIST
461  * OP_DEL_FDIR_FILTER request is failed due to this rule doesn't exist.
462  *
463  * VIRTCHNL_FDIR_FAILURE_RULE_INVALID
464  * OP_ADD_FDIR_FILTER request is failed due to parameters validation
465  * or HW doesn't support.
466  *
467  * VIRTCHNL_FDIR_FAILURE_RULE_TIMEOUT
468  * OP_ADD/DEL_FDIR_FILTER request is failed due to timing out
469  * for programming.
470  *
471  * VIRTCHNL_FDIR_FAILURE_QUERY_INVALID
472  * OP_QUERY_FDIR_FILTER request is failed due to parameters validation,
473  * for example, VF query counter of a rule who has no counter action.
474  */
475 enum virtchnl_fdir_prgm_status
476 {
477   VIRTCHNL_FDIR_SUCCESS = 0,
478   VIRTCHNL_FDIR_FAILURE_RULE_NORESOURCE,
479   VIRTCHNL_FDIR_FAILURE_RULE_EXIST,
480   VIRTCHNL_FDIR_FAILURE_RULE_CONFLICT,
481   VIRTCHNL_FDIR_FAILURE_RULE_NONEXIST,
482   VIRTCHNL_FDIR_FAILURE_RULE_INVALID,
483   VIRTCHNL_FDIR_FAILURE_RULE_TIMEOUT,
484   VIRTCHNL_FDIR_FAILURE_QUERY_INVALID,
485   VIRTCHNL_FDIR_FAILURE_MAX,
486 };
487
488 /* VIRTCHNL_OP_ADD_FDIR_FILTER
489  * VF sends this request to PF by filling out vsi_id,
490  * validate_only and rule_cfg. PF will return flow_id
491  * if the request is successfully done and return add_status to VF.
492  */
493 struct virtchnl_fdir_add
494 {
495   u16 vsi_id; /* INPUT */
496   /*
497    * 1 for validating a fdir rule, 0 for creating a fdir rule.
498    * Validate and create share one ops: VIRTCHNL_OP_ADD_FDIR_FILTER.
499    */
500   u16 validate_only;                     /* INPUT */
501   u32 flow_id;                           /* OUTPUT */
502   struct virtchnl_fdir_rule rule_cfg;    /* INPUT */
503   enum virtchnl_fdir_prgm_status status; /* OUTPUT */
504 };
505
506 VIRTCHNL_CHECK_STRUCT_LEN (2616, virtchnl_fdir_add);
507
508 /* VIRTCHNL_OP_DEL_FDIR_FILTER
509  * VF sends this request to PF by filling out vsi_id
510  * and flow_id. PF will return del_status to VF.
511  */
512 struct virtchnl_fdir_del
513 {
514   u16 vsi_id; /* INPUT */
515   u16 pad;
516   u32 flow_id;                           /* INPUT */
517   enum virtchnl_fdir_prgm_status status; /* OUTPUT */
518 };
519
520 VIRTCHNL_CHECK_STRUCT_LEN (12, virtchnl_fdir_del);
521
522 /* VIRTCHNL_OP_QUERY_FDIR_FILTER
523  * VF sends this request to PF by filling out vsi_id,
524  * flow_id and reset_counter. PF will return query_info
525  * and query_status to VF.
526  */
527 struct virtchnl_fdir_query
528 {
529   u16 vsi_id; /* INPUT */
530   u16 pad1[3];
531   u32 flow_id;                                /* INPUT */
532   u32 reset_counter : 1;                      /* INPUT */
533   struct virtchnl_fdir_query_info query_info; /* OUTPUT */
534   enum virtchnl_fdir_prgm_status status;      /* OUTPUT */
535   u32 pad2;
536 };
537
538 VIRTCHNL_CHECK_STRUCT_LEN (48, virtchnl_fdir_query);
539
540 /**
541  * Those headers used temporary, maybe OS packet
542  * definition can replace. Add flow error, pattern
543  * and action definition.
544  */
545
546 /**
547  * Verbose error types.
548  *
549  * Most of them provide the type of the object referenced by struct
550  * rte_flow_error.cause.
551  */
552 enum avf_flow_error_type
553 {
554   AVF_FLOW_ERROR_TYPE_NONE,          /**< No error. */
555   AVF_FLOW_ERROR_TYPE_UNSPECIFIED,   /**< Cause unspecified. */
556   AVF_FLOW_ERROR_TYPE_HANDLE,        /**< Flow rule (handle). */
557   AVF_FLOW_ERROR_TYPE_ATTR_GROUP,    /**< Group field. */
558   AVF_FLOW_ERROR_TYPE_ATTR_PRIORITY, /**< Priority field. */
559   AVF_FLOW_ERROR_TYPE_ATTR_INGRESS,  /**< Ingress field. */
560   AVF_FLOW_ERROR_TYPE_ATTR_EGRESS,   /**< Egress field. */
561   AVF_FLOW_ERROR_TYPE_ATTR_TRANSFER, /**< Transfer field. */
562   AVF_FLOW_ERROR_TYPE_ATTR,          /**< Attributes structure. */
563   AVF_FLOW_ERROR_TYPE_ITEM_NUM,      /**< Pattern length. */
564   AVF_FLOW_ERROR_TYPE_ITEM_SPEC,     /**< Item specification. */
565   AVF_FLOW_ERROR_TYPE_ITEM_LAST,     /**< Item specification range. */
566   AVF_FLOW_ERROR_TYPE_ITEM_MASK,     /**< Item specification mask. */
567   AVF_FLOW_ERROR_TYPE_ITEM,          /**< Specific pattern item. */
568   AVF_FLOW_ERROR_TYPE_ACTION_NUM,    /**< Number of actions. */
569   AVF_FLOW_ERROR_TYPE_ACTION_CONF,   /**< Action configuration. */
570   AVF_FLOW_ERROR_TYPE_ACTION,        /**< Specific action. */
571 };
572
573 /**
574  * Verbose error structure definition.
575  * Both cause and message may be NULL regardless of the error type.
576  */
577 struct avf_flow_error
578 {
579   enum avf_flow_error_type type; /**< Cause field and error types. */
580   const void *cause;             /**< Object responsible for the error. */
581   const char *message;           /**< Human-readable error message. */
582 };
583
584 #define AVF_ETHER_ADDR_LEN 6
585 struct avf_ether_addr
586 {
587   u8 addr_bytes[AVF_ETHER_ADDR_LEN]; /**< Addr bytes in tx order */
588 } __attribute__ ((__aligned__ (2)));
589
590 struct avf_flow_eth_hdr
591 {
592   struct avf_ether_addr dst; /**< Destination MAC. */
593   struct avf_ether_addr src; /**< Source MAC. */
594   u16 type;                  /**< EtherType or TPID. */
595 };
596
597 /**
598  * IPv4 Header
599  */
600 struct avf_ipv4_hdr
601 {
602   u8 version_ihl;      /**< version and header length */
603   u8 type_of_service;  /**< type of service */
604   u16 total_length;    /**< length of packet */
605   u16 packet_id;       /**< packet ID */
606   u16 fragment_offset; /**< fragmentation offset */
607   u8 time_to_live;     /**< time to live */
608   u8 next_proto_id;    /**< protocol ID */
609   u16 hdr_checksum;    /**< header checksum */
610   u32 src_addr;        /**< source address */
611   u32 dst_addr;        /**< destination address */
612 } __attribute__ ((__packed__));
613
614 /**
615  * IPv6 Header
616  */
617 struct avf_ipv6_hdr
618 {
619   u32 vtc_flow;    /**< IP version, traffic class & flow label. */
620   u16 payload_len; /**< IP packet length - includes header size */
621   u8 proto;        /**< Protocol, next header. */
622   u8 hop_limits;   /**< Hop limits. */
623   u8 src_addr[16]; /**< IP address of source host. */
624   u8 dst_addr[16]; /**< IP address of destination host(s). */
625 } __attribute__ ((__packed__));
626
627 /**
628  * TCP Header
629  */
630 struct avf_tcp_hdr
631 {
632   u16 src_port; /**< TCP source port. */
633   u16 dst_port; /**< TCP destination port. */
634   u32 sent_seq; /**< TX data sequence number. */
635   u32 recv_ack; /**< RX data acknowledgment sequence number. */
636   u8 data_off;  /**< Data offset. */
637   u8 tcp_flags; /**< TCP flags */
638   u16 rx_win;   /**< RX flow control window. */
639   u16 cksum;    /**< TCP checksum. */
640   u16 tcp_urp;  /**< TCP urgent pointer, if any. */
641 } __attribute__ ((__packed__));
642
643 /**
644  * UDP Header
645  */
646 struct avf_udp_hdr
647 {
648   u16 src_port;    /**< UDP source port. */
649   u16 dst_port;    /**< UDP destination port. */
650   u16 dgram_len;   /**< UDP datagram length */
651   u16 dgram_cksum; /**< UDP datagram checksum */
652 } __attribute__ ((__packed__));
653
654 /**
655  * Match IP Authentication Header (AH), RFC 4302
656  */
657 struct avf_ah_hdr
658 {
659   u32 next_hdr : 8;
660   u32 payload_len : 8;
661   u32 reserved : 16;
662   u32 spi;
663   u32 seq_num;
664 };
665
666 /**
667  * ESP Header
668  */
669 struct avf_esp_hdr
670 {
671   u32 spi; /**< Security Parameters Index */
672   u32 seq; /**< packet sequence number */
673 } __attribute__ ((__packed__));
674
675 /**
676  * Match PFCP Header
677  */
678 struct avf_pfcp_hdr
679 {
680   u8 s_field;
681   u8 msg_type;
682   u16 msg_len;
683   u64 seid;
684 };
685
686 /**
687  * Matches a L2TPv3 over IP header.
688  */
689 struct avf_l2tpv3oip_hdr
690 {
691   u32 session_id; /**< Session ID. */
692 };
693
694 /**
695  * Matches a GTP PDU extension header with type 0x85.
696  */
697 struct avf_gtp_psc_hdr
698 {
699   u8 pdu_type; /**< PDU type. */
700   u8 qfi;      /**< QoS flow identifier. */
701 };
702
703 /**
704  * Matches a GTPv1 header.
705  */
706 struct avf_gtp_hdr
707 {
708   /**
709    * Version (3b), protocol type (1b), reserved (1b),
710    * Extension header flag (1b),
711    * Sequence number flag (1b),
712    * N-PDU number flag (1b).
713    */
714   u8 v_pt_rsv_flags;
715   u8 msg_type; /**< Message type. */
716   u16 msg_len; /**< Message length. */
717   u32 teid;    /**< Tunnel endpoint identifier. */
718 };
719
720 /**
721  * SCTP Header
722  */
723 struct avf_sctp_hdr
724 {
725   u16 src_port; /**< Source port. */
726   u16 dst_port; /**< Destin port. */
727   u32 tag;      /**< Validation tag. */
728   u32 cksum;    /**< Checksum. */
729 } __attribute__ ((__packed__));
730
731 /**
732  * Hash function types.
733  */
734 enum avf_eth_hash_function
735 {
736   AVF_ETH_HASH_FUNCTION_DEFAULT = 0,
737   AVF_ETH_HASH_FUNCTION_TOEPLITZ,   /**< Toeplitz */
738   AVF_ETH_HASH_FUNCTION_SIMPLE_XOR, /**< Simple XOR */
739   /**
740    * Symmetric Toeplitz: src, dst will be replaced by
741    * xor(src, dst). For the case with src/dst only,
742    * src or dst address will xor with zero pair.
743    */
744   AVF_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ,
745   AVF_ETH_HASH_FUNCTION_MAX,
746 };
747
748 struct avf_flow_action_rss
749 {
750   enum avf_eth_hash_function func; /**< RSS hash function to apply. */
751
752   u32 level;
753   u64 types;        /**< Specific RSS hash types (see ETH_RSS_*). */
754   u32 key_len;      /**< Hash key length in bytes. */
755   u32 queue_num;    /**< Number of entries in @p queue. */
756   const u8 *key;    /**< Hash key. */
757   const u16 *queue; /**< Queue indices to use. */
758 };
759
760 struct avf_flow_action_queue
761 {
762   u16 index; /**< Queue index to use. */
763 };
764
765 struct avf_flow_action_mark
766 {
767   u32 id; /**< Integer value to return with packets. */
768 };
769
770 struct avf_flow_action
771 {
772   enum virtchnl_action type; /**< Action type. */
773   const void *conf;          /**< Pointer to action configuration object. */
774 };
775
776 struct avf_flow_item
777 {
778   enum virtchnl_proto_hdr_type type; /**< Item type. */
779   const void *spec; /**< Pointer to item specification structure. */
780   const void *mask; /**< Bit-mask applied to spec and last. */
781   int is_generic;   /* indicate if this item is for a generic flow pattern. */
782 };
783
784 struct avf_fdir_conf
785 {
786   struct virtchnl_fdir_add add_fltr;
787   struct virtchnl_fdir_del del_fltr;
788   u64 input_set;
789   u32 flow_id;
790   u32 mark_flag;
791   u32 vsi;
792   u32 nb_rx_queues;
793 };
794
795 enum virthnl_adv_ops
796 {
797   VIRTCHNL_ADV_OP_ADD_FDIR_FILTER = 0,
798   VIRTCHNL_ADV_OP_DEL_FDIR_FILTER,
799   VIRTCHNL_ADV_OP_QUERY_FDIR_FILTER,
800   VIRTCHNL_ADV_OP_ADD_RSS_CFG,
801   VIRTCHNL_ADV_OP_DEL_RSS_CFG,
802   VIRTCHNL_ADV_OP_MAX
803 };
804
805 /* virtual channel op handler */
806 typedef int (*avf_flow_vc_op_t) (void *vc_hdl, enum virthnl_adv_ops vc_op,
807                                  void *in, u32 in_len, void *out, u32 out_len);
808
809 /* virtual channel context object */
810 struct avf_flow_vc_ctx
811 {
812   void *vc_hdl; /* virtual channel handler */
813   avf_flow_vc_op_t vc_op;
814 };
815
816 /**
817  * Create a rule cfg object.
818  *
819  * @param rcfg
820  *      created rule cfg object.
821  * @param tunnel
822  *      tunnel level where protocol header start from
823  *      0 from moster outer layer.
824  *      1 from first inner layer.
825  *      2 form second inner layer.
826  *      ...
827  * @param vsi
828  *      avf vsi id
829  *
830  * @param nrxq
831  *      the rx queue number of the avf
832  *
833  * @return
834  *      0 = successful.
835  *      < 0 = failure.
836  */
837 int avf_fdir_rcfg_create (struct avf_fdir_conf **rcfg, int tunnel_level,
838                           u16 vsi, u16 nrxq);
839
840 /**
841  * Destroy a rule cfg object.
842  *
843  * @param rcfg
844  *      the cfg object to destroy.
845  *
846  * @return
847  *      0 = successful.
848  *      < 0 = failure.
849  */
850 int avf_fdir_rcfg_destroy (struct avf_fdir_conf *rcfg);
851
852 /**
853  * Set match potocol header on specific layer, it will overwrite is already be
854  * set.
855  *
856  * @param rcfg
857  *      the rule cfg object
858  * @param layer
859  *      layer of the protocol header.
860  * @param hdr
861  *      protocol header type.
862  *
863  * @return
864  *      0 = successful.
865  *      < 0 = failure.
866  */
867 int avf_fdir_rcfg_set_hdr (struct avf_fdir_conf *rcfg, int layer,
868                            enum virtchnl_proto_hdr_type hdr);
869
870 /**
871  * Set a match field on specific protocol layer, if any match field already be
872  * set on this layer, it will be overwritten.
873  *
874  * @param rcfg
875  *      the rule cfg object
876  * @param layer
877  *      layer of the protocol header.
878  * @param item
879  *      flow item
880  * @param error
881  *      save error cause
882  *
883  * @return
884  *      0 = successful.
885  *      < 0 = failure.
886  */
887 int avf_fdir_rcfg_set_field (struct avf_fdir_conf *rcfg, int layer,
888                              struct avf_flow_item *item,
889                              struct avf_flow_error *error);
890
891 /**
892  * Set action as to queue(group), conflict with drop action.
893  *
894  * @param rcfg
895  *      rule cfg object
896  * @param queue
897  *      queue id.
898  * @param size
899  *      queue group size, must be 2^n. 1 means only to single queue.
900  * @param act_idx
901  *      action index
902  *
903  * @return
904  *      0 = successful.
905  *      < 0 = failure.
906  */
907 int avf_fdir_rcfg_act_queue (struct avf_fdir_conf *rcfg, int queue, int size,
908                              int act_idx);
909
910 /**
911  * Set action as to queue group, conflict with drop action.
912  *
913  * @param rcfg
914  *      the rule cfg object
915  * @param act
916  *      flow actions
917  * @param act_idx
918  *      action index
919  * @error
920  *      save error cause
921  *
922  * @return
923  *      0 = successful.
924  *      < 0 = failure.
925  */
926 int avf_fdir_parse_action_qregion (struct avf_fdir_conf *rcfg,
927                                    const struct avf_flow_action *act,
928                                    int act_idx, struct avf_flow_error *error);
929
930 /**
931  * Set action as as drop, conflict with to queue(gropu) action.
932  *
933  * @param rcfg
934  *      the rule cfg object
935  * @param act_idx
936  *      action index
937  *
938  * @return
939  *      0 = successful.
940  *      < 0 = failure.
941  */
942 int avf_fdir_rcfg_act_drop (struct avf_fdir_conf *rcfg, int act_idx);
943
944 /**
945  * Set action as mark, it can co-exist with to queue(group) or drop action.
946  *
947  * @param rcfg
948  *      the rule cfg object
949  * @param mark
950  *      a 32 bit flow mark
951  * @param act_idx
952  *      action index
953  *
954  * @return
955  *      0 = successful.
956  *      < 0 = failure.
957  */
958 int avf_fdir_rcfg_act_mark (struct avf_fdir_conf *rcfg, const u32 mark,
959                             int act_idx);
960
961 /**
962  * Validate a flow rule cfg, check with PF driver if the rule cfg is supportted
963  *or not.
964  *
965  * @param ctx
966  *       virtual channel context
967  * @param rcfg
968  *      the rule cfg object.
969  *
970  * @return
971  *      0 = successful.
972  *      < 0 = failure.
973  */
974 int avf_fdir_rcfg_validate (struct avf_flow_vc_ctx *ctx,
975                             struct avf_fdir_conf *rcfg);
976
977 /**
978  * Create a flow rule, a FDIR rule is expected to be programmed into hardware
979  *if return success.
980  *
981  * @param ctx
982  *       virtual channel context
983  * @param rcfg
984  *      rule cfg object.
985  *
986  * @return
987  *      0 = successfule.
988  *      < 0 = failure.
989  */
990 int avf_fdir_rule_create (struct avf_flow_vc_ctx *ctx,
991                           struct avf_fdir_conf *rcfg);
992
993 /**
994  * Destroy a flow rule.
995  *
996  * @param ctx
997  *       virtual channel context
998  * @param rcfg
999  *      the rule cfg object.
1000  *
1001  * @return
1002  *      0 = successfule.
1003  *      < 0 = failure.
1004  */
1005 int avf_fdir_rule_destroy (struct avf_flow_vc_ctx *ctx,
1006                            struct avf_fdir_conf *rcfg);
1007
1008 /*
1009  * Parse avf patterns and set pattern fields.
1010  *
1011  * @param rcfg
1012  *      flow config
1013  * @param avf_items
1014  *      pattern items
1015  * @param error
1016  *      save error cause
1017  *
1018  * @return
1019  *      0 = successful.
1020  *      < 0 = failure
1021  */
1022 int avf_fdir_parse_pattern (struct avf_fdir_conf *rcfg,
1023                             struct avf_flow_item avf_items[],
1024                             struct avf_flow_error *error);
1025
1026 /*
1027  * Parse avf patterns for generic flow and set pattern fields.
1028  *
1029  * @param rcfg
1030  *      flow config
1031  * @param avf_items
1032  *      pattern items
1033  * @param error
1034  *      save error cause
1035  *
1036  * @return
1037  *      0 = successful.
1038  *      < 0 = failure
1039  */
1040 int avf_fdir_parse_generic_pattern (struct avf_fdir_conf *rcfg,
1041                                     struct avf_flow_item avf_items[],
1042                                     struct avf_flow_error *error);
1043
1044 /*
1045  * Parse flow actions, set actions.
1046  *
1047  * @param actions
1048  *      flow actions
1049  * @param rcfg
1050  *      flow config
1051  * @param error
1052  *      save error cause
1053  *
1054  * @return
1055  *  0 = successful.
1056  *  < 0 = failure
1057  */
1058 int avf_fdir_parse_action (const struct avf_flow_action actions[],
1059                            struct avf_fdir_conf *rcfg,
1060                            struct avf_flow_error *error);
1061
1062 /*
1063  * Parse avf patterns and set pattern fields for RSS.
1064  *
1065  * @param rss_cfg
1066  *      flow config
1067  * @param avf_items
1068  *      pattern items
1069  * @param error
1070  *      save error cause
1071  *
1072  * @return
1073  *      0 = successful.
1074  *      < 0 = failure
1075  */
1076 int avf_rss_parse_pattern (struct virtchnl_rss_cfg *rss_cfg,
1077                            struct avf_flow_item avf_items[],
1078                            struct avf_flow_error *error);
1079
1080 /*
1081  * Parse avf patterns and set pattern fields for RSS generic flow.
1082  *
1083  * @param rss_cfg
1084  *      flow config
1085  * @param avf_items
1086  *      pattern items
1087  * @param error
1088  *      save error cause
1089  *
1090  * @return
1091  *      0 = successful.
1092  *      < 0 = failure
1093  */
1094 int avf_rss_parse_generic_pattern (struct virtchnl_rss_cfg *rss_cfg,
1095                                    struct avf_flow_item avf_items[],
1096                                    struct avf_flow_error *error);
1097
1098 /*
1099  * Parse RSS flow actions, set actions.
1100  *
1101  * @param actions
1102  *      flow actions
1103  * @param rss_cfg
1104  *      flow config
1105  * @param error
1106  *      save error cause
1107  *
1108  * @return
1109  *  0 = successful.
1110  *  < 0 = failure
1111  */
1112 int avf_rss_parse_action (const struct avf_flow_action actions[],
1113                           struct virtchnl_rss_cfg *rss_cfg,
1114                           struct avf_flow_error *error);
1115
1116 /**
1117  * Create a RSS rule cfg object.
1118  *
1119  * @param rss_cfg
1120  *      created rule cfg object.
1121  * @param tunnel
1122  *      tunnel level where protocol header start from
1123  *      0 from moster outer layer.
1124  *      1 from first inner layer.
1125  *      2 form second inner layer.
1126  *  Must be 0 for generic flow.
1127  *
1128  * @return
1129  *      0 = successful.
1130  *      < 0 = failure.
1131  */
1132 int avf_rss_cfg_create (struct virtchnl_rss_cfg **rss_cfg, int tunnel_level);
1133
1134 int avf_rss_rcfg_destroy (struct virtchnl_rss_cfg *rss_cfg);
1135
1136 /**
1137  * Create a RSS flow rule
1138  *
1139  * @param ctx
1140  *       virtual channel context
1141  * @param rss_cfg
1142  *      rule cfg object.
1143  *
1144  * @return
1145  *      0 = successfule.
1146  *      < 0 = failure.
1147  */
1148 int avf_rss_rule_create (struct avf_flow_vc_ctx *ctx,
1149                          struct virtchnl_rss_cfg *rss_cfg);
1150
1151 /**
1152  * Destroy a RSS flow rule
1153  *
1154  * @param ctx
1155  *       virtual channel context
1156  * @param rss_cfg
1157  *      rule cfg object.
1158  *
1159  * @return
1160  *      0 = successfule.
1161  *      < 0 = failure.
1162  */
1163 int avf_rss_rule_destroy (struct avf_flow_vc_ctx *ctx,
1164                           struct virtchnl_rss_cfg *rss_cfg);
1165
1166 /**
1167  * Parse generic flow pattern to get spec and mask
1168  *
1169  * @param item
1170  *      flow item
1171  * @param pkt_buf
1172  *      spec buffer.
1173  * @param msk_buf
1174  *      mask buffer .
1175  * @param spec_len
1176  *      length of spec.
1177  */
1178 void avf_parse_generic_pattern (struct avf_flow_item *item, u8 *pkt_buf,
1179                                 u8 *msk_buf, u16 spec_len);
1180
1181 /**
1182  * Initialize flow error structure.
1183  *
1184  * @param[out] error
1185  *   Pointer to flow error structure (may be NULL).
1186  * @param code
1187  *   Related error code
1188  * @param type
1189  *   Cause field and error types.
1190  * @param cause
1191  *   Object responsible for the error.
1192  * @param message
1193  *   Human-readable error message.
1194  *
1195  * @return
1196  *   Negative error code (errno value)
1197  */
1198 int avf_flow_error_set (struct avf_flow_error *error, int code,
1199                         enum avf_flow_error_type type, const void *cause,
1200                         const char *message);
1201
1202 /*
1203  * decode the error number to Verbose error string
1204  *
1205  * @param err_no
1206  *  error number
1207  *
1208  * @return
1209  *  Verbose error string
1210  */
1211 char *avf_fdir_prgm_error_decode (int err_no);
1212
1213 #endif /* _AVF_ADVANCED_FLOW_H_ */
1214
1215 /*
1216  * fd.io coding-style-patch-verification: ON
1217  *
1218  * Local Variables:
1219  * eval: (c-set-style "gnu")
1220  * End:
1221  */