d3c9db492b30065750726992ba1001c48153232b
[sfrench/cifs-2.6.git] / include / linux / mlx5 / eswitch.h
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
11 enum {
12         SRIOV_NONE,
13         SRIOV_LEGACY,
14         SRIOV_OFFLOADS
15 };
16
17 enum {
18         REP_ETH,
19         REP_IB,
20         NUM_REP_TYPES,
21 };
22
23 struct mlx5_eswitch_rep;
24 struct mlx5_eswitch_rep_if {
25         int                    (*load)(struct mlx5_core_dev *dev,
26                                        struct mlx5_eswitch_rep *rep);
27         void                   (*unload)(struct mlx5_eswitch_rep *rep);
28         void                   *(*get_proto_dev)(struct mlx5_eswitch_rep *rep);
29         void                    *priv;
30         bool                   valid;
31 };
32
33 struct mlx5_eswitch_rep {
34         struct mlx5_eswitch_rep_if rep_if[NUM_REP_TYPES];
35         u16                    vport;
36         u8                     hw_id[ETH_ALEN];
37         u16                    vlan;
38         u32                    vlan_refcount;
39 };
40
41 void mlx5_eswitch_register_vport_rep(struct mlx5_eswitch *esw,
42                                      int vport_index,
43                                      struct mlx5_eswitch_rep_if *rep_if,
44                                      u8 rep_type);
45 void mlx5_eswitch_unregister_vport_rep(struct mlx5_eswitch *esw,
46                                        int vport_index,
47                                        u8 rep_type);
48 void *mlx5_eswitch_get_proto_dev(struct mlx5_eswitch *esw,
49                                  int vport,
50                                  u8 rep_type);
51 struct mlx5_eswitch_rep *mlx5_eswitch_vport_rep(struct mlx5_eswitch *esw,
52                                                 int vport);
53 void *mlx5_eswitch_uplink_get_proto_dev(struct mlx5_eswitch *esw, u8 rep_type);
54 u8 mlx5_eswitch_mode(struct mlx5_eswitch *esw);
55 struct mlx5_flow_handle *
56 mlx5_eswitch_add_send_to_vport_rule(struct mlx5_eswitch *esw,
57                                     int vport, u32 sqn);
58 #endif