public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: hongbo.wang@nxp.com
To: xiaoliang.yang_1@nxp.com, po.liu@nxp.com, mingkai.hu@nxp.com,
	allan.nielsen@microchip.com, claudiu.manoil@nxp.com,
	alexandru.marginean@nxp.com, vladimir.oltean@nxp.com,
	leoyang.li@nxp.com, andrew@lunn.ch, f.fainelli@gmail.com,
	vivien.didelot@gmail.com, davem@davemloft.net, jiri@resnulli.us,
	idosch@idosch.org, kuba@kernel.org, vinicius.gomes@intel.com,
	nikolay@cumulusnetworks.com, roopa@cumulusnetworks.com,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	horatiu.vultur@microchip.com, alexandre.belloni@bootlin.com,
	UNGLinuxDriver@microchip.com, ivecera@redhat.com
Cc: "hongbo.wang" <hongbo.wang@nxp.com>
Subject: [PATCH v6 2/3] net: switchdev: Add VLAN protocol support for switchdev port
Date: Wed, 16 Sep 2020 17:48:44 +0800	[thread overview]
Message-ID: <20200916094845.10782-3-hongbo.wang@nxp.com> (raw)
In-Reply-To: <20200916094845.10782-1-hongbo.wang@nxp.com>

From: "hongbo.wang" <hongbo.wang@nxp.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@nxp.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


  parent reply	other threads:[~2020-09-16  9:46 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-16  9:48 [PATCH v6 0/3] Add 802.1AD protocol support for dsa switch and ocelot driver hongbo.wang
2020-09-16  9:48 ` [PATCH v6 1/3] net: dsa: Add protocol support for 802.1AD when adding or deleting vlan for dsa switch port hongbo.wang
2020-09-16  9:48 ` hongbo.wang [this message]
2020-09-16  9:48 ` [PATCH v6 3/3] net: dsa: ocelot: Add support for QinQ Operation hongbo.wang
2020-09-16 10:00   ` Vladimir Oltean
2020-09-16 10:28     ` [EXT] " Hongbo Wang
2020-09-16 10:45       ` Vladimir Oltean
2020-09-17  2:37         ` Hongbo Wang
2020-10-09 12:29           ` Vladimir Oltean
2020-10-10  3:22             ` Hongbo Wang
2020-09-19  0:20 ` [PATCH v6 0/3] Add 802.1AD protocol support for dsa switch and ocelot driver David Miller
2020-09-19  0:23   ` Florian Fainelli
2020-09-21  3:05   ` [EXT] " Hongbo Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200916094845.10782-3-hongbo.wang@nxp.com \
    --to=hongbo.wang@nxp.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=alexandru.marginean@nxp.com \
    --cc=allan.nielsen@microchip.com \
    --cc=andrew@lunn.ch \
    --cc=claudiu.manoil@nxp.com \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=horatiu.vultur@microchip.com \
    --cc=idosch@idosch.org \
    --cc=ivecera@redhat.com \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=leoyang.li@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingkai.hu@nxp.com \
    --cc=netdev@vger.kernel.org \
    --cc=nikolay@cumulusnetworks.com \
    --cc=po.liu@nxp.com \
    --cc=roopa@cumulusnetworks.com \
    --cc=vinicius.gomes@intel.com \
    --cc=vivien.didelot@gmail.com \
    --cc=vladimir.oltean@nxp.com \
    --cc=xiaoliang.yang_1@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox