From: Daniel Golle <daniel@makrotopia.org>
To: Paul Davey <paul.davey@alliedtelesis.co.nz>
Cc: Andrew Lunn <andrew@lunn.ch>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next] net: phy: aquantia: Add mdix config and reporting
Date: Thu, 17 Oct 2024 12:54:28 +0100 [thread overview]
Message-ID: <ZxD69GqiPcqOZK2w@makrotopia.org> (raw)
In-Reply-To: <20241017015407.256737-1-paul.davey@alliedtelesis.co.nz>
On Thu, Oct 17, 2024 at 02:54:07PM +1300, Paul Davey wrote:
> Add support for configuring MDI-X state of PHY.
> Add reporting of resolved MDI-X state in status information.
> [...]
> +static int aqr_set_polarity(struct phy_device *phydev, int polarity)
"polarity" is not the right term here. This is not about the polarity
of copper pairs, but rather about pairs being swapped.
Please name the function accordingly, eg. aqr_set_mdix().
> +{
> + u16 val = 0;
> +
> + switch (polarity) {
> + case ETH_TP_MDI:
> + val = MDIO_AN_RESVD_VEND_PROV_MDIX_MDI;
> + break;
> + case ETH_TP_MDI_X:
> + val = MDIO_AN_RESVD_VEND_PROV_MDIX_MDIX;
> + break;
> + case ETH_TP_MDI_AUTO:
> + case ETH_TP_MDI_INVALID:
> + default:
> + val = MDIO_AN_RESVD_VEND_PROV_MDIX_AUTO;
> + break;
> + }
> +
> + return phy_modify_mmd_changed(phydev, MDIO_MMD_AN, MDIO_AN_RESVD_VEND_PROV,
> + MDIO_AN_RESVD_VEND_PROV_MDIX_MASK, val);
> +}
> +
> static int aqr_config_aneg(struct phy_device *phydev)
> {
> bool changed = false;
> u16 reg;
> int ret;
>
> + ret = aqr_set_polarity(phydev, phydev->mdix_ctrl);
> + if (ret < 0)
> + return ret;
> + if (ret > 0)
> + changed = true;
> +
> if (phydev->autoneg == AUTONEG_DISABLE)
> return genphy_c45_pma_setup_forced(phydev);
>
> @@ -278,6 +315,14 @@ static int aqr_read_status(struct phy_device *phydev)
> val & MDIO_AN_RX_LP_STAT1_1000BASET_HALF);
> }
>
> + val = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_AN_RESVD_VEND_STATUS1);
According to the datasheet the MDI/MDI-X indication should only be
interpreted when autonegotiation has completed.
Hence this call should be protected by genphy_c45_aneg_done(phydev) and
phydev->mdix set to ETH_TP_MDI_INVALID in case auto-negotiation hasn't
completed.
> + if (val < 0)
> + return val;
> + if (val & MDIO_AN_RESVD_VEND_STATUS1_MDIX)
> + phydev->mdix = ETH_TP_MDI_X;
> + else
> + phydev->mdix = ETH_TP_MDI;
> +
> return genphy_c45_read_status(phydev);
> }
>
> --
> 2.47.0
>
>
next prev parent reply other threads:[~2024-10-17 11:54 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-17 1:54 Paul Davey
2024-10-17 11:54 ` Daniel Golle [this message]
2024-10-17 23:52 ` Paul Davey
2024-10-18 0:19 ` Andrew Lunn
2024-10-18 2:49 ` Paul Davey
2024-10-18 17:20 ` Andrew Lunn
2024-11-06 0:01 ` Paul Davey
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=ZxD69GqiPcqOZK2w@makrotopia.org \
--to=daniel@makrotopia.org \
--cc=andrew@lunn.ch \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=paul.davey@alliedtelesis.co.nz \
/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
all inboxes | Powered by JetHome®