net/mlx5: E-Switch prepare functions change handler to be modular
Eswitch function change handler will service multiple type of events for VFs and non VF functions update. Hence, introduce and use the helper function esw_vfs_changed_event_handler() for handling change in num VFs to improve the code readability. Signed-off-by: Parav Pandit <parav@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
This commit is contained in:
parent
2752b82316
commit
7e736f9ae3
|
@ -2046,38 +2046,48 @@ static void esw_offloads_steering_cleanup(struct mlx5_eswitch *esw)
|
||||||
esw_destroy_offloads_acl_tables(esw);
|
esw_destroy_offloads_acl_tables(esw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
esw_vfs_changed_event_handler(struct mlx5_eswitch *esw, const u32 *out)
|
||||||
|
{
|
||||||
|
bool host_pf_disabled;
|
||||||
|
u16 new_num_vfs;
|
||||||
|
|
||||||
|
new_num_vfs = MLX5_GET(query_esw_functions_out, out,
|
||||||
|
host_params_context.host_num_of_vfs);
|
||||||
|
host_pf_disabled = MLX5_GET(query_esw_functions_out, out,
|
||||||
|
host_params_context.host_pf_disabled);
|
||||||
|
|
||||||
|
if (new_num_vfs == esw->esw_funcs.num_vfs || host_pf_disabled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* Number of VFs can only change from "0 to x" or "x to 0". */
|
||||||
|
if (esw->esw_funcs.num_vfs > 0) {
|
||||||
|
esw_offloads_unload_vf_reps(esw, esw->esw_funcs.num_vfs);
|
||||||
|
} else {
|
||||||
|
int err;
|
||||||
|
|
||||||
|
err = esw_offloads_load_vf_reps(esw, new_num_vfs);
|
||||||
|
if (err)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
esw->esw_funcs.num_vfs = new_num_vfs;
|
||||||
|
}
|
||||||
|
|
||||||
static void esw_functions_changed_event_handler(struct work_struct *work)
|
static void esw_functions_changed_event_handler(struct work_struct *work)
|
||||||
{
|
{
|
||||||
u32 out[MLX5_ST_SZ_DW(query_esw_functions_out)] = {};
|
u32 out[MLX5_ST_SZ_DW(query_esw_functions_out)] = {};
|
||||||
struct mlx5_host_work *host_work;
|
struct mlx5_host_work *host_work;
|
||||||
struct mlx5_eswitch *esw;
|
struct mlx5_eswitch *esw;
|
||||||
bool host_pf_disabled;
|
|
||||||
u16 num_vfs = 0;
|
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
host_work = container_of(work, struct mlx5_host_work, work);
|
host_work = container_of(work, struct mlx5_host_work, work);
|
||||||
esw = host_work->esw;
|
esw = host_work->esw;
|
||||||
|
|
||||||
err = mlx5_esw_query_functions(esw->dev, out, sizeof(out));
|
err = mlx5_esw_query_functions(esw->dev, out, sizeof(out));
|
||||||
num_vfs = MLX5_GET(query_esw_functions_out, out,
|
|
||||||
host_params_context.host_num_of_vfs);
|
|
||||||
host_pf_disabled = MLX5_GET(query_esw_functions_out, out,
|
|
||||||
host_params_context.host_pf_disabled);
|
|
||||||
if (err || host_pf_disabled || num_vfs == esw->esw_funcs.num_vfs)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
/* Number of VFs can only change from "0 to x" or "x to 0". */
|
|
||||||
if (esw->esw_funcs.num_vfs > 0) {
|
|
||||||
esw_offloads_unload_vf_reps(esw, esw->esw_funcs.num_vfs);
|
|
||||||
} else {
|
|
||||||
err = esw_offloads_load_vf_reps(esw, num_vfs);
|
|
||||||
|
|
||||||
if (err)
|
if (err)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
|
||||||
|
|
||||||
esw->esw_funcs.num_vfs = num_vfs;
|
|
||||||
|
|
||||||
|
esw_vfs_changed_event_handler(esw, out);
|
||||||
out:
|
out:
|
||||||
kfree(host_work);
|
kfree(host_work);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue