2023-01-17 00:18:48

by Michael Walle

[permalink] [raw]
Subject: [PATCH net-next 00/12] net: mdio: Continue separating C22 and C45

I've picked this older series from Andrew up and rebased it onto
the latest net-next.

This is the third (and hopefully last) patch set in the series which
separates the C22 and C45 MDIO bus transactions at the API level to the
MDIO bus drivers.

The first patch is a newer version of the former "net: dsa: Separate C22
and C45 MDIO bus transaction methods", which only contains the mt7530
changes. Although posted as v1, because this is a new series, there is a
changelog included in the patch comment section.

The last patch is a new one, which isn't from Andrew's tree.

To: Sean Wang <[email protected]>
To: Landen Chao <[email protected]>
To: DENG Qingfang <[email protected]>
To: Florian Fainelli <[email protected]>
To: Vladimir Oltean <[email protected]>
To: "David S. Miller" <[email protected]>
To: Eric Dumazet <[email protected]>
To: Jakub Kicinski <[email protected]>
To: Paolo Abeni <[email protected]>
To: Matthias Brugger <[email protected]>
To: Russell King <[email protected]>
To: Byungho An <[email protected]>
To: Nicolas Ferre <[email protected]>
To: Claudiu Beznea <[email protected]>
To: Jesse Brandeburg <[email protected]>
To: Tony Nguyen <[email protected]>
To: Yisen Zhuang <[email protected]>
To: Salil Mehta <[email protected]>
To: Tom Lendacky <[email protected]>
To: Shyam Sundar S K <[email protected]>
To: Sergey Shtylyov <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: Andrew Lunn <[email protected]>
Signed-off-by: Michael Walle <[email protected]>

---
Andrew Lunn (11):
net: dsa: mt7530: Separate C22 and C45 MDIO bus transactions
net: sxgbe: Separate C22 and C45 transactions
net: nixge: Separate C22 and C45 transactions
net: macb: Separate C22 and C45 transactions
ixgbe: Separate C22 and C45 transactions
ixgbe: Use C45 mdiobus accessors
net: hns: Separate C22 and C45 transactions
amd-xgbe: Separate C22 and C45 transactions
amd-xgbe: Replace MII_ADDR_C45 with XGBE_ADDR_C45
net: dsa: sja1105: C45 only transactions for PCS
net: dsa: sja1105: Separate C22 and C45 transactions for T1 MDIO bus

Michael Walle (1):
net: ethernet: renesas: rswitch: C45 only transactions

drivers/net/dsa/mt7530.c | 87 ++++-----
drivers/net/dsa/mt7530.h | 15 +-
drivers/net/dsa/sja1105/sja1105.h | 16 +-
drivers/net/dsa/sja1105/sja1105_mdio.c | 131 ++++++-------
drivers/net/dsa/sja1105/sja1105_spi.c | 24 +--
drivers/net/ethernet/amd/xgbe/xgbe-common.h | 11 +-
drivers/net/ethernet/amd/xgbe/xgbe-dev.c | 91 ++++++---
drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c | 120 +++++++++---
drivers/net/ethernet/amd/xgbe/xgbe.h | 7 +-
drivers/net/ethernet/cadence/macb_main.c | 161 ++++++++++------
drivers/net/ethernet/hisilicon/hns_mdio.c | 192 +++++++++++++------
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 6 +-
drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c | 237 ++++++++++++++++++------
drivers/net/ethernet/ni/nixge.c | 141 ++++++++------
drivers/net/ethernet/renesas/rswitch.c | 28 +--
drivers/net/ethernet/samsung/sxgbe/sxgbe_mdio.c | 105 ++++++++---
16 files changed, 906 insertions(+), 466 deletions(-)
---
base-commit: c941c0a15bee01a702d82793fe605326d453d9a7
change-id: 20230116-net-next-c45-seperation-part-3-f5387bcdf3ea

Best regards,
--
Michael Walle <[email protected]>


2023-01-17 00:37:31

by Michael Walle

[permalink] [raw]
Subject: [PATCH net-next 04/12] net: macb: Separate C22 and C45 transactions

From: Andrew Lunn <[email protected]>

