CVS commit: src/sys/dev/i2c

2018-05-11 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat May 12 01:31:08 UTC 2018

Modified Files:
src/sys/dev/i2c: axppmic.c

Log Message:
Trigger shutdown on POKLIRQ instead of POKSIRQ.

POKSIRQ is triggered if POK remains low for less than IRQLEVEL. This makes
it way too easy to accidentally trigger shutdown. POKLIRQ is triggered if
POK hold time is greater than IRQLEVEL, which is much more reasonable for
this use case.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/i2c/axppmic.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/i2c/axppmic.c
diff -u src/sys/dev/i2c/axppmic.c:1.6 src/sys/dev/i2c/axppmic.c:1.7
--- src/sys/dev/i2c/axppmic.c:1.6	Thu May 10 23:57:31 2018
+++ src/sys/dev/i2c/axppmic.c	Sat May 12 01:31:07 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: axppmic.c,v 1.6 2018/05/10 23:57:31 jmcneill Exp $ */
+/* $NetBSD: axppmic.c,v 1.7 2018/05/12 01:31:07 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014-2018 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: axppmic.c,v 1.6 2018/05/10 23:57:31 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: axppmic.c,v 1.7 2018/05/12 01:31:07 jmcneill Exp $");
 
 #include 
 #include 
@@ -61,8 +61,6 @@ __KERNEL_RCSID(0, "$NetBSD: axppmic.c,v 
 #define	 AXP_IRQ1_ACIN_LOWER	__BIT(5)
 #define	 AXP_IRQ1_VBUS_RAISE	__BIT(3)
 #define	 AXP_IRQ1_VBUS_LOWER	__BIT(2)
-#define	 AXP_IRQ2_POKSIRQ	__BIT(1)
-#define	 AXP_IRQ2_
 #define AXP_IRQ_STATUS_REG(n)	(0x48 + (n) - 1)
 
 #define	AXP_FUEL_GAUGE_CTRL_REG	0xb8
@@ -186,8 +184,8 @@ struct axppmic_config {
 	u_int irq_regs;
 	bool has_battery;
 	bool has_fuel_gauge;
-	u_int poksirq_reg;
-	uint8_t poksirq_mask;
+	u_int poklirq_reg;
+	uint8_t poklirq_mask;
 };
 
 enum axppmic_sensor {
@@ -208,8 +206,8 @@ struct axppmic_softc {
 
 	bool		sc_has_battery;
 	bool		sc_has_fuel_gauge;
-	u_int		sc_poksirq_reg;
-	uint8_t		sc_poksirq_mask;
+	u_int		sc_poklirq_reg;
+	uint8_t		sc_poklirq_mask;
 
 	u_int		sc_irq_regs;
 
@@ -244,8 +242,8 @@ static const struct axppmic_config axp80
 	.irq_regs = 6,
 	.has_battery = true,
 	.has_fuel_gauge = true,
-	.poksirq_reg = 5,
-	.poksirq_mask = __BIT(4),
+	.poklirq_reg = 5,
+	.poklirq_mask = __BIT(3),
 };
 
 static const struct axppmic_config axp805_config = {
@@ -253,8 +251,8 @@ static const struct axppmic_config axp80
 	.controls = axp805_ctrls,
 	.ncontrols = __arraycount(axp805_ctrls),
 	.irq_regs = 2,
-	.poksirq_reg = 2,
-	.poksirq_mask = __BIT(1),
+	.poklirq_reg = 2,
+	.poklirq_mask = __BIT(0),
 };
 
 static const struct of_compat_data compat_data[] = {
@@ -379,11 +377,11 @@ axppmic_intr(void *priv)
 	iic_acquire_bus(sc->sc_i2c, flags);
 	for (n = 1; n <= sc->sc_irq_regs; n++) {
 		if (axppmic_read(sc->sc_i2c, sc->sc_addr, AXP_IRQ_STATUS_REG(n), , flags) == 0) {
-			if (n == sc->sc_poksirq_reg && (stat & sc->sc_poksirq_mask) != 0)
+			if (n == sc->sc_poklirq_reg && (stat & sc->sc_poklirq_mask) != 0)
 sysmon_task_queue_sched(0, axppmic_task_shut, sc);
 
 			axppmic_write(sc->sc_i2c, sc->sc_addr,
-			AXP_IRQ_STATUS_REG(sc->sc_poksirq_reg), stat, flags);
+			AXP_IRQ_STATUS_REG(sc->sc_poklirq_reg), stat, flags);
 		}
 	}
 	iic_release_bus(sc->sc_i2c, flags);
@@ -582,8 +580,8 @@ axppmic_attach(device_t parent, device_t
 	sc->sc_has_battery = c->has_battery;
 	sc->sc_has_fuel_gauge = c->has_fuel_gauge;
 	sc->sc_irq_regs = c->irq_regs;
-	sc->sc_poksirq_reg = c->poksirq_reg;
-	sc->sc_poksirq_mask = c->poksirq_mask;
+	sc->sc_poklirq_reg = c->poklirq_reg;
+	sc->sc_poklirq_mask = c->poklirq_mask;
 
 	aprint_naive("\n");
 	aprint_normal(": %s\n", c->name);
@@ -595,8 +593,8 @@ axppmic_attach(device_t parent, device_t
 	iic_acquire_bus(sc->sc_i2c, I2C_F_POLL);
 	for (i = 1; i <= c->irq_regs; i++) {
 		irq_mask = 0;
-		if (i == c->poksirq_reg)
-			irq_mask |= c->poksirq_mask;
+		if (i == c->poklirq_reg)
+			irq_mask |= c->poklirq_mask;
 		axppmic_write(sc->sc_i2c, sc->sc_addr, AXP_IRQ_ENABLE_REG(i), irq_mask, I2C_F_POLL);
 	}
 	iic_release_bus(sc->sc_i2c, I2C_F_POLL);



CVS commit: src/sys/arch/arm/sunxi

2018-05-11 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri May 11 23:05:41 UTC 2018

Modified Files:
src/sys/arch/arm/sunxi: sun50i_a64_acodec.c sun8i_codec.c

Log Message:
Disable lineout by default. If HP is not plugged at boot, we get an
unplug event. However, no plug event when HP is plugged at boot.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/sunxi/sun50i_a64_acodec.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/sunxi/sun8i_codec.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/arm/sunxi/sun50i_a64_acodec.c
diff -u src/sys/arch/arm/sunxi/sun50i_a64_acodec.c:1.3 src/sys/arch/arm/sunxi/sun50i_a64_acodec.c:1.4
--- src/sys/arch/arm/sunxi/sun50i_a64_acodec.c:1.3	Fri May 11 22:51:12 2018
+++ src/sys/arch/arm/sunxi/sun50i_a64_acodec.c	Fri May 11 23:05:41 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: sun50i_a64_acodec.c,v 1.3 2018/05/11 22:51:12 jmcneill Exp $ */
+/* $NetBSD: sun50i_a64_acodec.c,v 1.4 2018/05/11 23:05:41 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sun50i_a64_acodec.c,v 1.3 2018/05/11 22:51:12 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sun50i_a64_acodec.c,v 1.4 2018/05/11 23:05:41 jmcneill Exp $");
 
 #include 
 #include 
@@ -439,15 +439,21 @@ a64_acodec_dai_jack_detect(audio_dai_tag
 {
 	struct a64_acodec_softc * const sc = audio_dai_private(dai);
 	const uint32_t lineout_mask = A64_LINEOUT_LEFT_EN | A64_LINEOUT_RIGHT_EN;
+	const uint32_t hppa_mask = A64_HPPA_EN;
 
 	switch (jack) {
 	case AUDIO_DAI_JACK_HP:
-		if (present)
+		if (present) {
 			a64_acodec_pr_set_clear(sc, A64_LINEOUT_CTRL0,
 			0, lineout_mask);
-		else
+			a64_acodec_pr_set_clear(sc, A64_HP_CTRL,
+			hppa_mask, 0);
+		} else {
 			a64_acodec_pr_set_clear(sc, A64_LINEOUT_CTRL0,
 			lineout_mask, 0);
+			a64_acodec_pr_set_clear(sc, A64_HP_CTRL,
+			0, hppa_mask);
+		}
 		break;
 	case AUDIO_DAI_JACK_MIC:
 		/* XXX TODO */
@@ -495,12 +501,10 @@ a64_acodec_attach(device_t parent, devic
 	aprint_naive("\n");
 	aprint_normal(": A64 Audio Codec (analog part)\n");
 
-	/* Right & Left LINEOUT enable */
-	a64_acodec_pr_set_clear(sc, A64_LINEOUT_CTRL0,
-	A64_LINEOUT_LEFT_EN | A64_LINEOUT_RIGHT_EN, 0);
 	/* Right & Left Headphone PA enable */
 	a64_acodec_pr_set_clear(sc, A64_HP_CTRL,
 	A64_HPPA_EN, 0);
+
 	/* Jack detect enable */
 	a64_acodec_pr_set_clear(sc, A64_JACK_MIC_CTRL,
 	A64_JACKDETEN | A64_INNERRESEN | A64_AUTOPLEN, 0);

Index: src/sys/arch/arm/sunxi/sun8i_codec.c
diff -u src/sys/arch/arm/sunxi/sun8i_codec.c:1.2 src/sys/arch/arm/sunxi/sun8i_codec.c:1.3
--- src/sys/arch/arm/sunxi/sun8i_codec.c:1.2	Fri May 11 22:51:12 2018
+++ src/sys/arch/arm/sunxi/sun8i_codec.c	Fri May 11 23:05:41 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: sun8i_codec.c,v 1.2 2018/05/11 22:51:12 jmcneill Exp $ */
+/* $NetBSD: sun8i_codec.c,v 1.3 2018/05/11 23:05:41 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sun8i_codec.c,v 1.2 2018/05/11 22:51:12 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sun8i_codec.c,v 1.3 2018/05/11 23:05:41 jmcneill Exp $");
 
 #include 
 #include 
@@ -118,7 +118,6 @@ struct sun8i_codec_softc {
 
 	struct audio_dai_device	sc_dai;
 	audio_dai_tag_t		sc_codec_analog;
-	uint32_t		sc_jackdet;
 	int			sc_jackdet_pol;
 
 	struct fdtbus_gpio_pin	*sc_pin_pa;
@@ -260,15 +259,15 @@ sun8i_codec_set_jackdet(struct sun8i_cod
 static int
 sun8i_codec_intr(void *priv)
 {
-	struct sun8i_codec_softc * const sc = priv;
 	const uint32_t mask =
 	HMIC_STS_JACK_DET_OIRQ |
 	HMIC_STS_JACK_DET_IIRQ |
 	HMIC_STS_MIC_DET_ST;
+	struct sun8i_codec_softc * const sc = priv;
+	uint32_t val;
 
-	sc->sc_jackdet = RD4(sc, HMIC_STS);
-
-	if (sc->sc_jackdet & mask) {
+	val = RD4(sc, HMIC_STS);
+	if (val & mask) {
 		/* Disable jack detect IRQ until work is complete */
 		sun8i_codec_set_jackdet(sc, false);
 
@@ -276,8 +275,6 @@ sun8i_codec_intr(void *priv)
 		workqueue_enqueue(sc->sc_workq, >sc_work, NULL);
 	}
 
-	WR4(sc, HMIC_STS, sc->sc_jackdet);
-
 	return 1;
 }
 
