[PATCH net-next 7/7] net/mlx5e: Use extack in set rxfh callback

Tariq Toukan posted 7 patches 1 week, 2 days ago
[PATCH net-next 7/7] net/mlx5e: Use extack in set rxfh callback
Posted by Tariq Toukan 1 week, 2 days ago
From: Gal Pressman <gal@nvidia.com>

The ->set_rxfh() callback now passes a valid extack instead of NULL
through netlink [1]. In case of an error, reflect it through extack instead
of a dmesg print.

[1]
commit c0ae03588bbb ("ethtool: rss: initial RSS_SET (indirection table handling)")

Signed-off-by: Gal Pressman <gal@nvidia.com>
Reviewed-by: Dragos Tatulea <dtatulea@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
---
 .../net/ethernet/mellanox/mlx5/core/en_ethtool.c  | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
index d507366d773e..eb25b19b4a4a 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
@@ -1494,7 +1494,8 @@ static int mlx5e_get_rxfh(struct net_device *netdev, struct ethtool_rxfh_param *
 }
 
 static int mlx5e_rxfh_hfunc_check(struct mlx5e_priv *priv,
-				  const struct ethtool_rxfh_param *rxfh)
+				  const struct ethtool_rxfh_param *rxfh,
+				  struct netlink_ext_ack *extack)
 {
 	unsigned int count;
 
@@ -1504,8 +1505,10 @@ static int mlx5e_rxfh_hfunc_check(struct mlx5e_priv *priv,
 		unsigned int xor8_max_channels = mlx5e_rqt_max_num_channels_allowed_for_xor8();
 
 		if (count > xor8_max_channels) {
-			netdev_err(priv->netdev, "%s: Cannot set RSS hash function to XOR, current number of channels (%d) exceeds the maximum allowed for XOR8 RSS hfunc (%d)\n",
-				   __func__, count, xor8_max_channels);
+			NL_SET_ERR_MSG_FMT_MOD(
+				extack,
+				"Cannot set RSS hash function to XOR, current number of channels (%d) exceeds the maximum allowed for XOR8 RSS hfunc (%d)\n",
+				count, xor8_max_channels);
 			return -EINVAL;
 		}
 	}
@@ -1524,7 +1527,7 @@ static int mlx5e_set_rxfh(struct net_device *dev,
 
 	mutex_lock(&priv->state_lock);
 
-	err = mlx5e_rxfh_hfunc_check(priv, rxfh);
+	err = mlx5e_rxfh_hfunc_check(priv, rxfh, extack);
 	if (err)
 		goto unlock;
 
@@ -1550,7 +1553,7 @@ static int mlx5e_create_rxfh_context(struct net_device *dev,
 
 	mutex_lock(&priv->state_lock);
 
-	err = mlx5e_rxfh_hfunc_check(priv, rxfh);
+	err = mlx5e_rxfh_hfunc_check(priv, rxfh, extack);
 	if (err)
 		goto unlock;
 
@@ -1590,7 +1593,7 @@ static int mlx5e_modify_rxfh_context(struct net_device *dev,
 
 	mutex_lock(&priv->state_lock);
 
-	err = mlx5e_rxfh_hfunc_check(priv, rxfh);
+	err = mlx5e_rxfh_hfunc_check(priv, rxfh, extack);
 	if (err)
 		goto unlock;
 
-- 
2.31.1
Re: [PATCH net-next 7/7] net/mlx5e: Use extack in set rxfh callback
Posted by Simon Horman 1 week ago
On Mon, Sep 22, 2025 at 12:01:11PM +0300, Tariq Toukan wrote:
> From: Gal Pressman <gal@nvidia.com>
> 
> The ->set_rxfh() callback now passes a valid extack instead of NULL
> through netlink [1]. In case of an error, reflect it through extack instead
> of a dmesg print.
> 
> [1]
> commit c0ae03588bbb ("ethtool: rss: initial RSS_SET (indirection table handling)")
> 
> Signed-off-by: Gal Pressman <gal@nvidia.com>
> Reviewed-by: Dragos Tatulea <dtatulea@nvidia.com>
> Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
> ---
>  .../net/ethernet/mellanox/mlx5/core/en_ethtool.c  | 15 +++++++++------
>  1 file changed, 9 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
> index d507366d773e..eb25b19b4a4a 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
> @@ -1494,7 +1494,8 @@ static int mlx5e_get_rxfh(struct net_device *netdev, struct ethtool_rxfh_param *
>  }
>  
>  static int mlx5e_rxfh_hfunc_check(struct mlx5e_priv *priv,
> -				  const struct ethtool_rxfh_param *rxfh)
> +				  const struct ethtool_rxfh_param *rxfh,
> +				  struct netlink_ext_ack *extack)
>  {
>  	unsigned int count;
>  
> @@ -1504,8 +1505,10 @@ static int mlx5e_rxfh_hfunc_check(struct mlx5e_priv *priv,
>  		unsigned int xor8_max_channels = mlx5e_rqt_max_num_channels_allowed_for_xor8();
>  
>  		if (count > xor8_max_channels) {
> -			netdev_err(priv->netdev, "%s: Cannot set RSS hash function to XOR, current number of channels (%d) exceeds the maximum allowed for XOR8 RSS hfunc (%d)\n",
> -				   __func__, count, xor8_max_channels);
> +			NL_SET_ERR_MSG_FMT_MOD(
> +				extack,
> +				"Cannot set RSS hash function to XOR, current number of channels (%d) exceeds the maximum allowed for XOR8 RSS hfunc (%d)\n",
> +				count, xor8_max_channels);
>  			return -EINVAL;
>  		}
>  	}

Hi Tariq and Gal,

Coccinelle says: "WARNING avoid newline at end of message in NL_SET_ERR_MSG_FMT_MOD"

...
Re: [PATCH net-next 7/7] net/mlx5e: Use extack in set rxfh callback
Posted by kernel test robot 1 week, 2 days ago
Hi Tariq,

kernel test robot noticed the following build warnings:

[auto build test WARNING on 312e6f7676e63bbb9b81e5c68e580a9f776cc6f0]

url:    https://github.com/intel-lab-lkp/linux/commits/Tariq-Toukan/net-mlx5-HWS-Generalize-complex-matchers/20250922-170716
base:   312e6f7676e63bbb9b81e5c68e580a9f776cc6f0
patch link:    https://lore.kernel.org/r/1758531671-819655-8-git-send-email-tariqt%40nvidia.com
patch subject: [PATCH net-next 7/7] net/mlx5e: Use extack in set rxfh callback
config: x86_64-rhel-9.4-rust (https://download.01.org/0day-ci/archive/20250923/202509231125.Tsan9Qny-lkp@intel.com/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
rustc: rustc 1.88.0 (6b00bc388 2025-06-23)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250923/202509231125.Tsan9Qny-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202509231125.Tsan9Qny-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c:1508:4: warning: 'snprintf' will always be truncated; specified size is 80, but format string expands to at least 131 [-Wformat-truncation]
    1508 |                         NL_SET_ERR_MSG_FMT_MOD(
         |                         ^
   include/linux/netlink.h:131:2: note: expanded from macro 'NL_SET_ERR_MSG_FMT_MOD'
     131 |         NL_SET_ERR_MSG_FMT((extack), KBUILD_MODNAME ": " fmt, ##args)
         |         ^
   include/linux/netlink.h:116:6: note: expanded from macro 'NL_SET_ERR_MSG_FMT'
     116 |         if (snprintf(__extack->_msg_buf, NETLINK_MAX_FMTMSG_LEN,               \
         |             ^
   1 warning generated.


vim +/snprintf +1508 drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c

  1495	
  1496	static int mlx5e_rxfh_hfunc_check(struct mlx5e_priv *priv,
  1497					  const struct ethtool_rxfh_param *rxfh,
  1498					  struct netlink_ext_ack *extack)
  1499	{
  1500		unsigned int count;
  1501	
  1502		count = priv->channels.params.num_channels;
  1503	
  1504		if (rxfh->hfunc == ETH_RSS_HASH_XOR) {
  1505			unsigned int xor8_max_channels = mlx5e_rqt_max_num_channels_allowed_for_xor8();
  1506	
  1507			if (count > xor8_max_channels) {
> 1508				NL_SET_ERR_MSG_FMT_MOD(
  1509					extack,
  1510					"Cannot set RSS hash function to XOR, current number of channels (%d) exceeds the maximum allowed for XOR8 RSS hfunc (%d)\n",
  1511					count, xor8_max_channels);
  1512				return -EINVAL;
  1513			}
  1514		}
  1515	
  1516		return 0;
  1517	}
  1518	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki