Subject: 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/24/2006 17:35:18
Hello,

I have tried a gigabit card with the gsip driver and a tagged VLAN. When
this did not work, I discovered that the VLAN tag is sent byte-swapped. If
I configure it as 4, I see 1024 on the wire. If I configure 1024, I see 4.
If I configure 2, I see 512.

This is on i386 with 3.0.

This quick patch seems to fix it, but probably is still not right for BE
machines, where the value will be initially correct, but then swapped by
htole32. Any better idea? Maybe use bswap16 instead of htons?

Pavel

Index: if_sip.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/if_sip.c,v
retrieving revision 1.101
diff -u -r1.101 if_sip.c
--- if_sip.c    27 Feb 2005 00:27:33 -0000      1.101
+++ if_sip.c    24 Jan 2006 15:29:50 -0000
@@ -1357,7 +1357,7 @@
                if ((mtag = VLAN_OUTPUT_TAG(&sc->sc_ethercom, m0)) != NULL) {
                        sc->sc_txdescs[lasttx].sipd_extsts |=
                            htole32(EXTSTS_VPKT |
-                                   (VLAN_TAG_VALUE(mtag) & EXTSTS_VTCI));
+                                   (htons(VLAN_TAG_VALUE(mtag)) & EXTSTS_VTCI));
                }
 
                /*