1 /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
2 /* QLogic qed NIC Driver
3 * Copyright (c) 2015-2017 QLogic Corporation
4 * Copyright (c) 2019-2020 Marvell International Ltd.
10 #include <linux/list.h>
11 #include <linux/if_link.h>
12 #include <linux/qed/eth_common.h>
13 #include <linux/qed/qed_if.h>
14 #include <linux/qed/qed_iov_if.h>
16 /* 64 max queues * (1 rx + 4 tx-cos + 1 xdp) */
17 #define QED_MIN_L2_CONS (2 + NUM_PHYS_TCS_4PORT_K2)
18 #define QED_MAX_L2_CONS (64 * (QED_MIN_L2_CONS))
20 struct qed_queue_start_common_params {
21 /* Should always be relative to entity sending this. */
25 /* Relative, but relevant only for PFs */
28 struct qed_sb_info *p_sb;
34 struct qed_rxq_start_ret_params {
39 struct qed_txq_start_ret_params {
40 void __iomem *p_doorbell;
44 enum qed_filter_config_mode {
45 QED_FILTER_CONFIG_MODE_DISABLE,
46 QED_FILTER_CONFIG_MODE_5_TUPLE,
47 QED_FILTER_CONFIG_MODE_L4_PORT,
48 QED_FILTER_CONFIG_MODE_IP_DEST,
49 QED_FILTER_CONFIG_MODE_IP_SRC,
52 struct qed_ntuple_filter_params {
53 /* Physically mapped address containing header of buffer to be used
58 /* Length of header in bytes */
61 /* Relative queue-id to receive classified packet */
62 #define QED_RFS_NTUPLE_QID_RSS ((u16)-1)
65 /* Identifier can either be according to vport-id or vfid */
70 /* true iff this filter is to be added. Else to be removed */
73 /* If flow needs to be dropped */
77 struct qed_dev_eth_info {
78 struct qed_dev_info common;
83 u8 port_mac[ETH_ALEN];
87 /* Legacy VF - this affects the datapath, so qede has to know */
90 /* Might depend on available resources [in case of VF] */
94 struct qed_update_vport_rss_params {
95 void *rss_ind_table[128];
100 struct qed_update_vport_params {
102 u8 update_vport_active_flg;
104 u8 update_tx_switching_flg;
106 u8 update_accept_any_vlan_flg;
109 struct qed_update_vport_rss_params rss_params;
112 struct qed_start_vport_params {
113 bool remove_inner_vlan;
114 bool handle_ptp_pkts;
122 enum qed_filter_rx_mode_type {
123 QED_FILTER_RX_MODE_TYPE_REGULAR,
124 QED_FILTER_RX_MODE_TYPE_MULTI_PROMISC,
125 QED_FILTER_RX_MODE_TYPE_PROMISC,
128 enum qed_filter_xcast_params_type {
129 QED_FILTER_XCAST_TYPE_ADD,
130 QED_FILTER_XCAST_TYPE_DEL,
131 QED_FILTER_XCAST_TYPE_REPLACE,
134 struct qed_filter_ucast_params {
135 enum qed_filter_xcast_params_type type;
139 unsigned char mac[ETH_ALEN];
142 struct qed_filter_mcast_params {
143 enum qed_filter_xcast_params_type type;
145 unsigned char mac[64][ETH_ALEN];
148 enum qed_filter_type {
149 QED_FILTER_TYPE_UCAST,
150 QED_FILTER_TYPE_MCAST,
151 QED_FILTER_TYPE_RX_MODE,
152 QED_MAX_FILTER_TYPES,
155 struct qed_tunn_params {
157 u8 update_vxlan_port;
159 u8 update_geneve_port;
162 struct qed_eth_cb_ops {
163 struct qed_common_cb_ops common;
164 void (*force_mac) (void *dev, u8 *mac, bool forced);
165 void (*ports_update)(void *dev, u16 vxlan_port, u16 geneve_port);
168 #define QED_MAX_PHC_DRIFT_PPB 291666666
170 enum qed_ptp_filter_type {
173 QED_PTP_FILTER_V1_L4_EVENT,
174 QED_PTP_FILTER_V1_L4_GEN,
175 QED_PTP_FILTER_V2_L4_EVENT,
176 QED_PTP_FILTER_V2_L4_GEN,
177 QED_PTP_FILTER_V2_L2_EVENT,
178 QED_PTP_FILTER_V2_L2_GEN,
179 QED_PTP_FILTER_V2_EVENT,
180 QED_PTP_FILTER_V2_GEN
183 enum qed_ptp_hwtstamp_tx_type {
184 QED_PTP_HWTSTAMP_TX_OFF,
185 QED_PTP_HWTSTAMP_TX_ON,
189 /* Prototype declaration of qed_eth_dcbnl_ops should match with the declaration
190 * of dcbnl_rtnl_ops structure.
192 struct qed_eth_dcbnl_ops {
193 /* IEEE 802.1Qaz std */
194 int (*ieee_getpfc)(struct qed_dev *cdev, struct ieee_pfc *pfc);
195 int (*ieee_setpfc)(struct qed_dev *cdev, struct ieee_pfc *pfc);
196 int (*ieee_getets)(struct qed_dev *cdev, struct ieee_ets *ets);
197 int (*ieee_setets)(struct qed_dev *cdev, struct ieee_ets *ets);
198 int (*ieee_peer_getets)(struct qed_dev *cdev, struct ieee_ets *ets);
199 int (*ieee_peer_getpfc)(struct qed_dev *cdev, struct ieee_pfc *pfc);
200 int (*ieee_getapp)(struct qed_dev *cdev, struct dcb_app *app);
201 int (*ieee_setapp)(struct qed_dev *cdev, struct dcb_app *app);
204 u8 (*getstate)(struct qed_dev *cdev);
205 u8 (*setstate)(struct qed_dev *cdev, u8 state);
206 void (*getpgtccfgtx)(struct qed_dev *cdev, int prio, u8 *prio_type,
207 u8 *pgid, u8 *bw_pct, u8 *up_map);
208 void (*getpgbwgcfgtx)(struct qed_dev *cdev, int pgid, u8 *bw_pct);
209 void (*getpgtccfgrx)(struct qed_dev *cdev, int prio, u8 *prio_type,
210 u8 *pgid, u8 *bw_pct, u8 *up_map);
211 void (*getpgbwgcfgrx)(struct qed_dev *cdev, int pgid, u8 *bw_pct);
212 void (*getpfccfg)(struct qed_dev *cdev, int prio, u8 *setting);
213 void (*setpfccfg)(struct qed_dev *cdev, int prio, u8 setting);
214 u8 (*getcap)(struct qed_dev *cdev, int capid, u8 *cap);
215 int (*getnumtcs)(struct qed_dev *cdev, int tcid, u8 *num);
216 u8 (*getpfcstate)(struct qed_dev *cdev);
217 int (*getapp)(struct qed_dev *cdev, u8 idtype, u16 id);
218 u8 (*getfeatcfg)(struct qed_dev *cdev, int featid, u8 *flags);
220 /* DCBX configuration */
221 u8 (*getdcbx)(struct qed_dev *cdev);
222 void (*setpgtccfgtx)(struct qed_dev *cdev, int prio,
223 u8 pri_type, u8 pgid, u8 bw_pct, u8 up_map);
224 void (*setpgtccfgrx)(struct qed_dev *cdev, int prio,
225 u8 pri_type, u8 pgid, u8 bw_pct, u8 up_map);
226 void (*setpgbwgcfgtx)(struct qed_dev *cdev, int pgid, u8 bw_pct);
227 void (*setpgbwgcfgrx)(struct qed_dev *cdev, int pgid, u8 bw_pct);
228 u8 (*setall)(struct qed_dev *cdev);
229 int (*setnumtcs)(struct qed_dev *cdev, int tcid, u8 num);
230 void (*setpfcstate)(struct qed_dev *cdev, u8 state);
231 int (*setapp)(struct qed_dev *cdev, u8 idtype, u16 idval, u8 up);
232 u8 (*setdcbx)(struct qed_dev *cdev, u8 state);
233 u8 (*setfeatcfg)(struct qed_dev *cdev, int featid, u8 flags);
236 int (*peer_getappinfo)(struct qed_dev *cdev,
237 struct dcb_peer_app_info *info,
239 int (*peer_getapptable)(struct qed_dev *cdev, struct dcb_app *table);
242 int (*cee_peer_getpfc)(struct qed_dev *cdev, struct cee_pfc *pfc);
243 int (*cee_peer_getpg)(struct qed_dev *cdev, struct cee_pg *pg);
247 struct qed_eth_ptp_ops {
248 int (*cfg_filters)(struct qed_dev *, enum qed_ptp_filter_type,
249 enum qed_ptp_hwtstamp_tx_type);
250 int (*read_rx_ts)(struct qed_dev *, u64 *);
251 int (*read_tx_ts)(struct qed_dev *, u64 *);
252 int (*read_cc)(struct qed_dev *, u64 *);
253 int (*disable)(struct qed_dev *);
254 int (*adjfreq)(struct qed_dev *, s32);
255 int (*enable)(struct qed_dev *);
259 const struct qed_common_ops *common;
260 #ifdef CONFIG_QED_SRIOV
261 const struct qed_iov_hv_ops *iov;
264 const struct qed_eth_dcbnl_ops *dcb;
266 const struct qed_eth_ptp_ops *ptp;
268 int (*fill_dev_info)(struct qed_dev *cdev,
269 struct qed_dev_eth_info *info);
271 void (*register_ops)(struct qed_dev *cdev,
272 struct qed_eth_cb_ops *ops,
275 bool(*check_mac) (struct qed_dev *cdev, u8 *mac);
277 int (*vport_start)(struct qed_dev *cdev,
278 struct qed_start_vport_params *params);
280 int (*vport_stop)(struct qed_dev *cdev,
283 int (*vport_update)(struct qed_dev *cdev,
284 struct qed_update_vport_params *params);
286 int (*q_rx_start)(struct qed_dev *cdev,
288 struct qed_queue_start_common_params *params,
290 dma_addr_t bd_chain_phys_addr,
291 dma_addr_t cqe_pbl_addr,
293 struct qed_rxq_start_ret_params *ret_params);
295 int (*q_rx_stop)(struct qed_dev *cdev, u8 rss_id, void *handle);
297 int (*q_tx_start)(struct qed_dev *cdev,
299 struct qed_queue_start_common_params *params,
302 struct qed_txq_start_ret_params *ret_params);
304 int (*q_tx_stop)(struct qed_dev *cdev, u8 rss_id, void *handle);
306 int (*filter_config_rx_mode)(struct qed_dev *cdev,
307 enum qed_filter_rx_mode_type type);
309 int (*filter_config_ucast)(struct qed_dev *cdev,
310 struct qed_filter_ucast_params *params);
312 int (*filter_config_mcast)(struct qed_dev *cdev,
313 struct qed_filter_mcast_params *params);
315 int (*fastpath_stop)(struct qed_dev *cdev);
317 int (*eth_cqe_completion)(struct qed_dev *cdev,
319 struct eth_slow_path_rx_cqe *cqe);
321 void (*get_vport_stats)(struct qed_dev *cdev,
322 struct qed_eth_stats *stats);
324 int (*tunn_config)(struct qed_dev *cdev,
325 struct qed_tunn_params *params);
327 int (*ntuple_filter_config)(struct qed_dev *cdev,
329 struct qed_ntuple_filter_params *params);
331 int (*configure_arfs_searcher)(struct qed_dev *cdev,
332 enum qed_filter_config_mode mode);
333 int (*get_coalesce)(struct qed_dev *cdev, u16 *coal, void *handle);
334 int (*req_bulletin_update_mac)(struct qed_dev *cdev, const u8 *mac);
337 const struct qed_eth_ops *qed_get_eth_ops(void);
338 void qed_put_eth_ops(void);