1 /* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */ 2 /* Copyright (c) 2015-2018 Mellanox Technologies. All rights reserved */ 3 4 #ifndef _MLXSW_SPECTRUM_H 5 #define _MLXSW_SPECTRUM_H 6 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> 22 #include <net/red.h> 23 #include <net/vxlan.h> 24 #include <net/flow_offload.h> 25 #include <net/inet_ecn.h> 26 27 #include "port.h" 28 #include "core.h" 29 #include "core_acl_flex_keys.h" 30 #include "core_acl_flex_actions.h" 31 #include "reg.h" 32 33 #define MLXSW_SP_DEFAULT_VID (VLAN_N_VID - 1) 34 35 #define MLXSW_SP_FID_8021D_MAX 1024 36 37 #define MLXSW_SP_MID_MAX 7000 38 39 #define MLXSW_SP_KVD_LINEAR_SIZE 98304 /* entries */ 40 #define MLXSW_SP_KVD_GRANULARITY 128 41 42 #define MLXSW_SP_RESOURCE_NAME_KVD "kvd" 43 #define MLXSW_SP_RESOURCE_NAME_KVD_LINEAR "linear" 44 #define MLXSW_SP_RESOURCE_NAME_KVD_HASH_SINGLE "hash_single" 45 #define MLXSW_SP_RESOURCE_NAME_KVD_HASH_DOUBLE "hash_double" 46 #define MLXSW_SP_RESOURCE_NAME_KVD_LINEAR_SINGLES "singles" 47 #define MLXSW_SP_RESOURCE_NAME_KVD_LINEAR_CHUNKS "chunks" 48 #define MLXSW_SP_RESOURCE_NAME_KVD_LINEAR_LARGE_CHUNKS "large_chunks" 49 50 #define MLXSW_SP_RESOURCE_NAME_SPAN "span_agents" 51 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" 55 56 enum mlxsw_sp_resource_id { 57 MLXSW_SP_RESOURCE_KVD = MLXSW_CORE_RESOURCE_MAX, 58 MLXSW_SP_RESOURCE_KVD_LINEAR, 59 MLXSW_SP_RESOURCE_KVD_HASH_SINGLE, 60 MLXSW_SP_RESOURCE_KVD_HASH_DOUBLE, 61 MLXSW_SP_RESOURCE_KVD_LINEAR_SINGLE, 62 MLXSW_SP_RESOURCE_KVD_LINEAR_CHUNKS, 63 MLXSW_SP_RESOURCE_KVD_LINEAR_LARGE_CHUNKS, 64 MLXSW_SP_RESOURCE_SPAN, 65 MLXSW_SP_RESOURCE_COUNTERS, 66 MLXSW_SP_RESOURCE_COUNTERS_FLOW, 67 MLXSW_SP_RESOURCE_COUNTERS_RIF, 68 MLXSW_SP_RESOURCE_GLOBAL_POLICERS, 69 MLXSW_SP_RESOURCE_SINGLE_RATE_POLICERS, 70 MLXSW_SP_RESOURCE_RIF_MAC_PROFILES, 71 MLXSW_SP_RESOURCE_RIFS, 72 }; 73 74 struct mlxsw_sp_port; 75 struct mlxsw_sp_rif; 76 struct mlxsw_sp_span_entry; 77 enum mlxsw_sp_l3proto; 78 union mlxsw_sp_l3addr; 79 80 struct mlxsw_sp_upper { 81 struct net_device *dev; 82 unsigned int ref_count; 83 }; 84 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, 91 }; 92 93 struct mlxsw_sp_router_ops; 94 95 extern const struct mlxsw_sp_router_ops mlxsw_sp1_router_ops; 96 extern const struct mlxsw_sp_router_ops mlxsw_sp2_router_ops; 97 98 struct mlxsw_sp_switchdev_ops; 99 100 extern const struct mlxsw_sp_switchdev_ops mlxsw_sp1_switchdev_ops; 101 extern const struct mlxsw_sp_switchdev_ops mlxsw_sp2_switchdev_ops; 102 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, 109 }; 110 111 enum mlxsw_sp_nve_type { 112 MLXSW_SP_NVE_TYPE_VXLAN, 113 }; 114 115 struct mlxsw_sp_sb; 116 struct mlxsw_sp_bridge; 117 struct mlxsw_sp_router; 118 struct mlxsw_sp_mr; 119 struct mlxsw_sp_acl; 120 struct mlxsw_sp_counter_pool; 121 struct mlxsw_sp_fid_core; 122 struct mlxsw_sp_kvdl; 123 struct mlxsw_sp_nve; 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; 137 struct mlxsw_sp_pgt; 138 139 struct mlxsw_sp_port_mapping { 140 u8 module; 141 u8 slot_index; 142 u8 width; /* Number of lanes used by the port */ 143 u8 module_width; /* Number of lanes in the module (static) */ 144 u8 lane; 145 }; 146 147 struct mlxsw_sp_port_mapping_events { 148 struct list_head queue; 149 spinlock_t queue_lock; /* protects queue */ 150 struct work_struct work; 151 }; 152 153 struct mlxsw_sp_parsing { 154 refcount_t parsing_depth_ref; 155 u16 parsing_depth; 156 u16 vxlan_udp_dport; 157 struct mutex lock; /* Protects parsing configuration */ 158 }; 159 160 struct mlxsw_sp { 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_kvdl *kvdl; 179 struct mlxsw_sp_nve *nve; 180 struct notifier_block netdevice_nb; 181 struct mlxsw_sp_ptp_clock *clock; 182 struct mlxsw_sp_ptp_state *ptp_state; 183 struct mlxsw_sp_counter_pool *counter_pool; 184 struct mlxsw_sp_span *span; 185 struct mlxsw_sp_trap *trap; 186 struct mlxsw_sp_parsing parsing; 187 const struct mlxsw_sp_switchdev_ops *switchdev_ops; 188 const struct mlxsw_sp_kvdl_ops *kvdl_ops; 189 const struct mlxsw_afa_ops *afa_ops; 190 const struct mlxsw_afk_ops *afk_ops; 191 const struct mlxsw_sp_mr_tcam_ops *mr_tcam_ops; 192 const struct mlxsw_sp_acl_rulei_ops *acl_rulei_ops; 193 const struct mlxsw_sp_acl_tcam_ops *acl_tcam_ops; 194 const struct mlxsw_sp_acl_bf_ops *acl_bf_ops; 195 const struct mlxsw_sp_nve_ops **nve_ops_arr; 196 const struct mlxsw_sp_sb_vals *sb_vals; 197 const struct mlxsw_sp_sb_ops *sb_ops; 198 const struct mlxsw_sp_port_type_speed_ops *port_type_speed_ops; 199 const struct mlxsw_sp_ptp_ops *ptp_ops; 200 const struct mlxsw_sp_span_ops *span_ops; 201 const struct mlxsw_sp_policer_core_ops *policer_core_ops; 202 const struct mlxsw_sp_trap_ops *trap_ops; 203 const struct mlxsw_sp_mall_ops *mall_ops; 204 const struct mlxsw_sp_router_ops *router_ops; 205 const struct mlxsw_listener *listeners; 206 const struct mlxsw_sp_fid_family **fid_family_arr; 207 size_t listeners_count; 208 u32 lowest_shaper_bs; 209 struct rhashtable ipv6_addr_ht; 210 struct mutex ipv6_addr_ht_lock; /* Protects ipv6_addr_ht */ 211 struct mlxsw_sp_pgt *pgt; 212 bool pgt_smpe_index_valid; 213 }; 214 215 struct mlxsw_sp_ptp_ops { 216 struct mlxsw_sp_ptp_clock * 217 (*clock_init)(struct mlxsw_sp *mlxsw_sp, struct device *dev); 218 void (*clock_fini)(struct mlxsw_sp_ptp_clock *clock); 219 220 struct mlxsw_sp_ptp_state *(*init)(struct mlxsw_sp *mlxsw_sp); 221 void (*fini)(struct mlxsw_sp_ptp_state *ptp_state); 222 223 /* Notify a driver that a packet that might be PTP was received. Driver 224 * is responsible for freeing the passed-in SKB. 225 */ 226 void (*receive)(struct mlxsw_sp *mlxsw_sp, struct sk_buff *skb, 227 u16 local_port); 228 229 /* Notify a driver that a timestamped packet was transmitted. Driver 230 * is responsible for freeing the passed-in SKB. 231 */ 232 void (*transmitted)(struct mlxsw_sp *mlxsw_sp, struct sk_buff *skb, 233 u16 local_port); 234 235 int (*hwtstamp_get)(struct mlxsw_sp_port *mlxsw_sp_port, 236 struct hwtstamp_config *config); 237 int (*hwtstamp_set)(struct mlxsw_sp_port *mlxsw_sp_port, 238 struct hwtstamp_config *config); 239 void (*shaper_work)(struct work_struct *work); 240 int (*get_ts_info)(struct mlxsw_sp *mlxsw_sp, 241 struct ethtool_ts_info *info); 242 int (*get_stats_count)(void); 243 void (*get_stats_strings)(u8 **p); 244 void (*get_stats)(struct mlxsw_sp_port *mlxsw_sp_port, 245 u64 *data, int data_index); 246 }; 247 248 static inline struct mlxsw_sp_upper * 249 mlxsw_sp_lag_get(struct mlxsw_sp *mlxsw_sp, u16 lag_id) 250 { 251 return &mlxsw_sp->lags[lag_id]; 252 } 253 254 struct mlxsw_sp_port_pcpu_stats { 255 u64 rx_packets; 256 u64 rx_bytes; 257 u64 tx_packets; 258 u64 tx_bytes; 259 struct u64_stats_sync syncp; 260 u32 tx_dropped; 261 }; 262 263 enum mlxsw_sp_sample_trigger_type { 264 MLXSW_SP_SAMPLE_TRIGGER_TYPE_INGRESS, 265 MLXSW_SP_SAMPLE_TRIGGER_TYPE_EGRESS, 266 MLXSW_SP_SAMPLE_TRIGGER_TYPE_POLICY_ENGINE, 267 }; 268 269 struct mlxsw_sp_sample_trigger { 270 enum mlxsw_sp_sample_trigger_type type; 271 u16 local_port; /* Reserved when trigger type is not ingress / egress. */ 272 }; 273 274 struct mlxsw_sp_sample_params { 275 struct psample_group *psample_group; 276 u32 trunc_size; 277 u32 rate; 278 bool truncate; 279 }; 280 281 struct mlxsw_sp_bridge_port; 282 struct mlxsw_sp_fid; 283 284 struct mlxsw_sp_port_vlan { 285 struct list_head list; 286 struct mlxsw_sp_port *mlxsw_sp_port; 287 struct mlxsw_sp_fid *fid; 288 u16 vid; 289 struct mlxsw_sp_bridge_port *bridge_port; 290 struct list_head bridge_vlan_node; 291 }; 292 293 /* No need an internal lock; At worse - miss a single periodic iteration */ 294 struct mlxsw_sp_port_xstats { 295 u64 ecn; 296 u64 tc_ecn[TC_MAX_QUEUE]; 297 u64 wred_drop[TC_MAX_QUEUE]; 298 u64 tail_drop[TC_MAX_QUEUE]; 299 u64 backlog[TC_MAX_QUEUE]; 300 u64 tx_bytes[IEEE_8021QAZ_MAX_TCS]; 301 u64 tx_packets[IEEE_8021QAZ_MAX_TCS]; 302 }; 303 304 struct mlxsw_sp_ptp_port_dir_stats { 305 u64 packets; 306 u64 timestamps; 307 }; 308 309 struct mlxsw_sp_ptp_port_stats { 310 struct mlxsw_sp_ptp_port_dir_stats rx_gcd; 311 struct mlxsw_sp_ptp_port_dir_stats tx_gcd; 312 }; 313 314 struct mlxsw_sp_port { 315 struct net_device *dev; 316 struct mlxsw_sp_port_pcpu_stats __percpu *pcpu_stats; 317 struct mlxsw_sp *mlxsw_sp; 318 u16 local_port; 319 u8 lagged:1, 320 split:1; 321 u16 pvid; 322 u16 lag_id; 323 struct { 324 u8 tx_pause:1, 325 rx_pause:1, 326 autoneg:1; 327 } link; 328 struct { 329 struct ieee_ets *ets; 330 struct ieee_maxrate *maxrate; 331 struct ieee_pfc *pfc; 332 enum mlxsw_reg_qpts_trust_state trust_state; 333 } dcb; 334 struct mlxsw_sp_port_mapping mapping; /* mapping is constant during the 335 * mlxsw_sp_port lifetime, however 336 * the same localport can have 337 * different mapping. 338 */ 339 struct { 340 #define MLXSW_HW_STATS_UPDATE_TIME HZ 341 struct rtnl_link_stats64 stats; 342 struct mlxsw_sp_port_xstats xstats; 343 struct delayed_work update_dw; 344 } periodic_hw_stats; 345 struct list_head vlans_list; 346 struct mlxsw_sp_port_vlan *default_vlan; 347 struct mlxsw_sp_qdisc_state *qdisc; 348 unsigned acl_rule_count; 349 struct mlxsw_sp_flow_block *ing_flow_block; 350 struct mlxsw_sp_flow_block *eg_flow_block; 351 struct { 352 struct delayed_work shaper_dw; 353 struct hwtstamp_config hwtstamp_config; 354 u16 ing_types; 355 u16 egr_types; 356 struct mlxsw_sp_ptp_port_stats stats; 357 } ptp; 358 int max_mtu; 359 u32 max_speed; 360 struct mlxsw_sp_hdroom *hdroom; 361 u64 module_overheat_initial_val; 362 }; 363 364 struct mlxsw_sp_port_type_speed_ops { 365 void (*from_ptys_supported_port)(struct mlxsw_sp *mlxsw_sp, 366 u32 ptys_eth_proto, 367 struct ethtool_link_ksettings *cmd); 368 void (*from_ptys_link)(struct mlxsw_sp *mlxsw_sp, u32 ptys_eth_proto, 369 unsigned long *mode); 370 u32 (*from_ptys_speed)(struct mlxsw_sp *mlxsw_sp, u32 ptys_eth_proto); 371 void (*from_ptys_link_mode)(struct mlxsw_sp *mlxsw_sp, 372 bool carrier_ok, u32 ptys_eth_proto, 373 struct ethtool_link_ksettings *cmd); 374 int (*ptys_max_speed)(struct mlxsw_sp_port *mlxsw_sp_port, u32 *p_max_speed); 375 u32 (*to_ptys_advert_link)(struct mlxsw_sp *mlxsw_sp, 376 const struct ethtool_link_ksettings *cmd); 377 u32 (*to_ptys_speed_lanes)(struct mlxsw_sp *mlxsw_sp, u8 width, 378 const struct ethtool_link_ksettings *cmd); 379 void (*reg_ptys_eth_pack)(struct mlxsw_sp *mlxsw_sp, char *payload, 380 u16 local_port, u32 proto_admin, bool autoneg); 381 void (*reg_ptys_eth_unpack)(struct mlxsw_sp *mlxsw_sp, char *payload, 382 u32 *p_eth_proto_cap, 383 u32 *p_eth_proto_admin, 384 u32 *p_eth_proto_oper); 385 u32 (*ptys_proto_cap_masked_get)(u32 eth_proto_cap); 386 }; 387 388 struct mlxsw_sp_ports_bitmap { 389 unsigned long *bitmap; 390 unsigned int nbits; 391 }; 392 393 static inline int 394 mlxsw_sp_port_bitmap_init(struct mlxsw_sp *mlxsw_sp, 395 struct mlxsw_sp_ports_bitmap *ports_bm) 396 { 397 unsigned int nbits = mlxsw_core_max_ports(mlxsw_sp->core); 398 399 ports_bm->nbits = nbits; 400 ports_bm->bitmap = bitmap_zalloc(nbits, GFP_KERNEL); 401 if (!ports_bm->bitmap) 402 return -ENOMEM; 403 404 return 0; 405 } 406 407 static inline void 408 mlxsw_sp_port_bitmap_fini(struct mlxsw_sp_ports_bitmap *ports_bm) 409 { 410 bitmap_free(ports_bm->bitmap); 411 } 412 413 static inline u8 mlxsw_sp_tunnel_ecn_decap(u8 outer_ecn, u8 inner_ecn, 414 bool *trap_en) 415 { 416 bool set_ce = false; 417 418 *trap_en = !!__INET_ECN_decapsulate(outer_ecn, inner_ecn, &set_ce); 419 if (set_ce) 420 return INET_ECN_CE; 421 else if (outer_ecn == INET_ECN_ECT_1 && inner_ecn == INET_ECN_ECT_0) 422 return INET_ECN_ECT_1; 423 else 424 return inner_ecn; 425 } 426 427 static inline struct net_device * 428 mlxsw_sp_bridge_vxlan_dev_find(struct net_device *br_dev) 429 { 430 struct net_device *dev; 431 struct list_head *iter; 432 433 netdev_for_each_lower_dev(br_dev, dev, iter) { 434 if (netif_is_vxlan(dev)) 435 return dev; 436 } 437 438 return NULL; 439 } 440 441 static inline bool mlxsw_sp_bridge_has_vxlan(struct net_device *br_dev) 442 { 443 return !!mlxsw_sp_bridge_vxlan_dev_find(br_dev); 444 } 445 446 static inline int 447 mlxsw_sp_vxlan_mapped_vid(const struct net_device *vxlan_dev, u16 *p_vid) 448 { 449 struct bridge_vlan_info vinfo; 450 u16 vid = 0; 451 int err; 452 453 err = br_vlan_get_pvid(vxlan_dev, &vid); 454 if (err || !vid) 455 goto out; 456 457 err = br_vlan_get_info(vxlan_dev, vid, &vinfo); 458 if (err || !(vinfo.flags & BRIDGE_VLAN_INFO_UNTAGGED)) 459 vid = 0; 460 461 out: 462 *p_vid = vid; 463 return err; 464 } 465 466 static inline bool 467 mlxsw_sp_port_is_pause_en(const struct mlxsw_sp_port *mlxsw_sp_port) 468 { 469 return mlxsw_sp_port->link.tx_pause || mlxsw_sp_port->link.rx_pause; 470 } 471 472 static inline struct mlxsw_sp_port * 473 mlxsw_sp_port_lagged_get(struct mlxsw_sp *mlxsw_sp, u16 lag_id, u8 port_index) 474 { 475 struct mlxsw_sp_port *mlxsw_sp_port; 476 u16 local_port; 477 478 local_port = mlxsw_core_lag_mapping_get(mlxsw_sp->core, 479 lag_id, port_index); 480 mlxsw_sp_port = mlxsw_sp->ports[local_port]; 481 return mlxsw_sp_port && mlxsw_sp_port->lagged ? mlxsw_sp_port : NULL; 482 } 483 484 static inline struct mlxsw_sp_port_vlan * 485 mlxsw_sp_port_vlan_find_by_vid(const struct mlxsw_sp_port *mlxsw_sp_port, 486 u16 vid) 487 { 488 struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan; 489 490 list_for_each_entry(mlxsw_sp_port_vlan, &mlxsw_sp_port->vlans_list, 491 list) { 492 if (mlxsw_sp_port_vlan->vid == vid) 493 return mlxsw_sp_port_vlan; 494 } 495 496 return NULL; 497 } 498 499 enum mlxsw_sp_flood_type { 500 MLXSW_SP_FLOOD_TYPE_UC, 501 MLXSW_SP_FLOOD_TYPE_BC, 502 MLXSW_SP_FLOOD_TYPE_MC, 503 }; 504 505 int mlxsw_sp_port_get_stats_raw(struct net_device *dev, int grp, 506 int prio, char *ppcnt_pl); 507 int mlxsw_sp_port_admin_status_set(struct mlxsw_sp_port *mlxsw_sp_port, 508 bool is_up); 509 int 510 mlxsw_sp_port_vlan_classification_set(struct mlxsw_sp_port *mlxsw_sp_port, 511 bool is_8021ad_tagged, 512 bool is_8021q_tagged); 513 static inline bool 514 mlxsw_sp_local_port_is_valid(struct mlxsw_sp *mlxsw_sp, u16 local_port) 515 { 516 unsigned int max_ports = mlxsw_core_max_ports(mlxsw_sp->core); 517 518 return local_port < max_ports && local_port; 519 } 520 521 /* spectrum_buffers.c */ 522 struct mlxsw_sp_hdroom_prio { 523 /* Number of port buffer associated with this priority. This is the 524 * actually configured value. 525 */ 526 u8 buf_idx; 527 /* Value of buf_idx deduced from the DCB ETS configuration. */ 528 u8 ets_buf_idx; 529 /* Value of buf_idx taken from the dcbnl_setbuffer configuration. */ 530 u8 set_buf_idx; 531 bool lossy; 532 }; 533 534 struct mlxsw_sp_hdroom_buf { 535 u32 thres_cells; 536 u32 size_cells; 537 /* Size requirement form dcbnl_setbuffer. */ 538 u32 set_size_cells; 539 bool lossy; 540 }; 541 542 enum mlxsw_sp_hdroom_mode { 543 MLXSW_SP_HDROOM_MODE_DCB, 544 MLXSW_SP_HDROOM_MODE_TC, 545 }; 546 547 #define MLXSW_SP_PB_COUNT 10 548 549 struct mlxsw_sp_hdroom { 550 enum mlxsw_sp_hdroom_mode mode; 551 552 struct { 553 struct mlxsw_sp_hdroom_prio prio[IEEE_8021Q_MAX_PRIORITIES]; 554 } prios; 555 struct { 556 struct mlxsw_sp_hdroom_buf buf[MLXSW_SP_PB_COUNT]; 557 } bufs; 558 struct { 559 /* Size actually configured for the internal buffer. Equal to 560 * reserve when internal buffer is enabled. 561 */ 562 u32 size_cells; 563 /* Space reserved in the headroom for the internal buffer. Port 564 * buffers are not allowed to grow into this space. 565 */ 566 u32 reserve_cells; 567 bool enable; 568 } int_buf; 569 int delay_bytes; 570 int mtu; 571 }; 572 573 int mlxsw_sp_buffers_init(struct mlxsw_sp *mlxsw_sp); 574 void mlxsw_sp_buffers_fini(struct mlxsw_sp *mlxsw_sp); 575 int mlxsw_sp_port_buffers_init(struct mlxsw_sp_port *mlxsw_sp_port); 576 void mlxsw_sp_port_buffers_fini(struct mlxsw_sp_port *mlxsw_sp_port); 577 int mlxsw_sp_sb_pool_get(struct mlxsw_core *mlxsw_core, 578 unsigned int sb_index, u16 pool_index, 579 struct devlink_sb_pool_info *pool_info); 580 int mlxsw_sp_sb_pool_set(struct mlxsw_core *mlxsw_core, 581 unsigned int sb_index, u16 pool_index, u32 size, 582 enum devlink_sb_threshold_type threshold_type, 583 struct netlink_ext_ack *extack); 584 int mlxsw_sp_sb_port_pool_get(struct mlxsw_core_port *mlxsw_core_port, 585 unsigned int sb_index, u16 pool_index, 586 u32 *p_threshold); 587 int mlxsw_sp_sb_port_pool_set(struct mlxsw_core_port *mlxsw_core_port, 588 unsigned int sb_index, u16 pool_index, 589 u32 threshold, struct netlink_ext_ack *extack); 590 int mlxsw_sp_sb_tc_pool_bind_get(struct mlxsw_core_port *mlxsw_core_port, 591 unsigned int sb_index, u16 tc_index, 592 enum devlink_sb_pool_type pool_type, 593 u16 *p_pool_index, u32 *p_threshold); 594 int mlxsw_sp_sb_tc_pool_bind_set(struct mlxsw_core_port *mlxsw_core_port, 595 unsigned int sb_index, u16 tc_index, 596 enum devlink_sb_pool_type pool_type, 597 u16 pool_index, u32 threshold, 598 struct netlink_ext_ack *extack); 599 int mlxsw_sp_sb_occ_snapshot(struct mlxsw_core *mlxsw_core, 600 unsigned int sb_index); 601 int mlxsw_sp_sb_occ_max_clear(struct mlxsw_core *mlxsw_core, 602 unsigned int sb_index); 603 int mlxsw_sp_sb_occ_port_pool_get(struct mlxsw_core_port *mlxsw_core_port, 604 unsigned int sb_index, u16 pool_index, 605 u32 *p_cur, u32 *p_max); 606 int mlxsw_sp_sb_occ_tc_port_bind_get(struct mlxsw_core_port *mlxsw_core_port, 607 unsigned int sb_index, u16 tc_index, 608 enum devlink_sb_pool_type pool_type, 609 u32 *p_cur, u32 *p_max); 610 u32 mlxsw_sp_cells_bytes(const struct mlxsw_sp *mlxsw_sp, u32 cells); 611 u32 mlxsw_sp_bytes_cells(const struct mlxsw_sp *mlxsw_sp, u32 bytes); 612 void mlxsw_sp_hdroom_prios_reset_buf_idx(struct mlxsw_sp_hdroom *hdroom); 613 void mlxsw_sp_hdroom_bufs_reset_lossiness(struct mlxsw_sp_hdroom *hdroom); 614 void mlxsw_sp_hdroom_bufs_reset_sizes(struct mlxsw_sp_port *mlxsw_sp_port, 615 struct mlxsw_sp_hdroom *hdroom); 616 int mlxsw_sp_hdroom_configure(struct mlxsw_sp_port *mlxsw_sp_port, 617 const struct mlxsw_sp_hdroom *hdroom); 618 struct mlxsw_sp_sample_params * 619 mlxsw_sp_sample_trigger_params_lookup(struct mlxsw_sp *mlxsw_sp, 620 const struct mlxsw_sp_sample_trigger *trigger); 621 int 622 mlxsw_sp_sample_trigger_params_set(struct mlxsw_sp *mlxsw_sp, 623 const struct mlxsw_sp_sample_trigger *trigger, 624 const struct mlxsw_sp_sample_params *params, 625 struct netlink_ext_ack *extack); 626 void 627 mlxsw_sp_sample_trigger_params_unset(struct mlxsw_sp *mlxsw_sp, 628 const struct mlxsw_sp_sample_trigger *trigger); 629 int mlxsw_sp_ipv6_addr_kvdl_index_get(struct mlxsw_sp *mlxsw_sp, 630 const struct in6_addr *addr6, 631 u32 *p_kvdl_index); 632 void 633 mlxsw_sp_ipv6_addr_put(struct mlxsw_sp *mlxsw_sp, const struct in6_addr *addr6); 634 635 extern const struct mlxsw_sp_sb_vals mlxsw_sp1_sb_vals; 636 extern const struct mlxsw_sp_sb_vals mlxsw_sp2_sb_vals; 637 638 extern const struct mlxsw_sp_sb_ops mlxsw_sp1_sb_ops; 639 extern const struct mlxsw_sp_sb_ops mlxsw_sp2_sb_ops; 640 extern const struct mlxsw_sp_sb_ops mlxsw_sp3_sb_ops; 641 642 /* spectrum_switchdev.c */ 643 int mlxsw_sp_switchdev_init(struct mlxsw_sp *mlxsw_sp); 644 void mlxsw_sp_switchdev_fini(struct mlxsw_sp *mlxsw_sp); 645 int mlxsw_sp_rif_fdb_op(struct mlxsw_sp *mlxsw_sp, const char *mac, u16 fid, 646 bool adding); 647 void 648 mlxsw_sp_port_vlan_bridge_leave(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan); 649 int mlxsw_sp_port_bridge_join(struct mlxsw_sp_port *mlxsw_sp_port, 650 struct net_device *brport_dev, 651 struct net_device *br_dev, 652 struct netlink_ext_ack *extack); 653 void mlxsw_sp_port_bridge_leave(struct mlxsw_sp_port *mlxsw_sp_port, 654 struct net_device *brport_dev, 655 struct net_device *br_dev); 656 bool mlxsw_sp_bridge_device_is_offloaded(const struct mlxsw_sp *mlxsw_sp, 657 const struct net_device *br_dev); 658 int mlxsw_sp_bridge_vxlan_join(struct mlxsw_sp *mlxsw_sp, 659 const struct net_device *br_dev, 660 const struct net_device *vxlan_dev, u16 vid, 661 struct netlink_ext_ack *extack); 662 void mlxsw_sp_bridge_vxlan_leave(struct mlxsw_sp *mlxsw_sp, 663 const struct net_device *vxlan_dev); 664 extern struct notifier_block mlxsw_sp_switchdev_notifier; 665 666 /* spectrum.c */ 667 void mlxsw_sp_rx_listener_no_mark_func(struct sk_buff *skb, 668 u16 local_port, void *priv); 669 void mlxsw_sp_ptp_receive(struct mlxsw_sp *mlxsw_sp, struct sk_buff *skb, 670 u16 local_port); 671 int mlxsw_sp_port_speed_get(struct mlxsw_sp_port *mlxsw_sp_port, u32 *speed); 672 int mlxsw_sp_port_ets_set(struct mlxsw_sp_port *mlxsw_sp_port, 673 enum mlxsw_reg_qeec_hr hr, u8 index, u8 next_index, 674 bool dwrr, u8 dwrr_weight); 675 int mlxsw_sp_port_prio_tc_set(struct mlxsw_sp_port *mlxsw_sp_port, 676 u8 switch_prio, u8 tclass); 677 int mlxsw_sp_port_ets_maxrate_set(struct mlxsw_sp_port *mlxsw_sp_port, 678 enum mlxsw_reg_qeec_hr hr, u8 index, 679 u8 next_index, u32 maxrate, u8 burst_size); 680 enum mlxsw_reg_spms_state mlxsw_sp_stp_spms_state(u8 stp_state); 681 int mlxsw_sp_port_vid_stp_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid, 682 u8 state); 683 int mlxsw_sp_port_vp_mode_set(struct mlxsw_sp_port *mlxsw_sp_port, bool enable); 684 int mlxsw_sp_port_vid_learning_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid, 685 bool learn_enable); 686 int mlxsw_sp_ethtype_to_sver_type(u16 ethtype, u8 *p_sver_type); 687 int mlxsw_sp_port_egress_ethtype_set(struct mlxsw_sp_port *mlxsw_sp_port, 688 u16 ethtype); 689 int mlxsw_sp_port_pvid_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid, 690 u16 ethtype); 691 struct mlxsw_sp_port_vlan * 692 mlxsw_sp_port_vlan_create(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid); 693 void mlxsw_sp_port_vlan_destroy(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan); 694 int mlxsw_sp_port_vlan_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid_begin, 695 u16 vid_end, bool is_member, bool untagged); 696 int mlxsw_sp_flow_counter_get(struct mlxsw_sp *mlxsw_sp, 697 unsigned int counter_index, u64 *packets, 698 u64 *bytes); 699 int mlxsw_sp_flow_counter_alloc(struct mlxsw_sp *mlxsw_sp, 700 unsigned int *p_counter_index); 701 void mlxsw_sp_flow_counter_free(struct mlxsw_sp *mlxsw_sp, 702 unsigned int counter_index); 703 bool mlxsw_sp_port_dev_check(const struct net_device *dev); 704 struct mlxsw_sp *mlxsw_sp_lower_get(struct net_device *dev); 705 struct mlxsw_sp_port *mlxsw_sp_port_dev_lower_find(struct net_device *dev); 706 struct mlxsw_sp_port *mlxsw_sp_port_lower_dev_hold(struct net_device *dev); 707 void mlxsw_sp_port_dev_put(struct mlxsw_sp_port *mlxsw_sp_port); 708 struct mlxsw_sp_port *mlxsw_sp_port_dev_lower_find_rcu(struct net_device *dev); 709 int mlxsw_sp_parsing_depth_inc(struct mlxsw_sp *mlxsw_sp); 710 void mlxsw_sp_parsing_depth_dec(struct mlxsw_sp *mlxsw_sp); 711 int mlxsw_sp_parsing_vxlan_udp_dport_set(struct mlxsw_sp *mlxsw_sp, 712 __be16 udp_dport); 713 714 /* spectrum_dcb.c */ 715 #ifdef CONFIG_MLXSW_SPECTRUM_DCB 716 int mlxsw_sp_port_dcb_init(struct mlxsw_sp_port *mlxsw_sp_port); 717 void mlxsw_sp_port_dcb_fini(struct mlxsw_sp_port *mlxsw_sp_port); 718 #else 719 static inline int mlxsw_sp_port_dcb_init(struct mlxsw_sp_port *mlxsw_sp_port) 720 { 721 return 0; 722 } 723 static inline void mlxsw_sp_port_dcb_fini(struct mlxsw_sp_port *mlxsw_sp_port) 724 {} 725 #endif 726 727 /* spectrum_router.c */ 728 enum mlxsw_sp_l3proto { 729 MLXSW_SP_L3_PROTO_IPV4, 730 MLXSW_SP_L3_PROTO_IPV6, 731 #define MLXSW_SP_L3_PROTO_MAX (MLXSW_SP_L3_PROTO_IPV6 + 1) 732 }; 733 734 union mlxsw_sp_l3addr { 735 __be32 addr4; 736 struct in6_addr addr6; 737 }; 738 739 u16 mlxsw_sp_rif_index(const struct mlxsw_sp_rif *rif); 740 int mlxsw_sp_router_init(struct mlxsw_sp *mlxsw_sp, 741 struct netlink_ext_ack *extack); 742 void mlxsw_sp_router_fini(struct mlxsw_sp *mlxsw_sp); 743 void mlxsw_sp_rif_macvlan_del(struct mlxsw_sp *mlxsw_sp, 744 const struct net_device *macvlan_dev); 745 int mlxsw_sp_inetaddr_valid_event(struct notifier_block *unused, 746 unsigned long event, void *ptr); 747 int mlxsw_sp_inet6addr_valid_event(struct notifier_block *unused, 748 unsigned long event, void *ptr); 749 int 750 mlxsw_sp_port_vlan_router_join(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan, 751 struct net_device *l3_dev, 752 struct netlink_ext_ack *extack); 753 void 754 mlxsw_sp_port_vlan_router_leave(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan); 755 void mlxsw_sp_rif_destroy_by_dev(struct mlxsw_sp *mlxsw_sp, 756 struct net_device *dev); 757 bool mlxsw_sp_rif_exists(struct mlxsw_sp *mlxsw_sp, 758 const struct net_device *dev); 759 u16 mlxsw_sp_rif_vid(struct mlxsw_sp *mlxsw_sp, const struct net_device *dev); 760 u16 mlxsw_sp_router_port(const struct mlxsw_sp *mlxsw_sp); 761 int mlxsw_sp_router_nve_promote_decap(struct mlxsw_sp *mlxsw_sp, u32 ul_tb_id, 762 enum mlxsw_sp_l3proto ul_proto, 763 const union mlxsw_sp_l3addr *ul_sip, 764 u32 tunnel_index); 765 void mlxsw_sp_router_nve_demote_decap(struct mlxsw_sp *mlxsw_sp, u32 ul_tb_id, 766 enum mlxsw_sp_l3proto ul_proto, 767 const union mlxsw_sp_l3addr *ul_sip); 768 int mlxsw_sp_router_tb_id_vr_id(struct mlxsw_sp *mlxsw_sp, u32 tb_id, 769 u16 *vr_id); 770 int mlxsw_sp_router_ul_rif_get(struct mlxsw_sp *mlxsw_sp, u32 ul_tb_id, 771 u16 *ul_rif_index); 772 void mlxsw_sp_router_ul_rif_put(struct mlxsw_sp *mlxsw_sp, u16 ul_rif_index); 773 774 /* spectrum_kvdl.c */ 775 enum mlxsw_sp_kvdl_entry_type { 776 MLXSW_SP_KVDL_ENTRY_TYPE_ADJ, 777 MLXSW_SP_KVDL_ENTRY_TYPE_ACTSET, 778 MLXSW_SP_KVDL_ENTRY_TYPE_PBS, 779 MLXSW_SP_KVDL_ENTRY_TYPE_MCRIGR, 780 MLXSW_SP_KVDL_ENTRY_TYPE_IPV6_ADDRESS, 781 MLXSW_SP_KVDL_ENTRY_TYPE_TNUMT, 782 }; 783 784 static inline unsigned int 785 mlxsw_sp_kvdl_entry_size(enum mlxsw_sp_kvdl_entry_type type) 786 { 787 switch (type) { 788 case MLXSW_SP_KVDL_ENTRY_TYPE_ADJ: 789 case MLXSW_SP_KVDL_ENTRY_TYPE_ACTSET: 790 case MLXSW_SP_KVDL_ENTRY_TYPE_PBS: 791 case MLXSW_SP_KVDL_ENTRY_TYPE_MCRIGR: 792 case MLXSW_SP_KVDL_ENTRY_TYPE_IPV6_ADDRESS: 793 case MLXSW_SP_KVDL_ENTRY_TYPE_TNUMT: 794 default: 795 return 1; 796 } 797 } 798 799 struct mlxsw_sp_kvdl_ops { 800 size_t priv_size; 801 int (*init)(struct mlxsw_sp *mlxsw_sp, void *priv); 802 void (*fini)(struct mlxsw_sp *mlxsw_sp, void *priv); 803 int (*alloc)(struct mlxsw_sp *mlxsw_sp, void *priv, 804 enum mlxsw_sp_kvdl_entry_type type, 805 unsigned int entry_count, u32 *p_entry_index); 806 void (*free)(struct mlxsw_sp *mlxsw_sp, void *priv, 807 enum mlxsw_sp_kvdl_entry_type type, 808 unsigned int entry_count, int entry_index); 809 int (*alloc_size_query)(struct mlxsw_sp *mlxsw_sp, void *priv, 810 enum mlxsw_sp_kvdl_entry_type type, 811 unsigned int entry_count, 812 unsigned int *p_alloc_count); 813 int (*resources_register)(struct mlxsw_sp *mlxsw_sp, void *priv); 814 }; 815 816 int mlxsw_sp_kvdl_init(struct mlxsw_sp *mlxsw_sp); 817 void mlxsw_sp_kvdl_fini(struct mlxsw_sp *mlxsw_sp); 818 int mlxsw_sp_kvdl_alloc(struct mlxsw_sp *mlxsw_sp, 819 enum mlxsw_sp_kvdl_entry_type type, 820 unsigned int entry_count, u32 *p_entry_index); 821 void mlxsw_sp_kvdl_free(struct mlxsw_sp *mlxsw_sp, 822 enum mlxsw_sp_kvdl_entry_type type, 823 unsigned int entry_count, int entry_index); 824 int mlxsw_sp_kvdl_alloc_count_query(struct mlxsw_sp *mlxsw_sp, 825 enum mlxsw_sp_kvdl_entry_type type, 826 unsigned int entry_count, 827 unsigned int *p_alloc_count); 828 829 /* spectrum1_kvdl.c */ 830 extern const struct mlxsw_sp_kvdl_ops mlxsw_sp1_kvdl_ops; 831 int mlxsw_sp1_kvdl_resources_register(struct mlxsw_core *mlxsw_core); 832 833 /* spectrum2_kvdl.c */ 834 extern const struct mlxsw_sp_kvdl_ops mlxsw_sp2_kvdl_ops; 835 836 enum mlxsw_sp_acl_mangle_field { 837 MLXSW_SP_ACL_MANGLE_FIELD_IP_DSFIELD, 838 MLXSW_SP_ACL_MANGLE_FIELD_IP_DSCP, 839 MLXSW_SP_ACL_MANGLE_FIELD_IP_ECN, 840 MLXSW_SP_ACL_MANGLE_FIELD_IP_SPORT, 841 MLXSW_SP_ACL_MANGLE_FIELD_IP_DPORT, 842 MLXSW_SP_ACL_MANGLE_FIELD_IP4_SIP, 843 MLXSW_SP_ACL_MANGLE_FIELD_IP4_DIP, 844 MLXSW_SP_ACL_MANGLE_FIELD_IP6_SIP_1, 845 MLXSW_SP_ACL_MANGLE_FIELD_IP6_SIP_2, 846 MLXSW_SP_ACL_MANGLE_FIELD_IP6_SIP_3, 847 MLXSW_SP_ACL_MANGLE_FIELD_IP6_SIP_4, 848 MLXSW_SP_ACL_MANGLE_FIELD_IP6_DIP_1, 849 MLXSW_SP_ACL_MANGLE_FIELD_IP6_DIP_2, 850 MLXSW_SP_ACL_MANGLE_FIELD_IP6_DIP_3, 851 MLXSW_SP_ACL_MANGLE_FIELD_IP6_DIP_4, 852 }; 853 854 struct mlxsw_sp_acl_rule_info { 855 unsigned int priority; 856 struct mlxsw_afk_element_values values; 857 struct mlxsw_afa_block *act_block; 858 u8 action_created:1, 859 ingress_bind_blocker:1, 860 egress_bind_blocker:1, 861 counter_valid:1, 862 policer_index_valid:1, 863 ipv6_valid:1; 864 unsigned int counter_index; 865 u16 policer_index; 866 struct { 867 u32 prev_val; 868 enum mlxsw_sp_acl_mangle_field prev_field; 869 } ipv6; 870 }; 871 872 /* spectrum_flow.c */ 873 struct mlxsw_sp_flow_block { 874 struct list_head binding_list; 875 struct { 876 struct list_head list; 877 unsigned int min_prio; 878 unsigned int max_prio; 879 } mall; 880 struct mlxsw_sp_acl_ruleset *ruleset_zero; 881 struct mlxsw_sp *mlxsw_sp; 882 unsigned int rule_count; 883 unsigned int disable_count; 884 unsigned int ingress_blocker_rule_count; 885 unsigned int egress_blocker_rule_count; 886 unsigned int ingress_binding_count; 887 unsigned int egress_binding_count; 888 struct net *net; 889 }; 890 891 struct mlxsw_sp_flow_block_binding { 892 struct list_head list; 893 struct mlxsw_sp_port *mlxsw_sp_port; 894 bool ingress; 895 }; 896 897 static inline struct mlxsw_sp * 898 mlxsw_sp_flow_block_mlxsw_sp(struct mlxsw_sp_flow_block *block) 899 { 900 return block->mlxsw_sp; 901 } 902 903 static inline unsigned int 904 mlxsw_sp_flow_block_rule_count(const struct mlxsw_sp_flow_block *block) 905 { 906 return block ? block->rule_count : 0; 907 } 908 909 static inline void 910 mlxsw_sp_flow_block_disable_inc(struct mlxsw_sp_flow_block *block) 911 { 912 if (block) 913 block->disable_count++; 914 } 915 916 static inline void 917 mlxsw_sp_flow_block_disable_dec(struct mlxsw_sp_flow_block *block) 918 { 919 if (block) 920 block->disable_count--; 921 } 922 923 static inline bool 924 mlxsw_sp_flow_block_disabled(const struct mlxsw_sp_flow_block *block) 925 { 926 return block->disable_count; 927 } 928 929 static inline bool 930 mlxsw_sp_flow_block_is_egress_bound(const struct mlxsw_sp_flow_block *block) 931 { 932 return block->egress_binding_count; 933 } 934 935 static inline bool 936 mlxsw_sp_flow_block_is_ingress_bound(const struct mlxsw_sp_flow_block *block) 937 { 938 return block->ingress_binding_count; 939 } 940 941 static inline bool 942 mlxsw_sp_flow_block_is_mixed_bound(const struct mlxsw_sp_flow_block *block) 943 { 944 return block->ingress_binding_count && block->egress_binding_count; 945 } 946 947 struct mlxsw_sp_flow_block *mlxsw_sp_flow_block_create(struct mlxsw_sp *mlxsw_sp, 948 struct net *net); 949 void mlxsw_sp_flow_block_destroy(struct mlxsw_sp_flow_block *block); 950 int mlxsw_sp_setup_tc_block_clsact(struct mlxsw_sp_port *mlxsw_sp_port, 951 struct flow_block_offload *f, 952 bool ingress); 953 954 /* spectrum_acl.c */ 955 struct mlxsw_sp_acl_ruleset; 956 957 enum mlxsw_sp_acl_profile { 958 MLXSW_SP_ACL_PROFILE_FLOWER, 959 MLXSW_SP_ACL_PROFILE_MR, 960 }; 961 962 struct mlxsw_afk *mlxsw_sp_acl_afk(struct mlxsw_sp_acl *acl); 963 964 int mlxsw_sp_acl_ruleset_bind(struct mlxsw_sp *mlxsw_sp, 965 struct mlxsw_sp_flow_block *block, 966 struct mlxsw_sp_flow_block_binding *binding); 967 void mlxsw_sp_acl_ruleset_unbind(struct mlxsw_sp *mlxsw_sp, 968 struct mlxsw_sp_flow_block *block, 969 struct mlxsw_sp_flow_block_binding *binding); 970 struct mlxsw_sp_acl_ruleset * 971 mlxsw_sp_acl_ruleset_lookup(struct mlxsw_sp *mlxsw_sp, 972 struct mlxsw_sp_flow_block *block, u32 chain_index, 973 enum mlxsw_sp_acl_profile profile); 974 struct mlxsw_sp_acl_ruleset * 975 mlxsw_sp_acl_ruleset_get(struct mlxsw_sp *mlxsw_sp, 976 struct mlxsw_sp_flow_block *block, u32 chain_index, 977 enum mlxsw_sp_acl_profile profile, 978 struct mlxsw_afk_element_usage *tmplt_elusage); 979 void mlxsw_sp_acl_ruleset_put(struct mlxsw_sp *mlxsw_sp, 980 struct mlxsw_sp_acl_ruleset *ruleset); 981 u16 mlxsw_sp_acl_ruleset_group_id(struct mlxsw_sp_acl_ruleset *ruleset); 982 void mlxsw_sp_acl_ruleset_prio_get(struct mlxsw_sp_acl_ruleset *ruleset, 983 unsigned int *p_min_prio, 984 unsigned int *p_max_prio); 985 986 struct mlxsw_sp_acl_rule_info * 987 mlxsw_sp_acl_rulei_create(struct mlxsw_sp_acl *acl, 988 struct mlxsw_afa_block *afa_block); 989 void mlxsw_sp_acl_rulei_destroy(struct mlxsw_sp_acl_rule_info *rulei); 990 int mlxsw_sp_acl_rulei_commit(struct mlxsw_sp_acl_rule_info *rulei); 991 void mlxsw_sp_acl_rulei_priority(struct mlxsw_sp_acl_rule_info *rulei, 992 unsigned int priority); 993 void mlxsw_sp_acl_rulei_keymask_u32(struct mlxsw_sp_acl_rule_info *rulei, 994 enum mlxsw_afk_element element, 995 u32 key_value, u32 mask_value); 996 void mlxsw_sp_acl_rulei_keymask_buf(struct mlxsw_sp_acl_rule_info *rulei, 997 enum mlxsw_afk_element element, 998 const char *key_value, 999 const char *mask_value, unsigned int len); 1000 int mlxsw_sp_acl_rulei_act_continue(struct mlxsw_sp_acl_rule_info *rulei); 1001 int mlxsw_sp_acl_rulei_act_jump(struct mlxsw_sp_acl_rule_info *rulei, 1002 u16 group_id); 1003 int mlxsw_sp_acl_rulei_act_terminate(struct mlxsw_sp_acl_rule_info *rulei); 1004 int mlxsw_sp_acl_rulei_act_drop(struct mlxsw_sp_acl_rule_info *rulei, 1005 bool ingress, 1006 const struct flow_action_cookie *fa_cookie, 1007 struct netlink_ext_ack *extack); 1008 int mlxsw_sp_acl_rulei_act_trap(struct mlxsw_sp_acl_rule_info *rulei); 1009 int mlxsw_sp_acl_rulei_act_mirror(struct mlxsw_sp *mlxsw_sp, 1010 struct mlxsw_sp_acl_rule_info *rulei, 1011 struct mlxsw_sp_flow_block *block, 1012 struct net_device *out_dev, 1013 struct netlink_ext_ack *extack); 1014 int mlxsw_sp_acl_rulei_act_fwd(struct mlxsw_sp *mlxsw_sp, 1015 struct mlxsw_sp_acl_rule_info *rulei, 1016 struct net_device *out_dev, 1017 struct netlink_ext_ack *extack); 1018 int mlxsw_sp_acl_rulei_act_vlan(struct mlxsw_sp *mlxsw_sp, 1019 struct mlxsw_sp_acl_rule_info *rulei, 1020 u32 action, u16 vid, u16 proto, u8 prio, 1021 struct netlink_ext_ack *extack); 1022 int mlxsw_sp_acl_rulei_act_priority(struct mlxsw_sp *mlxsw_sp, 1023 struct mlxsw_sp_acl_rule_info *rulei, 1024 u32 prio, struct netlink_ext_ack *extack); 1025 int mlxsw_sp_acl_rulei_act_mangle(struct mlxsw_sp *mlxsw_sp, 1026 struct mlxsw_sp_acl_rule_info *rulei, 1027 enum flow_action_mangle_base htype, 1028 u32 offset, u32 mask, u32 val, 1029 struct netlink_ext_ack *extack); 1030 int mlxsw_sp_acl_rulei_act_police(struct mlxsw_sp *mlxsw_sp, 1031 struct mlxsw_sp_acl_rule_info *rulei, 1032 u32 index, u64 rate_bytes_ps, 1033 u32 burst, struct netlink_ext_ack *extack); 1034 int mlxsw_sp_acl_rulei_act_count(struct mlxsw_sp *mlxsw_sp, 1035 struct mlxsw_sp_acl_rule_info *rulei, 1036 struct netlink_ext_ack *extack); 1037 int mlxsw_sp_acl_rulei_act_fid_set(struct mlxsw_sp *mlxsw_sp, 1038 struct mlxsw_sp_acl_rule_info *rulei, 1039 u16 fid, struct netlink_ext_ack *extack); 1040 int mlxsw_sp_acl_rulei_act_sample(struct mlxsw_sp *mlxsw_sp, 1041 struct mlxsw_sp_acl_rule_info *rulei, 1042 struct mlxsw_sp_flow_block *block, 1043 struct psample_group *psample_group, u32 rate, 1044 u32 trunc_size, bool truncate, 1045 struct netlink_ext_ack *extack); 1046 1047 struct mlxsw_sp_acl_rule; 1048 1049 struct mlxsw_sp_acl_rule * 1050 mlxsw_sp_acl_rule_create(struct mlxsw_sp *mlxsw_sp, 1051 struct mlxsw_sp_acl_ruleset *ruleset, 1052 unsigned long cookie, 1053 struct mlxsw_afa_block *afa_block, 1054 struct netlink_ext_ack *extack); 1055 void mlxsw_sp_acl_rule_destroy(struct mlxsw_sp *mlxsw_sp, 1056 struct mlxsw_sp_acl_rule *rule); 1057 int mlxsw_sp_acl_rule_add(struct mlxsw_sp *mlxsw_sp, 1058 struct mlxsw_sp_acl_rule *rule); 1059 void mlxsw_sp_acl_rule_del(struct mlxsw_sp *mlxsw_sp, 1060 struct mlxsw_sp_acl_rule *rule); 1061 int mlxsw_sp_acl_rule_action_replace(struct mlxsw_sp *mlxsw_sp, 1062 struct mlxsw_sp_acl_rule *rule, 1063 struct mlxsw_afa_block *afa_block); 1064 struct mlxsw_sp_acl_rule * 1065 mlxsw_sp_acl_rule_lookup(struct mlxsw_sp *mlxsw_sp, 1066 struct mlxsw_sp_acl_ruleset *ruleset, 1067 unsigned long cookie); 1068 struct mlxsw_sp_acl_rule_info * 1069 mlxsw_sp_acl_rule_rulei(struct mlxsw_sp_acl_rule *rule); 1070 int mlxsw_sp_acl_rule_get_stats(struct mlxsw_sp *mlxsw_sp, 1071 struct mlxsw_sp_acl_rule *rule, 1072 u64 *packets, u64 *bytes, u64 *drops, 1073 u64 *last_use, 1074 enum flow_action_hw_stats *used_hw_stats); 1075 1076 struct mlxsw_sp_fid *mlxsw_sp_acl_dummy_fid(struct mlxsw_sp *mlxsw_sp); 1077 1078 static inline const struct flow_action_cookie * 1079 mlxsw_sp_acl_act_cookie_lookup(struct mlxsw_sp *mlxsw_sp, u32 cookie_index) 1080 { 1081 return mlxsw_afa_cookie_lookup(mlxsw_sp->afa, cookie_index); 1082 } 1083 1084 int mlxsw_sp_acl_init(struct mlxsw_sp *mlxsw_sp); 1085 void mlxsw_sp_acl_fini(struct mlxsw_sp *mlxsw_sp); 1086 u32 mlxsw_sp_acl_region_rehash_intrvl_get(struct mlxsw_sp *mlxsw_sp); 1087 int mlxsw_sp_acl_region_rehash_intrvl_set(struct mlxsw_sp *mlxsw_sp, u32 val); 1088 1089 struct mlxsw_sp_acl_mangle_action; 1090 1091 struct mlxsw_sp_acl_rulei_ops { 1092 int (*act_mangle_field)(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_acl_rule_info *rulei, 1093 struct mlxsw_sp_acl_mangle_action *mact, u32 val, 1094 struct netlink_ext_ack *extack); 1095 }; 1096 1097 extern struct mlxsw_sp_acl_rulei_ops mlxsw_sp1_acl_rulei_ops; 1098 extern struct mlxsw_sp_acl_rulei_ops mlxsw_sp2_acl_rulei_ops; 1099 1100 /* spectrum_acl_tcam.c */ 1101 struct mlxsw_sp_acl_tcam; 1102 struct mlxsw_sp_acl_tcam_region; 1103 1104 struct mlxsw_sp_acl_tcam_ops { 1105 enum mlxsw_reg_ptar_key_type key_type; 1106 size_t priv_size; 1107 int (*init)(struct mlxsw_sp *mlxsw_sp, void *priv, 1108 struct mlxsw_sp_acl_tcam *tcam); 1109 void (*fini)(struct mlxsw_sp *mlxsw_sp, void *priv); 1110 size_t region_priv_size; 1111 int (*region_init)(struct mlxsw_sp *mlxsw_sp, void *region_priv, 1112 void *tcam_priv, 1113 struct mlxsw_sp_acl_tcam_region *region, 1114 void *hints_priv); 1115 void (*region_fini)(struct mlxsw_sp *mlxsw_sp, void *region_priv); 1116 int (*region_associate)(struct mlxsw_sp *mlxsw_sp, 1117 struct mlxsw_sp_acl_tcam_region *region); 1118 void * (*region_rehash_hints_get)(void *region_priv); 1119 void (*region_rehash_hints_put)(void *hints_priv); 1120 size_t chunk_priv_size; 1121 void (*chunk_init)(void *region_priv, void *chunk_priv, 1122 unsigned int priority); 1123 void (*chunk_fini)(void *chunk_priv); 1124 size_t entry_priv_size; 1125 int (*entry_add)(struct mlxsw_sp *mlxsw_sp, 1126 void *region_priv, void *chunk_priv, 1127 void *entry_priv, 1128 struct mlxsw_sp_acl_rule_info *rulei); 1129 void (*entry_del)(struct mlxsw_sp *mlxsw_sp, 1130 void *region_priv, void *chunk_priv, 1131 void *entry_priv); 1132 int (*entry_action_replace)(struct mlxsw_sp *mlxsw_sp, 1133 void *region_priv, void *entry_priv, 1134 struct mlxsw_sp_acl_rule_info *rulei); 1135 int (*entry_activity_get)(struct mlxsw_sp *mlxsw_sp, 1136 void *region_priv, void *entry_priv, 1137 bool *activity); 1138 }; 1139 1140 /* spectrum1_acl_tcam.c */ 1141 extern const struct mlxsw_sp_acl_tcam_ops mlxsw_sp1_acl_tcam_ops; 1142 1143 /* spectrum2_acl_tcam.c */ 1144 extern const struct mlxsw_sp_acl_tcam_ops mlxsw_sp2_acl_tcam_ops; 1145 1146 /* spectrum_acl_flex_actions.c */ 1147 extern const struct mlxsw_afa_ops mlxsw_sp1_act_afa_ops; 1148 extern const struct mlxsw_afa_ops mlxsw_sp2_act_afa_ops; 1149 1150 /* spectrum_acl_flex_keys.c */ 1151 extern const struct mlxsw_afk_ops mlxsw_sp1_afk_ops; 1152 extern const struct mlxsw_afk_ops mlxsw_sp2_afk_ops; 1153 extern const struct mlxsw_afk_ops mlxsw_sp4_afk_ops; 1154 1155 /* spectrum_acl_bloom_filter.c */ 1156 extern const struct mlxsw_sp_acl_bf_ops mlxsw_sp2_acl_bf_ops; 1157 extern const struct mlxsw_sp_acl_bf_ops mlxsw_sp4_acl_bf_ops; 1158 1159 /* spectrum_matchall.c */ 1160 struct mlxsw_sp_mall_ops { 1161 int (*sample_add)(struct mlxsw_sp *mlxsw_sp, 1162 struct mlxsw_sp_port *mlxsw_sp_port, 1163 struct mlxsw_sp_mall_entry *mall_entry, 1164 struct netlink_ext_ack *extack); 1165 void (*sample_del)(struct mlxsw_sp *mlxsw_sp, 1166 struct mlxsw_sp_port *mlxsw_sp_port, 1167 struct mlxsw_sp_mall_entry *mall_entry); 1168 }; 1169 1170 extern const struct mlxsw_sp_mall_ops mlxsw_sp1_mall_ops; 1171 extern const struct mlxsw_sp_mall_ops mlxsw_sp2_mall_ops; 1172 1173 enum mlxsw_sp_mall_action_type { 1174 MLXSW_SP_MALL_ACTION_TYPE_MIRROR, 1175 MLXSW_SP_MALL_ACTION_TYPE_SAMPLE, 1176 MLXSW_SP_MALL_ACTION_TYPE_TRAP, 1177 }; 1178 1179 struct mlxsw_sp_mall_mirror_entry { 1180 const struct net_device *to_dev; 1181 int span_id; 1182 }; 1183 1184 struct mlxsw_sp_mall_trap_entry { 1185 int span_id; 1186 }; 1187 1188 struct mlxsw_sp_mall_sample_entry { 1189 struct mlxsw_sp_sample_params params; 1190 int span_id; /* Relevant for Spectrum-2 onwards. */ 1191 }; 1192 1193 struct mlxsw_sp_mall_entry { 1194 struct list_head list; 1195 unsigned long cookie; 1196 unsigned int priority; 1197 enum mlxsw_sp_mall_action_type type; 1198 bool ingress; 1199 union { 1200 struct mlxsw_sp_mall_mirror_entry mirror; 1201 struct mlxsw_sp_mall_trap_entry trap; 1202 struct mlxsw_sp_mall_sample_entry sample; 1203 }; 1204 struct rcu_head rcu; 1205 }; 1206 1207 int mlxsw_sp_mall_replace(struct mlxsw_sp *mlxsw_sp, 1208 struct mlxsw_sp_flow_block *block, 1209 struct tc_cls_matchall_offload *f); 1210 void mlxsw_sp_mall_destroy(struct mlxsw_sp_flow_block *block, 1211 struct tc_cls_matchall_offload *f); 1212 int mlxsw_sp_mall_port_bind(struct mlxsw_sp_flow_block *block, 1213 struct mlxsw_sp_port *mlxsw_sp_port, 1214 struct netlink_ext_ack *extack); 1215 void mlxsw_sp_mall_port_unbind(struct mlxsw_sp_flow_block *block, 1216 struct mlxsw_sp_port *mlxsw_sp_port); 1217 int mlxsw_sp_mall_prio_get(struct mlxsw_sp_flow_block *block, u32 chain_index, 1218 unsigned int *p_min_prio, unsigned int *p_max_prio); 1219 1220 /* spectrum_flower.c */ 1221 int mlxsw_sp_flower_replace(struct mlxsw_sp *mlxsw_sp, 1222 struct mlxsw_sp_flow_block *block, 1223 struct flow_cls_offload *f); 1224 void mlxsw_sp_flower_destroy(struct mlxsw_sp *mlxsw_sp, 1225 struct mlxsw_sp_flow_block *block, 1226 struct flow_cls_offload *f); 1227 int mlxsw_sp_flower_stats(struct mlxsw_sp *mlxsw_sp, 1228 struct mlxsw_sp_flow_block *block, 1229 struct flow_cls_offload *f); 1230 int mlxsw_sp_flower_tmplt_create(struct mlxsw_sp *mlxsw_sp, 1231 struct mlxsw_sp_flow_block *block, 1232 struct flow_cls_offload *f); 1233 void mlxsw_sp_flower_tmplt_destroy(struct mlxsw_sp *mlxsw_sp, 1234 struct mlxsw_sp_flow_block *block, 1235 struct flow_cls_offload *f); 1236 int mlxsw_sp_flower_prio_get(struct mlxsw_sp *mlxsw_sp, 1237 struct mlxsw_sp_flow_block *block, 1238 u32 chain_index, unsigned int *p_min_prio, 1239 unsigned int *p_max_prio); 1240 1241 /* spectrum_qdisc.c */ 1242 int mlxsw_sp_tc_qdisc_init(struct mlxsw_sp_port *mlxsw_sp_port); 1243 void mlxsw_sp_tc_qdisc_fini(struct mlxsw_sp_port *mlxsw_sp_port); 1244 int mlxsw_sp_setup_tc_red(struct mlxsw_sp_port *mlxsw_sp_port, 1245 struct tc_red_qopt_offload *p); 1246 int mlxsw_sp_setup_tc_prio(struct mlxsw_sp_port *mlxsw_sp_port, 1247 struct tc_prio_qopt_offload *p); 1248 int mlxsw_sp_setup_tc_ets(struct mlxsw_sp_port *mlxsw_sp_port, 1249 struct tc_ets_qopt_offload *p); 1250 int mlxsw_sp_setup_tc_tbf(struct mlxsw_sp_port *mlxsw_sp_port, 1251 struct tc_tbf_qopt_offload *p); 1252 int mlxsw_sp_setup_tc_fifo(struct mlxsw_sp_port *mlxsw_sp_port, 1253 struct tc_fifo_qopt_offload *p); 1254 int mlxsw_sp_setup_tc_block_qevent_early_drop(struct mlxsw_sp_port *mlxsw_sp_port, 1255 struct flow_block_offload *f); 1256 int mlxsw_sp_setup_tc_block_qevent_mark(struct mlxsw_sp_port *mlxsw_sp_port, 1257 struct flow_block_offload *f); 1258 1259 /* spectrum_fid.c */ 1260 bool mlxsw_sp_fid_is_dummy(struct mlxsw_sp *mlxsw_sp, u16 fid_index); 1261 struct mlxsw_sp_fid *mlxsw_sp_fid_lookup_by_index(struct mlxsw_sp *mlxsw_sp, 1262 u16 fid_index); 1263 int mlxsw_sp_fid_nve_ifindex(const struct mlxsw_sp_fid *fid, int *nve_ifindex); 1264 int mlxsw_sp_fid_nve_type(const struct mlxsw_sp_fid *fid, 1265 enum mlxsw_sp_nve_type *p_type); 1266 struct mlxsw_sp_fid *mlxsw_sp_fid_lookup_by_vni(struct mlxsw_sp *mlxsw_sp, 1267 __be32 vni); 1268 int mlxsw_sp_fid_vni(const struct mlxsw_sp_fid *fid, __be32 *vni); 1269 int mlxsw_sp_fid_nve_flood_index_set(struct mlxsw_sp_fid *fid, 1270 u32 nve_flood_index); 1271 void mlxsw_sp_fid_nve_flood_index_clear(struct mlxsw_sp_fid *fid); 1272 bool mlxsw_sp_fid_nve_flood_index_is_set(const struct mlxsw_sp_fid *fid); 1273 int mlxsw_sp_fid_vni_set(struct mlxsw_sp_fid *fid, enum mlxsw_sp_nve_type type, 1274 __be32 vni, int nve_ifindex); 1275 void mlxsw_sp_fid_vni_clear(struct mlxsw_sp_fid *fid); 1276 bool mlxsw_sp_fid_vni_is_set(const struct mlxsw_sp_fid *fid); 1277 void mlxsw_sp_fid_fdb_clear_offload(const struct mlxsw_sp_fid *fid, 1278 const struct net_device *nve_dev); 1279 int mlxsw_sp_fid_flood_set(struct mlxsw_sp_fid *fid, 1280 enum mlxsw_sp_flood_type packet_type, u16 local_port, 1281 bool member); 1282 int mlxsw_sp_fid_port_vid_map(struct mlxsw_sp_fid *fid, 1283 struct mlxsw_sp_port *mlxsw_sp_port, u16 vid); 1284 void mlxsw_sp_fid_port_vid_unmap(struct mlxsw_sp_fid *fid, 1285 struct mlxsw_sp_port *mlxsw_sp_port, u16 vid); 1286 u16 mlxsw_sp_fid_index(const struct mlxsw_sp_fid *fid); 1287 enum mlxsw_sp_fid_type mlxsw_sp_fid_type(const struct mlxsw_sp_fid *fid); 1288 int mlxsw_sp_fid_rif_set(struct mlxsw_sp_fid *fid, struct mlxsw_sp_rif *rif); 1289 void mlxsw_sp_fid_rif_unset(struct mlxsw_sp_fid *fid); 1290 struct mlxsw_sp_rif *mlxsw_sp_fid_rif(const struct mlxsw_sp_fid *fid); 1291 enum mlxsw_sp_rif_type 1292 mlxsw_sp_fid_type_rif_type(const struct mlxsw_sp *mlxsw_sp, 1293 enum mlxsw_sp_fid_type type); 1294 u16 mlxsw_sp_fid_8021q_vid(const struct mlxsw_sp_fid *fid); 1295 struct mlxsw_sp_fid *mlxsw_sp_fid_8021q_get(struct mlxsw_sp *mlxsw_sp, u16 vid); 1296 struct mlxsw_sp_fid *mlxsw_sp_fid_8021d_get(struct mlxsw_sp *mlxsw_sp, 1297 int br_ifindex); 1298 struct mlxsw_sp_fid *mlxsw_sp_fid_8021q_lookup(struct mlxsw_sp *mlxsw_sp, 1299 u16 vid); 1300 struct mlxsw_sp_fid *mlxsw_sp_fid_8021d_lookup(struct mlxsw_sp *mlxsw_sp, 1301 int br_ifindex); 1302 struct mlxsw_sp_fid *mlxsw_sp_fid_rfid_get(struct mlxsw_sp *mlxsw_sp, 1303 u16 rif_index); 1304 struct mlxsw_sp_fid *mlxsw_sp_fid_dummy_get(struct mlxsw_sp *mlxsw_sp); 1305 void mlxsw_sp_fid_put(struct mlxsw_sp_fid *fid); 1306 int mlxsw_sp_port_fids_init(struct mlxsw_sp_port *mlxsw_sp_port); 1307 void mlxsw_sp_port_fids_fini(struct mlxsw_sp_port *mlxsw_sp_port); 1308 int mlxsw_sp_fids_init(struct mlxsw_sp *mlxsw_sp); 1309 void mlxsw_sp_fids_fini(struct mlxsw_sp *mlxsw_sp); 1310 1311 extern const struct mlxsw_sp_fid_family *mlxsw_sp1_fid_family_arr[]; 1312 extern const struct mlxsw_sp_fid_family *mlxsw_sp2_fid_family_arr[]; 1313 1314 /* spectrum_mr.c */ 1315 enum mlxsw_sp_mr_route_prio { 1316 MLXSW_SP_MR_ROUTE_PRIO_SG, 1317 MLXSW_SP_MR_ROUTE_PRIO_STARG, 1318 MLXSW_SP_MR_ROUTE_PRIO_CATCHALL, 1319 __MLXSW_SP_MR_ROUTE_PRIO_MAX 1320 }; 1321 1322 #define MLXSW_SP_MR_ROUTE_PRIO_MAX (__MLXSW_SP_MR_ROUTE_PRIO_MAX - 1) 1323 1324 struct mlxsw_sp_mr_route_key; 1325 1326 struct mlxsw_sp_mr_tcam_ops { 1327 size_t priv_size; 1328 int (*init)(struct mlxsw_sp *mlxsw_sp, void *priv); 1329 void (*fini)(void *priv); 1330 size_t route_priv_size; 1331 int (*route_create)(struct mlxsw_sp *mlxsw_sp, void *priv, 1332 void *route_priv, 1333 struct mlxsw_sp_mr_route_key *key, 1334 struct mlxsw_afa_block *afa_block, 1335 enum mlxsw_sp_mr_route_prio prio); 1336 void (*route_destroy)(struct mlxsw_sp *mlxsw_sp, void *priv, 1337 void *route_priv, 1338 struct mlxsw_sp_mr_route_key *key); 1339 int (*route_update)(struct mlxsw_sp *mlxsw_sp, void *route_priv, 1340 struct mlxsw_sp_mr_route_key *key, 1341 struct mlxsw_afa_block *afa_block); 1342 }; 1343 1344 /* spectrum1_mr_tcam.c */ 1345 extern const struct mlxsw_sp_mr_tcam_ops mlxsw_sp1_mr_tcam_ops; 1346 1347 /* spectrum2_mr_tcam.c */ 1348 extern const struct mlxsw_sp_mr_tcam_ops mlxsw_sp2_mr_tcam_ops; 1349 1350 /* spectrum_nve.c */ 1351 struct mlxsw_sp_nve_params { 1352 enum mlxsw_sp_nve_type type; 1353 __be32 vni; 1354 const struct net_device *dev; 1355 u16 ethertype; 1356 }; 1357 1358 extern const struct mlxsw_sp_nve_ops *mlxsw_sp1_nve_ops_arr[]; 1359 extern const struct mlxsw_sp_nve_ops *mlxsw_sp2_nve_ops_arr[]; 1360 1361 int mlxsw_sp_nve_learned_ip_resolve(struct mlxsw_sp *mlxsw_sp, u32 uip, 1362 enum mlxsw_sp_l3proto proto, 1363 union mlxsw_sp_l3addr *addr); 1364 int mlxsw_sp_nve_flood_ip_add(struct mlxsw_sp *mlxsw_sp, 1365 struct mlxsw_sp_fid *fid, 1366 enum mlxsw_sp_l3proto proto, 1367 union mlxsw_sp_l3addr *addr); 1368 void mlxsw_sp_nve_flood_ip_del(struct mlxsw_sp *mlxsw_sp, 1369 struct mlxsw_sp_fid *fid, 1370 enum mlxsw_sp_l3proto proto, 1371 union mlxsw_sp_l3addr *addr); 1372 int mlxsw_sp_nve_ipv6_addr_kvdl_set(struct mlxsw_sp *mlxsw_sp, 1373 const struct in6_addr *addr6, 1374 u32 *p_kvdl_index); 1375 void mlxsw_sp_nve_ipv6_addr_kvdl_unset(struct mlxsw_sp *mlxsw_sp, 1376 const struct in6_addr *addr6); 1377 int 1378 mlxsw_sp_nve_ipv6_addr_map_replace(struct mlxsw_sp *mlxsw_sp, const char *mac, 1379 u16 fid_index, 1380 const struct in6_addr *new_addr6); 1381 void mlxsw_sp_nve_ipv6_addr_map_del(struct mlxsw_sp *mlxsw_sp, const char *mac, 1382 u16 fid_index); 1383 int mlxsw_sp_nve_fid_enable(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_fid *fid, 1384 struct mlxsw_sp_nve_params *params, 1385 struct netlink_ext_ack *extack); 1386 void mlxsw_sp_nve_fid_disable(struct mlxsw_sp *mlxsw_sp, 1387 struct mlxsw_sp_fid *fid); 1388 int mlxsw_sp_port_nve_init(struct mlxsw_sp_port *mlxsw_sp_port); 1389 void mlxsw_sp_port_nve_fini(struct mlxsw_sp_port *mlxsw_sp_port); 1390 int mlxsw_sp_nve_init(struct mlxsw_sp *mlxsw_sp); 1391 void mlxsw_sp_nve_fini(struct mlxsw_sp *mlxsw_sp); 1392 1393 /* spectrum_nve_vxlan.c */ 1394 int mlxsw_sp_nve_inc_parsing_depth_get(struct mlxsw_sp *mlxsw_sp); 1395 void mlxsw_sp_nve_inc_parsing_depth_put(struct mlxsw_sp *mlxsw_sp); 1396 1397 /* spectrum_trap.c */ 1398 int mlxsw_sp_devlink_traps_init(struct mlxsw_sp *mlxsw_sp); 1399 void mlxsw_sp_devlink_traps_fini(struct mlxsw_sp *mlxsw_sp); 1400 int mlxsw_sp_trap_init(struct mlxsw_core *mlxsw_core, 1401 const struct devlink_trap *trap, void *trap_ctx); 1402 void mlxsw_sp_trap_fini(struct mlxsw_core *mlxsw_core, 1403 const struct devlink_trap *trap, void *trap_ctx); 1404 int mlxsw_sp_trap_action_set(struct mlxsw_core *mlxsw_core, 1405 const struct devlink_trap *trap, 1406 enum devlink_trap_action action, 1407 struct netlink_ext_ack *extack); 1408 int mlxsw_sp_trap_group_init(struct mlxsw_core *mlxsw_core, 1409 const struct devlink_trap_group *group); 1410 int mlxsw_sp_trap_group_set(struct mlxsw_core *mlxsw_core, 1411 const struct devlink_trap_group *group, 1412 const struct devlink_trap_policer *policer, 1413 struct netlink_ext_ack *extack); 1414 int 1415 mlxsw_sp_trap_policer_init(struct mlxsw_core *mlxsw_core, 1416 const struct devlink_trap_policer *policer); 1417 void mlxsw_sp_trap_policer_fini(struct mlxsw_core *mlxsw_core, 1418 const struct devlink_trap_policer *policer); 1419 int 1420 mlxsw_sp_trap_policer_set(struct mlxsw_core *mlxsw_core, 1421 const struct devlink_trap_policer *policer, 1422 u64 rate, u64 burst, struct netlink_ext_ack *extack); 1423 int 1424 mlxsw_sp_trap_policer_counter_get(struct mlxsw_core *mlxsw_core, 1425 const struct devlink_trap_policer *policer, 1426 u64 *p_drops); 1427 int mlxsw_sp_trap_group_policer_hw_id_get(struct mlxsw_sp *mlxsw_sp, u16 id, 1428 bool *p_enabled, u16 *p_hw_id); 1429 1430 static inline struct net *mlxsw_sp_net(struct mlxsw_sp *mlxsw_sp) 1431 { 1432 return mlxsw_core_net(mlxsw_sp->core); 1433 } 1434 1435 /* spectrum_ethtool.c */ 1436 extern const struct ethtool_ops mlxsw_sp_port_ethtool_ops; 1437 extern const struct mlxsw_sp_port_type_speed_ops mlxsw_sp1_port_type_speed_ops; 1438 extern const struct mlxsw_sp_port_type_speed_ops mlxsw_sp2_port_type_speed_ops; 1439 1440 /* spectrum_policer.c */ 1441 extern const struct mlxsw_sp_policer_core_ops mlxsw_sp1_policer_core_ops; 1442 extern const struct mlxsw_sp_policer_core_ops mlxsw_sp2_policer_core_ops; 1443 1444 enum mlxsw_sp_policer_type { 1445 MLXSW_SP_POLICER_TYPE_SINGLE_RATE, 1446 1447 __MLXSW_SP_POLICER_TYPE_MAX, 1448 MLXSW_SP_POLICER_TYPE_MAX = __MLXSW_SP_POLICER_TYPE_MAX - 1, 1449 }; 1450 1451 struct mlxsw_sp_policer_params { 1452 u64 rate; 1453 u64 burst; 1454 bool bytes; 1455 }; 1456 1457 int mlxsw_sp_policer_add(struct mlxsw_sp *mlxsw_sp, 1458 enum mlxsw_sp_policer_type type, 1459 const struct mlxsw_sp_policer_params *params, 1460 struct netlink_ext_ack *extack, u16 *p_policer_index); 1461 void mlxsw_sp_policer_del(struct mlxsw_sp *mlxsw_sp, 1462 enum mlxsw_sp_policer_type type, 1463 u16 policer_index); 1464 int mlxsw_sp_policer_drops_counter_get(struct mlxsw_sp *mlxsw_sp, 1465 enum mlxsw_sp_policer_type type, 1466 u16 policer_index, u64 *p_drops); 1467 int mlxsw_sp_policers_init(struct mlxsw_sp *mlxsw_sp); 1468 void mlxsw_sp_policers_fini(struct mlxsw_sp *mlxsw_sp); 1469 int mlxsw_sp_policer_resources_register(struct mlxsw_core *mlxsw_core); 1470 1471 /* spectrum_pgt.c */ 1472 int mlxsw_sp_pgt_mid_alloc(struct mlxsw_sp *mlxsw_sp, u16 *p_mid); 1473 void mlxsw_sp_pgt_mid_free(struct mlxsw_sp *mlxsw_sp, u16 mid_base); 1474 int mlxsw_sp_pgt_mid_alloc_range(struct mlxsw_sp *mlxsw_sp, u16 mid_base, 1475 u16 count); 1476 void mlxsw_sp_pgt_mid_free_range(struct mlxsw_sp *mlxsw_sp, u16 mid_base, 1477 u16 count); 1478 int mlxsw_sp_pgt_entry_port_set(struct mlxsw_sp *mlxsw_sp, u16 mid, 1479 u16 smpe, u16 local_port, bool member); 1480 int mlxsw_sp_pgt_init(struct mlxsw_sp *mlxsw_sp); 1481 void mlxsw_sp_pgt_fini(struct mlxsw_sp *mlxsw_sp); 1482 1483 #endif 1484