net/mlx5: E-switch, Reuse total_vports and avoid duplicate nvports
Total e-switch vports are already stored in mlx5_eswitch total_vports. Avoid copy of it in nvports and reuse existing total_vports calculation. Signed-off-by: Parav Pandit <parav@mellanox.com> Reviewed-by: Roi Dayan <roid@mellanox.com> Reviewed-by: Bodong Wang <bodong@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
This commit is contained in:
parent
8b95bda47c
commit
0da3c12dd6
@ -271,7 +271,6 @@ struct mlx5_eswitch {
|
||||
|
||||
struct mlx5_esw_offload offloads;
|
||||
int mode;
|
||||
int nvports;
|
||||
u16 manager_vport;
|
||||
u16 first_host_vport;
|
||||
struct mlx5_esw_functions esw_funcs;
|
||||
|
@ -1132,7 +1132,7 @@ static void esw_set_flow_group_source_port(struct mlx5_eswitch *esw,
|
||||
}
|
||||
}
|
||||
|
||||
static int esw_create_offloads_fdb_tables(struct mlx5_eswitch *esw, int nvports)
|
||||
static int esw_create_offloads_fdb_tables(struct mlx5_eswitch *esw)
|
||||
{
|
||||
int inlen = MLX5_ST_SZ_BYTES(create_flow_group_in);
|
||||
struct mlx5_flow_table_attr ft_attr = {};
|
||||
@ -1165,7 +1165,7 @@ static int esw_create_offloads_fdb_tables(struct mlx5_eswitch *esw, int nvports)
|
||||
goto ns_err;
|
||||
}
|
||||
|
||||
table_size = nvports * MAX_SQ_NVPORTS + MAX_PF_SQ +
|
||||
table_size = esw->total_vports * MAX_SQ_NVPORTS + MAX_PF_SQ +
|
||||
MLX5_ESW_MISS_FLOWS + esw->total_vports;
|
||||
|
||||
/* create the slow path fdb with encap set, so further table instances
|
||||
@ -1202,7 +1202,7 @@ static int esw_create_offloads_fdb_tables(struct mlx5_eswitch *esw, int nvports)
|
||||
MLX5_SET_TO_ONES(fte_match_param, match_criteria, misc_parameters.source_sqn);
|
||||
MLX5_SET_TO_ONES(fte_match_param, match_criteria, misc_parameters.source_port);
|
||||
|
||||
ix = nvports * MAX_SQ_NVPORTS + MAX_PF_SQ;
|
||||
ix = esw->total_vports * MAX_SQ_NVPORTS + MAX_PF_SQ;
|
||||
MLX5_SET(create_flow_group_in, flow_group_in, start_flow_index, 0);
|
||||
MLX5_SET(create_flow_group_in, flow_group_in, end_flow_index, ix - 1);
|
||||
|
||||
@ -1270,7 +1270,6 @@ static int esw_create_offloads_fdb_tables(struct mlx5_eswitch *esw, int nvports)
|
||||
if (err)
|
||||
goto miss_rule_err;
|
||||
|
||||
esw->nvports = nvports;
|
||||
kvfree(flow_group_in);
|
||||
return 0;
|
||||
|
||||
@ -2005,7 +2004,7 @@ static int esw_offloads_steering_init(struct mlx5_eswitch *esw)
|
||||
if (err)
|
||||
goto create_restore_err;
|
||||
|
||||
err = esw_create_offloads_fdb_tables(esw, total_vports);
|
||||
err = esw_create_offloads_fdb_tables(esw);
|
||||
if (err)
|
||||
goto create_fdb_err;
|
||||
|
||||
@ -2459,13 +2458,13 @@ int mlx5_devlink_eswitch_encap_mode_set(struct devlink *devlink,
|
||||
|
||||
esw->offloads.encap = encap;
|
||||
|
||||
err = esw_create_offloads_fdb_tables(esw, esw->nvports);
|
||||
err = esw_create_offloads_fdb_tables(esw);
|
||||
|
||||
if (err) {
|
||||
NL_SET_ERR_MSG_MOD(extack,
|
||||
"Failed re-creating fast FDB table");
|
||||
esw->offloads.encap = !encap;
|
||||
(void)esw_create_offloads_fdb_tables(esw, esw->nvports);
|
||||
(void)esw_create_offloads_fdb_tables(esw);
|
||||
}
|
||||
|
||||
unlock:
|
||||
|
Loading…
Reference in New Issue
Block a user