qed_eth_if.h 10.2 KB
Newer Older
Y
Yuval Mintz 已提交
1
/* QLogic qed NIC Driver
M
Mintz, Yuval 已提交
2
 * Copyright (c) 2015-2017  QLogic Corporation
Y
Yuval Mintz 已提交
3
 *
M
Mintz, Yuval 已提交
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
 * This software is available to you under a choice of one of two
 * licenses.  You may choose to be licensed under the terms of the GNU
 * General Public License (GPL) Version 2, available from the file
 * COPYING in the main directory of this source tree, or the
 * OpenIB.org BSD license below:
 *
 *     Redistribution and use in source and binary forms, with or
 *     without modification, are permitted provided that the following
 *     conditions are met:
 *
 *      - Redistributions of source code must retain the above
 *        copyright notice, this list of conditions and the following
 *        disclaimer.
 *
 *      - Redistributions in binary form must reproduce the above
 *        copyright notice, this list of conditions and the following
 *        disclaimer in the documentation and /or other materials
 *        provided with the distribution.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
Y
Yuval Mintz 已提交
31 32 33 34 35 36 37 38 39
 */

#ifndef _QED_ETH_IF_H
#define _QED_ETH_IF_H

#include <linux/list.h>
#include <linux/if_link.h>
#include <linux/qed/eth_common.h>
#include <linux/qed/qed_if.h>
Y
Yuval Mintz 已提交
40
#include <linux/qed/qed_iov_if.h>
Y
Yuval Mintz 已提交
41

M
Mintz, Yuval 已提交
42 43 44 45 46 47 48 49
struct qed_queue_start_common_params {
	/* Should always be relative to entity sending this. */
	u8 vport_id;
	u16 queue_id;

	/* Relative, but relevant only for PFs */
	u8 stats_id;

50
	struct qed_sb_info *p_sb;
M
Mintz, Yuval 已提交
51 52 53 54 55 56 57 58 59 60 61 62 63
	u8 sb_idx;
};

struct qed_rxq_start_ret_params {
	void __iomem *p_prod;
	void *p_handle;
};

struct qed_txq_start_ret_params {
	void __iomem *p_doorbell;
	void *p_handle;
};

T
Tomer Tayar 已提交
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
enum qed_filter_config_mode {
	QED_FILTER_CONFIG_MODE_DISABLE,
	QED_FILTER_CONFIG_MODE_5_TUPLE,
	QED_FILTER_CONFIG_MODE_L4_PORT,
	QED_FILTER_CONFIG_MODE_IP_DEST,
};

struct qed_ntuple_filter_params {
	/* Physically mapped address containing header of buffer to be used
	 * as filter.
	 */
	dma_addr_t addr;

	/* Length of header in bytes */
	u16 length;

	/* Relative queue-id to receive classified packet */
#define QED_RFS_NTUPLE_QID_RSS ((u16)-1)
	u16 qid;

	/* Identifier can either be according to vport-id or vfid */
	bool b_is_vf;
	u8 vport_id;
	u8 vf_id;

	/* true iff this filter is to be added. Else to be removed */
	bool b_is_add;
};

Y
Yuval Mintz 已提交
93 94 95 96 97 98 99
struct qed_dev_eth_info {
	struct qed_dev_info common;

	u8	num_queues;
	u8	num_tc;

	u8	port_mac[ETH_ALEN];
100
	u16	num_vlan_filters;
Y
Yuval Mintz 已提交
101
	u16	num_mac_filters;
102 103 104

	/* Legacy VF - this affects the datapath, so qede has to know */
	bool is_legacy;
M
Mintz, Yuval 已提交
105 106 107

	/* Might depend on available resources [in case of VF] */
	bool xdp_supported;
Y
Yuval Mintz 已提交
108 109
};

M
Manish Chopra 已提交
110
struct qed_update_vport_rss_params {
111
	void	*rss_ind_table[128];
M
Manish Chopra 已提交
112
	u32	rss_key[10];
113
	u8	rss_caps;
M
Manish Chopra 已提交
114 115 116 117 118 119
};

