Index | Thread | Search

From:
jan@openbsd.org
Subject:
Re: vmx(4): add missing NVLAN checks
To:
tech@openbsd.org
Date:
Wed, 7 Feb 2024 10:07:14 +0100

Download raw body.

Thread
On Tue, Feb 06, 2024 at 07:54:58PM +0100, jan@openbsd.org wrote:
> this diff adds some missing NVLAN checks in vmx(4).  I tested this with
> disabled vlan pseudo device.

Fixed the upt_features assignment.

ok?

Index: dev/pci/if_vmx.c
===================================================================
RCS file: /cvs/src/sys/dev/pci/if_vmx.c,v
diff -u -p -r1.79 if_vmx.c
--- dev/pci/if_vmx.c	10 Nov 2023 15:51:24 -0000	1.79
+++ dev/pci/if_vmx.c	7 Feb 2024 08:55:11 -0000
@@ -404,8 +404,10 @@ vmxnet3_attach(struct device *parent, st
 	if (sc->sc_ds->upt_features & UPT1_F_CSUM)
 		ifp->if_capabilities |= IFCAP_CSUM_TCPv4 | IFCAP_CSUM_UDPv4;
 #endif
+#if NVLAN > 0
 	if (sc->sc_ds->upt_features & UPT1_F_VLAN)
 		ifp->if_capabilities |= IFCAP_VLAN_HWTAGGING;
+#endif
 
 	ifq_init_maxlen(&ifp->if_snd, NTXDESC);
 
@@ -503,7 +505,10 @@ vmxnet3_dma_init(struct vmxnet3_softc *s
 #endif
 	ds->vmxnet3_revision = 1;
 	ds->upt_version = 1;
-	ds->upt_features = UPT1_F_CSUM | UPT1_F_VLAN;
+	ds->upt_features = UPT1_F_CSUM;
+#if NVLAN > 0
+	ds->upt_features |= UPT1_F_VLAN;
+#endif
 	ds->driver_data = ~0ULL;
 	ds->driver_data_len = 0;
 	ds->queue_shared = qs_pa;
@@ -1117,11 +1122,13 @@ vmxnet3_rxintr(struct vmxnet3_softc *sc,
 		m->m_pkthdr.len = m->m_len = len;
 
 		vmxnet3_rx_csum(rxcd, m);
+#if NVLAN > 0
 		if (letoh32(rxcd->rxc_word2 & VMXNET3_RXC_VLAN)) {
 			m->m_flags |= M_VLANTAG;
 			m->m_pkthdr.ether_vtag = letoh32((rxcd->rxc_word2 >>
 			    VMXNET3_RXC_VLANTAG_S) & VMXNET3_RXC_VLANTAG_M);
 		}
+#endif
 		if (((letoh32(rxcd->rxc_word0) >> VMXNET3_RXC_RSSTYPE_S) &
 		    VMXNET3_RXC_RSSTYPE_M) != VMXNET3_RXC_RSSTYPE_NONE) {
 			m->m_pkthdr.ph_flowid = letoh32(rxcd->rxc_word1);
@@ -1462,11 +1469,13 @@ vmxnet3_start(struct ifqueue *ifq)
 		}
 		txd->tx_word3 = htole32(VMXNET3_TX_EOP | VMXNET3_TX_COMPREQ);
 
+#if NVLAN > 0
 		if (ISSET(m->m_flags, M_VLANTAG)) {
 			sop->tx_word3 |= htole32(VMXNET3_TX_VTAG_MODE);
 			sop->tx_word3 |= htole32((m->m_pkthdr.ether_vtag &
 			    VMXNET3_TX_VLANTAG_M) << VMXNET3_TX_VLANTAG_S);
 		}
+#endif
 
 		ring->prod = prod;
 		/* Change the ownership by flipping the "generation" bit */