This source file includes following definitions.
- mlxsw_sp_lag_get
- mlxsw_sp_bridge_vxlan_dev_find
- mlxsw_sp_bridge_has_vxlan
- mlxsw_sp_vxlan_mapped_vid
- mlxsw_sp_port_is_pause_en
- mlxsw_sp_port_lagged_get
- mlxsw_sp_port_vlan_find_by_vid
- mlxsw_sp_port_dcb_init
- mlxsw_sp_port_dcb_fini
- mlxsw_sp_kvdl_entry_size
1
2
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
37 #define MLXSW_SP_PORT_BASE_SPEED_50G 50000
38
39 #define MLXSW_SP_KVD_LINEAR_SIZE 98304
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,
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;
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 struct mlxsw_sp_ptp_state;
140 struct mlxsw_sp_ptp_ops;
141
142 struct mlxsw_sp {
143 struct mlxsw_sp_port **ports;
144 struct mlxsw_core *core;
145 const struct mlxsw_bus_info *bus_info;
146 unsigned char base_mac[ETH_ALEN];
147 const unsigned char *mac_mask;
148 struct mlxsw_sp_upper *lags;
149 int *port_to_module;
150 struct mlxsw_sp_sb *sb;
151 struct mlxsw_sp_bridge *bridge;
152 struct mlxsw_sp_router *router;
153 struct mlxsw_sp_mr *mr;
154 struct mlxsw_afa *afa;
155 struct mlxsw_sp_acl *acl;
156 struct mlxsw_sp_fid_core *fid_core;
157 struct mlxsw_sp_kvdl *kvdl;
158 struct mlxsw_sp_nve *nve;
159 struct notifier_block netdevice_nb;
160 struct mlxsw_sp_ptp_clock *clock;
161 struct mlxsw_sp_ptp_state *ptp_state;
162
163 struct mlxsw_sp_counter_pool *counter_pool;
164 struct {
165 struct mlxsw_sp_span_entry *entries;
166 int entries_count;
167 } span;
168 const struct mlxsw_fw_rev *req_rev;
169 const char *fw_filename;
170 const struct mlxsw_sp_kvdl_ops *kvdl_ops;
171 const struct mlxsw_afa_ops *afa_ops;
172 const struct mlxsw_afk_ops *afk_ops;
173 const struct mlxsw_sp_mr_tcam_ops *mr_tcam_ops;
174 const struct mlxsw_sp_acl_tcam_ops *acl_tcam_ops;
175 const struct mlxsw_sp_nve_ops **nve_ops_arr;
176 const struct mlxsw_sp_rif_ops **rif_ops_arr;
177 const struct mlxsw_sp_sb_vals *sb_vals;
178 const struct mlxsw_sp_port_type_speed_ops *port_type_speed_ops;
179 const struct mlxsw_sp_ptp_ops *ptp_ops;
180 const struct mlxsw_listener *listeners;
181 size_t listeners_count;
182 };
183
184 static inline struct mlxsw_sp_upper *
185 mlxsw_sp_lag_get(struct mlxsw_sp *mlxsw_sp, u16 lag_id)
186 {
187 return &mlxsw_sp->lags[lag_id];
188 }
189
190 struct mlxsw_sp_port_pcpu_stats {
191 u64 rx_packets;
192 u64 rx_bytes;
193 u64 tx_packets;
194 u64 tx_bytes;
195 struct u64_stats_sync syncp;
196 u32 tx_dropped;
197 };
198
199 struct mlxsw_sp_port_sample {
200 struct psample_group __rcu *psample_group;
201 u32 trunc_size;
202 u32 rate;
203 bool truncate;
204 };
205
206 struct mlxsw_sp_bridge_port;
207 struct mlxsw_sp_fid;
208
209 struct mlxsw_sp_port_vlan {
210 struct list_head list;
211 struct mlxsw_sp_port *mlxsw_sp_port;
212 struct mlxsw_sp_fid *fid;
213 u16 vid;
214 struct mlxsw_sp_bridge_port *bridge_port;
215 struct list_head bridge_vlan_node;
216 };
217
218
219 struct mlxsw_sp_port_xstats {
220 u64 ecn;
221 u64 wred_drop[TC_MAX_QUEUE];
222 u64 tail_drop[TC_MAX_QUEUE];
223 u64 backlog[TC_MAX_QUEUE];
224 u64 tx_bytes[IEEE_8021QAZ_MAX_TCS];
225 u64 tx_packets[IEEE_8021QAZ_MAX_TCS];
226 };
227
228 struct mlxsw_sp_ptp_port_dir_stats {
229 u64 packets;
230 u64 timestamps;
231 };
232
233 struct mlxsw_sp_ptp_port_stats {
234 struct mlxsw_sp_ptp_port_dir_stats rx_gcd;
235 struct mlxsw_sp_ptp_port_dir_stats tx_gcd;
236 };
237
238 struct mlxsw_sp_port {
239 struct net_device *dev;
240 struct mlxsw_sp_port_pcpu_stats __percpu *pcpu_stats;
241 struct mlxsw_sp *mlxsw_sp;
242 u8 local_port;
243 u8 lagged:1,
244 split:1;
245 u16 pvid;
246 u16 lag_id;
247 struct {
248 u8 tx_pause:1,
249 rx_pause:1,
250 autoneg:1;
251 } link;
252 struct {
253 struct ieee_ets *ets;
254 struct ieee_maxrate *maxrate;
255 struct ieee_pfc *pfc;
256 enum mlxsw_reg_qpts_trust_state trust_state;
257 } dcb;
258 struct {
259 u8 module;
260 u8 width;
261 u8 lane;
262 } mapping;
263
264 struct list_head mall_tc_list;
265 struct {
266 #define MLXSW_HW_STATS_UPDATE_TIME HZ
267 struct rtnl_link_stats64 stats;
268 struct mlxsw_sp_port_xstats xstats;
269 struct delayed_work update_dw;
270 } periodic_hw_stats;
271 struct mlxsw_sp_port_sample *sample;
272 struct list_head vlans_list;
273 struct mlxsw_sp_port_vlan *default_vlan;
274 struct mlxsw_sp_qdisc *root_qdisc;
275 struct mlxsw_sp_qdisc *tclass_qdiscs;
276 unsigned acl_rule_count;
277 struct mlxsw_sp_acl_block *ing_acl_block;
278 struct mlxsw_sp_acl_block *eg_acl_block;
279 struct {
280 struct delayed_work shaper_dw;
281 struct hwtstamp_config hwtstamp_config;
282 u16 ing_types;
283 u16 egr_types;
284 struct mlxsw_sp_ptp_port_stats stats;
285 } ptp;
286 };
287
288 struct mlxsw_sp_port_type_speed_ops {
289 void (*from_ptys_supported_port)(struct mlxsw_sp *mlxsw_sp,
290 u32 ptys_eth_proto,
291 struct ethtool_link_ksettings *cmd);
292 void (*from_ptys_link)(struct mlxsw_sp *mlxsw_sp, u32 ptys_eth_proto,
293 u8 width, unsigned long *mode);
294 u32 (*from_ptys_speed)(struct mlxsw_sp *mlxsw_sp, u32 ptys_eth_proto);
295 void (*from_ptys_speed_duplex)(struct mlxsw_sp *mlxsw_sp,
296 bool carrier_ok, u32 ptys_eth_proto,
297 struct ethtool_link_ksettings *cmd);
298 u32 (*to_ptys_advert_link)(struct mlxsw_sp *mlxsw_sp, u8 width,
299 const struct ethtool_link_ksettings *cmd);
300 u32 (*to_ptys_speed)(struct mlxsw_sp *mlxsw_sp, u8 width, u32 speed);
301 u32 (*to_ptys_upper_speed)(struct mlxsw_sp *mlxsw_sp, u32 upper_speed);
302 int (*port_speed_base)(struct mlxsw_sp *mlxsw_sp, u8 local_port,
303 u32 *base_speed);
304 void (*reg_ptys_eth_pack)(struct mlxsw_sp *mlxsw_sp, char *payload,
305 u8 local_port, u32 proto_admin, bool autoneg);
306 void (*reg_ptys_eth_unpack)(struct mlxsw_sp *mlxsw_sp, char *payload,
307 u32 *p_eth_proto_cap,
308 u32 *p_eth_proto_admin,
309 u32 *p_eth_proto_oper);
310 };
311
312 static inline struct net_device *
313 mlxsw_sp_bridge_vxlan_dev_find(struct net_device *br_dev)
314 {
315 struct net_device *dev;
316 struct list_head *iter;
317
318 netdev_for_each_lower_dev(br_dev, dev, iter) {
319 if (netif_is_vxlan(dev))
320 return dev;
321 }
322
323 return NULL;
324 }
325
326 static inline bool mlxsw_sp_bridge_has_vxlan(struct net_device *br_dev)
327 {
328 return !!mlxsw_sp_bridge_vxlan_dev_find(br_dev);
329 }
330
331 static inline int
332 mlxsw_sp_vxlan_mapped_vid(const struct net_device *vxlan_dev, u16 *p_vid)
333 {
334 struct bridge_vlan_info vinfo;
335 u16 vid = 0;
336 int err;
337
338 err = br_vlan_get_pvid(vxlan_dev, &vid);
339 if (err || !vid)
340 goto out;
341
342 err = br_vlan_get_info(vxlan_dev, vid, &vinfo);
343 if (err || !(vinfo.flags & BRIDGE_VLAN_INFO_UNTAGGED))
344 vid = 0;
345
346 out:
347 *p_vid = vid;
348 return err;
349 }
350
351 static inline bool
352 mlxsw_sp_port_is_pause_en(const struct mlxsw_sp_port *mlxsw_sp_port)
353 {
354 return mlxsw_sp_port->link.tx_pause || mlxsw_sp_port->link.rx_pause;
355 }
356
357 static inline struct mlxsw_sp_port *
358 mlxsw_sp_port_lagged_get(struct mlxsw_sp *mlxsw_sp, u16 lag_id, u8 port_index)
359 {
360 struct mlxsw_sp_port *mlxsw_sp_port;
361 u8 local_port;
362
363 local_port = mlxsw_core_lag_mapping_get(mlxsw_sp->core,
364 lag_id, port_index);
365 mlxsw_sp_port = mlxsw_sp->ports[local_port];
366 return mlxsw_sp_port && mlxsw_sp_port->lagged ? mlxsw_sp_port : NULL;
367 }
368
369 static inline struct mlxsw_sp_port_vlan *
370 mlxsw_sp_port_vlan_find_by_vid(const struct mlxsw_sp_port *mlxsw_sp_port,
371 u16 vid)
372 {
373 struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan;
374
375 list_for_each_entry(mlxsw_sp_port_vlan, &mlxsw_sp_port->vlans_list,
376 list) {
377 if (mlxsw_sp_port_vlan->vid == vid)
378 return mlxsw_sp_port_vlan;
379 }
380
381 return NULL;
382 }
383
384 enum mlxsw_sp_flood_type {
385 MLXSW_SP_FLOOD_TYPE_UC,
386 MLXSW_SP_FLOOD_TYPE_BC,
387 MLXSW_SP_FLOOD_TYPE_MC,
388 };
389
390
391 int mlxsw_sp_buffers_init(struct mlxsw_sp *mlxsw_sp);
392 void mlxsw_sp_buffers_fini(struct mlxsw_sp *mlxsw_sp);
393 int mlxsw_sp_port_buffers_init(struct mlxsw_sp_port *mlxsw_sp_port);
394 int mlxsw_sp_sb_pool_get(struct mlxsw_core *mlxsw_core,
395 unsigned int sb_index, u16 pool_index,
396 struct devlink_sb_pool_info *pool_info);
397 int mlxsw_sp_sb_pool_set(struct mlxsw_core *mlxsw_core,
398 unsigned int sb_index, u16 pool_index, u32 size,
399 enum devlink_sb_threshold_type threshold_type,
400 struct netlink_ext_ack *extack);
401 int mlxsw_sp_sb_port_pool_get(struct mlxsw_core_port *mlxsw_core_port,
402 unsigned int sb_index, u16 pool_index,
403 u32 *p_threshold);
404 int mlxsw_sp_sb_port_pool_set(struct mlxsw_core_port *mlxsw_core_port,
405 unsigned int sb_index, u16 pool_index,
406 u32 threshold, struct netlink_ext_ack *extack);
407 int mlxsw_sp_sb_tc_pool_bind_get(struct mlxsw_core_port *mlxsw_core_port,
408 unsigned int sb_index, u16 tc_index,
409 enum devlink_sb_pool_type pool_type,
410 u16 *p_pool_index, u32 *p_threshold);
411 int mlxsw_sp_sb_tc_pool_bind_set(struct mlxsw_core_port *mlxsw_core_port,
412 unsigned int sb_index, u16 tc_index,
413 enum devlink_sb_pool_type pool_type,
414 u16 pool_index, u32 threshold,
415 struct netlink_ext_ack *extack);
416 int mlxsw_sp_sb_occ_snapshot(struct mlxsw_core *mlxsw_core,
417 unsigned int sb_index);
418 int mlxsw_sp_sb_occ_max_clear(struct mlxsw_core *mlxsw_core,
419 unsigned int sb_index);
420 int mlxsw_sp_sb_occ_port_pool_get(struct mlxsw_core_port *mlxsw_core_port,
421 unsigned int sb_index, u16 pool_index,
422 u32 *p_cur, u32 *p_max);
423 int mlxsw_sp_sb_occ_tc_port_bind_get(struct mlxsw_core_port *mlxsw_core_port,
424 unsigned int sb_index, u16 tc_index,
425 enum devlink_sb_pool_type pool_type,
426 u32 *p_cur, u32 *p_max);
427 u32 mlxsw_sp_cells_bytes(const struct mlxsw_sp *mlxsw_sp, u32 cells);
428 u32 mlxsw_sp_bytes_cells(const struct mlxsw_sp *mlxsw_sp, u32 bytes);
429 u32 mlxsw_sp_sb_max_headroom_cells(const struct mlxsw_sp *mlxsw_sp);
430
431 extern const struct mlxsw_sp_sb_vals mlxsw_sp1_sb_vals;
432 extern const struct mlxsw_sp_sb_vals mlxsw_sp2_sb_vals;
433
434
435 int mlxsw_sp_switchdev_init(struct mlxsw_sp *mlxsw_sp);
436 void mlxsw_sp_switchdev_fini(struct mlxsw_sp *mlxsw_sp);
437 int mlxsw_sp_rif_fdb_op(struct mlxsw_sp *mlxsw_sp, const char *mac, u16 fid,
438 bool adding);
439 void
440 mlxsw_sp_port_vlan_bridge_leave(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan);
441 int mlxsw_sp_port_bridge_join(struct mlxsw_sp_port *mlxsw_sp_port,
442 struct net_device *brport_dev,
443 struct net_device *br_dev,
444 struct netlink_ext_ack *extack);
445 void mlxsw_sp_port_bridge_leave(struct mlxsw_sp_port *mlxsw_sp_port,
446 struct net_device *brport_dev,
447 struct net_device *br_dev);
448 bool mlxsw_sp_bridge_device_is_offloaded(const struct mlxsw_sp *mlxsw_sp,
449 const struct net_device *br_dev);
450 int mlxsw_sp_bridge_vxlan_join(struct mlxsw_sp *mlxsw_sp,
451 const struct net_device *br_dev,
452 const struct net_device *vxlan_dev, u16 vid,
453 struct netlink_ext_ack *extack);
454 void mlxsw_sp_bridge_vxlan_leave(struct mlxsw_sp *mlxsw_sp,
455 const struct net_device *vxlan_dev);
456 struct mlxsw_sp_fid *mlxsw_sp_bridge_fid_get(struct mlxsw_sp *mlxsw_sp,
457 const struct net_device *br_dev,
458 u16 vid,
459 struct netlink_ext_ack *extack);
460 extern struct notifier_block mlxsw_sp_switchdev_notifier;
461
462
463 void mlxsw_sp_rx_listener_no_mark_func(struct sk_buff *skb,
464 u8 local_port, void *priv);
465 int mlxsw_sp_port_ets_set(struct mlxsw_sp_port *mlxsw_sp_port,
466 enum mlxsw_reg_qeec_hr hr, u8 index, u8 next_index,
467 bool dwrr, u8 dwrr_weight);
468 int mlxsw_sp_port_prio_tc_set(struct mlxsw_sp_port *mlxsw_sp_port,
469 u8 switch_prio, u8 tclass);
470 int __mlxsw_sp_port_headroom_set(struct mlxsw_sp_port *mlxsw_sp_port, int mtu,
471 u8 *prio_tc, bool pause_en,
472 struct ieee_pfc *my_pfc);
473 int mlxsw_sp_port_ets_maxrate_set(struct mlxsw_sp_port *mlxsw_sp_port,
474 enum mlxsw_reg_qeec_hr hr, u8 index,
475 u8 next_index, u32 maxrate);
476 enum mlxsw_reg_spms_state mlxsw_sp_stp_spms_state(u8 stp_state);
477 int mlxsw_sp_port_vid_stp_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid,
478 u8 state);
479 int mlxsw_sp_port_vp_mode_set(struct mlxsw_sp_port *mlxsw_sp_port, bool enable);
480 int mlxsw_sp_port_vid_learning_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid,
481 bool learn_enable);
482 int mlxsw_sp_port_pvid_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid);
483 struct mlxsw_sp_port_vlan *
484 mlxsw_sp_port_vlan_create(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid);
485 void mlxsw_sp_port_vlan_destroy(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan);
486 int mlxsw_sp_port_vlan_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid_begin,
487 u16 vid_end, bool is_member, bool untagged);
488 int mlxsw_sp_flow_counter_get(struct mlxsw_sp *mlxsw_sp,
489 unsigned int counter_index, u64 *packets,
490 u64 *bytes);
491 int mlxsw_sp_flow_counter_alloc(struct mlxsw_sp *mlxsw_sp,
492 unsigned int *p_counter_index);
493 void mlxsw_sp_flow_counter_free(struct mlxsw_sp *mlxsw_sp,
494 unsigned int counter_index);
495 bool mlxsw_sp_port_dev_check(const struct net_device *dev);
496 struct mlxsw_sp *mlxsw_sp_lower_get(struct net_device *dev);
497 struct mlxsw_sp_port *mlxsw_sp_port_dev_lower_find(struct net_device *dev);
498 struct mlxsw_sp_port *mlxsw_sp_port_lower_dev_hold(struct net_device *dev);
499 void mlxsw_sp_port_dev_put(struct mlxsw_sp_port *mlxsw_sp_port);
500 struct mlxsw_sp_port *mlxsw_sp_port_dev_lower_find_rcu(struct net_device *dev);
501
502
503 #ifdef CONFIG_MLXSW_SPECTRUM_DCB
504 int mlxsw_sp_port_dcb_init(struct mlxsw_sp_port *mlxsw_sp_port);
505 void mlxsw_sp_port_dcb_fini(struct mlxsw_sp_port *mlxsw_sp_port);
506 #else
507 static inline int mlxsw_sp_port_dcb_init(struct mlxsw_sp_port *mlxsw_sp_port)
508 {
509 return 0;
510 }
511 static inline void mlxsw_sp_port_dcb_fini(struct mlxsw_sp_port *mlxsw_sp_port)
512 {}
513 #endif
514
515
516 enum mlxsw_sp_l3proto {
517 MLXSW_SP_L3_PROTO_IPV4,
518 MLXSW_SP_L3_PROTO_IPV6,
519 #define MLXSW_SP_L3_PROTO_MAX (MLXSW_SP_L3_PROTO_IPV6 + 1)
520 };
521
522 union mlxsw_sp_l3addr {
523 __be32 addr4;
524 struct in6_addr addr6;
525 };
526
527 int mlxsw_sp_router_init(struct mlxsw_sp *mlxsw_sp);
528 void mlxsw_sp_router_fini(struct mlxsw_sp *mlxsw_sp);
529 int mlxsw_sp_netdevice_router_port_event(struct net_device *dev,
530 unsigned long event, void *ptr);
531 void mlxsw_sp_rif_macvlan_del(struct mlxsw_sp *mlxsw_sp,
532 const struct net_device *macvlan_dev);
533 int mlxsw_sp_inetaddr_valid_event(struct notifier_block *unused,
534 unsigned long event, void *ptr);
535 int mlxsw_sp_inet6addr_valid_event(struct notifier_block *unused,
536 unsigned long event, void *ptr);
537 int mlxsw_sp_netdevice_vrf_event(struct net_device *l3_dev, unsigned long event,
538 struct netdev_notifier_changeupper_info *info);
539 bool mlxsw_sp_netdev_is_ipip_ol(const struct mlxsw_sp *mlxsw_sp,
540 const struct net_device *dev);
541 bool mlxsw_sp_netdev_is_ipip_ul(const struct mlxsw_sp *mlxsw_sp,
542 const struct net_device *dev);
543 int mlxsw_sp_netdevice_ipip_ol_event(struct mlxsw_sp *mlxsw_sp,
544 struct net_device *l3_dev,
545 unsigned long event,
546 struct netdev_notifier_info *info);
547 int
548 mlxsw_sp_netdevice_ipip_ul_event(struct mlxsw_sp *mlxsw_sp,
549 struct net_device *l3_dev,
550 unsigned long event,
551 struct netdev_notifier_info *info);
552 void
553 mlxsw_sp_port_vlan_router_leave(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan);
554 void mlxsw_sp_rif_destroy_by_dev(struct mlxsw_sp *mlxsw_sp,
555 struct net_device *dev);
556 struct mlxsw_sp_rif *mlxsw_sp_rif_find_by_dev(const struct mlxsw_sp *mlxsw_sp,
557 const struct net_device *dev);
558 u8 mlxsw_sp_router_port(const struct mlxsw_sp *mlxsw_sp);
559 struct mlxsw_sp_fid *mlxsw_sp_rif_fid(const struct mlxsw_sp_rif *rif);
560 int mlxsw_sp_router_nve_promote_decap(struct mlxsw_sp *mlxsw_sp, u32 ul_tb_id,
561 enum mlxsw_sp_l3proto ul_proto,
562 const union mlxsw_sp_l3addr *ul_sip,
563 u32 tunnel_index);
564 void mlxsw_sp_router_nve_demote_decap(struct mlxsw_sp *mlxsw_sp, u32 ul_tb_id,
565 enum mlxsw_sp_l3proto ul_proto,
566 const union mlxsw_sp_l3addr *ul_sip);
567 int mlxsw_sp_router_tb_id_vr_id(struct mlxsw_sp *mlxsw_sp, u32 tb_id,
568 u16 *vr_id);
569 int mlxsw_sp_router_ul_rif_get(struct mlxsw_sp *mlxsw_sp, u32 ul_tb_id,
570 u16 *ul_rif_index);
571 void mlxsw_sp_router_ul_rif_put(struct mlxsw_sp *mlxsw_sp, u16 ul_rif_index);
572
573
574 enum mlxsw_sp_kvdl_entry_type {
575 MLXSW_SP_KVDL_ENTRY_TYPE_ADJ,
576 MLXSW_SP_KVDL_ENTRY_TYPE_ACTSET,
577 MLXSW_SP_KVDL_ENTRY_TYPE_PBS,
578 MLXSW_SP_KVDL_ENTRY_TYPE_MCRIGR,
579 MLXSW_SP_KVDL_ENTRY_TYPE_TNUMT,
580 };
581
582 static inline unsigned int
583 mlxsw_sp_kvdl_entry_size(enum mlxsw_sp_kvdl_entry_type type)
584 {
585 switch (type) {
586 case MLXSW_SP_KVDL_ENTRY_TYPE_ADJ:
587 case MLXSW_SP_KVDL_ENTRY_TYPE_ACTSET:
588 case MLXSW_SP_KVDL_ENTRY_TYPE_PBS:
589 case MLXSW_SP_KVDL_ENTRY_TYPE_MCRIGR:
590 case MLXSW_SP_KVDL_ENTRY_TYPE_TNUMT:
591 default:
592 return 1;
593 }
594 }
595
596 struct mlxsw_sp_kvdl_ops {
597 size_t priv_size;
598 int (*init)(struct mlxsw_sp *mlxsw_sp, void *priv);
599 void (*fini)(struct mlxsw_sp *mlxsw_sp, void *priv);
600 int (*alloc)(struct mlxsw_sp *mlxsw_sp, void *priv,
601 enum mlxsw_sp_kvdl_entry_type type,
602 unsigned int entry_count, u32 *p_entry_index);
603 void (*free)(struct mlxsw_sp *mlxsw_sp, void *priv,
604 enum mlxsw_sp_kvdl_entry_type type,
605 unsigned int entry_count, int entry_index);
606 int (*alloc_size_query)(struct mlxsw_sp *mlxsw_sp, void *priv,
607 enum mlxsw_sp_kvdl_entry_type type,
608 unsigned int entry_count,
609 unsigned int *p_alloc_count);
610 int (*resources_register)(struct mlxsw_sp *mlxsw_sp, void *priv);
611 };
612
613 int mlxsw_sp_kvdl_init(struct mlxsw_sp *mlxsw_sp);
614 void mlxsw_sp_kvdl_fini(struct mlxsw_sp *mlxsw_sp);
615 int mlxsw_sp_kvdl_alloc(struct mlxsw_sp *mlxsw_sp,
616 enum mlxsw_sp_kvdl_entry_type type,
617 unsigned int entry_count, u32 *p_entry_index);
618 void mlxsw_sp_kvdl_free(struct mlxsw_sp *mlxsw_sp,
619 enum mlxsw_sp_kvdl_entry_type type,
620 unsigned int entry_count, int entry_index);
621 int mlxsw_sp_kvdl_alloc_count_query(struct mlxsw_sp *mlxsw_sp,
622 enum mlxsw_sp_kvdl_entry_type type,
623 unsigned int entry_count,
624 unsigned int *p_alloc_count);
625
626
627 extern const struct mlxsw_sp_kvdl_ops mlxsw_sp1_kvdl_ops;
628 int mlxsw_sp1_kvdl_resources_register(struct mlxsw_core *mlxsw_core);
629
630
631 extern const struct mlxsw_sp_kvdl_ops mlxsw_sp2_kvdl_ops;
632
633 struct mlxsw_sp_acl_rule_info {
634 unsigned int priority;
635 struct mlxsw_afk_element_values values;
636 struct mlxsw_afa_block *act_block;
637 u8 action_created:1,
638 egress_bind_blocker:1;
639 unsigned int counter_index;
640 };
641
642 struct mlxsw_sp_acl_block;
643 struct mlxsw_sp_acl_ruleset;
644
645
646 enum mlxsw_sp_acl_profile {
647 MLXSW_SP_ACL_PROFILE_FLOWER,
648 MLXSW_SP_ACL_PROFILE_MR,
649 };
650
651 struct mlxsw_sp_acl_block {
652 struct list_head binding_list;
653 struct mlxsw_sp_acl_ruleset *ruleset_zero;
654 struct mlxsw_sp *mlxsw_sp;
655 unsigned int rule_count;
656 unsigned int disable_count;
657 unsigned int egress_blocker_rule_count;
658 struct net *net;
659 };
660
661 struct mlxsw_afk *mlxsw_sp_acl_afk(struct mlxsw_sp_acl *acl);
662 struct mlxsw_sp *mlxsw_sp_acl_block_mlxsw_sp(struct mlxsw_sp_acl_block *block);
663 unsigned int mlxsw_sp_acl_block_rule_count(struct mlxsw_sp_acl_block *block);
664 void mlxsw_sp_acl_block_disable_inc(struct mlxsw_sp_acl_block *block);
665 void mlxsw_sp_acl_block_disable_dec(struct mlxsw_sp_acl_block *block);
666 bool mlxsw_sp_acl_block_disabled(struct mlxsw_sp_acl_block *block);
667 struct mlxsw_sp_acl_block *mlxsw_sp_acl_block_create(struct mlxsw_sp *mlxsw_sp,
668 struct net *net);
669 void mlxsw_sp_acl_block_destroy(struct mlxsw_sp_acl_block *block);
670 int mlxsw_sp_acl_block_bind(struct mlxsw_sp *mlxsw_sp,
671 struct mlxsw_sp_acl_block *block,
672 struct mlxsw_sp_port *mlxsw_sp_port,
673 bool ingress,
674 struct netlink_ext_ack *extack);
675 int mlxsw_sp_acl_block_unbind(struct mlxsw_sp *mlxsw_sp,
676 struct mlxsw_sp_acl_block *block,
677 struct mlxsw_sp_port *mlxsw_sp_port,
678 bool ingress);
679 bool mlxsw_sp_acl_block_is_egress_bound(struct mlxsw_sp_acl_block *block);
680 struct mlxsw_sp_acl_ruleset *
681 mlxsw_sp_acl_ruleset_lookup(struct mlxsw_sp *mlxsw_sp,
682 struct mlxsw_sp_acl_block *block, u32 chain_index,
683 enum mlxsw_sp_acl_profile profile);
684 struct mlxsw_sp_acl_ruleset *
685 mlxsw_sp_acl_ruleset_get(struct mlxsw_sp *mlxsw_sp,
686 struct mlxsw_sp_acl_block *block, u32 chain_index,
687 enum mlxsw_sp_acl_profile profile,
688 struct mlxsw_afk_element_usage *tmplt_elusage);
689 void mlxsw_sp_acl_ruleset_put(struct mlxsw_sp *mlxsw_sp,
690 struct mlxsw_sp_acl_ruleset *ruleset);
691 u16 mlxsw_sp_acl_ruleset_group_id(struct mlxsw_sp_acl_ruleset *ruleset);
692
693 struct mlxsw_sp_acl_rule_info *
694 mlxsw_sp_acl_rulei_create(struct mlxsw_sp_acl *acl,
695 struct mlxsw_afa_block *afa_block);
696 void mlxsw_sp_acl_rulei_destroy(struct mlxsw_sp_acl_rule_info *rulei);
697 int mlxsw_sp_acl_rulei_commit(struct mlxsw_sp_acl_rule_info *rulei);
698 void mlxsw_sp_acl_rulei_priority(struct mlxsw_sp_acl_rule_info *rulei,
699 unsigned int priority);
700 void mlxsw_sp_acl_rulei_keymask_u32(struct mlxsw_sp_acl_rule_info *rulei,
701 enum mlxsw_afk_element element,
702 u32 key_value, u32 mask_value);
703 void mlxsw_sp_acl_rulei_keymask_buf(struct mlxsw_sp_acl_rule_info *rulei,
704 enum mlxsw_afk_element element,
705 const char *key_value,
706 const char *mask_value, unsigned int len);
707 int mlxsw_sp_acl_rulei_act_continue(struct mlxsw_sp_acl_rule_info *rulei);
708 int mlxsw_sp_acl_rulei_act_jump(struct mlxsw_sp_acl_rule_info *rulei,
709 u16 group_id);
710 int mlxsw_sp_acl_rulei_act_terminate(struct mlxsw_sp_acl_rule_info *rulei);
711 int mlxsw_sp_acl_rulei_act_drop(struct mlxsw_sp_acl_rule_info *rulei);
712 int mlxsw_sp_acl_rulei_act_trap(struct mlxsw_sp_acl_rule_info *rulei);
713 int mlxsw_sp_acl_rulei_act_mirror(struct mlxsw_sp *mlxsw_sp,
714 struct mlxsw_sp_acl_rule_info *rulei,
715 struct mlxsw_sp_acl_block *block,
716 struct net_device *out_dev,
717 struct netlink_ext_ack *extack);
718 int mlxsw_sp_acl_rulei_act_fwd(struct mlxsw_sp *mlxsw_sp,
719 struct mlxsw_sp_acl_rule_info *rulei,
720 struct net_device *out_dev,
721 struct netlink_ext_ack *extack);
722 int mlxsw_sp_acl_rulei_act_vlan(struct mlxsw_sp *mlxsw_sp,
723 struct mlxsw_sp_acl_rule_info *rulei,
724 u32 action, u16 vid, u16 proto, u8 prio,
725 struct netlink_ext_ack *extack);
726 int mlxsw_sp_acl_rulei_act_count(struct mlxsw_sp *mlxsw_sp,
727 struct mlxsw_sp_acl_rule_info *rulei,
728 struct netlink_ext_ack *extack);
729 int mlxsw_sp_acl_rulei_act_fid_set(struct mlxsw_sp *mlxsw_sp,
730 struct mlxsw_sp_acl_rule_info *rulei,
731 u16 fid, struct netlink_ext_ack *extack);
732
733 struct mlxsw_sp_acl_rule;
734
735 struct mlxsw_sp_acl_rule *
736 mlxsw_sp_acl_rule_create(struct mlxsw_sp *mlxsw_sp,
737 struct mlxsw_sp_acl_ruleset *ruleset,
738 unsigned long cookie,
739 struct mlxsw_afa_block *afa_block,
740 struct netlink_ext_ack *extack);
741 void mlxsw_sp_acl_rule_destroy(struct mlxsw_sp *mlxsw_sp,
742 struct mlxsw_sp_acl_rule *rule);
743 int mlxsw_sp_acl_rule_add(struct mlxsw_sp *mlxsw_sp,
744 struct mlxsw_sp_acl_rule *rule);
745 void mlxsw_sp_acl_rule_del(struct mlxsw_sp *mlxsw_sp,
746 struct mlxsw_sp_acl_rule *rule);
747 int mlxsw_sp_acl_rule_action_replace(struct mlxsw_sp *mlxsw_sp,
748 struct mlxsw_sp_acl_rule *rule,
749 struct mlxsw_afa_block *afa_block);
750 struct mlxsw_sp_acl_rule *
751 mlxsw_sp_acl_rule_lookup(struct mlxsw_sp *mlxsw_sp,
752 struct mlxsw_sp_acl_ruleset *ruleset,
753 unsigned long cookie);
754 struct mlxsw_sp_acl_rule_info *
755 mlxsw_sp_acl_rule_rulei(struct mlxsw_sp_acl_rule *rule);
756 int mlxsw_sp_acl_rule_get_stats(struct mlxsw_sp *mlxsw_sp,
757 struct mlxsw_sp_acl_rule *rule,
758 u64 *packets, u64 *bytes, u64 *last_use);
759
760 struct mlxsw_sp_fid *mlxsw_sp_acl_dummy_fid(struct mlxsw_sp *mlxsw_sp);
761
762 int mlxsw_sp_acl_init(struct mlxsw_sp *mlxsw_sp);
763 void mlxsw_sp_acl_fini(struct mlxsw_sp *mlxsw_sp);
764 u32 mlxsw_sp_acl_region_rehash_intrvl_get(struct mlxsw_sp *mlxsw_sp);
765 int mlxsw_sp_acl_region_rehash_intrvl_set(struct mlxsw_sp *mlxsw_sp, u32 val);
766
767
768 struct mlxsw_sp_acl_tcam;
769 struct mlxsw_sp_acl_tcam_region;
770
771 struct mlxsw_sp_acl_tcam_ops {
772 enum mlxsw_reg_ptar_key_type key_type;
773 size_t priv_size;
774 int (*init)(struct mlxsw_sp *mlxsw_sp, void *priv,
775 struct mlxsw_sp_acl_tcam *tcam);
776 void (*fini)(struct mlxsw_sp *mlxsw_sp, void *priv);
777 size_t region_priv_size;
778 int (*region_init)(struct mlxsw_sp *mlxsw_sp, void *region_priv,
779 void *tcam_priv,
780 struct mlxsw_sp_acl_tcam_region *region,
781 void *hints_priv);
782 void (*region_fini)(struct mlxsw_sp *mlxsw_sp, void *region_priv);
783 int (*region_associate)(struct mlxsw_sp *mlxsw_sp,
784 struct mlxsw_sp_acl_tcam_region *region);
785 void * (*region_rehash_hints_get)(void *region_priv);
786 void (*region_rehash_hints_put)(void *hints_priv);
787 size_t chunk_priv_size;
788 void (*chunk_init)(void *region_priv, void *chunk_priv,
789 unsigned int priority);
790 void (*chunk_fini)(void *chunk_priv);
791 size_t entry_priv_size;
792 int (*entry_add)(struct mlxsw_sp *mlxsw_sp,
793 void *region_priv, void *chunk_priv,
794 void *entry_priv,
795 struct mlxsw_sp_acl_rule_info *rulei);
796 void (*entry_del)(struct mlxsw_sp *mlxsw_sp,
797 void *region_priv, void *chunk_priv,
798 void *entry_priv);
799 int (*entry_action_replace)(struct mlxsw_sp *mlxsw_sp,
800 void *region_priv, void *entry_priv,
801 struct mlxsw_sp_acl_rule_info *rulei);
802 int (*entry_activity_get)(struct mlxsw_sp *mlxsw_sp,
803 void *region_priv, void *entry_priv,
804 bool *activity);
805 };
806
807
808 extern const struct mlxsw_sp_acl_tcam_ops mlxsw_sp1_acl_tcam_ops;
809
810
811 extern const struct mlxsw_sp_acl_tcam_ops mlxsw_sp2_acl_tcam_ops;
812
813
814 extern const struct mlxsw_afa_ops mlxsw_sp1_act_afa_ops;
815 extern const struct mlxsw_afa_ops mlxsw_sp2_act_afa_ops;
816
817
818 extern const struct mlxsw_afk_ops mlxsw_sp1_afk_ops;
819 extern const struct mlxsw_afk_ops mlxsw_sp2_afk_ops;
820
821
822 int mlxsw_sp_flower_replace(struct mlxsw_sp *mlxsw_sp,
823 struct mlxsw_sp_acl_block *block,
824 struct flow_cls_offload *f);
825 void mlxsw_sp_flower_destroy(struct mlxsw_sp *mlxsw_sp,
826 struct mlxsw_sp_acl_block *block,
827 struct flow_cls_offload *f);
828 int mlxsw_sp_flower_stats(struct mlxsw_sp *mlxsw_sp,
829 struct mlxsw_sp_acl_block *block,
830 struct flow_cls_offload *f);
831 int mlxsw_sp_flower_tmplt_create(struct mlxsw_sp *mlxsw_sp,
832 struct mlxsw_sp_acl_block *block,
833 struct flow_cls_offload *f);
834 void mlxsw_sp_flower_tmplt_destroy(struct mlxsw_sp *mlxsw_sp,
835 struct mlxsw_sp_acl_block *block,
836 struct flow_cls_offload *f);
837
838
839 int mlxsw_sp_tc_qdisc_init(struct mlxsw_sp_port *mlxsw_sp_port);
840 void mlxsw_sp_tc_qdisc_fini(struct mlxsw_sp_port *mlxsw_sp_port);
841 int mlxsw_sp_setup_tc_red(struct mlxsw_sp_port *mlxsw_sp_port,
842 struct tc_red_qopt_offload *p);
843 int mlxsw_sp_setup_tc_prio(struct mlxsw_sp_port *mlxsw_sp_port,
844 struct tc_prio_qopt_offload *p);
845
846
847 bool mlxsw_sp_fid_is_dummy(struct mlxsw_sp *mlxsw_sp, u16 fid_index);
848 bool mlxsw_sp_fid_lag_vid_valid(const struct mlxsw_sp_fid *fid);
849 struct mlxsw_sp_fid *mlxsw_sp_fid_lookup_by_index(struct mlxsw_sp *mlxsw_sp,
850 u16 fid_index);
851 int mlxsw_sp_fid_nve_ifindex(const struct mlxsw_sp_fid *fid, int *nve_ifindex);
852 int mlxsw_sp_fid_nve_type(const struct mlxsw_sp_fid *fid,
853 enum mlxsw_sp_nve_type *p_type);
854 struct mlxsw_sp_fid *mlxsw_sp_fid_lookup_by_vni(struct mlxsw_sp *mlxsw_sp,
855 __be32 vni);
856 int mlxsw_sp_fid_vni(const struct mlxsw_sp_fid *fid, __be32 *vni);
857 int mlxsw_sp_fid_nve_flood_index_set(struct mlxsw_sp_fid *fid,
858 u32 nve_flood_index);
859 void mlxsw_sp_fid_nve_flood_index_clear(struct mlxsw_sp_fid *fid);
860 bool mlxsw_sp_fid_nve_flood_index_is_set(const struct mlxsw_sp_fid *fid);
861 int mlxsw_sp_fid_vni_set(struct mlxsw_sp_fid *fid, enum mlxsw_sp_nve_type type,
862 __be32 vni, int nve_ifindex);
863 void mlxsw_sp_fid_vni_clear(struct mlxsw_sp_fid *fid);
864 bool mlxsw_sp_fid_vni_is_set(const struct mlxsw_sp_fid *fid);
865 void mlxsw_sp_fid_fdb_clear_offload(const struct mlxsw_sp_fid *fid,
866 const struct net_device *nve_dev);
867 int mlxsw_sp_fid_flood_set(struct mlxsw_sp_fid *fid,
868 enum mlxsw_sp_flood_type packet_type, u8 local_port,
869 bool member);
870 int mlxsw_sp_fid_port_vid_map(struct mlxsw_sp_fid *fid,
871 struct mlxsw_sp_port *mlxsw_sp_port, u16 vid);
872 void mlxsw_sp_fid_port_vid_unmap(struct mlxsw_sp_fid *fid,
873 struct mlxsw_sp_port *mlxsw_sp_port, u16 vid);
874 u16 mlxsw_sp_fid_index(const struct mlxsw_sp_fid *fid);
875 enum mlxsw_sp_fid_type mlxsw_sp_fid_type(const struct mlxsw_sp_fid *fid);
876 void mlxsw_sp_fid_rif_set(struct mlxsw_sp_fid *fid, struct mlxsw_sp_rif *rif);
877 struct mlxsw_sp_rif *mlxsw_sp_fid_rif(const struct mlxsw_sp_fid *fid);
878 enum mlxsw_sp_rif_type
879 mlxsw_sp_fid_type_rif_type(const struct mlxsw_sp *mlxsw_sp,
880 enum mlxsw_sp_fid_type type);
881 u16 mlxsw_sp_fid_8021q_vid(const struct mlxsw_sp_fid *fid);
882 struct mlxsw_sp_fid *mlxsw_sp_fid_8021q_get(struct mlxsw_sp *mlxsw_sp, u16 vid);
883 struct mlxsw_sp_fid *mlxsw_sp_fid_8021d_get(struct mlxsw_sp *mlxsw_sp,
884 int br_ifindex);
885 struct mlxsw_sp_fid *mlxsw_sp_fid_8021q_lookup(struct mlxsw_sp *mlxsw_sp,
886 u16 vid);
887 struct mlxsw_sp_fid *mlxsw_sp_fid_8021d_lookup(struct mlxsw_sp *mlxsw_sp,
888 int br_ifindex);
889 struct mlxsw_sp_fid *mlxsw_sp_fid_rfid_get(struct mlxsw_sp *mlxsw_sp,
890 u16 rif_index);
891 struct mlxsw_sp_fid *mlxsw_sp_fid_dummy_get(struct mlxsw_sp *mlxsw_sp);
892 void mlxsw_sp_fid_put(struct mlxsw_sp_fid *fid);
893 int mlxsw_sp_port_fids_init(struct mlxsw_sp_port *mlxsw_sp_port);
894 void mlxsw_sp_port_fids_fini(struct mlxsw_sp_port *mlxsw_sp_port);
895 int mlxsw_sp_fids_init(struct mlxsw_sp *mlxsw_sp);
896 void mlxsw_sp_fids_fini(struct mlxsw_sp *mlxsw_sp);
897
898
899 enum mlxsw_sp_mr_route_prio {
900 MLXSW_SP_MR_ROUTE_PRIO_SG,
901 MLXSW_SP_MR_ROUTE_PRIO_STARG,
902 MLXSW_SP_MR_ROUTE_PRIO_CATCHALL,
903 __MLXSW_SP_MR_ROUTE_PRIO_MAX
904 };
905
906 #define MLXSW_SP_MR_ROUTE_PRIO_MAX (__MLXSW_SP_MR_ROUTE_PRIO_MAX - 1)
907
908 struct mlxsw_sp_mr_route_key;
909
910 struct mlxsw_sp_mr_tcam_ops {
911 size_t priv_size;
912 int (*init)(struct mlxsw_sp *mlxsw_sp, void *priv);
913 void (*fini)(void *priv);
914 size_t route_priv_size;
915 int (*route_create)(struct mlxsw_sp *mlxsw_sp, void *priv,
916 void *route_priv,
917 struct mlxsw_sp_mr_route_key *key,
918 struct mlxsw_afa_block *afa_block,
919 enum mlxsw_sp_mr_route_prio prio);
920 void (*route_destroy)(struct mlxsw_sp *mlxsw_sp, void *priv,
921 void *route_priv,
922 struct mlxsw_sp_mr_route_key *key);
923 int (*route_update)(struct mlxsw_sp *mlxsw_sp, void *route_priv,
924 struct mlxsw_sp_mr_route_key *key,
925 struct mlxsw_afa_block *afa_block);
926 };
927
928
929 extern const struct mlxsw_sp_mr_tcam_ops mlxsw_sp1_mr_tcam_ops;
930
931
932 extern const struct mlxsw_sp_mr_tcam_ops mlxsw_sp2_mr_tcam_ops;
933
934
935 struct mlxsw_sp_nve_params {
936 enum mlxsw_sp_nve_type type;
937 __be32 vni;
938 const struct net_device *dev;
939 };
940
941 extern const struct mlxsw_sp_nve_ops *mlxsw_sp1_nve_ops_arr[];
942 extern const struct mlxsw_sp_nve_ops *mlxsw_sp2_nve_ops_arr[];
943
944 int mlxsw_sp_nve_learned_ip_resolve(struct mlxsw_sp *mlxsw_sp, u32 uip,
945 enum mlxsw_sp_l3proto proto,
946 union mlxsw_sp_l3addr *addr);
947 int mlxsw_sp_nve_flood_ip_add(struct mlxsw_sp *mlxsw_sp,
948 struct mlxsw_sp_fid *fid,
949 enum mlxsw_sp_l3proto proto,
950 union mlxsw_sp_l3addr *addr);
951 void mlxsw_sp_nve_flood_ip_del(struct mlxsw_sp *mlxsw_sp,
952 struct mlxsw_sp_fid *fid,
953 enum mlxsw_sp_l3proto proto,
954 union mlxsw_sp_l3addr *addr);
955 u32 mlxsw_sp_nve_decap_tunnel_index_get(const struct mlxsw_sp *mlxsw_sp);
956 bool mlxsw_sp_nve_ipv4_route_is_decap(const struct mlxsw_sp *mlxsw_sp,
957 u32 tb_id, __be32 addr);
958 int mlxsw_sp_nve_fid_enable(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_fid *fid,
959 struct mlxsw_sp_nve_params *params,
960 struct netlink_ext_ack *extack);
961 void mlxsw_sp_nve_fid_disable(struct mlxsw_sp *mlxsw_sp,
962 struct mlxsw_sp_fid *fid);
963 int mlxsw_sp_port_nve_init(struct mlxsw_sp_port *mlxsw_sp_port);
964 void mlxsw_sp_port_nve_fini(struct mlxsw_sp_port *mlxsw_sp_port);
965 int mlxsw_sp_nve_init(struct mlxsw_sp *mlxsw_sp);
966 void mlxsw_sp_nve_fini(struct mlxsw_sp *mlxsw_sp);
967
968
969 int mlxsw_sp_nve_inc_parsing_depth_get(struct mlxsw_sp *mlxsw_sp);
970 void mlxsw_sp_nve_inc_parsing_depth_put(struct mlxsw_sp *mlxsw_sp);
971
972
973 int mlxsw_sp_devlink_traps_init(struct mlxsw_sp *mlxsw_sp);
974 void mlxsw_sp_devlink_traps_fini(struct mlxsw_sp *mlxsw_sp);
975 int mlxsw_sp_trap_init(struct mlxsw_core *mlxsw_core,
976 const struct devlink_trap *trap, void *trap_ctx);
977 void mlxsw_sp_trap_fini(struct mlxsw_core *mlxsw_core,
978 const struct devlink_trap *trap, void *trap_ctx);
979 int mlxsw_sp_trap_action_set(struct mlxsw_core *mlxsw_core,
980 const struct devlink_trap *trap,
981 enum devlink_trap_action action);
982 int mlxsw_sp_trap_group_init(struct mlxsw_core *mlxsw_core,
983 const struct devlink_trap_group *group);
984
985 #endif