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

2016-12-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Dec 28 07:44:26 UTC 2016

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

Log Message:
More MPification


To generate a diff of this commit:
cvs rdiff -u -r1.22.2.16 -r1.22.2.17 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.16 src/sys/dev/usb/if_smsc.c:1.22.2.17
--- src/sys/dev/usb/if_smsc.c:1.22.2.16	Sun Oct 16 11:18:30 2016
+++ src/sys/dev/usb/if_smsc.c	Wed Dec 28 07:44:26 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_smsc.c,v 1.22.2.16 2016/10/16 11:18:30 skrll Exp $	*/
+/*	$NetBSD: if_smsc.c,v 1.22.2.17 2016/12/28 07:44:26 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 $ */
@@ -557,7 +557,6 @@ smsc_init(struct ifnet *ifp)
 	return ret;
 }
 
-
 int
 smsc_init_locked(struct ifnet *ifp)
 {
@@ -581,7 +580,7 @@ smsc_init_locked(struct ifnet *ifp)
 
 	/* Open RX and TX pipes. */
 	err = usbd_open_pipe(sc->sc_iface, sc->sc_ed[SMSC_ENDPT_RX],
-	USBD_EXCLUSIVE_USE, >sc_ep[SMSC_ENDPT_RX]);
+	USBD_EXCLUSIVE_USE | USBD_MPSAFE, >sc_ep[SMSC_ENDPT_RX]);
 	if (err) {
 		printf("%s: open rx pipe failed: %s\n",
 		device_xname(sc->sc_dev), usbd_errstr(err));
@@ -589,7 +588,7 @@ smsc_init_locked(struct ifnet *ifp)
 	}
 
 	err = usbd_open_pipe(sc->sc_iface, sc->sc_ed[SMSC_ENDPT_TX],
-	USBD_EXCLUSIVE_USE, >sc_ep[SMSC_ENDPT_TX]);
+	USBD_EXCLUSIVE_USE | USBD_MPSAFE, >sc_ep[SMSC_ENDPT_TX]);
 	if (err) {
 		printf("%s: open tx pipe failed: %s\n",
 		device_xname(sc->sc_dev), usbd_errstr(err));
@@ -616,6 +615,8 @@ smsc_init_locked(struct ifnet *ifp)
 		usbd_transfer(c->sc_xfer);
 	}
 
+	sc->sc_stopping = false;
+
 	/* Indicate we are up and running. */
 	ifp->if_flags |= IFF_RUNNING;
 	ifp->if_flags &= ~IFF_OACTIVE;
@@ -641,7 +642,8 @@ smsc_start(struct ifnet *ifp)
 	KASSERT(ifp->if_extflags & IFEF_START_MPSAFE);
 
 	mutex_enter(>sc_txlock);
-	smsc_start_locked(ifp);
+	if (!sc->sc_stopping)
+		smsc_start_locked(ifp);
 	mutex_exit(>sc_txlock);
 }
 
@@ -651,6 +653,8 @@ smsc_start_locked(struct ifnet *ifp)
 	struct smsc_softc * const sc = ifp->if_softc;
 	struct mbuf *m_head = NULL;
 
