net/mlx5: Lag, Use mlx5_lag_dev() instead of derefering pointers
Use the existing wrapper mlx5_lag_dev() to access the lag object from dev for better maintainability and consistent code. Signed-off-by: Roi Dayan <roid@nvidia.com> Reviewed-by: Maor Dickman <maord@nvidia.com> Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
This commit is contained in:
parent
2afcfae77a
commit
9a49a64ea7
@ -22,7 +22,7 @@ static int type_show(struct seq_file *file, void *priv)
|
||||
struct mlx5_lag *ldev;
|
||||
char *mode = NULL;
|
||||
|
||||
ldev = dev->priv.lag;
|
||||
ldev = mlx5_lag_dev(dev);
|
||||
mutex_lock(&ldev->lock);
|
||||
if (__mlx5_lag_is_active(ldev))
|
||||
mode = get_str_mode_type(ldev);
|
||||
@ -41,7 +41,7 @@ static int port_sel_mode_show(struct seq_file *file, void *priv)
|
||||
int ret = 0;
|
||||
char *mode;
|
||||
|
||||
ldev = dev->priv.lag;
|
||||
ldev = mlx5_lag_dev(dev);
|
||||
mutex_lock(&ldev->lock);
|
||||
if (__mlx5_lag_is_active(ldev))
|
||||
mode = mlx5_get_str_port_sel_mode(ldev->mode, ldev->mode_flags);
|
||||
@ -61,7 +61,7 @@ static int state_show(struct seq_file *file, void *priv)
|
||||
struct mlx5_lag *ldev;
|
||||
bool active;
|
||||
|
||||
ldev = dev->priv.lag;
|
||||
ldev = mlx5_lag_dev(dev);
|
||||
mutex_lock(&ldev->lock);
|
||||
active = __mlx5_lag_is_active(ldev);
|
||||
mutex_unlock(&ldev->lock);
|
||||
@ -77,7 +77,7 @@ static int flags_show(struct seq_file *file, void *priv)
|
||||
bool shared_fdb;
|
||||
bool lag_active;
|
||||
|
||||
ldev = dev->priv.lag;
|
||||
ldev = mlx5_lag_dev(dev);
|
||||
mutex_lock(&ldev->lock);
|
||||
lag_active = __mlx5_lag_is_active(ldev);
|
||||
if (!lag_active)
|
||||
@ -108,7 +108,7 @@ static int mapping_show(struct seq_file *file, void *priv)
|
||||
int num_ports;
|
||||
int i;
|
||||
|
||||
ldev = dev->priv.lag;
|
||||
ldev = mlx5_lag_dev(dev);
|
||||
mutex_lock(&ldev->lock);
|
||||
lag_active = __mlx5_lag_is_active(ldev);
|
||||
if (lag_active) {
|
||||
@ -142,7 +142,7 @@ static int members_show(struct seq_file *file, void *priv)
|
||||
struct mlx5_lag *ldev;
|
||||
int i;
|
||||
|
||||
ldev = dev->priv.lag;
|
||||
ldev = mlx5_lag_dev(dev);
|
||||
mutex_lock(&ldev->lock);
|
||||
for (i = 0; i < ldev->ports; i++) {
|
||||
if (!ldev->pf[i].dev)
|
||||
|
@ -1187,7 +1187,7 @@ static int __mlx5_lag_dev_add_mdev(struct mlx5_core_dev *dev)
|
||||
|
||||
tmp_dev = mlx5_get_next_phys_dev_lag(dev);
|
||||
if (tmp_dev)
|
||||
ldev = tmp_dev->priv.lag;
|
||||
ldev = mlx5_lag_dev(tmp_dev);
|
||||
|
||||
if (!ldev) {
|
||||
ldev = mlx5_lag_dev_alloc(dev);
|
||||
|
@ -58,7 +58,7 @@ static void mlx5_mpesw_work(struct work_struct *work)
|
||||
static int mlx5_lag_mpesw_queue_work(struct mlx5_core_dev *dev,
|
||||
enum mpesw_op op)
|
||||
{
|
||||
struct mlx5_lag *ldev = dev->priv.lag;
|
||||
struct mlx5_lag *ldev = mlx5_lag_dev(dev);
|
||||
struct mlx5_mpesw_work_st *work;
|
||||
int err = 0;
|
||||
|
||||
@ -100,7 +100,7 @@ int mlx5_lag_mpesw_do_mirred(struct mlx5_core_dev *mdev,
|
||||
struct net_device *out_dev,
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
struct mlx5_lag *ldev = mdev->priv.lag;
|
||||
struct mlx5_lag *ldev = mlx5_lag_dev(mdev);
|
||||
|
||||
if (!netif_is_bond_master(out_dev) || !ldev)
|
||||
return 0;
|
||||
@ -114,9 +114,10 @@ int mlx5_lag_mpesw_do_mirred(struct mlx5_core_dev *mdev,
|
||||
|
||||
bool mlx5_lag_mpesw_is_activated(struct mlx5_core_dev *dev)
|
||||
{
|
||||
struct mlx5_lag *ldev = mlx5_lag_dev(dev);
|
||||
bool ret;
|
||||
|
||||
ret = dev->priv.lag && dev->priv.lag->mode == MLX5_LAG_MODE_MPESW;
|
||||
ret = ldev && ldev->mode == MLX5_LAG_MODE_MPESW;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user