public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jon Hunter <jonathanh@nvidia.com>
To: daniel.braunwarth@kuka.com, Andrew Lunn <andrew@lunn.ch>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	Russell King <linux@armlinux.org.uk>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v2] net: phy: realtek: Add support for WOL magic packet on RTL8211F
Date: Tue, 10 Jun 2025 10:44:21 +0100	[thread overview]
Message-ID: <baaa083b-9a69-460f-ab35-2a7cb3246ffd@nvidia.com> (raw)
In-Reply-To: <20250429-realtek_wol-v2-1-8f84def1ef2c@kuka.com>

Hi Daniel,

On 29/04/2025 12:33, Daniel Braunwarth via B4 Relay wrote:
> From: Daniel Braunwarth <daniel.braunwarth@kuka.com>
> 
> The RTL8211F supports multiple WOL modes. This patch adds support for
> magic packets.
> 
> The PHY notifies the system via the INTB/PMEB pin when a WOL event
> occurs.
> 
> Signed-off-by: Daniel Braunwarth <daniel.braunwarth@kuka.com>
> ---
> Changes in v2:
> - Read current WOL configuration from PHY
> - Replace magic numbers with defines
> - Link to v1: https://lore.kernel.org/r/20250428-realtek_wol-v1-1-15de3139d488@kuka.com
> ---
>   drivers/net/phy/realtek/realtek_main.c | 69 ++++++++++++++++++++++++++++++++++
>   1 file changed, 69 insertions(+)
> 
> diff --git a/drivers/net/phy/realtek/realtek_main.c b/drivers/net/phy/realtek/realtek_main.c
> index 893c824796715a905bab99646a474c3bea95ec11..05c4f4d394a5ff32b43dd51f0bff08f437ad0494 100644
> --- a/drivers/net/phy/realtek/realtek_main.c
> +++ b/drivers/net/phy/realtek/realtek_main.c
> @@ -10,6 +10,7 @@
>   #include <linux/bitops.h>
>   #include <linux/of.h>
>   #include <linux/phy.h>
> +#include <linux/netdevice.h>
>   #include <linux/module.h>
>   #include <linux/delay.h>
>   #include <linux/clk.h>
> @@ -38,6 +39,24 @@
>   
>   #define RTL8211F_INSR				0x1d
>   
> +/* RTL8211F WOL interrupt configuration */
> +#define RTL8211F_INTBCR_PAGE			0xd40
> +#define RTL8211F_INTBCR				0x16
> +#define RTL8211F_INTBCR_INTB_PMEB		BIT(5)
> +
> +/* RTL8211F WOL settings */
> +#define RTL8211F_WOL_SETTINGS_PAGE		0xd8a
> +#define RTL8211F_WOL_SETTINGS_EVENTS		16
> +#define RTL8211F_WOL_EVENT_MAGIC		BIT(12)
> +#define RTL8211F_WOL_SETTINGS_STATUS		17
> +#define RTL8211F_WOL_STATUS_RESET		(BIT(15) | 0x1fff)
> +
> +/* RTL8211F Unique phyiscal and multicast address (WOL) */
> +#define RTL8211F_PHYSICAL_ADDR_PAGE		0xd8c
> +#define RTL8211F_PHYSICAL_ADDR_WORD0		16
> +#define RTL8211F_PHYSICAL_ADDR_WORD1		17
> +#define RTL8211F_PHYSICAL_ADDR_WORD2		18
> +
>   #define RTL8211F_LEDCR				0x10
>   #define RTL8211F_LEDCR_MODE			BIT(15)
>   #define RTL8211F_LEDCR_ACT_TXRX			BIT(4)
> @@ -123,6 +142,7 @@ struct rtl821x_priv {
>   	u16 phycr2;
>   	bool has_phycr2;
>   	struct clk *clk;
> +	u32 saved_wolopts;
>   };
>   
>   static int rtl821x_read_page(struct phy_device *phydev)
> @@ -354,6 +374,53 @@ static irqreturn_t rtl8211f_handle_interrupt(struct phy_device *phydev)
>   	return IRQ_HANDLED;
>   }
>   
> +static void rtl8211f_get_wol(struct phy_device *dev, struct ethtool_wolinfo *wol)
> +{
> +	wol->supported = WAKE_MAGIC;
> +	if (phy_read_paged(dev, RTL8211F_WOL_SETTINGS_PAGE, RTL8211F_WOL_SETTINGS_EVENTS)
> +	    & RTL8211F_WOL_EVENT_MAGIC)

Given that phy_read_paged() can return an error, should we not check the 
value return is greater than 0 before ANDing with RTL8211F_WOL_EVENT_MAGIC?

Thanks
Jon

-- 
nvpublic


      parent reply	other threads:[~2025-06-10  9:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-29 11:33 [PATCH net-next v2] net: phy: realtek: Add support for WOL magic packet on RTL8211F Daniel Braunwarth via B4 Relay
2025-04-29 12:28 ` Andrew Lunn
2025-05-02  1:10 ` patchwork-bot+netdevbpf
2025-06-10  9:44 ` Jon Hunter [this message]

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=baaa083b-9a69-460f-ab35-2a7cb3246ffd@nvidia.com \
    --to=jonathanh@nvidia.com \
    --cc=andrew@lunn.ch \
    --cc=daniel.braunwarth@kuka.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.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