xref: /openbmc/linux/drivers/net/ethernet/mellanox/mlxsw/spectrum.h (revision b24413180f5600bcb3bb70fbed5cf186b60864bd)
1 /*
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>
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>
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>
51 
52 #include "port.h"
53 #include "core.h"
54 #include "core_acl_flex_keys.h"
55 #include "core_acl_flex_actions.h"
56 
57 #define MLXSW_SP_FID_8021D_MAX 1024
58 
59 #define MLXSW_SP_MID_MAX 7000
60 
61 #define MLXSW_SP_PORTS_PER_CLUSTER_MAX 4
62 
63 #define MLXSW_SP_PORT_BASE_SPEED 25000	/* Mb/s */
64 
65 #define MLXSW_SP_KVD_LINEAR_SIZE 65536 /* entries */
66 #define MLXSW_SP_KVD_GRANULARITY 128
67 
68 struct mlxsw_sp_port;
69 struct mlxsw_sp_rif;
70 
71 struct mlxsw_sp_upper {
72 	struct net_device *dev;
73 	unsigned int ref_count;
74 };
75 
76 enum mlxsw_sp_rif_type {
77 	MLXSW_SP_RIF_TYPE_SUBPORT,
78 	MLXSW_SP_RIF_TYPE_VLAN,
79 	MLXSW_SP_RIF_TYPE_FID,
80 	MLXSW_SP_RIF_TYPE_IPIP_LB, /* IP-in-IP loopback. */
81 	MLXSW_SP_RIF_TYPE_MAX,
82 };
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 struct mlxsw_sp_mid {
93 	struct list_head list;
94 	unsigned char addr[ETH_ALEN];
95 	u16 fid;
96 	u16 mid;
97 	unsigned int ref_count;
98 };
99 
100 enum mlxsw_sp_span_type {
101 	MLXSW_SP_SPAN_EGRESS,
102 	MLXSW_SP_SPAN_INGRESS
103 };
104 
105 struct mlxsw_sp_span_inspected_port {
106 	struct list_head list;
107 	enum mlxsw_sp_span_type type;
108 	u8 local_port;
109 };
110 
111 struct mlxsw_sp_span_entry {
112 	u8 local_port;
113 	bool used;
114 	struct list_head bound_ports_list;
115 	int ref_count;
116 	int id;
117 };
118 
119 enum mlxsw_sp_port_mall_action_type {
120 	MLXSW_SP_PORT_MALL_MIRROR,
121 	MLXSW_SP_PORT_MALL_SAMPLE,
122 };
123 
124 struct mlxsw_sp_port_mall_mirror_tc_entry {
125 	u8 to_local_port;
126 	bool ingress;
127 };
128 
129 struct mlxsw_sp_port_mall_tc_entry {
130 	struct list_head list;
131 	unsigned long cookie;
132 	enum mlxsw_sp_port_mall_action_type type;
133 	union {
134 		struct mlxsw_sp_port_mall_mirror_tc_entry mirror;
135 	};
136 };
137 
138 struct mlxsw_sp_sb;
139 struct mlxsw_sp_bridge;
140 struct mlxsw_sp_router;
141 struct mlxsw_sp_acl;
142 struct mlxsw_sp_counter_pool;
143 struct mlxsw_sp_fid_core;
144 
145 struct mlxsw_sp {
146 	struct mlxsw_sp_port **ports;
147 	struct mlxsw_core *core;
148 	const struct mlxsw_bus_info *bus_info;
149 	unsigned char base_mac[ETH_ALEN];
150 	struct mlxsw_sp_upper *lags;
151 	u8 *port_to_module;
152 	struct mlxsw_sp_sb *sb;
153 	struct mlxsw_sp_bridge *bridge;
154 	struct mlxsw_sp_router *router;
155 	struct mlxsw_sp_acl *acl;
156 	struct mlxsw_sp_fid_core *fid_core;
157 	struct {
158 		DECLARE_BITMAP(usage, MLXSW_SP_KVD_LINEAR_SIZE);
159 	} kvdl;
160 
161 	struct mlxsw_sp_counter_pool *counter_pool;
162 	struct {
163 		struct mlxsw_sp_span_entry *entries;
164 		int entries_count;
165 	} span;
166 };
167 
168 static inline struct mlxsw_sp_upper *
169 mlxsw_sp_lag_get(struct mlxsw_sp *mlxsw_sp, u16 lag_id)
170 {
171 	return &mlxsw_sp->lags[lag_id];
172 }
173 
174 struct mlxsw_sp_port_pcpu_stats {
175 	u64			rx_packets;
176 	u64			rx_bytes;
177 	u64			tx_packets;
178 	u64			tx_bytes;
179 	struct u64_stats_sync	syncp;
180 	u32			tx_dropped;
181 };
182 
183 struct mlxsw_sp_port_sample {
184 	struct psample_group __rcu *psample_group;
185 	u32 trunc_size;
186 	u32 rate;
187 	bool truncate;
188 };
189 
190 struct mlxsw_sp_bridge_port;
191 struct mlxsw_sp_fid;
192 
193 struct mlxsw_sp_port_vlan {
194 	struct list_head list;
195 	struct mlxsw_sp_port *mlxsw_sp_port;
196 	struct mlxsw_sp_fid *fid;
197 	u16 vid;
198 	struct mlxsw_sp_bridge_port *bridge_port;
199 	struct list_head bridge_vlan_node;
200 };
201 
202 struct mlxsw_sp_port {
203 	struct net_device *dev;
204 	struct mlxsw_sp_port_pcpu_stats __percpu *pcpu_stats;
205 	struct mlxsw_sp *mlxsw_sp;
206 	u8 local_port;
207 	u8 lagged:1,
208 	   split:1;
209 	u16 pvid;
210 	u16 lag_id;
211 	struct {
212 		u8 tx_pause:1,
213 		   rx_pause:1,
214 		   autoneg:1;
215 	} link;
216 	struct {
217 		struct ieee_ets *ets;
218 		struct ieee_maxrate *maxrate;
219 		struct ieee_pfc *pfc;
220 	} dcb;
221 	struct {
222 		u8 module;
223 		u8 width;
224 		u8 lane;
225 	} mapping;
226 	/* TC handles */
227 	struct list_head mall_tc_list;
228 	struct {
229 		#define MLXSW_HW_STATS_UPDATE_TIME HZ
230 		struct rtnl_link_stats64 *cache;
231 		struct delayed_work update_dw;
232 	} hw_stats;
233 	struct mlxsw_sp_port_sample *sample;
234 	struct list_head vlans_list;
235 };
236 
237 static inline bool
238 mlxsw_sp_port_is_pause_en(const struct mlxsw_sp_port *mlxsw_sp_port)
239 {
240 	return mlxsw_sp_port->link.tx_pause || mlxsw_sp_port->link.rx_pause;
241 }
242 
243 static inline struct mlxsw_sp_port *
244 mlxsw_sp_port_lagged_get(struct mlxsw_sp *mlxsw_sp, u16 lag_id, u8 port_index)
245 {
246 	struct mlxsw_sp_port *mlxsw_sp_port;
247 	u8 local_port;
248 
249 	local_port = mlxsw_core_lag_mapping_get(mlxsw_sp->core,
250 						lag_id, port_index);
251 	mlxsw_sp_port = mlxsw_sp->ports[local_port];
252 	return mlxsw_sp_port && mlxsw_sp_port->lagged ? mlxsw_sp_port : NULL;
253 }
254 
255 static inline struct mlxsw_sp_port_vlan *
256 mlxsw_sp_port_vlan_find_by_vid(const struct mlxsw_sp_port *mlxsw_sp_port,
257 			       u16 vid)
258 {
259 	struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan;
260 
261 	list_for_each_entry(mlxsw_sp_port_vlan, &mlxsw_sp_port->vlans_list,
262 			    list) {
263 		if (mlxsw_sp_port_vlan->vid == vid)
264 			return mlxsw_sp_port_vlan;
265 	}
266 
267 	return NULL;
268 }
269 
270 enum mlxsw_sp_flood_type {
271 	MLXSW_SP_FLOOD_TYPE_UC,
272 	MLXSW_SP_FLOOD_TYPE_BC,
273 	MLXSW_SP_FLOOD_TYPE_MC,
274 };
275 
276 /* spectrum_buffers.c */
277 int mlxsw_sp_buffers_init(struct mlxsw_sp *mlxsw_sp);
278 void mlxsw_sp_buffers_fini(struct mlxsw_sp *mlxsw_sp);
279 int mlxsw_sp_port_buffers_init(struct mlxsw_sp_port *mlxsw_sp_port);
280 int mlxsw_sp_sb_pool_get(struct mlxsw_core *mlxsw_core,
281 			 unsigned int sb_index, u16 pool_index,
282 			 struct devlink_sb_pool_info *pool_info);
283 int mlxsw_sp_sb_pool_set(struct mlxsw_core *mlxsw_core,
284 			 unsigned int sb_index, u16 pool_index, u32 size,
285 			 enum devlink_sb_threshold_type threshold_type);
286 int mlxsw_sp_sb_port_pool_get(struct mlxsw_core_port *mlxsw_core_port,
287 			      unsigned int sb_index, u16 pool_index,
288 			      u32 *p_threshold);
289 int mlxsw_sp_sb_port_pool_set(struct mlxsw_core_port *mlxsw_core_port,
290 			      unsigned int sb_index, u16 pool_index,
291 			      u32 threshold);
292 int mlxsw_sp_sb_tc_pool_bind_get(struct mlxsw_core_port *mlxsw_core_port,
293 				 unsigned int sb_index, u16 tc_index,
294 				 enum devlink_sb_pool_type pool_type,
295 				 u16 *p_pool_index, u32 *p_threshold);
296 int mlxsw_sp_sb_tc_pool_bind_set(struct mlxsw_core_port *mlxsw_core_port,
297 				 unsigned int sb_index, u16 tc_index,
298 				 enum devlink_sb_pool_type pool_type,
299 				 u16 pool_index, u32 threshold);
300 int mlxsw_sp_sb_occ_snapshot(struct mlxsw_core *mlxsw_core,
301 			     unsigned int sb_index);
302 int mlxsw_sp_sb_occ_max_clear(struct mlxsw_core *mlxsw_core,
303 			      unsigned int sb_index);
304 int mlxsw_sp_sb_occ_port_pool_get(struct mlxsw_core_port *mlxsw_core_port,
305 				  unsigned int sb_index, u16 pool_index,
306 				  u32 *p_cur, u32 *p_max);
307 int mlxsw_sp_sb_occ_tc_port_bind_get(struct mlxsw_core_port *mlxsw_core_port,
308 				     unsigned int sb_index, u16 tc_index,
309 				     enum devlink_sb_pool_type pool_type,
310 				     u32 *p_cur, u32 *p_max);
311 u32 mlxsw_sp_cells_bytes(const struct mlxsw_sp *mlxsw_sp, u32 cells);
312 u32 mlxsw_sp_bytes_cells(const struct mlxsw_sp *mlxsw_sp, u32 bytes);
313 
314 /* spectrum_switchdev.c */
315 int mlxsw_sp_switchdev_init(struct mlxsw_sp *mlxsw_sp);
316 void mlxsw_sp_switchdev_fini(struct mlxsw_sp *mlxsw_sp);
317 void mlxsw_sp_port_switchdev_init(struct mlxsw_sp_port *mlxsw_sp_port);
318 void mlxsw_sp_port_switchdev_fini(struct mlxsw_sp_port *mlxsw_sp_port);
319 int mlxsw_sp_rif_fdb_op(struct mlxsw_sp *mlxsw_sp, const char *mac, u16 fid,
320 			bool adding);
321 void
322 mlxsw_sp_port_vlan_bridge_leave(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan);
323 int mlxsw_sp_port_bridge_join(struct mlxsw_sp_port *mlxsw_sp_port,
324 			      struct net_device *brport_dev,
325 			      struct net_device *br_dev);
326 void mlxsw_sp_port_bridge_leave(struct mlxsw_sp_port *mlxsw_sp_port,
327 				struct net_device *brport_dev,
328 				struct net_device *br_dev);
329 
330 /* spectrum.c */
331 int mlxsw_sp_port_ets_set(struct mlxsw_sp_port *mlxsw_sp_port,
332 			  enum mlxsw_reg_qeec_hr hr, u8 index, u8 next_index,
333 			  bool dwrr, u8 dwrr_weight);
334 int mlxsw_sp_port_prio_tc_set(struct mlxsw_sp_port *mlxsw_sp_port,
335 			      u8 switch_prio, u8 tclass);
336 int __mlxsw_sp_port_headroom_set(struct mlxsw_sp_port *mlxsw_sp_port, int mtu,
337 				 u8 *prio_tc, bool pause_en,
338 				 struct ieee_pfc *my_pfc);
339 int mlxsw_sp_port_ets_maxrate_set(struct mlxsw_sp_port *mlxsw_sp_port,
340 				  enum mlxsw_reg_qeec_hr hr, u8 index,
341 				  u8 next_index, u32 maxrate);
342 int mlxsw_sp_port_vid_stp_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid,
343 			      u8 state);
344 int mlxsw_sp_port_vp_mode_set(struct mlxsw_sp_port *mlxsw_sp_port, bool enable);
345 int mlxsw_sp_port_vid_learning_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid,
346 				   bool learn_enable);
347 int mlxsw_sp_port_pvid_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid);
348 struct mlxsw_sp_port_vlan *
349 mlxsw_sp_port_vlan_get(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid);
350 void mlxsw_sp_port_vlan_put(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan);
351 int mlxsw_sp_port_vlan_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid_begin,
352 			   u16 vid_end, bool is_member, bool untagged);
353 int mlxsw_sp_flow_counter_get(struct mlxsw_sp *mlxsw_sp,
354 			      unsigned int counter_index, u64 *packets,
355 			      u64 *bytes);
356 int mlxsw_sp_flow_counter_alloc(struct mlxsw_sp *mlxsw_sp,
357 				unsigned int *p_counter_index);
358 void mlxsw_sp_flow_counter_free(struct mlxsw_sp *mlxsw_sp,
359 				unsigned int counter_index);
360 bool mlxsw_sp_port_dev_check(const struct net_device *dev);
361 struct mlxsw_sp *mlxsw_sp_lower_get(struct net_device *dev);
362 struct mlxsw_sp_port *mlxsw_sp_port_dev_lower_find(struct net_device *dev);
363 struct mlxsw_sp_port *mlxsw_sp_port_lower_dev_hold(struct net_device *dev);
364 void mlxsw_sp_port_dev_put(struct mlxsw_sp_port *mlxsw_sp_port);
365 struct mlxsw_sp_port *mlxsw_sp_port_dev_lower_find_rcu(struct net_device *dev);
366 
367 /* spectrum_dcb.c */
368 #ifdef CONFIG_MLXSW_SPECTRUM_DCB
369 int mlxsw_sp_port_dcb_init(struct mlxsw_sp_port *mlxsw_sp_port);
370 void mlxsw_sp_port_dcb_fini(struct mlxsw_sp_port *mlxsw_sp_port);
371 #else
372 static inline int mlxsw_sp_port_dcb_init(struct mlxsw_sp_port *mlxsw_sp_port)
373 {
374 	return 0;
375 }
376 static inline void mlxsw_sp_port_dcb_fini(struct mlxsw_sp_port *mlxsw_sp_port)
377 {}
378 #endif
379 
380 /* spectrum_router.c */
381 int mlxsw_sp_router_init(struct mlxsw_sp *mlxsw_sp);
382 void mlxsw_sp_router_fini(struct mlxsw_sp *mlxsw_sp);
383 int mlxsw_sp_router_netevent_event(struct notifier_block *unused,
384 				   unsigned long event, void *ptr);
385 int mlxsw_sp_netdevice_router_port_event(struct net_device *dev);
386 int mlxsw_sp_inetaddr_event(struct notifier_block *unused,
387 			    unsigned long event, void *ptr);
388 int mlxsw_sp_inet6addr_event(struct notifier_block *unused,
389 			     unsigned long event, void *ptr);
390 int mlxsw_sp_netdevice_vrf_event(struct net_device *l3_dev, unsigned long event,
391 				 struct netdev_notifier_changeupper_info *info);
392 void
393 mlxsw_sp_port_vlan_router_leave(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan);
394 void mlxsw_sp_rif_destroy(struct mlxsw_sp_rif *rif);
395 
396 /* spectrum_kvdl.c */
397 int mlxsw_sp_kvdl_alloc(struct mlxsw_sp *mlxsw_sp, unsigned int entry_count,
398 			u32 *p_entry_index);
399 void mlxsw_sp_kvdl_free(struct mlxsw_sp *mlxsw_sp, int entry_index);
400 
401 struct mlxsw_sp_acl_rule_info {
402 	unsigned int priority;
403 	struct mlxsw_afk_element_values values;
404 	struct mlxsw_afa_block *act_block;
405 	unsigned int counter_index;
406 	bool counter_valid;
407 };
408 
409 enum mlxsw_sp_acl_profile {
410 	MLXSW_SP_ACL_PROFILE_FLOWER,
411 };
412 
413 struct mlxsw_sp_acl_profile_ops {
414 	size_t ruleset_priv_size;
415 	int (*ruleset_add)(struct mlxsw_sp *mlxsw_sp,
416 			   void *priv, void *ruleset_priv);
417 	void (*ruleset_del)(struct mlxsw_sp *mlxsw_sp, void *ruleset_priv);
418 	int (*ruleset_bind)(struct mlxsw_sp *mlxsw_sp, void *ruleset_priv,
419 			    struct net_device *dev, bool ingress);
420 	void (*ruleset_unbind)(struct mlxsw_sp *mlxsw_sp, void *ruleset_priv);
421 	u16 (*ruleset_group_id)(void *ruleset_priv);
422 	size_t rule_priv_size;
423 	int (*rule_add)(struct mlxsw_sp *mlxsw_sp,
424 			void *ruleset_priv, void *rule_priv,
425 			struct mlxsw_sp_acl_rule_info *rulei);
426 	void (*rule_del)(struct mlxsw_sp *mlxsw_sp, void *rule_priv);
427 	int (*rule_activity_get)(struct mlxsw_sp *mlxsw_sp, void *rule_priv,
428 				 bool *activity);
429 };
430 
431 struct mlxsw_sp_acl_ops {
432 	size_t priv_size;
433 	int (*init)(struct mlxsw_sp *mlxsw_sp, void *priv);
434 	void (*fini)(struct mlxsw_sp *mlxsw_sp, void *priv);
435 	const struct mlxsw_sp_acl_profile_ops *
436 			(*profile_ops)(struct mlxsw_sp *mlxsw_sp,
437 				       enum mlxsw_sp_acl_profile profile);
438 };
439 
440 struct mlxsw_sp_acl_ruleset;
441 
442 /* spectrum_acl.c */
443 struct mlxsw_afk *mlxsw_sp_acl_afk(struct mlxsw_sp_acl *acl);
444 struct mlxsw_sp_acl_ruleset *
445 mlxsw_sp_acl_ruleset_lookup(struct mlxsw_sp *mlxsw_sp, struct net_device *dev,
446 			    bool ingress, u32 chain_index,
447 			    enum mlxsw_sp_acl_profile profile);
448 struct mlxsw_sp_acl_ruleset *
449 mlxsw_sp_acl_ruleset_get(struct mlxsw_sp *mlxsw_sp, struct net_device *dev,
450 			 bool ingress, u32 chain_index,
451 			 enum mlxsw_sp_acl_profile profile);
452 void mlxsw_sp_acl_ruleset_put(struct mlxsw_sp *mlxsw_sp,
453 			      struct mlxsw_sp_acl_ruleset *ruleset);
454 u16 mlxsw_sp_acl_ruleset_group_id(struct mlxsw_sp_acl_ruleset *ruleset);
455 
456 struct mlxsw_sp_acl_rule_info *
457 mlxsw_sp_acl_rulei_create(struct mlxsw_sp_acl *acl);
458 void mlxsw_sp_acl_rulei_destroy(struct mlxsw_sp_acl_rule_info *rulei);
459 int mlxsw_sp_acl_rulei_commit(struct mlxsw_sp_acl_rule_info *rulei);
460 void mlxsw_sp_acl_rulei_priority(struct mlxsw_sp_acl_rule_info *rulei,
461 				 unsigned int priority);
462 void mlxsw_sp_acl_rulei_keymask_u32(struct mlxsw_sp_acl_rule_info *rulei,
463 				    enum mlxsw_afk_element element,
464 				    u32 key_value, u32 mask_value);
465 void mlxsw_sp_acl_rulei_keymask_buf(struct mlxsw_sp_acl_rule_info *rulei,
466 				    enum mlxsw_afk_element element,
467 				    const char *key_value,
468 				    const char *mask_value, unsigned int len);
469 void mlxsw_sp_acl_rulei_act_continue(struct mlxsw_sp_acl_rule_info *rulei);
470 void mlxsw_sp_acl_rulei_act_jump(struct mlxsw_sp_acl_rule_info *rulei,
471 				 u16 group_id);
472 int mlxsw_sp_acl_rulei_act_drop(struct mlxsw_sp_acl_rule_info *rulei);
473 int mlxsw_sp_acl_rulei_act_trap(struct mlxsw_sp_acl_rule_info *rulei);
474 int mlxsw_sp_acl_rulei_act_fwd(struct mlxsw_sp *mlxsw_sp,
475 			       struct mlxsw_sp_acl_rule_info *rulei,
476 			       struct net_device *out_dev);
477 int mlxsw_sp_acl_rulei_act_vlan(struct mlxsw_sp *mlxsw_sp,
478 				struct mlxsw_sp_acl_rule_info *rulei,
479 				u32 action, u16 vid, u16 proto, u8 prio);
480 int mlxsw_sp_acl_rulei_act_count(struct mlxsw_sp *mlxsw_sp,
481 				 struct mlxsw_sp_acl_rule_info *rulei);
482 int mlxsw_sp_acl_rulei_act_fid_set(struct mlxsw_sp *mlxsw_sp,
483 				   struct mlxsw_sp_acl_rule_info *rulei,
484 				   u16 fid);
485 
486 struct mlxsw_sp_acl_rule;
487 
488 struct mlxsw_sp_acl_rule *
489 mlxsw_sp_acl_rule_create(struct mlxsw_sp *mlxsw_sp,
490 			 struct mlxsw_sp_acl_ruleset *ruleset,
491 			 unsigned long cookie);
492 void mlxsw_sp_acl_rule_destroy(struct mlxsw_sp *mlxsw_sp,
493 			       struct mlxsw_sp_acl_rule *rule);
494 int mlxsw_sp_acl_rule_add(struct mlxsw_sp *mlxsw_sp,
495 			  struct mlxsw_sp_acl_rule *rule);
496 void mlxsw_sp_acl_rule_del(struct mlxsw_sp *mlxsw_sp,
497 			   struct mlxsw_sp_acl_rule *rule);
498 struct mlxsw_sp_acl_rule *
499 mlxsw_sp_acl_rule_lookup(struct mlxsw_sp *mlxsw_sp,
500 			 struct mlxsw_sp_acl_ruleset *ruleset,
501 			 unsigned long cookie);
502 struct mlxsw_sp_acl_rule_info *
503 mlxsw_sp_acl_rule_rulei(struct mlxsw_sp_acl_rule *rule);
504 int mlxsw_sp_acl_rule_get_stats(struct mlxsw_sp *mlxsw_sp,
505 				struct mlxsw_sp_acl_rule *rule,
506 				u64 *packets, u64 *bytes, u64 *last_use);
507 
508 struct mlxsw_sp_fid *mlxsw_sp_acl_dummy_fid(struct mlxsw_sp *mlxsw_sp);
509 
510 int mlxsw_sp_acl_init(struct mlxsw_sp *mlxsw_sp);
511 void mlxsw_sp_acl_fini(struct mlxsw_sp *mlxsw_sp);
512 
513 /* spectrum_acl_tcam.c */
514 extern const struct mlxsw_sp_acl_ops mlxsw_sp_acl_tcam_ops;
515 
516 /* spectrum_flower.c */
517 int mlxsw_sp_flower_replace(struct mlxsw_sp_port *mlxsw_sp_port, bool ingress,
518 			    struct tc_cls_flower_offload *f);
519 void mlxsw_sp_flower_destroy(struct mlxsw_sp_port *mlxsw_sp_port, bool ingress,
520 			     struct tc_cls_flower_offload *f);
521 int mlxsw_sp_flower_stats(struct mlxsw_sp_port *mlxsw_sp_port, bool ingress,
522 			  struct tc_cls_flower_offload *f);
523 
524 /* spectrum_fid.c */
525 int mlxsw_sp_fid_flood_set(struct mlxsw_sp_fid *fid,
526 			   enum mlxsw_sp_flood_type packet_type, u8 local_port,
527 			   bool member);
528 int mlxsw_sp_fid_port_vid_map(struct mlxsw_sp_fid *fid,
529 			      struct mlxsw_sp_port *mlxsw_sp_port, u16 vid);
530 void mlxsw_sp_fid_port_vid_unmap(struct mlxsw_sp_fid *fid,
531 				 struct mlxsw_sp_port *mlxsw_sp_port, u16 vid);
532 enum mlxsw_sp_rif_type mlxsw_sp_fid_rif_type(const struct mlxsw_sp_fid *fid);
533 u16 mlxsw_sp_fid_index(const struct mlxsw_sp_fid *fid);
534 enum mlxsw_sp_fid_type mlxsw_sp_fid_type(const struct mlxsw_sp_fid *fid);
535 void mlxsw_sp_fid_rif_set(struct mlxsw_sp_fid *fid, struct mlxsw_sp_rif *rif);
536 enum mlxsw_sp_rif_type
537 mlxsw_sp_fid_type_rif_type(const struct mlxsw_sp *mlxsw_sp,
538 			   enum mlxsw_sp_fid_type type);
539 u16 mlxsw_sp_fid_8021q_vid(const struct mlxsw_sp_fid *fid);
540 struct mlxsw_sp_fid *mlxsw_sp_fid_8021q_get(struct mlxsw_sp *mlxsw_sp, u16 vid);
541 struct mlxsw_sp_fid *mlxsw_sp_fid_8021d_get(struct mlxsw_sp *mlxsw_sp,
542 					    int br_ifindex);
543 struct mlxsw_sp_fid *mlxsw_sp_fid_rfid_get(struct mlxsw_sp *mlxsw_sp,
544 					   u16 rif_index);
545 struct mlxsw_sp_fid *mlxsw_sp_fid_dummy_get(struct mlxsw_sp *mlxsw_sp);
546 void mlxsw_sp_fid_put(struct mlxsw_sp_fid *fid);
547 int mlxsw_sp_port_fids_init(struct mlxsw_sp_port *mlxsw_sp_port);
548 void mlxsw_sp_port_fids_fini(struct mlxsw_sp_port *mlxsw_sp_port);
549 int mlxsw_sp_fids_init(struct mlxsw_sp *mlxsw_sp);
550 void mlxsw_sp_fids_fini(struct mlxsw_sp *mlxsw_sp);
551 
552 #endif
553