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

Commit 98977089 authored by Petr Machata's avatar Petr Machata Committed by David S. Miller
Browse files

mlxsw: span: Remove span_entry by span_id



Instead of removing span_entry by the port number, allow removing by
SPAN id. That simplifies some code right here, and for mirroring to soft
netdevices, avoids problems with netdevice pointer invalidation and
reuse.

Rename mlxsw_sp_span_entry_find() to mlxsw_sp_span_entry_find_by_port()
and keep it--follow-up patches will make use of it.

Signed-off-by: default avatarPetr Machata <petrm@mellanox.com>
Reviewed-by: default avatarIdo Schimmel <idosch@mellanox.com>
Signed-off-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 1da93eb4
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
/*
 * drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c
 * Copyright (c) 2017 Mellanox Technologies. All rights reserved.
 * Copyright (c) 2017, 2018 Mellanox Technologies. All rights reserved.
 * Copyright (c) 2017 Jiri Pirko <jiri@mellanox.com>
 *
 * Redistribution and use in source and binary forms, with or without
@@ -838,7 +838,6 @@ struct mlxsw_afa_mirror {
	struct mlxsw_afa_resource resource;
	int span_id;
	u8 local_in_port;
	u8 local_out_port;
	bool ingress;
};

@@ -848,7 +847,7 @@ mlxsw_afa_mirror_destroy(struct mlxsw_afa_block *block,
{
	block->afa->ops->mirror_del(block->afa->ops_priv,
				    mirror->local_in_port,
				    mirror->local_out_port,
				    mirror->span_id,
				    mirror->ingress);
	kfree(mirror);
}
@@ -882,7 +881,6 @@ mlxsw_afa_mirror_create(struct mlxsw_afa_block *block,
		goto err_mirror_add;

	mirror->ingress = ingress;
	mirror->local_out_port = local_out_port;
	mirror->local_in_port = local_in_port;
	mirror->resource.destructor = mlxsw_afa_mirror_destructor;
	mlxsw_afa_resource_add(block, &mirror->resource);
+1 −1
Original line number Diff line number Diff line
@@ -50,7 +50,7 @@ struct mlxsw_afa_ops {
	void (*counter_index_put)(void *priv, unsigned int counter_index);
	int (*mirror_add)(void *priv, u8 locol_in_port, u8 local_out_port,
			  bool ingress, int *p_span_id);
	void (*mirror_del)(void *priv, u8 locol_in_port, u8 local_out_port,
	void (*mirror_del)(void *priv, u8 local_in_port, int span_id,
			   bool ingress);
};

+2 −3
Original line number Diff line number Diff line
@@ -1273,11 +1273,10 @@ mlxsw_sp_port_add_cls_matchall_mirror(struct mlxsw_sp_port *mlxsw_sp_port,
	}
	to_port = netdev_priv(to_dev);

	mirror->to_local_port = to_port->local_port;
	mirror->ingress = ingress;
	span_type = ingress ? MLXSW_SP_SPAN_INGRESS : MLXSW_SP_SPAN_EGRESS;
	return mlxsw_sp_span_mirror_add(mlxsw_sp_port, to_port, span_type,
					true);
					true, &mirror->span_id);
}

static void
@@ -1288,7 +1287,7 @@ mlxsw_sp_port_del_cls_matchall_mirror(struct mlxsw_sp_port *mlxsw_sp_port,

	span_type = mirror->ingress ?
			MLXSW_SP_SPAN_INGRESS : MLXSW_SP_SPAN_EGRESS;
	mlxsw_sp_span_mirror_del(mlxsw_sp_port, mirror->to_local_port,
	mlxsw_sp_span_mirror_del(mlxsw_sp_port, mirror->span_id,
				 span_type, true);
}

+1 −1
Original line number Diff line number Diff line
@@ -124,7 +124,7 @@ enum mlxsw_sp_port_mall_action_type {
};

struct mlxsw_sp_port_mall_mirror_tc_entry {
	u8 to_local_port;
	int span_id;
	bool ingress;
};

+5 −22
Original line number Diff line number Diff line
/*
 * drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_flex_actions.c
 * Copyright (c) 2017 Mellanox Technologies. All rights reserved.
 * Copyright (c) 2017, 2018 Mellanox Technologies. All rights reserved.
 * Copyright (c) 2017 Jiri Pirko <jiri@mellanox.com>
 * Copyright (c) 2017 Yotam Gigi <yotamg@mellanox.com>
 *
@@ -130,36 +130,19 @@ mlxsw_sp_act_mirror_add(void *priv, u8 local_in_port, u8 local_out_port,
			bool ingress, int *p_span_id)
{
	struct mlxsw_sp_port *in_port, *out_port;
	struct mlxsw_sp_span_entry *span_entry;
	struct mlxsw_sp *mlxsw_sp = priv;
	enum mlxsw_sp_span_type type;
	int err;

	type = ingress ? MLXSW_SP_SPAN_INGRESS : MLXSW_SP_SPAN_EGRESS;
	out_port = mlxsw_sp->ports[local_out_port];
	in_port = mlxsw_sp->ports[local_in_port];

	err = mlxsw_sp_span_mirror_add(in_port, out_port, type, false);
	if (err)
		return err;

	span_entry = mlxsw_sp_span_entry_find(mlxsw_sp, local_out_port);
	if (!span_entry) {
		err = -ENOENT;
		goto err_span_entry_find;
	}

	*p_span_id = span_entry->id;
	return 0;

err_span_entry_find:
	mlxsw_sp_span_mirror_del(in_port, local_out_port, type, false);
	return err;
	return mlxsw_sp_span_mirror_add(in_port, out_port, type,
					false, p_span_id);
}

static void
mlxsw_sp_act_mirror_del(void *priv, u8 local_in_port, u8 local_out_port,
			bool ingress)
mlxsw_sp_act_mirror_del(void *priv, u8 local_in_port, int span_id, bool ingress)
{
	struct mlxsw_sp *mlxsw_sp = priv;
	struct mlxsw_sp_port *in_port;
@@ -168,7 +151,7 @@ mlxsw_sp_act_mirror_del(void *priv, u8 local_in_port, u8 local_out_port,
	type = ingress ? MLXSW_SP_SPAN_INGRESS : MLXSW_SP_SPAN_EGRESS;
	in_port = mlxsw_sp->ports[local_in_port];

	mlxsw_sp_span_mirror_del(in_port, local_out_port, type, false);
	mlxsw_sp_span_mirror_del(in_port, span_id, type, false);
}

static const struct mlxsw_afa_ops mlxsw_sp_act_afa_ops = {
Loading