FD.io VPP  v21.06-1-gbb7418cf9
Vector Packet Processing
avf_advanced_flow.h
Go to the documentation of this file.
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 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)
52 
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
59  */
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)
67 
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))
72 
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))
81 
82 /* protocol */
83 
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)
109 
110 /* field */
111 
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)
133 
134 /* input set */
135 
136 #define AVF_INSET_NONE 0ULL
137 
138 /* non-tunnel */
139 
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)
145 
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)
156 
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)
179 
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.
184  */
186 {
205 };
206 
207 /* Protocol header field within a protocol header. */
209 {
210  /* ETHER */
214  /* S-VLAN */
217  /* C-VLAN */
220  /* IPV4 */
227  /* IPV6 */
234  /* TCP */
238  /* UDP */
242  /* SCTP */
246  /* GTPU_IP */
249  /* GTPU_EH */
253  /* PPPOE */
256  /* L2TPV3 */
259  /* ESP */
261  /* AH */
263  /* PFCP */
267 };
268 
270 {
272  u32 field_selector; /* a bit mask to select field for header type */
273  u8 buffer[64];
274  /**
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.
278  */
279 };
280 
282 
284 {
286  /**
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
291  * ....
292  **/
293  int count; /* the proto layers must < VIRTCHNL_MAX_NUM_PROTO_HDRS */
295 };
296 
298 
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.
307  */
309 {
312  u8 key[1]; /* RSS hash key, packed bytes */
313 };
314 
316 
318 {
321  u8 lut[1]; /* RSS lookup table */
322 };
323 
325 
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.
332  */
334 {
336 };
337 
339 
340 /* Type of RSS algorithm */
342 {
347 };
348 
350 {
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 */
354 };
355 
357 
359 {
360  /* action types */
369 };
370 
371 /* action configuration for FDIR */
373 {
375  union
376  {
377  /* used for queue and qgroup action */
378  struct
379  {
382  } queue;
383  /* used for count action */
384  struct
385  {
386  /* share counter ID with other flow rules */
388  u32 id; /* counter ID */
389  } count;
390  /* used for mark action */
392  u8 reserve[32];
393  } act_conf;
394 };
395 
397 
398 #define VIRTCHNL_MAX_NUM_ACTIONS 8
399 
401 {
402  /* action number must be less then VIRTCHNL_MAX_NUM_ACTIONS */
403  int count;
405 };
406 
408 
409 /* pattern and action for FDIR rule */
411 {
412  struct virtchnl_proto_hdrs proto_hdrs;
413  struct virtchnl_filter_action_set action_set;
414 };
415 
417 
418 /* query information to retrieve fdir rule counters.
419  * PF will fill out this structure to reset counter.
420  */
422 {
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. */
429 };
430 
432 
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.
437  *
438  * VIRTCHNL_FDIR_FAILURE_RULE_NORESOURCE
439  * OP_ADD_FDIR_FILTER request is failed due to no Hardware resource.
440  *
441  * VIRTCHNL_FDIR_FAILURE_RULE_EXIST
442  * OP_ADD_FDIR_FILTER request is failed due to the rule is already existed.
443  *
444  * VIRTCHNL_FDIR_FAILURE_RULE_CONFLICT
445  * OP_ADD_FDIR_FILTER request is failed due to conflict with existing rule.
446  *
447  * VIRTCHNL_FDIR_FAILURE_RULE_NONEXIST
448  * OP_DEL_FDIR_FILTER request is failed due to this rule doesn't exist.
449  *
450  * VIRTCHNL_FDIR_FAILURE_RULE_INVALID
451  * OP_ADD_FDIR_FILTER request is failed due to parameters validation
452  * or HW doesn't support.
453  *
454  * VIRTCHNL_FDIR_FAILURE_RULE_TIMEOUT
455  * OP_ADD/DEL_FDIR_FILTER request is failed due to timing out
456  * for programming.
457  *
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.
461  */
463 {
473 };
474 
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.
479  */
481 {
482  u16 vsi_id; /* INPUT */
483  /*
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.
486  */
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 */
491 };
492 
494 
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.
498  */
500 {
501  u16 vsi_id; /* INPUT */
503  u32 flow_id; /* INPUT */
504  enum virtchnl_fdir_prgm_status status; /* OUTPUT */
505 };
506 
508 
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.
513  */
515 {
516  u16 vsi_id; /* INPUT */
517  u16 pad1[3];
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 */
523 };
524 
526 
527 /**
528  * Those headers used temporary, maybe OS packet
529  * definition can replace. Add flow error, pattern
530  * and action definition.
531  */
532 
533 /**
534  * Verbose error types.
535  *
536  * Most of them provide the type of the object referenced by struct
537  * rte_flow_error.cause.
538  */
540 {
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. */
558 };
559 
560 /**
561  * Verbose error structure definition.
562  * Both cause and message may be NULL regardless of the error type.
563  */
565 {
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. */
569 };
570 
571 #define AVF_ETHER_ADDR_LEN 6
573 {
574  u8 addr_bytes[AVF_ETHER_ADDR_LEN]; /**< Addr bytes in tx order */
575 } __attribute__ ((__aligned__ (2)));
576 
578 {
579  struct avf_ether_addr dst; /**< Destination MAC. */
580  struct avf_ether_addr src; /**< Source MAC. */
581  u16 type; /**< EtherType or TPID. */
582 };
583 
584 /**
585  * IPv4 Header
586  */
588 {
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__));
600 
601 /**
602  * IPv6 Header
603  */
605 {
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__));
613 
614 /**
615  * TCP Header
616  */
618 {
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__));
629 
630 /**
631  * UDP Header
632  */
634 {
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__));
640 
641 /**
642  * Match IP Authentication Header (AH), RFC 4302
643  */
645 {
648  u32 reserved : 16;
651 };
652 
653 /**
654  * ESP Header
655  */
657 {
658  u32 spi; /**< Security Parameters Index */
659  u32 seq; /**< packet sequence number */
660 } __attribute__ ((__packed__));
661 
662 /**
663  * Match PFCP Header
664  */
666 {
671 };
672 
673 /**
674  * Matches a L2TPv3 over IP header.
675  */
677 {
678  u32 session_id; /**< Session ID. */
679 };
680 
681 /**
682  * Matches a GTP PDU extension header with type 0x85.
683  */
685 {
686  u8 pdu_type; /**< PDU type. */
687  u8 qfi; /**< QoS flow identifier. */
688 };
689 
690 /**
691  * Matches a GTPv1 header.
692  */
694 {
695  /**
696  * Version (3b), protocol type (1b), reserved (1b),
697  * Extension header flag (1b),
698  * Sequence number flag (1b),
699  * N-PDU number flag (1b).
700  */
702  u8 msg_type; /**< Message type. */
703  u16 msg_len; /**< Message length. */
704  u32 teid; /**< Tunnel endpoint identifier. */
705 };
706 
707 /**
708  * SCTP Header
709  */
711 {
712  u16 src_port; /**< Source port. */
713  u16 dst_port; /**< Destin port. */
714  u32 tag; /**< Validation tag. */
715  u32 cksum; /**< Checksum. */
716 } __attribute__ ((__packed__));
717 
718 /**
719  * Hash function types.
720  */
722 {
726  /**
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.
730  */
733 };
734 
736 {
737  enum avf_eth_hash_function func; /**< RSS hash function to apply. */
738 
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. */
745 };
746 
748 {
749  u16 index; /**< Queue index to use. */
750 };
751 
753 {
754  u32 id; /**< Integer value to return with packets. */
755 };
756 
758 {
759  enum virtchnl_action type; /**< Action type. */
760  const void *conf; /**< Pointer to action configuration object. */
761 };
762 
764 {
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. */
768 };
769 
771 {
772  struct virtchnl_fdir_add add_fltr;
773  struct virtchnl_fdir_del del_fltr;
779 };
780 
782 {
787 };
788 
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);
792 
793 /* virtual channel context object */
795 {
796  void *vc_hdl; /* virtual channel handler */
798 };
799 
800 /**
801  * Create a rule cfg object.
802  *
803  * @param rcfg
804  * created rule cfg object.
805  * @param tunnel
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.
810  * ...
811  * @param vsi
812  * avf vsi id
813  *
814  * @param nrxq
815  * the rx queue number of the avf
816  *
817  * @return
818  * 0 = successful.
819  * < 0 = failure.
820  */
821 int avf_fdir_rcfg_create (struct avf_fdir_conf **rcfg, int tunnel_level,
822  u16 vsi, u16 nrxq);
823 
824 /**
825  * Destroy a rule cfg object.
826  *
827  * @param rcfg
828  * the cfg object to destroy.
829  *
830  * @return
831  * 0 = successful.
832  * < 0 = failure.
833  */
834 int avf_fdir_rcfg_destroy (struct avf_fdir_conf *rcfg);
835 
836 /**
837  * Set match potocol header on specific layer, it will overwrite is already be
838  * set.
839  *
840  * @param rcfg
841  * the rule cfg object
842  * @param layer
843  * layer of the protocol header.
844  * @param hdr
845  * protocol header type.
846  *
847  * @return
848  * 0 = successful.
849  * < 0 = failure.
850  */
851 int avf_fdir_rcfg_set_hdr (struct avf_fdir_conf *rcfg, int layer,
852  enum virtchnl_proto_hdr_type hdr);
853 
854 /**
855  * Set a match field on specific protocol layer, if any match field already be
856  * set on this layer, it will be overwritten.
857  *
858  * @param rcfg
859  * the rule cfg object
860  * @param layer
861  * layer of the protocol header.
862  * @param item
863  * flow item
864  * @param error
865  * save error cause
866  *
867  * @return
868  * 0 = successful.
869  * < 0 = failure.
870  */
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);
874 
875 /**
876  * Set action as to queue(group), conflict with drop action.
877  *
878  * @param rcfg
879  * rule cfg object
880  * @param queue
881  * queue id.
882  * @param size
883  * queue group size, must be 2^n. 1 means only to single queue.
884  * @param act_idx
885  * action index
886  *
887  * @return
888  * 0 = successful.
889  * < 0 = failure.
890  */
891 int avf_fdir_rcfg_act_queue (struct avf_fdir_conf *rcfg, int queue, int size,
892  int act_idx);
893 
894 /**
895  * Set action as to queue group, conflict with drop action.
896  *
897  * @param rcfg
898  * the rule cfg object
899  * @param act
900  * flow actions
901  * @param act_idx
902  * action index
903  * @error
904  * save error cause
905  *
906  * @return
907  * 0 = successful.
908  * < 0 = failure.
909  */
911  const struct avf_flow_action *act,
912  int act_idx, struct avf_flow_error *error);
913 
914 /**
915  * Set action as as drop, conflict with to queue(gropu) action.
916  *
917  * @param rcfg
918  * the rule cfg object
919  * @param act_idx
920  * action index
921  *
922  * @return
923  * 0 = successful.
924  * < 0 = failure.
925  */
926 int avf_fdir_rcfg_act_drop (struct avf_fdir_conf *rcfg, int act_idx);
927 
928 /**
929  * Set action as mark, it can co-exist with to queue(group) or drop action.
930  *
931  * @param rcfg
932  * the rule cfg object
933  * @param mark
934  * a 32 bit flow mark
935  * @param act_idx
936  * action index
937  *
938  * @return
939  * 0 = successful.
940  * < 0 = failure.
941  */
942 int avf_fdir_rcfg_act_mark (struct avf_fdir_conf *rcfg, const u32 mark,
943  int act_idx);
944 
945 /**
946  * Validate a flow rule cfg, check with PF driver if the rule cfg is supportted
947  *or not.
948  *
949  * @param ctx
950  * virtual channel context
951  * @param rcfg
952  * the rule cfg object.
953  *
954  * @return
955  * 0 = successful.
956  * < 0 = failure.
957  */
959  struct avf_fdir_conf *rcfg);
960 
961 /**
962  * Create a flow rule, a FDIR rule is expected to be programmed into hardware
963  *if return success.
964  *
965  * @param ctx
966  * virtual channel context
967  * @param rcfg
968  * rule cfg object.
969  *
970  * @return
971  * 0 = successfule.
972  * < 0 = failure.
973  */
975  struct avf_fdir_conf *rcfg);
976 
977 /**
978  * Destroy a flow rule.
979  *
980  * @param ctx
981  * virtual channel context
982  * @param rcfg
983  * the rule cfg object.
984  *
985  * @return
986  * 0 = successfule.
987  * < 0 = failure.
988  */
990  struct avf_fdir_conf *rcfg);
991 
992 /*
993  * Parse avf patterns and set pattern fields.
994  *
995  * @param rcfg
996  * flow config
997  * @param avf_items
998  * pattern items
999  * @param error
1000  * save error cause
1001  *
1002  * @return
1003  * 0 = successful.
1004  * < 0 = failure
1005  */
1006 int avf_fdir_parse_pattern (struct avf_fdir_conf *rcfg,
1007  struct avf_flow_item avf_items[],
1008  struct avf_flow_error *error);
1009 
1010 /*
1011  * Parse flow actions, set actions.
1012  *
1013  * @param actions
1014  * flow actions
1015  * @param rcfg
1016  * flow config
1017  * @param error
1018  * save error cause
1019  *
1020  * @return
1021  * 0 = successful.
1022  * < 0 = failure
1023  */
1024 int avf_fdir_parse_action (const struct avf_flow_action actions[],
1025  struct avf_fdir_conf *rcfg,
1026  struct avf_flow_error *error);
1027 
1028 /**
1029  * Initialize flow error structure.
1030  *
1031  * @param[out] error
1032  * Pointer to flow error structure (may be NULL).
1033  * @param code
1034  * Related error code
1035  * @param type
1036  * Cause field and error types.
1037  * @param cause
1038  * Object responsible for the error.
1039  * @param message
1040  * Human-readable error message.
1041  *
1042  * @return
1043  * Negative error code (errno value)
1044  */
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);
1048 
1049 /*
1050  * decode the error number to Verbose error string
1051  *
1052  * @param err_no
1053  * error number
1054  *
1055  * @return
1056  * Verbose error string
1057  */
1058 char *avf_fdir_prgm_error_decode (int err_no);
1059 
1060 #endif /* _AVF_ADVANCED_FLOW_H_ */
1061 
1062 /*
1063  * fd.io coding-style-patch-verification: ON
1064  *
1065  * Local Variables:
1066  * eval: (c-set-style "gnu")
1067  * End:
1068  */
u16 src_port
Source port.
const void * cause
Object responsible for the error.
const u16 * queue
Queue indices to use.
u32 id
Integer value to return with packets.
virtchnl_proto_hdr_field
const void * mask
Bit-mask applied to spec and last.
int avf_fdir_parse_action_qregion(struct avf_fdir_conf *rcfg, const struct avf_flow_action *act, int act_idx, struct avf_flow_error *error)
Set action as to queue group, conflict with drop action.
Definition: avf_fdir_lib.c:507
u16 payload_len
IP packet length - includes header size.
u8 tcp_flags
TCP flags.
SCTP Header.
const u8 * key
Hash key.
unsigned long u64
Definition: types.h:89
#define VIRTCHNL_MAX_NUM_PROTO_HDRS
int avf_fdir_rcfg_set_hdr(struct avf_fdir_conf *rcfg, int layer, enum virtchnl_proto_hdr_type hdr)
Set match potocol header on specific layer, it will overwrite is already be set.
Definition: avf_fdir_lib.c:70
Matches a L2TPv3 over IP header.
virtchnl_proto_hdr_type
int avf_fdir_parse_action(const struct avf_flow_action actions[], struct avf_fdir_conf *rcfg, struct avf_flow_error *error)
Definition: avf_fdir_lib.c:672
u16 dst_port
Destin port.
vl_api_address_t src
Definition: gre.api:54
u16 dst_port
TCP destination port.
int avf_fdir_rcfg_validate(struct avf_fdir_vc_ctx *ctx, struct avf_fdir_conf *rcfg)
Validate a flow rule cfg, check with PF driver if the rule cfg is supportted or not.
Definition: avf_fdir_lib.c:594
int avf_fdir_rcfg_create(struct avf_fdir_conf **rcfg, int tunnel_level, u16 vsi, u16 nrxq)
Create a rule cfg object.
Definition: avf_fdir_lib.c:43
int count
specify where protocol header start from.
int avf_fdir_rcfg_act_queue(struct avf_fdir_conf *rcfg, int queue, int size, int act_idx)
Set action as to queue(group), conflict with drop action.
Definition: avf_fdir_lib.c:486
u8 v_pt_rsv_flags
Version (3b), protocol type (1b), reserved (1b), Extension header flag (1b), Sequence number flag (1b...
u8 time_to_live
time to live
unsigned char u8
Definition: types.h:56
int avf_flow_error_set(struct avf_flow_error *error, int code, enum avf_flow_error_type type, const void *cause, const char *message)
Initialize flow error structure.
Definition: avf_fdir_lib.c:810
avf_flow_error_type
Those headers used temporary, maybe OS packet definition can replace.
u16 cksum
TCP checksum.
unsigned int u32
Definition: types.h:88
avf_eth_hash_function
Hash function types.
u16 src_port
UDP source port.
Verbose error structure definition.
u8 pdu_type
PDU type.
UDP Header.
u8 version_ihl
version and header length
#define PROTO_HDR_FIELD_START(proto_hdr_type)
u8 proto
Protocol, next header.
const void * conf
Pointer to action configuration object.
u16 packet_id
packet ID
u32 vtc_flow
IP version, traffic class & flow label.
u32 spi
Security Parameters Index.
Item specification mask.
u8 qfi
QoS flow identifier.
u16 total_length
length of packet
int avf_fdir_rcfg_act_mark(struct avf_fdir_conf *rcfg, const u32 mark, int act_idx)
Set action as mark, it can co-exist with to queue(group) or drop action.
Definition: avf_fdir_lib.c:578
int(* avf_fdir_vc_op_t)(void *vc_hdl, enum virthnl_adv_ops vc_op, void *in, u32 in_len, void *out, u32 out_len)
Definition: cJSON.c:88
Match PFCP Header.
u8 hop_limits
Hop limits.
u16 rx_win
RX flow control window.
u32 seq
packet sequence number
u16 tcp_urp
TCP urgent pointer, if any.
virtchnl_fdir_prgm_status
long ctx[MAX_CONNS]
Definition: main.c:144
const void * spec
Pointer to item specification structure.
unsigned short u16
Definition: types.h:57
u8 msg_type
Message type.
u32 size
Definition: vhost_user.h:125
ESP Header.
u16 dst_port
UDP destination port.
virtchnl_rss_algorithm
vl_api_mac_address_t src_addr
Definition: flow_types.api:64
Specific pattern item.
int avf_fdir_rcfg_destroy(struct avf_fdir_conf *rcfg)
Destroy a rule cfg object.
Definition: avf_fdir_lib.c:62
u16 src_port
TCP source port.
u16 dgram_len
UDP datagram length.
u16 fragment_offset
fragmentation offset
u16 type
EtherType or TPID.
u32 sent_seq
TX data sequence number.
u32 recv_ack
RX data acknowledgment sequence number.
vl_api_mac_address_t dst_addr
Definition: flow_types.api:65
TCP Header.
virthnl_adv_ops
IPv6 Header.
u32 tag
Validation tag.
Matches a GTPv1 header.
u32 session_id
Session ID.
#define VIRTCHNL_CHECK_STRUCT_LEN(n, X)
u8 next_proto_id
protocol ID
u32 dst_addr
destination address
IPv4 Header.
u16 index
Queue index to use.
cJSON * item
Definition: cJSON.h:222
u32 cksum
Checksum.
Symmetric Toeplitz: src, dst will be replaced by xor(src, dst).
u8 data_off
Data offset.
Matches a GTP PDU extension header with type 0x85.
avf_fdir_vc_op_t vc_op
u8 type_of_service
type of service
virtchnl_action
char * avf_fdir_prgm_error_decode(int err_no)
Definition: avf_fdir_lib.c:827
u32 teid
Tunnel endpoint identifier.
typedef key
Definition: ipsec_types.api:88
int avf_fdir_rcfg_set_field(struct avf_fdir_conf *rcfg, int layer, struct avf_flow_item *item, struct avf_flow_error *error)
Set a match field on specific protocol layer, if any match field already be set on this layer...
Definition: avf_fdir_lib.c:85
u16 hdr_checksum
header checksum
int avf_fdir_rule_create(struct avf_fdir_vc_ctx *ctx, struct avf_fdir_conf *rcfg)
Create a flow rule, a FDIR rule is expected to be programmed into hardware if return success...
Definition: avf_fdir_lib.c:620
u32 key_len
Hash key length in bytes.
Item specification range.
#define AVF_ETHER_ADDR_LEN
#define VIRTCHNL_MAX_NUM_ACTIONS
int avf_fdir_parse_pattern(struct avf_fdir_conf *rcfg, struct avf_flow_item avf_items[], struct avf_flow_error *error)
Definition: avf_fdir_lib.c:789
vl_api_ip4_address_t dst
Definition: pnat.api:41
int avf_fdir_rule_destroy(struct avf_fdir_vc_ctx *ctx, struct avf_fdir_conf *rcfg)
Destroy a flow rule.
Definition: avf_fdir_lib.c:647
u8 count
Definition: dhcp.api:208
const char * message
Human-readable error message.
u32 queue_num
Number of entries in queue.
u32 src_addr
source address
u16 msg_len
Message length.
u16 dgram_cksum
UDP datagram checksum.
enum virtchnl_proto_hdr_type type
Attributes structure.
Match IP Authentication Header (AH), RFC 4302.
u64 types
Specific RSS hash types (see ETH_RSS_*).
int avf_fdir_rcfg_act_drop(struct avf_fdir_conf *rcfg, int act_idx)
Set action as as drop, conflict with to queue(gropu) action.
Definition: avf_fdir_lib.c:564