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/types.h> 8 #include <linux/netdevice.h> 9 #include <linux/rhashtable.h> 10 #include <linux/bitops.h> 11 #include <linux/if_bridge.h> 12 #include <linux/if_vlan.h> 13 #include <linux/list.h> 14 #include <linux/dcbnl.h> 15 #include <linux/in6.h> 16 #include <linux/notifier.h> 17 #include <net/psample.h> 18 #include <net/pkt_cls.h> 19 #include <net/red.h> 20 #include <net/vxlan.h> 21 22 #include "port.h" 23 #include "core.h" 24 #include "core_acl_flex_keys.h" 25 #include "core_acl_flex_actions.h" 26 #include "reg.h" 27 28 #define MLXSW_SP_DEFAULT_VID (VLAN_N_VID - 1) 29 30 #define MLXSW_SP_FID_8021D_MAX 1024 31 32 #define MLXSW_SP_MID_MAX 7000 33 34 #define MLXSW_SP_PORTS_PER_CLUSTER_MAX 4 35 36 #define MLXSW_SP_PORT_BASE_SPEED_25G 25000 /* Mb/s */ 37 #define MLXSW_SP_PORT_BASE_SPEED_50G 50000 /* Mb/s */ 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 enum mlxsw_sp_resource_id { 51 MLXSW_SP_RESOURCE_KVD = 1, 52 MLXSW_SP_RESOURCE_KVD_LINEAR, 53 MLXSW_SP_RESOURCE_KVD_HASH_SINGLE, 54 MLXSW_SP_RESOURCE_KVD_HASH_DOUBLE, 55 MLXSW_SP_RESOURCE_KVD_LINEAR_SINGLE, 56 MLXSW_SP_RESOURCE_KVD_LINEAR_CHUNKS, 57 MLXSW_SP_RESOURCE_KVD_LINEAR_LARGE_CHUNKS, 58 }; 59 60 struct mlxsw_sp_port; 61 struct mlxsw_sp_rif; 62 struct mlxsw_sp_span_entry; 63 enum mlxsw_sp_l3proto; 64 union mlxsw_sp_l3addr; 65 66 struct mlxsw_sp_upper { 67 struct net_device *dev; 68 unsigned int ref_count; 69 }; 70 71 enum mlxsw_sp_rif_type { 72 MLXSW_SP_RIF_TYPE_SUBPORT, 73 MLXSW_SP_RIF_TYPE_VLAN, 74 MLXSW_SP_RIF_TYPE_FID, 75 MLXSW_SP_RIF_TYPE_IPIP_LB, /* IP-in-IP loopback. */ 76 MLXSW_SP_RIF_TYPE_MAX, 77 }; 78 79 struct mlxsw_sp_rif_ops; 80 81 extern const struct mlxsw_sp_rif_ops *mlxsw_sp1_rif_ops_arr[]; 82 extern const struct mlxsw_sp_rif_ops *mlxsw_sp2_rif_ops_arr[]; 83 84 enum mlxsw_sp_fid_type { 85 MLXSW_SP_FID_TYPE_8021Q, 86 MLXSW_SP_FID_TYPE_8021D, 87 MLXSW_SP_FID_TYPE_RFID, 88 MLXSW_SP_FID_TYPE_DUMMY, 89 MLXSW_SP_FID_TYPE_MAX, 90 }; 91 92 enum mlxsw_sp_nve_type { 93 MLXSW_SP_NVE_TYPE_VXLAN, 94 }; 95 96 struct mlxsw_sp_mid { 97 struct list_head list; 98 unsigned char addr[ETH_ALEN]; 99 u16 fid; 100 u16 mid; 101 bool in_hw; 102 unsigned long *ports_in_mid; /* bits array */ 103 }; 104 105 enum mlxsw_sp_port_mall_action_type { 106 MLXSW_SP_PORT_MALL_MIRROR, 107 MLXSW_SP_PORT_MALL_SAMPLE, 108 }; 109 110 struct mlxsw_sp_port_mall_mirror_tc_entry { 111 int span_id; 112 bool ingress; 113 }; 114 115 struct mlxsw_sp_port_mall_tc_entry { 116 struct list_head list; 117 unsigned long cookie; 118 enum mlxsw_sp_port_mall_action_type type; 119 union { 120 struct mlxsw_sp_port_mall_mirror_tc_entry mirror; 121 }; 122 }; 123 124 struct mlxsw_sp_sb; 125 struct mlxsw_sp_bridge; 126 struct mlxsw_sp_router; 127 struct mlxsw_sp_mr; 128 struct mlxsw_sp_acl; 129 struct mlxsw_sp_counter_pool; 130 struct mlxsw_sp_fid_core; 131 struct mlxsw_sp_kvdl; 132 struct mlxsw_sp_nve; 133 struct mlxsw_sp_kvdl_ops; 134 struct mlxsw_sp_mr_tcam_ops; 135 struct mlxsw_sp_acl_tcam_ops; 136 struct mlxsw_sp_nve_ops; 137 struct mlxsw_sp_sb_vals; 138 struct mlxsw_sp_port_type_speed_ops; 139 140 struct mlxsw_sp { 141 struct mlxsw_sp_port **ports; 142 struct mlxsw_core *core; 143 const struct mlxsw_bus_info *bus_info; 144 unsigned char base_mac[ETH_ALEN]; 145 const unsigned char *mac_mask; 146 struct mlxsw_sp_upper *lags; 147 int *port_to_module; 148 struct mlxsw_sp_sb *sb; 149 struct mlxsw_sp_bridge *bridge; 150 struct mlxsw_sp_router *router; 151 struct mlxsw_sp_mr *mr; 152 struct mlxsw_afa *afa; 153 struct mlxsw_sp_acl *acl; 154 struct mlxsw_sp_fid_core *fid_core; 155 struct mlxsw_sp_kvdl *kvdl; 156 struct mlxsw_sp_nve *nve; 157 struct notifier_block netdevice_nb; 158 159 struct mlxsw_sp_counter_pool *counter_pool; 160 struct { 161 struct mlxsw_sp_span_entry *entries; 162 int entries_count; 163 } span; 164 const struct mlxsw_fw_rev *req_rev; 165 const char *fw_filename; 166 const struct mlxsw_sp_kvdl_ops *kvdl_ops; 167 const struct mlxsw_afa_ops *afa_ops; 168 const struct mlxsw_afk_ops *afk_ops; 169 const struct mlxsw_sp_mr_tcam_ops *mr_tcam_ops; 170 const struct mlxsw_sp_acl_tcam_ops *acl_tcam_ops; 171 const struct mlxsw_sp_nve_ops **nve_ops_arr; 172 const struct mlxsw_sp_rif_ops **rif_ops_arr; 173 const struct mlxsw_sp_sb_vals *sb_vals; 174 const struct mlxsw_sp_port_type_speed_ops *port_type_speed_ops; 175 }; 176 177 static inline struct mlxsw_sp_upper * 178 mlxsw_sp_lag_get(struct mlxsw_sp *mlxsw_sp, u16 lag_id) 179 { 180 return &mlxsw_sp->lags[lag_id]; 181 } 182 183 struct mlxsw_sp_port_pcpu_stats { 184 u64 rx_packets; 185 u64 rx_bytes; 186 u64 tx_packets; 187 u64 tx_bytes; 188 struct u64_stats_sync syncp; 189 u32 tx_dropped; 190 }; 191 192 struct mlxsw_sp_port_sample { 193 struct psample_group __rcu *psample_group; 194 u32 trunc_size; 195 u32 rate; 196 bool truncate; 197 }; 198 199 struct mlxsw_sp_bridge_port; 200 struct mlxsw_sp_fid; 201 202 struct mlxsw_sp_port_vlan { 203 struct list_head list; 204 struct mlxsw_sp_port *mlxsw_sp_port; 205 struct mlxsw_sp_fid *fid; 206 u16 vid; 207 struct mlxsw_sp_bridge_port *bridge_port; 208 struct list_head bridge_vlan_node; 209 }; 210 211 /* No need an internal lock; At worse - miss a single periodic iteration */ 212 struct mlxsw_sp_port_xstats { 213 u64 ecn; 214 u64 wred_drop[TC_MAX_QUEUE]; 215 u64 tail_drop[TC_MAX_QUEUE]; 216 u64 backlog[TC_MAX_QUEUE]; 217 u64 tx_bytes[IEEE_8021QAZ_MAX_TCS]; 218 u64 tx_packets[IEEE_8021QAZ_MAX_TCS]; 219 }; 220 221 struct mlxsw_sp_port { 222 struct net_device *dev; 223 struct mlxsw_sp_port_pcpu_stats __percpu *pcpu_stats; 224 struct mlxsw_sp *mlxsw_sp; 225 u8 local_port; 226 u8 lagged:1, 227 split:1; 228 u16 pvid; 229 u16 lag_id; 230 struct { 231 u8 tx_pause:1, 232 rx_pause:1, 233 autoneg:1; 234 } link; 235 struct { 236 struct ieee_ets *ets; 237 struct ieee_maxrate *maxrate; 238 struct ieee_pfc *pfc; 239 enum mlxsw_reg_qpts_trust_state trust_state; 240 } dcb; 241 struct { 242 u8 module; 243 u8 width; 244 u8 lane; 245 } mapping; 246 /* TC handles */ 247 struct list_head mall_tc_list; 248 struct { 249 #define MLXSW_HW_STATS_UPDATE_TIME HZ 250 struct rtnl_link_stats64 stats; 251 struct mlxsw_sp_port_xstats xstats; 252 struct delayed_work update_dw; 253 } periodic_hw_stats; 254 struct mlxsw_sp_port_sample *sample; 255 struct list_head vlans_list; 256 struct mlxsw_sp_port_vlan *default_vlan; 257 struct mlxsw_sp_qdisc *root_qdisc; 258 struct mlxsw_sp_qdisc *tclass_qdiscs; 259 unsigned acl_rule_count; 260 struct mlxsw_sp_acl_block *ing_acl_block; 261 struct mlxsw_sp_acl_block *eg_acl_block; 262 }; 263 264 struct mlxsw_sp_port_type_speed_ops { 265 void (*from_ptys_supported_port)(struct mlxsw_sp *mlxsw_sp, 266 u32 ptys_eth_proto, 267 struct ethtool_link_ksettings *cmd); 268 void (*from_ptys_link)(struct mlxsw_sp *mlxsw_sp, u32 ptys_eth_proto, 269 unsigned long *mode); 270 void (*from_ptys_speed_duplex)(struct mlxsw_sp *mlxsw_sp, 271 bool carrier_ok, u32 ptys_eth_proto, 272 struct ethtool_link_ksettings *cmd); 273 u32 (*to_ptys_advert_link)(struct mlxsw_sp *mlxsw_sp, 274 const struct ethtool_link_ksettings *cmd); 275 u32 (*to_ptys_speed)(struct mlxsw_sp *mlxsw_sp, u32 speed); 276 u32 (*to_ptys_upper_speed)(struct mlxsw_sp *mlxsw_sp, u32 upper_speed); 277 int (*port_speed_base)(struct mlxsw_sp *mlxsw_sp, u8 local_port, 278 u32 *base_speed); 279 void (*reg_ptys_eth_pack)(struct mlxsw_sp *mlxsw_sp, char *payload, 280 u8 local_port, u32 proto_admin, bool autoneg); 281 void (*reg_ptys_eth_unpack)(struct mlxsw_sp *mlxsw_sp, char *payload, 282 u32 *p_eth_proto_cap, 283 u32 *p_eth_proto_admin, 284 u32 *p_eth_proto_oper); 285 }; 286 287 static inline struct net_device * 288 mlxsw_sp_bridge_vxlan_dev_find(struct net_device *br_dev) 289 { 290 struct net_device *dev; 291 struct list_head *iter; 292 293 netdev_for_each_lower_dev(br_dev, dev, iter) { 294 if (netif_is_vxlan(dev)) 295 return dev; 296 } 297 298 return NULL; 299 } 300 301 static inline bool mlxsw_sp_bridge_has_vxlan(struct net_device *br_dev) 302 { 303 return !!mlxsw_sp_bridge_vxlan_dev_find(br_dev); 304 } 305 306 static inline int 307 mlxsw_sp_vxlan_mapped_vid(const struct net_device *vxlan_dev, u16 *p_vid) 308 { 309 struct bridge_vlan_info vinfo; 310 u16 vid = 0; 311 int err; 312 313 err = br_vlan_get_pvid(vxlan_dev, &vid); 314 if (err || !vid) 315 goto out; 316 317 err = br_vlan_get_info(vxlan_dev, vid, &vinfo); 318 if (err || !(vinfo.flags & BRIDGE_VLAN_INFO_UNTAGGED)) 319 vid = 0; 320 321 out: 322 *p_vid = vid; 323 return err; 324 } 325 326 static inline bool 327 mlxsw_sp_port_is_pause_en(const struct mlxsw_sp_port *mlxsw_sp_port) 328 { 329 return mlxsw_sp_port->link.tx_pause || mlxsw_sp_port->link.rx_pause; 330 } 331 332 static inline struct mlxsw_sp_port * 333 mlxsw_sp_port_lagged_get(struct mlxsw_sp *mlxsw_sp, u16 lag_id, u8 port_index) 334 { 335 struct mlxsw_sp_port *mlxsw_sp_port; 336 u8 local_port; 337 338 local_port = mlxsw_core_lag_mapping_get(mlxsw_sp->core, 339 lag_id, port_index); 340 mlxsw_sp_port = mlxsw_sp->ports[local_port]; 341 return mlxsw_sp_port && mlxsw_sp_port->lagged ? mlxsw_sp_port : NULL; 342 } 343 344 static inline struct mlxsw_sp_port_vlan * 345 mlxsw_sp_port_vlan_find_by_vid(const struct mlxsw_sp_port *mlxsw_sp_port, 346 u16 vid) 347 { 348 struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan; 349 350 list_for_each_entry(mlxsw_sp_port_vlan, &mlxsw_sp_port->vlans_list, 351 list) { 352 if (mlxsw_sp_port_vlan->vid == vid) 353 return mlxsw_sp_port_vlan; 354 } 355 356 return NULL; 357 } 358 359 enum mlxsw_sp_flood_type { 360 MLXSW_SP_FLOOD_TYPE_UC, 361 MLXSW_SP_FLOOD_TYPE_BC, 362 MLXSW_SP_FLOOD_TYPE_MC, 363 }; 364 365 /* spectrum_buffers.c */ 366 int mlxsw_sp_buffers_init(struct mlxsw_sp *mlxsw_sp); 367 void mlxsw_sp_buffers_fini(struct mlxsw_sp *mlxsw_sp); 368 int mlxsw_sp_port_buffers_init(struct mlxsw_sp_port *mlxsw_sp_port); 369 int mlxsw_sp_sb_pool_get(struct mlxsw_core *mlxsw_core, 370 unsigned int sb_index, u16 pool_index, 371 struct devlink_sb_pool_info *pool_info); 372 int mlxsw_sp_sb_pool_set(struct mlxsw_core *mlxsw_core, 373 unsigned int sb_index, u16 pool_index, u32 size, 374 enum devlink_sb_threshold_type threshold_type, 375 struct netlink_ext_ack *extack); 376 int mlxsw_sp_sb_port_pool_get(struct mlxsw_core_port *mlxsw_core_port, 377 unsigned int sb_index, u16 pool_index, 378 u32 *p_threshold); 379 int mlxsw_sp_sb_port_pool_set(struct mlxsw_core_port *mlxsw_core_port, 380 unsigned int sb_index, u16 pool_index, 381 u32 threshold, struct netlink_ext_ack *extack); 382 int mlxsw_sp_sb_tc_pool_bind_get(struct mlxsw_core_port *mlxsw_core_port, 383 unsigned int sb_index, u16 tc_index, 384 enum devlink_sb_pool_type pool_type, 385 u16 *p_pool_index, u32 *p_threshold); 386 int mlxsw_sp_sb_tc_pool_bind_set(struct mlxsw_core_port *mlxsw_core_port, 387 unsigned int sb_index, u16 tc_index, 388 enum devlink_sb_pool_type pool_type, 389 u16 pool_index, u32 threshold, 390 struct netlink_ext_ack *extack); 391 int mlxsw_sp_sb_occ_snapshot(struct mlxsw_core *mlxsw_core, 392 unsigned int sb_index); 393 int mlxsw_sp_sb_occ_max_clear(struct mlxsw_core *mlxsw_core, 394 unsigned int sb_index); 395 int mlxsw_sp_sb_occ_port_pool_get(struct mlxsw_core_port *mlxsw_core_port, 396 unsigned int sb_index, u16 pool_index, 397 u32 *p_cur, u32 *p_max); 398 int mlxsw_sp_sb_occ_tc_port_bind_get(struct mlxsw_core_port *mlxsw_core_port, 399 unsigned int sb_index, u16 tc_index, 400 enum devlink_sb_pool_type pool_type, 401 u32 *p_cur, u32 *p_max); 402 u32 mlxsw_sp_cells_bytes(const struct mlxsw_sp *mlxsw_sp, u32 cells); 403 u32 mlxsw_sp_bytes_cells(const struct mlxsw_sp *mlxsw_sp, u32 bytes); 404 u32 mlxsw_sp_sb_max_headroom_cells(const struct mlxsw_sp *mlxsw_sp); 405 406 extern const struct mlxsw_sp_sb_vals mlxsw_sp1_sb_vals; 407 extern const struct mlxsw_sp_sb_vals mlxsw_sp2_sb_vals; 408 409 /* spectrum_switchdev.c */ 410 int mlxsw_sp_switchdev_init(struct mlxsw_sp *mlxsw_sp); 411 void mlxsw_sp_switchdev_fini(struct mlxsw_sp *mlxsw_sp); 412 int mlxsw_sp_rif_fdb_op(struct mlxsw_sp *mlxsw_sp, const char *mac, u16 fid, 413 bool adding); 414 void 415 mlxsw_sp_port_vlan_bridge_leave(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan); 416 int mlxsw_sp_port_bridge_join(struct mlxsw_sp_port *mlxsw_sp_port, 417 struct net_device *brport_dev, 418 struct net_device *br_dev, 419 struct netlink_ext_ack *extack); 420 void mlxsw_sp_port_bridge_leave(struct mlxsw_sp_port *mlxsw_sp_port, 421 struct net_device *brport_dev, 422 struct net_device *br_dev); 423 bool mlxsw_sp_bridge_device_is_offloaded(const struct mlxsw_sp *mlxsw_sp, 424 const struct net_device *br_dev); 425 int mlxsw_sp_bridge_vxlan_join(struct mlxsw_sp *mlxsw_sp, 426 const struct net_device *br_dev, 427 const struct net_device *vxlan_dev, u16 vid, 428 struct netlink_ext_ack *extack); 429 void mlxsw_sp_bridge_vxlan_leave(struct mlxsw_sp *mlxsw_sp, 430 const struct net_device *vxlan_dev); 431 struct mlxsw_sp_fid *mlxsw_sp_bridge_fid_get(struct mlxsw_sp *mlxsw_sp, 432 const struct net_device *br_dev, 433 u16 vid, 434 struct netlink_ext_ack *extack); 435 extern struct notifier_block mlxsw_sp_switchdev_notifier; 436 437 /* spectrum.c */ 438 int mlxsw_sp_port_ets_set(struct mlxsw_sp_port *mlxsw_sp_port, 439 enum mlxsw_reg_qeec_hr hr, u8 index, u8 next_index, 440 bool dwrr, u8 dwrr_weight); 441 int mlxsw_sp_port_prio_tc_set(struct mlxsw_sp_port *mlxsw_sp_port, 442 u8 switch_prio, u8 tclass); 443 int __mlxsw_sp_port_headroom_set(struct mlxsw_sp_port *mlxsw_sp_port, int mtu, 444 u8 *prio_tc, bool pause_en, 445 struct ieee_pfc *my_pfc); 446 int mlxsw_sp_port_ets_maxrate_set(struct mlxsw_sp_port *mlxsw_sp_port, 447 enum mlxsw_reg_qeec_hr hr, u8 index, 448 u8 next_index, u32 maxrate); 449 enum mlxsw_reg_spms_state mlxsw_sp_stp_spms_state(u8 stp_state); 450 int mlxsw_sp_port_vid_stp_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid, 451 u8 state); 452 int mlxsw_sp_port_vp_mode_set(struct mlxsw_sp_port *mlxsw_sp_port, bool enable); 453 int mlxsw_sp_port_vid_learning_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid, 454 bool learn_enable); 455 int mlxsw_sp_port_pvid_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid); 456 struct mlxsw_sp_port_vlan * 457 mlxsw_sp_port_vlan_create(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid); 458 void mlxsw_sp_port_vlan_destroy(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan); 459 int mlxsw_sp_port_vlan_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid_begin, 460 u16 vid_end, bool is_member, bool untagged); 461 int mlxsw_sp_flow_counter_get(struct mlxsw_sp *mlxsw_sp, 462 unsigned int counter_index, u64 *packets, 463 u64 *bytes); 464 int mlxsw_sp_flow_counter_alloc(struct mlxsw_sp *mlxsw_sp, 465 unsigned int *p_counter_index); 466 void mlxsw_sp_flow_counter_free(struct mlxsw_sp *mlxsw_sp, 467 unsigned int counter_index); 468 bool mlxsw_sp_port_dev_check(const struct net_device *dev); 469 struct mlxsw_sp *mlxsw_sp_lower_get(struct net_device *dev); 470 struct mlxsw_sp_port *mlxsw_sp_port_dev_lower_find(struct net_device *dev); 471 struct mlxsw_sp_port *mlxsw_sp_port_lower_dev_hold(struct net_device *dev); 472 void mlxsw_sp_port_dev_put(struct mlxsw_sp_port *mlxsw_sp_port); 473 struct mlxsw_sp_port *mlxsw_sp_port_dev_lower_find_rcu(struct net_device *dev); 474 475 /* spectrum_dcb.c */ 476 #ifdef CONFIG_MLXSW_SPECTRUM_DCB 477 int mlxsw_sp_port_dcb_init(struct mlxsw_sp_port *mlxsw_sp_port); 478 void mlxsw_sp_port_dcb_fini(struct mlxsw_sp_port *mlxsw_sp_port); 479 #else 480 static inline int mlxsw_sp_port_dcb_init(struct mlxsw_sp_port *mlxsw_sp_port) 481 { 482 return 0; 483 } 484 static inline void mlxsw_sp_port_dcb_fini(struct mlxsw_sp_port *mlxsw_sp_port) 485 {} 486 #endif 487 488 /* spectrum_router.c */ 489 enum mlxsw_sp_l3proto { 490 MLXSW_SP_L3_PROTO_IPV4, 491 MLXSW_SP_L3_PROTO_IPV6, 492 #define MLXSW_SP_L3_PROTO_MAX (MLXSW_SP_L3_PROTO_IPV6 + 1) 493 }; 494 495 union mlxsw_sp_l3addr { 496 __be32 addr4; 497 struct in6_addr addr6; 498 }; 499 500 int mlxsw_sp_router_init(struct mlxsw_sp *mlxsw_sp); 501 void mlxsw_sp_router_fini(struct mlxsw_sp *mlxsw_sp); 502 int mlxsw_sp_netdevice_router_port_event(struct net_device *dev, 503 unsigned long event, void *ptr); 504 void mlxsw_sp_rif_macvlan_del(struct mlxsw_sp *mlxsw_sp, 505 const struct net_device *macvlan_dev); 506 int mlxsw_sp_inetaddr_valid_event(struct notifier_block *unused, 507 unsigned long event, void *ptr); 508 int mlxsw_sp_inet6addr_valid_event(struct notifier_block *unused, 509 unsigned long event, void *ptr); 510 int mlxsw_sp_netdevice_vrf_event(struct net_device *l3_dev, unsigned long event, 511 struct netdev_notifier_changeupper_info *info); 512 bool mlxsw_sp_netdev_is_ipip_ol(const struct mlxsw_sp *mlxsw_sp, 513 const struct net_device *dev); 514 bool mlxsw_sp_netdev_is_ipip_ul(const struct mlxsw_sp *mlxsw_sp, 515 const struct net_device *dev); 516 int mlxsw_sp_netdevice_ipip_ol_event(struct mlxsw_sp *mlxsw_sp, 517 struct net_device *l3_dev, 518 unsigned long event, 519 struct netdev_notifier_info *info); 520 int 521 mlxsw_sp_netdevice_ipip_ul_event(struct mlxsw_sp *mlxsw_sp, 522 struct net_device *l3_dev, 523 unsigned long event, 524 struct netdev_notifier_info *info); 525 void 526 mlxsw_sp_port_vlan_router_leave(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan); 527 void mlxsw_sp_rif_destroy_by_dev(struct mlxsw_sp *mlxsw_sp, 528 struct net_device *dev); 529 struct mlxsw_sp_rif *mlxsw_sp_rif_find_by_dev(const struct mlxsw_sp *mlxsw_sp, 530 const struct net_device *dev); 531 u8 mlxsw_sp_router_port(const struct mlxsw_sp *mlxsw_sp); 532 struct mlxsw_sp_fid *mlxsw_sp_rif_fid(const struct mlxsw_sp_rif *rif); 533 int mlxsw_sp_router_nve_promote_decap(struct mlxsw_sp *mlxsw_sp, u32 ul_tb_id, 534 enum mlxsw_sp_l3proto ul_proto, 535 const union mlxsw_sp_l3addr *ul_sip, 536 u32 tunnel_index); 537 void mlxsw_sp_router_nve_demote_decap(struct mlxsw_sp *mlxsw_sp, u32 ul_tb_id, 538 enum mlxsw_sp_l3proto ul_proto, 539 const union mlxsw_sp_l3addr *ul_sip); 540 int mlxsw_sp_router_tb_id_vr_id(struct mlxsw_sp *mlxsw_sp, u32 tb_id, 541 u16 *vr_id); 542 int mlxsw_sp_router_ul_rif_get(struct mlxsw_sp *mlxsw_sp, u32 ul_tb_id, 543 u16 *ul_rif_index); 544 void mlxsw_sp_router_ul_rif_put(struct mlxsw_sp *mlxsw_sp, u16 ul_rif_index); 545 546 /* spectrum_kvdl.c */ 547 enum mlxsw_sp_kvdl_entry_type { 548 MLXSW_SP_KVDL_ENTRY_TYPE_ADJ, 549 MLXSW_SP_KVDL_ENTRY_TYPE_ACTSET, 550 MLXSW_SP_KVDL_ENTRY_TYPE_PBS, 551 MLXSW_SP_KVDL_ENTRY_TYPE_MCRIGR, 552 MLXSW_SP_KVDL_ENTRY_TYPE_TNUMT, 553 }; 554 555 static inline unsigned int 556 mlxsw_sp_kvdl_entry_size(enum mlxsw_sp_kvdl_entry_type type) 557 { 558 switch (type) { 559 case MLXSW_SP_KVDL_ENTRY_TYPE_ADJ: /* fall through */ 560 case MLXSW_SP_KVDL_ENTRY_TYPE_ACTSET: /* fall through */ 561 case MLXSW_SP_KVDL_ENTRY_TYPE_PBS: /* fall through */ 562 case MLXSW_SP_KVDL_ENTRY_TYPE_MCRIGR: /* fall through */ 563 case MLXSW_SP_KVDL_ENTRY_TYPE_TNUMT: /* fall through */ 564 default: 565 return 1; 566 } 567 } 568 569 struct mlxsw_sp_kvdl_ops { 570 size_t priv_size; 571 int (*init)(struct mlxsw_sp *mlxsw_sp, void *priv); 572 void (*fini)(struct mlxsw_sp *mlxsw_sp, void *priv); 573 int (*alloc)(struct mlxsw_sp *mlxsw_sp, void *priv, 574 enum mlxsw_sp_kvdl_entry_type type, 575 unsigned int entry_count, u32 *p_entry_index); 576 void (*free)(struct mlxsw_sp *mlxsw_sp, void *priv, 577 enum mlxsw_sp_kvdl_entry_type type, 578 unsigned int entry_count, int entry_index); 579 int (*alloc_size_query)(struct mlxsw_sp *mlxsw_sp, void *priv, 580 enum mlxsw_sp_kvdl_entry_type type, 581 unsigned int entry_count, 582 unsigned int *p_alloc_count); 583 int (*resources_register)(struct mlxsw_sp *mlxsw_sp, void *priv); 584 }; 585 586 int mlxsw_sp_kvdl_init(struct mlxsw_sp *mlxsw_sp); 587 void mlxsw_sp_kvdl_fini(struct mlxsw_sp *mlxsw_sp); 588 int mlxsw_sp_kvdl_alloc(struct mlxsw_sp *mlxsw_sp, 589 enum mlxsw_sp_kvdl_entry_type type, 590 unsigned int entry_count, u32 *p_entry_index); 591 void mlxsw_sp_kvdl_free(struct mlxsw_sp *mlxsw_sp, 592 enum mlxsw_sp_kvdl_entry_type type, 593 unsigned int entry_count, int entry_index); 594 int mlxsw_sp_kvdl_alloc_count_query(struct mlxsw_sp *mlxsw_sp, 595 enum mlxsw_sp_kvdl_entry_type type, 596 unsigned int entry_count, 597 unsigned int *p_alloc_count); 598 599 /* spectrum1_kvdl.c */ 600 extern const struct mlxsw_sp_kvdl_ops mlxsw_sp1_kvdl_ops; 601 int mlxsw_sp1_kvdl_resources_register(struct mlxsw_core *mlxsw_core); 602 603 /* spectrum2_kvdl.c */ 604 extern const struct mlxsw_sp_kvdl_ops mlxsw_sp2_kvdl_ops; 605 606 struct mlxsw_sp_acl_rule_info { 607 unsigned int priority; 608 struct mlxsw_afk_element_values values; 609 struct mlxsw_afa_block *act_block; 610 u8 action_created:1; 611 unsigned int counter_index; 612 }; 613 614 struct mlxsw_sp_acl_block; 615 struct mlxsw_sp_acl_ruleset; 616 617 /* spectrum_acl.c */ 618 enum mlxsw_sp_acl_profile { 619 MLXSW_SP_ACL_PROFILE_FLOWER, 620 MLXSW_SP_ACL_PROFILE_MR, 621 }; 622 623 struct mlxsw_afk *mlxsw_sp_acl_afk(struct mlxsw_sp_acl *acl); 624 struct mlxsw_sp *mlxsw_sp_acl_block_mlxsw_sp(struct mlxsw_sp_acl_block *block); 625 unsigned int mlxsw_sp_acl_block_rule_count(struct mlxsw_sp_acl_block *block); 626 void mlxsw_sp_acl_block_disable_inc(struct mlxsw_sp_acl_block *block); 627 void mlxsw_sp_acl_block_disable_dec(struct mlxsw_sp_acl_block *block); 628 bool mlxsw_sp_acl_block_disabled(struct mlxsw_sp_acl_block *block); 629 struct mlxsw_sp_acl_block *mlxsw_sp_acl_block_create(struct mlxsw_sp *mlxsw_sp, 630 struct net *net); 631 void mlxsw_sp_acl_block_destroy(struct mlxsw_sp_acl_block *block); 632 int mlxsw_sp_acl_block_bind(struct mlxsw_sp *mlxsw_sp, 633 struct mlxsw_sp_acl_block *block, 634 struct mlxsw_sp_port *mlxsw_sp_port, 635 bool ingress); 636 int mlxsw_sp_acl_block_unbind(struct mlxsw_sp *mlxsw_sp, 637 struct mlxsw_sp_acl_block *block, 638 struct mlxsw_sp_port *mlxsw_sp_port, 639 bool ingress); 640 bool mlxsw_sp_acl_block_is_egress_bound(struct mlxsw_sp_acl_block *block); 641 struct mlxsw_sp_acl_ruleset * 642 mlxsw_sp_acl_ruleset_lookup(struct mlxsw_sp *mlxsw_sp, 643 struct mlxsw_sp_acl_block *block, u32 chain_index, 644 enum mlxsw_sp_acl_profile profile); 645 struct mlxsw_sp_acl_ruleset * 646 mlxsw_sp_acl_ruleset_get(struct mlxsw_sp *mlxsw_sp, 647 struct mlxsw_sp_acl_block *block, u32 chain_index, 648 enum mlxsw_sp_acl_profile profile, 649 struct mlxsw_afk_element_usage *tmplt_elusage); 650 void mlxsw_sp_acl_ruleset_put(struct mlxsw_sp *mlxsw_sp, 651 struct mlxsw_sp_acl_ruleset *ruleset); 652 u16 mlxsw_sp_acl_ruleset_group_id(struct mlxsw_sp_acl_ruleset *ruleset); 653 654 struct mlxsw_sp_acl_rule_info * 655 mlxsw_sp_acl_rulei_create(struct mlxsw_sp_acl *acl, 656 struct mlxsw_afa_block *afa_block); 657 void mlxsw_sp_acl_rulei_destroy(struct mlxsw_sp_acl_rule_info *rulei); 658 int mlxsw_sp_acl_rulei_commit(struct mlxsw_sp_acl_rule_info *rulei); 659 void mlxsw_sp_acl_rulei_priority(struct mlxsw_sp_acl_rule_info *rulei, 660 unsigned int priority); 661 void mlxsw_sp_acl_rulei_keymask_u32(struct mlxsw_sp_acl_rule_info *rulei, 662 enum mlxsw_afk_element element, 663 u32 key_value, u32 mask_value); 664 void mlxsw_sp_acl_rulei_keymask_buf(struct mlxsw_sp_acl_rule_info *rulei, 665 enum mlxsw_afk_element element, 666 const char *key_value, 667 const char *mask_value, unsigned int len); 668 int mlxsw_sp_acl_rulei_act_continue(struct mlxsw_sp_acl_rule_info *rulei); 669 int mlxsw_sp_acl_rulei_act_jump(struct mlxsw_sp_acl_rule_info *rulei, 670 u16 group_id); 671 int mlxsw_sp_acl_rulei_act_terminate(struct mlxsw_sp_acl_rule_info *rulei); 672 int mlxsw_sp_acl_rulei_act_drop(struct mlxsw_sp_acl_rule_info *rulei); 673 int mlxsw_sp_acl_rulei_act_trap(struct mlxsw_sp_acl_rule_info *rulei); 674 int mlxsw_sp_acl_rulei_act_mirror(struct mlxsw_sp *mlxsw_sp, 675 struct mlxsw_sp_acl_rule_info *rulei, 676 struct mlxsw_sp_acl_block *block, 677 struct net_device *out_dev, 678 struct netlink_ext_ack *extack); 679 int mlxsw_sp_acl_rulei_act_fwd(struct mlxsw_sp *mlxsw_sp, 680 struct mlxsw_sp_acl_rule_info *rulei, 681 struct net_device *out_dev, 682 struct netlink_ext_ack *extack); 683 int mlxsw_sp_acl_rulei_act_vlan(struct mlxsw_sp *mlxsw_sp, 684 struct mlxsw_sp_acl_rule_info *rulei, 685 u32 action, u16 vid, u16 proto, u8 prio, 686 struct netlink_ext_ack *extack); 687 int mlxsw_sp_acl_rulei_act_count(struct mlxsw_sp *mlxsw_sp, 688 struct mlxsw_sp_acl_rule_info *rulei, 689 struct netlink_ext_ack *extack); 690 int mlxsw_sp_acl_rulei_act_fid_set(struct mlxsw_sp *mlxsw_sp, 691 struct mlxsw_sp_acl_rule_info *rulei, 692 u16 fid, struct netlink_ext_ack *extack); 693 694 struct mlxsw_sp_acl_rule; 695 696 struct mlxsw_sp_acl_rule * 697 mlxsw_sp_acl_rule_create(struct mlxsw_sp *mlxsw_sp, 698 struct mlxsw_sp_acl_ruleset *ruleset, 699 unsigned long cookie, 700 struct mlxsw_afa_block *afa_block, 701 struct netlink_ext_ack *extack); 702 void mlxsw_sp_acl_rule_destroy(struct mlxsw_sp *mlxsw_sp, 703 struct mlxsw_sp_acl_rule *rule); 704 int mlxsw_sp_acl_rule_add(struct mlxsw_sp *mlxsw_sp, 705 struct mlxsw_sp_acl_rule *rule); 706 void mlxsw_sp_acl_rule_del(struct mlxsw_sp *mlxsw_sp, 707 struct mlxsw_sp_acl_rule *rule); 708 int mlxsw_sp_acl_rule_action_replace(struct mlxsw_sp *mlxsw_sp, 709 struct mlxsw_sp_acl_rule *rule, 710 struct mlxsw_afa_block *afa_block); 711 struct mlxsw_sp_acl_rule * 712 mlxsw_sp_acl_rule_lookup(struct mlxsw_sp *mlxsw_sp, 713 struct mlxsw_sp_acl_ruleset *ruleset, 714 unsigned long cookie); 715 struct mlxsw_sp_acl_rule_info * 716 mlxsw_sp_acl_rule_rulei(struct mlxsw_sp_acl_rule *rule); 717 int mlxsw_sp_acl_rule_get_stats(struct mlxsw_sp *mlxsw_sp, 718 struct mlxsw_sp_acl_rule *rule, 719 u64 *packets, u64 *bytes, u64 *last_use); 720 721 struct mlxsw_sp_fid *mlxsw_sp_acl_dummy_fid(struct mlxsw_sp *mlxsw_sp); 722 723 int mlxsw_sp_acl_init(struct mlxsw_sp *mlxsw_sp); 724 void mlxsw_sp_acl_fini(struct mlxsw_sp *mlxsw_sp); 725 u32 mlxsw_sp_acl_region_rehash_intrvl_get(struct mlxsw_sp *mlxsw_sp); 726 int mlxsw_sp_acl_region_rehash_intrvl_set(struct mlxsw_sp *mlxsw_sp, u32 val); 727 728 /* spectrum_acl_tcam.c */ 729 struct mlxsw_sp_acl_tcam; 730 struct mlxsw_sp_acl_tcam_region; 731 732 struct mlxsw_sp_acl_tcam_ops { 733 enum mlxsw_reg_ptar_key_type key_type; 734 size_t priv_size; 735 int (*init)(struct mlxsw_sp *mlxsw_sp, void *priv, 736 struct mlxsw_sp_acl_tcam *tcam); 737 void (*fini)(struct mlxsw_sp *mlxsw_sp, void *priv); 738 size_t region_priv_size; 739 int (*region_init)(struct mlxsw_sp *mlxsw_sp, void *region_priv, 740 void *tcam_priv, 741 struct mlxsw_sp_acl_tcam_region *region, 742 void *hints_priv); 743 void (*region_fini)(struct mlxsw_sp *mlxsw_sp, void *region_priv); 744 int (*region_associate)(struct mlxsw_sp *mlxsw_sp, 745 struct mlxsw_sp_acl_tcam_region *region); 746 void * (*region_rehash_hints_get)(void *region_priv); 747 void (*region_rehash_hints_put)(void *hints_priv); 748 size_t chunk_priv_size; 749 void (*chunk_init)(void *region_priv, void *chunk_priv, 750 unsigned int priority); 751 void (*chunk_fini)(void *chunk_priv); 752 size_t entry_priv_size; 753 int (*entry_add)(struct mlxsw_sp *mlxsw_sp, 754 void *region_priv, void *chunk_priv, 755 void *entry_priv, 756 struct mlxsw_sp_acl_rule_info *rulei); 757 void (*entry_del)(struct mlxsw_sp *mlxsw_sp, 758 void *region_priv, void *chunk_priv, 759 void *entry_priv); 760 int (*entry_action_replace)(struct mlxsw_sp *mlxsw_sp, 761 void *region_priv, void *entry_priv, 762 struct mlxsw_sp_acl_rule_info *rulei); 763 int (*entry_activity_get)(struct mlxsw_sp *mlxsw_sp, 764 void *region_priv, void *entry_priv, 765 bool *activity); 766 }; 767 768 /* spectrum1_acl_tcam.c */ 769 extern const struct mlxsw_sp_acl_tcam_ops mlxsw_sp1_acl_tcam_ops; 770 771 /* spectrum2_acl_tcam.c */ 772 extern const struct mlxsw_sp_acl_tcam_ops mlxsw_sp2_acl_tcam_ops; 773 774 /* spectrum_acl_flex_actions.c */ 775 extern const struct mlxsw_afa_ops mlxsw_sp1_act_afa_ops; 776 extern const struct mlxsw_afa_ops mlxsw_sp2_act_afa_ops; 777 778 /* spectrum_acl_flex_keys.c */ 779 extern const struct mlxsw_afk_ops mlxsw_sp1_afk_ops; 780 extern const struct mlxsw_afk_ops mlxsw_sp2_afk_ops; 781 782 /* spectrum_flower.c */ 783 int mlxsw_sp_flower_replace(struct mlxsw_sp *mlxsw_sp, 784 struct mlxsw_sp_acl_block *block, 785 struct tc_cls_flower_offload *f); 786 void mlxsw_sp_flower_destroy(struct mlxsw_sp *mlxsw_sp, 787 struct mlxsw_sp_acl_block *block, 788 struct tc_cls_flower_offload *f); 789 int mlxsw_sp_flower_stats(struct mlxsw_sp *mlxsw_sp, 790 struct mlxsw_sp_acl_block *block, 791 struct tc_cls_flower_offload *f); 792 int mlxsw_sp_flower_tmplt_create(struct mlxsw_sp *mlxsw_sp, 793 struct mlxsw_sp_acl_block *block, 794 struct tc_cls_flower_offload *f); 795 void mlxsw_sp_flower_tmplt_destroy(struct mlxsw_sp *mlxsw_sp, 796 struct mlxsw_sp_acl_block *block, 797 struct tc_cls_flower_offload *f); 798 799 /* spectrum_qdisc.c */ 800 int mlxsw_sp_tc_qdisc_init(struct mlxsw_sp_port *mlxsw_sp_port); 801 void mlxsw_sp_tc_qdisc_fini(struct mlxsw_sp_port *mlxsw_sp_port); 802 int mlxsw_sp_setup_tc_red(struct mlxsw_sp_port *mlxsw_sp_port, 803 struct tc_red_qopt_offload *p); 804 int mlxsw_sp_setup_tc_prio(struct mlxsw_sp_port *mlxsw_sp_port, 805 struct tc_prio_qopt_offload *p); 806 807 /* spectrum_fid.c */ 808 bool mlxsw_sp_fid_lag_vid_valid(const struct mlxsw_sp_fid *fid); 809 struct mlxsw_sp_fid *mlxsw_sp_fid_lookup_by_index(struct mlxsw_sp *mlxsw_sp, 810 u16 fid_index); 811 int mlxsw_sp_fid_nve_ifindex(const struct mlxsw_sp_fid *fid, int *nve_ifindex); 812 int mlxsw_sp_fid_nve_type(const struct mlxsw_sp_fid *fid, 813 enum mlxsw_sp_nve_type *p_type); 814 struct mlxsw_sp_fid *mlxsw_sp_fid_lookup_by_vni(struct mlxsw_sp *mlxsw_sp, 815 __be32 vni); 816 int mlxsw_sp_fid_vni(const struct mlxsw_sp_fid *fid, __be32 *vni); 817 int mlxsw_sp_fid_nve_flood_index_set(struct mlxsw_sp_fid *fid, 818 u32 nve_flood_index); 819 void mlxsw_sp_fid_nve_flood_index_clear(struct mlxsw_sp_fid *fid); 820 bool mlxsw_sp_fid_nve_flood_index_is_set(const struct mlxsw_sp_fid *fid); 821 int mlxsw_sp_fid_vni_set(struct mlxsw_sp_fid *fid, enum mlxsw_sp_nve_type type, 822 __be32 vni, int nve_ifindex); 823 void mlxsw_sp_fid_vni_clear(struct mlxsw_sp_fid *fid); 824 bool mlxsw_sp_fid_vni_is_set(const struct mlxsw_sp_fid *fid); 825 void mlxsw_sp_fid_fdb_clear_offload(const struct mlxsw_sp_fid *fid, 826 const struct net_device *nve_dev); 827 int mlxsw_sp_fid_flood_set(struct mlxsw_sp_fid *fid, 828 enum mlxsw_sp_flood_type packet_type, u8 local_port, 829 bool member); 830 int mlxsw_sp_fid_port_vid_map(struct mlxsw_sp_fid *fid, 831 struct mlxsw_sp_port *mlxsw_sp_port, u16 vid); 832 void mlxsw_sp_fid_port_vid_unmap(struct mlxsw_sp_fid *fid, 833 struct mlxsw_sp_port *mlxsw_sp_port, u16 vid); 834 u16 mlxsw_sp_fid_index(const struct mlxsw_sp_fid *fid); 835 enum mlxsw_sp_fid_type mlxsw_sp_fid_type(const struct mlxsw_sp_fid *fid); 836 void mlxsw_sp_fid_rif_set(struct mlxsw_sp_fid *fid, struct mlxsw_sp_rif *rif); 837 struct mlxsw_sp_rif *mlxsw_sp_fid_rif(const struct mlxsw_sp_fid *fid); 838 enum mlxsw_sp_rif_type 839 mlxsw_sp_fid_type_rif_type(const struct mlxsw_sp *mlxsw_sp, 840 enum mlxsw_sp_fid_type type); 841 u16 mlxsw_sp_fid_8021q_vid(const struct mlxsw_sp_fid *fid); 842 struct mlxsw_sp_fid *mlxsw_sp_fid_8021q_get(struct mlxsw_sp *mlxsw_sp, u16 vid); 843 struct mlxsw_sp_fid *mlxsw_sp_fid_8021d_get(struct mlxsw_sp *mlxsw_sp, 844 int br_ifindex); 845 struct mlxsw_sp_fid *mlxsw_sp_fid_8021q_lookup(struct mlxsw_sp *mlxsw_sp, 846 u16 vid); 847 struct mlxsw_sp_fid *mlxsw_sp_fid_8021d_lookup(struct mlxsw_sp *mlxsw_sp, 848 int br_ifindex); 849 struct mlxsw_sp_fid *mlxsw_sp_fid_rfid_get(struct mlxsw_sp *mlxsw_sp, 850 u16 rif_index); 851 struct mlxsw_sp_fid *mlxsw_sp_fid_dummy_get(struct mlxsw_sp *mlxsw_sp); 852 void mlxsw_sp_fid_put(struct mlxsw_sp_fid *fid); 853 int mlxsw_sp_port_fids_init(struct mlxsw_sp_port *mlxsw_sp_port); 854 void mlxsw_sp_port_fids_fini(struct mlxsw_sp_port *mlxsw_sp_port); 855 int mlxsw_sp_fids_init(struct mlxsw_sp *mlxsw_sp); 856 void mlxsw_sp_fids_fini(struct mlxsw_sp *mlxsw_sp); 857 858 /* spectrum_mr.c */ 859 enum mlxsw_sp_mr_route_prio { 860 MLXSW_SP_MR_ROUTE_PRIO_SG, 861 MLXSW_SP_MR_ROUTE_PRIO_STARG, 862 MLXSW_SP_MR_ROUTE_PRIO_CATCHALL, 863 __MLXSW_SP_MR_ROUTE_PRIO_MAX 864 }; 865 866 #define MLXSW_SP_MR_ROUTE_PRIO_MAX (__MLXSW_SP_MR_ROUTE_PRIO_MAX - 1) 867 868 struct mlxsw_sp_mr_route_key; 869 870 struct mlxsw_sp_mr_tcam_ops { 871 size_t priv_size; 872 int (*init)(struct mlxsw_sp *mlxsw_sp, void *priv); 873 void (*fini)(void *priv); 874 size_t route_priv_size; 875 int (*route_create)(struct mlxsw_sp *mlxsw_sp, void *priv, 876 void *route_priv, 877 struct mlxsw_sp_mr_route_key *key, 878 struct mlxsw_afa_block *afa_block, 879 enum mlxsw_sp_mr_route_prio prio); 880 void (*route_destroy)(struct mlxsw_sp *mlxsw_sp, void *priv, 881 void *route_priv, 882 struct mlxsw_sp_mr_route_key *key); 883 int (*route_update)(struct mlxsw_sp *mlxsw_sp, void *route_priv, 884 struct mlxsw_sp_mr_route_key *key, 885 struct mlxsw_afa_block *afa_block); 886 }; 887 888 /* spectrum1_mr_tcam.c */ 889 extern const struct mlxsw_sp_mr_tcam_ops mlxsw_sp1_mr_tcam_ops; 890 891 /* spectrum2_mr_tcam.c */ 892 extern const struct mlxsw_sp_mr_tcam_ops mlxsw_sp2_mr_tcam_ops; 893 894 /* spectrum_nve.c */ 895 struct mlxsw_sp_nve_params { 896 enum mlxsw_sp_nve_type type; 897 __be32 vni; 898 const struct net_device *dev; 899 }; 900 901 extern const struct mlxsw_sp_nve_ops *mlxsw_sp1_nve_ops_arr[]; 902 extern const struct mlxsw_sp_nve_ops *mlxsw_sp2_nve_ops_arr[]; 903 904 int mlxsw_sp_nve_learned_ip_resolve(struct mlxsw_sp *mlxsw_sp, u32 uip, 905 enum mlxsw_sp_l3proto proto, 906 union mlxsw_sp_l3addr *addr); 907 int mlxsw_sp_nve_flood_ip_add(struct mlxsw_sp *mlxsw_sp, 908 struct mlxsw_sp_fid *fid, 909 enum mlxsw_sp_l3proto proto, 910 union mlxsw_sp_l3addr *addr); 911 void mlxsw_sp_nve_flood_ip_del(struct mlxsw_sp *mlxsw_sp, 912 struct mlxsw_sp_fid *fid, 913 enum mlxsw_sp_l3proto proto, 914 union mlxsw_sp_l3addr *addr); 915 u32 mlxsw_sp_nve_decap_tunnel_index_get(const struct mlxsw_sp *mlxsw_sp); 916 bool mlxsw_sp_nve_ipv4_route_is_decap(const struct mlxsw_sp *mlxsw_sp, 917 u32 tb_id, __be32 addr); 918 int mlxsw_sp_nve_fid_enable(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_fid *fid, 919 struct mlxsw_sp_nve_params *params, 920 struct netlink_ext_ack *extack); 921 void mlxsw_sp_nve_fid_disable(struct mlxsw_sp *mlxsw_sp, 922 struct mlxsw_sp_fid *fid); 923 int mlxsw_sp_port_nve_init(struct mlxsw_sp_port *mlxsw_sp_port); 924 void mlxsw_sp_port_nve_fini(struct mlxsw_sp_port *mlxsw_sp_port); 925 int mlxsw_sp_nve_init(struct mlxsw_sp *mlxsw_sp); 926 void mlxsw_sp_nve_fini(struct mlxsw_sp *mlxsw_sp); 927 928 #endif 929