struct qed_update_vport_params {
	u8 vport_id;
	u8 update_vport_active_flg;
	u8 vport_active_flg;
Y
Yuval Mintz 已提交
120 121
	u8 update_tx_switching_flg;
	u8 tx_switching_flg;
122 123
	u8 update_accept_any_vlan_flg;
	u8 accept_any_vlan;
M
Manish Chopra 已提交
124 125 126 127
	u8 update_rss_flg;
	struct qed_update_vport_rss_params rss_params;
};

128 129
struct qed_start_vport_params {
	bool remove_inner_vlan;
130
	bool handle_ptp_pkts;
131 132 133 134
	bool gro_enable;
	bool drop_ttl0;
	u8 vport_id;
	u16 mtu;
135
	bool clear_stats;
136 137
};

M
Manish Chopra 已提交
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
enum qed_filter_rx_mode_type {
	QED_FILTER_RX_MODE_TYPE_REGULAR,
	QED_FILTER_RX_MODE_TYPE_MULTI_PROMISC,
	QED_FILTER_RX_MODE_TYPE_PROMISC,
};

enum qed_filter_xcast_params_type {
	QED_FILTER_XCAST_TYPE_ADD,
	QED_FILTER_XCAST_TYPE_DEL,
	QED_FILTER_XCAST_TYPE_REPLACE,
};

struct qed_filter_ucast_params {
	enum qed_filter_xcast_params_type type;
	u8 vlan_valid;
	u16 vlan;
	u8 mac_valid;
	unsigned char mac[ETH_ALEN];
};

struct qed_filter_mcast_params {
	enum qed_filter_xcast_params_type type;
	u8 num;
	unsigned char mac[64][ETH_ALEN];
};

union qed_filter_type_params {
	enum qed_filter_rx_mode_type accept_flags;
	struct qed_filter_ucast_params ucast;
	struct qed_filter_mcast_params mcast;
};

enum qed_filter_type {
	QED_FILTER_TYPE_UCAST,
	QED_FILTER_TYPE_MCAST,
	QED_FILTER_TYPE_RX_MODE,
	QED_MAX_FILTER_TYPES,
};

struct qed_filter_params {
	enum qed_filter_type type;
	union qed_filter_type_params filter;
};

182 183 184 185 186 187 188
struct qed_tunn_params {
	u16 vxlan_port;
	u8 update_vxlan_port;
	u16 geneve_port;
	u8 update_geneve_port;
};

M
Manish Chopra 已提交
189 190
struct qed_eth_cb_ops {
	struct qed_common_cb_ops common;
Y
Yuval Mintz 已提交
191
	void (*force_mac) (void *dev, u8 *mac, bool forced);
192
	void (*ports_update)(void *dev, u16 vxlan_port, u16 geneve_port);
M
Manish Chopra 已提交
193 194
};

195 196 197
#define QED_MAX_PHC_DRIFT_PPB   291666666

enum qed_ptp_filter_type {
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212
	QED_PTP_FILTER_NONE,
	QED_PTP_FILTER_ALL,
	QED_PTP_FILTER_V1_L4_EVENT,
	QED_PTP_FILTER_V1_L4_GEN,
	QED_PTP_FILTER_V2_L4_EVENT,
	QED_PTP_FILTER_V2_L4_GEN,
	QED_PTP_FILTER_V2_L2_EVENT,
	QED_PTP_FILTER_V2_L2_GEN,
	QED_PTP_FILTER_V2_EVENT,
	QED_PTP_FILTER_V2_GEN
};

enum qed_ptp_hwtstamp_tx_type {
	QED_PTP_HWTSTAMP_TX_OFF,
	QED_PTP_HWTSTAMP_TX_ON,
213 214
};

215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273
#ifdef CONFIG_DCB
/* Prototype declaration of qed_eth_dcbnl_ops should match with the declaration
 * of dcbnl_rtnl_ops structure.
 */
