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 void 95 ice_queue_set_napi(struct ice_vsi *vsi, unsigned int queue_index, 96 enum netdev_queue_type type, struct napi_struct *napi); 97 98 void __ice_q_vector_set_napi_queues(struct ice_q_vector *q_vector, bool locked); 99 100 void ice_q_vector_set_napi_queues(struct ice_q_vector *q_vector); 101 102 void ice_vsi_set_napi_queues(struct ice_vsi *vsi); 103 104 int ice_vsi_release(struct ice_vsi *vsi); 105 106 void ice_vsi_close(struct ice_vsi *vsi); 107 108 int ice_ena_vsi(struct ice_vsi *vsi, bool locked); 109 110 void ice_vsi_decfg(struct ice_vsi *vsi); 111 void ice_dis_vsi(struct ice_vsi *vsi, bool locked); 112 113 int ice_vsi_rebuild(struct ice_vsi *vsi, u32 vsi_flags); 114 int ice_vsi_cfg(struct ice_vsi *vsi, struct ice_vsi_cfg_params *params); 115 116 bool ice_is_reset_in_progress(unsigned long *state); 117 int ice_wait_for_reset(struct ice_pf *pf, unsigned long timeout); 118 119 void 120 ice_write_qrxflxp_cntxt(struct ice_hw *hw, u16 pf_q, u32 rxdid, u32 prio, 121 bool ena_ts); 122 123 void ice_vsi_dis_irq(struct ice_vsi *vsi); 124 125 void ice_vsi_free_irq(struct ice_vsi *vsi); 126 127 void ice_vsi_free_rx_rings(struct ice_vsi *vsi); 128 129 void ice_vsi_free_tx_rings(struct ice_vsi *vsi); 130 131 void ice_vsi_manage_rss_lut(struct ice_vsi *vsi, bool ena); 132 133 void ice_vsi_cfg_crc_strip(struct ice_vsi *vsi, bool disable); 134 135 void ice_update_tx_ring_stats(struct ice_tx_ring *ring, u64 pkts, u64 bytes); 136 137 void ice_update_rx_ring_stats(struct ice_rx_ring *ring, u64 pkts, u64 bytes); 138 139 void ice_write_intrl(struct ice_q_vector *q_vector, u8 intrl); 140 void ice_write_itr(struct ice_ring_container *rc, u16 itr); 141 void ice_set_q_vector_intrl(struct ice_q_vector *q_vector); 142 143 int ice_vsi_cfg_mac_fltr(struct ice_vsi *vsi, const u8 *macaddr, bool set); 144 145 bool ice_is_safe_mode(struct ice_pf *pf); 146 bool ice_is_rdma_ena(struct ice_pf *pf); 147 bool ice_is_dflt_vsi_in_use(struct ice_port_info *pi); 148 bool ice_is_vsi_dflt_vsi(struct ice_vsi *vsi); 149 int ice_set_dflt_vsi(struct ice_vsi *vsi); 150 int ice_clear_dflt_vsi(struct ice_vsi *vsi); 151 int ice_set_min_bw_limit(struct ice_vsi *vsi, u64 min_tx_rate); 152 int ice_set_max_bw_limit(struct ice_vsi *vsi, u64 max_tx_rate); 153 int ice_get_link_speed_kbps(struct ice_vsi *vsi); 154 int ice_get_link_speed_mbps(struct ice_vsi *vsi); 155 int 156 ice_vsi_update_security(struct ice_vsi *vsi, void (*fill)(struct ice_vsi_ctx *)); 157 158 void ice_vsi_ctx_set_antispoof(struct ice_vsi_ctx *ctx); 159 160 void ice_vsi_ctx_clear_antispoof(struct ice_vsi_ctx *ctx); 161 162 void ice_vsi_ctx_set_allow_override(struct ice_vsi_ctx *ctx); 163 164 void ice_vsi_ctx_clear_allow_override(struct ice_vsi_ctx *ctx); 165 int ice_vsi_update_local_lb(struct ice_vsi *vsi, bool set); 166 int ice_vsi_add_vlan_zero(struct ice_vsi *vsi); 167 int ice_vsi_del_vlan_zero(struct ice_vsi *vsi); 168 bool ice_vsi_has_non_zero_vlans(struct ice_vsi *vsi); 169 u16 ice_vsi_num_non_zero_vlans(struct ice_vsi *vsi); 170 bool ice_is_feature_supported(struct ice_pf *pf, enum ice_feature f); 171 void ice_set_feature_support(struct ice_pf *pf, enum ice_feature f); 172 void ice_clear_feature_support(struct ice_pf *pf, enum ice_feature f); 173 void ice_init_feature_support(struct ice_pf *pf); 174 bool ice_vsi_is_rx_queue_active(struct ice_vsi *vsi); 175 #endif /* !_ICE_LIB_H_ */ 176