mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-04 10:56:06 -04:00
net/mlx5e: Symmetric OR-XOR RSS hash control
Allow control over the symmetric RSS hash, which was previously set to enabled by default by the driver. Symmetric OR-XOR RSS can now be queried and controlled using the 'ethtool -x/X' command. Reviewed-by: Cosmin Ratiu <cratiu@nvidia.com> Reviewed-by: Tariq Toukan <tariqt@nvidia.com> Signed-off-by: Gal Pressman <gal@nvidia.com> Link: https://patch.msgid.link/20250224174416.499070-3-gal@nvidia.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
ecdff89338
commit
4d20c9f2db
@@ -161,6 +161,7 @@ static void mlx5e_rss_params_init(struct mlx5e_rss *rss)
|
||||
{
|
||||
enum mlx5_traffic_types tt;
|
||||
|
||||
rss->hash.symmetric = true;
|
||||
rss->hash.hfunc = ETH_RSS_HASH_TOP;
|
||||
netdev_rss_key_fill(rss->hash.toeplitz_hash_key,
|
||||
sizeof(rss->hash.toeplitz_hash_key));
|
||||
@@ -566,7 +567,7 @@ int mlx5e_rss_packet_merge_set_param(struct mlx5e_rss *rss,
|
||||
return final_err;
|
||||
}
|
||||
|
||||
int mlx5e_rss_get_rxfh(struct mlx5e_rss *rss, u32 *indir, u8 *key, u8 *hfunc)
|
||||
int mlx5e_rss_get_rxfh(struct mlx5e_rss *rss, u32 *indir, u8 *key, u8 *hfunc, bool *symmetric)
|
||||
{
|
||||
if (indir)
|
||||
memcpy(indir, rss->indir.table,
|
||||
@@ -579,11 +580,14 @@ int mlx5e_rss_get_rxfh(struct mlx5e_rss *rss, u32 *indir, u8 *key, u8 *hfunc)
|
||||
if (hfunc)
|
||||
*hfunc = rss->hash.hfunc;
|
||||
|
||||
if (symmetric)
|
||||
*symmetric = rss->hash.symmetric;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mlx5e_rss_set_rxfh(struct mlx5e_rss *rss, const u32 *indir,
|
||||
const u8 *key, const u8 *hfunc,
|
||||
const u8 *key, const u8 *hfunc, const bool *symmetric,
|
||||
u32 *rqns, u32 *vhca_ids, unsigned int num_rqns)
|
||||
{
|
||||
bool changed_indir = false;
|
||||
@@ -623,6 +627,11 @@ int mlx5e_rss_set_rxfh(struct mlx5e_rss *rss, const u32 *indir,
|
||||
rss->indir.actual_table_size * sizeof(*rss->indir.table));
|
||||
}
|
||||
|
||||
if (symmetric) {
|
||||
rss->hash.symmetric = *symmetric;
|
||||
changed_hash = true;
|
||||
}
|
||||
|
||||
if (changed_indir && rss->enabled) {
|
||||
err = mlx5e_rss_apply(rss, rqns, vhca_ids, num_rqns);
|
||||
if (err) {
|
||||
|
||||
@@ -47,9 +47,9 @@ void mlx5e_rss_disable(struct mlx5e_rss *rss);
|
||||
|
||||
int mlx5e_rss_packet_merge_set_param(struct mlx5e_rss *rss,
|
||||
struct mlx5e_packet_merge_param *pkt_merge_param);
|
||||
int mlx5e_rss_get_rxfh(struct mlx5e_rss *rss, u32 *indir, u8 *key, u8 *hfunc);
|
||||
int mlx5e_rss_get_rxfh(struct mlx5e_rss *rss, u32 *indir, u8 *key, u8 *hfunc, bool *symmetric);
|
||||
int mlx5e_rss_set_rxfh(struct mlx5e_rss *rss, const u32 *indir,
|
||||
const u8 *key, const u8 *hfunc,
|
||||
const u8 *key, const u8 *hfunc, const bool *symmetric,
|
||||
u32 *rqns, u32 *vhca_ids, unsigned int num_rqns);
|
||||
struct mlx5e_rss_params_hash mlx5e_rss_get_hash(struct mlx5e_rss *rss);
|
||||
u8 mlx5e_rss_get_hash_fields(struct mlx5e_rss *rss, enum mlx5_traffic_types tt);
|
||||
|
||||
@@ -194,7 +194,7 @@ void mlx5e_rx_res_rss_set_indir_uniform(struct mlx5e_rx_res *res, unsigned int n
|
||||
}
|
||||
|
||||
int mlx5e_rx_res_rss_get_rxfh(struct mlx5e_rx_res *res, u32 rss_idx,
|
||||
u32 *indir, u8 *key, u8 *hfunc)
|
||||
u32 *indir, u8 *key, u8 *hfunc, bool *symmetric)
|
||||
{
|
||||
struct mlx5e_rss *rss;
|
||||
|
||||
@@ -205,11 +205,12 @@ int mlx5e_rx_res_rss_get_rxfh(struct mlx5e_rx_res *res, u32 rss_idx,
|
||||
if (!rss)
|
||||
return -ENOENT;
|
||||
|
||||
return mlx5e_rss_get_rxfh(rss, indir, key, hfunc);
|
||||
return mlx5e_rss_get_rxfh(rss, indir, key, hfunc, symmetric);
|
||||
}
|
||||
|
||||
int mlx5e_rx_res_rss_set_rxfh(struct mlx5e_rx_res *res, u32 rss_idx,
|
||||
const u32 *indir, const u8 *key, const u8 *hfunc)
|
||||
const u32 *indir, const u8 *key, const u8 *hfunc,
|
||||
const bool *symmetric)
|
||||
{
|
||||
u32 *vhca_ids = get_vhca_ids(res, 0);
|
||||
struct mlx5e_rss *rss;
|
||||
@@ -221,8 +222,8 @@ int mlx5e_rx_res_rss_set_rxfh(struct mlx5e_rx_res *res, u32 rss_idx,
|
||||
if (!rss)
|
||||
return -ENOENT;
|
||||
|
||||
return mlx5e_rss_set_rxfh(rss, indir, key, hfunc, res->rss_rqns, vhca_ids,
|
||||
res->rss_nch);
|
||||
return mlx5e_rss_set_rxfh(rss, indir, key, hfunc, symmetric,
|
||||
res->rss_rqns, vhca_ids, res->rss_nch);
|
||||
}
|
||||
|
||||
int mlx5e_rx_res_rss_get_hash_fields(struct mlx5e_rx_res *res, u32 rss_idx,
|
||||
|
||||
@@ -49,9 +49,10 @@ void mlx5e_rx_res_xsk_update(struct mlx5e_rx_res *res, struct mlx5e_channels *ch
|
||||
/* Configuration API */
|
||||
void mlx5e_rx_res_rss_set_indir_uniform(struct mlx5e_rx_res *res, unsigned int nch);
|
||||
int mlx5e_rx_res_rss_get_rxfh(struct mlx5e_rx_res *res, u32 rss_idx,
|
||||
u32 *indir, u8 *key, u8 *hfunc);
|
||||
u32 *indir, u8 *key, u8 *hfunc, bool *symmetric);
|
||||
int mlx5e_rx_res_rss_set_rxfh(struct mlx5e_rx_res *res, u32 rss_idx,
|
||||
const u32 *indir, const u8 *key, const u8 *hfunc);
|
||||
const u32 *indir, const u8 *key, const u8 *hfunc,
|
||||
const bool *symmetric);
|
||||
|
||||
int mlx5e_rx_res_rss_get_hash_fields(struct mlx5e_rx_res *res, u32 rss_idx,
|
||||
enum mlx5_traffic_types tt);
|
||||
|
||||
@@ -124,7 +124,7 @@ void mlx5e_tir_builder_build_rss(struct mlx5e_tir_builder *builder,
|
||||
const size_t len = MLX5_FLD_SZ_BYTES(tirc, rx_hash_toeplitz_key);
|
||||
void *rss_key = MLX5_ADDR_OF(tirc, tirc, rx_hash_toeplitz_key);
|
||||
|
||||
MLX5_SET(tirc, tirc, rx_hash_symmetric, 1);
|
||||
MLX5_SET(tirc, tirc, rx_hash_symmetric, rss_hash->symmetric);
|
||||
memcpy(rss_key, rss_hash->toeplitz_hash_key, len);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
struct mlx5e_rss_params_hash {
|
||||
u8 hfunc;
|
||||
u8 toeplitz_hash_key[40];
|
||||
bool symmetric;
|
||||
};
|
||||
|
||||
struct mlx5e_rss_params_traffic_type {
|
||||
|
||||
@@ -1456,18 +1456,27 @@ static int mlx5e_get_rxfh(struct net_device *netdev, struct ethtool_rxfh_param *
|
||||
{
|
||||
struct mlx5e_priv *priv = netdev_priv(netdev);
|
||||
u32 rss_context = rxfh->rss_context;
|
||||
bool symmetric;
|
||||
int err;
|
||||
|
||||
mutex_lock(&priv->state_lock);
|
||||
err = mlx5e_rx_res_rss_get_rxfh(priv->rx_res, rss_context,
|
||||
rxfh->indir, rxfh->key, &rxfh->hfunc);
|
||||
rxfh->indir, rxfh->key, &rxfh->hfunc, &symmetric);
|
||||
mutex_unlock(&priv->state_lock);
|
||||
return err;
|
||||
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if (symmetric)
|
||||
rxfh->input_xfrm = RXH_XFRM_SYM_OR_XOR;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mlx5e_set_rxfh(struct net_device *dev, struct ethtool_rxfh_param *rxfh,
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
bool symmetric = rxfh->input_xfrm == RXH_XFRM_SYM_OR_XOR;
|
||||
struct mlx5e_priv *priv = netdev_priv(dev);
|
||||
u32 *rss_context = &rxfh->rss_context;
|
||||
u8 hfunc = rxfh->hfunc;
|
||||
@@ -1502,7 +1511,8 @@ static int mlx5e_set_rxfh(struct net_device *dev, struct ethtool_rxfh_param *rxf
|
||||
|
||||
err = mlx5e_rx_res_rss_set_rxfh(priv->rx_res, *rss_context,
|
||||
rxfh->indir, rxfh->key,
|
||||
hfunc == ETH_RSS_HASH_NO_CHANGE ? NULL : &hfunc);
|
||||
hfunc == ETH_RSS_HASH_NO_CHANGE ? NULL : &hfunc,
|
||||
rxfh->input_xfrm == RXH_XFRM_NO_CHANGE ? NULL : &symmetric);
|
||||
|
||||
unlock:
|
||||
mutex_unlock(&priv->state_lock);
|
||||
@@ -2611,6 +2621,7 @@ const struct ethtool_ops mlx5e_ethtool_ops = {
|
||||
ETHTOOL_COALESCE_MAX_FRAMES |
|
||||
ETHTOOL_COALESCE_USE_ADAPTIVE |
|
||||
ETHTOOL_COALESCE_USE_CQE,
|
||||
.supported_input_xfrm = RXH_XFRM_SYM_OR_XOR,
|
||||
.get_drvinfo = mlx5e_get_drvinfo,
|
||||
.get_link = ethtool_op_get_link,
|
||||
.get_link_ext_state = mlx5e_get_link_ext_state,
|
||||
|
||||
Reference in New Issue
Block a user