diff options
author | Ido Schimmel <idosch@nvidia.com> | 2021-03-11 15:24:14 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2021-03-12 03:22:39 +0300 |
commit | 20afb9bc480d0bfe3d1abcb934d79b2cdc19acbf (patch) | |
tree | 3321d6f8a44fa93ef740749e043a9bd03004f40a /drivers/net/ethernet/mellanox/mlxsw/spectrum_matchall.c | |
parent | 2dcbd9207b3380c0efd89b2805dfc4e867470eb9 (diff) | |
download | linux-20afb9bc480d0bfe3d1abcb934d79b2cdc19acbf.tar.xz |
mlxsw: spectrum_matchall: Split sampling support between ASICs
Sampling of ingress packets is supported using a dedicated sampling
mechanism on all Spectrum ASICs. However, Spectrum-2 and later ASICs
support more sophisticated sampling by mirroring packets to the CPU.
As a preparation for more advanced sampling configurations, split the
sampling operations between Spectrum-1 and later ASICs.
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/mellanox/mlxsw/spectrum_matchall.c')
-rw-r--r-- | drivers/net/ethernet/mellanox/mlxsw/spectrum_matchall.c | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_matchall.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_matchall.c index 2b7652b4b0bb..ad1209df81ea 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_matchall.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_matchall.c @@ -96,6 +96,7 @@ static int mlxsw_sp_mall_port_sample_add(struct mlxsw_sp_port *mlxsw_sp_port, struct mlxsw_sp_mall_entry *mall_entry) { + struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; int err; if (rtnl_dereference(mlxsw_sp_port->sample)) { @@ -104,8 +105,8 @@ mlxsw_sp_mall_port_sample_add(struct mlxsw_sp_port *mlxsw_sp_port, } rcu_assign_pointer(mlxsw_sp_port->sample, &mall_entry->sample); - err = mlxsw_sp_mall_port_sample_set(mlxsw_sp_port, true, - mall_entry->sample.rate); + err = mlxsw_sp->mall_ops->sample_add(mlxsw_sp, mlxsw_sp_port, + mall_entry->sample.rate); if (err) goto err_port_sample_set; return 0; @@ -118,10 +119,12 @@ err_port_sample_set: static void mlxsw_sp_mall_port_sample_del(struct mlxsw_sp_port *mlxsw_sp_port) { + struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; + if (!mlxsw_sp_port->sample) return; - mlxsw_sp_mall_port_sample_set(mlxsw_sp_port, false, 1); + mlxsw_sp->mall_ops->sample_del(mlxsw_sp, mlxsw_sp_port); RCU_INIT_POINTER(mlxsw_sp_port->sample, NULL); } @@ -356,3 +359,26 @@ int mlxsw_sp_mall_prio_get(struct mlxsw_sp_flow_block *block, u32 chain_index, *p_max_prio = block->mall.max_prio; return 0; } + +static int mlxsw_sp1_mall_sample_add(struct mlxsw_sp *mlxsw_sp, + struct mlxsw_sp_port *mlxsw_sp_port, + u32 rate) +{ + return mlxsw_sp_mall_port_sample_set(mlxsw_sp_port, true, rate); +} + +static void mlxsw_sp1_mall_sample_del(struct mlxsw_sp *mlxsw_sp, + struct mlxsw_sp_port *mlxsw_sp_port) +{ + mlxsw_sp_mall_port_sample_set(mlxsw_sp_port, false, 1); +} + +const struct mlxsw_sp_mall_ops mlxsw_sp1_mall_ops = { + .sample_add = mlxsw_sp1_mall_sample_add, + .sample_del = mlxsw_sp1_mall_sample_del, +}; + +const struct mlxsw_sp_mall_ops mlxsw_sp2_mall_ops = { + .sample_add = mlxsw_sp1_mall_sample_add, + .sample_del = mlxsw_sp1_mall_sample_del, +}; |