xref: /linux/drivers/net/ethernet/intel/ice/ice_lib.h (revision 906fd46a65383cd639e5eec72a047efc33045d86)
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 const char *ice_vsi_type_str(enum ice_vsi_type vsi_type);
15 
16 bool ice_pf_state_is_nominal(struct ice_pf *pf);
17 
18 void ice_update_eth_stats(struct ice_vsi *vsi);
19 
20 void ice_vsi_cfg_msix(struct ice_vsi *vsi);
21 
22 int ice_vsi_start_all_rx_rings(struct ice_vsi *vsi);
23 
24 int ice_vsi_stop_all_rx_rings(struct ice_vsi *vsi);
25 
26 int
27 ice_vsi_stop_lan_tx_rings(struct ice_vsi *vsi, enum ice_disq_rst_src rst_src,
28 			  u16 rel_vmvf_num);
29 
30 int ice_vsi_stop_xdp_tx_rings(struct ice_vsi *vsi);
31 
32 void ice_cfg_sw_lldp(struct ice_vsi *vsi, bool tx, bool create);
33 
34 int ice_set_link(struct ice_vsi *vsi, bool ena);
35 
36 void ice_vsi_delete(struct ice_vsi *vsi);
37 
38 int ice_vsi_cfg_tc(struct ice_vsi *vsi, u8 ena_tc);
39 
40 int ice_vsi_cfg_rss_lut_key(struct ice_vsi *vsi);
41 
42 void ice_vsi_cfg_netdev_tc(struct ice_vsi *vsi, u8 ena_tc);
43 
44 struct ice_vsi *
45 ice_vsi_setup(struct ice_pf *pf, struct ice_vsi_cfg_params *params);
46 
47 void
48 ice_queue_set_napi(struct ice_vsi *vsi, unsigned int queue_index,
49 		   enum netdev_queue_type type, struct napi_struct *napi);
50 
51 void __ice_q_vector_set_napi_queues(struct ice_q_vector *q_vector, bool locked);
52 
53 void ice_q_vector_set_napi_queues(struct ice_q_vector *q_vector);
54 
55 void ice_vsi_set_napi_queues(struct ice_vsi *vsi);
56 
57 int ice_vsi_release(struct ice_vsi *vsi);
58 
59 void ice_vsi_close(struct ice_vsi *vsi);
60 
61 int ice_ena_vsi(struct ice_vsi *vsi, bool locked);
62 
63 void ice_vsi_decfg(struct ice_vsi *vsi);
64 void ice_dis_vsi(struct ice_vsi *vsi, bool locked);
65 
66 int ice_vsi_rebuild(struct ice_vsi *vsi, u32 vsi_flags);
67 int ice_vsi_cfg(struct ice_vsi *vsi);
68 
69 bool ice_is_reset_in_progress(unsigned long *state);
70 int ice_wait_for_reset(struct ice_pf *pf, unsigned long timeout);
71 
72 void
73 ice_write_qrxflxp_cntxt(struct ice_hw *hw, u16 pf_q, u32 rxdid, u32 prio,
74 			bool ena_ts);
75 
76 void ice_vsi_free_irq(struct ice_vsi *vsi);
77 
78 void ice_vsi_free_rx_rings(struct ice_vsi *vsi);
79 
80 void ice_vsi_free_tx_rings(struct ice_vsi *vsi);
81 
82 void ice_vsi_manage_rss_lut(struct ice_vsi *vsi, bool ena);
83 
84 void ice_vsi_cfg_crc_strip(struct ice_vsi *vsi, bool disable);
85 
86 void ice_update_tx_ring_stats(struct ice_tx_ring *ring, u64 pkts, u64 bytes);
87 
88 void ice_update_rx_ring_stats(struct ice_rx_ring *ring, u64 pkts, u64 bytes);
89 
90 void ice_write_intrl(struct ice_q_vector *q_vector, u8 intrl);
91 void ice_write_itr(struct ice_ring_container *rc, u16 itr);
92 void ice_set_q_vector_intrl(struct ice_q_vector *q_vector);
93 
94 int ice_vsi_cfg_mac_fltr(struct ice_vsi *vsi, const u8 *macaddr, bool set);
95 
96 bool ice_is_safe_mode(struct ice_pf *pf);
97 bool ice_is_rdma_ena(struct ice_pf *pf);
98 bool ice_is_dflt_vsi_in_use(struct ice_port_info *pi);
99 bool ice_is_vsi_dflt_vsi(struct ice_vsi *vsi);
100 int ice_set_dflt_vsi(struct ice_vsi *vsi);
101 int ice_clear_dflt_vsi(struct ice_vsi *vsi);
102 int ice_set_min_bw_limit(struct ice_vsi *vsi, u64 min_tx_rate);
103 int ice_set_max_bw_limit(struct ice_vsi *vsi, u64 max_tx_rate);
104 int ice_get_link_speed_kbps(struct ice_vsi *vsi);
105 int ice_get_link_speed_mbps(struct ice_vsi *vsi);
106 int
107 ice_vsi_update_security(struct ice_vsi *vsi, void (*fill)(struct ice_vsi_ctx *));
108 
109 void ice_vsi_ctx_set_antispoof(struct ice_vsi_ctx *ctx);
110 
111 void ice_vsi_ctx_clear_antispoof(struct ice_vsi_ctx *ctx);
112 
113 void ice_vsi_ctx_set_allow_override(struct ice_vsi_ctx *ctx);
114 
115 void ice_vsi_ctx_clear_allow_override(struct ice_vsi_ctx *ctx);
116 int ice_vsi_update_local_lb(struct ice_vsi *vsi, bool set);
117 int ice_vsi_add_vlan_zero(struct ice_vsi *vsi);
118 int ice_vsi_del_vlan_zero(struct ice_vsi *vsi);
119 bool ice_vsi_has_non_zero_vlans(struct ice_vsi *vsi);
120 u16 ice_vsi_num_non_zero_vlans(struct ice_vsi *vsi);
121 bool ice_is_feature_supported(struct ice_pf *pf, enum ice_feature f);
122 void ice_set_feature_support(struct ice_pf *pf, enum ice_feature f);
123 void ice_clear_feature_support(struct ice_pf *pf, enum ice_feature f);
124 void ice_init_feature_support(struct ice_pf *pf);
125 bool ice_vsi_is_rx_queue_active(struct ice_vsi *vsi);
126 #endif /* !_ICE_LIB_H_ */
127