net/mlx5e: Correct the calculation of max channels for rep
authorMoshe Tal <moshet@nvidia.com>
Wed, 27 Apr 2022 15:26:52 +0000 (18:26 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Jun 2022 08:25:54 +0000 (10:25 +0200)
[ Upstream commit 6d0ba49321a40a8dada22c223bbe91c063b08db4 ]

Correct the calculation of maximum channels of rep to better utilize
the hardware resources and allow a larger scale of reps.

This will allow creation of all virtual ports configured.

Fixes: 473baf2e9e8c ("net/mlx5e: Allow profile-specific limitation on max num of channels")
Signed-off-by: Moshe Tal <moshet@nvidia.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/mellanox/mlx5/core/en.h
drivers/net/ethernet/mellanox/mlx5/core/en_main.c
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c

index c14e06ca64d8d7f3dbc25c4839af6b5879f3c8a9..5ccd6c634274b7c97b35020723c5d258b63c3849 100644 (file)
@@ -1188,6 +1188,7 @@ mlx5e_tx_mpwqe_supported(struct mlx5_core_dev *mdev)
                MLX5_CAP_ETH(mdev, enhanced_multi_pkt_send_wqe);
 }
 
+int mlx5e_get_pf_num_tirs(struct mlx5_core_dev *mdev);
 int mlx5e_priv_init(struct mlx5e_priv *priv,
                    const struct mlx5e_profile *profile,
                    struct net_device *netdev,
index 3500faf086710d4c5aa396e34561bf4a4f1b2d3f..531fffe1abe3a557ac194ad5285a8cacc39fef78 100644 (file)
@@ -5206,6 +5206,15 @@ mlx5e_calc_max_nch(struct mlx5_core_dev *mdev, struct net_device *netdev,
        return max_nch;
 }
 
+int mlx5e_get_pf_num_tirs(struct mlx5_core_dev *mdev)
+{
+       /* Indirect TIRS: 2 sets of TTCs (inner + outer steering)
+        * and 1 set of direct TIRS
+        */
+       return 2 * MLX5E_NUM_INDIR_TIRS
+               + mlx5e_profile_max_num_channels(mdev, &mlx5e_nic_profile);
+}
+
 /* mlx5e generic netdev management API (move to en_common.c) */
 int mlx5e_priv_init(struct mlx5e_priv *priv,
                    const struct mlx5e_profile *profile,
index 06d1f46f16887792f101cdfca7726a2af3954870..f6a1c5efdb25feeac8483ceb92c9e98644c384c0 100644 (file)
@@ -592,10 +592,16 @@ bool mlx5e_eswitch_vf_rep(const struct net_device *netdev)
        return netdev->netdev_ops == &mlx5e_netdev_ops_rep;
 }
 
+/* One indirect TIR set for outer. Inner not supported in reps. */
+#define REP_NUM_INDIR_TIRS MLX5E_NUM_INDIR_TIRS
+
 static int mlx5e_rep_max_nch_limit(struct mlx5_core_dev *mdev)
 {
-       return (1 << MLX5_CAP_GEN(mdev, log_max_tir)) /
-               mlx5_eswitch_get_total_vports(mdev);
+       int max_tir_num = 1 << MLX5_CAP_GEN(mdev, log_max_tir);
+       int num_vports = mlx5_eswitch_get_total_vports(mdev);
+
+       return (max_tir_num - mlx5e_get_pf_num_tirs(mdev)
+               - (num_vports * REP_NUM_INDIR_TIRS)) / num_vports;
 }
 
 static void mlx5e_build_rep_params(struct net_device *netdev)