|
FD.io VPP
v21.06-3-gbb25fbf28
Vector Packet Processing
|
Go to the documentation of this file.
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))
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) \
44 #define AVF_ETHER_TYPE_IPV4 0x0800
45 #define AVF_ETHER_TYPE_IPV6 0x86DD
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)
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)
398 #define VIRTCHNL_MAX_NUM_ACTIONS 8
571 #define AVF_ETHER_ADDR_LEN 6
575 } __attribute__ ((__aligned__ (2)));
599 } __attribute__ ((__packed__));
612 } __attribute__ ((__packed__));
628 } __attribute__ ((__packed__));
639 } __attribute__ ((__packed__));
660 } __attribute__ ((__packed__));
716 } __attribute__ ((__packed__));
791 void *in,
u32 in_len,
void *out,
u32 out_len);
1047 const char *message);
#define VIRTCHNL_MAX_NUM_ACTIONS
@ VIRTCHNL_PROTO_HDR_ETH_ETHERTYPE
u16 dst_port
UDP destination port.
@ VIRTCHNL_FDIR_FAILURE_MAX
@ VIRTCHNL_PROTO_HDR_GTPU_EH_PDU_UP
@ VIRTCHNL_PROTO_HDR_S_VLAN
struct virtchnl_proto_hdrs proto_hdrs
u8 type_of_service
type of service
@ VIRTCHNL_PROTO_HDR_L2TPV3_SESS_ID
u8 qfi
QoS flow identifier.
@ VIRTCHNL_PROTO_HDR_IPV6_DST
@ VIRTCHNL_FDIR_FAILURE_RULE_TIMEOUT
@ VIRTCHNL_PROTO_HDR_GTPU_IP
@ AVF_FLOW_ERROR_TYPE_ACTION_CONF
Action configuration.
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.
@ VIRTCHNL_ACTION_PASSTHRU
@ VIRTCHNL_ACTION_Q_REGION
@ AVF_FLOW_ERROR_TYPE_ATTR_EGRESS
Egress field.
@ AVF_FLOW_ERROR_TYPE_UNSPECIFIED
Cause unspecified.
@ VIRTCHNL_PROTO_HDR_IPV4_TTL
u16 fragment_offset
fragmentation offset
@ AVF_FLOW_ERROR_TYPE_ITEM_MASK
Item specification mask.
@ VIRTCHNL_ADV_OP_QUERY_FDIR_FILTER
@ VIRTCHNL_PROTO_HDR_TCP_DST_PORT
@ VIRTCHNL_FDIR_FAILURE_QUERY_INVALID
avf_eth_hash_function
Hash function types.
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.
const void * cause
Object responsible for the error.
@ AVF_FLOW_ERROR_TYPE_HANDLE
Flow rule (handle).
u32 dst_addr
destination address
enum virtchnl_action type
u16 index
Queue index to use.
u32 seq
packet sequence number
@ VIRTCHNL_PROTO_HDR_GTPU_EH_QFI
avf_flow_error_type
Those headers used temporary, maybe OS packet definition can replace.
@ AVF_FLOW_ERROR_TYPE_ITEM_NUM
Pattern length.
u32 sent_seq
TX data sequence number.
Matches a GTP PDU extension header with type 0x85.
enum avf_flow_error_type type
Cause field and error types.
@ VIRTCHNL_RSS_ALG_TOEPLITZ_ASYMMETRIC
int avf_fdir_parse_action(const struct avf_flow_action actions[], struct avf_fdir_conf *rcfg, struct avf_flow_error *error)
@ AVF_ETH_HASH_FUNCTION_DEFAULT
@ VIRTCHNL_PROTO_HDR_GTPU_EH
u32 vtc_flow
IP version, traffic class & flow label.
@ VIRTCHNL_PROTO_HDR_PPPOE_SESS_ID
Match IP Authentication Header (AH), RFC 4302.
int avf_fdir_rcfg_create(struct avf_fdir_conf **rcfg, int tunnel_level, u16 vsi, u16 nrxq)
Create a rule cfg object.
u32 src_addr
source address
@ AVF_FLOW_ERROR_TYPE_ITEM_SPEC
Item specification.
@ VIRTCHNL_ADV_OP_DEL_FDIR_FILTER
@ VIRTCHNL_PROTO_HDR_IPV4
@ VIRTCHNL_RSS_ALG_TOEPLITZ_SYMMETRIC
@ VIRTCHNL_PROTO_HDR_GTPU_IP_TEID
u16 dgram_len
UDP datagram length.
#define VIRTCHNL_MAX_NUM_PROTO_HDRS
u16 type
EtherType or TPID.
@ VIRTCHNL_ACTION_TC_REDIRECT
@ AVF_FLOW_ERROR_TYPE_ATTR_INGRESS
Ingress field.
@ VIRTCHNL_PROTO_HDR_SCTP_SRC_PORT
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.
u16 hdr_checksum
header checksum
@ VIRTCHNL_PROTO_HDR_C_VLAN_ID
u8 next_proto_id
protocol ID
u32 session_id
Session ID.
int count
specify where protocol header start from.
@ VIRTCHNL_PROTO_HDR_IPV6
u8 version_ihl
version and header length
@ AVF_ETH_HASH_FUNCTION_MAX
@ VIRTCHNL_PROTO_HDR_IPV4_SRC
enum virtchnl_fdir_prgm_status status
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)
@ VIRTCHNL_PROTO_HDR_L2TPV3
u16 msg_len
Message length.
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.
@ VIRTCHNL_RSS_ALG_XOR_ASYMMETRIC
struct virtchnl_filter_action actions[VIRTCHNL_MAX_NUM_ACTIONS]
enum virtchnl_fdir_prgm_status status
const void * spec
Pointer to item specification structure.
u32 spi
Security Parameters Index.
u32 id
Integer value to return with packets.
union virtchnl_filter_action::@32 act_conf
#define PROTO_HDR_FIELD_START(proto_hdr_type)
u8 v_pt_rsv_flags
Version (3b), protocol type (1b), reserved (1b), Extension header flag (1b), Sequence number flag (1b...
@ AVF_FLOW_ERROR_TYPE_ATTR_PRIORITY
Priority field.
@ VIRTCHNL_PROTO_HDR_SCTP
@ AVF_FLOW_ERROR_TYPE_ATTR_TRANSFER
Transfer field.
@ VIRTCHNL_PROTO_HDR_IPV4_PROT
virtchnl_fdir_prgm_status
@ VIRTCHNL_PROTO_HDR_PFCP
@ VIRTCHNL_PROTO_HDR_IPV6_HOP_LIMIT
@ AVF_FLOW_ERROR_TYPE_ACTION
Specific action.
@ VIRTCHNL_PROTO_HDR_AH_SPI
u16 src_port
UDP source port.
Verbose error structure definition.
@ VIRTCHNL_PROTO_HDR_PFCP_SEID
@ VIRTCHNL_RSS_ALG_XOR_SYMMETRIC
struct virtchnl_fdir_rule rule_cfg
struct avf_ether_addr dst
Destination MAC.
int avf_fdir_rcfg_destroy(struct avf_fdir_conf *rcfg)
Destroy a rule cfg object.
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.
@ AVF_FLOW_ERROR_TYPE_ATTR_GROUP
Group field.
@ AVF_ETH_HASH_FUNCTION_TOEPLITZ
Toeplitz.
@ VIRTCHNL_PROTO_HDR_GTPU_EH_PDU
Matches a L2TPv3 over IP header.
u8 src_addr[16]
IP address of source host.
@ AVF_FLOW_ERROR_TYPE_ITEM
Specific pattern item.
struct virtchnl_fdir_query_info query_info
@ VIRTCHNL_PROTO_HDR_IPV4_DST
enum virtchnl_fdir_prgm_status status
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.
@ VIRTCHNL_PROTO_HDR_IPV6_TC
@ VIRTCHNL_PROTO_HDR_IPV4_DSCP
u16 src_port
TCP source port.
@ AVF_FLOW_ERROR_TYPE_ATTR
Attributes structure.
u16 dgram_cksum
UDP datagram checksum.
u8 time_to_live
time to live
@ AVF_FLOW_ERROR_TYPE_ITEM_LAST
Item specification range.
@ AVF_FLOW_ERROR_TYPE_ACTION_NUM
Number of actions.
@ VIRTCHNL_PROTO_HDR_UDP_SRC_PORT
@ VIRTCHNL_PROTO_HDR_PPPOE
int avf_fdir_rule_destroy(struct avf_fdir_vc_ctx *ctx, struct avf_fdir_conf *rcfg)
Destroy a flow rule.
@ VIRTCHNL_FDIR_FAILURE_RULE_CONFLICT
enum virtchnl_proto_hdr_type type
Item type.
struct virtchnl_proto_hdr proto_hdr[VIRTCHNL_MAX_NUM_PROTO_HDRS]
#define VIRTCHNL_CHECK_STRUCT_LEN(n, X)
@ VIRTCHNL_PROTO_HDR_PFCP_S_FIELD
@ VIRTCHNL_PROTO_HDR_NONE
vl_api_flow_action_t actions
@ VIRTCHNL_PROTO_HDR_IPV6_PROT
struct virtchnl_filter_action::@32::@34 count
@ VIRTCHNL_PROTO_HDR_ETH_DST
@ VIRTCHNL_PROTO_HDR_UDP_DST_PORT
@ VIRTCHNL_FDIR_FAILURE_RULE_INVALID
const void * conf
Pointer to action configuration object.
struct avf_ether_addr src
Source MAC.
@ VIRTCHNL_PROTO_HDR_C_VLAN
@ AVF_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ
Symmetric Toeplitz: src, dst will be replaced by xor(src, dst).
@ VIRTCHNL_PROTO_HDR_ETH_SRC
u32 teid
Tunnel endpoint identifier.
@ VIRTCHNL_FDIR_FAILURE_RULE_NONEXIST
@ VIRTCHNL_PROTO_HDR_GTPU_EH_PDU_DWN
@ AVF_FLOW_ERROR_TYPE_NONE
No error.
u16 total_length
length of packet
struct virtchnl_fdir_add add_fltr
@ VIRTCHNL_FDIR_FAILURE_RULE_NORESOURCE
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,...
u16 rx_win
RX flow control window.
u16 tcp_urp
TCP urgent pointer, if any.
@ VIRTCHNL_FDIR_FAILURE_RULE_EXIST
@ VIRTCHNL_PROTO_HDR_ESP_SPI
@ VIRTCHNL_PROTO_HDR_IPV6_SRC
struct virtchnl_fdir_del del_fltr
struct virtchnl_filter_action::@32::@33 queue
#define AVF_ETHER_ADDR_LEN
u32 recv_ack
RX data acknowledgment sequence number.
enum virtchnl_action type
Action type.
enum virtchnl_proto_hdr_type type
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.
@ AVF_ETH_HASH_FUNCTION_SIMPLE_XOR
Simple XOR.
int avf_fdir_parse_pattern(struct avf_fdir_conf *rcfg, struct avf_flow_item avf_items[], struct avf_flow_error *error)
char * avf_fdir_prgm_error_decode(int err_no)
u8 dst_addr[16]
IP address of destination host(s).
@ VIRTCHNL_PROTO_HDR_TCP_SRC_PORT
u16 payload_len
IP packet length - includes header size.
u16 dst_port
TCP destination port.
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.
vl_api_fib_path_type_t type
const char * message
Human-readable error message.
@ VIRTCHNL_PROTO_HDR_SCTP_DST_PORT
const void * mask
Bit-mask applied to spec and last.
u8 proto
Protocol, next header.
@ VIRTCHNL_ADV_OP_ADD_FDIR_FILTER
u8 addr_bytes[AVF_ETHER_ADDR_LEN]
Addr bytes in tx order.
@ VIRTCHNL_PROTO_HDR_S_VLAN_ID
struct virtchnl_filter_action_set action_set