]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - drivers/net/ethernet/mellanox/mlx5/core/en.h
net/mlx5e: IPoIB, Add PTP support to IPoIB device driver
[mirror_ubuntu-artful-kernel.git] / drivers / net / ethernet / mellanox / mlx5 / core / en.h
CommitLineData
f62b8bb8 1/*
1afff42c 2 * Copyright (c) 2015-2016, Mellanox Technologies. All rights reserved.
f62b8bb8
AV
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 */
1afff42c
MF
32#ifndef __MLX5_EN_H__
33#define __MLX5_EN_H__
f62b8bb8
AV
34
35#include <linux/if_vlan.h>
36#include <linux/etherdevice.h>
ef9814de
EBE
37#include <linux/timecounter.h>
38#include <linux/net_tstamp.h>
3d8c38af 39#include <linux/ptp_clock_kernel.h>
48935bbb 40#include <linux/crash_dump.h>
f62b8bb8
AV
41#include <linux/mlx5/driver.h>
42#include <linux/mlx5/qp.h>
43#include <linux/mlx5/cq.h>
ada68c31 44#include <linux/mlx5/port.h>
d18a9470 45#include <linux/mlx5/vport.h>
8d7f9ecb 46#include <linux/mlx5/transobj.h>
e8f887ac 47#include <linux/rhashtable.h>
cb67b832 48#include <net/switchdev.h>
f62b8bb8 49#include "wq.h"
f62b8bb8 50#include "mlx5_core.h"
9218b44d 51#include "en_stats.h"
f62b8bb8 52
1cabe6b0
MG
53#define MLX5_SET_CFG(p, f, v) MLX5_SET(create_flow_group_in, p, f, v)
54
c139dbfd
ES
55#define MLX5E_ETH_HARD_MTU (ETH_HLEN + VLAN_HLEN + ETH_FCS_LEN)
56
57#define MLX5E_HW2SW_MTU(priv, hwmtu) ((hwmtu) - ((priv)->hard_mtu))
58#define MLX5E_SW2HW_MTU(priv, swmtu) ((swmtu) + ((priv)->hard_mtu))
d8bec2b2 59
f62b8bb8
AV
60#define MLX5E_MAX_NUM_TC 8
61
e842b100 62#define MLX5E_PARAMS_MINIMUM_LOG_SQ_SIZE 0x6
f62b8bb8
AV
63#define MLX5E_PARAMS_DEFAULT_LOG_SQ_SIZE 0xa
64#define MLX5E_PARAMS_MAXIMUM_LOG_SQ_SIZE 0xd
65
e842b100 66#define MLX5E_PARAMS_MINIMUM_LOG_RQ_SIZE 0x1
f62b8bb8
AV
67#define MLX5E_PARAMS_DEFAULT_LOG_RQ_SIZE 0xa
68#define MLX5E_PARAMS_MAXIMUM_LOG_RQ_SIZE 0xd
69
461017cb 70#define MLX5E_PARAMS_MINIMUM_LOG_RQ_SIZE_MPW 0x1
7e426671 71#define MLX5E_PARAMS_DEFAULT_LOG_RQ_SIZE_MPW 0x3
461017cb
TT
72#define MLX5E_PARAMS_MAXIMUM_LOG_RQ_SIZE_MPW 0x6
73
1bfecfca
SM
74#define MLX5_RX_HEADROOM NET_SKB_PAD
75
f32f5bd2
DJ
76#define MLX5_MPWRQ_MIN_LOG_STRIDE_SZ(mdev) \
77 (6 + MLX5_CAP_GEN(mdev, cache_line_128byte)) /* HW restriction */
78#define MLX5_MPWRQ_LOG_STRIDE_SZ(mdev, req) \
79 max_t(u32, MLX5_MPWRQ_MIN_LOG_STRIDE_SZ(mdev), req)
80#define MLX5_MPWRQ_DEF_LOG_STRIDE_SZ(mdev) MLX5_MPWRQ_LOG_STRIDE_SZ(mdev, 6)
81#define MLX5_MPWRQ_CQE_CMPRS_LOG_STRIDE_SZ(mdev) MLX5_MPWRQ_LOG_STRIDE_SZ(mdev, 8)
82
7e426671 83#define MLX5_MPWRQ_LOG_WQE_SZ 18
461017cb
TT
84#define MLX5_MPWRQ_WQE_PAGE_ORDER (MLX5_MPWRQ_LOG_WQE_SZ - PAGE_SHIFT > 0 ? \
85 MLX5_MPWRQ_LOG_WQE_SZ - PAGE_SHIFT : 0)
86#define MLX5_MPWRQ_PAGES_PER_WQE BIT(MLX5_MPWRQ_WQE_PAGE_ORDER)
87#define MLX5_MPWRQ_STRIDES_PER_PAGE (MLX5_MPWRQ_NUM_STRIDES >> \
88 MLX5_MPWRQ_WQE_PAGE_ORDER)
fe4c988b
SM
89
90#define MLX5_MTT_OCTW(npages) (ALIGN(npages, 8) / 2)
ec8b9981
TT
91#define MLX5E_REQUIRED_MTTS(wqes) \
92 (wqes * ALIGN(MLX5_MPWRQ_PAGES_PER_WQE, 8))
93#define MLX5E_VALID_NUM_MTTS(num_mtts) (MLX5_MTT_OCTW(num_mtts) - 1 <= U16_MAX)
fe4c988b 94
bc77b240 95#define MLX5_UMR_ALIGN (2048)
cbad8cdd 96#define MLX5_MPWRQ_SMALL_PACKET_THRESHOLD (256)
461017cb 97
d9a40271 98#define MLX5E_PARAMS_DEFAULT_LRO_WQE_SZ (64 * 1024)
2b029556
SM
99#define MLX5E_DEFAULT_LRO_TIMEOUT 32
100#define MLX5E_LRO_TIMEOUT_ARR_SIZE 4
101
f62b8bb8 102#define MLX5E_PARAMS_DEFAULT_RX_CQ_MODERATION_USEC 0x10
9908aa29 103#define MLX5E_PARAMS_DEFAULT_RX_CQ_MODERATION_USEC_FROM_CQE 0x3
f62b8bb8
AV
104#define MLX5E_PARAMS_DEFAULT_RX_CQ_MODERATION_PKTS 0x20
105#define MLX5E_PARAMS_DEFAULT_TX_CQ_MODERATION_USEC 0x10
106#define MLX5E_PARAMS_DEFAULT_TX_CQ_MODERATION_PKTS 0x20
107#define MLX5E_PARAMS_DEFAULT_MIN_RX_WQES 0x80
461017cb 108#define MLX5E_PARAMS_DEFAULT_MIN_RX_WQES_MPW 0x2
f62b8bb8 109
936896e9
AS
110#define MLX5E_LOG_INDIR_RQT_SIZE 0x7
111#define MLX5E_INDIR_RQT_SIZE BIT(MLX5E_LOG_INDIR_RQT_SIZE)
b4e029da 112#define MLX5E_MIN_NUM_CHANNELS 0x1
936896e9 113#define MLX5E_MAX_NUM_CHANNELS (MLX5E_INDIR_RQT_SIZE >> 1)
507f0c81 114#define MLX5E_MAX_NUM_SQS (MLX5E_MAX_NUM_CHANNELS * MLX5E_MAX_NUM_TC)
f62b8bb8
AV
115#define MLX5E_TX_CQ_POLL_BUDGET 128
116#define MLX5E_UPDATE_STATS_INTERVAL 200 /* msecs */
117
f10b7cc7
SM
118#define MLX5E_ICOSQ_MAX_WQEBBS \
119 (DIV_ROUND_UP(sizeof(struct mlx5e_umr_wqe), MLX5_SEND_WQE_BB))
120
b5503b99 121#define MLX5E_XDP_MIN_INLINE (ETH_HLEN + VLAN_HLEN)
b5503b99 122#define MLX5E_XDP_TX_DS_COUNT \
b70149dd 123 ((sizeof(struct mlx5e_tx_wqe) / MLX5_SEND_WQE_DS) + 1 /* SG DS */)
b5503b99 124
86d722ad 125#define MLX5E_NUM_MAIN_GROUPS 9
2f48af12 126
461017cb
TT
127static inline u16 mlx5_min_rx_wqes(int wq_type, u32 wq_size)
128{
129 switch (wq_type) {
130 case MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ:
131 return min_t(u16, MLX5E_PARAMS_DEFAULT_MIN_RX_WQES_MPW,
132 wq_size / 2);
133 default:
134 return min_t(u16, MLX5E_PARAMS_DEFAULT_MIN_RX_WQES,
135 wq_size / 2);
136 }
137}
138
139static inline int mlx5_min_log_rq_size(int wq_type)
140{
141 switch (wq_type) {
142 case MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ:
143 return MLX5E_PARAMS_MINIMUM_LOG_RQ_SIZE_MPW;
144 default:
145 return MLX5E_PARAMS_MINIMUM_LOG_RQ_SIZE;
146 }
147}
148
149static inline int mlx5_max_log_rq_size(int wq_type)
150{
151 switch (wq_type) {
152 case MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ:
153 return MLX5E_PARAMS_MAXIMUM_LOG_RQ_SIZE_MPW;
154 default:
155 return MLX5E_PARAMS_MAXIMUM_LOG_RQ_SIZE;
156 }
157}
158
48935bbb
SM
159static inline int mlx5e_get_max_num_channels(struct mlx5_core_dev *mdev)
160{
161 return is_kdump_kernel() ?
162 MLX5E_MIN_NUM_CHANNELS :
163 min_t(int, mdev->priv.eq_table.num_comp_vectors,
164 MLX5E_MAX_NUM_CHANNELS);
165}
166
2f48af12
TT
167struct mlx5e_tx_wqe {
168 struct mlx5_wqe_ctrl_seg ctrl;
169 struct mlx5_wqe_eth_seg eth;
170};
171
172struct mlx5e_rx_wqe {
173 struct mlx5_wqe_srq_next_seg next;
174 struct mlx5_wqe_data_seg data;
175};
86d722ad 176
bc77b240
TT
177struct mlx5e_umr_wqe {
178 struct mlx5_wqe_ctrl_seg ctrl;
179 struct mlx5_wqe_umr_ctrl_seg uctrl;
180 struct mlx5_mkey_seg mkc;
181 struct mlx5_wqe_data_seg data;
182};
183
d605d668
KH
184extern const char mlx5e_self_tests[][ETH_GSTRING_LEN];
185
4e59e288 186static const char mlx5e_priv_flags[][ETH_GSTRING_LEN] = {
9908aa29 187 "rx_cqe_moder",
9bcc8606 188 "rx_cqe_compress",
4e59e288
GP
189};
190
191enum mlx5e_priv_flag {
9908aa29 192 MLX5E_PFLAG_RX_CQE_BASED_MODER = (1 << 0),
9bcc8606 193 MLX5E_PFLAG_RX_CQE_COMPRESS = (1 << 1),
4e59e288
GP
194};
195
6a9764ef 196#define MLX5E_SET_PFLAG(params, pflag, enable) \
59ece1c9
SD
197 do { \
198 if (enable) \
6a9764ef 199 (params)->pflags |= (pflag); \
59ece1c9 200 else \
6a9764ef 201 (params)->pflags &= ~(pflag); \
4e59e288
GP
202 } while (0)
203
6a9764ef 204#define MLX5E_GET_PFLAG(params, pflag) (!!((params)->pflags & (pflag)))
59ece1c9 205
08fb1dac
SM
206#ifdef CONFIG_MLX5_CORE_EN_DCB
207#define MLX5E_MAX_BW_ALLOC 100 /* Max percentage of BW allocation */
08fb1dac
SM
208#endif
209
9908aa29
TT
210struct mlx5e_cq_moder {
211 u16 usec;
212 u16 pkts;
213};
214
f62b8bb8
AV
215struct mlx5e_params {
216 u8 log_sq_size;
461017cb 217 u8 rq_wq_type;
d9d9f156
TT
218 u8 mpwqe_log_stride_sz;
219 u8 mpwqe_log_num_strides;
f62b8bb8
AV
220 u8 log_rq_size;
221 u16 num_channels;
f62b8bb8 222 u8 num_tc;
9908aa29 223 u8 rx_cq_period_mode;
9bcc8606 224 bool rx_cqe_compress_def;
9908aa29
TT
225 struct mlx5e_cq_moder rx_cq_moderation;
226 struct mlx5e_cq_moder tx_cq_moderation;
f62b8bb8
AV
227 bool lro_en;
228 u32 lro_wqe_sz;
58d52291 229 u16 tx_max_inline;
cff92d7c 230 u8 tx_min_inline_mode;
2d75b2bc
AS
231 u8 rss_hfunc;
232 u8 toeplitz_hash_key[40];
233 u32 indirection_rqt[MLX5E_INDIR_RQT_SIZE];
36350114 234 bool vlan_strip_disable;
102722fc 235 bool scatter_fcs_en;
cb3c7fd4 236 bool rx_am_enabled;
2b029556 237 u32 lro_timeout;
59ece1c9 238 u32 pflags;
6a9764ef 239 struct bpf_prog *xdp_prog;
f62b8bb8
AV
240};
241
3a6a931d
HN
242#ifdef CONFIG_MLX5_CORE_EN_DCB
243struct mlx5e_cee_config {
244 /* bw pct for priority group */
245 u8 pg_bw_pct[CEE_DCBX_MAX_PGS];
246 u8 prio_to_pg_map[CEE_DCBX_MAX_PRIO];
247 bool pfc_setting[CEE_DCBX_MAX_PRIO];
248 bool pfc_enable;
249};
250
251enum {
252 MLX5_DCB_CHG_RESET,
253 MLX5_DCB_NO_CHG,
254 MLX5_DCB_CHG_NO_RESET,
255};
256
257struct mlx5e_dcbx {
e207b7e9 258 enum mlx5_dcbx_oper_mode mode;
3a6a931d 259 struct mlx5e_cee_config cee_cfg; /* pending configuration */
820c2c5e
HN
260
261 /* The only setting that cannot be read from FW */
262 u8 tc_tsa[IEEE_8021QAZ_MAX_TCS];
3a6a931d
HN
263};
264#endif
265
ef9814de
EBE
266struct mlx5e_tstamp {
267 rwlock_t lock;
268 struct cyclecounter cycles;
269 struct timecounter clock;
270 struct hwtstamp_config hwtstamp_config;
271 u32 nominal_c_mult;
272 unsigned long overflow_period;
273 struct delayed_work overflow_work;
274 struct mlx5_core_dev *mdev;
3d8c38af
EBE
275 struct ptp_clock *ptp;
276 struct ptp_clock_info ptp_info;
ee7f1220 277 u8 *pps_pin_caps;
ef9814de
EBE
278};
279
f62b8bb8 280enum {
c0f1147d 281 MLX5E_RQ_STATE_ENABLED,
bc77b240 282 MLX5E_RQ_STATE_UMR_WQE_IN_PROGRESS,
cb3c7fd4 283 MLX5E_RQ_STATE_AM,
f62b8bb8
AV
284};
285
f62b8bb8
AV
286struct mlx5e_cq {
287 /* data path - accessed per cqe */
288 struct mlx5_cqwq wq;
f62b8bb8
AV
289
290 /* data path - accessed per napi poll */
cb3c7fd4 291 u16 event_ctr;
f62b8bb8
AV
292 struct napi_struct *napi;
293 struct mlx5_core_cq mcq;
294 struct mlx5e_channel *channel;
295
7219ab34
TT
296 /* cqe decompression */
297 struct mlx5_cqe64 title;
298 struct mlx5_mini_cqe8 mini_arr[MLX5_MINI_CQE_ARRAY_SIZE];
299 u8 mini_arr_idx;
300 u16 decmprs_left;
301 u16 decmprs_wqe_counter;
302
f62b8bb8 303 /* control */
a43b25da 304 struct mlx5_core_dev *mdev;
1c1b5228 305 struct mlx5_frag_wq_ctrl wq_ctrl;
f62b8bb8
AV
306} ____cacheline_aligned_in_smp;
307
eba2db2b 308struct mlx5e_tx_wqe_info {
77bdf895 309 struct sk_buff *skb;
eba2db2b
SM
310 u32 num_bytes;
311 u8 num_wqebbs;
312 u8 num_dma;
313};
314
315enum mlx5e_dma_map_type {
316 MLX5E_DMA_MAP_SINGLE,
317 MLX5E_DMA_MAP_PAGE
318};
319
320struct mlx5e_sq_dma {
321 dma_addr_t addr;
322 u32 size;
323 enum mlx5e_dma_map_type type;
324};
325
326enum {
327 MLX5E_SQ_STATE_ENABLED,
328};
329
330struct mlx5e_sq_wqe_info {
331 u8 opcode;
332 u8 num_wqebbs;
333};
2f48af12 334
31391048 335struct mlx5e_txqsq {
eba2db2b
SM
336 /* data path */
337
338 /* dirtied @completion */
339 u16 cc;
340 u32 dma_fifo_cc;
341
342 /* dirtied @xmit */
343 u16 pc ____cacheline_aligned_in_smp;
344 u32 dma_fifo_pc;
345 struct mlx5e_sq_stats stats;
346
347 struct mlx5e_cq cq;
348
31391048
SM
349 /* write@xmit, read@completion */
350 struct {
31391048
SM
351 struct mlx5e_sq_dma *dma_fifo;
352 struct mlx5e_tx_wqe_info *wqe_info;
eba2db2b
SM
353 } db;
354
355 /* read only */
356 struct mlx5_wq_cyc wq;
357 u32 dma_fifo_mask;
358 void __iomem *uar_map;
359 struct netdev_queue *txq;
360 u32 sqn;
361 u16 max_inline;
362 u8 min_inline_mode;
363 u16 edge;
364 struct device *pdev;
365 struct mlx5e_tstamp *tstamp;
366 __be32 mkey_be;
367 unsigned long state;
368
369 /* control path */
370 struct mlx5_wq_ctrl wq_ctrl;
371 struct mlx5e_channel *channel;
acc6c595 372 int txq_ix;
eba2db2b 373 u32 rate_limit;
31391048
SM
374} ____cacheline_aligned_in_smp;
375
376struct mlx5e_xdpsq {
377 /* data path */
378
379 /* dirtied @rx completion */
380 u16 cc;
381 u16 pc;
382
383 struct mlx5e_cq cq;
384
385 /* write@xmit, read@completion */
386 struct {
387 struct mlx5e_dma_info *di;
388 bool doorbell;
389 } db;
390
391 /* read only */
392 struct mlx5_wq_cyc wq;
393 void __iomem *uar_map;
394 u32 sqn;
395 struct device *pdev;
396 __be32 mkey_be;
397 u8 min_inline_mode;
398 unsigned long state;
399
400 /* control path */
401 struct mlx5_wq_ctrl wq_ctrl;
402 struct mlx5e_channel *channel;
403} ____cacheline_aligned_in_smp;
404
405struct mlx5e_icosq {
406 /* data path */
407
408 /* dirtied @completion */
409 u16 cc;
410
411 /* dirtied @xmit */
412 u16 pc ____cacheline_aligned_in_smp;
413 u32 dma_fifo_pc;
414 u16 prev_cc;
415
416 struct mlx5e_cq cq;
417
418 /* write@xmit, read@completion */
419 struct {
420 struct mlx5e_sq_wqe_info *ico_wqe;
421 } db;
422
423 /* read only */
424 struct mlx5_wq_cyc wq;
425 void __iomem *uar_map;
426 u32 sqn;
427 u16 edge;
428 struct device *pdev;
429 __be32 mkey_be;
430 unsigned long state;
431
432 /* control path */
433 struct mlx5_wq_ctrl wq_ctrl;
434 struct mlx5e_channel *channel;
eba2db2b
SM
435} ____cacheline_aligned_in_smp;
436
864b2d71
SM
437static inline bool
438mlx5e_wqc_has_room_for(struct mlx5_wq_cyc *wq, u16 cc, u16 pc, u16 n)
eba2db2b 439{
864b2d71 440 return (((wq->sz_m1 & (cc - pc)) >= n) || (cc == pc));
eba2db2b 441}
6cd392a0 442
461017cb
TT
443struct mlx5e_dma_info {
444 struct page *page;
445 dma_addr_t addr;
446};
447
eba2db2b
SM
448struct mlx5e_umr_dma_info {
449 __be64 *mtt;
450 dma_addr_t mtt_addr;
451 struct mlx5e_dma_info dma_info[MLX5_MPWRQ_PAGES_PER_WQE];
452 struct mlx5e_umr_wqe wqe;
453};
454
455struct mlx5e_mpw_info {
456 struct mlx5e_umr_dma_info umr;
457 u16 consumed_strides;
458 u16 skbs_frags[MLX5_MPWRQ_PAGES_PER_WQE];
459};
460
cb3c7fd4
GR
461struct mlx5e_rx_am_stats {
462 int ppms; /* packets per msec */
c3164d2f 463 int bpms; /* bytes per msec */
cb3c7fd4
GR
464 int epms; /* events per msec */
465};
466
467struct mlx5e_rx_am_sample {
53acd76c
TG
468 ktime_t time;
469 u32 pkt_ctr;
470 u32 byte_ctr;
471 u16 event_ctr;
cb3c7fd4
GR
472};
473
474struct mlx5e_rx_am { /* Adaptive Moderation */
475 u8 state;
476 struct mlx5e_rx_am_stats prev_stats;
477 struct mlx5e_rx_am_sample start_sample;
478 struct work_struct work;
479 u8 profile_ix;
480 u8 mode;
481 u8 tune_state;
482 u8 steps_right;
483 u8 steps_left;
484 u8 tired;
485};
486
4415a031
TT
487/* a single cache unit is capable to serve one napi call (for non-striding rq)
488 * or a MPWQE (for striding rq).
489 */
490#define MLX5E_CACHE_UNIT (MLX5_MPWRQ_PAGES_PER_WQE > NAPI_POLL_WEIGHT ? \
491 MLX5_MPWRQ_PAGES_PER_WQE : NAPI_POLL_WEIGHT)
492#define MLX5E_CACHE_SIZE (2 * roundup_pow_of_two(MLX5E_CACHE_UNIT))
493struct mlx5e_page_cache {
494 u32 head;
495 u32 tail;
496 struct mlx5e_dma_info page_cache[MLX5E_CACHE_SIZE];
497};
498
eba2db2b
SM
499struct mlx5e_rq;
500typedef void (*mlx5e_fp_handle_rx_cqe)(struct mlx5e_rq*, struct mlx5_cqe64*);
501typedef int (*mlx5e_fp_alloc_wqe)(struct mlx5e_rq*, struct mlx5e_rx_wqe*, u16);
502typedef void (*mlx5e_fp_dealloc_wqe)(struct mlx5e_rq*, u16);
503
f62b8bb8
AV
504struct mlx5e_rq {
505 /* data path */
506 struct mlx5_wq_ll wq;
1bfecfca 507
21c59685
SM
508 union {
509 struct mlx5e_dma_info *dma_info;
510 struct {
511 struct mlx5e_mpw_info *info;
512 void *mtt_no_align;
21c59685
SM
513 } mpwqe;
514 };
1bfecfca
SM
515 struct {
516 u8 page_order;
517 u32 wqe_sz; /* wqe data buffer size */
b5503b99 518 u8 map_dir; /* dma map direction */
1bfecfca 519 } buff;
bc77b240 520 __be32 mkey_be;
f62b8bb8
AV
521
522 struct device *pdev;
523 struct net_device *netdev;
ef9814de 524 struct mlx5e_tstamp *tstamp;
f62b8bb8
AV
525 struct mlx5e_rq_stats stats;
526 struct mlx5e_cq cq;
4415a031
TT
527 struct mlx5e_page_cache page_cache;
528
2f48af12
TT
529 mlx5e_fp_handle_rx_cqe handle_rx_cqe;
530 mlx5e_fp_alloc_wqe alloc_wqe;
6cd392a0 531 mlx5e_fp_dealloc_wqe dealloc_wqe;
f62b8bb8
AV
532
533 unsigned long state;
534 int ix;
d8bec2b2 535 u16 rx_headroom;
f62b8bb8 536
cb3c7fd4 537 struct mlx5e_rx_am am; /* Adaptive Moderation */
31871f87
SM
538
539 /* XDP */
86994156 540 struct bpf_prog *xdp_prog;
31391048 541 struct mlx5e_xdpsq xdpsq;
cb3c7fd4 542
f62b8bb8
AV
543 /* control */
544 struct mlx5_wq_ctrl wq_ctrl;
461017cb 545 u8 wq_type;
d9d9f156
TT
546 u32 mpwqe_stride_sz;
547 u32 mpwqe_num_strides;
f62b8bb8
AV
548 u32 rqn;
549 struct mlx5e_channel *channel;
a43b25da 550 struct mlx5_core_dev *mdev;
ec8b9981 551 struct mlx5_core_mkey umr_mkey;
f62b8bb8
AV
552} ____cacheline_aligned_in_smp;
553
f62b8bb8
AV
554enum channel_flags {
555 MLX5E_CHANNEL_NAPI_SCHED = 1,
556};
557
558struct mlx5e_channel {
559 /* data path */
560 struct mlx5e_rq rq;
31391048
SM
561 struct mlx5e_txqsq sq[MLX5E_MAX_NUM_TC];
562 struct mlx5e_icosq icosq; /* internal control operations */
b5503b99 563 bool xdp;
f62b8bb8
AV
564 struct napi_struct napi;
565 struct device *pdev;
566 struct net_device *netdev;
567 __be32 mkey_be;
568 u8 num_tc;
569 unsigned long flags;
570
571 /* control */
572 struct mlx5e_priv *priv;
a43b25da
SM
573 struct mlx5_core_dev *mdev;
574 struct mlx5e_tstamp *tstamp;
f62b8bb8
AV
575 int ix;
576 int cpu;
577};
578
ff9c852f
SM
579struct mlx5e_channels {
580 struct mlx5e_channel **c;
581 unsigned int num;
6a9764ef 582 struct mlx5e_params params;
ff9c852f
SM
583};
584
f62b8bb8 585enum mlx5e_traffic_types {
5a6f8aef
AS
586 MLX5E_TT_IPV4_TCP,
587 MLX5E_TT_IPV6_TCP,
588 MLX5E_TT_IPV4_UDP,
589 MLX5E_TT_IPV6_UDP,
a741749f
AS
590 MLX5E_TT_IPV4_IPSEC_AH,
591 MLX5E_TT_IPV6_IPSEC_AH,
592 MLX5E_TT_IPV4_IPSEC_ESP,
593 MLX5E_TT_IPV6_IPSEC_ESP,
5a6f8aef
AS
594 MLX5E_TT_IPV4,
595 MLX5E_TT_IPV6,
596 MLX5E_TT_ANY,
597 MLX5E_NUM_TT,
1da36696 598 MLX5E_NUM_INDIR_TIRS = MLX5E_TT_ANY,
f62b8bb8
AV
599};
600
acff797c 601enum {
e0f46eb9 602 MLX5E_STATE_ASYNC_EVENTS_ENABLED,
acff797c
MG
603 MLX5E_STATE_OPENED,
604 MLX5E_STATE_DESTROYING,
605};
606
607struct mlx5e_vxlan_db {
608 spinlock_t lock; /* protect vxlan table */
609 struct radix_tree_root tree;
610};
611
33cfaaa8 612struct mlx5e_l2_rule {
f62b8bb8 613 u8 addr[ETH_ALEN + 2];
74491de9 614 struct mlx5_flow_handle *rule;
f62b8bb8
AV
615};
616
acff797c
MG
617struct mlx5e_flow_table {
618 int num_groups;
619 struct mlx5_flow_table *t;
620 struct mlx5_flow_group **g;
621};
622
33cfaaa8 623#define MLX5E_L2_ADDR_HASH_SIZE BIT(BITS_PER_BYTE)
f62b8bb8 624
acff797c
MG
625struct mlx5e_tc_table {
626 struct mlx5_flow_table *t;
627
628 struct rhashtable_params ht_params;
629 struct rhashtable ht;
11c9c548
OG
630
631 DECLARE_HASHTABLE(mod_hdr_tbl, 8);
f62b8bb8
AV
632};
633
acff797c
MG
634struct mlx5e_vlan_table {
635 struct mlx5e_flow_table ft;
aad9e6e4 636 unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
74491de9
MB
637 struct mlx5_flow_handle *active_vlans_rule[VLAN_N_VID];
638 struct mlx5_flow_handle *untagged_rule;
8a271746
MHY
639 struct mlx5_flow_handle *any_cvlan_rule;
640 struct mlx5_flow_handle *any_svlan_rule;
641 bool filter_disabled;
f62b8bb8
AV
642};
643
33cfaaa8
MG
644struct mlx5e_l2_table {
645 struct mlx5e_flow_table ft;
646 struct hlist_head netdev_uc[MLX5E_L2_ADDR_HASH_SIZE];
647 struct hlist_head netdev_mc[MLX5E_L2_ADDR_HASH_SIZE];
648 struct mlx5e_l2_rule broadcast;
649 struct mlx5e_l2_rule allmulti;
650 struct mlx5e_l2_rule promisc;
651 bool broadcast_enabled;
652 bool allmulti_enabled;
653 bool promisc_enabled;
654};
655
656/* L3/L4 traffic type classifier */
657struct mlx5e_ttc_table {
658 struct mlx5e_flow_table ft;
74491de9 659 struct mlx5_flow_handle *rules[MLX5E_NUM_TT];
33cfaaa8
MG
660};
661
18c908e4
MG
662#define ARFS_HASH_SHIFT BITS_PER_BYTE
663#define ARFS_HASH_SIZE BIT(BITS_PER_BYTE)
1cabe6b0
MG
664struct arfs_table {
665 struct mlx5e_flow_table ft;
74491de9 666 struct mlx5_flow_handle *default_rule;
18c908e4 667 struct hlist_head rules_hash[ARFS_HASH_SIZE];
1cabe6b0
MG
668};
669
670enum arfs_type {
671 ARFS_IPV4_TCP,
672 ARFS_IPV6_TCP,
673 ARFS_IPV4_UDP,
674 ARFS_IPV6_UDP,
675 ARFS_NUM_TYPES,
676};
677
678struct mlx5e_arfs_tables {
679 struct arfs_table arfs_tables[ARFS_NUM_TYPES];
18c908e4
MG
680 /* Protect aRFS rules list */
681 spinlock_t arfs_lock;
682 struct list_head rules;
683 int last_filter_id;
684 struct workqueue_struct *wq;
1cabe6b0
MG
685};
686
687/* NIC prio FTS */
688enum {
689 MLX5E_VLAN_FT_LEVEL = 0,
690 MLX5E_L2_FT_LEVEL,
691 MLX5E_TTC_FT_LEVEL,
692 MLX5E_ARFS_FT_LEVEL
693};
694
6dc6071c
MG
695struct mlx5e_ethtool_table {
696 struct mlx5_flow_table *ft;
697 int num_rules;
698};
699
1174fce8 700#define ETHTOOL_NUM_L3_L4_FTS 7
6dc6071c
MG
701#define ETHTOOL_NUM_L2_FTS 4
702
703struct mlx5e_ethtool_steering {
1174fce8 704 struct mlx5e_ethtool_table l3_l4_ft[ETHTOOL_NUM_L3_L4_FTS];
6dc6071c
MG
705 struct mlx5e_ethtool_table l2_ft[ETHTOOL_NUM_L2_FTS];
706 struct list_head rules;
707 int tot_num_rules;
708};
709
acff797c
MG
710struct mlx5e_flow_steering {
711 struct mlx5_flow_namespace *ns;
6dc6071c 712 struct mlx5e_ethtool_steering ethtool;
acff797c
MG
713 struct mlx5e_tc_table tc;
714 struct mlx5e_vlan_table vlan;
33cfaaa8
MG
715 struct mlx5e_l2_table l2;
716 struct mlx5e_ttc_table ttc;
1cabe6b0 717 struct mlx5e_arfs_tables arfs;
f62b8bb8
AV
718};
719
398f3351 720struct mlx5e_rqt {
1da36696 721 u32 rqtn;
398f3351
HHZ
722 bool enabled;
723};
724
725struct mlx5e_tir {
726 u32 tirn;
727 struct mlx5e_rqt rqt;
728 struct list_head list;
1da36696
TT
729};
730
acff797c
MG
731enum {
732 MLX5E_TC_PRIO = 0,
733 MLX5E_NIC_PRIO
734};
735
f62b8bb8
AV
736struct mlx5e_priv {
737 /* priv data path fields - start */
acc6c595
SM
738 struct mlx5e_txqsq *txq2sq[MLX5E_MAX_NUM_CHANNELS * MLX5E_MAX_NUM_TC];
739 int channel_tc2txq[MLX5E_MAX_NUM_CHANNELS][MLX5E_MAX_NUM_TC];
f62b8bb8
AV
740 /* priv data path fields - end */
741
742 unsigned long state;
743 struct mutex state_lock; /* Protects Interface state */
50cfa25a 744 struct mlx5e_rq drop_rq;
f62b8bb8 745
ff9c852f 746 struct mlx5e_channels channels;
f62b8bb8 747 u32 tisn[MLX5E_MAX_NUM_TC];
398f3351 748 struct mlx5e_rqt indir_rqt;
724b2aa1
HHZ
749 struct mlx5e_tir indir_tir[MLX5E_NUM_INDIR_TIRS];
750 struct mlx5e_tir direct_tir[MLX5E_MAX_NUM_CHANNELS];
507f0c81 751 u32 tx_rates[MLX5E_MAX_NUM_SQS];
c139dbfd 752 int hard_mtu;
f62b8bb8 753
acff797c 754 struct mlx5e_flow_steering fs;
b3f63c3d 755 struct mlx5e_vxlan_db vxlan;
f62b8bb8 756
7bb29755 757 struct workqueue_struct *wq;
f62b8bb8
AV
758 struct work_struct update_carrier_work;
759 struct work_struct set_rx_mode_work;
3947ca18 760 struct work_struct tx_timeout_work;
f62b8bb8
AV
761 struct delayed_work update_stats_work;
762
763 struct mlx5_core_dev *mdev;
764 struct net_device *netdev;
765 struct mlx5e_stats stats;
ef9814de 766 struct mlx5e_tstamp tstamp;
593cf338 767 u16 q_counter;
3a6a931d
HN
768#ifdef CONFIG_MLX5_CORE_EN_DCB
769 struct mlx5e_dcbx dcbx;
770#endif
771
6bfd390b 772 const struct mlx5e_profile *profile;
127ea380 773 void *ppriv;
f62b8bb8
AV
774};
775
a43b25da
SM
776struct mlx5e_profile {
777 void (*init)(struct mlx5_core_dev *mdev,
778 struct net_device *netdev,
779 const struct mlx5e_profile *profile, void *ppriv);
780 void (*cleanup)(struct mlx5e_priv *priv);
781 int (*init_rx)(struct mlx5e_priv *priv);
782 void (*cleanup_rx)(struct mlx5e_priv *priv);
783 int (*init_tx)(struct mlx5e_priv *priv);
784 void (*cleanup_tx)(struct mlx5e_priv *priv);
785 void (*enable)(struct mlx5e_priv *priv);
786 void (*disable)(struct mlx5e_priv *priv);
787 void (*update_stats)(struct mlx5e_priv *priv);
7ca42c80 788 void (*update_carrier)(struct mlx5e_priv *priv);
a43b25da 789 int (*max_nch)(struct mlx5_core_dev *mdev);
20fd0c19
SM
790 struct {
791 mlx5e_fp_handle_rx_cqe handle_rx_cqe;
792 mlx5e_fp_handle_rx_cqe handle_rx_cqe_mpwqe;
793 } rx_handlers;
a43b25da
SM
794 int max_tc;
795};
796
665bc539
GP
797void mlx5e_build_ptys2ethtool_map(void);
798
f62b8bb8
AV
799u16 mlx5e_select_queue(struct net_device *dev, struct sk_buff *skb,
800 void *accel_priv, select_queue_fallback_t fallback);
801netdev_tx_t mlx5e_xmit(struct sk_buff *skb, struct net_device *dev);
f62b8bb8
AV
802
803void mlx5e_completion_event(struct mlx5_core_cq *mcq);
804void mlx5e_cq_error_event(struct mlx5_core_cq *mcq, enum mlx5_event event);
805int mlx5e_napi_poll(struct napi_struct *napi, int budget);
8ec736e5 806bool mlx5e_poll_tx_cq(struct mlx5e_cq *cq, int napi_budget);
44fb6fbb 807int mlx5e_poll_rx_cq(struct mlx5e_cq *cq, int budget);
1c4bf940 808bool mlx5e_poll_xdpsq_cq(struct mlx5e_cq *cq);
31391048
SM
809void mlx5e_free_txqsq_descs(struct mlx5e_txqsq *sq);
810void mlx5e_free_xdpsq_descs(struct mlx5e_xdpsq *sq);
461017cb 811
4415a031
TT
812void mlx5e_page_release(struct mlx5e_rq *rq, struct mlx5e_dma_info *dma_info,
813 bool recycle);
2f48af12 814void mlx5e_handle_rx_cqe(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe);
461017cb 815void mlx5e_handle_rx_cqe_mpwrq(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe);
f62b8bb8 816bool mlx5e_post_rx_wqes(struct mlx5e_rq *rq);
2f48af12 817int mlx5e_alloc_rx_wqe(struct mlx5e_rq *rq, struct mlx5e_rx_wqe *wqe, u16 ix);
7e426671 818int mlx5e_alloc_rx_mpwqe(struct mlx5e_rq *rq, struct mlx5e_rx_wqe *wqe, u16 ix);
6cd392a0
DJ
819void mlx5e_dealloc_rx_wqe(struct mlx5e_rq *rq, u16 ix);
820void mlx5e_dealloc_rx_mpwqe(struct mlx5e_rq *rq, u16 ix);
7e426671
TT
821void mlx5e_post_rx_mpwqe(struct mlx5e_rq *rq);
822void mlx5e_free_rx_mpwqe(struct mlx5e_rq *rq, struct mlx5e_mpw_info *wi);
f62b8bb8
AV
823struct mlx5_cqe64 *mlx5e_get_cqe(struct mlx5e_cq *cq);
824
cb3c7fd4
GR
825void mlx5e_rx_am(struct mlx5e_rq *rq);
826void mlx5e_rx_am_work(struct work_struct *work);
827struct mlx5e_cq_moder mlx5e_am_get_def_profile(u8 rx_cq_period_mode);
828
3834a5e6 829void mlx5e_update_stats(struct mlx5e_priv *priv, bool full);
f62b8bb8 830
acff797c
MG
831int mlx5e_create_flow_steering(struct mlx5e_priv *priv);
832void mlx5e_destroy_flow_steering(struct mlx5e_priv *priv);
33cfaaa8 833void mlx5e_init_l2_addr(struct mlx5e_priv *priv);
1cabe6b0 834void mlx5e_destroy_flow_table(struct mlx5e_flow_table *ft);
d605d668
KH
835int mlx5e_self_test_num(struct mlx5e_priv *priv);
836void mlx5e_self_test(struct net_device *ndev, struct ethtool_test *etest,
837 u64 *buf);
f913a72a
MG
838int mlx5e_ethtool_get_flow(struct mlx5e_priv *priv, struct ethtool_rxnfc *info,
839 int location);
840int mlx5e_ethtool_get_all_flows(struct mlx5e_priv *priv,
841 struct ethtool_rxnfc *info, u32 *rule_locs);
6dc6071c
MG
842int mlx5e_ethtool_flow_replace(struct mlx5e_priv *priv,
843 struct ethtool_rx_flow_spec *fs);
844int mlx5e_ethtool_flow_remove(struct mlx5e_priv *priv,
845 int location);
846void mlx5e_ethtool_init_steering(struct mlx5e_priv *priv);
847void mlx5e_ethtool_cleanup_steering(struct mlx5e_priv *priv);
f62b8bb8
AV
848void mlx5e_set_rx_mode_work(struct work_struct *work);
849
ef9814de
EBE
850void mlx5e_fill_hwstamp(struct mlx5e_tstamp *clock, u64 timestamp,
851 struct skb_shared_hwtstamps *hwts);
852void mlx5e_timestamp_init(struct mlx5e_priv *priv);
853void mlx5e_timestamp_cleanup(struct mlx5e_priv *priv);
ee7f1220
EE
854void mlx5e_pps_event_handler(struct mlx5e_priv *priv,
855 struct ptp_clock_event *event);
ef9814de
EBE
856int mlx5e_hwstamp_set(struct net_device *dev, struct ifreq *ifr);
857int mlx5e_hwstamp_get(struct net_device *dev, struct ifreq *ifr);
be7e87f9 858int mlx5e_modify_rx_cqe_compression_locked(struct mlx5e_priv *priv, bool val);
ef9814de 859
f62b8bb8
AV
860int mlx5e_vlan_rx_add_vid(struct net_device *dev, __always_unused __be16 proto,
861 u16 vid);
862int mlx5e_vlan_rx_kill_vid(struct net_device *dev, __always_unused __be16 proto,
863 u16 vid);
864void mlx5e_enable_vlan_filter(struct mlx5e_priv *priv);
865void mlx5e_disable_vlan_filter(struct mlx5e_priv *priv);
f62b8bb8 866
a5f97fee
SM
867struct mlx5e_redirect_rqt_param {
868 bool is_rss;
869 union {
870 u32 rqn; /* Direct RQN (Non-RSS) */
871 struct {
872 u8 hfunc;
873 struct mlx5e_channels *channels;
874 } rss; /* RSS data */
875 };
876};
877
878int mlx5e_redirect_rqt(struct mlx5e_priv *priv, u32 rqtn, int sz,
879 struct mlx5e_redirect_rqt_param rrp);
6a9764ef
SM
880void mlx5e_build_indir_tir_ctx_hash(struct mlx5e_params *params,
881 enum mlx5e_traffic_types tt,
882 void *tirc);
2d75b2bc 883
f62b8bb8
AV
884int mlx5e_open_locked(struct net_device *netdev);
885int mlx5e_close_locked(struct net_device *netdev);
55c2503d
SM
886
887int mlx5e_open_channels(struct mlx5e_priv *priv,
888 struct mlx5e_channels *chs);
889void mlx5e_close_channels(struct mlx5e_channels *chs);
2e20a151
SM
890
891/* Function pointer to be used to modify WH settings while
892 * switching channels
893 */
894typedef int (*mlx5e_fp_hw_modify)(struct mlx5e_priv *priv);
55c2503d 895void mlx5e_switch_priv_channels(struct mlx5e_priv *priv,
2e20a151
SM
896 struct mlx5e_channels *new_chs,
897 mlx5e_fp_hw_modify hw_modify);
603f4a45
SM
898void mlx5e_activate_priv_channels(struct mlx5e_priv *priv);
899void mlx5e_deactivate_priv_channels(struct mlx5e_priv *priv);
55c2503d 900
d8c9660d
TT
901void mlx5e_build_default_indir_rqt(struct mlx5_core_dev *mdev,
902 u32 *indirection_rqt, int len,
85082dba 903 int num_channels);
b797a684 904int mlx5e_get_max_linkspeed(struct mlx5_core_dev *mdev, u32 *speed);
f62b8bb8 905
9908aa29
TT
906void mlx5e_set_rx_cq_mode_params(struct mlx5e_params *params,
907 u8 cq_period_mode);
6a9764ef
SM
908void mlx5e_set_rq_type_params(struct mlx5_core_dev *mdev,
909 struct mlx5e_params *params, u8 rq_type);
9908aa29 910
864b2d71
SM
911static inline
912struct mlx5e_tx_wqe *mlx5e_post_nop(struct mlx5_wq_cyc *wq, u32 sqn, u16 *pc)
f62b8bb8 913{
864b2d71
SM
914 u16 pi = *pc & wq->sz_m1;
915 struct mlx5e_tx_wqe *wqe = mlx5_wq_cyc_get_wqe(wq, pi);
916 struct mlx5_wqe_ctrl_seg *cseg = &wqe->ctrl;
917
918 memset(cseg, 0, sizeof(*cseg));
919
920 cseg->opmod_idx_opcode = cpu_to_be32((*pc << 8) | MLX5_OPCODE_NOP);
921 cseg->qpn_ds = cpu_to_be32((sqn << 8) | 0x01);
922
923 (*pc)++;
924
925 return wqe;
926}
927
928static inline
929void mlx5e_notify_hw(struct mlx5_wq_cyc *wq, u16 pc,
930 void __iomem *uar_map,
931 struct mlx5_wqe_ctrl_seg *ctrl)
932{
933 ctrl->fm_ce_se = MLX5_WQE_CTRL_CQ_UPDATE;
f62b8bb8
AV
934 /* ensure wqe is visible to device before updating doorbell record */
935 dma_wmb();
936
864b2d71 937 *wq->db = cpu_to_be32(pc);
f62b8bb8
AV
938
939 /* ensure doorbell record is visible to device before ringing the
940 * doorbell
941 */
942 wmb();
f62b8bb8 943
864b2d71 944 mlx5_write64((__be32 *)ctrl, uar_map, NULL);
f62b8bb8
AV
945}
946
947static inline void mlx5e_cq_arm(struct mlx5e_cq *cq)
948{
949 struct mlx5_core_cq *mcq;
950
951 mcq = &cq->mcq;
5fe9dec0 952 mlx5_cq_arm(mcq, MLX5_CQ_DB_REQ_NOT, mcq->uar->map, cq->wq.cc);
f62b8bb8
AV
953}
954
7e426671
TT
955static inline u32 mlx5e_get_wqe_mtt_offset(struct mlx5e_rq *rq, u16 wqe_ix)
956{
ec8b9981 957 return wqe_ix * ALIGN(MLX5_MPWRQ_PAGES_PER_WQE, 8);
7e426671
TT
958}
959
f62b8bb8 960extern const struct ethtool_ops mlx5e_ethtool_ops;
08fb1dac
SM
961#ifdef CONFIG_MLX5_CORE_EN_DCB
962extern const struct dcbnl_rtnl_ops mlx5e_dcbnl_ops;
963int mlx5e_dcbnl_ieee_setets_core(struct mlx5e_priv *priv, struct ieee_ets *ets);
e207b7e9 964void mlx5e_dcbnl_initialize(struct mlx5e_priv *priv);
08fb1dac
SM
965#endif
966
1cabe6b0
MG
967#ifndef CONFIG_RFS_ACCEL
968static inline int mlx5e_arfs_create_tables(struct mlx5e_priv *priv)
969{
970 return 0;
971}
972
973static inline void mlx5e_arfs_destroy_tables(struct mlx5e_priv *priv) {}
45bf454a
MG
974
975static inline int mlx5e_arfs_enable(struct mlx5e_priv *priv)
976{
9eb78923 977 return -EOPNOTSUPP;
45bf454a
MG
978}
979
980static inline int mlx5e_arfs_disable(struct mlx5e_priv *priv)
981{
9eb78923 982 return -EOPNOTSUPP;
45bf454a 983}
1cabe6b0
MG
984#else
985int mlx5e_arfs_create_tables(struct mlx5e_priv *priv);
986void mlx5e_arfs_destroy_tables(struct mlx5e_priv *priv);
45bf454a
MG
987int mlx5e_arfs_enable(struct mlx5e_priv *priv);
988int mlx5e_arfs_disable(struct mlx5e_priv *priv);
18c908e4
MG
989int mlx5e_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb,
990 u16 rxq_index, u32 flow_id);
1cabe6b0
MG
991#endif
992
58d52291 993u16 mlx5e_get_max_inline_cap(struct mlx5_core_dev *mdev);
724b2aa1
HHZ
994int mlx5e_create_tir(struct mlx5_core_dev *mdev,
995 struct mlx5e_tir *tir, u32 *in, int inlen);
996void mlx5e_destroy_tir(struct mlx5_core_dev *mdev,
997 struct mlx5e_tir *tir);
b50d292b
HHZ
998int mlx5e_create_mdev_resources(struct mlx5_core_dev *mdev);
999void mlx5e_destroy_mdev_resources(struct mlx5_core_dev *mdev);
b676f653 1000int mlx5e_refresh_tirs(struct mlx5e_priv *priv, bool enable_uc_lb);
1afff42c 1001
bc81b9d3 1002/* common netdev helpers */
8f493ffd
SM
1003int mlx5e_create_indirect_rqt(struct mlx5e_priv *priv);
1004
1005int mlx5e_create_indirect_tirs(struct mlx5e_priv *priv);
1006void mlx5e_destroy_indirect_tirs(struct mlx5e_priv *priv);
1007
cb67b832 1008int mlx5e_create_direct_rqts(struct mlx5e_priv *priv);
8f493ffd 1009void mlx5e_destroy_direct_rqts(struct mlx5e_priv *priv);
cb67b832
HHZ
1010int mlx5e_create_direct_tirs(struct mlx5e_priv *priv);
1011void mlx5e_destroy_direct_tirs(struct mlx5e_priv *priv);
8f493ffd
SM
1012void mlx5e_destroy_rqt(struct mlx5e_priv *priv, struct mlx5e_rqt *rqt);
1013
50854114 1014int mlx5e_create_ttc_table(struct mlx5e_priv *priv);
bc81b9d3
SM
1015void mlx5e_destroy_ttc_table(struct mlx5e_priv *priv);
1016
5426a0b2
SM
1017int mlx5e_create_tis(struct mlx5_core_dev *mdev, int tc,
1018 u32 underlay_qpn, u32 *tisn);
1019void mlx5e_destroy_tis(struct mlx5_core_dev *mdev, u32 tisn);
1020
cb67b832
HHZ
1021int mlx5e_create_tises(struct mlx5e_priv *priv);
1022void mlx5e_cleanup_nic_tx(struct mlx5e_priv *priv);
1023int mlx5e_close(struct net_device *netdev);
1024int mlx5e_open(struct net_device *netdev);
1025void mlx5e_update_stats_work(struct work_struct *work);
2b029556 1026u32 mlx5e_choose_lro_timeout(struct mlx5_core_dev *mdev, u32 wanted_timeout);
cb67b832 1027
076b0936
ES
1028/* ethtool helpers */
1029void mlx5e_ethtool_get_drvinfo(struct mlx5e_priv *priv,
1030 struct ethtool_drvinfo *drvinfo);
1031void mlx5e_ethtool_get_strings(struct mlx5e_priv *priv,
1032 uint32_t stringset, uint8_t *data);
1033int mlx5e_ethtool_get_sset_count(struct mlx5e_priv *priv, int sset);
1034void mlx5e_ethtool_get_ethtool_stats(struct mlx5e_priv *priv,
1035 struct ethtool_stats *stats, u64 *data);
1036void mlx5e_ethtool_get_ringparam(struct mlx5e_priv *priv,
1037 struct ethtool_ringparam *param);
1038int mlx5e_ethtool_set_ringparam(struct mlx5e_priv *priv,
1039 struct ethtool_ringparam *param);
1040void mlx5e_ethtool_get_channels(struct mlx5e_priv *priv,
1041 struct ethtool_channels *ch);
1042int mlx5e_ethtool_set_channels(struct mlx5e_priv *priv,
1043 struct ethtool_channels *ch);
1044int mlx5e_ethtool_get_coalesce(struct mlx5e_priv *priv,
1045 struct ethtool_coalesce *coal);
1046int mlx5e_ethtool_set_coalesce(struct mlx5e_priv *priv,
1047 struct ethtool_coalesce *coal);
3844b07e
FD
1048int mlx5e_ethtool_get_ts_info(struct mlx5e_priv *priv,
1049 struct ethtool_ts_info *info);
076b0936 1050
2c3b5bee
SM
1051/* mlx5e generic netdev management API */
1052struct net_device*
1053mlx5e_create_netdev(struct mlx5_core_dev *mdev, const struct mlx5e_profile *profile,
1054 void *ppriv);
1055int mlx5e_attach_netdev(struct mlx5e_priv *priv);
1056void mlx5e_detach_netdev(struct mlx5e_priv *priv);
1057void mlx5e_destroy_netdev(struct mlx5e_priv *priv);
8f493ffd
SM
1058void mlx5e_build_nic_params(struct mlx5_core_dev *mdev,
1059 struct mlx5e_params *params,
1060 u16 max_channels);
2c3b5bee 1061
1afff42c 1062#endif /* __MLX5_EN_H__ */