linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: dsa: Add protocol support for 802.1AD when adding or deleting vlan for dsa switch and port
@ 2020-07-21 11:02 hongbo.wang
  2020-07-21 17:55 ` Florian Fainelli
  0 siblings, 1 reply; 3+ messages in thread
From: hongbo.wang @ 2020-07-21 11:02 UTC (permalink / raw)
  To: xiaoliang.yang_1, allan.nielsen, po.liu, claudiu.manoil,
	alexandru.marginean, vladimir.oltean, leoyang.li, mingkai.hu,
	andrew, f.fainelli, vivien.didelot, davem, jiri, idosch, kuba,
	vinicius.gomes, nikolay, roopa, netdev, linux-kernel,
	horatiu.vultur, alexandre.belloni, UNGLinuxDriver, linux-devel
  Cc: hongbo.wang

From: "hongbo.wang" <hongbo.wang@nxp.com>

the following command will be supported:
Add VLAN:
    ip link add link swp1 name swp1.100 type vlan protocol 802.1ad id 100
Delete VLAN:
    ip link del link swp1 name swp1.100

when adding vlan, this patch only set protocol for user port,
cpu port don't care it, so set parameter proto to 0 for cpu port.

Signed-off-by: hongbo.wang <hongbo.wang@nxp.com>
---
 include/net/switchdev.h | 1 +
 net/dsa/dsa_priv.h      | 4 ++--
 net/dsa/port.c          | 7 ++++---
 net/dsa/slave.c         | 9 +++++----
 net/dsa/tag_8021q.c     | 4 ++--
 5 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/include/net/switchdev.h b/include/net/switchdev.h
index ff2246914301..7594ea82879f 100644
--- a/include/net/switchdev.h
+++ b/include/net/switchdev.h
@@ -97,6 +97,7 @@ struct switchdev_obj_port_vlan {
 	u16 flags;
 	u16 vid_begin;
 	u16 vid_end;
+	u16 proto;
 };
 
 #define SWITCHDEV_OBJ_PORT_VLAN(OBJ) \
diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h
index 1653e3377cb3..52685b9875e5 100644
--- a/net/dsa/dsa_priv.h
+++ b/net/dsa/dsa_priv.h
@@ -164,8 +164,8 @@ int dsa_port_vlan_add(struct dsa_port *dp,
 		      struct switchdev_trans *trans);
 int dsa_port_vlan_del(struct dsa_port *dp,
 		      const struct switchdev_obj_port_vlan *vlan);
-int dsa_port_vid_add(struct dsa_port *dp, u16 vid, u16 flags);
-int dsa_port_vid_del(struct dsa_port *dp, u16 vid);
+int dsa_port_vid_add(struct dsa_port *dp, u16 vid, u16 proto, u16 flags);
+int dsa_port_vid_del(struct dsa_port *dp, u16 vid, u16 proto);
 int dsa_port_link_register_of(struct dsa_port *dp);
 void dsa_port_link_unregister_of(struct dsa_port *dp);
 extern const struct phylink_mac_ops dsa_port_phylink_mac_ops;
diff --git a/net/dsa/port.c b/net/dsa/port.c
index e23ece229c7e..c07c6ee136a9 100644
--- a/net/dsa/port.c
+++ b/net/dsa/port.c
@@ -364,7 +364,6 @@ int dsa_port_fdb_del(struct dsa_port *dp, const unsigned char *addr,
 		.port = dp->index,
 		.addr = addr,
 		.vid = vid,
-
 	};
 
 	return dsa_port_notify(dp, DSA_NOTIFIER_FDB_DEL, &info);
@@ -433,13 +432,14 @@ int dsa_port_vlan_del(struct dsa_port *dp,
 	return dsa_port_notify(dp, DSA_NOTIFIER_VLAN_DEL, &info);
 }
 
-int dsa_port_vid_add(struct dsa_port *dp, u16 vid, u16 flags)
+int dsa_port_vid_add(struct dsa_port *dp, u16 vid, u16 proto, u16 flags)
 {
 	struct switchdev_obj_port_vlan vlan = {
 		.obj.id = SWITCHDEV_OBJ_ID_PORT_VLAN,
 		.flags = flags,
 		.vid_begin = vid,
 		.vid_end = vid,
+		.proto = proto,
 	};
 	struct switchdev_trans trans;
 	int err;
@@ -454,12 +454,13 @@ int dsa_port_vid_add(struct dsa_port *dp, u16 vid, u16 flags)
 }
 EXPORT_SYMBOL(dsa_port_vid_add);
 
-int dsa_port_vid_del(struct dsa_port *dp, u16 vid)
+int dsa_port_vid_del(struct dsa_port *dp, u16 vid, u16 proto)
 {
 	struct switchdev_obj_port_vlan vlan = {
 		.obj.id = SWITCHDEV_OBJ_ID_PORT_VLAN,
 		.vid_begin = vid,
 		.vid_end = vid,
+		.proto = proto,
 	};
 
 	return dsa_port_vlan_del(dp, &vlan);
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 41d60eeefdbd..ba3984565f7e 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -1252,11 +1252,11 @@ static int dsa_slave_vlan_rx_add_vid(struct net_device *dev, __be16 proto,
 			return -EBUSY;
 	}
 
-	ret = dsa_port_vid_add(dp, vid, 0);
+	ret = dsa_port_vid_add(dp, vid, ntohs(proto), 0);
 	if (ret)
 		return ret;
 
-	ret = dsa_port_vid_add(dp->cpu_dp, vid, 0);
+	ret = dsa_port_vid_add(dp->cpu_dp, vid, 0, 0);
 	if (ret)
 		return ret;
 
@@ -1289,7 +1289,7 @@ static int dsa_slave_vlan_rx_kill_vid(struct net_device *dev, __be16 proto,
 	/* Do not deprogram the CPU port as it may be shared with other user
 	 * ports which can be members of this VLAN as well.
 	 */
-	return dsa_port_vid_del(dp, vid);
+	return dsa_port_vid_del(dp, vid, ntohs(proto));
 }
 
 struct dsa_hw_port {
@@ -1744,7 +1744,8 @@ int dsa_slave_create(struct dsa_port *port)
 
 	slave_dev->features = master->vlan_features | NETIF_F_HW_TC;
 	if (ds->ops->port_vlan_add && ds->ops->port_vlan_del)
-		slave_dev->features |= NETIF_F_HW_VLAN_CTAG_FILTER;
+		slave_dev->features |= NETIF_F_HW_VLAN_CTAG_FILTER |
+				       NETIF_F_HW_VLAN_STAG_FILTER;
 	slave_dev->hw_features |= NETIF_F_HW_TC;
 	slave_dev->features |= NETIF_F_LLTX;
 	slave_dev->ethtool_ops = &dsa_slave_ethtool_ops;
diff --git a/net/dsa/tag_8021q.c b/net/dsa/tag_8021q.c
index 780b2a15ac9b..848f85ed5c0f 100644
--- a/net/dsa/tag_8021q.c
+++ b/net/dsa/tag_8021q.c
@@ -152,9 +152,9 @@ static int dsa_8021q_vid_apply(struct dsa_switch *ds, int port, u16 vid,
 	struct dsa_port *dp = dsa_to_port(ds, port);
 
 	if (enabled)
-		return dsa_port_vid_add(dp, vid, flags);
+		return dsa_port_vid_add(dp, vid, 0, flags);
 
-	return dsa_port_vid_del(dp, vid);
+	return dsa_port_vid_del(dp, vid, 0);
 }
 
 /* RX VLAN tagging (left) and TX VLAN tagging (right) setup shown for a single
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] net: dsa: Add protocol support for 802.1AD when adding or deleting vlan for dsa switch and port
  2020-07-21 11:02 [PATCH] net: dsa: Add protocol support for 802.1AD when adding or deleting vlan for dsa switch and port hongbo.wang
@ 2020-07-21 17:55 ` Florian Fainelli
  2020-07-22  5:51   ` [EXT] " Hongbo Wang
  0 siblings, 1 reply; 3+ messages in thread
From: Florian Fainelli @ 2020-07-21 17:55 UTC (permalink / raw)
  To: hongbo.wang, xiaoliang.yang_1, allan.nielsen, po.liu,
	claudiu.manoil, alexandru.marginean, vladimir.oltean, leoyang.li,
	mingkai.hu, andrew, vivien.didelot, davem, jiri, idosch, kuba,
	vinicius.gomes, nikolay, roopa, netdev, linux-kernel,
	horatiu.vultur, alexandre.belloni, UNGLinuxDriver, linux-devel

On 7/21/20 4:02 AM, hongbo.wang@nxp.com wrote:
> From: "hongbo.wang" <hongbo.wang@nxp.com>
> 
> the following command will be supported:
> Add VLAN:
>     ip link add link swp1 name swp1.100 type vlan protocol 802.1ad id 100
> Delete VLAN:
>     ip link del link swp1 name swp1.100
> 
> when adding vlan, this patch only set protocol for user port,
> cpu port don't care it, so set parameter proto to 0 for cpu port.

My previous feedback has been partially addressed, can you also post the
switch driver changes that are going to implement the driver side
changes? Presumably you must act on the 802.1AD programming request in
the switch driver somehow, right?
-- 
Florian

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [EXT] Re: [PATCH] net: dsa: Add protocol support for 802.1AD when adding or deleting vlan for dsa switch and port
  2020-07-21 17:55 ` Florian Fainelli
