Messages in this thread | | | Date | Fri, 16 Feb 2024 15:21:17 +0200 | From | Vladimir Oltean <> | Subject | Re: [PATCH net-next v4 07/15] net: dsa: vsc73xx: Add vlan filtering |
| |
On Tue, Feb 13, 2024 at 11:03:20PM +0100, Pawel Dembicki wrote: > +static int > +vsc73xx_port_vlan_filtering(struct dsa_switch *ds, int port, > + bool vlan_filtering, struct netlink_ext_ack *extack) > +{ > + enum vsc73xx_port_vlan_conf port_vlan_conf = VSC73XX_VLAN_IGNORE; > + struct vsc73xx *vsc = ds->priv; > + bool store_untagged = false; > + bool store_pvid = false; > + u16 vlan_no, vlan_untagged; > + > + /* The swap processed bellow is required because vsc73xx is using tag8021q. > + * When vlan_filtering is disabled, tag8021q use pvid/untagged vlans for > + * port recognition. The values configured for vlans < 3072 are stored > + * in storage table. When vlan_filtering is enabled, we need to restore > + * pvid/untagged from storage and keep values used for tag8021q. > + */ > + > + if (vlan_filtering) { > + /* Use VLAN_N_VID to count all vlans */ > + u16 num_untagged = vsc73xx_bridge_vlan_num_untagged(vsc, port, VLAN_N_VID); > + > + port_vlan_conf = (num_untagged > 1) ? > + VSC73XX_VLAN_FILTER_UNTAG_ALL : VSC73XX_VLAN_FILTER; > + > + vlan_untagged = vsc73xx_find_first_vlan_untagged(vsc, port); > + if (vlan_no < VLAN_N_VID) {
One more that I've missed. There's a bug here. You don't mean "vlan_no" (which at this stage is uninitialized), but "vlan_untagged".
> + store_untagged = vsc73xx_port_get_untagged(vsc, port, &vlan_no, false); > + vsc73xx_vlan_change_untagged(vsc, port, vlan_untagged, > + vlan_untagged < VLAN_N_VID, false); > + vsc->untagged_storage[port] = store_untagged ? vlan_no : VLAN_N_VID; > + } > + } else { > + vsc73xx_vlan_change_untagged(vsc, port, vsc->untagged_storage[port], > + vsc->untagged_storage[port] < VLAN_N_VID, false); > + } > + > + vsc73xx_set_vlan_conf(vsc, port, port_vlan_conf); > + > + store_pvid = vsc73xx_port_get_pvid(vsc, port, &vlan_no, false); > + vsc73xx_vlan_change_pvid(vsc, port, vsc->pvid_storage[port], > + vsc->pvid_storage[port] < VLAN_N_VID, false); > + vsc->pvid_storage[port] = store_pvid ? vlan_no : VLAN_N_VID; > + > + return 0; > +}
| |