2024-04-23 18:34:19

by Florian Fainelli

[permalink] [raw]
Subject: [PATCH net-next 0/8] net: dsa: b53: Remove adjust_link

b53 is now the only remaining driver that uses both PHYLIB's adjust_link
and PHYLINK's mac_ops callbacks, convert entirely to PHYLINK.

Florian Fainelli (8):
net: dsa: b53: Stop exporting b53_phylink_* routines
net: dsa: b53: Introduce b53_adjust_531x5_rgmii()
net: dsa: b53: Introduce b53_adjust_5325_mii()
net: dsa: b53: Force flow control for BCM5301X CPU port(s)
net: dsa: b53: Configure RGMII for 531x5 and MII for 5325
net: dsa: b53: Call b53_eee_init() from b53_mac_link_up()
net: dsa: b53: Remove b53_adjust_link()
net: dsa: b53: provide own phylink MAC operations

drivers/net/dsa/b53/b53_common.c | 208 ++++++++++++++++---------------
drivers/net/dsa/b53/b53_priv.h | 12 --
2 files changed, 105 insertions(+), 115 deletions(-)

--
2.34.1



2024-04-23 18:34:19

by Florian Fainelli

[permalink] [raw]
Subject: [PATCH net-next 4/8] net: dsa: b53: Force flow control for BCM5301X CPU port(s)

Just like what b53_adjust_link() does, force flow control for the
BCM5301X CPU port(s) by forcing rx_pause and tx_pause in
b53_phylink_mac_link_up(). Preparatory step for getting rid of
b53_adjust_link().

