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 "eswitch.h"
11 
12 struct mlx5_flow_table;
13 struct mlx5_flow_group;
14 
15 struct mlx5_esw_bridge_offloads {
16 	struct mlx5_eswitch *esw;
17 	struct list_head bridges;
18 	struct notifier_block netdev_nb;
19 	struct notifier_block nb_blk;
20 	struct notifier_block nb;
21 	struct workqueue_struct *wq;
22 	struct delayed_work update_work;
23 
24 	struct mlx5_flow_table *ingress_ft;
25 	struct mlx5_flow_group *ingress_vlan_fg;
26 	struct mlx5_flow_group *ingress_filter_fg;
27 	struct mlx5_flow_group *ingress_mac_fg;
28 
29 	struct mlx5_flow_table *skip_ft;
30 };
31 
32 struct mlx5_esw_bridge_offloads *mlx5_esw_bridge_init(struct mlx5_eswitch *esw);
33 void mlx5_esw_bridge_cleanup(struct mlx5_eswitch *esw);
34 int mlx5_esw_bridge_vport_link(int ifindex, struct mlx5_esw_bridge_offloads *br_offloads,
35 			       struct mlx5_vport *vport, struct netlink_ext_ack *extack);
36 int mlx5_esw_bridge_vport_unlink(int ifindex, struct mlx5_esw_bridge_offloads *br_offloads,
37 				 struct mlx5_vport *vport, struct netlink_ext_ack *extack);
38 void mlx5_esw_bridge_fdb_create(struct net_device *dev, struct mlx5_eswitch *esw,
39 				struct mlx5_vport *vport,
40 				struct switchdev_notifier_fdb_info *fdb_info);
41 void mlx5_esw_bridge_fdb_remove(struct net_device *dev, struct mlx5_eswitch *esw,
42 				struct mlx5_vport *vport,
43 				struct switchdev_notifier_fdb_info *fdb_info);
44 void mlx5_esw_bridge_update(struct mlx5_esw_bridge_offloads *br_offloads);
45 int mlx5_esw_bridge_ageing_time_set(unsigned long ageing_time, struct mlx5_eswitch *esw,
46 				    struct mlx5_vport *vport);
47 int mlx5_esw_bridge_vlan_filtering_set(bool enable, struct mlx5_eswitch *esw,
48 				       struct mlx5_vport *vport);
49 int mlx5_esw_bridge_port_vlan_add(u16 vid, u16 flags, struct mlx5_eswitch *esw,
50 				  struct mlx5_vport *vport, struct netlink_ext_ack *extack);
51 void mlx5_esw_bridge_port_vlan_del(u16 vid, struct mlx5_eswitch *esw, struct mlx5_vport *vport);
52 
53 #endif /* __MLX5_ESW_BRIDGE_H__ */
54