From: Tobias Waldekranz <tobias@waldekranz.com>
To: davem@davemloft.net, kuba@kernel.org
Cc: andrew@lunn.ch, vivien.didelot@gmail.com, f.fainelli@gmail.com,
olteanv@gmail.com, roopa@nvidia.com, nikolay@nvidia.com,
jiri@resnulli.us, idosch@idosch.org, stephen@networkplumber.org,
netdev@vger.kernel.org, bridge@lists.linux-foundation.org
Subject: [RFC net-next 8/9] net: dsa: mv88e6xxx: Map virtual bridge port in PVT
Date: Mon, 26 Apr 2021 19:04:10 +0200 [thread overview]
Message-ID: <20210426170411.1789186-9-tobias@waldekranz.com> (raw)
In-Reply-To: <20210426170411.1789186-1-tobias@waldekranz.com>
Now that each bridge has a unique DSA device/port tuple, make sure
that each chip limits forwarding from the bridge to only include
fabric ports and local ports that are members of the same bridge.
Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
---
MAINTAINERS | 1 +
drivers/net/dsa/mv88e6xxx/chip.c | 33 ++++++++++++++++++++++++--------
drivers/net/dsa/mv88e6xxx/dst.c | 33 ++++++++++++++++++++++++++++++++
drivers/net/dsa/mv88e6xxx/dst.h | 2 ++
include/linux/dsa/mv88e6xxx.h | 13 +++++++++++++
5 files changed, 74 insertions(+), 8 deletions(-)
create mode 100644 include/linux/dsa/mv88e6xxx.h
diff --git a/MAINTAINERS b/MAINTAINERS
index c3c8fa572580..8794b05793b2 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -10647,6 +10647,7 @@ S: Maintained
F: Documentation/devicetree/bindings/net/dsa/marvell.txt
F: Documentation/networking/devlink/mv88e6xxx.rst
F: drivers/net/dsa/mv88e6xxx/
+F: include/linux/dsa/mv88e6xxx.h
F: include/linux/platform_data/mv88e6xxx.h
MARVELL ARMADA 3700 PHY DRIVERS
diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index 06ef654472b7..6975cf16da65 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -12,6 +12,7 @@
#include <linux/bitfield.h>
#include <linux/delay.h>
+#include <linux/dsa/mv88e6xxx.h>
#include <linux/etherdevice.h>
#include <linux/ethtool.h>
#include <linux/if_bridge.h>
@@ -1229,15 +1230,25 @@ static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
}
}
- /* Prevent frames from unknown switch or port */
- if (!found)
- return 0;
+ if (found) {
+ /* Frames from DSA links and CPU ports can egress any
+ * local port.
+ */
+ if (dp->type == DSA_PORT_TYPE_CPU ||
+ dp->type == DSA_PORT_TYPE_DSA)
+ return mv88e6xxx_port_mask(chip);
- /* Frames from DSA links and CPU ports can egress any local port */
- if (dp->type == DSA_PORT_TYPE_CPU || dp->type == DSA_PORT_TYPE_DSA)
- return mv88e6xxx_port_mask(chip);
+ br = dp->bridge_dev;
+ } else {
+ br = mv88e6xxx_dst_bridge_from_dsa(dst, dev, port);
+
+ /* Reject frames from ports that are neither physical
+ * nor virtual bridge ports.
+ */
+ if (!br)
+ return 0;
+ }
- br = dp->bridge_dev;
pvlan = 0;
/* Frames from user ports can egress any local DSA links and CPU ports,
@@ -2340,6 +2351,7 @@ static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
struct dsa_switch *ds = chip->ds;
struct dsa_switch_tree *dst = ds->dst;
struct dsa_port *dp;
+ u8 dev, port;
int err;
list_for_each_entry(dp, &dst->ports, list) {
@@ -2363,7 +2375,12 @@ static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
}
}
- return 0;
+ /* Map the virtual bridge port if one is assigned. */
+ err = mv88e6xxx_dst_bridge_to_dsa(dst, br, &dev, &port);
+ if (!err)
+ err = mv88e6xxx_pvt_map(chip, dev, port);
+
+ return err;
}
static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
diff --git a/drivers/net/dsa/mv88e6xxx/dst.c b/drivers/net/dsa/mv88e6xxx/dst.c
index 399a818063bf..a5f9077e5b3f 100644
--- a/drivers/net/dsa/mv88e6xxx/dst.c
+++ b/drivers/net/dsa/mv88e6xxx/dst.c
@@ -33,6 +33,39 @@ struct mv88e6xxx_dst {
#define PORT_FROM_BIT(_bit) ((_bit) % (MV88E6XXX_MAX_PVT_PORTS))
};
+struct net_device *mv88e6xxx_dst_bridge_from_dsa(struct dsa_switch_tree *dst,
+ u8 dev, u8 port)
+{
+ struct mv88e6xxx_dst *mvdst = dst->priv;
+ struct mv88e6xxx_br *mvbr;
+
+ list_for_each_entry(mvbr, &mvdst->bridges, list) {
+ if (mvbr->dev == dev && mvbr->port == port)
+ return mvbr->brdev;
+ }
+
+ return NULL;
+}
+
+int mv88e6xxx_dst_bridge_to_dsa(const struct dsa_switch_tree *dst,
+ const struct net_device *brdev,
+ u8 *dev, u8 *port)
+{
+ struct mv88e6xxx_dst *mvdst = dst->priv;
+ struct mv88e6xxx_br *mvbr;
+
+ list_for_each_entry(mvbr, &mvdst->bridges, list) {
+ if (mvbr->brdev == brdev) {
+ *dev = mvbr->dev;
+ *port = mvbr->port;
+ return 0;
+ }
+ }
+
+ return -ENODEV;
+}
+EXPORT_SYMBOL_GPL(mv88e6xxx_dst_bridge_to_dsa);
+
int mv88e6xxx_dst_bridge_join(struct dsa_switch_tree *dst,
struct net_device *brdev)
{
diff --git a/drivers/net/dsa/mv88e6xxx/dst.h b/drivers/net/dsa/mv88e6xxx/dst.h
index 3845a19192ef..911890ec4792 100644
--- a/drivers/net/dsa/mv88e6xxx/dst.h
+++ b/drivers/net/dsa/mv88e6xxx/dst.h
@@ -3,6 +3,8 @@
#ifndef _MV88E6XXX_DST_H
#define _MV88E6XXX_DST_H
+struct net_device *mv88e6xxx_dst_bridge_from_dsa(struct dsa_switch_tree *dst,
+ u8 dev, u8 port);
int mv88e6xxx_dst_bridge_join(struct dsa_switch_tree *dst,
struct net_device *brdev);
void mv88e6xxx_dst_bridge_leave(struct dsa_switch_tree *dst,
diff --git a/include/linux/dsa/mv88e6xxx.h b/include/linux/dsa/mv88e6xxx.h
new file mode 100644
index 000000000000..fa486dfe9808
--- /dev/null
+++ b/include/linux/dsa/mv88e6xxx.h
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef _NET_DSA_MV88E6XXX_H
+#define _NET_DSA_MV88E6XXX_H
+
+#include <linux/netdevice.h>
+#include <net/dsa.h>
+
+int mv88e6xxx_dst_bridge_to_dsa(const struct dsa_switch_tree *dst,
+ const struct net_device *brdev,
+ u8 *dev, u8 *port);
+
+#endif /* _NET_DSA_MV88E6XXX_H */
--
2.25.1
next prev parent reply other threads:[~2021-04-26 17:05 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-26 17:04 [RFC net-next 0/9] net: bridge: Forward offloading Tobias Waldekranz
2021-04-26 17:04 ` [RFC net-next 1/9] net: dfwd: Constrain existing users to macvlan subordinates Tobias Waldekranz
2021-04-26 17:04 ` [RFC net-next 2/9] net: bridge: Disambiguate offload_fwd_mark Tobias Waldekranz
2021-05-02 15:00 ` Ido Schimmel
2021-05-03 8:49 ` Tobias Waldekranz
2021-05-05 7:39 ` Ido Schimmel
2021-04-26 17:04 ` [RFC net-next 3/9] net: bridge: switchdev: Recycle unused hwdoms Tobias Waldekranz
2021-04-27 10:42 ` Nikolay Aleksandrov
2021-04-26 17:04 ` [RFC net-next 4/9] net: bridge: switchdev: Forward offloading Tobias Waldekranz
2021-04-27 10:35 ` Nikolay Aleksandrov
2021-04-28 22:47 ` Tobias Waldekranz
2021-04-29 9:16 ` Nikolay Aleksandrov
2021-04-29 14:55 ` Tobias Waldekranz
2021-05-02 15:04 ` Ido Schimmel
2021-05-03 8:53 ` Tobias Waldekranz
2021-05-06 11:01 ` Vladimir Oltean
2021-04-26 17:04 ` [RFC net-next 5/9] net: dsa: Track port PVIDs Tobias Waldekranz
2021-04-26 19:40 ` Vladimir Oltean
2021-04-26 20:05 ` Tobias Waldekranz
2021-04-26 20:28 ` Vladimir Oltean
2021-04-27 9:12 ` Tobias Waldekranz
2021-04-27 9:27 ` Vladimir Oltean
2021-04-27 10:07 ` Vladimir Oltean
2021-04-28 23:10 ` Tobias Waldekranz
2021-04-26 17:04 ` [RFC net-next 6/9] net: dsa: Forward offloading Tobias Waldekranz
2021-04-27 10:17 ` Vladimir Oltean
2021-05-04 14:44 ` Tobias Waldekranz
2021-05-04 15:21 ` Vladimir Oltean
2021-05-04 20:07 ` Tobias Waldekranz
2021-05-04 20:33 ` Andrew Lunn
2021-05-04 21:24 ` Tobias Waldekranz
2021-05-04 20:58 ` Vladimir Oltean
2021-05-04 22:12 ` Tobias Waldekranz
2021-05-04 23:04 ` Vladimir Oltean
2021-05-05 9:01 ` Tobias Waldekranz
2021-05-05 16:12 ` Vladimir Oltean
2021-04-26 17:04 ` [RFC net-next 7/9] net: dsa: mv88e6xxx: Allocate a virtual DSA port for each bridge Tobias Waldekranz
2021-04-26 17:04 ` Tobias Waldekranz [this message]
2021-04-26 17:04 ` [RFC net-next 9/9] net: dsa: mv88e6xxx: Forward offloading Tobias Waldekranz
2021-05-02 14:58 ` [RFC net-next 0/9] net: bridge: " Ido Schimmel
2021-05-03 9:44 ` Tobias Waldekranz
2021-05-06 10:59 ` Vladimir Oltean
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=20210426170411.1789186-9-tobias@waldekranz.com \
--to=tobias@waldekranz.com \
--cc=andrew@lunn.ch \
--cc=bridge@lists.linux-foundation.org \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=idosch@idosch.org \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nikolay@nvidia.com \
--cc=olteanv@gmail.com \
--cc=roopa@nvidia.com \
--cc=stephen@networkplumber.org \
--cc=vivien.didelot@gmail.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;
as well as URLs for NNTP newsgroup(s).