1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34#ifndef _MLXSW_SPECTRUM_SPAN_H
35#define _MLXSW_SPECTRUM_SPAN_H
36
37#include <linux/types.h>
38#include <linux/if_ether.h>
39
40#include "spectrum_router.h"
41
42struct mlxsw_sp;
43struct mlxsw_sp_port;
44
45enum mlxsw_sp_span_type {
46 MLXSW_SP_SPAN_EGRESS,
47 MLXSW_SP_SPAN_INGRESS
48};
49
50struct mlxsw_sp_span_inspected_port {
51 struct list_head list;
52 enum mlxsw_sp_span_type type;
53 u8 local_port;
54
55
56 bool bound;
57};
58
59struct mlxsw_sp_span_parms {
60 struct mlxsw_sp_port *dest_port;
61 unsigned int ttl;
62 unsigned char dmac[ETH_ALEN];
63 unsigned char smac[ETH_ALEN];
64 union mlxsw_sp_l3addr daddr;
65 union mlxsw_sp_l3addr saddr;
66 u16 vid;
67};
68
69struct mlxsw_sp_span_entry_ops;
70
71struct mlxsw_sp_span_entry {
72 const struct net_device *to_dev;
73 const struct mlxsw_sp_span_entry_ops *ops;
74 struct mlxsw_sp_span_parms parms;
75 struct list_head bound_ports_list;
76 int ref_count;
77 int id;
78};
79
80struct mlxsw_sp_span_entry_ops {
81 bool (*can_handle)(const struct net_device *to_dev);
82 int (*parms)(const struct net_device *to_dev,
83 struct mlxsw_sp_span_parms *sparmsp);
84 int (*configure)(struct mlxsw_sp_span_entry *span_entry,
85 struct mlxsw_sp_span_parms sparms);
86 void (*deconfigure)(struct mlxsw_sp_span_entry *span_entry);
87};
88
89int mlxsw_sp_span_init(struct mlxsw_sp *mlxsw_sp);
90void mlxsw_sp_span_fini(struct mlxsw_sp *mlxsw_sp);
91void mlxsw_sp_span_respin(struct mlxsw_sp *mlxsw_sp);
92
93int mlxsw_sp_span_mirror_add(struct mlxsw_sp_port *from,
94 const struct net_device *to_dev,
95 enum mlxsw_sp_span_type type,
96 bool bind, int *p_span_id);
97void mlxsw_sp_span_mirror_del(struct mlxsw_sp_port *from, int span_id,
98 enum mlxsw_sp_span_type type, bool bind);
99struct mlxsw_sp_span_entry *
100mlxsw_sp_span_entry_find_by_port(struct mlxsw_sp *mlxsw_sp,
101 const struct net_device *to_dev);
102
103void mlxsw_sp_span_entry_invalidate(struct mlxsw_sp *mlxsw_sp,
104 struct mlxsw_sp_span_entry *span_entry);
105
106int mlxsw_sp_span_port_mtu_update(struct mlxsw_sp_port *port, u16 mtu);
107
108#endif
109