Commit 9a49a64e authored by Roi Dayan's avatar Roi Dayan Committed by Saeed Mahameed

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: default avatarRoi Dayan <roid@nvidia.com>
Reviewed-by: default avatarMaor Dickman <maord@nvidia.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
parent 2afcfae7
...@@ -22,7 +22,7 @@ static int type_show(struct seq_file *file, void *priv) ...@@ -22,7 +22,7 @@ static int type_show(struct seq_file *file, void *priv)
struct mlx5_lag *ldev; struct mlx5_lag *ldev;
char *mode = NULL; char *mode = NULL;
ldev = dev->priv.lag; ldev = mlx5_lag_dev(dev);
mutex_lock(&ldev->lock); mutex_lock(&ldev->lock);
if (__mlx5_lag_is_active(ldev)) if (__mlx5_lag_is_active(ldev))
mode = get_str_mode_type(ldev); mode = get_str_mode_type(ldev);
...@@ -41,7 +41,7 @@ static int port_sel_mode_show(struct seq_file *file, void *priv) ...@@ -41,7 +41,7 @@ static int port_sel_mode_show(struct seq_file *file, void *priv)
int ret = 0; int ret = 0;
char *mode; char *mode;
ldev = dev->priv.lag; ldev = mlx5_lag_dev(dev);
mutex_lock(&ldev->lock); mutex_lock(&ldev->lock);
if (__mlx5_lag_is_active(ldev)) if (__mlx5_lag_is_active(ldev))
mode = mlx5_get_str_port_sel_mode(ldev->mode, ldev->mode_flags); 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) ...@@ -61,7 +61,7 @@ static int state_show(struct seq_file *file, void *priv)
struct mlx5_lag *ldev; struct mlx5_lag *ldev;
bool active; bool active;
ldev = dev->priv.lag; ldev = mlx5_lag_dev(dev);
mutex_lock(&ldev->lock); mutex_lock(&ldev->lock);
active = __mlx5_lag_is_active(ldev); active = __mlx5_lag_is_active(ldev);
mutex_unlock(&ldev->lock); mutex_unlock(&ldev->lock);
...@@ -77,7 +77,7 @@ static int flags_show(struct seq_file *file, void *priv) ...@@ -77,7 +77,7 @@ static int flags_show(struct seq_file *file, void *priv)
bool shared_fdb; bool shared_fdb;
bool lag_active; bool lag_active;
ldev = dev->priv.lag; ldev = mlx5_lag_dev(dev);
mutex_lock(&ldev->lock); mutex_lock(&ldev->lock);
lag_active = __mlx5_lag_is_active(ldev); lag_active = __mlx5_lag_is_active(ldev);
if (!lag_active) if (!lag_active)
...@@ -108,7 +108,7 @@ static int mapping_show(struct seq_file *file, void *priv) ...@@ -108,7 +108,7 @@ static int mapping_show(struct seq_file *file, void *priv)
int num_ports; int num_ports;
int i; int i;
ldev = dev->priv.lag; ldev = mlx5_lag_dev(dev);
mutex_lock(&ldev->lock); mutex_lock(&ldev->lock);
lag_active = __mlx5_lag_is_active(ldev); lag_active = __mlx5_lag_is_active(ldev);
if (lag_active) { if (lag_active) {
...@@ -142,7 +142,7 @@ static int members_show(struct seq_file *file, void *priv) ...@@ -142,7 +142,7 @@ static int members_show(struct seq_file *file, void *priv)
struct mlx5_lag *ldev; struct mlx5_lag *ldev;
int i; int i;
ldev = dev->priv.lag; ldev = mlx5_lag_dev(dev);
mutex_lock(&ldev->lock); mutex_lock(&ldev->lock);
for (i = 0; i < ldev->ports; i++) { for (i = 0; i < ldev->ports; i++) {
if (!ldev->pf[i].dev) if (!ldev->pf[i].dev)
......
...@@ -1187,7 +1187,7 @@ static int __mlx5_lag_dev_add_mdev(struct mlx5_core_dev *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); tmp_dev = mlx5_get_next_phys_dev_lag(dev);
if (tmp_dev) if (tmp_dev)
ldev = tmp_dev->priv.lag; ldev = mlx5_lag_dev(tmp_dev);
if (!ldev) { if (!ldev) {
ldev = mlx5_lag_dev_alloc(dev); ldev = mlx5_lag_dev_alloc(dev);
......
...@@ -58,7 +58,7 @@ static void mlx5_mpesw_work(struct work_struct *work) ...@@ -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, static int mlx5_lag_mpesw_queue_work(struct mlx5_core_dev *dev,
enum mpesw_op op) 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; struct mlx5_mpesw_work_st *work;
int err = 0; int err = 0;
...@@ -100,7 +100,7 @@ int mlx5_lag_mpesw_do_mirred(struct mlx5_core_dev *mdev, ...@@ -100,7 +100,7 @@ int mlx5_lag_mpesw_do_mirred(struct mlx5_core_dev *mdev,
struct net_device *out_dev, struct net_device *out_dev,
struct netlink_ext_ack *extack) 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) if (!netif_is_bond_master(out_dev) || !ldev)
return 0; return 0;
...@@ -114,9 +114,10 @@ int mlx5_lag_mpesw_do_mirred(struct mlx5_core_dev *mdev, ...@@ -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) bool mlx5_lag_mpesw_is_activated(struct mlx5_core_dev *dev)
{ {
struct mlx5_lag *ldev = mlx5_lag_dev(dev);
bool ret; bool ret;
ret = dev->priv.lag && dev->priv.lag->mode == MLX5_LAG_MODE_MPESW; ret = ldev && ldev->mode == MLX5_LAG_MODE_MPESW;
return ret; return ret;
} }
......
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