CVS commit: [netbsd-9] src/sys/arch/x86/pci

2023-08-23 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Aug 23 17:09:09 UTC 2023

Modified Files:
src/sys/arch/x86/pci [netbsd-9]: pci_machdep.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #1722):

sys/arch/x86/pci/pci_machdep.c: revision 1.94

Fix detection of availability of MSI/MSI-X on some systems.

Try to find all functions on bus 0, device 0 to find a PCI host bridge.
Some CPU's host bridge is at 0:0.4. Tested by Intel Snow Ridge.


To generate a diff of this commit:
cvs rdiff -u -r1.86 -r1.86.2.1 src/sys/arch/x86/pci/pci_machdep.c

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



CVS commit: [netbsd-9] src/sys/arch/x86/pci

2023-08-23 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Aug 23 17:09:09 UTC 2023

Modified Files:
src/sys/arch/x86/pci [netbsd-9]: pci_machdep.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #1722):

sys/arch/x86/pci/pci_machdep.c: revision 1.94

Fix detection of availability of MSI/MSI-X on some systems.

Try to find all functions on bus 0, device 0 to find a PCI host bridge.
Some CPU's host bridge is at 0:0.4. Tested by Intel Snow Ridge.


To generate a diff of this commit:
cvs rdiff -u -r1.86 -r1.86.2.1 src/sys/arch/x86/pci/pci_machdep.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/pci_machdep.c
diff -u src/sys/arch/x86/pci/pci_machdep.c:1.86 src/sys/arch/x86/pci/pci_machdep.c:1.86.2.1
--- src/sys/arch/x86/pci/pci_machdep.c:1.86	Fri May 24 14:28:48 2019
+++ src/sys/arch/x86/pci/pci_machdep.c	Wed Aug 23 17:09:09 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_machdep.c,v 1.86 2019/05/24 14:28:48 nonaka Exp $	*/
+/*	$NetBSD: pci_machdep.c,v 1.86.2.1 2023/08/23 17:09:09 martin Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.86 2019/05/24 14:28:48 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.86.2.1 2023/08/23 17:09:09 martin Exp $");
 
 #include 
 #include 
@@ -485,6 +485,8 @@ pci_attach_hook(device_t parent, device_
 	pci_chipset_tag_t pc = pba->pba_pc;
 	pcitag_t tag;
 	pcireg_t id, class;
+	int i;
+	bool havehb = false;
 #endif
 
 	if (pba->pba_bus == 0)
@@ -502,19 +504,25 @@ pci_attach_hook(device_t parent, device_
 #ifdef __HAVE_PCI_MSI_MSIX
 	/*
 	 * In order to decide whether the system supports MSI we look
-	 * at the host bridge, which should be device 0 function 0 on
-	 * bus 0.  It is better to not enable MSI on systems that
+	 * at the host bridge, which should be device 0 on bus 0.
+	 * It is better to not enable MSI on systems that
 	 * support it than the other way around, so be conservative
 	 * here.  So we don't enable MSI if we don't find a host
 	 * bridge there.  We also deliberately don't enable MSI on
 	 * chipsets from low-end manifacturers like VIA and SiS.
 	 */
-	tag = pci_make_tag(pc, 0, 0, 0);
-	id = pci_conf_read(pc, tag, PCI_ID_REG);
-	class = pci_conf_read(pc, tag, PCI_CLASS_REG);
-
-	if (PCI_CLASS(class) != PCI_CLASS_BRIDGE ||
-	PCI_SUBCLASS(class) != PCI_SUBCLASS_BRIDGE_HOST)
+	for (i = 0; i <= 7; i++) {
+		tag = pci_make_tag(pc, 0, 0, i);
+		id = pci_conf_read(pc, tag, PCI_ID_REG);
+		class = pci_conf_read(pc, tag, PCI_CLASS_REG);
+
+		if (PCI_CLASS(class) == PCI_CLASS_BRIDGE &&
+		PCI_SUBCLASS(class) == PCI_SUBCLASS_BRIDGE_HOST) {
+			havehb = true;
+			break;
+		}
+	}
+	if (havehb == false)
 		return;
 
 	/* VMware and KVM use old chipset, but they can use MSI/MSI-X */



CVS commit: [netbsd-9] src/sys/arch/x86/pci

2023-08-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Aug 22 16:10:21 UTC 2023

Modified Files:
src/sys/arch/x86/pci [netbsd-9]: amdsmn.c amdzentemp.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #1720):

sys/arch/x86/pci/amdzentemp.c: revision 1.20
sys/arch/x86/pci/amdsmn.c: revision 1.17
sys/arch/x86/pci/amdzentemp.c: revision 1.19

Add Zen4 Ryzen "Phoenix" support.
Add Zen2 Mendocino APU support.
Add Zen4 Phoenix support.