The macb MDIO bus driver can perform both C22 and C45 transfers.
Create separate functions for each and register the C45 versions using
the new API calls where appropriate.

Signed-off-by: Andrew Lunn <[email protected]>
Signed-off-by: Michael Walle <[email protected]>
---
drivers/net/ethernet/cadence/macb_main.c | 161 +++++++++++++++++++++----------
1 file changed, 108 insertions(+), 53 deletions(-)

diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index 95667b979fab..f2d08a2dadf9 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -334,7 +334,7 @@ static int macb_mdio_wait_for_idle(struct macb *bp)
1, MACB_MDIO_TIMEOUT);
}

-static int macb_mdio_read(struct mii_bus *bus, int mii_id, int regnum)
+static int macb_mdio_read_c22(struct mii_bus *bus, int mii_id, int regnum)
{
struct macb *bp = bus->priv;
int status;
@@ -347,31 +347,58 @@ static int macb_mdio_read(struct mii_bus *bus, int mii_id, int regnum)
if (status < 0)
goto mdio_read_exit;

- if (regnum & MII_ADDR_C45) {
- macb_writel(bp, MAN, (MACB_BF(SOF, MACB_MAN_C45_SOF)
- | MACB_BF(RW, MACB_MAN_C45_ADDR)
- | MACB_BF(PHYA, mii_id)
- | MACB_BF(REGA, (regnum >> 16) & 0x1F)
- | MACB_BF(DATA, regnum & 0xFFFF)
- | MACB_BF(CODE, MACB_MAN_C45_CODE)));
-
- status = macb_mdio_wait_for_idle(bp);
- if (status < 0)
- goto mdio_read_exit;
-
- macb_writel(bp, MAN, (MACB_BF(SOF, MACB_MAN_C45_SOF)
- | MACB_BF(RW, MACB_MAN_C45_READ)
- | MACB_BF(PHYA, mii_id)
- | MACB_BF(REGA, (regnum >> 16) & 0x1F)
- | MACB_BF(CODE, MACB_MAN_C45_CODE)));
- } else {
- macb_writel(bp, MAN, (MACB_BF(SOF, MACB_MAN_C22_SOF)
- | MACB_BF(RW, MACB_MAN_C22_READ)
- | MACB_BF(PHYA, mii_id)
- | MACB_BF(REGA, regnum)
- | MACB_BF(CODE, MACB_MAN_C22_CODE)));
+ macb_writel(bp, MAN, (MACB_BF(SOF, MACB_MAN_C22_SOF)
+ | MACB_BF(RW, MACB_MAN_C22_READ)
+ | MACB_BF(PHYA, mii_id)
+ | MACB_BF(REGA, regnum)
+ | MACB_BF(CODE, MACB_MAN_C22_CODE)));
+
+ status = macb_mdio_wait_for_idle(bp);
+ if (status < 0)
+ goto mdio_read_exit;
+
+ status = MACB_BFEXT(DATA, macb_readl(bp, MAN));
+
+mdio_read_exit:
+ pm_runtime_mark_last_busy(&bp->pdev->dev);
+ pm_runtime_put_autosuspend(&bp->pdev->dev);
+mdio_pm_exit:
+ return status;
+}
+
+static int macb_mdio_read_c45(struct mii_bus *bus, int mii_id, int devad,
+ int regnum)
+{
+ struct macb *bp = bus->priv;
+ int status;
+
+ status = pm_runtime_get_sync(&bp->pdev->dev);
+ if (status < 0) {
+ pm_runtime_put_noidle(&bp->pdev->dev);
+ goto mdio_pm_exit;
}

+ status = macb_mdio_wait_for_idle(bp);
+ if (status < 0)
+ goto mdio_read_exit;
+
+ macb_writel(bp, MAN, (MACB_BF(SOF, MACB_MAN_C45_SOF)
+ | MACB_BF(RW, MACB_MAN_C45_ADDR)
+ | MACB_BF(PHYA, mii_id)
+ | MACB_BF(REGA, devad & 0x1F)
+ | MACB_BF(DATA, regnum & 0xFFFF)
+ | MACB_BF(CODE, MACB_MAN_C45_CODE)));
+
+ status = macb_mdio_wait_for_idle(bp);
+ if (status < 0)
+ goto mdio_read_exit;
+
+ macb_writel(bp, MAN, (MACB_BF(SOF, MACB_MAN_C45_SOF)
+ | MACB_BF(RW, MACB_MAN_C45_READ)
+ | MACB_BF(PHYA, mii_id)
+ | MACB_BF(REGA, devad & 0x1F)
+ | MACB_BF(CODE, MACB_MAN_C45_CODE)));
+
status = macb_mdio_wait_for_idle(bp);
if (status < 0)
goto mdio_read_exit;
@@ -385,8 +412,8 @@ static int macb_mdio_read(struct mii_bus *bus, int mii_id, int regnum)
return status;
}

-static int macb_mdio_write(struct mii_bus *bus, int mii_id, int regnum,
- u16 value)
+static int macb_mdio_write_c22(struct mii_bus *bus, int mii_id, int regnum,
+ u16 value)
{
struct macb *bp = bus->priv;
int status;
@@ -399,37 +426,63 @@ static int macb_mdio_write(struct mii_bus *bus, int mii_id, int regnum,
if (status < 0)
goto mdio_write_exit;

- if (regnum & MII_ADDR_C45) {
- macb_writel(bp, MAN, (MACB_BF(SOF, MACB_MAN_C45_SOF)
- | MACB_BF(RW, MACB_MAN_C45_ADDR)
- | MACB_BF(PHYA, mii_id)
- | MACB_BF(REGA, (regnum >> 16) & 0x1F)
- | MACB_BF(DATA, regnum & 0xFFFF)
- | MACB_BF(CODE, MACB_MAN_C45_CODE)));
-
- status = macb_mdio_wait_for_idle(bp);
- if (status < 0)
- goto mdio_write_exit;
-
- macb_writel(bp, MAN, (MACB_BF(SOF, MACB_MAN_C45_SOF)
- | MACB_BF(RW, MACB_MAN_C45_WRITE)
- | MACB_BF(PHYA, mii_id)
- | MACB_BF(REGA, (regnum >> 16) & 0x1F)
- | MACB_BF(CODE, MACB_MAN_C45_CODE)
- | MACB_BF(DATA, value)));
- } else {
- macb_writel(bp, MAN, (MACB_BF(SOF, MACB_MAN_C22_SOF)
- | MACB_BF(RW, MACB_MAN_C22_WRITE)
- | MACB_BF(PHYA, mii_id)
- | MACB_BF(REGA, regnum)
- | MACB_BF(CODE, MACB_MAN_C22_CODE)
- | MACB_BF(DATA, value)));
+ macb_writel(bp, MAN, (MACB_BF(SOF, MACB_MAN_C22_SOF)
+ | MACB_BF(RW, MACB_MAN_C22_WRITE)
+ | MACB_BF(PHYA, mii_id)
+ | MACB_BF(REGA, regnum)
+ | MACB_BF(CODE, MACB_MAN_C22_CODE)
+ | MACB_BF(DATA, value)));
+
+ status = macb_mdio_wait_for_idle(bp);
+ if (status < 0)
+ goto mdio_write_exit;
+
+mdio_write_exit:
+ pm_runtime_mark_last_busy(&bp->pdev->dev);
+ pm_runtime_put_autosuspend(&bp->pdev->dev);
+mdio_pm_exit:
+ return status;
+}
+
+static int macb_mdio_write_c45(struct mii_bus *bus, int mii_id,
+ int devad, int regnum,
+ u16 value)
+{
+ struct macb *bp = bus->priv;
+ int status;
+
+ status = pm_runtime_get_sync(&bp->pdev->dev);
+ if (status < 0) {
+ pm_runtime_put_noidle(&bp->pdev->dev);
+ goto mdio_pm_exit;
}

status = macb_mdio_wait_for_idle(bp);
if (status < 0)
goto mdio_write_exit;

+ macb_writel(bp, MAN, (MACB_BF(SOF, MACB_MAN_C45_SOF)
+ | MACB_BF(RW, MACB_MAN_C45_ADDR)
+ | MACB_BF(PHYA, mii_id)
+ | MACB_BF(REGA, devad & 0x1F)
+ | MACB_BF(DATA, regnum & 0xFFFF)
+ | MACB_BF(CODE, MACB_MAN_C45_CODE)));
+
+ status = macb_mdio_wait_for_idle(bp);
+ if (status < 0)
+ goto mdio_write_exit;
+
+ macb_writel(bp, MAN, (MACB_BF(SOF, MACB_MAN_C45_SOF)
+ | MACB_BF(RW, MACB_MAN_C45_WRITE)
+ | MACB_BF(PHYA, mii_id)
+ | MACB_BF(REGA, devad & 0x1F)
+ | MACB_BF(CODE, MACB_MAN_C45_CODE)
+ | MACB_BF(DATA, value)));
+
+ status = macb_mdio_wait_for_idle(bp);
+ if (status < 0)
+ goto mdio_write_exit;
+
mdio_write_exit:
pm_runtime_mark_last_busy(&bp->pdev->dev);
pm_runtime_put_autosuspend(&bp->pdev->dev);
@@ -902,8 +955,10 @@ static int macb_mii_init(struct macb *bp)
}

bp->mii_bus->name = "MACB_mii_bus";
- bp->mii_bus->read = &macb_mdio_read;
- bp->mii_bus->write = &macb_mdio_write;
+ bp->mii_bus->read = &macb_mdio_read_c22;
+ bp->mii_bus->write = &macb_mdio_write_c22;
+ bp->mii_bus->read_c45 = &macb_mdio_read_c45;
+ bp->mii_bus->write_c45 = &macb_mdio_write_c45;
snprintf(bp->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x",
bp->pdev->name, bp->pdev->id);
bp->mii_bus->priv = bp;

--
2.30.2

2023-01-18 04:14:23

by patchwork-bot+netdevbpf

[permalink] [raw]
Subject: Re: [PATCH net-next 00/12] net: mdio: Continue separating C22 and C45

Hello:

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

On Tue, 17 Jan 2023 00:52:16 +0100 you wrote:
> I've picked this older series from Andrew up and rebased it onto
> the latest net-next.
>
> This is the third (and hopefully last) patch set in the series which
> separates the C22 and C45 MDIO bus transactions at the API level to the
> MDIO bus drivers.
>
> [...]

Here is the summary with links:
- [net-next,01/12] net: dsa: mt7530: Separate C22 and C45 MDIO bus transactions
https://git.kernel.org/netdev/net-next/c/defa2e541894
- [net-next,02/12] net: sxgbe: Separate C22 and C45 transactions
https://git.kernel.org/netdev/net-next/c/e078c8b5eab7
- [net-next,03/12] net: nixge: Separate C22 and C45 transactions
https://git.kernel.org/netdev/net-next/c/064a6a887f95
- [net-next,04/12] net: macb: Separate C22 and C45 transactions
https://git.kernel.org/netdev/net-next/c/a4d65b1de2a2
- [net-next,05/12] ixgbe: Separate C22 and C45 transactions
https://git.kernel.org/netdev/net-next/c/308c8ffd5a7d
- [net-next,06/12] ixgbe: Use C45 mdiobus accessors
https://git.kernel.org/netdev/net-next/c/ab2960f0fdfe
- [net-next,07/12] net: hns: Separate C22 and C45 transactions
https://git.kernel.org/netdev/net-next/c/41799a77f4bb
- [net-next,08/12] amd-xgbe: Separate C22 and C45 transactions
https://git.kernel.org/netdev/net-next/c/070f6186a2f1
- [net-next,09/12] amd-xgbe: Replace MII_ADDR_C45 with XGBE_ADDR_C45
https://git.kernel.org/netdev/net-next/c/47e61593f367
- [net-next,10/12] net: dsa: sja1105: C45 only transactions for PCS
https://git.kernel.org/netdev/net-next/c/ae271547bba6
- [net-next,11/12] net: dsa: sja1105: Separate C22 and C45 transactions for T1 MDIO bus
https://git.kernel.org/netdev/net-next/c/c708e1350370
- [net-next,12/12] net: ethernet: renesas: rswitch: C45 only transactions
https://git.kernel.org/netdev/net-next/c/95331514d95f

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