This b53 backport significantly stabilizes switch traffic performance.
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
#include <linux/delay.h>
#include <linux/export.h>
#include <linux/gpio.h>
-@@ -2533,8 +2531,9 @@ int b53_switch_detect(struct b53_device
+@@ -2567,8 +2565,9 @@ int b53_switch_detect(struct b53_device
dev->chip_id = id32;
break;
default:
return -ENODEV;
}
}
-@@ -2564,7 +2563,8 @@ int b53_switch_register(struct b53_devic
+@@ -2598,7 +2597,8 @@ int b53_switch_register(struct b53_devic
if (ret)
return ret;
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
-@@ -755,8 +755,11 @@ static int b53_switch_reset(struct b53_d
+@@ -768,8 +768,11 @@ static int b53_switch_reset(struct b53_d
usleep_range(1000, 2000);
} while (timeout-- > 0);
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
-@@ -2329,6 +2329,22 @@ static const struct b53_chip_data b53_sw
+@@ -2363,6 +2363,22 @@ static const struct b53_chip_data b53_sw
.jumbo_pm_reg = B53_JUMBO_PORT_MASK,
.jumbo_size_reg = B53_JUMBO_MAX_SIZE,
},
--- /dev/null
+From 4d776482ecc689bdd68627985ac4cb5a6f325953 Mon Sep 17 00:00:00 2001
+From: Florian Fainelli <f.fainelli@gmail.com>
+Date: Tue, 7 Jan 2020 21:06:05 -0800
+Subject: [PATCH] net: dsa: Get information about stacked DSA protocol
+
+It is possible to stack multiple DSA switches in a way that they are not
+part of the tree (disjoint) but the DSA master of a switch is a DSA
+slave of another. When that happens switch drivers may have to know this
+is the case so as to determine whether their tagging protocol has a
+remove chance of working.
+
+This is useful for specific switch drivers such as b53 where devices
+have been known to be stacked in the wild without the Broadcom tag
+protocol supporting that feature. This allows b53 to continue supporting
+those devices by forcing the disabling of Broadcom tags on the outermost
+switches if necessary.
+
+The get_tag_protocol() function is therefore updated to gain an
+additional enum dsa_tag_protocol argument which denotes the current
+tagging protocol used by the DSA master we are attached to, else
+DSA_TAG_PROTO_NONE for the top of the dsa_switch_tree.
+
+Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+---
+ drivers/net/dsa/b53/b53_common.c | 22 +++++++++++-------
+ drivers/net/dsa/b53/b53_priv.h | 4 +++-
+ drivers/net/dsa/dsa_loop.c | 3 ++-
+ drivers/net/dsa/lan9303-core.c | 3 ++-
+ drivers/net/dsa/lantiq_gswip.c | 3 ++-
+ drivers/net/dsa/microchip/ksz8795.c | 3 ++-
+ drivers/net/dsa/microchip/ksz9477.c | 3 ++-
+ drivers/net/dsa/mt7530.c | 3 ++-
+ drivers/net/dsa/mv88e6060.c | 3 ++-
+ drivers/net/dsa/mv88e6xxx/chip.c | 3 ++-
+ drivers/net/dsa/ocelot/felix.c | 3 ++-
+ drivers/net/dsa/qca/ar9331.c | 3 ++-
+ drivers/net/dsa/qca8k.c | 3 ++-
+ drivers/net/dsa/rtl8366rb.c | 3 ++-
+ drivers/net/dsa/sja1105/sja1105_main.c | 3 ++-
+ drivers/net/dsa/vitesse-vsc73xx-core.c | 3 ++-
+ include/net/dsa.h | 3 ++-
+ net/dsa/dsa2.c | 31 ++++++++++++++++++++++++--
+ net/dsa/dsa_priv.h | 1 +
+ net/dsa/slave.c | 4 +---
+ 20 files changed, 78 insertions(+), 29 deletions(-)
+
+--- a/drivers/net/dsa/b53/b53_common.c
++++ b/drivers/net/dsa/b53/b53_common.c
+@@ -587,9 +587,8 @@ EXPORT_SYMBOL(b53_disable_port);
+
+ void b53_brcm_hdr_setup(struct dsa_switch *ds, int port)
+ {
+- bool tag_en = !(ds->ops->get_tag_protocol(ds, port) ==
+- DSA_TAG_PROTO_NONE);
+ struct b53_device *dev = ds->priv;
++ bool tag_en = !(dev->tag_protocol == DSA_TAG_PROTO_NONE);
+ u8 hdr_ctl, val;
+ u16 reg;
+
+@@ -1921,7 +1920,8 @@ static bool b53_can_enable_brcm_tags(str
+ return ret;
+ }
+
+-enum dsa_tag_protocol b53_get_tag_protocol(struct dsa_switch *ds, int port)
++enum dsa_tag_protocol b53_get_tag_protocol(struct dsa_switch *ds, int port,
++ enum dsa_tag_protocol mprot)
+ {
+ struct b53_device *dev = ds->priv;
+
+@@ -1931,16 +1931,22 @@ enum dsa_tag_protocol b53_get_tag_protoc
+ * misses on multicast addresses (TBD).
+ */
+ if (is5325(dev) || is5365(dev) || is539x(dev) || is531x5(dev) ||
+- !b53_can_enable_brcm_tags(ds, port))
+- return DSA_TAG_PROTO_NONE;
++ !b53_can_enable_brcm_tags(ds, port)) {
++ dev->tag_protocol = DSA_TAG_PROTO_NONE;
++ goto out;
++ }
+
+ /* Broadcom BCM58xx chips have a flow accelerator on Port 8
+ * which requires us to use the prepended Broadcom tag type
+ */
+- if (dev->chip_id == BCM58XX_DEVICE_ID && port == B53_CPU_PORT)
+- return DSA_TAG_PROTO_BRCM_PREPEND;
++ if (dev->chip_id == BCM58XX_DEVICE_ID && port == B53_CPU_PORT) {
++ dev->tag_protocol = DSA_TAG_PROTO_BRCM_PREPEND;
++ goto out;
++ }
+
+- return DSA_TAG_PROTO_BRCM;
++ dev->tag_protocol = DSA_TAG_PROTO_BRCM;
++out:
++ return dev->tag_protocol;
+ }
+ EXPORT_SYMBOL(b53_get_tag_protocol);
+
+--- a/drivers/net/dsa/b53/b53_priv.h
++++ b/drivers/net/dsa/b53/b53_priv.h
+@@ -118,6 +118,7 @@ struct b53_device {
+ u8 jumbo_size_reg;
+ int reset_gpio;
+ u8 num_arl_entries;
++ enum dsa_tag_protocol tag_protocol;
+
+ /* used ports mask */
+ u16 enabled_ports;
+@@ -359,7 +360,8 @@ int b53_mdb_del(struct dsa_switch *ds, i
+ const struct switchdev_obj_port_mdb *mdb);
+ int b53_mirror_add(struct dsa_switch *ds, int port,
+ struct dsa_mall_mirror_tc_entry *mirror, bool ingress);
+-enum dsa_tag_protocol b53_get_tag_protocol(struct dsa_switch *ds, int port);
++enum dsa_tag_protocol b53_get_tag_protocol(struct dsa_switch *ds, int port,
++ enum dsa_tag_protocol mprot);
+ void b53_mirror_del(struct dsa_switch *ds, int port,
+ struct dsa_mall_mirror_tc_entry *mirror);
+ int b53_enable_port(struct dsa_switch *ds, int port, struct phy_device *phy);
+--- a/drivers/net/dsa/dsa_loop.c
++++ b/drivers/net/dsa/dsa_loop.c
+@@ -61,7 +61,8 @@ struct dsa_loop_priv {
+ static struct phy_device *phydevs[PHY_MAX_ADDR];
+
+ static enum dsa_tag_protocol dsa_loop_get_protocol(struct dsa_switch *ds,
+- int port)
++ int port,
++ enum dsa_tag_protocol mp)
+ {
+ dev_dbg(ds->dev, "%s: port: %d\n", __func__, port);
+
+--- a/drivers/net/dsa/lan9303-core.c
++++ b/drivers/net/dsa/lan9303-core.c
+@@ -889,7 +889,8 @@ static int lan9303_check_device(struct l
+ /* ---------------------------- DSA -----------------------------------*/
+
+ static enum dsa_tag_protocol lan9303_get_tag_protocol(struct dsa_switch *ds,
+- int port)
++ int port,
++ enum dsa_tag_protocol mp)
+ {
+ return DSA_TAG_PROTO_LAN9303;
+ }
+--- a/drivers/net/dsa/lantiq_gswip.c
++++ b/drivers/net/dsa/lantiq_gswip.c
+@@ -860,7 +860,8 @@ static int gswip_setup(struct dsa_switch
+ }
+
+ static enum dsa_tag_protocol gswip_get_tag_protocol(struct dsa_switch *ds,
+- int port)
++ int port,
++ enum dsa_tag_protocol mp)
+ {
+ return DSA_TAG_PROTO_GSWIP;
+ }
+--- a/drivers/net/dsa/microchip/ksz8795.c
++++ b/drivers/net/dsa/microchip/ksz8795.c
+@@ -645,7 +645,8 @@ static void ksz8795_w_phy(struct ksz_dev
+ }
+
+ static enum dsa_tag_protocol ksz8795_get_tag_protocol(struct dsa_switch *ds,
+- int port)
++ int port,
++ enum dsa_tag_protocol mp)
+ {
+ return DSA_TAG_PROTO_KSZ8795;
+ }
+--- a/drivers/net/dsa/microchip/ksz9477.c
++++ b/drivers/net/dsa/microchip/ksz9477.c
+@@ -295,7 +295,8 @@ static void ksz9477_port_init_cnt(struct
+ }
+
+ static enum dsa_tag_protocol ksz9477_get_tag_protocol(struct dsa_switch *ds,
+- int port)
++ int port,
++ enum dsa_tag_protocol mp)
+ {
+ enum dsa_tag_protocol proto = DSA_TAG_PROTO_KSZ9477;
+ struct ksz_device *dev = ds->priv;
+--- a/drivers/net/dsa/mt7530.c
++++ b/drivers/net/dsa/mt7530.c
+@@ -1144,7 +1144,8 @@ mt7530_port_vlan_del(struct dsa_switch *
+ }
+
+ static enum dsa_tag_protocol
+-mtk_get_tag_protocol(struct dsa_switch *ds, int port)
++mtk_get_tag_protocol(struct dsa_switch *ds, int port,
++ enum dsa_tag_protocol mp)
+ {
+ struct mt7530_priv *priv = ds->priv;
+
+--- a/drivers/net/dsa/mv88e6060.c
++++ b/drivers/net/dsa/mv88e6060.c
+@@ -43,7 +43,8 @@ static const char *mv88e6060_get_name(st
+ }
+
+ static enum dsa_tag_protocol mv88e6060_get_tag_protocol(struct dsa_switch *ds,
+- int port)
++ int port,
++ enum dsa_tag_protocol m)
+ {
+ return DSA_TAG_PROTO_TRAILER;
+ }
+--- a/drivers/net/dsa/mv88e6xxx/chip.c
++++ b/drivers/net/dsa/mv88e6xxx/chip.c
+@@ -4878,7 +4878,8 @@ static struct mv88e6xxx_chip *mv88e6xxx_
+ }
+
+ static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
+- int port)
++ int port,
++ enum dsa_tag_protocol m)
+ {
+ struct mv88e6xxx_chip *chip = ds->priv;
+
+--- a/drivers/net/dsa/qca8k.c
++++ b/drivers/net/dsa/qca8k.c
+@@ -1016,7 +1016,8 @@ qca8k_port_fdb_dump(struct dsa_switch *d
+ }
+
+ static enum dsa_tag_protocol
+-qca8k_get_tag_protocol(struct dsa_switch *ds, int port)
++qca8k_get_tag_protocol(struct dsa_switch *ds, int port,
++ enum dsa_tag_protocol mp)
+ {
+ return DSA_TAG_PROTO_QCA;
+ }
+--- a/drivers/net/dsa/rtl8366rb.c
++++ b/drivers/net/dsa/rtl8366rb.c
+@@ -964,7 +964,8 @@ static int rtl8366rb_setup(struct dsa_sw
+ }
+
+ static enum dsa_tag_protocol rtl8366_get_tag_protocol(struct dsa_switch *ds,
+- int port)
++ int port,
++ enum dsa_tag_protocol mp)
+ {
+ /* For now, the RTL switches are handled without any custom tags.
+ *
+--- a/drivers/net/dsa/sja1105/sja1105_main.c
++++ b/drivers/net/dsa/sja1105/sja1105_main.c
+@@ -1591,7 +1591,8 @@ static int sja1105_setup_8021q_tagging(s
+ }
+
+ static enum dsa_tag_protocol
+-sja1105_get_tag_protocol(struct dsa_switch *ds, int port)
++sja1105_get_tag_protocol(struct dsa_switch *ds, int port,
++ enum dsa_tag_protocol mp)
+ {
+ return DSA_TAG_PROTO_SJA1105;
+ }
+--- a/drivers/net/dsa/vitesse-vsc73xx-core.c
++++ b/drivers/net/dsa/vitesse-vsc73xx-core.c
+@@ -542,7 +542,8 @@ static int vsc73xx_phy_write(struct dsa_
+ }
+
+ static enum dsa_tag_protocol vsc73xx_get_tag_protocol(struct dsa_switch *ds,
+- int port)
++ int port,
++ enum dsa_tag_protocol mp)
+ {
+ /* The switch internally uses a 8 byte header with length,
+ * source port, tag, LPA and priority. This is supposedly
+--- a/include/net/dsa.h
++++ b/include/net/dsa.h
+@@ -353,7 +353,8 @@ typedef int dsa_fdb_dump_cb_t(const unsi
+ bool is_static, void *data);
+ struct dsa_switch_ops {
+ enum dsa_tag_protocol (*get_tag_protocol)(struct dsa_switch *ds,
+- int port);
++ int port,
++ enum dsa_tag_protocol mprot);
+
+ int (*setup)(struct dsa_switch *ds);
+ void (*teardown)(struct dsa_switch *ds);
+--- a/net/dsa/dsa2.c
++++ b/net/dsa/dsa2.c
+@@ -631,6 +631,32 @@ static int dsa_port_parse_dsa(struct dsa
+ return 0;
+ }
+
++static enum dsa_tag_protocol dsa_get_tag_protocol(struct dsa_port *dp,
++ struct net_device *master)
++{
++ enum dsa_tag_protocol tag_protocol = DSA_TAG_PROTO_NONE;
++ struct dsa_switch *mds, *ds = dp->ds;
++ unsigned int mdp_upstream;
++ struct dsa_port *mdp;
++
++ /* It is possible to stack DSA switches onto one another when that
++ * happens the switch driver may want to know if its tagging protocol
++ * is going to work in such a configuration.
++ */
++ if (dsa_slave_dev_check(master)) {
++ mdp = dsa_slave_to_port(master);
++ mds = mdp->ds;
++ mdp_upstream = dsa_upstream_port(mds, mdp->index);
++ tag_protocol = mds->ops->get_tag_protocol(mds, mdp_upstream,
++ DSA_TAG_PROTO_NONE);
++ }
++
++ /* If the master device is not itself a DSA slave in a disjoint DSA
++ * tree, then return immediately.
++ */
++ return ds->ops->get_tag_protocol(ds, dp->index, tag_protocol);
++}
++
+ static int dsa_port_parse_cpu(struct dsa_port *dp, struct net_device *master)
+ {
+ struct dsa_switch *ds = dp->ds;
+@@ -638,20 +664,21 @@ static int dsa_port_parse_cpu(struct dsa
+ const struct dsa_device_ops *tag_ops;
+ enum dsa_tag_protocol tag_protocol;
+
+- tag_protocol = ds->ops->get_tag_protocol(ds, dp->index);
++ tag_protocol = dsa_get_tag_protocol(dp, master);
+ tag_ops = dsa_tag_driver_get(tag_protocol);
+ if (IS_ERR(tag_ops)) {
+ if (PTR_ERR(tag_ops) == -ENOPROTOOPT)
+ return -EPROBE_DEFER;
+ dev_warn(ds->dev, "No tagger for this switch\n");
++ dp->master = NULL;
+ return PTR_ERR(tag_ops);
+ }
+
++ dp->master = master;
+ dp->type = DSA_PORT_TYPE_CPU;
+ dp->filter = tag_ops->filter;
+ dp->rcv = tag_ops->rcv;
+ dp->tag_ops = tag_ops;
+- dp->master = master;
+ dp->dst = dst;
+
+ return 0;
+--- a/net/dsa/dsa_priv.h
++++ b/net/dsa/dsa_priv.h
+@@ -189,6 +189,7 @@ extern const struct dsa_device_ops notag
+ void dsa_slave_mii_bus_init(struct dsa_switch *ds);
+ int dsa_slave_create(struct dsa_port *dp);
+ void dsa_slave_destroy(struct net_device *slave_dev);
++bool dsa_slave_dev_check(const struct net_device *dev);
+ int dsa_slave_suspend(struct net_device *slave_dev);
+ int dsa_slave_resume(struct net_device *slave_dev);
+ int dsa_slave_register_notifier(void);
+--- a/net/dsa/slave.c
++++ b/net/dsa/slave.c
+@@ -22,8 +22,6 @@
+
+ #include "dsa_priv.h"
+
+-static bool dsa_slave_dev_check(const struct net_device *dev);
+-
+ /* slave mii_bus handling ***************************************************/
+ static int dsa_slave_phy_read(struct mii_bus *bus, int addr, int reg)
+ {
+@@ -1494,7 +1492,7 @@ void dsa_slave_destroy(struct net_device
+ free_netdev(slave_dev);
+ }
+
+-static bool dsa_slave_dev_check(const struct net_device *dev)
++bool dsa_slave_dev_check(const struct net_device *dev)
+ {
+ return dev->netdev_ops == &dsa_slave_netdev_ops;
+ }
--- /dev/null
+From 8fab459e69abfd04a66d76423d18ba853fced4ab Mon Sep 17 00:00:00 2001
+From: Florian Fainelli <f.fainelli@gmail.com>
+Date: Tue, 7 Jan 2020 21:06:06 -0800
+Subject: [PATCH] net: dsa: b53: Enable Broadcom tags for 531x5/539x families
+
+The BCM531x5 and BCM539x families require that the IMP port be enabled
+within the management page and that management mode (SM_SW_FWD_MODE) be
+turned on. Once this is done, everything works as expected, including
+multicast with standalone DSA devices or bridge devices.
+
+Because such switches are frequencly cascaded with other internal
+Broadcom switches on which we want to enable Broadcom tags, update
+b53_can_enable_brcm_tags() to check the kind of DSA master tagging
+protocol being used, if it is one of the two supported Broadcom tagging
+protocols, force DSA_TAG_PROTO_NONE.
+
+Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+---
+ drivers/net/dsa/b53/b53_common.c | 46 +++++++++++++++++++++++++-------
+ 1 file changed, 37 insertions(+), 9 deletions(-)
+
+--- a/drivers/net/dsa/b53/b53_common.c
++++ b/drivers/net/dsa/b53/b53_common.c
+@@ -371,8 +371,6 @@ static void b53_enable_vlan(struct b53_d
+ b53_read8(dev, B53_VLAN_PAGE, B53_VLAN_CTRL5, &vc5);
+ }
+
+- mgmt &= ~SM_SW_FWD_MODE;
+-
+ if (enable) {
+ vc0 |= VC0_VLAN_EN | VC0_VID_CHK_EN | VC0_VID_HASH_VID;
+ vc1 |= VC1_RX_MCST_UNTAG_EN | VC1_RX_MCST_FWD_EN;
+@@ -608,6 +606,22 @@ void b53_brcm_hdr_setup(struct dsa_switc
+ break;
+ }
+
++ /* Enable management mode if tagging is requested */
++ b53_read8(dev, B53_CTRL_PAGE, B53_SWITCH_MODE, &hdr_ctl);
++ if (tag_en)
++ hdr_ctl |= SM_SW_FWD_MODE;
++ else
++ hdr_ctl &= ~SM_SW_FWD_MODE;
++ b53_write8(dev, B53_CTRL_PAGE, B53_SWITCH_MODE, hdr_ctl);
++
++ /* Configure the appropriate IMP port */
++ b53_read8(dev, B53_MGMT_PAGE, B53_GLOBAL_CONFIG, &hdr_ctl);
++ if (port == 8)
++ hdr_ctl |= GC_FRM_MGMT_PORT_MII;
++ else if (port == 5)
++ hdr_ctl |= GC_FRM_MGMT_PORT_M;
++ b53_write8(dev, B53_MGMT_PAGE, B53_GLOBAL_CONFIG, hdr_ctl);
++
+ /* Enable Broadcom tags for IMP port */
+ b53_read8(dev, B53_MGMT_PAGE, B53_BRCM_HDR, &hdr_ctl);
+ if (tag_en)
+@@ -1910,13 +1924,29 @@ static bool b53_possible_cpu_port(struct
+ return false;
+ }
+
+-static bool b53_can_enable_brcm_tags(struct dsa_switch *ds, int port)
++static bool b53_can_enable_brcm_tags(struct dsa_switch *ds, int port,
++ enum dsa_tag_protocol tag_protocol)
+ {
+ bool ret = b53_possible_cpu_port(ds, port);
+
+- if (!ret)
++ if (!ret) {
+ dev_warn(ds->dev, "Port %d is not Broadcom tag capable\n",
+ port);
++ return ret;
++ }
++
++ switch (tag_protocol) {
++ case DSA_TAG_PROTO_BRCM:
++ case DSA_TAG_PROTO_BRCM_PREPEND:
++ dev_warn(ds->dev,
++ "Port %d is stacked to Broadcom tag switch\n", port);
++ ret = false;
++ break;
++ default:
++ ret = true;
++ break;
++ }
++
+ return ret;
+ }
+
+@@ -1926,12 +1956,10 @@ enum dsa_tag_protocol b53_get_tag_protoc
+ struct b53_device *dev = ds->priv;
+
+ /* Older models (5325, 5365) support a different tag format that we do
+- * not support in net/dsa/tag_brcm.c yet. 539x and 531x5 require managed
+- * mode to be turned on which means we need to specifically manage ARL
+- * misses on multicast addresses (TBD).
++ * not support in net/dsa/tag_brcm.c yet.
+ */
+- if (is5325(dev) || is5365(dev) || is539x(dev) || is531x5(dev) ||
+- !b53_can_enable_brcm_tags(ds, port)) {
++ if (is5325(dev) || is5365(dev) ||
++ !b53_can_enable_brcm_tags(ds, port, mprot)) {
+ dev->tag_protocol = DSA_TAG_PROTO_NONE;
+ goto out;
+ }
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
-@@ -1564,7 +1564,6 @@ static int b53_arl_op(struct b53_device
+@@ -1577,7 +1577,6 @@ static int b53_arl_op(struct b53_device
ent.is_valid = !!(ent.port);
}
+}
+
static enum dsa_tag_protocol
- mtk_get_tag_protocol(struct dsa_switch *ds, int port)
- {
-@@ -1520,6 +1578,8 @@ static const struct dsa_switch_ops mt753
+ mtk_get_tag_protocol(struct dsa_switch *ds, int port,
+ enum dsa_tag_protocol mp)
+@@ -1521,6 +1579,8 @@ static const struct dsa_switch_ops mt753
.port_vlan_prepare = mt7530_port_vlan_prepare,
.port_vlan_add = mt7530_port_vlan_add,
.port_vlan_del = mt7530_port_vlan_del,
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
-@@ -4928,6 +4928,80 @@ static int mv88e6xxx_port_mdb_del(struct
+@@ -4929,6 +4929,80 @@ static int mv88e6xxx_port_mdb_del(struct
return err;
}
static int mv88e6xxx_port_egress_floods(struct dsa_switch *ds, int port,
bool unicast, bool multicast)
{
-@@ -4982,6 +5056,8 @@ static const struct dsa_switch_ops mv88e
+@@ -4983,6 +5057,8 @@ static const struct dsa_switch_ops mv88e
.port_mdb_prepare = mv88e6xxx_port_mdb_prepare,
.port_mdb_add = mv88e6xxx_port_mdb_add,
.port_mdb_del = mv88e6xxx_port_mdb_del,
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
-@@ -4995,7 +4995,7 @@ static void mv88e6xxx_port_mirror_del(st
+@@ -4996,7 +4996,7 @@ static void mv88e6xxx_port_mirror_del(st
if (chip->info->ops->set_egress_port(chip,
direction,
dsa_upstream_port(ds,
{
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
-@@ -319,7 +319,7 @@ static int dsa_slave_vlan_add(struct net
+@@ -317,7 +317,7 @@ static int dsa_slave_vlan_add(struct net
if (obj->orig_dev != dev)
return -EOPNOTSUPP;
return 0;
vlan = *SWITCHDEV_OBJ_PORT_VLAN(obj);
-@@ -386,7 +386,7 @@ static int dsa_slave_vlan_del(struct net
+@@ -384,7 +384,7 @@ static int dsa_slave_vlan_del(struct net
if (obj->orig_dev != dev)
return -EOPNOTSUPP;
return 0;
/* Do not deprogram the CPU port as it may be shared with other user
-@@ -1120,7 +1120,7 @@ static int dsa_slave_vlan_rx_add_vid(str
+@@ -1118,7 +1118,7 @@ static int dsa_slave_vlan_rx_add_vid(str
* need to emulate the switchdev prepare + commit phase.
*/
if (dp->bridge_dev) {
return 0;
/* br_vlan_get_info() returns -EINVAL or -ENOENT if the
-@@ -1154,7 +1154,7 @@ static int dsa_slave_vlan_rx_kill_vid(st
+@@ -1152,7 +1152,7 @@ static int dsa_slave_vlan_rx_kill_vid(st
* need to emulate the switchdev prepare + commit phase.
*/
if (dp->bridge_dev) {
mutex_lock(&priv->reg_mutex);
pvid = priv->ports[port].pvid;
-@@ -1232,6 +1220,7 @@ mt7530_setup(struct dsa_switch *ds)
+@@ -1233,6 +1221,7 @@ mt7530_setup(struct dsa_switch *ds)
* as two netdev instances.
*/
dn = ds->ports[MT7530_CPU_PORT].master->dev.of_node->parent;
if (ret)
return ret;
-@@ -966,21 +964,8 @@ static int rtl8366rb_setup(struct dsa_sw
- static enum dsa_tag_protocol rtl8366_get_tag_protocol(struct dsa_switch *ds,
- int port)
+@@ -967,21 +965,8 @@ static enum dsa_tag_protocol rtl8366_get
+ int port,
+ enum dsa_tag_protocol mp)
{
- /* For now, the RTL switches are handled without any custom tags.
- *
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
-@@ -70,8 +70,11 @@ static int dsa_slave_open(struct net_dev
+@@ -68,8 +68,11 @@ static int dsa_slave_open(struct net_dev
struct dsa_port *dp = dsa_slave_to_port(dev);
int err;
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
-@@ -1593,7 +1593,9 @@ static void dsa_slave_switchdev_event_wo
+@@ -1591,7 +1591,9 @@ static void dsa_slave_switchdev_event_wo
err = dsa_port_fdb_add(dp, fdb_info->addr, fdb_info->vid);
if (err) {
break;
}
fdb_info->offloaded = true;
-@@ -1608,9 +1610,11 @@ static void dsa_slave_switchdev_event_wo
+@@ -1606,9 +1608,11 @@ static void dsa_slave_switchdev_event_wo
err = dsa_port_fdb_del(dp, fdb_info->addr, fdb_info->vid);
if (err) {
struct sk_buff * (*xmit)(struct sk_buff *skb,
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
-@@ -1568,76 +1568,66 @@ static int dsa_slave_netdevice_event(str
+@@ -1566,76 +1566,66 @@ static int dsa_slave_netdevice_event(str
return NOTIFY_DONE;
}
}
/* Called under rcu_read_lock() */
-@@ -1645,7 +1635,9 @@ static int dsa_slave_switchdev_event(str
+@@ -1643,7 +1633,9 @@ static int dsa_slave_switchdev_event(str
unsigned long event, void *ptr)
{
struct net_device *dev = switchdev_notifier_info_to_dev(ptr);
int err;
if (event == SWITCHDEV_PORT_ATTR_SET) {
-@@ -1658,20 +1650,32 @@ static int dsa_slave_switchdev_event(str
+@@ -1656,20 +1648,32 @@ static int dsa_slave_switchdev_event(str
if (!dsa_slave_dev_check(dev))
return NOTIFY_DONE;
dev_hold(dev);
break;
default:
-@@ -1681,10 +1685,6 @@ static int dsa_slave_switchdev_event(str
+@@ -1679,10 +1683,6 @@ static int dsa_slave_switchdev_event(str
dsa_schedule_work(&switchdev_work->work);
return NOTIFY_OK;
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
-@@ -1640,31 +1640,29 @@ static int dsa_slave_switchdev_event(str
+@@ -1638,31 +1638,29 @@ static int dsa_slave_switchdev_event(str
struct dsa_port *dp;
int err;
fdb_info = ptr;
if (!fdb_info->added_by_user) {
-@@ -1677,13 +1675,12 @@ static int dsa_slave_switchdev_event(str
+@@ -1675,13 +1673,12 @@ static int dsa_slave_switchdev_event(str
switchdev_work->vid = fdb_info->vid;
dev_hold(dev);
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
-@@ -1653,6 +1653,9 @@ static int dsa_slave_switchdev_event(str
+@@ -1651,6 +1651,9 @@ static int dsa_slave_switchdev_event(str
dp = dsa_slave_to_port(dev);
*/
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
-@@ -1630,6 +1630,25 @@ static void dsa_slave_switchdev_event_wo
+@@ -1628,6 +1628,25 @@ static void dsa_slave_switchdev_event_wo
dev_put(dp->slave);
}
/* Called under rcu_read_lock() */
static int dsa_slave_switchdev_event(struct notifier_block *unused,
unsigned long event, void *ptr)
-@@ -1648,10 +1667,37 @@ static int dsa_slave_switchdev_event(str
+@@ -1646,10 +1665,37 @@ static int dsa_slave_switchdev_event(str
return notifier_from_errno(err);
case SWITCHDEV_FDB_ADD_TO_DEVICE:
case SWITCHDEV_FDB_DEL_TO_DEVICE:
if (!dp->ds->ops->port_fdb_add || !dp->ds->ops->port_fdb_del)
return NOTIFY_DONE;
-@@ -1666,18 +1712,13 @@ static int dsa_slave_switchdev_event(str
+@@ -1664,18 +1710,13 @@ static int dsa_slave_switchdev_event(str
switchdev_work->port = dp->index;
switchdev_work->event = event;
#include "dsa_priv.h"
-@@ -1226,6 +1230,27 @@ static struct devlink_port *dsa_slave_ge
+@@ -1224,6 +1228,27 @@ static struct devlink_port *dsa_slave_ge
return dp->ds->devlink ? &dp->devlink_port : NULL;
}
static const struct net_device_ops dsa_slave_netdev_ops = {
.ndo_open = dsa_slave_open,
.ndo_stop = dsa_slave_close,
-@@ -1250,6 +1275,9 @@ static const struct net_device_ops dsa_s
+@@ -1248,6 +1273,9 @@ static const struct net_device_ops dsa_s
.ndo_vlan_rx_add_vid = dsa_slave_vlan_rx_add_vid,
.ndo_vlan_rx_kill_vid = dsa_slave_vlan_rx_kill_vid,
.ndo_get_devlink_port = dsa_slave_get_devlink_port,
Signed-off-by: René van Dorst <opensource@vdorst.com>
--- a/drivers/net/dsa/mt7530.c
+++ b/drivers/net/dsa/mt7530.c
-@@ -1407,9 +1407,13 @@ static void mt7530_phylink_mac_config(st
+@@ -1408,9 +1408,13 @@ static void mt7530_phylink_mac_config(st
switch (state->speed) {
case SPEED_1000:
mcr_new |= PMCR_FORCE_SPEED_1000;
break;
}
if (state->duplex == DUPLEX_FULL) {
-@@ -1545,6 +1549,54 @@ mt7530_phylink_mac_link_state(struct dsa
+@@ -1546,6 +1550,54 @@ mt7530_phylink_mac_link_state(struct dsa
return 1;
}
static const struct dsa_switch_ops mt7530_switch_ops = {
.get_tag_protocol = mtk_get_tag_protocol,
.setup = mt7530_setup,
-@@ -1572,6 +1624,8 @@ static const struct dsa_switch_ops mt753
+@@ -1573,6 +1625,8 @@ static const struct dsa_switch_ops mt753
.phylink_mac_config = mt7530_phylink_mac_config,
.phylink_mac_link_down = mt7530_phylink_mac_link_down,
.phylink_mac_link_up = mt7530_phylink_mac_link_up,
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
-@@ -1698,10 +1698,12 @@ static int dsa_slave_switchdev_event(str
+@@ -1696,10 +1696,12 @@ static int dsa_slave_switchdev_event(str
fdb_info = ptr;
if (dsa_slave_dev_check(dev)) {
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
-@@ -1712,7 +1712,11 @@ static int dsa_slave_switchdev_event(str
+@@ -1710,7 +1710,11 @@ static int dsa_slave_switchdev_event(str
struct net_device *br_dev;
struct dsa_slave_priv *p;
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
-@@ -1705,9 +1705,12 @@ static int dsa_slave_switchdev_event(str
+@@ -1703,9 +1703,12 @@ static int dsa_slave_switchdev_event(str
else if (!fdb_info->added_by_user)
return NOTIFY_OK;
} else {
*/
struct net_device *br_dev;
struct dsa_slave_priv *p;
-@@ -1729,7 +1732,8 @@ static int dsa_slave_switchdev_event(str
+@@ -1727,7 +1730,8 @@ static int dsa_slave_switchdev_event(str
dp = p->dp->cpu_dp;
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
-@@ -5082,6 +5082,7 @@ static int mv88e6xxx_register_switch(str
+@@ -5083,6 +5083,7 @@ static int mv88e6xxx_register_switch(str
ds->ops = &mv88e6xxx_switch_ops;
ds->ageing_time_min = chip->info->age_time_coeff;
ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
static const u32 vsc9959_gcb_regmap[] = {
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
-@@ -559,6 +559,7 @@ struct dsa_switch_ops {
+@@ -560,6 +560,7 @@ struct dsa_switch_ops {
*/
netdev_tx_t (*port_deferred_xmit)(struct dsa_switch *ds, int port,
struct sk_buff *skb);
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
-@@ -1284,7 +1284,9 @@ EXPORT_SYMBOL(b53_phylink_mac_link_down)
+@@ -1297,7 +1297,9 @@ EXPORT_SYMBOL(b53_phylink_mac_link_down)
void b53_phylink_mac_link_up(struct dsa_switch *ds, int port,
unsigned int mode,
phy_interface_t interface,
--- a/drivers/net/dsa/b53/b53_priv.h
+++ b/drivers/net/dsa/b53/b53_priv.h
-@@ -337,7 +337,9 @@ void b53_phylink_mac_link_down(struct ds
+@@ -338,7 +338,9 @@ void b53_phylink_mac_link_down(struct ds
void b53_phylink_mac_link_up(struct dsa_switch *ds, int port,
unsigned int mode,
phy_interface_t interface,
struct ethtool_eee *p = &priv->dev->ports[port].eee;
--- a/drivers/net/dsa/lantiq_gswip.c
+++ b/drivers/net/dsa/lantiq_gswip.c
-@@ -1661,7 +1661,9 @@ static void gswip_phylink_mac_link_down(
+@@ -1662,7 +1662,9 @@ static void gswip_phylink_mac_link_down(
static void gswip_phylink_mac_link_up(struct dsa_switch *ds, int port,
unsigned int mode,
phy_interface_t interface,
--- a/drivers/net/dsa/mt7530.c
+++ b/drivers/net/dsa/mt7530.c
-@@ -1440,7 +1440,9 @@ static void mt7530_phylink_mac_link_down
+@@ -1441,7 +1441,9 @@ static void mt7530_phylink_mac_link_down
static void mt7530_phylink_mac_link_up(struct dsa_switch *ds, int port,
unsigned int mode,
phy_interface_t interface,
}
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
-@@ -406,7 +406,9 @@ struct dsa_switch_ops {
+@@ -407,7 +407,9 @@ struct dsa_switch_ops {
void (*phylink_mac_link_up)(struct dsa_switch *ds, int port,
unsigned int mode,
phy_interface_t interface,
mutex_unlock(&priv->reg_mutex);
}
-@@ -1395,8 +1384,7 @@ static void mt7530_phylink_mac_config(st
+@@ -1396,8 +1385,7 @@ static void mt7530_phylink_mac_config(st
mcr_cur = mt7530_read(priv, MT7530_PMCR_P(port));
mcr_new = mcr_cur;
mcr_new |= PMCR_IFG_XMIT(1) | PMCR_MAC_MODE | PMCR_BACKOFF_EN |
PMCR_BACKPR_EN | PMCR_FORCE_MODE;
-@@ -1404,26 +1392,6 @@ static void mt7530_phylink_mac_config(st
+@@ -1405,26 +1393,6 @@ static void mt7530_phylink_mac_config(st
if (port == 5 && dsa_is_user_port(ds, 5))
mcr_new |= PMCR_EXT_PHY;
if (mcr_new != mcr_cur)
mt7530_write(priv, MT7530_PMCR_P(port), mcr_new);
}
-@@ -1434,7 +1402,7 @@ static void mt7530_phylink_mac_link_down
+@@ -1435,7 +1403,7 @@ static void mt7530_phylink_mac_link_down
{
struct mt7530_priv *priv = ds->priv;
}
static void mt7530_phylink_mac_link_up(struct dsa_switch *ds, int port,
-@@ -1445,8 +1413,31 @@ static void mt7530_phylink_mac_link_up(s
+@@ -1446,8 +1414,31 @@ static void mt7530_phylink_mac_link_up(s
bool tx_pause, bool rx_pause)
{
struct mt7530_priv *priv = ds->priv;
return -EINVAL;
}
-@@ -1332,12 +1334,11 @@ mt7530_setup(struct dsa_switch *ds)
+@@ -1333,12 +1335,11 @@ mt7530_setup(struct dsa_switch *ds)
return 0;
}
switch (port) {
case 0: /* Internal phy */
-@@ -1346,33 +1347,114 @@ static void mt7530_phylink_mac_config(st
+@@ -1347,33 +1348,114 @@ static void mt7530_phylink_mac_config(st
case 3:
case 4:
if (state->interface != PHY_INTERFACE_MODE_GMII)
return;
}
-@@ -1440,61 +1522,44 @@ static void mt7530_phylink_mac_link_up(s
+@@ -1441,61 +1523,44 @@ static void mt7530_phylink_mac_link_up(s
mt7530_set(priv, MT7530_PMCR_P(port), mcr);
}
phylink_set(mask, Pause);
phylink_set(mask, Asym_Pause);
-@@ -1590,12 +1655,45 @@ static int mt7530_set_mac_eee(struct dsa
+@@ -1591,12 +1656,45 @@ static int mt7530_set_mac_eee(struct dsa
return 0;
}
.get_ethtool_stats = mt7530_get_ethtool_stats,
.get_sset_count = mt7530_get_sset_count,
.port_enable = mt7530_port_enable,
-@@ -1612,18 +1710,43 @@ static const struct dsa_switch_ops mt753
+@@ -1613,18 +1711,43 @@ static const struct dsa_switch_ops mt753
.port_vlan_del = mt7530_port_vlan_del,
.port_mirror_add = mt7530_port_mirror_add,
.port_mirror_del = mt7530_port_mirror_del,
{ /* sentinel */ },
};
MODULE_DEVICE_TABLE(of, mt7530_of_match);
-@@ -1661,8 +1784,21 @@ mt7530_probe(struct mdio_device *mdiodev
+@@ -1662,8 +1785,21 @@ mt7530_probe(struct mdio_device *mdiodev
/* Get the hardware identifier from the devicetree node.
* We will need it for some of the clock and regulator setup.
*/
}
}
-@@ -1280,7 +1619,7 @@ mt7530_setup(struct dsa_switch *ds)
+@@ -1281,7 +1620,7 @@ mt7530_setup(struct dsa_switch *ds)
PCR_MATRIX_CLR);
if (dsa_is_cpu_port(ds, i))
else
mt7530_port_disable(ds, i);
-@@ -1334,6 +1673,118 @@ mt7530_setup(struct dsa_switch *ds)
+@@ -1335,6 +1674,118 @@ mt7530_setup(struct dsa_switch *ds)
return 0;
}
static bool
mt7530_phy_mode_supported(struct dsa_switch *ds, int port,
const struct phylink_link_state *state)
-@@ -1372,6 +1823,47 @@ unsupported:
+@@ -1373,6 +1824,47 @@ unsupported:
return false;
}
static bool
mt753x_phy_mode_supported(struct dsa_switch *ds, int port,
const struct phylink_link_state *state)
-@@ -1404,6 +1896,227 @@ mt7530_mac_config(struct dsa_switch *ds,
+@@ -1405,6 +1897,227 @@ mt7530_mac_config(struct dsa_switch *ds,
return 0;
}
static int
mt753x_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
const struct phylink_link_state *state)
-@@ -1439,6 +2152,8 @@ mt753x_phylink_mac_config(struct dsa_swi
+@@ -1440,6 +2153,8 @@ mt753x_phylink_mac_config(struct dsa_swi
if (mt753x_mac_config(ds, port, mode, state) < 0)
goto unsupported;
break;
case 6: /* 1st cpu port */
if (priv->p6_interface == state->interface)
-@@ -1458,7 +2173,8 @@ unsupported:
+@@ -1459,7 +2174,8 @@ unsupported:
return;
}
dev_err(ds->dev, "%s: in-band negotiation unsupported\n",
__func__);
return;
-@@ -1468,7 +2184,7 @@ unsupported:
+@@ -1469,7 +2185,7 @@ unsupported:
mcr_new = mcr_cur;
mcr_new &= ~PMCR_LINK_SETTINGS_MASK;
mcr_new |= PMCR_IFG_XMIT(1) | PMCR_MAC_MODE | PMCR_BACKOFF_EN |
/* Are we connected to external phy */
if (port == 5 && dsa_is_user_port(ds, 5))
-@@ -1478,7 +2194,18 @@ unsupported:
+@@ -1479,7 +2195,18 @@ unsupported:
mt7530_write(priv, MT7530_PMCR_P(port), mcr_new);
}
unsigned int mode,
phy_interface_t interface)
{
-@@ -1487,7 +2214,19 @@ static void mt7530_phylink_mac_link_down
+@@ -1488,7 +2215,19 @@ static void mt7530_phylink_mac_link_down
mt7530_clear(priv, MT7530_PMCR_P(port), PMCR_LINK_SETTINGS_MASK);
}
unsigned int mode,
phy_interface_t interface,
struct phy_device *phydev,
-@@ -1497,18 +2236,29 @@ static void mt7530_phylink_mac_link_up(s
+@@ -1498,18 +2237,29 @@ static void mt7530_phylink_mac_link_up(s
struct mt7530_priv *priv = ds->priv;
u32 mcr;
break;
}
if (duplex == DUPLEX_FULL) {
-@@ -1522,6 +2272,45 @@ static void mt7530_phylink_mac_link_up(s
+@@ -1523,6 +2273,45 @@ static void mt7530_phylink_mac_link_up(s
mt7530_set(priv, MT7530_PMCR_P(port), mcr);
}
static void
mt7530_mac_port_validate(struct dsa_switch *ds, int port,
unsigned long *supported)
-@@ -1530,6 +2319,14 @@ mt7530_mac_port_validate(struct dsa_swit
+@@ -1531,6 +2320,14 @@ mt7530_mac_port_validate(struct dsa_swit
phylink_set(supported, 1000baseX_Full);
}
static void
mt753x_phylink_validate(struct dsa_switch *ds, int port,
unsigned long *supported,
-@@ -1546,7 +2343,8 @@ mt753x_phylink_validate(struct dsa_switc
+@@ -1547,7 +2344,8 @@ mt753x_phylink_validate(struct dsa_switc
phylink_set_port_modes(mask);
phylink_set(mask, 10baseT_Half);
phylink_set(mask, 10baseT_Full);
phylink_set(mask, 100baseT_Half);
-@@ -1565,6 +2363,11 @@ mt753x_phylink_validate(struct dsa_switc
+@@ -1566,6 +2364,11 @@ mt753x_phylink_validate(struct dsa_switc
linkmode_and(supported, supported, mask);
linkmode_and(state->advertising, state->advertising, mask);
}
static int
-@@ -1655,6 +2458,63 @@ static int mt7530_set_mac_eee(struct dsa
+@@ -1656,6 +2459,63 @@ static int mt7530_set_mac_eee(struct dsa
return 0;
}
static int
mt753x_phylink_mac_link_state(struct dsa_switch *ds, int port,
struct phylink_link_state *state)
-@@ -1708,13 +2568,14 @@ static const struct dsa_switch_ops mt753
+@@ -1709,13 +2569,14 @@ static const struct dsa_switch_ops mt753
.port_vlan_prepare = mt7530_port_vlan_prepare,
.port_vlan_add = mt7530_port_vlan_add,
.port_vlan_del = mt7530_port_vlan_del,
.get_mac_eee = mt7530_get_mac_eee,
.set_mac_eee = mt7530_set_mac_eee,
};
-@@ -1742,11 +2603,26 @@ static const struct mt753x_info mt753x_t
+@@ -1743,11 +2604,26 @@ static const struct mt753x_info mt753x_t
.mac_port_get_state = mt7530_phylink_mac_link_state,
.mac_port_config = mt7530_mac_config,
},