2018-08-09 15:59:11 +07:00
|
|
|
/* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */
|
|
|
|
/* Copyright (c) 2018 Mellanox Technologies. All rights reserved */
|
2018-02-13 17:27:48 +07:00
|
|
|
|
|
|
|
#ifndef _MLXSW_SPECTRUM_SPAN_H
|
|
|
|
#define _MLXSW_SPECTRUM_SPAN_H
|
|
|
|
|
|
|
|
#include <linux/types.h>
|
2018-02-27 20:53:48 +07:00
|
|
|
#include <linux/if_ether.h>
|
2020-04-24 22:43:44 +07:00
|
|
|
#include <linux/refcount.h>
|
2018-02-27 20:53:48 +07:00
|
|
|
|
|
|
|
#include "spectrum_router.h"
|
2018-02-13 17:27:48 +07:00
|
|
|
|
|
|
|
struct mlxsw_sp;
|
|
|
|
struct mlxsw_sp_port;
|
|
|
|
|
2018-02-27 20:53:45 +07:00
|
|
|
struct mlxsw_sp_span_parms {
|
|
|
|
struct mlxsw_sp_port *dest_port; /* NULL for unoffloaded SPAN. */
|
2018-02-27 20:53:48 +07:00
|
|
|
unsigned int ttl;
|
|
|
|
unsigned char dmac[ETH_ALEN];
|
|
|
|
unsigned char smac[ETH_ALEN];
|
|
|
|
union mlxsw_sp_l3addr daddr;
|
|
|
|
union mlxsw_sp_l3addr saddr;
|
2018-04-29 14:56:13 +07:00
|
|
|
u16 vid;
|
2020-07-14 21:21:01 +07:00
|
|
|
u16 policer_id;
|
|
|
|
bool policer_enable;
|
2018-02-27 20:53:45 +07:00
|
|
|
};
|
|
|
|
|
2020-05-01 00:01:12 +07:00
|
|
|
enum mlxsw_sp_span_trigger {
|
|
|
|
MLXSW_SP_SPAN_TRIGGER_INGRESS,
|
|
|
|
MLXSW_SP_SPAN_TRIGGER_EGRESS,
|
2020-07-11 04:55:08 +07:00
|
|
|
MLXSW_SP_SPAN_TRIGGER_TAIL_DROP,
|
|
|
|
MLXSW_SP_SPAN_TRIGGER_EARLY_DROP,
|
|
|
|
MLXSW_SP_SPAN_TRIGGER_ECN,
|
2020-05-01 00:01:12 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct mlxsw_sp_span_trigger_parms {
|
|
|
|
int span_id;
|
|
|
|
};
|
|
|
|
|
2020-07-14 21:21:00 +07:00
|
|
|
struct mlxsw_sp_span_agent_parms {
|
|
|
|
const struct net_device *to_dev;
|
2020-07-14 21:21:01 +07:00
|
|
|
u16 policer_id;
|
|
|
|
bool policer_enable;
|
2020-07-14 21:21:00 +07:00
|
|
|
};
|
|
|
|
|
2018-02-27 20:53:45 +07:00
|
|
|
struct mlxsw_sp_span_entry_ops;
|
|
|
|
|
2020-07-11 04:55:06 +07:00
|
|
|
struct mlxsw_sp_span_ops {
|
2020-07-11 04:55:07 +07:00
|
|
|
int (*init)(struct mlxsw_sp *mlxsw_sp);
|
2020-07-11 04:55:06 +07:00
|
|
|
u32 (*buffsize_get)(int mtu, u32 speed);
|
2020-07-14 21:21:01 +07:00
|
|
|
int (*policer_id_base_set)(struct mlxsw_sp *mlxsw_sp,
|
|
|
|
u16 policer_id_base);
|
2020-07-11 04:55:06 +07:00
|
|
|
};
|
|
|
|
|
2018-02-13 17:27:48 +07:00
|
|
|
struct mlxsw_sp_span_entry {
|
2018-02-27 20:53:44 +07:00
|
|
|
const struct net_device *to_dev;
|
2018-02-27 20:53:45 +07:00
|
|
|
const struct mlxsw_sp_span_entry_ops *ops;
|
|
|
|
struct mlxsw_sp_span_parms parms;
|
2020-04-24 22:43:44 +07:00
|
|
|
refcount_t ref_count;
|
2018-02-13 17:27:48 +07:00
|
|
|
int id;
|
|
|
|
};
|
|
|
|
|
2018-02-27 20:53:45 +07:00
|
|
|
struct mlxsw_sp_span_entry_ops {
|
|
|
|
bool (*can_handle)(const struct net_device *to_dev);
|
2020-07-14 21:20:57 +07:00
|
|
|
int (*parms_set)(struct mlxsw_sp *mlxsw_sp,
|
|
|
|
const struct net_device *to_dev,
|
2020-04-24 22:43:42 +07:00
|
|
|
struct mlxsw_sp_span_parms *sparmsp);
|
2018-02-27 20:53:45 +07:00
|
|
|
int (*configure)(struct mlxsw_sp_span_entry *span_entry,
|
|
|
|
struct mlxsw_sp_span_parms sparms);
|
|
|
|
void (*deconfigure)(struct mlxsw_sp_span_entry *span_entry);
|
|
|
|
};
|
|
|
|
|
2018-02-13 17:27:48 +07:00
|
|
|
int mlxsw_sp_span_init(struct mlxsw_sp *mlxsw_sp);
|
|
|
|
void mlxsw_sp_span_fini(struct mlxsw_sp *mlxsw_sp);
|
2018-02-27 20:53:46 +07:00
|
|
|
void mlxsw_sp_span_respin(struct mlxsw_sp *mlxsw_sp);
|
2018-02-13 17:27:48 +07:00
|
|
|
|
|
|
|
struct mlxsw_sp_span_entry *
|
2018-02-27 20:53:44 +07:00
|
|
|
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);
|
2018-02-13 17:27:48 +07:00
|
|
|
|
|
|
|
int mlxsw_sp_span_port_mtu_update(struct mlxsw_sp_port *port, u16 mtu);
|
2020-01-20 14:52:53 +07:00
|
|
|
void mlxsw_sp_span_speed_update_work(struct work_struct *work);
|
2018-02-13 17:27:48 +07:00
|
|
|
|
2020-07-14 21:21:00 +07:00
|
|
|
int mlxsw_sp_span_agent_get(struct mlxsw_sp *mlxsw_sp, int *p_span_id,
|
|
|
|
const struct mlxsw_sp_span_agent_parms *parms);
|
2020-05-01 00:01:08 +07:00
|
|
|
void mlxsw_sp_span_agent_put(struct mlxsw_sp *mlxsw_sp, int span_id);
|
2020-05-01 00:01:09 +07:00
|
|
|
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);
|
2020-05-01 00:01:12 +07:00
|
|
|
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);
|
2020-07-11 04:55:09 +07:00
|
|
|
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);
|
2020-05-01 00:01:08 +07:00
|
|
|
|
2020-07-11 04:55:06 +07:00
|
|
|
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;
|
|
|
|
|
2018-02-13 17:27:48 +07:00
|
|
|
#endif
|