1 | /* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */ |
2 | /* Copyright (c) 2015-2018 Mellanox Technologies. All rights reserved */ |
3 | |
4 | #ifndef _MLXSW_SPECTRUM_H |
5 | #define _MLXSW_SPECTRUM_H |
6 | |
7 | #include <linux/types.h> |
8 | #include <linux/netdevice.h> |
9 | #include <linux/rhashtable.h> |
10 | #include <linux/bitops.h> |
11 | #include <linux/if_bridge.h> |
12 | #include <linux/if_vlan.h> |
13 | #include <linux/list.h> |
14 | #include <linux/dcbnl.h> |
15 | #include <linux/in6.h> |
16 | #include <linux/notifier.h> |
17 | #include <net/psample.h> |
18 | #include <net/pkt_cls.h> |
19 | #include <net/red.h> |
20 | #include <net/vxlan.h> |
21 | |
22 | #include "port.h" |
23 | #include "core.h" |
24 | #include "core_acl_flex_keys.h" |
25 | #include "core_acl_flex_actions.h" |
26 | #include "reg.h" |
27 | |
28 | #define MLXSW_SP_DEFAULT_VID (VLAN_N_VID - 1) |
29 | |
30 | #define MLXSW_SP_FID_8021D_MAX 1024 |
31 | |
32 | #define MLXSW_SP_MID_MAX 7000 |
33 | |
34 | #define MLXSW_SP_PORTS_PER_CLUSTER_MAX 4 |
35 | |
36 | #define MLXSW_SP_PORT_BASE_SPEED_25G 25000 /* Mb/s */ |
37 | #define MLXSW_SP_PORT_BASE_SPEED_50G 50000 /* Mb/s */ |
38 | |
39 | #define MLXSW_SP_KVD_LINEAR_SIZE 98304 /* entries */ |
40 | #define MLXSW_SP_KVD_GRANULARITY 128 |
41 | |
42 | #define MLXSW_SP_RESOURCE_NAME_KVD "kvd" |
43 | #define MLXSW_SP_RESOURCE_NAME_KVD_LINEAR "linear" |
44 | #define MLXSW_SP_RESOURCE_NAME_KVD_HASH_SINGLE "hash_single" |
45 | #define MLXSW_SP_RESOURCE_NAME_KVD_HASH_DOUBLE "hash_double" |
46 | #define MLXSW_SP_RESOURCE_NAME_KVD_LINEAR_SINGLES "singles" |
47 | #define MLXSW_SP_RESOURCE_NAME_KVD_LINEAR_CHUNKS "chunks" |
48 | #define MLXSW_SP_RESOURCE_NAME_KVD_LINEAR_LARGE_CHUNKS "large_chunks" |
49 | |
50 | enum mlxsw_sp_resource_id { |
51 | MLXSW_SP_RESOURCE_KVD = 1, |
52 | MLXSW_SP_RESOURCE_KVD_LINEAR, |
53 | MLXSW_SP_RESOURCE_KVD_HASH_SINGLE, |
54 | MLXSW_SP_RESOURCE_KVD_HASH_DOUBLE, |
55 | MLXSW_SP_RESOURCE_KVD_LINEAR_SINGLE, |
56 | MLXSW_SP_RESOURCE_KVD_LINEAR_CHUNKS, |
57 | MLXSW_SP_RESOURCE_KVD_LINEAR_LARGE_CHUNKS, |
58 | }; |
59 | |
60 | struct mlxsw_sp_port; |
61 | struct mlxsw_sp_rif; |
62 | struct mlxsw_sp_span_entry; |
63 | enum mlxsw_sp_l3proto; |
64 | union mlxsw_sp_l3addr; |
65 | |
66 | struct mlxsw_sp_upper { |
67 | struct net_device *dev; |
68 | unsigned int ref_count; |
69 | }; |
70 | |
71 | enum mlxsw_sp_rif_type { |
72 | MLXSW_SP_RIF_TYPE_SUBPORT, |
73 | MLXSW_SP_RIF_TYPE_VLAN, |
74 | MLXSW_SP_RIF_TYPE_FID, |
75 | MLXSW_SP_RIF_TYPE_IPIP_LB, /* IP-in-IP loopback. */ |
76 | MLXSW_SP_RIF_TYPE_MAX, |
77 | }; |
78 | |
79 | struct mlxsw_sp_rif_ops; |
80 | |
81 | extern const struct mlxsw_sp_rif_ops *mlxsw_sp1_rif_ops_arr[]; |
82 | extern const struct mlxsw_sp_rif_ops *mlxsw_sp2_rif_ops_arr[]; |
83 | |
84 | enum mlxsw_sp_fid_type { |
85 | MLXSW_SP_FID_TYPE_8021Q, |
86 | MLXSW_SP_FID_TYPE_8021D, |
87 | MLXSW_SP_FID_TYPE_RFID, |
88 | MLXSW_SP_FID_TYPE_DUMMY, |
89 | MLXSW_SP_FID_TYPE_MAX, |
90 | }; |
91 | |
92 | enum mlxsw_sp_nve_type { |
93 | MLXSW_SP_NVE_TYPE_VXLAN, |
94 | }; |
95 | |
96 | struct mlxsw_sp_mid { |
97 | struct list_head list; |
98 | unsigned char addr[ETH_ALEN]; |
99 | u16 fid; |
100 | u16 mid; |
101 | bool in_hw; |
102 | unsigned long *ports_in_mid; /* bits array */ |
103 | }; |
104 | |
105 | enum mlxsw_sp_port_mall_action_type { |
106 | MLXSW_SP_PORT_MALL_MIRROR, |
107 | MLXSW_SP_PORT_MALL_SAMPLE, |
108 | }; |
109 | |
110 | struct mlxsw_sp_port_mall_mirror_tc_entry { |
111 | int span_id; |
112 | bool ingress; |
113 | }; |
114 | |
115 | struct mlxsw_sp_port_mall_tc_entry { |
116 | struct list_head list; |
117 | unsigned long cookie; |
118 | enum mlxsw_sp_port_mall_action_type type; |
119 | union { |
120 | struct mlxsw_sp_port_mall_mirror_tc_entry mirror; |
121 | }; |
122 | }; |
123 | |
124 | struct mlxsw_sp_sb; |
125 | struct mlxsw_sp_bridge; |
126 | struct mlxsw_sp_router; |
127 | struct mlxsw_sp_mr; |
128 | struct mlxsw_sp_acl; |
129 | struct mlxsw_sp_counter_pool; |
130 | struct mlxsw_sp_fid_core; |
131 | struct mlxsw_sp_kvdl; |
132 | struct mlxsw_sp_nve; |
133 | struct mlxsw_sp_kvdl_ops; |
134 | struct mlxsw_sp_mr_tcam_ops; |
135 | struct mlxsw_sp_acl_tcam_ops; |
136 | struct mlxsw_sp_nve_ops; |
137 | struct mlxsw_sp_sb_vals; |
138 | struct mlxsw_sp_port_type_speed_ops; |
139 | |
140 | struct mlxsw_sp { |
141 | struct mlxsw_sp_port **ports; |
142 | struct mlxsw_core *core; |
143 | const struct mlxsw_bus_info *bus_info; |
144 | unsigned char base_mac[ETH_ALEN]; |
145 | const unsigned char *mac_mask; |
146 | struct mlxsw_sp_upper *lags; |
147 | int *port_to_module; |
148 | struct mlxsw_sp_sb *sb; |
149 | struct mlxsw_sp_bridge *bridge; |
150 | struct mlxsw_sp_router *router; |
151 | struct mlxsw_sp_mr *mr; |
152 | struct mlxsw_afa *afa; |
153 | struct mlxsw_sp_acl *acl; |
154 | struct mlxsw_sp_fid_core *fid_core; |
155 | struct mlxsw_sp_kvdl *kvdl; |
156 | struct mlxsw_sp_nve *nve; |
157 | struct notifier_block netdevice_nb; |
158 | |
159 | struct mlxsw_sp_counter_pool *counter_pool; |
160 | struct { |
161 | struct mlxsw_sp_span_entry *entries; |
162 | int entries_count; |
163 | } span; |
164 | const struct mlxsw_fw_rev *req_rev; |
165 | const char *fw_filename; |
166 | const struct mlxsw_sp_kvdl_ops *kvdl_ops; |
167 | const struct mlxsw_afa_ops *afa_ops; |
168 | const struct mlxsw_afk_ops *afk_ops; |
169 | const struct mlxsw_sp_mr_tcam_ops *mr_tcam_ops; |
170 | const struct mlxsw_sp_acl_tcam_ops *acl_tcam_ops; |
171 | const struct mlxsw_sp_nve_ops **nve_ops_arr; |
172 | const struct mlxsw_sp_rif_ops **rif_ops_arr; |
173 | const struct mlxsw_sp_sb_vals *sb_vals; |
174 | const struct mlxsw_sp_port_type_speed_ops *port_type_speed_ops; |
175 | }; |
176 | |
177 | static inline struct mlxsw_sp_upper * |
178 | mlxsw_sp_lag_get(struct mlxsw_sp *mlxsw_sp, u16 lag_id) |
179 | { |
180 | return &mlxsw_sp->lags[lag_id]; |
181 | } |
182 | |
183 | struct mlxsw_sp_port_pcpu_stats { |
184 | u64 rx_packets; |
185 | u64 rx_bytes; |
186 | u64 tx_packets; |
187 | u64 tx_bytes; |
188 | struct u64_stats_sync syncp; |
189 | u32 tx_dropped; |
190 | }; |
191 | |
192 | struct mlxsw_sp_port_sample { |
193 | struct psample_group __rcu *psample_group; |
194 | u32 trunc_size; |
195 | u32 rate; |
196 | bool truncate; |
197 | }; |
198 | |
199 | struct mlxsw_sp_bridge_port; |
200 | struct mlxsw_sp_fid; |
201 | |
202 | struct mlxsw_sp_port_vlan { |
203 | struct list_head list; |
204 | struct mlxsw_sp_port *mlxsw_sp_port; |
205 | struct mlxsw_sp_fid *fid; |
206 | u16 vid; |
207 | struct mlxsw_sp_bridge_port *bridge_port; |
208 | struct list_head bridge_vlan_node; |
209 | }; |
210 | |
211 | /* No need an internal lock; At worse - miss a single periodic iteration */ |
212 | struct mlxsw_sp_port_xstats { |
213 | u64 ecn; |
214 | u64 wred_drop[TC_MAX_QUEUE]; |
215 | u64 tail_drop[TC_MAX_QUEUE]; |
216 | u64 backlog[TC_MAX_QUEUE]; |
217 | u64 tx_bytes[IEEE_8021QAZ_MAX_TCS]; |
218 | u64 tx_packets[IEEE_8021QAZ_MAX_TCS]; |
219 | }; |
220 | |
221 | struct mlxsw_sp_port { |
222 | struct net_device *dev; |
223 | struct mlxsw_sp_port_pcpu_stats __percpu *pcpu_stats; |
224 | struct mlxsw_sp *mlxsw_sp; |
225 | u8 local_port; |
226 | u8 lagged:1, |
227 | split:1; |
228 | u16 pvid; |
229 | u16 lag_id; |
230 | struct { |
231 | u8 tx_pause:1, |
232 | rx_pause:1, |
233 | autoneg:1; |
234 | } link; |
235 | struct { |
236 | struct ieee_ets *ets; |
237 | struct ieee_maxrate *maxrate; |
238 | struct ieee_pfc *pfc; |
239 | enum mlxsw_reg_qpts_trust_state trust_state; |
240 | } dcb; |
241 | struct { |
242 | u8 module; |
243 | u8 width; |
244 | u8 lane; |
245 | } mapping; |
246 | /* TC handles */ |
247 | struct list_head mall_tc_list; |
248 | struct { |
249 | #define MLXSW_HW_STATS_UPDATE_TIME HZ |
250 | struct rtnl_link_stats64 stats; |
251 | struct mlxsw_sp_port_xstats xstats; |
252 | struct delayed_work update_dw; |
253 | } periodic_hw_stats; |
254 | struct mlxsw_sp_port_sample *sample; |
255 | struct list_head vlans_list; |
256 | struct mlxsw_sp_port_vlan *default_vlan; |
257 | struct mlxsw_sp_qdisc *root_qdisc; |
258 | struct mlxsw_sp_qdisc *tclass_qdiscs; |
259 | unsigned acl_rule_count; |
260 | struct mlxsw_sp_acl_block *ing_acl_block; |
261 | struct mlxsw_sp_acl_block *eg_acl_block; |
262 | }; |
263 | |
264 | struct mlxsw_sp_port_type_speed_ops { |
265 | void (*from_ptys_supported_port)(struct mlxsw_sp *mlxsw_sp, |
266 | u32 ptys_eth_proto, |
267 | struct ethtool_link_ksettings *cmd); |
268 | void (*from_ptys_link)(struct mlxsw_sp *mlxsw_sp, u32 ptys_eth_proto, |
269 | unsigned long *mode); |
270 | void (*from_ptys_speed_duplex)(struct mlxsw_sp *mlxsw_sp, |
271 | bool carrier_ok, u32 ptys_eth_proto, |
272 | struct ethtool_link_ksettings *cmd); |
273 | u32 (*to_ptys_advert_link)(struct mlxsw_sp *mlxsw_sp, |
274 | const struct ethtool_link_ksettings *cmd); |
275 | u32 (*to_ptys_speed)(struct mlxsw_sp *mlxsw_sp, u32 speed); |
276 | u32 (*to_ptys_upper_speed)(struct mlxsw_sp *mlxsw_sp, u32 upper_speed); |
277 | int (*port_speed_base)(struct mlxsw_sp *mlxsw_sp, u8 local_port, |
278 | u32 *base_speed); |
279 | void (*reg_ptys_eth_pack)(struct mlxsw_sp *mlxsw_sp, char *payload, |
280 | u8 local_port, u32 proto_admin, bool autoneg); |
281 | void (*reg_ptys_eth_unpack)(struct mlxsw_sp *mlxsw_sp, char *payload, |
282 | u32 *p_eth_proto_cap, |
283 | u32 *p_eth_proto_admin, |
284 | u32 *p_eth_proto_oper); |
285 | }; |
286 | |
287 | static inline struct net_device * |
288 | mlxsw_sp_bridge_vxlan_dev_find(struct net_device *br_dev) |
289 | { |
290 | struct net_device *dev; |
291 | struct list_head *iter; |
292 | |
293 | netdev_for_each_lower_dev(br_dev, dev, iter) { |
294 | if (netif_is_vxlan(dev)) |
295 | return dev; |
296 | } |
297 | |
298 | return NULL; |
299 | } |
300 | |
301 | static inline bool mlxsw_sp_bridge_has_vxlan(struct net_device *br_dev) |
302 | { |
303 | return !!mlxsw_sp_bridge_vxlan_dev_find(br_dev); |
304 | } |
305 | |
306 | static inline int |
307 | mlxsw_sp_vxlan_mapped_vid(const struct net_device *vxlan_dev, u16 *p_vid) |
308 | { |
309 | struct bridge_vlan_info vinfo; |
310 | u16 vid = 0; |
311 | int err; |
312 | |
313 | err = br_vlan_get_pvid(vxlan_dev, &vid); |
314 | if (err || !vid) |
315 | goto out; |
316 | |
317 | err = br_vlan_get_info(vxlan_dev, vid, &vinfo); |
318 | if (err || !(vinfo.flags & BRIDGE_VLAN_INFO_UNTAGGED)) |
319 | vid = 0; |
320 | |
321 | out: |
322 | *p_vid = vid; |
323 | return err; |
324 | } |
325 | |
326 | static inline bool |
327 | mlxsw_sp_port_is_pause_en(const struct mlxsw_sp_port *mlxsw_sp_port) |
328 | { |
329 | return mlxsw_sp_port->link.tx_pause || mlxsw_sp_port->link.rx_pause; |
330 | } |
331 | |
332 | static inline struct mlxsw_sp_port * |
333 | mlxsw_sp_port_lagged_get(struct mlxsw_sp *mlxsw_sp, u16 lag_id, u8 port_index) |
334 | { |
335 | struct mlxsw_sp_port *mlxsw_sp_port; |
336 | u8 local_port; |
337 | |
338 | local_port = mlxsw_core_lag_mapping_get(mlxsw_sp->core, |
339 | lag_id, port_index); |
340 | mlxsw_sp_port = mlxsw_sp->ports[local_port]; |
341 | return mlxsw_sp_port && mlxsw_sp_port->lagged ? mlxsw_sp_port : NULL; |
342 | } |
343 | |
344 | static inline struct mlxsw_sp_port_vlan * |
345 | mlxsw_sp_port_vlan_find_by_vid(const struct mlxsw_sp_port *mlxsw_sp_port, |
346 | u16 vid) |
347 | { |
348 | struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan; |
349 | |
350 | list_for_each_entry(mlxsw_sp_port_vlan, &mlxsw_sp_port->vlans_list, |
351 | list) { |
352 | if (mlxsw_sp_port_vlan->vid == vid) |
353 | return mlxsw_sp_port_vlan; |
354 | } |
355 | |
356 | return NULL; |
357 | } |
358 | |
359 | enum mlxsw_sp_flood_type { |
360 | MLXSW_SP_FLOOD_TYPE_UC, |
361 | MLXSW_SP_FLOOD_TYPE_BC, |
362 | MLXSW_SP_FLOOD_TYPE_MC, |
363 | }; |
364 | |
365 | /* spectrum_buffers.c */ |
366 | int mlxsw_sp_buffers_init(struct mlxsw_sp *mlxsw_sp); |
367 | void mlxsw_sp_buffers_fini(struct mlxsw_sp *mlxsw_sp); |
368 | int mlxsw_sp_port_buffers_init(struct mlxsw_sp_port *mlxsw_sp_port); |
369 | int mlxsw_sp_sb_pool_get(struct mlxsw_core *mlxsw_core, |
370 | unsigned int sb_index, u16 pool_index, |
371 | struct devlink_sb_pool_info *pool_info); |
372 | int mlxsw_sp_sb_pool_set(struct mlxsw_core *mlxsw_core, |
373 | unsigned int sb_index, u16 pool_index, u32 size, |
374 | enum devlink_sb_threshold_type threshold_type); |
375 | int mlxsw_sp_sb_port_pool_get(struct mlxsw_core_port *mlxsw_core_port, |
376 | unsigned int sb_index, u16 pool_index, |
377 | u32 *p_threshold); |
378 | int mlxsw_sp_sb_port_pool_set(struct mlxsw_core_port *mlxsw_core_port, |
379 | unsigned int sb_index, u16 pool_index, |
380 | u32 threshold); |
381 | int mlxsw_sp_sb_tc_pool_bind_get(struct mlxsw_core_port *mlxsw_core_port, |
382 | unsigned int sb_index, u16 tc_index, |
383 | enum devlink_sb_pool_type pool_type, |
384 | u16 *p_pool_index, u32 *p_threshold); |
385 | int mlxsw_sp_sb_tc_pool_bind_set(struct mlxsw_core_port *mlxsw_core_port, |
386 | unsigned int sb_index, u16 tc_index, |
387 | enum devlink_sb_pool_type pool_type, |
388 | u16 pool_index, u32 threshold); |
389 | int mlxsw_sp_sb_occ_snapshot(struct mlxsw_core *mlxsw_core, |
390 | unsigned int sb_index); |
391 | int mlxsw_sp_sb_occ_max_clear(struct mlxsw_core *mlxsw_core, |
392 | unsigned int sb_index); |
393 | int mlxsw_sp_sb_occ_port_pool_get(struct mlxsw_core_port *mlxsw_core_port, |
394 | unsigned int sb_index, u16 pool_index, |
395 | u32 *p_cur, u32 *p_max); |
396 | int mlxsw_sp_sb_occ_tc_port_bind_get(struct mlxsw_core_port *mlxsw_core_port, |
397 | unsigned int sb_index, u16 tc_index, |
398 | enum devlink_sb_pool_type pool_type, |
399 | u32 *p_cur, u32 *p_max); |
400 | u32 mlxsw_sp_cells_bytes(const struct mlxsw_sp *mlxsw_sp, u32 cells); |
401 | u32 mlxsw_sp_bytes_cells(const struct mlxsw_sp *mlxsw_sp, u32 bytes); |
402 | u32 mlxsw_sp_sb_max_headroom_cells(const struct mlxsw_sp *mlxsw_sp); |
403 | |
404 | extern const struct mlxsw_sp_sb_vals mlxsw_sp1_sb_vals; |
405 | extern const struct mlxsw_sp_sb_vals mlxsw_sp2_sb_vals; |
406 | |
407 | /* spectrum_switchdev.c */ |
408 | int mlxsw_sp_switchdev_init(struct mlxsw_sp *mlxsw_sp); |
409 | void mlxsw_sp_switchdev_fini(struct mlxsw_sp *mlxsw_sp); |
410 | int mlxsw_sp_rif_fdb_op(struct mlxsw_sp *mlxsw_sp, const char *mac, u16 fid, |
411 | bool adding); |
412 | void |
413 | mlxsw_sp_port_vlan_bridge_leave(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan); |
414 | int mlxsw_sp_port_bridge_join(struct mlxsw_sp_port *mlxsw_sp_port, |
415 | struct net_device *brport_dev, |
416 | struct net_device *br_dev, |
417 | struct netlink_ext_ack *extack); |
418 | void mlxsw_sp_port_bridge_leave(struct mlxsw_sp_port *mlxsw_sp_port, |
419 | struct net_device *brport_dev, |
420 | struct net_device *br_dev); |
421 | bool mlxsw_sp_bridge_device_is_offloaded(const struct mlxsw_sp *mlxsw_sp, |
422 | const struct net_device *br_dev); |
423 | int mlxsw_sp_bridge_vxlan_join(struct mlxsw_sp *mlxsw_sp, |
424 | const struct net_device *br_dev, |
425 | const struct net_device *vxlan_dev, u16 vid, |
426 | struct netlink_ext_ack *extack); |
427 | void mlxsw_sp_bridge_vxlan_leave(struct mlxsw_sp *mlxsw_sp, |
428 | const struct net_device *vxlan_dev); |
429 | struct mlxsw_sp_fid *mlxsw_sp_bridge_fid_get(struct mlxsw_sp *mlxsw_sp, |
430 | const struct net_device *br_dev, |
431 | u16 vid, |
432 | struct netlink_ext_ack *extack); |
433 | extern struct notifier_block mlxsw_sp_switchdev_notifier; |
434 | |
435 | /* spectrum.c */ |
436 | int mlxsw_sp_port_ets_set(struct mlxsw_sp_port *mlxsw_sp_port, |
437 | enum mlxsw_reg_qeec_hr hr, u8 index, u8 next_index, |
438 | bool dwrr, u8 dwrr_weight); |
439 | int mlxsw_sp_port_prio_tc_set(struct mlxsw_sp_port *mlxsw_sp_port, |
440 | u8 switch_prio, u8 tclass); |
441 | int __mlxsw_sp_port_headroom_set(struct mlxsw_sp_port *mlxsw_sp_port, int mtu, |
442 | u8 *prio_tc, bool pause_en, |
443 | struct ieee_pfc *my_pfc); |
444 | int mlxsw_sp_port_ets_maxrate_set(struct mlxsw_sp_port *mlxsw_sp_port, |
445 | enum mlxsw_reg_qeec_hr hr, u8 index, |
446 | u8 next_index, u32 maxrate); |
447 | enum mlxsw_reg_spms_state mlxsw_sp_stp_spms_state(u8 stp_state); |
448 | int mlxsw_sp_port_vid_stp_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid, |
449 | u8 state); |
450 | int mlxsw_sp_port_vp_mode_set(struct mlxsw_sp_port *mlxsw_sp_port, bool enable); |
451 | int mlxsw_sp_port_vid_learning_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid, |
452 | bool learn_enable); |
453 | int mlxsw_sp_port_pvid_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid); |
454 | struct mlxsw_sp_port_vlan * |
455 | mlxsw_sp_port_vlan_create(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid); |
456 | void mlxsw_sp_port_vlan_destroy(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan); |
457 | int mlxsw_sp_port_vlan_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid_begin, |
458 | u16 vid_end, bool is_member, bool untagged); |
459 | int mlxsw_sp_flow_counter_get(struct mlxsw_sp *mlxsw_sp, |
460 | unsigned int counter_index, u64 *packets, |
461 | u64 *bytes); |
462 | int mlxsw_sp_flow_counter_alloc(struct mlxsw_sp *mlxsw_sp, |
463 | unsigned int *p_counter_index); |
464 | void mlxsw_sp_flow_counter_free(struct mlxsw_sp *mlxsw_sp, |
465 | unsigned int counter_index); |
466 | bool mlxsw_sp_port_dev_check(const struct net_device *dev); |
467 | struct mlxsw_sp *mlxsw_sp_lower_get(struct net_device *dev); |
468 | struct mlxsw_sp_port *mlxsw_sp_port_dev_lower_find(struct net_device *dev); |
469 | struct mlxsw_sp_port *mlxsw_sp_port_lower_dev_hold(struct net_device *dev); |
470 | void mlxsw_sp_port_dev_put(struct mlxsw_sp_port *mlxsw_sp_port); |
471 | struct mlxsw_sp_port *mlxsw_sp_port_dev_lower_find_rcu(struct net_device *dev); |
472 | |
473 | /* spectrum_dcb.c */ |
474 | #ifdef CONFIG_MLXSW_SPECTRUM_DCB |
475 | int mlxsw_sp_port_dcb_init(struct mlxsw_sp_port *mlxsw_sp_port); |
476 | void mlxsw_sp_port_dcb_fini(struct mlxsw_sp_port *mlxsw_sp_port); |
477 | #else |
478 | static inline int mlxsw_sp_port_dcb_init(struct mlxsw_sp_port *mlxsw_sp_port) |
479 | { |
480 | return 0; |
481 | } |
482 | static inline void mlxsw_sp_port_dcb_fini(struct mlxsw_sp_port *mlxsw_sp_port) |
483 | {} |
484 | #endif |
485 | |
486 | /* spectrum_router.c */ |
487 | enum mlxsw_sp_l3proto { |
488 | MLXSW_SP_L3_PROTO_IPV4, |
489 | MLXSW_SP_L3_PROTO_IPV6, |
490 | #define MLXSW_SP_L3_PROTO_MAX (MLXSW_SP_L3_PROTO_IPV6 + 1) |
491 | }; |
492 | |
493 | union mlxsw_sp_l3addr { |
494 | __be32 addr4; |
495 | struct in6_addr addr6; |
496 | }; |
497 | |
498 | int mlxsw_sp_router_init(struct mlxsw_sp *mlxsw_sp); |
499 | void mlxsw_sp_router_fini(struct mlxsw_sp *mlxsw_sp); |
500 | int mlxsw_sp_netdevice_router_port_event(struct net_device *dev, |
501 | unsigned long event, void *ptr); |
502 | void mlxsw_sp_rif_macvlan_del(struct mlxsw_sp *mlxsw_sp, |
503 | const struct net_device *macvlan_dev); |
504 | int mlxsw_sp_inetaddr_valid_event(struct notifier_block *unused, |
505 | unsigned long event, void *ptr); |
506 | int mlxsw_sp_inet6addr_valid_event(struct notifier_block *unused, |
507 | unsigned long event, void *ptr); |
508 | int mlxsw_sp_netdevice_vrf_event(struct net_device *l3_dev, unsigned long event, |
509 | struct netdev_notifier_changeupper_info *info); |
510 | bool mlxsw_sp_netdev_is_ipip_ol(const struct mlxsw_sp *mlxsw_sp, |
511 | const struct net_device *dev); |
512 | bool mlxsw_sp_netdev_is_ipip_ul(const struct mlxsw_sp *mlxsw_sp, |
513 | const struct net_device *dev); |
514 | int mlxsw_sp_netdevice_ipip_ol_event(struct mlxsw_sp *mlxsw_sp, |
515 | struct net_device *l3_dev, |
516 | unsigned long event, |
517 | struct netdev_notifier_info *info); |
518 | int |
519 | mlxsw_sp_netdevice_ipip_ul_event(struct mlxsw_sp *mlxsw_sp, |
520 | struct net_device *l3_dev, |
521 | unsigned long event, |
522 | struct netdev_notifier_info *info); |
523 | void |
524 | mlxsw_sp_port_vlan_router_leave(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan); |
525 | void mlxsw_sp_rif_destroy_by_dev(struct mlxsw_sp *mlxsw_sp, |
526 | struct net_device *dev); |
527 | struct mlxsw_sp_rif *mlxsw_sp_rif_find_by_dev(const struct mlxsw_sp *mlxsw_sp, |
528 | const struct net_device *dev); |
529 | u8 mlxsw_sp_router_port(const struct mlxsw_sp *mlxsw_sp); |
530 | struct mlxsw_sp_fid *mlxsw_sp_rif_fid(const struct mlxsw_sp_rif *rif); |
531 | int mlxsw_sp_router_nve_promote_decap(struct mlxsw_sp *mlxsw_sp, u32 ul_tb_id, |
532 | enum mlxsw_sp_l3proto ul_proto, |
533 | const union mlxsw_sp_l3addr *ul_sip, |
534 | u32 tunnel_index); |
535 | void mlxsw_sp_router_nve_demote_decap(struct mlxsw_sp *mlxsw_sp, u32 ul_tb_id, |
536 | enum mlxsw_sp_l3proto ul_proto, |
537 | const union mlxsw_sp_l3addr *ul_sip); |
538 | int mlxsw_sp_router_tb_id_vr_id(struct mlxsw_sp *mlxsw_sp, u32 tb_id, |
539 | u16 *vr_id); |
540 | int mlxsw_sp_router_ul_rif_get(struct mlxsw_sp *mlxsw_sp, u32 ul_tb_id, |
541 | u16 *ul_rif_index); |
542 | void mlxsw_sp_router_ul_rif_put(struct mlxsw_sp *mlxsw_sp, u16 ul_rif_index); |
543 | |
544 | /* spectrum_kvdl.c */ |
545 | enum mlxsw_sp_kvdl_entry_type { |
546 | MLXSW_SP_KVDL_ENTRY_TYPE_ADJ, |
547 | MLXSW_SP_KVDL_ENTRY_TYPE_ACTSET, |
548 | MLXSW_SP_KVDL_ENTRY_TYPE_PBS, |
549 | MLXSW_SP_KVDL_ENTRY_TYPE_MCRIGR, |
550 | MLXSW_SP_KVDL_ENTRY_TYPE_TNUMT, |
551 | }; |
552 | |
553 | static inline unsigned int |
554 | mlxsw_sp_kvdl_entry_size(enum mlxsw_sp_kvdl_entry_type type) |
555 | { |
556 | switch (type) { |
557 | case MLXSW_SP_KVDL_ENTRY_TYPE_ADJ: /* fall through */ |
558 | case MLXSW_SP_KVDL_ENTRY_TYPE_ACTSET: /* fall through */ |
559 | case MLXSW_SP_KVDL_ENTRY_TYPE_PBS: /* fall through */ |
560 | case MLXSW_SP_KVDL_ENTRY_TYPE_MCRIGR: /* fall through */ |
561 | case MLXSW_SP_KVDL_ENTRY_TYPE_TNUMT: /* fall through */ |
562 | default: |
563 | return 1; |
564 | } |
565 | } |
566 | |
567 | struct mlxsw_sp_kvdl_ops { |
568 | size_t priv_size; |
569 | int (*init)(struct mlxsw_sp *mlxsw_sp, void *priv); |
570 | void (*fini)(struct mlxsw_sp *mlxsw_sp, void *priv); |
571 | int (*alloc)(struct mlxsw_sp *mlxsw_sp, void *priv, |
572 | enum mlxsw_sp_kvdl_entry_type type, |
573 | unsigned int entry_count, u32 *p_entry_index); |
574 | void (*free)(struct mlxsw_sp *mlxsw_sp, void *priv, |
575 | enum mlxsw_sp_kvdl_entry_type type, |
576 | unsigned int entry_count, int entry_index); |
577 | int (*alloc_size_query)(struct mlxsw_sp *mlxsw_sp, void *priv, |
578 | enum mlxsw_sp_kvdl_entry_type type, |
579 | unsigned int entry_count, |
580 | unsigned int *p_alloc_count); |
581 | int (*resources_register)(struct mlxsw_sp *mlxsw_sp, void *priv); |
582 | }; |
583 | |
584 | int mlxsw_sp_kvdl_init(struct mlxsw_sp *mlxsw_sp); |
585 | void mlxsw_sp_kvdl_fini(struct mlxsw_sp *mlxsw_sp); |
586 | int mlxsw_sp_kvdl_alloc(struct mlxsw_sp *mlxsw_sp, |
587 | enum mlxsw_sp_kvdl_entry_type type, |
588 | unsigned int entry_count, u32 *p_entry_index); |
589 | void mlxsw_sp_kvdl_free(struct mlxsw_sp *mlxsw_sp, |
590 | enum mlxsw_sp_kvdl_entry_type type, |
591 | unsigned int entry_count, int entry_index); |
592 | int mlxsw_sp_kvdl_alloc_count_query(struct mlxsw_sp *mlxsw_sp, |
593 | enum mlxsw_sp_kvdl_entry_type type, |
594 | unsigned int entry_count, |
595 | unsigned int *p_alloc_count); |
596 | |
597 | /* spectrum1_kvdl.c */ |
598 | extern const struct mlxsw_sp_kvdl_ops mlxsw_sp1_kvdl_ops; |
599 | int mlxsw_sp1_kvdl_resources_register(struct mlxsw_core *mlxsw_core); |
600 | |
601 | /* spectrum2_kvdl.c */ |
602 | extern const struct mlxsw_sp_kvdl_ops mlxsw_sp2_kvdl_ops; |
603 | |
604 | struct mlxsw_sp_acl_rule_info { |
605 | unsigned int priority; |
606 | struct mlxsw_afk_element_values values; |
607 | struct mlxsw_afa_block *act_block; |
608 | u8 action_created:1; |
609 | unsigned int counter_index; |
610 | }; |
611 | |
612 | struct mlxsw_sp_acl_block; |
613 | struct mlxsw_sp_acl_ruleset; |
614 | |
615 | /* spectrum_acl.c */ |
616 | enum mlxsw_sp_acl_profile { |
617 | MLXSW_SP_ACL_PROFILE_FLOWER, |
618 | MLXSW_SP_ACL_PROFILE_MR, |
619 | }; |
620 | |
621 | struct mlxsw_afk *mlxsw_sp_acl_afk(struct mlxsw_sp_acl *acl); |
622 | struct mlxsw_sp *mlxsw_sp_acl_block_mlxsw_sp(struct mlxsw_sp_acl_block *block); |
623 | unsigned int mlxsw_sp_acl_block_rule_count(struct mlxsw_sp_acl_block *block); |
624 | void mlxsw_sp_acl_block_disable_inc(struct mlxsw_sp_acl_block *block); |
625 | void mlxsw_sp_acl_block_disable_dec(struct mlxsw_sp_acl_block *block); |
626 | bool mlxsw_sp_acl_block_disabled(struct mlxsw_sp_acl_block *block); |
627 | struct mlxsw_sp_acl_block *mlxsw_sp_acl_block_create(struct mlxsw_sp *mlxsw_sp, |
628 | struct net *net); |
629 | void mlxsw_sp_acl_block_destroy(struct mlxsw_sp_acl_block *block); |
630 | int mlxsw_sp_acl_block_bind(struct mlxsw_sp *mlxsw_sp, |
631 | struct mlxsw_sp_acl_block *block, |
632 | struct mlxsw_sp_port *mlxsw_sp_port, |
633 | bool ingress); |
634 | int mlxsw_sp_acl_block_unbind(struct mlxsw_sp *mlxsw_sp, |
635 | struct mlxsw_sp_acl_block *block, |
636 | struct mlxsw_sp_port *mlxsw_sp_port, |
637 | bool ingress); |
638 | bool mlxsw_sp_acl_block_is_egress_bound(struct mlxsw_sp_acl_block *block); |
639 | struct mlxsw_sp_acl_ruleset * |
640 | mlxsw_sp_acl_ruleset_lookup(struct mlxsw_sp *mlxsw_sp, |
641 | struct mlxsw_sp_acl_block *block, u32 chain_index, |
642 | enum mlxsw_sp_acl_profile profile); |
643 | struct mlxsw_sp_acl_ruleset * |
644 | mlxsw_sp_acl_ruleset_get(struct mlxsw_sp *mlxsw_sp, |
645 | struct mlxsw_sp_acl_block *block, u32 chain_index, |
646 | enum mlxsw_sp_acl_profile profile, |
647 | struct mlxsw_afk_element_usage *tmplt_elusage); |
648 | void mlxsw_sp_acl_ruleset_put(struct mlxsw_sp *mlxsw_sp, |
649 | struct mlxsw_sp_acl_ruleset *ruleset); |
650 | u16 mlxsw_sp_acl_ruleset_group_id(struct mlxsw_sp_acl_ruleset *ruleset); |
651 | |
652 | struct mlxsw_sp_acl_rule_info * |
653 | mlxsw_sp_acl_rulei_create(struct mlxsw_sp_acl *acl, |
654 | struct mlxsw_afa_block *afa_block); |
655 | void mlxsw_sp_acl_rulei_destroy(struct mlxsw_sp_acl_rule_info *rulei); |
656 | int mlxsw_sp_acl_rulei_commit(struct mlxsw_sp_acl_rule_info *rulei); |
657 | void mlxsw_sp_acl_rulei_priority(struct mlxsw_sp_acl_rule_info *rulei, |
658 | unsigned int priority); |
659 | void mlxsw_sp_acl_rulei_keymask_u32(struct mlxsw_sp_acl_rule_info *rulei, |
660 | enum mlxsw_afk_element element, |
661 | u32 key_value, u32 mask_value); |
662 | void mlxsw_sp_acl_rulei_keymask_buf(struct mlxsw_sp_acl_rule_info *rulei, |
663 | enum mlxsw_afk_element element, |
664 | const char *key_value, |
665 | const char *mask_value, unsigned int len); |
666 | int mlxsw_sp_acl_rulei_act_continue(struct mlxsw_sp_acl_rule_info *rulei); |
667 | int mlxsw_sp_acl_rulei_act_jump(struct mlxsw_sp_acl_rule_info *rulei, |
668 | u16 group_id); |
669 | int mlxsw_sp_acl_rulei_act_terminate(struct mlxsw_sp_acl_rule_info *rulei); |
670 | int mlxsw_sp_acl_rulei_act_drop(struct mlxsw_sp_acl_rule_info *rulei); |
671 | int mlxsw_sp_acl_rulei_act_trap(struct mlxsw_sp_acl_rule_info *rulei); |
672 | int mlxsw_sp_acl_rulei_act_mirror(struct mlxsw_sp *mlxsw_sp, |
673 | struct mlxsw_sp_acl_rule_info *rulei, |
674 | struct mlxsw_sp_acl_block *block, |
675 | struct net_device *out_dev, |
676 | struct netlink_ext_ack *extack); |
677 | int mlxsw_sp_acl_rulei_act_fwd(struct mlxsw_sp *mlxsw_sp, |
678 | struct mlxsw_sp_acl_rule_info *rulei, |
679 | struct net_device *out_dev, |
680 | struct netlink_ext_ack *extack); |
681 | int mlxsw_sp_acl_rulei_act_vlan(struct mlxsw_sp *mlxsw_sp, |
682 | struct mlxsw_sp_acl_rule_info *rulei, |
683 | u32 action, u16 vid, u16 proto, u8 prio, |
684 | struct netlink_ext_ack *extack); |
685 | int mlxsw_sp_acl_rulei_act_count(struct mlxsw_sp *mlxsw_sp, |
686 | struct mlxsw_sp_acl_rule_info *rulei, |
687 | struct netlink_ext_ack *extack); |
688 | int mlxsw_sp_acl_rulei_act_fid_set(struct mlxsw_sp *mlxsw_sp, |
689 | struct mlxsw_sp_acl_rule_info *rulei, |
690 | u16 fid, struct netlink_ext_ack *extack); |
691 | |
692 | struct mlxsw_sp_acl_rule; |
693 | |
694 | struct mlxsw_sp_acl_rule * |
695 | mlxsw_sp_acl_rule_create(struct mlxsw_sp *mlxsw_sp, |
696 | struct mlxsw_sp_acl_ruleset *ruleset, |
697 | unsigned long cookie, |
698 | struct mlxsw_afa_block *afa_block, |
699 | struct netlink_ext_ack *extack); |
700 | void mlxsw_sp_acl_rule_destroy(struct mlxsw_sp *mlxsw_sp, |
701 | struct mlxsw_sp_acl_rule *rule); |
702 | int mlxsw_sp_acl_rule_add(struct mlxsw_sp *mlxsw_sp, |
703 | struct mlxsw_sp_acl_rule *rule); |
704 | void mlxsw_sp_acl_rule_del(struct mlxsw_sp *mlxsw_sp, |
705 | struct mlxsw_sp_acl_rule *rule); |
706 | int mlxsw_sp_acl_rule_action_replace(struct mlxsw_sp *mlxsw_sp, |
707 | struct mlxsw_sp_acl_rule *rule, |
708 | struct mlxsw_afa_block *afa_block); |
709 | struct mlxsw_sp_acl_rule * |
710 | mlxsw_sp_acl_rule_lookup(struct mlxsw_sp *mlxsw_sp, |
711 | struct mlxsw_sp_acl_ruleset *ruleset, |
712 | unsigned long cookie); |
713 | struct mlxsw_sp_acl_rule_info * |
714 | mlxsw_sp_acl_rule_rulei(struct mlxsw_sp_acl_rule *rule); |
715 | int mlxsw_sp_acl_rule_get_stats(struct mlxsw_sp *mlxsw_sp, |
716 | struct mlxsw_sp_acl_rule *rule, |
717 | u64 *packets, u64 *bytes, u64 *last_use); |
718 | |
719 | struct mlxsw_sp_fid *mlxsw_sp_acl_dummy_fid(struct mlxsw_sp *mlxsw_sp); |
720 | |
721 | int mlxsw_sp_acl_init(struct mlxsw_sp *mlxsw_sp); |
722 | void mlxsw_sp_acl_fini(struct mlxsw_sp *mlxsw_sp); |
723 | u32 mlxsw_sp_acl_region_rehash_intrvl_get(struct mlxsw_sp *mlxsw_sp); |
724 | int mlxsw_sp_acl_region_rehash_intrvl_set(struct mlxsw_sp *mlxsw_sp, u32 val); |
725 | |
726 | /* spectrum_acl_tcam.c */ |
727 | struct mlxsw_sp_acl_tcam; |
728 | struct mlxsw_sp_acl_tcam_region; |
729 | |
730 | struct mlxsw_sp_acl_tcam_ops { |
731 | enum mlxsw_reg_ptar_key_type key_type; |
732 | size_t priv_size; |
733 | int (*init)(struct mlxsw_sp *mlxsw_sp, void *priv, |
734 | struct mlxsw_sp_acl_tcam *tcam); |
735 | void (*fini)(struct mlxsw_sp *mlxsw_sp, void *priv); |
736 | size_t region_priv_size; |
737 | int (*region_init)(struct mlxsw_sp *mlxsw_sp, void *region_priv, |
738 | void *tcam_priv, |
739 | struct mlxsw_sp_acl_tcam_region *region, |
740 | void *hints_priv); |
741 | void (*region_fini)(struct mlxsw_sp *mlxsw_sp, void *region_priv); |
742 | int (*region_associate)(struct mlxsw_sp *mlxsw_sp, |
743 | struct mlxsw_sp_acl_tcam_region *region); |
744 | void * (*region_rehash_hints_get)(void *region_priv); |
745 | void (*region_rehash_hints_put)(void *hints_priv); |
746 | size_t chunk_priv_size; |
747 | void (*chunk_init)(void *region_priv, void *chunk_priv, |
748 | unsigned int priority); |
749 | void (*chunk_fini)(void *chunk_priv); |
750 | size_t entry_priv_size; |
751 | int (*entry_add)(struct mlxsw_sp *mlxsw_sp, |
752 | void *region_priv, void *chunk_priv, |
753 | void *entry_priv, |
754 | struct mlxsw_sp_acl_rule_info *rulei); |
755 | void (*entry_del)(struct mlxsw_sp *mlxsw_sp, |
756 | void *region_priv, void *chunk_priv, |
757 | void *entry_priv); |
758 | int (*entry_action_replace)(struct mlxsw_sp *mlxsw_sp, |
759 | void *region_priv, void *entry_priv, |
760 | struct mlxsw_sp_acl_rule_info *rulei); |
761 | int (*entry_activity_get)(struct mlxsw_sp *mlxsw_sp, |
762 | void *region_priv, void *entry_priv, |
763 | bool *activity); |
764 | }; |
765 | |
766 | /* spectrum1_acl_tcam.c */ |
767 | extern const struct mlxsw_sp_acl_tcam_ops mlxsw_sp1_acl_tcam_ops; |
768 | |
769 | /* spectrum2_acl_tcam.c */ |
770 | extern const struct mlxsw_sp_acl_tcam_ops mlxsw_sp2_acl_tcam_ops; |
771 | |
772 | /* spectrum_acl_flex_actions.c */ |
773 | extern const struct mlxsw_afa_ops mlxsw_sp1_act_afa_ops; |
774 | extern const struct mlxsw_afa_ops mlxsw_sp2_act_afa_ops; |
775 | |
776 | /* spectrum_acl_flex_keys.c */ |
777 | extern const struct mlxsw_afk_ops mlxsw_sp1_afk_ops; |
778 | extern const struct mlxsw_afk_ops mlxsw_sp2_afk_ops; |
779 | |
780 | /* spectrum_flower.c */ |
781 | int mlxsw_sp_flower_replace(struct mlxsw_sp *mlxsw_sp, |
782 | struct mlxsw_sp_acl_block *block, |
783 | struct tc_cls_flower_offload *f); |
784 | void mlxsw_sp_flower_destroy(struct mlxsw_sp *mlxsw_sp, |
785 | struct mlxsw_sp_acl_block *block, |
786 | struct tc_cls_flower_offload *f); |
787 | int mlxsw_sp_flower_stats(struct mlxsw_sp *mlxsw_sp, |
788 | struct mlxsw_sp_acl_block *block, |
789 | struct tc_cls_flower_offload *f); |
790 | int mlxsw_sp_flower_tmplt_create(struct mlxsw_sp *mlxsw_sp, |
791 | struct mlxsw_sp_acl_block *block, |
792 | struct tc_cls_flower_offload *f); |
793 | void mlxsw_sp_flower_tmplt_destroy(struct mlxsw_sp *mlxsw_sp, |
794 | struct mlxsw_sp_acl_block *block, |
795 | struct tc_cls_flower_offload *f); |
796 | |
797 | /* spectrum_qdisc.c */ |
798 | int mlxsw_sp_tc_qdisc_init(struct mlxsw_sp_port *mlxsw_sp_port); |
799 | void mlxsw_sp_tc_qdisc_fini(struct mlxsw_sp_port *mlxsw_sp_port); |
800 | int mlxsw_sp_setup_tc_red(struct mlxsw_sp_port *mlxsw_sp_port, |
801 | struct tc_red_qopt_offload *p); |
802 | int mlxsw_sp_setup_tc_prio(struct mlxsw_sp_port *mlxsw_sp_port, |
803 | struct tc_prio_qopt_offload *p); |
804 | |
805 | /* spectrum_fid.c */ |
806 | bool mlxsw_sp_fid_lag_vid_valid(const struct mlxsw_sp_fid *fid); |
807 | struct mlxsw_sp_fid *mlxsw_sp_fid_lookup_by_index(struct mlxsw_sp *mlxsw_sp, |
808 | u16 fid_index); |
809 | int mlxsw_sp_fid_nve_ifindex(const struct mlxsw_sp_fid *fid, int *nve_ifindex); |
810 | int mlxsw_sp_fid_nve_type(const struct mlxsw_sp_fid *fid, |
811 | enum mlxsw_sp_nve_type *p_type); |
812 | struct mlxsw_sp_fid *mlxsw_sp_fid_lookup_by_vni(struct mlxsw_sp *mlxsw_sp, |
813 | __be32 vni); |
814 | int mlxsw_sp_fid_vni(const struct mlxsw_sp_fid *fid, __be32 *vni); |
815 | int mlxsw_sp_fid_nve_flood_index_set(struct mlxsw_sp_fid *fid, |
816 | u32 nve_flood_index); |
817 | void mlxsw_sp_fid_nve_flood_index_clear(struct mlxsw_sp_fid *fid); |
818 | bool mlxsw_sp_fid_nve_flood_index_is_set(const struct mlxsw_sp_fid *fid); |
819 | int mlxsw_sp_fid_vni_set(struct mlxsw_sp_fid *fid, enum mlxsw_sp_nve_type type, |
820 | __be32 vni, int nve_ifindex); |
821 | void mlxsw_sp_fid_vni_clear(struct mlxsw_sp_fid *fid); |
822 | bool mlxsw_sp_fid_vni_is_set(const struct mlxsw_sp_fid *fid); |
823 | void mlxsw_sp_fid_fdb_clear_offload(const struct mlxsw_sp_fid *fid, |
824 | const struct net_device *nve_dev); |
825 | int mlxsw_sp_fid_flood_set(struct mlxsw_sp_fid *fid, |
826 | enum mlxsw_sp_flood_type packet_type, u8 local_port, |
827 | bool member); |
828 | int mlxsw_sp_fid_port_vid_map(struct mlxsw_sp_fid *fid, |
829 | struct mlxsw_sp_port *mlxsw_sp_port, u16 vid); |
830 | void mlxsw_sp_fid_port_vid_unmap(struct mlxsw_sp_fid *fid, |
831 | struct mlxsw_sp_port *mlxsw_sp_port, u16 vid); |
832 | u16 mlxsw_sp_fid_index(const struct mlxsw_sp_fid *fid); |
833 | enum mlxsw_sp_fid_type mlxsw_sp_fid_type(const struct mlxsw_sp_fid *fid); |
834 | void mlxsw_sp_fid_rif_set(struct mlxsw_sp_fid *fid, struct mlxsw_sp_rif *rif); |
835 | struct mlxsw_sp_rif *mlxsw_sp_fid_rif(const struct mlxsw_sp_fid *fid); |
836 | enum mlxsw_sp_rif_type |
837 | mlxsw_sp_fid_type_rif_type(const struct mlxsw_sp *mlxsw_sp, |
838 | enum mlxsw_sp_fid_type type); |
839 | u16 mlxsw_sp_fid_8021q_vid(const struct mlxsw_sp_fid *fid); |
840 | struct mlxsw_sp_fid *mlxsw_sp_fid_8021q_get(struct mlxsw_sp *mlxsw_sp, u16 vid); |
841 | struct mlxsw_sp_fid *mlxsw_sp_fid_8021d_get(struct mlxsw_sp *mlxsw_sp, |
842 | int br_ifindex); |
843 | struct mlxsw_sp_fid *mlxsw_sp_fid_8021q_lookup(struct mlxsw_sp *mlxsw_sp, |
844 | u16 vid); |
845 | struct mlxsw_sp_fid *mlxsw_sp_fid_8021d_lookup(struct mlxsw_sp *mlxsw_sp, |
846 | int br_ifindex); |
847 | struct mlxsw_sp_fid *mlxsw_sp_fid_rfid_get(struct mlxsw_sp *mlxsw_sp, |
848 | u16 rif_index); |
849 | struct mlxsw_sp_fid *mlxsw_sp_fid_dummy_get(struct mlxsw_sp *mlxsw_sp); |
850 | void mlxsw_sp_fid_put(struct mlxsw_sp_fid *fid); |
851 | int mlxsw_sp_port_fids_init(struct mlxsw_sp_port *mlxsw_sp_port); |
852 | void mlxsw_sp_port_fids_fini(struct mlxsw_sp_port *mlxsw_sp_port); |
853 | int mlxsw_sp_fids_init(struct mlxsw_sp *mlxsw_sp); |
854 | void mlxsw_sp_fids_fini(struct mlxsw_sp *mlxsw_sp); |
855 | |
856 | /* spectrum_mr.c */ |
857 | enum mlxsw_sp_mr_route_prio { |
858 | MLXSW_SP_MR_ROUTE_PRIO_SG, |
859 | MLXSW_SP_MR_ROUTE_PRIO_STARG, |
860 | MLXSW_SP_MR_ROUTE_PRIO_CATCHALL, |
861 | __MLXSW_SP_MR_ROUTE_PRIO_MAX |
862 | }; |
863 | |
864 | #define MLXSW_SP_MR_ROUTE_PRIO_MAX (__MLXSW_SP_MR_ROUTE_PRIO_MAX - 1) |
865 | |
866 | struct mlxsw_sp_mr_route_key; |
867 | |
868 | struct mlxsw_sp_mr_tcam_ops { |
869 | size_t priv_size; |
870 | int (*init)(struct mlxsw_sp *mlxsw_sp, void *priv); |
871 | void (*fini)(void *priv); |
872 | size_t route_priv_size; |
873 | int (*route_create)(struct mlxsw_sp *mlxsw_sp, void *priv, |
874 | void *route_priv, |
875 | struct mlxsw_sp_mr_route_key *key, |
876 | struct mlxsw_afa_block *afa_block, |
877 | enum mlxsw_sp_mr_route_prio prio); |
878 | void (*route_destroy)(struct mlxsw_sp *mlxsw_sp, void *priv, |
879 | void *route_priv, |
880 | struct mlxsw_sp_mr_route_key *key); |
881 | int (*route_update)(struct mlxsw_sp *mlxsw_sp, void *route_priv, |
882 | struct mlxsw_sp_mr_route_key *key, |
883 | struct mlxsw_afa_block *afa_block); |
884 | }; |
885 | |
886 | /* spectrum1_mr_tcam.c */ |
887 | extern const struct mlxsw_sp_mr_tcam_ops mlxsw_sp1_mr_tcam_ops; |
888 | |
889 | /* spectrum2_mr_tcam.c */ |
890 | extern const struct mlxsw_sp_mr_tcam_ops mlxsw_sp2_mr_tcam_ops; |
891 | |
892 | /* spectrum_nve.c */ |
893 | struct mlxsw_sp_nve_params { |
894 | enum mlxsw_sp_nve_type type; |
895 | __be32 vni; |
896 | const struct net_device *dev; |
897 | }; |
898 | |
899 | extern const struct mlxsw_sp_nve_ops *mlxsw_sp1_nve_ops_arr[]; |
900 | extern const struct mlxsw_sp_nve_ops *mlxsw_sp2_nve_ops_arr[]; |
901 | |
902 | int mlxsw_sp_nve_learned_ip_resolve(struct mlxsw_sp *mlxsw_sp, u32 uip, |
903 | enum mlxsw_sp_l3proto proto, |
904 | union mlxsw_sp_l3addr *addr); |
905 | int mlxsw_sp_nve_flood_ip_add(struct mlxsw_sp *mlxsw_sp, |
906 | struct mlxsw_sp_fid *fid, |
907 | enum mlxsw_sp_l3proto proto, |
908 | union mlxsw_sp_l3addr *addr); |
909 | void mlxsw_sp_nve_flood_ip_del(struct mlxsw_sp *mlxsw_sp, |
910 | struct mlxsw_sp_fid *fid, |
911 | enum mlxsw_sp_l3proto proto, |
912 | union mlxsw_sp_l3addr *addr); |
913 | u32 mlxsw_sp_nve_decap_tunnel_index_get(const struct mlxsw_sp *mlxsw_sp); |
914 | bool mlxsw_sp_nve_ipv4_route_is_decap(const struct mlxsw_sp *mlxsw_sp, |
915 | u32 tb_id, __be32 addr); |
916 | int mlxsw_sp_nve_fid_enable(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_fid *fid, |
917 | struct mlxsw_sp_nve_params *params, |
918 | struct netlink_ext_ack *extack); |
919 | void mlxsw_sp_nve_fid_disable(struct mlxsw_sp *mlxsw_sp, |
920 | struct mlxsw_sp_fid *fid); |
921 | int mlxsw_sp_port_nve_init(struct mlxsw_sp_port *mlxsw_sp_port); |
922 | void mlxsw_sp_port_nve_fini(struct mlxsw_sp_port *mlxsw_sp_port); |
923 | int mlxsw_sp_nve_init(struct mlxsw_sp *mlxsw_sp); |
924 | void mlxsw_sp_nve_fini(struct mlxsw_sp *mlxsw_sp); |
925 | |
926 | #endif |
927 | |