Commit b9d1ab7e authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

mlx4: use netdev_rss_key_fill() helper

Use of well known RSS key increases attack surface.
Switch to a random one, using generic helper so that all
ports share a common key.

Also provide ethtool -x support to fetch RSS key
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Cc: Amir Vadai <amirv@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9913c61c
...@@ -973,6 +973,11 @@ static u32 mlx4_en_get_rxfh_indir_size(struct net_device *dev) ...@@ -973,6 +973,11 @@ static u32 mlx4_en_get_rxfh_indir_size(struct net_device *dev)
return priv->rx_ring_num; return priv->rx_ring_num;
} }
static u32 mlx4_en_get_rxfh_key_size(struct net_device *netdev)
{
return MLX4_EN_RSS_KEY_SIZE;
}
static int mlx4_en_get_rxfh(struct net_device *dev, u32 *ring_index, u8 *key) static int mlx4_en_get_rxfh(struct net_device *dev, u32 *ring_index, u8 *key)
{ {
struct mlx4_en_priv *priv = netdev_priv(dev); struct mlx4_en_priv *priv = netdev_priv(dev);
...@@ -988,7 +993,8 @@ static int mlx4_en_get_rxfh(struct net_device *dev, u32 *ring_index, u8 *key) ...@@ -988,7 +993,8 @@ static int mlx4_en_get_rxfh(struct net_device *dev, u32 *ring_index, u8 *key)
ring_index[n] = rss_map->qps[n % rss_rings].qpn - ring_index[n] = rss_map->qps[n % rss_rings].qpn -
rss_map->base_qpn; rss_map->base_qpn;
} }
if (key)
netdev_rss_key_fill(key, MLX4_EN_RSS_KEY_SIZE);
return err; return err;
} }
...@@ -1799,6 +1805,7 @@ const struct ethtool_ops mlx4_en_ethtool_ops = { ...@@ -1799,6 +1805,7 @@ const struct ethtool_ops mlx4_en_ethtool_ops = {
.get_rxnfc = mlx4_en_get_rxnfc, .get_rxnfc = mlx4_en_get_rxnfc,
.set_rxnfc = mlx4_en_set_rxnfc, .set_rxnfc = mlx4_en_set_rxnfc,
.get_rxfh_indir_size = mlx4_en_get_rxfh_indir_size, .get_rxfh_indir_size = mlx4_en_get_rxfh_indir_size,
.get_rxfh_key_size = mlx4_en_get_rxfh_key_size,
.get_rxfh = mlx4_en_get_rxfh, .get_rxfh = mlx4_en_get_rxfh,
.set_rxfh = mlx4_en_set_rxfh, .set_rxfh = mlx4_en_set_rxfh,
.get_channels = mlx4_en_get_channels, .get_channels = mlx4_en_get_channels,
......
...@@ -1169,9 +1169,6 @@ int mlx4_en_config_rss_steer(struct mlx4_en_priv *priv) ...@@ -1169,9 +1169,6 @@ int mlx4_en_config_rss_steer(struct mlx4_en_priv *priv)
int i, qpn; int i, qpn;
int err = 0; int err = 0;
int good_qps = 0; int good_qps = 0;
static const u32 rsskey[10] = { 0xD181C62C, 0xF7F4DB5B, 0x1983A2FC,
0x943E1ADB, 0xD9389E6B, 0xD1039C2C, 0xA74499AD,
0x593D56D9, 0xF3253C06, 0x2ADC1FFC};
en_dbg(DRV, priv, "Configuring rss steering\n"); en_dbg(DRV, priv, "Configuring rss steering\n");
err = mlx4_qp_reserve_range(mdev->dev, priv->rx_ring_num, err = mlx4_qp_reserve_range(mdev->dev, priv->rx_ring_num,
...@@ -1226,8 +1223,7 @@ int mlx4_en_config_rss_steer(struct mlx4_en_priv *priv) ...@@ -1226,8 +1223,7 @@ int mlx4_en_config_rss_steer(struct mlx4_en_priv *priv)
rss_context->flags = rss_mask; rss_context->flags = rss_mask;
rss_context->hash_fn = MLX4_RSS_HASH_TOP; rss_context->hash_fn = MLX4_RSS_HASH_TOP;
for (i = 0; i < 10; i++) netdev_rss_key_fill(rss_context->rss_key, MLX4_EN_RSS_KEY_SIZE);
rss_context->rss_key[i] = cpu_to_be32(rsskey[i]);
err = mlx4_qp_to_ready(mdev->dev, &priv->res.mtt, &context, err = mlx4_qp_to_ready(mdev->dev, &priv->res.mtt, &context,
&rss_map->indir_qp, &rss_map->indir_state); &rss_map->indir_qp, &rss_map->indir_state);
......
...@@ -120,13 +120,15 @@ enum { ...@@ -120,13 +120,15 @@ enum {
MLX4_RSS_QPC_FLAG_OFFSET = 13, MLX4_RSS_QPC_FLAG_OFFSET = 13,
}; };
#define MLX4_EN_RSS_KEY_SIZE 40
struct mlx4_rss_context { struct mlx4_rss_context {
__be32 base_qpn; __be32 base_qpn;
__be32 default_qpn; __be32 default_qpn;
u16 reserved; u16 reserved;
u8 hash_fn; u8 hash_fn;
u8 flags; u8 flags;
__be32 rss_key[10]; __be32 rss_key[MLX4_EN_RSS_KEY_SIZE / sizeof(__be32)];
__be32 base_qpn_udp; __be32 base_qpn_udp;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment