1 /******************************************************************************
2 
3   Copyright (c) 2013-2018, Intel Corporation
4   All rights reserved.
5 
6   Redistribution and use in source and binary forms, with or without
7   modification, are permitted provided that the following conditions are met:
8 
9    1. Redistributions of source code must retain the above copyright notice,
10       this list of conditions and the following disclaimer.
11 
12    2. Redistributions in binary form must reproduce the above copyright
13       notice, this list of conditions and the following disclaimer in the
14       documentation and/or other materials provided with the distribution.
15 
16    3. Neither the name of the Intel Corporation nor the names of its
17       contributors may be used to endorse or promote products derived from
18       this software without specific prior written permission.
19 
20   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30   POSSIBILITY OF SUCH DAMAGE.
31 
32 ******************************************************************************/
33 /*$FreeBSD$*/
34 
35 #ifndef _I40E_PROTOTYPE_H_
36 #define _I40E_PROTOTYPE_H_
37 
38 #include "i40e_type.h"
39 #include "i40e_alloc.h"
40 #include "virtchnl.h"
41 
42 /* Prototypes for shared code functions that are not in
43  * the standard function pointer structures.  These are
44  * mostly because they are needed even before the init
45  * has happened and will assist in the early SW and FW
46  * setup.
47  */
48 
49 /* adminq functions */
50 enum i40e_status_code i40e_init_adminq(struct i40e_hw *hw);
51 enum i40e_status_code i40e_shutdown_adminq(struct i40e_hw *hw);
52 enum i40e_status_code i40e_init_asq(struct i40e_hw *hw);
53 enum i40e_status_code i40e_init_arq(struct i40e_hw *hw);
54 enum i40e_status_code i40e_alloc_adminq_asq_ring(struct i40e_hw *hw);
55 enum i40e_status_code i40e_alloc_adminq_arq_ring(struct i40e_hw *hw);
56 enum i40e_status_code i40e_shutdown_asq(struct i40e_hw *hw);
57 enum i40e_status_code i40e_shutdown_arq(struct i40e_hw *hw);
58 u16 i40e_clean_asq(struct i40e_hw *hw);
59 void i40e_free_adminq_asq(struct i40e_hw *hw);
60 void i40e_free_adminq_arq(struct i40e_hw *hw);
61 enum i40e_status_code i40e_validate_mac_addr(u8 *mac_addr);
62 void i40e_adminq_init_ring_data(struct i40e_hw *hw);
63 enum i40e_status_code i40e_clean_arq_element(struct i40e_hw *hw,
64 					     struct i40e_arq_event_info *e,
65 					     u16 *events_pending);
66 enum i40e_status_code i40e_asq_send_command(struct i40e_hw *hw,
67 				struct i40e_aq_desc *desc,
68 				void *buff, /* can be NULL */
69 				u16  buff_size,
70 				struct i40e_asq_cmd_details *cmd_details);
71 bool i40e_asq_done(struct i40e_hw *hw);
72 
73 /* debug function for adminq */
74 void i40e_debug_aq(struct i40e_hw *hw, enum i40e_debug_mask mask,
75 		   void *desc, void *buffer, u16 buf_len);
76 
77 void i40e_idle_aq(struct i40e_hw *hw);
78 bool i40e_check_asq_alive(struct i40e_hw *hw);
79 enum i40e_status_code i40e_aq_queue_shutdown(struct i40e_hw *hw, bool unloading);
80 
81 enum i40e_status_code i40e_aq_get_rss_lut(struct i40e_hw *hw, u16 seid,
82 					  bool pf_lut, u8 *lut, u16 lut_size);
83 enum i40e_status_code i40e_aq_set_rss_lut(struct i40e_hw *hw, u16 seid,
84 					  bool pf_lut, u8 *lut, u16 lut_size);
85 enum i40e_status_code i40e_aq_get_rss_key(struct i40e_hw *hw,
86 				     u16 seid,
87 				     struct i40e_aqc_get_set_rss_key_data *key);
88 enum i40e_status_code i40e_aq_set_rss_key(struct i40e_hw *hw,
89 				     u16 seid,
90 				     struct i40e_aqc_get_set_rss_key_data *key);
91 const char *i40e_aq_str(struct i40e_hw *hw, enum i40e_admin_queue_err aq_err);
92 const char *i40e_stat_str(struct i40e_hw *hw, enum i40e_status_code stat_err);
93 
94 
95 u32 i40e_led_get(struct i40e_hw *hw);
96 void i40e_led_set(struct i40e_hw *hw, u32 mode, bool blink);
97 enum i40e_status_code i40e_led_set_phy(struct i40e_hw *hw, bool on,
98 				       u16 led_addr, u32 mode);
99 enum i40e_status_code i40e_led_get_phy(struct i40e_hw *hw, u16 *led_addr,
100 				       u16 *val);
101 enum i40e_status_code i40e_blink_phy_link_led(struct i40e_hw *hw,
102 					      u32 time, u32 interval);
103 enum i40e_status_code i40e_led_get_reg(struct i40e_hw *hw, u16 led_addr,
104 				       u32 *reg_val);
105 enum i40e_status_code i40e_led_set_reg(struct i40e_hw *hw, u16 led_addr,
106 				       u32 reg_val);
107 enum i40e_status_code i40e_get_phy_lpi_status(struct i40e_hw *hw,
108 					      struct i40e_hw_port_stats *stats);
109 enum i40e_status_code i40e_get_lpi_counters(struct i40e_hw *hw, u32 *tx_counter,
110 					    u32 *rx_counter, bool *is_clear);
111 enum i40e_status_code i40e_lpi_stat_update(struct i40e_hw *hw,
112 					   bool offset_loaded, u64 *tx_offset,
113 					   u64 *tx_stat, u64 *rx_offset,
114 					   u64 *rx_stat);
115 enum i40e_status_code i40e_get_lpi_duration(struct i40e_hw *hw,
116 					    struct i40e_hw_port_stats *stat,
117 					    u64 *tx_duration, u64 *rx_duration);
118 /* admin send queue commands */
119 
120 enum i40e_status_code i40e_aq_get_firmware_version(struct i40e_hw *hw,
121 				u16 *fw_major_version, u16 *fw_minor_version,
122 				u32 *fw_build,
123 				u16 *api_major_version, u16 *api_minor_version,
124 				struct i40e_asq_cmd_details *cmd_details);
125 enum i40e_status_code i40e_aq_debug_write_register(struct i40e_hw *hw,
126 				u32 reg_addr, u64 reg_val,
127 				struct i40e_asq_cmd_details *cmd_details);
128 enum i40e_status_code i40e_aq_debug_read_register(struct i40e_hw *hw,
129 				u32  reg_addr, u64 *reg_val,
130 				struct i40e_asq_cmd_details *cmd_details);
131 enum i40e_status_code i40e_aq_set_phy_debug(struct i40e_hw *hw, u8 cmd_flags,
132 				struct i40e_asq_cmd_details *cmd_details);
133 enum i40e_status_code i40e_aq_set_default_vsi(struct i40e_hw *hw, u16 vsi_id,
134 				struct i40e_asq_cmd_details *cmd_details);
135 enum i40e_status_code i40e_aq_clear_default_vsi(struct i40e_hw *hw, u16 vsi_id,
136 				struct i40e_asq_cmd_details *cmd_details);
137 enum i40e_status_code i40e_aq_get_phy_capabilities(struct i40e_hw *hw,
138 			bool qualified_modules, bool report_init,
139 			struct i40e_aq_get_phy_abilities_resp *abilities,
140 			struct i40e_asq_cmd_details *cmd_details);
141 enum i40e_status_code i40e_aq_set_phy_config(struct i40e_hw *hw,
142 				struct i40e_aq_set_phy_config *config,
143 				struct i40e_asq_cmd_details *cmd_details);
144 enum i40e_status_code i40e_set_fc(struct i40e_hw *hw, u8 *aq_failures,
145 				  bool atomic_reset);
146 enum i40e_status_code i40e_aq_set_phy_int_mask(struct i40e_hw *hw, u16 mask,
147 				struct i40e_asq_cmd_details *cmd_details);
148 enum i40e_status_code i40e_aq_set_mac_config(struct i40e_hw *hw,
149 				u16 max_frame_size, bool crc_en, u16 pacing,
150 				bool auto_drop_blocking_packets,
151 				struct i40e_asq_cmd_details *cmd_details);
152 enum i40e_status_code i40e_aq_get_local_advt_reg(struct i40e_hw *hw,
153 				u64 *advt_reg,
154 				struct i40e_asq_cmd_details *cmd_details);
155 enum i40e_status_code i40e_aq_get_partner_advt(struct i40e_hw *hw,
156 				u64 *advt_reg,
157 				struct i40e_asq_cmd_details *cmd_details);
158 enum i40e_status_code
159 i40e_aq_set_lb_modes(struct i40e_hw *hw, u8 lb_level, u8 lb_type, u8 speed,
160 		     struct i40e_asq_cmd_details *cmd_details);
161 enum i40e_status_code i40e_aq_clear_pxe_mode(struct i40e_hw *hw,
162 			struct i40e_asq_cmd_details *cmd_details);
163 enum i40e_status_code i40e_aq_set_link_restart_an(struct i40e_hw *hw,
164 		bool enable_link, struct i40e_asq_cmd_details *cmd_details);
165 enum i40e_status_code i40e_aq_get_link_info(struct i40e_hw *hw,
166 				bool enable_lse, struct i40e_link_status *link,
167 				struct i40e_asq_cmd_details *cmd_details);
168 enum i40e_status_code i40e_aq_set_local_advt_reg(struct i40e_hw *hw,
169 				u64 advt_reg,
170 				struct i40e_asq_cmd_details *cmd_details);
171 enum i40e_status_code i40e_aq_send_driver_version(struct i40e_hw *hw,
172 				struct i40e_driver_version *dv,
173 				struct i40e_asq_cmd_details *cmd_details);
174 enum i40e_status_code i40e_aq_add_vsi(struct i40e_hw *hw,
175 				struct i40e_vsi_context *vsi_ctx,
176 				struct i40e_asq_cmd_details *cmd_details);
177 enum i40e_status_code i40e_aq_set_vsi_broadcast(struct i40e_hw *hw,
178 				u16 vsi_id, bool set_filter,
179 				struct i40e_asq_cmd_details *cmd_details);
180 enum i40e_status_code i40e_aq_set_vsi_unicast_promiscuous(struct i40e_hw *hw,
181 		u16 vsi_id, bool set, struct i40e_asq_cmd_details *cmd_details,
182 		bool rx_only_promisc);
183 enum i40e_status_code i40e_aq_set_vsi_multicast_promiscuous(struct i40e_hw *hw,
184 		u16 vsi_id, bool set, struct i40e_asq_cmd_details *cmd_details);
185 enum i40e_status_code i40e_aq_set_vsi_full_promiscuous(struct i40e_hw *hw,
186 				u16 seid, bool set,
187 				struct i40e_asq_cmd_details *cmd_details);
188 enum i40e_status_code i40e_aq_set_vsi_mc_promisc_on_vlan(struct i40e_hw *hw,
189 				u16 seid, bool enable, u16 vid,
190 				struct i40e_asq_cmd_details *cmd_details);
191 enum i40e_status_code i40e_aq_set_vsi_uc_promisc_on_vlan(struct i40e_hw *hw,
192 				u16 seid, bool enable, u16 vid,
193 				struct i40e_asq_cmd_details *cmd_details);
194 enum i40e_status_code i40e_aq_set_vsi_bc_promisc_on_vlan(struct i40e_hw *hw,
195 				u16 seid, bool enable, u16 vid,
196 				struct i40e_asq_cmd_details *cmd_details);
197 enum i40e_status_code i40e_aq_set_vsi_vlan_promisc(struct i40e_hw *hw,
198 				u16 seid, bool enable,
199 				struct i40e_asq_cmd_details *cmd_details);
200 enum i40e_status_code i40e_aq_get_vsi_params(struct i40e_hw *hw,
201 				struct i40e_vsi_context *vsi_ctx,
202 				struct i40e_asq_cmd_details *cmd_details);
203 enum i40e_status_code i40e_aq_update_vsi_params(struct i40e_hw *hw,
204 				struct i40e_vsi_context *vsi_ctx,
205 				struct i40e_asq_cmd_details *cmd_details);
206 enum i40e_status_code i40e_aq_add_veb(struct i40e_hw *hw, u16 uplink_seid,
207 				u16 downlink_seid, u8 enabled_tc,
208 				bool default_port, u16 *pveb_seid,
209 				bool enable_stats,
210 				struct i40e_asq_cmd_details *cmd_details);
211 enum i40e_status_code i40e_aq_get_veb_parameters(struct i40e_hw *hw,
212 				u16 veb_seid, u16 *switch_id, bool *floating,
213 				u16 *statistic_index, u16 *vebs_used,
214 				u16 *vebs_free,
215 				struct i40e_asq_cmd_details *cmd_details);
216 enum i40e_status_code i40e_aq_add_macvlan(struct i40e_hw *hw, u16 vsi_id,
217 			struct i40e_aqc_add_macvlan_element_data *mv_list,
218 			u16 count, struct i40e_asq_cmd_details *cmd_details);
219 enum i40e_status_code i40e_aq_remove_macvlan(struct i40e_hw *hw, u16 vsi_id,
220 			struct i40e_aqc_remove_macvlan_element_data *mv_list,
221 			u16 count, struct i40e_asq_cmd_details *cmd_details);
222 enum i40e_status_code i40e_aq_add_mirrorrule(struct i40e_hw *hw, u16 sw_seid,
223 			u16 rule_type, u16 dest_vsi, u16 count, __le16 *mr_list,
224 			struct i40e_asq_cmd_details *cmd_details,
225 			u16 *rule_id, u16 *rules_used, u16 *rules_free);
226 enum i40e_status_code i40e_aq_delete_mirrorrule(struct i40e_hw *hw, u16 sw_seid,
227 			u16 rule_type, u16 rule_id, u16 count, __le16 *mr_list,
228 			struct i40e_asq_cmd_details *cmd_details,
229 			u16 *rules_used, u16 *rules_free);
230 
231 enum i40e_status_code i40e_aq_add_vlan(struct i40e_hw *hw, u16 vsi_id,
232 			struct i40e_aqc_add_remove_vlan_element_data *v_list,
233 			u8 count, struct i40e_asq_cmd_details *cmd_details);
234 enum i40e_status_code i40e_aq_remove_vlan(struct i40e_hw *hw, u16 vsi_id,
235 			struct i40e_aqc_add_remove_vlan_element_data *v_list,
236 			u8 count, struct i40e_asq_cmd_details *cmd_details);
237 enum i40e_status_code i40e_aq_send_msg_to_vf(struct i40e_hw *hw, u16 vfid,
238 				u32 v_opcode, u32 v_retval, u8 *msg, u16 msglen,
239 				struct i40e_asq_cmd_details *cmd_details);
240 enum i40e_status_code i40e_aq_get_switch_config(struct i40e_hw *hw,
241 				struct i40e_aqc_get_switch_config_resp *buf,
242 				u16 buf_size, u16 *start_seid,
243 				struct i40e_asq_cmd_details *cmd_details);
244 enum i40e_status_code i40e_aq_set_switch_config(struct i40e_hw *hw,
245 				u16 flags, u16 valid_flags, u8 mode,
246 				struct i40e_asq_cmd_details *cmd_details);
247 enum i40e_status_code i40e_aq_request_resource(struct i40e_hw *hw,
248 				enum i40e_aq_resources_ids resource,
249 				enum i40e_aq_resource_access_type access,
250 				u8 sdp_number, u64 *timeout,
251 				struct i40e_asq_cmd_details *cmd_details);
252 enum i40e_status_code i40e_aq_release_resource(struct i40e_hw *hw,
253 				enum i40e_aq_resources_ids resource,
254 				u8 sdp_number,
255 				struct i40e_asq_cmd_details *cmd_details);
256 enum i40e_status_code i40e_aq_read_nvm(struct i40e_hw *hw, u8 module_pointer,
257 				u32 offset, u16 length, void *data,
258 				bool last_command,
259 				struct i40e_asq_cmd_details *cmd_details);
260 enum i40e_status_code i40e_aq_erase_nvm(struct i40e_hw *hw, u8 module_pointer,
261 				u32 offset, u16 length, bool last_command,
262 				struct i40e_asq_cmd_details *cmd_details);
263 enum i40e_status_code i40e_aq_read_nvm_config(struct i40e_hw *hw,
264 				u8 cmd_flags, u32 field_id, void *data,
265 				u16 buf_size, u16 *element_count,
266 				struct i40e_asq_cmd_details *cmd_details);
267 enum i40e_status_code i40e_aq_write_nvm_config(struct i40e_hw *hw,
268 				u8 cmd_flags, void *data, u16 buf_size,
269 				u16 element_count,
270 				struct i40e_asq_cmd_details *cmd_details);
271 enum i40e_status_code i40e_aq_oem_post_update(struct i40e_hw *hw,
272 				void *buff, u16 buff_size,
273 				struct i40e_asq_cmd_details *cmd_details);
274 enum i40e_status_code i40e_aq_discover_capabilities(struct i40e_hw *hw,
275 				void *buff, u16 buff_size, u16 *data_size,
276 				enum i40e_admin_queue_opc list_type_opc,
277 				struct i40e_asq_cmd_details *cmd_details);
278 enum i40e_status_code i40e_aq_update_nvm(struct i40e_hw *hw, u8 module_pointer,
279 				u32 offset, u16 length, void *data,
280 				bool last_command, u8 preservation_flags,
281 				struct i40e_asq_cmd_details *cmd_details);
282 enum i40e_status_code i40e_aq_nvm_progress(struct i40e_hw *hw, u8 *progress,
283 				struct i40e_asq_cmd_details *cmd_details);
284 enum i40e_status_code i40e_aq_get_lldp_mib(struct i40e_hw *hw, u8 bridge_type,
285 				u8 mib_type, void *buff, u16 buff_size,
286 				u16 *local_len, u16 *remote_len,
287 				struct i40e_asq_cmd_details *cmd_details);
288 enum i40e_status_code i40e_aq_set_lldp_mib(struct i40e_hw *hw,
289 				u8 mib_type, void *buff, u16 buff_size,
290 				struct i40e_asq_cmd_details *cmd_details);
291 enum i40e_status_code i40e_aq_cfg_lldp_mib_change_event(struct i40e_hw *hw,
292 				bool enable_update,
293 				struct i40e_asq_cmd_details *cmd_details);
294 enum i40e_status_code
295 i40e_aq_restore_lldp(struct i40e_hw *hw, u8 *setting, bool restore,
296 		     struct i40e_asq_cmd_details *cmd_details);
297 enum i40e_status_code i40e_aq_stop_lldp(struct i40e_hw *hw, bool shutdown_agent,
298 				bool persist,
299 				struct i40e_asq_cmd_details *cmd_details);
300 enum i40e_status_code i40e_aq_set_dcb_parameters(struct i40e_hw *hw,
301 						 bool dcb_enable,
302 						 struct i40e_asq_cmd_details
303 						 *cmd_details);
304 enum i40e_status_code i40e_aq_start_lldp(struct i40e_hw *hw,
305 				bool persist,
306 				struct i40e_asq_cmd_details *cmd_details);
307 enum i40e_status_code i40e_aq_get_cee_dcb_config(struct i40e_hw *hw,
308 				void *buff, u16 buff_size,
309 				struct i40e_asq_cmd_details *cmd_details);
310 enum i40e_status_code i40e_aq_start_stop_dcbx(struct i40e_hw *hw,
311 				bool start_agent,
312 				struct i40e_asq_cmd_details *cmd_details);
313 enum i40e_status_code i40e_aq_add_udp_tunnel(struct i40e_hw *hw,
314 				u16 udp_port, u8 protocol_index,
315 				u8 *filter_index,
316 				struct i40e_asq_cmd_details *cmd_details);
317 enum i40e_status_code i40e_aq_del_udp_tunnel(struct i40e_hw *hw, u8 index,
318 				struct i40e_asq_cmd_details *cmd_details);
319 enum i40e_status_code i40e_aq_get_switch_resource_alloc(struct i40e_hw *hw,
320 			u8 *num_entries,
321 			struct i40e_aqc_switch_resource_alloc_element_resp *buf,
322 			u16 count,
323 			struct i40e_asq_cmd_details *cmd_details);
324 enum i40e_status_code i40e_aq_add_pvirt(struct i40e_hw *hw, u16 flags,
325 				       u16 mac_seid, u16 vsi_seid,
326 				       u16 *ret_seid);
327 enum i40e_status_code i40e_aq_add_tag(struct i40e_hw *hw, bool direct_to_queue,
328 				u16 vsi_seid, u16 tag, u16 queue_num,
329 				u16 *tags_used, u16 *tags_free,
330 				struct i40e_asq_cmd_details *cmd_details);
331 enum i40e_status_code i40e_aq_remove_tag(struct i40e_hw *hw, u16 vsi_seid,
332 				u16 tag, u16 *tags_used, u16 *tags_free,
333 				struct i40e_asq_cmd_details *cmd_details);
334 enum i40e_status_code i40e_aq_add_mcast_etag(struct i40e_hw *hw, u16 pe_seid,
335 				u16 etag, u8 num_tags_in_buf, void *buf,
336 				u16 *tags_used, u16 *tags_free,
337 				struct i40e_asq_cmd_details *cmd_details);
338 enum i40e_status_code i40e_aq_remove_mcast_etag(struct i40e_hw *hw, u16 pe_seid,
339 				u16 etag, u16 *tags_used, u16 *tags_free,
340 				struct i40e_asq_cmd_details *cmd_details);
341 enum i40e_status_code i40e_aq_update_tag(struct i40e_hw *hw, u16 vsi_seid,
342 				u16 old_tag, u16 new_tag, u16 *tags_used,
343 				u16 *tags_free,
344 				struct i40e_asq_cmd_details *cmd_details);
345 enum i40e_status_code i40e_aq_add_statistics(struct i40e_hw *hw, u16 seid,
346 				u16 vlan_id, u16 *stat_index,
347 				struct i40e_asq_cmd_details *cmd_details);
348 enum i40e_status_code i40e_aq_remove_statistics(struct i40e_hw *hw, u16 seid,
349 				u16 vlan_id, u16 stat_index,
350 				struct i40e_asq_cmd_details *cmd_details);
351 enum i40e_status_code i40e_aq_set_port_parameters(struct i40e_hw *hw,
352 				u16 bad_frame_vsi, bool save_bad_pac,
353 				bool pad_short_pac, bool double_vlan,
354 				struct i40e_asq_cmd_details *cmd_details);
355 enum i40e_status_code i40e_aq_delete_element(struct i40e_hw *hw, u16 seid,
356 				struct i40e_asq_cmd_details *cmd_details);
357 enum i40e_status_code i40e_aq_mac_address_write(struct i40e_hw *hw,
358 				    u16 flags, u8 *mac_addr,
359 				    struct i40e_asq_cmd_details *cmd_details);
360 enum i40e_status_code i40e_aq_config_vsi_bw_limit(struct i40e_hw *hw,
361 				u16 seid, u16 credit, u8 max_credit,
362 				struct i40e_asq_cmd_details *cmd_details);
363 enum i40e_status_code i40e_aq_dcb_ignore_pfc(struct i40e_hw *hw,
364 				u8 tcmap, bool request, u8 *tcmap_ret,
365 				struct i40e_asq_cmd_details *cmd_details);
366 enum i40e_status_code i40e_aq_config_switch_comp_ets_bw_limit(
367 	struct i40e_hw *hw, u16 seid,
368 	struct i40e_aqc_configure_switching_comp_ets_bw_limit_data *bw_data,
369 	struct i40e_asq_cmd_details *cmd_details);
370 enum i40e_status_code i40e_aq_config_vsi_ets_sla_bw_limit(struct i40e_hw *hw,
371 			u16 seid,
372 			struct i40e_aqc_configure_vsi_ets_sla_bw_data *bw_data,
373 			struct i40e_asq_cmd_details *cmd_details);
374 enum i40e_status_code i40e_aq_dcb_updated(struct i40e_hw *hw,
375 				struct i40e_asq_cmd_details *cmd_details);
376 enum i40e_status_code i40e_aq_config_switch_comp_bw_limit(struct i40e_hw *hw,
377 				u16 seid, u16 credit, u8 max_bw,
378 				struct i40e_asq_cmd_details *cmd_details);
379 enum i40e_status_code i40e_aq_config_vsi_tc_bw(struct i40e_hw *hw, u16 seid,
380 			struct i40e_aqc_configure_vsi_tc_bw_data *bw_data,
381 			struct i40e_asq_cmd_details *cmd_details);
382 enum i40e_status_code i40e_aq_query_vsi_bw_config(struct i40e_hw *hw,
383 			u16 seid,
384 			struct i40e_aqc_query_vsi_bw_config_resp *bw_data,
385 			struct i40e_asq_cmd_details *cmd_details);
386 enum i40e_status_code i40e_aq_query_vsi_ets_sla_config(struct i40e_hw *hw,
387 			u16 seid,
388 			struct i40e_aqc_query_vsi_ets_sla_config_resp *bw_data,
389 			struct i40e_asq_cmd_details *cmd_details);
390 enum i40e_status_code i40e_aq_query_switch_comp_ets_config(struct i40e_hw *hw,
391 		u16 seid,
392 		struct i40e_aqc_query_switching_comp_ets_config_resp *bw_data,
393 		struct i40e_asq_cmd_details *cmd_details);
394 enum i40e_status_code i40e_aq_query_port_ets_config(struct i40e_hw *hw,
395 		u16 seid,
396 		struct i40e_aqc_query_port_ets_config_resp *bw_data,
397 		struct i40e_asq_cmd_details *cmd_details);
398 enum i40e_status_code i40e_aq_query_switch_comp_bw_config(struct i40e_hw *hw,
399 		u16 seid,
400 		struct i40e_aqc_query_switching_comp_bw_config_resp *bw_data,
401 		struct i40e_asq_cmd_details *cmd_details);
402 enum i40e_status_code i40e_aq_resume_port_tx(struct i40e_hw *hw,
403 				struct i40e_asq_cmd_details *cmd_details);
404 enum i40e_status_code
405 i40e_aq_add_cloud_filters_bb(struct i40e_hw *hw, u16 seid,
406 			     struct i40e_aqc_cloud_filters_element_bb *filters,
407 			     u8 filter_count);
408 enum i40e_status_code
409 i40e_aq_add_cloud_filters(struct i40e_hw *hw, u16 vsi,
410 			  struct i40e_aqc_cloud_filters_element_data *filters,
411 			  u8 filter_count);
412 enum i40e_status_code
413 i40e_aq_rem_cloud_filters(struct i40e_hw *hw, u16 vsi,
414 			  struct i40e_aqc_cloud_filters_element_data *filters,
415 			  u8 filter_count);
416 enum i40e_status_code
417 i40e_aq_rem_cloud_filters_bb(struct i40e_hw *hw, u16 seid,
418 			     struct i40e_aqc_cloud_filters_element_bb *filters,
419 			     u8 filter_count);
420 enum i40e_status_code i40e_read_lldp_cfg(struct i40e_hw *hw,
421 					struct i40e_lldp_variables *lldp_cfg);
422 enum i40e_status_code i40e_aq_replace_cloud_filters(struct i40e_hw *hw,
423 		struct i40e_aqc_replace_cloud_filters_cmd *filters,
424 		struct i40e_aqc_replace_cloud_filters_cmd_buf *cmd_buf);
425 enum i40e_status_code i40e_aq_alternate_read(struct i40e_hw *hw,
426 				u32 reg_addr0, u32 *reg_val0,
427 				u32 reg_addr1, u32 *reg_val1);
428 enum i40e_status_code i40e_aq_alternate_read_indirect(struct i40e_hw *hw,
429 				u32 addr, u32 dw_count, void *buffer);
430 enum i40e_status_code i40e_aq_alternate_write(struct i40e_hw *hw,
431 				u32 reg_addr0, u32 reg_val0,
432 				u32 reg_addr1, u32 reg_val1);
433 enum i40e_status_code i40e_aq_alternate_write_indirect(struct i40e_hw *hw,
434 				u32 addr, u32 dw_count, void *buffer);
435 enum i40e_status_code i40e_aq_alternate_clear(struct i40e_hw *hw);
436 enum i40e_status_code i40e_aq_alternate_write_done(struct i40e_hw *hw,
437 				u8 bios_mode, bool *reset_needed);
438 enum i40e_status_code i40e_aq_set_oem_mode(struct i40e_hw *hw,
439 				u8 oem_mode);
440 
441 /* i40e_common */
442 enum i40e_status_code i40e_init_shared_code(struct i40e_hw *hw);
443 enum i40e_status_code i40e_pf_reset(struct i40e_hw *hw);
444 void i40e_clear_hw(struct i40e_hw *hw);
445 void i40e_clear_pxe_mode(struct i40e_hw *hw);
446 enum i40e_status_code i40e_get_link_status(struct i40e_hw *hw, bool *link_up);
447 enum i40e_status_code i40e_update_link_info(struct i40e_hw *hw);
448 enum i40e_status_code i40e_get_mac_addr(struct i40e_hw *hw, u8 *mac_addr);
449 enum i40e_status_code i40e_read_bw_from_alt_ram(struct i40e_hw *hw,
450 		u32 *max_bw, u32 *min_bw, bool *min_valid, bool *max_valid);
451 enum i40e_status_code i40e_aq_configure_partition_bw(struct i40e_hw *hw,
452 			struct i40e_aqc_configure_partition_bw_data *bw_data,
453 			struct i40e_asq_cmd_details *cmd_details);
454 enum i40e_status_code i40e_get_port_mac_addr(struct i40e_hw *hw, u8 *mac_addr);
455 enum i40e_status_code i40e_read_pba_string(struct i40e_hw *hw, u8 *pba_num,
456 					    u32 pba_num_size);
457 void i40e_pre_tx_queue_cfg(struct i40e_hw *hw, u32 queue, bool enable);
458 enum i40e_aq_link_speed i40e_get_link_speed(struct i40e_hw *hw);
459 /* prototype for functions used for NVM access */
460 enum i40e_status_code i40e_init_nvm(struct i40e_hw *hw);
461 enum i40e_status_code i40e_acquire_nvm(struct i40e_hw *hw,
462 				      enum i40e_aq_resource_access_type access);
463 void i40e_release_nvm(struct i40e_hw *hw);
464 enum i40e_status_code i40e_read_nvm_word(struct i40e_hw *hw, u16 offset,
465 					 u16 *data);
466 enum i40e_status_code
467 i40e_read_nvm_module_data(struct i40e_hw *hw, u8 module_ptr, u16 module_offset,
468 			  u16 data_offset, u16 words_data_size, u16 *data_ptr);
469 enum i40e_status_code i40e_read_nvm_buffer(struct i40e_hw *hw, u16 offset,
470 					   u16 *words, u16 *data);
471 enum i40e_status_code i40e_write_nvm_aq(struct i40e_hw *hw, u8 module,
472 					u32 offset, u16 words, void *data,
473 					bool last_command);
474 enum i40e_status_code __i40e_read_nvm_word(struct i40e_hw *hw, u16 offset,
475 					   u16 *data);
476 enum i40e_status_code __i40e_read_nvm_buffer(struct i40e_hw *hw, u16 offset,
477 					     u16 *words, u16 *data);
478 enum i40e_status_code __i40e_write_nvm_word(struct i40e_hw *hw, u32 offset,
479 					  void *data);
480 enum i40e_status_code __i40e_write_nvm_buffer(struct i40e_hw *hw, u8 module,
481 					    u32 offset, u16 words, void *data);
482 enum i40e_status_code i40e_calc_nvm_checksum(struct i40e_hw *hw, u16 *checksum);
483 enum i40e_status_code i40e_update_nvm_checksum(struct i40e_hw *hw);
484 enum i40e_status_code i40e_validate_nvm_checksum(struct i40e_hw *hw,
485 						 u16 *checksum);
486 enum i40e_status_code i40e_nvmupd_command(struct i40e_hw *hw,
487 					  struct i40e_nvm_access *cmd,
488 					  u8 *bytes, int *);
489 void i40e_nvmupd_check_wait_event(struct i40e_hw *hw, u16 opcode,
490 				  struct i40e_aq_desc *desc);
491 void i40e_nvmupd_clear_wait_state(struct i40e_hw *hw);
492 void i40e_set_pci_config_data(struct i40e_hw *hw, u16 link_status);
493 enum i40e_status_code i40e_enable_eee(struct i40e_hw *hw, bool enable);
494 
495 enum i40e_status_code i40e_set_mac_type(struct i40e_hw *hw);
496 
497 extern struct i40e_rx_ptype_decoded i40e_ptype_lookup[];
498 
decode_rx_desc_ptype(u8 ptype)499 static INLINE struct i40e_rx_ptype_decoded decode_rx_desc_ptype(u8 ptype)
500 {
501 	return i40e_ptype_lookup[ptype];
502 }
503 
504 /**
505  * i40e_virtchnl_link_speed - Convert AdminQ link_speed to virtchnl definition
506  * @link_speed: the speed to convert
507  *
508  * Returns the link_speed in terms of the virtchnl interface, for use in
509  * converting link_speed as reported by the AdminQ into the format used for
510  * talking to virtchnl devices. If we can't represent the link speed properly,
511  * report LINK_SPEED_UNKNOWN.
512  **/
513 static INLINE enum virtchnl_link_speed
i40e_virtchnl_link_speed(enum i40e_aq_link_speed link_speed)514 i40e_virtchnl_link_speed(enum i40e_aq_link_speed link_speed)
515 {
516 	switch (link_speed) {
517 	case I40E_LINK_SPEED_100MB:
518 		return VIRTCHNL_LINK_SPEED_100MB;
519 	case I40E_LINK_SPEED_1GB:
520 		return VIRTCHNL_LINK_SPEED_1GB;
521 	case I40E_LINK_SPEED_2_5GB:
522 		return VIRTCHNL_LINK_SPEED_2_5GB;
523 	case I40E_LINK_SPEED_5GB:
524 		return VIRTCHNL_LINK_SPEED_5GB;
525 	case I40E_LINK_SPEED_10GB:
526 		return VIRTCHNL_LINK_SPEED_10GB;
527 	case I40E_LINK_SPEED_40GB:
528 		return VIRTCHNL_LINK_SPEED_40GB;
529 	case I40E_LINK_SPEED_20GB:
530 		return VIRTCHNL_LINK_SPEED_20GB;
531 	case I40E_LINK_SPEED_25GB:
532 		return VIRTCHNL_LINK_SPEED_25GB;
533 	case I40E_LINK_SPEED_UNKNOWN:
534 	default:
535 		return VIRTCHNL_LINK_SPEED_UNKNOWN;
536 	}
537 }
538 
539 /* prototype for functions used for SW spinlocks */
540 void i40e_init_spinlock(struct i40e_spinlock *sp);
541 void i40e_acquire_spinlock(struct i40e_spinlock *sp);
542 void i40e_release_spinlock(struct i40e_spinlock *sp);
543 void i40e_destroy_spinlock(struct i40e_spinlock *sp);
544 
545 /* i40e_common for VF drivers*/
546 void i40e_vf_parse_hw_config(struct i40e_hw *hw,
547 			     struct virtchnl_vf_resource *msg);
548 enum i40e_status_code i40e_vf_reset(struct i40e_hw *hw);
549 enum i40e_status_code i40e_aq_send_msg_to_pf(struct i40e_hw *hw,
550 				enum virtchnl_ops v_opcode,
551 				enum i40e_status_code v_retval,
552 				u8 *msg, u16 msglen,
553 				struct i40e_asq_cmd_details *cmd_details);
554 enum i40e_status_code i40e_set_filter_control(struct i40e_hw *hw,
555 				struct i40e_filter_control_settings *settings);
556 enum i40e_status_code i40e_aq_add_rem_control_packet_filter(struct i40e_hw *hw,
557 				u8 *mac_addr, u16 ethtype, u16 flags,
558 				u16 vsi_seid, u16 queue, bool is_add,
559 				struct i40e_control_filter_stats *stats,
560 				struct i40e_asq_cmd_details *cmd_details);
561 enum i40e_status_code i40e_aq_debug_dump(struct i40e_hw *hw, u8 cluster_id,
562 				u8 table_id, u32 start_index, u16 buff_size,
563 				void *buff, u16 *ret_buff_size,
564 				u8 *ret_next_table, u32 *ret_next_index,
565 				struct i40e_asq_cmd_details *cmd_details);
566 void i40e_add_filter_to_drop_tx_flow_control_frames(struct i40e_hw *hw,
567 						    u16 vsi_seid);
568 enum i40e_status_code i40e_aq_rx_ctl_read_register(struct i40e_hw *hw,
569 				u32 reg_addr, u32 *reg_val,
570 				struct i40e_asq_cmd_details *cmd_details);
571 u32 i40e_read_rx_ctl(struct i40e_hw *hw, u32 reg_addr);
572 enum i40e_status_code i40e_aq_rx_ctl_write_register(struct i40e_hw *hw,
573 				u32 reg_addr, u32 reg_val,
574 				struct i40e_asq_cmd_details *cmd_details);
575 void i40e_write_rx_ctl(struct i40e_hw *hw, u32 reg_addr, u32 reg_val);
576 enum i40e_status_code
577 i40e_aq_set_phy_register_ext(struct i40e_hw *hw,
578 			     u8 phy_select, u8 dev_addr, bool page_change,
579 			     bool set_mdio, u8 mdio_num,
580 			     u32 reg_addr, u32 reg_val,
581 			     struct i40e_asq_cmd_details *cmd_details);
582 enum i40e_status_code
583 i40e_aq_get_phy_register_ext(struct i40e_hw *hw,
584 			     u8 phy_select, u8 dev_addr, bool page_change,
585 			     bool set_mdio, u8 mdio_num,
586 			     u32 reg_addr, u32 *reg_val,
587 			     struct i40e_asq_cmd_details *cmd_details);
588 
589 /* Convenience wrappers for most common use case */
590 #define i40e_aq_set_phy_register(hw, ps, da, pc, ra, rv, cd) \
591 	i40e_aq_set_phy_register_ext(hw, ps, da, pc, FALSE, 0, ra, rv, cd)
592 #define i40e_aq_get_phy_register(hw, ps, da, pc, ra, rv, cd) \
593 	i40e_aq_get_phy_register_ext(hw, ps, da, pc, FALSE, 0, ra, rv, cd)
594 
595 enum i40e_status_code
596 i40e_aq_run_phy_activity(struct i40e_hw *hw, u16 activity_id, u32 opcode,
597 			 u32 *cmd_status, u32 *data0, u32 *data1,
598 			 struct i40e_asq_cmd_details *cmd_details);
599 
600 enum i40e_status_code i40e_aq_set_arp_proxy_config(struct i40e_hw *hw,
601 			struct i40e_aqc_arp_proxy_data *proxy_config,
602 			struct i40e_asq_cmd_details *cmd_details);
603 enum i40e_status_code i40e_aq_set_ns_proxy_table_entry(struct i40e_hw *hw,
604 			struct i40e_aqc_ns_proxy_data *ns_proxy_table_entry,
605 			struct i40e_asq_cmd_details *cmd_details);
606 enum i40e_status_code i40e_aq_set_clear_wol_filter(struct i40e_hw *hw,
607 			u8 filter_index,
608 			struct i40e_aqc_set_wol_filter_data *filter,
609 			bool set_filter, bool no_wol_tco,
610 			bool filter_valid, bool no_wol_tco_valid,
611 			struct i40e_asq_cmd_details *cmd_details);
612 enum i40e_status_code i40e_aq_get_wake_event_reason(struct i40e_hw *hw,
613 			u16 *wake_reason,
614 			struct i40e_asq_cmd_details *cmd_details);
615 enum i40e_status_code i40e_aq_clear_all_wol_filters(struct i40e_hw *hw,
616 			struct i40e_asq_cmd_details *cmd_details);
617 enum i40e_status_code i40e_read_phy_register_clause22(struct i40e_hw *hw,
618 					u16 reg, u8 phy_addr, u16 *value);
619 enum i40e_status_code i40e_write_phy_register_clause22(struct i40e_hw *hw,
620 					u16 reg, u8 phy_addr, u16 value);
621 enum i40e_status_code i40e_read_phy_register_clause45(struct i40e_hw *hw,
622 				u8 page, u16 reg, u8 phy_addr, u16 *value);
623 enum i40e_status_code i40e_write_phy_register_clause45(struct i40e_hw *hw,
624 				u8 page, u16 reg, u8 phy_addr, u16 value);
625 enum i40e_status_code i40e_read_phy_register(struct i40e_hw *hw,
626 				u8 page, u16 reg, u8 phy_addr, u16 *value);
627 enum i40e_status_code i40e_write_phy_register(struct i40e_hw *hw,
628 				u8 page, u16 reg, u8 phy_addr, u16 value);
629 u8 i40e_get_phy_address(struct i40e_hw *hw, u8 dev_num);
630 #endif /* _I40E_PROTOTYPE_H_ */
631