Module Name:    src
Committed By:   nonaka
Date:           Mon Apr 16 09:10:42 UTC 2018

Modified Files:
        src/sys/arch/x86/pci: if_vmx.c

Log Message:
vmx(4): handled SIOCZIFDATA.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/x86/pci/if_vmx.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/if_vmx.c
diff -u src/sys/arch/x86/pci/if_vmx.c:1.22 src/sys/arch/x86/pci/if_vmx.c:1.23
--- src/sys/arch/x86/pci/if_vmx.c:1.22	Mon Apr 16 03:21:43 2018
+++ src/sys/arch/x86/pci/if_vmx.c	Mon Apr 16 09:10:42 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vmx.c,v 1.22 2018/04/16 03:21:43 nonaka Exp $	*/
+/*	$NetBSD: if_vmx.c,v 1.23 2018/04/16 09:10:42 nonaka Exp $	*/
 /*	$OpenBSD: if_vmx.c,v 1.16 2014/01/22 06:04:17 brad Exp $	*/
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.22 2018/04/16 03:21:43 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.23 2018/04/16 09:10:42 nonaka Exp $");
 
 #include <sys/param.h>
 #include <sys/cpu.h>
@@ -2892,27 +2892,38 @@ vmxnet3_ioctl(struct ifnet *ifp, u_long 
 		splx(s);
 		break;
 	case SIOCGIFDATA:
+	case SIOCZIFDATA:
 		ifp->if_ipackets = 0;
 		ifp->if_iqdrops = 0;
 		ifp->if_ierrors = 0;
 		for (int i = 0; i < sc->vmx_nrxqueues; i++) {
-			ifp->if_ipackets +=
-			    sc->vmx_rxq[i].vxrxq_stats.vmrxs_ipackets;
-			ifp->if_iqdrops +=
-			    sc->vmx_rxq[i].vxrxq_stats.vmrxs_iqdrops;
-			ifp->if_ierrors +=
-			    sc->vmx_rxq[i].vxrxq_stats.vmrxs_ierrors;
+			struct vmxnet3_rxqueue *rxq = &sc->vmx_rxq[i];
+
+			VMXNET3_RXQ_LOCK(rxq);
+			ifp->if_ipackets += rxq->vxrxq_stats.vmrxs_ipackets;
+			ifp->if_iqdrops += rxq->vxrxq_stats.vmrxs_iqdrops;
+			ifp->if_ierrors += rxq->vxrxq_stats.vmrxs_ierrors;
+			if (cmd == SIOCZIFDATA) {
+				memset(&rxq->vxrxq_stats, 0,
+				    sizeof(rxq->vxrxq_stats));
+			}
+			VMXNET3_RXQ_UNLOCK(rxq);
 		}
 		ifp->if_opackets = 0;
 		ifp->if_obytes = 0;
 		ifp->if_omcasts = 0;
 		for (int i = 0; i < sc->vmx_ntxqueues; i++) {
-			ifp->if_opackets +=
-			    sc->vmx_txq[i].vxtxq_stats.vmtxs_opackets;
-			ifp->if_obytes +=
-			    sc->vmx_txq[i].vxtxq_stats.vmtxs_obytes;
-			ifp->if_omcasts +=
-			    sc->vmx_txq[i].vxtxq_stats.vmtxs_omcasts;
+			struct vmxnet3_txqueue *txq = &sc->vmx_txq[i];
+
+			VMXNET3_TXQ_LOCK(txq);
+			ifp->if_opackets += txq->vxtxq_stats.vmtxs_opackets;
+			ifp->if_obytes += txq->vxtxq_stats.vmtxs_obytes;
+			ifp->if_omcasts += txq->vxtxq_stats.vmtxs_omcasts;
+			if (cmd == SIOCZIFDATA) {
+				memset(&txq->vxtxq_stats, 0,
+				    sizeof(txq->vxtxq_stats));
+			}
+			VMXNET3_TXQ_UNLOCK(txq);
 		}
 		/* FALLTHROUGH */
 	default:

Reply via email to