Skip to contentSkip to conversation

Followup changes to mlx5-next branch

PATCH In review Leon Romanovsky 4 participants 8 messages Feb 11, 2019 – Feb 13, 2019

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover Followup changes to mlx5-next branch

From: Leon Romanovsky <[email protected]>

Hi,

There are two small cleanups needed after prefetch MR code was merged.

Thanks

Leon Romanovsky (2):
net/mlx5: Align ODP capability function with netdev coding style net/mlx5: Factor out HCA capabilities functions

 .../net/ethernet/mellanox/mlx5/core/main.c    | 62 ++++++++++++-------
 1 file changed, 39 insertions(+), 23 deletions(-)
#1 lore raw

PATCH 1/2 net/mlx5: Align ODP capability function with netdev coding style

From: Leon Romanovsky <[email protected]>

Update newly introduced function to be aligned to netdev coding style.

Fixes 46861e3e88be ("net/mlx5: Set ODP SRQ support in firmware")
---
 drivers/net/ethernet/mellanox/mlx5/core/main.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/main.c +6 -9
index e38aa206ab6d..6d45518edbdc 100644
@@ -461,9 +461,9 @@ static int handle_hca_cap_atomic(struct mlx5_core_dev *dev)
 
 static int handle_hca_cap_odp(struct mlx5_core_dev *dev)
 {
-	void *set_ctx;
 	void *set_hca_cap;
-	int set_sz = MLX5_ST_SZ_BYTES(set_hca_cap_in);
+	void *set_ctx;
+	int set_sz;
 	int err;
 
 	if (!MLX5_CAP_GEN(dev, pg))
@@ -473,15 +473,12 @@ static int handle_hca_cap_odp(struct mlx5_core_dev *dev)
 	if (err)
 		return err;
 
-	/**
-	 * If all bits are cleared we shouldn't try to set it
-	 * or we might fail while trying to access a reserved bit.
-	 */
 	if (!(MLX5_CAP_ODP_MAX(dev, ud_odp_caps.srq_receive) ||
 	      MLX5_CAP_ODP_MAX(dev, rc_odp_caps.srq_receive) ||
 	      MLX5_CAP_ODP_MAX(dev, xrc_odp_caps.srq_receive)))
 		return 0;
 
+	set_sz = MLX5_ST_SZ_BYTES(set_hca_cap_in);
 	set_ctx = kzalloc(set_sz, GFP_KERNEL);
 	if (!set_ctx)
 		return -ENOMEM;
@@ -492,13 +489,13 @@ static int handle_hca_cap_odp(struct mlx5_core_dev *dev)
 
 	/* set ODP SRQ support for RC/UD and XRC transports */
 	MLX5_SET(odp_cap, set_hca_cap, ud_odp_caps.srq_receive,
-		 (MLX5_CAP_ODP_MAX(dev, ud_odp_caps.srq_receive)));
+		 MLX5_CAP_ODP_MAX(dev, ud_odp_caps.srq_receive));
 
 	MLX5_SET(odp_cap, set_hca_cap, rc_odp_caps.srq_receive,
-		 (MLX5_CAP_ODP_MAX(dev, rc_odp_caps.srq_receive)));
+		 MLX5_CAP_ODP_MAX(dev, rc_odp_caps.srq_receive));
 
 	MLX5_SET(odp_cap, set_hca_cap, xrc_odp_caps.srq_receive,
-		 (MLX5_CAP_ODP_MAX(dev, xrc_odp_caps.srq_receive)));
+		 MLX5_CAP_ODP_MAX(dev, xrc_odp_caps.srq_receive));
 
 	err = set_caps(dev, set_ctx, set_sz, MLX5_SET_HCA_CAP_OP_MOD_ODP);
 
Signature · 1 line
2.19.1
#2 lore raw

PATCH 2/2 net/mlx5: Factor out HCA capabilities functions

In reply to Leon Romanovsky

From: Leon Romanovsky <[email protected]>

Combine all HCA capabilities setters under one function and compile out the ODP related function in case kernel was compiled without ODP support.

---
 .../net/ethernet/mellanox/mlx5/core/main.c    | 47 +++++++++++++------
 1 file changed, 33 insertions(+), 14 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/main.c +33 -14
index 6d45518edbdc..d7145ab6105d 100644
@@ -459,6 +459,7 @@ static int handle_hca_cap_atomic(struct mlx5_core_dev *dev)
 	return err;
 }
 
+#ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING
 static int handle_hca_cap_odp(struct mlx5_core_dev *dev)
 {
 	void *set_hca_cap;
@@ -502,6 +503,7 @@ static int handle_hca_cap_odp(struct mlx5_core_dev *dev)
 	kfree(set_ctx);
 	return err;
 }
