net/mlx5: Add CONFIG_MLX5_ESWITCH Kconfig
[platform/kernel/linux-rpi.git] / drivers / net / ethernet / mellanox / mlx5 / core / en_main.c
index e3c858c..b19e9d2 100644 (file)
@@ -3025,6 +3025,7 @@ static int mlx5e_ndo_setup_tc(struct net_device *dev, u32 handle,
                              u32 chain_index, __be16 proto,
                              struct tc_to_netdev *tc)
 {
+#ifdef CONFIG_MLX5_ESWITCH
        struct mlx5e_priv *priv = netdev_priv(dev);
 
        if (TC_H_MAJ(handle) != TC_H_MAJ(TC_H_INGRESS))
@@ -3048,6 +3049,7 @@ static int mlx5e_ndo_setup_tc(struct net_device *dev, u32 handle,
        }
 
 mqprio:
+#endif
        if (tc->type != TC_SETUP_MQPRIO)
                return -EINVAL;
 
@@ -3350,6 +3352,7 @@ static int mlx5e_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
        }
 }
 
+#ifdef CONFIG_MLX5_ESWITCH
 static int mlx5e_set_vf_mac(struct net_device *dev, int vf, u8 *mac)
 {
        struct mlx5e_priv *priv = netdev_priv(dev);
@@ -3452,6 +3455,7 @@ static int mlx5e_get_vf_stats(struct net_device *dev,
        return mlx5_eswitch_get_vport_stats(mdev->priv.eswitch, vf + 1,
                                            vf_stats);
 }
+#endif
 
 static void mlx5e_add_vxlan_port(struct net_device *netdev,
                                 struct udp_tunnel_info *ti)
@@ -3685,7 +3689,7 @@ static void mlx5e_netpoll(struct net_device *dev)
 }
 #endif
 
-static const struct net_device_ops mlx5e_netdev_ops_basic = {
+static const struct net_device_ops mlx5e_netdev_ops = {
        .ndo_open                = mlx5e_open,
        .ndo_stop                = mlx5e_close,
        .ndo_start_xmit          = mlx5e_xmit,
@@ -3711,34 +3715,7 @@ static const struct net_device_ops mlx5e_netdev_ops_basic = {
 #ifdef CONFIG_NET_POLL_CONTROLLER
        .ndo_poll_controller     = mlx5e_netpoll,
 #endif
-};
-
-static const struct net_device_ops mlx5e_netdev_ops_sriov = {
-       .ndo_open                = mlx5e_open,
-       .ndo_stop                = mlx5e_close,
-       .ndo_start_xmit          = mlx5e_xmit,
-       .ndo_setup_tc            = mlx5e_ndo_setup_tc,
-       .ndo_select_queue        = mlx5e_select_queue,
-       .ndo_get_stats64         = mlx5e_get_stats,
-       .ndo_set_rx_mode         = mlx5e_set_rx_mode,
-       .ndo_set_mac_address     = mlx5e_set_mac,
-       .ndo_vlan_rx_add_vid     = mlx5e_vlan_rx_add_vid,
-       .ndo_vlan_rx_kill_vid    = mlx5e_vlan_rx_kill_vid,
-       .ndo_set_features        = mlx5e_set_features,
-       .ndo_change_mtu          = mlx5e_change_mtu,
-       .ndo_do_ioctl            = mlx5e_ioctl,
-       .ndo_set_tx_maxrate      = mlx5e_set_tx_maxrate,
-       .ndo_udp_tunnel_add      = mlx5e_add_vxlan_port,
-       .ndo_udp_tunnel_del      = mlx5e_del_vxlan_port,
-       .ndo_features_check      = mlx5e_features_check,
-#ifdef CONFIG_RFS_ACCEL
-       .ndo_rx_flow_steer       = mlx5e_rx_flow_steer,
-#endif
-       .ndo_tx_timeout          = mlx5e_tx_timeout,
-       .ndo_xdp                 = mlx5e_xdp,
-#ifdef CONFIG_NET_POLL_CONTROLLER
-       .ndo_poll_controller     = mlx5e_netpoll,
-#endif
+#ifdef CONFIG_MLX5_ESWITCH
        /* SRIOV E-Switch NDOs */
        .ndo_set_vf_mac          = mlx5e_set_vf_mac,
        .ndo_set_vf_vlan         = mlx5e_set_vf_vlan,
@@ -3750,6 +3727,7 @@ static const struct net_device_ops mlx5e_netdev_ops_sriov = {
        .ndo_get_vf_stats        = mlx5e_get_vf_stats,
        .ndo_has_offload_stats   = mlx5e_has_offload_stats,
        .ndo_get_offload_stats   = mlx5e_get_offload_stats,
+#endif
 };
 
 static int mlx5e_check_required_hca_cap(struct mlx5_core_dev *mdev)
@@ -3979,9 +3957,11 @@ static void mlx5e_set_netdev_dev_addr(struct net_device *netdev)
        }
 }
 
+#if IS_ENABLED(CONFIG_NET_SWITCHDEV) && IS_ENABLED(CONFIG_MLX5_ESWITCH)
 static const struct switchdev_ops mlx5e_switchdev_ops = {
        .switchdev_port_attr_get        = mlx5e_attr_get,
 };
+#endif
 
 static void mlx5e_build_nic_netdev(struct net_device *netdev)
 {
@@ -3992,15 +3972,12 @@ static void mlx5e_build_nic_netdev(struct net_device *netdev)
 
        SET_NETDEV_DEV(netdev, &mdev->pdev->dev);
 
-       if (MLX5_CAP_GEN(mdev, vport_group_manager)) {
-               netdev->netdev_ops = &mlx5e_netdev_ops_sriov;
+       netdev->netdev_ops = &mlx5e_netdev_ops;
+
 #ifdef CONFIG_MLX5_CORE_EN_DCB
-               if (MLX5_CAP_GEN(mdev, qos))
-                       netdev->dcbnl_ops = &mlx5e_dcbnl_ops;
+       if (MLX5_CAP_GEN(mdev, vport_group_manager) && MLX5_CAP_GEN(mdev, qos))
+               netdev->dcbnl_ops = &mlx5e_dcbnl_ops;
 #endif
-       } else {
-               netdev->netdev_ops = &mlx5e_netdev_ops_basic;
-       }
 
        netdev->watchdog_timeo    = 15 * HZ;
 
@@ -4072,7 +4049,7 @@ static void mlx5e_build_nic_netdev(struct net_device *netdev)
 
        mlx5e_set_netdev_dev_addr(netdev);
 
-#ifdef CONFIG_NET_SWITCHDEV
+#if IS_ENABLED(CONFIG_NET_SWITCHDEV) && IS_ENABLED(CONFIG_MLX5_ESWITCH)
        if (MLX5_VPORT_MANAGER(mdev))
                netdev->switchdev_ops = &mlx5e_switchdev_ops;
 #endif
@@ -4431,6 +4408,7 @@ static void *mlx5e_add(struct mlx5_core_dev *mdev)
        if (err)
                return NULL;
 
+#ifdef CONFIG_MLX5_ESWITCH
        if (MLX5_VPORT_MANAGER(mdev)) {
                rpriv = mlx5e_alloc_nic_rep_priv(mdev);
                if (!rpriv) {
@@ -4438,6 +4416,7 @@ static void *mlx5e_add(struct mlx5_core_dev *mdev)
                        return NULL;
                }
        }
+#endif
 
        netdev = mlx5e_create_netdev(mdev, &mlx5e_nic_profile, rpriv);
        if (!netdev) {