en.h 31.9 KB
Newer Older
1
/*
2
 * Copyright (c) 2015-2016, Mellanox Technologies. All rights reserved.
3
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
31
 *
 * 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.
 */
32
33
#ifndef __MLX5_EN_H__
#define __MLX5_EN_H__
34
35
36

#include <linux/if_vlan.h>
#include <linux/etherdevice.h>
37
38
#include <linux/timecounter.h>
#include <linux/net_tstamp.h>
39
#include <linux/ptp_clock_kernel.h>
40
#include <linux/crash_dump.h>
41
42
43
#include <linux/mlx5/driver.h>
#include <linux/mlx5/qp.h>
#include <linux/mlx5/cq.h>
44
#include <linux/mlx5/port.h>
45
#include <linux/mlx5/vport.h>
46
#include <linux/mlx5/transobj.h>
47
#include <linux/rhashtable.h>
48
#include <net/switchdev.h>
49
50
#include "wq.h"
#include "mlx5_core.h"
51
#include "en_stats.h"
52

53
54
#define MLX5_SET_CFG(p, f, v) MLX5_SET(create_flow_group_in, p, f, v)

55
56
57
58
#define MLX5E_ETH_HARD_MTU (ETH_HLEN + VLAN_HLEN + ETH_FCS_LEN)

#define MLX5E_HW2SW_MTU(priv, hwmtu) ((hwmtu) - ((priv)->hard_mtu))
#define MLX5E_SW2HW_MTU(priv, swmtu) ((swmtu) + ((priv)->hard_mtu))
59

60
61
#define MLX5E_MAX_NUM_TC	8

62
#define MLX5E_PARAMS_MINIMUM_LOG_SQ_SIZE                0x6
63
64
65
#define MLX5E_PARAMS_DEFAULT_LOG_SQ_SIZE                0xa
#define MLX5E_PARAMS_MAXIMUM_LOG_SQ_SIZE                0xd

66
#define MLX5E_PARAMS_MINIMUM_LOG_RQ_SIZE                0x1
67
68
69
#define MLX5E_PARAMS_DEFAULT_LOG_RQ_SIZE                0xa
#define MLX5E_PARAMS_MAXIMUM_LOG_RQ_SIZE                0xd

70
#define MLX5E_PARAMS_MINIMUM_LOG_RQ_SIZE_MPW            0x2
71
#define MLX5E_PARAMS_DEFAULT_LOG_RQ_SIZE_MPW            0x3
72
73
#define MLX5E_PARAMS_MAXIMUM_LOG_RQ_SIZE_MPW            0x6

74
#define MLX5_RX_HEADROOM NET_SKB_PAD
75
76
#define MLX5_SKB_FRAG_SZ(len)	(SKB_DATA_ALIGN(len) +	\
				 SKB_DATA_ALIGN(sizeof(struct skb_shared_info)))
77

78
79
80
81
82
83
84
#define MLX5_MPWRQ_MIN_LOG_STRIDE_SZ(mdev) \
	(6 + MLX5_CAP_GEN(mdev, cache_line_128byte)) /* HW restriction */
#define MLX5_MPWRQ_LOG_STRIDE_SZ(mdev, req) \
	max_t(u32, MLX5_MPWRQ_MIN_LOG_STRIDE_SZ(mdev), req)
#define MLX5_MPWRQ_DEF_LOG_STRIDE_SZ(mdev)       MLX5_MPWRQ_LOG_STRIDE_SZ(mdev, 6)
#define MLX5_MPWRQ_CQE_CMPRS_LOG_STRIDE_SZ(mdev) MLX5_MPWRQ_LOG_STRIDE_SZ(mdev, 8)

85
#define MLX5_MPWRQ_LOG_WQE_SZ			18
86
87
88
89
90
#define MLX5_MPWRQ_WQE_PAGE_ORDER  (MLX5_MPWRQ_LOG_WQE_SZ - PAGE_SHIFT > 0 ? \
				    MLX5_MPWRQ_LOG_WQE_SZ - PAGE_SHIFT : 0)
#define MLX5_MPWRQ_PAGES_PER_WQE		BIT(MLX5_MPWRQ_WQE_PAGE_ORDER)
#define MLX5_MPWRQ_STRIDES_PER_PAGE		(MLX5_MPWRQ_NUM_STRIDES >> \
						 MLX5_MPWRQ_WQE_PAGE_ORDER)
91
92

#define MLX5_MTT_OCTW(npages) (ALIGN(npages, 8) / 2)
93
94
95
#define MLX5E_REQUIRED_MTTS(wqes)		\
	(wqes * ALIGN(MLX5_MPWRQ_PAGES_PER_WQE, 8))
#define MLX5E_VALID_NUM_MTTS(num_mtts) (MLX5_MTT_OCTW(num_mtts) - 1 <= U16_MAX)
96

97
#define MLX5_UMR_ALIGN				(2048)
98
#define MLX5_MPWRQ_SMALL_PACKET_THRESHOLD	(256)
99

100
#define MLX5E_PARAMS_DEFAULT_LRO_WQE_SZ                 (64 * 1024)
101
102
103
#define MLX5E_DEFAULT_LRO_TIMEOUT                       32
#define MLX5E_LRO_TIMEOUT_ARR_SIZE                      4

104
#define MLX5E_PARAMS_DEFAULT_RX_CQ_MODERATION_USEC      0x10
Tariq Toukan's avatar
Tariq Toukan committed
105
#define MLX5E_PARAMS_DEFAULT_RX_CQ_MODERATION_USEC_FROM_CQE 0x3
106
107
108
109
#define MLX5E_PARAMS_DEFAULT_RX_CQ_MODERATION_PKTS      0x20
#define MLX5E_PARAMS_DEFAULT_TX_CQ_MODERATION_USEC      0x10
#define MLX5E_PARAMS_DEFAULT_TX_CQ_MODERATION_PKTS      0x20
#define MLX5E_PARAMS_DEFAULT_MIN_RX_WQES                0x80
110
#define MLX5E_PARAMS_DEFAULT_MIN_RX_WQES_MPW            0x2
111

