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 void ice_vsi_cfg_msix(struct ice_vsi *vsi); 58 59 int ice_vsi_start_all_rx_rings(struct ice_vsi *vsi); 60 61 int ice_vsi_stop_all_rx_rings(struct ice_vsi *vsi); 62 63 int 64 ice_vsi_stop_lan_tx_rings(struct ice_vsi *vsi, enum ice_disq_rst_src rst_src, 65 u16 rel_vmvf_num); 66 67 int ice_vsi_stop_xdp_tx_rings(struct ice_vsi *vsi); 68 69 void ice_cfg_sw_lldp(struct ice_vsi *vsi, bool tx, bool create); 70 71 int ice_set_link(struct ice_vsi *vsi, bool ena); 72 73 void ice_vsi_delete(struct ice_vsi *vsi); 74 75 int ice_vsi_cfg_tc(struct ice_vsi *vsi, u8 ena_tc); 76 77 int ice_vsi_cfg_rss_lut_key(struct ice_vsi *vsi); 78 79 void ice_vsi_cfg_netdev_tc(struct ice_vsi *vsi, u8 ena_tc); 80 81 struct ice_vsi * 82 ice_vsi_setup(struct ice_pf *pf, struct ice_vsi_cfg_params *params); 83 84 void 85 ice_queue_set_napi(struct ice_vsi *vsi, unsigned int queue_index, 86 enum netdev_queue_type type, struct napi_struct *napi); 87 88 void __ice_q_vector_set_napi_queues(struct ice_q_vector *q_vector, bool locked); 89 90 void ice_q_vector_set_napi_queues(struct ice_q_vector *q_vector); 91 92 void ice_vsi_set_napi_queues(struct ice_vsi *vsi); 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_free_irq(struct ice_vsi *vsi); 114 115 void ice_vsi_free_rx_rings(struct ice_vsi *vsi); 116 117 void ice_vsi_free_tx_rings(struct ice_vsi *vsi); 118 119 void ice_vsi_manage_rss_lut(struct ice_vsi *vsi, bool ena); 120 121 void ice_vsi_cfg_crc_strip(struct ice_vsi *vsi, bool disable); 122 123 void ice_update_tx_ring_stats(struct ice_tx_ring *ring, u64 pkts, u64 bytes); 124 125 void ice_update_rx_ring_stats(struct ice_rx_ring *ring, u64 pkts, u64 bytes); 126 127 void ice_write_intrl(struct ice_q_vector *q_vector, u8 intrl); 128 void ice_write_itr(struct ice_ring_container *rc, u16 itr); 129 void ice_set_q_vector_intrl(struct ice_q_vector *q_vector); 130 131 int ice_vsi_cfg_mac_fltr(struct ice_vsi *vsi, const u8 *macaddr, bool set); 132 133 bool ice_is_safe_mode(struct ice_pf *pf); 134 bool ice_is_rdma_ena(struct ice_pf *pf); 135 bool ice_is_dflt_vsi_in_use(struct ice_port_info *pi); 136 bool ice_is_vsi_dflt_vsi(struct ice_vsi *vsi); 137 int ice_set_dflt_vsi(struct ice_vsi *vsi); 138 int ice_clear_dflt_vsi(struct ice_vsi *vsi); 139 int ice_set_min_bw_limit(struct ice_vsi *vsi, u64 min_tx_rate); 140 int ice_set_max_bw_limit(struct ice_vsi *vsi, u64 max_tx_rate); 141 int ice_get_link_speed_kbps(struct ice_vsi *vsi); 142 int ice_get_link_speed_mbps(struct ice_vsi *vsi); 143 int 144 ice_vsi_update_security(struct ice_vsi *vsi, void (*fill)(struct ice_vsi_ctx *)); 145 146 void ice_vsi_ctx_set_antispoof(struct ice_vsi_ctx *ctx); 147 148 void ice_vsi_ctx_clear_antispoof(struct ice_vsi_ctx *ctx); 149 150 void ice_vsi_ctx_set_allow_override(struct ice_vsi_ctx *ctx); 151 152 void ice_vsi_ctx_clear_allow_override(struct ice_vsi_ctx *ctx); 153 int ice_vsi_update_local_lb(struct ice_vsi *vsi, bool set); 154 int ice_vsi_add_vlan_zero(struct ice_vsi *vsi); 155 int ice_vsi_del_vlan_zero(struct ice_vsi *vsi); 156 bool ice_vsi_has_non_zero_vlans(struct ice_vsi *vsi); 157 u16 ice_vsi_num_non_zero_vlans(struct ice_vsi *vsi); 158 bool ice_is_feature_supported(struct ice_pf *pf, enum ice_feature f); 159 void ice_set_feature_support(struct ice_pf *pf, enum ice_feature f); 160 void ice_clear_feature_support(struct ice_pf *pf, enum ice_feature f); 161 void ice_init_feature_support(struct ice_pf *pf); 162 bool ice_vsi_is_rx_queue_active(struct ice_vsi *vsi); 163 #endif /* !_ICE_LIB_H_ */ 164