Signed-off-by: Florian Fainelli <[email protected]>
---
drivers/net/dsa/b53/b53_common.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
index a127a17be11c..6277ab7dcb7f 100644
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
@@ -1475,6 +1475,10 @@ static void b53_phylink_mac_link_up(struct dsa_switch *ds, int port,
return;

if (mode == MLO_AN_FIXED) {
+ /* Force flow control on BCM5301x's CPU port */
+ if (is5301x(dev) && dsa_is_cpu_port(ds, port))
+ tx_pause = rx_pause = true;
+
b53_force_port_config(dev, port, speed, duplex,
tx_pause, rx_pause);
b53_force_link(dev, port, true);
--
2.34.1


2024-04-23 18:34:30

by Florian Fainelli

[permalink] [raw]
Subject: [PATCH net-next 6/8] net: dsa: b53: Call b53_eee_init() from b53_mac_link_up()

And make sure this is done for the MLO_AN_PHY case, where it actually
makes sense, contrary to b53_adjust_link() which only did it for
fixed-PHY configurations where it does not make sense.

Signed-off-by: Florian Fainelli <[email protected]>
---
drivers/net/dsa/b53/b53_common.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
index 18b87e903943..a4b50ee97f87 100644
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
@@ -1481,9 +1481,13 @@ static void b53_phylink_mac_link_up(struct dsa_switch *ds, int port,
bool tx_pause, bool rx_pause)
{
struct b53_device *dev = ds->priv;
+ struct ethtool_keee *p = &dev->ports[port].eee;

- if (mode == MLO_AN_PHY)
+ if (mode == MLO_AN_PHY) {
+ /* Re-negotiate EEE if it was enabled already */
+ p->eee_enabled = b53_eee_init(ds, port, phydev);
return;
+ }

if (mode == MLO_AN_FIXED) {
/* Force flow control on BCM5301x's CPU port */
--
2.34.1


2024-04-23 18:34:32

by Florian Fainelli

[permalink] [raw]
Subject: [PATCH net-next 1/8] net: dsa: b53: Stop exporting b53_phylink_* routines

They are not used outside of the b53_common.c file, no need to be
exported.

Signed-off-by: Florian Fainelli <[email protected]>
---
drivers/net/dsa/b53/b53_common.c | 27 ++++++++++++---------------
drivers/net/dsa/b53/b53_priv.h | 12 ------------
2 files changed, 12 insertions(+), 27 deletions(-)

diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
index b2eeff04f4c8..bd069439549f 100644
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
@@ -1420,16 +1420,15 @@ static struct phylink_pcs *b53_phylink_mac_select_pcs(struct dsa_switch *ds,
return dev->ops->phylink_mac_select_pcs(dev, port, interface);
}

-void b53_phylink_mac_config(struct dsa_switch *ds, int port,
- unsigned int mode,
- const struct phylink_link_state *state)
+static void b53_phylink_mac_config(struct dsa_switch *ds, int port,
+ unsigned int mode,
+ const struct phylink_link_state *state)
{
}
-EXPORT_SYMBOL(b53_phylink_mac_config);

-void b53_phylink_mac_link_down(struct dsa_switch *ds, int port,
- unsigned int mode,
- phy_interface_t interface)
+static void b53_phylink_mac_link_down(struct dsa_switch *ds, int port,
+ unsigned int mode,
+ phy_interface_t interface)
{
struct b53_device *dev = ds->priv;

@@ -1445,14 +1444,13 @@ void b53_phylink_mac_link_down(struct dsa_switch *ds, int port,
dev->ops->serdes_link_set)
dev->ops->serdes_link_set(dev, port, mode, interface, false);
}
-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,
- struct phy_device *phydev,
- int speed, int duplex,
- bool tx_pause, bool rx_pause)
+static void b53_phylink_mac_link_up(struct dsa_switch *ds, int port,
+ unsigned int mode,
+ phy_interface_t interface,
+ struct phy_device *phydev,
+ int speed, int duplex,
+ bool tx_pause, bool rx_pause)
{
struct b53_device *dev = ds->priv;

@@ -1473,7 +1471,6 @@ void b53_phylink_mac_link_up(struct dsa_switch *ds, int port,
dev->ops->serdes_link_set)
dev->ops->serdes_link_set(dev, port, mode, interface, true);
}
-EXPORT_SYMBOL(b53_phylink_mac_link_up);

int b53_vlan_filtering(struct dsa_switch *ds, int port, bool vlan_filtering,
struct netlink_ext_ack *extack)
diff --git a/drivers/net/dsa/b53/b53_priv.h b/drivers/net/dsa/b53/b53_priv.h
index c13a907947f1..05141176daf5 100644
--- a/drivers/net/dsa/b53/b53_priv.h
+++ b/drivers/net/dsa/b53/b53_priv.h
@@ -352,18 +352,6 @@ int b53_br_flags(struct dsa_switch *ds, int port,
struct netlink_ext_ack *extack);
int b53_setup_devlink_resources(struct dsa_switch *ds);
void b53_port_event(struct dsa_switch *ds, int port);
-void b53_phylink_mac_config(struct dsa_switch *ds, int port,
- unsigned int mode,
- const struct phylink_link_state *state);
-void b53_phylink_mac_link_down(struct dsa_switch *ds, int port,
- unsigned int mode,
- phy_interface_t interface);
-void b53_phylink_mac_link_up(struct dsa_switch *ds, int port,
- unsigned int mode,
- phy_interface_t interface,
- struct phy_device *phydev,
- int speed, int duplex,
- bool tx_pause, bool rx_pause);
int b53_vlan_filtering(struct dsa_switch *ds, int port, bool vlan_filtering,
struct netlink_ext_ack *extack);
int b53_vlan_add(struct dsa_switch *ds, int port,
--
2.34.1


2024-04-23 19:14:52

by Russell King (Oracle)

[permalink] [raw]
Subject: Re: [PATCH net-next 0/8] net: dsa: b53: Remove adjust_link

On Tue, Apr 23, 2024 at 11:33:31AM -0700, Florian Fainelli wrote:
> b53 is now the only remaining driver that uses both PHYLIB's adjust_link
> and PHYLINK's mac_ops callbacks, convert entirely to PHYLINK.
>
> Florian Fainelli (8):
> net: dsa: b53: Stop exporting b53_phylink_* routines
> net: dsa: b53: Introduce b53_adjust_531x5_rgmii()
> net: dsa: b53: Introduce b53_adjust_5325_mii()
> net: dsa: b53: Force flow control for BCM5301X CPU port(s)
> net: dsa: b53: Configure RGMII for 531x5 and MII for 5325
> net: dsa: b53: Call b53_eee_init() from b53_mac_link_up()
> net: dsa: b53: Remove b53_adjust_link()
> net: dsa: b53: provide own phylink MAC operations

Read through the series, nothing obvious stands out, thanks for doing
this!

For the series:

Reviewed-by: Russell King (Oracle) <[email protected]>

--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

2024-04-23 19:16:22

by Florian Fainelli

[permalink] [raw]
Subject: Re: [PATCH net-next 0/8] net: dsa: b53: Remove adjust_link

On 4/23/24 12:14, Russell King (Oracle) wrote:
> On Tue, Apr 23, 2024 at 11:33:31AM -0700, Florian Fainelli wrote:
>> b53 is now the only remaining driver that uses both PHYLIB's adjust_link
>> and PHYLINK's mac_ops callbacks, convert entirely to PHYLINK.
>>
>> Florian Fainelli (8):
>> net: dsa: b53: Stop exporting b53_phylink_* routines
>> net: dsa: b53: Introduce b53_adjust_531x5_rgmii()
>> net: dsa: b53: Introduce b53_adjust_5325_mii()
>> net: dsa: b53: Force flow control for BCM5301X CPU port(s)
>> net: dsa: b53: Configure RGMII for 531x5 and MII for 5325
>> net: dsa: b53: Call b53_eee_init() from b53_mac_link_up()
>> net: dsa: b53: Remove b53_adjust_link()
>> net: dsa: b53: provide own phylink MAC operations
>
> Read through the series, nothing obvious stands out, thanks for doing
> this!

And thank you for the reminder this needed to be done, once this lands I
will submit the removal of the adjust_link within net/dsa/, unless you
have that queued up already ready to go?

>
> For the series:
>
> Reviewed-by: Russell King (Oracle) <[email protected]>
>

--
Florian


Attachments:
smime.p7s (4.12 kB)
S/MIME Cryptographic Signature

2024-04-23 19:36:05

by Florian Fainelli

[permalink] [raw]
Subject: [PATCH net-next 7/8] net: dsa: b53: Remove b53_adjust_link()

Only use the PHYLINK implementation from there on now that an equivalent
configuration is applied to all of the switch ports.

Signed-off-by: Florian Fainelli <[email protected]>
---
drivers/net/dsa/b53/b53_common.c | 40 --------------------------------
1 file changed, 40 deletions(-)

diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
index a4b50ee97f87..e490ef0fd3f1 100644
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
@@ -1332,45 +1332,6 @@ static void b53_adjust_5325_mii(struct dsa_switch *ds, int port)
}
}

-static void b53_adjust_link(struct dsa_switch *ds, int port,
- struct phy_device *phydev)
-{
- struct b53_device *dev = ds->priv;
- struct ethtool_keee *p = &dev->ports[port].eee;
- bool tx_pause = false;
- bool rx_pause = false;
-
- if (!phy_is_pseudo_fixed_link(phydev))
- return;
-
- /* Enable flow control on BCM5301x's CPU port */
- if (is5301x(dev) && dsa_is_cpu_port(ds, port))
- tx_pause = rx_pause = true;
-
- if (phydev->pause) {
- if (phydev->asym_pause)
- tx_pause = true;
- rx_pause = true;
- }
-
- b53_force_port_config(dev, port, phydev->speed, phydev->duplex,
- tx_pause, rx_pause);
- b53_force_link(dev, port, phydev->link);
-
- if (is63xx(dev) && port >= B53_63XX_RGMII0)
- b53_adjust_63xx_rgmii(ds, port, phydev->interface);
-
- if (is531x5(dev) && phy_interface_is_rgmii(phydev))
- b53_adjust_531x5_rgmii(ds, port, phydev->interface);
-
- /* configure MII port if necessary */
- if (is5325(dev))
- b53_adjust_5325_mii(ds, port);
-
- /* Re-negotiate EEE if it was enabled already */
- p->eee_enabled = b53_eee_init(ds, port, phydev);
-}
-
void b53_port_event(struct dsa_switch *ds, int port)
{
struct b53_device *dev = ds->priv;
@@ -2308,7 +2269,6 @@ static const struct dsa_switch_ops b53_switch_ops = {
.get_ethtool_phy_stats = b53_get_ethtool_phy_stats,
.phy_read = b53_phy_read16,
.phy_write = b53_phy_write16,
- .adjust_link = b53_adjust_link,
.phylink_get_caps = b53_phylink_get_caps,
.phylink_mac_select_pcs = b53_phylink_mac_select_pcs,
.phylink_mac_config = b53_phylink_mac_config,
--
2.34.1


2024-04-23 19:42:27

by Florian Fainelli

[permalink] [raw]
Subject: [PATCH net-next 8/8] net: dsa: b53: provide own phylink MAC operations

Convert b53 to provide its own phylink MAC operations, thus avoiding the
shim layer in DSA's port.c

Signed-off-by: Florian Fainelli <[email protected]>
---
drivers/net/dsa/b53/b53_common.c | 40 +++++++++++++++++++++-----------
1 file changed, 26 insertions(+), 14 deletions(-)

diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
index e490ef0fd3f1..8f50abe739b7 100644
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
@@ -1383,24 +1383,27 @@ static void b53_phylink_get_caps(struct dsa_switch *ds, int port,
dev->ops->phylink_get_caps(dev, port, config);
}

-static struct phylink_pcs *b53_phylink_mac_select_pcs(struct dsa_switch *ds,
- int port,
+static struct phylink_pcs *b53_phylink_mac_select_pcs(struct phylink_config *config,
phy_interface_t interface)
{
- struct b53_device *dev = ds->priv;
+ struct dsa_port *dp = dsa_phylink_to_port(config);
+ struct b53_device *dev = dp->ds->priv;

if (!dev->ops->phylink_mac_select_pcs)
return NULL;

- return dev->ops->phylink_mac_select_pcs(dev, port, interface);
+ return dev->ops->phylink_mac_select_pcs(dev, dp->index, interface);
}

-static void b53_phylink_mac_config(struct dsa_switch *ds, int port,
+static void b53_phylink_mac_config(struct phylink_config *config,
unsigned int mode,
const struct phylink_link_state *state)
{
+ struct dsa_port *dp = dsa_phylink_to_port(config);
phy_interface_t interface = state->interface;
+ struct dsa_switch *ds = dp->ds;
struct b53_device *dev = ds->priv;
+ int port = dp->index;

if (is63xx(dev) && port >= B53_63XX_RGMII0)
b53_adjust_63xx_rgmii(ds, port, interface);
@@ -1415,11 +1418,13 @@ static void b53_phylink_mac_config(struct dsa_switch *ds, int port,
}
}

-static void b53_phylink_mac_link_down(struct dsa_switch *ds, int port,
+static void b53_phylink_mac_link_down(struct phylink_config *config,
unsigned int mode,
phy_interface_t interface)
{
- struct b53_device *dev = ds->priv;
+ struct dsa_port *dp = dsa_phylink_to_port(config);
+ struct b53_device *dev = dp->ds->priv;
+ int port = dp->index;

if (mode == MLO_AN_PHY)
return;
@@ -1434,15 +1439,18 @@ static void b53_phylink_mac_link_down(struct dsa_switch *ds, int port,
dev->ops->serdes_link_set(dev, port, mode, interface, false);
}

-static void b53_phylink_mac_link_up(struct dsa_switch *ds, int port,
+static void b53_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 dsa_port *dp = dsa_phylink_to_port(config);
+ struct dsa_switch *ds = dp->ds;
struct b53_device *dev = ds->priv;
- struct ethtool_keee *p = &dev->ports[port].eee;
+ struct ethtool_keee *p = &dev->ports[dp->index].eee;
+ int port = dp->index;

if (mode == MLO_AN_PHY) {
/* Re-negotiate EEE if it was enabled already */
@@ -2259,6 +2267,13 @@ static int b53_get_max_mtu(struct dsa_switch *ds, int port)
return JMS_MAX_SIZE;
}

+static const struct phylink_mac_ops b53_phylink_mac_ops = {
+ .mac_select_pcs = b53_phylink_mac_select_pcs,
+ .mac_config = b53_phylink_mac_config,
+ .mac_link_down = b53_phylink_mac_link_down,
+ .mac_link_up = b53_phylink_mac_link_up,
+};
+
static const struct dsa_switch_ops b53_switch_ops = {
.get_tag_protocol = b53_get_tag_protocol,
.setup = b53_setup,
@@ -2270,10 +2285,6 @@ static const struct dsa_switch_ops b53_switch_ops = {
.phy_read = b53_phy_read16,
.phy_write = b53_phy_write16,
.phylink_get_caps = b53_phylink_get_caps,
- .phylink_mac_select_pcs = b53_phylink_mac_select_pcs,
- .phylink_mac_config = b53_phylink_mac_config,
- .phylink_mac_link_down = b53_phylink_mac_link_down,
- .phylink_mac_link_up = b53_phylink_mac_link_up,
.port_enable = b53_enable_port,
.port_disable = b53_disable_port,
.get_mac_eee = b53_get_mac_eee,
@@ -2716,6 +2727,7 @@ struct b53_device *b53_switch_alloc(struct device *base,
dev->priv = priv;
dev->ops = ops;
ds->ops = &b53_switch_ops;
+ ds->phylink_mac_ops = &b53_phylink_mac_ops;
dev->vlan_enabled = true;
/* Let DSA handle the case were multiple bridges span the same switch
* device and different VLAN awareness settings are requested, which
--
2.34.1


2024-04-23 19:43:47

by Florian Fainelli

[permalink] [raw]
Subject: [PATCH net-next 2/8] net: dsa: b53: Introduce b53_adjust_531x5_rgmii()

Takes care of doing the 531x5 switch series specific RGMII programming
and is called from b53_adjust_link() to allow the future removal of
b53_adjust_link().

Signed-off-by: Florian Fainelli <[email protected]>
---
drivers/net/dsa/b53/b53_common.c | 84 +++++++++++++++++---------------
1 file changed, 46 insertions(+), 38 deletions(-)

diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
index bd069439549f..744567c465f7 100644
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
@@ -1266,14 +1266,57 @@ static void b53_adjust_63xx_rgmii(struct dsa_switch *ds, int port,
phy_modes(interface));
}

+static void b53_adjust_531x5_rgmii(struct dsa_switch *ds, int port,
+ phy_interface_t interface)
+{
+ struct b53_device *dev = ds->priv;
+ u8 rgmii_ctrl = 0, off;
+
+ if (port == dev->imp_port)
+ off = B53_RGMII_CTRL_IMP;
+ else
+ off = B53_RGMII_CTRL_P(port);
+
+ /* Configure the port RGMII clock delay by DLL disabled and
+ * tx_clk aligned timing (restoring to reset defaults)
+ */
+ b53_read8(dev, B53_CTRL_PAGE, off, &rgmii_ctrl);
+ rgmii_ctrl &= ~(RGMII_CTRL_DLL_RXC | RGMII_CTRL_DLL_TXC |
+ RGMII_CTRL_TIMING_SEL);
+
+ /* PHY_INTERFACE_MODE_RGMII_TXID means TX internal delay, make
+ * sure that we enable the port TX clock internal delay to
+ * account for this internal delay that is inserted, otherwise
+ * the switch won't be able to receive correctly.
+ *
+ * PHY_INTERFACE_MODE_RGMII means that we are not introducing
+ * any delay neither on transmission nor reception, so the
+ * BCM53125 must also be configured accordingly to account for
+ * the lack of delay and introduce
+ *
+ * The BCM53125 switch has its RX clock and TX clock control
+ * swapped, hence the reason why we modify the TX clock path in
+ * the "RGMII" case
+ */
+ if (interface == PHY_INTERFACE_MODE_RGMII_TXID)
+ rgmii_ctrl |= RGMII_CTRL_DLL_TXC;
+ if (interface == PHY_INTERFACE_MODE_RGMII)
+ rgmii_ctrl |= RGMII_CTRL_DLL_TXC | RGMII_CTRL_DLL_RXC;
+ rgmii_ctrl |= RGMII_CTRL_TIMING_SEL;
+ b53_write8(dev, B53_CTRL_PAGE, off, rgmii_ctrl);
+
+ dev_info(ds->dev, "Configured port %d for %s\n", port,
+ phy_modes(interface));
+}
+
static void b53_adjust_link(struct dsa_switch *ds, int port,
struct phy_device *phydev)
{
struct b53_device *dev = ds->priv;
struct ethtool_keee *p = &dev->ports[port].eee;
- u8 rgmii_ctrl = 0, reg = 0, off;
bool tx_pause = false;
bool rx_pause = false;
+ u8 reg = 0;

if (!phy_is_pseudo_fixed_link(phydev))
return;
@@ -1295,43 +1338,8 @@ static void b53_adjust_link(struct dsa_switch *ds, int port,
if (is63xx(dev) && port >= B53_63XX_RGMII0)
b53_adjust_63xx_rgmii(ds, port, phydev->interface);

- if (is531x5(dev) && phy_interface_is_rgmii(phydev)) {
- if (port == dev->imp_port)
- off = B53_RGMII_CTRL_IMP;
- else
- off = B53_RGMII_CTRL_P(port);
-
- /* Configure the port RGMII clock delay by DLL disabled and
- * tx_clk aligned timing (restoring to reset defaults)
- */
- b53_read8(dev, B53_CTRL_PAGE, off, &rgmii_ctrl);
- rgmii_ctrl &= ~(RGMII_CTRL_DLL_RXC | RGMII_CTRL_DLL_TXC |
- RGMII_CTRL_TIMING_SEL);
-
- /* PHY_INTERFACE_MODE_RGMII_TXID means TX internal delay, make
- * sure that we enable the port TX clock internal delay to
- * account for this internal delay that is inserted, otherwise
- * the switch won't be able to receive correctly.
- *
- * PHY_INTERFACE_MODE_RGMII means that we are not introducing
- * any delay neither on transmission nor reception, so the
- * BCM53125 must also be configured accordingly to account for
- * the lack of delay and introduce
- *
- * The BCM53125 switch has its RX clock and TX clock control
- * swapped, hence the reason why we modify the TX clock path in
- * the "RGMII" case
- */
- if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID)
- rgmii_ctrl |= RGMII_CTRL_DLL_TXC;
- if (phydev->interface == PHY_INTERFACE_MODE_RGMII)
- rgmii_ctrl |= RGMII_CTRL_DLL_TXC | RGMII_CTRL_DLL_RXC;
- rgmii_ctrl |= RGMII_CTRL_TIMING_SEL;
- b53_write8(dev, B53_CTRL_PAGE, off, rgmii_ctrl);
-
- dev_info(ds->dev, "Configured port %d for %s\n", port,
- phy_modes(phydev->interface));
- }
+ if (is531x5(dev) && phy_interface_is_rgmii(phydev))
+ b53_adjust_531x5_rgmii(ds, port, phydev->interface);

/* configure MII port if necessary */
if (is5325(dev)) {
--
2.34.1


2024-04-23 20:48:51

by Florian Fainelli

[permalink] [raw]
Subject: [PATCH net-next 3/8] net: dsa: b53: Introduce b53_adjust_5325_mii()

Takes care of doing the 5325 switch series specific MII programming and
is called from b53_adjust_link() to allow the future removal of
b53_adjust_link().

Signed-off-by: Florian Fainelli <[email protected]>
---
drivers/net/dsa/b53/b53_common.c | 44 ++++++++++++++++++--------------
1 file changed, 25 insertions(+), 19 deletions(-)

diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
index 744567c465f7..a127a17be11c 100644
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
@@ -1309,6 +1309,29 @@ static void b53_adjust_531x5_rgmii(struct dsa_switch *ds, int port,
phy_modes(interface));
}

+static void b53_adjust_5325_mii(struct dsa_switch *ds, int port)
+{
+ struct b53_device *dev = ds->priv;
+ u8 reg = 0;
+
+ b53_read8(dev, B53_CTRL_PAGE, B53_PORT_OVERRIDE_CTRL,
+ &reg);
+
+ /* reverse mii needs to be enabled */
+ if (!(reg & PORT_OVERRIDE_RV_MII_25)) {
+ b53_write8(dev, B53_CTRL_PAGE, B53_PORT_OVERRIDE_CTRL,
+ reg | PORT_OVERRIDE_RV_MII_25);
+ b53_read8(dev, B53_CTRL_PAGE, B53_PORT_OVERRIDE_CTRL,
+ &reg);
+
+ if (!(reg & PORT_OVERRIDE_RV_MII_25)) {
+ dev_err(ds->dev,
+ "Failed to enable reverse MII mode\n");
+ return;
+ }
+ }
+}
+
static void b53_adjust_link(struct dsa_switch *ds, int port,
struct phy_device *phydev)
{
@@ -1316,7 +1339,6 @@ static void b53_adjust_link(struct dsa_switch *ds, int port,
struct ethtool_keee *p = &dev->ports[port].eee;
bool tx_pause = false;
bool rx_pause = false;
- u8 reg = 0;

if (!phy_is_pseudo_fixed_link(phydev))
return;
@@ -1342,24 +1364,8 @@ static void b53_adjust_link(struct dsa_switch *ds, int port,
b53_adjust_531x5_rgmii(ds, port, phydev->interface);

/* configure MII port if necessary */
- if (is5325(dev)) {
- b53_read8(dev, B53_CTRL_PAGE, B53_PORT_OVERRIDE_CTRL,
- &reg);
-
- /* reverse mii needs to be enabled */
- if (!(reg & PORT_OVERRIDE_RV_MII_25)) {
- b53_write8(dev, B53_CTRL_PAGE, B53_PORT_OVERRIDE_CTRL,
- reg | PORT_OVERRIDE_RV_MII_25);
- b53_read8(dev, B53_CTRL_PAGE, B53_PORT_OVERRIDE_CTRL,
- &reg);
-
- if (!(reg & PORT_OVERRIDE_RV_MII_25)) {
- dev_err(ds->dev,
- "Failed to enable reverse MII mode\n");
- return;
- }
- }
- }
+ if (is5325(dev))
+ b53_adjust_5325_mii(ds, port);

/* Re-negotiate EEE if it was enabled already */
p->eee_enabled = b53_eee_init(ds, port, phydev);
--
2.34.1


2024-04-23 20:52:22

by Florian Fainelli

[permalink] [raw]
Subject: [PATCH net-next 5/8] net: dsa: b53: Configure RGMII for 531x5 and MII for 5325

Call b53_adjust_531x5_rgmii() and b53_adjust_5325_mii() from
b53_phylink_mac_config() when we have a fixed PHY in preparation for removing
b53_adjust_link(). Also move b53_adjust_63xx_rgmii() to
b53_phylink_mac_config() where it logically belongs.

Signed-off-by: Florian Fainelli <[email protected]>
---
drivers/net/dsa/b53/b53_common.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
index 6277ab7dcb7f..18b87e903943 100644
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
@@ -1438,6 +1438,20 @@ static void b53_phylink_mac_config(struct dsa_switch *ds, int port,
unsigned int mode,
const struct phylink_link_state *state)
{
+ phy_interface_t interface = state->interface;
+ struct b53_device *dev = ds->priv;
+
+ if (is63xx(dev) && port >= B53_63XX_RGMII0)
+ b53_adjust_63xx_rgmii(ds, port, interface);
+
+ if (mode == MLO_AN_FIXED) {
+ if (is531x5(dev) && phy_interface_mode_is_rgmii(interface))
+ b53_adjust_531x5_rgmii(ds, port, interface);
+
+ /* configure MII port if necessary */
+ if (is5325(dev))
+ b53_adjust_5325_mii(ds, port);
+ }
}

static void b53_phylink_mac_link_down(struct dsa_switch *ds, int port,
@@ -1468,9 +1482,6 @@ static void b53_phylink_mac_link_up(struct dsa_switch *ds, int port,
{
struct b53_device *dev = ds->priv;

- if (is63xx(dev) && port >= B53_63XX_RGMII0)
- b53_adjust_63xx_rgmii(ds, port, interface);
-
if (mode == MLO_AN_PHY)
return;

--
2.34.1


2024-04-23 21:17:27

by Russell King (Oracle)

[permalink] [raw]
Subject: Re: [PATCH net-next 0/8] net: dsa: b53: Remove adjust_link

On Tue, Apr 23, 2024 at 12:15:49PM -0700, Florian Fainelli wrote:
> And thank you for the reminder this needed to be done, once this lands I
> will submit the removal of the adjust_link within net/dsa/, unless you have
> that queued up already ready to go?

I don't have that queued up, but it would be great to get that done as
well. I think it would get rid of a reasonable amount of code in
net/dsa?

--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

2024-04-25 18:50:44

by patchwork-bot+netdevbpf

[permalink] [raw]
Subject: Re: [PATCH net-next 0/8] net: dsa: b53: Remove adjust_link

Hello:

This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <[email protected]>:

On Tue, 23 Apr 2024 11:33:31 -0700 you wrote:
> b53 is now the only remaining driver that uses both PHYLIB's adjust_link
> and PHYLINK's mac_ops callbacks, convert entirely to PHYLINK.
>
> Florian Fainelli (8):
> net: dsa: b53: Stop exporting b53_phylink_* routines
> net: dsa: b53: Introduce b53_adjust_531x5_rgmii()
> net: dsa: b53: Introduce b53_adjust_5325_mii()
> net: dsa: b53: Force flow control for BCM5301X CPU port(s)
> net: dsa: b53: Configure RGMII for 531x5 and MII for 5325
> net: dsa: b53: Call b53_eee_init() from b53_mac_link_up()
> net: dsa: b53: Remove b53_adjust_link()
> net: dsa: b53: provide own phylink MAC operations
>
> [...]

Here is the summary with links:
- [net-next,1/8] net: dsa: b53: Stop exporting b53_phylink_* routines
https://git.kernel.org/netdev/net-next/c/65245197ecec
- [net-next,2/8] net: dsa: b53: Introduce b53_adjust_531x5_rgmii()
https://git.kernel.org/netdev/net-next/c/b3d06dc3707f
- [net-next,3/8] net: dsa: b53: Introduce b53_adjust_5325_mii()
https://git.kernel.org/netdev/net-next/c/0d18dea4cde6
- [net-next,4/8] net: dsa: b53: Force flow control for BCM5301X CPU port(s)
https://git.kernel.org/netdev/net-next/c/93a2579ed08c
- [net-next,5/8] net: dsa: b53: Configure RGMII for 531x5 and MII for 5325
https://git.kernel.org/netdev/net-next/c/536e5b2ecbae
- [net-next,6/8] net: dsa: b53: Call b53_eee_init() from b53_mac_link_up()
https://git.kernel.org/netdev/net-next/c/888128f360e1
- [net-next,7/8] net: dsa: b53: Remove b53_adjust_link()
https://git.kernel.org/netdev/net-next/c/600354352cf2
- [net-next,8/8] net: dsa: b53: provide own phylink MAC operations
https://git.kernel.org/netdev/net-next/c/d0a35d2948ec

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html