112
113
#define MLX5E_LOG_INDIR_RQT_SIZE       0x7
#define MLX5E_INDIR_RQT_SIZE           BIT(MLX5E_LOG_INDIR_RQT_SIZE)
114
#define MLX5E_MIN_NUM_CHANNELS         0x1
115
#define MLX5E_MAX_NUM_CHANNELS         (MLX5E_INDIR_RQT_SIZE >> 1)
116
#define MLX5E_MAX_NUM_SQS              (MLX5E_MAX_NUM_CHANNELS * MLX5E_MAX_NUM_TC)
117
118
119
#define MLX5E_TX_CQ_POLL_BUDGET        128
#define MLX5E_UPDATE_STATS_INTERVAL    200 /* msecs */

120
121
122
#define MLX5E_ICOSQ_MAX_WQEBBS \
	(DIV_ROUND_UP(sizeof(struct mlx5e_umr_wqe), MLX5_SEND_WQE_BB))

123
124
#define MLX5E_XDP_MIN_INLINE (ETH_HLEN + VLAN_HLEN)
#define MLX5E_XDP_TX_DS_COUNT \
125
	((sizeof(struct mlx5e_tx_wqe) / MLX5_SEND_WQE_DS) + 1 /* SG DS */)
126

127
#define MLX5E_NUM_MAIN_GROUPS 9
128

129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
static inline u16 mlx5_min_rx_wqes(int wq_type, u32 wq_size)
{
	switch (wq_type) {
	case MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ:
		return min_t(u16, MLX5E_PARAMS_DEFAULT_MIN_RX_WQES_MPW,
			     wq_size / 2);
	default:
		return min_t(u16, MLX5E_PARAMS_DEFAULT_MIN_RX_WQES,
			     wq_size / 2);
	}
}

static inline int mlx5_min_log_rq_size(int wq_type)
{
	switch (wq_type) {
	case MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ:
		return MLX5E_PARAMS_MINIMUM_LOG_RQ_SIZE_MPW;
	default:
		return MLX5E_PARAMS_MINIMUM_LOG_RQ_SIZE;
	}
}

static inline int mlx5_max_log_rq_size(int wq_type)
{
	switch (wq_type) {
	case MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ:
		return MLX5E_PARAMS_MAXIMUM_LOG_RQ_SIZE_MPW;
	default:
		return MLX5E_PARAMS_MAXIMUM_LOG_RQ_SIZE;
	}
}

161
162
163
164
165
166
167
168
static inline int mlx5e_get_max_num_channels(struct mlx5_core_dev *mdev)
{
	return is_kdump_kernel() ?
		MLX5E_MIN_NUM_CHANNELS :
		min_t(int, mdev->priv.eq_table.num_comp_vectors,
		      MLX5E_MAX_NUM_CHANNELS);
}

169
170
171
172
173
174
175
176
177
struct mlx5e_tx_wqe {
	struct mlx5_wqe_ctrl_seg ctrl;
	struct mlx5_wqe_eth_seg  eth;
};

struct mlx5e_rx_wqe {
	struct mlx5_wqe_srq_next_seg  next;
	struct mlx5_wqe_data_seg      data;
};
178

179
180
181
182
183
184
185
struct mlx5e_umr_wqe {
	struct mlx5_wqe_ctrl_seg       ctrl;
	struct mlx5_wqe_umr_ctrl_seg   uctrl;
	struct mlx5_mkey_seg           mkc;
	struct mlx5_wqe_data_seg       data;
};

186
187
extern const char mlx5e_self_tests[][ETH_GSTRING_LEN];

188
static const char mlx5e_priv_flags[][ETH_GSTRING_LEN] = {
Tariq Toukan's avatar
Tariq Toukan committed
189
	"rx_cqe_moder",
190
	"rx_cqe_compress",
191
192
193
};

enum mlx5e_priv_flag {
Tariq Toukan's avatar
Tariq Toukan committed
194
	MLX5E_PFLAG_RX_CQE_BASED_MODER = (1 << 0),
195
	MLX5E_PFLAG_RX_CQE_COMPRESS = (1 << 1),
196
197
};

198
#define MLX5E_SET_PFLAG(params, pflag, enable)			\
199
200
	do {							\
		if (enable)					\
201
			(params)->pflags |= (pflag);		\
202
		else						\
203
			(params)->pflags &= ~(pflag);		\
204
205
	} while (0)

206
#define MLX5E_GET_PFLAG(params, pflag) (!!((params)->pflags & (pflag)))
207

208
209
210
211
#ifdef CONFIG_MLX5_CORE_EN_DCB
#define MLX5E_MAX_BW_ALLOC 100 /* Max percentage of BW allocation */
#endif

Tariq Toukan's avatar
Tariq Toukan committed
212
213
214
215
216
struct mlx5e_cq_moder {
	u16 usec;
	u16 pkts;
};

217
218
struct mlx5e_params {
	u8  log_sq_size;
219
	u8  rq_wq_type;
220
	u16 rq_headroom;
221
222
	u8  mpwqe_log_stride_sz;
	u8  mpwqe_log_num_strides;
223
224
225
	u8  log_rq_size;
	u16 num_channels;
	u8  num_tc;
Tariq Toukan's avatar
Tariq Toukan committed
226
	u8  rx_cq_period_mode;
227
	bool rx_cqe_compress_def;
Tariq Toukan's avatar
Tariq Toukan committed
228
229
	struct mlx5e_cq_moder rx_cq_moderation;
	struct mlx5e_cq_moder tx_cq_moderation;
230
231
	bool lro_en;
	u32 lro_wqe_sz;
232
	u16 tx_max_inline;
233
	u8  tx_min_inline_mode;
234
235
236
	u8  rss_hfunc;
	u8  toeplitz_hash_key[40];
	u32 indirection_rqt[MLX5E_INDIR_RQT_SIZE];
237
	bool vlan_strip_disable;
238
	bool scatter_fcs_en;
239
	bool rx_am_enabled;
240
	u32 lro_timeout;
241
	u32 pflags;
242
	struct bpf_prog *xdp_prog;
243
244
};

Huy Nguyen's avatar
Huy Nguyen committed
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
#ifdef CONFIG_MLX5_CORE_EN_DCB
struct mlx5e_cee_config {
	/* bw pct for priority group */
	u8                         pg_bw_pct[CEE_DCBX_MAX_PGS];
	u8                         prio_to_pg_map[CEE_DCBX_MAX_PRIO];
	bool                       pfc_setting[CEE_DCBX_MAX_PRIO];
	bool                       pfc_enable;
};

