Skip to content

Commit 37b6bb7

Browse files
author
Leon Romanovsky
committed
net/mlx5: Factor out HCA capabilities functions
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>
1 parent 08e8676 commit 37b6bb7

1 file changed

Lines changed: 31 additions & 15 deletions

File tree

  • drivers/net/ethernet/mellanox/mlx5/core

‎drivers/net/ethernet/mellanox/mlx5/core/main.c‎

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,8 @@ static int handle_hca_cap_odp(struct mlx5_core_dev *dev)
467467
int set_sz;
468468
int err;
469469

470-
if (!MLX5_CAP_GEN(dev, pg))
470+
if (!IS_ENABLED(CONFIG_INFINIBAND_ON_DEMAND_PAGING) ||
471+
!MLX5_CAP_GEN(dev, pg))
471472
return 0;
472473

473474
err = mlx5_core_get_caps(dev, MLX5_CAP_ODP);
@@ -577,6 +578,33 @@ static int handle_hca_cap(struct mlx5_core_dev *dev)
577578
return err;
578579
}
579580

581+
static int set_hca_cap(struct mlx5_core_dev *dev)
582+
{
583+
struct pci_dev *pdev = dev->pdev;
584+
int err;
585+
586+
err = handle_hca_cap(dev);
587+
if (err) {
588+
dev_err(&pdev->dev, "handle_hca_cap failed\n");
589+
goto out;
590+
}
591+
592+
err = handle_hca_cap_atomic(dev);
593+
if (err) {
594+
dev_err(&pdev->dev, "handle_hca_cap_atomic failed\n");
595+
goto out;
596+
}
597+
598+
err = handle_hca_cap_odp(dev);
599+
if (err) {
600+
dev_err(&pdev->dev, "handle_hca_cap_odp failed\n");
601+
goto out;
602+
}
603+
604+
out:
605+
return err;
606+
}
607+
580608
static int set_hca_ctrl(struct mlx5_core_dev *dev)
581609
{
582610
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,
969997
goto reclaim_boot_pages;
970998
}
971999

972-
err = handle_hca_cap(dev);
973-
if (err) {
974-
dev_err(&pdev->dev, "handle_hca_cap failed\n");
975-
goto reclaim_boot_pages;
976-
}
977-
978-
err = handle_hca_cap_atomic(dev);
979-
if (err) {
980-
dev_err(&pdev->dev, "handle_hca_cap_atomic failed\n");
981-
goto reclaim_boot_pages;
982-
}
983-
984-
err = handle_hca_cap_odp(dev);
1000+
err = set_hca_cap(dev);
9851001
if (err) {
986-
dev_err(&pdev->dev, "handle_hca_cap_odp failed\n");
1002+
dev_err(&pdev->dev, "set_hca_cap failed\n");
9871003
goto reclaim_boot_pages;
9881004
}
9891005

0 commit comments

Comments
 (0)