]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
net/mlx5: Factor out HCA capabilities functions
authorLeon Romanovsky <leonro@mellanox.com>
Sun, 17 Feb 2019 11:11:02 +0000 (13:11 +0200)
committerLeon Romanovsky <leonro@mellanox.com>
Tue, 19 Feb 2019 12:40:44 +0000 (14:40 +0200)
Combine all HCA capabilities setters under one function
and compile out the ODP related function in case kernel
was compiled without ODP support.

Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
drivers/net/ethernet/mellanox/mlx5/core/main.c

index 40d591c8e76ce793f7a3e7a8e318128c8bc8b8c1..af67c3f3b165f30c1f7856480f2c68b4c7323a19 100644 (file)
@@ -467,7 +467,8 @@ static int handle_hca_cap_odp(struct mlx5_core_dev *dev)
        int set_sz;
        int err;
 
-       if (!MLX5_CAP_GEN(dev, pg))
+       if (!IS_ENABLED(CONFIG_INFINIBAND_ON_DEMAND_PAGING) ||
+           !MLX5_CAP_GEN(dev, pg))
                return 0;
 
        err = mlx5_core_get_caps(dev, MLX5_CAP_ODP);
@@ -577,6 +578,33 @@ static int handle_hca_cap(struct mlx5_core_dev *dev)
        return err;
 }
 
+static int set_hca_cap(struct mlx5_core_dev *dev)
+{
+       struct pci_dev *pdev = dev->pdev;
+       int err;
+
+       err = handle_hca_cap(dev);
+       if (err) {
+               dev_err(&pdev->dev, "handle_hca_cap failed\n");
+               goto out;
+       }
+
+       err = handle_hca_cap_atomic(dev);
+       if (err) {
+               dev_err(&pdev->dev, "handle_hca_cap_atomic failed\n");
+               goto out;
+       }
+
+       err = handle_hca_cap_odp(dev);
+       if (err) {
+               dev_err(&pdev->dev, "handle_hca_cap_odp failed\n");
+               goto out;
+       }
+
+out:
+       return err;
+}
+
 static int set_hca_ctrl(struct mlx5_core_dev *dev)
 {
        struct mlx5_reg_host_endianness he_in;
@@ -969,21 +997,9 @@ static int mlx5_load_one(struct mlx5_core_dev *dev, struct mlx5_priv *priv,
                goto reclaim_boot_pages;
        }
 
-       err = handle_hca_cap(dev);
-       if (err) {
-               dev_err(&pdev->dev, "handle_hca_cap failed\n");
-               goto reclaim_boot_pages;
-       }
-
-       err = handle_hca_cap_atomic(dev);
-       if (err) {
-               dev_err(&pdev->dev, "handle_hca_cap_atomic failed\n");
-               goto reclaim_boot_pages;
-       }
-
-       err = handle_hca_cap_odp(dev);
+       err = set_hca_cap(dev);
        if (err) {
-               dev_err(&pdev->dev, "handle_hca_cap_odp failed\n");
+               dev_err(&pdev->dev, "set_hca_cap failed\n");
                goto reclaim_boot_pages;
        }