To generate a diff of this commit:
cvs rdiff -u -r1.5.2.4 -r1.5.2.5 src/sys/arch/x86/pci/amdsmn.c
cvs rdiff -u -r1.9.2.4 -r1.9.2.5 src/sys/arch/x86/pci/amdzentemp.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/amdsmn.c
diff -u src/sys/arch/x86/pci/amdsmn.c:1.5.2.4 src/sys/arch/x86/pci/amdsmn.c:1.5.2.5
--- src/sys/arch/x86/pci/amdsmn.c:1.5.2.4	Wed Jun 21 18:56:58 2023
+++ src/sys/arch/x86/pci/amdsmn.c	Tue Aug 22 16:10:21 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: amdsmn.c,v 1.5.2.4 2023/06/21 18:56:58 martin Exp $	*/
+/*	$NetBSD: amdsmn.c,v 1.5.2.5 2023/08/22 16:10:21 martin Exp $	*/
 
 /*-
  * Copyright (c) 2017, 2019 Conrad Meyer 
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: amdsmn.c,v 1.5.2.4 2023/06/21 18:56:58 martin Exp $ ");
+__KERNEL_RCSID(0, "$NetBSD: amdsmn.c,v 1.5.2.5 2023/08/22 16:10:21 martin Exp $ ");
 
 /*
  * Driver for the AMD Family 15h (model 60+) and 17h CPU
@@ -112,6 +112,11 @@ static const struct pciid {
 		.amdsmn_addr_reg = F17H_SMN_ADDR_REG,
 		.amdsmn_data_reg = F17H_SMN_DATA_REG,
 	},
+	{
+		.amdsmn_deviceid = PCI_PRODUCT_AMD_F19_7X_RC,
+		.amdsmn_addr_reg = F17H_SMN_ADDR_REG,
+		.amdsmn_data_reg = F17H_SMN_DATA_REG,
+	},
 };
 
 static int amdsmn_match(device_t, cfdata_t, void *);

Index: src/sys/arch/x86/pci/amdzentemp.c
diff -u src/sys/arch/x86/pci/amdzentemp.c:1.9.2.4 src/sys/arch/x86/pci/amdzentemp.c:1.9.2.5
--- src/sys/arch/x86/pci/amdzentemp.c:1.9.2.4	Wed Jun 21 18:56:58 2023
+++ src/sys/arch/x86/pci/amdzentemp.c	Tue Aug 22 16:10:21 2023
@@ -1,4 +1,4 @@
-/*  $NetBSD: amdzentemp.c,v 1.9.2.4 2023/06/21 18:56:58 martin Exp $ */
+/*  $NetBSD: amdzentemp.c,v 1.9.2.5 2023/08/22 16:10:21 martin Exp $ */
 /*  $OpenBSD: kate.c,v 1.2 2008/03/27 04:52:03 cnst Exp $   */
 
 /*
@@ -53,7 +53,7 @@
 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: amdzentemp.c,v 1.9.2.4 2023/06/21 18:56:58 martin Exp $ ");
+__KERNEL_RCSID(0, "$NetBSD: amdzentemp.c,v 1.9.2.5 2023/08/22 16:10:21 martin Exp $ ");
 
 #include 
 #include 
@@ -370,15 +370,19 @@ amdzentemp_probe_ccd_sensors17h(struct a
 {
 	int maxreg;
 
-	sc->sc_ccd_offset = 0x154;
-
 	switch (model) {
 	case 0x00 ... 0x2f: /* Zen1, Zen+ */
+		sc->sc_ccd_offset = 0x154;
 		maxreg = 4;
 		break;
 	case 0x30 ... 0x3f: /* Zen2 TR (Castle Peak)/EPYC (Rome) */
 	case 0x60 ... 0x7f: /* Zen2 Ryzen (Renoir APU, Matisse) */
 	case 0x90 ... 0x9f: /* Zen2 Ryzen (Van Gogh APU) */
+		sc->sc_ccd_offset = 0x154;
+		maxreg = 8;
+		break;
+	case 0xa0 ... 0xaf: /* Zen2 Ryzen (Mendocino APU) */
+		sc->sc_ccd_offset = 0x300;
 		maxreg = 8;
 		break;
 	default:
@@ -403,6 +407,7 @@ amdzentemp_probe_ccd_sensors19h(struct a
 		maxreg = 8;
 		break;
 	case 0x60 ... 0x6f: /* Zen4 Ryzen "Raphael" */
+	case 0x70 ... 0x7f: /* Zen4 Ryzen "Phoenix" */
 		sc->sc_ccd_offset = 0x308;
 		maxreg = 8;
 		break;



CVS commit: [netbsd-9] src/sys/arch/x86/pci

2023-08-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Aug 22 16:10:21 UTC 2023

Modified Files:
src/sys/arch/x86/pci [netbsd-9]: amdsmn.c amdzentemp.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #1720):

sys/arch/x86/pci/amdzentemp.c: revision 1.20
sys/arch/x86/pci/amdsmn.c: revision 1.17
sys/arch/x86/pci/amdzentemp.c: revision 1.19

Add Zen4 Ryzen "Phoenix" support.
Add Zen2 Mendocino APU support.
Add Zen4 Phoenix support.


To generate a diff of this commit:
cvs rdiff -u -r1.5.2.4 -r1.5.2.5 src/sys/arch/x86/pci/amdsmn.c
cvs rdiff -u -r1.9.2.4 -r1.9.2.5 src/sys/arch/x86/pci/amdzentemp.c

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



CVS commit: [netbsd-9] src/sys/arch/x86/pci

2023-06-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Jun 21 18:56:58 UTC 2023

Modified Files:
src/sys/arch/x86/pci [netbsd-9]: amdsmn.c amdzentemp.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #1644):

sys/arch/x86/pci/amdsmn.c: revision 1.16
sys/arch/x86/pci/amdzentemp.c: revision 1.17
sys/arch/x86/pci/amdzentemp.c: revision 1.18

Reduce diff against DragonFly. No functional change.
amdsmn(4),amdzentemp(4): Add Zen3+ Rembrandt(19h/4xh) & Zen4 Genoa(19h/1xh).


To generate a diff of this commit:
cvs rdiff -u -r1.5.2.3 -r1.5.2.4 src/sys/arch/x86/pci/amdsmn.c
cvs rdiff -u -r1.9.2.3 -r1.9.2.4 src/sys/arch/x86/pci/amdzentemp.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/amdsmn.c
diff -u src/sys/arch/x86/pci/amdsmn.c:1.5.2.3 src/sys/arch/x86/pci/amdsmn.c:1.5.2.4
--- src/sys/arch/x86/pci/amdsmn.c:1.5.2.3	Tue Oct 11 18:16:20 2022
+++ src/sys/arch/x86/pci/amdsmn.c	Wed Jun 21 18:56:58 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: amdsmn.c,v 1.5.2.3 2022/10/11 18:16:20 martin Exp $	*/
+/*	$NetBSD: amdsmn.c,v 1.5.2.4 2023/06/21 18:56:58 martin Exp $	*/
 
 /*-
  * Copyright (c) 2017, 2019 Conrad Meyer 
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: amdsmn.c,v 1.5.2.3 2022/10/11 18:16:20 martin Exp $ ");
+__KERNEL_RCSID(0, "$NetBSD: amdsmn.c,v 1.5.2.4 2023/06/21 18:56:58 martin Exp $ ");
 
 /*
  * Driver for the AMD Family 15h (model 60+) and 17h CPU
@@ -93,7 +93,17 @@ static const struct pciid {
 		.amdsmn_data_reg = F17H_SMN_DATA_REG,
 	},
 	{
-		.amdsmn_deviceid = PCI_PRODUCT_AMD_F17_7X_RC,
+		.amdsmn_deviceid = PCI_PRODUCT_AMD_F17_7X_RC, /* or F19_0X */
+		.amdsmn_addr_reg = F17H_SMN_ADDR_REG,
+		.amdsmn_data_reg = F17H_SMN_DATA_REG,
+	},
+	{
+		.amdsmn_deviceid = PCI_PRODUCT_AMD_F17_AX_RC, /* or F19_4X */
+		.amdsmn_addr_reg = F17H_SMN_ADDR_REG,
+		.amdsmn_data_reg = F17H_SMN_DATA_REG,
+	},
+	{
+		.amdsmn_deviceid = PCI_PRODUCT_AMD_F19_1X_RC,
 		.amdsmn_addr_reg = F17H_SMN_ADDR_REG,
 		.amdsmn_data_reg = F17H_SMN_DATA_REG,
 	},

Index: src/sys/arch/x86/pci/amdzentemp.c
diff -u src/sys/arch/x86/pci/amdzentemp.c:1.9.2.3 src/sys/arch/x86/pci/amdzentemp.c:1.9.2.4
--- src/sys/arch/x86/pci/amdzentemp.c:1.9.2.3	Mon Jan 23 12:27:33 2023
+++ src/sys/arch/x86/pci/amdzentemp.c	Wed Jun 21 18:56:58 2023
@@ -1,4 +1,4 @@
-/*  $NetBSD: amdzentemp.c,v 1.9.2.3 2023/01/23 12:27:33 martin Exp $ */
+/*  $NetBSD: amdzentemp.c,v 1.9.2.4 2023/06/21 18:56:58 martin Exp $ */
 /*  $OpenBSD: kate.c,v 1.2 2008/03/27 04:52:03 cnst Exp $   */
 
 /*
@@ -53,7 +53,7 @@
 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: amdzentemp.c,v 1.9.2.3 2023/01/23 12:27:33 martin Exp $ ");
+__KERNEL_RCSID(0, "$NetBSD: amdzentemp.c,v 1.9.2.4 2023/06/21 18:56:58 martin Exp $ ");
 
 #include 
 #include 
@@ -74,7 +74,6 @@ __KERNEL_RCSID(0, "$NetBSD: amdzentemp.c
 #include "amdsmn.h"
 
 #define	AMD_CURTMP_RANGE_ADJUST	4900	/* in microKelvins (ie, 49C) */
-#define	AMD_CURTMP_RANGE_CHECK	__BIT(19)
 #define	F10_TEMP_CURTMP		__BITS(31,21)	/* XXX same as amdtemp.c */
 #define	F10_TEMP_CURTMP_MASK	0x7ff
 #define	F15M60_CURTMP_TJSEL	__BITS(17,16)
