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/ethtool.h>
8 #include <linux/types.h>
9 #include <linux/netdevice.h>
10 #include <linux/rhashtable.h>
11 #include <linux/bitops.h>
12 #include <linux/if_bridge.h>
13 #include <linux/if_vlan.h>
14 #include <linux/list.h>
15 #include <linux/dcbnl.h>
16 #include <linux/in6.h>
17 #include <linux/notifier.h>
18 #include <linux/net_namespace.h>
19 #include <linux/spinlock.h>
20 #include <net/psample.h>
21 #include <net/pkt_cls.h>
23 #include <net/vxlan.h>
24 #include <net/flow_offload.h>
25 #include <net/inet_ecn.h>
29 #include "core_acl_flex_keys.h"
30 #include "core_acl_flex_actions.h"
33 #define MLXSW_SP_DEFAULT_VID (VLAN_N_VID - 1)
35 #define MLXSW_SP_FID_8021D_MAX 1024
37 #define MLXSW_SP_MID_MAX 7000
39 #define MLXSW_SP_KVD_LINEAR_SIZE 98304 /* entries */
40 #define MLXSW_SP_KVD_GRANULARITY 128
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"
50 #define MLXSW_SP_RESOURCE_NAME_SPAN "span_agents"
52 #define MLXSW_SP_RESOURCE_NAME_COUNTERS "counters"
53 #define MLXSW_SP_RESOURCE_NAME_COUNTERS_FLOW "flow"
54 #define MLXSW_SP_RESOURCE_NAME_COUNTERS_RIF "rif"
56 enum mlxsw_sp_resource_id {
57 MLXSW_SP_RESOURCE_KVD = MLXSW_CORE_RESOURCE_MAX,
58 MLXSW_SP_RESOURCE_KVD_LINEAR,
59 MLXSW_SP_RESOURCE_KVD_HASH_SINGLE,
60 MLXSW_SP_RESOURCE_KVD_HASH_DOUBLE,
61 MLXSW_SP_RESOURCE_KVD_LINEAR_SINGLE,
62 MLXSW_SP_RESOURCE_KVD_LINEAR_CHUNKS,
63 MLXSW_SP_RESOURCE_KVD_LINEAR_LARGE_CHUNKS,
64 MLXSW_SP_RESOURCE_SPAN,
65 MLXSW_SP_RESOURCE_COUNTERS,
66 MLXSW_SP_RESOURCE_COUNTERS_FLOW,
67 MLXSW_SP_RESOURCE_COUNTERS_RIF,
68 MLXSW_SP_RESOURCE_GLOBAL_POLICERS,
69 MLXSW_SP_RESOURCE_SINGLE_RATE_POLICERS,
70 MLXSW_SP_RESOURCE_RIF_MAC_PROFILES,
71 MLXSW_SP_RESOURCE_RIFS,
72 MLXSW_SP_RESOURCE_PORT_RANGE_REGISTERS,
77 struct mlxsw_sp_span_entry;
78 enum mlxsw_sp_l3proto;
79 union mlxsw_sp_l3addr;
81 struct mlxsw_sp_upper {
82 struct net_device *dev;
83 unsigned int ref_count;
86 enum mlxsw_sp_rif_type {
87 MLXSW_SP_RIF_TYPE_SUBPORT,
88 MLXSW_SP_RIF_TYPE_VLAN,
89 MLXSW_SP_RIF_TYPE_FID,
90 MLXSW_SP_RIF_TYPE_IPIP_LB, /* IP-in-IP loopback. */
91 MLXSW_SP_RIF_TYPE_MAX,
94 struct mlxsw_sp_router_ops;
96 extern const struct mlxsw_sp_router_ops mlxsw_sp1_router_ops;
97 extern const struct mlxsw_sp_router_ops mlxsw_sp2_router_ops;
99 struct mlxsw_sp_switchdev_ops;
101 extern const struct mlxsw_sp_switchdev_ops mlxsw_sp1_switchdev_ops;
102 extern const struct mlxsw_sp_switchdev_ops mlxsw_sp2_switchdev_ops;
104 enum 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,
112 enum mlxsw_sp_nve_type {
113 MLXSW_SP_NVE_TYPE_VXLAN,
117 struct mlxsw_sp_bridge;
118 struct mlxsw_sp_router;
121 struct mlxsw_sp_counter_pool;
122 struct mlxsw_sp_fid_core;
123 struct mlxsw_sp_kvdl;
125 struct mlxsw_sp_kvdl_ops;
126 struct mlxsw_sp_mr_tcam_ops;
127 struct mlxsw_sp_acl_rulei_ops;
128 struct mlxsw_sp_acl_tcam_ops;
129 struct mlxsw_sp_nve_ops;
130 struct mlxsw_sp_sb_ops;
131 struct mlxsw_sp_sb_vals;
132 struct mlxsw_sp_port_type_speed_ops;
133 struct mlxsw_sp_ptp_state;
134 struct mlxsw_sp_ptp_ops;
135 struct mlxsw_sp_span_ops;
136 struct mlxsw_sp_qdisc_state;
137 struct mlxsw_sp_mall_entry;
140 struct mlxsw_sp_port_mapping {
143 u8 width; /* Number of lanes used by the port */
144 u8 module_width; /* Number of lanes in the module (static) */
148 struct mlxsw_sp_port_mapping_events {
149 struct list_head queue;
150 spinlock_t queue_lock; /* protects queue */
151 struct work_struct work;
154 struct mlxsw_sp_parsing {
155 refcount_t parsing_depth_ref;
158 struct mutex lock; /* Protects parsing configuration */
162 struct mlxsw_sp_port **ports;
163 struct mlxsw_core *core;
164 const struct mlxsw_bus_info *bus_info;
165 unsigned char base_mac[ETH_ALEN];
166 const unsigned char *mac_mask;
167 struct mlxsw_sp_upper *lags;
168 struct mlxsw_sp_port_mapping *port_mapping;
169 struct mlxsw_sp_port_mapping_events port_mapping_events;
170 struct rhashtable sample_trigger_ht;
171 struct mlxsw_sp_sb *sb;
172 struct mlxsw_sp_bridge *bridge;
173 struct mlxsw_sp_router *router;
174 struct mlxsw_sp_mr *mr;
175 struct mlxsw_afa *afa;
176 struct mlxsw_sp_acl *acl;
177 struct mlxsw_sp_fid_core *fid_core;
178 struct mlxsw_sp_policer_core *policer_core;
179 struct mlxsw_sp_port_range_core *pr_core;
180 struct mlxsw_sp_kvdl *kvdl;
181 struct mlxsw_sp_nve *nve;
182 struct notifier_block netdevice_nb;
183 struct mlxsw_sp_ptp_clock *clock;
184 struct mlxsw_sp_ptp_state *ptp_state;
185 struct mlxsw_sp_counter_pool *counter_pool;
186 struct mlxsw_sp_span *span;
187 struct mlxsw_sp_trap *trap;
188 struct mlxsw_sp_parsing parsing;
189 const struct mlxsw_sp_switchdev_ops *switchdev_ops;
190 const struct mlxsw_sp_kvdl_ops *kvdl_ops;
191 const struct mlxsw_afa_ops *afa_ops;
192 const struct mlxsw_afk_ops *afk_ops;
193 const struct mlxsw_sp_mr_tcam_ops *mr_tcam_ops;
194 const struct mlxsw_sp_acl_rulei_ops *acl_rulei_ops;
195 const struct mlxsw_sp_acl_tcam_ops *acl_tcam_ops;
196 const struct mlxsw_sp_acl_bf_ops *acl_bf_ops;
197 const struct mlxsw_sp_nve_ops **nve_ops_arr;
198 const struct mlxsw_sp_sb_vals *sb_vals;
199 const struct mlxsw_sp_sb_ops *sb_ops;
200 const struct mlxsw_sp_port_type_speed_ops *port_type_speed_ops;
201 const struct mlxsw_sp_ptp_ops *ptp_ops;
202 const struct mlxsw_sp_span_ops *span_ops;
203 const struct mlxsw_sp_policer_core_ops *policer_core_ops;
204 const struct mlxsw_sp_trap_ops *trap_ops;
205 const struct mlxsw_sp_mall_ops *mall_ops;
206 const struct mlxsw_sp_router_ops *router_ops;
207 const struct mlxsw_listener *listeners;
208 const struct mlxsw_sp_fid_core_ops *fid_core_ops;
209 size_t listeners_count;
210 u32 lowest_shaper_bs;
211 struct rhashtable ipv6_addr_ht;
212 struct mutex ipv6_addr_ht_lock; /* Protects ipv6_addr_ht */
213 struct mlxsw_sp_pgt *pgt;
214 bool pgt_smpe_index_valid;
218 struct mlxsw_sp_ptp_ops {
219 struct mlxsw_sp_ptp_clock *
220 (*clock_init)(struct mlxsw_sp *mlxsw_sp, struct device *dev);
221 void (*clock_fini)(struct mlxsw_sp_ptp_clock *clock);
223 struct mlxsw_sp_ptp_state *(*init)(struct mlxsw_sp *mlxsw_sp);
224 void (*fini)(struct mlxsw_sp_ptp_state *ptp_state);
226 /* Notify a driver that a packet that might be PTP was received. Driver
227 * is responsible for freeing the passed-in SKB.
229 void (*receive)(struct mlxsw_sp *mlxsw_sp, struct sk_buff *skb,
232 /* Notify a driver that a timestamped packet was transmitted. Driver
233 * is responsible for freeing the passed-in SKB.
235 void (*transmitted)(struct mlxsw_sp *mlxsw_sp, struct sk_buff *skb,
238 int (*hwtstamp_get)(struct mlxsw_sp_port *mlxsw_sp_port,
239 struct hwtstamp_config *config);
240 int (*hwtstamp_set)(struct mlxsw_sp_port *mlxsw_sp_port,
241 struct hwtstamp_config *config);
242 void (*shaper_work)(struct work_struct *work);
243 int (*get_ts_info)(struct mlxsw_sp *mlxsw_sp,
244 struct ethtool_ts_info *info);
245 int (*get_stats_count)(void);
246 void (*get_stats_strings)(u8 **p);
247 void (*get_stats)(struct mlxsw_sp_port *mlxsw_sp_port,
248 u64 *data, int data_index);
249 int (*txhdr_construct)(struct mlxsw_core *mlxsw_core,
250 struct mlxsw_sp_port *mlxsw_sp_port,
252 const struct mlxsw_tx_info *tx_info);
255 struct mlxsw_sp_fid_core_ops {
256 int (*init)(struct mlxsw_sp *mlxsw_sp);
257 void (*fini)(struct mlxsw_sp *mlxsw_sp);
260 static inline struct mlxsw_sp_upper *
261 mlxsw_sp_lag_get(struct mlxsw_sp *mlxsw_sp, u16 lag_id)
263 return &mlxsw_sp->lags[lag_id];
266 struct mlxsw_sp_port_pcpu_stats {
271 struct u64_stats_sync syncp;
275 enum mlxsw_sp_sample_trigger_type {
276 MLXSW_SP_SAMPLE_TRIGGER_TYPE_INGRESS,
277 MLXSW_SP_SAMPLE_TRIGGER_TYPE_EGRESS,
278 MLXSW_SP_SAMPLE_TRIGGER_TYPE_POLICY_ENGINE,
281 struct mlxsw_sp_sample_trigger {
282 enum mlxsw_sp_sample_trigger_type type;
283 u16 local_port; /* Reserved when trigger type is not ingress / egress. */
286 struct mlxsw_sp_sample_params {
287 struct psample_group *psample_group;
293 struct mlxsw_sp_bridge_port;
296 struct mlxsw_sp_port_vlan {
297 struct list_head list;
298 struct mlxsw_sp_port *mlxsw_sp_port;
299 struct mlxsw_sp_fid *fid;
301 struct mlxsw_sp_bridge_port *bridge_port;
302 struct list_head bridge_vlan_node;
305 /* No need an internal lock; At worse - miss a single periodic iteration */
306 struct mlxsw_sp_port_xstats {
308 u64 tc_ecn[TC_MAX_QUEUE];
309 u64 wred_drop[TC_MAX_QUEUE];
310 u64 tail_drop[TC_MAX_QUEUE];
311 u64 backlog[TC_MAX_QUEUE];
312 u64 tx_bytes[IEEE_8021QAZ_MAX_TCS];
313 u64 tx_packets[IEEE_8021QAZ_MAX_TCS];
316 struct mlxsw_sp_ptp_port_dir_stats {
321 struct mlxsw_sp_ptp_port_stats {
322 struct mlxsw_sp_ptp_port_dir_stats rx_gcd;
323 struct mlxsw_sp_ptp_port_dir_stats tx_gcd;
326 struct mlxsw_sp_port {
327 struct net_device *dev;
328 struct mlxsw_sp_port_pcpu_stats __percpu *pcpu_stats;
329 struct mlxsw_sp *mlxsw_sp;
342 struct ieee_ets *ets;
343 struct ieee_maxrate *maxrate;
344 struct ieee_pfc *pfc;
345 enum mlxsw_reg_qpts_trust_state trust_state;
347 struct mlxsw_sp_port_mapping mapping; /* mapping is constant during the
348 * mlxsw_sp_port lifetime, however
349 * the same localport can have
353 #define MLXSW_HW_STATS_UPDATE_TIME HZ
354 struct rtnl_link_stats64 stats;
355 struct mlxsw_sp_port_xstats xstats;
356 struct delayed_work update_dw;
358 struct list_head vlans_list;
359 struct mlxsw_sp_port_vlan *default_vlan;
360 struct mlxsw_sp_qdisc_state *qdisc;
361 unsigned acl_rule_count;
362 struct mlxsw_sp_flow_block *ing_flow_block;
363 struct mlxsw_sp_flow_block *eg_flow_block;
365 struct delayed_work shaper_dw;
366 struct hwtstamp_config hwtstamp_config;
369 struct mlxsw_sp_ptp_port_stats stats;
373 struct mlxsw_sp_hdroom *hdroom;
374 u64 module_overheat_initial_val;
377 struct mlxsw_sp_port_type_speed_ops {
378 void (*from_ptys_supported_port)(struct mlxsw_sp *mlxsw_sp,
380 struct ethtool_link_ksettings *cmd);
381 void (*from_ptys_link)(struct mlxsw_sp *mlxsw_sp, u32 ptys_eth_proto,
382 unsigned long *mode);
383 u32 (*from_ptys_speed)(struct mlxsw_sp *mlxsw_sp, u32 ptys_eth_proto);
384 void (*from_ptys_link_mode)(struct mlxsw_sp *mlxsw_sp,
385 bool carrier_ok, u32 ptys_eth_proto,
386 struct ethtool_link_ksettings *cmd);
387 int (*ptys_max_speed)(struct mlxsw_sp_port *mlxsw_sp_port, u32 *p_max_speed);
388 u32 (*to_ptys_advert_link)(struct mlxsw_sp *mlxsw_sp,
389 const struct ethtool_link_ksettings *cmd);
390 u32 (*to_ptys_speed_lanes)(struct mlxsw_sp *mlxsw_sp, u8 width,
391 const struct ethtool_link_ksettings *cmd);
392 void (*reg_ptys_eth_pack)(struct mlxsw_sp *mlxsw_sp, char *payload,
393 u16 local_port, u32 proto_admin, bool autoneg);
394 void (*reg_ptys_eth_unpack)(struct mlxsw_sp *mlxsw_sp, char *payload,
395 u32 *p_eth_proto_cap,
396 u32 *p_eth_proto_admin,
397 u32 *p_eth_proto_oper);
398 u32 (*ptys_proto_cap_masked_get)(u32 eth_proto_cap);
401 struct mlxsw_sp_ports_bitmap {
402 unsigned long *bitmap;
407 mlxsw_sp_port_bitmap_init(struct mlxsw_sp *mlxsw_sp,
408 struct mlxsw_sp_ports_bitmap *ports_bm)
410 unsigned int nbits = mlxsw_core_max_ports(mlxsw_sp->core);
412 ports_bm->nbits = nbits;
413 ports_bm->bitmap = bitmap_zalloc(nbits, GFP_KERNEL);
414 if (!ports_bm->bitmap)
421 mlxsw_sp_port_bitmap_fini(struct mlxsw_sp_ports_bitmap *ports_bm)
423 bitmap_free(ports_bm->bitmap);
426 static inline u8 mlxsw_sp_tunnel_ecn_decap(u8 outer_ecn, u8 inner_ecn,
431 *trap_en = !!__INET_ECN_decapsulate(outer_ecn, inner_ecn, &set_ce);
434 else if (outer_ecn == INET_ECN_ECT_1 && inner_ecn == INET_ECN_ECT_0)
435 return INET_ECN_ECT_1;
440 static inline struct net_device *
441 mlxsw_sp_bridge_vxlan_dev_find(struct net_device *br_dev)
443 struct net_device *dev;
444 struct list_head *iter;
446 netdev_for_each_lower_dev(br_dev, dev, iter) {
447 if (netif_is_vxlan(dev))
454 static inline bool mlxsw_sp_bridge_has_vxlan(struct net_device *br_dev)
456 return !!mlxsw_sp_bridge_vxlan_dev_find(br_dev);
460 mlxsw_sp_vxlan_mapped_vid(const struct net_device *vxlan_dev, u16 *p_vid)
462 struct bridge_vlan_info vinfo;
466 err = br_vlan_get_pvid(vxlan_dev, &vid);
470 err = br_vlan_get_info(vxlan_dev, vid, &vinfo);
471 if (err || !(vinfo.flags & BRIDGE_VLAN_INFO_UNTAGGED))
480 mlxsw_sp_port_is_pause_en(const struct mlxsw_sp_port *mlxsw_sp_port)
482 return mlxsw_sp_port->link.tx_pause || mlxsw_sp_port->link.rx_pause;
485 static inline struct mlxsw_sp_port *
486 mlxsw_sp_port_lagged_get(struct mlxsw_sp *mlxsw_sp, u16 lag_id, u8 port_index)
488 struct mlxsw_sp_port *mlxsw_sp_port;
491 local_port = mlxsw_core_lag_mapping_get(mlxsw_sp->core,
493 mlxsw_sp_port = mlxsw_sp->ports[local_port];
494 return mlxsw_sp_port && mlxsw_sp_port->lagged ? mlxsw_sp_port : NULL;
497 static inline struct mlxsw_sp_port_vlan *
498 mlxsw_sp_port_vlan_find_by_vid(const struct mlxsw_sp_port *mlxsw_sp_port,
501 struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan;
503 list_for_each_entry(mlxsw_sp_port_vlan, &mlxsw_sp_port->vlans_list,
505 if (mlxsw_sp_port_vlan->vid == vid)
506 return mlxsw_sp_port_vlan;
512 enum mlxsw_sp_flood_type {
513 MLXSW_SP_FLOOD_TYPE_UC,
514 MLXSW_SP_FLOOD_TYPE_BC,
515 MLXSW_SP_FLOOD_TYPE_MC,
516 /* For RSP FIDs in CFF mode. */
517 MLXSW_SP_FLOOD_TYPE_NOT_UC,
518 /* For NVE traffic. */
519 MLXSW_SP_FLOOD_TYPE_ANY,
522 int mlxsw_sp_port_get_stats_raw(struct net_device *dev, int grp,
523 int prio, char *ppcnt_pl);
524 int mlxsw_sp_port_admin_status_set(struct mlxsw_sp_port *mlxsw_sp_port,
527 mlxsw_sp_port_vlan_classification_set(struct mlxsw_sp_port *mlxsw_sp_port,
528 bool is_8021ad_tagged,
529 bool is_8021q_tagged);
531 mlxsw_sp_local_port_is_valid(struct mlxsw_sp *mlxsw_sp, u16 local_port)
533 unsigned int max_ports = mlxsw_core_max_ports(mlxsw_sp->core);
535 return local_port < max_ports && local_port;
538 /* spectrum_buffers.c */
539 struct mlxsw_sp_hdroom_prio {
540 /* Number of port buffer associated with this priority. This is the
541 * actually configured value.
544 /* Value of buf_idx deduced from the DCB ETS configuration. */
546 /* Value of buf_idx taken from the dcbnl_setbuffer configuration. */
551 struct mlxsw_sp_hdroom_buf {
554 /* Size requirement form dcbnl_setbuffer. */
559 enum mlxsw_sp_hdroom_mode {
560 MLXSW_SP_HDROOM_MODE_DCB,
561 MLXSW_SP_HDROOM_MODE_TC,
564 #define MLXSW_SP_PB_COUNT 10
566 struct mlxsw_sp_hdroom {
567 enum mlxsw_sp_hdroom_mode mode;
570 struct mlxsw_sp_hdroom_prio prio[IEEE_8021Q_MAX_PRIORITIES];
573 struct mlxsw_sp_hdroom_buf buf[MLXSW_SP_PB_COUNT];
576 /* Size actually configured for the internal buffer. Equal to
577 * reserve when internal buffer is enabled.
580 /* Space reserved in the headroom for the internal buffer. Port
581 * buffers are not allowed to grow into this space.
590 int mlxsw_sp_buffers_init(struct mlxsw_sp *mlxsw_sp);
591 void mlxsw_sp_buffers_fini(struct mlxsw_sp *mlxsw_sp);
592 int mlxsw_sp_port_buffers_init(struct mlxsw_sp_port *mlxsw_sp_port);
593 void mlxsw_sp_port_buffers_fini(struct mlxsw_sp_port *mlxsw_sp_port);
594 int mlxsw_sp_sb_pool_get(struct mlxsw_core *mlxsw_core,
595 unsigned int sb_index, u16 pool_index,
596 struct devlink_sb_pool_info *pool_info);
597 int mlxsw_sp_sb_pool_set(struct mlxsw_core *mlxsw_core,
598 unsigned int sb_index, u16 pool_index, u32 size,
599 enum devlink_sb_threshold_type threshold_type,
600 struct netlink_ext_ack *extack);
601 int mlxsw_sp_sb_port_pool_get(struct mlxsw_core_port *mlxsw_core_port,
602 unsigned int sb_index, u16 pool_index,
604 int mlxsw_sp_sb_port_pool_set(struct mlxsw_core_port *mlxsw_core_port,
605 unsigned int sb_index, u16 pool_index,
606 u32 threshold, struct netlink_ext_ack *extack);
607 int mlxsw_sp_sb_tc_pool_bind_get(struct mlxsw_core_port *mlxsw_core_port,
608 unsigned int sb_index, u16 tc_index,
609 enum devlink_sb_pool_type pool_type,
610 u16 *p_pool_index, u32 *p_threshold);
611 int mlxsw_sp_sb_tc_pool_bind_set(struct mlxsw_core_port *mlxsw_core_port,
612 unsigned int sb_index, u16 tc_index,
613 enum devlink_sb_pool_type pool_type,
614 u16 pool_index, u32 threshold,
615 struct netlink_ext_ack *extack);
616 int mlxsw_sp_sb_occ_snapshot(struct mlxsw_core *mlxsw_core,
617 unsigned int sb_index);
618 int mlxsw_sp_sb_occ_max_clear(struct mlxsw_core *mlxsw_core,
619 unsigned int sb_index);
620 int mlxsw_sp_sb_occ_port_pool_get(struct mlxsw_core_port *mlxsw_core_port,
621 unsigned int sb_index, u16 pool_index,
622 u32 *p_cur, u32 *p_max);
623 int mlxsw_sp_sb_occ_tc_port_bind_get(struct mlxsw_core_port *mlxsw_core_port,
624 unsigned int sb_index, u16 tc_index,
625 enum devlink_sb_pool_type pool_type,
626 u32 *p_cur, u32 *p_max);
627 u32 mlxsw_sp_cells_bytes(const struct mlxsw_sp *mlxsw_sp, u32 cells);
628 u32 mlxsw_sp_bytes_cells(const struct mlxsw_sp *mlxsw_sp, u32 bytes);
629 void mlxsw_sp_hdroom_prios_reset_buf_idx(struct mlxsw_sp_hdroom *hdroom);
630 void mlxsw_sp_hdroom_bufs_reset_lossiness(struct mlxsw_sp_hdroom *hdroom);
631 void mlxsw_sp_hdroom_bufs_reset_sizes(struct mlxsw_sp_port *mlxsw_sp_port,
632 struct mlxsw_sp_hdroom *hdroom);
633 int mlxsw_sp_hdroom_configure(struct mlxsw_sp_port *mlxsw_sp_port,
634 const struct mlxsw_sp_hdroom *hdroom);
635 struct mlxsw_sp_sample_params *
636 mlxsw_sp_sample_trigger_params_lookup(struct mlxsw_sp *mlxsw_sp,
637 const struct mlxsw_sp_sample_trigger *trigger);
639 mlxsw_sp_sample_trigger_params_set(struct mlxsw_sp *mlxsw_sp,
640 const struct mlxsw_sp_sample_trigger *trigger,
641 const struct mlxsw_sp_sample_params *params,
642 struct netlink_ext_ack *extack);
644 mlxsw_sp_sample_trigger_params_unset(struct mlxsw_sp *mlxsw_sp,
645 const struct mlxsw_sp_sample_trigger *trigger);
646 int mlxsw_sp_ipv6_addr_kvdl_index_get(struct mlxsw_sp *mlxsw_sp,
647 const struct in6_addr *addr6,
650 mlxsw_sp_ipv6_addr_put(struct mlxsw_sp *mlxsw_sp, const struct in6_addr *addr6);
652 extern const struct mlxsw_sp_sb_vals mlxsw_sp1_sb_vals;
653 extern const struct mlxsw_sp_sb_vals mlxsw_sp2_sb_vals;
655 extern const struct mlxsw_sp_sb_ops mlxsw_sp1_sb_ops;
656 extern const struct mlxsw_sp_sb_ops mlxsw_sp2_sb_ops;
657 extern const struct mlxsw_sp_sb_ops mlxsw_sp3_sb_ops;
659 /* spectrum_switchdev.c */
660 int mlxsw_sp_switchdev_init(struct mlxsw_sp *mlxsw_sp);
661 void mlxsw_sp_switchdev_fini(struct mlxsw_sp *mlxsw_sp);
662 int mlxsw_sp_rif_fdb_op(struct mlxsw_sp *mlxsw_sp, const char *mac, u16 fid,
665 mlxsw_sp_port_vlan_bridge_leave(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan);
666 int mlxsw_sp_port_bridge_join(struct mlxsw_sp_port *mlxsw_sp_port,
667 struct net_device *brport_dev,
668 struct net_device *br_dev,
669 struct netlink_ext_ack *extack);
670 void mlxsw_sp_port_bridge_leave(struct mlxsw_sp_port *mlxsw_sp_port,
671 struct net_device *brport_dev,
672 struct net_device *br_dev);
673 bool mlxsw_sp_bridge_device_is_offloaded(const struct mlxsw_sp *mlxsw_sp,
674 const struct net_device *br_dev);
675 int mlxsw_sp_bridge_vxlan_join(struct mlxsw_sp *mlxsw_sp,
676 const struct net_device *br_dev,
677 const struct net_device *vxlan_dev, u16 vid,
678 struct netlink_ext_ack *extack);
679 void mlxsw_sp_bridge_vxlan_leave(struct mlxsw_sp *mlxsw_sp,
680 const struct net_device *vxlan_dev);
681 extern struct notifier_block mlxsw_sp_switchdev_notifier;
684 void mlxsw_sp_rx_listener_no_mark_func(struct sk_buff *skb,
685 u16 local_port, void *priv);
686 void mlxsw_sp_ptp_receive(struct mlxsw_sp *mlxsw_sp, struct sk_buff *skb,
688 int mlxsw_sp_port_speed_get(struct mlxsw_sp_port *mlxsw_sp_port, u32 *speed);
689 int mlxsw_sp_port_ets_set(struct mlxsw_sp_port *mlxsw_sp_port,
690 enum mlxsw_reg_qeec_hr hr, u8 index, u8 next_index,
691 bool dwrr, u8 dwrr_weight);
692 int mlxsw_sp_port_prio_tc_set(struct mlxsw_sp_port *mlxsw_sp_port,
693 u8 switch_prio, u8 tclass);
694 int mlxsw_sp_port_ets_maxrate_set(struct mlxsw_sp_port *mlxsw_sp_port,
695 enum mlxsw_reg_qeec_hr hr, u8 index,
696 u8 next_index, u32 maxrate, u8 burst_size);
697 enum mlxsw_reg_spms_state mlxsw_sp_stp_spms_state(u8 stp_state);
698 int mlxsw_sp_port_vid_stp_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid,
700 int mlxsw_sp_port_vp_mode_set(struct mlxsw_sp_port *mlxsw_sp_port, bool enable);
701 int mlxsw_sp_port_vid_learning_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid,
703 int mlxsw_sp_port_security_set(struct mlxsw_sp_port *mlxsw_sp_port,
705 int mlxsw_sp_ethtype_to_sver_type(u16 ethtype, u8 *p_sver_type);
706 int mlxsw_sp_port_egress_ethtype_set(struct mlxsw_sp_port *mlxsw_sp_port,
708 int mlxsw_sp_port_pvid_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid,
710 struct mlxsw_sp_port_vlan *
711 mlxsw_sp_port_vlan_create(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid);
712 void mlxsw_sp_port_vlan_destroy(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan);
713 int mlxsw_sp_port_kill_vid(struct net_device *dev,
714 __be16 __always_unused proto, u16 vid);
715 int mlxsw_sp_port_vlan_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid_begin,
716 u16 vid_end, bool is_member, bool untagged);
717 int mlxsw_sp_flow_counter_get(struct mlxsw_sp *mlxsw_sp,
718 unsigned int counter_index, u64 *packets,
720 int mlxsw_sp_flow_counter_alloc(struct mlxsw_sp *mlxsw_sp,
721 unsigned int *p_counter_index);
722 void mlxsw_sp_flow_counter_free(struct mlxsw_sp *mlxsw_sp,
723 unsigned int counter_index);
724 void mlxsw_sp_txhdr_construct(struct sk_buff *skb,
725 const struct mlxsw_tx_info *tx_info);
726 int mlxsw_sp_txhdr_ptp_data_construct(struct mlxsw_core *mlxsw_core,
727 struct mlxsw_sp_port *mlxsw_sp_port,
729 const struct mlxsw_tx_info *tx_info);
730 bool mlxsw_sp_port_dev_check(const struct net_device *dev);
731 struct mlxsw_sp *mlxsw_sp_lower_get(struct net_device *dev);
732 struct mlxsw_sp_port *mlxsw_sp_port_dev_lower_find(struct net_device *dev);
733 struct mlxsw_sp_port *mlxsw_sp_port_dev_lower_find_rcu(struct net_device *dev);
734 int mlxsw_sp_parsing_depth_inc(struct mlxsw_sp *mlxsw_sp);
735 void mlxsw_sp_parsing_depth_dec(struct mlxsw_sp *mlxsw_sp);
736 int mlxsw_sp_parsing_vxlan_udp_dport_set(struct mlxsw_sp *mlxsw_sp,
740 #ifdef CONFIG_MLXSW_SPECTRUM_DCB
741 int mlxsw_sp_port_dcb_init(struct mlxsw_sp_port *mlxsw_sp_port);
742 void mlxsw_sp_port_dcb_fini(struct mlxsw_sp_port *mlxsw_sp_port);
744 static inline int mlxsw_sp_port_dcb_init(struct mlxsw_sp_port *mlxsw_sp_port)
748 static inline void mlxsw_sp_port_dcb_fini(struct mlxsw_sp_port *mlxsw_sp_port)
752 /* spectrum_router.c */
753 enum mlxsw_sp_l3proto {
754 MLXSW_SP_L3_PROTO_IPV4,
755 MLXSW_SP_L3_PROTO_IPV6,
756 #define MLXSW_SP_L3_PROTO_MAX (MLXSW_SP_L3_PROTO_IPV6 + 1)
759 union mlxsw_sp_l3addr {
761 struct in6_addr addr6;
764 u16 mlxsw_sp_rif_index(const struct mlxsw_sp_rif *rif);
765 int mlxsw_sp_rif_subport_port(const struct mlxsw_sp_rif *rif,
766 u16 *port, bool *is_lag);
767 int mlxsw_sp_router_init(struct mlxsw_sp *mlxsw_sp,
768 struct netlink_ext_ack *extack);
769 void mlxsw_sp_router_fini(struct mlxsw_sp *mlxsw_sp);
770 void mlxsw_sp_rif_macvlan_del(struct mlxsw_sp *mlxsw_sp,
771 const struct net_device *macvlan_dev);
773 mlxsw_sp_port_vlan_router_leave(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan);
774 void mlxsw_sp_rif_destroy_by_dev(struct mlxsw_sp *mlxsw_sp,
775 struct net_device *dev);
776 bool mlxsw_sp_rif_exists(struct mlxsw_sp *mlxsw_sp,
777 const struct net_device *dev);
778 u16 mlxsw_sp_rif_vid(struct mlxsw_sp *mlxsw_sp, const struct net_device *dev);
779 u16 mlxsw_sp_router_port(const struct mlxsw_sp *mlxsw_sp);
780 int mlxsw_sp_router_nve_promote_decap(struct mlxsw_sp *mlxsw_sp, u32 ul_tb_id,
781 enum mlxsw_sp_l3proto ul_proto,
782 const union mlxsw_sp_l3addr *ul_sip,
784 void mlxsw_sp_router_nve_demote_decap(struct mlxsw_sp *mlxsw_sp, u32 ul_tb_id,
785 enum mlxsw_sp_l3proto ul_proto,
786 const union mlxsw_sp_l3addr *ul_sip);
787 int mlxsw_sp_router_tb_id_vr_id(struct mlxsw_sp *mlxsw_sp, u32 tb_id,
789 int mlxsw_sp_router_ul_rif_get(struct mlxsw_sp *mlxsw_sp, u32 ul_tb_id,
791 void mlxsw_sp_router_ul_rif_put(struct mlxsw_sp *mlxsw_sp, u16 ul_rif_index);
793 /* spectrum_kvdl.c */
794 enum mlxsw_sp_kvdl_entry_type {
795 MLXSW_SP_KVDL_ENTRY_TYPE_ADJ,
796 MLXSW_SP_KVDL_ENTRY_TYPE_ACTSET,
797 MLXSW_SP_KVDL_ENTRY_TYPE_PBS,
798 MLXSW_SP_KVDL_ENTRY_TYPE_MCRIGR,
799 MLXSW_SP_KVDL_ENTRY_TYPE_IPV6_ADDRESS,
800 MLXSW_SP_KVDL_ENTRY_TYPE_TNUMT,
803 static inline unsigned int
804 mlxsw_sp_kvdl_entry_size(enum mlxsw_sp_kvdl_entry_type type)
807 case MLXSW_SP_KVDL_ENTRY_TYPE_ADJ:
808 case MLXSW_SP_KVDL_ENTRY_TYPE_ACTSET:
809 case MLXSW_SP_KVDL_ENTRY_TYPE_PBS:
810 case MLXSW_SP_KVDL_ENTRY_TYPE_MCRIGR:
811 case MLXSW_SP_KVDL_ENTRY_TYPE_IPV6_ADDRESS:
812 case MLXSW_SP_KVDL_ENTRY_TYPE_TNUMT:
818 struct mlxsw_sp_kvdl_ops {
820 int (*init)(struct mlxsw_sp *mlxsw_sp, void *priv);
821 void (*fini)(struct mlxsw_sp *mlxsw_sp, void *priv);
822 int (*alloc)(struct mlxsw_sp *mlxsw_sp, void *priv,
823 enum mlxsw_sp_kvdl_entry_type type,
824 unsigned int entry_count, u32 *p_entry_index);
825 void (*free)(struct mlxsw_sp *mlxsw_sp, void *priv,
826 enum mlxsw_sp_kvdl_entry_type type,
827 unsigned int entry_count, int entry_index);
828 int (*alloc_size_query)(struct mlxsw_sp *mlxsw_sp, void *priv,
829 enum mlxsw_sp_kvdl_entry_type type,
830 unsigned int entry_count,
831 unsigned int *p_alloc_count);
832 int (*resources_register)(struct mlxsw_sp *mlxsw_sp, void *priv);
835 int mlxsw_sp_kvdl_init(struct mlxsw_sp *mlxsw_sp);
836 void mlxsw_sp_kvdl_fini(struct mlxsw_sp *mlxsw_sp);
837 int mlxsw_sp_kvdl_alloc(struct mlxsw_sp *mlxsw_sp,
838 enum mlxsw_sp_kvdl_entry_type type,
839 unsigned int entry_count, u32 *p_entry_index);
840 void mlxsw_sp_kvdl_free(struct mlxsw_sp *mlxsw_sp,
841 enum mlxsw_sp_kvdl_entry_type type,
842 unsigned int entry_count, int entry_index);
843 int mlxsw_sp_kvdl_alloc_count_query(struct mlxsw_sp *mlxsw_sp,
844 enum mlxsw_sp_kvdl_entry_type type,
845 unsigned int entry_count,
846 unsigned int *p_alloc_count);
848 /* spectrum1_kvdl.c */
849 extern const struct mlxsw_sp_kvdl_ops mlxsw_sp1_kvdl_ops;
850 int mlxsw_sp1_kvdl_resources_register(struct mlxsw_core *mlxsw_core);
852 /* spectrum2_kvdl.c */
853 extern const struct mlxsw_sp_kvdl_ops mlxsw_sp2_kvdl_ops;
855 enum mlxsw_sp_acl_mangle_field {
856 MLXSW_SP_ACL_MANGLE_FIELD_IP_DSFIELD,
857 MLXSW_SP_ACL_MANGLE_FIELD_IP_DSCP,
858 MLXSW_SP_ACL_MANGLE_FIELD_IP_ECN,
859 MLXSW_SP_ACL_MANGLE_FIELD_IP_SPORT,
860 MLXSW_SP_ACL_MANGLE_FIELD_IP_DPORT,
861 MLXSW_SP_ACL_MANGLE_FIELD_IP4_SIP,
862 MLXSW_SP_ACL_MANGLE_FIELD_IP4_DIP,
863 MLXSW_SP_ACL_MANGLE_FIELD_IP6_SIP_1,
864 MLXSW_SP_ACL_MANGLE_FIELD_IP6_SIP_2,
865 MLXSW_SP_ACL_MANGLE_FIELD_IP6_SIP_3,
866 MLXSW_SP_ACL_MANGLE_FIELD_IP6_SIP_4,
867 MLXSW_SP_ACL_MANGLE_FIELD_IP6_DIP_1,
868 MLXSW_SP_ACL_MANGLE_FIELD_IP6_DIP_2,
869 MLXSW_SP_ACL_MANGLE_FIELD_IP6_DIP_3,
870 MLXSW_SP_ACL_MANGLE_FIELD_IP6_DIP_4,
873 struct mlxsw_sp_acl_rule_info {
874 unsigned int priority;
875 struct mlxsw_afk_element_values values;
876 struct mlxsw_afa_block *act_block;
878 ingress_bind_blocker:1,
879 egress_bind_blocker:1,
881 policer_index_valid:1,
883 src_port_range_reg_valid:1,
884 dst_port_range_reg_valid:1;
885 unsigned int counter_index;
887 u8 src_port_range_reg_index;
888 u8 dst_port_range_reg_index;
891 enum mlxsw_sp_acl_mangle_field prev_field;
895 /* spectrum_flow.c */
896 struct mlxsw_sp_flow_block {
897 struct list_head binding_list;
899 struct list_head list;
900 unsigned int min_prio;
901 unsigned int max_prio;
903 struct mlxsw_sp_acl_ruleset *ruleset_zero;
904 struct mlxsw_sp *mlxsw_sp;
905 unsigned int rule_count;
906 unsigned int disable_count;
907 unsigned int ingress_blocker_rule_count;
908 unsigned int egress_blocker_rule_count;
909 unsigned int ingress_binding_count;
910 unsigned int egress_binding_count;
914 struct mlxsw_sp_flow_block_binding {
915 struct list_head list;
916 struct mlxsw_sp_port *mlxsw_sp_port;
920 static inline struct mlxsw_sp *
921 mlxsw_sp_flow_block_mlxsw_sp(struct mlxsw_sp_flow_block *block)
923 return block->mlxsw_sp;
926 static inline unsigned int
927 mlxsw_sp_flow_block_rule_count(const struct mlxsw_sp_flow_block *block)
929 return block ? block->rule_count : 0;
933 mlxsw_sp_flow_block_disable_inc(struct mlxsw_sp_flow_block *block)
936 block->disable_count++;
940 mlxsw_sp_flow_block_disable_dec(struct mlxsw_sp_flow_block *block)
943 block->disable_count--;
947 mlxsw_sp_flow_block_disabled(const struct mlxsw_sp_flow_block *block)
949 return block->disable_count;
953 mlxsw_sp_flow_block_is_egress_bound(const struct mlxsw_sp_flow_block *block)
955 return block->egress_binding_count;
959 mlxsw_sp_flow_block_is_ingress_bound(const struct mlxsw_sp_flow_block *block)
961 return block->ingress_binding_count;
965 mlxsw_sp_flow_block_is_mixed_bound(const struct mlxsw_sp_flow_block *block)
967 return block->ingress_binding_count && block->egress_binding_count;
970 struct mlxsw_sp_flow_block *mlxsw_sp_flow_block_create(struct mlxsw_sp *mlxsw_sp,
972 void mlxsw_sp_flow_block_destroy(struct mlxsw_sp_flow_block *block);
973 int mlxsw_sp_setup_tc_block_clsact(struct mlxsw_sp_port *mlxsw_sp_port,
974 struct flow_block_offload *f,
978 struct mlxsw_sp_acl_ruleset;
980 enum mlxsw_sp_acl_profile {
981 MLXSW_SP_ACL_PROFILE_FLOWER,
982 MLXSW_SP_ACL_PROFILE_MR,
985 struct mlxsw_afk *mlxsw_sp_acl_afk(struct mlxsw_sp_acl *acl);
986 struct mlxsw_sp_acl_tcam *mlxsw_sp_acl_to_tcam(struct mlxsw_sp_acl *acl);
988 int mlxsw_sp_acl_ruleset_bind(struct mlxsw_sp *mlxsw_sp,
989 struct mlxsw_sp_flow_block *block,
990 struct mlxsw_sp_flow_block_binding *binding);
991 void mlxsw_sp_acl_ruleset_unbind(struct mlxsw_sp *mlxsw_sp,
992 struct mlxsw_sp_flow_block *block,
993 struct mlxsw_sp_flow_block_binding *binding);
994 struct mlxsw_sp_acl_ruleset *
995 mlxsw_sp_acl_ruleset_lookup(struct mlxsw_sp *mlxsw_sp,
996 struct mlxsw_sp_flow_block *block, u32 chain_index,
997 enum mlxsw_sp_acl_profile profile);
998 struct mlxsw_sp_acl_ruleset *
999 mlxsw_sp_acl_ruleset_get(struct mlxsw_sp *mlxsw_sp,
1000 struct mlxsw_sp_flow_block *block, u32 chain_index,
1001 enum mlxsw_sp_acl_profile profile,
1002 struct mlxsw_afk_element_usage *tmplt_elusage);
1003 void mlxsw_sp_acl_ruleset_put(struct mlxsw_sp *mlxsw_sp,
1004 struct mlxsw_sp_acl_ruleset *ruleset);
1005 u16 mlxsw_sp_acl_ruleset_group_id(struct mlxsw_sp_acl_ruleset *ruleset);
1006 void mlxsw_sp_acl_ruleset_prio_get(struct mlxsw_sp_acl_ruleset *ruleset,
1007 unsigned int *p_min_prio,
1008 unsigned int *p_max_prio);
1010 struct mlxsw_sp_acl_rule_info *
1011 mlxsw_sp_acl_rulei_create(struct mlxsw_sp_acl *acl,
1012 struct mlxsw_afa_block *afa_block);
1013 void mlxsw_sp_acl_rulei_destroy(struct mlxsw_sp *mlxsw_sp,
1014 struct mlxsw_sp_acl_rule_info *rulei);
1015 int mlxsw_sp_acl_rulei_commit(struct mlxsw_sp_acl_rule_info *rulei);
1016 void mlxsw_sp_acl_rulei_priority(struct mlxsw_sp_acl_rule_info *rulei,
1017 unsigned int priority);
1018 void mlxsw_sp_acl_rulei_keymask_u32(struct mlxsw_sp_acl_rule_info *rulei,
1019 enum mlxsw_afk_element element,
1020 u32 key_value, u32 mask_value);
1021 void mlxsw_sp_acl_rulei_keymask_buf(struct mlxsw_sp_acl_rule_info *rulei,
1022 enum mlxsw_afk_element element,
1023 const char *key_value,
1024 const char *mask_value, unsigned int len);
1025 int mlxsw_sp_acl_rulei_act_continue(struct mlxsw_sp_acl_rule_info *rulei);
1026 int mlxsw_sp_acl_rulei_act_jump(struct mlxsw_sp_acl_rule_info *rulei,
1028 int mlxsw_sp_acl_rulei_act_terminate(struct mlxsw_sp_acl_rule_info *rulei);
1029 int mlxsw_sp_acl_rulei_act_drop(struct mlxsw_sp_acl_rule_info *rulei,
1031 const struct flow_action_cookie *fa_cookie,
1032 struct netlink_ext_ack *extack);
1033 int mlxsw_sp_acl_rulei_act_trap(struct mlxsw_sp_acl_rule_info *rulei);
1034 int mlxsw_sp_acl_rulei_act_mirror(struct mlxsw_sp *mlxsw_sp,
1035 struct mlxsw_sp_acl_rule_info *rulei,
1036 struct mlxsw_sp_flow_block *block,
1037 struct net_device *out_dev,
1038 struct netlink_ext_ack *extack);
1039 int mlxsw_sp_acl_rulei_act_fwd(struct mlxsw_sp *mlxsw_sp,
1040 struct mlxsw_sp_acl_rule_info *rulei,
1041 struct net_device *out_dev,
1042 struct netlink_ext_ack *extack);
1043 int mlxsw_sp_acl_rulei_act_vlan(struct mlxsw_sp *mlxsw_sp,
1044 struct mlxsw_sp_acl_rule_info *rulei,
1045 u32 action, u16 vid, u16 proto, u8 prio,
1046 struct netlink_ext_ack *extack);
1047 int mlxsw_sp_acl_rulei_act_priority(struct mlxsw_sp *mlxsw_sp,
1048 struct mlxsw_sp_acl_rule_info *rulei,
1049 u32 prio, struct netlink_ext_ack *extack);
1050 int mlxsw_sp_acl_rulei_act_mangle(struct mlxsw_sp *mlxsw_sp,
1051 struct mlxsw_sp_acl_rule_info *rulei,
1052 enum flow_action_mangle_base htype,
1053 u32 offset, u32 mask, u32 val,
1054 struct netlink_ext_ack *extack);
1055 int mlxsw_sp_acl_rulei_act_police(struct mlxsw_sp *mlxsw_sp,
1056 struct mlxsw_sp_acl_rule_info *rulei,
1057 u32 index, u64 rate_bytes_ps,
1058 u32 burst, struct netlink_ext_ack *extack);
1059 int mlxsw_sp_acl_rulei_act_count(struct mlxsw_sp *mlxsw_sp,
1060 struct mlxsw_sp_acl_rule_info *rulei,
1061 struct netlink_ext_ack *extack);
1062 int mlxsw_sp_acl_rulei_act_fid_set(struct mlxsw_sp *mlxsw_sp,
1063 struct mlxsw_sp_acl_rule_info *rulei,
1064 u16 fid, struct netlink_ext_ack *extack);
1065 int mlxsw_sp_acl_rulei_act_ignore(struct mlxsw_sp *mlxsw_sp,
1066 struct mlxsw_sp_acl_rule_info *rulei,
1067 bool disable_learning, bool disable_security);
1068 int mlxsw_sp_acl_rulei_act_sample(struct mlxsw_sp *mlxsw_sp,
1069 struct mlxsw_sp_acl_rule_info *rulei,
1070 struct mlxsw_sp_flow_block *block,
1071 struct psample_group *psample_group, u32 rate,
1072 u32 trunc_size, bool truncate,
1073 struct netlink_ext_ack *extack);
1075 struct mlxsw_sp_acl_rule;
1077 struct mlxsw_sp_acl_rule *
1078 mlxsw_sp_acl_rule_create(struct mlxsw_sp *mlxsw_sp,
1079 struct mlxsw_sp_acl_ruleset *ruleset,
1080 unsigned long cookie,
1081 struct mlxsw_afa_block *afa_block,
1082 struct netlink_ext_ack *extack);
1083 void mlxsw_sp_acl_rule_destroy(struct mlxsw_sp *mlxsw_sp,
1084 struct mlxsw_sp_acl_rule *rule);
1085 int mlxsw_sp_acl_rule_add(struct mlxsw_sp *mlxsw_sp,
1086 struct mlxsw_sp_acl_rule *rule);
1087 void mlxsw_sp_acl_rule_del(struct mlxsw_sp *mlxsw_sp,
1088 struct mlxsw_sp_acl_rule *rule);
1089 int mlxsw_sp_acl_rule_action_replace(struct mlxsw_sp *mlxsw_sp,
1090 struct mlxsw_sp_acl_rule *rule,
1091 struct mlxsw_afa_block *afa_block);
1092 struct mlxsw_sp_acl_rule *
1093 mlxsw_sp_acl_rule_lookup(struct mlxsw_sp *mlxsw_sp,
1094 struct mlxsw_sp_acl_ruleset *ruleset,
1095 unsigned long cookie);
1096 struct mlxsw_sp_acl_rule_info *
1097 mlxsw_sp_acl_rule_rulei(struct mlxsw_sp_acl_rule *rule);
1098 int mlxsw_sp_acl_rule_get_stats(struct mlxsw_sp *mlxsw_sp,
1099 struct mlxsw_sp_acl_rule *rule,
1100 u64 *packets, u64 *bytes, u64 *drops,
1102 enum flow_action_hw_stats *used_hw_stats);
1104 struct mlxsw_sp_fid *mlxsw_sp_acl_dummy_fid(struct mlxsw_sp *mlxsw_sp);
1106 static inline const struct flow_action_cookie *
1107 mlxsw_sp_acl_act_cookie_lookup(struct mlxsw_sp *mlxsw_sp, u32 cookie_index)
1109 return mlxsw_afa_cookie_lookup(mlxsw_sp->afa, cookie_index);
1112 int mlxsw_sp_acl_init(struct mlxsw_sp *mlxsw_sp);
1113 void mlxsw_sp_acl_fini(struct mlxsw_sp *mlxsw_sp);
1115 struct mlxsw_sp_acl_mangle_action;
1117 struct mlxsw_sp_acl_rulei_ops {
1118 int (*act_mangle_field)(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_acl_rule_info *rulei,
1119 struct mlxsw_sp_acl_mangle_action *mact, u32 val,
1120 struct netlink_ext_ack *extack);
1123 extern struct mlxsw_sp_acl_rulei_ops mlxsw_sp1_acl_rulei_ops;
1124 extern struct mlxsw_sp_acl_rulei_ops mlxsw_sp2_acl_rulei_ops;
1126 /* spectrum_acl_tcam.c */
1127 struct mlxsw_sp_acl_tcam;
1128 struct mlxsw_sp_acl_tcam_region;
1130 struct mlxsw_sp_acl_tcam_ops {
1131 enum mlxsw_reg_ptar_key_type key_type;
1133 int (*init)(struct mlxsw_sp *mlxsw_sp, void *priv,
1134 struct mlxsw_sp_acl_tcam *tcam);
1135 void (*fini)(struct mlxsw_sp *mlxsw_sp, void *priv);
1136 size_t region_priv_size;
1137 int (*region_init)(struct mlxsw_sp *mlxsw_sp, void *region_priv,
1139 struct mlxsw_sp_acl_tcam_region *region,
1141 void (*region_fini)(struct mlxsw_sp *mlxsw_sp, void *region_priv);
1142 int (*region_associate)(struct mlxsw_sp *mlxsw_sp,
1143 struct mlxsw_sp_acl_tcam_region *region);
1144 void * (*region_rehash_hints_get)(void *region_priv);
1145 void (*region_rehash_hints_put)(void *hints_priv);
1146 size_t chunk_priv_size;
1147 void (*chunk_init)(void *region_priv, void *chunk_priv,
1148 unsigned int priority);
1149 void (*chunk_fini)(void *chunk_priv);
1150 size_t entry_priv_size;
1151 int (*entry_add)(struct mlxsw_sp *mlxsw_sp,
1152 void *region_priv, void *chunk_priv,
1154 struct mlxsw_sp_acl_rule_info *rulei);
1155 void (*entry_del)(struct mlxsw_sp *mlxsw_sp,
1156 void *region_priv, void *chunk_priv,
1158 int (*entry_action_replace)(struct mlxsw_sp *mlxsw_sp,
1159 void *region_priv, void *entry_priv,
1160 struct mlxsw_sp_acl_rule_info *rulei);
1161 int (*entry_activity_get)(struct mlxsw_sp *mlxsw_sp,
1162 void *region_priv, void *entry_priv,
1166 /* spectrum1_acl_tcam.c */
1167 extern const struct mlxsw_sp_acl_tcam_ops mlxsw_sp1_acl_tcam_ops;
1169 /* spectrum2_acl_tcam.c */
1170 extern const struct mlxsw_sp_acl_tcam_ops mlxsw_sp2_acl_tcam_ops;
1172 /* spectrum_acl_flex_actions.c */
1173 extern const struct mlxsw_afa_ops mlxsw_sp1_act_afa_ops;
1174 extern const struct mlxsw_afa_ops mlxsw_sp2_act_afa_ops;
1176 /* spectrum_acl_flex_keys.c */
1177 extern const struct mlxsw_afk_ops mlxsw_sp1_afk_ops;
1178 extern const struct mlxsw_afk_ops mlxsw_sp2_afk_ops;
1179 extern const struct mlxsw_afk_ops mlxsw_sp4_afk_ops;
1181 /* spectrum_acl_bloom_filter.c */
1182 extern const struct mlxsw_sp_acl_bf_ops mlxsw_sp2_acl_bf_ops;
1183 extern const struct mlxsw_sp_acl_bf_ops mlxsw_sp4_acl_bf_ops;
1185 /* spectrum_matchall.c */
1186 struct mlxsw_sp_mall_ops {
1187 int (*sample_add)(struct mlxsw_sp *mlxsw_sp,
1188 struct mlxsw_sp_port *mlxsw_sp_port,
1189 struct mlxsw_sp_mall_entry *mall_entry,
1190 struct netlink_ext_ack *extack);
1191 void (*sample_del)(struct mlxsw_sp *mlxsw_sp,
1192 struct mlxsw_sp_port *mlxsw_sp_port,
1193 struct mlxsw_sp_mall_entry *mall_entry);
1196 extern const struct mlxsw_sp_mall_ops mlxsw_sp1_mall_ops;
1197 extern const struct mlxsw_sp_mall_ops mlxsw_sp2_mall_ops;
1199 enum mlxsw_sp_mall_action_type {
1200 MLXSW_SP_MALL_ACTION_TYPE_MIRROR,
1201 MLXSW_SP_MALL_ACTION_TYPE_SAMPLE,
1202 MLXSW_SP_MALL_ACTION_TYPE_TRAP,
1205 struct mlxsw_sp_mall_mirror_entry {
1206 const struct net_device *to_dev;
1210 struct mlxsw_sp_mall_trap_entry {
1214 struct mlxsw_sp_mall_sample_entry {
1215 struct mlxsw_sp_sample_params params;
1216 int span_id; /* Relevant for Spectrum-2 onwards. */
1219 struct mlxsw_sp_mall_entry {
1220 struct list_head list;
1221 unsigned long cookie;
1222 unsigned int priority;
1223 enum mlxsw_sp_mall_action_type type;
1226 struct mlxsw_sp_mall_mirror_entry mirror;
1227 struct mlxsw_sp_mall_trap_entry trap;
1228 struct mlxsw_sp_mall_sample_entry sample;
1230 struct rcu_head rcu;
1233 int mlxsw_sp_mall_replace(struct mlxsw_sp *mlxsw_sp,
1234 struct mlxsw_sp_flow_block *block,
1235 struct tc_cls_matchall_offload *f);
1236 void mlxsw_sp_mall_destroy(struct mlxsw_sp_flow_block *block,
1237 struct tc_cls_matchall_offload *f);
1238 int mlxsw_sp_mall_port_bind(struct mlxsw_sp_flow_block *block,
1239 struct mlxsw_sp_port *mlxsw_sp_port,
1240 struct netlink_ext_ack *extack);
1241 void mlxsw_sp_mall_port_unbind(struct mlxsw_sp_flow_block *block,
1242 struct mlxsw_sp_port *mlxsw_sp_port);
1243 int mlxsw_sp_mall_prio_get(struct mlxsw_sp_flow_block *block, u32 chain_index,
1244 unsigned int *p_min_prio, unsigned int *p_max_prio);
1246 /* spectrum_flower.c */
1247 int mlxsw_sp_flower_replace(struct mlxsw_sp *mlxsw_sp,
1248 struct mlxsw_sp_flow_block *block,
1249 struct flow_cls_offload *f);
1250 void mlxsw_sp_flower_destroy(struct mlxsw_sp *mlxsw_sp,
1251 struct mlxsw_sp_flow_block *block,
1252 struct flow_cls_offload *f);
1253 int mlxsw_sp_flower_stats(struct mlxsw_sp *mlxsw_sp,
1254 struct mlxsw_sp_flow_block *block,
1255 struct flow_cls_offload *f);
1256 int mlxsw_sp_flower_tmplt_create(struct mlxsw_sp *mlxsw_sp,
1257 struct mlxsw_sp_flow_block *block,
1258 struct flow_cls_offload *f);
1259 void mlxsw_sp_flower_tmplt_destroy(struct mlxsw_sp *mlxsw_sp,
1260 struct mlxsw_sp_flow_block *block,
1261 struct flow_cls_offload *f);
1262 int mlxsw_sp_flower_prio_get(struct mlxsw_sp *mlxsw_sp,
1263 struct mlxsw_sp_flow_block *block,
1264 u32 chain_index, unsigned int *p_min_prio,
1265 unsigned int *p_max_prio);
1267 /* spectrum_qdisc.c */
1268 int mlxsw_sp_tc_qdisc_init(struct mlxsw_sp_port *mlxsw_sp_port);
1269 void mlxsw_sp_tc_qdisc_fini(struct mlxsw_sp_port *mlxsw_sp_port);
1270 int mlxsw_sp_setup_tc_red(struct mlxsw_sp_port *mlxsw_sp_port,
1271 struct tc_red_qopt_offload *p);
1272 int mlxsw_sp_setup_tc_prio(struct mlxsw_sp_port *mlxsw_sp_port,
1273 struct tc_prio_qopt_offload *p);
1274 int mlxsw_sp_setup_tc_ets(struct mlxsw_sp_port *mlxsw_sp_port,
1275 struct tc_ets_qopt_offload *p);
1276 int mlxsw_sp_setup_tc_tbf(struct mlxsw_sp_port *mlxsw_sp_port,
1277 struct tc_tbf_qopt_offload *p);
1278 int mlxsw_sp_setup_tc_fifo(struct mlxsw_sp_port *mlxsw_sp_port,
1279 struct tc_fifo_qopt_offload *p);
1280 int mlxsw_sp_setup_tc_block_qevent_early_drop(struct mlxsw_sp_port *mlxsw_sp_port,
1281 struct flow_block_offload *f);
1282 int mlxsw_sp_setup_tc_block_qevent_mark(struct mlxsw_sp_port *mlxsw_sp_port,
1283 struct flow_block_offload *f);
1285 /* spectrum_fid.c */
1286 struct mlxsw_sp_fid *mlxsw_sp_fid_lookup_by_index(struct mlxsw_sp *mlxsw_sp,
1288 int mlxsw_sp_fid_nve_ifindex(const struct mlxsw_sp_fid *fid, int *nve_ifindex);
1289 int mlxsw_sp_fid_nve_type(const struct mlxsw_sp_fid *fid,
1290 enum mlxsw_sp_nve_type *p_type);
1291 struct mlxsw_sp_fid *mlxsw_sp_fid_lookup_by_vni(struct mlxsw_sp *mlxsw_sp,
1293 int mlxsw_sp_fid_vni(const struct mlxsw_sp_fid *fid, __be32 *vni);
1294 int mlxsw_sp_fid_nve_flood_index_set(struct mlxsw_sp_fid *fid,
1295 u32 nve_flood_index);
1296 void mlxsw_sp_fid_nve_flood_index_clear(struct mlxsw_sp_fid *fid);
1297 bool mlxsw_sp_fid_nve_flood_index_is_set(const struct mlxsw_sp_fid *fid);
1298 int mlxsw_sp_fid_vni_set(struct mlxsw_sp_fid *fid, enum mlxsw_sp_nve_type type,
1299 __be32 vni, int nve_ifindex);
1300 void mlxsw_sp_fid_vni_clear(struct mlxsw_sp_fid *fid);
1301 bool mlxsw_sp_fid_vni_is_set(const struct mlxsw_sp_fid *fid);
1302 void mlxsw_sp_fid_fdb_clear_offload(const struct mlxsw_sp_fid *fid,
1303 const struct net_device *nve_dev);
1304 int mlxsw_sp_fid_flood_set(struct mlxsw_sp_fid *fid,
1305 enum mlxsw_sp_flood_type packet_type, u16 local_port,
1307 int mlxsw_sp_fid_port_vid_map(struct mlxsw_sp_fid *fid,
1308 struct mlxsw_sp_port *mlxsw_sp_port, u16 vid);
1309 void mlxsw_sp_fid_port_vid_unmap(struct mlxsw_sp_fid *fid,
1310 struct mlxsw_sp_port *mlxsw_sp_port, u16 vid);
1311 u16 mlxsw_sp_fid_index(const struct mlxsw_sp_fid *fid);
1312 enum mlxsw_sp_fid_type mlxsw_sp_fid_type(const struct mlxsw_sp_fid *fid);
1313 int mlxsw_sp_fid_rif_set(struct mlxsw_sp_fid *fid, struct mlxsw_sp_rif *rif);
1314 void mlxsw_sp_fid_rif_unset(struct mlxsw_sp_fid *fid);
1315 struct mlxsw_sp_rif *mlxsw_sp_fid_rif(const struct mlxsw_sp_fid *fid);
1316 enum mlxsw_sp_rif_type
1317 mlxsw_sp_fid_type_rif_type(const struct mlxsw_sp *mlxsw_sp,
1318 enum mlxsw_sp_fid_type type);
1319 u16 mlxsw_sp_fid_8021q_vid(const struct mlxsw_sp_fid *fid);
1320 struct mlxsw_sp_fid *mlxsw_sp_fid_8021q_get(struct mlxsw_sp *mlxsw_sp, u16 vid);
1321 struct mlxsw_sp_fid *mlxsw_sp_fid_8021d_get(struct mlxsw_sp *mlxsw_sp,
1323 struct mlxsw_sp_fid *mlxsw_sp_fid_8021q_lookup(struct mlxsw_sp *mlxsw_sp,
1325 struct mlxsw_sp_fid *mlxsw_sp_fid_8021d_lookup(struct mlxsw_sp *mlxsw_sp,
1327 struct mlxsw_sp_fid *mlxsw_sp_fid_rfid_get(struct mlxsw_sp *mlxsw_sp,
1329 struct mlxsw_sp_fid *mlxsw_sp_fid_dummy_get(struct mlxsw_sp *mlxsw_sp);
1330 void mlxsw_sp_fid_put(struct mlxsw_sp_fid *fid);
1331 int mlxsw_sp_port_fids_init(struct mlxsw_sp_port *mlxsw_sp_port);
1332 void mlxsw_sp_port_fids_fini(struct mlxsw_sp_port *mlxsw_sp_port);
1333 int mlxsw_sp_fid_port_join_lag(const struct mlxsw_sp_port *mlxsw_sp_port);
1334 void mlxsw_sp_fid_port_leave_lag(const struct mlxsw_sp_port *mlxsw_sp_port);
1336 extern const struct mlxsw_sp_fid_core_ops mlxsw_sp1_fid_core_ops;
1337 extern const struct mlxsw_sp_fid_core_ops mlxsw_sp2_fid_core_ops;
1340 enum mlxsw_sp_mr_route_prio {
1341 MLXSW_SP_MR_ROUTE_PRIO_SG,
1342 MLXSW_SP_MR_ROUTE_PRIO_STARG,
1343 MLXSW_SP_MR_ROUTE_PRIO_CATCHALL,
1344 __MLXSW_SP_MR_ROUTE_PRIO_MAX
1347 #define MLXSW_SP_MR_ROUTE_PRIO_MAX (__MLXSW_SP_MR_ROUTE_PRIO_MAX - 1)
1349 struct mlxsw_sp_mr_route_key;
1351 struct mlxsw_sp_mr_tcam_ops {
1353 int (*init)(struct mlxsw_sp *mlxsw_sp, void *priv);
1354 void (*fini)(void *priv);
1355 size_t route_priv_size;
1356 int (*route_create)(struct mlxsw_sp *mlxsw_sp, void *priv,
1358 struct mlxsw_sp_mr_route_key *key,
1359 struct mlxsw_afa_block *afa_block,
1360 enum mlxsw_sp_mr_route_prio prio);
1361 void (*route_destroy)(struct mlxsw_sp *mlxsw_sp, void *priv,
1363 struct mlxsw_sp_mr_route_key *key);
1364 int (*route_update)(struct mlxsw_sp *mlxsw_sp, void *route_priv,
1365 struct mlxsw_sp_mr_route_key *key,
1366 struct mlxsw_afa_block *afa_block);
1369 /* spectrum1_mr_tcam.c */
1370 extern const struct mlxsw_sp_mr_tcam_ops mlxsw_sp1_mr_tcam_ops;
1372 /* spectrum2_mr_tcam.c */
1373 extern const struct mlxsw_sp_mr_tcam_ops mlxsw_sp2_mr_tcam_ops;
1375 /* spectrum_nve.c */
1376 struct mlxsw_sp_nve_params {
1377 enum mlxsw_sp_nve_type type;
1379 const struct net_device *dev;
1383 extern const struct mlxsw_sp_nve_ops *mlxsw_sp1_nve_ops_arr[];
1384 extern const struct mlxsw_sp_nve_ops *mlxsw_sp2_nve_ops_arr[];
1386 int mlxsw_sp_nve_learned_ip_resolve(struct mlxsw_sp *mlxsw_sp, u32 uip,
1387 enum mlxsw_sp_l3proto proto,
1388 union mlxsw_sp_l3addr *addr);
1389 int mlxsw_sp_nve_flood_ip_add(struct mlxsw_sp *mlxsw_sp,
1390 struct mlxsw_sp_fid *fid,
1391 enum mlxsw_sp_l3proto proto,
1392 union mlxsw_sp_l3addr *addr);
1393 void mlxsw_sp_nve_flood_ip_del(struct mlxsw_sp *mlxsw_sp,
1394 struct mlxsw_sp_fid *fid,
1395 enum mlxsw_sp_l3proto proto,
1396 union mlxsw_sp_l3addr *addr);
1397 int mlxsw_sp_nve_ipv6_addr_kvdl_set(struct mlxsw_sp *mlxsw_sp,
1398 const struct in6_addr *addr6,
1400 void mlxsw_sp_nve_ipv6_addr_kvdl_unset(struct mlxsw_sp *mlxsw_sp,
1401 const struct in6_addr *addr6);
1403 mlxsw_sp_nve_ipv6_addr_map_replace(struct mlxsw_sp *mlxsw_sp, const char *mac,
1405 const struct in6_addr *new_addr6);
1406 void mlxsw_sp_nve_ipv6_addr_map_del(struct mlxsw_sp *mlxsw_sp, const char *mac,
1408 int mlxsw_sp_nve_fid_enable(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_fid *fid,
1409 struct mlxsw_sp_nve_params *params,
1410 struct netlink_ext_ack *extack);
1411 void mlxsw_sp_nve_fid_disable(struct mlxsw_sp *mlxsw_sp,
1412 struct mlxsw_sp_fid *fid);
1413 int mlxsw_sp_port_nve_init(struct mlxsw_sp_port *mlxsw_sp_port);
1414 void mlxsw_sp_port_nve_fini(struct mlxsw_sp_port *mlxsw_sp_port);
1415 int mlxsw_sp_nve_init(struct mlxsw_sp *mlxsw_sp);
1416 void mlxsw_sp_nve_fini(struct mlxsw_sp *mlxsw_sp);
1418 /* spectrum_trap.c */
1419 int mlxsw_sp_devlink_traps_init(struct mlxsw_sp *mlxsw_sp);
1420 void mlxsw_sp_devlink_traps_fini(struct mlxsw_sp *mlxsw_sp);
1421 int mlxsw_sp_trap_init(struct mlxsw_core *mlxsw_core,
1422 const struct devlink_trap *trap, void *trap_ctx);
1423 void mlxsw_sp_trap_fini(struct mlxsw_core *mlxsw_core,
1424 const struct devlink_trap *trap, void *trap_ctx);
1425 int mlxsw_sp_trap_action_set(struct mlxsw_core *mlxsw_core,
1426 const struct devlink_trap *trap,
1427 enum devlink_trap_action action,
1428 struct netlink_ext_ack *extack);
1429 int mlxsw_sp_trap_group_init(struct mlxsw_core *mlxsw_core,
1430 const struct devlink_trap_group *group);
1431 int mlxsw_sp_trap_group_set(struct mlxsw_core *mlxsw_core,
1432 const struct devlink_trap_group *group,
1433 const struct devlink_trap_policer *policer,
1434 struct netlink_ext_ack *extack);
1436 mlxsw_sp_trap_policer_init(struct mlxsw_core *mlxsw_core,
1437 const struct devlink_trap_policer *policer);
1438 void mlxsw_sp_trap_policer_fini(struct mlxsw_core *mlxsw_core,
1439 const struct devlink_trap_policer *policer);
1441 mlxsw_sp_trap_policer_set(struct mlxsw_core *mlxsw_core,
1442 const struct devlink_trap_policer *policer,
1443 u64 rate, u64 burst, struct netlink_ext_ack *extack);
1445 mlxsw_sp_trap_policer_counter_get(struct mlxsw_core *mlxsw_core,
1446 const struct devlink_trap_policer *policer,
1448 int mlxsw_sp_trap_group_policer_hw_id_get(struct mlxsw_sp *mlxsw_sp, u16 id,
1449 bool *p_enabled, u16 *p_hw_id);
1451 static inline struct net *mlxsw_sp_net(struct mlxsw_sp *mlxsw_sp)
1453 return mlxsw_core_net(mlxsw_sp->core);
1456 /* spectrum_ethtool.c */
1457 extern const struct ethtool_ops mlxsw_sp_port_ethtool_ops;
1458 extern const struct mlxsw_sp_port_type_speed_ops mlxsw_sp1_port_type_speed_ops;
1459 extern const struct mlxsw_sp_port_type_speed_ops mlxsw_sp2_port_type_speed_ops;
1461 /* spectrum_policer.c */
1462 extern const struct mlxsw_sp_policer_core_ops mlxsw_sp1_policer_core_ops;
1463 extern const struct mlxsw_sp_policer_core_ops mlxsw_sp2_policer_core_ops;
1465 enum mlxsw_sp_policer_type {
1466 MLXSW_SP_POLICER_TYPE_SINGLE_RATE,
1468 __MLXSW_SP_POLICER_TYPE_MAX,
1469 MLXSW_SP_POLICER_TYPE_MAX = __MLXSW_SP_POLICER_TYPE_MAX - 1,
1472 struct mlxsw_sp_policer_params {
1478 int mlxsw_sp_policer_add(struct mlxsw_sp *mlxsw_sp,
1479 enum mlxsw_sp_policer_type type,
1480 const struct mlxsw_sp_policer_params *params,
1481 struct netlink_ext_ack *extack, u16 *p_policer_index);
1482 void mlxsw_sp_policer_del(struct mlxsw_sp *mlxsw_sp,
1483 enum mlxsw_sp_policer_type type,
1485 int mlxsw_sp_policer_drops_counter_get(struct mlxsw_sp *mlxsw_sp,
1486 enum mlxsw_sp_policer_type type,
1487 u16 policer_index, u64 *p_drops);
1488 int mlxsw_sp_policers_init(struct mlxsw_sp *mlxsw_sp);
1489 void mlxsw_sp_policers_fini(struct mlxsw_sp *mlxsw_sp);
1490 int mlxsw_sp_policer_resources_register(struct mlxsw_core *mlxsw_core);
1492 /* spectrum_pgt.c */
1493 int mlxsw_sp_pgt_mid_alloc(struct mlxsw_sp *mlxsw_sp, u16 *p_mid);
1494 void mlxsw_sp_pgt_mid_free(struct mlxsw_sp *mlxsw_sp, u16 mid_base);
1495 int mlxsw_sp_pgt_mid_alloc_range(struct mlxsw_sp *mlxsw_sp, u16 *mid_base,
1497 void mlxsw_sp_pgt_mid_free_range(struct mlxsw_sp *mlxsw_sp, u16 mid_base,
1499 int mlxsw_sp_pgt_entry_port_set(struct mlxsw_sp *mlxsw_sp, u16 mid,
1500 u16 smpe, u16 local_port, bool member);
1501 int mlxsw_sp_pgt_init(struct mlxsw_sp *mlxsw_sp);
1502 void mlxsw_sp_pgt_fini(struct mlxsw_sp *mlxsw_sp);
1504 /* spectrum_port_range.c */
1505 struct mlxsw_sp_port_range {
1508 u8 source:1; /* Source or destination */
1511 int mlxsw_sp_port_range_reg_get(struct mlxsw_sp *mlxsw_sp,
1512 const struct mlxsw_sp_port_range *range,
1513 struct netlink_ext_ack *extack,
1515 void mlxsw_sp_port_range_reg_put(struct mlxsw_sp *mlxsw_sp, u8 prr_index);
1516 int mlxsw_sp_port_range_init(struct mlxsw_sp *mlxsw_sp);
1517 void mlxsw_sp_port_range_fini(struct mlxsw_sp *mlxsw_sp);