Subject: Re: gsip sends byte-swapped vlan tags
To: None <tech-net@netbsd.org>
From: Pavel Cahyna <pcah8322@artax.karlin.mff.cuni.cz>
List: tech-net
Date: 01/25/2006 10:14:01
On Wed, Jan 25, 2006 at 09:50:55AM +0100, Martin Husemann wrote:
> 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).

Yes, that was my understanding, too.

I thought about doing the bit shifting and setting in native PCI
(little-endian) byteorder, but this would be difficult and error-prone for
not much benefit.

> 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

And do you know if they work with VLANs on both big and little endian
machines?

Pavel