aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorAmir Vadai <amirv@mellanox.com>2015-04-27 06:40:56 -0400
committerDavid S. Miller <davem@davemloft.net>2015-04-27 13:36:48 -0400
commitb37069090b7c5615610a8aa6b36533d67b364d38 (patch)
tree51016dd7408b67d63b09da9c8f3d024f0a67bcac /drivers/net
parent33df10e2ee414183953cc89453bf9c85027a188b (diff)
net/mlx4_en: Prevent setting invalid RSS hash function
mlx4_en_check_rxfh_func() was checking for hardware support before setting a known RSS hash function, but didn't do any check before setting unknown RSS hash function. Need to make it fail on such values. In this occasion, moved the actual setting of the new value from the check function into mlx4_en_set_rxfh(). Fixes: 947cbb0 ("net/mlx4_en: Support for configurable RSS hash function") Signed-off-by: Amir Vadai <amirv@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_ethtool.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
index 3f44e2bbb982..a2ddf3d75ff8 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
@@ -1102,20 +1102,21 @@ static int mlx4_en_check_rxfh_func(struct net_device *dev, u8 hfunc)
1102 struct mlx4_en_priv *priv = netdev_priv(dev); 1102 struct mlx4_en_priv *priv = netdev_priv(dev);
1103 1103
1104 /* check if requested function is supported by the device */ 1104 /* check if requested function is supported by the device */
1105 if ((hfunc == ETH_RSS_HASH_TOP && 1105 if (hfunc == ETH_RSS_HASH_TOP) {
1106 !(priv->mdev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_RSS_TOP)) || 1106 if (!(priv->mdev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_RSS_TOP))
1107 (hfunc == ETH_RSS_HASH_XOR && 1107 return -EINVAL;
1108 !(priv->mdev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_RSS_XOR))) 1108 if (!(dev->features & NETIF_F_RXHASH))
1109 return -EINVAL; 1109 en_warn(priv, "Toeplitz hash function should be used in conjunction with RX hashing for optimal performance\n");
1110 return 0;
1111 } else if (hfunc == ETH_RSS_HASH_XOR) {
1112 if (!(priv->mdev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_RSS_XOR))
1113 return -EINVAL;
1114 if (dev->features & NETIF_F_RXHASH)
1115 en_warn(priv, "Enabling both XOR Hash function and RX Hashing can limit RPS functionality\n");
1116 return 0;
1117 }
1110 1118
1111 priv->rss_hash_fn = hfunc; 1119 return -EINVAL;
1112 if (hfunc == ETH_RSS_HASH_TOP && !(dev->features & NETIF_F_RXHASH))
1113 en_warn(priv,
1114 "Toeplitz hash function should be used in conjunction with RX hashing for optimal performance\n");
1115 if (hfunc == ETH_RSS_HASH_XOR && (dev->features & NETIF_F_RXHASH))
1116 en_warn(priv,
1117 "Enabling both XOR Hash function and RX Hashing can limit RPS functionality\n");
1118 return 0;
1119} 1120}
1120 1121
1121static int mlx4_en_get_rxfh(struct net_device *dev, u32 *ring_index, u8 *key, 1122static int mlx4_en_get_rxfh(struct net_device *dev, u32 *ring_index, u8 *key,
@@ -1189,6 +1190,8 @@ static int mlx4_en_set_rxfh(struct net_device *dev, const u32 *ring_index,
1189 priv->prof->rss_rings = rss_rings; 1190 priv->prof->rss_rings = rss_rings;
1190 if (key) 1191 if (key)
1191 memcpy(priv->rss_key, key, MLX4_EN_RSS_KEY_SIZE); 1192 memcpy(priv->rss_key, key, MLX4_EN_RSS_KEY_SIZE);
1193 if (hfunc != ETH_RSS_HASH_NO_CHANGE)
1194 priv->rss_hash_fn = hfunc;
1192 1195
1193 if (port_up) { 1196 if (port_up) {
1194 err = mlx4_en_start_port(dev); 1197 err = mlx4_en_start_port(dev);