net/mlx5: Add support for multiple RoCE enable
authorIlan Tayari <ilant@mellanox.com>
Sun, 26 Mar 2017 14:23:42 +0000 (17:23 +0300)
committerSaeed Mahameed <saeedm@mellanox.com>
Tue, 27 Jun 2017 13:36:47 +0000 (16:36 +0300)
Previously, only mlx5_ib enabled RoCE on the port, but FPGA needs it as
well.
Add support for counting number of enables, so that FPGA and IB can work
in parallel and independently.
Program the HW to enable RoCE on the first enable call, and program to
disable RoCE on the last disable call.

Signed-off-by: Ilan Tayari <ilant@mellanox.com>
Reviewed-by: Boris Pismenny <borisp@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
drivers/net/ethernet/mellanox/mlx5/core/vport.c
include/linux/mlx5/driver.h

index 06019d00ab7ba2078b082ec1ade123b88934c0da..5abfec1c3399547fc41469e65158359a30ae98fb 100644 (file)
@@ -926,12 +926,16 @@ static int mlx5_nic_vport_update_roce_state(struct mlx5_core_dev *mdev,
 
 int mlx5_nic_vport_enable_roce(struct mlx5_core_dev *mdev)
 {
+       if (atomic_inc_return(&mdev->roce.roce_en) != 1)
+               return 0;
        return mlx5_nic_vport_update_roce_state(mdev, MLX5_VPORT_ROCE_ENABLED);
 }
 EXPORT_SYMBOL_GPL(mlx5_nic_vport_enable_roce);
 
 int mlx5_nic_vport_disable_roce(struct mlx5_core_dev *mdev)
 {
+       if (atomic_dec_return(&mdev->roce.roce_en) != 0)
+               return 0;
        return mlx5_nic_vport_update_roce_state(mdev, MLX5_VPORT_ROCE_DISABLED);
 }
 EXPORT_SYMBOL_GPL(mlx5_nic_vport_disable_roce);
index 08e99bd2cd7735c3d21a0f3db52df3641e636501..32b0835d4491f94a25be55c4f76c3a0efc0df607 100644 (file)
@@ -777,6 +777,7 @@ struct mlx5_core_dev {
        struct mlx5e_resources  mlx5e_res;
        struct {
                struct mlx5_rsvd_gids   reserved_gids;
+               atomic_t                roce_en;
        } roce;
 #ifdef CONFIG_MLX5_FPGA
        struct mlx5_fpga_device *fpga;