+#endif
 
 static int handle_hca_cap(struct mlx5_core_dev *dev)
 {
@@ -576,6 +578,35 @@ 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;
+	}
+
+#ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING
+	err = handle_hca_cap_odp(dev);
+	if (err) {
+		dev_err(&pdev->dev, "handle_hca_cap_odp failed\n");
+		goto out;
+	}
+#endif
+
+out:
+	return err;
+}
+
 static int set_hca_ctrl(struct mlx5_core_dev *dev)
 {
 	struct mlx5_reg_host_endianness he_in;
@@ -963,21 +994,9 @@ static int mlx5_load_one(struct mlx5_core_dev *dev, struct mlx5_priv *priv,
 		goto reclaim_boot_pages;
 	}
 
-	err = handle_hca_cap(dev);
+	err = set_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);
-	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;
 	}
 
Signature · 1 line
2.19.1
#3 lore raw

Re: [PATCH mlx5-next 2/2] net/mlx5: Factor out HCA capabilities functions

Quoted 47 lines · Leon Romanovsky

From: Leon Romanovsky <[email protected]>

Combine all HCA capabilities setters under one function and compile out the ODP related function in case kernel was compiled without ODP support.

 .../net/ethernet/mellanox/mlx5/core/main.c    | 47 +++++++++++++------
 1 file changed, 33 insertions(+), 14 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/main.c +17 -0
index 6d45518edbdc..d7145ab6105d 100644
+++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c
@@ -459,6 +459,7 @@ static int handle_hca_cap_atomic(struct mlx5_core_dev *dev)
 	return err;
 }
 
+#ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING
 static int handle_hca_cap_odp(struct mlx5_core_dev *dev)
 {
 	void *set_hca_cap;
@@ -502,6 +503,7 @@ static int handle_hca_cap_odp(struct mlx5_core_dev *dev)
 	kfree(set_ctx);
 	return err;
 }
+#endif
 
 static int handle_hca_cap(struct mlx5_core_dev *dev)
 {
@@ -576,6 +578,35 @@ 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");

drivers/net/ethernet/mellanox/mlx5/core/main.c static int handle_hca_cap(struct mlx5_core_dev *dev) · line 604

Quoted 10 lines
drivers/net/ethernet/mellanox/mlx5/core/main.c +10 -0
+		goto out;
+	}
+
+#ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING
+	err = handle_hca_cap_odp(dev);
+	if (err) {
+		dev_err(&pdev->dev, "handle_hca_cap_odp failed\n");
+		goto out;
+	}
+#endif

Adding
if (IS_ENABLED..)

    return 0;

To the top of handle_hca_cap_odp is alot better.

Jason

#4 lore raw

Re: [PATCH mlx5-next 2/2] net/mlx5: Factor out HCA capabilities functions

Quoted 61 lines · Jason Gunthorpe
Quoted 47 lines · Leon Romanovsky

From: Leon Romanovsky <[email protected]>

Combine all HCA capabilities setters under one function and compile out the ODP related function in case kernel was compiled without ODP support.

 .../net/ethernet/mellanox/mlx5/core/main.c    | 47 +++++++++++++------
 1 file changed, 33 insertions(+), 14 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/main.c +17 -0
index 6d45518edbdc..d7145ab6105d 100644
+++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c
@@ -459,6 +459,7 @@ static int handle_hca_cap_atomic(struct mlx5_core_dev *dev)
 	return err;
 }
 
+#ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING
 static int handle_hca_cap_odp(struct mlx5_core_dev *dev)
 {
 	void *set_hca_cap;
@@ -502,6 +503,7 @@ static int handle_hca_cap_odp(struct mlx5_core_dev *dev)
 	kfree(set_ctx);
 	return err;
 }
+#endif
 
 static int handle_hca_cap(struct mlx5_core_dev *dev)
 {
@@ -576,6 +578,35 @@ 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");

drivers/net/ethernet/mellanox/mlx5/core/main.c static int handle_hca_cap(struct mlx5_core_dev *dev) · line 604

Quoted 10 lines
drivers/net/ethernet/mellanox/mlx5/core/main.c +10 -0
+		goto out;
+	}
+
+#ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING
+	err = handle_hca_cap_odp(dev);
+	if (err) {
+		dev_err(&pdev->dev, "handle_hca_cap_odp failed\n");
+		goto out;
+	}
+#endif

Adding
if (IS_ENABLED..)

Quoted 3 lines
    return 0;

To the top of handle_hca_cap_odp is alot better.

Saeed gave comment that he prefers code to be compiled-out in case config is not set. In you suggestion, the code will exist and only with some optimizations enabled it will be thrown.

Thanks

Quoted 2 lines

Jason

#5 lore raw

Re: [PATCH mlx5-next 2/2] net/mlx5: Factor out HCA capabilities functions

Quoted 64 lines · Leon Romanovsky
Quoted 63 lines · Jason Gunthorpe
Quoted 47 lines · Leon Romanovsky

From: Leon Romanovsky <[email protected]>

Combine all HCA capabilities setters under one function and compile out the ODP related function in case kernel was compiled without ODP support.

 .../net/ethernet/mellanox/mlx5/core/main.c    | 47 +++++++++++++------
 1 file changed, 33 insertions(+), 14 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/main.c +17 -0
