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