+	KASSERT(mutex_owned(>sc_txlock));
+
 	/* Don't send anything if there is no link or controller is busy. */
 	if ((sc->sc_flags & SMSC_FLAG_LINK) == 0) {
 		return;
@@ -710,6 +714,13 @@ smsc_stop_locked(struct ifnet *ifp, int 
 
 //	smsc_reset(sc);
 
+	KASSERT(mutex_owned(>sc_lock));
+	mutex_enter(>sc_rxlock);
+	mutex_enter(>sc_txlock);
+	sc->sc_stopping = true;
+	mutex_exit(>sc_txlock);
+	mutex_exit(>sc_rxlock);
+
 	callout_stop(>sc_stat_ch);
 
 	/* Stop transfers. */
@@ -1012,6 +1023,7 @@ smsc_attach(device_t parent, device_t se
 
 	sc->sc_dev = self;
 	sc->sc_udev = dev;
+	sc->sc_stopping = false;
 
 	aprint_naive("\n");
 	aprint_normal("\n");
@@ -1285,17 +1297,24 @@ smsc_rxeof(struct usbd_xfer *xfer, void 
 	uint32_t		rxhdr;
 	uint16_t		pktlen;
 	struct mbuf		*m;
-	int			s;
 
-	if (sc->sc_dying)
+	mutex_enter(>sc_rxlock);
+
+	if (sc->sc_dying) {
+		mutex_exit(>sc_rxlock);
 		return;
+	}
 
-	if (!(ifp->if_flags & IFF_RUNNING))
+	if (!(ifp->if_flags & IFF_RUNNING)) {
+		mutex_exit(>sc_rxlock);
 		return;
+	}
 
 	if (status != USBD_NORMAL_COMPLETION) {
-		if (status == USBD_NOT_STARTED || status == USBD_CANCELLED)
+		if (status == USBD_NOT_STARTED || status == USBD_CANCELLED) {
+			mutex_exit(>sc_rxlock);
 			return;
+		}
 		if (usbd_ratecheck(>sc_rx_notice)) {
 			printf("%s: usb errors on rx: %s\n",
 			device_xname(sc->sc_dev), usbd_errstr(status));
@@ -1434,14 +1453,18 @@ smsc_rxeof(struct usbd_xfer *xfer, void 
 		buf += pktlen;
 		total_len -= pktlen;
 
+		mutex_exit(>sc_rxlock);
+
 		/* push the packet up */
-		s = splnet();
 		bpf_mtap(ifp, m);
 		if_percpuq_enqueue(sc->sc_ipq, m);
-		splx(s);
+
+		mutex_enter(>sc_rxlock);
 	}
 
 done:
+	mutex_exit(>sc_rxlock);
+
 	/* Setup new transfer. */
 	usbd_setup_xfer(xfer, c, c->sc_buf, sc->sc_bufsz, USBD_SHORT_XFER_OK,
 	USBD_NO_TIMEOUT, smsc_rxeof);
@@ -1457,17 +1480,24 @@ smsc_txeof(struct usbd_xfer *xfer, void 
 	struct smsc_softc *sc = c->sc_sc;
 	struct ifnet *ifp = >sc_ec.ec_if;
 
-	if (sc->sc_dying)
+	mutex_enter(>sc_txlock);
+
+	if (sc->sc_dying) {
+		mutex_exit(>sc_txlock);
 		return;
+	}
 
-	int s = splnet();
+	if (sc->sc_stopping) {
+		mutex_exit(>sc_txlock);
+		return;
+	}
 
 	ifp->if_timer = 0;
 	ifp->if_flags &= ~IFF_OACTIVE;
 
 	if (status != USBD_NORMAL_COMPLETION) {
 		if (status == USBD_NOT_STARTED || status == USBD_CANCELLED) {
-			splx(s);
+			mutex_exit(>sc_txlock);
 			return;
 		}
 		ifp->if_oerrors++;
@@ -1475,7 +1505,7 @@ smsc_txeof(struct usbd_xfer *xfer, void 
 		usbd_errstr(status));
 		if (status == USBD_STALLED)
 			

CVS commit: src/sys/sys

2016-12-27 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Dec 28 07:34:34 UTC 2016

Modified Files:
src/sys/sys: param.h

Log Message:
Bump for ethercom#ec_lock

Welcome to 7.99.53


To generate a diff of this commit:
cvs rdiff -u -r1.519 -r1.520 src/sys/sys/param.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/sys/param.h
diff -u src/sys/sys/param.h:1.519 src/sys/sys/param.h:1.520
--- src/sys/sys/param.h:1.519	Thu Dec 22 13:42:14 2016
+++ src/sys/sys/param.h	Wed Dec 28 07:34:33 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.519 2016/12/22 13:42:14 mlelstv Exp $	*/
+/*	$NetBSD: param.h,v 1.520 2016/12/28 07:34:33 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -67,7 +67,7 @@
  *	2.99.9		(299000900)
  */
 
-#define	__NetBSD_Version__	799005200	/* NetBSD 7.99.52 */
+#define	__NetBSD_Version__	799005300	/* NetBSD 7.99.53 */
 
 #define __NetBSD_Prereq__(M,m,p) (M) * 1) + \
 (m) * 100) + (p) * 100) <= __NetBSD_Version__)



CVS commit: src/sys

2016-12-27 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Dec 28 07:32:16 UTC 2016

Modified Files:
src/sys/arch/x86/pci: if_vmx.c
src/sys/dev/pci: if_vioif.c if_wm.c
src/sys/net: if_ether.h if_ethersubr.c

Log Message:
Protect ec_multi* with mutex

The data can be accessed from sysctl, ioctl, interface watchdog
(if_slowtimo) and interrupt handlers. We need to protect the data against
parallel accesses from them.

Currently the mutex is applied to some drivers, we need to apply it to all
drivers in the future.

Note that the mutex is adaptive one for ease of implementation but some
drivers access the data in interrupt context so we cannot apply the mutex
to every drivers as is. We have two options: one is to replace the mutex
with a spin one, which requires some additional works (see
ether_multicast_sysctl), and the other is to modify the drivers to access
the data not in interrupt context somehow.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/x86/pci/if_vmx.c
cvs rdiff -u -r1.29 -r1.30 src/sys/dev/pci/if_vioif.c
cvs rdiff -u -r1.459 -r1.460 src/sys/dev/pci/if_wm.c
cvs rdiff -u -r1.65 -r1.66 src/sys/net/if_ether.h
cvs rdiff -u -r1.230 -r1.231 src/sys/net/if_ethersubr.c

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

Modified files:

Index: src/sys/arch/x86/pci/if_vmx.c
diff -u src/sys/arch/x86/pci/if_vmx.c:1.14 src/sys/arch/x86/pci/if_vmx.c:1.15
--- src/sys/arch/x86/pci/if_vmx.c:1.14	Tue Dec 27 03:09:55 2016
+++ src/sys/arch/x86/pci/if_vmx.c	Wed Dec 28 07:32:16 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vmx.c,v 1.14 2016/12/27 03:09:55 hikaru Exp $	*/
+/*	$NetBSD: if_vmx.c,v 1.15 2016/12/28 07:32:16 ozaki-r Exp $	*/
 /*	$OpenBSD: if_vmx.c,v 1.16 2014/01/22 06:04:17 brad Exp $	*/
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.14 2016/12/27 03:09:55 hikaru Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.15 2016/12/28 07:32:16 ozaki-r Exp $");
 
 #include 
 #include 
@@ -2818,9 +2818,11 @@ vmxnet3_set_rxfilter(struct vmxnet3_soft
 		goto allmulti;
 
 	p = sc->vmx_mcast;
+	ETHER_LOCK(ec);
 	ETHER_FIRST_MULTI(step, ec, enm);
 	while (enm != NULL) {
 		if (memcmp(enm->enm_addrlo, enm->enm_addrhi, ETHER_ADDR_LEN)) {
+			ETHER_UNLOCK(ec);
 			/*
 			 * We must listen to a range of multicast addresses.
 			 * For now, just accept all multicasts, rather than
@@ -2837,6 +2839,7 @@ vmxnet3_set_rxfilter(struct vmxnet3_soft
 
 		ETHER_NEXT_MULTI(step, enm);
 	}
+	ETHER_UNLOCK(ec);
 
 	if (ec->ec_multicnt > 0) {
 		SET(mode, VMXNET3_RXMODE_MCAST);

Index: src/sys/dev/pci/if_vioif.c
diff -u src/sys/dev/pci/if_vioif.c:1.29 src/sys/dev/pci/if_vioif.c:1.30
--- src/sys/dev/pci/if_vioif.c:1.29	Thu Dec 15 09:28:05 2016
+++ src/sys/dev/pci/if_vioif.c	Wed Dec 28 07:32:16 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vioif.c,v 1.29 2016/12/15 09:28:05 ozaki-r Exp $	*/
+/*	$NetBSD: if_vioif.c,v 1.30 2016/12/28 07:32:16 ozaki-r Exp $	*/
 
 /*
  * Copyright (c) 2010 Minoura Makoto.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.29 2016/12/15 09:28:05 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.30 2016/12/28 07:32:16 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -1446,6 +1446,7 @@ vioif_rx_filter(struct vioif_softc *sc)
 	}
 
 	nentries = -1;
+	ETHER_LOCK(>sc_ethercom);
 	ETHER_FIRST_MULTI(step, >sc_ethercom, enm);
 	while (nentries++, enm != NULL) {
 		if (nentries >= VIRTIO_NET_CTRL_MAC_MAXENTRIES) {
@@ -1464,6 +1465,8 @@ vioif_rx_filter(struct vioif_softc *sc)
 	rxfilter = 1;
 
 set:
+	ETHER_UNLOCK(>sc_ethercom);
+
 	if (rxfilter) {
 		sc->sc_ctrl_mac_tbl_uc->nentries = 0;
 		sc->sc_ctrl_mac_tbl_mc->nentries = nentries;

Index: src/sys/dev/pci/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.459 src/sys/dev/pci/if_wm.c:1.460
--- src/sys/dev/pci/if_wm.c:1.459	Mon Dec 26 07:55:00 2016
+++ src/sys/dev/pci/if_wm.c	Wed Dec 28 07:32:16 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.459 2016/12/26 07:55:00 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.460 2016/12/28 07:32:16 ozaki-r Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -84,7 +84,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.459 2016/12/26 07:55:00 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.460 2016/12/28 07:32:16 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -3249,9 +3249,11 @@ wm_set_filter(struct wm_softc *sc)
 	for (i = 0; i < size; i++)
 		CSR_WRITE(sc, mta_reg + (i << 2), 0);
 
+	ETHER_LOCK(ec);
 	ETHER_FIRST_MULTI(step, ec, enm);
 	while (enm != NULL) {
 		if (memcmp(enm->enm_addrlo, enm->enm_addrhi, ETHER_ADDR_LEN)) {
+			ETHER_UNLOCK(ec);
 			/*
 			 * We must listen to a range of multicast addresses.
 			 * For now, just accept all multicasts, rather than
@@ -3293,6 +3295,7 @@ wm_set_filter(struct wm_softc *sc)
 
 		ETHER_NEXT_MULTI(step, enm);
 	}
+	ETHER_UNLOCK(ec);
 

CVS commit: src

2016-12-27 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Dec 28 07:26:25 UTC 2016

Modified Files:
src/share/man/man9: ethersubr.9
src/sys/net: if_ethersubr.c
src/sys/netinet: ip_carp.c

Log Message:
Use ether_ifattach in carp_clone_create instead of C code

carp_clone_destroy calls ether_ifdetach so not calling ether_ifattach is
inconsistent. If we add something pair of initialization and destruction
to ether_ifattach and ether_ifdetach (e.g., mutex_init/mutex_destroy),
ether_ifdetach of carp_clone_destroy won't work. So use ether_ifattach.

In order to do so, make ether_ifattach accept the 2nd argument (lla) as
NULL to allow carp to initialize its link level address by itself.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/share/man/man9/ethersubr.9
cvs rdiff -u -r1.229 -r1.230 src/sys/net/if_ethersubr.c
cvs rdiff -u -r1.80 -r1.81 src/sys/netinet/ip_carp.c

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

Modified files:

Index: src/share/man/man9/ethersubr.9
diff -u src/share/man/man9/ethersubr.9:1.25 src/share/man/man9/ethersubr.9:1.26
--- src/share/man/man9/ethersubr.9:1.25	Tue Sep 17 19:58:03 2013
+++ src/share/man/man9/ethersubr.9	Wed Dec 28 07:26:24 2016
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ethersubr.9,v 1.25 2013/09/17 19:58:03 wiz Exp $
+.\"	$NetBSD: ethersubr.9,v 1.26 2016/12/28 07:26:24 ozaki-r Exp $
 .\"
 .\" Copyright (c) 1997 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd March 3, 1997
+.Dd December 28, 2016
 .Dt ETHERSUBR 9
 .Os
 .Sh NAME
@@ -94,6 +94,11 @@ address in the interface's address list 
 pointed to by
 .Fa lla
 there.
+Drivers can initialize the link level address by themselves by calling
+the function with
+.Fa lla
+as NULL and calling
+.Fn if_set_sadl .
 .Pp
 This function must be called from the driver's attach function.
 .It Fn fddi_ifattach "ifp" "lla"

Index: src/sys/net/if_ethersubr.c
diff -u src/sys/net/if_ethersubr.c:1.229 src/sys/net/if_ethersubr.c:1.230
--- src/sys/net/if_ethersubr.c:1.229	Tue Oct 18 07:30:30 2016
+++ src/sys/net/if_ethersubr.c	Wed Dec 28 07:26:24 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_ethersubr.c,v 1.229 2016/10/18 07:30:30 ozaki-r Exp $	*/
+/*	$NetBSD: if_ethersubr.c,v 1.230 2016/12/28 07:26:24 ozaki-r Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.229 2016/10/18 07:30:30 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.230 2016/12/28 07:26:24 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -962,7 +962,8 @@ ether_ifattach(struct ifnet *ifp, const 
 	if (ifp->if_baudrate == 0)
 		ifp->if_baudrate = IF_Mbps(10);		/* just a default */
 
-	if_set_sadl(ifp, lla, ETHER_ADDR_LEN, !ETHER_IS_LOCAL(lla));
+	if (lla != NULL)
+		if_set_sadl(ifp, lla, ETHER_ADDR_LEN, !ETHER_IS_LOCAL(lla));
 
 	LIST_INIT(>ec_multiaddrs);
 	ifp->if_broadcastaddr = etherbroadcastaddr;

Index: src/sys/netinet/ip_carp.c
diff -u src/sys/netinet/ip_carp.c:1.80 src/sys/netinet/ip_carp.c:1.81
--- src/sys/netinet/ip_carp.c:1.80	Mon Dec 12 03:55:57 2016
+++ src/sys/netinet/ip_carp.c	Wed Dec 28 07:26:25 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip_carp.c,v 1.80 2016/12/12 03:55:57 ozaki-r Exp $	*/
+/*	$NetBSD: ip_carp.c,v 1.81 2016/12/28 07:26:25 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.80 2016/12/12 03:55:57 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_carp.c,v 1.81 2016/12/28 07:26:25 ozaki-r Exp $");
 
 /*
  * TODO:
@@ -835,33 +835,17 @@ carp_clone_create(struct if_clone *ifc, 
 	ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
 	ifp->if_ioctl = carp_ioctl;
 	ifp->if_start = carp_start;
-	ifp->if_output = carp_output;
-	ifp->if_type = IFT_CARP;
-	ifp->if_addrlen = ETHER_ADDR_LEN;
-	ifp->if_hdrlen = ETHER_HDR_LEN;
-	ifp->if_mtu = ETHERMTU;
 	IFQ_SET_MAXLEN(>if_snd, ifqmaxlen);
 	IFQ_SET_READY(>if_snd);
-	if_attach(ifp);
-
-	if_alloc_sadl(ifp);
-	ifp->if_broadcastaddr = etherbroadcastaddr;
+	if_initialize(ifp);
+	ether_ifattach(ifp, NULL);
 	carp_set_enaddr(sc);
-	LIST_INIT(>sc_ac.ec_multiaddrs);
-	bpf_attach(ifp, DLT_EN10MB, ETHER_HDR_LEN);
-#ifdef MBUFTRACE
-	strlcpy(sc->sc_ac.ec_tx_mowner.mo_name, ifp->if_xname,
-	sizeof(sc->sc_ac.ec_tx_mowner.mo_name));
-	strlcpy(sc->sc_ac.ec_tx_mowner.mo_descr, "tx",
-	sizeof(sc->sc_ac.ec_tx_mowner.mo_descr));
-	strlcpy(sc->sc_ac.ec_rx_mowner.mo_name, ifp->if_xname,
-	sizeof(sc->sc_ac.ec_rx_mowner.mo_name));
-	strlcpy(sc->sc_ac.ec_rx_mowner.mo_descr, "rx",
-	sizeof(sc->sc_ac.ec_rx_mowner.mo_descr));
-	MOWNER_ATTACH(>sc_ac.ec_tx_mowner);
-	MOWNER_ATTACH(>sc_ac.ec_rx_mowner);
-	ifp->if_mowner = 

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

2016-12-27 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Dec 28 07:05:11 UTC 2016

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

Log Message:
 Allow 0 as the defalut of hw.ixgN.advertise_speed sysctl.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sys/dev/pci/ixgbe/ixgbe.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/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.56 src/sys/dev/pci/ixgbe/ixgbe.c:1.57
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.56	Tue Dec 27 10:01:39 2016
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Wed Dec 28 07:05:11 2016
@@ -59,7 +59,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 /*$FreeBSD: head/sys/dev/ixgbe/if_ix.c 302384 2016-07-07 03:39:18Z sbruno $*/
-/*$NetBSD: ixgbe.c,v 1.56 2016/12/27 10:01:39 msaitoh Exp $*/
+/*$NetBSD: ixgbe.c,v 1.57 2016/12/28 07:05:11 msaitoh Exp $*/
 
 #include "opt_inet.h"
 #include "opt_inet6.h"
@@ -4998,6 +4998,7 @@ ixgbe_set_flowcntl(struct adapter *adapt
 /*
 ** Control advertised link speed:
 **	Flags:
+**	0x0 - Default (all capable link speed)
 **	0x1 - advertise 100 Mb
 **	0x2 - advertise 1G
 **	0x4 - advertise 10G
@@ -5044,26 +5045,26 @@ ixgbe_set_advertise(struct adapter *adap
 		return (EINVAL);
 	}
 
-	if (advertise < 0x1 || advertise > 0x7) {
+	if (advertise < 0x0 || advertise > 0x7) {
 		device_printf(dev,
-		"Invalid advertised speed; valid modes are 0x1 through 0x7\n");
-		return (EINVAL);
-	}
-
-	if ((advertise & 0x1)
-	&& (hw->mac.type != ixgbe_mac_X540)
-	&& (hw->mac.type != ixgbe_mac_X550)) {
-		device_printf(dev, "Set Advertise: 100Mb on X540/X550 only\n");
+		"Invalid advertised speed; valid modes are 0x0 through 0x7\n");
 		return (EINVAL);
 	}
 
 	/* Set new value and report new advertised mode */
 	speed = 0;
-	if (advertise & 0x1)
+	if ((hw->mac.type != ixgbe_mac_X540)
+	&& (hw->mac.type != ixgbe_mac_X550)) {
+		if (advertise & 0x1) {
+			device_printf(dev,
+			"Set Advertise: 100Mb on X540/X550 only\n");
+			return (EINVAL);
+		}
+	} else if ((advertise & 0x1) || (advertise == 0))
 		speed |= IXGBE_LINK_SPEED_100_FULL;
-	if (advertise & 0x2)
+	if ((advertise & 0x2) || (advertise == 0))
 		speed |= IXGBE_LINK_SPEED_1GB_FULL;
-	if (advertise & 0x4)
+	if ((advertise & 0x4) || (advertise == 0))
 		speed |= IXGBE_LINK_SPEED_10GB_FULL;
 	adapter->advertise = advertise;
 



CVS commit: src/sys/dev/pci

2016-12-27 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Dec 28 06:57:27 UTC 2016

Modified Files:
src/sys/dev/pci: pci_subr.c pcireg.h

Log Message:
 The Power Controller Control bit (PCIE_SLCSR_PCC) in the Slot Control & Status
Register is 0 on power on. Print "Power " instead of "".


To generate a diff of this commit:
cvs rdiff -u -r1.155 -r1.156 src/sys/dev/pci/pci_subr.c
cvs rdiff -u -r1.118 -r1.119 src/sys/dev/pci/pcireg.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/pci_subr.c
diff -u src/sys/dev/pci/pci_subr.c:1.155 src/sys/dev/pci/pci_subr.c:1.156
--- src/sys/dev/pci/pci_subr.c:1.155	Wed Nov  2 00:39:56 2016
+++ src/sys/dev/pci/pci_subr.c	Wed Dec 28 06:57:27 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_subr.c,v 1.155 2016/11/02 00:39:56 pgoyette Exp $	*/
+/*	$NetBSD: pci_subr.c,v 1.156 2016/12/28 06:57:27 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 1997 Zubin D. Dittia.  All rights reserved.
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v 1.155 2016/11/02 00:39:56 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v 1.156 2016/12/28 06:57:27 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_pci.h"
@@ -1798,7 +1798,8 @@ pci_conf_print_pcie_cap(const pcireg_t *
 			printf("off\n");
 			break;
 		}
-		onoff("Power Controller Control", reg, PCIE_SLCSR_PCC);
+		printf("  Power Controller Control: Power %s\n",
+		reg & PCIE_SLCSR_PCC ? "off" : "on");
 		onoff("Electromechanical Interlock Control",
 		reg, PCIE_SLCSR_EIC);
 		onoff("Data Link Layer State Changed Enable", reg,

Index: src/sys/dev/pci/pcireg.h
diff -u src/sys/dev/pci/pcireg.h:1.118 src/sys/dev/pci/pcireg.h:1.119
--- src/sys/dev/pci/pcireg.h:1.118	Tue Dec 27 03:51:55 2016
+++ src/sys/dev/pci/pcireg.h	Wed Dec 28 06:57:27 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcireg.h,v 1.118 2016/12/27 03:51:55 msaitoh Exp $	*/
+/*	$NetBSD: pcireg.h,v 1.119 2016/12/28 06:57:27 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 1995, 1996, 1999, 2000
@@ -978,7 +978,10 @@ typedef u_int8_t pci_revision_t;
 #define PCIE_SLCSR_HPE		__BIT(5)   /* Hot Plug Interrupt Enable */
 #define PCIE_SLCSR_AIC		__BITS(7, 6)   /* Attention Indicator Control*/
 #define PCIE_SLCSR_PIC		__BITS(9, 8)   /* Power Indicator Control */
-#define PCIE_SLCSR_PCC		__BIT(10)  /* Power Controller Control */
+#define PCIE_SLCSR_PCC		__BIT(10)  /*
+		* Power Controller Control:
+		* 0: Power on, 1: Power off.
+		*/
 #define PCIE_SLCSR_EIC		__BIT(11)  /* Electromechanical Interlock*/
 #define PCIE_SLCSR_DLLSCE	__BIT(12)  /* DataLinkLayer State Changed*/
 #define PCIE_SLCSR_AUTOSPLDIS	__BIT(13)  /* Auto Slot Power Limit Dis. */
@@ -1779,7 +1782,7 @@ struct pci_rom {
 
 /*
  * Extended capability ID: 0x0014
- * (Reserved for AMD)
+ * Enhanced Allocation
  */
 
 /*



CVS commit: src/sys/kern

2016-12-27 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed Dec 28 06:25:40 UTC 2016

Modified Files:
src/sys/kern: vfs_bio.c

Log Message:
Remove some extraneous whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.266 -r1.267 src/sys/kern/vfs_bio.c

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

Modified files:

Index: src/sys/kern/vfs_bio.c
diff -u src/sys/kern/vfs_bio.c:1.266 src/sys/kern/vfs_bio.c:1.267
--- src/sys/kern/vfs_bio.c:1.266	Tue Dec 27 04:12:34 2016
+++ src/sys/kern/vfs_bio.c	Wed Dec 28 06:25:40 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_bio.c,v 1.266 2016/12/27 04:12:34 pgoyette Exp $	*/
+/*	$NetBSD: vfs_bio.c,v 1.267 2016/12/28 06:25:40 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -123,7 +123,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.266 2016/12/27 04:12:34 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.267 2016/12/28 06:25:40 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_bufcache.h"
@@ -1541,7 +1541,7 @@ biowait(buf_t *bp)
 
 	SDT_PROBE1(io, kernel, , wait__done, bp);
 
-	BIOHIST_LOG(biohist, "  return %d", bp->b_error, 0, 0, 0);
+	BIOHIST_LOG(biohist, "return %d", bp->b_error, 0, 0, 0);
 
 	return bp->b_error;
 }



CVS commit: src/share/man/man4

2016-12-27 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Dec 28 05:03:32 UTC 2016

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

Log Message:
 Add X550.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/share/man/man4/ixg.4

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

Modified files:

Index: src/share/man/man4/ixg.4
diff -u src/share/man/man4/ixg.4:1.8 src/share/man/man4/ixg.4:1.9
--- src/share/man/man4/ixg.4:1.8	Thu Aug 13 05:02:37 2015
+++ src/share/man/man4/ixg.4	Wed Dec 28 05:03:32 2016
@@ -1,4 +1,4 @@
-.\" $NetBSD: ixg.4,v 1.8 2015/08/13 05:02:37 msaitoh Exp $
+.\" $NetBSD: ixg.4,v 1.9 2016/12/28 05:03:32 msaitoh Exp $
 .\"
 .\" Copyright (c) 2001-2008, Intel Corporation
 .\" All rights reserved.
@@ -33,7 +33,7 @@
 .\"
 .\" $FreeBSD: src/share/man/man4/ixgbe.4,v 1.3 2010/12/19 23:54:31 yongari Exp $
 .\"
-.Dd August 13, 2015
+.Dd December 28, 2016
 .Dt IXG 4
 .Os
 .Sh NAME
@@ -45,7 +45,7 @@
 The
 .Nm
 driver provides support for PCI 10Gb Ethernet adapters based on
-the Intel(R) 82598EB, 82599 and X540 Ethernet Controllers.
+the Intel(R) 82598EB, 82599, X540 and X550 Ethernet Controllers.
 The driver supports Jumbo Frames, TCP Segmentation Offload (TSO).
 .Pp
 For questions related to hardware requirements,



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

2016-12-27 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Dec 28 03:49:16 UTC 2016

Modified Files:
src/sys/arch/evbmips/conf: ERLITE

Log Message:
enable a few things that make sense for a router-style box:

BPFJIT, SJIT, bpf, ppp, pppoe, tun, tap, vlan, and bridge.

add a commented out OCTEON_MEMSIZE setting for users who see
that problem.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/evbmips/conf/ERLITE

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/evbmips/conf/ERLITE
diff -u src/sys/arch/evbmips/conf/ERLITE:1.13 src/sys/arch/evbmips/conf/ERLITE:1.14
--- src/sys/arch/evbmips/conf/ERLITE:1.13	Thu Sep 22 08:09:40 2016
+++ src/sys/arch/evbmips/conf/ERLITE	Wed Dec 28 03:49:16 2016
@@ -1,14 +1,18 @@
-#	$NetBSD: ERLITE,v 1.13 2016/09/22 08:09:40 roy Exp $
+#	$NetBSD: ERLITE,v 1.14 2016/12/28 03:49:16 mrg Exp $
 
 include 	"arch/mips/conf/std.octeon"
 include 	"arch/evbmips/conf/files.octeon"
 
 #options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident 		"ERLITE-$Revision: 1.13 $"
+#ident 		"ERLITE-$Revision: 1.14 $"
 
 maxusers	32
 
+# XXX UVM freelists vs 4GB issue.  Enable this if you see hangs
+# waiting for memory when there are actual free pages around.
+#options 	OCTEON_MEMSIZE="(256*1024*1024)"
+
 # Options for necessary to use MD
 #options 	MEMORY_DISK_HOOKS
 #options 	MEMORY_DISK_IS_ROOT	# force root on memory disk
@@ -98,6 +102,8 @@ options 	INET6		# IPV6
 #options 	PPP_DEFLATE	# Deflate compression support for PPP
 #options 	PPP_FILTER	# Active filter support for PPP (requires bpf)
 #options 	IPFILTER_LOG	# ipmon(8) log support
+options 	BPFJIT
+options 	SLJIT
 
 # Compatibility with 4.2BSD implementation of TCP/IP.  Not recommended.
 #options 	TCP_COMPAT_42
@@ -158,19 +164,21 @@ ukphy*		at mii? phy ?		# generic unknown
 # Network pseudo-devices
 pseudo-device	bpfilter			# Berkeley packet filter
 #pseudo-device	ipfilter			# IP filter (firewall) and NAT
+pseudo-device	npf# NPF packet filter
 pseudo-device	loop# network loopback
-#pseudo-device	ppp# Point-to-Point Protocol
+pseudo-device	ppp# Point-to-Point Protocol
+pseudo-device	pppoe# Point-to-Point Protocol over Ethernet
 #pseudo-device	sl# Serial Line IP
 #pseudo-device	strip# Starmode Radio IP (Metricom)
-#pseudo-device	tun# network tunneling over tty
-#pseudo-device	tap# virtual Ethernet
+pseudo-device	tun# network tunneling over tty
+pseudo-device	tap# virtual Ethernet
 #pseudo-device	gre# generic L3 over IP tunnel
 #pseudo-device	ipip# RFC 2003 IP Encapsulation
 #pseudo-device	gif# RFC1933 tunnel
 #pseudo-device	faith# IPv[46] tcp relay translation
 #pseudo-device	stf# 6to4 IPv6 over IPv4 encapsulation
-#pseudo-device	vlan# IEEE 802.1q encapsulation
-#pseudo-device	bridge# simple inter-network bridging
+pseudo-device	vlan# IEEE 802.1q encapsulation
+pseudo-device	bridge# simple inter-network bridging
 
 # Miscellaneous pseudo-devices
 pseudo-device	pty# pseudo-terminals



CVS commit: src/sys/arch/evbmips

2016-12-27 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Dec 28 03:27:08 UTC 2016

Modified Files:
src/sys/arch/evbmips/cavium: machdep.c
src/sys/arch/evbmips/conf: files.octeon

Log Message:
add an OCTEON_MEMSIZE option to override the uboot provided memory
size.  limiting this to 256 avoids an annoying uvm freelist problem on
the 512mb erlite, partly described here:

http://mail-index.netbsd.org/tech-kern/2016/12/20/msg021358.html


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/evbmips/cavium/machdep.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/evbmips/conf/files.octeon

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/evbmips/cavium/machdep.c
diff -u src/sys/arch/evbmips/cavium/machdep.c:1.9 src/sys/arch/evbmips/cavium/machdep.c:1.10
--- src/sys/arch/evbmips/cavium/machdep.c:1.9	Thu Dec 22 14:47:56 2016
+++ src/sys/arch/evbmips/cavium/machdep.c	Wed Dec 28 03:27:08 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.9 2016/12/22 14:47:56 cherry Exp $	*/
+/*	$NetBSD: machdep.c,v 1.10 2016/12/28 03:27:08 mrg Exp $	*/
 
 /*
  * Copyright 2001, 2002 Wasabi Systems, Inc.
@@ -112,9 +112,10 @@
  */
 
 #include "opt_multiprocessor.h"
+#include "opt_cavium.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.9 2016/12/22 14:47:56 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.10 2016/12/28 03:27:08 mrg Exp $");
 
 #include 
 #include 
@@ -203,7 +204,11 @@ mach_init(uint64_t arg0, uint64_t arg1, 
 	sizeof(octeon_btinfo));
 
 	corefreq = octeon_btinfo.obt_eclock_hz;
+#ifdef OCTEON_MEMSIZE // avoid uvm issue
+	memsize = OCTEON_MEMSIZE;
+#else
 	memsize = octeon_btinfo.obt_dram_size * 1024 * 1024;
+#endif
 
 	octeon_cal_timer(corefreq);
 

Index: src/sys/arch/evbmips/conf/files.octeon
diff -u src/sys/arch/evbmips/conf/files.octeon:1.5 src/sys/arch/evbmips/conf/files.octeon:1.6
--- src/sys/arch/evbmips/conf/files.octeon:1.5	Fri Dec  9 10:30:48 2016
+++ src/sys/arch/evbmips/conf/files.octeon	Wed Dec 28 03:27:08 2016
@@ -1,4 +1,4 @@
-#	$NetBSD: files.octeon,v 1.5 2016/12/09 10:30:48 roy Exp $
+#	$NetBSD: files.octeon,v 1.6 2016/12/28 03:27:08 mrg Exp $
 
 file	arch/evbmips/cavium/autoconf.c
 file	arch/evbmips/cavium/machdep.c
@@ -18,3 +18,6 @@ include	"external/bsd/sljit/conf/files.s
 
 # Memory Disk
 file	dev/md_root.cmemory_disk_hooks
+
+# workaround Cavium 50x0 problem vs uvm freelists
+defparam opt_cavium.h		OCTEON_MEMSIZE



CVS commit: src/usr.sbin/npf/npfd

2016-12-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Dec 28 03:02:54 UTC 2016

Modified Files:
src/usr.sbin/npf/npfd: npfd.c npfd_log.c

Log Message:
starts running


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/npf/npfd/npfd.c \
src/usr.sbin/npf/npfd/npfd_log.c

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

Modified files:

Index: src/usr.sbin/npf/npfd/npfd.c
diff -u src/usr.sbin/npf/npfd/npfd.c:1.2 src/usr.sbin/npf/npfd/npfd.c:1.3
--- src/usr.sbin/npf/npfd/npfd.c:1.2	Tue Dec 27 20:25:48 2016
+++ src/usr.sbin/npf/npfd/npfd.c	Tue Dec 27 22:02:54 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: npfd.c,v 1.2 2016/12/28 01:25:48 christos Exp $	*/
+/*	$NetBSD: npfd.c,v 1.3 2016/12/28 03:02:54 christos Exp $	*/
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: npfd.c,v 1.2 2016/12/28 01:25:48 christos Exp $");
+__RCSID("$NetBSD: npfd.c,v 1.3 2016/12/28 03:02:54 christos Exp $");
 
 #include 
 #include 
@@ -76,6 +76,8 @@ npfd_event_loop(void)
 	npfd_log_t *log;
 
 	log = npfd_log_create(0);
+	if (log == NULL)
+		exit(EXIT_FAILURE);
 	pfd.fd = npfd_log_getsock(log);
 	pfd.events = POLLHUP | POLLIN;
 
@@ -105,7 +107,6 @@ npfd_event_loop(void)
 }
 
 static void
-/*###114 [cc] error: 'sighandler' defined but not used [-Werror=unused-function]%%%*/
 sighandler(int sig)
 {
 	switch (sig) {
Index: src/usr.sbin/npf/npfd/npfd_log.c
diff -u src/usr.sbin/npf/npfd/npfd_log.c:1.2 src/usr.sbin/npf/npfd/npfd_log.c:1.3
--- src/usr.sbin/npf/npfd/npfd_log.c:1.2	Tue Dec 27 20:25:48 2016
+++ src/usr.sbin/npf/npfd/npfd_log.c	Tue Dec 27 22:02:54 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: npfd_log.c,v 1.2 2016/12/28 01:25:48 christos Exp $	*/
+/*	$NetBSD: npfd_log.c,v 1.3 2016/12/28 03:02:54 christos Exp $	*/
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: npfd_log.c,v 1.2 2016/12/28 01:25:48 christos Exp $");
+__RCSID("$NetBSD: npfd_log.c,v 1.3 2016/12/28 03:02:54 christos Exp $");
 
 #include 
 #include 
@@ -40,6 +40,7 @@ __RCSID("$NetBSD: npfd_log.c,v 1.2 2016/
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -80,6 +81,11 @@ npfd_log_create(unsigned if_idx)
 
 	pcap_set_snaplen(ctx->pcap, 10240);
 
+	if (pcap_activate(ctx->pcap) == -1) {
+		syslog(LOG_ERR, "pcap_activate failed: %s",
+		pcap_geterr(ctx->pcap));
+		goto err;
+	}
 	snprintf(ctx->path, sizeof(ctx->path), "%s/%s%s",
 	NPFD_LOG_PATH, ctx->ifname, ".pcap");
 
@@ -100,9 +106,12 @@ npfd_log_reopen(npfd_log_t *ctx)
 	/*
 	 * Open a log file to write for a given interface and dump there.
 	 */
-	ctx->dumper = pcap_dump_open_append(ctx->pcap, ctx->path);
+	if (access(ctx->path, F_OK) == 0)
+		ctx->dumper = pcap_dump_open_append(ctx->pcap, ctx->path);
+	else
+		ctx->dumper = pcap_dump_open(ctx->pcap, ctx->path);
 	if (ctx->dumper == NULL) {
-		syslog(LOG_ERR, "pcap_dump_open_append failed for `%s': %s",
+		syslog(LOG_ERR, "pcap_dump_open failed for `%s': %s",
 		ctx->path, pcap_geterr(ctx->pcap));
 		return false;
 	}



CVS commit: src/sys/dev

2016-12-27 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Wed Dec 28 02:44:59 UTC 2016

Modified Files:
src/sys/dev: audio.c audiovar.h

Log Message:
Audio device won't fail if one cannot set the common/hw format.

Audio won't be able to be opened though unless a common format is
configured properly.

This would alow the user to change the common format via sysctls
until hardware is configured.

Simplification of several functions.


To generate a diff of this commit:
cvs rdiff -u -r1.287 -r1.288 src/sys/dev/audio.c
cvs rdiff -u -r1.47 -r1.48 src/sys/dev/audiovar.h

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

Modified files:

Index: src/sys/dev/audio.c
diff -u src/sys/dev/audio.c:1.287 src/sys/dev/audio.c:1.288
--- src/sys/dev/audio.c:1.287	Sun Dec 25 22:44:24 2016
+++ src/sys/dev/audio.c	Wed Dec 28 02:44:59 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.287 2016/12/25 22:44:24 nat Exp $	*/
+/*	$NetBSD: audio.c,v 1.288 2016/12/28 02:44:59 nat Exp $	*/
 
 /*-
  * Copyright (c) 2016 Nathanial Sloss 
@@ -148,7 +148,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.287 2016/12/25 22:44:24 nat Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.288 2016/12/28 02:44:59 nat Exp $");
 
 #include "audio.h"
 #if NAUDIO > 0
@@ -196,18 +196,6 @@ int	audiodebug = AUDIO_DEBUG;
 #define SPECIFIED(x)	(x != ~0)
 #define SPECIFIED_CH(x)	(x != (u_char)~0)
 
-#define VAUDIO_NFORMATS	1
-static const struct audio_format vaudio_formats[VAUDIO_NFORMATS] = {
-	{ NULL, AUMODE_PLAY | AUMODE_RECORD,
-#if BYTE_ORDER == LITTLE_ENDIAN
-	 AUDIO_ENCODING_SLINEAR_LE,
-#else
-	 AUDIO_ENCODING_SLINEAR_BE,
-#endif
-	 16, 16, 2, AUFMT_STEREO, 1, { 44100 }
-	 }
-};
-
 /* #define AUDIO_PM_IDLE */
 #ifdef AUDIO_PM_IDLE
 int	audio_idle_timeout = 30;
@@ -415,19 +403,6 @@ const struct cdevsw audio_cdevsw = {
 	.d_flag = D_MCLOSE | D_MPSAFE
 };
 
-/* The default vchan mode: 44.1 kHz stereo signed linear */
-struct audio_params vchan_default = {
-	.sample_rate = 44100,
-#if BYTE_ORDER == LITTLE_ENDIAN
-	.encoding = AUDIO_ENCODING_SLINEAR_LE,
-#else
-	.encoding = AUDIO_ENCODING_SLINEAR_BE,
-#endif
-	.precision = 16,
-	.validbits = 16,
-	.channels = 2,
-};
-
 /* The default audio mode: 8 kHz mono mu-law */
 const struct audio_params audio_default = {
 	.sample_rate = 8000,
@@ -477,6 +452,31 @@ audioattach(device_t parent, device_t se
 	sc->sc_opens = 0;
 	sc->sc_recopens = 0;
 	sc->sc_aivalid = false;
+ 	sc->sc_ready = true;
+
+ 	sc->sc_format[0].mode = AUMODE_PLAY | AUMODE_RECORD;
+ 	sc->sc_format[0].encoding =
+#if BYTE_ORDER == LITTLE_ENDIAN
+		 AUDIO_ENCODING_SLINEAR_LE;
+#else
+		 AUDIO_ENCODING_SLINEAR_BE;
+#endif
+ 	sc->sc_format[0].precision = 16;
+ 	sc->sc_format[0].validbits = 16;
+ 	sc->sc_format[0].channels = 2;
+ 	sc->sc_format[0].channel_mask = AUFMT_STEREO;
+ 	sc->sc_format[0].frequency_type = 1;
+ 	sc->sc_format[0].frequency[0] = 44100;
+
+	sc->sc_vchan_params.sample_rate = 44100;
+#if BYTE_ORDER == LITTLE_ENDIAN
+	sc->sc_vchan_params.encoding = AUDIO_ENCODING_SLINEAR_LE;
+#else
+	sc->sc_vchan_params.encoding = AUDIO_ENCODING_SLINEAR_BE;
+#endif
+	sc->sc_vchan_params.precision = 16;
+	sc->sc_vchan_params.validbits = 16;
+	sc->sc_vchan_params.channels = 2;
 
 	sc->sc_trigger_started = false;
 	sc->sc_rec_started = false;
@@ -497,7 +497,7 @@ audioattach(device_t parent, device_t se
 	sc->sc_precision = 16;
 	sc->sc_channels = 2;
 
-	if (auconv_create_encodings(vaudio_formats, VAUDIO_NFORMATS,
+	if (auconv_create_encodings(sc->sc_format, VAUDIO_NFORMATS,
 	>sc_encodings) != 0) {
 		aprint_error_dev(self, "couldn't create encodings\n");
 		return;
@@ -608,13 +608,11 @@ bad_rec:
 	sc->sc_saturate = true;
 
 	error = audio_set_vchan_defaults(sc, AUMODE_PLAY | AUMODE_PLAY_ALL |
-	AUMODE_RECORD, _formats[0], 0);
+	AUMODE_RECORD, >sc_format[0], 0);
 	mutex_exit(sc->sc_lock);
 	if (error != 0) {
 		aprint_error_dev(sc->sc_dev, "%s: audio_set_vchan_defaults() "
 		"failed\n", __func__);
-		sc->hw_if = NULL;
-		return;
 	}
 
 	sc->sc_pr.blksize = sc->sc_vchan[0]->sc_mpr.blksize;
@@ -1872,7 +1870,7 @@ audio_open(dev_t dev, struct audio_softc
 
 	KASSERT(mutex_owned(sc->sc_lock));
 
-	if (sc->sc_opens >= VAUDIOCHANS)
+	if (sc->sc_ready == false || sc->sc_opens >= VAUDIOCHANS)
 		return ENXIO;
 
 	for (n = 1; n < VAUDIOCHANS; n++) {
@@ -3810,15 +3808,23 @@ audio_set_vchan_defaults(struct audio_so
 {
 	struct virtual_channel *vc = sc->sc_vchan[n];
 	struct audio_info ai;
-	bool reset;
-	int i, error;
+	int error;
 
 	KASSERT(mutex_owned(sc->sc_lock));
 
-	reset = false;
+	sc->sc_vchan_params.sample_rate = sc->sc_iffreq;
+#if BYTE_ORDER == LITTLE_ENDIAN
+	sc->sc_vchan_params.encoding = AUDIO_ENCODING_SLINEAR_LE;
+#else
+	sc->sc_vchan_params.encoding = AUDIO_ENCODING_SLINEAR_BE;
+#endif
+	sc->sc_vchan_params.precision = sc->sc_precision;
+	sc->sc_vchan_params.validbits = sc->sc_precision;
+	sc->sc_vchan_params.channels = 

CVS commit: src/usr.sbin/npf/npfd

2016-12-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Dec 28 01:25:48 UTC 2016

Modified Files:
src/usr.sbin/npf/npfd: Makefile npfd.c npfd.h npfd_log.c

Log Message:
Add some flesh.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/npf/npfd/Makefile \
src/usr.sbin/npf/npfd/npfd.c src/usr.sbin/npf/npfd/npfd.h \
src/usr.sbin/npf/npfd/npfd_log.c

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

Modified files:

Index: src/usr.sbin/npf/npfd/Makefile
diff -u src/usr.sbin/npf/npfd/Makefile:1.1 src/usr.sbin/npf/npfd/Makefile:1.2
--- src/usr.sbin/npf/npfd/Makefile:1.1	Tue Dec 27 17:20:00 2016
+++ src/usr.sbin/npf/npfd/Makefile	Tue Dec 27 20:25:48 2016
@@ -1,11 +1,12 @@
-# $NetBSD: Makefile,v 1.1 2016/12/27 22:20:00 rmind Exp $
+# $NetBSD: Makefile,v 1.2 2016/12/28 01:25:48 christos Exp $
 #
 # Public Domain
 #
 
+NOMAN=
 PROG=		npfd
 
-SRCS=		npfd.c
+SRCS=		npfd.c npfd_log.c
 CPPFLAGS+=	-I${.CURDIR}
 
 LDADD+=		-lnpf -lpcap
Index: src/usr.sbin/npf/npfd/npfd.c
diff -u src/usr.sbin/npf/npfd/npfd.c:1.1 src/usr.sbin/npf/npfd/npfd.c:1.2
--- src/usr.sbin/npf/npfd/npfd.c:1.1	Tue Dec 27 17:20:00 2016
+++ src/usr.sbin/npf/npfd/npfd.c	Tue Dec 27 20:25:48 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: npfd.c,v 1.1 2016/12/27 22:20:00 rmind Exp $	*/
+/*	$NetBSD: npfd.c,v 1.2 2016/12/28 01:25:48 christos Exp $	*/
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -30,21 +30,29 @@
  */
 
 #include 
-__RCSID("$NetBSD: npfd.c,v 1.1 2016/12/27 22:20:00 rmind Exp $");
+__RCSID("$NetBSD: npfd.c,v 1.2 2016/12/28 01:25:48 christos Exp $");
 
 #include 
+#include 
+#include 
 #include 
+#include 
 #include 
+#include 
+#include 
+#include 
 #include 
 
+#include 
+
 #include "npfd.h"
 
-static volatile sig_atomic_t	hup = false;
+static volatile sig_atomic_t hup, stats, done;
 
-int
+static int
 npfd_getctl(void)
 {
-	int fd;
+	int fd, ver;
 
 	fd = open(NPF_DEV_PATH, O_RDONLY);
 	if (fd == -1) {
@@ -55,7 +63,7 @@ npfd_getctl(void)
 	}
 	if (ver != NPF_VERSION) {
 		errx(EXIT_FAILURE,
-		"incompatible NPF interface version (%d, kernel %d)\n"
+		"Incompatible NPF interface version (%d, kernel %d)\n"
 		"Hint: update userland?", NPF_VERSION, ver);
 	}
 	return fd;
@@ -64,38 +72,57 @@ npfd_getctl(void)
 static void
 npfd_event_loop(void)
 {
-	int fds[8], fd, nfds = 0, maxfd = 0;
-	fd_set rfds;
+	struct pollfd pfd;
+	npfd_log_t *log;
 
-	FD_ZERO();
+	log = npfd_log_create(0);
+	pfd.fd = npfd_log_getsock(log);
+	pfd.events = POLLHUP | POLLIN;
 
-	fd = npfd_log_create(0)
-	fds[nfds++] = fd;
-	FD_SET(fd, );
-
-	for (int i = 0; i < nfds; i++) {
-		maxfd = MAX(maxfd, fds[i] + 1);
-	}
-
-	while (!done) {
-		if ((ret = select(maxfd, , NULL, NULL, NULL)) == -1) {
-			syslog(LOG_ERR, "select failed: %m");
-			err(EXIT_FAILURE, "select");
-		}
+	while  (!done) {
 		if (hup) {
 			hup = false;
+			npfd_log_reopen(log);
 		}
-
-		for (fd = 0; fd < maxfd; fd++) {
-			// TODO
+		if (stats) {
+			stats = false;
+			npfd_log_stats(log);
 		}
+		switch (poll(, 1, 1000)) {
+		case -1:
+			if (errno == EINTR)
+continue;
+			syslog(LOG_ERR, "poll failed: %m");
+			exit(EXIT_FAILURE);
+		case 0:
+			continue;
+		default:
+			npfd_log(log);
+		}
+
 	}
+	npfd_log_destroy(log);
 }
 
 static void
-sighup_handler(int sig)
+/*###114 [cc] error: 'sighandler' defined but not used [-Werror=unused-function]%%%*/
+sighandler(int sig)
 {
-	hup = true;
+	switch (sig) {
+	case SIGHUP:
+		hup = true;
+		break;
+	case SIGTERM:
+	case SIGINT:
+		hup = true;
+		break;
+	case SIGINFO:
+	case SIGQUIT:
+		stats = true;
+		break;
+	default:
+		syslog(LOG_ERR, "Unhandled signal %d", sig);
+	}
 }
 
 int
@@ -110,16 +137,22 @@ main(int argc, char **argv)
 			daemon_off = true;
 			break;
 		default:
-			errx(EXIT_FAILURE, "usage:\n\t%s [ -d ]", argv[0]);
+			fprintf(stderr, "Usage: %s [-d]\n", getprogname());
+			exit(EXIT_FAILURE);
 		}
 	}
+	int fd = npfd_getctl();
+	(void)close(fd);
 
-	openlog(argv[0], LOG_PID | LOG_NDELAY | LOG_CONS, LOG_DAEMON);
 	if (!daemon_off && daemon(0, 0) == -1) {
-		syslog(LOG_ERR, "daemon failed: %m");
 		err(EXIT_FAILURE, "daemon");
 	}
-	signal(SIGHUP, sighup_handler);
+	openlog(argv[0], LOG_PID | LOG_NDELAY | LOG_CONS, LOG_DAEMON);
+	signal(SIGHUP, sighandler);
+	signal(SIGINT, sighandler);
+	signal(SIGTERM, sighandler);
+	signal(SIGINFO, sighandler);
+	signal(SIGQUIT, sighandler);
 	npfd_event_loop();
 	closelog();
 
Index: src/usr.sbin/npf/npfd/npfd.h
diff -u src/usr.sbin/npf/npfd/npfd.h:1.1 src/usr.sbin/npf/npfd/npfd.h:1.2
--- src/usr.sbin/npf/npfd/npfd.h:1.1	Tue Dec 27 17:20:00 2016
+++ src/usr.sbin/npf/npfd/npfd.h	Tue Dec 27 20:25:48 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: npfd.h,v 1.1 2016/12/27 22:20:00 rmind Exp $	*/
+/*	$NetBSD: npfd.h,v 1.2 2016/12/28 01:25:48 christos Exp $	*/
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -34,6 +34,7 @@
 
 #define	PCAP_NPACKETS		1024
 #define	NPFD_LOG_PATH		"/var/log"

CVS commit: src/usr.sbin/npf/npfctl

2016-12-27 Thread Mindaugas Rasiukevicius
Module Name:src
Committed By:   rmind
Date:   Tue Dec 27 22:35:33 UTC 2016

Modified Files:
src/usr.sbin/npf/npfctl: npf.conf.5 npf_bpf_comp.c npf_build.c
npf_data.c npf_parse.y npf_scan.l npfctl.h

Log Message:
npf.conf: add support for logical NOT, e.g.: pass from ! 10.0.0.1 to any


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/usr.sbin/npf/npfctl/npf.conf.5
cvs rdiff -u -r1.9 -r1.10 src/usr.sbin/npf/npfctl/npf_bpf_comp.c
cvs rdiff -u -r1.41 -r1.42 src/usr.sbin/npf/npfctl/npf_build.c \
src/usr.sbin/npf/npfctl/npfctl.h
cvs rdiff -u -r1.26 -r1.27 src/usr.sbin/npf/npfctl/npf_data.c
cvs rdiff -u -r1.38 -r1.39 src/usr.sbin/npf/npfctl/npf_parse.y
cvs rdiff -u -r1.23 -r1.24 src/usr.sbin/npf/npfctl/npf_scan.l

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

Modified files:

Index: src/usr.sbin/npf/npfctl/npf.conf.5
diff -u src/usr.sbin/npf/npfctl/npf.conf.5:1.44 src/usr.sbin/npf/npfctl/npf.conf.5:1.45
--- src/usr.sbin/npf/npfctl/npf.conf.5:1.44	Sun Feb  1 22:57:21 2015
+++ src/usr.sbin/npf/npfctl/npf.conf.5	Tue Dec 27 22:35:33 2016
@@ -1,4 +1,4 @@
-.\"$NetBSD: npf.conf.5,v 1.44 2015/02/01 22:57:21 rmind Exp $
+.\"$NetBSD: npf.conf.5,v 1.45 2016/12/27 22:35:33 rmind Exp $
 .\"
 .\" Copyright (c) 2009-2015 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd February 1, 2015
+.Dd December 28, 2016
 .Dt NPF.CONF 5
 .Os
 .Sh NAME
@@ -295,7 +295,8 @@ proto-opts	= "flags" tcp-flags [ "/" tcp
 
 addr-mask	= addr [ "/" mask ]
 filt-opts	= "from" filt-addr [ port-opts ] "to" filt-addr [ port-opts ]
-filt-addr	= [ interface | var-name | addr-mask | table-id | "any" ]
+filt-addr	= [ "!" ] [ interface | var-name |
+  addr-mask | table-id | "any" ]
 filt-port	= "port" ( port-num | port-from "-" port-to | var-name )
 .Ed
 .\" -

Index: src/usr.sbin/npf/npfctl/npf_bpf_comp.c
diff -u src/usr.sbin/npf/npfctl/npf_bpf_comp.c:1.9 src/usr.sbin/npf/npfctl/npf_bpf_comp.c:1.10
--- src/usr.sbin/npf/npfctl/npf_bpf_comp.c:1.9	Mon Dec 26 23:05:05 2016
+++ src/usr.sbin/npf/npfctl/npf_bpf_comp.c	Tue Dec 27 22:35:33 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: npf_bpf_comp.c,v 1.9 2016/12/26 23:05:05 christos Exp $	*/
+/*	$NetBSD: npf_bpf_comp.c,v 1.10 2016/12/27 22:35:33 rmind Exp $	*/
 
 /*-
  * Copyright (c) 2010-2014 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: npf_bpf_comp.c,v 1.9 2016/12/26 23:05:05 christos Exp $");
+__RCSID("$NetBSD: npf_bpf_comp.c,v 1.10 2016/12/27 22:35:33 rmind Exp $");
 
 #include 
 #include 
@@ -244,18 +244,29 @@ npfctl_bpf_group(npf_bpf_t *ctx)
 }
 
 void
-npfctl_bpf_endgroup(npf_bpf_t *ctx)
+npfctl_bpf_endgroup(npf_bpf_t *ctx, bool invert)
 {
 	struct bpf_program *bp = >prog;
 	const size_t curoff = bp->bf_len;
 
 	/* If there are no blocks or only one - nothing to do. */
-	if ((ctx->nblocks - ctx->gblock) <= 1) {
+	if (!invert && (ctx->nblocks - ctx->gblock) <= 1) {
 		ctx->goff = ctx->gblock = 0;
 		return;
 	}
 
 	/*
+	 * If inverting, then prepend a jump over the statement below.
+	 * If matching, jump will jump below and the fail will happen.
+	 */
+	if (invert) {
+		struct bpf_insn insns_ret[] = {
+			BPF_STMT(BPF_JMP+BPF_JA, 1),
+		};
+		add_insns(ctx, insns_ret, __arraycount(insns_ret));
+	}
+
+	/*
 	 * Append a failure return as a fall-through i.e. if there is
 	 * no match within the group.
 	 */
@@ -309,7 +320,7 @@ fetch_l3(npf_bpf_t *ctx, sa_family_t af,
 		 */
 		if (ingroup) {
 			assert(ctx->nblocks == ctx->gblock);
-			npfctl_bpf_endgroup(ctx);
+			npfctl_bpf_endgroup(ctx, false);
 		}
 
 		/*

Index: src/usr.sbin/npf/npfctl/npf_build.c
diff -u src/usr.sbin/npf/npfctl/npf_build.c:1.41 src/usr.sbin/npf/npfctl/npf_build.c:1.42
--- src/usr.sbin/npf/npfctl/npf_build.c:1.41	Mon Dec 26 23:05:05 2016
+++ src/usr.sbin/npf/npfctl/npf_build.c	Tue Dec 27 22:35:33 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: npf_build.c,v 1.41 2016/12/26 23:05:05 christos Exp $	*/
+/*	$NetBSD: npf_build.c,v 1.42 2016/12/27 22:35:33 rmind Exp $	*/
 
 /*-
  * Copyright (c) 2011-2014 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: npf_build.c,v 1.41 2016/12/26 23:05:05 christos Exp $");
+__RCSID("$NetBSD: npf_build.c,v 1.42 2016/12/27 22:35:33 rmind Exp $");
 
 #include 
 #include 
@@ -268,7 +268,7 @@ npfctl_build_vars(npf_bpf_t *ctx, sa_fam
 			assert(false);
 		}
 	}
-	npfctl_bpf_endgroup(ctx);
+	npfctl_bpf_endgroup(ctx, (opts & MATCH_INVERT) != 0);
 }
 
 static void
@@ -321,6 +321,7 @@ npfctl_build_code(nl_rule_t *rl, sa_fami
 	const addr_port_t *apto = >fo_to;
 	const int proto = op->op_proto;
 	npf_bpf_t *bc;
+	unsigned opts;
 	size_t len;
 
 	/* If none specified, then no byte-code. */
@@ -365,8 +366,10 @@ npfctl_build_code(nl_rule_t *rl, sa_fami
 	}
 
 	/* Build IP address blocks. */

CVS commit: src/usr.sbin/npf/npfd

2016-12-27 Thread Mindaugas Rasiukevicius
Module Name:src
Committed By:   rmind
Date:   Tue Dec 27 22:20:00 UTC 2016

Added Files:
src/usr.sbin/npf/npfd: Makefile npfd.c npfd.h npfd_log.c

Log Message:
Add some very preliminary npfd(8) code.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/usr.sbin/npf/npfd/Makefile \
src/usr.sbin/npf/npfd/npfd.c src/usr.sbin/npf/npfd/npfd.h \
src/usr.sbin/npf/npfd/npfd_log.c

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

Added files:

Index: src/usr.sbin/npf/npfd/Makefile
diff -u /dev/null src/usr.sbin/npf/npfd/Makefile:1.1
--- /dev/null	Tue Dec 27 22:20:00 2016
+++ src/usr.sbin/npf/npfd/Makefile	Tue Dec 27 22:20:00 2016
@@ -0,0 +1,17 @@
+# $NetBSD: Makefile,v 1.1 2016/12/27 22:20:00 rmind Exp $
+#
+# Public Domain
+#
+
+PROG=		npfd
+
+SRCS=		npfd.c
+CPPFLAGS+=	-I${.CURDIR}
+
+LDADD+=		-lnpf -lpcap
+DPADD+=		${LIBNPF} ${LIBPCAP}
+
+WARNS=		5
+NOLINT=		# disabled deliberately
+
+.include 
Index: src/usr.sbin/npf/npfd/npfd.c
diff -u /dev/null src/usr.sbin/npf/npfd/npfd.c:1.1
--- /dev/null	Tue Dec 27 22:20:00 2016
+++ src/usr.sbin/npf/npfd/npfd.c	Tue Dec 27 22:20:00 2016
@@ -0,0 +1,127 @@
+/*	$NetBSD: npfd.c,v 1.1 2016/12/27 22:20:00 rmind Exp $	*/
+
+/*-
+ * Copyright (c) 2015 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Mindaugas Rasiukevicius.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+__RCSID("$NetBSD: npfd.c,v 1.1 2016/12/27 22:20:00 rmind Exp $");
+
+#include 
+#include 
+#include 
+#include 
+
+#include "npfd.h"
+
+static volatile sig_atomic_t	hup = false;
+
+int
+npfd_getctl(void)
+{
+	int fd;
+
+	fd = open(NPF_DEV_PATH, O_RDONLY);
+	if (fd == -1) {
+		err(EXIT_FAILURE, "cannot open '%s'", NPF_DEV_PATH);
+	}
+	if (ioctl(fd, IOC_NPF_VERSION, ) == -1) {
+		err(EXIT_FAILURE, "ioctl(IOC_NPF_VERSION)");
+	}
+	if (ver != NPF_VERSION) {
+		errx(EXIT_FAILURE,
+		"incompatible NPF interface version (%d, kernel %d)\n"
+		"Hint: update userland?", NPF_VERSION, ver);
+	}
+	return fd;
+}
+
+static void
+npfd_event_loop(void)
+{
+	int fds[8], fd, nfds = 0, maxfd = 0;
+	fd_set rfds;
+
+	FD_ZERO();
+
+	fd = npfd_log_create(0)
+	fds[nfds++] = fd;
+	FD_SET(fd, );
+
+	for (int i = 0; i < nfds; i++) {
+		maxfd = MAX(maxfd, fds[i] + 1);
+	}
+
+	while (!done) {
+		if ((ret = select(maxfd, , NULL, NULL, NULL)) == -1) {
+			syslog(LOG_ERR, "select failed: %m");
+			err(EXIT_FAILURE, "select");
+		}
+		if (hup) {
+			hup = false;
+		}
+
+		for (fd = 0; fd < maxfd; fd++) {
+			// TODO
+		}
+	}
+}
+
+static void
+sighup_handler(int sig)
+{
+	hup = true;
+}
+
+int
+main(int argc, char **argv)
+{
+	bool daemon_off = false;
+	int ch;
+
+	while ((ch = getopt(argc, argv, "d")) != -1) {
+		switch (ch) {
+		case 'd':
+			daemon_off = true;
+			break;
+		default:
+			errx(EXIT_FAILURE, "usage:\n\t%s [ -d ]", argv[0]);
+		}
+	}
+
+	openlog(argv[0], LOG_PID | LOG_NDELAY | LOG_CONS, LOG_DAEMON);
+	if (!daemon_off && daemon(0, 0) == -1) {
+		syslog(LOG_ERR, "daemon failed: %m");
+		err(EXIT_FAILURE, "daemon");
+	}
+	signal(SIGHUP, sighup_handler);
+	npfd_event_loop();
+	closelog();
+
+	return 0;
+}
Index: src/usr.sbin/npf/npfd/npfd.h
diff -u /dev/null src/usr.sbin/npf/npfd/npfd.h:1.1
--- /dev/null	Tue Dec 27 22:20:00 2016
+++ src/usr.sbin/npf/npfd/npfd.h	Tue Dec 27 22:20:00 2016
@@ -0,0 +1,49 @@
+/*	$NetBSD: npfd.h,v 1.1 2016/12/27 22:20:00 rmind Exp $	*/
+
+/*-
+ * Copyright (c) 2015 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Mindaugas Rasiukevicius.
+ *
+ * 

CVS commit: src/share/man/man4

2016-12-27 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Tue Dec 27 21:54:51 UTC 2016

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

Log Message:
Bump date for previous.


To generate a diff of this commit:
cvs rdiff -u -r1.163 -r1.164 src/share/man/man4/ddb.4

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

Modified files:

Index: src/share/man/man4/ddb.4
diff -u src/share/man/man4/ddb.4:1.163 src/share/man/man4/ddb.4:1.164
--- src/share/man/man4/ddb.4:1.163	Tue Dec 27 21:54:17 2016
+++ src/share/man/man4/ddb.4	Tue Dec 27 21:54:50 2016
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ddb.4,v 1.163 2016/12/27 21:54:17 pgoyette Exp $
+.\"	$NetBSD: ddb.4,v 1.164 2016/12/27 21:54:50 pgoyette Exp $
 .\"
 .\" Copyright (c) 1997 - 2009 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -56,7 +56,7 @@
 .\" any improvements or extensions that they make and grant Carnegie Mellon
 .\" the rights to redistribute these changes.
 .\"
-.Dd April 13, 2016
+.Dd December 28, 2016
 .Dt DDB 4
 .Os
 .Sh NAME



CVS commit: src/share/man/man4

2016-12-27 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Tue Dec 27 21:54:17 UTC 2016

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

Log Message:
Update the list of options that enable the "show kernhist" command, and
restructure a bit.


To generate a diff of this commit:
cvs rdiff -u -r1.162 -r1.163 src/share/man/man4/ddb.4

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

Modified files:

Index: src/share/man/man4/ddb.4
diff -u src/share/man/man4/ddb.4:1.162 src/share/man/man4/ddb.4:1.163
--- src/share/man/man4/ddb.4:1.162	Mon Dec 26 23:12:33 2016
+++ src/share/man/man4/ddb.4	Tue Dec 27 21:54:17 2016
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ddb.4,v 1.162 2016/12/26 23:12:33 pgoyette Exp $
+.\"	$NetBSD: ddb.4,v 1.163 2016/12/27 21:54:17 pgoyette Exp $
 .\"
 .\" Copyright (c) 1997 - 2009 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -744,14 +744,14 @@ Print a selection of UVM counters and st
 .It Ic show kernhist Oo Ar addr Oc
 Dumps all the kernel histories if no address is specified, or the history
 at the address.
-This command is available only if a kernel is compiled with
-.Cd options KERNHIST
+This command is available only if a kernel is compiled with one or more
+of the kernel history options
+.Cd KERNHIST ,
+.Cd SYSCALL_DEBUG ,
+.Cd USB_DEBUG ,
+.Cd BIOHIST ,
 or
-.Cd options USB_DEBUG
-(or related options) or
-.Cd options BIOHIST
-or
-.Cd options UVMHIST .
+.Cd UVMHIST .
 .It Ic show vnode Ns Oo Cm /f Oc Ar address
 Print the vnode at
 .Ar address .



CVS commit: src/usr.bin/xlint/lint1

2016-12-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Dec 27 21:52:36 UTC 2016

Modified Files:
src/usr.bin/xlint/lint1: cgram.y decl.c externs1.h lint1.h

Log Message:
teach lint __attribute__((__unused__))


To generate a diff of this commit:
cvs rdiff -u -r1.81 -r1.82 src/usr.bin/xlint/lint1/cgram.y
cvs rdiff -u -r1.66 -r1.67 src/usr.bin/xlint/lint1/decl.c
cvs rdiff -u -r1.33 -r1.34 src/usr.bin/xlint/lint1/externs1.h
cvs rdiff -u -r1.29 -r1.30 src/usr.bin/xlint/lint1/lint1.h

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/xlint/lint1/cgram.y
diff -u src/usr.bin/xlint/lint1/cgram.y:1.81 src/usr.bin/xlint/lint1/cgram.y:1.82
--- src/usr.bin/xlint/lint1/cgram.y:1.81	Fri Nov  4 21:09:30 2016
+++ src/usr.bin/xlint/lint1/cgram.y	Tue Dec 27 16:52:35 2016
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.81 2016/11/05 01:09:30 christos Exp $ */
+/* $NetBSD: cgram.y,v 1.82 2016/12/27 21:52:35 christos Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: cgram.y,v 1.81 2016/11/05 01:09:30 christos Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.82 2016/12/27 21:52:35 christos Exp $");
 #endif
 
 #include 
@@ -516,7 +516,9 @@ type_attribute_spec:
 	| T_AT_GNU_INLINE
 	| T_AT_FORMAT T_LPARN type_attribute_format_type T_COMMA
 	constant T_COMMA constant T_RPARN
-	| T_AT_UNUSED
+	| T_AT_UNUSED {
+		addused();
+	}
 	| T_AT_WEAK
 	| T_AT_VISIBILITY T_LPARN constant T_RPARN
 	| T_QUAL {

Index: src/usr.bin/xlint/lint1/decl.c
diff -u src/usr.bin/xlint/lint1/decl.c:1.66 src/usr.bin/xlint/lint1/decl.c:1.67
--- src/usr.bin/xlint/lint1/decl.c:1.66	Thu Nov  3 18:08:30 2016
+++ src/usr.bin/xlint/lint1/decl.c	Tue Dec 27 16:52:35 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.66 2016/11/03 22:08:30 kamil Exp $ */
+/* $NetBSD: decl.c,v 1.67 2016/12/27 21:52:35 christos Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: decl.c,v 1.66 2016/11/03 22:08:30 kamil Exp $");
+__RCSID("$NetBSD: decl.c,v 1.67 2016/12/27 21:52:35 christos Exp $");
 #endif
 
 #include 
@@ -537,6 +537,12 @@ addpacked(void)
 		setpackedsize(dcs->d_type);
 }
 
+void
+addused(void)
+{
+	dcs->d_used = 1;
+}
+
 /*
  * Remember a qualifier which is part of the declaration specifiers
  * (and not the declarator) in the top element of the declaration stack.
@@ -2365,6 +2371,7 @@ decl1arg(sym_t *sym, int initflg)
 	if (sym->s_type->t_tspec != VOID)
 		(void)length(sym->s_type, sym->s_name);
 
+	sym->s_used = dcs->d_used;
 	setsflg(sym);
 
 	return (sym);

Index: src/usr.bin/xlint/lint1/externs1.h
diff -u src/usr.bin/xlint/lint1/externs1.h:1.33 src/usr.bin/xlint/lint1/externs1.h:1.34
--- src/usr.bin/xlint/lint1/externs1.h:1.33	Sat Dec 24 12:43:45 2016
+++ src/usr.bin/xlint/lint1/externs1.h	Tue Dec 27 16:52:35 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: externs1.h,v 1.33 2016/12/24 17:43:45 christos Exp $	*/
+/*	$NetBSD: externs1.h,v 1.34 2016/12/27 21:52:35 christos Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -145,6 +145,7 @@ extern	void	addscl(scl_t);
 extern	void	addtype(type_t *);
 extern	void	addqual(tqual_t);
 extern	void	addpacked(void);
+extern	void	addused(void);
 extern	void	pushdecl(scl_t);
 extern	void	popdecl(void);
 extern	void	setasm(void);

Index: src/usr.bin/xlint/lint1/lint1.h
diff -u src/usr.bin/xlint/lint1/lint1.h:1.29 src/usr.bin/xlint/lint1/lint1.h:1.30
--- src/usr.bin/xlint/lint1/lint1.h:1.29	Sun Jul 20 19:00:49 2014
+++ src/usr.bin/xlint/lint1/lint1.h	Tue Dec 27 16:52:35 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: lint1.h,v 1.29 2014/07/20 23:00:49 dholland Exp $ */
+/* $NetBSD: lint1.h,v 1.30 2016/12/27 21:52:35 christos Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -344,6 +344,7 @@ typedef	struct dinfo {
 	u_int	d_notyp : 1;	/* set if no type specifier was present */
 	u_int	d_asm : 1;	/* set if d_ctx == AUTO and asm() present */
 	u_int	d_ispacked : 1;	/* packed */
+	u_int	d_used : 1;	/* used */
 	type_t	*d_tagtyp;	/* tag during member declaration */
 	sym_t	*d_fargs;	/* list of arguments during function def. */
 	pos_t	d_fdpos;	/* position of function definition */



CVS commit: src/lib/libnpf

2016-12-27 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Tue Dec 27 21:25:12 UTC 2016

Modified Files:
src/lib/libnpf: libnpf.3

Log Message:
Fix typos.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/libnpf/libnpf.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/libnpf/libnpf.3
diff -u src/lib/libnpf/libnpf.3:1.3 src/lib/libnpf/libnpf.3:1.4
--- src/lib/libnpf/libnpf.3:1.3	Tue Dec 27 17:58:56 2016
+++ src/lib/libnpf/libnpf.3	Tue Dec 27 21:25:12 2016
@@ -1,4 +1,4 @@
-.\"	$NetBSD: libnpf.3,v 1.3 2016/12/27 17:58:56 rmind Exp $
+.\"	$NetBSD: libnpf.3,v 1.4 2016/12/27 21:25:12 wiz Exp $
 .\"
 .\" Copyright (c) 2011-2015 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -132,7 +132,7 @@ Flush the current configuration.
 .It Fn npf_config_retrieve "fd" "active" "loaded"
 Retrieve and return the loaded configuration from the kernel.
 .It Fn npf_config_active_p "ncf"
-Indicate whether the retrievied configuration is active (true if yes
+Indicate whether the retrieved configuration is active (true if yes
 and false otherwise).
 .It Fn npf_config_destroy "ncf"
 Destroy the configuration
@@ -210,7 +210,7 @@ and its size by
 .Fa len .
 The size shall not exceed
 .Dv NPF_RULE_MAXKEYLEN .
-The kernel does not validate the key is unique, it is the responsibilty
+The kernel does not validate the key is unique, it is the responsibility
 of the caller.
 .\" ---
 .It Fn npf_rule_setinfo "rl" "info" "len"



CVS commit: src/usr.sbin/npf/npfctl

2016-12-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Dec 27 20:55:11 UTC 2016

Modified Files:
src/usr.sbin/npf/npfctl: npfctl.8

Log Message:
Document list


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/usr.sbin/npf/npfctl/npfctl.8

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

Modified files:

Index: src/usr.sbin/npf/npfctl/npfctl.8
diff -u src/usr.sbin/npf/npfctl/npfctl.8:1.18 src/usr.sbin/npf/npfctl/npfctl.8:1.19
--- src/usr.sbin/npf/npfctl/npfctl.8:1.18	Tue May 24 01:46:57 2016
+++ src/usr.sbin/npf/npfctl/npfctl.8	Tue Dec 27 15:55:11 2016
@@ -1,4 +1,4 @@
-.\"	$NetBSD: npfctl.8,v 1.18 2016/05/24 05:46:57 wiz Exp $
+.\"	$NetBSD: npfctl.8,v 1.19 2016/12/27 20:55:11 christos Exp $
 .\"
 .\" Copyright (c) 2009-2014 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd August 2, 2014
+.Dd December 27, 2016
 .Dt NPFCTL 8
 .Os
 .Sh NAME
@@ -153,6 +153,24 @@ Print various statistics.
 Process the configuration file, print the byte-code of each rule
 and dump the raw configuration.
 This is primarily for developer use.
+.It Ic list Oo Fl 46hNnw Oc Op Fl i Ar ifname
+Display a list of tracked connections:
+.Bl -tag -width x -compact -offset 3n
+.It Fl 4
+Display only IPv4 connections.
+.It Fl 6
+Display only IPv6 connections.
+.It Fl h
+Don't display a header.
+.It Fl N
+Try to resolve addresses.
+.It Fl n
+Only show NAT connections.
+.It Fl w
+Don't restrict display width.
+.It Fl i Ar ifname
+Display only connections through the named interface.
+.El
 .El
 .Sh PERFORMANCE
 Reloading the configuration is a relatively expensive operation.



CVS commit: src/lib/libnpf

2016-12-27 Thread Mindaugas Rasiukevicius
Module Name:src
Committed By:   rmind
Date:   Tue Dec 27 20:32:58 UTC 2016

Modified Files:
src/lib/libnpf: npf.c npf.h

Log Message:
KNF


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/lib/libnpf/npf.c
cvs rdiff -u -r1.32 -r1.33 src/lib/libnpf/npf.h

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

Modified files:

Index: src/lib/libnpf/npf.c
diff -u src/lib/libnpf/npf.c:1.41 src/lib/libnpf/npf.c:1.42
--- src/lib/libnpf/npf.c:1.41	Tue Dec 27 20:14:07 2016
+++ src/lib/libnpf/npf.c	Tue Dec 27 20:32:58 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: npf.c,v 1.41 2016/12/27 20:14:07 christos Exp $	*/
+/*	$NetBSD: npf.c,v 1.42 2016/12/27 20:32:58 rmind Exp $	*/
 
 /*-
  * Copyright (c) 2010-2015 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: npf.c,v 1.41 2016/12/27 20:14:07 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: npf.c,v 1.42 2016/12/27 20:32:58 rmind Exp $");
 
 #include 
 #include 
@@ -1427,18 +1427,18 @@ npf_conn_list(int fd, npf_conn_func_t fu
 	if (ncf == NULL) {
 		return errno;
 	}
-
-/* Connection list - array */ 
-if (prop_object_type(ncf->ncf_conn_list) != PROP_TYPE_ARRAY) {
-return EINVAL;
-}
-
-prop_object_iterator_t it = prop_array_iterator(ncf->ncf_conn_list);
-prop_dictionary_t condict;
-while ((condict = prop_object_iterator_next(it)) != NULL) {
-if (prop_object_type(condict) != PROP_TYPE_DICTIONARY) {
+
+	/* Connection list - array */ 
+	if (prop_object_type(ncf->ncf_conn_list) != PROP_TYPE_ARRAY) {
+		return EINVAL;
+	}
+
+	prop_object_iterator_t it = prop_array_iterator(ncf->ncf_conn_list);
+	prop_dictionary_t condict;
+	while ((condict = prop_object_iterator_next(it)) != NULL) {
+		if (prop_object_type(condict) != PROP_TYPE_DICTIONARY) {
 			return EINVAL;
-}
+		}
 		npf_conn_handle(condict, fun, v);
 	}
 	return 0;

Index: src/lib/libnpf/npf.h
diff -u src/lib/libnpf/npf.h:1.32 src/lib/libnpf/npf.h:1.33
--- src/lib/libnpf/npf.h:1.32	Tue Dec 27 20:14:07 2016
+++ src/lib/libnpf/npf.h	Tue Dec 27 20:32:58 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: npf.h,v 1.32 2016/12/27 20:14:07 christos Exp $	*/
+/*	$NetBSD: npf.h,v 1.33 2016/12/27 20:32:58 rmind Exp $	*/
 
 /*-
  * Copyright (c) 2011-2014 The NetBSD Foundation, Inc.
@@ -150,10 +150,9 @@ void		_npf_debug_addif(nl_config_t *, co
 int 		_npf_alg_load(nl_config_t *, const char *);
 int		_npf_alg_unload(nl_config_t *, const char *);
 
-/* utils */
-typedef int (*npf_conn_func_t)(unsigned, const npf_addr_t *, const in_port_t *,
-const char *, void *);
-int	 	npf_conn_list(int, npf_conn_func_t, void *);
+typedef int (*npf_conn_func_t)(unsigned, const npf_addr_t *,
+const in_port_t *, const char *, void *);
+int		npf_conn_list(int, npf_conn_func_t, void *);
 
 #endif
 



CVS commit: src/usr.sbin/npf/npfctl

2016-12-27 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Tue Dec 27 20:24:32 UTC 2016

Modified Files:
src/usr.sbin/npf/npfctl: npfctl.c

Log Message:
Sort options in usage.


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

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

Modified files:

Index: src/usr.sbin/npf/npfctl/npfctl.c
diff -u src/usr.sbin/npf/npfctl/npfctl.c:1.50 src/usr.sbin/npf/npfctl/npfctl.c:1.51
--- src/usr.sbin/npf/npfctl/npfctl.c:1.50	Tue Dec 27 20:14:35 2016
+++ src/usr.sbin/npf/npfctl/npfctl.c	Tue Dec 27 20:24:32 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: npfctl.c,v 1.50 2016/12/27 20:14:35 christos Exp $	*/
+/*	$NetBSD: npfctl.c,v 1.51 2016/12/27 20:24:32 wiz Exp $	*/
 
 /*-
  * Copyright (c) 2009-2014 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: npfctl.c,v 1.50 2016/12/27 20:14:35 christos Exp $");
+__RCSID("$NetBSD: npfctl.c,v 1.51 2016/12/27 20:24:32 wiz Exp $");
 
 #include 
 #include 
@@ -150,7 +150,7 @@ usage(void)
 	"\t%s save | load\n",
 	progname);
 	fprintf(stderr,
-	"\t%s list [-46hnNw] [-i ]\n",
+	"\t%s list [-46hNnw] [-i ]\n",
 	progname);
 	exit(EXIT_FAILURE);
 }



CVS commit: src/usr.sbin/npf/npfctl

2016-12-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Dec 27 20:14:35 UTC 2016

Modified Files:
src/usr.sbin/npf/npfctl: npf_show.c npfctl.c npfctl.h

Log Message:
Add a list command to iterate over connection and nat endpoints.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/usr.sbin/npf/npfctl/npf_show.c
cvs rdiff -u -r1.49 -r1.50 src/usr.sbin/npf/npfctl/npfctl.c
cvs rdiff -u -r1.40 -r1.41 src/usr.sbin/npf/npfctl/npfctl.h

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

Modified files:

Index: src/usr.sbin/npf/npfctl/npf_show.c
diff -u src/usr.sbin/npf/npfctl/npf_show.c:1.20 src/usr.sbin/npf/npfctl/npf_show.c:1.21
--- src/usr.sbin/npf/npfctl/npf_show.c:1.20	Mon Dec 26 18:05:05 2016
+++ src/usr.sbin/npf/npfctl/npf_show.c	Tue Dec 27 15:14:35 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: npf_show.c,v 1.20 2016/12/26 23:05:05 christos Exp $	*/
+/*	$NetBSD: npf_show.c,v 1.21 2016/12/27 20:14:35 christos Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: npf_show.c,v 1.20 2016/12/26 23:05:05 christos Exp $");
+__RCSID("$NetBSD: npf_show.c,v 1.21 2016/12/27 20:14:35 christos Exp $");
 
 #include 
 #define	__FAVOR_BSD
@@ -153,7 +153,7 @@ print_address(npf_conf_info_t *ctx, cons
 		errx(EXIT_FAILURE, "invalid byte-code mark (address)");
 	}
 	addr = (const npf_addr_t *)words;
-	return npfctl_print_addrmask(alen, addr, mask);
+	return npfctl_print_addrmask(alen, "%a", addr, mask);
 }
 
 static char *
@@ -437,7 +437,7 @@ npfctl_print_nat(npf_conf_info_t *ctx, n
 
 	/* Get the translation address (and port, if used). */
 	npf_nat_getmap(nt, , , );
-	seg = npfctl_print_addrmask(alen, , NPF_NO_NETMASK);
+	seg = npfctl_print_addrmask(alen, "%a", , NPF_NO_NETMASK);
 	if (port) {
 		char *p;
 		easprintf(, "%s port %u", seg, ntohs(port));

Index: src/usr.sbin/npf/npfctl/npfctl.c
diff -u src/usr.sbin/npf/npfctl/npfctl.c:1.49 src/usr.sbin/npf/npfctl/npfctl.c:1.50
--- src/usr.sbin/npf/npfctl/npfctl.c:1.49	Tue Dec 27 08:43:38 2016
+++ src/usr.sbin/npf/npfctl/npfctl.c	Tue Dec 27 15:14:35 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: npfctl.c,v 1.49 2016/12/27 13:43:38 christos Exp $	*/
+/*	$NetBSD: npfctl.c,v 1.50 2016/12/27 20:14:35 christos Exp $	*/
 
 /*-
  * Copyright (c) 2009-2014 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: npfctl.c,v 1.49 2016/12/27 13:43:38 christos Exp $");
+__RCSID("$NetBSD: npfctl.c,v 1.50 2016/12/27 20:14:35 christos Exp $");
 
 #include 
 #include 
@@ -70,6 +70,7 @@ enum {
 	NPFCTL_STATS,
 	NPFCTL_SAVE,
 	NPFCTL_LOAD,
+	NPFCTL_CONN_LIST,
 };
 
 static const struct operations_s {
@@ -92,6 +93,7 @@ static const struct operations_s {
 	/* Full state save/load */
 	{	"save",		NPFCTL_SAVE		},
 	{	"load",		NPFCTL_LOAD		},
+	{	"list",		NPFCTL_CONN_LIST	},
 	/* --- */
 	{	NULL,		0			}
 };
@@ -147,6 +149,9 @@ usage(void)
 	fprintf(stderr,
 	"\t%s save | load\n",
 	progname);
+	fprintf(stderr,
+	"\t%s list [-46hnNw] [-i ]\n",
+	progname);
 	exit(EXIT_FAILURE);
 }
 
@@ -230,9 +235,10 @@ npfctl_print_error(const npf_error_t *ne
 }
 
 char *
-npfctl_print_addrmask(int alen, const npf_addr_t *addr, npf_netmask_t mask)
+npfctl_print_addrmask(int alen, const char *fmt, const npf_addr_t *addr,
+npf_netmask_t mask)
 {
-	const unsigned buflen = 64;
+	const unsigned buflen = 256;
 	char *buf = ecalloc(1, buflen);
 	struct sockaddr_storage ss;
 
@@ -241,12 +247,14 @@ npfctl_print_addrmask(int alen, const np
 	switch (alen) {
 	case 4: {
 		struct sockaddr_in *sin = (void *)
+		sin->sin_len = sizeof(*sin);
 		sin->sin_family = AF_INET;
 		memcpy(>sin_addr, addr, sizeof(sin->sin_addr));
 		break;
 	}
 	case 16: {
 		struct sockaddr_in6 *sin6 = (void *)
+		sin6->sin6_len = sizeof(*sin6);
 		sin6->sin6_family = AF_INET6;
 		memcpy(>sin6_addr, addr, sizeof(sin6->sin6_addr));
 		break;
@@ -254,7 +262,7 @@ npfctl_print_addrmask(int alen, const np
 	default:
 		assert(false);
 	}
-	inet_ntop(ss.ss_family, (const void *), buf, buflen);
+	sockaddr_snprintf(buf, buflen, fmt, (const void *));
 	if (mask && mask != NPF_NO_NETMASK) {
 		const unsigned len = strlen(buf);
 		snprintf([len], buflen - len, "/%u", mask);
@@ -359,7 +367,7 @@ again:
 		while (nct.nct_data.buf.len--) {
 			if (!ent->alen)
 break;
-			buf = npfctl_print_addrmask(ent->alen,
+			buf = npfctl_print_addrmask(ent->alen, "%a",
 			>addr, ent->mask);
 			puts(buf);
 			ent++;
@@ -574,6 +582,103 @@ npfctl_load(int fd)
 	return error;
 }
 
+struct npf_conn_filter {
+	uint16_t alen;
+	const char *ifname;
+	bool nat;
+	bool wide;
+	bool name;
+	int width;
+	FILE *fp;
+};
+
+static int
+npfctl_conn_print(unsigned alen, const npf_addr_t *a, const in_port_t *p, 
+const char *ifname, void *v)
+{
+	struct npf_conn_filter *fil = v;
+	FILE *fp = fil->fp;
+	char *src, *dst;
+
+	if (fil->ifname && strcmp(ifname, fil->ifname) != 0)
+		return 0;
+	if (fil->alen 

CVS commit: src/lib/libnpf

2016-12-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Dec 27 20:14:07 UTC 2016

Modified Files:
src/lib/libnpf: npf.c npf.h

Log Message:
Add a function to iterate over endpoints


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/lib/libnpf/npf.c
cvs rdiff -u -r1.31 -r1.32 src/lib/libnpf/npf.h

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

Modified files:

Index: src/lib/libnpf/npf.c
diff -u src/lib/libnpf/npf.c:1.40 src/lib/libnpf/npf.c:1.41
--- src/lib/libnpf/npf.c:1.40	Mon Dec 26 18:05:05 2016
+++ src/lib/libnpf/npf.c	Tue Dec 27 15:14:07 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: npf.c,v 1.40 2016/12/26 23:05:05 christos Exp $	*/
+/*	$NetBSD: npf.c,v 1.41 2016/12/27 20:14:07 christos Exp $	*/
 
 /*-
  * Copyright (c) 2010-2015 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: npf.c,v 1.40 2016/12/26 23:05:05 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: npf.c,v 1.41 2016/12/27 20:14:07 christos Exp $");
 
 #include 
 #include 
@@ -122,7 +122,7 @@ _npf_add_addr(prop_dictionary_t dict, co
 	return true;
 }
 
-static bool
+static unsigned
 _npf_get_addr(prop_dictionary_t dict, const char *name, npf_addr_t *addr)
 {
 	prop_object_t obj = prop_dictionary_get(dict, name);
@@ -136,9 +136,9 @@ _npf_get_addr(prop_dictionary_t dict, co
 	case sizeof(struct in_addr):
 	case sizeof(struct in6_addr):
 		memcpy(addr, d, sz);
-		return true;
+		return (unsigned)sz;
 	default:
-		return false;
+		return 0;
 	}
 }
 
@@ -1359,3 +1359,87 @@ out:
 	prop_object_release(conn_dict);
 	return error;
 }
+
+struct npf_endpoint {
+	npf_addr_t addr[2];
+	in_port_t port[2];
+	uint16_t alen;
+	uint16_t proto;
+};
+
+static bool
+npf_endpoint_load(prop_dictionary_t cdict, const char *name,
+struct npf_endpoint *ep)
+{
+	prop_dictionary_t ed = prop_dictionary_get(cdict, name);
+	if (ed == NULL)
+		return false;
+	if (!(ep->alen = _npf_get_addr(ed, "saddr", >addr[0])))
+		return false;
+	if (ep->alen != _npf_get_addr(ed, "daddr", >addr[1]))
+		return false;
+	if (!prop_dictionary_get_uint16(ed, "sport", >port[0]))
+		return false;
+	if (!prop_dictionary_get_uint16(ed, "dport", >port[1]))
+		return false;
+	if (!prop_dictionary_get_uint16(ed, "proto", >proto))
+		return false;
+	return true;
+}
+
+static void
+npf_conn_handle(prop_dictionary_t cdict, npf_conn_func_t fun, void *v)
+{
+	prop_dictionary_t nat;
+	struct npf_endpoint ep;
+	uint16_t tport;
+	const char *ifname;
+
+	if (!prop_dictionary_get_cstring_nocopy(cdict, "ifname", ))
+		goto err;
+
+	if ((nat = prop_dictionary_get(cdict, "nat")) != NULL &&
+	prop_object_type(nat) == PROP_TYPE_DICTIONARY) {
+		if (!prop_dictionary_get_uint16(nat, "tport", ))
+			goto err;
+	} else {
+		tport = 0;
+	}
+	if (!npf_endpoint_load(cdict, "forw-key", ))
+		goto err;
+
+	in_port_t p[] = {
+	ntohs(ep.port[0]),
+	ntohs(ep.port[1]),
+	ntohs(tport)
+	};
+	(*fun)((unsigned)ep.alen, ep.addr, p, ifname, v);
+err:
+	return;
+}
+
+int
+npf_conn_list(int fd, npf_conn_func_t fun, void *v)
+{
+	nl_config_t *ncf;
+
+	ncf = npf_config_retrieve(fd);
+	if (ncf == NULL) {
+		return errno;
+	}
+
+/* Connection list - array */ 
+if (prop_object_type(ncf->ncf_conn_list) != PROP_TYPE_ARRAY) {
+return EINVAL;
+}
+
+prop_object_iterator_t it = prop_array_iterator(ncf->ncf_conn_list);
+prop_dictionary_t condict;
+while ((condict = prop_object_iterator_next(it)) != NULL) {
+if (prop_object_type(condict) != PROP_TYPE_DICTIONARY) {
+			return EINVAL;
+}
+		npf_conn_handle(condict, fun, v);
+	}
+	return 0;
+}

Index: src/lib/libnpf/npf.h
diff -u src/lib/libnpf/npf.h:1.31 src/lib/libnpf/npf.h:1.32
--- src/lib/libnpf/npf.h:1.31	Mon Dec 26 18:05:05 2016
+++ src/lib/libnpf/npf.h	Tue Dec 27 15:14:07 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: npf.h,v 1.31 2016/12/26 23:05:05 christos Exp $	*/
+/*	$NetBSD: npf.h,v 1.32 2016/12/27 20:14:07 christos Exp $	*/
 
 /*-
  * Copyright (c) 2011-2014 The NetBSD Foundation, Inc.
@@ -150,6 +150,11 @@ void		_npf_debug_addif(nl_config_t *, co
 int 		_npf_alg_load(nl_config_t *, const char *);
 int		_npf_alg_unload(nl_config_t *, const char *);
 
+/* utils */
+typedef int (*npf_conn_func_t)(unsigned, const npf_addr_t *, const in_port_t *,
+const char *, void *);
+int	 	npf_conn_list(int, npf_conn_func_t, void *);
+
 #endif
 
 __END_DECLS



CVS commit: src/lib/libnpf

2016-12-27 Thread Mindaugas Rasiukevicius
Module Name:src
Committed By:   rmind
Date:   Tue Dec 27 17:58:56 UTC 2016

Modified Files:
src/lib/libnpf: libnpf.3

Log Message:
Update libnpf(3) man page.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/libnpf/libnpf.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/libnpf/libnpf.3
diff -u src/lib/libnpf/libnpf.3:1.2 src/lib/libnpf/libnpf.3:1.3
--- src/lib/libnpf/libnpf.3:1.2	Sun Aug  3 00:02:56 2014
+++ src/lib/libnpf/libnpf.3	Tue Dec 27 17:58:56 2016
@@ -1,6 +1,6 @@
-.\"	$NetBSD: libnpf.3,v 1.2 2014/08/03 00:02:56 rmind Exp $
+.\"	$NetBSD: libnpf.3,v 1.3 2016/12/27 17:58:56 rmind Exp $
 .\"
-.\" Copyright (c) 2011-2013 The NetBSD Foundation, Inc.
+.\" Copyright (c) 2011-2015 The NetBSD Foundation, Inc.
 .\" All rights reserved.
 .\"
 .\" This material is based upon work partially supported by The
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd August 2, 2014
+.Dd April 19, 2015
 .Dt LIBNPF 3
 .Os
 .Sh NAME
@@ -41,11 +41,19 @@
 .Ft nl_config_t *
 .Fn npf_config_create "void"
 .Ft int
-.Fn npf_config_submit "nl_config_t *ncf" "int fd"
-.Ft void
-.Fn npf_config_destroy "nl_config_t *ncf"
+.Fn npf_config_submit "nl_config_t *ncf" "int fd" "nl_error_t *errinfo"
+.Ft nl_config_t *
+.Fn npf_config_retrieve "int fd" "bool *active" "bool *loaded"
 .Ft int
 .Fn npf_config_flush "int fd"
+.Ft void
+.Fn npf_config_export "const nl_config_t *ncf" "size_t *len"
+.Ft nl_config_t *
+.Fn npf_config_import "const void *blob" "size_t len"
+.Ft bool
+.Fn npf_config_active_p "nl_config_t *ncf"
+.Ft void
+.Fn npf_config_destroy "nl_config_t *ncf"
 .\" ---
 .Ft nl_rule_t *
 .Fn npf_rule_create "char *name" "uint32_t attr" "const char *ifname"
@@ -53,14 +61,18 @@
 .Fn npf_rule_setcode "nl_rule_t *rl" "int type" "const void *code" "size_t len"
 .Ft int
 .Fn npf_rule_setkey "nl_rule_t *rl" "int type" "const void *code" "size_t len"
+.Ft int
+.Fn npf_rule_setinfo "nl_rule_t *rl" "const void *info" "size_t len"
 .Ft bool
 .Fn npf_rule_exists_p "nl_config_t *ncf" "const char *name"
 .Ft int
-.Fn npf_rule_insert "nl_config_t *ncf" "nl_rule_t *parent" "nl_rule_t *rl"
-.Ft int
-.Fn npf_rule_setprio "nl_rule_t *rl" "pri_t pri"
+.Fn npf_rule_setprio "nl_rule_t *rl" "int pri"
 .Ft int
 .Fn npf_rule_setproc "nl_config_t *ncf" "nl_rule_t *rl" "const char *name"
+.Ft int
+.Fn npf_rule_insert "nl_config_t *ncf" "nl_rule_t *parent" "nl_rule_t *rl"
+.Ft void *
+.Fn npf_rule_export "nl_rule_t *rl" "size_t *length"
 .Ft void
 .Fn npf_rule_destroy "nl_rule_t *rl"
 .\" ---
@@ -99,15 +111,32 @@ The configuration can be submitted to th
 .Bl -tag -width 4n
 .It Fn npf_config_create
 Create a configuration.
-.It Fn npf_config_submit "ncf" "fd"
+.It Fn npf_config_submit "ncf" "fd" "errinfo"
 Submit configuration
 .Fa ncf
 to the kernel.
+On error, the the description is written into the structure specified by
+.Fa errinfo .
+.It Fn npf_config_export "fd" "len"
+Serialize the given configuration and return binary object and its
+length in
+.Fa len
+parameter.
+The binary object is dynamically allocated and should be destroyed using
+.Xr free 3 .
+.It Fn npf_config_import "blob" "len"
+Read the configuration from a binary object of the specified length,
+unserialize, construct and return the configuration object.
+.It Fn npf_config_flush "fd"
+Flush the current configuration.
+.It Fn npf_config_retrieve "fd" "active" "loaded"
+Retrieve and return the loaded configuration from the kernel.
+.It Fn npf_config_active_p "ncf"
+Indicate whether the retrievied configuration is active (true if yes
+and false otherwise).
 .It Fn npf_config_destroy "ncf"
 Destroy the configuration
 .Fa ncf .
-.It Fn npf_config_flush "fd"
-Flush the current configuration.
 .El
 .\" ---
 .Ss Rule interface
@@ -124,20 +153,32 @@ The following attributes, which can be O
 Decision of this rule is "pass".
 If this attribute is not
 specified, then packet "block" (drop) is the default.
+.It Dv NPF_RULE_IN
+Match incoming packets.
+.It Dv NPF_RULE_OUT
+Match outgoing packets.
 .It Dv NPF_RULE_FINAL
 Indicates that on rule match, further processing of the
 ruleset should be stopped and this rule applied instantly.
 .It Dv NPF_RULE_STATEFUL
 Create a state (session) on match, track the connection and
 therefore pass the backwards stream without inspection.
+The state is uniquely identified by a 5-tuple (source and destination
+IP addresses, port numbers and an interface identifier).
+.It Dv NPF_RULE_MULTIENDS
+Exclude the interface from the state identifier.
 .It Dv NPF_RULE_RETRST
 Return TCP RST packet in a case of packet block.
 .It Dv NPF_RULE_RETICMP
 Return ICMP destination unreachable in a case of packet block.
-.It Dv NPF_RULE_IN
-Rule may match only if incoming packet.
-.It Dv NPF_RULE_OUT
-Rule may match only if outgoing packet.
+.It Dv 

CVS commit: src/etc/mtree

2016-12-27 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Tue Dec 27 17:13:45 UTC 2016

Modified Files:
src/etc/mtree: special

Log Message:
Add blacklistd.conf so it gets backed up, too.


To generate a diff of this commit:
cvs rdiff -u -r1.154 -r1.155 src/etc/mtree/special

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

Modified files:

Index: src/etc/mtree/special
diff -u src/etc/mtree/special:1.154 src/etc/mtree/special:1.155
--- src/etc/mtree/special:1.154	Tue Dec 27 16:48:12 2016
+++ src/etc/mtree/special	Tue Dec 27 17:13:45 2016
@@ -1,4 +1,4 @@
-#	$NetBSD: special,v 1.154 2016/12/27 16:48:12 christos Exp $
+#	$NetBSD: special,v 1.155 2016/12/27 17:13:45 maya Exp $
 #	@(#)special	8.2 (Berkeley) 1/23/94
 #
 # This file may be overwritten on upgrades.
@@ -29,6 +29,7 @@
 ./etc/Distfile			type=file mode=0644 optional
 ./etc/amd			type=dir  mode=0755 optional
 ./etc/apm			type=dir  mode=0755 optional
+./etc/blacklistd.conf		type=file mode=0644 optional
 ./etc/bluetooth			type=dir  mode=0755
 ./etc/bluetooth/btattach.conf	type=file mode=0644
 ./etc/bluetooth/btdevctl.conf	type=file mode=0644



CVS commit: src/etc/mtree

2016-12-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Dec 27 16:48:12 UTC 2016

Modified Files:
src/etc/mtree: special

Log Message:
Add npf.conf so it gets backed up.


To generate a diff of this commit:
cvs rdiff -u -r1.153 -r1.154 src/etc/mtree/special

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

Modified files:

Index: src/etc/mtree/special
diff -u src/etc/mtree/special:1.153 src/etc/mtree/special:1.154
--- src/etc/mtree/special:1.153	Mon Nov 23 14:56:47 2015
+++ src/etc/mtree/special	Tue Dec 27 11:48:12 2016
@@ -1,4 +1,4 @@
-#	$NetBSD: special,v 1.153 2015/11/23 19:56:47 christos Exp $
+#	$NetBSD: special,v 1.154 2016/12/27 16:48:12 christos Exp $
 #	@(#)special	8.2 (Berkeley) 1/23/94
 #
 # This file may be overwritten on upgrades.
@@ -124,6 +124,7 @@
 ./etc/newsyslog.conf		type=file mode=0644
 ./etc/nsswitch.conf		type=file mode=0644
 ./etc/ntp.conf			type=file mode=0644 optional
+./etc/npf.conf			type=file mode=0644 optional
 ./etc/pam.conf			type=file mode=0644 optional
 ./etc/pam.d			type=dir  mode=0755
 ./etc/pam.d/display_manager	type=file mode=0644



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

2016-12-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Dec 27 15:25:42 UTC 2016

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

Log Message:
Another merge botch


To generate a diff of this commit:
cvs rdiff -u -r1.108.2.35 -r1.108.2.36 src/sys/dev/usb/ucom.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/ucom.c
diff -u src/sys/dev/usb/ucom.c:1.108.2.35 src/sys/dev/usb/ucom.c:1.108.2.36
--- src/sys/dev/usb/ucom.c:1.108.2.35	Tue Dec 27 15:22:10 2016
+++ src/sys/dev/usb/ucom.c	Tue Dec 27 15:25:41 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ucom.c,v 1.108.2.35 2016/12/27 15:22:10 skrll Exp $	*/
+/*	$NetBSD: ucom.c,v 1.108.2.36 2016/12/27 15:25:41 skrll Exp $	*/
 
 /*
  * Copyright (c) 1998, 2000, 2016 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.108.2.35 2016/12/27 15:22:10 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.108.2.36 2016/12/27 15:25:41 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -1639,6 +1639,7 @@ ucomreadcb(struct usbd_xfer *xfer, void 
 		return;
 	}
 
+	mutex_exit(>sc_lock);
 	ub->ub_data = usbd_get_buffer(xfer);
 	if (sc->sc_methods->ucom_read != NULL) {
 		sc->sc_methods->ucom_read(sc->sc_parent, sc->sc_portno,
@@ -1649,6 +1650,15 @@ ucomreadcb(struct usbd_xfer *xfer, void 
 
 	ub->ub_len = cc;
 
+	mutex_enter(>sc_lock);
+	if (sc->sc_dying) {
+		if (--sc->sc_refcnt < 0)
+			cv_broadcast(>sc_detachcv);
+		mutex_exit(>sc_lock);
+		DPRINTF("... dying", 0, 0, 0, 0);
+		return;
+	}
+
 	SIMPLEQ_INSERT_TAIL(>sc_ibuff_full, ub, ub_link);
 
 	ucom_read_complete(sc);



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

2016-12-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Dec 27 15:22:10 UTC 2016

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

Log Message:
Update copyright notice


To generate a diff of this commit:
cvs rdiff -u -r1.108.2.34 -r1.108.2.35 src/sys/dev/usb/ucom.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/ucom.c
diff -u src/sys/dev/usb/ucom.c:1.108.2.34 src/sys/dev/usb/ucom.c:1.108.2.35
--- src/sys/dev/usb/ucom.c:1.108.2.34	Tue Dec 27 15:21:46 2016
+++ src/sys/dev/usb/ucom.c	Tue Dec 27 15:22:10 2016
@@ -1,12 +1,12 @@
-/*	$NetBSD: ucom.c,v 1.108.2.34 2016/12/27 15:21:46 skrll Exp $	*/
+/*	$NetBSD: ucom.c,v 1.108.2.35 2016/12/27 15:22:10 skrll Exp $	*/
 
 /*
- * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
+ * Copyright (c) 1998, 2000, 2016 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
  * by Lennart Augustsson (lenn...@augustsson.net) at
- * Carlstedt Research & Technology.
+ * Carlstedt Research & Technology, and Nick Hudson
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.108.2.34 2016/12/27 15:21:46 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.108.2.35 2016/12/27 15:22:10 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"



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

2016-12-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Dec 27 15:21:46 UTC 2016

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

Log Message:
Fix merge botch


To generate a diff of this commit:
cvs rdiff -u -r1.108.2.33 -r1.108.2.34 src/sys/dev/usb/ucom.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/ucom.c
diff -u src/sys/dev/usb/ucom.c:1.108.2.33 src/sys/dev/usb/ucom.c:1.108.2.34
--- src/sys/dev/usb/ucom.c:1.108.2.33	Tue Dec 27 14:58:07 2016
+++ src/sys/dev/usb/ucom.c	Tue Dec 27 15:21:46 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ucom.c,v 1.108.2.33 2016/12/27 14:58:07 skrll Exp $	*/
+/*	$NetBSD: ucom.c,v 1.108.2.34 2016/12/27 15:21:46 skrll Exp $	*/
 
 /*
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.108.2.33 2016/12/27 14:58:07 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.108.2.34 2016/12/27 15:21:46 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -1208,16 +1208,6 @@ ucomparam(struct tty *tp, struct termios
 	sc->sc_refcnt++;
 	mutex_exit(>sc_lock);
 
-	mutex_enter(>sc_lock);
-	if (sc->sc_dying) {
-		DPRINTF("... dying", 0, 0, 0, 0);
-		mutex_exit(>sc_lock);
-		return EIO;
-	}
-
-	sc->sc_refcnt++;
-	mutex_exit(>sc_lock);
-
 	/* Check requested parameters. */
 	if (t->c_ispeed && t->c_ispeed != t->c_ospeed) {
 		error = EINVAL;



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

2016-12-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Dec 27 14:58:07 UTC 2016

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

Log Message:
Open pipes with USBD_MPSAFE - we don't need the KERNEL_LOCK to be held.


To generate a diff of this commit:
cvs rdiff -u -r1.108.2.32 -r1.108.2.33 src/sys/dev/usb/ucom.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/ucom.c
diff -u src/sys/dev/usb/ucom.c:1.108.2.32 src/sys/dev/usb/ucom.c:1.108.2.33
--- src/sys/dev/usb/ucom.c:1.108.2.32	Mon Dec  5 10:55:18 2016
+++ src/sys/dev/usb/ucom.c	Tue Dec 27 14:58:07 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ucom.c,v 1.108.2.32 2016/12/05 10:55:18 skrll Exp $	*/
+/*	$NetBSD: ucom.c,v 1.108.2.33 2016/12/27 14:58:07 skrll Exp $	*/
 
 /*
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.108.2.32 2016/12/05 10:55:18 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.108.2.33 2016/12/27 14:58:07 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -323,7 +323,7 @@ ucom_attach(device_t parent, device_t se
 	if (sc->sc_bulkin_no != -1) {
 		/* Open the bulk pipes */
 		err = usbd_open_pipe(sc->sc_iface, sc->sc_bulkin_no,
-		USBD_EXCLUSIVE_USE, >sc_bulkin_pipe);
+		USBD_EXCLUSIVE_USE | USBD_MPSAFE, >sc_bulkin_pipe);
 		if (err) {
 			DPRINTF("open bulk in error (addr %d), err=%d",
 			sc->sc_bulkin_no, err, 0, 0);
@@ -345,7 +345,7 @@ ucom_attach(device_t parent, device_t se
 
 	if (sc->sc_bulkout_no != -1) {
 		err = usbd_open_pipe(sc->sc_iface, sc->sc_bulkout_no,
-		USBD_EXCLUSIVE_USE, >sc_bulkout_pipe);
+		USBD_EXCLUSIVE_USE | USBD_MPSAFE, >sc_bulkout_pipe);
 		if (err) {
 			DPRINTF("open bulk out error (addr %d), err=%d",
 			sc->sc_bulkout_no, err, 0, 0);



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

2016-12-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Dec 27 14:43:59 UTC 2016

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

Log Message:
Fix a comment


To generate a diff of this commit:
cvs rdiff -u -r1.162.2.49 -r1.162.2.50 src/sys/dev/usb/usbdi.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/usbdi.c
diff -u src/sys/dev/usb/usbdi.c:1.162.2.49 src/sys/dev/usb/usbdi.c:1.162.2.50
--- src/sys/dev/usb/usbdi.c:1.162.2.49	Sun Dec 11 17:31:09 2016
+++ src/sys/dev/usb/usbdi.c	Tue Dec 27 14:43:59 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbdi.c,v 1.162.2.49 2016/12/11 17:31:09 skrll Exp $	*/
+/*	$NetBSD: usbdi.c,v 1.162.2.50 2016/12/27 14:43:59 skrll Exp $	*/
 
 /*
  * Copyright (c) 1998, 2012, 2015 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.162.2.49 2016/12/11 17:31:09 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.162.2.50 2016/12/27 14:43:59 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -860,7 +860,7 @@ usbd_get_interface(struct usbd_interface
 
 /*** Internal routines ***/
 
-/* Dequeue all pipe operations, called at splusb(). */
+/* Dequeue all pipe operations, called with bus lock held. */
 Static usbd_status
 usbd_ar_pipe(struct usbd_pipe *pipe)
 {



CVS commit: src/sys/dev/pci

2016-12-27 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Dec 27 14:09:57 UTC 2016

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

Log Message:
Add some Radeon devices. Mainly taken from OpenBSD.


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

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

Modified files:

Index: src/sys/dev/pci/pcidevs
diff -u src/sys/dev/pci/pcidevs:1.1274 src/sys/dev/pci/pcidevs:1.1275
--- src/sys/dev/pci/pcidevs:1.1274	Mon Dec 26 07:53:03 2016
+++ src/sys/dev/pci/pcidevs	Tue Dec 27 14:09:57 2016
@@ -1,4 +1,4 @@
-$NetBSD: pcidevs,v 1.1274 2016/12/26 07:53:03 msaitoh Exp $
+$NetBSD: pcidevs,v 1.1275 2016/12/27 14:09:57 msaitoh Exp $
 
 /*
  * Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -1506,8 +1506,28 @@ product ATI RADEON_R423_5D57	0x5d57	Rade
 product ATI RADEON_X850XT_S	0x5d72	Radeon X850 XT Secondary
 product ATI RADEON_X700		0x5e4b	Radeon X700 Pro
 product ATI RADEON_X700_S	0x5e6b	Radeon X700 Pro Secondary
+product ATI RADEON_HD8790M	0x6606	Radeon HD 8790M
+product ATI RADEON_HD8530M	0x6607	Radeon HD 8530M
+product ATI RADEON_HD8600	0x6610	Radeon HD 8600
+product ATI RADEON_HD8570	0x6611	Radeon HD 8570
+product ATI RADEON_HD8500	0x6613	Radeon HD 8500
+product ATI RADEON_RX460	0x67ef	Radeon RX460
+product ATI RADEON_HD8800M	0x682b	Radeon HD 8800M
+product ATI RADEON_HD7730M	0x682f	Radeon HD 7730M
+product ATI RADEON_HD7800M	0x6830	Radeon HD 7800M
+product ATI RADEON_HD7700M	0x6831	Radeon HD 7700M
+product ATI RADEON_HD7730	0x6837	Radeon HD 7730
+product ATI RADEON_HD7700	0x683b	Radeon HD 7700
+product ATI RADEON_HD7770	0x683d	Radeon HD 7770
+product ATI RADEON_HD7750	0x683f	Radeon HD 7750
+product ATI RADEON_HD7600M	0x6840	Radeon HD 7600M
+product ATI RADEON_HD7550M	0x6841	Radeon HD 7550M
+product ATI RADEON_HD7000M	0x6842	Radeon HD 7000M
+product ATI RADEON_HD7670M	0x6843	Radeon HD 7670M
+product ATI RADEON_HD7400	0x6849	Radeon HD 7400
 product ATI RADEON_HD5870	0x6898	Radeon HD 5870 Cypress
 product ATI RADEON_HD5600_RD	0x68c1	Radeon HD 5600 Redwood
+product ATI RADEON_HD5570	0x68d9	Radeon HD 5570
 product ATI RADEON_HD5450	0x68f9	Radeon HD 5450
 product ATI RADEON_X1300	0x7146	Radeon X1300 Series (RV515)
 product ATI RADEON_X1300_S	0x7166	Radeon X1300 Series (RV515) Secondary
@@ -1544,7 +1564,22 @@ product ATI RADEON_HD3650_AGP	0x9596	Rad
 product ATI RADEON_HD3650	0x9598	Radeon HD3650
 product ATI RADEON_HD3400_M82	0x95c4	Mobility Radeon HD 3400 Series (M82)
 product ATI RADEON_HD4250_S	0x95c5	Radeon HD4250 GPU (RV610) Secondary
-product ATI RADEON_HD6520G	0x9647	Radeon HD6520G
+product ATI RS780_HDMI_AUDIO	0x960f	RS780 HDMI Audio
+product ATI RADEON_HD3200	0x9610	Radeon HD 3200
+product ATI RADEON_HD3100	0x9611	Radeon HD 3100
+product ATI RADEON_HD3200M	0x9612	Mobility Radeon HD 3200
+product ATI RADEON_3100		0x9613	Mobility Radeon 3100
+product ATI RADEON_HD3300	0x9614	Radeon HD 3300
+product ATI RADEON_HD6550D	0x9640	Radeon HD 6550D
+product ATI RADEON_HD6620G	0x9641	Radeon HD 6620G
+product ATI RADEON_HD6370D	0x9642	Radeon HD 6370D
+product ATI RADEON_HD6380G	0x9643	Radeon HD 6380G
+product ATI RADEON_HD6410D_1	0x9644	Radeon HD 6410D
+product ATI RADEON_HD6410D_2	0x9645	Radeon HD 6410D
+product ATI RADEON_HD6520G	0x9647	Radeon HD 6520G
+product ATI RADEON_HD6480G_1	0x9648	Radeon HD 6480G
+product ATI RADEON_HD6480G_2	0x9649	Radeon HD 6480G
+product ATI RADEON_HD6530D	0x964a	Radeon HD 6530D
 product ATI RADEON_HD4200	0x9712	Radeon HD4200 Mobility
 product ATI RADEON_HD4250	0x9715	Radeon HD4250 GPU (RS880)
 product ATI RADEON_HD6310	0x9802	Radeon HD6310 Graphics
@@ -1557,6 +1592,8 @@ product ATI RADEON_HD34XX_HDA	0xaa28	Rad
 product ATI RADEON_HD4350_HD	0xaa38	Radeon HD4350 HD Audio Controller
 product ATI RADEON_HD5600_HDMI	0xaa60	Redwood HDMI Audio
 product ATI RADEON_HD54XX_HDA	0xaa68	Radeon HD 54xx Audio
+product ATI RADEON_HD7700_HDA	0xaab0	Radeon HD 7700 HD Audio
+product ATI RADEON_RX460_HDA	0xaae0	Radeon RX460 HD Audio
 
 /* Auravision products */
 product AURAVISION VXP524	0x01f7	VxP524 PCI Video Processor



CVS commit: src/sys/net

2016-12-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Dec 27 13:49:58 UTC 2016

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

Log Message:
Another missed patch


To generate a diff of this commit:
cvs rdiff -u -r1.164 -r1.165 src/sys/net/if_spppsubr.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_spppsubr.c
diff -u src/sys/net/if_spppsubr.c:1.164 src/sys/net/if_spppsubr.c:1.165
--- src/sys/net/if_spppsubr.c:1.164	Mon Dec 26 18:21:49 2016
+++ src/sys/net/if_spppsubr.c	Tue Dec 27 08:49:58 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_spppsubr.c,v 1.164 2016/12/26 23:21:49 christos Exp $	 */
+/*	$NetBSD: if_spppsubr.c,v 1.165 2016/12/27 13:49:58 christos Exp $	 */
 
 /*
  * Synchronous PPP/Cisco link level subroutines.
@@ -41,7 +41,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.164 2016/12/26 23:21:49 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.165 2016/12/27 13:49:58 christos Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -5372,8 +5372,7 @@ sppp_clear_ip_addrs_work(struct work *wk
 			ifp->if_xname, __func__, error);
 		}
 		if (!error) {
-			(void)pfil_run_hooks(if_pfil,
-			(struct mbuf **)SIOCAIFADDR, ifp, PFIL_IFADDR);
+			pfil_run_addrhooks(if_pfil, SIOCAIFADDR, ifa);
 		}
 	}
 



CVS commit: src/usr.sbin/npf/npfctl

2016-12-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Dec 27 13:43:38 UTC 2016

Modified Files:
src/usr.sbin/npf/npfctl: npfctl.c

Log Message:
We don't use openssl for NPF in NetBSD, so don't include the header, and
provide a compatibility define.


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/usr.sbin/npf/npfctl/npfctl.c

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

Modified files:

Index: src/usr.sbin/npf/npfctl/npfctl.c
diff -u src/usr.sbin/npf/npfctl/npfctl.c:1.48 src/usr.sbin/npf/npfctl/npfctl.c:1.49
--- src/usr.sbin/npf/npfctl/npfctl.c:1.48	Mon Dec 26 18:05:05 2016
+++ src/usr.sbin/npf/npfctl/npfctl.c	Tue Dec 27 08:43:38 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: npfctl.c,v 1.48 2016/12/26 23:05:05 christos Exp $	*/
+/*	$NetBSD: npfctl.c,v 1.49 2016/12/27 13:43:38 christos Exp $	*/
 
 /*-
  * Copyright (c) 2009-2014 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: npfctl.c,v 1.48 2016/12/26 23:05:05 christos Exp $");
+__RCSID("$NetBSD: npfctl.c,v 1.49 2016/12/27 13:43:38 christos Exp $");
 
 #include 
 #include 
@@ -39,6 +39,9 @@ __RCSID("$NetBSD: npfctl.c,v 1.48 2016/1
 #include 
 #include 
 #include 
+#define SHA_DIGEST_LENGTH SHA1_DIGEST_LENGTH
+#else
+#include 
 #endif
 
 #include 
@@ -50,7 +53,6 @@ __RCSID("$NetBSD: npfctl.c,v 1.48 2016/1
 #include 
 
 #include 
-#include 
 
 #include "npfctl.h"
 
@@ -389,8 +391,8 @@ npfctl_parse_rule(int argc, char **argv)
 }
 
 #ifdef __NetBSD__
-unsigned char *
-SHA1(const unsigned char *d, unsigned long l, unsigned char *md)
+static unsigned char *
+SHA1(const unsigned char *d, size_t l, unsigned char *md)
 {
 	SHA1_CTX c;
 



CVS commit: src/libexec/httpd/testsuite

2016-12-27 Thread Amitai Schleier
Module Name:src
Committed By:   schmonz
Date:   Tue Dec 27 12:09:19 UTC 2016

Modified Files:
src/libexec/httpd/testsuite: html_cmp test-simple

Log Message:
When testing non-verbosely, show diff on failure. ok mrg@


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/libexec/httpd/testsuite/html_cmp
cvs rdiff -u -r1.2 -r1.3 src/libexec/httpd/testsuite/test-simple

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

Modified files:

Index: src/libexec/httpd/testsuite/html_cmp
diff -u src/libexec/httpd/testsuite/html_cmp:1.4 src/libexec/httpd/testsuite/html_cmp:1.5
--- src/libexec/httpd/testsuite/html_cmp:1.4	Fri Nov 18 09:51:31 2011
+++ src/libexec/httpd/testsuite/html_cmp	Tue Dec 27 12:09:19 2016
@@ -2,12 +2,20 @@
 #
 #	$eterna: html_cmp,v 1.9 2011/11/17 22:18:02 mrg Exp $
 #
-# like cmp(1) but compares to files after making their `Date: ' headers
-# the same, to allow `now' and `then' to work properly.  it also tries
-# to find servername's that might be the local host and converts those
-# as well..
+# like cmp(1)/diff(1) but compares to files after making their
+# `Date: ' headers the same, to allow `now' and `then' to work properly.
+# it also tries to find servername's that might be the local host and
+# converts those as well..
 #
-# it must be called like `cmp file1 file1' *only*.  
+# it must be called like `html_cmp cmp|diff file1 file1' *only*.
+
+if [ "cmp" = "$1" ]; then
+	cmd="cmp -s"
+elif [ "diff" = "$1" ]; then
+	cmd="diff -u"
+else
+	exit 77
+fi
 
 h=`hostname || uname -n`
 
@@ -17,10 +25,10 @@ sedcmd="s/^Date: .*/Date: nowish/;
 	s/^Server: .*/^Server: bozotic HTTP server version 5.08/;
 	s/^Content-Length: .*/Content-Length: 223/;"
 
-sed -e "$sedcmd" < "$1" > "f1.tmp.$$"
-sed -e "$sedcmd" < "$2" > "f2.tmp.$$"
+sed -e "$sedcmd" < "$2" > "f1.tmp.$$"
+sed -e "$sedcmd" < "$3" > "f2.tmp.$$"
 
-cmp -s "f1.tmp.$$" "f2.tmp.$$"
+${cmd} "f1.tmp.$$" "f2.tmp.$$"
 rv=$?
 rm -f "f1.tmp.$$" "f2.tmp.$$"
 

Index: src/libexec/httpd/testsuite/test-simple
diff -u src/libexec/httpd/testsuite/test-simple:1.2 src/libexec/httpd/testsuite/test-simple:1.3
--- src/libexec/httpd/testsuite/test-simple:1.2	Mon Sep 26 00:21:22 2016
+++ src/libexec/httpd/testsuite/test-simple	Tue Dec 27 12:09:19 2016
@@ -1,5 +1,5 @@
 #! /bin/sh
-# $NetBSD: test-simple,v 1.2 2016/09/26 00:21:22 schmonz Exp $
+# $NetBSD: test-simple,v 1.3 2016/12/27 12:09:19 schmonz Exp $
 
 test="$1"
 bozohttpd="$2"
@@ -15,9 +15,9 @@ fi
 bozotestport=1
 
 ${bozohttpd} ${datadir} < $test.in > tmp.$test.out
-if ./html_cmp $test.out tmp.$test.out; then
+if ./html_cmp cmp $test.out tmp.$test.out; then
 	exit 0
 else
-	[ "yes" = "$verbose" ] || echo "Failed test $test: `cat tmp.$test.err; echo; cat $test.out`"
+	[ "yes" = "$verbose" ] || echo "Failed test $test: `cat tmp.$test.err; echo; ./html_cmp diff $test.out tmp.$test.out`"
 	exit 1
 fi



CVS commit: src/sys/kern

2016-12-27 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue Dec 27 11:59:36 UTC 2016

Modified Files:
src/sys/kern: vfs_vnode.c

Log Message:
It is wrong to block the vnode during vcache_rekey.  The vnode may be looked
up using the old key until vcache_rekey_exit changes the key to the new one.

Add an assertion that the temporary key is different from the current one.


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/sys/kern/vfs_vnode.c

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

Modified files:

Index: src/sys/kern/vfs_vnode.c
diff -u src/sys/kern/vfs_vnode.c:1.64 src/sys/kern/vfs_vnode.c:1.65
--- src/sys/kern/vfs_vnode.c:1.64	Tue Dec 20 10:02:21 2016
+++ src/sys/kern/vfs_vnode.c	Tue Dec 27 11:59:36 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_vnode.c,v 1.64 2016/12/20 10:02:21 hannken Exp $	*/
+/*	$NetBSD: vfs_vnode.c,v 1.65 2016/12/27 11:59:36 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1997-2011 The NetBSD Foundation, Inc.
@@ -156,7 +156,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.64 2016/12/20 10:02:21 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.65 2016/12/27 11:59:36 hannken Exp $");
 
 #include 
 #include 
@@ -1305,7 +1305,7 @@ vcache_new(struct mount *mp, struct vnod
 }
 
 /*
- * Prepare key change: lock old and new cache node.
+ * Prepare key change: update old cache nodes key and lock new cache node.
  * Return an error if the new node already exists.
  */
 int
@@ -1345,20 +1345,18 @@ vcache_rekey_enter(struct mount *mp, str
 	SLIST_INSERT_HEAD([new_hash & vcache.hashmask],
 	new_node, vi_hash);
 
-	/* Lock old node. */
+	/* Replace old nodes key with the temporary copy. */
 	node = vcache_hash_lookup(_vcache_key, old_hash);
 	KASSERT(node != NULL);
 	KASSERT(VIMPL_TO_VNODE(node) == vp);
-	mutex_enter(vp->v_interlock);
-	VSTATE_CHANGE(vp, VS_ACTIVE, VS_BLOCKED);
+	KASSERT(node->vi_key.vk_key != old_vcache_key.vk_key);
 	node->vi_key = old_vcache_key;
-	mutex_exit(vp->v_interlock);
 	mutex_exit();
 	return 0;
 }
 
 /*
- * Key change complete: remove old node and unlock new node.
+ * Key change complete: update old node and remove placeholder.
  */
 void
 vcache_rekey_exit(struct mount *mp, struct vnode *vp,
@@ -1386,8 +1384,6 @@ vcache_rekey_exit(struct mount *mp, stru
 	old_node = vcache_hash_lookup(_vcache_key, old_hash);
 	KASSERT(old_node != NULL);
 	KASSERT(VIMPL_TO_VNODE(old_node) == vp);
-	mutex_enter(vp->v_interlock);
-	VSTATE_ASSERT(vp, VS_BLOCKED);
 
 	new_node = vcache_hash_lookup(_vcache_key, new_hash);
 	KASSERT(new_node != NULL);
@@ -1404,8 +1400,6 @@ vcache_rekey_exit(struct mount *mp, stru
 		SLIST_INSERT_HEAD([new_hash & vcache.hashmask],
 		old_node, vi_hash);
 	}
-	VSTATE_CHANGE(vp, VS_BLOCKED, VS_ACTIVE);
-	mutex_exit(vp->v_interlock);
 
 	/* Remove new node used as placeholder. */
 	SLIST_REMOVE([new_hash & vcache.hashmask],



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

2016-12-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Dec 27 11:37:36 UTC 2016

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

Log Message:
WIP MPification


To generate a diff of this commit:
cvs rdiff -u -r1.9.4.11 -r1.9.4.12 src/sys/dev/usb/if_urndis.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_urndis.c
diff -u src/sys/dev/usb/if_urndis.c:1.9.4.11 src/sys/dev/usb/if_urndis.c:1.9.4.12
--- src/sys/dev/usb/if_urndis.c:1.9.4.11	Mon Dec  5 10:55:18 2016
+++ src/sys/dev/usb/if_urndis.c	Tue Dec 27 11:37:36 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_urndis.c,v 1.9.4.11 2016/12/05 10:55:18 skrll Exp $ */
+/*	$NetBSD: if_urndis.c,v 1.9.4.12 2016/12/27 11:37:36 skrll Exp $ */
 /*	$OpenBSD: if_urndis.c,v 1.31 2011/07/03 15:47:17 matthew Exp $ */
 
 /*
@@ -21,7 +21,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_urndis.c,v 1.9.4.11 2016/12/05 10:55:18 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_urndis.c,v 1.9.4.12 2016/12/27 11:37:36 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -75,13 +75,18 @@ static void urndis_watchdog(struct ifnet
 #endif
 
 static void urndis_start(struct ifnet *);
+static void urndis_start_locked(struct ifnet *);
 static void urndis_rxeof(struct usbd_xfer *, void *, usbd_status);
 static void urndis_txeof(struct usbd_xfer *, void *, usbd_status);
 static int urndis_rx_list_init(struct urndis_softc *);
+static void urndis_rx_list_free(struct urndis_softc *);
 static int urndis_tx_list_init(struct urndis_softc *);
+static void urndis_tx_list_free(struct urndis_softc *);
 
 static int urndis_init(struct ifnet *);
+static int urndis_init_locked(struct ifnet *);
 static void urndis_stop(struct ifnet *);
+static void urndis_stop_locked(struct ifnet *);
 
 static usbd_status urndis_ctrl_msg(struct urndis_softc *, uint8_t, uint8_t,
 uint16_t, uint16_t, void *, size_t);
@@ -879,7 +884,7 @@ urndis_decap(struct urndis_softc *sc, st
 
 			bpf_mtap(ifp, m);
 
-			if_percpuq_enqueue(ifp->if_percpuq, m);
+			if_percpuq_enqueue(sc->urndis_ipq, m);
 		}
 		splx(s);
 
@@ -941,6 +946,21 @@ urndis_rx_list_init(struct urndis_softc 
 	return 0;
 }
 
+static void
+urndis_rx_list_free(struct urndis_softc *sc)
+{
+	for (int i = 0; i < RNDIS_RX_LIST_CNT; i++) {
+		if (sc->sc_data.sc_rx_chain[i].sc_mbuf != NULL) {
+			m_freem(sc->sc_data.sc_rx_chain[i].sc_mbuf);
+			sc->sc_data.sc_rx_chain[i].sc_mbuf = NULL;
+		}
+		if (sc->sc_data.sc_rx_chain[i].sc_xfer != NULL) {
+			usbd_destroy_xfer(sc->sc_data.sc_rx_chain[i].sc_xfer);
+			sc->sc_data.sc_rx_chain[i].sc_xfer = NULL;
+		}
+	}
+}
+
 static int
 urndis_tx_list_init(struct urndis_softc *sc)
 {
@@ -965,6 +985,21 @@ urndis_tx_list_init(struct urndis_softc 
 	return 0;
 }
 
+static void
+urndis_tx_list_free(struct urndis_softc *sc)
+{
+	for (int i = 0; i < RNDIS_TX_LIST_CNT; i++) {
+		if (sc->sc_data.sc_tx_chain[i].sc_mbuf != NULL) {
+			m_freem(sc->sc_data.sc_tx_chain[i].sc_mbuf);
+			sc->sc_data.sc_tx_chain[i].sc_mbuf = NULL;
+		}
+		if (sc->sc_data.sc_tx_chain[i].sc_xfer != NULL) {
+			usbd_destroy_xfer(sc->sc_data.sc_tx_chain[i].sc_xfer);
+			sc->sc_data.sc_tx_chain[i].sc_xfer = NULL;
+		}
+	}
+}
+
 static int
 urndis_ioctl(struct ifnet *ifp, unsigned long command, void *data)
 {
@@ -979,24 +1014,7 @@ urndis_ioctl(struct ifnet *ifp, unsigned
 
 	s = splnet();
 
-	switch(command) {
-	case SIOCSIFFLAGS:
-		if ((error = ifioctl_common(ifp, command, data)) != 0)
-			break;
-		if (ifp->if_flags & IFF_UP) {
-			if (!(ifp->if_flags & IFF_RUNNING))
-urndis_init(ifp);
-		} else {
-			if (ifp->if_flags & IFF_RUNNING)
-urndis_stop(ifp);
-		}
-		error = 0;
-		break;
-
-	default:
-		error = ether_ioctl(ifp, command, data);
-		break;
-	}
+	error = ether_ioctl(ifp, command, data);
 
 	if (error == ENETRESET)
 		error = 0;
@@ -1026,8 +1044,20 @@ urndis_watchdog(struct ifnet *ifp)
 static int
 urndis_init(struct ifnet *ifp)
 {
+	struct urndis_softc *sc = ifp->if_softc;
+
+	mutex_enter(>urndis_lock);
+	int ret = urndis_init_locked(ifp);
+	mutex_exit(>urndis_lock);
+
+	return ret;
+}
+
+static int
+urndis_init_locked(struct ifnet *ifp)
+{
 	struct urndis_softc	*sc;
-	int			 i, s;
+	int			 i;
 	int 			 err;
 	usbd_status		 usberr;
 
@@ -1040,15 +1070,12 @@ urndis_init(struct ifnet *ifp)
 	if (err != RNDIS_STATUS_SUCCESS)
 		return EIO;
 
-	s = splnet();
-
 	usberr = usbd_open_pipe(sc->sc_iface_data, sc->sc_bulkin_no,
 	USBD_EXCLUSIVE_USE, >sc_bulkin_pipe);
 	if (usberr) {
 		printf("%s: open rx pipe failed: %s\n", DEVNAME(sc),
 		usbd_errstr(err));
-		splx(s);
-		return EIO;
+		goto fail;
 	}
 
 	usberr = usbd_open_pipe(sc->sc_iface_data, sc->sc_bulkout_no,
@@ -1056,24 +1083,21 @@ urndis_init(struct ifnet *ifp)
 	if (usberr) {
 		printf("%s: open tx pipe failed: %s\n", DEVNAME(sc),
 		usbd_errstr(err));
-		splx(s);
-		return EIO;
+		goto fail2;
 	}
 
 	err = urndis_tx_list_init(sc);
 	if (err) {
 		

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

2016-12-27 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Dec 27 11:17:51 UTC 2016

Modified Files:
src/sys/dev/pci/ixgbe: ixgbe_x550.c

Log Message:
 Fix DEBUGFUNC() output in ixgbe_disable_rx_x550().


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/pci/ixgbe/ixgbe_x550.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/ixgbe_x550.c
diff -u src/sys/dev/pci/ixgbe/ixgbe_x550.c:1.3 src/sys/dev/pci/ixgbe/ixgbe_x550.c:1.4
--- src/sys/dev/pci/ixgbe/ixgbe_x550.c:1.3	Mon Dec  5 08:50:29 2016
+++ src/sys/dev/pci/ixgbe/ixgbe_x550.c	Tue Dec 27 11:17:51 2016
@@ -2645,7 +2645,7 @@ void ixgbe_disable_rx_x550(struct ixgbe_
 	s32 status;
 	struct ixgbe_hic_disable_rxen fw_cmd;
 
-	DEBUGFUNC("ixgbe_enable_rx_dma_x550");
+	DEBUGFUNC("ixgbe_disable_rx_dma_x550");
 
 	rxctrl = IXGBE_READ_REG(hw, IXGBE_RXCTRL);
 	if (rxctrl & IXGBE_RXCTRL_RXEN) {



CVS commit: src/sys/ufs/ffs

2016-12-27 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue Dec 27 10:54:38 UTC 2016

Modified Files:
src/sys/ufs/ffs: ffs_vfsops.c

Log Message:
Fix a bug introduced with Rev. 1.294:  use LK_NOWAIT when called with MNT_LAZY.


To generate a diff of this commit:
cvs rdiff -u -r1.341 -r1.342 src/sys/ufs/ffs/ffs_vfsops.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/ufs/ffs/ffs_vfsops.c
diff -u src/sys/ufs/ffs/ffs_vfsops.c:1.341 src/sys/ufs/ffs/ffs_vfsops.c:1.342
--- src/sys/ufs/ffs/ffs_vfsops.c:1.341	Thu Oct 20 19:31:32 2016
+++ src/sys/ufs/ffs/ffs_vfsops.c	Tue Dec 27 10:54:38 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_vfsops.c,v 1.341 2016/10/20 19:31:32 jdolecek Exp $	*/
+/*	$NetBSD: ffs_vfsops.c,v 1.342 2016/12/27 10:54:38 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.341 2016/10/20 19:31:32 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.342 2016/12/27 10:54:38 hannken Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -1917,7 +1917,8 @@ ffs_sync(struct mount *mp, int waitfor, 
 	ctx.is_suspending = is_suspending;
 	while ((vp = vfs_vnode_iterator_next(marker, ffs_sync_selector, )))
 	{
-		error = vn_lock(vp, LK_EXCLUSIVE);
+		error = vn_lock(vp,
+		LK_EXCLUSIVE | (waitfor == MNT_LAZY ? LK_NOWAIT : 0));
 		if (error) {
 			vrele(vp);
 			continue;



CVS commit: src/sys

2016-12-27 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Tue Dec 27 10:53:12 UTC 2016

Modified Files:
src/sys/netinet: in.c
src/sys/netinet6: in6.c

Log Message:
Fix panic in pfil_run_hooks on bootup

XXX a kernel with pf still fails to boot up. Please someone fix it.


To generate a diff of this commit:
cvs rdiff -u -r1.192 -r1.193 src/sys/netinet/in.c
cvs rdiff -u -r1.226 -r1.227 src/sys/netinet6/in6.c

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

Modified files:

Index: src/sys/netinet/in.c
diff -u src/sys/netinet/in.c:1.192 src/sys/netinet/in.c:1.193
--- src/sys/netinet/in.c:1.192	Mon Dec 26 00:30:07 2016
+++ src/sys/netinet/in.c	Tue Dec 27 10:53:11 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: in.c,v 1.192 2016/12/26 00:30:07 knakahara Exp $	*/
+/*	$NetBSD: in.c,v 1.193 2016/12/27 10:53:11 ozaki-r Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -91,7 +91,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: in.c,v 1.192 2016/12/26 00:30:07 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in.c,v 1.193 2016/12/27 10:53:11 ozaki-r Exp $");
 
 #include "arp.h"
 
@@ -705,8 +705,7 @@ in_control0(struct socket *so, u_long cm
 
 	if (error == 0) {
 		if (run_hook)
-			(void)pfil_run_hooks(if_pfil,
-			(struct mbuf **)cmd, ifp, PFIL_IFADDR);
+			pfil_run_addrhooks(if_pfil, cmd, iatoifa(ia));
 	} else if (newifaddr) {
 		KASSERT(ia != NULL);
 		in_purgeaddr(>ia_ifa);

Index: src/sys/netinet6/in6.c
diff -u src/sys/netinet6/in6.c:1.226 src/sys/netinet6/in6.c:1.227
--- src/sys/netinet6/in6.c:1.226	Wed Dec 21 08:47:02 2016
+++ src/sys/netinet6/in6.c	Tue Dec 27 10:53:12 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: in6.c,v 1.226 2016/12/21 08:47:02 ozaki-r Exp $	*/
+/*	$NetBSD: in6.c,v 1.227 2016/12/27 10:53:12 ozaki-r Exp $	*/
 /*	$KAME: in6.c,v 1.198 2001/07/18 09:12:38 itojun Exp $	*/
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.226 2016/12/21 08:47:02 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.227 2016/12/27 10:53:12 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -719,10 +719,9 @@ in6_control1(struct socket *so, u_long c
 		error = ENOTTY;
 	}
 release:
-	ia6_release(ia, );
-
 	if (run_hooks)
-		pfil_run_hooks(if_pfil, (struct mbuf **)cmd, ifp, PFIL_IFADDR);
+		pfil_run_addrhooks(if_pfil, cmd, (struct ifaddr *)ia);
+	ia6_release(ia, );
 out:
 	curlwp_bindx(bound);
 	return error;



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

2016-12-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Dec 27 10:37:52 UTC 2016

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

Log Message:
Reduce scope of variables


To generate a diff of this commit:
cvs rdiff -u -r1.234.2.106 -r1.234.2.107 src/sys/dev/usb/ehci.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/ehci.c
diff -u src/sys/dev/usb/ehci.c:1.234.2.106 src/sys/dev/usb/ehci.c:1.234.2.107
--- src/sys/dev/usb/ehci.c:1.234.2.106	Tue Dec 27 10:16:49 2016
+++ src/sys/dev/usb/ehci.c	Tue Dec 27 10:37:52 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ehci.c,v 1.234.2.106 2016/12/27 10:16:49 skrll Exp $ */
+/*	$NetBSD: ehci.c,v 1.234.2.107 2016/12/27 10:37:52 skrll Exp $ */
 
 /*
  * Copyright (c) 2004-2012 The NetBSD Foundation, Inc.
@@ -53,7 +53,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.234.2.106 2016/12/27 10:16:49 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.234.2.107 2016/12/27 10:37:52 skrll Exp $");
 
 #include "ohci.h"
 #include "uhci.h"
@@ -3392,18 +3392,17 @@ done:
 Static void
 ehci_timeout(void *addr)
 {
+	EHCIHIST_FUNC(); EHCIHIST_CALLED();
 	struct usbd_xfer *xfer = addr;
-	struct usbd_pipe *pipe = xfer->ux_pipe;
-	struct usbd_device *dev = pipe->up_dev;
 	ehci_softc_t *sc = EHCI_XFER2SC(xfer);
 	bool timeout = false;
 
-	EHCIHIST_FUNC(); EHCIHIST_CALLED();
-
 	DPRINTF("xfer %p", xfer, 0, 0, 0);
 #ifdef EHCI_DEBUG
-	if (ehcidebug >= 2)
+	if (ehcidebug >= 2) {
+		struct usbd_pipe *pipe = xfer->ux_pipe;
 		usbd_dump_pipe(pipe);
+	}
 #endif
 
 	mutex_enter(>sc_lock);
@@ -3418,6 +3417,8 @@ ehci_timeout(void *addr)
 	mutex_exit(>sc_lock);
 
 	if (timeout) {
+		struct usbd_device *dev = xfer->ux_pipe->up_dev;
+
 		/* Execute the abort in a process context. */
 		usb_init_task(>ux_aborttask, ehci_timeout_task, xfer,
 		USB_TASKQ_MPSAFE);



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

2016-12-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Dec 27 10:24:00 UTC 2016

Modified Files:
src/sys/dev/usb [nick-nhusb]: ehcivar.h

Log Message:
Missed commit in the ehci abort improvement


To generate a diff of this commit:
cvs rdiff -u -r1.42.14.26 -r1.42.14.27 src/sys/dev/usb/ehcivar.h

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

Modified files:

Index: src/sys/dev/usb/ehcivar.h
diff -u src/sys/dev/usb/ehcivar.h:1.42.14.26 src/sys/dev/usb/ehcivar.h:1.42.14.27
--- src/sys/dev/usb/ehcivar.h:1.42.14.26	Sat Apr 30 10:34:14 2016
+++ src/sys/dev/usb/ehcivar.h	Tue Dec 27 10:24:00 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ehcivar.h,v 1.42.14.26 2016/04/30 10:34:14 skrll Exp $ */
+/*	$NetBSD: ehcivar.h,v 1.42.14.27 2016/12/27 10:24:00 skrll Exp $ */
 
 /*
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -164,6 +164,7 @@ typedef struct ehci_softc {
 	device_t sc_dev;
 	kmutex_t sc_lock;
 	kmutex_t sc_intr_lock;
+	bool sc_dbanswered;
 	kcondvar_t sc_doorbell;
 	void *sc_doorbell_si;
 	void *sc_pcd_si;
@@ -210,8 +211,6 @@ typedef struct ehci_softc {
 	uint8_t sc_istthreshold;	/* ISOC Scheduling Threshold (uframes) */
 	struct usbd_xfer *sc_intrxfer;
 	char sc_isreset[EHCI_MAX_PORTS];
-	char sc_softwake;
-	kcondvar_t sc_softwake_cv;
 
 	uint32_t sc_eintrs;
 	ehci_soft_qh_t *sc_async_head;



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

2016-12-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Dec 27 10:16:49 UTC 2016

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

Log Message:
Remove a printf


To generate a diff of this commit:
cvs rdiff -u -r1.234.2.105 -r1.234.2.106 src/sys/dev/usb/ehci.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/ehci.c
diff -u src/sys/dev/usb/ehci.c:1.234.2.105 src/sys/dev/usb/ehci.c:1.234.2.106
--- src/sys/dev/usb/ehci.c:1.234.2.105	Tue Dec 27 08:59:48 2016
+++ src/sys/dev/usb/ehci.c	Tue Dec 27 10:16:49 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ehci.c,v 1.234.2.105 2016/12/27 08:59:48 skrll Exp $ */
+/*	$NetBSD: ehci.c,v 1.234.2.106 2016/12/27 10:16:49 skrll Exp $ */
 
 /*
  * Copyright (c) 2004-2012 The NetBSD Foundation, Inc.
@@ -53,7 +53,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.234.2.105 2016/12/27 08:59:48 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.234.2.106 2016/12/27 10:16:49 skrll Exp $");
 
 #include "ohci.h"
 #include "uhci.h"
@@ -3239,7 +3239,6 @@ ehci_abort_xfer(struct usbd_xfer *xfer, 
 	sqtd = sqtd->nextqtd;
 	/* Zap curqtd register if hardware pointed inside the xfer. */
 	if (hit && sqtd != NULL) {
-printf("%s: hit!\n", __func__);
 		DPRINTF("cur=0x%08x", sqtd->physaddr, 0, 0, 0);
 		sqh->qh.qh_curqtd = htole32(sqtd->physaddr); /* unlink qTDs */
 		usb_syncmem(>dma,



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

2016-12-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Dec 27 10:09:24 UTC 2016

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

Log Message:
Stray #endif


To generate a diff of this commit:
cvs rdiff -u -r1.12.2.31 -r1.12.2.32 src/sys/dev/usb/motg.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/motg.c
diff -u src/sys/dev/usb/motg.c:1.12.2.31 src/sys/dev/usb/motg.c:1.12.2.32
--- src/sys/dev/usb/motg.c:1.12.2.31	Tue Dec 27 08:49:29 2016
+++ src/sys/dev/usb/motg.c	Tue Dec 27 10:09:24 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: motg.c,v 1.12.2.31 2016/12/27 08:49:29 skrll Exp $	*/
+/*	$NetBSD: motg.c,v 1.12.2.32 2016/12/27 10:09:24 skrll Exp $	*/
 
 /*
  * Copyright (c) 1998, 2004, 2011, 2012, 2014 The NetBSD Foundation, Inc.
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: motg.c,v 1.12.2.31 2016/12/27 08:49:29 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: motg.c,v 1.12.2.32 2016/12/27 10:09:24 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_motg.h"
@@ -2090,7 +2090,6 @@ complete:
 	KASSERTMSG(xfer && xfer->ux_status == USBD_IN_PROGRESS && 
 	ep->phase == DATA_OUT, "xfer %p status %d phase %d",
 	xfer, xfer->ux_status, ep->phase);
-#endif
 	ep->phase = IDLE;
 	ep->xfer = NULL;
 	if (xfer && xfer->ux_status == USBD_IN_PROGRESS) {



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

2016-12-27 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Dec 27 10:01:39 UTC 2016

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

Log Message:
  Fix flow control setting sysctl. I don't know why disabling autonego when
the flow control parameter is changed. Now the ixgN.fc sysctl works as
expected.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/sys/dev/pci/ixgbe/ixgbe.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/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.55 src/sys/dev/pci/ixgbe/ixgbe.c:1.56
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.55	Fri Dec 16 08:41:01 2016
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Tue Dec 27 10:01:39 2016
@@ -59,7 +59,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 /*$FreeBSD: head/sys/dev/ixgbe/if_ix.c 302384 2016-07-07 03:39:18Z sbruno $*/
-/*$NetBSD: ixgbe.c,v 1.55 2016/12/16 08:41:01 msaitoh Exp $*/
+/*$NetBSD: ixgbe.c,v 1.56 2016/12/27 10:01:39 msaitoh Exp $*/
 
 #include "opt_inet.h"
 #include "opt_inet6.h"
@@ -4987,8 +4987,10 @@ ixgbe_set_flowcntl(struct adapter *adapt
 			return (EINVAL);
 	}
 	adapter->fc = fc;
+#if 0 /* XXX NetBSD */
 	/* Don't autoneg if forcing a value */
 	adapter->hw.fc.disable_fc_autoneg = TRUE;
+#endif
 	ixgbe_fc_enable(>hw);
 	return (0);
 }



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

2016-12-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Dec 27 08:59:48 UTC 2016

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

Log Message:
Improve and simplify ehci_abort_xfer.  The races should now be removed.


To generate a diff of this commit:
cvs rdiff -u -r1.234.2.104 -r1.234.2.105 src/sys/dev/usb/ehci.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/ehci.c
diff -u src/sys/dev/usb/ehci.c:1.234.2.104 src/sys/dev/usb/ehci.c:1.234.2.105
--- src/sys/dev/usb/ehci.c:1.234.2.104	Wed Oct  5 20:55:57 2016
+++ src/sys/dev/usb/ehci.c	Tue Dec 27 08:59:48 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ehci.c,v 1.234.2.104 2016/10/05 20:55:57 skrll Exp $ */
+/*	$NetBSD: ehci.c,v 1.234.2.105 2016/12/27 08:59:48 skrll Exp $ */
 
 /*
  * Copyright (c) 2004-2012 The NetBSD Foundation, Inc.
@@ -53,7 +53,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.234.2.104 2016/10/05 20:55:57 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.234.2.105 2016/12/27 08:59:48 skrll Exp $");
 
 #include "ohci.h"
 #include "uhci.h"
@@ -412,8 +412,7 @@ ehci_init(ehci_softc_t *sc)
 
 	mutex_init(>sc_lock, MUTEX_DEFAULT, IPL_SOFTUSB);
 	mutex_init(>sc_intr_lock, MUTEX_DEFAULT, IPL_USB);
-	cv_init(>sc_softwake_cv, "ehciab");
-	cv_init(>sc_doorbell, "ehcidi");
+	cv_init(>sc_doorbell, "ehcidb");
 
 	sc->sc_xferpool = pool_cache_init(sizeof(struct ehci_xfer), 0, 0, 0,
 	"ehcixfer", NULL, IPL_USB, NULL, NULL, NULL);
@@ -751,8 +750,10 @@ Static void
 ehci_doorbell(void *addr)
 {
 	ehci_softc_t *sc = addr;
+	EHCIHIST_FUNC(); EHCIHIST_CALLED();
 
 	mutex_enter(>sc_lock);
+	sc->sc_dbanswered = true;
 	cv_broadcast(>sc_doorbell);
 	mutex_exit(>sc_lock);
 }
@@ -853,11 +854,6 @@ ehci_softintr(void *v)
 	!TAILQ_EMPTY(>sc_intrhead))
 		callout_reset(>sc_tmo_intrlist,
 		hz, ehci_intrlist_timeout, sc);
-
-	if (sc->sc_softwake) {
-		sc->sc_softwake = 0;
-		cv_broadcast(>sc_softwake_cv);
-	}
 }
 
 Static void
@@ -939,7 +935,6 @@ ehci_check_qh_intr(ehci_softc_t *sc, str
 	}
  done:
 	DPRINTFN(10, "ex=%p done", ex, 0, 0, 0);
-	callout_stop(>ex_xfer.ux_callout);
 	ehci_idone(ex, cq);
 }
 
@@ -985,7 +980,6 @@ ehci_check_itd_intr(ehci_softc_t *sc, st
 	return;
 done:
 	DPRINTF("ex %p done", ex, 0, 0, 0);
-	callout_stop(>ex_xfer.ux_callout);
 	ehci_idone(ex, cq);
 }
 
@@ -1023,7 +1017,6 @@ ehci_check_sitd_intr(ehci_softc_t *sc, s
 		return;
 
 	DPRINTFN(10, "ex=%p done", ex, 0, 0, 0);
-	callout_stop(&(ex->ex_xfer.ux_callout));
 	ehci_idone(ex, cq);
 }
 
@@ -1031,19 +1024,24 @@ ehci_check_sitd_intr(ehci_softc_t *sc, s
 Static void
 ehci_idone(struct ehci_xfer *ex, ex_completeq_t *cq)
 {
+	EHCIHIST_FUNC(); EHCIHIST_CALLED();
 	struct usbd_xfer *xfer = >ex_xfer;
 	struct ehci_pipe *epipe = EHCI_XFER2EPIPE(xfer);
 	struct ehci_softc *sc = EHCI_XFER2SC(xfer);
 	ehci_soft_qtd_t *sqtd, *fsqtd, *lsqtd;
 	uint32_t status = 0, nstatus = 0;
 	int actlen = 0;
+	bool polling = sc->sc_bus.ub_usepolling;
 
-	EHCIHIST_FUNC(); EHCIHIST_CALLED();
-
-	KASSERT(sc->sc_bus.ub_usepolling || mutex_owned(>sc_lock));
+	KASSERT(polling || mutex_owned(>sc_lock));
 
 	DPRINTF("ex=%p", ex, 0, 0, 0);
 
+	/*
+	 * Make sure the timeout handler didn't run or ran to the end
+	 * and set the transfer status.
+	 */
+	callout_halt(>ex_xfer.ux_callout, polling ? NULL : >sc_lock);
 	if (xfer->ux_status == USBD_CANCELLED ||
 	xfer->ux_status == USBD_TIMEOUT) {
 		DPRINTF("aborted xfer=%p", xfer, 0, 0, 0);
@@ -1332,7 +1330,6 @@ ehci_detach(struct ehci_softc *sc, int f
 		kmem_free(sc->sc_softitds,
 		sc->sc_flsize * sizeof(ehci_soft_itd_t *));
 	cv_destroy(>sc_doorbell);
-	cv_destroy(>sc_softwake_cv);
 
 #if 0
 	/* XXX destroyed in ehci_pci.c as it controls ehci_intr access */
@@ -2158,22 +2155,27 @@ ehci_sync_hc(ehci_softc_t *sc)
 		DPRINTF("dying", 0, 0, 0, 0);
 		return;
 	}
+
 	/* ask for doorbell */
 	EOWRITE4(sc, EHCI_USBCMD, EOREAD4(sc, EHCI_USBCMD) | EHCI_CMD_IAAD);
 	DPRINTF("cmd = 0x%08x sts = 0x%08x",
 	EOREAD4(sc, EHCI_USBCMD), EOREAD4(sc, EHCI_USBSTS), 0, 0);
 
-	error = cv_timedwait(>sc_doorbell, >sc_lock, hz); /* bell wait */
+	sc->sc_dbanswered = false;
+	/* bell wait */
+	while (!sc->sc_dbanswered) {
+		error = cv_timedwait(>sc_doorbell, >sc_lock, hz);
 
-	DPRINTF("cmd = 0x%08x sts = 0x%08x ... done",
-	EOREAD4(sc, EHCI_USBCMD), EOREAD4(sc, EHCI_USBSTS), 0, 0);
+		DPRINTF("cmd = 0x%08x sts = 0x%08x ... done",
+		EOREAD4(sc, EHCI_USBCMD), EOREAD4(sc, EHCI_USBSTS), 0, 0);
 #ifdef DIAGNOSTIC
-	if (error == EWOULDBLOCK) {
-		printf("ehci_sync_hc: timed out\n");
-	} else if (error) {
-		printf("ehci_sync_hc: cv_timedwait: error %d\n", error);
-	}
+		if (error == EWOULDBLOCK) {
+			printf("%s: timed out\n", __func__);
+		} else if (error) {
+			printf("%s: cv_timedwait: error %d\n", __func__, error);
+		}
 #endif
+	}
 }
 
 Static void
@@ -3095,16 +3097,19 @@ ehci_close_pipe(struct usbd_pipe *pipe, 
 }
 
 /*
- * Abort a device 

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

2016-12-27 Thread Felix Deichmann
Module Name:src
Committed By:   flxd
Date:   Tue Dec 27 08:56:00 UTC 2016

Modified Files:
src/sys/arch/vax/conf: GENERIC INSTALL VAX780

Log Message:
Fix TC adaptor's CSR address.
Add "PMAD" LANCE TC Ethernet.


To generate a diff of this commit:
cvs rdiff -u -r1.199 -r1.200 src/sys/arch/vax/conf/GENERIC
cvs rdiff -u -r1.71 -r1.72 src/sys/arch/vax/conf/INSTALL
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/vax/conf/VAX780

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/vax/conf/GENERIC
diff -u src/sys/arch/vax/conf/GENERIC:1.199 src/sys/arch/vax/conf/GENERIC:1.200
--- src/sys/arch/vax/conf/GENERIC:1.199	Tue Dec 13 20:42:21 2016
+++ src/sys/arch/vax/conf/GENERIC	Tue Dec 27 08:56:00 2016
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.199 2016/12/13 20:42:21 christos Exp $
+# $NetBSD: GENERIC,v 1.200 2016/12/27 08:56:00 flxd Exp $
 #
 # GENERIC machine description file
 # 
@@ -22,7 +22,7 @@ include		"arch/vax/conf/std.vax"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident 		"GENERIC-$Revision: 1.199 $"
+#ident 		"GENERIC-$Revision: 1.200 $"
 
 # Here are all different supported CPU types listed.
 #options 	VAX8800		# VAX 8500, 8530, 8550, 8700, 8800
@@ -211,11 +211,12 @@ audio*		at audiobus?
 
 spkr*		at audio?		# PC speaker (synthesized)
 
-tc0		at vsbus0 csr 0x3600 # VS4000/60 or 90 TC adapter
+tc0		at vsbus0 csr 0x3680 # VS4000/60 or 90 TC adapter
 tcds*		at tc0 slot ? offset ?	 # TC dual SCSI controller
 asc*		at tcds? chip ?		 # PMAZB/C
 asc*		at tc? slot ? offset ?	 # PMAZ 
 fta*		at tc? slot ? offset ?	 # TC FDDI controller
+le*		at tc? slot ? offset ?	 # PMAD
 
 hdc0		at vsbus0 csr 0x200c # HDC9224 MFM/floppy ctlr
 rd*		at hdc0 drive?		# RD5x disks

Index: src/sys/arch/vax/conf/INSTALL
diff -u src/sys/arch/vax/conf/INSTALL:1.71 src/sys/arch/vax/conf/INSTALL:1.72
--- src/sys/arch/vax/conf/INSTALL:1.71	Wed Aug 12 07:53:58 2015
+++ src/sys/arch/vax/conf/INSTALL	Tue Dec 27 08:56:00 2016
@@ -1,4 +1,4 @@
-#	$NetBSD: INSTALL,v 1.71 2015/08/12 07:53:58 maxv Exp $
+#	$NetBSD: INSTALL,v 1.72 2016/12/27 08:56:00 flxd Exp $
 #
 # INSTALL kernel; all supported devices but nothing fancy.
 #
@@ -157,11 +157,12 @@ smg0		at vsbus0 csr 0x200f # Small m
 #clr0		at vsbus0 csr 0x3000 # 4- or 8-bitplans color graphics
 spx0		at vsbus0 csr 0x3800 # Low Cost SPX on VS4000/90.
 #lcg0		at vsbus0 csr 0x21801000 # VS4000/60 (or VLC) graphics
-tc0		at vsbus0 csr 0x3600 # VS4000/60 or 90 TC adapter
+tc0		at vsbus0 csr 0x3680 # VS4000/60 or 90 TC adapter
 tcds*		at tc0 slot ? offset ?	 # TC dual SCSI controller
 asc*		at tcds? chip ?		 # PMAZB/C
 asc*		at tc? slot ? offset ?	 # PMAZ 
 fta*		at tc? slot ? offset ?	 # TC FDDI controller
+le*		at tc? slot ? offset ?	 # PMAD
 
 hdc0		at vsbus0 csr 0x200c # HDC9224 MFM/floppy ctlr
 rd*		at hdc0 drive?		# RD5x disks

Index: src/sys/arch/vax/conf/VAX780
diff -u src/sys/arch/vax/conf/VAX780:1.20 src/sys/arch/vax/conf/VAX780:1.21
--- src/sys/arch/vax/conf/VAX780:1.20	Sat Aug  8 06:36:26 2015
+++ src/sys/arch/vax/conf/VAX780	Tue Dec 27 08:56:00 2016
@@ -1,4 +1,4 @@
-# $NetBSD: VAX780,v 1.20 2015/08/08 06:36:26 maxv Exp $
+# $NetBSD: VAX780,v 1.21 2016/12/27 08:56:00 flxd Exp $
 #
 # 11/780,750,730 machine description file
 # 
@@ -188,11 +188,12 @@ ubi0		at mainbus0		# 11/730 direct unibu
 #clr0		at vsbus0 csr 0x3000 # 4- or 8-bitplans color graphics
 #spx0		at vsbus0 csr 0x3800 # Low Cost SPX on VS4000/90.
 #lcg0		at vsbus0 csr 0x21801000 # VS4000/60 (or VLC) graphics
-#tc0		at vsbus0 csr 0x3600 # VS4000/60 or 90 TC adapter
+#tc0		at vsbus0 csr 0x3680 # VS4000/60 or 90 TC adapter
 #tcds*		at tc0 slot ? offset ?	 # TC dual SCSI controller
 #asc*		at tcds? chip ?		 # PMAZB/C
 #asc*		at tc? slot ? offset ?	 # PMAZ 
 #fta*		at tc? slot ? offset ?	 # TC FDDI controller
+#le*		at tc? slot ? offset ?	 # PMAD
 
 #hdc0		at vsbus0 csr 0x200c # HDC9224 MFM/floppy ctlr
 #rd*		at hdc0 drive?		# RD5x disks



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

2016-12-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Dec 27 08:49:29 UTC 2016

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

Log Message:
#ifdef DIAGNOSTIC + panic -> KASSERTMSG


To generate a diff of this commit:
cvs rdiff -u -r1.12.2.30 -r1.12.2.31 src/sys/dev/usb/motg.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/motg.c
diff -u src/sys/dev/usb/motg.c:1.12.2.30 src/sys/dev/usb/motg.c:1.12.2.31
--- src/sys/dev/usb/motg.c:1.12.2.30	Sat Jul  9 20:25:15 2016
+++ src/sys/dev/usb/motg.c	Tue Dec 27 08:49:29 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: motg.c,v 1.12.2.30 2016/07/09 20:25:15 skrll Exp $	*/
+/*	$NetBSD: motg.c,v 1.12.2.31 2016/12/27 08:49:29 skrll Exp $	*/
 
 /*
  * Copyright (c) 1998, 2004, 2011, 2012, 2014 The NetBSD Foundation, Inc.
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: motg.c,v 1.12.2.30 2016/07/09 20:25:15 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: motg.c,v 1.12.2.31 2016/12/27 08:49:29 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_motg.h"
@@ -2087,9 +2087,9 @@ motg_device_intr_tx(struct motg_softc *s
 complete:
 	DPRINTFN(MD_BULK, "xfer %p complete, status %d", xfer,
 	(xfer != NULL) ? xfer->ux_status : 0, 0, 0);
-#ifdef DIAGNOSTIC
-	if (xfer && xfer->ux_status == USBD_IN_PROGRESS && ep->phase != DATA_OUT)
-		panic("motg_device_intr_tx: bad phase %d", ep->phase);
+	KASSERTMSG(xfer && xfer->ux_status == USBD_IN_PROGRESS && 
+	ep->phase == DATA_OUT, "xfer %p status %d phase %d",
+	xfer, xfer->ux_status, ep->phase);
 #endif
 	ep->phase = IDLE;
 	ep->xfer = NULL;



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

2016-12-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Dec 27 08:33:08 UTC 2016

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

Log Message:
Actually set the transfer status on transfers in ohci_abort_xfer and
the controller is dying


To generate a diff of this commit:
cvs rdiff -u -r1.254.2.82 -r1.254.2.83 src/sys/dev/usb/ohci.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/ohci.c
diff -u src/sys/dev/usb/ohci.c:1.254.2.82 src/sys/dev/usb/ohci.c:1.254.2.83
--- src/sys/dev/usb/ohci.c:1.254.2.82	Tue Dec 27 08:32:19 2016
+++ src/sys/dev/usb/ohci.c	Tue Dec 27 08:33:08 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ohci.c,v 1.254.2.82 2016/12/27 08:32:19 skrll Exp $	*/
+/*	$NetBSD: ohci.c,v 1.254.2.83 2016/12/27 08:33:08 skrll Exp $	*/
 
 /*
  * Copyright (c) 1998, 2004, 2005, 2012 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.254.2.82 2016/12/27 08:32:19 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.254.2.83 2016/12/27 08:33:08 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -2269,7 +2269,7 @@ ohci_abort_xfer(struct usbd_xfer *xfer, 
 
 	if (sc->sc_dying) {
 		/* If we're dying, just do the software part. */
-		KASSERT(xfer->ux_status == status);
+		xfer->ux_status = status;
 		callout_halt(>ux_callout, >sc_lock);
 		usb_transfer_complete(xfer);
 		return;



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

2016-12-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Dec 27 08:32:19 UTC 2016

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

Log Message:
Don't supply the lock to callout_halt when polling as it won't be held


To generate a diff of this commit:
cvs rdiff -u -r1.254.2.81 -r1.254.2.82 src/sys/dev/usb/ohci.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/ohci.c
diff -u src/sys/dev/usb/ohci.c:1.254.2.81 src/sys/dev/usb/ohci.c:1.254.2.82
--- src/sys/dev/usb/ohci.c:1.254.2.81	Sat Dec 17 10:10:34 2016
+++ src/sys/dev/usb/ohci.c	Tue Dec 27 08:32:19 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ohci.c,v 1.254.2.81 2016/12/17 10:10:34 skrll Exp $	*/
+/*	$NetBSD: ohci.c,v 1.254.2.82 2016/12/27 08:32:19 skrll Exp $	*/
 
 /*
  * Copyright (c) 1998, 2004, 2005, 2012 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.254.2.81 2016/12/17 10:10:34 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.254.2.82 2016/12/27 08:32:19 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -1402,8 +1402,9 @@ ohci_softintr(void *v)
 	int len, cc;
 	int i, j, actlen, iframes, uedir;
 	ohci_physaddr_t done = 0;
+	bool polling = sc->sc_bus.ub_usepolling;
 
-	KASSERT(sc->sc_bus.ub_usepolling || mutex_owned(>sc_lock));
+	KASSERT(polling || mutex_owned(>sc_lock));
 
 	OHCIHIST_FUNC(); OHCIHIST_CALLED();
 
@@ -1491,7 +1492,7 @@ ohci_softintr(void *v)
 		 * Make sure the timeout handler didn't run or ran to the end
 		 * and set the transfer status.
 		 */
-		callout_halt(>ux_callout, >sc_lock);
+		callout_halt(>ux_callout, polling ? NULL : >sc_lock);
 
 		if (xfer->ux_status == USBD_CANCELLED ||
 		xfer->ux_status == USBD_TIMEOUT) {