mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-30 10:39:04 +00:00
5714660643
Manually rebased:
backport-5.15/603-v5.19-page_pool-Add-recycle-stats-to-page_pool_put_page_bu.patch
pending-5.15/723-net-mt7531-ensure-all-MACs-are-powered-down-before-r.patch*
Removed upstreamed:
generic-backport/610-v6.3-net-page_pool-use-in_softirq-instead.patch[1]
backport-5.15/705-12-v6.0-net-dsa-mt7530-rework-mt753-01-_setup.patch[2]
backport-5.15/790-v6.4-0010-net-dsa-mt7530-split-off-common-parts-from-mt7531_se.patch[3]
backport-5.15/703-10-v5.16-net-dsa-introduce-helpers-for-iterating-through-port.patch[4]
All other patches automatically rebased.
* Modified to define the variable i as suggested by DragonBluep in PR discussion.
See: https://github.com/openwrt/openwrt/pull/12823#issuecomment-1578518576
1. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v5.15.115&id=3af319d5147454dc63665ef451229c674b538377
2. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v5.15.115&id=0753c1ef24194580f7165ae6e259b59a851392f2
3. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v5.15.115&id=5a7266feaa6d708fc6880a161786eaa884ef3c8e
4. 9902f91cf6
Build system: x86_64
Build-tested: bcm2711/RPi4B, ramips/tplink_archer-a6-v3, filogic/xiaomi_redmi-router-ax6000-ubootmod
Run-tested: bcm2711/RPi4B, ramips/tplink_archer-a6-v3, filogic/xiaomi_redmi-router-ax6000-ubootmod
Signed-off-by: John Audia <therealgraysky@proton.me>
167 lines
6.0 KiB
Diff
167 lines
6.0 KiB
Diff
From a1da54bcd664fc27169386db966575675ac3ccb0 Mon Sep 17 00:00:00 2001
|
|
From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
|
|
Date: Mon, 11 Apr 2022 10:46:01 +0100
|
|
Subject: [PATCH 02/13] net: dsa: mt7530: populate supported_interfaces and
|
|
mac_capabilities
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
Populate the supported interfaces and MAC capabilities for mt7530,
|
|
mt7531 and mt7621 DSA switches. Filling this in will enable phylink
|
|
to pre-check the PHY interface mode against the the supported
|
|
interfaces bitmap prior to calling the validate function, and will
|
|
eventually allow us to convert to using the generic validation.
|
|
|
|
Tested-by: Marek Behún <kabel@kernel.org>
|
|
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
|
|
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
|
---
|
|
drivers/net/dsa/mt7530.c | 74 ++++++++++++++++++++++++++++++++++++++++
|
|
drivers/net/dsa/mt7530.h | 2 ++
|
|
2 files changed, 76 insertions(+)
|
|
|
|
--- a/drivers/net/dsa/mt7530.c
|
|
+++ b/drivers/net/dsa/mt7530.c
|
|
@@ -2444,6 +2444,32 @@ mt7531_setup(struct dsa_switch *ds)
|
|
return 0;
|
|
}
|
|
|
|
+static void mt7530_mac_port_get_caps(struct dsa_switch *ds, int port,
|
|
+ struct phylink_config *config)
|
|
+{
|
|
+ switch (port) {
|
|
+ case 0 ... 4: /* Internal phy */
|
|
+ __set_bit(PHY_INTERFACE_MODE_GMII,
|
|
+ config->supported_interfaces);
|
|
+ break;
|
|
+
|
|
+ case 5: /* 2nd cpu port with phy of port 0 or 4 / external phy */
|
|
+ phy_interface_set_rgmii(config->supported_interfaces);
|
|
+ __set_bit(PHY_INTERFACE_MODE_MII,
|
|
+ config->supported_interfaces);
|
|
+ __set_bit(PHY_INTERFACE_MODE_GMII,
|
|
+ config->supported_interfaces);
|
|
+ break;
|
|
+
|
|
+ case 6: /* 1st cpu port */
|
|
+ __set_bit(PHY_INTERFACE_MODE_RGMII,
|
|
+ config->supported_interfaces);
|
|
+ __set_bit(PHY_INTERFACE_MODE_TRGMII,
|
|
+ config->supported_interfaces);
|
|
+ break;
|
|
+ }
|
|
+}
|
|
+
|
|
static bool
|
|
mt7530_phy_mode_supported(struct dsa_switch *ds, int port,
|
|
const struct phylink_link_state *state)
|
|
@@ -2480,6 +2506,37 @@ static bool mt7531_is_rgmii_port(struct
|
|
return (port == 5) && (priv->p5_intf_sel != P5_INTF_SEL_GMAC5_SGMII);
|
|
}
|
|
|
|
+static void mt7531_mac_port_get_caps(struct dsa_switch *ds, int port,
|
|
+ struct phylink_config *config)
|
|
+{
|
|
+ struct mt7530_priv *priv = ds->priv;
|
|
+
|
|
+ switch (port) {
|
|
+ case 0 ... 4: /* Internal phy */
|
|
+ __set_bit(PHY_INTERFACE_MODE_GMII,
|
|
+ config->supported_interfaces);
|
|
+ break;
|
|
+
|
|
+ case 5: /* 2nd cpu port supports either rgmii or sgmii/8023z */
|
|
+ if (mt7531_is_rgmii_port(priv, port)) {
|
|
+ phy_interface_set_rgmii(config->supported_interfaces);
|
|
+ break;
|
|
+ }
|
|
+ fallthrough;
|
|
+
|
|
+ case 6: /* 1st cpu port supports sgmii/8023z only */
|
|
+ __set_bit(PHY_INTERFACE_MODE_SGMII,
|
|
+ config->supported_interfaces);
|
|
+ __set_bit(PHY_INTERFACE_MODE_1000BASEX,
|
|
+ config->supported_interfaces);
|
|
+ __set_bit(PHY_INTERFACE_MODE_2500BASEX,
|
|
+ config->supported_interfaces);
|
|
+
|
|
+ config->mac_capabilities |= MAC_2500FD;
|
|
+ break;
|
|
+ }
|
|
+}
|
|
+
|
|
static bool
|
|
mt7531_phy_mode_supported(struct dsa_switch *ds, int port,
|
|
const struct phylink_link_state *state)
|
|
@@ -2956,6 +3013,18 @@ mt7531_cpu_port_config(struct dsa_switch
|
|
return 0;
|
|
}
|
|
|
|
+static void mt753x_phylink_get_caps(struct dsa_switch *ds, int port,
|
|
+ struct phylink_config *config)
|
|
+{
|
|
+ struct mt7530_priv *priv = ds->priv;
|
|
+
|
|
+ /* This switch only supports full-duplex at 1Gbps */
|
|
+ config->mac_capabilities = MAC_ASYM_PAUSE | MAC_SYM_PAUSE |
|
|
+ MAC_10 | MAC_100 | MAC_1000FD;
|
|
+
|
|
+ priv->info->mac_port_get_caps(ds, port, config);
|
|
+}
|
|
+
|
|
static void
|
|
mt7530_mac_port_validate(struct dsa_switch *ds, int port,
|
|
unsigned long *supported)
|
|
@@ -3191,6 +3260,7 @@ static const struct dsa_switch_ops mt753
|
|
.port_vlan_del = mt7530_port_vlan_del,
|
|
.port_mirror_add = mt753x_port_mirror_add,
|
|
.port_mirror_del = mt753x_port_mirror_del,
|
|
+ .phylink_get_caps = mt753x_phylink_get_caps,
|
|
.phylink_validate = mt753x_phylink_validate,
|
|
.phylink_mac_link_state = mt753x_phylink_mac_link_state,
|
|
.phylink_mac_config = mt753x_phylink_mac_config,
|
|
@@ -3208,6 +3278,7 @@ static const struct mt753x_info mt753x_t
|
|
.phy_read = mt7530_phy_read,
|
|
.phy_write = mt7530_phy_write,
|
|
.pad_setup = mt7530_pad_clk_setup,
|
|
+ .mac_port_get_caps = mt7530_mac_port_get_caps,
|
|
.phy_mode_supported = mt7530_phy_mode_supported,
|
|
.mac_port_validate = mt7530_mac_port_validate,
|
|
.mac_port_get_state = mt7530_phylink_mac_link_state,
|
|
@@ -3219,6 +3290,7 @@ static const struct mt753x_info mt753x_t
|
|
.phy_read = mt7530_phy_read,
|
|
.phy_write = mt7530_phy_write,
|
|
.pad_setup = mt7530_pad_clk_setup,
|
|
+ .mac_port_get_caps = mt7530_mac_port_get_caps,
|
|
.phy_mode_supported = mt7530_phy_mode_supported,
|
|
.mac_port_validate = mt7530_mac_port_validate,
|
|
.mac_port_get_state = mt7530_phylink_mac_link_state,
|
|
@@ -3231,6 +3303,7 @@ static const struct mt753x_info mt753x_t
|
|
.phy_write = mt7531_ind_phy_write,
|
|
.pad_setup = mt7531_pad_setup,
|
|
.cpu_port_config = mt7531_cpu_port_config,
|
|
+ .mac_port_get_caps = mt7531_mac_port_get_caps,
|
|
.phy_mode_supported = mt7531_phy_mode_supported,
|
|
.mac_port_validate = mt7531_mac_port_validate,
|
|
.mac_port_get_state = mt7531_phylink_mac_link_state,
|
|
@@ -3293,6 +3366,7 @@ mt7530_probe(struct mdio_device *mdiodev
|
|
*/
|
|
if (!priv->info->sw_setup || !priv->info->pad_setup ||
|
|
!priv->info->phy_read || !priv->info->phy_write ||
|
|
+ !priv->info->mac_port_get_caps ||
|
|
!priv->info->phy_mode_supported ||
|
|
!priv->info->mac_port_validate ||
|
|
!priv->info->mac_port_get_state || !priv->info->mac_port_config)
|
|
--- a/drivers/net/dsa/mt7530.h
|
|
+++ b/drivers/net/dsa/mt7530.h
|
|
@@ -769,6 +769,8 @@ struct mt753x_info {
|
|
int (*phy_write)(struct mt7530_priv *priv, int port, int regnum, u16 val);
|
|
int (*pad_setup)(struct dsa_switch *ds, phy_interface_t interface);
|
|
int (*cpu_port_config)(struct dsa_switch *ds, int port);
|
|
+ void (*mac_port_get_caps)(struct dsa_switch *ds, int port,
|
|
+ struct phylink_config *config);
|
|
bool (*phy_mode_supported)(struct dsa_switch *ds, int port,
|
|
const struct phylink_link_state *state);
|
|
void (*mac_port_validate)(struct dsa_switch *ds, int port,
|