Lines Matching +full:lan966x +full:- +full:switch

1 // SPDX-License-Identifier: GPL-2.0+
12 struct lan966x *lan966x; member
24 lan966x_fdb_find_entry(struct lan966x *lan966x, in lan966x_fdb_find_entry() argument
29 list_for_each_entry(fdb_entry, &lan966x->fdb_entries, list) { in lan966x_fdb_find_entry()
30 if (fdb_entry->vid == fdb_info->vid && in lan966x_fdb_find_entry()
31 ether_addr_equal(fdb_entry->mac, fdb_info->addr)) in lan966x_fdb_find_entry()
38 static void lan966x_fdb_add_entry(struct lan966x *lan966x, in lan966x_fdb_add_entry() argument
43 fdb_entry = lan966x_fdb_find_entry(lan966x, fdb_info); in lan966x_fdb_add_entry()
45 fdb_entry->references++; in lan966x_fdb_add_entry()
53 ether_addr_copy(fdb_entry->mac, fdb_info->addr); in lan966x_fdb_add_entry()
54 fdb_entry->vid = fdb_info->vid; in lan966x_fdb_add_entry()
55 fdb_entry->references = 1; in lan966x_fdb_add_entry()
56 list_add_tail(&fdb_entry->list, &lan966x->fdb_entries); in lan966x_fdb_add_entry()
59 static bool lan966x_fdb_del_entry(struct lan966x *lan966x, in lan966x_fdb_del_entry() argument
64 list_for_each_entry_safe(fdb_entry, tmp, &lan966x->fdb_entries, in lan966x_fdb_del_entry()
66 if (fdb_entry->vid == fdb_info->vid && in lan966x_fdb_del_entry()
67 ether_addr_equal(fdb_entry->mac, fdb_info->addr)) { in lan966x_fdb_del_entry()
68 fdb_entry->references--; in lan966x_fdb_del_entry()
69 if (!fdb_entry->references) { in lan966x_fdb_del_entry()
70 list_del(&fdb_entry->list); in lan966x_fdb_del_entry()
81 void lan966x_fdb_write_entries(struct lan966x *lan966x, u16 vid) in lan966x_fdb_write_entries() argument
85 list_for_each_entry(fdb_entry, &lan966x->fdb_entries, list) { in lan966x_fdb_write_entries()
86 if (fdb_entry->vid != vid) in lan966x_fdb_write_entries()
89 lan966x_mac_cpu_learn(lan966x, fdb_entry->mac, fdb_entry->vid); in lan966x_fdb_write_entries()
93 void lan966x_fdb_erase_entries(struct lan966x *lan966x, u16 vid) in lan966x_fdb_erase_entries() argument
97 list_for_each_entry(fdb_entry, &lan966x->fdb_entries, list) { in lan966x_fdb_erase_entries()
98 if (fdb_entry->vid != vid) in lan966x_fdb_erase_entries()
101 lan966x_mac_cpu_forget(lan966x, fdb_entry->mac, fdb_entry->vid); in lan966x_fdb_erase_entries()
105 static void lan966x_fdb_purge_entries(struct lan966x *lan966x) in lan966x_fdb_purge_entries() argument
109 list_for_each_entry_safe(fdb_entry, tmp, &lan966x->fdb_entries, list) { in lan966x_fdb_purge_entries()
110 list_del(&fdb_entry->list); in lan966x_fdb_purge_entries()
115 int lan966x_fdb_init(struct lan966x *lan966x) in lan966x_fdb_init() argument
117 INIT_LIST_HEAD(&lan966x->fdb_entries); in lan966x_fdb_init()
118 lan966x->fdb_work = alloc_ordered_workqueue("lan966x_order", 0); in lan966x_fdb_init()
119 if (!lan966x->fdb_work) in lan966x_fdb_init()
120 return -ENOMEM; in lan966x_fdb_init()
125 void lan966x_fdb_deinit(struct lan966x *lan966x) in lan966x_fdb_deinit() argument
127 destroy_workqueue(lan966x->fdb_work); in lan966x_fdb_deinit()
128 lan966x_fdb_purge_entries(lan966x); in lan966x_fdb_deinit()
131 void lan966x_fdb_flush_workqueue(struct lan966x *lan966x) in lan966x_fdb_flush_workqueue() argument
133 flush_workqueue(lan966x->fdb_work); in lan966x_fdb_flush_workqueue()
140 struct lan966x *lan966x; in lan966x_fdb_port_event_work() local
142 lan966x = fdb_work->lan966x; in lan966x_fdb_port_event_work()
143 port = netdev_priv(fdb_work->orig_dev); in lan966x_fdb_port_event_work()
144 fdb_info = &fdb_work->fdb_info; in lan966x_fdb_port_event_work()
146 switch (fdb_work->event) { in lan966x_fdb_port_event_work()
148 if (!fdb_info->added_by_user) in lan966x_fdb_port_event_work()
150 lan966x_mac_add_entry(lan966x, port, fdb_info->addr, in lan966x_fdb_port_event_work()
151 fdb_info->vid); in lan966x_fdb_port_event_work()
154 if (!fdb_info->added_by_user) in lan966x_fdb_port_event_work()
156 lan966x_mac_del_entry(lan966x, fdb_info->addr, in lan966x_fdb_port_event_work()
157 fdb_info->vid); in lan966x_fdb_port_event_work()
165 struct lan966x *lan966x; in lan966x_fdb_bridge_event_work() local
168 lan966x = fdb_work->lan966x; in lan966x_fdb_bridge_event_work()
169 fdb_info = &fdb_work->fdb_info; in lan966x_fdb_bridge_event_work()
172 switch (fdb_work->event) { in lan966x_fdb_bridge_event_work()
181 lan966x_fdb_add_entry(lan966x, fdb_info); in lan966x_fdb_bridge_event_work()
182 if (!lan966x_vlan_cpu_member_cpu_vlan_mask(lan966x, in lan966x_fdb_bridge_event_work()
183 fdb_info->vid)) in lan966x_fdb_bridge_event_work()
186 lan966x_mac_cpu_learn(lan966x, fdb_info->addr, in lan966x_fdb_bridge_event_work()
187 fdb_info->vid); in lan966x_fdb_bridge_event_work()
190 ret = lan966x_fdb_del_entry(lan966x, fdb_info); in lan966x_fdb_bridge_event_work()
191 if (!lan966x_vlan_cpu_member_cpu_vlan_mask(lan966x, in lan966x_fdb_bridge_event_work()
192 fdb_info->vid)) in lan966x_fdb_bridge_event_work()
196 lan966x_mac_cpu_forget(lan966x, fdb_info->addr, in lan966x_fdb_bridge_event_work()
197 fdb_info->vid); in lan966x_fdb_bridge_event_work()
206 struct lan966x *lan966x; in lan966x_fdb_lag_event_work() local
208 if (!lan966x_lag_first_port(fdb_work->orig_dev, fdb_work->dev)) in lan966x_fdb_lag_event_work()
211 lan966x = fdb_work->lan966x; in lan966x_fdb_lag_event_work()
212 port = netdev_priv(fdb_work->dev); in lan966x_fdb_lag_event_work()
213 fdb_info = &fdb_work->fdb_info; in lan966x_fdb_lag_event_work()
215 switch (fdb_work->event) { in lan966x_fdb_lag_event_work()
217 if (!fdb_info->added_by_user) in lan966x_fdb_lag_event_work()
219 lan966x_mac_add_entry(lan966x, port, fdb_info->addr, in lan966x_fdb_lag_event_work()
220 fdb_info->vid); in lan966x_fdb_lag_event_work()
223 if (!fdb_info->added_by_user) in lan966x_fdb_lag_event_work()
225 lan966x_mac_del_entry(lan966x, fdb_info->addr, fdb_info->vid); in lan966x_fdb_lag_event_work()
235 if (lan966x_netdevice_check(fdb_work->orig_dev)) in lan966x_fdb_event_work()
237 else if (netif_is_bridge_master(fdb_work->orig_dev)) in lan966x_fdb_event_work()
239 else if (netif_is_lag_master(fdb_work->orig_dev)) in lan966x_fdb_event_work()
242 kfree(fdb_work->fdb_info.addr); in lan966x_fdb_event_work()
252 struct lan966x *lan966x = port->lan966x; in lan966x_handle_fdb() local
258 switch (event) { in lan966x_handle_fdb()
262 !fdb_info->added_by_user) in lan966x_handle_fdb()
267 return -ENOMEM; in lan966x_handle_fdb()
269 fdb_work->dev = dev; in lan966x_handle_fdb()
270 fdb_work->orig_dev = orig_dev; in lan966x_handle_fdb()
271 fdb_work->lan966x = lan966x; in lan966x_handle_fdb()
272 fdb_work->event = event; in lan966x_handle_fdb()
273 INIT_WORK(&fdb_work->work, lan966x_fdb_event_work); in lan966x_handle_fdb()
274 memcpy(&fdb_work->fdb_info, fdb_info, sizeof(fdb_work->fdb_info)); in lan966x_handle_fdb()
275 fdb_work->fdb_info.addr = kzalloc(ETH_ALEN, GFP_ATOMIC); in lan966x_handle_fdb()
276 if (!fdb_work->fdb_info.addr) in lan966x_handle_fdb()
279 ether_addr_copy((u8 *)fdb_work->fdb_info.addr, fdb_info->addr); in lan966x_handle_fdb()
281 queue_work(lan966x->fdb_work, &fdb_work->work); in lan966x_handle_fdb()
288 return -ENOMEM; in lan966x_handle_fdb()