enum {
	MLX5_DCB_CHG_RESET,
	MLX5_DCB_NO_CHG,
	MLX5_DCB_CHG_NO_RESET,
};

struct mlx5e_dcbx {
261
	enum mlx5_dcbx_oper_mode   mode;
Huy Nguyen's avatar
Huy Nguyen committed
262
	struct mlx5e_cee_config    cee_cfg; /* pending configuration */
263
264
265

	/* The only setting that cannot be read from FW */
	u8                         tc_tsa[IEEE_8021QAZ_MAX_TCS];
266
	u8                         cap;
Huy Nguyen's avatar
Huy Nguyen committed
267
268
269
};
#endif

270
271
272
273
274
#define MAX_PIN_NUM	8
struct mlx5e_pps {
	u8                         pin_caps[MAX_PIN_NUM];
	struct work_struct         out_work;
	u64                        start[MAX_PIN_NUM];
275
	u8                         enabled;
276
277
};

278
279
280
281
282
283
284
285
286
struct mlx5e_tstamp {
	rwlock_t                   lock;
	struct cyclecounter        cycles;
	struct timecounter         clock;
	struct hwtstamp_config     hwtstamp_config;
	u32                        nominal_c_mult;
	unsigned long              overflow_period;
	struct delayed_work        overflow_work;
	struct mlx5_core_dev      *mdev;
287
288
	struct ptp_clock          *ptp;
	struct ptp_clock_info      ptp_info;
289
	struct mlx5e_pps           pps_info;
290
291
};

292
enum {
293
	MLX5E_RQ_STATE_ENABLED,
294
	MLX5E_RQ_STATE_AM,
295
296
};

297
298
#define MLX5E_TEST_BIT(state, nr) (state & BIT(nr))

299
300
301
302
303
struct mlx5e_cq {
	/* data path - accessed per cqe */
	struct mlx5_cqwq           wq;

	/* data path - accessed per napi poll */
304
	u16                        event_ctr;
305
306
307
308
	struct napi_struct        *napi;
	struct mlx5_core_cq        mcq;
	struct mlx5e_channel      *channel;

Tariq Toukan's avatar
Tariq Toukan committed
309
310
311
312
313
314
315
	/* cqe decompression */
	struct mlx5_cqe64          title;
	struct mlx5_mini_cqe8      mini_arr[MLX5_MINI_CQE_ARRAY_SIZE];
	u8                         mini_arr_idx;
	u16                        decmprs_left;
	u16                        decmprs_wqe_counter;

316
	/* control */
317
	struct mlx5_core_dev      *mdev;
318
	struct mlx5_frag_wq_ctrl   wq_ctrl;
319
320
} ____cacheline_aligned_in_smp;

321
struct mlx5e_tx_wqe_info {
322
	struct sk_buff *skb;
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
	u32 num_bytes;
	u8  num_wqebbs;
	u8  num_dma;
};

enum mlx5e_dma_map_type {
	MLX5E_DMA_MAP_SINGLE,
	MLX5E_DMA_MAP_PAGE
};

struct mlx5e_sq_dma {
	dma_addr_t              addr;
	u32                     size;
	enum mlx5e_dma_map_type type;
};

enum {
	MLX5E_SQ_STATE_ENABLED,
341
	MLX5E_SQ_STATE_IPSEC,
342
343
344
345
346
};

struct mlx5e_sq_wqe_info {
	u8  opcode;
};
347

Saeed Mahameed's avatar
Saeed Mahameed committed
348
struct mlx5e_txqsq {
349
350
351
352
353
354
355
356
357
358
359
360
361
	/* data path */

	/* dirtied @completion */
	u16                        cc;
	u32                        dma_fifo_cc;

	/* dirtied @xmit */
	u16                        pc ____cacheline_aligned_in_smp;
	u32                        dma_fifo_pc;
	struct mlx5e_sq_stats      stats;

	struct mlx5e_cq            cq;

Saeed Mahameed's avatar
Saeed Mahameed committed
362
363
364
365
	/* write@xmit, read@completion */
	struct {
		struct mlx5e_sq_dma       *dma_fifo;
		struct mlx5e_tx_wqe_info  *wqe_info;
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
	} db;

	/* read only */
	struct mlx5_wq_cyc         wq;
	u32                        dma_fifo_mask;
	void __iomem              *uar_map;
	struct netdev_queue       *txq;
	u32                        sqn;
	u16                        max_inline;
	u8                         min_inline_mode;
	u16                        edge;
	struct device             *pdev;
	struct mlx5e_tstamp       *tstamp;
	__be32                     mkey_be;
	unsigned long              state;

	/* control path */
	struct mlx5_wq_ctrl        wq_ctrl;
	struct mlx5e_channel      *channel;
385
	int                        txq_ix;
386
	u32                        rate_limit;
Saeed Mahameed's avatar
Saeed Mahameed committed
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
} ____cacheline_aligned_in_smp;

struct mlx5e_xdpsq {
	/* data path */

	/* dirtied @rx completion */
	u16                        cc;
	u16                        pc;

	struct mlx5e_cq            cq;

	/* write@xmit, read@completion */
	struct {
		struct mlx5e_dma_info     *di;
		bool                       doorbell;
	} db;

	/* read only */
	struct mlx5_wq_cyc         wq;
	void __iomem              *uar_map;
	u32                        sqn;
	struct device             *pdev;
	__be32                     mkey_be;
	u8                         min_inline_mode;
	unsigned long              state;

	/* control path */
	struct mlx5_wq_ctrl        wq_ctrl;
	struct mlx5e_channel      *channel;
} ____cacheline_aligned_in_smp;

struct mlx5e_icosq {
	/* data path */

	/* dirtied @xmit */
	u16                        pc ____cacheline_aligned_in_smp;

	struct mlx5e_cq            cq;

	/* write@xmit, read@completion */
	struct {
		struct mlx5e_sq_wqe_info *ico_wqe;
	} db;

	/* read only */
	struct mlx5_wq_cyc         wq;
	void __iomem              *uar_map;
	u32                        sqn;
	u16                        edge;
	__be32                     mkey_be;
	unsigned long              state;

	/* control path */
	struct mlx5_wq_ctrl        wq_ctrl;
	struct mlx5e_channel      *channel;
442
443
} ____cacheline_aligned_in_smp;

