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
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
43enum 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
49enum 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
58struct 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
67struct 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
75struct 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
81struct 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
107struct mlxsw_sp_mr;
108struct mlxsw_sp_mr_table;
109
110int mlxsw_sp_mr_init(struct mlxsw_sp *mlxsw_sp,
111 const struct mlxsw_sp_mr_ops *mr_ops);
112void mlxsw_sp_mr_fini(struct mlxsw_sp *mlxsw_sp);
113int mlxsw_sp_mr_route_add(struct mlxsw_sp_mr_table *mr_table,
114 struct mr_mfc *mfc, bool replace);
115void mlxsw_sp_mr_route_del(struct mlxsw_sp_mr_table *mr_table,
116 struct mr_mfc *mfc);
117int 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);
121void mlxsw_sp_mr_vif_del(struct mlxsw_sp_mr_table *mr_table, vifi_t vif_index);
122int mlxsw_sp_mr_rif_add(struct mlxsw_sp_mr_table *mr_table,
123 const struct mlxsw_sp_rif *rif);
124void mlxsw_sp_mr_rif_del(struct mlxsw_sp_mr_table *mr_table,
125 const struct mlxsw_sp_rif *rif);
126void mlxsw_sp_mr_rif_mtu_update(struct mlxsw_sp_mr_table *mr_table,
127 const struct mlxsw_sp_rif *rif, int mtu);
128struct mlxsw_sp_mr_table *mlxsw_sp_mr_table_create(struct mlxsw_sp *mlxsw_sp,
129 u32 tb_id,
130 enum mlxsw_sp_l3proto proto);
131void mlxsw_sp_mr_table_destroy(struct mlxsw_sp_mr_table *mr_table);
132void mlxsw_sp_mr_table_flush(struct mlxsw_sp_mr_table *mr_table);
133bool mlxsw_sp_mr_table_empty(const struct mlxsw_sp_mr_table *mr_table);
134
135#endif
136