2 * Copyright (c) 2015-2016, Mellanox Technologies. All rights reserved.
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:
10 * Redistribution and use in source and binary forms, with or
11 * without modification, are permitted provided that the following
14 * - Redistributions of source code must retain the above
15 * copyright notice, this list of conditions and the following
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.
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
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 <linux/rhashtable.h>
47 #include <net/switchdev.h>
49 #include "mlx5_core.h"
52 #define MLX5_SET_CFG(p, f, v) MLX5_SET(create_flow_group_in, p, f, v)
54 #define MLX5E_MAX_NUM_TC 8
56 #define MLX5E_PARAMS_MINIMUM_LOG_SQ_SIZE 0x6
57 #define MLX5E_PARAMS_DEFAULT_LOG_SQ_SIZE 0xa
58 #define MLX5E_PARAMS_MAXIMUM_LOG_SQ_SIZE 0xd
60 #define MLX5E_PARAMS_MINIMUM_LOG_RQ_SIZE 0x1
61 #define MLX5E_PARAMS_DEFAULT_LOG_RQ_SIZE 0xa
62 #define MLX5E_PARAMS_MAXIMUM_LOG_RQ_SIZE 0xd
64 #define MLX5E_PARAMS_MINIMUM_LOG_RQ_SIZE_MPW 0x1
65 #define MLX5E_PARAMS_DEFAULT_LOG_RQ_SIZE_MPW 0x3
66 #define MLX5E_PARAMS_MAXIMUM_LOG_RQ_SIZE_MPW 0x6
68 #define MLX5_RX_HEADROOM NET_SKB_PAD
70 #define MLX5_MPWRQ_LOG_STRIDE_SIZE 6 /* >= 6, HW restriction */
71 #define MLX5_MPWRQ_LOG_STRIDE_SIZE_CQE_COMPRESS 8 /* >= 6, HW restriction */
72 #define MLX5_MPWRQ_LOG_WQE_SZ 18
73 #define MLX5_MPWRQ_WQE_PAGE_ORDER (MLX5_MPWRQ_LOG_WQE_SZ - PAGE_SHIFT > 0 ? \
74 MLX5_MPWRQ_LOG_WQE_SZ - PAGE_SHIFT : 0)
75 #define MLX5_MPWRQ_PAGES_PER_WQE BIT(MLX5_MPWRQ_WQE_PAGE_ORDER)
76 #define MLX5_MPWRQ_STRIDES_PER_PAGE (MLX5_MPWRQ_NUM_STRIDES >> \
77 MLX5_MPWRQ_WQE_PAGE_ORDER)
79 #define MLX5_MTT_OCTW(npages) (ALIGN(npages, 8) / 2)
80 #define MLX5E_REQUIRED_MTTS(rqs, wqes)\
81 (rqs * wqes * ALIGN(MLX5_MPWRQ_PAGES_PER_WQE, 8))
82 #define MLX5E_VALID_NUM_MTTS(num_mtts) (MLX5_MTT_OCTW(num_mtts) <= U16_MAX)
84 #define MLX5_UMR_ALIGN (2048)
85 #define MLX5_MPWRQ_SMALL_PACKET_THRESHOLD (128)
87 #define MLX5E_PARAMS_DEFAULT_LRO_WQE_SZ (64 * 1024)
88 #define MLX5E_PARAMS_DEFAULT_RX_CQ_MODERATION_USEC 0x10
89 #define MLX5E_PARAMS_DEFAULT_RX_CQ_MODERATION_USEC_FROM_CQE 0x3
90 #define MLX5E_PARAMS_DEFAULT_RX_CQ_MODERATION_PKTS 0x20
91 #define MLX5E_PARAMS_DEFAULT_TX_CQ_MODERATION_USEC 0x10
92 #define MLX5E_PARAMS_DEFAULT_TX_CQ_MODERATION_PKTS 0x20
93 #define MLX5E_PARAMS_DEFAULT_MIN_RX_WQES 0x80
94 #define MLX5E_PARAMS_DEFAULT_MIN_RX_WQES_MPW 0x2
96 #define MLX5E_LOG_INDIR_RQT_SIZE 0x7
97 #define MLX5E_INDIR_RQT_SIZE BIT(MLX5E_LOG_INDIR_RQT_SIZE)
98 #define MLX5E_MAX_NUM_CHANNELS (MLX5E_INDIR_RQT_SIZE >> 1)
99 #define MLX5E_MAX_NUM_SQS (MLX5E_MAX_NUM_CHANNELS * MLX5E_MAX_NUM_TC)
100 #define MLX5E_TX_CQ_POLL_BUDGET 128
101 #define MLX5E_UPDATE_STATS_INTERVAL 200 /* msecs */
102 #define MLX5E_SQ_BF_BUDGET 16
104 #define MLX5E_NUM_MAIN_GROUPS 9
106 static inline u16 mlx5_min_rx_wqes(int wq_type, u32 wq_size)
109 case MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ:
110 return min_t(u16, MLX5E_PARAMS_DEFAULT_MIN_RX_WQES_MPW,
113 return min_t(u16, MLX5E_PARAMS_DEFAULT_MIN_RX_WQES,
118 static inline int mlx5_min_log_rq_size(int wq_type)
121 case MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ:
122 return MLX5E_PARAMS_MINIMUM_LOG_RQ_SIZE_MPW;
124 return MLX5E_PARAMS_MINIMUM_LOG_RQ_SIZE;
128 static inline int mlx5_max_log_rq_size(int wq_type)
131 case MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ:
132 return MLX5E_PARAMS_MAXIMUM_LOG_RQ_SIZE_MPW;
134 return MLX5E_PARAMS_MAXIMUM_LOG_RQ_SIZE;
139 MLX5E_INLINE_MODE_L2,
140 MLX5E_INLINE_MODE_VPORT_CONTEXT,
141 MLX5_INLINE_MODE_NOT_REQUIRED,
144 struct mlx5e_tx_wqe {
145 struct mlx5_wqe_ctrl_seg ctrl;
146 struct mlx5_wqe_eth_seg eth;
149 struct mlx5e_rx_wqe {
150 struct mlx5_wqe_srq_next_seg next;
151 struct mlx5_wqe_data_seg data;
154 struct mlx5e_umr_wqe {
155 struct mlx5_wqe_ctrl_seg ctrl;
156 struct mlx5_wqe_umr_ctrl_seg uctrl;
157 struct mlx5_mkey_seg mkc;
158 struct mlx5_wqe_data_seg data;
161 static const char mlx5e_priv_flags[][ETH_GSTRING_LEN] = {
165 enum mlx5e_priv_flag {
166 MLX5E_PFLAG_RX_CQE_BASED_MODER = (1 << 0),
169 #define MLX5E_SET_PRIV_FLAG(priv, pflag, enable) \
172 priv->pflags |= pflag; \
174 priv->pflags &= ~pflag; \
177 #ifdef CONFIG_MLX5_CORE_EN_DCB
178 #define MLX5E_MAX_BW_ALLOC 100 /* Max percentage of BW allocation */
181 struct mlx5e_cq_moder {
186 struct mlx5e_params {
189 u8 mpwqe_log_stride_sz;
190 u8 mpwqe_log_num_strides;
194 u8 rx_cq_period_mode;
195 bool rx_cqe_compress_admin;
196 bool rx_cqe_compress;
197 struct mlx5e_cq_moder rx_cq_moderation;
198 struct mlx5e_cq_moder tx_cq_moderation;
203 u8 tx_min_inline_mode;
205 u8 toeplitz_hash_key[40];
206 u32 indirection_rqt[MLX5E_INDIR_RQT_SIZE];
207 bool vlan_strip_disable;
208 #ifdef CONFIG_MLX5_CORE_EN_DCB
214 struct mlx5e_tstamp {
216 struct cyclecounter cycles;
217 struct timecounter clock;
218 struct hwtstamp_config hwtstamp_config;
220 unsigned long overflow_period;
221 struct delayed_work overflow_work;
222 struct mlx5_core_dev *mdev;
223 struct ptp_clock *ptp;
224 struct ptp_clock_info ptp_info;
228 MLX5E_RQ_STATE_FLUSH,
229 MLX5E_RQ_STATE_UMR_WQE_IN_PROGRESS,
234 /* data path - accessed per cqe */
237 /* data path - accessed per napi poll */
239 struct napi_struct *napi;
240 struct mlx5_core_cq mcq;
241 struct mlx5e_channel *channel;
242 struct mlx5e_priv *priv;
244 /* cqe decompression */
245 struct mlx5_cqe64 title;
246 struct mlx5_mini_cqe8 mini_arr[MLX5_MINI_CQE_ARRAY_SIZE];
249 u16 decmprs_wqe_counter;
252 struct mlx5_wq_ctrl wq_ctrl;
253 } ____cacheline_aligned_in_smp;
256 typedef void (*mlx5e_fp_handle_rx_cqe)(struct mlx5e_rq *rq,
257 struct mlx5_cqe64 *cqe);
258 typedef int (*mlx5e_fp_alloc_wqe)(struct mlx5e_rq *rq, struct mlx5e_rx_wqe *wqe,
261 typedef void (*mlx5e_fp_dealloc_wqe)(struct mlx5e_rq *rq, u16 ix);
263 struct mlx5e_dma_info {
268 struct mlx5e_rx_am_stats {
269 int ppms; /* packets per msec */
270 int epms; /* events per msec */
273 struct mlx5e_rx_am_sample {
275 unsigned int pkt_ctr;
279 struct mlx5e_rx_am { /* Adaptive Moderation */
281 struct mlx5e_rx_am_stats prev_stats;
282 struct mlx5e_rx_am_sample start_sample;
283 struct work_struct work;
292 /* a single cache unit is capable to serve one napi call (for non-striding rq)
293 * or a MPWQE (for striding rq).
295 #define MLX5E_CACHE_UNIT (MLX5_MPWRQ_PAGES_PER_WQE > NAPI_POLL_WEIGHT ? \
296 MLX5_MPWRQ_PAGES_PER_WQE : NAPI_POLL_WEIGHT)
297 #define MLX5E_CACHE_SIZE (2 * roundup_pow_of_two(MLX5E_CACHE_UNIT))
298 struct mlx5e_page_cache {
301 struct mlx5e_dma_info page_cache[MLX5E_CACHE_SIZE];
306 struct mlx5_wq_ll wq;
309 struct mlx5e_dma_info *dma_info;
311 struct mlx5e_mpw_info *info;
318 u32 wqe_sz; /* wqe data buffer size */
323 struct net_device *netdev;
324 struct mlx5e_tstamp *tstamp;
325 struct mlx5e_rq_stats stats;
327 struct mlx5e_page_cache page_cache;
329 mlx5e_fp_handle_rx_cqe handle_rx_cqe;
330 mlx5e_fp_alloc_wqe alloc_wqe;
331 mlx5e_fp_dealloc_wqe dealloc_wqe;
336 struct mlx5e_rx_am am; /* Adaptive Moderation */
337 struct bpf_prog *xdp_prog;
340 struct mlx5_wq_ctrl wq_ctrl;
343 u32 mpwqe_num_strides;
345 struct mlx5e_channel *channel;
346 struct mlx5e_priv *priv;
347 } ____cacheline_aligned_in_smp;
349 struct mlx5e_umr_dma_info {
352 struct mlx5e_dma_info dma_info[MLX5_MPWRQ_PAGES_PER_WQE];
353 struct mlx5e_umr_wqe wqe;
356 struct mlx5e_mpw_info {
357 struct mlx5e_umr_dma_info umr;
358 u16 consumed_strides;
359 u16 skbs_frags[MLX5_MPWRQ_PAGES_PER_WQE];
362 struct mlx5e_tx_wqe_info {
368 enum mlx5e_dma_map_type {
369 MLX5E_DMA_MAP_SINGLE,
373 struct mlx5e_sq_dma {
376 enum mlx5e_dma_map_type type;
380 MLX5E_SQ_STATE_FLUSH,
381 MLX5E_SQ_STATE_BF_ENABLE,
384 struct mlx5e_ico_wqe_info {
392 /* dirtied @completion */
397 u16 pc ____cacheline_aligned_in_smp;
402 struct mlx5e_sq_stats stats;
406 /* pointers to per packet info: write@xmit, read@completion */
407 struct sk_buff **skb;
408 struct mlx5e_sq_dma *dma_fifo;
409 struct mlx5e_tx_wqe_info *wqe_info;
412 struct mlx5_wq_cyc wq;
414 void __iomem *uar_map;
415 struct netdev_queue *txq;
422 struct mlx5e_tstamp *tstamp;
427 struct mlx5_wq_ctrl wq_ctrl;
429 struct mlx5e_channel *channel;
431 struct mlx5e_ico_wqe_info *ico_wqe_info;
433 } ____cacheline_aligned_in_smp;
435 static inline bool mlx5e_sq_has_room_for(struct mlx5e_sq *sq, u16 n)
437 return (((sq->wq.sz_m1 & (sq->cc - sq->pc)) >= n) ||
442 MLX5E_CHANNEL_NAPI_SCHED = 1,
445 struct mlx5e_channel {
448 struct mlx5e_sq sq[MLX5E_MAX_NUM_TC];
449 struct mlx5e_sq icosq; /* internal control operations */
450 struct napi_struct napi;
452 struct net_device *netdev;
458 struct mlx5e_priv *priv;
463 enum mlx5e_traffic_types {
468 MLX5E_TT_IPV4_IPSEC_AH,
469 MLX5E_TT_IPV6_IPSEC_AH,
470 MLX5E_TT_IPV4_IPSEC_ESP,
471 MLX5E_TT_IPV6_IPSEC_ESP,
476 MLX5E_NUM_INDIR_TIRS = MLX5E_TT_ANY,
480 MLX5E_STATE_ASYNC_EVENTS_ENABLED,
482 MLX5E_STATE_DESTROYING,
485 struct mlx5e_vxlan_db {
486 spinlock_t lock; /* protect vxlan table */
487 struct radix_tree_root tree;
490 struct mlx5e_l2_rule {
491 u8 addr[ETH_ALEN + 2];
492 struct mlx5_flow_rule *rule;
495 struct mlx5e_flow_table {
497 struct mlx5_flow_table *t;
498 struct mlx5_flow_group **g;
501 #define MLX5E_L2_ADDR_HASH_SIZE BIT(BITS_PER_BYTE)
503 struct mlx5e_tc_table {
504 struct mlx5_flow_table *t;
506 struct rhashtable_params ht_params;
507 struct rhashtable ht;
510 struct mlx5e_vlan_table {
511 struct mlx5e_flow_table ft;
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;
519 struct mlx5e_l2_table {
520 struct mlx5e_flow_table ft;
521 struct hlist_head netdev_uc[MLX5E_L2_ADDR_HASH_SIZE];
522 struct hlist_head netdev_mc[MLX5E_L2_ADDR_HASH_SIZE];
523 struct mlx5e_l2_rule broadcast;
524 struct mlx5e_l2_rule allmulti;
525 struct mlx5e_l2_rule promisc;
526 bool broadcast_enabled;
527 bool allmulti_enabled;
528 bool promisc_enabled;
531 /* L3/L4 traffic type classifier */
532 struct mlx5e_ttc_table {
533 struct mlx5e_flow_table ft;
534 struct mlx5_flow_rule *rules[MLX5E_NUM_TT];
537 #define ARFS_HASH_SHIFT BITS_PER_BYTE
538 #define ARFS_HASH_SIZE BIT(BITS_PER_BYTE)
540 struct mlx5e_flow_table ft;
541 struct mlx5_flow_rule *default_rule;
542 struct hlist_head rules_hash[ARFS_HASH_SIZE];
553 struct mlx5e_arfs_tables {
554 struct arfs_table arfs_tables[ARFS_NUM_TYPES];
555 /* Protect aRFS rules list */
556 spinlock_t arfs_lock;
557 struct list_head rules;
559 struct workqueue_struct *wq;
564 MLX5E_VLAN_FT_LEVEL = 0,
570 struct mlx5e_ethtool_table {
571 struct mlx5_flow_table *ft;
575 #define ETHTOOL_NUM_L3_L4_FTS 7
576 #define ETHTOOL_NUM_L2_FTS 4
578 struct mlx5e_ethtool_steering {
579 struct mlx5e_ethtool_table l3_l4_ft[ETHTOOL_NUM_L3_L4_FTS];
580 struct mlx5e_ethtool_table l2_ft[ETHTOOL_NUM_L2_FTS];
581 struct list_head rules;
585 struct mlx5e_flow_steering {
586 struct mlx5_flow_namespace *ns;
587 struct mlx5e_ethtool_steering ethtool;
588 struct mlx5e_tc_table tc;
589 struct mlx5e_vlan_table vlan;
590 struct mlx5e_l2_table l2;
591 struct mlx5e_ttc_table ttc;
592 struct mlx5e_arfs_tables arfs;
602 struct mlx5e_rqt rqt;
603 struct list_head list;
611 struct mlx5e_profile {
612 void (*init)(struct mlx5_core_dev *mdev,
613 struct net_device *netdev,
614 const struct mlx5e_profile *profile, void *ppriv);
615 void (*cleanup)(struct mlx5e_priv *priv);
616 int (*init_rx)(struct mlx5e_priv *priv);
617 void (*cleanup_rx)(struct mlx5e_priv *priv);
618 int (*init_tx)(struct mlx5e_priv *priv);
619 void (*cleanup_tx)(struct mlx5e_priv *priv);
620 void (*enable)(struct mlx5e_priv *priv);
621 void (*disable)(struct mlx5e_priv *priv);
622 void (*update_stats)(struct mlx5e_priv *priv);
623 int (*max_nch)(struct mlx5_core_dev *mdev);
628 /* priv data path fields - start */
629 struct mlx5e_sq **txq_to_sq_map;
630 int channeltc_to_txq_map[MLX5E_MAX_NUM_CHANNELS][MLX5E_MAX_NUM_TC];
631 struct bpf_prog *xdp_prog;
632 /* priv data path fields - end */
635 struct mutex state_lock; /* Protects Interface state */
636 struct mlx5_core_mkey umr_mkey;
637 struct mlx5e_rq drop_rq;
639 struct mlx5e_channel **channel;
640 u32 tisn[MLX5E_MAX_NUM_TC];
641 struct mlx5e_rqt indir_rqt;
642 struct mlx5e_tir indir_tir[MLX5E_NUM_INDIR_TIRS];
643 struct mlx5e_tir direct_tir[MLX5E_MAX_NUM_CHANNELS];
644 u32 tx_rates[MLX5E_MAX_NUM_SQS];
646 struct mlx5e_flow_steering fs;
647 struct mlx5e_vxlan_db vxlan;
649 struct mlx5e_params params;
650 struct workqueue_struct *wq;
651 struct work_struct update_carrier_work;
652 struct work_struct set_rx_mode_work;
653 struct work_struct tx_timeout_work;
654 struct delayed_work update_stats_work;
657 struct mlx5_core_dev *mdev;
658 struct net_device *netdev;
659 struct mlx5e_stats stats;
660 struct mlx5e_tstamp tstamp;
662 const struct mlx5e_profile *profile;
666 void mlx5e_build_ptys2ethtool_map(void);
668 void mlx5e_send_nop(struct mlx5e_sq *sq, bool notify_hw);
669 u16 mlx5e_select_queue(struct net_device *dev, struct sk_buff *skb,
670 void *accel_priv, select_queue_fallback_t fallback);
671 netdev_tx_t mlx5e_xmit(struct sk_buff *skb, struct net_device *dev);
673 void mlx5e_completion_event(struct mlx5_core_cq *mcq);
674 void mlx5e_cq_error_event(struct mlx5_core_cq *mcq, enum mlx5_event event);
675 int mlx5e_napi_poll(struct napi_struct *napi, int budget);
676 bool mlx5e_poll_tx_cq(struct mlx5e_cq *cq, int napi_budget);
677 int mlx5e_poll_rx_cq(struct mlx5e_cq *cq, int budget);
678 void mlx5e_free_tx_descs(struct mlx5e_sq *sq);
680 void mlx5e_page_release(struct mlx5e_rq *rq, struct mlx5e_dma_info *dma_info,
682 void mlx5e_handle_rx_cqe(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe);
683 void mlx5e_handle_rx_cqe_mpwrq(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe);
684 bool mlx5e_post_rx_wqes(struct mlx5e_rq *rq);
685 int mlx5e_alloc_rx_wqe(struct mlx5e_rq *rq, struct mlx5e_rx_wqe *wqe, u16 ix);
686 int mlx5e_alloc_rx_mpwqe(struct mlx5e_rq *rq, struct mlx5e_rx_wqe *wqe, u16 ix);
687 void mlx5e_dealloc_rx_wqe(struct mlx5e_rq *rq, u16 ix);
688 void mlx5e_dealloc_rx_mpwqe(struct mlx5e_rq *rq, u16 ix);
689 void mlx5e_post_rx_mpwqe(struct mlx5e_rq *rq);
690 void mlx5e_free_rx_mpwqe(struct mlx5e_rq *rq, struct mlx5e_mpw_info *wi);
691 struct mlx5_cqe64 *mlx5e_get_cqe(struct mlx5e_cq *cq);
693 void mlx5e_rx_am(struct mlx5e_rq *rq);
694 void mlx5e_rx_am_work(struct work_struct *work);
695 struct mlx5e_cq_moder mlx5e_am_get_def_profile(u8 rx_cq_period_mode);
697 void mlx5e_update_stats(struct mlx5e_priv *priv);
699 int mlx5e_create_flow_steering(struct mlx5e_priv *priv);
700 void mlx5e_destroy_flow_steering(struct mlx5e_priv *priv);
701 void mlx5e_init_l2_addr(struct mlx5e_priv *priv);
702 void mlx5e_destroy_flow_table(struct mlx5e_flow_table *ft);
703 int mlx5e_ethtool_get_flow(struct mlx5e_priv *priv, struct ethtool_rxnfc *info,
705 int mlx5e_ethtool_get_all_flows(struct mlx5e_priv *priv,
706 struct ethtool_rxnfc *info, u32 *rule_locs);
707 int mlx5e_ethtool_flow_replace(struct mlx5e_priv *priv,
708 struct ethtool_rx_flow_spec *fs);
709 int mlx5e_ethtool_flow_remove(struct mlx5e_priv *priv,
711 void mlx5e_ethtool_init_steering(struct mlx5e_priv *priv);
712 void mlx5e_ethtool_cleanup_steering(struct mlx5e_priv *priv);
713 void mlx5e_set_rx_mode_work(struct work_struct *work);
715 void mlx5e_fill_hwstamp(struct mlx5e_tstamp *clock, u64 timestamp,
716 struct skb_shared_hwtstamps *hwts);
717 void mlx5e_timestamp_init(struct mlx5e_priv *priv);
718 void mlx5e_timestamp_cleanup(struct mlx5e_priv *priv);
719 int mlx5e_hwstamp_set(struct net_device *dev, struct ifreq *ifr);
720 int mlx5e_hwstamp_get(struct net_device *dev, struct ifreq *ifr);
721 void mlx5e_modify_rx_cqe_compression(struct mlx5e_priv *priv, bool val);
723 int mlx5e_vlan_rx_add_vid(struct net_device *dev, __always_unused __be16 proto,
725 int mlx5e_vlan_rx_kill_vid(struct net_device *dev, __always_unused __be16 proto,
727 void mlx5e_enable_vlan_filter(struct mlx5e_priv *priv);
728 void mlx5e_disable_vlan_filter(struct mlx5e_priv *priv);
730 int mlx5e_modify_rqs_vsd(struct mlx5e_priv *priv, bool vsd);
732 int mlx5e_redirect_rqt(struct mlx5e_priv *priv, u32 rqtn, int sz, int ix);
733 void mlx5e_build_tir_ctx_hash(void *tirc, struct mlx5e_priv *priv);
735 int mlx5e_open_locked(struct net_device *netdev);
736 int mlx5e_close_locked(struct net_device *netdev);
737 void mlx5e_build_default_indir_rqt(struct mlx5_core_dev *mdev,
738 u32 *indirection_rqt, int len,
740 int mlx5e_get_max_linkspeed(struct mlx5_core_dev *mdev, u32 *speed);
742 void mlx5e_set_rx_cq_mode_params(struct mlx5e_params *params,
745 static inline void mlx5e_tx_notify_hw(struct mlx5e_sq *sq,
746 struct mlx5_wqe_ctrl_seg *ctrl, int bf_sz)
748 u16 ofst = MLX5_BF_OFFSET + sq->bf_offset;
750 /* ensure wqe is visible to device before updating doorbell record */
753 *sq->wq.db = cpu_to_be32(sq->pc);
755 /* ensure doorbell record is visible to device before ringing the
760 __iowrite64_copy(sq->uar_map + ofst, ctrl, bf_sz);
762 mlx5_write64((__be32 *)ctrl, sq->uar_map + ofst, NULL);
763 /* flush the write-combining mapped buffer */
766 sq->bf_offset ^= sq->bf_buf_size;
769 static inline void mlx5e_cq_arm(struct mlx5e_cq *cq)
771 struct mlx5_core_cq *mcq;
774 mlx5_cq_arm(mcq, MLX5_CQ_DB_REQ_NOT, mcq->uar->map, NULL, cq->wq.cc);
777 static inline u32 mlx5e_get_wqe_mtt_offset(struct mlx5e_rq *rq, u16 wqe_ix)
779 return rq->mpwqe.mtt_offset +
780 wqe_ix * ALIGN(MLX5_MPWRQ_PAGES_PER_WQE, 8);
783 static inline int mlx5e_get_max_num_channels(struct mlx5_core_dev *mdev)
785 return min_t(int, mdev->priv.eq_table.num_comp_vectors,
786 MLX5E_MAX_NUM_CHANNELS);
789 extern const struct ethtool_ops mlx5e_ethtool_ops;
790 #ifdef CONFIG_MLX5_CORE_EN_DCB
791 extern const struct dcbnl_rtnl_ops mlx5e_dcbnl_ops;
792 int mlx5e_dcbnl_ieee_setets_core(struct mlx5e_priv *priv, struct ieee_ets *ets);
795 #ifndef CONFIG_RFS_ACCEL
796 static inline int mlx5e_arfs_create_tables(struct mlx5e_priv *priv)
801 static inline void mlx5e_arfs_destroy_tables(struct mlx5e_priv *priv) {}
803 static inline int mlx5e_arfs_enable(struct mlx5e_priv *priv)
808 static inline int mlx5e_arfs_disable(struct mlx5e_priv *priv)
813 int mlx5e_arfs_create_tables(struct mlx5e_priv *priv);
814 void mlx5e_arfs_destroy_tables(struct mlx5e_priv *priv);
815 int mlx5e_arfs_enable(struct mlx5e_priv *priv);
816 int mlx5e_arfs_disable(struct mlx5e_priv *priv);
817 int mlx5e_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb,
818 u16 rxq_index, u32 flow_id);
821 u16 mlx5e_get_max_inline_cap(struct mlx5_core_dev *mdev);
822 int mlx5e_create_tir(struct mlx5_core_dev *mdev,
823 struct mlx5e_tir *tir, u32 *in, int inlen);
824 void mlx5e_destroy_tir(struct mlx5_core_dev *mdev,
825 struct mlx5e_tir *tir);
826 int mlx5e_create_mdev_resources(struct mlx5_core_dev *mdev);
827 void mlx5e_destroy_mdev_resources(struct mlx5_core_dev *mdev);
828 int mlx5e_refresh_tirs_self_loopback_enable(struct mlx5_core_dev *mdev);
830 struct mlx5_eswitch_rep;
831 int mlx5e_vport_rep_load(struct mlx5_eswitch *esw,
832 struct mlx5_eswitch_rep *rep);
833 void mlx5e_vport_rep_unload(struct mlx5_eswitch *esw,
834 struct mlx5_eswitch_rep *rep);
835 int mlx5e_nic_rep_load(struct mlx5_eswitch *esw, struct mlx5_eswitch_rep *rep);
836 void mlx5e_nic_rep_unload(struct mlx5_eswitch *esw,
837 struct mlx5_eswitch_rep *rep);
838 int mlx5e_add_sqs_fwd_rules(struct mlx5e_priv *priv);
839 void mlx5e_remove_sqs_fwd_rules(struct mlx5e_priv *priv);
840 int mlx5e_attr_get(struct net_device *dev, struct switchdev_attr *attr);
842 int mlx5e_create_direct_rqts(struct mlx5e_priv *priv);
843 void mlx5e_destroy_rqt(struct mlx5e_priv *priv, struct mlx5e_rqt *rqt);
844 int mlx5e_create_direct_tirs(struct mlx5e_priv *priv);
845 void mlx5e_destroy_direct_tirs(struct mlx5e_priv *priv);
846 int mlx5e_create_tises(struct mlx5e_priv *priv);
847 void mlx5e_cleanup_nic_tx(struct mlx5e_priv *priv);
848 int mlx5e_close(struct net_device *netdev);
849 int mlx5e_open(struct net_device *netdev);
850 void mlx5e_update_stats_work(struct work_struct *work);
851 struct net_device *mlx5e_create_netdev(struct mlx5_core_dev *mdev,
852 const struct mlx5e_profile *profile,
854 void mlx5e_destroy_netdev(struct mlx5_core_dev *mdev, struct mlx5e_priv *priv);
855 int mlx5e_attach_netdev(struct mlx5_core_dev *mdev, struct net_device *netdev);
856 void mlx5e_detach_netdev(struct mlx5_core_dev *mdev, struct net_device *netdev);
857 struct rtnl_link_stats64 *
858 mlx5e_get_stats(struct net_device *dev, struct rtnl_link_stats64 *stats);
860 #endif /* __MLX5_EN_H__ */