444
445
static inline bool
mlx5e_wqc_has_room_for(struct mlx5_wq_cyc *wq, u16 cc, u16 pc, u16 n)
446
{
447
	return (((wq->sz_m1 & (cc - pc)) >= n) || (cc == pc));
448
}
449

450
451
452
453
454
struct mlx5e_dma_info {
	struct page	*page;
	dma_addr_t	addr;
};

455
456
457
458
459
struct mlx5e_wqe_frag_info {
	struct mlx5e_dma_info di;
	u32 offset;
};

460
461
462
463
464
465
466
467
468
469
470
471
472
struct mlx5e_umr_dma_info {
	__be64                *mtt;
	dma_addr_t             mtt_addr;
	struct mlx5e_dma_info  dma_info[MLX5_MPWRQ_PAGES_PER_WQE];
	struct mlx5e_umr_wqe   wqe;
};

struct mlx5e_mpw_info {
	struct mlx5e_umr_dma_info umr;
	u16 consumed_strides;
	u16 skbs_frags[MLX5_MPWRQ_PAGES_PER_WQE];
};

473
474
struct mlx5e_rx_am_stats {
	int ppms; /* packets per msec */
475
	int bpms; /* bytes per msec */
476
477
478
479
	int epms; /* events per msec */
};

struct mlx5e_rx_am_sample {
480
481
482
483
	ktime_t	time;
	u32	pkt_ctr;
	u32	byte_ctr;
	u16	event_ctr;
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
};

struct mlx5e_rx_am { /* Adaptive Moderation */
	u8					state;
	struct mlx5e_rx_am_stats		prev_stats;
	struct mlx5e_rx_am_sample		start_sample;
	struct work_struct			work;
	u8					profile_ix;
	u8					mode;
	u8					tune_state;
	u8					steps_right;
	u8					steps_left;
	u8					tired;
};

499
500
501
502
503
/* a single cache unit is capable to serve one napi call (for non-striding rq)
 * or a MPWQE (for striding rq).
 */
#define MLX5E_CACHE_UNIT	(MLX5_MPWRQ_PAGES_PER_WQE > NAPI_POLL_WEIGHT ? \
				 MLX5_MPWRQ_PAGES_PER_WQE : NAPI_POLL_WEIGHT)
504
#define MLX5E_CACHE_SIZE	(4 * roundup_pow_of_two(MLX5E_CACHE_UNIT))
505
506
507
508
509
510
struct mlx5e_page_cache {
	u32 head;
	u32 tail;
	struct mlx5e_dma_info page_cache[MLX5E_CACHE_SIZE];
};

511
512
struct mlx5e_rq;
typedef void (*mlx5e_fp_handle_rx_cqe)(struct mlx5e_rq*, struct mlx5_cqe64*);
513
typedef bool (*mlx5e_fp_post_rx_wqes)(struct mlx5e_rq *rq);
514
515
typedef void (*mlx5e_fp_dealloc_wqe)(struct mlx5e_rq*, u16);

516
517
518
struct mlx5e_rq {
	/* data path */
	struct mlx5_wq_ll      wq;
519

520
	union {
521
522
523
		struct {
			struct mlx5e_wqe_frag_info *frag_info;
			u32 frag_sz;	/* max possible skb frag_sz */
524
525
526
527
			union {
				bool page_reuse;
				bool xdp_xmit;
			};
528
		} wqe;
529
530
531
		struct {
			struct mlx5e_mpw_info *info;
			void                  *mtt_no_align;
532
			u16                    num_strides;
533
			u8                     log_stride_sz;
534
			bool                   umr_in_progress;
535
536
		} mpwqe;
	};
537
	struct {
538
		u16            headroom;
539
		u8             page_order;
540
		u8             map_dir;   /* dma map direction */
541
	} buff;
542

543
	struct mlx5e_channel  *channel;
544
545
	struct device         *pdev;
	struct net_device     *netdev;
546
	struct mlx5e_tstamp   *tstamp;
547
548
	struct mlx5e_rq_stats  stats;
	struct mlx5e_cq        cq;
549
550
	struct mlx5e_page_cache page_cache;

551
	mlx5e_fp_handle_rx_cqe handle_rx_cqe;
552
	mlx5e_fp_post_rx_wqes  post_wqes;
553
	mlx5e_fp_dealloc_wqe   dealloc_wqe;
554
555
556
557

	unsigned long          state;
	int                    ix;

558
	struct mlx5e_rx_am     am; /* Adaptive Moderation */
559
560

	/* XDP */
561
	struct bpf_prog       *xdp_prog;
Saeed Mahameed's avatar
Saeed Mahameed committed
562
	struct mlx5e_xdpsq     xdpsq;
563

564
565
	/* control */
	struct mlx5_wq_ctrl    wq_ctrl;
566
	__be32                 mkey_be;
567
	u8                     wq_type;
568
	u32                    rqn;
569
	struct mlx5_core_dev  *mdev;
570
	struct mlx5_core_mkey  umr_mkey;
571
572
573
574
575
} ____cacheline_aligned_in_smp;

struct mlx5e_channel {
	/* data path */
	struct mlx5e_rq            rq;
Saeed Mahameed's avatar
Saeed Mahameed committed
576
577
	struct mlx5e_txqsq         sq[MLX5E_MAX_NUM_TC];
	struct mlx5e_icosq         icosq;   /* internal control operations */
578
	bool                       xdp;
579
580
581
582
583
584
	struct napi_struct         napi;
	struct device             *pdev;
	struct net_device         *netdev;
	__be32                     mkey_be;
	u8                         num_tc;

585
586
	/* data path - accessed per napi poll */
	struct irq_desc *irq_desc;
587
588
589

	/* control */
	struct mlx5e_priv         *priv;
590
591
	struct mlx5_core_dev      *mdev;
	struct mlx5e_tstamp       *tstamp;
592
593
594
	int                        ix;
};

595
596
597
struct mlx5e_channels {
	struct mlx5e_channel **c;
	unsigned int           num;
598
	struct mlx5e_params    params;
599
600
};

601
enum mlx5e_traffic_types {
602
603
604
605
	MLX5E_TT_IPV4_TCP,
	MLX5E_TT_IPV6_TCP,
	MLX5E_TT_IPV4_UDP,
	MLX5E_TT_IPV6_UDP,
606
607
608
609
	MLX5E_TT_IPV4_IPSEC_AH,
	MLX5E_TT_IPV6_IPSEC_AH,
	MLX5E_TT_IPV4_IPSEC_ESP,
	MLX5E_TT_IPV6_IPSEC_ESP,
610
611
612
613
	MLX5E_TT_IPV4,
	MLX5E_TT_IPV6,
	MLX5E_TT_ANY,
	MLX5E_NUM_TT,
Tariq Toukan's avatar
Tariq Toukan committed
614
	MLX5E_NUM_INDIR_TIRS = MLX5E_TT_ANY,
615
616
};

617
618
619
620
621
622
enum mlx5e_tunnel_types {
	MLX5E_TT_IPV4_GRE,
	MLX5E_TT_IPV6_GRE,
	MLX5E_NUM_TUNNEL_TT,
};

623
enum {
624
	MLX5E_STATE_ASYNC_EVENTS_ENABLED,
625
626
627
628
629
630
631
632
633
	MLX5E_STATE_OPENED,
	MLX5E_STATE_DESTROYING,
};

struct mlx5e_vxlan_db {
	spinlock_t			lock; /* protect vxlan table */
	struct radix_tree_root		tree;
};

634
struct mlx5e_l2_rule {
635
	u8  addr[ETH_ALEN + 2];
Mark Bloch's avatar
Mark Bloch committed
636
	struct mlx5_flow_handle *rule;
637
638
};

639
640
641
642
643
644
struct mlx5e_flow_table {
	int num_groups;
	struct mlx5_flow_table *t;
	struct mlx5_flow_group **g;
};

645
#define MLX5E_L2_ADDR_HASH_SIZE BIT(BITS_PER_BYTE)
646

647
648
649
650
651
struct mlx5e_tc_table {
	struct mlx5_flow_table		*t;

	struct rhashtable_params        ht_params;
	struct rhashtable               ht;
652
653

	DECLARE_HASHTABLE(mod_hdr_tbl, 8);
654
655
};

656
657
struct mlx5e_vlan_table {
	struct mlx5e_flow_table		ft;
658
	unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
Mark Bloch's avatar
Mark Bloch committed
659
660
	struct mlx5_flow_handle	*active_vlans_rule[VLAN_N_VID];
	struct mlx5_flow_handle	*untagged_rule;
661
662
663
	struct mlx5_flow_handle	*any_cvlan_rule;
	struct mlx5_flow_handle	*any_svlan_rule;
	bool			filter_disabled;
664
665
};

666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
struct mlx5e_l2_table {
	struct mlx5e_flow_table    ft;
	struct hlist_head          netdev_uc[MLX5E_L2_ADDR_HASH_SIZE];
	struct hlist_head          netdev_mc[MLX5E_L2_ADDR_HASH_SIZE];
	struct mlx5e_l2_rule	   broadcast;
	struct mlx5e_l2_rule	   allmulti;
	struct mlx5e_l2_rule	   promisc;
	bool                       broadcast_enabled;
	bool                       allmulti_enabled;
	bool                       promisc_enabled;
};

/* L3/L4 traffic type classifier */
struct mlx5e_ttc_table {
	struct mlx5e_flow_table  ft;
Mark Bloch's avatar
Mark Bloch committed
681
	struct mlx5_flow_handle	 *rules[MLX5E_NUM_TT];
682
	struct mlx5_flow_handle  *tunnel_rules[MLX5E_NUM_TUNNEL_TT];
683
684
};

685
686
#define ARFS_HASH_SHIFT BITS_PER_BYTE
#define ARFS_HASH_SIZE BIT(BITS_PER_BYTE)
687
688
struct arfs_table {
	struct mlx5e_flow_table  ft;
Mark Bloch's avatar
Mark Bloch committed
689
	struct mlx5_flow_handle	 *default_rule;
690
	struct hlist_head	 rules_hash[ARFS_HASH_SIZE];
691
692
693
694
695
696
697
698
699
700
701
702
};

enum  arfs_type {
	ARFS_IPV4_TCP,
	ARFS_IPV6_TCP,
	ARFS_IPV4_UDP,
	ARFS_IPV6_UDP,
	ARFS_NUM_TYPES,
};

struct mlx5e_arfs_tables {
	struct arfs_table arfs_tables[ARFS_NUM_TYPES];
703
704
705
706
707
	/* Protect aRFS rules list */
	spinlock_t                     arfs_lock;
	struct list_head               rules;
	int                            last_filter_id;
	struct workqueue_struct        *wq;
708
709
710
711
712
713
714
};

/* NIC prio FTS */
enum {
	MLX5E_VLAN_FT_LEVEL = 0,
	MLX5E_L2_FT_LEVEL,
	MLX5E_TTC_FT_LEVEL,
715
	MLX5E_INNER_TTC_FT_LEVEL,
716
717
718
	MLX5E_ARFS_FT_LEVEL
};

719
720
721
722
723
struct mlx5e_ethtool_table {
	struct mlx5_flow_table *ft;
	int                    num_rules;
};

724
#define ETHTOOL_NUM_L3_L4_FTS 7
725
726
727
#define ETHTOOL_NUM_L2_FTS 4

struct mlx5e_ethtool_steering {
728
	struct mlx5e_ethtool_table      l3_l4_ft[ETHTOOL_NUM_L3_L4_FTS];
729
730
731
732
733
	struct mlx5e_ethtool_table      l2_ft[ETHTOOL_NUM_L2_FTS];
	struct list_head                rules;
	int                             tot_num_rules;
};

734
735
struct mlx5e_flow_steering {
	struct mlx5_flow_namespace      *ns;
736
	struct mlx5e_ethtool_steering   ethtool;
737
738
	struct mlx5e_tc_table           tc;
	struct mlx5e_vlan_table         vlan;
739
740
	struct mlx5e_l2_table           l2;
	struct mlx5e_ttc_table          ttc;
741
	struct mlx5e_ttc_table          inner_ttc;
742
	struct mlx5e_arfs_tables        arfs;
743
744
};

745
struct mlx5e_rqt {
Tariq Toukan's avatar
Tariq Toukan committed
746
	u32              rqtn;
747
748
749
750
751
752
753
	bool		 enabled;
};

struct mlx5e_tir {
	u32		  tirn;
	struct mlx5e_rqt  rqt;
	struct list_head  list;
Tariq Toukan's avatar
Tariq Toukan committed
754
755
};

756
757
758
759
760
enum {
	MLX5E_TC_PRIO = 0,
	MLX5E_NIC_PRIO
};

