18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/* Copyright (c) 2018, Intel Corporation. */
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_ci#ifndef _ICE_COMMON_H_
58c2ecf20Sopenharmony_ci#define _ICE_COMMON_H_
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#include "ice.h"
88c2ecf20Sopenharmony_ci#include "ice_type.h"
98c2ecf20Sopenharmony_ci#include "ice_nvm.h"
108c2ecf20Sopenharmony_ci#include "ice_flex_pipe.h"
118c2ecf20Sopenharmony_ci#include "ice_switch.h"
128c2ecf20Sopenharmony_ci#include <linux/avf/virtchnl.h>
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_cienum ice_status ice_init_hw(struct ice_hw *hw);
158c2ecf20Sopenharmony_civoid ice_deinit_hw(struct ice_hw *hw);
168c2ecf20Sopenharmony_cienum ice_status ice_check_reset(struct ice_hw *hw);
178c2ecf20Sopenharmony_cienum ice_status ice_reset(struct ice_hw *hw, enum ice_reset_req req);
188c2ecf20Sopenharmony_cienum ice_status ice_create_all_ctrlq(struct ice_hw *hw);
198c2ecf20Sopenharmony_cienum ice_status ice_init_all_ctrlq(struct ice_hw *hw);
208c2ecf20Sopenharmony_civoid ice_shutdown_all_ctrlq(struct ice_hw *hw);
218c2ecf20Sopenharmony_civoid ice_destroy_all_ctrlq(struct ice_hw *hw);
228c2ecf20Sopenharmony_cienum ice_status
238c2ecf20Sopenharmony_ciice_clean_rq_elem(struct ice_hw *hw, struct ice_ctl_q_info *cq,
248c2ecf20Sopenharmony_ci		  struct ice_rq_event_info *e, u16 *pending);
258c2ecf20Sopenharmony_cienum ice_status
268c2ecf20Sopenharmony_ciice_get_link_status(struct ice_port_info *pi, bool *link_up);
278c2ecf20Sopenharmony_cienum ice_status ice_update_link_info(struct ice_port_info *pi);
288c2ecf20Sopenharmony_cienum ice_status
298c2ecf20Sopenharmony_ciice_acquire_res(struct ice_hw *hw, enum ice_aq_res_ids res,
308c2ecf20Sopenharmony_ci		enum ice_aq_res_access_type access, u32 timeout);
318c2ecf20Sopenharmony_civoid ice_release_res(struct ice_hw *hw, enum ice_aq_res_ids res);
328c2ecf20Sopenharmony_cienum ice_status
338c2ecf20Sopenharmony_ciice_alloc_hw_res(struct ice_hw *hw, u16 type, u16 num, bool btm, u16 *res);
348c2ecf20Sopenharmony_cienum ice_status
358c2ecf20Sopenharmony_ciice_free_hw_res(struct ice_hw *hw, u16 type, u16 num, u16 *res);
368c2ecf20Sopenharmony_cienum ice_status
378c2ecf20Sopenharmony_ciice_aq_alloc_free_res(struct ice_hw *hw, u16 num_entries,
388c2ecf20Sopenharmony_ci		      struct ice_aqc_alloc_free_res_elem *buf, u16 buf_size,
398c2ecf20Sopenharmony_ci		      enum ice_adminq_opc opc, struct ice_sq_cd *cd);
408c2ecf20Sopenharmony_cienum ice_status
418c2ecf20Sopenharmony_ciice_sq_send_cmd(struct ice_hw *hw, struct ice_ctl_q_info *cq,
428c2ecf20Sopenharmony_ci		struct ice_aq_desc *desc, void *buf, u16 buf_size,
438c2ecf20Sopenharmony_ci		struct ice_sq_cd *cd);
448c2ecf20Sopenharmony_civoid ice_clear_pxe_mode(struct ice_hw *hw);
458c2ecf20Sopenharmony_cienum ice_status ice_get_caps(struct ice_hw *hw);
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_civoid ice_set_safe_mode_caps(struct ice_hw *hw);
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_cienum ice_status
508c2ecf20Sopenharmony_ciice_write_rxq_ctx(struct ice_hw *hw, struct ice_rlan_ctx *rlan_ctx,
518c2ecf20Sopenharmony_ci		  u32 rxq_index);
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_cienum ice_status
548c2ecf20Sopenharmony_ciice_aq_get_rss_lut(struct ice_hw *hw, u16 vsi_handle, u8 lut_type, u8 *lut,
558c2ecf20Sopenharmony_ci		   u16 lut_size);
568c2ecf20Sopenharmony_cienum ice_status
578c2ecf20Sopenharmony_ciice_aq_set_rss_lut(struct ice_hw *hw, u16 vsi_handle, u8 lut_type, u8 *lut,
588c2ecf20Sopenharmony_ci		   u16 lut_size);
598c2ecf20Sopenharmony_cienum ice_status
608c2ecf20Sopenharmony_ciice_aq_get_rss_key(struct ice_hw *hw, u16 vsi_handle,
618c2ecf20Sopenharmony_ci		   struct ice_aqc_get_set_rss_keys *keys);
628c2ecf20Sopenharmony_cienum ice_status
638c2ecf20Sopenharmony_ciice_aq_set_rss_key(struct ice_hw *hw, u16 vsi_handle,
648c2ecf20Sopenharmony_ci		   struct ice_aqc_get_set_rss_keys *keys);
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_cibool ice_check_sq_alive(struct ice_hw *hw, struct ice_ctl_q_info *cq);
678c2ecf20Sopenharmony_cienum ice_status ice_aq_q_shutdown(struct ice_hw *hw, bool unloading);
688c2ecf20Sopenharmony_civoid ice_fill_dflt_direct_cmd_desc(struct ice_aq_desc *desc, u16 opcode);
698c2ecf20Sopenharmony_ciextern const struct ice_ctx_ele ice_tlan_ctx_info[];
708c2ecf20Sopenharmony_cienum ice_status
718c2ecf20Sopenharmony_ciice_set_ctx(struct ice_hw *hw, u8 *src_ctx, u8 *dest_ctx,
728c2ecf20Sopenharmony_ci	    const struct ice_ctx_ele *ce_info);
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_ciextern struct mutex ice_global_cfg_lock_sw;
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_cienum ice_status
778c2ecf20Sopenharmony_ciice_aq_send_cmd(struct ice_hw *hw, struct ice_aq_desc *desc,
788c2ecf20Sopenharmony_ci		void *buf, u16 buf_size, struct ice_sq_cd *cd);
798c2ecf20Sopenharmony_cienum ice_status ice_aq_get_fw_ver(struct ice_hw *hw, struct ice_sq_cd *cd);
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_cienum ice_status
828c2ecf20Sopenharmony_ciice_aq_send_driver_ver(struct ice_hw *hw, struct ice_driver_ver *dv,
838c2ecf20Sopenharmony_ci		       struct ice_sq_cd *cd);
848c2ecf20Sopenharmony_cienum ice_status
858c2ecf20Sopenharmony_ciice_aq_get_phy_caps(struct ice_port_info *pi, bool qual_mods, u8 report_mode,
868c2ecf20Sopenharmony_ci		    struct ice_aqc_get_phy_caps_data *caps,
878c2ecf20Sopenharmony_ci		    struct ice_sq_cd *cd);
888c2ecf20Sopenharmony_cienum ice_status
898c2ecf20Sopenharmony_ciice_aq_list_caps(struct ice_hw *hw, void *buf, u16 buf_size, u32 *cap_count,
908c2ecf20Sopenharmony_ci		 enum ice_adminq_opc opc, struct ice_sq_cd *cd);
918c2ecf20Sopenharmony_cienum ice_status
928c2ecf20Sopenharmony_ciice_discover_dev_caps(struct ice_hw *hw, struct ice_hw_dev_caps *dev_caps);
938c2ecf20Sopenharmony_civoid
948c2ecf20Sopenharmony_ciice_update_phy_type(u64 *phy_type_low, u64 *phy_type_high,
958c2ecf20Sopenharmony_ci		    u16 link_speeds_bitmap);
968c2ecf20Sopenharmony_cienum ice_status
978c2ecf20Sopenharmony_ciice_aq_manage_mac_write(struct ice_hw *hw, const u8 *mac_addr, u8 flags,
988c2ecf20Sopenharmony_ci			struct ice_sq_cd *cd);
998c2ecf20Sopenharmony_cienum ice_status ice_clear_pf_cfg(struct ice_hw *hw);
1008c2ecf20Sopenharmony_cienum ice_status
1018c2ecf20Sopenharmony_ciice_aq_set_phy_cfg(struct ice_hw *hw, struct ice_port_info *pi,
1028c2ecf20Sopenharmony_ci		   struct ice_aqc_set_phy_cfg_data *cfg, struct ice_sq_cd *cd);
1038c2ecf20Sopenharmony_cibool ice_fw_supports_link_override(struct ice_hw *hw);
1048c2ecf20Sopenharmony_cienum ice_status
1058c2ecf20Sopenharmony_ciice_get_link_default_override(struct ice_link_default_override_tlv *ldo,
1068c2ecf20Sopenharmony_ci			      struct ice_port_info *pi);
1078c2ecf20Sopenharmony_cibool ice_is_phy_caps_an_enabled(struct ice_aqc_get_phy_caps_data *caps);
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_cienum ice_fc_mode ice_caps_to_fc_mode(u8 caps);
1108c2ecf20Sopenharmony_cienum ice_fec_mode ice_caps_to_fec_mode(u8 caps, u8 fec_options);
1118c2ecf20Sopenharmony_cienum ice_status
1128c2ecf20Sopenharmony_ciice_set_fc(struct ice_port_info *pi, u8 *aq_failures,
1138c2ecf20Sopenharmony_ci	   bool ena_auto_link_update);
1148c2ecf20Sopenharmony_cienum ice_status
1158c2ecf20Sopenharmony_ciice_cfg_phy_fc(struct ice_port_info *pi, struct ice_aqc_set_phy_cfg_data *cfg,
1168c2ecf20Sopenharmony_ci	       enum ice_fc_mode fc);
1178c2ecf20Sopenharmony_cibool
1188c2ecf20Sopenharmony_ciice_phy_caps_equals_cfg(struct ice_aqc_get_phy_caps_data *caps,
1198c2ecf20Sopenharmony_ci			struct ice_aqc_set_phy_cfg_data *cfg);
1208c2ecf20Sopenharmony_civoid
1218c2ecf20Sopenharmony_ciice_copy_phy_caps_to_cfg(struct ice_port_info *pi,
1228c2ecf20Sopenharmony_ci			 struct ice_aqc_get_phy_caps_data *caps,
1238c2ecf20Sopenharmony_ci			 struct ice_aqc_set_phy_cfg_data *cfg);
1248c2ecf20Sopenharmony_cienum ice_status
1258c2ecf20Sopenharmony_ciice_cfg_phy_fec(struct ice_port_info *pi, struct ice_aqc_set_phy_cfg_data *cfg,
1268c2ecf20Sopenharmony_ci		enum ice_fec_mode fec);
1278c2ecf20Sopenharmony_cienum ice_status
1288c2ecf20Sopenharmony_ciice_aq_set_link_restart_an(struct ice_port_info *pi, bool ena_link,
1298c2ecf20Sopenharmony_ci			   struct ice_sq_cd *cd);
1308c2ecf20Sopenharmony_cienum ice_status
1318c2ecf20Sopenharmony_ciice_aq_set_mac_cfg(struct ice_hw *hw, u16 max_frame_size, struct ice_sq_cd *cd);
1328c2ecf20Sopenharmony_cienum ice_status
1338c2ecf20Sopenharmony_ciice_aq_get_link_info(struct ice_port_info *pi, bool ena_lse,
1348c2ecf20Sopenharmony_ci		     struct ice_link_status *link, struct ice_sq_cd *cd);
1358c2ecf20Sopenharmony_cienum ice_status
1368c2ecf20Sopenharmony_ciice_aq_set_event_mask(struct ice_hw *hw, u8 port_num, u16 mask,
1378c2ecf20Sopenharmony_ci		      struct ice_sq_cd *cd);
1388c2ecf20Sopenharmony_cienum ice_status
1398c2ecf20Sopenharmony_ciice_aq_set_mac_loopback(struct ice_hw *hw, bool ena_lpbk, struct ice_sq_cd *cd);
1408c2ecf20Sopenharmony_ci
1418c2ecf20Sopenharmony_cienum ice_status
1428c2ecf20Sopenharmony_ciice_aq_set_port_id_led(struct ice_port_info *pi, bool is_orig_mode,
1438c2ecf20Sopenharmony_ci		       struct ice_sq_cd *cd);
1448c2ecf20Sopenharmony_cienum ice_status
1458c2ecf20Sopenharmony_ciice_aq_sff_eeprom(struct ice_hw *hw, u16 lport, u8 bus_addr,
1468c2ecf20Sopenharmony_ci		  u16 mem_addr, u8 page, u8 set_page, u8 *data, u8 length,
1478c2ecf20Sopenharmony_ci		  bool write, struct ice_sq_cd *cd);
1488c2ecf20Sopenharmony_ci
1498c2ecf20Sopenharmony_cienum ice_status
1508c2ecf20Sopenharmony_ciice_dis_vsi_txq(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u8 num_queues,
1518c2ecf20Sopenharmony_ci		u16 *q_handle, u16 *q_ids, u32 *q_teids,
1528c2ecf20Sopenharmony_ci		enum ice_disq_rst_src rst_src, u16 vmvf_num,
1538c2ecf20Sopenharmony_ci		struct ice_sq_cd *cd);
1548c2ecf20Sopenharmony_cienum ice_status
1558c2ecf20Sopenharmony_ciice_cfg_vsi_lan(struct ice_port_info *pi, u16 vsi_handle, u8 tc_bitmap,
1568c2ecf20Sopenharmony_ci		u16 *max_lanqs);
1578c2ecf20Sopenharmony_cienum ice_status
1588c2ecf20Sopenharmony_ciice_ena_vsi_txq(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u16 q_handle,
1598c2ecf20Sopenharmony_ci		u8 num_qgrps, struct ice_aqc_add_tx_qgrp *buf, u16 buf_size,
1608c2ecf20Sopenharmony_ci		struct ice_sq_cd *cd);
1618c2ecf20Sopenharmony_cienum ice_status ice_replay_vsi(struct ice_hw *hw, u16 vsi_handle);
1628c2ecf20Sopenharmony_civoid ice_replay_post(struct ice_hw *hw);
1638c2ecf20Sopenharmony_civoid ice_output_fw_log(struct ice_hw *hw, struct ice_aq_desc *desc, void *buf);
1648c2ecf20Sopenharmony_cistruct ice_q_ctx *
1658c2ecf20Sopenharmony_ciice_get_lan_q_ctx(struct ice_hw *hw, u16 vsi_handle, u8 tc, u16 q_handle);
1668c2ecf20Sopenharmony_civoid
1678c2ecf20Sopenharmony_ciice_stat_update40(struct ice_hw *hw, u32 reg, bool prev_stat_loaded,
1688c2ecf20Sopenharmony_ci		  u64 *prev_stat, u64 *cur_stat);
1698c2ecf20Sopenharmony_civoid
1708c2ecf20Sopenharmony_ciice_stat_update32(struct ice_hw *hw, u32 reg, bool prev_stat_loaded,
1718c2ecf20Sopenharmony_ci		  u64 *prev_stat, u64 *cur_stat);
1728c2ecf20Sopenharmony_cienum ice_status
1738c2ecf20Sopenharmony_ciice_sched_query_elem(struct ice_hw *hw, u32 node_teid,
1748c2ecf20Sopenharmony_ci		     struct ice_aqc_txsched_elem_data *buf);
1758c2ecf20Sopenharmony_cienum ice_status
1768c2ecf20Sopenharmony_ciice_aq_set_lldp_mib(struct ice_hw *hw, u8 mib_type, void *buf, u16 buf_size,
1778c2ecf20Sopenharmony_ci		    struct ice_sq_cd *cd);
1788c2ecf20Sopenharmony_ci#endif /* _ICE_COMMON_H_ */
179