Skip to content

Commit 5e6107b

Browse files
mosheshemesh2Saeed Mahameed
authored andcommitted
net/mlx5: Check capability for fw_reset
Functions which can't access MFRL (Management Firmware Reset Level) register, have no use of fw_reset structures or events. Remove fw_reset structures allocation and registration for fw reset events notifications for these functions. Having the devlink param enable_remote_dev_reset on functions that don't have this capability is misleading as these functions are not allowed to influence the reset flow. Hence, this patch removes this parameter for such functions. In addition, return not supported on devlink reload action fw_activate for these functions. Fixes: 38b9f90 ("net/mlx5: Handle sync reset request event") Signed-off-by: Moshe Shemesh <[email protected]> Reviewed-by: Aya Levin <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent ac8082a commit 5e6107b

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,12 @@ static int mlx5_devlink_reload_down(struct devlink *devlink, bool netns_change,
157157
return -EOPNOTSUPP;
158158
}
159159

160+
if (action == DEVLINK_RELOAD_ACTION_FW_ACTIVATE &&
161+
!dev->priv.fw_reset) {
162+
NL_SET_ERR_MSG_MOD(extack, "FW activate is unsupported for this function");
163+
return -EOPNOTSUPP;
164+
}
165+
160166
if (mlx5_core_is_pf(dev) && pci_num_vf(pdev))
161167
NL_SET_ERR_MSG_MOD(extack, "reload while VFs are present is unfavorable");
162168

drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -703,19 +703,30 @@ void mlx5_fw_reset_events_start(struct mlx5_core_dev *dev)
703703
{
704704
struct mlx5_fw_reset *fw_reset = dev->priv.fw_reset;
705705

706+
if (!fw_reset)
707+
return;
708+
706709
MLX5_NB_INIT(&fw_reset->nb, fw_reset_event_notifier, GENERAL_EVENT);
707710
mlx5_eq_notifier_register(dev, &fw_reset->nb);
708711
}
709712

710713
void mlx5_fw_reset_events_stop(struct mlx5_core_dev *dev)
711714
{
712-
mlx5_eq_notifier_unregister(dev, &dev->priv.fw_reset->nb);
715+
struct mlx5_fw_reset *fw_reset = dev->priv.fw_reset;
716+
717+
if (!fw_reset)
718+
return;
719+
720+
mlx5_eq_notifier_unregister(dev, &fw_reset->nb);
713721
}
714722

715723
void mlx5_drain_fw_reset(struct mlx5_core_dev *dev)
716724
{
717725
struct mlx5_fw_reset *fw_reset = dev->priv.fw_reset;
718726

727+
if (!fw_reset)
728+
return;
729+
719730
set_bit(MLX5_FW_RESET_FLAGS_DROP_NEW_REQUESTS, &fw_reset->reset_flags);
720731
cancel_work_sync(&fw_reset->fw_live_patch_work);
721732
cancel_work_sync(&fw_reset->reset_request_work);
@@ -733,9 +744,13 @@ static const struct devlink_param mlx5_fw_reset_devlink_params[] = {
733744

734745
int mlx5_fw_reset_init(struct mlx5_core_dev *dev)
735746
{
736-
struct mlx5_fw_reset *fw_reset = kzalloc(sizeof(*fw_reset), GFP_KERNEL);
747+
struct mlx5_fw_reset *fw_reset;
737748
int err;
738749

750+
if (!MLX5_CAP_MCAM_REG(dev, mfrl))
751+
return 0;
752+
753+
fw_reset = kzalloc(sizeof(*fw_reset), GFP_KERNEL);
739754
if (!fw_reset)
740755
return -ENOMEM;
741756
fw_reset->wq = create_singlethread_workqueue("mlx5_fw_reset_events");
@@ -771,6 +786,9 @@ void mlx5_fw_reset_cleanup(struct mlx5_core_dev *dev)
771786
{
772787
struct mlx5_fw_reset *fw_reset = dev->priv.fw_reset;
773788

789+
if (!fw_reset)
790+
return;
791+
774792
devl_params_unregister(priv_to_devlink(dev),
775793
mlx5_fw_reset_devlink_params,
776794
ARRAY_SIZE(mlx5_fw_reset_devlink_params));

include/linux/mlx5/mlx5_ifc.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10261,7 +10261,9 @@ struct mlx5_ifc_mcam_access_reg_bits {
1026110261

1026210262
u8 regs_63_to_46[0x12];
1026310263
u8 mrtc[0x1];
10264-
u8 regs_44_to_32[0xd];
10264+
u8 regs_44_to_41[0x4];
10265+
u8 mfrl[0x1];
10266+
u8 regs_39_to_32[0x8];
1026510267

1026610268
u8 regs_31_to_10[0x16];
1026710269
u8 mtmp[0x1];

0 commit comments

Comments
 (0)