diff mbox series

[net-next,06/11] net/mlx5e: Use extack in set ringparams callback

Message ID 20240806125804.2048753-7-tariqt@nvidia.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series mlx5 misc patches 2024-08-06 | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 29 this patch: 29
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 1 maintainers not CCed: linux-rdma@vger.kernel.org
netdev/build_clang success Errors and warnings before: 29 this patch: 29
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 30 this patch: 30
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 77 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-08-06--21-00 (tests: 707)

Commit Message

Tariq Toukan Aug. 6, 2024, 12:57 p.m. UTC
From: Gal Pressman <gal@nvidia.com>

In case of errors in set ringparams, reflect it through extack instead
of a dmesg print.
While at it, make the messages more human friendly.

Signed-off-by: Gal Pressman <gal@nvidia.com>
Reviewed-by: Cosmin Ratiu <cratiu@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en.h  |  3 ++-
 .../ethernet/mellanox/mlx5/core/en_ethtool.c  | 23 +++++++++----------
 .../net/ethernet/mellanox/mlx5/core/en_rep.c  |  2 +-
 .../mellanox/mlx5/core/ipoib/ethtool.c        |  2 +-
 4 files changed, 15 insertions(+), 15 deletions(-)

Comments

Jakub Kicinski Aug. 7, 2024, 1:16 a.m. UTC | #1
On Tue, 6 Aug 2024 15:57:59 +0300 Tariq Toukan wrote:
>  	if (param->rx_jumbo_pending) {
> -		netdev_info(priv->netdev, "%s: rx_jumbo_pending not supported\n",
> -			    __func__);
> +		NL_SET_ERR_MSG_MOD(extack, "rx-jumbo not supported");
>  		return -EINVAL;
>  	}
>  	if (param->rx_mini_pending) {
> -		netdev_info(priv->netdev, "%s: rx_mini_pending not supported\n",
> -			    __func__);
> +		NL_SET_ERR_MSG_MOD(extack, "rx-mini not supported");
>  		return -EINVAL;
>  	}

This is dead code in the first place, mlx5 doesn't set associated max
values so:

	if (ringparam.rx_pending > max.rx_max_pending ||
	    ringparam.rx_mini_pending > max.rx_mini_max_pending ||
	    ringparam.rx_jumbo_pending > max.rx_jumbo_max_pending ||
	    ringparam.tx_pending > max.tx_max_pending)
		return -EINVAL;

in the core will reject any attempts at using these.
Gal Pressman Aug. 7, 2024, 6:22 a.m. UTC | #2
On 07/08/2024 4:16, Jakub Kicinski wrote:
> On Tue, 6 Aug 2024 15:57:59 +0300 Tariq Toukan wrote:
>>  	if (param->rx_jumbo_pending) {
>> -		netdev_info(priv->netdev, "%s: rx_jumbo_pending not supported\n",
>> -			    __func__);
>> +		NL_SET_ERR_MSG_MOD(extack, "rx-jumbo not supported");
>>  		return -EINVAL;
>>  	}
>>  	if (param->rx_mini_pending) {
>> -		netdev_info(priv->netdev, "%s: rx_mini_pending not supported\n",
>> -			    __func__);
>> +		NL_SET_ERR_MSG_MOD(extack, "rx-mini not supported");
>>  		return -EINVAL;
>>  	}
> 
> This is dead code in the first place, mlx5 doesn't set associated max
> values so:
> 
> 	if (ringparam.rx_pending > max.rx_max_pending ||
> 	    ringparam.rx_mini_pending > max.rx_mini_max_pending ||
> 	    ringparam.rx_jumbo_pending > max.rx_jumbo_max_pending ||
> 	    ringparam.tx_pending > max.tx_max_pending)
> 		return -EINVAL;
> 
> in the core will reject any attempts at using these.

