Mark Bloch | 57cbd89 | 2018-01-16 14:04:14 +0000 | [diff] [blame] | 1 | /* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */ |
| 2 | /* |
| 3 | * Copyright (c) 2018 Mellanox Technologies. All rights reserved. |
| 4 | */ |
| 5 | |
| 6 | #ifndef _MLX5_ESWITCH_ |
| 7 | #define _MLX5_ESWITCH_ |
| 8 | |
| 9 | #include <linux/mlx5/driver.h> |
| 10 | |
Or Gerlitz | 0efc856 | 2018-05-31 11:16:18 +0300 | [diff] [blame] | 11 | #define MLX5_ESWITCH_MANAGER(mdev) MLX5_CAP_GEN(mdev, eswitch_manager) |
| 12 | |
Mark Bloch | 57cbd89 | 2018-01-16 14:04:14 +0000 | [diff] [blame] | 13 | enum { |
| 14 | SRIOV_NONE, |
| 15 | SRIOV_LEGACY, |
| 16 | SRIOV_OFFLOADS |
| 17 | }; |
| 18 | |
| 19 | enum { |
| 20 | REP_ETH, |
Mark Bloch | 5e65b02 | 2018-01-16 14:13:46 +0000 | [diff] [blame] | 21 | REP_IB, |
Mark Bloch | 57cbd89 | 2018-01-16 14:04:14 +0000 | [diff] [blame] | 22 | NUM_REP_TYPES, |
| 23 | }; |
| 24 | |
Bodong Wang | f121e0e | 2019-01-29 21:48:31 -0600 | [diff] [blame] | 25 | enum { |
| 26 | REP_UNREGISTERED, |
| 27 | REP_REGISTERED, |
| 28 | REP_LOADED, |
| 29 | }; |
| 30 | |
Mark Bloch | 57cbd89 | 2018-01-16 14:04:14 +0000 | [diff] [blame] | 31 | struct mlx5_eswitch_rep; |
| 32 | struct mlx5_eswitch_rep_if { |
| 33 | int (*load)(struct mlx5_core_dev *dev, |
| 34 | struct mlx5_eswitch_rep *rep); |
| 35 | void (*unload)(struct mlx5_eswitch_rep *rep); |
| 36 | void *(*get_proto_dev)(struct mlx5_eswitch_rep *rep); |
| 37 | void *priv; |
Bodong Wang | 6f4e021 | 2019-04-18 18:24:15 -0500 | [diff] [blame] | 38 | atomic_t state; |
Mark Bloch | 57cbd89 | 2018-01-16 14:04:14 +0000 | [diff] [blame] | 39 | }; |
| 40 | |
| 41 | struct mlx5_eswitch_rep { |
| 42 | struct mlx5_eswitch_rep_if rep_if[NUM_REP_TYPES]; |
| 43 | u16 vport; |
| 44 | u8 hw_id[ETH_ALEN]; |
| 45 | u16 vlan; |
| 46 | u32 vlan_refcount; |
| 47 | }; |
| 48 | |
Bodong Wang | f8e8fa0 | 2019-01-31 17:42:57 -0600 | [diff] [blame] | 49 | void mlx5_eswitch_register_vport_reps(struct mlx5_eswitch *esw, |
| 50 | struct mlx5_eswitch_rep_if *rep_if, |
| 51 | u8 rep_type); |
| 52 | void mlx5_eswitch_unregister_vport_reps(struct mlx5_eswitch *esw, u8 rep_type); |
Mark Bloch | 57cbd89 | 2018-01-16 14:04:14 +0000 | [diff] [blame] | 53 | void *mlx5_eswitch_get_proto_dev(struct mlx5_eswitch *esw, |
Parav Pandit | 02f3afd | 2019-04-05 01:07:19 -0500 | [diff] [blame] | 54 | u16 vport_num, |
Mark Bloch | 57cbd89 | 2018-01-16 14:04:14 +0000 | [diff] [blame] | 55 | u8 rep_type); |
| 56 | struct mlx5_eswitch_rep *mlx5_eswitch_vport_rep(struct mlx5_eswitch *esw, |
Parav Pandit | 02f3afd | 2019-04-05 01:07:19 -0500 | [diff] [blame] | 57 | u16 vport_num); |
Mark Bloch | 57cbd89 | 2018-01-16 14:04:14 +0000 | [diff] [blame] | 58 | void *mlx5_eswitch_uplink_get_proto_dev(struct mlx5_eswitch *esw, u8 rep_type); |
| 59 | u8 mlx5_eswitch_mode(struct mlx5_eswitch *esw); |
| 60 | struct mlx5_flow_handle * |
| 61 | mlx5_eswitch_add_send_to_vport_rule(struct mlx5_eswitch *esw, |
Parav Pandit | 02f3afd | 2019-04-05 01:07:19 -0500 | [diff] [blame] | 62 | u16 vport_num, u32 sqn); |
Mark Bloch | 57cbd89 | 2018-01-16 14:04:14 +0000 | [diff] [blame] | 63 | #endif |