CVS commit: [nick-nhusb] src/sys/dev/usb

2017-02-01 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Feb  2 07:40:51 UTC 2017

Modified Files:
src/sys/dev/usb [nick-nhusb]: if_smsc.c

Log Message:
Style / more const.  No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.22.2.28 -r1.22.2.29 src/sys/dev/usb/if_smsc.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_smsc.c
diff -u src/sys/dev/usb/if_smsc.c:1.22.2.28 src/sys/dev/usb/if_smsc.c:1.22.2.29
--- src/sys/dev/usb/if_smsc.c:1.22.2.28	Thu Feb  2 07:36:45 2017
+++ src/sys/dev/usb/if_smsc.c	Thu Feb  2 07:40:51 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_smsc.c,v 1.22.2.28 2017/02/02 07:36:45 skrll Exp $	*/
+/*	$NetBSD: if_smsc.c,v 1.22.2.29 2017/02/02 07:40:51 skrll Exp $	*/
 
 /*	$OpenBSD: if_smsc.c,v 1.4 2012/09/27 12:38:11 jsg Exp $	*/
 /*	$FreeBSD: src/sys/dev/usb/net/if_smsc.c,v 1.1 2012/08/15 04:03:55 gonzo Exp $ */
@@ -679,7 +679,7 @@ smsc_start_locked(struct ifnet *ifp)
 void
 smsc_tick(void *xsc)
 {
-	struct smsc_softc *sc = xsc;
+	struct smsc_softc * const sc = xsc;
 
 	if (sc == NULL)
 		return;
@@ -1225,22 +1225,20 @@ smsc_detach(device_t self, int flags)
 void
 smsc_tick_task(void *xsc)
 {
-	int			 s;
-	struct smsc_softc	*sc = xsc;
-	struct ifnet		*ifp;
-	struct mii_data		*mii;
+	struct smsc_softc * const sc = xsc;
 
 	if (sc == NULL)
 		return;
 
 	if (sc->sc_dying)
 		return;
-	ifp = >sc_ec.ec_if;
-	mii = >sc_mii;
+
+	struct ifnet * const ifp = >sc_ec.ec_if;
+	struct mii_data	* const mii = >sc_mii;
 	if (mii == NULL)
 		return;
 
-	s = splnet();
+	const int s = splnet();
 
 	mii_tick(mii);
 	if ((sc->sc_flags & SMSC_FLAG_LINK) == 0)



CVS commit: [nick-nhusb] src/sys/dev/usb

2017-02-01 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Feb  2 07:36:45 UTC 2017

Modified Files:
src/sys/dev/usb [nick-nhusb]: if_smsc.c

Log Message:
Whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.22.2.27 -r1.22.2.28 src/sys/dev/usb/if_smsc.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_smsc.c
diff -u src/sys/dev/usb/if_smsc.c:1.22.2.27 src/sys/dev/usb/if_smsc.c:1.22.2.28
--- src/sys/dev/usb/if_smsc.c:1.22.2.27	Thu Feb  2 07:35:36 2017
+++ src/sys/dev/usb/if_smsc.c	Thu Feb  2 07:36:45 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_smsc.c,v 1.22.2.27 2017/02/02 07:35:36 skrll Exp $	*/
+/*	$NetBSD: if_smsc.c,v 1.22.2.28 2017/02/02 07:36:45 skrll Exp $	*/
 
 /*	$OpenBSD: if_smsc.c,v 1.4 2012/09/27 12:38:11 jsg Exp $	*/
 /*	$FreeBSD: src/sys/dev/usb/net/if_smsc.c,v 1.1 2012/08/15 04:03:55 gonzo Exp $ */
@@ -1626,7 +1626,7 @@ smsc_encap(struct smsc_softc *sc, struct
 	 * length of the packet and buffer.
 	 */
 	txhdr = SMSC_TX_CTRL_0_BUF_SIZE(m->m_pkthdr.len) |
-			SMSC_TX_CTRL_0_FIRST_SEG | SMSC_TX_CTRL_0_LAST_SEG;
+	SMSC_TX_CTRL_0_FIRST_SEG | SMSC_TX_CTRL_0_LAST_SEG;
 	txhdr = htole32(txhdr);
 	memcpy(c->sc_buf, , sizeof(txhdr));
 



CVS commit: [nick-nhusb] src/sys/dev/usb

2017-02-01 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Feb  2 07:35:36 UTC 2017

Modified Files:
src/sys/dev/usb [nick-nhusb]: if_smsc.c

Log Message:
Use lower case


To generate a diff of this commit:
cvs rdiff -u -r1.22.2.26 -r1.22.2.27 src/sys/dev/usb/if_smsc.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_smsc.c
diff -u src/sys/dev/usb/if_smsc.c:1.22.2.26 src/sys/dev/usb/if_smsc.c:1.22.2.27
--- src/sys/dev/usb/if_smsc.c:1.22.2.26	Thu Feb  2 07:34:15 2017
+++ src/sys/dev/usb/if_smsc.c	Thu Feb  2 07:35:36 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_smsc.c,v 1.22.2.26 2017/02/02 07:34:15 skrll Exp $	*/
+/*	$NetBSD: if_smsc.c,v 1.22.2.27 2017/02/02 07:35:36 skrll Exp $	*/
 
 /*	$OpenBSD: if_smsc.c,v 1.4 2012/09/27 12:38:11 jsg Exp $	*/
 /*	$FreeBSD: src/sys/dev/usb/net/if_smsc.c,v 1.1 2012/08/15 04:03:55 gonzo Exp $ */
@@ -280,7 +280,7 @@ smsc_miibus_readreg(device_t dev, int ph
 done:
 	smsc_unlock_mii(sc);
 
-	return val & 0x;
+	return val & 0x;
 }
 
 void



CVS commit: [nick-nhusb] src/sys/dev/usb

2017-02-01 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Feb  2 07:34:15 UTC 2017

Modified Files:
src/sys/dev/usb [nick-nhusb]: if_smsc.c

Log Message:
Remove useless check


To generate a diff of this commit:
cvs rdiff -u -r1.22.2.25 -r1.22.2.26 src/sys/dev/usb/if_smsc.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_smsc.c
diff -u src/sys/dev/usb/if_smsc.c:1.22.2.25 src/sys/dev/usb/if_smsc.c:1.22.2.26
--- src/sys/dev/usb/if_smsc.c:1.22.2.25	Thu Feb  2 07:23:03 2017
+++ src/sys/dev/usb/if_smsc.c	Thu Feb  2 07:34:15 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_smsc.c,v 1.22.2.25 2017/02/02 07:23:03 skrll Exp $	*/
+/*	$NetBSD: if_smsc.c,v 1.22.2.26 2017/02/02 07:34:15 skrll Exp $	*/
 
 /*	$OpenBSD: if_smsc.c,v 1.4 2012/09/27 12:38:11 jsg Exp $	*/
 /*	$FreeBSD: src/sys/dev/usb/net/if_smsc.c,v 1.1 2012/08/15 04:03:55 gonzo Exp $ */
@@ -474,9 +474,6 @@ smsc_sethwcsum(struct smsc_softc *sc)
 	uint32_t val;
 	int err;
 
-	if (!ifp)
-		return EIO;
-
 	err = smsc_read_reg(sc, SMSC_COE_CTRL, );
 	if (err != 0) {
 		smsc_warn_printf(sc, "failed to read SMSC_COE_CTRL (err=%d)\n",



CVS commit: [nick-nhusb] src/sys/dev/usb

2017-02-01 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Feb  2 07:23:03 UTC 2017

Modified Files:
src/sys/dev/usb [nick-nhusb]: if_smsc.c

Log Message:
Sprinkle some const


To generate a diff of this commit:
cvs rdiff -u -r1.22.2.24 -r1.22.2.25 src/sys/dev/usb/if_smsc.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_smsc.c
diff -u src/sys/dev/usb/if_smsc.c:1.22.2.24 src/sys/dev/usb/if_smsc.c:1.22.2.25
--- src/sys/dev/usb/if_smsc.c:1.22.2.24	Thu Feb  2 07:16:03 2017
+++ src/sys/dev/usb/if_smsc.c	Thu Feb  2 07:23:03 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_smsc.c,v 1.22.2.24 2017/02/02 07:16:03 skrll Exp $	*/
+/*	$NetBSD: if_smsc.c,v 1.22.2.25 2017/02/02 07:23:03 skrll Exp $	*/
 
 /*	$OpenBSD: if_smsc.c,v 1.4 2012/09/27 12:38:11 jsg Exp $	*/
 /*	$FreeBSD: src/sys/dev/usb/net/if_smsc.c,v 1.1 2012/08/15 04:03:55 gonzo Exp $ */
@@ -259,7 +259,7 @@ smsc_wait_for_bits(struct smsc_softc *sc
 int
 smsc_miibus_readreg(device_t dev, int phy, int reg)
 {
-	struct smsc_softc *sc = device_private(dev);
+	struct smsc_softc * const sc = device_private(dev);
 	uint32_t addr;
 	uint32_t val = 0;
 
@@ -286,7 +286,7 @@ done:
 void
 smsc_miibus_writereg(device_t dev, int phy, int reg, int val)
 {
-	struct smsc_softc *sc = device_private(dev);
+	struct smsc_softc * const sc = device_private(dev);
 	uint32_t addr;
 
 	if (sc->sc_phyno != phy)
@@ -312,8 +312,8 @@ smsc_miibus_writereg(device_t dev, int p
 void
 smsc_miibus_statchg(struct ifnet *ifp)
 {
-	struct smsc_softc *sc = ifp->if_softc;
-	struct mii_data *mii = >sc_mii;
+	struct smsc_softc * const sc = ifp->if_softc;
+	struct mii_data * const mii = >sc_mii;
 	int err;
 	uint32_t flow;
 	uint32_t afc_cfg;
@@ -386,8 +386,8 @@ smsc_miibus_statchg(struct ifnet *ifp)
 int
 smsc_ifmedia_upd(struct ifnet *ifp)
 {
-	struct smsc_softc *sc = ifp->if_softc;
-	struct mii_data *mii = >sc_mii;
+	struct smsc_softc * const sc = ifp->if_softc;
+	struct mii_data * const mii = >sc_mii;
 	int err;
 
 	if (mii->mii_instance) {
@@ -403,8 +403,8 @@ smsc_ifmedia_upd(struct ifnet *ifp)
 void
 smsc_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr)
 {
-	struct smsc_softc *sc = ifp->if_softc;
-	struct mii_data *mii = >sc_mii;
+	struct smsc_softc * const sc = ifp->if_softc;
+	struct mii_data * const mii = >sc_mii;
 
 	mii_pollstat(mii);
 
@@ -421,7 +421,7 @@ smsc_hash(uint8_t addr[ETHER_ADDR_LEN])
 void
 smsc_setmulti(struct smsc_softc *sc)
 {
-	struct ifnet		*ifp = >sc_ec.ec_if;
+	struct ifnet * const ifp = >sc_ec.ec_if;
 	struct ether_multi	*enm;
 	struct ether_multistep	 step;
 	uint32_t		 hashtbl[2] = { 0, 0 };
@@ -470,7 +470,7 @@ allmulti:
 int
 smsc_sethwcsum(struct smsc_softc *sc)
 {
-	struct ifnet *ifp = >sc_ec.ec_if;
+	struct ifnet * const ifp = >sc_ec.ec_if;
 	uint32_t val;
 	int err;
 
@@ -545,7 +545,7 @@ smsc_reset(struct smsc_softc *sc)
 int
 smsc_init(struct ifnet *ifp)
 {
-	struct smsc_softc *sc = ifp->if_softc;
+	struct smsc_softc * const sc = ifp->if_softc;
 
 	mutex_enter(>sc_lock);
 	int ret = smsc_init_locked(ifp);



CVS commit: [nick-nhusb] src/sys/dev/usb

2017-02-01 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Feb  2 07:16:03 UTC 2017

Modified Files:
src/sys/dev/usb [nick-nhusb]: if_smsc.c

Log Message:
Add a TAB


To generate a diff of this commit:
cvs rdiff -u -r1.22.2.23 -r1.22.2.24 src/sys/dev/usb/if_smsc.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_smsc.c
diff -u src/sys/dev/usb/if_smsc.c:1.22.2.23 src/sys/dev/usb/if_smsc.c:1.22.2.24
--- src/sys/dev/usb/if_smsc.c:1.22.2.23	Tue Jan 31 17:09:08 2017
+++ src/sys/dev/usb/if_smsc.c	Thu Feb  2 07:16:03 2017
@@ -1,7 +1,7 @@
-/*	$NetBSD: if_smsc.c,v 1.22.2.23 2017/01/31 17:09:08 skrll Exp $	*/
+/*	$NetBSD: if_smsc.c,v 1.22.2.24 2017/02/02 07:16:03 skrll Exp $	*/
 
 /*	$OpenBSD: if_smsc.c,v 1.4 2012/09/27 12:38:11 jsg Exp $	*/
-/* $FreeBSD: src/sys/dev/usb/net/if_smsc.c,v 1.1 2012/08/15 04:03:55 gonzo Exp $ */
+/*	$FreeBSD: src/sys/dev/usb/net/if_smsc.c,v 1.1 2012/08/15 04:03:55 gonzo Exp $ */
 /*-
  * Copyright (c) 2012
  *	Ben Gray .



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

2017-02-01 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Feb  2 05:43:48 UTC 2017

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

Log Message:
 Modify comment. Use long form.


To generate a diff of this commit:
cvs rdiff -u -r1.91 -r1.92 src/sys/arch/x86/include/specialreg.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/specialreg.h
diff -u src/sys/arch/x86/include/specialreg.h:1.91 src/sys/arch/x86/include/specialreg.h:1.92
--- src/sys/arch/x86/include/specialreg.h:1.91	Thu Dec  8 06:11:03 2016
+++ src/sys/arch/x86/include/specialreg.h	Thu Feb  2 05:43:48 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: specialreg.h,v 1.91 2016/12/08 06:11:03 msaitoh Exp $	*/
+/*	$NetBSD: specialreg.h,v 1.92 2017/02/02 05:43:48 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 1991 The Regents of the University of California.
@@ -292,7 +292,7 @@
 #define CPUID_DSPM_HWP_ACTWIN  __BIT(9)	/* HWP Activity Window */
 #define CPUID_DSPM_HWP_EPP __BIT(10)	/* HWP Energy Performance Preference */
 #define CPUID_DSPM_HWP_PLR __BIT(11)	/* HWP Package Level Request */
-#define CPUID_DSPM_HDC	__BIT(13)	/* HDC */
+#define CPUID_DSPM_HDC	__BIT(13)	/* Hardware Duty Cycling */
 
 #define CPUID_DSPM_FLAGS	"\20" \
 	"\1" "DTS"	"\2" "IDA"	"\3" "ARAT" 			\



CVS commit: src/sys/dev/pci

2017-02-01 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Feb  2 05:38:59 UTC 2017

Modified Files:
src/sys/dev/pci: if_wmreg.h

Log Message:
Fix typo in comment.


To generate a diff of this commit:
cvs rdiff -u -r1.96 -r1.97 src/sys/dev/pci/if_wmreg.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/if_wmreg.h
diff -u src/sys/dev/pci/if_wmreg.h:1.96 src/sys/dev/pci/if_wmreg.h:1.97
--- src/sys/dev/pci/if_wmreg.h:1.96	Wed Feb  1 04:18:43 2017
+++ src/sys/dev/pci/if_wmreg.h	Thu Feb  2 05:38:59 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wmreg.h,v 1.96 2017/02/01 04:18:43 knakahara Exp $	*/
+/*	$NetBSD: if_wmreg.h,v 1.97 2017/02/02 05:38:59 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -1161,7 +1161,7 @@ struct livengood_tcpip_ctxdesc {
 #define	WUC_APME		0x0001 /* APM Enable */
 #define	WUC_PME_EN		0x0002 /* PME Enable */
 
-#define	WMREG_WUFC	0x5808	/* Wakeup Filter COntrol */
+#define	WMREG_WUFC	0x5808	/* Wakeup Filter Control */
 #define WUFC_MAG		0x0002 /* Magic Packet Wakeup Enable */
 #define WUFC_EX			0x0004 /* Directed Exact Wakeup Enable */
 #define WUFC_MC			0x0008 /* Directed Multicast Wakeup En */



CVS commit: src/sys/dev/pci

2017-02-01 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Thu Feb  2 03:41:22 UTC 2017

Modified Files:
src/sys/dev/pci: if_wpi.c if_wpivar.h

Log Message:
wpi(4): use MSI if available.


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/sys/dev/pci/if_wpi.c
cvs rdiff -u -r1.19 -r1.20 src/sys/dev/pci/if_wpivar.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/if_wpi.c
diff -u src/sys/dev/pci/if_wpi.c:1.75 src/sys/dev/pci/if_wpi.c:1.76
--- src/sys/dev/pci/if_wpi.c:1.75	Thu Dec  8 01:12:01 2016
+++ src/sys/dev/pci/if_wpi.c	Thu Feb  2 03:41:22 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wpi.c,v 1.75 2016/12/08 01:12:01 ozaki-r Exp $	*/
+/*	$NetBSD: if_wpi.c,v 1.76 2017/02/02 03:41:22 jakllsch Exp $	*/
 
 /*-
  * Copyright (c) 2006, 2007
@@ -18,7 +18,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wpi.c,v 1.75 2016/12/08 01:12:01 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wpi.c,v 1.76 2017/02/02 03:41:22 jakllsch Exp $");
 
 /*
  * Driver for Intel PRO/Wireless 3945ABG 802.11 network adapters.
@@ -206,7 +206,6 @@ wpi_attach(device_t parent __unused, dev
 	const char *intrstr;
 	bus_space_tag_t memt;
 	bus_space_handle_t memh;
-	pci_intr_handle_t ih;
 	pcireg_t data;
 	int ac, error;
 	char intrbuf[PCI_INTRSTR_LEN];
@@ -256,13 +255,15 @@ wpi_attach(device_t parent __unused, dev
 	sc->sc_sh = memh;
 	sc->sc_dmat = pa->pa_dmat;
 
-	if (pci_intr_map(pa, ) != 0) {
+	if (pci_intr_alloc(pa, >sc_pihp, NULL, 0)) {
 		aprint_error_dev(self, "could not map interrupt\n");
 		return;
 	}
 
-	intrstr = pci_intr_string(sc->sc_pct, ih, intrbuf, sizeof(intrbuf));
-	sc->sc_ih = pci_intr_establish(sc->sc_pct, ih, IPL_NET, wpi_intr, sc);
+	intrstr = pci_intr_string(sc->sc_pct, sc->sc_pihp[0], intrbuf,
+	sizeof(intrbuf));
+	sc->sc_ih = pci_intr_establish(sc->sc_pct, sc->sc_pihp[0], IPL_NET,
+	wpi_intr, sc);
 	if (sc->sc_ih == NULL) {
 		aprint_error_dev(self, "could not establish interrupt");
 		if (intrstr != NULL)
@@ -432,6 +433,10 @@ wpi_detach(device_t self, int flags __un
 		pci_intr_disestablish(sc->sc_pct, sc->sc_ih);
 		sc->sc_ih = NULL;
 	}
+	if (sc->sc_pihp != NULL) {
+		pci_intr_release(sc->sc_pct, sc->sc_pihp, 1);
+		sc->sc_pihp = NULL;
+	}
 	mutex_enter(>sc_rsw_mtx);
 	sc->sc_dying = 1;
 	cv_signal(>sc_rsw_cv);

Index: src/sys/dev/pci/if_wpivar.h
diff -u src/sys/dev/pci/if_wpivar.h:1.19 src/sys/dev/pci/if_wpivar.h:1.20
--- src/sys/dev/pci/if_wpivar.h:1.19	Tue Jan  6 15:39:54 2015
+++ src/sys/dev/pci/if_wpivar.h	Thu Feb  2 03:41:22 2017
@@ -1,4 +1,4 @@
-/*  $NetBSD: if_wpivar.h,v 1.19 2015/01/06 15:39:54 bouyer Exp $*/
+/*  $NetBSD: if_wpivar.h,v 1.20 2017/02/02 03:41:22 jakllsch Exp $*/
 
 /*-
  * Copyright (c) 2006
@@ -150,6 +150,7 @@ struct wpi_softc {
 	bus_space_tag_t		sc_st;
 	bus_space_handle_t	sc_sh;
 	void 			*sc_ih;
+	pci_intr_handle_t	*sc_pihp;
 	pci_chipset_tag_t	sc_pct;
 	pcitag_t		sc_pcitag;
 	bus_size_t		sc_sz;



CVS commit: src/sys/dev/pci

2017-02-01 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Thu Feb  2 03:20:20 UTC 2017

Modified Files:
src/sys/dev/pci: if_iwn.c if_iwnvar.h

Log Message:
iwn(4): use MSI if available.


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.83 src/sys/dev/pci/if_iwn.c
cvs rdiff -u -r1.17 -r1.18 src/sys/dev/pci/if_iwnvar.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/if_iwn.c
diff -u src/sys/dev/pci/if_iwn.c:1.82 src/sys/dev/pci/if_iwn.c:1.83
--- src/sys/dev/pci/if_iwn.c:1.82	Wed Jan  4 03:05:24 2017
+++ src/sys/dev/pci/if_iwn.c	Thu Feb  2 03:20:19 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_iwn.c,v 1.82 2017/01/04 03:05:24 nonaka Exp $	*/
+/*	$NetBSD: if_iwn.c,v 1.83 2017/02/02 03:20:19 nonaka Exp $	*/
 /*	$OpenBSD: if_iwn.c,v 1.135 2014/09/10 07:22:09 dcoppa Exp $	*/
 
 /*-
@@ -22,7 +22,7 @@
  * adapters.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_iwn.c,v 1.82 2017/01/04 03:05:24 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_iwn.c,v 1.83 2017/02/02 03:20:19 nonaka Exp $");
 
 #define IWN_USE_RBUF	/* Use local storage for RX */
 #undef IWN_HWCRYPTO	/* XXX does not even compile yet */
@@ -362,7 +362,6 @@ iwn_attach(device_t parent __unused, dev
 	struct ifnet *ifp = >sc_ec.ec_if;
 	struct pci_attach_args *pa = aux;
 	const char *intrstr;
-	pci_intr_handle_t ih;
 	pcireg_t memtype, reg;
 	int i, error;
 	char intrbuf[PCI_INTRSTR_LEN];
@@ -395,14 +394,10 @@ iwn_attach(device_t parent __unused, dev
 	if (reg & 0xff00)
 		pci_conf_write(sc->sc_pct, sc->sc_pcitag, 0x40, reg & ~0xff00);
 
-	/* Enable bus-mastering and hardware bug workaround. */
+	/* Enable bus-mastering. */
 	/* XXX verify the bus-mastering is really needed (not in OpenBSD) */
 	reg = pci_conf_read(sc->sc_pct, sc->sc_pcitag, PCI_COMMAND_STATUS_REG);
 	reg |= PCI_COMMAND_MASTER_ENABLE;
-	if (reg & PCI_COMMAND_INTERRUPT_DISABLE) {
-		DPRINTF(("PCIe INTx Disable set\n"));
-		reg &= ~PCI_COMMAND_INTERRUPT_DISABLE;
-	}
 	pci_conf_write(sc->sc_pct, sc->sc_pcitag, PCI_COMMAND_STATUS_REG, reg);
 
 	memtype = pci_mapreg_type(pa->pa_pc, pa->pa_tag, IWN_PCI_BAR0);
@@ -414,18 +409,27 @@ iwn_attach(device_t parent __unused, dev
 	}
 
 	/* Install interrupt handler. */
-	if (pci_intr_map(pa, ) != 0) {
-		aprint_error_dev(self, "can't map interrupt\n");
-		return;
+	error = pci_intr_alloc(pa, >sc_pihp, NULL, 0);
+	if (error) {
+		aprint_error_dev(self, "can't allocate interrupt\n");
+		goto unmap;
 	}
-	intrstr = pci_intr_string(sc->sc_pct, ih, intrbuf, sizeof(intrbuf));
-	sc->sc_ih = pci_intr_establish(sc->sc_pct, ih, IPL_NET, iwn_intr, sc);
+	reg = pci_conf_read(sc->sc_pct, sc->sc_pcitag, PCI_COMMAND_STATUS_REG);
+	if (pci_intr_type(sc->sc_pct, sc->sc_pihp[0]) == PCI_INTR_TYPE_INTX)
+		CLR(reg, PCI_COMMAND_INTERRUPT_DISABLE);
+	else
+		SET(reg, PCI_COMMAND_INTERRUPT_DISABLE);
+	pci_conf_write(sc->sc_pct, sc->sc_pcitag, PCI_COMMAND_STATUS_REG, reg);
+	intrstr = pci_intr_string(sc->sc_pct, sc->sc_pihp[0], intrbuf,
+	sizeof(intrbuf));
+	sc->sc_ih = pci_intr_establish_xname(sc->sc_pct, sc->sc_pihp[0],
+	IPL_NET, iwn_intr, sc, device_xname(self));
 	if (sc->sc_ih == NULL) {
 		aprint_error_dev(self, "can't establish interrupt");
 		if (intrstr != NULL)
 			aprint_error(" at %s", intrstr);
 		aprint_error("\n");
-		return;
+		goto failia;
 	}
 	aprint_normal_dev(self, "interrupting at %s\n", intrstr);
 
@@ -439,25 +443,25 @@ iwn_attach(device_t parent __unused, dev
 		error = iwn5000_attach(sc, PCI_PRODUCT(pa->pa_id));
 	if (error != 0) {
 		aprint_error_dev(self, "could not attach device\n");
-		return;
+		goto failih;
 	}	
 
 	if ((error = iwn_hw_prepare(sc)) != 0) {
 		aprint_error_dev(self, "hardware not ready\n");
-		return;
+		goto failih;
 	}
 
 	/* Read MAC address, channels, etc from EEPROM. */
 	if ((error = iwn_read_eeprom(sc)) != 0) {
 		aprint_error_dev(self, "could not read EEPROM\n");
-		return;
+		goto failih;
 	}
 
 	/* Allocate DMA memory for firmware transfers. */
 	if ((error = iwn_alloc_fwmem(sc)) != 0) {
 		aprint_error_dev(self,
 		"could not allocate memory for firmware\n");
-		return;
+		goto failih;
 	}
 
 	/* Allocate "Keep Warm" page. */
@@ -638,6 +642,11 @@ fail3:	if (sc->ict != NULL)
 		iwn_free_ict(sc);
 fail2:	iwn_free_kw(sc);
 fail1:	iwn_free_fwmem(sc);
+failih:	pci_intr_disestablish(sc->sc_pct, sc->sc_ih);
+	sc->sc_ih = NULL;
+failia:	pci_intr_release(sc->sc_pct, sc->sc_pihp, 1);
+	sc->sc_pihp = NULL;
+unmap:	bus_space_unmap(sc->sc_st, sc->sc_sh, sc->sc_sz);
 }
 
 int
@@ -825,6 +834,8 @@ iwn_detach(device_t self, int flags __un
 	/* Uninstall interrupt handler. */
 	if (sc->sc_ih != NULL)
 		pci_intr_disestablish(sc->sc_pct, sc->sc_ih);
+	if (sc->sc_pihp != NULL)
+		pci_intr_release(sc->sc_pct, sc->sc_pihp, 1);
 
 	/* Free DMA resources. */
 	iwn_free_rx_ring(sc, >rxq);

Index: src/sys/dev/pci/if_iwnvar.h
diff -u src/sys/dev/pci/if_iwnvar.h:1.17 src/sys/dev/pci/if_iwnvar.h:1.18
--- 

CVS commit: src/sys

2017-02-01 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Thu Feb  2 02:52:10 UTC 2017

Modified Files:
src/sys/net: files.net
src/sys/netinet: ip_carp.c ip_icmp.c
src/sys/netinet6: icmp6.c
src/sys/rump/librump/rumpnet: Makefile.rumpnet
Added Files:
src/sys/netinet: wqinput.c wqinput.h

Log Message:
Defer some pr_input to workqueue

pr_input is currently called in softint. Some pr_input such as ICMP, ICMPv6
and CARP can add/delete/update IP addresses and routing table entries. For
example, icmp6_redirect_input updates an a routing table entry and
nd6_ra_input may delete an IP address.

Basically such operations shouldn't be done in softint. That aside, we have
a reason to avoid the situation; psz/psref waits cannot be used in softint,
however they are required to work in such pr_input in the MP-safe world.

The change implements the workqueue pr_input framework called wqinput which
provides a means to defer pr_input of a protocol to workqueue easily.
Currently icmp_input, icmp6_input, carp_proto_input and carp6_proto_input
are deferred to workqueue by the framework.

Proposed and discussed on tech-kern and tech-net


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/net/files.net
cvs rdiff -u -r1.83 -r1.84 src/sys/netinet/ip_carp.c
cvs rdiff -u -r1.155 -r1.156 src/sys/netinet/ip_icmp.c
cvs rdiff -u -r0 -r1.1 src/sys/netinet/wqinput.c src/sys/netinet/wqinput.h
cvs rdiff -u -r1.206 -r1.207 src/sys/netinet6/icmp6.c
cvs rdiff -u -r1.20 -r1.21 src/sys/rump/librump/rumpnet/Makefile.rumpnet

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/files.net
diff -u src/sys/net/files.net:1.11 src/sys/net/files.net:1.12
--- src/sys/net/files.net:1.11	Fri Sep 16 03:10:45 2016
+++ src/sys/net/files.net	Thu Feb  2 02:52:10 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: files.net,v 1.11 2016/09/16 03:10:45 pgoyette Exp $
+#	$NetBSD: files.net,v 1.12 2017/02/02 02:52:10 ozaki-r Exp $
 
 # XXX CLEANUP
 define	net
@@ -62,6 +62,7 @@ file	netinet/ip_carp.c		carp & (inet | i
 file	netinet/ip_ecn.c		ipsec | gif | stf
 file	netinet/ip_encap.c		inet | inet6
 file	netinet/ip_etherip.c		etherip & inet
+file	netinet/wqinput.c		inet | inet6
 file	netinet6/ip6_etherip.c		etherip & inet6
 file	netinet6/in6_gif.c		gif & inet6
 

Index: src/sys/netinet/ip_carp.c
diff -u src/sys/netinet/ip_carp.c:1.83 src/sys/netinet/ip_carp.c:1.84
--- src/sys/netinet/ip_carp.c:1.83	Mon Jan 16 15:44:47 2017
+++ src/sys/netinet/ip_carp.c	Thu Feb  2 02:52:10 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip_carp.c,v 1.83 2017/01/16 15:44:47 christos Exp $	*/
+/*	$NetBSD: ip_carp.c,v 1.84 2017/02/02 02:52:10 ozaki-r Exp $	*/
 /*	$OpenBSD: ip_carp.c,v 1.113 2005/11/04 08:11:54 mcbride Exp $	*/
 
 /*
@@ -33,7 +33,7 @@
 #endif
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ip_carp.c,v 1.83 2017/01/16 15:44:47 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_carp.c,v 1.84 2017/02/02 02:52:10 ozaki-r Exp $");
 
 /*
  * TODO:
@@ -70,6 +70,7 @@ __KERNEL_RCSID(0, "$NetBSD: ip_carp.c,v 
 #include 
 #include 
 #include 
+#include 
 
 #if NFDDI > 0
 #include 
@@ -234,6 +235,14 @@ static void	carp_ether_purgemulti(struct
 
 static void	sysctl_net_inet_carp_setup(struct sysctllog **);
 
+/* workqueue-based pr_input */
+static struct wqinput *carp_wqinput;
+static void _carp_proto_input(struct mbuf *, int, int);
+#ifdef INET6
+static struct wqinput *carp6_wqinput;
+static void _carp6_proto_input(struct mbuf *, int, int);
+#endif
+
 struct if_clone carp_cloner =
 IF_CLONE_INITIALIZER("carp", carp_clone_create, carp_clone_destroy);
 
@@ -468,19 +477,15 @@ carp_setroute(struct carp_softc *sc, int
  * we have rearranged checks order compared to the rfc,
  * but it seems more efficient this way or not possible otherwise.
  */
-void
-carp_proto_input(struct mbuf *m, ...)
+static void
+_carp_proto_input(struct mbuf *m, int hlen, int proto)
 {
 	struct ip *ip = mtod(m, struct ip *);
 	struct carp_softc *sc = NULL;
 	struct carp_header *ch;
 	int iplen, len;
-	va_list ap;
 	struct ifnet *rcvif;
 
-	va_start(ap, m);
-	va_end(ap);
-
 	CARP_STATINC(CARP_STAT_IPACKETS);
 	MCLAIM(m, _proto_mowner_rx);
 
@@ -542,11 +547,17 @@ carp_proto_input(struct mbuf *m, ...)
 	carp_proto_input_c(m, ch, AF_INET);
 }
 
+void
+carp_proto_input(struct mbuf *m, ...)
+{
+
+	wqinput_input(carp_wqinput, m, 0, 0);
+}
+
 #ifdef INET6
-int
-carp6_proto_input(struct mbuf **mp, int *offp, int proto)
+static void
+_carp6_proto_input(struct mbuf *m, int off, int proto)
 {
-	struct mbuf *m = *mp;
 	struct carp_softc *sc = NULL;
 	struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *);
 	struct carp_header *ch;
@@ -558,7 +569,7 @@ carp6_proto_input(struct mbuf **mp, int 
 
 	if (!carp_opts[CARPCTL_ALLOW]) {
 		m_freem(m);
-		return (IPPROTO_DONE);
+		return;
 	}
 
 	rcvif = m_get_rcvif_NOMPSAFE(m);
@@ -569,7 +580,7 @@ carp6_proto_input(struct mbuf **mp, int 
 		CARP_LOG(sc, ("packet received on 

CVS commit: src/external/cddl/osnet/dev/cyclic

2017-02-01 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Wed Feb  1 21:59:09 UTC 2017

Modified Files:
src/external/cddl/osnet/dev/cyclic: cyclic.c

Log Message:
put back the include of dtrace_bsd.h, it actually is needed.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/external/cddl/osnet/dev/cyclic/cyclic.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/cddl/osnet/dev/cyclic/cyclic.c
diff -u src/external/cddl/osnet/dev/cyclic/cyclic.c:1.6 src/external/cddl/osnet/dev/cyclic/cyclic.c:1.7
--- src/external/cddl/osnet/dev/cyclic/cyclic.c:1.6	Wed Feb  1 20:06:21 2017
+++ src/external/cddl/osnet/dev/cyclic/cyclic.c	Wed Feb  1 21:59:09 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: cyclic.c,v 1.6 2017/02/01 20:06:21 chs Exp $	*/
+/*	$NetBSD: cyclic.c,v 1.7 2017/02/01 21:59:09 chs Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -336,6 +336,7 @@
 #include 
 #include 
 #include 
+#include 
 #ifdef __FreeBSD__
 #include 
 #endif



CVS commit: src/external/cddl/osnet/dev/cyclic

2017-02-01 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Wed Feb  1 20:06:21 UTC 2017

Modified Files:
src/external/cddl/osnet/dev/cyclic: cyclic.c

Log Message:
fix this module to depend on the solaris module rather than the dtrace module.
remove an unneeded header.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/external/cddl/osnet/dev/cyclic/cyclic.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/cddl/osnet/dev/cyclic/cyclic.c
diff -u src/external/cddl/osnet/dev/cyclic/cyclic.c:1.5 src/external/cddl/osnet/dev/cyclic/cyclic.c:1.6
--- src/external/cddl/osnet/dev/cyclic/cyclic.c:1.5	Sat Apr  9 14:50:08 2016
+++ src/external/cddl/osnet/dev/cyclic/cyclic.c	Wed Feb  1 20:06:21 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: cyclic.c,v 1.5 2016/04/09 14:50:08 riastradh Exp $	*/
+/*	$NetBSD: cyclic.c,v 1.6 2017/02/01 20:06:21 chs Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -336,7 +336,6 @@
 #include 
 #include 
 #include 
-#include 
 #ifdef __FreeBSD__
 #include 
 #endif
@@ -1466,5 +1465,5 @@ cyclic_modcmd(modcmd_t cmd, void *data)
 	}
 }
 
-MODULE(MODULE_CLASS_MISC, cyclic, "dtrace");
+MODULE(MODULE_CLASS_MISC, cyclic, "solaris");
 #endif



CVS commit: src/external/cddl/osnet/dist/cmd/dtrace

2017-02-01 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Wed Feb  1 20:02:22 UTC 2017

Modified Files:
src/external/cddl/osnet/dist/cmd/dtrace: dtrace.c

Log Message:
add some missing bits from freebsd r211554:
remove the DOODAD from prochandler().
we are now DOODAD-compatible with current freebsd.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/external/cddl/osnet/dist/cmd/dtrace/dtrace.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/cddl/osnet/dist/cmd/dtrace/dtrace.c
diff -u src/external/cddl/osnet/dist/cmd/dtrace/dtrace.c:1.7 src/external/cddl/osnet/dist/cmd/dtrace/dtrace.c:1.8
--- src/external/cddl/osnet/dist/cmd/dtrace/dtrace.c:1.7	Fri Feb  5 10:14:49 2016
+++ src/external/cddl/osnet/dist/cmd/dtrace/dtrace.c	Wed Feb  1 20:02:22 2017
@@ -770,22 +770,30 @@ compile_str(dtrace_cmd_t *dcp)
 }
 
 /*ARGSUSED*/
-static void __dead
+static void
 prochandler(struct ps_prochandle *P, const char *msg, void *arg)
 {
-fatal("DOODAD in function %s, file %s, line %d\n",__FUNCTION__,__FILE__,__LINE__);
-#ifdef DOODAD
+#ifdef illumos
 	const psinfo_t *prp = Ppsinfo(P);
 	int pid = Pstatus(P)->pr_pid;
 	char name[SIG2STR_MAX];
+#else
+	int wstatus = proc_getwstat(P);
+	int pid = proc_getpid(P);
+#endif
 
 	if (msg != NULL) {
 		notice("pid %d: %s\n", pid, msg);
 		return;
 	}
 
+#ifdef illumos
 	switch (Pstate(P)) {
+#else
+	switch (proc_state(P)) {
+#endif
 	case PS_UNDEAD:
+#ifdef illumos
 		/*
 		 * Ideally we would like to always report pr_wstat here, but it
 		 * isn't possible given current /proc semantics.  If we grabbed
@@ -798,9 +806,20 @@ fatal("DOODAD in function %s, file %s, l
 			notice("pid %d terminated by %s\n", pid,
 			proc_signame(WTERMSIG(prp->pr_wstat),
 			name, sizeof (name)));
+#else
+		if (WIFSIGNALED(wstatus)) {
+			notice("pid %d terminated by %d\n", pid,
+			WTERMSIG(wstatus));
+#endif
+#ifdef illumos
 		} else if (prp != NULL && WEXITSTATUS(prp->pr_wstat) != 0) {
 			notice("pid %d exited with status %d\n",
 			pid, WEXITSTATUS(prp->pr_wstat));
+#else
+		} else if (WEXITSTATUS(wstatus) != 0) {
+			notice("pid %d exited with status %d\n",
+			pid, WEXITSTATUS(wstatus));
+#endif
 		} else {
 			notice("pid %d has exited\n", pid);
 		}
@@ -812,7 +831,6 @@ fatal("DOODAD in function %s, file %s, l
 		g_pslive--;
 		break;
 	}
-#endif
 }
 
 /*ARGSUSED*/



CVS commit: src/external/bsd/libproc/dist

2017-02-01 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Wed Feb  1 20:01:40 UTC 2017

Modified Files:
src/external/bsd/libproc/dist: proc_util.c

Log Message:
implement proc_getlwpstatus() for netbsd using PT_GET_SIGINFO.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/bsd/libproc/dist/proc_util.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/bsd/libproc/dist/proc_util.c
diff -u src/external/bsd/libproc/dist/proc_util.c:1.4 src/external/bsd/libproc/dist/proc_util.c:1.5
--- src/external/bsd/libproc/dist/proc_util.c:1.4	Tue Apr 26 14:29:58 2016
+++ src/external/bsd/libproc/dist/proc_util.c	Wed Feb  1 20:01:39 2017
@@ -36,6 +36,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include "_libproc.h"
@@ -216,17 +217,39 @@ proc_getlwpstatus(struct proc_handle *ph
 	struct ptrace_lwpinfo lwpinfo;
 	lwpstatus_t *psp = >lwps;
 	siginfo_t *siginfo;
+	bool have_siginfo, sysentry, sysexit;
 
 	if (phdl == NULL)
 		return (NULL);
-	lwpinfo.pl_lwpid = 1;
+	lwpinfo.pl_lwpid = 0;
 	if (ptrace(PT_LWPINFO, phdl->pid, (void *),
 	sizeof(lwpinfo)) < 0)
 		return (NULL);
+
+#ifdef PL_FLAG_SI
+	have_siginfo = (lwpinfo.pl_flags & PL_FLAG_SI) != 0;
+	sysentry = (lwpinfo.pl_flags & PL_FLAG_SCE) != 0;
+	sysexit = (lwpinfo.pl_flags & PL_FLAG_SCX) != 0;
+#endif
+#ifdef PT_GET_SIGINFO
+	have_siginfo = 1;
+	sysentry = 0;
+	sysexit = 0;
+#endif
+
+	if (lwpinfo.pl_event == PL_EVENT_SIGNAL && have_siginfo) {
 #ifdef PL_FLAG_SI
-	siginfo = _siginfo;
-	if (lwpinfo.pl_event == PL_EVENT_SIGNAL &&
-	(lwpinfo.pl_flags & PL_FLAG_SI) != 0) {
+		siginfo = _siginfo;
+#endif
+#ifdef PT_GET_SIGINFO
+		struct ptrace_siginfo si;
+
+		if (ptrace(PT_GET_SIGINFO, phdl->pid, (void *),
+			   sizeof(si)) < 0)
+			return (NULL);
+
+		siginfo = _siginfo;
+#endif
 		if (siginfo->si_signo == SIGTRAP &&
 		(siginfo->si_code == TRAP_BRKPT ||
 		siginfo->si_code == TRAP_TRACE)) {
@@ -236,12 +259,10 @@ proc_getlwpstatus(struct proc_handle *ph
 			psp->pr_why = PR_SIGNALLED;
 			psp->pr_what = siginfo->si_signo;
 		}
-	} else if (lwpinfo.pl_flags & PL_FLAG_SCE) {
+	} else if (sysentry) {
 		psp->pr_why = PR_SYSENTRY;
-	} else if (lwpinfo.pl_flags & PL_FLAG_SCX) {
+	} else if (sysexit) {
 		psp->pr_why = PR_SYSEXIT;
 	}
-#endif
-
 	return (psp);
 }



CVS commit: src/sys/dev/isa

2017-02-01 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Wed Feb  1 19:10:33 UTC 2017

Modified Files:
src/sys/dev/isa: gus.c

Log Message:
Use boolean logical and operation on booleans, rather than bitwise and.

>From David Binderman in PR kern/51936.


To generate a diff of this commit:
cvs rdiff -u -r1.110 -r1.111 src/sys/dev/isa/gus.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/isa/gus.c
diff -u src/sys/dev/isa/gus.c:1.110 src/sys/dev/isa/gus.c:1.111
--- src/sys/dev/isa/gus.c:1.110	Mon Jul 11 11:31:50 2016
+++ src/sys/dev/isa/gus.c	Wed Feb  1 19:10:33 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: gus.c,v 1.110 2016/07/11 11:31:50 msaitoh Exp $	*/
+/*	$NetBSD: gus.c,v 1.111 2017/02/01 19:10:33 jakllsch Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1999, 2008 The NetBSD Foundation, Inc.
@@ -88,7 +88,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gus.c,v 1.110 2016/07/11 11:31:50 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gus.c,v 1.111 2017/02/01 19:10:33 jakllsch Exp $");
 
 #include 
 #include 
@@ -1027,7 +1027,7 @@ gusattach(device_t parent, device_t self
 	printf(", %dKB memory\n", sc->sc_dsize);
 
 	/* A GUS MAX should always have a CODEC installed */
-	if ((sc->sc_revision >= 10) & !(HAS_CODEC(sc)))
+	if ((sc->sc_revision >= 10) && !(HAS_CODEC(sc)))
 		printf("%s: WARNING: did not attach CODEC on MAX\n",
 		device_xname(sc->sc_dev));
 



CVS commit: src/share/man/man9

2017-02-01 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Wed Feb  1 18:47:24 UTC 2017

Modified Files:
src/share/man/man9: kprintf.9

Log Message:
Add missing entries in the NAME section.

These functions are described in the body of the man page but not
mentioned in the NAME section. Without an entry in the NAME section
apropos(1) doesn't get this man page in the results when queried for
one of those functions.

ok from christos.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/share/man/man9/kprintf.9

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/man9/kprintf.9
diff -u src/share/man/man9/kprintf.9:1.33 src/share/man/man9/kprintf.9:1.34
--- src/share/man/man9/kprintf.9:1.33	Tue Sep 17 19:58:03 2013
+++ src/share/man/man9/kprintf.9	Wed Feb  1 18:47:24 2017
@@ -1,4 +1,4 @@
-.\" $NetBSD: kprintf.9,v 1.33 2013/09/17 19:58:03 wiz Exp $
+.\" $NetBSD: kprintf.9,v 1.34 2017/02/01 18:47:24 abhinav Exp $
 .\"
 .\" Copyright (c) 1998, 2002, 2007, 2011 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,19 +27,37 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd November 21, 2012
+.Dd February 1, 2017
 .Dt KPRINTF 9
 .Os
 .Sh NAME
 .Nm device_printf ,
 .Nm printf ,
+.Nm printf_nolog ,
 .Nm snprintf ,
 .Nm vprintf ,
 .Nm vsnprintf ,
 .Nm uprintf ,
 .Nm ttyprintf ,
+.Nm tprintf_open ,
 .Nm tprintf ,
-.Nm aprint
+.Nm tprintf_close ,
+.Nm aprint_normal ,
+.Nm aprint_naive ,
+.Nm aprint_verbose ,
+.Nm aprint_debug ,
+.Nm aprint_error ,
+.Nm aprint_normal_dev ,
+.Nm aprint_naive_dev ,
+.Nm aprint_verbose_dev ,
+.Nm aprint_debug_dev ,
+.Nm aprint_error_dev ,
+.Nm aprint_normal_ifnet ,
+.Nm aprint_naive_ifnet ,
+.Nm aprint_verbose_ifnet ,
+.Nm aprint_debug_ifnet ,
+.Nm aprint_error_ifnet ,
+.Nm aprint_get_error_count
 .Nd kernel formatted output conversion
 .Sh SYNOPSIS
 .In sys/systm.h



CVS commit: src/usr.bin/make

2017-02-01 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Wed Feb  1 18:39:27 UTC 2017

Modified Files:
src/usr.bin/make: make.1 var.c

Log Message:
Since we are avoiding VAR_INTERNAL, allow the variable :_ stores to
to be specified, also allows for multiple stages of modification to
be stashed.


To generate a diff of this commit:
cvs rdiff -u -r1.265 -r1.266 src/usr.bin/make/make.1
cvs rdiff -u -r1.212 -r1.213 src/usr.bin/make/var.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.bin/make/make.1
diff -u src/usr.bin/make/make.1:1.265 src/usr.bin/make/make.1:1.266
--- src/usr.bin/make/make.1:1.265	Mon Jan 30 02:46:20 2017
+++ src/usr.bin/make/make.1	Wed Feb  1 18:39:27 2017
@@ -1,4 +1,4 @@
-.\"	$NetBSD: make.1,v 1.265 2017/01/30 02:46:20 sjg Exp $
+.\"	$NetBSD: make.1,v 1.266 2017/02/01 18:39:27 sjg Exp $
 .\"
 .\" Copyright (c) 1990, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\"	from: @(#)make.1	8.4 (Berkeley) 3/19/94
 .\"
-.Dd January 29, 2017
+.Dd February 1, 2017
 .Dt MAKE 1
 .Os
 .Sh NAME
@@ -1425,24 +1425,22 @@ For example.
 .Pp
 However a single character variable is often more readable:
 .Dl ${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'${.newline}@}
-.It Cm \&:_
+.It Cm \&:_[=var]
 Save the current variable value in
 .Ql $_
+or the named
+.Va var
 for later reference.
-This
-.Ql $_
-is internal to the variable modifier processing and
-will not conflict with any set in a makefile.
 Example usage:
 .Bd -literal -offset indent
-M_cmpv.units = 1 100 1
+M_cmpv.units = 1 1000 100
 M_cmpv = S,., ,g:_:range:@i@+ $${_:[-$$i]} \&\\
 \\* $${M_cmpv.units:[$$i]}@:S,^,expr 0 ,1:sh
 
 .Dv .if ${VERSION:${M_cmpv}} < ${3.1.12:L:${M_cmpv}}
 
 .Ed
-Here the 
+Here
 .Ql $_
 is used to save the result of the
 .Ql :S

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.212 src/usr.bin/make/var.c:1.213
--- src/usr.bin/make/var.c:1.212	Wed Feb  1 18:00:14 2017
+++ src/usr.bin/make/var.c	Wed Feb  1 18:39:27 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.212 2017/02/01 18:00:14 sjg Exp $	*/
+/*	$NetBSD: var.c,v 1.213 2017/02/01 18:39:27 sjg Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.212 2017/02/01 18:00:14 sjg Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.213 2017/02/01 18:39:27 sjg Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.212 2017/02/01 18:00:14 sjg Exp $");
+__RCSID("$NetBSD: var.c,v 1.213 2017/02/01 18:39:27 sjg Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -2742,11 +2742,24 @@ ApplyModifiers(char *nstr, const char *t
 		break;
 	}
 	case '_':			/* remember current value */
-	if CHARMOD_MATCH(tstr[1]) {
-		Var_Set("_", nstr, ctxt, 0);
+	cp = tstr + 1;	/* make sure it is set */
+	if (STRMOD_MATCHX(tstr, "_", 1)) {
+		if (tstr[1] == '=') {
+		char *np;
+		int n;
+
+		cp++;
+		n = strcspn(cp, ":)}");
+		np = bmake_strndup(cp, n+1);
+		np[n] = '\0';
+		cp = tstr + 2 + n;
+		Var_Set(np, nstr, ctxt, 0);
+		free(np);
+		} else {
+		Var_Set("_", nstr, ctxt, 0);
+		}
 		newStr = nstr;
-		cp = ++tstr;
-		termc = *tstr;
+		termc = *cp;
 		break;
 	}
 	goto default_case;



CVS commit: src/sys/arch/sun68k/stand/libsa

2017-02-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Feb  1 18:24:22 UTC 2017

Modified Files:
src/sys/arch/sun68k/stand/libsa: promdev.c

Log Message:
PR/51935: David Binderman: bad call to printf
- fix debugging printfs in general.
- KNF


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/sun68k/stand/libsa/promdev.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/sun68k/stand/libsa/promdev.c
diff -u src/sys/arch/sun68k/stand/libsa/promdev.c:1.6 src/sys/arch/sun68k/stand/libsa/promdev.c:1.7
--- src/sys/arch/sun68k/stand/libsa/promdev.c:1.6	Wed Nov  6 19:42:42 2013
+++ src/sys/arch/sun68k/stand/libsa/promdev.c	Wed Feb  1 13:24:22 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: promdev.c,v 1.6 2013/11/07 00:42:42 christos Exp $ */
+/*	$NetBSD: promdev.c,v 1.7 2017/02/01 18:24:22 christos Exp $ */
 
 /*
  * Copyright (c) 1995 Gordon W. Ross
@@ -42,6 +42,16 @@
 
 int promdev_inuse;
 
+#ifdef DEBUG_PROM
+# define DPRINTF(fmt, ...) \
+	do { \
+		if (debug) \
+			printf("%s: " fmt "\n", __func__, __VA_ARGS__); \
+	} while (/*CONSTCOND*/0)
+#else
+# define DPRINTF(fmt, ...)
+#endif
+
 /*
  * Note: caller sets the fields:
  *	si->si_boottab
@@ -58,85 +68,67 @@ prom_iopen(struct saioreq *si)
 	int	ctlr, error;
 
 	if (promdev_inuse)
-		return(EMFILE);
+		return EMFILE;
 
 	ops = si->si_boottab;
 	dip = ops->b_devinfo;
 	ctlr = si->si_ctlr;
 
-#ifdef DEBUG_PROM
-	if (debug) {
-		printf("Boot device type: %s\n", ops->b_desc);
-	}
-#endif
+
+	DPRINTF("Boot device type: %s", ops->b_desc);
 
 	if (!_is2) {
 #ifdef DEBUG_PROM
 		if (debug) {
-		printf("d_devbytes=%d\n", dip->d_devbytes);
-		printf("d_dmabytes=%d\n", dip->d_dmabytes);
-		printf("d_localbytes=%d\n", dip->d_localbytes);
-		printf("d_devtype=%d\n", dip->d_devtype);
-		printf("d_maxiobytes=%d\n", dip->d_maxiobytes);
-		printf("d_stdcount=%d\n", dip->d_stdcount);
-		for (i = 0; i < dip->d_stdcount; i++)
-			printf("d_stdaddrs[i]=0x%x\n",
-   i, dip->d_stdaddrs[0]);
-	}
+			printf("d_devbytes=%d\n", dip->d_devbytes);
+			printf("d_dmabytes=%d\n", dip->d_dmabytes);
+			printf("d_localbytes=%d\n", dip->d_localbytes);
+			printf("d_devtype=%d\n", dip->d_devtype);
+			printf("d_maxiobytes=%d\n", dip->d_maxiobytes);
+			printf("d_stdcount=%d\n", dip->d_stdcount);
+			for (int i = 0; i < dip->d_stdcount; i++)
+printf("d_stdaddrs[%d]=%#x\n",
+i, dip->d_stdaddrs[0]);
+		}
 #endif
 
-	if (dip->d_devbytes && dip->d_stdcount) {
-		if (ctlr >= dip->d_stdcount) {
-			putstr("Invalid controller number\n");
-			return(ENXIO);
+		if (dip->d_devbytes && dip->d_stdcount) {
+			if (ctlr >= dip->d_stdcount) {
+putstr("Invalid controller number\n");
+return ENXIO;
+			}
+			si->si_devaddr = dev_mapin(dip->d_devtype,
+			dip->d_stdaddrs[ctlr], dip->d_devbytes);
+			DPRINTF("devaddr=%#x", si->si_devaddr);
 		}
-		si->si_devaddr = dev_mapin(dip->d_devtype,
-			dip->d_stdaddrs[ctlr], dip->d_devbytes);
-#ifdef	DEBUG_PROM
-		if (debug)
-			printf("prom_iopen: devaddr=0x%x\n", si->si_devaddr);
-#endif
-	}
 
-	if (dip->d_dmabytes) {
-		si->si_dmaaddr = dvma_alloc(dip->d_dmabytes);
-#ifdef	DEBUG_PROM
-		if (debug)
-			printf("prom_iopen: dmaaddr=0x%x\n", si->si_dmaaddr);
-#endif
-	}
+		if (dip->d_dmabytes) {
+			si->si_dmaaddr = dvma_alloc(dip->d_dmabytes);
+			DPRINTF("dmaaddr=%#x", si->si_dmaaddr);
+		}
 
-	if (dip->d_localbytes) {
-		si->si_devdata = alloc(dip->d_localbytes);
-#ifdef	DEBUG_PROM
-		if (debug)
-			printf("prom_iopen: devdata=0x%x\n", si->si_devdata);
-#endif
+		if (dip->d_localbytes) {
+			si->si_devdata = alloc(dip->d_localbytes);
+			DPRINTF("devdata=%#x", si->si_devdata);
 		}
 	}
 
 	/* OK, call the PROM device open routine. */
-#ifdef	DEBUG_PROM
-	if (debug)
-		printf("prom_iopen: calling prom open...\n");
-#endif
+	DPRINTF("calling prom open... %p", si);
 	error = (*ops->b_open)(si);
-#ifdef	DEBUG_PROM
-	if (debug)
-		printf("prom_iopen: prom open returned %d\n", error);
-#endif
+	DPRINTF("prom open returned %d", error);
 	if (error != 0) {
-#if 0	/* XXX: printf is too big for bootxx */
-		printf("prom_iopen: \"%s\" error=%d\n",
-			   ops->b_desc, error);
+#if 0		/* XXX: printf is too big for bootxx */
+		printf("%s: \"%s\" error=%d\n", __func__,
+		ops->b_desc, error);
 #else
 		putstr("prom_iopen: prom open failed");
 #endif
-		return (ENXIO);
+		return ENXIO;
 	}
 
 	promdev_inuse++;
-	return (0);
+	return 0;
 }
 
 void 
@@ -149,10 +141,7 @@ prom_iclose(struct saioreq *si)
 
 	ops = si->si_boottab;
 
-#ifdef	DEBUG_PROM
-	if (debug)
-		printf("prom_iclose: calling prom close...\n");
-#endif
+	DPRINTF("calling prom close... %p", si);
 	(*ops->b_close)(si);
 
 	promdev_inuse = 0;



CVS commit: src/usr.bin/make

2017-02-01 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Wed Feb  1 18:00:14 UTC 2017

Modified Files:
src/usr.bin/make: var.c

Log Message:
Just have :_ use current ctxt, avoid need to force VAR_INTERNAL.


To generate a diff of this commit:
cvs rdiff -u -r1.211 -r1.212 src/usr.bin/make/var.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.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.211 src/usr.bin/make/var.c:1.212
--- src/usr.bin/make/var.c:1.211	Tue Jan 31 07:00:59 2017
+++ src/usr.bin/make/var.c	Wed Feb  1 18:00:14 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.211 2017/01/31 07:00:59 sjg Exp $	*/
+/*	$NetBSD: var.c,v 1.212 2017/02/01 18:00:14 sjg Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.211 2017/01/31 07:00:59 sjg Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.212 2017/02/01 18:00:14 sjg Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.211 2017/01/31 07:00:59 sjg Exp $");
+__RCSID("$NetBSD: var.c,v 1.212 2017/02/01 18:00:14 sjg Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -2743,7 +2743,7 @@ ApplyModifiers(char *nstr, const char *t
 	}
 	case '_':			/* remember current value */
 	if CHARMOD_MATCH(tstr[1]) {
-		Var_Set("_", nstr, VAR_INTERNAL, 0);
+		Var_Set("_", nstr, ctxt, 0);
 		newStr = nstr;
 		cp = ++tstr;
 		termc = *tstr;
@@ -3729,7 +3729,6 @@ char *
 Var_Parse(const char *str, GNode *ctxt, int flags,
 	  int *lengthPtr, void **freePtr)
 {
-GNode	   *mctxt;
 const char	   *tstr;	/* Pointer into str */
 Var		   *v;		/* Variable in invocation */
 Boolean 	haveModifier;/* TRUE if have modifiers for the variable */
@@ -3747,12 +3746,6 @@ Var_Parse(const char *str, GNode *ctxt, 
 const char *extramodifiers; /* extra modifiers to apply first */
 char	  name[2];
 
-/*
- * We can safely (and only need to?) use VAR_INTERNAL for modifiers
- * (so correct $_ is found) if ctxt is any of VAR_CMD, VAR_GLOBAL
- * or VAR_INTERNAL, otherwise leave it alone.
- */
-mctxt = (ctxt == VAR_GLOBAL || ctxt == VAR_CMD) ? VAR_INTERNAL : ctxt;
 *freePtr = NULL;
 extramodifiers = NULL;
 dynamic = FALSE;
@@ -3999,7 +3992,7 @@ Var_Parse(const char *str, GNode *ctxt, 
 	extraFree = NULL;
 	if (extramodifiers != NULL) {
 		nstr = ApplyModifiers(nstr, extramodifiers, '(', ')',
-  v, mctxt, flags, , );
+  v, ctxt, flags, , );
 	}
 
 	if (haveModifier) {
@@ -4007,7 +4000,7 @@ Var_Parse(const char *str, GNode *ctxt, 
 		tstr++;
 
 		nstr = ApplyModifiers(nstr, tstr, startc, endc,
-  v, mctxt, flags, , freePtr);
+  v, ctxt, flags, , freePtr);
 		tstr += used;
 		free(extraFree);
 	} else {



CVS commit: src/sys/net

2017-02-01 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed Feb  1 17:58:47 UTC 2017

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

Log Message:
Not sure what we are trying to achieve here, but there are two issues;
error can be printed while it is not initialized, and if m_pulldown fails
m is freed and reused.

Quickly reviewed by christos and martin


To generate a diff of this commit:
cvs rdiff -u -r1.123 -r1.124 src/sys/net/if_pppoe.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_pppoe.c
diff -u src/sys/net/if_pppoe.c:1.123 src/sys/net/if_pppoe.c:1.124
--- src/sys/net/if_pppoe.c:1.123	Tue Dec 27 01:31:06 2016
+++ src/sys/net/if_pppoe.c	Wed Feb  1 17:58:47 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: if_pppoe.c,v 1.123 2016/12/27 01:31:06 christos Exp $ */
+/* $NetBSD: if_pppoe.c,v 1.124 2017/02/01 17:58:47 maxv Exp $ */
 
 /*-
  * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.123 2016/12/27 01:31:06 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.124 2017/02/01 17:58:47 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "pppoe.h"
@@ -621,19 +621,21 @@ pppoe_dispatch_disc_pkt(struct mbuf *m, 
 		case PPPOE_TAG_ACNAME:
 			error = NULL;
 			if (sc != NULL && len > 0) {
-error = malloc(len+1, M_TEMP, M_NOWAIT);
-if (error) {
-	n = m_pulldown(m, off + sizeof(*pt),
-	len, );
-	if (n) {
-		strlcpy(error,
-		mtod(n, char*) + noff,
-		len);
-	}
-	printf("%s: connected to %s\n",
-	devname, error);
+error = malloc(len + 1, M_TEMP, M_NOWAIT);
+if (error == NULL)
+	break;
+
+n = m_pulldown(m, off + sizeof(*pt), len,
+);
+if (!n) {
+	m = NULL;
 	free(error, M_TEMP);
+	goto done;
 }
+
+strlcpy(error, mtod(n, char*) + noff, len + 1);
+printf("%s: connected to %s\n", devname, error);
+free(error, M_TEMP);
 			}
 			break;	/* ignored */
 		case PPPOE_TAG_HUNIQUE: {
@@ -704,12 +706,15 @@ pppoe_dispatch_disc_pkt(struct mbuf *m, 
 		if (err_msg) {
 			error = NULL;
 			if (errortag && len) {
-error = malloc(len+1, M_TEMP, M_NOWAIT);
+error = malloc(len + 1, M_TEMP,
+M_NOWAIT|M_ZERO);
 n = m_pulldown(m, off + sizeof(*pt), len,
 );
-if (n && error) {
-	strlcpy(error, 
-	mtod(n, char *) + noff, len);
+if (!n) {
+	m = NULL;
+} else if (error) {
+	strlcpy(error, mtod(n, char *) + noff,
+	len + 1);
 }
 			}
 			if (error) {



CVS commit: src/lib/libm/man

2017-02-01 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Wed Feb  1 16:06:19 UTC 2017

Modified Files:
src/lib/libm/man: ceil.3

Log Message:
Add comma between two Nm entries in the NAME section.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/lib/libm/man/ceil.3

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

Modified files:

Index: src/lib/libm/man/ceil.3
diff -u src/lib/libm/man/ceil.3:1.20 src/lib/libm/man/ceil.3:1.21
--- src/lib/libm/man/ceil.3:1.20	Tue Nov 12 00:10:29 2013
+++ src/lib/libm/man/ceil.3	Wed Feb  1 16:06:19 2017
@@ -26,7 +26,7 @@
 .\" SUCH DAMAGE.
 .\"
 .\" from: @(#)ceil.3	5.1 (Berkeley) 5/2/91
-.\"	$NetBSD: ceil.3,v 1.20 2013/11/12 00:10:29 joerg Exp $
+.\"	$NetBSD: ceil.3,v 1.21 2017/02/01 16:06:19 abhinav Exp $
 .\"
 .Dd November 12, 2013
 .Dt CEIL 3
@@ -36,7 +36,7 @@
 .Nm ceilf ,
 .Nm ceill ,
 .Nm floor ,
-.Nm floorf
+.Nm floorf ,
 .Nm floorl
 .Nd ceiling and floor
 .Sh LIBRARY



CVS commit: src/lib/libm/man

2017-02-01 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Wed Feb  1 15:57:47 UTC 2017

Modified Files:
src/lib/libm/man: modf.3

Log Message:
Add modff and modfl in the NAME section.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/libm/man/modf.3

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

Modified files:

Index: src/lib/libm/man/modf.3
diff -u src/lib/libm/man/modf.3:1.2 src/lib/libm/man/modf.3:1.3
--- src/lib/libm/man/modf.3:1.2	Tue Mar 15 15:29:19 2016
+++ src/lib/libm/man/modf.3	Wed Feb  1 15:57:47 2017
@@ -1,4 +1,4 @@
-.\"	$NetBSD: modf.3,v 1.2 2016/03/15 15:29:19 nros Exp $
+.\"	$NetBSD: modf.3,v 1.3 2017/02/01 15:57:47 abhinav Exp $
 .\"
 .\" Copyright (c) 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -37,7 +37,9 @@
 .Dt MODF 3
 .Os
 .Sh NAME
-.Nm modf
+.Nm modf ,
+.Nm modff ,
+.Nm modfl
 .Nd extract signed integral and fractional values from floating-point number
 .Sh LIBRARY
 .Lb libm



CVS commit: src/lib/libm/man

2017-02-01 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Wed Feb  1 15:49:02 UTC 2017

Modified Files:
src/lib/libm/man: ieee_test.3

Log Message:
Fix a sentence.
Correct function name in the DESCRIPTION section.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/lib/libm/man/ieee_test.3

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

Modified files:

Index: src/lib/libm/man/ieee_test.3
diff -u src/lib/libm/man/ieee_test.3:1.12 src/lib/libm/man/ieee_test.3:1.13
--- src/lib/libm/man/ieee_test.3:1.12	Tue Sep 13 07:11:43 2011
+++ src/lib/libm/man/ieee_test.3	Wed Feb  1 15:49:02 2017
@@ -26,7 +26,7 @@
 .\" SUCH DAMAGE.
 .\"
 .\" from: @(#)ieee.3	6.4 (Berkeley) 5/6/91
-.\"	$NetBSD: ieee_test.3,v 1.12 2011/09/13 07:11:43 njoly Exp $
+.\"	$NetBSD: ieee_test.3,v 1.13 2017/02/01 15:49:02 abhinav Exp $
 .\"
 .Dd August 3, 2011
 .Dt IEEE_TEST 3
@@ -61,7 +61,7 @@
 .Sh DESCRIPTION
 These functions allow users to test conformance to
 .St -ieee754 .
-Their use is not otherwise recommended.
+Their use is otherwise not recommended.
 .Pp
 .Fn logb x
 returns
@@ -73,7 +73,7 @@ a signed integer converted to double\-pr
 .Fn logb 0
 = -\*(If with a division by zero exception.
 .Pp
-.Fn scalbn x n
+.Fn scalb x n
 returns
 .Fa x Ns \(**(2** Ns Fa n )
 computed by exponent manipulation.



CVS commit: src/lib/libm/man

2017-02-01 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Wed Feb  1 14:51:29 UTC 2017

Modified Files:
src/lib/libm/man: log.3

Log Message:
Also, fix spelling of described.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/lib/libm/man/log.3

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

Modified files:

Index: src/lib/libm/man/log.3
diff -u src/lib/libm/man/log.3:1.4 src/lib/libm/man/log.3:1.5
--- src/lib/libm/man/log.3:1.4	Wed Feb  1 14:42:28 2017
+++ src/lib/libm/man/log.3	Wed Feb  1 14:51:29 2017
@@ -1,4 +1,4 @@
-.\" $NetBSD: log.3,v 1.4 2017/02/01 14:42:28 abhinav Exp $
+.\" $NetBSD: log.3,v 1.5 2017/02/01 14:51:29 abhinav Exp $
 .\"
 .\" Copyright (c) 2011 Jukka Ruohonen 
 .\" All rights reserved.
@@ -91,7 +91,7 @@ functions return the base 2 logarithm.
 .Sh RETURN VALUES
 Upon successful completion, the functions return the logarithm of
 .Fa x
-as descibed above.
+as described above.
 Otherwise the following may occur:
 .Bl -enum -offset indent
 .It



CVS commit: src/lib/libm/man

2017-02-01 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Wed Feb  1 14:46:51 UTC 2017

Modified Files:
src/lib/libm/man: exp.3

Log Message:
Fix sentence.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/lib/libm/man/exp.3

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

Modified files:

Index: src/lib/libm/man/exp.3
diff -u src/lib/libm/man/exp.3:1.30 src/lib/libm/man/exp.3:1.31
--- src/lib/libm/man/exp.3:1.30	Wed Feb  1 14:37:20 2017
+++ src/lib/libm/man/exp.3	Wed Feb  1 14:46:51 2017
@@ -27,7 +27,7 @@
 .\"
 .\" from: @(#)exp.3	6.12 (Berkeley) 7/31/91
 .\" $FreeBSD: src/lib/msun/man/exp.3,v 1.24 2008/01/18 21:43:00 das Exp $
-.\"	$NetBSD: exp.3,v 1.30 2017/02/01 14:37:20 abhinav Exp $
+.\"	$NetBSD: exp.3,v 1.31 2017/02/01 14:46:51 abhinav Exp $
 .\"
 .Dd September 13, 2011
 .Dt EXP 3
@@ -105,7 +105,7 @@ and cause a reserved operand fault on a
 .Sh STANDARDS
 The
 .Fn exp
-functions conform to
+function conforms to
 .St -ansiC .
 The
 .Fn exp2 ,



CVS commit: src/lib/libm/man

2017-02-01 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Wed Feb  1 14:42:28 UTC 2017

Modified Files:
src/lib/libm/man: log.3

Log Message:
Remove comma after last Nm entry.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/libm/man/log.3

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

Modified files:

Index: src/lib/libm/man/log.3
diff -u src/lib/libm/man/log.3:1.3 src/lib/libm/man/log.3:1.4
--- src/lib/libm/man/log.3:1.3	Tue Sep 13 08:51:32 2011
+++ src/lib/libm/man/log.3	Wed Feb  1 14:42:28 2017
@@ -1,4 +1,4 @@
-.\" $NetBSD: log.3,v 1.3 2011/09/13 08:51:32 wiz Exp $
+.\" $NetBSD: log.3,v 1.4 2017/02/01 14:42:28 abhinav Exp $
 .\"
 .\" Copyright (c) 2011 Jukka Ruohonen 
 .\" All rights reserved.
@@ -35,7 +35,7 @@
 .Nm log1p ,
 .Nm log1pf
 .Nm log2 ,
-.Nm log2f ,
+.Nm log2f
 .Nd logarithm functions
 .Sh LIBRARY
 .Lb libm



CVS commit: src/lib/libm/man

2017-02-01 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Wed Feb  1 14:37:20 UTC 2017

Modified Files:
src/lib/libm/man: exp.3

Log Message:
Remove comma after the last Nm entry.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/lib/libm/man/exp.3

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

Modified files:

Index: src/lib/libm/man/exp.3
diff -u src/lib/libm/man/exp.3:1.29 src/lib/libm/man/exp.3:1.30
--- src/lib/libm/man/exp.3:1.29	Tue Nov  6 21:43:37 2012
+++ src/lib/libm/man/exp.3	Wed Feb  1 14:37:20 2017
@@ -27,7 +27,7 @@
 .\"
 .\" from: @(#)exp.3	6.12 (Berkeley) 7/31/91
 .\" $FreeBSD: src/lib/msun/man/exp.3,v 1.24 2008/01/18 21:43:00 das Exp $
-.\"	$NetBSD: exp.3,v 1.29 2012/11/06 21:43:37 dholland Exp $
+.\"	$NetBSD: exp.3,v 1.30 2017/02/01 14:37:20 abhinav Exp $
 .\"
 .Dd September 13, 2011
 .Dt EXP 3
@@ -40,7 +40,7 @@
 .Nm exp2f ,
 .\" .Nm exp2l ,
 .Nm expm1 ,
-.Nm expm1f ,
+.Nm expm1f
 .Nd exponential functions
 .Sh LIBRARY
 .Lb libm



CVS commit: src/sys/arch/atari/vme

2017-02-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Feb  1 14:33:10 UTC 2017

Modified Files:
src/sys/arch/atari/vme: leo.c

Log Message:
PR/51933: David Binderman: Boolean confusion


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/atari/vme/leo.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/atari/vme/leo.c
diff -u src/sys/arch/atari/vme/leo.c:1.21 src/sys/arch/atari/vme/leo.c:1.22
--- src/sys/arch/atari/vme/leo.c:1.21	Fri Jul 25 04:10:32 2014
+++ src/sys/arch/atari/vme/leo.c	Wed Feb  1 09:33:10 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: leo.c,v 1.21 2014/07/25 08:10:32 dholland Exp $	*/
+/*	$NetBSD: leo.c,v 1.22 2017/02/01 14:33:10 christos Exp $	*/
 
 /*-
  * Copyright (c) 1997 maximum entropy 
@@ -47,7 +47,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: leo.c,v 1.21 2014/07/25 08:10:32 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: leo.c,v 1.22 2017/02/01 14:33:10 christos Exp $");
 
 #include 
 #include 
@@ -333,9 +333,9 @@ leo_scroll(struct leo_softc *sc, int scr
 	if ((scroll < 0) || (scroll > 255))
 		return EINVAL;
 bus_space_write_1(sc->sc_iot, sc->sc_ioh, LEO_REG_MSBSCROLL,
-			  (scroll >> 6) && 0xff);
+			  (scroll >> 6) & 0xff);
 bus_space_write_1(sc->sc_iot, sc->sc_ioh, LEO_REG_LSBSCROLL,
-			  (scroll << 2) && 0xff);
+			  (scroll << 2) & 0xff);
 	return 0;
 }
 



CVS commit: src/crypto/external/bsd/openssh/dist

2017-02-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Feb  1 14:27:37 UTC 2017

Modified Files:
src/crypto/external/bsd/openssh/dist: sshd_config

Log Message:
match the man page, and explain why.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/crypto/external/bsd/openssh/dist/sshd_config

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/openssh/dist/sshd_config
diff -u src/crypto/external/bsd/openssh/dist/sshd_config:1.18 src/crypto/external/bsd/openssh/dist/sshd_config:1.19
--- src/crypto/external/bsd/openssh/dist/sshd_config:1.18	Sat Dec 24 19:07:47 2016
+++ src/crypto/external/bsd/openssh/dist/sshd_config	Wed Feb  1 09:27:37 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: sshd_config,v 1.18 2016/12/25 00:07:47 christos Exp $
+#	$NetBSD: sshd_config,v 1.19 2017/02/01 14:27:37 christos Exp $
 #	$OpenBSD: sshd_config,v 1.100 2016/08/15 12:32:04 naddy Exp $
 
 # This is the sshd server system-wide configuration file.  See
@@ -28,7 +28,8 @@
 
 # Authentication:
 
-#LoginGraceTime 2m
+# For slow CPUs, bumped from 2 minutes to 10
+LoginGraceTime 600
 #PermitRootLogin prohibit-password
 #StrictModes yes
 #MaxAuthTries 6



CVS commit: src/distrib/sets/lists/comp

2017-02-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Feb  1 12:33:58 UTC 2017

Modified Files:
src/distrib/sets/lists/comp: mi

Log Message:
Add evbuffer.h.3


To generate a diff of this commit:
cvs rdiff -u -r1.2106 -r1.2107 src/distrib/sets/lists/comp/mi

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/comp/mi
diff -u src/distrib/sets/lists/comp/mi:1.2106 src/distrib/sets/lists/comp/mi:1.2107
--- src/distrib/sets/lists/comp/mi:1.2106	Tue Jan 31 20:23:17 2017
+++ src/distrib/sets/lists/comp/mi	Wed Feb  1 07:33:58 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: mi,v 1.2106 2017/02/01 01:23:17 christos Exp $
+#	$NetBSD: mi,v 1.2107 2017/02/01 12:33:58 christos Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 ./etc/mtree/set.compcomp-sys-root
@@ -6226,6 +6226,7 @@
 ./usr/share/man/cat3/ethers.0			comp-c-catman		.cat
 ./usr/share/man/cat3/evasprintf.0		comp-c-catman		.cat
 ./usr/share/man/cat3/evbuffer.0			comp-c-catman		.cat
+./usr/share/man/cat3/evbuffer.h.0		comp-c-catman		.cat
 ./usr/share/man/cat3/evbuffer_add.0		comp-obsolete		obsolete
 ./usr/share/man/cat3/evbuffer_add_buffer.0	comp-obsolete		obsolete
 ./usr/share/man/cat3/evbuffer_add_printf.0	comp-obsolete		obsolete
@@ -13639,6 +13640,7 @@
 ./usr/share/man/html3/ethers.html		comp-c-htmlman		html
 ./usr/share/man/html3/evasprintf.html		comp-c-htmlman		html
 ./usr/share/man/html3/evbuffer.html		comp-c-htmlman		html
+./usr/share/man/html3/evbuffer.h.html		comp-c-htmlman		html
 ./usr/share/man/html3/evbuffer_add.html		comp-obsolete		obsolete
 ./usr/share/man/html3/evbuffer_add_buffer.html	comp-obsolete		obsolete
 ./usr/share/man/html3/evbuffer_add_printf.html	comp-obsolete		obsolete
@@ -20963,6 +20965,7 @@
 ./usr/share/man/man3/ethers.3			comp-c-man		.man
 ./usr/share/man/man3/evasprintf.3		comp-c-man		.man
 ./usr/share/man/man3/evbuffer.3			comp-c-man		.man
+./usr/share/man/man3/evbuffer.h.3		comp-c-man		.man
 ./usr/share/man/man3/evbuffer_add.3		comp-obsolete		obsolete
 ./usr/share/man/man3/evbuffer_add_buffer.3	comp-obsolete		obsolete
 ./usr/share/man/man3/evbuffer_add_printf.3	comp-obsolete		obsolete



CVS commit: src/external/bsd/libevent/man

2017-02-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Feb  1 12:32:55 UTC 2017

Modified Files:
src/external/bsd/libevent/man: Makefile

Log Message:
now we have evbuffer.h.3 and ebuffer.3 so handle it carefully.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/external/bsd/libevent/man/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/bsd/libevent/man/Makefile
diff -u src/external/bsd/libevent/man/Makefile:1.7 src/external/bsd/libevent/man/Makefile:1.8
--- src/external/bsd/libevent/man/Makefile:1.7	Tue Jan 31 18:49:28 2017
+++ src/external/bsd/libevent/man/Makefile	Wed Feb  1 07:32:54 2017
@@ -1,9 +1,8 @@
-# $NetBSD: Makefile,v 1.7 2017/01/31 23:49:28 christos Exp $
+# $NetBSD: Makefile,v 1.8 2017/02/01 12:32:54 christos Exp $
 
 # Try to undo the doxygen lossage in the man pages.
 
 HSRCS1= \
-buffer.h.3 \
 buffer_compat.h.3 \
 dns.h.3 \
 dns_compat.h.3 \
@@ -43,6 +42,10 @@ ev$i: $i
 		-e 's/^deprecated/evdeprecated/g' < ${.ALLSRC} > ${.TARGET}
 .endfor
 
+evbuffer.h.3: buffer.h.3
+	cp ${.ALLSRC} ${.TARGET}
+HMAN3=evbuffer.h.3
+
 MAN+= \
 bufferevent.3 \
 bufferevent.h.3 \
@@ -60,9 +63,9 @@ evutil_addrinfo.3 \
 evutil_monotonic_timer.3
 
 
-MAN+= ${HMAN1} ${HMAN2} ${MAN1}
+MAN+= ${HMAN1} ${HMAN2} ${HMAN3} ${MAN1}
 
-CLEANFILES+=${HMAN1} ${HMAN2} ${MAN1}
+CLEANFILES+=${HMAN1} ${HMAN2} ${HMAN3} ${MAN1}
 
 USETBL=	yes
 



CVS commit: src/sys/dev/pci/ixgbe

2017-02-01 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Feb  1 10:47:13 UTC 2017

Modified Files:
src/sys/dev/pci/ixgbe: ix_txrx.c ixgbe.c ixgbe.h ixgbe_netbsd.h ixv.c

Log Message:
 TX multiqueue. If you want to disable it, enable IXGBE_LEGACY_TX
in ixgbe_netbsd.h


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/dev/pci/ixgbe/ix_txrx.c
cvs rdiff -u -r1.66 -r1.67 src/sys/dev/pci/ixgbe/ixgbe.c
cvs rdiff -u -r1.21 -r1.22 src/sys/dev/pci/ixgbe/ixgbe.h
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/pci/ixgbe/ixgbe_netbsd.h
cvs rdiff -u -r1.34 -r1.35 src/sys/dev/pci/ixgbe/ixv.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/ixgbe/ix_txrx.c
diff -u src/sys/dev/pci/ixgbe/ix_txrx.c:1.17 src/sys/dev/pci/ixgbe/ix_txrx.c:1.18
--- src/sys/dev/pci/ixgbe/ix_txrx.c:1.17	Mon Jan 30 05:02:43 2017
+++ src/sys/dev/pci/ixgbe/ix_txrx.c	Wed Feb  1 10:47:13 2017
@@ -59,7 +59,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 /*$FreeBSD: head/sys/dev/ixgbe/ix_txrx.c 301538 2016-06-07 04:51:50Z sephe $*/
-/*$NetBSD: ix_txrx.c,v 1.17 2017/01/30 05:02:43 msaitoh Exp $*/
+/*$NetBSD: ix_txrx.c,v 1.18 2017/02/01 10:47:13 msaitoh Exp $*/
 
 #include "opt_inet.h"
 #include "opt_inet6.h"
@@ -126,7 +126,6 @@ static __inline void ixgbe_rx_input(stru
 
 static void	ixgbe_setup_hw_rsc(struct rx_ring *);
 
-#ifdef IXGBE_LEGACY_TX
 /*
  *  Transmit entry point
  *
@@ -204,7 +203,7 @@ ixgbe_start(struct ifnet *ifp)
 	return;
 }
 
-#else /* ! IXGBE_LEGACY_TX */
+#ifndef IXGBE_LEGACY_TX
 
 /*
 ** Multiqueue Transmit Entry Point
@@ -214,7 +213,6 @@ int
 ixgbe_mq_start(struct ifnet *ifp, struct mbuf *m)
 {
 	struct adapter	*adapter = ifp->if_softc;
-	struct ix_queue	*que;
 	struct tx_ring	*txr;
 	int 		i, err = 0;
 #ifdef	RSS
@@ -228,6 +226,7 @@ ixgbe_mq_start(struct ifnet *ifp, struct
 	 * If everything is setup correctly, it should be the
 	 * same bucket that the current CPU we're on is.
 	 */
+#if 0
 #if __FreeBSD_version < 1100054
 	if (m->m_flags & M_FLOWID) {
 #else
@@ -244,26 +243,29 @@ ixgbe_mq_start(struct ifnet *ifp, struct
 "(%d)\n", bucket_id, adapter->num_queues);
 #endif
 		} else
-#endif
+#endif /* RSS */
 			i = m->m_pkthdr.flowid % adapter->num_queues;
 	} else
-		i = curcpu % adapter->num_queues;
+#endif
+		i = cpu_index(curcpu()) % adapter->num_queues;
 
 	/* Check for a hung queue and pick alternative */
 	if (((1 << i) & adapter->active_queues) == 0)
-		i = ffsl(adapter->active_queues);
+		i = ffs64(adapter->active_queues);
 
 	txr = >tx_rings[i];
-	que = >queues[i];
 
-	err = drbr_enqueue(ifp, txr->br, m);
-	if (err)
+	err = pcq_put(txr->txr_interq, m);
+	if (err == false) {
+		m_freem(m);
+		txr->pcq_drops.ev_count++;
 		return (err);
+	}
 	if (IXGBE_TX_TRYLOCK(txr)) {
 		ixgbe_mq_start_locked(ifp, txr);
 		IXGBE_TX_UNLOCK(txr);
 	} else
-		softint_schedule(txr->txq_si);
+		softint_schedule(txr->txr_si);
 
 	return (0);
 }
@@ -280,26 +282,12 @@ ixgbe_mq_start_locked(struct ifnet *ifp,
 		return (ENETDOWN);
 
 	/* Process the queue */
-#if __FreeBSD_version < 901504
-	next = drbr_dequeue(ifp, txr->br);
-	while (next != NULL) {
-		if ((err = ixgbe_xmit(txr, )) != 0) {
-			if (next != NULL)
-err = drbr_enqueue(ifp, txr->br, next);
-#else
-	while ((next = drbr_peek(ifp, txr->br)) != NULL) {
-		if ((err = ixgbe_xmit(txr, )) != 0) {
-			if (next == NULL) {
-drbr_advance(ifp, txr->br);
-			} else {
-drbr_putback(ifp, txr->br, next);
-			}
-#endif
+	while ((next = pcq_get(txr->txr_interq)) != NULL) {
+		if ((err = ixgbe_xmit(txr, next)) != 0) {
+			m_freem(next);
+			/* All errors are counted in ixgbe_xmit() */
 			break;
 		}
-#if __FreeBSD_version >= 901504
-		drbr_advance(ifp, txr->br);
-#endif
 		enqueued++;
 #if 0 // this is VF-only
 #if __FreeBSD_version >= 1100036
@@ -311,14 +299,11 @@ ixgbe_mq_start_locked(struct ifnet *ifp,
 		if (txr->tail < IXGBE_TDT(0) && next->m_flags & M_MCAST)
 			if_inc_counter(ifp, IFCOUNTER_OMCASTS, 1);
 #endif
-#endif
+#endif /* 0 */
 		/* Send a copy of the frame to the BPF listener */
 		bpf_mtap(ifp, next);
 		if ((ifp->if_flags & IFF_RUNNING) == 0)
 			break;
-#if __FreeBSD_version < 901504
-		next = drbr_dequeue(ifp, txr->br);
-#endif
 	}
 
 	if (txr->tx_avail < IXGBE_TX_CLEANUP_THRESHOLD)
@@ -331,36 +316,18 @@ ixgbe_mq_start_locked(struct ifnet *ifp,
  * Called from a taskqueue to drain queued transmit packets.
  */
 void
-ixgbe_deferred_mq_start(void *arg, int pending)
+ixgbe_deferred_mq_start(void *arg)
 {
 	struct tx_ring *txr = arg;
 	struct adapter *adapter = txr->adapter;
 	struct ifnet *ifp = adapter->ifp;
 
 	IXGBE_TX_LOCK(txr);
-	if (!drbr_empty(ifp, txr->br))
+	if (pcq_peek(txr->txr_interq) != NULL)
 		ixgbe_mq_start_locked(ifp, txr);
 	IXGBE_TX_UNLOCK(txr);
 }
 
-/*
- * Flush all ring buffers
- */
-void
-ixgbe_qflush(struct ifnet *ifp)
-{
-	struct adapter	*adapter = 

CVS commit: src/tests/lib/libc/sys

2017-02-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb  1 10:18:28 UTC 2017

Modified Files:
src/tests/lib/libc/sys: Makefile

Log Message:
Restrict special mode/owner settings to truncate_test.root_owned;
otherwise the Atffile will be generated unreadable for group/others
as well.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/tests/lib/libc/sys/Makefile

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

Modified files:

Index: src/tests/lib/libc/sys/Makefile
diff -u src/tests/lib/libc/sys/Makefile:1.47 src/tests/lib/libc/sys/Makefile:1.48
--- src/tests/lib/libc/sys/Makefile:1.47	Sat Jan 14 03:59:58 2017
+++ src/tests/lib/libc/sys/Makefile	Wed Feb  1 10:18:27 2017
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.47 2017/01/14 03:59:58 pgoyette Exp $
+# $NetBSD: Makefile,v 1.48 2017/02/01 10:18:27 martin Exp $
 
 MKMAN=	no
 
@@ -86,10 +86,10 @@ CPPFLAGS.t_lwp_create.c += -D_KERNTYPES
 
 FILES=		truncate_test.root_owned
 FILESBUILD=	yes
-FILESDIR=	${TESTSDIR}
-FILESMODE=	0600
-FILESOWNER=	root
-FILESGRP=	wheel
+FILESDIR_truncate_test.root_owned=	${TESTSDIR}
+FILESMODE_truncate_test.root_owned=	0600
+FILESOWNER_truncate_test.root_owned=	root
+FILESGRP_truncate_test.root_owned=	wheel
 
 CLEANFILES=   truncate_test.root_owned
 truncate_test.root_owned:



CVS commit: src

2017-02-01 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Wed Feb  1 09:26:43 UTC 2017

Modified Files:
src/crypto/external/bsd/netpgp/dist/buildaux: config.guess config.sub
src/crypto/external/cpl/tpm-tools/dist: config.guess config.sub
src/crypto/external/cpl/trousers/dist: config.guess config.sub
src/external/bsd/am-utils/dist: config.guess config.sub
src/external/bsd/bind/dist: config.guess config.sub
src/external/bsd/bind/dist/contrib/dnsperf-2.1.0.0-1: config.guess
config.sub
src/external/bsd/bind/dist/contrib/idn/idnkit-1.0-src: config.guess
config.sub
src/external/bsd/bind/dist/contrib/nslint-3.0a2: config.guess
config.sub
src/external/bsd/bind/dist/unit/atf-src/admin: config.guess config.sub
src/external/bsd/byacc/dist: config.guess config.sub
src/external/bsd/dhcp/dist: config.guess config.sub
src/external/bsd/file/dist: config.guess config.sub
src/external/bsd/flex/dist/build-aux: config.guess config.sub
src/external/bsd/iscsi/dist/buildaux: config.guess config.sub
src/external/bsd/libbind/dist: config.guess config.sub
src/external/bsd/libevent/dist: config.guess config.sub
src/external/bsd/libpcap/dist: config.guess config.sub
src/external/bsd/ntp/dist/sntp/libevent/build-aux: config.guess
config.sub
src/external/bsd/openldap/dist/build: config.guess config.sub
src/external/bsd/openldap/dist/contrib/ldapc++: config.guess config.sub
src/external/bsd/openpam/dist: config.guess config.sub
src/external/bsd/pcc/dist/pcc: config.guess config.sub
src/external/bsd/tcpdump/dist: config.guess config.sub
src/external/bsd/top/dist: config.guess config.sub
src/external/bsd/tre/dist/utils: config.guess config.sub
src/external/bsd/unbound/dist: config.guess config.sub
src/external/gpl2/diffutils/dist/config: config.guess config.sub
src/external/gpl2/gettext/dist/build-aux: config.guess config.sub

src/external/gpl2/gettext/dist/gettext-tools/examples/hello-c++-kde/admin:
config.guess config.sub
src/external/gpl2/gmake/dist/config: config.guess config.sub
src/external/gpl2/grep/dist: config.guess config.sub
src/external/gpl2/lvm2/dist/autoconf: config.guess config.sub
src/external/gpl2/texinfo/dist: config.guess config.sub
src/external/gpl2/xcvs/dist/build-aux: config.guess config.sub
src/external/gpl3/autoconf/dist/build-aux: config.guess config.sub
src/external/gpl3/binutils/dist: config.guess config.sub
src/external/gpl3/gcc/dist: config.guess config.sub
src/external/gpl3/gdb.old/dist: config.guess config.sub
src/external/gpl3/gdb.old/dist/readline/support: config.guess
config.sub
src/external/gpl3/gdb/dist: config.guess config.sub
src/external/gpl3/gdb/dist/readline/support: config.guess config.sub
src/external/lgpl3/gmp/dist: config.guess config.sub
src/external/lgpl3/mpc/dist: config.guess config.sub
src/external/lgpl3/mpfr/dist: config.guess config.sub
src/external/mit/expat/dist/conftools: config.guess config.sub
src/lib/librumpuser/build-aux: config.guess config.sub

Log Message:
Update supporting files for components which rely on autoconf to allow systems
introducing since release of software to be recognised. This should hopefully
allow the builds to progress a littles further on systems such as the POWER8
which features a little endian 64-bit PowerPC CPU identified as ppc64le.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 \
src/crypto/external/bsd/netpgp/dist/buildaux/config.guess \
src/crypto/external/bsd/netpgp/dist/buildaux/config.sub
cvs rdiff -u -r1.1.1.1 -r1.2 \
src/crypto/external/cpl/tpm-tools/dist/config.guess \
src/crypto/external/cpl/tpm-tools/dist/config.sub
cvs rdiff -u -r1.1.1.1 -r1.2 \
src/crypto/external/cpl/trousers/dist/config.guess \
src/crypto/external/cpl/trousers/dist/config.sub
cvs rdiff -u -r1.1.1.3 -r1.2 src/external/bsd/am-utils/dist/config.guess \
src/external/bsd/am-utils/dist/config.sub
cvs rdiff -u -r1.1.1.3 -r1.2 src/external/bsd/bind/dist/config.guess
cvs rdiff -u -r1.1.1.2 -r1.2 src/external/bsd/bind/dist/config.sub
cvs rdiff -u -r1.1.1.1 -r1.2 \
src/external/bsd/bind/dist/contrib/dnsperf-2.1.0.0-1/config.guess \
src/external/bsd/bind/dist/contrib/dnsperf-2.1.0.0-1/config.sub
cvs rdiff -u -r1.1.1.1 -r1.2 \
src/external/bsd/bind/dist/contrib/idn/idnkit-1.0-src/config.guess \
src/external/bsd/bind/dist/contrib/idn/idnkit-1.0-src/config.sub
cvs rdiff -u -r1.1.1.1 -r1.2 \
src/external/bsd/bind/dist/contrib/nslint-3.0a2/config.guess \
src/external/bsd/bind/dist/contrib/nslint-3.0a2/config.sub
cvs rdiff -u -r1.1.1.1 -r1.2 \

CVS commit: src/sys/dev/pci

2017-02-01 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Feb  1 08:56:41 UTC 2017

Modified Files:
src/sys/dev/pci: if_wm.c if_wmvar.h

Log Message:
 Use new wm_gmii_setup_phytype() function to setup sc_phytype and
mii_{read|write}reg. This function is called twie.

 To identify PHY type, correct read/write function should be selected. To
select correct read/write function, PCI ID or MAC type are required without
accessing PHY registers.

 On the first call of this function, PHY ID is not known yet. Check PCI ID or
MAC type. The list of the PCI ID may not be perfect, so the result might be
incorrect.

 In the second call, PHY OUI and model are used to identify PHY type. It might
not be perfpect because of the lack of compared entry, but it would be better
than the first call.

 If the detected new result and previous assumption is different, diagnous
message will be printed.


To generate a diff of this commit:
cvs rdiff -u -r1.474 -r1.475 src/sys/dev/pci/if_wm.c
cvs rdiff -u -r1.32 -r1.33 src/sys/dev/pci/if_wmvar.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/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.474 src/sys/dev/pci/if_wm.c:1.475
--- src/sys/dev/pci/if_wm.c:1.474	Wed Feb  1 07:50:03 2017
+++ src/sys/dev/pci/if_wm.c	Wed Feb  1 08:56:41 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.474 2017/02/01 07:50:03 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.475 2017/02/01 08:56:41 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -84,7 +84,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.474 2017/02/01 07:50:03 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.475 2017/02/01 08:56:41 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -726,6 +726,7 @@ static int	wm_linkintr_msix(void *);
 static void	wm_tbi_serdes_set_linkled(struct wm_softc *);
 /* GMII related */
 static void	wm_gmii_reset(struct wm_softc *);
+static void	wm_gmii_setup_phytype(struct wm_softc *sc, uint32_t, uint16_t);
 static int	wm_get_phy_id_82575(struct wm_softc *);
 static void	wm_gmii_mediainit(struct wm_softc *, pci_product_id_t);
 static int	wm_gmii_mediachange(struct ifnet *);
@@ -8557,6 +8558,251 @@ wm_gmii_reset(struct wm_softc *sc)
 }
 
 /*
+ * Setup sc_phytype and mii_{read|write}reg.
+ *
+ *  To identify PHY type, correct read/write function should be selected.
+ * To select correct read/write function, PCI ID or MAC type are required
+ * without accessing PHY registers.
+ *
+ *  On the first call of this function, PHY ID is not known yet. Check
+ * PCI ID or MAC type. The list of the PCI ID may not be perfect, so the
+ * result might be incorrect.
+ *
+ *  In the second call, PHY OUI and model is used to identify PHY type.
+ * It might not be perfpect because of the lack of compared entry, but it
+ * would be better than the first call.
+ *
+ *  If the detected new result and previous assumption is different,
+ * diagnous message will be printed.
+ */
+static void
+wm_gmii_setup_phytype(struct wm_softc *sc, uint32_t phy_oui,
+uint16_t phy_model)
+{
+	device_t dev = sc->sc_dev;
+	struct mii_data *mii = >sc_mii;
+	uint16_t new_phytype = WMPHY_UNKNOWN;
+	uint16_t doubt_phytype = WMPHY_UNKNOWN;
+	mii_readreg_t new_readreg;
+	mii_writereg_t new_writereg;
+
+	if (mii->mii_readreg == NULL) {
+		/*
+		 *  This is the first call of this function. For ICH and PCH
+		 * variants, it's difficult to determine the PHY access method
+		 * by sc_type, so use the PCI product ID for some devices.
+		 */
+
+		switch (sc->sc_pcidevid) {
+		case PCI_PRODUCT_INTEL_PCH_M_LM:
+		case PCI_PRODUCT_INTEL_PCH_M_LC:
+			/* 82577 */
+			new_phytype = WMPHY_82577;
+			break;
+		case PCI_PRODUCT_INTEL_PCH_D_DM:
+		case PCI_PRODUCT_INTEL_PCH_D_DC:
+			/* 82578 */
+			new_phytype = WMPHY_82578;
+			break;
+		case PCI_PRODUCT_INTEL_PCH2_LV_LM:
+		case PCI_PRODUCT_INTEL_PCH2_LV_V:
+			/* 82579 */
+			new_phytype = WMPHY_82579;
+			break;
+		case PCI_PRODUCT_INTEL_82801H_82567V_3:
+		case PCI_PRODUCT_INTEL_82801I_BM:
+		case PCI_PRODUCT_INTEL_82801I_IGP_M_AMT: /* Not IGP but BM */
+		case PCI_PRODUCT_INTEL_82801J_R_BM_LM:
+		case PCI_PRODUCT_INTEL_82801J_R_BM_LF:
+		case PCI_PRODUCT_INTEL_82801J_D_BM_LM:
+		case PCI_PRODUCT_INTEL_82801J_D_BM_LF:
+		case PCI_PRODUCT_INTEL_82801J_R_BM_V:
+			/* ICH8, 9, 10 with 82567 */
+			new_phytype = WMPHY_BM;
+			break;
+		default:
+			break;
+		}
+	} else {
+		/* It's not the first call. Use PHY OUI and model */
+		switch (phy_oui) {
+		case MII_OUI_ATHEROS: /* XXX ??? */
+			switch (phy_model) {
+			case 0x0004: /* XXX */
+new_phytype = WMPHY_82578;
+break;
+			default:
+break;
+			}
+			break;
+		case MII_OUI_xxMARVELL:
+			switch (phy_model) {
+			case MII_MODEL_xxMARVELL_I210:
+new_phytype = WMPHY_I210;
+break;
+			case MII_MODEL_xxMARVELL_E1011:
+			case MII_MODEL_xxMARVELL_E1000_3:
+			case 

CVS commit: src/sys/net

2017-02-01 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Feb  1 08:18:33 UTC 2017

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

Log Message:
Reduce return points


To generate a diff of this commit:
cvs rdiff -u -r1.211 -r1.212 src/sys/net/bpf.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/bpf.c
diff -u src/sys/net/bpf.c:1.211 src/sys/net/bpf.c:1.212
--- src/sys/net/bpf.c:1.211	Wed Feb  1 08:16:42 2017
+++ src/sys/net/bpf.c	Wed Feb  1 08:18:33 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: bpf.c,v 1.211 2017/02/01 08:16:42 ozaki-r Exp $	*/
+/*	$NetBSD: bpf.c,v 1.212 2017/02/01 08:18:33 ozaki-r Exp $	*/
 
 /*
  * Copyright (c) 1990, 1991, 1993
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.211 2017/02/01 08:16:42 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.212 2017/02/01 08:18:33 ozaki-r Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_bpf.h"
@@ -632,9 +632,8 @@ bpf_read(struct file *fp, off_t *offp, s
 	while (d->bd_hbuf == NULL) {
 		if (fp->f_flag & FNONBLOCK) {
 			if (d->bd_slen == 0) {
-splx(s);
-KERNEL_UNLOCK_ONE(NULL);
-return (EWOULDBLOCK);
+error = EWOULDBLOCK;
+goto out;
 			}
 			ROTATE_BUFFERS(d);
 			break;
@@ -654,11 +653,9 @@ bpf_read(struct file *fp, off_t *offp, s
 		error = cv_timedwait_sig(>bd_cv, d->bd_mtx, d->bd_rtout);
 		mutex_exit(d->bd_mtx);
 
-		if (error == EINTR || error == ERESTART) {
-			splx(s);
-			KERNEL_UNLOCK_ONE(NULL);
-			return (error);
-		}
+		if (error == EINTR || error == ERESTART)
+			goto out;
+
 		if (error == EWOULDBLOCK) {
 			/*
 			 * On a timeout, return what's in the buffer,
@@ -674,15 +671,14 @@ bpf_read(struct file *fp, off_t *offp, s
 break;
 
 			if (d->bd_slen == 0) {
-splx(s);
-KERNEL_UNLOCK_ONE(NULL);
-return (0);
+error = 0;
+goto out;
 			}
 			ROTATE_BUFFERS(d);
 			break;
 		}
 		if (error != 0)
-			goto done;
+			goto out;
 	}
 	/*
 	 * At this point, we know we have something in the hold slot.
@@ -700,7 +696,7 @@ bpf_read(struct file *fp, off_t *offp, s
 	d->bd_fbuf = d->bd_hbuf;
 	d->bd_hbuf = NULL;
 	d->bd_hlen = 0;
-done:
+out:
 	splx(s);
 	KERNEL_UNLOCK_ONE(NULL);
 	return (error);



CVS commit: src/sys/net

2017-02-01 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Feb  1 08:16:42 UTC 2017

Modified Files:
src/sys/net: bpf.c bpfdesc.h

Log Message:
Kill tsleep/wakeup and use cv


To generate a diff of this commit:
cvs rdiff -u -r1.210 -r1.211 src/sys/net/bpf.c
cvs rdiff -u -r1.42 -r1.43 src/sys/net/bpfdesc.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/net/bpf.c
diff -u src/sys/net/bpf.c:1.210 src/sys/net/bpf.c:1.211
--- src/sys/net/bpf.c:1.210	Wed Feb  1 08:15:15 2017
+++ src/sys/net/bpf.c	Wed Feb  1 08:16:42 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: bpf.c,v 1.210 2017/02/01 08:15:15 ozaki-r Exp $	*/
+/*	$NetBSD: bpf.c,v 1.211 2017/02/01 08:16:42 ozaki-r Exp $	*/
 
 /*
  * Copyright (c) 1990, 1991, 1993
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.210 2017/02/01 08:15:15 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.211 2017/02/01 08:16:42 ozaki-r Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_bpf.h"
@@ -523,6 +523,8 @@ bpfopen(dev_t dev, int flag, int mode, s
 	d->bd_jitcode = NULL;
 	BPF_DLIST_ENTRY_INIT(d);
 	BPFIF_DLIST_ENTRY_INIT(d);
+	d->bd_mtx = mutex_obj_alloc(MUTEX_DEFAULT, IPL_NET);
+	cv_init(>bd_cv, "bpf");
 
 	mutex_enter(_mtx);
 	BPF_DLIST_WRITER_INSEART_HEAD(d);
@@ -577,6 +579,9 @@ bpf_close(struct file *fp)
 	callout_destroy(>bd_callout);
 	seldestroy(>bd_sel);
 	softint_disestablish(d->bd_sih);
+	mutex_obj_free(d->bd_mtx);
+	cv_destroy(>bd_cv);
+
 	kmem_free(d, sizeof(*d));
 
 	return (0);
@@ -644,8 +649,11 @@ bpf_read(struct file *fp, off_t *offp, s
 			ROTATE_BUFFERS(d);
 			break;
 		}
-		error = tsleep(d, PRINET|PCATCH, "bpf",
-d->bd_rtout);
+
+		mutex_enter(d->bd_mtx);
+		error = cv_timedwait_sig(>bd_cv, d->bd_mtx, d->bd_rtout);
+		mutex_exit(d->bd_mtx);
+
 		if (error == EINTR || error == ERESTART) {
 			splx(s);
 			KERNEL_UNLOCK_ONE(NULL);
@@ -705,7 +713,11 @@ done:
 static inline void
 bpf_wakeup(struct bpf_d *d)
 {
-	wakeup(d);
+
+	mutex_enter(d->bd_mtx);
+	cv_broadcast(>bd_cv);
+	mutex_exit(d->bd_mtx);
+
 	if (d->bd_async)
 		softint_schedule(d->bd_sih);
 	selnotify(>bd_sel, 0, 0);

Index: src/sys/net/bpfdesc.h
diff -u src/sys/net/bpfdesc.h:1.42 src/sys/net/bpfdesc.h:1.43
--- src/sys/net/bpfdesc.h:1.42	Wed Feb  1 08:13:45 2017
+++ src/sys/net/bpfdesc.h	Wed Feb  1 08:16:42 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: bpfdesc.h,v 1.42 2017/02/01 08:13:45 ozaki-r Exp $	*/
+/*	$NetBSD: bpfdesc.h,v 1.43 2017/02/01 08:16:42 ozaki-r Exp $	*/
 
 /*
  * Copyright (c) 1990, 1991, 1993
@@ -47,6 +47,8 @@
 #include 			/* for bpfjit_function_t */
 #ifdef _KERNEL
 #include 
+#include 
+#include 
 #endif
 
 /*
@@ -111,6 +113,8 @@ struct bpf_d {
 #ifdef _KERNEL
 	struct pslist_entry	bd_bif_dlist_entry; /* For bpf_if */
 	struct pslist_entry	bd_bpf_dlist_entry; /* For the global list */
+	kmutex_t	*bd_mtx;
+	kcondvar_t	bd_cv;
 #endif
 };
 



CVS commit: src/sys/net

2017-02-01 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Feb  1 08:15:15 UTC 2017

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

Log Message:
Make bpf_gstats percpu


To generate a diff of this commit:
cvs rdiff -u -r1.209 -r1.210 src/sys/net/bpf.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/bpf.c
diff -u src/sys/net/bpf.c:1.209 src/sys/net/bpf.c:1.210
--- src/sys/net/bpf.c:1.209	Wed Feb  1 08:13:45 2017
+++ src/sys/net/bpf.c	Wed Feb  1 08:15:15 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: bpf.c,v 1.209 2017/02/01 08:13:45 ozaki-r Exp $	*/
+/*	$NetBSD: bpf.c,v 1.210 2017/02/01 08:15:15 ozaki-r Exp $	*/
 
 /*
  * Copyright (c) 1990, 1991, 1993
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.209 2017/02/01 08:13:45 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.210 2017/02/01 08:15:15 ozaki-r Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_bpf.h"
@@ -76,6 +76,7 @@ __KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.20
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -120,7 +121,15 @@ struct bpfjit_ops bpfjit_module_ops = {
 /*
  * Global BPF statistics returned by net.bpf.stats sysctl.
  */
-static struct bpf_stat	bpf_gstats;
+static struct percpu	*bpf_gstats_percpu; /* struct bpf_stat */
+
+#define BPF_STATINC(id)	\
+	{		\
+		struct bpf_stat *__stats =		\
+		percpu_getref(bpf_gstats_percpu);	\
+		__stats->bs_##id++;			\
+		percpu_putref(bpf_gstats_percpu);	\
+	}
 
 /*
  * Use a mutex to avoid a race condition between gathering the stats/peers
@@ -466,9 +475,7 @@ bpf_init(void)
 	PSLIST_INIT(_iflist);
 	PSLIST_INIT(_dlist);
 
-	bpf_gstats.bs_recv = 0;
-	bpf_gstats.bs_drop = 0;
-	bpf_gstats.bs_capt = 0;
+	bpf_gstats_percpu = percpu_alloc(sizeof(struct bpf_stat));
 
 	return;
 }
@@ -1496,7 +1503,7 @@ bpf_deliver(struct bpf_if *bp, void *(*c
 			continue;
 		}
 		d->bd_rcount++;
-		bpf_gstats.bs_recv++;
+		BPF_STATINC(recv);
 
 		if (d->bd_jitcode)
 			slen = d->bd_jitcode(NULL, );
@@ -1787,7 +1794,7 @@ catchpacket(struct bpf_d *d, u_char *pkt
 	int do_wakeup = 0;
 
 	++d->bd_ccount;
-	++bpf_gstats.bs_capt;
+	BPF_STATINC(capt);
 	/*
 	 * Figure out how many bytes to move.  If the packet is
 	 * greater or equal to the snapshot length, transfer that
@@ -1826,7 +1833,7 @@ catchpacket(struct bpf_d *d, u_char *pkt
 			 * so drop the packet.
 			 */
 			++d->bd_dcount;
-			++bpf_gstats.bs_drop;
+			BPF_STATINC(drop);
 			return;
 		}
 		ROTATE_BUFFERS(d);
@@ -2244,6 +2251,38 @@ sysctl_net_bpf_peers(SYSCTLFN_ARGS)
 	return (error);
 }
 
+static void
+bpf_stats(void *p, void *arg, struct cpu_info *ci __unused)
+{
+	struct bpf_stat *const stats = p;
+	struct bpf_stat *sum = arg;
+
+	sum->bs_recv += stats->bs_recv;
+	sum->bs_drop += stats->bs_drop;
+	sum->bs_capt += stats->bs_capt;
+}
+
+static int
+bpf_sysctl_gstats_handler(SYSCTLFN_ARGS)
+{
+	struct sysctlnode node;
+	int error;
+	struct bpf_stat sum;
+
+	memset(, 0, sizeof(sum));
+	node = *rnode;
+
+	percpu_foreach(bpf_gstats_percpu, bpf_stats, );
+
+	node.sysctl_data = 
+	node.sysctl_size = sizeof(sum);
+	error = sysctl_lookup(SYSCTLFN_CALL());
+	if (error != 0 || newp == NULL)
+		return error;
+
+	return 0;
+}
+
 static struct sysctllog *bpf_sysctllog;
 static void
 sysctl_net_bpf_setup(void)
@@ -2276,7 +2315,7 @@ sysctl_net_bpf_setup(void)
 			CTLFLAG_PERMANENT,
 			CTLTYPE_STRUCT, "stats",
 			SYSCTL_DESCR("BPF stats"),
-			NULL, 0, _gstats, sizeof(bpf_gstats),
+			bpf_sysctl_gstats_handler, 0, NULL, 0,
 			CTL_NET, node->sysctl_num, CTL_CREATE, CTL_EOL);
 		sysctl_createv(_sysctllog, 0, NULL, NULL,
 			CTLFLAG_PERMANENT,



CVS commit: src/sys/net

2017-02-01 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Feb  1 08:13:45 UTC 2017

Modified Files:
src/sys/net: bpf.c bpfdesc.h

Log Message:
Use pslist(9) instead of queue(9) for psz/psref

As usual some member variables of struct bpf_d and bpf_if remain to avoid
breaking kvm(3) users (netstat and fstat).


To generate a diff of this commit:
cvs rdiff -u -r1.208 -r1.209 src/sys/net/bpf.c
cvs rdiff -u -r1.41 -r1.42 src/sys/net/bpfdesc.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/net/bpf.c
diff -u src/sys/net/bpf.c:1.208 src/sys/net/bpf.c:1.209
--- src/sys/net/bpf.c:1.208	Wed Feb  1 08:07:27 2017
+++ src/sys/net/bpf.c	Wed Feb  1 08:13:45 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: bpf.c,v 1.208 2017/02/01 08:07:27 ozaki-r Exp $	*/
+/*	$NetBSD: bpf.c,v 1.209 2017/02/01 08:13:45 ozaki-r Exp $	*/
 
 /*
  * Copyright (c) 1990, 1991, 1993
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.208 2017/02/01 08:07:27 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.209 2017/02/01 08:13:45 ozaki-r Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_bpf.h"
@@ -132,8 +132,60 @@ static kmutex_t bpf_mtx;
  *  bpf_iflist is the list of interfaces; each corresponds to an ifnet
  *  bpf_dtab holds the descriptors, indexed by minor device #
  */
-static struct bpf_if	*bpf_iflist;
-static LIST_HEAD(, bpf_d) bpf_list;
+static struct pslist_head bpf_iflist;
+static struct pslist_head bpf_dlist;
+
+/* Macros for bpf_d on bpf_dlist */
+#define BPF_DLIST_WRITER_INSEART_HEAD(__d)\
+	PSLIST_WRITER_INSERT_HEAD(_dlist, (__d), bd_bpf_dlist_entry)
+#define BPF_DLIST_READER_FOREACH(__d)	\
+	PSLIST_READER_FOREACH((__d), _dlist, struct bpf_d,		\
+	  bd_bpf_dlist_entry)
+#define BPF_DLIST_WRITER_FOREACH(__d)	\
+	PSLIST_WRITER_FOREACH((__d), _dlist, struct bpf_d,		\
+	  bd_bpf_dlist_entry)
+#define BPF_DLIST_ENTRY_INIT(__d)	\
+	PSLIST_ENTRY_INIT((__d), bd_bpf_dlist_entry)
+#define BPF_DLIST_WRITER_REMOVE(__d)	\
+	PSLIST_WRITER_REMOVE((__d), bd_bpf_dlist_entry)
+#define BPF_DLIST_ENTRY_DESTROY(__d)	\
+	PSLIST_ENTRY_DESTROY((__d), bd_bpf_dlist_entry)
+
+/* Macros for bpf_if on bpf_iflist */
+#define BPF_IFLIST_WRITER_INSERT_HEAD(__bp)\
+	PSLIST_WRITER_INSERT_HEAD(_iflist, (__bp), bif_iflist_entry)
+#define BPF_IFLIST_READER_FOREACH(__bp)	\
+	PSLIST_READER_FOREACH((__bp), _iflist, struct bpf_if,	\
+	  bif_iflist_entry)
+#define BPF_IFLIST_WRITER_FOREACH(__bp)	\
+	PSLIST_WRITER_FOREACH((__bp), _iflist, struct bpf_if,	\
+	  bif_iflist_entry)
+#define BPF_IFLIST_WRITER_REMOVE(__bp)	\
+	PSLIST_WRITER_REMOVE((__bp), bif_iflist_entry)
+#define BPF_IFLIST_ENTRY_INIT(__bp)	\
+	PSLIST_ENTRY_INIT((__bp), bif_iflist_entry)
+#define BPF_IFLIST_ENTRY_DESTROY(__bp)	\
+	PSLIST_ENTRY_DESTROY((__bp), bif_iflist_entry)
+
+/* Macros for bpf_d on bpf_if#bif_dlist_pslist */
+#define BPFIF_DLIST_READER_FOREACH(__d, __bp)\
+	PSLIST_READER_FOREACH((__d), &(__bp)->bif_dlist_head, struct bpf_d, \
+	  bd_bif_dlist_entry)
+#define BPFIF_DLIST_WRITER_INSERT_HEAD(__bp, __d)			\
+	PSLIST_WRITER_INSERT_HEAD(&(__bp)->bif_dlist_head, (__d),	\
+	  bd_bif_dlist_entry)
+#define BPFIF_DLIST_WRITER_REMOVE(__d)	\
+	PSLIST_WRITER_REMOVE((__d), bd_bif_dlist_entry)
+#define BPFIF_DLIST_ENTRY_INIT(__d)	\
+	PSLIST_ENTRY_INIT((__d), bd_bif_dlist_entry)
+#define	BPFIF_DLIST_READER_EMPTY(__bp)	\
+	(PSLIST_READER_FIRST(&(__bp)->bif_dlist_head, struct bpf_d,	\
+	 bd_bif_dlist_entry) == NULL)
+#define	BPFIF_DLIST_WRITER_EMPTY(__bp)	\
+	(PSLIST_WRITER_FIRST(&(__bp)->bif_dlist_head, struct bpf_d,	\
+	 bd_bif_dlist_entry) == NULL)
+#define BPFIF_DLIST_ENTRY_DESTROY(__d)	\
+	PSLIST_ENTRY_DESTROY((__d), bd_bif_dlist_entry)
 
 static int	bpf_allocbufs(struct bpf_d *);
 static void	bpf_deliver(struct bpf_if *,
@@ -350,8 +402,7 @@ bpf_attachd(struct bpf_d *d, struct bpf_
 	 * it will divert packets to bpf.
 	 */
 	d->bd_bif = bp;
-	d->bd_next = bp->bif_dlist;
-	bp->bif_dlist = d;
+	BPFIF_DLIST_WRITER_INSERT_HEAD(bp, d);
 
 	*bp->bif_driverp = bp;
 }
@@ -362,7 +413,6 @@ bpf_attachd(struct bpf_d *d, struct bpf_
 static void
 bpf_detachd(struct bpf_d *d)
 {
-	struct bpf_d **p;
 	struct bpf_if *bp;
 
 	KASSERT(mutex_owned(_mtx));
@@ -389,19 +439,21 @@ bpf_detachd(struct bpf_d *d)
 			printf("%s: ifpromisc failed: %d", __func__, error);
 #endif
 	}
+
 	/* Remove d from the interface's descriptor list. */
-	p = >bif_dlist;
-	while (*p != d) {
-		p = &(*p)->bd_next;
-		if (*p == NULL)
-			panic("%s: descriptor not in list", __func__);
-	}
-	*p = (*p)->bd_next;
-	if (bp->bif_dlist == NULL)
+	BPFIF_DLIST_WRITER_REMOVE(d);
+
+	/* TODO pserialize_perform(); */
+	/* TODO psref_target_destroy(); */
+	BPFIF_DLIST_ENTRY_DESTROY(d);
+
+	/* XXX 

CVS commit: src/sys/net

2017-02-01 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Feb  1 08:07:27 UTC 2017

Modified Files:
src/sys/net: bpf.c bpfdesc.h

Log Message:
Use kmem(9) instead of malloc/free


To generate a diff of this commit:
cvs rdiff -u -r1.207 -r1.208 src/sys/net/bpf.c
cvs rdiff -u -r1.40 -r1.41 src/sys/net/bpfdesc.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/net/bpf.c
diff -u src/sys/net/bpf.c:1.207 src/sys/net/bpf.c:1.208
--- src/sys/net/bpf.c:1.207	Wed Feb  1 08:06:01 2017
+++ src/sys/net/bpf.c	Wed Feb  1 08:07:27 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: bpf.c,v 1.207 2017/02/01 08:06:01 ozaki-r Exp $	*/
+/*	$NetBSD: bpf.c,v 1.208 2017/02/01 08:07:27 ozaki-r Exp $	*/
 
 /*
  * Copyright (c) 1990, 1991, 1993
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.207 2017/02/01 08:06:01 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.208 2017/02/01 08:07:27 ozaki-r Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_bpf.h"
@@ -446,7 +446,7 @@ bpfopen(dev_t dev, int flag, int mode, s
 	if ((error = fd_allocfile(, )) != 0)
 		return error;
 
-	d = malloc(sizeof(*d), M_DEVBUF, M_WAITOK|M_ZERO);
+	d = kmem_zalloc(sizeof(*d), KM_SLEEP);
 	d->bd_bufsize = bpf_bufsize;
 	d->bd_seesent = 1;
 	d->bd_feedback = 0;
@@ -511,7 +511,7 @@ bpf_close(struct file *fp)
 	callout_destroy(>bd_callout);
 	seldestroy(>bd_sel);
 	softint_disestablish(d->bd_sih);
-	free(d, M_DEVBUF);
+	kmem_free(d, sizeof(*d));
 
 	return (0);
 }
@@ -840,7 +840,11 @@ bpf_ioctl(struct file *fp, u_long cmd, v
 	 * Set buffer length.
 	 */
 	case BIOCSBLEN:
-		if (d->bd_bif != NULL)
+		/*
+		 * Forbid to change the buffer length if buffers are already
+		 * allocated.
+		 */
+		if (d->bd_bif != NULL || d->bd_sbuf != NULL)
 			error = EINVAL;
 		else {
 			u_int size = *(u_int *)addr;
@@ -1110,7 +1114,7 @@ bpf_setf(struct bpf_d *d, struct bpf_pro
 {
 	struct bpf_insn *fcode, *old;
 	bpfjit_func_t jcode, oldj;
-	size_t flen, size;
+	size_t flen, size = 0, old_size;
 	int s;
 
 	jcode = NULL;
@@ -1126,10 +1130,10 @@ bpf_setf(struct bpf_d *d, struct bpf_pro
 		 * userspace and validate it.
 		 */
 		size = flen * sizeof(*fp->bf_insns);
-		fcode = malloc(size, M_DEVBUF, M_WAITOK);
+		fcode = kmem_alloc(size, KM_SLEEP);
 		if (copyin(fp->bf_insns, fcode, size) != 0 ||
 		!bpf_validate(fcode, (int)flen)) {
-			free(fcode, M_DEVBUF);
+			kmem_free(fcode, size);
 			return EINVAL;
 		}
 		membar_consumer();
@@ -1139,16 +1143,19 @@ bpf_setf(struct bpf_d *d, struct bpf_pro
 		fcode = NULL;
 	}
 
+	old_size = d->bd_filter_size;
+
 	s = splnet();
 	old = d->bd_filter;
 	d->bd_filter = fcode;
+	d->bd_filter_size = size;
 	oldj = d->bd_jitcode;
 	d->bd_jitcode = jcode;
 	reset_d(d);
 	splx(s);
 
 	if (old) {
-		free(old, M_DEVBUF);
+		kmem_free(old, old_size);
 	}
 	if (oldj) {
 		bpf_jit_freecode(oldj);
@@ -1822,12 +1829,12 @@ static int
 bpf_allocbufs(struct bpf_d *d)
 {
 
-	d->bd_fbuf = malloc(d->bd_bufsize, M_DEVBUF, M_NOWAIT);
+	d->bd_fbuf = kmem_alloc(d->bd_bufsize, KM_NOSLEEP);
 	if (!d->bd_fbuf)
 		return (ENOBUFS);
-	d->bd_sbuf = malloc(d->bd_bufsize, M_DEVBUF, M_NOWAIT);
+	d->bd_sbuf = kmem_alloc(d->bd_bufsize, KM_NOSLEEP);
 	if (!d->bd_sbuf) {
-		free(d->bd_fbuf, M_DEVBUF);
+		kmem_free(d->bd_fbuf, d->bd_bufsize);
 		return (ENOBUFS);
 	}
 	d->bd_slen = 0;
@@ -1848,14 +1855,14 @@ bpf_freed(struct bpf_d *d)
 	 * free.
 	 */
 	if (d->bd_sbuf != NULL) {
-		free(d->bd_sbuf, M_DEVBUF);
+		kmem_free(d->bd_sbuf, d->bd_bufsize);
 		if (d->bd_hbuf != NULL)
-			free(d->bd_hbuf, M_DEVBUF);
+			kmem_free(d->bd_hbuf, d->bd_bufsize);
 		if (d->bd_fbuf != NULL)
-			free(d->bd_fbuf, M_DEVBUF);
+			kmem_free(d->bd_fbuf, d->bd_bufsize);
 	}
 	if (d->bd_filter)
-		free(d->bd_filter, M_DEVBUF);
+		kmem_free(d->bd_filter, d->bd_filter_size);
 
 	if (d->bd_jitcode != NULL) {
 		bpf_jit_freecode(d->bd_jitcode);
@@ -1871,7 +1878,7 @@ static void
 _bpfattach(struct ifnet *ifp, u_int dlt, u_int hdrlen, struct bpf_if **driverp)
 {
 	struct bpf_if *bp;
-	bp = malloc(sizeof(*bp), M_DEVBUF, M_DONTWAIT);
+	bp = kmem_alloc(sizeof(*bp), KM_NOSLEEP);
 	if (bp == NULL)
 		panic("bpfattach");
 
@@ -1957,7 +1964,7 @@ _bpfdetach(struct ifnet *ifp)
 splx(s);
 softint_disestablish(bp->bif_si);
 			}
-			free(bp, M_DEVBUF);
+			kmem_free(bp, sizeof(*bp));
 			goto again;
 		}
 	}

Index: src/sys/net/bpfdesc.h
diff -u src/sys/net/bpfdesc.h:1.40 src/sys/net/bpfdesc.h:1.41
--- src/sys/net/bpfdesc.h:1.40	Tue Jan 24 09:05:28 2017
+++ src/sys/net/bpfdesc.h	Wed Feb  1 08:07:27 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: bpfdesc.h,v 1.40 2017/01/24 09:05:28 ozaki-r Exp $	*/
+/*	$NetBSD: bpfdesc.h,v 1.41 2017/02/01 08:07:27 ozaki-r Exp $	*/
 
 /*
  * Copyright (c) 1990, 1991, 1993
@@ -102,6 +102,7 @@ struct bpf_d {
 	int		bd_compat32;	/* 32-bit stream on LP64 system */
 #endif
 	bpfjit_func_t	bd_jitcode;	/* compiled filter program */
+	size_t		bd_filter_size;
 };
 
 



CVS commit: src/sys/net

2017-02-01 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Feb  1 08:06:01 UTC 2017

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

Log Message:
Make global variables static


To generate a diff of this commit:
cvs rdiff -u -r1.206 -r1.207 src/sys/net/bpf.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/bpf.c
diff -u src/sys/net/bpf.c:1.206 src/sys/net/bpf.c:1.207
--- src/sys/net/bpf.c:1.206	Wed Jan 25 01:04:23 2017
+++ src/sys/net/bpf.c	Wed Feb  1 08:06:01 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: bpf.c,v 1.206 2017/01/25 01:04:23 ozaki-r Exp $	*/
+/*	$NetBSD: bpf.c,v 1.207 2017/02/01 08:06:01 ozaki-r Exp $	*/
 
 /*
  * Copyright (c) 1990, 1991, 1993
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.206 2017/01/25 01:04:23 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.207 2017/02/01 08:06:01 ozaki-r Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_bpf.h"
@@ -108,9 +108,9 @@ __KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.20
  * XXX the default values should be computed dynamically based
  * on available memory size and available mbuf clusters.
  */
-int bpf_bufsize = BPF_BUFSIZE;
-int bpf_maxbufsize = BPF_DFLTBUFSIZE;	/* XXX set dynamically, see above */
-bool bpf_jit = false;
+static int bpf_bufsize = BPF_BUFSIZE;
+static int bpf_maxbufsize = BPF_DFLTBUFSIZE;	/* XXX set dynamically, see above */
+static bool bpf_jit = false;
 
 struct bpfjit_ops bpfjit_module_ops = {
 	.bj_generate_code = NULL,
@@ -120,7 +120,7 @@ struct bpfjit_ops bpfjit_module_ops = {
 /*
  * Global BPF statistics returned by net.bpf.stats sysctl.
  */
-struct bpf_stat	bpf_gstats;
+static struct bpf_stat	bpf_gstats;
 
 /*
  * Use a mutex to avoid a race condition between gathering the stats/peers
@@ -132,8 +132,8 @@ static kmutex_t bpf_mtx;
  *  bpf_iflist is the list of interfaces; each corresponds to an ifnet
  *  bpf_dtab holds the descriptors, indexed by minor device #
  */
-struct bpf_if	*bpf_iflist;
-LIST_HEAD(, bpf_d) bpf_list;
+static struct bpf_if	*bpf_iflist;
+static LIST_HEAD(, bpf_d) bpf_list;
 
 static int	bpf_allocbufs(struct bpf_d *);
 static void	bpf_deliver(struct bpf_if *,



CVS commit: src/tests/net/bpf

2017-02-01 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Feb  1 08:04:49 UTC 2017

Modified Files:
src/tests/net/bpf: t_bpf.c

Log Message:
Add a test case for BIOCGBLEN and BIOCSBLEN


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/net/bpf/t_bpf.c

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

Modified files:

Index: src/tests/net/bpf/t_bpf.c
diff -u src/tests/net/bpf/t_bpf.c:1.6 src/tests/net/bpf/t_bpf.c:1.7
--- src/tests/net/bpf/t_bpf.c:1.6	Fri Jan 13 21:30:42 2017
+++ src/tests/net/bpf/t_bpf.c	Wed Feb  1 08:04:49 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_bpf.c,v 1.6 2017/01/13 21:30:42 christos Exp $	*/
+/*	$NetBSD: t_bpf.c,v 1.7 2017/02/01 08:04:49 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 2010 Antti Kantee.  All Rights Reserved.
@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  */
 #include 
-__RCSID("$NetBSD: t_bpf.c,v 1.6 2017/01/13 21:30:42 christos Exp $");
+__RCSID("$NetBSD: t_bpf.c,v 1.7 2017/02/01 08:04:49 ozaki-r Exp $");
 
 #include 
 #include 
@@ -166,6 +166,39 @@ ATF_TC_BODY(bpfwritetrunc, tc)
 }
 #endif /* #if (SIZE_MAX > UINT_MAX) */
 
+ATF_TC(bpf_ioctl_BLEN);
+ATF_TC_HEAD(bpf_ioctl_BLEN, tc)
+{
+
+	atf_tc_set_md_var(tc, "descr", "Checks behaviors of BIOCGBLEN and "
+	"BIOCSBLEN");
+}
+
+ATF_TC_BODY(bpf_ioctl_BLEN, tc)
+{
+	struct ifreq ifr;
+	int ifnum, bpfd;
+	u_int blen = 0;
+
+	RZ(rump_init());
+	RZ(rump_pub_shmif_create(NULL, ));
+	sprintf(ifr.ifr_name, "shmif%d", ifnum);
+
+	RL(bpfd = rump_sys_open("/dev/bpf", O_RDWR));
+
+	RL(rump_sys_ioctl(bpfd, BIOCGBLEN, ));
+	ATF_REQUIRE(blen != 0);
+	blen = 100;
+	RL(rump_sys_ioctl(bpfd, BIOCSBLEN, ));
+	RL(rump_sys_ioctl(bpfd, BIOCGBLEN, ));
+	ATF_REQUIRE_EQ(blen, 100);
+
+	RL(rump_sys_ioctl(bpfd, BIOCSETIF, ));
+
+	ATF_REQUIRE_EQ_MSG(rump_sys_ioctl(bpfd, BIOCSBLEN, ), -1,
+	"Don't allow to change buflen after binding bpf to an interface");
+}
+
 ATF_TP_ADD_TCS(tp)
 {
 
@@ -173,5 +206,6 @@ ATF_TP_ADD_TCS(tp)
 #if (SIZE_MAX > UINT_MAX)
 	ATF_TP_ADD_TC(tp, bpfwritetrunc);
 #endif
+	ATF_TP_ADD_TC(tp, bpf_ioctl_BLEN);
 	return atf_no_error();
 }