1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2001-2020 Intel Corporation
8 #include "ice_common.h"
10 #define ICE_FDIR_IP_PROTOCOLS
11 #define ICE_IP_PROTO_TCP 6
12 #define ICE_IP_PROTO_UDP 17
13 #define ICE_IP_PROTO_SCTP 132
14 #define ICE_IP_PROTO_IP 0
15 #define ICE_IP_PROTO_ESP 50
17 #define ICE_FDIR_TUN_PKT_OFF 50
18 #define ICE_FDIR_MAX_RAW_PKT_SIZE (512 + ICE_FDIR_TUN_PKT_OFF)
19 #define ICE_FDIR_BUF_FULL_MARGIN 10
21 /* macros for offsets into packets for flow director programming */
22 #define ICE_IPV4_SRC_ADDR_OFFSET 26
23 #define ICE_IPV4_DST_ADDR_OFFSET 30
24 #define ICE_IPV4_TCP_SRC_PORT_OFFSET 34
25 #define ICE_IPV4_TCP_DST_PORT_OFFSET 36
26 #define ICE_IPV4_UDP_SRC_PORT_OFFSET 34
27 #define ICE_IPV4_UDP_DST_PORT_OFFSET 36
28 #define ICE_IPV4_SCTP_SRC_PORT_OFFSET 34
29 #define ICE_IPV4_SCTP_DST_PORT_OFFSET 36
30 #define ICE_IPV4_PROTO_OFFSET 23
31 #define ICE_IPV6_SRC_ADDR_OFFSET 22
32 #define ICE_IPV6_DST_ADDR_OFFSET 38
33 #define ICE_IPV6_TCP_SRC_PORT_OFFSET 54
34 #define ICE_IPV6_TCP_DST_PORT_OFFSET 56
35 #define ICE_IPV6_UDP_SRC_PORT_OFFSET 54
36 #define ICE_IPV6_UDP_DST_PORT_OFFSET 56
37 #define ICE_IPV6_SCTP_SRC_PORT_OFFSET 54
38 #define ICE_IPV6_SCTP_DST_PORT_OFFSET 56
40 #define ICE_MAC_ETHTYPE_OFFSET 12
41 #define ICE_IPV4_TOS_OFFSET 15
42 #define ICE_IPV4_TTL_OFFSET 22
43 #define ICE_IPV6_TC_OFFSET 14
44 #define ICE_IPV6_HLIM_OFFSET 21
45 #define ICE_IPV6_PROTO_OFFSET 20
46 #define ICE_IPV4_GTPU_TEID_OFFSET 46
47 #define ICE_IPV4_GTPU_QFI_OFFSET 56
48 #define ICE_IPV6_GTPU_TEID_OFFSET 66
49 #define ICE_IPV6_GTPU_QFI_OFFSET 76
50 #define ICE_IPV4_L2TPV3_SESS_ID_OFFSET 34
51 #define ICE_IPV6_L2TPV3_SESS_ID_OFFSET 54
52 #define ICE_IPV4_ESP_SPI_OFFSET 34
53 #define ICE_IPV6_ESP_SPI_OFFSET 54
54 #define ICE_IPV4_AH_SPI_OFFSET 38
55 #define ICE_IPV6_AH_SPI_OFFSET 58
56 #define ICE_IPV4_NAT_T_ESP_SPI_OFFSET 42
57 #define ICE_IPV6_NAT_T_ESP_SPI_OFFSET 62
58 #define ICE_IPV4_VXLAN_VNI_OFFSET 45
60 #define ICE_FDIR_MAX_FLTRS 16384
62 /* IP v4 has 2 flag bits that enable fragment processing: DF and MF. DF
63 * requests that the packet not be fragmented. MF indicates that a packet has
66 #define ICE_FDIR_IPV4_PKT_FLAG_DF 0x20
67 #define ICE_FDIR_IPV4_PKT_FLAG_MF 0x40
69 enum ice_fltr_prgm_desc_dest {
70 ICE_FLTR_PRGM_DESC_DEST_DROP_PKT,
71 ICE_FLTR_PRGM_DESC_DEST_DIRECT_PKT_QINDEX,
72 ICE_FLTR_PRGM_DESC_DEST_DIRECT_PKT_QGROUP,
73 ICE_FLTR_PRGM_DESC_DEST_DIRECT_PKT_OTHER,
76 enum ice_fltr_prgm_desc_fd_status {
77 ICE_FLTR_PRGM_DESC_FD_STATUS_NONE,
78 ICE_FLTR_PRGM_DESC_FD_STATUS_FD_ID,
79 ICE_FLTR_PRGM_DESC_FD_STATUS_FD_ID_4FLEX_BYTES,
80 ICE_FLTR_PRGM_DESC_FD_STATUS_8FLEX_BYTES,
83 /* Flow Director (FD) Filter Programming descriptor */
84 struct ice_fd_fltr_desc_ctx {
110 #define ICE_FLTR_PRGM_FLEX_WORD_SIZE sizeof(__be16)
112 struct ice_rx_flow_userdef {
124 __be32 sec_parm_idx; /* security parameter index */
131 #define ICE_IPV6_ADDR_LEN_AS_U32 4
134 __be32 dst_ip[ICE_IPV6_ADDR_LEN_AS_U32];
135 __be32 src_ip[ICE_IPV6_ADDR_LEN_AS_U32];
138 __be32 l4_header; /* next header */
139 __be32 sec_parm_idx; /* security parameter index */
145 struct ice_fdir_udp_gtp {
150 __be16 rsrvd_seq_nbr;
152 u8 rsrvd_next_ext_type;
163 struct ice_fdir_l2tpv3 {
167 struct ice_fdir_udp_vxlan {
168 __be32 vni; /* 8 bits reserved, always be zero */
171 struct ice_fdir_extra {
172 u8 dst_mac[ETH_ALEN]; /* dest MAC address */
173 u8 src_mac[ETH_ALEN]; /* src MAC address */
174 __be16 ether_type; /* for NON_IP_L2 */
175 u32 usr_def[2]; /* user data */
176 __be16 vlan_type; /* VLAN ethertype */
177 __be16 vlan_tag; /* VLAN tag info */
180 struct ice_fdir_fltr {
181 struct LIST_ENTRY_TYPE fltr_node;
182 enum ice_fltr_ptype flow_type;
185 struct ice_fdir_v4 v4;
186 struct ice_fdir_v6 v6;
189 /* for tunnel outer part */
191 struct ice_fdir_v4 v4;
192 struct ice_fdir_v6 v6;
193 } ip_outer, mask_outer;
195 struct ice_fdir_extra ext_data_outer;
196 struct ice_fdir_extra ext_mask_outer;
198 struct ice_fdir_udp_vxlan vxlan_data;
199 struct ice_fdir_udp_vxlan vxlan_mask;
201 struct ice_fdir_udp_gtp gtpu_data;
202 struct ice_fdir_udp_gtp gtpu_mask;
204 struct ice_fdir_l2tpv3 l2tpv3_data;
205 struct ice_fdir_l2tpv3 l2tpv3_mask;
207 struct ice_fdir_extra ext_data;
208 struct ice_fdir_extra ext_mask;
210 /* flex byte filter data */
212 /* queue region size (=2^q_region) */
227 /* Set to true for an ACL filter */
231 /* Dummy packet filter definition structure */
232 struct ice_fdir_base_pkt {
233 enum ice_fltr_ptype flow;
240 enum ice_status ice_alloc_fd_res_cntr(struct ice_hw *hw, u16 *cntr_id);
241 enum ice_status ice_free_fd_res_cntr(struct ice_hw *hw, u16 cntr_id);
243 ice_alloc_fd_guar_item(struct ice_hw *hw, u16 *cntr_id, u16 num_fltr);
245 ice_free_fd_guar_item(struct ice_hw *hw, u16 cntr_id, u16 num_fltr);
247 ice_alloc_fd_shrd_item(struct ice_hw *hw, u16 *cntr_id, u16 num_fltr);
249 ice_free_fd_shrd_item(struct ice_hw *hw, u16 cntr_id, u16 num_fltr);
250 enum ice_status ice_clear_pf_fd_table(struct ice_hw *hw);
252 ice_fdir_get_prgm_desc(struct ice_hw *hw, struct ice_fdir_fltr *input,
253 struct ice_fltr_desc *fdesc, bool add);
255 ice_fdir_get_gen_prgm_pkt(struct ice_hw *hw, struct ice_fdir_fltr *input,
256 u8 *pkt, bool frag, bool tun);
258 ice_fdir_get_prgm_pkt(struct ice_fdir_fltr *input, u8 *pkt, bool frag);
259 int ice_get_fdir_cnt_all(struct ice_hw *hw);
260 bool ice_fdir_is_dup_fltr(struct ice_hw *hw, struct ice_fdir_fltr *input);
261 bool ice_fdir_has_frag(enum ice_fltr_ptype flow);
262 struct ice_fdir_fltr *
263 ice_fdir_find_fltr_by_idx(struct ice_hw *hw, u32 fltr_idx);
265 ice_fdir_update_cntrs(struct ice_hw *hw, enum ice_fltr_ptype flow,
266 bool acl_fltr, bool add);
267 void ice_fdir_list_add_fltr(struct ice_hw *hw, struct ice_fdir_fltr *input);
268 #endif /* _ICE_FDIR_H_ */