Commit 6fe5ff2c authored by Maxim Mikityanskiy's avatar Maxim Mikityanskiy Committed by Saeed Mahameed

net/mlx5e: Create struct mlx5e_rss_params_hash

This commit introduces a new struct to store RSS hash parameters: hash
function and hash key. The existing usages are changed to use the new
struct.
Signed-off-by: default avatarMaxim Mikityanskiy <maximmi@nvidia.com>
Reviewed-by: default avatarTariq Toukan <tariqt@nvidia.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
parent 4b3e42ee
...@@ -10,11 +10,15 @@ ...@@ -10,11 +10,15 @@
#define MLX5E_MAX_NUM_CHANNELS (MLX5E_INDIR_RQT_SIZE / 2) #define MLX5E_MAX_NUM_CHANNELS (MLX5E_INDIR_RQT_SIZE / 2)
struct mlx5e_rss_params_hash {
u8 hfunc;
u8 toeplitz_hash_key[40];
};
struct mlx5e_rss_params { struct mlx5e_rss_params {
struct mlx5e_rss_params_hash hash;
struct mlx5e_rss_params_indir indir; struct mlx5e_rss_params_indir indir;
u32 rx_hash_fields[MLX5E_NUM_INDIR_TIRS]; u32 rx_hash_fields[MLX5E_NUM_INDIR_TIRS];
u8 toeplitz_hash_key[40];
u8 hfunc;
}; };
struct mlx5e_tir { struct mlx5e_tir {
......
...@@ -1172,7 +1172,7 @@ static int mlx5e_set_link_ksettings(struct net_device *netdev, ...@@ -1172,7 +1172,7 @@ static int mlx5e_set_link_ksettings(struct net_device *netdev,
u32 mlx5e_ethtool_get_rxfh_key_size(struct mlx5e_priv *priv) u32 mlx5e_ethtool_get_rxfh_key_size(struct mlx5e_priv *priv)
{ {
return sizeof(priv->rx_res->rss_params.toeplitz_hash_key); return sizeof(priv->rx_res->rss_params.hash.toeplitz_hash_key);
} }
static u32 mlx5e_get_rxfh_key_size(struct net_device *netdev) static u32 mlx5e_get_rxfh_key_size(struct net_device *netdev)
...@@ -1206,11 +1206,10 @@ int mlx5e_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key, ...@@ -1206,11 +1206,10 @@ int mlx5e_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key,
memcpy(indir, rss->indir.table, sizeof(rss->indir.table)); memcpy(indir, rss->indir.table, sizeof(rss->indir.table));
if (key) if (key)
memcpy(key, rss->toeplitz_hash_key, memcpy(key, rss->hash.toeplitz_hash_key, sizeof(rss->hash.toeplitz_hash_key));
sizeof(rss->toeplitz_hash_key));
if (hfunc) if (hfunc)
*hfunc = rss->hfunc; *hfunc = rss->hash.hfunc;
return 0; return 0;
} }
...@@ -1238,8 +1237,8 @@ int mlx5e_set_rxfh(struct net_device *dev, const u32 *indir, ...@@ -1238,8 +1237,8 @@ int mlx5e_set_rxfh(struct net_device *dev, const u32 *indir,
rss = &priv->rx_res->rss_params; rss = &priv->rx_res->rss_params;
if (hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != rss->hfunc) { if (hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != rss->hash.hfunc) {
rss->hfunc = hfunc; rss->hash.hfunc = hfunc;
refresh_rqt = true; refresh_rqt = true;
refresh_tirs = true; refresh_tirs = true;
} }
...@@ -1250,9 +1249,8 @@ int mlx5e_set_rxfh(struct net_device *dev, const u32 *indir, ...@@ -1250,9 +1249,8 @@ int mlx5e_set_rxfh(struct net_device *dev, const u32 *indir,
} }
if (key) { if (key) {
memcpy(rss->toeplitz_hash_key, key, memcpy(rss->hash.toeplitz_hash_key, key, sizeof(rss->hash.toeplitz_hash_key));
sizeof(rss->toeplitz_hash_key)); refresh_tirs = refresh_tirs || rss->hash.hfunc == ETH_RSS_HASH_TOP;
refresh_tirs = refresh_tirs || rss->hfunc == ETH_RSS_HASH_TOP;
} }
if (refresh_rqt && test_bit(MLX5E_STATE_OPENED, &priv->state)) { if (refresh_rqt && test_bit(MLX5E_STATE_OPENED, &priv->state)) {
...@@ -1267,7 +1265,7 @@ int mlx5e_set_rxfh(struct net_device *dev, const u32 *indir, ...@@ -1267,7 +1265,7 @@ int mlx5e_set_rxfh(struct net_device *dev, const u32 *indir,
mlx5e_rqt_redirect_indir(&priv->rx_res->indir_rqt, rqns, mlx5e_rqt_redirect_indir(&priv->rx_res->indir_rqt, rqns,
priv->channels.num, priv->channels.num,
rss->hfunc, &rss->indir); rss->hash.hfunc, &rss->indir);
kvfree(rqns); kvfree(rqns);
} }
} }
......
...@@ -2285,7 +2285,7 @@ static void mlx5e_redirect_rqts_to_channels(struct mlx5e_priv *priv, ...@@ -2285,7 +2285,7 @@ static void mlx5e_redirect_rqts_to_channels(struct mlx5e_priv *priv,
rqns[ix] = chs->c[ix]->rq.rqn; rqns[ix] = chs->c[ix]->rq.rqn;
mlx5e_rqt_redirect_indir(&res->indir_rqt, rqns, chs->num, mlx5e_rqt_redirect_indir(&res->indir_rqt, rqns, chs->num,
res->rss_params.hfunc, res->rss_params.hash.hfunc,
&res->rss_params.indir); &res->rss_params.indir);
kvfree(rqns); kvfree(rqns);
} }
...@@ -2393,15 +2393,15 @@ void mlx5e_build_indir_tir_ctx_hash(struct mlx5e_rss_params *rss_params, ...@@ -2393,15 +2393,15 @@ void mlx5e_build_indir_tir_ctx_hash(struct mlx5e_rss_params *rss_params,
void *hfso = inner ? MLX5_ADDR_OF(tirc, tirc, rx_hash_field_selector_inner) : void *hfso = inner ? MLX5_ADDR_OF(tirc, tirc, rx_hash_field_selector_inner) :
MLX5_ADDR_OF(tirc, tirc, rx_hash_field_selector_outer); MLX5_ADDR_OF(tirc, tirc, rx_hash_field_selector_outer);
MLX5_SET(tirc, tirc, rx_hash_fn, mlx5e_rx_hash_fn(rss_params->hfunc)); MLX5_SET(tirc, tirc, rx_hash_fn, mlx5e_rx_hash_fn(rss_params->hash.hfunc));
if (rss_params->hfunc == ETH_RSS_HASH_TOP) { if (rss_params->hash.hfunc == ETH_RSS_HASH_TOP) {
void *rss_key = MLX5_ADDR_OF(tirc, tirc, void *rss_key = MLX5_ADDR_OF(tirc, tirc,
rx_hash_toeplitz_key); rx_hash_toeplitz_key);
size_t len = MLX5_FLD_SZ_BYTES(tirc, size_t len = MLX5_FLD_SZ_BYTES(tirc,
rx_hash_toeplitz_key); rx_hash_toeplitz_key);
MLX5_SET(tirc, tirc, rx_hash_symmetric, 1); MLX5_SET(tirc, tirc, rx_hash_symmetric, 1);
memcpy(rss_key, rss_params->toeplitz_hash_key, len); memcpy(rss_key, rss_params->hash.toeplitz_hash_key, len);
} }
MLX5_SET(rx_hash_field_select, hfso, l3_prot_type, MLX5_SET(rx_hash_field_select, hfso, l3_prot_type,
ttconfig->l3_prot_type); ttconfig->l3_prot_type);
...@@ -4591,9 +4591,9 @@ void mlx5e_build_rss_params(struct mlx5e_rss_params *rss_params, ...@@ -4591,9 +4591,9 @@ void mlx5e_build_rss_params(struct mlx5e_rss_params *rss_params,
{ {
enum mlx5e_traffic_types tt; enum mlx5e_traffic_types tt;
rss_params->hfunc = ETH_RSS_HASH_TOP; rss_params->hash.hfunc = ETH_RSS_HASH_TOP;
netdev_rss_key_fill(rss_params->toeplitz_hash_key, netdev_rss_key_fill(rss_params->hash.toeplitz_hash_key,
sizeof(rss_params->toeplitz_hash_key)); sizeof(rss_params->hash.toeplitz_hash_key));
mlx5e_build_default_indir_rqt(rss_params->indir.table, mlx5e_build_default_indir_rqt(rss_params->indir.table,
MLX5E_INDIR_RQT_SIZE, num_channels); MLX5E_INDIR_RQT_SIZE, num_channels);
for (tt = 0; tt < MLX5E_NUM_INDIR_TIRS; tt++) for (tt = 0; tt < MLX5E_NUM_INDIR_TIRS; tt++)
......
...@@ -507,7 +507,7 @@ static int mlx5e_hairpin_create_indirect_rqt(struct mlx5e_hairpin *hp) ...@@ -507,7 +507,7 @@ static int mlx5e_hairpin_create_indirect_rqt(struct mlx5e_hairpin *hp)
mlx5e_build_default_indir_rqt(indir->table, MLX5E_INDIR_RQT_SIZE, hp->num_channels); mlx5e_build_default_indir_rqt(indir->table, MLX5E_INDIR_RQT_SIZE, hp->num_channels);
err = mlx5e_rqt_init_indir(&hp->indir_rqt, mdev, hp->pair->rqn, hp->num_channels, err = mlx5e_rqt_init_indir(&hp->indir_rqt, mdev, hp->pair->rqn, hp->num_channels,
priv->rx_res->rss_params.hfunc, indir); priv->rx_res->rss_params.hash.hfunc, indir);
kvfree(indir); kvfree(indir);
return err; return err;
......
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