761
762
struct mlx5e_priv {
	/* priv data path fields - start */
763
764
	struct mlx5e_txqsq *txq2sq[MLX5E_MAX_NUM_CHANNELS * MLX5E_MAX_NUM_TC];
	int channel_tc2txq[MLX5E_MAX_NUM_CHANNELS][MLX5E_MAX_NUM_TC];
765
766
767
768
	/* priv data path fields - end */

	unsigned long              state;
	struct mutex               state_lock; /* Protects Interface state */
769
	struct mlx5e_rq            drop_rq;
770

771
	struct mlx5e_channels      channels;
772
	u32                        tisn[MLX5E_MAX_NUM_TC];
773
	struct mlx5e_rqt           indir_rqt;
774
	struct mlx5e_tir           indir_tir[MLX5E_NUM_INDIR_TIRS];
775
	struct mlx5e_tir           inner_indir_tir[MLX5E_NUM_INDIR_TIRS];
776
	struct mlx5e_tir           direct_tir[MLX5E_MAX_NUM_CHANNELS];
777
	u32                        tx_rates[MLX5E_MAX_NUM_SQS];
778
	int                        hard_mtu;
779

780
	struct mlx5e_flow_steering fs;
781
	struct mlx5e_vxlan_db      vxlan;
782

783
	struct workqueue_struct    *wq;
784
785
	struct work_struct         update_carrier_work;
	struct work_struct         set_rx_mode_work;
786
	struct work_struct         tx_timeout_work;
787
788
789
790
791
	struct delayed_work        update_stats_work;

	struct mlx5_core_dev      *mdev;
	struct net_device         *netdev;
	struct mlx5e_stats         stats;
792
	struct mlx5e_tstamp        tstamp;
793
	u16 q_counter;
Huy Nguyen's avatar
Huy Nguyen committed
794
795
796
797
#ifdef CONFIG_MLX5_CORE_EN_DCB
	struct mlx5e_dcbx          dcbx;
#endif

798
	const struct mlx5e_profile *profile;
799
	void                      *ppriv;
800
801
802
#ifdef CONFIG_MLX5_EN_IPSEC
	struct mlx5e_ipsec        *ipsec;
#endif
803
804
};

805
806
807
808
809
810
811
812
813
814
815
816
struct mlx5e_profile {
	void	(*init)(struct mlx5_core_dev *mdev,
			struct net_device *netdev,
			const struct mlx5e_profile *profile, void *ppriv);
	void	(*cleanup)(struct mlx5e_priv *priv);
	int	(*init_rx)(struct mlx5e_priv *priv);
	void	(*cleanup_rx)(struct mlx5e_priv *priv);
	int	(*init_tx)(struct mlx5e_priv *priv);
	void	(*cleanup_tx)(struct mlx5e_priv *priv);
	void	(*enable)(struct mlx5e_priv *priv);
	void	(*disable)(struct mlx5e_priv *priv);
	void	(*update_stats)(struct mlx5e_priv *priv);
817
	void	(*update_carrier)(struct mlx5e_priv *priv);
818
	int	(*max_nch)(struct mlx5_core_dev *mdev);
819
820
821
822
	struct {
		mlx5e_fp_handle_rx_cqe handle_rx_cqe;
		mlx5e_fp_handle_rx_cqe handle_rx_cqe_mpwqe;
	} rx_handlers;
823
824
825
	int	max_tc;
};

826
827
void mlx5e_build_ptys2ethtool_map(void);

828
829
830
831
832
833
834
u16 mlx5e_select_queue(struct net_device *dev, struct sk_buff *skb,
		       void *accel_priv, select_queue_fallback_t fallback);
netdev_tx_t mlx5e_xmit(struct sk_buff *skb, struct net_device *dev);

void mlx5e_completion_event(struct mlx5_core_cq *mcq);
void mlx5e_cq_error_event(struct mlx5_core_cq *mcq, enum mlx5_event event);
int mlx5e_napi_poll(struct napi_struct *napi, int budget);
835
bool mlx5e_poll_tx_cq(struct mlx5e_cq *cq, int napi_budget);
836
int mlx5e_poll_rx_cq(struct mlx5e_cq *cq, int budget);
837
bool mlx5e_poll_xdpsq_cq(struct mlx5e_cq *cq);
Saeed Mahameed's avatar
Saeed Mahameed committed
838
839
void mlx5e_free_txqsq_descs(struct mlx5e_txqsq *sq);
void mlx5e_free_xdpsq_descs(struct mlx5e_xdpsq *sq);
840

841
842
void mlx5e_page_release(struct mlx5e_rq *rq, struct mlx5e_dma_info *dma_info,
			bool recycle);
843
void mlx5e_handle_rx_cqe(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe);
844
void mlx5e_handle_rx_cqe_mpwrq(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe);
845
bool mlx5e_post_rx_wqes(struct mlx5e_rq *rq);
846
bool mlx5e_post_rx_mpwqes(struct mlx5e_rq *rq);
847
848
void mlx5e_dealloc_rx_wqe(struct mlx5e_rq *rq, u16 ix);
void mlx5e_dealloc_rx_mpwqe(struct mlx5e_rq *rq, u16 ix);
849
void mlx5e_free_rx_mpwqe(struct mlx5e_rq *rq, struct mlx5e_mpw_info *wi);
850

851
852
853
854
void mlx5e_rx_am(struct mlx5e_rq *rq);
void mlx5e_rx_am_work(struct work_struct *work);
struct mlx5e_cq_moder mlx5e_am_get_def_profile(u8 rx_cq_period_mode);

855
void mlx5e_update_stats(struct mlx5e_priv *priv, bool full);
856

857
858
int mlx5e_create_flow_steering(struct mlx5e_priv *priv);
void mlx5e_destroy_flow_steering(struct mlx5e_priv *priv);
859
void mlx5e_init_l2_addr(struct mlx5e_priv *priv);
860
void mlx5e_destroy_flow_table(struct mlx5e_flow_table *ft);
861
862
863
int mlx5e_self_test_num(struct mlx5e_priv *priv);
void mlx5e_self_test(struct net_device *ndev, struct ethtool_test *etest,
		     u64 *buf);
864
865
866
867
int mlx5e_ethtool_get_flow(struct mlx5e_priv *priv, struct ethtool_rxnfc *info,
			   int location);
