2 * drivers/net/ethernet/mellanox/mlxsw/spectrum.h
3 * Copyright (c) 2015-2017 Mellanox Technologies. All rights reserved.
4 * Copyright (c) 2015-2017 Jiri Pirko <jiri@mellanox.com>
5 * Copyright (c) 2015 Ido Schimmel <idosch@mellanox.com>
6 * Copyright (c) 2015 Elad Raz <eladr@mellanox.com>
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are met:
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.
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.
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.
37 #ifndef _MLXSW_SPECTRUM_H
38 #define _MLXSW_SPECTRUM_H
40 #include <linux/types.h>
41 #include <linux/netdevice.h>
42 #include <linux/rhashtable.h>
43 #include <linux/bitops.h>
44 #include <linux/if_vlan.h>
45 #include <linux/list.h>
46 #include <linux/dcbnl.h>
47 #include <linux/in6.h>
48 #include <linux/notifier.h>
49 #include <net/psample.h>
50 #include <net/pkt_cls.h>
55 #include "core_acl_flex_keys.h"
56 #include "core_acl_flex_actions.h"
58 #define MLXSW_SP_FID_8021D_MAX 1024
60 #define MLXSW_SP_MID_MAX 7000
62 #define MLXSW_SP_PORTS_PER_CLUSTER_MAX 4
64 #define MLXSW_SP_PORT_BASE_SPEED 25000 /* Mb/s */
66 #define MLXSW_SP_KVD_LINEAR_SIZE 98304 /* entries */
67 #define MLXSW_SP_KVD_GRANULARITY 128
69 #define MLXSW_SP_RESOURCE_NAME_KVD "kvd"
70 #define MLXSW_SP_RESOURCE_NAME_KVD_LINEAR "linear"
71 #define MLXSW_SP_RESOURCE_NAME_KVD_HASH_SINGLE "hash_single"
72 #define MLXSW_SP_RESOURCE_NAME_KVD_HASH_DOUBLE "hash_double"
73 #define MLXSW_SP_RESOURCE_NAME_KVD_LINEAR_SINGLES "singles"
74 #define MLXSW_SP_RESOURCE_NAME_KVD_LINEAR_CHUNKS "chunks"
75 #define MLXSW_SP_RESOURCE_NAME_KVD_LINEAR_LARGE_CHUNKS "large_chunks"
77 enum mlxsw_sp_resource_id {
78 MLXSW_SP_RESOURCE_KVD,
79 MLXSW_SP_RESOURCE_KVD_LINEAR,
80 MLXSW_SP_RESOURCE_KVD_HASH_SINGLE,
81 MLXSW_SP_RESOURCE_KVD_HASH_DOUBLE,
82 MLXSW_SP_RESOURCE_KVD_LINEAR_SINGLE,
83 MLXSW_SP_RESOURCE_KVD_LINEAR_CHUNKS,
84 MLXSW_SP_RESOURCE_KVD_LINEAR_LARGE_CHUNKS,
89 struct mlxsw_sp_span_entry;
91 struct mlxsw_sp_upper {
92 struct net_device *dev;
93 unsigned int ref_count;
96 enum mlxsw_sp_rif_type {
97 MLXSW_SP_RIF_TYPE_SUBPORT,
98 MLXSW_SP_RIF_TYPE_VLAN,
99 MLXSW_SP_RIF_TYPE_FID,
100 MLXSW_SP_RIF_TYPE_IPIP_LB, /* IP-in-IP loopback. */
101 MLXSW_SP_RIF_TYPE_MAX,
104 enum mlxsw_sp_fid_type {
105 MLXSW_SP_FID_TYPE_8021Q,
106 MLXSW_SP_FID_TYPE_8021D,
107 MLXSW_SP_FID_TYPE_RFID,
108 MLXSW_SP_FID_TYPE_DUMMY,
109 MLXSW_SP_FID_TYPE_MAX,
112 struct mlxsw_sp_mid {
113 struct list_head list;
114 unsigned char addr[ETH_ALEN];
118 unsigned long *ports_in_mid; /* bits array */
121 enum mlxsw_sp_port_mall_action_type {
122 MLXSW_SP_PORT_MALL_MIRROR,
123 MLXSW_SP_PORT_MALL_SAMPLE,
126 struct mlxsw_sp_port_mall_mirror_tc_entry {
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;
136 struct mlxsw_sp_port_mall_mirror_tc_entry mirror;
141 struct mlxsw_sp_bridge;
142 struct mlxsw_sp_router;
145 struct mlxsw_sp_counter_pool;
146 struct mlxsw_sp_fid_core;
147 struct mlxsw_sp_kvdl;
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];
154 struct mlxsw_sp_upper *lags;
156 struct mlxsw_sp_sb *sb;
157 struct mlxsw_sp_bridge *bridge;
158 struct mlxsw_sp_router *router;
159 struct mlxsw_sp_mr *mr;
160 struct mlxsw_afa *afa;
161 struct mlxsw_sp_acl *acl;
162 struct mlxsw_sp_fid_core *fid_core;
163 struct mlxsw_sp_kvdl *kvdl;
164 struct notifier_block netdevice_nb;
166 struct mlxsw_sp_counter_pool *counter_pool;
168 struct mlxsw_sp_span_entry *entries;
173 static inline struct mlxsw_sp_upper *
174 mlxsw_sp_lag_get(struct mlxsw_sp *mlxsw_sp, u16 lag_id)
176 return &mlxsw_sp->lags[lag_id];
179 struct mlxsw_sp_port_pcpu_stats {
184 struct u64_stats_sync syncp;
188 struct mlxsw_sp_port_sample {
189 struct psample_group __rcu *psample_group;
195 struct mlxsw_sp_bridge_port;
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;
202 unsigned int ref_count;
204 struct mlxsw_sp_bridge_port *bridge_port;
205 struct list_head bridge_vlan_node;
208 /* No need an internal lock; At worse - miss a single periodic iteration */
209 struct mlxsw_sp_port_xstats {
211 u64 wred_drop[TC_MAX_QUEUE];
212 u64 tail_drop[TC_MAX_QUEUE];
213 u64 backlog[TC_MAX_QUEUE];
214 u64 tx_bytes[IEEE_8021QAZ_MAX_TCS];
215 u64 tx_packets[IEEE_8021QAZ_MAX_TCS];
218 struct mlxsw_sp_port {
219 struct net_device *dev;
220 struct mlxsw_sp_port_pcpu_stats __percpu *pcpu_stats;
221 struct mlxsw_sp *mlxsw_sp;
233 struct ieee_ets *ets;
234 struct ieee_maxrate *maxrate;
235 struct ieee_pfc *pfc;
243 struct list_head mall_tc_list;
245 #define MLXSW_HW_STATS_UPDATE_TIME HZ
246 struct rtnl_link_stats64 stats;
247 struct mlxsw_sp_port_xstats xstats;
248 struct delayed_work update_dw;
250 struct mlxsw_sp_port_sample *sample;
251 struct list_head vlans_list;
252 struct mlxsw_sp_qdisc *root_qdisc;
253 struct mlxsw_sp_qdisc *tclass_qdiscs;
254 unsigned acl_rule_count;
255 struct mlxsw_sp_acl_block *ing_acl_block;
256 struct mlxsw_sp_acl_block *eg_acl_block;
260 mlxsw_sp_port_is_pause_en(const struct mlxsw_sp_port *mlxsw_sp_port)
262 return mlxsw_sp_port->link.tx_pause || mlxsw_sp_port->link.rx_pause;
265 static inline struct mlxsw_sp_port *
266 mlxsw_sp_port_lagged_get(struct mlxsw_sp *mlxsw_sp, u16 lag_id, u8 port_index)
268 struct mlxsw_sp_port *mlxsw_sp_port;
271 local_port = mlxsw_core_lag_mapping_get(mlxsw_sp->core,
273 mlxsw_sp_port = mlxsw_sp->ports[local_port];
274 return mlxsw_sp_port && mlxsw_sp_port->lagged ? mlxsw_sp_port : NULL;
277 static inline struct mlxsw_sp_port_vlan *
278 mlxsw_sp_port_vlan_find_by_vid(const struct mlxsw_sp_port *mlxsw_sp_port,
281 struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan;
283 list_for_each_entry(mlxsw_sp_port_vlan, &mlxsw_sp_port->vlans_list,
285 if (mlxsw_sp_port_vlan->vid == vid)
286 return mlxsw_sp_port_vlan;
292 enum mlxsw_sp_flood_type {
293 MLXSW_SP_FLOOD_TYPE_UC,
294 MLXSW_SP_FLOOD_TYPE_BC,
295 MLXSW_SP_FLOOD_TYPE_MC,
298 /* spectrum_buffers.c */
299 int mlxsw_sp_buffers_init(struct mlxsw_sp *mlxsw_sp);
300 void mlxsw_sp_buffers_fini(struct mlxsw_sp *mlxsw_sp);
301 int mlxsw_sp_port_buffers_init(struct mlxsw_sp_port *mlxsw_sp_port);
302 int mlxsw_sp_sb_pool_get(struct mlxsw_core *mlxsw_core,
303 unsigned int sb_index, u16 pool_index,
304 struct devlink_sb_pool_info *pool_info);
305 int mlxsw_sp_sb_pool_set(struct mlxsw_core *mlxsw_core,
306 unsigned int sb_index, u16 pool_index, u32 size,
307 enum devlink_sb_threshold_type threshold_type);
308 int mlxsw_sp_sb_port_pool_get(struct mlxsw_core_port *mlxsw_core_port,
309 unsigned int sb_index, u16 pool_index,
311 int mlxsw_sp_sb_port_pool_set(struct mlxsw_core_port *mlxsw_core_port,
312 unsigned int sb_index, u16 pool_index,
314 int mlxsw_sp_sb_tc_pool_bind_get(struct mlxsw_core_port *mlxsw_core_port,
315 unsigned int sb_index, u16 tc_index,
316 enum devlink_sb_pool_type pool_type,
317 u16 *p_pool_index, u32 *p_threshold);
318 int mlxsw_sp_sb_tc_pool_bind_set(struct mlxsw_core_port *mlxsw_core_port,
319 unsigned int sb_index, u16 tc_index,
320 enum devlink_sb_pool_type pool_type,
321 u16 pool_index, u32 threshold);
322 int mlxsw_sp_sb_occ_snapshot(struct mlxsw_core *mlxsw_core,
323 unsigned int sb_index);
324 int mlxsw_sp_sb_occ_max_clear(struct mlxsw_core *mlxsw_core,
325 unsigned int sb_index);
326 int mlxsw_sp_sb_occ_port_pool_get(struct mlxsw_core_port *mlxsw_core_port,
327 unsigned int sb_index, u16 pool_index,
328 u32 *p_cur, u32 *p_max);
329 int mlxsw_sp_sb_occ_tc_port_bind_get(struct mlxsw_core_port *mlxsw_core_port,
330 unsigned int sb_index, u16 tc_index,
331 enum devlink_sb_pool_type pool_type,
332 u32 *p_cur, u32 *p_max);
333 u32 mlxsw_sp_cells_bytes(const struct mlxsw_sp *mlxsw_sp, u32 cells);
334 u32 mlxsw_sp_bytes_cells(const struct mlxsw_sp *mlxsw_sp, u32 bytes);
336 /* spectrum_switchdev.c */
337 int mlxsw_sp_switchdev_init(struct mlxsw_sp *mlxsw_sp);
338 void mlxsw_sp_switchdev_fini(struct mlxsw_sp *mlxsw_sp);
339 void mlxsw_sp_port_switchdev_init(struct mlxsw_sp_port *mlxsw_sp_port);
340 void mlxsw_sp_port_switchdev_fini(struct mlxsw_sp_port *mlxsw_sp_port);
341 int mlxsw_sp_rif_fdb_op(struct mlxsw_sp *mlxsw_sp, const char *mac, u16 fid,
344 mlxsw_sp_port_vlan_bridge_leave(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan);
345 int mlxsw_sp_port_bridge_join(struct mlxsw_sp_port *mlxsw_sp_port,
346 struct net_device *brport_dev,
347 struct net_device *br_dev,
348 struct netlink_ext_ack *extack);
349 void mlxsw_sp_port_bridge_leave(struct mlxsw_sp_port *mlxsw_sp_port,
350 struct net_device *brport_dev,
351 struct net_device *br_dev);
352 bool mlxsw_sp_bridge_device_is_offloaded(const struct mlxsw_sp *mlxsw_sp,
353 const struct net_device *br_dev);
356 int mlxsw_sp_port_ets_set(struct mlxsw_sp_port *mlxsw_sp_port,
357 enum mlxsw_reg_qeec_hr hr, u8 index, u8 next_index,
358 bool dwrr, u8 dwrr_weight);
359 int mlxsw_sp_port_prio_tc_set(struct mlxsw_sp_port *mlxsw_sp_port,
360 u8 switch_prio, u8 tclass);
361 int __mlxsw_sp_port_headroom_set(struct mlxsw_sp_port *mlxsw_sp_port, int mtu,
362 u8 *prio_tc, bool pause_en,
363 struct ieee_pfc *my_pfc);
364 int mlxsw_sp_port_ets_maxrate_set(struct mlxsw_sp_port *mlxsw_sp_port,
365 enum mlxsw_reg_qeec_hr hr, u8 index,
366 u8 next_index, u32 maxrate);
367 int mlxsw_sp_port_vid_stp_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid,
369 int mlxsw_sp_port_vp_mode_set(struct mlxsw_sp_port *mlxsw_sp_port, bool enable);
370 int mlxsw_sp_port_vid_learning_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid,
372 int mlxsw_sp_port_pvid_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid);
373 struct mlxsw_sp_port_vlan *
374 mlxsw_sp_port_vlan_get(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid);
375 void mlxsw_sp_port_vlan_put(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan);
376 int mlxsw_sp_port_vlan_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid_begin,
377 u16 vid_end, bool is_member, bool untagged);
378 int mlxsw_sp_flow_counter_get(struct mlxsw_sp *mlxsw_sp,
379 unsigned int counter_index, u64 *packets,
381 int mlxsw_sp_flow_counter_alloc(struct mlxsw_sp *mlxsw_sp,
382 unsigned int *p_counter_index);
383 void mlxsw_sp_flow_counter_free(struct mlxsw_sp *mlxsw_sp,
384 unsigned int counter_index);
385 bool mlxsw_sp_port_dev_check(const struct net_device *dev);
386 struct mlxsw_sp *mlxsw_sp_lower_get(struct net_device *dev);
387 struct mlxsw_sp_port *mlxsw_sp_port_dev_lower_find(struct net_device *dev);
388 struct mlxsw_sp_port *mlxsw_sp_port_lower_dev_hold(struct net_device *dev);
389 void mlxsw_sp_port_dev_put(struct mlxsw_sp_port *mlxsw_sp_port);
390 struct mlxsw_sp_port *mlxsw_sp_port_dev_lower_find_rcu(struct net_device *dev);
393 #ifdef CONFIG_MLXSW_SPECTRUM_DCB
394 int mlxsw_sp_port_dcb_init(struct mlxsw_sp_port *mlxsw_sp_port);
395 void mlxsw_sp_port_dcb_fini(struct mlxsw_sp_port *mlxsw_sp_port);
397 static inline int mlxsw_sp_port_dcb_init(struct mlxsw_sp_port *mlxsw_sp_port)
401 static inline void mlxsw_sp_port_dcb_fini(struct mlxsw_sp_port *mlxsw_sp_port)
405 /* spectrum_router.c */
406 int mlxsw_sp_router_init(struct mlxsw_sp *mlxsw_sp);
407 void mlxsw_sp_router_fini(struct mlxsw_sp *mlxsw_sp);
408 int mlxsw_sp_netdevice_router_port_event(struct net_device *dev);
409 int mlxsw_sp_inetaddr_event(struct notifier_block *unused,
410 unsigned long event, void *ptr);
411 int mlxsw_sp_inetaddr_valid_event(struct notifier_block *unused,
412 unsigned long event, void *ptr);
413 int mlxsw_sp_inet6addr_event(struct notifier_block *unused,
414 unsigned long event, void *ptr);
415 int mlxsw_sp_inet6addr_valid_event(struct notifier_block *unused,
416 unsigned long event, void *ptr);
417 int mlxsw_sp_netdevice_vrf_event(struct net_device *l3_dev, unsigned long event,
418 struct netdev_notifier_changeupper_info *info);
419 bool mlxsw_sp_netdev_is_ipip_ol(const struct mlxsw_sp *mlxsw_sp,
420 const struct net_device *dev);
421 bool mlxsw_sp_netdev_is_ipip_ul(const struct mlxsw_sp *mlxsw_sp,
422 const struct net_device *dev);
423 int mlxsw_sp_netdevice_ipip_ol_event(struct mlxsw_sp *mlxsw_sp,
424 struct net_device *l3_dev,
426 struct netdev_notifier_info *info);
428 mlxsw_sp_netdevice_ipip_ul_event(struct mlxsw_sp *mlxsw_sp,
429 struct net_device *l3_dev,
431 struct netdev_notifier_info *info);
433 mlxsw_sp_port_vlan_router_leave(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan);
434 void mlxsw_sp_rif_destroy(struct mlxsw_sp_rif *rif);
436 /* spectrum_kvdl.c */
437 int mlxsw_sp_kvdl_init(struct mlxsw_sp *mlxsw_sp);
438 void mlxsw_sp_kvdl_fini(struct mlxsw_sp *mlxsw_sp);
439 int mlxsw_sp_kvdl_alloc(struct mlxsw_sp *mlxsw_sp, unsigned int entry_count,
441 void mlxsw_sp_kvdl_free(struct mlxsw_sp *mlxsw_sp, int entry_index);
442 int mlxsw_sp_kvdl_alloc_size_query(struct mlxsw_sp *mlxsw_sp,
443 unsigned int entry_count,
444 unsigned int *p_alloc_size);
445 u64 mlxsw_sp_kvdl_occ_get(const struct mlxsw_sp *mlxsw_sp);
446 int mlxsw_sp_kvdl_resources_register(struct devlink *devlink);
448 struct mlxsw_sp_acl_rule_info {
449 unsigned int priority;
450 struct mlxsw_afk_element_values values;
451 struct mlxsw_afa_block *act_block;
452 unsigned int counter_index;
455 enum mlxsw_sp_acl_profile {
456 MLXSW_SP_ACL_PROFILE_FLOWER,
459 struct mlxsw_sp_acl_profile_ops {
460 size_t ruleset_priv_size;
461 int (*ruleset_add)(struct mlxsw_sp *mlxsw_sp,
462 void *priv, void *ruleset_priv);
463 void (*ruleset_del)(struct mlxsw_sp *mlxsw_sp, void *ruleset_priv);
464 int (*ruleset_bind)(struct mlxsw_sp *mlxsw_sp, void *ruleset_priv,
465 struct mlxsw_sp_port *mlxsw_sp_port,
467 void (*ruleset_unbind)(struct mlxsw_sp *mlxsw_sp, void *ruleset_priv,
468 struct mlxsw_sp_port *mlxsw_sp_port,
470 u16 (*ruleset_group_id)(void *ruleset_priv);
471 size_t rule_priv_size;
472 int (*rule_add)(struct mlxsw_sp *mlxsw_sp,
473 void *ruleset_priv, void *rule_priv,
474 struct mlxsw_sp_acl_rule_info *rulei);
475 void (*rule_del)(struct mlxsw_sp *mlxsw_sp, void *rule_priv);
476 int (*rule_activity_get)(struct mlxsw_sp *mlxsw_sp, void *rule_priv,
480 struct mlxsw_sp_acl_ops {
482 int (*init)(struct mlxsw_sp *mlxsw_sp, void *priv);
483 void (*fini)(struct mlxsw_sp *mlxsw_sp, void *priv);
484 const struct mlxsw_sp_acl_profile_ops *
485 (*profile_ops)(struct mlxsw_sp *mlxsw_sp,
486 enum mlxsw_sp_acl_profile profile);
489 struct mlxsw_sp_acl_block;
490 struct mlxsw_sp_acl_ruleset;
493 struct mlxsw_afk *mlxsw_sp_acl_afk(struct mlxsw_sp_acl *acl);
494 struct mlxsw_sp *mlxsw_sp_acl_block_mlxsw_sp(struct mlxsw_sp_acl_block *block);
495 unsigned int mlxsw_sp_acl_block_rule_count(struct mlxsw_sp_acl_block *block);
496 void mlxsw_sp_acl_block_disable_inc(struct mlxsw_sp_acl_block *block);
497 void mlxsw_sp_acl_block_disable_dec(struct mlxsw_sp_acl_block *block);
498 bool mlxsw_sp_acl_block_disabled(struct mlxsw_sp_acl_block *block);
499 struct mlxsw_sp_acl_block *mlxsw_sp_acl_block_create(struct mlxsw_sp *mlxsw_sp,
501 void mlxsw_sp_acl_block_destroy(struct mlxsw_sp_acl_block *block);
502 int mlxsw_sp_acl_block_bind(struct mlxsw_sp *mlxsw_sp,
503 struct mlxsw_sp_acl_block *block,
504 struct mlxsw_sp_port *mlxsw_sp_port,
506 int mlxsw_sp_acl_block_unbind(struct mlxsw_sp *mlxsw_sp,
507 struct mlxsw_sp_acl_block *block,
508 struct mlxsw_sp_port *mlxsw_sp_port,
510 struct mlxsw_sp_acl_ruleset *
511 mlxsw_sp_acl_ruleset_lookup(struct mlxsw_sp *mlxsw_sp,
512 struct mlxsw_sp_acl_block *block, u32 chain_index,
513 enum mlxsw_sp_acl_profile profile);
514 struct mlxsw_sp_acl_ruleset *
515 mlxsw_sp_acl_ruleset_get(struct mlxsw_sp *mlxsw_sp,
516 struct mlxsw_sp_acl_block *block, u32 chain_index,
517 enum mlxsw_sp_acl_profile profile);
518 void mlxsw_sp_acl_ruleset_put(struct mlxsw_sp *mlxsw_sp,
519 struct mlxsw_sp_acl_ruleset *ruleset);
520 u16 mlxsw_sp_acl_ruleset_group_id(struct mlxsw_sp_acl_ruleset *ruleset);
522 struct mlxsw_sp_acl_rule_info *
523 mlxsw_sp_acl_rulei_create(struct mlxsw_sp_acl *acl);
524 void mlxsw_sp_acl_rulei_destroy(struct mlxsw_sp_acl_rule_info *rulei);
525 int mlxsw_sp_acl_rulei_commit(struct mlxsw_sp_acl_rule_info *rulei);
526 void mlxsw_sp_acl_rulei_priority(struct mlxsw_sp_acl_rule_info *rulei,
527 unsigned int priority);
528 void mlxsw_sp_acl_rulei_keymask_u32(struct mlxsw_sp_acl_rule_info *rulei,
529 enum mlxsw_afk_element element,
530 u32 key_value, u32 mask_value);
531 void mlxsw_sp_acl_rulei_keymask_buf(struct mlxsw_sp_acl_rule_info *rulei,
532 enum mlxsw_afk_element element,
533 const char *key_value,
534 const char *mask_value, unsigned int len);
535 int mlxsw_sp_acl_rulei_act_continue(struct mlxsw_sp_acl_rule_info *rulei);
536 int mlxsw_sp_acl_rulei_act_jump(struct mlxsw_sp_acl_rule_info *rulei,
538 int mlxsw_sp_acl_rulei_act_drop(struct mlxsw_sp_acl_rule_info *rulei);
539 int mlxsw_sp_acl_rulei_act_trap(struct mlxsw_sp_acl_rule_info *rulei);
540 int mlxsw_sp_acl_rulei_act_mirror(struct mlxsw_sp *mlxsw_sp,
541 struct mlxsw_sp_acl_rule_info *rulei,
542 struct mlxsw_sp_acl_block *block,
543 struct net_device *out_dev);
544 int mlxsw_sp_acl_rulei_act_fwd(struct mlxsw_sp *mlxsw_sp,
545 struct mlxsw_sp_acl_rule_info *rulei,
546 struct net_device *out_dev);
547 int mlxsw_sp_acl_rulei_act_vlan(struct mlxsw_sp *mlxsw_sp,
548 struct mlxsw_sp_acl_rule_info *rulei,
549 u32 action, u16 vid, u16 proto, u8 prio);
550 int mlxsw_sp_acl_rulei_act_count(struct mlxsw_sp *mlxsw_sp,
551 struct mlxsw_sp_acl_rule_info *rulei);
552 int mlxsw_sp_acl_rulei_act_fid_set(struct mlxsw_sp *mlxsw_sp,
553 struct mlxsw_sp_acl_rule_info *rulei,
556 struct mlxsw_sp_acl_rule;
558 struct mlxsw_sp_acl_rule *
559 mlxsw_sp_acl_rule_create(struct mlxsw_sp *mlxsw_sp,
560 struct mlxsw_sp_acl_ruleset *ruleset,
561 unsigned long cookie);
562 void mlxsw_sp_acl_rule_destroy(struct mlxsw_sp *mlxsw_sp,
563 struct mlxsw_sp_acl_rule *rule);
564 int mlxsw_sp_acl_rule_add(struct mlxsw_sp *mlxsw_sp,
565 struct mlxsw_sp_acl_rule *rule);
566 void mlxsw_sp_acl_rule_del(struct mlxsw_sp *mlxsw_sp,
567 struct mlxsw_sp_acl_rule *rule);
568 struct mlxsw_sp_acl_rule *
569 mlxsw_sp_acl_rule_lookup(struct mlxsw_sp *mlxsw_sp,
570 struct mlxsw_sp_acl_ruleset *ruleset,
571 unsigned long cookie);
572 struct mlxsw_sp_acl_rule_info *
573 mlxsw_sp_acl_rule_rulei(struct mlxsw_sp_acl_rule *rule);
574 int mlxsw_sp_acl_rule_get_stats(struct mlxsw_sp *mlxsw_sp,
575 struct mlxsw_sp_acl_rule *rule,
576 u64 *packets, u64 *bytes, u64 *last_use);
578 struct mlxsw_sp_fid *mlxsw_sp_acl_dummy_fid(struct mlxsw_sp *mlxsw_sp);
580 int mlxsw_sp_acl_init(struct mlxsw_sp *mlxsw_sp);
581 void mlxsw_sp_acl_fini(struct mlxsw_sp *mlxsw_sp);
583 /* spectrum_acl_tcam.c */
584 extern const struct mlxsw_sp_acl_ops mlxsw_sp_acl_tcam_ops;
586 /* spectrum_flower.c */
587 int mlxsw_sp_flower_replace(struct mlxsw_sp *mlxsw_sp,
588 struct mlxsw_sp_acl_block *block,
589 struct tc_cls_flower_offload *f);
590 void mlxsw_sp_flower_destroy(struct mlxsw_sp *mlxsw_sp,
591 struct mlxsw_sp_acl_block *block,
592 struct tc_cls_flower_offload *f);
593 int mlxsw_sp_flower_stats(struct mlxsw_sp *mlxsw_sp,
594 struct mlxsw_sp_acl_block *block,
595 struct tc_cls_flower_offload *f);
597 /* spectrum_qdisc.c */
598 int mlxsw_sp_tc_qdisc_init(struct mlxsw_sp_port *mlxsw_sp_port);
599 void mlxsw_sp_tc_qdisc_fini(struct mlxsw_sp_port *mlxsw_sp_port);
600 int mlxsw_sp_setup_tc_red(struct mlxsw_sp_port *mlxsw_sp_port,
601 struct tc_red_qopt_offload *p);
602 int mlxsw_sp_setup_tc_prio(struct mlxsw_sp_port *mlxsw_sp_port,
603 struct tc_prio_qopt_offload *p);
606 int mlxsw_sp_fid_flood_set(struct mlxsw_sp_fid *fid,
607 enum mlxsw_sp_flood_type packet_type, u8 local_port,
609 int mlxsw_sp_fid_port_vid_map(struct mlxsw_sp_fid *fid,
610 struct mlxsw_sp_port *mlxsw_sp_port, u16 vid);
611 void mlxsw_sp_fid_port_vid_unmap(struct mlxsw_sp_fid *fid,
612 struct mlxsw_sp_port *mlxsw_sp_port, u16 vid);
613 enum mlxsw_sp_rif_type mlxsw_sp_fid_rif_type(const struct mlxsw_sp_fid *fid);
614 u16 mlxsw_sp_fid_index(const struct mlxsw_sp_fid *fid);
615 enum mlxsw_sp_fid_type mlxsw_sp_fid_type(const struct mlxsw_sp_fid *fid);
616 void mlxsw_sp_fid_rif_set(struct mlxsw_sp_fid *fid, struct mlxsw_sp_rif *rif);
617 enum mlxsw_sp_rif_type
618 mlxsw_sp_fid_type_rif_type(const struct mlxsw_sp *mlxsw_sp,
619 enum mlxsw_sp_fid_type type);
620 u16 mlxsw_sp_fid_8021q_vid(const struct mlxsw_sp_fid *fid);
621 struct mlxsw_sp_fid *mlxsw_sp_fid_8021q_get(struct mlxsw_sp *mlxsw_sp, u16 vid);
622 struct mlxsw_sp_fid *mlxsw_sp_fid_8021d_get(struct mlxsw_sp *mlxsw_sp,
624 struct mlxsw_sp_fid *mlxsw_sp_fid_rfid_get(struct mlxsw_sp *mlxsw_sp,
626 struct mlxsw_sp_fid *mlxsw_sp_fid_dummy_get(struct mlxsw_sp *mlxsw_sp);
627 void mlxsw_sp_fid_put(struct mlxsw_sp_fid *fid);
628 int mlxsw_sp_port_fids_init(struct mlxsw_sp_port *mlxsw_sp_port);
629 void mlxsw_sp_port_fids_fini(struct mlxsw_sp_port *mlxsw_sp_port);
630 int mlxsw_sp_fids_init(struct mlxsw_sp *mlxsw_sp);
631 void mlxsw_sp_fids_fini(struct mlxsw_sp *mlxsw_sp);