mirror of https://gitee.com/openkylin/linux.git
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>
This commit is contained in:
parent
e1f78ecdfd
commit
48990bef1e
|
@ -2212,29 +2212,6 @@ void mlxsw_sp_ptp_receive(struct mlxsw_sp *mlxsw_sp, struct sk_buff *skb,
|
|||
mlxsw_sp->ptp_ops->receive(mlxsw_sp, skb, local_port);
|
||||
}
|
||||
|
||||
void mlxsw_sp_sample_receive(struct mlxsw_sp *mlxsw_sp, struct sk_buff *skb,
|
||||
u8 local_port)
|
||||
{
|
||||
struct mlxsw_sp_port *mlxsw_sp_port = mlxsw_sp->ports[local_port];
|
||||
struct mlxsw_sp_port_sample *sample;
|
||||
struct psample_metadata md = {};
|
||||
|
||||
if (unlikely(!mlxsw_sp_port)) {
|
||||
dev_warn_ratelimited(mlxsw_sp->bus_info->dev, "Port %d: sample skb received for non-existent port\n",
|
||||
local_port);
|
||||
goto out;
|
||||
}
|
||||
|
||||
sample = rcu_dereference(mlxsw_sp_port->sample);
|
||||
if (!sample)
|
||||
goto out;
|
||||
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_RXL_NO_MARK(_trap_id, _action, _trap_group, _is_ctrl) \
|
||||
MLXSW_RXL(mlxsw_sp_rx_listener_no_mark_func, _trap_id, _action, \
|
||||
_is_ctrl, SP_##_trap_group, DISCARD)
|
||||
|
|
|
@ -570,8 +570,6 @@ void mlxsw_sp_rx_listener_no_mark_func(struct sk_buff *skb,
|
|||
u8 local_port, void *priv);
|
||||
void mlxsw_sp_ptp_receive(struct mlxsw_sp *mlxsw_sp, struct sk_buff *skb,
|
||||
u8 local_port);
|
||||
void mlxsw_sp_sample_receive(struct mlxsw_sp *mlxsw_sp, struct sk_buff *skb,
|
||||
u8 local_port);
|
||||
int mlxsw_sp_port_speed_get(struct mlxsw_sp_port *mlxsw_sp_port, u32 *speed);
|
||||
int mlxsw_sp_port_ets_set(struct mlxsw_sp_port *mlxsw_sp_port,
|
||||
enum mlxsw_reg_qeec_hr hr, u8 index, u8 next_index,
|
||||
|
|
|
@ -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) \
|
||||
|
|
Loading…
Reference in New Issue