162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci/* Copyright (c) 2018, Intel Corporation. */
362306a36Sopenharmony_ci
462306a36Sopenharmony_ci#ifndef _ICE_COMMON_H_
562306a36Sopenharmony_ci#define _ICE_COMMON_H_
662306a36Sopenharmony_ci
762306a36Sopenharmony_ci#include <linux/bitfield.h>
862306a36Sopenharmony_ci
962306a36Sopenharmony_ci#include "ice_type.h"
1062306a36Sopenharmony_ci#include "ice_nvm.h"
1162306a36Sopenharmony_ci#include "ice_flex_pipe.h"
1262306a36Sopenharmony_ci#include <linux/avf/virtchnl.h>
1362306a36Sopenharmony_ci#include "ice_switch.h"
1462306a36Sopenharmony_ci#include "ice_fdir.h"
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_ci#define ICE_SQ_SEND_DELAY_TIME_MS	10
1762306a36Sopenharmony_ci#define ICE_SQ_SEND_MAX_EXECUTE		3
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ciint ice_init_hw(struct ice_hw *hw);
2062306a36Sopenharmony_civoid ice_deinit_hw(struct ice_hw *hw);
2162306a36Sopenharmony_ciint ice_check_reset(struct ice_hw *hw);
2262306a36Sopenharmony_ciint ice_reset(struct ice_hw *hw, enum ice_reset_req req);
2362306a36Sopenharmony_ciint ice_create_all_ctrlq(struct ice_hw *hw);
2462306a36Sopenharmony_ciint ice_init_all_ctrlq(struct ice_hw *hw);
2562306a36Sopenharmony_civoid ice_shutdown_all_ctrlq(struct ice_hw *hw);
2662306a36Sopenharmony_civoid ice_destroy_all_ctrlq(struct ice_hw *hw);
2762306a36Sopenharmony_ciint
2862306a36Sopenharmony_ciice_clean_rq_elem(struct ice_hw *hw, struct ice_ctl_q_info *cq,
2962306a36Sopenharmony_ci		  struct ice_rq_event_info *e, u16 *pending);
3062306a36Sopenharmony_ciint
3162306a36Sopenharmony_ciice_get_link_status(struct ice_port_info *pi, bool *link_up);
3262306a36Sopenharmony_ciint ice_update_link_info(struct ice_port_info *pi);
3362306a36Sopenharmony_ciint
3462306a36Sopenharmony_ciice_acquire_res(struct ice_hw *hw, enum ice_aq_res_ids res,
3562306a36Sopenharmony_ci		enum ice_aq_res_access_type access, u32 timeout);
3662306a36Sopenharmony_civoid ice_release_res(struct ice_hw *hw, enum ice_aq_res_ids res);
3762306a36Sopenharmony_ciint
3862306a36Sopenharmony_ciice_alloc_hw_res(struct ice_hw *hw, u16 type, u16 num, bool btm, u16 *res);
3962306a36Sopenharmony_ciint
4062306a36Sopenharmony_ciice_free_hw_res(struct ice_hw *hw, u16 type, u16 num, u16 *res);
4162306a36Sopenharmony_ciint ice_aq_alloc_free_res(struct ice_hw *hw,
4262306a36Sopenharmony_ci			  struct ice_aqc_alloc_free_res_elem *buf, u16 buf_size,
4362306a36Sopenharmony_ci			  enum ice_adminq_opc opc);
4462306a36Sopenharmony_cibool ice_is_sbq_supported(struct ice_hw *hw);
4562306a36Sopenharmony_cistruct ice_ctl_q_info *ice_get_sbq(struct ice_hw *hw);
4662306a36Sopenharmony_ciint
4762306a36Sopenharmony_ciice_sq_send_cmd(struct ice_hw *hw, struct ice_ctl_q_info *cq,
4862306a36Sopenharmony_ci		struct ice_aq_desc *desc, void *buf, u16 buf_size,
4962306a36Sopenharmony_ci		struct ice_sq_cd *cd);
5062306a36Sopenharmony_civoid ice_clear_pxe_mode(struct ice_hw *hw);
5162306a36Sopenharmony_ciint ice_get_caps(struct ice_hw *hw);
5262306a36Sopenharmony_ci
5362306a36Sopenharmony_civoid ice_set_safe_mode_caps(struct ice_hw *hw);
5462306a36Sopenharmony_ci
5562306a36Sopenharmony_ciint
5662306a36Sopenharmony_ciice_write_rxq_ctx(struct ice_hw *hw, struct ice_rlan_ctx *rlan_ctx,
5762306a36Sopenharmony_ci		  u32 rxq_index);
5862306a36Sopenharmony_ci
5962306a36Sopenharmony_ciint
6062306a36Sopenharmony_ciice_aq_get_rss_lut(struct ice_hw *hw, struct ice_aq_get_set_rss_lut_params *get_params);
6162306a36Sopenharmony_ciint
6262306a36Sopenharmony_ciice_aq_set_rss_lut(struct ice_hw *hw, struct ice_aq_get_set_rss_lut_params *set_params);
6362306a36Sopenharmony_ciint
6462306a36Sopenharmony_ciice_aq_get_rss_key(struct ice_hw *hw, u16 vsi_handle,
6562306a36Sopenharmony_ci		   struct ice_aqc_get_set_rss_keys *keys);
6662306a36Sopenharmony_ciint
6762306a36Sopenharmony_ciice_aq_set_rss_key(struct ice_hw *hw, u16 vsi_handle,
6862306a36Sopenharmony_ci		   struct ice_aqc_get_set_rss_keys *keys);
6962306a36Sopenharmony_ci
7062306a36Sopenharmony_cibool ice_check_sq_alive(struct ice_hw *hw, struct ice_ctl_q_info *cq);
7162306a36Sopenharmony_ciint ice_aq_q_shutdown(struct ice_hw *hw, bool unloading);
7262306a36Sopenharmony_civoid ice_fill_dflt_direct_cmd_desc(struct ice_aq_desc *desc, u16 opcode);
7362306a36Sopenharmony_ciextern const struct ice_ctx_ele ice_tlan_ctx_info[];
7462306a36Sopenharmony_ciint
7562306a36Sopenharmony_ciice_set_ctx(struct ice_hw *hw, u8 *src_ctx, u8 *dest_ctx,
7662306a36Sopenharmony_ci	    const struct ice_ctx_ele *ce_info);
7762306a36Sopenharmony_ci
7862306a36Sopenharmony_ciextern struct mutex ice_global_cfg_lock_sw;
7962306a36Sopenharmony_ci
8062306a36Sopenharmony_ciint
8162306a36Sopenharmony_ciice_aq_send_cmd(struct ice_hw *hw, struct ice_aq_desc *desc,
8262306a36Sopenharmony_ci		void *buf, u16 buf_size, struct ice_sq_cd *cd);
8362306a36Sopenharmony_ciint ice_aq_get_fw_ver(struct ice_hw *hw, struct ice_sq_cd *cd);
8462306a36Sopenharmony_ci
8562306a36Sopenharmony_ciint
8662306a36Sopenharmony_ciice_aq_send_driver_ver(struct ice_hw *hw, struct ice_driver_ver *dv,
8762306a36Sopenharmony_ci		       struct ice_sq_cd *cd);
8862306a36Sopenharmony_ciint
8962306a36Sopenharmony_ciice_aq_set_port_params(struct ice_port_info *pi, bool double_vlan,
9062306a36Sopenharmony_ci		       struct ice_sq_cd *cd);
9162306a36Sopenharmony_ciint
9262306a36Sopenharmony_ciice_aq_get_phy_caps(struct ice_port_info *pi, bool qual_mods, u8 report_mode,
9362306a36Sopenharmony_ci		    struct ice_aqc_get_phy_caps_data *caps,
9462306a36Sopenharmony_ci		    struct ice_sq_cd *cd);
9562306a36Sopenharmony_cibool ice_is_pf_c827(struct ice_hw *hw);
9662306a36Sopenharmony_ciint
9762306a36Sopenharmony_ciice_aq_list_caps(struct ice_hw *hw, void *buf, u16 buf_size, u32 *cap_count,
9862306a36Sopenharmony_ci		 enum ice_adminq_opc opc, struct ice_sq_cd *cd);
9962306a36Sopenharmony_ciint
10062306a36Sopenharmony_ciice_discover_dev_caps(struct ice_hw *hw, struct ice_hw_dev_caps *dev_caps);
10162306a36Sopenharmony_civoid
10262306a36Sopenharmony_ciice_update_phy_type(u64 *phy_type_low, u64 *phy_type_high,
10362306a36Sopenharmony_ci		    u16 link_speeds_bitmap);
10462306a36Sopenharmony_ciint
10562306a36Sopenharmony_ciice_aq_manage_mac_write(struct ice_hw *hw, const u8 *mac_addr, u8 flags,
10662306a36Sopenharmony_ci			struct ice_sq_cd *cd);
10762306a36Sopenharmony_cibool ice_is_e810(struct ice_hw *hw);
10862306a36Sopenharmony_ciint ice_clear_pf_cfg(struct ice_hw *hw);
10962306a36Sopenharmony_ciint
11062306a36Sopenharmony_ciice_aq_set_phy_cfg(struct ice_hw *hw, struct ice_port_info *pi,
11162306a36Sopenharmony_ci		   struct ice_aqc_set_phy_cfg_data *cfg, struct ice_sq_cd *cd);
11262306a36Sopenharmony_cibool ice_fw_supports_link_override(struct ice_hw *hw);
11362306a36Sopenharmony_ciint
11462306a36Sopenharmony_ciice_get_link_default_override(struct ice_link_default_override_tlv *ldo,
11562306a36Sopenharmony_ci			      struct ice_port_info *pi);
11662306a36Sopenharmony_cibool ice_is_phy_caps_an_enabled(struct ice_aqc_get_phy_caps_data *caps);
11762306a36Sopenharmony_ci
11862306a36Sopenharmony_cienum ice_fc_mode ice_caps_to_fc_mode(u8 caps);
11962306a36Sopenharmony_cienum ice_fec_mode ice_caps_to_fec_mode(u8 caps, u8 fec_options);
12062306a36Sopenharmony_ciint
12162306a36Sopenharmony_ciice_set_fc(struct ice_port_info *pi, u8 *aq_failures,
12262306a36Sopenharmony_ci	   bool ena_auto_link_update);
12362306a36Sopenharmony_ciint
12462306a36Sopenharmony_ciice_cfg_phy_fc(struct ice_port_info *pi, struct ice_aqc_set_phy_cfg_data *cfg,
12562306a36Sopenharmony_ci	       enum ice_fc_mode req_mode);
12662306a36Sopenharmony_cibool
12762306a36Sopenharmony_ciice_phy_caps_equals_cfg(struct ice_aqc_get_phy_caps_data *caps,
12862306a36Sopenharmony_ci			struct ice_aqc_set_phy_cfg_data *cfg);
12962306a36Sopenharmony_civoid
13062306a36Sopenharmony_ciice_copy_phy_caps_to_cfg(struct ice_port_info *pi,
13162306a36Sopenharmony_ci			 struct ice_aqc_get_phy_caps_data *caps,
13262306a36Sopenharmony_ci			 struct ice_aqc_set_phy_cfg_data *cfg);
13362306a36Sopenharmony_ciint
13462306a36Sopenharmony_ciice_cfg_phy_fec(struct ice_port_info *pi, struct ice_aqc_set_phy_cfg_data *cfg,
13562306a36Sopenharmony_ci		enum ice_fec_mode fec);
13662306a36Sopenharmony_ciint
13762306a36Sopenharmony_ciice_aq_set_link_restart_an(struct ice_port_info *pi, bool ena_link,
13862306a36Sopenharmony_ci			   struct ice_sq_cd *cd);
13962306a36Sopenharmony_ciint
14062306a36Sopenharmony_ciice_aq_set_mac_cfg(struct ice_hw *hw, u16 max_frame_size, struct ice_sq_cd *cd);
14162306a36Sopenharmony_ciint
14262306a36Sopenharmony_ciice_aq_get_link_info(struct ice_port_info *pi, bool ena_lse,
14362306a36Sopenharmony_ci		     struct ice_link_status *link, struct ice_sq_cd *cd);
14462306a36Sopenharmony_ciint
14562306a36Sopenharmony_ciice_aq_set_event_mask(struct ice_hw *hw, u8 port_num, u16 mask,
14662306a36Sopenharmony_ci		      struct ice_sq_cd *cd);
14762306a36Sopenharmony_ciint
14862306a36Sopenharmony_ciice_aq_set_mac_loopback(struct ice_hw *hw, bool ena_lpbk, struct ice_sq_cd *cd);
14962306a36Sopenharmony_ci
15062306a36Sopenharmony_ciint
15162306a36Sopenharmony_ciice_aq_set_port_id_led(struct ice_port_info *pi, bool is_orig_mode,
15262306a36Sopenharmony_ci		       struct ice_sq_cd *cd);
15362306a36Sopenharmony_ciint
15462306a36Sopenharmony_ciice_aq_get_port_options(struct ice_hw *hw,
15562306a36Sopenharmony_ci			struct ice_aqc_get_port_options_elem *options,
15662306a36Sopenharmony_ci			u8 *option_count, u8 lport, bool lport_valid,
15762306a36Sopenharmony_ci			u8 *active_option_idx, bool *active_option_valid,
15862306a36Sopenharmony_ci			u8 *pending_option_idx, bool *pending_option_valid);
15962306a36Sopenharmony_ciint
16062306a36Sopenharmony_ciice_aq_set_port_option(struct ice_hw *hw, u8 lport, u8 lport_valid,
16162306a36Sopenharmony_ci		       u8 new_option);
16262306a36Sopenharmony_ciint
16362306a36Sopenharmony_ciice_aq_sff_eeprom(struct ice_hw *hw, u16 lport, u8 bus_addr,
16462306a36Sopenharmony_ci		  u16 mem_addr, u8 page, u8 set_page, u8 *data, u8 length,
16562306a36Sopenharmony_ci		  bool write, struct ice_sq_cd *cd);
16662306a36Sopenharmony_ciu32 ice_get_link_speed(u16 index);
16762306a36Sopenharmony_ci
16862306a36Sopenharmony_ciint
16962306a36Sopenharmony_ciice_cfg_vsi_rdma(struct ice_port_info *pi, u16 vsi_handle, u16 tc_bitmap,
17062306a36Sopenharmony_ci		 u16 *max_rdmaqs);
17162306a36Sopenharmony_ciint
17262306a36Sopenharmony_ciice_ena_vsi_rdma_qset(struct ice_port_info *pi, u16 vsi_handle, u8 tc,
17362306a36Sopenharmony_ci		      u16 *rdma_qset, u16 num_qsets, u32 *qset_teid);
17462306a36Sopenharmony_ciint
17562306a36Sopenharmony_ciice_dis_vsi_rdma_qset(struct ice_port_info *pi, u16 count, u32 *qset_teid,
17662306a36Sopenharmony_ci		      u16 *q_id);
17762306a36Sopenharmony_ciint
17862306a36Sopenharmony_ciice_dis_vsi_txq(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u8 num_queues,
17962306a36Sopenharmony_ci		u16 *q_handle, u16 *q_ids, u32 *q_teids,
18062306a36Sopenharmony_ci		enum ice_disq_rst_src rst_src, u16 vmvf_num,
18162306a36Sopenharmony_ci		struct ice_sq_cd *cd);
18262306a36Sopenharmony_ciint
18362306a36Sopenharmony_ciice_cfg_vsi_lan(struct ice_port_info *pi, u16 vsi_handle, u8 tc_bitmap,
18462306a36Sopenharmony_ci		u16 *max_lanqs);
18562306a36Sopenharmony_ciint
18662306a36Sopenharmony_ciice_ena_vsi_txq(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u16 q_handle,
18762306a36Sopenharmony_ci		u8 num_qgrps, struct ice_aqc_add_tx_qgrp *buf, u16 buf_size,
18862306a36Sopenharmony_ci		struct ice_sq_cd *cd);
18962306a36Sopenharmony_ciint
19062306a36Sopenharmony_ciice_aq_cfg_lan_txq(struct ice_hw *hw, struct ice_aqc_cfg_txqs_buf *buf,
19162306a36Sopenharmony_ci		   u16 buf_size, u16 num_qs, u8 oldport, u8 newport,
19262306a36Sopenharmony_ci		   struct ice_sq_cd *cd);
19362306a36Sopenharmony_ciint ice_replay_vsi(struct ice_hw *hw, u16 vsi_handle);
19462306a36Sopenharmony_civoid ice_replay_post(struct ice_hw *hw);
19562306a36Sopenharmony_civoid ice_output_fw_log(struct ice_hw *hw, struct ice_aq_desc *desc, void *buf);
19662306a36Sopenharmony_cistruct ice_q_ctx *
19762306a36Sopenharmony_ciice_get_lan_q_ctx(struct ice_hw *hw, u16 vsi_handle, u8 tc, u16 q_handle);
19862306a36Sopenharmony_ciint ice_sbq_rw_reg(struct ice_hw *hw, struct ice_sbq_msg_input *in);
19962306a36Sopenharmony_civoid
20062306a36Sopenharmony_ciice_stat_update40(struct ice_hw *hw, u32 reg, bool prev_stat_loaded,
20162306a36Sopenharmony_ci		  u64 *prev_stat, u64 *cur_stat);
20262306a36Sopenharmony_civoid
20362306a36Sopenharmony_ciice_stat_update32(struct ice_hw *hw, u32 reg, bool prev_stat_loaded,
20462306a36Sopenharmony_ci		  u64 *prev_stat, u64 *cur_stat);
20562306a36Sopenharmony_cibool ice_is_e810t(struct ice_hw *hw);
20662306a36Sopenharmony_cibool ice_is_e823(struct ice_hw *hw);
20762306a36Sopenharmony_ciint
20862306a36Sopenharmony_ciice_sched_query_elem(struct ice_hw *hw, u32 node_teid,
20962306a36Sopenharmony_ci		     struct ice_aqc_txsched_elem_data *buf);
21062306a36Sopenharmony_ciint
21162306a36Sopenharmony_ciice_aq_set_driver_param(struct ice_hw *hw, enum ice_aqc_driver_params idx,
21262306a36Sopenharmony_ci			u32 value, struct ice_sq_cd *cd);
21362306a36Sopenharmony_ciint
21462306a36Sopenharmony_ciice_aq_get_driver_param(struct ice_hw *hw, enum ice_aqc_driver_params idx,
21562306a36Sopenharmony_ci			u32 *value, struct ice_sq_cd *cd);
21662306a36Sopenharmony_ciint
21762306a36Sopenharmony_ciice_aq_set_gpio(struct ice_hw *hw, u16 gpio_ctrl_handle, u8 pin_idx, bool value,
21862306a36Sopenharmony_ci		struct ice_sq_cd *cd);
21962306a36Sopenharmony_ciint
22062306a36Sopenharmony_ciice_aq_get_gpio(struct ice_hw *hw, u16 gpio_ctrl_handle, u8 pin_idx,
22162306a36Sopenharmony_ci		bool *value, struct ice_sq_cd *cd);
22262306a36Sopenharmony_cibool ice_is_100m_speed_supported(struct ice_hw *hw);
22362306a36Sopenharmony_ciint
22462306a36Sopenharmony_ciice_aq_set_lldp_mib(struct ice_hw *hw, u8 mib_type, void *buf, u16 buf_size,
22562306a36Sopenharmony_ci		    struct ice_sq_cd *cd);
22662306a36Sopenharmony_cibool ice_fw_supports_lldp_fltr_ctrl(struct ice_hw *hw);
22762306a36Sopenharmony_ciint
22862306a36Sopenharmony_ciice_lldp_fltr_add_remove(struct ice_hw *hw, u16 vsi_num, bool add);
22962306a36Sopenharmony_ciint ice_lldp_execute_pending_mib(struct ice_hw *hw);
23062306a36Sopenharmony_ciint
23162306a36Sopenharmony_ciice_aq_read_i2c(struct ice_hw *hw, struct ice_aqc_link_topo_addr topo_addr,
23262306a36Sopenharmony_ci		u16 bus_addr, __le16 addr, u8 params, u8 *data,
23362306a36Sopenharmony_ci		struct ice_sq_cd *cd);
23462306a36Sopenharmony_ciint
23562306a36Sopenharmony_ciice_aq_write_i2c(struct ice_hw *hw, struct ice_aqc_link_topo_addr topo_addr,
23662306a36Sopenharmony_ci		 u16 bus_addr, __le16 addr, u8 params, const u8 *data,
23762306a36Sopenharmony_ci		 struct ice_sq_cd *cd);
23862306a36Sopenharmony_cibool ice_fw_supports_report_dflt_cfg(struct ice_hw *hw);
23962306a36Sopenharmony_ci#endif /* _ICE_COMMON_H_ */
240