linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v2] net: dsa: Use prepare/commit phase in dsa_slave_vlan_rx_add_vid()
@ 2019-03-01 18:37 Florian Fainelli
  2019-03-04  4:46 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Florian Fainelli @ 2019-03-01 18:37 UTC (permalink / raw)
  To: netdev
  Cc: Heiner Kallweit, Michal Vokáč,
	Florian Fainelli, Andrew Lunn, Vivien Didelot, David S. Miller,
	open list

We were skipping the prepare phase which causes some problems with at
least a couple of drivers:

- mv88e6xxx chooses to skip programming VID = 0 with -EOPNOTSUPP in
  the prepare phase, but we would still try to force this VID since we
  would only call the commit phase and so we would get the driver to
  return -EINVAL instead

- qca8k does not currently have a port_vlan_add() callback implemented,
  yet we would try to call that unconditionally leading to a NPD

Fix both issues by conforming to the current model doing a
prepare/commit phase, this makes us consistent throughout the code and
assumptions.

Reported-by: Heiner Kallweit <hkallweit1@gmail.com>
Reported-by: Michal Vokáč <michal.vokac@ysoft.com>
Fixes: 061f6a505ac3 ("net: dsa: Add ndo_vlan_rx_{add, kill}_vid implementation")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 net/dsa/slave.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 1808a2cd6872..093eef6f2599 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -993,6 +993,7 @@ static int dsa_slave_vlan_rx_add_vid(struct net_device *dev, __be16 proto,
 		/* This API only allows programming tagged, non-PVID VIDs */
 		.flags = 0,
 	};
+	struct switchdev_trans trans;
 	struct bridge_vlan_info info;
 	int ret;
 
@@ -1009,11 +1010,13 @@ static int dsa_slave_vlan_rx_add_vid(struct net_device *dev, __be16 proto,
 			return -EBUSY;
 	}
 
-	ret = dsa_port_vlan_add(dp, &vlan, NULL);
+	trans.ph_prepare = true;
+	ret = dsa_port_vlan_add(dp, &vlan, &trans);
 	if (ret == -EOPNOTSUPP)
-		ret = 0;
+		return 0;
 
-	return ret;
+	trans.ph_prepare = false;
+	return dsa_port_vlan_add(dp, &vlan, &trans);
 }
 
 static int dsa_slave_vlan_rx_kill_vid(struct net_device *dev, __be16 proto,
-- 
2.17.1


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

* Re: [PATCH net-next v2] net: dsa: Use prepare/commit phase in dsa_slave_vlan_rx_add_vid()
  2019-03-01 18:37 [PATCH net-next v2] net: dsa: Use prepare/commit phase in dsa_slave_vlan_rx_add_vid() Florian Fainelli
@ 2019-03-04  4:46 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2019-03-04  4:46 UTC (permalink / raw)
  To: f.fainelli
  Cc: netdev, hkallweit1, michal.vokac, andrew, vivien.didelot, linux-kernel

From: Florian Fainelli <f.fainelli@gmail.com>
Date: Fri,  1 Mar 2019 10:37:25 -0800

> We were skipping the prepare phase which causes some problems with at
> least a couple of drivers:
> 
> - mv88e6xxx chooses to skip programming VID = 0 with -EOPNOTSUPP in
>   the prepare phase, but we would still try to force this VID since we
>   would only call the commit phase and so we would get the driver to
>   return -EINVAL instead
> 
> - qca8k does not currently have a port_vlan_add() callback implemented,
>   yet we would try to call that unconditionally leading to a NPD
> 
> Fix both issues by conforming to the current model doing a
> prepare/commit phase, this makes us consistent throughout the code and
> assumptions.
> 
> Reported-by: Heiner Kallweit <hkallweit1@gmail.com>
> Reported-by: Michal Vokáč <michal.vokac@ysoft.com>
> Fixes: 061f6a505ac3 ("net: dsa: Add ndo_vlan_rx_{add, kill}_vid implementation")
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>

Applied, thanks Florian.

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

end of thread, other threads:[~2019-03-04  4:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-01 18:37 [PATCH net-next v2] net: dsa: Use prepare/commit phase in dsa_slave_vlan_rx_add_vid() Florian Fainelli
2019-03-04  4:46 ` 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).