1 /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
2 /* Copyright (c) 2021 Mellanox Technologies. */
3 
4 #ifndef __MLX5_ESW_BRIDGE_H__
5 #define __MLX5_ESW_BRIDGE_H__
6 
7 #include <linux/notifier.h>
8 #include <linux/list.h>
9 #include <linux/workqueue.h>
10 #include <linux/xarray.h>
11 #include "eswitch.h"
12 
13 struct mlx5_flow_table;
14 struct mlx5_flow_group;
15 
16 struct mlx5_esw_bridge_offloads {
17 	struct mlx5_eswitch *esw;
18 	struct list_head bridges;
19 	struct xarray ports;
20 
21 	struct notifier_block netdev_nb;
22 	struct notifier_block nb_blk;
23 	struct notifier_block nb;
24 	struct workqueue_struct *wq;
25 	struct delayed_work update_work;
26 
27 	struct mlx5_flow_table *ingress_ft;
28 	struct mlx5_flow_group *ingress_vlan_fg;
29 	struct mlx5_flow_group *ingress_vlan_filter_fg;
30 	struct mlx5_flow_group *ingress_qinq_fg;
31 	struct mlx5_flow_group *ingress_qinq_filter_fg;
32 	struct mlx5_flow_group *ingress_mac_fg;
33 
34 	struct mlx5_flow_table *skip_ft;
35 };
36 
37 struct mlx5_esw_bridge_offloads *mlx5_esw_bridge_init(struct mlx5_eswitch *esw);
38 void mlx5_esw_bridge_cleanup(struct mlx5_eswitch *esw);
39 int mlx5_esw_bridge_vport_link(int ifindex, u16 vport_num, u16 esw_owner_vhca_id,
40 			       struct mlx5_esw_bridge_offloads *br_offloads,
41 			       struct netlink_ext_ack *extack);
42 int mlx5_esw_bridge_vport_unlink(int ifindex, u16 vport_num, u16 esw_owner_vhca_id,
43 				 struct mlx5_esw_bridge_offloads *br_offloads,
44 				 struct netlink_ext_ack *extack);
45 int mlx5_esw_bridge_vport_peer_link(int ifindex, u16 vport_num, u16 esw_owner_vhca_id,
46 				    struct mlx5_esw_bridge_offloads *br_offloads,
47 				    struct netlink_ext_ack *extack);
48 int mlx5_esw_bridge_vport_peer_unlink(int ifindex, u16 vport_num, u16 esw_owner_vhca_id,
49 				      struct mlx5_esw_bridge_offloads *br_offloads,
50 				      struct netlink_ext_ack *extack);
51 void mlx5_esw_bridge_fdb_update_used(struct net_device *dev, u16 vport_num, u16 esw_owner_vhca_id,
52 				     struct mlx5_esw_bridge_offloads *br_offloads,
53 				     struct switchdev_notifier_fdb_info *fdb_info);
54 void mlx5_esw_bridge_fdb_create(struct net_device *dev, u16 vport_num, u16 esw_owner_vhca_id,
55 				struct mlx5_esw_bridge_offloads *br_offloads,
56 				struct switchdev_notifier_fdb_info *fdb_info);
57 void mlx5_esw_bridge_fdb_remove(struct net_device *dev, u16 vport_num, u16 esw_owner_vhca_id,
58 				struct mlx5_esw_bridge_offloads *br_offloads,
59 				struct switchdev_notifier_fdb_info *fdb_info);
60 void mlx5_esw_bridge_update(struct mlx5_esw_bridge_offloads *br_offloads);
61 int mlx5_esw_bridge_ageing_time_set(u16 vport_num, u16 esw_owner_vhca_id, unsigned long ageing_time,
62 				    struct mlx5_esw_bridge_offloads *br_offloads);
63 int mlx5_esw_bridge_vlan_filtering_set(u16 vport_num, u16 esw_owner_vhca_id, bool enable,
64 				       struct mlx5_esw_bridge_offloads *br_offloads);
65 int mlx5_esw_bridge_vlan_proto_set(u16 vport_num, u16 esw_owner_vhca_id, u16 proto,
66 				   struct mlx5_esw_bridge_offloads *br_offloads);
67 int mlx5_esw_bridge_port_vlan_add(u16 vport_num, u16 esw_owner_vhca_id, u16 vid, u16 flags,
68 				  struct mlx5_esw_bridge_offloads *br_offloads,
69 				  struct netlink_ext_ack *extack);
70 void mlx5_esw_bridge_port_vlan_del(u16 vport_num, u16 esw_owner_vhca_id, u16 vid,
71 				   struct mlx5_esw_bridge_offloads *br_offloads);
72 
73 #endif /* __MLX5_ESW_BRIDGE_H__ */
74