Commit e8711402 authored by Leon Romanovsky's avatar Leon Romanovsky

net/mlx5: Simplify eswitch mode check

Provide mlx5_core device instead of "priv" pointer while checking
eswith mode.
Reviewed-by: default avatarRoi Dayan <roid@nvidia.com>
Signed-off-by: default avatarLeon Romanovsky <leonro@nvidia.com>
parent 601c10c8
...@@ -138,13 +138,6 @@ static int mlx5_ib_create_counters(struct ib_counters *counters, ...@@ -138,13 +138,6 @@ static int mlx5_ib_create_counters(struct ib_counters *counters,
} }
static bool is_mdev_switchdev_mode(const struct mlx5_core_dev *mdev)
{
return MLX5_ESWITCH_MANAGER(mdev) &&
mlx5_ib_eswitch_mode(mdev->priv.eswitch) ==
MLX5_ESWITCH_OFFLOADS;
}
static const struct mlx5_ib_counters *get_counters(struct mlx5_ib_dev *dev, static const struct mlx5_ib_counters *get_counters(struct mlx5_ib_dev *dev,
u8 port_num) u8 port_num)
{ {
......
...@@ -102,11 +102,6 @@ static const struct mlx5_eswitch_rep_ops rep_ops = { ...@@ -102,11 +102,6 @@ static const struct mlx5_eswitch_rep_ops rep_ops = {
.get_proto_dev = mlx5_ib_vport_get_proto_dev, .get_proto_dev = mlx5_ib_vport_get_proto_dev,
}; };
u8 mlx5_ib_eswitch_mode(struct mlx5_eswitch *esw)
{
return mlx5_eswitch_mode(esw);
}
struct mlx5_ib_dev *mlx5_ib_get_rep_ibdev(struct mlx5_eswitch *esw, struct mlx5_ib_dev *mlx5_ib_get_rep_ibdev(struct mlx5_eswitch *esw,
u16 vport_num) u16 vport_num)
{ {
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
extern const struct mlx5_ib_profile raw_eth_profile; extern const struct mlx5_ib_profile raw_eth_profile;
#ifdef CONFIG_MLX5_ESWITCH #ifdef CONFIG_MLX5_ESWITCH
u8 mlx5_ib_eswitch_mode(struct mlx5_eswitch *esw);
struct mlx5_ib_dev *mlx5_ib_get_rep_ibdev(struct mlx5_eswitch *esw, struct mlx5_ib_dev *mlx5_ib_get_rep_ibdev(struct mlx5_eswitch *esw,
u16 vport_num); u16 vport_num);
struct mlx5_ib_dev *mlx5_ib_get_uplink_ibdev(struct mlx5_eswitch *esw); struct mlx5_ib_dev *mlx5_ib_get_uplink_ibdev(struct mlx5_eswitch *esw);
...@@ -26,11 +25,6 @@ struct mlx5_flow_handle *create_flow_rule_vport_sq(struct mlx5_ib_dev *dev, ...@@ -26,11 +25,6 @@ struct mlx5_flow_handle *create_flow_rule_vport_sq(struct mlx5_ib_dev *dev,
struct net_device *mlx5_ib_get_rep_netdev(struct mlx5_eswitch *esw, struct net_device *mlx5_ib_get_rep_netdev(struct mlx5_eswitch *esw,
u16 vport_num); u16 vport_num);
#else /* CONFIG_MLX5_ESWITCH */ #else /* CONFIG_MLX5_ESWITCH */
static inline u8 mlx5_ib_eswitch_mode(struct mlx5_eswitch *esw)
{
return MLX5_ESWITCH_NONE;
}
static inline static inline
struct mlx5_ib_dev *mlx5_ib_get_rep_ibdev(struct mlx5_eswitch *esw, struct mlx5_ib_dev *mlx5_ib_get_rep_ibdev(struct mlx5_eswitch *esw,
u16 vport_num) u16 vport_num)
......
...@@ -47,7 +47,7 @@ static bool is_eth_rep_supported(struct mlx5_core_dev *dev) ...@@ -47,7 +47,7 @@ static bool is_eth_rep_supported(struct mlx5_core_dev *dev)
if (!MLX5_ESWITCH_MANAGER(dev)) if (!MLX5_ESWITCH_MANAGER(dev))
return false; return false;
if (mlx5_eswitch_mode(dev->priv.eswitch) != MLX5_ESWITCH_OFFLOADS) if (!is_mdev_switchdev_mode(dev))
return false; return false;
return true; return true;
...@@ -144,7 +144,7 @@ static bool is_ib_rep_supported(struct mlx5_core_dev *dev) ...@@ -144,7 +144,7 @@ static bool is_ib_rep_supported(struct mlx5_core_dev *dev)
if (!MLX5_ESWITCH_MANAGER(dev)) if (!MLX5_ESWITCH_MANAGER(dev))
return false; return false;
if (mlx5_eswitch_mode(dev->priv.eswitch) != MLX5_ESWITCH_OFFLOADS) if (!is_mdev_switchdev_mode(dev))
return false; return false;
if (mlx5_core_mp_enabled(dev)) if (mlx5_core_mp_enabled(dev))
......
...@@ -221,7 +221,7 @@ static int mlx5_devlink_fs_mode_validate(struct devlink *devlink, u32 id, ...@@ -221,7 +221,7 @@ static int mlx5_devlink_fs_mode_validate(struct devlink *devlink, u32 id,
u8 eswitch_mode; u8 eswitch_mode;
bool smfs_cap; bool smfs_cap;
eswitch_mode = mlx5_eswitch_mode(dev->priv.eswitch); eswitch_mode = mlx5_eswitch_mode(dev);
smfs_cap = mlx5_fs_dr_is_supported(dev); smfs_cap = mlx5_fs_dr_is_supported(dev);
if (!smfs_cap) { if (!smfs_cap) {
......
...@@ -3135,7 +3135,7 @@ static void mlx5e_modify_admin_state(struct mlx5_core_dev *mdev, ...@@ -3135,7 +3135,7 @@ static void mlx5e_modify_admin_state(struct mlx5_core_dev *mdev,
mlx5_set_port_admin_status(mdev, state); mlx5_set_port_admin_status(mdev, state);
if (!MLX5_ESWITCH_MANAGER(mdev) || mlx5_eswitch_mode(esw) == MLX5_ESWITCH_OFFLOADS) if (mlx5_eswitch_mode(mdev) != MLX5_ESWITCH_LEGACY)
return; return;
if (state == MLX5_PORT_UP) if (state == MLX5_PORT_UP)
......
...@@ -271,8 +271,6 @@ mlx5e_tc_match_to_reg_set(struct mlx5_core_dev *mdev, ...@@ -271,8 +271,6 @@ mlx5e_tc_match_to_reg_set(struct mlx5_core_dev *mdev,
return 0; return 0;
} }
#define esw_offloads_mode(esw) (mlx5_eswitch_mode(esw) == MLX5_ESWITCH_OFFLOADS)
static struct mlx5_tc_ct_priv * static struct mlx5_tc_ct_priv *
get_ct_priv(struct mlx5e_priv *priv) get_ct_priv(struct mlx5e_priv *priv)
{ {
...@@ -280,7 +278,7 @@ get_ct_priv(struct mlx5e_priv *priv) ...@@ -280,7 +278,7 @@ get_ct_priv(struct mlx5e_priv *priv)
struct mlx5_rep_uplink_priv *uplink_priv; struct mlx5_rep_uplink_priv *uplink_priv;
struct mlx5e_rep_priv *uplink_rpriv; struct mlx5e_rep_priv *uplink_rpriv;
if (esw_offloads_mode(esw)) { if (is_mdev_switchdev_mode(priv->mdev)) {
uplink_rpriv = mlx5_eswitch_get_uplink_priv(esw, REP_ETH); uplink_rpriv = mlx5_eswitch_get_uplink_priv(esw, REP_ETH);
uplink_priv = &uplink_rpriv->uplink_priv; uplink_priv = &uplink_rpriv->uplink_priv;
...@@ -297,7 +295,7 @@ mlx5_tc_rule_insert(struct mlx5e_priv *priv, ...@@ -297,7 +295,7 @@ mlx5_tc_rule_insert(struct mlx5e_priv *priv,
{ {
struct mlx5_eswitch *esw = priv->mdev->priv.eswitch; struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
if (esw_offloads_mode(esw)) if (is_mdev_switchdev_mode(priv->mdev))
return mlx5_eswitch_add_offloaded_rule(esw, spec, attr); return mlx5_eswitch_add_offloaded_rule(esw, spec, attr);
return mlx5e_add_offloaded_nic_rule(priv, spec, attr); return mlx5e_add_offloaded_nic_rule(priv, spec, attr);
...@@ -310,7 +308,7 @@ mlx5_tc_rule_delete(struct mlx5e_priv *priv, ...@@ -310,7 +308,7 @@ mlx5_tc_rule_delete(struct mlx5e_priv *priv,
{ {
struct mlx5_eswitch *esw = priv->mdev->priv.eswitch; struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
if (esw_offloads_mode(esw)) { if (is_mdev_switchdev_mode(priv->mdev)) {
mlx5_eswitch_del_offloaded_rule(esw, rule, attr); mlx5_eswitch_del_offloaded_rule(esw, rule, attr);
return; return;
......
...@@ -2436,8 +2436,10 @@ int mlx5_eswitch_get_vport_stats(struct mlx5_eswitch *esw, ...@@ -2436,8 +2436,10 @@ int mlx5_eswitch_get_vport_stats(struct mlx5_eswitch *esw,
return err; return err;
} }
u8 mlx5_eswitch_mode(struct mlx5_eswitch *esw) u8 mlx5_eswitch_mode(struct mlx5_core_dev *dev)
{ {
struct mlx5_eswitch *esw = dev->priv.eswitch;
return ESW_ALLOWED(esw) ? esw->mode : MLX5_ESWITCH_NONE; return ESW_ALLOWED(esw) ? esw->mode : MLX5_ESWITCH_NONE;
} }
EXPORT_SYMBOL_GPL(mlx5_eswitch_mode); EXPORT_SYMBOL_GPL(mlx5_eswitch_mode);
......
...@@ -96,10 +96,10 @@ static inline u32 mlx5_eswitch_get_vport_metadata_mask(void) ...@@ -96,10 +96,10 @@ static inline u32 mlx5_eswitch_get_vport_metadata_mask(void)
u32 mlx5_eswitch_get_vport_metadata_for_match(struct mlx5_eswitch *esw, u32 mlx5_eswitch_get_vport_metadata_for_match(struct mlx5_eswitch *esw,
u16 vport_num); u16 vport_num);
u8 mlx5_eswitch_mode(struct mlx5_eswitch *esw); u8 mlx5_eswitch_mode(struct mlx5_core_dev *dev);
#else /* CONFIG_MLX5_ESWITCH */ #else /* CONFIG_MLX5_ESWITCH */
static inline u8 mlx5_eswitch_mode(struct mlx5_eswitch *esw) static inline u8 mlx5_eswitch_mode(struct mlx5_core_dev *dev)
{ {
return MLX5_ESWITCH_NONE; return MLX5_ESWITCH_NONE;
} }
...@@ -136,4 +136,8 @@ mlx5_eswitch_get_vport_metadata_mask(void) ...@@ -136,4 +136,8 @@ mlx5_eswitch_get_vport_metadata_mask(void)
} }
#endif /* CONFIG_MLX5_ESWITCH */ #endif /* CONFIG_MLX5_ESWITCH */
static inline bool is_mdev_switchdev_mode(struct mlx5_core_dev *dev)
{
return mlx5_eswitch_mode(dev) == MLX5_ESWITCH_OFFLOADS;
}
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment