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 union qed_filter_type_params {
149 enum qed_filter_rx_mode_type accept_flags;
150 struct qed_filter_ucast_params ucast;
151 struct qed_filter_mcast_params mcast;
154 enum qed_filter_type {
155 QED_FILTER_TYPE_UCAST,
156 QED_FILTER_TYPE_MCAST,
157 QED_FILTER_TYPE_RX_MODE,
158 QED_MAX_FILTER_TYPES,
161 struct qed_filter_params {
162 enum qed_filter_type type;
163 union qed_filter_type_params filter;
166 struct qed_tunn_params {
168 u8 update_vxlan_port;
170 u8 update_geneve_port;
173 struct qed_eth_cb_ops {
174 struct qed_common_cb_ops common;
175 void (*force_mac) (void *dev, u8 *mac, bool forced);
176 void (*ports_update)(void *dev, u16 vxlan_port, u16 geneve_port);
179 #define QED_MAX_PHC_DRIFT_PPB 291666666
181 enum qed_ptp_filter_type {
184 QED_PTP_FILTER_V1_L4_EVENT,
185 QED_PTP_FILTER_V1_L4_GEN,
186 QED_PTP_FILTER_V2_L4_EVENT,
187 QED_PTP_FILTER_V2_L4_GEN,
188 QED_PTP_FILTER_V2_L2_EVENT,
189 QED_PTP_FILTER_V2_L2_GEN,
190 QED_PTP_FILTER_V2_EVENT,
191 QED_PTP_FILTER_V2_GEN
194 enum qed_ptp_hwtstamp_tx_type {
195 QED_PTP_HWTSTAMP_TX_OFF,
196 QED_PTP_HWTSTAMP_TX_ON,
200 /* Prototype declaration of qed_eth_dcbnl_ops should match with the declaration
201 * of dcbnl_rtnl_ops structure.
203 struct qed_eth_dcbnl_ops {
204 /* IEEE 802.1Qaz std */
205 int (*ieee_getpfc)(struct qed_dev *cdev, struct ieee_pfc *pfc);
206 int (*ieee_setpfc)(struct qed_dev *cdev, struct ieee_pfc *pfc);
207 int (*ieee_getets)(struct qed_dev *cdev, struct ieee_ets *ets);
208 int (*ieee_setets)(struct qed_dev *cdev, struct ieee_ets *ets);
209 int (*ieee_peer_getets)(struct qed_dev *cdev, struct ieee_ets *ets);
210 int (*ieee_peer_getpfc)(struct qed_dev *cdev, struct ieee_pfc *pfc);
211 int (*ieee_getapp)(struct qed_dev *cdev, struct dcb_app *app);
212 int (*ieee_setapp)(struct qed_dev *cdev, struct dcb_app *app);
215 u8 (*getstate)(struct qed_dev *cdev);
216 u8 (*setstate)(struct qed_dev *cdev, u8 state);
217 void (*getpgtccfgtx)(struct qed_dev *cdev, int prio, u8 *prio_type,
218 u8 *pgid, u8 *bw_pct, u8 *up_map);
219 void (*getpgbwgcfgtx)(struct qed_dev *cdev, int pgid, u8 *bw_pct);
220 void (*getpgtccfgrx)(struct qed_dev *cdev, int prio, u8 *prio_type,
221 u8 *pgid, u8 *bw_pct, u8 *up_map);
222 void (*getpgbwgcfgrx)(struct qed_dev *cdev, int pgid, u8 *bw_pct);
223 void (*getpfccfg)(struct qed_dev *cdev, int prio, u8 *setting);
224 void (*setpfccfg)(struct qed_dev *cdev, int prio, u8 setting);
225 u8 (*getcap)(struct qed_dev *cdev, int capid, u8 *cap);
226 int (*getnumtcs)(struct qed_dev *cdev, int tcid, u8 *num);
227 u8 (*getpfcstate)(struct qed_dev *cdev);
228 int (*getapp)(struct qed_dev *cdev, u8 idtype, u16 id);
229 u8 (*getfeatcfg)(struct qed_dev *cdev, int featid, u8 *flags);
231 /* DCBX configuration */
232 u8 (*getdcbx)(struct qed_dev *cdev);
233 void (*setpgtccfgtx)(struct qed_dev *cdev, int prio,
234 u8 pri_type, u8 pgid, u8 bw_pct, u8 up_map);
235 void (*setpgtccfgrx)(struct qed_dev *cdev, int prio,
236 u8 pri_type, u8 pgid, u8 bw_pct, u8 up_map);
237 void (*setpgbwgcfgtx)(struct qed_dev *cdev, int pgid, u8 bw_pct);
238 void (*setpgbwgcfgrx)(struct qed_dev *cdev, int pgid, u8 bw_pct);
239 u8 (*setall)(struct qed_dev *cdev);
240 int (*setnumtcs)(struct qed_dev *cdev, int tcid, u8 num);
241 void (*setpfcstate)(struct qed_dev *cdev, u8 state);
242 int (*setapp)(struct qed_dev *cdev, u8 idtype, u16 idval, u8 up);
243 u8 (*setdcbx)(struct qed_dev *cdev, u8 state);
244 u8 (*setfeatcfg)(struct qed_dev *cdev, int featid, u8 flags);
247 int (*peer_getappinfo)(struct qed_dev *cdev,
248 struct dcb_peer_app_info *info,
250 int (*peer_getapptable)(struct qed_dev *cdev, struct dcb_app *table);
253 int (*cee_peer_getpfc)(struct qed_dev *cdev, struct cee_pfc *pfc);
254 int (*cee_peer_getpg)(struct qed_dev *cdev, struct cee_pg *pg);
258 struct qed_eth_ptp_ops {
259 int (*cfg_filters)(struct qed_dev *, enum qed_ptp_filter_type,
260 enum qed_ptp_hwtstamp_tx_type);
261 int (*read_rx_ts)(struct qed_dev *, u64 *);
262 int (*read_tx_ts)(struct qed_dev *, u64 *);
263 int (*read_cc)(struct qed_dev *, u64 *);
264 int (*disable)(struct qed_dev *);
265 int (*adjfreq)(struct qed_dev *, s32);
266 int (*enable)(struct qed_dev *);
270 const struct qed_common_ops *common;
271 #ifdef CONFIG_QED_SRIOV
272 const struct qed_iov_hv_ops *iov;
275 const struct qed_eth_dcbnl_ops *dcb;
277 const struct qed_eth_ptp_ops *ptp;
279 int (*fill_dev_info)(struct qed_dev *cdev,
280 struct qed_dev_eth_info *info);
282 void (*register_ops)(struct qed_dev *cdev,
283 struct qed_eth_cb_ops *ops,
286 bool(*check_mac) (struct qed_dev *cdev, u8 *mac);
288 int (*vport_start)(struct qed_dev *cdev,
289 struct qed_start_vport_params *params);
291 int (*vport_stop)(struct qed_dev *cdev,
294 int (*vport_update)(struct qed_dev *cdev,
295 struct qed_update_vport_params *params);
297 int (*q_rx_start)(struct qed_dev *cdev,
299 struct qed_queue_start_common_params *params,
301 dma_addr_t bd_chain_phys_addr,
302 dma_addr_t cqe_pbl_addr,
304 struct qed_rxq_start_ret_params *ret_params);
306 int (*q_rx_stop)(struct qed_dev *cdev, u8 rss_id, void *handle);
308 int (*q_tx_start)(struct qed_dev *cdev,
310 struct qed_queue_start_common_params *params,
313 struct qed_txq_start_ret_params *ret_params);
315 int (*q_tx_stop)(struct qed_dev *cdev, u8 rss_id, void *handle);
317 int (*filter_config)(struct qed_dev *cdev,
318 struct qed_filter_params *params);
320 int (*fastpath_stop)(struct qed_dev *cdev);
322 int (*eth_cqe_completion)(struct qed_dev *cdev,
324 struct eth_slow_path_rx_cqe *cqe);
326 void (*get_vport_stats)(struct qed_dev *cdev,
327 struct qed_eth_stats *stats);
329 int (*tunn_config)(struct qed_dev *cdev,
330 struct qed_tunn_params *params);
332 int (*ntuple_filter_config)(struct qed_dev *cdev,
334 struct qed_ntuple_filter_params *params);
336 int (*configure_arfs_searcher)(struct qed_dev *cdev,
337 enum qed_filter_config_mode mode);
338 int (*get_coalesce)(struct qed_dev *cdev, u16 *coal, void *handle);
339 int (*req_bulletin_update_mac)(struct qed_dev *cdev, u8 *mac);
342 const struct qed_eth_ops *qed_get_eth_ops(void);
343 void qed_put_eth_ops(void);