Skip to content

Commit e37a79e

Browse files
mark-blochrleon
authored andcommitted
net/mlx5e: Add tc support for FWD rule with counter
When creating a FWD rule using tc create also a HW counter for this rule. Signed-off-by: Mark Bloch <markb@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com> Signed-off-by: Leon Romanovsky <leon@kernel.org>
1 parent ae05831 commit e37a79e

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,8 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv, struct tcf_exts *exts,
419419
return -EINVAL;
420420
}
421421

422-
attr->action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST;
422+
attr->action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST |
423+
MLX5_FLOW_CONTEXT_ACTION_COUNT;
423424
out_priv = netdev_priv(out_dev);
424425
attr->out_rep = out_priv->ppriv;
425426
continue;

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,27 +48,30 @@ mlx5_eswitch_add_offloaded_rule(struct mlx5_eswitch *esw,
4848
struct mlx5_flow_spec *spec,
4949
struct mlx5_esw_flow_attr *attr)
5050
{
51-
struct mlx5_flow_destination dest = { 0 };
51+
struct mlx5_flow_destination dest[2] = {};
5252
struct mlx5_fc *counter = NULL;
5353
struct mlx5_flow_handle *rule;
5454
void *misc;
5555
int action;
56+
int i = 0;
5657

5758
if (esw->mode != SRIOV_OFFLOADS)
5859
return ERR_PTR(-EOPNOTSUPP);
5960

6061
action = attr->action;
6162

6263
if (action & MLX5_FLOW_CONTEXT_ACTION_FWD_DEST) {
63-
dest.type = MLX5_FLOW_DESTINATION_TYPE_VPORT;
64-
dest.vport_num = attr->out_rep->vport;
65-
action = MLX5_FLOW_CONTEXT_ACTION_FWD_DEST;
66-
} else if (action & MLX5_FLOW_CONTEXT_ACTION_COUNT) {
64+
dest[i].type = MLX5_FLOW_DESTINATION_TYPE_VPORT;
65+
dest[i].vport_num = attr->out_rep->vport;
66+
i++;
67+
}
68+
if (action & MLX5_FLOW_CONTEXT_ACTION_COUNT) {
6769
counter = mlx5_fc_create(esw->dev, true);
6870
if (IS_ERR(counter))
6971
return ERR_CAST(counter);
70-
dest.type = MLX5_FLOW_DESTINATION_TYPE_COUNTER;
71-
dest.counter = counter;
72+
dest[i].type = MLX5_FLOW_DESTINATION_TYPE_COUNTER;
73+
dest[i].counter = counter;
74+
i++;
7275
}
7376

7477
misc = MLX5_ADDR_OF(fte_match_param, spec->match_value, misc_parameters);
@@ -81,8 +84,7 @@ mlx5_eswitch_add_offloaded_rule(struct mlx5_eswitch *esw,
8184
MLX5_MATCH_MISC_PARAMETERS;
8285

8386
rule = mlx5_add_flow_rules((struct mlx5_flow_table *)esw->fdb_table.fdb,
84-
spec, action, 0, &dest, 1);
85-
87+
spec, action, 0, dest, i);
8688
if (IS_ERR(rule))
8789
mlx5_fc_destroy(esw->dev, counter);
8890

0 commit comments

Comments
 (0)