int mlx5e_ethtool_get_all_flows(struct mlx5e_priv *priv,
				struct ethtool_rxnfc *info, u32 *rule_locs);
868
869
870
871
872
873
int mlx5e_ethtool_flow_replace(struct mlx5e_priv *priv,
			       struct ethtool_rx_flow_spec *fs);
int mlx5e_ethtool_flow_remove(struct mlx5e_priv *priv,
			      int location);
void mlx5e_ethtool_init_steering(struct mlx5e_priv *priv);
void mlx5e_ethtool_cleanup_steering(struct mlx5e_priv *priv);
874
875
void mlx5e_set_rx_mode_work(struct work_struct *work);

876
877
878
879
void mlx5e_fill_hwstamp(struct mlx5e_tstamp *clock, u64 timestamp,
			struct skb_shared_hwtstamps *hwts);
void mlx5e_timestamp_init(struct mlx5e_priv *priv);
void mlx5e_timestamp_cleanup(struct mlx5e_priv *priv);
880
881
void mlx5e_pps_event_handler(struct mlx5e_priv *priv,
			     struct ptp_clock_event *event);
882
883
int mlx5e_hwstamp_set(struct mlx5e_priv *priv, struct ifreq *ifr);
int mlx5e_hwstamp_get(struct mlx5e_priv *priv, struct ifreq *ifr);
884
int mlx5e_modify_rx_cqe_compression_locked(struct mlx5e_priv *priv, bool val);
885

886
887
888
889
890
891
892
int mlx5e_vlan_rx_add_vid(struct net_device *dev, __always_unused __be16 proto,
			  u16 vid);
int mlx5e_vlan_rx_kill_vid(struct net_device *dev, __always_unused __be16 proto,
			   u16 vid);
void mlx5e_enable_vlan_filter(struct mlx5e_priv *priv);
void mlx5e_disable_vlan_filter(struct mlx5e_priv *priv);

893
894
895
896
897
898
899
900
901
902
903
904
905
struct mlx5e_redirect_rqt_param {
	bool is_rss;
	union {
		u32 rqn; /* Direct RQN (Non-RSS) */
		struct {
			u8 hfunc;
			struct mlx5e_channels *channels;
		} rss; /* RSS data */
	};
};

int mlx5e_redirect_rqt(struct mlx5e_priv *priv, u32 rqtn, int sz,
		       struct mlx5e_redirect_rqt_param rrp);
906
907
void mlx5e_build_indir_tir_ctx_hash(struct mlx5e_params *params,
				    enum mlx5e_traffic_types tt,
908
				    void *tirc, bool inner);
909

910
911
int mlx5e_open_locked(struct net_device *netdev);
int mlx5e_close_locked(struct net_device *netdev);
912
913
914
915

int mlx5e_open_channels(struct mlx5e_priv *priv,
			struct mlx5e_channels *chs);
void mlx5e_close_channels(struct mlx5e_channels *chs);
916
917
918
919
920

/* Function pointer to be used to modify WH settings while
 * switching channels
 */
typedef int (*mlx5e_fp_hw_modify)(struct mlx5e_priv *priv);
921
void mlx5e_switch_priv_channels(struct mlx5e_priv *priv,
922
923
				struct mlx5e_channels *new_chs,
				mlx5e_fp_hw_modify hw_modify);
924
925
void mlx5e_activate_priv_channels(struct mlx5e_priv *priv);
void mlx5e_deactivate_priv_channels(struct mlx5e_priv *priv);
926

927
void mlx5e_build_default_indir_rqt(u32 *indirection_rqt, int len,
928
				   int num_channels);
929
int mlx5e_get_max_linkspeed(struct mlx5_core_dev *mdev, u32 *speed);
930

Tariq Toukan's avatar
Tariq Toukan committed
931
932
void mlx5e_set_rx_cq_mode_params(struct mlx5e_params *params,
				 u8 cq_period_mode);
933
934
void mlx5e_set_rq_type_params(struct mlx5_core_dev *mdev,
			      struct mlx5e_params *params, u8 rq_type);
Tariq Toukan's avatar
Tariq Toukan committed
935

936
937
938
939
940
941
static inline bool mlx5e_tunnel_inner_ft_supported(struct mlx5_core_dev *mdev)
{
	return (MLX5_CAP_ETH(mdev, tunnel_stateless_gre) &&
		MLX5_CAP_FLOWTABLE_NIC_RX(mdev, ft_field_support.inner_ip_version));
}

942
943
static inline
struct mlx5e_tx_wqe *mlx5e_post_nop(struct mlx5_wq_cyc *wq, u32 sqn, u16 *pc)
944
{
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
	u16                         pi   = *pc & wq->sz_m1;
	struct mlx5e_tx_wqe        *wqe  = mlx5_wq_cyc_get_wqe(wq, pi);
	struct mlx5_wqe_ctrl_seg   *cseg = &wqe->ctrl;

	memset(cseg, 0, sizeof(*cseg));

	cseg->opmod_idx_opcode = cpu_to_be32((*pc << 8) | MLX5_OPCODE_NOP);
	cseg->qpn_ds           = cpu_to_be32((sqn << 8) | 0x01);

	(*pc)++;

	return wqe;
}

static inline
void mlx5e_notify_hw(struct mlx5_wq_cyc *wq, u16 pc,
		     void __iomem *uar_map,
		     struct mlx5_wqe_ctrl_seg *ctrl)
{
	ctrl->fm_ce_se = MLX5_WQE_CTRL_CQ_UPDATE;
965
966
967
	/* ensure wqe is visible to device before updating doorbell record */
	dma_wmb();

968
	*wq->db = cpu_to_be32(pc);
969
970
971
972
973
974

	/* ensure doorbell record is visible to device before ringing the
	 * doorbell
	 */
	wmb();

975
	mlx5_write64((__be32 *)ctrl, uar_map, NULL);
976
977
978
979
980
981
982
}

static inline void mlx5e_cq_arm(struct mlx5e_cq *cq)
{
	struct mlx5_core_cq *mcq;

	mcq = &cq->mcq;
983
	mlx5_cq_arm(mcq, MLX5_CQ_DB_REQ_NOT, mcq->uar->map, cq->wq.cc);
984
985
}

986
987
static inline u32 mlx5e_get_wqe_mtt_offset(struct mlx5e_rq *rq, u16 wqe_ix)
{
988
	return wqe_ix * ALIGN(MLX5_MPWRQ_PAGES_PER_WQE, 8);
989
990
}

