#ifndef __MLX5_EN_H__
#define __MLX5_EN_H__
#include <linux/if_vlan.h>
#include <linux/etherdevice.h>
#include <linux/timecounter.h>
#include <linux/net_tstamp.h>
#include <linux/crash_dump.h>
#include <linux/mlx5/driver.h>
#include <linux/mlx5/qp.h>
#include <linux/mlx5/cq.h>
#include <linux/mlx5/port.h>
#include <linux/mlx5/vport.h>
#include <linux/mlx5/transobj.h>
#include <linux/mlx5/fs.h>
#include <linux/rhashtable.h>
#include <net/udp_tunnel.h>
#include <net/switchdev.h>
#include <net/xdp.h>
#include <linux/dim.h>
#include <linux/bits.h>
#include "wq.h"
#include "mlx5_core.h"
#include "en_stats.h"
#include "en/dcbnl.h"
#include "en/fs.h"
#include "en/qos.h"
#include "lib/hv_vhca.h"
#include "lib/clock.h"
#include "en/rx_res.h"
#include "en/selq.h"
#include "lib/sd.h"
extern const struct net_device_ops mlx5e_netdev_ops;
struct page_pool;
#define MLX5E_METADATA_ETHER_TYPE …
#define MLX5E_METADATA_ETHER_LEN …
#define MLX5E_ETH_HARD_MTU …
#define MLX5E_HW2SW_MTU(params, hwmtu) …
#define MLX5E_SW2HW_MTU(params, swmtu) …
#define MLX5E_MAX_NUM_MQPRIO_CH_TC …
#define MLX5_RX_HEADROOM …
#define MLX5_SKB_FRAG_SZ(len) …
#define MLX5E_RX_MAX_HEAD …
#define MLX5E_SHAMPO_LOG_HEADER_ENTRY_SIZE …
#define MLX5E_SHAMPO_LOG_MAX_HEADER_ENTRY_SIZE …
#define MLX5E_SHAMPO_WQ_HEADER_PER_PAGE …
#define MLX5E_SHAMPO_WQ_BASE_HEAD_ENTRY_SIZE …
#define MLX5E_SHAMPO_WQ_RESRV_SIZE …
#define MLX5E_SHAMPO_WQ_BASE_RESRV_SIZE …
#define MLX5_MPWRQ_MIN_LOG_STRIDE_SZ(mdev) …
#define MLX5_MPWRQ_LOG_STRIDE_SZ(mdev, req) …
#define MLX5_MPWRQ_DEF_LOG_STRIDE_SZ(mdev) …
#define MLX5_MPWRQ_MAX_LOG_WQE_SZ …
#define MLX5_UMR_MAX_FLEX_SPACE …
#define MLX5_MPWRQ_MAX_PAGES_PER_WQE …
#define MLX5E_MAX_RQ_NUM_MTTS …
#define MLX5E_MAX_RQ_NUM_KSMS …
#define MLX5E_ORDER2_MAX_PACKET_MTU …
#define MLX5E_MIN_SKB_FRAG_SZ …
#define MLX5E_LOG_MAX_RX_WQE_BULK …
#define MLX5E_PARAMS_MINIMUM_LOG_SQ_SIZE …
#define MLX5E_PARAMS_DEFAULT_LOG_SQ_SIZE …
#define MLX5E_PARAMS_MAXIMUM_LOG_SQ_SIZE …
#define MLX5E_PARAMS_MINIMUM_LOG_RQ_SIZE …
#define MLX5E_PARAMS_DEFAULT_LOG_RQ_SIZE …
#define MLX5E_PARAMS_MAXIMUM_LOG_RQ_SIZE …
#define MLX5E_PARAMS_MINIMUM_LOG_RQ_SIZE_MPW …
#define MLX5E_DEFAULT_LRO_TIMEOUT …
#define MLX5E_LRO_TIMEOUT_ARR_SIZE …
#define MLX5E_PARAMS_DEFAULT_RX_CQ_MODERATION_USEC …
#define MLX5E_PARAMS_DEFAULT_RX_CQ_MODERATION_USEC_FROM_CQE …
#define MLX5E_PARAMS_DEFAULT_RX_CQ_MODERATION_PKTS …
#define MLX5E_PARAMS_DEFAULT_TX_CQ_MODERATION_USEC …
#define MLX5E_PARAMS_DEFAULT_TX_CQ_MODERATION_USEC_FROM_CQE …
#define MLX5E_PARAMS_DEFAULT_TX_CQ_MODERATION_PKTS …
#define MLX5E_PARAMS_DEFAULT_MIN_RX_WQES …
#define MLX5E_PARAMS_DEFAULT_MIN_RX_WQES_MPW …
#define MLX5E_MIN_NUM_CHANNELS …
#define MLX5E_MAX_NUM_CHANNELS …
#define MLX5E_TX_CQ_POLL_BUDGET …
#define MLX5E_TX_XSK_POLL_BUDGET …
#define MLX5E_SQ_RECOVER_MIN_INTERVAL …
#define mlx5e_state_dereference(priv, p) …
enum mlx5e_devcom_events { … };
static inline u8 mlx5e_get_num_lag_ports(struct mlx5_core_dev *mdev)
{ … }
static inline u16 mlx5_min_rx_wqes(int wq_type, u32 wq_size)
{ … }
static inline int mlx5e_get_max_num_channels(struct mlx5_core_dev *mdev)
{ … }
static inline u8 mlx5e_get_max_sq_wqebbs(struct mlx5_core_dev *mdev)
{ … }
static inline u8 mlx5e_get_max_sq_aligned_wqebbs(struct mlx5_core_dev *mdev)
{ … }
struct mlx5e_tx_wqe { … };
struct mlx5e_rx_wqe_ll { … };
struct mlx5e_rx_wqe_cyc { … };
struct mlx5e_umr_wqe { … };
enum mlx5e_priv_flag { … };
#define MLX5E_SET_PFLAG(params, pflag, enable) …
#define MLX5E_GET_PFLAG(params, pflag) …
enum packet_merge { … };
struct mlx5e_packet_merge_param { … };
struct mlx5e_params { … };
static inline u8 mlx5e_get_dcb_num_tc(struct mlx5e_params *params)
{ … }
enum { … };
struct mlx5e_cq { … } ____cacheline_aligned_in_smp;
struct mlx5e_cq_decomp { … } ____cacheline_aligned_in_smp;
enum mlx5e_dma_map_type { … };
struct mlx5e_sq_dma { … };
enum { … };
struct mlx5e_tx_mpwqe { … };
struct mlx5e_skb_fifo { … };
struct mlx5e_ptpsq;
struct mlx5e_txqsq { … } ____cacheline_aligned_in_smp;
struct mlx5e_xdp_info_fifo { … };
struct mlx5e_xdpsq;
struct mlx5e_xmit_data;
struct xsk_tx_metadata;
mlx5e_fp_xmit_xdp_frame_check;
mlx5e_fp_xmit_xdp_frame;
struct mlx5e_xdpsq { … } ____cacheline_aligned_in_smp;
struct mlx5e_ktls_resync_resp;
struct mlx5e_icosq { … } ____cacheline_aligned_in_smp;
struct mlx5e_frag_page { … };
enum mlx5e_wqe_frag_flag { … };
struct mlx5e_wqe_frag_info { … };
mlx5e_alloc_units;
struct mlx5e_mpw_info { … };
#define MLX5E_MAX_RX_FRAGS …
struct mlx5e_rq;
mlx5e_fp_handle_rx_cqe;
mlx5e_fp_skb_from_cqe_mpwrq;
mlx5e_fp_skb_from_cqe;
mlx5e_fp_post_rx_wqes;
mlx5e_fp_dealloc_wqe;
mlx5e_fp_shampo_dealloc_hd;
int mlx5e_rq_set_handlers(struct mlx5e_rq *rq, struct mlx5e_params *params, bool xsk);
void mlx5e_rq_set_trap_handlers(struct mlx5e_rq *rq, struct mlx5e_params *params);
enum mlx5e_rq_flag { … };
struct mlx5e_rq_frag_info { … };
struct mlx5e_rq_frags_info { … };
struct mlx5e_dma_info { … };
struct mlx5e_shampo_hd { … };
struct mlx5e_hw_gro_data { … };
enum mlx5e_mpwrq_umr_mode { … };
struct mlx5e_rq { … } ____cacheline_aligned_in_smp;
enum mlx5e_channel_state { … };
struct mlx5e_channel { … };
struct mlx5e_ptp;
struct mlx5e_channels { … };
struct mlx5e_channel_stats { … } ____cacheline_aligned_in_smp;
struct mlx5e_ptp_stats { … } ____cacheline_aligned_in_smp;
enum { … };
struct mlx5e_modify_sq_param { … };
#if IS_ENABLED(CONFIG_PCI_HYPERV_INTERFACE)
struct mlx5e_hv_vhca_stats_agent { … };
#endif
struct mlx5e_xsk { … };
struct mlx5e_scratchpad { … };
struct mlx5e_trap;
struct mlx5e_htb;
struct mlx5e_priv { … };
struct mlx5e_dev { … };
struct mlx5e_rx_handlers { … };
extern const struct mlx5e_rx_handlers mlx5e_rx_handlers_nic;
enum mlx5e_profile_feature { … };
struct mlx5e_profile { … };
u32 mlx5e_profile_get_tisn(struct mlx5_core_dev *mdev,
struct mlx5e_priv *priv,
const struct mlx5e_profile *profile,
u8 lag_port, u8 tc);
#define mlx5e_profile_feature_cap(profile, feature) …
void mlx5e_build_ptys2ethtool_map(void);
bool mlx5e_check_fragmented_striding_rq_cap(struct mlx5_core_dev *mdev, u8 page_shift,
enum mlx5e_mpwrq_umr_mode umr_mode);
void mlx5e_shampo_dealloc_hd(struct mlx5e_rq *rq);
void mlx5e_get_stats(struct net_device *dev, struct rtnl_link_stats64 *stats);
void mlx5e_fold_sw_stats64(struct mlx5e_priv *priv, struct rtnl_link_stats64 *s);
int mlx5e_self_test_num(struct mlx5e_priv *priv);
int mlx5e_self_test_fill_strings(struct mlx5e_priv *priv, u8 *data);
void mlx5e_self_test(struct net_device *ndev, struct ethtool_test *etest,
u64 *buf);
void mlx5e_set_rx_mode_work(struct work_struct *work);
int mlx5e_hwstamp_set(struct mlx5e_priv *priv, struct ifreq *ifr);
int mlx5e_hwstamp_get(struct mlx5e_priv *priv, struct ifreq *ifr);
int mlx5e_modify_rx_cqe_compression_locked(struct mlx5e_priv *priv, bool val, bool rx_filter);
int mlx5e_vlan_rx_add_vid(struct net_device *dev, __always_unused __be16 proto,
u16 vid);
int mlx5e_vlan_rx_kill_vid(struct net_device *dev, __always_unused __be16 proto,
u16 vid);
void mlx5e_timestamp_init(struct mlx5e_priv *priv);
struct mlx5e_xsk_param;
struct mlx5e_rq_param;
int mlx5e_open_rq(struct mlx5e_params *params, struct mlx5e_rq_param *param,
struct mlx5e_xsk_param *xsk, int node, u16 q_counter,
struct mlx5e_rq *rq);
#define MLX5E_RQ_WQES_TIMEOUT …
int mlx5e_wait_for_min_rx_wqes(struct mlx5e_rq *rq, int wait_time);
void mlx5e_close_rq(struct mlx5e_rq *rq);
int mlx5e_create_rq(struct mlx5e_rq *rq, struct mlx5e_rq_param *param, u16 q_counter);
void mlx5e_destroy_rq(struct mlx5e_rq *rq);
bool mlx5e_reset_rx_moderation(struct dim_cq_moder *cq_moder, u8 cq_period_mode,
bool dim_enabled);
bool mlx5e_reset_rx_channels_moderation(struct mlx5e_channels *chs, u8 cq_period_mode,
bool dim_enabled, bool keep_dim_state);
struct mlx5e_sq_param;
int mlx5e_open_xdpsq(struct mlx5e_channel *c, struct mlx5e_params *params,
struct mlx5e_sq_param *param, struct xsk_buff_pool *xsk_pool,
struct mlx5e_xdpsq *sq, bool is_redirect);
void mlx5e_close_xdpsq(struct mlx5e_xdpsq *sq);
struct mlx5e_create_cq_param { … };
struct mlx5e_cq_param;
int mlx5e_open_cq(struct mlx5_core_dev *mdev, struct dim_cq_moder moder,
struct mlx5e_cq_param *param, struct mlx5e_create_cq_param *ccp,
struct mlx5e_cq *cq);
void mlx5e_close_cq(struct mlx5e_cq *cq);
int mlx5e_modify_cq_period_mode(struct mlx5_core_dev *dev, struct mlx5_core_cq *cq,
u8 cq_period_mode);
int mlx5e_modify_cq_moderation(struct mlx5_core_dev *dev, struct mlx5_core_cq *cq,
u16 cq_period, u16 cq_max_count, u8 cq_period_mode);
int mlx5e_open_locked(struct net_device *netdev);
int mlx5e_close_locked(struct net_device *netdev);
void mlx5e_trigger_napi_icosq(struct mlx5e_channel *c);
void mlx5e_trigger_napi_sched(struct napi_struct *napi);
int mlx5e_open_channels(struct mlx5e_priv *priv,
struct mlx5e_channels *chs);
void mlx5e_close_channels(struct mlx5e_channels *chs);
mlx5e_fp_preactivate;
#define MLX5E_DEFINE_PREACTIVATE_WRAPPER_CTX(fn) …
int mlx5e_safe_reopen_channels(struct mlx5e_priv *priv);
int mlx5e_safe_switch_params(struct mlx5e_priv *priv,
struct mlx5e_params *new_params,
mlx5e_fp_preactivate preactivate,
void *context, bool reset);
int mlx5e_update_tx_netdev_queues(struct mlx5e_priv *priv);
int mlx5e_num_channels_changed_ctx(struct mlx5e_priv *priv, void *context);
int mlx5e_update_tc_and_tx_queues_ctx(struct mlx5e_priv *priv, void *context);
void mlx5e_activate_priv_channels(struct mlx5e_priv *priv);
void mlx5e_deactivate_priv_channels(struct mlx5e_priv *priv);
int mlx5e_ptp_rx_manage_fs_ctx(struct mlx5e_priv *priv, void *ctx);
int mlx5e_flush_rq(struct mlx5e_rq *rq, int curr_state);
void mlx5e_activate_rq(struct mlx5e_rq *rq);
void mlx5e_deactivate_rq(struct mlx5e_rq *rq);
void mlx5e_activate_icosq(struct mlx5e_icosq *icosq);
void mlx5e_deactivate_icosq(struct mlx5e_icosq *icosq);
int mlx5e_modify_sq(struct mlx5_core_dev *mdev, u32 sqn,
struct mlx5e_modify_sq_param *p);
int mlx5e_open_txqsq(struct mlx5e_channel *c, u32 tisn, int txq_ix,
struct mlx5e_params *params, struct mlx5e_sq_param *param,
struct mlx5e_txqsq *sq, int tc, u16 qos_queue_group_id,
struct mlx5e_sq_stats *sq_stats);
void mlx5e_activate_txqsq(struct mlx5e_txqsq *sq);
void mlx5e_deactivate_txqsq(struct mlx5e_txqsq *sq);
void mlx5e_free_txqsq(struct mlx5e_txqsq *sq);
void mlx5e_tx_disable_queue(struct netdev_queue *txq);
int mlx5e_alloc_txqsq_db(struct mlx5e_txqsq *sq, int numa);
void mlx5e_free_txqsq_db(struct mlx5e_txqsq *sq);
struct mlx5e_create_sq_param;
int mlx5e_create_sq_rdy(struct mlx5_core_dev *mdev,
struct mlx5e_sq_param *param,
struct mlx5e_create_sq_param *csp,
u16 qos_queue_group_id,
u32 *sqn);
void mlx5e_tx_err_cqe_work(struct work_struct *recover_work);
void mlx5e_close_txqsq(struct mlx5e_txqsq *sq);
bool mlx5e_reset_tx_moderation(struct dim_cq_moder *cq_moder, u8 cq_period_mode,
bool dim_enabled);
bool mlx5e_reset_tx_channels_moderation(struct mlx5e_channels *chs, u8 cq_period_mode,
bool dim_enabled, bool keep_dim_state);
static inline bool mlx5_tx_swp_supported(struct mlx5_core_dev *mdev)
{ … }
extern const struct ethtool_ops mlx5e_ethtool_ops;
int mlx5e_create_mkey(struct mlx5_core_dev *mdev, u32 pdn, u32 *mkey);
int mlx5e_create_mdev_resources(struct mlx5_core_dev *mdev, bool create_tises);
void mlx5e_destroy_mdev_resources(struct mlx5_core_dev *mdev);
int mlx5e_refresh_tirs(struct mlx5e_priv *priv, bool enable_uc_lb,
bool enable_mc_lb);
void mlx5e_mkey_set_relaxed_ordering(struct mlx5_core_dev *mdev, void *mkc);
void mlx5e_create_q_counters(struct mlx5e_priv *priv);
void mlx5e_destroy_q_counters(struct mlx5e_priv *priv);
int mlx5e_open_drop_rq(struct mlx5e_priv *priv,
struct mlx5e_rq *drop_rq);
void mlx5e_close_drop_rq(struct mlx5e_rq *drop_rq);
int mlx5e_create_tis(struct mlx5_core_dev *mdev, void *in, u32 *tisn);
void mlx5e_destroy_tis(struct mlx5_core_dev *mdev, u32 tisn);
void mlx5e_update_carrier(struct mlx5e_priv *priv);
int mlx5e_close(struct net_device *netdev);
int mlx5e_open(struct net_device *netdev);
void mlx5e_queue_update_stats(struct mlx5e_priv *priv);
int mlx5e_set_dev_port_mtu(struct mlx5e_priv *priv);
int mlx5e_set_dev_port_mtu_ctx(struct mlx5e_priv *priv, void *context);
int mlx5e_change_mtu(struct net_device *netdev, int new_mtu,
mlx5e_fp_preactivate preactivate);
void mlx5e_vxlan_set_netdev_info(struct mlx5e_priv *priv);
void mlx5e_ethtool_get_drvinfo(struct mlx5e_priv *priv,
struct ethtool_drvinfo *drvinfo);
void mlx5e_ethtool_get_strings(struct mlx5e_priv *priv,
u32 stringset, u8 *data);
int mlx5e_ethtool_get_sset_count(struct mlx5e_priv *priv, int sset);
void mlx5e_ethtool_get_ethtool_stats(struct mlx5e_priv *priv,
struct ethtool_stats *stats, u64 *data);
void mlx5e_ethtool_get_ringparam(struct mlx5e_priv *priv,
struct ethtool_ringparam *param,
struct kernel_ethtool_ringparam *kernel_param);
int mlx5e_ethtool_set_ringparam(struct mlx5e_priv *priv,
struct ethtool_ringparam *param);
void mlx5e_ethtool_get_channels(struct mlx5e_priv *priv,
struct ethtool_channels *ch);
int mlx5e_ethtool_set_channels(struct mlx5e_priv *priv,
struct ethtool_channels *ch);
int mlx5e_ethtool_get_coalesce(struct mlx5e_priv *priv,
struct ethtool_coalesce *coal,
struct kernel_ethtool_coalesce *kernel_coal);
int mlx5e_ethtool_set_coalesce(struct mlx5e_priv *priv,
struct ethtool_coalesce *coal,
struct kernel_ethtool_coalesce *kernel_coal,
struct netlink_ext_ack *extack);
int mlx5e_get_per_queue_coalesce(struct net_device *dev, u32 queue,
struct ethtool_coalesce *coal);
int mlx5e_set_per_queue_coalesce(struct net_device *dev, u32 queue,
struct ethtool_coalesce *coal);
u32 mlx5e_ethtool_get_rxfh_key_size(struct mlx5e_priv *priv);
u32 mlx5e_ethtool_get_rxfh_indir_size(struct mlx5e_priv *priv);
int mlx5e_ethtool_get_ts_info(struct mlx5e_priv *priv,
struct kernel_ethtool_ts_info *info);
int mlx5e_ethtool_flash_device(struct mlx5e_priv *priv,
struct ethtool_flash *flash);
static inline bool
mlx5e_tx_mpwqe_supported(struct mlx5_core_dev *mdev)
{ … }
int mlx5e_get_pf_num_tirs(struct mlx5_core_dev *mdev);
int mlx5e_priv_init(struct mlx5e_priv *priv,
const struct mlx5e_profile *profile,
struct net_device *netdev,
struct mlx5_core_dev *mdev);
void mlx5e_priv_cleanup(struct mlx5e_priv *priv);
struct net_device *
mlx5e_create_netdev(struct mlx5_core_dev *mdev, const struct mlx5e_profile *profile);
int mlx5e_attach_netdev(struct mlx5e_priv *priv);
void mlx5e_detach_netdev(struct mlx5e_priv *priv);
void mlx5e_destroy_netdev(struct mlx5e_priv *priv);
int mlx5e_netdev_change_profile(struct mlx5e_priv *priv,
const struct mlx5e_profile *new_profile, void *new_ppriv);
void mlx5e_netdev_attach_nic_profile(struct mlx5e_priv *priv);
void mlx5e_set_netdev_mtu_boundaries(struct mlx5e_priv *priv);
void mlx5e_build_nic_params(struct mlx5e_priv *priv, struct mlx5e_xsk *xsk, u16 mtu);
void mlx5e_set_xdp_feature(struct net_device *netdev);
netdev_features_t mlx5e_features_check(struct sk_buff *skb,
struct net_device *netdev,
netdev_features_t features);
int mlx5e_set_features(struct net_device *netdev, netdev_features_t features);
#ifdef CONFIG_MLX5_ESWITCH
int mlx5e_set_vf_mac(struct net_device *dev, int vf, u8 *mac);
int mlx5e_set_vf_rate(struct net_device *dev, int vf, int min_tx_rate, int max_tx_rate);
int mlx5e_get_vf_config(struct net_device *dev, int vf, struct ifla_vf_info *ivi);
int mlx5e_get_vf_stats(struct net_device *dev, int vf, struct ifla_vf_stats *vf_stats);
#endif
int mlx5e_create_mkey(struct mlx5_core_dev *mdev, u32 pdn, u32 *mkey);
#endif