Subject: Re: gsip sends byte-swapped vlan tags
To: Pavel Cahyna <pavel.cahyna@st.mff.cuni.cz>
From: Jason Thorpe <thorpej@shagadelic.org>
List: tech-net
Date: 01/24/2006 10:02:51
On Jan 24, 2006, at 9:15 AM, Pavel Cahyna wrote:
> I can confirm that using bswap16 makes it send correct tag from a BE
> machine (sgimips). To correctly receive tags, it is necessary to
> change
> another already existing ntohs to bswap16. Then the tagged VLAN work
> correctly. This final patch is below.
Please add some comments explaining why an unconditional swap is
being used.
Thanks!
>
> Pavel Cahyna
>
> 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 17:13: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));
> + (bswap16(VLAN_TAG_VALUE(mtag)) & EXTSTS_VTCI));
> }
>
> /*
> @@ -1970,7 +1970,7 @@
> * for us. Associate the tag with the packet.
> */
> if ((extsts & EXTSTS_VPKT) != 0) {
> - VLAN_INPUT_TAG(ifp, m, ntohs(extsts & EXTSTS_VTCI),
> + VLAN_INPUT_TAG(ifp, m, bswap16(extsts & EXTSTS_VTCI),
> continue);
> }
>
-- thorpej