Commit 713ba5e5 authored by Tariq Toukan's avatar Tariq Toukan Committed by Saeed Mahameed

net/mlx5e: Introduce abstraction of RSS context

Bring all fields that define and maintain RSS behavior together
into a new structure.
Align all usages with this new structure. Keep it hidden within
rx_res.c.
This helps supporting multiple RSS contexts in downstream patch.

Use dynamic allocations for the RSS context.
Signed-off-by: default avatarTariq Toukan <tariqt@nvidia.com>
Reviewed-by: default avatarMaxim Mikityanskiy <maximmi@nvidia.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
parent fc651ff9
...@@ -64,24 +64,22 @@ mlx5e_rss_get_default_tt_config(enum mlx5_traffic_types tt) ...@@ -64,24 +64,22 @@ mlx5e_rss_get_default_tt_config(enum mlx5_traffic_types tt)
return rss_default_config[tt]; return rss_default_config[tt];
} }
struct mlx5e_rss {
struct mlx5e_rss_params_hash hash;
struct mlx5e_rss_params_indir indir;
u32 rx_hash_fields[MLX5E_NUM_INDIR_TIRS];
struct mlx5e_tir tir[MLX5E_NUM_INDIR_TIRS];
struct mlx5e_tir inner_tir[MLX5E_NUM_INDIR_TIRS];
struct mlx5e_rqt rqt;
};
struct mlx5e_rx_res { struct mlx5e_rx_res {
struct mlx5_core_dev *mdev; struct mlx5_core_dev *mdev;
enum mlx5e_rx_res_features features; enum mlx5e_rx_res_features features;
unsigned int max_nch; unsigned int max_nch;
u32 drop_rqn; u32 drop_rqn;
struct { struct mlx5e_rss *rss;
struct mlx5e_rss_params_hash hash;
struct mlx5e_rss_params_indir indir;
u32 rx_hash_fields[MLX5E_NUM_INDIR_TIRS];
} rss_params;
struct mlx5e_rqt indir_rqt;
struct {
struct mlx5e_tir indir_tir;
struct mlx5e_tir inner_indir_tir;
} rss[MLX5E_NUM_INDIR_TIRS];
bool rss_active; bool rss_active;
u32 rss_rqns[MLX5E_INDIR_RQT_SIZE]; u32 rss_rqns[MLX5E_INDIR_RQT_SIZE];
unsigned int rss_nch; unsigned int rss_nch;
...@@ -106,14 +104,15 @@ struct mlx5e_rx_res *mlx5e_rx_res_alloc(void) ...@@ -106,14 +104,15 @@ struct mlx5e_rx_res *mlx5e_rx_res_alloc(void)
static void mlx5e_rx_res_rss_params_init(struct mlx5e_rx_res *res, unsigned int init_nch) static void mlx5e_rx_res_rss_params_init(struct mlx5e_rx_res *res, unsigned int init_nch)
{ {
struct mlx5e_rss *rss = res->rss;
enum mlx5_traffic_types tt; enum mlx5_traffic_types tt;
res->rss_params.hash.hfunc = ETH_RSS_HASH_TOP; rss->hash.hfunc = ETH_RSS_HASH_TOP;
netdev_rss_key_fill(res->rss_params.hash.toeplitz_hash_key, netdev_rss_key_fill(rss->hash.toeplitz_hash_key,
sizeof(res->rss_params.hash.toeplitz_hash_key)); sizeof(rss->hash.toeplitz_hash_key));
mlx5e_rss_params_indir_init_uniform(&res->rss_params.indir, init_nch); mlx5e_rss_params_indir_init_uniform(&rss->indir, init_nch);
for (tt = 0; tt < MLX5E_NUM_INDIR_TIRS; tt++) for (tt = 0; tt < MLX5E_NUM_INDIR_TIRS; tt++)
res->rss_params.rx_hash_fields[tt] = rss->rx_hash_fields[tt] =
mlx5e_rss_get_default_tt_config(tt).rx_hash_fields; mlx5e_rss_get_default_tt_config(tt).rx_hash_fields;
} }
...@@ -121,9 +120,10 @@ static void mlx5e_rx_res_rss_destroy_tir(struct mlx5e_rx_res *res, ...@@ -121,9 +120,10 @@ static void mlx5e_rx_res_rss_destroy_tir(struct mlx5e_rx_res *res,
enum mlx5_traffic_types tt, enum mlx5_traffic_types tt,
bool inner) bool inner)
{ {
struct mlx5e_rss *rss = res->rss;
struct mlx5e_tir *tir; struct mlx5e_tir *tir;
tir = inner ? &res->rss[tt].inner_indir_tir : &res->rss[tt].indir_tir; tir = inner ? &rss->inner_tir[tt] : &rss->tir[tt];
mlx5e_tir_destroy(tir); mlx5e_tir_destroy(tir);
} }
...@@ -135,18 +135,19 @@ static int mlx5e_rx_res_rss_create_tir(struct mlx5e_rx_res *res, ...@@ -135,18 +135,19 @@ static int mlx5e_rx_res_rss_create_tir(struct mlx5e_rx_res *res,
{ {
bool inner_ft_support = res->features & MLX5E_RX_RES_FEATURE_INNER_FT; bool inner_ft_support = res->features & MLX5E_RX_RES_FEATURE_INNER_FT;
struct mlx5e_rss_params_traffic_type rss_tt; struct mlx5e_rss_params_traffic_type rss_tt;
struct mlx5e_rss *rss = res->rss;
struct mlx5e_tir *tir; struct mlx5e_tir *tir;
u32 rqtn; u32 rqtn;
int err; int err;
tir = inner ? &res->rss[tt].inner_indir_tir : &res->rss[tt].indir_tir; tir = inner ? &rss->inner_tir[tt] : &rss->tir[tt];
rqtn = mlx5e_rqt_get_rqtn(&res->indir_rqt); rqtn = mlx5e_rqt_get_rqtn(&rss->rqt);
mlx5e_tir_builder_build_rqt(builder, res->mdev->mlx5e_res.hw_objs.td.tdn, mlx5e_tir_builder_build_rqt(builder, res->mdev->mlx5e_res.hw_objs.td.tdn,
rqtn, inner_ft_support); rqtn, inner_ft_support);
mlx5e_tir_builder_build_lro(builder, init_lro_param); mlx5e_tir_builder_build_lro(builder, init_lro_param);
rss_tt = mlx5e_rx_res_rss_get_current_tt_config(res, tt); rss_tt = mlx5e_rx_res_rss_get_current_tt_config(res, tt);
mlx5e_tir_builder_build_rss(builder, &res->rss_params.hash, &rss_tt, inner); mlx5e_tir_builder_build_rss(builder, &rss->hash, &rss_tt, inner);
err = mlx5e_tir_init(tir, builder, res->mdev, true); err = mlx5e_tir_init(tir, builder, res->mdev, true);
if (err) { if (err) {
...@@ -198,14 +199,24 @@ static void mlx5e_rx_res_rss_destroy_tirs(struct mlx5e_rx_res *res, bool inner) ...@@ -198,14 +199,24 @@ static void mlx5e_rx_res_rss_destroy_tirs(struct mlx5e_rx_res *res, bool inner)
} }
static int mlx5e_rx_res_rss_init(struct mlx5e_rx_res *res, static int mlx5e_rx_res_rss_init(struct mlx5e_rx_res *res,
const struct mlx5e_lro_param *init_lro_param) const struct mlx5e_lro_param *init_lro_param,
unsigned int init_nch)
{ {
bool inner_ft_support = res->features & MLX5E_RX_RES_FEATURE_INNER_FT; bool inner_ft_support = res->features & MLX5E_RX_RES_FEATURE_INNER_FT;
struct mlx5e_rss *rss;
int err; int err;
err = mlx5e_rqt_init_direct(&res->indir_rqt, res->mdev, true, res->drop_rqn); rss = kvzalloc(sizeof(*rss), GFP_KERNEL);
if (!rss)
return -ENOMEM;
res->rss = rss;
mlx5e_rx_res_rss_params_init(res, init_nch);
err = mlx5e_rqt_init_direct(&rss->rqt, res->mdev, true, res->drop_rqn);
if (err) if (err)
return err; goto err_free_rss;
err = mlx5e_rx_res_rss_create_tirs(res, init_lro_param, false); err = mlx5e_rx_res_rss_create_tirs(res, init_lro_param, false);
if (err) if (err)
...@@ -223,8 +234,11 @@ static int mlx5e_rx_res_rss_init(struct mlx5e_rx_res *res, ...@@ -223,8 +234,11 @@ static int mlx5e_rx_res_rss_init(struct mlx5e_rx_res *res,
mlx5e_rx_res_rss_destroy_tirs(res, false); mlx5e_rx_res_rss_destroy_tirs(res, false);
err_destroy_rqt: err_destroy_rqt:
mlx5e_rqt_destroy(&res->indir_rqt); mlx5e_rqt_destroy(&rss->rqt);
err_free_rss:
kvfree(rss);
res->rss = NULL;
return err; return err;
} }
...@@ -367,12 +381,16 @@ static int mlx5e_rx_res_ptp_init(struct mlx5e_rx_res *res) ...@@ -367,12 +381,16 @@ static int mlx5e_rx_res_ptp_init(struct mlx5e_rx_res *res)
static void mlx5e_rx_res_rss_destroy(struct mlx5e_rx_res *res) static void mlx5e_rx_res_rss_destroy(struct mlx5e_rx_res *res)
{ {
struct mlx5e_rss *rss = res->rss;
mlx5e_rx_res_rss_destroy_tirs(res, false); mlx5e_rx_res_rss_destroy_tirs(res, false);
if (res->features & MLX5E_RX_RES_FEATURE_INNER_FT) if (res->features & MLX5E_RX_RES_FEATURE_INNER_FT)
mlx5e_rx_res_rss_destroy_tirs(res, true); mlx5e_rx_res_rss_destroy_tirs(res, true);
mlx5e_rqt_destroy(&res->indir_rqt); mlx5e_rqt_destroy(&rss->rqt);
kvfree(rss);
res->rss = NULL;
} }
static void mlx5e_rx_res_channels_destroy(struct mlx5e_rx_res *res) static void mlx5e_rx_res_channels_destroy(struct mlx5e_rx_res *res)
...@@ -411,9 +429,7 @@ int mlx5e_rx_res_init(struct mlx5e_rx_res *res, struct mlx5_core_dev *mdev, ...@@ -411,9 +429,7 @@ int mlx5e_rx_res_init(struct mlx5e_rx_res *res, struct mlx5_core_dev *mdev,
res->max_nch = max_nch; res->max_nch = max_nch;
res->drop_rqn = drop_rqn; res->drop_rqn = drop_rqn;
mlx5e_rx_res_rss_params_init(res, init_nch); err = mlx5e_rx_res_rss_init(res, init_lro_param, init_nch);
err = mlx5e_rx_res_rss_init(res, init_lro_param);
if (err) if (err)
return err; return err;
...@@ -460,13 +476,17 @@ u32 mlx5e_rx_res_get_tirn_xsk(struct mlx5e_rx_res *res, unsigned int ix) ...@@ -460,13 +476,17 @@ u32 mlx5e_rx_res_get_tirn_xsk(struct mlx5e_rx_res *res, unsigned int ix)
u32 mlx5e_rx_res_get_tirn_rss(struct mlx5e_rx_res *res, enum mlx5_traffic_types tt) u32 mlx5e_rx_res_get_tirn_rss(struct mlx5e_rx_res *res, enum mlx5_traffic_types tt)
{ {
return mlx5e_tir_get_tirn(&res->rss[tt].indir_tir); struct mlx5e_rss *rss = res->rss;
return mlx5e_tir_get_tirn(&rss->tir[tt]);
} }
u32 mlx5e_rx_res_get_tirn_rss_inner(struct mlx5e_rx_res *res, enum mlx5_traffic_types tt) u32 mlx5e_rx_res_get_tirn_rss_inner(struct mlx5e_rx_res *res, enum mlx5_traffic_types tt)
{ {
struct mlx5e_rss *rss = res->rss;
WARN_ON(!(res->features & MLX5E_RX_RES_FEATURE_INNER_FT)); WARN_ON(!(res->features & MLX5E_RX_RES_FEATURE_INNER_FT));
return mlx5e_tir_get_tirn(&res->rss[tt].inner_indir_tir); return mlx5e_tir_get_tirn(&rss->inner_tir[tt]);
} }
u32 mlx5e_rx_res_get_tirn_ptp(struct mlx5e_rx_res *res) u32 mlx5e_rx_res_get_tirn_ptp(struct mlx5e_rx_res *res)
...@@ -482,28 +502,30 @@ u32 mlx5e_rx_res_get_rqtn_direct(struct mlx5e_rx_res *res, unsigned int ix) ...@@ -482,28 +502,30 @@ u32 mlx5e_rx_res_get_rqtn_direct(struct mlx5e_rx_res *res, unsigned int ix)
static void mlx5e_rx_res_rss_enable(struct mlx5e_rx_res *res) static void mlx5e_rx_res_rss_enable(struct mlx5e_rx_res *res)
{ {
struct mlx5e_rss *rss = res->rss;
int err; int err;
res->rss_active = true; res->rss_active = true;
err = mlx5e_rqt_redirect_indir(&res->indir_rqt, res->rss_rqns, res->rss_nch, err = mlx5e_rqt_redirect_indir(&rss->rqt, res->rss_rqns, res->rss_nch,
res->rss_params.hash.hfunc, rss->hash.hfunc,
&res->rss_params.indir); &rss->indir);
if (err) if (err)
mlx5_core_warn(res->mdev, "Failed to redirect indirect RQT %#x to channels: err = %d\n", mlx5_core_warn(res->mdev, "Failed to redirect RQT %#x to channels: err = %d\n",
mlx5e_rqt_get_rqtn(&res->indir_rqt), err); mlx5e_rqt_get_rqtn(&rss->rqt), err);
} }
static void mlx5e_rx_res_rss_disable(struct mlx5e_rx_res *res) static void mlx5e_rx_res_rss_disable(struct mlx5e_rx_res *res)
{ {
struct mlx5e_rss *rss = res->rss;
int err; int err;
res->rss_active = false; res->rss_active = false;
err = mlx5e_rqt_redirect_direct(&res->indir_rqt, res->drop_rqn); err = mlx5e_rqt_redirect_direct(&rss->rqt, res->drop_rqn);
if (err) if (err)
mlx5_core_warn(res->mdev, "Failed to redirect indirect RQT %#x to drop RQ %#x: err = %d\n", mlx5_core_warn(res->mdev, "Failed to redirect RQT %#x to drop RQ %#x: err = %d\n",
mlx5e_rqt_get_rqtn(&res->indir_rqt), res->drop_rqn, err); mlx5e_rqt_get_rqtn(&rss->rqt), res->drop_rqn, err);
} }
void mlx5e_rx_res_channels_activate(struct mlx5e_rx_res *res, struct mlx5e_channels *chs) void mlx5e_rx_res_channels_activate(struct mlx5e_rx_res *res, struct mlx5e_channels *chs)
...@@ -637,9 +659,10 @@ struct mlx5e_rss_params_traffic_type ...@@ -637,9 +659,10 @@ struct mlx5e_rss_params_traffic_type
mlx5e_rx_res_rss_get_current_tt_config(struct mlx5e_rx_res *res, enum mlx5_traffic_types tt) mlx5e_rx_res_rss_get_current_tt_config(struct mlx5e_rx_res *res, enum mlx5_traffic_types tt)
{ {
struct mlx5e_rss_params_traffic_type rss_tt; struct mlx5e_rss_params_traffic_type rss_tt;
struct mlx5e_rss *rss = res->rss;
rss_tt = mlx5e_rss_get_default_tt_config(tt); rss_tt = mlx5e_rss_get_default_tt_config(tt);
rss_tt.rx_hash_fields = res->rss_params.rx_hash_fields[tt]; rss_tt.rx_hash_fields = rss->rx_hash_fields[tt];
return rss_tt; return rss_tt;
} }
...@@ -647,23 +670,26 @@ mlx5e_rx_res_rss_get_current_tt_config(struct mlx5e_rx_res *res, enum mlx5_traff ...@@ -647,23 +670,26 @@ mlx5e_rx_res_rss_get_current_tt_config(struct mlx5e_rx_res *res, enum mlx5_traff
void mlx5e_rx_res_rss_set_indir_uniform(struct mlx5e_rx_res *res, unsigned int nch) void mlx5e_rx_res_rss_set_indir_uniform(struct mlx5e_rx_res *res, unsigned int nch)
{ {
WARN_ON_ONCE(res->rss_active); WARN_ON_ONCE(res->rss_active);
mlx5e_rss_params_indir_init_uniform(&res->rss_params.indir, nch); mlx5e_rss_params_indir_init_uniform(&res->rss->indir, nch);
} }
void mlx5e_rx_res_rss_get_rxfh(struct mlx5e_rx_res *res, u32 *indir, u8 *key, u8 *hfunc) int mlx5e_rx_res_rss_get_rxfh(struct mlx5e_rx_res *res, u32 *indir, u8 *key, u8 *hfunc)
{ {
struct mlx5e_rss *rss = res->rss;
unsigned int i; unsigned int i;
if (indir) if (indir)
for (i = 0; i < MLX5E_INDIR_RQT_SIZE; i++) for (i = 0; i < MLX5E_INDIR_RQT_SIZE; i++)
indir[i] = res->rss_params.indir.table[i]; indir[i] = rss->indir.table[i];
if (key) if (key)
memcpy(key, res->rss_params.hash.toeplitz_hash_key, memcpy(key, rss->hash.toeplitz_hash_key,
sizeof(res->rss_params.hash.toeplitz_hash_key)); sizeof(rss->hash.toeplitz_hash_key));
if (hfunc) if (hfunc)
*hfunc = res->rss_params.hash.hfunc; *hfunc = rss->hash.hfunc;
return 0;
} }
static int mlx5e_rx_res_rss_update_tir(struct mlx5e_rx_res *res, enum mlx5_traffic_types tt, static int mlx5e_rx_res_rss_update_tir(struct mlx5e_rx_res *res, enum mlx5_traffic_types tt,
...@@ -671,6 +697,7 @@ static int mlx5e_rx_res_rss_update_tir(struct mlx5e_rx_res *res, enum mlx5_traff ...@@ -671,6 +697,7 @@ static int mlx5e_rx_res_rss_update_tir(struct mlx5e_rx_res *res, enum mlx5_traff
{ {
struct mlx5e_rss_params_traffic_type rss_tt; struct mlx5e_rss_params_traffic_type rss_tt;
struct mlx5e_tir_builder *builder; struct mlx5e_tir_builder *builder;
struct mlx5e_rss *rss = res->rss;
struct mlx5e_tir *tir; struct mlx5e_tir *tir;
int err; int err;
...@@ -680,8 +707,8 @@ static int mlx5e_rx_res_rss_update_tir(struct mlx5e_rx_res *res, enum mlx5_traff ...@@ -680,8 +707,8 @@ static int mlx5e_rx_res_rss_update_tir(struct mlx5e_rx_res *res, enum mlx5_traff
rss_tt = mlx5e_rx_res_rss_get_current_tt_config(res, tt); rss_tt = mlx5e_rx_res_rss_get_current_tt_config(res, tt);
mlx5e_tir_builder_build_rss(builder, &res->rss_params.hash, &rss_tt, inner); mlx5e_tir_builder_build_rss(builder, &rss->hash, &rss_tt, inner);
tir = inner ? &res->rss[tt].inner_indir_tir : &res->rss[tt].indir_tir; tir = inner ? &rss->inner_tir[tt] : &rss->tir[tt];
err = mlx5e_tir_modify(tir, builder); err = mlx5e_tir_modify(tir, builder);
mlx5e_tir_builder_free(builder); mlx5e_tir_builder_free(builder);
...@@ -691,12 +718,13 @@ static int mlx5e_rx_res_rss_update_tir(struct mlx5e_rx_res *res, enum mlx5_traff ...@@ -691,12 +718,13 @@ static int mlx5e_rx_res_rss_update_tir(struct mlx5e_rx_res *res, enum mlx5_traff
int mlx5e_rx_res_rss_set_rxfh(struct mlx5e_rx_res *res, const u32 *indir, int mlx5e_rx_res_rss_set_rxfh(struct mlx5e_rx_res *res, const u32 *indir,
const u8 *key, const u8 *hfunc) const u8 *key, const u8 *hfunc)
{ {
struct mlx5e_rss *rss = res->rss;
enum mlx5_traffic_types tt; enum mlx5_traffic_types tt;
bool changed_indir = false; bool changed_indir = false;
bool changed_hash = false; bool changed_hash = false;
int err; int err;
if (hfunc && *hfunc != res->rss_params.hash.hfunc) { if (hfunc && *hfunc != rss->hash.hfunc) {
switch (*hfunc) { switch (*hfunc) {
case ETH_RSS_HASH_XOR: case ETH_RSS_HASH_XOR:
case ETH_RSS_HASH_TOP: case ETH_RSS_HASH_TOP:
...@@ -706,14 +734,14 @@ int mlx5e_rx_res_rss_set_rxfh(struct mlx5e_rx_res *res, const u32 *indir, ...@@ -706,14 +734,14 @@ int mlx5e_rx_res_rss_set_rxfh(struct mlx5e_rx_res *res, const u32 *indir,
} }
changed_hash = true; changed_hash = true;
changed_indir = true; changed_indir = true;
res->rss_params.hash.hfunc = *hfunc; rss->hash.hfunc = *hfunc;
} }
if (key) { if (key) {
if (res->rss_params.hash.hfunc == ETH_RSS_HASH_TOP) if (rss->hash.hfunc == ETH_RSS_HASH_TOP)
changed_hash = true; changed_hash = true;
memcpy(res->rss_params.hash.toeplitz_hash_key, key, memcpy(rss->hash.toeplitz_hash_key, key,
sizeof(res->rss_params.hash.toeplitz_hash_key)); sizeof(rss->hash.toeplitz_hash_key));
} }
if (indir) { if (indir) {
...@@ -722,16 +750,15 @@ int mlx5e_rx_res_rss_set_rxfh(struct mlx5e_rx_res *res, const u32 *indir, ...@@ -722,16 +750,15 @@ int mlx5e_rx_res_rss_set_rxfh(struct mlx5e_rx_res *res, const u32 *indir,
changed_indir = true; changed_indir = true;
for (i = 0; i < MLX5E_INDIR_RQT_SIZE; i++) for (i = 0; i < MLX5E_INDIR_RQT_SIZE; i++)
res->rss_params.indir.table[i] = indir[i]; rss->indir.table[i] = indir[i];
} }
if (changed_indir && res->rss_active) { if (changed_indir && res->rss_active) {
err = mlx5e_rqt_redirect_indir(&res->indir_rqt, res->rss_rqns, res->rss_nch, err = mlx5e_rqt_redirect_indir(&rss->rqt, res->rss_rqns, res->rss_nch,
res->rss_params.hash.hfunc, rss->hash.hfunc, &rss->indir);
&res->rss_params.indir);
if (err) if (err)
mlx5_core_warn(res->mdev, "Failed to redirect indirect RQT %#x to channels: err = %d\n", mlx5_core_warn(res->mdev, "Failed to redirect indirect RQT %#x to channels: err = %d\n",
mlx5e_rqt_get_rqtn(&res->indir_rqt), err); mlx5e_rqt_get_rqtn(&rss->rqt), err);
} }
if (changed_hash) if (changed_hash)
...@@ -755,25 +782,28 @@ int mlx5e_rx_res_rss_set_rxfh(struct mlx5e_rx_res *res, const u32 *indir, ...@@ -755,25 +782,28 @@ int mlx5e_rx_res_rss_set_rxfh(struct mlx5e_rx_res *res, const u32 *indir,
u8 mlx5e_rx_res_rss_get_hash_fields(struct mlx5e_rx_res *res, enum mlx5_traffic_types tt) u8 mlx5e_rx_res_rss_get_hash_fields(struct mlx5e_rx_res *res, enum mlx5_traffic_types tt)
{ {
return res->rss_params.rx_hash_fields[tt]; struct mlx5e_rss *rss = res->rss;
return rss->rx_hash_fields[tt];
} }
int mlx5e_rx_res_rss_set_hash_fields(struct mlx5e_rx_res *res, enum mlx5_traffic_types tt, int mlx5e_rx_res_rss_set_hash_fields(struct mlx5e_rx_res *res, enum mlx5_traffic_types tt,
u8 rx_hash_fields) u8 rx_hash_fields)
{ {
struct mlx5e_rss *rss = res->rss;
u8 old_rx_hash_fields; u8 old_rx_hash_fields;
int err; int err;
old_rx_hash_fields = res->rss_params.rx_hash_fields[tt]; old_rx_hash_fields = rss->rx_hash_fields[tt];
if (old_rx_hash_fields == rx_hash_fields) if (old_rx_hash_fields == rx_hash_fields)
return 0; return 0;
res->rss_params.rx_hash_fields[tt] = rx_hash_fields; rss->rx_hash_fields[tt] = rx_hash_fields;
err = mlx5e_rx_res_rss_update_tir(res, tt, false); err = mlx5e_rx_res_rss_update_tir(res, tt, false);
if (err) { if (err) {
res->rss_params.rx_hash_fields[tt] = old_rx_hash_fields; rss->rx_hash_fields[tt] = old_rx_hash_fields;
mlx5_core_warn(res->mdev, "Failed to update RSS hash fields of indirect TIR for traffic type %d: err = %d\n", mlx5_core_warn(res->mdev, "Failed to update RSS hash fields of indirect TIR for traffic type %d: err = %d\n",
tt, err); tt, err);
return err; return err;
...@@ -787,11 +817,12 @@ int mlx5e_rx_res_rss_set_hash_fields(struct mlx5e_rx_res *res, enum mlx5_traffic ...@@ -787,11 +817,12 @@ int mlx5e_rx_res_rss_set_hash_fields(struct mlx5e_rx_res *res, enum mlx5_traffic
/* Partial update happened. Try to revert - it may fail too, but /* Partial update happened. Try to revert - it may fail too, but
* there is nothing more we can do. * there is nothing more we can do.
*/ */
res->rss_params.rx_hash_fields[tt] = old_rx_hash_fields; rss->rx_hash_fields[tt] = old_rx_hash_fields;
mlx5_core_warn(res->mdev, "Failed to update RSS hash fields of inner indirect TIR for traffic type %d: err = %d\n", mlx5_core_warn(res->mdev, "Failed to update RSS hash fields of inner indirect TIR for traffic type %d: err = %d\n",
tt, err); tt, err);
if (mlx5e_rx_res_rss_update_tir(res, tt, false)) if (mlx5e_rx_res_rss_update_tir(res, tt, false))
mlx5_core_warn(res->mdev, "Partial update of RSS hash fields happened: failed to revert indirect TIR for traffic type %d to the old values\n", mlx5_core_warn(res->mdev,
"Partial update of RSS hash fields happened: failed to revert indirect TIR for traffic type %d to the old values\n",
tt); tt);
} }
...@@ -800,6 +831,7 @@ int mlx5e_rx_res_rss_set_hash_fields(struct mlx5e_rx_res *res, enum mlx5_traffic ...@@ -800,6 +831,7 @@ int mlx5e_rx_res_rss_set_hash_fields(struct mlx5e_rx_res *res, enum mlx5_traffic
int mlx5e_rx_res_lro_set_param(struct mlx5e_rx_res *res, struct mlx5e_lro_param *lro_param) int mlx5e_rx_res_lro_set_param(struct mlx5e_rx_res *res, struct mlx5e_lro_param *lro_param)
{ {
struct mlx5e_rss *rss = res->rss;
struct mlx5e_tir_builder *builder; struct mlx5e_tir_builder *builder;
enum mlx5_traffic_types tt; enum mlx5_traffic_types tt;
int err, final_err; int err, final_err;
...@@ -814,10 +846,10 @@ int mlx5e_rx_res_lro_set_param(struct mlx5e_rx_res *res, struct mlx5e_lro_param ...@@ -814,10 +846,10 @@ int mlx5e_rx_res_lro_set_param(struct mlx5e_rx_res *res, struct mlx5e_lro_param
final_err = 0; final_err = 0;
for (tt = 0; tt < MLX5E_NUM_INDIR_TIRS; tt++) { for (tt = 0; tt < MLX5E_NUM_INDIR_TIRS; tt++) {
err = mlx5e_tir_modify(&res->rss[tt].indir_tir, builder); err = mlx5e_tir_modify(&rss->tir[tt], builder);
if (err) { if (err) {
mlx5_core_warn(res->mdev, "Failed to update LRO state of indirect TIR %#x for traffic type %d: err = %d\n", mlx5_core_warn(res->mdev, "Failed to update LRO state of indirect TIR %#x for traffic type %d: err = %d\n",
mlx5e_tir_get_tirn(&res->rss[tt].indir_tir), tt, err); mlx5e_tir_get_tirn(&rss->tir[tt]), tt, err);
if (!final_err) if (!final_err)
final_err = err; final_err = err;
} }
...@@ -825,10 +857,10 @@ int mlx5e_rx_res_lro_set_param(struct mlx5e_rx_res *res, struct mlx5e_lro_param ...@@ -825,10 +857,10 @@ int mlx5e_rx_res_lro_set_param(struct mlx5e_rx_res *res, struct mlx5e_lro_param
if (!(res->features & MLX5E_RX_RES_FEATURE_INNER_FT)) if (!(res->features & MLX5E_RX_RES_FEATURE_INNER_FT))
continue; continue;
err = mlx5e_tir_modify(&res->rss[tt].inner_indir_tir, builder); err = mlx5e_tir_modify(&rss->inner_tir[tt], builder);
if (err) { if (err) {
mlx5_core_warn(res->mdev, "Failed to update LRO state of inner indirect TIR %#x for traffic type %d: err = %d\n", mlx5_core_warn(res->mdev, "Failed to update LRO state of inner indirect TIR %#x for traffic type %d: err = %d\n",
mlx5e_tir_get_tirn(&res->rss[tt].inner_indir_tir), tt, err); mlx5e_tir_get_tirn(&rss->inner_tir[tt]), tt, err);
if (!final_err) if (!final_err)
final_err = err; final_err = err;
} }
...@@ -850,5 +882,5 @@ int mlx5e_rx_res_lro_set_param(struct mlx5e_rx_res *res, struct mlx5e_lro_param ...@@ -850,5 +882,5 @@ int mlx5e_rx_res_lro_set_param(struct mlx5e_rx_res *res, struct mlx5e_lro_param
struct mlx5e_rss_params_hash mlx5e_rx_res_get_current_hash(struct mlx5e_rx_res *res) struct mlx5e_rss_params_hash mlx5e_rx_res_get_current_hash(struct mlx5e_rx_res *res)
{ {
return res->rss_params.hash; return res->rss->hash;
} }
...@@ -53,7 +53,7 @@ int mlx5e_rx_res_xsk_deactivate(struct mlx5e_rx_res *res, unsigned int ix); ...@@ -53,7 +53,7 @@ int mlx5e_rx_res_xsk_deactivate(struct mlx5e_rx_res *res, unsigned int ix);
struct mlx5e_rss_params_traffic_type struct mlx5e_rss_params_traffic_type
mlx5e_rx_res_rss_get_current_tt_config(struct mlx5e_rx_res *res, enum mlx5_traffic_types tt); mlx5e_rx_res_rss_get_current_tt_config(struct mlx5e_rx_res *res, enum mlx5_traffic_types tt);
void mlx5e_rx_res_rss_set_indir_uniform(struct mlx5e_rx_res *res, unsigned int nch); void mlx5e_rx_res_rss_set_indir_uniform(struct mlx5e_rx_res *res, unsigned int nch);
void mlx5e_rx_res_rss_get_rxfh(struct mlx5e_rx_res *res, u32 *indir, u8 *key, u8 *hfunc); int mlx5e_rx_res_rss_get_rxfh(struct mlx5e_rx_res *res, u32 *indir, u8 *key, u8 *hfunc);
int mlx5e_rx_res_rss_set_rxfh(struct mlx5e_rx_res *res, const u32 *indir, int mlx5e_rx_res_rss_set_rxfh(struct mlx5e_rx_res *res, const u32 *indir,
const u8 *key, const u8 *hfunc); const u8 *key, const u8 *hfunc);
u8 mlx5e_rx_res_rss_get_hash_fields(struct mlx5e_rx_res *res, enum mlx5_traffic_types tt); u8 mlx5e_rx_res_rss_get_hash_fields(struct mlx5e_rx_res *res, enum mlx5_traffic_types tt);
......
...@@ -1198,12 +1198,12 @@ int mlx5e_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key, ...@@ -1198,12 +1198,12 @@ int mlx5e_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key,
u8 *hfunc) u8 *hfunc)
{ {
struct mlx5e_priv *priv = netdev_priv(netdev); struct mlx5e_priv *priv = netdev_priv(netdev);
int err;
mutex_lock(&priv->state_lock); mutex_lock(&priv->state_lock);
mlx5e_rx_res_rss_get_rxfh(priv->rx_res, indir, key, hfunc); err = mlx5e_rx_res_rss_get_rxfh(priv->rx_res, indir, key, hfunc);
mutex_unlock(&priv->state_lock); mutex_unlock(&priv->state_lock);
return err;
return 0;
} }
int mlx5e_set_rxfh(struct net_device *dev, const u32 *indir, int mlx5e_set_rxfh(struct net_device *dev, const u32 *indir,
......
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