1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright (C) 2023, Intel Corporation. */
3 
4 #ifndef _ICE_ESWITCH_BR_H_
5 #define _ICE_ESWITCH_BR_H_
6 
7 #include <linux/rhashtable.h>
8 
9 struct ice_esw_br_fdb_data {
10 	unsigned char addr[ETH_ALEN];
11 	u16 vid;
12 };
13 
14 struct ice_esw_br_flow {
15 	struct ice_rule_query_data *fwd_rule;
16 	struct ice_rule_query_data *guard_rule;
17 };
18 
19 enum {
20 	ICE_ESWITCH_BR_FDB_ADDED_BY_USER = BIT(0),
21 };
22 
23 struct ice_esw_br_fdb_entry {
24 	struct ice_esw_br_fdb_data data;
25 	struct rhash_head ht_node;
26 	struct list_head list;
27 
28 	int flags;
29 
30 	struct net_device *dev;
31 	struct ice_esw_br_port *br_port;
32 	struct ice_esw_br_flow *flow;
33 };
34 
35 enum ice_esw_br_port_type {
36 	ICE_ESWITCH_BR_UPLINK_PORT = 0,
37 	ICE_ESWITCH_BR_VF_REPR_PORT = 1,
38 };
39 
40 struct ice_esw_br_port {
41 	struct ice_esw_br *bridge;
42 	struct ice_vsi *vsi;
43 	enum ice_esw_br_port_type type;
44 	u16 vsi_idx;
45 };
46 
47 struct ice_esw_br {
48 	struct ice_esw_br_offloads *br_offloads;
49 	struct xarray ports;
50 
51 	struct rhashtable fdb_ht;
52 	struct list_head fdb_list;
53 
54 	int ifindex;
55 };
56 
57 struct ice_esw_br_offloads {
58 	struct ice_pf *pf;
59 	struct ice_esw_br *bridge;
60 	struct notifier_block netdev_nb;
61 	struct notifier_block switchdev_nb;
62 
63 	struct workqueue_struct *wq;
64 };
65 
66 struct ice_esw_br_fdb_work {
67 	struct work_struct work;
68 	struct switchdev_notifier_fdb_info fdb_info;
69 	struct net_device *dev;
70 	unsigned long event;
71 };
72 
73 #define ice_nb_to_br_offloads(nb, nb_name) \
74 	container_of(nb, \
75 		     struct ice_esw_br_offloads, \
76 		     nb_name)
77 
78 #define ice_work_to_fdb_work(w) \
79 	container_of(w, \
80 		     struct ice_esw_br_fdb_work, \
81 		     work)
82 
83 void
84 ice_eswitch_br_offloads_deinit(struct ice_pf *pf);
85 int
86 ice_eswitch_br_offloads_init(struct ice_pf *pf);
87 
88 #endif /* _ICE_ESWITCH_BR_H_ */
89