17ec59eeaSAnirudh Venkataramanan /* SPDX-License-Identifier: GPL-2.0 */ 27ec59eeaSAnirudh Venkataramanan /* Copyright (c) 2018, Intel Corporation. */ 37ec59eeaSAnirudh Venkataramanan 47ec59eeaSAnirudh Venkataramanan #ifndef _ICE_COMMON_H_ 57ec59eeaSAnirudh Venkataramanan #define _ICE_COMMON_H_ 67ec59eeaSAnirudh Venkataramanan 77ec59eeaSAnirudh Venkataramanan #include "ice.h" 87ec59eeaSAnirudh Venkataramanan #include "ice_type.h" 9031f2147SMd Fahad Iqbal Polash #include "ice_nvm.h" 10c7648810STony Nguyen #include "ice_flex_pipe.h" 119c20346bSAnirudh Venkataramanan #include "ice_switch.h" 12ddf30f7fSAnirudh Venkataramanan #include <linux/avf/virtchnl.h> 137ec59eeaSAnirudh Venkataramanan 140e674aebSAnirudh Venkataramanan enum ice_status ice_nvm_validate_checksum(struct ice_hw *hw); 150e674aebSAnirudh Venkataramanan 16f31e4b6fSAnirudh Venkataramanan enum ice_status ice_init_hw(struct ice_hw *hw); 17f31e4b6fSAnirudh Venkataramanan void ice_deinit_hw(struct ice_hw *hw); 18f31e4b6fSAnirudh Venkataramanan enum ice_status ice_check_reset(struct ice_hw *hw); 19f31e4b6fSAnirudh Venkataramanan enum ice_status ice_reset(struct ice_hw *hw, enum ice_reset_req req); 205c91ecfdSJacob Keller enum ice_status ice_create_all_ctrlq(struct ice_hw *hw); 217ec59eeaSAnirudh Venkataramanan enum ice_status ice_init_all_ctrlq(struct ice_hw *hw); 227ec59eeaSAnirudh Venkataramanan void ice_shutdown_all_ctrlq(struct ice_hw *hw); 235c91ecfdSJacob Keller void ice_destroy_all_ctrlq(struct ice_hw *hw); 247ec59eeaSAnirudh Venkataramanan enum ice_status 25940b61afSAnirudh Venkataramanan ice_clean_rq_elem(struct ice_hw *hw, struct ice_ctl_q_info *cq, 26940b61afSAnirudh Venkataramanan struct ice_rq_event_info *e, u16 *pending); 27940b61afSAnirudh Venkataramanan enum ice_status 280b28b702SAnirudh Venkataramanan ice_get_link_status(struct ice_port_info *pi, bool *link_up); 295755143dSDave Ertman enum ice_status ice_update_link_info(struct ice_port_info *pi); 300b28b702SAnirudh Venkataramanan enum ice_status 31f31e4b6fSAnirudh Venkataramanan ice_acquire_res(struct ice_hw *hw, enum ice_aq_res_ids res, 32ff2b1321SDan Nowlin enum ice_aq_res_access_type access, u32 timeout); 33f31e4b6fSAnirudh Venkataramanan void ice_release_res(struct ice_hw *hw, enum ice_aq_res_ids res); 3431ad4e4eSTony Nguyen enum ice_status 3531ad4e4eSTony Nguyen ice_alloc_hw_res(struct ice_hw *hw, u16 type, u16 num, bool btm, u16 *res); 36451f2c44STony Nguyen enum ice_status 37451f2c44STony Nguyen ice_free_hw_res(struct ice_hw *hw, u16 type, u16 num, u16 *res); 38f31e4b6fSAnirudh Venkataramanan enum ice_status 3931ad4e4eSTony Nguyen ice_aq_alloc_free_res(struct ice_hw *hw, u16 num_entries, 4031ad4e4eSTony Nguyen struct ice_aqc_alloc_free_res_elem *buf, u16 buf_size, 4131ad4e4eSTony Nguyen enum ice_adminq_opc opc, struct ice_sq_cd *cd); 4231ad4e4eSTony Nguyen enum ice_status 437ec59eeaSAnirudh Venkataramanan ice_sq_send_cmd(struct ice_hw *hw, struct ice_ctl_q_info *cq, 447ec59eeaSAnirudh Venkataramanan struct ice_aq_desc *desc, void *buf, u16 buf_size, 457ec59eeaSAnirudh Venkataramanan struct ice_sq_cd *cd); 46f31e4b6fSAnirudh Venkataramanan void ice_clear_pxe_mode(struct ice_hw *hw); 479c20346bSAnirudh Venkataramanan enum ice_status ice_get_caps(struct ice_hw *hw); 48f203dca3SAnirudh Venkataramanan 49462acf6aSTony Nguyen void ice_set_safe_mode_caps(struct ice_hw *hw); 50462acf6aSTony Nguyen 51cdedef59SAnirudh Venkataramanan enum ice_status 52cdedef59SAnirudh Venkataramanan ice_write_rxq_ctx(struct ice_hw *hw, struct ice_rlan_ctx *rlan_ctx, 53cdedef59SAnirudh Venkataramanan u32 rxq_index); 54d76a60baSAnirudh Venkataramanan 55d76a60baSAnirudh Venkataramanan enum ice_status 564fb33f31SAnirudh Venkataramanan ice_aq_get_rss_lut(struct ice_hw *hw, u16 vsi_handle, u8 lut_type, u8 *lut, 57d76a60baSAnirudh Venkataramanan u16 lut_size); 58d76a60baSAnirudh Venkataramanan enum ice_status 594fb33f31SAnirudh Venkataramanan ice_aq_set_rss_lut(struct ice_hw *hw, u16 vsi_handle, u8 lut_type, u8 *lut, 60d76a60baSAnirudh Venkataramanan u16 lut_size); 61d76a60baSAnirudh Venkataramanan enum ice_status 624fb33f31SAnirudh Venkataramanan ice_aq_get_rss_key(struct ice_hw *hw, u16 vsi_handle, 63d76a60baSAnirudh Venkataramanan struct ice_aqc_get_set_rss_keys *keys); 64d76a60baSAnirudh Venkataramanan enum ice_status 654fb33f31SAnirudh Venkataramanan ice_aq_set_rss_key(struct ice_hw *hw, u16 vsi_handle, 66d76a60baSAnirudh Venkataramanan struct ice_aqc_get_set_rss_keys *keys); 674fb33f31SAnirudh Venkataramanan 687ec59eeaSAnirudh Venkataramanan bool ice_check_sq_alive(struct ice_hw *hw, struct ice_ctl_q_info *cq); 697ec59eeaSAnirudh Venkataramanan enum ice_status ice_aq_q_shutdown(struct ice_hw *hw, bool unloading); 707ec59eeaSAnirudh Venkataramanan void ice_fill_dflt_direct_cmd_desc(struct ice_aq_desc *desc, u16 opcode); 71cdedef59SAnirudh Venkataramanan extern const struct ice_ctx_ele ice_tlan_ctx_info[]; 72cdedef59SAnirudh Venkataramanan enum ice_status 737e34786aSBruce Allan ice_set_ctx(struct ice_hw *hw, u8 *src_ctx, u8 *dest_ctx, 747e34786aSBruce Allan const struct ice_ctx_ele *ce_info); 75c7648810STony Nguyen 76c7648810STony Nguyen extern struct mutex ice_global_cfg_lock_sw; 77c7648810STony Nguyen 787ec59eeaSAnirudh Venkataramanan enum ice_status 797ec59eeaSAnirudh Venkataramanan ice_aq_send_cmd(struct ice_hw *hw, struct ice_aq_desc *desc, 807ec59eeaSAnirudh Venkataramanan void *buf, u16 buf_size, struct ice_sq_cd *cd); 817ec59eeaSAnirudh Venkataramanan enum ice_status ice_aq_get_fw_ver(struct ice_hw *hw, struct ice_sq_cd *cd); 8248cb27f2SChinh Cao 8348cb27f2SChinh Cao enum ice_status 84e3710a01SPaul M Stillwell Jr ice_aq_send_driver_ver(struct ice_hw *hw, struct ice_driver_ver *dv, 85e3710a01SPaul M Stillwell Jr struct ice_sq_cd *cd); 86e3710a01SPaul M Stillwell Jr enum ice_status 8748cb27f2SChinh Cao ice_aq_get_phy_caps(struct ice_port_info *pi, bool qual_mods, u8 report_mode, 8848cb27f2SChinh Cao struct ice_aqc_get_phy_caps_data *caps, 8948cb27f2SChinh Cao struct ice_sq_cd *cd); 908d7aab35SJacob Keller enum ice_status 918d7aab35SJacob Keller ice_aq_list_caps(struct ice_hw *hw, void *buf, u16 buf_size, u32 *cap_count, 928d7aab35SJacob Keller enum ice_adminq_opc opc, struct ice_sq_cd *cd); 9348cb27f2SChinh Cao void 94aef74145SAnirudh Venkataramanan ice_update_phy_type(u64 *phy_type_low, u64 *phy_type_high, 95aef74145SAnirudh Venkataramanan u16 link_speeds_bitmap); 96e94d4478SAnirudh Venkataramanan enum ice_status 97d671e3e0SJacob Keller ice_aq_manage_mac_write(struct ice_hw *hw, const u8 *mac_addr, u8 flags, 98e94d4478SAnirudh Venkataramanan struct ice_sq_cd *cd); 99f31e4b6fSAnirudh Venkataramanan enum ice_status ice_clear_pf_cfg(struct ice_hw *hw); 100dc49c772SAnirudh Venkataramanan enum ice_status 1011a3571b5SPaul Greenwalt ice_aq_set_phy_cfg(struct ice_hw *hw, struct ice_port_info *pi, 10248cb27f2SChinh Cao struct ice_aqc_set_phy_cfg_data *cfg, struct ice_sq_cd *cd); 1031a3571b5SPaul Greenwalt enum ice_fc_mode ice_caps_to_fc_mode(u8 caps); 1041a3571b5SPaul Greenwalt enum ice_fec_mode ice_caps_to_fec_mode(u8 caps, u8 fec_options); 10548cb27f2SChinh Cao enum ice_status 10648cb27f2SChinh Cao ice_set_fc(struct ice_port_info *pi, u8 *aq_failures, 10748cb27f2SChinh Cao bool ena_auto_link_update); 10861cf42e7SPaul Greenwalt enum ice_status 1091a3571b5SPaul Greenwalt ice_cfg_phy_fc(struct ice_port_info *pi, struct ice_aqc_set_phy_cfg_data *cfg, 1101a3571b5SPaul Greenwalt enum ice_fc_mode fc); 1111a3571b5SPaul Greenwalt bool 1121a3571b5SPaul Greenwalt ice_phy_caps_equals_cfg(struct ice_aqc_get_phy_caps_data *caps, 1131a3571b5SPaul Greenwalt struct ice_aqc_set_phy_cfg_data *cfg); 114f776b3acSPaul Greenwalt void 115f776b3acSPaul Greenwalt ice_copy_phy_caps_to_cfg(struct ice_aqc_get_phy_caps_data *caps, 116f776b3acSPaul Greenwalt struct ice_aqc_set_phy_cfg_data *cfg); 117fcea6f3dSAnirudh Venkataramanan enum ice_status 1181a3571b5SPaul Greenwalt ice_cfg_phy_fec(struct ice_port_info *pi, struct ice_aqc_set_phy_cfg_data *cfg, 1191a3571b5SPaul Greenwalt enum ice_fec_mode fec); 1201a3571b5SPaul Greenwalt enum ice_status 121fcea6f3dSAnirudh Venkataramanan ice_aq_set_link_restart_an(struct ice_port_info *pi, bool ena_link, 122fcea6f3dSAnirudh Venkataramanan struct ice_sq_cd *cd); 123fcea6f3dSAnirudh Venkataramanan enum ice_status 12442449105SAnirudh Venkataramanan ice_aq_set_mac_cfg(struct ice_hw *hw, u16 max_frame_size, struct ice_sq_cd *cd); 12542449105SAnirudh Venkataramanan enum ice_status 126250c3b3eSBrett Creeley ice_aq_get_link_info(struct ice_port_info *pi, bool ena_lse, 127250c3b3eSBrett Creeley struct ice_link_status *link, struct ice_sq_cd *cd); 128250c3b3eSBrett Creeley enum ice_status 129250c3b3eSBrett Creeley ice_aq_set_event_mask(struct ice_hw *hw, u8 port_num, u16 mask, 130250c3b3eSBrett Creeley struct ice_sq_cd *cd); 131250c3b3eSBrett Creeley enum ice_status 1320e674aebSAnirudh Venkataramanan ice_aq_set_mac_loopback(struct ice_hw *hw, bool ena_lpbk, struct ice_sq_cd *cd); 1330e674aebSAnirudh Venkataramanan 1340e674aebSAnirudh Venkataramanan enum ice_status 1358e151d50SAnirudh Venkataramanan ice_aq_set_port_id_led(struct ice_port_info *pi, bool is_orig_mode, 1368e151d50SAnirudh Venkataramanan struct ice_sq_cd *cd); 137a012dca9SScott W Taylor enum ice_status 138a012dca9SScott W Taylor ice_aq_sff_eeprom(struct ice_hw *hw, u16 lport, u8 bus_addr, 139a012dca9SScott W Taylor u16 mem_addr, u8 page, u8 set_page, u8 *data, u8 length, 140a012dca9SScott W Taylor bool write, struct ice_sq_cd *cd); 1418e151d50SAnirudh Venkataramanan 1428e151d50SAnirudh Venkataramanan enum ice_status 143bb87ee0eSAnirudh Venkataramanan ice_dis_vsi_txq(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u8 num_queues, 144bb87ee0eSAnirudh Venkataramanan u16 *q_handle, u16 *q_ids, u32 *q_teids, 145bb87ee0eSAnirudh Venkataramanan enum ice_disq_rst_src rst_src, u16 vmvf_num, 146bb87ee0eSAnirudh Venkataramanan struct ice_sq_cd *cd); 147cdedef59SAnirudh Venkataramanan enum ice_status 1484fb33f31SAnirudh Venkataramanan ice_cfg_vsi_lan(struct ice_port_info *pi, u16 vsi_handle, u8 tc_bitmap, 1495513b920SAnirudh Venkataramanan u16 *max_lanqs); 1505513b920SAnirudh Venkataramanan enum ice_status 151bb87ee0eSAnirudh Venkataramanan ice_ena_vsi_txq(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u16 q_handle, 152bb87ee0eSAnirudh Venkataramanan u8 num_qgrps, struct ice_aqc_add_tx_qgrp *buf, u16 buf_size, 153cdedef59SAnirudh Venkataramanan struct ice_sq_cd *cd); 154334cb062SAnirudh Venkataramanan enum ice_status ice_replay_vsi(struct ice_hw *hw, u16 vsi_handle); 155334cb062SAnirudh Venkataramanan void ice_replay_post(struct ice_hw *hw); 1568b97ceb1SHieu Tran void ice_output_fw_log(struct ice_hw *hw, struct ice_aq_desc *desc, void *buf); 1571ddef455SUsha Ketineni struct ice_q_ctx * 1581ddef455SUsha Ketineni ice_get_lan_q_ctx(struct ice_hw *hw, u16 vsi_handle, u8 tc, u16 q_handle); 159c8b7abddSBruce Allan void 16036517fd3SJacob Keller ice_stat_update40(struct ice_hw *hw, u32 reg, bool prev_stat_loaded, 16136517fd3SJacob Keller u64 *prev_stat, u64 *cur_stat); 162c8b7abddSBruce Allan void 163c8b7abddSBruce Allan ice_stat_update32(struct ice_hw *hw, u32 reg, bool prev_stat_loaded, 16445d3d428SAnirudh Venkataramanan u64 *prev_stat, u64 *cur_stat); 1657b9ffc76SAnirudh Venkataramanan enum ice_status 1667b9ffc76SAnirudh Venkataramanan ice_sched_query_elem(struct ice_hw *hw, u32 node_teid, 167b3c38904SBruce Allan struct ice_aqc_txsched_elem_data *buf); 1687ec59eeaSAnirudh Venkataramanan #endif /* _ICE_COMMON_H_ */ 169