From: Simon Horman <horms@kernel.org>
To: Vineeth Karumanchi <vineeth.karumanchi@amd.com>
Cc: nicolas.ferre@microchip.com, claudiu.beznea@tuxon.dev,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, robh+dt@kernel.org,
krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org,
linux@armlinux.org.uk, vadim.fedorenko@linux.dev, andrew@lunn.ch,
netdev@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, git@amd.com
Subject: Re: [PATCH net-next v6 3/4] net: macb: Add ARP support to WOL
Date: Tue, 18 Jun 2024 11:56:59 +0100 [thread overview]
Message-ID: <20240618105659.GL8447@kernel.org> (raw)
In-Reply-To: <20240617070413.2291511-4-vineeth.karumanchi@amd.com>
On Mon, Jun 17, 2024 at 12:34:12PM +0530, Vineeth Karumanchi wrote:
> Extend wake-on LAN support with an ARP packet.
>
> Currently, if PHY supports WOL, ethtool ignores the modes supported
> by MACB. This change extends the WOL modes with MACB supported modes.
>
> Advertise wake-on LAN supported modes by default without relying on
> dt node. By default, wake-on LAN will be in disabled state.
> Using ethtool, users can enable/disable or choose packet types.
>
> For wake-on LAN via ARP, ensure the IP address is assigned and
> report an error otherwise.
>
> Co-developed-by: Harini Katakam <harini.katakam@amd.com>
> Signed-off-by: Harini Katakam <harini.katakam@amd.com>
> Signed-off-by: Vineeth Karumanchi <vineeth.karumanchi@amd.com>
...
> diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
...
> @@ -84,8 +85,7 @@ struct sifive_fu540_macb_mgmt {
> #define GEM_MTU_MIN_SIZE ETH_MIN_MTU
> #define MACB_NETIF_LSO NETIF_F_TSO
>
> -#define MACB_WOL_HAS_MAGIC_PACKET (0x1 << 0)
> -#define MACB_WOL_ENABLED (0x1 << 1)
> +#define MACB_WOL_ENABLED (0x1 << 0)
nit: BIT() could be used here
>
> #define HS_SPEED_10000M 4
> #define MACB_SERDES_RATE_10G 1
...
> @@ -5290,6 +5289,14 @@ static int __maybe_unused macb_suspend(struct device *dev)
> macb_writel(bp, TSR, -1);
> macb_writel(bp, RSR, -1);
>
> + tmp = (bp->wolopts & WAKE_MAGIC) ? MACB_BIT(MAG) : 0;
> + if (bp->wolopts & WAKE_ARP) {
> + tmp |= MACB_BIT(ARP);
> + /* write IP address into register */
> + tmp |= MACB_BFEXT(IP,
> + (__force u32)(cpu_to_be32p((uint32_t *)&ifa->ifa_local)));
Hi Vineeth and Harini,
I guess I must be reading this wrong, beause I am confused
by the intent of the endeness handling above.
* ifa->ifa_local is a 32-bit big-endian value
* It's address is cast to a 32-bit host-endian pointer
nit: I think u32 would be preferable to uint32_t; this is kernel code.
* The value at this address is then converted to a host byte order value.
nit: Why is cpu_to_be32p() used here instead of the more commonly used
cpu_to_be32() ?
More importantly, why is a host byte order value being converted from
big-endian to host byte order?
* The value returned by cpu_to_be32p, which is big-endian, because
that is what that function does, is then cast to host-byte order.
So overall we have:
1. Cast from big endian to host byte order
2. Conversion from host byte order to big endian
(a bytes-swap on litte endian hosts; no-op on big endian hosts)
3. Cast from big endian to host byte oder
All three of these steps seem to warrant explanation.
And the combination is confusing to say the least.
> + }
> +
> /* Change interrupt handler and
> * Enable WoL IRQ on queue 0
...
next prev parent reply other threads:[~2024-06-18 10:57 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-17 7:04 [PATCH net-next v6 0/4] net: macb: WOL enhancements Vineeth Karumanchi
2024-06-17 7:04 ` [PATCH net-next v6 1/4] net: macb: queue tie-off or disable during WOL suspend Vineeth Karumanchi
2024-06-17 7:04 ` [PATCH net-next v6 2/4] net: macb: Enable queue disable Vineeth Karumanchi
2024-06-17 7:04 ` [PATCH net-next v6 3/4] net: macb: Add ARP support to WOL Vineeth Karumanchi
2024-06-18 10:56 ` Simon Horman [this message]
2024-06-20 15:59 ` Karumanchi, Vineeth
2024-06-20 16:41 ` Simon Horman
2024-06-17 7:04 ` [PATCH net-next v6 4/4] dt-bindings: net: cdns,macb: Deprecate magic-packet property Vineeth Karumanchi
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=20240618105659.GL8447@kernel.org \
--to=horms@kernel.org \
--cc=andrew@lunn.ch \
--cc=claudiu.beznea@tuxon.dev \
--cc=conor+dt@kernel.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@google.com \
--cc=git@amd.com \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=nicolas.ferre@microchip.com \
--cc=pabeni@redhat.com \
--cc=robh+dt@kernel.org \
--cc=vadim.fedorenko@linux.dev \
--cc=vineeth.karumanchi@amd.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.