mirror of
https://github.com/torvalds/linux.git
synced 2026-09-24 06:24:02 +02:00
net/mlx5e: Return errors from profile->enable
profile->enable is called before enabling an mlx5 netdevice and currently doesn't return errors. Code called from it has to either: 1. eat errors and keep going, leaving a netdevice initialized with missing functionality or 2. manually clean up things that other parts of the init flow might have set up. Option 1 might be useful in some cases for optional functionality but option 2 doesn't make for good design. Add a 3rd option for code which wants to propagate errors from profile->enable and fail netdev init. This change is a noop for now, the first 'user' of this option 3 will be in the next patch. Signed-off-by: Cosmin Ratiu <cratiu@nvidia.com> Signed-off-by: Tariq Toukan <tariqt@nvidia.com> Link: https://patch.msgid.link/20260707130858.969928-15-tariqt@nvidia.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
1e6e0cec0d
commit
13ae76a6a3
|
|
@ -1028,7 +1028,7 @@ struct mlx5e_profile {
|
|||
void (*cleanup_rx)(struct mlx5e_priv *priv);
|
||||
int (*init_tx)(struct mlx5e_priv *priv);
|
||||
void (*cleanup_tx)(struct mlx5e_priv *priv);
|
||||
void (*enable)(struct mlx5e_priv *priv);
|
||||
int (*enable)(struct mlx5e_priv *priv);
|
||||
void (*disable)(struct mlx5e_priv *priv);
|
||||
int (*update_rx)(struct mlx5e_priv *priv);
|
||||
void (*update_stats)(struct mlx5e_priv *priv);
|
||||
|
|
|
|||
|
|
@ -6193,7 +6193,7 @@ static int mlx5e_init_nic_tx(struct mlx5e_priv *priv)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void mlx5e_nic_enable(struct mlx5e_priv *priv)
|
||||
static int mlx5e_nic_enable(struct mlx5e_priv *priv)
|
||||
{
|
||||
struct net_device *netdev = priv->netdev;
|
||||
struct mlx5_core_dev *mdev = priv->mdev;
|
||||
|
|
@ -6224,7 +6224,7 @@ static void mlx5e_nic_enable(struct mlx5e_priv *priv)
|
|||
mlx5e_pcie_cong_event_init(priv);
|
||||
mlx5e_hv_vhca_stats_create(priv);
|
||||
if (netdev->reg_state != NETREG_REGISTERED)
|
||||
return;
|
||||
return 0;
|
||||
mlx5e_dcbnl_init_app(priv);
|
||||
|
||||
mlx5e_nic_set_rx_mode(priv);
|
||||
|
|
@ -6237,6 +6237,8 @@ static void mlx5e_nic_enable(struct mlx5e_priv *priv)
|
|||
netdev_unlock(netdev);
|
||||
netif_device_attach(netdev);
|
||||
rtnl_unlock();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void mlx5e_nic_disable(struct mlx5e_priv *priv)
|
||||
|
|
@ -6618,13 +6620,18 @@ int mlx5e_attach_netdev(struct mlx5e_priv *priv)
|
|||
if (err)
|
||||
goto err_cleanup_tx;
|
||||
|
||||
if (profile->enable)
|
||||
profile->enable(priv);
|
||||
if (profile->enable) {
|
||||
err = profile->enable(priv);
|
||||
if (err)
|
||||
goto err_cleanup_rx;
|
||||
}
|
||||
|
||||
mlx5e_update_features(priv->netdev);
|
||||
|
||||
return 0;
|
||||
|
||||
err_cleanup_rx:
|
||||
profile->cleanup_rx(priv);
|
||||
err_cleanup_tx:
|
||||
profile->cleanup_tx(priv);
|
||||
|
||||
|
|
|
|||
|
|
@ -1262,9 +1262,11 @@ static void mlx5e_cleanup_rep_tx(struct mlx5e_priv *priv)
|
|||
mlx5e_rep_neigh_cleanup(rpriv);
|
||||
}
|
||||
|
||||
static void mlx5e_rep_enable(struct mlx5e_priv *priv)
|
||||
static int mlx5e_rep_enable(struct mlx5e_priv *priv)
|
||||
{
|
||||
mlx5e_set_netdev_mtu_boundaries(priv);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void mlx5e_rep_disable(struct mlx5e_priv *priv)
|
||||
|
|
@ -1322,7 +1324,7 @@ static int uplink_rep_async_event(struct notifier_block *nb, unsigned long event
|
|||
return NOTIFY_DONE;
|
||||
}
|
||||
|
||||
static void mlx5e_uplink_rep_enable(struct mlx5e_priv *priv)
|
||||
static int mlx5e_uplink_rep_enable(struct mlx5e_priv *priv)
|
||||
{
|
||||
struct net_device *netdev = priv->netdev;
|
||||
struct mlx5_core_dev *mdev = priv->mdev;
|
||||
|
|
@ -1357,6 +1359,8 @@ static void mlx5e_uplink_rep_enable(struct mlx5e_priv *priv)
|
|||
netdev_unlock(netdev);
|
||||
netif_device_attach(netdev);
|
||||
rtnl_unlock();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void mlx5e_uplink_rep_disable(struct mlx5e_priv *priv)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user