CVS commit: src/sys/dev/isa

2021-07-02 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Sat Jul  3 04:44:16 UTC 2021

Modified Files:
src/sys/dev/isa: itesio_isa.c itesio_isavar.h

Log Message:
itesio(4): Added IT8625E support.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/dev/isa/itesio_isa.c
cvs rdiff -u -r1.13 -r1.14 src/sys/dev/isa/itesio_isavar.h

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

Modified files:

Index: src/sys/dev/isa/itesio_isa.c
diff -u src/sys/dev/isa/itesio_isa.c:1.28 src/sys/dev/isa/itesio_isa.c:1.29
--- src/sys/dev/isa/itesio_isa.c:1.28	Tue Jul 23 09:38:53 2019
+++ src/sys/dev/isa/itesio_isa.c	Sat Jul  3 04:44:16 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: itesio_isa.c,v 1.28 2019/07/23 09:38:53 msaitoh Exp $ */
+/*	$NetBSD: itesio_isa.c,v 1.29 2021/07/03 04:44:16 nonaka Exp $ */
 /*	Derived from $OpenBSD: it.c,v 1.19 2006/04/10 00:57:54 deraadt Exp $	*/
 
 /*
@@ -34,13 +34,14 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: itesio_isa.c,v 1.28 2019/07/23 09:38:53 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: itesio_isa.c,v 1.29 2021/07/03 04:44:16 nonaka Exp $");
 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -52,6 +53,11 @@ __KERNEL_RCSID(0, "$NetBSD: itesio_isa.c
 #define IT_VOLTSTART_IDX 	3 	/* voltage start index */
 #define IT_FANSTART_IDX 	12 	/* fan start index */
 
+/* IT8625: 3 temps, 10 volts, 6 fans */
+#define IT8625_NUM_SENSORS	19
+#define IT8625_VOLTSTART_IDX 	3	/* voltage start index */
+#define IT8625_FANSTART_IDX 	13	/* fan start index */
+
 #if defined(ITESIO_DEBUG)
 #define DPRINTF(x)		do { printf x; } while (0)
 #else
@@ -90,6 +96,13 @@ static void	itesio_refresh_temp(struct i
 static void	itesio_refresh_volts(struct itesio_softc *, envsys_data_t *);
 static void	itesio_refresh_fans(struct itesio_softc *, envsys_data_t *);
 static void	itesio_refresh(struct sysmon_envsys *, envsys_data_t *);
+static void	itesio_refresh_it8705_fans(struct itesio_softc *,
+		envsys_data_t *);
+static void	itesio_setup_it8625_sensors(struct itesio_softc *);
+static void	itesio_refresh_it8625_volts(struct itesio_softc *,
+		envsys_data_t *);
+static void	itesio_refresh_it8625_fans(struct itesio_softc *,
+		envsys_data_t *);
 
 /* sysmon_wdog glue */
 static bool	itesio_wdt_suspend(device_t, const pmf_qual_t *);
@@ -109,11 +122,58 @@ static const int itesio_vrfact[] = {
 	RFACT_NONE	/* VBAT		*/
 };
 
+static const struct itesio_config itesio_config[] = {
+	{
+		.chipid = ITESIO_ID8625,
+		.no_wdt = true,
+		.num_sensors = IT8625_NUM_SENSORS,
+		.voltstart_idx = IT8625_VOLTSTART_IDX,
+		.fanstart_idx = IT8625_FANSTART_IDX,
+		.setup_sensors = itesio_setup_it8625_sensors,
+		.refresh_volts = itesio_refresh_it8625_volts,
+		.refresh_fans = itesio_refresh_it8625_fans,
+	},
+	{	.chipid = ITESIO_ID8628, },
+	{	.chipid = ITESIO_ID8655, },
+	{
+		.chipid = ITESIO_ID8705,
+		.no_wdt = true,
+		.refresh_fans = itesio_refresh_it8705_fans,
+	},
+	{
+		.chipid = ITESIO_ID8712,
+		.refresh_fans = itesio_refresh_it8705_fans,
+	},
+	{	.chipid = ITESIO_ID8716, },
+	{	.chipid = ITESIO_ID8718, },
+	{	.chipid = ITESIO_ID8720, },
+	{	.chipid = ITESIO_ID8721, },
+	{	.chipid = ITESIO_ID8726, },
+	{	.chipid = ITESIO_ID8728, },
+	{	.chipid = ITESIO_ID8771, },
+	{	.chipid = ITESIO_ID8772, },
+};
+
+static const struct itesio_config *
+itesio_isa_find_config(uint16_t chipid)
+{
+	const struct itesio_config *ic;
+	size_t i;
+
+	for (i = 0; i < __arraycount(itesio_config); i++) {
+		ic = _config[i];
+		if (chipid == ic->chipid)
+			return ic;
+	}
+	return NULL;
+}
+
 static int
 itesio_isa_match(device_t parent, cfdata_t match, void *aux)
 {
 	struct isa_attach_args *ia = aux;
 	bus_space_handle_t ioh;
+	const struct itesio_config *ic;
 	uint16_t cr;
 
 	/* Must supply an address */
@@ -135,28 +195,16 @@ itesio_isa_match(device_t parent, cfdata
 	itesio_exit(ia->ia_iot, ioh);
 	bus_space_unmap(ia->ia_iot, ioh, 2);
 
-	switch (cr) {
-	case ITESIO_ID8628:
-	case ITESIO_ID8655:
-	case ITESIO_ID8705:
-	case ITESIO_ID8712:
-	case ITESIO_ID8716:
-	case ITESIO_ID8718:
-	case ITESIO_ID8720:
-	case ITESIO_ID8721:
-	case ITESIO_ID8726:
-	case ITESIO_ID8728:
-	case ITESIO_ID8771:
-	case ITESIO_ID8772:
-		ia->ia_nio = 1;
-		ia->ia_io[0].ir_size = 2;
-		ia->ia_niomem = 0;
-		ia->ia_nirq = 0;
-		ia->ia_ndrq = 0;
-		return 1;
-	default:
+	ic = itesio_isa_find_config(cr);
+	if (ic == NULL)
 		return 0;
-	}
+
+	ia->ia_nio = 1;
+	ia->ia_io[0].ir_size = 2;
+	ia->ia_niomem = 0;
+	ia->ia_nirq = 0;
+	ia->ia_ndrq = 0;
+	return 1;
 }
 
 static void
@@ -164,7 +212,9 @@ itesio_isa_attach(device_t parent, devic
 {
 	struct itesio_softc *sc = device_private(self);
 	struct isa_attach_args *ia = aux;
-	int i;
+	const struct itesio_config *ic;
+	uint32_t i;
+	int error;
 	uint8_t cr;
 
 	sc->sc_iot = ia->ia_iot;
@@ -205,6 +255,27 @@ itesio_isa_attach(device_t parent, devic
 	 */
 	itesio_exit(sc->sc_iot, 

CVS commit: src/sys/dev/hyperv

2021-06-10 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Thu Jun 10 07:48:01 UTC 2021

Modified Files:
src/sys/dev/hyperv: hvs.c

Log Message:
hvs(4): Pass correct pointer of scsibus device to scsi_probe_bus().


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/hyperv/hvs.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/dev/hyperv/hvs.c
diff -u src/sys/dev/hyperv/hvs.c:1.5 src/sys/dev/hyperv/hvs.c:1.6
--- src/sys/dev/hyperv/hvs.c:1.5	Sat Apr 24 23:36:54 2021
+++ src/sys/dev/hyperv/hvs.c	Thu Jun 10 07:48:00 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: hvs.c,v 1.5 2021/04/24 23:36:54 thorpej Exp $	*/
+/*	$NetBSD: hvs.c,v 1.6 2021/06/10 07:48:00 nonaka Exp $	*/
 /*	$OpenBSD: hvs.c,v 1.17 2017/08/10 17:22:48 mikeb Exp $	*/
 
 /*-
@@ -37,7 +37,7 @@
 /* #define HVS_DEBUG_IO */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: hvs.c,v 1.5 2021/04/24 23:36:54 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hvs.c,v 1.6 2021/06/10 07:48:00 nonaka Exp $");
 
 #include 
 #include 
@@ -833,7 +833,7 @@ hvs_scsi_probe(void *arg)
 	struct hvs_softc *sc = arg;
 
 	if (sc->sc_scsibus != NULL)
-		scsi_probe_bus((void *)sc->sc_scsibus, -1, -1);
+		scsi_probe_bus(device_private(sc->sc_scsibus), -1, -1);
 }
 
 static void



CVS commit: src/sys/arch/x86/pci

2021-06-06 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Sun Jun  6 11:35:22 UTC 2021

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

Log Message:
Fix build failure on i386.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 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.13 src/sys/arch/x86/pci/amdzentemp.c:1.14
--- src/sys/arch/x86/pci/amdzentemp.c:1.13	Sun Jun  6 08:45:18 2021
+++ src/sys/arch/x86/pci/amdzentemp.c	Sun Jun  6 11:35:22 2021
@@ -1,4 +1,4 @@
-/*  $NetBSD: amdzentemp.c,v 1.13 2021/06/06 08:45:18 nonaka Exp $ */
+/*  $NetBSD: amdzentemp.c,v 1.14 2021/06/06 11:35:22 nonaka 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.13 2021/06/06 08:45:18 nonaka Exp $ ");
+__KERNEL_RCSID(0, "$NetBSD: amdzentemp.c,v 1.14 2021/06/06 11:35:22 nonaka Exp $ ");
 
 #include 
 #include 
@@ -431,8 +431,9 @@ static void
 amdzentemp_setup_ccd_sensors(struct amdzentemp_softc *sc)
 {
 	envsys_data_t *edata;
+	size_t i;
 	uint32_t temp;
-	int i, error;
+	int error;
 
 	for (i = 0; i < sc->sc_numsensors - 1; i++) {
 		error = amdsmn_read(sc->sc_smn,
@@ -446,7 +447,7 @@ amdzentemp_setup_ccd_sensors(struct amdz
 		edata->flags = ENVSYS_FHAS_ENTROPY;
 		edata->private = CCD_BASE + i;
 		snprintf(edata->desc, sizeof(edata->desc),
-		"cpu%u ccd%u temperature", device_unit(sc->sc_dev), i);
+		"cpu%u ccd%zu temperature", device_unit(sc->sc_dev), i);
 	}
 }
 



CVS commit: src/sys/arch/x86/pci

2021-06-06 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Sun Jun  6 08:45:18 UTC 2021

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

Log Message:
amdzentemp(4): Add support for per CCD temperature sensor from FreeBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 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.12 src/sys/arch/x86/pci/amdzentemp.c:1.13
--- src/sys/arch/x86/pci/amdzentemp.c:1.12	Sat Jun  5 01:38:22 2021
+++ src/sys/arch/x86/pci/amdzentemp.c	Sun Jun  6 08:45:18 2021
@@ -1,4 +1,4 @@
-/*  $NetBSD: amdzentemp.c,v 1.12 2021/06/05 01:38:22 nonaka Exp $ */
+/*  $NetBSD: amdzentemp.c,v 1.13 2021/06/06 08:45:18 nonaka 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.12 2021/06/05 01:38:22 nonaka Exp $ ");
+__KERNEL_RCSID(0, "$NetBSD: amdzentemp.c,v 1.13 2021/06/06 08:45:18 nonaka Exp $ ");
 
 #include 
 #include 
@@ -76,6 +76,7 @@ __KERNEL_RCSID(0, "$NetBSD: amdzentemp.c
 #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,7 +97,17 @@ __KERNEL_RCSID(0, "$NetBSD: amdzentemp.c
  */
 #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_CCD_TMP_VALID		__BIT(11)
+
 struct amdzentemp_softc {
+	device_t sc_dev;
 	struct sysmon_envsys *sc_sme;
 	device_t sc_smn;
 	envsys_data_t *sc_sensor;
@@ -105,15 +116,33 @@ struct amdzentemp_softc {
 	int32_t sc_offset;
 };
 
+enum {
+	NOSENSOR = 0,
+	CORE0_SENSOR0,
+	CCD_BASE,
+	CCD0 = CCD_BASE,
+	CCD1,
+	CCD2,
+	CCD3,
+	CCD4,
+	CCD5,
+	CCD6,
+	CCD7,
+	CCD_MAX,
+	NUM_CCDS = CCD_MAX - CCD_BASE
+};
+
 
 static int  amdzentemp_match(device_t, cfdata_t, void *);
 static void amdzentemp_attach(device_t, device_t, void *);
 static int  amdzentemp_detach(device_t, int);
 
-static void amdzentemp_init(struct amdzentemp_softc *);
-static void amdzentemp_setup_sensors(struct amdzentemp_softc *, int);
+static void amdzentemp_init(struct amdzentemp_softc *, int, int);
+static void amdzentemp_setup_sensors(struct amdzentemp_softc *);
 static void amdzentemp_family15_refresh(struct sysmon_envsys *, envsys_data_t *);
 static void amdzentemp_family17_refresh(struct sysmon_envsys *, envsys_data_t *);
+static int  amdzentemp_probe_ccd_sensors(struct amdzentemp_softc *, int, int);
+static void amdzentemp_setup_ccd_sensors(struct amdzentemp_softc *);
 
 CFATTACH_DECL_NEW(amdzentemp, sizeof(struct amdzentemp_softc),
 amdzentemp_match, amdzentemp_attach, amdzentemp_detach, NULL);
@@ -124,9 +153,9 @@ amdzentemp_match(device_t parent, cfdata
 	struct pci_attach_args *pa __diagused = aux;
 
 	KASSERT(PCI_VENDOR(pa->pa_id) == PCI_VENDOR_AMD);
- 
+
 	cfdata_t parent_cfdata = device_cfdata(parent);
- 
+
 	/* Got AMD family 17h system management network */
 	return parent_cfdata->cf_name &&
 	memcmp(parent_cfdata->cf_name, "amdsmn", 6) == 0;
@@ -137,18 +166,20 @@ amdzentemp_attach(device_t parent, devic
 {
 	struct amdzentemp_softc *sc = device_private(self);
 	struct cpu_info *ci = curcpu();
-	int family;
+	int family, model;
 	int error;
 	size_t i;
 
+	sc->sc_dev = self;
+
 	family = CPUID_TO_FAMILY(ci->ci_signature);
+	model = CPUID_TO_MODEL(ci->ci_signature);
 	aprint_naive("\n");
-	aprint_normal(": AMD CPU Temperature Sensors (Family%xh)",
-	family);
+	aprint_normal(": AMD CPU Temperature Sensors (Family%xh)", family);
 
 	sc->sc_smn = parent;
 
-	amdzentemp_init(sc);
+	amdzentemp_init(sc, family, model);
 
 	aprint_normal("\n");
 
@@ -156,12 +187,14 @@ amdzentemp_attach(device_t parent, devic
 	sc->sc_sensor_len = sizeof(envsys_data_t) * sc->sc_numsensors;
 	sc->sc_sensor = kmem_zalloc(sc->sc_sensor_len, KM_SLEEP);
 
-	amdzentemp_setup_sensors(sc, device_unit(self));
+	amdzentemp_setup_sensors(sc);
 
 	/*
 	 * Set properties in sensors.
 	 */
 	for (i = 0; i < sc->sc_numsensors; i++) {
+		if (sc->sc_sensor[i].private == NOSENSOR)
+			continue;
 		if (sysmon_envsys_sensor_attach(sc->sc_sme, >sc_sensor[i]))
 			goto bad;
 	}
@@ -223,10 +256,10 @@ amdzentemp_detach(device_t self, int fla
 
 
 static void
-amdzentemp_init(struct amdzentemp_softc *sc) 
+amdzentemp_init(struct amdzentemp_softc *sc, int family, int model)
 {
 
-	sc->sc_numsensors = 1;
+	

CVS commit: src/sys/dev/isa

2021-06-04 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Sat Jun  5 01:40:53 UTC 2021

Modified Files:
src/sys/dev/isa: itesio_isavar.h

Log Message:
Add IT8625 chip id.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/dev/isa/itesio_isavar.h

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

Modified files:

Index: src/sys/dev/isa/itesio_isavar.h
diff -u src/sys/dev/isa/itesio_isavar.h:1.12 src/sys/dev/isa/itesio_isavar.h:1.13
--- src/sys/dev/isa/itesio_isavar.h:1.12	Tue Jul 23 09:38:53 2019
+++ src/sys/dev/isa/itesio_isavar.h	Sat Jun  5 01:40:53 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: itesio_isavar.h,v 1.12 2019/07/23 09:38:53 msaitoh Exp $	*/
+/*	$NetBSD: itesio_isavar.h,v 1.13 2021/06/05 01:40:53 nonaka Exp $	*/
 /*	$OpenBSD: itvar.h,v 1.2 2003/11/05 20:57:10 grange Exp $	*/
 
 /*
@@ -57,6 +57,7 @@
 #define ITESIO_CHIPID2	0x21	/* Chip ID 2 */
 #define ITESIO_DEVREV	0x22	/* Device Revision */
 
+#define ITESIO_ID8625	0x8625
 #define ITESIO_ID8628	0x8628
 #define ITESIO_ID8655	0x8655
 #define ITESIO_ID8705	0x8705



CVS commit: src/sys/arch/x86/pci

2021-06-04 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Sat Jun  5 01:38:22 UTC 2021

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

Log Message:
amdzentemp(4): Add Zen 3 support.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 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.11 src/sys/arch/x86/pci/amdzentemp.c:1.12
--- src/sys/arch/x86/pci/amdzentemp.c:1.11	Sat Apr 25 15:26:18 2020
+++ src/sys/arch/x86/pci/amdzentemp.c	Sat Jun  5 01:38:22 2021
@@ -1,4 +1,4 @@
-/*  $NetBSD: amdzentemp.c,v 1.11 2020/04/25 15:26:18 bouyer Exp $ */
+/*  $NetBSD: amdzentemp.c,v 1.12 2021/06/05 01:38:22 nonaka 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.11 2020/04/25 15:26:18 bouyer Exp $ ");
+__KERNEL_RCSID(0, "$NetBSD: amdzentemp.c,v 1.12 2021/06/05 01:38:22 nonaka Exp $ ");
 
 #include 
 #include 
@@ -177,6 +177,7 @@ amdzentemp_attach(device_t parent, devic
 		sc->sc_sme->sme_refresh = amdzentemp_family15_refresh;
 		break;
 	case 0x17:
+	case 0x19:
 		sc->sc_sme->sme_refresh = amdzentemp_family17_refresh;
 		break;
 	default:



CVS commit: src/sys/arch/x86/include

2021-03-17 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Thu Mar 18 01:50:12 UTC 2021

Modified Files:
src/sys/arch/x86/include: intrdefs.h

Log Message:
LIR_HV priority should be lower than softint.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/x86/include/intrdefs.h

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/include/intrdefs.h
diff -u src/sys/arch/x86/include/intrdefs.h:1.24 src/sys/arch/x86/include/intrdefs.h:1.25
--- src/sys/arch/x86/include/intrdefs.h:1.24	Sat Apr 25 15:26:18 2020
+++ src/sys/arch/x86/include/intrdefs.h	Thu Mar 18 01:50:12 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: intrdefs.h,v 1.24 2020/04/25 15:26:18 bouyer Exp $	*/
+/*	$NetBSD: intrdefs.h,v 1.25 2021/03/18 01:50:12 nonaka Exp $	*/
 
 #ifndef _X86_INTRDEFS_H_
 #define _X86_INTRDEFS_H_
@@ -27,7 +27,6 @@
  */
 #define LIR_IPI		31
 #define LIR_TIMER	30
-#define LIR_HV		29
 
 /*
  * XXX These should be lowest numbered, but right now would
@@ -35,11 +34,12 @@
  * means that soft interrupt take priority over hardware
  * interrupts when lowering the priority level!
  */
-#define	SIR_SERIAL	28
-#define	SIR_NET		27
-#define	SIR_BIO		26
-#define	SIR_CLOCK	25
-#define	SIR_PREEMPT	24
+#define	SIR_SERIAL	29
+#define	SIR_NET		28
+#define	SIR_BIO		27
+#define	SIR_CLOCK	26
+#define	SIR_PREEMPT	25
+#define	LIR_HV		24
 #define	SIR_XENIPL_HIGH 23
 #define	SIR_XENIPL_SCHED 22
 #define	SIR_XENIPL_VM	21



CVS commit: src/sys/dev/hyperv

2021-01-28 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Fri Jan 29 04:38:49 UTC 2021

Modified Files:
src/sys/dev/hyperv: if_hvn.c

Log Message:
hvn(4): Don't wait forever.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/dev/hyperv/if_hvn.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/dev/hyperv/if_hvn.c
diff -u src/sys/dev/hyperv/if_hvn.c:1.19 src/sys/dev/hyperv/if_hvn.c:1.20
--- src/sys/dev/hyperv/if_hvn.c:1.19	Fri Dec 11 08:13:08 2020
+++ src/sys/dev/hyperv/if_hvn.c	Fri Jan 29 04:38:49 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_hvn.c,v 1.19 2020/12/11 08:13:08 nonaka Exp $	*/
+/*	$NetBSD: if_hvn.c,v 1.20 2021/01/29 04:38:49 nonaka Exp $	*/
 /*	$OpenBSD: if_hvn.c,v 1.39 2018/03/11 14:31:34 mikeb Exp $	*/
 
 /*-
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_hvn.c,v 1.19 2020/12/11 08:13:08 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_hvn.c,v 1.20 2021/01/29 04:38:49 nonaka Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1070,7 +1070,8 @@ hvn_nvs_cmd(struct hvn_softc *sc, void *
 			if (cold)
 delay(1000);
 			else
-tsleep(cmd, PRIBIO, "nvsout", mstohz(1));
+tsleep(cmd, PRIBIO, "nvsout",
+uimax(1, mstohz(1)));
 		} else if (rv) {
 			DPRINTF("%s: NVSP operation %u send error %d\n",
 			device_xname(sc->sc_dev), hdr->nvs_type, rv);
@@ -1095,7 +1096,7 @@ hvn_nvs_cmd(struct hvn_softc *sc, void *
 			splx(s);
 		} else
 			tsleep(sc->sc_nvsrsp, PRIBIO | PCATCH, "nvscmd",
-			mstohz(1));
+			uimax(1, mstohz(1)));
 	} while (--timo > 0 && sc->sc_nvsdone != 1);
 
 	if (timo == 0 && sc->sc_nvsdone != 1) {
@@ -1393,7 +1394,8 @@ hvn_rndis_cmd(struct hvn_softc *sc, stru
 			if (cold)
 delay(1000);
 			else
-tsleep(rc, PRIBIO, "rndisout", mstohz(1));
+tsleep(rc, PRIBIO, "rndisout",
+uimax(1, mstohz(1)));
 		} else if (rv) {
 			DPRINTF("%s: RNDIS operation %u send error %d\n",
 			device_xname(sc->sc_dev), hdr->rm_type, rv);
@@ -1422,7 +1424,8 @@ hvn_rndis_cmd(struct hvn_softc *sc, stru
 			hvn_nvs_intr(sc);
 			splx(s);
 		} else
-			tsleep(rc, PRIBIO | PCATCH, "rndiscmd", mstohz(1));
+			tsleep(rc, PRIBIO | PCATCH, "rndiscmd",
+			uimax(1, mstohz(1)));
 	} while (--timo > 0 && rc->rc_done != 1);
 
 	bus_dmamap_sync(sc->sc_dmat, rc->rc_dmap, 0, PAGE_SIZE,



CVS commit: src/sys/dev/hyperv

2021-01-28 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Fri Jan 29 04:38:34 UTC 2021

Modified Files:
src/sys/dev/hyperv: vmbus.c

Log Message:
vmbus(4): Don't wait forever.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/dev/hyperv/vmbus.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/dev/hyperv/vmbus.c
diff -u src/sys/dev/hyperv/vmbus.c:1.11 src/sys/dev/hyperv/vmbus.c:1.12
--- src/sys/dev/hyperv/vmbus.c:1.11	Tue May 26 16:08:55 2020
+++ src/sys/dev/hyperv/vmbus.c	Fri Jan 29 04:38:34 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: vmbus.c,v 1.11 2020/05/26 16:08:55 nonaka Exp $	*/
+/*	$NetBSD: vmbus.c,v 1.12 2021/01/29 04:38:34 nonaka Exp $	*/
 /*	$OpenBSD: hyperv.c,v 1.43 2017/06/27 13:56:15 mikeb Exp $	*/
 
 /*-
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vmbus.c,v 1.11 2020/05/26 16:08:55 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vmbus.c,v 1.12 2021/01/29 04:38:34 nonaka Exp $");
 
 #include 
 #include 
@@ -608,7 +608,8 @@ vmbus_start(struct vmbus_softc *sc, stru
 			hyperv_intr();
 			splx(s);
 		} else
-			tsleep(wchan, PRIBIO, wchan, mstohz(delays[i]));
+			tsleep(wchan, PRIBIO, wchan,
+			uimax(1, mstohz(delays[i] / 1000)));
 	}
 	if (status != HYPERCALL_STATUS_SUCCESS) {
 		device_printf(sc->sc_dev,



CVS commit: src/sys/dev/hyperv

2021-01-28 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Fri Jan 29 04:38:18 UTC 2021

Modified Files:
src/sys/dev/hyperv: hvkbd.c

Log Message:
hvkbd(4): Don't wait forever.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/hyperv/hvkbd.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/dev/hyperv/hvkbd.c
diff -u src/sys/dev/hyperv/hvkbd.c:1.6 src/sys/dev/hyperv/hvkbd.c:1.7
--- src/sys/dev/hyperv/hvkbd.c:1.6	Fri Nov 22 12:40:07 2019
+++ src/sys/dev/hyperv/hvkbd.c	Fri Jan 29 04:38:18 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: hvkbd.c,v 1.6 2019/11/22 12:40:07 nonaka Exp $	*/
+/*	$NetBSD: hvkbd.c,v 1.7 2021/01/29 04:38:18 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2017 Microsoft Corp.
@@ -36,7 +36,7 @@
 #endif /* _KERNEL_OPT */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: hvkbd.c,v 1.6 2019/11/22 12:40:07 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hvkbd.c,v 1.7 2021/01/29 04:38:18 nonaka Exp $");
 
 #include 
 #include 
@@ -350,7 +350,8 @@ hvkbd_connect(struct hvkbd_softc *sc)
 			hvkbd_intr(sc);
 			splx(s);
 		} else
-			tsleep(sc, PRIBIO | PCATCH, "hvkbdcon", mstohz(1));
+			tsleep(sc, PRIBIO | PCATCH, "hvkbdcon",
+			uimax(1, mstohz(1)));
 	} while (--timo > 0 && sc->sc_connected == 0);
 
 	if (timo == 0 && sc->sc_connected == 0) {



CVS commit: src/sys/dev/hyperv

2020-12-11 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Fri Dec 11 08:13:08 UTC 2020

Modified Files:
src/sys/dev/hyperv: if_hvn.c

Log Message:
hvn(4): fix unable to ifconfig up/down.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/dev/hyperv/if_hvn.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/dev/hyperv/if_hvn.c
diff -u src/sys/dev/hyperv/if_hvn.c:1.18 src/sys/dev/hyperv/if_hvn.c:1.19
--- src/sys/dev/hyperv/if_hvn.c:1.18	Sun May 24 10:31:59 2020
+++ src/sys/dev/hyperv/if_hvn.c	Fri Dec 11 08:13:08 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_hvn.c,v 1.18 2020/05/24 10:31:59 nonaka Exp $	*/
+/*	$NetBSD: if_hvn.c,v 1.19 2020/12/11 08:13:08 nonaka Exp $	*/
 /*	$OpenBSD: if_hvn.c,v 1.39 2018/03/11 14:31:34 mikeb Exp $	*/
 
 /*-
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_hvn.c,v 1.18 2020/05/24 10:31:59 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_hvn.c,v 1.19 2020/12/11 08:13:08 nonaka Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -387,26 +387,7 @@ hvn_ioctl(struct ifnet *ifp, u_long comm
 
 	s = splnet();
 
-	switch (command) {
-	case SIOCSIFFLAGS:
-		if (ifp->if_flags & IFF_UP) {
-			if (ifp->if_flags & IFF_RUNNING)
-error = ENETRESET;
-			else {
-error = hvn_init(ifp);
-if (error)
-	ifp->if_flags &= ~IFF_UP;
-			}
-		} else {
-			if (ifp->if_flags & IFF_RUNNING)
-hvn_stop(ifp, 1);
-		}
-		break;
-	default:
-		error = ether_ioctl(ifp, command, data);
-		break;
-	}
-
+	error = ether_ioctl(ifp, command, data);
 	if (error == ENETRESET) {
 		if (ifp->if_flags & IFF_RUNNING)
 			hvn_iff(sc);



CVS commit: src/sys/dev

2020-08-17 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Mon Aug 17 08:34:36 UTC 2020

Modified Files:
src/sys/dev: ipmi.c

Log Message:
ipmi(4): Fixed a bug that incorrect condition is notified.

When the value obtained from the sensor is below the lower limit of
the critical threshold, it is notified that the value is below the lower
limit of the warning threshold.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/ipmi.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/dev/ipmi.c
diff -u src/sys/dev/ipmi.c:1.4 src/sys/dev/ipmi.c:1.5
--- src/sys/dev/ipmi.c:1.4	Sat May 18 08:38:00 2019
+++ src/sys/dev/ipmi.c	Mon Aug 17 08:34:36 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ipmi.c,v 1.4 2019/05/18 08:38:00 mlelstv Exp $ */
+/*	$NetBSD: ipmi.c,v 1.5 2020/08/17 08:34:36 nonaka Exp $ */
 
 /*
  * Copyright (c) 2019 Michael van Elst
@@ -76,7 +76,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ipmi.c,v 1.4 2019/05/18 08:38:00 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ipmi.c,v 1.5 2020/08/17 08:34:36 nonaka Exp $");
 
 #include 
 #include 
@@ -1632,14 +1632,14 @@ ipmi_sensor_status(struct ipmi_softc *sc
 		edata->value_cur > psensor->i_limits.sel_warnmax)
 			return ENVSYS_SWARNOVER;
 
-		if (psensor->i_props & PROP_WARNMIN &&
-		edata->value_cur < psensor->i_limits.sel_warnmin)
-			return ENVSYS_SWARNUNDER;
-
 		if (psensor->i_props & PROP_CRITMIN &&
 		edata->value_cur < psensor->i_limits.sel_critmin)
 			return ENVSYS_SCRITUNDER;
 
+		if (psensor->i_props & PROP_WARNMIN &&
+		edata->value_cur < psensor->i_limits.sel_warnmin)
+			return ENVSYS_SWARNUNDER;
+
 		break;
 
 	case IPMI_SENSOR_TYPE_INTRUSION:



CVS commit: src/sys/dev/hyperv

2020-05-26 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Tue May 26 16:08:55 UTC 2020

Modified Files:
src/sys/dev/hyperv: vmbus.c vmbusvar.h

Log Message:
vmbus(4): Do not call hyperv_dma_alloc() in interrupt context.

The channel offer and rescind process is performed on another context.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/hyperv/vmbus.c
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/hyperv/vmbusvar.h

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

Modified files:

Index: src/sys/dev/hyperv/vmbus.c
diff -u src/sys/dev/hyperv/vmbus.c:1.10 src/sys/dev/hyperv/vmbus.c:1.11
--- src/sys/dev/hyperv/vmbus.c:1.10	Tue May 26 16:00:06 2020
+++ src/sys/dev/hyperv/vmbus.c	Tue May 26 16:08:55 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: vmbus.c,v 1.10 2020/05/26 16:00:06 nonaka Exp $	*/
+/*	$NetBSD: vmbus.c,v 1.11 2020/05/26 16:08:55 nonaka Exp $	*/
 /*	$OpenBSD: hyperv.c,v 1.43 2017/06/27 13:56:15 mikeb Exp $	*/
 
 /*-
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vmbus.c,v 1.10 2020/05/26 16:00:06 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vmbus.c,v 1.11 2020/05/26 16:08:55 nonaka Exp $");
 
 #include 
 #include 
@@ -103,10 +103,14 @@ static void	vmbus_channel_detach(struct 
 static void	vmbus_channel_pause(struct vmbus_channel *);
 static uint32_t	vmbus_channel_unpause(struct vmbus_channel *);
 static uint32_t	vmbus_channel_ready(struct vmbus_channel *);
+static void	vmbus_chevq_enqueue(struct vmbus_softc *, int, void *);
+static void	vmbus_process_chevq(void *);
+static void	vmbus_chevq_thread(void *);
 static void	vmbus_devq_enqueue(struct vmbus_softc *, int,
 		struct vmbus_channel *);
 static void	vmbus_process_devq(void *);
 static void	vmbus_devq_thread(void *);
+static void	vmbus_subchannel_devq_thread(void *);
 
 static struct vmbus_softc *vmbus_sc;
 
@@ -841,15 +845,33 @@ vmbus_channel_response(struct vmbus_soft
 static void
 vmbus_channel_offer(struct vmbus_softc *sc, struct vmbus_chanmsg_hdr *hdr)
 {
+	struct vmbus_chanmsg_choffer *co;
 
-	vmbus_process_offer(sc, (struct vmbus_chanmsg_choffer *)hdr);
+	co = kmem_intr_alloc(sizeof(*co), KM_NOSLEEP);
+	if (co == NULL) {
+		device_printf(sc->sc_dev,
+		"failed to allocate an offer object\n");
+		return;
+	}
+
+	memcpy(co, hdr, sizeof(*co));
+	vmbus_chevq_enqueue(sc, VMBUS_CHEV_TYPE_OFFER, co);
 }
 
 static void
 vmbus_channel_rescind(struct vmbus_softc *sc, struct vmbus_chanmsg_hdr *hdr)
 {
+	struct vmbus_chanmsg_chrescind *cr;
+ 
+	cr = kmem_intr_alloc(sizeof(*cr), KM_NOSLEEP);
+	if (cr == NULL) {
+		device_printf(sc->sc_dev,
+		"failed to allocate an rescind object\n");
+		return;
+	}
 
-	vmbus_process_rescind(sc, (struct vmbus_chanmsg_chrescind *)hdr);
+	memcpy(cr, hdr, sizeof(*cr));
+	vmbus_chevq_enqueue(sc, VMBUS_CHEV_TYPE_RESCIND, cr);
 }
 
 static void
@@ -906,16 +928,48 @@ vmbus_channel_scan(struct vmbus_softc *s
 	struct vmbus_chanmsg_hdr hdr;
 	struct vmbus_chanmsg_choffer rsp;
 
+	TAILQ_INIT(>sc_prichans);
+	mutex_init(>sc_prichan_lock, MUTEX_DEFAULT, IPL_NET);
 	TAILQ_INIT(>sc_channels);
 	mutex_init(>sc_channel_lock, MUTEX_DEFAULT, IPL_NET);
 
+	/*
+	 * This queue serializes vmbus channel offer and rescind messages.
+	 */
+	SIMPLEQ_INIT(>sc_chevq);
+	mutex_init(>sc_chevq_lock, MUTEX_DEFAULT, IPL_NET);
+	cv_init(>sc_chevq_cv, "hvchevcv");
+	if (kthread_create(PRI_NONE, KTHREAD_MPSAFE, NULL,
+	vmbus_chevq_thread, sc, NULL, "hvchevq") != 0) {
+		DPRINTF("%s: failed to create prich chevq thread\n",
+		device_xname(sc->sc_dev));
+		return -1;
+	}
+
+	/*
+	 * This queue serializes vmbus devices' attach and detach
+	 * for channel offer and rescind messages.
+	 */
 	SIMPLEQ_INIT(>sc_devq);
 	mutex_init(>sc_devq_lock, MUTEX_DEFAULT, IPL_NET);
 	cv_init(>sc_devq_cv, "hvdevqcv");
+	if (kthread_create(PRI_NONE, KTHREAD_MPSAFE, NULL,
+	vmbus_devq_thread, sc, NULL, "hvdevq") != 0) {
+		DPRINTF("%s: failed to create prich devq thread\n",
+		device_xname(sc->sc_dev));
+		return -1;
+	}
 
+	/*
+	 * This queue handles sub-channel detach, so that vmbus
+	 * device's detach running in sc_devq can drain its sub-channels.
+	 */
+	SIMPLEQ_INIT(>sc_subch_devq);
+	mutex_init(>sc_subch_devq_lock, MUTEX_DEFAULT, IPL_NET);
+	cv_init(>sc_subch_devq_cv, "hvsdvqcv");
 	if (kthread_create(PRI_NONE, KTHREAD_MPSAFE, NULL,
-	vmbus_devq_thread, sc, NULL, "hvoffer") != 0) {
-		DPRINTF("%s: failed to create offer thread\n",
+	vmbus_subchannel_devq_thread, sc, NULL, "hvsdevq") != 0) {
+		DPRINTF("%s: failed to create subch devq thread\n",
 		device_xname(sc->sc_dev));
 		return -1;
 	}
@@ -932,6 +986,9 @@ vmbus_channel_scan(struct vmbus_softc *s
 	while (!ISSET(sc->sc_flags, VMBUS_SCFLAG_OFFERS_DELIVERED))
 		tsleep(>sc_devq, PRIBIO, "hvscan", 1);
 
+	mutex_enter(>sc_chevq_lock);
+	vmbus_process_chevq(sc);
+	mutex_exit(>sc_chevq_lock);
 	mutex_enter(>sc_devq_lock);
 	vmbus_process_devq(sc);
 	mutex_exit(>sc_devq_lock);
@@ 

CVS commit: src/sys/dev/hyperv

2020-05-26 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Tue May 26 16:00:06 UTC 2020

Modified Files:
src/sys/dev/hyperv: vmbus.c

Log Message:
vmbus(4): Fixed incorrect use of vmbus_wait() in vmbus_channel_scan().

Found by kUBSan.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/hyperv/vmbus.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/dev/hyperv/vmbus.c
diff -u src/sys/dev/hyperv/vmbus.c:1.9 src/sys/dev/hyperv/vmbus.c:1.10
--- src/sys/dev/hyperv/vmbus.c:1.9	Mon May 25 10:14:58 2020
+++ src/sys/dev/hyperv/vmbus.c	Tue May 26 16:00:06 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: vmbus.c,v 1.9 2020/05/25 10:14:58 nonaka Exp $	*/
+/*	$NetBSD: vmbus.c,v 1.10 2020/05/26 16:00:06 nonaka Exp $	*/
 /*	$OpenBSD: hyperv.c,v 1.43 2017/06/27 13:56:15 mikeb Exp $	*/
 
 /*-
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vmbus.c,v 1.9 2020/05/25 10:14:58 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vmbus.c,v 1.10 2020/05/26 16:00:06 nonaka Exp $");
 
 #include 
 #include 
@@ -76,9 +76,6 @@ static int	vmbus_cmd(struct vmbus_softc 
 		int);
 static int	vmbus_start(struct vmbus_softc *, struct vmbus_msg *, paddr_t);
 static int	vmbus_reply(struct vmbus_softc *, struct vmbus_msg *);
-static void	vmbus_wait(struct vmbus_softc *,
-		int (*done)(struct vmbus_softc *, struct vmbus_msg *),
-		struct vmbus_msg *, void *, const char *);
 static uint16_t vmbus_intr_signal(struct vmbus_softc *, paddr_t);
 static void	vmbus_event_proc(void *, struct cpu_info *);
 static void	vmbus_event_proc_compat(void *, struct cpu_info *);
@@ -642,36 +639,26 @@ vmbus_reply_done(struct vmbus_softc *sc,
 static int
 vmbus_reply(struct vmbus_softc *sc, struct vmbus_msg *msg)
 {
+	int s;
 
 	if (msg->msg_flags & MSGF_NOQUEUE)
 		return 0;
 
-	vmbus_wait(sc, vmbus_reply_done, msg, msg, "hvreply");
-
-	mutex_enter(>sc_rsp_lock);
-	TAILQ_REMOVE(>sc_rsps, msg, msg_entry);
-	mutex_exit(>sc_rsp_lock);
-
-	return 0;
-}
-
-static void
-vmbus_wait(struct vmbus_softc *sc,
-int (*cond)(struct vmbus_softc *, struct vmbus_msg *),
-struct vmbus_msg *msg, void *wchan, const char *wmsg)
-{
-	int s;
-
-	while (!cond(sc, msg)) {
+	while (!vmbus_reply_done(sc, msg)) {
 		if (msg->msg_flags & MSGF_NOSLEEP) {
 			delay(1000);
 			s = splnet();
 			hyperv_intr();
 			splx(s);
 		} else
-			tsleep(wchan, PRIBIO, wmsg ? wmsg : "hvwait",
-			mstohz(1));
+			tsleep(msg, PRIBIO, "hvreply", 1);
 	}
+
+	mutex_enter(>sc_rsp_lock);
+	TAILQ_REMOVE(>sc_rsps, msg, msg_entry);
+	mutex_exit(>sc_rsp_lock);
+
+	return 0;
 }
 
 static uint16_t
@@ -914,13 +901,6 @@ hyperv_guid_sprint(struct hyperv_guid *g
 }
 
 static int
-vmbus_channel_scan_done(struct vmbus_softc *sc, struct vmbus_msg *msg __unused)
-{
-
-	return ISSET(sc->sc_flags, VMBUS_SCFLAG_OFFERS_DELIVERED);
-}
-
-static int
 vmbus_channel_scan(struct vmbus_softc *sc)
 {
 	struct vmbus_chanmsg_hdr hdr;
@@ -949,8 +929,8 @@ vmbus_channel_scan(struct vmbus_softc *s
 		return -1;
 	}
 
-	vmbus_wait(sc, vmbus_channel_scan_done, (struct vmbus_msg *),
-	>sc_devq, "hvscan");
+	while (!ISSET(sc->sc_flags, VMBUS_SCFLAG_OFFERS_DELIVERED))
+		tsleep(>sc_devq, PRIBIO, "hvscan", 1);
 
 	mutex_enter(>sc_devq_lock);
 	vmbus_process_devq(sc);



CVS commit: src/sys/dev/hyperv

2020-05-25 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Mon May 25 10:14:58 UTC 2020

Modified Files:
src/sys/dev/hyperv: hvs.c vmbus.c

Log Message:
Use howmany() macro.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/hyperv/hvs.c
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/hyperv/vmbus.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/dev/hyperv/hvs.c
diff -u src/sys/dev/hyperv/hvs.c:1.3 src/sys/dev/hyperv/hvs.c:1.4
--- src/sys/dev/hyperv/hvs.c:1.3	Mon Nov 25 08:53:39 2019
+++ src/sys/dev/hyperv/hvs.c	Mon May 25 10:14:58 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: hvs.c,v 1.3 2019/11/25 08:53:39 nonaka Exp $	*/
+/*	$NetBSD: hvs.c,v 1.4 2020/05/25 10:14:58 nonaka Exp $	*/
 /*	$OpenBSD: hvs.c,v 1.17 2017/08/10 17:22:48 mikeb Exp $	*/
 
 /*-
@@ -37,7 +37,7 @@
 /* #define HVS_DEBUG_IO */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: hvs.c,v 1.3 2019/11/25 08:53:39 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hvs.c,v 1.4 2020/05/25 10:14:58 nonaka Exp $");
 
 #include 
 #include 
@@ -180,7 +180,7 @@ union hvs_cmd {
 
 #define HVS_RING_SIZE			(20 * PAGE_SIZE)
 #define HVS_MAX_CCB			128
-#define HVS_MAX_SGE			(MAXPHYS / PAGE_SIZE + 1)
+#define HVS_MAX_SGE			(howmany(MAXPHYS, PAGE_SIZE) + 1)
 
 struct hvs_softc;
 

Index: src/sys/dev/hyperv/vmbus.c
diff -u src/sys/dev/hyperv/vmbus.c:1.8 src/sys/dev/hyperv/vmbus.c:1.9
--- src/sys/dev/hyperv/vmbus.c:1.8	Tue Dec 10 12:20:20 2019
+++ src/sys/dev/hyperv/vmbus.c	Mon May 25 10:14:58 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: vmbus.c,v 1.8 2019/12/10 12:20:20 nonaka Exp $	*/
+/*	$NetBSD: vmbus.c,v 1.9 2020/05/25 10:14:58 nonaka Exp $	*/
 /*	$OpenBSD: hyperv.c,v 1.43 2017/06/27 13:56:15 mikeb Exp $	*/
 
 /*-
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vmbus.c,v 1.8 2019/12/10 12:20:20 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vmbus.c,v 1.9 2020/05/25 10:14:58 nonaka Exp $");
 
 #include 
 #include 
@@ -1911,7 +1911,7 @@ vmbus_handle_alloc(struct vmbus_channel 
 
 	/* Allocate additional gpadl_body structures if required */
 	if (left > 0) {
-		ncmds = MAX(1, left / VMBUS_NPFNBODY + left % VMBUS_NPFNBODY);
+		ncmds = howmany(left, VMBUS_NPFNBODY);
 		bodylen = ncmds * VMBUS_MSG_DSIZE_MAX;
 		body = kmem_zalloc(bodylen, kmemflags);
 		if (body == NULL) {



CVS commit: src/sys/dev/hyperv

2020-05-24 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Sun May 24 10:32:00 UTC 2020

Modified Files:
src/sys/dev/hyperv: if_hvn.c

Log Message:
hvn(4): Prevent from occur panic when acquiring the media status.

hvn(4) sleeps during hvn_media_status(), and thus requires an adaptive mutex
for the media lock.  Taken from recent iwm(4) change.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/dev/hyperv/if_hvn.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/dev/hyperv/if_hvn.c
diff -u src/sys/dev/hyperv/if_hvn.c:1.17 src/sys/dev/hyperv/if_hvn.c:1.18
--- src/sys/dev/hyperv/if_hvn.c:1.17	Tue Feb  4 05:25:38 2020
+++ src/sys/dev/hyperv/if_hvn.c	Sun May 24 10:31:59 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_hvn.c,v 1.17 2020/02/04 05:25:38 thorpej Exp $	*/
+/*	$NetBSD: if_hvn.c,v 1.18 2020/05/24 10:31:59 nonaka Exp $	*/
 /*	$OpenBSD: if_hvn.c,v 1.39 2018/03/11 14:31:34 mikeb Exp $	*/
 
 /*-
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_hvn.c,v 1.17 2020/02/04 05:25:38 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_hvn.c,v 1.18 2020/05/24 10:31:59 nonaka Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -133,6 +133,7 @@ struct hvn_softc {
 
 	struct ethercom			sc_ec;
 	struct ifmedia			sc_media;
+	kmutex_t			sc_media_lock;	/* XXX */
 	struct if_percpuq		*sc_ipq;
 	intsc_link_state;
 	intsc_promisc;
@@ -294,8 +295,10 @@ hvn_attach(device_t parent, device_t sel
 
 	/* Initialize ifmedia structures. */
 	sc->sc_ec.ec_ifmedia = >sc_media;
-	ifmedia_init(>sc_media, IFM_IMASK, hvn_media_change,
-	hvn_media_status);
+	/* XXX media locking needs revisiting */
+	mutex_init(>sc_media_lock, MUTEX_DEFAULT, IPL_SOFTNET);
+	ifmedia_init_with_lock(>sc_media, IFM_IMASK,
+	hvn_media_change, hvn_media_status, >sc_media_lock);
 	ifmedia_add(>sc_media, IFM_ETHER | IFM_MANUAL, 0, NULL);
 	ifmedia_set(>sc_media, IFM_ETHER | IFM_MANUAL);
 
@@ -341,7 +344,9 @@ hvn_attach(device_t parent, device_t sel
 
 fail4:	hvn_rndis_detach(sc);
 	if_percpuq_destroy(sc->sc_ipq);
-fail3:	hvn_tx_ring_destroy(sc);
+fail3:	ifmedia_fini(>sc_media);
+	mutex_destroy(>sc_media_lock);
+	hvn_tx_ring_destroy(sc);
 fail2:	hvn_rx_ring_destroy(sc);
 fail1:	hvn_nvs_detach(sc);
 }
@@ -363,6 +368,7 @@ hvn_detach(device_t self, int flags)
 	ether_ifdetach(ifp);
 	if_detach(ifp);
 	ifmedia_fini(>sc_media);
+	mutex_destroy(>sc_media_lock);
 	if_percpuq_destroy(sc->sc_ipq);
 
 	hvn_rndis_detach(sc);



CVS commit: src/sys/arch/x86/x86

2020-05-17 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Sun May 17 11:54:40 UTC 2020

Modified Files:
src/sys/arch/x86/x86: hyperv.c

Log Message:
Fixed a problem that caused a page fault when attaching vmbus(4).

Dynamically allocate a page of memory with uvm_km_alloc(kernel_map, ...)
for Hyper-V hypercall.  However, this method can no longer be used to
make an executable page.
So we prevent it by using statically allocated memory for text segment.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/x86/x86/hyperv.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/x86/hyperv.c
diff -u src/sys/arch/x86/x86/hyperv.c:1.8 src/sys/arch/x86/x86/hyperv.c:1.9
--- src/sys/arch/x86/x86/hyperv.c:1.8	Sat Apr 25 15:26:18 2020
+++ src/sys/arch/x86/x86/hyperv.c	Sun May 17 11:54:39 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: hyperv.c,v 1.8 2020/04/25 15:26:18 bouyer Exp $	*/
+/*	$NetBSD: hyperv.c,v 1.9 2020/05/17 11:54:39 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2009-2012,2016-2017 Microsoft Corp.
@@ -33,7 +33,7 @@
  */
 #include 
 #ifdef __KERNEL_RCSID
-__KERNEL_RCSID(0, "$NetBSD: hyperv.c,v 1.8 2020/04/25 15:26:18 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hyperv.c,v 1.9 2020/05/17 11:54:39 nonaka Exp $");
 #endif
 #ifdef __FBSDID
 __FBSDID("$FreeBSD: head/sys/dev/hyperv/vmbus/hyperv.c 331757 2018-03-30 02:25:12Z emaste $");
@@ -97,6 +97,9 @@ struct hyperv_hypercall_ctx {
 
 static struct hyperv_hypercall_ctx hyperv_hypercall_ctx;
 
+static char hyperv_hypercall_page[PAGE_SIZE]
+__section(".text") __aligned(PAGE_SIZE) = { 0xcc };
+
 static u_int	hyperv_get_timecount(struct timecounter *);
 
 static u_int hyperv_ver_major;
@@ -703,11 +706,7 @@ static void
 hyperv_hypercall_memfree(void)
 {
 
-	if (hyperv_hypercall_ctx.hc_addr != NULL) {
-		uvm_km_free(kernel_map, (vaddr_t)hyperv_hypercall_ctx.hc_addr,
-		PAGE_SIZE, UVM_KMF_WIRED);
-		hyperv_hypercall_ctx.hc_addr = NULL;
-	}
+	hyperv_hypercall_ctx.hc_addr = NULL;
 }
 
 static bool
@@ -715,30 +714,9 @@ hyperv_init_hypercall(void)
 {
 	uint64_t hc, hc_orig;
 
-	hyperv_hypercall_ctx.hc_addr = (void *)uvm_km_alloc(kernel_map,
-	PAGE_SIZE, PAGE_SIZE,
-	UVM_KMF_WIRED | UVM_KMF_EXEC | (cold ? UVM_KMF_NOWAIT : 0));
-	if (hyperv_hypercall_ctx.hc_addr == NULL) {
-		aprint_error("Hyper-V: Hypercall page allocation failed\n");
-		return false;
-	}
-
-	memset(hyperv_hypercall_ctx.hc_addr, 0xcc, PAGE_SIZE);
-	wbinvd();
-	x86_flush();
-
-	/* The hypercall page must be both readable and executable */
-	uvm_km_protect(kernel_map, (vaddr_t)hyperv_hypercall_ctx.hc_addr,
-	PAGE_SIZE, VM_PROT_READ | VM_PROT_EXECUTE);
-
-	if (!pmap_extract(pmap_kernel(), (vaddr_t)hyperv_hypercall_ctx.hc_addr,
-	_hypercall_ctx.hc_paddr)) {
-		aprint_error("Hyper-V: Hypercall page setup failed\n");
-		hyperv_hypercall_memfree();
-		/* Can't perform any Hyper-V specific actions */
-		vm_guest = VM_GUEST_VM;
-		return false;
-	}
+	hyperv_hypercall_ctx.hc_addr = hyperv_hypercall_page;
+	hyperv_hypercall_ctx.hc_paddr = vtophys((vaddr_t)hyperv_hypercall_page);
+	KASSERT(hyperv_hypercall_ctx.hc_paddr != 0);
 
 	/* Get the 'reserved' bits, which requires preservation. */
 	hc_orig = rdmsr(MSR_HV_HYPERCALL);



CVS commit: src/sys/arch/i386/stand/efiboot

2020-01-18 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Sat Jan 18 19:25:58 UTC 2020

Modified Files:
src/sys/arch/i386/stand/efiboot: devopen.c

Log Message:
x86 efiboot: Fixed the problem that /EFI/NetBSD/boot.cfg could not be loaded.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/i386/stand/efiboot/devopen.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/i386/stand/efiboot/devopen.c
diff -u src/sys/arch/i386/stand/efiboot/devopen.c:1.10 src/sys/arch/i386/stand/efiboot/devopen.c:1.11
--- src/sys/arch/i386/stand/efiboot/devopen.c:1.10	Sat Jan 18 19:20:23 2020
+++ src/sys/arch/i386/stand/efiboot/devopen.c	Sat Jan 18 19:25:58 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: devopen.c,v 1.10 2020/01/18 19:20:23 nonaka Exp $	 */
+/*	$NetBSD: devopen.c,v 1.11 2020/01/18 19:25:58 nonaka Exp $	 */
 
 /*-
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -100,7 +100,7 @@ bios2dev(int biosdev, daddr_t sector, ch
 		*devname = "hd";
 
 	(void)biosdisk_findpartition(biosdev, sector, partition, part_name);
-	if (*part_name != NULL) {
+	if (part_name != NULL && *part_name != NULL) {
 		snprintf(savedevname, sizeof(savedevname),
 		"NAME=%s", *part_name);
 		*devname = savedevname;



CVS commit: src/sys/arch/i386/stand/efiboot

2020-01-18 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Sat Jan 18 19:20:23 UTC 2020

Modified Files:
src/sys/arch/i386/stand/efiboot: devopen.c

Log Message:
fix indent.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/i386/stand/efiboot/devopen.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/i386/stand/efiboot/devopen.c
diff -u src/sys/arch/i386/stand/efiboot/devopen.c:1.9 src/sys/arch/i386/stand/efiboot/devopen.c:1.10
--- src/sys/arch/i386/stand/efiboot/devopen.c:1.9	Tue Dec 10 02:02:47 2019
+++ src/sys/arch/i386/stand/efiboot/devopen.c	Sat Jan 18 19:20:23 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: devopen.c,v 1.9 2019/12/10 02:02:47 manu Exp $	 */
+/*	$NetBSD: devopen.c,v 1.10 2020/01/18 19:20:23 nonaka Exp $	 */
 
 /*-
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -103,7 +103,7 @@ bios2dev(int biosdev, daddr_t sector, ch
 	if (*part_name != NULL) {
 		snprintf(savedevname, sizeof(savedevname),
 		"NAME=%s", *part_name);
-			*devname = savedevname;
+		*devname = savedevname;
 	}
 }
 



CVS commit: src/sys/dev/ic

2020-01-07 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Wed Jan  8 04:53:38 UTC 2020

Modified Files:
src/sys/dev/ic: rndisreg.h

Log Message:
Added some RNDIS status definitions from FreeBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/ic/rndisreg.h

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

Modified files:

Index: src/sys/dev/ic/rndisreg.h
diff -u src/sys/dev/ic/rndisreg.h:1.4 src/sys/dev/ic/rndisreg.h:1.5
--- src/sys/dev/ic/rndisreg.h:1.4	Fri Dec  6 12:41:17 2019
+++ src/sys/dev/ic/rndisreg.h	Wed Jan  8 04:53:38 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: rndisreg.h,v 1.4 2019/12/06 12:41:17 nonaka Exp $ */
+/*	$NetBSD: rndisreg.h,v 1.5 2020/01/08 04:53:38 nonaka Exp $ */
 /*	NetBSD: if_urndisreg.h,v 1.4 2018/11/09 21:57:09 maya Exp */
 /*	$OpenBSD: if_urndisreg.h,v 1.14 2010/07/08 18:22:01 ckuethe Exp $ */
 
@@ -32,6 +32,8 @@
 #define RNDIS_STATUS_PENDING		0x0103L
 #define RNDIS_STATUS_MEDIA_CONNECT	0x4001000BL
 #define RNDIS_STATUS_MEDIA_DISCONNECT	0x4001000CL
+#define RNDIS_STATUS_LINK_SPEED_CHANGE	0x40010013L
+#define RNDIS_STATUS_NETWORK_CHANGE	0x40010018L
 #define RNDIS_STATUS_OFFLOAD_CURRENT_CONFIG	0x40020006
 #define RNDIS_STATUS_BUFFER_OVERFLOW	0x8005L
 #define RNDIS_STATUS_FAILURE		0xC001L



CVS commit: src/sys/dev/hyperv

2019-12-26 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Fri Dec 27 05:59:53 UTC 2019

Modified Files:
src/sys/dev/hyperv: if_hvn.c

Log Message:
hvn(4): Handle CFI field of VLAN.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/hyperv/if_hvn.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/dev/hyperv/if_hvn.c
diff -u src/sys/dev/hyperv/if_hvn.c:1.14 src/sys/dev/hyperv/if_hvn.c:1.15
--- src/sys/dev/hyperv/if_hvn.c:1.14	Fri Dec 27 05:56:42 2019
+++ src/sys/dev/hyperv/if_hvn.c	Fri Dec 27 05:59:53 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_hvn.c,v 1.14 2019/12/27 05:56:42 nonaka Exp $	*/
+/*	$NetBSD: if_hvn.c,v 1.15 2019/12/27 05:59:53 nonaka Exp $	*/
 /*	$OpenBSD: if_hvn.c,v 1.39 2018/03/11 14:31:34 mikeb Exp $	*/
 
 /*-
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_hvn.c,v 1.14 2019/12/27 05:56:42 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_hvn.c,v 1.15 2019/12/27 05:59:53 nonaka Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -67,6 +67,9 @@ __KERNEL_RCSID(0, "$NetBSD: if_hvn.c,v 1
 #ifndef EVL_PRIO_BITS
 #define EVL_PRIO_BITS	13
 #endif
+#ifndef EVL_CFI_BITS
+#define EVL_CFI_BITS	12
+#endif
 
 #define HVN_NVS_MSGSIZE			32
 #define HVN_NVS_BUFSIZE			PAGE_SIZE
@@ -584,7 +587,7 @@ hvn_encap(struct hvn_softc *sc, struct m
 
 		tag = vlan_get_tag(m);
 		vlan = NDIS_VLAN_INFO_MAKE(EVL_VLANOFTAG(tag),
-		EVL_PRIOFTAG(tag), 0);
+		EVL_PRIOFTAG(tag), EVL_CFIOFTAG(tag));
 		cp = hvn_rndis_pktinfo_append(pkt, HVN_RNDIS_PKT_LEN,
 		NDIS_VLAN_INFO_SIZE, NDIS_PKTINFO_TYPE_VLAN);
 		memcpy(cp, , NDIS_VLAN_INFO_SIZE);
@@ -1593,6 +1596,7 @@ hvn_rxeof(struct hvn_softc *sc, uint8_t 
 			if (vlan != 0x) {
 uint16_t t = NDIS_VLAN_INFO_ID(vlan);
 t |= NDIS_VLAN_INFO_PRI(vlan) << EVL_PRIO_BITS;
+t |= NDIS_VLAN_INFO_CFI(vlan) << EVL_CFI_BITS;
 vlan_set_tag(m, t);
 			}
 			break;



CVS commit: src/sys/dev/hyperv

2019-12-26 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Fri Dec 27 05:56:42 UTC 2019

Modified Files:
src/sys/dev/hyperv: if_hvn.c

Log Message:
hvn(4): Use vlan_{get,set,has}_tag().


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/dev/hyperv/if_hvn.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/dev/hyperv/if_hvn.c
diff -u src/sys/dev/hyperv/if_hvn.c:1.13 src/sys/dev/hyperv/if_hvn.c:1.14
--- src/sys/dev/hyperv/if_hvn.c:1.13	Tue Dec 10 12:20:20 2019
+++ src/sys/dev/hyperv/if_hvn.c	Fri Dec 27 05:56:42 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_hvn.c,v 1.13 2019/12/10 12:20:20 nonaka Exp $	*/
+/*	$NetBSD: if_hvn.c,v 1.14 2019/12/27 05:56:42 nonaka Exp $	*/
 /*	$OpenBSD: if_hvn.c,v 1.39 2018/03/11 14:31:34 mikeb Exp $	*/
 
 /*-
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_hvn.c,v 1.13 2019/12/10 12:20:20 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_hvn.c,v 1.14 2019/12/27 05:56:42 nonaka Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -577,13 +577,14 @@ hvn_encap(struct hvn_softc *sc, struct m
 	}
 	txd->txd_buf = m;
 
-	if (m->m_flags & M_VLANTAG) {
+	if (vlan_has_tag(m)) {
 		uint32_t vlan;
 		char *cp;
+		uint16_t tag;
 
-		vlan = NDIS_VLAN_INFO_MAKE(
-		EVL_VLANOFTAG(m->m_pkthdr.ether_vtag),
-		EVL_PRIOFTAG(m->m_pkthdr.ether_vtag), 0);
+		tag = vlan_get_tag(m);
+		vlan = NDIS_VLAN_INFO_MAKE(EVL_VLANOFTAG(tag),
+		EVL_PRIOFTAG(tag), 0);
 		cp = hvn_rndis_pktinfo_append(pkt, HVN_RNDIS_PKT_LEN,
 		NDIS_VLAN_INFO_SIZE, NDIS_PKTINFO_TYPE_VLAN);
 		memcpy(cp, , NDIS_VLAN_INFO_SIZE);
@@ -1590,10 +1591,9 @@ hvn_rxeof(struct hvn_softc *sc, uint8_t 
 		case NDIS_PKTINFO_TYPE_VLAN:
 			memcpy(, pi->rm_data, sizeof(vlan));
 			if (vlan != 0x) {
-m->m_pkthdr.ether_vtag =
-NDIS_VLAN_INFO_ID(vlan) |
-(NDIS_VLAN_INFO_PRI(vlan) << EVL_PRIO_BITS);
-m->m_flags |= M_VLANTAG;
+uint16_t t = NDIS_VLAN_INFO_ID(vlan);
+t |= NDIS_VLAN_INFO_PRI(vlan) << EVL_PRIO_BITS;
+vlan_set_tag(m, t);
 			}
 			break;
 		default:



CVS commit: src/sys/dev/hyperv

2019-12-10 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Tue Dec 10 12:20:20 UTC 2019

Modified Files:
src/sys/dev/hyperv: hyperv_common.c hypervvar.h if_hvn.c vmbus.c
vmbusvar.h

Log Message:
hvn(4) can be added and deleted dynamically.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/hyperv/hyperv_common.c
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/hyperv/hypervvar.h \
src/sys/dev/hyperv/vmbusvar.h
cvs rdiff -u -r1.12 -r1.13 src/sys/dev/hyperv/if_hvn.c
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/hyperv/vmbus.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/dev/hyperv/hyperv_common.c
diff -u src/sys/dev/hyperv/hyperv_common.c:1.4 src/sys/dev/hyperv/hyperv_common.c:1.5
--- src/sys/dev/hyperv/hyperv_common.c:1.4	Sat Dec  7 11:45:45 2019
+++ src/sys/dev/hyperv/hyperv_common.c	Tue Dec 10 12:20:20 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: hyperv_common.c,v 1.4 2019/12/07 11:45:45 nonaka Exp $	*/
+/*	$NetBSD: hyperv_common.c,v 1.5 2019/12/10 12:20:20 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2009-2012,2016-2017 Microsoft Corp.
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: hyperv_common.c,v 1.4 2019/12/07 11:45:45 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hyperv_common.c,v 1.5 2019/12/10 12:20:20 nonaka Exp $");
 
 #include "hyperv.h"
 
@@ -111,17 +111,18 @@ hyperv_guid2str(const struct hyperv_guid
  */
 void *
 hyperv_dma_alloc(bus_dma_tag_t dmat, struct hyperv_dma *dma, bus_size_t size,
-bus_size_t alignment, bus_size_t boundary, int nsegs)
+bus_size_t alignment, bus_size_t boundary, int nsegs, int flags)
 {
-	const int kmemflags = cold ? KM_NOSLEEP : KM_SLEEP;
-	const int dmaflags = cold ? BUS_DMA_NOWAIT : BUS_DMA_WAITOK;
+	const int waitok = (flags & HYPERV_DMA_NOSLEEP) != HYPERV_DMA_NOSLEEP;
+	const int kmemflags = waitok ? KM_SLEEP: KM_NOSLEEP;
+	const int dmaflags = waitok ? BUS_DMA_WAITOK : BUS_DMA_NOWAIT;
 	int rseg, error;
 
 	KASSERT(dma != NULL);
 	KASSERT(dma->segs == NULL);
 	KASSERT(nsegs > 0);
 
-	dma->segs = kmem_zalloc(sizeof(*dma->segs) * nsegs, kmemflags);
+	dma->segs = kmem_intr_zalloc(sizeof(*dma->segs) * nsegs, kmemflags);
 	if (dma->segs == NULL)
 		return NULL;
 

Index: src/sys/dev/hyperv/hypervvar.h
diff -u src/sys/dev/hyperv/hypervvar.h:1.3 src/sys/dev/hyperv/hypervvar.h:1.4
--- src/sys/dev/hyperv/hypervvar.h:1.3	Sat Dec  7 11:45:45 2019
+++ src/sys/dev/hyperv/hypervvar.h	Tue Dec 10 12:20:20 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: hypervvar.h,v 1.3 2019/12/07 11:45:45 nonaka Exp $	*/
+/*	$NetBSD: hypervvar.h,v 1.4 2019/12/10 12:20:20 nonaka Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -108,8 +108,10 @@ hyperv_dma_get_paddr(struct hyperv_dma *
 	return dma->map->dm_segs[0].ds_addr;
 }
 
+#define HYPERV_DMA_SLEEPOK	0
+#define HYPERV_DMA_NOSLEEP	__BIT(0)
 void *hyperv_dma_alloc(bus_dma_tag_t, struct hyperv_dma *, bus_size_t,
-bus_size_t, bus_size_t, int);
+bus_size_t, bus_size_t, int, int);
 void hyperv_dma_free(bus_dma_tag_t, struct hyperv_dma *);
 
 #endif	/* _KERNEL */
Index: src/sys/dev/hyperv/vmbusvar.h
diff -u src/sys/dev/hyperv/vmbusvar.h:1.3 src/sys/dev/hyperv/vmbusvar.h:1.4
--- src/sys/dev/hyperv/vmbusvar.h:1.3	Sat Dec  7 11:45:45 2019
+++ src/sys/dev/hyperv/vmbusvar.h	Tue Dec 10 12:20:20 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: vmbusvar.h,v 1.3 2019/12/07 11:45:45 nonaka Exp $	*/
+/*	$NetBSD: vmbusvar.h,v 1.4 2019/12/10 12:20:20 nonaka Exp $	*/
 /*	$OpenBSD: hypervvar.h,v 1.13 2017/06/23 19:05:42 mikeb Exp $	*/
 
 /*
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -43,6 +44,7 @@
 typedef void (*vmbus_channel_callback_t)(void *);
 
 struct vmbus_softc;
+struct vmbus_channel;
 
 struct vmbus_msg {
 	uint64_t			msg_flags;
@@ -57,11 +59,14 @@ struct vmbus_msg {
 __CTASSERT((offsetof(struct vmbus_msg, msg_req) % 8) == 0);
 TAILQ_HEAD(vmbus_queue, vmbus_msg);
 
-struct vmbus_offer {
-	struct vmbus_chanmsg_choffer	co_chan;
-	SIMPLEQ_ENTRY(vmbus_offer)	co_entry;
+struct vmbus_dev {
+	int	vd_type;
+#define VMBUS_DEV_TYPE_ATTACH			0
+#define VMBUS_DEV_TYPE_DETACH			1
+	struct vmbus_channel			*vd_chan;
+	SIMPLEQ_ENTRY(vmbus_dev)		vd_entry;
 };
-SIMPLEQ_HEAD(vmbus_offers, vmbus_offer);
+SIMPLEQ_HEAD(vmbus_devq, vmbus_dev);
 
 struct vmbus_ring_data {
 	struct vmbus_bufring		*rd_ring;
@@ -72,7 +77,6 @@ struct vmbus_ring_data {
 	uint32_t			rd_dsize;
 };
 
-struct vmbus_channel;
 TAILQ_HEAD(vmbus_channels, vmbus_channel);
 
 struct vmbus_channel {
@@ -111,6 +115,7 @@ struct vmbus_channel {
 	uint32_t			ch_flags;
 #define  CHF_BATCHED			__BIT(0)
 #define  CHF_MONITOR			__BIT(1)
+#define  CHF_REVOKED			__BIT(2)
 
 	uint8_tch_mgroup;
 	uint8_tch_mindex;
@@ -137,12 +142,6 @@ struct vmbus_attach_args {
 	bus_space_tag_t			aa_memt;
 };
 
-struct vmbus_dev {
-	struct vmbus_attach_args	dv_aa;
-	SLIST_ENTRY(vmbus_dev)		dv_entry;
-};
-SLIST_HEAD(vmbus_devices, 

CVS commit: src/sys/dev/hyperv

2019-12-10 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Tue Dec 10 11:19:25 UTC 2019

Modified Files:
src/sys/dev/hyperv: if_hvn.c

Log Message:
hvn(4): Handle VMBUS_CHANPKT_TYPE_INBAND packet type.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/dev/hyperv/if_hvn.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/dev/hyperv/if_hvn.c
diff -u src/sys/dev/hyperv/if_hvn.c:1.11 src/sys/dev/hyperv/if_hvn.c:1.12
--- src/sys/dev/hyperv/if_hvn.c:1.11	Tue Nov 26 01:46:31 2019
+++ src/sys/dev/hyperv/if_hvn.c	Tue Dec 10 11:19:25 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_hvn.c,v 1.11 2019/11/26 01:46:31 nonaka Exp $	*/
+/*	$NetBSD: if_hvn.c,v 1.12 2019/12/10 11:19:25 nonaka Exp $	*/
 /*	$OpenBSD: if_hvn.c,v 1.39 2018/03/11 14:31:34 mikeb Exp $	*/
 
 /*-
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_hvn.c,v 1.11 2019/11/26 01:46:31 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_hvn.c,v 1.12 2019/12/10 11:19:25 nonaka Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1040,6 +1040,16 @@ hvn_nvs_intr(void *arg)
 "on receive\n", nvs->nvs_type);
 break;
 			}
+		} else if (cph->cph_type == VMBUS_CHANPKT_TYPE_INBAND) {
+			switch (nvs->nvs_type) {
+			case HVN_NVS_TYPE_TXTBL_NOTE:
+/* Useless; ignore */
+break;
+			default:
+device_printf(sc->sc_dev,
+"got notify, nvs type %u\n", nvs->nvs_type);
+break;
+			}
 		} else
 			device_printf(sc->sc_dev,
 			"unknown NVSP packet type %u\n", cph->cph_type);



CVS commit: src/sys

2019-12-07 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Sat Dec  7 11:45:45 UTC 2019

Modified Files:
src/sys/arch/x86/x86: cpu.c hyperv.c hypervvar.h
src/sys/dev/hyperv: hyperv_common.c hypervvar.h vmbus.c vmbusvar.h

Log Message:
Get a Hyper-V virtual processor id in cpu_hatch().

Currently, it is got in config_interrupts context.
However, since it is required when attaching a device,
it is got earlier than now.


To generate a diff of this commit:
cvs rdiff -u -r1.177 -r1.178 src/sys/arch/x86/x86/cpu.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/x86/x86/hyperv.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/x86/x86/hypervvar.h
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/hyperv/hyperv_common.c
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/hyperv/hypervvar.h \
src/sys/dev/hyperv/vmbusvar.h
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/hyperv/vmbus.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/x86/cpu.c
diff -u src/sys/arch/x86/x86/cpu.c:1.177 src/sys/arch/x86/x86/cpu.c:1.178
--- src/sys/arch/x86/x86/cpu.c:1.177	Wed Nov 27 06:24:33 2019
+++ src/sys/arch/x86/x86/cpu.c	Sat Dec  7 11:45:45 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.177 2019/11/27 06:24:33 maxv Exp $	*/
+/*	$NetBSD: cpu.c,v 1.178 2019/12/07 11:45:45 nonaka Exp $	*/
 
 /*
  * Copyright (c) 2000-2012 NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.177 2019/11/27 06:24:33 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.178 2019/12/07 11:45:45 nonaka Exp $");
 
 #include "opt_ddb.h"
 #include "opt_mpbios.h"		/* for MPDEBUG */
@@ -118,6 +118,13 @@ __KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.17
 
 #include "tsc.h"
 
+#ifndef XEN
+#include "hyperv.h"
+#if NHYPERV > 0
+#include 
+#endif
+#endif
+
 static int	cpu_match(device_t, cfdata_t, void *);
 static void	cpu_attach(device_t, device_t, void *);
 static void	cpu_defer(device_t);
@@ -863,6 +870,9 @@ cpu_hatch(void *v)
 	cpu_init_msrs(ci, true);
 	cpu_probe(ci);
 	cpu_speculation_init(ci);
+#if NHYPERV > 0
+	hyperv_init_cpu(ci);
+#endif
 
 	ci->ci_data.cpu_cc_freq = cpu_info_primary.ci_data.cpu_cc_freq;
 	/* cpu_get_tsc_freq(ci); */

Index: src/sys/arch/x86/x86/hyperv.c
diff -u src/sys/arch/x86/x86/hyperv.c:1.5 src/sys/arch/x86/x86/hyperv.c:1.6
--- src/sys/arch/x86/x86/hyperv.c:1.5	Sat Nov 30 05:28:28 2019
+++ src/sys/arch/x86/x86/hyperv.c	Sat Dec  7 11:45:45 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: hyperv.c,v 1.5 2019/11/30 05:28:28 nonaka Exp $	*/
+/*	$NetBSD: hyperv.c,v 1.6 2019/12/07 11:45:45 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2009-2012,2016-2017 Microsoft Corp.
@@ -33,7 +33,7 @@
  */
 #include 
 #ifdef __KERNEL_RCSID
-__KERNEL_RCSID(0, "$NetBSD: hyperv.c,v 1.5 2019/11/30 05:28:28 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hyperv.c,v 1.6 2019/12/07 11:45:45 nonaka Exp $");
 #endif
 #ifdef __FBSDID
 __FBSDID("$FreeBSD: head/sys/dev/hyperv/vmbus/hyperv.c 331757 2018-03-30 02:25:12Z emaste $");
@@ -113,6 +113,8 @@ static char hyperv_features3_str[256];
 
 static int hyperv_idtvec;
 
+uint32_t hyperv_vcpuid[MAXCPUS];
+
 static struct timecounter hyperv_timecounter = {
 	.tc_get_timecount = hyperv_get_timecount,
 	.tc_counter_mask = 0x,
@@ -495,12 +497,45 @@ hyperv_early_init(void)
 {
 	u_int features, pm_features, features3;
 	u_int maxleaf;
+	int i;
 
 	if (!hyperv_probe(, , _features, ))
 		return;
 
 	if (features & CPUID_HV_MSR_TIME_REFCNT)
 		x86_delay = delay_func = delay_msr;
+
+	if (features & CPUID_HV_MSR_VP_INDEX) {
+		/* Save virtual processor id. */
+		hyperv_vcpuid[0] = rdmsr(MSR_HV_VP_INDEX);
+	} else {
+		/* Set virtual processor id to 0 for compatibility. */
+		hyperv_vcpuid[0] = 0;
+	}
+	for (i = 1; i < MAXCPUS; i++)
+		hyperv_vcpuid[i] = hyperv_vcpuid[0];
+}
+
+void
+hyperv_init_cpu(struct cpu_info *ci)
+{
+	u_int features, pm_features, features3;
+	u_int maxleaf;
+
+	if (!hyperv_probe(, , _features, ))
+		return;
+
+	if (features & CPUID_HV_MSR_VP_INDEX)
+		hyperv_vcpuid[ci->ci_index] = rdmsr(MSR_HV_VP_INDEX);
+}
+
+uint32_t
+hyperv_get_vcpuid(cpuid_t cpu)
+{
+
+	if (cpu < MAXCPUS)
+		return hyperv_vcpuid[cpu];
+	return 0;
 }
 
 static bool
@@ -798,14 +833,6 @@ vmbus_init_synic_md(struct vmbus_softc *
 
 	pd = >sc_percpu[cpu];
 
-	if (hyperv_features & CPUID_HV_MSR_VP_INDEX) {
-		/* Save virtual processor id. */
-		pd->vcpuid = rdmsr(MSR_HV_VP_INDEX);
-	} else {
-		/* Set virtual processor id to 0 for compatibility. */
-		pd->vcpuid = 0;
-	}
-
 	/*
 	 * Setup the SynIC message.
 	 */

Index: src/sys/arch/x86/x86/hypervvar.h
diff -u src/sys/arch/x86/x86/hypervvar.h:1.1 src/sys/arch/x86/x86/hypervvar.h:1.2
--- src/sys/arch/x86/x86/hypervvar.h:1.1	Fri May 24 14:28:48 2019
+++ src/sys/arch/x86/x86/hypervvar.h	Sat Dec  7 11:45:45 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: hypervvar.h,v 1.1 2019/05/24 14:28:48 nonaka Exp $	*/
+/*	$NetBSD: hypervvar.h,v 1.2 2019/12/07 11:45:45 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2009-2012,2016 Microsoft 

CVS commit: src/sys/dev/hyperv

2019-12-06 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Fri Dec  6 12:46:06 UTC 2019

Modified Files:
src/sys/dev/hyperv: hyperv_common.c vmbus.c

Log Message:
Clear the allocated memory in hyperv_dma_alloc().


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/hyperv/hyperv_common.c
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/hyperv/vmbus.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/dev/hyperv/hyperv_common.c
diff -u src/sys/dev/hyperv/hyperv_common.c:1.2 src/sys/dev/hyperv/hyperv_common.c:1.3
--- src/sys/dev/hyperv/hyperv_common.c:1.2	Fri May 31 04:23:19 2019
+++ src/sys/dev/hyperv/hyperv_common.c	Fri Dec  6 12:46:06 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: hyperv_common.c,v 1.2 2019/05/31 04:23:19 nonaka Exp $	*/
+/*	$NetBSD: hyperv_common.c,v 1.3 2019/12/06 12:46:06 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2009-2012,2016-2017 Microsoft Corp.
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: hyperv_common.c,v 1.2 2019/05/31 04:23:19 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hyperv_common.c,v 1.3 2019/12/06 12:46:06 nonaka Exp $");
 
 #include "hyperv.h"
 
@@ -155,6 +155,10 @@ hyperv_dma_alloc(bus_dma_tag_t dmat, str
 		goto fail4;
 	}
 
+	memset(dma->addr, 0, dma->map->dm_mapsize);
+	bus_dmamap_sync(dmat, dma->map, 0, dma->map->dm_mapsize,
+	BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
+
 	return dma->addr;
 
 fail4:	bus_dmamap_destroy(dmat, dma->map);

Index: src/sys/dev/hyperv/vmbus.c
diff -u src/sys/dev/hyperv/vmbus.c:1.5 src/sys/dev/hyperv/vmbus.c:1.6
--- src/sys/dev/hyperv/vmbus.c:1.5	Fri Nov 22 12:30:32 2019
+++ src/sys/dev/hyperv/vmbus.c	Fri Dec  6 12:46:06 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: vmbus.c,v 1.5 2019/11/22 12:30:32 nonaka Exp $	*/
+/*	$NetBSD: vmbus.c,v 1.6 2019/12/06 12:46:06 nonaka Exp $	*/
 /*	$OpenBSD: hyperv.c,v 1.43 2017/06/27 13:56:15 mikeb Exp $	*/
 
 /*-
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vmbus.c,v 1.5 2019/11/22 12:30:32 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vmbus.c,v 1.6 2019/12/06 12:46:06 nonaka Exp $");
 
 #include 
 #include 
@@ -985,7 +985,6 @@ vmbus_channel_alloc(struct vmbus_softc *
 		kmem_free(ch, sizeof(*ch));
 		return NULL;
 	}
-	memset(ch->ch_monprm, 0, sizeof(*ch->ch_monprm));
 
 	ch->ch_refs = 1;
 	ch->ch_sc = sc;
@@ -1264,7 +1263,6 @@ vmbus_channel_ring_create(struct vmbus_c
 		"failed to allocate channel ring\n");
 		return ENOMEM;
 	}
-	memset(ch->ch_ring, 0, ch->ch_ring_size);
 
 	memset(>ch_wrd, 0, sizeof(ch->ch_wrd));
 	ch->ch_wrd.rd_ring = (struct vmbus_bufring *)ch->ch_ring;



CVS commit: src/sys/dev/ic

2019-12-06 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Fri Dec  6 12:41:17 UTC 2019

Modified Files:
src/sys/dev/ic: rndisreg.h

Log Message:
Added RNDIS RSS and TCP offload related definitions.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/ic/rndisreg.h

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

Modified files:

Index: src/sys/dev/ic/rndisreg.h
diff -u src/sys/dev/ic/rndisreg.h:1.3 src/sys/dev/ic/rndisreg.h:1.4
--- src/sys/dev/ic/rndisreg.h:1.3	Thu Aug  8 06:16:39 2019
+++ src/sys/dev/ic/rndisreg.h	Fri Dec  6 12:41:17 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: rndisreg.h,v 1.3 2019/08/08 06:16:39 maya Exp $ */
+/*	$NetBSD: rndisreg.h,v 1.4 2019/12/06 12:41:17 nonaka Exp $ */
 /*	NetBSD: if_urndisreg.h,v 1.4 2018/11/09 21:57:09 maya Exp */
 /*	$OpenBSD: if_urndisreg.h,v 1.14 2010/07/08 18:22:01 ckuethe Exp $ */
 
@@ -64,6 +64,8 @@
 #define	OID_GEN_SUPPORTED_GUIDS		0x00010117
 #define	OID_GEN_NETWORK_LAYER_ADDRESSES	0x00010118
 #define	OID_GEN_TRANSPORT_HEADER_OFFSET	0x00010119
+#define	OID_GEN_RECEIVE_SCALE_CAPABILITIES	0x00010203
+#define	OID_GEN_RECEIVE_SCALE_PARAMETERS	0x00010204
 #define	OID_GEN_MACHINE_NAME		0x0001021A
 #define	OID_GEN_RNDIS_CONFIG_PARAMETER	0x0001021B
 #define	OID_GEN_VLAN_ID			0x0001021C
@@ -85,6 +87,7 @@
 #define	OID_802_3_XMIT_LATE_COLLISIONS	0x01020207
 
 #define OID_TCP_OFFLOAD_PARAMETERS	0xFC01020C
+#define OID_TCP_OFFLOAD_HARDWARE_CAPABILITIES	0xFC01020D
 
 #define RNDIS_MEDIUM_802_3		0x
 



CVS commit: src/sys/dev/ic

2019-12-06 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Fri Dec  6 12:39:51 UTC 2019

Modified Files:
src/sys/dev/ic: ndisreg.h

Log Message:
Added NDIS ver.6.20 definition.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/ic/ndisreg.h

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

Modified files:

Index: src/sys/dev/ic/ndisreg.h
diff -u src/sys/dev/ic/ndisreg.h:1.1 src/sys/dev/ic/ndisreg.h:1.2
--- src/sys/dev/ic/ndisreg.h:1.1	Fri Feb 15 08:54:02 2019
+++ src/sys/dev/ic/ndisreg.h	Fri Dec  6 12:39:51 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ndisreg.h,v 1.1 2019/02/15 08:54:02 nonaka Exp $	*/
+/*	$NetBSD: ndisreg.h,v 1.2 2019/12/06 12:39:51 nonaka Exp $	*/
 /*	$OpenBSD: ndis.h,v 1.2 2016/09/23 11:32:13 mikeb Exp $	*/
 
 /*-
@@ -39,6 +39,7 @@
 #define NDIS_VERSION_5_1		0x00050001
 #define NDIS_VERSION_6_0		0x0006
 #define NDIS_VERSION_6_1		0x00060001
+#define NDIS_VERSION_6_20		0x00060014
 #define NDIS_VERSION_6_30		0x0006001e
 
 #define	NDIS_MEDIA_STATE_CONNECTED	0



CVS commit: src/sys/arch/i386/stand/efiboot

2019-04-17 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Wed Apr 17 06:50:34 UTC 2019

Modified Files:
src/sys/arch/i386/stand/efiboot: efidisk.c

Log Message:
efiboot: Don't panic when BLOCK_IO_PROTOCOL is not found.

It has been reported that there is a machine where BLOCK_IO_PROTOCOL
can not be found when network boot without disk.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/i386/stand/efiboot/efidisk.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/i386/stand/efiboot/efidisk.c
diff -u src/sys/arch/i386/stand/efiboot/efidisk.c:1.6 src/sys/arch/i386/stand/efiboot/efidisk.c:1.7
--- src/sys/arch/i386/stand/efiboot/efidisk.c:1.6	Wed Apr 11 10:32:09 2018
+++ src/sys/arch/i386/stand/efiboot/efidisk.c	Wed Apr 17 06:50:34 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: efidisk.c,v 1.6 2018/04/11 10:32:09 nonaka Exp $	*/
+/*	$NetBSD: efidisk.c,v 1.7 2019/04/17 06:50:34 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -57,8 +57,7 @@ efi_disk_probe(void)
 	status = LibLocateHandle(ByProtocol, , NULL,
 	, );
 	if (EFI_ERROR(status))
-		panic("LocateHandle(BlockIoProtocol): %" PRIxMAX,
-		(uintmax_t)status);
+		return;
 
 	if (efi_bootdp != NULL)
 		depth = efi_device_path_depth(efi_bootdp, MEDIA_DEVICE_PATH);
@@ -76,8 +75,7 @@ efi_disk_probe(void)
 		status = uefi_call_wrapper(BS->HandleProtocol, 3, handles[i],
 		, (void **));
 		if (EFI_ERROR(status))
-			panic("HandleProtocol(BlockIoProtocol): %" PRIxMAX,
-			(uintmax_t)status);
+			continue;
 
 		media = bio->Media;
 		if (media->LogicalPartition || !media->MediaPresent)



CVS commit: src/sys/arch/x86/pci

2019-03-20 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Wed Mar 20 13:34:51 UTC 2019

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

Log Message:
PR/54058: vmx(4): Fix device enable command failure when the number of vCPUs
is not a power of two.

Make the size of the vmx(4) TX/RX queue a power of two not exceeding
the number of vCPUs.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 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.26 src/sys/arch/x86/pci/if_vmx.c:1.27
--- src/sys/arch/x86/pci/if_vmx.c:1.26	Tue Jun 26 06:48:00 2018
+++ src/sys/arch/x86/pci/if_vmx.c	Wed Mar 20 13:34:51 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vmx.c,v 1.26 2018/06/26 06:48:00 msaitoh Exp $	*/
+/*	$NetBSD: if_vmx.c,v 1.27 2019/03/20 13:34:51 nonaka 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.26 2018/06/26 06:48:00 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.27 2019/03/20 13:34:51 nonaka Exp $");
 
 #include 
 #include 
@@ -395,6 +395,29 @@ void vmxnet3_dma_free(struct vmxnet3_sof
 CFATTACH_DECL3_NEW(vmx, sizeof(struct vmxnet3_softc),
 vmxnet3_match, vmxnet3_attach, vmxnet3_detach, NULL, NULL, NULL, 0);
 
+/* round down to the nearest power of 2 */
+static int
+vmxnet3_calc_queue_size(int n)
+{
+	int v, q;
+
+	v = n;
+	while (v != 0) {
+		if (powerof2(n) != 0)
+			break;
+		v /= 2;
+		q = rounddown2(n, v);
+		if (q != 0) {
+			n = q;
+			break;
+		}
+	}
+	if (n == 0)
+		n = 1;
+
+	return n;
+}
+
 static inline void
 vmxnet3_write_bar0(struct vmxnet3_softc *sc, bus_size_t r, uint32_t v)
 {
@@ -520,8 +543,10 @@ vmxnet3_attach(device_t parent, device_t
 	sc->vmx_mtx = mutex_obj_alloc(MUTEX_DEFAULT, IPL_NET);
 	callout_init(>vmx_tick, CALLOUT_MPSAFE);
 
-	sc->vmx_max_ntxqueues = ncpu;
-	sc->vmx_max_nrxqueues = ncpu;
+	sc->vmx_max_ntxqueues =
+	vmxnet3_calc_queue_size(MIN(VMXNET3_MAX_TX_QUEUES, ncpu));
+	sc->vmx_max_nrxqueues =
+	vmxnet3_calc_queue_size(MIN(VMXNET3_MAX_RX_QUEUES, ncpu));
 	sc->vmx_ntxdescs = 512;
 	sc->vmx_nrxdescs = 256;
 	sc->vmx_max_rxsegs = VMXNET3_MAX_RX_SEGS;



CVS commit: src/sys/arch/amd64/amd64

2019-03-07 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Thu Mar  7 10:16:07 UTC 2019

Modified Files:
src/sys/arch/amd64/amd64: vector.S

Log Message:
Use IDTVEC instead of NENTRY for handle_hyperv_hypercall.


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 src/sys/arch/amd64/amd64/vector.S

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/amd64/amd64/vector.S
diff -u src/sys/arch/amd64/amd64/vector.S:1.69 src/sys/arch/amd64/amd64/vector.S:1.70
--- src/sys/arch/amd64/amd64/vector.S:1.69	Fri Feb 15 08:54:01 2019
+++ src/sys/arch/amd64/amd64/vector.S	Thu Mar  7 10:16:07 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: vector.S,v 1.69 2019/02/15 08:54:01 nonaka Exp $	*/
+/*	$NetBSD: vector.S,v 1.70 2019/03/07 10:16:07 nonaka Exp $	*/
 
 /*
  * Copyright (c) 1998, 2007, 2008 The NetBSD Foundation, Inc.
@@ -277,12 +277,12 @@ IDTVEC(recurse_hyperv_hypercall)
 	INTR_RECURSE_ENTRY
 	jmp	1f
 IDTVEC_END(recurse_hyperv_hypercall)
-NENTRY(handle_hyperv_hypercall)
+IDTVEC(handle_hyperv_hypercall)
 	movl	CPUVAR(ILEVEL),%ebx
 	cmpl	$IPL_NET,%ebx
 	jae	2f
 	jmp	1f
-END(handle_hyperv_hypercall)
+IDTVEC_END(handle_hyperv_hypercall)
 IDTVEC(resume_hyperv_hypercall)
 1:
 	incl	CPUVAR(IDEPTH)
@@ -302,7 +302,7 @@ IDTVEC(intr_hyperv_hypercall)
 	pushq	$0
 	pushq	$T_ASTFLT
 	INTRENTRY
-	jmp	_C_LABEL(handle_hyperv_hypercall)
+	jmp	_C_LABEL(Xhandle_hyperv_hypercall)
 IDTVEC_END(intr_hyperv_hypercall)
 	TEXT_USER_END
 #endif	/* NHYPERV > 0 */



CVS commit: src/sys/arch/amd64/conf

2019-03-01 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Fri Mar  1 12:25:09 UTC 2019

Modified Files:
src/sys/arch/amd64/conf: GENERIC

Log Message:
fix typo. pointed out by pgoyette@n.o.


To generate a diff of this commit:
cvs rdiff -u -r1.519 -r1.520 src/sys/arch/amd64/conf/GENERIC

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/amd64/conf/GENERIC
diff -u src/sys/arch/amd64/conf/GENERIC:1.519 src/sys/arch/amd64/conf/GENERIC:1.520
--- src/sys/arch/amd64/conf/GENERIC:1.519	Fri Mar  1 11:06:55 2019
+++ src/sys/arch/amd64/conf/GENERIC	Fri Mar  1 12:25:09 2019
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.519 2019/03/01 11:06:55 pgoyette Exp $
+# $NetBSD: GENERIC,v 1.520 2019/03/01 12:25:09 nonaka Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@ include 	"arch/amd64/conf/std.amd64"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident		"GENERIC-$Revision: 1.519 $"
+#ident		"GENERIC-$Revision: 1.520 $"
 
 maxusers	64		# estimated number of users
 
@@ -1090,7 +1090,7 @@ vmbus*		at acpi?		# Hyper-V VMBus
 hvn*		at vmbus?		# Hyper-V NetVSC
 hvs*		at vmbus?		# Hyper-V StorVSC
 hvheartbeat*	at vmbus?		# Hyper-V Heartbeat Service
-hvshutdown*	at vmbus?		# Hyper-V Geust Shutdown Service
+hvshutdown*	at vmbus?		# Hyper-V Guest Shutdown Service
 hvtimesync*	at vmbus?		# Hyper-V Time Synchronization Service
 #hvkvp*		at vmbus?		# Hyper-V Data Exchange Service
 



CVS commit: src/sys/arch/i386/conf

2019-03-01 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Fri Mar  1 12:23:10 UTC 2019

Modified Files:
src/sys/arch/i386/conf: GENERIC

Log Message:
commented out hvkvp entry.


To generate a diff of this commit:
cvs rdiff -u -r1.1203 -r1.1204 src/sys/arch/i386/conf/GENERIC

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/i386/conf/GENERIC
diff -u src/sys/arch/i386/conf/GENERIC:1.1203 src/sys/arch/i386/conf/GENERIC:1.1204
--- src/sys/arch/i386/conf/GENERIC:1.1203	Fri Mar  1 08:17:51 2019
+++ src/sys/arch/i386/conf/GENERIC	Fri Mar  1 12:23:10 2019
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.1203 2019/03/01 08:17:51 nonaka Exp $
+# $NetBSD: GENERIC,v 1.1204 2019/03/01 12:23:10 nonaka Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@ include 	"arch/i386/conf/std.i386"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident		"GENERIC-$Revision: 1.1203 $"
+#ident		"GENERIC-$Revision: 1.1204 $"
 
 maxusers	64		# estimated number of users
 
@@ -1433,7 +1433,7 @@ hvs*		at vmbus?		# Hyper-V StorVSC
 hvheartbeat*	at vmbus?		# Hyper-V Heartbeat Service
 hvshutdown*	at vmbus?		# Hyper-V Guest Shutdown Service
 hvtimesync*	at vmbus?		# Hyper-V Time Synchronization Service
-hvkvp*		at vmbus?		# Hyper-V Data Exchange Service
+#hvkvp*		at vmbus?		# Hyper-V Data Exchange Service
 
 
 # Pull in optional local configuration



CVS commit: src/sys/dev/hyperv

2019-03-01 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Fri Mar  1 10:02:33 UTC 2019

Modified Files:
src/sys/dev/hyperv: vmbusicreg.h

Log Message:
Remove unused definition.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/hyperv/vmbusicreg.h

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

Modified files:

Index: src/sys/dev/hyperv/vmbusicreg.h
diff -u src/sys/dev/hyperv/vmbusicreg.h:1.1 src/sys/dev/hyperv/vmbusicreg.h:1.2
--- src/sys/dev/hyperv/vmbusicreg.h:1.1	Fri Feb 15 08:54:02 2019
+++ src/sys/dev/hyperv/vmbusicreg.h	Fri Mar  1 10:02:33 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: vmbusicreg.h,v 1.1 2019/02/15 08:54:02 nonaka Exp $	*/
+/*	$NetBSD: vmbusicreg.h,v 1.2 2019/03/01 10:02:33 nonaka Exp $	*/
 /*	$OpenBSD: hypervicreg.h,v 1.6 2017/11/07 16:49:42 mikeb Exp $	*/
 
 /*-
@@ -32,8 +32,6 @@
 #ifndef _VMBUSICREG_H_
 #define _VMBUSICREG_H_
 
-#define VMBUS_IC_BUFRINGSIZE		(4 * PAGE_SIZE)
-
 #define VMBUS_ICMSG_TYPE_NEGOTIATE	0
 #define VMBUS_ICMSG_TYPE_HEARTBEAT	1
 #define VMBUS_ICMSG_TYPE_KVP		2



CVS commit: src/sys

2019-03-01 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Fri Mar  1 08:17:51 UTC 2019

Modified Files:
src/sys/arch/amd64/conf: GENERIC
src/sys/arch/i386/conf: GENERIC
src/sys/dev/hyperv: hvheartbeat.c hvshutdown.c hvtimesync.c

Log Message:
Update Hyper-V related drivers description.


To generate a diff of this commit:
cvs rdiff -u -r1.517 -r1.518 src/sys/arch/amd64/conf/GENERIC
cvs rdiff -u -r1.1202 -r1.1203 src/sys/arch/i386/conf/GENERIC
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/hyperv/hvheartbeat.c \
src/sys/dev/hyperv/hvshutdown.c src/sys/dev/hyperv/hvtimesync.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/amd64/conf/GENERIC
diff -u src/sys/arch/amd64/conf/GENERIC:1.517 src/sys/arch/amd64/conf/GENERIC:1.518
--- src/sys/arch/amd64/conf/GENERIC:1.517	Sat Feb 23 03:10:06 2019
+++ src/sys/arch/amd64/conf/GENERIC	Fri Mar  1 08:17:51 2019
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.517 2019/02/23 03:10:06 kamil Exp $
+# $NetBSD: GENERIC,v 1.518 2019/03/01 08:17:51 nonaka Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@ include 	"arch/amd64/conf/std.amd64"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident		"GENERIC-$Revision: 1.517 $"
+#ident		"GENERIC-$Revision: 1.518 $"
 
 maxusers	64		# estimated number of users
 
@@ -1089,9 +1089,10 @@ vioscsi* at virtio?			# Virtio SCSI devi
 vmbus*		at acpi?		# Hyper-V VMBus
 hvn*		at vmbus?		# Hyper-V NetVSC
 hvs*		at vmbus?		# Hyper-V StorVSC
-hvheartbeat*	at vmbus?		# Hyper-V Heartbeat
-hvshutdown*	at vmbus?		# Hyper-V Shutdown
-hvtimesync*	at vmbus?		# Hyper-V Timesync
+hvheartbeat*	at vmbus?		# Hyper-V Heartbeat Service
+hvshutdown*	at vmbus?		# Hyper-V Geust Shutdown Service
+hvtimesync*	at vmbus?		# Hyper-V Time Synchronization Service
+hvkvp*		at vmbus?		# Hyper-V Data Exchange Service
 
 # Pull in optional local configuration
 cinclude "arch/amd64/conf/GENERIC.local"

Index: src/sys/arch/i386/conf/GENERIC
diff -u src/sys/arch/i386/conf/GENERIC:1.1202 src/sys/arch/i386/conf/GENERIC:1.1203
--- src/sys/arch/i386/conf/GENERIC:1.1202	Sat Feb 23 12:28:22 2019
+++ src/sys/arch/i386/conf/GENERIC	Fri Mar  1 08:17:51 2019
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.1202 2019/02/23 12:28:22 kamil Exp $
+# $NetBSD: GENERIC,v 1.1203 2019/03/01 08:17:51 nonaka Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@ include 	"arch/i386/conf/std.i386"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident		"GENERIC-$Revision: 1.1202 $"
+#ident		"GENERIC-$Revision: 1.1203 $"
 
 maxusers	64		# estimated number of users
 
@@ -1430,9 +1430,10 @@ vioscsi* at virtio?			# Virtio SCSI devi
 vmbus*		at acpi?		# Hyper-V VMBus
 hvn*		at vmbus?		# Hyper-V NetVSC
 hvs*		at vmbus?		# Hyper-V StorVSC
-hvheartbeat*	at vmbus?		# Hyper-V Heartbeat
-hvshutdown*	at vmbus?		# Hyper-V Shutdown
-hvtimesync*	at vmbus?		# Hyper-V Timesync
+hvheartbeat*	at vmbus?		# Hyper-V Heartbeat Service
+hvshutdown*	at vmbus?		# Hyper-V Guest Shutdown Service
+hvtimesync*	at vmbus?		# Hyper-V Time Synchronization Service
+hvkvp*		at vmbus?		# Hyper-V Data Exchange Service
 
 
 # Pull in optional local configuration

Index: src/sys/dev/hyperv/hvheartbeat.c
diff -u src/sys/dev/hyperv/hvheartbeat.c:1.1 src/sys/dev/hyperv/hvheartbeat.c:1.2
--- src/sys/dev/hyperv/hvheartbeat.c:1.1	Fri Feb 15 08:54:01 2019
+++ src/sys/dev/hyperv/hvheartbeat.c	Fri Mar  1 08:17:51 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: hvheartbeat.c,v 1.1 2019/02/15 08:54:01 nonaka Exp $	*/
+/*	$NetBSD: hvheartbeat.c,v 1.2 2019/03/01 08:17:51 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2014,2016 Microsoft Corp.
@@ -28,7 +28,7 @@
 
 #include 
 #ifdef __KERNEL_RCSID
-__KERNEL_RCSID(0, "$NetBSD: hvheartbeat.c,v 1.1 2019/02/15 08:54:01 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hvheartbeat.c,v 1.2 2019/03/01 08:17:51 nonaka Exp $");
 #endif
 #ifdef __FBSDID
 __FBSDID("$FreeBSD: head/sys/dev/hyperv/utilities/vmbus_heartbeat.c 310324 2016-12-20 09:46:14Z sephe $");
@@ -80,7 +80,7 @@ hvheartbeat_attach(device_t parent, devi
 	int error;
 
 	aprint_naive("\n");
-	aprint_normal(": Hyper-V Heartbeat\n");
+	aprint_normal(": Hyper-V Heartbeat Service\n");
 
 	error = vmbusic_attach(self, aa, hvheartbeat_channel_cb);
 	if (error)
Index: src/sys/dev/hyperv/hvshutdown.c
diff -u src/sys/dev/hyperv/hvshutdown.c:1.1 src/sys/dev/hyperv/hvshutdown.c:1.2
--- src/sys/dev/hyperv/hvshutdown.c:1.1	Fri Feb 15 08:54:01 2019
+++ src/sys/dev/hyperv/hvshutdown.c	Fri Mar  1 08:17:51 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: hvshutdown.c,v 1.1 2019/02/15 08:54:01 nonaka Exp $	*/
+/*	$NetBSD: hvshutdown.c,v 1.2 2019/03/01 08:17:51 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2014,2016 Microsoft Corp.
@@ -28,7 +28,7 @@
 
 #include 
 #ifdef __KERNEL_RCSID
-__KERNEL_RCSID(0, "$NetBSD: hvshutdown.c,v 1.1 2019/02/15 08:54:01 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hvshutdown.c,v 1.2 2019/03/01 08:17:51 

CVS commit: src/usr.sbin/arp

2019-02-27 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Thu Feb 28 01:20:25 UTC 2019

Modified Files:
src/usr.sbin/arp: arp.c

Log Message:
arp(8): one more to close socket.


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/usr.sbin/arp/arp.c

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

Modified files:

Index: src/usr.sbin/arp/arp.c
diff -u src/usr.sbin/arp/arp.c:1.64 src/usr.sbin/arp/arp.c:1.65
--- src/usr.sbin/arp/arp.c:1.64	Wed Feb 27 23:29:50 2019
+++ src/usr.sbin/arp/arp.c	Thu Feb 28 01:20:25 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: arp.c,v 1.64 2019/02/27 23:29:50 dholland Exp $ */
+/*	$NetBSD: arp.c,v 1.65 2019/02/28 01:20:25 nonaka Exp $ */
 
 /*
  * Copyright (c) 1984, 1993
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1984, 19
 #if 0
 static char sccsid[] = "@(#)arp.c	8.3 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: arp.c,v 1.64 2019/02/27 23:29:50 dholland Exp $");
+__RCSID("$NetBSD: arp.c,v 1.65 2019/02/28 01:20:25 nonaka Exp $");
 #endif
 #endif /* not lint */
 
@@ -413,8 +413,10 @@ delete_one(struct rt_msghdr *rtm)
 	sina = (struct sockaddr_inarp *)(void *)(rtm + 1);
 	sdl = (struct sockaddr_dl *)(void *)(RT_ROUNDUP(sina->sin_len) +
 	(char *)(void *)sina);
-	if (sdl->sdl_family != AF_LINK)
+	if (sdl->sdl_family != AF_LINK) {
+		prog_close(s);
 		return (1);
+	}
 	rtm = rtmsg(s, RTM_DELETE, rtm, sina, sdl);
 	prog_close(s);
 	if (rtm == NULL)



CVS commit: src/sys/arch/x86/x86

2019-02-16 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Sun Feb 17 05:06:16 UTC 2019

Modified Files:
src/sys/arch/x86/x86: lapic.c

Log Message:
PR/53984: Partial revert of modify lapic_calibrate_timer() in lapic.c r1.69.


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 src/sys/arch/x86/x86/lapic.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/x86/lapic.c
diff -u src/sys/arch/x86/x86/lapic.c:1.69 src/sys/arch/x86/x86/lapic.c:1.70
--- src/sys/arch/x86/x86/lapic.c:1.69	Fri Feb 15 08:54:01 2019
+++ src/sys/arch/x86/x86/lapic.c	Sun Feb 17 05:06:16 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: lapic.c,v 1.69 2019/02/15 08:54:01 nonaka Exp $	*/
+/*	$NetBSD: lapic.c,v 1.70 2019/02/17 05:06:16 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2000, 2008 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lapic.c,v 1.69 2019/02/15 08:54:01 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lapic.c,v 1.70 2019/02/17 05:06:16 nonaka Exp $");
 
 #include "acpica.h"
 #include "ioapic.h"
@@ -604,11 +604,9 @@ extern void (*initclock_func)(void); /* 
 void
 lapic_calibrate_timer(struct cpu_info *ci)
 {
-	struct timecounter *tc;
-	timecounter_get_t *tick_func;
-	unsigned int tval, mask, delta, initial_counter, initial_lapic;
-	unsigned int cur_counter, cur_lapic;
-	uint64_t seen, end, tmp, freq;
+	unsigned int seen, delta, initial_i8254, initial_lapic;
+	unsigned int cur_i8254, cur_lapic;
+	uint64_t tmp;
 	int i;
 	char tbuf[9];
 
@@ -617,19 +615,6 @@ lapic_calibrate_timer(struct cpu_info *c
 
 	aprint_debug_dev(ci->ci_dev, "calibrating local timer\n");
 
-	tc = timecounter;
-	if (tc->tc_quality <= 0) {
-		tick_func = (timecounter_get_t *)gettick;
-		tval = rtclock_tval;
-		mask = ~0u;
-		freq = TIMER_FREQ;
-	} else {
-		tick_func = tc->tc_get_timecount;
-		tval = mask = tc->tc_counter_mask;
-		freq = tc->tc_frequency;
-	}
-	end = freq / 100;
-
 	/*
 	 * Configure timer to one-shot, interrupt masked,
 	 * large positive number.
@@ -641,22 +626,22 @@ lapic_calibrate_timer(struct cpu_info *c
 	x86_disable_intr();
 
 	initial_lapic = lapic_gettick();
-	initial_counter = tick_func(tc) & mask;
+	initial_i8254 = gettick();
 
-	for (seen = 0; seen < end; seen += delta) {
-		cur_counter = tick_func(tc) & mask;
-		if (cur_counter > initial_counter)
-			delta = tval - (cur_counter - initial_counter);
+	for (seen = 0; seen < TIMER_FREQ / 100; seen += delta) {
+		cur_i8254 = gettick();
+		if (cur_i8254 > initial_i8254)
+			delta = rtclock_tval - (cur_i8254 - initial_i8254);
 		else
-			delta = initial_counter - cur_counter;
-		initial_counter = cur_counter;
+			delta = initial_i8254 - cur_i8254;
+		initial_i8254 = cur_i8254;
 	}
 	cur_lapic = lapic_gettick();
 
 	x86_enable_intr();
 
 	tmp = initial_lapic - cur_lapic;
-	lapic_per_second = (tmp * freq + seen / 2) / seen;
+	lapic_per_second = (tmp * TIMER_FREQ + seen / 2) / seen;
 
 calibrate_done:
 	humanize_number(tbuf, sizeof(tbuf), lapic_per_second, "Hz", 1000);



CVS commit: src/sys/dev

2019-02-13 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Thu Feb 14 03:33:55 UTC 2019

Modified Files:
src/sys/dev/usb: if_urndis.c
Added Files:
src/sys/dev/ic: rndisreg.h
Removed Files:
src/sys/dev/usb: if_urndisreg.h

Log Message:
separate RNDIS definitions from urndis(4) for use with Hyper-V NetVSC.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/dev/ic/rndisreg.h
cvs rdiff -u -r1.19 -r1.20 src/sys/dev/usb/if_urndis.c
cvs rdiff -u -r1.4 -r0 src/sys/dev/usb/if_urndisreg.h

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

Modified files:

Index: src/sys/dev/usb/if_urndis.c
diff -u src/sys/dev/usb/if_urndis.c:1.19 src/sys/dev/usb/if_urndis.c:1.20
--- src/sys/dev/usb/if_urndis.c:1.19	Fri Nov  9 21:57:09 2018
+++ src/sys/dev/usb/if_urndis.c	Thu Feb 14 03:33:55 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_urndis.c,v 1.19 2018/11/09 21:57:09 maya Exp $ */
+/*	$NetBSD: if_urndis.c,v 1.20 2019/02/14 03:33:55 nonaka Exp $ */
 /*	$OpenBSD: if_urndis.c,v 1.31 2011/07/03 15:47:17 matthew Exp $ */
 
 /*
@@ -21,7 +21,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_urndis.c,v 1.19 2018/11/09 21:57:09 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_urndis.c,v 1.20 2019/02/14 03:33:55 nonaka Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -53,7 +53,56 @@ __KERNEL_RCSID(0, "$NetBSD: if_urndis.c,
 #include 
 #include 
 
-#include 
+#include 
+
+#define RNDIS_RX_LIST_CNT	1
+#define RNDIS_TX_LIST_CNT	1
+#define RNDIS_BUFSZ		1562
+
+struct urndis_softc;
+
+struct urndis_chain {
+	struct urndis_softc	*sc_softc;
+	struct usbd_xfer	*sc_xfer;
+	char			*sc_buf;
+	struct mbuf		*sc_mbuf;
+	int			 sc_idx;
+};
+
+struct urndis_cdata {
+	struct urndis_chain	sc_rx_chain[RNDIS_RX_LIST_CNT];
+	struct urndis_chain	sc_tx_chain[RNDIS_TX_LIST_CNT];
+	int			sc_tx_cnt;
+};
+
+#define GET_IFP(sc) (&(sc)->sc_ec.ec_if)
+struct urndis_softc {
+	device_t			sc_dev;
+
+	charsc_attached;
+	intsc_dying;
+	struct ethercom			sc_ec;
+
+	/* RNDIS device info */
+	uint32_t			sc_filter;
+	uint32_t			sc_maxppt;
+	uint32_t			sc_maxtsz;
+	uint32_t			sc_palign;
+
+	/* USB goo */
+	struct usbd_device *		sc_udev;
+	intsc_ifaceno_ctl;
+	struct usbd_interface *		sc_iface_ctl;
+	struct usbd_interface *		sc_iface_data;
+
+	struct timeval			sc_rx_notice;
+	intsc_bulkin_no;
+	struct usbd_pipe *		sc_bulkin_pipe;
+	intsc_bulkout_no;
+	struct usbd_pipe *		sc_bulkout_pipe;
+
+	struct urndis_cdata		sc_data;
+};
 
 #ifdef URNDIS_DEBUG
 #define DPRINTF(x)  do { printf x; } while (0)
@@ -86,16 +135,16 @@ static void urndis_stop(struct ifnet *);
 static usbd_status urndis_ctrl_msg(struct urndis_softc *, uint8_t, uint8_t,
 uint16_t, uint16_t, void *, size_t);
 static usbd_status urndis_ctrl_send(struct urndis_softc *, void *, size_t);
-static struct urndis_comp_hdr *urndis_ctrl_recv(struct urndis_softc *);
+static struct rndis_comp_hdr *urndis_ctrl_recv(struct urndis_softc *);
 
 static uint32_t urndis_ctrl_handle(struct urndis_softc *,
-struct urndis_comp_hdr *, void **, size_t *);
+struct rndis_comp_hdr *, void **, size_t *);
 static uint32_t urndis_ctrl_handle_init(struct urndis_softc *,
-const struct urndis_comp_hdr *);
+const struct rndis_comp_hdr *);
 static uint32_t urndis_ctrl_handle_query(struct urndis_softc *,
-const struct urndis_comp_hdr *, void **, size_t *);
+const struct rndis_comp_hdr *, void **, size_t *);
 static uint32_t urndis_ctrl_handle_reset(struct urndis_softc *,
-const struct urndis_comp_hdr *);
+const struct rndis_comp_hdr *);
 
 static uint32_t urndis_ctrl_init(struct urndis_softc *);
 #if 0
@@ -164,10 +213,10 @@ urndis_ctrl_send(struct urndis_softc *sc
 	return err;
 }
 
-static struct urndis_comp_hdr *
+static struct rndis_comp_hdr *
 urndis_ctrl_recv(struct urndis_softc *sc)
 {
-	struct urndis_comp_hdr	*hdr;
+	struct rndis_comp_hdr	*hdr;
 	char			*buf;
 	usbd_status		 err;
 
@@ -181,7 +230,7 @@ urndis_ctrl_recv(struct urndis_softc *sc
 		return NULL;
 	}
 
-	hdr = (struct urndis_comp_hdr *)buf;
+	hdr = (struct rndis_comp_hdr *)buf;
 	DPRINTF(("%s: urndis_ctrl_recv: type 0x%x len %u\n",
 	DEVNAME(sc),
 	le32toh(hdr->rm_type),
@@ -200,7 +249,7 @@ urndis_ctrl_recv(struct urndis_softc *sc
 }
 
 static uint32_t
-urndis_ctrl_handle(struct urndis_softc *sc, struct urndis_comp_hdr *hdr,
+urndis_ctrl_handle(struct urndis_softc *sc, struct rndis_comp_hdr *hdr,
 void **buf, size_t *bufsz)
 {
 	uint32_t rval;
@@ -243,11 +292,11 @@ urndis_ctrl_handle(struct urndis_softc *
 
 static uint32_t
 urndis_ctrl_handle_init(struct urndis_softc *sc,
-const struct urndis_comp_hdr *hdr)
+const struct rndis_comp_hdr *hdr)
 {
-	const struct urndis_init_comp	*msg;
+	const struct rndis_init_comp	*msg;
 
-	msg = (const struct urndis_init_comp *) hdr;
+	msg = (const struct rndis_init_comp *) hdr;
 
 	DPRINTF(("%s: urndis_ctrl_handle_init: len %u rid %u status 0x%x "
 	"ver_major %u 

CVS commit: src/usr.sbin/arp

2018-07-31 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Tue Jul 31 09:45:52 UTC 2018

Modified Files:
src/usr.sbin/arp: arp.c

Log Message:
arp(8): Fix the host output when arp -dav.


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/usr.sbin/arp/arp.c

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

Modified files:

Index: src/usr.sbin/arp/arp.c
diff -u src/usr.sbin/arp/arp.c:1.62 src/usr.sbin/arp/arp.c:1.63
--- src/usr.sbin/arp/arp.c:1.62	Wed Jul 11 03:10:48 2018
+++ src/usr.sbin/arp/arp.c	Tue Jul 31 09:45:52 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: arp.c,v 1.62 2018/07/11 03:10:48 ozaki-r Exp $ */
+/*	$NetBSD: arp.c,v 1.63 2018/07/31 09:45:52 nonaka Exp $ */
 
 /*
  * Copyright (c) 1984, 1993
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1984, 19
 #if 0
 static char sccsid[] = "@(#)arp.c	8.3 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: arp.c,v 1.62 2018/07/11 03:10:48 ozaki-r Exp $");
+__RCSID("$NetBSD: arp.c,v 1.63 2018/07/31 09:45:52 nonaka Exp $");
 #endif
 #endif /* not lint */
 
@@ -497,6 +497,7 @@ void
 delete(const char *host, const char *info)
 {
 	int mib[6];
+	char addr[sizeof("000.000.000.000\0")];
 	size_t needed;
 	char *lim, *buf, *next;
 	struct rt_msghdr *rtm;
@@ -543,8 +544,10 @@ retry:
 		found = true;
 		ret = delete_one(rtm);
 		if (vflag && ret == 0) {
-			(void)printf("%s (%s) deleted\n", host,
+			snprintf(addr, sizeof(addr), "%s",
 			inet_ntoa(sina->sin_addr));
+			(void)printf("%s (%s) deleted\n",
+			host != NULL ? host : addr, addr);
 		}
 	}
 	if (host != NULL && !found)



CVS commit: src/usr.sbin/ndp

2018-07-12 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Thu Jul 12 08:20:49 UTC 2018

Modified Files:
src/usr.sbin/ndp: ndp.c

Log Message:
Use s6, not mysin.


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/usr.sbin/ndp/ndp.c

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

Modified files:

Index: src/usr.sbin/ndp/ndp.c
diff -u src/usr.sbin/ndp/ndp.c:1.53 src/usr.sbin/ndp/ndp.c:1.54
--- src/usr.sbin/ndp/ndp.c:1.53	Thu Jul 12 08:16:14 2018
+++ src/usr.sbin/ndp/ndp.c	Thu Jul 12 08:20:49 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ndp.c,v 1.53 2018/07/12 08:16:14 nonaka Exp $	*/
+/*	$NetBSD: ndp.c,v 1.54 2018/07/12 08:20:49 nonaka Exp $	*/
 /*	$KAME: ndp.c,v 1.121 2005/07/13 11:30:13 keiichi Exp $	*/
 
 /*
@@ -494,8 +494,8 @@ delete(struct rt_msghdr *rtm, char *host
 	if (rtmsg(RTM_DELETE, rtm) == 0) {
 		struct sockaddr_in6 s6 = *mysin; /* XXX: for safety */
 
-		mysin->sin6_scope_id = 0;
-		inet6_putscopeid(mysin, INET6_IS_ADDR_LINKLOCAL);
+		s6.sin6_scope_id = 0;
+		inet6_putscopeid(, INET6_IS_ADDR_LINKLOCAL);
 		(void)getnameinfo((struct sockaddr *)(void *),
 		(socklen_t)s6.sin6_len, delete_host_buf,
 		sizeof(delete_host_buf), NULL, 0,



CVS commit: src/usr.sbin/ndp

2018-07-12 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Thu Jul 12 08:16:14 UTC 2018

Modified Files:
src/usr.sbin/ndp: ndp.c

Log Message:
ndp(8): host_buf should not be used in delete().

host_buf is passed to the argument host of delete() in do_foreach().


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/usr.sbin/ndp/ndp.c

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

Modified files:

Index: src/usr.sbin/ndp/ndp.c
diff -u src/usr.sbin/ndp/ndp.c:1.52 src/usr.sbin/ndp/ndp.c:1.53
--- src/usr.sbin/ndp/ndp.c:1.52	Thu Jul 12 07:32:35 2018
+++ src/usr.sbin/ndp/ndp.c	Thu Jul 12 08:16:14 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ndp.c,v 1.52 2018/07/12 07:32:35 nonaka Exp $	*/
+/*	$NetBSD: ndp.c,v 1.53 2018/07/12 08:16:14 nonaka Exp $	*/
 /*	$KAME: ndp.c,v 1.121 2005/07/13 11:30:13 keiichi Exp $	*/
 
 /*
@@ -478,6 +478,7 @@ delete_one(char *host)
 static int
 delete(struct rt_msghdr *rtm, char *host)
 {
+	char delete_host_buf[NI_MAXHOST];
 	struct sockaddr_in6 *mysin = _m;
 	struct sockaddr_dl *sdl;
 
@@ -496,10 +497,10 @@ delete(struct rt_msghdr *rtm, char *host
 		mysin->sin6_scope_id = 0;
 		inet6_putscopeid(mysin, INET6_IS_ADDR_LINKLOCAL);
 		(void)getnameinfo((struct sockaddr *)(void *),
-		(socklen_t)s6.sin6_len, host_buf,
-		sizeof(host_buf), NULL, 0,
+		(socklen_t)s6.sin6_len, delete_host_buf,
+		sizeof(delete_host_buf), NULL, 0,
 		(nflag ? NI_NUMERICHOST : 0));
-		(void)printf("%s (%s) deleted\n", host, host_buf);
+		(void)printf("%s (%s) deleted\n", host, delete_host_buf);
 	}
 
 	return 0;



CVS commit: src/usr.sbin/ndp

2018-07-12 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Thu Jul 12 07:32:35 UTC 2018

Modified Files:
src/usr.sbin/ndp: ndp.c

Log Message:
Remove duplicate rtrlist() function prototype.


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/usr.sbin/ndp/ndp.c

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

Modified files:

Index: src/usr.sbin/ndp/ndp.c
diff -u src/usr.sbin/ndp/ndp.c:1.51 src/usr.sbin/ndp/ndp.c:1.52
--- src/usr.sbin/ndp/ndp.c:1.51	Sat Jun 16 13:09:41 2018
+++ src/usr.sbin/ndp/ndp.c	Thu Jul 12 07:32:35 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ndp.c,v 1.51 2018/06/16 13:09:41 christos Exp $	*/
+/*	$NetBSD: ndp.c,v 1.52 2018/07/12 07:32:35 nonaka Exp $	*/
 /*	$KAME: ndp.c,v 1.121 2005/07/13 11:30:13 keiichi Exp $	*/
 
 /*
@@ -134,7 +134,6 @@ static void ifinfo(char *, int, char **)
 static void rtrlist(void);
 static void plist(void);
 static void pfx_flush(void);
-static void rtrlist(void);
 static void rtr_flush(void);
 static void harmonize_rtr(void);
 #ifdef SIOCSDEFIFACE_IN6	/* XXX: check SIOCGDEFIFACE_IN6 as well? */



CVS commit: src/sys/arch/i386/stand/efiboot

2018-06-08 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Fri Jun  8 11:52:30 UTC 2018

Modified Files:
src/sys/arch/i386/stand/efiboot: efiboot.c

Log Message:
Remove unused include.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/i386/stand/efiboot/efiboot.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/i386/stand/efiboot/efiboot.c
diff -u src/sys/arch/i386/stand/efiboot/efiboot.c:1.7 src/sys/arch/i386/stand/efiboot/efiboot.c:1.8
--- src/sys/arch/i386/stand/efiboot/efiboot.c:1.7	Wed Apr 11 10:32:09 2018
+++ src/sys/arch/i386/stand/efiboot/efiboot.c	Fri Jun  8 11:52:30 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: efiboot.c,v 1.7 2018/04/11 10:32:09 nonaka Exp $	*/
+/*	$NetBSD: efiboot.c,v 1.8 2018/06/08 11:52:30 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -28,7 +28,6 @@
 
 #include "efiboot.h"
 
-#include "biosdisk_ll.h"
 #include "bootinfo.h"
 #include "devopen.h"
 



CVS commit: src/usr.sbin/arp

2018-06-07 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Fri Jun  8 04:24:12 UTC 2018

Modified Files:
src/usr.sbin/arp: arp.c

Log Message:
fix usage of `arp -d'.


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/usr.sbin/arp/arp.c

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

Modified files:

Index: src/usr.sbin/arp/arp.c
diff -u src/usr.sbin/arp/arp.c:1.58 src/usr.sbin/arp/arp.c:1.59
--- src/usr.sbin/arp/arp.c:1.58	Wed Jun 28 08:17:50 2017
+++ src/usr.sbin/arp/arp.c	Fri Jun  8 04:24:12 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: arp.c,v 1.58 2017/06/28 08:17:50 ozaki-r Exp $ */
+/*	$NetBSD: arp.c,v 1.59 2018/06/08 04:24:12 nonaka Exp $ */
 
 /*
  * Copyright (c) 1984, 1993
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1984, 19
 #if 0
 static char sccsid[] = "@(#)arp.c	8.3 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: arp.c,v 1.58 2017/06/28 08:17:50 ozaki-r Exp $");
+__RCSID("$NetBSD: arp.c,v 1.59 2018/06/08 04:24:12 nonaka Exp $");
 #endif
 #endif /* not lint */
 
@@ -597,7 +597,7 @@ usage(void)
 	progname = getprogname();
 	(void)fprintf(stderr, "Usage: %s [-n] hostname\n", progname);
 	(void)fprintf(stderr, "   %s [-nv] -a\n", progname);
-	(void)fprintf(stderr, "   %s [-v] -d [-a|hostname [pub [proxy]]]\n",
+	(void)fprintf(stderr, "   %s [-v] -d [-a|hostname [proxy]]\n",
 	progname);
 	(void)fprintf(stderr, "   %s -s hostname ether_addr [temp] [pub [proxy]]\n",
 	progname);



CVS commit: src/sys/net

2018-06-04 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Tue Jun  5 01:25:59 UTC 2018

Modified Files:
src/sys/net: if_llatbl.c

Log Message:
It is necessary to set wall time instead of monotonic time to rmx_expire.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/net/if_llatbl.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/net/if_llatbl.c
diff -u src/sys/net/if_llatbl.c:1.26 src/sys/net/if_llatbl.c:1.27
--- src/sys/net/if_llatbl.c:1.26	Tue Mar  6 07:27:55 2018
+++ src/sys/net/if_llatbl.c	Tue Jun  5 01:25:59 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_llatbl.c,v 1.26 2018/03/06 07:27:55 ozaki-r Exp $	*/
+/*	$NetBSD: if_llatbl.c,v 1.27 2018/06/05 01:25:59 nonaka Exp $	*/
 /*
  * Copyright (c) 2004 Luigi Rizzo, Alessandro Cerri. All rights reserved.
  * Copyright (c) 2004-2008 Qing Li. All rights reserved.
@@ -112,8 +112,8 @@ lltable_dump_entry(struct lltable *llt, 
 		/* Need to copy by myself */
 		rtm->rtm_index = ifp->if_index;
 		rtm->rtm_rmx.rmx_mtu = 0;
-		rtm->rtm_rmx.rmx_expire =
-		(lle->la_flags & LLE_STATIC) ? 0 : lle->la_expire;
+		rtm->rtm_rmx.rmx_expire = (lle->la_flags & LLE_STATIC) ? 0 :
+		time_mono_to_wall(lle->la_expire);
 		rtm->rtm_flags = RTF_UP;
 		rtm->rtm_flags |= RTF_HOST; /* For ndp */
 		/* For backward compatibility */



CVS commit: src/external/gpl2/gmake/dist/glob

2018-05-23 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Wed May 23 09:52:27 UTC 2018

Modified Files:
src/external/gpl2/gmake/dist/glob: glob.c

Log Message:
gmake: __alloca and __stat are provided only when building with GLIBC.

Fix a build failure on Ubuntu 18.04.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/gpl2/gmake/dist/glob/glob.c

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

Modified files:

Index: src/external/gpl2/gmake/dist/glob/glob.c
diff -u src/external/gpl2/gmake/dist/glob/glob.c:1.4 src/external/gpl2/gmake/dist/glob/glob.c:1.5
--- src/external/gpl2/gmake/dist/glob/glob.c:1.4	Mon Apr 16 16:11:40 2018
+++ src/external/gpl2/gmake/dist/glob/glob.c	Wed May 23 09:52:27 2018
@@ -207,7 +207,7 @@ my_realloc (p, n)
 #endif /* __GNU_LIBRARY__ */
 
 
-#if !defined __alloca && !(defined __GNU_LIBRARY__ || defined __GLIBC__)
+#if !defined __alloca
 
 # ifdef	__GNUC__
 #  undef alloca
@@ -230,7 +230,7 @@ extern char *alloca ();
 
 #endif
 
-#ifndef __GNU_LIBRARY__
+#if !defined __stat
 # define __stat stat
 # ifdef STAT_MACROS_BROKEN
 #  undef S_ISDIR



CVS commit: src/sys/compat/common

2018-05-10 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Thu May 10 09:33:46 UTC 2018

Modified Files:
src/sys/compat/common: rtsock_50.c

Log Message:
Added missing ifi_link_state at compat_50_rt_oifmsg() and compat_50_iflist().


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/compat/common/rtsock_50.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/compat/common/rtsock_50.c
diff -u src/sys/compat/common/rtsock_50.c:1.6 src/sys/compat/common/rtsock_50.c:1.7
--- src/sys/compat/common/rtsock_50.c:1.6	Sat Dec 16 09:10:30 2017
+++ src/sys/compat/common/rtsock_50.c	Thu May 10 09:33:46 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtsock_50.c,v 1.6 2017/12/16 09:10:30 maxv Exp $	*/
+/*	$NetBSD: rtsock_50.c,v 1.7 2018/05/10 09:33:46 nonaka Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rtsock_50.c,v 1.6 2017/12/16 09:10:30 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtsock_50.c,v 1.7 2018/05/10 09:33:46 nonaka Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -95,6 +95,7 @@ compat_50_rt_oifmsg(struct ifnet *ifp)
 	oifm.ifm_data.ifi_type = ifp->if_data.ifi_type;
 	oifm.ifm_data.ifi_addrlen = ifp->if_data.ifi_addrlen;
 	oifm.ifm_data.ifi_hdrlen = ifp->if_data.ifi_hdrlen;
+	oifm.ifm_data.ifi_link_state = ifp->if_data.ifi_link_state;
 	oifm.ifm_data.ifi_mtu = ifp->if_data.ifi_mtu;
 	oifm.ifm_data.ifi_metric = ifp->if_data.ifi_metric;
 	oifm.ifm_data.ifi_baudrate = ifp->if_data.ifi_baudrate;
@@ -131,6 +132,7 @@ compat_50_iflist(struct ifnet *ifp, stru
 	ifm->ifm_data.ifi_type = ifp->if_data.ifi_type;
 	ifm->ifm_data.ifi_addrlen = ifp->if_data.ifi_addrlen;
 	ifm->ifm_data.ifi_hdrlen = ifp->if_data.ifi_hdrlen;
+	ifm->ifm_data.ifi_link_state = ifp->if_data.ifi_link_state;
 	ifm->ifm_data.ifi_mtu = ifp->if_data.ifi_mtu;
 	ifm->ifm_data.ifi_metric = ifp->if_data.ifi_metric;
 	ifm->ifm_data.ifi_baudrate = ifp->if_data.ifi_baudrate;



CVS commit: src/external/gpl2/texinfo/makedoc

2018-05-02 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Thu May  3 01:12:26 UTC 2018

Modified Files:
src/external/gpl2/texinfo/makedoc: Makefile

Log Message:
Restore MAKEDOC. Fix a build failure on non NetBSD host.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/external/gpl2/texinfo/makedoc/Makefile

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

Modified files:

Index: src/external/gpl2/texinfo/makedoc/Makefile
diff -u src/external/gpl2/texinfo/makedoc/Makefile:1.2 src/external/gpl2/texinfo/makedoc/Makefile:1.3
--- src/external/gpl2/texinfo/makedoc/Makefile:1.2	Tue May  1 19:59:43 2018
+++ src/external/gpl2/texinfo/makedoc/Makefile	Thu May  3 01:12:26 2018
@@ -1,5 +1,6 @@
-#	$NetBSD: Makefile,v 1.2 2018/05/01 19:59:43 christos Exp $
+#	$NetBSD: Makefile,v 1.3 2018/05/03 01:12:26 nonaka Exp $
 
+MAKEDOC=
 .include 
 
 HOSTPROG=	makedoc



CVS commit: src/external/gpl2/gmake/dist

2018-04-30 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Tue May  1 00:39:58 UTC 2018

Modified Files:
src/external/gpl2/gmake/dist: configure configure.in

Log Message:
gmake: Revert configure r1.2 and configure.in r1.2.

> gmake: Apply patch to support GLIBC glob interface v2
>
> http://git.savannah.gnu.org/cgit/make.git/commit/?id=48c8a116
>
> Fix a build failure on Ubuntu 18.04.

Don't apply an imcompatible license patch.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/external/gpl2/gmake/dist/configure \
src/external/gpl2/gmake/dist/configure.in

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

Modified files:

Index: src/external/gpl2/gmake/dist/configure
diff -u src/external/gpl2/gmake/dist/configure:1.2 src/external/gpl2/gmake/dist/configure:1.3
--- src/external/gpl2/gmake/dist/configure:1.2	Sat Apr 28 12:20:40 2018
+++ src/external/gpl2/gmake/dist/configure	Tue May  1 00:39:58 2018
@@ -13619,9 +13619,10 @@ cat >>conftest.$ac_ext <<_ACEOF
 #include 
 #include 
 
+#define GLOB_INTERFACE_VERSION 1
 #if !defined _LIBC && defined __GNU_LIBRARY__ && __GNU_LIBRARY__ > 1
 # include 
-# if _GNU_GLOB_INTERFACE_VERSION == 1 || _GNU_GLOB_INTERFACE_VERSION == 2
+# if _GNU_GLOB_INTERFACE_VERSION == GLOB_INTERFACE_VERSION
gnu glob
 # endif
 #endif
Index: src/external/gpl2/gmake/dist/configure.in
diff -u src/external/gpl2/gmake/dist/configure.in:1.2 src/external/gpl2/gmake/dist/configure.in:1.3
--- src/external/gpl2/gmake/dist/configure.in:1.2	Sat Apr 28 12:20:40 2018
+++ src/external/gpl2/gmake/dist/configure.in	Tue May  1 00:39:58 2018
@@ -19,7 +19,7 @@
 AC_INIT([GNU make],[3.81],[bug-m...@gnu.org])
 
 AC_PREREQ(2.59)
-AC_REVISION([[$Id: configure.in,v 1.2 2018/04/28 12:20:40 nonaka Exp $]])
+AC_REVISION([[$Id: configure.in,v 1.3 2018/05/01 00:39:58 nonaka Exp $]])
 
 # Autoconf setup
 AC_CONFIG_AUX_DIR(config)
@@ -351,9 +351,10 @@ AC_CACHE_VAL(make_cv_sys_gnu_glob, [
 #include 
 #include 
 
+#define GLOB_INTERFACE_VERSION 1
 #if !defined _LIBC && defined __GNU_LIBRARY__ && __GNU_LIBRARY__ > 1
 # include 
-# if _GNU_GLOB_INTERFACE_VERSION == 1 || _GNU_GLOB_INTERFACE_VERSION == 2
+# if _GNU_GLOB_INTERFACE_VERSION == GLOB_INTERFACE_VERSION
gnu glob
 # endif
 #endif



CVS commit: src/external/gpl2/gmake/dist

2018-04-30 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Tue May  1 00:36:58 UTC 2018

Modified Files:
src/external/gpl2/gmake/dist: dir.c

Log Message:
gmake: Revert dir.c r.1.2.

> gmake: Make this work with glibc glob interface v2
>
> http://git.savannah.gnu.org/cgit/make.git/commit/?id=193f1e81

Don't apply an imcompatible license patch.

Reported by kamil@n.o.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/external/gpl2/gmake/dist/dir.c

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

Modified files:

Index: src/external/gpl2/gmake/dist/dir.c
diff -u src/external/gpl2/gmake/dist/dir.c:1.2 src/external/gpl2/gmake/dist/dir.c:1.3
--- src/external/gpl2/gmake/dist/dir.c:1.2	Mon Apr 30 04:17:27 2018
+++ src/external/gpl2/gmake/dist/dir.c	Tue May  1 00:36:57 2018
@@ -1194,32 +1194,6 @@ local_stat (const char *path, struct sta
 }
 #endif
 
-/* Similarly for lstat.  */
-#if !defined(lstat) && !defined(WINDOWS32) || defined(VMS)
-# ifndef VMS
-#  ifndef HAVE_SYS_STAT_H
-int lstat (const char *path, struct stat *sbuf);
-#  endif
-# else
-/* We are done with the fake lstat.  Go back to the real lstat */
-#   ifdef lstat
-# undef lstat
-#   endif
-# endif
-# define local_lstat lstat
-#elif defined(WINDOWS32)
-/* Windows doesn't support lstat().  */
-# define local_lstat local_stat
-#else
-static int
-local_lstat (const char *path, struct stat *buf)
-{
-  int e;
-  EINTRLOOP (e, lstat (path, buf));
-  return e;
-}
-#endif
-
 void
 dir_setup_glob (glob_t *gl)
 {
@@ -1227,8 +1201,9 @@ dir_setup_glob (glob_t *gl)
   gl->gl_opendir = open_dirstream;
   gl->gl_readdir = read_dirstream;
   gl->gl_closedir = ansi_free;
-  gl->gl_lstat = local_lstat;
   gl->gl_stat = local_stat;
+  /* We don't bother setting gl_lstat, since glob never calls it.
+ The slot is only there for compatibility with 4.4 BSD.  */
 }
 
 void



CVS commit: src/external/gpl2/gmake/dist

2018-04-29 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Mon Apr 30 04:17:27 UTC 2018

Modified Files:
src/external/gpl2/gmake/dist: dir.c

Log Message:
gmake: Make this work with glibc glob interface v2

http://git.savannah.gnu.org/cgit/make.git/commit/?id=193f1e81


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.2 src/external/gpl2/gmake/dist/dir.c

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

Modified files:

Index: src/external/gpl2/gmake/dist/dir.c
diff -u src/external/gpl2/gmake/dist/dir.c:1.1.1.1 src/external/gpl2/gmake/dist/dir.c:1.2
--- src/external/gpl2/gmake/dist/dir.c:1.1.1.1	Mon Aug 18 06:46:58 2014
+++ src/external/gpl2/gmake/dist/dir.c	Mon Apr 30 04:17:27 2018
@@ -1194,6 +1194,32 @@ local_stat (const char *path, struct sta
 }
 #endif
 
+/* Similarly for lstat.  */
+#if !defined(lstat) && !defined(WINDOWS32) || defined(VMS)
+# ifndef VMS
+#  ifndef HAVE_SYS_STAT_H
+int lstat (const char *path, struct stat *sbuf);
+#  endif
+# else
+/* We are done with the fake lstat.  Go back to the real lstat */
+#   ifdef lstat
+# undef lstat
+#   endif
+# endif
+# define local_lstat lstat
+#elif defined(WINDOWS32)
+/* Windows doesn't support lstat().  */
+# define local_lstat local_stat
+#else
+static int
+local_lstat (const char *path, struct stat *buf)
+{
+  int e;
+  EINTRLOOP (e, lstat (path, buf));
+  return e;
+}
+#endif
+
 void
 dir_setup_glob (glob_t *gl)
 {
@@ -1201,9 +1227,8 @@ dir_setup_glob (glob_t *gl)
   gl->gl_opendir = open_dirstream;
   gl->gl_readdir = read_dirstream;
   gl->gl_closedir = ansi_free;
+  gl->gl_lstat = local_lstat;
   gl->gl_stat = local_stat;
-  /* We don't bother setting gl_lstat, since glob never calls it.
- The slot is only there for compatibility with 4.4 BSD.  */
 }
 
 void



CVS commit: src/external/gpl2/gmake/dist

2018-04-28 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Sat Apr 28 12:20:41 UTC 2018

Modified Files:
src/external/gpl2/gmake/dist: configure configure.in

Log Message:
gmake: Apply patch to support GLIBC glob interface v2

http://git.savannah.gnu.org/cgit/make.git/commit/?id=48c8a116

Fix a build failure on Ubuntu 18.04.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.2 src/external/gpl2/gmake/dist/configure \
src/external/gpl2/gmake/dist/configure.in

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

Modified files:

Index: src/external/gpl2/gmake/dist/configure
diff -u src/external/gpl2/gmake/dist/configure:1.1.1.1 src/external/gpl2/gmake/dist/configure:1.2
--- src/external/gpl2/gmake/dist/configure:1.1.1.1	Mon Aug 18 06:46:54 2014
+++ src/external/gpl2/gmake/dist/configure	Sat Apr 28 12:20:40 2018
@@ -13619,10 +13619,9 @@ cat >>conftest.$ac_ext <<_ACEOF
 #include 
 #include 
 
-#define GLOB_INTERFACE_VERSION 1
 #if !defined _LIBC && defined __GNU_LIBRARY__ && __GNU_LIBRARY__ > 1
 # include 
-# if _GNU_GLOB_INTERFACE_VERSION == GLOB_INTERFACE_VERSION
+# if _GNU_GLOB_INTERFACE_VERSION == 1 || _GNU_GLOB_INTERFACE_VERSION == 2
gnu glob
 # endif
 #endif
Index: src/external/gpl2/gmake/dist/configure.in
diff -u src/external/gpl2/gmake/dist/configure.in:1.1.1.1 src/external/gpl2/gmake/dist/configure.in:1.2
--- src/external/gpl2/gmake/dist/configure.in:1.1.1.1	Mon Aug 18 06:46:47 2014
+++ src/external/gpl2/gmake/dist/configure.in	Sat Apr 28 12:20:40 2018
@@ -19,7 +19,7 @@
 AC_INIT([GNU make],[3.81],[bug-m...@gnu.org])
 
 AC_PREREQ(2.59)
-AC_REVISION([[$Id: configure.in,v 1.1.1.1 2014/08/18 06:46:47 christos Exp $]])
+AC_REVISION([[$Id: configure.in,v 1.2 2018/04/28 12:20:40 nonaka Exp $]])
 
 # Autoconf setup
 AC_CONFIG_AUX_DIR(config)
@@ -351,10 +351,9 @@ AC_CACHE_VAL(make_cv_sys_gnu_glob, [
 #include 
 #include 
 
-#define GLOB_INTERFACE_VERSION 1
 #if !defined _LIBC && defined __GNU_LIBRARY__ && __GNU_LIBRARY__ > 1
 # include 
-# if _GNU_GLOB_INTERFACE_VERSION == GLOB_INTERFACE_VERSION
+# if _GNU_GLOB_INTERFACE_VERSION == 1 || _GNU_GLOB_INTERFACE_VERSION == 2
gnu glob
 # endif
 #endif



CVS commit: src/sbin/nvmectl

2018-04-18 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Wed Apr 18 10:17:54 UTC 2018

Modified Files:
src/sbin/nvmectl: nvmectl.8

Log Message:
nvmectl(8): Remove some wdc subcommands from man page.

- wdc drive-log
- wdc get-crash-dump
- wdc purge
- wdc purge-monitor


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sbin/nvmectl/nvmectl.8

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

Modified files:

Index: src/sbin/nvmectl/nvmectl.8
diff -u src/sbin/nvmectl/nvmectl.8:1.4 src/sbin/nvmectl/nvmectl.8:1.5
--- src/sbin/nvmectl/nvmectl.8:1.4	Sun Apr 30 15:59:18 2017
+++ src/sbin/nvmectl/nvmectl.8	Wed Apr 18 10:17:54 2018
@@ -1,4 +1,4 @@
-.\" $NetBSD: nvmectl.8,v 1.4 2017/04/30 15:59:18 wiz Exp $
+.\" $NetBSD: nvmectl.8,v 1.5 2018/04/18 10:17:54 nonaka Exp $
 .\"
 .\" Copyright (c) 2012 Intel Corporation
 .\" All rights reserved.
@@ -54,10 +54,10 @@
 .\".Aq Fl o Ar read|write
 .\".Aq Fl s Ar size_in_bytes
 .\".Aq Fl t Ar time_in_sec
-.\".Aq namespace id
+.\".Aq namespace_id
 .\".Nm
 .\".Ic reset
-.\".Aq controller id
+.\".Aq controller_id
 .Nm
 .Ic logpage
 .Op Fl x
@@ -80,21 +80,7 @@
 .Nm
 .Ic wdc cap-diag
 .Op Fl o path_template
-.Ar device id
-.Nm
-.Ic wdc drive-log
-.Op Fl o path_template
-.Ar device id
-.Nm
-.Ic wdc get-crash-dump
-.Op Fl o path_template
-.Ar device id
-.\" .Nm
-.\" .Ic wdc purge
-.\" .Aq device id
-.\" .Nm
-.\" .Ic wdc purge-monitor
-.\" .Aq device id
+.Ar device_id
 .Sh DESCRIPTION
 NVM Express (NVMe) is a storage protocol standard, for SSDs and other
 high-speed storage devices over PCI Express.



CVS commit: src/sbin/nvmectl

2018-04-18 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Wed Apr 18 10:16:22 UTC 2018

Modified Files:
src/sbin/nvmectl: nvmectl.h

Log Message:
nvmectl(8): fix subcommand usage.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sbin/nvmectl/nvmectl.h

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

Modified files:

Index: src/sbin/nvmectl/nvmectl.h
diff -u src/sbin/nvmectl/nvmectl.h:1.7 src/sbin/nvmectl/nvmectl.h:1.8
--- src/sbin/nvmectl/nvmectl.h:1.7	Tue Apr 17 15:31:00 2018
+++ src/sbin/nvmectl/nvmectl.h	Wed Apr 18 10:16:22 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvmectl.h,v 1.7 2018/04/17 15:31:00 nonaka Exp $	*/
+/*	$NetBSD: nvmectl.h,v 1.8 2018/04/18 10:16:22 nonaka Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -53,14 +53,14 @@ struct nvme_function {
 "devlist\n"
 
 #define IDENTIFY_USAGE			   \
-"identify [-x [-v]] \n"
+"identify [-x [-v]] \n"
 
 #ifdef ENABLE_PREFTEST
 #define PERFTEST_USAGE			   \
-"perftest <-n num_threads> <-o read|write>\n"		   \
+"perftest <-n num_threads> <-o read|write>\n"   \
 "<-s size_in_bytes> <-t time_in_seconds>\n"	   \
 "<-i intr|wait> [-f refthread] [-p]\n"		   \
-"\n"
+"\n"
 #endif
 
 #ifdef ENABLE_RESET
@@ -69,16 +69,16 @@ struct nvme_function {
 #endif
 
 #define LOGPAGE_USAGE			   \
-"logpage <-p page_id> [-b] [-v vendor] [-x] "		   \
-"\n"
+"logpage <-p page_id> [-b] [-v vendor] [-x] "   \
+"\n"
 
 #ifdef ENABLE_FIRMWARE
 #define FIRMWARE_USAGE			   \
-"firmware [-s slot] [-f path_to_firmware] [-a] \n"
+"firmware [-s slot] [-f path_to_firmware] [-a] \n"
 #endif
 
 #define POWER_USAGE			   \
-"power [-l] [-p new-state [-w workload-hint]] \n"
+"power [-l] [-p new-state [-w workload-hint]] \n"
 
 #define WDC_USAGE			   \
 "wdc cap-diag [-o path-templete]\n"



CVS commit: src

2018-04-18 Thread NONAKA Kimihiro
cific */
-#define	NVME_FEAT_SOFTWARE_PROGRESS_MARKER		0x80
-#define	NVME_FEAT_HOST_IDENTIFIER			0x81
-#define	NVME_FEAT_RESERVATION_NOTIFICATION_MASK		0x82
-#define	NVME_FEAT_RESERVATION_PERSISTANCE		0x83
-
 /* Get Log Page */
 #define	NVME_LOG_ERROR	0x01
 #define	NVME_LOG_HEALTH_INFORMATION			0x02

Index: src/sbin/nvmectl/util.c
diff -u src/sbin/nvmectl/util.c:1.1 src/sbin/nvmectl/util.c:1.2
--- src/sbin/nvmectl/util.c:1.1	Tue Apr 17 08:54:35 2018
+++ src/sbin/nvmectl/util.c	Wed Apr 18 10:11:44 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: util.c,v 1.1 2018/04/17 08:54:35 nonaka Exp $	*/
+/*	$NetBSD: util.c,v 1.2 2018/04/18 10:11:44 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2017 Netflix, Inc
@@ -28,7 +28,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: util.c,v 1.1 2018/04/17 08:54:35 nonaka Exp $");
+__RCSID("$NetBSD: util.c,v 1.2 2018/04/18 10:11:44 nonaka Exp $");
 #if 0
 __FBSDID("$FreeBSD: head/sbin/nvmecontrol/util.c 320423 2017-06-27 20:24:25Z imp $");
 #endif
@@ -89,8 +89,16 @@ print_bignum(const char *title, uint64_t
 {
 	char buf[64];
 	uint8_t tmp[16];
-	uint64_t l = le64toh(v[0]);
-	uint64_t h = le64toh(v[1]);
+	uint64_t h, l;
+
+#if _BYTE_ORDER != _LITTLE_ENDIAN
+	/* Already Converted to host endian */
+	h = v[0];
+	l = v[1];
+	memcpy(tmp, v, sizeof(tmp));
+#else
+	h = v[1];
+	l = v[0];
 
 	tmp[ 0] = (h >> 56) & 0xff;
 	tmp[ 1] = (h >> 48) & 0xff;
@@ -108,16 +116,17 @@ print_bignum(const char *title, uint64_t
 	tmp[13] = (l >> 16) & 0xff;
 	tmp[14] = (l >> 8) & 0xff;
 	tmp[15] = l & 0xff;
+#endif
 
 	buf[0] = '\0';
-	BIGNUM *bn = BN_bin2bn(tmp, __arraycount(tmp), NULL);
+	BIGNUM *bn = BN_bin2bn(tmp, sizeof(tmp), NULL);
 	if (bn != NULL) {
 		humanize_bignum(buf, METRIX_PREFIX_BUFSIZ + strlen(suffix),
 		bn, suffix, HN_AUTOSCALE, HN_DECIMAL);
 		BN_free(bn);
 	}
 	if (buf[0] == '\0')
-		snprintf(buf, sizeof(buf), "0x%016jx%016jx", h, l);
+		snprintf(buf, sizeof(buf), "0x%016" PRIx64 "%016" PRIx64, h, l);
 	printf("%-31s %s\n", title, buf);
 }
 

Index: src/sys/dev/ic/ld_nvme.c
diff -u src/sys/dev/ic/ld_nvme.c:1.19 src/sys/dev/ic/ld_nvme.c:1.20
--- src/sys/dev/ic/ld_nvme.c:1.19	Fri Mar 16 23:31:19 2018
+++ src/sys/dev/ic/ld_nvme.c	Wed Apr 18 10:11:45 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ld_nvme.c,v 1.19 2018/03/16 23:31:19 jdolecek Exp $	*/
+/*	$NetBSD: ld_nvme.c,v 1.20 2018/04/18 10:11:45 nonaka Exp $	*/
 
 /*-
  * Copyright (C) 2016 NONAKA Kimihiro <non...@netbsd.org>
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ld_nvme.c,v 1.19 2018/03/16 23:31:19 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ld_nvme.c,v 1.20 2018/04/18 10:11:45 nonaka Exp $");
 
 #include 
 #include 
@@ -86,7 +86,6 @@ ld_nvme_attach(device_t parent, device_t
 	struct nvme_attach_args *naa = aux;
 	struct nvme_namespace *ns;
 	struct nvm_namespace_format *f;
-	uint64_t nsze;
 	int error;
 
 	ld->sc_dv = self;
@@ -104,11 +103,10 @@ ld_nvme_attach(device_t parent, device_t
 
 	ns = nvme_ns_get(sc->sc_nvme, sc->sc_nsid);
 	KASSERT(ns);
-	nsze = lemtoh64(>ident->nsze);
 	f = >ident->lbaf[NVME_ID_NS_FLBAS(ns->ident->flbas)];
 
 	ld->sc_secsize = 1 << f->lbads;
-	ld->sc_secperunit = nsze;
+	ld->sc_secperunit = ns->ident->nsze;
 	ld->sc_maxxfer = naa->naa_maxphys;
 	ld->sc_maxqueuecnt = naa->naa_qentries;
 	ld->sc_start = ld_nvme_start;

Index: src/sys/dev/ic/nvme.c
diff -u src/sys/dev/ic/nvme.c:1.38 src/sys/dev/ic/nvme.c:1.39
--- src/sys/dev/ic/nvme.c:1.38	Wed Apr 18 10:05:59 2018
+++ src/sys/dev/ic/nvme.c	Wed Apr 18 10:11:45 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvme.c,v 1.38 2018/04/18 10:05:59 nonaka Exp $	*/
+/*	$NetBSD: nvme.c,v 1.39 2018/04/18 10:11:45 nonaka Exp $	*/
 /*	$OpenBSD: nvme.c,v 1.49 2016/04/18 05:59:50 dlg Exp $ */
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.38 2018/04/18 10:05:59 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.39 2018/04/18 10:11:45 nonaka Exp $");
 
 #include 
 #include 
@@ -624,7 +624,9 @@ nvme_ns_identify(struct nvme_softc *sc, 
 
 	identify = kmem_zalloc(sizeof(*identify), KM_SLEEP);
 	*identify = *((volatile struct nvm_identify_namespace *)NVME_DMA_KVA(mem));
-	//memcpy(identify, NVME_DMA_KVA(mem), sizeof(*identify));
+
+	/* Convert data to host endian */
+	nvme_identify_namespace_swapbytes(identify);
 
 	ns = nvme_ns_get(sc, nsid);
 	KASSERT(ns);
@@ -899,7 +901,7 @@ nvme_getcache_fill(struct nvme_queue *q,
 	struct nvme_sqe *sqe = slot;
 
 	sqe->opcode = NVM_ADMIN_GET_FEATURES;
-	sqe->cdw10 = NVM_FEATURE_VOLATILE_WRITE_CACHE;
+	htolem32(>cdw10, NVM_FEATURE_VOLATILE_WRITE_CACHE);
 }
 
 static void
@@ -1122,7 +1124,7 @@ nvme_q_submit(struct nvme_softc *sc, str
 	sizeof(*sqe) * tail, sizeof(*sqe), BUS_DMASYNC_POSTWRITE);
 	memset(sqe, 0, sizeof(*sqe));
 	(*fill)(q, ccb, sqe);
-	sqe->cid = ccb->ccb

CVS commit: src/sys/dev/ic

2018-04-18 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Wed Apr 18 10:10:26 UTC 2018

Modified Files:
src/sys/dev/ic: nvmereg.h

Log Message:
Add some new structure fileds, opcodes and statuses from NVMe 1.3a.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/ic/nvmereg.h

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

Modified files:

Index: src/sys/dev/ic/nvmereg.h
diff -u src/sys/dev/ic/nvmereg.h:1.10 src/sys/dev/ic/nvmereg.h:1.11
--- src/sys/dev/ic/nvmereg.h:1.10	Tue Apr 17 08:54:35 2018
+++ src/sys/dev/ic/nvmereg.h	Wed Apr 18 10:10:26 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvmereg.h,v 1.10 2018/04/17 08:54:35 nonaka Exp $	*/
+/*	$NetBSD: nvmereg.h,v 1.11 2018/04/18 10:10:26 nonaka Exp $	*/
 /*	$OpenBSD: nvmereg.h,v 1.10 2016/04/14 11:18:32 dlg Exp $ */
 
 /*
@@ -318,13 +318,27 @@ NVME_CTASSERT(sizeof(struct nvme_cqe) ==
 /* 0x0e-0x0f - reserved */
 #define NVM_ADMIN_FW_COMMIT	0x10 /* Firmware Commit */
 #define NVM_ADMIN_FW_DOWNLOAD	0x11 /* Firmware Image Download */
+#define NVM_ADMIN_DEV_SELFTEST	0x14 /* Device Self Test */
 #define NVM_ADMIN_NS_ATTACHMENT	0x15 /* Namespace Attachment */
+#define NVM_ADMIN_KEEP_ALIVE	0x18 /* Keep Alive */
+#define NVM_ADMIN_DIRECTIVE_SND	0x19 /* Derective Send */
+#define NVM_ADMIN_DIRECTIVE_RCV	0x1a /* Derective Receive */
+#define NVM_ADMIN_VIRT_MGMT	0x1c /* Virtualization Management */
+#define NVM_ADMIN_NVME_MI_SEND	0x1d /* NVMe-MI Send */
+#define NVM_ADMIN_NVME_MI_RECV	0x1e /* NVMe-MI Receive */
+#define NVM_ADMIN_DOORBELL_BC	0x7c /* Doorbell Buffer Config */
+#define NVM_ADMIN_FORMAT_NVM	0x80 /* Format NVM */
+#define NVM_ADMIN_SECURITY_SND	0x81 /* Security Send */
+#define NVM_ADMIN_SECURITY_RCV	0x82 /* Security Receive */
+#define NVM_ADMIN_SANITIZE	0x84 /* Sanitize */
 
 #define NVM_CMD_FLUSH		0x00 /* Flush */
 #define NVM_CMD_WRITE		0x01 /* Write */
 #define NVM_CMD_READ		0x02 /* Read */
 #define NVM_CMD_WR_UNCOR	0x04 /* Write Uncorrectable */
 #define NVM_CMD_COMPARE		0x05 /* Compare */
+/* 0x06-0x07 - reserved */
+#define NVM_CMD_WRITE_ZEROES	0x08 /* Write Zeroes */
 #define NVM_CMD_DSM		0x09 /* Dataset Management */
 
 /* Features for GET/SET FEATURES */
@@ -349,7 +363,10 @@ NVME_CTASSERT(sizeof(struct nvme_cqe) ==
 /* 0x12-0x77 - reserved */
 /* 0x78-0x7f - NVMe Management Interface */
 #define NVM_FEAT_SOFTWARE_PROGRESS_MARKER	0x80
-/* 0x81-0xBF - command set specific (reserved) */
+#define NVM_FEAT_HOST_IDENTIFIER		0x81
+#define NVM_FEAT_RESERVATION_NOTIFICATION_MASK	0x82
+#define NVM_FEAT_RESERVATION_PERSISTANCE	0x83
+/* 0x84-0xBF - command set specific (reserved) */
 /* 0xC0-0xFF - vendor specific */
 
 /* Power State Descriptor Data */
@@ -421,6 +438,11 @@ struct nvm_identify_controller {
 	/* Admin Command Set Attributes & Optional Controller Capabilities */
 
 	uint16_t	oacs;		/* Optional Admin Command Support */
+#define	NVME_ID_CTRLR_OACS_DOORBELL_BC	__BIT(8)
+#define	NVME_ID_CTRLR_OACS_VIRT_MGMT	__BIT(7)
+#define	NVME_ID_CTRLR_OACS_NVME_MI	__BIT(6)
+#define	NVME_ID_CTRLR_OACS_DIRECTIVES	__BIT(5)
+#define	NVME_ID_CTRLR_OACS_DEV_SELFTEST	__BIT(4)
 #define	NVME_ID_CTRLR_OACS_NS		__BIT(3)
 #define	NVME_ID_CTRLR_OACS_FW		__BIT(2)
 #define	NVME_ID_CTRLR_OACS_FORMAT	__BIT(1)
@@ -501,11 +523,14 @@ struct nvm_identify_controller {
 	uint16_t	fuses;		/* Fused Operation Support */
 
 	uint8_t		fna;		/* Format NVM Attributes */
+#define	NVME_ID_CTRLR_FNA_CRYPTO_ERASE	__BIT(2)
+#define	NVME_ID_CTRLR_FNA_ERASE_ALL	__BIT(1)
+#define	NVME_ID_CTRLR_FNA_FORMAT_ALL	__BIT(0)
 	uint8_t		vwc;		/* Volatile Write Cache */
 #define	NVME_ID_CTRLR_VWC_PRESENT	__BIT(0)
 	uint16_t	awun;		/* Atomic Write Unit Normal */
-
 	uint16_t	awupf;		/* Atomic Write Unit Power Fail */
+
 	uint8_t		nvscc;		/* NVM Vendor Specific Command */
 	uint8_t		_reserved4[1];
 
@@ -514,19 +539,17 @@ struct nvm_identify_controller {
 
 	uint32_t	sgls;		/* SGL Support */
 
-	uint8_t		_reserved6[164];
+	uint8_t		_reserved6[228];
 
-	/* I/O Command Set Attributes */
+	uint8_t		subnqn[256];	/* NVM Subsystem NVMe Qualified Name */
 
-	uint8_t		_reserved7[1344];
+	uint8_t		_reserved7[768];
 
-	/* Power State Descriptors */
+	uint8_t		_reserved8[256]; /* NVMe over Fabrics specification */
 
 	struct nvm_identify_psd psd[32]; /* Power State Descriptors */
 
-	/* Vendor Specific */
-
-	uint8_t		_reserved8[1024];
+	uint8_t		vs[1024];	/* Vendor Specific */
 } __packed __aligned(8);
 NVME_CTASSERT(sizeof(struct nvm_identify_controller) == 4096, "bad size for nvm_identify_controller");
 
@@ -555,9 +578,35 @@ struct nvm_identify_namespace {
 	uint8_t		mc;		/* Metadata Capabilities */
 	uint8_t		dpc;		/* End-to-end Data Protection
 	   Capabilities */
-	uint8_t		dps;		/* End-to-end Data Protection Type Settings */
+	uint8_t		dps;		/* End-to-end Data Protection Type
+	   Settings */
+#define	NVME_ID_NS_DPS_MD_START			__BIT(3)
+#define	NVME_ID_NS_DPS_PIT(_f)			((_f) & 0x7)
+
+	uint8_t		nmic;		/* Namespace 

CVS commit: src/sys/dev

2018-04-18 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Wed Apr 18 10:05:59 UTC 2018

Modified Files:
src/sys/dev/ic: nvme.c nvmevar.h
src/sys/dev/pci: nvme_pci.c

Log Message:
nvme(4): Added some delay before check RDY bit quirk when disabling device.

Pick from FreeBSD nvme(4) r326937.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/dev/ic/nvme.c
cvs rdiff -u -r1.15 -r1.16 src/sys/dev/ic/nvmevar.h
cvs rdiff -u -r1.19 -r1.20 src/sys/dev/pci/nvme_pci.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/dev/ic/nvme.c
diff -u src/sys/dev/ic/nvme.c:1.37 src/sys/dev/ic/nvme.c:1.38
--- src/sys/dev/ic/nvme.c:1.37	Sat Mar 17 09:45:44 2018
+++ src/sys/dev/ic/nvme.c	Wed Apr 18 10:05:59 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvme.c,v 1.37 2018/03/17 09:45:44 jdolecek Exp $	*/
+/*	$NetBSD: nvme.c,v 1.38 2018/04/18 10:05:59 nonaka Exp $	*/
 /*	$OpenBSD: nvme.c,v 1.49 2016/04/18 05:59:50 dlg Exp $ */
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.37 2018/03/17 09:45:44 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.38 2018/04/18 10:05:59 nonaka Exp $");
 
 #include 
 #include 
@@ -42,6 +42,8 @@ __KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.3
 
 #include "ioconf.h"
 
+#define	B4_CHK_RDY_DELAY_MS	2300	/* workaround controller bug */
+
 int nvme_adminq_size = 32;
 int nvme_ioq_size = 1024;
 
@@ -220,15 +222,6 @@ static int
 nvme_ready(struct nvme_softc *sc, uint32_t rdy)
 {
 	u_int i = 0;
-	uint32_t cc;
-
-	cc = nvme_read4(sc, NVME_CC);
-	if (((cc & NVME_CC_EN) != 0) != (rdy != 0)) {
-		aprint_error_dev(sc->sc_dev,
-		"controller enabled status expected %d, found to be %d\n",
-		(rdy != 0), ((cc & NVME_CC_EN) != 0));
-		return ENXIO;
-	}
 
 	while ((nvme_read4(sc, NVME_CSTS) & NVME_CSTS_RDY) != rdy) {
 		if (i++ > sc->sc_rdy_to)
@@ -245,17 +238,24 @@ static int
 nvme_enable(struct nvme_softc *sc, u_int mps)
 {
 	uint32_t cc, csts;
+	int error;
 
 	cc = nvme_read4(sc, NVME_CC);
 	csts = nvme_read4(sc, NVME_CSTS);
-	
-	if (ISSET(cc, NVME_CC_EN)) {
-		aprint_error_dev(sc->sc_dev, "controller unexpectedly enabled, failed to stay disabled\n");
 
+	/*
+	 * See note in nvme_disable. Short circuit if we're already enabled.
+	 */
+	if (ISSET(cc, NVME_CC_EN)) {
 		if (ISSET(csts, NVME_CSTS_RDY))
-			return 1;
+			return 0;
 
 		goto waitready;
+	} else {
+		/* EN == 0 already wait for RDY == 0 or fail */
+		error = nvme_ready(sc, 0);
+		if (error)
+			return error;
 	}
 
 	nvme_write8(sc, NVME_ASQ, NVME_DMA_DVA(sc->sc_admin_q->q_sq_dmamem));
@@ -282,7 +282,6 @@ nvme_enable(struct nvme_softc *sc, u_int
 	nvme_write4(sc, NVME_CC, cc);
 	nvme_barrier(sc, 0, sc->sc_ios,
 	BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE);
-	delay(5000);
 
 waitready:
 	return nvme_ready(sc, NVME_CSTS_RDY);
@@ -292,20 +291,44 @@ static int
 nvme_disable(struct nvme_softc *sc)
 {
 	uint32_t cc, csts;
+	int error;
 
 	cc = nvme_read4(sc, NVME_CC);
 	csts = nvme_read4(sc, NVME_CSTS);
 
-	if (ISSET(cc, NVME_CC_EN) && !ISSET(csts, NVME_CSTS_RDY))
-		nvme_ready(sc, NVME_CSTS_RDY);
+	/*
+	 * Per 3.1.5 in NVME 1.3 spec, transitioning CC.EN from 0 to 1
+	 * when CSTS.RDY is 1 or transitioning CC.EN from 1 to 0 when
+	 * CSTS.RDY is 0 "has undefined results" So make sure that CSTS.RDY
+	 * isn't the desired value. Short circuit if we're already disabled.
+	 */
+	if (ISSET(cc, NVME_CC_EN)) {
+		if (!ISSET(csts, NVME_CSTS_RDY)) {
+			/* EN == 1, wait for RDY == 1 or fail */
+			error = nvme_ready(sc, NVME_CSTS_RDY);
+			if (error)
+return error;
+		}
+	} else {
+		/* EN == 0 already wait for RDY == 0 */
+		if (!ISSET(csts, NVME_CSTS_RDY))
+			return 0;
 
-	CLR(cc, NVME_CC_EN);
+		goto waitready;
+	}
 
+	CLR(cc, NVME_CC_EN);
 	nvme_write4(sc, NVME_CC, cc);
 	nvme_barrier(sc, 0, sc->sc_ios, BUS_SPACE_BARRIER_READ);
-	
-	delay(5000);
 
+	/*
+	 * Some drives have issues with accessing the mmio after we disable,
+	 * so delay for a bit after we write the bit to cope with these issues.
+	 */
+	if (ISSET(sc->sc_quirks, NVME_QUIRK_DELAY_B4_CHK_RDY))
+		delay(B4_CHK_RDY_DELAY_MS);
+
+waitready:
 	return nvme_ready(sc, 0);
 }
 

Index: src/sys/dev/ic/nvmevar.h
diff -u src/sys/dev/ic/nvmevar.h:1.15 src/sys/dev/ic/nvmevar.h:1.16
--- src/sys/dev/ic/nvmevar.h:1.15	Fri Mar 16 23:31:19 2018
+++ src/sys/dev/ic/nvmevar.h	Wed Apr 18 10:05:59 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvmevar.h,v 1.15 2018/03/16 23:31:19 jdolecek Exp $	*/
+/*	$NetBSD: nvmevar.h,v 1.16 2018/04/18 10:05:59 nonaka Exp $	*/
 /*	$OpenBSD: nvmevar.h,v 1.8 2016/04/14 11:18:32 dlg Exp $ */
 
 /*
@@ -136,6 +136,9 @@ struct nvme_softc {
 	uint32_t		sc_flags;
 #define	NVME_F_ATTACHED	__BIT(0)
 #define	NVME_F_OPEN	__BIT(1)
+
+	uint32_t		sc_quirks;
+#define	NVME_QUIRK_DELAY_B4_CHK_RDY	__BIT(0)
 };
 
 #define	lemtoh16(p)	le16toh(*((uint16_t *)(p)))

Index: src/sys/dev/pci/nvme_pci.c
diff -u src/sys/dev/pci/nvme_pci.c:1.19 

CVS commit: src/sbin/nvmectl

2018-04-17 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Tue Apr 17 15:31:00 UTC 2018

Modified Files:
src/sbin/nvmectl: nvmectl.h

Log Message:
nvmectl(8): fix wdc command usage.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sbin/nvmectl/nvmectl.h

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

Modified files:

Index: src/sbin/nvmectl/nvmectl.h
diff -u src/sbin/nvmectl/nvmectl.h:1.6 src/sbin/nvmectl/nvmectl.h:1.7
--- src/sbin/nvmectl/nvmectl.h:1.6	Tue Apr 17 08:54:35 2018
+++ src/sbin/nvmectl/nvmectl.h	Tue Apr 17 15:31:00 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvmectl.h,v 1.6 2018/04/17 08:54:35 nonaka Exp $	*/
+/*	$NetBSD: nvmectl.h,v 1.7 2018/04/17 15:31:00 nonaka Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -81,7 +81,7 @@ struct nvme_function {
 "power [-l] [-p new-state [-w workload-hint]] \n"
 
 #define WDC_USAGE			   \
-"wdc (cap-diag|drive-log|get-crash-dump|purge|purge-montior)\n"
+"wdc cap-diag [-o path-templete]\n"
 
 void devlist(int, char *[]) __dead;
 void identify(int, char *[]) __dead;



CVS commit: src

2018-04-17 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Tue Apr 17 08:54:35 UTC 2018

Modified Files:
src/sbin/nvmectl: Makefile devlist.c firmware.c identify.c logpage.c
nvmectl.c nvmectl.h perftest.c reset.c wdc.c
src/sys/dev/ic: nvmereg.h
Added Files:
src/sbin/nvmectl: util.c

Log Message:
nvmectl(8): Sync with FreeBSD nvmecontrol(8) r328763.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sbin/nvmectl/Makefile src/sbin/nvmectl/devlist.c \
src/sbin/nvmectl/identify.c src/sbin/nvmectl/perftest.c
cvs rdiff -u -r1.2 -r1.3 src/sbin/nvmectl/firmware.c src/sbin/nvmectl/reset.c \
src/sbin/nvmectl/wdc.c
cvs rdiff -u -r1.5 -r1.6 src/sbin/nvmectl/logpage.c \
src/sbin/nvmectl/nvmectl.c src/sbin/nvmectl/nvmectl.h
cvs rdiff -u -r0 -r1.1 src/sbin/nvmectl/util.c
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/ic/nvmereg.h

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

Modified files:

Index: src/sbin/nvmectl/Makefile
diff -u src/sbin/nvmectl/Makefile:1.3 src/sbin/nvmectl/Makefile:1.4
--- src/sbin/nvmectl/Makefile:1.3	Sat Apr 29 00:06:40 2017
+++ src/sbin/nvmectl/Makefile	Tue Apr 17 08:54:35 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.3 2017/04/29 00:06:40 nonaka Exp $
+#	$NetBSD: Makefile,v 1.4 2018/04/17 08:54:35 nonaka Exp $
 
 .include 
 
@@ -11,6 +11,7 @@ SRCS+=	logpage.c
 SRCS+=	perftest.c
 SRCS+=	power.c
 SRCS+=	reset.c
+SRCS+=	util.c
 SRCS+=	wdc.c
 SRCS+=	bignum.c
 SRCS+=	humanize_bignum.c
Index: src/sbin/nvmectl/devlist.c
diff -u src/sbin/nvmectl/devlist.c:1.3 src/sbin/nvmectl/devlist.c:1.4
--- src/sbin/nvmectl/devlist.c:1.3	Sat Mar 17 11:07:26 2018
+++ src/sbin/nvmectl/devlist.c	Tue Apr 17 08:54:35 2018
@@ -1,6 +1,8 @@
-/*	$NetBSD: devlist.c,v 1.3 2018/03/17 11:07:26 jdolecek Exp $	*/
+/*	$NetBSD: devlist.c,v 1.4 2018/04/17 08:54:35 nonaka Exp $	*/
 
 /*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
  * Copyright (C) 2012-2013 Intel Corporation
  * All rights reserved.
  *
@@ -28,9 +30,9 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: devlist.c,v 1.3 2018/03/17 11:07:26 jdolecek Exp $");
+__RCSID("$NetBSD: devlist.c,v 1.4 2018/04/17 08:54:35 nonaka Exp $");
 #if 0
-__FBSDID("$FreeBSD: head/sbin/nvmecontrol/devlist.c 260381 2014-01-06 23:48:47Z jimharris $");
+__FBSDID("$FreeBSD: head/sbin/nvmecontrol/devlist.c 326276 2017-11-27 15:37:16Z pfg $");
 #endif
 #endif
 
Index: src/sbin/nvmectl/identify.c
diff -u src/sbin/nvmectl/identify.c:1.3 src/sbin/nvmectl/identify.c:1.4
--- src/sbin/nvmectl/identify.c:1.3	Sat Mar 17 11:07:26 2018
+++ src/sbin/nvmectl/identify.c	Tue Apr 17 08:54:35 2018
@@ -1,6 +1,8 @@
-/*	$NetBSD: identify.c,v 1.3 2018/03/17 11:07:26 jdolecek Exp $	*/
+/*	$NetBSD: identify.c,v 1.4 2018/04/17 08:54:35 nonaka Exp $	*/
 
 /*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
  * Copyright (C) 2012-2013 Intel Corporation
  * All rights reserved.
  *
@@ -28,9 +30,9 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: identify.c,v 1.3 2018/03/17 11:07:26 jdolecek Exp $");
+__RCSID("$NetBSD: identify.c,v 1.4 2018/04/17 08:54:35 nonaka Exp $");
 #if 0
-__FBSDID("$FreeBSD: head/sbin/nvmecontrol/identify.c 253476 2013-07-19 21:40:57Z jimharris $");
+__FBSDID("$FreeBSD: head/sbin/nvmecontrol/identify.c 326276 2017-11-27 15:37:16Z pfg $");
 #endif
 #endif
 
@@ -72,6 +74,7 @@ print_controller(struct nvm_identify_con
 		printf("Unlimited\n");
 	else
 		printf("%ld\n", sysconf(_SC_PAGESIZE) * (1 << cdata->mdts));
+	printf("Controller ID:  0x%02x\n", cdata->cntlid);
 	printf("\n");
 
 	printf("Admin Command Set Attributes\n");
@@ -85,6 +88,9 @@ print_controller(struct nvm_identify_con
 	printf("Firmware Activate/Download:  %s\n",
 		(cdata->oacs & NVME_ID_CTRLR_OACS_FW) ?
 		"Supported" : "Not Supported");
+	printf("Namespace Managment: %s\n",
+		(cdata->oacs & NVME_ID_CTRLR_OACS_NS) ?
+		"Supported" : "Not Supported");
 	printf("Abort Command Limit: %d\n", cdata->acl+1);
 	printf("Async Event Request Limit:   %d\n", cdata->aerl+1);
 	printf("Number of Firmware Slots:");
@@ -139,6 +145,16 @@ print_controller(struct nvm_identify_con
 	printf("Volatile Write Cache:%s\n",
 		(cdata->vwc & NVME_ID_CTRLR_VWC_PRESENT) ?
 		"Present" : "Not Present");
+
+	if (cdata->oacs & NVME_ID_CTRLR_OACS_NS) {
+		printf("\n");
+		printf("Namespace Drive Attributes\n");
+		printf("==\n");
+		print_bignum("NVM total cap:   ",
+		cdata->untncap.tnvmcap, "");
+		print_bignum("NVM unallocated cap: ",
+		cdata->untncap.unvmcap, "");
+	}
 }
 
 static void
Index: src/sbin/nvmectl/perftest.c
diff -u src/sbin/nvmectl/perftest.c:1.3 src/sbin/nvmectl/perftest.c:1.4
--- src/sbin/nvmectl/perftest.c:1.3	Sat Mar 17 11:07:26 2018
+++ src/sbin/nvmectl/perftest.c	Tue Apr 17 08:54:35 2018
@@ -1,6 +1,8 @@
-/*	$NetBSD: perftest.c,v 1.3 2018/03/17 11:07:26 jdolecek Exp $	*/
+/*	$NetBSD: perftest.c,v 1.4 2018/04/17 08:54:35 

CVS commit: src/sys/dev/pci

2018-04-17 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Tue Apr 17 08:47:44 UTC 2018

Modified Files:
src/sys/dev/pci: pcidevs.h pcidevs_data.h

Log Message:
regen


To generate a diff of this commit:
cvs rdiff -u -r1.1320 -r1.1321 src/sys/dev/pci/pcidevs.h
cvs rdiff -u -r1.1319 -r1.1320 src/sys/dev/pci/pcidevs_data.h

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

diffs are larger than 1MB and have been omitted


CVS commit: src/sys/dev/pci

2018-04-17 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Tue Apr 17 08:47:19 UTC 2018

Modified Files:
src/sys/dev/pci: pcidevs

Log Message:
Added some NVMe devices.


To generate a diff of this commit:
cvs rdiff -u -r1.1329 -r1.1330 src/sys/dev/pci/pcidevs

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

Modified files:

Index: src/sys/dev/pci/pcidevs
diff -u src/sys/dev/pci/pcidevs:1.1329 src/sys/dev/pci/pcidevs:1.1330
--- src/sys/dev/pci/pcidevs:1.1329	Mon Apr 16 13:11:53 2018
+++ src/sys/dev/pci/pcidevs	Tue Apr 17 08:47:19 2018
@@ -1,4 +1,4 @@
-$NetBSD: pcidevs,v 1.1329 2018/04/16 13:11:53 msaitoh Exp $
+$NetBSD: pcidevs,v 1.1330 2018/04/17 08:47:19 nonaka Exp $
 
 /*
  * Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -645,6 +645,8 @@ vendor MARVELL2		0x1b4b	Marvell
 vendor FRESCO		0x1b73	Fresco Logic
 vendor QINHENG2		0x1c00	Nanjing QinHeng Electronics (PCIe)
 vendor SYMPHONY2	0x1c1c	Symphony Labs (2nd PCI Vendor ID)
+vendor HGST		0x1c58	HGST, Inc.
+vendor BEIJING_MEMBLAZE	0x1c5f	Beijing Memblaze Technology Co. Ltd.
 vendor TEKRAM2		0x1de1	Tekram Technology (2nd PCI Vendor ID)
 vendor SUNIX2		0x1fd4	SUNIX Co
 vendor HINT		0x3388	HiNT
@@ -1742,6 +1744,9 @@ product BBELEC ISOLATED_2_PORT		0x4212	d
 product BBELEC ISOLATED_4_PORT		0x4214	quad-channel Isolated RS-485 PCI UART
 product BBELEC ISOLATED_8_PORT		0x4218	octal-channel Isolated RS-485 PCI UART
 
+/* Beijing Memblaze Technology Co. Ltd. products */
+product BEIJING_MEMBLAZE PBLAZE4	0x0540	PBlaze4 NVMe SSD
+
 /* Belkin products */
 product BELKIN F5D6001		0x6001	F5D6001
 product BELKIN F5D6020V3	0x6020	F5D6020v3 802.11b
@@ -2631,6 +2636,10 @@ product HP ILO3_SLAVE		0x3306	iLO3 Slave
 product HP ILO3_MGMT		0x3307	iLO3 Management
 product HP RS780_PPB_GFX	0x9602  (AMD) RS780 PCI-PCI Bridge (int gfx)
 
+/* HGST Inc. products */
+product HGST SN100	0x0003	Ultrastar SN100 Series NVMe SSD
+product HGST SN200	0x0023	Ultrastar SN200 Series NVMe SSD
+
 /* Hifn products */
 product HIFN 7751	0x0005	7751
 product HIFN 6500	0x0006	6500
@@ -6616,6 +6625,8 @@ product SAFENET SAFEXCEL	0x1141 SafeXcel
 product SAMSUNGELEC3	XP941		0xa800	XP941 M.2 SSD
 product SAMSUNGELEC3	SM951		0xa801	SM951 M.2 SSD
 product SAMSUNGELEC3	SM951_NVME	0xa802	SM951 M.2 NVMe SSD
+product SAMSUNGELEC3	172X		0xa821	NVMe SSD Controller 172X
+product SAMSUNGELEC3	172XAB		0xa822	NVMe SSD Controller 172Xa/172Xb
 
 /* Samsung Semiconductor products */
 product SAMSUNGSEMI	KS8920	0x8920	KS8920 10/100 Ethernet



CVS commit: src/sys/arch/x86/pci

2018-04-16 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Mon Apr 16 09:12:52 UTC 2018

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

Log Message:
vmx(4): compute if_ibytes using rxq->vxrxq_stats.vmrxs_ibytes.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 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.23 src/sys/arch/x86/pci/if_vmx.c:1.24
--- src/sys/arch/x86/pci/if_vmx.c:1.23	Mon Apr 16 09:10:42 2018
+++ src/sys/arch/x86/pci/if_vmx.c	Mon Apr 16 09:12:52 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vmx.c,v 1.23 2018/04/16 09:10:42 nonaka Exp $	*/
+/*	$NetBSD: if_vmx.c,v 1.24 2018/04/16 09:12:52 nonaka 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.23 2018/04/16 09:10:42 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.24 2018/04/16 09:12:52 nonaka Exp $");
 
 #include 
 #include 
@@ -2894,6 +2894,7 @@ vmxnet3_ioctl(struct ifnet *ifp, u_long 
 	case SIOCGIFDATA:
 	case SIOCZIFDATA:
 		ifp->if_ipackets = 0;
+		ifp->if_ibytes = 0;
 		ifp->if_iqdrops = 0;
 		ifp->if_ierrors = 0;
 		for (int i = 0; i < sc->vmx_nrxqueues; i++) {
@@ -2901,6 +2902,7 @@ vmxnet3_ioctl(struct ifnet *ifp, u_long 
 
 			VMXNET3_RXQ_LOCK(rxq);
 			ifp->if_ipackets += rxq->vxrxq_stats.vmrxs_ipackets;
+			ifp->if_ibytes += rxq->vxrxq_stats.vmrxs_ibytes;
 			ifp->if_iqdrops += rxq->vxrxq_stats.vmrxs_iqdrops;
 			ifp->if_ierrors += rxq->vxrxq_stats.vmrxs_ierrors;
 			if (cmd == SIOCZIFDATA) {



CVS commit: src/sys/arch/x86/pci

2018-04-16 Thread NONAKA Kimihiro
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 
-__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 
 #include 
@@ -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 = >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(>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 = >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(>vxtxq_stats, 0,
+sizeof(txq->vxtxq_stats));
+			}
+			VMXNET3_TXQ_UNLOCK(txq);
 		}
 		/* FALLTHROUGH */
 	default:



CVS commit: src/sys/arch/x86/pci

2018-04-15 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Mon Apr 16 03:21:43 UTC 2018

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

Log Message:
vmx(4): Fix calculation of interface statistics counter.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 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.21 src/sys/arch/x86/pci/if_vmx.c:1.22
--- src/sys/arch/x86/pci/if_vmx.c:1.21	Mon Feb 12 17:01:22 2018
+++ src/sys/arch/x86/pci/if_vmx.c	Mon Apr 16 03:21:43 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vmx.c,v 1.21 2018/02/12 17:01:22 maxv Exp $	*/
+/*	$NetBSD: if_vmx.c,v 1.22 2018/04/16 03:21:43 nonaka 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.21 2018/02/12 17:01:22 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.22 2018/04/16 03:21:43 nonaka Exp $");
 
 #include 
 #include 
@@ -2892,20 +2892,26 @@ vmxnet3_ioctl(struct ifnet *ifp, u_long 
 		splx(s);
 		break;
 	case SIOCGIFDATA:
+		ifp->if_ipackets = 0;
+		ifp->if_iqdrops = 0;
+		ifp->if_ierrors = 0;
 		for (int i = 0; i < sc->vmx_nrxqueues; i++) {
-			ifp->if_ipackets =
+			ifp->if_ipackets +=
 			sc->vmx_rxq[i].vxrxq_stats.vmrxs_ipackets;
-			ifp->if_iqdrops =
+			ifp->if_iqdrops +=
 			sc->vmx_rxq[i].vxrxq_stats.vmrxs_iqdrops;
-			ifp->if_ierrors =
+			ifp->if_ierrors +=
 			sc->vmx_rxq[i].vxrxq_stats.vmrxs_ierrors;
 		}
+		ifp->if_opackets = 0;
+		ifp->if_obytes = 0;
+		ifp->if_omcasts = 0;
 		for (int i = 0; i < sc->vmx_ntxqueues; i++) {
-			ifp->if_opackets =
+			ifp->if_opackets +=
 			sc->vmx_txq[i].vxtxq_stats.vmtxs_opackets;
-			ifp->if_obytes =
+			ifp->if_obytes +=
 			sc->vmx_txq[i].vxtxq_stats.vmtxs_obytes;
-			ifp->if_omcasts =
+			ifp->if_omcasts +=
 			sc->vmx_txq[i].vxtxq_stats.vmtxs_omcasts;
 		}
 		/* FALLTHROUGH */



CVS commit: src/sys/arch/x86/include

2018-04-13 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Fri Apr 13 11:24:34 UTC 2018

Modified Files:
src/sys/arch/x86/include: bootinfo.h

Log Message:
x86: Increase BOOTINFO_MAXSIZE to 8Kib.

Proposed on port-i386 and port-amd64 with no objections:
http://mail-index.netbsd.org/port-i386/2018/04/11/msg003692.html
http://mail-index.netbsd.org/port-amd64/2018/04/11/msg002697.html


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/x86/include/bootinfo.h

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/include/bootinfo.h
diff -u src/sys/arch/x86/include/bootinfo.h:1.28 src/sys/arch/x86/include/bootinfo.h:1.29
--- src/sys/arch/x86/include/bootinfo.h:1.28	Thu Nov  9 01:01:33 2017
+++ src/sys/arch/x86/include/bootinfo.h	Fri Apr 13 11:24:34 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: bootinfo.h,v 1.28 2017/11/09 01:01:33 christos Exp $	*/
+/*	$NetBSD: bootinfo.h,v 1.29 2018/04/13 11:24:34 nonaka Exp $	*/
 
 /*
  * Copyright (c) 1997
@@ -251,7 +251,7 @@ struct btinfo_efimemmap {
 
 #ifdef _KERNEL
 
-#define BOOTINFO_MAXSIZE 4096
+#define BOOTINFO_MAXSIZE 8192
 
 #ifndef _LOCORE
 /*



CVS commit: src/sys/arch/x86/pci

2018-04-11 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Wed Apr 11 10:34:20 UTC 2018

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

Log Message:
efiboot reports parent ppb bus/device/function of booted network inteface.


To generate a diff of this commit:
cvs rdiff -u -r1.79 -r1.80 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.79 src/sys/arch/x86/pci/pci_machdep.c:1.80
--- src/sys/arch/x86/pci/pci_machdep.c:1.79	Thu Jun  1 02:45:08 2017
+++ src/sys/arch/x86/pci/pci_machdep.c	Wed Apr 11 10:34:19 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_machdep.c,v 1.79 2017/06/01 02:45:08 chs Exp $	*/
+/*	$NetBSD: pci_machdep.c,v 1.80 2018/04/11 10:34:19 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.79 2017/06/01 02:45:08 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.80 2018/04/11 10:34:19 nonaka Exp $");
 
 #include 
 #include 
@@ -98,6 +98,7 @@ __KERNEL_RCSID(0, "$NetBSD: pci_machdep.
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -149,6 +150,10 @@ __KERNEL_RCSID(0, "$NetBSD: pci_machdep.
 #include 
 #endif
 
+#ifndef XEN
+#include 
+#endif
+
 #include "opt_pci_conf_mode.h"
 
 #ifdef PCI_CONF_MODE
@@ -1016,6 +1021,7 @@ device_t
 device_pci_register(device_t dev, void *aux)
 {
 	static bool found_console = false;
+	device_t parent = device_parent(dev);
 
 	device_pci_props_register(dev, aux);
 
@@ -1037,8 +1043,7 @@ device_pci_register(device_t dev, void *
 		 * information (checked below) must be sufficient to
 		 * identify the device.
 		 */
-		if (bin->bus == BI_BUS_PCI &&
-		device_is_a(device_parent(dev), "pci")) {
+		if (bin->bus == BI_BUS_PCI && device_is_a(parent, "pci")) {
 			struct pci_attach_args *paa = aux;
 			int b, d, f;
 
@@ -1052,9 +1057,23 @@ device_pci_register(device_t dev, void *
 			pci_decompose_tag(paa->pa_pc, paa->pa_tag, , , );
 			if (bin->addr.tag == ((b << 8) | (d << 3) | f))
 return dev;
+
+#ifndef XEN
+			/*
+			 * efiboot reports parent ppb bus/device/function.
+			 */
+			device_t grand = device_parent(parent);
+			if (efi_probe() && grand && device_is_a(grand, "ppb")) {
+struct ppb_softc *ppb_sc = device_private(grand);
+pci_decompose_tag(ppb_sc->sc_pc, ppb_sc->sc_tag,
+, , );
+if (bin->addr.tag == ((b << 8) | (d << 3) | f))
+	return dev;
+			}
+#endif
 		}
 	}
-	if (device_parent(dev) && device_is_a(device_parent(dev), "pci") &&
+	if (parent && device_is_a(parent, "pci") &&
 	found_console == false) {
 		struct btinfo_framebuffer *fbinfo;
 		struct pci_attach_args *pa = aux;



CVS commit: src/sys/arch/i386/stand/efiboot

2018-04-11 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Wed Apr 11 10:32:10 UTC 2018

Modified Files:
src/sys/arch/i386/stand/efiboot: Makefile.efiboot boot.c conf.c
devopen.c devopen.h efiboot.c efiboot.h efidisk.c
Added Files:
src/sys/arch/i386/stand/efiboot: dev_net.c efinet.c efinet.h efipxe.c

Log Message:
efiboot: Added network boot support.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/i386/stand/efiboot/Makefile.efiboot
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/i386/stand/efiboot/boot.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/i386/stand/efiboot/conf.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/i386/stand/efiboot/dev_net.c \
src/sys/arch/i386/stand/efiboot/efinet.c \
src/sys/arch/i386/stand/efiboot/efinet.h \
src/sys/arch/i386/stand/efiboot/efipxe.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/i386/stand/efiboot/devopen.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/i386/stand/efiboot/devopen.h
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/i386/stand/efiboot/efiboot.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/i386/stand/efiboot/efiboot.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/i386/stand/efiboot/efidisk.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/i386/stand/efiboot/Makefile.efiboot
diff -u src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.11 src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.12
--- src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.11	Tue Mar 27 14:15:05 2018
+++ src/sys/arch/i386/stand/efiboot/Makefile.efiboot	Wed Apr 11 10:32:09 2018
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.efiboot,v 1.11 2018/03/27 14:15:05 nonaka Exp $
+# $NetBSD: Makefile.efiboot,v 1.12 2018/04/11 10:32:09 nonaka Exp $
 
 S=		${.CURDIR}/../../../../..
 
@@ -8,12 +8,12 @@ NEWVERSWHAT?=	"EFI Boot"
 
 AFLAGS.start.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:}
 
-SOURCES?= start.S conf.c devopen.c efiboot.c self_reloc.c
-LIBI386SRCS= boot.c biosdisk.c bootinfo.c bootinfo_biosgeom.c
-LIBI386SRCS+= bootmenu.c diskbuf.c exec.c menuutils.c
-LIBI386SRCS+= panic.c parseutils.c pread.c
-LIBI386SRCS+= efichar.c eficons.c efidelay.c efidev.c efidisk.c efidisk_ll.c
-LIBI386SRCS+= efigetsecs.c efimemory.c
+SOURCES= start.S boot.c conf.c devopen.c dev_net.c self_reloc.c panic.c
+SOURCES+= efiboot.c efichar.c eficons.c efidelay.c efidev.c
+SOURCES+= efidisk.c efidisk_ll.c efigetsecs.c efimemory.c
+SOURCES+= efinet.c efipxe.c
+LIBI386SRCS= biosdisk.c bootinfo.c bootinfo_biosgeom.c bootmenu.c
+LIBI386SRCS+= diskbuf.c exec.c menuutils.c parseutils.c pread.c
 SRCS= ${SOURCES} ${EXTRA_SOURCES} ${LIBI386SRCS}
 
 PIE_CFLAGS=
@@ -57,10 +57,22 @@ CPPFLAGS+= -DSUPPORT_CD9660
 CPPFLAGS+= -D"devb2cdb(bno)=(bno)"
 CPPFLAGS+= -DSUPPORT_DOSFS
 CPPFLAGS+= -DSUPPORT_EXT2FS
+CPPFLAGS+= -DSUPPORT_BOOTP
+CPPFLAGS+= -DSUPPORT_DHCP
+CPPFLAGS+= -DSUPPORT_NFS
+#CPPFLAGS+= -DSUPPORT_TFTP
 CPPFLAGS+= -DPASS_BIOSGEOM
 CPPFLAGS+= -DBIOSDISK_DEFAULT_SECSIZE=2048	# for bootinfo_biosgeom.c
 CPPFLAGS+= -DLIBSA_ENABLE_LS_OP
 
+#CPPFLAGS+= -DARP_DEBUG
+#CPPFLAGS+= -DBOOTP_DEBUG
+#CPPFLAGS+= -DNET_DEBUG
+#CPPFLAGS+= -DNETIF_DEBUG
+#CPPFLAGS+= -DNFS_DEBUG
+#CPPFLAGS+= -DRARP_DEBUG
+#CPPFLAGS+= -DRPC_DEBUG
+
 EFIDIR= ${S}/external/bsd/gnu-efi/dist
 GNUEFIARCH?= ${MACHINE_CPU}
 CPPFLAGS+= -I${EFIDIR}/inc -I${EFIDIR}/inc/${GNUEFIARCH}
@@ -69,12 +81,12 @@ CPPFLAGS+= -I${EFIDIR}/inc/protocol
 SAMISCCPPFLAGS+= -DLIBSA_PRINTF_LONGLONG_SUPPORT
 SAMISCCPPFLAGS+= -DLIBSA_PRINTF_WIDTH_SUPPORT
 SAMISCCPPFLAGS+= -D"cdb2devb(bno)=(bno)"
-SAMISCMAKEFLAGS+= SA_USE_CREAD=yes  # Read compressed kernels
-SAMISCMAKEFLAGS+= SA_INCLUDE_NET=no # Netboot via TFTP, NFS
 
 ### find out what to use for libsa
 SA_AS= library
 SAMISCMAKEFLAGS+="SA_USE_LOADFILE=yes"
+SAMISCMAKEFLAGS+="SA_USE_CREAD=yes"
+SAMISCMAKEFLAGS+="SA_INCLUDE_NET=yes"
 SAMISCMAKEFLAGS+="SA_ENABLE_LS_OP=yes"
 .include "${S}/lib/libsa/Makefile.inc"
 LIBSA= ${SALIB}

Index: src/sys/arch/i386/stand/efiboot/boot.c
diff -u src/sys/arch/i386/stand/efiboot/boot.c:1.9 src/sys/arch/i386/stand/efiboot/boot.c:1.10
--- src/sys/arch/i386/stand/efiboot/boot.c:1.9	Mon Apr  2 09:44:18 2018
+++ src/sys/arch/i386/stand/efiboot/boot.c	Wed Apr 11 10:32:09 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot.c,v 1.9 2018/04/02 09:44:18 nonaka Exp $	*/
+/*	$NetBSD: boot.c,v 1.10 2018/04/11 10:32:09 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -182,6 +182,21 @@ parsebootfile(const char *fname, char **
 }
 
 static char *
+snprint_bootdev(char *buf, size_t bufsize, const char *devname, int unit,
+int partition)
+{
+	static const char *no_partition_devs[] = { "esp", "net", "nfs", "tftp" };
+	int i;
+
+	for (i = 0; i < __arraycount(no_partition_devs); i++)
+		if (strcmp(devname, no_partition_devs[i]) == 0)
+			break;
+	snprintf(buf, bufsize, "%s%d%c", devname, unit,
+	i < __arraycount(no_partition_devs) ? '\0' : 'a' + partition);
+	return buf;
+}
+
+static char *
 

CVS commit: src/sys

2018-04-02 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Mon Apr  2 09:44:19 UTC 2018

Modified Files:
src/sys/arch/i386/stand/efiboot: TODO.efiboot boot.c devopen.c
devopen.h efidisk.c efidisk.h
src/sys/arch/i386/stand/lib: biosdisk.c biosdisk.h bootmenu.c
bootmenu.h
src/sys/lib/libsa: bootcfg.c bootcfg.h

Log Message:
efiboot: try to read boot.cfg from /EFI/NetBSD on ESP of the booted disk.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/i386/stand/efiboot/TODO.efiboot \
src/sys/arch/i386/stand/efiboot/efidisk.c
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/i386/stand/efiboot/boot.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/i386/stand/efiboot/devopen.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/i386/stand/efiboot/devopen.h
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/i386/stand/efiboot/efidisk.h
cvs rdiff -u -r1.48 -r1.49 src/sys/arch/i386/stand/lib/biosdisk.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/i386/stand/lib/biosdisk.h
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/i386/stand/lib/bootmenu.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/i386/stand/lib/bootmenu.h
cvs rdiff -u -r1.2 -r1.3 src/sys/lib/libsa/bootcfg.c
cvs rdiff -u -r1.1 -r1.2 src/sys/lib/libsa/bootcfg.h

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/i386/stand/efiboot/TODO.efiboot
diff -u src/sys/arch/i386/stand/efiboot/TODO.efiboot:1.4 src/sys/arch/i386/stand/efiboot/TODO.efiboot:1.5
--- src/sys/arch/i386/stand/efiboot/TODO.efiboot:1.4	Thu Mar  8 10:34:33 2018
+++ src/sys/arch/i386/stand/efiboot/TODO.efiboot	Mon Apr  2 09:44:18 2018
@@ -1,6 +1,5 @@
 - efiboot
  * handle UEFI variables
- * load boot.cfg from EFI system partition (FAT32)
 
 - kernel
  * handle UEFI variables (/dev/efivar)
Index: src/sys/arch/i386/stand/efiboot/efidisk.c
diff -u src/sys/arch/i386/stand/efiboot/efidisk.c:1.4 src/sys/arch/i386/stand/efiboot/efidisk.c:1.5
--- src/sys/arch/i386/stand/efiboot/efidisk.c:1.4	Tue Mar 27 14:15:05 2018
+++ src/sys/arch/i386/stand/efiboot/efidisk.c	Mon Apr  2 09:44:18 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: efidisk.c,v 1.4 2018/03/27 14:15:05 nonaka Exp $	*/
+/*	$NetBSD: efidisk.c,v 1.5 2018/04/02 09:44:18 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -213,3 +213,37 @@ get_harddrives(void)
 {
 	return nefidisks;
 }
+
+int
+efidisk_get_efi_system_partition(int dev, int *partition)
+{
+	extern const struct uuid GET_efi;
+	const struct efidiskinfo *edi;
+	struct biosdisk_partition *part;
+	int i, nparts;
+
+	edi = efidisk_getinfo(dev);
+	if (edi == NULL)
+		return ENXIO;
+
+	if (edi->type != BIOSDISK_TYPE_HD)
+		return ENOTSUP;
+
+	if (biosdisk_readpartition(edi->dev, , ))
+		return EIO;
+
+	for (i = 0; i < nparts; i++) {
+		if (part[i].size == 0)
+			continue;
+		if (part[i].fstype == FS_UNUSED)
+			continue;
+		if (guid_is_equal(part[i].guid->guid, _efi))
+			break;
+	}
+	dealloc(part, sizeof(*part) * nparts);
+	if (i == nparts)
+		return ENOENT;
+
+	*partition = i;
+	return 0;
+}

Index: src/sys/arch/i386/stand/efiboot/boot.c
diff -u src/sys/arch/i386/stand/efiboot/boot.c:1.8 src/sys/arch/i386/stand/efiboot/boot.c:1.9
--- src/sys/arch/i386/stand/efiboot/boot.c:1.8	Tue Mar 27 14:15:05 2018
+++ src/sys/arch/i386/stand/efiboot/boot.c	Mon Apr  2 09:44:18 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot.c,v 1.8 2018/03/27 14:15:05 nonaka Exp $	*/
+/*	$NetBSD: boot.c,v 1.9 2018/04/02 09:44:18 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -55,7 +55,9 @@ static const char * const names[][2] = {
 #define NUMNAMES	__arraycount(names)
 #define DEFFILENAME	names[0][0]
 
-#define	MAXDEVNAME	16
+#ifndef	EFIBOOTCFG_FILENAME
+#define	EFIBOOTCFG_FILENAME	"esp:/EFI/NetBSD/boot.cfg"
+#endif
 
 void	command_help(char *);
 void	command_quit(char *);
@@ -273,6 +275,10 @@ boot(void)
 	default_filename = DEFFILENAME;
 
 	if (!(boot_params.bp_flags & X86_BP_FLAGS_NOBOOTCONF)) {
+#ifdef EFIBOOTCFG_FILENAME
+		int rv = parsebootconf(EFIBOOTCFG_FILENAME);
+		if (rv)
+#endif
 		parsebootconf(BOOTCFG_FILENAME);
 	} else {
 		bootcfg_info.timeout = boot_params.bp_timeout;

Index: src/sys/arch/i386/stand/efiboot/devopen.c
diff -u src/sys/arch/i386/stand/efiboot/devopen.c:1.3 src/sys/arch/i386/stand/efiboot/devopen.c:1.4
--- src/sys/arch/i386/stand/efiboot/devopen.c:1.3	Tue Mar 20 10:16:17 2018
+++ src/sys/arch/i386/stand/efiboot/devopen.c	Mon Apr  2 09:44:18 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: devopen.c,v 1.3 2018/03/20 10:16:17 nonaka Exp $	 */
+/*	$NetBSD: devopen.c,v 1.4 2018/04/02 09:44:18 nonaka Exp $	 */
 
 /*-
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -59,6 +59,7 @@
 #include 
 #include "devopen.h"
 #include 
+#include "efidisk.h"
 
 static int
 dev2bios(char *devname, int unit, int *biosdev)
@@ -103,9 +104,20 @@ devopen(struct open_file *f, const char 
 	int biosdev;
 	int error;
 
-	if ((error = parsebootfile(fname, , ,
-   , , (const 

CVS commit: src/usr.sbin/makefs/cd9660

2018-03-28 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Wed Mar 28 06:48:55 UTC 2018

Modified Files:
src/usr.sbin/makefs/cd9660: cd9660_eltorito.c

Log Message:
Correctly mark the last El Torito section header.

Pointed out by Benno Rice via DM.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/usr.sbin/makefs/cd9660/cd9660_eltorito.c

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

Modified files:

Index: src/usr.sbin/makefs/cd9660/cd9660_eltorito.c
diff -u src/usr.sbin/makefs/cd9660/cd9660_eltorito.c:1.22 src/usr.sbin/makefs/cd9660/cd9660_eltorito.c:1.23
--- src/usr.sbin/makefs/cd9660/cd9660_eltorito.c:1.22	Thu Nov  9 01:28:05 2017
+++ src/usr.sbin/makefs/cd9660/cd9660_eltorito.c	Wed Mar 28 06:48:55 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: cd9660_eltorito.c,v 1.22 2017/11/09 01:28:05 nonaka Exp $	*/
+/*	$NetBSD: cd9660_eltorito.c,v 1.23 2018/03/28 06:48:55 nonaka Exp $	*/
 
 /*
  * Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
@@ -40,7 +40,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: cd9660_eltorito.c,v 1.22 2017/11/09 01:28:05 nonaka Exp $");
+__RCSID("$NetBSD: cd9660_eltorito.c,v 1.23 2018/03/28 06:48:55 nonaka Exp $");
 #endif  /* !__lint */
 
 #ifdef DEBUG
@@ -497,6 +497,12 @@ cd9660_setup_boot(iso9660_disk *diskStru
 		LIST_INSERT_AFTER(head, temp, ll_struct);
 	}
 
+	/* Find the last Section Header entry and mark it as the last. */
+	head = NULL;
+	LIST_FOREACH(next, >boot_entries, ll_struct) {
+		if (next->entry_type == ET_ENTRY_SH)
+			head = next;
+	}
 	if (head != NULL)
 		head->entry_data.SH.header_indicator[0] = ET_SECTION_HEADER_LAST;
 



CVS commit: src/sys/arch/i386/stand/efiboot

2018-03-27 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Tue Mar 27 14:15:05 UTC 2018

Modified Files:
src/sys/arch/i386/stand/efiboot: Makefile.efiboot boot.c efiboot.c
efiboot.h eficons.c efidelay.c efidisk.c efimemory.c
src/sys/arch/i386/stand/efiboot/bootia32: efibootia32.c
src/sys/arch/i386/stand/efiboot/bootx64: efibootx64.c
Added Files:
src/sys/arch/i386/stand/efiboot: efichar.c

Log Message:
efiboot: Added serial console support.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/i386/stand/efiboot/Makefile.efiboot
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/i386/stand/efiboot/boot.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/i386/stand/efiboot/efiboot.c
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/i386/stand/efiboot/efiboot.h
cvs rdiff -u -r0 -r1.1 src/sys/arch/i386/stand/efiboot/efichar.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/i386/stand/efiboot/eficons.c \
src/sys/arch/i386/stand/efiboot/efimemory.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/i386/stand/efiboot/efidelay.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/i386/stand/efiboot/efidisk.c
cvs rdiff -u -r1.3 -r1.4 \
src/sys/arch/i386/stand/efiboot/bootia32/efibootia32.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/i386/stand/efiboot/bootx64/efibootx64.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/i386/stand/efiboot/Makefile.efiboot
diff -u src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.10 src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.11
--- src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.10	Thu Mar  8 10:34:33 2018
+++ src/sys/arch/i386/stand/efiboot/Makefile.efiboot	Tue Mar 27 14:15:05 2018
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.efiboot,v 1.10 2018/03/08 10:34:33 nonaka Exp $
+# $NetBSD: Makefile.efiboot,v 1.11 2018/03/27 14:15:05 nonaka Exp $
 
 S=		${.CURDIR}/../../../../..
 
@@ -12,7 +12,7 @@ SOURCES?= start.S conf.c devopen.c efibo
 LIBI386SRCS= boot.c biosdisk.c bootinfo.c bootinfo_biosgeom.c
 LIBI386SRCS+= bootmenu.c diskbuf.c exec.c menuutils.c
 LIBI386SRCS+= panic.c parseutils.c pread.c
-LIBI386SRCS+= eficons.c efidelay.c efidev.c efidisk.c efidisk_ll.c
+LIBI386SRCS+= efichar.c eficons.c efidelay.c efidev.c efidisk.c efidisk_ll.c
 LIBI386SRCS+= efigetsecs.c efimemory.c
 SRCS= ${SOURCES} ${EXTRA_SOURCES} ${LIBI386SRCS}
 

Index: src/sys/arch/i386/stand/efiboot/boot.c
diff -u src/sys/arch/i386/stand/efiboot/boot.c:1.7 src/sys/arch/i386/stand/efiboot/boot.c:1.8
--- src/sys/arch/i386/stand/efiboot/boot.c:1.7	Tue Mar 20 10:18:10 2018
+++ src/sys/arch/i386/stand/efiboot/boot.c	Tue Mar 27 14:15:05 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot.c,v 1.7 2018/03/20 10:18:10 nonaka Exp $	*/
+/*	$NetBSD: boot.c,v 1.8 2018/03/27 14:15:05 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -463,11 +463,16 @@ command_consdev(char *arg)
 	char *sep, *sep2 = NULL;
 	int ioport, speed = 0;
 
+	if (*arg == '\0') {
+		efi_cons_show();
+		return;
+	}
+
 	sep = strchr(arg, ',');
 	if (sep != NULL) {
 		*sep++ = '\0';
 		sep2 = strchr(sep, ',');
-		if (sep != NULL)
+		if (sep2 != NULL)
 			*sep2++ = '\0';
 	}
 
@@ -555,6 +560,8 @@ void
 command_version(char *arg)
 {
 	CHAR16 *path;
+	char *upath, *ufirmware;
+	int rv;
 
 	if (strcmp(arg, "full") == 0) {
 		printf("ImageBase: 0x%" PRIxPTR "\n",
@@ -562,12 +569,24 @@ command_version(char *arg)
 		printf("Stack: 0x%" PRIxPTR "\n", efi_main_sp);
 		printf("EFI version: %d.%02d\n",
 		ST->Hdr.Revision >> 16, ST->Hdr.Revision & 0x);
-		Print(L"EFI Firmware: %s (rev %d.%02d)\n", ST->FirmwareVendor,
-		ST->FirmwareRevision >> 16, ST->FirmwareRevision & 0x);
+		ufirmware = NULL;
+		rv = ucs2_to_utf8(ST->FirmwareVendor, );
+		if (rv == 0) {
+			printf("EFI Firmware: %s (rev %d.%02d)\n", ufirmware,
+			ST->FirmwareRevision >> 16,
+			ST->FirmwareRevision & 0x);
+			FreePool(ufirmware);
+		}
 		path = DevicePathToStr(efi_bootdp);
-		Print(L"Boot DevicePath: %d:%d:%s\n", DevicePathType(efi_bootdp),
-		DevicePathSubType(efi_bootdp), path);
+		upath = NULL;
+		rv = ucs2_to_utf8(path, );
 		FreePool(path);
+		if (rv == 0) {
+			printf("Boot DevicePath: %d:%d:%s\n",
+			DevicePathType(efi_bootdp),
+			DevicePathSubType(efi_bootdp), upath);
+			FreePool(upath);
+		}
 	}
 
 	printf("\n"
@@ -603,7 +622,9 @@ command_devpath(char *arg)
 	EFI_HANDLE *handles;
 	EFI_DEVICE_PATH *dp0, *dp;
 	CHAR16 *path;
+	char *upath;
 	UINTN cols, rows, row = 0;
+	int rv;
 
 	status = uefi_call_wrapper(ST->ConOut->QueryMode, 4, ST->ConOut,
 	ST->ConOut->Mode->Mode, , );
@@ -626,41 +647,54 @@ command_devpath(char *arg)
 		if (EFI_ERROR(status))
 			break;
 
-		Print(L"DevicePathType %d\n", DevicePathType(dp0));
+		printf("DevicePathType %d\n", DevicePathType(dp0));
 		if (++row >= rows) {
 			row = 0;
-			Print(L"Press Any Key to continue :");
+			printf("Press Any Key to continue :");
 			(void) awaitkey(-1, 0);
-			

CVS commit: src/sys/dev/pci

2018-03-20 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Tue Mar 20 11:23:06 UTC 2018

Modified Files:
src/sys/dev/pci: pcidevs

Log Message:
Add Intel Wireless AC 9260.


To generate a diff of this commit:
cvs rdiff -u -r1.1320 -r1.1321 src/sys/dev/pci/pcidevs

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

Modified files:

Index: src/sys/dev/pci/pcidevs
diff -u src/sys/dev/pci/pcidevs:1.1320 src/sys/dev/pci/pcidevs:1.1321
--- src/sys/dev/pci/pcidevs:1.1320	Fri Mar 16 08:40:06 2018
+++ src/sys/dev/pci/pcidevs	Tue Mar 20 11:23:06 2018
@@ -1,4 +1,4 @@
-$NetBSD: pcidevs,v 1.1320 2018/03/16 08:40:06 msaitoh Exp $
+$NetBSD: pcidevs,v 1.1321 2018/03/20 11:23:06 nonaka Exp $
 
 /*
  * Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -3738,6 +3738,7 @@ product INTEL WIFI_LINK_3168	0x24fb	Dual
 product INTEL WIFI_LINK_8265	0x24fd	Dual Band Wireless AC 8265
 product INTEL 82820_MCH		0x2501	82820 MCH (Camino)
 product INTEL 82820_AGP		0x250f	82820 AGP
+product INTEL WIFI_LINK_9260	0x2526	Wireless AC 9260
 product INTEL 82850_HB		0x2530	82850 Host
 product INTEL 82860_HB		0x2531	82860 Host
 product INTEL 82850_AGP		0x2532	82850/82860 AGP



CVS commit: src/sys/arch/i386/stand/lib

2018-03-20 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Tue Mar 20 10:21:01 UTC 2018

Modified Files:
src/sys/arch/i386/stand/lib: biosdisk.c

Log Message:
efiboot: fix to find boot partition process.

NetBSD related partitions with no bootme flag set are also candidates
for boot partition.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/sys/arch/i386/stand/lib/biosdisk.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/i386/stand/lib/biosdisk.c
diff -u src/sys/arch/i386/stand/lib/biosdisk.c:1.47 src/sys/arch/i386/stand/lib/biosdisk.c:1.48
--- src/sys/arch/i386/stand/lib/biosdisk.c:1.47	Thu Mar  8 10:34:33 2018
+++ src/sys/arch/i386/stand/lib/biosdisk.c	Tue Mar 20 10:21:01 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: biosdisk.c,v 1.47 2018/03/08 10:34:33 nonaka Exp $	*/
+/*	$NetBSD: biosdisk.c,v 1.48 2018/03/20 10:21:01 nonaka Exp $	*/
 
 /*
  * Copyright (c) 1996, 1998
@@ -802,20 +802,21 @@ biosdisk_findpartition(int biosdev, dadd
 			if (d->part[partition].fstype == FS_UNUSED)
 continue;
 #ifdef EFIBOOT
-			if (d->part[partition].attr & GPT_ENT_ATTR_BOOTME) {
-switch (d->part[partition].fstype) {
-case FS_BSDFFS:
-case FS_BSDLFS:
-case FS_RAID:
-case FS_CCD:
-case FS_CGD:
-case FS_ISO9660:
-	break;
+			switch (d->part[partition].fstype) {
+			case FS_BSDFFS:
+			case FS_BSDLFS:
+			case FS_RAID:
+			case FS_CCD:
+			case FS_CGD:
+			case FS_ISO9660:
+if (d->part[partition].attr & GPT_ENT_ATTR_BOOTME)
+	goto found;
+candidate = partition;
+break;
 
-default:
+			default:
+if (d->part[partition].attr & GPT_ENT_ATTR_BOOTME)
 	candidate = partition;
-	continue;
-}
 break;
 			}
 #else
@@ -824,6 +825,7 @@ biosdisk_findpartition(int biosdev, dadd
 #endif
 		}
 #ifdef EFIBOOT
+found:
 		if (partition == 0 && candidate != 0)
 			partition = candidate;
 #endif



CVS commit: src/sys/arch/i386/stand/efiboot

2018-03-20 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Tue Mar 20 10:19:33 UTC 2018

Modified Files:
src/sys/arch/i386/stand/efiboot: efidisk.c

Log Message:
efiboot: boot device is always efi_distlist first element.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/i386/stand/efiboot/efidisk.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/i386/stand/efiboot/efidisk.c
diff -u src/sys/arch/i386/stand/efiboot/efidisk.c:1.2 src/sys/arch/i386/stand/efiboot/efidisk.c:1.3
--- src/sys/arch/i386/stand/efiboot/efidisk.c:1.2	Thu Mar  8 10:34:33 2018
+++ src/sys/arch/i386/stand/efiboot/efidisk.c	Tue Mar 20 10:19:33 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: efidisk.c,v 1.2 2018/03/08 10:34:33 nonaka Exp $	*/
+/*	$NetBSD: efidisk.c,v 1.3 2018/03/20 10:19:33 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -106,14 +106,11 @@ next:
 	FreePool(handles);
 
 	if (efi_bootdp_type == BIOSDISK_TYPE_CD) {
-		TAILQ_FOREACH(edi, _disklist, list) {
-			if (edi->bootdev) {
-edi = TAILQ_FIRST(_disklist);
-edi->type = BIOSDISK_TYPE_CD;
-TAILQ_REMOVE(_disklist, edi, list);
-TAILQ_INSERT_TAIL(_disklist, edi, list);
-break;
-			}
+		edi = TAILQ_FIRST(_disklist);
+		if (edi != NULL && edi->bootdev) {
+			edi->type = BIOSDISK_TYPE_CD;
+			TAILQ_REMOVE(_disklist, edi, list);
+			TAILQ_INSERT_TAIL(_disklist, edi, list);
 		}
 	}
 



CVS commit: src/sys/arch/i386/stand/efiboot

2018-03-20 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Tue Mar 20 10:18:10 UTC 2018

Modified Files:
src/sys/arch/i386/stand/efiboot: boot.c

Log Message:
efiboot: more pager.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/i386/stand/efiboot/boot.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/i386/stand/efiboot/boot.c
diff -u src/sys/arch/i386/stand/efiboot/boot.c:1.6 src/sys/arch/i386/stand/efiboot/boot.c:1.7
--- src/sys/arch/i386/stand/efiboot/boot.c:1.6	Thu Mar  8 10:34:33 2018
+++ src/sys/arch/i386/stand/efiboot/boot.c	Tue Mar 20 10:18:10 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot.c,v 1.6 2018/03/08 10:34:33 nonaka Exp $	*/
+/*	$NetBSD: boot.c,v 1.7 2018/03/20 10:18:10 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -627,6 +627,12 @@ command_devpath(char *arg)
 			break;
 
 		Print(L"DevicePathType %d\n", DevicePathType(dp0));
+		if (++row >= rows) {
+			row = 0;
+			Print(L"Press Any Key to continue :");
+			(void) awaitkey(-1, 0);
+			Print(L"\n");
+		}
 		for (dp = dp0;
 		 !IsDevicePathEnd(dp);
 		 dp = NextDevicePathNode(dp)) {



CVS commit: src/sys/arch/i386/stand/efiboot

2018-03-20 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Tue Mar 20 10:16:18 UTC 2018

Modified Files:
src/sys/arch/i386/stand/efiboot: devopen.c

Log Message:
efiboot: fix it can't boot from HDD.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/i386/stand/efiboot/devopen.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/i386/stand/efiboot/devopen.c
diff -u src/sys/arch/i386/stand/efiboot/devopen.c:1.2 src/sys/arch/i386/stand/efiboot/devopen.c:1.3
--- src/sys/arch/i386/stand/efiboot/devopen.c:1.2	Thu Mar  8 10:34:33 2018
+++ src/sys/arch/i386/stand/efiboot/devopen.c	Tue Mar 20 10:16:17 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: devopen.c,v 1.2 2018/03/08 10:34:33 nonaka Exp $	 */
+/*	$NetBSD: devopen.c,v 1.3 2018/03/20 10:16:17 nonaka Exp $	 */
 
 /*-
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@ dev2bios(char *devname, int unit, int *b
 
 	if (strcmp(devname, "hd") == 0)
 		*biosdev = 0x80 + unit;
-	if (strcmp(devname, "cd") == 0)
+	else if (strcmp(devname, "cd") == 0)
 		*biosdev = 0x80 + get_harddrives() + unit;
 	else
 		return ENXIO;



CVS commit: src/sys/lib/libsa

2018-03-08 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Thu Mar  8 23:02:50 UTC 2018

Modified Files:
src/sys/lib/libsa: cd9660.c

Log Message:
Add missed file in previous commit.

> efiboot: system can boot from CD/DVD-ROM media.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/lib/libsa/cd9660.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/lib/libsa/cd9660.c
diff -u src/sys/lib/libsa/cd9660.c:1.30 src/sys/lib/libsa/cd9660.c:1.31
--- src/sys/lib/libsa/cd9660.c:1.30	Thu Mar 20 03:13:18 2014
+++ src/sys/lib/libsa/cd9660.c	Thu Mar  8 23:02:50 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: cd9660.c,v 1.30 2014/03/20 03:13:18 christos Exp $	*/
+/*	$NetBSD: cd9660.c,v 1.31 2018/03/08 23:02:50 nonaka Exp $	*/
 
 /*
  * Copyright (C) 1996 Wolfgang Solfrank.
@@ -71,7 +71,9 @@ struct ptable_ent {
 #define	PTFIXSZ		8
 #define	PTSIZE(pp)	roundup(PTFIXSZ + isonum_711((pp)->namlen), 2)
 
+#ifndef	cdb2devb
 #define	cdb2devb(bno)	((bno) * ISO_DEFAULT_BLOCK_SIZE / DEV_BSIZE)
+#endif
 
 static int	pnmatch(const char *, struct ptable_ent *);
 static int	dirmatch(const char *, struct iso_directory_record *);



CVS commit: src/sys/arch/i386/stand

2018-03-08 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Thu Mar  8 10:34:33 UTC 2018

Modified Files:
src/sys/arch/i386/stand/efiboot: Makefile.efiboot TODO.efiboot boot.c
devopen.c efiboot.c efiboot.h efidisk.c efidisk.h efidisk_ll.c
src/sys/arch/i386/stand/lib: biosdisk.c biosdisk.h biosdisk_ll.h
Added Files:
src/sys/arch/i386/stand/efiboot: efidev.c

Log Message:
efiboot: system can boot from CD/DVD-ROM media.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/i386/stand/efiboot/Makefile.efiboot
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/i386/stand/efiboot/TODO.efiboot
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/i386/stand/efiboot/boot.c \
src/sys/arch/i386/stand/efiboot/efiboot.h
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/i386/stand/efiboot/devopen.c \
src/sys/arch/i386/stand/efiboot/efidisk.c \
src/sys/arch/i386/stand/efiboot/efidisk.h \
src/sys/arch/i386/stand/efiboot/efidisk_ll.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/i386/stand/efiboot/efiboot.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/i386/stand/efiboot/efidev.c
cvs rdiff -u -r1.46 -r1.47 src/sys/arch/i386/stand/lib/biosdisk.c
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/i386/stand/lib/biosdisk.h
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/i386/stand/lib/biosdisk_ll.h

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/i386/stand/efiboot/Makefile.efiboot
diff -u src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.9 src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.10
--- src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.9	Sat Apr 29 00:05:35 2017
+++ src/sys/arch/i386/stand/efiboot/Makefile.efiboot	Thu Mar  8 10:34:33 2018
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.efiboot,v 1.9 2017/04/29 00:05:35 nonaka Exp $
+# $NetBSD: Makefile.efiboot,v 1.10 2018/03/08 10:34:33 nonaka Exp $
 
 S=		${.CURDIR}/../../../../..
 
@@ -12,8 +12,8 @@ SOURCES?= start.S conf.c devopen.c efibo
 LIBI386SRCS= boot.c biosdisk.c bootinfo.c bootinfo_biosgeom.c
 LIBI386SRCS+= bootmenu.c diskbuf.c exec.c menuutils.c
 LIBI386SRCS+= panic.c parseutils.c pread.c
-LIBI386SRCS+= eficons.c efidelay.c efidisk.c efidisk_ll.c efigetsecs.c
-LIBI386SRCS+= efimemory.c
+LIBI386SRCS+= eficons.c efidelay.c efidev.c efidisk.c efidisk_ll.c
+LIBI386SRCS+= efigetsecs.c efimemory.c
 SRCS= ${SOURCES} ${EXTRA_SOURCES} ${LIBI386SRCS}
 
 PIE_CFLAGS=
@@ -54,9 +54,11 @@ CPPFLAGS+= -Wno-pointer-sign
 CPPFLAGS+= -DEFI_ALLOCATE_MAX_ADDRESS=0x1ULL
 CPPFLAGS+= -DHEAP_VARIABLE
 CPPFLAGS+= -DSUPPORT_CD9660
+CPPFLAGS+= -D"devb2cdb(bno)=(bno)"
 CPPFLAGS+= -DSUPPORT_DOSFS
 CPPFLAGS+= -DSUPPORT_EXT2FS
 CPPFLAGS+= -DPASS_BIOSGEOM
+CPPFLAGS+= -DBIOSDISK_DEFAULT_SECSIZE=2048	# for bootinfo_biosgeom.c
 CPPFLAGS+= -DLIBSA_ENABLE_LS_OP
 
 EFIDIR= ${S}/external/bsd/gnu-efi/dist
@@ -66,6 +68,7 @@ CPPFLAGS+= -I${EFIDIR}/inc/protocol
 
 SAMISCCPPFLAGS+= -DLIBSA_PRINTF_LONGLONG_SUPPORT
 SAMISCCPPFLAGS+= -DLIBSA_PRINTF_WIDTH_SUPPORT
+SAMISCCPPFLAGS+= -D"cdb2devb(bno)=(bno)"
 SAMISCMAKEFLAGS+= SA_USE_CREAD=yes  # Read compressed kernels
 SAMISCMAKEFLAGS+= SA_INCLUDE_NET=no # Netboot via TFTP, NFS
 

Index: src/sys/arch/i386/stand/efiboot/TODO.efiboot
diff -u src/sys/arch/i386/stand/efiboot/TODO.efiboot:1.3 src/sys/arch/i386/stand/efiboot/TODO.efiboot:1.4
--- src/sys/arch/i386/stand/efiboot/TODO.efiboot:1.3	Sun Mar 12 06:37:41 2017
+++ src/sys/arch/i386/stand/efiboot/TODO.efiboot	Thu Mar  8 10:34:33 2018
@@ -1,6 +1,5 @@
 - efiboot
  * handle UEFI variables
- * boot from CD/DVD (bootable from CD/DVD, but root fs not found.)
  * load boot.cfg from EFI system partition (FAT32)
 
 - kernel

Index: src/sys/arch/i386/stand/efiboot/boot.c
diff -u src/sys/arch/i386/stand/efiboot/boot.c:1.5 src/sys/arch/i386/stand/efiboot/boot.c:1.6
--- src/sys/arch/i386/stand/efiboot/boot.c:1.5	Mon May  1 13:03:01 2017
+++ src/sys/arch/i386/stand/efiboot/boot.c	Thu Mar  8 10:34:33 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot.c,v 1.5 2017/05/01 13:03:01 nonaka Exp $	*/
+/*	$NetBSD: boot.c,v 1.6 2018/03/08 10:34:33 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -419,7 +419,7 @@ command_dev(char *arg)
 	const char *file; /* dummy */
 
 	if (*arg == '\0') {
-		biosdisk_probe();
+		efi_disk_show();
 		printf("default %s%d%c\n", default_devname, default_unit,
 		   'a' + default_partition);
 		return;
@@ -554,6 +554,7 @@ command_multiboot(char *arg)
 void
 command_version(char *arg)
 {
+	CHAR16 *path;
 
 	if (strcmp(arg, "full") == 0) {
 		printf("ImageBase: 0x%" PRIxPTR "\n",
@@ -563,6 +564,10 @@ command_version(char *arg)
 		ST->Hdr.Revision >> 16, ST->Hdr.Revision & 0x);
 		Print(L"EFI Firmware: %s (rev %d.%02d)\n", ST->FirmwareVendor,
 		ST->FirmwareRevision >> 16, ST->FirmwareRevision & 0x);
+		path = DevicePathToStr(efi_bootdp);
+		Print(L"Boot DevicePath: %d:%d:%s\n", DevicePathType(efi_bootdp),
+		DevicePathSubType(efi_bootdp), path);
+		

CVS commit: src/usr.sbin/makefs/cd9660

2017-11-08 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Thu Nov  9 01:28:06 UTC 2017

Modified Files:
src/usr.sbin/makefs/cd9660: cd9660_eltorito.c

Log Message:
Initialize boot_catalog_entry's entry_type properly.

This had been missing but the type was used in cd9660_setup_boot().

>From OpenBSD usr.sbin/makefs/cd9660/cd9660_eltorito.c r1.10.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/usr.sbin/makefs/cd9660/cd9660_eltorito.c

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

Modified files:

Index: src/usr.sbin/makefs/cd9660/cd9660_eltorito.c
diff -u src/usr.sbin/makefs/cd9660/cd9660_eltorito.c:1.21 src/usr.sbin/makefs/cd9660/cd9660_eltorito.c:1.22
--- src/usr.sbin/makefs/cd9660/cd9660_eltorito.c:1.21	Tue Jan 24 11:22:43 2017
+++ src/usr.sbin/makefs/cd9660/cd9660_eltorito.c	Thu Nov  9 01:28:05 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: cd9660_eltorito.c,v 1.21 2017/01/24 11:22:43 nonaka Exp $	*/
+/*	$NetBSD: cd9660_eltorito.c,v 1.22 2017/11/09 01:28:05 nonaka Exp $	*/
 
 /*
  * Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
@@ -40,7 +40,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: cd9660_eltorito.c,v 1.21 2017/01/24 11:22:43 nonaka Exp $");
+__RCSID("$NetBSD: cd9660_eltorito.c,v 1.22 2017/11/09 01:28:05 nonaka Exp $");
 #endif  /* !__lint */
 
 #ifdef DEBUG
@@ -247,6 +247,7 @@ cd9660_boot_setup_validation_entry(char 
 	size_t i;
 	entry = cd9660_init_boot_catalog_entry();
 
+	entry->entry_type = ET_ENTRY_VE;
 	ve = >entry_data.VE;
 
 	ve->header_id[0] = 1;
@@ -281,6 +282,7 @@ cd9660_boot_setup_default_entry(struct c
 	if (default_entry == NULL)
 		return NULL;
 
+	default_entry->entry_type = ET_ENTRY_IE;
 	ie = _entry->entry_data.IE;
 
 	ie->boot_indicator[0] = disk->bootable;
@@ -308,6 +310,7 @@ cd9660_boot_setup_section_head(char plat
 	if (entry == NULL)
 		return NULL;
 
+	entry->entry_type = ET_ENTRY_SH;
 	sh = >entry_data.SH;
 	/* More by default. The last one will manually be set to 0x91 */
 	sh->header_indicator[0] = ET_SECTION_HEADER_MORE;
@@ -324,6 +327,7 @@ cd9660_boot_setup_section_entry(struct c
 	if ((entry = cd9660_init_boot_catalog_entry()) == NULL)
 		return NULL;
 
+	entry->entry_type = ET_ENTRY_SE;
 	se = >entry_data.SE;
 
 	se->boot_indicator[0] = ET_BOOTABLE;



CVS commit: src/external/lgpl3/gmp/dist

2017-10-18 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Thu Oct 19 03:26:29 UTC 2017

Modified Files:
src/external/lgpl3/gmp/dist: acinclude.m4 configure

Log Message:
external/lgpl3/gmp build fail in configure phase with "ln -s J 
/etc/malloc.conf".

patch from pkgsrc/devel/gmp
  http://mail-index.netbsd.org/pkgsrc-changes/2017/06/15/msg158404.html


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/lgpl3/gmp/dist/acinclude.m4
cvs rdiff -u -r1.6 -r1.7 src/external/lgpl3/gmp/dist/configure

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

Modified files:

Index: src/external/lgpl3/gmp/dist/acinclude.m4
diff -u src/external/lgpl3/gmp/dist/acinclude.m4:1.4 src/external/lgpl3/gmp/dist/acinclude.m4:1.5
--- src/external/lgpl3/gmp/dist/acinclude.m4:1.4	Tue Aug 22 09:55:44 2017
+++ src/external/lgpl3/gmp/dist/acinclude.m4	Thu Oct 19 03:26:28 2017
@@ -744,7 +744,7 @@ main ()
   long i;
   for (i = 0; i < 88 + 1; i++)
 a[i] = ~0L;
-  r = malloc (1 * sizeof (unsigned long));
+  r = calloc (1, sizeof (unsigned long));
   r2 = r;
   for (i = 0; i < 528; i += 23)
 {

Index: src/external/lgpl3/gmp/dist/configure
diff -u src/external/lgpl3/gmp/dist/configure:1.6 src/external/lgpl3/gmp/dist/configure:1.7
--- src/external/lgpl3/gmp/dist/configure:1.6	Tue Aug 22 09:55:44 2017
+++ src/external/lgpl3/gmp/dist/configure	Thu Oct 19 03:26:28 2017
@@ -6786,7 +6786,7 @@ main ()
   long i;
   for (i = 0; i < 88 + 1; i++)
 a[i] = ~0L;
-  r = malloc (1 * sizeof (unsigned long));
+  r = calloc (1, sizeof (unsigned long));
   r2 = r;
   for (i = 0; i < 528; i += 23)
 {
@@ -8404,7 +8404,7 @@ main ()
   long i;
   for (i = 0; i < 88 + 1; i++)
 a[i] = ~0L;
-  r = malloc (1 * sizeof (unsigned long));
+  r = calloc (1, sizeof (unsigned long));
   r2 = r;
   for (i = 0; i < 528; i += 23)
 {



CVS commit: src/sys/external/bsd/drm2/pci

2017-07-26 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Thu Jul 27 02:11:24 UTC 2017

Modified Files:
src/sys/external/bsd/drm2/pci: drm_pci.c

Log Message:
PR/52409: Avoid panic at resume.

XXX: pullup-8


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/external/bsd/drm2/pci/drm_pci.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/external/bsd/drm2/pci/drm_pci.c
diff -u src/sys/external/bsd/drm2/pci/drm_pci.c:1.17 src/sys/external/bsd/drm2/pci/drm_pci.c:1.18
--- src/sys/external/bsd/drm2/pci/drm_pci.c:1.17	Thu Jun  1 02:45:12 2017
+++ src/sys/external/bsd/drm2/pci/drm_pci.c	Thu Jul 27 02:11:24 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: drm_pci.c,v 1.17 2017/06/01 02:45:12 chs Exp $	*/
+/*	$NetBSD: drm_pci.c,v 1.18 2017/07/27 02:11:24 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: drm_pci.c,v 1.17 2017/06/01 02:45:12 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: drm_pci.c,v 1.18 2017/07/27 02:11:24 nonaka Exp $");
 
 #include 
 #include 
@@ -243,11 +243,23 @@ drm_pci_irq_install(struct drm_device *d
 	irq_cookie = kmem_alloc(sizeof(*irq_cookie), KM_SLEEP);
 
 	if (dev->pdev->msi_enabled) {
-		irq_cookie->intr_handles = dev->pdev->intr_handles;
-		dev->pdev->intr_handles = NULL;
+		if (dev->pdev->intr_handles == NULL) {
+			if (pci_msi_alloc_exact(pa, _cookie->intr_handles,
+			1)) {
+aprint_error_dev(dev->dev,
+"couldn't allocate MSI (%s)\n", name);
+goto error;
+			}
+		} else {
+			irq_cookie->intr_handles = dev->pdev->intr_handles;
+			dev->pdev->intr_handles = NULL;
+		}
 	} else {
-		if (pci_intx_alloc(pa, _cookie->intr_handles))
-			return -ENOENT;
+		if (pci_intx_alloc(pa, _cookie->intr_handles)) {
+			aprint_error_dev(dev->dev,
+			"couldn't allocate INTx interrupt (%s)\n", name);
+			goto error;
+		}
 	}
 
 	intrstr = pci_intr_string(pa->pa_pc, irq_cookie->intr_handles[0],
@@ -257,12 +269,17 @@ drm_pci_irq_install(struct drm_device *d
 	if (irq_cookie->ih_cookie == NULL) {
 		aprint_error_dev(dev->dev,
 		"couldn't establish interrupt at %s (%s)\n", intrstr, name);
-		return -ENOENT;
+		pci_intr_release(pa->pa_pc, irq_cookie->intr_handles, 1);
+		goto error;
 	}
 
 	aprint_normal_dev(dev->dev, "interrupting at %s (%s)\n", intrstr, name);
 	*cookiep = irq_cookie;
 	return 0;
+
+error:
+	kmem_free(irq_cookie, sizeof(*irq_cookie));
+	return -ENOENT;
 }
 
 static void



CVS commit: src/sys/arch/x86/x86

2017-07-12 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Thu Jul 13 00:44:14 UTC 2017

Modified Files:
src/sys/arch/x86/x86: lapic.c

Log Message:
PR/52266: Before access MSR[APICBASE], need to check if APIC is present.


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/sys/arch/x86/x86/lapic.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/x86/lapic.c
diff -u src/sys/arch/x86/x86/lapic.c:1.59 src/sys/arch/x86/x86/lapic.c:1.60
--- src/sys/arch/x86/x86/lapic.c:1.59	Sat Jul  8 14:35:33 2017
+++ src/sys/arch/x86/x86/lapic.c	Thu Jul 13 00:44:14 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lapic.c,v 1.59 2017/07/08 14:35:33 nonaka Exp $	*/
+/*	$NetBSD: lapic.c,v 1.60 2017/07/13 00:44:14 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2000, 2008 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lapic.c,v 1.59 2017/07/08 14:35:33 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lapic.c,v 1.60 2017/07/13 00:44:14 nonaka Exp $");
 
 #include "acpica.h"
 #include "ioapic.h"
@@ -237,7 +237,8 @@ lapic_is_x2apic(void)
 {
 	uint64_t msr;
 
-	if (rdmsr_safe(MSR_APICBASE, ) == EFAULT)
+	if (!ISSET(cpu_feature[0], CPUID_APIC) ||
+	rdmsr_safe(MSR_APICBASE, ) == EFAULT)
 		return false;
 	return (msr & (APICBASE_EN | APICBASE_EXTD)) ==
 	(APICBASE_EN | APICBASE_EXTD);



CVS commit: src/sys/arch/x86/x86

2017-07-08 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Sat Jul  8 14:35:33 UTC 2017

Modified Files:
src/sys/arch/x86/x86: lapic.c

Log Message:
PR/52266: use rdmsr_safe(9) instead of rdmsr(9) for old machine.

tested by simonb@


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/sys/arch/x86/x86/lapic.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/x86/lapic.c
diff -u src/sys/arch/x86/x86/lapic.c:1.58 src/sys/arch/x86/x86/lapic.c:1.59
--- src/sys/arch/x86/x86/lapic.c:1.58	Tue May 23 08:54:39 2017
+++ src/sys/arch/x86/x86/lapic.c	Sat Jul  8 14:35:33 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lapic.c,v 1.58 2017/05/23 08:54:39 nonaka Exp $	*/
+/*	$NetBSD: lapic.c,v 1.59 2017/07/08 14:35:33 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2000, 2008 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lapic.c,v 1.58 2017/05/23 08:54:39 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lapic.c,v 1.59 2017/07/08 14:35:33 nonaka Exp $");
 
 #include "acpica.h"
 #include "ioapic.h"
@@ -235,10 +235,12 @@ lapic_enable_x2apic(void)
 bool
 lapic_is_x2apic(void)
 {
-	uint64_t r;
+	uint64_t msr;
 
-	r = rdmsr(MSR_APICBASE);
-	return (r & (APICBASE_EN | APICBASE_EXTD)) == (APICBASE_EN | APICBASE_EXTD);
+	if (rdmsr_safe(MSR_APICBASE, ) == EFAULT)
+		return false;
+	return (msr & (APICBASE_EN | APICBASE_EXTD)) ==
+	(APICBASE_EN | APICBASE_EXTD);
 }
 
 /*



CVS commit: src/sys/dev/pci

2017-06-08 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Fri Jun  9 04:48:58 UTC 2017

Modified Files:
src/sys/dev/pci: if_iwm.c

Log Message:
fix typo.

reported by ryo@.


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/sys/dev/pci/if_iwm.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/dev/pci/if_iwm.c
diff -u src/sys/dev/pci/if_iwm.c:1.73 src/sys/dev/pci/if_iwm.c:1.74
--- src/sys/dev/pci/if_iwm.c:1.73	Thu Jun  1 02:45:11 2017
+++ src/sys/dev/pci/if_iwm.c	Fri Jun  9 04:48:58 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_iwm.c,v 1.73 2017/06/01 02:45:11 chs Exp $	*/
+/*	$NetBSD: if_iwm.c,v 1.74 2017/06/09 04:48:58 nonaka Exp $	*/
 /*	OpenBSD: if_iwm.c,v 1.148 2016/11/19 21:07:08 stsp Exp	*/
 #define IEEE80211_NO_HT
 /*
@@ -106,7 +106,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_iwm.c,v 1.73 2017/06/01 02:45:11 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_iwm.c,v 1.74 2017/06/09 04:48:58 nonaka Exp $");
 
 #include 
 #include 
@@ -3044,7 +3044,7 @@ iwm_send_paging_cmd(struct iwm_softc *sc
 			fw_paging_cmd.device_phy_addr.addr32[blk_idx] =
 			htole32(dev_phy_addr);
 		}
-		dmap = sc->fw_paging_db[blk_idx].fw_paging_block.map,
+		dmap = sc->fw_paging_db[blk_idx].fw_paging_block.map;
 		bus_dmamap_sync(sc->sc_dmat, dmap, 0, dmap->dm_mapsize,
 		BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD);
 	}



CVS commit: src/sys/dev/ic

2017-05-28 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Mon May 29 02:25:37 UTC 2017

Modified Files:
src/sys/dev/ic: nvme.c

Log Message:
nvme(4): Don't set prp1 for DEL_IOCQ

> NVM_ADMIN_DEL_IOCQ does not need prp1 (just as NVM_ADMIN_DEL_IOSQ).
> Remove what is likely a cut'n'paste error from the *_ADD_* code.

from OpenBSD nvme.c r1.56.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/dev/ic/nvme.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/dev/ic/nvme.c
diff -u src/sys/dev/ic/nvme.c:1.28 src/sys/dev/ic/nvme.c:1.29
--- src/sys/dev/ic/nvme.c:1.28	Mon May 29 02:24:00 2017
+++ src/sys/dev/ic/nvme.c	Mon May 29 02:25:37 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvme.c,v 1.28 2017/05/29 02:24:00 nonaka Exp $	*/
+/*	$NetBSD: nvme.c,v 1.29 2017/05/29 02:25:37 nonaka Exp $	*/
 /*	$OpenBSD: nvme.c,v 1.49 2016/04/18 05:59:50 dlg Exp $ */
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.28 2017/05/29 02:24:00 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.29 2017/05/29 02:25:37 nonaka Exp $");
 
 #include 
 #include 
@@ -1296,7 +1296,6 @@ nvme_q_delete(struct nvme_softc *sc, str
 
 	memset(, 0, sizeof(sqe));
 	sqe.opcode = NVM_ADMIN_DEL_IOCQ;
-	htolem64(, NVME_DMA_DVA(q->q_sq_dmamem));
 	htolem16(, q->q_id);
 
 	rv = nvme_poll(sc, sc->sc_admin_q, ccb, nvme_sqe_fill, NVME_TIMO_QOP);



CVS commit: src/sys/dev/ic

2017-05-28 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Mon May 29 02:24:00 UTC 2017

Modified Files:
src/sys/dev/ic: nvme.c

Log Message:
nvme(4): Do not use bus_space_{read,write}_8() even on LP64 archs.

> some (broken) controllers require ordered split transfers.
> From linux a310acd7a7ea53533886c11bb7edd11ffd61a036

from OpenBSD nvme.c r1.53.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/dev/ic/nvme.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/dev/ic/nvme.c
diff -u src/sys/dev/ic/nvme.c:1.27 src/sys/dev/ic/nvme.c:1.28
--- src/sys/dev/ic/nvme.c:1.27	Mon May 29 02:20:34 2017
+++ src/sys/dev/ic/nvme.c	Mon May 29 02:24:00 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvme.c,v 1.27 2017/05/29 02:20:34 nonaka Exp $	*/
+/*	$NetBSD: nvme.c,v 1.28 2017/05/29 02:24:00 nonaka Exp $	*/
 /*	$OpenBSD: nvme.c,v 1.49 2016/04/18 05:59:50 dlg Exp $ */
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.27 2017/05/29 02:20:34 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.28 2017/05/29 02:24:00 nonaka Exp $");
 
 #include 
 #include 
@@ -121,12 +121,10 @@ static int	nvme_get_number_of_queues(str
 	bus_space_read_4((_s)->sc_iot, (_s)->sc_ioh, (_r))
 #define nvme_write4(_s, _r, _v) \
 	bus_space_write_4((_s)->sc_iot, (_s)->sc_ioh, (_r), (_v))
-#ifdef __LP64__
-#define nvme_read8(_s, _r) \
-	bus_space_read_8((_s)->sc_iot, (_s)->sc_ioh, (_r))
-#define nvme_write8(_s, _r, _v) \
-	bus_space_write_8((_s)->sc_iot, (_s)->sc_ioh, (_r), (_v))
-#else /* __LP64__ */
+/*
+ * Some controllers, at least Apple NVMe, always require split
+ * transfers, so don't use bus_space_{read,write}_8() on LP64.
+ */
 static inline uint64_t
 nvme_read8(struct nvme_softc *sc, bus_size_t r)
 {
@@ -157,7 +155,6 @@ nvme_write8(struct nvme_softc *sc, bus_s
 	nvme_write4(sc, r + 4, a[0]);
 #endif
 }
-#endif /* __LP64__ */
 #define nvme_barrier(_s, _r, _l, _f) \
 	bus_space_barrier((_s)->sc_iot, (_s)->sc_ioh, (_r), (_l), (_f))
 



CVS commit: src/sys/dev/ic

2017-05-28 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Mon May 29 02:20:34 UTC 2017

Modified Files:
src/sys/dev/ic: nvme.c nvmereg.h

Log Message:
nvme(4): Mask non relevant bits when pritting version number.

from OpenBSD nvme.c r1.52.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/dev/ic/nvme.c
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/ic/nvmereg.h

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

Modified files:

Index: src/sys/dev/ic/nvme.c
diff -u src/sys/dev/ic/nvme.c:1.26 src/sys/dev/ic/nvme.c:1.27
--- src/sys/dev/ic/nvme.c:1.26	Wed Apr  5 20:15:49 2017
+++ src/sys/dev/ic/nvme.c	Mon May 29 02:20:34 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvme.c,v 1.26 2017/04/05 20:15:49 jdolecek Exp $	*/
+/*	$NetBSD: nvme.c,v 1.27 2017/05/29 02:20:34 nonaka Exp $	*/
 /*	$OpenBSD: nvme.c,v 1.49 2016/04/18 05:59:50 dlg Exp $ */
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.26 2017/04/05 20:15:49 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.27 2017/05/29 02:20:34 nonaka Exp $");
 
 #include 
 #include 
@@ -50,7 +50,6 @@ static int	nvme_enable(struct nvme_softc
 static int	nvme_disable(struct nvme_softc *);
 static int	nvme_shutdown(struct nvme_softc *);
 
-static void	nvme_version(struct nvme_softc *, uint32_t);
 #ifdef NVME_DEBUG
 static void	nvme_dumpregs(struct nvme_softc *);
 #endif
@@ -162,32 +161,6 @@ nvme_write8(struct nvme_softc *sc, bus_s
 #define nvme_barrier(_s, _r, _l, _f) \
 	bus_space_barrier((_s)->sc_iot, (_s)->sc_ioh, (_r), (_l), (_f))
 
-static void
-nvme_version(struct nvme_softc *sc, uint32_t ver)
-{
-	const char *v = NULL;
-
-	switch (ver) {
-	case NVME_VS_1_0:
-		v = "1.0";
-		break;
-	case NVME_VS_1_1:
-		v = "1.1";
-		break;
-	case NVME_VS_1_2:
-		v = "1.2";
-		break;
-	case NVME_VS_1_2_1:
-		v = "1.2.1";
-		break;
-	default:
-		aprint_error_dev(sc->sc_dev, "unknown version 0x%08x\n", ver);
-		return;
-	}
-
-	aprint_normal_dev(sc->sc_dev, "NVMe %s\n", v);
-}
-
 #ifdef NVME_DEBUG
 static __used void
 nvme_dumpregs(struct nvme_softc *sc)
@@ -353,7 +326,12 @@ nvme_attach(struct nvme_softc *sc)
 		return 1;
 	}
 
-	nvme_version(sc, reg);
+	if (NVME_VS_TER(reg) == 0)
+		aprint_normal_dev(sc->sc_dev, "NVMe %d.%d\n", NVME_VS_MJR(reg),
+		NVME_VS_MNR(reg));
+	else
+		aprint_normal_dev(sc->sc_dev, "NVMe %d.%d.%d\n", NVME_VS_MJR(reg),
+		NVME_VS_MNR(reg), NVME_VS_TER(reg));
 
 	cap = nvme_read8(sc, NVME_CAP);
 	dstrd = NVME_CAP_DSTRD(cap);

Index: src/sys/dev/ic/nvmereg.h
diff -u src/sys/dev/ic/nvmereg.h:1.8 src/sys/dev/ic/nvmereg.h:1.9
--- src/sys/dev/ic/nvmereg.h:1.8	Tue Feb 28 20:53:50 2017
+++ src/sys/dev/ic/nvmereg.h	Mon May 29 02:20:34 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvmereg.h,v 1.8 2017/02/28 20:53:50 jdolecek Exp $	*/
+/*	$NetBSD: nvmereg.h,v 1.9 2017/05/29 02:20:34 nonaka Exp $	*/
 /*	$OpenBSD: nvmereg.h,v 1.10 2016/04/14 11:18:32 dlg Exp $ */
 
 /*
@@ -37,11 +37,8 @@
 #define NVME_CAP_HI	0x0004
 #define NVME_VS		0x0008	/* Version */
 #define  NVME_VS_MJR(_r)	(((_r) >> 16) & 0x)
-#define  NVME_VS_MNR(_r)	((_r) & 0x)
-#define  NVME_VS_1_0		0x0001
-#define  NVME_VS_1_1		0x00010100
-#define  NVME_VS_1_2		0x00010200
-#define  NVME_VS_1_2_1		0x00010201
+#define  NVME_VS_MNR(_r)	(((_r) >> 8) & 0xff)
+#define  NVME_VS_TER(_r)	((_r) & 0xff)
 #define NVME_INTMS	0x000c	/* Interrupt Mask Set */
 #define NVME_INTMC	0x0010	/* Interrupt Mask Clear */
 #define NVME_CC		0x0014	/* Controller Configuration */



CVS commit: src/sys/arch

2017-05-23 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Tue May 23 08:54:39 UTC 2017

Modified Files:
src/sys/arch/amd64/amd64: db_interface.c mainbus.c vector.S
src/sys/arch/amd64/include: i82093reg.h
src/sys/arch/i386/i386: db_interface.c mainbus.c vector.S
src/sys/arch/i386/include: i82093reg.h
src/sys/arch/x86/include: cpuvar.h i82489var.h intr.h mpacpi.h
src/sys/arch/x86/pci: msipic.c
src/sys/arch/x86/x86: cpu.c lapic.c pmc.c tprof_amdpmi.c tprof_pmi.c
src/sys/arch/xen/include: intr.h mpacpi.h
src/sys/arch/xen/x86: intr.c mainbus.c

Log Message:
x86: Add preliminary x2APIC support.

x2APIC is used only when x2APIC is enabled in BIOS/UEFI.
LAPIC ID is not supported above 256.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/amd64/amd64/db_interface.c
cvs rdiff -u -r1.37 -r1.38 src/sys/arch/amd64/amd64/mainbus.c
cvs rdiff -u -r1.48 -r1.49 src/sys/arch/amd64/amd64/vector.S
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/amd64/include/i82093reg.h
cvs rdiff -u -r1.71 -r1.72 src/sys/arch/i386/i386/db_interface.c
cvs rdiff -u -r1.102 -r1.103 src/sys/arch/i386/i386/mainbus.c
cvs rdiff -u -r1.68 -r1.69 src/sys/arch/i386/i386/vector.S
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/i386/include/i82093reg.h
cvs rdiff -u -r1.49 -r1.50 src/sys/arch/x86/include/cpuvar.h \
src/sys/arch/x86/include/intr.h
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/x86/include/i82489var.h
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/x86/include/mpacpi.h
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/x86/pci/msipic.c
cvs rdiff -u -r1.124 -r1.125 src/sys/arch/x86/x86/cpu.c
cvs rdiff -u -r1.57 -r1.58 src/sys/arch/x86/x86/lapic.c
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/x86/x86/pmc.c \
src/sys/arch/x86/x86/tprof_amdpmi.c
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/x86/x86/tprof_pmi.c
cvs rdiff -u -r1.39 -r1.40 src/sys/arch/xen/include/intr.h
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/xen/include/mpacpi.h
cvs rdiff -u -r1.30 -r1.31 src/sys/arch/xen/x86/intr.c
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/xen/x86/mainbus.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/amd64/amd64/db_interface.c
diff -u src/sys/arch/amd64/amd64/db_interface.c:1.24 src/sys/arch/amd64/amd64/db_interface.c:1.25
--- src/sys/arch/amd64/amd64/db_interface.c:1.24	Thu Aug 11 19:52:52 2011
+++ src/sys/arch/amd64/amd64/db_interface.c	Tue May 23 08:54:38 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_interface.c,v 1.24 2011/08/11 19:52:52 cherry Exp $	*/
+/*	$NetBSD: db_interface.c,v 1.25 2017/05/23 08:54:38 nonaka Exp $	*/
 
 /*
  * Mach Operating System
@@ -33,11 +33,13 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.24 2011/08/11 19:52:52 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.25 2017/05/23 08:54:38 nonaka Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
 
+#include "lapic.h"
+
 #include 
 #include 
 #include 
@@ -93,7 +95,7 @@ static bool ddb_mp_online;
 int ddb_cpu = NOCPU;
 
 typedef void (vector)(void);
-extern vector Xintrddb;
+extern vector Xintrddb, Xx2apic_intrddb;
 
 void
 db_machine_init(void)
@@ -101,9 +103,14 @@ db_machine_init(void)
 
 #ifdef MULTIPROCESSOR
 #ifndef XEN
+	vector *handler = 
+#if NLAPIC > 0
+	if (lapic_is_x2apic())
+		handler = _intrddb;
+#endif
 	ddb_vec = idt_vec_alloc(0xf0, 0xff);
-	setgate((struct gate_descriptor *)[ddb_vec], , 1,
-	SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
+	setgate([ddb_vec], handler, 1, SDT_SYS386IGT, SEL_KPL,
+	GSEL(GCODE_SEL, SEL_KPL));
 #else
 	/* Initialised as part of xen_ipi_init() */
 #endif /* XEN */

Index: src/sys/arch/amd64/amd64/mainbus.c
diff -u src/sys/arch/amd64/amd64/mainbus.c:1.37 src/sys/arch/amd64/amd64/mainbus.c:1.38
--- src/sys/arch/amd64/amd64/mainbus.c:1.37	Tue Jun 21 11:33:32 2016
+++ src/sys/arch/amd64/amd64/mainbus.c	Tue May 23 08:54:38 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: mainbus.c,v 1.37 2016/06/21 11:33:32 nonaka Exp $	*/
+/*	$NetBSD: mainbus.c,v 1.38 2017/05/23 08:54:38 nonaka Exp $	*/
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.37 2016/06/21 11:33:32 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.38 2017/05/23 08:54:38 nonaka Exp $");
 
 #include 
 #include 
@@ -126,6 +126,9 @@ int mp_nintr;
 int mp_isa_bus = -1;
 int mp_eisa_bus = -1;
 
+bool acpi_present;
+bool mpacpi_active;
+
 # ifdef MPVERBOSE
 #  if MPVERBOSE > 0
 int mp_verbose = MPVERBOSE;
@@ -160,13 +163,9 @@ mainbus_attach(device_t parent, device_t
 #if NPCI > 0
 	int mode;
 #endif
-#if NACPICA > 0
-	int acpi_present = 0;
-#endif
 #ifdef MPBIOS
 	int mpbios_present = 0;
 #endif
-	int mpacpi_active = 0;
 	int numcpus = 0;
 #if defined(PCI_BUS_FIXUP)
 	int pci_maxbus = 0;
@@ -202,14 +201,14 @@ mainbus_attach(device_t parent, device_t
 
 #if NACPICA > 0
 	if ((boothowto & RB_MD2) 

CVS commit: src/sys/arch

2017-05-23 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Tue May 23 08:48:35 UTC 2017

Modified Files:
src/sys/arch/amd64/amd64: autoconf.c
src/sys/arch/i386/i386: autoconf.c
src/sys/arch/x86/include: cpu.h
src/sys/arch/x86/x86: identcpu.c vmt.c
src/sys/arch/xen/conf: files.xen
src/sys/arch/xen/x86: autoconf.c
Added Files:
src/sys/arch/x86/x86: vmtreg.h vmtvar.h

Log Message:
x86: hypervisor detection from FreeBSD for x2APIC support.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/amd64/amd64/autoconf.c
cvs rdiff -u -r1.102 -r1.103 src/sys/arch/i386/i386/autoconf.c
cvs rdiff -u -r1.70 -r1.71 src/sys/arch/x86/include/cpu.h
cvs rdiff -u -r1.54 -r1.55 src/sys/arch/x86/x86/identcpu.c
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/x86/x86/vmt.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/x86/x86/vmtreg.h \
src/sys/arch/x86/x86/vmtvar.h
cvs rdiff -u -r1.146 -r1.147 src/sys/arch/xen/conf/files.xen
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/xen/x86/autoconf.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/amd64/amd64/autoconf.c
diff -u src/sys/arch/amd64/amd64/autoconf.c:1.25 src/sys/arch/amd64/amd64/autoconf.c:1.26
--- src/sys/arch/amd64/amd64/autoconf.c:1.25	Sun Nov 22 13:41:24 2015
+++ src/sys/arch/amd64/amd64/autoconf.c	Tue May 23 08:48:34 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.25 2015/11/22 13:41:24 maxv Exp $	*/
+/*	$NetBSD: autoconf.c,v 1.26 2017/05/23 08:48:34 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -46,7 +46,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.25 2015/11/22 13:41:24 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.26 2017/05/23 08:48:34 nonaka Exp $");
 
 #include "opt_multiprocessor.h"
 #include "opt_intrdebug.h"
@@ -91,6 +91,8 @@ cpu_configure(void)
 #if NBIOS32 > 0
 	bios32_init();
 	platform_init();
+	/* identify hypervisor type from SMBIOS */
+	identify_hypervisor();
 #endif
 
 	x86_64_proc0_tss_ldt_init();

Index: src/sys/arch/i386/i386/autoconf.c
diff -u src/sys/arch/i386/i386/autoconf.c:1.102 src/sys/arch/i386/i386/autoconf.c:1.103
--- src/sys/arch/i386/i386/autoconf.c:1.102	Sat Apr 22 04:29:31 2017
+++ src/sys/arch/i386/i386/autoconf.c	Tue May 23 08:48:34 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.102 2017/04/22 04:29:31 nonaka Exp $	*/
+/*	$NetBSD: autoconf.c,v 1.103 2017/05/23 08:48:34 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -46,7 +46,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.102 2017/04/22 04:29:31 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.103 2017/05/23 08:48:34 nonaka Exp $");
 
 #include "opt_compat_oldboot.h"
 #include "opt_intrdebug.h"
@@ -105,6 +105,8 @@ cpu_configure(void)
 #if NBIOS32 > 0
 	bios32_init();
 	platform_init();
+	/* identify hypervisor type from SMBIOS */
+	identify_hypervisor();
 #endif
 #ifdef PCIBIOS
 	pcibios_init();

Index: src/sys/arch/x86/include/cpu.h
diff -u src/sys/arch/x86/include/cpu.h:1.70 src/sys/arch/x86/include/cpu.h:1.71
--- src/sys/arch/x86/include/cpu.h:1.70	Mon May 15 04:02:52 2017
+++ src/sys/arch/x86/include/cpu.h	Tue May 23 08:48:34 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.h,v 1.70 2017/05/15 04:02:52 msaitoh Exp $	*/
+/*	$NetBSD: cpu.h,v 1.71 2017/05/23 08:48:34 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -422,6 +422,18 @@ void 	tmx86_init_longrun(void);
 /* identcpu.c */
 void 	cpu_probe(struct cpu_info *);
 void	cpu_identify(struct cpu_info *);
+void	identify_hypervisor(void);
+
+typedef enum vm_guest {
+	VM_GUEST_NO = 0,
+	VM_GUEST_VM,
+	VM_GUEST_XEN,
+	VM_GUEST_HV,
+	VM_GUEST_VMWARE,
+	VM_GUEST_KVM,
+	VM_LAST
+} vm_guest_t;
+extern vm_guest_t vm_guest;
 
 /* cpu_topology.c */
 void	x86_cpu_topology(struct cpu_info *);

Index: src/sys/arch/x86/x86/identcpu.c
diff -u src/sys/arch/x86/x86/identcpu.c:1.54 src/sys/arch/x86/x86/identcpu.c:1.55
--- src/sys/arch/x86/x86/identcpu.c:1.54	Wed May 10 08:02:37 2017
+++ src/sys/arch/x86/x86/identcpu.c	Tue May 23 08:48:34 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: identcpu.c,v 1.54 2017/05/10 08:02:37 msaitoh Exp $	*/
+/*	$NetBSD: identcpu.c,v 1.55 2017/05/23 08:48:34 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.54 2017/05/10 08:02:37 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.55 2017/05/23 08:48:34 nonaka Exp $");
 
 #include "opt_xen.h"
 
@@ -50,6 +50,9 @@ __KERNEL_RCSID(0, "$NetBSD: identcpu.c,v
 #include 
 #include 
 
+#include 	/* for vmt_hvcall() */
+#include 	/* for vmt_hvcall() */
+
 static const struct x86_cache_info intel_cpuid_cache_info[] = INTEL_CACHE_INFO;
 
 static const struct x86_cache_info amd_cpuid_l2cache_assoc_info[] = 

CVS commit: src/sys/dev/pci

2017-05-23 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Tue May 23 07:12:57 UTC 2017

Modified Files:
src/sys/dev/pci: pcidevs

Log Message:
Add some AMD entries.


To generate a diff of this commit:
cvs rdiff -u -r1.1288 -r1.1289 src/sys/dev/pci/pcidevs

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

Modified files:

Index: src/sys/dev/pci/pcidevs
diff -u src/sys/dev/pci/pcidevs:1.1288 src/sys/dev/pci/pcidevs:1.1289
--- src/sys/dev/pci/pcidevs:1.1288	Mon May  8 07:34:33 2017
+++ src/sys/dev/pci/pcidevs	Tue May 23 07:12:56 2017
@@ -1,4 +1,4 @@
-$NetBSD: pcidevs,v 1.1288 2017/05/08 07:34:33 msaitoh Exp $
+$NetBSD: pcidevs,v 1.1289 2017/05/23 07:12:56 nonaka Exp $
 
 /*
  * Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -961,6 +961,32 @@ product AMD AMD64_F11_ADDR	0x1301	AMD64 
 product AMD AMD64_F11_DRAM	0x1302	AMD64 Family11h DRAM Configuration
 product AMD AMD64_F11_MISC	0x1303	AMD64 Family11h Miscellaneous Configuration
 product AMD AMD64_F11_LINK	0x1304	AMD64 Family11h Link Configuration
+product AMD F15_10_PF_0	0x1400	Family15h Processor Function 0
+product AMD F15_10_PF_1	0x1401	Family15h Processor Function 1
+product AMD F15_10_PF_2	0x1402	Family15h Processor Function 2
+product AMD F15_10_PF_3	0x1403	Family15h Processor Function 3
+product AMD F15_10_PF_4	0x1404	Family15h Processor Function 4
+product AMD F15_10_PF_5	0x1405	Family15h Processor Function 5
+product AMD F15_10_RC	0x1410	Family15h Root Complex
+product AMD F15_10_RP_2	0x1412	Family15h Root Port
+product AMD F15_10_RP_3	0x1413	Family15h Root Port
+product AMD F15_10_RP_4	0x1414	Family15h Root Port
+product AMD F15_10_RP_5	0x1415	Family15h Root Port
+product AMD F15_10_RP_6	0x1416	Family15h Root Port
+product AMD F15_10_RP_7	0x1417	Family15h Root Port
+product AMD F15_10_RP_8	0x1418	Family15h Root Port
+product AMD F15_10_IOMMU	0x1419	Family15h IOMMU
+product AMD F15_30_PF_0	0x141a	Family15h Processor Function 0
+product AMD F15_30_PF_1	0x141b	Family15h Processor Function 1
+product AMD F15_30_PF_2	0x141c	Family15h Processor Function 2
+product AMD F15_30_PF_3	0x141d	Family15h Processor Function 3
+product AMD F15_30_PF_4	0x141e	Family15h Processor Function 4
+product AMD F15_30_PF_5	0x141f	Family15h Processor Function 5
+product AMD F15_30_RC	0x1422	Family15h Root Complex
+product AMD F15_30_IOMMU	0x1423	Family15h IOMMU
+product AMD F15_30_HB	0x1424	Family15h Host Bridge
+product AMD F15_30_RP_5	0x1425	Family15h Root Port
+product AMD F15_30_RP_6	0x1426	Family15h Root Port
 product AMD F16_GPPB	0x1439	Family16h GPP Bridge
 product AMD F14_RC	0x1510	Family14h Root Complex
 product AMD F16_HT	0x1530	Family16h HyperTransport Configuration
@@ -975,6 +1001,18 @@ product AMD F16_30_RC	0x1566	Family16h R
 product AMD F16_30_IOMMU	0x1567	Family16h IOMMU
 product AMD F16_HB	0x1568	Family16h Host Bridge
 product AMD F16_30_HB	0x156b	Family16h Host Bridge
+product AMD F15_60_PF_0	0x1570	Family15h Processor Function 0
+product AMD F15_60_PF_1	0x1571	Family15h Processor Function 1
+product AMD F15_60_PF_2	0x1572	Family15h Processor Function 2
+product AMD F15_60_PF_3	0x1573	Family15h Processor Function 3
+product AMD F15_60_PF_4	0x1574	Family15h Processor Function 4
+product AMD F15_60_PF_5	0x1575	Family15h Processor Function 5
+product AMD F15_60_RC	0x1576	Family15h Root Complex
+product AMD F15_60_IOMMU	0x1577	Family15h IOMMU
+product AMD F15_60_PSP	0x1578	Family15h PSP
+product AMD F15_60_AC	0x157a	Family15h Audio Controller
+product AMD F15_60_HB	0x157b	Family15h Host Bridge
+product AMD F15_60_RP	0x157c	Family15h Root Port
 product AMD F16_30_HT	0x1580	Family16h HyperTransport Configuration
 product AMD F16_30_ADDR	0x1581	Family16h Address Map Configuration
 product AMD F16_30_DRAM	0x1582	Family16h DRAM Configuration



CVS commit: src/sys/arch/x86

2017-05-22 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Tue May 23 03:23:58 UTC 2017

Modified Files:
src/sys/arch/x86/include: i82093var.h
src/sys/arch/x86/x86: lapic.c

Log Message:
whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/x86/include/i82093var.h
cvs rdiff -u -r1.56 -r1.57 src/sys/arch/x86/x86/lapic.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/include/i82093var.h
diff -u src/sys/arch/x86/include/i82093var.h:1.15 src/sys/arch/x86/include/i82093var.h:1.16
--- src/sys/arch/x86/include/i82093var.h:1.15	Tue May 23 03:18:40 2017
+++ src/sys/arch/x86/include/i82093var.h	Tue May 23 03:23:58 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: i82093var.h,v 1.15 2017/05/23 03:18:40 nonaka Exp $ */
+/* $NetBSD: i82093var.h,v 1.16 2017/05/23 03:23:58 nonaka Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -37,8 +37,7 @@
 #include 
 #include 
 
-struct ioapic_pin 
-{
+struct ioapic_pin {
 	struct ioapic_pin	*ip_next;	/* next pin on this vector */
 	struct mp_intr_map 	*ip_map;
 	int			ip_vector;	/* IDT vector */
@@ -52,7 +51,7 @@ struct ioapic_softc {
 	struct ioapic_softc	*sc_next;
 	int			sc_apic_vers;
 	int			sc_apic_vecbase; /* global int base if ACPI */
-	int			sc_apic_sz;	/* apic size*/
+	int			sc_apic_sz;	/* apic size */
 	int			sc_flags;
 	paddr_t			sc_pa;		/* PA of ioapic */
 	volatile uint32_t	*sc_reg;	/* KVA of ioapic addr */
@@ -71,7 +70,7 @@ struct ioapic_softc {
  * (ih&0x000ff800)>>43 -> MSI/MSI-X device id.
  * (ih&0x07ff)>>32 -> MSI/MSI-X vector id in a device.
  */
-#define	MPSAFE_MASK		0x8000ULL
+#define MPSAFE_MASK		0x8000ULL
 #define APIC_INT_VIA_APIC	0x1000ULL
 #define APIC_INT_VIA_MSI	0x2000ULL
 #define APIC_INT_APIC_MASK	0x00ffULL

Index: src/sys/arch/x86/x86/lapic.c
diff -u src/sys/arch/x86/x86/lapic.c:1.56 src/sys/arch/x86/x86/lapic.c:1.57
--- src/sys/arch/x86/x86/lapic.c:1.56	Sat Apr 22 04:29:31 2017
+++ src/sys/arch/x86/x86/lapic.c	Tue May 23 03:23:58 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lapic.c,v 1.56 2017/04/22 04:29:31 nonaka Exp $	*/
+/*	$NetBSD: lapic.c,v 1.57 2017/05/23 03:23:58 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2000, 2008 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lapic.c,v 1.56 2017/04/22 04:29:31 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lapic.c,v 1.57 2017/05/23 03:23:58 nonaka Exp $");
 
 #include "opt_ddb.h"
 #include "opt_mpbios.h"		/* for MPDEBUG */
@@ -85,7 +85,7 @@ struct pic local_pic = {
 	.pic_lock = __SIMPLELOCK_UNLOCKED,
 	.pic_hwmask = lapic_hwmask,
 	.pic_hwunmask = lapic_hwunmask,
-	.pic_addroute =lapic_setup,
+	.pic_addroute = lapic_setup,
 	.pic_delroute = lapic_setup,
 };
 



CVS commit: src/sys/arch/x86

2017-05-22 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Tue May 23 03:18:40 UTC 2017

Modified Files:
src/sys/arch/x86/include: i82093var.h
src/sys/arch/x86/x86: mpbios.c

Log Message:
x86: No ioapic_softc.sc_apicid is used anymore. Use 
ioapic_softc.sc_pic.pic_apicid.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/x86/include/i82093var.h
cvs rdiff -u -r1.65 -r1.66 src/sys/arch/x86/x86/mpbios.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/include/i82093var.h
diff -u src/sys/arch/x86/include/i82093var.h:1.14 src/sys/arch/x86/include/i82093var.h:1.15
--- src/sys/arch/x86/include/i82093var.h:1.14	Mon Apr 27 07:03:58 2015
+++ src/sys/arch/x86/include/i82093var.h	Tue May 23 03:18:40 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: i82093var.h,v 1.14 2015/04/27 07:03:58 knakahara Exp $ */
+/* $NetBSD: i82093var.h,v 1.15 2017/05/23 03:18:40 nonaka Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -50,7 +50,6 @@ struct ioapic_softc {
 	device_t		sc_dev;
 	struct pic		sc_pic;
 	struct ioapic_softc	*sc_next;
-	int			sc_apicid;
 	int			sc_apic_vers;
 	int			sc_apic_vecbase; /* global int base if ACPI */
 	int			sc_apic_sz;	/* apic size*/

Index: src/sys/arch/x86/x86/mpbios.c
diff -u src/sys/arch/x86/x86/mpbios.c:1.65 src/sys/arch/x86/x86/mpbios.c:1.66
--- src/sys/arch/x86/x86/mpbios.c:1.65	Fri Jul 17 06:41:18 2015
+++ src/sys/arch/x86/x86/mpbios.c	Tue May 23 03:18:40 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: mpbios.c,v 1.65 2015/07/17 06:41:18 msaitoh Exp $	*/
+/*	$NetBSD: mpbios.c,v 1.66 2017/05/23 03:18:40 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -96,7 +96,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mpbios.c,v 1.65 2015/07/17 06:41:18 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mpbios.c,v 1.66 2017/05/23 03:18:40 nonaka Exp $");
 
 #include "acpica.h"
 #include "lapic.h"
@@ -752,7 +752,7 @@ mpbios_scan(device_t self, int *ncpup)
 	struct ioapic_softc *sc;
 	for (sc = ioapics ; sc != NULL;
 	 sc = sc->sc_next) {
-		ie.dst_apic_id = sc->sc_apicid;
+		ie.dst_apic_id = sc->sc_pic.pic_apicid;
 		mpbios_int((char *), type,
 		_intrs[cur_intr++]);
 	}



CVS commit: src/sys/dev/pci

2017-05-19 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Fri May 19 14:18:10 UTC 2017

Modified Files:
src/sys/dev/pci: if_iwm.c

Log Message:
iwm(4): match Wireless 8265 device.


To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.72 src/sys/dev/pci/if_iwm.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/dev/pci/if_iwm.c
diff -u src/sys/dev/pci/if_iwm.c:1.71 src/sys/dev/pci/if_iwm.c:1.72
--- src/sys/dev/pci/if_iwm.c:1.71	Tue Mar 14 23:59:26 2017
+++ src/sys/dev/pci/if_iwm.c	Fri May 19 14:18:10 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_iwm.c,v 1.71 2017/03/14 23:59:26 nonaka Exp $	*/
+/*	$NetBSD: if_iwm.c,v 1.72 2017/05/19 14:18:10 nonaka Exp $	*/
 /*	OpenBSD: if_iwm.c,v 1.148 2016/11/19 21:07:08 stsp Exp	*/
 #define IEEE80211_NO_HT
 /*
@@ -106,7 +106,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_iwm.c,v 1.71 2017/03/14 23:59:26 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_iwm.c,v 1.72 2017/05/19 14:18:10 nonaka Exp $");
 
 #include 
 #include 
@@ -7725,6 +7725,7 @@ static const pci_product_id_t iwm_device
 	PCI_PRODUCT_INTEL_WIFI_LINK_8260_2,
 	PCI_PRODUCT_INTEL_WIFI_LINK_4165_1,
 	PCI_PRODUCT_INTEL_WIFI_LINK_4165_2,
+	PCI_PRODUCT_INTEL_WIFI_LINK_8265,
 };
 
 static int



CVS commit: src/sys/dev/pci

2017-05-17 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Thu May 18 01:32:46 UTC 2017

Modified Files:
src/sys/dev/pci: if_rtwn.c

Log Message:
Fixed m is not freed if m_defrag() fails.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/dev/pci/if_rtwn.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/dev/pci/if_rtwn.c
diff -u src/sys/dev/pci/if_rtwn.c:1.11 src/sys/dev/pci/if_rtwn.c:1.12
--- src/sys/dev/pci/if_rtwn.c:1.11	Thu Feb  2 10:05:35 2017
+++ src/sys/dev/pci/if_rtwn.c	Thu May 18 01:32:46 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_rtwn.c,v 1.11 2017/02/02 10:05:35 nonaka Exp $	*/
+/*	$NetBSD: if_rtwn.c,v 1.12 2017/05/18 01:32:46 nonaka Exp $	*/
 /*	$OpenBSD: if_rtwn.c,v 1.5 2015/06/14 08:02:47 stsp Exp $	*/
 #define	IEEE80211_NO_HT
 /*-
@@ -23,7 +23,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_rtwn.c,v 1.11 2017/02/02 10:05:35 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_rtwn.c,v 1.12 2017/05/18 01:32:46 nonaka Exp $");
 
 #include 
 #include 
@@ -1957,10 +1957,13 @@ rtwn_tx(struct rtwn_softc *sc, struct mb
 	}
 	if (error != 0) {
 		/* Too many DMA segments, linearize mbuf. */
-		if ((m = m_defrag(m, M_DONTWAIT)) == NULL) {
+		struct mbuf *newm = m_defrag(m, M_DONTWAIT);
+		if (newm == NULL) {
 			aprint_error_dev(sc->sc_dev, "can't defrag mbuf\n");
+			m_freem(m);
 			return ENOBUFS;
 		}
+		m = newm;
 
 		error = bus_dmamap_load_mbuf(sc->sc_dmat, data->map, m,
 		BUS_DMA_NOWAIT | BUS_DMA_WRITE);



CVS commit: src/sys/arch/i386/stand/efiboot

2017-05-01 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Mon May  1 13:03:02 UTC 2017

Modified Files:
src/sys/arch/i386/stand/efiboot: boot.c efiboot.h eficons.c

Log Message:
efiboot: implement consdev command.

no support to change console device for efiboot yet.
only pass console parameters to kernel.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/i386/stand/efiboot/boot.c \
src/sys/arch/i386/stand/efiboot/efiboot.h
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/i386/stand/efiboot/eficons.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/i386/stand/efiboot/boot.c
diff -u src/sys/arch/i386/stand/efiboot/boot.c:1.4 src/sys/arch/i386/stand/efiboot/boot.c:1.5
--- src/sys/arch/i386/stand/efiboot/boot.c:1.4	Sun Mar 12 05:33:48 2017
+++ src/sys/arch/i386/stand/efiboot/boot.c	Mon May  1 13:03:01 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot.c,v 1.4 2017/03/12 05:33:48 nonaka Exp $	*/
+/*	$NetBSD: boot.c,v 1.5 2017/05/01 13:03:01 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -30,6 +30,7 @@
 
 #include 
 #include 
+#include 
 
 #include "bootcfg.h"
 #include "bootmod.h"
@@ -340,7 +341,7 @@ command_help(char *arg)
 	   "boot [xdNx:][filename] [-12acdqsvxz]\n"
 	   " (ex. \"hd0a:netbsd.old -s\"\n"
 	   "dev [xd[N[x]]:]\n"
-	   "consdev {pc|com[0123]|com[0123]kbd|auto}\n"
+	   "consdev {pc|com[0123][,{speed}]|com,{ioport}[,{speed}]}\n"
 	   "devpath\n"
 	   "efivar\n"
 	   "gop [{modenum|list}]\n"
@@ -436,12 +437,77 @@ command_dev(char *arg)
 	default_devname = savedevname;
 }
 
-/* ARGSUSED */
+static const struct cons_devs {
+	const char	*name;
+	u_int		tag;
+	int		ioport;
+} cons_devs[] = {
+	{ "pc",		CONSDEV_PC,   0 },
+	{ "com0",	CONSDEV_COM0, 0 },
+	{ "com1",	CONSDEV_COM1, 0 },
+	{ "com2",	CONSDEV_COM2, 0 },
+	{ "com3",	CONSDEV_COM3, 0 },
+	{ "com0kbd",	CONSDEV_COM0KBD, 0 },
+	{ "com1kbd",	CONSDEV_COM1KBD, 0 },
+	{ "com2kbd",	CONSDEV_COM2KBD, 0 },
+	{ "com3kbd",	CONSDEV_COM3KBD, 0 },
+	{ "com",	CONSDEV_COM0, -1 },
+	{ "auto",	CONSDEV_AUTO, 0 },
+	{ NULL,		0 }
+};
+
 void
 command_consdev(char *arg)
 {
-
-	/* XXX not implemented yet */
+	const struct cons_devs *cdp;
+	char *sep, *sep2 = NULL;
+	int ioport, speed = 0;
+
+	sep = strchr(arg, ',');
+	if (sep != NULL) {
+		*sep++ = '\0';
+		sep2 = strchr(sep, ',');
+		if (sep != NULL)
+			*sep2++ = '\0';
+	}
+
+	for (cdp = cons_devs; cdp->name; cdp++) {
+		if (strcmp(arg, cdp->name) == 0) {
+			ioport = cdp->ioport;
+			if (cdp->tag == CONSDEV_PC || cdp->tag == CONSDEV_AUTO) {
+if (sep != NULL || sep2 != NULL)
+	goto error;
+			} else {
+/* com? */
+if (ioport == -1) {
+	if (sep != NULL) {
+		u_long t = strtoul(sep, NULL, 0);
+		if (t > INT_MAX)
+			goto error;
+		ioport = (int)t;
+	}
+	if (sep2 != NULL) {
+		speed = atoi(sep2);
+		if (speed < 0)
+			goto error;
+	}
+} else {
+	if (sep != NULL) {
+		speed = atoi(sep);
+		if (speed < 0)
+			goto error;
+	}
+	if (sep2 != NULL)
+		goto error;
+}
+			}
+			consinit(cdp->tag, ioport, speed);
+			print_banner();
+			return;
+		}
+	}
+error:
+	printf("invalid console device.\n");
 }
 
 #ifndef SMALL
Index: src/sys/arch/i386/stand/efiboot/efiboot.h
diff -u src/sys/arch/i386/stand/efiboot/efiboot.h:1.4 src/sys/arch/i386/stand/efiboot/efiboot.h:1.5
--- src/sys/arch/i386/stand/efiboot/efiboot.h:1.4	Sat Feb 11 10:23:39 2017
+++ src/sys/arch/i386/stand/efiboot/efiboot.h	Mon May  1 13:03:01 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: efiboot.h,v 1.4 2017/02/11 10:23:39 nonaka Exp $	*/
+/*	$NetBSD: efiboot.h,v 1.5 2017/05/01 13:03:01 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -55,6 +55,7 @@ void efi_cleanup(void);
 
 /* eficons.c */
 int cninit(void);
+void consinit(int, int, int);
 void command_text(char *);
 void command_gop(char *);
 

Index: src/sys/arch/i386/stand/efiboot/eficons.c
diff -u src/sys/arch/i386/stand/efiboot/eficons.c:1.3 src/sys/arch/i386/stand/efiboot/eficons.c:1.4
--- src/sys/arch/i386/stand/efiboot/eficons.c:1.3	Fri Mar 24 01:25:36 2017
+++ src/sys/arch/i386/stand/efiboot/eficons.c	Mon May  1 13:03:01 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: eficons.c,v 1.3 2017/03/24 01:25:36 nonaka Exp $	*/
+/*	$NetBSD: eficons.c,v 1.4 2017/05/01 13:03:01 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -34,6 +34,8 @@
 #include "bootinfo.h"
 #include "vbe.h"
 
+extern struct x86_boot_params boot_params;
+
 struct btinfo_console btinfo_console;
 
 static EFI_GRAPHICS_OUTPUT_PROTOCOL *efi_gop;
@@ -46,6 +48,68 @@ static int keybuf_write = 0;
 static void eficons_init_video(void);
 static void efi_switch_video_to_text_mode(void);
 
+static int
+getcomaddr(int idx)
+{
+	static const short comioport[4] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8 };
+
+	if (idx < __arraycount(comioport))

CVS commit: src/sbin/nvmectl

2017-04-28 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Sat Apr 29 00:08:46 UTC 2017

Added Files:
src/sbin/nvmectl: wdc.c

Log Message:
Added missing file...

> nvmectl(8): sync with FreeBSD HEAD r316105.
>
>  - Expand the SMART / Health Information Log Page (Page 02) printout based on
>NVM Express 1.2.1 Standard.
>  - Implement Intel-specific log pages.
>  - Implement HGST-specific log pages.
>  - Implement wdc-specific nvme control options.
>  - Add the ability to dump log pages directly in binary to stdout.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sbin/nvmectl/wdc.c

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

Added files:

Index: src/sbin/nvmectl/wdc.c
diff -u /dev/null src/sbin/nvmectl/wdc.c:1.1
--- /dev/null	Sat Apr 29 00:08:46 2017
+++ src/sbin/nvmectl/wdc.c	Sat Apr 29 00:08:46 2017
@@ -0,0 +1,354 @@
+/*	$NetBSD: wdc.c,v 1.1 2017/04/29 00:08:46 nonaka Exp $	*/
+
+/*-
+ * Copyright (c) 2017 Netflix, Inc
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include 
+#ifndef lint
+__RCSID("$NetBSD: wdc.c,v 1.1 2017/04/29 00:08:46 nonaka Exp $");
+#if 0
+__FBSDID("$FreeBSD: head/sbin/nvmecontrol/wdc.c 316105 2017-03-28 20:34:02Z ngie $");
+#endif
+#endif
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "nvmectl.h"
+
+#define WDC_NVME_TOC_SIZE	8
+
+#define WDC_NVME_CAP_DIAG_OPCODE	0xe6
+#define WDC_NVME_CAP_DIAG_CMD		0x
+
+#define WDC_NVME_DIAG_OPCODE		0xc6
+#define WDC_NVME_DRIVE_LOG_SIZE_CMD	0x0120
+#define WDC_NVME_DRIVE_LOG_CMD		0x0020
+#define WDC_NVME_CRASH_DUMP_SIZE_CMD	0x0320
+#define WDC_NVME_CRASH_DUMP_CMD		0x0420
+#define WDC_NVME_PFAIL_DUMP_SIZE_CMD	0x0520
+#define WDC_NVME_PFAIL_DUMP_CMD		0x0620
+
+#define WDC_NVME_CLEAR_DUMP_OPCODE	0xff
+#define WDC_NVME_CLEAR_CRASH_DUMP_CMD	0x0503
+#define WDC_NVME_CLEAR_PFAIL_DUMP_CMD	0x0603
+
+static void wdc_cap_diag(int argc, char *argv[]);
+static void wdc_drive_log(int argc, char *argv[]);
+static void wdc_get_crash_dump(int argc, char *argv[]);
+static void wdc_purge(int argc, char *argv[]);
+static void wdc_purge_monitor(int argc, char *argv[]);
+
+#define WDC_CAP_DIAG_USAGE	"\tnvmecontrol wdc cap-diag [-o path-template]\n"
+#define WDC_DRIVE_LOG_USAGE	"\tnvmecontrol wdc drive-log [-o path-template]\n"
+#define WDC_GET_CRASH_DUMP_USAGE "\tnvmecontrol wdc get-crash-dump [-o path-template]\n"
+#define WDC_PURGE_USAGE		"\tnvmecontrol wdc purge [-o path-template]\n"
+#define WDC_PURGE_MONITOR_USAGE	"\tnvmecontrol wdc purge-monitor\n"
+
+static struct nvme_function wdc_funcs[] = {
+	{"cap-diag",		wdc_cap_diag,		WDC_CAP_DIAG_USAGE},
+	{"drive-log",		wdc_drive_log,		WDC_DRIVE_LOG_USAGE},
+	{"get-crash-dump",	wdc_get_crash_dump,	WDC_GET_CRASH_DUMP_USAGE},
+	{"purge",		wdc_purge,		WDC_PURGE_USAGE},
+	{"purge_monitor",	wdc_purge_monitor,	WDC_PURGE_MONITOR_USAGE},
+	{NULL,			NULL,			NULL},
+};
+
+static void
+wdc_append_serial_name(int fd, char *buf, size_t len, const char *suffix)
+{
+	struct nvm_identify_controller	cdata;
+	char sn[sizeof(cdata.sn) + 1];
+	char *walker;
+
+	len -= strlen(buf);
+	buf += strlen(buf);
+	read_controller_data(fd, );
+	memcpy(sn, cdata.sn, sizeof(cdata.sn));
+	walker = sn + sizeof(cdata.sn) - 1;
+	while (walker > sn && *walker == ' ')
+		walker--;
+	*++walker = '\0';
+	snprintf(buf, len, "%s%s.bin", sn, suffix);
+}
+
+static void
+wdc_get_data(int fd, uint32_t opcode, uint32_t len, uint32_t off, uint32_t cmd,
+uint8_t *buffer, size_t buflen)
+{
+	struct nvme_pt_command	pt;
+
+	memset(, 0, sizeof(pt));
+	pt.cmd.opcode = opcode;
+	pt.cmd.cdw10 = len / 

CVS commit: src/sbin/nvmectl

2017-04-28 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Sat Apr 29 00:06:40 UTC 2017

Modified Files:
src/sbin/nvmectl: Makefile firmware.c logpage.c nvme.h nvmectl.8
nvmectl.c nvmectl.h

Log Message:
nvmectl(8): sync with FreeBSD HEAD r316105.

 - Expand the SMART / Health Information Log Page (Page 02) printout based on
   NVM Express 1.2.1 Standard.
 - Implement Intel-specific log pages.
 - Implement HGST-specific log pages.
 - Implement wdc-specific nvme control options.
 - Add the ability to dump log pages directly in binary to stdout.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sbin/nvmectl/Makefile src/sbin/nvmectl/nvmectl.8 \
src/sbin/nvmectl/nvmectl.c src/sbin/nvmectl/nvmectl.h
cvs rdiff -u -r1.1 -r1.2 src/sbin/nvmectl/firmware.c src/sbin/nvmectl/nvme.h
cvs rdiff -u -r1.3 -r1.4 src/sbin/nvmectl/logpage.c

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

Modified files:

Index: src/sbin/nvmectl/Makefile
diff -u src/sbin/nvmectl/Makefile:1.2 src/sbin/nvmectl/Makefile:1.3
--- src/sbin/nvmectl/Makefile:1.2	Mon Feb 13 11:16:46 2017
+++ src/sbin/nvmectl/Makefile	Sat Apr 29 00:06:40 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.2 2017/02/13 11:16:46 nonaka Exp $
+#	$NetBSD: Makefile,v 1.3 2017/04/29 00:06:40 nonaka Exp $
 
 .include 
 
@@ -11,6 +11,7 @@ SRCS+=	logpage.c
 SRCS+=	perftest.c
 SRCS+=	power.c
 SRCS+=	reset.c
+SRCS+=	wdc.c
 SRCS+=	bignum.c
 SRCS+=	humanize_bignum.c
 MAN=	nvmectl.8
Index: src/sbin/nvmectl/nvmectl.8
diff -u src/sbin/nvmectl/nvmectl.8:1.2 src/sbin/nvmectl/nvmectl.8:1.3
--- src/sbin/nvmectl/nvmectl.8:1.2	Sun Jun  5 09:13:08 2016
+++ src/sbin/nvmectl/nvmectl.8	Sat Apr 29 00:06:40 2017
@@ -1,4 +1,4 @@
-.\" $NetBSD: nvmectl.8,v 1.2 2016/06/05 09:13:08 wiz Exp $
+.\" $NetBSD: nvmectl.8,v 1.3 2017/04/29 00:06:40 nonaka Exp $
 .\"
 .\" Copyright (c) 2012 Intel Corporation
 .\" All rights reserved.
@@ -32,7 +32,7 @@
 .\"
 .\" Author: Jim Harris 
 .\"
-.\" $FreeBSD: head/sbin/nvmecontrol/nvmecontrol.8 299151 2016-05-06 03:11:34Z pfg $
+.\" $FreeBSD: head/sbin/nvmecontrol/nvmecontrol.8 314230 2017-02-25 00:09:16Z imp $
 .\"
 .Dd May 19, 2016
 .Dt NVMECTL 8
@@ -62,6 +62,8 @@
 .Ic logpage
 .Op Fl x
 .Op Fl p Ar page_id
+.Op Fl v Ar vendor-string
+.Op Fl b
 .Ar device_id Ns | Ns Ar namespace_id
 .\".Nm
 .\".Ic firmware
@@ -75,9 +77,56 @@
 .Op Fl p Ar power_state
 .Op Fl w Ar workload_hint
 .Ar device_id
+.Nm
+.Ic wdc cap-diag
+.Op Fl o path_template
+.Ar device id
+.Nm
+.Ic wdc drive-log
+.Op Fl o path_template
+.Ar device id
+.Nm
+.Ic wdc get-crash-dump
+.Op Fl o path_template
+.Ar device id
+.\" .Nm
+.\" .Ic wdc purge
+.\" .Aq device id
+.\" .Nm
+.\" .Ic wdc purge-monitor
+.\" .Aq device id
 .Sh DESCRIPTION
 NVM Express (NVMe) is a storage protocol standard, for SSDs and other
 high-speed storage devices over PCI Express.
+.Pp
+.Ss logpage
+The logpage command knows how to print log pages of various types.
+It also knows about vendor specific log pages from hgst/wdc and intel.
+Page 0xc1 for hgst/wdc contains the advanced smart information about
+the drive.
+Page 0xc1 is read latency stats for intel.
+Page 0xc2 is write latency stats for intel.
+Page 0xc5 is temperature stats for intel.
+Page 0xca is advanced smart information for intel.
+.Pp
+Specifying
+.Fl p
+.Ic help
+will list all valid vendors and pages.
+.Fl x
+will print the page as hex.
+.Fl b
+will print the binary data for the page.
+.Ss wdc
+The various wdc command retrieve log data from the wdc/hgst drives.
+The
+.Fl o
+flag specifies a path template to use to output the files.
+Each file takes the path template (which defaults to nothing), appends
+the drive's serial number and the type of dump it is followed
+by .bin.
+These logs must be sent to the vendor for analysis.
+This tool only provides a way to extract them.
 .Sh EXAMPLES
 .Dl nvmectl devlist
 .Pp
@@ -95,9 +144,9 @@ data for namespace 1.
 .\".Pp
 .\".Dl nvmectl perftest -n 32 -o read -s 512 -t 30 nvme0ns1
 .\".Pp
-.\"Run a performance test on nvme0ns1 using 32 kernel threads for 30 seconds.  Each
-.\"thread will issue a single 512 byte read command.  Results are printed to
-.\"stdout when 30 seconds expires.
+.\"Run a performance test on nvme0ns1 using 32 kernel threads for 30 seconds.
+.\"Each thread will issue a single 512 byte read command.
+.\"Results are printed to stdout when 30 seconds expires.
 .\".Pp
 .\".Dl nvmectl reset nvme0
 .\".Pp
@@ -109,9 +158,20 @@ Display a human-readable summary of the 
 Log pages defined by the NVMe specification include Error Information Log (ID=1),
 SMART/Health Information Log (ID=2), and Firmware Slot Log (ID=3).
 .Pp
+.Dl nvmectl logpage -p 0xc1 -v wdc nvme0
+.Pp
+Display a human-readable summary of the nvme0's wdc-specific advanced
+SMART data.
+.Pp
 .Dl nvmectl logpage -p 1 -x nvme0
 .Pp
 Display a hexadecimal dump of the nvme0 controller's Error Information Log.
+.Pp
+.Dl nvmectl logpage 

CVS commit: src/sys

2017-04-28 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Sat Apr 29 00:05:36 UTC 2017

Modified Files:
src/sys/arch/i386/stand/efiboot: Makefile.efiboot
src/sys/arch/i386/stand/efiboot/bootia32: efibootia32.c start.S
src/sys/arch/i386/stand/efiboot/bootx64: efibootx64.c start.S
src/sys/sys: bootblock.h

Log Message:
efiboot: Boot parameters can be set via installboot(8).


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/i386/stand/efiboot/Makefile.efiboot
cvs rdiff -u -r1.2 -r1.3 \
src/sys/arch/i386/stand/efiboot/bootia32/efibootia32.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/i386/stand/efiboot/bootia32/start.S
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/i386/stand/efiboot/bootx64/efibootx64.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/i386/stand/efiboot/bootx64/start.S
cvs rdiff -u -r1.57 -r1.58 src/sys/sys/bootblock.h

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/i386/stand/efiboot/Makefile.efiboot
diff -u src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.8 src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.9
--- src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.8	Sat Apr  8 19:53:21 2017
+++ src/sys/arch/i386/stand/efiboot/Makefile.efiboot	Sat Apr 29 00:05:35 2017
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.efiboot,v 1.8 2017/04/08 19:53:21 christos Exp $
+# $NetBSD: Makefile.efiboot,v 1.9 2017/04/29 00:05:35 nonaka Exp $
 
 S=		${.CURDIR}/../../../../..
 
@@ -10,7 +10,7 @@ AFLAGS.start.S= ${${ACTIVE_CC} == "clang
 
 SOURCES?= start.S conf.c devopen.c efiboot.c self_reloc.c
 LIBI386SRCS= boot.c biosdisk.c bootinfo.c bootinfo_biosgeom.c
-LIBI386SRCS+= bootmenu.c boot_params.S diskbuf.c exec.c menuutils.c
+LIBI386SRCS+= bootmenu.c diskbuf.c exec.c menuutils.c
 LIBI386SRCS+= panic.c parseutils.c pread.c
 LIBI386SRCS+= eficons.c efidelay.c efidisk.c efidisk_ll.c efigetsecs.c
 LIBI386SRCS+= efimemory.c

Index: src/sys/arch/i386/stand/efiboot/bootia32/efibootia32.c
diff -u src/sys/arch/i386/stand/efiboot/bootia32/efibootia32.c:1.2 src/sys/arch/i386/stand/efiboot/bootia32/efibootia32.c:1.3
--- src/sys/arch/i386/stand/efiboot/bootia32/efibootia32.c:1.2	Tue Feb 21 10:53:37 2017
+++ src/sys/arch/i386/stand/efiboot/bootia32/efibootia32.c	Sat Apr 29 00:05:35 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: efibootia32.c,v 1.2 2017/02/21 10:53:37 nonaka Exp $	*/
+/*	$NetBSD: efibootia32.c,v 1.3 2017/04/29 00:05:35 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -30,8 +30,6 @@
 
 #include 
 
-struct x86_boot_params boot_params;
-
 void startprog32_start(physaddr_t, uint32_t, uint32_t *, physaddr_t,
 physaddr_t, physaddr_t, u_long, void *);
 extern void (*startprog32)(physaddr_t, uint32_t, uint32_t *, physaddr_t,

Index: src/sys/arch/i386/stand/efiboot/bootia32/start.S
diff -u src/sys/arch/i386/stand/efiboot/bootia32/start.S:1.1 src/sys/arch/i386/stand/efiboot/bootia32/start.S:1.2
--- src/sys/arch/i386/stand/efiboot/bootia32/start.S:1.1	Tue Jan 24 11:09:14 2017
+++ src/sys/arch/i386/stand/efiboot/bootia32/start.S	Sat Apr 29 00:05:35 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: start.S,v 1.1 2017/01/24 11:09:14 nonaka Exp $	*/
+/*	$NetBSD: start.S,v 1.2 2017/04/29 00:05:35 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2008-2010 Rui Paulo 
@@ -29,6 +29,7 @@
  */
 
 #include 
+#include 
 
 	.text
 	.align	16
@@ -72,3 +73,18 @@ END(_start)
 	.long   0
 	.long   10
 	.word   0
+
+	/* boot parameters */
+	.text
+	.code16
+	.align 512
+.Lfake_bootxx:
+	jmp	1f
+	.balign 4
+	.long	X86_BOOT_MAGIC_EFI	/* checked by installboot */
+	.globl _C_LABEL(boot_params)
+_C_LABEL(boot_params):			/* space for patchable variables */
+	.long	1f - boot_params	/* length of this data area */
+#include 
+	. = .Lfake_bootxx + 0x80	/* Space for patching unknown params */
+1:

Index: src/sys/arch/i386/stand/efiboot/bootx64/efibootx64.c
diff -u src/sys/arch/i386/stand/efiboot/bootx64/efibootx64.c:1.2 src/sys/arch/i386/stand/efiboot/bootx64/efibootx64.c:1.3
--- src/sys/arch/i386/stand/efiboot/bootx64/efibootx64.c:1.2	Sat Feb 11 10:23:39 2017
+++ src/sys/arch/i386/stand/efiboot/bootx64/efibootx64.c	Sat Apr 29 00:05:35 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: efibootx64.c,v 1.2 2017/02/11 10:23:39 nonaka Exp $	*/
+/*	$NetBSD: efibootx64.c,v 1.3 2017/04/29 00:05:35 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -30,8 +30,6 @@
 
 #include 
 
-struct x86_boot_params boot_params;
-
 void startprog64_start(physaddr_t, physaddr_t, physaddr_t, u_long,
 void *, physaddr_t);
 extern void (*startprog64)(physaddr_t, physaddr_t, physaddr_t, u_long,

Index: src/sys/arch/i386/stand/efiboot/bootx64/start.S
diff -u src/sys/arch/i386/stand/efiboot/bootx64/start.S:1.1 src/sys/arch/i386/stand/efiboot/bootx64/start.S:1.2
--- src/sys/arch/i386/stand/efiboot/bootx64/start.S:1.1	Tue Jan 24 11:09:14 2017
+++ src/sys/arch/i386/stand/efiboot/bootx64/start.S	Sat Apr 29 

CVS commit: src/sys/arch/x86/include

2017-04-27 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Fri Apr 28 01:23:58 UTC 2017

Modified Files:
src/sys/arch/x86/include: i82489reg.h

Log Message:
Added AMD extended APIC register space present definition.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/x86/include/i82489reg.h

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/include/i82489reg.h
diff -u src/sys/arch/x86/include/i82489reg.h:1.15 src/sys/arch/x86/include/i82489reg.h:1.16
--- src/sys/arch/x86/include/i82489reg.h:1.15	Sat Apr 22 04:24:25 2017
+++ src/sys/arch/x86/include/i82489reg.h	Fri Apr 28 01:23:58 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: i82489reg.h,v 1.15 2017/04/22 04:24:25 nonaka Exp $	*/
+/*	$NetBSD: i82489reg.h,v 1.16 2017/04/28 01:23:58 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
@@ -44,6 +44,7 @@
 #	define LAPIC_VERSION_LVT_MASK	0x00ff
 #	define LAPIC_VERSION_LVT_SHIFT	16
 #	define LAPIC_VERSION_DIRECTED_EOI 0x0100
+#	define LAPIC_VERSION_EXTAPIC_SPACE 0x8000
 
 #define LAPIC_TPRI		0x080	/* Task Prio. RW */
 #	define LAPIC_TPRI_MASK		0x00ff



CVS commit: src/sys/arch

2017-04-21 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Sat Apr 22 04:29:31 UTC 2017

Modified Files:
src/sys/arch/i386/i386: autoconf.c
src/sys/arch/x86/include: i82489var.h
src/sys/arch/x86/x86: cpu.c lapic.c

Log Message:
use CR8 instead of LAPIC Task Priority register on x86-64.


To generate a diff of this commit:
cvs rdiff -u -r1.101 -r1.102 src/sys/arch/i386/i386/autoconf.c
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/x86/include/i82489var.h
cvs rdiff -u -r1.123 -r1.124 src/sys/arch/x86/x86/cpu.c
cvs rdiff -u -r1.55 -r1.56 src/sys/arch/x86/x86/lapic.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/i386/i386/autoconf.c
diff -u src/sys/arch/i386/i386/autoconf.c:1.101 src/sys/arch/i386/i386/autoconf.c:1.102
--- src/sys/arch/i386/i386/autoconf.c:1.101	Sun Oct 16 10:24:59 2016
+++ src/sys/arch/i386/i386/autoconf.c	Sat Apr 22 04:29:31 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.101 2016/10/16 10:24:59 maxv Exp $	*/
+/*	$NetBSD: autoconf.c,v 1.102 2017/04/22 04:29:31 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -46,7 +46,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.101 2016/10/16 10:24:59 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.102 2017/04/22 04:29:31 nonaka Exp $");
 
 #include "opt_compat_oldboot.h"
 #include "opt_intrdebug.h"
@@ -131,6 +131,6 @@ cpu_configure(void)
 
 	spl0();
 #if NLAPIC > 0
-	i82489_writereg(LAPIC_TPRI, 0);
+	lapic_write_tpri(0);
 #endif
 }

Index: src/sys/arch/x86/include/i82489var.h
diff -u src/sys/arch/x86/include/i82489var.h:1.17 src/sys/arch/x86/include/i82489var.h:1.18
--- src/sys/arch/x86/include/i82489var.h:1.17	Wed Apr 19 06:43:05 2017
+++ src/sys/arch/x86/include/i82489var.h	Sat Apr 22 04:29:31 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: i82489var.h,v 1.17 2017/04/19 06:43:05 nonaka Exp $	*/
+/*	$NetBSD: i82489var.h,v 1.18 2017/04/22 04:29:31 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -104,4 +104,6 @@ extern void lapic_enable(void);
 extern void lapic_calibrate_timer(struct cpu_info *ci);
 extern void lapic_initclocks(void);
 
+extern void lapic_write_tpri(uint32_t);
+
 #endif

Index: src/sys/arch/x86/x86/cpu.c
diff -u src/sys/arch/x86/x86/cpu.c:1.123 src/sys/arch/x86/x86/cpu.c:1.124
--- src/sys/arch/x86/x86/cpu.c:1.123	Sat Feb 11 14:11:24 2017
+++ src/sys/arch/x86/x86/cpu.c	Sat Apr 22 04:29:31 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.123 2017/02/11 14:11:24 maxv Exp $	*/
+/*	$NetBSD: cpu.c,v 1.124 2017/04/22 04:29:31 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2000-2012 NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.123 2017/02/11 14:11:24 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.124 2017/04/22 04:29:31 nonaka Exp $");
 
 #include "opt_ddb.h"
 #include "opt_mpbios.h"		/* for MPDEBUG */
@@ -879,11 +879,7 @@ cpu_hatch(void *v)
 	cpu_get_tsc_freq(ci);
 
 	s = splhigh();
-#ifdef i386
-	i82489_writereg(LAPIC_TPRI, 0);
-#else
-	lcr8(0);
-#endif
+	lapic_write_tpri(0);
 	x86_enable_intr();
 	splx(s);
 	x86_errata();

Index: src/sys/arch/x86/x86/lapic.c
diff -u src/sys/arch/x86/x86/lapic.c:1.55 src/sys/arch/x86/x86/lapic.c:1.56
--- src/sys/arch/x86/x86/lapic.c:1.55	Sat Apr 22 04:24:26 2017
+++ src/sys/arch/x86/x86/lapic.c	Sat Apr 22 04:29:31 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lapic.c,v 1.55 2017/04/22 04:24:26 nonaka Exp $	*/
+/*	$NetBSD: lapic.c,v 1.56 2017/04/22 04:29:31 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2000, 2008 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lapic.c,v 1.55 2017/04/22 04:24:26 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lapic.c,v 1.56 2017/04/22 04:29:31 nonaka Exp $");
 
 #include "opt_ddb.h"
 #include "opt_mpbios.h"		/* for MPDEBUG */
@@ -89,6 +89,18 @@ struct pic local_pic = {
 	.pic_delroute = lapic_setup,
 };
 
+void
+lapic_write_tpri(uint32_t val)
+{
+
+	val &= LAPIC_TPRI_MASK;
+#ifdef i386
+	i82489_writereg(LAPIC_TPRI, val);
+#else
+	lcr8(val >> 4);
+#endif
+}
+
 static void
 lapic_map(paddr_t lapic_base)
 {
@@ -130,7 +142,7 @@ lapic_map(paddr_t lapic_base)
 	cpu_init_first();	/* catch up to changed cpu_number() */
 #endif
 
-	i82489_writereg(LAPIC_TPRI, 0);
+	lapic_write_tpri(0);
 	x86_enable_intr();
 }
 



CVS commit: src/sys/arch/x86/include

2017-04-21 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Sat Apr 22 04:25:09 UTC 2017

Modified Files:
src/sys/arch/x86/include: i82093reg.h

Log Message:
Added I/O APIC EOI register definition.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/x86/include/i82093reg.h

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/include/i82093reg.h
diff -u src/sys/arch/x86/include/i82093reg.h:1.4 src/sys/arch/x86/include/i82093reg.h:1.5
--- src/sys/arch/x86/include/i82093reg.h:1.4	Sat Jan 26 17:37:39 2013
+++ src/sys/arch/x86/include/i82093reg.h	Sat Apr 22 04:25:09 2017
@@ -1,4 +1,4 @@
-/* 	$NetBSD: i82093reg.h,v 1.4 2013/01/26 17:37:39 dyoung Exp $ */
+/* 	$NetBSD: i82093reg.h,v 1.5 2017/04/22 04:25:09 nonaka Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -50,6 +50,8 @@
 
 #define	IOAPIC_REG		0x
 #define IOAPIC_DATA		0x0010
+#define IOAPIC_EOI		0x0040
+#define		IOAPIC_EOI_MASK		0x00ff
 
 /*
  * Internal I/O APIC registers.



  1   2   3   4   5   6   7   >