1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright(c) 2013 - 2021 Intel Corporation. */
3 
4 #ifndef _I40E_PROTOTYPE_H_
5 #define _I40E_PROTOTYPE_H_
6 
7 #include <linux/ethtool.h>
8 #include <linux/avf/virtchnl.h>
9 #include "i40e_debug.h"
10 #include "i40e_type.h"
11 
12 /* Prototypes for shared code functions that are not in
13  * the standard function pointer structures.  These are
14  * mostly because they are needed even before the init
15  * has happened and will assist in the early SW and FW
16  * setup.
17  */
18 
19 /* adminq functions */
20 int i40e_init_adminq(struct i40e_hw *hw);
21 void i40e_shutdown_adminq(struct i40e_hw *hw);
22 int i40e_clean_arq_element(struct i40e_hw *hw,
23 			   struct i40e_arq_event_info *e,
24 			   u16 *events_pending);
25 int
26 i40e_asq_send_command(struct i40e_hw *hw, struct i40e_aq_desc *desc,
27 		      void *buff, /* can be NULL */ u16  buff_size,
28 		      struct i40e_asq_cmd_details *cmd_details);
29 int
30 i40e_asq_send_command_atomic(struct i40e_hw *hw, struct i40e_aq_desc *desc,
31 			     void *buff, /* can be NULL */ u16  buff_size,
32 			     struct i40e_asq_cmd_details *cmd_details,
33 			     bool is_atomic_context);
34 int
35 i40e_asq_send_command_atomic_v2(struct i40e_hw *hw,
36 				struct i40e_aq_desc *desc,
37 				void *buff, /* can be NULL */
38 				u16  buff_size,
39 				struct i40e_asq_cmd_details *cmd_details,
40 				bool is_atomic_context,
41 				enum i40e_admin_queue_err *aq_status);
42 
43 /* debug function for adminq */
44 void i40e_debug_aq(struct i40e_hw *hw, enum i40e_debug_mask mask,
45 		   void *desc, void *buffer, u16 buf_len);
46 
47 bool i40e_check_asq_alive(struct i40e_hw *hw);
48 int i40e_aq_queue_shutdown(struct i40e_hw *hw, bool unloading);
49 const char *i40e_aq_str(struct i40e_hw *hw, enum i40e_admin_queue_err aq_err);
50 
51 int i40e_aq_get_rss_lut(struct i40e_hw *hw, u16 seid,
52 			bool pf_lut, u8 *lut, u16 lut_size);
53 int i40e_aq_set_rss_lut(struct i40e_hw *hw, u16 seid,
54 			bool pf_lut, u8 *lut, u16 lut_size);
55 int i40e_aq_get_rss_key(struct i40e_hw *hw,
56 			u16 seid,
57 			struct i40e_aqc_get_set_rss_key_data *key);
58 int i40e_aq_set_rss_key(struct i40e_hw *hw,
59 			u16 seid,
60 			struct i40e_aqc_get_set_rss_key_data *key);
61 
62 u32 i40e_led_get(struct i40e_hw *hw);
63 void i40e_led_set(struct i40e_hw *hw, u32 mode, bool blink);
64 int i40e_led_set_phy(struct i40e_hw *hw, bool on,
65 		     u16 led_addr, u32 mode);
66 int i40e_led_get_phy(struct i40e_hw *hw, u16 *led_addr,
67 		     u16 *val);
68 
69 /* admin send queue commands */
70 
71 int i40e_aq_get_firmware_version(struct i40e_hw *hw,
72 				 u16 *fw_major_version, u16 *fw_minor_version,
73 				 u32 *fw_build,
74 				 u16 *api_major_version, u16 *api_minor_version,
75 				 struct i40e_asq_cmd_details *cmd_details);
76 int i40e_aq_debug_write_register(struct i40e_hw *hw,
77 				 u32 reg_addr, u64 reg_val,
78 				 struct i40e_asq_cmd_details *cmd_details);
79 int i40e_aq_debug_read_register(struct i40e_hw *hw,
80 				u32  reg_addr, u64 *reg_val,
81 				struct i40e_asq_cmd_details *cmd_details);
82 int i40e_aq_set_phy_debug(struct i40e_hw *hw, u8 cmd_flags,
83 			  struct i40e_asq_cmd_details *cmd_details);
84 int i40e_aq_set_default_vsi(struct i40e_hw *hw, u16 vsi_id,
85 			    struct i40e_asq_cmd_details *cmd_details);
86 int i40e_aq_clear_default_vsi(struct i40e_hw *hw, u16 vsi_id,
87 			      struct i40e_asq_cmd_details *cmd_details);
88 int i40e_aq_get_phy_capabilities(struct i40e_hw *hw,
89 				 bool qualified_modules, bool report_init,
90 				 struct i40e_aq_get_phy_abilities_resp *abilities,
91 				 struct i40e_asq_cmd_details *cmd_details);
92 int i40e_aq_set_phy_config(struct i40e_hw *hw,
93 			   struct i40e_aq_set_phy_config *config,
94 			   struct i40e_asq_cmd_details *cmd_details);
95 int i40e_set_fc(struct i40e_hw *hw, u8 *aq_failures,
96 		bool atomic_reset);
97 int i40e_aq_set_mac_loopback(struct i40e_hw *hw,
98 			     bool ena_lpbk,
99 			     struct i40e_asq_cmd_details *cmd_details);
100 int i40e_aq_set_phy_int_mask(struct i40e_hw *hw, u16 mask,
101 			     struct i40e_asq_cmd_details *cmd_details);
102 int i40e_aq_clear_pxe_mode(struct i40e_hw *hw,
103 			   struct i40e_asq_cmd_details *cmd_details);
104 int i40e_aq_set_link_restart_an(struct i40e_hw *hw,
105 				bool enable_link,
106 				struct i40e_asq_cmd_details *cmd_details);
107 int i40e_aq_get_link_info(struct i40e_hw *hw,
108 			  bool enable_lse, struct i40e_link_status *link,
109 			  struct i40e_asq_cmd_details *cmd_details);
110 int i40e_aq_send_driver_version(struct i40e_hw *hw,
111 				struct i40e_driver_version *dv,
112 				struct i40e_asq_cmd_details *cmd_details);
113 int i40e_aq_add_vsi(struct i40e_hw *hw,
114 		    struct i40e_vsi_context *vsi_ctx,
115 		    struct i40e_asq_cmd_details *cmd_details);
116 int i40e_aq_set_vsi_broadcast(struct i40e_hw *hw,
117 			      u16 vsi_id, bool set_filter,
118 			      struct i40e_asq_cmd_details *cmd_details);
119 int i40e_aq_set_vsi_unicast_promiscuous(struct i40e_hw *hw, u16 vsi_id, bool set,
120 					struct i40e_asq_cmd_details *cmd_details,
121 					bool rx_only_promisc);
122 int i40e_aq_set_vsi_multicast_promiscuous(struct i40e_hw *hw, u16 vsi_id, bool set,
123 					  struct i40e_asq_cmd_details *cmd_details);
124 int i40e_aq_set_vsi_mc_promisc_on_vlan(struct i40e_hw *hw,
125 				       u16 seid, bool enable,
126 				       u16 vid,
127 				       struct i40e_asq_cmd_details *cmd_details);
128 int i40e_aq_set_vsi_uc_promisc_on_vlan(struct i40e_hw *hw,
129 				       u16 seid, bool enable,
130 				       u16 vid,
131 				       struct i40e_asq_cmd_details *cmd_details);
132 int i40e_aq_set_vsi_bc_promisc_on_vlan(struct i40e_hw *hw,
133 				       u16 seid, bool enable, u16 vid,
134 				       struct i40e_asq_cmd_details *cmd_details);
135 int i40e_aq_get_vsi_params(struct i40e_hw *hw,
136 			   struct i40e_vsi_context *vsi_ctx,
137 			   struct i40e_asq_cmd_details *cmd_details);
138 int i40e_aq_update_vsi_params(struct i40e_hw *hw,
139 			      struct i40e_vsi_context *vsi_ctx,
140 			      struct i40e_asq_cmd_details *cmd_details);
141 int i40e_aq_add_veb(struct i40e_hw *hw, u16 uplink_seid,
142 		    u16 downlink_seid, u8 enabled_tc,
143 		    bool default_port, u16 *pveb_seid,
144 		    bool enable_stats,
145 		    struct i40e_asq_cmd_details *cmd_details);
146 int i40e_aq_get_veb_parameters(struct i40e_hw *hw,
147 			       u16 veb_seid, u16 *switch_id, bool *floating,
148 			       u16 *statistic_index, u16 *vebs_used,
149 			       u16 *vebs_free,
150 			       struct i40e_asq_cmd_details *cmd_details);
151 int i40e_aq_add_macvlan(struct i40e_hw *hw, u16 vsi_id,
152 			struct i40e_aqc_add_macvlan_element_data *mv_list,
153 			u16 count, struct i40e_asq_cmd_details *cmd_details);
154 int
155 i40e_aq_add_macvlan_v2(struct i40e_hw *hw, u16 seid,
156 		       struct i40e_aqc_add_macvlan_element_data *mv_list,
157 		       u16 count, struct i40e_asq_cmd_details *cmd_details,
158 		       enum i40e_admin_queue_err *aq_status);
159 int i40e_aq_remove_macvlan(struct i40e_hw *hw, u16 vsi_id,
160 			   struct i40e_aqc_remove_macvlan_element_data *mv_list,
161 			   u16 count, struct i40e_asq_cmd_details *cmd_details);
162 int
163 i40e_aq_remove_macvlan_v2(struct i40e_hw *hw, u16 seid,
164 			  struct i40e_aqc_remove_macvlan_element_data *mv_list,
165 			  u16 count, struct i40e_asq_cmd_details *cmd_details,
166 			  enum i40e_admin_queue_err *aq_status);
167 
168 int i40e_aq_send_msg_to_vf(struct i40e_hw *hw, u16 vfid,
169 			   u32 v_opcode, u32 v_retval, u8 *msg, u16 msglen,
170 			   struct i40e_asq_cmd_details *cmd_details);
171 int i40e_aq_get_switch_config(struct i40e_hw *hw,
172 			      struct i40e_aqc_get_switch_config_resp *buf,
173 			      u16 buf_size, u16 *start_seid,
174 			      struct i40e_asq_cmd_details *cmd_details);
175 int i40e_aq_set_switch_config(struct i40e_hw *hw,
176 			      u16 flags,
177 			      u16 valid_flags, u8 mode,
178 			      struct i40e_asq_cmd_details *cmd_details);
179 int i40e_aq_request_resource(struct i40e_hw *hw,
180 			     enum i40e_aq_resources_ids resource,
181 			     enum i40e_aq_resource_access_type access,
182 			     u8 sdp_number, u64 *timeout,
183 			     struct i40e_asq_cmd_details *cmd_details);
184 int i40e_aq_release_resource(struct i40e_hw *hw,
185 			     enum i40e_aq_resources_ids resource,
186 			     u8 sdp_number,
187 			     struct i40e_asq_cmd_details *cmd_details);
188 int i40e_aq_read_nvm(struct i40e_hw *hw, u8 module_pointer,
189 		     u32 offset, u16 length, void *data,
190 		     bool last_command,
191 		     struct i40e_asq_cmd_details *cmd_details);
192 int i40e_aq_erase_nvm(struct i40e_hw *hw, u8 module_pointer,
193 		      u32 offset, u16 length, bool last_command,
194 		      struct i40e_asq_cmd_details *cmd_details);
195 int i40e_aq_discover_capabilities(struct i40e_hw *hw,
196 				  void *buff, u16 buff_size, u16 *data_size,
197 				  enum i40e_admin_queue_opc list_type_opc,
198 				  struct i40e_asq_cmd_details *cmd_details);
199 int i40e_aq_update_nvm(struct i40e_hw *hw, u8 module_pointer,
200 		       u32 offset, u16 length, void *data,
201 		       bool last_command, u8 preservation_flags,
202 		       struct i40e_asq_cmd_details *cmd_details);
203 int i40e_aq_get_lldp_mib(struct i40e_hw *hw, u8 bridge_type,
204 			 u8 mib_type, void *buff, u16 buff_size,
205 			 u16 *local_len, u16 *remote_len,
206 			 struct i40e_asq_cmd_details *cmd_details);
207 int
208 i40e_aq_set_lldp_mib(struct i40e_hw *hw,
209 		     u8 mib_type, void *buff, u16 buff_size,
210 		     struct i40e_asq_cmd_details *cmd_details);
211 int i40e_aq_cfg_lldp_mib_change_event(struct i40e_hw *hw,
212 				      bool enable_update,
213 				      struct i40e_asq_cmd_details *cmd_details);
214 int i40e_aq_stop_lldp(struct i40e_hw *hw, bool shutdown_agent,
215 		      bool persist,
216 		      struct i40e_asq_cmd_details *cmd_details);
217 int i40e_aq_set_dcb_parameters(struct i40e_hw *hw,
218 			       bool dcb_enable,
219 			       struct i40e_asq_cmd_details
220 			       *cmd_details);
221 int i40e_aq_start_lldp(struct i40e_hw *hw, bool persist,
222 		       struct i40e_asq_cmd_details *cmd_details);
223 int i40e_aq_get_cee_dcb_config(struct i40e_hw *hw,
224 			       void *buff, u16 buff_size,
225 			       struct i40e_asq_cmd_details *cmd_details);
226 int i40e_aq_add_udp_tunnel(struct i40e_hw *hw,
227 			   u16 udp_port, u8 protocol_index,
228 			   u8 *filter_index,
229 			   struct i40e_asq_cmd_details *cmd_details);
230 int i40e_aq_del_udp_tunnel(struct i40e_hw *hw, u8 index,
231 			   struct i40e_asq_cmd_details *cmd_details);
232 int i40e_aq_delete_element(struct i40e_hw *hw, u16 seid,
233 			   struct i40e_asq_cmd_details *cmd_details);
234 int i40e_aq_mac_address_write(struct i40e_hw *hw,
235 			      u16 flags, u8 *mac_addr,
236 			      struct i40e_asq_cmd_details *cmd_details);
237 int i40e_aq_config_vsi_bw_limit(struct i40e_hw *hw,
238 				u16 seid, u16 credit, u8 max_credit,
239 				struct i40e_asq_cmd_details *cmd_details);
240 int i40e_aq_dcb_updated(struct i40e_hw *hw,
241 			struct i40e_asq_cmd_details *cmd_details);
242 int i40e_aq_config_vsi_tc_bw(struct i40e_hw *hw, u16 seid,
243 			     struct i40e_aqc_configure_vsi_tc_bw_data *bw_data,
244 			     struct i40e_asq_cmd_details *cmd_details);
245 int
246 i40e_aq_config_switch_comp_ets(struct i40e_hw *hw,
247 			       u16 seid,
248 			       struct i40e_aqc_configure_switching_comp_ets_data *ets_data,
249 			       enum i40e_admin_queue_opc opcode,
250 			       struct i40e_asq_cmd_details *cmd_details);
251 int i40e_aq_config_switch_comp_bw_config(struct i40e_hw *hw,
252 	u16 seid,
253 	struct i40e_aqc_configure_switching_comp_bw_config_data *bw_data,
254 	struct i40e_asq_cmd_details *cmd_details);
255 int i40e_aq_query_vsi_bw_config(struct i40e_hw *hw,
256 				u16 seid,
257 				struct i40e_aqc_query_vsi_bw_config_resp *bw_data,
258 				struct i40e_asq_cmd_details *cmd_details);
259 int
260 i40e_aq_query_vsi_ets_sla_config(struct i40e_hw *hw,
261 				 u16 seid,
262 				 struct i40e_aqc_query_vsi_ets_sla_config_resp *bw_data,
263 				 struct i40e_asq_cmd_details *cmd_details);
264 int
265 i40e_aq_query_switch_comp_ets_config(struct i40e_hw *hw,
266 				     u16 seid,
267 				     struct i40e_aqc_query_switching_comp_ets_config_resp *bw_data,
268 				     struct i40e_asq_cmd_details *cmd_details);
269 int
270 i40e_aq_query_port_ets_config(struct i40e_hw *hw,
271 			      u16 seid,
272 			      struct i40e_aqc_query_port_ets_config_resp *bw_data,
273 			      struct i40e_asq_cmd_details *cmd_details);
274 int
275 i40e_aq_query_switch_comp_bw_config(struct i40e_hw *hw,
276 				    u16 seid,
277 				    struct i40e_aqc_query_switching_comp_bw_config_resp *bw_data,
278 				    struct i40e_asq_cmd_details *cmd_details);
279 int i40e_aq_resume_port_tx(struct i40e_hw *hw,
280 			   struct i40e_asq_cmd_details *cmd_details);
281 int
282 i40e_aq_add_cloud_filters_bb(struct i40e_hw *hw, u16 seid,
283 			     struct i40e_aqc_cloud_filters_element_bb *filters,
284 			     u8 filter_count);
285 int
286 i40e_aq_add_cloud_filters(struct i40e_hw *hw, u16 vsi,
287 			  struct i40e_aqc_cloud_filters_element_data *filters,
288 			  u8 filter_count);
289 int
290 i40e_aq_rem_cloud_filters(struct i40e_hw *hw, u16 vsi,
291 			  struct i40e_aqc_cloud_filters_element_data *filters,
292 			  u8 filter_count);
293 int
294 i40e_aq_rem_cloud_filters_bb(struct i40e_hw *hw, u16 seid,
295 			     struct i40e_aqc_cloud_filters_element_bb *filters,
296 			     u8 filter_count);
297 int i40e_read_lldp_cfg(struct i40e_hw *hw,
298 		       struct i40e_lldp_variables *lldp_cfg);
299 int
300 i40e_aq_suspend_port_tx(struct i40e_hw *hw, u16 seid,
301 			struct i40e_asq_cmd_details *cmd_details);
302 /* i40e_common */
303 int i40e_init_shared_code(struct i40e_hw *hw);
304 int i40e_pf_reset(struct i40e_hw *hw);
305 void i40e_clear_hw(struct i40e_hw *hw);
306 void i40e_clear_pxe_mode(struct i40e_hw *hw);
307 int i40e_get_link_status(struct i40e_hw *hw, bool *link_up);
308 int i40e_update_link_info(struct i40e_hw *hw);
309 int i40e_get_mac_addr(struct i40e_hw *hw, u8 *mac_addr);
310 int i40e_read_bw_from_alt_ram(struct i40e_hw *hw,
311 			      u32 *max_bw, u32 *min_bw, bool *min_valid,
312 			      bool *max_valid);
313 int
314 i40e_aq_configure_partition_bw(struct i40e_hw *hw,
315 			       struct i40e_aqc_configure_partition_bw_data *bw_data,
316 			       struct i40e_asq_cmd_details *cmd_details);
317 int i40e_get_port_mac_addr(struct i40e_hw *hw, u8 *mac_addr);
318 void i40e_get_pba_string(struct i40e_hw *hw);
319 void i40e_pre_tx_queue_cfg(struct i40e_hw *hw, u32 queue, bool enable);
320 /* prototype for functions used for NVM access */
321 int i40e_init_nvm(struct i40e_hw *hw);
322 int i40e_acquire_nvm(struct i40e_hw *hw,
323 		     enum i40e_aq_resource_access_type access);
324 void i40e_release_nvm(struct i40e_hw *hw);
325 int i40e_read_nvm_word(struct i40e_hw *hw, u16 offset,
326 		       u16 *data);
327 int i40e_read_nvm_module_data(struct i40e_hw *hw,
328 			      u8 module_ptr,
329 			      u16 module_offset,
330 			      u16 data_offset,
331 			      u16 words_data_size,
332 			      u16 *data_ptr);
333 int i40e_read_nvm_buffer(struct i40e_hw *hw, u16 offset,
334 			 u16 *words, u16 *data);
335 int i40e_update_nvm_checksum(struct i40e_hw *hw);
336 int i40e_validate_nvm_checksum(struct i40e_hw *hw,
337 			       u16 *checksum);
338 int i40e_nvmupd_command(struct i40e_hw *hw,
339 			struct i40e_nvm_access *cmd,
340 			u8 *bytes, int *errno);
341 void i40e_nvmupd_check_wait_event(struct i40e_hw *hw, u16 opcode,
342 				  struct i40e_aq_desc *desc);
343 void i40e_nvmupd_clear_wait_state(struct i40e_hw *hw);
344 void i40e_set_pci_config_data(struct i40e_hw *hw, u16 link_status);
345 
346 int i40e_set_mac_type(struct i40e_hw *hw);
347 
348 /**
349  * i40e_virtchnl_link_speed - Convert AdminQ link_speed to virtchnl definition
350  * @link_speed: the speed to convert
351  *
352  * Returns the link_speed in terms of the virtchnl interface, for use in
353  * converting link_speed as reported by the AdminQ into the format used for
354  * talking to virtchnl devices. If we can't represent the link speed properly,
355  * report LINK_SPEED_UNKNOWN.
356  **/
357 static inline enum virtchnl_link_speed
i40e_virtchnl_link_speed(enum i40e_aq_link_speed link_speed)358 i40e_virtchnl_link_speed(enum i40e_aq_link_speed link_speed)
359 {
360 	switch (link_speed) {
361 	case I40E_LINK_SPEED_100MB:
362 		return VIRTCHNL_LINK_SPEED_100MB;
363 	case I40E_LINK_SPEED_1GB:
364 		return VIRTCHNL_LINK_SPEED_1GB;
365 	case I40E_LINK_SPEED_2_5GB:
366 		return VIRTCHNL_LINK_SPEED_2_5GB;
367 	case I40E_LINK_SPEED_5GB:
368 		return VIRTCHNL_LINK_SPEED_5GB;
369 	case I40E_LINK_SPEED_10GB:
370 		return VIRTCHNL_LINK_SPEED_10GB;
371 	case I40E_LINK_SPEED_40GB:
372 		return VIRTCHNL_LINK_SPEED_40GB;
373 	case I40E_LINK_SPEED_20GB:
374 		return VIRTCHNL_LINK_SPEED_20GB;
375 	case I40E_LINK_SPEED_25GB:
376 		return VIRTCHNL_LINK_SPEED_25GB;
377 	case I40E_LINK_SPEED_UNKNOWN:
378 	default:
379 		return VIRTCHNL_LINK_SPEED_UNKNOWN;
380 	}
381 }
382 
383 /* prototype for functions used for SW locks */
384 
385 /* i40e_common for VF drivers*/
386 int i40e_set_filter_control(struct i40e_hw *hw,
387 			    struct i40e_filter_control_settings *settings);
388 int i40e_aq_add_rem_control_packet_filter(struct i40e_hw *hw,
389 					  u8 *mac_addr, u16 ethtype, u16 flags,
390 					  u16 vsi_seid, u16 queue, bool is_add,
391 					  struct i40e_control_filter_stats *stats,
392 					  struct i40e_asq_cmd_details *cmd_details);
393 int i40e_aq_debug_dump(struct i40e_hw *hw, u8 cluster_id,
394 		       u8 table_id, u32 start_index, u16 buff_size,
395 		       void *buff, u16 *ret_buff_size,
396 		       u8 *ret_next_table, u32 *ret_next_index,
397 		       struct i40e_asq_cmd_details *cmd_details);
398 void i40e_add_filter_to_drop_tx_flow_control_frames(struct i40e_hw *hw,
399 						    u16 vsi_seid);
400 int i40e_aq_rx_ctl_read_register(struct i40e_hw *hw,
401 				 u32 reg_addr, u32 *reg_val,
402 				 struct i40e_asq_cmd_details *cmd_details);
403 u32 i40e_read_rx_ctl(struct i40e_hw *hw, u32 reg_addr);
404 int i40e_aq_rx_ctl_write_register(struct i40e_hw *hw,
405 				  u32 reg_addr, u32 reg_val,
406 				  struct i40e_asq_cmd_details *cmd_details);
407 void i40e_write_rx_ctl(struct i40e_hw *hw, u32 reg_addr, u32 reg_val);
408 int
409 i40e_aq_set_phy_register_ext(struct i40e_hw *hw,
410 			     u8 phy_select, u8 dev_addr, bool page_change,
411 			     bool set_mdio, u8 mdio_num,
412 			     u32 reg_addr, u32 reg_val,
413 			     struct i40e_asq_cmd_details *cmd_details);
414 int
415 i40e_aq_get_phy_register_ext(struct i40e_hw *hw,
416 			     u8 phy_select, u8 dev_addr, bool page_change,
417 			     bool set_mdio, u8 mdio_num,
418 			     u32 reg_addr, u32 *reg_val,
419 			     struct i40e_asq_cmd_details *cmd_details);
420 
421 /* Convenience wrappers for most common use case */
422 #define i40e_aq_set_phy_register(hw, ps, da, pc, ra, rv, cd)		\
423 	i40e_aq_set_phy_register_ext(hw, ps, da, pc, false, 0, ra, rv, cd)
424 #define i40e_aq_get_phy_register(hw, ps, da, pc, ra, rv, cd)		\
425 	i40e_aq_get_phy_register_ext(hw, ps, da, pc, false, 0, ra, rv, cd)
426 
427 int i40e_read_phy_register_clause22(struct i40e_hw *hw,
428 				    u16 reg, u8 phy_addr, u16 *value);
429 int i40e_write_phy_register_clause22(struct i40e_hw *hw,
430 				     u16 reg, u8 phy_addr, u16 value);
431 int i40e_read_phy_register_clause45(struct i40e_hw *hw,
432 				    u8 page, u16 reg, u8 phy_addr, u16 *value);
433 int i40e_write_phy_register_clause45(struct i40e_hw *hw,
434 				     u8 page, u16 reg, u8 phy_addr, u16 value);
435 u8 i40e_get_phy_address(struct i40e_hw *hw, u8 dev_num);
436 int i40e_aq_write_ddp(struct i40e_hw *hw, void *buff,
437 		      u16 buff_size, u32 track_id,
438 		      u32 *error_offset, u32 *error_info,
439 		      struct i40e_asq_cmd_details *
440 		      cmd_details);
441 int i40e_aq_get_ddp_list(struct i40e_hw *hw, void *buff,
442 			 u16 buff_size, u8 flags,
443 			 struct i40e_asq_cmd_details *
444 			 cmd_details);
445 struct i40e_generic_seg_header *
446 i40e_find_segment_in_package(u32 segment_type,
447 			     struct i40e_package_header *pkg_header);
448 int
449 i40e_write_profile(struct i40e_hw *hw, struct i40e_profile_segment *i40e_seg,
450 		   u32 track_id);
451 int
452 i40e_rollback_profile(struct i40e_hw *hw, struct i40e_profile_segment *i40e_seg,
453 		      u32 track_id);
454 /* i40e_ddp */
455 int i40e_ddp_flash(struct net_device *netdev, struct ethtool_flash *flash);
456 
457 /* Firmware and AdminQ version check helpers */
458 
459 /**
460  * i40e_is_aq_api_ver_ge
461  * @hw: pointer to i40e_hw structure
462  * @maj: API major value to compare
463  * @min: API minor value to compare
464  *
465  * Assert whether current HW API version is greater/equal than provided.
466  **/
i40e_is_aq_api_ver_ge(struct i40e_hw * hw,u16 maj,u16 min)467 static inline bool i40e_is_aq_api_ver_ge(struct i40e_hw *hw, u16 maj, u16 min)
468 {
469 	return (hw->aq.api_maj_ver > maj ||
470 		(hw->aq.api_maj_ver == maj && hw->aq.api_min_ver >= min));
471 }
472 
473 /**
474  * i40e_is_aq_api_ver_lt
475  * @hw: pointer to i40e_hw structure
476  * @maj: API major value to compare
477  * @min: API minor value to compare
478  *
479  * Assert whether current HW API version is less than provided.
480  **/
i40e_is_aq_api_ver_lt(struct i40e_hw * hw,u16 maj,u16 min)481 static inline bool i40e_is_aq_api_ver_lt(struct i40e_hw *hw, u16 maj, u16 min)
482 {
483 	return !i40e_is_aq_api_ver_ge(hw, maj, min);
484 }
485 
486 /**
487  * i40e_is_fw_ver_ge
488  * @hw: pointer to i40e_hw structure
489  * @maj: API major value to compare
490  * @min: API minor value to compare
491  *
492  * Assert whether current firmware version is greater/equal than provided.
493  **/
i40e_is_fw_ver_ge(struct i40e_hw * hw,u16 maj,u16 min)494 static inline bool i40e_is_fw_ver_ge(struct i40e_hw *hw, u16 maj, u16 min)
495 {
496 	return (hw->aq.fw_maj_ver > maj ||
497 		(hw->aq.fw_maj_ver == maj && hw->aq.fw_min_ver >= min));
498 }
499 
500 /**
501  * i40e_is_fw_ver_lt
502  * @hw: pointer to i40e_hw structure
503  * @maj: API major value to compare
504  * @min: API minor value to compare
505  *
506  * Assert whether current firmware version is less than provided.
507  **/
i40e_is_fw_ver_lt(struct i40e_hw * hw,u16 maj,u16 min)508 static inline bool i40e_is_fw_ver_lt(struct i40e_hw *hw, u16 maj, u16 min)
509 {
510 	return !i40e_is_fw_ver_ge(hw, maj, min);
511 }
512 
513 /**
514  * i40e_is_fw_ver_eq
515  * @hw: pointer to i40e_hw structure
516  * @maj: API major value to compare
517  * @min: API minor value to compare
518  *
519  * Assert whether current firmware version is equal to provided.
520  **/
i40e_is_fw_ver_eq(struct i40e_hw * hw,u16 maj,u16 min)521 static inline bool i40e_is_fw_ver_eq(struct i40e_hw *hw, u16 maj, u16 min)
522 {
523 	return (hw->aq.fw_maj_ver == maj && hw->aq.fw_min_ver == min);
524 }
525 
526 #endif /* _I40E_PROTOTYPE_H_ */
527