aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMoshe Shemesh <moshe@mellanox.com>2018-02-15 05:41:48 -0500
committerSaeed Mahameed <saeedm@mellanox.com>2018-03-26 16:58:15 -0400
commitb392a2078b5e0094ff38aa0c9d2a31b3f607d4ef (patch)
tree65942abe7e55a0bc77fdff8f523b678d1efd3c4d
parentf125376b06bcc57dfb0216ac8d6ec6d5dcf81025 (diff)
net/mlx5e: Verify coalescing parameters in range
Add check of coalescing parameters received through ethtool are within range of values supported by the HW. Driver gets the coalescing rx/tx-usecs and rx/tx-frames as set by the users through ethtool. The ethtool support up to 32 bit value for each. However, mlx5 modify cq limits the coalescing time parameter to 12 bit and coalescing frames parameters to 16 bits. Return out of range error if user tries to set these parameters to higher values. Fixes: f62b8bb8f2d3 ('net/mlx5: Extend mlx5_core to support ConnectX-4 Ethernet functionality') Signed-off-by: Moshe Shemesh <moshe@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
index cc8048f68f11..59ebfdae6695 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
@@ -477,6 +477,9 @@ static int mlx5e_get_coalesce(struct net_device *netdev,
477 return mlx5e_ethtool_get_coalesce(priv, coal); 477 return mlx5e_ethtool_get_coalesce(priv, coal);
478} 478}
479 479
480#define MLX5E_MAX_COAL_TIME MLX5_MAX_CQ_PERIOD
481#define MLX5E_MAX_COAL_FRAMES MLX5_MAX_CQ_COUNT
482
480static void 483static void
481mlx5e_set_priv_channels_coalesce(struct mlx5e_priv *priv, struct ethtool_coalesce *coal) 484mlx5e_set_priv_channels_coalesce(struct mlx5e_priv *priv, struct ethtool_coalesce *coal)
482{ 485{
@@ -511,6 +514,20 @@ int mlx5e_ethtool_set_coalesce(struct mlx5e_priv *priv,
511 if (!MLX5_CAP_GEN(mdev, cq_moderation)) 514 if (!MLX5_CAP_GEN(mdev, cq_moderation))
512 return -EOPNOTSUPP; 515 return -EOPNOTSUPP;
513 516
517 if (coal->tx_coalesce_usecs > MLX5E_MAX_COAL_TIME ||
518 coal->rx_coalesce_usecs > MLX5E_MAX_COAL_TIME) {
519 netdev_info(priv->netdev, "%s: maximum coalesce time supported is %lu usecs\n",
520 __func__, MLX5E_MAX_COAL_TIME);
521 return -ERANGE;
522 }
523
524 if (coal->tx_max_coalesced_frames > MLX5E_MAX_COAL_FRAMES ||
525 coal->rx_max_coalesced_frames > MLX5E_MAX_COAL_FRAMES) {
526 netdev_info(priv->netdev, "%s: maximum coalesced frames supported is %lu\n",
527 __func__, MLX5E_MAX_COAL_FRAMES);
528 return -ERANGE;
529 }
530
514 mutex_lock(&priv->state_lock); 531 mutex_lock(&priv->state_lock);
515 new_channels.params = priv->channels.params; 532 new_channels.params = priv->channels.params;
516 533