aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/drivers/net/ethernet/mellanox/mlxsw/spectrum_trap.c
diff options
context:
space:
mode:
authorIdo Schimmel <idosch@nvidia.com>2021-03-14 14:19:38 +0200
committerDavid S. Miller <davem@davemloft.net>2021-03-14 15:00:44 -0700
commit48990bef1e6880613b142cea4f3962dd51458bd6 (patch)
treef00ae7f7893c8455e8b36ff8a197ce02ecb95e27 /drivers/net/ethernet/mellanox/mlxsw/spectrum_trap.c
parentmlxsw: spectrum: Remove unnecessary RCU read-side critical section (diff)
downloadwireguard-linux-48990bef1e6880613b142cea4f3962dd51458bd6.tar.xz
wireguard-linux-48990bef1e6880613b142cea4f3962dd51458bd6.zip
mlxsw: spectrum: Remove mlxsw_sp_sample_receive()
The function resolves the psample sampling group from the Rx port because this is the only form of sampling the driver currently supports. Subsequent patches are going to add support for Tx-based and policy-based sampling, in which case the sampling group would not be resolved from the Rx port. Therefore, move this code to the Rx-specific sampling listener. 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_trap.c')
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/spectrum_trap.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_trap.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_trap.c
index 5d4ae4886f76..ea01047f8f8f 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_trap.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_trap.c
@@ -208,17 +208,32 @@ static void mlxsw_sp_rx_sample_listener(struct sk_buff *skb, u8 local_port,
void *trap_ctx)
{
struct mlxsw_sp *mlxsw_sp = devlink_trap_ctx_priv(trap_ctx);
+ struct mlxsw_sp_port *mlxsw_sp_port;
+ struct mlxsw_sp_port_sample *sample;
+ struct psample_metadata md = {};
int err;
err = __mlxsw_sp_rx_no_mark_listener(skb, local_port, trap_ctx);
if (err)
return;
- /* The sample handler expects skb->data to point to the start of the
+ mlxsw_sp_port = mlxsw_sp->ports[local_port];
+ if (!mlxsw_sp_port)
+ goto out;
+
+ sample = rcu_dereference(mlxsw_sp_port->sample);
+ if (!sample)
+ goto out;
+
+ /* The psample module expects skb->data to point to the start of the
* Ethernet header.
*/
skb_push(skb, ETH_HLEN);
- mlxsw_sp_sample_receive(mlxsw_sp, skb, local_port);
+ md.trunc_size = sample->truncate ? sample->trunc_size : skb->len;
+ md.in_ifindex = mlxsw_sp_port->dev->ifindex;
+ psample_sample_packet(sample->psample_group, skb, sample->rate, &md);
+out:
+ consume_skb(skb);
}
#define MLXSW_SP_TRAP_DROP(_id, _group_id) \