Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /* Copyright (c) 2021, Intel Corporation. */
0003 
0004 #ifndef _IAVF_FDIR_H_
0005 #define _IAVF_FDIR_H_
0006 
0007 struct iavf_adapter;
0008 
0009 /* State of Flow Director filter */
0010 enum iavf_fdir_fltr_state_t {
0011     IAVF_FDIR_FLTR_ADD_REQUEST, /* User requests to add filter */
0012     IAVF_FDIR_FLTR_ADD_PENDING, /* Filter pending add by the PF */
0013     IAVF_FDIR_FLTR_DEL_REQUEST, /* User requests to delete filter */
0014     IAVF_FDIR_FLTR_DEL_PENDING, /* Filter pending delete by the PF */
0015     IAVF_FDIR_FLTR_ACTIVE,      /* Filter is active */
0016 };
0017 
0018 enum iavf_fdir_flow_type {
0019     /* NONE - used for undef/error */
0020     IAVF_FDIR_FLOW_NONE = 0,
0021     IAVF_FDIR_FLOW_IPV4_TCP,
0022     IAVF_FDIR_FLOW_IPV4_UDP,
0023     IAVF_FDIR_FLOW_IPV4_SCTP,
0024     IAVF_FDIR_FLOW_IPV4_AH,
0025     IAVF_FDIR_FLOW_IPV4_ESP,
0026     IAVF_FDIR_FLOW_IPV4_OTHER,
0027     IAVF_FDIR_FLOW_IPV6_TCP,
0028     IAVF_FDIR_FLOW_IPV6_UDP,
0029     IAVF_FDIR_FLOW_IPV6_SCTP,
0030     IAVF_FDIR_FLOW_IPV6_AH,
0031     IAVF_FDIR_FLOW_IPV6_ESP,
0032     IAVF_FDIR_FLOW_IPV6_OTHER,
0033     IAVF_FDIR_FLOW_NON_IP_L2,
0034     /* MAX - this must be last and add anything new just above it */
0035     IAVF_FDIR_FLOW_PTYPE_MAX,
0036 };
0037 
0038 /* Must not exceed the array element number of '__be32 data[2]' in the ethtool
0039  * 'struct ethtool_rx_flow_spec.m_ext.data[2]' to express the flex-byte (word).
0040  */
0041 #define IAVF_FLEX_WORD_NUM  2
0042 
0043 struct iavf_flex_word {
0044     u16 offset;
0045     u16 word;
0046 };
0047 
0048 struct iavf_ipv4_addrs {
0049     __be32 src_ip;
0050     __be32 dst_ip;
0051 };
0052 
0053 struct iavf_ipv6_addrs {
0054     struct in6_addr src_ip;
0055     struct in6_addr dst_ip;
0056 };
0057 
0058 struct iavf_fdir_eth {
0059     __be16 etype;
0060 };
0061 
0062 struct iavf_fdir_ip {
0063     union {
0064         struct iavf_ipv4_addrs v4_addrs;
0065         struct iavf_ipv6_addrs v6_addrs;
0066     };
0067     __be16 src_port;
0068     __be16 dst_port;
0069     __be32 l4_header;   /* first 4 bytes of the layer 4 header */
0070     __be32 spi;     /* security parameter index for AH/ESP */
0071     union {
0072         u8 tos;
0073         u8 tclass;
0074     };
0075     u8 proto;
0076 };
0077 
0078 struct iavf_fdir_extra {
0079     u32 usr_def[IAVF_FLEX_WORD_NUM];
0080 };
0081 
0082 /* bookkeeping of Flow Director filters */
0083 struct iavf_fdir_fltr {
0084     enum iavf_fdir_fltr_state_t state;
0085     struct list_head list;
0086 
0087     enum iavf_fdir_flow_type flow_type;
0088 
0089     struct iavf_fdir_eth eth_data;
0090     struct iavf_fdir_eth eth_mask;
0091 
0092     struct iavf_fdir_ip ip_data;
0093     struct iavf_fdir_ip ip_mask;
0094 
0095     struct iavf_fdir_extra ext_data;
0096     struct iavf_fdir_extra ext_mask;
0097 
0098     enum virtchnl_action action;
0099 
0100     /* flex byte filter data */
0101     u8 ip_ver; /* used to adjust the flex offset, 4 : IPv4, 6 : IPv6 */
0102     u8 flex_cnt;
0103     struct iavf_flex_word flex_words[IAVF_FLEX_WORD_NUM];
0104 
0105     u32 flow_id;
0106 
0107     u32 loc;    /* Rule location inside the flow table */
0108     u32 q_index;
0109 
0110     struct virtchnl_fdir_add vc_add_msg;
0111 };
0112 
0113 int iavf_fill_fdir_add_msg(struct iavf_adapter *adapter, struct iavf_fdir_fltr *fltr);
0114 void iavf_print_fdir_fltr(struct iavf_adapter *adapter, struct iavf_fdir_fltr *fltr);
0115 bool iavf_fdir_is_dup_fltr(struct iavf_adapter *adapter, struct iavf_fdir_fltr *fltr);
0116 void iavf_fdir_list_add_fltr(struct iavf_adapter *adapter, struct iavf_fdir_fltr *fltr);
0117 struct iavf_fdir_fltr *iavf_find_fdir_fltr_by_loc(struct iavf_adapter *adapter, u32 loc);
0118 #endif /* _IAVF_FDIR_H_ */