Tue 15 May 2012 10:27:28 AM UTC, comment #6:
I finally troubleshooted that and found why pppInputHeader must be packed.
If a structure is not packed, I guess the compiler optimize any use of this structure in a way that the structure must be aligned everywhere it is used.
With PPPoE, if not packed:
Ethernet => +14
PPPoE header => +6
sizeof(*pih) - sizeof(inProtocol) => -6
So, pppInputHeader replaces the PPPoE header, which is good (except that we double the inProtocol field, which is what -sizeof(inProtocol) tried to avoid), but the *pih ptr is not aligned and some uC die because of that.
Of course, if the structure pppInputHeader is not packed, it may work I guess if ETH_PAD_SIZE is set to 2 (if the driver support it, which mine not at the moment), but this is just because the PPPoE header is 6 bytes long and pppInputHeader too.
I am not a compiler expert, I guess if the structure is packed, that the compiler does not add alignment optimisation then the structure can be used on unaligned address.
|