RE: [PATCH, resubmit] ax88179_178a: ASIX AX88179_178A USB 3.0/2.0 to gigabit ethernet adapter driver

From: David Laight
Date: Fri Feb 08 2013 - 05:24:29 EST


> > +struct ax88179_rx_pkt_header {
> > + u8 l4_csum_err:1,
> > + l3_csum_err:1,
> > + l4_type:3,
> > + l3_type:2,
> > + ce:1;
> > +
> > + u8 vlan_ind:3,
> > + rx_ok:1,
> > + pri:3,
> > + bmc:1;
> > +
> > + u16 len:13,
> > + crc:1,
> > + mii:1,
> > + drop:1;
> > +} __packed;
>
> This won't work on both big-endian systems (assuming this works on x86).
> You apparently try to convert the structure in-place in
> ax88179_rx_fixup() by calling le32_to_cpus(); that may work if you
> define all the bitfields to be part of a u32 but it won't work with the
> current definition.

Trying to use bit fields to map hardware registers (etc) isn't a
good idea at all. The C standard says absolutely nothing about
the order in which the bits are allocated to the field names.
(There are at least 4 possible orederings.)

It is much better to define constants for the bit values and
explicitly mask them as required.

David

èº{.nÇ+‰·Ÿ®‰­†+%ŠËlzwm…ébëæìr¸›zX§»®w¥Š{ayºÊÚë,j­¢f£¢·hš‹àz¹®w¥¢¸ ¢·¦j:+v‰¨ŠwèjØm¶Ÿÿ¾«‘êçzZ+ƒùšŽŠÝj"ú!¶iO•æ¬z·švØ^¶m§ÿðà nÆàþY&—