@@ -96,14 +95,7 @@ __KERNEL_RCSID(0, "$NetBSD: amdzentemp.c
  * to -49..206C.
  */
 #define	AMD_17H_CUR_TMP			0x59800
-
-/*
- * The following register set was discovered experimentally by Ondrej Čerman
- * and collaborators, but is not (yet) documented in a PPR/OSRR (other than
- * the M70H PPR SMN memory map showing [0x59800, +0x314] as allocated to
- * SMU::THM).  It seems plausible and the Linux sensor folks have adopted it.
- */
-#define	AMD_17H_CCD_TMP_BASE		0x59954
+#define	AMD_17H_CUR_TMP_RANGE_SEL	__BIT(19)
 #define	AMD_17H_CCD_TMP_VALID		__BIT(11)
 
 struct amdzentemp_softc {
@@ -114,7 +106,7 @@ struct amdzentemp_softc {
 	size_t sc_sensor_len;
 	size_t sc_numsensors;
 	int32_t sc_offset;
-	uint32_t sc_ccd_tmp_base;
+	int32_t sc_ccd_offset;
 };
 
 enum {
@@ -129,6 +121,10 @@ enum {
 	CCD5,
 	CCD6,
 	CCD7,
+	CCD8,
+	CCD9,
+	CCD10,
+	CCD11,
 	CCD_MAX,
 	NUM_CCDS = CCD_MAX - CCD_BASE
 };
@@ -339,14 +335,16 @@ amdzentemp_family17_refresh(struct sysmo
 			edata->state = ENVSYS_SINVALID;
 			return;
 		}
-		minus49 = (temp & AMD_CURTMP_RANGE_CHECK) ? true : false;
+		minus49 = (temp & AMD_17H_CUR_TMP_RANGE_SEL) ?
+		true : false;
 		temp = __SHIFTOUT(temp, F10_TEMP_CURTMP);
 		break;
 	case CCD_BASE ... (CCD_MAX - 1):
 		/* Tccd */
 		i = edata->private - CCD_BASE;
 		error = amdsmn_read(sc->sc_smn,
-		sc->sc_ccd_tmp_base + (i * sizeof(temp)), );
+		AMD_17H_CUR_TMP + sc->sc_ccd_offset + (i * sizeof(temp)),
+		);
 		if (error || !ISSET(temp, AMD_17H_CCD_TMP_VALID)) {
 			edata->state = ENVSYS_SINVALID;
 			return;
@@ -372,6 +370,8 @@ amdzentemp_probe_ccd_sensors17h(struct a
 {
 	int maxreg;
 
+	sc->sc_ccd_offset = 0x154;
+
 	switch (model) {
 	case 0x00 ... 0x2f: /* Zen1, Zen+ */
 		maxreg = 4;
@@ -399,12 

CVS commit: [netbsd-9] src/sys/arch/x86/pci

2023-06-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Jun 21 18:56:58 UTC 2023

Modified Files:
src/sys/arch/x86/pci [netbsd-9]: amdsmn.c amdzentemp.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #1644):

sys/arch/x86/pci/amdsmn.c: revision 1.16
sys/arch/x86/pci/amdzentemp.c: revision 1.17
sys/arch/x86/pci/amdzentemp.c: revision 1.18

Reduce diff against DragonFly. No functional change.
amdsmn(4),amdzentemp(4): Add Zen3+ Rembrandt(19h/4xh) & Zen4 Genoa(19h/1xh).


To generate a diff of this commit:
cvs rdiff -u -r1.5.2.3 -r1.5.2.4 src/sys/arch/x86/pci/amdsmn.c
cvs rdiff -u -r1.9.2.3 -r1.9.2.4 src/sys/arch/x86/pci/amdzentemp.c

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



CVS commit: [netbsd-9] src/sys/arch/x86/pci

2023-01-23 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jan 23 12:27:33 UTC 2023

Modified Files:
src/sys/arch/x86/pci [netbsd-9]: amdzentemp.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #1572):

sys/arch/x86/pci/amdzentemp.c: revision 1.16

match zen3 "cezanne" (ryzen 5000-series APU.)


To generate a diff of this commit:
cvs rdiff -u -r1.9.2.2 -r1.9.2.3 src/sys/arch/x86/pci/amdzentemp.c

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



CVS commit: [netbsd-9] src/sys/arch/x86/pci

2023-01-23 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jan 23 12:27:33 UTC 2023

Modified Files:
src/sys/arch/x86/pci [netbsd-9]: amdzentemp.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #1572):

sys/arch/x86/pci/amdzentemp.c: revision 1.16

match zen3 "cezanne" (ryzen 5000-series APU.)


To generate a diff of this commit:
cvs rdiff -u -r1.9.2.2 -r1.9.2.3 src/sys/arch/x86/pci/amdzentemp.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/amdzentemp.c
diff -u src/sys/arch/x86/pci/amdzentemp.c:1.9.2.2 src/sys/arch/x86/pci/amdzentemp.c:1.9.2.3
--- src/sys/arch/x86/pci/amdzentemp.c:1.9.2.2	Tue Oct 11 18:16:20 2022
+++ src/sys/arch/x86/pci/amdzentemp.c	Mon Jan 23 12:27:33 2023
@@ -1,4 +1,4 @@
-/*  $NetBSD: amdzentemp.c,v 1.9.2.2 2022/10/11 18:16:20 martin Exp $ */
+/*  $NetBSD: amdzentemp.c,v 1.9.2.3 2023/01/23 12:27:33 martin Exp $ */
 /*  $OpenBSD: kate.c,v 1.2 2008/03/27 04:52:03 cnst Exp $   */
 
 /*
@@ -53,7 +53,7 @@
 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: amdzentemp.c,v 1.9.2.2 2022/10/11 18:16:20 martin Exp $ ");
+__KERNEL_RCSID(0, "$NetBSD: amdzentemp.c,v 1.9.2.3 2023/01/23 12:27:33 martin Exp $ ");
 
 #include 
 #include 
@@ -398,6 +398,7 @@ amdzentemp_probe_ccd_sensors19h(struct a
 	switch (model) {
 	case 0x00 ... 0x0f: /* Zen3 EPYC "Milan" */
 	case 0x20 ... 0x2f: /* Zen3 Ryzen "Vermeer" */
+	case 0x50 ... 0x5f: /* Zen3 Ryzen "Cezanne" */
 		maxreg = 8;
 		break;
 	case 0x60 ... 0x6f: /* Zen4 Ryzen "Raphael" */



CVS commit: [netbsd-9] src/sys/arch/x86/pci

2019-11-16 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Nov 16 16:53:13 UTC 2019

Modified Files:
src/sys/arch/x86/pci [netbsd-9]: msipic.c

Log Message:
Pull up following revision(s) (requested by hikaru in ticket #429):

sys/arch/x86/pci/msipic.c: revision 1.19

Disable MSI-X before writing the MSI-X table.

That fixes MSI-X interrupt lost on VMware ESXi 6.7 PCI passthrough devices.

ok knakahara@


To generate a diff of this commit:
cvs rdiff -u -r1.17.2.1 -r1.17.2.2 src/sys/arch/x86/pci/msipic.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/msipic.c
diff -u src/sys/arch/x86/pci/msipic.c:1.17.2.1 src/sys/arch/x86/pci/msipic.c:1.17.2.2
--- src/sys/arch/x86/pci/msipic.c:1.17.2.1	Tue Oct 15 18:08:31 2019
+++ src/sys/arch/x86/pci/msipic.c	Sat Nov 16 16:53:13 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: msipic.c,v 1.17.2.1 2019/10/15 18:08:31 martin Exp $	*/
+/*	$NetBSD: msipic.c,v 1.17.2.2 2019/11/16 16:53:13 martin Exp $	*/
 
 /*
  * Copyright (c) 2015 Internet Initiative Japan Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: msipic.c,v 1.17.2.1 2019/10/15 18:08:31 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msipic.c,v 1.17.2.2 2019/11/16 16:53:13 martin Exp $");
 
 #include "opt_intrdebug.h"
 
@@ -548,6 +548,11 @@ msix_addroute(struct pic *pic, struct cp
 	err = pci_get_capability(pc, tag, PCI_CAP_MSIX, , NULL);
 	KASSERT(err != 0);
 
+	/* Disable MSI-X before writing MSI-X table */
+	ctl = pci_conf_read(pc, tag, off + PCI_MSIX_CTL);
+	ctl &= ~PCI_MSIX_CTL_ENABLE;
+	pci_conf_write(pc, tag, off + PCI_MSIX_CTL, ctl);
+
 	entry_base = PCI_MSIX_TABLE_ENTRY_SIZE * msix_vec;
 
 	/*



CVS commit: [netbsd-9] src/sys/arch/x86/pci

2019-11-16 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Nov 16 16:53:13 UTC 2019

Modified Files:
src/sys/arch/x86/pci [netbsd-9]: msipic.c

Log Message:
Pull up following revision(s) (requested by hikaru in ticket #429):

sys/arch/x86/pci/msipic.c: revision 1.19

Disable MSI-X before writing the MSI-X table.

That fixes MSI-X interrupt lost on VMware ESXi 6.7 PCI passthrough devices.

ok knakahara@


To generate a diff of this commit:
cvs rdiff -u -r1.17.2.1 -r1.17.2.2 src/sys/arch/x86/pci/msipic.c

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



CVS commit: [netbsd-9] src/sys/arch/x86/pci

2019-10-15 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Oct 15 18:08:31 UTC 2019

Modified Files:
src/sys/arch/x86/pci [netbsd-9]: msipic.c

Log Message:
Pull up following revision(s) (requested by tnn in ticket #305):

sys/arch/x86/pci/msipic.c: revision 1.18

change bus_space_map to _x86_memio_map

Resolves bus space reservation conflict between MI and MD code.

Discussion:
http://mail-index.netbsd.org/port-amd64/2019/09/28/msg003014.html


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.17.2.1 src/sys/arch/x86/pci/msipic.c

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



CVS commit: [netbsd-9] src/sys/arch/x86/pci

2019-10-15 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Oct 15 18:08:31 UTC 2019

Modified Files:
src/sys/arch/x86/pci [netbsd-9]: msipic.c

Log Message:
Pull up following revision(s) (requested by tnn in ticket #305):

sys/arch/x86/pci/msipic.c: revision 1.18

change bus_space_map to _x86_memio_map

Resolves bus space reservation conflict between MI and MD code.

Discussion:
http://mail-index.netbsd.org/port-amd64/2019/09/28/msg003014.html


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.17.2.1 src/sys/arch/x86/pci/msipic.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/msipic.c
diff -u src/sys/arch/x86/pci/msipic.c:1.17 src/sys/arch/x86/pci/msipic.c:1.17.2.1
--- src/sys/arch/x86/pci/msipic.c:1.17	Wed Jun 26 10:20:06 2019
+++ src/sys/arch/x86/pci/msipic.c	Tue Oct 15 18:08:31 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: msipic.c,v 1.17 2019/06/26 10:20:06 knakahara Exp $	*/
+/*	$NetBSD: msipic.c,v 1.17.2.1 2019/10/15 18:08:31 martin Exp $	*/
 
 /*
  * Copyright (c) 2015 Internet Initiative Japan Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: msipic.c,v 1.17 2019/06/26 10:20:06 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msipic.c,v 1.17.2.1 2019/10/15 18:08:31 martin Exp $");
 
 #include "opt_intrdebug.h"
 
@@ -711,7 +711,7 @@ msipic_construct_msix_pic(const struct p
 		flags &= ~BUS_SPACE_MAP_PREFETCHABLE;
 	}
 	bssize = roundup(table_size, PAGE_SIZE);
-	err = bus_space_map(pa->pa_memt, memaddr + table_offset, bssize, flags,
+	err = _x86_memio_map(pa->pa_memt, memaddr + table_offset, bssize, flags,
 	);
 	bstag = pa->pa_memt;
 #endif
@@ -739,8 +739,8 @@ msipic_destruct_msix_pic(struct pic *msi
 	KASSERT(msix_pic->pic_type == PIC_MSIX);
 
 	msipic = msix_pic->pic_msipic;
-	bus_space_unmap(msipic->mp_bstag, msipic->mp_bshandle,
-	msipic->mp_bssize);
+	_x86_memio_unmap(msipic->mp_bstag, msipic->mp_bshandle,
+	msipic->mp_bssize, NULL);
 
 	msipic_destruct_common_msi_pic(msix_pic);
 }



CVS commit: [netbsd-9] src/sys/arch/x86/pci

2019-10-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Oct 10 17:32:15 UTC 2019

Modified Files:
src/sys/arch/x86/pci [netbsd-9]: if_vmx.c

Log Message:
Pull up following revision(s) (requested by knakahara in ticket #298):

sys/arch/x86/pci/if_vmx.c: revision 1.51

Fix kassert failure in vmxnet3_transmit(). Pointed out by ryo@n.o, thanks.


To generate a diff of this commit:
cvs rdiff -u -r1.45.2.3 -r1.45.2.4 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.



CVS commit: [netbsd-9] src/sys/arch/x86/pci

2019-10-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Oct 10 17:32:15 UTC 2019

Modified Files:
src/sys/arch/x86/pci [netbsd-9]: if_vmx.c

Log Message:
Pull up following revision(s) (requested by knakahara in ticket #298):

sys/arch/x86/pci/if_vmx.c: revision 1.51

Fix kassert failure in vmxnet3_transmit(). Pointed out by ryo@n.o, thanks.


To generate a diff of this commit:
cvs rdiff -u -r1.45.2.3 -r1.45.2.4 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.45.2.3 src/sys/arch/x86/pci/if_vmx.c:1.45.2.4
--- src/sys/arch/x86/pci/if_vmx.c:1.45.2.3	Mon Sep 30 15:42:03 2019
+++ src/sys/arch/x86/pci/if_vmx.c	Thu Oct 10 17:32:15 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vmx.c,v 1.45.2.3 2019/09/30 15:42:03 martin Exp $	*/
+/*	$NetBSD: if_vmx.c,v 1.45.2.4 2019/10/10 17:32:15 martin Exp $	*/
 /*	$OpenBSD: if_vmx.c,v 1.16 2014/01/22 06:04:17 brad Exp $	*/
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.45.2.3 2019/09/30 15:42:03 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.45.2.4 2019/10/10 17:32:15 martin Exp $");
 
 #include 
 #include 
@@ -3276,7 +3276,9 @@ vmxnet3_transmit(struct ifnet *ifp, stru
 		vmxnet3_transmit_locked(ifp, txq);
 		VMXNET3_TXQ_UNLOCK(txq);
 	} else {
+		kpreempt_disable();
 		softint_schedule(txq->vxtxq_si);
+		kpreempt_enable();
 	}
 
 	return 0;



CVS commit: [netbsd-9] src/sys/arch/x86/pci

2019-09-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Sep 30 15:42:03 UTC 2019

Modified Files:
src/sys/arch/x86/pci [netbsd-9]: if_vmx.c

Log Message:
Pull up following revision(s) (requested by knakahara in ticket #268):

sys/arch/x86/pci/if_vmx.c: revision 1.50

Fix typo in vmxnet3_legacy_intr().

That causes sysctl hw.vmx*.{rx,tx} effect inversely when vmx(4) uses
INTx or MSI.


To generate a diff of this commit:
cvs rdiff -u -r1.45.2.2 -r1.45.2.3 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.45.2.2 src/sys/arch/x86/pci/if_vmx.c:1.45.2.3
--- src/sys/arch/x86/pci/if_vmx.c:1.45.2.2	Sun Sep  1 13:52:53 2019
+++ src/sys/arch/x86/pci/if_vmx.c	Mon Sep 30 15:42:03 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vmx.c,v 1.45.2.2 2019/09/01 13:52:53 martin Exp $	*/
+/*	$NetBSD: if_vmx.c,v 1.45.2.3 2019/09/30 15:42:03 martin Exp $	*/
 /*	$OpenBSD: if_vmx.c,v 1.16 2014/01/22 06:04:17 brad Exp $	*/
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.45.2.2 2019/09/01 13:52:53 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.45.2.3 2019/09/30 15:42:03 martin Exp $");
 
 #include 
 #include 
@@ -2513,11 +2513,11 @@ vmxnet3_legacy_intr(void *xsc)
 		vmxnet3_evintr(sc);
 
 	VMXNET3_RXQ_LOCK(rxq);
-	rxmore = vmxnet3_rxq_eof(rxq, txlimit);
+	rxmore = vmxnet3_rxq_eof(rxq, rxlimit);
 	VMXNET3_RXQ_UNLOCK(rxq);
 
 	VMXNET3_TXQ_LOCK(txq);
-	txmore = vmxnet3_txq_eof(txq, rxlimit);
+	txmore = vmxnet3_txq_eof(txq, txlimit);
 	VMXNET3_TXQ_UNLOCK(txq);
 
 	if (txmore || rxmore) {



CVS commit: [netbsd-9] src/sys/arch/x86/pci

2019-09-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Sep 30 15:42:03 UTC 2019

Modified Files:
src/sys/arch/x86/pci [netbsd-9]: if_vmx.c

Log Message:
Pull up following revision(s) (requested by knakahara in ticket #268):

sys/arch/x86/pci/if_vmx.c: revision 1.50

Fix typo in vmxnet3_legacy_intr().

That causes sysctl hw.vmx*.{rx,tx} effect inversely when vmx(4) uses
INTx or MSI.


To generate a diff of this commit:
cvs rdiff -u -r1.45.2.2 -r1.45.2.3 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.



CVS commit: [netbsd-9] src/sys/arch/x86/pci

2019-09-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Sep  1 13:52:53 UTC 2019

Modified Files:
src/sys/arch/x86/pci [netbsd-9]: if_vmx.c

Log Message:
Pull up following revision(s) (requested by knakahara in ticket #143):

sys/arch/x86/pci/if_vmx.c: revision 1.49

vmxnet3_softc.vmx_stats should not count globally. pointed out by hikaru@n.o

divide vmxnet3_softc.vmx_stats to each vmxnet3_txqueue and vmxnet3_rxqueue,
furthermore make them evcnt.


To generate a diff of this commit:
cvs rdiff -u -r1.45.2.1 -r1.45.2.2 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.



CVS commit: [netbsd-9] src/sys/arch/x86/pci

2019-09-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Sep  1 13:52:53 UTC 2019

Modified Files:
src/sys/arch/x86/pci [netbsd-9]: if_vmx.c

Log Message:
Pull up following revision(s) (requested by knakahara in ticket #143):

sys/arch/x86/pci/if_vmx.c: revision 1.49

vmxnet3_softc.vmx_stats should not count globally. pointed out by hikaru@n.o

divide vmxnet3_softc.vmx_stats to each vmxnet3_txqueue and vmxnet3_rxqueue,
furthermore make them evcnt.


To generate a diff of this commit:
cvs rdiff -u -r1.45.2.1 -r1.45.2.2 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.45.2.1 src/sys/arch/x86/pci/if_vmx.c:1.45.2.2
--- src/sys/arch/x86/pci/if_vmx.c:1.45.2.1	Tue Aug 20 11:31:46 2019
+++ src/sys/arch/x86/pci/if_vmx.c	Sun Sep  1 13:52:53 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vmx.c,v 1.45.2.1 2019/08/20 11:31:46 martin Exp $	*/
+/*	$NetBSD: if_vmx.c,v 1.45.2.2 2019/09/01 13:52:53 martin Exp $	*/
 /*	$OpenBSD: if_vmx.c,v 1.16 2014/01/22 06:04:17 brad Exp $	*/
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.45.2.1 2019/08/20 11:31:46 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.45.2.2 2019/09/01 13:52:53 martin Exp $");
 
 #include 
 #include 
@@ -207,6 +207,8 @@ struct vmxnet3_txqueue {
 	struct evcnt vxtxq_pcqdrop;
 	struct evcnt vxtxq_transmitdef;
 	struct evcnt vxtxq_watchdogto;
+	struct evcnt vxtxq_defragged;
+	struct evcnt vxtxq_defrag_failed;
 };
 
 struct vmxnet3_rxq_stats {
@@ -230,6 +232,8 @@ struct vmxnet3_rxqueue {
 	struct evcnt vxrxq_intr;
 	struct evcnt vxrxq_defer;
 	struct evcnt vxrxq_deferreq;
+	struct evcnt vxrxq_mgetcl_failed;
+	struct evcnt vxrxq_mbuf_load_failed;
 };
 
 struct vmxnet3_queue {
@@ -244,13 +248,6 @@ struct vmxnet3_queue {
 	struct work vxq_wq_cookie;
 };
 
-struct vmxnet3_statistics {
-	uint32_t vmst_defragged;
-	uint32_t vmst_defrag_failed;
-	uint32_t vmst_mgetcl_failed;
-	uint32_t vmst_mbuf_load_failed;
-};
-
 struct vmxnet3_softc {
 	device_t vmx_dev;
 	struct ethercom vmx_ethercom;
@@ -281,7 +278,6 @@ struct vmxnet3_softc {
 	int vmx_nrxdescs;
 	int vmx_max_rxsegs;
 
-	struct vmxnet3_statistics vmx_stats;
 	struct evcnt vmx_event_intr;
 	struct evcnt vmx_event_link;
 	struct evcnt vmx_event_txqerror;
@@ -395,7 +391,8 @@ int vmxnet3_setup_interface(struct vmxne
 
 void vmxnet3_evintr(struct vmxnet3_softc *);
 bool vmxnet3_txq_eof(struct vmxnet3_txqueue *, u_int);
-int vmxnet3_newbuf(struct vmxnet3_softc *, struct vmxnet3_rxring *);
+int vmxnet3_newbuf(struct vmxnet3_softc *, struct vmxnet3_rxqueue *,
+struct vmxnet3_rxring *);
 void vmxnet3_rxq_eof_discard(struct vmxnet3_rxqueue *,
 struct vmxnet3_rxring *, int);
 void vmxnet3_rxq_discard_chain(struct vmxnet3_rxqueue *);
@@ -1971,6 +1968,10 @@ vmxnet3_setup_stats(struct vmxnet3_softc
 		NULL, txq->vxtxq_name, "Deferred transmit");
 		evcnt_attach_dynamic(>vxtxq_watchdogto, EVCNT_TYPE_MISC,
 		NULL, txq->vxtxq_name, "Watchdog timeount");
+		evcnt_attach_dynamic(>vxtxq_defragged, EVCNT_TYPE_MISC,
+		NULL, txq->vxtxq_name, "m_defrag sucessed");
+		evcnt_attach_dynamic(>vxtxq_defrag_failed, EVCNT_TYPE_MISC,
+		NULL, txq->vxtxq_name, "m_defrag failed");
 	}
 
 	for (i = 0; i < sc->vmx_nrxqueues; i++) {
@@ -1982,6 +1983,10 @@ vmxnet3_setup_stats(struct vmxnet3_softc
 		NULL, rxq->vxrxq_name, "Handled queue in softint/workqueue");
 		evcnt_attach_dynamic(>vxrxq_deferreq, EVCNT_TYPE_MISC,
 		NULL, rxq->vxrxq_name, "Requested in softint/workqueue");
+		evcnt_attach_dynamic(>vxrxq_mgetcl_failed, EVCNT_TYPE_MISC,
+		NULL, rxq->vxrxq_name, "MCLGET failed");
+		evcnt_attach_dynamic(>vxrxq_mbuf_load_failed, EVCNT_TYPE_MISC,
+		NULL, rxq->vxrxq_name, "bus_dmamap_load_mbuf failed");
 	}
 
 	evcnt_attach_dynamic(>vmx_event_intr, EVCNT_TYPE_INTR,
@@ -2017,6 +2022,8 @@ vmxnet3_teardown_stats(struct vmxnet3_so
 		evcnt_detach(>vxtxq_pcqdrop);
 		evcnt_detach(>vxtxq_transmitdef);
 		evcnt_detach(>vxtxq_watchdogto);
+		evcnt_detach(>vxtxq_defragged);
+		evcnt_detach(>vxtxq_defrag_failed);
 	}
 
 	for (i = 0; i < sc->vmx_nrxqueues; i++) {
@@ -2025,6 +2032,8 @@ vmxnet3_teardown_stats(struct vmxnet3_so
 		evcnt_detach(>vxrxq_intr);
 		evcnt_detach(>vxrxq_defer);
 		evcnt_detach(>vxrxq_deferreq);
+		evcnt_detach(>vxrxq_mgetcl_failed);
+		evcnt_detach(>vxrxq_mbuf_load_failed);
 	}
 
 	evcnt_detach(>vmx_event_intr);
@@ -2154,7 +2163,8 @@ vmxnet3_txq_eof(struct vmxnet3_txqueue *
 }
 
 int
-vmxnet3_newbuf(struct vmxnet3_softc *sc, struct vmxnet3_rxring *rxr)
+vmxnet3_newbuf(struct vmxnet3_softc *sc, struct vmxnet3_rxqueue *rxq,
+struct vmxnet3_rxring *rxr)
 {
 	struct mbuf *m;
 	struct vmxnet3_rxdesc *rxd;
@@ -2180,7 +2190,7 @@ vmxnet3_newbuf(struct vmxnet3_softc *sc,
 
 	MCLGET(m, M_DONTWAIT);
 	if ((m->m_flags & M_EXT) == 0) {
-		

CVS commit: [netbsd-9] src/sys/arch/x86/pci

2019-08-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Aug 20 11:31:46 UTC 2019

Modified Files:
src/sys/arch/x86/pci [netbsd-9]: if_vmx.c

Log Message:
Pull up following revision(s) (requested by knakahara in ticket #99):

sys/arch/x86/pci/if_vmx.c: revision 1.46
sys/arch/x86/pci/if_vmx.c: revision 1.47
sys/arch/x86/pci/if_vmx.c: revision 1.48

vmx(4) uses interrupt distribution for each queue like ixg(4).

fix panic when vmx(4) is detached.

add vmx(4) basic statistics counters.
Sorry, I have forgotten this TODO in r1.40 commit message.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.45.2.1 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.45 src/sys/arch/x86/pci/if_vmx.c:1.45.2.1
--- src/sys/arch/x86/pci/if_vmx.c:1.45	Tue Jul 30 11:16:15 2019
+++ src/sys/arch/x86/pci/if_vmx.c	Tue Aug 20 11:31:46 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vmx.c,v 1.45 2019/07/30 11:16:15 knakahara Exp $	*/
+/*	$NetBSD: if_vmx.c,v 1.45.2.1 2019/08/20 11:31:46 martin Exp $	*/
 /*	$OpenBSD: if_vmx.c,v 1.16 2014/01/22 06:04:17 brad Exp $	*/
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.45 2019/07/30 11:16:15 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.45.2.1 2019/08/20 11:31:46 martin Exp $");
 
 #include 
 #include 
@@ -31,6 +31,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -199,6 +200,13 @@ struct vmxnet3_txqueue {
 	char vxtxq_name[16];
 
 	void *vxtxq_si;
+
+	struct evcnt vxtxq_intr;
+	struct evcnt vxtxq_defer;
+	struct evcnt vxtxq_deferreq;
+	struct evcnt vxtxq_pcqdrop;
+	struct evcnt vxtxq_transmitdef;
+	struct evcnt vxtxq_watchdogto;
 };
 
 struct vmxnet3_rxq_stats {
@@ -218,6 +226,10 @@ struct vmxnet3_rxqueue {
 	struct vmxnet3_rxq_stats vxrxq_stats;
 	struct vmxnet3_rxq_shared *vxrxq_rs;
 	char vxrxq_name[16];
+
+	struct evcnt vxrxq_intr;
+	struct evcnt vxrxq_defer;
+	struct evcnt vxrxq_deferreq;
 };
 
 struct vmxnet3_queue {
@@ -270,6 +282,12 @@ struct vmxnet3_softc {
 	int vmx_max_rxsegs;
 
 	struct vmxnet3_statistics vmx_stats;
+	struct evcnt vmx_event_intr;
+	struct evcnt vmx_event_link;
+	struct evcnt vmx_event_txqerror;
+	struct evcnt vmx_event_rxqerror;
+	struct evcnt vmx_event_dic;
+	struct evcnt vmx_event_debug;
 
 	int vmx_intr_type;
 	int vmx_intr_mask_mode;
@@ -348,6 +366,9 @@ void vmxnet3_set_interrupt_idx(struct vm
 int vmxnet3_setup_interrupts(struct vmxnet3_softc *);
 int vmxnet3_setup_sysctl(struct vmxnet3_softc *);
 
+int vmxnet3_setup_stats(struct vmxnet3_softc *);
+void vmxnet3_teardown_stats(struct vmxnet3_softc *);
+
 int vmxnet3_init_rxq(struct vmxnet3_softc *, int);
 int vmxnet3_init_txq(struct vmxnet3_softc *, int);
 int vmxnet3_alloc_rxtx_queues(struct vmxnet3_softc *);
@@ -630,6 +651,10 @@ vmxnet3_attach(device_t parent, device_t
 	if (error)
 		return;
 
+	error = vmxnet3_setup_stats(sc);
+	if (error)
+		return;
+
 	sc->vmx_flags |= VMXNET3_FLAG_ATTACHED;
 }
 
@@ -654,6 +679,7 @@ vmxnet3_detach(device_t self, int flags)
 		if_detach(ifp);
 	}
 
+	vmxnet3_teardown_stats(sc);
 	sysctl_teardown(>vmx_sysctllog);
 
 	vmxnet3_free_interrupts(sc);
@@ -858,11 +884,13 @@ vmxnet3_free_interrupts(struct vmxnet3_s
 	int i;
 
 	workqueue_destroy(sc->vmx_queue_wq);
-	for (i = 0; i < sc->vmx_nintrs; i++) {
+	for (i = 0; i < sc->vmx_ntxqueues; i++) {
 		struct vmxnet3_queue *vmxq =  >vmx_queue[i];
 
 		softint_disestablish(vmxq->vxq_si);
 		vmxq->vxq_si = NULL;
+	}
+	for (i = 0; i < sc->vmx_nintrs; i++) {
 		pci_intr_disestablish(pc, sc->vmx_ihs[i]);
 	}
 	pci_intr_release(pc, sc->vmx_intrs, sc->vmx_nintrs);
@@ -876,6 +904,7 @@ vmxnet3_setup_msix_interrupts(struct vmx
 	pci_intr_handle_t *intr;
 	void **ihs;
 	int intr_idx, i, use_queues, error;
+	kcpuset_t *affinity;
 	const char *intrstr;
 	char intrbuf[PCI_INTRSTR_LEN];
 	char xnamebuf[32];
@@ -903,6 +932,16 @@ vmxnet3_setup_msix_interrupts(struct vmx
 		}
 		aprint_normal_dev(sc->vmx_dev, "txrx interrupting at %s\n", intrstr);
 
+		kcpuset_create(, true);
+		kcpuset_set(affinity, intr_idx % ncpu);
+		error = interrupt_distribute(*ihs, affinity, NULL);
+		if (error) {
+			aprint_normal_dev(sc->vmx_dev,
+			"%s cannot be changed affinity, use default CPU\n",
+			intrstr);
+		}
+		kcpuset_destroy(affinity);
+
 		vmxq->vxq_si = softint_establish(SOFTINT_NET | SOFTINT_MPSAFE,
 		vmxnet3_handle_queue, vmxq);
 		if (vmxq->vxq_si == NULL) {
@@ -1909,6 +1948,93 @@ out:
 	return error;
 }
 
+int
+vmxnet3_setup_stats(struct vmxnet3_softc *sc)
+{
+	struct vmxnet3_queue *vmxq;
+	struct vmxnet3_txqueue *txq;
+	struct vmxnet3_rxqueue *rxq;
+	int i;
+
+	for (i = 0; i < sc->vmx_ntxqueues; i++) {
+		vmxq = >vmx_queue[i];
+		txq = >vxq_txqueue;
+		evcnt_attach_dynamic(>vxtxq_intr, EVCNT_TYPE_INTR,
+		   

CVS commit: [netbsd-9] src/sys/arch/x86/pci

2019-08-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Aug 20 11:31:46 UTC 2019

Modified Files:
src/sys/arch/x86/pci [netbsd-9]: if_vmx.c

Log Message:
Pull up following revision(s) (requested by knakahara in ticket #99):

sys/arch/x86/pci/if_vmx.c: revision 1.46
sys/arch/x86/pci/if_vmx.c: revision 1.47
sys/arch/x86/pci/if_vmx.c: revision 1.48

vmx(4) uses interrupt distribution for each queue like ixg(4).

fix panic when vmx(4) is detached.

add vmx(4) basic statistics counters.
Sorry, I have forgotten this TODO in r1.40 commit message.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.45.2.1 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.