net/mlx5e: Fix soft lockup when HW Timestamping is enabled
[linux-2.6-block.git] / drivers / net / ethernet / mellanox / mlx5 / core / en.h
CommitLineData
f62b8bb8
AV
1/*
2 * Copyright (c) 2015, Mellanox Technologies. All rights reserved.
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 */
32
33#include <linux/if_vlan.h>
34#include <linux/etherdevice.h>
ef9814de
EBE
35#include <linux/timecounter.h>
36#include <linux/net_tstamp.h>
3d8c38af 37#include <linux/ptp_clock_kernel.h>
f62b8bb8
AV
38#include <linux/mlx5/driver.h>
39#include <linux/mlx5/qp.h>
40#include <linux/mlx5/cq.h>
d18a9470 41#include <linux/mlx5/vport.h>
8d7f9ecb 42#include <linux/mlx5/transobj.h>
f62b8bb8 43#include "wq.h"
f62b8bb8
AV
44#include "mlx5_core.h"
45
46#define MLX5E_MAX_NUM_TC 8
47
e842b100 48#define MLX5E_PARAMS_MINIMUM_LOG_SQ_SIZE 0x6
f62b8bb8
AV
49#define MLX5E_PARAMS_DEFAULT_LOG_SQ_SIZE 0xa
50#define MLX5E_PARAMS_MAXIMUM_LOG_SQ_SIZE 0xd
51
e842b100 52#define MLX5E_PARAMS_MINIMUM_LOG_RQ_SIZE 0x1
f62b8bb8
AV
53#define MLX5E_PARAMS_DEFAULT_LOG_RQ_SIZE 0xa
54#define MLX5E_PARAMS_MAXIMUM_LOG_RQ_SIZE 0xd
55
d9a40271 56#define MLX5E_PARAMS_DEFAULT_LRO_WQE_SZ (64 * 1024)
f62b8bb8
AV
57#define MLX5E_PARAMS_DEFAULT_RX_CQ_MODERATION_USEC 0x10
58#define MLX5E_PARAMS_DEFAULT_RX_CQ_MODERATION_PKTS 0x20
59#define MLX5E_PARAMS_DEFAULT_TX_CQ_MODERATION_USEC 0x10
60#define MLX5E_PARAMS_DEFAULT_TX_CQ_MODERATION_PKTS 0x20
61#define MLX5E_PARAMS_DEFAULT_MIN_RX_WQES 0x80
f62b8bb8 62
936896e9
AS
63#define MLX5E_LOG_INDIR_RQT_SIZE 0x7
64#define MLX5E_INDIR_RQT_SIZE BIT(MLX5E_LOG_INDIR_RQT_SIZE)
65#define MLX5E_MAX_NUM_CHANNELS (MLX5E_INDIR_RQT_SIZE >> 1)
f62b8bb8
AV
66#define MLX5E_TX_CQ_POLL_BUDGET 128
67#define MLX5E_UPDATE_STATS_INTERVAL 200 /* msecs */
88a85f99 68#define MLX5E_SQ_BF_BUDGET 16
f62b8bb8 69
86d722ad
MG
70#define MLX5E_NUM_MAIN_GROUPS 9
71
f62b8bb8
AV
72static const char vport_strings[][ETH_GSTRING_LEN] = {
73 /* vport statistics */
74 "rx_packets",
75 "rx_bytes",
76 "tx_packets",
77 "tx_bytes",
78 "rx_error_packets",
79 "rx_error_bytes",
80 "tx_error_packets",
81 "tx_error_bytes",
82 "rx_unicast_packets",
83 "rx_unicast_bytes",
84 "tx_unicast_packets",
85 "tx_unicast_bytes",
86 "rx_multicast_packets",
87 "rx_multicast_bytes",
88 "tx_multicast_packets",
89 "tx_multicast_bytes",
90 "rx_broadcast_packets",
91 "rx_broadcast_bytes",
92 "tx_broadcast_packets",
93 "tx_broadcast_bytes",
94
95 /* SW counters */
96 "tso_packets",
97 "tso_bytes",
98 "lro_packets",
99 "lro_bytes",
100 "rx_csum_good",
101 "rx_csum_none",
bbceefce 102 "rx_csum_sw",
f62b8bb8
AV
103 "tx_csum_offload",
104 "tx_queue_stopped",
105 "tx_queue_wake",
106 "tx_queue_dropped",
107 "rx_wqe_err",
108};
109
110struct mlx5e_vport_stats {
111 /* HW counters */
112 u64 rx_packets;
113 u64 rx_bytes;
114 u64 tx_packets;
115 u64 tx_bytes;
116 u64 rx_error_packets;
117 u64 rx_error_bytes;
118 u64 tx_error_packets;
119 u64 tx_error_bytes;
120 u64 rx_unicast_packets;
121 u64 rx_unicast_bytes;
122 u64 tx_unicast_packets;
123 u64 tx_unicast_bytes;
124 u64 rx_multicast_packets;
125 u64 rx_multicast_bytes;
126 u64 tx_multicast_packets;
127 u64 tx_multicast_bytes;
128 u64 rx_broadcast_packets;
129 u64 rx_broadcast_bytes;
130 u64 tx_broadcast_packets;
131 u64 tx_broadcast_bytes;
132
133 /* SW counters */
134 u64 tso_packets;
135 u64 tso_bytes;
136 u64 lro_packets;
137 u64 lro_bytes;
138 u64 rx_csum_good;
139 u64 rx_csum_none;
bbceefce 140 u64 rx_csum_sw;
f62b8bb8
AV
141 u64 tx_csum_offload;
142 u64 tx_queue_stopped;
143 u64 tx_queue_wake;
144 u64 tx_queue_dropped;
145 u64 rx_wqe_err;
146
bbceefce 147#define NUM_VPORT_COUNTERS 32
f62b8bb8
AV
148};
149
efea389d
GP
150static const char pport_strings[][ETH_GSTRING_LEN] = {
151 /* IEEE802.3 counters */
152 "frames_tx",
153 "frames_rx",
154 "check_seq_err",
155 "alignment_err",
156 "octets_tx",
157 "octets_received",
158 "multicast_xmitted",
159 "broadcast_xmitted",
160 "multicast_rx",
161 "broadcast_rx",
162 "in_range_len_errors",
163 "out_of_range_len",
164 "too_long_errors",
165 "symbol_err",
166 "mac_control_tx",
167 "mac_control_rx",
168 "unsupported_op_rx",
169 "pause_ctrl_rx",
170 "pause_ctrl_tx",
171
172 /* RFC2863 counters */
173 "in_octets",
174 "in_ucast_pkts",
175 "in_discards",
176 "in_errors",
177 "in_unknown_protos",
178 "out_octets",
179 "out_ucast_pkts",
180 "out_discards",
181 "out_errors",
182 "in_multicast_pkts",
183 "in_broadcast_pkts",
184 "out_multicast_pkts",
185 "out_broadcast_pkts",
186
187 /* RFC2819 counters */
188 "drop_events",
189 "octets",
190 "pkts",
191 "broadcast_pkts",
192 "multicast_pkts",
193 "crc_align_errors",
194 "undersize_pkts",
195 "oversize_pkts",
196 "fragments",
197 "jabbers",
198 "collisions",
199 "p64octets",
200 "p65to127octets",
201 "p128to255octets",
202 "p256to511octets",
203 "p512to1023octets",
204 "p1024to1518octets",
205 "p1519to2047octets",
206 "p2048to4095octets",
207 "p4096to8191octets",
208 "p8192to10239octets",
209};
210
211#define NUM_IEEE_802_3_COUNTERS 19
212#define NUM_RFC_2863_COUNTERS 13
213#define NUM_RFC_2819_COUNTERS 21
214#define NUM_PPORT_COUNTERS (NUM_IEEE_802_3_COUNTERS + \
215 NUM_RFC_2863_COUNTERS + \
216 NUM_RFC_2819_COUNTERS)
217
218struct mlx5e_pport_stats {
219 __be64 IEEE_802_3_counters[NUM_IEEE_802_3_COUNTERS];
220 __be64 RFC_2863_counters[NUM_RFC_2863_COUNTERS];
221 __be64 RFC_2819_counters[NUM_RFC_2819_COUNTERS];
222};
223
f62b8bb8
AV
224static const char rq_stats_strings[][ETH_GSTRING_LEN] = {
225 "packets",
226 "csum_none",
bbceefce 227 "csum_sw",
f62b8bb8
AV
228 "lro_packets",
229 "lro_bytes",
230 "wqe_err"
231};
232
233struct mlx5e_rq_stats {
234 u64 packets;
235 u64 csum_none;
bbceefce 236 u64 csum_sw;
f62b8bb8
AV
237 u64 lro_packets;
238 u64 lro_bytes;
239 u64 wqe_err;
bbceefce 240#define NUM_RQ_STATS 6
f62b8bb8
AV
241};
242
243static const char sq_stats_strings[][ETH_GSTRING_LEN] = {
244 "packets",
245 "tso_packets",
246 "tso_bytes",
247 "csum_offload_none",
248 "stopped",
249 "wake",
250 "dropped",
251 "nop"
252};
253
254struct mlx5e_sq_stats {
255 u64 packets;
256 u64 tso_packets;
257 u64 tso_bytes;
258 u64 csum_offload_none;
259 u64 stopped;
260 u64 wake;
261 u64 dropped;
262 u64 nop;
263#define NUM_SQ_STATS 8
264};
265
266struct mlx5e_stats {
267 struct mlx5e_vport_stats vport;
efea389d 268 struct mlx5e_pport_stats pport;
f62b8bb8
AV
269};
270
271struct mlx5e_params {
272 u8 log_sq_size;
273 u8 log_rq_size;
274 u16 num_channels;
275 u8 default_vlan_prio;
276 u8 num_tc;
277 u16 rx_cq_moderation_usec;
278 u16 rx_cq_moderation_pkts;
279 u16 tx_cq_moderation_usec;
280 u16 tx_cq_moderation_pkts;
281 u16 min_rx_wqes;
f62b8bb8
AV
282 bool lro_en;
283 u32 lro_wqe_sz;
58d52291 284 u16 tx_max_inline;
2d75b2bc
AS
285 u8 rss_hfunc;
286 u8 toeplitz_hash_key[40];
287 u32 indirection_rqt[MLX5E_INDIR_RQT_SIZE];
f62b8bb8
AV
288};
289
ef9814de
EBE
290struct mlx5e_tstamp {
291 rwlock_t lock;
292 struct cyclecounter cycles;
293 struct timecounter clock;
294 struct hwtstamp_config hwtstamp_config;
295 u32 nominal_c_mult;
296 unsigned long overflow_period;
297 struct delayed_work overflow_work;
298 struct mlx5_core_dev *mdev;
3d8c38af
EBE
299 struct ptp_clock *ptp;
300 struct ptp_clock_info ptp_info;
ef9814de
EBE
301};
302
f62b8bb8
AV
303enum {
304 MLX5E_RQ_STATE_POST_WQES_ENABLE,
305};
306
f62b8bb8
AV
307struct mlx5e_cq {
308 /* data path - accessed per cqe */
309 struct mlx5_cqwq wq;
f62b8bb8
AV
310
311 /* data path - accessed per napi poll */
312 struct napi_struct *napi;
313 struct mlx5_core_cq mcq;
314 struct mlx5e_channel *channel;
50cfa25a 315 struct mlx5e_priv *priv;
f62b8bb8
AV
316
317 /* control */
318 struct mlx5_wq_ctrl wq_ctrl;
319} ____cacheline_aligned_in_smp;
320
321struct mlx5e_rq {
322 /* data path */
323 struct mlx5_wq_ll wq;
324 u32 wqe_sz;
325 struct sk_buff **skb;
326
327 struct device *pdev;
328 struct net_device *netdev;
ef9814de 329 struct mlx5e_tstamp *tstamp;
f62b8bb8
AV
330 struct mlx5e_rq_stats stats;
331 struct mlx5e_cq cq;
332
333 unsigned long state;
334 int ix;
335
336 /* control */
337 struct mlx5_wq_ctrl wq_ctrl;
338 u32 rqn;
339 struct mlx5e_channel *channel;
50cfa25a 340 struct mlx5e_priv *priv;
f62b8bb8
AV
341} ____cacheline_aligned_in_smp;
342
34802a42 343struct mlx5e_tx_wqe_info {
f62b8bb8
AV
344 u32 num_bytes;
345 u8 num_wqebbs;
346 u8 num_dma;
347};
348
d4e28cbd
AS
349enum mlx5e_dma_map_type {
350 MLX5E_DMA_MAP_SINGLE,
351 MLX5E_DMA_MAP_PAGE
352};
353
f62b8bb8 354struct mlx5e_sq_dma {
d4e28cbd
AS
355 dma_addr_t addr;
356 u32 size;
357 enum mlx5e_dma_map_type type;
f62b8bb8
AV
358};
359
360enum {
361 MLX5E_SQ_STATE_WAKE_TXQ_ENABLE,
362};
363
364struct mlx5e_sq {
365 /* data path */
366
367 /* dirtied @completion */
368 u16 cc;
369 u32 dma_fifo_cc;
370
371 /* dirtied @xmit */
372 u16 pc ____cacheline_aligned_in_smp;
373 u32 dma_fifo_pc;
88a85f99
AS
374 u16 bf_offset;
375 u16 prev_cc;
376 u8 bf_budget;
f62b8bb8
AV
377 struct mlx5e_sq_stats stats;
378
379 struct mlx5e_cq cq;
380
381 /* pointers to per packet info: write@xmit, read@completion */
382 struct sk_buff **skb;
383 struct mlx5e_sq_dma *dma_fifo;
34802a42 384 struct mlx5e_tx_wqe_info *wqe_info;
f62b8bb8
AV
385
386 /* read only */
387 struct mlx5_wq_cyc wq;
388 u32 dma_fifo_mask;
389 void __iomem *uar_map;
88a85f99 390 void __iomem *uar_bf_map;
f62b8bb8
AV
391 struct netdev_queue *txq;
392 u32 sqn;
88a85f99 393 u16 bf_buf_size;
12be4b21
SM
394 u16 max_inline;
395 u16 edge;
f62b8bb8 396 struct device *pdev;
ef9814de 397 struct mlx5e_tstamp *tstamp;
f62b8bb8
AV
398 __be32 mkey_be;
399 unsigned long state;
400
401 /* control path */
402 struct mlx5_wq_ctrl wq_ctrl;
403 struct mlx5_uar uar;
404 struct mlx5e_channel *channel;
405 int tc;
406} ____cacheline_aligned_in_smp;
407
408static inline bool mlx5e_sq_has_room_for(struct mlx5e_sq *sq, u16 n)
409{
410 return (((sq->wq.sz_m1 & (sq->cc - sq->pc)) >= n) ||
411 (sq->cc == sq->pc));
412}
413
414enum channel_flags {
415 MLX5E_CHANNEL_NAPI_SCHED = 1,
416};
417
418struct mlx5e_channel {
419 /* data path */
420 struct mlx5e_rq rq;
421 struct mlx5e_sq sq[MLX5E_MAX_NUM_TC];
422 struct napi_struct napi;
423 struct device *pdev;
424 struct net_device *netdev;
425 __be32 mkey_be;
426 u8 num_tc;
427 unsigned long flags;
428
429 /* control */
430 struct mlx5e_priv *priv;
431 int ix;
432 int cpu;
433};
434
435enum mlx5e_traffic_types {
5a6f8aef
AS
436 MLX5E_TT_IPV4_TCP,
437 MLX5E_TT_IPV6_TCP,
438 MLX5E_TT_IPV4_UDP,
439 MLX5E_TT_IPV6_UDP,
a741749f
AS
440 MLX5E_TT_IPV4_IPSEC_AH,
441 MLX5E_TT_IPV6_IPSEC_AH,
442 MLX5E_TT_IPV4_IPSEC_ESP,
443 MLX5E_TT_IPV6_IPSEC_ESP,
5a6f8aef
AS
444 MLX5E_TT_IPV4,
445 MLX5E_TT_IPV6,
446 MLX5E_TT_ANY,
447 MLX5E_NUM_TT,
f62b8bb8
AV
448};
449
4cbeaff5
AS
450enum mlx5e_rqt_ix {
451 MLX5E_INDIRECTION_RQT,
452 MLX5E_SINGLE_RQ_RQT,
453 MLX5E_NUM_RQT,
f62b8bb8
AV
454};
455
456struct mlx5e_eth_addr_info {
457 u8 addr[ETH_ALEN + 2];
458 u32 tt_vec;
86d722ad 459 struct mlx5_flow_rule *ft_rule[MLX5E_NUM_TT];
f62b8bb8
AV
460};
461
462#define MLX5E_ETH_ADDR_HASH_SIZE (1 << BITS_PER_BYTE)
463
464struct mlx5e_eth_addr_db {
465 struct hlist_head netdev_uc[MLX5E_ETH_ADDR_HASH_SIZE];
466 struct hlist_head netdev_mc[MLX5E_ETH_ADDR_HASH_SIZE];
467 struct mlx5e_eth_addr_info broadcast;
468 struct mlx5e_eth_addr_info allmulti;
469 struct mlx5e_eth_addr_info promisc;
470 bool broadcast_enabled;
471 bool allmulti_enabled;
472 bool promisc_enabled;
473};
474
475enum {
476 MLX5E_STATE_ASYNC_EVENTS_ENABLE,
477 MLX5E_STATE_OPENED,
9b37b07f 478 MLX5E_STATE_DESTROYING,
f62b8bb8
AV
479};
480
481struct mlx5e_vlan_db {
aad9e6e4 482 unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
86d722ad
MG
483 struct mlx5_flow_rule *active_vlans_rule[VLAN_N_VID];
484 struct mlx5_flow_rule *untagged_rule;
485 struct mlx5_flow_rule *any_vlan_rule;
f62b8bb8
AV
486 bool filter_disabled;
487};
488
489struct mlx5e_flow_table {
86d722ad
MG
490 int num_groups;
491 struct mlx5_flow_table *t;
492 struct mlx5_flow_group **g;
493};
494
495struct mlx5e_flow_tables {
496 struct mlx5_flow_namespace *ns;
497 struct mlx5e_flow_table vlan;
498 struct mlx5e_flow_table main;
f62b8bb8
AV
499};
500
501struct mlx5e_priv {
502 /* priv data path fields - start */
f62b8bb8 503 int default_vlan_prio;
03289b88 504 struct mlx5e_sq **txq_to_sq_map;
5283af89 505 int channeltc_to_txq_map[MLX5E_MAX_NUM_CHANNELS][MLX5E_MAX_NUM_TC];
f62b8bb8
AV
506 /* priv data path fields - end */
507
508 unsigned long state;
509 struct mutex state_lock; /* Protects Interface state */
510 struct mlx5_uar cq_uar;
511 u32 pdn;
3191e05f 512 u32 tdn;
f62b8bb8 513 struct mlx5_core_mr mr;
50cfa25a 514 struct mlx5e_rq drop_rq;
f62b8bb8
AV
515
516 struct mlx5e_channel **channel;
517 u32 tisn[MLX5E_MAX_NUM_TC];
4cbeaff5 518 u32 rqtn[MLX5E_NUM_RQT];
f62b8bb8
AV
519 u32 tirn[MLX5E_NUM_TT];
520
86d722ad 521 struct mlx5e_flow_tables fts;
f62b8bb8
AV
522 struct mlx5e_eth_addr_db eth_addr;
523 struct mlx5e_vlan_db vlan;
524
525 struct mlx5e_params params;
526 spinlock_t async_events_spinlock; /* sync hw events */
527 struct work_struct update_carrier_work;
528 struct work_struct set_rx_mode_work;
529 struct delayed_work update_stats_work;
530
531 struct mlx5_core_dev *mdev;
532 struct net_device *netdev;
533 struct mlx5e_stats stats;
ef9814de 534 struct mlx5e_tstamp tstamp;
f62b8bb8
AV
535};
536
537#define MLX5E_NET_IP_ALIGN 2
538
539struct mlx5e_tx_wqe {
540 struct mlx5_wqe_ctrl_seg ctrl;
541 struct mlx5_wqe_eth_seg eth;
542};
543
544struct mlx5e_rx_wqe {
545 struct mlx5_wqe_srq_next_seg next;
546 struct mlx5_wqe_data_seg data;
547};
548
549enum mlx5e_link_mode {
550 MLX5E_1000BASE_CX_SGMII = 0,
551 MLX5E_1000BASE_KX = 1,
552 MLX5E_10GBASE_CX4 = 2,
553 MLX5E_10GBASE_KX4 = 3,
554 MLX5E_10GBASE_KR = 4,
555 MLX5E_20GBASE_KR2 = 5,
556 MLX5E_40GBASE_CR4 = 6,
557 MLX5E_40GBASE_KR4 = 7,
558 MLX5E_56GBASE_R4 = 8,
559 MLX5E_10GBASE_CR = 12,
560 MLX5E_10GBASE_SR = 13,
561 MLX5E_10GBASE_ER = 14,
562 MLX5E_40GBASE_SR4 = 15,
563 MLX5E_40GBASE_LR4 = 16,
564 MLX5E_100GBASE_CR4 = 20,
565 MLX5E_100GBASE_SR4 = 21,
566 MLX5E_100GBASE_KR4 = 22,
567 MLX5E_100GBASE_LR4 = 23,
568 MLX5E_100BASE_TX = 24,
569 MLX5E_100BASE_T = 25,
570 MLX5E_10GBASE_T = 26,
571 MLX5E_25GBASE_CR = 27,
572 MLX5E_25GBASE_KR = 28,
573 MLX5E_25GBASE_SR = 29,
574 MLX5E_50GBASE_CR2 = 30,
575 MLX5E_50GBASE_KR2 = 31,
576 MLX5E_LINK_MODES_NUMBER,
577};
578
579#define MLX5E_PROT_MASK(link_mode) (1 << link_mode)
580
12be4b21 581void mlx5e_send_nop(struct mlx5e_sq *sq, bool notify_hw);
f62b8bb8
AV
582u16 mlx5e_select_queue(struct net_device *dev, struct sk_buff *skb,
583 void *accel_priv, select_queue_fallback_t fallback);
584netdev_tx_t mlx5e_xmit(struct sk_buff *skb, struct net_device *dev);
f62b8bb8
AV
585
586void mlx5e_completion_event(struct mlx5_core_cq *mcq);
587void mlx5e_cq_error_event(struct mlx5_core_cq *mcq, enum mlx5_event event);
588int mlx5e_napi_poll(struct napi_struct *napi, int budget);
589bool mlx5e_poll_tx_cq(struct mlx5e_cq *cq);
44fb6fbb 590int mlx5e_poll_rx_cq(struct mlx5e_cq *cq, int budget);
f62b8bb8
AV
591bool mlx5e_post_rx_wqes(struct mlx5e_rq *rq);
592struct mlx5_cqe64 *mlx5e_get_cqe(struct mlx5e_cq *cq);
593
594void mlx5e_update_stats(struct mlx5e_priv *priv);
595
40ab6a6e
AS
596int mlx5e_create_flow_tables(struct mlx5e_priv *priv);
597void mlx5e_destroy_flow_tables(struct mlx5e_priv *priv);
f62b8bb8 598void mlx5e_init_eth_addr(struct mlx5e_priv *priv);
f62b8bb8
AV
599void mlx5e_set_rx_mode_work(struct work_struct *work);
600
ef9814de
EBE
601void mlx5e_fill_hwstamp(struct mlx5e_tstamp *clock, u64 timestamp,
602 struct skb_shared_hwtstamps *hwts);
603void mlx5e_timestamp_init(struct mlx5e_priv *priv);
604void mlx5e_timestamp_cleanup(struct mlx5e_priv *priv);
605int mlx5e_hwstamp_set(struct net_device *dev, struct ifreq *ifr);
606int mlx5e_hwstamp_get(struct net_device *dev, struct ifreq *ifr);
607
f62b8bb8
AV
608int mlx5e_vlan_rx_add_vid(struct net_device *dev, __always_unused __be16 proto,
609 u16 vid);
610int mlx5e_vlan_rx_kill_vid(struct net_device *dev, __always_unused __be16 proto,
611 u16 vid);
612void mlx5e_enable_vlan_filter(struct mlx5e_priv *priv);
613void mlx5e_disable_vlan_filter(struct mlx5e_priv *priv);
f62b8bb8 614
2d75b2bc
AS
615int mlx5e_redirect_rqt(struct mlx5e_priv *priv, enum mlx5e_rqt_ix rqt_ix);
616
f62b8bb8
AV
617int mlx5e_open_locked(struct net_device *netdev);
618int mlx5e_close_locked(struct net_device *netdev);
f62b8bb8
AV
619
620static inline void mlx5e_tx_notify_hw(struct mlx5e_sq *sq,
88a85f99 621 struct mlx5e_tx_wqe *wqe, int bf_sz)
f62b8bb8 622{
88a85f99
AS
623 u16 ofst = MLX5_BF_OFFSET + sq->bf_offset;
624
f62b8bb8
AV
625 /* ensure wqe is visible to device before updating doorbell record */
626 dma_wmb();
627
628 *sq->wq.db = cpu_to_be32(sq->pc);
629
630 /* ensure doorbell record is visible to device before ringing the
631 * doorbell
632 */
633 wmb();
634
88a85f99
AS
635 if (bf_sz) {
636 __iowrite64_copy(sq->uar_bf_map + ofst, &wqe->ctrl, bf_sz);
637
638 /* flush the write-combining mapped buffer */
639 wmb();
640
641 } else {
642 mlx5_write64((__be32 *)&wqe->ctrl, sq->uar_map + ofst, NULL);
643 }
f62b8bb8
AV
644
645 sq->bf_offset ^= sq->bf_buf_size;
646}
647
648static inline void mlx5e_cq_arm(struct mlx5e_cq *cq)
649{
650 struct mlx5_core_cq *mcq;
651
652 mcq = &cq->mcq;
653 mlx5_cq_arm(mcq, MLX5_CQ_DB_REQ_NOT, mcq->uar->map, NULL, cq->wq.cc);
654}
655
3435ab59
AS
656static inline int mlx5e_get_max_num_channels(struct mlx5_core_dev *mdev)
657{
658 return min_t(int, mdev->priv.eq_table.num_comp_vectors,
659 MLX5E_MAX_NUM_CHANNELS);
660}
661
f62b8bb8 662extern const struct ethtool_ops mlx5e_ethtool_ops;
58d52291 663u16 mlx5e_get_max_inline_cap(struct mlx5_core_dev *mdev);