net/mlx5: Avoid deriving mlx5_core_dev second time
All callers needs to work on mlx5_core_dev and it is already derived before calling mlx5_devlink_eswitch_check(). Hence, accept mlx5_core_dev in mlx5_devlink_eswitch_check(). Given that it works on mlx5_core_dev change helper function name to drop devlink prefix. Reviewed-by: Roi Dayan <roid@mellanox.com> Reviewed-by: Bodong Wang <bodong@mellanox.com> Signed-off-by: Parav Pandit <parav@mellanox.com> Reviewed-by: Mark Bloch <markb@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
This commit is contained in:
parent
d6c8022dfb
commit
0e6fa491e8
|
@ -2478,10 +2478,8 @@ static int esw_inline_mode_to_devlink(u8 mlx5_mode, u8 *mode)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int mlx5_devlink_eswitch_check(struct devlink *devlink)
|
||||
static int mlx5_eswitch_check(const struct mlx5_core_dev *dev)
|
||||
{
|
||||
struct mlx5_core_dev *dev = devlink_priv(devlink);
|
||||
|
||||
if (MLX5_CAP_GEN(dev, port_type) != MLX5_CAP_PORT_TYPE_ETH)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
|
@ -2502,7 +2500,7 @@ int mlx5_devlink_eswitch_mode_set(struct devlink *devlink, u16 mode,
|
|||
u16 cur_mlx5_mode, mlx5_mode = 0;
|
||||
int err;
|
||||
|
||||
err = mlx5_devlink_eswitch_check(devlink);
|
||||
err = mlx5_eswitch_check(dev);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
|
@ -2527,7 +2525,7 @@ int mlx5_devlink_eswitch_mode_get(struct devlink *devlink, u16 *mode)
|
|||
struct mlx5_core_dev *dev = devlink_priv(devlink);
|
||||
int err;
|
||||
|
||||
err = mlx5_devlink_eswitch_check(devlink);
|
||||
err = mlx5_eswitch_check(dev);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
|
@ -2542,7 +2540,7 @@ int mlx5_devlink_eswitch_inline_mode_set(struct devlink *devlink, u8 mode,
|
|||
int err, vport, num_vport;
|
||||
u8 mlx5_mode;
|
||||
|
||||
err = mlx5_devlink_eswitch_check(devlink);
|
||||
err = mlx5_eswitch_check(dev);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
|
@ -2596,7 +2594,7 @@ int mlx5_devlink_eswitch_inline_mode_get(struct devlink *devlink, u8 *mode)
|
|||
struct mlx5_eswitch *esw = dev->priv.eswitch;
|
||||
int err;
|
||||
|
||||
err = mlx5_devlink_eswitch_check(devlink);
|
||||
err = mlx5_eswitch_check(dev);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
|
@ -2611,7 +2609,7 @@ int mlx5_devlink_eswitch_encap_mode_set(struct devlink *devlink,
|
|||
struct mlx5_eswitch *esw = dev->priv.eswitch;
|
||||
int err;
|
||||
|
||||
err = mlx5_devlink_eswitch_check(devlink);
|
||||
err = mlx5_eswitch_check(dev);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
|
@ -2660,7 +2658,7 @@ int mlx5_devlink_eswitch_encap_mode_get(struct devlink *devlink,
|
|||
struct mlx5_eswitch *esw = dev->priv.eswitch;
|
||||
int err;
|
||||
|
||||
err = mlx5_devlink_eswitch_check(devlink);
|
||||
err = mlx5_eswitch_check(dev);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
|
|
Loading…
Reference in New Issue