Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e37a79e5 authored by Mark Bloch's avatar Mark Bloch Committed by Leon Romanovsky
Browse files

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: default avatarMark Bloch <markb@mellanox.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leon@kernel.org>
parent ae058314
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -419,7 +419,8 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv, struct tcf_exts *exts,
				return -EINVAL;
				return -EINVAL;
			}
			}


			attr->action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST;
			attr->action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST |
					MLX5_FLOW_CONTEXT_ACTION_COUNT;
			out_priv = netdev_priv(out_dev);
			out_priv = netdev_priv(out_dev);
			attr->out_rep = out_priv->ppriv;
			attr->out_rep = out_priv->ppriv;
			continue;
			continue;
+11 −9
Original line number Original line Diff line number Diff line
@@ -48,11 +48,12 @@ mlx5_eswitch_add_offloaded_rule(struct mlx5_eswitch *esw,
				struct mlx5_flow_spec *spec,
				struct mlx5_flow_spec *spec,
				struct mlx5_esw_flow_attr *attr)
				struct mlx5_esw_flow_attr *attr)
{
{
	struct mlx5_flow_destination dest = { 0 };
	struct mlx5_flow_destination dest[2] = {};
	struct mlx5_fc *counter = NULL;
	struct mlx5_fc *counter = NULL;
	struct mlx5_flow_handle *rule;
	struct mlx5_flow_handle *rule;
	void *misc;
	void *misc;
	int action;
	int action;
	int i = 0;


	if (esw->mode != SRIOV_OFFLOADS)
	if (esw->mode != SRIOV_OFFLOADS)
		return ERR_PTR(-EOPNOTSUPP);
		return ERR_PTR(-EOPNOTSUPP);
@@ -60,15 +61,17 @@ mlx5_eswitch_add_offloaded_rule(struct mlx5_eswitch *esw,
	action = attr->action;
	action = attr->action;


	if (action & MLX5_FLOW_CONTEXT_ACTION_FWD_DEST) {
	if (action & MLX5_FLOW_CONTEXT_ACTION_FWD_DEST) {
		dest.type = MLX5_FLOW_DESTINATION_TYPE_VPORT;
		dest[i].type = MLX5_FLOW_DESTINATION_TYPE_VPORT;
		dest.vport_num = attr->out_rep->vport;
		dest[i].vport_num = attr->out_rep->vport;
		action = MLX5_FLOW_CONTEXT_ACTION_FWD_DEST;
		i++;
	} else if (action & MLX5_FLOW_CONTEXT_ACTION_COUNT) {
	}
	if (action & MLX5_FLOW_CONTEXT_ACTION_COUNT) {
		counter = mlx5_fc_create(esw->dev, true);
		counter = mlx5_fc_create(esw->dev, true);
		if (IS_ERR(counter))
		if (IS_ERR(counter))
			return ERR_CAST(counter);
			return ERR_CAST(counter);
		dest.type = MLX5_FLOW_DESTINATION_TYPE_COUNTER;
		dest[i].type = MLX5_FLOW_DESTINATION_TYPE_COUNTER;
		dest.counter = counter;
		dest[i].counter = counter;
		i++;
	}
	}


	misc = MLX5_ADDR_OF(fte_match_param, spec->match_value, misc_parameters);
	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,
				      MLX5_MATCH_MISC_PARAMETERS;
				      MLX5_MATCH_MISC_PARAMETERS;


	rule = mlx5_add_flow_rules((struct mlx5_flow_table *)esw->fdb_table.fdb,
	rule = mlx5_add_flow_rules((struct mlx5_flow_table *)esw->fdb_table.fdb,
				   spec, action, 0, &dest, 1);
				   spec, action, 0, dest, i);

	if (IS_ERR(rule))
	if (IS_ERR(rule))
		mlx5_fc_destroy(esw->dev, counter);
		mlx5_fc_destroy(esw->dev, counter);