]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/blob - drivers/net/ethernet/mellanox/mlxsw/spectrum_mr.h
Merge tag 'mac80211-next-for-davem-2018-03-29' of git://git.kernel.org/pub/scm/linux...
[mirror_ubuntu-eoan-kernel.git] / drivers / net / ethernet / mellanox / mlxsw / spectrum_mr.h
1 /*
2 * drivers/net/ethernet/mellanox/mlxsw/spectrum_mr.h
3 * Copyright (c) 2017 Mellanox Technologies. All rights reserved.
4 * Copyright (c) 2017 Yotam Gigi <yotamg@mellanox.com>
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. Neither the names of the copyright holders nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * Alternatively, this software may be distributed under the terms of the
19 * GNU General Public License ("GPL") version 2 as published by the Free
20 * Software Foundation.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 */
34
35 #ifndef _MLXSW_SPECTRUM_MCROUTER_H
36 #define _MLXSW_SPECTRUM_MCROUTER_H
37
38 #include <linux/mroute.h>
39 #include <linux/mroute6.h>
40 #include "spectrum_router.h"
41 #include "spectrum.h"
42
43 enum mlxsw_sp_mr_route_action {
44 MLXSW_SP_MR_ROUTE_ACTION_FORWARD,
45 MLXSW_SP_MR_ROUTE_ACTION_TRAP,
46 MLXSW_SP_MR_ROUTE_ACTION_TRAP_AND_FORWARD,
47 };
48
49 enum mlxsw_sp_mr_route_prio {
50 MLXSW_SP_MR_ROUTE_PRIO_SG,
51 MLXSW_SP_MR_ROUTE_PRIO_STARG,
52 MLXSW_SP_MR_ROUTE_PRIO_CATCHALL,
53 __MLXSW_SP_MR_ROUTE_PRIO_MAX
54 };
55
56 #define MLXSW_SP_MR_ROUTE_PRIO_MAX (__MLXSW_SP_MR_ROUTE_PRIO_MAX - 1)
57
58 struct mlxsw_sp_mr_route_key {
59 int vrid;
60 enum mlxsw_sp_l3proto proto;
61 union mlxsw_sp_l3addr group;
62 union mlxsw_sp_l3addr group_mask;
63 union mlxsw_sp_l3addr source;
64 union mlxsw_sp_l3addr source_mask;
65 };
66
67 struct mlxsw_sp_mr_route_info {
68 enum mlxsw_sp_mr_route_action route_action;
69 u16 irif_index;
70 u16 *erif_indices;
71 size_t erif_num;
72 u16 min_mtu;
73 };
74
75 struct mlxsw_sp_mr_route_params {
76 struct mlxsw_sp_mr_route_key key;
77 struct mlxsw_sp_mr_route_info value;
78 enum mlxsw_sp_mr_route_prio prio;
79 };
80
81 struct mlxsw_sp_mr_ops {
82 int priv_size;
83 int route_priv_size;
84 int (*init)(struct mlxsw_sp *mlxsw_sp, void *priv);
85 int (*route_create)(struct mlxsw_sp *mlxsw_sp, void *priv,
86 void *route_priv,
87 struct mlxsw_sp_mr_route_params *route_params);
88 int (*route_update)(struct mlxsw_sp *mlxsw_sp, void *route_priv,
89 struct mlxsw_sp_mr_route_info *route_info);
90 int (*route_stats)(struct mlxsw_sp *mlxsw_sp, void *route_priv,
91 u64 *packets, u64 *bytes);
92 int (*route_action_update)(struct mlxsw_sp *mlxsw_sp, void *route_priv,
93 enum mlxsw_sp_mr_route_action route_action);
94 int (*route_min_mtu_update)(struct mlxsw_sp *mlxsw_sp, void *route_priv,
95 u16 min_mtu);
96 int (*route_irif_update)(struct mlxsw_sp *mlxsw_sp, void *route_priv,
97 u16 irif_index);
98 int (*route_erif_add)(struct mlxsw_sp *mlxsw_sp, void *route_priv,
99 u16 erif_index);
100 int (*route_erif_del)(struct mlxsw_sp *mlxsw_sp, void *route_priv,
101 u16 erif_index);
102 void (*route_destroy)(struct mlxsw_sp *mlxsw_sp, void *priv,
103 void *route_priv);
104 void (*fini)(void *priv);
105 };
106
107 struct mlxsw_sp_mr;
108 struct mlxsw_sp_mr_table;
109
110 int mlxsw_sp_mr_init(struct mlxsw_sp *mlxsw_sp,
111 const struct mlxsw_sp_mr_ops *mr_ops);
112 void mlxsw_sp_mr_fini(struct mlxsw_sp *mlxsw_sp);
113 int mlxsw_sp_mr_route_add(struct mlxsw_sp_mr_table *mr_table,
114 struct mr_mfc *mfc, bool replace);
115 void mlxsw_sp_mr_route_del(struct mlxsw_sp_mr_table *mr_table,
116 struct mr_mfc *mfc);
117 int mlxsw_sp_mr_vif_add(struct mlxsw_sp_mr_table *mr_table,
118 struct net_device *dev, vifi_t vif_index,
119 unsigned long vif_flags,
120 const struct mlxsw_sp_rif *rif);
121 void mlxsw_sp_mr_vif_del(struct mlxsw_sp_mr_table *mr_table, vifi_t vif_index);
122 int mlxsw_sp_mr_rif_add(struct mlxsw_sp_mr_table *mr_table,
123 const struct mlxsw_sp_rif *rif);
124 void mlxsw_sp_mr_rif_del(struct mlxsw_sp_mr_table *mr_table,
125 const struct mlxsw_sp_rif *rif);
126 void mlxsw_sp_mr_rif_mtu_update(struct mlxsw_sp_mr_table *mr_table,
127 const struct mlxsw_sp_rif *rif, int mtu);
128 struct mlxsw_sp_mr_table *mlxsw_sp_mr_table_create(struct mlxsw_sp *mlxsw_sp,
129 u32 tb_id,
130 enum mlxsw_sp_l3proto proto);
131 void mlxsw_sp_mr_table_destroy(struct mlxsw_sp_mr_table *mr_table);
132 void mlxsw_sp_mr_table_flush(struct mlxsw_sp_mr_table *mr_table);
133 bool mlxsw_sp_mr_table_empty(const struct mlxsw_sp_mr_table *mr_table);
134
135 #endif