xref: /dpdk/lib/ethdev/rte_eth_ctrl.h (revision 719834a6849e1daf4a70ff7742bbcc3ae7e25607)
199a2dd95SBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause
299a2dd95SBruce Richardson  * Copyright(c) 2010-2015 Intel Corporation
399a2dd95SBruce Richardson  */
499a2dd95SBruce Richardson 
599a2dd95SBruce Richardson #ifndef _RTE_ETH_CTRL_H_
699a2dd95SBruce Richardson #define _RTE_ETH_CTRL_H_
799a2dd95SBruce Richardson 
899a2dd95SBruce Richardson #include <stdint.h>
999a2dd95SBruce Richardson #include <rte_common.h>
1099a2dd95SBruce Richardson #include <rte_ether.h>
1199a2dd95SBruce Richardson #include "rte_flow.h"
1299a2dd95SBruce Richardson #include "rte_ethdev.h"
1399a2dd95SBruce Richardson 
1499a2dd95SBruce Richardson /**
1599a2dd95SBruce Richardson  * @deprecated Please use rte_flow API instead of this legacy one.
1699a2dd95SBruce Richardson  * @file
1799a2dd95SBruce Richardson  *
1899a2dd95SBruce Richardson  * Ethernet device features and related data structures used
1999a2dd95SBruce Richardson  * by control APIs should be defined in this file.
2099a2dd95SBruce Richardson  */
2199a2dd95SBruce Richardson 
2299a2dd95SBruce Richardson /**
2399a2dd95SBruce Richardson  * Define all structures for ntuple Filter type.
2499a2dd95SBruce Richardson  */
2599a2dd95SBruce Richardson 
2699a2dd95SBruce Richardson #define RTE_NTUPLE_FLAGS_DST_IP    0x0001 /**< If set, dst_ip is part of ntuple */
2799a2dd95SBruce Richardson #define RTE_NTUPLE_FLAGS_SRC_IP    0x0002 /**< If set, src_ip is part of ntuple */
2899a2dd95SBruce Richardson #define RTE_NTUPLE_FLAGS_DST_PORT  0x0004 /**< If set, dst_port is part of ntuple */
2999a2dd95SBruce Richardson #define RTE_NTUPLE_FLAGS_SRC_PORT  0x0008 /**< If set, src_port is part of ntuple */
3099a2dd95SBruce Richardson #define RTE_NTUPLE_FLAGS_PROTO     0x0010 /**< If set, protocol is part of ntuple */
3199a2dd95SBruce Richardson #define RTE_NTUPLE_FLAGS_TCP_FLAG  0x0020 /**< If set, tcp flag is involved */
3299a2dd95SBruce Richardson 
3399a2dd95SBruce Richardson #define RTE_5TUPLE_FLAGS ( \
3499a2dd95SBruce Richardson 		RTE_NTUPLE_FLAGS_DST_IP | \
3599a2dd95SBruce Richardson 		RTE_NTUPLE_FLAGS_SRC_IP | \
3699a2dd95SBruce Richardson 		RTE_NTUPLE_FLAGS_DST_PORT | \
3799a2dd95SBruce Richardson 		RTE_NTUPLE_FLAGS_SRC_PORT | \
3899a2dd95SBruce Richardson 		RTE_NTUPLE_FLAGS_PROTO)
3999a2dd95SBruce Richardson 
4099a2dd95SBruce Richardson #define RTE_2TUPLE_FLAGS ( \
4199a2dd95SBruce Richardson 		RTE_NTUPLE_FLAGS_DST_PORT | \
4299a2dd95SBruce Richardson 		RTE_NTUPLE_FLAGS_PROTO)
4399a2dd95SBruce Richardson 
4499a2dd95SBruce Richardson #define RTE_NTUPLE_TCP_FLAGS_MASK 0x3F /**< TCP flags filter can match. */
4599a2dd95SBruce Richardson 
4699a2dd95SBruce Richardson /**
4799a2dd95SBruce Richardson  * A structure used to define the ntuple filter entry
4899a2dd95SBruce Richardson  * to support RTE_ETH_FILTER_NTUPLE data representation.
4999a2dd95SBruce Richardson  */
5099a2dd95SBruce Richardson struct rte_eth_ntuple_filter {
5199a2dd95SBruce Richardson 	uint16_t flags;          /**< Flags from RTE_NTUPLE_FLAGS_* */
5299a2dd95SBruce Richardson 	uint32_t dst_ip;         /**< Destination IP address in big endian. */
5399a2dd95SBruce Richardson 	uint32_t dst_ip_mask;    /**< Mask of destination IP address. */
5499a2dd95SBruce Richardson 	uint32_t src_ip;         /**< Source IP address in big endian. */
5599a2dd95SBruce Richardson 	uint32_t src_ip_mask;    /**< Mask of destination IP address. */
5699a2dd95SBruce Richardson 	uint16_t dst_port;       /**< Destination port in big endian. */
5799a2dd95SBruce Richardson 	uint16_t dst_port_mask;  /**< Mask of destination port. */
5899a2dd95SBruce Richardson 	uint16_t src_port;       /**< Source Port in big endian. */
5999a2dd95SBruce Richardson 	uint16_t src_port_mask;  /**< Mask of source port. */
6099a2dd95SBruce Richardson 	uint8_t proto;           /**< L4 protocol. */
6199a2dd95SBruce Richardson 	uint8_t proto_mask;      /**< Mask of L4 protocol. */
6299a2dd95SBruce Richardson 	/** tcp_flags only meaningful when the proto is TCP.
6399a2dd95SBruce Richardson 	    The packet matched above ntuple fields and contain
6499a2dd95SBruce Richardson 	    any set bit in tcp_flags will hit this filter. */
6599a2dd95SBruce Richardson 	uint8_t tcp_flags;
6699a2dd95SBruce Richardson 	uint16_t priority;       /**< seven levels (001b-111b), 111b is highest,
6799a2dd95SBruce Richardson 				      used when more than one filter matches. */
6899a2dd95SBruce Richardson 	uint16_t queue;          /**< Queue assigned to when match*/
6999a2dd95SBruce Richardson };
7099a2dd95SBruce Richardson 
7199a2dd95SBruce Richardson #define RTE_ETH_FDIR_MAX_FLEXLEN 16  /**< Max length of flexbytes. */
7299a2dd95SBruce Richardson #define RTE_ETH_INSET_SIZE_MAX   128 /**< Max length of input set. */
7399a2dd95SBruce Richardson 
7499a2dd95SBruce Richardson /**
7599a2dd95SBruce Richardson  * Input set fields for Flow Director and Hash filters
7699a2dd95SBruce Richardson  */
7799a2dd95SBruce Richardson enum rte_eth_input_set_field {
7899a2dd95SBruce Richardson 	RTE_ETH_INPUT_SET_UNKNOWN = 0,
7999a2dd95SBruce Richardson 
8099a2dd95SBruce Richardson 	/* L2 */
8199a2dd95SBruce Richardson 	RTE_ETH_INPUT_SET_L2_SRC_MAC = 1,
8299a2dd95SBruce Richardson 	RTE_ETH_INPUT_SET_L2_DST_MAC,
8399a2dd95SBruce Richardson 	RTE_ETH_INPUT_SET_L2_OUTER_VLAN,
8499a2dd95SBruce Richardson 	RTE_ETH_INPUT_SET_L2_INNER_VLAN,
8599a2dd95SBruce Richardson 	RTE_ETH_INPUT_SET_L2_ETHERTYPE,
8699a2dd95SBruce Richardson 
8799a2dd95SBruce Richardson 	/* L3 */
8899a2dd95SBruce Richardson 	RTE_ETH_INPUT_SET_L3_SRC_IP4 = 129,
8999a2dd95SBruce Richardson 	RTE_ETH_INPUT_SET_L3_DST_IP4,
9099a2dd95SBruce Richardson 	RTE_ETH_INPUT_SET_L3_SRC_IP6,
9199a2dd95SBruce Richardson 	RTE_ETH_INPUT_SET_L3_DST_IP6,
9299a2dd95SBruce Richardson 	RTE_ETH_INPUT_SET_L3_IP4_TOS,
9399a2dd95SBruce Richardson 	RTE_ETH_INPUT_SET_L3_IP4_PROTO,
9499a2dd95SBruce Richardson 	RTE_ETH_INPUT_SET_L3_IP6_TC,
9599a2dd95SBruce Richardson 	RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER,
9699a2dd95SBruce Richardson 	RTE_ETH_INPUT_SET_L3_IP4_TTL,
9799a2dd95SBruce Richardson 	RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS,
9899a2dd95SBruce Richardson 
9999a2dd95SBruce Richardson 	/* L4 */
10099a2dd95SBruce Richardson 	RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT = 257,
10199a2dd95SBruce Richardson 	RTE_ETH_INPUT_SET_L4_UDP_DST_PORT,
10299a2dd95SBruce Richardson 	RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT,
10399a2dd95SBruce Richardson 	RTE_ETH_INPUT_SET_L4_TCP_DST_PORT,
10499a2dd95SBruce Richardson 	RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT,
10599a2dd95SBruce Richardson 	RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT,
10699a2dd95SBruce Richardson 	RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG,
10799a2dd95SBruce Richardson 
10899a2dd95SBruce Richardson 	/* Tunnel */
10999a2dd95SBruce Richardson 	RTE_ETH_INPUT_SET_TUNNEL_L2_INNER_DST_MAC = 385,
11099a2dd95SBruce Richardson 	RTE_ETH_INPUT_SET_TUNNEL_L2_INNER_SRC_MAC,
11199a2dd95SBruce Richardson 	RTE_ETH_INPUT_SET_TUNNEL_L2_INNER_VLAN,
11299a2dd95SBruce Richardson 	RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY,
11399a2dd95SBruce Richardson 	RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY,
11499a2dd95SBruce Richardson 
11599a2dd95SBruce Richardson 	/* Flexible Payload */
11699a2dd95SBruce Richardson 	RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD = 641,
11799a2dd95SBruce Richardson 	RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD,
11899a2dd95SBruce Richardson 	RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD,
11999a2dd95SBruce Richardson 	RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD,
12099a2dd95SBruce Richardson 	RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD,
12199a2dd95SBruce Richardson 	RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD,
12299a2dd95SBruce Richardson 	RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD,
12399a2dd95SBruce Richardson 	RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD,
12499a2dd95SBruce Richardson 
12599a2dd95SBruce Richardson 	RTE_ETH_INPUT_SET_DEFAULT = 65533,
12699a2dd95SBruce Richardson 	RTE_ETH_INPUT_SET_NONE = 65534,
12799a2dd95SBruce Richardson 	RTE_ETH_INPUT_SET_MAX = 65535,
12899a2dd95SBruce Richardson };
12999a2dd95SBruce Richardson 
13099a2dd95SBruce Richardson /**
13199a2dd95SBruce Richardson  * Filters input set operations
13299a2dd95SBruce Richardson  */
13399a2dd95SBruce Richardson enum rte_filter_input_set_op {
13499a2dd95SBruce Richardson 	RTE_ETH_INPUT_SET_OP_UNKNOWN,
13599a2dd95SBruce Richardson 	RTE_ETH_INPUT_SET_SELECT, /**< select input set */
13699a2dd95SBruce Richardson 	RTE_ETH_INPUT_SET_ADD,    /**< add input set entry */
13799a2dd95SBruce Richardson 	RTE_ETH_INPUT_SET_OP_MAX
13899a2dd95SBruce Richardson };
13999a2dd95SBruce Richardson 
14099a2dd95SBruce Richardson 
14199a2dd95SBruce Richardson /**
14299a2dd95SBruce Richardson  * A structure used to define the input set configuration for
14399a2dd95SBruce Richardson  * flow director and hash filters
14499a2dd95SBruce Richardson  */
14599a2dd95SBruce Richardson struct rte_eth_input_set_conf {
14699a2dd95SBruce Richardson 	uint16_t flow_type;
14799a2dd95SBruce Richardson 	uint16_t inset_size;
14899a2dd95SBruce Richardson 	enum rte_eth_input_set_field field[RTE_ETH_INSET_SIZE_MAX];
14999a2dd95SBruce Richardson 	enum rte_filter_input_set_op op;
15099a2dd95SBruce Richardson };
15199a2dd95SBruce Richardson 
15299a2dd95SBruce Richardson /**
15399a2dd95SBruce Richardson  * A structure used to define the input for L2 flow
15499a2dd95SBruce Richardson  */
15599a2dd95SBruce Richardson struct rte_eth_l2_flow {
15699a2dd95SBruce Richardson 	uint16_t ether_type;          /**< Ether type in big endian */
15799a2dd95SBruce Richardson };
15899a2dd95SBruce Richardson 
15999a2dd95SBruce Richardson /**
16099a2dd95SBruce Richardson  * A structure used to define the input for IPV4 flow
16199a2dd95SBruce Richardson  */
16299a2dd95SBruce Richardson struct rte_eth_ipv4_flow {
16399a2dd95SBruce Richardson 	uint32_t src_ip;      /**< IPv4 source address in big endian. */
16499a2dd95SBruce Richardson 	uint32_t dst_ip;      /**< IPv4 destination address in big endian. */
16599a2dd95SBruce Richardson 	uint8_t  tos;         /**< Type of service to match. */
16699a2dd95SBruce Richardson 	uint8_t  ttl;         /**< Time to live to match. */
16799a2dd95SBruce Richardson 	uint8_t  proto;       /**< Protocol, next header in big endian. */
16899a2dd95SBruce Richardson };
16999a2dd95SBruce Richardson 
17099a2dd95SBruce Richardson /**
17199a2dd95SBruce Richardson  * A structure used to define the input for IPV4 UDP flow
17299a2dd95SBruce Richardson  */
17399a2dd95SBruce Richardson struct rte_eth_udpv4_flow {
17499a2dd95SBruce Richardson 	struct rte_eth_ipv4_flow ip; /**< IPv4 fields to match. */
17599a2dd95SBruce Richardson 	uint16_t src_port;           /**< UDP source port in big endian. */
17699a2dd95SBruce Richardson 	uint16_t dst_port;           /**< UDP destination port in big endian. */
17799a2dd95SBruce Richardson };
17899a2dd95SBruce Richardson 
17999a2dd95SBruce Richardson /**
18099a2dd95SBruce Richardson  * A structure used to define the input for IPV4 TCP flow
18199a2dd95SBruce Richardson  */
18299a2dd95SBruce Richardson struct rte_eth_tcpv4_flow {
18399a2dd95SBruce Richardson 	struct rte_eth_ipv4_flow ip; /**< IPv4 fields to match. */
18499a2dd95SBruce Richardson 	uint16_t src_port;           /**< TCP source port in big endian. */
18599a2dd95SBruce Richardson 	uint16_t dst_port;           /**< TCP destination port in big endian. */
18699a2dd95SBruce Richardson };
18799a2dd95SBruce Richardson 
18899a2dd95SBruce Richardson /**
18999a2dd95SBruce Richardson  * A structure used to define the input for IPV4 SCTP flow
19099a2dd95SBruce Richardson  */
19199a2dd95SBruce Richardson struct rte_eth_sctpv4_flow {
19299a2dd95SBruce Richardson 	struct rte_eth_ipv4_flow ip; /**< IPv4 fields to match. */
19399a2dd95SBruce Richardson 	uint16_t src_port;           /**< SCTP source port in big endian. */
19499a2dd95SBruce Richardson 	uint16_t dst_port;           /**< SCTP destination port in big endian. */
19599a2dd95SBruce Richardson 	uint32_t verify_tag;         /**< Verify tag in big endian */
19699a2dd95SBruce Richardson };
19799a2dd95SBruce Richardson 
19899a2dd95SBruce Richardson /**
19999a2dd95SBruce Richardson  * A structure used to define the input for IPV6 flow
20099a2dd95SBruce Richardson  */
20199a2dd95SBruce Richardson struct rte_eth_ipv6_flow {
20299a2dd95SBruce Richardson 	uint32_t src_ip[4];      /**< IPv6 source address in big endian. */
20399a2dd95SBruce Richardson 	uint32_t dst_ip[4];      /**< IPv6 destination address in big endian. */
20499a2dd95SBruce Richardson 	uint8_t  tc;             /**< Traffic class to match. */
20599a2dd95SBruce Richardson 	uint8_t  proto;          /**< Protocol, next header to match. */
20699a2dd95SBruce Richardson 	uint8_t  hop_limits;     /**< Hop limits to match. */
20799a2dd95SBruce Richardson };
20899a2dd95SBruce Richardson 
20999a2dd95SBruce Richardson /**
21099a2dd95SBruce Richardson  * A structure used to define the input for IPV6 UDP flow
21199a2dd95SBruce Richardson  */
21299a2dd95SBruce Richardson struct rte_eth_udpv6_flow {
21399a2dd95SBruce Richardson 	struct rte_eth_ipv6_flow ip; /**< IPv6 fields to match. */
21499a2dd95SBruce Richardson 	uint16_t src_port;           /**< UDP source port in big endian. */
21599a2dd95SBruce Richardson 	uint16_t dst_port;           /**< UDP destination port in big endian. */
21699a2dd95SBruce Richardson };
21799a2dd95SBruce Richardson 
21899a2dd95SBruce Richardson /**
21999a2dd95SBruce Richardson  * A structure used to define the input for IPV6 TCP flow
22099a2dd95SBruce Richardson  */
22199a2dd95SBruce Richardson struct rte_eth_tcpv6_flow {
22299a2dd95SBruce Richardson 	struct rte_eth_ipv6_flow ip; /**< IPv6 fields to match. */
22399a2dd95SBruce Richardson 	uint16_t src_port;           /**< TCP source port to in big endian. */
22499a2dd95SBruce Richardson 	uint16_t dst_port;           /**< TCP destination port in big endian. */
22599a2dd95SBruce Richardson };
22699a2dd95SBruce Richardson 
22799a2dd95SBruce Richardson /**
22899a2dd95SBruce Richardson  * A structure used to define the input for IPV6 SCTP flow
22999a2dd95SBruce Richardson  */
23099a2dd95SBruce Richardson struct rte_eth_sctpv6_flow {
23199a2dd95SBruce Richardson 	struct rte_eth_ipv6_flow ip; /**< IPv6 fields to match. */
23299a2dd95SBruce Richardson 	uint16_t src_port;           /**< SCTP source port in big endian. */
23399a2dd95SBruce Richardson 	uint16_t dst_port;           /**< SCTP destination port in big endian. */
23499a2dd95SBruce Richardson 	uint32_t verify_tag;         /**< Verify tag in big endian. */
23599a2dd95SBruce Richardson };
23699a2dd95SBruce Richardson 
23799a2dd95SBruce Richardson /**
23899a2dd95SBruce Richardson  * A structure used to define the input for MAC VLAN flow
23999a2dd95SBruce Richardson  */
24099a2dd95SBruce Richardson struct rte_eth_mac_vlan_flow {
24199a2dd95SBruce Richardson 	struct rte_ether_addr mac_addr;  /**< Mac address to match. */
24299a2dd95SBruce Richardson };
24399a2dd95SBruce Richardson 
24499a2dd95SBruce Richardson /**
24599a2dd95SBruce Richardson  * Tunnel type for flow director.
24699a2dd95SBruce Richardson  */
24799a2dd95SBruce Richardson enum rte_eth_fdir_tunnel_type {
24899a2dd95SBruce Richardson 	RTE_FDIR_TUNNEL_TYPE_UNKNOWN = 0,
24999a2dd95SBruce Richardson 	RTE_FDIR_TUNNEL_TYPE_NVGRE,
25099a2dd95SBruce Richardson 	RTE_FDIR_TUNNEL_TYPE_VXLAN,
25199a2dd95SBruce Richardson };
25299a2dd95SBruce Richardson 
25399a2dd95SBruce Richardson /**
25499a2dd95SBruce Richardson  * A structure used to define the input for tunnel flow, now it's VxLAN or
25599a2dd95SBruce Richardson  * NVGRE
25699a2dd95SBruce Richardson  */
25799a2dd95SBruce Richardson struct rte_eth_tunnel_flow {
25899a2dd95SBruce Richardson 	enum rte_eth_fdir_tunnel_type tunnel_type; /**< Tunnel type to match. */
25999a2dd95SBruce Richardson 	/** Tunnel ID to match. TNI, VNI... in big endian. */
26099a2dd95SBruce Richardson 	uint32_t tunnel_id;
26199a2dd95SBruce Richardson 	struct rte_ether_addr mac_addr;            /**< Mac address to match. */
26299a2dd95SBruce Richardson };
26399a2dd95SBruce Richardson 
26499a2dd95SBruce Richardson /**
26599a2dd95SBruce Richardson  * An union contains the inputs for all types of flow
26699a2dd95SBruce Richardson  * Items in flows need to be in big endian
26799a2dd95SBruce Richardson  */
26899a2dd95SBruce Richardson union rte_eth_fdir_flow {
26999a2dd95SBruce Richardson 	struct rte_eth_l2_flow     l2_flow;
27099a2dd95SBruce Richardson 	struct rte_eth_udpv4_flow  udp4_flow;
27199a2dd95SBruce Richardson 	struct rte_eth_tcpv4_flow  tcp4_flow;
27299a2dd95SBruce Richardson 	struct rte_eth_sctpv4_flow sctp4_flow;
27399a2dd95SBruce Richardson 	struct rte_eth_ipv4_flow   ip4_flow;
27499a2dd95SBruce Richardson 	struct rte_eth_udpv6_flow  udp6_flow;
27599a2dd95SBruce Richardson 	struct rte_eth_tcpv6_flow  tcp6_flow;
27699a2dd95SBruce Richardson 	struct rte_eth_sctpv6_flow sctp6_flow;
27799a2dd95SBruce Richardson 	struct rte_eth_ipv6_flow   ipv6_flow;
27899a2dd95SBruce Richardson 	struct rte_eth_mac_vlan_flow mac_vlan_flow;
27999a2dd95SBruce Richardson 	struct rte_eth_tunnel_flow   tunnel_flow;
28099a2dd95SBruce Richardson };
28199a2dd95SBruce Richardson 
28299a2dd95SBruce Richardson /**
28399a2dd95SBruce Richardson  * A structure used to contain extend input of flow
28499a2dd95SBruce Richardson  */
28599a2dd95SBruce Richardson struct rte_eth_fdir_flow_ext {
28699a2dd95SBruce Richardson 	uint16_t vlan_tci;
28799a2dd95SBruce Richardson 	uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
28899a2dd95SBruce Richardson 	/**< It is filled by the flexible payload to match. */
28999a2dd95SBruce Richardson 	uint8_t is_vf;   /**< 1 for VF, 0 for port dev */
29099a2dd95SBruce Richardson 	uint16_t dst_id; /**< VF ID, available when is_vf is 1*/
29199a2dd95SBruce Richardson };
29299a2dd95SBruce Richardson 
29399a2dd95SBruce Richardson /**
29499a2dd95SBruce Richardson  * A structure used to define the input for a flow director filter entry
29599a2dd95SBruce Richardson  */
29699a2dd95SBruce Richardson struct rte_eth_fdir_input {
29799a2dd95SBruce Richardson 	uint16_t flow_type;
29899a2dd95SBruce Richardson 	union rte_eth_fdir_flow flow;
29999a2dd95SBruce Richardson 	/**< Flow fields to match, dependent on flow_type */
30099a2dd95SBruce Richardson 	struct rte_eth_fdir_flow_ext flow_ext;
30199a2dd95SBruce Richardson 	/**< Additional fields to match */
30299a2dd95SBruce Richardson };
30399a2dd95SBruce Richardson 
30499a2dd95SBruce Richardson /**
30599a2dd95SBruce Richardson  * Behavior will be taken if FDIR match
30699a2dd95SBruce Richardson  */
30799a2dd95SBruce Richardson enum rte_eth_fdir_behavior {
30899a2dd95SBruce Richardson 	RTE_ETH_FDIR_ACCEPT = 0,
30999a2dd95SBruce Richardson 	RTE_ETH_FDIR_REJECT,
31099a2dd95SBruce Richardson 	RTE_ETH_FDIR_PASSTHRU,
31199a2dd95SBruce Richardson };
31299a2dd95SBruce Richardson 
31399a2dd95SBruce Richardson /**
31499a2dd95SBruce Richardson  * Flow director report status
31599a2dd95SBruce Richardson  * It defines what will be reported if FDIR entry is matched.
31699a2dd95SBruce Richardson  */
31799a2dd95SBruce Richardson enum rte_eth_fdir_status {
31899a2dd95SBruce Richardson 	RTE_ETH_FDIR_NO_REPORT_STATUS = 0, /**< Report nothing. */
31999a2dd95SBruce Richardson 	RTE_ETH_FDIR_REPORT_ID,            /**< Only report FD ID. */
32099a2dd95SBruce Richardson 	RTE_ETH_FDIR_REPORT_ID_FLEX_4,     /**< Report FD ID and 4 flex bytes. */
32199a2dd95SBruce Richardson 	RTE_ETH_FDIR_REPORT_FLEX_8,        /**< Report 8 flex bytes. */
32299a2dd95SBruce Richardson };
32399a2dd95SBruce Richardson 
32499a2dd95SBruce Richardson /**
32599a2dd95SBruce Richardson  * A structure used to define an action when match FDIR packet filter.
32699a2dd95SBruce Richardson  */
32799a2dd95SBruce Richardson struct rte_eth_fdir_action {
32899a2dd95SBruce Richardson 	uint16_t rx_queue;        /**< Queue assigned to if FDIR match. */
32999a2dd95SBruce Richardson 	enum rte_eth_fdir_behavior behavior;     /**< Behavior will be taken */
33099a2dd95SBruce Richardson 	enum rte_eth_fdir_status report_status;  /**< Status report option */
33199a2dd95SBruce Richardson 	uint8_t flex_off;
33299a2dd95SBruce Richardson 	/**< If report_status is RTE_ETH_FDIR_REPORT_ID_FLEX_4 or
33399a2dd95SBruce Richardson 	     RTE_ETH_FDIR_REPORT_FLEX_8, flex_off specifies where the reported
33499a2dd95SBruce Richardson 	     flex bytes start from in flexible payload. */
33599a2dd95SBruce Richardson };
33699a2dd95SBruce Richardson 
33799a2dd95SBruce Richardson /**
33899a2dd95SBruce Richardson  * A structure used to define the flow director filter entry.
33999a2dd95SBruce Richardson  */
34099a2dd95SBruce Richardson struct rte_eth_fdir_filter {
34199a2dd95SBruce Richardson 	uint32_t soft_id;
34299a2dd95SBruce Richardson 	/**< ID, an unique value is required when deal with FDIR entry */
34399a2dd95SBruce Richardson 	struct rte_eth_fdir_input input;    /**< Input set */
34499a2dd95SBruce Richardson 	struct rte_eth_fdir_action action;  /**< Action taken when match */
34599a2dd95SBruce Richardson };
34699a2dd95SBruce Richardson 
34799a2dd95SBruce Richardson /**
34899a2dd95SBruce Richardson  *  A structure used to configure FDIR masks that are used by the device
349*09fd4227SAndrew Rybchenko  *  to match the various fields of Rx packet headers.
35099a2dd95SBruce Richardson  */
35199a2dd95SBruce Richardson struct rte_eth_fdir_masks {
35299a2dd95SBruce Richardson 	uint16_t vlan_tci_mask;   /**< Bit mask for vlan_tci in big endian */
35399a2dd95SBruce Richardson 	/** Bit mask for ipv4 flow in big endian. */
35499a2dd95SBruce Richardson 	struct rte_eth_ipv4_flow   ipv4_mask;
35599a2dd95SBruce Richardson 	/** Bit mask for ipv6 flow in big endian. */
35699a2dd95SBruce Richardson 	struct rte_eth_ipv6_flow   ipv6_mask;
35799a2dd95SBruce Richardson 	/** Bit mask for L4 source port in big endian. */
35899a2dd95SBruce Richardson 	uint16_t src_port_mask;
35999a2dd95SBruce Richardson 	/** Bit mask for L4 destination port in big endian. */
36099a2dd95SBruce Richardson 	uint16_t dst_port_mask;
36199a2dd95SBruce Richardson 	/** 6 bit mask for proper 6 bytes of Mac address, bit 0 matches the
36299a2dd95SBruce Richardson 	    first byte on the wire */
36399a2dd95SBruce Richardson 	uint8_t mac_addr_byte_mask;
36499a2dd95SBruce Richardson 	/** Bit mask for tunnel ID in big endian. */
36599a2dd95SBruce Richardson 	uint32_t tunnel_id_mask;
36699a2dd95SBruce Richardson 	uint8_t tunnel_type_mask; /**< 1 - Match tunnel type,
36799a2dd95SBruce Richardson 				       0 - Ignore tunnel type. */
36899a2dd95SBruce Richardson };
36999a2dd95SBruce Richardson 
37099a2dd95SBruce Richardson /**
37199a2dd95SBruce Richardson  * Payload type
37299a2dd95SBruce Richardson  */
37399a2dd95SBruce Richardson enum rte_eth_payload_type {
37499a2dd95SBruce Richardson 	RTE_ETH_PAYLOAD_UNKNOWN = 0,
37599a2dd95SBruce Richardson 	RTE_ETH_RAW_PAYLOAD,
37699a2dd95SBruce Richardson 	RTE_ETH_L2_PAYLOAD,
37799a2dd95SBruce Richardson 	RTE_ETH_L3_PAYLOAD,
37899a2dd95SBruce Richardson 	RTE_ETH_L4_PAYLOAD,
37999a2dd95SBruce Richardson 	RTE_ETH_PAYLOAD_MAX = 8,
38099a2dd95SBruce Richardson };
38199a2dd95SBruce Richardson 
38299a2dd95SBruce Richardson /**
38399a2dd95SBruce Richardson  * A structure used to select bytes extracted from the protocol layers to
38499a2dd95SBruce Richardson  * flexible payload for filter
38599a2dd95SBruce Richardson  */
38699a2dd95SBruce Richardson struct rte_eth_flex_payload_cfg {
38799a2dd95SBruce Richardson 	enum rte_eth_payload_type type;  /**< Payload type */
38899a2dd95SBruce Richardson 	uint16_t src_offset[RTE_ETH_FDIR_MAX_FLEXLEN];
38999a2dd95SBruce Richardson 	/**< Offset in bytes from the beginning of packet's payload
39099a2dd95SBruce Richardson 	     src_offset[i] indicates the flexbyte i's offset in original
39199a2dd95SBruce Richardson 	     packet payload. This value should be less than
39299a2dd95SBruce Richardson 	     flex_payload_limit in struct rte_eth_fdir_info.*/
39399a2dd95SBruce Richardson };
39499a2dd95SBruce Richardson 
39599a2dd95SBruce Richardson /**
39699a2dd95SBruce Richardson  * A structure used to define FDIR masks for flexible payload
39799a2dd95SBruce Richardson  * for each flow type
39899a2dd95SBruce Richardson  */
39999a2dd95SBruce Richardson struct rte_eth_fdir_flex_mask {
40099a2dd95SBruce Richardson 	uint16_t flow_type;
40199a2dd95SBruce Richardson 	uint8_t mask[RTE_ETH_FDIR_MAX_FLEXLEN];
40299a2dd95SBruce Richardson 	/**< Mask for the whole flexible payload */
40399a2dd95SBruce Richardson };
40499a2dd95SBruce Richardson 
40599a2dd95SBruce Richardson /**
40699a2dd95SBruce Richardson  * A structure used to define all flexible payload related setting
40799a2dd95SBruce Richardson  * include flex payload and flex mask
40899a2dd95SBruce Richardson  */
40999a2dd95SBruce Richardson struct rte_eth_fdir_flex_conf {
41099a2dd95SBruce Richardson 	uint16_t nb_payloads;  /**< The number of following payload cfg */
41199a2dd95SBruce Richardson 	uint16_t nb_flexmasks; /**< The number of following mask */
41299a2dd95SBruce Richardson 	struct rte_eth_flex_payload_cfg flex_set[RTE_ETH_PAYLOAD_MAX];
41399a2dd95SBruce Richardson 	/**< Flex payload configuration for each payload type */
41499a2dd95SBruce Richardson 	struct rte_eth_fdir_flex_mask flex_mask[RTE_ETH_FLOW_MAX];
41599a2dd95SBruce Richardson 	/**< Flex mask configuration for each flow type */
41699a2dd95SBruce Richardson };
41799a2dd95SBruce Richardson 
41899a2dd95SBruce Richardson /**
41999a2dd95SBruce Richardson  *  Flow Director setting modes: none, signature or perfect.
42099a2dd95SBruce Richardson  */
42199a2dd95SBruce Richardson enum rte_fdir_mode {
42299a2dd95SBruce Richardson 	RTE_FDIR_MODE_NONE      = 0, /**< Disable FDIR support. */
42399a2dd95SBruce Richardson 	RTE_FDIR_MODE_SIGNATURE,     /**< Enable FDIR signature filter mode. */
42499a2dd95SBruce Richardson 	RTE_FDIR_MODE_PERFECT,       /**< Enable FDIR perfect filter mode. */
42599a2dd95SBruce Richardson 	RTE_FDIR_MODE_PERFECT_MAC_VLAN, /**< Enable FDIR filter mode - MAC VLAN. */
42699a2dd95SBruce Richardson 	RTE_FDIR_MODE_PERFECT_TUNNEL,   /**< Enable FDIR filter mode - tunnel. */
42799a2dd95SBruce Richardson };
42899a2dd95SBruce Richardson 
42999a2dd95SBruce Richardson #define UINT64_BIT (CHAR_BIT * sizeof(uint64_t))
43099a2dd95SBruce Richardson #define RTE_FLOW_MASK_ARRAY_SIZE \
43199a2dd95SBruce Richardson 	(RTE_ALIGN(RTE_ETH_FLOW_MAX, UINT64_BIT)/UINT64_BIT)
43299a2dd95SBruce Richardson 
43399a2dd95SBruce Richardson /**
43499a2dd95SBruce Richardson  * A structure used to get the information of flow director filter.
43599a2dd95SBruce Richardson  * It supports RTE_ETH_FILTER_FDIR with RTE_ETH_FILTER_INFO operation.
43699a2dd95SBruce Richardson  * It includes the mode, flexible payload configuration information,
43799a2dd95SBruce Richardson  * capabilities and supported flow types, flexible payload characters.
43899a2dd95SBruce Richardson  * It can be gotten to help taking specific configurations per device.
43999a2dd95SBruce Richardson  */
44099a2dd95SBruce Richardson struct rte_eth_fdir_info {
44199a2dd95SBruce Richardson 	enum rte_fdir_mode mode; /**< Flow director mode */
44299a2dd95SBruce Richardson 	struct rte_eth_fdir_masks mask;
44399a2dd95SBruce Richardson 	/** Flex payload configuration information */
44499a2dd95SBruce Richardson 	struct rte_eth_fdir_flex_conf flex_conf;
44599a2dd95SBruce Richardson 	uint32_t guarant_spc; /**< Guaranteed spaces.*/
44699a2dd95SBruce Richardson 	uint32_t best_spc; /**< Best effort spaces.*/
44799a2dd95SBruce Richardson 	/** Bit mask for every supported flow type. */
44899a2dd95SBruce Richardson 	uint64_t flow_types_mask[RTE_FLOW_MASK_ARRAY_SIZE];
44999a2dd95SBruce Richardson 	uint32_t max_flexpayload; /**< Total flex payload in bytes. */
45099a2dd95SBruce Richardson 	/** Flexible payload unit in bytes. Size and alignments of all flex
45199a2dd95SBruce Richardson 	    payload segments should be multiplies of this value. */
45299a2dd95SBruce Richardson 	uint32_t flex_payload_unit;
45399a2dd95SBruce Richardson 	/** Max number of flexible payload continuous segments.
45499a2dd95SBruce Richardson 	    Each segment should be a multiple of flex_payload_unit.*/
45599a2dd95SBruce Richardson 	uint32_t max_flex_payload_segment_num;
45699a2dd95SBruce Richardson 	/** Maximum src_offset in bytes allowed. It indicates that
45799a2dd95SBruce Richardson 	    src_offset[i] in struct rte_eth_flex_payload_cfg should be less
45899a2dd95SBruce Richardson 	    than this value. */
45999a2dd95SBruce Richardson 	uint16_t flex_payload_limit;
46099a2dd95SBruce Richardson 	/** Flex bitmask unit in bytes. Size of flex bitmasks should be a
46199a2dd95SBruce Richardson 	    multiply of this value. */
46299a2dd95SBruce Richardson 	uint32_t flex_bitmask_unit;
46399a2dd95SBruce Richardson 	/** Max supported size of flex bitmasks in flex_bitmask_unit */
46499a2dd95SBruce Richardson 	uint32_t max_flex_bitmask_num;
46599a2dd95SBruce Richardson };
46699a2dd95SBruce Richardson 
46799a2dd95SBruce Richardson /**
46899a2dd95SBruce Richardson  * A structure used to define the statistics of flow director.
46999a2dd95SBruce Richardson  * It supports RTE_ETH_FILTER_FDIR with RTE_ETH_FILTER_STATS operation.
47099a2dd95SBruce Richardson  */
47199a2dd95SBruce Richardson struct rte_eth_fdir_stats {
47299a2dd95SBruce Richardson 	uint32_t collision;    /**< Number of filters with collision. */
47399a2dd95SBruce Richardson 	uint32_t free;         /**< Number of free filters. */
47499a2dd95SBruce Richardson 	uint32_t maxhash;
47599a2dd95SBruce Richardson 	/**< The lookup hash value of the added filter that updated the value
47699a2dd95SBruce Richardson 	   of the MAXLEN field */
47799a2dd95SBruce Richardson 	uint32_t maxlen;       /**< Longest linked list of filters. */
47899a2dd95SBruce Richardson 	uint64_t add;          /**< Number of added filters. */
47999a2dd95SBruce Richardson 	uint64_t remove;       /**< Number of removed filters. */
48099a2dd95SBruce Richardson 	uint64_t f_add;        /**< Number of failed added filters. */
48199a2dd95SBruce Richardson 	uint64_t f_remove;     /**< Number of failed removed filters. */
48299a2dd95SBruce Richardson 	uint32_t guarant_cnt;  /**< Number of filters in guaranteed spaces. */
48399a2dd95SBruce Richardson 	uint32_t best_cnt;     /**< Number of filters in best effort spaces. */
48499a2dd95SBruce Richardson };
48599a2dd95SBruce Richardson 
48699a2dd95SBruce Richardson #endif /* _RTE_ETH_CTRL_H_ */
487