2 * drivers/net/ethernet/mellanox/mlxsw/mlxsw_span.h
3 * Copyright (c) 2018 Mellanox Technologies. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the names of the copyright holders nor the names of its
14 * contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission.
17 * Alternatively, this software may be distributed under the terms of the
18 * GNU General Public License ("GPL") version 2 as published by the Free
19 * Software Foundation.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
34 #ifndef _MLXSW_SPECTRUM_SPAN_H
35 #define _MLXSW_SPECTRUM_SPAN_H
37 #include <linux/types.h>
38 #include <linux/if_ether.h>
40 #include "spectrum_router.h"
45 enum mlxsw_sp_span_type {
50 struct mlxsw_sp_span_inspected_port {
51 struct list_head list;
52 enum mlxsw_sp_span_type type;
55 /* Whether this is a directly bound mirror (port-to-port) or an ACL. */
59 struct mlxsw_sp_span_parms {
60 struct mlxsw_sp_port *dest_port; /* NULL for unoffloaded SPAN. */
62 unsigned char dmac[ETH_ALEN];
63 unsigned char smac[ETH_ALEN];
64 union mlxsw_sp_l3addr daddr;
65 union mlxsw_sp_l3addr saddr;
69 struct mlxsw_sp_span_entry_ops;
71 struct 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;
80 struct 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);
89 int mlxsw_sp_span_init(struct mlxsw_sp *mlxsw_sp);
90 void mlxsw_sp_span_fini(struct mlxsw_sp *mlxsw_sp);
91 void mlxsw_sp_span_respin(struct mlxsw_sp *mlxsw_sp);
93 int 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);
97 void mlxsw_sp_span_mirror_del(struct mlxsw_sp_port *from, int span_id,
98 enum mlxsw_sp_span_type type, bool bind);
99 struct mlxsw_sp_span_entry *
100 mlxsw_sp_span_entry_find_by_port(struct mlxsw_sp *mlxsw_sp,
101 const struct net_device *to_dev);
103 void mlxsw_sp_span_entry_invalidate(struct mlxsw_sp *mlxsw_sp,
104 struct mlxsw_sp_span_entry *span_entry);
106 int mlxsw_sp_span_port_mtu_update(struct mlxsw_sp_port *port, u16 mtu);