Skip to content

Commit 4383cfc

Browse files
gurmichaelSaeed Mahameed
authored andcommitted
net/mlx5: Add devlink reload
Implement devlink reload for mlx5. Usage example: devlink dev reload pci/0000:06:00.0 Signed-off-by: Michael Guralnik <michaelgur@mellanox.com> Acked-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
1 parent 71c6eae commit 4383cfc

3 files changed

Lines changed: 25 additions & 2 deletions

File tree

‎drivers/net/ethernet/mellanox/mlx5/core/devlink.c‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,22 @@ mlx5_devlink_info_get(struct devlink *devlink, struct devlink_info_req *req,
8585
return 0;
8686
}
8787

88+
static int mlx5_devlink_reload_down(struct devlink *devlink, bool netns_change,
89+
struct netlink_ext_ack *extack)
90+
{
91+
struct mlx5_core_dev *dev = devlink_priv(devlink);
92+
93+
return mlx5_unload_one(dev, false);
94+
}
95+
96+
static int mlx5_devlink_reload_up(struct devlink *devlink,
97+
struct netlink_ext_ack *extack)
98+
{
99+
struct mlx5_core_dev *dev = devlink_priv(devlink);
100+
101+
return mlx5_load_one(dev, false);
102+
}
103+
88104
static const struct devlink_ops mlx5_devlink_ops = {
89105
#ifdef CONFIG_MLX5_ESWITCH
90106
.eswitch_mode_set = mlx5_devlink_eswitch_mode_set,
@@ -96,6 +112,8 @@ static const struct devlink_ops mlx5_devlink_ops = {
96112
#endif
97113
.flash_update = mlx5_devlink_flash_update,
98114
.info_get = mlx5_devlink_info_get,
115+
.reload_down = mlx5_devlink_reload_down,
116+
.reload_up = mlx5_devlink_reload_up,
99117
};
100118

101119
struct devlink *mlx5_devlink_alloc(void)
@@ -235,6 +253,7 @@ int mlx5_devlink_register(struct devlink *devlink, struct device *dev)
235253
goto params_reg_err;
236254
mlx5_devlink_set_params_init_values(devlink);
237255
devlink_params_publish(devlink);
256+
devlink_reload_enable(devlink);
238257
return 0;
239258

240259
params_reg_err:
@@ -244,6 +263,7 @@ int mlx5_devlink_register(struct devlink *devlink, struct device *dev)
244263

245264
void mlx5_devlink_unregister(struct devlink *devlink)
246265
{
266+
devlink_reload_disable(devlink);
247267
devlink_params_unregister(devlink, mlx5_devlink_params,
248268
ARRAY_SIZE(mlx5_devlink_params));
249269
devlink_unregister(devlink);

‎drivers/net/ethernet/mellanox/mlx5/core/main.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,7 +1168,7 @@ static void mlx5_unload(struct mlx5_core_dev *dev)
11681168
mlx5_put_uars_page(dev, dev->priv.uar);
11691169
}
11701170

1171-
static int mlx5_load_one(struct mlx5_core_dev *dev, bool boot)
1171+
int mlx5_load_one(struct mlx5_core_dev *dev, bool boot)
11721172
{
11731173
int err = 0;
11741174

@@ -1226,7 +1226,7 @@ static int mlx5_load_one(struct mlx5_core_dev *dev, bool boot)
12261226
return err;
12271227
}
12281228

1229-
static int mlx5_unload_one(struct mlx5_core_dev *dev, bool cleanup)
1229+
int mlx5_unload_one(struct mlx5_core_dev *dev, bool cleanup)
12301230
{
12311231
if (cleanup) {
12321232
mlx5_unregister_device(dev);

‎drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,4 +243,7 @@ enum {
243243

244244
u8 mlx5_get_nic_state(struct mlx5_core_dev *dev);
245245
void mlx5_set_nic_state(struct mlx5_core_dev *dev, u8 state);
246+
247+
int mlx5_unload_one(struct mlx5_core_dev *dev, bool cleanup);
248+
int mlx5_load_one(struct mlx5_core_dev *dev, bool boot);
246249
#endif /* __MLX5_CORE_H__ */

0 commit comments

Comments
 (0)