1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2001-2018
8 #include "ice_common.h"
9 #include "ice_protocol_type.h"
11 #define ICE_SW_CFG_MAX_BUF_LEN 2048
12 #define ICE_MAX_SW 256
13 #define ICE_DFLT_VSI_INVAL 0xff
17 #define ICE_VSI_INVAL_ID 0xFFFF
19 /* VSI context structure for add/get/update/free operations */
25 struct ice_aqc_vsi_props info;
26 struct ice_sched_vsi_info sched;
28 struct ice_lock rss_locks; /* protect rss config in VSI ctx */
29 struct LIST_HEAD_TYPE rss_list_head;
33 /* Switch recipe ID enum values are specific to hardware */
34 enum ice_sw_lkup_type {
35 ICE_SW_LKUP_ETHERTYPE = 0,
37 ICE_SW_LKUP_MAC_VLAN = 2,
38 ICE_SW_LKUP_PROMISC = 3,
41 ICE_SW_LKUP_ETHERTYPE_MAC = 8,
42 ICE_SW_LKUP_PROMISC_VLAN = 9,
46 /* type of filter src id */
48 ICE_SRC_ID_UNKNOWN = 0,
54 struct ice_fltr_info {
55 /* Look up information: how to look up packet */
56 enum ice_sw_lkup_type lkup_type;
57 /* Forward action: filter action to do after lookup */
58 enum ice_sw_fwd_act_type fltr_act;
59 /* rule ID returned by firmware once filter rule is created */
62 #define ICE_FLTR_RX BIT(0)
63 #define ICE_FLTR_TX BIT(1)
64 #define ICE_FLTR_TX_RX (ICE_FLTR_RX | ICE_FLTR_TX)
66 /* Source VSI for LOOKUP_TX or source port for LOOKUP_RX */
68 enum ice_src_id src_id;
72 u8 mac_addr[ETH_ALEN];
75 u8 mac_addr[ETH_ALEN];
81 /* Set lkup_type as ICE_SW_LKUP_ETHERTYPE
82 * if just using ethertype as filter. Set lkup_type as
83 * ICE_SW_LKUP_ETHERTYPE_MAC if MAC also needs to be
84 * passed in as filter.
88 u8 mac_addr[ETH_ALEN]; /* optional */
90 } l_data; /* Make sure to zero out the memory of l_data before using
91 * it or only set the data associated with lookup match
92 * rest everything should be zero
95 /* Depending on filter action */
97 /* queue id in case of ICE_FWD_TO_Q and starting
98 * queue id in case of ICE_FWD_TO_QGRP.
109 /* Set to num_queues if action is ICE_FWD_TO_QGRP. This field
110 * determines the range of queues the packet needs to be forwarded to.
111 * Note that qgrp_size must be set to a power of 2.
115 /* Rule creations populate these indicators basing on the switch type */
116 u8 lb_en; /* Indicate if packet can be looped back */
117 u8 lan_en; /* Indicate if packet can be forwarded to the uplink */
120 struct ice_adv_lkup_elem {
121 enum ice_protocol_type type;
122 union ice_prot_hdr h_u; /* Header values */
123 union ice_prot_hdr m_u; /* Mask of header values to match */
126 struct ice_sw_act_ctrl {
127 /* Source VSI for LOOKUP_TX or source port for LOOKUP_RX */
130 #define ICE_FLTR_RX BIT(0)
131 #define ICE_FLTR_TX BIT(1)
132 #define ICE_FLTR_TX_RX (ICE_FLTR_RX | ICE_FLTR_TX)
134 enum ice_sw_fwd_act_type fltr_act;
135 /* Depending on filter action */
137 /* This is a queue id in case of ICE_FWD_TO_Q and starting
138 * queue id in case of ICE_FWD_TO_QGRP.
145 /* software VSI handle */
150 struct ice_adv_rule_info {
151 enum ice_sw_tunnel_type tun_type;
152 struct ice_sw_act_ctrl sw_act;
154 u8 rx; /* true means LOOKUP_RX otherwise LOOKUP_TX */
157 /* A collection of one or more four word recipe */
158 struct ice_sw_recipe {
159 /* For a chained recipe the root recipe is what should be used for
165 /* Number of extraction words */
167 /* Protocol ID and Offset pair (extraction word) to describe the
170 struct ice_fv_word ext_words[ICE_MAX_CHAIN_WORDS];
172 /* if this recipe is a collection of other recipe */
175 /* if this recipe is part of another bigger recipe then chain index
176 * corresponding to this recipe
180 /* if this recipe is a collection of other recipe then count of other
181 * recipes and recipe ids of those recipes
185 /* Bit map specifying the IDs associated with this group of recipe */
186 ice_declare_bitmap(r_bitmap, ICE_MAX_NUM_RECIPES);
188 enum ice_sw_tunnel_type tun_type;
190 /* List of type ice_fltr_mgmt_list_entry or adv_rule */
192 struct LIST_HEAD_TYPE filt_rules;
193 struct LIST_HEAD_TYPE filt_replay_rules;
195 struct ice_lock filt_rule_lock; /* protect filter rule structure */
197 /* Profiles this recipe should be associated with */
198 struct LIST_HEAD_TYPE fv_list;
200 /* Profiles this recipe is associated with */
201 u8 num_profs, *prof_ids;
203 /* This allows user to specify the recipe priority.
204 * For now, this becomes 'fwd_priority' when recipe
205 * is created, usually recipes can have 'fwd' and 'join'
210 struct LIST_HEAD_TYPE rg_list;
212 /* AQ buffer associated with this recipe */
213 struct ice_aqc_recipe_data_elem *root_buf;
216 /* Bookkeeping structure to hold bitmap of VSIs corresponding to VSI list id */
217 struct ice_vsi_list_map_info {
218 struct LIST_ENTRY_TYPE list_entry;
219 ice_declare_bitmap(vsi_map, ICE_MAX_VSI);
221 /* counter to track how many rules are reusing this VSI list */
225 struct ice_fltr_list_entry {
226 struct LIST_ENTRY_TYPE list_entry;
227 enum ice_status status;
228 struct ice_fltr_info fltr_info;
231 /* This defines an entry in the list that maintains MAC or VLAN membership
232 * to HW list mapping, since multiple VSIs can subscribe to the same MAC or
233 * VLAN. As an optimization the VSI list should be created only when a
234 * second VSI becomes a subscriber to the same MAC address. VSI lists are always
235 * used for VLAN membership.
237 struct ice_fltr_mgmt_list_entry {
238 /* back pointer to VSI list id to VSI list mapping */
239 struct ice_vsi_list_map_info *vsi_list_info;
241 #define ICE_INVAL_LG_ACT_INDEX 0xffff
243 #define ICE_INVAL_SW_MARKER_ID 0xffff
245 struct LIST_ENTRY_TYPE list_entry;
246 struct ice_fltr_info fltr_info;
247 #define ICE_INVAL_COUNTER_ID 0xff
251 struct ice_adv_fltr_mgmt_list_entry {
252 struct LIST_ENTRY_TYPE list_entry;
254 struct ice_adv_lkup_elem *lkups;
255 struct ice_adv_rule_info rule_info;
259 enum ice_promisc_flags {
260 ICE_PROMISC_UCAST_RX = 0x1,
261 ICE_PROMISC_UCAST_TX = 0x2,
262 ICE_PROMISC_MCAST_RX = 0x4,
263 ICE_PROMISC_MCAST_TX = 0x8,
264 ICE_PROMISC_BCAST_RX = 0x10,
265 ICE_PROMISC_BCAST_TX = 0x20,
266 ICE_PROMISC_VLAN_RX = 0x40,
267 ICE_PROMISC_VLAN_TX = 0x80,
270 /* VSI related commands */
272 ice_add_vsi(struct ice_hw *hw, u16 vsi_handle, struct ice_vsi_ctx *vsi_ctx,
273 struct ice_sq_cd *cd);
275 ice_free_vsi(struct ice_hw *hw, u16 vsi_handle, struct ice_vsi_ctx *vsi_ctx,
276 bool keep_vsi_alloc, struct ice_sq_cd *cd);
278 ice_update_vsi(struct ice_hw *hw, u16 vsi_handle, struct ice_vsi_ctx *vsi_ctx,
279 struct ice_sq_cd *cd);
280 struct ice_vsi_ctx *ice_get_vsi_ctx(struct ice_hw *hw, u16 vsi_handle);
281 void ice_clear_all_vsi_ctx(struct ice_hw *hw);
283 enum ice_status ice_get_initial_sw_cfg(struct ice_hw *hw);
286 ice_alloc_vlan_res_counter(struct ice_hw *hw, u16 *counter_id);
288 ice_free_vlan_res_counter(struct ice_hw *hw, u16 counter_id);
290 /* Switch/bridge related commands */
291 enum ice_status ice_update_sw_rule_bridge_mode(struct ice_hw *hw);
293 ice_add_vlan(struct ice_hw *hw, struct LIST_HEAD_TYPE *m_list);
294 enum ice_status ice_add_mac(struct ice_hw *hw, struct LIST_HEAD_TYPE *m_lst);
295 enum ice_status ice_remove_mac(struct ice_hw *hw, struct LIST_HEAD_TYPE *m_lst);
297 ice_remove_vlan(struct ice_hw *hw, struct LIST_HEAD_TYPE *v_list);
298 #ifndef NO_MACVLAN_SUPPORT
300 ice_add_mac_vlan(struct ice_hw *hw, struct LIST_HEAD_TYPE *m_list);
302 ice_remove_mac_vlan(struct ice_hw *hw, struct LIST_HEAD_TYPE *v_list);
303 #endif /* !NO_MACVLAN_SUPPORT */
305 void ice_remove_vsi_fltr(struct ice_hw *hw, u16 vsi_handle);
308 /* Promisc/defport setup for VSIs */
310 ice_cfg_dflt_vsi(struct ice_port_info *pi, u16 vsi_handle, bool set,
313 ice_set_vsi_promisc(struct ice_hw *hw, u16 vsi_handle, u8 promisc_mask,
316 ice_clear_vsi_promisc(struct ice_hw *hw, u16 vsi_handle, u8 promisc_mask,
319 ice_set_vlan_vsi_promisc(struct ice_hw *hw, u16 vsi_handle, u8 promisc_mask,
320 bool rm_vlan_promisc);
326 enum ice_status ice_init_def_sw_recp(struct ice_hw *hw);
327 u16 ice_get_hw_vsi_num(struct ice_hw *hw, u16 vsi_handle);
328 bool ice_is_vsi_valid(struct ice_hw *hw, u16 vsi_handle);
330 enum ice_status ice_replay_vsi_all_fltr(struct ice_hw *hw, u16 vsi_handle);
331 void ice_rm_all_sw_replay_rule_info(struct ice_hw *hw);
333 #endif /* _ICE_SWITCH_H_ */