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,
76 struct mlxsw_sp_span_entry;
77 enum mlxsw_sp_l3proto;
78 union mlxsw_sp_l3addr;
80 struct mlxsw_sp_upper {
81 struct net_device *dev;
82 unsigned int ref_count;
85 enum mlxsw_sp_rif_type {
86 MLXSW_SP_RIF_TYPE_SUBPORT,
87 MLXSW_SP_RIF_TYPE_VLAN,
88 MLXSW_SP_RIF_TYPE_FID,
89 MLXSW_SP_RIF_TYPE_IPIP_LB, /* IP-in-IP loopback. */
90 MLXSW_SP_RIF_TYPE_MAX,
93 struct mlxsw_sp_router_ops;
95 extern const struct mlxsw_sp_router_ops mlxsw_sp1_router_ops;
96 extern const struct mlxsw_sp_router_ops mlxsw_sp2_router_ops;
98 struct mlxsw_sp_switchdev_ops;
100 extern const struct mlxsw_sp_switchdev_ops mlxsw_sp1_switchdev_ops;
101 extern const struct mlxsw_sp_switchdev_ops mlxsw_sp2_switchdev_ops;
103 enum mlxsw_sp_fid_type {
104 MLXSW_SP_FID_TYPE_8021Q,
105 MLXSW_SP_FID_TYPE_8021D,
106 MLXSW_SP_FID_TYPE_RFID,
107 MLXSW_SP_FID_TYPE_DUMMY,
108 MLXSW_SP_FID_TYPE_MAX,
111 enum mlxsw_sp_nve_type {
112 MLXSW_SP_NVE_TYPE_VXLAN,
116 struct mlxsw_sp_bridge;
117 struct mlxsw_sp_router;
120 struct mlxsw_sp_counter_pool;
121 struct mlxsw_sp_fid_core;
122 struct mlxsw_sp_kvdl;
124 struct mlxsw_sp_kvdl_ops;
125 struct mlxsw_sp_mr_tcam_ops;
126 struct mlxsw_sp_acl_rulei_ops;
127 struct mlxsw_sp_acl_tcam_ops;
128 struct mlxsw_sp_nve_ops;
129 struct mlxsw_sp_sb_ops;
130 struct mlxsw_sp_sb_vals;
131 struct mlxsw_sp_port_type_speed_ops;
132 struct mlxsw_sp_ptp_state;
133 struct mlxsw_sp_ptp_ops;
134 struct mlxsw_sp_span_ops;
135 struct mlxsw_sp_qdisc_state;
136 struct mlxsw_sp_mall_entry;
139 struct mlxsw_sp_port_mapping {
142 u8 width; /* Number of lanes used by the port */
143 u8 module_width; /* Number of lanes in the module (static) */
147 struct mlxsw_sp_port_mapping_events {
148 struct list_head queue;
149 spinlock_t queue_lock; /* protects queue */
150 struct work_struct work;
153 struct mlxsw_sp_parsing {
154 refcount_t parsing_depth_ref;
157 struct mutex lock; /* Protects parsing configuration */
161 struct mlxsw_sp_port **ports;
162 struct mlxsw_core *core;
163 const struct mlxsw_bus_info *bus_info;
164 unsigned char base_mac[ETH_ALEN];
165 const unsigned char *mac_mask;
166 struct mlxsw_sp_upper *lags;
167 struct mlxsw_sp_port_mapping *port_mapping;
168 struct mlxsw_sp_port_mapping_events port_mapping_events;
169 struct rhashtable sample_trigger_ht;
170 struct mlxsw_sp_sb *sb;
171 struct mlxsw_sp_bridge *bridge;
172 struct mlxsw_sp_router *router;
173 struct mlxsw_sp_mr *mr;
174 struct mlxsw_afa *afa;
175 struct mlxsw_sp_acl *acl;
176 struct mlxsw_sp_fid_core *fid_core;
177 struct mlxsw_sp_policer_core *policer_core;
178 struct mlxsw_sp_port_range_core *pr_core;
179 struct mlxsw_sp_kvdl *kvdl;
180 struct mlxsw_sp_nve *nve;
181 struct notifier_block netdevice_nb;
182 struct mlxsw_sp_ptp_clock *clock;
183 struct mlxsw_sp_ptp_state *ptp_state;
184 struct mlxsw_sp_counter_pool *counter_pool;
185 struct mlxsw_sp_span *span;
186 struct mlxsw_sp_trap *trap;
187 struct mlxsw_sp_parsing parsing;
188 const struct mlxsw_sp_switchdev_ops *switchdev_ops;
189 const struct mlxsw_sp_kvdl_ops *kvdl_ops;
190 const struct mlxsw_afa_ops *afa_ops;
191 const struct mlxsw_afk_ops *afk_ops;
192 const struct mlxsw_sp_mr_tcam_ops *mr_tcam_ops;
193 const struct mlxsw_sp_acl_rulei_ops *acl_rulei_ops;
194 const struct mlxsw_sp_acl_tcam_ops *acl_tcam_ops;
195 const struct mlxsw_sp_acl_bf_ops *acl_bf_ops;
196 const struct mlxsw_sp_nve_ops **nve_ops_arr;
197 const struct mlxsw_sp_sb_vals *sb_vals;
198 const struct mlxsw_sp_sb_ops *sb_ops;
199 const struct mlxsw_sp_port_type_speed_ops *port_type_speed_ops;
200 const struct mlxsw_sp_ptp_ops *ptp_ops;
201 const struct mlxsw_sp_span_ops *span_ops;
202 const struct mlxsw_sp_policer_core_ops *policer_core_ops;
203 const struct mlxsw_sp_trap_ops *trap_ops;
204 const struct mlxsw_sp_mall_ops *mall_ops;
205 const struct mlxsw_sp_router_ops *router_ops;
206 const struct mlxsw_listener *listeners;
207 const struct mlxsw_sp_fid_family **fid_family_arr;
208 size_t listeners_count;
209 u32 lowest_shaper_bs;
210 struct rhashtable ipv6_addr_ht;
211 struct mutex ipv6_addr_ht_lock; /* Protects ipv6_addr_ht */
212 struct mlxsw_sp_pgt *pgt;
213 bool pgt_smpe_index_valid;
216 struct mlxsw_sp_ptp_ops {
217 struct mlxsw_sp_ptp_clock *
218 (*clock_init)(struct mlxsw_sp *mlxsw_sp, struct device *dev);
219 void (*clock_fini)(struct mlxsw_sp_ptp_clock *clock);
221 struct mlxsw_sp_ptp_state *(*init)(struct mlxsw_sp *mlxsw_sp);
222 void (*fini)(struct mlxsw_sp_ptp_state *ptp_state);
224 /* Notify a driver that a packet that might be PTP was received. Driver
225 * is responsible for freeing the passed-in SKB.
227 void (*receive)(struct mlxsw_sp *mlxsw_sp, struct sk_buff *skb,
230 /* Notify a driver that a timestamped packet was transmitted. Driver
231 * is responsible for freeing the passed-in SKB.
233 void (*transmitted)(struct mlxsw_sp *mlxsw_sp, struct sk_buff *skb,
236 int (*hwtstamp_get)(struct mlxsw_sp_port *mlxsw_sp_port,
237 struct hwtstamp_config *config);
238 int (*hwtstamp_set)(struct mlxsw_sp_port *mlxsw_sp_port,
239 struct hwtstamp_config *config);
240 void (*shaper_work)(struct work_struct *work);
241 int (*get_ts_info)(struct mlxsw_sp *mlxsw_sp,
242 struct ethtool_ts_info *info);
243 int (*get_stats_count)(void);
244 void (*get_stats_strings)(u8 **p);
245 void (*get_stats)(struct mlxsw_sp_port *mlxsw_sp_port,
246 u64 *data, int data_index);
247 int (*txhdr_construct)(struct mlxsw_core *mlxsw_core,
248 struct mlxsw_sp_port *mlxsw_sp_port,
250 const struct mlxsw_tx_info *tx_info);
253 static inline struct mlxsw_sp_upper *
254 mlxsw_sp_lag_get(struct mlxsw_sp *mlxsw_sp, u16 lag_id)
256 return &mlxsw_sp->lags[lag_id];
259 struct mlxsw_sp_port_pcpu_stats {
264 struct u64_stats_sync syncp;
268 enum mlxsw_sp_sample_trigger_type {
269 MLXSW_SP_SAMPLE_TRIGGER_TYPE_INGRESS,
270 MLXSW_SP_SAMPLE_TRIGGER_TYPE_EGRESS,
271 MLXSW_SP_SAMPLE_TRIGGER_TYPE_POLICY_ENGINE,
274 struct mlxsw_sp_sample_trigger {
275 enum mlxsw_sp_sample_trigger_type type;
276 u16 local_port; /* Reserved when trigger type is not ingress / egress. */
279 struct mlxsw_sp_sample_params {
280 struct psample_group *psample_group;
286 struct mlxsw_sp_bridge_port;
289 struct mlxsw_sp_port_vlan {
290 struct list_head list;
291 struct mlxsw_sp_port *mlxsw_sp_port;
292 struct mlxsw_sp_fid *fid;
294 struct mlxsw_sp_bridge_port *bridge_port;
295 struct list_head bridge_vlan_node;
298 /* No need an internal lock; At worse - miss a single periodic iteration */
299 struct mlxsw_sp_port_xstats {
301 u64 tc_ecn[TC_MAX_QUEUE];
302 u64 wred_drop[TC_MAX_QUEUE];
303 u64 tail_drop[TC_MAX_QUEUE];
304 u64 backlog[TC_MAX_QUEUE];
305 u64 tx_bytes[IEEE_8021QAZ_MAX_TCS];
306 u64 tx_packets[IEEE_8021QAZ_MAX_TCS];
309 struct mlxsw_sp_ptp_port_dir_stats {
314 struct mlxsw_sp_ptp_port_stats {
315 struct mlxsw_sp_ptp_port_dir_stats rx_gcd;
316 struct mlxsw_sp_ptp_port_dir_stats tx_gcd;
319 struct mlxsw_sp_port {
320 struct net_device *dev;
321 struct mlxsw_sp_port_pcpu_stats __percpu *pcpu_stats;
322 struct mlxsw_sp *mlxsw_sp;
335 struct ieee_ets *ets;
336 struct ieee_maxrate *maxrate;
337 struct ieee_pfc *pfc;
338 enum mlxsw_reg_qpts_trust_state trust_state;
340 struct mlxsw_sp_port_mapping mapping; /* mapping is constant during the
341 * mlxsw_sp_port lifetime, however
342 * the same localport can have
346 #define MLXSW_HW_STATS_UPDATE_TIME HZ
347 struct rtnl_link_stats64 stats;
348 struct mlxsw_sp_port_xstats xstats;
349 struct delayed_work update_dw;
351 struct list_head vlans_list;
352 struct mlxsw_sp_port_vlan *default_vlan;
353 struct mlxsw_sp_qdisc_state *qdisc;
354 unsigned acl_rule_count;
355 struct mlxsw_sp_flow_block *ing_flow_block;
356 struct mlxsw_sp_flow_block *eg_flow_block;
358 struct delayed_work shaper_dw;
359 struct hwtstamp_config hwtstamp_config;
362 struct mlxsw_sp_ptp_port_stats stats;
366 struct mlxsw_sp_hdroom *hdroom;
367 u64 module_overheat_initial_val;
370 struct mlxsw_sp_port_type_speed_ops {
371 void (*from_ptys_supported_port)(struct mlxsw_sp *mlxsw_sp,
373 struct ethtool_link_ksettings *cmd);
374 void (*from_ptys_link)(struct mlxsw_sp *mlxsw_sp, u32 ptys_eth_proto,
375 unsigned long *mode);
376 u32 (*from_ptys_speed)(struct mlxsw_sp *mlxsw_sp, u32 ptys_eth_proto);
377 void (*from_ptys_link_mode)(struct mlxsw_sp *mlxsw_sp,
378 bool carrier_ok, u32 ptys_eth_proto,
379 struct ethtool_link_ksettings *cmd);
380 int (*ptys_max_speed)(struct mlxsw_sp_port *mlxsw_sp_port, u32 *p_max_speed);
381 u32 (*to_ptys_advert_link)(struct mlxsw_sp *mlxsw_sp,
382 const struct ethtool_link_ksettings *cmd);
383 u32 (*to_ptys_speed_lanes)(struct mlxsw_sp *mlxsw_sp, u8 width,
384 const struct ethtool_link_ksettings *cmd);
385 void (*reg_ptys_eth_pack)(struct mlxsw_sp *mlxsw_sp, char *payload,
386 u16 local_port, u32 proto_admin, bool autoneg);
387 void (*reg_ptys_eth_unpack)(struct mlxsw_sp *mlxsw_sp, char *payload,
388 u32 *p_eth_proto_cap,
389 u32 *p_eth_proto_admin,
390 u32 *p_eth_proto_oper);
391 u32 (*ptys_proto_cap_masked_get)(u32 eth_proto_cap);
394 struct mlxsw_sp_ports_bitmap {
395 unsigned long *bitmap;
400 mlxsw_sp_port_bitmap_init(struct mlxsw_sp *mlxsw_sp,
401 struct mlxsw_sp_ports_bitmap *ports_bm)
403 unsigned int nbits = mlxsw_core_max_ports(mlxsw_sp->core);
405 ports_bm->nbits = nbits;
406 ports_bm->bitmap = bitmap_zalloc(nbits, GFP_KERNEL);
407 if (!ports_bm->bitmap)
414 mlxsw_sp_port_bitmap_fini(struct mlxsw_sp_ports_bitmap *ports_bm)
416 bitmap_free(ports_bm->bitmap);
419 static inline u8 mlxsw_sp_tunnel_ecn_decap(u8 outer_ecn, u8 inner_ecn,
424 *trap_en = !!__INET_ECN_decapsulate(outer_ecn, inner_ecn, &set_ce);
427 else if (outer_ecn == INET_ECN_ECT_1 && inner_ecn == INET_ECN_ECT_0)
428 return INET_ECN_ECT_1;
433 static inline struct net_device *
434 mlxsw_sp_bridge_vxlan_dev_find(struct net_device *br_dev)
436 struct net_device *dev;
437 struct list_head *iter;
439 netdev_for_each_lower_dev(br_dev, dev, iter) {
440 if (netif_is_vxlan(dev))
447 static inline bool mlxsw_sp_bridge_has_vxlan(struct net_device *br_dev)
449 return !!mlxsw_sp_bridge_vxlan_dev_find(br_dev);
453 mlxsw_sp_vxlan_mapped_vid(const struct net_device *vxlan_dev, u16 *p_vid)
455 struct bridge_vlan_info vinfo;
459 err = br_vlan_get_pvid(vxlan_dev, &vid);
463 err = br_vlan_get_info(vxlan_dev, vid, &vinfo);
464 if (err || !(vinfo.flags & BRIDGE_VLAN_INFO_UNTAGGED))
473 mlxsw_sp_port_is_pause_en(const struct mlxsw_sp_port *mlxsw_sp_port)
475 return mlxsw_sp_port->link.tx_pause || mlxsw_sp_port->link.rx_pause;
478 static inline struct mlxsw_sp_port *
479 mlxsw_sp_port_lagged_get(struct mlxsw_sp *mlxsw_sp, u16 lag_id, u8 port_index)
481 struct mlxsw_sp_port *mlxsw_sp_port;
484 local_port = mlxsw_core_lag_mapping_get(mlxsw_sp->core,
486 mlxsw_sp_port = mlxsw_sp->ports[local_port];
487 return mlxsw_sp_port && mlxsw_sp_port->lagged ? mlxsw_sp_port : NULL;
490 static inline struct mlxsw_sp_port_vlan *
491 mlxsw_sp_port_vlan_find_by_vid(const struct mlxsw_sp_port *mlxsw_sp_port,
494 struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan;
496 list_for_each_entry(mlxsw_sp_port_vlan, &mlxsw_sp_port->vlans_list,
498 if (mlxsw_sp_port_vlan->vid == vid)
499 return mlxsw_sp_port_vlan;
505 enum mlxsw_sp_flood_type {
506 MLXSW_SP_FLOOD_TYPE_UC,
507 MLXSW_SP_FLOOD_TYPE_BC,
508 MLXSW_SP_FLOOD_TYPE_MC,
511 int mlxsw_sp_port_get_stats_raw(struct net_device *dev, int grp,
512 int prio, char *ppcnt_pl);
513 int mlxsw_sp_port_admin_status_set(struct mlxsw_sp_port *mlxsw_sp_port,
516 mlxsw_sp_port_vlan_classification_set(struct mlxsw_sp_port *mlxsw_sp_port,
517 bool is_8021ad_tagged,
518 bool is_8021q_tagged);
520 mlxsw_sp_local_port_is_valid(struct mlxsw_sp *mlxsw_sp, u16 local_port)
522 unsigned int max_ports = mlxsw_core_max_ports(mlxsw_sp->core);
524 return local_port < max_ports && local_port;
527 /* spectrum_buffers.c */
528 struct mlxsw_sp_hdroom_prio {
529 /* Number of port buffer associated with this priority. This is the
530 * actually configured value.
533 /* Value of buf_idx deduced from the DCB ETS configuration. */
535 /* Value of buf_idx taken from the dcbnl_setbuffer configuration. */
540 struct mlxsw_sp_hdroom_buf {
543 /* Size requirement form dcbnl_setbuffer. */
548 enum mlxsw_sp_hdroom_mode {
549 MLXSW_SP_HDROOM_MODE_DCB,
550 MLXSW_SP_HDROOM_MODE_TC,
553 #define MLXSW_SP_PB_COUNT 10
555 struct mlxsw_sp_hdroom {
556 enum mlxsw_sp_hdroom_mode mode;
559 struct mlxsw_sp_hdroom_prio prio[IEEE_8021Q_MAX_PRIORITIES];
562 struct mlxsw_sp_hdroom_buf buf[MLXSW_SP_PB_COUNT];
565 /* Size actually configured for the internal buffer. Equal to
566 * reserve when internal buffer is enabled.
569 /* Space reserved in the headroom for the internal buffer. Port
570 * buffers are not allowed to grow into this space.
579 int mlxsw_sp_buffers_init(struct mlxsw_sp *mlxsw_sp);
580 void mlxsw_sp_buffers_fini(struct mlxsw_sp *mlxsw_sp);
581 int mlxsw_sp_port_buffers_init(struct mlxsw_sp_port *mlxsw_sp_port);
582 void mlxsw_sp_port_buffers_fini(struct mlxsw_sp_port *mlxsw_sp_port);
583 int mlxsw_sp_sb_pool_get(struct mlxsw_core *mlxsw_core,
584 unsigned int sb_index, u16 pool_index,
585 struct devlink_sb_pool_info *pool_info);
586 int mlxsw_sp_sb_pool_set(struct mlxsw_core *mlxsw_core,
587 unsigned int sb_index, u16 pool_index, u32 size,
588 enum devlink_sb_threshold_type threshold_type,
589 struct netlink_ext_ack *extack);
590 int mlxsw_sp_sb_port_pool_get(struct mlxsw_core_port *mlxsw_core_port,
591 unsigned int sb_index, u16 pool_index,
593 int mlxsw_sp_sb_port_pool_set(struct mlxsw_core_port *mlxsw_core_port,
594 unsigned int sb_index, u16 pool_index,
595 u32 threshold, struct netlink_ext_ack *extack);
596 int mlxsw_sp_sb_tc_pool_bind_get(struct mlxsw_core_port *mlxsw_core_port,
597 unsigned int sb_index, u16 tc_index,
598 enum devlink_sb_pool_type pool_type,
599 u16 *p_pool_index, u32 *p_threshold);
600 int mlxsw_sp_sb_tc_pool_bind_set(struct mlxsw_core_port *mlxsw_core_port,
601 unsigned int sb_index, u16 tc_index,
602 enum devlink_sb_pool_type pool_type,
603 u16 pool_index, u32 threshold,
604 struct netlink_ext_ack *extack);
605 int mlxsw_sp_sb_occ_snapshot(struct mlxsw_core *mlxsw_core,
606 unsigned int sb_index);
607 int mlxsw_sp_sb_occ_max_clear(struct mlxsw_core *mlxsw_core,
608 unsigned int sb_index);
609 int mlxsw_sp_sb_occ_port_pool_get(struct mlxsw_core_port *mlxsw_core_port,
610 unsigned int sb_index, u16 pool_index,
611 u32 *p_cur, u32 *p_max);
612 int mlxsw_sp_sb_occ_tc_port_bind_get(struct mlxsw_core_port *mlxsw_core_port,
613 unsigned int sb_index, u16 tc_index,
614 enum devlink_sb_pool_type pool_type,
615 u32 *p_cur, u32 *p_max);
616 u32 mlxsw_sp_cells_bytes(const struct mlxsw_sp *mlxsw_sp, u32 cells);
617 u32 mlxsw_sp_bytes_cells(const struct mlxsw_sp *mlxsw_sp, u32 bytes);
618 void mlxsw_sp_hdroom_prios_reset_buf_idx(struct mlxsw_sp_hdroom *hdroom);
619 void mlxsw_sp_hdroom_bufs_reset_lossiness(struct mlxsw_sp_hdroom *hdroom);
620 void mlxsw_sp_hdroom_bufs_reset_sizes(struct mlxsw_sp_port *mlxsw_sp_port,
621 struct mlxsw_sp_hdroom *hdroom);
622 int mlxsw_sp_hdroom_configure(struct mlxsw_sp_port *mlxsw_sp_port,
623 const struct mlxsw_sp_hdroom *hdroom);
624 struct mlxsw_sp_sample_params *
625 mlxsw_sp_sample_trigger_params_lookup(struct mlxsw_sp *mlxsw_sp,
626 const struct mlxsw_sp_sample_trigger *trigger);
628 mlxsw_sp_sample_trigger_params_set(struct mlxsw_sp *mlxsw_sp,
629 const struct mlxsw_sp_sample_trigger *trigger,
630 const struct mlxsw_sp_sample_params *params,
631 struct netlink_ext_ack *extack);
633 mlxsw_sp_sample_trigger_params_unset(struct mlxsw_sp *mlxsw_sp,
634 const struct mlxsw_sp_sample_trigger *trigger);
635 int mlxsw_sp_ipv6_addr_kvdl_index_get(struct mlxsw_sp *mlxsw_sp,
636 const struct in6_addr *addr6,
639 mlxsw_sp_ipv6_addr_put(struct mlxsw_sp *mlxsw_sp, const struct in6_addr *addr6);
641 extern const struct mlxsw_sp_sb_vals mlxsw_sp1_sb_vals;
642 extern const struct mlxsw_sp_sb_vals mlxsw_sp2_sb_vals;
644 extern const struct mlxsw_sp_sb_ops mlxsw_sp1_sb_ops;
645 extern const struct mlxsw_sp_sb_ops mlxsw_sp2_sb_ops;
646 extern const struct mlxsw_sp_sb_ops mlxsw_sp3_sb_ops;
648 /* spectrum_switchdev.c */
649 int mlxsw_sp_switchdev_init(struct mlxsw_sp *mlxsw_sp);
650 void mlxsw_sp_switchdev_fini(struct mlxsw_sp *mlxsw_sp);
651 int mlxsw_sp_rif_fdb_op(struct mlxsw_sp *mlxsw_sp, const char *mac, u16 fid,
654 mlxsw_sp_port_vlan_bridge_leave(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan);
655 int mlxsw_sp_port_bridge_join(struct mlxsw_sp_port *mlxsw_sp_port,
656 struct net_device *brport_dev,
657 struct net_device *br_dev,
658 struct netlink_ext_ack *extack);
659 void mlxsw_sp_port_bridge_leave(struct mlxsw_sp_port *mlxsw_sp_port,
660 struct net_device *brport_dev,
661 struct net_device *br_dev);
662 bool mlxsw_sp_bridge_device_is_offloaded(const struct mlxsw_sp *mlxsw_sp,
663 const struct net_device *br_dev);
664 int mlxsw_sp_bridge_vxlan_join(struct mlxsw_sp *mlxsw_sp,
665 const struct net_device *br_dev,
666 const struct net_device *vxlan_dev, u16 vid,
667 struct netlink_ext_ack *extack);
668 void mlxsw_sp_bridge_vxlan_leave(struct mlxsw_sp *mlxsw_sp,
669 const struct net_device *vxlan_dev);
670 extern struct notifier_block mlxsw_sp_switchdev_notifier;
673 void mlxsw_sp_rx_listener_no_mark_func(struct sk_buff *skb,
674 u16 local_port, void *priv);
675 void mlxsw_sp_ptp_receive(struct mlxsw_sp *mlxsw_sp, struct sk_buff *skb,
677 int mlxsw_sp_port_speed_get(struct mlxsw_sp_port *mlxsw_sp_port, u32 *speed);
678 int mlxsw_sp_port_ets_set(struct mlxsw_sp_port *mlxsw_sp_port,
679 enum mlxsw_reg_qeec_hr hr, u8 index, u8 next_index,
680 bool dwrr, u8 dwrr_weight);
681 int mlxsw_sp_port_prio_tc_set(struct mlxsw_sp_port *mlxsw_sp_port,
682 u8 switch_prio, u8 tclass);
683 int mlxsw_sp_port_ets_maxrate_set(struct mlxsw_sp_port *mlxsw_sp_port,
684 enum mlxsw_reg_qeec_hr hr, u8 index,
685 u8 next_index, u32 maxrate, u8 burst_size);
686 enum mlxsw_reg_spms_state mlxsw_sp_stp_spms_state(u8 stp_state);
687 int mlxsw_sp_port_vid_stp_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid,
689 int mlxsw_sp_port_vp_mode_set(struct mlxsw_sp_port *mlxsw_sp_port, bool enable);
690 int mlxsw_sp_port_vid_learning_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid,
692 int mlxsw_sp_port_security_set(struct mlxsw_sp_port *mlxsw_sp_port,
694 int mlxsw_sp_ethtype_to_sver_type(u16 ethtype, u8 *p_sver_type);
695 int mlxsw_sp_port_egress_ethtype_set(struct mlxsw_sp_port *mlxsw_sp_port,
697 int mlxsw_sp_port_pvid_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid,
699 struct mlxsw_sp_port_vlan *
700 mlxsw_sp_port_vlan_create(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid);
701 void mlxsw_sp_port_vlan_destroy(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan);
702 int mlxsw_sp_port_vlan_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid_begin,
703 u16 vid_end, bool is_member, bool untagged);
704 int mlxsw_sp_flow_counter_get(struct mlxsw_sp *mlxsw_sp,
705 unsigned int counter_index, u64 *packets,
707 int mlxsw_sp_flow_counter_alloc(struct mlxsw_sp *mlxsw_sp,
708 unsigned int *p_counter_index);
709 void mlxsw_sp_flow_counter_free(struct mlxsw_sp *mlxsw_sp,
710 unsigned int counter_index);
711 void mlxsw_sp_txhdr_construct(struct sk_buff *skb,
712 const struct mlxsw_tx_info *tx_info);
713 int mlxsw_sp_txhdr_ptp_data_construct(struct mlxsw_core *mlxsw_core,
714 struct mlxsw_sp_port *mlxsw_sp_port,
716 const struct mlxsw_tx_info *tx_info);
717 bool mlxsw_sp_port_dev_check(const struct net_device *dev);
718 struct mlxsw_sp *mlxsw_sp_lower_get(struct net_device *dev);
719 struct mlxsw_sp_port *mlxsw_sp_port_dev_lower_find(struct net_device *dev);
720 struct mlxsw_sp_port *mlxsw_sp_port_lower_dev_hold(struct net_device *dev);
721 void mlxsw_sp_port_dev_put(struct mlxsw_sp_port *mlxsw_sp_port);
722 struct mlxsw_sp_port *mlxsw_sp_port_dev_lower_find_rcu(struct net_device *dev);
723 int mlxsw_sp_parsing_depth_inc(struct mlxsw_sp *mlxsw_sp);
724 void mlxsw_sp_parsing_depth_dec(struct mlxsw_sp *mlxsw_sp);
725 int mlxsw_sp_parsing_vxlan_udp_dport_set(struct mlxsw_sp *mlxsw_sp,
729 #ifdef CONFIG_MLXSW_SPECTRUM_DCB
730 int mlxsw_sp_port_dcb_init(struct mlxsw_sp_port *mlxsw_sp_port);
731 void mlxsw_sp_port_dcb_fini(struct mlxsw_sp_port *mlxsw_sp_port);
733 static inline int mlxsw_sp_port_dcb_init(struct mlxsw_sp_port *mlxsw_sp_port)
737 static inline void mlxsw_sp_port_dcb_fini(struct mlxsw_sp_port *mlxsw_sp_port)
741 /* spectrum_router.c */
742 enum mlxsw_sp_l3proto {
743 MLXSW_SP_L3_PROTO_IPV4,
744 MLXSW_SP_L3_PROTO_IPV6,
745 #define MLXSW_SP_L3_PROTO_MAX (MLXSW_SP_L3_PROTO_IPV6 + 1)
748 union mlxsw_sp_l3addr {
750 struct in6_addr addr6;
753 u16 mlxsw_sp_rif_index(const struct mlxsw_sp_rif *rif);
754 int mlxsw_sp_router_init(struct mlxsw_sp *mlxsw_sp,
755 struct netlink_ext_ack *extack);
756 void mlxsw_sp_router_fini(struct mlxsw_sp *mlxsw_sp);
757 void mlxsw_sp_rif_macvlan_del(struct mlxsw_sp *mlxsw_sp,
758 const struct net_device *macvlan_dev);
760 mlxsw_sp_port_vlan_router_leave(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan);
761 void mlxsw_sp_rif_destroy_by_dev(struct mlxsw_sp *mlxsw_sp,
762 struct net_device *dev);
763 bool mlxsw_sp_rif_exists(struct mlxsw_sp *mlxsw_sp,
764 const struct net_device *dev);
765 u16 mlxsw_sp_rif_vid(struct mlxsw_sp *mlxsw_sp, const struct net_device *dev);
766 u16 mlxsw_sp_router_port(const struct mlxsw_sp *mlxsw_sp);
767 int mlxsw_sp_router_nve_promote_decap(struct mlxsw_sp *mlxsw_sp, u32 ul_tb_id,
768 enum mlxsw_sp_l3proto ul_proto,
769 const union mlxsw_sp_l3addr *ul_sip,
771 void mlxsw_sp_router_nve_demote_decap(struct mlxsw_sp *mlxsw_sp, u32 ul_tb_id,
772 enum mlxsw_sp_l3proto ul_proto,
773 const union mlxsw_sp_l3addr *ul_sip);
774 int mlxsw_sp_router_tb_id_vr_id(struct mlxsw_sp *mlxsw_sp, u32 tb_id,
776 int mlxsw_sp_router_ul_rif_get(struct mlxsw_sp *mlxsw_sp, u32 ul_tb_id,
778 void mlxsw_sp_router_ul_rif_put(struct mlxsw_sp *mlxsw_sp, u16 ul_rif_index);
780 /* spectrum_kvdl.c */
781 enum mlxsw_sp_kvdl_entry_type {
782 MLXSW_SP_KVDL_ENTRY_TYPE_ADJ,
783 MLXSW_SP_KVDL_ENTRY_TYPE_ACTSET,
784 MLXSW_SP_KVDL_ENTRY_TYPE_PBS,
785 MLXSW_SP_KVDL_ENTRY_TYPE_MCRIGR,
786 MLXSW_SP_KVDL_ENTRY_TYPE_IPV6_ADDRESS,
787 MLXSW_SP_KVDL_ENTRY_TYPE_TNUMT,
790 static inline unsigned int
791 mlxsw_sp_kvdl_entry_size(enum mlxsw_sp_kvdl_entry_type type)
794 case MLXSW_SP_KVDL_ENTRY_TYPE_ADJ:
795 case MLXSW_SP_KVDL_ENTRY_TYPE_ACTSET:
796 case MLXSW_SP_KVDL_ENTRY_TYPE_PBS:
797 case MLXSW_SP_KVDL_ENTRY_TYPE_MCRIGR:
798 case MLXSW_SP_KVDL_ENTRY_TYPE_IPV6_ADDRESS:
799 case MLXSW_SP_KVDL_ENTRY_TYPE_TNUMT:
805 struct mlxsw_sp_kvdl_ops {
807 int (*init)(struct mlxsw_sp *mlxsw_sp, void *priv);
808 void (*fini)(struct mlxsw_sp *mlxsw_sp, void *priv);
809 int (*alloc)(struct mlxsw_sp *mlxsw_sp, void *priv,
810 enum mlxsw_sp_kvdl_entry_type type,
811 unsigned int entry_count, u32 *p_entry_index);
812 void (*free)(struct mlxsw_sp *mlxsw_sp, void *priv,
813 enum mlxsw_sp_kvdl_entry_type type,
814 unsigned int entry_count, int entry_index);
815 int (*alloc_size_query)(struct mlxsw_sp *mlxsw_sp, void *priv,
816 enum mlxsw_sp_kvdl_entry_type type,
817 unsigned int entry_count,
818 unsigned int *p_alloc_count);
819 int (*resources_register)(struct mlxsw_sp *mlxsw_sp, void *priv);
822 int mlxsw_sp_kvdl_init(struct mlxsw_sp *mlxsw_sp);
823 void mlxsw_sp_kvdl_fini(struct mlxsw_sp *mlxsw_sp);
824 int mlxsw_sp_kvdl_alloc(struct mlxsw_sp *mlxsw_sp,
825 enum mlxsw_sp_kvdl_entry_type type,
826 unsigned int entry_count, u32 *p_entry_index);
827 void mlxsw_sp_kvdl_free(struct mlxsw_sp *mlxsw_sp,
828 enum mlxsw_sp_kvdl_entry_type type,
829 unsigned int entry_count, int entry_index);
830 int mlxsw_sp_kvdl_alloc_count_query(struct mlxsw_sp *mlxsw_sp,
831 enum mlxsw_sp_kvdl_entry_type type,
832 unsigned int entry_count,
833 unsigned int *p_alloc_count);
835 /* spectrum1_kvdl.c */
836 extern const struct mlxsw_sp_kvdl_ops mlxsw_sp1_kvdl_ops;
837 int mlxsw_sp1_kvdl_resources_register(struct mlxsw_core *mlxsw_core);
839 /* spectrum2_kvdl.c */
840 extern const struct mlxsw_sp_kvdl_ops mlxsw_sp2_kvdl_ops;
842 enum mlxsw_sp_acl_mangle_field {
843 MLXSW_SP_ACL_MANGLE_FIELD_IP_DSFIELD,
844 MLXSW_SP_ACL_MANGLE_FIELD_IP_DSCP,
845 MLXSW_SP_ACL_MANGLE_FIELD_IP_ECN,
846 MLXSW_SP_ACL_MANGLE_FIELD_IP_SPORT,
847 MLXSW_SP_ACL_MANGLE_FIELD_IP_DPORT,
848 MLXSW_SP_ACL_MANGLE_FIELD_IP4_SIP,
849 MLXSW_SP_ACL_MANGLE_FIELD_IP4_DIP,
850 MLXSW_SP_ACL_MANGLE_FIELD_IP6_SIP_1,
851 MLXSW_SP_ACL_MANGLE_FIELD_IP6_SIP_2,
852 MLXSW_SP_ACL_MANGLE_FIELD_IP6_SIP_3,
853 MLXSW_SP_ACL_MANGLE_FIELD_IP6_SIP_4,
854 MLXSW_SP_ACL_MANGLE_FIELD_IP6_DIP_1,
855 MLXSW_SP_ACL_MANGLE_FIELD_IP6_DIP_2,
856 MLXSW_SP_ACL_MANGLE_FIELD_IP6_DIP_3,
857 MLXSW_SP_ACL_MANGLE_FIELD_IP6_DIP_4,
860 struct mlxsw_sp_acl_rule_info {
861 unsigned int priority;
862 struct mlxsw_afk_element_values values;
863 struct mlxsw_afa_block *act_block;
865 ingress_bind_blocker:1,
866 egress_bind_blocker:1,
868 policer_index_valid:1,
870 unsigned int counter_index;
874 enum mlxsw_sp_acl_mangle_field prev_field;
878 /* spectrum_flow.c */
879 struct mlxsw_sp_flow_block {
880 struct list_head binding_list;
882 struct list_head list;
883 unsigned int min_prio;
884 unsigned int max_prio;
886 struct mlxsw_sp_acl_ruleset *ruleset_zero;
887 struct mlxsw_sp *mlxsw_sp;
888 unsigned int rule_count;
889 unsigned int disable_count;
890 unsigned int ingress_blocker_rule_count;
891 unsigned int egress_blocker_rule_count;
892 unsigned int ingress_binding_count;
893 unsigned int egress_binding_count;
897 struct mlxsw_sp_flow_block_binding {
898 struct list_head list;
899 struct mlxsw_sp_port *mlxsw_sp_port;
903 static inline struct mlxsw_sp *
904 mlxsw_sp_flow_block_mlxsw_sp(struct mlxsw_sp_flow_block *block)
906 return block->mlxsw_sp;
909 static inline unsigned int
910 mlxsw_sp_flow_block_rule_count(const struct mlxsw_sp_flow_block *block)
912 return block ? block->rule_count : 0;
916 mlxsw_sp_flow_block_disable_inc(struct mlxsw_sp_flow_block *block)
919 block->disable_count++;
923 mlxsw_sp_flow_block_disable_dec(struct mlxsw_sp_flow_block *block)
926 block->disable_count--;
930 mlxsw_sp_flow_block_disabled(const struct mlxsw_sp_flow_block *block)
932 return block->disable_count;
936 mlxsw_sp_flow_block_is_egress_bound(const struct mlxsw_sp_flow_block *block)
938 return block->egress_binding_count;
942 mlxsw_sp_flow_block_is_ingress_bound(const struct mlxsw_sp_flow_block *block)
944 return block->ingress_binding_count;
948 mlxsw_sp_flow_block_is_mixed_bound(const struct mlxsw_sp_flow_block *block)
950 return block->ingress_binding_count && block->egress_binding_count;
953 struct mlxsw_sp_flow_block *mlxsw_sp_flow_block_create(struct mlxsw_sp *mlxsw_sp,
955 void mlxsw_sp_flow_block_destroy(struct mlxsw_sp_flow_block *block);
956 int mlxsw_sp_setup_tc_block_clsact(struct mlxsw_sp_port *mlxsw_sp_port,
957 struct flow_block_offload *f,
961 struct mlxsw_sp_acl_ruleset;
963 enum mlxsw_sp_acl_profile {
964 MLXSW_SP_ACL_PROFILE_FLOWER,
965 MLXSW_SP_ACL_PROFILE_MR,
968 struct mlxsw_afk *mlxsw_sp_acl_afk(struct mlxsw_sp_acl *acl);
969 struct mlxsw_sp_acl_tcam *mlxsw_sp_acl_to_tcam(struct mlxsw_sp_acl *acl);
971 int mlxsw_sp_acl_ruleset_bind(struct mlxsw_sp *mlxsw_sp,
972 struct mlxsw_sp_flow_block *block,
973 struct mlxsw_sp_flow_block_binding *binding);
974 void mlxsw_sp_acl_ruleset_unbind(struct mlxsw_sp *mlxsw_sp,
975 struct mlxsw_sp_flow_block *block,
976 struct mlxsw_sp_flow_block_binding *binding);
977 struct mlxsw_sp_acl_ruleset *
978 mlxsw_sp_acl_ruleset_lookup(struct mlxsw_sp *mlxsw_sp,
979 struct mlxsw_sp_flow_block *block, u32 chain_index,
980 enum mlxsw_sp_acl_profile profile);
981 struct mlxsw_sp_acl_ruleset *
982 mlxsw_sp_acl_ruleset_get(struct mlxsw_sp *mlxsw_sp,
983 struct mlxsw_sp_flow_block *block, u32 chain_index,
984 enum mlxsw_sp_acl_profile profile,
985 struct mlxsw_afk_element_usage *tmplt_elusage);
986 void mlxsw_sp_acl_ruleset_put(struct mlxsw_sp *mlxsw_sp,
987 struct mlxsw_sp_acl_ruleset *ruleset);
988 u16 mlxsw_sp_acl_ruleset_group_id(struct mlxsw_sp_acl_ruleset *ruleset);
989 void mlxsw_sp_acl_ruleset_prio_get(struct mlxsw_sp_acl_ruleset *ruleset,
990 unsigned int *p_min_prio,
991 unsigned int *p_max_prio);
993 struct mlxsw_sp_acl_rule_info *
994 mlxsw_sp_acl_rulei_create(struct mlxsw_sp_acl *acl,
995 struct mlxsw_afa_block *afa_block);
996 void mlxsw_sp_acl_rulei_destroy(struct mlxsw_sp_acl_rule_info *rulei);
997 int mlxsw_sp_acl_rulei_commit(struct mlxsw_sp_acl_rule_info *rulei);
998 void mlxsw_sp_acl_rulei_priority(struct mlxsw_sp_acl_rule_info *rulei,
999 unsigned int priority);
1000 void mlxsw_sp_acl_rulei_keymask_u32(struct mlxsw_sp_acl_rule_info *rulei,
1001 enum mlxsw_afk_element element,
1002 u32 key_value, u32 mask_value);
1003 void mlxsw_sp_acl_rulei_keymask_buf(struct mlxsw_sp_acl_rule_info *rulei,
1004 enum mlxsw_afk_element element,
1005 const char *key_value,
1006 const char *mask_value, unsigned int len);
1007 int mlxsw_sp_acl_rulei_act_continue(struct mlxsw_sp_acl_rule_info *rulei);
1008 int mlxsw_sp_acl_rulei_act_jump(struct mlxsw_sp_acl_rule_info *rulei,
1010 int mlxsw_sp_acl_rulei_act_terminate(struct mlxsw_sp_acl_rule_info *rulei);
1011 int mlxsw_sp_acl_rulei_act_drop(struct mlxsw_sp_acl_rule_info *rulei,
1013 const struct flow_action_cookie *fa_cookie,
1014 struct netlink_ext_ack *extack);
1015 int mlxsw_sp_acl_rulei_act_trap(struct mlxsw_sp_acl_rule_info *rulei);
1016 int mlxsw_sp_acl_rulei_act_mirror(struct mlxsw_sp *mlxsw_sp,
1017 struct mlxsw_sp_acl_rule_info *rulei,
1018 struct mlxsw_sp_flow_block *block,
1019 struct net_device *out_dev,
1020 struct netlink_ext_ack *extack);
1021 int mlxsw_sp_acl_rulei_act_fwd(struct mlxsw_sp *mlxsw_sp,
1022 struct mlxsw_sp_acl_rule_info *rulei,
1023 struct net_device *out_dev,
1024 struct netlink_ext_ack *extack);
1025 int mlxsw_sp_acl_rulei_act_vlan(struct mlxsw_sp *mlxsw_sp,
1026 struct mlxsw_sp_acl_rule_info *rulei,
1027 u32 action, u16 vid, u16 proto, u8 prio,
1028 struct netlink_ext_ack *extack);
1029 int mlxsw_sp_acl_rulei_act_priority(struct mlxsw_sp *mlxsw_sp,
1030 struct mlxsw_sp_acl_rule_info *rulei,
1031 u32 prio, struct netlink_ext_ack *extack);
1032 int mlxsw_sp_acl_rulei_act_mangle(struct mlxsw_sp *mlxsw_sp,
1033 struct mlxsw_sp_acl_rule_info *rulei,
1034 enum flow_action_mangle_base htype,
1035 u32 offset, u32 mask, u32 val,
1036 struct netlink_ext_ack *extack);
1037 int mlxsw_sp_acl_rulei_act_police(struct mlxsw_sp *mlxsw_sp,
1038 struct mlxsw_sp_acl_rule_info *rulei,
1039 u32 index, u64 rate_bytes_ps,
1040 u32 burst, struct netlink_ext_ack *extack);
1041 int mlxsw_sp_acl_rulei_act_count(struct mlxsw_sp *mlxsw_sp,
1042 struct mlxsw_sp_acl_rule_info *rulei,
1043 struct netlink_ext_ack *extack);
1044 int mlxsw_sp_acl_rulei_act_fid_set(struct mlxsw_sp *mlxsw_sp,
1045 struct mlxsw_sp_acl_rule_info *rulei,
1046 u16 fid, struct netlink_ext_ack *extack);
1047 int mlxsw_sp_acl_rulei_act_sample(struct mlxsw_sp *mlxsw_sp,
1048 struct mlxsw_sp_acl_rule_info *rulei,
1049 struct mlxsw_sp_flow_block *block,
1050 struct psample_group *psample_group, u32 rate,
1051 u32 trunc_size, bool truncate,
1052 struct netlink_ext_ack *extack);
1054 struct mlxsw_sp_acl_rule;
1056 struct mlxsw_sp_acl_rule *
1057 mlxsw_sp_acl_rule_create(struct mlxsw_sp *mlxsw_sp,
1058 struct mlxsw_sp_acl_ruleset *ruleset,
1059 unsigned long cookie,
1060 struct mlxsw_afa_block *afa_block,
1061 struct netlink_ext_ack *extack);
1062 void mlxsw_sp_acl_rule_destroy(struct mlxsw_sp *mlxsw_sp,
1063 struct mlxsw_sp_acl_rule *rule);
1064 int mlxsw_sp_acl_rule_add(struct mlxsw_sp *mlxsw_sp,
1065 struct mlxsw_sp_acl_rule *rule);
1066 void mlxsw_sp_acl_rule_del(struct mlxsw_sp *mlxsw_sp,
1067 struct mlxsw_sp_acl_rule *rule);
1068 int mlxsw_sp_acl_rule_action_replace(struct mlxsw_sp *mlxsw_sp,
1069 struct mlxsw_sp_acl_rule *rule,
1070 struct mlxsw_afa_block *afa_block);
1071 struct mlxsw_sp_acl_rule *
1072 mlxsw_sp_acl_rule_lookup(struct mlxsw_sp *mlxsw_sp,
1073 struct mlxsw_sp_acl_ruleset *ruleset,
1074 unsigned long cookie);
1075 struct mlxsw_sp_acl_rule_info *
1076 mlxsw_sp_acl_rule_rulei(struct mlxsw_sp_acl_rule *rule);
1077 int mlxsw_sp_acl_rule_get_stats(struct mlxsw_sp *mlxsw_sp,
1078 struct mlxsw_sp_acl_rule *rule,
1079 u64 *packets, u64 *bytes, u64 *drops,
1081 enum flow_action_hw_stats *used_hw_stats);
1083 struct mlxsw_sp_fid *mlxsw_sp_acl_dummy_fid(struct mlxsw_sp *mlxsw_sp);
1085 static inline const struct flow_action_cookie *
1086 mlxsw_sp_acl_act_cookie_lookup(struct mlxsw_sp *mlxsw_sp, u32 cookie_index)
1088 return mlxsw_afa_cookie_lookup(mlxsw_sp->afa, cookie_index);
1091 int mlxsw_sp_acl_init(struct mlxsw_sp *mlxsw_sp);
1092 void mlxsw_sp_acl_fini(struct mlxsw_sp *mlxsw_sp);
1094 struct mlxsw_sp_acl_mangle_action;
1096 struct mlxsw_sp_acl_rulei_ops {
1097 int (*act_mangle_field)(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_acl_rule_info *rulei,
1098 struct mlxsw_sp_acl_mangle_action *mact, u32 val,
1099 struct netlink_ext_ack *extack);
1102 extern struct mlxsw_sp_acl_rulei_ops mlxsw_sp1_acl_rulei_ops;
1103 extern struct mlxsw_sp_acl_rulei_ops mlxsw_sp2_acl_rulei_ops;
1105 /* spectrum_acl_tcam.c */
1106 struct mlxsw_sp_acl_tcam;
1107 struct mlxsw_sp_acl_tcam_region;
1109 struct mlxsw_sp_acl_tcam_ops {
1110 enum mlxsw_reg_ptar_key_type key_type;
1112 int (*init)(struct mlxsw_sp *mlxsw_sp, void *priv,
1113 struct mlxsw_sp_acl_tcam *tcam);
1114 void (*fini)(struct mlxsw_sp *mlxsw_sp, void *priv);
1115 size_t region_priv_size;
1116 int (*region_init)(struct mlxsw_sp *mlxsw_sp, void *region_priv,
1118 struct mlxsw_sp_acl_tcam_region *region,
1120 void (*region_fini)(struct mlxsw_sp *mlxsw_sp, void *region_priv);
1121 int (*region_associate)(struct mlxsw_sp *mlxsw_sp,
1122 struct mlxsw_sp_acl_tcam_region *region);
1123 void * (*region_rehash_hints_get)(void *region_priv);
1124 void (*region_rehash_hints_put)(void *hints_priv);
1125 size_t chunk_priv_size;
1126 void (*chunk_init)(void *region_priv, void *chunk_priv,
1127 unsigned int priority);
1128 void (*chunk_fini)(void *chunk_priv);
1129 size_t entry_priv_size;
1130 int (*entry_add)(struct mlxsw_sp *mlxsw_sp,
1131 void *region_priv, void *chunk_priv,
1133 struct mlxsw_sp_acl_rule_info *rulei);
1134 void (*entry_del)(struct mlxsw_sp *mlxsw_sp,
1135 void *region_priv, void *chunk_priv,
1137 int (*entry_action_replace)(struct mlxsw_sp *mlxsw_sp,
1138 void *region_priv, void *entry_priv,
1139 struct mlxsw_sp_acl_rule_info *rulei);
1140 int (*entry_activity_get)(struct mlxsw_sp *mlxsw_sp,
1141 void *region_priv, void *entry_priv,
1145 /* spectrum1_acl_tcam.c */
1146 extern const struct mlxsw_sp_acl_tcam_ops mlxsw_sp1_acl_tcam_ops;
1148 /* spectrum2_acl_tcam.c */
1149 extern const struct mlxsw_sp_acl_tcam_ops mlxsw_sp2_acl_tcam_ops;
1151 /* spectrum_acl_flex_actions.c */
1152 extern const struct mlxsw_afa_ops mlxsw_sp1_act_afa_ops;
1153 extern const struct mlxsw_afa_ops mlxsw_sp2_act_afa_ops;
1155 /* spectrum_acl_flex_keys.c */
1156 extern const struct mlxsw_afk_ops mlxsw_sp1_afk_ops;
1157 extern const struct mlxsw_afk_ops mlxsw_sp2_afk_ops;
1158 extern const struct mlxsw_afk_ops mlxsw_sp4_afk_ops;
1160 /* spectrum_acl_bloom_filter.c */
1161 extern const struct mlxsw_sp_acl_bf_ops mlxsw_sp2_acl_bf_ops;
1162 extern const struct mlxsw_sp_acl_bf_ops mlxsw_sp4_acl_bf_ops;
1164 /* spectrum_matchall.c */
1165 struct mlxsw_sp_mall_ops {
1166 int (*sample_add)(struct mlxsw_sp *mlxsw_sp,
1167 struct mlxsw_sp_port *mlxsw_sp_port,
1168 struct mlxsw_sp_mall_entry *mall_entry,
1169 struct netlink_ext_ack *extack);
1170 void (*sample_del)(struct mlxsw_sp *mlxsw_sp,
1171 struct mlxsw_sp_port *mlxsw_sp_port,
1172 struct mlxsw_sp_mall_entry *mall_entry);
1175 extern const struct mlxsw_sp_mall_ops mlxsw_sp1_mall_ops;
1176 extern const struct mlxsw_sp_mall_ops mlxsw_sp2_mall_ops;
1178 enum mlxsw_sp_mall_action_type {
1179 MLXSW_SP_MALL_ACTION_TYPE_MIRROR,
1180 MLXSW_SP_MALL_ACTION_TYPE_SAMPLE,
1181 MLXSW_SP_MALL_ACTION_TYPE_TRAP,
1184 struct mlxsw_sp_mall_mirror_entry {
1185 const struct net_device *to_dev;
1189 struct mlxsw_sp_mall_trap_entry {
1193 struct mlxsw_sp_mall_sample_entry {
1194 struct mlxsw_sp_sample_params params;
1195 int span_id; /* Relevant for Spectrum-2 onwards. */
1198 struct mlxsw_sp_mall_entry {
1199 struct list_head list;
1200 unsigned long cookie;
1201 unsigned int priority;
1202 enum mlxsw_sp_mall_action_type type;
1205 struct mlxsw_sp_mall_mirror_entry mirror;
1206 struct mlxsw_sp_mall_trap_entry trap;
1207 struct mlxsw_sp_mall_sample_entry sample;
1209 struct rcu_head rcu;
1212 int mlxsw_sp_mall_replace(struct mlxsw_sp *mlxsw_sp,
1213 struct mlxsw_sp_flow_block *block,
1214 struct tc_cls_matchall_offload *f);
1215 void mlxsw_sp_mall_destroy(struct mlxsw_sp_flow_block *block,
1216 struct tc_cls_matchall_offload *f);
1217 int mlxsw_sp_mall_port_bind(struct mlxsw_sp_flow_block *block,
1218 struct mlxsw_sp_port *mlxsw_sp_port,
1219 struct netlink_ext_ack *extack);
1220 void mlxsw_sp_mall_port_unbind(struct mlxsw_sp_flow_block *block,
1221 struct mlxsw_sp_port *mlxsw_sp_port);
1222 int mlxsw_sp_mall_prio_get(struct mlxsw_sp_flow_block *block, u32 chain_index,
1223 unsigned int *p_min_prio, unsigned int *p_max_prio);
1225 /* spectrum_flower.c */
1226 int mlxsw_sp_flower_replace(struct mlxsw_sp *mlxsw_sp,
1227 struct mlxsw_sp_flow_block *block,
1228 struct flow_cls_offload *f);
1229 void mlxsw_sp_flower_destroy(struct mlxsw_sp *mlxsw_sp,
1230 struct mlxsw_sp_flow_block *block,
1231 struct flow_cls_offload *f);
1232 int mlxsw_sp_flower_stats(struct mlxsw_sp *mlxsw_sp,
1233 struct mlxsw_sp_flow_block *block,
1234 struct flow_cls_offload *f);
1235 int mlxsw_sp_flower_tmplt_create(struct mlxsw_sp *mlxsw_sp,
1236 struct mlxsw_sp_flow_block *block,
1237 struct flow_cls_offload *f);
1238 void mlxsw_sp_flower_tmplt_destroy(struct mlxsw_sp *mlxsw_sp,
1239 struct mlxsw_sp_flow_block *block,
1240 struct flow_cls_offload *f);
1241 int mlxsw_sp_flower_prio_get(struct mlxsw_sp *mlxsw_sp,
1242 struct mlxsw_sp_flow_block *block,
1243 u32 chain_index, unsigned int *p_min_prio,
1244 unsigned int *p_max_prio);
1246 /* spectrum_qdisc.c */
1247 int mlxsw_sp_tc_qdisc_init(struct mlxsw_sp_port *mlxsw_sp_port);
1248 void mlxsw_sp_tc_qdisc_fini(struct mlxsw_sp_port *mlxsw_sp_port);
1249 int mlxsw_sp_setup_tc_red(struct mlxsw_sp_port *mlxsw_sp_port,
1250 struct tc_red_qopt_offload *p);
1251 int mlxsw_sp_setup_tc_prio(struct mlxsw_sp_port *mlxsw_sp_port,
1252 struct tc_prio_qopt_offload *p);
1253 int mlxsw_sp_setup_tc_ets(struct mlxsw_sp_port *mlxsw_sp_port,
1254 struct tc_ets_qopt_offload *p);
1255 int mlxsw_sp_setup_tc_tbf(struct mlxsw_sp_port *mlxsw_sp_port,
1256 struct tc_tbf_qopt_offload *p);
1257 int mlxsw_sp_setup_tc_fifo(struct mlxsw_sp_port *mlxsw_sp_port,
1258 struct tc_fifo_qopt_offload *p);
1259 int mlxsw_sp_setup_tc_block_qevent_early_drop(struct mlxsw_sp_port *mlxsw_sp_port,
1260 struct flow_block_offload *f);
1261 int mlxsw_sp_setup_tc_block_qevent_mark(struct mlxsw_sp_port *mlxsw_sp_port,
1262 struct flow_block_offload *f);
1264 /* spectrum_fid.c */
1265 bool mlxsw_sp_fid_is_dummy(struct mlxsw_sp *mlxsw_sp, u16 fid_index);
1266 struct mlxsw_sp_fid *mlxsw_sp_fid_lookup_by_index(struct mlxsw_sp *mlxsw_sp,
1268 int mlxsw_sp_fid_nve_ifindex(const struct mlxsw_sp_fid *fid, int *nve_ifindex);
1269 int mlxsw_sp_fid_nve_type(const struct mlxsw_sp_fid *fid,
1270 enum mlxsw_sp_nve_type *p_type);
1271 struct mlxsw_sp_fid *mlxsw_sp_fid_lookup_by_vni(struct mlxsw_sp *mlxsw_sp,
1273 int mlxsw_sp_fid_vni(const struct mlxsw_sp_fid *fid, __be32 *vni);
1274 int mlxsw_sp_fid_nve_flood_index_set(struct mlxsw_sp_fid *fid,
1275 u32 nve_flood_index);
1276 void mlxsw_sp_fid_nve_flood_index_clear(struct mlxsw_sp_fid *fid);
1277 bool mlxsw_sp_fid_nve_flood_index_is_set(const struct mlxsw_sp_fid *fid);
1278 int mlxsw_sp_fid_vni_set(struct mlxsw_sp_fid *fid, enum mlxsw_sp_nve_type type,
1279 __be32 vni, int nve_ifindex);
1280 void mlxsw_sp_fid_vni_clear(struct mlxsw_sp_fid *fid);
1281 bool mlxsw_sp_fid_vni_is_set(const struct mlxsw_sp_fid *fid);
1282 void mlxsw_sp_fid_fdb_clear_offload(const struct mlxsw_sp_fid *fid,
1283 const struct net_device *nve_dev);
1284 int mlxsw_sp_fid_flood_set(struct mlxsw_sp_fid *fid,
1285 enum mlxsw_sp_flood_type packet_type, u16 local_port,
1287 int mlxsw_sp_fid_port_vid_map(struct mlxsw_sp_fid *fid,
1288 struct mlxsw_sp_port *mlxsw_sp_port, u16 vid);
1289 void mlxsw_sp_fid_port_vid_unmap(struct mlxsw_sp_fid *fid,
1290 struct mlxsw_sp_port *mlxsw_sp_port, u16 vid);
1291 u16 mlxsw_sp_fid_index(const struct mlxsw_sp_fid *fid);
1292 enum mlxsw_sp_fid_type mlxsw_sp_fid_type(const struct mlxsw_sp_fid *fid);
1293 int mlxsw_sp_fid_rif_set(struct mlxsw_sp_fid *fid, struct mlxsw_sp_rif *rif);
1294 void mlxsw_sp_fid_rif_unset(struct mlxsw_sp_fid *fid);
1295 struct mlxsw_sp_rif *mlxsw_sp_fid_rif(const struct mlxsw_sp_fid *fid);
1296 enum mlxsw_sp_rif_type
1297 mlxsw_sp_fid_type_rif_type(const struct mlxsw_sp *mlxsw_sp,
1298 enum mlxsw_sp_fid_type type);
1299 u16 mlxsw_sp_fid_8021q_vid(const struct mlxsw_sp_fid *fid);
1300 struct mlxsw_sp_fid *mlxsw_sp_fid_8021q_get(struct mlxsw_sp *mlxsw_sp, u16 vid);
1301 struct mlxsw_sp_fid *mlxsw_sp_fid_8021d_get(struct mlxsw_sp *mlxsw_sp,
1303 struct mlxsw_sp_fid *mlxsw_sp_fid_8021q_lookup(struct mlxsw_sp *mlxsw_sp,
1305 struct mlxsw_sp_fid *mlxsw_sp_fid_8021d_lookup(struct mlxsw_sp *mlxsw_sp,
1307 struct mlxsw_sp_fid *mlxsw_sp_fid_rfid_get(struct mlxsw_sp *mlxsw_sp,
1309 struct mlxsw_sp_fid *mlxsw_sp_fid_dummy_get(struct mlxsw_sp *mlxsw_sp);
1310 void mlxsw_sp_fid_put(struct mlxsw_sp_fid *fid);
1311 int mlxsw_sp_port_fids_init(struct mlxsw_sp_port *mlxsw_sp_port);
1312 void mlxsw_sp_port_fids_fini(struct mlxsw_sp_port *mlxsw_sp_port);
1313 int mlxsw_sp_fids_init(struct mlxsw_sp *mlxsw_sp);
1314 void mlxsw_sp_fids_fini(struct mlxsw_sp *mlxsw_sp);
1316 extern const struct mlxsw_sp_fid_family *mlxsw_sp1_fid_family_arr[];
1317 extern const struct mlxsw_sp_fid_family *mlxsw_sp2_fid_family_arr[];
1320 enum mlxsw_sp_mr_route_prio {
1321 MLXSW_SP_MR_ROUTE_PRIO_SG,
1322 MLXSW_SP_MR_ROUTE_PRIO_STARG,
1323 MLXSW_SP_MR_ROUTE_PRIO_CATCHALL,
1324 __MLXSW_SP_MR_ROUTE_PRIO_MAX
1327 #define MLXSW_SP_MR_ROUTE_PRIO_MAX (__MLXSW_SP_MR_ROUTE_PRIO_MAX - 1)
1329 struct mlxsw_sp_mr_route_key;
1331 struct mlxsw_sp_mr_tcam_ops {
1333 int (*init)(struct mlxsw_sp *mlxsw_sp, void *priv);
1334 void (*fini)(void *priv);
1335 size_t route_priv_size;
1336 int (*route_create)(struct mlxsw_sp *mlxsw_sp, void *priv,
1338 struct mlxsw_sp_mr_route_key *key,
1339 struct mlxsw_afa_block *afa_block,
1340 enum mlxsw_sp_mr_route_prio prio);
1341 void (*route_destroy)(struct mlxsw_sp *mlxsw_sp, void *priv,
1343 struct mlxsw_sp_mr_route_key *key);
1344 int (*route_update)(struct mlxsw_sp *mlxsw_sp, void *route_priv,
1345 struct mlxsw_sp_mr_route_key *key,
1346 struct mlxsw_afa_block *afa_block);
1349 /* spectrum1_mr_tcam.c */
1350 extern const struct mlxsw_sp_mr_tcam_ops mlxsw_sp1_mr_tcam_ops;
1352 /* spectrum2_mr_tcam.c */
1353 extern const struct mlxsw_sp_mr_tcam_ops mlxsw_sp2_mr_tcam_ops;
1355 /* spectrum_nve.c */
1356 struct mlxsw_sp_nve_params {
1357 enum mlxsw_sp_nve_type type;
1359 const struct net_device *dev;
1363 extern const struct mlxsw_sp_nve_ops *mlxsw_sp1_nve_ops_arr[];
1364 extern const struct mlxsw_sp_nve_ops *mlxsw_sp2_nve_ops_arr[];
1366 int mlxsw_sp_nve_learned_ip_resolve(struct mlxsw_sp *mlxsw_sp, u32 uip,
1367 enum mlxsw_sp_l3proto proto,
1368 union mlxsw_sp_l3addr *addr);
1369 int mlxsw_sp_nve_flood_ip_add(struct mlxsw_sp *mlxsw_sp,
1370 struct mlxsw_sp_fid *fid,
1371 enum mlxsw_sp_l3proto proto,
1372 union mlxsw_sp_l3addr *addr);
1373 void mlxsw_sp_nve_flood_ip_del(struct mlxsw_sp *mlxsw_sp,
1374 struct mlxsw_sp_fid *fid,
1375 enum mlxsw_sp_l3proto proto,
1376 union mlxsw_sp_l3addr *addr);
1377 int mlxsw_sp_nve_ipv6_addr_kvdl_set(struct mlxsw_sp *mlxsw_sp,
1378 const struct in6_addr *addr6,
1380 void mlxsw_sp_nve_ipv6_addr_kvdl_unset(struct mlxsw_sp *mlxsw_sp,
1381 const struct in6_addr *addr6);
1383 mlxsw_sp_nve_ipv6_addr_map_replace(struct mlxsw_sp *mlxsw_sp, const char *mac,
1385 const struct in6_addr *new_addr6);
1386 void mlxsw_sp_nve_ipv6_addr_map_del(struct mlxsw_sp *mlxsw_sp, const char *mac,
1388 int mlxsw_sp_nve_fid_enable(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_fid *fid,
1389 struct mlxsw_sp_nve_params *params,
1390 struct netlink_ext_ack *extack);
1391 void mlxsw_sp_nve_fid_disable(struct mlxsw_sp *mlxsw_sp,
1392 struct mlxsw_sp_fid *fid);
1393 int mlxsw_sp_port_nve_init(struct mlxsw_sp_port *mlxsw_sp_port);
1394 void mlxsw_sp_port_nve_fini(struct mlxsw_sp_port *mlxsw_sp_port);
1395 int mlxsw_sp_nve_init(struct mlxsw_sp *mlxsw_sp);
1396 void mlxsw_sp_nve_fini(struct mlxsw_sp *mlxsw_sp);
1398 /* spectrum_nve_vxlan.c */
1399 int mlxsw_sp_nve_inc_parsing_depth_get(struct mlxsw_sp *mlxsw_sp);
1400 void mlxsw_sp_nve_inc_parsing_depth_put(struct mlxsw_sp *mlxsw_sp);
1402 /* spectrum_trap.c */
1403 int mlxsw_sp_devlink_traps_init(struct mlxsw_sp *mlxsw_sp);
1404 void mlxsw_sp_devlink_traps_fini(struct mlxsw_sp *mlxsw_sp);
1405 int mlxsw_sp_trap_init(struct mlxsw_core *mlxsw_core,
1406 const struct devlink_trap *trap, void *trap_ctx);
1407 void mlxsw_sp_trap_fini(struct mlxsw_core *mlxsw_core,
1408 const struct devlink_trap *trap, void *trap_ctx);
1409 int mlxsw_sp_trap_action_set(struct mlxsw_core *mlxsw_core,
1410 const struct devlink_trap *trap,
1411 enum devlink_trap_action action,
1412 struct netlink_ext_ack *extack);
1413 int mlxsw_sp_trap_group_init(struct mlxsw_core *mlxsw_core,
1414 const struct devlink_trap_group *group);
1415 int mlxsw_sp_trap_group_set(struct mlxsw_core *mlxsw_core,
1416 const struct devlink_trap_group *group,
1417 const struct devlink_trap_policer *policer,
1418 struct netlink_ext_ack *extack);
1420 mlxsw_sp_trap_policer_init(struct mlxsw_core *mlxsw_core,
1421 const struct devlink_trap_policer *policer);
1422 void mlxsw_sp_trap_policer_fini(struct mlxsw_core *mlxsw_core,
1423 const struct devlink_trap_policer *policer);
1425 mlxsw_sp_trap_policer_set(struct mlxsw_core *mlxsw_core,
1426 const struct devlink_trap_policer *policer,
1427 u64 rate, u64 burst, struct netlink_ext_ack *extack);
1429 mlxsw_sp_trap_policer_counter_get(struct mlxsw_core *mlxsw_core,
1430 const struct devlink_trap_policer *policer,
1432 int mlxsw_sp_trap_group_policer_hw_id_get(struct mlxsw_sp *mlxsw_sp, u16 id,
1433 bool *p_enabled, u16 *p_hw_id);
1435 static inline struct net *mlxsw_sp_net(struct mlxsw_sp *mlxsw_sp)
1437 return mlxsw_core_net(mlxsw_sp->core);
1440 /* spectrum_ethtool.c */
1441 extern const struct ethtool_ops mlxsw_sp_port_ethtool_ops;
1442 extern const struct mlxsw_sp_port_type_speed_ops mlxsw_sp1_port_type_speed_ops;
1443 extern const struct mlxsw_sp_port_type_speed_ops mlxsw_sp2_port_type_speed_ops;
1445 /* spectrum_policer.c */
1446 extern const struct mlxsw_sp_policer_core_ops mlxsw_sp1_policer_core_ops;
1447 extern const struct mlxsw_sp_policer_core_ops mlxsw_sp2_policer_core_ops;
1449 enum mlxsw_sp_policer_type {
1450 MLXSW_SP_POLICER_TYPE_SINGLE_RATE,
1452 __MLXSW_SP_POLICER_TYPE_MAX,
1453 MLXSW_SP_POLICER_TYPE_MAX = __MLXSW_SP_POLICER_TYPE_MAX - 1,
1456 struct mlxsw_sp_policer_params {
1462 int mlxsw_sp_policer_add(struct mlxsw_sp *mlxsw_sp,
1463 enum mlxsw_sp_policer_type type,
1464 const struct mlxsw_sp_policer_params *params,
1465 struct netlink_ext_ack *extack, u16 *p_policer_index);
1466 void mlxsw_sp_policer_del(struct mlxsw_sp *mlxsw_sp,
1467 enum mlxsw_sp_policer_type type,
1469 int mlxsw_sp_policer_drops_counter_get(struct mlxsw_sp *mlxsw_sp,
1470 enum mlxsw_sp_policer_type type,
1471 u16 policer_index, u64 *p_drops);
1472 int mlxsw_sp_policers_init(struct mlxsw_sp *mlxsw_sp);
1473 void mlxsw_sp_policers_fini(struct mlxsw_sp *mlxsw_sp);
1474 int mlxsw_sp_policer_resources_register(struct mlxsw_core *mlxsw_core);
1476 /* spectrum_pgt.c */
1477 int mlxsw_sp_pgt_mid_alloc(struct mlxsw_sp *mlxsw_sp, u16 *p_mid);
1478 void mlxsw_sp_pgt_mid_free(struct mlxsw_sp *mlxsw_sp, u16 mid_base);
1479 int mlxsw_sp_pgt_mid_alloc_range(struct mlxsw_sp *mlxsw_sp, u16 mid_base,
1481 void mlxsw_sp_pgt_mid_free_range(struct mlxsw_sp *mlxsw_sp, u16 mid_base,
1483 int mlxsw_sp_pgt_entry_port_set(struct mlxsw_sp *mlxsw_sp, u16 mid,
1484 u16 smpe, u16 local_port, bool member);
1485 int mlxsw_sp_pgt_init(struct mlxsw_sp *mlxsw_sp);
1486 void mlxsw_sp_pgt_fini(struct mlxsw_sp *mlxsw_sp);
1488 /* spectrum_port_range.c */
1489 struct mlxsw_sp_port_range {
1492 u8 source:1; /* Source or destination */
1495 int mlxsw_sp_port_range_reg_get(struct mlxsw_sp *mlxsw_sp,
1496 const struct mlxsw_sp_port_range *range,
1497 struct netlink_ext_ack *extack,
1499 void mlxsw_sp_port_range_reg_put(struct mlxsw_sp *mlxsw_sp, u8 prr_index);
1500 int mlxsw_sp_port_range_init(struct mlxsw_sp *mlxsw_sp);
1501 void mlxsw_sp_port_range_fini(struct mlxsw_sp *mlxsw_sp);