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