Merge tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma
[sfrench/cifs-2.6.git] / drivers / net / ethernet / mellanox / mlx5 / core / main.c
index f1de152a61135844f291af44a69d04df60a96bb6..995eb2d5ace0b2681718920d7ebdb09c94625156 100644 (file)
 #include <linux/kmod.h>
 #include <linux/mlx5/mlx5_ifc.h>
 #include <linux/mlx5/vport.h>
-#ifdef CONFIG_RFS_ACCEL
-#include <linux/cpu_rmap.h>
-#endif
 #include <linux/version.h>
 #include <net/devlink.h>
 #include "mlx5_core.h"
+#include "thermal.h"
 #include "lib/eq.h"
 #include "fs_core.h"
 #include "lib/mpfs.h"
@@ -102,15 +100,19 @@ enum {
 static struct mlx5_profile profile[] = {
        [0] = {
                .mask           = 0,
+               .num_cmd_caches = MLX5_NUM_COMMAND_CACHES,
        },
        [1] = {
                .mask           = MLX5_PROF_MASK_QP_SIZE,
                .log_max_qp     = 12,
+               .num_cmd_caches = MLX5_NUM_COMMAND_CACHES,
+
        },
        [2] = {
                .mask           = MLX5_PROF_MASK_QP_SIZE |
                                  MLX5_PROF_MASK_MR_CACHE,
                .log_max_qp     = LOG_MAX_SUPPORTED_QPS,
+               .num_cmd_caches = MLX5_NUM_COMMAND_CACHES,
                .mr_cache[0]    = {
                        .size   = 500,
                        .limit  = 250
@@ -176,6 +178,11 @@ static struct mlx5_profile profile[] = {
                        .limit  = 4
                },
        },
+       [3] = {
+               .mask           = MLX5_PROF_MASK_QP_SIZE,
+               .log_max_qp     = LOG_MAX_SUPPORTED_QPS,
+               .num_cmd_caches = 0,
+       },
 };
 
 static int wait_fw_init(struct mlx5_core_dev *dev, u32 max_wait_mili,
@@ -191,7 +198,7 @@ static int wait_fw_init(struct mlx5_core_dev *dev, u32 max_wait_mili,
                if (!(fw_initializing >> 31))
                        break;
                if (time_after(jiffies, end) ||
-                   test_and_clear_bit(MLX5_BREAK_FW_WAIT, &dev->intf_state)) {
+                   test_bit(MLX5_BREAK_FW_WAIT, &dev->intf_state)) {
                        err = -EBUSY;
                        break;
                }
@@ -684,6 +691,9 @@ static int handle_hca_cap_roce(struct mlx5_core_dev *dev, void *set_ctx)
               MLX5_ST_SZ_BYTES(roce_cap));
        MLX5_SET(roce_cap, set_hca_cap, sw_r_roce_src_udp_port, 1);
 
+       if (MLX5_CAP_ROCE_MAX(dev, qp_ooo_transmit_default))
+               MLX5_SET(roce_cap, set_hca_cap, qp_ooo_transmit_default, 1);
+
        err = set_caps(dev, set_ctx, MLX5_SET_HCA_CAP_OP_MOD_ROCE);
        return err;
 }
@@ -710,7 +720,7 @@ static int handle_hca_cap_port_selection(struct mlx5_core_dev *dev,
               MLX5_ST_SZ_BYTES(port_selection_cap));
        MLX5_SET(port_selection_cap, set_hca_cap, port_select_flow_table_bypass, 1);
 
-       err = set_caps(dev, set_ctx, MLX5_SET_HCA_CAP_OP_MODE_PORT_SELECTION);
+       err = set_caps(dev, set_ctx, MLX5_SET_HCA_CAP_OP_MOD_PORT_SELECTION);
 
        return err;
 }
@@ -917,7 +927,6 @@ static int mlx5_pci_init(struct mlx5_core_dev *dev, struct pci_dev *pdev,
        return 0;
 
 err_clr_master:
-       pci_clear_master(dev->pdev);
        release_bar(dev->pdev);
 err_disable:
        mlx5_pci_disable_device(dev);
@@ -932,7 +941,6 @@ static void mlx5_pci_close(struct mlx5_core_dev *dev)
         */
        mlx5_drain_health_wq(dev);
        iounmap(dev->iseg);
-       pci_clear_master(dev->pdev);
        release_bar(dev->pdev);
        mlx5_pci_disable_device(dev);
 }
@@ -1402,16 +1410,16 @@ int mlx5_init_one(struct mlx5_core_dev *dev)
                goto function_teardown;
        }
 
+       err = mlx5_devlink_params_register(priv_to_devlink(dev));
+       if (err)
+               goto err_devlink_params_reg;
+
        err = mlx5_load(dev);
        if (err)
                goto err_load;
 
        set_bit(MLX5_INTERFACE_STATE_UP, &dev->intf_state);
 
-       err = mlx5_devlink_params_register(priv_to_devlink(dev));
-       if (err)
-               goto err_devlink_params_reg;
-
        err = mlx5_register_device(dev);
        if (err)
                goto err_register;
@@ -1421,11 +1429,11 @@ int mlx5_init_one(struct mlx5_core_dev *dev)
        return 0;
 
 err_register:
-       mlx5_devlink_params_unregister(priv_to_devlink(dev));
-err_devlink_params_reg:
        clear_bit(MLX5_INTERFACE_STATE_UP, &dev->intf_state);
        mlx5_unload(dev);
 err_load:
+       mlx5_devlink_params_unregister(priv_to_devlink(dev));
+err_devlink_params_reg:
        mlx5_cleanup_once(dev);
 function_teardown:
        mlx5_function_teardown(dev, true);
@@ -1444,7 +1452,6 @@ void mlx5_uninit_one(struct mlx5_core_dev *dev)
        mutex_lock(&dev->intf_state_mutex);
 
        mlx5_unregister_device(dev);
-       mlx5_devlink_params_unregister(priv_to_devlink(dev));
 
        if (!test_bit(MLX5_INTERFACE_STATE_UP, &dev->intf_state)) {
                mlx5_core_warn(dev, "%s: interface is down, NOP\n",
@@ -1455,6 +1462,7 @@ void mlx5_uninit_one(struct mlx5_core_dev *dev)
 
        clear_bit(MLX5_INTERFACE_STATE_UP, &dev->intf_state);
        mlx5_unload(dev);
+       mlx5_devlink_params_unregister(priv_to_devlink(dev));
        mlx5_cleanup_once(dev);
        mlx5_function_teardown(dev, true);
 out:
@@ -1509,13 +1517,13 @@ out:
        return err;
 }
 
-int mlx5_load_one(struct mlx5_core_dev *dev)
+int mlx5_load_one(struct mlx5_core_dev *dev, bool recovery)
 {
        struct devlink *devlink = priv_to_devlink(dev);
        int ret;
 
        devl_lock(devlink);
-       ret = mlx5_load_one_devl_locked(dev, false);
+       ret = mlx5_load_one_devl_locked(dev, recovery);
        devl_unlock(devlink);
        return ret;
 }
@@ -1768,6 +1776,10 @@ static int probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
        if (err)
                dev_err(&pdev->dev, "mlx5_crdump_enable failed with error code %d\n", err);
 
+       err = mlx5_thermal_init(dev);
+       if (err)
+               dev_err(&pdev->dev, "mlx5_thermal_init failed with error code %d\n", err);
+
        pci_save_state(pdev);
        devlink_register(devlink);
        return 0;
@@ -1796,6 +1808,7 @@ static void remove_one(struct pci_dev *pdev)
        mlx5_drain_fw_reset(dev);
        devlink_unregister(devlink);
        mlx5_sriov_disable(pdev);
+       mlx5_thermal_uninit(dev);
        mlx5_crdump_disable(dev);
        mlx5_drain_health_wq(dev);
        mlx5_uninit_one(dev);
@@ -1912,7 +1925,8 @@ static void mlx5_pci_resume(struct pci_dev *pdev)
 
        mlx5_pci_trace(dev, "Enter, loading driver..\n");
 
-       err = mlx5_load_one(dev);
+       err = mlx5_load_one(dev, false);
+
        if (!err)
                devlink_health_reporter_state_update(dev->priv.health.fw_fatal_reporter,
                                                     DEVLINK_HEALTH_REPORTER_STATE_HEALTHY);
@@ -2003,7 +2017,7 @@ static int mlx5_resume(struct pci_dev *pdev)
 {
        struct mlx5_core_dev *dev = pci_get_drvdata(pdev);
 
-       return mlx5_load_one(dev);
+       return mlx5_load_one(dev, false);
 }
 
 static const struct pci_device_id mlx5_core_pci_table[] = {