linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: dsa: b53: Configure VLANs while not filtering
@ 2020-09-11  4:19 Florian Fainelli
  2020-09-11 15:48 ` Vladimir Oltean
  2020-09-11 18:28 ` Florian Fainelli
  0 siblings, 2 replies; 4+ messages in thread
From: Florian Fainelli @ 2020-09-11  4:19 UTC (permalink / raw)
  To: netdev
  Cc: olteanv, Florian Fainelli, Andrew Lunn, Vivien Didelot,
	David S. Miller, Jakub Kicinski, open list

Update the B53 driver to support VLANs while not filtering. This
requires us to enable VLAN globally within the switch upon driver
initial configuration (dev->vlan_enabled).

We also need to remove the code that dealt with PVID re-configuration in
b53_vlan_filtering() since that function worked under the assumption
that it would only be called to make a bridge VLAN filtering, or not
filtering, and we would attempt to move the port's PVID accordingly.

Now that VLANs are programmed all the time, even in the case of a
non-VLAN filtering bridge, we would be programming a default_pvid for
the bridged switch ports.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/dsa/b53/b53_common.c | 23 ++++-------------------
 1 file changed, 4 insertions(+), 19 deletions(-)

diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
index 6a5796c32721..46ac8875f870 100644
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
@@ -1377,23 +1377,6 @@ EXPORT_SYMBOL(b53_phylink_mac_link_up);
 int b53_vlan_filtering(struct dsa_switch *ds, int port, bool vlan_filtering)
 {
 	struct b53_device *dev = ds->priv;
-	u16 pvid, new_pvid;
-
-	b53_read16(dev, B53_VLAN_PAGE, B53_VLAN_PORT_DEF_TAG(port), &pvid);
-	if (!vlan_filtering) {
-		/* Filtering is currently enabled, use the default PVID since
-		 * the bridge does not expect tagging anymore
-		 */
-		dev->ports[port].pvid = pvid;
-		new_pvid = b53_default_pvid(dev);
-	} else {
-		/* Filtering is currently disabled, restore the previous PVID */
-		new_pvid = dev->ports[port].pvid;
-	}
-
-	if (pvid != new_pvid)
-		b53_write16(dev, B53_VLAN_PAGE, B53_VLAN_PORT_DEF_TAG(port),
-			    new_pvid);
 
 	b53_enable_vlan(dev, dev->vlan_enabled, vlan_filtering);
 
@@ -1444,7 +1427,7 @@ void b53_vlan_add(struct dsa_switch *ds, int port,
 			untagged = true;
 
 		vl->members |= BIT(port);
-		if (untagged && !dsa_is_cpu_port(ds, port))
+		if (untagged)
 			vl->untag |= BIT(port);
 		else
 			vl->untag &= ~BIT(port);
@@ -1482,7 +1465,7 @@ int b53_vlan_del(struct dsa_switch *ds, int port,
 		if (pvid == vid)
 			pvid = b53_default_pvid(dev);
 
-		if (untagged && !dsa_is_cpu_port(ds, port))
+		if (untagged)
 			vl->untag &= ~(BIT(port));
 
 		b53_set_vlan_entry(dev, vid, vl);
@@ -2619,6 +2602,8 @@ struct b53_device *b53_switch_alloc(struct device *base,
 	dev->priv = priv;
 	dev->ops = ops;
 	ds->ops = &b53_switch_ops;
+	ds->configure_vlan_while_not_filtering = true;
+	dev->vlan_enabled = ds->configure_vlan_while_not_filtering;
 	mutex_init(&dev->reg_mutex);
 	mutex_init(&dev->stats_mutex);
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] net: dsa: b53: Configure VLANs while not filtering
  2020-09-11  4:19 [PATCH net-next] net: dsa: b53: Configure VLANs while not filtering Florian Fainelli
@ 2020-09-11 15:48 ` Vladimir Oltean
  2020-09-11 18:28 ` Florian Fainelli
  1 sibling, 0 replies; 4+ messages in thread
From: Vladimir Oltean @ 2020-09-11 15:48 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: netdev, Andrew Lunn, Vivien Didelot, David S. Miller,
	Jakub Kicinski, open list

On Thu, Sep 10, 2020 at 09:19:05PM -0700, Florian Fainelli wrote:
> Update the B53 driver to support VLANs while not filtering. This
> requires us to enable VLAN globally within the switch upon driver
> initial configuration (dev->vlan_enabled).
>
> We also need to remove the code that dealt with PVID re-configuration in
> b53_vlan_filtering() since that function worked under the assumption
> that it would only be called to make a bridge VLAN filtering, or not
> filtering, and we would attempt to move the port's PVID accordingly.
>
> Now that VLANs are programmed all the time, even in the case of a
> non-VLAN filtering bridge, we would be programming a default_pvid for
> the bridged switch ports.
>
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
> ---

Not sure it's worth a lot, but:

Acked-by: Vladimir Oltean <olteanv@gmail.com>

>  drivers/net/dsa/b53/b53_common.c | 23 ++++-------------------
>  1 file changed, 4 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
> index 6a5796c32721..46ac8875f870 100644
> --- a/drivers/net/dsa/b53/b53_common.c
> +++ b/drivers/net/dsa/b53/b53_common.c
> @@ -1377,23 +1377,6 @@ EXPORT_SYMBOL(b53_phylink_mac_link_up);
>  int b53_vlan_filtering(struct dsa_switch *ds, int port, bool vlan_filtering)
>  {
>  	struct b53_device *dev = ds->priv;
> -	u16 pvid, new_pvid;
> -
> -	b53_read16(dev, B53_VLAN_PAGE, B53_VLAN_PORT_DEF_TAG(port), &pvid);
> -	if (!vlan_filtering) {
> -		/* Filtering is currently enabled, use the default PVID since
> -		 * the bridge does not expect tagging anymore
> -		 */
> -		dev->ports[port].pvid = pvid;
> -		new_pvid = b53_default_pvid(dev);
> -	} else {
> -		/* Filtering is currently disabled, restore the previous PVID */
> -		new_pvid = dev->ports[port].pvid;
> -	}
> -
> -	if (pvid != new_pvid)
> -		b53_write16(dev, B53_VLAN_PAGE, B53_VLAN_PORT_DEF_TAG(port),
> -			    new_pvid);
>
>  	b53_enable_vlan(dev, dev->vlan_enabled, vlan_filtering);
>
> @@ -1444,7 +1427,7 @@ void b53_vlan_add(struct dsa_switch *ds, int port,
>  			untagged = true;
>
>  		vl->members |= BIT(port);
> -		if (untagged && !dsa_is_cpu_port(ds, port))
> +		if (untagged)
>  			vl->untag |= BIT(port);
>  		else
>  			vl->untag &= ~BIT(port);
> @@ -1482,7 +1465,7 @@ int b53_vlan_del(struct dsa_switch *ds, int port,
>  		if (pvid == vid)
>  			pvid = b53_default_pvid(dev);
>
> -		if (untagged && !dsa_is_cpu_port(ds, port))
> +		if (untagged)
>  			vl->untag &= ~(BIT(port));
>
>  		b53_set_vlan_entry(dev, vid, vl);
> @@ -2619,6 +2602,8 @@ struct b53_device *b53_switch_alloc(struct device *base,
>  	dev->priv = priv;
>  	dev->ops = ops;
>  	ds->ops = &b53_switch_ops;
> +	ds->configure_vlan_while_not_filtering = true;
> +	dev->vlan_enabled = ds->configure_vlan_while_not_filtering;
>  	mutex_init(&dev->reg_mutex);
>  	mutex_init(&dev->stats_mutex);
>
> --
> 2.25.1
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] net: dsa: b53: Configure VLANs while not filtering
  2020-09-11  4:19 [PATCH net-next] net: dsa: b53: Configure VLANs while not filtering Florian Fainelli
  2020-09-11 15:48 ` Vladimir Oltean
@ 2020-09-11 18:28 ` Florian Fainelli
  2020-09-11 21:38   ` David Miller
  1 sibling, 1 reply; 4+ messages in thread
From: Florian Fainelli @ 2020-09-11 18:28 UTC (permalink / raw)
  To: netdev
  Cc: olteanv, Andrew Lunn, Vivien Didelot, David S. Miller,
	Jakub Kicinski, open list



On 9/10/2020 9:19 PM, Florian Fainelli wrote:
> Update the B53 driver to support VLANs while not filtering. This
> requires us to enable VLAN globally within the switch upon driver
> initial configuration (dev->vlan_enabled).
> 
> We also need to remove the code that dealt with PVID re-configuration in
> b53_vlan_filtering() since that function worked under the assumption
> that it would only be called to make a bridge VLAN filtering, or not
> filtering, and we would attempt to move the port's PVID accordingly.
> 
> Now that VLANs are programmed all the time, even in the case of a
> non-VLAN filtering bridge, we would be programming a default_pvid for
> the bridged switch ports.
> 
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>

David, Jakub, please hold off applying this just yet, Vladimir has 
submitted another patch for testing that would be IMHO a better way to 
deal with DSA switches that have an egress tagged default_pvid. 
Depending on the outcome of that patch, I will resubmit this one or 
request that you apply it.

Thanks
-- 
Florian

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] net: dsa: b53: Configure VLANs while not filtering
  2020-09-11 18:28 ` Florian Fainelli
@ 2020-09-11 21:38   ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2020-09-11 21:38 UTC (permalink / raw)
  To: f.fainelli; +Cc: netdev, olteanv, andrew, vivien.didelot, kuba, linux-kernel

From: Florian Fainelli <f.fainelli@gmail.com>
Date: Fri, 11 Sep 2020 11:28:27 -0700

> 
> 
> On 9/10/2020 9:19 PM, Florian Fainelli wrote:
>> Update the B53 driver to support VLANs while not filtering. This
>> requires us to enable VLAN globally within the switch upon driver
>> initial configuration (dev->vlan_enabled).
>> We also need to remove the code that dealt with PVID re-configuration
>> in
>> b53_vlan_filtering() since that function worked under the assumption
>> that it would only be called to make a bridge VLAN filtering, or not
>> filtering, and we would attempt to move the port's PVID accordingly.
>> Now that VLANs are programmed all the time, even in the case of a
>> non-VLAN filtering bridge, we would be programming a default_pvid for
>> the bridged switch ports.
>> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
> 
> David, Jakub, please hold off applying this just yet, Vladimir has
> submitted another patch for testing that would be IMHO a better way to
> deal with DSA switches that have an egress tagged
> default_pvid. Depending on the outcome of that patch, I will resubmit
> this one or request that you apply it.

Ok.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-09-11 21:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-11  4:19 [PATCH net-next] net: dsa: b53: Configure VLANs while not filtering Florian Fainelli
2020-09-11 15:48 ` Vladimir Oltean
2020-09-11 18:28 ` Florian Fainelli
2020-09-11 21:38   ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).