1 /* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */
2 /* Copyright (c) 2015-2018 Mellanox Technologies. All rights reserved */
4 #ifndef _MLXSW_SPECTRUM_H
5 #define _MLXSW_SPECTRUM_H
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 <linux/net_namespace.h>
18 #include <net/psample.h>
19 #include <net/pkt_cls.h>
21 #include <net/vxlan.h>
22 #include <net/flow_offload.h>
26 #include "core_acl_flex_keys.h"
27 #include "core_acl_flex_actions.h"
30 #define MLXSW_SP_DEFAULT_VID (VLAN_N_VID - 1)
32 #define MLXSW_SP_FID_8021D_MAX 1024
34 #define MLXSW_SP_MID_MAX 7000
36 #define MLXSW_SP_KVD_LINEAR_SIZE 98304 /* entries */
37 #define MLXSW_SP_KVD_GRANULARITY 128
39 #define MLXSW_SP_RESOURCE_NAME_KVD "kvd"
40 #define MLXSW_SP_RESOURCE_NAME_KVD_LINEAR "linear"
41 #define MLXSW_SP_RESOURCE_NAME_KVD_HASH_SINGLE "hash_single"
42 #define MLXSW_SP_RESOURCE_NAME_KVD_HASH_DOUBLE "hash_double"
43 #define MLXSW_SP_RESOURCE_NAME_KVD_LINEAR_SINGLES "singles"
44 #define MLXSW_SP_RESOURCE_NAME_KVD_LINEAR_CHUNKS "chunks"
45 #define MLXSW_SP_RESOURCE_NAME_KVD_LINEAR_LARGE_CHUNKS "large_chunks"
47 #define MLXSW_SP_RESOURCE_NAME_SPAN "span_agents"
49 #define MLXSW_SP_RESOURCE_NAME_COUNTERS "counters"
50 #define MLXSW_SP_RESOURCE_NAME_COUNTERS_FLOW "flow"
51 #define MLXSW_SP_RESOURCE_NAME_COUNTERS_RIF "rif"
53 enum mlxsw_sp_resource_id {
54 MLXSW_SP_RESOURCE_KVD = 1,
55 MLXSW_SP_RESOURCE_KVD_LINEAR,
56 MLXSW_SP_RESOURCE_KVD_HASH_SINGLE,
57 MLXSW_SP_RESOURCE_KVD_HASH_DOUBLE,
58 MLXSW_SP_RESOURCE_KVD_LINEAR_SINGLE,
59 MLXSW_SP_RESOURCE_KVD_LINEAR_CHUNKS,
60 MLXSW_SP_RESOURCE_KVD_LINEAR_LARGE_CHUNKS,
61 MLXSW_SP_RESOURCE_SPAN,
62 MLXSW_SP_RESOURCE_COUNTERS,
63 MLXSW_SP_RESOURCE_COUNTERS_FLOW,
64 MLXSW_SP_RESOURCE_COUNTERS_RIF,
69 struct mlxsw_sp_span_entry;
70 enum mlxsw_sp_l3proto;
71 union mlxsw_sp_l3addr;
73 struct mlxsw_sp_upper {
74 struct net_device *dev;
75 unsigned int ref_count;
78 enum mlxsw_sp_rif_type {
79 MLXSW_SP_RIF_TYPE_SUBPORT,
80 MLXSW_SP_RIF_TYPE_VLAN,
81 MLXSW_SP_RIF_TYPE_FID,
82 MLXSW_SP_RIF_TYPE_IPIP_LB, /* IP-in-IP loopback. */
83 MLXSW_SP_RIF_TYPE_MAX,
86 struct mlxsw_sp_rif_ops;
88 extern const struct mlxsw_sp_rif_ops *mlxsw_sp1_rif_ops_arr[];
89 extern const struct mlxsw_sp_rif_ops *mlxsw_sp2_rif_ops_arr[];
91 enum mlxsw_sp_fid_type {
92 MLXSW_SP_FID_TYPE_8021Q,
93 MLXSW_SP_FID_TYPE_8021D,
94 MLXSW_SP_FID_TYPE_RFID,
95 MLXSW_SP_FID_TYPE_DUMMY,
96 MLXSW_SP_FID_TYPE_MAX,
99 enum mlxsw_sp_nve_type {
100 MLXSW_SP_NVE_TYPE_VXLAN,
103 struct mlxsw_sp_mid {
104 struct list_head list;
105 unsigned char addr[ETH_ALEN];
109 unsigned long *ports_in_mid; /* bits array */
113 struct mlxsw_sp_bridge;
114 struct mlxsw_sp_router;
117 struct mlxsw_sp_counter_pool;
118 struct mlxsw_sp_fid_core;
119 struct mlxsw_sp_kvdl;
121 struct mlxsw_sp_kvdl_ops;
122 struct mlxsw_sp_mr_tcam_ops;
123 struct mlxsw_sp_acl_tcam_ops;
124 struct mlxsw_sp_nve_ops;
125 struct mlxsw_sp_sb_vals;
126 struct mlxsw_sp_port_type_speed_ops;
127 struct mlxsw_sp_ptp_state;
128 struct mlxsw_sp_ptp_ops;
129 struct mlxsw_sp_span_ops;
130 struct mlxsw_sp_qdisc_state;
132 struct mlxsw_sp_port_mapping {
139 struct mlxsw_sp_port **ports;
140 struct mlxsw_core *core;
141 const struct mlxsw_bus_info *bus_info;
142 unsigned char base_mac[ETH_ALEN];
143 const unsigned char *mac_mask;
144 struct mlxsw_sp_upper *lags;
145 struct mlxsw_sp_port_mapping **port_mapping;
146 struct mlxsw_sp_sb *sb;
147 struct mlxsw_sp_bridge *bridge;
148 struct mlxsw_sp_router *router;
149 struct mlxsw_sp_mr *mr;
150 struct mlxsw_afa *afa;
151 struct mlxsw_sp_acl *acl;
152 struct mlxsw_sp_fid_core *fid_core;
153 struct mlxsw_sp_kvdl *kvdl;
154 struct mlxsw_sp_nve *nve;
155 struct notifier_block netdevice_nb;
156 struct mlxsw_sp_ptp_clock *clock;
157 struct mlxsw_sp_ptp_state *ptp_state;
158 struct mlxsw_sp_counter_pool *counter_pool;
159 struct mlxsw_sp_span *span;
160 struct mlxsw_sp_trap *trap;
161 const struct mlxsw_fw_rev *req_rev;
162 const char *fw_filename;
163 const struct mlxsw_sp_kvdl_ops *kvdl_ops;
164 const struct mlxsw_afa_ops *afa_ops;
165 const struct mlxsw_afk_ops *afk_ops;
166 const struct mlxsw_sp_mr_tcam_ops *mr_tcam_ops;
167 const struct mlxsw_sp_acl_tcam_ops *acl_tcam_ops;
168 const struct mlxsw_sp_nve_ops **nve_ops_arr;
169 const struct mlxsw_sp_rif_ops **rif_ops_arr;
170 const struct mlxsw_sp_sb_vals *sb_vals;
171 const struct mlxsw_sp_port_type_speed_ops *port_type_speed_ops;
172 const struct mlxsw_sp_ptp_ops *ptp_ops;
173 const struct mlxsw_sp_span_ops *span_ops;
174 const struct mlxsw_listener *listeners;
175 size_t listeners_count;
176 u32 lowest_shaper_bs;
179 static inline struct mlxsw_sp_upper *
180 mlxsw_sp_lag_get(struct mlxsw_sp *mlxsw_sp, u16 lag_id)
182 return &mlxsw_sp->lags[lag_id];
185 struct mlxsw_sp_port_pcpu_stats {
190 struct u64_stats_sync syncp;
194 struct mlxsw_sp_port_sample {
195 struct psample_group *psample_group;
201 struct mlxsw_sp_bridge_port;
204 struct mlxsw_sp_port_vlan {
205 struct list_head list;
206 struct mlxsw_sp_port *mlxsw_sp_port;
207 struct mlxsw_sp_fid *fid;
209 struct mlxsw_sp_bridge_port *bridge_port;
210 struct list_head bridge_vlan_node;
213 /* No need an internal lock; At worse - miss a single periodic iteration */
214 struct mlxsw_sp_port_xstats {
216 u64 wred_drop[TC_MAX_QUEUE];
217 u64 tail_drop[TC_MAX_QUEUE];
218 u64 backlog[TC_MAX_QUEUE];
219 u64 tx_bytes[IEEE_8021QAZ_MAX_TCS];
220 u64 tx_packets[IEEE_8021QAZ_MAX_TCS];
223 struct mlxsw_sp_ptp_port_dir_stats {
228 struct mlxsw_sp_ptp_port_stats {
229 struct mlxsw_sp_ptp_port_dir_stats rx_gcd;
230 struct mlxsw_sp_ptp_port_dir_stats tx_gcd;
233 struct mlxsw_sp_port {
234 struct net_device *dev;
235 struct mlxsw_sp_port_pcpu_stats __percpu *pcpu_stats;
236 struct mlxsw_sp *mlxsw_sp;
248 struct ieee_ets *ets;
249 struct ieee_maxrate *maxrate;
250 struct ieee_pfc *pfc;
251 enum mlxsw_reg_qpts_trust_state trust_state;
253 struct mlxsw_sp_port_mapping mapping; /* mapping is constant during the
254 * mlxsw_sp_port lifetime, however
255 * the same localport can have
259 #define MLXSW_HW_STATS_UPDATE_TIME HZ
260 struct rtnl_link_stats64 stats;
261 struct mlxsw_sp_port_xstats xstats;
262 struct delayed_work update_dw;
264 struct mlxsw_sp_port_sample __rcu *sample;
265 struct list_head vlans_list;
266 struct mlxsw_sp_port_vlan *default_vlan;
267 struct mlxsw_sp_qdisc_state *qdisc;
268 unsigned acl_rule_count;
269 struct mlxsw_sp_flow_block *ing_flow_block;
270 struct mlxsw_sp_flow_block *eg_flow_block;
272 struct delayed_work shaper_dw;
273 struct hwtstamp_config hwtstamp_config;
276 struct mlxsw_sp_ptp_port_stats stats;
278 u8 split_base_local_port;
280 struct delayed_work speed_update_dw;
284 struct mlxsw_sp_port_type_speed_ops {
285 void (*from_ptys_supported_port)(struct mlxsw_sp *mlxsw_sp,
287 struct ethtool_link_ksettings *cmd);
288 void (*from_ptys_link)(struct mlxsw_sp *mlxsw_sp, u32 ptys_eth_proto,
289 u8 width, unsigned long *mode);
290 u32 (*from_ptys_speed)(struct mlxsw_sp *mlxsw_sp, u32 ptys_eth_proto);
291 void (*from_ptys_speed_duplex)(struct mlxsw_sp *mlxsw_sp,
292 bool carrier_ok, u32 ptys_eth_proto,
293 struct ethtool_link_ksettings *cmd);
294 u32 (*to_ptys_advert_link)(struct mlxsw_sp *mlxsw_sp, u8 width,
295 const struct ethtool_link_ksettings *cmd);
296 u32 (*to_ptys_speed)(struct mlxsw_sp *mlxsw_sp, u8 width, u32 speed);
297 void (*reg_ptys_eth_pack)(struct mlxsw_sp *mlxsw_sp, char *payload,
298 u8 local_port, u32 proto_admin, bool autoneg);
299 void (*reg_ptys_eth_unpack)(struct mlxsw_sp *mlxsw_sp, char *payload,
300 u32 *p_eth_proto_cap,
301 u32 *p_eth_proto_admin,
302 u32 *p_eth_proto_oper);
305 static inline struct net_device *
306 mlxsw_sp_bridge_vxlan_dev_find(struct net_device *br_dev)
308 struct net_device *dev;
309 struct list_head *iter;
311 netdev_for_each_lower_dev(br_dev, dev, iter) {
312 if (netif_is_vxlan(dev))
319 static inline bool mlxsw_sp_bridge_has_vxlan(struct net_device *br_dev)
321 return !!mlxsw_sp_bridge_vxlan_dev_find(br_dev);
325 mlxsw_sp_vxlan_mapped_vid(const struct net_device *vxlan_dev, u16 *p_vid)
327 struct bridge_vlan_info vinfo;
331 err = br_vlan_get_pvid(vxlan_dev, &vid);
335 err = br_vlan_get_info(vxlan_dev, vid, &vinfo);
336 if (err || !(vinfo.flags & BRIDGE_VLAN_INFO_UNTAGGED))
345 mlxsw_sp_port_is_pause_en(const struct mlxsw_sp_port *mlxsw_sp_port)
347 return mlxsw_sp_port->link.tx_pause || mlxsw_sp_port->link.rx_pause;
350 static inline struct mlxsw_sp_port *
351 mlxsw_sp_port_lagged_get(struct mlxsw_sp *mlxsw_sp, u16 lag_id, u8 port_index)
353 struct mlxsw_sp_port *mlxsw_sp_port;
356 local_port = mlxsw_core_lag_mapping_get(mlxsw_sp->core,
358 mlxsw_sp_port = mlxsw_sp->ports[local_port];
359 return mlxsw_sp_port && mlxsw_sp_port->lagged ? mlxsw_sp_port : NULL;
362 static inline struct mlxsw_sp_port_vlan *
363 mlxsw_sp_port_vlan_find_by_vid(const struct mlxsw_sp_port *mlxsw_sp_port,
366 struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan;
368 list_for_each_entry(mlxsw_sp_port_vlan, &mlxsw_sp_port->vlans_list,
370 if (mlxsw_sp_port_vlan->vid == vid)
371 return mlxsw_sp_port_vlan;
377 enum mlxsw_sp_flood_type {
378 MLXSW_SP_FLOOD_TYPE_UC,
379 MLXSW_SP_FLOOD_TYPE_BC,
380 MLXSW_SP_FLOOD_TYPE_MC,
383 /* spectrum_buffers.c */
384 int mlxsw_sp_buffers_init(struct mlxsw_sp *mlxsw_sp);
385 void mlxsw_sp_buffers_fini(struct mlxsw_sp *mlxsw_sp);
386 int mlxsw_sp_port_buffers_init(struct mlxsw_sp_port *mlxsw_sp_port);
387 int mlxsw_sp_sb_pool_get(struct mlxsw_core *mlxsw_core,
388 unsigned int sb_index, u16 pool_index,
389 struct devlink_sb_pool_info *pool_info);
390 int mlxsw_sp_sb_pool_set(struct mlxsw_core *mlxsw_core,
391 unsigned int sb_index, u16 pool_index, u32 size,
392 enum devlink_sb_threshold_type threshold_type,
393 struct netlink_ext_ack *extack);
394 int mlxsw_sp_sb_port_pool_get(struct mlxsw_core_port *mlxsw_core_port,
395 unsigned int sb_index, u16 pool_index,
397 int mlxsw_sp_sb_port_pool_set(struct mlxsw_core_port *mlxsw_core_port,
398 unsigned int sb_index, u16 pool_index,
399 u32 threshold, struct netlink_ext_ack *extack);
400 int mlxsw_sp_sb_tc_pool_bind_get(struct mlxsw_core_port *mlxsw_core_port,
401 unsigned int sb_index, u16 tc_index,
402 enum devlink_sb_pool_type pool_type,
403 u16 *p_pool_index, u32 *p_threshold);
404 int mlxsw_sp_sb_tc_pool_bind_set(struct mlxsw_core_port *mlxsw_core_port,
405 unsigned int sb_index, u16 tc_index,
406 enum devlink_sb_pool_type pool_type,
407 u16 pool_index, u32 threshold,
408 struct netlink_ext_ack *extack);
409 int mlxsw_sp_sb_occ_snapshot(struct mlxsw_core *mlxsw_core,
410 unsigned int sb_index);
411 int mlxsw_sp_sb_occ_max_clear(struct mlxsw_core *mlxsw_core,
412 unsigned int sb_index);
413 int mlxsw_sp_sb_occ_port_pool_get(struct mlxsw_core_port *mlxsw_core_port,
414 unsigned int sb_index, u16 pool_index,
415 u32 *p_cur, u32 *p_max);
416 int mlxsw_sp_sb_occ_tc_port_bind_get(struct mlxsw_core_port *mlxsw_core_port,
417 unsigned int sb_index, u16 tc_index,
418 enum devlink_sb_pool_type pool_type,
419 u32 *p_cur, u32 *p_max);
420 u32 mlxsw_sp_cells_bytes(const struct mlxsw_sp *mlxsw_sp, u32 cells);
421 u32 mlxsw_sp_bytes_cells(const struct mlxsw_sp *mlxsw_sp, u32 bytes);
422 u32 mlxsw_sp_sb_max_headroom_cells(const struct mlxsw_sp *mlxsw_sp);
424 extern const struct mlxsw_sp_sb_vals mlxsw_sp1_sb_vals;
425 extern const struct mlxsw_sp_sb_vals mlxsw_sp2_sb_vals;
427 /* spectrum_switchdev.c */
428 int mlxsw_sp_switchdev_init(struct mlxsw_sp *mlxsw_sp);
429 void mlxsw_sp_switchdev_fini(struct mlxsw_sp *mlxsw_sp);
430 int mlxsw_sp_rif_fdb_op(struct mlxsw_sp *mlxsw_sp, const char *mac, u16 fid,
433 mlxsw_sp_port_vlan_bridge_leave(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan);
434 int mlxsw_sp_port_bridge_join(struct mlxsw_sp_port *mlxsw_sp_port,
435 struct net_device *brport_dev,
436 struct net_device *br_dev,
437 struct netlink_ext_ack *extack);
438 void mlxsw_sp_port_bridge_leave(struct mlxsw_sp_port *mlxsw_sp_port,
439 struct net_device *brport_dev,
440 struct net_device *br_dev);
441 bool mlxsw_sp_bridge_device_is_offloaded(const struct mlxsw_sp *mlxsw_sp,
442 const struct net_device *br_dev);
443 int mlxsw_sp_bridge_vxlan_join(struct mlxsw_sp *mlxsw_sp,
444 const struct net_device *br_dev,
445 const struct net_device *vxlan_dev, u16 vid,
446 struct netlink_ext_ack *extack);
447 void mlxsw_sp_bridge_vxlan_leave(struct mlxsw_sp *mlxsw_sp,
448 const struct net_device *vxlan_dev);
449 extern struct notifier_block mlxsw_sp_switchdev_notifier;
452 void mlxsw_sp_rx_listener_no_mark_func(struct sk_buff *skb,
453 u8 local_port, void *priv);
454 void mlxsw_sp_ptp_receive(struct mlxsw_sp *mlxsw_sp, struct sk_buff *skb,
456 void mlxsw_sp_sample_receive(struct mlxsw_sp *mlxsw_sp, struct sk_buff *skb,
458 int mlxsw_sp_port_speed_get(struct mlxsw_sp_port *mlxsw_sp_port, u32 *speed);
459 int mlxsw_sp_port_ets_set(struct mlxsw_sp_port *mlxsw_sp_port,
460 enum mlxsw_reg_qeec_hr hr, u8 index, u8 next_index,
461 bool dwrr, u8 dwrr_weight);
462 int mlxsw_sp_port_prio_tc_set(struct mlxsw_sp_port *mlxsw_sp_port,
463 u8 switch_prio, u8 tclass);
464 int __mlxsw_sp_port_headroom_set(struct mlxsw_sp_port *mlxsw_sp_port, int mtu,
465 u8 *prio_tc, bool pause_en,
466 struct ieee_pfc *my_pfc);
467 int mlxsw_sp_port_ets_maxrate_set(struct mlxsw_sp_port *mlxsw_sp_port,
468 enum mlxsw_reg_qeec_hr hr, u8 index,
469 u8 next_index, u32 maxrate, u8 burst_size);
470 enum mlxsw_reg_spms_state mlxsw_sp_stp_spms_state(u8 stp_state);
471 int mlxsw_sp_port_vid_stp_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid,
473 int mlxsw_sp_port_vp_mode_set(struct mlxsw_sp_port *mlxsw_sp_port, bool enable);
474 int mlxsw_sp_port_vid_learning_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid,
476 int mlxsw_sp_port_pvid_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid);
477 struct mlxsw_sp_port_vlan *
478 mlxsw_sp_port_vlan_create(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid);
479 void mlxsw_sp_port_vlan_destroy(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan);
480 int mlxsw_sp_port_vlan_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid_begin,
481 u16 vid_end, bool is_member, bool untagged);
482 int mlxsw_sp_flow_counter_get(struct mlxsw_sp *mlxsw_sp,
483 unsigned int counter_index, u64 *packets,
485 int mlxsw_sp_flow_counter_alloc(struct mlxsw_sp *mlxsw_sp,
486 unsigned int *p_counter_index);
487 void mlxsw_sp_flow_counter_free(struct mlxsw_sp *mlxsw_sp,
488 unsigned int counter_index);
489 u32 mlxsw_sp_span_buffsize_get(struct mlxsw_sp *mlxsw_sp, int mtu, u32 speed);
490 bool mlxsw_sp_port_dev_check(const struct net_device *dev);
491 struct mlxsw_sp *mlxsw_sp_lower_get(struct net_device *dev);
492 struct mlxsw_sp_port *mlxsw_sp_port_dev_lower_find(struct net_device *dev);
493 struct mlxsw_sp_port *mlxsw_sp_port_lower_dev_hold(struct net_device *dev);
494 void mlxsw_sp_port_dev_put(struct mlxsw_sp_port *mlxsw_sp_port);
495 struct mlxsw_sp_port *mlxsw_sp_port_dev_lower_find_rcu(struct net_device *dev);
498 #ifdef CONFIG_MLXSW_SPECTRUM_DCB
499 int mlxsw_sp_port_dcb_init(struct mlxsw_sp_port *mlxsw_sp_port);
500 void mlxsw_sp_port_dcb_fini(struct mlxsw_sp_port *mlxsw_sp_port);
502 static inline int mlxsw_sp_port_dcb_init(struct mlxsw_sp_port *mlxsw_sp_port)
506 static inline void mlxsw_sp_port_dcb_fini(struct mlxsw_sp_port *mlxsw_sp_port)
510 /* spectrum_router.c */
511 enum mlxsw_sp_l3proto {
512 MLXSW_SP_L3_PROTO_IPV4,
513 MLXSW_SP_L3_PROTO_IPV6,
514 #define MLXSW_SP_L3_PROTO_MAX (MLXSW_SP_L3_PROTO_IPV6 + 1)
517 union mlxsw_sp_l3addr {
519 struct in6_addr addr6;
522 int mlxsw_sp_router_init(struct mlxsw_sp *mlxsw_sp,
523 struct netlink_ext_ack *extack);
524 void mlxsw_sp_router_fini(struct mlxsw_sp *mlxsw_sp);
525 int mlxsw_sp_netdevice_router_port_event(struct net_device *dev,
526 unsigned long event, void *ptr);
527 void mlxsw_sp_rif_macvlan_del(struct mlxsw_sp *mlxsw_sp,
528 const struct net_device *macvlan_dev);
529 int mlxsw_sp_inetaddr_valid_event(struct notifier_block *unused,
530 unsigned long event, void *ptr);
531 int mlxsw_sp_inet6addr_valid_event(struct notifier_block *unused,
532 unsigned long event, void *ptr);
533 int mlxsw_sp_netdevice_vrf_event(struct net_device *l3_dev, unsigned long event,
534 struct netdev_notifier_changeupper_info *info);
535 bool mlxsw_sp_netdev_is_ipip_ol(const struct mlxsw_sp *mlxsw_sp,
536 const struct net_device *dev);
537 bool mlxsw_sp_netdev_is_ipip_ul(struct mlxsw_sp *mlxsw_sp,
538 const struct net_device *dev);
539 int mlxsw_sp_netdevice_ipip_ol_event(struct mlxsw_sp *mlxsw_sp,
540 struct net_device *l3_dev,
542 struct netdev_notifier_info *info);
544 mlxsw_sp_netdevice_ipip_ul_event(struct mlxsw_sp *mlxsw_sp,
545 struct net_device *l3_dev,
547 struct netdev_notifier_info *info);
549 mlxsw_sp_port_vlan_router_leave(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan);
550 void mlxsw_sp_rif_destroy_by_dev(struct mlxsw_sp *mlxsw_sp,
551 struct net_device *dev);
552 bool mlxsw_sp_rif_exists(struct mlxsw_sp *mlxsw_sp,
553 const struct net_device *dev);
554 u16 mlxsw_sp_rif_vid(struct mlxsw_sp *mlxsw_sp, const struct net_device *dev);
555 u8 mlxsw_sp_router_port(const struct mlxsw_sp *mlxsw_sp);
556 int mlxsw_sp_router_nve_promote_decap(struct mlxsw_sp *mlxsw_sp, u32 ul_tb_id,
557 enum mlxsw_sp_l3proto ul_proto,
558 const union mlxsw_sp_l3addr *ul_sip,
560 void mlxsw_sp_router_nve_demote_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 int mlxsw_sp_router_tb_id_vr_id(struct mlxsw_sp *mlxsw_sp, u32 tb_id,
565 int mlxsw_sp_router_ul_rif_get(struct mlxsw_sp *mlxsw_sp, u32 ul_tb_id,
567 void mlxsw_sp_router_ul_rif_put(struct mlxsw_sp *mlxsw_sp, u16 ul_rif_index);
569 /* spectrum_kvdl.c */
570 enum mlxsw_sp_kvdl_entry_type {
571 MLXSW_SP_KVDL_ENTRY_TYPE_ADJ,
572 MLXSW_SP_KVDL_ENTRY_TYPE_ACTSET,
573 MLXSW_SP_KVDL_ENTRY_TYPE_PBS,
574 MLXSW_SP_KVDL_ENTRY_TYPE_MCRIGR,
575 MLXSW_SP_KVDL_ENTRY_TYPE_TNUMT,
578 static inline unsigned int
579 mlxsw_sp_kvdl_entry_size(enum mlxsw_sp_kvdl_entry_type type)
582 case MLXSW_SP_KVDL_ENTRY_TYPE_ADJ: /* fall through */
583 case MLXSW_SP_KVDL_ENTRY_TYPE_ACTSET: /* fall through */
584 case MLXSW_SP_KVDL_ENTRY_TYPE_PBS: /* fall through */
585 case MLXSW_SP_KVDL_ENTRY_TYPE_MCRIGR: /* fall through */
586 case MLXSW_SP_KVDL_ENTRY_TYPE_TNUMT: /* fall through */
592 struct mlxsw_sp_kvdl_ops {
594 int (*init)(struct mlxsw_sp *mlxsw_sp, void *priv);
595 void (*fini)(struct mlxsw_sp *mlxsw_sp, void *priv);
596 int (*alloc)(struct mlxsw_sp *mlxsw_sp, void *priv,
597 enum mlxsw_sp_kvdl_entry_type type,
598 unsigned int entry_count, u32 *p_entry_index);
599 void (*free)(struct mlxsw_sp *mlxsw_sp, void *priv,
600 enum mlxsw_sp_kvdl_entry_type type,
601 unsigned int entry_count, int entry_index);
602 int (*alloc_size_query)(struct mlxsw_sp *mlxsw_sp, void *priv,
603 enum mlxsw_sp_kvdl_entry_type type,
604 unsigned int entry_count,
605 unsigned int *p_alloc_count);
606 int (*resources_register)(struct mlxsw_sp *mlxsw_sp, void *priv);
609 int mlxsw_sp_kvdl_init(struct mlxsw_sp *mlxsw_sp);
610 void mlxsw_sp_kvdl_fini(struct mlxsw_sp *mlxsw_sp);
611 int mlxsw_sp_kvdl_alloc(struct mlxsw_sp *mlxsw_sp,
612 enum mlxsw_sp_kvdl_entry_type type,
613 unsigned int entry_count, u32 *p_entry_index);
614 void mlxsw_sp_kvdl_free(struct mlxsw_sp *mlxsw_sp,
615 enum mlxsw_sp_kvdl_entry_type type,
616 unsigned int entry_count, int entry_index);
617 int mlxsw_sp_kvdl_alloc_count_query(struct mlxsw_sp *mlxsw_sp,
618 enum mlxsw_sp_kvdl_entry_type type,
619 unsigned int entry_count,
620 unsigned int *p_alloc_count);
622 /* spectrum1_kvdl.c */
623 extern const struct mlxsw_sp_kvdl_ops mlxsw_sp1_kvdl_ops;
624 int mlxsw_sp1_kvdl_resources_register(struct mlxsw_core *mlxsw_core);
626 /* spectrum2_kvdl.c */
627 extern const struct mlxsw_sp_kvdl_ops mlxsw_sp2_kvdl_ops;
629 struct mlxsw_sp_acl_rule_info {
630 unsigned int priority;
631 struct mlxsw_afk_element_values values;
632 struct mlxsw_afa_block *act_block;
634 ingress_bind_blocker:1,
635 egress_bind_blocker:1,
637 unsigned int counter_index;
640 /* spectrum_flow.c */
641 struct mlxsw_sp_flow_block {
642 struct list_head binding_list;
644 struct list_head list;
645 unsigned int min_prio;
646 unsigned int max_prio;
648 struct mlxsw_sp_acl_ruleset *ruleset_zero;
649 struct mlxsw_sp *mlxsw_sp;
650 unsigned int rule_count;
651 unsigned int disable_count;
652 unsigned int ingress_blocker_rule_count;
653 unsigned int egress_blocker_rule_count;
654 unsigned int ingress_binding_count;
655 unsigned int egress_binding_count;
659 struct mlxsw_sp_flow_block_binding {
660 struct list_head list;
661 struct net_device *dev;
662 struct mlxsw_sp_port *mlxsw_sp_port;
666 static inline struct mlxsw_sp *
667 mlxsw_sp_flow_block_mlxsw_sp(struct mlxsw_sp_flow_block *block)
669 return block->mlxsw_sp;
672 static inline unsigned int
673 mlxsw_sp_flow_block_rule_count(const struct mlxsw_sp_flow_block *block)
675 return block ? block->rule_count : 0;
679 mlxsw_sp_flow_block_disable_inc(struct mlxsw_sp_flow_block *block)
682 block->disable_count++;
686 mlxsw_sp_flow_block_disable_dec(struct mlxsw_sp_flow_block *block)
689 block->disable_count--;
693 mlxsw_sp_flow_block_disabled(const struct mlxsw_sp_flow_block *block)
695 return block->disable_count;
699 mlxsw_sp_flow_block_is_egress_bound(const struct mlxsw_sp_flow_block *block)
701 return block->egress_binding_count;
705 mlxsw_sp_flow_block_is_ingress_bound(const struct mlxsw_sp_flow_block *block)
707 return block->ingress_binding_count;
711 mlxsw_sp_flow_block_is_mixed_bound(const struct mlxsw_sp_flow_block *block)
713 return block->ingress_binding_count && block->egress_binding_count;
716 struct mlxsw_sp_flow_block *mlxsw_sp_flow_block_create(struct mlxsw_sp *mlxsw_sp,
718 void mlxsw_sp_flow_block_destroy(struct mlxsw_sp_flow_block *block);
719 int mlxsw_sp_setup_tc_block(struct mlxsw_sp_port *mlxsw_sp_port,
720 struct flow_block_offload *f);
723 struct mlxsw_sp_acl_ruleset;
725 enum mlxsw_sp_acl_profile {
726 MLXSW_SP_ACL_PROFILE_FLOWER,
727 MLXSW_SP_ACL_PROFILE_MR,
730 struct mlxsw_afk *mlxsw_sp_acl_afk(struct mlxsw_sp_acl *acl);
732 int mlxsw_sp_acl_ruleset_bind(struct mlxsw_sp *mlxsw_sp,
733 struct mlxsw_sp_flow_block *block,
734 struct mlxsw_sp_flow_block_binding *binding);
735 void mlxsw_sp_acl_ruleset_unbind(struct mlxsw_sp *mlxsw_sp,
736 struct mlxsw_sp_flow_block *block,
737 struct mlxsw_sp_flow_block_binding *binding);
738 struct mlxsw_sp_acl_ruleset *
739 mlxsw_sp_acl_ruleset_lookup(struct mlxsw_sp *mlxsw_sp,
740 struct mlxsw_sp_flow_block *block, u32 chain_index,
741 enum mlxsw_sp_acl_profile profile);
742 struct mlxsw_sp_acl_ruleset *
743 mlxsw_sp_acl_ruleset_get(struct mlxsw_sp *mlxsw_sp,
744 struct mlxsw_sp_flow_block *block, u32 chain_index,
745 enum mlxsw_sp_acl_profile profile,
746 struct mlxsw_afk_element_usage *tmplt_elusage);
747 void mlxsw_sp_acl_ruleset_put(struct mlxsw_sp *mlxsw_sp,
748 struct mlxsw_sp_acl_ruleset *ruleset);
749 u16 mlxsw_sp_acl_ruleset_group_id(struct mlxsw_sp_acl_ruleset *ruleset);
750 void mlxsw_sp_acl_ruleset_prio_get(struct mlxsw_sp_acl_ruleset *ruleset,
751 unsigned int *p_min_prio,
752 unsigned int *p_max_prio);
754 struct mlxsw_sp_acl_rule_info *
755 mlxsw_sp_acl_rulei_create(struct mlxsw_sp_acl *acl,
756 struct mlxsw_afa_block *afa_block);
757 void mlxsw_sp_acl_rulei_destroy(struct mlxsw_sp_acl_rule_info *rulei);
758 int mlxsw_sp_acl_rulei_commit(struct mlxsw_sp_acl_rule_info *rulei);
759 void mlxsw_sp_acl_rulei_priority(struct mlxsw_sp_acl_rule_info *rulei,
760 unsigned int priority);
761 void mlxsw_sp_acl_rulei_keymask_u32(struct mlxsw_sp_acl_rule_info *rulei,
762 enum mlxsw_afk_element element,
763 u32 key_value, u32 mask_value);
764 void mlxsw_sp_acl_rulei_keymask_buf(struct mlxsw_sp_acl_rule_info *rulei,
765 enum mlxsw_afk_element element,
766 const char *key_value,
767 const char *mask_value, unsigned int len);
768 int mlxsw_sp_acl_rulei_act_continue(struct mlxsw_sp_acl_rule_info *rulei);
769 int mlxsw_sp_acl_rulei_act_jump(struct mlxsw_sp_acl_rule_info *rulei,
771 int mlxsw_sp_acl_rulei_act_terminate(struct mlxsw_sp_acl_rule_info *rulei);
772 int mlxsw_sp_acl_rulei_act_drop(struct mlxsw_sp_acl_rule_info *rulei,
774 const struct flow_action_cookie *fa_cookie,
775 struct netlink_ext_ack *extack);
776 int mlxsw_sp_acl_rulei_act_trap(struct mlxsw_sp_acl_rule_info *rulei);
777 int mlxsw_sp_acl_rulei_act_mirror(struct mlxsw_sp *mlxsw_sp,
778 struct mlxsw_sp_acl_rule_info *rulei,
779 struct mlxsw_sp_flow_block *block,
780 struct net_device *out_dev,
781 struct netlink_ext_ack *extack);
782 int mlxsw_sp_acl_rulei_act_fwd(struct mlxsw_sp *mlxsw_sp,
783 struct mlxsw_sp_acl_rule_info *rulei,
784 struct net_device *out_dev,
785 struct netlink_ext_ack *extack);
786 int mlxsw_sp_acl_rulei_act_vlan(struct mlxsw_sp *mlxsw_sp,
787 struct mlxsw_sp_acl_rule_info *rulei,
788 u32 action, u16 vid, u16 proto, u8 prio,
789 struct netlink_ext_ack *extack);
790 int mlxsw_sp_acl_rulei_act_priority(struct mlxsw_sp *mlxsw_sp,
791 struct mlxsw_sp_acl_rule_info *rulei,
792 u32 prio, struct netlink_ext_ack *extack);
793 int mlxsw_sp_acl_rulei_act_mangle(struct mlxsw_sp *mlxsw_sp,
794 struct mlxsw_sp_acl_rule_info *rulei,
795 enum flow_action_mangle_base htype,
796 u32 offset, u32 mask, u32 val,
797 struct netlink_ext_ack *extack);
798 int mlxsw_sp_acl_rulei_act_count(struct mlxsw_sp *mlxsw_sp,
799 struct mlxsw_sp_acl_rule_info *rulei,
800 struct netlink_ext_ack *extack);
801 int mlxsw_sp_acl_rulei_act_fid_set(struct mlxsw_sp *mlxsw_sp,
802 struct mlxsw_sp_acl_rule_info *rulei,
803 u16 fid, struct netlink_ext_ack *extack);
805 struct mlxsw_sp_acl_rule;
807 struct mlxsw_sp_acl_rule *
808 mlxsw_sp_acl_rule_create(struct mlxsw_sp *mlxsw_sp,
809 struct mlxsw_sp_acl_ruleset *ruleset,
810 unsigned long cookie,
811 struct mlxsw_afa_block *afa_block,
812 struct netlink_ext_ack *extack);
813 void mlxsw_sp_acl_rule_destroy(struct mlxsw_sp *mlxsw_sp,
814 struct mlxsw_sp_acl_rule *rule);
815 int mlxsw_sp_acl_rule_add(struct mlxsw_sp *mlxsw_sp,
816 struct mlxsw_sp_acl_rule *rule);
817 void mlxsw_sp_acl_rule_del(struct mlxsw_sp *mlxsw_sp,
818 struct mlxsw_sp_acl_rule *rule);
819 int mlxsw_sp_acl_rule_action_replace(struct mlxsw_sp *mlxsw_sp,
820 struct mlxsw_sp_acl_rule *rule,
821 struct mlxsw_afa_block *afa_block);
822 struct mlxsw_sp_acl_rule *
823 mlxsw_sp_acl_rule_lookup(struct mlxsw_sp *mlxsw_sp,
824 struct mlxsw_sp_acl_ruleset *ruleset,
825 unsigned long cookie);
826 struct mlxsw_sp_acl_rule_info *
827 mlxsw_sp_acl_rule_rulei(struct mlxsw_sp_acl_rule *rule);
828 int mlxsw_sp_acl_rule_get_stats(struct mlxsw_sp *mlxsw_sp,
829 struct mlxsw_sp_acl_rule *rule,
830 u64 *packets, u64 *bytes, u64 *last_use,
831 enum flow_action_hw_stats *used_hw_stats);
833 struct mlxsw_sp_fid *mlxsw_sp_acl_dummy_fid(struct mlxsw_sp *mlxsw_sp);
835 static inline const struct flow_action_cookie *
836 mlxsw_sp_acl_act_cookie_lookup(struct mlxsw_sp *mlxsw_sp, u32 cookie_index)
838 return mlxsw_afa_cookie_lookup(mlxsw_sp->afa, cookie_index);
841 int mlxsw_sp_acl_init(struct mlxsw_sp *mlxsw_sp);
842 void mlxsw_sp_acl_fini(struct mlxsw_sp *mlxsw_sp);
843 u32 mlxsw_sp_acl_region_rehash_intrvl_get(struct mlxsw_sp *mlxsw_sp);
844 int mlxsw_sp_acl_region_rehash_intrvl_set(struct mlxsw_sp *mlxsw_sp, u32 val);
846 /* spectrum_acl_tcam.c */
847 struct mlxsw_sp_acl_tcam;
848 struct mlxsw_sp_acl_tcam_region;
850 struct mlxsw_sp_acl_tcam_ops {
851 enum mlxsw_reg_ptar_key_type key_type;
853 int (*init)(struct mlxsw_sp *mlxsw_sp, void *priv,
854 struct mlxsw_sp_acl_tcam *tcam);
855 void (*fini)(struct mlxsw_sp *mlxsw_sp, void *priv);
856 size_t region_priv_size;
857 int (*region_init)(struct mlxsw_sp *mlxsw_sp, void *region_priv,
859 struct mlxsw_sp_acl_tcam_region *region,
861 void (*region_fini)(struct mlxsw_sp *mlxsw_sp, void *region_priv);
862 int (*region_associate)(struct mlxsw_sp *mlxsw_sp,
863 struct mlxsw_sp_acl_tcam_region *region);
864 void * (*region_rehash_hints_get)(void *region_priv);
865 void (*region_rehash_hints_put)(void *hints_priv);
866 size_t chunk_priv_size;
867 void (*chunk_init)(void *region_priv, void *chunk_priv,
868 unsigned int priority);
869 void (*chunk_fini)(void *chunk_priv);
870 size_t entry_priv_size;
871 int (*entry_add)(struct mlxsw_sp *mlxsw_sp,
872 void *region_priv, void *chunk_priv,
874 struct mlxsw_sp_acl_rule_info *rulei);
875 void (*entry_del)(struct mlxsw_sp *mlxsw_sp,
876 void *region_priv, void *chunk_priv,
878 int (*entry_action_replace)(struct mlxsw_sp *mlxsw_sp,
879 void *region_priv, void *entry_priv,
880 struct mlxsw_sp_acl_rule_info *rulei);
881 int (*entry_activity_get)(struct mlxsw_sp *mlxsw_sp,
882 void *region_priv, void *entry_priv,
886 /* spectrum1_acl_tcam.c */
887 extern const struct mlxsw_sp_acl_tcam_ops mlxsw_sp1_acl_tcam_ops;
889 /* spectrum2_acl_tcam.c */
890 extern const struct mlxsw_sp_acl_tcam_ops mlxsw_sp2_acl_tcam_ops;
892 /* spectrum_acl_flex_actions.c */
893 extern const struct mlxsw_afa_ops mlxsw_sp1_act_afa_ops;
894 extern const struct mlxsw_afa_ops mlxsw_sp2_act_afa_ops;
896 /* spectrum_acl_flex_keys.c */
897 extern const struct mlxsw_afk_ops mlxsw_sp1_afk_ops;
898 extern const struct mlxsw_afk_ops mlxsw_sp2_afk_ops;
900 /* spectrum_matchall.c */
901 int mlxsw_sp_mall_replace(struct mlxsw_sp *mlxsw_sp,
902 struct mlxsw_sp_flow_block *block,
903 struct tc_cls_matchall_offload *f);
904 void mlxsw_sp_mall_destroy(struct mlxsw_sp_flow_block *block,
905 struct tc_cls_matchall_offload *f);
906 int mlxsw_sp_mall_port_bind(struct mlxsw_sp_flow_block *block,
907 struct mlxsw_sp_port *mlxsw_sp_port);
908 void mlxsw_sp_mall_port_unbind(struct mlxsw_sp_flow_block *block,
909 struct mlxsw_sp_port *mlxsw_sp_port);
910 int mlxsw_sp_mall_prio_get(struct mlxsw_sp_flow_block *block, u32 chain_index,
911 unsigned int *p_min_prio, unsigned int *p_max_prio);
913 /* spectrum_flower.c */
914 int mlxsw_sp_flower_replace(struct mlxsw_sp *mlxsw_sp,
915 struct mlxsw_sp_flow_block *block,
916 struct flow_cls_offload *f);
917 void mlxsw_sp_flower_destroy(struct mlxsw_sp *mlxsw_sp,
918 struct mlxsw_sp_flow_block *block,
919 struct flow_cls_offload *f);
920 int mlxsw_sp_flower_stats(struct mlxsw_sp *mlxsw_sp,
921 struct mlxsw_sp_flow_block *block,
922 struct flow_cls_offload *f);
923 int mlxsw_sp_flower_tmplt_create(struct mlxsw_sp *mlxsw_sp,
924 struct mlxsw_sp_flow_block *block,
925 struct flow_cls_offload *f);
926 void mlxsw_sp_flower_tmplt_destroy(struct mlxsw_sp *mlxsw_sp,
927 struct mlxsw_sp_flow_block *block,
928 struct flow_cls_offload *f);
929 int mlxsw_sp_flower_prio_get(struct mlxsw_sp *mlxsw_sp,
930 struct mlxsw_sp_flow_block *block,
931 u32 chain_index, unsigned int *p_min_prio,
932 unsigned int *p_max_prio);
934 /* spectrum_qdisc.c */
935 int mlxsw_sp_tc_qdisc_init(struct mlxsw_sp_port *mlxsw_sp_port);
936 void mlxsw_sp_tc_qdisc_fini(struct mlxsw_sp_port *mlxsw_sp_port);
937 int mlxsw_sp_setup_tc_red(struct mlxsw_sp_port *mlxsw_sp_port,
938 struct tc_red_qopt_offload *p);
939 int mlxsw_sp_setup_tc_prio(struct mlxsw_sp_port *mlxsw_sp_port,
940 struct tc_prio_qopt_offload *p);
941 int mlxsw_sp_setup_tc_ets(struct mlxsw_sp_port *mlxsw_sp_port,
942 struct tc_ets_qopt_offload *p);
943 int mlxsw_sp_setup_tc_tbf(struct mlxsw_sp_port *mlxsw_sp_port,
944 struct tc_tbf_qopt_offload *p);
945 int mlxsw_sp_setup_tc_fifo(struct mlxsw_sp_port *mlxsw_sp_port,
946 struct tc_fifo_qopt_offload *p);
949 bool mlxsw_sp_fid_is_dummy(struct mlxsw_sp *mlxsw_sp, u16 fid_index);
950 bool mlxsw_sp_fid_lag_vid_valid(const struct mlxsw_sp_fid *fid);
951 struct mlxsw_sp_fid *mlxsw_sp_fid_lookup_by_index(struct mlxsw_sp *mlxsw_sp,
953 int mlxsw_sp_fid_nve_ifindex(const struct mlxsw_sp_fid *fid, int *nve_ifindex);
954 int mlxsw_sp_fid_nve_type(const struct mlxsw_sp_fid *fid,
955 enum mlxsw_sp_nve_type *p_type);
956 struct mlxsw_sp_fid *mlxsw_sp_fid_lookup_by_vni(struct mlxsw_sp *mlxsw_sp,
958 int mlxsw_sp_fid_vni(const struct mlxsw_sp_fid *fid, __be32 *vni);
959 int mlxsw_sp_fid_nve_flood_index_set(struct mlxsw_sp_fid *fid,
960 u32 nve_flood_index);
961 void mlxsw_sp_fid_nve_flood_index_clear(struct mlxsw_sp_fid *fid);
962 bool mlxsw_sp_fid_nve_flood_index_is_set(const struct mlxsw_sp_fid *fid);
963 int mlxsw_sp_fid_vni_set(struct mlxsw_sp_fid *fid, enum mlxsw_sp_nve_type type,
964 __be32 vni, int nve_ifindex);
965 void mlxsw_sp_fid_vni_clear(struct mlxsw_sp_fid *fid);
966 bool mlxsw_sp_fid_vni_is_set(const struct mlxsw_sp_fid *fid);
967 void mlxsw_sp_fid_fdb_clear_offload(const struct mlxsw_sp_fid *fid,
968 const struct net_device *nve_dev);
969 int mlxsw_sp_fid_flood_set(struct mlxsw_sp_fid *fid,
970 enum mlxsw_sp_flood_type packet_type, u8 local_port,
972 int mlxsw_sp_fid_port_vid_map(struct mlxsw_sp_fid *fid,
973 struct mlxsw_sp_port *mlxsw_sp_port, u16 vid);
974 void mlxsw_sp_fid_port_vid_unmap(struct mlxsw_sp_fid *fid,
975 struct mlxsw_sp_port *mlxsw_sp_port, u16 vid);
976 u16 mlxsw_sp_fid_index(const struct mlxsw_sp_fid *fid);
977 enum mlxsw_sp_fid_type mlxsw_sp_fid_type(const struct mlxsw_sp_fid *fid);
978 void mlxsw_sp_fid_rif_set(struct mlxsw_sp_fid *fid, struct mlxsw_sp_rif *rif);
979 struct mlxsw_sp_rif *mlxsw_sp_fid_rif(const struct mlxsw_sp_fid *fid);
980 enum mlxsw_sp_rif_type
981 mlxsw_sp_fid_type_rif_type(const struct mlxsw_sp *mlxsw_sp,
982 enum mlxsw_sp_fid_type type);
983 u16 mlxsw_sp_fid_8021q_vid(const struct mlxsw_sp_fid *fid);
984 struct mlxsw_sp_fid *mlxsw_sp_fid_8021q_get(struct mlxsw_sp *mlxsw_sp, u16 vid);
985 struct mlxsw_sp_fid *mlxsw_sp_fid_8021d_get(struct mlxsw_sp *mlxsw_sp,
987 struct mlxsw_sp_fid *mlxsw_sp_fid_8021q_lookup(struct mlxsw_sp *mlxsw_sp,
989 struct mlxsw_sp_fid *mlxsw_sp_fid_8021d_lookup(struct mlxsw_sp *mlxsw_sp,
991 struct mlxsw_sp_fid *mlxsw_sp_fid_rfid_get(struct mlxsw_sp *mlxsw_sp,
993 struct mlxsw_sp_fid *mlxsw_sp_fid_dummy_get(struct mlxsw_sp *mlxsw_sp);
994 void mlxsw_sp_fid_put(struct mlxsw_sp_fid *fid);
995 int mlxsw_sp_port_fids_init(struct mlxsw_sp_port *mlxsw_sp_port);
996 void mlxsw_sp_port_fids_fini(struct mlxsw_sp_port *mlxsw_sp_port);
997 int mlxsw_sp_fids_init(struct mlxsw_sp *mlxsw_sp);
998 void mlxsw_sp_fids_fini(struct mlxsw_sp *mlxsw_sp);
1001 enum mlxsw_sp_mr_route_prio {
1002 MLXSW_SP_MR_ROUTE_PRIO_SG,
1003 MLXSW_SP_MR_ROUTE_PRIO_STARG,
1004 MLXSW_SP_MR_ROUTE_PRIO_CATCHALL,
1005 __MLXSW_SP_MR_ROUTE_PRIO_MAX
1008 #define MLXSW_SP_MR_ROUTE_PRIO_MAX (__MLXSW_SP_MR_ROUTE_PRIO_MAX - 1)
1010 struct mlxsw_sp_mr_route_key;
1012 struct mlxsw_sp_mr_tcam_ops {
1014 int (*init)(struct mlxsw_sp *mlxsw_sp, void *priv);
1015 void (*fini)(void *priv);
1016 size_t route_priv_size;
1017 int (*route_create)(struct mlxsw_sp *mlxsw_sp, void *priv,
1019 struct mlxsw_sp_mr_route_key *key,
1020 struct mlxsw_afa_block *afa_block,
1021 enum mlxsw_sp_mr_route_prio prio);
1022 void (*route_destroy)(struct mlxsw_sp *mlxsw_sp, void *priv,
1024 struct mlxsw_sp_mr_route_key *key);
1025 int (*route_update)(struct mlxsw_sp *mlxsw_sp, void *route_priv,
1026 struct mlxsw_sp_mr_route_key *key,
1027 struct mlxsw_afa_block *afa_block);
1030 /* spectrum1_mr_tcam.c */
1031 extern const struct mlxsw_sp_mr_tcam_ops mlxsw_sp1_mr_tcam_ops;
1033 /* spectrum2_mr_tcam.c */
1034 extern const struct mlxsw_sp_mr_tcam_ops mlxsw_sp2_mr_tcam_ops;
1036 /* spectrum_nve.c */
1037 struct mlxsw_sp_nve_params {
1038 enum mlxsw_sp_nve_type type;
1040 const struct net_device *dev;
1043 extern const struct mlxsw_sp_nve_ops *mlxsw_sp1_nve_ops_arr[];
1044 extern const struct mlxsw_sp_nve_ops *mlxsw_sp2_nve_ops_arr[];
1046 int mlxsw_sp_nve_learned_ip_resolve(struct mlxsw_sp *mlxsw_sp, u32 uip,
1047 enum mlxsw_sp_l3proto proto,
1048 union mlxsw_sp_l3addr *addr);
1049 int mlxsw_sp_nve_flood_ip_add(struct mlxsw_sp *mlxsw_sp,
1050 struct mlxsw_sp_fid *fid,
1051 enum mlxsw_sp_l3proto proto,
1052 union mlxsw_sp_l3addr *addr);
1053 void mlxsw_sp_nve_flood_ip_del(struct mlxsw_sp *mlxsw_sp,
1054 struct mlxsw_sp_fid *fid,
1055 enum mlxsw_sp_l3proto proto,
1056 union mlxsw_sp_l3addr *addr);
1057 int mlxsw_sp_nve_fid_enable(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_fid *fid,
1058 struct mlxsw_sp_nve_params *params,
1059 struct netlink_ext_ack *extack);
1060 void mlxsw_sp_nve_fid_disable(struct mlxsw_sp *mlxsw_sp,
1061 struct mlxsw_sp_fid *fid);
1062 int mlxsw_sp_port_nve_init(struct mlxsw_sp_port *mlxsw_sp_port);
1063 void mlxsw_sp_port_nve_fini(struct mlxsw_sp_port *mlxsw_sp_port);
1064 int mlxsw_sp_nve_init(struct mlxsw_sp *mlxsw_sp);
1065 void mlxsw_sp_nve_fini(struct mlxsw_sp *mlxsw_sp);
1067 /* spectrum_nve_vxlan.c */
1068 int mlxsw_sp_nve_inc_parsing_depth_get(struct mlxsw_sp *mlxsw_sp);
1069 void mlxsw_sp_nve_inc_parsing_depth_put(struct mlxsw_sp *mlxsw_sp);
1071 /* spectrum_trap.c */
1072 int mlxsw_sp_devlink_traps_init(struct mlxsw_sp *mlxsw_sp);
1073 void mlxsw_sp_devlink_traps_fini(struct mlxsw_sp *mlxsw_sp);
1074 int mlxsw_sp_trap_init(struct mlxsw_core *mlxsw_core,
1075 const struct devlink_trap *trap, void *trap_ctx);
1076 void mlxsw_sp_trap_fini(struct mlxsw_core *mlxsw_core,
1077 const struct devlink_trap *trap, void *trap_ctx);
1078 int mlxsw_sp_trap_action_set(struct mlxsw_core *mlxsw_core,
1079 const struct devlink_trap *trap,
1080 enum devlink_trap_action action);
1081 int mlxsw_sp_trap_group_init(struct mlxsw_core *mlxsw_core,
1082 const struct devlink_trap_group *group);
1083 int mlxsw_sp_trap_group_set(struct mlxsw_core *mlxsw_core,
1084 const struct devlink_trap_group *group,
1085 const struct devlink_trap_policer *policer);
1087 mlxsw_sp_trap_policer_init(struct mlxsw_core *mlxsw_core,
1088 const struct devlink_trap_policer *policer);
1089 void mlxsw_sp_trap_policer_fini(struct mlxsw_core *mlxsw_core,
1090 const struct devlink_trap_policer *policer);
1092 mlxsw_sp_trap_policer_set(struct mlxsw_core *mlxsw_core,
1093 const struct devlink_trap_policer *policer,
1094 u64 rate, u64 burst, struct netlink_ext_ack *extack);
1096 mlxsw_sp_trap_policer_counter_get(struct mlxsw_core *mlxsw_core,
1097 const struct devlink_trap_policer *policer,
1100 static inline struct net *mlxsw_sp_net(struct mlxsw_sp *mlxsw_sp)
1102 return mlxsw_core_net(mlxsw_sp->core);