Skip to content

Commit 6cb8786

Browse files
mark-blochSaeed Mahameed
authored andcommitted
net/mlx5: Lag, offload active-backup drops to hardware
In active-backup mode the backup interface's packets are dropped by the bond device. In switchdev where TC rules are offloaded to the FDB this can lead to packets being hit in the FDB where without offload they would have been dropped before reaching TC rules in the kernel. Create a drop rule to make sure packets on inactive ports are dropped before reaching the FDB. Signed-off-by: Mark Bloch <[email protected]> Reviewed-by: Maor Gottlieb <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 54493a0 commit 6cb8786

File tree

2 files changed

+73
-3
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core/lag

2 files changed

+73
-3
lines changed

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

Lines changed: 72 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include "lib/devcom.h"
3939
#include "mlx5_core.h"
4040
#include "eswitch.h"
41+
#include "esw/acl/ofld.h"
4142
#include "lag.h"
4243
#include "mp.h"
4344

@@ -210,6 +211,62 @@ static void mlx5_infer_tx_affinity_mapping(struct lag_tracker *tracker,
210211
*port1 = MLX5_LAG_EGRESS_PORT_2;
211212
}
212213

214+
static bool mlx5_lag_has_drop_rule(struct mlx5_lag *ldev)
215+
{
216+
return ldev->pf[MLX5_LAG_P1].has_drop || ldev->pf[MLX5_LAG_P2].has_drop;
217+
}
218+
219+
static void mlx5_lag_drop_rule_cleanup(struct mlx5_lag *ldev)
220+
{
221+
int i;
222+
223+
for (i = 0; i < MLX5_MAX_PORTS; i++) {
224+
if (!ldev->pf[i].has_drop)
225+
continue;
226+
227+
mlx5_esw_acl_ingress_vport_drop_rule_destroy(ldev->pf[i].dev->priv.eswitch,
228+
MLX5_VPORT_UPLINK);
229+
ldev->pf[i].has_drop = false;
230+
}
231+
}
232+
233+
static void mlx5_lag_drop_rule_setup(struct mlx5_lag *ldev,
234+
struct lag_tracker *tracker)
235+
{
236+
struct mlx5_core_dev *dev0 = ldev->pf[MLX5_LAG_P1].dev;
237+
struct mlx5_core_dev *dev1 = ldev->pf[MLX5_LAG_P2].dev;
238+
struct mlx5_core_dev *inactive;
239+
u8 v2p_port1, v2p_port2;
240+
int inactive_idx;
241+
int err;
242+
243+
/* First delete the current drop rule so there won't be any dropped
244+
* packets
245+
*/
246+
mlx5_lag_drop_rule_cleanup(ldev);
247+
248+
if (!ldev->tracker.has_inactive)
249+
return;
250+
251+
mlx5_infer_tx_affinity_mapping(tracker, &v2p_port1, &v2p_port2);
252+
253+
if (v2p_port1 == MLX5_LAG_EGRESS_PORT_1) {
254+
inactive = dev1;
255+
inactive_idx = MLX5_LAG_P2;
256+
} else {
257+
inactive = dev0;
258+
inactive_idx = MLX5_LAG_P1;
259+
}
260+
261+
err = mlx5_esw_acl_ingress_vport_drop_rule_create(inactive->priv.eswitch,
262+
MLX5_VPORT_UPLINK);
263+
if (!err)
264+
ldev->pf[inactive_idx].has_drop = true;
265+
else
266+
mlx5_core_err(inactive,
267+
"Failed to create lag drop rule, error: %d", err);
268+
}
269+
213270
static int _mlx5_modify_lag(struct mlx5_lag *ldev, u8 v2p_port1, u8 v2p_port2)
214271
{
215272
struct mlx5_core_dev *dev0 = ldev->pf[MLX5_LAG_P1].dev;
@@ -244,6 +301,10 @@ void mlx5_modify_lag(struct mlx5_lag *ldev,
244301
ldev->v2p_map[MLX5_LAG_P1],
245302
ldev->v2p_map[MLX5_LAG_P2]);
246303
}
304+
305+
if (tracker->tx_type == NETDEV_LAG_TX_TYPE_ACTIVEBACKUP &&
306+
!(ldev->flags & MLX5_LAG_FLAG_ROCE))
307+
mlx5_lag_drop_rule_setup(ldev, tracker);
247308
}
248309

249310
static void mlx5_lag_set_port_sel_mode(struct mlx5_lag *ldev,
@@ -345,6 +406,10 @@ int mlx5_activate_lag(struct mlx5_lag *ldev,
345406
return err;
346407
}
347408

409+
if (tracker->tx_type == NETDEV_LAG_TX_TYPE_ACTIVEBACKUP &&
410+
!roce_lag)
411+
mlx5_lag_drop_rule_setup(ldev, tracker);
412+
348413
ldev->flags |= flags;
349414
ldev->shared_fdb = shared_fdb;
350415
return 0;
@@ -379,11 +444,15 @@ static int mlx5_deactivate_lag(struct mlx5_lag *ldev)
379444
"Failed to deactivate VF LAG; driver restart required\n"
380445
"Make sure all VFs are unbound prior to VF LAG activation or deactivation\n");
381446
}
382-
} else if (flags & MLX5_LAG_FLAG_HASH_BASED) {
383-
mlx5_lag_port_sel_destroy(ldev);
447+
return err;
384448
}
385449

386-
return err;
450+
if (flags & MLX5_LAG_FLAG_HASH_BASED)
451+
mlx5_lag_port_sel_destroy(ldev);
452+
if (mlx5_lag_has_drop_rule(ldev))
453+
mlx5_lag_drop_rule_cleanup(ldev);
454+
455+
return 0;
387456
}
388457

389458
static bool mlx5_lag_check_prereq(struct mlx5_lag *ldev)

drivers/net/ethernet/mellanox/mlx5/core/lag/lag.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ enum {
2828
struct lag_func {
2929
struct mlx5_core_dev *dev;
3030
struct net_device *netdev;
31+
bool has_drop;
3132
};
3233

3334
/* Used for collection of netdev event info. */

0 commit comments

Comments
 (0)