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