0001
0002
0003
0004 #ifndef _MLXSW_SPECTRUM_H
0005 #define _MLXSW_SPECTRUM_H
0006
0007 #include <linux/ethtool.h>
0008 #include <linux/types.h>
0009 #include <linux/netdevice.h>
0010 #include <linux/rhashtable.h>
0011 #include <linux/bitops.h>
0012 #include <linux/if_bridge.h>
0013 #include <linux/if_vlan.h>
0014 #include <linux/list.h>
0015 #include <linux/dcbnl.h>
0016 #include <linux/in6.h>
0017 #include <linux/notifier.h>
0018 #include <linux/net_namespace.h>
0019 #include <linux/spinlock.h>
0020 #include <net/psample.h>
0021 #include <net/pkt_cls.h>
0022 #include <net/red.h>
0023 #include <net/vxlan.h>
0024 #include <net/flow_offload.h>
0025 #include <net/inet_ecn.h>
0026
0027 #include "port.h"
0028 #include "core.h"
0029 #include "core_acl_flex_keys.h"
0030 #include "core_acl_flex_actions.h"
0031 #include "reg.h"
0032
0033 #define MLXSW_SP_DEFAULT_VID (VLAN_N_VID - 1)
0034
0035 #define MLXSW_SP_FID_8021D_MAX 1024
0036
0037 #define MLXSW_SP_MID_MAX 7000
0038
0039 #define MLXSW_SP_KVD_LINEAR_SIZE 98304
0040 #define MLXSW_SP_KVD_GRANULARITY 128
0041
0042 #define MLXSW_SP_RESOURCE_NAME_KVD "kvd"
0043 #define MLXSW_SP_RESOURCE_NAME_KVD_LINEAR "linear"
0044 #define MLXSW_SP_RESOURCE_NAME_KVD_HASH_SINGLE "hash_single"
0045 #define MLXSW_SP_RESOURCE_NAME_KVD_HASH_DOUBLE "hash_double"
0046 #define MLXSW_SP_RESOURCE_NAME_KVD_LINEAR_SINGLES "singles"
0047 #define MLXSW_SP_RESOURCE_NAME_KVD_LINEAR_CHUNKS "chunks"
0048 #define MLXSW_SP_RESOURCE_NAME_KVD_LINEAR_LARGE_CHUNKS "large_chunks"
0049
0050 #define MLXSW_SP_RESOURCE_NAME_SPAN "span_agents"
0051
0052 #define MLXSW_SP_RESOURCE_NAME_COUNTERS "counters"
0053 #define MLXSW_SP_RESOURCE_NAME_COUNTERS_FLOW "flow"
0054 #define MLXSW_SP_RESOURCE_NAME_COUNTERS_RIF "rif"
0055
0056 enum mlxsw_sp_resource_id {
0057 MLXSW_SP_RESOURCE_KVD = MLXSW_CORE_RESOURCE_MAX,
0058 MLXSW_SP_RESOURCE_KVD_LINEAR,
0059 MLXSW_SP_RESOURCE_KVD_HASH_SINGLE,
0060 MLXSW_SP_RESOURCE_KVD_HASH_DOUBLE,
0061 MLXSW_SP_RESOURCE_KVD_LINEAR_SINGLE,
0062 MLXSW_SP_RESOURCE_KVD_LINEAR_CHUNKS,
0063 MLXSW_SP_RESOURCE_KVD_LINEAR_LARGE_CHUNKS,
0064 MLXSW_SP_RESOURCE_SPAN,
0065 MLXSW_SP_RESOURCE_COUNTERS,
0066 MLXSW_SP_RESOURCE_COUNTERS_FLOW,
0067 MLXSW_SP_RESOURCE_COUNTERS_RIF,
0068 MLXSW_SP_RESOURCE_GLOBAL_POLICERS,
0069 MLXSW_SP_RESOURCE_SINGLE_RATE_POLICERS,
0070 MLXSW_SP_RESOURCE_RIF_MAC_PROFILES,
0071 MLXSW_SP_RESOURCE_RIFS,
0072 };
0073
0074 struct mlxsw_sp_port;
0075 struct mlxsw_sp_rif;
0076 struct mlxsw_sp_span_entry;
0077 enum mlxsw_sp_l3proto;
0078 union mlxsw_sp_l3addr;
0079
0080 struct mlxsw_sp_upper {
0081 struct net_device *dev;
0082 unsigned int ref_count;
0083 };
0084
0085 enum mlxsw_sp_rif_type {
0086 MLXSW_SP_RIF_TYPE_SUBPORT,
0087 MLXSW_SP_RIF_TYPE_VLAN,
0088 MLXSW_SP_RIF_TYPE_FID,
0089 MLXSW_SP_RIF_TYPE_IPIP_LB,
0090 MLXSW_SP_RIF_TYPE_MAX,
0091 };
0092
0093 struct mlxsw_sp_router_ops;
0094
0095 extern const struct mlxsw_sp_router_ops mlxsw_sp1_router_ops;
0096 extern const struct mlxsw_sp_router_ops mlxsw_sp2_router_ops;
0097
0098 struct mlxsw_sp_switchdev_ops;
0099
0100 extern const struct mlxsw_sp_switchdev_ops mlxsw_sp1_switchdev_ops;
0101 extern const struct mlxsw_sp_switchdev_ops mlxsw_sp2_switchdev_ops;
0102
0103 enum mlxsw_sp_fid_type {
0104 MLXSW_SP_FID_TYPE_8021Q,
0105 MLXSW_SP_FID_TYPE_8021D,
0106 MLXSW_SP_FID_TYPE_RFID,
0107 MLXSW_SP_FID_TYPE_DUMMY,
0108 MLXSW_SP_FID_TYPE_MAX,
0109 };
0110
0111 enum mlxsw_sp_nve_type {
0112 MLXSW_SP_NVE_TYPE_VXLAN,
0113 };
0114
0115 struct mlxsw_sp_sb;
0116 struct mlxsw_sp_bridge;
0117 struct mlxsw_sp_router;
0118 struct mlxsw_sp_mr;
0119 struct mlxsw_sp_acl;
0120 struct mlxsw_sp_counter_pool;
0121 struct mlxsw_sp_fid_core;
0122 struct mlxsw_sp_kvdl;
0123 struct mlxsw_sp_nve;
0124 struct mlxsw_sp_kvdl_ops;
0125 struct mlxsw_sp_mr_tcam_ops;
0126 struct mlxsw_sp_acl_rulei_ops;
0127 struct mlxsw_sp_acl_tcam_ops;
0128 struct mlxsw_sp_nve_ops;
0129 struct mlxsw_sp_sb_ops;
0130 struct mlxsw_sp_sb_vals;
0131 struct mlxsw_sp_port_type_speed_ops;
0132 struct mlxsw_sp_ptp_state;
0133 struct mlxsw_sp_ptp_ops;
0134 struct mlxsw_sp_span_ops;
0135 struct mlxsw_sp_qdisc_state;
0136 struct mlxsw_sp_mall_entry;
0137 struct mlxsw_sp_pgt;
0138
0139 struct mlxsw_sp_port_mapping {
0140 u8 module;
0141 u8 slot_index;
0142 u8 width;
0143 u8 module_width;
0144 u8 lane;
0145 };
0146
0147 struct mlxsw_sp_port_mapping_events {
0148 struct list_head queue;
0149 spinlock_t queue_lock;
0150 struct work_struct work;
0151 };
0152
0153 struct mlxsw_sp_parsing {
0154 refcount_t parsing_depth_ref;
0155 u16 parsing_depth;
0156 u16 vxlan_udp_dport;
0157 struct mutex lock;
0158 };
0159
0160 struct mlxsw_sp {
0161 struct mlxsw_sp_port **ports;
0162 struct mlxsw_core *core;
0163 const struct mlxsw_bus_info *bus_info;
0164 unsigned char base_mac[ETH_ALEN];
0165 const unsigned char *mac_mask;
0166 struct mlxsw_sp_upper *lags;
0167 struct mlxsw_sp_port_mapping *port_mapping;
0168 struct mlxsw_sp_port_mapping_events port_mapping_events;
0169 struct rhashtable sample_trigger_ht;
0170 struct mlxsw_sp_sb *sb;
0171 struct mlxsw_sp_bridge *bridge;
0172 struct mlxsw_sp_router *router;
0173 struct mlxsw_sp_mr *mr;
0174 struct mlxsw_afa *afa;
0175 struct mlxsw_sp_acl *acl;
0176 struct mlxsw_sp_fid_core *fid_core;
0177 struct mlxsw_sp_policer_core *policer_core;
0178 struct mlxsw_sp_kvdl *kvdl;
0179 struct mlxsw_sp_nve *nve;
0180 struct notifier_block netdevice_nb;
0181 struct mlxsw_sp_ptp_clock *clock;
0182 struct mlxsw_sp_ptp_state *ptp_state;
0183 struct mlxsw_sp_counter_pool *counter_pool;
0184 struct mlxsw_sp_span *span;
0185 struct mlxsw_sp_trap *trap;
0186 struct mlxsw_sp_parsing parsing;
0187 const struct mlxsw_sp_switchdev_ops *switchdev_ops;
0188 const struct mlxsw_sp_kvdl_ops *kvdl_ops;
0189 const struct mlxsw_afa_ops *afa_ops;
0190 const struct mlxsw_afk_ops *afk_ops;
0191 const struct mlxsw_sp_mr_tcam_ops *mr_tcam_ops;
0192 const struct mlxsw_sp_acl_rulei_ops *acl_rulei_ops;
0193 const struct mlxsw_sp_acl_tcam_ops *acl_tcam_ops;
0194 const struct mlxsw_sp_acl_bf_ops *acl_bf_ops;
0195 const struct mlxsw_sp_nve_ops **nve_ops_arr;
0196 const struct mlxsw_sp_sb_vals *sb_vals;
0197 const struct mlxsw_sp_sb_ops *sb_ops;
0198 const struct mlxsw_sp_port_type_speed_ops *port_type_speed_ops;
0199 const struct mlxsw_sp_ptp_ops *ptp_ops;
0200 const struct mlxsw_sp_span_ops *span_ops;
0201 const struct mlxsw_sp_policer_core_ops *policer_core_ops;
0202 const struct mlxsw_sp_trap_ops *trap_ops;
0203 const struct mlxsw_sp_mall_ops *mall_ops;
0204 const struct mlxsw_sp_router_ops *router_ops;
0205 const struct mlxsw_listener *listeners;
0206 const struct mlxsw_sp_fid_family **fid_family_arr;
0207 size_t listeners_count;
0208 u32 lowest_shaper_bs;
0209 struct rhashtable ipv6_addr_ht;
0210 struct mutex ipv6_addr_ht_lock;
0211 struct mlxsw_sp_pgt *pgt;
0212 bool pgt_smpe_index_valid;
0213 };
0214
0215 struct mlxsw_sp_ptp_ops {
0216 struct mlxsw_sp_ptp_clock *
0217 (*clock_init)(struct mlxsw_sp *mlxsw_sp, struct device *dev);
0218 void (*clock_fini)(struct mlxsw_sp_ptp_clock *clock);
0219
0220 struct mlxsw_sp_ptp_state *(*init)(struct mlxsw_sp *mlxsw_sp);
0221 void (*fini)(struct mlxsw_sp_ptp_state *ptp_state);
0222
0223
0224
0225
0226 void (*receive)(struct mlxsw_sp *mlxsw_sp, struct sk_buff *skb,
0227 u16 local_port);
0228
0229
0230
0231
0232 void (*transmitted)(struct mlxsw_sp *mlxsw_sp, struct sk_buff *skb,
0233 u16 local_port);
0234
0235 int (*hwtstamp_get)(struct mlxsw_sp_port *mlxsw_sp_port,
0236 struct hwtstamp_config *config);
0237 int (*hwtstamp_set)(struct mlxsw_sp_port *mlxsw_sp_port,
0238 struct hwtstamp_config *config);
0239 void (*shaper_work)(struct work_struct *work);
0240 int (*get_ts_info)(struct mlxsw_sp *mlxsw_sp,
0241 struct ethtool_ts_info *info);
0242 int (*get_stats_count)(void);
0243 void (*get_stats_strings)(u8 **p);
0244 void (*get_stats)(struct mlxsw_sp_port *mlxsw_sp_port,
0245 u64 *data, int data_index);
0246 int (*txhdr_construct)(struct mlxsw_core *mlxsw_core,
0247 struct mlxsw_sp_port *mlxsw_sp_port,
0248 struct sk_buff *skb,
0249 const struct mlxsw_tx_info *tx_info);
0250 };
0251
0252 static inline struct mlxsw_sp_upper *
0253 mlxsw_sp_lag_get(struct mlxsw_sp *mlxsw_sp, u16 lag_id)
0254 {
0255 return &mlxsw_sp->lags[lag_id];
0256 }
0257
0258 struct mlxsw_sp_port_pcpu_stats {
0259 u64 rx_packets;
0260 u64 rx_bytes;
0261 u64 tx_packets;
0262 u64 tx_bytes;
0263 struct u64_stats_sync syncp;
0264 u32 tx_dropped;
0265 };
0266
0267 enum mlxsw_sp_sample_trigger_type {
0268 MLXSW_SP_SAMPLE_TRIGGER_TYPE_INGRESS,
0269 MLXSW_SP_SAMPLE_TRIGGER_TYPE_EGRESS,
0270 MLXSW_SP_SAMPLE_TRIGGER_TYPE_POLICY_ENGINE,
0271 };
0272
0273 struct mlxsw_sp_sample_trigger {
0274 enum mlxsw_sp_sample_trigger_type type;
0275 u16 local_port;
0276 };
0277
0278 struct mlxsw_sp_sample_params {
0279 struct psample_group *psample_group;
0280 u32 trunc_size;
0281 u32 rate;
0282 bool truncate;
0283 };
0284
0285 struct mlxsw_sp_bridge_port;
0286 struct mlxsw_sp_fid;
0287
0288 struct mlxsw_sp_port_vlan {
0289 struct list_head list;
0290 struct mlxsw_sp_port *mlxsw_sp_port;
0291 struct mlxsw_sp_fid *fid;
0292 u16 vid;
0293 struct mlxsw_sp_bridge_port *bridge_port;
0294 struct list_head bridge_vlan_node;
0295 };
0296
0297
0298 struct mlxsw_sp_port_xstats {
0299 u64 ecn;
0300 u64 tc_ecn[TC_MAX_QUEUE];
0301 u64 wred_drop[TC_MAX_QUEUE];
0302 u64 tail_drop[TC_MAX_QUEUE];
0303 u64 backlog[TC_MAX_QUEUE];
0304 u64 tx_bytes[IEEE_8021QAZ_MAX_TCS];
0305 u64 tx_packets[IEEE_8021QAZ_MAX_TCS];
0306 };
0307
0308 struct mlxsw_sp_ptp_port_dir_stats {
0309 u64 packets;
0310 u64 timestamps;
0311 };
0312
0313 struct mlxsw_sp_ptp_port_stats {
0314 struct mlxsw_sp_ptp_port_dir_stats rx_gcd;
0315 struct mlxsw_sp_ptp_port_dir_stats tx_gcd;
0316 };
0317
0318 struct mlxsw_sp_port {
0319 struct net_device *dev;
0320 struct mlxsw_sp_port_pcpu_stats __percpu *pcpu_stats;
0321 struct mlxsw_sp *mlxsw_sp;
0322 u16 local_port;
0323 u8 lagged:1,
0324 split:1;
0325 u16 pvid;
0326 u16 lag_id;
0327 struct {
0328 u8 tx_pause:1,
0329 rx_pause:1,
0330 autoneg:1;
0331 } link;
0332 struct {
0333 struct ieee_ets *ets;
0334 struct ieee_maxrate *maxrate;
0335 struct ieee_pfc *pfc;
0336 enum mlxsw_reg_qpts_trust_state trust_state;
0337 } dcb;
0338 struct mlxsw_sp_port_mapping mapping;
0339
0340
0341
0342
0343 struct {
0344 #define MLXSW_HW_STATS_UPDATE_TIME HZ
0345 struct rtnl_link_stats64 stats;
0346 struct mlxsw_sp_port_xstats xstats;
0347 struct delayed_work update_dw;
0348 } periodic_hw_stats;
0349 struct list_head vlans_list;
0350 struct mlxsw_sp_port_vlan *default_vlan;
0351 struct mlxsw_sp_qdisc_state *qdisc;
0352 unsigned acl_rule_count;
0353 struct mlxsw_sp_flow_block *ing_flow_block;
0354 struct mlxsw_sp_flow_block *eg_flow_block;
0355 struct {
0356 struct delayed_work shaper_dw;
0357 struct hwtstamp_config hwtstamp_config;
0358 u16 ing_types;
0359 u16 egr_types;
0360 struct mlxsw_sp_ptp_port_stats stats;
0361 } ptp;
0362 int max_mtu;
0363 u32 max_speed;
0364 struct mlxsw_sp_hdroom *hdroom;
0365 u64 module_overheat_initial_val;
0366 };
0367
0368 struct mlxsw_sp_port_type_speed_ops {
0369 void (*from_ptys_supported_port)(struct mlxsw_sp *mlxsw_sp,
0370 u32 ptys_eth_proto,
0371 struct ethtool_link_ksettings *cmd);
0372 void (*from_ptys_link)(struct mlxsw_sp *mlxsw_sp, u32 ptys_eth_proto,
0373 unsigned long *mode);
0374 u32 (*from_ptys_speed)(struct mlxsw_sp *mlxsw_sp, u32 ptys_eth_proto);
0375 void (*from_ptys_link_mode)(struct mlxsw_sp *mlxsw_sp,
0376 bool carrier_ok, u32 ptys_eth_proto,
0377 struct ethtool_link_ksettings *cmd);
0378 int (*ptys_max_speed)(struct mlxsw_sp_port *mlxsw_sp_port, u32 *p_max_speed);
0379 u32 (*to_ptys_advert_link)(struct mlxsw_sp *mlxsw_sp,
0380 const struct ethtool_link_ksettings *cmd);
0381 u32 (*to_ptys_speed_lanes)(struct mlxsw_sp *mlxsw_sp, u8 width,
0382 const struct ethtool_link_ksettings *cmd);
0383 void (*reg_ptys_eth_pack)(struct mlxsw_sp *mlxsw_sp, char *payload,
0384 u16 local_port, u32 proto_admin, bool autoneg);
0385 void (*reg_ptys_eth_unpack)(struct mlxsw_sp *mlxsw_sp, char *payload,
0386 u32 *p_eth_proto_cap,
0387 u32 *p_eth_proto_admin,
0388 u32 *p_eth_proto_oper);
0389 u32 (*ptys_proto_cap_masked_get)(u32 eth_proto_cap);
0390 };
0391
0392 struct mlxsw_sp_ports_bitmap {
0393 unsigned long *bitmap;
0394 unsigned int nbits;
0395 };
0396
0397 static inline int
0398 mlxsw_sp_port_bitmap_init(struct mlxsw_sp *mlxsw_sp,
0399 struct mlxsw_sp_ports_bitmap *ports_bm)
0400 {
0401 unsigned int nbits = mlxsw_core_max_ports(mlxsw_sp->core);
0402
0403 ports_bm->nbits = nbits;
0404 ports_bm->bitmap = bitmap_zalloc(nbits, GFP_KERNEL);
0405 if (!ports_bm->bitmap)
0406 return -ENOMEM;
0407
0408 return 0;
0409 }
0410
0411 static inline void
0412 mlxsw_sp_port_bitmap_fini(struct mlxsw_sp_ports_bitmap *ports_bm)
0413 {
0414 bitmap_free(ports_bm->bitmap);
0415 }
0416
0417 static inline u8 mlxsw_sp_tunnel_ecn_decap(u8 outer_ecn, u8 inner_ecn,
0418 bool *trap_en)
0419 {
0420 bool set_ce = false;
0421
0422 *trap_en = !!__INET_ECN_decapsulate(outer_ecn, inner_ecn, &set_ce);
0423 if (set_ce)
0424 return INET_ECN_CE;
0425 else if (outer_ecn == INET_ECN_ECT_1 && inner_ecn == INET_ECN_ECT_0)
0426 return INET_ECN_ECT_1;
0427 else
0428 return inner_ecn;
0429 }
0430
0431 static inline struct net_device *
0432 mlxsw_sp_bridge_vxlan_dev_find(struct net_device *br_dev)
0433 {
0434 struct net_device *dev;
0435 struct list_head *iter;
0436
0437 netdev_for_each_lower_dev(br_dev, dev, iter) {
0438 if (netif_is_vxlan(dev))
0439 return dev;
0440 }
0441
0442 return NULL;
0443 }
0444
0445 static inline bool mlxsw_sp_bridge_has_vxlan(struct net_device *br_dev)
0446 {
0447 return !!mlxsw_sp_bridge_vxlan_dev_find(br_dev);
0448 }
0449
0450 static inline int
0451 mlxsw_sp_vxlan_mapped_vid(const struct net_device *vxlan_dev, u16 *p_vid)
0452 {
0453 struct bridge_vlan_info vinfo;
0454 u16 vid = 0;
0455 int err;
0456
0457 err = br_vlan_get_pvid(vxlan_dev, &vid);
0458 if (err || !vid)
0459 goto out;
0460
0461 err = br_vlan_get_info(vxlan_dev, vid, &vinfo);
0462 if (err || !(vinfo.flags & BRIDGE_VLAN_INFO_UNTAGGED))
0463 vid = 0;
0464
0465 out:
0466 *p_vid = vid;
0467 return err;
0468 }
0469
0470 static inline bool
0471 mlxsw_sp_port_is_pause_en(const struct mlxsw_sp_port *mlxsw_sp_port)
0472 {
0473 return mlxsw_sp_port->link.tx_pause || mlxsw_sp_port->link.rx_pause;
0474 }
0475
0476 static inline struct mlxsw_sp_port *
0477 mlxsw_sp_port_lagged_get(struct mlxsw_sp *mlxsw_sp, u16 lag_id, u8 port_index)
0478 {
0479 struct mlxsw_sp_port *mlxsw_sp_port;
0480 u16 local_port;
0481
0482 local_port = mlxsw_core_lag_mapping_get(mlxsw_sp->core,
0483 lag_id, port_index);
0484 mlxsw_sp_port = mlxsw_sp->ports[local_port];
0485 return mlxsw_sp_port && mlxsw_sp_port->lagged ? mlxsw_sp_port : NULL;
0486 }
0487
0488 static inline struct mlxsw_sp_port_vlan *
0489 mlxsw_sp_port_vlan_find_by_vid(const struct mlxsw_sp_port *mlxsw_sp_port,
0490 u16 vid)
0491 {
0492 struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan;
0493
0494 list_for_each_entry(mlxsw_sp_port_vlan, &mlxsw_sp_port->vlans_list,
0495 list) {
0496 if (mlxsw_sp_port_vlan->vid == vid)
0497 return mlxsw_sp_port_vlan;
0498 }
0499
0500 return NULL;
0501 }
0502
0503 enum mlxsw_sp_flood_type {
0504 MLXSW_SP_FLOOD_TYPE_UC,
0505 MLXSW_SP_FLOOD_TYPE_BC,
0506 MLXSW_SP_FLOOD_TYPE_MC,
0507 };
0508
0509 int mlxsw_sp_port_get_stats_raw(struct net_device *dev, int grp,
0510 int prio, char *ppcnt_pl);
0511 int mlxsw_sp_port_admin_status_set(struct mlxsw_sp_port *mlxsw_sp_port,
0512 bool is_up);
0513 int
0514 mlxsw_sp_port_vlan_classification_set(struct mlxsw_sp_port *mlxsw_sp_port,
0515 bool is_8021ad_tagged,
0516 bool is_8021q_tagged);
0517 static inline bool
0518 mlxsw_sp_local_port_is_valid(struct mlxsw_sp *mlxsw_sp, u16 local_port)
0519 {
0520 unsigned int max_ports = mlxsw_core_max_ports(mlxsw_sp->core);
0521
0522 return local_port < max_ports && local_port;
0523 }
0524
0525
0526 struct mlxsw_sp_hdroom_prio {
0527
0528
0529
0530 u8 buf_idx;
0531
0532 u8 ets_buf_idx;
0533
0534 u8 set_buf_idx;
0535 bool lossy;
0536 };
0537
0538 struct mlxsw_sp_hdroom_buf {
0539 u32 thres_cells;
0540 u32 size_cells;
0541
0542 u32 set_size_cells;
0543 bool lossy;
0544 };
0545
0546 enum mlxsw_sp_hdroom_mode {
0547 MLXSW_SP_HDROOM_MODE_DCB,
0548 MLXSW_SP_HDROOM_MODE_TC,
0549 };
0550
0551 #define MLXSW_SP_PB_COUNT 10
0552
0553 struct mlxsw_sp_hdroom {
0554 enum mlxsw_sp_hdroom_mode mode;
0555
0556 struct {
0557 struct mlxsw_sp_hdroom_prio prio[IEEE_8021Q_MAX_PRIORITIES];
0558 } prios;
0559 struct {
0560 struct mlxsw_sp_hdroom_buf buf[MLXSW_SP_PB_COUNT];
0561 } bufs;
0562 struct {
0563
0564
0565
0566 u32 size_cells;
0567
0568
0569
0570 u32 reserve_cells;
0571 bool enable;
0572 } int_buf;
0573 int delay_bytes;
0574 int mtu;
0575 };
0576
0577 int mlxsw_sp_buffers_init(struct mlxsw_sp *mlxsw_sp);
0578 void mlxsw_sp_buffers_fini(struct mlxsw_sp *mlxsw_sp);
0579 int mlxsw_sp_port_buffers_init(struct mlxsw_sp_port *mlxsw_sp_port);
0580 void mlxsw_sp_port_buffers_fini(struct mlxsw_sp_port *mlxsw_sp_port);
0581 int mlxsw_sp_sb_pool_get(struct mlxsw_core *mlxsw_core,
0582 unsigned int sb_index, u16 pool_index,
0583 struct devlink_sb_pool_info *pool_info);
0584 int mlxsw_sp_sb_pool_set(struct mlxsw_core *mlxsw_core,
0585 unsigned int sb_index, u16 pool_index, u32 size,
0586 enum devlink_sb_threshold_type threshold_type,
0587 struct netlink_ext_ack *extack);
0588 int mlxsw_sp_sb_port_pool_get(struct mlxsw_core_port *mlxsw_core_port,
0589 unsigned int sb_index, u16 pool_index,
0590 u32 *p_threshold);
0591 int mlxsw_sp_sb_port_pool_set(struct mlxsw_core_port *mlxsw_core_port,
0592 unsigned int sb_index, u16 pool_index,
0593 u32 threshold, struct netlink_ext_ack *extack);
0594 int mlxsw_sp_sb_tc_pool_bind_get(struct mlxsw_core_port *mlxsw_core_port,
0595 unsigned int sb_index, u16 tc_index,
0596 enum devlink_sb_pool_type pool_type,
0597 u16 *p_pool_index, u32 *p_threshold);
0598 int mlxsw_sp_sb_tc_pool_bind_set(struct mlxsw_core_port *mlxsw_core_port,
0599 unsigned int sb_index, u16 tc_index,
0600 enum devlink_sb_pool_type pool_type,
0601 u16 pool_index, u32 threshold,
0602 struct netlink_ext_ack *extack);
0603 int mlxsw_sp_sb_occ_snapshot(struct mlxsw_core *mlxsw_core,
0604 unsigned int sb_index);
0605 int mlxsw_sp_sb_occ_max_clear(struct mlxsw_core *mlxsw_core,
0606 unsigned int sb_index);
0607 int mlxsw_sp_sb_occ_port_pool_get(struct mlxsw_core_port *mlxsw_core_port,
0608 unsigned int sb_index, u16 pool_index,
0609 u32 *p_cur, u32 *p_max);
0610 int mlxsw_sp_sb_occ_tc_port_bind_get(struct mlxsw_core_port *mlxsw_core_port,
0611 unsigned int sb_index, u16 tc_index,
0612 enum devlink_sb_pool_type pool_type,
0613 u32 *p_cur, u32 *p_max);
0614 u32 mlxsw_sp_cells_bytes(const struct mlxsw_sp *mlxsw_sp, u32 cells);
0615 u32 mlxsw_sp_bytes_cells(const struct mlxsw_sp *mlxsw_sp, u32 bytes);
0616 void mlxsw_sp_hdroom_prios_reset_buf_idx(struct mlxsw_sp_hdroom *hdroom);
0617 void mlxsw_sp_hdroom_bufs_reset_lossiness(struct mlxsw_sp_hdroom *hdroom);
0618 void mlxsw_sp_hdroom_bufs_reset_sizes(struct mlxsw_sp_port *mlxsw_sp_port,
0619 struct mlxsw_sp_hdroom *hdroom);
0620 int mlxsw_sp_hdroom_configure(struct mlxsw_sp_port *mlxsw_sp_port,
0621 const struct mlxsw_sp_hdroom *hdroom);
0622 struct mlxsw_sp_sample_params *
0623 mlxsw_sp_sample_trigger_params_lookup(struct mlxsw_sp *mlxsw_sp,
0624 const struct mlxsw_sp_sample_trigger *trigger);
0625 int
0626 mlxsw_sp_sample_trigger_params_set(struct mlxsw_sp *mlxsw_sp,
0627 const struct mlxsw_sp_sample_trigger *trigger,
0628 const struct mlxsw_sp_sample_params *params,
0629 struct netlink_ext_ack *extack);
0630 void
0631 mlxsw_sp_sample_trigger_params_unset(struct mlxsw_sp *mlxsw_sp,
0632 const struct mlxsw_sp_sample_trigger *trigger);
0633 int mlxsw_sp_ipv6_addr_kvdl_index_get(struct mlxsw_sp *mlxsw_sp,
0634 const struct in6_addr *addr6,
0635 u32 *p_kvdl_index);
0636 void
0637 mlxsw_sp_ipv6_addr_put(struct mlxsw_sp *mlxsw_sp, const struct in6_addr *addr6);
0638
0639 extern const struct mlxsw_sp_sb_vals mlxsw_sp1_sb_vals;
0640 extern const struct mlxsw_sp_sb_vals mlxsw_sp2_sb_vals;
0641
0642 extern const struct mlxsw_sp_sb_ops mlxsw_sp1_sb_ops;
0643 extern const struct mlxsw_sp_sb_ops mlxsw_sp2_sb_ops;
0644 extern const struct mlxsw_sp_sb_ops mlxsw_sp3_sb_ops;
0645
0646
0647 int mlxsw_sp_switchdev_init(struct mlxsw_sp *mlxsw_sp);
0648 void mlxsw_sp_switchdev_fini(struct mlxsw_sp *mlxsw_sp);
0649 int mlxsw_sp_rif_fdb_op(struct mlxsw_sp *mlxsw_sp, const char *mac, u16 fid,
0650 bool adding);
0651 void
0652 mlxsw_sp_port_vlan_bridge_leave(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan);
0653 int mlxsw_sp_port_bridge_join(struct mlxsw_sp_port *mlxsw_sp_port,
0654 struct net_device *brport_dev,
0655 struct net_device *br_dev,
0656 struct netlink_ext_ack *extack);
0657 void mlxsw_sp_port_bridge_leave(struct mlxsw_sp_port *mlxsw_sp_port,
0658 struct net_device *brport_dev,
0659 struct net_device *br_dev);
0660 bool mlxsw_sp_bridge_device_is_offloaded(const struct mlxsw_sp *mlxsw_sp,
0661 const struct net_device *br_dev);
0662 int mlxsw_sp_bridge_vxlan_join(struct mlxsw_sp *mlxsw_sp,
0663 const struct net_device *br_dev,
0664 const struct net_device *vxlan_dev, u16 vid,
0665 struct netlink_ext_ack *extack);
0666 void mlxsw_sp_bridge_vxlan_leave(struct mlxsw_sp *mlxsw_sp,
0667 const struct net_device *vxlan_dev);
0668 extern struct notifier_block mlxsw_sp_switchdev_notifier;
0669
0670
0671 void mlxsw_sp_rx_listener_no_mark_func(struct sk_buff *skb,
0672 u16 local_port, void *priv);
0673 void mlxsw_sp_ptp_receive(struct mlxsw_sp *mlxsw_sp, struct sk_buff *skb,
0674 u16 local_port);
0675 int mlxsw_sp_port_speed_get(struct mlxsw_sp_port *mlxsw_sp_port, u32 *speed);
0676 int mlxsw_sp_port_ets_set(struct mlxsw_sp_port *mlxsw_sp_port,
0677 enum mlxsw_reg_qeec_hr hr, u8 index, u8 next_index,
0678 bool dwrr, u8 dwrr_weight);
0679 int mlxsw_sp_port_prio_tc_set(struct mlxsw_sp_port *mlxsw_sp_port,
0680 u8 switch_prio, u8 tclass);
0681 int mlxsw_sp_port_ets_maxrate_set(struct mlxsw_sp_port *mlxsw_sp_port,
0682 enum mlxsw_reg_qeec_hr hr, u8 index,
0683 u8 next_index, u32 maxrate, u8 burst_size);
0684 enum mlxsw_reg_spms_state mlxsw_sp_stp_spms_state(u8 stp_state);
0685 int mlxsw_sp_port_vid_stp_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid,
0686 u8 state);
0687 int mlxsw_sp_port_vp_mode_set(struct mlxsw_sp_port *mlxsw_sp_port, bool enable);
0688 int mlxsw_sp_port_vid_learning_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid,
0689 bool learn_enable);
0690 int mlxsw_sp_ethtype_to_sver_type(u16 ethtype, u8 *p_sver_type);
0691 int mlxsw_sp_port_egress_ethtype_set(struct mlxsw_sp_port *mlxsw_sp_port,
0692 u16 ethtype);
0693 int mlxsw_sp_port_pvid_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid,
0694 u16 ethtype);
0695 struct mlxsw_sp_port_vlan *
0696 mlxsw_sp_port_vlan_create(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid);
0697 void mlxsw_sp_port_vlan_destroy(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan);
0698 int mlxsw_sp_port_vlan_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid_begin,
0699 u16 vid_end, bool is_member, bool untagged);
0700 int mlxsw_sp_flow_counter_get(struct mlxsw_sp *mlxsw_sp,
0701 unsigned int counter_index, u64 *packets,
0702 u64 *bytes);
0703 int mlxsw_sp_flow_counter_alloc(struct mlxsw_sp *mlxsw_sp,
0704 unsigned int *p_counter_index);
0705 void mlxsw_sp_flow_counter_free(struct mlxsw_sp *mlxsw_sp,
0706 unsigned int counter_index);
0707 void mlxsw_sp_txhdr_construct(struct sk_buff *skb,
0708 const struct mlxsw_tx_info *tx_info);
0709 int mlxsw_sp_txhdr_ptp_data_construct(struct mlxsw_core *mlxsw_core,
0710 struct mlxsw_sp_port *mlxsw_sp_port,
0711 struct sk_buff *skb,
0712 const struct mlxsw_tx_info *tx_info);
0713 bool mlxsw_sp_port_dev_check(const struct net_device *dev);
0714 struct mlxsw_sp *mlxsw_sp_lower_get(struct net_device *dev);
0715 struct mlxsw_sp_port *mlxsw_sp_port_dev_lower_find(struct net_device *dev);
0716 struct mlxsw_sp_port *mlxsw_sp_port_lower_dev_hold(struct net_device *dev);
0717 void mlxsw_sp_port_dev_put(struct mlxsw_sp_port *mlxsw_sp_port);
0718 struct mlxsw_sp_port *mlxsw_sp_port_dev_lower_find_rcu(struct net_device *dev);
0719 int mlxsw_sp_parsing_depth_inc(struct mlxsw_sp *mlxsw_sp);
0720 void mlxsw_sp_parsing_depth_dec(struct mlxsw_sp *mlxsw_sp);
0721 int mlxsw_sp_parsing_vxlan_udp_dport_set(struct mlxsw_sp *mlxsw_sp,
0722 __be16 udp_dport);
0723
0724
0725 #ifdef CONFIG_MLXSW_SPECTRUM_DCB
0726 int mlxsw_sp_port_dcb_init(struct mlxsw_sp_port *mlxsw_sp_port);
0727 void mlxsw_sp_port_dcb_fini(struct mlxsw_sp_port *mlxsw_sp_port);
0728 #else
0729 static inline int mlxsw_sp_port_dcb_init(struct mlxsw_sp_port *mlxsw_sp_port)
0730 {
0731 return 0;
0732 }
0733 static inline void mlxsw_sp_port_dcb_fini(struct mlxsw_sp_port *mlxsw_sp_port)
0734 {}
0735 #endif
0736
0737
0738 enum mlxsw_sp_l3proto {
0739 MLXSW_SP_L3_PROTO_IPV4,
0740 MLXSW_SP_L3_PROTO_IPV6,
0741 #define MLXSW_SP_L3_PROTO_MAX (MLXSW_SP_L3_PROTO_IPV6 + 1)
0742 };
0743
0744 union mlxsw_sp_l3addr {
0745 __be32 addr4;
0746 struct in6_addr addr6;
0747 };
0748
0749 u16 mlxsw_sp_rif_index(const struct mlxsw_sp_rif *rif);
0750 int mlxsw_sp_router_init(struct mlxsw_sp *mlxsw_sp,
0751 struct netlink_ext_ack *extack);
0752 void mlxsw_sp_router_fini(struct mlxsw_sp *mlxsw_sp);
0753 void mlxsw_sp_rif_macvlan_del(struct mlxsw_sp *mlxsw_sp,
0754 const struct net_device *macvlan_dev);
0755 int mlxsw_sp_inetaddr_valid_event(struct notifier_block *unused,
0756 unsigned long event, void *ptr);
0757 int mlxsw_sp_inet6addr_valid_event(struct notifier_block *unused,
0758 unsigned long event, void *ptr);
0759 int
0760 mlxsw_sp_port_vlan_router_join(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan,
0761 struct net_device *l3_dev,
0762 struct netlink_ext_ack *extack);
0763 void
0764 mlxsw_sp_port_vlan_router_leave(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan);
0765 void mlxsw_sp_rif_destroy_by_dev(struct mlxsw_sp *mlxsw_sp,
0766 struct net_device *dev);
0767 bool mlxsw_sp_rif_exists(struct mlxsw_sp *mlxsw_sp,
0768 const struct net_device *dev);
0769 u16 mlxsw_sp_rif_vid(struct mlxsw_sp *mlxsw_sp, const struct net_device *dev);
0770 u16 mlxsw_sp_router_port(const struct mlxsw_sp *mlxsw_sp);
0771 int mlxsw_sp_router_nve_promote_decap(struct mlxsw_sp *mlxsw_sp, u32 ul_tb_id,
0772 enum mlxsw_sp_l3proto ul_proto,
0773 const union mlxsw_sp_l3addr *ul_sip,
0774 u32 tunnel_index);
0775 void mlxsw_sp_router_nve_demote_decap(struct mlxsw_sp *mlxsw_sp, u32 ul_tb_id,
0776 enum mlxsw_sp_l3proto ul_proto,
0777 const union mlxsw_sp_l3addr *ul_sip);
0778 int mlxsw_sp_router_tb_id_vr_id(struct mlxsw_sp *mlxsw_sp, u32 tb_id,
0779 u16 *vr_id);
0780 int mlxsw_sp_router_ul_rif_get(struct mlxsw_sp *mlxsw_sp, u32 ul_tb_id,
0781 u16 *ul_rif_index);
0782 void mlxsw_sp_router_ul_rif_put(struct mlxsw_sp *mlxsw_sp, u16 ul_rif_index);
0783
0784
0785 enum mlxsw_sp_kvdl_entry_type {
0786 MLXSW_SP_KVDL_ENTRY_TYPE_ADJ,
0787 MLXSW_SP_KVDL_ENTRY_TYPE_ACTSET,
0788 MLXSW_SP_KVDL_ENTRY_TYPE_PBS,
0789 MLXSW_SP_KVDL_ENTRY_TYPE_MCRIGR,
0790 MLXSW_SP_KVDL_ENTRY_TYPE_IPV6_ADDRESS,
0791 MLXSW_SP_KVDL_ENTRY_TYPE_TNUMT,
0792 };
0793
0794 static inline unsigned int
0795 mlxsw_sp_kvdl_entry_size(enum mlxsw_sp_kvdl_entry_type type)
0796 {
0797 switch (type) {
0798 case MLXSW_SP_KVDL_ENTRY_TYPE_ADJ:
0799 case MLXSW_SP_KVDL_ENTRY_TYPE_ACTSET:
0800 case MLXSW_SP_KVDL_ENTRY_TYPE_PBS:
0801 case MLXSW_SP_KVDL_ENTRY_TYPE_MCRIGR:
0802 case MLXSW_SP_KVDL_ENTRY_TYPE_IPV6_ADDRESS:
0803 case MLXSW_SP_KVDL_ENTRY_TYPE_TNUMT:
0804 default:
0805 return 1;
0806 }
0807 }
0808
0809 struct mlxsw_sp_kvdl_ops {
0810 size_t priv_size;
0811 int (*init)(struct mlxsw_sp *mlxsw_sp, void *priv);
0812 void (*fini)(struct mlxsw_sp *mlxsw_sp, void *priv);
0813 int (*alloc)(struct mlxsw_sp *mlxsw_sp, void *priv,
0814 enum mlxsw_sp_kvdl_entry_type type,
0815 unsigned int entry_count, u32 *p_entry_index);
0816 void (*free)(struct mlxsw_sp *mlxsw_sp, void *priv,
0817 enum mlxsw_sp_kvdl_entry_type type,
0818 unsigned int entry_count, int entry_index);
0819 int (*alloc_size_query)(struct mlxsw_sp *mlxsw_sp, void *priv,
0820 enum mlxsw_sp_kvdl_entry_type type,
0821 unsigned int entry_count,
0822 unsigned int *p_alloc_count);
0823 int (*resources_register)(struct mlxsw_sp *mlxsw_sp, void *priv);
0824 };
0825
0826 int mlxsw_sp_kvdl_init(struct mlxsw_sp *mlxsw_sp);
0827 void mlxsw_sp_kvdl_fini(struct mlxsw_sp *mlxsw_sp);
0828 int mlxsw_sp_kvdl_alloc(struct mlxsw_sp *mlxsw_sp,
0829 enum mlxsw_sp_kvdl_entry_type type,
0830 unsigned int entry_count, u32 *p_entry_index);
0831 void mlxsw_sp_kvdl_free(struct mlxsw_sp *mlxsw_sp,
0832 enum mlxsw_sp_kvdl_entry_type type,
0833 unsigned int entry_count, int entry_index);
0834 int mlxsw_sp_kvdl_alloc_count_query(struct mlxsw_sp *mlxsw_sp,
0835 enum mlxsw_sp_kvdl_entry_type type,
0836 unsigned int entry_count,
0837 unsigned int *p_alloc_count);
0838
0839
0840 extern const struct mlxsw_sp_kvdl_ops mlxsw_sp1_kvdl_ops;
0841 int mlxsw_sp1_kvdl_resources_register(struct mlxsw_core *mlxsw_core);
0842
0843
0844 extern const struct mlxsw_sp_kvdl_ops mlxsw_sp2_kvdl_ops;
0845
0846 enum mlxsw_sp_acl_mangle_field {
0847 MLXSW_SP_ACL_MANGLE_FIELD_IP_DSFIELD,
0848 MLXSW_SP_ACL_MANGLE_FIELD_IP_DSCP,
0849 MLXSW_SP_ACL_MANGLE_FIELD_IP_ECN,
0850 MLXSW_SP_ACL_MANGLE_FIELD_IP_SPORT,
0851 MLXSW_SP_ACL_MANGLE_FIELD_IP_DPORT,
0852 MLXSW_SP_ACL_MANGLE_FIELD_IP4_SIP,
0853 MLXSW_SP_ACL_MANGLE_FIELD_IP4_DIP,
0854 MLXSW_SP_ACL_MANGLE_FIELD_IP6_SIP_1,
0855 MLXSW_SP_ACL_MANGLE_FIELD_IP6_SIP_2,
0856 MLXSW_SP_ACL_MANGLE_FIELD_IP6_SIP_3,
0857 MLXSW_SP_ACL_MANGLE_FIELD_IP6_SIP_4,
0858 MLXSW_SP_ACL_MANGLE_FIELD_IP6_DIP_1,
0859 MLXSW_SP_ACL_MANGLE_FIELD_IP6_DIP_2,
0860 MLXSW_SP_ACL_MANGLE_FIELD_IP6_DIP_3,
0861 MLXSW_SP_ACL_MANGLE_FIELD_IP6_DIP_4,
0862 };
0863
0864 struct mlxsw_sp_acl_rule_info {
0865 unsigned int priority;
0866 struct mlxsw_afk_element_values values;
0867 struct mlxsw_afa_block *act_block;
0868 u8 action_created:1,
0869 ingress_bind_blocker:1,
0870 egress_bind_blocker:1,
0871 counter_valid:1,
0872 policer_index_valid:1,
0873 ipv6_valid:1;
0874 unsigned int counter_index;
0875 u16 policer_index;
0876 struct {
0877 u32 prev_val;
0878 enum mlxsw_sp_acl_mangle_field prev_field;
0879 } ipv6;
0880 };
0881
0882
0883 struct mlxsw_sp_flow_block {
0884 struct list_head binding_list;
0885 struct {
0886 struct list_head list;
0887 unsigned int min_prio;
0888 unsigned int max_prio;
0889 } mall;
0890 struct mlxsw_sp_acl_ruleset *ruleset_zero;
0891 struct mlxsw_sp *mlxsw_sp;
0892 unsigned int rule_count;
0893 unsigned int disable_count;
0894 unsigned int ingress_blocker_rule_count;
0895 unsigned int egress_blocker_rule_count;
0896 unsigned int ingress_binding_count;
0897 unsigned int egress_binding_count;
0898 struct net *net;
0899 };
0900
0901 struct mlxsw_sp_flow_block_binding {
0902 struct list_head list;
0903 struct mlxsw_sp_port *mlxsw_sp_port;
0904 bool ingress;
0905 };
0906
0907 static inline struct mlxsw_sp *
0908 mlxsw_sp_flow_block_mlxsw_sp(struct mlxsw_sp_flow_block *block)
0909 {
0910 return block->mlxsw_sp;
0911 }
0912
0913 static inline unsigned int
0914 mlxsw_sp_flow_block_rule_count(const struct mlxsw_sp_flow_block *block)
0915 {
0916 return block ? block->rule_count : 0;
0917 }
0918
0919 static inline void
0920 mlxsw_sp_flow_block_disable_inc(struct mlxsw_sp_flow_block *block)
0921 {
0922 if (block)
0923 block->disable_count++;
0924 }
0925
0926 static inline void
0927 mlxsw_sp_flow_block_disable_dec(struct mlxsw_sp_flow_block *block)
0928 {
0929 if (block)
0930 block->disable_count--;
0931 }
0932
0933 static inline bool
0934 mlxsw_sp_flow_block_disabled(const struct mlxsw_sp_flow_block *block)
0935 {
0936 return block->disable_count;
0937 }
0938
0939 static inline bool
0940 mlxsw_sp_flow_block_is_egress_bound(const struct mlxsw_sp_flow_block *block)
0941 {
0942 return block->egress_binding_count;
0943 }
0944
0945 static inline bool
0946 mlxsw_sp_flow_block_is_ingress_bound(const struct mlxsw_sp_flow_block *block)
0947 {
0948 return block->ingress_binding_count;
0949 }
0950
0951 static inline bool
0952 mlxsw_sp_flow_block_is_mixed_bound(const struct mlxsw_sp_flow_block *block)
0953 {
0954 return block->ingress_binding_count && block->egress_binding_count;
0955 }
0956
0957 struct mlxsw_sp_flow_block *mlxsw_sp_flow_block_create(struct mlxsw_sp *mlxsw_sp,
0958 struct net *net);
0959 void mlxsw_sp_flow_block_destroy(struct mlxsw_sp_flow_block *block);
0960 int mlxsw_sp_setup_tc_block_clsact(struct mlxsw_sp_port *mlxsw_sp_port,
0961 struct flow_block_offload *f,
0962 bool ingress);
0963
0964
0965 struct mlxsw_sp_acl_ruleset;
0966
0967 enum mlxsw_sp_acl_profile {
0968 MLXSW_SP_ACL_PROFILE_FLOWER,
0969 MLXSW_SP_ACL_PROFILE_MR,
0970 };
0971
0972 struct mlxsw_afk *mlxsw_sp_acl_afk(struct mlxsw_sp_acl *acl);
0973
0974 int mlxsw_sp_acl_ruleset_bind(struct mlxsw_sp *mlxsw_sp,
0975 struct mlxsw_sp_flow_block *block,
0976 struct mlxsw_sp_flow_block_binding *binding);
0977 void mlxsw_sp_acl_ruleset_unbind(struct mlxsw_sp *mlxsw_sp,
0978 struct mlxsw_sp_flow_block *block,
0979 struct mlxsw_sp_flow_block_binding *binding);
0980 struct mlxsw_sp_acl_ruleset *
0981 mlxsw_sp_acl_ruleset_lookup(struct mlxsw_sp *mlxsw_sp,
0982 struct mlxsw_sp_flow_block *block, u32 chain_index,
0983 enum mlxsw_sp_acl_profile profile);
0984 struct mlxsw_sp_acl_ruleset *
0985 mlxsw_sp_acl_ruleset_get(struct mlxsw_sp *mlxsw_sp,
0986 struct mlxsw_sp_flow_block *block, u32 chain_index,
0987 enum mlxsw_sp_acl_profile profile,
0988 struct mlxsw_afk_element_usage *tmplt_elusage);
0989 void mlxsw_sp_acl_ruleset_put(struct mlxsw_sp *mlxsw_sp,
0990 struct mlxsw_sp_acl_ruleset *ruleset);
0991 u16 mlxsw_sp_acl_ruleset_group_id(struct mlxsw_sp_acl_ruleset *ruleset);
0992 void mlxsw_sp_acl_ruleset_prio_get(struct mlxsw_sp_acl_ruleset *ruleset,
0993 unsigned int *p_min_prio,
0994 unsigned int *p_max_prio);
0995
0996 struct mlxsw_sp_acl_rule_info *
0997 mlxsw_sp_acl_rulei_create(struct mlxsw_sp_acl *acl,
0998 struct mlxsw_afa_block *afa_block);
0999 void mlxsw_sp_acl_rulei_destroy(struct mlxsw_sp_acl_rule_info *rulei);
1000 int mlxsw_sp_acl_rulei_commit(struct mlxsw_sp_acl_rule_info *rulei);
1001 void mlxsw_sp_acl_rulei_priority(struct mlxsw_sp_acl_rule_info *rulei,
1002 unsigned int priority);
1003 void mlxsw_sp_acl_rulei_keymask_u32(struct mlxsw_sp_acl_rule_info *rulei,
1004 enum mlxsw_afk_element element,
1005 u32 key_value, u32 mask_value);
1006 void mlxsw_sp_acl_rulei_keymask_buf(struct mlxsw_sp_acl_rule_info *rulei,
1007 enum mlxsw_afk_element element,
1008 const char *key_value,
1009 const char *mask_value, unsigned int len);
1010 int mlxsw_sp_acl_rulei_act_continue(struct mlxsw_sp_acl_rule_info *rulei);
1011 int mlxsw_sp_acl_rulei_act_jump(struct mlxsw_sp_acl_rule_info *rulei,
1012 u16 group_id);
1013 int mlxsw_sp_acl_rulei_act_terminate(struct mlxsw_sp_acl_rule_info *rulei);
1014 int mlxsw_sp_acl_rulei_act_drop(struct mlxsw_sp_acl_rule_info *rulei,
1015 bool ingress,
1016 const struct flow_action_cookie *fa_cookie,
1017 struct netlink_ext_ack *extack);
1018 int mlxsw_sp_acl_rulei_act_trap(struct mlxsw_sp_acl_rule_info *rulei);
1019 int mlxsw_sp_acl_rulei_act_mirror(struct mlxsw_sp *mlxsw_sp,
1020 struct mlxsw_sp_acl_rule_info *rulei,
1021 struct mlxsw_sp_flow_block *block,
1022 struct net_device *out_dev,
1023 struct netlink_ext_ack *extack);
1024 int mlxsw_sp_acl_rulei_act_fwd(struct mlxsw_sp *mlxsw_sp,
1025 struct mlxsw_sp_acl_rule_info *rulei,
1026 struct net_device *out_dev,
1027 struct netlink_ext_ack *extack);
1028 int mlxsw_sp_acl_rulei_act_vlan(struct mlxsw_sp *mlxsw_sp,
1029 struct mlxsw_sp_acl_rule_info *rulei,
1030 u32 action, u16 vid, u16 proto, u8 prio,
1031 struct netlink_ext_ack *extack);
1032 int mlxsw_sp_acl_rulei_act_priority(struct mlxsw_sp *mlxsw_sp,
1033 struct mlxsw_sp_acl_rule_info *rulei,
1034 u32 prio, struct netlink_ext_ack *extack);
1035 int mlxsw_sp_acl_rulei_act_mangle(struct mlxsw_sp *mlxsw_sp,
1036 struct mlxsw_sp_acl_rule_info *rulei,
1037 enum flow_action_mangle_base htype,
1038 u32 offset, u32 mask, u32 val,
1039 struct netlink_ext_ack *extack);
1040 int mlxsw_sp_acl_rulei_act_police(struct mlxsw_sp *mlxsw_sp,
1041 struct mlxsw_sp_acl_rule_info *rulei,
1042 u32 index, u64 rate_bytes_ps,
1043 u32 burst, struct netlink_ext_ack *extack);
1044 int mlxsw_sp_acl_rulei_act_count(struct mlxsw_sp *mlxsw_sp,
1045 struct mlxsw_sp_acl_rule_info *rulei,
1046 struct netlink_ext_ack *extack);
1047 int mlxsw_sp_acl_rulei_act_fid_set(struct mlxsw_sp *mlxsw_sp,
1048 struct mlxsw_sp_acl_rule_info *rulei,
1049 u16 fid, struct netlink_ext_ack *extack);
1050 int mlxsw_sp_acl_rulei_act_sample(struct mlxsw_sp *mlxsw_sp,
1051 struct mlxsw_sp_acl_rule_info *rulei,
1052 struct mlxsw_sp_flow_block *block,
1053 struct psample_group *psample_group, u32 rate,
1054 u32 trunc_size, bool truncate,
1055 struct netlink_ext_ack *extack);
1056
1057 struct mlxsw_sp_acl_rule;
1058
1059 struct mlxsw_sp_acl_rule *
1060 mlxsw_sp_acl_rule_create(struct mlxsw_sp *mlxsw_sp,
1061 struct mlxsw_sp_acl_ruleset *ruleset,
1062 unsigned long cookie,
1063 struct mlxsw_afa_block *afa_block,
1064 struct netlink_ext_ack *extack);
1065 void mlxsw_sp_acl_rule_destroy(struct mlxsw_sp *mlxsw_sp,
1066 struct mlxsw_sp_acl_rule *rule);
1067 int mlxsw_sp_acl_rule_add(struct mlxsw_sp *mlxsw_sp,
1068 struct mlxsw_sp_acl_rule *rule);
1069 void mlxsw_sp_acl_rule_del(struct mlxsw_sp *mlxsw_sp,
1070 struct mlxsw_sp_acl_rule *rule);
1071 int mlxsw_sp_acl_rule_action_replace(struct mlxsw_sp *mlxsw_sp,
1072 struct mlxsw_sp_acl_rule *rule,
1073 struct mlxsw_afa_block *afa_block);
1074 struct mlxsw_sp_acl_rule *
1075 mlxsw_sp_acl_rule_lookup(struct mlxsw_sp *mlxsw_sp,
1076 struct mlxsw_sp_acl_ruleset *ruleset,
1077 unsigned long cookie);
1078 struct mlxsw_sp_acl_rule_info *
1079 mlxsw_sp_acl_rule_rulei(struct mlxsw_sp_acl_rule *rule);
1080 int mlxsw_sp_acl_rule_get_stats(struct mlxsw_sp *mlxsw_sp,
1081 struct mlxsw_sp_acl_rule *rule,
1082 u64 *packets, u64 *bytes, u64 *drops,
1083 u64 *last_use,
1084 enum flow_action_hw_stats *used_hw_stats);
1085
1086 struct mlxsw_sp_fid *mlxsw_sp_acl_dummy_fid(struct mlxsw_sp *mlxsw_sp);
1087
1088 static inline const struct flow_action_cookie *
1089 mlxsw_sp_acl_act_cookie_lookup(struct mlxsw_sp *mlxsw_sp, u32 cookie_index)
1090 {
1091 return mlxsw_afa_cookie_lookup(mlxsw_sp->afa, cookie_index);
1092 }
1093
1094 int mlxsw_sp_acl_init(struct mlxsw_sp *mlxsw_sp);
1095 void mlxsw_sp_acl_fini(struct mlxsw_sp *mlxsw_sp);
1096 u32 mlxsw_sp_acl_region_rehash_intrvl_get(struct mlxsw_sp *mlxsw_sp);
1097 int mlxsw_sp_acl_region_rehash_intrvl_set(struct mlxsw_sp *mlxsw_sp, u32 val);
1098
1099 struct mlxsw_sp_acl_mangle_action;
1100
1101 struct mlxsw_sp_acl_rulei_ops {
1102 int (*act_mangle_field)(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_acl_rule_info *rulei,
1103 struct mlxsw_sp_acl_mangle_action *mact, u32 val,
1104 struct netlink_ext_ack *extack);
1105 };
1106
1107 extern struct mlxsw_sp_acl_rulei_ops mlxsw_sp1_acl_rulei_ops;
1108 extern struct mlxsw_sp_acl_rulei_ops mlxsw_sp2_acl_rulei_ops;
1109
1110
1111 struct mlxsw_sp_acl_tcam;
1112 struct mlxsw_sp_acl_tcam_region;
1113
1114 struct mlxsw_sp_acl_tcam_ops {
1115 enum mlxsw_reg_ptar_key_type key_type;
1116 size_t priv_size;
1117 int (*init)(struct mlxsw_sp *mlxsw_sp, void *priv,
1118 struct mlxsw_sp_acl_tcam *tcam);
1119 void (*fini)(struct mlxsw_sp *mlxsw_sp, void *priv);
1120 size_t region_priv_size;
1121 int (*region_init)(struct mlxsw_sp *mlxsw_sp, void *region_priv,
1122 void *tcam_priv,
1123 struct mlxsw_sp_acl_tcam_region *region,
1124 void *hints_priv);
1125 void (*region_fini)(struct mlxsw_sp *mlxsw_sp, void *region_priv);
1126 int (*region_associate)(struct mlxsw_sp *mlxsw_sp,
1127 struct mlxsw_sp_acl_tcam_region *region);
1128 void * (*region_rehash_hints_get)(void *region_priv);
1129 void (*region_rehash_hints_put)(void *hints_priv);
1130 size_t chunk_priv_size;
1131 void (*chunk_init)(void *region_priv, void *chunk_priv,
1132 unsigned int priority);
1133 void (*chunk_fini)(void *chunk_priv);
1134 size_t entry_priv_size;
1135 int (*entry_add)(struct mlxsw_sp *mlxsw_sp,
1136 void *region_priv, void *chunk_priv,
1137 void *entry_priv,
1138 struct mlxsw_sp_acl_rule_info *rulei);
1139 void (*entry_del)(struct mlxsw_sp *mlxsw_sp,
1140 void *region_priv, void *chunk_priv,
1141 void *entry_priv);
1142 int (*entry_action_replace)(struct mlxsw_sp *mlxsw_sp,
1143 void *region_priv, void *entry_priv,
1144 struct mlxsw_sp_acl_rule_info *rulei);
1145 int (*entry_activity_get)(struct mlxsw_sp *mlxsw_sp,
1146 void *region_priv, void *entry_priv,
1147 bool *activity);
1148 };
1149
1150
1151 extern const struct mlxsw_sp_acl_tcam_ops mlxsw_sp1_acl_tcam_ops;
1152
1153
1154 extern const struct mlxsw_sp_acl_tcam_ops mlxsw_sp2_acl_tcam_ops;
1155
1156
1157 extern const struct mlxsw_afa_ops mlxsw_sp1_act_afa_ops;
1158 extern const struct mlxsw_afa_ops mlxsw_sp2_act_afa_ops;
1159
1160
1161 extern const struct mlxsw_afk_ops mlxsw_sp1_afk_ops;
1162 extern const struct mlxsw_afk_ops mlxsw_sp2_afk_ops;
1163 extern const struct mlxsw_afk_ops mlxsw_sp4_afk_ops;
1164
1165
1166 extern const struct mlxsw_sp_acl_bf_ops mlxsw_sp2_acl_bf_ops;
1167 extern const struct mlxsw_sp_acl_bf_ops mlxsw_sp4_acl_bf_ops;
1168
1169
1170 struct mlxsw_sp_mall_ops {
1171 int (*sample_add)(struct mlxsw_sp *mlxsw_sp,
1172 struct mlxsw_sp_port *mlxsw_sp_port,
1173 struct mlxsw_sp_mall_entry *mall_entry,
1174 struct netlink_ext_ack *extack);
1175 void (*sample_del)(struct mlxsw_sp *mlxsw_sp,
1176 struct mlxsw_sp_port *mlxsw_sp_port,
1177 struct mlxsw_sp_mall_entry *mall_entry);
1178 };
1179
1180 extern const struct mlxsw_sp_mall_ops mlxsw_sp1_mall_ops;
1181 extern const struct mlxsw_sp_mall_ops mlxsw_sp2_mall_ops;
1182
1183 enum mlxsw_sp_mall_action_type {
1184 MLXSW_SP_MALL_ACTION_TYPE_MIRROR,
1185 MLXSW_SP_MALL_ACTION_TYPE_SAMPLE,
1186 MLXSW_SP_MALL_ACTION_TYPE_TRAP,
1187 };
1188
1189 struct mlxsw_sp_mall_mirror_entry {
1190 const struct net_device *to_dev;
1191 int span_id;
1192 };
1193
1194 struct mlxsw_sp_mall_trap_entry {
1195 int span_id;
1196 };
1197
1198 struct mlxsw_sp_mall_sample_entry {
1199 struct mlxsw_sp_sample_params params;
1200 int span_id;
1201 };
1202
1203 struct mlxsw_sp_mall_entry {
1204 struct list_head list;
1205 unsigned long cookie;
1206 unsigned int priority;
1207 enum mlxsw_sp_mall_action_type type;
1208 bool ingress;
1209 union {
1210 struct mlxsw_sp_mall_mirror_entry mirror;
1211 struct mlxsw_sp_mall_trap_entry trap;
1212 struct mlxsw_sp_mall_sample_entry sample;
1213 };
1214 struct rcu_head rcu;
1215 };
1216
1217 int mlxsw_sp_mall_replace(struct mlxsw_sp *mlxsw_sp,
1218 struct mlxsw_sp_flow_block *block,
1219 struct tc_cls_matchall_offload *f);
1220 void mlxsw_sp_mall_destroy(struct mlxsw_sp_flow_block *block,
1221 struct tc_cls_matchall_offload *f);
1222 int mlxsw_sp_mall_port_bind(struct mlxsw_sp_flow_block *block,
1223 struct mlxsw_sp_port *mlxsw_sp_port,
1224 struct netlink_ext_ack *extack);
1225 void mlxsw_sp_mall_port_unbind(struct mlxsw_sp_flow_block *block,
1226 struct mlxsw_sp_port *mlxsw_sp_port);
1227 int mlxsw_sp_mall_prio_get(struct mlxsw_sp_flow_block *block, u32 chain_index,
1228 unsigned int *p_min_prio, unsigned int *p_max_prio);
1229
1230
1231 int mlxsw_sp_flower_replace(struct mlxsw_sp *mlxsw_sp,
1232 struct mlxsw_sp_flow_block *block,
1233 struct flow_cls_offload *f);
1234 void mlxsw_sp_flower_destroy(struct mlxsw_sp *mlxsw_sp,
1235 struct mlxsw_sp_flow_block *block,
1236 struct flow_cls_offload *f);
1237 int mlxsw_sp_flower_stats(struct mlxsw_sp *mlxsw_sp,
1238 struct mlxsw_sp_flow_block *block,
1239 struct flow_cls_offload *f);
1240 int mlxsw_sp_flower_tmplt_create(struct mlxsw_sp *mlxsw_sp,
1241 struct mlxsw_sp_flow_block *block,
1242 struct flow_cls_offload *f);
1243 void mlxsw_sp_flower_tmplt_destroy(struct mlxsw_sp *mlxsw_sp,
1244 struct mlxsw_sp_flow_block *block,
1245 struct flow_cls_offload *f);
1246 int mlxsw_sp_flower_prio_get(struct mlxsw_sp *mlxsw_sp,
1247 struct mlxsw_sp_flow_block *block,
1248 u32 chain_index, unsigned int *p_min_prio,
1249 unsigned int *p_max_prio);
1250
1251
1252 int mlxsw_sp_tc_qdisc_init(struct mlxsw_sp_port *mlxsw_sp_port);
1253 void mlxsw_sp_tc_qdisc_fini(struct mlxsw_sp_port *mlxsw_sp_port);
1254 int mlxsw_sp_setup_tc_red(struct mlxsw_sp_port *mlxsw_sp_port,
1255 struct tc_red_qopt_offload *p);
1256 int mlxsw_sp_setup_tc_prio(struct mlxsw_sp_port *mlxsw_sp_port,
1257 struct tc_prio_qopt_offload *p);
1258 int mlxsw_sp_setup_tc_ets(struct mlxsw_sp_port *mlxsw_sp_port,
1259 struct tc_ets_qopt_offload *p);
1260 int mlxsw_sp_setup_tc_tbf(struct mlxsw_sp_port *mlxsw_sp_port,
1261 struct tc_tbf_qopt_offload *p);
1262 int mlxsw_sp_setup_tc_fifo(struct mlxsw_sp_port *mlxsw_sp_port,
1263 struct tc_fifo_qopt_offload *p);
1264 int mlxsw_sp_setup_tc_block_qevent_early_drop(struct mlxsw_sp_port *mlxsw_sp_port,
1265 struct flow_block_offload *f);
1266 int mlxsw_sp_setup_tc_block_qevent_mark(struct mlxsw_sp_port *mlxsw_sp_port,
1267 struct flow_block_offload *f);
1268
1269
1270 bool mlxsw_sp_fid_is_dummy(struct mlxsw_sp *mlxsw_sp, u16 fid_index);
1271 struct mlxsw_sp_fid *mlxsw_sp_fid_lookup_by_index(struct mlxsw_sp *mlxsw_sp,
1272 u16 fid_index);
1273 int mlxsw_sp_fid_nve_ifindex(const struct mlxsw_sp_fid *fid, int *nve_ifindex);
1274 int mlxsw_sp_fid_nve_type(const struct mlxsw_sp_fid *fid,
1275 enum mlxsw_sp_nve_type *p_type);
1276 struct mlxsw_sp_fid *mlxsw_sp_fid_lookup_by_vni(struct mlxsw_sp *mlxsw_sp,
1277 __be32 vni);
1278 int mlxsw_sp_fid_vni(const struct mlxsw_sp_fid *fid, __be32 *vni);
1279 int mlxsw_sp_fid_nve_flood_index_set(struct mlxsw_sp_fid *fid,
1280 u32 nve_flood_index);
1281 void mlxsw_sp_fid_nve_flood_index_clear(struct mlxsw_sp_fid *fid);
1282 bool mlxsw_sp_fid_nve_flood_index_is_set(const struct mlxsw_sp_fid *fid);
1283 int mlxsw_sp_fid_vni_set(struct mlxsw_sp_fid *fid, enum mlxsw_sp_nve_type type,
1284 __be32 vni, int nve_ifindex);
1285 void mlxsw_sp_fid_vni_clear(struct mlxsw_sp_fid *fid);
1286 bool mlxsw_sp_fid_vni_is_set(const struct mlxsw_sp_fid *fid);
1287 void mlxsw_sp_fid_fdb_clear_offload(const struct mlxsw_sp_fid *fid,
1288 const struct net_device *nve_dev);
1289 int mlxsw_sp_fid_flood_set(struct mlxsw_sp_fid *fid,
1290 enum mlxsw_sp_flood_type packet_type, u16 local_port,
1291 bool member);
1292 int mlxsw_sp_fid_port_vid_map(struct mlxsw_sp_fid *fid,
1293 struct mlxsw_sp_port *mlxsw_sp_port, u16 vid);
1294 void mlxsw_sp_fid_port_vid_unmap(struct mlxsw_sp_fid *fid,
1295 struct mlxsw_sp_port *mlxsw_sp_port, u16 vid);
1296 u16 mlxsw_sp_fid_index(const struct mlxsw_sp_fid *fid);
1297 enum mlxsw_sp_fid_type mlxsw_sp_fid_type(const struct mlxsw_sp_fid *fid);
1298 int mlxsw_sp_fid_rif_set(struct mlxsw_sp_fid *fid, struct mlxsw_sp_rif *rif);
1299 void mlxsw_sp_fid_rif_unset(struct mlxsw_sp_fid *fid);
1300 struct mlxsw_sp_rif *mlxsw_sp_fid_rif(const struct mlxsw_sp_fid *fid);
1301 enum mlxsw_sp_rif_type
1302 mlxsw_sp_fid_type_rif_type(const struct mlxsw_sp *mlxsw_sp,
1303 enum mlxsw_sp_fid_type type);
1304 u16 mlxsw_sp_fid_8021q_vid(const struct mlxsw_sp_fid *fid);
1305 struct mlxsw_sp_fid *mlxsw_sp_fid_8021q_get(struct mlxsw_sp *mlxsw_sp, u16 vid);
1306 struct mlxsw_sp_fid *mlxsw_sp_fid_8021d_get(struct mlxsw_sp *mlxsw_sp,
1307 int br_ifindex);
1308 struct mlxsw_sp_fid *mlxsw_sp_fid_8021q_lookup(struct mlxsw_sp *mlxsw_sp,
1309 u16 vid);
1310 struct mlxsw_sp_fid *mlxsw_sp_fid_8021d_lookup(struct mlxsw_sp *mlxsw_sp,
1311 int br_ifindex);
1312 struct mlxsw_sp_fid *mlxsw_sp_fid_rfid_get(struct mlxsw_sp *mlxsw_sp,
1313 u16 rif_index);
1314 struct mlxsw_sp_fid *mlxsw_sp_fid_dummy_get(struct mlxsw_sp *mlxsw_sp);
1315 void mlxsw_sp_fid_put(struct mlxsw_sp_fid *fid);
1316 int mlxsw_sp_port_fids_init(struct mlxsw_sp_port *mlxsw_sp_port);
1317 void mlxsw_sp_port_fids_fini(struct mlxsw_sp_port *mlxsw_sp_port);
1318 int mlxsw_sp_fids_init(struct mlxsw_sp *mlxsw_sp);
1319 void mlxsw_sp_fids_fini(struct mlxsw_sp *mlxsw_sp);
1320
1321 extern const struct mlxsw_sp_fid_family *mlxsw_sp1_fid_family_arr[];
1322 extern const struct mlxsw_sp_fid_family *mlxsw_sp2_fid_family_arr[];
1323
1324
1325 enum mlxsw_sp_mr_route_prio {
1326 MLXSW_SP_MR_ROUTE_PRIO_SG,
1327 MLXSW_SP_MR_ROUTE_PRIO_STARG,
1328 MLXSW_SP_MR_ROUTE_PRIO_CATCHALL,
1329 __MLXSW_SP_MR_ROUTE_PRIO_MAX
1330 };
1331
1332 #define MLXSW_SP_MR_ROUTE_PRIO_MAX (__MLXSW_SP_MR_ROUTE_PRIO_MAX - 1)
1333
1334 struct mlxsw_sp_mr_route_key;
1335
1336 struct mlxsw_sp_mr_tcam_ops {
1337 size_t priv_size;
1338 int (*init)(struct mlxsw_sp *mlxsw_sp, void *priv);
1339 void (*fini)(void *priv);
1340 size_t route_priv_size;
1341 int (*route_create)(struct mlxsw_sp *mlxsw_sp, void *priv,
1342 void *route_priv,
1343 struct mlxsw_sp_mr_route_key *key,
1344 struct mlxsw_afa_block *afa_block,
1345 enum mlxsw_sp_mr_route_prio prio);
1346 void (*route_destroy)(struct mlxsw_sp *mlxsw_sp, void *priv,
1347 void *route_priv,
1348 struct mlxsw_sp_mr_route_key *key);
1349 int (*route_update)(struct mlxsw_sp *mlxsw_sp, void *route_priv,
1350 struct mlxsw_sp_mr_route_key *key,
1351 struct mlxsw_afa_block *afa_block);
1352 };
1353
1354
1355 extern const struct mlxsw_sp_mr_tcam_ops mlxsw_sp1_mr_tcam_ops;
1356
1357
1358 extern const struct mlxsw_sp_mr_tcam_ops mlxsw_sp2_mr_tcam_ops;
1359
1360
1361 struct mlxsw_sp_nve_params {
1362 enum mlxsw_sp_nve_type type;
1363 __be32 vni;
1364 const struct net_device *dev;
1365 u16 ethertype;
1366 };
1367
1368 extern const struct mlxsw_sp_nve_ops *mlxsw_sp1_nve_ops_arr[];
1369 extern const struct mlxsw_sp_nve_ops *mlxsw_sp2_nve_ops_arr[];
1370
1371 int mlxsw_sp_nve_learned_ip_resolve(struct mlxsw_sp *mlxsw_sp, u32 uip,
1372 enum mlxsw_sp_l3proto proto,
1373 union mlxsw_sp_l3addr *addr);
1374 int mlxsw_sp_nve_flood_ip_add(struct mlxsw_sp *mlxsw_sp,
1375 struct mlxsw_sp_fid *fid,
1376 enum mlxsw_sp_l3proto proto,
1377 union mlxsw_sp_l3addr *addr);
1378 void mlxsw_sp_nve_flood_ip_del(struct mlxsw_sp *mlxsw_sp,
1379 struct mlxsw_sp_fid *fid,
1380 enum mlxsw_sp_l3proto proto,
1381 union mlxsw_sp_l3addr *addr);
1382 int mlxsw_sp_nve_ipv6_addr_kvdl_set(struct mlxsw_sp *mlxsw_sp,
1383 const struct in6_addr *addr6,
1384 u32 *p_kvdl_index);
1385 void mlxsw_sp_nve_ipv6_addr_kvdl_unset(struct mlxsw_sp *mlxsw_sp,
1386 const struct in6_addr *addr6);
1387 int
1388 mlxsw_sp_nve_ipv6_addr_map_replace(struct mlxsw_sp *mlxsw_sp, const char *mac,
1389 u16 fid_index,
1390 const struct in6_addr *new_addr6);
1391 void mlxsw_sp_nve_ipv6_addr_map_del(struct mlxsw_sp *mlxsw_sp, const char *mac,
1392 u16 fid_index);
1393 int mlxsw_sp_nve_fid_enable(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_fid *fid,
1394 struct mlxsw_sp_nve_params *params,
1395 struct netlink_ext_ack *extack);
1396 void mlxsw_sp_nve_fid_disable(struct mlxsw_sp *mlxsw_sp,
1397 struct mlxsw_sp_fid *fid);
1398 int mlxsw_sp_port_nve_init(struct mlxsw_sp_port *mlxsw_sp_port);
1399 void mlxsw_sp_port_nve_fini(struct mlxsw_sp_port *mlxsw_sp_port);
1400 int mlxsw_sp_nve_init(struct mlxsw_sp *mlxsw_sp);
1401 void mlxsw_sp_nve_fini(struct mlxsw_sp *mlxsw_sp);
1402
1403
1404 int mlxsw_sp_nve_inc_parsing_depth_get(struct mlxsw_sp *mlxsw_sp);
1405 void mlxsw_sp_nve_inc_parsing_depth_put(struct mlxsw_sp *mlxsw_sp);
1406
1407
1408 int mlxsw_sp_devlink_traps_init(struct mlxsw_sp *mlxsw_sp);
1409 void mlxsw_sp_devlink_traps_fini(struct mlxsw_sp *mlxsw_sp);
1410 int mlxsw_sp_trap_init(struct mlxsw_core *mlxsw_core,
1411 const struct devlink_trap *trap, void *trap_ctx);
1412 void mlxsw_sp_trap_fini(struct mlxsw_core *mlxsw_core,
1413 const struct devlink_trap *trap, void *trap_ctx);
1414 int mlxsw_sp_trap_action_set(struct mlxsw_core *mlxsw_core,
1415 const struct devlink_trap *trap,
1416 enum devlink_trap_action action,
1417 struct netlink_ext_ack *extack);
1418 int mlxsw_sp_trap_group_init(struct mlxsw_core *mlxsw_core,
1419 const struct devlink_trap_group *group);
1420 int mlxsw_sp_trap_group_set(struct mlxsw_core *mlxsw_core,
1421 const struct devlink_trap_group *group,
1422 const struct devlink_trap_policer *policer,
1423 struct netlink_ext_ack *extack);
1424 int
1425 mlxsw_sp_trap_policer_init(struct mlxsw_core *mlxsw_core,
1426 const struct devlink_trap_policer *policer);
1427 void mlxsw_sp_trap_policer_fini(struct mlxsw_core *mlxsw_core,
1428 const struct devlink_trap_policer *policer);
1429 int
1430 mlxsw_sp_trap_policer_set(struct mlxsw_core *mlxsw_core,
1431 const struct devlink_trap_policer *policer,
1432 u64 rate, u64 burst, struct netlink_ext_ack *extack);
1433 int
1434 mlxsw_sp_trap_policer_counter_get(struct mlxsw_core *mlxsw_core,
1435 const struct devlink_trap_policer *policer,
1436 u64 *p_drops);
1437 int mlxsw_sp_trap_group_policer_hw_id_get(struct mlxsw_sp *mlxsw_sp, u16 id,
1438 bool *p_enabled, u16 *p_hw_id);
1439
1440 static inline struct net *mlxsw_sp_net(struct mlxsw_sp *mlxsw_sp)
1441 {
1442 return mlxsw_core_net(mlxsw_sp->core);
1443 }
1444
1445
1446 extern const struct ethtool_ops mlxsw_sp_port_ethtool_ops;
1447 extern const struct mlxsw_sp_port_type_speed_ops mlxsw_sp1_port_type_speed_ops;
1448 extern const struct mlxsw_sp_port_type_speed_ops mlxsw_sp2_port_type_speed_ops;
1449
1450
1451 extern const struct mlxsw_sp_policer_core_ops mlxsw_sp1_policer_core_ops;
1452 extern const struct mlxsw_sp_policer_core_ops mlxsw_sp2_policer_core_ops;
1453
1454 enum mlxsw_sp_policer_type {
1455 MLXSW_SP_POLICER_TYPE_SINGLE_RATE,
1456
1457 __MLXSW_SP_POLICER_TYPE_MAX,
1458 MLXSW_SP_POLICER_TYPE_MAX = __MLXSW_SP_POLICER_TYPE_MAX - 1,
1459 };
1460
1461 struct mlxsw_sp_policer_params {
1462 u64 rate;
1463 u64 burst;
1464 bool bytes;
1465 };
1466
1467 int mlxsw_sp_policer_add(struct mlxsw_sp *mlxsw_sp,
1468 enum mlxsw_sp_policer_type type,
1469 const struct mlxsw_sp_policer_params *params,
1470 struct netlink_ext_ack *extack, u16 *p_policer_index);
1471 void mlxsw_sp_policer_del(struct mlxsw_sp *mlxsw_sp,
1472 enum mlxsw_sp_policer_type type,
1473 u16 policer_index);
1474 int mlxsw_sp_policer_drops_counter_get(struct mlxsw_sp *mlxsw_sp,
1475 enum mlxsw_sp_policer_type type,
1476 u16 policer_index, u64 *p_drops);
1477 int mlxsw_sp_policers_init(struct mlxsw_sp *mlxsw_sp);
1478 void mlxsw_sp_policers_fini(struct mlxsw_sp *mlxsw_sp);
1479 int mlxsw_sp_policer_resources_register(struct mlxsw_core *mlxsw_core);
1480
1481
1482 int mlxsw_sp_pgt_mid_alloc(struct mlxsw_sp *mlxsw_sp, u16 *p_mid);
1483 void mlxsw_sp_pgt_mid_free(struct mlxsw_sp *mlxsw_sp, u16 mid_base);
1484 int mlxsw_sp_pgt_mid_alloc_range(struct mlxsw_sp *mlxsw_sp, u16 mid_base,
1485 u16 count);
1486 void mlxsw_sp_pgt_mid_free_range(struct mlxsw_sp *mlxsw_sp, u16 mid_base,
1487 u16 count);
1488 int mlxsw_sp_pgt_entry_port_set(struct mlxsw_sp *mlxsw_sp, u16 mid,
1489 u16 smpe, u16 local_port, bool member);
1490 int mlxsw_sp_pgt_init(struct mlxsw_sp *mlxsw_sp);
1491 void mlxsw_sp_pgt_fini(struct mlxsw_sp *mlxsw_sp);
1492
1493 #endif