netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Oleksij Rempel <o.rempel@pengutronix.de>
To: Thangaraj.S@microchip.com
Cc: andrew+netdev@lunn.ch, rmk+kernel@armlinux.org.uk,
	davem@davemloft.net, Woojung.Huh@microchip.com,
	pabeni@redhat.com, edumazet@google.com, kuba@kernel.org,
	phil@raspberrypi.org, kernel@pengutronix.de,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	UNGLinuxDriver@microchip.com
Subject: Re: [PATCH net-next v1 1/7] net: usb: lan78xx: Convert to PHYlink for improved PHY and MAC management
Date: Wed, 22 Jan 2025 07:06:56 +0100	[thread overview]
Message-ID: <Z5CLAMsLJtKA43kM@pengutronix.de> (raw)
In-Reply-To: <0397c3a4cac5795fc33dd313ea74a8743a587d28.camel@microchip.com>

Hi Thangaraj,

On Wed, Jan 22, 2025 at 04:02:42AM +0000, Thangaraj.S@microchip.com wrote:
> Hi Oleksji,
> 
> On Wed, 2025-01-08 at 13:13 +0100, Oleksij Rempel wrote:
> >  /* use ethtool to change the level for any given device */
> > @@ -1554,40 +1558,6 @@ static void lan78xx_set_multicast(struct
> > net_device *netdev)
> >         schedule_work(&pdata->set_multicast);
> >  }
> > 
> > 
> > 
> > -static int lan78xx_link_reset(struct lan78xx_net *dev)
> > +static int lan78xx_phy_int_ack(struct lan78xx_net *dev)
> >  {
> 
> Is there any specific reason why this complete logic on phy interrupt
> handling is removed?

### Before: Old PHY Interrupt Handling

In the old implementation, the driver processed PHY interrupts as follows:

1. When a status URB was received, the driver checked for the `INT_ENP_PHY_INT`
   flag to detect a PHY-related interrupt:
   - Upon detecting the interrupt, it triggered a deferred kevent
     (`lan78xx_defer_kevent`) with the `EVENT_LINK_RESET` event.
   - It also called `generic_handle_irq_safe` to notify the PHY subsystem of
     the interrupt, allowing it to update the PHY state.

2. The deferred kevent was handled by `lan78xx_link_reset`, which:
   - It invoked `phy_read_status` to retrieve the PHY state.
   - Based on the PHY state, it adjusted MAC settings (e.g., flow control,
     USB state) and restarted the RX/TX paths if needed.
   - Enabled/disrupted timers and submitted RX URBs when link changes occurred.

This design required the driver to manually handle both PHY and MAC state
management, leading to complex and redundant logic.

### Now: PHYlink Integration

In the updated code, the handling process is simplified:

1. When a status URB detects a PHY interrupt (`INT_ENP_PHY_INT`), the driver
   still calls `lan78xx_defer_kevent(dev, EVENT_PHY_INT_ACK)`. However:
   - The deferred event now serves only to acknowledge the interrupt by calling
     `lan78xx_phy_int_ack`.
   - This separation is necessary because the URB completion context cannot
     directly perform register writes.

2. The interrupt is forwarded to the PHY subsystem, which updates the PHY state
   as before. No additional logic is performed in this step.

3. Once the PHY state is updated, PHYlink invokes appropriate callbacks to
   handle MAC reconfiguration:
   - `mac_config` for initial setup.
   - `mac_link_up` and `mac_link_down` to manage link transitions, flow
     control, and USB state.

### Why the Old Logic is No Longer Needed

The MAC is now reconfigured only through PHYlink callbacks, eliminating the
need for deferred events to handle complex link reset logic.

With PHYlink coordinating PHY and MAC interactions, the driver no longer needs
custom logic to manage state transitions.

> > +static void lan78xx_mac_config(struct phylink_config *config,
> > unsigned int mode,
> > +                              const struct phylink_link_state
> > *state)
> > +{
> > +       struct net_device *net = to_net_dev(config->dev);
> > +       struct lan78xx_net *dev = netdev_priv(net);
> > +       u32 rgmii_id = 0;
> 
> This variable is not modified anywhere in this function. Remove this
> variable if not needed.

Thank you. I'll update it.

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

  reply	other threads:[~2025-01-22  6:07 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-08 12:13 [PATCH net-next v1 0/7] Convert LAN78xx to PHYLINK Oleksij Rempel
2025-01-08 12:13 ` [PATCH net-next v1 1/7] net: usb: lan78xx: Convert to PHYlink for improved PHY and MAC management Oleksij Rempel
2025-01-08 12:43   ` Russell King (Oracle)
2025-01-17 10:50   ` Rengarajan.S
2025-01-22  8:16     ` Oleksij Rempel
2025-01-22  4:02   ` Thangaraj.S
2025-01-22  6:06     ` Oleksij Rempel [this message]
2025-01-08 12:13 ` [PATCH net-next v1 2/7] net: usb: lan78xx: Move fixed PHY cleanup to lan78xx_unbind() Oleksij Rempel
2025-01-08 12:13 ` [PATCH net-next v1 3/7] net: usb: lan78xx: Improve error handling for PHY init path Oleksij Rempel
2025-01-08 12:52   ` Russell King (Oracle)
2025-01-08 12:13 ` [PATCH net-next v1 4/7] net: usb: lan78xx: Use ethtool_op_get_link to reflect current link status Oleksij Rempel
2025-01-08 12:13 ` [PATCH net-next v1 5/7] net: usb: lan78xx: port link settings to phylink API Oleksij Rempel
2025-01-08 12:13 ` [PATCH net-next v1 6/7] net: usb: lan78xx: Transition get/set_pause to phylink Oleksij Rempel
2025-01-08 12:13 ` [PATCH net-next v1 7/7] net: usb: lan78xx: Enable EEE support with phylink integration Oleksij Rempel
2025-01-08 12:47   ` Russell King (Oracle)
2025-01-08 14:23     ` Oleksij Rempel
2025-01-08 15:15       ` Russell King (Oracle)
2025-01-09 17:13         ` Oleksij Rempel
2025-01-09 17:27           ` Russell King (Oracle)
2025-01-09 17:39             ` Oleksij Rempel
2025-01-09 18:10               ` Russell King (Oracle)
2025-01-09 19:33                 ` Andrew Lunn
2025-01-13 12:42                   ` Oleksij Rempel
2025-01-13 13:29                     ` Russell King (Oracle)
2025-01-13 13:45                       ` Andrew Lunn
2025-01-17 16:23                         ` Russell King (Oracle)
2025-01-18  7:22                           ` Oleksij Rempel
2025-01-18  9:04                             ` Russell King (Oracle)
2025-01-18 10:01                               ` Oleksij Rempel
2025-01-18 10:40                                 ` Russell King (Oracle)
2025-01-18 11:23                                   ` Oleksij Rempel
2025-01-18 10:03                             ` Oleksij Rempel
2025-01-09 19:36                 ` 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=Z5CLAMsLJtKA43kM@pengutronix.de \
    --to=o.rempel@pengutronix.de \
    --cc=Thangaraj.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=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).