Merge branch 'mlx5-next' of git://git.kernel.org/pub/scm/linux/kernel/git/mellanox...
[linux-2.6-microblaze.git] / drivers / net / ethernet / mellanox / mlx5 / core / main.c
index bfc8c6f..072b56f 100644 (file)
@@ -56,6 +56,7 @@
 #include "fs_core.h"
 #include "lib/mpfs.h"
 #include "eswitch.h"
+#include "devlink.h"
 #include "lib/mlx5.h"
 #include "fpga/core.h"
 #include "fpga/ipsec.h"
@@ -63,7 +64,9 @@
 #include "accel/tls.h"
 #include "lib/clock.h"
 #include "lib/vxlan.h"
+#include "lib/geneve.h"
 #include "lib/devcom.h"
+#include "lib/pci_vsc.h"
 #include "diag/fw_tracer.h"
 #include "ecpf.h"
 
@@ -771,6 +774,8 @@ static int mlx5_pci_init(struct mlx5_core_dev *dev, struct pci_dev *pdev,
                goto err_clr_master;
        }
 
+       mlx5_pci_vsc_init(dev);
+
        return 0;
 
 err_clr_master:
@@ -837,6 +842,7 @@ static int mlx5_init_once(struct mlx5_core_dev *dev)
        mlx5_init_clock(dev);
 
        dev->vxlan = mlx5_vxlan_create(dev);
+       dev->geneve = mlx5_geneve_create(dev);
 
        err = mlx5_init_rl_table(dev);
        if (err) {
@@ -881,6 +887,7 @@ err_mpfs_cleanup:
 err_rl_cleanup:
        mlx5_cleanup_rl_table(dev);
 err_tables_cleanup:
+       mlx5_geneve_destroy(dev->geneve);
        mlx5_vxlan_destroy(dev->vxlan);
        mlx5_cleanup_mkey_table(dev);
        mlx5_cleanup_qp_table(dev);
@@ -905,6 +912,7 @@ static void mlx5_cleanup_once(struct mlx5_core_dev *dev)
        mlx5_sriov_cleanup(dev);
        mlx5_mpfs_cleanup(dev);
        mlx5_cleanup_rl_table(dev);
+       mlx5_geneve_destroy(dev->geneve);
        mlx5_vxlan_destroy(dev->vxlan);
        mlx5_cleanup_clock(dev);
        mlx5_cleanup_reserved_gids(dev);
@@ -1092,7 +1100,7 @@ static int mlx5_load(struct mlx5_core_dev *dev)
        err = mlx5_core_set_hca_defaults(dev);
        if (err) {
                mlx5_core_err(dev, "Failed to set hca defaults\n");
-               goto err_fs;
+               goto err_sriov;
        }
 
        err = mlx5_sriov_attach(dev);
@@ -1211,7 +1219,7 @@ static int mlx5_unload_one(struct mlx5_core_dev *dev, bool cleanup)
        int err = 0;
 
        if (cleanup)
-               mlx5_drain_health_recovery(dev);
+               mlx5_drain_health_wq(dev);
 
        mutex_lock(&dev->intf_state_mutex);
        if (!test_bit(MLX5_INTERFACE_STATE_UP, &dev->intf_state)) {
@@ -1238,17 +1246,6 @@ out:
        return err;
 }
 
-static const struct devlink_ops mlx5_devlink_ops = {
-#ifdef CONFIG_MLX5_ESWITCH
-       .eswitch_mode_set = mlx5_devlink_eswitch_mode_set,
-       .eswitch_mode_get = mlx5_devlink_eswitch_mode_get,
-       .eswitch_inline_mode_set = mlx5_devlink_eswitch_inline_mode_set,
-       .eswitch_inline_mode_get = mlx5_devlink_eswitch_inline_mode_get,
-       .eswitch_encap_mode_set = mlx5_devlink_eswitch_encap_mode_set,
-       .eswitch_encap_mode_get = mlx5_devlink_eswitch_encap_mode_get,
-#endif
-};
-
 static int mlx5_mdev_init(struct mlx5_core_dev *dev, int profile_idx)
 {
        struct mlx5_priv *priv = &dev->priv;
@@ -1310,9 +1307,9 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *id)
        struct devlink *devlink;
        int err;
 
-       devlink = devlink_alloc(&mlx5_devlink_ops, sizeof(*dev));
+       devlink = mlx5_devlink_alloc();
        if (!devlink) {
-               dev_err(&pdev->dev, "kzalloc failed\n");
+               dev_err(&pdev->dev, "devlink alloc failed\n");
                return -ENOMEM;
        }
 
@@ -1340,10 +1337,14 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *id)
 
        request_module_nowait(MLX5_IB_MOD);
 
-       err = devlink_register(devlink, &pdev->dev);
+       err = mlx5_devlink_register(devlink, &pdev->dev);
        if (err)
                goto clean_load;
 
+       err = mlx5_crdump_enable(dev);
+       if (err)
+               dev_err(&pdev->dev, "mlx5_crdump_enable failed with error code %d\n", err);
+
        pci_save_state(pdev);
        return 0;
 
@@ -1355,7 +1356,7 @@ err_load_one:
 pci_init_err:
        mlx5_mdev_uninit(dev);
 mdev_init_err:
-       devlink_free(devlink);
+       mlx5_devlink_free(devlink);
 
        return err;
 }
@@ -1365,7 +1366,8 @@ static void remove_one(struct pci_dev *pdev)
        struct mlx5_core_dev *dev  = pci_get_drvdata(pdev);
        struct devlink *devlink = priv_to_devlink(dev);
 
-       devlink_unregister(devlink);
+       mlx5_crdump_disable(dev);
+       mlx5_devlink_unregister(devlink);
        mlx5_unregister_device(dev);
 
        if (mlx5_unload_one(dev, true)) {
@@ -1376,7 +1378,7 @@ static void remove_one(struct pci_dev *pdev)
 
        mlx5_pci_close(dev);
        mlx5_mdev_uninit(dev);
-       devlink_free(devlink);
+       mlx5_devlink_free(devlink);
 }
 
 static pci_ers_result_t mlx5_pci_err_detected(struct pci_dev *pdev,
@@ -1387,12 +1389,10 @@ static pci_ers_result_t mlx5_pci_err_detected(struct pci_dev *pdev,
        mlx5_core_info(dev, "%s was called\n", __func__);
 
        mlx5_enter_error_state(dev, false);
+       mlx5_error_sw_reset(dev);
        mlx5_unload_one(dev, false);
-       /* In case of kernel call drain the health wq */
-       if (state) {
-               mlx5_drain_health_wq(dev);
-               mlx5_pci_disable_device(dev);
-       }
+       mlx5_drain_health_wq(dev);
+       mlx5_pci_disable_device(dev);
 
        return state == pci_channel_io_perm_failure ?
                PCI_ERS_RESULT_DISCONNECT : PCI_ERS_RESULT_NEED_RESET;
@@ -1560,7 +1560,8 @@ MODULE_DEVICE_TABLE(pci, mlx5_core_pci_table);
 
 void mlx5_disable_device(struct mlx5_core_dev *dev)
 {
-       mlx5_pci_err_detected(dev->pdev, 0);
+       mlx5_error_sw_reset(dev);
+       mlx5_unload_one(dev, false);
 }
 
 void mlx5_recover_device(struct mlx5_core_dev *dev)