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