xref: /linux/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.h (revision d96fc832bcb6269d96e33d506f33033d7ed08598)
1 /*
2  * drivers/net/ethernet/mellanox/mlxsw/mlxsw_span.h
3  * Copyright (c) 2018 Mellanox Technologies. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
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.
16  *
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.
20  *
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.
32  */
33 
34 #ifndef _MLXSW_SPECTRUM_SPAN_H
35 #define _MLXSW_SPECTRUM_SPAN_H
36 
37 #include <linux/types.h>
38 
39 struct mlxsw_sp;
40 struct mlxsw_sp_port;
41 
42 enum mlxsw_sp_span_type {
43 	MLXSW_SP_SPAN_EGRESS,
44 	MLXSW_SP_SPAN_INGRESS
45 };
46 
47 struct mlxsw_sp_span_inspected_port {
48 	struct list_head list;
49 	enum mlxsw_sp_span_type type;
50 	u8 local_port;
51 };
52 
53 struct mlxsw_sp_span_entry {
54 	u8 local_port;
55 	struct list_head bound_ports_list;
56 	int ref_count;
57 	int id;
58 };
59 
60 int mlxsw_sp_span_init(struct mlxsw_sp *mlxsw_sp);
61 void mlxsw_sp_span_fini(struct mlxsw_sp *mlxsw_sp);
62 
63 int mlxsw_sp_span_mirror_add(struct mlxsw_sp_port *from,
64 			     struct mlxsw_sp_port *to,
65 			     enum mlxsw_sp_span_type type, bool bind);
66 void mlxsw_sp_span_mirror_del(struct mlxsw_sp_port *from, u8 destination_port,
67 			      enum mlxsw_sp_span_type type, bool bind);
68 struct mlxsw_sp_span_entry *
69 mlxsw_sp_span_entry_find(struct mlxsw_sp *mlxsw_sp, u8 local_port);
70 
71 int mlxsw_sp_span_port_mtu_update(struct mlxsw_sp_port *port, u16 mtu);
72 
73 #endif
74