1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2001-2019
8 #include "ice_common.h"
10 /* Flow Director (FD) Filter Programming descriptor */
11 struct ice_fd_fltr_desc_ctx {
37 enum ice_status ice_alloc_fd_res_cntr(struct ice_hw *hw, u16 *cntr_id);
38 enum ice_status ice_free_fd_res_cntr(struct ice_hw *hw, u16 cntr_id);
40 ice_set_fd_desc_val(struct ice_fd_fltr_desc_ctx *fd_fltr_ctx,
41 struct ice_fltr_desc *fdir_desc);
42 void ice_set_dflt_val_fd_desc(struct ice_fd_fltr_desc_ctx *fd_fltr_ctx);
44 ice_alloc_fd_guar_item(struct ice_hw *hw, u16 *cntr_id, u16 num_fltr);
46 ice_free_fd_guar_item(struct ice_hw *hw, u16 cntr_id, u16 num_fltr);
48 ice_alloc_fd_shrd_item(struct ice_hw *hw, u16 *cntr_id, u16 num_fltr);
50 ice_free_fd_shrd_item(struct ice_hw *hw, u16 cntr_id, u16 num_fltr);
51 enum ice_status ice_clear_vsi_fd_table(struct ice_hw *hw, u16 vsi_num);
52 enum ice_status ice_clear_pf_fd_table(struct ice_hw *hw);
54 #define ICE_FDIR_IP_PROTOCOLS
55 #define ICE_IP_PROTO_TCP 6
56 #define ICE_IP_PROTO_UDP 17
57 #define ICE_IP_PROTO_SCTP 132
58 #define ICE_IP_PROTO_IP 0
59 #define ICE_IP_PROTO_ESP 50
61 #define ICE_FDIR_MAX_RAW_PKT_SIZE 512
62 #define ICE_FDIR_BUF_FULL_MARGIN 10
63 #define ICE_FDIR_BUF_HEAD_ROOM 32
65 /* macros for offsets into packets for flow director programming */
66 #define ICE_IPV4_SRC_ADDR_OFFSET 26
67 #define ICE_IPV4_DST_ADDR_OFFSET 30
68 #define ICE_IPV4_TCP_SRC_PORT_OFFSET 34
69 #define ICE_IPV4_TCP_DST_PORT_OFFSET 36
70 #define ICE_IPV4_UDP_SRC_PORT_OFFSET 34
71 #define ICE_IPV4_UDP_DST_PORT_OFFSET 36
72 #define ICE_IPV4_SCTP_SRC_PORT_OFFSET 34
73 #define ICE_IPV4_SCTP_DST_PORT_OFFSET 36
74 #define ICE_IPV4_PROTO_OFFSET 23
75 #define ICE_IPV6_SRC_ADDR_OFFSET 22
76 #define ICE_IPV6_DST_ADDR_OFFSET 38
77 #define ICE_IPV6_TCP_SRC_PORT_OFFSET 54
78 #define ICE_IPV6_TCP_DST_PORT_OFFSET 56
79 #define ICE_IPV6_UDP_SRC_PORT_OFFSET 54
80 #define ICE_IPV6_UDP_DST_PORT_OFFSET 56
81 #define ICE_IPV6_SCTP_SRC_PORT_OFFSET 54
82 #define ICE_IPV6_SCTP_DST_PORT_OFFSET 56
84 #define ICE_FDIR_MAX_FLTRS 16384
86 /* IP v4 has 2 flag bits that enable fragment processing: DF and MF. DF
87 * requests that the packet not be fragmented. MF indicates that a packet has
90 #define ICE_FDIR_IPV4_PKT_FLAG_DF 0x20
91 #define ICE_FDIR_IPV4_PKT_FLAG_MF 0x40
93 enum ice_fltr_prgm_desc_dest {
94 ICE_FLTR_PRGM_DESC_DEST_DROP_PKT,
95 ICE_FLTR_PRGM_DESC_DEST_DIRECT_PKT_QINDEX,
96 ICE_FLTR_PRGM_DESC_DEST_DIRECT_PKT_QGROUP,
97 ICE_FLTR_PRGM_DESC_DEST_DIRECT_PKT_OTHER,
100 enum ice_fltr_prgm_desc_fd_status {
101 ICE_FLTR_PRGM_DESC_FD_STATUS_NONE,
102 ICE_FLTR_PRGM_DESC_FD_STATUS_FD_ID,
103 ICE_FLTR_PRGM_DESC_FD_STATUS_FD_ID_4FLEX_BYTES,
104 ICE_FLTR_PRGM_DESC_FD_STATUS_8FLEX_BYTES,
107 #define ICE_FLTR_PRGM_FLEX_WORD_SIZE sizeof(__be16)
109 struct ice_rx_flow_userdef {
121 __be32 sec_parm_idx; /* security parameter index */
127 #define ICE_IPV6_ADDR_LEN_AS_U32 4
130 __be32 dst_ip[ICE_IPV6_ADDR_LEN_AS_U32];
131 __be32 src_ip[ICE_IPV6_ADDR_LEN_AS_U32];
134 __be32 l4_header; /* next header */
135 __be32 sec_parm_idx; /* security parameter index */
140 struct ice_fdir_extra {
141 u8 dst_mac[ETH_ALEN]; /* dest MAC address */
142 u32 usr_def[2]; /* user data */
143 __be16 vlan_type; /* VLAN ethertype */
144 __be16 vlan_tag; /* VLAN tag info */
147 struct ice_fdir_fltr {
148 struct LIST_ENTRY_TYPE fltr_node;
149 enum ice_fltr_ptype flow_type;
152 struct ice_fdir_v4 v4;
153 struct ice_fdir_v6 v6;
156 struct ice_fdir_extra ext_data;
157 struct ice_fdir_extra ext_mask;
159 /* flex byte filter data */
173 /* Dummy packet filter definition structure. */
174 struct ice_fdir_base_pkt {
175 enum ice_fltr_ptype flow;
181 ice_fdir_get_prgm_desc(struct ice_hw *hw, struct ice_fdir_fltr *input,
182 struct ice_fltr_desc *fdesc, bool add);
184 ice_fdir_get_prgm_pkt(struct ice_fdir_fltr *input, u8 *pkt, bool frag);
186 ice_add_del_fdir(struct ice_hw *hw, struct ice_fdir_fltr *input, bool add);
187 int ice_get_fdir_cnt_all(struct ice_hw *hw);
188 bool ice_fdir_is_dup_fltr(struct ice_hw *hw, struct ice_fdir_fltr *input);
190 ice_update_fdir_list_entry(struct ice_hw *hw, struct ice_fdir_fltr *input,
192 bool ice_fdir_has_frag(enum ice_fltr_ptype flow);
193 struct ice_fdir_fltr *
194 ice_fdir_find_fltr_by_idx(struct ice_hw *hw, u32 fltr_idx);
196 ice_fdir_update_cntrs(struct ice_hw *hw, enum ice_fltr_ptype flow, bool add);
197 void ice_fdir_list_add_fltr(struct ice_hw *hw, struct ice_fdir_fltr *input);
198 #endif /* _ICE_FDIR_H_ */