Get rid of the switchdev transactional model
Subsystems (18)
Vladimir Oltean
maintainerv3 cover Get rid of the switchdev transactional model
From: Vladimir Oltean <[email protected]>
Changes in v3:
- Resolved a build warning in mv88e6xxx and tested that it actually works properly, which resulted in an extra patch (02/11.
- Addressed Ido's minor feedback in commit 10/11 relating to a comment.
Changes in v2:
- Got rid of the vid_begin -> vid_end range too from the switchdev API.
- Actually propagating errors from DSA MDB and VLAN notifiers.
This series comes after the late realization that the prepare/commit separation imposed by switchdev does not help literally anybody:
https://patchwork.kernel.org/project/netdevbpf/patch/[email protected]/
We should kill it before it inflicts even more damage to the error handling logic in drivers.
Also remove the unused VLAN ranges feature from the switchdev VLAN objects, which simplifies all drivers by quite a bit.
Vladimir Oltean (11):
net: switchdev: remove vid_begin -> vid_end range from VLAN objects
net: dsa: mv88e6xxx: deny vid 0 on the CPU port and DSA links too
net: switchdev: remove the transaction structure from port object
notifiers
net: switchdev: delete switchdev_port_obj_add_now
net: switchdev: remove the transaction structure from port attributes
net: dsa: remove the transactional logic from ageing time notifiers
net: dsa: remove the transactional logic from MDB entries
net: dsa: remove the transactional logic from VLAN objects
net: dsa: remove obsolete comments about switchdev transactions
mlxsw: spectrum_switchdev: remove transactional logic for VLAN objects
net: switchdev: delete the transaction object
drivers/net/dsa/b53/b53_common.c | 96 ++++------ drivers/net/dsa/b53/b53_priv.h | 15 +- drivers/net/dsa/bcm_sf2.c | 2 - drivers/net/dsa/bcm_sf2_cfp.c | 10 +- drivers/net/dsa/dsa_loop.c | 68 +++---- drivers/net/dsa/hirschmann/hellcreek.c | 39 ++-- drivers/net/dsa/lan9303-core.c | 12 +- drivers/net/dsa/lantiq_gswip.c | 100 ++++------- drivers/net/dsa/microchip/ksz8795.c | 76 ++++---- drivers/net/dsa/microchip/ksz9477.c | 96 +++++----- drivers/net/dsa/microchip/ksz_common.c | 25 +-- drivers/net/dsa/microchip/ksz_common.h | 8 +- drivers/net/dsa/mt7530.c | 52 ++---- drivers/net/dsa/mv88e6xxx/chip.c | 155 ++++++++-------- drivers/net/dsa/ocelot/felix.c | 69 ++------ drivers/net/dsa/qca8k.c | 37 ++-- drivers/net/dsa/realtek-smi-core.h | 9 +- drivers/net/dsa/rtl8366.c | 152 +++++++--------- drivers/net/dsa/rtl8366rb.c | 1 - drivers/net/dsa/sja1105/sja1105.h | 3 +- drivers/net/dsa/sja1105/sja1105_devlink.c | 9 +- drivers/net/dsa/sja1105/sja1105_main.c | 97 ++++------ .../marvell/prestera/prestera_switchdev.c | 62 ++----- .../mellanox/mlxsw/spectrum_switchdev.c | 167 +++++------------- drivers/net/ethernet/mscc/ocelot.c | 32 ++-- drivers/net/ethernet/mscc/ocelot_net.c | 69 ++------ drivers/net/ethernet/rocker/rocker.h | 6 +- drivers/net/ethernet/rocker/rocker_main.c | 61 ++----- drivers/net/ethernet/rocker/rocker_ofdpa.c | 43 ++--- drivers/net/ethernet/ti/cpsw_switchdev.c | 70 ++------ drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 115 +++++------- include/net/dsa.h | 11 +- include/net/switchdev.h | 27 +-- include/soc/mscc/ocelot.h | 3 +- net/bridge/br_switchdev.c | 6 +- net/dsa/dsa_priv.h | 27 +-- net/dsa/port.c | 103 +++++------ net/dsa/slave.c | 79 +++------ net/dsa/switch.c | 89 ++-------- net/switchdev/switchdev.c | 101 ++--------- 40 files changed, 714 insertions(+), 1488 deletions(-)
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH v3 1/11 net: switchdev: remove vid_begin -> vid_end range from VLAN objects
From: Vladimir Oltean <[email protected]>
The call path of a switchdev VLAN addition to the bridge looks something like this today:
nbp_vlan_init
| __br_vlan_set_default_pvid
| | |
| | br_afspec |
| | | |
| | v |
| | br_process_vlan_info |
| | | |
| | v |
| | br_vlan_info |
| | / \ /
| | / \ /
| | / \ /
| | / \ /
v v v v v
nbp_vlan_add br_vlan_add ------+
| ^ ^ | |
| / | | |
| / / / |
\ br_vlan_get_master/ / v
\ ^ / / br_vlan_add_existing
\ | / / |
\ | / / /
\ | / / /
\ | / / /
\ | / / /
v | | v /
__vlan_add /
/ | /
/ | /
v | /
__vlan_vid_add | /
\ | /
v v v br_switchdev_port_vlan_add
The ranges UAPI was introduced to the bridge in commit bdced7ef7838 ("bridge: support for multiple vlans and vlan ranges in setlink and dellink requests") (Jan 10 2015). But the VLAN ranges (parsed in br_afspec) have always been passed one by one, through struct bridge_vlan_info tmp_vinfo, to br_vlan_info. So the range never went too far in depth.
Then Scott Feldman introduced the switchdev_port_bridge_setlink function in commit 47f8328bb1a4 ("switchdev: add new switchdev bridge setlink"). That marked the introduction of the SWITCHDEV_OBJ_PORT_VLAN, which made full use of the range. But switchdev_port_bridge_setlink was called like this:
br_setlink
-> br_afspec
-> switchdev_port_bridge_setlink
Basically, the switchdev and the bridge code were not tightly integrated. Then commit 41c498b9359e ("bridge: restore br_setlink back to original") came, and switchdev drivers were required to implement .ndo_bridge_setlink = switchdev_port_bridge_setlink for a while.
In the meantime, commits such as 0944d6b5a2fa ("bridge: try switchdev op first in __vlan_vid_add/del") finally made switchdev penetrate the br_vlan_info() barrier and start to develop the call path we have today. But remember, br_vlan_info() still receives VLANs one by one.
Then Arkadi Sharshevsky refactored the switchdev API in 2017 in commit 29ab586c3d83 ("net: switchdev: Remove bridge bypass support from switchdev") so that drivers would not implement .ndo_bridge_setlink any longer. The switchdev_port_bridge_setlink also got deleted. This refactoring removed the parallel bridge_setlink implementation from switchdev, and left the only switchdev VLAN objects to be the ones offloaded from __vlan_vid_add (basically RX filtering) and __vlan_add (the latter coming from commit 9c86ce2c1ae3 ("net: bridge: Notify about bridge VLANs")).
That is to say, today the switchdev VLAN object ranges are not used in the kernel. Refactoring the above call path is a bit complicated, when the bridge VLAN call path is already a bit complicated.
Let's go off and finish the job of commit 29ab586c3d83 by deleting the bogus iteration through the VLAN ranges from the drivers. Some aspects of this feature never made too much sense in the first place. For example, what is a range of VLANs all having the BRIDGE_VLAN_INFO_PVID flag supposed to mean, when a port can obviously have a single pvid? This particular configuration _is_ denied as of commit 6623c60dc28e ("bridge: vlan: enforce no pvid flag in vlan ranges"), but from an API perspective, the driver still has to play pretend, and only offload the vlan->vid_end as pvid. And the addition of a switchdev VLAN object can modify the flags of another, completely unrelated, switchdev VLAN object! (a VLAN that is PVID will invalidate the PVID flag from whatever other VLAN had previously been offloaded with switchdev and had that flag. Yet switchdev never notifies about that change, drivers are supposed to guess).
Nonetheless, having a VLAN range in the API makes error handling look scarier than it really is - unwinding on errors and all of that. When in reality, no one really calls this API with more than one VLAN. It is all unnecessary complexity.
And despite appearing pretentious (two-phase transactional model and all), the switchdev API is really sloppy because the VLAN addition and removal operations are not paired with one another (you can add a VLAN 100 times and delete it just once). The bridge notifies through switchdev of a VLAN addition not only when the flags of an existing VLAN change, but also when nothing changes. There are switchdev drivers out there who don't like adding a VLAN that has already been added, and those checks don't really belong at driver level. But the fact that the API contains ranges is yet another factor that prevents this from being addressed in the future.
Of the existing switchdev pieces of hardware, it appears that only Mellanox Spectrum supports offloading more than one VLAN at a time, through mlxsw_sp_port_vlan_set. I have kept that code internal to the driver, because there is some more bookkeeping that makes use of it, but I deleted it from the switchdev API. But since the switchdev support for ranges has already been de facto deleted by a Mellanox employee and nobody noticed for 4 years, I'm going to assume it's not a biggie.
---
Changes in v3:
- Touch up the commit message a little bit.
- s/vid/vlan->vid/ in mv88e6xxx dev_err() printf message.
drivers/net/dsa/b53/b53_common.c | 54 ++++---- drivers/net/dsa/bcm_sf2_cfp.c | 3 +- drivers/net/dsa/dsa_loop.c | 39 +++--- drivers/net/dsa/hirschmann/hellcreek.c | 21 ++-- drivers/net/dsa/lantiq_gswip.c | 61 ++++------ drivers/net/dsa/microchip/ksz8795.c | 62 +++++----- drivers/net/dsa/microchip/ksz9477.c | 66 +++++----- drivers/net/dsa/mt7530.c | 32 ++--- drivers/net/dsa/mv88e6xxx/chip.c | 89 +++++++------- drivers/net/dsa/ocelot/felix.c | 42 ++----- drivers/net/dsa/qca8k.c | 17 +-- drivers/net/dsa/rtl8366.c | 115 ++++++++---------- drivers/net/dsa/sja1105/sja1105_main.c | 33 ++--- .../marvell/prestera/prestera_switchdev.c | 18 +-- .../mellanox/mlxsw/spectrum_switchdev.c | 63 +++------- drivers/net/ethernet/mscc/ocelot_net.c | 41 ++----- drivers/net/ethernet/rocker/rocker_ofdpa.c | 20 +-- drivers/net/ethernet/ti/cpsw_switchdev.c | 33 +---- drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 47 +++---- include/net/switchdev.h | 3 +- net/bridge/br_switchdev.c | 6 +- net/dsa/slave.c | 23 ++-- 22 files changed, 321 insertions(+), 567 deletions(-)
drivers/net/dsa/b53/b53_common.c +24 -30
@@ -1393,7 +1393,7 @@ int b53_vlan_prepare(struct dsa_switch *ds, int port, {struct b53_device *dev = ds->priv; -if ((is5325 (dev) ||is5365 (dev)) && vlan->vid_begin ==0 ) +if ((is5325 (dev) ||is5365 (dev)) && vlan->vid ==0 )return -EOPNOTSUPP ;/* Port 7 on 7278 connects to the ASP's UniMAC which is not capable of
@@ -1404,7 +1404,7 @@ int b53_vlan_prepare(struct dsa_switch *ds, int port, !(vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED))return -EINVAL ; -if (vlan->vid_end > dev->num_vlans) +if (vlan->vid > dev->num_vlans)return -ERANGE ;b53_enable_vlan (dev, true, ds->vlan_filtering);
@@ -1420,30 +1420,27 @@ void b53_vlan_add(struct dsa_switch *ds, int port,bool untagged = vlan->flags &BRIDGE_VLAN_INFO_UNTAGGED ;bool pvid = vlan->flags &BRIDGE_VLAN_INFO_PVID ;struct b53_vlan *vl; -u16 vid; -for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) { - vl = &dev->vlans[vid]; + vl = &dev->vlans[vlan->vid]; -b53_get_vlan_entry (dev, vid, vl); +b53_get_vlan_entry (dev, vlan->vid, vl); -if (vid ==0 && vid ==b53_default_pvid (dev)) - untagged = true; +if (vlan->vid ==0 && vlan->vid ==b53_default_pvid (dev)) + untagged = true; - vl->members |=BIT (port); -if (untagged && !dsa_is_cpu_port (ds, port)) - vl->untag |=BIT (port); -else - vl->untag &= ~BIT (port); + vl->members |=BIT (port); +if (untagged && !dsa_is_cpu_port (ds, port)) + vl->untag |=BIT (port); +else + vl->untag &= ~BIT (port); -b53_set_vlan_entry (dev, vid, vl); -b53_fast_age_vlan (dev, vid); - } +b53_set_vlan_entry (dev, vlan->vid, vl); +b53_fast_age_vlan (dev, vlan->vid);if (pvid && !dsa_is_cpu_port (ds, port)) {b53_write16 (dev,B53_VLAN_PAGE ,B53_VLAN_PORT_DEF_TAG (port), - vlan->vid_end); -b53_fast_age_vlan (dev, vid); + vlan->vid); +b53_fast_age_vlan (dev, vlan->vid); } }EXPORT_SYMBOL (b53_vlan_add);
@@ -1454,27 +1451,24 @@ int b53_vlan_del(struct dsa_switch *ds, int port,struct b53_device *dev = ds->priv;bool untagged = vlan->flags &BRIDGE_VLAN_INFO_UNTAGGED ;struct b53_vlan *vl; -u16 vid;u16 pvid;b53_read16 (dev,B53_VLAN_PAGE ,B53_VLAN_PORT_DEF_TAG (port), &pvid); -for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) { - vl = &dev->vlans[vid]; + vl = &dev->vlans[vlan->vid]; -b53_get_vlan_entry (dev, vid, vl); +b53_get_vlan_entry (dev, vlan->vid, vl); - vl->members &= ~BIT (port); + vl->members &= ~BIT (port); -if (pvid == vid) - pvid =b53_default_pvid (dev); +if (pvid == vlan->vid) + pvid =b53_default_pvid (dev); -if (untagged && !dsa_is_cpu_port (ds, port)) - vl->untag &= ~(BIT (port)); +if (untagged && !dsa_is_cpu_port (ds, port)) + vl->untag &= ~(BIT (port)); -b53_set_vlan_entry (dev, vid, vl); -b53_fast_age_vlan (dev, vid); - } +b53_set_vlan_entry (dev, vlan->vid, vl); +b53_fast_age_vlan (dev, vlan->vid);b53_write16 (dev,B53_VLAN_PAGE ,B53_VLAN_PORT_DEF_TAG (port), pvid);b53_fast_age_vlan (dev, pvid);
drivers/net/dsa/bcm_sf2_cfp.c +1 -2
@@ -885,8 +885,7 @@ static int bcm_sf2_cfp_rule_insert(struct dsa_switch *ds, int port,return -EINVAL ; vid =be16_to_cpu (fs->h_ext.vlan_tci) &VLAN_VID_MASK ; - vlan.vid_begin = vid; - vlan.vid_end = vid; + vlan.vid = vid;if (cpu_to_be32 (fs->h_ext.data[1 ]) &1 ) vlan.flags =BRIDGE_VLAN_INFO_UNTAGGED ;else
drivers/net/dsa/dsa_loop.c +17 -22
@@ -206,8 +206,7 @@ dsa_loop_port_vlan_prepare(struct dsa_switch *ds, int port,struct dsa_loop_priv *ps = ds->priv;struct mii_bus *bus = ps->bus; -dev_dbg (ds->dev,"%s: port: %d, vlan: %d-%d" , - __func__, port, vlan->vid_begin, vlan->vid_end); +dev_dbg (ds->dev,"%s: port: %d, vlan: %d" , __func__, port, vlan->vid);/* Just do a sleeping operation to make lockdep checks effective */ mdiobus_read (bus, ps->port_base + port,MII_BMSR );
@@ -231,18 +230,16 @@ static void dsa_loop_port_vlan_add(struct dsa_switch *ds, int port,/* Just do a sleeping operation to make lockdep checks effective */ mdiobus_read (bus, ps->port_base + port,MII_BMSR ); -for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) { - vl = &ps->vlans[vid]; + vl = &ps->vlans[vlan->vid]; - vl->members |=BIT (port); -if (untagged) - vl->untagged |=BIT (port); -else - vl->untagged &= ~BIT (port); + vl->members |=BIT (port); +if (untagged) + vl->untagged |=BIT (port); +else + vl->untagged &= ~BIT (port); -dev_dbg (ds->dev,"%s: port: %d vlan: %d, %stagged, pvid: %d\n" , - __func__, port, vid, untagged ?"un" :"" , pvid); - } +dev_dbg (ds->dev,"%s: port: %d vlan: %d, %stagged, pvid: %d\n" , + __func__, port, vid, untagged ?"un" :"" , pvid);if (pvid) ps->ports[port].pvid = vid;
@@ -260,19 +257,17 @@ static int dsa_loop_port_vlan_del(struct dsa_switch *ds, int port,/* Just do a sleeping operation to make lockdep checks effective */ mdiobus_read (bus, ps->port_base + port,MII_BMSR ); -for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) { - vl = &ps->vlans[vid]; + vl = &ps->vlans[vlan->vid]; - vl->members &= ~BIT (port); -if (untagged) - vl->untagged &= ~BIT (port); + vl->members &= ~BIT (port); +if (untagged) + vl->untagged &= ~BIT (port); -if (pvid == vid) - pvid =1 ; +if (pvid == vid) + pvid =1 ; -dev_dbg (ds->dev,"%s: port: %d vlan: %d, %stagged, pvid: %d\n" , - __func__, port, vid, untagged ?"un" :"" , pvid); - } +dev_dbg (ds->dev,"%s: port: %d vlan: %d, %stagged, pvid: %d\n" , + __func__, port, vid, untagged ?"un" :"" , pvid); ps->ports[port].pvid = pvid;return 0 ;
drivers/net/dsa/hirschmann/hellcreek.c +7 -14
@@ -353,9 +353,8 @@ static int hellcreek_vlan_prepare(struct dsa_switch *ds, int port,if (!dsa_is_user_port (ds, i))continue ; -for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) -if (vid == restricted_vid) -return -EBUSY ; +if (vlan->vid == restricted_vid) +return -EBUSY ; }return 0 ;
@@ -446,28 +445,22 @@ static void hellcreek_vlan_add(struct dsa_switch *ds, int port,bool untagged = vlan->flags &BRIDGE_VLAN_INFO_UNTAGGED ;bool pvid = vlan->flags &BRIDGE_VLAN_INFO_PVID ;struct hellcreek *hellcreek = ds->priv; -u16 vid; -dev_dbg (hellcreek->dev,"Add VLANs (%d -- %d) on port %d, %s, %s\n" , - vlan->vid_begin, vlan->vid_end, port, - untagged ?"untagged" :"tagged" , +dev_dbg (hellcreek->dev,"Add VLAN %d on port %d, %s, %s\n" , + vlan->vid, port, untagged ?"untagged" :"tagged" , pvid ?"PVID" :"no PVID" ); -for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) -hellcreek_apply_vlan (hellcreek, port, vid, pvid, untagged); +hellcreek_apply_vlan (hellcreek, port, vlan->vid, pvid, untagged); }static int hellcreek_vlan_del (struct dsa_switch *ds,int port,const struct switchdev_obj_port_vlan *vlan) {struct hellcreek *hellcreek = ds->priv; -u16 vid; -dev_dbg (hellcreek->dev,"Remove VLANs (%d -- %d) on port %d\n" , - vlan->vid_begin, vlan->vid_end, port); +dev_dbg (hellcreek->dev,"Remove VLAN %d on port %d\n" , vlan->vid, port); -for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) -hellcreek_unapply_vlan (hellcreek, port, vid); +hellcreek_unapply_vlan (hellcreek, port, vlan->vid);return 0 ; }
drivers/net/dsa/lantiq_gswip.c +23 -38
102 lines not on this page · raw message
drivers/net/dsa/microchip/ksz8795.c +30 -32
93 lines not on this page · raw message
drivers/net/dsa/microchip/ksz9477.c +30 -36
93 lines not on this page · raw message
drivers/net/dsa/mt7530.c +13 -19
@@ -1501,20 +1501,16 @@ mt7530_port_vlan_add(struct dsa_switch *ds, int port,bool pvid = vlan->flags &BRIDGE_VLAN_INFO_PVID ;struct mt7530_hw_vlan_entry new_entry;struct mt7530_priv *priv = ds->priv; -u16 vid;mutex_lock (&priv->reg_mutex); -for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) { -mt7530_hw_vlan_entry_init (&new_entry, port, untagged); -mt7530_hw_vlan_update (priv, vid, &new_entry, - mt7530_hw_vlan_add); - } +mt7530_hw_vlan_entry_init (&new_entry, port, untagged); +mt7530_hw_vlan_update (priv, vlan->vid, &new_entry, mt7530_hw_vlan_add);if (pvid) {mt7530_rmw (priv,MT7530_PPBV1_P (port),G0_PORT_VID_MASK , -G0_PORT_VID (vlan->vid_end)); - priv->ports[port].pvid = vlan->vid_end; +G0_PORT_VID (vlan->vid)); + priv->ports[port].pvid = vlan->vid; }mutex_unlock (&priv->reg_mutex);
@@ -1526,22 +1522,20 @@ mt7530_port_vlan_del(struct dsa_switch *ds, int port, {struct mt7530_hw_vlan_entry target_entry;struct mt7530_priv *priv = ds->priv; -u16 vid, pvid; +u16 pvid;mutex_lock (&priv->reg_mutex); pvid = priv->ports[port].pvid; -for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) { -mt7530_hw_vlan_entry_init (&target_entry, port,0 ); -mt7530_hw_vlan_update (priv, vid, &target_entry, - mt7530_hw_vlan_del); +mt7530_hw_vlan_entry_init (&target_entry, port,0 ); +mt7530_hw_vlan_update (priv, vlan->vid, &target_entry, + mt7530_hw_vlan_del); -/* PVID is being restored to the default whenever the PVID port -* is being removed from the VLAN. -*/ -if (pvid == vid) - pvid =G0_PORT_VID_DEF ; - } +/* PVID is being restored to the default whenever the PVID port +* is being removed from the VLAN. +*/ +if (pvid == vlan->vid) + pvid =G0_PORT_VID_DEF ;mt7530_rmw (priv,MT7530_PPBV1_P (port),G0_PORT_VID_MASK , pvid); priv->ports[port].pvid = pvid;
drivers/net/dsa/mv88e6xxx/chip.c +41 -48
148 lines not on this page · raw message
drivers/net/dsa/ocelot/felix.c +8 -34
68 lines not on this page · raw message
drivers/net/dsa/qca8k.c +5 -12
@@ -1330,11 +1330,8 @@ qca8k_port_vlan_add(struct dsa_switch *ds, int port,bool pvid = vlan->flags &BRIDGE_VLAN_INFO_PVID ;struct qca8k_priv *priv = ds->priv;int ret =0 ; -u16 vid; - -for (vid = vlan->vid_begin; vid <= vlan->vid_end && !ret; ++vid) - ret =qca8k_vlan_add (priv, port, vid, untagged); + ret =qca8k_vlan_add (priv, port, vlan->vid, untagged);if (ret)dev_err (priv->dev,"Failed to add VLAN to port %d (%d)" , port, ret);
@@ -1342,11 +1339,10 @@ qca8k_port_vlan_add(struct dsa_switch *ds, int port,int shift =16 * (port %2 );qca8k_rmw (priv,QCA8K_EGRESS_VLAN (port), -0xfff << shift, - vlan->vid_end << shift); +0xfff << shift, vlan->vid << shift);qca8k_write (priv,QCA8K_REG_PORT_VLAN_CTRL0 (port), -QCA8K_PORT_VLAN_CVID (vlan->vid_end) | -QCA8K_PORT_VLAN_SVID (vlan->vid_end)); +QCA8K_PORT_VLAN_CVID (vlan->vid) | +QCA8K_PORT_VLAN_SVID (vlan->vid)); } }
@@ -1356,11 +1352,8 @@ qca8k_port_vlan_del(struct dsa_switch *ds, int port, {struct qca8k_priv *priv = ds->priv;int ret =0 ; -u16 vid; - -for (vid = vlan->vid_begin; vid <= vlan->vid_end && !ret; ++vid) - ret =qca8k_vlan_del (priv, port, vid); + ret =qca8k_vlan_del (priv, port, vlan->vid);if (ret)dev_err (priv->dev,"Failed to delete VLAN from port %d (%d)" , port, ret);
drivers/net/dsa/rtl8366.c +48 -67
155 lines not on this page · raw message
drivers/net/dsa/sja1105/sja1105_main.c +12 -21
@@ -2611,7 +2611,6 @@ static int sja1105_vlan_prepare(struct dsa_switch *ds, int port, const struct switchdev_obj_port_vlan *vlan) {struct sja1105_private *priv = ds->priv; -u16 vid;if (priv->vlan_state ==SJA1105_VLAN_FILTERING_FULL )return 0 ;
@@ -2620,11 +2619,9 @@ static int sja1105_vlan_prepare(struct dsa_switch *ds, int port,* bridge plus tagging), be sure to at least deny alterations to the * configuration done by dsa_8021q. */ -for (vid = vlan->vid_begin; vid <= vlan->vid_end; vid++) { -if (vid_is_dsa_8021q (vid)) { -dev_err (ds->dev,"Range 1024-3071 reserved for dsa_8021q operation\n" ); -return -EBUSY ; - } +if (vid_is_dsa_8021q (vlan->vid)) { +dev_err (ds->dev,"Range 1024-3071 reserved for dsa_8021q operation\n" ); +return -EBUSY ; }return 0 ;
@@ -2799,17 +2796,14 @@ static void sja1105_vlan_add(struct dsa_switch *ds, int port, {struct sja1105_private *priv = ds->priv;bool vlan_table_changed = false; -u16 vid;int rc; -for (vid = vlan->vid_begin; vid <= vlan->vid_end; vid++) { - rc =sja1105_vlan_add_one (ds, port, vid, vlan->flags, - &priv->bridge_vlans); -if (rc <0 ) -return ; -if (rc >0 ) - vlan_table_changed = true; - } + rc =sja1105_vlan_add_one (ds, port, vlan->vid, vlan->flags, + &priv->bridge_vlans); +if (rc <0 ) +return ; +if (rc >0 ) + vlan_table_changed = true;if (!vlan_table_changed)return ;
@@ -2824,14 +2818,11 @@ static int sja1105_vlan_del(struct dsa_switch *ds, int port, {struct sja1105_private *priv = ds->priv;bool vlan_table_changed = false; -u16 vid;int rc; -for (vid = vlan->vid_begin; vid <= vlan->vid_end; vid++) { - rc =sja1105_vlan_del_one (ds, port, vid, &priv->bridge_vlans); -if (rc >0 ) - vlan_table_changed = true; - } + rc =sja1105_vlan_del_one (ds, port, vlan->vid, &priv->bridge_vlans); +if (rc >0 ) + vlan_table_changed = true;if (!vlan_table_changed)return 0 ;
drivers/net/ethernet/marvell/prestera/prestera_switchdev.c +4 -14
@@ -1045,17 +1045,9 @@ static int prestera_port_vlans_add(struct prestera_port *port,if (!bridge->vlan_enabled)return 0 ; -for (vid = vlan->vid_begin; vid <= vlan->vid_end; vid++) { -int err; - - err =prestera_bridge_port_vlan_add (port, br_port, - vid, flag_untagged, - flag_pvid, extack); -if (err) -return err; - } - -return 0 ; +return prestera_bridge_port_vlan_add (port, br_port, + vid, flag_untagged, + flag_pvid, extack); } static int prestera_port_obj_add(struct net_device *dev,
@@ -1081,7 +1073,6 @@ static int prestera_port_vlans_del(struct prestera_port *port,struct net_device *dev = vlan->obj.orig_dev;struct prestera_bridge_port *br_port;struct prestera_switch *sw = port->sw; -u16 vid;if (netif_is_bridge_master (dev))return -EOPNOTSUPP ;
@@ -1093,8 +1084,7 @@ static int prestera_port_vlans_del(struct prestera_port *port,if (!br_port->bridge->vlan_enabled)return 0 ; -for (vid = vlan->vid_begin; vid <= vlan->vid_end; vid++) -prestera_bridge_port_vlan_del (port, br_port, vid); +prestera_bridge_port_vlan_del (port, br_port, vlan->vid);return 0 ; }
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +19 -44
122 lines not on this page · raw message
drivers/net/ethernet/mscc/ocelot_net.c +9 -32
56 lines not on this page · raw message
drivers/net/ethernet/rocker/rocker_ofdpa.c +2 -18
@@ -2540,32 +2540,16 @@ static int ofdpa_port_obj_vlan_add(struct rocker_port *rocker_port, const struct switchdev_obj_port_vlan *vlan) {struct ofdpa_port *ofdpa_port = rocker_port->wpriv; -u16 vid; -int err; -for (vid = vlan->vid_begin; vid <= vlan->vid_end; vid++) { - err =ofdpa_port_vlan_add (ofdpa_port, vid, vlan->flags); -if (err) -return err; - } - -return 0 ; +return ofdpa_port_vlan_add (ofdpa_port, vlan->vid, vlan->flags); }static int ofdpa_port_obj_vlan_del (struct rocker_port *rocker_port,const struct switchdev_obj_port_vlan *vlan) {struct ofdpa_port *ofdpa_port = rocker_port->wpriv; -u16 vid; -int err; -for (vid = vlan->vid_begin; vid <= vlan->vid_end; vid++) { - err =ofdpa_port_vlan_del (ofdpa_port, vid, vlan->flags); -if (err) -return err; - } - -return 0 ; +return ofdpa_port_vlan_del (ofdpa_port, vlan->vid, vlan->flags); } static int ofdpa_port_obj_fdb_add(struct rocker_port *rocker_port,
drivers/net/ethernet/ti/cpsw_switchdev.c +3 -30
@@ -260,10 +260,9 @@ static int cpsw_port_vlans_add(struct cpsw_priv *priv,struct net_device *orig_dev = vlan->obj.orig_dev;bool cpu_port =netif_is_bridge_master (orig_dev);bool pvid = vlan->flags &BRIDGE_VLAN_INFO_PVID ; -u16 vid;dev_dbg (priv->dev,"VID add: %s: vid:%u flags:%X\n" , - priv->ndev->name, vlan->vid_begin, vlan->flags); + priv->ndev->name, vlan->vid, vlan->flags);if (cpu_port && !(vlan->flags &BRIDGE_VLAN_INFO_BRENTRY ))return 0 ;
@@ -271,33 +270,7 @@ static int cpsw_port_vlans_add(struct cpsw_priv *priv,if (switchdev_trans_ph_prepare (trans))return 0 ; -for (vid = vlan->vid_begin; vid <= vlan->vid_end; vid++) { -int err; - - err =cpsw_port_vlan_add (priv, untag, pvid, vid, orig_dev); -if (err) -return err; - } - -return 0 ; -} - -static int cpsw_port_vlans_del (struct cpsw_priv *priv, -const struct switchdev_obj_port_vlan *vlan) - -{ -struct net_device *orig_dev = vlan->obj.orig_dev; -u16 vid; - -for (vid = vlan->vid_begin; vid <= vlan->vid_end; vid++) { -int err; - - err =cpsw_port_vlan_del (priv, vid, orig_dev); -if (err) -return err; - } - -return 0 ; +return cpsw_port_vlan_add (priv, untag, pvid, vlan->vid, orig_dev); } static int cpsw_port_mdb_add(struct cpsw_priv *priv,
@@ -392,7 +365,7 @@ static int cpsw_port_obj_del(struct net_device *ndev,switch (obj->id) {case SWITCHDEV_OBJ_ID_PORT_VLAN : - err =cpsw_port_vlans_del (priv, vlan); + err =cpsw_port_vlan_del (priv, vlan->vid, vlan->obj.orig_dev);break ;case SWITCHDEV_OBJ_ID_PORT_MDB :case SWITCHDEV_OBJ_ID_HOST_MDB :
drivers/staging/fsl-dpaa2/ethsw/ethsw.c +15 -32
79 lines not on this page · raw message
include/net/switchdev.h +1 -2
@@ -97,8 +97,7 @@ struct switchdev_obj {struct switchdev_obj_port_vlan {struct switchdev_obj obj;u16 flags; -u16 vid_begin; -u16 vid_end; +u16 vid; };#define SWITCHDEV_OBJ_PORT_VLAN (OBJ ) \
net/bridge/br_switchdev.c +2 -4
@@ -153,8 +153,7 @@ int br_switchdev_port_vlan_add(struct net_device *dev, u16 vid, u16 flags, .obj.orig_dev = dev, .obj.id = SWITCHDEV_OBJ_ID_PORT_VLAN, .flags = flags, - .vid_begin = vid, - .vid_end = vid, + .vid = vid, };return switchdev_port_obj_add (dev, &v.obj, extack);
@@ -165,8 +164,7 @@ int br_switchdev_port_vlan_del(struct net_device *dev, u16 vid)struct switchdev_obj_port_vlan v = { .obj.orig_dev = dev, .obj.id =SWITCHDEV_OBJ_ID_PORT_VLAN , - .vid_begin = vid, - .vid_end = vid, + .vid = vid, };return switchdev_port_obj_del (dev, &v.obj);
net/dsa/slave.c +7 -16
@@ -318,7 +318,7 @@ dsa_slave_vlan_check_for_8021q_uppers(struct net_device *slave,continue ; vid =vlan_dev_vlan_id (upper_dev); -if (vid >= vlan->vid_begin && vid <= vlan->vid_end) +if (vid == vlan->vid)return -EBUSY ; }
@@ -332,7 +332,7 @@ static int dsa_slave_vlan_add(struct net_device *dev,struct net_device *master =dsa_slave_to_master (dev);struct dsa_port *dp =dsa_slave_to_port (dev);struct switchdev_obj_port_vlan vlan; -int vid, err; +int err;if (obj->orig_dev != dev)return -EOPNOTSUPP ;
@@ -367,13 +367,7 @@ static int dsa_slave_vlan_add(struct net_device *dev,if (err)return err; -for (vid = vlan.vid_begin; vid <= vlan.vid_end; vid++) { - err =vlan_vid_add (master,htons (ETH_P_8021Q ), vid); -if (err) -return err; - } - -return 0 ; +return vlan_vid_add (master,htons (ETH_P_8021Q ), vlan.vid); } static int dsa_slave_port_obj_add(struct net_device *dev,
@@ -419,7 +413,7 @@ static int dsa_slave_vlan_del(struct net_device *dev,struct net_device *master =dsa_slave_to_master (dev);struct dsa_port *dp =dsa_slave_to_port (dev);struct switchdev_obj_port_vlan *vlan; -int vid, err; +int err;if (obj->orig_dev != dev)return -EOPNOTSUPP ;
@@ -436,8 +430,7 @@ static int dsa_slave_vlan_del(struct net_device *dev,if (err)return err; -for (vid = vlan->vid_begin; vid <= vlan->vid_end; vid++) -vlan_vid_del (master,htons (ETH_P_8021Q ), vid); +vlan_vid_del (master,htons (ETH_P_8021Q ), vlan->vid);return 0 ; }
@@ -1289,8 +1282,7 @@ static int dsa_slave_vlan_rx_add_vid(struct net_device *dev, __be16 proto,struct dsa_port *dp =dsa_slave_to_port (dev);struct switchdev_obj_port_vlan vlan = { .obj.id =SWITCHDEV_OBJ_ID_PORT_VLAN , - .vid_begin = vid, - .vid_end = vid, + .vid = vid,/* This API only allows programming tagged, non-PVID VIDs */ .flags =0 , };
@@ -1328,8 +1320,7 @@ static int dsa_slave_vlan_rx_kill_vid(struct net_device *dev, __be16 proto,struct net_device *master =dsa_slave_to_master (dev);struct dsa_port *dp =dsa_slave_to_port (dev);struct switchdev_obj_port_vlan vlan = { - .vid_begin = vid, - .vid_end = vid, + .vid = vid,/* This API only allows programming tagged, non-PVID VIDs */ .flags =0 , };
Signature · 1 line
2.25.1
Kurt Kanzenbach
maintainerRe: [PATCH v3 net-next 01/11] net: switchdev: remove vid_begin -> vid_end range from VLAN objects
Quoted 122 lines · Vladimir Oltean
From: Vladimir Oltean <[email protected]>
The call path of a switchdev VLAN addition to the bridge looks something like this today:
nbp_vlan_init
|__br_vlan_set_default_pvid
| | |
| |br_afspec|
| | | |
| | v |
| |br_process_vlan_info|
| | | |
| | v |
| |br_vlan_info|
| | / \ /
| | / \ /
| | / \ /
| | / \ /
v v v v v
nbp_vlan_addbr_vlan_add------+
| ^ ^ | |
| / | | |
| / / / |
\ br_vlan_get_master/ / v
\ ^ / /br_vlan_add_existing
\ | / / |
\ | / / /
\ | / / /
\ | / / /
\ | / / /
v | | v /
__vlan_add/
/ | /
/ | /
v | /__vlan_vid_add | / \ | / v v v
br_switchdev_port_vlan_addThe ranges UAPI was introduced to the bridge in commit
bdced7ef7838("bridge: support for multiple vlans and vlan ranges in setlink and dellink requests") (Jan 10 2015). But the VLAN ranges (parsed inbr_afspec) have always been passed one by one, through structbridge_vlan_infotmp_vinfo, tobr_vlan_info. So the range never went too far in depth.Then Scott Feldman introduced the
switchdev_port_bridge_setlinkfunction in commit47f8328bb1a4("switchdev: add new switchdev bridge setlink"). That marked the introduction of theSWITCHDEV_OBJ_PORT_VLAN, which made full use of the range. Butswitchdev_port_bridge_setlinkwas called like this:
br_setlink
->br_afspec
->switchdev_port_bridge_setlinkBasically, the switchdev and the bridge code were not tightly integrated. Then commit
41c498b9359e("bridge: restorebr_setlinkback to original") came, and switchdev drivers were required to implement .ndo_bridge_setlink =switchdev_port_bridge_setlinkfor a while.In the meantime, commits such as
0944d6b5a2fa("bridge: try switchdev op first in __vlan_vid_add/del") finally made switchdev penetrate thebr_vlan_info()barrier and start to develop the call path we have today. But remember,br_vlan_info()still receives VLANs one by one.Then Arkadi Sharshevsky refactored the switchdev API in 2017 in commit
29ab586c3d83("net: switchdev: Remove bridge bypass support from switchdev") so that drivers would not implement .ndo_bridge_setlink any longer. Theswitchdev_port_bridge_setlinkalso got deleted. This refactoring removed the parallelbridge_setlinkimplementation from switchdev, and left the only switchdev VLAN objects to be the ones offloaded from__vlan_vid_add(basically RX filtering) and__vlan_add(the latter coming from commit9c86ce2c1ae3("net: bridge: Notify about bridge VLANs")).That is to say, today the switchdev VLAN object ranges are not used in the kernel. Refactoring the above call path is a bit complicated, when the bridge VLAN call path is already a bit complicated.
Let's go off and finish the job of commit
29ab586c3d83by deleting the bogus iteration through the VLAN ranges from the drivers. Some aspects of this feature never made too much sense in the first place. For example, what is a range of VLANs all having theBRIDGE_VLAN_INFO_PVIDflag supposed to mean, when a port can obviously have a single pvid? This particular configuration _is_ denied as of commit6623c60dc28e("bridge: vlan: enforce no pvid flag in vlan ranges"), but from an API perspective, the driver still has to play pretend, and only offload thevlan->vid_endas pvid. And the addition of a switchdev VLAN object can modify the flags of another, completely unrelated, switchdev VLAN object! (a VLAN that is PVID will invalidate the PVID flag from whatever other VLAN had previously been offloaded with switchdev and had that flag. Yet switchdev never notifies about that change, drivers are supposed to guess).Nonetheless, having a VLAN range in the API makes error handling look scarier than it really is - unwinding on errors and all of that. When in reality, no one really calls this API with more than one VLAN. It is all unnecessary complexity.
And despite appearing pretentious (two-phase transactional model and all), the switchdev API is really sloppy because the VLAN addition and removal operations are not paired with one another (you can add a VLAN 100 times and delete it just once). The bridge notifies through switchdev of a VLAN addition not only when the flags of an existing VLAN change, but also when nothing changes. There are switchdev drivers out there who don't like adding a VLAN that has already been added, and those checks don't really belong at driver level. But the fact that the API contains ranges is yet another factor that prevents this from being addressed in the future.
Of the existing switchdev pieces of hardware, it appears that only Mellanox Spectrum supports offloading more than one VLAN at a time, through
mlxsw_sp_port_vlan_set. I have kept that code internal to the driver, because there is some more bookkeeping that makes use of it, but I deleted it from the switchdev API. But since the switchdev support for ranges has already been de facto deleted by a Mellanox employee and nobody noticed for 4 years, I'm going to assume it's not a biggie.Signed-off-by Vladimir Oltean <[email protected]>
[snip]
drivers/net/dsa/hirschmann/hellcreek.c static int hellcreek_vlan_prepare(struct dsa_switch *ds, int port, · line 357
Quoted 11 lines
drivers/net/dsa/hirschmann/hellcreek.c +2
-3@@ -353,9 +353,8 @@ static int hellcreek_vlan_prepare(struct dsa_switch *ds, int port,if (!dsa_is_user_port (ds, i))continue ; -for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) -if (vid == restricted_vid) -return -EBUSY ; +if (vlan->vid == restricted_vid) +return -EBUSY ;
`u16 vid' is not used anymore:
drivers/net/dsa/hirschmann/hellcreek.c: In function ‘hellcreek_vlan_prepare’:drivers/net/dsa/hirschmann/hellcreek.c:359:7: warning: unused variable ‘vid’ [-Wunused-variable]
u16 vid;
^~~Thanks,
Kurt
Vladimir Oltean
maintainerRe: [PATCH v3 net-next 01/11] net: switchdev: remove vid_begin -> vid_end range from VLAN objects
Quoted 16 lines · Kurt Kanzenbach
[snip]
drivers/net/dsa/hirschmann/hellcreek.c static int hellcreek_vlan_prepare(struct dsa_switch *ds, int port, · line 357
Quoted 11 lines
drivers/net/dsa/hirschmann/hellcreek.c +2
-3@@ -353,9 +353,8 @@ static int hellcreek_vlan_prepare(struct dsa_switch *ds, int port,if (!dsa_is_user_port (ds, i))continue ; -for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) -if (vid == restricted_vid) -return -EBUSY ; +if (vlan->vid == restricted_vid) +return -EBUSY ;`u16 vid' is not used anymore:
Quoted 4 lines
drivers/net/dsa/hirschmann/hellcreek.c: In function ‘hellcreek_vlan_prepare’:drivers/net/dsa/hirschmann/hellcreek.c:359:7: warning: unused variable ‘vid’ [-Wunused-variable]u16 vid; ^~~
Thanks, I noticed now. I also noticed I did not update dsa_loop. Sorry.
https://patchwork.hopto.org/static/nipa/410259/12002471/build_32bit/stderr
Vladimir Oltean
maintainerPATCH v3 2/11 net: dsa: mv88e6xxx: deny vid 0 on the CPU port and DSA links too
In reply to Vladimir Olteanmv88e6xxx apparently has a problem offloading VID 0, which the 8021q module tries to install as part of commit ad1afb003939 ("vlan_dev: VLAN 0 should be treated as "no vlan tag" (802.1p packet)"). That mv88e6xxx restriction seems to have been introduced by the "VTU GetNext VID-1 trick to retrieve a single entry" - see commit 2fb5ef09de7c ("net: dsa:
mv88e6xxx: extract single VLAN retrieval").
There is one more problem. The mv88e6xxx CPU port and DSA links are very gullible. They'll say yes to whatever VLAN you ask them to offload:
mv88e6xxx_port_vlan_prepare
-> mv88e6xxx_port_check_hw_vlan:
/* DSA and CPU ports have to be members of multiple vlans */ if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port)) return 0;
Except that if you actually try to commit to it, they'll error out and print this message:
[ 32.802438] mv88e6085 d0032004.mdio-mii:12: p9: failed to add VLAN 0t
which comes from:
mv88e6xxx_port_vlan_add
-> mv88e6xxx_port_vlan_join:
if (!vid) return -EOPNOTSUPP;
What prevents this condition from triggering in real life? The fact that when a DSA_NOTIFIER_VLAN_ADD is emitted, it never targets a DSA link directly. Instead, the notifier will always target either a user port or a CPU port. DSA links just happen to get dragged in by:
static bool dsa_switch_vlan_match(struct dsa_switch *ds, int port,
struct dsa_notifier_vlan_info *info)
{
...
if (dsa_is_dsa_port(ds, port))
return true;
...
}So for every DSA VLAN notifier, during the prepare phase, it will just so happen that there will be somebody to say "no, don't do that".
This will become a problem when the switchdev prepare/commit transactional model goes away. Every port needs to think on its own. DSA links can no longer bluff and rely on the fact that the prepare phase will not go through to the end, because there will be no prepare phase any longer.
Fix this issue before it becomes a problem, by having the "vid == 0" check earlier than the check whether we are a CPU port / DSA link or not. Also, the "vid == 0" check becomes unnecessary in the .port_vlan_add callback, so we can remove it.
---
Changes in v3:
Patch is new.
drivers/net/dsa/mv88e6xxx/chip.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/net/dsa/mv88e6xxx/chip.c +3 -6
@@ -1535,13 +1535,13 @@ static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,struct mv88e6xxx_vtu_entry vlan;int i, err; +if (!vid) +return -EOPNOTSUPP ; +/* DSA and CPU ports have to be members of multiple vlans */ if (dsa_is_dsa_port (ds, port) ||dsa_is_cpu_port (ds, port))return 0 ; -if (!vid) -return -EOPNOTSUPP ; - vlan.vid = vid -1 ; vlan.valid = false;
@@ -1920,9 +1920,6 @@ static int mv88e6xxx_port_vlan_join(struct mv88e6xxx_chip *chip, int port,struct mv88e6xxx_vtu_entry vlan;int i, err; -if (!vid) -return -EOPNOTSUPP ; - vlan.vid = vid -1 ; vlan.valid = false;
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH v3 3/11 net: switchdev: remove the transaction structure from port object notifiers
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
Since the introduction of the switchdev API, port objects were transmitted to drivers for offloading using a two-step transactional model, with a prepare phase that was supposed to catch all errors, and a commit phase that was supposed to never fail.
Some classes of failures can never be avoided, like hardware access, or memory allocation. In the latter case, merely attempting to move the memory allocation to the preparation phase makes it impossible to avoid memory leaks, since commit 91cf8eceffc1 ("switchdev: Remove unused transaction item queue") which has removed the unused mechanism of passing on the allocated memory between one phase and another.
It is time we admit that separating the preparation from the commit phase is something that is best left for the driver to decide, and not something that should be baked into the API, especially since there are no switchdev callers that depend on this.
This patch removes the struct switchdev_trans member from switchdev port object notifier structures, and converts drivers to not look at this member.
Where driver conversion is trivial (like in the case of the Marvell Prestera driver, NXP DPAA2 switch, TI CPSW, and Rocker drivers), it is done in this patch.
Where driver conversion needs more attention (DSA, Mellanox Spectrum), the conversion is left for subsequent patches and here we only fake the prepare/commit phases at a lower level, just not in the switchdev notifier itself.
Where the code has a natural structure that is best left alone as a preparation and a commit phase (as in the case of the Ocelot switch), that structure is left in place, just made to not depend upon the switchdev transactional model.
---
Changes in v3:
None.
Changes in v2:
Rebased on top of the VLAN range deletion.
.../marvell/prestera/prestera_switchdev.c | 7 +-- .../mellanox/mlxsw/spectrum_switchdev.c | 51 +++++++++------- drivers/net/ethernet/mscc/ocelot_net.c | 25 +++----- drivers/net/ethernet/rocker/rocker_main.c | 15 ++--- drivers/net/ethernet/ti/cpsw_switchdev.c | 17 ++---- drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 59 +++++++++---------- include/net/switchdev.h | 3 - net/dsa/dsa_priv.h | 8 +-- net/dsa/port.c | 8 +-- net/dsa/slave.c | 34 +++-------- net/dsa/switch.c | 36 ++--------- net/switchdev/switchdev.c | 42 ++----------- 12 files changed, 97 insertions(+), 208 deletions(-)
drivers/net/ethernet/marvell/prestera/prestera_switchdev.c +1 -6
@@ -1020,7 +1020,6 @@ prestera_bridge_port_vlan_del(struct prestera_port *port,static int prestera_port_vlans_add (struct prestera_port *port,const struct switchdev_obj_port_vlan *vlan, -struct switchdev_trans *trans,struct netlink_ext_ack *extack) {bool flag_untagged = vlan->flags &BRIDGE_VLAN_INFO_UNTAGGED ;
@@ -1034,9 +1033,6 @@ static int prestera_port_vlans_add(struct prestera_port *port,if (netif_is_bridge_master (dev))return 0 ; -if (switchdev_trans_ph_commit (trans)) -return 0 ; - br_port =prestera_bridge_port_by_dev (sw->swdev, dev);if (WARN_ON (!br_port))return -EINVAL ;
@@ -1052,7 +1048,6 @@ static int prestera_port_vlans_add(struct prestera_port *port,static int prestera_port_obj_add (struct net_device *dev,const struct switchdev_obj *obj, -struct switchdev_trans *trans,struct netlink_ext_ack *extack) {struct prestera_port *port =netdev_priv (dev);
@@ -1061,7 +1056,7 @@ static int prestera_port_obj_add(struct net_device *dev,switch (obj->id) {case SWITCHDEV_OBJ_ID_PORT_VLAN : vlan =SWITCHDEV_OBJ_PORT_VLAN (obj); -return prestera_port_vlans_add (port, vlan, trans, extack); +return prestera_port_vlans_add (port, vlan, extack);default :return -EOPNOTSUPP ; }
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +31 -20
105 lines not on this page · raw message
drivers/net/ethernet/mscc/ocelot_net.c +8 -17
@@ -890,33 +890,27 @@ static int ocelot_port_attr_set(struct net_device *dev, }static int ocelot_port_obj_add_vlan (struct net_device *dev, -const struct switchdev_obj_port_vlan *vlan, -struct switchdev_trans *trans) +const struct switchdev_obj_port_vlan *vlan) {bool untagged = vlan->flags &BRIDGE_VLAN_INFO_UNTAGGED ;bool pvid = vlan->flags &BRIDGE_VLAN_INFO_PVID ;int ret; -if (switchdev_trans_ph_prepare (trans)) - ret =ocelot_vlan_vid_prepare (dev, vlan->vid, pvid, untagged); -else - ret =ocelot_vlan_vid_add (dev, vlan->vid, pvid, untagged); + ret =ocelot_vlan_vid_prepare (dev, vlan->vid, pvid, untagged); +if (ret) +return ret; -return ret; +return ocelot_vlan_vid_add (dev, vlan->vid, pvid, untagged); }static int ocelot_port_obj_add_mdb (struct net_device *dev, -const struct switchdev_obj_port_mdb *mdb, -struct switchdev_trans *trans) +const struct switchdev_obj_port_mdb *mdb) {struct ocelot_port_private *priv =netdev_priv (dev);struct ocelot_port *ocelot_port = &priv->port;struct ocelot *ocelot = ocelot_port->ocelot;int port = priv->chip_port; -if (switchdev_trans_ph_prepare (trans)) -return 0 ; -return ocelot_port_mdb_add (ocelot, port, mdb); }
@@ -933,7 +927,6 @@ static int ocelot_port_obj_del_mdb(struct net_device *dev,static int ocelot_port_obj_add (struct net_device *dev,const struct switchdev_obj *obj, -struct switchdev_trans *trans,struct netlink_ext_ack *extack) {int ret =0 ;
@@ -941,12 +934,10 @@ static int ocelot_port_obj_add(struct net_device *dev,switch (obj->id) {case SWITCHDEV_OBJ_ID_PORT_VLAN : ret =ocelot_port_obj_add_vlan (dev, -SWITCHDEV_OBJ_PORT_VLAN (obj), - trans); +SWITCHDEV_OBJ_PORT_VLAN (obj));break ;case SWITCHDEV_OBJ_ID_PORT_MDB : - ret =ocelot_port_obj_add_mdb (dev,SWITCHDEV_OBJ_PORT_MDB (obj), - trans); + ret =ocelot_port_obj_add_mdb (dev,SWITCHDEV_OBJ_PORT_MDB (obj));break ;default :return -EOPNOTSUPP ;
drivers/net/ethernet/rocker/rocker_main.c +4 -11
@@ -1638,17 +1638,13 @@ rocker_world_port_attr_bridge_ageing_time_set(struct rocker_port *rocker_port,static int rocker_world_port_obj_vlan_add (struct rocker_port *rocker_port, -const struct switchdev_obj_port_vlan *vlan, -struct switchdev_trans *trans) +const struct switchdev_obj_port_vlan *vlan) {struct rocker_world_ops *wops = rocker_port->rocker->wops;if (!wops->port_obj_vlan_add)return -EOPNOTSUPP ; -if (switchdev_trans_ph_prepare (trans)) -return 0 ; -return wops->port_obj_vlan_add (rocker_port, vlan); }
@@ -2102,8 +2098,7 @@ static int rocker_port_attr_set(struct net_device *dev, }static int rocker_port_obj_add (struct net_device *dev, -const struct switchdev_obj *obj, -struct switchdev_trans *trans) +const struct switchdev_obj *obj) {struct rocker_port *rocker_port =netdev_priv (dev);int err =0 ;
@@ -2111,8 +2106,7 @@ static int rocker_port_obj_add(struct net_device *dev,switch (obj->id) {case SWITCHDEV_OBJ_ID_PORT_VLAN : err =rocker_world_port_obj_vlan_add (rocker_port, -SWITCHDEV_OBJ_PORT_VLAN (obj), - trans); +SWITCHDEV_OBJ_PORT_VLAN (obj));break ;default : err = -EOPNOTSUPP ;
@@ -2847,8 +2841,7 @@ rocker_switchdev_port_obj_event(unsigned long event, struct net_device *netdev,switch (event) {case SWITCHDEV_PORT_OBJ_ADD : - err =rocker_port_obj_add (netdev, port_obj_info->obj, - port_obj_info->trans); + err =rocker_port_obj_add (netdev, port_obj_info->obj);break ;case SWITCHDEV_PORT_OBJ_DEL : err =rocker_port_obj_del (netdev, port_obj_info->obj);
drivers/net/ethernet/ti/cpsw_switchdev.c +4 -13
@@ -253,8 +253,7 @@ static int cpsw_port_vlan_del(struct cpsw_priv *priv, u16 vid, }static int cpsw_port_vlans_add (struct cpsw_priv *priv, -const struct switchdev_obj_port_vlan *vlan, -struct switchdev_trans *trans) +const struct switchdev_obj_port_vlan *vlan) {bool untag = vlan->flags &BRIDGE_VLAN_INFO_UNTAGGED ;struct net_device *orig_dev = vlan->obj.orig_dev;
@@ -267,15 +266,11 @@ static int cpsw_port_vlans_add(struct cpsw_priv *priv,if (cpu_port && !(vlan->flags &BRIDGE_VLAN_INFO_BRENTRY ))return 0 ; -if (switchdev_trans_ph_prepare (trans)) -return 0 ; -return cpsw_port_vlan_add (priv, untag, pvid, vlan->vid, orig_dev); }static int cpsw_port_mdb_add (struct cpsw_priv *priv, -struct switchdev_obj_port_mdb *mdb, -struct switchdev_trans *trans) +struct switchdev_obj_port_mdb *mdb) {struct net_device *orig_dev = mdb->obj.orig_dev;
@@ -284,9 +279,6 @@ static int cpsw_port_mdb_add(struct cpsw_priv *priv,int port_mask;int err; -if (switchdev_trans_ph_prepare (trans)) -return 0 ; -if (cpu_port) port_mask =BIT (HOST_PORT_NUM );else
@@ -325,7 +317,6 @@ static int cpsw_port_mdb_del(struct cpsw_priv *priv,static int cpsw_port_obj_add (struct net_device *ndev,const struct switchdev_obj *obj, -struct switchdev_trans *trans,struct netlink_ext_ack *extack) {struct switchdev_obj_port_vlan *vlan =SWITCHDEV_OBJ_PORT_VLAN (obj);
@@ -338,11 +329,11 @@ static int cpsw_port_obj_add(struct net_device *ndev,switch (obj->id) {case SWITCHDEV_OBJ_ID_PORT_VLAN : - err =cpsw_port_vlans_add (priv, vlan, trans); + err =cpsw_port_vlans_add (priv, vlan);break ;case SWITCHDEV_OBJ_ID_PORT_MDB :case SWITCHDEV_OBJ_ID_HOST_MDB : - err =cpsw_port_mdb_add (priv, mdb, trans); + err =cpsw_port_mdb_add (priv, mdb);break ;default : err = -EOPNOTSUPP ;
drivers/staging/fsl-dpaa2/ethsw/ethsw.c +28 -31
105 lines not on this page · raw message
include/net/switchdev.h +0 -3
@@ -233,7 +233,6 @@ struct switchdev_notifier_fdb_info {struct switchdev_notifier_port_obj_info {struct switchdev_notifier_info info;/* must be first */ const struct switchdev_obj *obj; -struct switchdev_trans *trans;bool handled; };
@@ -288,7 +287,6 @@ int switchdev_handle_port_obj_add(struct net_device *dev,bool (*check_cb)(const struct net_device *dev), int (*add_cb)(struct net_device *dev,const struct switchdev_obj *obj, -struct switchdev_trans *trans, struct netlink_ext_ack *extack)); int switchdev_handle_port_obj_del(struct net_device *dev, struct switchdev_notifier_port_obj_info *port_obj_info,
@@ -372,7 +370,6 @@ switchdev_handle_port_obj_add(struct net_device *dev,bool (*check_cb)(const struct net_device *dev), int (*add_cb)(struct net_device *dev,const struct switchdev_obj *obj, -struct switchdev_trans *trans, struct netlink_ext_ack *extack)) { return 0;
net/dsa/dsa_priv.h +2 -6
@@ -52,7 +52,6 @@ struct dsa_notifier_fdb_info {/* DSA_NOTIFIER_MDB_* */ struct dsa_notifier_mdb_info {const struct switchdev_obj_port_mdb *mdb; -struct switchdev_trans *trans;int sw_index;int port; };
@@ -60,7 +59,6 @@ struct dsa_notifier_mdb_info {/* DSA_NOTIFIER_VLAN_* */ struct dsa_notifier_vlan_info {const struct switchdev_obj_port_vlan *vlan; -struct switchdev_trans *trans;int sw_index;int port; };
@@ -148,8 +146,7 @@ int dsa_port_fdb_del(struct dsa_port *dp, const unsigned char *addr, u16 vid);int dsa_port_fdb_dump (struct dsa_port *dp,dsa_fdb_dump_cb_t *cb,void *data);int dsa_port_mdb_add (const struct dsa_port *dp, -const struct switchdev_obj_port_mdb *mdb, -struct switchdev_trans *trans); +const struct switchdev_obj_port_mdb *mdb);int dsa_port_mdb_del (const struct dsa_port *dp,const struct switchdev_obj_port_mdb *mdb); int dsa_port_pre_bridge_flags(const struct dsa_port *dp, unsigned long flags,
@@ -159,8 +156,7 @@ int dsa_port_bridge_flags(const struct dsa_port *dp, unsigned long flags,int dsa_port_mrouter (struct dsa_port *dp,bool mrouter,struct switchdev_trans *trans);int dsa_port_vlan_add (struct dsa_port *dp, -const struct switchdev_obj_port_vlan *vlan, -struct switchdev_trans *trans); +const struct switchdev_obj_port_vlan *vlan);int dsa_port_vlan_del (struct dsa_port *dp,const struct switchdev_obj_port_vlan *vlan);int dsa_port_link_register_of (struct dsa_port *dp);
net/dsa/port.c +2 -6
@@ -425,13 +425,11 @@ int dsa_port_fdb_dump(struct dsa_port *dp, dsa_fdb_dump_cb_t *cb, void *data) }int dsa_port_mdb_add (const struct dsa_port *dp, -const struct switchdev_obj_port_mdb *mdb, -struct switchdev_trans *trans) +const struct switchdev_obj_port_mdb *mdb) {struct dsa_notifier_mdb_info info = { .sw_index = dp->ds->index, .port = dp->index, - .trans = trans, .mdb = mdb, };
@@ -451,13 +449,11 @@ int dsa_port_mdb_del(const struct dsa_port *dp, }int dsa_port_vlan_add (struct dsa_port *dp, -const struct switchdev_obj_port_vlan *vlan, -struct switchdev_trans *trans) +const struct switchdev_obj_port_vlan *vlan) {struct dsa_notifier_vlan_info info = { .sw_index = dp->ds->index, .port = dp->index, - .trans = trans, .vlan = vlan, };
net/dsa/slave.c +9 -25
@@ -326,8 +326,7 @@ dsa_slave_vlan_check_for_8021q_uppers(struct net_device *slave, }static int dsa_slave_vlan_add (struct net_device *dev, -const struct switchdev_obj *obj, -struct switchdev_trans *trans) +const struct switchdev_obj *obj) {struct net_device *master =dsa_slave_to_master (dev);struct dsa_port *dp =dsa_slave_to_port (dev);
@@ -345,7 +344,7 @@ static int dsa_slave_vlan_add(struct net_device *dev,/* Deny adding a bridge VLAN when there is already an 802.1Q upper with * the same VID. */ -if (trans->ph_prepare &&br_vlan_enabled (dp->bridge_dev)) { +if (br_vlan_enabled (dp->bridge_dev)) {rcu_read_lock (); err =dsa_slave_vlan_check_for_8021q_uppers (dev, &vlan);rcu_read_unlock ();
@@ -353,7 +352,7 @@ static int dsa_slave_vlan_add(struct net_device *dev,return err; } - err =dsa_port_vlan_add (dp, &vlan, trans); + err =dsa_port_vlan_add (dp, &vlan);if (err)return err;
@@ -363,7 +362,7 @@ static int dsa_slave_vlan_add(struct net_device *dev,*/ vlan.flags &= ~BRIDGE_VLAN_INFO_PVID ; - err =dsa_port_vlan_add (dp->cpu_dp, &vlan, trans); + err =dsa_port_vlan_add (dp->cpu_dp, &vlan);if (err)return err;
@@ -372,7 +371,6 @@ static int dsa_slave_vlan_add(struct net_device *dev,static int dsa_slave_port_obj_add (struct net_device *dev,const struct switchdev_obj *obj, -struct switchdev_trans *trans,struct netlink_ext_ack *extack) {struct dsa_port *dp =dsa_slave_to_port (dev);
@@ -387,17 +385,16 @@ static int dsa_slave_port_obj_add(struct net_device *dev,case SWITCHDEV_OBJ_ID_PORT_MDB :if (obj->orig_dev != dev)return -EOPNOTSUPP ; - err =dsa_port_mdb_add (dp,SWITCHDEV_OBJ_PORT_MDB (obj), trans); + err =dsa_port_mdb_add (dp,SWITCHDEV_OBJ_PORT_MDB (obj));break ;case SWITCHDEV_OBJ_ID_HOST_MDB :/* DSA can directly translate this to a normal MDB add, * but on the CPU port. */ - err =dsa_port_mdb_add (dp->cpu_dp,SWITCHDEV_OBJ_PORT_MDB (obj), - trans); + err =dsa_port_mdb_add (dp->cpu_dp,SWITCHDEV_OBJ_PORT_MDB (obj));break ;case SWITCHDEV_OBJ_ID_PORT_VLAN : - err =dsa_slave_vlan_add (dev, obj, trans); + err =dsa_slave_vlan_add (dev, obj);break ;default : err = -EOPNOTSUPP ;
@@ -1286,28 +1283,15 @@ 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;int ret;/* User port... */ - trans.ph_prepare = true; - ret =dsa_port_vlan_add (dp, &vlan, &trans); -if (ret) -return ret; - - trans.ph_prepare = false; - ret =dsa_port_vlan_add (dp, &vlan, &trans); + ret =dsa_port_vlan_add (dp, &vlan);if (ret)return ret;/* And CPU port... */ - trans.ph_prepare = true; - ret =dsa_port_vlan_add (dp->cpu_dp, &vlan, &trans); -if (ret) -return ret; - - trans.ph_prepare = false; - ret =dsa_port_vlan_add (dp->cpu_dp, &vlan, &trans); + ret =dsa_port_vlan_add (dp->cpu_dp, &vlan);if (ret)return ret;
net/dsa/switch.c +4 -32
@@ -190,8 +190,8 @@ static bool dsa_switch_mdb_match(struct dsa_switch *ds, int port,return false; } -static int dsa_switch_mdb_prepare (struct dsa_switch *ds, -struct dsa_notifier_mdb_info *info) +static int dsa_switch_mdb_add (struct dsa_switch *ds, +struct dsa_notifier_mdb_info *info) {int port, err;
@@ -206,20 +206,6 @@ static int dsa_switch_mdb_prepare(struct dsa_switch *ds, } } -return 0 ; -} - -static int dsa_switch_mdb_add (struct dsa_switch *ds, -struct dsa_notifier_mdb_info *info) -{ -int port; - -if (switchdev_trans_ph_prepare (info->trans)) -return dsa_switch_mdb_prepare (ds, info); - -if (!ds->ops->port_mdb_add) -return 0 ; -for (port =0 ; port < ds->num_ports; port++)if (dsa_switch_mdb_match (ds, port, info)) ds->ops->port_mdb_add (ds, port, info->mdb);
@@ -251,8 +237,8 @@ static bool dsa_switch_vlan_match(struct dsa_switch *ds, int port,return false; } -static int dsa_switch_vlan_prepare (struct dsa_switch *ds, -struct dsa_notifier_vlan_info *info) +static int dsa_switch_vlan_add (struct dsa_switch *ds, +struct dsa_notifier_vlan_info *info) {int port, err;
@@ -267,20 +253,6 @@ static int dsa_switch_vlan_prepare(struct dsa_switch *ds, } } -return 0 ; -} - -static int dsa_switch_vlan_add (struct dsa_switch *ds, -struct dsa_notifier_vlan_info *info) -{ -int port; - -if (switchdev_trans_ph_prepare (info->trans)) -return dsa_switch_vlan_prepare (ds, info); - -if (!ds->ops->port_vlan_add) -return 0 ; -for (port =0 ; port < ds->num_ports; port++)if (dsa_switch_vlan_match (ds, port, info)) ds->ops->port_vlan_add (ds, port, info->vlan);
net/switchdev/switchdev.c +4 -38
92 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [PATCH v3 net-next 03/11] net: switchdev: remove the transaction structure from port object notifiers
+Petr
Quoted 5 lines · Vladimir Oltean
static int mlxsw_sp_port_obj_add(struct
net_device*dev,drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +0
-1const struct switchdev_obj *obj, - struct switchdev_trans *trans, struct netlink_ext_ack *extack) {
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c mlxsw_sp_port_mrouter_update_mdb(struct mlxsw_sp_port *mlxsw_sp_port, · line 1810
Quoted 10 lines
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +2
-1struct mlxsw_sp_port *mlxsw_sp_port =netdev_priv (dev);const struct switchdev_obj_port_vlan *vlan; +struct switchdev_trans trans;int err =0 ;switch (obj->id) {case SWITCHDEV_OBJ_ID_PORT_VLAN : vlan =SWITCHDEV_OBJ_PORT_VLAN (obj); - err = mlxsw_sp_port_vlans_add(mlxsw_sp_port, vlan, trans, +
Got the regression results. The call to mlxsw_sp_span_respin() should be placed here because it needs to be triggered regardless of the return value of mlxsw_sp_port_vlans_add().
I'm looking into another failure, which might not be related to these patches. I will also have results with a debug kernel tomorrow (takes almost a day to complete). Will let you know.
Quoted 33 lines
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +15
-10+ trans.ph_prepare = true; + err =mlxsw_sp_port_vlans_add (mlxsw_sp_port, vlan, &trans, extack); +if (err) +break ; -if (switchdev_trans_ph_prepare (trans)) { -/* The event is emitted before the changes are actually -* applied to the bridge. Therefore schedule the respin -* call for later, so that the respin logic sees the -* updated bridge state. -*/ -mlxsw_sp_span_respin (mlxsw_sp_port->mlxsw_sp); - } +/* The event is emitted before the changes are actually +* applied to the bridge. Therefore schedule the respin +* call for later, so that the respin logic sees the +* updated bridge state. +*/ +mlxsw_sp_span_respin (mlxsw_sp_port->mlxsw_sp); + + trans.ph_prepare = false; + err =mlxsw_sp_port_vlans_add (mlxsw_sp_port, vlan, &trans, + extack);break ;case SWITCHDEV_OBJ_ID_PORT_MDB : err =mlxsw_sp_port_mdb_add (mlxsw_sp_port, -SWITCHDEV_OBJ_PORT_MDB (obj), - trans); +SWITCHDEV_OBJ_PORT_MDB (obj));break ;default : err = -EOPNOTSUPP ;
Re: [PATCH v3 net-next 03/11] net: switchdev: remove the transaction structure from port object notifiers
Forgot to actually add Petr
Quoted 60 lines · Ido Schimmel
+Petr
Quoted 5 lines · Vladimir Oltean
static int mlxsw_sp_port_obj_add(struct
net_device*dev,drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +0
-1const struct switchdev_obj *obj, - struct switchdev_trans *trans, struct netlink_ext_ack *extack) {drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c mlxsw_sp_port_mrouter_update_mdb(struct mlxsw_sp_port *mlxsw_sp_port, · line 1810
Quoted 10 lines
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +2
-1struct mlxsw_sp_port *mlxsw_sp_port =netdev_priv (dev);const struct switchdev_obj_port_vlan *vlan; +struct switchdev_trans trans;int err =0 ;switch (obj->id) {case SWITCHDEV_OBJ_ID_PORT_VLAN : vlan =SWITCHDEV_OBJ_PORT_VLAN (obj); - err = mlxsw_sp_port_vlans_add(mlxsw_sp_port, vlan, trans, +Got the regression results. The call to
mlxsw_sp_span_respin()should be placed here because it needs to be triggered regardless of the return value ofmlxsw_sp_port_vlans_add().I'm looking into another failure, which might not be related to these patches. I will also have results with a debug kernel tomorrow (takes almost a day to complete). Will let you know.
Quoted 33 lines
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +15
-10+ trans.ph_prepare = true; + err =mlxsw_sp_port_vlans_add (mlxsw_sp_port, vlan, &trans, extack); +if (err) +break ; -if (switchdev_trans_ph_prepare (trans)) { -/* The event is emitted before the changes are actually -* applied to the bridge. Therefore schedule the respin -* call for later, so that the respin logic sees the -* updated bridge state. -*/ -mlxsw_sp_span_respin (mlxsw_sp_port->mlxsw_sp); - } +/* The event is emitted before the changes are actually +* applied to the bridge. Therefore schedule the respin +* call for later, so that the respin logic sees the +* updated bridge state. +*/ +mlxsw_sp_span_respin (mlxsw_sp_port->mlxsw_sp); + + trans.ph_prepare = false; + err =mlxsw_sp_port_vlans_add (mlxsw_sp_port, vlan, &trans, + extack);break ;case SWITCHDEV_OBJ_ID_PORT_MDB : err =mlxsw_sp_port_mdb_add (mlxsw_sp_port, -SWITCHDEV_OBJ_PORT_MDB (obj), - trans); +SWITCHDEV_OBJ_PORT_MDB (obj));break ;default : err = -EOPNOTSUPP ;
Re: [PATCH v3 net-next 03/11] net: switchdev: remove the transaction structure from port object notifiers
Quoted 29 lines · Ido Schimmel
Forgot to actually add Petr
Quoted 26 lines · Ido Schimmel
+Petr
Quoted 5 lines · Vladimir Oltean
static int mlxsw_sp_port_obj_add(struct
net_device*dev,drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +0
-1const struct switchdev_obj *obj, - struct switchdev_trans *trans, struct netlink_ext_ack *extack) {drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c mlxsw_sp_port_mrouter_update_mdb(struct mlxsw_sp_port *mlxsw_sp_port, · line 1810
Quoted 10 lines
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +2
-1struct mlxsw_sp_port *mlxsw_sp_port =netdev_priv (dev);const struct switchdev_obj_port_vlan *vlan; +struct switchdev_trans trans;int err =0 ;switch (obj->id) {case SWITCHDEV_OBJ_ID_PORT_VLAN : vlan =SWITCHDEV_OBJ_PORT_VLAN (obj); - err = mlxsw_sp_port_vlans_add(mlxsw_sp_port, vlan, trans, +Got the regression results. The call to
mlxsw_sp_span_respin()should be placed here because it needs to be triggered regardless of the return value ofmlxsw_sp_port_vlans_add().I'm looking into another failure, which might not be related to these patches. I will also have results with a debug kernel tomorrow (takes almost a day to complete). Will let you know.
Please ignore the comment about the additional failure. Not related to these patches.
Thanks
Quoted 34 lines
Quoted 34 lines
Quoted 34 lines
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +15
-10+ trans.ph_prepare = true; + err =mlxsw_sp_port_vlans_add (mlxsw_sp_port, vlan, &trans, extack); +if (err) +break ; -if (switchdev_trans_ph_prepare (trans)) { -/* The event is emitted before the changes are actually -* applied to the bridge. Therefore schedule the respin -* call for later, so that the respin logic sees the -* updated bridge state. -*/ -mlxsw_sp_span_respin (mlxsw_sp_port->mlxsw_sp); - } +/* The event is emitted before the changes are actually +* applied to the bridge. Therefore schedule the respin +* call for later, so that the respin logic sees the +* updated bridge state. +*/ +mlxsw_sp_span_respin (mlxsw_sp_port->mlxsw_sp); + + trans.ph_prepare = false; + err =mlxsw_sp_port_vlans_add (mlxsw_sp_port, vlan, &trans, + extack);break ;case SWITCHDEV_OBJ_ID_PORT_MDB : err =mlxsw_sp_port_mdb_add (mlxsw_sp_port, -SWITCHDEV_OBJ_PORT_MDB (obj), - trans); +SWITCHDEV_OBJ_PORT_MDB (obj));break ;default : err = -EOPNOTSUPP ;
Petr Machata
maintainerRe: [PATCH v3 net-next 03/11] net: switchdev: remove the transaction structure from port object notifiers
In reply to Ido SchimmelQuoted 13 lines · Ido Schimmel
+Petr
Quoted 10 lines · Vladimir Oltean
static int mlxsw_sp_port_obj_add(struct
net_device*dev,drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +1
-1const struct switchdev_obj *obj, - struct switchdev_trans *trans, struct netlink_ext_ack *extack) { struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev);const struct switchdev_obj_port_vlan *vlan; +struct switchdev_trans trans;int err =0 ;
Quoted 9 lines
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c mlxsw_sp_port_mrouter_update_mdb(struct mlxsw_sp_port *mlxsw_sp_port, · line 1810
Quoted 5 lines
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +1
-1switch (obj->id) {case SWITCHDEV_OBJ_ID_PORT_VLAN : vlan =SWITCHDEV_OBJ_PORT_VLAN (obj); - err = mlxsw_sp_port_vlans_add(mlxsw_sp_port, vlan, trans, +Got the regression results. The call to
mlxsw_sp_span_respin()should be placed here because it needs to be triggered regardless of the return value ofmlxsw_sp_port_vlans_add().
Agreed, the new code differs in that respin is not called on error path.
Vladimir Oltean
maintainerRe: [PATCH v3 net-next 03/11] net: switchdev: remove the transaction structure from port object notifiers
In reply to Ido SchimmelQuoted 13 lines · Ido Schimmel
+Petr
Quoted 10 lines · Vladimir Oltean
static int mlxsw_sp_port_obj_add(struct
net_device*dev,drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +1
-1const struct switchdev_obj *obj, - struct switchdev_trans *trans, struct netlink_ext_ack *extack) { struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev);const struct switchdev_obj_port_vlan *vlan; +struct switchdev_trans trans;int err =0 ;
Quoted 9 lines
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c mlxsw_sp_port_mrouter_update_mdb(struct mlxsw_sp_port *mlxsw_sp_port, · line 1810
Quoted 5 lines
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +1
-1switch (obj->id) {case SWITCHDEV_OBJ_ID_PORT_VLAN : vlan =SWITCHDEV_OBJ_PORT_VLAN (obj); - err = mlxsw_sp_port_vlans_add(mlxsw_sp_port, vlan, trans, +Got the regression results. The call to
mlxsw_sp_span_respin()should be placed here because it needs to be triggered regardless of the return value ofmlxsw_sp_port_vlans_add().
So before, mlxsw_sp_span_respin() was called right in between the prepare phase and the commit phase, regardless of the error value of mlxsw_sp_port_vlans_add. How does that work, I assume that mlxsw_sp_span_respin_work gets to run after the commit phase because it serializes using rtnl_lock()? Then why did it matter enough to schedule it between the prepare and commit phase in the first place? And what is there to do in mlxsw_sp_span_respin_work when mlxsw_sp_port_vlans_add returns -EOPNOTSUPP, -EBUSY, -EINVAL, -EEXIST or -ENOMEM?
Re: [PATCH v3 net-next 03/11] net: switchdev: remove the transaction structure from port object notifiers
Quoted 24 lines · Vladimir Oltean
Quoted 13 lines · Ido Schimmel
+Petr
Quoted 10 lines · Vladimir Oltean
static int mlxsw_sp_port_obj_add(struct
net_device*dev,drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +1
-1const struct switchdev_obj *obj, - struct switchdev_trans *trans, struct netlink_ext_ack *extack) { struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev);const struct switchdev_obj_port_vlan *vlan; +struct switchdev_trans trans;int err =0 ;Quoted 9 lines
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c mlxsw_sp_port_mrouter_update_mdb(struct mlxsw_sp_port *mlxsw_sp_port, · line 1810
Quoted 5 lines
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +1
-1switch (obj->id) {case SWITCHDEV_OBJ_ID_PORT_VLAN : vlan =SWITCHDEV_OBJ_PORT_VLAN (obj); - err = mlxsw_sp_port_vlans_add(mlxsw_sp_port, vlan, trans, +Got the regression results. The call to
mlxsw_sp_span_respin()should be placed here because it needs to be triggered regardless of the return value ofmlxsw_sp_port_vlans_add().
Quoted 9 lines
So before,
mlxsw_sp_span_respin()was called right in between the prepare phase and the commit phase, regardless of the error value ofmlxsw_sp_port_vlans_add. How does that work, I assume thatmlxsw_sp_span_respin_workgets to run after the commit phase because it serializes usingrtnl_lock()? Then why did it matter enough to schedule it between the prepare and commit phase in the first place? And what is there to do inmlxsw_sp_span_respin_workwhenmlxsw_sp_port_vlans_addreturns-EOPNOTSUPP,-EBUSY,-EINVAL,-EEXISTor-ENOMEM?
The bridge driver will ignore -EOPNOTSUPP and actually add the VLAN on the bridge device. See commit 9c86ce2c1ae3 ("net: bridge: Notify about bridge VLANs") and commit ea4721751977 ("mlxsw: spectrum_switchdev:
Ignore bridge VLAN events")
Since the VLAN was successfully added on the bridge device, mlxsw_sp_span_respin_work() should be able to resolve the egress port for a packet that is mirrored to a gre tap and passes through the bridge device.
Vladimir Oltean
maintainerPATCH v3 4/11 net: switchdev: delete switchdev_port_obj_add_now
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
After the removal of the transactional model inside switchdev_port_obj_add_now, it has no added value and we can just call switchdev_port_obj_notify directly, bypassing this function. Let's delete it.
---
Changes in v3:
None.
Changes in v2:
None.
net/switchdev/switchdev.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-)
net/switchdev/switchdev.c +5 -12
@@ -242,23 +242,15 @@ static int switchdev_port_obj_notify(enum switchdev_notifier_type nt,return 0 ; } -static int switchdev_port_obj_add_now (struct net_device *dev, -const struct switchdev_obj *obj, -struct netlink_ext_ack *extack) -{ -ASSERT_RTNL (); - -return switchdev_port_obj_notify (SWITCHDEV_PORT_OBJ_ADD , - dev, obj, extack); -} -static void switchdev_port_obj_add_deferred (struct net_device *dev,const void *data) {const struct switchdev_obj *obj = data;int err; - err =switchdev_port_obj_add_now (dev, obj,NULL ); +ASSERT_RTNL (); + err =switchdev_port_obj_notify (SWITCHDEV_PORT_OBJ_ADD , + dev, obj,NULL );if (err && err != -EOPNOTSUPP )netdev_err (dev,"failed (err=%d) to add object (id=%d)\n" , err, obj->id);
@@ -290,7 +282,8 @@ int switchdev_port_obj_add(struct net_device *dev,if (obj->flags &SWITCHDEV_F_DEFER )return switchdev_port_obj_add_defer (dev, obj);ASSERT_RTNL (); -return switchdev_port_obj_add_now (dev, obj, extack); +return switchdev_port_obj_notify (SWITCHDEV_PORT_OBJ_ADD , + dev, obj, extack); }EXPORT_SYMBOL_GPL (switchdev_port_obj_add);
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH v3 5/11 net: switchdev: remove the transaction structure from port attributes
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
Since the introduction of the switchdev API, port attributes were transmitted to drivers for offloading using a two-step transactional model, with a prepare phase that was supposed to catch all errors, and a commit phase that was supposed to never fail.
Some classes of failures can never be avoided, like hardware access, or memory allocation. In the latter case, merely attempting to move the memory allocation to the preparation phase makes it impossible to avoid memory leaks, since commit 91cf8eceffc1 ("switchdev: Remove unused transaction item queue") which has removed the unused mechanism of passing on the allocated memory between one phase and another.
It is time we admit that separating the preparation from the commit phase is something that is best left for the driver to decide, and not something that should be baked into the API, especially since there are no switchdev callers that depend on this.
This patch removes the struct switchdev_trans member from switchdev port attribute notifier structures, and converts drivers to not look at this member.
In part, this patch contains a revert of my previous commit 2e554a7a5d8a ("net: dsa: propagate switchdev vlan_filtering prepare phase to drivers").
For the most part, the conversion was trivial except for:
- Rocker's world implementation based on Broadcom OF-DPA had an odd implementation of ofdpa_port_attr_bridge_flags_set. The conversion was done mechanically, by pasting the implementation twice, then only keeping the code that would get executed during prepare phase on top, then only keeping the code that gets executed during the commit phase on bottom, then simplifying the resulting code until this was obtained.
- DSA's offloading of STP state, bridge flags, VLAN filtering and multicast router could be converted right away. But the ageing time could not, so a shim was introduced and this was left for a further commit.
---
Changes in v3:
None.
Changes in v2:
None.
drivers/net/dsa/b53/b53_common.c | 6 +- drivers/net/dsa/b53/b53_priv.h | 3 +- drivers/net/dsa/dsa_loop.c | 3 +- drivers/net/dsa/hirschmann/hellcreek.c | 6 +- drivers/net/dsa/lantiq_gswip.c | 26 +---- drivers/net/dsa/microchip/ksz8795.c | 6 +- drivers/net/dsa/microchip/ksz9477.c | 6 +- drivers/net/dsa/mt7530.c | 6 +- drivers/net/dsa/mv88e6xxx/chip.c | 7 +- drivers/net/dsa/ocelot/felix.c | 5 +- drivers/net/dsa/qca8k.c | 6 +- drivers/net/dsa/realtek-smi-core.h | 3 +- drivers/net/dsa/rtl8366.c | 11 +-- drivers/net/dsa/sja1105/sja1105.h | 3 +- drivers/net/dsa/sja1105/sja1105_devlink.c | 9 +- drivers/net/dsa/sja1105/sja1105_main.c | 17 ++-- .../marvell/prestera/prestera_switchdev.c | 37 ++----- .../mellanox/mlxsw/spectrum_switchdev.c | 63 +++--------- drivers/net/ethernet/mscc/ocelot.c | 32 ++---- drivers/net/ethernet/mscc/ocelot_net.c | 13 +-- drivers/net/ethernet/rocker/rocker.h | 6 +- drivers/net/ethernet/rocker/rocker_main.c | 46 +++------ drivers/net/ethernet/rocker/rocker_ofdpa.c | 23 ++--- drivers/net/ethernet/ti/cpsw_switchdev.c | 20 +--- drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 21 +--- include/net/dsa.h | 3 +- include/net/switchdev.h | 7 +- include/soc/mscc/ocelot.h | 3 +- net/dsa/dsa_priv.h | 18 ++-- net/dsa/port.c | 97 ++++++++----------- net/dsa/slave.c | 17 ++-- net/dsa/switch.c | 11 +-- net/switchdev/switchdev.c | 46 +-------- 33 files changed, 162 insertions(+), 424 deletions(-)
drivers/net/dsa/b53/b53_common.c +1 -5
@@ -1374,14 +1374,10 @@ void b53_phylink_mac_link_up(struct dsa_switch *ds, int port, }EXPORT_SYMBOL (b53_phylink_mac_link_up); -int b53_vlan_filtering (struct dsa_switch *ds,int port,bool vlan_filtering, -struct switchdev_trans *trans) +int b53_vlan_filtering (struct dsa_switch *ds,int port,bool vlan_filtering) {struct b53_device *dev = ds->priv; -if (switchdev_trans_ph_prepare (trans)) -return 0 ; -b53_enable_vlan (dev, dev->vlan_enabled, vlan_filtering);return 0 ;
drivers/net/dsa/b53/b53_priv.h +1 -2
@@ -347,8 +347,7 @@ void b53_phylink_mac_link_up(struct dsa_switch *ds, int port,struct phy_device *phydev, int speed, int duplex, bool tx_pause, bool rx_pause); -int b53_vlan_filtering (struct dsa_switch *ds,int port,bool vlan_filtering, -struct switchdev_trans *trans); +int b53_vlan_filtering (struct dsa_switch *ds,int port,bool vlan_filtering);int b53_vlan_prepare (struct dsa_switch *ds,int port,const struct switchdev_obj_port_vlan *vlan); void b53_vlan_add(struct dsa_switch *ds, int port,
drivers/net/dsa/dsa_loop.c +1 -2
@@ -190,8 +190,7 @@ static void dsa_loop_port_stp_state_set(struct dsa_switch *ds, int port, }static int dsa_loop_port_vlan_filtering (struct dsa_switch *ds,int port, -bool vlan_filtering, -struct switchdev_trans *trans) +bool vlan_filtering) {dev_dbg (ds->dev,"%s: port: %d, vlan_filtering: %d\n" , __func__, port, vlan_filtering);
drivers/net/dsa/hirschmann/hellcreek.c +1 -5
@@ -859,14 +859,10 @@ static int hellcreek_fdb_dump(struct dsa_switch *ds, int port, }static int hellcreek_vlan_filtering (struct dsa_switch *ds,int port, -bool vlan_filtering, -struct switchdev_trans *trans) +bool vlan_filtering) {struct hellcreek *hellcreek = ds->priv; -if (switchdev_trans_ph_prepare (trans)) -return 0 ; -dev_dbg (hellcreek->dev,"%s VLAN filtering on port %d\n" , vlan_filtering ?"Enable" :"Disable" , port);
drivers/net/dsa/lantiq_gswip.c +5 -21
@@ -727,23 +727,14 @@ static int gswip_pce_load_microcode(struct gswip_priv *priv) }static int gswip_port_vlan_filtering (struct dsa_switch *ds,int port, -bool vlan_filtering, -struct switchdev_trans *trans) +bool vlan_filtering) { +struct net_device *bridge =dsa_to_port (ds, port)->bridge_dev;struct gswip_priv *priv = ds->priv;/* Do not allow changing the VLAN filtering options while in bridge */ -if (switchdev_trans_ph_prepare (trans)) { -struct net_device *bridge =dsa_to_port (ds, port)->bridge_dev; - -if (!bridge) -return 0 ; - -if (!!(priv->port_vlan_filter &BIT (port)) != vlan_filtering) -return -EIO ; - -return 0 ; - } +if (bridge && !!(priv->port_vlan_filter &BIT (port)) != vlan_filtering) +return -EIO ;if (vlan_filtering) {/* Use port based VLAN tag */
@@ -781,15 +772,8 @@ static int gswip_setup(struct dsa_switch *ds)/* disable port fetch/store dma on all ports */ for (i =0 ; i < priv->hw_info->max_ports; i++) { -struct switchdev_trans trans; - -/* Skip the prepare phase, this shouldn't return an error -* during setup. -*/ - trans.ph_prepare = false; -gswip_port_disable (ds, i); -gswip_port_vlan_filtering (ds, i, false, &trans); +gswip_port_vlan_filtering (ds, i, false); }/* enable Switch */
drivers/net/dsa/microchip/ksz8795.c +1 -5
@@ -783,14 +783,10 @@ static void ksz8795_flush_dyn_mac_table(struct ksz_device *dev, int port) }static int ksz8795_port_vlan_filtering (struct dsa_switch *ds,int port, -bool flag, -struct switchdev_trans *trans) +bool flag) {struct ksz_device *dev = ds->priv; -if (switchdev_trans_ph_prepare (trans)) -return 0 ; -ksz_cfg (dev,S_MIRROR_CTRL ,SW_VLAN_ENABLE , flag);return 0 ;
drivers/net/dsa/microchip/ksz9477.c +1 -5
@@ -493,14 +493,10 @@ static void ksz9477_flush_dyn_mac_table(struct ksz_device *dev, int port) }static int ksz9477_port_vlan_filtering (struct dsa_switch *ds,int port, -bool flag, -struct switchdev_trans *trans) +bool flag) {struct ksz_device *dev = ds->priv; -if (switchdev_trans_ph_prepare (trans)) -return 0 ; -if (flag) {ksz_port_cfg (dev, port,REG_PORT_LUE_CTRL ,PORT_VLAN_LOOKUP_VID_0 , true);
drivers/net/dsa/mt7530.c +1 -5
@@ -1376,12 +1376,8 @@ mt7530_vlan_cmd(struct mt7530_priv *priv, enum mt7530_vlan_cmd cmd, u16 vid)static int mt7530_port_vlan_filtering (struct dsa_switch *ds,int port, -bool vlan_filtering, -struct switchdev_trans *trans) +bool vlan_filtering) { -if (switchdev_trans_ph_prepare (trans)) -return 0 ; -if (vlan_filtering) {/* The port is being kept as VLAN-unaware port when bridge is * set up with vlan_filtering not being set, Otherwise, the
drivers/net/dsa/mv88e6xxx/chip.c +3 -4
@@ -1583,16 +1583,15 @@ static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port, }static int mv88e6xxx_port_vlan_filtering (struct dsa_switch *ds,int port, -bool vlan_filtering, -struct switchdev_trans *trans) +bool vlan_filtering) {struct mv88e6xxx_chip *chip = ds->priv;u16 mode = vlan_filtering ?MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE :MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED ;int err; -if (switchdev_trans_ph_prepare (trans)) -return mv88e6xxx_max_vid (chip) ?0 : -EOPNOTSUPP ; +if (!mv88e6xxx_max_vid (chip)) +return -EOPNOTSUPP ;mv88e6xxx_reg_lock (chip); err =mv88e6xxx_port_set_8021q_mode (chip, port, mode);
drivers/net/dsa/ocelot/felix.c +2 -3
@@ -134,12 +134,11 @@ static int felix_vlan_prepare(struct dsa_switch *ds, int port, flags & BRIDGE_VLAN_INFO_UNTAGGED); } -static int felix_vlan_filtering (struct dsa_switch *ds,int port,bool enabled, -struct switchdev_trans *trans) +static int felix_vlan_filtering (struct dsa_switch *ds,int port,bool enabled) {struct ocelot *ocelot = ds->priv; -return ocelot_port_vlan_filtering (ocelot, port, enabled, trans); +return ocelot_port_vlan_filtering (ocelot, port, enabled); } static void felix_vlan_add(struct dsa_switch *ds, int port,
drivers/net/dsa/qca8k.c +1 -5
@@ -1294,14 +1294,10 @@ qca8k_port_fdb_dump(struct dsa_switch *ds, int port, }static int -qca8k_port_vlan_filtering (struct dsa_switch *ds,int port,bool vlan_filtering, -struct switchdev_trans *trans) +qca8k_port_vlan_filtering (struct dsa_switch *ds,int port,bool vlan_filtering) {struct qca8k_priv *priv = ds->priv; -if (switchdev_trans_ph_prepare (trans)) -return 0 ; -if (vlan_filtering) { qca8k_rmw(priv, QCA8K_PORT_LOOKUP_CTRL(port), QCA8K_PORT_LOOKUP_VLAN_MODE,
drivers/net/dsa/realtek-smi-core.h +1 -2
@@ -131,8 +131,7 @@ int rtl8366_enable_vlan(struct realtek_smi *smi, bool enable);int rtl8366_reset_vlan (struct realtek_smi *smi);int rtl8366_init_vlan (struct realtek_smi *smi);int rtl8366_vlan_filtering (struct dsa_switch *ds,int port, -bool vlan_filtering, -struct switchdev_trans *trans); +bool vlan_filtering);int rtl8366_vlan_prepare (struct dsa_switch *ds,int port,const struct switchdev_obj_port_vlan *vlan); void rtl8366_vlan_add(struct dsa_switch *ds, int port,
drivers/net/dsa/rtl8366.c +3 -8
@@ -340,20 +340,15 @@ int rtl8366_init_vlan(struct realtek_smi *smi) }EXPORT_SYMBOL_GPL (rtl8366_init_vlan); -int rtl8366_vlan_filtering (struct dsa_switch *ds,int port,bool vlan_filtering, -struct switchdev_trans *trans) +int rtl8366_vlan_filtering (struct dsa_switch *ds,int port,bool vlan_filtering) {struct realtek_smi *smi = ds->priv;struct rtl8366_vlan_4k vlan4k;int ret;/* Use VLAN nr port + 1 since VLAN0 is not valid */ -if (switchdev_trans_ph_prepare (trans)) { -if (!smi->ops->is_vlan_valid (smi, port +1 )) -return -EINVAL ; - -return 0 ; - } +if (!smi->ops->is_vlan_valid (smi, port +1 )) +return -EINVAL ; dev_info(smi->dev, "%s filtering on port %d\n", vlan_filtering ? "enable" : "disable",
drivers/net/dsa/sja1105/sja1105.h +1 -2
@@ -245,8 +245,7 @@ enum sja1105_reset_reason {int sja1105_static_config_reload (struct sja1105_private *priv,enum sja1105_reset_reason reason); -int sja1105_vlan_filtering (struct dsa_switch *ds,int port,bool enabled, -struct switchdev_trans *trans); +int sja1105_vlan_filtering (struct dsa_switch *ds,int port,bool enabled);void sja1105_frame_memory_partitioning (struct sja1105_private *priv);/* From sja1105_devlink.c */
drivers/net/dsa/sja1105/sja1105_devlink.c +1 -8
@@ -135,7 +135,6 @@ static int sja1105_best_effort_vlan_filtering_set(struct sja1105_private *priv,rtnl_lock ();for (port =0 ; port < ds->num_ports; port++) { -struct switchdev_trans trans;struct dsa_port *dp;if (!dsa_is_user_port (ds, port))
@@ -144,13 +143,7 @@ static int sja1105_best_effort_vlan_filtering_set(struct sja1105_private *priv, dp =dsa_to_port (ds, port); vlan_filtering =dsa_port_is_vlan_filtering (dp); - trans.ph_prepare = true; - rc =sja1105_vlan_filtering (ds, port, vlan_filtering, &trans); -if (rc) -break ; - - trans.ph_prepare = false; - rc =sja1105_vlan_filtering (ds, port, vlan_filtering, &trans); + rc =sja1105_vlan_filtering (ds, port, vlan_filtering);if (rc)break ; }
drivers/net/dsa/sja1105/sja1105_main.c +6 -11
@@ -2631,8 +2631,7 @@ static int sja1105_vlan_prepare(struct dsa_switch *ds, int port,* which can only be partially reconfigured at runtime (and not the TPID). * So a switch reset is required. */ -int sja1105_vlan_filtering (struct dsa_switch *ds,int port,bool enabled, -struct switchdev_trans *trans) +int sja1105_vlan_filtering (struct dsa_switch *ds,int port,bool enabled) {struct sja1105_l2_lookup_params_entry *l2_lookup_params;struct sja1105_general_params_entry *general_params;
@@ -2644,16 +2643,12 @@ int sja1105_vlan_filtering(struct dsa_switch *ds, int port, bool enabled,u16 tpid, tpid2;int rc; -if (switchdev_trans_ph_prepare (trans)) { -list_for_each_entry (rule, &priv->flow_block.rules, list) { -if (rule->type ==SJA1105_RULE_VL ) { -dev_err (ds->dev, -"Cannot change VLAN filtering with active VL rules\n" ); -return -EBUSY ; - } +list_for_each_entry (rule, &priv->flow_block.rules, list) { +if (rule->type ==SJA1105_RULE_VL ) { +dev_err (ds->dev, +"Cannot change VLAN filtering with active VL rules\n" ); +return -EBUSY ; } - -return 0 ; }if (enabled) {
drivers/net/ethernet/marvell/prestera/prestera_switchdev.c +8 -29
@@ -580,16 +580,12 @@ int prestera_bridge_port_event(struct net_device *dev, unsigned long event, }static int prestera_port_attr_br_flags_set (struct prestera_port *port, -struct switchdev_trans *trans,struct net_device *dev,unsigned long flags) {struct prestera_bridge_port *br_port;int err; -if (switchdev_trans_ph_prepare (trans)) -return 0 ; - br_port =prestera_bridge_port_by_dev (port->sw->swdev, dev);if (!br_port)return 0 ;
@@ -608,35 +604,26 @@ static int prestera_port_attr_br_flags_set(struct prestera_port *port, }static int prestera_port_attr_br_ageing_set (struct prestera_port *port, -struct switchdev_trans *trans,unsigned long ageing_clock_t) {unsigned long ageing_jiffies =clock_t_to_jiffies (ageing_clock_t);u32 ageing_time_ms =jiffies_to_msecs (ageing_jiffies);struct prestera_switch *sw = port->sw; -if (switchdev_trans_ph_prepare (trans)) { -if (ageing_time_ms <PRESTERA_MIN_AGEING_TIME_MS || - ageing_time_ms >PRESTERA_MAX_AGEING_TIME_MS ) -return -ERANGE ; -else -return 0 ; - } +if (ageing_time_ms <PRESTERA_MIN_AGEING_TIME_MS || + ageing_time_ms >PRESTERA_MAX_AGEING_TIME_MS ) +return -ERANGE ;return prestera_hw_switch_ageing_set (sw, ageing_time_ms); }static int prestera_port_attr_br_vlan_set (struct prestera_port *port, -struct switchdev_trans *trans,struct net_device *dev,bool vlan_enabled) {struct prestera_switch *sw = port->sw;struct prestera_bridge *bridge; -if (!switchdev_trans_ph_prepare (trans)) -return 0 ; - bridge =prestera_bridge_by_dev (sw->swdev, dev);if (WARN_ON (!bridge))return -EINVAL ;
@@ -666,7 +653,6 @@ static int prestera_port_bridge_vlan_stp_set(struct prestera_port *port, }static int presterar_port_attr_stp_state_set (struct prestera_port *port, -struct switchdev_trans *trans,struct net_device *dev,u8 state) {
@@ -675,9 +661,6 @@ static int presterar_port_attr_stp_state_set(struct prestera_port *port,int err;u16 vid; -if (switchdev_trans_ph_prepare (trans)) -return 0 ; - br_port =prestera_bridge_port_by_dev (port->sw->swdev, dev);if (!br_port)return 0 ;
@@ -712,16 +695,14 @@ static int presterar_port_attr_stp_state_set(struct prestera_port *port, }static int prestera_port_obj_attr_set (struct net_device *dev, -const struct switchdev_attr *attr, -struct switchdev_trans *trans) +const struct switchdev_attr *attr) {struct prestera_port *port =netdev_priv (dev);int err =0 ;switch (attr->id) {case SWITCHDEV_ATTR_ID_PORT_STP_STATE : - err =presterar_port_attr_stp_state_set (port, trans, - attr->orig_dev, + err =presterar_port_attr_stp_state_set (port, attr->orig_dev, attr->u.stp_state);break ;case SWITCHDEV_ATTR_ID_PORT_PRE_BRIDGE_FLAGS :
@@ -730,17 +711,15 @@ static int prestera_port_obj_attr_set(struct net_device *dev, err = -EINVAL ;break ;case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS : - err =prestera_port_attr_br_flags_set (port, trans, - attr->orig_dev, + err =prestera_port_attr_br_flags_set (port, attr->orig_dev, attr->u.brport_flags);break ;case SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME : - err =prestera_port_attr_br_ageing_set (port, trans, + err =prestera_port_attr_br_ageing_set (port, attr->u.ageing_time);break ;case SWITCHDEV_ATTR_ID_BRIDGE_VLAN_FILTERING : - err =prestera_port_attr_br_vlan_set (port, trans, - attr->orig_dev, + err =prestera_port_attr_br_vlan_set (port, attr->orig_dev, attr->u.vlan_filtering);break ;default :
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +13 -50
213 lines not on this page · raw message
drivers/net/ethernet/mscc/ocelot.c +10 -22
@@ -208,25 +208,20 @@ static void ocelot_port_set_pvid(struct ocelot *ocelot, int port, }int ocelot_port_vlan_filtering (struct ocelot *ocelot,int port, -bool vlan_aware,struct switchdev_trans *trans) +bool vlan_aware) { +struct ocelot_vcap_block *block = &ocelot->block[VCAP_IS1 ];struct ocelot_port *ocelot_port = ocelot->ports[port]; +struct ocelot_vcap_filter *filter;u32 val; -if (switchdev_trans_ph_prepare (trans)) { -struct ocelot_vcap_block *block = &ocelot->block[VCAP_IS1 ]; -struct ocelot_vcap_filter *filter; - -list_for_each_entry (filter, &block->rules, list) { -if (filter->ingress_port_mask &BIT (port) && - filter->action.vid_replace_ena) { -dev_err (ocelot->dev, -"Cannot change VLAN state with vlan modify rules active\n" ); -return -EBUSY ; - } +list_for_each_entry (filter, &block->rules, list) { +if (filter->ingress_port_mask &BIT (port) && + filter->action.vid_replace_ena) { +dev_err (ocelot->dev, +"Cannot change VLAN state with vlan modify rules active\n" ); +return -EBUSY ; } - -return 0 ; } ocelot_port->vlan_aware = vlan_aware;
@@ -1179,7 +1174,6 @@ int ocelot_port_bridge_leave(struct ocelot *ocelot, int port, struct net_device *bridge) {struct ocelot_vlan pvid = {0 }, native_vlan = {0 }; -struct switchdev_trans trans;int ret; ocelot->bridge_mask &= ~BIT (port);
@@ -1187,13 +1181,7 @@ int ocelot_port_bridge_leave(struct ocelot *ocelot, int port,if (!ocelot->bridge_mask) ocelot->hw_bridge_dev =NULL ; - trans.ph_prepare = true; - ret =ocelot_port_vlan_filtering (ocelot, port, false, &trans); -if (ret) -return ret; - - trans.ph_prepare = false; - ret =ocelot_port_vlan_filtering (ocelot, port, false, &trans); + ret =ocelot_port_vlan_filtering (ocelot, port, false);if (ret)return ret;
drivers/net/ethernet/mscc/ocelot_net.c +3 -10
@@ -825,12 +825,8 @@ static const struct ethtool_ops ocelot_ethtool_ops = { };static void ocelot_port_attr_stp_state_set (struct ocelot *ocelot,int port, -struct switchdev_trans *trans,u8 state) { -if (switchdev_trans_ph_prepare (trans)) -return ; -ocelot_bridge_stp_state_set (ocelot, port, state); }
@@ -858,8 +854,7 @@ static void ocelot_port_attr_mc_set(struct ocelot *ocelot, int port, bool mc) }static int ocelot_port_attr_set (struct net_device *dev, -const struct switchdev_attr *attr, -struct switchdev_trans *trans) +const struct switchdev_attr *attr) {struct ocelot_port_private *priv =netdev_priv (dev);struct ocelot *ocelot = priv->port.ocelot;
@@ -868,15 +863,13 @@ static int ocelot_port_attr_set(struct net_device *dev,switch (attr->id) {case SWITCHDEV_ATTR_ID_PORT_STP_STATE : -ocelot_port_attr_stp_state_set (ocelot, port, trans, - attr->u.stp_state); +ocelot_port_attr_stp_state_set (ocelot, port, attr->u.stp_state);break ;case SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME :ocelot_port_attr_ageing_set (ocelot, port, attr->u.ageing_time);break ;case SWITCHDEV_ATTR_ID_BRIDGE_VLAN_FILTERING : -ocelot_port_vlan_filtering (ocelot, port, - attr->u.vlan_filtering, trans); +ocelot_port_vlan_filtering (ocelot, port, attr->u.vlan_filtering);break ;case SWITCHDEV_ATTR_ID_BRIDGE_MC_DISABLED :ocelot_port_attr_mc_set (ocelot, port, !attr->u.mc_disabled);
drivers/net/ethernet/rocker/rocker.h +2 -4
@@ -103,15 +103,13 @@ struct rocker_world_ops {int (*port_attr_stp_state_set)(struct rocker_port *rocker_port,u8 state);int (*port_attr_bridge_flags_set)(struct rocker_port *rocker_port, -unsigned long brport_flags, -struct switchdev_trans *trans); +unsigned long brport_flags);int (*port_attr_bridge_flags_support_get)(const struct rocker_port * rocker_port,unsigned long * p_brport_flags);int (*port_attr_bridge_ageing_time_set)(struct rocker_port *rocker_port, -u32 ageing_time, -struct switchdev_trans *trans); +u32 ageing_time);int (*port_obj_vlan_add)(struct rocker_port *rocker_port,const struct switchdev_obj_port_vlan *vlan); int (*port_obj_vlan_del)(struct rocker_port *rocker_port,
drivers/net/ethernet/rocker/rocker_main.c +12 -34
113 lines not on this page · raw message
drivers/net/ethernet/rocker/rocker_ofdpa.c +8 -15
@@ -2488,8 +2488,7 @@ static int ofdpa_port_attr_stp_state_set(struct rocker_port *rocker_port, }static int ofdpa_port_attr_bridge_flags_set (struct rocker_port *rocker_port, -unsigned long brport_flags, -struct switchdev_trans *trans) +unsigned long brport_flags) {struct ofdpa_port *ofdpa_port = rocker_port->wpriv;unsigned long orig_flags;
@@ -2497,14 +2496,11 @@ static int ofdpa_port_attr_bridge_flags_set(struct rocker_port *rocker_port, orig_flags = ofdpa_port->brport_flags; ofdpa_port->brport_flags = brport_flags; -if ((orig_flags ^ ofdpa_port->brport_flags) &BR_LEARNING && - !switchdev_trans_ph_prepare (trans)) + +if ((orig_flags ^ ofdpa_port->brport_flags) &BR_LEARNING ) err =rocker_port_set_learning (ofdpa_port->rocker_port, !!(ofdpa_port->brport_flags &BR_LEARNING )); -if (switchdev_trans_ph_prepare (trans)) - ofdpa_port->brport_flags = orig_flags; -return err; }
@@ -2520,18 +2516,15 @@ ofdpa_port_attr_bridge_flags_support_get(const struct rocker_port *static int ofdpa_port_attr_bridge_ageing_time_set (struct rocker_port *rocker_port, -u32 ageing_time, -struct switchdev_trans *trans) +u32 ageing_time) {struct ofdpa_port *ofdpa_port = rocker_port->wpriv;struct ofdpa *ofdpa = ofdpa_port->ofdpa; -if (!switchdev_trans_ph_prepare (trans)) { - ofdpa_port->ageing_time =clock_t_to_jiffies (ageing_time); -if (ofdpa_port->ageing_time < ofdpa->ageing_time) - ofdpa->ageing_time = ofdpa_port->ageing_time; -mod_timer (&ofdpa_port->ofdpa->fdb_cleanup_timer, jiffies); - } + ofdpa_port->ageing_time =clock_t_to_jiffies (ageing_time); +if (ofdpa_port->ageing_time < ofdpa->ageing_time) + ofdpa->ageing_time = ofdpa_port->ageing_time; +mod_timer (&ofdpa_port->ofdpa->fdb_cleanup_timer, jiffies);return 0 ; }
drivers/net/ethernet/ti/cpsw_switchdev.c +5 -15
@@ -24,16 +24,12 @@ struct cpsw_switchdev_event_work {unsigned long event; }; -static int cpsw_port_stp_state_set (struct cpsw_priv *priv, -struct switchdev_trans *trans,u8 state) +static int cpsw_port_stp_state_set (struct cpsw_priv *priv,u8 state) {struct cpsw_common *cpsw = priv->cpsw;u8 cpsw_state;int ret =0 ; -if (switchdev_trans_ph_prepare (trans)) -return 0 ; -switch (state) {case BR_STATE_FORWARDING : cpsw_state =ALE_PORT_STATE_FORWARD ;
@@ -60,16 +56,12 @@ static int cpsw_port_stp_state_set(struct cpsw_priv *priv, }static int cpsw_port_attr_br_flags_set (struct cpsw_priv *priv, -struct switchdev_trans *trans,struct net_device *orig_dev,unsigned long brport_flags) {struct cpsw_common *cpsw = priv->cpsw;bool unreg_mcast_add = false; -if (switchdev_trans_ph_prepare (trans)) -return 0 ; -if (brport_flags &BR_MCAST_FLOOD ) unreg_mcast_add = true; dev_dbg(priv->dev, "BR_MCAST_FLOOD: %d port %u\n",
@@ -82,7 +74,6 @@ static int cpsw_port_attr_br_flags_set(struct cpsw_priv *priv, }static int cpsw_port_attr_br_flags_pre_set (struct net_device *netdev, -struct switchdev_trans *trans,unsigned long flags) {if (flags & ~(BR_LEARNING |BR_MCAST_FLOOD ))
@@ -92,8 +83,7 @@ static int cpsw_port_attr_br_flags_pre_set(struct net_device *netdev, }static int cpsw_port_attr_set (struct net_device *ndev, -const struct switchdev_attr *attr, -struct switchdev_trans *trans) +const struct switchdev_attr *attr) {struct cpsw_priv *priv =netdev_priv (ndev);int ret;
@@ -102,15 +92,15 @@ static int cpsw_port_attr_set(struct net_device *ndev,switch (attr->id) {case SWITCHDEV_ATTR_ID_PORT_PRE_BRIDGE_FLAGS : - ret =cpsw_port_attr_br_flags_pre_set (ndev, trans, + ret =cpsw_port_attr_br_flags_pre_set (ndev, attr->u.brport_flags);break ;case SWITCHDEV_ATTR_ID_PORT_STP_STATE : - ret =cpsw_port_stp_state_set (priv, trans, attr->u.stp_state); + ret =cpsw_port_stp_state_set (priv, attr->u.stp_state);dev_dbg (priv->dev,"stp state: %u\n" , attr->u.stp_state);break ;case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS : - ret =cpsw_port_attr_br_flags_set (priv, trans, attr->orig_dev, + ret =cpsw_port_attr_br_flags_set (priv, attr->orig_dev, attr->u.brport_flags);break ;default :
drivers/staging/fsl-dpaa2/ethsw/ethsw.c +5 -16
@@ -901,19 +901,14 @@ static void dpaa2_switch_teardown_irqs(struct fsl_mc_device *sw_dev) }static int dpaa2_switch_port_attr_stp_state_set (struct net_device *netdev, -struct switchdev_trans *trans,u8 state) {struct ethsw_port_priv *port_priv =netdev_priv (netdev); -if (switchdev_trans_ph_prepare (trans)) -return 0 ; -return dpaa2_switch_port_set_stp_state (port_priv, state); }static int dpaa2_switch_port_attr_br_flags_pre_set (struct net_device *netdev, -struct switchdev_trans *trans,unsigned long flags) {if (flags & ~(BR_LEARNING |BR_FLOOD ))
@@ -923,15 +918,11 @@ static int dpaa2_switch_port_attr_br_flags_pre_set(struct net_device *netdev, }static int dpaa2_switch_port_attr_br_flags_set (struct net_device *netdev, -struct switchdev_trans *trans,unsigned long flags) {struct ethsw_port_priv *port_priv =netdev_priv (netdev);int err =0 ; -if (switchdev_trans_ph_prepare (trans)) -return 0 ; -/* Learning is enabled per switch */ err =dpaa2_switch_set_learning (port_priv->ethsw_data, !!(flags &BR_LEARNING ));
@@ -945,22 +936,21 @@ static int dpaa2_switch_port_attr_br_flags_set(struct net_device *netdev, }static int dpaa2_switch_port_attr_set (struct net_device *netdev, -const struct switchdev_attr *attr, -struct switchdev_trans *trans) +const struct switchdev_attr *attr) {int err =0 ;switch (attr->id) {case SWITCHDEV_ATTR_ID_PORT_STP_STATE : - err =dpaa2_switch_port_attr_stp_state_set (netdev, trans, + err =dpaa2_switch_port_attr_stp_state_set (netdev, attr->u.stp_state);break ;case SWITCHDEV_ATTR_ID_PORT_PRE_BRIDGE_FLAGS : - err =dpaa2_switch_port_attr_br_flags_pre_set (netdev, trans, + err =dpaa2_switch_port_attr_br_flags_pre_set (netdev, attr->u.brport_flags);break ;case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS : - err =dpaa2_switch_port_attr_br_flags_set (netdev, trans, + err =dpaa2_switch_port_attr_br_flags_set (netdev, attr->u.brport_flags);break ;case SWITCHDEV_ATTR_ID_BRIDGE_VLAN_FILTERING :
@@ -1197,8 +1187,7 @@ static int dpaa2_switch_port_attr_set_event(struct net_device *netdev, {int err; - err =dpaa2_switch_port_attr_set (netdev, port_attr_info->attr, - port_attr_info->trans); + err =dpaa2_switch_port_attr_set (netdev, port_attr_info->attr); port_attr_info->handled = true;return notifier_from_errno (err);
include/net/dsa.h +1 -2
@@ -560,8 +560,7 @@ struct dsa_switch_ops {* VLAN support */ int (*port_vlan_filtering)(struct dsa_switch *ds,int port, -bool vlan_filtering, -struct switchdev_trans *trans); +bool vlan_filtering);int (*port_vlan_prepare)(struct dsa_switch *ds,int port,const struct switchdev_obj_port_vlan *vlan); void (*port_vlan_add)(struct dsa_switch *ds, int port,
include/net/switchdev.h +2 -5
@@ -239,7 +239,6 @@ struct switchdev_notifier_port_obj_info {struct switchdev_notifier_port_attr_info {struct switchdev_notifier_info info;/* must be first */ const struct switchdev_attr *attr; -struct switchdev_trans *trans;bool handled; };
@@ -298,8 +297,7 @@ int switchdev_handle_port_attr_set(struct net_device *dev,struct switchdev_notifier_port_attr_info *port_attr_info, bool (*check_cb)(const struct net_device *dev), int (*set_cb)(struct net_device *dev, -const struct switchdev_attr *attr, - struct switchdev_trans *trans)); + const struct switchdev_attr *attr));#else static inline void switchdev_deferred_process (void )
@@ -390,8 +388,7 @@ switchdev_handle_port_attr_set(struct net_device *dev,struct switchdev_notifier_port_attr_info *port_attr_info, bool (*check_cb)(const struct net_device *dev), int (*set_cb)(struct net_device *dev, -const struct switchdev_attr *attr, - struct switchdev_trans *trans)) + const struct switchdev_attr *attr)) { return 0; }
include/soc/mscc/ocelot.h +1 -2
@@ -739,8 +739,7 @@ int ocelot_get_ts_info(struct ocelot *ocelot, int port,void ocelot_set_ageing_time (struct ocelot *ocelot,unsigned int msecs);void ocelot_adjust_link (struct ocelot *ocelot,int port,struct phy_device *phydev); -int ocelot_port_vlan_filtering (struct ocelot *ocelot,int port,bool enabled, -struct switchdev_trans *trans); +int ocelot_port_vlan_filtering (struct ocelot *ocelot,int port,bool enabled);void ocelot_bridge_stp_state_set (struct ocelot *ocelot,int port,u8 state);int ocelot_port_bridge_join (struct ocelot *ocelot,int port,struct net_device *bridge);
net/dsa/dsa_priv.h +6 -12
@@ -125,19 +125,16 @@ static inline struct net_device *dsa_master_find_slave(struct net_device *dev, }/* port.c */ -int dsa_port_set_state (struct dsa_port *dp,u8 state, -struct switchdev_trans *trans); +int dsa_port_set_state (struct dsa_port *dp,u8 state);int dsa_port_enable_rt (struct dsa_port *dp,struct phy_device *phy);int dsa_port_enable (struct dsa_port *dp,struct phy_device *phy);void dsa_port_disable_rt (struct dsa_port *dp);void dsa_port_disable (struct dsa_port *dp);int dsa_port_bridge_join (struct dsa_port *dp,struct net_device *br);void dsa_port_bridge_leave (struct dsa_port *dp,struct net_device *br); -int dsa_port_vlan_filtering (struct dsa_port *dp,bool vlan_filtering, -struct switchdev_trans *trans); +int dsa_port_vlan_filtering (struct dsa_port *dp,bool vlan_filtering);bool dsa_port_skip_vlan_configuration (struct dsa_port *dp); -int dsa_port_ageing_time (struct dsa_port *dp,clock_t ageing_clock, -struct switchdev_trans *trans); +int dsa_port_ageing_time (struct dsa_port *dp,clock_t ageing_clock);int dsa_port_mtu_change (struct dsa_port *dp,int new_mtu,bool propagate_upstream); int dsa_port_fdb_add(struct dsa_port *dp, const unsigned char *addr,
@@ -149,12 +146,9 @@ int dsa_port_mdb_add(const struct dsa_port *dp, const struct switchdev_obj_port_mdb *mdb);int dsa_port_mdb_del (const struct dsa_port *dp,const struct switchdev_obj_port_mdb *mdb); -int dsa_port_pre_bridge_flags (const struct dsa_port *dp,unsigned long flags, -struct switchdev_trans *trans); -int dsa_port_bridge_flags (const struct dsa_port *dp,unsigned long flags, -struct switchdev_trans *trans); -int dsa_port_mrouter (struct dsa_port *dp,bool mrouter, -struct switchdev_trans *trans); +int dsa_port_pre_bridge_flags (const struct dsa_port *dp,unsigned long flags); +int dsa_port_bridge_flags (const struct dsa_port *dp,unsigned long flags); +int dsa_port_mrouter (struct dsa_port *dp,bool mrouter);int dsa_port_vlan_add (struct dsa_port *dp,const struct switchdev_obj_port_vlan *vlan); int dsa_port_vlan_del(struct dsa_port *dp,
net/dsa/port.c +43 -54
187 lines not on this page · raw message
net/dsa/slave.c +7 -10
@@ -268,32 +268,29 @@ static int dsa_slave_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) }static int dsa_slave_port_attr_set (struct net_device *dev, -const struct switchdev_attr *attr, -struct switchdev_trans *trans) +const struct switchdev_attr *attr) {struct dsa_port *dp =dsa_slave_to_port (dev);int ret;switch (attr->id) {case SWITCHDEV_ATTR_ID_PORT_STP_STATE : - ret =dsa_port_set_state (dp, attr->u.stp_state, trans); + ret =dsa_port_set_state (dp, attr->u.stp_state);break ;case SWITCHDEV_ATTR_ID_BRIDGE_VLAN_FILTERING : - ret =dsa_port_vlan_filtering (dp, attr->u.vlan_filtering, - trans); + ret =dsa_port_vlan_filtering (dp, attr->u.vlan_filtering);break ;case SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME : - ret =dsa_port_ageing_time (dp, attr->u.ageing_time, trans); + ret =dsa_port_ageing_time (dp, attr->u.ageing_time);break ;case SWITCHDEV_ATTR_ID_PORT_PRE_BRIDGE_FLAGS : - ret =dsa_port_pre_bridge_flags (dp, attr->u.brport_flags, - trans); + ret =dsa_port_pre_bridge_flags (dp, attr->u.brport_flags);break ;case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS : - ret =dsa_port_bridge_flags (dp, attr->u.brport_flags, trans); + ret =dsa_port_bridge_flags (dp, attr->u.brport_flags);break ;case SWITCHDEV_ATTR_ID_BRIDGE_MROUTER : - ret =dsa_port_mrouter (dp->cpu_dp, attr->u.mrouter, trans); + ret =dsa_port_mrouter (dp->cpu_dp, attr->u.mrouter);break ;default : ret = -EOPNOTSUPP ;
net/dsa/switch.c +1 -10
@@ -139,17 +139,8 @@ static int dsa_switch_bridge_leave(struct dsa_switch *ds, } }if (unset_vlan_filtering) { -struct switchdev_trans trans; - - trans.ph_prepare = true; - err =dsa_port_vlan_filtering (dsa_to_port (ds, info->port), - false, &trans); -if (err && err !=EOPNOTSUPP ) -return err; - - trans.ph_prepare = false; err =dsa_port_vlan_filtering (dsa_to_port (ds, info->port), - false, &trans); + false);if (err && err !=EOPNOTSUPP )return err; }
net/switchdev/switchdev.c +5 -41
88 lines not on this page · raw message
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH v3 6/11 net: dsa: remove the transactional logic from ageing time notifiers
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
Remove the shim introduced in DSA for offloading the bridge ageing time from switchdev, by first checking whether the ageing time is within the range limits requested by the driver.
---
Changes in v3:
None.
Changes in v2:
None.
net/dsa/dsa_priv.h | 1 - net/dsa/port.c | 6 +----- net/dsa/switch.c | 15 ++++++--------- 3 files changed, 7 insertions(+), 15 deletions(-)
net/dsa/dsa_priv.h +0 -1
@@ -29,7 +29,6 @@ enum {/* DSA_NOTIFIER_AGEING_TIME */ struct dsa_notifier_ageing_time_info { -struct switchdev_trans *trans;unsigned int ageing_time; };
net/dsa/port.c +1 -5
@@ -310,21 +310,17 @@ int dsa_port_ageing_time(struct dsa_port *dp, clock_t ageing_clock)unsigned long ageing_jiffies =clock_t_to_jiffies (ageing_clock);unsigned int ageing_time =jiffies_to_msecs (ageing_jiffies);struct dsa_notifier_ageing_time_info info; -struct switchdev_trans trans;int err; info.ageing_time = ageing_time; - info.trans = &trans; - trans.ph_prepare = true; err =dsa_port_notify (dp,DSA_NOTIFIER_AGEING_TIME , &info);if (err)return err; dp->ageing_time = ageing_time; - trans.ph_prepare = false; -return dsa_port_notify (dp,DSA_NOTIFIER_AGEING_TIME , &info); +return 0 ; }int dsa_port_pre_bridge_flags (const struct dsa_port *dp,unsigned long flags)
net/dsa/switch.c +6 -9
@@ -33,15 +33,12 @@ static int dsa_switch_ageing_time(struct dsa_switch *ds, struct dsa_notifier_ageing_time_info *info) {unsigned int ageing_time = info->ageing_time; -struct switchdev_trans *trans = info->trans; - -if (switchdev_trans_ph_prepare (trans)) { -if (ds->ageing_time_min && ageing_time < ds->ageing_time_min) -return -ERANGE ; -if (ds->ageing_time_max && ageing_time > ds->ageing_time_max) -return -ERANGE ; -return 0 ; - } + +if (ds->ageing_time_min && ageing_time < ds->ageing_time_min) +return -ERANGE ; + +if (ds->ageing_time_max && ageing_time > ds->ageing_time_max) +return -ERANGE ;/* Program the fastest ageing time in case of multiple bridges */ ageing_time =dsa_switch_fastest_ageing_time (ds, ageing_time);
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH v3 7/11 net: dsa: remove the transactional logic from MDB entries
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
For many drivers, the .port_mdb_prepare callback was not a good opportunity to avoid any error condition, and they would suppress errors found during the actual commit phase.
Where a logical separation between the prepare and the commit phase existed, the function that used to implement the .port_mdb_prepare callback still exists, but now it is called directly from .port_mdb_add, which was modified to return an int code.
---
Changes in v3:
None.
Changes in v2:
Propagating errors better now.
drivers/net/dsa/b53/b53_common.c | 19 +++---------------- drivers/net/dsa/b53/b53_priv.h | 6 ++---- drivers/net/dsa/bcm_sf2.c | 1 - drivers/net/dsa/lan9303-core.c | 12 ++++++++---- drivers/net/dsa/microchip/ksz8795.c | 1 - drivers/net/dsa/microchip/ksz9477.c | 14 +++++++++----- drivers/net/dsa/microchip/ksz_common.c | 16 +++++----------- drivers/net/dsa/microchip/ksz_common.h | 6 ++---- drivers/net/dsa/mv88e6xxx/chip.c | 24 +++++++----------------- drivers/net/dsa/ocelot/felix.c | 14 +++----------- drivers/net/dsa/sja1105/sja1105_main.c | 14 +++----------- include/net/dsa.h | 4 +--- net/dsa/switch.c | 15 ++++++--------- 13 files changed, 49 insertions(+), 97 deletions(-)
drivers/net/dsa/b53/b53_common.c +3 -16
@@ -1741,8 +1741,8 @@ int b53_fdb_dump(struct dsa_switch *ds, int port, }EXPORT_SYMBOL (b53_fdb_dump); -int b53_mdb_prepare (struct dsa_switch *ds,int port, -const struct switchdev_obj_port_mdb *mdb) +int b53_mdb_add (struct dsa_switch *ds,int port, +const struct switchdev_obj_port_mdb *mdb) {struct b53_device *priv = ds->priv;
@@ -1752,19 +1752,7 @@ int b53_mdb_prepare(struct dsa_switch *ds, int port,if (is5325 (priv) ||is5365 (priv))return -EOPNOTSUPP ; -return 0 ; -} -EXPORT_SYMBOL (b53_mdb_prepare); - -void b53_mdb_add (struct dsa_switch *ds,int port, -const struct switchdev_obj_port_mdb *mdb) -{ -struct b53_device *priv = ds->priv; -int ret; - - ret =b53_arl_op (priv,0 , port, mdb->addr, mdb->vid, true); -if (ret) -dev_err (ds->dev,"failed to add MDB entry\n" ); +return b53_arl_op (priv,0 , port, mdb->addr, mdb->vid, true); }EXPORT_SYMBOL (b53_mdb_add);
@@ -2205,7 +2193,6 @@ static const struct dsa_switch_ops b53_switch_ops = { .port_fdb_del = b53_fdb_del, .port_mirror_add = b53_mirror_add, .port_mirror_del = b53_mirror_del, - .port_mdb_prepare = b53_mdb_prepare, .port_mdb_add = b53_mdb_add, .port_mdb_del = b53_mdb_del, .port_max_mtu = b53_get_max_mtu,
drivers/net/dsa/b53/b53_priv.h +2 -4
@@ -360,10 +360,8 @@ int b53_fdb_del(struct dsa_switch *ds, int port, const unsigned char *addr, u16 vid);int b53_fdb_dump (struct dsa_switch *ds,int port,dsa_fdb_dump_cb_t *cb,void *data); -int b53_mdb_prepare (struct dsa_switch *ds,int port, -const struct switchdev_obj_port_mdb *mdb); -void b53_mdb_add (struct dsa_switch *ds,int port, -const struct switchdev_obj_port_mdb *mdb); +int b53_mdb_add (struct dsa_switch *ds,int port, +const struct switchdev_obj_port_mdb *mdb);int b53_mdb_del (struct dsa_switch *ds,int port,const struct switchdev_obj_port_mdb *mdb); int b53_mirror_add(struct dsa_switch *ds, int port,
drivers/net/dsa/bcm_sf2.c +0 -1
@@ -1123,7 +1123,6 @@ static const struct dsa_switch_ops bcm_sf2_ops = { .set_rxnfc = bcm_sf2_set_rxnfc, .port_mirror_add = b53_mirror_add, .port_mirror_del = b53_mirror_del, - .port_mdb_prepare = b53_mdb_prepare, .port_mdb_add = b53_mdb_add, .port_mdb_del = b53_mdb_del, };
drivers/net/dsa/lan9303-core.c +8 -4
@@ -1232,14 +1232,19 @@ static int lan9303_port_mdb_prepare(struct dsa_switch *ds, int port,return 0 ; } -static void lan9303_port_mdb_add (struct dsa_switch *ds,int port, -const struct switchdev_obj_port_mdb *mdb) +static int lan9303_port_mdb_add (struct dsa_switch *ds,int port, +const struct switchdev_obj_port_mdb *mdb) {struct lan9303 *chip = ds->priv; +int err; + + err =lan9303_port_mdb_prepare (ds, port, mdb); +if (err) +return err;dev_dbg (chip->dev,"%s(%d, %pM, %d)\n" , __func__, port, mdb->addr, mdb->vid); -lan9303_alr_add_port (chip, mdb->addr, port, false); +return lan9303_alr_add_port (chip, mdb->addr, port, false); } static int lan9303_port_mdb_del(struct dsa_switch *ds, int port,
@@ -1274,7 +1279,6 @@ static const struct dsa_switch_ops lan9303_switch_ops = { .port_fdb_add = lan9303_port_fdb_add, .port_fdb_del = lan9303_port_fdb_del, .port_fdb_dump = lan9303_port_fdb_dump, - .port_mdb_prepare = lan9303_port_mdb_prepare, .port_mdb_add = lan9303_port_mdb_add, .port_mdb_del = lan9303_port_mdb_del, };
drivers/net/dsa/microchip/ksz8795.c +0 -1
@@ -1114,7 +1114,6 @@ static const struct dsa_switch_ops ksz8795_switch_ops = { .port_vlan_add = ksz8795_port_vlan_add, .port_vlan_del = ksz8795_port_vlan_del, .port_fdb_dump = ksz_port_fdb_dump, - .port_mdb_prepare = ksz_port_mdb_prepare, .port_mdb_add = ksz_port_mdb_add, .port_mdb_del = ksz_port_mdb_del, .port_mirror_add = ksz8795_port_mirror_add,
drivers/net/dsa/microchip/ksz9477.c +9 -5
@@ -774,14 +774,15 @@ static int ksz9477_port_fdb_dump(struct dsa_switch *ds, int port,return ret; } -static void ksz9477_port_mdb_add (struct dsa_switch *ds,int port, -const struct switchdev_obj_port_mdb *mdb) +static int ksz9477_port_mdb_add (struct dsa_switch *ds,int port, +const struct switchdev_obj_port_mdb *mdb) {struct ksz_device *dev = ds->priv;u32 static_table[4 ];u32 data;int index;u32 mac_hi, mac_lo; +int err =0 ; mac_hi = ((mdb->addr[0 ] <<8 ) | mdb->addr[1 ]); mac_lo = ((mdb->addr[2 ] <<24 ) | (mdb->addr[3 ] <<16 ));
@@ -796,7 +797,8 @@ static void ksz9477_port_mdb_add(struct dsa_switch *ds, int port,ksz_write32 (dev,REG_SW_ALU_STAT_CTRL__4 , data);/* wait to be finished */ -if (ksz9477_wait_alu_sta_ready (dev)) { + err =ksz9477_wait_alu_sta_ready (dev); +if (err) {dev_dbg (dev->dev,"Failed to read ALU STATIC\n" ); goto exit; }
@@ -819,8 +821,10 @@ static void ksz9477_port_mdb_add(struct dsa_switch *ds, int port, }/* no available entry */ -if (index == dev->num_statics) +if (index == dev->num_statics) { + err = -ENOSPC ; goto exit; + }/* add entry */ static_table[0 ] =ALU_V_STATIC_VALID ;
@@ -842,6 +846,7 @@ static void ksz9477_port_mdb_add(struct dsa_switch *ds, int port, exit:mutex_unlock (&dev->alu_mutex); +return err; } static int ksz9477_port_mdb_del(struct dsa_switch *ds, int port,
@@ -1395,7 +1400,6 @@ static const struct dsa_switch_ops ksz9477_switch_ops = { .port_fdb_dump = ksz9477_port_fdb_dump, .port_fdb_add = ksz9477_port_fdb_add, .port_fdb_del = ksz9477_port_fdb_del, - .port_mdb_prepare = ksz_port_mdb_prepare, .port_mdb_add = ksz9477_port_mdb_add, .port_mdb_del = ksz9477_port_mdb_del, .port_mirror_add = ksz9477_port_mirror_add,
drivers/net/dsa/microchip/ksz_common.c +5 -11
@@ -253,16 +253,8 @@ int ksz_port_fdb_dump(struct dsa_switch *ds, int port, dsa_fdb_dump_cb_t *cb, }EXPORT_SYMBOL_GPL (ksz_port_fdb_dump); -int ksz_port_mdb_prepare (struct dsa_switch *ds,int port, -const struct switchdev_obj_port_mdb *mdb) -{ -/* nothing to do */ -return 0 ; -} -EXPORT_SYMBOL_GPL (ksz_port_mdb_prepare); - -void ksz_port_mdb_add (struct dsa_switch *ds,int port, -const struct switchdev_obj_port_mdb *mdb) +int ksz_port_mdb_add (struct dsa_switch *ds,int port, +const struct switchdev_obj_port_mdb *mdb) {struct ksz_device *dev = ds->priv;struct alu_struct alu;
@@ -284,7 +276,7 @@ void ksz_port_mdb_add(struct dsa_switch *ds, int port,/* no available entry */ if (index == dev->num_statics && !empty) -return ; +return -ENOSPC ;/* add entry */ if (index == dev->num_statics) {
@@ -301,6 +293,8 @@ void ksz_port_mdb_add(struct dsa_switch *ds, int port, alu.fid = mdb->vid; } dev->dev_ops->w_sta_mac_table (dev, index, &alu); + +return 0 ; }EXPORT_SYMBOL_GPL (ksz_port_mdb_add);
drivers/net/dsa/microchip/ksz_common.h +2 -4
@@ -165,10 +165,8 @@ int ksz_port_vlan_prepare(struct dsa_switch *ds, int port, const struct switchdev_obj_port_vlan *vlan);int ksz_port_fdb_dump (struct dsa_switch *ds,int port,dsa_fdb_dump_cb_t *cb,void *data); -int ksz_port_mdb_prepare (struct dsa_switch *ds,int port, -const struct switchdev_obj_port_mdb *mdb); -void ksz_port_mdb_add (struct dsa_switch *ds,int port, -const struct switchdev_obj_port_mdb *mdb); +int ksz_port_mdb_add (struct dsa_switch *ds,int port, +const struct switchdev_obj_port_mdb *mdb);int ksz_port_mdb_del (struct dsa_switch *ds,int port,const struct switchdev_obj_port_mdb *mdb);int ksz_enable_port (struct dsa_switch *ds,int port,struct phy_device *phy);
drivers/net/dsa/mv88e6xxx/chip.c +7 -17
@@ -5238,27 +5238,18 @@ static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,return chip->info->tag_protocol; } -static int mv88e6xxx_port_mdb_prepare (struct dsa_switch *ds,int port, -const struct switchdev_obj_port_mdb *mdb) -{ -/* We don't need any dynamic resource from the kernel (yet), -* so skip the prepare phase. -*/ - -return 0 ; -} - -static void mv88e6xxx_port_mdb_add (struct dsa_switch *ds,int port, -const struct switchdev_obj_port_mdb *mdb) +static int mv88e6xxx_port_mdb_add (struct dsa_switch *ds,int port, +const struct switchdev_obj_port_mdb *mdb) {struct mv88e6xxx_chip *chip = ds->priv; +int err;mv88e6xxx_reg_lock (chip); -if (mv88e6xxx_port_db_load_purge (chip, port, mdb->addr, mdb->vid, -MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC )) -dev_err (ds->dev,"p%d: failed to load multicast MAC address\n" , - port); + err =mv88e6xxx_port_db_load_purge (chip, port, mdb->addr, mdb->vid, +MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC );mv88e6xxx_reg_unlock (chip); + +return err; } static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
@@ -5403,7 +5394,6 @@ static const struct dsa_switch_ops mv88e6xxx_switch_ops = { .port_fdb_add = mv88e6xxx_port_fdb_add, .port_fdb_del = mv88e6xxx_port_fdb_del, .port_fdb_dump = mv88e6xxx_port_fdb_dump, - .port_mdb_prepare = mv88e6xxx_port_mdb_prepare, .port_mdb_add = mv88e6xxx_port_mdb_add, .port_mdb_del = mv88e6xxx_port_mdb_del, .port_mirror_add = mv88e6xxx_port_mirror_add,
drivers/net/dsa/ocelot/felix.c +3 -11
@@ -65,19 +65,12 @@ static int felix_fdb_del(struct dsa_switch *ds, int port,return ocelot_fdb_del (ocelot, port, addr, vid); } -/* This callback needs to be present */ -static int felix_mdb_prepare (struct dsa_switch *ds,int port, -const struct switchdev_obj_port_mdb *mdb) -{ -return 0 ; -} - -static void felix_mdb_add (struct dsa_switch *ds,int port, -const struct switchdev_obj_port_mdb *mdb) +static int felix_mdb_add (struct dsa_switch *ds,int port, +const struct switchdev_obj_port_mdb *mdb) {struct ocelot *ocelot = ds->priv; -ocelot_port_mdb_add (ocelot, port, mdb); +return ocelot_port_mdb_add (ocelot, port, mdb); } static int felix_mdb_del(struct dsa_switch *ds, int port,
@@ -771,7 +764,6 @@ const struct dsa_switch_ops felix_switch_ops = { .port_fdb_dump = felix_fdb_dump, .port_fdb_add = felix_fdb_add, .port_fdb_del = felix_fdb_del, - .port_mdb_prepare = felix_mdb_prepare, .port_mdb_add = felix_mdb_add, .port_mdb_del = felix_mdb_del, .port_bridge_join = felix_bridge_join,
drivers/net/dsa/sja1105/sja1105_main.c +3 -11
@@ -1524,17 +1524,10 @@ static int sja1105_fdb_dump(struct dsa_switch *ds, int port,return 0 ; } -/* This callback needs to be present */ -static int sja1105_mdb_prepare (struct dsa_switch *ds,int port, -const struct switchdev_obj_port_mdb *mdb) -{ -return 0 ; -} - -static void sja1105_mdb_add (struct dsa_switch *ds,int port, -const struct switchdev_obj_port_mdb *mdb) +static int sja1105_mdb_add (struct dsa_switch *ds,int port, +const struct switchdev_obj_port_mdb *mdb) { -sja1105_fdb_add (ds, port, mdb->addr, mdb->vid); +return sja1105_fdb_add (ds, port, mdb->addr, mdb->vid); } static int sja1105_mdb_del(struct dsa_switch *ds, int port,
@@ -3288,7 +3281,6 @@ static const struct dsa_switch_ops sja1105_switch_ops = { .port_vlan_filtering = sja1105_vlan_filtering, .port_vlan_add = sja1105_vlan_add, .port_vlan_del = sja1105_vlan_del, - .port_mdb_prepare = sja1105_mdb_prepare, .port_mdb_add = sja1105_mdb_add, .port_mdb_del = sja1105_mdb_del, .port_hwtstamp_get = sja1105_hwtstamp_get,
include/net/dsa.h +1 -3
@@ -580,10 +580,8 @@ struct dsa_switch_ops {/* * Multicast database */ -int (*port_mdb_prepare)(struct dsa_switch *ds,int port, +int (*port_mdb_add)(struct dsa_switch *ds,int port,const struct switchdev_obj_port_mdb *mdb); -void (*port_mdb_add)(struct dsa_switch *ds,int port, -const struct switchdev_obj_port_mdb *mdb);int (*port_mdb_del)(struct dsa_switch *ds,int port,const struct switchdev_obj_port_mdb *mdb);/*
net/dsa/switch.c +6 -9
@@ -181,24 +181,21 @@ static bool dsa_switch_mdb_match(struct dsa_switch *ds, int port,static int dsa_switch_mdb_add (struct dsa_switch *ds,struct dsa_notifier_mdb_info *info) { -int port, err; +int err =0 ; +int port; -if (!ds->ops->port_mdb_prepare || !ds->ops->port_mdb_add) +if (!ds->ops->port_mdb_add)return -EOPNOTSUPP ;for (port =0 ; port < ds->num_ports; port++) {if (dsa_switch_mdb_match (ds, port, info)) { - err = ds->ops->port_mdb_prepare (ds, port, info->mdb); + err = ds->ops->port_mdb_add (ds, port, info->mdb);if (err) -return err; +break ; } } -for (port =0 ; port < ds->num_ports; port++) -if (dsa_switch_mdb_match (ds, port, info)) - ds->ops->port_mdb_add (ds, port, info->mdb); - -return 0 ; +return err; } static int dsa_switch_mdb_del(struct dsa_switch *ds,
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH v3 8/11 net: dsa: remove the transactional logic from VLAN objects
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
It should be the driver's business to logically separate its VLAN offloading into a preparation and a commit phase, and some drivers don't need / can't do this.
So remove the transactional shim from DSA and let drivers propagate errors directly from the .port_vlan_add callback.
It would appear that the code has worse error handling now than it had before. DSA is the only in-kernel user of switchdev that offloads one switchdev object to more than one port: for every VLAN object offloaded to a user port, that VLAN is also offloaded to the CPU port. So the "prepare for user port -> check for errors -> prepare for CPU port -> check for errors -> commit for user port -> commit for CPU port" sequence appears to make more sense than the one we are using now:
"offload to user port -> check for errors -> offload to CPU port -> check for errors", but it is really a compromise. In the new way, we can catch errors from the commit phase that we previously had to ignore. But we have our hands tied and cannot do any rollback now: if we add a VLAN on the CPU port and it fails, we can't do the rollback by simply deleting it from the user port, because the switchdev API is not so nice with us: it could have simply been there already, even with the same flags. So we don't even attempt to rollback anything on addition error, just leave whatever VLANs managed to get offloaded right where they are. This should not be a problem at all in practice.
---
Changes in v3:
None.
Changes in v2:
- Rebased on top of the VLAN ranges removal.
- Propagating errors better now.
drivers/net/dsa/b53/b53_common.c | 17 ++++++---- drivers/net/dsa/b53/b53_priv.h | 6 ++-- drivers/net/dsa/bcm_sf2.c | 1 - drivers/net/dsa/bcm_sf2_cfp.c | 7 ++-- drivers/net/dsa/dsa_loop.c | 28 ++++------------ drivers/net/dsa/hirschmann/hellcreek.c | 12 +++++-- drivers/net/dsa/lantiq_gswip.c | 15 ++++++--- drivers/net/dsa/microchip/ksz8795.c | 7 ++-- drivers/net/dsa/microchip/ksz9477.c | 18 +++++++---- drivers/net/dsa/microchip/ksz_common.c | 9 ------ drivers/net/dsa/microchip/ksz_common.h | 2 -- drivers/net/dsa/mt7530.c | 14 ++------ drivers/net/dsa/mv88e6xxx/chip.c | 34 ++++++++++++-------- drivers/net/dsa/ocelot/felix.c | 16 ++++++---- drivers/net/dsa/qca8k.c | 14 +++----- drivers/net/dsa/realtek-smi-core.h | 6 ++-- drivers/net/dsa/rtl8366.c | 44 +++++++++++--------------- drivers/net/dsa/rtl8366rb.c | 1 - drivers/net/dsa/sja1105/sja1105_main.c | 43 +++++++++---------------- include/net/dsa.h | 4 +-- net/dsa/switch.c | 8 ++--- 21 files changed, 133 insertions(+), 173 deletions(-)
drivers/net/dsa/b53/b53_common.c +11 -6
@@ -1384,8 +1384,8 @@ int b53_vlan_filtering(struct dsa_switch *ds, int port, bool vlan_filtering) }EXPORT_SYMBOL (b53_vlan_filtering); -int b53_vlan_prepare (struct dsa_switch *ds,int port, -const struct switchdev_obj_port_vlan *vlan) +static int b53_vlan_prepare (struct dsa_switch *ds,int port, +const struct switchdev_obj_port_vlan *vlan) {struct b53_device *dev = ds->priv;
@@ -1407,15 +1407,19 @@ int b53_vlan_prepare(struct dsa_switch *ds, int port,return 0 ; } -EXPORT_SYMBOL (b53_vlan_prepare); -void b53_vlan_add (struct dsa_switch *ds,int port, -const struct switchdev_obj_port_vlan *vlan) +int b53_vlan_add (struct dsa_switch *ds,int port, +const struct switchdev_obj_port_vlan *vlan) {struct b53_device *dev = ds->priv;bool untagged = vlan->flags &BRIDGE_VLAN_INFO_UNTAGGED ;bool pvid = vlan->flags &BRIDGE_VLAN_INFO_PVID ;struct b53_vlan *vl; +int err; + + err =b53_vlan_prepare (ds, port, vlan); +if (err) +return err; vl = &dev->vlans[vlan->vid];
@@ -1438,6 +1442,8 @@ void b53_vlan_add(struct dsa_switch *ds, int port, vlan->vid);b53_fast_age_vlan (dev, vlan->vid); } + +return 0 ; }EXPORT_SYMBOL (b53_vlan_add);
@@ -2185,7 +2191,6 @@ static const struct dsa_switch_ops b53_switch_ops = { .port_fast_age = b53_br_fast_age, .port_egress_floods = b53_br_egress_floods, .port_vlan_filtering = b53_vlan_filtering, - .port_vlan_prepare = b53_vlan_prepare, .port_vlan_add = b53_vlan_add, .port_vlan_del = b53_vlan_del, .port_fdb_dump = b53_fdb_dump,
drivers/net/dsa/b53/b53_priv.h +2 -4
@@ -348,10 +348,8 @@ void b53_phylink_mac_link_up(struct dsa_switch *ds, int port, int speed, int duplex, bool tx_pause, bool rx_pause);int b53_vlan_filtering (struct dsa_switch *ds,int port,bool vlan_filtering); -int b53_vlan_prepare (struct dsa_switch *ds,int port, -const struct switchdev_obj_port_vlan *vlan); -void b53_vlan_add (struct dsa_switch *ds,int port, -const struct switchdev_obj_port_vlan *vlan); +int b53_vlan_add (struct dsa_switch *ds,int port, +const struct switchdev_obj_port_vlan *vlan);int b53_vlan_del (struct dsa_switch *ds,int port,const struct switchdev_obj_port_vlan *vlan); int b53_fdb_add(struct dsa_switch *ds, int port,
drivers/net/dsa/bcm_sf2.c +0 -1
@@ -1113,7 +1113,6 @@ static const struct dsa_switch_ops bcm_sf2_ops = { .port_stp_state_set = b53_br_set_stp_state, .port_fast_age = b53_br_fast_age, .port_vlan_filtering = b53_vlan_filtering, - .port_vlan_prepare = b53_vlan_prepare, .port_vlan_add = b53_vlan_add, .port_vlan_del = b53_vlan_del, .port_fdb_dump = b53_fdb_dump,
drivers/net/dsa/bcm_sf2_cfp.c +2 -5
@@ -891,11 +891,9 @@ static int bcm_sf2_cfp_rule_insert(struct dsa_switch *ds, int port,else vlan.flags =0 ; - ret = ds->ops->port_vlan_prepare (ds, port_num, &vlan); + ret = ds->ops->port_vlan_add (ds, port_num, &vlan);if (ret)return ret; - - ds->ops->port_vlan_add (ds, port_num, &vlan); }/*
@@ -941,8 +939,7 @@ static int bcm_sf2_cfp_rule_set(struct dsa_switch *ds, int port,return -EINVAL ;if ((fs->flow_type &FLOW_EXT ) && - !(ds->ops->port_vlan_prepare || ds->ops->port_vlan_add || - ds->ops->port_vlan_del)) + !(ds->ops->port_vlan_add || ds->ops->port_vlan_del))return -EOPNOTSUPP ; if (fs->location != RX_CLS_LOC_ANY &&
drivers/net/dsa/dsa_loop.c +7 -21
@@ -198,26 +198,8 @@ static int dsa_loop_port_vlan_filtering(struct dsa_switch *ds, int port,return 0 ; } -static int -dsa_loop_port_vlan_prepare (struct dsa_switch *ds,int port, -const struct switchdev_obj_port_vlan *vlan) -{ -struct dsa_loop_priv *ps = ds->priv; -struct mii_bus *bus = ps->bus; - -dev_dbg (ds->dev,"%s: port: %d, vlan: %d" , __func__, port, vlan->vid); - -/* Just do a sleeping operation to make lockdep checks effective */ -mdiobus_read (bus, ps->port_base + port,MII_BMSR ); - -if (vlan->vid_end >ARRAY_SIZE (ps->vlans)) -return -ERANGE ; - -return 0 ; -} - -static void dsa_loop_port_vlan_add (struct dsa_switch *ds,int port, -const struct switchdev_obj_port_vlan *vlan) +static int dsa_loop_port_vlan_add (struct dsa_switch *ds,int port, +const struct switchdev_obj_port_vlan *vlan) {bool untagged = vlan->flags &BRIDGE_VLAN_INFO_UNTAGGED ;bool pvid = vlan->flags &BRIDGE_VLAN_INFO_PVID ;
@@ -226,6 +208,9 @@ static void dsa_loop_port_vlan_add(struct dsa_switch *ds, int port,struct dsa_loop_vlan *vl;u16 vid; +if (vlan->vid_end >ARRAY_SIZE (ps->vlans)) +return -ERANGE ; +/* Just do a sleeping operation to make lockdep checks effective */ mdiobus_read (bus, ps->port_base + port,MII_BMSR );
@@ -242,6 +227,8 @@ static void dsa_loop_port_vlan_add(struct dsa_switch *ds, int port,if (pvid) ps->ports[port].pvid = vid; + +return 0 ; } static int dsa_loop_port_vlan_del(struct dsa_switch *ds, int port,
@@ -301,7 +288,6 @@ static const struct dsa_switch_ops dsa_loop_driver = { .port_bridge_leave = dsa_loop_port_bridge_leave, .port_stp_state_set = dsa_loop_port_stp_state_set, .port_vlan_filtering = dsa_loop_port_vlan_filtering, - .port_vlan_prepare = dsa_loop_port_vlan_prepare, .port_vlan_add = dsa_loop_port_vlan_add, .port_vlan_del = dsa_loop_port_vlan_del, .port_change_mtu = dsa_loop_port_change_mtu,
drivers/net/dsa/hirschmann/hellcreek.c +9 -3
@@ -439,18 +439,25 @@ static void hellcreek_unapply_vlan(struct hellcreek *hellcreek, int port,mutex_unlock (&hellcreek->reg_lock); } -static void hellcreek_vlan_add (struct dsa_switch *ds,int port, -const struct switchdev_obj_port_vlan *vlan) +static int hellcreek_vlan_add (struct dsa_switch *ds,int port, +const struct switchdev_obj_port_vlan *vlan) {bool untagged = vlan->flags &BRIDGE_VLAN_INFO_UNTAGGED ;bool pvid = vlan->flags &BRIDGE_VLAN_INFO_PVID ;struct hellcreek *hellcreek = ds->priv; +int err; + + err =hellcreek_vlan_prepare (ds, port, vlan); +if (err) +return err;dev_dbg (hellcreek->dev,"Add VLAN %d on port %d, %s, %s\n" , vlan->vid, port, untagged ?"untagged" :"tagged" , pvid ?"PVID" :"no PVID" );hellcreek_apply_vlan (hellcreek, port, vlan->vid, pvid, untagged); + +return 0 ; } static int hellcreek_vlan_del(struct dsa_switch *ds, int port,
@@ -1147,7 +1154,6 @@ static const struct dsa_switch_ops hellcreek_ds_ops = { .port_vlan_add = hellcreek_vlan_add, .port_vlan_del = hellcreek_vlan_del, .port_vlan_filtering = hellcreek_vlan_filtering, - .port_vlan_prepare = hellcreek_vlan_prepare, .setup = hellcreek_setup, };
drivers/net/dsa/lantiq_gswip.c +10 -5
@@ -1167,13 +1167,18 @@ static int gswip_port_vlan_prepare(struct dsa_switch *ds, int port,return 0 ; } -static void gswip_port_vlan_add (struct dsa_switch *ds,int port, -const struct switchdev_obj_port_vlan *vlan) +static int gswip_port_vlan_add (struct dsa_switch *ds,int port, +const struct switchdev_obj_port_vlan *vlan) {struct gswip_priv *priv = ds->priv;struct net_device *bridge =dsa_to_port (ds, port)->bridge_dev;bool untagged = vlan->flags &BRIDGE_VLAN_INFO_UNTAGGED ;bool pvid = vlan->flags &BRIDGE_VLAN_INFO_PVID ; +int err; + + err =gswip_port_vlan_prepare (ds, port, vlan); +if (err) +return err;/* We have to receive all packets on the CPU port and should not * do any VLAN filtering here. This is also called with bridge
@@ -1181,9 +1186,10 @@ static void gswip_port_vlan_add(struct dsa_switch *ds, int port,* this. */ if (dsa_is_cpu_port (ds, port)) -return ; +return 0 ; -gswip_vlan_add_aware (priv, bridge, port, vlan->vid, untagged, pvid); +return gswip_vlan_add_aware (priv, bridge, port, vlan->vid, + untagged, pvid); } static int gswip_port_vlan_del(struct dsa_switch *ds, int port,
@@ -1579,7 +1585,6 @@ static const struct dsa_switch_ops gswip_switch_ops = { .port_bridge_leave = gswip_port_bridge_leave, .port_fast_age = gswip_port_fast_age, .port_vlan_filtering = gswip_port_vlan_filtering, - .port_vlan_prepare = gswip_port_vlan_prepare, .port_vlan_add = gswip_port_vlan_add, .port_vlan_del = gswip_port_vlan_del, .port_stp_state_set = gswip_port_stp_state_set,
drivers/net/dsa/microchip/ksz8795.c +4 -3
@@ -792,8 +792,8 @@ static int ksz8795_port_vlan_filtering(struct dsa_switch *ds, int port,return 0 ; } -static void ksz8795_port_vlan_add (struct dsa_switch *ds,int port, -const struct switchdev_obj_port_vlan *vlan) +static int ksz8795_port_vlan_add (struct dsa_switch *ds,int port, +const struct switchdev_obj_port_vlan *vlan) {bool untagged = vlan->flags &BRIDGE_VLAN_INFO_UNTAGGED ;struct ksz_device *dev = ds->priv;
@@ -828,6 +828,8 @@ static void ksz8795_port_vlan_add(struct dsa_switch *ds, int port, vid |= new_pvid;ksz_pwrite16 (dev, port,REG_PORT_CTRL_VID , vid); } + +return 0 ; } static int ksz8795_port_vlan_del(struct dsa_switch *ds, int port,
@@ -1110,7 +1112,6 @@ static const struct dsa_switch_ops ksz8795_switch_ops = { .port_stp_state_set = ksz8795_port_stp_state_set, .port_fast_age = ksz_port_fast_age, .port_vlan_filtering = ksz8795_port_vlan_filtering, - .port_vlan_prepare = ksz_port_vlan_prepare, .port_vlan_add = ksz8795_port_vlan_add, .port_vlan_del = ksz8795_port_vlan_del, .port_fdb_dump = ksz_port_fdb_dump,
drivers/net/dsa/microchip/ksz9477.c +11 -7
@@ -510,16 +510,18 @@ static int ksz9477_port_vlan_filtering(struct dsa_switch *ds, int port,return 0 ; } -static void ksz9477_port_vlan_add (struct dsa_switch *ds,int port, -const struct switchdev_obj_port_vlan *vlan) +static int ksz9477_port_vlan_add (struct dsa_switch *ds,int port, +const struct switchdev_obj_port_vlan *vlan) {struct ksz_device *dev = ds->priv;u32 vlan_table[3 ];bool untagged = vlan->flags &BRIDGE_VLAN_INFO_UNTAGGED ; +int err; -if (ksz9477_get_vlan_table (dev, vlan->vid, vlan_table)) { + err =ksz9477_get_vlan_table (dev, vlan->vid, vlan_table); +if (err) {dev_dbg (dev->dev,"Failed to get vlan table\n" ); -return ; +return err; } vlan_table[0 ] =VLAN_VALID | (vlan->vid &VLAN_FID_M );
@@ -531,14 +533,17 @@ static void ksz9477_port_vlan_add(struct dsa_switch *ds, int port, vlan_table[2 ] |=BIT (port) |BIT (dev->cpu_port); -if (ksz9477_set_vlan_table (dev, vlan->vid, vlan_table)) { + err =ksz9477_set_vlan_table (dev, vlan->vid, vlan_table); +if (err) {dev_dbg (dev->dev,"Failed to set vlan table\n" ); -return ; +return err; }/* change PVID */ if (vlan->flags &BRIDGE_VLAN_INFO_PVID )ksz_pwrite16 (dev, port,REG_PORT_DEFAULT_VID , vlan->vid); + +return 0 ; } static int ksz9477_port_vlan_del(struct dsa_switch *ds, int port,
@@ -1394,7 +1399,6 @@ static const struct dsa_switch_ops ksz9477_switch_ops = { .port_stp_state_set = ksz9477_port_stp_state_set, .port_fast_age = ksz_port_fast_age, .port_vlan_filtering = ksz9477_port_vlan_filtering, - .port_vlan_prepare = ksz_port_vlan_prepare, .port_vlan_add = ksz9477_port_vlan_add, .port_vlan_del = ksz9477_port_vlan_del, .port_fdb_dump = ksz9477_port_fdb_dump,
drivers/net/dsa/microchip/ksz_common.c +0 -9
@@ -213,15 +213,6 @@ void ksz_port_fast_age(struct dsa_switch *ds, int port) }EXPORT_SYMBOL_GPL (ksz_port_fast_age); -int ksz_port_vlan_prepare (struct dsa_switch *ds,int port, -const struct switchdev_obj_port_vlan *vlan) -{ -/* nothing needed */ - -return 0 ; -} -EXPORT_SYMBOL_GPL (ksz_port_vlan_prepare); -int ksz_port_fdb_dump (struct dsa_switch *ds,int port,dsa_fdb_dump_cb_t *cb,void *data) {
drivers/net/dsa/microchip/ksz_common.h +0 -2
@@ -161,8 +161,6 @@ int ksz_port_bridge_join(struct dsa_switch *ds, int port,void ksz_port_bridge_leave (struct dsa_switch *ds,int port,struct net_device *br);void ksz_port_fast_age (struct dsa_switch *ds,int port); -int ksz_port_vlan_prepare (struct dsa_switch *ds,int port, -const struct switchdev_obj_port_vlan *vlan);int ksz_port_fdb_dump (struct dsa_switch *ds,int port,dsa_fdb_dump_cb_t *cb,void *data); int ksz_port_mdb_add(struct dsa_switch *ds, int port,
drivers/net/dsa/mt7530.c +3 -11
@@ -1393,15 +1393,6 @@ mt7530_port_vlan_filtering(struct dsa_switch *ds, int port,return 0 ; } -static int -mt7530_port_vlan_prepare (struct dsa_switch *ds,int port, -const struct switchdev_obj_port_vlan *vlan) -{ -/* nothing needed */ - -return 0 ; -} -static void mt7530_hw_vlan_add (struct mt7530_priv *priv,struct mt7530_hw_vlan_entry *entry)
@@ -1489,7 +1480,7 @@ mt7530_hw_vlan_update(struct mt7530_priv *priv, u16 vid,mt7530_vlan_cmd (priv,MT7530_VTCR_WR_VID , vid); } -static void +static int mt7530_port_vlan_add (struct dsa_switch *ds,int port,const struct switchdev_obj_port_vlan *vlan) {
@@ -1510,6 +1501,8 @@ mt7530_port_vlan_add(struct dsa_switch *ds, int port, }mutex_unlock (&priv->reg_mutex); + +return 0 ; } static int
@@ -2608,7 +2601,6 @@ static const struct dsa_switch_ops mt7530_switch_ops = { .port_fdb_del = mt7530_port_fdb_del, .port_fdb_dump = mt7530_port_fdb_dump, .port_vlan_filtering = mt7530_port_vlan_filtering, - .port_vlan_prepare = mt7530_port_vlan_prepare, .port_vlan_add = mt7530_port_vlan_add, .port_vlan_del = mt7530_port_vlan_del, .port_mirror_add = mt753x_port_mirror_add,
drivers/net/dsa/mv88e6xxx/chip.c +21 -13
@@ -1617,9 +1617,6 @@ mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port, err =mv88e6xxx_port_check_hw_vlan (ds, port, vlan->vid);mv88e6xxx_reg_unlock (chip); -/* We don't need any dynamic resource from the kernel (yet), -* so skip the prepare phase. -*/ return err; }
@@ -1963,17 +1960,19 @@ static int mv88e6xxx_port_vlan_join(struct mv88e6xxx_chip *chip, int port,return 0 ; } -static void mv88e6xxx_port_vlan_add (struct dsa_switch *ds,int port, -const struct switchdev_obj_port_vlan *vlan) +static int mv88e6xxx_port_vlan_add (struct dsa_switch *ds,int port, +const struct switchdev_obj_port_vlan *vlan) {struct mv88e6xxx_chip *chip = ds->priv;bool untagged = vlan->flags &BRIDGE_VLAN_INFO_UNTAGGED ;bool pvid = vlan->flags &BRIDGE_VLAN_INFO_PVID ;bool warn;u8 member; +int err; -if (!mv88e6xxx_max_vid (chip)) -return ; + err =mv88e6xxx_port_vlan_prepare (ds, port, vlan); +if (err) +return err;if (dsa_is_dsa_port (ds, port) ||dsa_is_cpu_port (ds, port)) member =MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED ;
@@ -1989,15 +1988,25 @@ static void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,mv88e6xxx_reg_lock (chip); -if (mv88e6xxx_port_vlan_join (chip, port, vlan->vid, member, warn)) + err =mv88e6xxx_port_vlan_join (chip, port, vlan->vid, member, warn); +if (err) {dev_err (ds->dev,"p%d: failed to add VLAN %d%c\n" , port, vlan->vid, untagged ?'u' :'t' ); + goto out; + } -if (pvid &&mv88e6xxx_port_set_pvid (chip, port, vlan->vid)) -dev_err (ds->dev,"p%d: failed to set PVID %d\n" , port, - vlan->vid); - +if (pvid) { + err =mv88e6xxx_port_set_pvid (chip, port, vlan->vid); +if (err) { +dev_err (ds->dev,"p%d: failed to set PVID %d\n" , + port, vlan->vid); + goto out; + } + } +out:mv88e6xxx_reg_unlock (chip); + +return err; } static int mv88e6xxx_port_vlan_leave(struct mv88e6xxx_chip *chip,
@@ -5388,7 +5397,6 @@ static const struct dsa_switch_ops mv88e6xxx_switch_ops = { .port_stp_state_set = mv88e6xxx_port_stp_state_set, .port_fast_age = mv88e6xxx_port_fast_age, .port_vlan_filtering = mv88e6xxx_port_vlan_filtering, - .port_vlan_prepare = mv88e6xxx_port_vlan_prepare, .port_vlan_add = mv88e6xxx_port_vlan_add, .port_vlan_del = mv88e6xxx_port_vlan_del, .port_fdb_add = mv88e6xxx_port_fdb_add,
drivers/net/dsa/ocelot/felix.c +10 -6
@@ -134,15 +134,20 @@ static int felix_vlan_filtering(struct dsa_switch *ds, int port, bool enabled)return ocelot_port_vlan_filtering (ocelot, port, enabled); } -static void felix_vlan_add (struct dsa_switch *ds,int port, -const struct switchdev_obj_port_vlan *vlan) +static int felix_vlan_add (struct dsa_switch *ds,int port, +const struct switchdev_obj_port_vlan *vlan) {struct ocelot *ocelot = ds->priv;u16 flags = vlan->flags; +int err; + + err =felix_vlan_prepare (ds, port, vlan); +if (err) +return err; -ocelot_vlan_add (ocelot, port, vlan->vid, - flags &BRIDGE_VLAN_INFO_PVID , - flags &BRIDGE_VLAN_INFO_UNTAGGED ); +return ocelot_vlan_add (ocelot, port, vlan->vid, + flags &BRIDGE_VLAN_INFO_PVID , + flags &BRIDGE_VLAN_INFO_UNTAGGED ); } static int felix_vlan_del(struct dsa_switch *ds, int port,
@@ -769,7 +774,6 @@ const struct dsa_switch_ops felix_switch_ops = { .port_bridge_join = felix_bridge_join, .port_bridge_leave = felix_bridge_leave, .port_stp_state_set = felix_bridge_stp_state_set, - .port_vlan_prepare = felix_vlan_prepare, .port_vlan_filtering = felix_vlan_filtering, .port_vlan_add = felix_vlan_add, .port_vlan_del = felix_vlan_del,
drivers/net/dsa/qca8k.c +5 -9
@@ -1312,13 +1312,6 @@ qca8k_port_vlan_filtering(struct dsa_switch *ds, int port, bool vlan_filtering) }static int -qca8k_port_vlan_prepare (struct dsa_switch *ds,int port, -const struct switchdev_obj_port_vlan *vlan) -{ -return 0 ; -} - -static void qca8k_port_vlan_add (struct dsa_switch *ds,int port,const struct switchdev_obj_port_vlan *vlan) {
@@ -1328,8 +1321,10 @@ qca8k_port_vlan_add(struct dsa_switch *ds, int port,int ret =0 ; ret =qca8k_vlan_add (priv, port, vlan->vid, untagged); -if (ret) +if (ret) {dev_err (priv->dev,"Failed to add VLAN to port %d (%d)" , port, ret); +return ret; + }if (pvid) {int shift =16 * (port %2 );
@@ -1340,6 +1335,8 @@ qca8k_port_vlan_add(struct dsa_switch *ds, int port,QCA8K_PORT_VLAN_CVID (vlan->vid) | QCA8K_PORT_VLAN_SVID(vlan->vid)); } + +return 0 ; } static int
@@ -1382,7 +1379,6 @@ static const struct dsa_switch_ops qca8k_switch_ops = { .port_fdb_del = qca8k_port_fdb_del, .port_fdb_dump = qca8k_port_fdb_dump, .port_vlan_filtering = qca8k_port_vlan_filtering, - .port_vlan_prepare = qca8k_port_vlan_prepare, .port_vlan_add = qca8k_port_vlan_add, .port_vlan_del = qca8k_port_vlan_del, .phylink_validate = qca8k_phylink_validate,
drivers/net/dsa/realtek-smi-core.h +2 -4
@@ -132,10 +132,8 @@ int rtl8366_reset_vlan(struct realtek_smi *smi);int rtl8366_init_vlan (struct realtek_smi *smi);int rtl8366_vlan_filtering (struct dsa_switch *ds,int port,bool vlan_filtering); -int rtl8366_vlan_prepare (struct dsa_switch *ds,int port, -const struct switchdev_obj_port_vlan *vlan); -void rtl8366_vlan_add (struct dsa_switch *ds,int port, -const struct switchdev_obj_port_vlan *vlan); +int rtl8366_vlan_add (struct dsa_switch *ds,int port, +const struct switchdev_obj_port_vlan *vlan);int rtl8366_vlan_del (struct dsa_switch *ds,int port,const struct switchdev_obj_port_vlan *vlan); void rtl8366_get_strings(struct dsa_switch *ds, int port, u32 stringset,
drivers/net/dsa/rtl8366.c +18 -26
74 lines not on this page · raw message
drivers/net/dsa/rtl8366rb.c +0 -1
@@ -1504,7 +1504,6 @@ static const struct dsa_switch_ops rtl8366rb_switch_ops = { .get_ethtool_stats = rtl8366_get_ethtool_stats, .get_sset_count = rtl8366_get_sset_count, .port_vlan_filtering = rtl8366_vlan_filtering, - .port_vlan_prepare = rtl8366_vlan_prepare, .port_vlan_add = rtl8366_vlan_add, .port_vlan_del = rtl8366_vlan_del, .port_enable = rtl8366rb_port_enable,
drivers/net/dsa/sja1105/sja1105_main.c +15 -28
74 lines not on this page · raw message
include/net/dsa.h +1 -3
@@ -561,10 +561,8 @@ struct dsa_switch_ops {*/ int (*port_vlan_filtering)(struct dsa_switch *ds,int port,bool vlan_filtering); -int (*port_vlan_prepare)(struct dsa_switch *ds,int port, +int (*port_vlan_add)(struct dsa_switch *ds,int port,const struct switchdev_obj_port_vlan *vlan); -void (*port_vlan_add)(struct dsa_switch *ds,int port, -const struct switchdev_obj_port_vlan *vlan);int (*port_vlan_del)(struct dsa_switch *ds,int port,const struct switchdev_obj_port_vlan *vlan);/*
net/dsa/switch.c +2 -6
@@ -227,21 +227,17 @@ static int dsa_switch_vlan_add(struct dsa_switch *ds, {int port, err; -if (!ds->ops->port_vlan_prepare || !ds->ops->port_vlan_add) +if (!ds->ops->port_vlan_add)return -EOPNOTSUPP ;for (port =0 ; port < ds->num_ports; port++) {if (dsa_switch_vlan_match (ds, port, info)) { - err = ds->ops->port_vlan_prepare (ds, port, info->vlan); + err = ds->ops->port_vlan_add (ds, port, info->vlan);if (err)return err; } } -for (port =0 ; port < ds->num_ports; port++) -if (dsa_switch_vlan_match (ds, port, info)) - ds->ops->port_vlan_add (ds, port, info->vlan); -return 0 ; }
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH v3 9/11 net: dsa: remove obsolete comments about switchdev transactions
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
Now that all port object notifiers were converted to be non-transactional, we can remove the comments that say otherwise.
---
Changes in v3:
None.
Changes in v2:
None.
net/dsa/slave.c | 5 ----- net/dsa/switch.c | 4 ---- 2 files changed, 9 deletions(-)
net/dsa/slave.c +0 -5
@@ -373,11 +373,6 @@ static int dsa_slave_port_obj_add(struct net_device *dev,struct dsa_port *dp =dsa_slave_to_port (dev);int err; -/* For the prepare phase, ensure the full set of changes is feasable in -* one go in order to signal a failure properly. If an operation is not -* supported, return -EOPNOTSUPP. -*/ -switch (obj->id) {case SWITCHDEV_OBJ_ID_PORT_MDB :if (obj->orig_dev != dev)
net/dsa/switch.c +0 -4
@@ -298,10 +298,6 @@ static int dsa_switch_event(struct notifier_block *nb,break ; } -/* Non-switchdev operations cannot be rolled back. If a DSA driver -* returns an error during the chained call, switch chips may be in an -* inconsistent state. -*/ if (err)dev_dbg (ds->dev,"breaking chain for DSA event %lu (%d)\n" , event, err);
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH v3 10/11 mlxsw: spectrum_switchdev: remove transactional logic for VLAN objects
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
As of commit 457e20d65924 ("mlxsw: spectrum_switchdev: Avoid returning errors in commit phase"), the mlxsw driver performs the VLAN object offloading during the prepare phase. So conversion just seems to be a matter of removing the code that was running in the commit phase.
---
Changes in v3:
Restored the comment to its original state.
Changes in v2:
Rebased on top of VLAN ranges removal.
.../mellanox/mlxsw/spectrum_switchdev.c | 34 +++---------------- 1 file changed, 4 insertions(+), 30 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +4 -30
@@ -1196,7 +1196,6 @@ mlxsw_sp_br_ban_rif_pvid_change(struct mlxsw_sp *mlxsw_sp,static int mlxsw_sp_port_vlans_add (struct mlxsw_sp_port *mlxsw_sp_port,const struct switchdev_obj_port_vlan *vlan, -struct switchdev_trans *trans,struct netlink_ext_ack *extack) {bool flag_untagged = vlan->flags &BRIDGE_VLAN_INFO_UNTAGGED ;
@@ -1209,8 +1208,7 @@ static int mlxsw_sp_port_vlans_add(struct mlxsw_sp_port *mlxsw_sp_port,int err =0 ;if ((vlan->flags &BRIDGE_VLAN_INFO_BRENTRY ) && -br_vlan_enabled (orig_dev) && -switchdev_trans_ph_prepare (trans)) +br_vlan_enabled (orig_dev)) err =mlxsw_sp_br_ban_rif_pvid_change (mlxsw_sp, orig_dev, vlan);if (!err)
@@ -1218,9 +1216,6 @@ static int mlxsw_sp_port_vlans_add(struct mlxsw_sp_port *mlxsw_sp_port,return err; } -if (switchdev_trans_ph_commit (trans)) -return 0 ; - bridge_port =mlxsw_sp_bridge_port_find (mlxsw_sp->bridge, orig_dev);if (WARN_ON (!bridge_port))return -EINVAL ;
@@ -1764,16 +1759,13 @@ static int mlxsw_sp_port_obj_add(struct net_device *dev, {struct mlxsw_sp_port *mlxsw_sp_port =netdev_priv (dev);const struct switchdev_obj_port_vlan *vlan; -struct switchdev_trans trans;int err =0 ;switch (obj->id) {case SWITCHDEV_OBJ_ID_PORT_VLAN : vlan =SWITCHDEV_OBJ_PORT_VLAN (obj); - trans.ph_prepare = true; - err =mlxsw_sp_port_vlans_add (mlxsw_sp_port, vlan, &trans, - extack); + err =mlxsw_sp_port_vlans_add (mlxsw_sp_port, vlan, extack);if (err)break ;
@@ -1783,10 +1775,6 @@ static int mlxsw_sp_port_obj_add(struct net_device *dev,* updated bridge state. */ mlxsw_sp_span_respin (mlxsw_sp_port->mlxsw_sp); - - trans.ph_prepare = false; - err =mlxsw_sp_port_vlans_add (mlxsw_sp_port, vlan, &trans, - extack);break ;case SWITCHDEV_OBJ_ID_PORT_MDB : err = mlxsw_sp_port_mdb_add(mlxsw_sp_port,
@@ -3350,8 +3338,7 @@ mlxsw_sp_switchdev_vxlan_vlan_del(struct mlxsw_sp *mlxsw_sp,static int mlxsw_sp_switchdev_vxlan_vlans_add (struct net_device *vxlan_dev,struct switchdev_notifier_port_obj_info * - port_obj_info, -struct switchdev_trans *trans) + port_obj_info) {struct switchdev_obj_port_vlan *vlan =SWITCHDEV_OBJ_PORT_VLAN (port_obj_info->obj);
@@ -3373,9 +3360,6 @@ mlxsw_sp_switchdev_vxlan_vlans_add(struct net_device *vxlan_dev, port_obj_info->handled = true; -if (switchdev_trans_ph_commit (trans)) -return 0 ; - bridge_device =mlxsw_sp_bridge_device_find (mlxsw_sp->bridge, br_dev);if (!bridge_device)return -EINVAL ;
@@ -3426,22 +3410,12 @@ mlxsw_sp_switchdev_handle_vxlan_obj_add(struct net_device *vxlan_dev,struct switchdev_notifier_port_obj_info * port_obj_info) { -struct switchdev_trans trans;int err =0 ;switch (port_obj_info->obj->id) {case SWITCHDEV_OBJ_ID_PORT_VLAN : - trans.ph_prepare = true; - err =mlxsw_sp_switchdev_vxlan_vlans_add (vxlan_dev, - port_obj_info, - &trans); -if (err) -break ; - - trans.ph_prepare = false; err =mlxsw_sp_switchdev_vxlan_vlans_add (vxlan_dev, - port_obj_info, - &trans); + port_obj_info);break ;default :break ;
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH v3 11/11 net: switchdev: delete the transaction object
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
Now that all users of struct switchdev_trans have been modified to do without it, we can remove this structure and the two helpers to determine the phase.
---
Changes in v3:
None.
Changes in v2:
None.
include/net/switchdev.h | 14 -------------- 1 file changed, 14 deletions(-)
include/net/switchdev.h +0 -14
@@ -16,20 +16,6 @@#define SWITCHDEV_F_SKIP_EOPNOTSUPP BIT(1)#define SWITCHDEV_F_DEFER BIT(2) -struct switchdev_trans { -bool ph_prepare; -}; - -static inline bool switchdev_trans_ph_prepare (struct switchdev_trans *trans) -{ -return trans && trans->ph_prepare; -} - -static inline bool switchdev_trans_ph_commit (struct switchdev_trans *trans) -{ -return trans && !trans->ph_prepare; -} -enum switchdev_attr_id {SWITCHDEV_ATTR_ID_UNDEFINED ,SWITCHDEV_ATTR_ID_PORT_STP_STATE ,
Signature · 1 line
2.25.1