From: Maxime Chevallier <maxime.chevallier@bootlin.com>
To: Gerhard Engleder <gerhard@engleder-embedded.com>
Cc: andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, netdev@vger.kernel.org
Subject: Re: [PATCH net-next v10 3/5] net: phy: micrel: Add loopback support
Date: Thu, 13 Mar 2025 10:41:28 +0100 [thread overview]
Message-ID: <20250313104128.3f6cb9e3@fedora-2.home> (raw)
In-Reply-To: <9b61088921bafd7da5739c786274c083@engleder-embedded.com>
Hi,
On Thu, 13 Mar 2025 10:35:47 +0100
Gerhard Engleder <gerhard@engleder-embedded.com> wrote:
> Am 13.03.2025 09:57, schrieb Maxime Chevallier:
> > Hello Gerhard,
> >
> > On Wed, 12 Mar 2025 21:30:08 +0100
> > Gerhard Engleder <gerhard@engleder-embedded.com> wrote:
> >
> >> The KSZ9031 PHYs requires full duplex for loopback mode. Add PHY
> >> specific set_loopback() to ensure this.
> >>
> >> Signed-off-by: Gerhard Engleder <gerhard@engleder-embedded.com>
> >> ---
> >> drivers/net/phy/micrel.c | 24 ++++++++++++++++++++++++
> >> 1 file changed, 24 insertions(+)
> >>
> >> diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
> >> index 289e1d56aa65..24882d30f685 100644
> >> --- a/drivers/net/phy/micrel.c
> >> +++ b/drivers/net/phy/micrel.c
> >> @@ -1032,6 +1032,29 @@ static int ksz9021_config_init(struct
> >> phy_device *phydev)
> >> #define MII_KSZ9031RN_EDPD 0x23
> >> #define MII_KSZ9031RN_EDPD_ENABLE BIT(0)
> >>
> >> +static int ksz9031_set_loopback(struct phy_device *phydev, bool
> >> enable,
> >> + int speed)
> >> +{
> >> + u16 ctl = BMCR_LOOPBACK;
> >> + int val;
> >> +
> >> + if (!enable)
> >> + return genphy_loopback(phydev, enable, 0);
> >> +
> >> + if (speed == SPEED_10 || speed == SPEED_100 || speed == SPEED_1000)
> >> + phydev->speed = speed;
> >> + else if (speed)
> >> + return -EINVAL;
> >> + phydev->duplex = DUPLEX_FULL;
> >> +
> >> + ctl |= mii_bmcr_encode_fixed(phydev->speed, phydev->duplex);
> >> +
> >> + phy_write(phydev, MII_BMCR, ctl);
> >> +
> >> + return phy_read_poll_timeout(phydev, MII_BMSR, val, val &
> >> BMSR_LSTATUS,
> >> + 5000, 500000, true);
> >
> > Maybe I don't fully get it, but it looks to me that you poll, waiting
> > for the link to become up. As you are in local loopback mode, how does
> > that work ? Do you need connection to an active LP for loopback to
> > work, or does the BMSR_LSTATUS bit behave differently under local
> > loopback ?
>
> Yes I'm polling for link to come up. This is identical to
> genphy_loopback().
> There is no need for a link partner to get a link up in loopback mode.
> BMSR_LSTATUS reflects the loopback as link in this case.
>
> This series allows to configure a loopback with defined speed without
> any
> link partner. Currently for PHY loopback a link partner is needed in
> some
> cases (starting with 1 Gbps loopback).
Ok thanks a lot for the clarification ! It looks good to me in that
case :)
Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Maxime
next prev parent reply other threads:[~2025-03-13 9:41 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-12 20:30 [PATCH net-next v10 0/5] Support loopback mode speed selection Gerhard Engleder
2025-03-12 20:30 ` [PATCH net-next v10 1/5] net: phy: Allow loopback speed selection for PHY drivers Gerhard Engleder
2025-03-12 20:30 ` [PATCH net-next v10 2/5] net: phy: Support speed selection for PHY loopback Gerhard Engleder
2025-03-12 20:30 ` [PATCH net-next v10 3/5] net: phy: micrel: Add loopback support Gerhard Engleder
2025-03-13 8:57 ` Maxime Chevallier
2025-03-13 9:35 ` Gerhard Engleder
2025-03-13 9:41 ` Maxime Chevallier [this message]
2025-03-12 20:30 ` [PATCH net-next v10 4/5] net: phy: marvell: Align set_loopback() implementation Gerhard Engleder
2025-03-12 20:30 ` [PATCH net-next v10 5/5] tsnep: Select speed for loopback Gerhard Engleder
2025-03-20 6:26 ` [PATCH net-next v10 0/5] Support loopback mode speed selection Gerhard Engleder
2025-03-20 7:32 ` Paolo Abeni
2025-03-20 7:50 ` patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250313104128.3f6cb9e3@fedora-2.home \
--to=maxime.chevallier@bootlin.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gerhard@engleder-embedded.com \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox