Skip to contentSkip to conversation

net: dsa: Use prepare/commit phase in dsa_slave_vlan_rx_add_vid()

PATCH Applied Florian Fainelli 2 participants 2 messages Mar 1, 2019 – Mar 4, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 net: dsa: Use prepare/commit phase in dsa_slave_vlan_rx_add_vid()

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.

Fixes 061f6a505ac3 ("net: dsa: Add ndo_vlan_rx_{add, kill}_vid implementation")
---
 net/dsa/slave.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
net/dsa/slave.c +6 -3
index 1808a2cd6872..093eef6f2599 100644
@@ -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,
Signature · 1 line
2.17.1
maintainer Applied
#1 lore raw

From: Florian Fainelli <[email protected]>
Date: Fri, 1 Mar 2019 10:37:25 -0800

Quoted 11 lines

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

Quoted 8 lines

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

Fixes 061f6a505ac3 ("net: dsa: Add ndo_vlan_rx_{add, kill}_vid implementation")

Applied, thanks Florian.