summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchrisz <chrisz@openbsd.org>2015-10-20 17:08:39 +0000
committerchrisz <chrisz@openbsd.org>2015-10-20 17:08:39 +0000
commit538c6aed8d1e17cd437c1b518d5c9f919ab0cc99 (patch)
tree2eda91e853b385e66d25bd472bf2e4a14a9877d9
parent... but keep the previous logic for sparc, which is the other user of this (diff)
downloadwireguard-openbsd-538c6aed8d1e17cd437c1b518d5c9f919ab0cc99.tar.xz
wireguard-openbsd-538c6aed8d1e17cd437c1b518d5c9f919ab0cc99.zip
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@
-rw-r--r--sys/dev/pci/if_vr.c13
-rw-r--r--sys/dev/pci/if_vrreg.h8
2 files changed, 16 insertions, 5 deletions
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