1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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#include <net/red.h>
52
53#include "port.h"
54#include "core.h"
55#include "core_acl_flex_keys.h"
56#include "core_acl_flex_actions.h"
57
58#define MLXSW_SP_FID_8021D_MAX 1024
59
60#define MLXSW_SP_MID_MAX 7000
61
62#define MLXSW_SP_PORTS_PER_CLUSTER_MAX 4
63
64#define MLXSW_SP_PORT_BASE_SPEED 25000
65
66#define MLXSW_SP_KVD_LINEAR_SIZE 98304
67#define MLXSW_SP_KVD_GRANULARITY 128
68
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"
76
77enum mlxsw_sp_resource_id {
78 MLXSW_SP_RESOURCE_KVD = 1,
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,
85};
86
87struct mlxsw_sp_port;
88struct mlxsw_sp_rif;
89struct mlxsw_sp_span_entry;
90
91struct mlxsw_sp_upper {
92 struct net_device *dev;
93 unsigned int ref_count;
94};
95
96enum 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,
101 MLXSW_SP_RIF_TYPE_MAX,
102};
103
104enum 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,
110};
111
112struct mlxsw_sp_mid {
113 struct list_head list;
114 unsigned char addr[ETH_ALEN];
115 u16 fid;
116 u16 mid;
117 bool in_hw;
118 unsigned long *ports_in_mid;
119};
120
121enum mlxsw_sp_port_mall_action_type {
122 MLXSW_SP_PORT_MALL_MIRROR,
123 MLXSW_SP_PORT_MALL_SAMPLE,
124};
125
126struct mlxsw_sp_port_mall_mirror_tc_entry {
127 int span_id;
128 bool ingress;
129};
130
131struct mlxsw_sp_port_mall_tc_entry {
132 struct list_head list;
133 unsigned long cookie;
134 enum mlxsw_sp_port_mall_action_type type;
135 union {
136 struct mlxsw_sp_port_mall_mirror_tc_entry mirror;
137 };
138};
139
140struct mlxsw_sp_sb;
141struct mlxsw_sp_bridge;
142struct mlxsw_sp_router;
143struct mlxsw_sp_mr;
144struct mlxsw_sp_acl;
145struct mlxsw_sp_counter_pool;
146struct mlxsw_sp_fid_core;
147struct mlxsw_sp_kvdl;
148
149struct mlxsw_sp {
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;
155 int *port_to_module;
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;
165
166 struct mlxsw_sp_counter_pool *counter_pool;
167 struct {
168 struct mlxsw_sp_span_entry *entries;
169 int entries_count;
170 } span;
171};
172
173static inline struct mlxsw_sp_upper *
174mlxsw_sp_lag_get(struct mlxsw_sp *mlxsw_sp, u16 lag_id)
175{
176 return &mlxsw_sp->lags[lag_id];
177}
178
179struct mlxsw_sp_port_pcpu_stats {
180 u64 rx_packets;
181 u64 rx_bytes;
182 u64 tx_packets;
183 u64 tx_bytes;
184 struct u64_stats_sync syncp;
185 u32 tx_dropped;
186};
187
188struct mlxsw_sp_port_sample {
189 struct psample_group __rcu *psample_group;
190 u32 trunc_size;
191 u32 rate;
192 bool truncate;
193};
194
195struct mlxsw_sp_bridge_port;
196struct mlxsw_sp_fid;
197
198struct 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;
203 u16 vid;
204 struct mlxsw_sp_bridge_port *bridge_port;
205 struct list_head bridge_vlan_node;
206};
207
208
209struct mlxsw_sp_port_xstats {
210 u64 ecn;
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];
216};
217
218struct mlxsw_sp_port {
219 struct net_device *dev;
220 struct mlxsw_sp_port_pcpu_stats __percpu *pcpu_stats;
221 struct mlxsw_sp *mlxsw_sp;
222 u8 local_port;
223 u8 lagged:1,
224 split:1;
225 u16 pvid;
226 u16 lag_id;
227 struct {
228 u8 tx_pause:1,
229 rx_pause:1,
230 autoneg:1;
231 } link;
232 struct {
233 struct ieee_ets *ets;
234 struct ieee_maxrate *maxrate;
235 struct ieee_pfc *pfc;
236 } dcb;
237 struct {
238 u8 module;
239 u8 width;
240 u8 lane;
241 } mapping;
242
243 struct list_head mall_tc_list;
244 struct {
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;
249 } periodic_hw_stats;
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;
257};
258
259static inline bool
260mlxsw_sp_port_is_pause_en(const struct mlxsw_sp_port *mlxsw_sp_port)
261{
262 return mlxsw_sp_port->link.tx_pause || mlxsw_sp_port->link.rx_pause;
263}
264
265static inline struct mlxsw_sp_port *
266mlxsw_sp_port_lagged_get(struct mlxsw_sp *mlxsw_sp, u16 lag_id, u8 port_index)
267{
268 struct mlxsw_sp_port *mlxsw_sp_port;
269 u8 local_port;
270
271 local_port = mlxsw_core_lag_mapping_get(mlxsw_sp->core,
272 lag_id, port_index);
273 mlxsw_sp_port = mlxsw_sp->ports[local_port];
274 return mlxsw_sp_port && mlxsw_sp_port->lagged ? mlxsw_sp_port : NULL;
275}
276
277static inline struct mlxsw_sp_port_vlan *
278mlxsw_sp_port_vlan_find_by_vid(const struct mlxsw_sp_port *mlxsw_sp_port,
279 u16 vid)
280{
281 struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan;
282
283 list_for_each_entry(mlxsw_sp_port_vlan, &mlxsw_sp_port->vlans_list,
284 list) {
285 if (mlxsw_sp_port_vlan->vid == vid)
286 return mlxsw_sp_port_vlan;
287 }
288
289 return NULL;
290}
291
292enum mlxsw_sp_flood_type {
293 MLXSW_SP_FLOOD_TYPE_UC,
294 MLXSW_SP_FLOOD_TYPE_BC,
295 MLXSW_SP_FLOOD_TYPE_MC,
296};
297
298
299int mlxsw_sp_buffers_init(struct mlxsw_sp *mlxsw_sp);
300void mlxsw_sp_buffers_fini(struct mlxsw_sp *mlxsw_sp);
301int mlxsw_sp_port_buffers_init(struct mlxsw_sp_port *mlxsw_sp_port);
302int 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);
305int 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);
308int mlxsw_sp_sb_port_pool_get(struct mlxsw_core_port *mlxsw_core_port,
309 unsigned int sb_index, u16 pool_index,
310 u32 *p_threshold);
311int mlxsw_sp_sb_port_pool_set(struct mlxsw_core_port *mlxsw_core_port,
312 unsigned int sb_index, u16 pool_index,
313 u32 threshold);
314int 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);
318int 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);
322int mlxsw_sp_sb_occ_snapshot(struct mlxsw_core *mlxsw_core,
323 unsigned int sb_index);
324int mlxsw_sp_sb_occ_max_clear(struct mlxsw_core *mlxsw_core,
325 unsigned int sb_index);
326int 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);
329int 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);
333u32 mlxsw_sp_cells_bytes(const struct mlxsw_sp *mlxsw_sp, u32 cells);
334u32 mlxsw_sp_bytes_cells(const struct mlxsw_sp *mlxsw_sp, u32 bytes);
335
336
337int mlxsw_sp_switchdev_init(struct mlxsw_sp *mlxsw_sp);
338void mlxsw_sp_switchdev_fini(struct mlxsw_sp *mlxsw_sp);
339void mlxsw_sp_port_switchdev_init(struct mlxsw_sp_port *mlxsw_sp_port);
340void mlxsw_sp_port_switchdev_fini(struct mlxsw_sp_port *mlxsw_sp_port);
341int mlxsw_sp_rif_fdb_op(struct mlxsw_sp *mlxsw_sp, const char *mac, u16 fid,
342 bool adding);
343void
344mlxsw_sp_port_vlan_bridge_leave(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan);
345int mlxsw_sp_port_bridge_join(struct mlxsw_sp_port *mlxsw_sp_port,
346 struct net_device *brport_dev,
347 struct net_device *br_dev);
348void mlxsw_sp_port_bridge_leave(struct mlxsw_sp_port *mlxsw_sp_port,
349 struct net_device *brport_dev,
350 struct net_device *br_dev);
351bool mlxsw_sp_bridge_device_is_offloaded(const struct mlxsw_sp *mlxsw_sp,
352 const struct net_device *br_dev);
353
354
355int mlxsw_sp_port_ets_set(struct mlxsw_sp_port *mlxsw_sp_port,
356 enum mlxsw_reg_qeec_hr hr, u8 index, u8 next_index,
357 bool dwrr, u8 dwrr_weight);
358int mlxsw_sp_port_prio_tc_set(struct mlxsw_sp_port *mlxsw_sp_port,
359 u8 switch_prio, u8 tclass);
360int __mlxsw_sp_port_headroom_set(struct mlxsw_sp_port *mlxsw_sp_port, int mtu,
361 u8 *prio_tc, bool pause_en,
362 struct ieee_pfc *my_pfc);
363int mlxsw_sp_port_ets_maxrate_set(struct mlxsw_sp_port *mlxsw_sp_port,
364 enum mlxsw_reg_qeec_hr hr, u8 index,
365 u8 next_index, u32 maxrate);
366int mlxsw_sp_port_vid_stp_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid,
367 u8 state);
368int mlxsw_sp_port_vp_mode_set(struct mlxsw_sp_port *mlxsw_sp_port, bool enable);
369int mlxsw_sp_port_vid_learning_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid,
370 bool learn_enable);
371int mlxsw_sp_port_pvid_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid);
372struct mlxsw_sp_port_vlan *
373mlxsw_sp_port_vlan_get(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid);
374void mlxsw_sp_port_vlan_put(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan);
375int mlxsw_sp_port_vlan_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid_begin,
376 u16 vid_end, bool is_member, bool untagged);
377int mlxsw_sp_flow_counter_get(struct mlxsw_sp *mlxsw_sp,
378 unsigned int counter_index, u64 *packets,
379 u64 *bytes);
380int mlxsw_sp_flow_counter_alloc(struct mlxsw_sp *mlxsw_sp,
381 unsigned int *p_counter_index);
382void mlxsw_sp_flow_counter_free(struct mlxsw_sp *mlxsw_sp,
383 unsigned int counter_index);
384bool mlxsw_sp_port_dev_check(const struct net_device *dev);
385struct mlxsw_sp *mlxsw_sp_lower_get(struct net_device *dev);
386struct mlxsw_sp_port *mlxsw_sp_port_dev_lower_find(struct net_device *dev);
387struct mlxsw_sp_port *mlxsw_sp_port_lower_dev_hold(struct net_device *dev);
388void mlxsw_sp_port_dev_put(struct mlxsw_sp_port *mlxsw_sp_port);
389struct mlxsw_sp_port *mlxsw_sp_port_dev_lower_find_rcu(struct net_device *dev);
390
391
392#ifdef CONFIG_MLXSW_SPECTRUM_DCB
393int mlxsw_sp_port_dcb_init(struct mlxsw_sp_port *mlxsw_sp_port);
394void mlxsw_sp_port_dcb_fini(struct mlxsw_sp_port *mlxsw_sp_port);
395#else
396static inline int mlxsw_sp_port_dcb_init(struct mlxsw_sp_port *mlxsw_sp_port)
397{
398 return 0;
399}
400static inline void mlxsw_sp_port_dcb_fini(struct mlxsw_sp_port *mlxsw_sp_port)
401{}
402#endif
403
404
405int mlxsw_sp_router_init(struct mlxsw_sp *mlxsw_sp);
406void mlxsw_sp_router_fini(struct mlxsw_sp *mlxsw_sp);
407int mlxsw_sp_netdevice_router_port_event(struct net_device *dev);
408int mlxsw_sp_inetaddr_event(struct notifier_block *unused,
409 unsigned long event, void *ptr);
410int mlxsw_sp_inetaddr_valid_event(struct notifier_block *unused,
411 unsigned long event, void *ptr);
412int mlxsw_sp_inet6addr_event(struct notifier_block *unused,
413 unsigned long event, void *ptr);
414int mlxsw_sp_inet6addr_valid_event(struct notifier_block *unused,
415 unsigned long event, void *ptr);
416int mlxsw_sp_netdevice_vrf_event(struct net_device *l3_dev, unsigned long event,
417 struct netdev_notifier_changeupper_info *info);
418bool mlxsw_sp_netdev_is_ipip_ol(const struct mlxsw_sp *mlxsw_sp,
419 const struct net_device *dev);
420bool mlxsw_sp_netdev_is_ipip_ul(const struct mlxsw_sp *mlxsw_sp,
421 const struct net_device *dev);
422int mlxsw_sp_netdevice_ipip_ol_event(struct mlxsw_sp *mlxsw_sp,
423 struct net_device *l3_dev,
424 unsigned long event,
425 struct netdev_notifier_info *info);
426int
427mlxsw_sp_netdevice_ipip_ul_event(struct mlxsw_sp *mlxsw_sp,
428 struct net_device *l3_dev,
429 unsigned long event,
430 struct netdev_notifier_info *info);
431void
432mlxsw_sp_port_vlan_router_leave(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan);
433void mlxsw_sp_rif_destroy(struct mlxsw_sp_rif *rif);
434void mlxsw_sp_rif_destroy_by_dev(struct mlxsw_sp *mlxsw_sp,
435 struct net_device *dev);
436
437
438int mlxsw_sp_kvdl_init(struct mlxsw_sp *mlxsw_sp);
439void mlxsw_sp_kvdl_fini(struct mlxsw_sp *mlxsw_sp);
440int mlxsw_sp_kvdl_alloc(struct mlxsw_sp *mlxsw_sp, unsigned int entry_count,
441 u32 *p_entry_index);
442void mlxsw_sp_kvdl_free(struct mlxsw_sp *mlxsw_sp, int entry_index);
443int mlxsw_sp_kvdl_alloc_size_query(struct mlxsw_sp *mlxsw_sp,
444 unsigned int entry_count,
445 unsigned int *p_alloc_size);
446int mlxsw_sp_kvdl_resources_register(struct mlxsw_core *mlxsw_core);
447
448struct 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;
453};
454
455enum mlxsw_sp_acl_profile {
456 MLXSW_SP_ACL_PROFILE_FLOWER,
457};
458
459struct 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,
466 bool ingress);
467 void (*ruleset_unbind)(struct mlxsw_sp *mlxsw_sp, void *ruleset_priv,
468 struct mlxsw_sp_port *mlxsw_sp_port,
469 bool ingress);
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,
477 bool *activity);
478};
479
480struct mlxsw_sp_acl_ops {
481 size_t priv_size;
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);
487};
488
489struct mlxsw_sp_acl_block;
490struct mlxsw_sp_acl_ruleset;
491
492
493struct mlxsw_afk *mlxsw_sp_acl_afk(struct mlxsw_sp_acl *acl);
494struct mlxsw_sp *mlxsw_sp_acl_block_mlxsw_sp(struct mlxsw_sp_acl_block *block);
495unsigned int mlxsw_sp_acl_block_rule_count(struct mlxsw_sp_acl_block *block);
496void mlxsw_sp_acl_block_disable_inc(struct mlxsw_sp_acl_block *block);
497void mlxsw_sp_acl_block_disable_dec(struct mlxsw_sp_acl_block *block);
498bool mlxsw_sp_acl_block_disabled(struct mlxsw_sp_acl_block *block);
499struct mlxsw_sp_acl_block *mlxsw_sp_acl_block_create(struct mlxsw_sp *mlxsw_sp,
500 struct net *net);
501void mlxsw_sp_acl_block_destroy(struct mlxsw_sp_acl_block *block);
502int 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,
505 bool ingress);
506int 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,
509 bool ingress);
510struct mlxsw_sp_acl_ruleset *
511mlxsw_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);
514struct mlxsw_sp_acl_ruleset *
515mlxsw_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);
518void mlxsw_sp_acl_ruleset_put(struct mlxsw_sp *mlxsw_sp,
519 struct mlxsw_sp_acl_ruleset *ruleset);
520u16 mlxsw_sp_acl_ruleset_group_id(struct mlxsw_sp_acl_ruleset *ruleset);
521
522struct mlxsw_sp_acl_rule_info *
523mlxsw_sp_acl_rulei_create(struct mlxsw_sp_acl *acl);
524void mlxsw_sp_acl_rulei_destroy(struct mlxsw_sp_acl_rule_info *rulei);
525int mlxsw_sp_acl_rulei_commit(struct mlxsw_sp_acl_rule_info *rulei);
526void mlxsw_sp_acl_rulei_priority(struct mlxsw_sp_acl_rule_info *rulei,
527 unsigned int priority);
528void 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);
531void 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);
535int mlxsw_sp_acl_rulei_act_continue(struct mlxsw_sp_acl_rule_info *rulei);
536int mlxsw_sp_acl_rulei_act_jump(struct mlxsw_sp_acl_rule_info *rulei,
537 u16 group_id);
538int mlxsw_sp_acl_rulei_act_terminate(struct mlxsw_sp_acl_rule_info *rulei);
539int mlxsw_sp_acl_rulei_act_drop(struct mlxsw_sp_acl_rule_info *rulei);
540int mlxsw_sp_acl_rulei_act_trap(struct mlxsw_sp_acl_rule_info *rulei);
541int mlxsw_sp_acl_rulei_act_mirror(struct mlxsw_sp *mlxsw_sp,
542 struct mlxsw_sp_acl_rule_info *rulei,
543 struct mlxsw_sp_acl_block *block,
544 struct net_device *out_dev);
545int mlxsw_sp_acl_rulei_act_fwd(struct mlxsw_sp *mlxsw_sp,
546 struct mlxsw_sp_acl_rule_info *rulei,
547 struct net_device *out_dev);
548int mlxsw_sp_acl_rulei_act_vlan(struct mlxsw_sp *mlxsw_sp,
549 struct mlxsw_sp_acl_rule_info *rulei,
550 u32 action, u16 vid, u16 proto, u8 prio);
551int mlxsw_sp_acl_rulei_act_count(struct mlxsw_sp *mlxsw_sp,
552 struct mlxsw_sp_acl_rule_info *rulei);
553int mlxsw_sp_acl_rulei_act_fid_set(struct mlxsw_sp *mlxsw_sp,
554 struct mlxsw_sp_acl_rule_info *rulei,
555 u16 fid);
556
557struct mlxsw_sp_acl_rule;
558
559struct mlxsw_sp_acl_rule *
560mlxsw_sp_acl_rule_create(struct mlxsw_sp *mlxsw_sp,
561 struct mlxsw_sp_acl_ruleset *ruleset,
562 unsigned long cookie);
563void mlxsw_sp_acl_rule_destroy(struct mlxsw_sp *mlxsw_sp,
564 struct mlxsw_sp_acl_rule *rule);
565int mlxsw_sp_acl_rule_add(struct mlxsw_sp *mlxsw_sp,
566 struct mlxsw_sp_acl_rule *rule);
567void mlxsw_sp_acl_rule_del(struct mlxsw_sp *mlxsw_sp,
568 struct mlxsw_sp_acl_rule *rule);
569struct mlxsw_sp_acl_rule *
570mlxsw_sp_acl_rule_lookup(struct mlxsw_sp *mlxsw_sp,
571 struct mlxsw_sp_acl_ruleset *ruleset,
572 unsigned long cookie);
573struct mlxsw_sp_acl_rule_info *
574mlxsw_sp_acl_rule_rulei(struct mlxsw_sp_acl_rule *rule);
575int mlxsw_sp_acl_rule_get_stats(struct mlxsw_sp *mlxsw_sp,
576 struct mlxsw_sp_acl_rule *rule,
577 u64 *packets, u64 *bytes, u64 *last_use);
578
579struct mlxsw_sp_fid *mlxsw_sp_acl_dummy_fid(struct mlxsw_sp *mlxsw_sp);
580
581int mlxsw_sp_acl_init(struct mlxsw_sp *mlxsw_sp);
582void mlxsw_sp_acl_fini(struct mlxsw_sp *mlxsw_sp);
583
584
585extern const struct mlxsw_sp_acl_ops mlxsw_sp_acl_tcam_ops;
586
587
588int mlxsw_sp_flower_replace(struct mlxsw_sp *mlxsw_sp,
589 struct mlxsw_sp_acl_block *block,
590 struct tc_cls_flower_offload *f);
591void mlxsw_sp_flower_destroy(struct mlxsw_sp *mlxsw_sp,
592 struct mlxsw_sp_acl_block *block,
593 struct tc_cls_flower_offload *f);
594int mlxsw_sp_flower_stats(struct mlxsw_sp *mlxsw_sp,
595 struct mlxsw_sp_acl_block *block,
596 struct tc_cls_flower_offload *f);
597
598
599int mlxsw_sp_tc_qdisc_init(struct mlxsw_sp_port *mlxsw_sp_port);
600void mlxsw_sp_tc_qdisc_fini(struct mlxsw_sp_port *mlxsw_sp_port);
601int mlxsw_sp_setup_tc_red(struct mlxsw_sp_port *mlxsw_sp_port,
602 struct tc_red_qopt_offload *p);
603int mlxsw_sp_setup_tc_prio(struct mlxsw_sp_port *mlxsw_sp_port,
604 struct tc_prio_qopt_offload *p);
605
606
607int mlxsw_sp_fid_flood_set(struct mlxsw_sp_fid *fid,
608 enum mlxsw_sp_flood_type packet_type, u8 local_port,
609 bool member);
610int mlxsw_sp_fid_port_vid_map(struct mlxsw_sp_fid *fid,
611 struct mlxsw_sp_port *mlxsw_sp_port, u16 vid);
612void mlxsw_sp_fid_port_vid_unmap(struct mlxsw_sp_fid *fid,
613 struct mlxsw_sp_port *mlxsw_sp_port, u16 vid);
614enum mlxsw_sp_rif_type mlxsw_sp_fid_rif_type(const struct mlxsw_sp_fid *fid);
615u16 mlxsw_sp_fid_index(const struct mlxsw_sp_fid *fid);
616enum mlxsw_sp_fid_type mlxsw_sp_fid_type(const struct mlxsw_sp_fid *fid);
617void mlxsw_sp_fid_rif_set(struct mlxsw_sp_fid *fid, struct mlxsw_sp_rif *rif);
618enum mlxsw_sp_rif_type
619mlxsw_sp_fid_type_rif_type(const struct mlxsw_sp *mlxsw_sp,
620 enum mlxsw_sp_fid_type type);
621u16 mlxsw_sp_fid_8021q_vid(const struct mlxsw_sp_fid *fid);
622struct mlxsw_sp_fid *mlxsw_sp_fid_8021q_get(struct mlxsw_sp *mlxsw_sp, u16 vid);
623struct mlxsw_sp_fid *mlxsw_sp_fid_8021d_get(struct mlxsw_sp *mlxsw_sp,
624 int br_ifindex);
625struct mlxsw_sp_fid *mlxsw_sp_fid_rfid_get(struct mlxsw_sp *mlxsw_sp,
626 u16 rif_index);
627struct mlxsw_sp_fid *mlxsw_sp_fid_dummy_get(struct mlxsw_sp *mlxsw_sp);
628void mlxsw_sp_fid_put(struct mlxsw_sp_fid *fid);
629int mlxsw_sp_port_fids_init(struct mlxsw_sp_port *mlxsw_sp_port);
630void mlxsw_sp_port_fids_fini(struct mlxsw_sp_port *mlxsw_sp_port);
631int mlxsw_sp_fids_init(struct mlxsw_sp *mlxsw_sp);
632void mlxsw_sp_fids_fini(struct mlxsw_sp *mlxsw_sp);
633
634#endif
635