991
extern const struct ethtool_ops mlx5e_ethtool_ops;
992
993
994
#ifdef CONFIG_MLX5_CORE_EN_DCB
extern const struct dcbnl_rtnl_ops mlx5e_dcbnl_ops;
int mlx5e_dcbnl_ieee_setets_core(struct mlx5e_priv *priv, struct ieee_ets *ets);
995
void mlx5e_dcbnl_initialize(struct mlx5e_priv *priv);
996
997
#endif

998
999
1000
1001
1002
1003
1004
#ifndef CONFIG_RFS_ACCEL
static inline int mlx5e_arfs_create_tables(struct mlx5e_priv *priv)
{
	return 0;
}

static inline void mlx5e_arfs_destroy_tables(struct mlx5e_priv *priv) {}
1005
1006
1007

static inline int mlx5e_arfs_enable(struct mlx5e_priv *priv)
{
1008
	return -EOPNOTSUPP;
1009
1010
1011
1012
}

static inline int mlx5e_arfs_disable(struct mlx5e_priv *priv)
{
1013
	return -EOPNOTSUPP;
1014
}
1015
1016
1017
#else
int mlx5e_arfs_create_tables(struct mlx5e_priv *priv);
void mlx5e_arfs_destroy_tables(struct mlx5e_priv *priv);
1018
1019
int mlx5e_arfs_enable(struct mlx5e_priv *priv);
int mlx5e_arfs_disable(struct mlx5e_priv *priv);
1020
1021
int mlx5e_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb,
			u16 rxq_index, u32 flow_id);
1022
1023
#endif

1024
u16 mlx5e_get_max_inline_cap(struct mlx5_core_dev *mdev);
1025
1026
1027
1028
int mlx5e_create_tir(struct mlx5_core_dev *mdev,
		     struct mlx5e_tir *tir, u32 *in, int inlen);
void mlx5e_destroy_tir(struct mlx5_core_dev *mdev,
		       struct mlx5e_tir *tir);
1029
1030
int mlx5e_create_mdev_resources(struct mlx5_core_dev *mdev);
void mlx5e_destroy_mdev_resources(struct mlx5_core_dev *mdev);
1031
int mlx5e_refresh_tirs(struct mlx5e_priv *priv, bool enable_uc_lb);
1032

1033
/* common netdev helpers */
1034
1035
1036
1037
1038
int mlx5e_create_indirect_rqt(struct mlx5e_priv *priv);

int mlx5e_create_indirect_tirs(struct mlx5e_priv *priv);
void mlx5e_destroy_indirect_tirs(struct mlx5e_priv *priv);

1039
int mlx5e_create_direct_rqts(struct mlx5e_priv *priv);
1040
void mlx5e_destroy_direct_rqts(struct mlx5e_priv *priv);
1041
1042
int mlx5e_create_direct_tirs(struct mlx5e_priv *priv);
void mlx5e_destroy_direct_tirs(struct mlx5e_priv *priv);
1043
1044
void mlx5e_destroy_rqt(struct mlx5e_priv *priv, struct mlx5e_rqt *rqt);

1045
int mlx5e_create_ttc_table(struct mlx5e_priv *priv);
1046
1047
void mlx5e_destroy_ttc_table(struct mlx5e_priv *priv);

1048
1049
1050
1051
int mlx5e_create_tis(struct mlx5_core_dev *mdev, int tc,
		     u32 underlay_qpn, u32 *tisn);
void mlx5e_destroy_tis(struct mlx5_core_dev *mdev, u32 tisn);

1052
1053
1054
1055
1056
int mlx5e_create_tises(struct mlx5e_priv *priv);
void mlx5e_cleanup_nic_tx(struct mlx5e_priv *priv);
int mlx5e_close(struct net_device *netdev);
int mlx5e_open(struct net_device *netdev);
void mlx5e_update_stats_work(struct work_struct *work);
1057
u32 mlx5e_choose_lro_timeout(struct mlx5_core_dev *mdev, u32 wanted_timeout);
1058

1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
/* ethtool helpers */
void mlx5e_ethtool_get_drvinfo(struct mlx5e_priv *priv,
			       struct ethtool_drvinfo *drvinfo);
void mlx5e_ethtool_get_strings(struct mlx5e_priv *priv,
			       uint32_t stringset, uint8_t *data);
int mlx5e_ethtool_get_sset_count(struct mlx5e_priv *priv, int sset);
void mlx5e_ethtool_get_ethtool_stats(struct mlx5e_priv *priv,
				     struct ethtool_stats *stats, u64 *data);
void mlx5e_ethtool_get_ringparam(struct mlx5e_priv *priv,
				 struct ethtool_ringparam *param);
int mlx5e_ethtool_set_ringparam(struct mlx5e_priv *priv,
				struct ethtool_ringparam *param);
void mlx5e_ethtool_get_channels(struct mlx5e_priv *priv,
				struct ethtool_channels *ch);
int mlx5e_ethtool_set_channels(struct mlx5e_priv *priv,
			       struct ethtool_channels *ch);
int mlx5e_ethtool_get_coalesce(struct mlx5e_priv *priv,
			       struct ethtool_coalesce *coal);
int mlx5e_ethtool_set_coalesce(struct mlx5e_priv *priv,
			       struct ethtool_coalesce *coal);
1079
1080
int mlx5e_ethtool_get_ts_info(struct mlx5e_priv *priv,
			      struct ethtool_ts_info *info);
1081
1082
int mlx5e_ethtool_flash_device(struct mlx5e_priv *priv,
			       struct ethtool_flash *flash);
1083

1084
1085
1086
1087
1088
1089
1090
/* mlx5e generic netdev management API */
struct net_device*
mlx5e_create_netdev(struct mlx5_core_dev *mdev, const struct mlx5e_profile *profile,
		    void *ppriv);
int mlx5e_attach_netdev(struct mlx5e_priv *priv);
void mlx5e_detach_netdev(struct mlx5e_priv *priv);
void mlx5e_destroy_netdev(struct mlx5e_priv *priv);
1091
1092
1093
void mlx5e_build_nic_params(struct mlx5_core_dev *mdev,
			    struct mlx5e_params *params,
			    u16 max_channels);
1094

1095
#endif /* __MLX5_EN_H__ */