mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-28 11:18:45 +07:00
4039504e6a
When mirroring packets to the CPU port the mirrored packets are trapped to the CPU. However, unlike other traps, it is not possible to set a policer on the associated trap group. Instead, the policer needs to be set on the SPAN agent. Moreover, the policer ID must be within a specified range: From a configurable (even) base ID to this base plus the maximum number of SPAN agents. While the immediate use case is to set the policer on a SPAN agent that mirrors to the CPU port, a policer can be set on any SPAN agent. Therefore, the operation is implemented for all SPAN agent types. Extend the SPAN agent request API to allow passing the desired policer ID that should be bound to the SPAN agent. Return an error for Spectrum-1, as it does not support policer setting on a SPAN agent. Reviewed-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: Petr Machata <petrm@mellanox.com> Signed-off-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
113 lines
3.4 KiB
C
113 lines
3.4 KiB
C
/* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */
|
|
/* Copyright (c) 2018 Mellanox Technologies. All rights reserved */
|
|
|
|
#ifndef _MLXSW_SPECTRUM_SPAN_H
|
|
#define _MLXSW_SPECTRUM_SPAN_H
|
|
|
|
#include <linux/types.h>
|
|
#include <linux/if_ether.h>
|
|
#include <linux/refcount.h>
|
|
|
|
#include "spectrum_router.h"
|
|
|
|
struct mlxsw_sp;
|
|
struct mlxsw_sp_port;
|
|
|
|
struct mlxsw_sp_span_parms {
|
|
struct mlxsw_sp_port *dest_port; /* NULL for unoffloaded SPAN. */
|
|
unsigned int ttl;
|
|
unsigned char dmac[ETH_ALEN];
|
|
unsigned char smac[ETH_ALEN];
|
|
union mlxsw_sp_l3addr daddr;
|
|
union mlxsw_sp_l3addr saddr;
|
|
u16 vid;
|
|
u16 policer_id;
|
|
bool policer_enable;
|
|
};
|
|
|
|
enum mlxsw_sp_span_trigger {
|
|
MLXSW_SP_SPAN_TRIGGER_INGRESS,
|
|
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 {
|
|
int span_id;
|
|
};
|
|
|
|
struct mlxsw_sp_span_agent_parms {
|
|
const struct net_device *to_dev;
|
|
u16 policer_id;
|
|
bool policer_enable;
|
|
};
|
|
|
|
struct mlxsw_sp_span_entry_ops;
|
|
|
|
struct mlxsw_sp_span_ops {
|
|
int (*init)(struct mlxsw_sp *mlxsw_sp);
|
|
u32 (*buffsize_get)(int mtu, u32 speed);
|
|
int (*policer_id_base_set)(struct mlxsw_sp *mlxsw_sp,
|
|
u16 policer_id_base);
|
|
};
|
|
|
|
struct mlxsw_sp_span_entry {
|
|
const struct net_device *to_dev;
|
|
const struct mlxsw_sp_span_entry_ops *ops;
|
|
struct mlxsw_sp_span_parms parms;
|
|
refcount_t ref_count;
|
|
int id;
|
|
};
|
|
|
|
struct mlxsw_sp_span_entry_ops {
|
|
bool (*can_handle)(const struct net_device *to_dev);
|
|
int (*parms_set)(struct mlxsw_sp *mlxsw_sp,
|
|
const struct net_device *to_dev,
|
|
struct mlxsw_sp_span_parms *sparmsp);
|
|
int (*configure)(struct mlxsw_sp_span_entry *span_entry,
|
|
struct mlxsw_sp_span_parms sparms);
|
|
void (*deconfigure)(struct mlxsw_sp_span_entry *span_entry);
|
|
};
|
|
|
|
int mlxsw_sp_span_init(struct mlxsw_sp *mlxsw_sp);
|
|
void mlxsw_sp_span_fini(struct mlxsw_sp *mlxsw_sp);
|
|
void mlxsw_sp_span_respin(struct mlxsw_sp *mlxsw_sp);
|
|
|
|
struct mlxsw_sp_span_entry *
|
|
mlxsw_sp_span_entry_find_by_port(struct mlxsw_sp *mlxsw_sp,
|
|
const struct net_device *to_dev);
|
|
|
|
void mlxsw_sp_span_entry_invalidate(struct mlxsw_sp *mlxsw_sp,
|
|
struct mlxsw_sp_span_entry *span_entry);
|
|
|
|
int mlxsw_sp_span_port_mtu_update(struct mlxsw_sp_port *port, u16 mtu);
|
|
void mlxsw_sp_span_speed_update_work(struct work_struct *work);
|
|
|
|
int mlxsw_sp_span_agent_get(struct mlxsw_sp *mlxsw_sp, int *p_span_id,
|
|
const struct mlxsw_sp_span_agent_parms *parms);
|
|
void mlxsw_sp_span_agent_put(struct mlxsw_sp *mlxsw_sp, int span_id);
|
|
int mlxsw_sp_span_analyzed_port_get(struct mlxsw_sp_port *mlxsw_sp_port,
|
|
bool ingress);
|
|
void mlxsw_sp_span_analyzed_port_put(struct mlxsw_sp_port *mlxsw_sp_port,
|
|
bool ingress);
|
|
int mlxsw_sp_span_agent_bind(struct mlxsw_sp *mlxsw_sp,
|
|
enum mlxsw_sp_span_trigger trigger,
|
|
struct mlxsw_sp_port *mlxsw_sp_port,
|
|
const struct mlxsw_sp_span_trigger_parms *parms);
|
|
void
|
|
mlxsw_sp_span_agent_unbind(struct mlxsw_sp *mlxsw_sp,
|
|
enum mlxsw_sp_span_trigger trigger,
|
|
struct mlxsw_sp_port *mlxsw_sp_port,
|
|
const struct mlxsw_sp_span_trigger_parms *parms);
|
|
int mlxsw_sp_span_trigger_enable(struct mlxsw_sp_port *mlxsw_sp_port,
|
|
enum mlxsw_sp_span_trigger trigger, u8 tc);
|
|
void mlxsw_sp_span_trigger_disable(struct mlxsw_sp_port *mlxsw_sp_port,
|
|
enum mlxsw_sp_span_trigger trigger, u8 tc);
|
|
|
|
extern const struct mlxsw_sp_span_ops mlxsw_sp1_span_ops;
|
|
extern const struct mlxsw_sp_span_ops mlxsw_sp2_span_ops;
|
|
extern const struct mlxsw_sp_span_ops mlxsw_sp3_span_ops;
|
|
|
|
#endif
|