-/* $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
}
#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
-/* $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
#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