]>
Commit | Line | Data |
---|---|---|
56ade8fe JP |
1 | /* |
2 | * drivers/net/ethernet/mellanox/mlxsw/spectrum.h | |
22a67766 JP |
3 | * Copyright (c) 2015-2017 Mellanox Technologies. All rights reserved. |
4 | * Copyright (c) 2015-2017 Jiri Pirko <jiri@mellanox.com> | |
56ade8fe JP |
5 | * Copyright (c) 2015 Ido Schimmel <idosch@mellanox.com> |
6 | * Copyright (c) 2015 Elad Raz <eladr@mellanox.com> | |
7 | * | |
8 | * Redistribution and use in source and binary forms, with or without | |
9 | * modification, are permitted provided that the following conditions are met: | |
10 | * | |
11 | * 1. Redistributions of source code must retain the above copyright | |
12 | * notice, this list of conditions and the following disclaimer. | |
13 | * 2. Redistributions in binary form must reproduce the above copyright | |
14 | * notice, this list of conditions and the following disclaimer in the | |
15 | * documentation and/or other materials provided with the distribution. | |
16 | * 3. Neither the names of the copyright holders nor the names of its | |
17 | * contributors may be used to endorse or promote products derived from | |
18 | * this software without specific prior written permission. | |
19 | * | |
20 | * Alternatively, this software may be distributed under the terms of the | |
21 | * GNU General Public License ("GPL") version 2 as published by the Free | |
22 | * Software Foundation. | |
23 | * | |
24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
27 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | |
28 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
29 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
30 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
31 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
32 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
34 | * POSSIBILITY OF SUCH DAMAGE. | |
35 | */ | |
36 | ||
37 | #ifndef _MLXSW_SPECTRUM_H | |
38 | #define _MLXSW_SPECTRUM_H | |
39 | ||
40 | #include <linux/types.h> | |
41 | #include <linux/netdevice.h> | |
6cf3c971 | 42 | #include <linux/rhashtable.h> |
56ade8fe JP |
43 | #include <linux/bitops.h> |
44 | #include <linux/if_vlan.h> | |
7f71eb46 | 45 | #include <linux/list.h> |
8e8dfe9f | 46 | #include <linux/dcbnl.h> |
5e9c16cc | 47 | #include <linux/in6.h> |
b45f64d1 | 48 | #include <linux/notifier.h> |
98d0f7b9 | 49 | #include <net/psample.h> |
7aa0f5aa | 50 | #include <net/pkt_cls.h> |
861fb829 | 51 | #include <net/red.h> |
56ade8fe | 52 | |
3a49b4fd | 53 | #include "port.h" |
56ade8fe | 54 | #include "core.h" |
22a67766 JP |
55 | #include "core_acl_flex_keys.h" |
56 | #include "core_acl_flex_actions.h" | |
56ade8fe | 57 | |
a1107487 | 58 | #define MLXSW_SP_FID_8021D_MAX 1024 |
7f71eb46 | 59 | |
53ae6283 ER |
60 | #define MLXSW_SP_MID_MAX 7000 |
61 | ||
18f1e70c IS |
62 | #define MLXSW_SP_PORTS_PER_CLUSTER_MAX 4 |
63 | ||
64 | #define MLXSW_SP_PORT_BASE_SPEED 25000 /* Mb/s */ | |
65 | ||
f11fbaf8 | 66 | #define MLXSW_SP_KVD_LINEAR_SIZE 98304 /* entries */ |
403547d3 | 67 | #define MLXSW_SP_KVD_GRANULARITY 128 |
c6022427 | 68 | |
56ade8fe | 69 | struct mlxsw_sp_port; |
4724ba56 | 70 | struct mlxsw_sp_rif; |
56ade8fe | 71 | |
0d65fc13 JP |
72 | struct mlxsw_sp_upper { |
73 | struct net_device *dev; | |
74 | unsigned int ref_count; | |
75 | }; | |
76 | ||
a1107487 IS |
77 | enum mlxsw_sp_rif_type { |
78 | MLXSW_SP_RIF_TYPE_SUBPORT, | |
79 | MLXSW_SP_RIF_TYPE_VLAN, | |
80 | MLXSW_SP_RIF_TYPE_FID, | |
6ddb7426 | 81 | MLXSW_SP_RIF_TYPE_IPIP_LB, /* IP-in-IP loopback. */ |
a1107487 IS |
82 | MLXSW_SP_RIF_TYPE_MAX, |
83 | }; | |
84 | ||
85 | enum mlxsw_sp_fid_type { | |
86 | MLXSW_SP_FID_TYPE_8021Q, | |
87 | MLXSW_SP_FID_TYPE_8021D, | |
88 | MLXSW_SP_FID_TYPE_RFID, | |
89 | MLXSW_SP_FID_TYPE_DUMMY, | |
90 | MLXSW_SP_FID_TYPE_MAX, | |
7f71eb46 IS |
91 | }; |
92 | ||
3a49b4fd ER |
93 | struct mlxsw_sp_mid { |
94 | struct list_head list; | |
95 | unsigned char addr[ETH_ALEN]; | |
46d0847c | 96 | u16 fid; |
3a49b4fd | 97 | u16 mid; |
73b433e8 | 98 | bool in_hw; |
4cdc35e4 | 99 | unsigned long *ports_in_mid; /* bits array */ |
3a49b4fd ER |
100 | }; |
101 | ||
763b4b70 YG |
102 | enum mlxsw_sp_span_type { |
103 | MLXSW_SP_SPAN_EGRESS, | |
104 | MLXSW_SP_SPAN_INGRESS | |
105 | }; | |
106 | ||
107 | struct mlxsw_sp_span_inspected_port { | |
108 | struct list_head list; | |
109 | enum mlxsw_sp_span_type type; | |
110 | u8 local_port; | |
111 | }; | |
112 | ||
113 | struct mlxsw_sp_span_entry { | |
114 | u8 local_port; | |
115 | bool used; | |
116 | struct list_head bound_ports_list; | |
117 | int ref_count; | |
118 | int id; | |
119 | }; | |
120 | ||
121 | enum mlxsw_sp_port_mall_action_type { | |
122 | MLXSW_SP_PORT_MALL_MIRROR, | |
98d0f7b9 | 123 | MLXSW_SP_PORT_MALL_SAMPLE, |
763b4b70 YG |
124 | }; |
125 | ||
126 | struct mlxsw_sp_port_mall_mirror_tc_entry { | |
127 | u8 to_local_port; | |
128 | bool ingress; | |
129 | }; | |
130 | ||
131 | struct mlxsw_sp_port_mall_tc_entry { | |
132 | struct list_head list; | |
133 | unsigned long cookie; | |
134 | enum mlxsw_sp_port_mall_action_type type; | |
135 | union { | |
136 | struct mlxsw_sp_port_mall_mirror_tc_entry mirror; | |
137 | }; | |
138 | }; | |
139 | ||
33cbd87c | 140 | struct mlxsw_sp_sb; |
5f6935c6 | 141 | struct mlxsw_sp_bridge; |
9011b677 | 142 | struct mlxsw_sp_router; |
0e14c777 | 143 | struct mlxsw_sp_mr; |
22a67766 | 144 | struct mlxsw_sp_acl; |
ff7b0d27 | 145 | struct mlxsw_sp_counter_pool; |
a1107487 | 146 | struct mlxsw_sp_fid_core; |
a875a2ee | 147 | struct mlxsw_sp_kvdl; |
22a67766 | 148 | |
56ade8fe | 149 | struct mlxsw_sp { |
56ade8fe JP |
150 | struct mlxsw_sp_port **ports; |
151 | struct mlxsw_core *core; | |
152 | const struct mlxsw_bus_info *bus_info; | |
153 | unsigned char base_mac[ETH_ALEN]; | |
ce0bd2b0 | 154 | struct mlxsw_sp_upper *lags; |
bf4e9f24 | 155 | int *port_to_module; |
33cbd87c | 156 | struct mlxsw_sp_sb *sb; |
5f6935c6 | 157 | struct mlxsw_sp_bridge *bridge; |
9011b677 | 158 | struct mlxsw_sp_router *router; |
c011ec1b | 159 | struct mlxsw_sp_mr *mr; |
d3b939b8 | 160 | struct mlxsw_afa *afa; |
22a67766 | 161 | struct mlxsw_sp_acl *acl; |
a1107487 | 162 | struct mlxsw_sp_fid_core *fid_core; |
a875a2ee | 163 | struct mlxsw_sp_kvdl *kvdl; |
c30f5d01 | 164 | struct notifier_block netdevice_nb; |
763b4b70 | 165 | |
ff7b0d27 | 166 | struct mlxsw_sp_counter_pool *counter_pool; |
763b4b70 YG |
167 | struct { |
168 | struct mlxsw_sp_span_entry *entries; | |
169 | int entries_count; | |
170 | } span; | |
56ade8fe JP |
171 | }; |
172 | ||
0d65fc13 JP |
173 | static inline struct mlxsw_sp_upper * |
174 | mlxsw_sp_lag_get(struct mlxsw_sp *mlxsw_sp, u16 lag_id) | |
175 | { | |
176 | return &mlxsw_sp->lags[lag_id]; | |
177 | } | |
178 | ||
56ade8fe JP |
179 | struct mlxsw_sp_port_pcpu_stats { |
180 | u64 rx_packets; | |
181 | u64 rx_bytes; | |
182 | u64 tx_packets; | |
183 | u64 tx_bytes; | |
184 | struct u64_stats_sync syncp; | |
185 | u32 tx_dropped; | |
186 | }; | |
187 | ||
98d0f7b9 YG |
188 | struct mlxsw_sp_port_sample { |
189 | struct psample_group __rcu *psample_group; | |
190 | u32 trunc_size; | |
191 | u32 rate; | |
192 | bool truncate; | |
193 | }; | |
194 | ||
c57529e1 | 195 | struct mlxsw_sp_bridge_port; |
a1107487 | 196 | struct mlxsw_sp_fid; |
c57529e1 | 197 | |
31a08a52 IS |
198 | struct mlxsw_sp_port_vlan { |
199 | struct list_head list; | |
200 | struct mlxsw_sp_port *mlxsw_sp_port; | |
201 | struct mlxsw_sp_fid *fid; | |
59500498 | 202 | unsigned int ref_count; |
31a08a52 | 203 | u16 vid; |
c57529e1 IS |
204 | struct mlxsw_sp_bridge_port *bridge_port; |
205 | struct list_head bridge_vlan_node; | |
31a08a52 IS |
206 | }; |
207 | ||
96f17e07 NF |
208 | enum mlxsw_sp_qdisc_type { |
209 | MLXSW_SP_QDISC_NO_QDISC, | |
210 | MLXSW_SP_QDISC_RED, | |
211 | }; | |
212 | ||
213 | struct mlxsw_sp_qdisc { | |
214 | u32 handle; | |
215 | enum mlxsw_sp_qdisc_type type; | |
861fb829 NF |
216 | struct red_stats xstats_base; |
217 | union { | |
218 | struct { | |
219 | u64 tail_drop_base; | |
220 | u64 ecn_base; | |
221 | u64 wred_drop_base; | |
222 | } red; | |
223 | } xstats; | |
3670756f NF |
224 | |
225 | u64 tx_bytes; | |
226 | u64 tx_packets; | |
227 | u64 drops; | |
228 | u64 overlimits; | |
96f17e07 NF |
229 | }; |
230 | ||
075ab8ad NF |
231 | /* No need an internal lock; At worse - miss a single periodic iteration */ |
232 | struct mlxsw_sp_port_xstats { | |
233 | u64 ecn; | |
234 | u64 wred_drop[TC_MAX_QUEUE]; | |
235 | u64 tail_drop[TC_MAX_QUEUE]; | |
236 | u64 backlog[TC_MAX_QUEUE]; | |
237 | }; | |
238 | ||
56ade8fe JP |
239 | struct mlxsw_sp_port { |
240 | struct net_device *dev; | |
241 | struct mlxsw_sp_port_pcpu_stats __percpu *pcpu_stats; | |
242 | struct mlxsw_sp *mlxsw_sp; | |
243 | u8 local_port; | |
c57529e1 | 244 | u8 lagged:1, |
18f1e70c | 245 | split:1; |
56ade8fe | 246 | u16 pvid; |
0d65fc13 | 247 | u16 lag_id; |
9f7ec052 IS |
248 | struct { |
249 | u8 tx_pause:1, | |
0c83f88c IS |
250 | rx_pause:1, |
251 | autoneg:1; | |
9f7ec052 | 252 | } link; |
8e8dfe9f IS |
253 | struct { |
254 | struct ieee_ets *ets; | |
cc7cf517 | 255 | struct ieee_maxrate *maxrate; |
d81a6bdb | 256 | struct ieee_pfc *pfc; |
8e8dfe9f | 257 | } dcb; |
d664b41e IS |
258 | struct { |
259 | u8 module; | |
260 | u8 width; | |
261 | u8 lane; | |
262 | } mapping; | |
763b4b70 YG |
263 | /* TC handles */ |
264 | struct list_head mall_tc_list; | |
fc1bbb0f NF |
265 | struct { |
266 | #define MLXSW_HW_STATS_UPDATE_TIME HZ | |
9deef43d | 267 | struct rtnl_link_stats64 stats; |
075ab8ad | 268 | struct mlxsw_sp_port_xstats xstats; |
fc1bbb0f | 269 | struct delayed_work update_dw; |
9deef43d | 270 | } periodic_hw_stats; |
98d0f7b9 | 271 | struct mlxsw_sp_port_sample *sample; |
31a08a52 | 272 | struct list_head vlans_list; |
96f17e07 | 273 | struct mlxsw_sp_qdisc root_qdisc; |
56ade8fe JP |
274 | }; |
275 | ||
9f7ec052 IS |
276 | static inline bool |
277 | mlxsw_sp_port_is_pause_en(const struct mlxsw_sp_port *mlxsw_sp_port) | |
278 | { | |
279 | return mlxsw_sp_port->link.tx_pause || mlxsw_sp_port->link.rx_pause; | |
280 | } | |
281 | ||
0d65fc13 JP |
282 | static inline struct mlxsw_sp_port * |
283 | mlxsw_sp_port_lagged_get(struct mlxsw_sp *mlxsw_sp, u16 lag_id, u8 port_index) | |
284 | { | |
285 | struct mlxsw_sp_port *mlxsw_sp_port; | |
286 | u8 local_port; | |
287 | ||
288 | local_port = mlxsw_core_lag_mapping_get(mlxsw_sp->core, | |
289 | lag_id, port_index); | |
290 | mlxsw_sp_port = mlxsw_sp->ports[local_port]; | |
291 | return mlxsw_sp_port && mlxsw_sp_port->lagged ? mlxsw_sp_port : NULL; | |
292 | } | |
293 | ||
31a08a52 IS |
294 | static inline struct mlxsw_sp_port_vlan * |
295 | mlxsw_sp_port_vlan_find_by_vid(const struct mlxsw_sp_port *mlxsw_sp_port, | |
296 | u16 vid) | |
297 | { | |
298 | struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan; | |
299 | ||
300 | list_for_each_entry(mlxsw_sp_port_vlan, &mlxsw_sp_port->vlans_list, | |
301 | list) { | |
302 | if (mlxsw_sp_port_vlan->vid == vid) | |
303 | return mlxsw_sp_port_vlan; | |
304 | } | |
305 | ||
306 | return NULL; | |
307 | } | |
308 | ||
a1107487 IS |
309 | enum mlxsw_sp_flood_type { |
310 | MLXSW_SP_FLOOD_TYPE_UC, | |
311 | MLXSW_SP_FLOOD_TYPE_BC, | |
312 | MLXSW_SP_FLOOD_TYPE_MC, | |
56ade8fe JP |
313 | }; |
314 | ||
cb4cc0e0 | 315 | /* spectrum_buffers.c */ |
56ade8fe | 316 | int mlxsw_sp_buffers_init(struct mlxsw_sp *mlxsw_sp); |
0f433fa0 | 317 | void mlxsw_sp_buffers_fini(struct mlxsw_sp *mlxsw_sp); |
56ade8fe | 318 | int mlxsw_sp_port_buffers_init(struct mlxsw_sp_port *mlxsw_sp_port); |
0f433fa0 JP |
319 | int mlxsw_sp_sb_pool_get(struct mlxsw_core *mlxsw_core, |
320 | unsigned int sb_index, u16 pool_index, | |
321 | struct devlink_sb_pool_info *pool_info); | |
322 | int mlxsw_sp_sb_pool_set(struct mlxsw_core *mlxsw_core, | |
323 | unsigned int sb_index, u16 pool_index, u32 size, | |
324 | enum devlink_sb_threshold_type threshold_type); | |
325 | int mlxsw_sp_sb_port_pool_get(struct mlxsw_core_port *mlxsw_core_port, | |
326 | unsigned int sb_index, u16 pool_index, | |
327 | u32 *p_threshold); | |
328 | int mlxsw_sp_sb_port_pool_set(struct mlxsw_core_port *mlxsw_core_port, | |
329 | unsigned int sb_index, u16 pool_index, | |
330 | u32 threshold); | |
331 | int mlxsw_sp_sb_tc_pool_bind_get(struct mlxsw_core_port *mlxsw_core_port, | |
332 | unsigned int sb_index, u16 tc_index, | |
333 | enum devlink_sb_pool_type pool_type, | |
334 | u16 *p_pool_index, u32 *p_threshold); | |
335 | int mlxsw_sp_sb_tc_pool_bind_set(struct mlxsw_core_port *mlxsw_core_port, | |
336 | unsigned int sb_index, u16 tc_index, | |
337 | enum devlink_sb_pool_type pool_type, | |
338 | u16 pool_index, u32 threshold); | |
2d0ed39f JP |
339 | int mlxsw_sp_sb_occ_snapshot(struct mlxsw_core *mlxsw_core, |
340 | unsigned int sb_index); | |
341 | int mlxsw_sp_sb_occ_max_clear(struct mlxsw_core *mlxsw_core, | |
342 | unsigned int sb_index); | |
343 | int mlxsw_sp_sb_occ_port_pool_get(struct mlxsw_core_port *mlxsw_core_port, | |
344 | unsigned int sb_index, u16 pool_index, | |
345 | u32 *p_cur, u32 *p_max); | |
346 | int mlxsw_sp_sb_occ_tc_port_bind_get(struct mlxsw_core_port *mlxsw_core_port, | |
347 | unsigned int sb_index, u16 tc_index, | |
348 | enum devlink_sb_pool_type pool_type, | |
349 | u32 *p_cur, u32 *p_max); | |
33cbd87c IS |
350 | u32 mlxsw_sp_cells_bytes(const struct mlxsw_sp *mlxsw_sp, u32 cells); |
351 | u32 mlxsw_sp_bytes_cells(const struct mlxsw_sp *mlxsw_sp, u32 bytes); | |
56ade8fe | 352 | |
cb4cc0e0 | 353 | /* spectrum_switchdev.c */ |
56ade8fe JP |
354 | int mlxsw_sp_switchdev_init(struct mlxsw_sp *mlxsw_sp); |
355 | void mlxsw_sp_switchdev_fini(struct mlxsw_sp *mlxsw_sp); | |
56ade8fe JP |
356 | void mlxsw_sp_port_switchdev_init(struct mlxsw_sp_port *mlxsw_sp_port); |
357 | void mlxsw_sp_port_switchdev_fini(struct mlxsw_sp_port *mlxsw_sp_port); | |
6e095fd4 IS |
358 | int mlxsw_sp_rif_fdb_op(struct mlxsw_sp *mlxsw_sp, const char *mac, u16 fid, |
359 | bool adding); | |
c57529e1 IS |
360 | void |
361 | mlxsw_sp_port_vlan_bridge_leave(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan); | |
362 | int mlxsw_sp_port_bridge_join(struct mlxsw_sp_port *mlxsw_sp_port, | |
363 | struct net_device *brport_dev, | |
9b63ef88 IS |
364 | struct net_device *br_dev, |
365 | struct netlink_ext_ack *extack); | |
c57529e1 IS |
366 | void mlxsw_sp_port_bridge_leave(struct mlxsw_sp_port *mlxsw_sp_port, |
367 | struct net_device *brport_dev, | |
368 | struct net_device *br_dev); | |
90045fc9 IS |
369 | bool mlxsw_sp_bridge_device_is_offloaded(const struct mlxsw_sp *mlxsw_sp, |
370 | const struct net_device *br_dev); | |
c57529e1 | 371 | |
cb4cc0e0 | 372 | /* spectrum.c */ |
8e8dfe9f IS |
373 | int mlxsw_sp_port_ets_set(struct mlxsw_sp_port *mlxsw_sp_port, |
374 | enum mlxsw_reg_qeec_hr hr, u8 index, u8 next_index, | |
375 | bool dwrr, u8 dwrr_weight); | |
376 | int mlxsw_sp_port_prio_tc_set(struct mlxsw_sp_port *mlxsw_sp_port, | |
377 | u8 switch_prio, u8 tclass); | |
378 | int __mlxsw_sp_port_headroom_set(struct mlxsw_sp_port *mlxsw_sp_port, int mtu, | |
d81a6bdb IS |
379 | u8 *prio_tc, bool pause_en, |
380 | struct ieee_pfc *my_pfc); | |
cc7cf517 IS |
381 | int mlxsw_sp_port_ets_maxrate_set(struct mlxsw_sp_port *mlxsw_sp_port, |
382 | enum mlxsw_reg_qeec_hr hr, u8 index, | |
383 | u8 next_index, u32 maxrate); | |
fe9ccc78 IS |
384 | int mlxsw_sp_port_vid_stp_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid, |
385 | u8 state); | |
a1107487 | 386 | int mlxsw_sp_port_vp_mode_set(struct mlxsw_sp_port *mlxsw_sp_port, bool enable); |
fe9ccc78 IS |
387 | int mlxsw_sp_port_vid_learning_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid, |
388 | bool learn_enable); | |
b02eae9b | 389 | int mlxsw_sp_port_pvid_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid); |
c57529e1 IS |
390 | struct mlxsw_sp_port_vlan * |
391 | mlxsw_sp_port_vlan_get(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid); | |
392 | void mlxsw_sp_port_vlan_put(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan); | |
cb4cc0e0 IS |
393 | int mlxsw_sp_port_vlan_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid_begin, |
394 | u16 vid_end, bool is_member, bool untagged); | |
395 | int mlxsw_sp_flow_counter_get(struct mlxsw_sp *mlxsw_sp, | |
396 | unsigned int counter_index, u64 *packets, | |
397 | u64 *bytes); | |
398 | int mlxsw_sp_flow_counter_alloc(struct mlxsw_sp *mlxsw_sp, | |
399 | unsigned int *p_counter_index); | |
400 | void mlxsw_sp_flow_counter_free(struct mlxsw_sp *mlxsw_sp, | |
401 | unsigned int counter_index); | |
402 | bool mlxsw_sp_port_dev_check(const struct net_device *dev); | |
403 | struct mlxsw_sp *mlxsw_sp_lower_get(struct net_device *dev); | |
404 | struct mlxsw_sp_port *mlxsw_sp_port_dev_lower_find(struct net_device *dev); | |
405 | struct mlxsw_sp_port *mlxsw_sp_port_lower_dev_hold(struct net_device *dev); | |
406 | void mlxsw_sp_port_dev_put(struct mlxsw_sp_port *mlxsw_sp_port); | |
af061378 | 407 | struct mlxsw_sp_port *mlxsw_sp_port_dev_lower_find_rcu(struct net_device *dev); |
56ade8fe | 408 | |
cb4cc0e0 | 409 | /* spectrum_dcb.c */ |
f00817df | 410 | #ifdef CONFIG_MLXSW_SPECTRUM_DCB |
f00817df IS |
411 | int mlxsw_sp_port_dcb_init(struct mlxsw_sp_port *mlxsw_sp_port); |
412 | void mlxsw_sp_port_dcb_fini(struct mlxsw_sp_port *mlxsw_sp_port); | |
f00817df | 413 | #else |
f00817df IS |
414 | static inline int mlxsw_sp_port_dcb_init(struct mlxsw_sp_port *mlxsw_sp_port) |
415 | { | |
416 | return 0; | |
417 | } | |
f00817df IS |
418 | static inline void mlxsw_sp_port_dcb_fini(struct mlxsw_sp_port *mlxsw_sp_port) |
419 | {} | |
f00817df IS |
420 | #endif |
421 | ||
cb4cc0e0 | 422 | /* spectrum_router.c */ |
464dce18 IS |
423 | int mlxsw_sp_router_init(struct mlxsw_sp *mlxsw_sp); |
424 | void mlxsw_sp_router_fini(struct mlxsw_sp *mlxsw_sp); | |
4724ba56 IS |
425 | int mlxsw_sp_netdevice_router_port_event(struct net_device *dev); |
426 | int mlxsw_sp_inetaddr_event(struct notifier_block *unused, | |
427 | unsigned long event, void *ptr); | |
89d5dd2e DA |
428 | int mlxsw_sp_inetaddr_valid_event(struct notifier_block *unused, |
429 | unsigned long event, void *ptr); | |
5ea1237f AS |
430 | int mlxsw_sp_inet6addr_event(struct notifier_block *unused, |
431 | unsigned long event, void *ptr); | |
89d5dd2e DA |
432 | int mlxsw_sp_inet6addr_valid_event(struct notifier_block *unused, |
433 | unsigned long event, void *ptr); | |
b1e45526 IS |
434 | int mlxsw_sp_netdevice_vrf_event(struct net_device *l3_dev, unsigned long event, |
435 | struct netdev_notifier_changeupper_info *info); | |
796ec776 PM |
436 | bool mlxsw_sp_netdev_is_ipip_ol(const struct mlxsw_sp *mlxsw_sp, |
437 | const struct net_device *dev); | |
61481f2f PM |
438 | bool mlxsw_sp_netdev_is_ipip_ul(const struct mlxsw_sp *mlxsw_sp, |
439 | const struct net_device *dev); | |
7e75af63 PM |
440 | int mlxsw_sp_netdevice_ipip_ol_event(struct mlxsw_sp *mlxsw_sp, |
441 | struct net_device *l3_dev, | |
442 | unsigned long event, | |
443 | struct netdev_notifier_info *info); | |
61481f2f PM |
444 | int |
445 | mlxsw_sp_netdevice_ipip_ul_event(struct mlxsw_sp *mlxsw_sp, | |
446 | struct net_device *l3_dev, | |
447 | unsigned long event, | |
448 | struct netdev_notifier_info *info); | |
a1107487 IS |
449 | void |
450 | mlxsw_sp_port_vlan_router_leave(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan); | |
e4f3c1c1 | 451 | void mlxsw_sp_rif_destroy(struct mlxsw_sp_rif *rif); |
4f6daa9e IS |
452 | void mlxsw_sp_rif_destroy_by_dev(struct mlxsw_sp *mlxsw_sp, |
453 | struct net_device *dev); | |
464dce18 | 454 | |
cb4cc0e0 | 455 | /* spectrum_kvdl.c */ |
a875a2ee IS |
456 | int mlxsw_sp_kvdl_init(struct mlxsw_sp *mlxsw_sp); |
457 | void mlxsw_sp_kvdl_fini(struct mlxsw_sp *mlxsw_sp); | |
13124443 AS |
458 | int mlxsw_sp_kvdl_alloc(struct mlxsw_sp *mlxsw_sp, unsigned int entry_count, |
459 | u32 *p_entry_index); | |
b090ef06 | 460 | void mlxsw_sp_kvdl_free(struct mlxsw_sp *mlxsw_sp, int entry_index); |
d672aec4 IS |
461 | int mlxsw_sp_kvdl_alloc_size_query(struct mlxsw_sp *mlxsw_sp, |
462 | unsigned int entry_count, | |
463 | unsigned int *p_alloc_size); | |
b090ef06 | 464 | |
22a67766 JP |
465 | struct mlxsw_sp_acl_rule_info { |
466 | unsigned int priority; | |
467 | struct mlxsw_afk_element_values values; | |
468 | struct mlxsw_afa_block *act_block; | |
48170729 AS |
469 | unsigned int counter_index; |
470 | bool counter_valid; | |
22a67766 JP |
471 | }; |
472 | ||
473 | enum mlxsw_sp_acl_profile { | |
474 | MLXSW_SP_ACL_PROFILE_FLOWER, | |
475 | }; | |
476 | ||
477 | struct mlxsw_sp_acl_profile_ops { | |
478 | size_t ruleset_priv_size; | |
479 | int (*ruleset_add)(struct mlxsw_sp *mlxsw_sp, | |
480 | void *priv, void *ruleset_priv); | |
481 | void (*ruleset_del)(struct mlxsw_sp *mlxsw_sp, void *ruleset_priv); | |
482 | int (*ruleset_bind)(struct mlxsw_sp *mlxsw_sp, void *ruleset_priv, | |
483 | struct net_device *dev, bool ingress); | |
484 | void (*ruleset_unbind)(struct mlxsw_sp *mlxsw_sp, void *ruleset_priv); | |
0ade3b64 | 485 | u16 (*ruleset_group_id)(void *ruleset_priv); |
22a67766 JP |
486 | size_t rule_priv_size; |
487 | int (*rule_add)(struct mlxsw_sp *mlxsw_sp, | |
488 | void *ruleset_priv, void *rule_priv, | |
489 | struct mlxsw_sp_acl_rule_info *rulei); | |
490 | void (*rule_del)(struct mlxsw_sp *mlxsw_sp, void *rule_priv); | |
7fd056c2 AS |
491 | int (*rule_activity_get)(struct mlxsw_sp *mlxsw_sp, void *rule_priv, |
492 | bool *activity); | |
22a67766 JP |
493 | }; |
494 | ||
495 | struct mlxsw_sp_acl_ops { | |
496 | size_t priv_size; | |
497 | int (*init)(struct mlxsw_sp *mlxsw_sp, void *priv); | |
498 | void (*fini)(struct mlxsw_sp *mlxsw_sp, void *priv); | |
499 | const struct mlxsw_sp_acl_profile_ops * | |
500 | (*profile_ops)(struct mlxsw_sp *mlxsw_sp, | |
501 | enum mlxsw_sp_acl_profile profile); | |
502 | }; | |
503 | ||
504 | struct mlxsw_sp_acl_ruleset; | |
505 | ||
cb4cc0e0 IS |
506 | /* spectrum_acl.c */ |
507 | struct mlxsw_afk *mlxsw_sp_acl_afk(struct mlxsw_sp_acl *acl); | |
22a67766 | 508 | struct mlxsw_sp_acl_ruleset * |
dbec8ee9 JP |
509 | mlxsw_sp_acl_ruleset_lookup(struct mlxsw_sp *mlxsw_sp, struct net_device *dev, |
510 | bool ingress, u32 chain_index, | |
511 | enum mlxsw_sp_acl_profile profile); | |
512 | struct mlxsw_sp_acl_ruleset * | |
45b62742 JP |
513 | mlxsw_sp_acl_ruleset_get(struct mlxsw_sp *mlxsw_sp, struct net_device *dev, |
514 | bool ingress, u32 chain_index, | |
22a67766 JP |
515 | enum mlxsw_sp_acl_profile profile); |
516 | void mlxsw_sp_acl_ruleset_put(struct mlxsw_sp *mlxsw_sp, | |
517 | struct mlxsw_sp_acl_ruleset *ruleset); | |
0ade3b64 | 518 | u16 mlxsw_sp_acl_ruleset_group_id(struct mlxsw_sp_acl_ruleset *ruleset); |
22a67766 JP |
519 | |
520 | struct mlxsw_sp_acl_rule_info * | |
521 | mlxsw_sp_acl_rulei_create(struct mlxsw_sp_acl *acl); | |
522 | void mlxsw_sp_acl_rulei_destroy(struct mlxsw_sp_acl_rule_info *rulei); | |
523 | int mlxsw_sp_acl_rulei_commit(struct mlxsw_sp_acl_rule_info *rulei); | |
524 | void mlxsw_sp_acl_rulei_priority(struct mlxsw_sp_acl_rule_info *rulei, | |
525 | unsigned int priority); | |
526 | void mlxsw_sp_acl_rulei_keymask_u32(struct mlxsw_sp_acl_rule_info *rulei, | |
527 | enum mlxsw_afk_element element, | |
528 | u32 key_value, u32 mask_value); | |
529 | void mlxsw_sp_acl_rulei_keymask_buf(struct mlxsw_sp_acl_rule_info *rulei, | |
530 | enum mlxsw_afk_element element, | |
531 | const char *key_value, | |
532 | const char *mask_value, unsigned int len); | |
2a52a8c6 JP |
533 | int mlxsw_sp_acl_rulei_act_continue(struct mlxsw_sp_acl_rule_info *rulei); |
534 | int mlxsw_sp_acl_rulei_act_jump(struct mlxsw_sp_acl_rule_info *rulei, | |
535 | u16 group_id); | |
22a67766 | 536 | int mlxsw_sp_acl_rulei_act_drop(struct mlxsw_sp_acl_rule_info *rulei); |
df7eea96 | 537 | int mlxsw_sp_acl_rulei_act_trap(struct mlxsw_sp_acl_rule_info *rulei); |
22a67766 JP |
538 | int mlxsw_sp_acl_rulei_act_fwd(struct mlxsw_sp *mlxsw_sp, |
539 | struct mlxsw_sp_acl_rule_info *rulei, | |
540 | struct net_device *out_dev); | |
a150201a PM |
541 | int mlxsw_sp_acl_rulei_act_vlan(struct mlxsw_sp *mlxsw_sp, |
542 | struct mlxsw_sp_acl_rule_info *rulei, | |
543 | u32 action, u16 vid, u16 proto, u8 prio); | |
48170729 AS |
544 | int mlxsw_sp_acl_rulei_act_count(struct mlxsw_sp *mlxsw_sp, |
545 | struct mlxsw_sp_acl_rule_info *rulei); | |
ac44dd43 JP |
546 | int mlxsw_sp_acl_rulei_act_fid_set(struct mlxsw_sp *mlxsw_sp, |
547 | struct mlxsw_sp_acl_rule_info *rulei, | |
548 | u16 fid); | |
22a67766 JP |
549 | |
550 | struct mlxsw_sp_acl_rule; | |
551 | ||
552 | struct mlxsw_sp_acl_rule * | |
553 | mlxsw_sp_acl_rule_create(struct mlxsw_sp *mlxsw_sp, | |
554 | struct mlxsw_sp_acl_ruleset *ruleset, | |
555 | unsigned long cookie); | |
556 | void mlxsw_sp_acl_rule_destroy(struct mlxsw_sp *mlxsw_sp, | |
557 | struct mlxsw_sp_acl_rule *rule); | |
558 | int mlxsw_sp_acl_rule_add(struct mlxsw_sp *mlxsw_sp, | |
559 | struct mlxsw_sp_acl_rule *rule); | |
560 | void mlxsw_sp_acl_rule_del(struct mlxsw_sp *mlxsw_sp, | |
561 | struct mlxsw_sp_acl_rule *rule); | |
562 | struct mlxsw_sp_acl_rule * | |
563 | mlxsw_sp_acl_rule_lookup(struct mlxsw_sp *mlxsw_sp, | |
564 | struct mlxsw_sp_acl_ruleset *ruleset, | |
565 | unsigned long cookie); | |
566 | struct mlxsw_sp_acl_rule_info * | |
567 | mlxsw_sp_acl_rule_rulei(struct mlxsw_sp_acl_rule *rule); | |
48170729 AS |
568 | int mlxsw_sp_acl_rule_get_stats(struct mlxsw_sp *mlxsw_sp, |
569 | struct mlxsw_sp_acl_rule *rule, | |
570 | u64 *packets, u64 *bytes, u64 *last_use); | |
22a67766 | 571 | |
a1107487 IS |
572 | struct mlxsw_sp_fid *mlxsw_sp_acl_dummy_fid(struct mlxsw_sp *mlxsw_sp); |
573 | ||
22a67766 JP |
574 | int mlxsw_sp_acl_init(struct mlxsw_sp *mlxsw_sp); |
575 | void mlxsw_sp_acl_fini(struct mlxsw_sp *mlxsw_sp); | |
576 | ||
cb4cc0e0 | 577 | /* spectrum_acl_tcam.c */ |
22a67766 JP |
578 | extern const struct mlxsw_sp_acl_ops mlxsw_sp_acl_tcam_ops; |
579 | ||
cb4cc0e0 | 580 | /* spectrum_flower.c */ |
7aa0f5aa | 581 | int mlxsw_sp_flower_replace(struct mlxsw_sp_port *mlxsw_sp_port, bool ingress, |
5fd9fc4e | 582 | struct tc_cls_flower_offload *f); |
7aa0f5aa JP |
583 | void mlxsw_sp_flower_destroy(struct mlxsw_sp_port *mlxsw_sp_port, bool ingress, |
584 | struct tc_cls_flower_offload *f); | |
7c1b8eb1 AS |
585 | int mlxsw_sp_flower_stats(struct mlxsw_sp_port *mlxsw_sp_port, bool ingress, |
586 | struct tc_cls_flower_offload *f); | |
7aa0f5aa | 587 | |
96f17e07 NF |
588 | /* spectrum_qdisc.c */ |
589 | int mlxsw_sp_setup_tc_red(struct mlxsw_sp_port *mlxsw_sp_port, | |
590 | struct tc_red_qopt_offload *p); | |
591 | ||
cb4cc0e0 | 592 | /* spectrum_fid.c */ |
a1107487 IS |
593 | int mlxsw_sp_fid_flood_set(struct mlxsw_sp_fid *fid, |
594 | enum mlxsw_sp_flood_type packet_type, u8 local_port, | |
595 | bool member); | |
596 | int mlxsw_sp_fid_port_vid_map(struct mlxsw_sp_fid *fid, | |
597 | struct mlxsw_sp_port *mlxsw_sp_port, u16 vid); | |
598 | void mlxsw_sp_fid_port_vid_unmap(struct mlxsw_sp_fid *fid, | |
599 | struct mlxsw_sp_port *mlxsw_sp_port, u16 vid); | |
600 | enum mlxsw_sp_rif_type mlxsw_sp_fid_rif_type(const struct mlxsw_sp_fid *fid); | |
601 | u16 mlxsw_sp_fid_index(const struct mlxsw_sp_fid *fid); | |
602 | enum mlxsw_sp_fid_type mlxsw_sp_fid_type(const struct mlxsw_sp_fid *fid); | |
603 | void mlxsw_sp_fid_rif_set(struct mlxsw_sp_fid *fid, struct mlxsw_sp_rif *rif); | |
e4f3c1c1 IS |
604 | enum mlxsw_sp_rif_type |
605 | mlxsw_sp_fid_type_rif_type(const struct mlxsw_sp *mlxsw_sp, | |
606 | enum mlxsw_sp_fid_type type); | |
607 | u16 mlxsw_sp_fid_8021q_vid(const struct mlxsw_sp_fid *fid); | |
a1107487 IS |
608 | struct mlxsw_sp_fid *mlxsw_sp_fid_8021q_get(struct mlxsw_sp *mlxsw_sp, u16 vid); |
609 | struct mlxsw_sp_fid *mlxsw_sp_fid_8021d_get(struct mlxsw_sp *mlxsw_sp, | |
610 | int br_ifindex); | |
611 | struct mlxsw_sp_fid *mlxsw_sp_fid_rfid_get(struct mlxsw_sp *mlxsw_sp, | |
612 | u16 rif_index); | |
613 | struct mlxsw_sp_fid *mlxsw_sp_fid_dummy_get(struct mlxsw_sp *mlxsw_sp); | |
614 | void mlxsw_sp_fid_put(struct mlxsw_sp_fid *fid); | |
615 | int mlxsw_sp_port_fids_init(struct mlxsw_sp_port *mlxsw_sp_port); | |
616 | void mlxsw_sp_port_fids_fini(struct mlxsw_sp_port *mlxsw_sp_port); | |
617 | int mlxsw_sp_fids_init(struct mlxsw_sp *mlxsw_sp); | |
618 | void mlxsw_sp_fids_fini(struct mlxsw_sp *mlxsw_sp); | |
619 | ||
56ade8fe | 620 | #endif |