@@ -286,17 +283,19 @@ static void
 sun8i_codec_thread(struct work *wk, void *priv)
 {
 	struct sun8i_codec_softc * const sc = priv;
-	const uint32_t sts = sc->sc_jackdet;
 	int hpdet = -1, micdet = -1;
+	uint32_t val;
+
+	val = RD4(sc, HMIC_STS);
 
 	if (sc->sc_codec_analog) {
-		if (sts & HMIC_STS_JACK_DET_OIRQ)
+		if (val & HMIC_STS_JACK_DET_OIRQ)
 			hpdet = 0 ^ sc->sc_jackdet_pol;
-		else if (sts & HMIC_STS_JACK_DET_IIRQ)
+		else if (val & HMIC_STS_JACK_DET_IIRQ)
 			hpdet = 1 ^ sc->sc_jackdet_pol;
 
-		if (sts & HMIC_STS_MIC_DET_ST)
-			micdet = !!(sts & HMIC_STS_MIC_PRESENT);
+		if (val & HMIC_STS_MIC_DET_ST)
+			micdet = !!(val & HMIC_STS_MIC_PRESENT);
 
 		if (hpdet != -1) {
 			

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

2018-05-11 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri May 11 22:51:33 UTC 2018

Modified Files:
src/sys/arch/macppc/conf: INSTALL

Log Message:
fix tpyo


To generate a diff of this commit:
cvs rdiff -u -r1.126 -r1.127 src/sys/arch/macppc/conf/INSTALL

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/macppc/conf/INSTALL
diff -u src/sys/arch/macppc/conf/INSTALL:1.126 src/sys/arch/macppc/conf/INSTALL:1.127
--- src/sys/arch/macppc/conf/INSTALL:1.126	Thu Sep 14 07:58:42 2017
+++ src/sys/arch/macppc/conf/INSTALL	Fri May 11 22:51:33 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: INSTALL,v 1.126 2017/09/14 07:58:42 mrg Exp $
+#	$NetBSD: INSTALL,v 1.127 2018/05/11 22:51:33 macallan Exp $
 #
 # config file for INSTALL FLOPPY
 #
@@ -152,7 +152,7 @@ nvram*	at obio?			# nvram
 #adb*	at obio?			# Apple Desktop Bus
 #akbd*	at adb?# ADB keyboard
 cuda*	at obio?			# Apple CUDA
-pmu*	at obio?			# Apple CUDA
+pmu*	at obio?			# Apple PMU
 nadb*	at cuda?			# new ADB Bus abstraction
 nadb*	at pmu?# new ADB Bus abstraction
 adbkbd* at nadb?			# ADB keyboard



CVS commit: src/sys/arch/arm/sunxi

2018-05-11 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri May 11 22:51:12 UTC 2018

Modified Files:
src/sys/arch/arm/sunxi: sun50i_a64_acodec.c sun8i_codec.c

Log Message:
Add HP jack detect support. When HP is present, mute lineout.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/sunxi/sun50i_a64_acodec.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/sunxi/sun8i_codec.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/arm/sunxi/sun50i_a64_acodec.c
diff -u src/sys/arch/arm/sunxi/sun50i_a64_acodec.c:1.2 src/sys/arch/arm/sunxi/sun50i_a64_acodec.c:1.3
--- src/sys/arch/arm/sunxi/sun50i_a64_acodec.c:1.2	Thu May 10 00:30:56 2018
+++ src/sys/arch/arm/sunxi/sun50i_a64_acodec.c	Fri May 11 22:51:12 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: sun50i_a64_acodec.c,v 1.2 2018/05/10 00:30:56 jmcneill Exp $ */
+/* $NetBSD: sun50i_a64_acodec.c,v 1.3 2018/05/11 22:51:12 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sun50i_a64_acodec.c,v 1.2 2018/05/10 00:30:56 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sun50i_a64_acodec.c,v 1.3 2018/05/11 22:51:12 jmcneill Exp $");
 
 #include 
 #include 
@@ -89,6 +89,10 @@ __KERNEL_RCSID(0, "$NetBSD: sun50i_a64_a
 #define	 A64_ADCREN		__BIT(7)
 #define	 A64_ADCLEN		__BIT(6)
 #define	 A64_ADCG		__BITS(2,0)
+#define	A64_JACK_MIC_CTRL	0x1d
+#define	 A64_JACKDETEN		__BIT(7)
+#define	 A64_INNERRESEN		__BIT(6)
+#define	 A64_AUTOPLEN		__BIT(1)
 
 struct a64_acodec_softc {
 	device_t		sc_dev;
@@ -430,6 +434,29 @@ static struct fdtbus_dai_controller_func
 	.get_tag = a64_acodec_dai_get_tag
 };
 
+static int
+a64_acodec_dai_jack_detect(audio_dai_tag_t dai, u_int jack, int present)
+{
+	struct a64_acodec_softc * const sc = audio_dai_private(dai);
+	const uint32_t lineout_mask = A64_LINEOUT_LEFT_EN | A64_LINEOUT_RIGHT_EN;
+
+	switch (jack) {
+	case AUDIO_DAI_JACK_HP:
+		if (present)
+			a64_acodec_pr_set_clear(sc, A64_LINEOUT_CTRL0,
+			0, lineout_mask);
+		else
+			a64_acodec_pr_set_clear(sc, A64_LINEOUT_CTRL0,
+			lineout_mask, 0);
+		break;
+	case AUDIO_DAI_JACK_MIC:
+		/* XXX TODO */
+		break;
+	}
+
+	return 0;
+}
+
 static const char * compatible[] = {
 	"allwinner,sun50i-a64-codec-analog",
 	NULL
@@ -474,7 +501,11 @@ a64_acodec_attach(device_t parent, devic
 	/* Right & Left Headphone PA enable */
 	a64_acodec_pr_set_clear(sc, A64_HP_CTRL,
 	A64_HPPA_EN, 0);
+	/* Jack detect enable */
+	a64_acodec_pr_set_clear(sc, A64_JACK_MIC_CTRL,
+	A64_JACKDETEN | A64_INNERRESEN | A64_AUTOPLEN, 0);
 
+	sc->sc_dai.dai_jack_detect = a64_acodec_dai_jack_detect;
 	sc->sc_dai.dai_hw_if = _acodec_hw_if;
 	sc->sc_dai.dai_dev = self;
 	sc->sc_dai.dai_priv = sc;

Index: src/sys/arch/arm/sunxi/sun8i_codec.c
diff -u src/sys/arch/arm/sunxi/sun8i_codec.c:1.1 src/sys/arch/arm/sunxi/sun8i_codec.c:1.2
--- src/sys/arch/arm/sunxi/sun8i_codec.c:1.1	Thu May 10 00:00:21 2018
+++ src/sys/arch/arm/sunxi/sun8i_codec.c	Fri May 11 22:51:12 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: sun8i_codec.c,v 1.1 2018/05/10 00:00:21 jmcneill Exp $ */
+/* $NetBSD: sun8i_codec.c,v 1.2 2018/05/11 22:51:12 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sun8i_codec.c,v 1.1 2018/05/10 00:00:21 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sun8i_codec.c,v 1.2 2018/05/11 22:51:12 jmcneill Exp $");
 
 #include 
 #include 
@@ -36,6 +36,7 @@ __KERNEL_RCSID(0, "$NetBSD: sun8i_codec.
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -82,6 +83,21 @@ __KERNEL_RCSID(0, "$NetBSD: sun8i_codec.
 #define	ADC_DIG_CTRL		0x100
 #define	 ADC_DIG_CTRL_ENAD	__BIT(15)
 
+#define	HMIC_CTRL1		0x110
+#define	 HMIC_CTRL1_N		__BITS(11,8)
+#define	 HMIC_CTRL1_JACK_IN_IRQ_EN __BIT(4)
+#define	 HMIC_CTRL1_JACK_OUT_IRQ_EN __BIT(3)
+#define	 HMIC_CTRL1_MIC_DET_IRQ_EN __BIT(0)
+
+#define	HMIC_CTRL2		0x114
+#define	 HMIC_CTRL2_MDATA_THRES	__BITS(12,8)
+
+#define	HMIC_STS		0x118
+#define	 HMIC_STS_MIC_PRESENT	__BIT(6)
+#define	 HMIC_STS_JACK_DET_OIRQ	__BIT(4)
+#define	 HMIC_STS_JACK_DET_IIRQ	__BIT(3)
+#define	 HMIC_STS_MIC_DET_ST	__BIT(0)
+
 #define	DAC_DIG_CTRL		0x120
 #define	 DAC_DIG_CTRL_ENDA	__BIT(15)
 
@@ -97,7 +113,13 @@ struct sun8i_codec_softc {
 	bus_space_handle_t	sc_bsh;
 	int			sc_phandle;
 
+	struct workqueue	*sc_workq;
+	struct work		sc_work;
+
 	struct audio_dai_device	sc_dai;
+	audio_dai_tag_t		sc_codec_analog;
+	uint32_t		sc_jackdet;
+	int			sc_jackdet_pol;
 
 	struct fdtbus_gpio_pin	*sc_pin_pa;
 
@@ -205,6 +227,91 @@ sun8i_codec_dai_set_format(audio_dai_tag
 	return 0;
 }
 
+static int
+sun8i_codec_dai_add_device(audio_dai_tag_t dai, audio_dai_tag_t aux)
+{
+	struct sun8i_codec_softc * const sc = audio_dai_private(dai);
+
+	if (sc->sc_codec_analog != NULL)
+		return 0;
+
+	sc->sc_codec_analog = aux;
+
+	

CVS commit: src/sys/dev/fdt

2018-05-11 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri May 11 22:49:19 UTC 2018

Modified Files:
src/sys/dev/fdt: ausoc.c

Log Message:
Attach aux devices to the codec


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/fdt/ausoc.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/fdt/ausoc.c
diff -u src/sys/dev/fdt/ausoc.c:1.1 src/sys/dev/fdt/ausoc.c:1.2
--- src/sys/dev/fdt/ausoc.c:1.1	Wed May  9 23:59:05 2018
+++ src/sys/dev/fdt/ausoc.c	Fri May 11 22:49:19 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: ausoc.c,v 1.1 2018/05/09 23:59:05 jmcneill Exp $ */
+/* $NetBSD: ausoc.c,v 1.2 2018/05/11 22:49:19 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ausoc.c,v 1.1 2018/05/09 23:59:05 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ausoc.c,v 1.2 2018/05/11 22:49:19 jmcneill Exp $");
 
 #include 
 #include 
@@ -505,11 +505,14 @@ ausoc_attach_link(struct ausoc_softc *sc
 		for (n = 0; n < link->link_naux; n++) {
 			link->link_aux[n] = fdtbus_dai_acquire_index(card_phandle,
 			"simple-audio-card,aux-devs", n);
+			KASSERT(link->link_aux[n] != NULL);
+
+			/* Attach aux devices to codec */
+			audio_dai_add_device(link->link_codec, link->link_aux[n]);
 		}
 	}
 
 	of_getprop_uint32(link_phandle, mclk_fs_prop, >link_mclk_fs);
-#if 1
 	if (ausoc_link_format(sc, link, link_phandle, codec_phandle, single_link, ) != 0) {
 		aprint_error_dev(sc->sc_dev, "couldn't parse format properties\n");
 		return;
@@ -522,18 +525,6 @@ ausoc_attach_link(struct ausoc_softc *sc
 		aprint_error_dev(sc->sc_dev, "couldn't set codec format\n");
 		return;
 	}
-#else
-	if (ausoc_link_format(sc, link, link_phandle, cpu_phandle, single_link, ) != 0 ||
-	audio_dai_set_format(link->link_cpu, format) != 0) {
-		aprint_error_dev(sc->sc_dev, "couldn't set cpu format\n");
-		return;
-	}
-	if (ausoc_link_format(sc, link, link_phandle, codec_phandle, single_link, ) != 0 ||
-	audio_dai_set_format(link->link_codec, format) != 0) {
-		aprint_error_dev(sc->sc_dev, "couldn't set codec format\n");
-		return;
-	}
-#endif
 
 	aprint_normal_dev(sc->sc_dev, "codec: %s, cpu: %s",
 	device_xname(audio_dai_device(link->link_codec)),



CVS commit: src/sys/arch/macppc/macppc

2018-05-11 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri May 11 22:48:38 UTC 2018

Modified Files:
src/sys/arch/macppc/macppc: cpu.c interrupts.c pic_u3_ht.c

Log Message:
deal with IPIs on U3/HT machines, only install OpenPIC IPI goop on actual
OpenPIC hardware


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/sys/arch/macppc/macppc/cpu.c
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/macppc/macppc/interrupts.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/macppc/macppc/pic_u3_ht.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/macppc/macppc/cpu.c
diff -u src/sys/arch/macppc/macppc/cpu.c:1.63 src/sys/arch/macppc/macppc/cpu.c:1.64
--- src/sys/arch/macppc/macppc/cpu.c:1.63	Thu Mar 29 16:19:46 2018
+++ src/sys/arch/macppc/macppc/cpu.c	Fri May 11 22:48:38 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.63 2018/03/29 16:19:46 macallan Exp $	*/
+/*	$NetBSD: cpu.c,v 1.64 2018/05/11 22:48:38 macallan Exp $	*/
 
 /*-
  * Copyright (c) 2001 Tsubai Masanari.
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.63 2018/03/29 16:19:46 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.64 2018/05/11 22:48:38 macallan Exp $");
 
 #include "opt_ppcparam.h"
 #include "opt_multiprocessor.h"
@@ -204,11 +204,14 @@ ohare_init(void)
 
 #ifdef MULTIPROCESSOR
 
+extern int have_u3_ht(void);
+extern void __u3_ht_set_priority(int, int);
+
 int
 md_setup_trampoline(volatile struct cpu_hatch_data *h, struct cpu_info *ci)
 {
 #ifdef OPENPIC
-	if (openpic_base) {
+	if ((openpic_base != NULL) || have_u3_ht()) {
 		uint32_t kl_base = (uint32_t)oea_mapiodev(0x8000, 0x1000);
 		uint32_t gpio = kl_base + 0x5c;	/* XXX */
 		u_int node, off;
@@ -253,7 +256,7 @@ void
 md_presync_timebase(volatile struct cpu_hatch_data *h)
 {
 #ifdef OPENPIC
-	if (openpic_base) {
+	if ((openpic_base != NULL) || have_u3_ht()) {
 		uint64_t tb;
 
 		/* Sync timebase. */
@@ -283,7 +286,7 @@ md_start_timebase(volatile struct cpu_ha
 {
 	int i;
 #ifdef OPENPIC
-	if (!openpic_base) {
+	if (!((openpic_base != NULL) || have_u3_ht())) {
 #endif
 		/*
 		 * wait for secondary spin up (1.5ms @ 604/200MHz)
@@ -306,7 +309,7 @@ void
 md_sync_timebase(volatile struct cpu_hatch_data *h)
 {
 #ifdef OPENPIC
-	if (openpic_base) {
+	if ((openpic_base != NULL) || have_u3_ht()) {
 		/* Sync timebase. */
 		u_int tbu = h->hatch_tbu;
 		u_int tbl = h->hatch_tbl;
@@ -324,9 +327,11 @@ void
 md_setup_interrupts(void)
 {
 #ifdef OPENPIC
-	if (openpic_base)
+	if (openpic_base) {
 		openpic_set_priority(cpu_number(), 0);
-	else
+	} else if (have_u3_ht()) {
+		__u3_ht_set_priority(cpu_number(), 0);		
+	} else
 #endif /* OPENPIC */
 		out32(HH_INTR_SECONDARY, ~0);	/* Reset interrupt. */
 }

Index: src/sys/arch/macppc/macppc/interrupts.c
diff -u src/sys/arch/macppc/macppc/interrupts.c:1.6 src/sys/arch/macppc/macppc/interrupts.c:1.7
--- src/sys/arch/macppc/macppc/interrupts.c:1.6	Thu Mar 22 21:28:58 2018
+++ src/sys/arch/macppc/macppc/interrupts.c	Fri May 11 22:48:38 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: interrupts.c,v 1.6 2018/03/22 21:28:58 macallan Exp $ */
+/*	$NetBSD: interrupts.c,v 1.7 2018/05/11 22:48:38 macallan Exp $ */
 
 /*-
  * Copyright (c) 2007 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: interrupts.c,v 1.6 2018/03/22 21:28:58 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: interrupts.c,v 1.7 2018/05/11 22:48:38 macallan Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -126,19 +126,21 @@ init_interrupt(void)
 		goto done;
 #endif
 #if NPIC_OPENPIC > 0
-	if (init_openpic(0))
+	if (init_openpic(0)) {
+#ifdef MULTIPROCESSOR
+		setup_openpic_ipi();
+#endif
 		goto done;
+	}
 #endif
 	panic("%s: no supported interrupt controller found", __func__);
 done:
 	oea_install_extint(pic_ext_intr);
 
 #ifdef MULTIPROCESSOR
-#if NPIC_OPENPIC > 0
-	setup_openpic_ipi();
-#else /*NPIC_OPENPIC*/
+#if (NPIC_OHARE + NPIC_HEATHROW) > 0
 	if (OF_finddevice("/hammerhead") != -1)
 		setup_hammerhead_ipi();
-#endif /*NPIC_OPENPIC*/
+#endif
 #endif /*MULTIPROCESSOR*/
 }

Index: src/sys/arch/macppc/macppc/pic_u3_ht.c
diff -u src/sys/arch/macppc/macppc/pic_u3_ht.c:1.4 src/sys/arch/macppc/macppc/pic_u3_ht.c:1.5
--- src/sys/arch/macppc/macppc/pic_u3_ht.c:1.4	Wed Jan 31 21:09:53 2018
+++ src/sys/arch/macppc/macppc/pic_u3_ht.c	Fri May 11 22:48:38 2018
@@ -32,6 +32,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include 
 #include 
@@ -92,6 +94,7 @@ static void u3_ht_disable_ht_irq(struct 
 static void u3_ht_ack_ht_irq(struct u3_ht_ops *, int);
 
 static void u3_ht_set_priority(struct u3_ht_ops *, int, int);
+void __u3_ht_set_priority(int, int);
 static int u3_ht_read_irq(struct u3_ht_ops *, int);
 static void u3_ht_eoi(struct u3_ht_ops *, int);
 
@@ -112,6 +115,17 @@ const char *pic_compat[] = {
 	NULL
 };
 
+static struct u3_ht_ops *u3ht0 = NULL;
+int have_u3_ht(void);
+
+#ifdef MULTIPROCESSOR
+
+extern struct ipi_ops 

CVS commit: src/sys/dev

2018-05-11 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri May 11 22:48:55 UTC 2018

Modified Files:
src/sys/dev: audio_dai.h

Log Message:
Add APIs for linking dai devices and jack detection


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/audio_dai.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/audio_dai.h
diff -u src/sys/dev/audio_dai.h:1.1 src/sys/dev/audio_dai.h:1.2
--- src/sys/dev/audio_dai.h:1.1	Wed May  9 23:57:58 2018
+++ src/sys/dev/audio_dai.h	Fri May 11 22:48:55 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: audio_dai.h,v 1.1 2018/05/09 23:57:58 jmcneill Exp $ */
+/* $NetBSD: audio_dai.h,v 1.2 2018/05/11 22:48:55 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -57,9 +57,14 @@
 #define	AUDIO_DAI_CLOCK_IN		0
 #define	AUDIO_DAI_CLOCK_OUT		1
 
+#define	AUDIO_DAI_JACK_HP		0
+#define	AUDIO_DAI_JACK_MIC		1
+
 typedef struct audio_dai_device {
 	int	(*dai_set_sysclk)(struct audio_dai_device *, u_int, int);
 	int	(*dai_set_format)(struct audio_dai_device *, u_int);
+	int	(*dai_add_device)(struct audio_dai_device *, struct audio_dai_device *);
+	int	(*dai_jack_detect)(struct audio_dai_device *, u_int, int);
 
 	const struct audio_hw_if *dai_hw_if;		/* audio driver callbacks */
 
@@ -98,6 +103,24 @@ audio_dai_set_format(audio_dai_tag_t dai
 }
 
 static inline int
+audio_dai_add_device(audio_dai_tag_t dai, audio_dai_tag_t aux)
+{
+	if (!dai->dai_add_device)
+		return 0;
+
+	return dai->dai_add_device(dai, aux);
+}
+
+static inline int
+audio_dai_jack_detect(audio_dai_tag_t dai, u_int jack, bool present)
+{
+	if (!dai->dai_jack_detect)
+		return 0;
+
+	return dai->dai_jack_detect(dai, jack, present);
+}
+
+static inline int
 audio_dai_open(audio_dai_tag_t dai, int flags)
 {
 	if (!dai->dai_hw_if->open)



CVS commit: src/sys/arch/powerpc/pic

2018-05-11 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri May 11 22:39:59 UTC 2018

Modified Files:
src/sys/arch/powerpc/pic: picvar.h

Log Message:
use 128 as IPI_VECTOR to avoid overlap wth hardware interrupts


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/powerpc/pic/picvar.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/powerpc/pic/picvar.h
diff -u src/sys/arch/powerpc/pic/picvar.h:1.9 src/sys/arch/powerpc/pic/picvar.h:1.10
--- src/sys/arch/powerpc/pic/picvar.h:1.9	Sat Jun 18 06:41:44 2011
+++ src/sys/arch/powerpc/pic/picvar.h	Fri May 11 22:39:59 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: picvar.h,v 1.9 2011/06/18 06:41:44 matt Exp $ */
+/*	$NetBSD: picvar.h,v 1.10 2018/05/11 22:39:59 macallan Exp $ */
 
 /*-
  * Copyright (c) 2007 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: picvar.h,v 1.9 2011/06/18 06:41:44 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: picvar.h,v 1.10 2018/05/11 22:39:59 macallan Exp $");
 
 #ifndef PIC_VAR_H
 #define PIC_VAR_H
@@ -132,6 +132,6 @@ void opic_ack_irq(struct pic_ops *pic, i
 /* IPI handler */
 int cpuintr(void *);
 /* XXX - may need to be PIC specific */
-#define IPI_VECTOR 64
+#define IPI_VECTOR 128
 
 #endif /* PIC_VAR_H */



CVS commit: src/sys/arch/powerpc/powerpc

2018-05-11 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri May 11 22:23:33 UTC 2018

Modified Files:
src/sys/arch/powerpc/powerpc: pmap_subr.c

Log Message:
disable the MULTIPROCESSOR case in pmap_syncicache() because:
- __syncicache() wants a virtual address, not a pa
- this crashes on G5 SMP
- the rest of the function does the same as __syncicache() except it turns
  the MMU off first so physical addresses work
with this, my PCIe G5 boots SMP


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/powerpc/powerpc/pmap_subr.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/powerpc/powerpc/pmap_subr.c
diff -u src/sys/arch/powerpc/powerpc/pmap_subr.c:1.27 src/sys/arch/powerpc/powerpc/pmap_subr.c:1.28
--- src/sys/arch/powerpc/powerpc/pmap_subr.c:1.27	Wed Feb  1 09:54:03 2012
+++ src/sys/arch/powerpc/powerpc/pmap_subr.c	Fri May 11 22:23:33 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap_subr.c,v 1.27 2012/02/01 09:54:03 matt Exp $	*/
+/*	$NetBSD: pmap_subr.c,v 1.28 2018/05/11 22:23:33 macallan Exp $	*/
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap_subr.c,v 1.27 2012/02/01 09:54:03 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap_subr.c,v 1.28 2018/05/11 22:23:33 macallan Exp $");
 
 #include "opt_multiprocessor.h"
 #include "opt_altivec.h"
@@ -425,7 +425,14 @@ pmap_copy_page(paddr_t src, paddr_t dst)
 void
 pmap_syncicache(paddr_t pa, psize_t len)
 {
-#ifdef MULTIPROCESSOR
+
+/* 
+ * XXX
+ * disabling the MULTIPROCESSOR case because:
+ * - _syncicache() takes a virtual addresses
+ * - this causes crashes on G5
+ */
+#ifdef MULTIPROCESSOR__
 	__syncicache((void *)pa, len);
 #else
 	const size_t linewidth = curcpu()->ci_ci.icache_line_size;



CVS commit: src

2018-05-11 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Fri May 11 20:19:25 UTC 2018

Modified Files:
src/crypto/external/bsd/netpgp/dist/bindings/lua: glue.c
src/libexec/httpd/lua: glue.c

Log Message:
remove definition of LUA_USE_APICHECK, it is a build time option for Lua
itself. Not for modules.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 \
src/crypto/external/bsd/netpgp/dist/bindings/lua/glue.c
cvs rdiff -u -r1.4 -r1.5 src/libexec/httpd/lua/glue.c

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

Modified files:

Index: src/crypto/external/bsd/netpgp/dist/bindings/lua/glue.c
diff -u src/crypto/external/bsd/netpgp/dist/bindings/lua/glue.c:1.5 src/crypto/external/bsd/netpgp/dist/bindings/lua/glue.c:1.6
--- src/crypto/external/bsd/netpgp/dist/bindings/lua/glue.c:1.5	Sun Apr 29 19:34:57 2018
+++ src/crypto/external/bsd/netpgp/dist/bindings/lua/glue.c	Fri May 11 20:19:25 2018
@@ -38,7 +38,6 @@
 #include 
 
 #define LUA_LIB
-#define LUA_USE_APICHECK
 #include 
 #include 
 #include 

Index: src/libexec/httpd/lua/glue.c
diff -u src/libexec/httpd/lua/glue.c:1.4 src/libexec/httpd/lua/glue.c:1.5
--- src/libexec/httpd/lua/glue.c:1.4	Fri May  4 19:45:27 2018
+++ src/libexec/httpd/lua/glue.c	Fri May 11 20:19:25 2018
@@ -38,7 +38,6 @@
 #include 
 
 #define LUA_LIB
-#define LUA_USE_APICHECK
 #include 
 #include 
 #include 



CVS commit: src/usr.bin/who

2018-05-11 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Fri May 11 16:36:57 UTC 2018

Modified Files:
src/usr.bin/who: who.1

Log Message:
Match sequence of flags with usage()
Following on from mandoc -Tlint, drop Pp macro before Bl and Tn macro.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/usr.bin/who/who.1

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

Modified files:

Index: src/usr.bin/who/who.1
diff -u src/usr.bin/who/who.1:1.23 src/usr.bin/who/who.1:1.24
--- src/usr.bin/who/who.1:1.23	Fri Dec 26 01:43:58 2014
+++ src/usr.bin/who/who.1	Fri May 11 16:36:57 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: who.1,v 1.23 2014/12/26 01:43:58 christos Exp $
+.\"	$NetBSD: who.1,v 1.24 2018/05/11 16:36:57 sevan Exp $
 .\"
 .\" Copyright (c) 1986, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\" @(#)who.1	8.2 (Berkeley) 12/30/93
 .\"
-.Dd December 25, 2014
+.Dd May 11, 2018
 .Dt WHO 1
 .Os
 .Sh NAME
@@ -37,7 +37,7 @@
 .Nd display who is logged in
 .Sh SYNOPSIS
 .Nm
-.Op Fl abdHlmqrstTuv
+.Op Fl abdHlmqrsTtuv
 .Op Ar file
 .Nm
 .Ar am i
@@ -49,7 +49,6 @@ each user the login name, tty name, the 
 hostname if not local.
 .Pp
 Available options:
-.Pp
 .Bl -tag -width file
 .It Fl a
 Same as
@@ -64,9 +63,7 @@ Write column headings above the regular 
 Print system login processes.
 .It Fl m
 Only print information about the current terminal.
-This is the
-.Tn POSIX
-way of saying
+This is the POSIX way of saying
 .Nm
 .Ar am i .
 .It Fl p



CVS commit: src/sys/netipsec

2018-05-11 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Fri May 11 15:43:07 UTC 2018

Modified Files:
src/sys/netipsec: xform_ah.c xform_esp.c

Log Message:
ENOBUFS -> EACCES when updating the replay counter.


To generate a diff of this commit:
cvs rdiff -u -r1.98 -r1.99 src/sys/netipsec/xform_ah.c
cvs rdiff -u -r1.86 -r1.87 src/sys/netipsec/xform_esp.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/netipsec/xform_ah.c
diff -u src/sys/netipsec/xform_ah.c:1.98 src/sys/netipsec/xform_ah.c:1.99
--- src/sys/netipsec/xform_ah.c:1.98	Mon May  7 09:16:46 2018
+++ src/sys/netipsec/xform_ah.c	Fri May 11 15:43:07 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: xform_ah.c,v 1.98 2018/05/07 09:16:46 maxv Exp $	*/
+/*	$NetBSD: xform_ah.c,v 1.99 2018/05/11 15:43:07 maxv Exp $	*/
 /*	$FreeBSD: xform_ah.c,v 1.1.4.1 2003/01/24 05:11:36 sam Exp $	*/
 /*	$OpenBSD: ip_ah.c,v 1.63 2001/06/26 06:18:58 angelos Exp $ */
 /*
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xform_ah.c,v 1.98 2018/05/07 09:16:46 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xform_ah.c,v 1.99 2018/05/11 15:43:07 maxv Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -837,7 +837,7 @@ ah_input_cb(struct cryptop *crp)
 		sizeof(seq), );
 		if (ipsec_updatereplay(ntohl(seq), sav)) {
 			AH_STATINC(AH_STAT_REPLAY);
-			error = ENOBUFS; /* XXX */
+			error = EACCES;
 			goto bad;
 		}
 	}

Index: src/sys/netipsec/xform_esp.c
diff -u src/sys/netipsec/xform_esp.c:1.86 src/sys/netipsec/xform_esp.c:1.87
--- src/sys/netipsec/xform_esp.c:1.86	Mon May  7 09:16:46 2018
+++ src/sys/netipsec/xform_esp.c	Fri May 11 15:43:07 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: xform_esp.c,v 1.86 2018/05/07 09:16:46 maxv Exp $	*/
+/*	$NetBSD: xform_esp.c,v 1.87 2018/05/11 15:43:07 maxv Exp $	*/
 /*	$FreeBSD: xform_esp.c,v 1.2.2.1 2003/01/24 05:11:36 sam Exp $	*/
 /*	$OpenBSD: ip_esp.c,v 1.69 2001/06/26 06:18:59 angelos Exp $ */
 
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xform_esp.c,v 1.86 2018/05/07 09:16:46 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xform_esp.c,v 1.87 2018/05/11 15:43:07 maxv Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -607,7 +607,7 @@ esp_input_cb(struct cryptop *crp)
 			DPRINTF(("%s: packet replay check for %s\n", __func__,
 			ipsec_logsastr(sav, logbuf, sizeof(logbuf;
 			ESP_STATINC(ESP_STAT_REPLAY);
-			error = ENOBUFS;
+			error = EACCES;
 			goto bad;
 		}
 	}



CVS commit: src/share/misc

2018-05-11 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Fri May 11 14:42:03 UTC 2018

Modified Files:
src/share/misc: acronyms.comp

Log Message:
Add IFS - internal field separator.


To generate a diff of this commit:
cvs rdiff -u -r1.194 -r1.195 src/share/misc/acronyms.comp

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

Modified files:

Index: src/share/misc/acronyms.comp
diff -u src/share/misc/acronyms.comp:1.194 src/share/misc/acronyms.comp:1.195
--- src/share/misc/acronyms.comp:1.194	Fri May 11 14:39:25 2018
+++ src/share/misc/acronyms.comp	Fri May 11 14:42:03 2018
@@ -1,4 +1,4 @@
-$NetBSD: acronyms.comp,v 1.194 2018/05/11 14:39:25 sevan Exp $
+$NetBSD: acronyms.comp,v 1.195 2018/05/11 14:42:03 sevan Exp $
 3WHS	three-way handshake
 8VSB	8-state vestigial side band modulation
 AA	anti-aliasing
@@ -596,6 +596,7 @@ IETF	Internet Engineering Task Force
 IF	intermediate frequency
 IFCM	isochronous flow control mode
 IFF	Interchange File Format
+IFS	internal field separator
 IGD	Internet gateway device
 IGMP	Internet Group Management Protocol
 IGP	interior gateway protocol



CVS commit: src/share/misc

2018-05-11 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Fri May 11 14:39:25 UTC 2018

Modified Files:
src/share/misc: acronyms acronyms.comp

Log Message:
Move HTTP Keyserver Protocol entry to the correct file.


To generate a diff of this commit:
cvs rdiff -u -r1.269 -r1.270 src/share/misc/acronyms
cvs rdiff -u -r1.193 -r1.194 src/share/misc/acronyms.comp

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

Modified files:

Index: src/share/misc/acronyms
diff -u src/share/misc/acronyms:1.269 src/share/misc/acronyms:1.270
--- src/share/misc/acronyms:1.269	Thu May 10 14:06:59 2018
+++ src/share/misc/acronyms	Fri May 11 14:39:25 2018
@@ -1,4 +1,4 @@
-$NetBSD: acronyms,v 1.269 2018/05/10 14:06:59 sevan Exp $
+$NetBSD: acronyms,v 1.270 2018/05/11 14:39:25 sevan Exp $
 10Q	thank you
 10X	thanks
 1337	elite ("leet")
@@ -210,7 +210,6 @@ HF	have fun
 HHIS	hanging head in shame
 HHOS	ha ha, only serious
 HICA	here it comes again
-HKP	OpenPGP HTTP Keyserver Protocol
 HME	home medical equipment
 HNY	happy new year
 HOAS	hold on a second

Index: src/share/misc/acronyms.comp
diff -u src/share/misc/acronyms.comp:1.193 src/share/misc/acronyms.comp:1.194
--- src/share/misc/acronyms.comp:1.193	Thu Mar  1 19:09:33 2018
+++ src/share/misc/acronyms.comp	Fri May 11 14:39:25 2018
@@ -1,4 +1,4 @@
-$NetBSD: acronyms.comp,v 1.193 2018/03/01 19:09:33 ginsbach Exp $
+$NetBSD: acronyms.comp,v 1.194 2018/05/11 14:39:25 sevan Exp $
 3WHS	three-way handshake
 8VSB	8-state vestigial side band modulation
 AA	anti-aliasing
@@ -544,6 +544,7 @@ HDTV	high-definition television
 HF	high frequency
 HFM	highest frequency mode
 HID	human interface device
+HKP	HTTP Keyserver Protocol
 HLL	high-level language
 HMA	high memory area
 HMI	human-machine interface



CVS commit: src

2018-05-11 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Fri May 11 14:38:28 UTC 2018

Modified Files:
src/share/man/man4: options.4
src/sys/netinet: ip_icmp.c
src/sys/netmpls: mpls_ttl.c

Log Message:
Retire ICMPPRINTFS, it's annoying and it doesn't build.


To generate a diff of this commit:
cvs rdiff -u -r1.486 -r1.487 src/share/man/man4/options.4
cvs rdiff -u -r1.169 -r1.170 src/sys/netinet/ip_icmp.c
cvs rdiff -u -r1.12 -r1.13 src/sys/netmpls/mpls_ttl.c

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

Modified files:

Index: src/share/man/man4/options.4
diff -u src/share/man/man4/options.4:1.486 src/share/man/man4/options.4:1.487
--- src/share/man/man4/options.4:1.486	Mon Apr  9 07:08:43 2018
+++ src/share/man/man4/options.4	Fri May 11 14:38:28 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: options.4,v 1.486 2018/04/09 07:08:43 wiz Exp $
+.\"	$NetBSD: options.4,v 1.487 2018/05/11 14:38:28 maxv Exp $
 .\"
 .\" Copyright (c) 1996
 .\" 	Perry E. Metzger.  All rights reserved.
@@ -30,7 +30,7 @@
 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
 .\"
-.Dd April 5, 2018
+.Dd May 11, 2018
 .Dt OPTIONS 4
 .Os
 .Sh NAME
@@ -1681,13 +1681,6 @@ is not invoked directly.
 has no impact on protocols other than IP, such as CLNP).
 .Em GATEWAY
 option also compiles IPv4 and IPv6 fast forwarding code into the kernel.
-.It Cd options ICMPPRINTFS
-The
-.Em ICMPPRINTFS
-option will enable debugging information to be printed about
-the
-.Xr icmp 4
-protocol.
 .It Cd options IPFORWARDING=value
 If
 .Em value

Index: src/sys/netinet/ip_icmp.c
diff -u src/sys/netinet/ip_icmp.c:1.169 src/sys/netinet/ip_icmp.c:1.170
--- src/sys/netinet/ip_icmp.c:1.169	Thu Apr 26 07:28:21 2018
+++ src/sys/netinet/ip_icmp.c	Fri May 11 14:38:28 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip_icmp.c,v 1.169 2018/04/26 07:28:21 maxv Exp $	*/
+/*	$NetBSD: ip_icmp.c,v 1.170 2018/05/11 14:38:28 maxv Exp $	*/
 
 /*
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -94,7 +94,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ip_icmp.c,v 1.169 2018/04/26 07:28:21 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_icmp.c,v 1.170 2018/05/11 14:38:28 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ipsec.h"
@@ -140,9 +140,6 @@ __KERNEL_RCSID(0, "$NetBSD: ip_icmp.c,v 
 
 int icmpmaskrepl = 0;
 int icmpbmcastecho = 0;
-#ifdef ICMPPRINTFS
-int icmpprintfs = 0;
-#endif
 int icmpreturndatabytes = 8;
 
 percpu_t *icmpstat_percpu;
@@ -261,11 +258,6 @@ icmp_error(struct mbuf *n, int type, int
 	unsigned datalen, mblen;
 	int totlen;
 
-#ifdef ICMPPRINTFS
-	if (icmpprintfs)
-		printf("icmp_error(%p, type:%d, code:%d)\n", oip, type, code);
-#endif
-
 	if (type != ICMP_REDIRECT)
 		ICMP_STATINC(ICMP_STAT_ERROR);
 
@@ -435,14 +427,6 @@ _icmp_input(struct mbuf *m, int hlen, in
 	 * that not corrupted and of at least minimum length.
 	 */
 	icmplen = ntohs(ip->ip_len) - hlen;
-#ifdef ICMPPRINTFS
-	if (icmpprintfs) {
-		char sbuf[INET_ADDRSTRLEN], dbuf[INET_ADDRSTRLEN];
-		printf("icmp_input from `%s' to `%s', len %d\n",
-		IN_PRINT(sbuf, >ip_src), IN_PRINT(dbuf, >ip_dst),
-		icmplen);
-	}
-#endif
 	if (icmplen < ICMP_MINLEN) {
 		ICMP_STATINC(ICMP_STAT_TOOSHORT);
 		goto freeit;
@@ -464,14 +448,6 @@ _icmp_input(struct mbuf *m, int hlen, in
 	m->m_len += hlen;
 	m->m_data -= hlen;
 
-#ifdef ICMPPRINTFS
-	/*
-	 * Message type specific processing.
-	 */
-	if (icmpprintfs)
-		printf("icmp_input(type:%d, code:%d)\n", icp->icmp_type,
-		icp->icmp_code);
-#endif
 	if (icp->icmp_type > ICMP_MAXTYPE)
 		goto raw;
 	ICMP_STATINC(ICMP_STAT_INHIST + icp->icmp_type);
@@ -556,10 +532,7 @@ _icmp_input(struct mbuf *m, int hlen, in
 
 		if (IN_MULTICAST(icp->icmp_ip.ip_dst.s_addr))
 			goto badcode;
-#ifdef ICMPPRINTFS
-		if (icmpprintfs)
-			printf("deliver to protocol %d\n", icp->icmp_ip.ip_p);
-#endif
+
 		icmpsrc.sin_addr = icp->icmp_ip.ip_dst;
 		ctlfunc = inetsw[ip_protox[icp->icmp_ip.ip_p]].pr_ctlinput;
 		if (ctlfunc)
@@ -664,14 +637,6 @@ reflect:
 		 */
 		icmpgw.sin_addr = ip->ip_src;
 		icmpdst.sin_addr = icp->icmp_gwaddr;
-#ifdef	ICMPPRINTFS
-		if (icmpprintfs) {
-			char gbuf[INET_ADDRSTRLEN], dbuf[INET_ADDRSTRLEN];
-			printf("redirect dst `%s' to `%s'\n",
-			IN_PRINT(dbuf, >icmp_ip.ip_dst),
-			IN_PRINT(gbuf, >icmp_gwaddr));
-		}
-#endif
 		icmpsrc.sin_addr = icp->icmp_ip.ip_dst;
 		rt = NULL;
 		rtredirect(sintosa(), sintosa(),
@@ -908,11 +873,6 @@ icmp_reflect(struct mbuf *m)
 		}
 
 		if (opts) {
-#ifdef ICMPPRINTFS
-			if (icmpprintfs)
-printf("icmp_reflect optlen %d rt %d => ",
-optlen, opts->m_len);
-#endif
 			for (cnt = optlen; cnt > 0; cnt -= len, cp += len) {
 opt = cp[IPOPT_OPTVAL];
 if (opt == IPOPT_EOL)
@@ -947,10 +907,6 @@ icmp_reflect(struct mbuf *m)
 	opts->m_len++;
 }
 			}
-#ifdef ICMPPRINTFS
-			if (icmpprintfs)
-printf("%d\n", opts->m_len);
-#endif
 		}
 
 		/*
@@ -1001,13 +957,7 @@ icmp_send(struct mbuf 

CVS commit: src/sys/netinet6

2018-05-11 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Fri May 11 14:25:50 UTC 2018

Modified Files:
src/sys/netinet6: raw_ip6.c

Log Message:
Dedup: introduce rip6_sbappendaddr. Same as IPv4.


To generate a diff of this commit:
cvs rdiff -u -r1.171 -r1.172 src/sys/netinet6/raw_ip6.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/netinet6/raw_ip6.c
diff -u src/sys/netinet6/raw_ip6.c:1.171 src/sys/netinet6/raw_ip6.c:1.172
--- src/sys/netinet6/raw_ip6.c:1.171	Sun Apr 29 07:05:13 2018
+++ src/sys/netinet6/raw_ip6.c	Fri May 11 14:25:50 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: raw_ip6.c,v 1.171 2018/04/29 07:05:13 maxv Exp $	*/
+/*	$NetBSD: raw_ip6.c,v 1.172 2018/05/11 14:25:50 maxv Exp $	*/
 /*	$KAME: raw_ip6.c,v 1.82 2001/07/23 18:57:56 jinmei Exp $	*/
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: raw_ip6.c,v 1.171 2018/04/29 07:05:13 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: raw_ip6.c,v 1.172 2018/05/11 14:25:50 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ipsec.h"
@@ -134,6 +134,28 @@ rip6_init(void)
 	rip6stat_percpu = percpu_alloc(sizeof(uint64_t) * RIP6_NSTATS);
 }
 
+static void
+rip6_sbappendaddr(struct in6pcb *last, struct ip6_hdr *ip6,
+const struct sockaddr *sa, int hlen, struct mbuf *n)
+{
+	struct mbuf *opts = NULL;
+
+	if (last->in6p_flags & IN6P_CONTROLOPTS)
+		ip6_savecontrol(last, , ip6, n);
+
+	m_adj(n, hlen);
+
+	if (sbappendaddr(>in6p_socket->so_rcv, sa, n, opts) == 0) {
+		soroverflow(last->in6p_socket);
+		m_freem(n);
+		if (opts)
+			m_freem(opts);
+		RIP6_STATINC(RIP6_STAT_FULLSOCK);
+	} else {
+		sorwakeup(last->in6p_socket);
+	}
+}
+
 /*
  * Setup generic address and protocol structures
  * for raw_input routine, then pass them along with
@@ -148,7 +170,7 @@ rip6_input(struct mbuf **mp, int *offp, 
 	struct in6pcb *in6p;
 	struct in6pcb *last = NULL;
 	struct sockaddr_in6 rip6src;
-	struct mbuf *n, *opts = NULL;
+	struct mbuf *n;
 
 	RIP6_STATINC(RIP6_STAT_IPACKETS);
 
@@ -198,21 +220,8 @@ rip6_input(struct mbuf **mp, int *offp, 
 		}
 #endif
 		else if ((n = m_copypacket(m, M_DONTWAIT)) != NULL) {
-			if (last->in6p_flags & IN6P_CONTROLOPTS)
-ip6_savecontrol(last, , ip6, n);
-			/* strip intermediate headers */
-			m_adj(n, *offp);
-			if (sbappendaddr(>in6p_socket->so_rcv,
-			sin6tosa(), n, opts) == 0) {
-soroverflow(last->in6p_socket);
-m_freem(n);
-if (opts)
-	m_freem(opts);
-RIP6_STATINC(RIP6_STAT_FULLSOCK);
-			} else {
-sorwakeup(last->in6p_socket);
-			}
-			opts = NULL;
+			rip6_sbappendaddr(last, ip6, sin6tosa(),
+			*offp, n);
 		}
 
 		last = in6p;
@@ -225,20 +234,8 @@ rip6_input(struct mbuf **mp, int *offp, 
 		/* do not inject data into pcb */
 	} else
 #endif
-	if (last) {
-		if (last->in6p_flags & IN6P_CONTROLOPTS)
-			ip6_savecontrol(last, , ip6, m);
-		/* strip intermediate headers */
-		m_adj(m, *offp);
-		if (sbappendaddr(>in6p_socket->so_rcv,
-		sin6tosa(), m, opts) == 0) {
-			soroverflow(last->in6p_socket);
-			m_freem(m);
-			if (opts)
-m_freem(opts);
-			RIP6_STATINC(RIP6_STAT_FULLSOCK);
-		} else
-			sorwakeup(last->in6p_socket);
+	if (last != NULL) {
+		rip6_sbappendaddr(last, ip6, sin6tosa(), *offp, m);
 	} else {
 		RIP6_STATINC(RIP6_STAT_NOSOCK);
 		if (m->m_flags & M_MCAST)



CVS commit: src/sys/netinet

2018-05-11 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Fri May 11 14:07:58 UTC 2018

Modified Files:
src/sys/netinet: raw_ip.c

Log Message:
Make sure we have at least an IP header, and remove pointless XXXs (there
is no issue).


To generate a diff of this commit:
cvs rdiff -u -r1.176 -r1.177 src/sys/netinet/raw_ip.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/netinet/raw_ip.c
diff -u src/sys/netinet/raw_ip.c:1.176 src/sys/netinet/raw_ip.c:1.177
--- src/sys/netinet/raw_ip.c:1.176	Sat Apr 28 13:26:57 2018
+++ src/sys/netinet/raw_ip.c	Fri May 11 14:07:58 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: raw_ip.c,v 1.176 2018/04/28 13:26:57 maxv Exp $	*/
+/*	$NetBSD: raw_ip.c,v 1.177 2018/05/11 14:07:58 maxv Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -65,7 +65,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: raw_ip.c,v 1.176 2018/04/28 13:26:57 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: raw_ip.c,v 1.177 2018/05/11 14:07:58 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -355,6 +355,10 @@ rip_output(struct mbuf *m, struct inpcb 
 			error = EMSGSIZE;
 			goto release;
 		}
+		if (m->m_pkthdr.len < sizeof(struct ip)) {
+			error = EINVAL;
+			goto release;
+		}
 		ip = mtod(m, struct ip *);
 
 		/*
@@ -367,7 +371,7 @@ rip_output(struct mbuf *m, struct inpcb 
 
 			m = m_copyup(m, hlen, (max_linkhdr + 3) & ~3);
 			if (m == NULL) {
-error = ENOMEM;	/* XXX */
+error = ENOMEM;
 goto release;
 			}
 			ip = mtod(m, struct ip *);
@@ -380,11 +384,14 @@ rip_output(struct mbuf *m, struct inpcb 
 		}
 		HTONS(ip->ip_len);
 		HTONS(ip->ip_off);
+
 		if (ip->ip_id != 0 || m->m_pkthdr.len < IP_MINFRAGSIZE)
 			flags |= IP_NOIPNEWID;
 		opts = NULL;
-		/* XXX prevent ip_output from overwriting header fields */
+
+		/* Prevent ip_output from overwriting header fields. */
 		flags |= IP_RAWOUTPUT;
+
 		IP_STATINC(IP_STAT_RAWOUT);
 	}
 



CVS commit: src/sys/netinet

2018-05-11 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Fri May 11 13:56:43 UTC 2018

Modified Files:
src/sys/netinet: if_arp.c

Log Message:
static


To generate a diff of this commit:
cvs rdiff -u -r1.274 -r1.275 src/sys/netinet/if_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/sys/netinet/if_arp.c
diff -u src/sys/netinet/if_arp.c:1.274 src/sys/netinet/if_arp.c:1.275
--- src/sys/netinet/if_arp.c:1.274	Tue May  1 07:21:39 2018
+++ src/sys/netinet/if_arp.c	Fri May 11 13:56:43 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_arp.c,v 1.274 2018/05/01 07:21:39 maxv Exp $	*/
+/*	$NetBSD: if_arp.c,v 1.275 2018/05/11 13:56:43 maxv Exp $	*/
 
 /*
  * Copyright (c) 1998, 2000, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.274 2018/05/01 07:21:39 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.275 2018/05/11 13:56:43 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -255,7 +255,7 @@ arp_fasttimo(void)
 	}
 }
 
-const struct protosw arpsw[] = {
+static const struct protosw arpsw[] = {
 	{
 		.pr_type = 0,
 		.pr_domain = ,



CVS commit: src/sys/net/npf

2018-05-11 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Fri May 11 13:52:49 UTC 2018

Modified Files:
src/sys/net/npf: npf_nat.c

Log Message:
Improve comment, it's not just IPv4.


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sys/net/npf/npf_nat.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/npf/npf_nat.c
diff -u src/sys/net/npf/npf_nat.c:1.42 src/sys/net/npf/npf_nat.c:1.43
--- src/sys/net/npf/npf_nat.c:1.42	Mon Apr 23 15:36:30 2018
+++ src/sys/net/npf/npf_nat.c	Fri May 11 13:52:48 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: npf_nat.c,v 1.42 2018/04/23 15:36:30 christos Exp $	*/
+/*	$NetBSD: npf_nat.c,v 1.43 2018/05/11 13:52:48 maxv Exp $	*/
 
 /*-
  * Copyright (c) 2014 Mindaugas Rasiukevicius 
@@ -72,7 +72,7 @@
 
 #ifdef _KERNEL
 #include 
-__KERNEL_RCSID(0, "$NetBSD: npf_nat.c,v 1.42 2018/04/23 15:36:30 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: npf_nat.c,v 1.43 2018/05/11 13:52:48 maxv Exp $");
 
 #include 
 #include 
@@ -692,7 +692,7 @@ npf_do_nat(npf_cache_t *npc, npf_conn_t 
 	int error;
 	bool forw;
 
-	/* All relevant IPv4 data should be already cached. */
+	/* All relevant data should be already cached. */
 	if (!npf_iscached(npc, NPC_IP46) || !npf_iscached(npc, NPC_LAYER4)) {
 		return 0;
 	}



CVS commit: src/sys/netipsec

2018-05-11 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Fri May 11 13:50:38 UTC 2018

Modified Files:
src/sys/netipsec: xform_tcp.c

Log Message:
Clean up, and panic if we call functions that are not supposed to be
called.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/netipsec/xform_tcp.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/netipsec/xform_tcp.c
diff -u src/sys/netipsec/xform_tcp.c:1.19 src/sys/netipsec/xform_tcp.c:1.20
--- src/sys/netipsec/xform_tcp.c:1.19	Mon May  7 09:16:46 2018
+++ src/sys/netipsec/xform_tcp.c	Fri May 11 13:50:38 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: xform_tcp.c,v 1.19 2018/05/07 09:16:46 maxv Exp $ */
+/*	$NetBSD: xform_tcp.c,v 1.20 2018/05/11 13:50:38 maxv Exp $ */
 /*	$FreeBSD: xform_tcp.c,v 1.1.2.1 2004/02/14 22:24:09 bms Exp $ */
 
 /*
@@ -28,10 +28,13 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-/* TCP MD5 Signature Option (RFC2385) */
+/*
+ * TCP MD5 Signature Option (RFC2385). Dummy code, everything is handled
+ * in TCP directly.
+ */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xform_tcp.c,v 1.19 2018/05/07 09:16:46 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xform_tcp.c,v 1.20 2018/05/11 13:50:38 maxv Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -40,29 +43,16 @@ __KERNEL_RCSID(0, "$NetBSD: xform_tcp.c,
 #include 
 #include 
 #include 
-#include 
-#include 
 #include 
-#include 
-#include 
 
 #include 
 #include 
 #include 
 #include 
-#include 
-#include 
-#include 
 
-#include 
 #include 
 #include 
 
-#ifdef INET6
-#include 
-#include 
-#endif
-
 #include 
 #include 
 
@@ -94,35 +84,29 @@ tcpsignature_init(struct secasvar *sav, 
 	if (sav->spi != htonl(TCP_SIG_SPI)) {
 		DPRINTF(("%s: SPI %x must be TCP_SIG_SPI (0x1000)\n",
 		__func__, sav->alg_auth));
-		return (EINVAL);
+		return EINVAL;
 	}
 	if (sav->alg_auth != SADB_X_AALG_TCP_MD5) {
 		DPRINTF(("%s: unsupported authentication algorithm %u\n",
 		__func__, sav->alg_auth));
-		return (EINVAL);
+		return EINVAL;
 	}
 	if (sav->key_auth == NULL) {
 		DPRINTF(("%s: no authentication key present\n", __func__));
-		return (EINVAL);
+		return EINVAL;
 	}
 	keylen = _KEYLEN(sav->key_auth);
 	if ((keylen < TCP_KEYLEN_MIN) || (keylen > TCP_KEYLEN_MAX)) {
 		DPRINTF(("%s: invalid key length %u\n", __func__, keylen));
-		return (EINVAL);
+		return EINVAL;
 	}
 
-	return (0);
+	return 0;
 }
 
-/*
- * Paranoia.
- *
- * Called when the SA is deleted.
- */
 static int
 tcpsignature_zeroize(struct secasvar *sav)
 {
-
 	if (sav->key_auth) {
 		explicit_memset(_KEYBUF(sav->key_auth), 0,
 		_KEYLEN(sav->key_auth));
@@ -132,33 +116,21 @@ tcpsignature_zeroize(struct secasvar *sa
 	sav->tdb_authalgxform = NULL;
 	sav->tdb_xform = NULL;
 
-	return (0);
+	return 0;
 }
 
-/*
- * Verify that an input packet passes authentication.
- * Called from the ipsec layer.
- * We do this from within tcp itself, so this routine is just a stub.
- */
 static int
 tcpsignature_input(struct mbuf *m, struct secasvar *sav, int skip,
 int protoff)
 {
-	/* XXX m_freem(m)? */
-	return (0);
+	panic("%s: should not have been called", __func__);
 }
 
-/*
- * Prepend the authentication header.
- * Called from the ipsec layer.
- * We do this from within tcp itself, so this routine is just a stub.
- */
 static int
 tcpsignature_output(struct mbuf *m, const struct ipsecrequest *isr,
 struct secasvar *sav, int skip, int protoff)
 {
-
-	return (EINVAL);
+	panic("%s: should not have been called", __func__);
 }
 
 static struct xformsw tcpsignature_xformsw = {
@@ -175,6 +147,5 @@ static struct xformsw tcpsignature_xform
 void
 tcpsignature_attach(void)
 {
-
 	xform_register(_xformsw);
 }



CVS commit: src/sys/arch/xen/xen

2018-05-11 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Fri May 11 13:24:46 UTC 2018

Modified Files:
src/sys/arch/xen/xen: clock.c

Log Message:
Fixes port-xen/53267
re-educate xen_clock_handler() how to use the interrupt stackframe.
The current regs value passed in is *ci, and thus invalid.

Reported and tested by kre@. See PR 53267 for more details.


To generate a diff of this commit:
cvs rdiff -u -r1.65 -r1.66 src/sys/arch/xen/xen/clock.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/xen/xen/clock.c
diff -u src/sys/arch/xen/xen/clock.c:1.65 src/sys/arch/xen/xen/clock.c:1.66
--- src/sys/arch/xen/xen/clock.c:1.65	Mon Nov  6 15:27:09 2017
+++ src/sys/arch/xen/xen/clock.c	Fri May 11 13:24:46 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: clock.c,v 1.65 2017/11/06 15:27:09 cherry Exp $	*/
+/*	$NetBSD: clock.c,v 1.66 2018/05/11 13:24:46 cherry Exp $	*/
 
 /*
  *
@@ -29,7 +29,7 @@
 #include "opt_xen.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.65 2017/11/06 15:27:09 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.66 2018/05/11 13:24:46 cherry Exp $");
 
 #include 
 #include 
@@ -49,7 +49,8 @@ __KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.
 #include 
 #include 
 
-static int xen_timer_handler(void *);
+static int xen_timer_handler(void *, struct intrframe *);
+static int (*xen_timer_handler_stub)(void *) = (void *) xen_timer_handler;
 static struct intrhand *ih;
 
 /* A timecounter: Xen system_time extrapolated with a TSC. */
@@ -524,7 +525,7 @@ xen_resumeclocks(struct cpu_info *ci)
 	KASSERT(evtch != -1);
 
 	ih = intr_establish_xname(0, _pic, evtch, IST_LEVEL, IPL_CLOCK,
-	xen_timer_handler, ci, true, "clock");
+	xen_timer_handler_stub, ci, true, "clock");
 
 	KASSERT(ih != NULL);
 
@@ -535,11 +536,10 @@ xen_resumeclocks(struct cpu_info *ci)
 
 /* ARGSUSED */
 static int
-xen_timer_handler(void *arg)
+xen_timer_handler(void *arg, struct intrframe *regs)
 {
 	int64_t delta;
 	struct cpu_info *ci = curcpu();
-	struct intrframe *regs = arg;
 
 	int err;
 again:



CVS commit: src/share/man/man3

2018-05-11 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Fri May 11 12:54:56 UTC 2018

Modified Files:
src/share/man/man3: intro.3

Log Message:
Pass through mandoc -Tlint, drop Pp before Bl.
Remove reference to libkadm, it is no longer present in NetBSD.
Direct reader to kadm5_pwcheck(3) for libkadm5srv.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/share/man/man3/intro.3

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

Modified files:

Index: src/share/man/man3/intro.3
diff -u src/share/man/man3/intro.3:1.33 src/share/man/man3/intro.3:1.34
--- src/share/man/man3/intro.3:1.33	Sun May 21 14:24:05 2017
+++ src/share/man/man3/intro.3	Fri May 11 12:54:56 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: intro.3,v 1.33 2017/05/21 14:24:05 riastradh Exp $
+.\"	$NetBSD: intro.3,v 1.34 2018/05/11 12:54:56 sevan Exp $
 .\"
 .\" Copyright (c) 1980, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\" @(#)intro.3	8.1 (Berkeley) 6/5/93
 .\"
-.Dd November 22, 2015
+.Dd May 11, 2018
 .Dt INTRO 3
 .Os
 .Sh NAME
@@ -71,7 +71,6 @@ it is not necessary to supply the linker
 for these functions.
 There are several subsystems included inside
 .Em libc :
-.Pp
 .Bl -tag -width "XX"
 .It standard I/O routines
 see
@@ -177,12 +176,12 @@ See
 .Xr ipsec_set_policy 3
 and
 .Xr ipsec_strerror 3 .
-.It Em libkadm Pq Fl l Ns Ar kadm
-The Kerberos IV administration server and client library.
 .It Em libkadm5clnt Pq Fl l Ns Ar kadm5clnt
 The Kerberos 5 administration client library.
 .It Em libkadm5srv Pq Fl l Ns Ar kadm5srv
 The Kerberos 5 administration server library.
+See
+.Xr kadm5_pwcheck 3 .
 .It Em libkafs Pq Fl l Ns Ar kafs
 The Kerberos IV AFS library.
 See



CVS commit: src/sys/dev/usb

2018-05-11 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri May 11 10:59:30 UTC 2018

Modified Files:
src/sys/dev/usb: if_bwfm_usb.c

Log Message:
Fix off-by-one in rx packet processing


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/usb/if_bwfm_usb.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/usb/if_bwfm_usb.c
diff -u src/sys/dev/usb/if_bwfm_usb.c:1.5 src/sys/dev/usb/if_bwfm_usb.c:1.6
--- src/sys/dev/usb/if_bwfm_usb.c:1.5	Fri May 11 07:41:11 2018
+++ src/sys/dev/usb/if_bwfm_usb.c	Fri May 11 10:59:30 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: if_bwfm_usb.c,v 1.5 2018/05/11 07:41:11 maya Exp $ */
+/* $NetBSD: if_bwfm_usb.c,v 1.6 2018/05/11 10:59:30 jmcneill Exp $ */
 /* $OpenBSD: if_bwfm_usb.c,v 1.2 2017/10/15 14:55:13 patrick Exp $ */
 /*
  * Copyright (c) 2010-2016 Broadcom Corporation
@@ -485,7 +485,7 @@ bwfm_usb_rxeof(struct usbd_xfer *xfer, v
 		goto resubmit;
 	len -= sizeof(*hdr);
 	off += sizeof(*hdr);
-	if (len < hdr->data_offset << 2)
+	if (len <= hdr->data_offset << 2)
 		goto resubmit;
 	len -= hdr->data_offset << 2;
 	off += hdr->data_offset << 2;



CVS commit: src/sys

2018-05-11 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri May 11 09:43:59 UTC 2018

Modified Files:
src/sys/kern: uipc_usrreq.c
src/sys/net: raw_cb.h
src/sys/netinet6: in6_proto.c

Log Message:
Increase the default size of some receive buffers from 8k to 16k.
This mitigates recent reports of socket overflow errors
and fixes PR bin/53247.


To generate a diff of this commit:
cvs rdiff -u -r1.185 -r1.186 src/sys/kern/uipc_usrreq.c
cvs rdiff -u -r1.28 -r1.29 src/sys/net/raw_cb.h
cvs rdiff -u -r1.124 -r1.125 src/sys/netinet6/in6_proto.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/kern/uipc_usrreq.c
diff -u src/sys/kern/uipc_usrreq.c:1.185 src/sys/kern/uipc_usrreq.c:1.186
--- src/sys/kern/uipc_usrreq.c:1.185	Sat May  5 19:58:08 2018
+++ src/sys/kern/uipc_usrreq.c	Fri May 11 09:43:59 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: uipc_usrreq.c,v 1.185 2018/05/05 19:58:08 christos Exp $	*/
+/*	$NetBSD: uipc_usrreq.c,v 1.186 2018/05/11 09:43:59 roy Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000, 2004, 2008, 2009 The NetBSD Foundation, Inc.
@@ -96,7 +96,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uipc_usrreq.c,v 1.185 2018/05/05 19:58:08 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_usrreq.c,v 1.186 2018/05/11 09:43:59 roy Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -680,7 +680,7 @@ uipc_ctloutput(int op, struct socket *so
 u_long	unpst_sendspace = PIPSIZ;
 u_long	unpst_recvspace = PIPSIZ;
 u_long	unpdg_sendspace = 2*1024;	/* really max datagram size */
-u_long	unpdg_recvspace = 4*1024;
+u_long	unpdg_recvspace = 16*1024;
 
 u_int	unp_rights;			/* files in flight */
 u_int	unp_rights_ratio = 2;		/* limit, fraction of maxfiles */

Index: src/sys/net/raw_cb.h
diff -u src/sys/net/raw_cb.h:1.28 src/sys/net/raw_cb.h:1.29
--- src/sys/net/raw_cb.h:1.28	Mon Sep 25 01:56:22 2017
+++ src/sys/net/raw_cb.h	Fri May 11 09:43:59 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: raw_cb.h,v 1.28 2017/09/25 01:56:22 ozaki-r Exp $	*/
+/*	$NetBSD: raw_cb.h,v 1.29 2018/05/11 09:43:59 roy Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -57,7 +57,7 @@ struct rawcb {
  * Nominal space allocated to a raw socket.
  */
 #define	RAWSNDQ		8192
-#define	RAWRCVQ		8192
+#define	RAWRCVQ		16384
 
 LIST_HEAD(rawcbhead, rawcb);
 

Index: src/sys/netinet6/in6_proto.c
diff -u src/sys/netinet6/in6_proto.c:1.124 src/sys/netinet6/in6_proto.c:1.125
--- src/sys/netinet6/in6_proto.c:1.124	Thu May  3 07:13:48 2018
+++ src/sys/netinet6/in6_proto.c	Fri May 11 09:43:59 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: in6_proto.c,v 1.124 2018/05/03 07:13:48 maxv Exp $	*/
+/*	$NetBSD: in6_proto.c,v 1.125 2018/05/11 09:43:59 roy Exp $	*/
 /*	$KAME: in6_proto.c,v 1.66 2000/10/10 15:35:47 itojun Exp $	*/
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: in6_proto.c,v 1.124 2018/05/03 07:13:48 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6_proto.c,v 1.125 2018/05/11 09:43:59 roy Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_gateway.h"
@@ -594,7 +594,7 @@ int pmtu_expire = 60*10;
  * Nominal space allocated to a raw ip socket.
  */
 #define	RIPV6SNDQ	8192
-#define	RIPV6RCVQ	8192
+#define	RIPV6RCVQ	16384
 
 u_long	rip6_sendspace = RIPV6SNDQ;
 u_long	rip6_recvspace = RIPV6RCVQ;



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

2018-05-11 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Fri May 11 07:44:48 UTC 2018

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

Log Message:
Enable bwfm at pci.


To generate a diff of this commit:
cvs rdiff -u -r1.489 -r1.490 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.489 src/sys/arch/amd64/conf/GENERIC:1.490
--- src/sys/arch/amd64/conf/GENERIC:1.489	Sun Apr  8 00:52:38 2018
+++ src/sys/arch/amd64/conf/GENERIC	Fri May 11 07:44:47 2018
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.489 2018/04/08 00:52:38 mrg Exp $
+# $NetBSD: GENERIC,v 1.490 2018/05/11 07:44:47 maya 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.489 $"
+#ident		"GENERIC-$Revision: 1.490 $"
 
 maxusers	64		# estimated number of users
 
@@ -765,6 +765,7 @@ bce*	at pci? dev ? function ?	# Broadcom
 bge*	at pci? dev ? function ?	# Broadcom 570x gigabit Ethernet
 bnx*	at pci? dev ? function ?	# Broadcom NetXtremeII gigabit Ethernet
 bwi*	at pci? dev ? function ?	# Broadcom BCM43xx wireless
+bwfm*	at pci? dev ? function ?	# Broadcom FullMAC
 dge*	at pci? dev ? function ?	# Intel 82597 10GbE LR
 en*	at pci? dev ? function ?	# ENI/Adaptec ATM
 ep*	at pci? dev ? function ?	# 3Com 3c59x



CVS commit: src/share/man/man4

2018-05-11 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Fri May 11 07:44:19 UTC 2018

Modified Files:
src/share/man/man4: bwfm.4

Log Message:
Update bwfm(4) man page to note pci support

Mention jmcneill's porting.
omit BUGS, the lack of SDIO support might be resolved soon.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/share/man/man4/bwfm.4

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

Modified files:

Index: src/share/man/man4/bwfm.4
diff -u src/share/man/man4/bwfm.4:1.2 src/share/man/man4/bwfm.4:1.3
--- src/share/man/man4/bwfm.4:1.2	Mon Oct 30 15:50:48 2017
+++ src/share/man/man4/bwfm.4	Fri May 11 07:44:18 2018
@@ -1,4 +1,4 @@
-.\" $NetBSD: bwfm.4,v 1.2 2017/10/30 15:50:48 wiz Exp $
+.\" $NetBSD: bwfm.4,v 1.3 2018/05/11 07:44:18 maya Exp $
 .\"
 .\" Copyright (c) 2017 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -24,7 +24,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd October 26, 2017
+.Dd May 5, 2018
 .Dt BWFM 4
 .Os
 .Sh NAME
@@ -32,6 +32,7 @@
 .Nd Broadcom and Cypress wireless network driver
 .Sh SYNOPSIS
 .Cd "bwfm* at uhub? port ?"
+.Cd "bwfm* at pci? dev ? function ?"
 .Sh DESCRIPTION
 The
 .Nm
@@ -49,7 +50,9 @@ The
 .Nm
 driver was written by
 .An Patrick Wildt
-.Aq Mt patr...@blueri.se .
-.Sh BUGS
-The firmware is outdated and contains known vulnerabilities.
-SDIO and PCI attachments are not supported yet.
+.Aq Mt patr...@blueri.se
+and ported to
+.Nx
+by
+.An Jared D. McNeill
+.Aq Mt jmcne...@netbsd.org .



CVS commit: src

2018-05-11 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Fri May 11 07:43:43 UTC 2018

Modified Files:
src/distrib/sets/lists/base: mi
src/external/broadcom/bwfm: Makefile
Added Files:
src/external/broadcom/bwfm/dist: brcmfmac4350-pcie.bin
brcmfmac4350c2-pcie.bin brcmfmac43602-pcie.bin

Log Message:
Add firmware for use with bwfm at pci.

from the linux-firmware tree


To generate a diff of this commit:
cvs rdiff -u -r1.1173 -r1.1174 src/distrib/sets/lists/base/mi
cvs rdiff -u -r1.1 -r1.2 src/external/broadcom/bwfm/Makefile
cvs rdiff -u -r0 -r1.1 src/external/broadcom/bwfm/dist/brcmfmac4350-pcie.bin \
src/external/broadcom/bwfm/dist/brcmfmac4350c2-pcie.bin \
src/external/broadcom/bwfm/dist/brcmfmac43602-pcie.bin

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

Modified files:

Index: src/distrib/sets/lists/base/mi
diff -u src/distrib/sets/lists/base/mi:1.1173 src/distrib/sets/lists/base/mi:1.1174
--- src/distrib/sets/lists/base/mi:1.1173	Thu Mar 29 04:19:54 2018
+++ src/distrib/sets/lists/base/mi	Fri May 11 07:43:42 2018
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1173 2018/03/29 04:19:54 snj Exp $
+# $NetBSD: mi,v 1.1174 2018/05/11 07:43:42 maya Exp $
 #
 # Note:	Don't delete entries from here - mark them as "obsolete" instead,
 #	unless otherwise stated below.
@@ -145,6 +145,9 @@
 ./libdata/firmware/if_bwfm/brcmfmac43236b.bin	base-firmware-root
 ./libdata/firmware/if_bwfm/brcmfmac43242a.bin	base-firmware-root
 ./libdata/firmware/if_bwfm/brcmfmac43569.bin	base-firmware-root
+./libdata/firmware/if_bwfm/brcmfmac4350-pcie.bin	base-firmware-root
+./libdata/firmware/if_bwfm/brcmfmac4350c2-pcie.bin	base-firmware-root
+./libdata/firmware/if_bwfm/brcmfmac43602-pcie.bin	base-firmware-root
 ./libdata/firmware/if_ipw			base-firmware-root
 ./libdata/firmware/if_ipw/LICENSE		base-firmware-root
 ./libdata/firmware/if_ipw/ipw2100-1.2-i.fw	base-firmware-root

Index: src/external/broadcom/bwfm/Makefile
diff -u src/external/broadcom/bwfm/Makefile:1.1 src/external/broadcom/bwfm/Makefile:1.2
--- src/external/broadcom/bwfm/Makefile:1.1	Sat Oct 21 02:06:34 2017
+++ src/external/broadcom/bwfm/Makefile	Fri May 11 07:43:42 2018
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.1 2017/10/21 02:06:34 jmcneill Exp $
+# $NetBSD: Makefile,v 1.2 2018/05/11 07:43:42 maya Exp $
 
 NOMAN=	# define
 
@@ -7,6 +7,9 @@ FILES+=	dist/brcmfmac43143.bin
 FILES+=	dist/brcmfmac43236b.bin
 FILES+=	dist/brcmfmac43242a.bin
 FILES+=	dist/brcmfmac43569.bin
+FILES+=	dist/brcmfmac4350-pcie.bin
+FILES+=	dist/brcmfmac4350c2-pcie.bin
+FILES+=	dist/brcmfmac43602-pcie.bin
 
 FILESDIR=	/libdata/firmware/if_bwfm
 

Added files:

Index: src/external/broadcom/bwfm/dist/brcmfmac4350-pcie.bin
Binary files are different
Index: src/external/broadcom/bwfm/dist/brcmfmac4350c2-pcie.bin
Binary files are different
Index: src/external/broadcom/bwfm/dist/brcmfmac43602-pcie.bin
Binary files are different



CVS commit: src/sys/dev/pci

2018-05-11 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Fri May 11 07:42:22 UTC 2018

Modified Files:
src/sys/dev/pci: files.pci
Added Files:
src/sys/dev/pci: if_bwfm_pci.c if_bwfm_pci.h

Log Message:
add bwfm pci support, from openbsd

Tested on BCM43602.


To generate a diff of this commit:
cvs rdiff -u -r1.394 -r1.395 src/sys/dev/pci/files.pci
cvs rdiff -u -r0 -r1.1 src/sys/dev/pci/if_bwfm_pci.c \
src/sys/dev/pci/if_bwfm_pci.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/pci/files.pci
diff -u src/sys/dev/pci/files.pci:1.394 src/sys/dev/pci/files.pci:1.395
--- src/sys/dev/pci/files.pci:1.394	Thu Mar  1 04:29:37 2018
+++ src/sys/dev/pci/files.pci	Fri May 11 07:42:22 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: files.pci,v 1.394 2018/03/01 04:29:37 pgoyette Exp $
+#	$NetBSD: files.pci,v 1.395 2018/05/11 07:42:22 maya Exp $
 #
 # Config file and device description for machine-independent PCI code.
 # Included by ports that need it.  Requires that the SCSI files be
@@ -1073,6 +1073,10 @@ include "dev/pci/n8/files.n8"
 attach	bwi at pci with bwi_pci
 file	dev/pci/if_bwi_pci.c		bwi_pci
 
+# Broadcom FullMAC USB wireless adapter
+attach	bwfm at pci with bwfm_pci: firmload
+file	dev/pci/if_bwfm_pci.c		bwfm_pci
+
 # Marvell Serial-ATA Host Controller
 attach	mvsata at pci with mvsata_pci
 file	dev/pci/mvsata_pci.c		mvsata_pci

Added files:

Index: src/sys/dev/pci/if_bwfm_pci.c
diff -u /dev/null src/sys/dev/pci/if_bwfm_pci.c:1.1
--- /dev/null	Fri May 11 07:42:22 2018
+++ src/sys/dev/pci/if_bwfm_pci.c	Fri May 11 07:42:22 2018
@@ -0,0 +1,2062 @@
+/*	$NetBSD: if_bwfm_pci.c,v 1.1 2018/05/11 07:42:22 maya Exp $	*/
+/*	$OpenBSD: if_bwfm_pci.c,v 1.18 2018/02/08 05:00:38 patrick Exp $	*/
+/*
+ * Copyright (c) 2010-2016 Broadcom Corporation
+ * Copyright (c) 2017 Patrick Wildt 
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#define BWFM_DMA_D2H_SCRATCH_BUF_LEN		8
+#define BWFM_DMA_D2H_RINGUPD_BUF_LEN		1024
+#define BWFM_DMA_H2D_IOCTL_BUF_LEN		ETHER_MAX_LEN
+
+#define BWFM_NUM_TX_MSGRINGS			2
+#define BWFM_NUM_RX_MSGRINGS			3
+
+#define BWFM_NUM_TX_PKTIDS			2048
+#define BWFM_NUM_RX_PKTIDS			1024
+
+#define BWFM_NUM_TX_DESCS			1
+#define BWFM_NUM_RX_DESCS			1
+
+#ifdef BWFM_DEBUG
+#define DPRINTF(x)	do { if (bwfm_debug > 0) printf x; } while (0)
+#define DPRINTFN(n, x)	do { if (bwfm_debug >= (n)) printf x; } while (0)
+static int bwfm_debug = 2;
+#else
+#define DPRINTF(x)	do { ; } while (0)
+#define DPRINTFN(n, x)	do { ; } while (0)
+#endif
+
+#define DEVNAME(sc)	device_xname((sc)->sc_sc.sc_dev)
+#define letoh16		htole16
+#define letoh32		htole32
+#define nitems(x)	__arraycount(x)
+
+enum ring_status {
+	RING_CLOSED,
+	RING_CLOSING,
+	RING_OPEN,
+	RING_OPENING,
+};
+
+struct bwfm_pci_msgring {
+	uint32_t		 w_idx_addr;
+	uint32_t		 r_idx_addr;
+	uint32_t		 w_ptr;
+	uint32_t		 r_ptr;
+	int			 nitem;
+	int			 itemsz;
+	enum ring_status	 status;
+	struct bwfm_pci_dmamem	*ring;
+	struct mbuf		*m;
+
+	int			 fifo;
+	uint8_t			 mac[ETHER_ADDR_LEN];
+};
+
+struct bwfm_pci_buf {
+	bus_dmamap_t	 bb_map;
+	struct mbuf	*bb_m;
+};
+
+struct bwfm_pci_pkts {
+	struct bwfm_pci_buf	*pkts;
+	uint32_t		 npkt;
+	int			 last;
+};
+
+struct if_rxring {
+	u_int	rxr_total;
+	u_int	rxr_inuse;
+};
+
+struct bwfm_cmd_flowring_create {
+	struct work		 wq_cookie;
+	struct bwfm_pci_softc	*sc;
+	struct mbuf		*m;
+	int			 flowid;
+	int			 prio;
+};
+
+struct bwfm_pci_softc {
+	struct bwfm_softc	 sc_sc;
+	pci_chipset_tag_t	 sc_pc;
+	pcitag_t		 sc_tag;
+	pcireg_t		 sc_id;
+	void			*sc_ih;
+	pci_intr_handle_t	*sc_pihp;
+
+	bus_space_tag_t		 sc_reg_iot;
+	bus_space_handle_t	 sc_reg_ioh;
+	bus_size_t		 sc_reg_ios;
+
+	bus_space_tag_t		 sc_tcm_iot;
+	bus_space_handle_t	 sc_tcm_ioh;
+	bus_size_t		 sc_tcm_ios;
+
+	bus_dma_tag_t		 sc_dmat;
+
+	uint32_t		 sc_shared_address;
+	uint32_t		 sc_shared_flags;
+	uint8_t			 sc_shared_version;
+
+	uint8_t			 sc_dma_idx_sz;
+	struct 

CVS commit: src/sys/dev

2018-05-11 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Fri May 11 07:41:11 UTC 2018

Modified Files:
src/sys/dev/ic: bwfm.c bwfmreg.h bwfmvar.h
src/sys/dev/sdmmc: if_bwfm_sdio.c
src/sys/dev/usb: if_bwfm_usb.c

Log Message:
sync with openbsd bwfm to some extent.

add a txcheck
set chip active/passive for more kinds of chips
add wrapper around setting active/passive
detect chip RAM
make bwfm_rx take an mbuf


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/ic/bwfm.c
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/ic/bwfmreg.h
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/ic/bwfmvar.h
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/sdmmc/if_bwfm_sdio.c
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/usb/if_bwfm_usb.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/bwfm.c
diff -u src/sys/dev/ic/bwfm.c:1.10 src/sys/dev/ic/bwfm.c:1.11
--- src/sys/dev/ic/bwfm.c:1.10	Tue Jan 16 18:42:43 2018
+++ src/sys/dev/ic/bwfm.c	Fri May 11 07:41:11 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: bwfm.c,v 1.10 2018/01/16 18:42:43 maxv Exp $ */
+/* $NetBSD: bwfm.c,v 1.11 2018/05/11 07:41:11 maya Exp $ */
 /* $OpenBSD: bwfm.c,v 1.5 2017/10/16 22:27:16 patrick Exp $ */
 /*
  * Copyright (c) 2010-2016 Broadcom Corporation
@@ -21,7 +21,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -85,9 +84,16 @@ void	 bwfm_chip_ai_reset(struct bwfm_sof
 void	 bwfm_chip_dmp_erom_scan(struct bwfm_softc *);
 int	 bwfm_chip_dmp_get_regaddr(struct bwfm_softc *, uint32_t *,
 	 uint32_t *, uint32_t *);
+int	 bwfm_chip_cr4_set_active(struct bwfm_softc *, const uint32_t);
 void	 bwfm_chip_cr4_set_passive(struct bwfm_softc *);
+int	 bwfm_chip_ca7_set_active(struct bwfm_softc *, const uint32_t);
 void	 bwfm_chip_ca7_set_passive(struct bwfm_softc *);
+int	 bwfm_chip_cm3_set_active(struct bwfm_softc *);
 void	 bwfm_chip_cm3_set_passive(struct bwfm_softc *);
+void	 bwfm_chip_socram_ramsize(struct bwfm_softc *, struct bwfm_core *);
+void	 bwfm_chip_sysmem_ramsize(struct bwfm_softc *, struct bwfm_core *);
+void	 bwfm_chip_tcm_ramsize(struct bwfm_softc *, struct bwfm_core *);
+void	 bwfm_chip_tcm_rambase(struct bwfm_softc *);
 
 int	 bwfm_proto_bcdc_query_dcmd(struct bwfm_softc *, int,
 	 int, char *, size_t *);
@@ -107,7 +113,7 @@ struct ieee80211_channel *bwfm_bss2chan(
 void	 bwfm_scan(struct bwfm_softc *);
 void	 bwfm_connect(struct bwfm_softc *);
 
-void	 bwfm_rx(struct bwfm_softc *, char *, size_t);
+void	 bwfm_rx(struct bwfm_softc *, struct mbuf *);
 void	 bwfm_rx_event(struct bwfm_softc *, char *, size_t);
 void	 bwfm_scan_node(struct bwfm_softc *, struct bwfm_bss_info *, size_t);
 
@@ -133,7 +139,7 @@ bwfm_attach(struct bwfm_softc *sc)
 	char fw_version[BWFM_DCMD_SMLEN];
 	uint32_t bandlist[3];
 	uint32_t tmp;
-	int i, error;
+	int i, j, error;
 
 	error = workqueue_create(>sc_taskq, DEVNAME(sc),
 	bwfm_task, sc, PRI_NONE, IPL_NET, 0);
@@ -203,8 +209,8 @@ bwfm_attach(struct bwfm_softc *sc)
 			ic->ic_sup_rates[IEEE80211_MODE_11B] = ieee80211_std_rateset_11b;
 			ic->ic_sup_rates[IEEE80211_MODE_11G] = ieee80211_std_rateset_11g;
 
-			for (i = 0; i < __arraycount(bwfm_2ghz_channels); i++) {
-uint8_t chan = bwfm_2ghz_channels[i];
+			for (j = 0; j < __arraycount(bwfm_2ghz_channels); j++) {
+uint8_t chan = bwfm_2ghz_channels[j];
 ic->ic_channels[chan].ic_freq =
 ieee80211_ieee2mhz(chan, IEEE80211_CHAN_2GHZ);
 ic->ic_channels[chan].ic_flags =
@@ -215,8 +221,8 @@ bwfm_attach(struct bwfm_softc *sc)
 		case BWFM_BAND_5G:
 			ic->ic_sup_rates[IEEE80211_MODE_11A] = ieee80211_std_rateset_11a;
 
-			for (i = 0; i < __arraycount(bwfm_5ghz_channels); i++) {
-uint8_t chan = bwfm_5ghz_channels[i];
+			for (j = 0; j < __arraycount(bwfm_5ghz_channels); j++) {
+uint8_t chan = bwfm_5ghz_channels[j];
 ic->ic_channels[chan].ic_freq =
 ieee80211_ieee2mhz(chan, IEEE80211_CHAN_5GHZ);
 ic->ic_channels[chan].ic_flags =
@@ -307,6 +313,11 @@ bwfm_start(struct ifnet *ifp)
 			continue;
 		}
 
+		if (sc->sc_bus_ops->bs_txcheck(sc)) {
+			ifp->if_flags |= IFF_OACTIVE;
+			break;
+		}
+
 		IFQ_DEQUEUE(>if_snd, m);
 		if (m == NULL)
 			break;
@@ -848,24 +859,22 @@ bwfm_chip_attach(struct bwfm_softc *sc)
 		return 1;
 	}
 
-	if (bwfm_chip_get_core(sc, BWFM_AGENT_CORE_ARM_CR4) != NULL)
-		bwfm_chip_cr4_set_passive(sc);
-	if (bwfm_chip_get_core(sc, BWFM_AGENT_CORE_ARM_CA7) != NULL)
-		bwfm_chip_ca7_set_passive(sc);
-	if (bwfm_chip_get_core(sc, BWFM_AGENT_CORE_ARM_CM3) != NULL)
-		bwfm_chip_cm3_set_passive(sc);
+	bwfm_chip_set_passive(sc);
 
 	if (sc->sc_buscore_ops->bc_reset) {
 		sc->sc_buscore_ops->bc_reset(sc);
-		if (bwfm_chip_get_core(sc, BWFM_AGENT_CORE_ARM_CR4) != NULL)
-			bwfm_chip_cr4_set_passive(sc);
-		if (bwfm_chip_get_core(sc, BWFM_AGENT_CORE_ARM_CA7) != NULL)
-			bwfm_chip_ca7_set_passive(sc);
-		if (bwfm_chip_get_core(sc, BWFM_AGENT_CORE_ARM_CM3) != NULL)
-