Re: [net-next PATCH] net: phy: aquantia: drop wrong endianness conversion for addr and CRC

Christian Marangi
2023-11-22T18:40:07Z

On Wed, Nov 22, 2023 at 10:23:47AM -0800, Jakub Kicinski wrote:
> On Wed, 22 Nov 2023 18:53:39 +0100 Christian Marangi wrote:
> > So they DO get converted to the HOST endian on reading the firmware from
> > an nvmem cell or a filesystem?
>
> They don't get converted when "reading from nvmem / fs".
> They get converted when you do:
>
> word = get_unaligned((const u32 *)(data + pos));
>
> get_unaligned() is basically:
>
> #if BIGENDIAN
> #define get_unaligned get_unaligned_be32
> #else
> #define get_unaligned get_unaligned_le32
> #endif
>
> so you'll get different behavior here depending on the CPU.

Ugh... If that is true this is bad...

When get_unaligned was suggested, I checked if the thing was doing any
kind of conversion and from [1] I tought it was just getting the
pointer.

I can't find the entry where the thing is done. Is this some kind of
include magic with asm specific API?

[1] https://elixir.bootlin.com/linux/latest/source/include/asm-generic/unaligned.h#L22

--
Ansuel