1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* Copyright (c) 2018, Intel Corporation. */ 3 4 #ifndef _ICE_LIB_H_ 5 #define _ICE_LIB_H_ 6 7 #include "ice.h" 8 #include "ice_vlan.h" 9 10 /* Flags used for VSI configuration and rebuild */ 11 #define ICE_VSI_FLAG_INIT BIT(0) 12 #define ICE_VSI_FLAG_NO_INIT 0 13 14 /** 15 * struct ice_vsi_cfg_params - VSI configuration parameters 16 * @pi: pointer to the port_info instance for the VSI 17 * @ch: pointer to the channel structure for the VSI, may be NULL 18 * @vf: pointer to the VF associated with this VSI, may be NULL 19 * @type: the type of VSI to configure 20 * @flags: VSI flags used for rebuild and configuration 21 * 22 * Parameter structure used when configuring a new VSI. 23 */ 24 struct ice_vsi_cfg_params { 25 struct ice_port_info *pi; 26 struct ice_channel *ch; 27 struct ice_vf *vf; 28 enum ice_vsi_type type; 29 u32 flags; 30 }; 31 32 /** 33 * ice_vsi_to_params - Get parameters for an existing VSI 34 * @vsi: the VSI to get parameters for 35 * 36 * Fill a parameter structure for reconfiguring a VSI with its current 37 * parameters, such as during a rebuild operation. 38 */ 39 static inline struct ice_vsi_cfg_params ice_vsi_to_params(struct ice_vsi *vsi) 40 { 41 struct ice_vsi_cfg_params params = {}; 42 43 params.pi = vsi->port_info; 44 params.ch = vsi->ch; 45 params.vf = vsi->vf; 46 params.type = vsi->type; 47 48 return params; 49 } 50 51 const char *ice_vsi_type_str(enum ice_vsi_type vsi_type); 52 53 bool ice_pf_state_is_nominal(struct ice_pf *pf); 54 55 void ice_update_eth_stats(struct ice_vsi *vsi); 56 57 int ice_vsi_cfg_single_rxq(struct ice_vsi *vsi, u16 q_idx); 58 59 int ice_vsi_cfg_single_txq(struct ice_vsi *vsi, struct ice_tx_ring **tx_rings, u16 q_idx); 60 61 int ice_vsi_cfg_rxqs(struct ice_vsi *vsi); 62 63 int ice_vsi_cfg_lan_txqs(struct ice_vsi *vsi); 64 65 void ice_vsi_cfg_msix(struct ice_vsi *vsi); 66 67 int ice_vsi_start_all_rx_rings(struct ice_vsi *vsi); 68 69 int ice_vsi_stop_all_rx_rings(struct ice_vsi *vsi); 70 71 int 72 ice_vsi_stop_lan_tx_rings(struct ice_vsi *vsi, enum ice_disq_rst_src rst_src, 73 u16 rel_vmvf_num); 74 75 int ice_vsi_cfg_xdp_txqs(struct ice_vsi *vsi); 76 77 int ice_vsi_stop_xdp_tx_rings(struct ice_vsi *vsi); 78 79 void ice_cfg_sw_lldp(struct ice_vsi *vsi, bool tx, bool create); 80 81 int ice_set_link(struct ice_vsi *vsi, bool ena); 82 83 void ice_vsi_delete(struct ice_vsi *vsi); 84 85 int ice_vsi_cfg_tc(struct ice_vsi *vsi, u8 ena_tc); 86 87 int ice_vsi_cfg_rss_lut_key(struct ice_vsi *vsi); 88 89 void ice_vsi_cfg_netdev_tc(struct ice_vsi *vsi, u8 ena_tc); 90 91 struct ice_vsi * 92 ice_vsi_setup(struct ice_pf *pf, struct ice_vsi_cfg_params *params); 93 94 int ice_vsi_release(struct ice_vsi *vsi); 95 96 void ice_vsi_close(struct ice_vsi *vsi); 97 98 int ice_ena_vsi(struct ice_vsi *vsi, bool locked); 99 100 void ice_vsi_decfg(struct ice_vsi *vsi); 101 void ice_dis_vsi(struct ice_vsi *vsi, bool locked); 102 103 int ice_vsi_rebuild(struct ice_vsi *vsi, u32 vsi_flags); 104 int ice_vsi_cfg(struct ice_vsi *vsi, struct ice_vsi_cfg_params *params); 105 106 bool ice_is_reset_in_progress(unsigned long *state); 107 int ice_wait_for_reset(struct ice_pf *pf, unsigned long timeout); 108 109 void 110 ice_write_qrxflxp_cntxt(struct ice_hw *hw, u16 pf_q, u32 rxdid, u32 prio, 111 bool ena_ts); 112 113 void ice_vsi_dis_irq(struct ice_vsi *vsi); 114 115 void ice_vsi_free_irq(struct ice_vsi *vsi); 116 117 void ice_vsi_free_rx_rings(struct ice_vsi *vsi); 118 119 void ice_vsi_free_tx_rings(struct ice_vsi *vsi); 120 121 void ice_vsi_manage_rss_lut(struct ice_vsi *vsi, bool ena); 122 123 void ice_vsi_cfg_crc_strip(struct ice_vsi *vsi, bool disable); 124 125 void ice_update_tx_ring_stats(struct ice_tx_ring *ring, u64 pkts, u64 bytes); 126 127 void ice_update_rx_ring_stats(struct ice_rx_ring *ring, u64 pkts, u64 bytes); 128 129 void ice_write_intrl(struct ice_q_vector *q_vector, u8 intrl); 130 void ice_write_itr(struct ice_ring_container *rc, u16 itr); 131 void ice_set_q_vector_intrl(struct ice_q_vector *q_vector); 132 133 int ice_vsi_cfg_mac_fltr(struct ice_vsi *vsi, const u8 *macaddr, bool set); 134 135 bool ice_is_safe_mode(struct ice_pf *pf); 136 bool ice_is_rdma_ena(struct ice_pf *pf); 137 bool ice_is_dflt_vsi_in_use(struct ice_port_info *pi); 138 bool ice_is_vsi_dflt_vsi(struct ice_vsi *vsi); 139 int ice_set_dflt_vsi(struct ice_vsi *vsi); 140 int ice_clear_dflt_vsi(struct ice_vsi *vsi); 141 int ice_set_min_bw_limit(struct ice_vsi *vsi, u64 min_tx_rate); 142 int ice_set_max_bw_limit(struct ice_vsi *vsi, u64 max_tx_rate); 143 int ice_get_link_speed_kbps(struct ice_vsi *vsi); 144 int ice_get_link_speed_mbps(struct ice_vsi *vsi); 145 int 146 ice_vsi_update_security(struct ice_vsi *vsi, void (*fill)(struct ice_vsi_ctx *)); 147 148 void ice_vsi_ctx_set_antispoof(struct ice_vsi_ctx *ctx); 149 150 void ice_vsi_ctx_clear_antispoof(struct ice_vsi_ctx *ctx); 151 152 void ice_vsi_ctx_set_allow_override(struct ice_vsi_ctx *ctx); 153 154 void ice_vsi_ctx_clear_allow_override(struct ice_vsi_ctx *ctx); 155 int ice_vsi_update_local_lb(struct ice_vsi *vsi, bool set); 156 int ice_vsi_add_vlan_zero(struct ice_vsi *vsi); 157 int ice_vsi_del_vlan_zero(struct ice_vsi *vsi); 158 bool ice_vsi_has_non_zero_vlans(struct ice_vsi *vsi); 159 u16 ice_vsi_num_non_zero_vlans(struct ice_vsi *vsi); 160 bool ice_is_feature_supported(struct ice_pf *pf, enum ice_feature f); 161 void ice_set_feature_support(struct ice_pf *pf, enum ice_feature f); 162 void ice_clear_feature_support(struct ice_pf *pf, enum ice_feature f); 163 void ice_init_feature_support(struct ice_pf *pf); 164 bool ice_vsi_is_rx_queue_active(struct ice_vsi *vsi); 165 #endif /* !_ICE_LIB_H_ */ 166