diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
index 3bfe29b3b93e..09b7e9d2d025 100644
--- a/drivers/net/dsa/mt7530.c
+++ b/drivers/net/dsa/mt7530.c
@@ -193,6 +193,11 @@ mt7530_fdb_cmd(struct mt7530_priv *priv, enum mt7530_fdb_cmd cmd, u32 *rsp)
return 0;
}
+static void mt7530_passthrough_port_fast_age(struct dsa_switch *ds,
+ int port)
+{
+}
+
static void mt7530_port_fast_age(struct dsa_switch *ds, int port)
{
struct mt7530_priv *priv = ds->priv;@@ -960,6 +965,12 @@ static void mt7530_get_eth_ctrl_stats(struct dsa_switch *ds, int port,
&ctrl_stats->MACControlFramesReceived);
}
+static int
+mt7530_passthrough_set_ageing_time(struct dsa_switch *ds, unsigned int msecs)
+{
+ return 0;
+}
+
static int
mt7530_set_ageing_time(struct dsa_switch *ds, unsigned int msecs)
{@@ -1286,13 +1297,81 @@ mt753x_trap_frames(struct mt7530_priv *priv)
TO_CPU_FW_CPU_ONLY);
}
+static int
+mt7530_passthrough_port_change_mtu(struct dsa_switch *ds, int port,
+ int new_mtu)
+{
+ return 0;
+}
+
+static int
+mt7530_port_change_mtu(struct dsa_switch *ds, int port, int new_mtu)
+{
+ struct mt7530_priv *priv = ds->priv;
+ int length;
+ u32 val;
+
+ /* When a new MTU is set, DSA always set the CPU port's MTU to the
+ * largest MTU of the user ports. Because the switch only has a global
+ * RX length register, only allowing CPU port here is enough.
+ */
+ if (!dsa_is_upstream_port(ds, port))
+ return 0;
+
+ regmap_read(priv->regmap, MT7530_GMACCR, &val);
+ val &= ~MAX_RX_PKT_LEN_MASK;
+
+ /* RX length also includes Ethernet header, MTK tag, and FCS length */
+ length = new_mtu + ETH_HLEN + MTK_HDR_LEN + ETH_FCS_LEN;
+ if (length <= 1522) {
+ val |= MAX_RX_PKT_LEN_1522;
+ } else if (length <= 1536) {
+ val |= MAX_RX_PKT_LEN_1536;
+ } else if (length <= 1552) {
+ val |= MAX_RX_PKT_LEN_1552;
+ } else {
+ val &= ~MAX_RX_JUMBO_MASK;
+ val |= MAX_RX_JUMBO(DIV_ROUND_UP(length, 1024));
+ val |= MAX_RX_PKT_LEN_JUMBO;
+ }
+
+ regmap_write(priv->regmap, MT7530_GMACCR, val);
+
+ return 0;
+}
+
+/* If this switch is downstream of another switch that is in passthrough mode,
+ * the "CPU" port is actually a DSA port.
+ */
static void
mt753x_cpu_port_enable(struct dsa_switch *ds, int port)
{
struct mt7530_priv *priv = ds->priv;
- /* Enable Mediatek header mode on the cpu port */
- regmap_write(priv->regmap, MT7530_PVC_P(port), PORT_SPEC_TAG);
+ if (priv->is_passthrough) {
+ /* Disable parsing of the DSA tag, it will be forwarded blindly
+ * to the downstream switch.
+ */
+ regmap_write(priv->regmap, MT7530_PVC_P(port),
+ VLAN_ATTR(MT7530_VLAN_TRANSPARENT) |
+ PVC_EG_TAG(MT7530_VLAN_EG_DISABLED));
+
+ /* The port is not configured to parse DSA tags, so they are
+ * liable to be confused for length fields, so length check is
+ * disabled.
+ */
+ regmap_clear_bits(priv->regmap, MT753X_AGC, AGC_L2LEN_CHK);
+
+ /* In passthrough mode, MTU is only enforced downstream */
+ mt7530_port_change_mtu(ds, port, MT7530_MAX_MTU);
+
+ /* Loop detection has no value in passthrough mode */
+ regmap_set_bits(priv->regmap, MT753X_MTRAP,
+ MT7530_LOOP_DET_DISABLE);
+ } else {
+ /* Not passthrough, enable DSA tag handling on CPU port. */
+ regmap_write(priv->regmap, MT7530_PVC_P(port), PORT_SPEC_TAG);
+ }
/* Enable flooding on the CPU port */
regmap_set_bits(priv->regmap, MT753X_MFC,@@ -1318,12 +1397,36 @@ mt753x_cpu_port_enable(struct dsa_switch *ds, int port)
PCR_PORT_VLAN_MASK, MT7530_PORT_FALLBACK_MODE);
}
+/**
+ * mt753x_upstream_port_index - get the index of the upstream port.
+ *
+ * If the CPU port is local then this is the upstream port, but in the case of
+ * hierarchy the CPU port may be on another switch and the upstream port is
+ * then the DSA port pointing toward that CPU port. Note that
+ * dsa_switch_upstream_port() is not reliable because the conduit for a given
+ * port can be customized.
+ */
+static int
+mt753x_upstream_port_index(struct dsa_port *dp)
+{
+ struct dsa_port *cpu_dp = dp->cpu_dp;
+
+ /* Early port_enable on CPU port happens before cpu_dp is set. */
+ if (!cpu_dp)
+ return dsa_switch_upstream_port(dp->ds);
+
+ return dsa_towards_port(dp->ds, cpu_dp->ds->index, cpu_dp->index);
+}
+
static int
mt7530_port_enable(struct dsa_switch *ds, int port,
struct phy_device *phy)
{
struct dsa_port *dp = dsa_to_port(ds, port);
struct mt7530_priv *priv = ds->priv;
+ int upstream_pt;
+
+ upstream_pt = mt753x_upstream_port_index(dp);
mutex_lock(&priv->reg_mutex);
@@ -1332,13 +1435,38 @@ mt7530_port_enable(struct dsa_switch *ds, int port,
* bridge.
*/
if (dsa_port_is_user(dp)) {
- struct dsa_port *cpu_dp = dp->cpu_dp;
+ priv->ports[port].pm |= PCR_MATRIX(BIT(upstream_pt));
+
+ } else if (dsa_port_is_dsa(dp) && dp->index != upstream_pt) {
+ priv->ports[port].pm |= PCR_MATRIX(BIT(upstream_pt));
+
+ /* Should not happen */
+ WARN_ON_ONCE(!priv->is_passthrough);
- priv->ports[port].pm |= PCR_MATRIX(BIT(cpu_dp->index));
+ /* We are passing through to a downstream switch so we set both
+ * CPU and downstream link to pass traffic untouched so that
+ * the STAG from the downstream switch will pass to the upstream.
+ */
+ regmap_write(priv->regmap, MT7530_PVC_P(port),
+ VLAN_ATTR(MT7530_VLAN_TRANSPARENT) |
+ PVC_EG_TAG(MT7530_VLAN_EG_DISABLED));
+
+ /* We let the downstream switch flood */
+ regmap_set_bits(priv->regmap, MT753X_MFC, BC_FFP(BIT(port)) |
+ UNM_FFP(BIT(port)) | UNU_FFP(BIT(port)));
+
+ /* Make the upstream port able to connect to the DSA port.
+ * This must be explicit because PORT_SPEC_TAG is unset.
+ */
+ regmap_write(priv->regmap, MT7530_PCR_P(upstream_pt),
+ PCR_MATRIX(BIT(port)));
}
priv->ports[port].enable = true;
- regmap_update_bits(priv->regmap, MT7530_PCR_P(port), PCR_MATRIX_MASK,
- priv->ports[port].pm);
+
+ /* In passthrough mode, CPU port mask is set above. */
+ if (!(priv->is_passthrough && dp->index == upstream_pt))
+ regmap_update_bits(priv->regmap, MT7530_PCR_P(port),
+ PCR_MATRIX_MASK, priv->ports[port].pm);
mutex_unlock(&priv->reg_mutex);
@@ -1380,45 +1508,14 @@ mt7530_port_disable(struct dsa_switch *ds, int port)
}
static int
-mt7530_port_change_mtu(struct dsa_switch *ds, int port, int new_mtu)
+mt7530_port_max_mtu(struct dsa_switch *ds, int port)
{
- struct mt7530_priv *priv = ds->priv;
- int length;
- u32 val;
-
- /* When a new MTU is set, DSA always set the CPU port's MTU to the
- * largest MTU of the user ports. Because the switch only has a global
- * RX length register, only allowing CPU port here is enough.
- */
- if (!dsa_is_cpu_port(ds, port))
- return 0;
-
- regmap_read(priv->regmap, MT7530_GMACCR, &val);
- val &= ~MAX_RX_PKT_LEN_MASK;
-
- /* RX length also includes Ethernet header, MTK tag, and FCS length */
- length = new_mtu + ETH_HLEN + MTK_HDR_LEN + ETH_FCS_LEN;
- if (length <= 1522) {
- val |= MAX_RX_PKT_LEN_1522;
- } else if (length <= 1536) {
- val |= MAX_RX_PKT_LEN_1536;
- } else if (length <= 1552) {
- val |= MAX_RX_PKT_LEN_1552;
- } else {
- val &= ~MAX_RX_JUMBO_MASK;
- val |= MAX_RX_JUMBO(DIV_ROUND_UP(length, 1024));
- val |= MAX_RX_PKT_LEN_JUMBO;
- }
-
- regmap_write(priv->regmap, MT7530_GMACCR, val);
-
- return 0;
+ return MT7530_MAX_MTU;
}
-static int
-mt7530_port_max_mtu(struct dsa_switch *ds, int port)
+static void
+mt7530_passthrough_stp_state_set(struct dsa_switch *ds, int port, u8 state)
{
- return MT7530_MAX_MTU;
}
static void@@ -1456,9 +1553,8 @@ static void mt7530_update_port_member(struct mt7530_priv *priv, int port,
bool join) __must_hold(&priv->reg_mutex)
{
struct dsa_port *dp = dsa_to_port(priv->ds, port), *other_dp;
+ u32 port_bitmap = BIT(mt753x_upstream_port_index(dp));
struct mt7530_port *p = &priv->ports[port], *other_p;
- struct dsa_port *cpu_dp = dp->cpu_dp;
- u32 port_bitmap = BIT(cpu_dp->index);
int other_port;
bool isolated;
@@ -1514,6 +1610,14 @@ mt7530_port_pre_bridge_flags(struct dsa_switch *ds, int port,
return 0;
}
+static int
+mt7530_passthrough_port_bridge_flags(struct dsa_switch *ds, int port,
+ struct switchdev_brport_flags flags,
+ struct netlink_ext_ack *extack)
+{
+ return 0;
+}
+
static int
mt7530_port_bridge_flags(struct dsa_switch *ds, int port,
struct switchdev_brport_flags flags,@@ -1554,6 +1658,15 @@ mt7530_port_bridge_flags(struct dsa_switch *ds, int port,
return 0;
}
+static int
+mt7530_passthrough_port_bridge_join(struct dsa_switch *ds, int port,
+ struct dsa_bridge bridge,
+ bool *tx_fwd_offload,
+ struct netlink_ext_ack *extack)
+{
+ return 0;
+}
+
static int
mt7530_port_bridge_join(struct dsa_switch *ds, int port,
struct dsa_bridge bridge, bool *tx_fwd_offload,@@ -1708,6 +1821,12 @@ mt7530_port_set_vlan_aware(struct dsa_switch *ds, int port)
}
}
+static void
+mt7530_passthrough_port_bridge_leave(struct dsa_switch *ds, int port,
+ struct dsa_bridge bridge)
+{
+}
+
static void
mt7530_port_bridge_leave(struct dsa_switch *ds, int port,
struct dsa_bridge bridge)@@ -1728,6 +1847,14 @@ mt7530_port_bridge_leave(struct dsa_switch *ds, int port,
mutex_unlock(&priv->reg_mutex);
}
+static int
+mt7530_passthrough_port_fdb_add(struct dsa_switch *ds, int port,
+ const unsigned char *addr, u16 vid,
+ struct dsa_db db)
+{
+ return 0;
+}
+
static int
mt7530_port_fdb_add(struct dsa_switch *ds, int port,
const unsigned char *addr, u16 vid,@@ -1745,6 +1872,14 @@ mt7530_port_fdb_add(struct dsa_switch *ds, int port,
return ret;
}
+static int
+mt7530_passthrough_port_fdb_del(struct dsa_switch *ds, int port,
+ const unsigned char *addr, u16 vid,
+ struct dsa_db db)
+{
+ return 0;
+}
+
static int
mt7530_port_fdb_del(struct dsa_switch *ds, int port,
const unsigned char *addr, u16 vid,@@ -1797,6 +1932,14 @@ mt7530_port_fdb_dump(struct dsa_switch *ds, int port,
return 0;
}
+static int
+mt7530_passthrough_port_mdb_add(struct dsa_switch *ds, int port,
+ const struct switchdev_obj_port_mdb *mdb,
+ struct dsa_db db)
+{
+ return 0;
+}
+
static int
mt7530_port_mdb_add(struct dsa_switch *ds, int port,
const struct switchdev_obj_port_mdb *mdb,@@ -1826,6 +1969,14 @@ mt7530_port_mdb_add(struct dsa_switch *ds, int port,
return ret;
}
+static int
+mt7530_passthrough_port_mdb_del(struct dsa_switch *ds, int port,
+ const struct switchdev_obj_port_mdb *mdb,
+ struct dsa_db db)
+{
+ return 0;
+}
+
static int
mt7530_port_mdb_del(struct dsa_switch *ds, int port,
const struct switchdev_obj_port_mdb *mdb,@@ -1856,12 +2007,19 @@ mt7530_port_mdb_del(struct dsa_switch *ds, int port,
return ret;
}
+static int
+mt7530_passthrough_port_vlan_filtering(struct dsa_switch *ds, int port,
+ bool vlan_filtering,
+ struct netlink_ext_ack *extack)
+{
+ return 0;
+}
+
static int
mt7530_port_vlan_filtering(struct dsa_switch *ds, int port, bool vlan_filtering,
struct netlink_ext_ack *extack)
{
struct dsa_port *dp = dsa_to_port(ds, port);
- struct dsa_port *cpu_dp = dp->cpu_dp;
if (vlan_filtering) {
/* The port is being kept as VLAN-unaware port when bridge is@@ -1870,7 +2028,7 @@ mt7530_port_vlan_filtering(struct dsa_switch *ds, int port, bool vlan_filtering,
* for becoming a VLAN-aware port.
*/
mt7530_port_set_vlan_aware(ds, port);
- mt7530_port_set_vlan_aware(ds, cpu_dp->index);
+ mt7530_port_set_vlan_aware(ds, mt753x_upstream_port_index(dp));
} else {
mt7530_port_set_vlan_unaware(ds, port);
}@@ -1902,7 +2060,7 @@ mt7530_hw_vlan_add(struct mt7530_priv *priv,
* that VLAN tags would be appended after hardware special tag used as
* DSA tag.
*/
- if (dsa_port_is_cpu(dp))
+ if (dp->index == mt753x_upstream_port_index(dp))
val = MT7530_VLAN_EGRESS_STACK;
else if (entry->untagged)
val = MT7530_VLAN_EGRESS_UNTAG;
@@ -1960,6 +2118,14 @@ mt7530_hw_vlan_update(struct mt7530_priv *priv, u16 vid,
mt7530_vlan_cmd(priv, MT7530_VTCR_WR_VID, vid);
}
+static int
+mt7530_passthrough_port_vlan_add(struct dsa_switch *ds, int port,
+ const struct switchdev_obj_port_vlan *vlan,
+ struct netlink_ext_ack *extack)
+{
+ return 0;
+}
+
static int
mt7530_port_vlan_add(struct dsa_switch *ds, int port,
const struct switchdev_obj_port_vlan *vlan,@@ -2015,6 +2181,13 @@ mt7530_port_vlan_add(struct dsa_switch *ds, int port,
return 0;
}
+static int
+mt7530_passthrough_port_vlan_del(struct dsa_switch *ds, int port,
+ const struct switchdev_obj_port_vlan *vlan)
+{
+ return 0;
+}
+
static int
mt7530_port_vlan_del(struct dsa_switch *ds, int port,
const struct switchdev_obj_port_vlan *vlan)@@ -2055,6 +2228,14 @@ mt7530_port_vlan_del(struct dsa_switch *ds, int port,
return 0;
}
+static int
+mt753x_passthrough_port_mirror_add(struct dsa_switch *ds, int port,
+ struct dsa_mall_mirror_tc_entry *mirror,
+ bool ingress, struct netlink_ext_ack *extack)
+{
+ return 0;
+}
+
static int mt753x_port_mirror_add(struct dsa_switch *ds, int port,
struct dsa_mall_mirror_tc_entry *mirror,
bool ingress, struct netlink_ext_ack *extack)@@ -2093,6 +2274,11 @@ static int mt753x_port_mirror_add(struct dsa_switch *ds, int port,
return 0;
}
+static void mt753x_passthrough_port_mirror_del(struct dsa_switch *ds, int port,
+ struct dsa_mall_mirror_tc_entry *mirror)
+{
+}
+
static void mt753x_port_mirror_del(struct dsa_switch *ds, int port,
struct dsa_mall_mirror_tc_entry *mirror)
{@@ -2405,11 +2591,6 @@ mt7530_setup(struct dsa_switch *ds)
break;
}
- if (!dn) {
- dev_err(ds->dev, "parent OF node of DSA conduit not found");
- return -EINVAL;
- }
-
ds->assisted_learning_on_cpu_port = true;
ds->untag_vlan_aware_bridge_pvid = true;
ds->mtu_enforcement_ingress = true;@@ -2491,7 +2672,8 @@ mt7530_setup(struct dsa_switch *ds)
if ((val & MT7530_XTAL_MASK) == MT7530_XTAL_40MHZ)
mt7530_pll_setup(priv);
- mt753x_trap_frames(priv);
+ if (!priv->is_passthrough)
+ mt753x_trap_frames(priv);
/* Enable and reset MIB counters */
mt7530_mib_reset(ds);
@@ -2511,7 +2693,7 @@ mt7530_setup(struct dsa_switch *ds)
/* Disable learning by default on all ports */
regmap_set_bits(priv->regmap, MT7530_PSC_P(i), SA_DIS);
- if (dsa_is_cpu_port(ds, i)) {
+ if (dsa_is_upstream_port(ds, i)) {
mt753x_cpu_port_enable(ds, i);
} else {
mt7530_port_disable(ds, i);@@ -2535,7 +2717,7 @@ mt7530_setup(struct dsa_switch *ds)
return ret;
/* Check for PHY muxing on port 5 */
- if (dsa_is_unused_port(ds, 5)) {
+ if (dn && dsa_is_unused_port(ds, 5)) {
/* Scan the ethernet nodes. Look for GMAC1, lookup the used PHY.
* Set priv->p5_mode to the appropriate value if PHY muxing is
* detected.@@ -2608,7 +2790,8 @@ mt7531_setup_common(struct dsa_switch *ds)
ds->ageing_time_min = 2 * 1000;
ds->ageing_time_max = (AGE_CNT_MAX + 1) * (AGE_UNIT_MAX + 1) * 1000;
- mt753x_trap_frames(priv);
+ if (!priv->is_passthrough)
+ mt753x_trap_frames(priv);
/* Enable and reset MIB counters */
mt7530_mib_reset(ds);
@@ -2635,7 +2818,7 @@ mt7531_setup_common(struct dsa_switch *ds)
regmap_set_bits(priv->regmap, MT7531_DBG_CNT(i),
MT7531_DIS_CLR);
- if (dsa_is_cpu_port(ds, i)) {
+ if (dsa_is_upstream_port(ds, i)) {
mt753x_cpu_port_enable(ds, i);
} else {
mt7530_port_disable(ds, i);@@ -3255,6 +3438,14 @@ static int mt753x_set_mac_eee(struct dsa_switch *ds, int port,
return 0;
}
+static int
+mt753x_passthrough_port_change_conduit(struct dsa_switch *ds, int port,
+ struct net_device *conduit,
+ struct netlink_ext_ack *extack)
+{
+ return 0;
+}
+
static int
mt753x_port_change_conduit(struct dsa_switch *ds, int port,
struct net_device *conduit,@@ -3365,6 +3556,13 @@ static int mt753x_tc_setup_qdisc_tbf(struct dsa_switch *ds, int port,
return 0;
}
+static int mt753x_passthrough_setup_tc(struct dsa_switch *ds, int port,
+ enum tc_setup_type type,
+ void *type_data)
+{
+ return 0;
+}
+
static int mt753x_setup_tc(struct dsa_switch *ds, int port,
enum tc_setup_type type, void *type_data)
{@@ -3402,6 +3600,96 @@ static int mt7988_setup(struct dsa_switch *ds)
return mt7531_setup_common(ds);
}
+/* 1 if passthrough, negative if error. */
+static int mt753x_check_passthrough(struct device *dev)
+{
+ struct device_node *ports, *port;
+ int ethernet_ports = 0;
+ int enabled_ports = 0;
+ int link_ports = 0;
+
+ ports = of_get_child_by_name(dev->of_node, "ports");
+ if (!ports)
+ ports = of_get_child_by_name(dev->of_node, "ethernet-ports");
+
+ if (!ports) {
+ dev_err(dev, "no ports child node found\n");
+ return -EINVAL;
+ }
+
+ for_each_available_child_of_node(ports, port) {
+ struct device_node *pt_node;
+
+ enabled_ports++;
+
+ pt_node = of_parse_phandle(port, "ethernet", 0);
+
+ if (pt_node) {
+ ethernet_ports++;
+ of_node_put(pt_node);
+ continue;
+ }
+
+ pt_node = of_parse_phandle(port, "link", 0);
+ if (pt_node) {
+ link_ports++;
+ of_node_put(pt_node);
+ }
+ }
+
+ of_node_put(ports);
+
+ /*
+ * A switch is considered passthrough if exactly two available
+ * ports have an "ethernet" or "link" phandle.
+ */
+ return link_ports == 1 && ethernet_ports == 1 && enabled_ports == 2;
+}
+
+/* No manipulation of forwarding rules allowed in passthrough mode */
+static const struct dsa_switch_ops mt7530_passthrough_switch_ops = {
+ .get_tag_protocol = mtk_get_tag_protocol,
+ .setup = mt753x_setup,
+ .teardown = mt753x_teardown,
+ .preferred_default_local_cpu_port = mt753x_preferred_default_local_cpu_port,
+ .port_change_conduit = mt753x_passthrough_port_change_conduit,
+ .get_strings = mt7530_get_strings,
+ .get_ethtool_stats = mt7530_get_ethtool_stats,
+ .get_sset_count = mt7530_get_sset_count,
+ .get_eth_mac_stats = mt7530_get_eth_mac_stats,
+ .get_rmon_stats = mt7530_get_rmon_stats,
+ .get_eth_ctrl_stats = mt7530_get_eth_ctrl_stats,
+ .get_stats64 = mt7530_get_stats64,
+ .set_ageing_time = mt7530_passthrough_set_ageing_time,
+ .port_enable = mt7530_port_enable,
+ .port_disable = mt7530_port_disable,
+ .port_change_mtu = mt7530_passthrough_port_change_mtu,
+ .port_max_mtu = mt7530_port_max_mtu,
+ .port_stp_state_set = mt7530_passthrough_stp_state_set,
+ .port_pre_bridge_flags = mt7530_port_pre_bridge_flags,
+ .port_bridge_flags = mt7530_passthrough_port_bridge_flags,
+ .port_bridge_join = mt7530_passthrough_port_bridge_join,
+ .port_bridge_leave = mt7530_passthrough_port_bridge_leave,
+ .port_fast_age = mt7530_passthrough_port_fast_age,
+ .port_fdb_add = mt7530_passthrough_port_fdb_add,
+ .port_fdb_del = mt7530_passthrough_port_fdb_del,
+ .port_fdb_dump = mt7530_port_fdb_dump,
+ .port_mdb_add = mt7530_passthrough_port_mdb_add,
+ .port_mdb_del = mt7530_passthrough_port_mdb_del,
+ .port_vlan_filtering = mt7530_passthrough_port_vlan_filtering,
+ .port_vlan_add = mt7530_passthrough_port_vlan_add,
+ .port_vlan_del = mt7530_passthrough_port_vlan_del,
+ .port_mirror_add = mt753x_passthrough_port_mirror_add,
+ .port_mirror_del = mt753x_passthrough_port_mirror_del,
+ .phylink_get_caps = mt753x_phylink_get_caps,
+ .support_eee = dsa_supports_eee,
+ .set_mac_eee = mt753x_set_mac_eee,
+ .conduit_state_change = mt753x_conduit_state_change,
+ .port_setup_tc = mt753x_passthrough_setup_tc,
+ .port_hsr_join = dsa_port_simple_hsr_join,
+ .port_hsr_leave = dsa_port_simple_hsr_leave,
+};
+
static const struct dsa_switch_ops mt7530_switch_ops = {
.get_tag_protocol = mtk_get_tag_protocol,
.setup = mt753x_setup,@@ -3534,8 +3822,12 @@ EXPORT_SYMBOL_GPL(mt753x_table);
int
mt7530_probe_common(struct mt7530_priv *priv)
{
+ int passthrough = mt753x_check_passthrough(priv->dev);
struct device *dev = priv->dev;
+ if (passthrough < 0)
+ return passthrough;
+
priv->ds = devm_kzalloc_obj(dev, *priv->ds);
if (!priv->ds)
return -ENOMEM;@@ -3553,7 +3845,14 @@ mt7530_probe_common(struct mt7530_priv *priv)
priv->id = priv->info->id;
priv->dev = dev;
priv->ds->priv = priv;
- priv->ds->ops = &mt7530_switch_ops;
+
+ priv->is_passthrough = passthrough;
+
+ if (passthrough)
+ priv->ds->ops = &mt7530_passthrough_switch_ops;
+ else
+ priv->ds->ops = &mt7530_switch_ops;
+
priv->ds->phylink_mac_ops = &mt753x_phylink_mac_ops;
mutex_init(&priv->reg_mutex);
spin_lock_init(&priv->stats_lock);
diff --git a/drivers/net/dsa/mt7530.h b/drivers/net/dsa/mt7530.h
index 3dabbc99fbbc..108c831dd012 100644
--- a/drivers/net/dsa/mt7530.h
+++ b/drivers/net/dsa/mt7530.h
@@ -40,6 +40,7 @@ enum mt753x_id {
/* Register for ARL global control */
#define MT753X_AGC 0xc
#define LOCAL_EN BIT(7)
+#define AGC_L2LEN_CHK BIT(4)
/* Register for MAC forward control */
#define MT753X_MFC 0x10@@ -583,6 +584,7 @@ enum mt7531_clk_skew {
#define MT753X_MTRAP 0x7804
#define MT7530_P5_PHY0_SEL BIT(20)
#define MT7530_CHG_TRAP BIT(16)
+#define MT7530_LOOP_DET_DISABLE BIT(14)
#define MT7530_P5_MAC_SEL BIT(13)
#define MT7530_P6_DIS BIT(8)
#define MT7530_P5_RGMII_MODE BIT(7)@@ -897,6 +899,9 @@ struct mt753x_info {
* @p5_mode: Holding the current mode of port 5 of the MT7530 switch
* @p5_sgmii: Flag for distinguishing if port 5 of the MT7531 switch
* has got SGMII
+ * @is_passthrough: If this switch is to pass traffic between the upstream
+ * (CPU) port and a second downstream switch, without
+ * altering the DSA tag.
* @irq_domain: IRQ domain of the switch irq_chip
* @create_sgmii: Pointer to function creating SGMII PCS instance(s)
* @active_cpu_ports: Holding the active CPU ports@@ -921,6 +926,7 @@ struct mt7530_priv {
bool p5_sgmii;
u8 mirror_rx;
u8 mirror_tx;
+ bool is_passthrough;
struct mt7530_port ports[MT7530_NUM_PORTS];
struct mt753x_pcs pcs[MT7530_NUM_PORTS];
/* protect among processes for registers access*/--
2.39.5