linux/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.h

/* 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;

/* SPAN session identifiers that correspond to MLXSW_TRAP_ID_MIRROR_SESSION<i>
 * trap identifiers. The session identifier is an attribute of the SPAN agent,
 * which determines the trap identifier of packets that are mirrored to the
 * CPU. Packets that are trapped to the CPU for the same logical reason (e.g.,
 * buffer drops) should use the same session identifier.
 */
enum mlxsw_sp_span_session_id {};

struct mlxsw_sp_span_parms {};

enum mlxsw_sp_span_trigger {};

struct mlxsw_sp_span_trigger_parms {};

struct mlxsw_sp_span_agent_parms {};

struct mlxsw_sp_span_entry_ops;

struct mlxsw_sp_span_ops {};

struct mlxsw_sp_span_entry {};

struct mlxsw_sp_span_entry_ops {};

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_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);
bool mlxsw_sp_span_trigger_is_ingress(enum mlxsw_sp_span_trigger trigger);

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