From: <Thangaraj.S@microchip.com>
To: <andrew+netdev@lunn.ch>, <rmk+kernel@armlinux.org.uk>,
<davem@davemloft.net>, <Rengarajan.S@microchip.com>,
<Woojung.Huh@microchip.com>, <pabeni@redhat.com>,
<o.rempel@pengutronix.de>, <edumazet@google.com>,
<kuba@kernel.org>
Cc: <phil@raspberrypi.org>, <kernel@pengutronix.de>,
<linux-kernel@vger.kernel.org>, <netdev@vger.kernel.org>,
<UNGLinuxDriver@microchip.com>
Subject: Re: [PATCH net-next v2 1/7] net: usb: lan78xx: Convert to PHYlink for improved PHY and MAC management
Date: Mon, 10 Mar 2025 09:29:45 +0000 [thread overview]
Message-ID: <1bb51aad80be4bb5e0413089e1b1bf747db4e123.camel@microchip.com> (raw)
In-Reply-To: <20250307182432.1976273-2-o.rempel@pengutronix.de>
Hi Oleksji,
On Fri, 2025-03-07 at 19:24 +0100, Oleksij Rempel wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you
> know the content is safe
>
> Convert the LAN78xx driver to use the PHYlink framework for managing
> PHY and MAC interactions.
>
> Key changes include:
> - Replace direct PHY operations with phylink equivalents (e.g.,
> phylink_start, phylink_stop).
> - Introduce lan78xx_phylink_setup for phylink initialization and
> configuration.
> - Add phylink MAC operations (lan78xx_mac_config,
> lan78xx_mac_link_down, lan78xx_mac_link_up) for managing link
> settings and flow control.
> - Remove redundant and now phylink-managed functions like
> `lan78xx_link_status_change`.
>
> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
> ---
> changes v2:
> - lan78xx_mac_config: remove unused rgmii_id
> - lan78xx_mac_config: PHY_INTERFACE_MODE_RGMII* variants
> - lan78xx_mac_config: remove auto-speed and duplex configuration
> - lan78xx_phylink_setup: set link_interface to
> PHY_INTERFACE_MODE_RGMII_ID
> instead of PHY_INTERFACE_MODE_NA.
> - lan78xx_phy_init: use phylink_set_fixed_link() instead of
> allocating
> fixed PHY.
> - lan78xx_configure_usb: move function values to separate variables
> ---
> drivers/net/usb/lan78xx.c | 565 ++++++++++++++++++++--------------
> ----
> 1 file changed, 300 insertions(+), 265 deletions(-)
>
> static int lan78xx_phy_init(struct lan78xx_net *dev)
> {
> - __ETHTOOL_DECLARE_LINK_MODE_MASK(fc) = { 0, };
> - int ret;
> - u32 mii_adv;
> struct phy_device *phydev;
> + int ret;
>
> switch (dev->chipid) {
> case ID_REV_CHIP_ID_7801_:
> phydev = lan7801_phy_init(dev);
> + /* If no PHY found, set fixed link, probably there is
> no
> + * device or some kind of different device like
> switch.
> + * For example: EVB-KSZ9897-1 (KSZ9897 switch
> evaluation board
> + * with LAN7801 & KSZ9031)
> + */
> if (!phydev) {
> - netdev_err(dev->net, "lan7801: PHY Init
> Failed");
> - return -EIO;
> + struct phylink_link_state state = {
> + .speed = SPEED_1000,
> + .duplex = DUPLEX_FULL,
> + .interface =
> PHY_INTERFACE_MODE_RGMII,
> + };
> +
> + ret = phylink_set_fixed_link(dev->phylink,
> &state);
> + if (ret)
> + netdev_err(dev->net, "Could not set
> fixed link\n");
> +
> + return ret;
> }
> +
> break;
>
> case ID_REV_CHIP_ID_7800_:
> @@ -2576,7 +2671,7 @@ static int lan78xx_phy_init(struct lan78xx_net
> *dev)
> return -EIO;
> }
> phydev->is_internal = true;
> - dev->interface = PHY_INTERFACE_MODE_GMII;
> + phydev->interface = PHY_INTERFACE_MODE_GMII;
> break;
>
> default:
> @@ -2591,36 +2686,14 @@ static int lan78xx_phy_init(struct
> lan78xx_net *dev)
> phydev->irq = PHY_POLL;
> netdev_dbg(dev->net, "phydev->irq = %d\n", phydev->irq);
>
> - /* set to AUTOMDIX */
> - phydev->mdix = ETH_TP_MDI_AUTO;
> -
> - ret = phy_connect_direct(dev->net, phydev,
> - lan78xx_link_status_change,
> - dev->interface);
> + ret = phylink_connect_phy(dev->phylink, phydev);
> if (ret) {
> netdev_err(dev->net, "can't attach PHY to %s\n",
> dev->mdiobus->id);
> - if (dev->chipid == ID_REV_CHIP_ID_7801_) {
> - if (phy_is_pseudo_fixed_link(phydev)) {
> - fixed_phy_unregister(phydev);
> - phy_device_free(phydev);
> - }
> - }
> return -EIO;
> }
>
> - /* MAC doesn't support 1000T Half */
> - phy_remove_link_mode(phydev,
> ETHTOOL_LINK_MODE_1000baseT_Half_BIT);
> -
> - /* support both flow controls */
> - dev->fc_request_control = (FLOW_CTRL_RX | FLOW_CTRL_TX);
> - linkmode_clear_bit(ETHTOOL_LINK_MODE_Pause_BIT,
> - phydev->advertising);
> - linkmode_clear_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT,
> - phydev->advertising);
> - mii_adv = (u32)mii_advertise_flowctrl(dev-
> >fc_request_control);
> - mii_adv_to_linkmode_adv_t(fc, mii_adv);
> - linkmode_or(phydev->advertising, fc, phydev->advertising);
> + phy_suspend(phydev);
>
Why phy_suspend called in the init? Is there any specific reason?
> phy_support_eee(phydev);
>
> @@ -2646,10 +2719,6 @@ static int lan78xx_phy_init(struct lan78xx_net
> *dev)
> }
> }
>
> - genphy_config_aneg(phydev);
> -
> - dev->fc_autoneg = phydev->autoneg;
> -
> return 0;
> }
>
>
next prev parent reply other threads:[~2025-03-10 9:29 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-07 18:24 [PATCH net-next v2 0/7] Convert LAN78xx to PHYLINK Oleksij Rempel
2025-03-07 18:24 ` [PATCH net-next v2 1/7] net: usb: lan78xx: Convert to PHYlink for improved PHY and MAC management Oleksij Rempel
2025-03-08 13:51 ` Maxime Chevallier
2025-03-10 9:29 ` Thangaraj.S [this message]
2025-03-10 9:58 ` Oleksij Rempel
2025-03-10 10:11 ` Russell King (Oracle)
2025-03-10 10:16 ` Oleksij Rempel
2025-03-10 10:23 ` Russell King (Oracle)
2025-03-07 18:24 ` [PATCH net-next v2 2/7] net: usb: lan78xx: Move fixed PHY cleanup to lan78xx_unbind() Oleksij Rempel
2025-03-08 13:54 ` Maxime Chevallier
2025-03-07 18:24 ` [PATCH net-next v2 3/7] net: usb: lan78xx: Improve error handling for PHY init path Oleksij Rempel
2025-03-07 18:24 ` [PATCH net-next v2 4/7] net: usb: lan78xx: Use ethtool_op_get_link to reflect current link status Oleksij Rempel
2025-03-07 18:24 ` [PATCH net-next v2 5/7] net: usb: lan78xx: port link settings to phylink API Oleksij Rempel
2025-03-07 18:24 ` [PATCH net-next v2 6/7] net: usb: lan78xx: Transition get/set_pause to phylink Oleksij Rempel
2025-03-07 18:24 ` [PATCH net-next v2 7/7] net: usb: lan78xx: Integrate EEE support with phylink LPI API Oleksij Rempel
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=1bb51aad80be4bb5e0413089e1b1bf747db4e123.camel@microchip.com \
--to=thangaraj.s@microchip.com \
--cc=Rengarajan.S@microchip.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=Woojung.Huh@microchip.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kernel@pengutronix.de \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=o.rempel@pengutronix.de \
--cc=pabeni@redhat.com \
--cc=phil@raspberrypi.org \
--cc=rmk+kernel@armlinux.org.uk \
/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;
as well as URLs for NNTP newsgroup(s).