Implement SIOCGIFRSS{KEY,HASH} for the mlx4en(4) driver.
Differential Revision: https://reviews.freebsd.org/D12176 MFC after: 1 week Sponsored by: Mellanox Technologies
This commit is contained in:
parent
2b4490a5d3
commit
29d6b8abb4
@ -795,6 +795,8 @@ int mlx4_en_map_buffer(struct mlx4_buf *buf);
|
||||
void mlx4_en_unmap_buffer(struct mlx4_buf *buf);
|
||||
void mlx4_en_calc_rx_buf(struct net_device *dev);
|
||||
|
||||
const u32 *mlx4_en_get_rss_key(struct mlx4_en_priv *priv, u16 *keylen);
|
||||
u8 mlx4_en_get_rss_mask(struct mlx4_en_priv *priv);
|
||||
int mlx4_en_config_rss_steer(struct mlx4_en_priv *priv);
|
||||
void mlx4_en_release_rss_steer(struct mlx4_en_priv *priv);
|
||||
int mlx4_en_create_drop_qp(struct mlx4_en_priv *priv);
|
||||
|
@ -1896,6 +1896,10 @@ static int mlx4_en_ioctl(struct ifnet *dev, u_long command, caddr_t data)
|
||||
struct ifreq *ifr;
|
||||
int error;
|
||||
int mask;
|
||||
struct ifrsskey *ifrk;
|
||||
const u32 *key;
|
||||
struct ifrsshash *ifrh;
|
||||
u8 rss_mask;
|
||||
|
||||
error = 0;
|
||||
mask = 0;
|
||||
@ -2024,6 +2028,39 @@ static int mlx4_en_ioctl(struct ifnet *dev, u_long command, caddr_t data)
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
case SIOCGIFRSSKEY:
|
||||
ifrk = (struct ifrsskey *)data;
|
||||
ifrk->ifrk_func = RSS_FUNC_TOEPLITZ;
|
||||
mutex_lock(&mdev->state_lock);
|
||||
key = mlx4_en_get_rss_key(priv, &ifrk->ifrk_keylen);
|
||||
if (ifrk->ifrk_keylen > RSS_KEYLEN)
|
||||
error = EINVAL;
|
||||
else
|
||||
memcpy(ifrk->ifrk_key, key, ifrk->ifrk_keylen);
|
||||
mutex_unlock(&mdev->state_lock);
|
||||
break;
|
||||
|
||||
case SIOCGIFRSSHASH:
|
||||
mutex_lock(&mdev->state_lock);
|
||||
rss_mask = mlx4_en_get_rss_mask(priv);
|
||||
mutex_unlock(&mdev->state_lock);
|
||||
ifrh = (struct ifrsshash *)data;
|
||||
ifrh->ifrh_func = RSS_FUNC_TOEPLITZ;
|
||||
ifrh->ifrh_types = 0;
|
||||
if (rss_mask & MLX4_RSS_IPV4)
|
||||
ifrh->ifrh_types |= RSS_TYPE_IPV4;
|
||||
if (rss_mask & MLX4_RSS_TCP_IPV4)
|
||||
ifrh->ifrh_types |= RSS_TYPE_TCP_IPV4;
|
||||
if (rss_mask & MLX4_RSS_IPV6)
|
||||
ifrh->ifrh_types |= RSS_TYPE_IPV6;
|
||||
if (rss_mask & MLX4_RSS_TCP_IPV6)
|
||||
ifrh->ifrh_types |= RSS_TYPE_TCP_IPV6;
|
||||
if (rss_mask & MLX4_RSS_UDP_IPV4)
|
||||
ifrh->ifrh_types |= RSS_TYPE_UDP_IPV4;
|
||||
if (rss_mask & MLX4_RSS_UDP_IPV6)
|
||||
ifrh->ifrh_types |= RSS_TYPE_UDP_IPV6;
|
||||
break;
|
||||
|
||||
default:
|
||||
error = ether_ioctl(dev, command, data);
|
||||
break;
|
||||
|
@ -814,6 +814,38 @@ void mlx4_en_destroy_drop_qp(struct mlx4_en_priv *priv)
|
||||
mlx4_qp_release_range(priv->mdev->dev, qpn, 1);
|
||||
}
|
||||
|
||||
const u32 *
|
||||
mlx4_en_get_rss_key(struct mlx4_en_priv *priv __unused,
|
||||
u16 *keylen)
|
||||
{
|
||||
static const u32 rsskey[10] = {
|
||||
cpu_to_be32(0xD181C62C),
|
||||
cpu_to_be32(0xF7F4DB5B),
|
||||
cpu_to_be32(0x1983A2FC),
|
||||
cpu_to_be32(0x943E1ADB),
|
||||
cpu_to_be32(0xD9389E6B),
|
||||
cpu_to_be32(0xD1039C2C),
|
||||
cpu_to_be32(0xA74499AD),
|
||||
cpu_to_be32(0x593D56D9),
|
||||
cpu_to_be32(0xF3253C06),
|
||||
cpu_to_be32(0x2ADC1FFC)
|
||||
};
|
||||
|
||||
if (keylen != NULL)
|
||||
*keylen = sizeof(rsskey);
|
||||
return (rsskey);
|
||||
}
|
||||
|
||||
u8 mlx4_en_get_rss_mask(struct mlx4_en_priv *priv)
|
||||
{
|
||||
u8 rss_mask = (MLX4_RSS_IPV4 | MLX4_RSS_TCP_IPV4 | MLX4_RSS_IPV6 |
|
||||
MLX4_RSS_TCP_IPV6);
|
||||
|
||||
if (priv->mdev->profile.udp_rss)
|
||||
rss_mask |= MLX4_RSS_UDP_IPV4 | MLX4_RSS_UDP_IPV6;
|
||||
return (rss_mask);
|
||||
}
|
||||
|
||||
/* Allocate rx qp's and configure them according to rss map */
|
||||
int mlx4_en_config_rss_steer(struct mlx4_en_priv *priv)
|
||||
{
|
||||
@ -821,16 +853,12 @@ int mlx4_en_config_rss_steer(struct mlx4_en_priv *priv)
|
||||
struct mlx4_en_rss_map *rss_map = &priv->rss_map;
|
||||
struct mlx4_qp_context context;
|
||||
struct mlx4_rss_context *rss_context;
|
||||
const u32 *key;
|
||||
int rss_rings;
|
||||
void *ptr;
|
||||
u8 rss_mask = (MLX4_RSS_IPV4 | MLX4_RSS_TCP_IPV4 | MLX4_RSS_IPV6 |
|
||||
MLX4_RSS_TCP_IPV6);
|
||||
int i;
|
||||
int err = 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");
|
||||
err = mlx4_qp_reserve_range(mdev->dev, priv->rx_ring_num,
|
||||
@ -874,14 +902,13 @@ int mlx4_en_config_rss_steer(struct mlx4_en_priv *priv)
|
||||
rss_context->base_qpn = cpu_to_be32(ilog2(rss_rings) << 24 |
|
||||
(rss_map->base_qpn));
|
||||
rss_context->default_qpn = cpu_to_be32(rss_map->base_qpn);
|
||||
if (priv->mdev->profile.udp_rss) {
|
||||
rss_mask |= MLX4_RSS_UDP_IPV4 | MLX4_RSS_UDP_IPV6;
|
||||
if (priv->mdev->profile.udp_rss)
|
||||
rss_context->base_qpn_udp = rss_context->default_qpn;
|
||||
}
|
||||
rss_context->flags = rss_mask;
|
||||
rss_context->flags = mlx4_en_get_rss_mask(priv);
|
||||
rss_context->hash_fn = MLX4_RSS_HASH_TOP;
|
||||
key = mlx4_en_get_rss_key(priv, NULL);
|
||||
for (i = 0; i < 10; i++)
|
||||
rss_context->rss_key[i] = cpu_to_be32(rsskey[i]);
|
||||
rss_context->rss_key[i] = key[i];
|
||||
|
||||
err = mlx4_qp_to_ready(mdev->dev, &priv->res.mtt, &context,
|
||||
&rss_map->indir_qp, &rss_map->indir_state);
|
||||
|
Loading…
Reference in New Issue
Block a user