All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH mlx5-next] RDMA/mlx5: Enforce same type port association for multiport RoCE
@ 2024-12-03 13:45 Leon Romanovsky
  2024-12-03 14:03 ` Mateusz Polchlopek
  2024-12-05  8:35 ` Leon Romanovsky
  0 siblings, 2 replies; 3+ messages in thread
From: Leon Romanovsky @ 2024-12-03 13:45 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Patrisious Haddad, Daniel Jurgens, linux-rdma, Mark Bloch, netdev,
	Parav Pandit, Saeed Mahameed, Tariq Toukan

From: Patrisious Haddad <phaddad@nvidia.com>

Different core device types such as PFs and VFs shouldn't be affiliated
together since they have different capabilities, fix that by enforcing
type check before doing the affiliation.

Fixes: 32f69e4be269 ("{net, IB}/mlx5: Manage port association for multiport RoCE")
Reviewed-by: Mark Bloch <mbloch@nvidia.com>
Signed-off-by: Patrisious Haddad <phaddad@nvidia.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
 drivers/infiniband/hw/mlx5/main.c | 6 ++++--
 include/linux/mlx5/driver.h       | 6 ++++++
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c
index bc7930d0c564..c2314797afc9 100644
--- a/drivers/infiniband/hw/mlx5/main.c
+++ b/drivers/infiniband/hw/mlx5/main.c
@@ -3639,7 +3639,8 @@ static int mlx5_ib_init_multiport_master(struct mlx5_ib_dev *dev)
 		list_for_each_entry(mpi, &mlx5_ib_unaffiliated_port_list,
 				    list) {
 			if (dev->sys_image_guid == mpi->sys_image_guid &&
-			    (mlx5_core_native_port_num(mpi->mdev) - 1) == i) {
+			    (mlx5_core_native_port_num(mpi->mdev) - 1) == i &&
+			    mlx5_core_same_coredev_type(dev->mdev, mpi->mdev)) {
 				bound = mlx5_ib_bind_slave_port(dev, mpi);
 			}
 
@@ -4785,7 +4786,8 @@ static int mlx5r_mp_probe(struct auxiliary_device *adev,
 
 	mutex_lock(&mlx5_ib_multiport_mutex);
 	list_for_each_entry(dev, &mlx5_ib_dev_list, ib_dev_list) {
-		if (dev->sys_image_guid == mpi->sys_image_guid)
+		if (dev->sys_image_guid == mpi->sys_image_guid &&
+		    mlx5_core_same_coredev_type(dev->mdev, mpi->mdev))
 			bound = mlx5_ib_bind_slave_port(dev, mpi);
 
 		if (bound) {
diff --git a/include/linux/mlx5/driver.h b/include/linux/mlx5/driver.h
index fc7e6153b73d..4f9e6f6dbaab 100644
--- a/include/linux/mlx5/driver.h
+++ b/include/linux/mlx5/driver.h
@@ -1202,6 +1202,12 @@ static inline bool mlx5_core_is_vf(const struct mlx5_core_dev *dev)
 	return dev->coredev_type == MLX5_COREDEV_VF;
 }
 
+static inline bool mlx5_core_same_coredev_type(const struct mlx5_core_dev *dev1,
+					       const struct mlx5_core_dev *dev2)
+{
+	return dev1->coredev_type == dev2->coredev_type;
+}
+
 static inline bool mlx5_core_is_ecpf(const struct mlx5_core_dev *dev)
 {
 	return dev->caps.embedded_cpu;
-- 
2.47.0


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

* Re: [PATCH mlx5-next] RDMA/mlx5: Enforce same type port association for multiport RoCE
  2024-12-03 13:45 [PATCH mlx5-next] RDMA/mlx5: Enforce same type port association for multiport RoCE Leon Romanovsky
@ 2024-12-03 14:03 ` Mateusz Polchlopek
  2024-12-05  8:35 ` Leon Romanovsky
  1 sibling, 0 replies; 3+ messages in thread
From: Mateusz Polchlopek @ 2024-12-03 14:03 UTC (permalink / raw)
  To: Leon Romanovsky, Jason Gunthorpe
  Cc: Patrisious Haddad, Daniel Jurgens, linux-rdma, Mark Bloch, netdev,
	Parav Pandit, Saeed Mahameed, Tariq Toukan



On 12/3/2024 2:45 PM, Leon Romanovsky wrote:
> From: Patrisious Haddad <phaddad@nvidia.com>
> 
> Different core device types such as PFs and VFs shouldn't be affiliated
> together since they have different capabilities, fix that by enforcing
> type check before doing the affiliation.
> 
> Fixes: 32f69e4be269 ("{net, IB}/mlx5: Manage port association for multiport RoCE")
> Reviewed-by: Mark Bloch <mbloch@nvidia.com>
> Signed-off-by: Patrisious Haddad <phaddad@nvidia.com>
> Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
> ---
>   drivers/infiniband/hw/mlx5/main.c | 6 ++++--
>   include/linux/mlx5/driver.h       | 6 ++++++
>   2 files changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c
> index bc7930d0c564..c2314797afc9 100644
> --- a/drivers/infiniband/hw/mlx5/main.c
> +++ b/drivers/infiniband/hw/mlx5/main.c
> @@ -3639,7 +3639,8 @@ static int mlx5_ib_init_multiport_master(struct mlx5_ib_dev *dev)
>   		list_for_each_entry(mpi, &mlx5_ib_unaffiliated_port_list,
>   				    list) {
>   			if (dev->sys_image_guid == mpi->sys_image_guid &&
> -			    (mlx5_core_native_port_num(mpi->mdev) - 1) == i) {
> +			    (mlx5_core_native_port_num(mpi->mdev) - 1) == i &&
> +			    mlx5_core_same_coredev_type(dev->mdev, mpi->mdev)) {
>   				bound = mlx5_ib_bind_slave_port(dev, mpi);
>   			}
>   
> @@ -4785,7 +4786,8 @@ static int mlx5r_mp_probe(struct auxiliary_device *adev,
>   
>   	mutex_lock(&mlx5_ib_multiport_mutex);
>   	list_for_each_entry(dev, &mlx5_ib_dev_list, ib_dev_list) {
> -		if (dev->sys_image_guid == mpi->sys_image_guid)
> +		if (dev->sys_image_guid == mpi->sys_image_guid &&
> +		    mlx5_core_same_coredev_type(dev->mdev, mpi->mdev))
>   			bound = mlx5_ib_bind_slave_port(dev, mpi);
>   
>   		if (bound) {
> diff --git a/include/linux/mlx5/driver.h b/include/linux/mlx5/driver.h
> index fc7e6153b73d..4f9e6f6dbaab 100644
> --- a/include/linux/mlx5/driver.h
> +++ b/include/linux/mlx5/driver.h
> @@ -1202,6 +1202,12 @@ static inline bool mlx5_core_is_vf(const struct mlx5_core_dev *dev)
>   	return dev->coredev_type == MLX5_COREDEV_VF;
>   }
>   
> +static inline bool mlx5_core_same_coredev_type(const struct mlx5_core_dev *dev1,
> +					       const struct mlx5_core_dev *dev2)
> +{
> +	return dev1->coredev_type == dev2->coredev_type;
> +}
> +
>   static inline bool mlx5_core_is_ecpf(const struct mlx5_core_dev *dev)
>   {
>   	return dev->caps.embedded_cpu;

Hmmm.. Looks good to me

Reviewed-by: Mateusz Polchlopek <mateusz.polchlopek@intel.com>


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

* Re: [PATCH mlx5-next] RDMA/mlx5: Enforce same type port association for multiport RoCE
  2024-12-03 13:45 [PATCH mlx5-next] RDMA/mlx5: Enforce same type port association for multiport RoCE Leon Romanovsky
  2024-12-03 14:03 ` Mateusz Polchlopek
@ 2024-12-05  8:35 ` Leon Romanovsky
  1 sibling, 0 replies; 3+ messages in thread
From: Leon Romanovsky @ 2024-12-05  8:35 UTC (permalink / raw)
  To: Jason Gunthorpe, Leon Romanovsky
  Cc: Patrisious Haddad, Daniel Jurgens, linux-rdma, Mark Bloch, netdev,
	Parav Pandit, Saeed Mahameed, Tariq Toukan


On Tue, 03 Dec 2024 15:45:37 +0200, Leon Romanovsky wrote:
> Different core device types such as PFs and VFs shouldn't be affiliated
> together since they have different capabilities, fix that by enforcing
> type check before doing the affiliation.
> 
> 

Applied, thanks!

[1/1] RDMA/mlx5: Enforce same type port association for multiport RoCE
      https://git.kernel.org/rdma/rdma/c/e05feab22fd7da

Best regards,
-- 
Leon Romanovsky <leon@kernel.org>


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

end of thread, other threads:[~2024-12-05  8:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-03 13:45 [PATCH mlx5-next] RDMA/mlx5: Enforce same type port association for multiport RoCE Leon Romanovsky
2024-12-03 14:03 ` Mateusz Polchlopek
2024-12-05  8:35 ` Leon Romanovsky

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.