[PATCH v8 3/4] gpio: rpmsg: add generic rpmsg GPIO driver
Andrew Lunn
andrew at lunn.ch
Fri Feb 20 12:41:36 PST 2026
> Yes, most compilers will lay this out without inserting padding between the fields.
> However, for a communication packet, we cannot freely reorder or tweak members
> just to satisfy alignment rules—the field order itself becomes part of the protocol definition.
Notice i've been saying design. If the design is poor, the
implementation has to jump through hoops to make it work, which is
when __packed it useful, it allows you to implement a bad design.
> Even within netdev, where you’re very familiar, the classic ethhdr still carries the packed annotation
> despite being naturally aligned:
>
> struct ethhdr {
> unsigned char h_dest[ETH_ALEN]; /* destination eth addr */
> unsigned char h_source[ETH_ALEN]; /* source ether addr */
> __be16 h_proto; /* packet type ID field */
> } __attribute__((packed));
And a lot of engineers will agree that this header is badly
designed. The network stack goes to a lot of trouble to ensure the
Ethernet header is placed into an skbuf with an offset of 2 bytes, so
the IP header is 4 byte aligned. This also makes the DMA engines more
complex, having to do an unaligned transfer at the start. More hoops
to jump though because of bad design.
None of the IP, UDP, TCP headers etc have packed, because they are all
well designed. The IETF did a better design job than IEEE.
Andrew
More information about the linux-arm-kernel
mailing list