All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH rdma-next 0/2] Limit to raw Ethernet QPs for raw ETH profile
@ 2020-05-06  7:16 Leon Romanovsky
  2020-05-06  7:16 ` [PATCH rdma-next 1/2] RDMA/mlx5: Assign profile before calling stages Leon Romanovsky
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Leon Romanovsky @ 2020-05-06  7:16 UTC (permalink / raw)
  To: Doug Ledford, Jason Gunthorpe; +Cc: Leon Romanovsky, linux-rdma, Mark Bloch

From: Leon Romanovsky <leonro@mellanox.com>

Hi,

This is a fix to restrict opening any other QP types except RAW_PACKET
if we are using raw ETH profile.

Thanks

Mark Bloch (2):
  RDMA/mlx5: Assign profile before calling stages
  RDMA/mlx5: Allow only raw Ethernet QPs when RoCE isn't enabled

 drivers/infiniband/hw/mlx5/ib_rep.h |  2 +-
 drivers/infiniband/hw/mlx5/main.c   |  3 ++-
 drivers/infiniband/hw/mlx5/qp.c     | 12 +++++++++---
 3 files changed, 12 insertions(+), 5 deletions(-)

--
2.26.2


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH rdma-next 1/2] RDMA/mlx5: Assign profile before calling stages
  2020-05-06  7:16 [PATCH rdma-next 0/2] Limit to raw Ethernet QPs for raw ETH profile Leon Romanovsky
@ 2020-05-06  7:16 ` Leon Romanovsky
  2020-05-06  7:16 ` [PATCH rdma-next 2/2] RDMA/mlx5: Allow only raw Ethernet QPs when RoCE isn't enabled Leon Romanovsky
  2020-05-06 22:49 ` [PATCH rdma-next 0/2] Limit to raw Ethernet QPs for raw ETH profile Jason Gunthorpe
  2 siblings, 0 replies; 4+ messages in thread
From: Leon Romanovsky @ 2020-05-06  7:16 UTC (permalink / raw)
  To: Doug Ledford, Jason Gunthorpe; +Cc: Mark Bloch, linux-rdma

From: Mark Bloch <markb@mellanox.com>

Assign the profile to the IB device before executing stages. This will
allow to check which profile is being used from within a stage.

Signed-off-by: Mark Bloch <markb@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
 drivers/infiniband/hw/mlx5/ib_rep.h | 2 +-
 drivers/infiniband/hw/mlx5/main.c   | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/hw/mlx5/ib_rep.h b/drivers/infiniband/hw/mlx5/ib_rep.h
index 3b6750cba796..5b30d3fa8f8d 100644
--- a/drivers/infiniband/hw/mlx5/ib_rep.h
+++ b/drivers/infiniband/hw/mlx5/ib_rep.h
@@ -9,9 +9,9 @@
 #include <linux/mlx5/eswitch.h>
 #include "mlx5_ib.h"
 
-#ifdef CONFIG_MLX5_ESWITCH
 extern const struct mlx5_ib_profile raw_eth_profile;
 
+#ifdef CONFIG_MLX5_ESWITCH
 u8 mlx5_ib_eswitch_mode(struct mlx5_eswitch *esw);
 struct mlx5_ib_dev *mlx5_ib_get_rep_ibdev(struct mlx5_eswitch *esw,
 					  u16 vport_num);
diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c
index c5f5aeea82b0..65790e2b442c 100644
--- a/drivers/infiniband/hw/mlx5/main.c
+++ b/drivers/infiniband/hw/mlx5/main.c
@@ -7131,6 +7131,8 @@ void *__mlx5_ib_add(struct mlx5_ib_dev *dev,
 	int err;
 	int i;
 
+	dev->profile = profile;
+
 	for (i = 0; i < MLX5_IB_STAGE_MAX; i++) {
 		if (profile->stage[i].init) {
 			err = profile->stage[i].init(dev);
@@ -7139,7 +7141,6 @@ void *__mlx5_ib_add(struct mlx5_ib_dev *dev,
 		}
 	}
 
-	dev->profile = profile;
 	dev->ib_active = true;
 
 	return dev;
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH rdma-next 2/2] RDMA/mlx5: Allow only raw Ethernet QPs when RoCE isn't enabled
  2020-05-06  7:16 [PATCH rdma-next 0/2] Limit to raw Ethernet QPs for raw ETH profile Leon Romanovsky
  2020-05-06  7:16 ` [PATCH rdma-next 1/2] RDMA/mlx5: Assign profile before calling stages Leon Romanovsky
@ 2020-05-06  7:16 ` Leon Romanovsky
  2020-05-06 22:49 ` [PATCH rdma-next 0/2] Limit to raw Ethernet QPs for raw ETH profile Jason Gunthorpe
  2 siblings, 0 replies; 4+ messages in thread
From: Leon Romanovsky @ 2020-05-06  7:16 UTC (permalink / raw)
  To: Doug Ledford, Jason Gunthorpe; +Cc: Mark Bloch, linux-rdma

From: Mark Bloch <markb@mellanox.com>

When operating in switchdev mode or using devlink to disable RoCE
only raw Ethernet QPs are allowed to be created.

When in switchdev mode this can lead to passing an invalid port number
as part of the modify qp firmware cmd and will lead to a syndrome
reported back to the user, such as:

 * mlx5_cmd_check:803:(pid 50148): RST2INIT_QP(0x502) op_mod(0x0) failed,
   status bad parameter(0x3), syndrome (0x177405).

Internal UD QP might be used to test for write combining support (even if
externally we report RoCE as disabled) check for that specific flag and
allow is specifically.

Fixes: b5ca15ad7e61 ("IB/mlx5: Add proper representors support")
Signed-off-by: Mark Bloch <markb@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
 drivers/infiniband/hw/mlx5/qp.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c
index fb2ea3bf9be4..40150595fdbb 100644
--- a/drivers/infiniband/hw/mlx5/qp.c
+++ b/drivers/infiniband/hw/mlx5/qp.c
@@ -2436,15 +2436,17 @@ static int check_qp_type(struct mlx5_ib_dev *dev, struct ib_qp_init_attr *attr,
 		if (!MLX5_CAP_GEN(dev->mdev, xrc))
 			goto out;
 		fallthrough;
-	case IB_QPT_RAW_PACKET:
 	case IB_QPT_RC:
 	case IB_QPT_UC:
-	case IB_QPT_UD:
 	case IB_QPT_SMI:
 	case MLX5_IB_QPT_HW_GSI:
-	case MLX5_IB_QPT_REG_UMR:
 	case IB_QPT_DRIVER:
 	case IB_QPT_GSI:
+		if (dev->profile == &raw_eth_profile)
+			goto out;
+	case IB_QPT_RAW_PACKET:
+	case IB_QPT_UD:
+	case MLX5_IB_QPT_REG_UMR:
 		break;
 	default:
 		goto out;
@@ -2641,6 +2643,10 @@ static int process_create_flags(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp,
 	int create_flags = attr->create_flags;
 	bool cond;

+	if (qp->type == IB_QPT_UD && dev->profile == &raw_eth_profile)
+		if (create_flags & ~MLX5_IB_QP_CREATE_WC_TEST)
+			return -EINVAL;
+
 	if (qp_type == MLX5_IB_QPT_DCT)
 		return (create_flags) ? -EINVAL : 0;

--
2.26.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH rdma-next 0/2] Limit to raw Ethernet QPs for raw ETH profile
  2020-05-06  7:16 [PATCH rdma-next 0/2] Limit to raw Ethernet QPs for raw ETH profile Leon Romanovsky
  2020-05-06  7:16 ` [PATCH rdma-next 1/2] RDMA/mlx5: Assign profile before calling stages Leon Romanovsky
  2020-05-06  7:16 ` [PATCH rdma-next 2/2] RDMA/mlx5: Allow only raw Ethernet QPs when RoCE isn't enabled Leon Romanovsky
@ 2020-05-06 22:49 ` Jason Gunthorpe
  2 siblings, 0 replies; 4+ messages in thread
From: Jason Gunthorpe @ 2020-05-06 22:49 UTC (permalink / raw)
  To: Leon Romanovsky; +Cc: Doug Ledford, Leon Romanovsky, linux-rdma, Mark Bloch

On Wed, May 06, 2020 at 10:16:00AM +0300, Leon Romanovsky wrote:
> From: Leon Romanovsky <leonro@mellanox.com>
> 
> Hi,
> 
> This is a fix to restrict opening any other QP types except RAW_PACKET
> if we are using raw ETH profile.
> 
> Thanks
> 
> Mark Bloch (2):
>   RDMA/mlx5: Assign profile before calling stages
>   RDMA/mlx5: Allow only raw Ethernet QPs when RoCE isn't enabled
> 
>  drivers/infiniband/hw/mlx5/ib_rep.h |  2 +-
>  drivers/infiniband/hw/mlx5/main.c   |  3 ++-
>  drivers/infiniband/hw/mlx5/qp.c     | 12 +++++++++---
>  3 files changed, 12 insertions(+), 5 deletions(-)

Applied to for-next, thanks

Jason

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-05-06 22:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-06  7:16 [PATCH rdma-next 0/2] Limit to raw Ethernet QPs for raw ETH profile Leon Romanovsky
2020-05-06  7:16 ` [PATCH rdma-next 1/2] RDMA/mlx5: Assign profile before calling stages Leon Romanovsky
2020-05-06  7:16 ` [PATCH rdma-next 2/2] RDMA/mlx5: Allow only raw Ethernet QPs when RoCE isn't enabled Leon Romanovsky
2020-05-06 22:49 ` [PATCH rdma-next 0/2] Limit to raw Ethernet QPs for raw ETH profile Jason Gunthorpe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.