Subject: Re: gsip sends byte-swapped vlan tags
To: Pavel Cahyna <pavel.cahyna@st.mff.cuni.cz>
From: Martin Husemann <martin@duskware.de>
List: tech-net
Date: 01/25/2006 09:50:55
On Wed, Jan 25, 2006 at 01:45:53AM +0100, Pavel Cahyna wrote:
> OK. My explanation is (review carefully, I have zero knowledge of this
> hardware):

Neither do I, but let me try to formulate my understanding anyway:

We want the VLAN tag in network byte order, so we do a htons() to convert
it. But then, in the descriptor, there are some other bits to be filled in
into the same 32bit word. So we need to do some bit shifting and setting
additional bits - which is done in host byte order. Then the whole thing
needs to be converted into 32bit little endian (native PCI bus byte order).

An alternative might be to modify the descriptor structure (with #ifdef
_BYTE_ORDER) to get the vlan field on its own. I'm not sure this realy
is cleaner.

Martin
P.S.: for the other chipsets you mention - I don't know if all chipsets do
expect the vlan tag in network byte order