Lines Matching +full:cpu +full:- +full:ports

1 // SPDX-License-Identifier: GPL-2.0+
11 u16 ports; member
18 u16 ports; member
25 INIT_LIST_HEAD(&lan966x->mdb_entries); in lan966x_mdb_init()
26 INIT_LIST_HEAD(&lan966x->pgid_entries); in lan966x_mdb_init()
33 list_for_each_entry_safe(mdb_entry, tmp, &lan966x->mdb_entries, list) { in lan966x_mdb_purge_mdb_entries()
34 list_del(&mdb_entry->list); in lan966x_mdb_purge_mdb_entries()
43 list_for_each_entry_safe(pgid_entry, tmp, &lan966x->pgid_entries, list) { in lan966x_mdb_purge_pgid_entries()
44 list_del(&pgid_entry->list); in lan966x_mdb_purge_pgid_entries()
62 list_for_each_entry(mdb_entry, &lan966x->mdb_entries, list) { in lan966x_mdb_entry_get()
63 if (ether_addr_equal(mdb_entry->mac, mac) && in lan966x_mdb_entry_get()
64 mdb_entry->vid == vid) in lan966x_mdb_entry_get()
79 return ERR_PTR(-ENOMEM); in lan966x_mdb_entry_add()
81 ether_addr_copy(mdb_entry->mac, mdb->addr); in lan966x_mdb_entry_add()
82 mdb_entry->vid = mdb->vid; in lan966x_mdb_entry_add()
84 list_add_tail(&mdb_entry->list, &lan966x->mdb_entries); in lan966x_mdb_entry_add()
93 ether_addr_copy(mac, mdb_entry->mac); in lan966x_mdb_encode_mac()
97 mac[1] = mdb_entry->ports >> 8; in lan966x_mdb_encode_mac()
98 mac[2] = mdb_entry->ports & 0xff; in lan966x_mdb_encode_mac()
100 mac[0] = mdb_entry->ports >> 8; in lan966x_mdb_encode_mac()
101 mac[1] = mdb_entry->ports & 0xff; in lan966x_mdb_encode_mac()
109 bool cpu_port = netif_is_bridge_master(mdb->obj.orig_dev); in lan966x_mdb_ip_add()
110 struct lan966x *lan966x = port->lan966x; in lan966x_mdb_ip_add()
115 mdb_entry = lan966x_mdb_entry_get(lan966x, mdb->addr, mdb->vid); in lan966x_mdb_ip_add()
122 lan966x_mac_forget(lan966x, mac, mdb_entry->vid, type); in lan966x_mdb_ip_add()
126 mdb_entry->cpu_copy++; in lan966x_mdb_ip_add()
128 mdb_entry->ports |= BIT(port->chip_port); in lan966x_mdb_ip_add()
130 /* Copy the frame to CPU only if the CPU is in the VLAN */ in lan966x_mdb_ip_add()
131 if (lan966x_vlan_cpu_member_cpu_vlan_mask(lan966x, mdb_entry->vid) && in lan966x_mdb_ip_add()
132 mdb_entry->cpu_copy) in lan966x_mdb_ip_add()
137 mac, mdb_entry->vid, type); in lan966x_mdb_ip_add()
144 bool cpu_port = netif_is_bridge_master(mdb->obj.orig_dev); in lan966x_mdb_ip_del()
145 struct lan966x *lan966x = port->lan966x; in lan966x_mdb_ip_del()
148 u16 ports; in lan966x_mdb_ip_del() local
150 mdb_entry = lan966x_mdb_entry_get(lan966x, mdb->addr, mdb->vid); in lan966x_mdb_ip_del()
152 return -ENOENT; in lan966x_mdb_ip_del()
154 ports = mdb_entry->ports; in lan966x_mdb_ip_del()
156 /* If there are still other references to the CPU port then in lan966x_mdb_ip_del()
159 mdb_entry->cpu_copy--; in lan966x_mdb_ip_del()
160 if (mdb_entry->cpu_copy) in lan966x_mdb_ip_del()
163 ports &= ~BIT(port->chip_port); in lan966x_mdb_ip_del()
167 lan966x_mac_forget(lan966x, mac, mdb_entry->vid, type); in lan966x_mdb_ip_del()
169 mdb_entry->ports = ports; in lan966x_mdb_ip_del()
171 if (!mdb_entry->ports && !mdb_entry->cpu_copy) { in lan966x_mdb_ip_del()
172 list_del(&mdb_entry->list); in lan966x_mdb_ip_del()
178 return lan966x_mac_ip_learn(lan966x, mdb_entry->cpu_copy, in lan966x_mdb_ip_del()
179 mac, mdb_entry->vid, type); in lan966x_mdb_ip_del()
183 lan966x_pgid_entry_add(struct lan966x *lan966x, int index, u16 ports) in lan966x_pgid_entry_add() argument
189 return ERR_PTR(-ENOMEM); in lan966x_pgid_entry_add()
191 pgid_entry->ports = ports; in lan966x_pgid_entry_add()
192 pgid_entry->index = index; in lan966x_pgid_entry_add()
193 refcount_set(&pgid_entry->refcount, 1); in lan966x_pgid_entry_add()
195 list_add_tail(&pgid_entry->list, &lan966x->pgid_entries); in lan966x_pgid_entry_add()
207 /* Try to find an existing pgid that uses the same ports as the in lan966x_pgid_entry_get()
210 list_for_each_entry(pgid_entry, &lan966x->pgid_entries, list) { in lan966x_pgid_entry_get()
211 if (pgid_entry->ports == mdb_entry->ports) { in lan966x_pgid_entry_get()
212 refcount_inc(&pgid_entry->refcount); in lan966x_pgid_entry_get()
223 list_for_each_entry(pgid_entry, &lan966x->pgid_entries, list) { in lan966x_pgid_entry_get()
224 if (pgid_entry->index == index) { in lan966x_pgid_entry_get()
232 mdb_entry->ports); in lan966x_pgid_entry_get()
235 return ERR_PTR(-ENOSPC); in lan966x_pgid_entry_get()
241 if (!refcount_dec_and_test(&pgid_entry->refcount)) in lan966x_pgid_entry_del()
244 list_del(&pgid_entry->list); in lan966x_pgid_entry_del()
252 bool cpu_port = netif_is_bridge_master(mdb->obj.orig_dev); in lan966x_mdb_l2_add()
253 struct lan966x *lan966x = port->lan966x; in lan966x_mdb_l2_add()
258 mdb_entry = lan966x_mdb_entry_get(lan966x, mdb->addr, mdb->vid); in lan966x_mdb_l2_add()
264 lan966x_pgid_entry_del(lan966x, mdb_entry->pgid); in lan966x_mdb_l2_add()
266 lan966x_mac_forget(lan966x, mac, mdb_entry->vid, type); in lan966x_mdb_l2_add()
270 mdb_entry->ports |= BIT(CPU_PORT); in lan966x_mdb_l2_add()
271 mdb_entry->cpu_copy++; in lan966x_mdb_l2_add()
273 mdb_entry->ports |= BIT(port->chip_port); in lan966x_mdb_l2_add()
278 list_del(&mdb_entry->list); in lan966x_mdb_l2_add()
282 mdb_entry->pgid = pgid_entry; in lan966x_mdb_l2_add()
284 /* Copy the frame to CPU only if the CPU is in the VLAN */ in lan966x_mdb_l2_add()
285 if (!lan966x_vlan_cpu_member_cpu_vlan_mask(lan966x, mdb_entry->vid) && in lan966x_mdb_l2_add()
286 mdb_entry->cpu_copy) in lan966x_mdb_l2_add()
287 mdb_entry->ports &= BIT(CPU_PORT); in lan966x_mdb_l2_add()
289 lan_rmw(ANA_PGID_PGID_SET(mdb_entry->ports), in lan966x_mdb_l2_add()
291 lan966x, ANA_PGID(pgid_entry->index)); in lan966x_mdb_l2_add()
293 return lan966x_mac_learn(lan966x, pgid_entry->index, mdb_entry->mac, in lan966x_mdb_l2_add()
294 mdb_entry->vid, type); in lan966x_mdb_l2_add()
301 bool cpu_port = netif_is_bridge_master(mdb->obj.orig_dev); in lan966x_mdb_l2_del()
302 struct lan966x *lan966x = port->lan966x; in lan966x_mdb_l2_del()
306 u16 ports; in lan966x_mdb_l2_del() local
308 mdb_entry = lan966x_mdb_entry_get(lan966x, mdb->addr, mdb->vid); in lan966x_mdb_l2_del()
310 return -ENOENT; in lan966x_mdb_l2_del()
312 ports = mdb_entry->ports; in lan966x_mdb_l2_del()
314 /* If there are still other references to the CPU port then in lan966x_mdb_l2_del()
317 mdb_entry->cpu_copy--; in lan966x_mdb_l2_del()
318 if (mdb_entry->cpu_copy) in lan966x_mdb_l2_del()
321 ports &= ~BIT(CPU_PORT); in lan966x_mdb_l2_del()
323 ports &= ~BIT(port->chip_port); in lan966x_mdb_l2_del()
327 lan966x_mac_forget(lan966x, mac, mdb_entry->vid, type); in lan966x_mdb_l2_del()
328 lan966x_pgid_entry_del(lan966x, mdb_entry->pgid); in lan966x_mdb_l2_del()
330 mdb_entry->ports = ports; in lan966x_mdb_l2_del()
332 if (!mdb_entry->ports) { in lan966x_mdb_l2_del()
333 list_del(&mdb_entry->list); in lan966x_mdb_l2_del()
340 list_del(&mdb_entry->list); in lan966x_mdb_l2_del()
344 mdb_entry->pgid = pgid_entry; in lan966x_mdb_l2_del()
346 lan_rmw(ANA_PGID_PGID_SET(mdb_entry->ports), in lan966x_mdb_l2_del()
348 lan966x, ANA_PGID(pgid_entry->index)); in lan966x_mdb_l2_del()
350 return lan966x_mac_learn(lan966x, pgid_entry->index, mdb_entry->mac, in lan966x_mdb_l2_del()
351 mdb_entry->vid, type); in lan966x_mdb_l2_del()
374 type = lan966x_mdb_classify(mdb->addr); in lan966x_handle_port_mdb_add()
391 type = lan966x_mdb_classify(mdb->addr); in lan966x_handle_port_mdb_del()
405 lan966x_mac_forget(lan966x, mac, mdb_entry->vid, type); in lan966x_mdb_ip_cpu_copy()
406 lan966x_mac_ip_learn(lan966x, true, mac, mdb_entry->vid, type); in lan966x_mdb_ip_cpu_copy()
416 lan966x_pgid_entry_del(lan966x, mdb_entry->pgid); in lan966x_mdb_l2_cpu_copy()
418 lan966x_mac_forget(lan966x, mac, mdb_entry->vid, type); in lan966x_mdb_l2_cpu_copy()
420 mdb_entry->ports |= BIT(CPU_PORT); in lan966x_mdb_l2_cpu_copy()
426 mdb_entry->pgid = pgid_entry; in lan966x_mdb_l2_cpu_copy()
428 lan_rmw(ANA_PGID_PGID_SET(mdb_entry->ports), in lan966x_mdb_l2_cpu_copy()
430 lan966x, ANA_PGID(pgid_entry->index)); in lan966x_mdb_l2_cpu_copy()
432 lan966x_mac_learn(lan966x, pgid_entry->index, mdb_entry->mac, in lan966x_mdb_l2_cpu_copy()
433 mdb_entry->vid, type); in lan966x_mdb_l2_cpu_copy()
441 list_for_each_entry(mdb_entry, &lan966x->mdb_entries, list) { in lan966x_mdb_write_entries()
442 if (mdb_entry->vid != vid || !mdb_entry->cpu_copy) in lan966x_mdb_write_entries()
445 type = lan966x_mdb_classify(mdb_entry->mac); in lan966x_mdb_write_entries()
460 lan966x_mac_forget(lan966x, mac, mdb_entry->vid, type); in lan966x_mdb_ip_cpu_remove()
461 lan966x_mac_ip_learn(lan966x, false, mac, mdb_entry->vid, type); in lan966x_mdb_ip_cpu_remove()
471 lan966x_pgid_entry_del(lan966x, mdb_entry->pgid); in lan966x_mdb_l2_cpu_remove()
473 lan966x_mac_forget(lan966x, mac, mdb_entry->vid, type); in lan966x_mdb_l2_cpu_remove()
475 mdb_entry->ports &= ~BIT(CPU_PORT); in lan966x_mdb_l2_cpu_remove()
481 mdb_entry->pgid = pgid_entry; in lan966x_mdb_l2_cpu_remove()
483 lan_rmw(ANA_PGID_PGID_SET(mdb_entry->ports), in lan966x_mdb_l2_cpu_remove()
485 lan966x, ANA_PGID(pgid_entry->index)); in lan966x_mdb_l2_cpu_remove()
487 lan966x_mac_learn(lan966x, pgid_entry->index, mdb_entry->mac, in lan966x_mdb_l2_cpu_remove()
488 mdb_entry->vid, type); in lan966x_mdb_l2_cpu_remove()
496 list_for_each_entry(mdb_entry, &lan966x->mdb_entries, list) { in lan966x_mdb_erase_entries()
497 if (mdb_entry->vid != vid || !mdb_entry->cpu_copy) in lan966x_mdb_erase_entries()
500 type = lan966x_mdb_classify(mdb_entry->mac); in lan966x_mdb_erase_entries()
514 list_for_each_entry(mdb_entry, &lan966x->mdb_entries, list) { in lan966x_mdb_clear_entries()
515 type = lan966x_mdb_classify(mdb_entry->mac); in lan966x_mdb_clear_entries()
521 lan966x_mac_forget(lan966x, mac, mdb_entry->vid, type); in lan966x_mdb_clear_entries()
532 list_for_each_entry(mdb_entry, &lan966x->mdb_entries, list) { in lan966x_mdb_restore_entries()
533 type = lan966x_mdb_classify(mdb_entry->mac); in lan966x_mdb_restore_entries()
537 /* Copy the frame to CPU only if the CPU is in the VLAN */ in lan966x_mdb_restore_entries()
539 mdb_entry->vid) && in lan966x_mdb_restore_entries()
540 mdb_entry->cpu_copy) in lan966x_mdb_restore_entries()
544 mdb_entry->vid, type); in lan966x_mdb_restore_entries()
546 lan966x_mac_learn(lan966x, mdb_entry->pgid->index, in lan966x_mdb_restore_entries()
547 mdb_entry->mac, in lan966x_mdb_restore_entries()
548 mdb_entry->vid, type); in lan966x_mdb_restore_entries()