Skip to content

Commit d8a2034

Browse files
Eli CohenSaeed Mahameed
authored andcommitted
net/mlx5: Don't use termination tables in slow path
Don't use termination tables for packets that are steered to the slow path, as a pre-step for supporting packet encap (packet reformat) action on termination tables. Packet encap (reformat action) actions steer the packet to the slow path until outer arp entries are resolved. Signed-off-by: Eli Cohen <[email protected]> Reviewed-by: Oz Shlomo <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent b5f814c commit d8a2034

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ struct mlx5_termtbl_handle;
332332

333333
bool
334334
mlx5_eswitch_termtbl_required(struct mlx5_eswitch *esw,
335+
struct mlx5_esw_flow_attr *attr,
335336
struct mlx5_flow_act *flow_act,
336337
struct mlx5_flow_spec *spec);
337338

@@ -393,6 +394,7 @@ enum {
393394
MLX5_ESW_ATTR_FLAG_VLAN_HANDLED = BIT(0),
394395
MLX5_ESW_ATTR_FLAG_SLOW_PATH = BIT(1),
395396
MLX5_ESW_ATTR_FLAG_NO_IN_PORT = BIT(2),
397+
MLX5_ESW_ATTR_FLAG_HAIRPIN = BIT(3),
396398
};
397399

398400
struct mlx5_esw_flow_attr {

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

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ mlx5_eswitch_add_offloaded_rule(struct mlx5_eswitch *esw,
300300
bool split = !!(attr->split_count);
301301
struct mlx5_flow_handle *rule;
302302
struct mlx5_flow_table *fdb;
303+
bool hairpin = false;
303304
int j, i = 0;
304305

305306
if (esw->mode != MLX5_ESWITCH_OFFLOADS)
@@ -397,16 +398,21 @@ mlx5_eswitch_add_offloaded_rule(struct mlx5_eswitch *esw,
397398
goto err_esw_get;
398399
}
399400

400-
if (mlx5_eswitch_termtbl_required(esw, &flow_act, spec))
401+
if (mlx5_eswitch_termtbl_required(esw, attr, &flow_act, spec)) {
401402
rule = mlx5_eswitch_add_termtbl_rule(esw, fdb, spec, attr,
402403
&flow_act, dest, i);
403-
else
404+
hairpin = true;
405+
} else {
404406
rule = mlx5_add_flow_rules(fdb, spec, &flow_act, dest, i);
407+
}
405408
if (IS_ERR(rule))
406409
goto err_add_rule;
407410
else
408411
atomic64_inc(&esw->offloads.num_flows);
409412

413+
if (hairpin)
414+
attr->flags |= MLX5_ESW_ATTR_FLAG_HAIRPIN;
415+
410416
return rule;
411417

412418
err_add_rule:
@@ -495,10 +501,12 @@ __mlx5_eswitch_del_rule(struct mlx5_eswitch *esw,
495501

496502
mlx5_del_flow_rules(rule);
497503

498-
/* unref the term table */
499-
for (i = 0; i < MLX5_MAX_FLOW_FWD_VPORTS; i++) {
500-
if (attr->dests[i].termtbl)
501-
mlx5_eswitch_termtbl_put(esw, attr->dests[i].termtbl);
504+
if (attr->flags & MLX5_ESW_ATTR_FLAG_HAIRPIN) {
505+
/* unref the term table */
506+
for (i = 0; i < MLX5_MAX_FLOW_FWD_VPORTS; i++) {
507+
if (attr->dests[i].termtbl)
508+
mlx5_eswitch_termtbl_put(esw, attr->dests[i].termtbl);
509+
}
502510
}
503511

504512
atomic64_dec(&esw->offloads.num_flows);

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,12 @@ static bool mlx5_eswitch_offload_is_uplink_port(const struct mlx5_eswitch *esw,
195195

196196
bool
197197
mlx5_eswitch_termtbl_required(struct mlx5_eswitch *esw,
198+
struct mlx5_esw_flow_attr *attr,
198199
struct mlx5_flow_act *flow_act,
199200
struct mlx5_flow_spec *spec)
200201
{
201-
if (!MLX5_CAP_ESW_FLOWTABLE_FDB(esw->dev, termination_table))
202+
if (!MLX5_CAP_ESW_FLOWTABLE_FDB(esw->dev, termination_table) ||
203+
attr->flags & MLX5_ESW_ATTR_FLAG_SLOW_PATH)
202204
return false;
203205

204206
/* push vlan on RX */

0 commit comments

Comments
 (0)