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#include <linux/workqueue.h>
9
10struct ice_esw_br_fdb_data {
11 unsigned char addr[ETH_ALEN];
12 u16 vid;
13};
14
15struct ice_esw_br_flow {
16 struct ice_rule_query_data *fwd_rule;
17 struct ice_rule_query_data *guard_rule;
18};
19
20enum {
21 ICE_ESWITCH_BR_FDB_ADDED_BY_USER = BIT(0),
22};
23
24struct ice_esw_br_fdb_entry {
25 struct ice_esw_br_fdb_data data;
26 struct rhash_head ht_node;
27 struct list_head list;
28
29 int flags;
30
31 struct net_device *dev;
32 struct ice_esw_br_port *br_port;
33 struct ice_esw_br_flow *flow;
34
35 unsigned long last_use;
36};
37
38enum ice_esw_br_port_type {
39 ICE_ESWITCH_BR_UPLINK_PORT = 0,
40 ICE_ESWITCH_BR_VF_REPR_PORT = 1,
41};
42
43struct ice_esw_br_port {
44 struct ice_esw_br *bridge;
45 struct ice_vsi *vsi;
46 enum ice_esw_br_port_type type;
47 u16 vsi_idx;
48 u16 pvid;
49 struct xarray vlans;
50};
51
52enum {
53 ICE_ESWITCH_BR_VLAN_FILTERING = BIT(0),
54};
55
56struct ice_esw_br {
57 struct ice_esw_br_offloads *br_offloads;
58 struct xarray ports;
59
60 struct rhashtable fdb_ht;
61 struct list_head fdb_list;
62
63 int ifindex;
64 u32 flags;
65 unsigned long ageing_time;
66};
67
68struct ice_esw_br_offloads {
69 struct ice_pf *pf;
70 struct ice_esw_br *bridge;
71 struct notifier_block netdev_nb;
72 struct notifier_block switchdev_blk;
73 struct notifier_block switchdev_nb;
74
75 struct workqueue_struct *wq;
76 struct delayed_work update_work;
77};
78
79struct ice_esw_br_fdb_work {
80 struct work_struct work;
81 struct switchdev_notifier_fdb_info fdb_info;
82 struct net_device *dev;
83 unsigned long event;
84};
85
86struct ice_esw_br_vlan {
87 u16 vid;
88 u16 flags;
89};
90
91#define ice_nb_to_br_offloads(nb, nb_name) \
92 container_of(nb, \
93 struct ice_esw_br_offloads, \
94 nb_name)
95
96#define ice_work_to_br_offloads(w) \
97 container_of(w, \
98 struct ice_esw_br_offloads, \
99 update_work.work)
100
101#define ice_work_to_fdb_work(w) \
102 container_of(w, \
103 struct ice_esw_br_fdb_work, \
104 work)
105
106static inline bool ice_eswitch_br_is_vid_valid(u16 vid)
107{
108 /* In trunk VLAN mode, for untagged traffic the bridge sends requests
109 * to offload VLAN 1 with pvid and untagged flags set. Since these
110 * flags are not supported, add a MAC filter instead.
111 */
112 return vid > 1;
113}
114
115void
116ice_eswitch_br_offloads_deinit(struct ice_pf *pf);
117int
118ice_eswitch_br_offloads_init(struct ice_pf *pf);
119
120#endif /* _ICE_ESWITCH_BR_H_ */
121

source code of linux/drivers/net/ethernet/intel/ice/ice_eswitch_br.h