xref: /linux-6.15/include/linux/qed/qed_eth_if.h (revision d19cd4bb)
1 /* QLogic qed NIC Driver
2  * Copyright (c) 2015-2017  QLogic Corporation
3  *
4  * This software is available to you under a choice of one of two
5  * licenses.  You may choose to be licensed under the terms of the GNU
6  * General Public License (GPL) Version 2, available from the file
7  * COPYING in the main directory of this source tree, or the
8  * OpenIB.org BSD license below:
9  *
10  *     Redistribution and use in source and binary forms, with or
11  *     without modification, are permitted provided that the following
12  *     conditions are met:
13  *
14  *      - Redistributions of source code must retain the above
15  *        copyright notice, this list of conditions and the following
16  *        disclaimer.
17  *
18  *      - Redistributions in binary form must reproduce the above
19  *        copyright notice, this list of conditions and the following
20  *        disclaimer in the documentation and /or other materials
21  *        provided with the distribution.
22  *
23  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30  * SOFTWARE.
31  */
32 
33 #ifndef _QED_ETH_IF_H
34 #define _QED_ETH_IF_H
35 
36 #include <linux/list.h>
37 #include <linux/if_link.h>
38 #include <linux/qed/eth_common.h>
39 #include <linux/qed/qed_if.h>
40 #include <linux/qed/qed_iov_if.h>
41 
42 struct qed_queue_start_common_params {
43 	/* Should always be relative to entity sending this. */
44 	u8 vport_id;
45 	u16 queue_id;
46 
47 	/* Relative, but relevant only for PFs */
48 	u8 stats_id;
49 
50 	struct qed_sb_info *p_sb;
51 	u8 sb_idx;
52 };
53 
54 struct qed_rxq_start_ret_params {
55 	void __iomem *p_prod;
56 	void *p_handle;
57 };
58 
59 struct qed_txq_start_ret_params {
60 	void __iomem *p_doorbell;
61 	void *p_handle;
62 };
63 
64 struct qed_dev_eth_info {
65 	struct qed_dev_info common;
66 
67 	u8	num_queues;
68 	u8	num_tc;
69 
70 	u8	port_mac[ETH_ALEN];
71 	u16	num_vlan_filters;
72 	u16	num_mac_filters;
73 
74 	/* Legacy VF - this affects the datapath, so qede has to know */
75 	bool is_legacy;
76 
77 	/* Might depend on available resources [in case of VF] */
78 	bool xdp_supported;
79 };
80 
81 struct qed_update_vport_rss_params {
82 	void	*rss_ind_table[128];
83 	u32	rss_key[10];
84 	u8	rss_caps;
85 };
86 
87 struct qed_update_vport_params {
88 	u8 vport_id;
89 	u8 update_vport_active_flg;
90 	u8 vport_active_flg;
91 	u8 update_tx_switching_flg;
92 	u8 tx_switching_flg;
93 	u8 update_accept_any_vlan_flg;
94 	u8 accept_any_vlan;
95 	u8 update_rss_flg;
96 	struct qed_update_vport_rss_params rss_params;
97 };
98 
99 struct qed_start_vport_params {
100 	bool remove_inner_vlan;
101 	bool handle_ptp_pkts;
102 	bool gro_enable;
103 	bool drop_ttl0;
104 	u8 vport_id;
105 	u16 mtu;
106 	bool clear_stats;
107 };
108 
109 enum qed_filter_rx_mode_type {
110 	QED_FILTER_RX_MODE_TYPE_REGULAR,
111 	QED_FILTER_RX_MODE_TYPE_MULTI_PROMISC,
112 	QED_FILTER_RX_MODE_TYPE_PROMISC,
113 };
114 
115 enum qed_filter_xcast_params_type {
116 	QED_FILTER_XCAST_TYPE_ADD,
117 	QED_FILTER_XCAST_TYPE_DEL,
118 	QED_FILTER_XCAST_TYPE_REPLACE,
119 };
120 
121 struct qed_filter_ucast_params {
122 	enum qed_filter_xcast_params_type type;
123 	u8 vlan_valid;
124 	u16 vlan;
125 	u8 mac_valid;
126 	unsigned char mac[ETH_ALEN];
127 };
128 
129 struct qed_filter_mcast_params {
130 	enum qed_filter_xcast_params_type type;
131 	u8 num;
132 	unsigned char mac[64][ETH_ALEN];
133 };
134 
135 union qed_filter_type_params {
136 	enum qed_filter_rx_mode_type accept_flags;
137 	struct qed_filter_ucast_params ucast;
138 	struct qed_filter_mcast_params mcast;
139 };
140 
141 enum qed_filter_type {
142 	QED_FILTER_TYPE_UCAST,
143 	QED_FILTER_TYPE_MCAST,
144 	QED_FILTER_TYPE_RX_MODE,
145 	QED_MAX_FILTER_TYPES,
146 };
147 
148 struct qed_filter_params {
149 	enum qed_filter_type type;
150 	union qed_filter_type_params filter;
151 };
152 
153 struct qed_tunn_params {
154 	u16 vxlan_port;
155 	u8 update_vxlan_port;
156 	u16 geneve_port;
157 	u8 update_geneve_port;
158 };
159 
160 struct qed_eth_cb_ops {
161 	struct qed_common_cb_ops common;
162 	void (*force_mac) (void *dev, u8 *mac, bool forced);
163 	void (*ports_update)(void *dev, u16 vxlan_port, u16 geneve_port);
164 };
165 
166 #define QED_MAX_PHC_DRIFT_PPB   291666666
167 
168 enum qed_ptp_filter_type {
169 	QED_PTP_FILTER_NONE,
170 	QED_PTP_FILTER_ALL,
171 	QED_PTP_FILTER_V1_L4_EVENT,
172 	QED_PTP_FILTER_V1_L4_GEN,
173 	QED_PTP_FILTER_V2_L4_EVENT,
174 	QED_PTP_FILTER_V2_L4_GEN,
175 	QED_PTP_FILTER_V2_L2_EVENT,
176 	QED_PTP_FILTER_V2_L2_GEN,
177 	QED_PTP_FILTER_V2_EVENT,
178 	QED_PTP_FILTER_V2_GEN
179 };
180 
181 enum qed_ptp_hwtstamp_tx_type {
182 	QED_PTP_HWTSTAMP_TX_OFF,
183 	QED_PTP_HWTSTAMP_TX_ON,
184 };
185 
186 #ifdef CONFIG_DCB
187 /* Prototype declaration of qed_eth_dcbnl_ops should match with the declaration
188  * of dcbnl_rtnl_ops structure.
189  */
190 struct qed_eth_dcbnl_ops {
191 	/* IEEE 802.1Qaz std */
192 	int (*ieee_getpfc)(struct qed_dev *cdev, struct ieee_pfc *pfc);
193 	int (*ieee_setpfc)(struct qed_dev *cdev, struct ieee_pfc *pfc);
194 	int (*ieee_getets)(struct qed_dev *cdev, struct ieee_ets *ets);
195 	int (*ieee_setets)(struct qed_dev *cdev, struct ieee_ets *ets);
196 	int (*ieee_peer_getets)(struct qed_dev *cdev, struct ieee_ets *ets);
197 	int (*ieee_peer_getpfc)(struct qed_dev *cdev, struct ieee_pfc *pfc);
198 	int (*ieee_getapp)(struct qed_dev *cdev, struct dcb_app *app);
199 	int (*ieee_setapp)(struct qed_dev *cdev, struct dcb_app *app);
200 
201 	/* CEE std */
202 	u8 (*getstate)(struct qed_dev *cdev);
203 	u8 (*setstate)(struct qed_dev *cdev, u8 state);
204 	void (*getpgtccfgtx)(struct qed_dev *cdev, int prio, u8 *prio_type,
205 			     u8 *pgid, u8 *bw_pct, u8 *up_map);
206 	void (*getpgbwgcfgtx)(struct qed_dev *cdev, int pgid, u8 *bw_pct);
207 	void (*getpgtccfgrx)(struct qed_dev *cdev, int prio, u8 *prio_type,
208 			     u8 *pgid, u8 *bw_pct, u8 *up_map);
209 	void (*getpgbwgcfgrx)(struct qed_dev *cdev, int pgid, u8 *bw_pct);
210 	void (*getpfccfg)(struct qed_dev *cdev, int prio, u8 *setting);
211 	void (*setpfccfg)(struct qed_dev *cdev, int prio, u8 setting);
212 	u8 (*getcap)(struct qed_dev *cdev, int capid, u8 *cap);
213 	int (*getnumtcs)(struct qed_dev *cdev, int tcid, u8 *num);
214 	u8 (*getpfcstate)(struct qed_dev *cdev);
215 	int (*getapp)(struct qed_dev *cdev, u8 idtype, u16 id);
216 	u8 (*getfeatcfg)(struct qed_dev *cdev, int featid, u8 *flags);
217 
218 	/* DCBX configuration */
219 	u8 (*getdcbx)(struct qed_dev *cdev);
220 	void (*setpgtccfgtx)(struct qed_dev *cdev, int prio,
221 			     u8 pri_type, u8 pgid, u8 bw_pct, u8 up_map);
222 	void (*setpgtccfgrx)(struct qed_dev *cdev, int prio,
223 			     u8 pri_type, u8 pgid, u8 bw_pct, u8 up_map);
224 	void (*setpgbwgcfgtx)(struct qed_dev *cdev, int pgid, u8 bw_pct);
225 	void (*setpgbwgcfgrx)(struct qed_dev *cdev, int pgid, u8 bw_pct);
226 	u8 (*setall)(struct qed_dev *cdev);
227 	int (*setnumtcs)(struct qed_dev *cdev, int tcid, u8 num);
228 	void (*setpfcstate)(struct qed_dev *cdev, u8 state);
229 	int (*setapp)(struct qed_dev *cdev, u8 idtype, u16 idval, u8 up);
230 	u8 (*setdcbx)(struct qed_dev *cdev, u8 state);
231 	u8 (*setfeatcfg)(struct qed_dev *cdev, int featid, u8 flags);
232 
233 	/* Peer apps */
234 	int (*peer_getappinfo)(struct qed_dev *cdev,
235 			       struct dcb_peer_app_info *info,
236 			       u16 *app_count);
237 	int (*peer_getapptable)(struct qed_dev *cdev, struct dcb_app *table);
238 
239 	/* CEE peer */
240 	int (*cee_peer_getpfc)(struct qed_dev *cdev, struct cee_pfc *pfc);
241 	int (*cee_peer_getpg)(struct qed_dev *cdev, struct cee_pg *pg);
242 };
243 #endif
244 
245 struct qed_eth_ptp_ops {
246 	int (*cfg_filters)(struct qed_dev *, enum qed_ptp_filter_type,
247 			   enum qed_ptp_hwtstamp_tx_type);
248 	int (*read_rx_ts)(struct qed_dev *, u64 *);
249 	int (*read_tx_ts)(struct qed_dev *, u64 *);
250 	int (*read_cc)(struct qed_dev *, u64 *);
251 	int (*disable)(struct qed_dev *);
252 	int (*adjfreq)(struct qed_dev *, s32);
253 	int (*enable)(struct qed_dev *);
254 };
255 
256 struct qed_eth_ops {
257 	const struct qed_common_ops *common;
258 #ifdef CONFIG_QED_SRIOV
259 	const struct qed_iov_hv_ops *iov;
260 #endif
261 #ifdef CONFIG_DCB
262 	const struct qed_eth_dcbnl_ops *dcb;
263 #endif
264 	const struct qed_eth_ptp_ops *ptp;
265 
266 	int (*fill_dev_info)(struct qed_dev *cdev,
267 			     struct qed_dev_eth_info *info);
268 
269 	void (*register_ops)(struct qed_dev *cdev,
270 			     struct qed_eth_cb_ops *ops,
271 			     void *cookie);
272 
273 	 bool(*check_mac) (struct qed_dev *cdev, u8 *mac);
274 
275 	int (*vport_start)(struct qed_dev *cdev,
276 			   struct qed_start_vport_params *params);
277 
278 	int (*vport_stop)(struct qed_dev *cdev,
279 			  u8 vport_id);
280 
281 	int (*vport_update)(struct qed_dev *cdev,
282 			    struct qed_update_vport_params *params);
283 
284 	int (*q_rx_start)(struct qed_dev *cdev,
285 			  u8 rss_num,
286 			  struct qed_queue_start_common_params *params,
287 			  u16 bd_max_bytes,
288 			  dma_addr_t bd_chain_phys_addr,
289 			  dma_addr_t cqe_pbl_addr,
290 			  u16 cqe_pbl_size,
291 			  struct qed_rxq_start_ret_params *ret_params);
292 
293 	int (*q_rx_stop)(struct qed_dev *cdev, u8 rss_id, void *handle);
294 
295 	int (*q_tx_start)(struct qed_dev *cdev,
296 			  u8 rss_num,
297 			  struct qed_queue_start_common_params *params,
298 			  dma_addr_t pbl_addr,
299 			  u16 pbl_size,
300 			  struct qed_txq_start_ret_params *ret_params);
301 
302 	int (*q_tx_stop)(struct qed_dev *cdev, u8 rss_id, void *handle);
303 
304 	int (*filter_config)(struct qed_dev *cdev,
305 			     struct qed_filter_params *params);
306 
307 	int (*fastpath_stop)(struct qed_dev *cdev);
308 
309 	int (*eth_cqe_completion)(struct qed_dev *cdev,
310 				  u8 rss_id,
311 				  struct eth_slow_path_rx_cqe *cqe);
312 
313 	void (*get_vport_stats)(struct qed_dev *cdev,
314 				struct qed_eth_stats *stats);
315 
316 	int (*tunn_config)(struct qed_dev *cdev,
317 			   struct qed_tunn_params *params);
318 
319 	int (*ntuple_filter_config)(struct qed_dev *cdev, void *cookie,
320 				    dma_addr_t mapping, u16 length,
321 				    u16 vport_id, u16 rx_queue_id,
322 				    bool add_filter);
323 
324 	int (*configure_arfs_searcher)(struct qed_dev *cdev,
325 				       bool en_searcher);
326 	int (*get_coalesce)(struct qed_dev *cdev, u16 *coal, void *handle);
327 };
328 
329 const struct qed_eth_ops *qed_get_eth_ops(void);
330 void qed_put_eth_ops(void);
331 
332 #endif
333