Skip to content

Commit 38ebc0f

Browse files
pmachatadavem330
authored andcommitted
mlxsw: spectrum_router: Add mlxsw_sp_ipip_ops
Details of individual tunnel types are kept in an array of mlxsw_sp_ipip_ops objects. Follow-up patches will use the list to determine whether a constructed RIF should be a loopback, and to decide whether a next hop references a tunnel. The list is currently empty, follow-up patches will add support for GRE. Signed-off-by: Petr Machata <[email protected]> Reviewed-by: Ido Schimmel <[email protected]> Signed-off-by: Jiri Pirko <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent ff1f06c commit 38ebc0f

File tree

4 files changed

+110
-2
lines changed

4 files changed

+110
-2
lines changed

drivers/net/ethernet/mellanox/mlxsw/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ mlxsw_spectrum-objs := spectrum.o spectrum_buffers.o \
1616
spectrum_switchdev.o spectrum_router.o \
1717
spectrum_kvdl.o spectrum_acl_tcam.o \
1818
spectrum_acl.o spectrum_flower.o \
19-
spectrum_cnt.o \
20-
spectrum_fid.o
19+
spectrum_cnt.o spectrum_fid.o \
20+
spectrum_ipip.o
2121
mlxsw_spectrum-$(CONFIG_MLXSW_SPECTRUM_DCB) += spectrum_dcb.o
2222
mlxsw_spectrum-$(CONFIG_NET_DEVLINK) += spectrum_dpipe.o
2323
obj-$(CONFIG_MLXSW_MINIMAL) += mlxsw_minimal.o
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* drivers/net/ethernet/mellanox/mlxsw/spectrum_ipip.c
3+
* Copyright (c) 2017 Mellanox Technologies. All rights reserved.
4+
* Copyright (c) 2017 Petr Machata <[email protected]>
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+
#include "spectrum_ipip.h"
36+
37+
const struct mlxsw_sp_ipip_ops *mlxsw_sp_ipip_ops_arr[] = {
38+
};
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* drivers/net/ethernet/mellanox/mlxsw/spectrum_ipip.h
3+
* Copyright (c) 2017 Mellanox Technologies. All rights reserved.
4+
* Copyright (c) 2017 Petr Machata <[email protected]>
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_IPIP_H_
36+
#define _MLXSW_IPIP_H_
37+
38+
#include "spectrum_router.h"
39+
40+
enum mlxsw_sp_ipip_type {
41+
MLXSW_SP_IPIP_TYPE_MAX,
42+
};
43+
44+
struct mlxsw_sp_ipip_ops {
45+
int dev_type;
46+
enum mlxsw_sp_l3proto ul_proto; /* Underlay. */
47+
};
48+
49+
extern const struct mlxsw_sp_ipip_ops *mlxsw_sp_ipip_ops_arr[];
50+
51+
#endif /* _MLXSW_IPIP_H_*/

drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
#include "reg.h"
6363
#include "spectrum_cnt.h"
6464
#include "spectrum_dpipe.h"
65+
#include "spectrum_ipip.h"
6566
#include "spectrum_router.h"
6667

6768
struct mlxsw_sp_vr;
@@ -89,6 +90,7 @@ struct mlxsw_sp_router {
8990
bool aborted;
9091
struct notifier_block fib_nb;
9192
const struct mlxsw_sp_rif_ops **rif_ops_arr;
93+
const struct mlxsw_sp_ipip_ops **ipip_ops_arr;
9294
};
9395

9496
struct mlxsw_sp_rif {
@@ -5152,6 +5154,16 @@ static void mlxsw_sp_rifs_fini(struct mlxsw_sp *mlxsw_sp)
51525154
kfree(mlxsw_sp->router->rifs);
51535155
}
51545156

5157+
static int mlxsw_sp_ipips_init(struct mlxsw_sp *mlxsw_sp)
5158+
{
5159+
mlxsw_sp->router->ipip_ops_arr = mlxsw_sp_ipip_ops_arr;
5160+
return 0;
5161+
}
5162+
5163+
static void mlxsw_sp_ipips_fini(struct mlxsw_sp *mlxsw_sp)
5164+
{
5165+
}
5166+
51555167
static void mlxsw_sp_router_fib_dump_flush(struct notifier_block *nb)
51565168
{
51575169
struct mlxsw_sp_router *router;
@@ -5211,6 +5223,10 @@ int mlxsw_sp_router_init(struct mlxsw_sp *mlxsw_sp)
52115223
if (err)
52125224
goto err_rifs_init;
52135225

5226+
err = mlxsw_sp_ipips_init(mlxsw_sp);
5227+
if (err)
5228+
goto err_ipips_init;
5229+
52145230
err = rhashtable_init(&mlxsw_sp->router->nexthop_ht,
52155231
&mlxsw_sp_nexthop_ht_params);
52165232
if (err)
@@ -5252,6 +5268,8 @@ int mlxsw_sp_router_init(struct mlxsw_sp *mlxsw_sp)
52525268
err_nexthop_group_ht_init:
52535269
rhashtable_destroy(&mlxsw_sp->router->nexthop_ht);
52545270
err_nexthop_ht_init:
5271+
mlxsw_sp_ipips_fini(mlxsw_sp);
5272+
err_ipips_init:
52555273
mlxsw_sp_rifs_fini(mlxsw_sp);
52565274
err_rifs_init:
52575275
__mlxsw_sp_router_fini(mlxsw_sp);
@@ -5268,6 +5286,7 @@ void mlxsw_sp_router_fini(struct mlxsw_sp *mlxsw_sp)
52685286
mlxsw_sp_lpm_fini(mlxsw_sp);
52695287
rhashtable_destroy(&mlxsw_sp->router->nexthop_group_ht);
52705288
rhashtable_destroy(&mlxsw_sp->router->nexthop_ht);
5289+
mlxsw_sp_ipips_fini(mlxsw_sp);
52715290
mlxsw_sp_rifs_fini(mlxsw_sp);
52725291
__mlxsw_sp_router_fini(mlxsw_sp);
52735292
kfree(mlxsw_sp->router);

0 commit comments

Comments
 (0)