RE: [PATCH 3/3] sfc: selftest: fix struct packing
From: David Laight
Date: Fri Jun 23 2023 - 06:53:09 EST
...
> Duplicating the definition isn't the prettiest thing in the world; it'd
> do for a quick fix if needed but I assume W=1 warnings aren't blocking
> anyone, so maybe defer this one for now and I'll follow up soon with a
> rewrite that fixes this more cleanly? My idea is to drop the __packed
> from the containing struct, make efx_begin_loopback() copy the layers
> separately, and efx_loopback_rx_packet() similarly do something less
> direct than casting the packet data to the struct.
Maybe you can get away with adding a 16bit pad before the ethernet
header so that the IP header is actually aligned.
(Then fight all the stuff that stops you doing a memcpy()
that runs into a second field of a structure.)
Failing that maybe a single shared copy of the misaligned
IP header.
I also suspect you could just add __packed to the two 32bit
address fields.
That would generate better code on systems that care.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)