index 6d45518edbdc..d7145ab6105d 100644
+++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c
@@ -459,6 +459,7 @@ static int handle_hca_cap_atomic(struct mlx5_core_dev *dev)
 	return err;
 }
 
+#ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING
 static int handle_hca_cap_odp(struct mlx5_core_dev *dev)
 {
 	void *set_hca_cap;
@@ -502,6 +503,7 @@ static int handle_hca_cap_odp(struct mlx5_core_dev *dev)
 	kfree(set_ctx);
 	return err;
 }
+#endif
 
 static int handle_hca_cap(struct mlx5_core_dev *dev)
 {
@@ -576,6 +578,35 @@ 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");

drivers/net/ethernet/mellanox/mlx5/core/main.c static int handle_hca_cap(struct mlx5_core_dev *dev) · line 604

Quoted 10 lines
drivers/net/ethernet/mellanox/mlx5/core/main.c +10 -0
+		goto out;
+	}
+
+#ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING
+	err = handle_hca_cap_odp(dev);
+	if (err) {
+		dev_err(&pdev->dev, "handle_hca_cap_odp failed\n");
+		goto out;
+	}
+#endif

Adding
if (IS_ENABLED..)

    return 0;
Quoted 5 lines
Quoted 1 line

To the top of handle_hca_cap_odp is alot better.

Saeed gave comment that he prefers code to be compiled-out in case config is not set. In you suggestion, the code will exist and only with some optimizations enabled it will be thrown.

the kernel always compiles with optimizations that will throw away this code, it is a widely used pattern.

#ifdef creates a compilation test matrix that is very undesired.

Jason

#6 lore raw

Re: [PATCH mlx5-next 2/2] net/mlx5: Factor out HCA capabilities functions

Quoted 74 lines · Jason Gunthorpe
Quoted 73 lines · Leon Romanovsky
Quoted 71 lines · Jason Gunthorpe
Quoted 54 lines · Leon Romanovsky

From: Leon Romanovsky <[email protected]>

Combine all HCA capabilities setters under one function and compile out the ODP related function in case kernel was compiled without ODP support.

 .../net/ethernet/mellanox/mlx5/core/main.c    | 47
+++++++++++++------
 1 file changed, 33 insertions(+), 14 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/main.c +2 -0
index 6d45518edbdc..d7145ab6105d 100644
+++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c
@@ -459,6 +459,7 @@ static int handle_hca_cap_atomic(struct
 mlx5_core_dev *dev)
 	return err;
 }
 
+#ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING
 static int handle_hca_cap_odp(struct mlx5_core_dev *dev)
 {
drivers/net/ethernet/mellanox/mlx5/core/main.c +1 -0
 	void *set_hca_cap;
@@ -502,6 +503,7 @@ static int handle_hca_cap_odp(struct
 mlx5_core_dev *dev)
 	kfree(set_ctx);
 	return err;
 }
+#endif
 
 static int handle_hca_cap(struct mlx5_core_dev *dev)

{

drivers/net/ethernet/mellanox/mlx5/core/main.c +15 -0
@@ -576,6 +578,35 @@ 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;

drivers/net/ethernet/mellanox/mlx5/core/main.c static int handle_hca_cap(struct · line 607

Quoted 10 lines
drivers/net/ethernet/mellanox/mlx5/core/main.c +9 -0
+	}
+
+#ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING
+	err = handle_hca_cap_odp(dev);
+	if (err) {
+		dev_err(&pdev->dev, "handle_hca_cap_odp
 failed\n");
+		goto out;
+	}
+#endif

Adding
if (IS_ENABLED..)

    return 0;

To the top of handle_hca_cap_odp is alot better.

Quoted 9 lines
Quoted 3 lines

Saeed gave comment that he prefers code to be compiled-out in case config is not set. In you suggestion, the code will exist and only with some optimizations enabled it will be thrown.

the kernel always compiles with optimizations that will throw away this code, it is a widely used pattern.

#ifdef creates a compilation test matrix that is very undesired.

It is more about code separation and readability rather than compiler optimizations, optimally i want to have a file(s) that will include all IB stuff and compile out directly from Makefile, of course we still need stub functions in a header file which will yield the same compilation test matrix, but code readability and separation will become more clear.

-Saeed.

Quoted 1 line

Jason

#7 lore raw
In reply to Leon Romanovsky
Quoted 10 lines · Leon Romanovsky

From: Leon Romanovsky <[email protected]>

Hi,

There are two small cleanups needed after prefetch MR code was merged.

Thanks

Leon Romanovsky (2):
net/mlx5: Align ODP capability function with netdev coding style

This patch was applied.

Quoted 1 line

net/mlx5: Factor out HCA capabilities functions

This will be resent.

Quoted 7 lines
 .../net/ethernet/mellanox/mlx5/core/main.c    | 62 ++++++++++++-------
 1 file changed, 39 insertions(+), 23 deletions(-)

--
2.19.1