forked from openwrt/openwrt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
generic: 6.1, 6.6: mt7530: import accepted patches
Import patches for the MT7530 DSA driver from net-next tree: cae425cb43fe net: dsa: allow DSA switch drivers to provide their own phylink mac ops dd0c9855b413 net: dsa: introduce dsa_phylink_to_port() 7c5e37d7ee78 net: dsa: mt7530: simplify core operations 868ff5f4944a net: dsa: mt7530-mdio: read PHY address of switch from device tree 2c606d138518 net: dsa: mt7530: fix port mirroring for MT7988 SoC switch d59cf049c837 net: dsa: mt7530: fix mirroring frames received on local port 62d6d91db98a net: dsa: mt7530: provide own phylink MAC operations Signed-off-by: Daniel Golle <daniel@makrotopia.org>
- Loading branch information
Showing
14 changed files
with
1,781 additions
and
0 deletions.
There are no files selected for viewing
99 changes: 99 additions & 0 deletions
99
target/linux/generic/backport-6.1/765-v6.10-net-dsa-introduce-dsa_phylink_to_port.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
From f13b2b33c7674fa0988dfaa9adb95d7d912b489f Mon Sep 17 00:00:00 2001 | ||
From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk> | ||
Date: Wed, 10 Apr 2024 20:42:38 +0100 | ||
Subject: [PATCH 1/2] net: dsa: introduce dsa_phylink_to_port() | ||
|
||
We convert from a phylink_config struct to a dsa_port struct in many | ||
places, let's provide a helper for this. | ||
|
||
Reviewed-by: Andrew Lunn <andrew@lunn.ch> | ||
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com> | ||
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> | ||
Reviewed-by: Vladimir Oltean <olteanv@gmail.com> | ||
Link: https://lore.kernel.org/r/E1rudqA-006K9B-85@rmk-PC.armlinux.org.uk | ||
Signed-off-by: Jakub Kicinski <kuba@kernel.org> | ||
--- | ||
include/net/dsa.h | 6 ++++++ | ||
net/dsa/port.c | 12 ++++++------ | ||
2 files changed, 12 insertions(+), 6 deletions(-) | ||
|
||
--- a/include/net/dsa.h | ||
+++ b/include/net/dsa.h | ||
@@ -337,6 +337,12 @@ struct dsa_port { | ||
struct list_head vlans; | ||
}; | ||
|
||
+static inline struct dsa_port * | ||
+dsa_phylink_to_port(struct phylink_config *config) | ||
+{ | ||
+ return container_of(config, struct dsa_port, pl_config); | ||
+} | ||
+ | ||
/* TODO: ideally DSA ports would have a single dp->link_dp member, | ||
* and no dst->rtable nor this struct dsa_link would be needed, | ||
* but this would require some more complex tree walking, | ||
--- a/net/dsa/port.c | ||
+++ b/net/dsa/port.c | ||
@@ -1552,7 +1552,7 @@ static void dsa_port_phylink_validate(st | ||
unsigned long *supported, | ||
struct phylink_link_state *state) | ||
{ | ||
- struct dsa_port *dp = container_of(config, struct dsa_port, pl_config); | ||
+ struct dsa_port *dp = dsa_phylink_to_port(config); | ||
struct dsa_switch *ds = dp->ds; | ||
|
||
if (!ds->ops->phylink_validate) { | ||
@@ -1567,7 +1567,7 @@ static void dsa_port_phylink_validate(st | ||
static void dsa_port_phylink_mac_pcs_get_state(struct phylink_config *config, | ||
struct phylink_link_state *state) | ||
{ | ||
- struct dsa_port *dp = container_of(config, struct dsa_port, pl_config); | ||
+ struct dsa_port *dp = dsa_phylink_to_port(config); | ||
struct dsa_switch *ds = dp->ds; | ||
int err; | ||
|
||
@@ -1589,7 +1589,7 @@ static struct phylink_pcs * | ||
dsa_port_phylink_mac_select_pcs(struct phylink_config *config, | ||
phy_interface_t interface) | ||
{ | ||
- struct dsa_port *dp = container_of(config, struct dsa_port, pl_config); | ||
+ struct dsa_port *dp = dsa_phylink_to_port(config); | ||
struct phylink_pcs *pcs = ERR_PTR(-EOPNOTSUPP); | ||
struct dsa_switch *ds = dp->ds; | ||
|
||
@@ -1603,7 +1603,7 @@ static void dsa_port_phylink_mac_config( | ||
unsigned int mode, | ||
const struct phylink_link_state *state) | ||
{ | ||
- struct dsa_port *dp = container_of(config, struct dsa_port, pl_config); | ||
+ struct dsa_port *dp = dsa_phylink_to_port(config); | ||
struct dsa_switch *ds = dp->ds; | ||
|
||
if (!ds->ops->phylink_mac_config) | ||
@@ -1614,7 +1614,7 @@ static void dsa_port_phylink_mac_config( | ||
|
||
static void dsa_port_phylink_mac_an_restart(struct phylink_config *config) | ||
{ | ||
- struct dsa_port *dp = container_of(config, struct dsa_port, pl_config); | ||
+ struct dsa_port *dp = dsa_phylink_to_port(config); | ||
struct dsa_switch *ds = dp->ds; | ||
|
||
if (!ds->ops->phylink_mac_an_restart) | ||
@@ -1627,7 +1627,7 @@ static void dsa_port_phylink_mac_link_do | ||
unsigned int mode, | ||
phy_interface_t interface) | ||
{ | ||
- struct dsa_port *dp = container_of(config, struct dsa_port, pl_config); | ||
+ struct dsa_port *dp = dsa_phylink_to_port(config); | ||
struct phy_device *phydev = NULL; | ||
struct dsa_switch *ds = dp->ds; | ||
|
||
@@ -1650,7 +1650,7 @@ static void dsa_port_phylink_mac_link_up | ||
int speed, int duplex, | ||
bool tx_pause, bool rx_pause) | ||
{ | ||
- struct dsa_port *dp = container_of(config, struct dsa_port, pl_config); | ||
+ struct dsa_port *dp = dsa_phylink_to_port(config); | ||
struct dsa_switch *ds = dp->ds; | ||
|
||
if (!ds->ops->phylink_mac_link_up) { |
117 changes: 117 additions & 0 deletions
117
...generic/backport-6.1/766-v6.10-net-dsa-allow-DSA-switch-drivers-to-provide-their-ow.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
From c22d8240fcd73a1c3ec8dcb055bd583fb970c375 Mon Sep 17 00:00:00 2001 | ||
From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk> | ||
Date: Wed, 10 Apr 2024 20:42:43 +0100 | ||
Subject: [PATCH 2/2] net: dsa: allow DSA switch drivers to provide their own | ||
phylink mac ops | ||
|
||
Rather than having a shim for each and every phylink MAC operation, | ||
allow DSA switch drivers to provide their own ops structure. When a | ||
DSA driver provides the phylink MAC operations, the shimmed ops must | ||
not be provided, so fail an attempt to register a switch with both | ||
the phylink_mac_ops in struct dsa_switch and the phylink_mac_* | ||
operations populated in dsa_switch_ops populated. | ||
|
||
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> | ||
Reviewed-by: Vladimir Oltean <olteanv@gmail.com> | ||
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com> | ||
Link: https://lore.kernel.org/r/E1rudqF-006K9H-Cc@rmk-PC.armlinux.org.uk | ||
Signed-off-by: Jakub Kicinski <kuba@kernel.org> | ||
--- | ||
include/net/dsa.h | 5 +++++ | ||
net/dsa/dsa.c | 11 +++++++++++ | ||
net/dsa/port.c | 26 ++++++++++++++++++++------ | ||
3 files changed, 36 insertions(+), 6 deletions(-) | ||
|
||
--- a/include/net/dsa.h | ||
+++ b/include/net/dsa.h | ||
@@ -468,6 +468,11 @@ struct dsa_switch { | ||
const struct dsa_switch_ops *ops; | ||
|
||
/* | ||
+ * Allow a DSA switch driver to override the phylink MAC ops | ||
+ */ | ||
+ const struct phylink_mac_ops *phylink_mac_ops; | ||
+ | ||
+ /* | ||
* Slave mii_bus and devices for the individual ports. | ||
*/ | ||
u32 phys_mii_mask; | ||
--- a/net/dsa/port.c | ||
+++ b/net/dsa/port.c | ||
@@ -1675,6 +1675,7 @@ static const struct phylink_mac_ops dsa_ | ||
|
||
int dsa_port_phylink_create(struct dsa_port *dp) | ||
{ | ||
+ const struct phylink_mac_ops *mac_ops; | ||
struct dsa_switch *ds = dp->ds; | ||
phy_interface_t mode; | ||
struct phylink *pl; | ||
@@ -1694,8 +1695,12 @@ int dsa_port_phylink_create(struct dsa_p | ||
if (ds->ops->phylink_get_caps) | ||
ds->ops->phylink_get_caps(ds, dp->index, &dp->pl_config); | ||
|
||
- pl = phylink_create(&dp->pl_config, of_fwnode_handle(dp->dn), | ||
- mode, &dsa_port_phylink_mac_ops); | ||
+ mac_ops = &dsa_port_phylink_mac_ops; | ||
+ if (ds->phylink_mac_ops) | ||
+ mac_ops = ds->phylink_mac_ops; | ||
+ | ||
+ pl = phylink_create(&dp->pl_config, of_fwnode_handle(dp->dn), mode, | ||
+ mac_ops); | ||
if (IS_ERR(pl)) { | ||
pr_err("error creating PHYLINK: %ld\n", PTR_ERR(pl)); | ||
return PTR_ERR(pl); | ||
@@ -1961,12 +1966,23 @@ static void dsa_shared_port_validate_of( | ||
dn, dsa_port_is_cpu(dp) ? "CPU" : "DSA", dp->index); | ||
} | ||
|
||
+static void dsa_shared_port_link_down(struct dsa_port *dp) | ||
+{ | ||
+ struct dsa_switch *ds = dp->ds; | ||
+ | ||
+ if (ds->phylink_mac_ops && ds->phylink_mac_ops->mac_link_down) | ||
+ ds->phylink_mac_ops->mac_link_down(&dp->pl_config, MLO_AN_FIXED, | ||
+ PHY_INTERFACE_MODE_NA); | ||
+ else if (ds->ops->phylink_mac_link_down) | ||
+ ds->ops->phylink_mac_link_down(ds, dp->index, MLO_AN_FIXED, | ||
+ PHY_INTERFACE_MODE_NA); | ||
+} | ||
+ | ||
int dsa_shared_port_link_register_of(struct dsa_port *dp) | ||
{ | ||
struct dsa_switch *ds = dp->ds; | ||
bool missing_link_description; | ||
bool missing_phy_mode; | ||
- int port = dp->index; | ||
|
||
dsa_shared_port_validate_of(dp, &missing_phy_mode, | ||
&missing_link_description); | ||
@@ -1982,9 +1998,7 @@ int dsa_shared_port_link_register_of(str | ||
"Skipping phylink registration for %s port %d\n", | ||
dsa_port_is_cpu(dp) ? "CPU" : "DSA", dp->index); | ||
} else { | ||
- if (ds->ops->phylink_mac_link_down) | ||
- ds->ops->phylink_mac_link_down(ds, port, | ||
- MLO_AN_FIXED, PHY_INTERFACE_MODE_NA); | ||
+ dsa_shared_port_link_down(dp); | ||
|
||
return dsa_shared_port_phylink_register(dp); | ||
} | ||
--- a/net/dsa/dsa2.c | ||
+++ b/net/dsa/dsa2.c | ||
@@ -1736,6 +1736,15 @@ static int dsa_switch_probe(struct dsa_s | ||
if (!ds->num_ports) | ||
return -EINVAL; | ||
|
||
+ if (ds->phylink_mac_ops) { | ||
+ if (ds->ops->phylink_mac_select_pcs || | ||
+ ds->ops->phylink_mac_config || | ||
+ ds->ops->phylink_mac_link_down || | ||
+ ds->ops->phylink_mac_link_up || | ||
+ ds->ops->adjust_link) | ||
+ return -EINVAL; | ||
+ } | ||
+ | ||
if (np) { | ||
err = dsa_switch_parse_of(ds, np); | ||
if (err) |
135 changes: 135 additions & 0 deletions
135
.../generic/backport-6.1/790-49-v6.10-net-dsa-mt7530-provide-own-phylink-MAC-operations.patc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
From 5754b3bdcd872aa229881b8f07f84a8404c7d72a Mon Sep 17 00:00:00 2001 | ||
From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk> | ||
Date: Fri, 12 Apr 2024 16:15:34 +0100 | ||
Subject: [PATCH 1/5] net: dsa: mt7530: provide own phylink MAC operations | ||
MIME-Version: 1.0 | ||
Content-Type: text/plain; charset=UTF-8 | ||
Content-Transfer-Encoding: 8bit | ||
|
||
Convert mt753x to provide its own phylink MAC operations, thus avoiding | ||
the shim layer in DSA's port.c | ||
|
||
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> | ||
Tested-by: Arınç ÜNAL <arinc.unal@arinc9.com> | ||
Link: https://lore.kernel.org/r/E1rvIco-006bQu-Fq@rmk-PC.armlinux.org.uk | ||
Signed-off-by: Paolo Abeni <pabeni@redhat.com> | ||
--- | ||
drivers/net/dsa/mt7530.c | 46 +++++++++++++++++++++++++--------------- | ||
1 file changed, 29 insertions(+), 17 deletions(-) | ||
|
||
--- a/drivers/net/dsa/mt7530.c | ||
+++ b/drivers/net/dsa/mt7530.c | ||
@@ -2841,28 +2841,34 @@ mt7531_mac_config(struct dsa_switch *ds, | ||
} | ||
|
||
static struct phylink_pcs * | ||
-mt753x_phylink_mac_select_pcs(struct dsa_switch *ds, int port, | ||
+mt753x_phylink_mac_select_pcs(struct phylink_config *config, | ||
phy_interface_t interface) | ||
{ | ||
- struct mt7530_priv *priv = ds->priv; | ||
+ struct dsa_port *dp = dsa_phylink_to_port(config); | ||
+ struct mt7530_priv *priv = dp->ds->priv; | ||
|
||
switch (interface) { | ||
case PHY_INTERFACE_MODE_TRGMII: | ||
- return &priv->pcs[port].pcs; | ||
+ return &priv->pcs[dp->index].pcs; | ||
case PHY_INTERFACE_MODE_SGMII: | ||
case PHY_INTERFACE_MODE_1000BASEX: | ||
case PHY_INTERFACE_MODE_2500BASEX: | ||
- return priv->ports[port].sgmii_pcs; | ||
+ return priv->ports[dp->index].sgmii_pcs; | ||
default: | ||
return NULL; | ||
} | ||
} | ||
|
||
static void | ||
-mt753x_phylink_mac_config(struct dsa_switch *ds, int port, unsigned int mode, | ||
+mt753x_phylink_mac_config(struct phylink_config *config, unsigned int mode, | ||
const struct phylink_link_state *state) | ||
{ | ||
- struct mt7530_priv *priv = ds->priv; | ||
+ struct dsa_port *dp = dsa_phylink_to_port(config); | ||
+ struct dsa_switch *ds = dp->ds; | ||
+ struct mt7530_priv *priv; | ||
+ int port = dp->index; | ||
+ | ||
+ priv = ds->priv; | ||
|
||
if ((port == 5 || port == 6) && priv->info->mac_port_config) | ||
priv->info->mac_port_config(ds, port, mode, state->interface); | ||
@@ -2872,23 +2878,25 @@ mt753x_phylink_mac_config(struct dsa_swi | ||
mt7530_set(priv, MT7530_PMCR_P(port), PMCR_EXT_PHY); | ||
} | ||
|
||
-static void mt753x_phylink_mac_link_down(struct dsa_switch *ds, int port, | ||
+static void mt753x_phylink_mac_link_down(struct phylink_config *config, | ||
unsigned int mode, | ||
phy_interface_t interface) | ||
{ | ||
- struct mt7530_priv *priv = ds->priv; | ||
+ struct dsa_port *dp = dsa_phylink_to_port(config); | ||
+ struct mt7530_priv *priv = dp->ds->priv; | ||
|
||
- mt7530_clear(priv, MT7530_PMCR_P(port), PMCR_LINK_SETTINGS_MASK); | ||
+ mt7530_clear(priv, MT7530_PMCR_P(dp->index), PMCR_LINK_SETTINGS_MASK); | ||
} | ||
|
||
-static void mt753x_phylink_mac_link_up(struct dsa_switch *ds, int port, | ||
+static void mt753x_phylink_mac_link_up(struct phylink_config *config, | ||
+ struct phy_device *phydev, | ||
unsigned int mode, | ||
phy_interface_t interface, | ||
- struct phy_device *phydev, | ||
int speed, int duplex, | ||
bool tx_pause, bool rx_pause) | ||
{ | ||
- struct mt7530_priv *priv = ds->priv; | ||
+ struct dsa_port *dp = dsa_phylink_to_port(config); | ||
+ struct mt7530_priv *priv = dp->ds->priv; | ||
u32 mcr; | ||
|
||
mcr = PMCR_RX_EN | PMCR_TX_EN | PMCR_FORCE_LNK; | ||
@@ -2923,7 +2931,7 @@ static void mt753x_phylink_mac_link_up(s | ||
} | ||
} | ||
|
||
- mt7530_set(priv, MT7530_PMCR_P(port), mcr); | ||
+ mt7530_set(priv, MT7530_PMCR_P(dp->index), mcr); | ||
} | ||
|
||
static void mt753x_phylink_get_caps(struct dsa_switch *ds, int port, | ||
@@ -3148,16 +3156,19 @@ const struct dsa_switch_ops mt7530_switc | ||
.port_mirror_add = mt753x_port_mirror_add, | ||
.port_mirror_del = mt753x_port_mirror_del, | ||
.phylink_get_caps = mt753x_phylink_get_caps, | ||
- .phylink_mac_select_pcs = mt753x_phylink_mac_select_pcs, | ||
- .phylink_mac_config = mt753x_phylink_mac_config, | ||
- .phylink_mac_link_down = mt753x_phylink_mac_link_down, | ||
- .phylink_mac_link_up = mt753x_phylink_mac_link_up, | ||
.get_mac_eee = mt753x_get_mac_eee, | ||
.set_mac_eee = mt753x_set_mac_eee, | ||
.master_state_change = mt753x_conduit_state_change, | ||
}; | ||
EXPORT_SYMBOL_GPL(mt7530_switch_ops); | ||
|
||
+static const struct phylink_mac_ops mt753x_phylink_mac_ops = { | ||
+ .mac_select_pcs = mt753x_phylink_mac_select_pcs, | ||
+ .mac_config = mt753x_phylink_mac_config, | ||
+ .mac_link_down = mt753x_phylink_mac_link_down, | ||
+ .mac_link_up = mt753x_phylink_mac_link_up, | ||
+}; | ||
+ | ||
const struct mt753x_info mt753x_table[] = { | ||
[ID_MT7621] = { | ||
.id = ID_MT7621, | ||
@@ -3227,6 +3238,7 @@ mt7530_probe_common(struct mt7530_priv * | ||
priv->dev = dev; | ||
priv->ds->priv = priv; | ||
priv->ds->ops = &mt7530_switch_ops; | ||
+ priv->ds->phylink_mac_ops = &mt753x_phylink_mac_ops; | ||
mutex_init(&priv->reg_mutex); | ||
dev_set_drvdata(dev, priv); | ||
|
Oops, something went wrong.