struct qed_eth_dcbnl_ops {
	/* IEEE 802.1Qaz std */
	int (*ieee_getpfc)(struct qed_dev *cdev, struct ieee_pfc *pfc);
	int (*ieee_setpfc)(struct qed_dev *cdev, struct ieee_pfc *pfc);
	int (*ieee_getets)(struct qed_dev *cdev, struct ieee_ets *ets);
	int (*ieee_setets)(struct qed_dev *cdev, struct ieee_ets *ets);
	int (*ieee_peer_getets)(struct qed_dev *cdev, struct ieee_ets *ets);
	int (*ieee_peer_getpfc)(struct qed_dev *cdev, struct ieee_pfc *pfc);
	int (*ieee_getapp)(struct qed_dev *cdev, struct dcb_app *app);
	int (*ieee_setapp)(struct qed_dev *cdev, struct dcb_app *app);

	/* CEE std */
	u8 (*getstate)(struct qed_dev *cdev);
	u8 (*setstate)(struct qed_dev *cdev, u8 state);
	void (*getpgtccfgtx)(struct qed_dev *cdev, int prio, u8 *prio_type,
			     u8 *pgid, u8 *bw_pct, u8 *up_map);
	void (*getpgbwgcfgtx)(struct qed_dev *cdev, int pgid, u8 *bw_pct);
	void (*getpgtccfgrx)(struct qed_dev *cdev, int prio, u8 *prio_type,
			     u8 *pgid, u8 *bw_pct, u8 *up_map);
	void (*getpgbwgcfgrx)(struct qed_dev *cdev, int pgid, u8 *bw_pct);
	void (*getpfccfg)(struct qed_dev *cdev, int prio, u8 *setting);
	void (*setpfccfg)(struct qed_dev *cdev, int prio, u8 setting);
	u8 (*getcap)(struct qed_dev *cdev, int capid, u8 *cap);
	int (*getnumtcs)(struct qed_dev *cdev, int tcid, u8 *num);
	u8 (*getpfcstate)(struct qed_dev *cdev);
	int (*getapp)(struct qed_dev *cdev, u8 idtype, u16 id);
	u8 (*getfeatcfg)(struct qed_dev *cdev, int featid, u8 *flags);

	/* DCBX configuration */
	u8 (*getdcbx)(struct qed_dev *cdev);
	void (*setpgtccfgtx)(struct qed_dev *cdev, int prio,
			     u8 pri_type, u8 pgid, u8 bw_pct, u8 up_map);
	void (*setpgtccfgrx)(struct qed_dev *cdev, int prio,
			     u8 pri_type, u8 pgid, u8 bw_pct, u8 up_map);
	void (*setpgbwgcfgtx)(struct qed_dev *cdev, int pgid, u8 bw_pct);
	void (*setpgbwgcfgrx)(struct qed_dev *cdev, int pgid, u8 bw_pct);
	u8 (*setall)(struct qed_dev *cdev);
	int (*setnumtcs)(struct qed_dev *cdev, int tcid, u8 num);
	void (*setpfcstate)(struct qed_dev *cdev, u8 state);
	int (*setapp)(struct qed_dev *cdev, u8 idtype, u16 idval, u8 up);
	u8 (*setdcbx)(struct qed_dev *cdev, u8 state);
	u8 (*setfeatcfg)(struct qed_dev *cdev, int featid, u8 flags);

	/* Peer apps */
	int (*peer_getappinfo)(struct qed_dev *cdev,
			       struct dcb_peer_app_info *info,
			       u16 *app_count);
	int (*peer_getapptable)(struct qed_dev *cdev, struct dcb_app *table);

	/* CEE peer */
	int (*cee_peer_getpfc)(struct qed_dev *cdev, struct cee_pfc *pfc);
	int (*cee_peer_getpg)(struct qed_dev *cdev, struct cee_pg *pg);
};
#endif

274
struct qed_eth_ptp_ops {
275 276
	int (*cfg_filters)(struct qed_dev *, enum qed_ptp_filter_type,
			   enum qed_ptp_hwtstamp_tx_type);
277 278 279 280 281 282 283 284
	int (*read_rx_ts)(struct qed_dev *, u64 *);
	int (*read_tx_ts)(struct qed_dev *, u64 *);
	int (*read_cc)(struct qed_dev *, u64 *);
	int (*disable)(struct qed_dev *);
	int (*adjfreq)(struct qed_dev *, s32);
	int (*enable)(struct qed_dev *);
};