@ 2020-07-22  5:51   ` Hongbo Wang
  0 siblings, 0 replies; 3+ messages in thread
From: Hongbo Wang @ 2020-07-22  5:51 UTC (permalink / raw)
  To: Florian Fainelli, Xiaoliang Yang, allan.nielsen, Po Liu,
	Claudiu Manoil, Alexandru Marginean, Vladimir Oltean, Leo Li,
	Mingkai Hu, andrew, vivien.didelot, davem, jiri, idosch, kuba,
	vinicius.gomes, nikolay, roopa, netdev, linux-kernel,
	horatiu.vultur, alexandre.belloni, UNGLinuxDriver, linux-devel

Hi Florian,

Thanks for your reply!

I had posted my patch for switch port driver, the email title is "net: dsa: ocelot: Add support for QinQ Operation",

Best Regards!
hongbo

-----Original Message-----
From: Florian Fainelli <f.fainelli@gmail.com> 
Sent: 2020年7月22日 1:55
To: Hongbo Wang <hongbo.wang@nxp.com>; Xiaoliang Yang <xiaoliang.yang_1@nxp.com>; allan.nielsen@microchip.com; Po Liu <po.liu@nxp.com>; Claudiu Manoil <claudiu.manoil@nxp.com>; Alexandru Marginean <alexandru.marginean@nxp.com>; Vladimir Oltean <vladimir.oltean@nxp.com>; Leo Li <leoyang.li@nxp.com>; Mingkai Hu <mingkai.hu@nxp.com>; andrew@lunn.ch; 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; linux-devel@linux.nxdi.nxp.com
Subject: [EXT] Re: [PATCH] net: dsa: Add protocol support for 802.1AD when adding or deleting vlan for dsa switch and port

Caution: EXT Email

On 7/21/20 4:02 AM, hongbo.wang@nxp.com wrote:
> From: "hongbo.wang" <hongbo.wang@nxp.com>
>
> the following command will be supported:
> Add VLAN:
>     ip link add link swp1 name swp1.100 type vlan protocol 802.1ad id 
> 100 Delete VLAN:
>     ip link del link swp1 name swp1.100
>
> when adding vlan, this patch only set protocol for user port, cpu port 
> don't care it, so set parameter proto to 0 for cpu port.

My previous feedback has been partially addressed, can you also post the switch driver changes that are going to implement the driver side changes? Presumably you must act on the 802.1AD programming request in the switch driver somehow, right?
--
Florian

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-07-22  5:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-21 11:02 [PATCH] net: dsa: Add protocol support for 802.1AD when adding or deleting vlan for dsa switch and port hongbo.wang
2020-07-21 17:55 ` Florian Fainelli
2020-07-22  5:51   ` [EXT] " Hongbo Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).