[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200916094845.10782-3-hongbo.wang@nxp.com>
Date: Wed, 16 Sep 2020 17:48:44 +0800
From: hongbo.wang@....com
To: xiaoliang.yang_1@....com, po.liu@....com, mingkai.hu@....com,
allan.nielsen@...rochip.com, claudiu.manoil@....com,
alexandru.marginean@....com, vladimir.oltean@....com,
leoyang.li@....com, andrew@...n.ch, f.fainelli@...il.com,
vivien.didelot@...il.com, davem@...emloft.net, jiri@...nulli.us,
idosch@...sch.org, kuba@...nel.org, vinicius.gomes@...el.com,
nikolay@...ulusnetworks.com, roopa@...ulusnetworks.com,
netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
horatiu.vultur@...rochip.com, alexandre.belloni@...tlin.com,
UNGLinuxDriver@...rochip.com, ivecera@...hat.com
Cc: "hongbo.wang" <hongbo.wang@....com>
Subject: [PATCH v6 2/3] net: switchdev: Add VLAN protocol support for switchdev port
From: "hongbo.wang" <hongbo.wang@....com>
Add VLAN protocol support when adding or deleting VLAN for switchdev
port, get current bridge's VLAN protocol and pass it to port driver.
Signed-off-by: hongbo.wang <hongbo.wang@....com>
---
net/bridge/br_switchdev.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/net/bridge/br_switchdev.c b/net/bridge/br_switchdev.c
index 015209bf44aa..7712da3e7912 100644
--- a/net/bridge/br_switchdev.c
+++ b/net/bridge/br_switchdev.c
@@ -146,6 +146,26 @@ br_switchdev_fdb_notify(const struct net_bridge_fdb_entry *fdb, int type)
}
}
+static u16 br_switchdev_get_bridge_vlan_proto(const struct net_device *dev)
+{
+ const struct net_device *br = NULL;
+ u16 vlan_proto = ETH_P_8021Q;
+ struct net_bridge_port *p;
+
+ if (netif_is_bridge_master(dev)) {
+ br = dev;
+ } else {
+ p = br_port_get_rtnl_rcu(dev);
+ if (p)
+ br = p->br->dev;
+ }
+
+ if (br)
+ br_vlan_get_proto(br, &vlan_proto);
+
+ return vlan_proto;
+}
+
int br_switchdev_port_vlan_add(struct net_device *dev, u16 vid, u16 flags,
struct netlink_ext_ack *extack)
{
@@ -157,6 +177,8 @@ int br_switchdev_port_vlan_add(struct net_device *dev, u16 vid, u16 flags,
.vid_end = vid,
};
+ v.proto = br_switchdev_get_bridge_vlan_proto(dev);
+
return switchdev_port_obj_add(dev, &v.obj, extack);
}
@@ -169,5 +191,7 @@ int br_switchdev_port_vlan_del(struct net_device *dev, u16 vid)
.vid_end = vid,
};
+ v.proto = br_switchdev_get_bridge_vlan_proto(dev);
+
return switchdev_port_obj_del(dev, &v.obj);
}
--
2.17.1
Powered by blists - more mailing lists