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"
74 enum mlxsw_sp_resource_id
{
75 MLXSW_SP_RESOURCE_KVD
,
76 MLXSW_SP_RESOURCE_KVD_LINEAR
,
77 MLXSW_SP_RESOURCE_KVD_HASH_SINGLE
,
78 MLXSW_SP_RESOURCE_KVD_HASH_DOUBLE
,
84 struct mlxsw_sp_upper
{
85 struct net_device
*dev
;
86 unsigned int ref_count
;
89 enum mlxsw_sp_rif_type
{
90 MLXSW_SP_RIF_TYPE_SUBPORT
,
91 MLXSW_SP_RIF_TYPE_VLAN
,
92 MLXSW_SP_RIF_TYPE_FID
,
93 MLXSW_SP_RIF_TYPE_IPIP_LB
, /* IP-in-IP loopback. */
94 MLXSW_SP_RIF_TYPE_MAX
,
97 enum mlxsw_sp_fid_type
{
98 MLXSW_SP_FID_TYPE_8021Q
,
99 MLXSW_SP_FID_TYPE_8021D
,
100 MLXSW_SP_FID_TYPE_RFID
,
101 MLXSW_SP_FID_TYPE_DUMMY
,
102 MLXSW_SP_FID_TYPE_MAX
,
105 struct mlxsw_sp_mid
{
106 struct list_head list
;
107 unsigned char addr
[ETH_ALEN
];
111 unsigned long *ports_in_mid
; /* bits array */
114 enum mlxsw_sp_span_type
{
115 MLXSW_SP_SPAN_EGRESS
,
116 MLXSW_SP_SPAN_INGRESS
119 struct mlxsw_sp_span_inspected_port
{
120 struct list_head list
;
121 enum mlxsw_sp_span_type type
;
125 struct mlxsw_sp_span_entry
{
128 struct list_head bound_ports_list
;
133 enum mlxsw_sp_port_mall_action_type
{
134 MLXSW_SP_PORT_MALL_MIRROR
,
135 MLXSW_SP_PORT_MALL_SAMPLE
,
138 struct mlxsw_sp_port_mall_mirror_tc_entry
{
143 struct mlxsw_sp_port_mall_tc_entry
{
144 struct list_head list
;
145 unsigned long cookie
;
146 enum mlxsw_sp_port_mall_action_type type
;
148 struct mlxsw_sp_port_mall_mirror_tc_entry mirror
;
153 struct mlxsw_sp_bridge
;
154 struct mlxsw_sp_router
;
157 struct mlxsw_sp_counter_pool
;
158 struct mlxsw_sp_fid_core
;
159 struct mlxsw_sp_kvdl
;
162 struct mlxsw_sp_port
**ports
;
163 struct mlxsw_core
*core
;
164 const struct mlxsw_bus_info
*bus_info
;
165 unsigned char base_mac
[ETH_ALEN
];
166 struct mlxsw_sp_upper
*lags
;
168 struct mlxsw_sp_sb
*sb
;
169 struct mlxsw_sp_bridge
*bridge
;
170 struct mlxsw_sp_router
*router
;
171 struct mlxsw_sp_mr
*mr
;
172 struct mlxsw_afa
*afa
;
173 struct mlxsw_sp_acl
*acl
;
174 struct mlxsw_sp_fid_core
*fid_core
;
175 struct mlxsw_sp_kvdl
*kvdl
;
176 struct notifier_block netdevice_nb
;
178 struct mlxsw_sp_counter_pool
*counter_pool
;
180 struct mlxsw_sp_span_entry
*entries
;
185 static inline struct mlxsw_sp_upper
*
186 mlxsw_sp_lag_get(struct mlxsw_sp
*mlxsw_sp
, u16 lag_id
)
188 return &mlxsw_sp
->lags
[lag_id
];
191 struct mlxsw_sp_port_pcpu_stats
{
196 struct u64_stats_sync syncp
;
200 struct mlxsw_sp_port_sample
{
201 struct psample_group __rcu
*psample_group
;
207 struct mlxsw_sp_bridge_port
;
210 struct mlxsw_sp_port_vlan
{
211 struct list_head list
;
212 struct mlxsw_sp_port
*mlxsw_sp_port
;
213 struct mlxsw_sp_fid
*fid
;
214 unsigned int ref_count
;
216 struct mlxsw_sp_bridge_port
*bridge_port
;
217 struct list_head bridge_vlan_node
;
220 /* No need an internal lock; At worse - miss a single periodic iteration */
221 struct mlxsw_sp_port_xstats
{
223 u64 wred_drop
[TC_MAX_QUEUE
];
224 u64 tail_drop
[TC_MAX_QUEUE
];
225 u64 backlog
[TC_MAX_QUEUE
];
228 struct mlxsw_sp_port
{
229 struct net_device
*dev
;
230 struct mlxsw_sp_port_pcpu_stats __percpu
*pcpu_stats
;
231 struct mlxsw_sp
*mlxsw_sp
;
243 struct ieee_ets
*ets
;
244 struct ieee_maxrate
*maxrate
;
245 struct ieee_pfc
*pfc
;
253 struct list_head mall_tc_list
;
255 #define MLXSW_HW_STATS_UPDATE_TIME HZ
256 struct rtnl_link_stats64 stats
;
257 struct mlxsw_sp_port_xstats xstats
;
258 struct delayed_work update_dw
;
260 struct mlxsw_sp_port_sample
*sample
;
261 struct list_head vlans_list
;
262 struct mlxsw_sp_qdisc
*root_qdisc
;
263 unsigned acl_rule_count
;
264 struct mlxsw_sp_acl_block
*ing_acl_block
;
265 struct mlxsw_sp_acl_block
*eg_acl_block
;
269 mlxsw_sp_port_is_pause_en(const struct mlxsw_sp_port
*mlxsw_sp_port
)
271 return mlxsw_sp_port
->link
.tx_pause
|| mlxsw_sp_port
->link
.rx_pause
;
274 static inline struct mlxsw_sp_port
*
275 mlxsw_sp_port_lagged_get(struct mlxsw_sp
*mlxsw_sp
, u16 lag_id
, u8 port_index
)
277 struct mlxsw_sp_port
*mlxsw_sp_port
;
280 local_port
= mlxsw_core_lag_mapping_get(mlxsw_sp
->core
,
282 mlxsw_sp_port
= mlxsw_sp
->ports
[local_port
];
283 return mlxsw_sp_port
&& mlxsw_sp_port
->lagged
? mlxsw_sp_port
: NULL
;
286 static inline struct mlxsw_sp_port_vlan
*
287 mlxsw_sp_port_vlan_find_by_vid(const struct mlxsw_sp_port
*mlxsw_sp_port
,
290 struct mlxsw_sp_port_vlan
*mlxsw_sp_port_vlan
;
292 list_for_each_entry(mlxsw_sp_port_vlan
, &mlxsw_sp_port
->vlans_list
,
294 if (mlxsw_sp_port_vlan
->vid
== vid
)
295 return mlxsw_sp_port_vlan
;
301 enum mlxsw_sp_flood_type
{
302 MLXSW_SP_FLOOD_TYPE_UC
,
303 MLXSW_SP_FLOOD_TYPE_BC
,
304 MLXSW_SP_FLOOD_TYPE_MC
,
307 /* spectrum_buffers.c */
308 int mlxsw_sp_buffers_init(struct mlxsw_sp
*mlxsw_sp
);
309 void mlxsw_sp_buffers_fini(struct mlxsw_sp
*mlxsw_sp
);
310 int mlxsw_sp_port_buffers_init(struct mlxsw_sp_port
*mlxsw_sp_port
);
311 int mlxsw_sp_sb_pool_get(struct mlxsw_core
*mlxsw_core
,
312 unsigned int sb_index
, u16 pool_index
,
313 struct devlink_sb_pool_info
*pool_info
);
314 int mlxsw_sp_sb_pool_set(struct mlxsw_core
*mlxsw_core
,
315 unsigned int sb_index
, u16 pool_index
, u32 size
,
316 enum devlink_sb_threshold_type threshold_type
);
317 int mlxsw_sp_sb_port_pool_get(struct mlxsw_core_port
*mlxsw_core_port
,
318 unsigned int sb_index
, u16 pool_index
,
320 int mlxsw_sp_sb_port_pool_set(struct mlxsw_core_port
*mlxsw_core_port
,
321 unsigned int sb_index
, u16 pool_index
,
323 int mlxsw_sp_sb_tc_pool_bind_get(struct mlxsw_core_port
*mlxsw_core_port
,
324 unsigned int sb_index
, u16 tc_index
,
325 enum devlink_sb_pool_type pool_type
,
326 u16
*p_pool_index
, u32
*p_threshold
);
327 int mlxsw_sp_sb_tc_pool_bind_set(struct mlxsw_core_port
*mlxsw_core_port
,
328 unsigned int sb_index
, u16 tc_index
,
329 enum devlink_sb_pool_type pool_type
,
330 u16 pool_index
, u32 threshold
);
331 int mlxsw_sp_sb_occ_snapshot(struct mlxsw_core
*mlxsw_core
,
332 unsigned int sb_index
);
333 int mlxsw_sp_sb_occ_max_clear(struct mlxsw_core
*mlxsw_core
,
334 unsigned int sb_index
);
335 int mlxsw_sp_sb_occ_port_pool_get(struct mlxsw_core_port
*mlxsw_core_port
,
336 unsigned int sb_index
, u16 pool_index
,
337 u32
*p_cur
, u32
*p_max
);
338 int mlxsw_sp_sb_occ_tc_port_bind_get(struct mlxsw_core_port
*mlxsw_core_port
,
339 unsigned int sb_index
, u16 tc_index
,
340 enum devlink_sb_pool_type pool_type
,
341 u32
*p_cur
, u32
*p_max
);
342 u32
mlxsw_sp_cells_bytes(const struct mlxsw_sp
*mlxsw_sp
, u32 cells
);
343 u32
mlxsw_sp_bytes_cells(const struct mlxsw_sp
*mlxsw_sp
, u32 bytes
);
345 /* spectrum_switchdev.c */
346 int mlxsw_sp_switchdev_init(struct mlxsw_sp
*mlxsw_sp
);
347 void mlxsw_sp_switchdev_fini(struct mlxsw_sp
*mlxsw_sp
);
348 void mlxsw_sp_port_switchdev_init(struct mlxsw_sp_port
*mlxsw_sp_port
);
349 void mlxsw_sp_port_switchdev_fini(struct mlxsw_sp_port
*mlxsw_sp_port
);
350 int mlxsw_sp_rif_fdb_op(struct mlxsw_sp
*mlxsw_sp
, const char *mac
, u16 fid
,
353 mlxsw_sp_port_vlan_bridge_leave(struct mlxsw_sp_port_vlan
*mlxsw_sp_port_vlan
);
354 int mlxsw_sp_port_bridge_join(struct mlxsw_sp_port
*mlxsw_sp_port
,
355 struct net_device
*brport_dev
,
356 struct net_device
*br_dev
,
357 struct netlink_ext_ack
*extack
);
358 void mlxsw_sp_port_bridge_leave(struct mlxsw_sp_port
*mlxsw_sp_port
,
359 struct net_device
*brport_dev
,
360 struct net_device
*br_dev
);
361 bool mlxsw_sp_bridge_device_is_offloaded(const struct mlxsw_sp
*mlxsw_sp
,
362 const struct net_device
*br_dev
);
365 int mlxsw_sp_port_ets_set(struct mlxsw_sp_port
*mlxsw_sp_port
,
366 enum mlxsw_reg_qeec_hr hr
, u8 index
, u8 next_index
,
367 bool dwrr
, u8 dwrr_weight
);
368 int mlxsw_sp_port_prio_tc_set(struct mlxsw_sp_port
*mlxsw_sp_port
,
369 u8 switch_prio
, u8 tclass
);
370 int __mlxsw_sp_port_headroom_set(struct mlxsw_sp_port
*mlxsw_sp_port
, int mtu
,
371 u8
*prio_tc
, bool pause_en
,
372 struct ieee_pfc
*my_pfc
);
373 int mlxsw_sp_port_ets_maxrate_set(struct mlxsw_sp_port
*mlxsw_sp_port
,
374 enum mlxsw_reg_qeec_hr hr
, u8 index
,
375 u8 next_index
, u32 maxrate
);
376 int mlxsw_sp_port_vid_stp_set(struct mlxsw_sp_port
*mlxsw_sp_port
, u16 vid
,
378 int mlxsw_sp_port_vp_mode_set(struct mlxsw_sp_port
*mlxsw_sp_port
, bool enable
);
379 int mlxsw_sp_port_vid_learning_set(struct mlxsw_sp_port
*mlxsw_sp_port
, u16 vid
,
381 int mlxsw_sp_port_pvid_set(struct mlxsw_sp_port
*mlxsw_sp_port
, u16 vid
);
382 struct mlxsw_sp_port_vlan
*
383 mlxsw_sp_port_vlan_get(struct mlxsw_sp_port
*mlxsw_sp_port
, u16 vid
);
384 void mlxsw_sp_port_vlan_put(struct mlxsw_sp_port_vlan
*mlxsw_sp_port_vlan
);
385 int mlxsw_sp_port_vlan_set(struct mlxsw_sp_port
*mlxsw_sp_port
, u16 vid_begin
,
386 u16 vid_end
, bool is_member
, bool untagged
);
387 int mlxsw_sp_flow_counter_get(struct mlxsw_sp
*mlxsw_sp
,
388 unsigned int counter_index
, u64
*packets
,
390 int mlxsw_sp_flow_counter_alloc(struct mlxsw_sp
*mlxsw_sp
,
391 unsigned int *p_counter_index
);
392 void mlxsw_sp_flow_counter_free(struct mlxsw_sp
*mlxsw_sp
,
393 unsigned int counter_index
);
394 bool mlxsw_sp_port_dev_check(const struct net_device
*dev
);
395 struct mlxsw_sp
*mlxsw_sp_lower_get(struct net_device
*dev
);
396 struct mlxsw_sp_port
*mlxsw_sp_port_dev_lower_find(struct net_device
*dev
);
397 struct mlxsw_sp_port
*mlxsw_sp_port_lower_dev_hold(struct net_device
*dev
);
398 void mlxsw_sp_port_dev_put(struct mlxsw_sp_port
*mlxsw_sp_port
);
399 struct mlxsw_sp_port
*mlxsw_sp_port_dev_lower_find_rcu(struct net_device
*dev
);
400 int mlxsw_sp_span_mirror_add(struct mlxsw_sp_port
*from
,
401 struct mlxsw_sp_port
*to
,
402 enum mlxsw_sp_span_type type
,
404 void mlxsw_sp_span_mirror_del(struct mlxsw_sp_port
*from
,
406 enum mlxsw_sp_span_type type
,
408 struct mlxsw_sp_span_entry
*
409 mlxsw_sp_span_entry_find(struct mlxsw_sp
*mlxsw_sp
, u8 local_port
);
412 #ifdef CONFIG_MLXSW_SPECTRUM_DCB
413 int mlxsw_sp_port_dcb_init(struct mlxsw_sp_port
*mlxsw_sp_port
);
414 void mlxsw_sp_port_dcb_fini(struct mlxsw_sp_port
*mlxsw_sp_port
);
416 static inline int mlxsw_sp_port_dcb_init(struct mlxsw_sp_port
*mlxsw_sp_port
)
420 static inline void mlxsw_sp_port_dcb_fini(struct mlxsw_sp_port
*mlxsw_sp_port
)
424 /* spectrum_router.c */
425 int mlxsw_sp_router_init(struct mlxsw_sp
*mlxsw_sp
);
426 void mlxsw_sp_router_fini(struct mlxsw_sp
*mlxsw_sp
);
427 int mlxsw_sp_netdevice_router_port_event(struct net_device
*dev
);
428 int mlxsw_sp_inetaddr_event(struct notifier_block
*unused
,
429 unsigned long event
, void *ptr
);
430 int mlxsw_sp_inetaddr_valid_event(struct notifier_block
*unused
,
431 unsigned long event
, void *ptr
);
432 int mlxsw_sp_inet6addr_event(struct notifier_block
*unused
,
433 unsigned long event
, void *ptr
);
434 int mlxsw_sp_inet6addr_valid_event(struct notifier_block
*unused
,
435 unsigned long event
, void *ptr
);
436 int mlxsw_sp_netdevice_vrf_event(struct net_device
*l3_dev
, unsigned long event
,
437 struct netdev_notifier_changeupper_info
*info
);
438 bool mlxsw_sp_netdev_is_ipip_ol(const struct mlxsw_sp
*mlxsw_sp
,
439 const struct net_device
*dev
);
440 bool mlxsw_sp_netdev_is_ipip_ul(const struct mlxsw_sp
*mlxsw_sp
,
441 const struct net_device
*dev
);
442 int mlxsw_sp_netdevice_ipip_ol_event(struct mlxsw_sp
*mlxsw_sp
,
443 struct net_device
*l3_dev
,
445 struct netdev_notifier_info
*info
);
447 mlxsw_sp_netdevice_ipip_ul_event(struct mlxsw_sp
*mlxsw_sp
,
448 struct net_device
*l3_dev
,
450 struct netdev_notifier_info
*info
);
452 mlxsw_sp_port_vlan_router_leave(struct mlxsw_sp_port_vlan
*mlxsw_sp_port_vlan
);
453 void mlxsw_sp_rif_destroy(struct mlxsw_sp_rif
*rif
);
455 /* spectrum_kvdl.c */
456 int mlxsw_sp_kvdl_init(struct mlxsw_sp
*mlxsw_sp
);
457 void mlxsw_sp_kvdl_fini(struct mlxsw_sp
*mlxsw_sp
);
458 int mlxsw_sp_kvdl_alloc(struct mlxsw_sp
*mlxsw_sp
, unsigned int entry_count
,
460 void mlxsw_sp_kvdl_free(struct mlxsw_sp
*mlxsw_sp
, int entry_index
);
461 int mlxsw_sp_kvdl_alloc_size_query(struct mlxsw_sp
*mlxsw_sp
,
462 unsigned int entry_count
,
463 unsigned int *p_alloc_size
);
464 u64
mlxsw_sp_kvdl_occ_get(const struct mlxsw_sp
*mlxsw_sp
);
466 struct mlxsw_sp_acl_rule_info
{
467 unsigned int priority
;
468 struct mlxsw_afk_element_values values
;
469 struct mlxsw_afa_block
*act_block
;
470 unsigned int counter_index
;
473 enum mlxsw_sp_acl_profile
{
474 MLXSW_SP_ACL_PROFILE_FLOWER
,
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 mlxsw_sp_port
*mlxsw_sp_port
,
485 void (*ruleset_unbind
)(struct mlxsw_sp
*mlxsw_sp
, void *ruleset_priv
,
486 struct mlxsw_sp_port
*mlxsw_sp_port
,
488 u16 (*ruleset_group_id
)(void *ruleset_priv
);
489 size_t rule_priv_size
;
490 int (*rule_add
)(struct mlxsw_sp
*mlxsw_sp
,
491 void *ruleset_priv
, void *rule_priv
,
492 struct mlxsw_sp_acl_rule_info
*rulei
);
493 void (*rule_del
)(struct mlxsw_sp
*mlxsw_sp
, void *rule_priv
);
494 int (*rule_activity_get
)(struct mlxsw_sp
*mlxsw_sp
, void *rule_priv
,
498 struct mlxsw_sp_acl_ops
{
500 int (*init
)(struct mlxsw_sp
*mlxsw_sp
, void *priv
);
501 void (*fini
)(struct mlxsw_sp
*mlxsw_sp
, void *priv
);
502 const struct mlxsw_sp_acl_profile_ops
*
503 (*profile_ops
)(struct mlxsw_sp
*mlxsw_sp
,
504 enum mlxsw_sp_acl_profile profile
);
507 struct mlxsw_sp_acl_block
;
508 struct mlxsw_sp_acl_ruleset
;
511 struct mlxsw_afk
*mlxsw_sp_acl_afk(struct mlxsw_sp_acl
*acl
);
512 struct mlxsw_sp
*mlxsw_sp_acl_block_mlxsw_sp(struct mlxsw_sp_acl_block
*block
);
513 unsigned int mlxsw_sp_acl_block_rule_count(struct mlxsw_sp_acl_block
*block
);
514 void mlxsw_sp_acl_block_disable_inc(struct mlxsw_sp_acl_block
*block
);
515 void mlxsw_sp_acl_block_disable_dec(struct mlxsw_sp_acl_block
*block
);
516 bool mlxsw_sp_acl_block_disabled(struct mlxsw_sp_acl_block
*block
);
517 struct mlxsw_sp_acl_block
*mlxsw_sp_acl_block_create(struct mlxsw_sp
*mlxsw_sp
,
519 void mlxsw_sp_acl_block_destroy(struct mlxsw_sp_acl_block
*block
);
520 int mlxsw_sp_acl_block_bind(struct mlxsw_sp
*mlxsw_sp
,
521 struct mlxsw_sp_acl_block
*block
,
522 struct mlxsw_sp_port
*mlxsw_sp_port
,
524 int mlxsw_sp_acl_block_unbind(struct mlxsw_sp
*mlxsw_sp
,
525 struct mlxsw_sp_acl_block
*block
,
526 struct mlxsw_sp_port
*mlxsw_sp_port
,
528 struct mlxsw_sp_acl_ruleset
*
529 mlxsw_sp_acl_ruleset_lookup(struct mlxsw_sp
*mlxsw_sp
,
530 struct mlxsw_sp_acl_block
*block
, u32 chain_index
,
531 enum mlxsw_sp_acl_profile profile
);
532 struct mlxsw_sp_acl_ruleset
*
533 mlxsw_sp_acl_ruleset_get(struct mlxsw_sp
*mlxsw_sp
,
534 struct mlxsw_sp_acl_block
*block
, u32 chain_index
,
535 enum mlxsw_sp_acl_profile profile
);
536 void mlxsw_sp_acl_ruleset_put(struct mlxsw_sp
*mlxsw_sp
,
537 struct mlxsw_sp_acl_ruleset
*ruleset
);
538 u16
mlxsw_sp_acl_ruleset_group_id(struct mlxsw_sp_acl_ruleset
*ruleset
);
540 struct mlxsw_sp_acl_rule_info
*
541 mlxsw_sp_acl_rulei_create(struct mlxsw_sp_acl
*acl
);
542 void mlxsw_sp_acl_rulei_destroy(struct mlxsw_sp_acl_rule_info
*rulei
);
543 int mlxsw_sp_acl_rulei_commit(struct mlxsw_sp_acl_rule_info
*rulei
);
544 void mlxsw_sp_acl_rulei_priority(struct mlxsw_sp_acl_rule_info
*rulei
,
545 unsigned int priority
);
546 void mlxsw_sp_acl_rulei_keymask_u32(struct mlxsw_sp_acl_rule_info
*rulei
,
547 enum mlxsw_afk_element element
,
548 u32 key_value
, u32 mask_value
);
549 void mlxsw_sp_acl_rulei_keymask_buf(struct mlxsw_sp_acl_rule_info
*rulei
,
550 enum mlxsw_afk_element element
,
551 const char *key_value
,
552 const char *mask_value
, unsigned int len
);
553 int mlxsw_sp_acl_rulei_act_continue(struct mlxsw_sp_acl_rule_info
*rulei
);
554 int mlxsw_sp_acl_rulei_act_jump(struct mlxsw_sp_acl_rule_info
*rulei
,
556 int mlxsw_sp_acl_rulei_act_drop(struct mlxsw_sp_acl_rule_info
*rulei
);
557 int mlxsw_sp_acl_rulei_act_trap(struct mlxsw_sp_acl_rule_info
*rulei
);
558 int mlxsw_sp_acl_rulei_act_mirror(struct mlxsw_sp
*mlxsw_sp
,
559 struct mlxsw_sp_acl_rule_info
*rulei
,
560 struct mlxsw_sp_acl_block
*block
,
561 struct net_device
*out_dev
);
562 int mlxsw_sp_acl_rulei_act_fwd(struct mlxsw_sp
*mlxsw_sp
,
563 struct mlxsw_sp_acl_rule_info
*rulei
,
564 struct net_device
*out_dev
);
565 int mlxsw_sp_acl_rulei_act_vlan(struct mlxsw_sp
*mlxsw_sp
,
566 struct mlxsw_sp_acl_rule_info
*rulei
,
567 u32 action
, u16 vid
, u16 proto
, u8 prio
);
568 int mlxsw_sp_acl_rulei_act_count(struct mlxsw_sp
*mlxsw_sp
,
569 struct mlxsw_sp_acl_rule_info
*rulei
);
570 int mlxsw_sp_acl_rulei_act_fid_set(struct mlxsw_sp
*mlxsw_sp
,
571 struct mlxsw_sp_acl_rule_info
*rulei
,
574 struct mlxsw_sp_acl_rule
;
576 struct mlxsw_sp_acl_rule
*
577 mlxsw_sp_acl_rule_create(struct mlxsw_sp
*mlxsw_sp
,
578 struct mlxsw_sp_acl_ruleset
*ruleset
,
579 unsigned long cookie
);
580 void mlxsw_sp_acl_rule_destroy(struct mlxsw_sp
*mlxsw_sp
,
581 struct mlxsw_sp_acl_rule
*rule
);
582 int mlxsw_sp_acl_rule_add(struct mlxsw_sp
*mlxsw_sp
,
583 struct mlxsw_sp_acl_rule
*rule
);
584 void mlxsw_sp_acl_rule_del(struct mlxsw_sp
*mlxsw_sp
,
585 struct mlxsw_sp_acl_rule
*rule
);
586 struct mlxsw_sp_acl_rule
*
587 mlxsw_sp_acl_rule_lookup(struct mlxsw_sp
*mlxsw_sp
,
588 struct mlxsw_sp_acl_ruleset
*ruleset
,
589 unsigned long cookie
);
590 struct mlxsw_sp_acl_rule_info
*
591 mlxsw_sp_acl_rule_rulei(struct mlxsw_sp_acl_rule
*rule
);
592 int mlxsw_sp_acl_rule_get_stats(struct mlxsw_sp
*mlxsw_sp
,
593 struct mlxsw_sp_acl_rule
*rule
,
594 u64
*packets
, u64
*bytes
, u64
*last_use
);
596 struct mlxsw_sp_fid
*mlxsw_sp_acl_dummy_fid(struct mlxsw_sp
*mlxsw_sp
);
598 int mlxsw_sp_acl_init(struct mlxsw_sp
*mlxsw_sp
);
599 void mlxsw_sp_acl_fini(struct mlxsw_sp
*mlxsw_sp
);
601 /* spectrum_acl_tcam.c */
602 extern const struct mlxsw_sp_acl_ops mlxsw_sp_acl_tcam_ops
;
604 /* spectrum_flower.c */
605 int mlxsw_sp_flower_replace(struct mlxsw_sp
*mlxsw_sp
,
606 struct mlxsw_sp_acl_block
*block
,
607 struct tc_cls_flower_offload
*f
);
608 void mlxsw_sp_flower_destroy(struct mlxsw_sp
*mlxsw_sp
,
609 struct mlxsw_sp_acl_block
*block
,
610 struct tc_cls_flower_offload
*f
);
611 int mlxsw_sp_flower_stats(struct mlxsw_sp
*mlxsw_sp
,
612 struct mlxsw_sp_acl_block
*block
,
613 struct tc_cls_flower_offload
*f
);
615 /* spectrum_qdisc.c */
616 int mlxsw_sp_tc_qdisc_init(struct mlxsw_sp_port
*mlxsw_sp_port
);
617 void mlxsw_sp_tc_qdisc_fini(struct mlxsw_sp_port
*mlxsw_sp_port
);
618 int mlxsw_sp_setup_tc_red(struct mlxsw_sp_port
*mlxsw_sp_port
,
619 struct tc_red_qopt_offload
*p
);
620 int mlxsw_sp_setup_tc_prio(struct mlxsw_sp_port
*mlxsw_sp_port
,
621 struct tc_prio_qopt_offload
*p
);
624 int mlxsw_sp_fid_flood_set(struct mlxsw_sp_fid
*fid
,
625 enum mlxsw_sp_flood_type packet_type
, u8 local_port
,
627 int mlxsw_sp_fid_port_vid_map(struct mlxsw_sp_fid
*fid
,
628 struct mlxsw_sp_port
*mlxsw_sp_port
, u16 vid
);
629 void mlxsw_sp_fid_port_vid_unmap(struct mlxsw_sp_fid
*fid
,
630 struct mlxsw_sp_port
*mlxsw_sp_port
, u16 vid
);
631 enum mlxsw_sp_rif_type
mlxsw_sp_fid_rif_type(const struct mlxsw_sp_fid
*fid
);
632 u16
mlxsw_sp_fid_index(const struct mlxsw_sp_fid
*fid
);
633 enum mlxsw_sp_fid_type
mlxsw_sp_fid_type(const struct mlxsw_sp_fid
*fid
);
634 void mlxsw_sp_fid_rif_set(struct mlxsw_sp_fid
*fid
, struct mlxsw_sp_rif
*rif
);
635 enum mlxsw_sp_rif_type
636 mlxsw_sp_fid_type_rif_type(const struct mlxsw_sp
*mlxsw_sp
,
637 enum mlxsw_sp_fid_type type
);
638 u16
mlxsw_sp_fid_8021q_vid(const struct mlxsw_sp_fid
*fid
);
639 struct mlxsw_sp_fid
*mlxsw_sp_fid_8021q_get(struct mlxsw_sp
*mlxsw_sp
, u16 vid
);
640 struct mlxsw_sp_fid
*mlxsw_sp_fid_8021d_get(struct mlxsw_sp
*mlxsw_sp
,
642 struct mlxsw_sp_fid
*mlxsw_sp_fid_rfid_get(struct mlxsw_sp
*mlxsw_sp
,
644 struct mlxsw_sp_fid
*mlxsw_sp_fid_dummy_get(struct mlxsw_sp
*mlxsw_sp
);
645 void mlxsw_sp_fid_put(struct mlxsw_sp_fid
*fid
);
646 int mlxsw_sp_port_fids_init(struct mlxsw_sp_port
*mlxsw_sp_port
);
647 void mlxsw_sp_port_fids_fini(struct mlxsw_sp_port
*mlxsw_sp_port
);
648 int mlxsw_sp_fids_init(struct mlxsw_sp
*mlxsw_sp
);
649 void mlxsw_sp_fids_fini(struct mlxsw_sp
*mlxsw_sp
);