Good catch, thanks!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h
index 5fd82c67b6ab..01781b70434c 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h
@@ -1172,7 +1172,8 @@  void mlx5e_ethtool_get_ringparam(struct mlx5e_priv *priv,
 				 struct ethtool_ringparam *param,
 				 struct kernel_ethtool_ringparam *kernel_param);
 int mlx5e_ethtool_set_ringparam(struct mlx5e_priv *priv,
-				struct ethtool_ringparam *param);
+				struct ethtool_ringparam *param,
+				struct netlink_ext_ack *extack);
 void mlx5e_ethtool_get_channels(struct mlx5e_priv *priv,
 				struct ethtool_channels *ch);
 int mlx5e_ethtool_set_channels(struct mlx5e_priv *priv,
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
index 5fd81253d6b9..f162fd0355ed 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
@@ -352,7 +352,8 @@  static void mlx5e_get_ringparam(struct net_device *dev,
 }
 
 int mlx5e_ethtool_set_ringparam(struct mlx5e_priv *priv,
-				struct ethtool_ringparam *param)
+				struct ethtool_ringparam *param,
+				struct netlink_ext_ack *extack)
 {
 	struct mlx5e_params new_params;
 	u8 log_rq_size;
@@ -360,27 +361,25 @@  int mlx5e_ethtool_set_ringparam(struct mlx5e_priv *priv,
 	int err = 0;
 
 	if (param->rx_jumbo_pending) {
-		netdev_info(priv->netdev, "%s: rx_jumbo_pending not supported\n",
-			    __func__);
+		NL_SET_ERR_MSG_MOD(extack, "rx-jumbo not supported");
 		return -EINVAL;
 	}
 	if (param->rx_mini_pending) {
-		netdev_info(priv->netdev, "%s: rx_mini_pending not supported\n",
-			    __func__);
+		NL_SET_ERR_MSG_MOD(extack, "rx-mini not supported");
 		return -EINVAL;
 	}
 
 	if (param->rx_pending < (1 << MLX5E_PARAMS_MINIMUM_LOG_RQ_SIZE)) {
-		netdev_info(priv->netdev, "%s: rx_pending (%d) < min (%d)\n",
-			    __func__, param->rx_pending,
-			    1 << MLX5E_PARAMS_MINIMUM_LOG_RQ_SIZE);
+		NL_SET_ERR_MSG_FMT_MOD(extack, "rx (%d) < min (%d)",
+				       param->rx_pending,
+				       1 << MLX5E_PARAMS_MINIMUM_LOG_RQ_SIZE);
 		return -EINVAL;
 	}
 
 	if (param->tx_pending < (1 << MLX5E_PARAMS_MINIMUM_LOG_SQ_SIZE)) {
-		netdev_info(priv->netdev, "%s: tx_pending (%d) < min (%d)\n",
-			    __func__, param->tx_pending,
-			    1 << MLX5E_PARAMS_MINIMUM_LOG_SQ_SIZE);
+		NL_SET_ERR_MSG_FMT_MOD(extack, "tx (%d) < min (%d)",
+				       param->tx_pending,
+				       1 << MLX5E_PARAMS_MINIMUM_LOG_SQ_SIZE);
 		return -EINVAL;
 	}
 
@@ -416,7 +415,7 @@  static int mlx5e_set_ringparam(struct net_device *dev,
 {
 	struct mlx5e_priv *priv = netdev_priv(dev);
 
-	return mlx5e_ethtool_set_ringparam(priv, param);
+	return mlx5e_ethtool_set_ringparam(priv, param, extack);
 }
 
 void mlx5e_ethtool_get_channels(struct mlx5e_priv *priv,
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
index 8790d57dc6db..916ba0db29f2 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
@@ -360,7 +360,7 @@  mlx5e_rep_set_ringparam(struct net_device *dev,
 {
 	struct mlx5e_priv *priv = netdev_priv(dev);
 
-	return mlx5e_ethtool_set_ringparam(priv, param);
+	return mlx5e_ethtool_set_ringparam(priv, param, extack);
 }
 
 static void mlx5e_rep_get_channels(struct net_device *dev,
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ethtool.c
index 26f8a11b8906..424ff39db28d 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ethtool.c
@@ -74,7 +74,7 @@  static int mlx5i_set_ringparam(struct net_device *dev,
 {
 	struct mlx5e_priv *priv = mlx5i_epriv(dev);
 
-	return mlx5e_ethtool_set_ringparam(priv, param);
+	return mlx5e_ethtool_set_ringparam(priv, param, extack);
 }
 
 static void mlx5i_get_ringparam(struct net_device *dev,