Skip to content

Commit 8b32580

Browse files
ogerlitzdavem330
authored andcommitted
net/mlx5e: Add TC vlan action for SRIOV offloads
Parse TC vlan actions and set the required elements to allow offloading. Signed-off-by: Or Gerlitz <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent f5f8247 commit 8b32580

File tree

1 file changed

+32
-11
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core

1 file changed

+32
-11
lines changed

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

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -119,17 +119,27 @@ static struct mlx5_flow_rule *mlx5e_tc_add_fdb_flow(struct mlx5e_priv *priv,
119119
struct mlx5_esw_flow_attr *attr)
120120
{
121121
struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
122+
int err;
123+
124+
err = mlx5_eswitch_add_vlan_action(esw, attr);
125+
if (err)
126+
return ERR_PTR(err);
122127

123128
return mlx5_eswitch_add_offloaded_rule(esw, spec, attr);
124129
}
125130

126131
static void mlx5e_tc_del_flow(struct mlx5e_priv *priv,
127-
struct mlx5_flow_rule *rule)
132+
struct mlx5_flow_rule *rule,
133+
struct mlx5_esw_flow_attr *attr)
128134
{
135+
struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
129136
struct mlx5_fc *counter = NULL;
130137

131138
counter = mlx5_flow_rule_counter(rule);
132139

140+
if (esw && esw->mode == SRIOV_OFFLOADS)
141+
mlx5_eswitch_del_vlan_action(esw, attr);
142+
133143
mlx5_del_flow_rule(rule);
134144

135145
mlx5_fc_destroy(priv->mdev, counter);
@@ -369,13 +379,9 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv, struct tcf_exts *exts,
369379

370380
tcf_exts_to_list(exts, &actions);
371381
list_for_each_entry(a, &actions, list) {
372-
/* Only support a single action per rule */
373-
if (attr->action)
374-
return -EINVAL;
375-
376382
if (is_tcf_gact_shot(a)) {
377-
attr->action = MLX5_FLOW_CONTEXT_ACTION_DROP |
378-
MLX5_FLOW_CONTEXT_ACTION_COUNT;
383+
attr->action |= MLX5_FLOW_CONTEXT_ACTION_DROP |
384+
MLX5_FLOW_CONTEXT_ACTION_COUNT;
379385
continue;
380386
}
381387

@@ -392,12 +398,25 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv, struct tcf_exts *exts,
392398
return -EINVAL;
393399
}
394400

395-
attr->action = MLX5_FLOW_CONTEXT_ACTION_FWD_DEST;
401+
attr->action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST;
396402
out_priv = netdev_priv(out_dev);
397403
attr->out_rep = out_priv->ppriv;
398404
continue;
399405
}
400406

407+
if (is_tcf_vlan(a)) {
408+
if (tcf_vlan_action(a) == VLAN_F_POP) {
409+
attr->action |= MLX5_FLOW_CONTEXT_ACTION_VLAN_POP;
410+
} else if (tcf_vlan_action(a) == VLAN_F_PUSH) {
411+
if (tcf_vlan_push_proto(a) != htons(ETH_P_8021Q))
412+
return -EOPNOTSUPP;
413+
414+
attr->action |= MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH;
415+
attr->vlan = tcf_vlan_push_vid(a);
416+
}
417+
continue;
418+
}
419+
401420
return -EINVAL;
402421
}
403422
return 0;
@@ -413,6 +432,7 @@ int mlx5e_configure_flower(struct mlx5e_priv *priv, __be16 protocol,
413432
struct mlx5e_tc_flow *flow;
414433
struct mlx5_flow_spec *spec;
415434
struct mlx5_flow_rule *old = NULL;
435+
struct mlx5_esw_flow_attr *old_attr;
416436
struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
417437

418438
if (esw && esw->mode == SRIOV_OFFLOADS)
@@ -422,6 +442,7 @@ int mlx5e_configure_flower(struct mlx5e_priv *priv, __be16 protocol,
422442
tc->ht_params);
423443
if (flow) {
424444
old = flow->rule;
445+
old_attr = flow->attr;
425446
} else {
426447
if (fdb_flow)
427448
flow = kzalloc(sizeof(*flow) + sizeof(struct mlx5_esw_flow_attr),
@@ -466,7 +487,7 @@ int mlx5e_configure_flower(struct mlx5e_priv *priv, __be16 protocol,
466487
goto err_del_rule;
467488

468489
if (old)
469-
mlx5e_tc_del_flow(priv, old);
490+
mlx5e_tc_del_flow(priv, old, old_attr);
470491

471492
goto out;
472493

@@ -494,7 +515,7 @@ int mlx5e_delete_flower(struct mlx5e_priv *priv,
494515

495516
rhashtable_remove_fast(&tc->ht, &flow->node, tc->ht_params);
496517

497-
mlx5e_tc_del_flow(priv, flow->rule);
518+
mlx5e_tc_del_flow(priv, flow->rule, flow->attr);
498519

499520
kfree(flow);
500521

@@ -551,7 +572,7 @@ static void _mlx5e_tc_del_flow(void *ptr, void *arg)
551572
struct mlx5e_tc_flow *flow = ptr;
552573
struct mlx5e_priv *priv = arg;
553574

554-
mlx5e_tc_del_flow(priv, flow->rule);
575+
mlx5e_tc_del_flow(priv, flow->rule, flow->attr);
555576
kfree(flow);
556577
}
557578

0 commit comments

Comments
 (0)