Module Name:    src
Committed By:   knakahara
Date:           Thu Apr 13 10:37:36 UTC 2017

Modified Files:
        src/share/man/man4: wm.4
        src/sys/dev/pci: files.pci if_wm.c

Log Message:
wm(4) can disable msi/msix by build option and ddb command.

suggested by nonaka@n.o.
reviewed by msaitoh@n.o and nonaka@n.o.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/share/man/man4/wm.4
cvs rdiff -u -r1.387 -r1.388 src/sys/dev/pci/files.pci
cvs rdiff -u -r1.507 -r1.508 src/sys/dev/pci/if_wm.c

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

Modified files:

Index: src/share/man/man4/wm.4
diff -u src/share/man/man4/wm.4:1.35 src/share/man/man4/wm.4:1.36
--- src/share/man/man4/wm.4:1.35	Wed Mar 22 09:38:10 2017
+++ src/share/man/man4/wm.4	Thu Apr 13 10:37:36 2017
@@ -1,4 +1,4 @@
-.\"	$NetBSD: wm.4,v 1.35 2017/03/22 09:38:10 wiz Exp $
+.\"	$NetBSD: wm.4,v 1.36 2017/04/13 10:37:36 knakahara Exp $
 .\"
 .\" Copyright 2002, 2003 Wasabi Systems, Inc.
 .\" All rights reserved.
@@ -196,6 +196,12 @@ Enable many event counters such as each 
 counter.
 Caution: If this flag is enabled, the number of evcnt entries increase
 very much.
+.It Dv WM_DISABLE_MSI
+If this option is set non-zero value, this driver does not use msi.
+The default value is 0.
+.It Dv WM_DISABLE_MSIX
+If this option is set non-zero value, this driver does not use msix.
+The default value is 0.
 .El
 .Pp
 Setting

Index: src/sys/dev/pci/files.pci
diff -u src/sys/dev/pci/files.pci:1.387 src/sys/dev/pci/files.pci:1.388
--- src/sys/dev/pci/files.pci:1.387	Wed Mar 22 03:32:09 2017
+++ src/sys/dev/pci/files.pci	Thu Apr 13 10:37:36 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: files.pci,v 1.387 2017/03/22 03:32:09 knakahara Exp $
+#	$NetBSD: files.pci,v 1.388 2017/04/13 10:37:36 knakahara Exp $
 #
 # Config file and device description for machine-independent PCI code.
 # Included by ports that need it.  Requires that the SCSI files be
@@ -693,6 +693,8 @@ file	dev/pci/if_wm.c			wm
 defflag	opt_if_wm.h	WM_EVENT_COUNTERS
 defparam opt_if_wm.h	WM_RX_PROCESS_LIMIT_DEFAULT
 			WM_RX_INTR_PROCESS_LIMIT_DEFAULT
+			WM_DISABLE_MSI
+			WM_DISABLE_MSIX
 
 # Broadcom 570x Gigabit Ethernet
 device	bge: ether, ifnet, arp, mii, mii_bitbang

Index: src/sys/dev/pci/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.507 src/sys/dev/pci/if_wm.c:1.508
--- src/sys/dev/pci/if_wm.c:1.507	Wed Apr 12 05:08:00 2017
+++ src/sys/dev/pci/if_wm.c	Thu Apr 13 10:37:36 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.507 2017/04/12 05:08:00 knakahara Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.508 2017/04/13 10:37:36 knakahara Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -84,7 +84,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.507 2017/04/12 05:08:00 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.508 2017/04/13 10:37:36 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -173,6 +173,16 @@ int	wm_debug = WM_DEBUG_TX | WM_DEBUG_RX
 #define WM_MAX_NQUEUEINTR	16
 #define WM_MAX_NINTR		(WM_MAX_NQUEUEINTR + 1)
 
+#ifndef WM_DISABLE_MSI
+#define	WM_DISABLE_MSI 0
+#endif
+#ifndef WM_DISABLE_MSIX
+#define	WM_DISABLE_MSIX 0
+#endif
+
+int wm_disable_msi = WM_DISABLE_MSI;
+int wm_disable_msix = WM_DISABLE_MSIX;
+
 /*
  * Transmit descriptor list size.  Due to errata, we can only have
  * 256 hardware descriptors in the ring on < 82544, but we use 4096
@@ -1831,6 +1841,17 @@ wm_attach(device_t parent, device_t self
 	counts[PCI_INTR_TYPE_MSIX] = sc->sc_nqueues + 1;
 	counts[PCI_INTR_TYPE_MSI] = 1;
 	counts[PCI_INTR_TYPE_INTX] = 1;
+	/* overridden by disable flags */
+	if (wm_disable_msi != 0) {
+		counts[PCI_INTR_TYPE_MSI] = 0;
+		if (wm_disable_msix != 0) {
+			max_type = PCI_INTR_TYPE_INTX;
+			counts[PCI_INTR_TYPE_MSIX] = 0;
+		}
+	} else if (wm_disable_msix != 0) {
+		max_type = PCI_INTR_TYPE_MSI;
+		counts[PCI_INTR_TYPE_MSIX] = 0;
+	}
 
 alloc_retry:
 	if (pci_intr_alloc(pa, &sc->sc_intrs, counts, max_type) != 0) {

Reply via email to