Commit ab8c06b7 authored by Ido Schimmel's avatar Ido Schimmel Committed by David S. Miller

mlxsw: spectrum_span: Add support for global mirroring triggers

Global mirroring triggers are triggers that are only keyed by their
trigger, as opposed to per-port triggers, which are keyed by their
trigger and port.

Such triggers allow mirroring packets that were tail/early dropped or
ECN marked to a SPAN agent.

Implement the previously added trigger operations for these global
triggers. Since such triggers are only supported from Spectrum-2
onwards, have the Spectrum-1 operations return an error.
Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
Reviewed-by: default avatarPetr Machata <petrm@mellanox.com>
Reviewed-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarPetr Machata <petrm@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 08a3641f
...@@ -49,6 +49,7 @@ struct mlxsw_sp_span_trigger_entry { ...@@ -49,6 +49,7 @@ struct mlxsw_sp_span_trigger_entry {
enum mlxsw_sp_span_trigger_type { enum mlxsw_sp_span_trigger_type {
MLXSW_SP_SPAN_TRIGGER_TYPE_PORT, MLXSW_SP_SPAN_TRIGGER_TYPE_PORT,
MLXSW_SP_SPAN_TRIGGER_TYPE_GLOBAL,
}; };
struct mlxsw_sp_span_trigger_ops { struct mlxsw_sp_span_trigger_ops {
...@@ -1140,9 +1141,101 @@ mlxsw_sp_span_trigger_port_ops = { ...@@ -1140,9 +1141,101 @@ mlxsw_sp_span_trigger_port_ops = {
.matches = mlxsw_sp_span_trigger_port_matches, .matches = mlxsw_sp_span_trigger_port_matches,
}; };
static int
mlxsw_sp1_span_trigger_global_bind(struct mlxsw_sp_span_trigger_entry *
trigger_entry)
{
return -EOPNOTSUPP;
}
static void
mlxsw_sp1_span_trigger_global_unbind(struct mlxsw_sp_span_trigger_entry *
trigger_entry)
{
}
static bool
mlxsw_sp1_span_trigger_global_matches(struct mlxsw_sp_span_trigger_entry *
trigger_entry,
enum mlxsw_sp_span_trigger trigger,
struct mlxsw_sp_port *mlxsw_sp_port)
{
WARN_ON_ONCE(1);
return false;
}
static const struct mlxsw_sp_span_trigger_ops
mlxsw_sp1_span_trigger_global_ops = {
.bind = mlxsw_sp1_span_trigger_global_bind,
.unbind = mlxsw_sp1_span_trigger_global_unbind,
.matches = mlxsw_sp1_span_trigger_global_matches,
};
static const struct mlxsw_sp_span_trigger_ops *
mlxsw_sp1_span_trigger_ops_arr[] = {
[MLXSW_SP_SPAN_TRIGGER_TYPE_PORT] = &mlxsw_sp_span_trigger_port_ops,
[MLXSW_SP_SPAN_TRIGGER_TYPE_GLOBAL] =
&mlxsw_sp1_span_trigger_global_ops,
};
static int
mlxsw_sp2_span_trigger_global_bind(struct mlxsw_sp_span_trigger_entry *
trigger_entry)
{
struct mlxsw_sp *mlxsw_sp = trigger_entry->span->mlxsw_sp;
enum mlxsw_reg_mpagr_trigger trigger;
char mpagr_pl[MLXSW_REG_MPAGR_LEN];
switch (trigger_entry->trigger) {
case MLXSW_SP_SPAN_TRIGGER_TAIL_DROP:
trigger = MLXSW_REG_MPAGR_TRIGGER_INGRESS_SHARED_BUFFER;
break;
case MLXSW_SP_SPAN_TRIGGER_EARLY_DROP:
trigger = MLXSW_REG_MPAGR_TRIGGER_INGRESS_WRED;
break;
case MLXSW_SP_SPAN_TRIGGER_ECN:
trigger = MLXSW_REG_MPAGR_TRIGGER_EGRESS_ECN;
break;
default:
WARN_ON_ONCE(1);
return -EINVAL;
}
mlxsw_reg_mpagr_pack(mpagr_pl, trigger, trigger_entry->parms.span_id,
1);
return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(mpagr), mpagr_pl);
}
static void
mlxsw_sp2_span_trigger_global_unbind(struct mlxsw_sp_span_trigger_entry *
trigger_entry)
{
/* There is no unbinding for global triggers. The trigger should be
* disabled on all ports by now.
*/
}
static bool
mlxsw_sp2_span_trigger_global_matches(struct mlxsw_sp_span_trigger_entry *
trigger_entry,
enum mlxsw_sp_span_trigger trigger,
struct mlxsw_sp_port *mlxsw_sp_port)
{
return trigger_entry->trigger == trigger;
}
static const struct mlxsw_sp_span_trigger_ops
mlxsw_sp2_span_trigger_global_ops = {
.bind = mlxsw_sp2_span_trigger_global_bind,
.unbind = mlxsw_sp2_span_trigger_global_unbind,
.matches = mlxsw_sp2_span_trigger_global_matches,
};
static const struct mlxsw_sp_span_trigger_ops * static const struct mlxsw_sp_span_trigger_ops *
mlxsw_sp_span_trigger_ops_arr[] = { mlxsw_sp2_span_trigger_ops_arr[] = {
[MLXSW_SP_SPAN_TRIGGER_TYPE_PORT] = &mlxsw_sp_span_trigger_port_ops, [MLXSW_SP_SPAN_TRIGGER_TYPE_PORT] = &mlxsw_sp_span_trigger_port_ops,
[MLXSW_SP_SPAN_TRIGGER_TYPE_GLOBAL] =
&mlxsw_sp2_span_trigger_global_ops,
}; };
static void static void
...@@ -1156,6 +1249,11 @@ mlxsw_sp_span_trigger_ops_set(struct mlxsw_sp_span_trigger_entry *trigger_entry) ...@@ -1156,6 +1249,11 @@ mlxsw_sp_span_trigger_ops_set(struct mlxsw_sp_span_trigger_entry *trigger_entry)
case MLXSW_SP_SPAN_TRIGGER_EGRESS: case MLXSW_SP_SPAN_TRIGGER_EGRESS:
type = MLXSW_SP_SPAN_TRIGGER_TYPE_PORT; type = MLXSW_SP_SPAN_TRIGGER_TYPE_PORT;
break; break;
case MLXSW_SP_SPAN_TRIGGER_TAIL_DROP: /* fall-through */
case MLXSW_SP_SPAN_TRIGGER_EARLY_DROP: /* fall-through */
case MLXSW_SP_SPAN_TRIGGER_ECN:
type = MLXSW_SP_SPAN_TRIGGER_TYPE_GLOBAL;
break;
default: default:
WARN_ON_ONCE(1); WARN_ON_ONCE(1);
return; return;
...@@ -1286,7 +1384,7 @@ void mlxsw_sp_span_agent_unbind(struct mlxsw_sp *mlxsw_sp, ...@@ -1286,7 +1384,7 @@ void mlxsw_sp_span_agent_unbind(struct mlxsw_sp *mlxsw_sp,
static int mlxsw_sp1_span_init(struct mlxsw_sp *mlxsw_sp) static int mlxsw_sp1_span_init(struct mlxsw_sp *mlxsw_sp)
{ {
mlxsw_sp->span->span_trigger_ops_arr = mlxsw_sp_span_trigger_ops_arr; mlxsw_sp->span->span_trigger_ops_arr = mlxsw_sp1_span_trigger_ops_arr;
return 0; return 0;
} }
...@@ -1303,7 +1401,7 @@ const struct mlxsw_sp_span_ops mlxsw_sp1_span_ops = { ...@@ -1303,7 +1401,7 @@ const struct mlxsw_sp_span_ops mlxsw_sp1_span_ops = {
static int mlxsw_sp2_span_init(struct mlxsw_sp *mlxsw_sp) static int mlxsw_sp2_span_init(struct mlxsw_sp *mlxsw_sp)
{ {
mlxsw_sp->span->span_trigger_ops_arr = mlxsw_sp_span_trigger_ops_arr; mlxsw_sp->span->span_trigger_ops_arr = mlxsw_sp2_span_trigger_ops_arr;
return 0; return 0;
} }
......
...@@ -26,6 +26,9 @@ struct mlxsw_sp_span_parms { ...@@ -26,6 +26,9 @@ struct mlxsw_sp_span_parms {
enum mlxsw_sp_span_trigger { enum mlxsw_sp_span_trigger {
MLXSW_SP_SPAN_TRIGGER_INGRESS, MLXSW_SP_SPAN_TRIGGER_INGRESS,
MLXSW_SP_SPAN_TRIGGER_EGRESS, MLXSW_SP_SPAN_TRIGGER_EGRESS,
MLXSW_SP_SPAN_TRIGGER_TAIL_DROP,
MLXSW_SP_SPAN_TRIGGER_EARLY_DROP,
MLXSW_SP_SPAN_TRIGGER_ECN,
}; };
struct mlxsw_sp_span_trigger_parms { struct mlxsw_sp_span_trigger_parms {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment