Subject: Re: sky2 problem on powerpc

From: Benjamin Herrenschmidt <[email-masked]>
Date: Mon, 04 Sep 2006 17:21:09 +1000

> Because if you look at the definition for:
> 
> struct sky2_rx_le {
> 	__le32	addr;
> 	__le16	length;
> 	u8	ctrl;
> 	u8	opcode;
> } __attribute((packed));
> 
> (As an example)
> 
> If the chips does LE accesses, then marking "lenght" as being an LE
> value isn't enough. It also needs to be swapped with ctrl and opcode.
> The layout then becomes:
> 
> struct sky2_rx_le {
> 	__le32	addr;
> 	u8	opcode;
> 	u8	ctrl;
> 	__le16	length;
> } __attribute((packed));

And of course, I'm stupid... the structure layout in memory is well
defined and the chip is accessing it just fine... The problem are
actually related to

 - That special "reverse" descriptor bit one can set in the chip....
That will indeed cause my scenario above to happen by causing the chip
to do a 32 bits byteswap it seems. But if we set this bit, we must also
remove all of the cpu_to_le/le_to_cpu conversions used to access
descriptors.

 - I've decided not to set that bit for now, thus disabled the code
doing so (and thus requiring be/le conversions). We have cases where
they are missing, and thus it's not working.

I'm trying to get it right now, will send a patch if I can get something
working. At one point, I suppose I'll have the choice of either letting
the HW do the 32 bits flip, which involves playing #ifdef __BIG_ENDIAN
with the structures in sky2.h or just ignore that bit and do cpu_to_le*
when needed. I'm tempted to do the later...

Ben

-- 
VGER BF report: U 0.526041