diff options
author | Vladimir Oltean <olteanv@gmail.com> | 2019-04-28 21:45:54 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-04-30 23:05:29 -0400 |
commit | 314f76d7a68bab0516aa52877944e6aacfa0fc3f (patch) | |
tree | 69566e08f1d74a449e6df3d1444ef89925084780 /net/dsa/port.c | |
parent | e74f014eb4ceeeefe4e5058daac705422eecb683 (diff) | |
download | linux-next-314f76d7a68bab0516aa52877944e6aacfa0fc3f.tar.gz |
net: dsa: Add more convenient functions for installing port VLANs
This hides the need to perform a two-phase transaction and construct a
switchdev_obj_port_vlan struct.
Call graph (including a function that will be introduced in a follow-up
patch) looks like this now (same for the *_vlan_del function):
dsa_slave_vlan_rx_add_vid dsa_port_setup_8021q_tagging
| |
| |
| +-------------+
| |
v v
dsa_port_vid_add dsa_slave_port_obj_add
| |
+-------+ +-------+
| |
v v
dsa_port_vlan_add
Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dsa/port.c')
-rw-r--r-- | net/dsa/port.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/net/dsa/port.c b/net/dsa/port.c index aa7ec043d5ba..1ed287b2badd 100644 --- a/net/dsa/port.c +++ b/net/dsa/port.c @@ -370,6 +370,37 @@ int dsa_port_vlan_del(struct dsa_port *dp, return 0; } +int dsa_port_vid_add(struct dsa_port *dp, u16 vid, u16 flags) +{ + struct switchdev_obj_port_vlan vlan = { + .obj.id = SWITCHDEV_OBJ_ID_PORT_VLAN, + .flags = flags, + .vid_begin = vid, + .vid_end = vid, + }; + struct switchdev_trans trans; + int err; + + trans.ph_prepare = true; + err = dsa_port_vlan_add(dp, &vlan, &trans); + if (err == -EOPNOTSUPP) + return 0; + + trans.ph_prepare = false; + return dsa_port_vlan_add(dp, &vlan, &trans); +} + +int dsa_port_vid_del(struct dsa_port *dp, u16 vid) +{ + struct switchdev_obj_port_vlan vlan = { + .obj.id = SWITCHDEV_OBJ_ID_PORT_VLAN, + .vid_begin = vid, + .vid_end = vid, + }; + + return dsa_port_vlan_del(dp, &vlan); +} + static struct phy_device *dsa_port_get_phy_device(struct dsa_port *dp) { struct device_node *phy_dn; |