1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright (c) 2021, Intel Corporation. */
9 /* State of Flow Director filter */
10 enum iavf_fdir_fltr_state_t {
11 IAVF_FDIR_FLTR_ADD_REQUEST, /* User requests to add filter */
12 IAVF_FDIR_FLTR_ADD_PENDING, /* Filter pending add by the PF */
13 IAVF_FDIR_FLTR_DEL_REQUEST, /* User requests to delete filter */
14 IAVF_FDIR_FLTR_DEL_PENDING, /* Filter pending delete by the PF */
15 IAVF_FDIR_FLTR_ACTIVE, /* Filter is active */
18 enum iavf_fdir_flow_type {
19 /* NONE - used for undef/error */
20 IAVF_FDIR_FLOW_NONE = 0,
21 IAVF_FDIR_FLOW_IPV4_TCP,
22 IAVF_FDIR_FLOW_IPV4_UDP,
23 IAVF_FDIR_FLOW_IPV4_SCTP,
24 IAVF_FDIR_FLOW_IPV4_AH,
25 IAVF_FDIR_FLOW_IPV4_ESP,
26 IAVF_FDIR_FLOW_IPV4_OTHER,
27 IAVF_FDIR_FLOW_IPV6_TCP,
28 IAVF_FDIR_FLOW_IPV6_UDP,
29 IAVF_FDIR_FLOW_IPV6_SCTP,
30 IAVF_FDIR_FLOW_IPV6_AH,
31 IAVF_FDIR_FLOW_IPV6_ESP,
32 IAVF_FDIR_FLOW_IPV6_OTHER,
33 IAVF_FDIR_FLOW_NON_IP_L2,
34 /* MAX - this must be last and add anything new just above it */
35 IAVF_FDIR_FLOW_PTYPE_MAX,
38 /* Must not exceed the array element number of '__be32 data[2]' in the ethtool
39 * 'struct ethtool_rx_flow_spec.m_ext.data[2]' to express the flex-byte (word).
41 #define IAVF_FLEX_WORD_NUM 2
43 struct iavf_flex_word {
48 struct iavf_ipv4_addrs {
53 struct iavf_ipv6_addrs {
54 struct in6_addr src_ip;
55 struct in6_addr dst_ip;
58 struct iavf_fdir_eth {
64 struct iavf_ipv4_addrs v4_addrs;
65 struct iavf_ipv6_addrs v6_addrs;
69 __be32 l4_header; /* first 4 bytes of the layer 4 header */
70 __be32 spi; /* security parameter index for AH/ESP */
78 struct iavf_fdir_extra {
79 u32 usr_def[IAVF_FLEX_WORD_NUM];
82 /* bookkeeping of Flow Director filters */
83 struct iavf_fdir_fltr {
84 enum iavf_fdir_fltr_state_t state;
85 struct list_head list;
87 enum iavf_fdir_flow_type flow_type;
89 struct iavf_fdir_eth eth_data;
90 struct iavf_fdir_eth eth_mask;
92 struct iavf_fdir_ip ip_data;
93 struct iavf_fdir_ip ip_mask;
95 struct iavf_fdir_extra ext_data;
96 struct iavf_fdir_extra ext_mask;
98 enum virtchnl_action action;
100 /* flex byte filter data */
101 u8 ip_ver; /* used to adjust the flex offset, 4 : IPv4, 6 : IPv6 */
103 struct iavf_flex_word flex_words[IAVF_FLEX_WORD_NUM];
107 u32 loc; /* Rule location inside the flow table */
110 struct virtchnl_fdir_add vc_add_msg;
113 int iavf_fill_fdir_add_msg(struct iavf_adapter *adapter, struct iavf_fdir_fltr *fltr);
114 void iavf_print_fdir_fltr(struct iavf_adapter *adapter, struct iavf_fdir_fltr *fltr);
115 bool iavf_fdir_is_dup_fltr(struct iavf_adapter *adapter, struct iavf_fdir_fltr *fltr);
116 void iavf_fdir_list_add_fltr(struct iavf_adapter *adapter, struct iavf_fdir_fltr *fltr);
117 struct iavf_fdir_fltr *iavf_find_fdir_fltr_by_loc(struct iavf_adapter *adapter, u32 loc);
118 #endif /* _IAVF_FDIR_H_ */