Skip to content

Commit ddbb5dd

Browse files
lrw514kuba-moo
authored andcommitted
net/mlx5: LAG, Refactor lag logic
Wrap the lag pf access into two new macros: 1. ldev_for_each() 2. ldev_for_each_reverse() The maximum number of lag ports and the index to `natvie_port_num` mapping will be handled by the two new macros. Users shouldn't use the for loop anymore. Signed-off-by: Rongwei Liu <[email protected]> Reviewed-by: Saeed Mahameed <[email protected]> Reviewed-by: Mark Bloch <[email protected]> Signed-off-by: Tariq Toukan <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 8d94a74 commit ddbb5dd

File tree

6 files changed

+137
-121
lines changed

6 files changed

+137
-121
lines changed

drivers/net/ethernet/mellanox/mlx5/core/lag/debugfs.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,20 +105,20 @@ static int mapping_show(struct seq_file *file, void *priv)
105105
struct mlx5_lag *ldev;
106106
bool hash = false;
107107
bool lag_active;
108+
int i, idx = 0;
108109
int num_ports;
109-
int i;
110110

111111
ldev = mlx5_lag_dev(dev);
112112
mutex_lock(&ldev->lock);
113113
lag_active = __mlx5_lag_is_active(ldev);
114114
if (lag_active) {
115115
if (test_bit(MLX5_LAG_MODE_FLAG_HASH_BASED, &ldev->mode_flags)) {
116-
mlx5_infer_tx_enabled(&ldev->tracker, ldev->ports, ports,
116+
mlx5_infer_tx_enabled(&ldev->tracker, ldev, ports,
117117
&num_ports);
118118
hash = true;
119119
} else {
120-
for (i = 0; i < ldev->ports; i++)
121-
ports[i] = ldev->v2p_map[i];
120+
mlx5_ldev_for_each(i, 0, ldev)
121+
ports[idx++] = ldev->v2p_map[i];
122122
num_ports = ldev->ports;
123123
}
124124
}
@@ -144,11 +144,8 @@ static int members_show(struct seq_file *file, void *priv)
144144

145145
ldev = mlx5_lag_dev(dev);
146146
mutex_lock(&ldev->lock);
147-
for (i = 0; i < ldev->ports; i++) {
148-
if (!ldev->pf[i].dev)
149-
continue;
147+
mlx5_ldev_for_each(i, 0, ldev)
150148
seq_printf(file, "%s\n", dev_name(ldev->pf[i].dev->device));
151-
}
152149
mutex_unlock(&ldev->lock);
153150

154151
return 0;

0 commit comments

Comments
 (0)