#include <linux/bpf.h>
#include <linux/etherdevice.h>
#include <linux/filter.h>
#include <linux/tcp.h>
#include <linux/if_vlan.h>
#include <linux/delay.h>
#include <linux/slab.h>
#include <linux/hash.h>
#include <net/ip.h>
#include <net/vxlan.h>
#include <net/devlink.h>
#include <net/rps.h>
#include <net/netdev_queues.h>
#include <linux/mlx4/driver.h>
#include <linux/mlx4/device.h>
#include <linux/mlx4/cmd.h>
#include <linux/mlx4/cq.h>
#include "mlx4_en.h"
#include "en_port.h"
#define MLX4_EN_MAX_XDP_MTU …
int mlx4_en_setup_tc(struct net_device *dev, u8 up)
{ … }
int mlx4_en_alloc_tx_queue_per_tc(struct net_device *dev, u8 tc)
{ … }
static int __mlx4_en_setup_tc(struct net_device *dev, enum tc_setup_type type,
void *type_data)
{ … }
#ifdef CONFIG_RFS_ACCEL
struct mlx4_en_filter { … };
static void mlx4_en_filter_rfs_expire(struct mlx4_en_priv *priv);
static enum mlx4_net_trans_rule_id mlx4_ip_proto_to_trans_rule_id(u8 ip_proto)
{
switch (ip_proto) {
case IPPROTO_UDP:
return MLX4_NET_TRANS_RULE_ID_UDP;
case IPPROTO_TCP:
return MLX4_NET_TRANS_RULE_ID_TCP;
default:
return MLX4_NET_TRANS_RULE_NUM;
}
};
static void mlx4_en_filter_work(struct work_struct *work)
{ … }
static inline struct hlist_head *
filter_hash_bucket(struct mlx4_en_priv *priv, __be32 src_ip, __be32 dst_ip,
__be16 src_port, __be16 dst_port)
{ … }
static struct mlx4_en_filter *
mlx4_en_filter_alloc(struct mlx4_en_priv *priv, int rxq_index, __be32 src_ip,
__be32 dst_ip, u8 ip_proto, __be16 src_port,
__be16 dst_port, u32 flow_id)
{ … }
static void mlx4_en_filter_free(struct mlx4_en_filter *filter)
{ … }
static inline struct mlx4_en_filter *
mlx4_en_filter_find(struct mlx4_en_priv *priv, __be32 src_ip, __be32 dst_ip,
u8 ip_proto, __be16 src_port, __be16 dst_port)
{ … }
static int
mlx4_en_filter_rfs(struct net_device *net_dev, const struct sk_buff *skb,
u16 rxq_index, u32 flow_id)
{ … }
void mlx4_en_cleanup_filters(struct mlx4_en_priv *priv)
{ … }
static void mlx4_en_filter_rfs_expire(struct mlx4_en_priv *priv)
{ … }
#endif
static int mlx4_en_vlan_rx_add_vid(struct net_device *dev,
__be16 proto, u16 vid)
{ … }
static int mlx4_en_vlan_rx_kill_vid(struct net_device *dev,
__be16 proto, u16 vid)
{ … }
static void mlx4_en_u64_to_mac(struct net_device *dev, u64 src_mac)
{ … }
static int mlx4_en_tunnel_steer_add(struct mlx4_en_priv *priv,
const unsigned char *addr,
int qpn, u64 *reg_id)
{ … }
static int mlx4_en_uc_steer_add(struct mlx4_en_priv *priv,
const unsigned char *mac, int *qpn, u64 *reg_id)
{ … }
static void mlx4_en_uc_steer_release(struct mlx4_en_priv *priv,
const unsigned char *mac,
int qpn, u64 reg_id)
{ … }
static int mlx4_en_get_qp(struct mlx4_en_priv *priv)
{ … }
static void mlx4_en_put_qp(struct mlx4_en_priv *priv)
{ … }
static int mlx4_en_replace_mac(struct mlx4_en_priv *priv, int qpn,
unsigned char *new_mac, unsigned char *prev_mac)
{ … }
static void mlx4_en_update_user_mac(struct mlx4_en_priv *priv,
unsigned char new_mac[ETH_ALEN + 2])
{ … }
static int mlx4_en_do_set_mac(struct mlx4_en_priv *priv,
unsigned char new_mac[ETH_ALEN + 2])
{ … }
static int mlx4_en_set_mac(struct net_device *dev, void *addr)
{ … }
static void mlx4_en_clear_list(struct net_device *dev)
{ … }
static void mlx4_en_cache_mclist(struct net_device *dev)
{ … }
static void update_mclist_flags(struct mlx4_en_priv *priv,
struct list_head *dst,
struct list_head *src)
{ … }
static void mlx4_en_set_rx_mode(struct net_device *dev)
{ … }
static void mlx4_en_set_promisc_mode(struct mlx4_en_priv *priv,
struct mlx4_en_dev *mdev)
{ … }
static void mlx4_en_clear_promisc_mode(struct mlx4_en_priv *priv,
struct mlx4_en_dev *mdev)
{ … }
static void mlx4_en_do_multicast(struct mlx4_en_priv *priv,
struct net_device *dev,
struct mlx4_en_dev *mdev)
{ … }
static void mlx4_en_do_uc_filter(struct mlx4_en_priv *priv,
struct net_device *dev,
struct mlx4_en_dev *mdev)
{ … }
static void mlx4_en_do_set_rx_mode(struct work_struct *work)
{ … }
static int mlx4_en_set_rss_steer_rules(struct mlx4_en_priv *priv)
{ … }
static void mlx4_en_delete_rss_steer_rules(struct mlx4_en_priv *priv)
{ … }
static void mlx4_en_tx_timeout(struct net_device *dev, unsigned int txqueue)
{ … }
static void
mlx4_en_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
{ … }
static void mlx4_en_set_default_moderation(struct mlx4_en_priv *priv)
{ … }
static void mlx4_en_auto_moderation(struct mlx4_en_priv *priv)
{ … }
static void mlx4_en_do_get_stats(struct work_struct *work)
{ … }
static void mlx4_en_service_task(struct work_struct *work)
{ … }
static void mlx4_en_linkstate(struct mlx4_en_priv *priv)
{ … }
static void mlx4_en_linkstate_work(struct work_struct *work)
{ … }
static int mlx4_en_init_affinity_hint(struct mlx4_en_priv *priv, int ring_idx)
{ … }
static void mlx4_en_free_affinity_hint(struct mlx4_en_priv *priv, int ring_idx)
{ … }
static void mlx4_en_init_recycle_ring(struct mlx4_en_priv *priv,
int tx_ring_idx)
{ … }
int mlx4_en_start_port(struct net_device *dev)
{ … }
void mlx4_en_stop_port(struct net_device *dev, int detach)
{ … }
static void mlx4_en_restart(struct work_struct *work)
{ … }
static void mlx4_en_clear_stats(struct net_device *dev)
{ … }
static int mlx4_en_open(struct net_device *dev)
{ … }
static int mlx4_en_close(struct net_device *dev)
{ … }
static void mlx4_en_free_resources(struct mlx4_en_priv *priv)
{ … }
static int mlx4_en_alloc_resources(struct mlx4_en_priv *priv)
{ … }
static int mlx4_en_copy_priv(struct mlx4_en_priv *dst,
struct mlx4_en_priv *src,
struct mlx4_en_port_profile *prof)
{ … }
static void mlx4_en_update_priv(struct mlx4_en_priv *dst,
struct mlx4_en_priv *src)
{ … }
int mlx4_en_try_alloc_resources(struct mlx4_en_priv *priv,
struct mlx4_en_priv *tmp,
struct mlx4_en_port_profile *prof,
bool carry_xdp_prog)
{ … }
void mlx4_en_safe_replace_resources(struct mlx4_en_priv *priv,
struct mlx4_en_priv *tmp)
{ … }
void mlx4_en_destroy_netdev(struct net_device *dev)
{ … }
static bool mlx4_en_check_xdp_mtu(struct net_device *dev, int mtu)
{ … }
static int mlx4_en_change_mtu(struct net_device *dev, int new_mtu)
{ … }
static int mlx4_en_hwtstamp_set(struct net_device *dev, struct ifreq *ifr)
{ … }
static int mlx4_en_hwtstamp_get(struct net_device *dev, struct ifreq *ifr)
{ … }
static int mlx4_en_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
{ … }
static netdev_features_t mlx4_en_fix_features(struct net_device *netdev,
netdev_features_t features)
{ … }
static int mlx4_en_set_features(struct net_device *netdev,
netdev_features_t features)
{ … }
static int mlx4_en_set_vf_mac(struct net_device *dev, int queue, u8 *mac)
{ … }
static int mlx4_en_set_vf_vlan(struct net_device *dev, int vf, u16 vlan, u8 qos,
__be16 vlan_proto)
{ … }
static int mlx4_en_set_vf_rate(struct net_device *dev, int vf, int min_tx_rate,
int max_tx_rate)
{ … }
static int mlx4_en_set_vf_spoofchk(struct net_device *dev, int vf, bool setting)
{ … }
static int mlx4_en_get_vf_config(struct net_device *dev, int vf, struct ifla_vf_info *ivf)
{ … }
static int mlx4_en_set_vf_link_state(struct net_device *dev, int vf, int link_state)
{ … }
static int mlx4_en_get_vf_stats(struct net_device *dev, int vf,
struct ifla_vf_stats *vf_stats)
{ … }
#define PORT_ID_BYTE_LEN …
static int mlx4_en_get_phys_port_id(struct net_device *dev,
struct netdev_phys_item_id *ppid)
{ … }
static int mlx4_udp_tunnel_sync(struct net_device *dev, unsigned int table)
{ … }
static const struct udp_tunnel_nic_info mlx4_udp_tunnels = …;
static netdev_features_t mlx4_en_features_check(struct sk_buff *skb,
struct net_device *dev,
netdev_features_t features)
{ … }
static int mlx4_en_set_tx_maxrate(struct net_device *dev, int queue_index, u32 maxrate)
{ … }
static int mlx4_xdp_set(struct net_device *dev, struct bpf_prog *prog)
{ … }
static int mlx4_xdp(struct net_device *dev, struct netdev_bpf *xdp)
{ … }
static const struct net_device_ops mlx4_netdev_ops = …;
static const struct net_device_ops mlx4_netdev_ops_master = …;
static const struct xdp_metadata_ops mlx4_xdp_metadata_ops = …;
int mlx4_en_netdev_event(struct notifier_block *this,
unsigned long event, void *ptr)
{ … }
void mlx4_en_update_pfc_stats_bitmap(struct mlx4_dev *dev,
struct mlx4_en_stats_bitmap *stats_bitmap,
u8 rx_ppp, u8 rx_pause,
u8 tx_ppp, u8 tx_pause)
{ … }
void mlx4_en_set_stats_bitmap(struct mlx4_dev *dev,
struct mlx4_en_stats_bitmap *stats_bitmap,
u8 rx_ppp, u8 rx_pause,
u8 tx_ppp, u8 tx_pause)
{ … }
static void mlx4_get_queue_stats_rx(struct net_device *dev, int i,
struct netdev_queue_stats_rx *stats)
{ … }
static void mlx4_get_queue_stats_tx(struct net_device *dev, int i,
struct netdev_queue_stats_tx *stats)
{ … }
static void mlx4_get_base_stats(struct net_device *dev,
struct netdev_queue_stats_rx *rx,
struct netdev_queue_stats_tx *tx)
{ … }
static const struct netdev_stat_ops mlx4_stat_ops = …;
int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,
struct mlx4_en_port_profile *prof)
{ … }
int mlx4_en_reset_config(struct net_device *dev,
struct hwtstamp_config ts_config,
netdev_features_t features)
{ … }