Y
Yuval Mintz 已提交
285 286
struct qed_eth_ops {
	const struct qed_common_ops *common;
Y
Yuval Mintz 已提交
287 288 289
#ifdef CONFIG_QED_SRIOV
	const struct qed_iov_hv_ops *iov;
#endif
290 291 292
#ifdef CONFIG_DCB
	const struct qed_eth_dcbnl_ops *dcb;
#endif
293
	const struct qed_eth_ptp_ops *ptp;
Y
Yuval Mintz 已提交
294 295 296 297

	int (*fill_dev_info)(struct qed_dev *cdev,
			     struct qed_dev_eth_info *info);

Y
Yuval Mintz 已提交
298 299 300 301
	void (*register_ops)(struct qed_dev *cdev,
			     struct qed_eth_cb_ops *ops,
			     void *cookie);

Y
Yuval Mintz 已提交
302 303
	 bool(*check_mac) (struct qed_dev *cdev, u8 *mac);

M
Manish Chopra 已提交
304
	int (*vport_start)(struct qed_dev *cdev,
305
			   struct qed_start_vport_params *params);
M
Manish Chopra 已提交
306 307 308 309 310 311 312 313

	int (*vport_stop)(struct qed_dev *cdev,
			  u8 vport_id);

	int (*vport_update)(struct qed_dev *cdev,
			    struct qed_update_vport_params *params);

	int (*q_rx_start)(struct qed_dev *cdev,
M
Mintz, Yuval 已提交
314
			  u8 rss_num,
M
Manish Chopra 已提交
315 316 317 318 319
			  struct qed_queue_start_common_params *params,
			  u16 bd_max_bytes,
			  dma_addr_t bd_chain_phys_addr,
			  dma_addr_t cqe_pbl_addr,
			  u16 cqe_pbl_size,
M
Mintz, Yuval 已提交
320
			  struct qed_rxq_start_ret_params *ret_params);
M
Manish Chopra 已提交
321

M
Mintz, Yuval 已提交
322
	int (*q_rx_stop)(struct qed_dev *cdev, u8 rss_id, void *handle);
M
Manish Chopra 已提交
323 324

	int (*q_tx_start)(struct qed_dev *cdev,
M
Mintz, Yuval 已提交
325
			  u8 rss_num,
M
Manish Chopra 已提交
326 327 328
			  struct qed_queue_start_common_params *params,
			  dma_addr_t pbl_addr,
			  u16 pbl_size,
M
Mintz, Yuval 已提交
329
			  struct qed_txq_start_ret_params *ret_params);
M
Manish Chopra 已提交
330

M
Mintz, Yuval 已提交
331
	int (*q_tx_stop)(struct qed_dev *cdev, u8 rss_id, void *handle);
M
Manish Chopra 已提交
332 333 334 335 336 337 338 339 340

	int (*filter_config)(struct qed_dev *cdev,
			     struct qed_filter_params *params);

	int (*fastpath_stop)(struct qed_dev *cdev);

	int (*eth_cqe_completion)(struct qed_dev *cdev,
				  u8 rss_id,
				  struct eth_slow_path_rx_cqe *cqe);
M
Manish Chopra 已提交
341 342 343

	void (*get_vport_stats)(struct qed_dev *cdev,
				struct qed_eth_stats *stats);
344 345 346

	int (*tunn_config)(struct qed_dev *cdev,
			   struct qed_tunn_params *params);
347

T
Tomer Tayar 已提交
348 349 350
	int (*ntuple_filter_config)(struct qed_dev *cdev,
				    void *cookie,
				    struct qed_ntuple_filter_params *params);
351 352

	int (*configure_arfs_searcher)(struct qed_dev *cdev,
T
Tomer Tayar 已提交
353
				       enum qed_filter_config_mode mode);
354
	int (*get_coalesce)(struct qed_dev *cdev, u16 *coal, void *handle);
355
	int (*req_bulletin_update_mac)(struct qed_dev *cdev, u8 *mac);
Y
Yuval Mintz 已提交
356 357
};

R
Rahul Verma 已提交
358
const struct qed_eth_ops *qed_get_eth_ops(void);
Y
Yuval Mintz 已提交
359 360 361
void qed_put_eth_ops(void);

#endif