mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-29 22:14:41 +08:00
a6379db818
Flex-bytes allows for packet matching based on an offset and value. This is supported via the ethtool user-def option. The user-def 0xAAAABBBBCCCCDDDD: BBBB is the 2 byte pattern while AAAA corresponds to its offset in the packet. Similarly DDDD is the 2 byte pattern with CCCC being the corresponding offset. The offset ranges from 0x0 to 0x1F7 (up to 504 bytes into the packet). The offset starts from the beginning of the packet. This feature can be used to allow customers to set flow director rules for protocols headers that are beyond standard ones supported by ethtool (e.g. PFCP or GTP-U). Like for matching GTP-U's TEID value 0x10203040: ethtool -N ens787f0v0 flow-type udp4 dst-port 2152 \ user-def 0x002e102000303040 action 13 Signed-off-by: Haiyue Wang <haiyue.wang@intel.com> Tested-by: Chen Bo <BoX.C.Chen@intel.com> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
114 lines
2.7 KiB
C
114 lines
2.7 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
/* Copyright (c) 2021, Intel Corporation. */
|
|
|
|
#ifndef _IAVF_FDIR_H_
|
|
#define _IAVF_FDIR_H_
|
|
|
|
struct iavf_adapter;
|
|
|
|
/* State of Flow Director filter */
|
|
enum iavf_fdir_fltr_state_t {
|
|
IAVF_FDIR_FLTR_ADD_REQUEST, /* User requests to add filter */
|
|
IAVF_FDIR_FLTR_ADD_PENDING, /* Filter pending add by the PF */
|
|
IAVF_FDIR_FLTR_DEL_REQUEST, /* User requests to delete filter */
|
|
IAVF_FDIR_FLTR_DEL_PENDING, /* Filter pending delete by the PF */
|
|
IAVF_FDIR_FLTR_ACTIVE, /* Filter is active */
|
|
};
|
|
|
|
enum iavf_fdir_flow_type {
|
|
/* NONE - used for undef/error */
|
|
IAVF_FDIR_FLOW_NONE = 0,
|
|
IAVF_FDIR_FLOW_IPV4_TCP,
|
|
IAVF_FDIR_FLOW_IPV4_UDP,
|
|
IAVF_FDIR_FLOW_IPV4_SCTP,
|
|
IAVF_FDIR_FLOW_IPV4_AH,
|
|
IAVF_FDIR_FLOW_IPV4_ESP,
|
|
IAVF_FDIR_FLOW_IPV4_OTHER,
|
|
IAVF_FDIR_FLOW_IPV6_TCP,
|
|
IAVF_FDIR_FLOW_IPV6_UDP,
|
|
IAVF_FDIR_FLOW_IPV6_SCTP,
|
|
IAVF_FDIR_FLOW_IPV6_AH,
|
|
IAVF_FDIR_FLOW_IPV6_ESP,
|
|
IAVF_FDIR_FLOW_IPV6_OTHER,
|
|
IAVF_FDIR_FLOW_NON_IP_L2,
|
|
/* MAX - this must be last and add anything new just above it */
|
|
IAVF_FDIR_FLOW_PTYPE_MAX,
|
|
};
|
|
|
|
struct iavf_flex_word {
|
|
u16 offset;
|
|
u16 word;
|
|
};
|
|
|
|
struct iavf_ipv4_addrs {
|
|
__be32 src_ip;
|
|
__be32 dst_ip;
|
|
};
|
|
|
|
struct iavf_ipv6_addrs {
|
|
struct in6_addr src_ip;
|
|
struct in6_addr dst_ip;
|
|
};
|
|
|
|
struct iavf_fdir_eth {
|
|
__be16 etype;
|
|
};
|
|
|
|
struct iavf_fdir_ip {
|
|
union {
|
|
struct iavf_ipv4_addrs v4_addrs;
|
|
struct iavf_ipv6_addrs v6_addrs;
|
|
};
|
|
__be16 src_port;
|
|
__be16 dst_port;
|
|
__be32 l4_header; /* first 4 bytes of the layer 4 header */
|
|
__be32 spi; /* security parameter index for AH/ESP */
|
|
union {
|
|
u8 tos;
|
|
u8 tclass;
|
|
};
|
|
u8 proto;
|
|
};
|
|
|
|
struct iavf_fdir_extra {
|
|
u32 usr_def[2];
|
|
};
|
|
|
|
/* bookkeeping of Flow Director filters */
|
|
struct iavf_fdir_fltr {
|
|
enum iavf_fdir_fltr_state_t state;
|
|
struct list_head list;
|
|
|
|
enum iavf_fdir_flow_type flow_type;
|
|
|
|
struct iavf_fdir_eth eth_data;
|
|
struct iavf_fdir_eth eth_mask;
|
|
|
|
struct iavf_fdir_ip ip_data;
|
|
struct iavf_fdir_ip ip_mask;
|
|
|
|
struct iavf_fdir_extra ext_data;
|
|
struct iavf_fdir_extra ext_mask;
|
|
|
|
enum virtchnl_action action;
|
|
|
|
/* flex byte filter data */
|
|
u8 ip_ver; /* used to adjust the flex offset, 4 : IPv4, 6 : IPv6 */
|
|
u8 flex_cnt;
|
|
struct iavf_flex_word flex_words[2];
|
|
|
|
u32 flow_id;
|
|
|
|
u32 loc; /* Rule location inside the flow table */
|
|
u32 q_index;
|
|
|
|
struct virtchnl_fdir_add vc_add_msg;
|
|
};
|
|
|
|
int iavf_fill_fdir_add_msg(struct iavf_adapter *adapter, struct iavf_fdir_fltr *fltr);
|
|
void iavf_print_fdir_fltr(struct iavf_adapter *adapter, struct iavf_fdir_fltr *fltr);
|
|
bool iavf_fdir_is_dup_fltr(struct iavf_adapter *adapter, struct iavf_fdir_fltr *fltr);
|
|
void iavf_fdir_list_add_fltr(struct iavf_adapter *adapter, struct iavf_fdir_fltr *fltr);
|
|
struct iavf_fdir_fltr *iavf_find_fdir_fltr_by_loc(struct iavf_adapter *adapter, u32 loc);
|
|
#endif /* _IAVF_FDIR_H_ */
|