From: chrisz Date: Tue, 20 Oct 2015 17:08:39 +0000 (+0000) Subject: Fix 802.1p VLAN priority code points for VLAN_HWTAGGING. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=538c6aed8d1e17cd437c1b518d5c9f919ab0cc99;p=openbsd Fix 802.1p VLAN priority code points for VLAN_HWTAGGING. Our in-kernel ether-vtag has a different layout to the vr TXSTAT register. ok sthen@ --- diff --git a/sys/dev/pci/if_vr.c b/sys/dev/pci/if_vr.c index 0656fb3b92f..cb2216c77e0 100644 --- a/sys/dev/pci/if_vr.c +++ b/sys/dev/pci/if_vr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_vr.c,v 1.142 2015/09/12 10:15:10 miod Exp $ */ +/* $OpenBSD: if_vr.c,v 1.143 2015/10/20 17:08:39 chrisz Exp $ */ /* * Copyright (c) 1997, 1998 @@ -1242,11 +1242,16 @@ vr_encap(struct vr_softc *sc, struct vr_chain **cp, struct mbuf *m_head) } #if NVLAN > 0 - /* Tell chip to insert VLAN tag if needed. */ + /* + * Tell chip to insert VLAN tag if needed. + * This chip expects the VLAN ID (0x0FFF) and the PCP (0xE000) + * in only 15 bits without the gap at 0x1000 (reserved for DEI). + * Therefore we need to de- / re-construct the VLAN header. + */ if (m_head->m_flags & M_VLANTAG) { u_int32_t vtag = m_head->m_pkthdr.ether_vtag; - vtag = (vtag << VR_TXSTAT_PQSHIFT) & VR_TXSTAT_PQMASK; - vr_status |= vtag; + vtag = EVL_VLANOFTAG(vtag) | EVL_PRIOFTAG(vtag) << 12; + vr_status |= vtag << VR_TXSTAT_PQSHIFT; vr_ctl |= htole32(VR_TXCTL_INSERTTAG); } #endif diff --git a/sys/dev/pci/if_vrreg.h b/sys/dev/pci/if_vrreg.h index 799d7dc510b..d082bf09fab 100644 --- a/sys/dev/pci/if_vrreg.h +++ b/sys/dev/pci/if_vrreg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_vrreg.h,v 1.36 2014/07/08 05:35:19 dlg Exp $ */ +/* $OpenBSD: if_vrreg.h,v 1.37 2015/10/20 17:08:39 chrisz Exp $ */ /* * Copyright (c) 1997, 1998 @@ -413,6 +413,12 @@ struct vr_desc { #define VR_TXSTAT_BUSERR 0x00002000 #define VR_TXSTAT_JABTIMEO 0x00004000 #define VR_TXSTAT_ERRSUM 0x00008000 +/* + * Note there are only 15 bits total. + * The drop eligible indicator is left out. + * VLAN ID at the lower 12 bits 0x0FFF; + * priority code point at the upper 3 bits 0x7000. + */ #define VR_TXSTAT_PQMASK 0x7FFF0000 #define VR_TXSTAT_OWN 0x80000000 #define VR_TXSTAT_PQSHIFT 16