Re: CVS commit: src/external/cddl/osnet/lib/libdtrace

2014-03-16 Thread Ryota Ozaki
On Sun, Mar 16, 2014 at 3:02 PM, Matt Thomas m...@3am-software.com wrote:

 On Mar 15, 2014, at 10:11 PM, Ryota Ozaki ozak...@netbsd.org wrote:

 Module Name:  src
 Committed By: ozaki-r
 Date: Sun Mar 16 05:11:19 UTC 2014

 Modified Files:
   src/external/cddl/osnet/lib/libdtrace: Makefile

 Log Message:
 Look up arm directory on MACHINE_ARCH=*arm*

 Use MACHINE_CPU instead.

Oh, sorry. I forgot it. Thank you for pointing it out!

  ozaki-r


Re: CVS commit: src/sys

2014-07-02 Thread Ryota Ozaki
On Wed, Jul 2, 2014 at 1:34 PM, David Holland
dholland-sourcechan...@netbsd.org wrote:
 On Tue, Jul 01, 2014 at 10:16:02AM +, Ryota Ozaki wrote:
   Log Message:
   Lock IFQ operations when NET_MPSAFE
  
   - Introduce NET_MPSAFE
 - not defined by default

 If it compiles (and is expected to continue to compile) please add it
 to ALL.

It compiles, but I'm not sure it should be exposed to users
at this point (before branching netbsd-7) because it's not
worthwhile for users yet.

 ozaki-r


 --
 David A. Holland
 dholl...@netbsd.org


Re: CVS commit: src/sys

2014-07-02 Thread Ryota Ozaki
On Wed, Jul 2, 2014 at 3:37 PM, Ryota Ozaki ozak...@netbsd.org wrote:
 On Wed, Jul 2, 2014 at 1:34 PM, David Holland
 dholland-sourcechan...@netbsd.org wrote:
 On Tue, Jul 01, 2014 at 10:16:02AM +, Ryota Ozaki wrote:
   Log Message:
   Lock IFQ operations when NET_MPSAFE
  
   - Introduce NET_MPSAFE
 - not defined by default

 If it compiles (and is expected to continue to compile) please add it
 to ALL.

 It compiles, but I'm not sure it should be exposed to users
 at this point (before branching netbsd-7) because it's not
 worthwhile for users yet.

msaitoh taught me what ALL is and I got it :) I'll do it.

  ozaki-r


  ozaki-r


 --
 David A. Holland
 dholl...@netbsd.org


Re: CVS commit: src/sys

2014-07-06 Thread Ryota Ozaki
On Sun, Jul 6, 2014 at 9:24 AM, Mindaugas Rasiukevicius
rm...@netbsd.org wrote:
 David Holland dholland-sourcechan...@netbsd.org wrote:
 On Tue, Jul 01, 2014 at 10:16:02AM +, Ryota Ozaki wrote:
   Log Message:
   Lock IFQ operations when NET_MPSAFE
  
   - Introduce NET_MPSAFE
 - not defined by default

 If it compiles (and is expected to continue to compile) please add it
 to ALL.


 While it is okay for now, I think this knob should be only for the short
 term (i.e. only for transitional period while making changes to the APIs).

Yes, of course :)

  ozaki-r


 --
 Mindaugas


Re: CVS commit: src/sys/net

2014-07-30 Thread Ryota Ozaki
On Wed, Jul 30, 2014 at 8:41 PM, Takahiro HAYASHI t.hash...@gmail.com wrote:
 (07/28/14 23:24), Ryota Ozaki wrote:

 Module Name:src
 Committed By:   ozaki-r
 Date:   Mon Jul 28 14:24:48 UTC 2014

 Modified Files:

 src/sys/net: if.c if_ether.h if_ethersubr.c

 Log Message:
 Add a mutex for global variables of if_ethersubr.c

 To initialize the mutex, we introduce etherinit that is called from
 ifinit1.


 etherinit() would be undefined if kernel does
 not have any ethernet interfaces like BEAGLEBOARDXM.

 should be wrapped with something like #if NETHER  0 ?

Yes. I've just committed the fix. (It took long time to confirm
the fix...)

Thanks,
  ozaki-r



 --
 t-hash


Re: CVS commit: src/sys

2014-11-16 Thread Ryota Ozaki
On Mon, Nov 17, 2014 at 6:58 AM, matthew green m...@eterna.com.au wrote:

 Ryota Ozaki writes:
 Module Name:  src
 Committed By: ozaki-r
 Date: Sun Nov 16 16:20:01 UTC 2014

 Modified Files:
   src/sys/arch/x86/pci: fwhrng.c
   src/sys/arch/x86/x86: via_padlock.c
   src/sys/dev/bluetooth: bcsp.c btkbd.c
   src/sys/dev/ic: nslm7x.c
   src/sys/dev/ir: irframe_tty.c
   src/sys/dev/isa: aps.c
   src/sys/dev/pci: pccbb.c
   src/sys/dev/pcmcia: btbc.c
   src/sys/dev/sdmmc: sdmmc.c
   src/sys/dev/wscons: wskbd.c
   src/sys/net: if_ecosubr.c

 Log Message:
 Replace callout_stop with callout_halt

 In order to call callout_destroy for a callout safely, we have to ensure
 the function of the callout is not running and pending. To do so, we should
 use callout_halt, not callout_stop.

 Discussed with martin@ and riastradh@.

 thanks.  it might be nice if callout(9) was expanded to specifically
 warn against using callout_stop() before callout_destroy().

Okay, will do.


 i suspect many of these should be pulled up to -5 and -6.

I can work on pullup-6 and pullup-7 but I'd appreciate it
if someone does pullup-5 because I have no netbsd-5 tree
in my local machine.

Anyway another patch is under review so that please wait for
the patch committed :)

  ozaki-r



 .mrg.


Re: CVS commit: src/sys/net

2014-11-26 Thread Ryota Ozaki
On Thu, Nov 27, 2014 at 10:30 AM, Matt Thomas m...@3am-software.com wrote:

 On Nov 26, 2014, at 1:38 AM, Ryota Ozaki ozak...@netbsd.org wrote:

 Module Name:  src
 Committed By: ozaki-r
 Date: Wed Nov 26 09:38:42 UTC 2014

 Modified Files:
   src/sys/net: if.c if.h

 Log Message:
 Change if_slowtimo_ch to a pointer

 One benefit to do so is to reduce memory used for struct callout;
 we can avoid to allocate struct callout for interfaces that don't
 use callout.

 Requested by uebayasi@.

 This requires a kernel version bump.


OK, I did it. Thanks.

  ozaki-r


Re: CVS commit: src/sys/net

2014-11-26 Thread Ryota Ozaki
On Thu, Nov 27, 2014 at 10:51 AM, Masao Uebayashi uebay...@gmail.com wrote:
 Maybe adding a few spare members, like 5 pointers, to reduce # of bumps ... ?

I thought the version bump is required because a member has been changed
(a struct to a pointer). So IIUC the spare members don't help for such
a situation?

  ozaki-r


Re: CVS commit: src/sys/net

2014-11-26 Thread Ryota Ozaki
On Thu, Nov 27, 2014 at 10:55 AM, Masao Uebayashi uebay...@gmail.com wrote:
 On Thu, Nov 27, 2014 at 10:51 AM, Masao Uebayashi uebay...@gmail.com wrote:
 Maybe adding a few spare members, like 5 pointers, to reduce # of bumps ... ?

 Or completely hide sizeof(struct ifnet) by forcing use of if_alloc(),
 as struct device did.

Hmm, I'm confused. When do we have to bump the kernel version?

  ozaki-r


Re: CVS commit: src/sys/net

2014-11-26 Thread Ryota Ozaki
On Thu, Nov 27, 2014 at 11:39 AM, matthew green m...@eterna.com.au wrote:

 Ryota Ozaki writes:
 On Thu, Nov 27, 2014 at 10:51 AM, Masao Uebayashi uebay...@gmail.com wrote:
  Maybe adding a few spare members, like 5 pointers, to reduce # of bumps 
  ... ?

 I thought the version bump is required because a member has been changed
 (a struct to a pointer). So IIUC the spare members don't help for such
 a situation?

 this is correct.  you need a kernel bump when ever the kernel
 ABI changes.

 hiding stuff inside an alloc doesn't really help much when the
 kernel code needs to access the structure anyway, unless you
 also hide all accesses to the structure inside functions.

Thanks! I understood.

  ozaki-r


 that said, it's probably a good idea anyway.


 .mrg.


Re: CVS commit: src/sys/net

2014-11-30 Thread Ryota Ozaki
On Mon, Dec 1, 2014 at 9:27 AM, Christos Zoulas chris...@netbsd.org wrote:
 Module Name:src
 Committed By:   christos
 Date:   Mon Dec  1 00:27:05 UTC 2014

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

 Log Message:
 PR/49437: jmcneill: revert broken changes that broke SIOCGIFCONF (mdnsd uses 
 it)

I'm sorry for my fault. I'll fix that commit later.

BTW, we may need ATF tests to ring the bell for such regressions.

  ozaki-r



 To generate a diff of this commit:
 cvs rdiff -u -r1.300 -r1.301 src/sys/net/if.c

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



Re: CVS commit: src/sys/net

2014-12-01 Thread Ryota Ozaki
On Mon, Dec 1, 2014 at 5:01 PM, Martin Husemann mar...@duskware.de wrote:
 On Mon, Dec 01, 2014 at 11:54:23AM +0900, Ryota Ozaki wrote:
 BTW, we may need ATF tests to ring the bell for such regressions.

 This is a bit tricky to do as we do not expose a sane api to create
 old binaries from source. It would boil down to copy  paste of the old
 structure definition and some magic to test ioctls with them.

Hmm, in this case, a test with a new userland binary (7.99.2) and
a new kernel (7.99.2) can expose the regression. So I thought we
need to add a test that does ioctl(SIOCGIFCONF) (or just run
ifconfig with no argument).

  ozaki-r


 Testing the ioctls itself against a rump kernel is very simple.

 But then you'll have to install helpers (like rump.ifconfig but for various
 ioctl versions) and it quickly gets messy.

 So no easy/safe/scalable way there that I can see. The other option that
 comes to mind is running a -current kernel and doing a -7 and -6 release
 branch test run. Unfortunately that will include all RUMP components from that
 branch as well, so not test the compatibility we are looking for either.

 But I guess we should think about rearrangements in this direction to make
 it easier in the future - starting with a separate rump.tgz set, or maybe
 a few of them, not sure what granularity would be needed there.

 Antti, Justin, can we separate the rump userland from the rump kernel
 binaries easily and put them in different sets, and then run the userland
 from -6 or -7 against the (rump-)kernel from -current?

 Martin


Re: CVS commit: src/sys/net

2014-12-01 Thread Ryota Ozaki
On Mon, Dec 1, 2014 at 11:28 PM, Martin Husemann mar...@duskware.de wrote:
 On Mon, Dec 01, 2014 at 11:21:17PM +0900, Ryota Ozaki wrote:
 Hmm, in this case, a test with a new userland binary (7.99.2) and
 a new kernel (7.99.2) can expose the regression. So I thought we
 need to add a test that does ioctl(SIOCGIFCONF) (or just run
 ifconfig with no argument).

 Oh, I somehow thought the -current version had worked and only compat
 got broken.

 This is very simple, see for example src/tests/net/mpls - but that is a
 quite complex version setting up 4 independent rump servers. In this
 case, a single one would do.

Thanks, I'll try to do it.

  ozaki-r


 Martin


Re: CVS commit: src/sys

2014-12-02 Thread Ryota Ozaki
On Tue, Dec 2, 2014 at 8:25 PM, Antti Kantee po...@iki.fi wrote:
 [like pros, we were talking on source-changes list.  that wasn't very
 useful]

 On 02/12/14 04:28, Ryota Ozaki wrote:

 On Tue, Dec 2, 2014 at 12:39 PM, Antti Kantee po...@iki.fi wrote:

 On 02/12/14 03:30, Ryota Ozaki wrote:


 The problem is that the real if_drain_all() will never be called in
 environments with the weak alias problem even if the non-stub
 implementation
 is present and it should be called.



 I'm getting the problem, but I have still one question; why ifnet_list
 works while if_drain_all doesn't?



 If you are asking about the linker, ifnet_list is a common symbol, not a
 weak alias.

 If you are asking about traversing ifnet_list, semi-accidentally -- the
 tailq macros happen to work for zero-filled heads unless you try to
 tailq_insert_tail.


 I meant the former. Anyway I got it. rumpnet doesn't add any items
 to ifnet_list, so it works without rumpnet_net.


 Right, because interfaces don't exist in net, only in net_net (it makes
 sense if you think about sys vs. sys/net).

 Actually, looking more closely, it is currently a problem for _all_
 platforms since you stubbed it to a panic instead of a nop.



 Oh, right. I just followed bridge ones...



 If you look at the history of that file, you will notice that I have been
 removing __weak_alias() instances.  bridge/agr not working on platforms
 without weak alias support is acceptable (because it never has worked).

 I hope bridge/agr can be fixed some day, but perhaps they will fix
 themselves with a more modular networking stack ;)


 We can get rid of __weak_alias(bridge_input) already :)
 The other two are...I don't know when it's done :-/


 Oh, nice!  Can you remove the now-unnecessary weak aliases?

Done.

I'm thinking how to remove weak alias for bridge_ifdetach.
It can be done by having a (if)detach callback list that
callbacks are called in ether_ifdetach. We can register
bpf_detach and vlan_ifdetach to the list as well as
bridge_ifdetach. I don't know it's worthwhile to do though.

  ozaki-r


Re: CVS commit: src/usr.bin/config

2014-12-16 Thread Ryota Ozaki
On Tue, Dec 16, 2014 at 12:49 AM, Masao Uebayashi uebay...@netbsd.org wrote:
 Module Name:src
 Committed By:   uebayasi
 Date:   Mon Dec 15 15:49:25 UTC 2014

 Modified Files:
 src/usr.bin/config: mkmakefile.c

 Log Message:
 Revert debug code.  Simplify.

http://releng.netbsd.org/b5reports/i386/commits-2014.12.html#2014.12.15.15.49.25

It seems this commit (and/or the previous commit) increases failures of ATF.

Regards,
  ozaki-r



 To generate a diff of this commit:
 cvs rdiff -u -r1.36 -r1.37 src/usr.bin/config/mkmakefile.c

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



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

2014-12-18 Thread Ryota Ozaki
On Fri, Dec 19, 2014 at 1:44 PM, John Klos jk...@netbsd.org wrote:
 Module Name:src
 Committed By:   jklos
 Date:   Fri Dec 19 04:44:13 UTC 2014

 Modified Files:
 src/sys/arch/vax/conf: GENERIC files.vax majors.vax
 Added Files:
 src/sys/arch/vax/vsa: vsaudio.c

 Log Message:
 Add audio support for VAXstation VLC, 60 and 90 machines. Originally rom
 Blaz Antonic and ported from OpenBSD by Björn Johannesso. Tested on VLC
 and 4000/60.

The change seems to break the build of vax:
http://build.tastylime.net/builders/kernel-vax/builds/2875/steps/GENERIC/logs/stdio

Regards,
  ozaki-r


CVS commit: src/distrib/notes/common

2014-02-24 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Feb 24 11:56:01 UTC 2014

Modified Files:
src/distrib/notes/common: main

Log Message:
Add myself


To generate a diff of this commit:
cvs rdiff -u -r1.506 -r1.507 src/distrib/notes/common/main

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

Modified files:

Index: src/distrib/notes/common/main
diff -u src/distrib/notes/common/main:1.506 src/distrib/notes/common/main:1.507
--- src/distrib/notes/common/main:1.506	Mon Feb 24 07:23:39 2014
+++ src/distrib/notes/common/main	Mon Feb 24 11:56:01 2014
@@ -1,4 +1,4 @@
-.\	$NetBSD: main,v 1.506 2014/02/24 07:23:39 skrll Exp $
+.\	$NetBSD: main,v 1.507 2014/02/24 11:56:01 ozaki-r Exp $
 .\
 .\ Copyright (c) 1999-2012 The NetBSD Foundation, Inc.
 .\ All rights reserved.
@@ -1325,6 +1325,7 @@ If you're one of them, and would like to
 .It Ta Ryo ONODERA Ta Mt ry...@netbsd.org
 .It Ta Atsushi Onoe Ta Mt o...@netbsd.org
 .It Ta Greg Oster Ta Mt os...@netbsd.org
+.It Ta Ryota Ozaki Ta Mt ozak...@netbsd.org
 .It Ta Jonathan Perkin Ta Mt ske...@netbsd.org
 .It Ta Fredrik Pettai Ta Mt pet...@netbsd.org
 .It Ta Herb Peyerl Ta Mt hpey...@netbsd.org



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

2014-02-25 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Feb 26 03:58:33 UTC 2014

Modified Files:
src/sys/arch/arm/omap: if_cpsw.c if_cpswreg.h

Log Message:
Make cpsw driver work without uboot support

On some eval boards such as BeagleBone, the cpsw device is initialized
rightly by the uboot of the boards so that the cpsw driver doesn't need
to do some initializations but works fine.

The patch adds initializations to make the driver work solely. It also
adds support for 1000BaseT (RGMII) PHY that is equipped on some boards,
e.g., CKB-3352.

Reviewed by christos@


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/omap/if_cpsw.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/omap/if_cpswreg.h

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

Modified files:

Index: src/sys/arch/arm/omap/if_cpsw.c
diff -u src/sys/arch/arm/omap/if_cpsw.c:1.4 src/sys/arch/arm/omap/if_cpsw.c:1.5
--- src/sys/arch/arm/omap/if_cpsw.c:1.4	Wed Dec 18 12:53:26 2013
+++ src/sys/arch/arm/omap/if_cpsw.c	Wed Feb 26 03:58:33 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_cpsw.c,v 1.4 2013/12/18 12:53:26 skrll Exp $	*/
+/*	$NetBSD: if_cpsw.c,v 1.5 2014/02/26 03:58:33 ozaki-r Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -53,7 +53,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(1, $NetBSD: if_cpsw.c,v 1.4 2013/12/18 12:53:26 skrll Exp $);
+__KERNEL_RCSID(1, $NetBSD: if_cpsw.c,v 1.5 2014/02/26 03:58:33 ozaki-r Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -122,6 +122,7 @@ struct cpsw_softc {
 	bus_addr_t sc_rxdescs_pa;
 	struct ethercom sc_ec;
 	struct mii_data sc_mii;
+	bool sc_phy_has_1000t;
 	callout_t sc_tick_ch;
 	void *sc_ih;
 	struct cpsw_ring_data *sc_rdp;
@@ -163,6 +164,11 @@ static int cpsw_rxintr(void *);
 static int cpsw_txintr(void *);
 static int cpsw_miscintr(void *);
 
+/* ALE support */
+#define CPSW_MAX_ALE_ENTRIES	1024
+
+static int cpsw_ale_update_addresses(struct cpsw_softc *, int purge);
+
 CFATTACH_DECL_NEW(cpsw, sizeof(struct cpsw_softc),
 cpsw_match, cpsw_attach, NULL, NULL);
 
@@ -318,6 +324,18 @@ cpsw_match(device_t parent, cfdata_t cf,
 	return 0;
 }
 
+static bool
+cpsw_phy_has_1000t(struct cpsw_softc * const sc)
+{
+	struct ifmedia_entry *ifm;
+
+	TAILQ_FOREACH(ifm, sc-sc_mii.mii_media.ifm_list, ifm_list) {
+		if (IFM_SUBTYPE(ifm-ifm_media) == IFM_1000_T)
+			return true;
+	}
+	return false;
+}
+
 static void
 cpsw_attach(device_t parent, device_t self, void *aux)
 {
@@ -469,13 +487,28 @@ cpsw_attach(device_t parent, device_t se
 	sc-sc_ec.ec_mii = sc-sc_mii;
 	ifmedia_init(sc-sc_mii.mii_media, 0, ether_mediachange,
 	ether_mediastatus);
+
+	/* Initialize MDIO */
+	cpsw_write_4(sc, MDIOCONTROL, MDIOCTL_ENABLE | MDIOCTL_FAULTENB | MDIOCTL_CLKDIV(0xff));
+	/* Clear ALE */
+	cpsw_write_4(sc, CPSW_ALE_CONTROL, ALECTL_CLEAR_TABLE);
+
 	mii_attach(self, sc-sc_mii, 0x, MII_PHY_ANY, 0, 0);
 	if (LIST_FIRST(sc-sc_mii.mii_phys) == NULL) {
 		aprint_error_dev(self, no PHY found!\n);
+		sc-sc_phy_has_1000t = false;
 		ifmedia_add(sc-sc_mii.mii_media,
 		IFM_ETHER|IFM_MANUAL, 0, NULL);
 		ifmedia_set(sc-sc_mii.mii_media, IFM_ETHER|IFM_MANUAL);
 	} else {
+		sc-sc_phy_has_1000t = cpsw_phy_has_1000t(sc);
+		if (sc-sc_phy_has_1000t) {
+			aprint_normal_dev(sc-sc_dev, 1000baseT PHY found. setting RGMII Mode\n);
+			/* Select the Interface RGMII Mode in the Control Module */
+			sitara_cm_reg_write_4(CPSW_GMII_SEL,
+			GMIISEL_GMII2_SEL(RGMII_MODE) | GMIISEL_GMII1_SEL(RGMII_MODE));
+		}
+
 		ifmedia_set(sc-sc_mii.mii_media, IFM_ETHER|IFM_AUTO);
 	}
 
@@ -791,6 +824,8 @@ cpsw_init(struct ifnet *ifp)
 
 	/* Reset and init Sliver port 1 and 2 */
 	for (i = 0; i  2; i++) {
+		uint32_t macctl;
+
 		/* Reset */
 		cpsw_write_4(sc, CPSW_SL_SOFT_RESET(i), 1);
 		while(cpsw_read_4(sc, CPSW_SL_SOFT_RESET(i))  1);
@@ -805,9 +840,12 @@ cpsw_init(struct ifnet *ifp)
 		cpsw_write_4(sc, CPSW_PORT_P_SA_LO(i+1),
 		sc-sc_enaddr[4] | (sc-sc_enaddr[5]  8));
 
-		/* Set MACCONTROL for ports 0,1: FULLDUPLEX(1), GMII_EN(5),
-		   IFCTL_A(15), IFCTL_B(16) FIXME */
-		cpsw_write_4(sc, CPSW_SL_MACCONTROL(i), 1 | (15) | (115));
+		/* Set MACCONTROL for ports 0,1 */
+		macctl = SLMACCTL_FULLDUPLEX | SLMACCTL_GMII_EN |
+		SLMACCTL_IFCTL_A;
+		if (sc-sc_phy_has_1000t)
+			macctl |= SLMACCTL_GIG;
+		cpsw_write_4(sc, CPSW_SL_MACCONTROL(i), macctl);
 
 		/* Set ALE port to forwarding(3) */
 		cpsw_write_4(sc, CPSW_ALE_PORTCTL(i+1), 3);
@@ -820,6 +858,9 @@ cpsw_init(struct ifnet *ifp)
 	/* Set ALE port to forwarding(3) */
 	cpsw_write_4(sc, CPSW_ALE_PORTCTL(0), 3);
 
+	/* Initialize addrs */
+	cpsw_ale_update_addresses(sc, 1);
+
 	cpsw_write_4(sc, CPSW_SS_PTYPE, 0);
 	cpsw_write_4(sc, CPSW_SS_STAT_PORT_EN, 7);
 
@@ -1242,3 +1283,194 @@ cpsw_miscintr(void *arg)
 
 	return 1;
 }
+
+/*
+ *
+ * ALE support routines.
+ *
+ */
+
+static void
+cpsw_ale_entry_init(uint32_t *ale_entry)
+{
+	ale_entry[0] = ale_entry[1] = 

CVS commit: src/sys/dev/mii

2014-02-25 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Feb 26 04:13:45 UTC 2014

Modified Files:
src/sys/dev/mii: files.mii miidevs
Added Files:
src/sys/dev/mii: micphy.c

Log Message:
Add Micrel PHY (KSZ9021RN)

The new driver micphy is almost same as ukphy except that
micphy has a fixup for cpsw; a PHY with cpsw has to adjust
RGMII signal timing.

Reviewed by christos@


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/sys/dev/mii/files.mii
cvs rdiff -u -r0 -r1.1 src/sys/dev/mii/micphy.c
cvs rdiff -u -r1.117 -r1.118 src/sys/dev/mii/miidevs

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/mii/files.mii
diff -u src/sys/dev/mii/files.mii:1.48 src/sys/dev/mii/files.mii:1.49
--- src/sys/dev/mii/files.mii:1.48	Wed Jan 26 18:48:12 2011
+++ src/sys/dev/mii/files.mii	Wed Feb 26 04:13:44 2014
@@ -1,4 +1,4 @@
-#	$NetBSD: files.mii,v 1.48 2011/01/26 18:48:12 bouyer Exp $
+#	$NetBSD: files.mii,v 1.49 2014/02/26 04:13:44 ozaki-r Exp $
 
 defflag	opt_mii.h	MIIVERBOSE
 
@@ -148,3 +148,7 @@ file	dev/mii/etphy.cetphy
 device	rdcphy: mii_phy
 attach	rdcphy at mii
 file	dev/mii/rdcphy.c			rdcphy
+
+device	micphy: mii_phy, ukphy_subr
+attach	micphy at mii
+file	dev/mii/micphy.c			micphy

Index: src/sys/dev/mii/miidevs
diff -u src/sys/dev/mii/miidevs:1.117 src/sys/dev/mii/miidevs:1.118
--- src/sys/dev/mii/miidevs:1.117	Sat Dec 21 15:16:23 2013
+++ src/sys/dev/mii/miidevs	Wed Feb 26 04:13:44 2014
@@ -1,4 +1,4 @@
-$NetBSD: miidevs,v 1.117 2013/12/21 15:16:23 kiyohara Exp $
+$NetBSD: miidevs,v 1.118 2014/02/26 04:13:44 ozaki-r Exp $
 
 /*-
  * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
@@ -66,6 +66,7 @@ oui INTEL			0x00aa00	Intel
 oui JMICRON			0x00d831	JMicron
 oui LEVEL1			0x00207b	Level 1
 oui MARVELL			0x005043	Marvell Semiconductor
+oui MICREL			0x0010a1	Micrel
 oui MYSON			0x00c0b4	Myson Technology
 oui NATSEMI			0x080017	National Semiconductor
 oui PMCSIERRA			0x00e004	PMC-Sierra
@@ -260,6 +261,9 @@ model xxMARVELL E1116R		0x0024 Marvell 8
 model xxMARVELL E1116R_29	0x0029 Marvell 88E1116R Gigabit PHY
 model xxMARVELL E1543		0x002a Marvell 88E1543 Alaska Quad Port Gb PHY
 
+/* Micrel PHYs */
+model MICREL KSZ9021RNI		0x0021 Micrel KSZ9021RNI 10/100/1000 PHY
+
 /* Myson Technology PHYs */
 model xxMYSON MTD972		0x MTD972 10/100 media interface
 model MYSON MTD803		0x MTD803 3-in-1 media interface

Added files:

Index: src/sys/dev/mii/micphy.c
diff -u /dev/null src/sys/dev/mii/micphy.c:1.1
--- /dev/null	Wed Feb 26 04:13:45 2014
+++ src/sys/dev/mii/micphy.c	Wed Feb 26 04:13:44 2014
@@ -0,0 +1,251 @@
+/*	$NetBSD: micphy.c,v 1.1 2014/02/26 04:13:44 ozaki-r Exp $	*/
+
+/*-
+ * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
+ * NASA Ames Research Center, and by Frank van der Linden.
+ *
+ * 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.
+ */
+
+/*
+ * Copyright (c) 1997 Manuel Bouyer.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS 

CVS commit: src/sys/dev/mii

2014-02-25 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Feb 26 04:31:29 UTC 2014

Modified Files:
src/sys/dev/mii: miidevs.h miidevs_data.h

Log Message:
Regen.


To generate a diff of this commit:
cvs rdiff -u -r1.120 -r1.121 src/sys/dev/mii/miidevs.h
cvs rdiff -u -r1.108 -r1.109 src/sys/dev/mii/miidevs_data.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/mii/miidevs.h
diff -u src/sys/dev/mii/miidevs.h:1.120 src/sys/dev/mii/miidevs.h:1.121
--- src/sys/dev/mii/miidevs.h:1.120	Sat Dec 21 15:18:21 2013
+++ src/sys/dev/mii/miidevs.h	Wed Feb 26 04:31:29 2014
@@ -1,10 +1,10 @@
-/*	$NetBSD: miidevs.h,v 1.120 2013/12/21 15:18:21 kiyohara Exp $	*/
+/*	$NetBSD: miidevs.h,v 1.121 2014/02/26 04:31:29 ozaki-r Exp $	*/
 
 /*
  * THIS FILE AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *	NetBSD: miidevs,v 1.117 2013/12/21 15:16:23 kiyohara Exp
+ *	NetBSD: miidevs,v 1.118 2014/02/26 04:13:44 ozaki-r Exp
  */
 
 /*-
@@ -73,6 +73,7 @@
 #define	MII_OUI_JMICRON	0x00d831	/* JMicron */
 #define	MII_OUI_LEVEL1	0x00207b	/* Level 1 */
 #define	MII_OUI_MARVELL	0x005043	/* Marvell Semiconductor */
+#define	MII_OUI_MICREL	0x0010a1	/* Micrel */
 #define	MII_OUI_MYSON	0x00c0b4	/* Myson Technology */
 #define	MII_OUI_NATSEMI	0x080017	/* National Semiconductor */
 #define	MII_OUI_PMCSIERRA	0x00e004	/* PMC-Sierra */
@@ -381,6 +382,10 @@
 #define	MII_MODEL_xxMARVELL_E1543	0x002a
 #define	MII_STR_xxMARVELL_E1543	Marvell 88E1543 Alaska Quad Port Gb PHY
 
+/* Micrel PHYs */
+#define	MII_MODEL_MICREL_KSZ9021RNI	0x0021
+#define	MII_STR_MICREL_KSZ9021RNI	Micrel KSZ9021RNI 10/100/1000 PHY
+
 /* Myson Technology PHYs */
 #define	MII_MODEL_xxMYSON_MTD972	0x
 #define	MII_STR_xxMYSON_MTD972	MTD972 10/100 media interface

Index: src/sys/dev/mii/miidevs_data.h
diff -u src/sys/dev/mii/miidevs_data.h:1.108 src/sys/dev/mii/miidevs_data.h:1.109
--- src/sys/dev/mii/miidevs_data.h:1.108	Sat Dec 21 15:18:21 2013
+++ src/sys/dev/mii/miidevs_data.h	Wed Feb 26 04:31:29 2014
@@ -1,10 +1,10 @@
-/*	$NetBSD: miidevs_data.h,v 1.108 2013/12/21 15:18:21 kiyohara Exp $	*/
+/*	$NetBSD: miidevs_data.h,v 1.109 2014/02/26 04:31:29 ozaki-r Exp $	*/
 
 /*
  * THIS FILE AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *	NetBSD: miidevs,v 1.117 2013/12/21 15:16:23 kiyohara Exp
+ *	NetBSD: miidevs,v 1.118 2014/02/26 04:13:44 ozaki-r Exp
  */
 
 /*-
@@ -151,6 +151,7 @@ struct mii_knowndev mii_knowndevs[] = {
  { MII_OUI_xxMARVELL, MII_MODEL_xxMARVELL_E1116R, MII_STR_xxMARVELL_E1116R },
  { MII_OUI_xxMARVELL, MII_MODEL_xxMARVELL_E1116R_29, MII_STR_xxMARVELL_E1116R_29 },
  { MII_OUI_xxMARVELL, MII_MODEL_xxMARVELL_E1543, MII_STR_xxMARVELL_E1543 },
+ { MII_OUI_MICREL, MII_MODEL_MICREL_KSZ9021RNI, MII_STR_MICREL_KSZ9021RNI },
  { MII_OUI_xxMYSON, MII_MODEL_xxMYSON_MTD972, MII_STR_xxMYSON_MTD972 },
  { MII_OUI_MYSON, MII_MODEL_MYSON_MTD803, MII_STR_MYSON_MTD803 },
  { MII_OUI_xxNATSEMI, MII_MODEL_xxNATSEMI_DP83840, MII_STR_xxNATSEMI_DP83840 },



CVS commit: src/share/man/man4

2014-03-02 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Mar  3 01:35:08 UTC 2014

Added Files:
src/share/man/man4: micphy.4

Log Message:
Add micphy(4) manpage


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/share/man/man4/micphy.4

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

Added files:

Index: src/share/man/man4/micphy.4
diff -u /dev/null src/share/man/man4/micphy.4:1.1
--- /dev/null	Mon Mar  3 01:35:08 2014
+++ src/share/man/man4/micphy.4	Mon Mar  3 01:35:08 2014
@@ -0,0 +1,38 @@
+.\	$NetBSD: micphy.4,v 1.1 2014/03/03 01:35:08 ozaki-r Exp $
+.\
+.\ Copyright (c) 2014 The NetBSD Foundation, Inc.
+.\ All rights reserved.
+.\
+.\ Permission to use, copy, modify, and distribute this software for any
+.\ purpose with or without fee is hereby granted, provided that the above
+.\ copyright notice and this permission notice appear in all copies.
+.\
+.\ THE SOFTWARE IS PROVIDED AS IS AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+.\ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+.\ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+.\ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+.\ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+.\ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+.\ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+.\
+.Dd March 3, 2014
+.Dt MICPHY 4
+.Os
+.Sh NAME
+.Nm micphy
+.Nd Micrel KSZ9021 10/100/1000 PHY driver
+.Sh SYNOPSIS
+.Cd micphy* at mii? phy ?
+.Sh DESCRIPTION
+The
+.Nm
+driver currently supports only Micrel KSZ9021RN PHY.
+The driver has a fixup for
+.Xr cpsw 4
+which requires Gig-E PHYs to adjust RGMII signal timing.
+.Sh SEE ALSO
+.Xr cpsw 4 ,
+.Xr ifmedia 4 ,
+.Xr intro 4 ,
+.Xr mii 4 ,
+.Xr ifconfig 8



CVS commit: src/share/man/man4

2014-03-02 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Mar  3 01:36:21 UTC 2014

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

Log Message:
Mention micphy(4)


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/share/man/man4/mii.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/mii.4
diff -u src/share/man/man4/mii.4:1.25 src/share/man/man4/mii.4:1.26
--- src/share/man/man4/mii.4:1.25	Tue Mar 13 19:25:40 2012
+++ src/share/man/man4/mii.4	Mon Mar  3 01:36:21 2014
@@ -1,4 +1,4 @@
-.\	$NetBSD: mii.4,v 1.25 2012/03/13 19:25:40 njoly Exp $
+.\	$NetBSD: mii.4,v 1.26 2014/03/03 01:36:21 ozaki-r Exp $
 .\
 .\ Copyright (c) 1998, 2002 The NetBSD Foundation, Inc.
 .\ All rights reserved.
@@ -28,7 +28,7 @@
 .\ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\ POSSIBILITY OF SUCH DAMAGE.
 .\
-.Dd October 13, 2006
+.Dd March 3, 2014
 .Dt MII 4
 .Os
 .Sh NAME
@@ -51,6 +51,7 @@
 .Cd iophy*at mii? phy ?		# Intel 82553 PHYs
 .Cd lxtphy*   at mii? phy ?		# Level One LXT-970 PHYs
 .Cd makphy*   at mii? phy ?		# Marvel 88E1000 Gig-E PHYs
+.Cd micphy*   at mii? phy ?		# Micrel KSZ9021 Gig-E PHYs
 .Cd nsphy*at mii? phy ?		# NatSemi DP83840 PHYs
 .Cd nsphyter* at mii? phy ?		# NatSemi DP83843/DP83815 PHYs
 .Cd pnaphy*   at mii? phy ?		# Generic HomePNA PHYs
@@ -113,6 +114,7 @@ program.
 .Xr iophy 4 ,
 .Xr lxtphy 4 ,
 .Xr makphy 4 ,
+.Xr micphy 4 ,
 .Xr nsphy 4 ,
 .Xr nsphyter 4 ,
 .Xr pnaphy 4 ,



CVS commit: src/share/man/man4

2014-03-02 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Mar  3 02:03:31 UTC 2014

Modified Files:
src/share/man/man4: Makefile

Log Message:
Add micphy.4


To generate a diff of this commit:
cvs rdiff -u -r1.608 -r1.609 src/share/man/man4/Makefile

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/Makefile
diff -u src/share/man/man4/Makefile:1.608 src/share/man/man4/Makefile:1.609
--- src/share/man/man4/Makefile:1.608	Mon Feb 24 07:23:40 2014
+++ src/share/man/man4/Makefile	Mon Mar  3 02:03:31 2014
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.608 2014/02/24 07:23:40 skrll Exp $
+#	$NetBSD: Makefile,v 1.609 2014/03/03 02:03:31 ozaki-r Exp $
 #	@(#)Makefile	8.1 (Berkeley) 6/18/93
 
 MAN=	aac.4 ac97.4 acardide.4 aceride.4 acphy.4 \
@@ -38,7 +38,7 @@ MAN=	aac.4 ac97.4 acardide.4 aceride.4 a
 	kloader.4 kse.4 ksyms.4 kttcp.4 \
 	lc.4 ld.4 lii.4 lo.4 lua.4 lxtphy.4 \
 	mainbus.4 makphy.4 malo.4 mbe.4 mca.4 mcclock.4 md.4 mfb.4 mfi.4 mhzc.4 \
-	midi.4 mii.4 mk48txx.4 mlx.4 mly.4 mpls.4 mpii.4 mpt.4 mpu.4 mtd.4 \
+	micphy.4 midi.4 mii.4 mk48txx.4 mlx.4 mly.4 mpls.4 mpii.4 mpt.4 mpu.4 mtd.4 \
 	mtio.4 msm6242b.4 multicast.4 mvsata.4 \
 	nadb.4 ne.4 neo.4 netintro.4 nfe.4 nfsmb.4 njata.4 njs.4 \
 	nsclpcsio.4 nside.4 nsp.4 nsphy.4 nsphyter.4 ntwoc.4 null.4 nsmb.4 \



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

2014-03-02 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Mar  3 02:10:24 UTC 2014

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

Log Message:
Add micphy


To generate a diff of this commit:
cvs rdiff -u -r1.1460 -r1.1461 src/distrib/sets/lists/man/mi

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

Modified files:

Index: src/distrib/sets/lists/man/mi
diff -u src/distrib/sets/lists/man/mi:1.1460 src/distrib/sets/lists/man/mi:1.1461
--- src/distrib/sets/lists/man/mi:1.1460	Mon Feb 24 07:23:39 2014
+++ src/distrib/sets/lists/man/mi	Mon Mar  3 02:10:24 2014
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1460 2014/02/24 07:23:39 skrll Exp $
+# $NetBSD: mi,v 1.1461 2014/03/03 02:10:24 ozaki-r Exp $
 #
 # Note: don't delete entries from here - mark them as obsolete instead.
 #
@@ -1363,6 +1363,7 @@
 ./usr/share/man/cat4/mfi.0			man-sys-catman		.cat
 ./usr/share/man/cat4/mgadrm.0			man-sys-catman		.cat
 ./usr/share/man/cat4/mhzc.0			man-sys-catman		.cat
+./usr/share/man/cat4/micphy.0			man-sys-catman		.cat
 ./usr/share/man/cat4/midi.0			man-sys-catman		.cat
 ./usr/share/man/cat4/mii.0			man-sys-catman		.cat
 ./usr/share/man/cat4/mixer.0			man-sys-catman		.cat
@@ -4333,6 +4334,7 @@
 ./usr/share/man/html4/mfi.html			man-sys-htmlman		html
 ./usr/share/man/html4/mgadrm.html		man-sys-htmlman		html
 ./usr/share/man/html4/mhzc.html			man-sys-htmlman		html
+./usr/share/man/html4/micphy.html		man-sys-htmlman		html
 ./usr/share/man/html4/midi.html			man-sys-htmlman		html
 ./usr/share/man/html4/mii.html			man-sys-htmlman		html
 ./usr/share/man/html4/mixer.html		man-sys-htmlman		html
@@ -7151,6 +7153,7 @@
 ./usr/share/man/man4/mfi.4			man-sys-man		.man
 ./usr/share/man/man4/mgadrm.4			man-sys-man		.man
 ./usr/share/man/man4/mhzc.4			man-sys-man		.man
+./usr/share/man/man4/micphy.4			man-sys-man		.man
 ./usr/share/man/man4/midi.4			man-sys-man		.man
 ./usr/share/man/man4/mii.4			man-sys-man		.man
 ./usr/share/man/man4/mixer.4			man-sys-man		.man



CVS commit: src/sys/modules/iic

2014-03-03 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Tue Mar  4 00:54:55 UTC 2014

Modified Files:
src/sys/modules/iic: iic.ioconf

Log Message:
Remove unnecessary files.i2c inclusion

files.i2c is already included in conf/files. So we don't need to include
it in this file.

This fix shuts up many warnings on building sys/modules/iic.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/modules/iic/iic.ioconf

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

Modified files:

Index: src/sys/modules/iic/iic.ioconf
diff -u src/sys/modules/iic/iic.ioconf:1.1 src/sys/modules/iic/iic.ioconf:1.2
--- src/sys/modules/iic/iic.ioconf:1.1	Sun Oct  2 21:14:22 2011
+++ src/sys/modules/iic/iic.ioconf	Tue Mar  4 00:54:55 2014
@@ -1,9 +1,8 @@
-#	$NetBSD: iic.ioconf,v 1.1 2011/10/02 21:14:22 jmcneill Exp $
+#	$NetBSD: iic.ioconf,v 1.2 2014/03/04 00:54:55 ozaki-r Exp $
 
 ioconf		iic
 
 include		conf/files
-include		dev/i2c/files.i2c
 
 pseudo-root	i2cbus*
 iic*		at i2cbus?



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

2014-03-03 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Tue Mar  4 03:20:49 UTC 2014

Modified Files:
src/external/cddl/osnet/dev/dtrace: dtrace_debug.c

Log Message:
Fix wrong conditional statement in dtrace_debug_output

Reported in PR kern/48547 by ozaki-r.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/external/cddl/osnet/dev/dtrace/dtrace_debug.c

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

Modified files:

Index: src/external/cddl/osnet/dev/dtrace/dtrace_debug.c
diff -u src/external/cddl/osnet/dev/dtrace/dtrace_debug.c:1.6 src/external/cddl/osnet/dev/dtrace/dtrace_debug.c:1.7
--- src/external/cddl/osnet/dev/dtrace/dtrace_debug.c:1.6	Sun Apr 14 16:39:59 2013
+++ src/external/cddl/osnet/dev/dtrace/dtrace_debug.c	Tue Mar  4 03:20:49 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: dtrace_debug.c,v 1.6 2013/04/14 16:39:59 christos Exp $	*/
+/*	$NetBSD: dtrace_debug.c,v 1.7 2014/03/04 03:20:49 ozaki-r Exp $	*/
 
 /*-
  * Copyright (C) 2008 John Birrell j...@freebsd.org.
@@ -167,7 +167,7 @@ dtrace_debug_output(void)
 
 			for (p = d-first; p  d-next; p++)
 *p1++ = *p;
-		} else if (d-next  d-first) {
+		} else if (d-first  d-next) {
 			char *p1 = dtrace_debug_bufr;
 
 			count = (uintptr_t) d-last - (uintptr_t) d-first;



CVS commit: src/external/cddl/osnet/sys/sys

2014-03-04 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Tue Mar  4 09:24:42 UTC 2014

Modified Files:
src/external/cddl/osnet/sys/sys: mount.h

Log Message:
Get rid of unused variable definition za from mount.h

There is no user for it. Even worse, it breaks dtrace build for arm.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/external/cddl/osnet/sys/sys/mount.h

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

Modified files:

Index: src/external/cddl/osnet/sys/sys/mount.h
diff -u src/external/cddl/osnet/sys/sys/mount.h:1.6 src/external/cddl/osnet/sys/sys/mount.h:1.7
--- src/external/cddl/osnet/sys/sys/mount.h:1.6	Sat Oct 20 22:11:38 2012
+++ src/external/cddl/osnet/sys/sys/mount.h	Tue Mar  4 09:24:42 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: mount.h,v 1.6 2012/10/20 22:11:38 riastradh Exp $	*/
+/*	$NetBSD: mount.h,v 1.7 2014/03/04 09:24:42 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 2007 Pawel Jakub Dawidek p...@freebsd.org
@@ -52,7 +52,7 @@ struct zfs_args {
 	int  datalen;
 	int  optlen;
 	int  flags;
-} za;
+};
 
 typedef struct zfs_args zfs_args_t;
 



CVS commit: src/external/cddl/osnet/dev/dtrace/arm

2014-03-04 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Tue Mar  4 11:07:40 UTC 2014

Modified Files:
src/external/cddl/osnet/dev/dtrace/arm: dtrace_asm.S

Log Message:
Add missing END for each function


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/external/cddl/osnet/dev/dtrace/arm/dtrace_asm.S

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

Modified files:

Index: src/external/cddl/osnet/dev/dtrace/arm/dtrace_asm.S
diff -u src/external/cddl/osnet/dev/dtrace/arm/dtrace_asm.S:1.1 src/external/cddl/osnet/dev/dtrace/arm/dtrace_asm.S:1.2
--- src/external/cddl/osnet/dev/dtrace/arm/dtrace_asm.S:1.1	Fri Jun 21 19:16:00 2013
+++ src/external/cddl/osnet/dev/dtrace/arm/dtrace_asm.S	Tue Mar  4 11:07:40 2014
@@ -42,12 +42,14 @@ void dtrace_membar_producer(void)
 */
 ENTRY(dtrace_membar_producer)
 	RET
+END(dtrace_membar_producer)
 
 /*
 void dtrace_membar_consumer(void)
 */
 ENTRY(dtrace_membar_consumer)
 	RET
+END(dtrace_membar_consumer)
 
 /*
 dtrace_icookie_t dtrace_interrupt_disable(void)
@@ -58,6 +60,8 @@ ENTRY(dtrace_interrupt_disable)
 	orr	r1, r1, #(I32_bit|F32_bit)
 	msr	cpsr_c, r1
 	RET
+END(dtrace_interrupt_disable)
+
 /*
 void dtrace_interrupt_enable(dtrace_icookie_t cookie)
 */
@@ -68,6 +72,7 @@ ENTRY(dtrace_interrupt_enable)
 	orr	r1, r1, r0
 	msr	cpsr_c, r1
 	RET
+END(dtrace_interrupt_enable)
 
 /*
 uint32_t dtrace_cas32(uint32_t *target, uint32_t cmp, uint32_t new)
@@ -95,6 +100,8 @@ ENTRY(dtrace_cas32)
 	msr	cpsr_c, r3
 	ldmfd	sp!, {r4, r5}
 	RET
+END(dtrace_cas32)
+END(dtrace_casptr)
 
 /*
 uint8_t
@@ -104,6 +111,7 @@ ENTRY(dtrace_fuword8_nocheck)
 	ldrb	r3, [r0]
 	mov 	r0, r3
 	RET
+END(dtrace_fuword8_nocheck)
 
 /*
 uint16_t
@@ -113,6 +121,7 @@ ENTRY(dtrace_fuword16_nocheck)
 	ldrh	r3, [r0]
 	mov 	r0, r3
 	RET
+END(dtrace_fuword16_nocheck)
 
 /*
 uint32_t
@@ -122,6 +131,7 @@ ENTRY(dtrace_fuword32_nocheck)
 	ldr	r3, [r0]
 	mov 	r0, r3
 	RET
+END(dtrace_fuword32_nocheck)
 
 /*
 uint64_t
@@ -142,6 +152,7 @@ ENTRY(dtrace_fuword64_nocheck)
 	mov	r1, r2
 #endif
 	RET
+END(dtrace_fuword64_nocheck)
 
 /*
 void
@@ -161,6 +172,7 @@ ENTRY(dtrace_copy)
 
 2:	ldmfd   sp!, {r4-r5}			/* stack is 8 byte aligned */
 	RET
+END(dtrace_copy)
 
 
 /*
@@ -184,6 +196,7 @@ ENTRY(dtrace_copystr)
 
 2:	ldmfd   sp!, {r4-r5}			/* stack is 8 byte aligned */
 	RET
+END(dtrace_copystr)
 
 
 /*
@@ -191,12 +204,14 @@ void dtrace_invop_init(void)
 */
 ENTRY(dtrace_invop_init)
 	RET
+END(dtrace_invop_init)
 
 /*
 void dtrace_invop_uninit(void)
 */
 ENTRY(dtrace_invop_uninit)
 	RET
+END(dtrace_invop_uninit)
 
 /*
 void
@@ -205,6 +220,7 @@ vpanic(const char *format, va_list alist
 ENTRY(vpanic)/* Initial stack layout: */
 vpanic_common:
 	RET
+END(vpanic)
 
 /*
 void
@@ -212,6 +228,7 @@ dtrace_vpanic(const char *format, va_lis
 */
 ENTRY(dtrace_vpanic)			/* Initial stack layout: */
 	RET
+END(dtrace_vpanic)
 
 /*
 uintptr_t
@@ -220,3 +237,4 @@ dtrace_caller(int aframes)
 ENTRY(dtrace_caller)
 	mov	r0, #-1
 	RET
+END(dtrace_caller)



CVS commit: src/external/cddl/osnet/dev/dtrace/arm

2014-03-04 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Mar  5 02:00:24 UTC 2014

Modified Files:
src/external/cddl/osnet/dev/dtrace/arm: dtrace_isa.c

Log Message:
Use uint32_t instead of u_int32_t


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/external/cddl/osnet/dev/dtrace/arm/dtrace_isa.c

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

Modified files:

Index: src/external/cddl/osnet/dev/dtrace/arm/dtrace_isa.c
diff -u src/external/cddl/osnet/dev/dtrace/arm/dtrace_isa.c:1.1 src/external/cddl/osnet/dev/dtrace/arm/dtrace_isa.c:1.2
--- src/external/cddl/osnet/dev/dtrace/arm/dtrace_isa.c:1.1	Fri Jun 21 19:16:00 2013
+++ src/external/cddl/osnet/dev/dtrace/arm/dtrace_isa.c	Wed Mar  5 02:00:24 2014
@@ -68,7 +68,7 @@ void
 dtrace_getpcstack(pc_t *pcstack, int pcstack_limit, int aframes,
 uint32_t *intrpc)
 {
-	u_int32_t	*frame, *lastframe;
+	uint32_t	*frame, *lastframe;
 	int	scp_offset;
 	int	depth = 0;
 	pc_t caller = (pc_t) solaris_cpu[curcpu].cpu_dtrace_caller;
@@ -78,16 +78,16 @@ dtrace_getpcstack(pc_t *pcstack, int pcs
 
 	aframes++;
 
-	frame = (u_int32_t *)__builtin_frame_address(0);;
+	frame = (uint32_t *)__builtin_frame_address(0);;
 	lastframe = NULL;
 	scp_offset = -(get_pc_str_offset()  2);
 
 	while ((frame != NULL)  (depth  pcstack_limit)) {
 		db_addr_t	scp;
 #if 0 
-		u_int32_t	savecode;
+		uint32_t	savecode;
 		int		r;
-		u_int32_t	*rp;
+		uint32_t	*rp;
 #endif
 
 		/*
@@ -109,7 +109,7 @@ dtrace_getpcstack(pc_t *pcstack, int pcs
 		}
 
 #if 0
-		savecode = ((u_int32_t *)scp)[scp_offset];
+		savecode = ((uint32_t *)scp)[scp_offset];
 		if ((savecode  0x0e10) == 0x0800) {
 			/* Looks like an STM */
 			rp = frame - 4;
@@ -128,7 +128,7 @@ dtrace_getpcstack(pc_t *pcstack, int pcs
 			break; /* Top of stack */
 
 		lastframe = frame;
-		frame = (u_int32_t *)(frame[FR_RFP]);
+		frame = (uint32_t *)(frame[FR_RFP]);
 
 		if (INKERNEL((int)frame)) {
 			/* staying in kernel */
@@ -177,20 +177,20 @@ dtrace_getarg(int arg, int aframes)
 int
 dtrace_getstackdepth(int aframes)
 {
-	u_int32_t	*frame, *lastframe;
+	uint32_t	*frame, *lastframe;
 	int	scp_offset;
 	int	depth = 1;
 
-	frame = (u_int32_t *)__builtin_frame_address(0);;
+	frame = (uint32_t *)__builtin_frame_address(0);;
 	lastframe = NULL;
 	scp_offset = -(get_pc_str_offset()  2);
 
 	while (frame != NULL) {
 		db_addr_t	scp;
 #if 0 
-		u_int32_t	savecode;
+		uint32_t	savecode;
 		int		r;
-		u_int32_t	*rp;
+		uint32_t	*rp;
 #endif
 
 		/*
@@ -208,7 +208,7 @@ dtrace_getstackdepth(int aframes)
 			break; /* Top of stack */
 
 		lastframe = frame;
-		frame = (u_int32_t *)(frame[FR_RFP]);
+		frame = (uint32_t *)(frame[FR_RFP]);
 
 		if (INKERNEL((int)frame)) {
 			/* staying in kernel */



CVS commit: src/external/cddl/osnet/dev/dtrace/arm

2014-03-04 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Mar  5 03:09:17 UTC 2014

Modified Files:
src/external/cddl/osnet/dev/dtrace/arm: dtrace_asm.S

Log Message:
Fix dtrace_cas32 logic

- compare with cmp, not new
- return old value


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/external/cddl/osnet/dev/dtrace/arm/dtrace_asm.S

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

Modified files:

Index: src/external/cddl/osnet/dev/dtrace/arm/dtrace_asm.S
diff -u src/external/cddl/osnet/dev/dtrace/arm/dtrace_asm.S:1.2 src/external/cddl/osnet/dev/dtrace/arm/dtrace_asm.S:1.3
--- src/external/cddl/osnet/dev/dtrace/arm/dtrace_asm.S:1.2	Tue Mar  4 11:07:40 2014
+++ src/external/cddl/osnet/dev/dtrace/arm/dtrace_asm.S	Wed Mar  5 03:09:17 2014
@@ -89,12 +89,12 @@ ENTRY(dtrace_cas32)
 	msr	cpsr_c, r4
 
 	ldr	r5, [r0]
-	cmp	r5, r2
-	movne	r0, #0
+	cmp	r5, r1
+	movne	r0, r5
 	bne	2f
 
 	str	r2, [r0]
-	mov	r0, #1
+	mov	r0, r5
 
 2:
 	msr	cpsr_c, r3



CVS commit: src/sys/conf

2014-03-04 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Mar  5 03:16:43 UTC 2014

Modified Files:
src/sys/conf: files

Log Message:
Build net/zlib.c for DTrace

This is needed for building DTrace on ARM.


To generate a diff of this commit:
cvs rdiff -u -r1.1084 -r1.1085 src/sys/conf/files

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

Modified files:

Index: src/sys/conf/files
diff -u src/sys/conf/files:1.1084 src/sys/conf/files:1.1085
--- src/sys/conf/files:1.1084	Thu Feb 27 13:00:06 2014
+++ src/sys/conf/files	Wed Mar  5 03:16:43 2014
@@ -1,4 +1,4 @@
-#	$NetBSD: files,v 1.1084 2014/02/27 13:00:06 hannken Exp $
+#	$NetBSD: files,v 1.1085 2014/03/05 03:16:43 ozaki-r Exp $
 #	@(#)files.newconf	7.5 (Berkeley) 5/10/93
 
 version 	20100430
@@ -1707,7 +1707,7 @@ file	net/route.c
 file	net/rtbl.c
 file	net/rtsock.c
 file	net/slcompress.c		sl | ppp | strip | (irip  irip_vj)
-file	net/zlib.c			(ppp  ppp_deflate) | opencrypto | vnd_compression
+file	net/zlib.c			(ppp  ppp_deflate) | opencrypto | vnd_compression | kdtrace_hooks
 file	netinet/accf_data.c		accf_data
 file	netinet/accf_http.c		accf_http
 file	netinet/cpu_in_cksum.c		(inet | inet6)  !cpu_in_cksum



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

2014-03-04 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Mar  5 06:06:42 UTC 2014

Modified Files:
src/external/cddl/osnet/dev/dtrace: dtrace_debug.c

Log Message:
Use native atomic function instead of DTrace's own one

So we don't need to implement it for each architecture.

This change is from FreeBSD (not as-is though).


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/external/cddl/osnet/dev/dtrace/dtrace_debug.c

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

Modified files:

Index: src/external/cddl/osnet/dev/dtrace/dtrace_debug.c
diff -u src/external/cddl/osnet/dev/dtrace/dtrace_debug.c:1.7 src/external/cddl/osnet/dev/dtrace/dtrace_debug.c:1.8
--- src/external/cddl/osnet/dev/dtrace/dtrace_debug.c:1.7	Tue Mar  4 03:20:49 2014
+++ src/external/cddl/osnet/dev/dtrace/dtrace_debug.c	Wed Mar  5 06:06:42 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: dtrace_debug.c,v 1.7 2014/03/04 03:20:49 ozaki-r Exp $	*/
+/*	$NetBSD: dtrace_debug.c,v 1.8 2014/03/05 06:06:42 ozaki-r Exp $	*/
 
 /*-
  * Copyright (C) 2008 John Birrell j...@freebsd.org.
@@ -36,62 +36,6 @@ static char const hex2ascii_data[] = 01
 
 #ifdef DEBUG
 
-#if defined(__amd64__)
-static __inline int
-dtrace_cmpset_long(volatile u_long *dst, u_long exp, u_long src)
-{
-	u_char res;
-
-	__asm __volatile(
-		 lock ; 		
-		cmpxchgq %2,%1 ;	
-	   sete	%0 ;		
-	1:
-	# dtrace_cmpset_long
-	: =a (res),			/* 0 */
-	  =m (*dst)			/* 1 */
-	: r (src),			/* 2 */
-	  a (exp),			/* 3 */
-	  m (*dst)			/* 4 */
-	: memory);
-
-	return (res);
-}
-#elif defined(__i386__)
-static __inline int
-dtrace_cmpset_long(volatile u_long *dst, u_long exp, u_long src)
-{
-	u_char res;
-
-	__asm __volatile(
-	lock ;	
-	   cmpxchgl %2,%1 ;
-	   sete%0 ;
-	1: 
-	# dtrace_cmpset_long
-	: =a (res),   /* 0 */
-	  =m (*dst)   /* 1 */
-	: r (src),/* 2 */
-	  a (exp),/* 3 */
-	  m (*dst)/* 4 */
-	: memory);
-
-	return (res);
-}
-#elif defined(__arm__)
-static __inline int
-dtrace_cmpset_long(volatile u_long *dst, u_long exp, u_long src)
-{
-	u_char res;
-	if (*dst == src) {
-		res = *dst;
-		*dst = src;
-		return res;
-	}
-	return exp;
-}
-#endif
-
 #define DTRACE_DEBUG_BUFR_SIZE	(32 * 1024)
 
 struct dtrace_debug_data {
@@ -108,7 +52,8 @@ static volatile u_long	dtrace_debug_flag
 static void
 dtrace_debug_lock(int cpu)
 {
-	while (dtrace_cmpset_long(dtrace_debug_flag[cpu], 0, 1) == 0)
+	/* FIXME: use atomic_cmpset_ulong once we have it  */
+	while (atomic_cas_ulong(dtrace_debug_flag[cpu], 0, 1) == 0)
 		/* Loop until the lock is obtained. */
 		;
 }



CVS commit: src/external/cddl/osnet/dist/uts/common

2014-03-04 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Mar  5 06:12:00 UTC 2014

Modified Files:
src/external/cddl/osnet/dist/uts/common/dtrace: dtrace.c
src/external/cddl/osnet/dist/uts/common/sys: dtrace.h

Log Message:
Add defined(__arm__)


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 \
src/external/cddl/osnet/dist/uts/common/dtrace/dtrace.c
cvs rdiff -u -r1.8 -r1.9 src/external/cddl/osnet/dist/uts/common/sys/dtrace.h

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

Modified files:

Index: src/external/cddl/osnet/dist/uts/common/dtrace/dtrace.c
diff -u src/external/cddl/osnet/dist/uts/common/dtrace/dtrace.c:1.23 src/external/cddl/osnet/dist/uts/common/dtrace/dtrace.c:1.24
--- src/external/cddl/osnet/dist/uts/common/dtrace/dtrace.c:1.23	Fri Jun 21 16:22:46 2013
+++ src/external/cddl/osnet/dist/uts/common/dtrace/dtrace.c	Wed Mar  5 06:12:00 2014
@@ -16603,7 +16603,7 @@ static int		dtrace_unload(void);
 #include dtrace_unload.c
 #include dtrace_vtime.c
 #include dtrace_hacks.c
-#if defined(__i386__) || defined(__x86_64__)
+#if defined(__i386__) || defined(__x86_64__) || defined(__arm__)
 #include dtrace_isa.c
 #endif
 

Index: src/external/cddl/osnet/dist/uts/common/sys/dtrace.h
diff -u src/external/cddl/osnet/dist/uts/common/sys/dtrace.h:1.8 src/external/cddl/osnet/dist/uts/common/sys/dtrace.h:1.9
--- src/external/cddl/osnet/dist/uts/common/sys/dtrace.h:1.8	Sun Jul 17 20:54:33 2011
+++ src/external/cddl/osnet/dist/uts/common/sys/dtrace.h	Wed Mar  5 06:12:00 2014
@@ -2286,7 +2286,7 @@ extern void dtrace_safe_synchronous_sign
 
 extern int dtrace_mach_aframes(void);
 
-#if defined(__i386) || defined(__amd64)
+#if defined(__i386) || defined(__amd64) || defined(__arm__)
 extern int dtrace_instr_size(uchar_t *instr);
 extern int dtrace_instr_size_isa(uchar_t *, model_t, int *);
 extern void dtrace_invop_add(int (*)(uintptr_t, uintptr_t *, uintptr_t));



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

2014-03-04 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Mar  5 06:35:44 UTC 2014

Added Files:
src/external/cddl/osnet/dev/cyclic/arm: cyclic_machdep.c

Log Message:
Add cyclic_machdep.c for ARM

The code is still almost same as i386's one.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 \
src/external/cddl/osnet/dev/cyclic/arm/cyclic_machdep.c

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

Added files:

Index: src/external/cddl/osnet/dev/cyclic/arm/cyclic_machdep.c
diff -u /dev/null src/external/cddl/osnet/dev/cyclic/arm/cyclic_machdep.c:1.1
--- /dev/null	Wed Mar  5 06:35:44 2014
+++ src/external/cddl/osnet/dev/cyclic/arm/cyclic_machdep.c	Wed Mar  5 06:35:44 2014
@@ -0,0 +1,150 @@
+/*	$NetBSD: cyclic_machdep.c,v 1.1 2014/03/05 06:35:44 ozaki-r Exp $	*/
+
+/*
+ * Copyright 2006-2008 John Birrell j...@freebsd.org
+ *
+ * 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 AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ *
+ */
+
+#include arm/armreg.h
+
+static void enable(cyb_arg_t);
+static void disable(cyb_arg_t);
+static void reprogram(cyb_arg_t, hrtime_t);
+static void xcall(cyb_arg_t, cpu_t *, cyc_func_t, void *);
+
+static cyc_backend_t	be	= {
+	NULL,		/* cyb_configure */
+	NULL,		/* cyb_unconfigure */
+	enable,
+	disable,
+	reprogram,
+	xcall,
+	NULL		/* cyb_arg_t cyb_arg */
+};
+
+static void
+cyclic_ap_start(void *dummy)
+{
+	/* Initialise the rest of the CPUs. */
+	cyclic_mp_init();
+}
+
+SYSINIT(cyclic_ap_start, SI_SUB_SMP, SI_ORDER_ANY, cyclic_ap_start, NULL);
+
+/*
+ *  Machine dependent cyclic subsystem initialisation.
+ */
+static void
+cyclic_machdep_init(void)
+{
+	/* Register the cyclic backend. */
+	cyclic_init(be);
+#ifdef __NetBSD__
+	cyclic_ap_start(NULL);
+#endif
+}
+
+static void
+cyclic_machdep_uninit(void)
+{
+	int i;
+
+	for (i = 0; i = mp_maxid; i++)
+		/* Reset the cyclic clock callback hook. */
+		cyclic_clock_func[i] = NULL;
+
+	/* De-register the cyclic backend. */
+	cyclic_uninit();
+}
+
+static hrtime_t exp_due[MAXCPU];
+
+/*
+ * This function is the one registered by the machine dependent
+ * initialiser as the callback for high speed timer events.
+ */
+static void
+cyclic_clock(struct clockframe *frame)
+{
+	cpu_t *c = solaris_cpu[cpu_number()];
+
+	if (c-cpu_cyclic != NULL  gethrtime() = exp_due[cpu_number()]) {
+		if (TRAPF_USERMODE(frame)) {
+			c-cpu_profile_pc = 0;
+			c-cpu_profile_upc = TRAPF_PC(frame);
+		} else {
+			c-cpu_profile_pc = TRAPF_PC(frame);
+			c-cpu_profile_upc = 0;
+		}
+
+		c-cpu_intr_actv = 1;
+
+		/* Fire any timers that are due. */
+		cyclic_fire(c);
+
+		c-cpu_intr_actv = 0;
+	}
+}
+
+static void enable(cyb_arg_t arg)
+{
+	/* Register the cyclic clock callback function. */
+	cyclic_clock_func[cpu_number()] = cyclic_clock;
+}
+
+static void disable(cyb_arg_t arg)
+{
+	/* Reset the cyclic clock callback function. */
+	cyclic_clock_func[cpu_number()] = NULL;
+}
+
+static void reprogram(cyb_arg_t arg, hrtime_t exp)
+{
+	exp_due[cpu_number()] = exp;
+}
+
+#ifdef __NetBSD__
+static void xcall_func(void *arg0, void *arg1)
+{
+	cyc_func_t func;
+
+	func = arg0;
+	(*func)(arg1);
+}
+#endif
+
+static void xcall(cyb_arg_t arg, cpu_t *c, cyc_func_t func, void *param)
+{
+#ifdef __NetBSD__
+	uint64_t xc;
+
+	xc = xc_unicast(XC_HIGHPRI, xcall_func, func, param, cpu_lookup(c-cpuid));
+	xc_wait(xc);
+#else
+	smp_rendezvous_cpus((cpumask_t) (1  c-cpuid),
+	smp_no_rendevous_barrier, func, smp_no_rendevous_barrier, param);
+#endif
+}



CVS commit: src/sys/modules

2014-03-04 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Mar  5 06:40:45 UTC 2014

Modified Files:
src/sys/modules/cyclic: Makefile
src/sys/modules/dtrace/dtrace: Makefile

Log Message:
Tidy up Makefile of cyclic and dtrace modules to support ARM


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/modules/cyclic/Makefile
cvs rdiff -u -r1.3 -r1.4 src/sys/modules/dtrace/dtrace/Makefile

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

Modified files:

Index: src/sys/modules/cyclic/Makefile
diff -u src/sys/modules/cyclic/Makefile:1.2 src/sys/modules/cyclic/Makefile:1.3
--- src/sys/modules/cyclic/Makefile:1.2	Fri Dec 14 15:46:51 2012
+++ src/sys/modules/cyclic/Makefile	Wed Mar  5 06:40:45 2014
@@ -2,14 +2,26 @@
 
 .include ../Makefile.inc
 
-.PATH: ${NETBSDSRCDIR}/external/cddl/osnet/dev/cyclic
+.include bsd.own.mk
+
+OSNETDIR=${NETBSDSRCDIR}/external/cddl/osnet
+
+.if exists(${OSNETDIR}/dev/cyclic/${MACHINE:S/amd64/i386/})
+ARCH=${MACHINE:S/amd64/i386/}
+.elif exists(${OSNETDIR}/dev/cyclic/${MACHINE_CPU})
+ARCH=${MACHINE_CPU}
+.else
+.error ${MACHINE} or ${MACHINE_CPU} not supported.
+.endif
+
+.PATH: ${OSNETDIR}/dev/cyclic
 
 KMOD=		cyclic
 SRCS=		cyclic.c
 
-CPPFLAGS+=	-I${NETBSDSRCDIR}/external/cddl/osnet/sys \
-		-I${NETBSDSRCDIR}/external/cddl/osnet/dev/cyclic/${MACHINE:S/amd64/i386/} \
-		-I${NETBSDSRCDIR}/external/cddl/osnet/dist/uts/common
+CPPFLAGS+=	-I${OSNETDIR}/sys \
+		-I${OSNETDIR}/dev/cyclic/${ARCH} \
+		-I${OSNETDIR}/dist/uts/common
 
 CPPFLAGS+=	-Wno-unknown-pragmas -Wno-cast-qual
 

Index: src/sys/modules/dtrace/dtrace/Makefile
diff -u src/sys/modules/dtrace/dtrace/Makefile:1.3 src/sys/modules/dtrace/dtrace/Makefile:1.4
--- src/sys/modules/dtrace/dtrace/Makefile:1.3	Tue Dec 14 23:27:47 2010
+++ src/sys/modules/dtrace/dtrace/Makefile	Wed Mar  5 06:40:45 2014
@@ -3,11 +3,21 @@
 .include ../../Makefile.inc
 .include ../../Makefile.assym
 
-ARCHDIR=	${MACHINE}
+.include bsd.own.mk
 
-.PATH: ${NETBSDSRCDIR}/external/cddl/osnet/dist/uts/common/dtrace
-.PATH: ${NETBSDSRCDIR}/external/cddl/osnet/dev/dtrace
-.PATH: ${NETBSDSRCDIR}/external/cddl/osnet/dev/dtrace/${ARCHDIR}
+OSNETDIR=${NETBSDSRCDIR}/external/cddl/osnet
+
+.if exists(${OSNETDIR}/dev/dtrace/${MACHINE})
+ARCH=${MACHINE}
+.elif exists(${OSNETDIR}/dev/dtrace/${MACHINE_CPU})
+ARCH=${MACHINE_CPU}
+.else
+.error ${MACHINE} or ${MACHINE_CPU} not supported.
+.endif
+
+.PATH: ${OSNETDIR}/dist/uts/common/dtrace
+.PATH: ${OSNETDIR}/dev/dtrace
+.PATH: ${OSNETDIR}/dev/dtrace/${ARCH}
 
 KMOD=		dtrace
 SRCS=		dtrace.c \
@@ -19,10 +29,10 @@ SRCS+=		dis_tables.c \
 		instr_size.c
 .endif
 
-CPPFLAGS+=	-I${NETBSDSRCDIR}/external/cddl/osnet/sys \
-		-I${NETBSDSRCDIR}/external/cddl/osnet/dev/dtrace \
-		-I${NETBSDSRCDIR}/external/cddl/osnet/dev/dtrace/${ARCHDIR} \
-		-I${NETBSDSRCDIR}/external/cddl/osnet/dist/uts/common \
+CPPFLAGS+=	-I${OSNETDIR}/sys \
+		-I${OSNETDIR}/dev/dtrace \
+		-I${OSNETDIR}/dev/dtrace/${ARCH} \
+		-I${OSNETDIR}/dist/uts/common \
 		-DDIS_MEM
 
 CPPFLAGS+=	-DSMP -DDEBUG



CVS commit: src/external/cddl/osnet/dist/uts/common/dtrace

2014-03-06 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Fri Mar  7 02:37:16 UTC 2014

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

Log Message:
Fix build of DTrace with GCC 4.8

Use __diagused for a variable which is only referred by KASSERT.

Advised by matt@


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 \
src/external/cddl/osnet/dist/uts/common/dtrace/dtrace.c

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

Modified files:

Index: src/external/cddl/osnet/dist/uts/common/dtrace/dtrace.c
diff -u src/external/cddl/osnet/dist/uts/common/dtrace/dtrace.c:1.25 src/external/cddl/osnet/dist/uts/common/dtrace/dtrace.c:1.26
--- src/external/cddl/osnet/dist/uts/common/dtrace/dtrace.c:1.25	Wed Mar  5 20:14:15 2014
+++ src/external/cddl/osnet/dist/uts/common/dtrace/dtrace.c	Fri Mar  7 02:37:16 2014
@@ -16655,7 +16655,7 @@ dtrace_state_worker_add(void (*fn)(dtrac
 hrtime_t interval)
 {
 	struct dtrace_state_worker *w;
-	int error;
+	int error __diagused;
 
 	w = kmem_alloc(sizeof(*w), KM_SLEEP);
 	mutex_init(w-lock, MUTEX_DEFAULT, IPL_NONE);
@@ -1,7 +1,6 @@ dtrace_state_worker_add(void (*fn)(dtrac
 	w-exiting = false;
 	error = kthread_create(PRI_NONE, KTHREAD_MPSAFE|KTHREAD_MUSTJOIN, NULL,
 	dtrace_state_worker_thread, w, w-lwp, dtrace-state-worker);
-	(void) error;
 	KASSERT(error == 0); /* XXX */
 	return w;
 }
@@ -16674,7 +16673,7 @@ dtrace_state_worker_add(void (*fn)(dtrac
 void
 dtrace_state_worker_remove(struct dtrace_state_worker *w)
 {
-	int error;
+	int error __diagused;
 
 	KASSERT(!w-exiting);
 	mutex_enter(w-lock);



CVS commit: src/external/cddl/osnet/dev/dtrace/arm

2014-03-08 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Sat Mar  8 11:46:01 UTC 2014

Modified Files:
src/external/cddl/osnet/dev/dtrace/arm: dtrace_isa.c

Log Message:
Prepare dtrace_isa.c for build

- Tidy up header file inclusions
- Replace curcpu with cpu_number()
- Fix argument of dtrace_getreg
- Tweak for gcc 4.8

Note that the file is still not buildable.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/external/cddl/osnet/dev/dtrace/arm/dtrace_isa.c

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

Modified files:

Index: src/external/cddl/osnet/dev/dtrace/arm/dtrace_isa.c
diff -u src/external/cddl/osnet/dev/dtrace/arm/dtrace_isa.c:1.2 src/external/cddl/osnet/dev/dtrace/arm/dtrace_isa.c:1.3
--- src/external/cddl/osnet/dev/dtrace/arm/dtrace_isa.c:1.2	Wed Mar  5 02:00:24 2014
+++ src/external/cddl/osnet/dev/dtrace/arm/dtrace_isa.c	Sat Mar  8 11:46:01 2014
@@ -30,24 +30,14 @@
 #include sys/param.h
 #include sys/systm.h
 #include sys/kernel.h
-#include sys/stack.h
-#include sys/pcpu.h
 
 #include machine/frame.h
-#include machine/md_var.h
 #include machine/reg.h
 
-#include vm/vm.h
-#include vm/vm_param.h
-#include vm/pmap.h
-
 #include machine/db_machdep.h
-#include machine/md_var.h
 #include machine/vmparam.h
-#include machine/stack.h
 #include ddb/db_sym.h
 #include ddb/ddb.h
-#include sys/kdb.h
 
 #include regset.h
 
@@ -69,9 +59,11 @@ dtrace_getpcstack(pc_t *pcstack, int pcs
 uint32_t *intrpc)
 {
 	uint32_t	*frame, *lastframe;
+#if 0
 	int	scp_offset;
+#endif
 	int	depth = 0;
-	pc_t caller = (pc_t) solaris_cpu[curcpu].cpu_dtrace_caller;
+	pc_t caller = (pc_t) solaris_cpu[cpu_number()].cpu_dtrace_caller;
 
 	if (intrpc != 0)
 		pcstack[depth++] = (pc_t) intrpc;
@@ -80,7 +72,9 @@ dtrace_getpcstack(pc_t *pcstack, int pcs
 
 	frame = (uint32_t *)__builtin_frame_address(0);;
 	lastframe = NULL;
+#if 0
 	scp_offset = -(get_pc_str_offset()  2);
+#endif
 
 	while ((frame != NULL)  (depth  pcstack_limit)) {
 		db_addr_t	scp;
@@ -178,27 +172,18 @@ int
 dtrace_getstackdepth(int aframes)
 {
 	uint32_t	*frame, *lastframe;
-	int	scp_offset;
 	int	depth = 1;
 
 	frame = (uint32_t *)__builtin_frame_address(0);;
 	lastframe = NULL;
-	scp_offset = -(get_pc_str_offset()  2);
 
 	while (frame != NULL) {
-		db_addr_t	scp;
 #if 0 
 		uint32_t	savecode;
 		int		r;
 		uint32_t	*rp;
 #endif
 
-		/*
-		 * In theory, the SCP isn't guaranteed to be in the function
-		 * that generated the stack frame.  We hope for the best.
-		 */
-		scp = frame[FR_SCP];
-
 		depth++;
 
 		/*
@@ -229,7 +214,7 @@ dtrace_getstackdepth(int aframes)
 }
 
 ulong_t
-dtrace_getreg(struct trapframe *rp, uint_t reg)
+dtrace_getreg(struct regs *regs, uint_t reg)
 {
 
 	return (0);
@@ -241,7 +226,7 @@ dtrace_copycheck(uintptr_t uaddr, uintpt
 
 	if (uaddr + size  VM_MAXUSER_ADDRESS || uaddr + size  uaddr) {
 		DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR);
-		cpu_core[curcpu].cpuc_dtrace_illval = uaddr;
+		cpu_core[cpu_number()].cpuc_dtrace_illval = uaddr;
 		return (0);
 	}
 
@@ -285,7 +270,7 @@ dtrace_fuword8(void *uaddr)
 {
 	if ((uintptr_t)uaddr  VM_MAXUSER_ADDRESS) {
 		DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR);
-		cpu_core[curcpu].cpuc_dtrace_illval = (uintptr_t)uaddr;
+		cpu_core[cpu_number()].cpuc_dtrace_illval = (uintptr_t)uaddr;
 		return (0);
 	}
 	return (dtrace_fuword8_nocheck(uaddr));
@@ -296,7 +281,7 @@ dtrace_fuword16(void *uaddr)
 {
 	if ((uintptr_t)uaddr  VM_MAXUSER_ADDRESS) {
 		DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR);
-		cpu_core[curcpu].cpuc_dtrace_illval = (uintptr_t)uaddr;
+		cpu_core[cpu_number()].cpuc_dtrace_illval = (uintptr_t)uaddr;
 		return (0);
 	}
 	return (dtrace_fuword16_nocheck(uaddr));
@@ -307,7 +292,7 @@ dtrace_fuword32(void *uaddr)
 {
 	if ((uintptr_t)uaddr  VM_MAXUSER_ADDRESS) {
 		DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR);
-		cpu_core[curcpu].cpuc_dtrace_illval = (uintptr_t)uaddr;
+		cpu_core[cpu_number()].cpuc_dtrace_illval = (uintptr_t)uaddr;
 		return (0);
 	}
 	return (dtrace_fuword32_nocheck(uaddr));
@@ -318,7 +303,7 @@ dtrace_fuword64(void *uaddr)
 {
 	if ((uintptr_t)uaddr  VM_MAXUSER_ADDRESS) {
 		DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR);
-		cpu_core[curcpu].cpuc_dtrace_illval = (uintptr_t)uaddr;
+		cpu_core[cpu_number()].cpuc_dtrace_illval = (uintptr_t)uaddr;
 		return (0);
 	}
 	return (dtrace_fuword64_nocheck(uaddr));



CVS commit: src/sys/netipsec

2014-03-08 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Sat Mar  8 12:18:04 UTC 2014

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

Log Message:
Mark a variable __diagused


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/netipsec/ipsec_input.c

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

Modified files:

Index: src/sys/netipsec/ipsec_input.c
diff -u src/sys/netipsec/ipsec_input.c:1.31 src/sys/netipsec/ipsec_input.c:1.32
--- src/sys/netipsec/ipsec_input.c:1.31	Sun Nov  3 18:37:10 2013
+++ src/sys/netipsec/ipsec_input.c	Sat Mar  8 12:18:04 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: ipsec_input.c,v 1.31 2013/11/03 18:37:10 mrg Exp $	*/
+/*	$NetBSD: ipsec_input.c,v 1.32 2014/03/08 12:18:04 ozaki-r Exp $	*/
 /*	$FreeBSD: /usr/local/www/cvsroot/FreeBSD/src/sys/netipsec/ipsec_input.c,v 1.2.4.2 2003/03/28 20:32:53 sam Exp $	*/
 /*	$OpenBSD: ipsec_input.c,v 1.63 2003/02/20 18:35:43 deraadt Exp $	*/
 
@@ -39,7 +39,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ipsec_input.c,v 1.31 2013/11/03 18:37:10 mrg Exp $);
+__KERNEL_RCSID(0, $NetBSD: ipsec_input.c,v 1.32 2014/03/08 12:18:04 ozaki-r Exp $);
 
 /*
  * IPsec input processing.
@@ -592,7 +592,7 @@ int
 ipsec6_common_input_cb(struct mbuf *m, struct secasvar *sav, int skip, int protoff,
 struct m_tag *mt)
 {
-	int af, sproto;
+	int af __diagused, sproto;
 	struct ip6_hdr *ip6;
 	struct m_tag *mtag;
 	struct tdb_ident *tdbi;



CVS commit: src/sys/conf

2014-03-09 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Mar 10 02:04:29 UTC 2014

Modified Files:
src/sys/conf: Makefile.kern.inc

Log Message:
Use CTFMFLAGS, not CTFFLAGS, for CTFMERGE


To generate a diff of this commit:
cvs rdiff -u -r1.165 -r1.166 src/sys/conf/Makefile.kern.inc

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

Modified files:

Index: src/sys/conf/Makefile.kern.inc
diff -u src/sys/conf/Makefile.kern.inc:1.165 src/sys/conf/Makefile.kern.inc:1.166
--- src/sys/conf/Makefile.kern.inc:1.165	Tue Mar  4 14:58:14 2014
+++ src/sys/conf/Makefile.kern.inc	Mon Mar 10 02:04:29 2014
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.kern.inc,v 1.165 2014/03/04 14:58:14 joerg Exp $
+#	$NetBSD: Makefile.kern.inc,v 1.166 2014/03/10 02:04:29 ozaki-r Exp $
 #
 # This file contains common `MI' targets and definitions and it is included
 # at the bottom of each `MD' ${MACHINE}/conf/Makefile.${MACHINE}.
@@ -226,7 +226,7 @@ SYSTEM_DEP+=	Makefile ${SYSTEM_OBJ:O} .g
 SYSTEM_DEP+=	${KERNLDSCRIPT}
 .endif
 .if defined(CTFMERGE)
-SYSTEM_CTFMERGE= ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${SYSTEM_OBJ} ${EXTRA_OBJ} vers.o
+SYSTEM_CTFMERGE= ${CTFMERGE} ${CTFMFLAGS} -o ${.TARGET} ${SYSTEM_OBJ} ${EXTRA_OBJ} vers.o
 .else
 SYSTEM_CTFMERGE= ${_MKSHECHO}
 .endif



CVS commit: src/sys/conf

2014-03-09 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Mar 10 02:36:50 UTC 2014

Modified Files:
src/sys/conf: Makefile.kern.inc

Log Message:
Do COMPILE_CTFCONVERT on vers.o as same as other targets

Otherwise, we will get the error when building a kernel with -V MKDTRACE:
  ERROR: nbctfmerge: Input file vers.o was partially built from C sources,
  but no CTF data was present


To generate a diff of this commit:
cvs rdiff -u -r1.166 -r1.167 src/sys/conf/Makefile.kern.inc

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

Modified files:

Index: src/sys/conf/Makefile.kern.inc
diff -u src/sys/conf/Makefile.kern.inc:1.166 src/sys/conf/Makefile.kern.inc:1.167
--- src/sys/conf/Makefile.kern.inc:1.166	Mon Mar 10 02:04:29 2014
+++ src/sys/conf/Makefile.kern.inc	Mon Mar 10 02:36:50 2014
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.kern.inc,v 1.166 2014/03/10 02:04:29 ozaki-r Exp $
+#	$NetBSD: Makefile.kern.inc,v 1.167 2014/03/10 02:36:50 ozaki-r Exp $
 #
 # This file contains common `MI' targets and definitions and it is included
 # at the bottom of each `MD' ${MACHINE}/conf/Makefile.${MACHINE}.
@@ -355,6 +355,7 @@ vers.o: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
 	${HOST_SH} $S/conf/newvers.sh ${_NVFLAGS}
 	${_MKTARGET_COMPILE}
 	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
+	${COMPILE_CTFCONVERT}
 .endif
 
 .if defined(MEMORY_DISK_IMAGE)



CVS commit: src/external/cddl/osnet/dev/dtrace/arm

2014-03-09 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Mar 10 03:04:57 UTC 2014

Modified Files:
src/external/cddl/osnet/dev/dtrace/arm: dtrace_subr.c

Log Message:
Make arm/dtrace_subr.c buildable

The change just imports the code from
http://people.freebsd.org/~gonzo/arm/dtrace-arm.diff
and tweaks for NetBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/external/cddl/osnet/dev/dtrace/arm/dtrace_subr.c

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

Modified files:

Index: src/external/cddl/osnet/dev/dtrace/arm/dtrace_subr.c
diff -u src/external/cddl/osnet/dev/dtrace/arm/dtrace_subr.c:1.1 src/external/cddl/osnet/dev/dtrace/arm/dtrace_subr.c:1.2
--- src/external/cddl/osnet/dev/dtrace/arm/dtrace_subr.c:1.1	Fri Jun 21 19:16:00 2013
+++ src/external/cddl/osnet/dev/dtrace/arm/dtrace_subr.c	Mon Mar 10 03:04:57 2014
@@ -1,3 +1,5 @@
+/*	$NetBSD: dtrace_subr.c,v 1.2 2014/03/10 03:04:57 ozaki-r Exp $	*/
+
 /*
  * CDDL HEADER START
  *
@@ -27,25 +29,25 @@
  * Use is subject to license terms.
  */
 
-#include sys/cdefs.h
-__FBSDID($FreeBSD$);
-
 #include sys/param.h
 #include sys/systm.h
 #include sys/types.h
 #include sys/kernel.h
 #include sys/malloc.h
 #include sys/kmem.h
-#include sys/smp.h
+#include sys/xcall.h
+#include sys/cpu.h
+#include sys/cpuvar.h
 #include sys/dtrace_impl.h
 #include sys/dtrace_bsd.h
-#include machine/clock.h
+#include machine/cpu.h
 #include machine/frame.h
-#include machine/trap.h
-#include vm/pmap.h
+#include machine/vmparam.h
+#include uvm/uvm_pglist.h
+#include uvm/uvm_prot.h
+#include uvm/uvm_pmap.h
 
-#define	DELAYBRANCH(x)	((int)(x)  0)
-		
+extern uintptr_t 	kernelbase;
 extern uintptr_t 	dtrace_in_probe_addr;
 extern int		dtrace_in_probe;
 extern dtrace_id_t	dtrace_probeid_error;
@@ -59,6 +61,8 @@ typedef struct dtrace_invop_hdlr {
 
 dtrace_invop_hdlr_t *dtrace_invop_hdlr;
 
+void dtrace_gethrtime_init(void *arg);
+
 int
 dtrace_invop(uintptr_t addr, uintptr_t *stack, uintptr_t eax)
 {
@@ -72,26 +76,76 @@ dtrace_invop(uintptr_t addr, uintptr_t *
 	return (0);
 }
 
+void
+dtrace_invop_add(int (*func)(uintptr_t, uintptr_t *, uintptr_t))
+{
+	dtrace_invop_hdlr_t *hdlr;
+
+	hdlr = kmem_alloc(sizeof (dtrace_invop_hdlr_t), KM_SLEEP);
+	hdlr-dtih_func = func;
+	hdlr-dtih_next = dtrace_invop_hdlr;
+	dtrace_invop_hdlr = hdlr;
+}
+
+void
+dtrace_invop_remove(int (*func)(uintptr_t, uintptr_t *, uintptr_t))
+{
+	dtrace_invop_hdlr_t *hdlr = dtrace_invop_hdlr, *prev = NULL;
+
+	for (;;) {
+		if (hdlr == NULL)
+			panic(attempt to remove non-existent invop handler);
+
+		if (hdlr-dtih_func == func)
+			break;
+
+		prev = hdlr;
+		hdlr = hdlr-dtih_next;
+	}
+
+	if (prev == NULL) {
+		ASSERT(dtrace_invop_hdlr == hdlr);
+		dtrace_invop_hdlr = hdlr-dtih_next;
+	} else {
+		ASSERT(dtrace_invop_hdlr != hdlr);
+		prev-dtih_next = hdlr-dtih_next;
+	}
+
+	kmem_free(hdlr, sizeof (dtrace_invop_hdlr_t));
+}
 
-/*ARGSUSED*/
 void
 dtrace_toxic_ranges(void (*func)(uintptr_t base, uintptr_t limit))
 {
-	printf(IMPLEMENT ME: dtrace_toxic_ranges\n);
+	(*func)(0, kernelbase);
+}
+
+static void
+xcall_func(void *arg0, void *arg1)
+{
+	dtrace_xcall_t func = arg0;
+
+	(*func)(arg1);
 }
 
 void
 dtrace_xcall(processorid_t cpu, dtrace_xcall_t func, void *arg)
 {
-	cpuset_t cpus;
+	uint64_t where;
 
-	if (cpu == DTRACE_CPUALL)
-		cpus = all_cpus;
-	else
-		CPU_SETOF(cpu, cpus);
+	if (cpu == DTRACE_CPUALL) {
+		where = xc_broadcast(0, xcall_func, func, arg);
+	} else {
+		struct cpu_info *cinfo = cpu_lookup(cpu);
 
-	smp_rendezvous_cpus(cpus, smp_no_rendevous_barrier, func,
-	smp_no_rendevous_barrier, arg);
+		KASSERT(cinfo != NULL);
+		where = xc_unicast(0, xcall_func, func, arg, cinfo);
+	}
+	xc_wait(where);
+
+	/* XXX Q. Do we really need the other cpus to wait also? 
+	 * (see solaris:xc_sync())
+	 */
 }
 
 static void
@@ -133,10 +187,12 @@ dtrace_gethrestime(void)
 	return (curtime.tv_sec * 10UL + curtime.tv_nsec);
 }
 
-/* Function to handle DTrace traps during probes. See amd64/amd64/trap.c */
+/* Function to handle DTrace traps during probes. Not used on ARM yet */
 int
 dtrace_trap(struct trapframe *frame, u_int type)
 {
+	cpuid_t cpuid = cpu_number();	/* current cpu id */
+
 	/*
 	 * A trap can occur while DTrace executes a probe. Before
 	 * executing the probe, DTrace blocks re-scheduling and sets
@@ -147,7 +203,8 @@ dtrace_trap(struct trapframe *frame, u_i
 	 * Check if DTrace has enabled 'no-fault' mode:
 	 *
 	 */
-	if ((cpu_core[curcpu].cpuc_dtrace_flags  CPU_DTRACE_NOFAULT) != 0) {
+
+	if ((cpu_core[cpuid].cpuc_dtrace_flags  CPU_DTRACE_NOFAULT) != 0) {
 		/*
 		 * There are only a couple of trap types that are expected.
 		 * All the rest will be handled in the usual way.
@@ -156,8 +213,8 @@ dtrace_trap(struct trapframe *frame, u_i
 		/* Page fault. */
 		case 0:
 			/* Flag a bad address. */
-			cpu_core[curcpu].cpuc_dtrace_flags |= CPU_DTRACE_BADADDR;
-			

CVS commit: src/external/cddl/osnet/dev/dtrace/arm

2014-03-10 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Mar 10 06:38:22 UTC 2014

Modified Files:
src/external/cddl/osnet/dev/dtrace/arm: dtrace_asm.S

Log Message:
Fix header inclusions


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/external/cddl/osnet/dev/dtrace/arm/dtrace_asm.S

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

Modified files:

Index: src/external/cddl/osnet/dev/dtrace/arm/dtrace_asm.S
diff -u src/external/cddl/osnet/dev/dtrace/arm/dtrace_asm.S:1.3 src/external/cddl/osnet/dev/dtrace/arm/dtrace_asm.S:1.4
--- src/external/cddl/osnet/dev/dtrace/arm/dtrace_asm.S:1.3	Wed Mar  5 03:09:17 2014
+++ src/external/cddl/osnet/dev/dtrace/arm/dtrace_asm.S	Mon Mar 10 06:38:22 2014
@@ -34,8 +34,7 @@
 #include sys/dtrace.h
 
 #include machine/asm.h
-
-#include assym.s
+#include arm/armreg.h
 
 /*
 void dtrace_membar_producer(void)



CVS commit: src/sys/arch/hpcarm/hpcarm

2014-03-10 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Tue Mar 11 04:17:36 UTC 2014

Modified Files:
src/sys/arch/hpcarm/hpcarm: pxa2x0_hpc_machdep.c

Log Message:
Remove unused variable found by gcc 4.8


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/hpcarm/hpcarm/pxa2x0_hpc_machdep.c

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

Modified files:

Index: src/sys/arch/hpcarm/hpcarm/pxa2x0_hpc_machdep.c
diff -u src/sys/arch/hpcarm/hpcarm/pxa2x0_hpc_machdep.c:1.20 src/sys/arch/hpcarm/hpcarm/pxa2x0_hpc_machdep.c:1.21
--- src/sys/arch/hpcarm/hpcarm/pxa2x0_hpc_machdep.c:1.20	Mon Aug 26 15:31:06 2013
+++ src/sys/arch/hpcarm/hpcarm/pxa2x0_hpc_machdep.c	Tue Mar 11 04:17:36 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: pxa2x0_hpc_machdep.c,v 1.20 2013/08/26 15:31:06 matt Exp $	*/
+/*	$NetBSD: pxa2x0_hpc_machdep.c,v 1.21 2014/03/11 04:17:36 ozaki-r Exp $	*/
 
 /*
  * Copyright (c) 1994-1998 Mark Brinicombe.
@@ -40,7 +40,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pxa2x0_hpc_machdep.c,v 1.20 2013/08/26 15:31:06 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: pxa2x0_hpc_machdep.c,v 1.21 2014/03/11 04:17:36 ozaki-r Exp $);
 
 #include opt_ddb.h
 #include opt_dram_pages.h
@@ -252,7 +252,6 @@ init_pxa2x0(int argc, char **argv, struc
 	u_int kerneldatasize, symbolsize;
 	u_int l1pagetable;
 	vaddr_t freemempos;
-	vsize_t pt_size;
 	int loop;
 #if NKSYMS || defined(DDB) || defined(MODULAR)
 	Elf_Shdr *sh;
@@ -392,8 +391,6 @@ init_pxa2x0(int argc, char **argv, struc
 	 */
 	valloc_pages(systempage, 1);
 
-	pt_size = round_page(freemempos) - physical_start;
-
 	/* Allocate stacks for all modes */
 	valloc_pages(irqstack, IRQ_STACK_SIZE);
 	valloc_pages(abtstack, ABT_STACK_SIZE);



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

2014-03-14 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Sat Mar 15 05:54:20 UTC 2014

Modified Files:
src/sys/arch/arm/include: trap.h

Log Message:
Add breakpoint definitions for DTrace


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/include/trap.h

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

Modified files:

Index: src/sys/arch/arm/include/trap.h
diff -u src/sys/arch/arm/include/trap.h:1.8 src/sys/arch/arm/include/trap.h:1.9
--- src/sys/arch/arm/include/trap.h:1.8	Sat Jan 19 13:11:09 2008
+++ src/sys/arch/arm/include/trap.h	Sat Mar 15 05:54:20 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.h,v 1.8 2008/01/19 13:11:09 chris Exp $	*/
+/*	$NetBSD: trap.h,v 1.9 2014/03/15 05:54:20 ozaki-r Exp $	*/
 
 /*
  * Copyright (c) 1995 Mark Brinicombe.
@@ -62,6 +62,14 @@
 #define GDB_THUMB_BREAKPOINT	0xdefe		/* Thumb in GDB */
 #define KERNEL_BREAKPOINT	0xe7ff	/* Used by DDB */
 
+/*
+ * DTrace uses 0xe7fffef0 to 0xe7fffeff as breakpoints.
+ * The first byte is used to encode a cond value.
+ */
+#define DTRACE_BREAKPOINT	0xe7fffef0
+#define DTRACE_BREAKPOINT_MASK	0xfff0
+#define DTRACE_IS_BREAKPOINT(insn)	((insn  DTRACE_BREAKPOINT_MASK) == DTRACE_BREAKPOINT)
+
 #define KBPT_ASM		.word 0xe7ffdefe
 
 #define USER_BREAKPOINT		GDB_BREAKPOINT



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

2014-03-14 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Sat Mar 15 05:58:30 UTC 2014

Modified Files:
src/sys/arch/arm/arm: undefined.c

Log Message:
Add a trap handler for DTrace FBT provider


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/sys/arch/arm/arm/undefined.c

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

Modified files:

Index: src/sys/arch/arm/arm/undefined.c
diff -u src/sys/arch/arm/arm/undefined.c:1.52 src/sys/arch/arm/arm/undefined.c:1.53
--- src/sys/arch/arm/arm/undefined.c:1.52	Wed Mar  5 02:18:30 2014
+++ src/sys/arch/arm/arm/undefined.c	Sat Mar 15 05:58:30 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: undefined.c,v 1.52 2014/03/05 02:18:30 matt Exp $	*/
+/*	$NetBSD: undefined.c,v 1.53 2014/03/15 05:58:30 ozaki-r Exp $	*/
 
 /*
  * Copyright (c) 2001 Ben Harris.
@@ -48,13 +48,14 @@
 
 #include opt_ddb.h
 #include opt_kgdb.h
+#include opt_dtrace.h
 
 #include sys/param.h
 #ifdef KGDB
 #include sys/kgdb.h
 #endif
 
-__KERNEL_RCSID(0, $NetBSD: undefined.c,v 1.52 2014/03/05 02:18:30 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: undefined.c,v 1.53 2014/03/15 05:58:30 ozaki-r Exp $);
 
 #include sys/kmem.h
 #include sys/queue.h
@@ -220,6 +221,45 @@ static struct undefined_handler gdb_uh;
 static struct undefined_handler gdb_uh_thumb;
 #endif
 
+#ifdef KDTRACE_HOOKS
+#include sys/dtrace_bsd.h
+
+/* Not used for now, but needed for dtrace/fbt modules */
+dtrace_doubletrap_func_t	dtrace_doubletrap_func = NULL;
+dtrace_trap_func_t		dtrace_trap_func = NULL;
+
+int (* dtrace_invop_jump_addr)(uintptr_t, uintptr_t *, uintptr_t);
+void (* dtrace_emulation_jump_addr)(int, struct trapframe *);
+
+static int
+dtrace_trapper(u_int addr, struct trapframe *frame)
+{
+	int op;
+	struct trapframe back;
+	u_int insn = read_insn(addr, false);
+
+	if (dtrace_invop_jump_addr == NULL || dtrace_emulation_jump_addr == NULL)
+		return 1;
+
+	if (!DTRACE_IS_BREAKPOINT(insn))
+		return 1;
+
+	/* cond value is encoded in the first byte */
+	if (!arm_cond_ok_p(__SHIFTIN(insn, INSN_COND_MASK), frame-tf_spsr)) {
+		frame-tf_pc += INSN_SIZE;
+		return 0;
+	}
+
+	back = *frame;
+	op = dtrace_invop_jump_addr(addr, (uintptr_t *) frame-tf_svc_sp, frame-tf_r0);
+	*frame = back;
+
+	dtrace_emulation_jump_addr(op, frame);
+
+	return 0;
+}
+#endif
+
 void
 undefined_init(void)
 {
@@ -262,6 +302,15 @@ undefinedinstruction(trapframe_t *tf)
 
 	und_ev.ev_count++;
 
+#ifdef KDTRACE_HOOKS
+	if ((tf-tf_spsr  PSR_MODE) != PSR_USR32_MODE) {
+		tf-tf_pc -= INSN_SIZE;
+		if (dtrace_trapper(tf-tf_pc, tf) == 0)
+			return;
+		tf-tf_pc += INSN_SIZE; /* Reset for the rest code */
+	}
+#endif
+
 	/* Enable interrupts if they were enabled before the exception. */
 #ifdef acorn26
 	if ((tf-tf_r15  R15_IRQ_DISABLE) == 0)



CVS commit: src/external/cddl/osnet/dev/dtrace/arm

2014-03-15 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Sat Mar 15 07:43:01 UTC 2014

Modified Files:
src/external/cddl/osnet/dev/dtrace/arm: dtrace_isa.c

Log Message:
Make arm/dtrace_isa.c buildable

This is a band-aid for build, but it works anyway.
We have to do a real fix in the future.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/external/cddl/osnet/dev/dtrace/arm/dtrace_isa.c

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

Modified files:

Index: src/external/cddl/osnet/dev/dtrace/arm/dtrace_isa.c
diff -u src/external/cddl/osnet/dev/dtrace/arm/dtrace_isa.c:1.3 src/external/cddl/osnet/dev/dtrace/arm/dtrace_isa.c:1.4
--- src/external/cddl/osnet/dev/dtrace/arm/dtrace_isa.c:1.3	Sat Mar  8 11:46:01 2014
+++ src/external/cddl/osnet/dev/dtrace/arm/dtrace_isa.c	Sat Mar 15 07:43:01 2014
@@ -39,6 +39,17 @@
 #include ddb/db_sym.h
 #include ddb/ddb.h
 
+uintptr_t kernelbase = (uintptr_t)KERNEL_BASE;
+
+/* TODO: support AAPCS */
+/* XXX: copied from sys/arch/arm/arm/db_trace.c */
+#define INKERNEL(va)	(((vaddr_t)(va)) = VM_MIN_KERNEL_ADDRESS)
+
+#define FR_SCP	(0)
+#define FR_RLV	(-1)
+#define FR_RSP	(-2)
+#define FR_RFP	(-3)
+
 #include regset.h
 
 /*



CVS commit: src/external/cddl/osnet/dev/dtrace/arm

2014-03-15 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Sat Mar 15 07:49:15 UTC 2014

Modified Files:
src/external/cddl/osnet/dev/dtrace/arm: dtrace_asm.S

Log Message:
Enable invop handler on module load

It sets a fbt handler to dtrace_invop_jump_addr on module load,
which is used to call the dtrace probing function from the trap
handler.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/cddl/osnet/dev/dtrace/arm/dtrace_asm.S

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

Modified files:

Index: src/external/cddl/osnet/dev/dtrace/arm/dtrace_asm.S
diff -u src/external/cddl/osnet/dev/dtrace/arm/dtrace_asm.S:1.4 src/external/cddl/osnet/dev/dtrace/arm/dtrace_asm.S:1.5
--- src/external/cddl/osnet/dev/dtrace/arm/dtrace_asm.S:1.4	Mon Mar 10 06:38:22 2014
+++ src/external/cddl/osnet/dev/dtrace/arm/dtrace_asm.S	Sat Mar 15 07:49:15 2014
@@ -202,13 +202,24 @@ END(dtrace_copystr)
 void dtrace_invop_init(void)
 */
 ENTRY(dtrace_invop_init)
+	ldr	r1, .Ldtrace_invop
+	ldr	r2, .Ldtrace_invop_jump_addr
+	str	r1, [r2]
 	RET
+	.align	0
+.Ldtrace_invop:
+	.word	dtrace_invop
+.Ldtrace_invop_jump_addr:
+	.word	dtrace_invop_jump_addr
 END(dtrace_invop_init)
 
 /*
 void dtrace_invop_uninit(void)
 */
 ENTRY(dtrace_invop_uninit)
+	mov	r0, #0
+	ldr	r1, .Ldtrace_invop_jump_addr
+	str	r0, [r1]
 	RET
 END(dtrace_invop_uninit)
 



CVS commit: src/external/cddl/osnet

2014-03-15 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Sat Mar 15 08:00:19 UTC 2014

Modified Files:
src/external/cddl/osnet/dev/fbt: fbt.c
src/external/cddl/osnet/dist/uts/common/sys: dtrace.h

Log Message:
Implement DTrace FBT provider for ARM

- Finding probable functions
- Replacing instructions
- Emulating instructions

It is tested only on ARMv7 CPUs yet, for example,
-m evbarm (-a earm) kernel=BEAGLEBONE.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/external/cddl/osnet/dev/fbt/fbt.c
cvs rdiff -u -r1.9 -r1.10 \
src/external/cddl/osnet/dist/uts/common/sys/dtrace.h

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

Modified files:

Index: src/external/cddl/osnet/dev/fbt/fbt.c
diff -u src/external/cddl/osnet/dev/fbt/fbt.c:1.13 src/external/cddl/osnet/dev/fbt/fbt.c:1.14
--- src/external/cddl/osnet/dev/fbt/fbt.c:1.13	Wed Mar  5 20:14:15 2014
+++ src/external/cddl/osnet/dev/fbt/fbt.c	Sat Mar 15 08:00:19 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: fbt.c,v 1.13 2014/03/05 20:14:15 tron Exp $	*/
+/*	$NetBSD: fbt.c,v 1.14 2014/03/15 08:00:19 ozaki-r Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -58,12 +58,19 @@
 #include sys/unistd.h
 
 #include machine/cpu.h
+#if defined(__i386__) || defined(__amd64__)
 #include machine/cpufunc.h
 #include machine/specialreg.h
 #if 0
 #include x86/cpuvar.h
 #endif
 #include x86/cputypes.h
+#elif __arm__
+#include machine/trap.h
+#include arm/cpufunc.h
+#include arm/armreg.h
+#include arm/frame.h
+#endif
 
 #define ELFSIZE ARCH_ELFSIZE
 #include sys/exec_elf.h
@@ -77,6 +84,7 @@ mod_ctf_t *modptr;
 
 MALLOC_DEFINE(M_FBT, fbt, Function Boundary Tracing);
 
+#if defined(__i386__) || defined(__amd64__)
 #define	FBT_PUSHL_EBP		0x55
 #define	FBT_MOVL_ESP_EBP0_V0	0x8b
 #define	FBT_MOVL_ESP_EBP1_V0	0xec
@@ -88,11 +96,43 @@ MALLOC_DEFINE(M_FBT, fbt, Function Bo
 #define	FBT_RET			0xc3
 #define	FBT_RET_IMM16		0xc2
 #define	FBT_LEAVE		0xc9
+#endif
 
 #ifdef __amd64__
 #define	FBT_PATCHVAL		0xcc
-#else
+#elif defined(__i386__)
 #define	FBT_PATCHVAL		0xf0
+
+#elif defined(__arm__)
+#define	FBT_PATCHVAL		DTRACE_BREAKPOINT
+
+/* entry and return */
+#define	FBT_BX_LR_P(insn)	(((insn)  ~INSN_COND_MASK) == 0x012fff1e)
+#define	FBT_B_LABEL_P(insn)	(((insn)  0xff00) == 0xea00)
+/* entry */
+#define	FBT_MOV_IP_SP_P(insn)	((insn) == 0xe1a0c00d)
+/* index=1, add=1, wback=0 */
+#define	FBT_LDR_IMM_P(insn)	(((insn)  0xfff0) == 0xe590)
+#define	FBT_MOVW_P(insn)	(((insn)  0xfff0) == 0xe300)
+#define	FBT_MOV_IMM_P(insn)	(((insn)  0x) == 0xe3a0)
+#define	FBT_CMP_IMM_P(insn)	(((insn)  0xfff0) == 0xe350)
+#define	FBT_PUSH_P(insn)	(((insn)  0x) == 0xe92d)
+/* return */
+/* cond=always, writeback=no, rn=sp and register_list includes pc */
+#define	FBT_LDM_P(insn)	(((insn)  0x0fff8000) == 0x089d8000)
+#define	FBT_LDMIB_P(insn)	(((insn)  0x0fff8000) == 0x099d8000)
+#define	FBT_MOV_PC_LR_P(insn)	(((insn)  ~INSN_COND_MASK) == 0x01a0f00e)
+/* cond=always, writeback=no, rn=sp and register_list includes lr, but not pc */
+#define	FBT_LDM_LR_P(insn)	(((insn)  0xc000) == 0xe89d4000)
+#define	FBT_LDMIB_LR_P(insn)	(((insn)  0xc000) == 0xe99d4000)
+
+/* rval = insn | invop_id (overwriting cond with invop ID) */
+#define	BUILD_RVAL(insn, id)	(((insn)  ~INSN_COND_MASK) | __SHIFTIN((id), INSN_COND_MASK))
+/* encode cond in the first byte */
+#define	PATCHVAL_ENCODE_COND(insn)	(FBT_PATCHVAL | __SHIFTOUT((insn), INSN_COND_MASK))
+
+#else
+#error architecture not supported
 #endif
 
 static dev_type_open(fbt_open);
@@ -140,10 +180,17 @@ static dtrace_pops_t fbt_pops = {
 
 typedef struct fbt_probe {
 	struct fbt_probe *fbtp_hashnext;
+#if defined(__i386__) || defined(__amd64__)
 	uint8_t		*fbtp_patchpoint;
 	int8_t		fbtp_rval;
 	uint8_t		fbtp_patchval;
 	uint8_t		fbtp_savedval;
+#elif __arm__
+	uint32_t	*fbtp_patchpoint;
+	int32_t		fbtp_rval;
+	uint32_t	fbtp_patchval;
+	uint32_t	fbtp_savedval;
+#endif
 	uintptr_t	fbtp_roffset;
 	dtrace_id_t	fbtp_id;
 	const char	*fbtp_name;
@@ -164,6 +211,226 @@ static fbt_probe_t		**fbt_probetab;
 static int			fbt_probetab_size;
 static int			fbt_probetab_mask;
 
+#ifdef __arm__
+extern void (* dtrace_emulation_jump_addr)(int, struct trapframe *);
+
+static uint32_t
+expand_imm(uint32_t imm12)
+{
+	uint32_t unrot = imm12  0xff;
+	int amount = 2 * (imm12  8);
+
+	if (amount)
+		return (unrot  amount) | (unrot  (32 - amount));
+	else
+		return unrot;
+}
+
+static uint32_t
+add_with_carry(uint32_t x, uint32_t y, int carry_in,
+	int *carry_out, int *overflow)
+{
+	uint32_t result;
+	uint64_t unsigned_sum = x + y + (uint32_t)carry_in;
+	int64_t signed_sum = (int32_t)x + (int32_t)y + (int32_t)carry_in;
+	KASSERT(carry_in == 1);
+
+	result = (uint32_t)(unsigned_sum  0x);
+	*carry_out = ((uint64_t)result == unsigned_sum) ? 1 : 0;
+	*overflow = ((int64_t)result == signed_sum) ? 0 : 1;
+	
+	return result;
+}
+
+static void

CVS commit: src/external/cddl/osnet/lib/libdtrace

2014-03-15 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Sun Mar 16 05:11:19 UTC 2014

Modified Files:
src/external/cddl/osnet/lib/libdtrace: Makefile

Log Message:
Look up arm directory on MACHINE_ARCH=*arm*


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/external/cddl/osnet/lib/libdtrace/Makefile

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

Modified files:

Index: src/external/cddl/osnet/lib/libdtrace/Makefile
diff -u src/external/cddl/osnet/lib/libdtrace/Makefile:1.7 src/external/cddl/osnet/lib/libdtrace/Makefile:1.8
--- src/external/cddl/osnet/lib/libdtrace/Makefile:1.7	Fri Jun 21 19:16:01 2013
+++ src/external/cddl/osnet/lib/libdtrace/Makefile	Sun Mar 16 05:11:19 2014
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.7 2013/06/21 19:16:01 christos Exp $
+#	$NetBSD: Makefile,v 1.8 2014/03/16 05:11:19 ozaki-r Exp $
 
 # $FreeBSD: src/cddl/lib/libdtrace/Makefile,v 1.2.2.1 2009/08/03 08:13:06 kensmith Exp $
 
@@ -86,7 +86,7 @@ COPTS.dt_subr.c		+= -Wno-stack-protector
 CPPFLAGS+=	-I${OPENSOLARIS_SYS_DISTDIR}/uts/intel
 .elif ${MACHINE_ARCH} == sparc64
 CPPFLAGS+=	-I${OPENSOLARIS_SYS_DISTDIR}/uts/sparc
-.elif ${MACHINE_ARCH} == arm
+.elif !empty(MACHINE_ARCH:M*arm*)
 CPPFLAGS+=	-I${OPENSOLARIS_SYS_DISTDIR}/uts/arm
 .PATH:		${.CURDIR}/../../dist/lib/libdtrace/arm
 SRCS+=	dt_isadep.c



CVS commit: src/external/cddl/osnet/lib/libdtrace

2014-03-16 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Sun Mar 16 06:51:43 UTC 2014

Modified Files:
src/external/cddl/osnet/lib/libdtrace: Makefile

Log Message:
Use MACHINE_CPU instead of MACHINE_ARCH with pattern matching

Include bsd.own.mk to use MACHINE_CPU.

Advised by matt@


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/external/cddl/osnet/lib/libdtrace/Makefile

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

Modified files:

Index: src/external/cddl/osnet/lib/libdtrace/Makefile
diff -u src/external/cddl/osnet/lib/libdtrace/Makefile:1.8 src/external/cddl/osnet/lib/libdtrace/Makefile:1.9
--- src/external/cddl/osnet/lib/libdtrace/Makefile:1.8	Sun Mar 16 05:11:19 2014
+++ src/external/cddl/osnet/lib/libdtrace/Makefile	Sun Mar 16 06:51:43 2014
@@ -1,7 +1,9 @@
-#	$NetBSD: Makefile,v 1.8 2014/03/16 05:11:19 ozaki-r Exp $
+#	$NetBSD: Makefile,v 1.9 2014/03/16 06:51:43 ozaki-r Exp $
 
 # $FreeBSD: src/cddl/lib/libdtrace/Makefile,v 1.2.2.1 2009/08/03 08:13:06 kensmith Exp $
 
+.include bsd.own.mk
+
 .include	../../Makefile.inc
 
 LIB=		dtrace
@@ -86,7 +88,7 @@ COPTS.dt_subr.c		+= -Wno-stack-protector
 CPPFLAGS+=	-I${OPENSOLARIS_SYS_DISTDIR}/uts/intel
 .elif ${MACHINE_ARCH} == sparc64
 CPPFLAGS+=	-I${OPENSOLARIS_SYS_DISTDIR}/uts/sparc
-.elif !empty(MACHINE_ARCH:M*arm*)
+.elif ${MACHINE_CPU} == arm
 CPPFLAGS+=	-I${OPENSOLARIS_SYS_DISTDIR}/uts/arm
 .PATH:		${.CURDIR}/../../dist/lib/libdtrace/arm
 SRCS+=	dt_isadep.c



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

2014-03-19 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Mar 19 11:14:12 UTC 2014

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

Log Message:
Exclude mvsoctmr_* functions from FBT targets

Probing them doesn't work for DTrace/arm for some reason.

Anyway with this fix, DTrace/arm works on SHEEVAPLUG
as well as BEAGLEBONE.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/external/cddl/osnet/dev/fbt/fbt.c

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

Modified files:

Index: src/external/cddl/osnet/dev/fbt/fbt.c
diff -u src/external/cddl/osnet/dev/fbt/fbt.c:1.14 src/external/cddl/osnet/dev/fbt/fbt.c:1.15
--- src/external/cddl/osnet/dev/fbt/fbt.c:1.14	Sat Mar 15 08:00:19 2014
+++ src/external/cddl/osnet/dev/fbt/fbt.c	Wed Mar 19 11:14:12 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: fbt.c,v 1.14 2014/03/15 08:00:19 ozaki-r Exp $	*/
+/*	$NetBSD: fbt.c,v 1.15 2014/03/19 11:14:12 ozaki-r Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -756,12 +756,13 @@ fbt_provide_module_cb(const char *name, 
 	|| strncmp(name, kauth_, 5) == 0 /* CRED XXX for now */
 	/* Sensitive functions on ARM */
 	|| strncmp(name, _spl, 4) == 0
-	|| strncmp(name, dmt_, 4) == 0
 	|| strcmp(name, binuptime) == 0
 	|| strcmp(name, dosoftints) == 0
 	|| strcmp(name, fbt_emulate) == 0
 	|| strcmp(name, nanouptime) == 0
 	|| strcmp(name, undefinedinstruction) == 0
+	|| strncmp(name, dmt_, 4) == 0 /* omap */
+	|| strncmp(name, mvsoctmr_, 9) == 0 /* marvell */
 	) {
 		return 0;
 	}



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

2014-03-19 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Thu Mar 20 05:39:11 UTC 2014

Modified Files:
src/sys/arch/arm/broadcom: bcm2835_bsc.c

Log Message:
Mark a variable __diagused

PR 48668 from David H. Gutteridge


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/broadcom/bcm2835_bsc.c

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

Modified files:

Index: src/sys/arch/arm/broadcom/bcm2835_bsc.c
diff -u src/sys/arch/arm/broadcom/bcm2835_bsc.c:1.1 src/sys/arch/arm/broadcom/bcm2835_bsc.c:1.2
--- src/sys/arch/arm/broadcom/bcm2835_bsc.c:1.1	Sat Jan  5 20:15:17 2013
+++ src/sys/arch/arm/broadcom/bcm2835_bsc.c	Thu Mar 20 05:39:11 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: bcm2835_bsc.c,v 1.1 2013/01/05 20:15:17 jakllsch Exp $	*/
+/*	$NetBSD: bcm2835_bsc.c,v 1.2 2014/03/20 05:39:11 ozaki-r Exp $	*/
 
 /*
  * Copyright (c) 2012 Jonathan A. Kollasch
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: bcm2835_bsc.c,v 1.1 2013/01/05 20:15:17 jakllsch Exp $);
+__KERNEL_RCSID(0, $NetBSD: bcm2835_bsc.c,v 1.2 2014/03/20 05:39:11 ozaki-r Exp $);
 
 #include sys/param.h
 #include sys/device.h
@@ -169,7 +169,7 @@ static int
 bsciic_acquire_bus(void *v, int flags)
 {
 	struct bsciic_softc * const sc = v;
-	uint32_t s;
+	uint32_t s __diagused;
 
 	mutex_enter(sc-sc_buslock);
 



CVS commit: src/external/gpl3/gcc/dist/libgcc/config

2014-03-24 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Tue Mar 25 00:50:46 UTC 2014

Modified Files:
src/external/gpl3/gcc/dist/libgcc/config/arm: pr-support.c
src/external/gpl3/gcc/dist/libgcc/config/c6x: pr-support.c

Log Message:
Cast ptr to the correct return type (_Unwind_Ptr)


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/external/gpl3/gcc/dist/libgcc/config/arm/pr-support.c
cvs rdiff -u -r1.2 -r1.3 \
src/external/gpl3/gcc/dist/libgcc/config/c6x/pr-support.c

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

Modified files:

Index: src/external/gpl3/gcc/dist/libgcc/config/arm/pr-support.c
diff -u src/external/gpl3/gcc/dist/libgcc/config/arm/pr-support.c:1.2 src/external/gpl3/gcc/dist/libgcc/config/arm/pr-support.c:1.3
--- src/external/gpl3/gcc/dist/libgcc/config/arm/pr-support.c:1.2	Mon Mar 24 21:26:01 2014
+++ src/external/gpl3/gcc/dist/libgcc/config/arm/pr-support.c	Tue Mar 25 00:50:45 2014
@@ -366,7 +366,7 @@ _Unwind_GetLanguageSpecificData (_Unwind
   /* Skip the unwind opcodes.  */
   ptr += (((*ptr)  24)  0xff) + 1;
 
-  return ptr;
+  return (_Unwind_Ptr) ptr;
 }
 
 

Index: src/external/gpl3/gcc/dist/libgcc/config/c6x/pr-support.c
diff -u src/external/gpl3/gcc/dist/libgcc/config/c6x/pr-support.c:1.2 src/external/gpl3/gcc/dist/libgcc/config/c6x/pr-support.c:1.3
--- src/external/gpl3/gcc/dist/libgcc/config/c6x/pr-support.c:1.2	Mon Mar 24 21:26:01 2014
+++ src/external/gpl3/gcc/dist/libgcc/config/c6x/pr-support.c	Tue Mar 25 00:50:45 2014
@@ -531,5 +531,5 @@ _Unwind_GetLanguageSpecificData (_Unwind
   /* Skip the unwind opcodes.  */
   ptr += (((*ptr)  24)  0xff) + 1;
 
-  return ptr;
+  return (_Unwind_Ptr) ptr;
 }



CVS commit: src

2014-03-25 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Tue Mar 25 09:52:56 UTC 2014

Modified Files:
src/distrib/sets/lists/comp: mi
src/distrib/sets/lists/man: mi
src/etc: Makefile.params
src/external/cddl: Makefile
src/external/cddl/osnet/lib: Makefile
src/external/cddl/osnet/usr.bin: Makefile
src/share/man/man5: mk.conf.5
src/share/mk: bsd.README bsd.own.mk bsd.prog.mk
src/tools: Makefile

Log Message:
Add MKCTF

This variable separates CTF stuffs from MKDTRACE; we can build DTrace
solely without building and using them. This allows us to use DTrace
even if CTF stuffs have problems (actually they have now).

This variable would be merged into MKDTRACE eventually, once CTF stuffs
work correctly again.


To generate a diff of this commit:
cvs rdiff -u -r1.1886 -r1.1887 src/distrib/sets/lists/comp/mi
cvs rdiff -u -r1.1465 -r1.1466 src/distrib/sets/lists/man/mi
cvs rdiff -u -r1.10 -r1.11 src/etc/Makefile.params
cvs rdiff -u -r1.2 -r1.3 src/external/cddl/Makefile
cvs rdiff -u -r1.5 -r1.6 src/external/cddl/osnet/lib/Makefile
cvs rdiff -u -r1.2 -r1.3 src/external/cddl/osnet/usr.bin/Makefile
cvs rdiff -u -r1.67 -r1.68 src/share/man/man5/mk.conf.5
cvs rdiff -u -r1.328 -r1.329 src/share/mk/bsd.README
cvs rdiff -u -r1.791 -r1.792 src/share/mk/bsd.own.mk
cvs rdiff -u -r1.289 -r1.290 src/share/mk/bsd.prog.mk
cvs rdiff -u -r1.171 -r1.172 src/tools/Makefile

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

Modified files:

Index: src/distrib/sets/lists/comp/mi
diff -u src/distrib/sets/lists/comp/mi:1.1886 src/distrib/sets/lists/comp/mi:1.1887
--- src/distrib/sets/lists/comp/mi:1.1886	Mon Mar 24 13:42:40 2014
+++ src/distrib/sets/lists/comp/mi	Tue Mar 25 09:52:55 2014
@@ -1,4 +1,4 @@
-#	$NetBSD: mi,v 1.1886 2014/03/24 13:42:40 hannken Exp $
+#	$NetBSD: mi,v 1.1887 2014/03/25 09:52:55 ozaki-r Exp $
 #
 # Note: don't delete entries from here - mark them as obsolete instead.
 #
@@ -20,9 +20,9 @@
 ./usr/bin/configcomp-util-bin
 ./usr/bin/crunchgencomp-c-bin
 ./usr/bin/crunchidecomp-c-bin
-./usr/bin/ctfconvertcomp-util-bin		dtrace
-./usr/bin/ctfdumpcomp-util-bin		dtrace
-./usr/bin/ctfmergecomp-util-bin		dtrace
+./usr/bin/ctfconvertcomp-util-bin		ctf
+./usr/bin/ctfdumpcomp-util-bin		ctf
+./usr/bin/ctfmergecomp-util-bin		ctf
 ./usr/bin/cvs	comp-cvs-bin		cvs
 ./usr/bin/cvsbugcomp-cvs-bin		cvs
 ./usr/bin/elfeditcomp-util-bin		binutils

Index: src/distrib/sets/lists/man/mi
diff -u src/distrib/sets/lists/man/mi:1.1465 src/distrib/sets/lists/man/mi:1.1466
--- src/distrib/sets/lists/man/mi:1.1465	Wed Mar 19 15:26:41 2014
+++ src/distrib/sets/lists/man/mi	Tue Mar 25 09:52:55 2014
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1465 2014/03/19 15:26:41 nonaka Exp $
+# $NetBSD: mi,v 1.1466 2014/03/25 09:52:55 ozaki-r Exp $
 #
 # Note: don't delete entries from here - mark them as obsolete instead.
 #
@@ -125,9 +125,9 @@
 ./usr/share/man/cat1/csh.0			man-util-catman		.cat
 ./usr/share/man/cat1/csplit.0			man-util-catman		.cat
 ./usr/share/man/cat1/ctags.0			man-c-catman		.cat
-./usr/share/man/cat1/ctfconvert.0		man-util-catman		.cat,dtrace
-./usr/share/man/cat1/ctfdump.0			man-util-catman		.cat,dtrace
-./usr/share/man/cat1/ctfmerge.0			man-util-catman		.cat,dtrace
+./usr/share/man/cat1/ctfconvert.0		man-util-catman		.cat,ctf
+./usr/share/man/cat1/ctfdump.0			man-util-catman		.cat,ctf
+./usr/share/man/cat1/ctfmerge.0			man-util-catman		.cat,ctf
 ./usr/share/man/cat1/cu.0			man-util-catman		.cat
 ./usr/share/man/cat1/cut.0			man-util-catman		.cat
 ./usr/share/man/cat1/daicctl.0			man-sysutil-catman	.cat
@@ -3240,9 +3240,9 @@
 ./usr/share/man/html1/csh.html			man-util-htmlman	html
 ./usr/share/man/html1/csplit.html		man-util-htmlman	html
 ./usr/share/man/html1/ctags.html		man-c-htmlman		html
-./usr/share/man/html1/ctfconvert.html		man-util-htmlman	html,dtrace
-./usr/share/man/html1/ctfdump.html		man-util-htmlman	html,dtrace
-./usr/share/man/html1/ctfmerge.html		man-util-htmlman	html,dtrace
+./usr/share/man/html1/ctfconvert.html		man-util-htmlman	html,ctf
+./usr/share/man/html1/ctfdump.html		man-util-htmlman	html,ctf
+./usr/share/man/html1/ctfmerge.html		man-util-htmlman	html,ctf
 ./usr/share/man/html1/cu.html			man-util-htmlman	html
 ./usr/share/man/html1/cut.html			man-util-htmlman	html
 ./usr/share/man/html1/daicctl.html		man-sysutil-htmlman	html
@@ -5963,9 +5963,9 @@
 ./usr/share/man/man1/csh.1			man-util-man		.man
 ./usr/share/man/man1/csplit.1			man-util-man		.man
 ./usr/share/man/man1/ctags.1			man-c-man		.man
-./usr/share/man/man1/ctfconvert.1		man-util-man		.man,dtrace
-./usr/share/man/man1/ctfdump.1			man-util-man		.man,dtrace
-./usr/share/man/man1/ctfmerge.1			man-util-man		.man,dtrace
+./usr/share/man/man1/ctfconvert.1		man-util-man		.man,ctf
+./usr/share/man/man1/ctfdump.1			man-util-man		.man,ctf
+./usr/share/man/man1/ctfmerge.1			man-util-man		.man,ctf

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

2014-03-26 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Mar 26 11:59:05 UTC 2014

Modified Files:
src/sys/arch/arm/omap: ti_iic.c

Log Message:
Add missing 2nd argument to snprintf


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/omap/ti_iic.c

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

Modified files:

Index: src/sys/arch/arm/omap/ti_iic.c
diff -u src/sys/arch/arm/omap/ti_iic.c:1.6 src/sys/arch/arm/omap/ti_iic.c:1.7
--- src/sys/arch/arm/omap/ti_iic.c:1.6	Wed Mar 26 08:52:00 2014
+++ src/sys/arch/arm/omap/ti_iic.c	Wed Mar 26 11:59:05 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: ti_iic.c,v 1.6 2014/03/26 08:52:00 christos Exp $ */
+/* $NetBSD: ti_iic.c,v 1.7 2014/03/26 11:59:05 ozaki-r Exp $ */
 
 /*
  * Copyright (c) 2013 Manuel Bouyer.  All rights reserved.
@@ -50,7 +50,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ti_iic.c,v 1.6 2014/03/26 08:52:00 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: ti_iic.c,v 1.7 2014/03/26 11:59:05 ozaki-r Exp $);
 
 #include opt_omap.h
 #include locators.h
@@ -238,7 +238,7 @@ ti_iic_attach(device_t parent, device_t 
 		}
 	}
 	KASSERT(i  __arraycount(am335x_iic));
-	snprintf(buf, %s_SDA, am335x_iic[i].as_name);
+	snprintf(buf, sizeof(buf), %s_SDA, am335x_iic[i].as_name);
 	if (sitara_cm_padconf_get(buf, mode, state) == 0) {
 		aprint_debug(: SDA mode %s state %d , mode, state);
 	}



CVS commit: src/external/cddl/osnet

2014-03-27 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Fri Mar 28 02:50:18 UTC 2014

Modified Files:
src/external/cddl/osnet/dist/cmd/zdb: zdb.c
src/external/cddl/osnet/dist/cmd/ztest: ztest.c
src/external/cddl/osnet/dist/lib/libzpool/common: util.c
src/external/cddl/osnet/sys/sys: zfs_context.h

Log Message:
Add missing 3rd argument of nicenum


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/external/cddl/osnet/dist/cmd/zdb/zdb.c
cvs rdiff -u -r1.5 -r1.6 src/external/cddl/osnet/dist/cmd/ztest/ztest.c
cvs rdiff -u -r1.2 -r1.3 \
src/external/cddl/osnet/dist/lib/libzpool/common/util.c
cvs rdiff -u -r1.15 -r1.16 src/external/cddl/osnet/sys/sys/zfs_context.h

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

Modified files:

Index: src/external/cddl/osnet/dist/cmd/zdb/zdb.c
diff -u src/external/cddl/osnet/dist/cmd/zdb/zdb.c:1.2 src/external/cddl/osnet/dist/cmd/zdb/zdb.c:1.3
--- src/external/cddl/osnet/dist/cmd/zdb/zdb.c:1.2	Thu Mar 27 15:50:48 2014
+++ src/external/cddl/osnet/dist/cmd/zdb/zdb.c	Fri Mar 28 02:50:18 2014
@@ -462,7 +462,7 @@ dump_metaslab_stats(metaslab_t *msp)
 	avl_tree_t *t = sm-sm_pp_root;
 	int free_pct = sm-sm_space * 100 / sm-sm_size;
 
-	nicenum(space_map_maxsize(sm), maxbuf);
+	nicenum(space_map_maxsize(sm), maxbuf, sizeof(maxbuf));
 
 	(void) printf(\t %25s %10lu   %7s  %6s   %4s %4d%%\n,
 	segments, avl_numnodes(t), maxsize, maxbuf,
@@ -478,7 +478,7 @@ dump_metaslab(metaslab_t *msp)
 	space_map_obj_t *smo = msp-ms_smo;
 	char freebuf[5];
 
-	nicenum(sm-sm_size - smo-smo_alloc, freebuf);
+	nicenum(sm-sm_size - smo-smo_alloc, freebuf, sizeof(freebuf));
 
 	(void) printf(
 	\tmetaslab %6llu   offset %12llx   spacemap %6llu   free%5s\n,
@@ -969,15 +969,15 @@ dump_dsl_dir(objset_t *os, uint64_t obje
 	(u_longlong_t)dd-dd_origin_obj);
 	(void) printf(\t\tchild_dir_zapobj = %llu\n,
 	(u_longlong_t)dd-dd_child_dir_zapobj);
-	nicenum(dd-dd_used_bytes, nice);
+	nicenum(dd-dd_used_bytes, nice, sizeof(nice));
 	(void) printf(\t\tused_bytes = %s\n, nice);
-	nicenum(dd-dd_compressed_bytes, nice);
+	nicenum(dd-dd_compressed_bytes, nice, sizeof(nice));
 	(void) printf(\t\tcompressed_bytes = %s\n, nice);
-	nicenum(dd-dd_uncompressed_bytes, nice);
+	nicenum(dd-dd_uncompressed_bytes, nice, sizeof(nice));
 	(void) printf(\t\tuncompressed_bytes = %s\n, nice);
-	nicenum(dd-dd_quota, nice);
+	nicenum(dd-dd_quota, nice, sizeof(nice));
 	(void) printf(\t\tquota = %s\n, nice);
-	nicenum(dd-dd_reserved, nice);
+	nicenum(dd-dd_reserved, nice, sizeof(nice));
 	(void) printf(\t\treserved = %s\n, nice);
 	(void) printf(\t\tprops_zapobj = %llu\n,
 	(u_longlong_t)dd-dd_props_zapobj);
@@ -987,7 +987,7 @@ dump_dsl_dir(objset_t *os, uint64_t obje
 	(u_longlong_t)dd-dd_flags);
 
 #define	DO(which) \
-	nicenum(dd-dd_used_breakdown[DD_USED_ ## which], nice); \
+	nicenum(dd-dd_used_breakdown[DD_USED_ ## which], nice, sizeof(nice)); \
 	(void) printf(\t\tused_breakdown[ #which ] = %s\n, nice)
 	DO(HEAD);
 	DO(SNAP);
@@ -1011,10 +1011,10 @@ dump_dsl_dataset(objset_t *os, uint64_t 
 
 	ASSERT(size == sizeof (*ds));
 	crtime = ds-ds_creation_time;
-	nicenum(ds-ds_used_bytes, used);
-	nicenum(ds-ds_compressed_bytes, compressed);
-	nicenum(ds-ds_uncompressed_bytes, uncompressed);
-	nicenum(ds-ds_unique_bytes, unique);
+	nicenum(ds-ds_used_bytes, used, sizeof(used));
+	nicenum(ds-ds_compressed_bytes, compressed, sizeof(compressed));
+	nicenum(ds-ds_uncompressed_bytes, uncompressed, sizeof(uncompressed));
+	nicenum(ds-ds_unique_bytes, unique, sizeof(unique));
 	snprintf_blkptr(blkbuf, sizeof(blkbuf), ds-ds_bp);
 
 	(void) printf(\t\tdir_obj = %llu\n,
@@ -1074,10 +1074,10 @@ dump_bplist(objset_t *mos, uint64_t obje
 		return;
 	}
 
-	nicenum(bpl.bpl_phys-bpl_bytes, bytes);
+	nicenum(bpl.bpl_phys-bpl_bytes, bytes, sizeof(bytes));
 	if (bpl.bpl_dbuf-db_size == sizeof (bplist_phys_t)) {
-		nicenum(bpl.bpl_phys-bpl_comp, comp);
-		nicenum(bpl.bpl_phys-bpl_uncomp, uncomp);
+		nicenum(bpl.bpl_phys-bpl_comp, comp, sizeof(comp));
+		nicenum(bpl.bpl_phys-bpl_uncomp, uncomp, sizeof(uncomp));
 		(void) printf(\n%s: %llu entries, %s (%s/%s comp)\n,
 		name, (u_longlong_t)bpl.bpl_phys-bpl_entries,
 		bytes, comp, uncomp);
@@ -1300,11 +1300,11 @@ dump_object(objset_t *os, uint64_t objec
 	}
 	dmu_object_info_from_dnode(dn, doi);
 
-	nicenum(doi.doi_metadata_block_size, iblk);
-	nicenum(doi.doi_data_block_size, dblk);
-	nicenum(doi.doi_max_offset, lsize);
-	nicenum(doi.doi_physical_blocks_512  9, asize);
-	nicenum(doi.doi_bonus_size, bonus_size);
+	nicenum(doi.doi_metadata_block_size, iblk, sizeof(iblk));
+	nicenum(doi.doi_data_block_size, dblk, sizeof(dblk));
+	nicenum(doi.doi_max_offset, lsize, sizeof(lsize));
+	nicenum(doi.doi_physical_blocks_512  9, asize, sizeof(asize));
+	nicenum(doi.doi_bonus_size, bonus_size, sizeof(bonus_size));
 	(void) snprintf(fill, %6.2f, 100.0 * 

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

2014-03-27 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Fri Mar 28 02:58:36 UTC 2014

Modified Files:
src/external/cddl/osnet/dist/cmd/dtrace: dtrace.c
src/external/cddl/osnet/dist/cmd/zdb: zdb.c
src/external/cddl/osnet/dist/cmd/ztest: ztest.c
src/external/cddl/osnet/dist/lib/libdtrace/common: dt_link.c

Log Message:
Fix some snprintf


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/external/cddl/osnet/dist/cmd/dtrace/dtrace.c
cvs rdiff -u -r1.3 -r1.4 src/external/cddl/osnet/dist/cmd/zdb/zdb.c
cvs rdiff -u -r1.6 -r1.7 src/external/cddl/osnet/dist/cmd/ztest/ztest.c
cvs rdiff -u -r1.5 -r1.6 \
src/external/cddl/osnet/dist/lib/libdtrace/common/dt_link.c

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

Modified files:

Index: src/external/cddl/osnet/dist/cmd/dtrace/dtrace.c
diff -u src/external/cddl/osnet/dist/cmd/dtrace/dtrace.c:1.3 src/external/cddl/osnet/dist/cmd/dtrace/dtrace.c:1.4
--- src/external/cddl/osnet/dist/cmd/dtrace/dtrace.c:1.3	Thu Mar 27 15:50:48 2014
+++ src/external/cddl/osnet/dist/cmd/dtrace/dtrace.c	Fri Mar 28 02:58:36 2014
@@ -953,7 +953,7 @@ bufhandler(const dtrace_bufdata_t *bufda
 			uint8_t *data;
 			int lim = rec-dtrd_size;
 
-			(void) snprintf(buf, end, %d (data: , rec-dtrd_offset);
+			(void) snprintf(buf, end - buf, %d (data: , rec-dtrd_offset);
 			c = buf + strlen(buf);
 
 			if (lim  sizeof (uint64_t))

Index: src/external/cddl/osnet/dist/cmd/zdb/zdb.c
diff -u src/external/cddl/osnet/dist/cmd/zdb/zdb.c:1.3 src/external/cddl/osnet/dist/cmd/zdb/zdb.c:1.4
--- src/external/cddl/osnet/dist/cmd/zdb/zdb.c:1.3	Fri Mar 28 02:50:18 2014
+++ src/external/cddl/osnet/dist/cmd/zdb/zdb.c	Fri Mar 28 02:58:36 2014
@@ -1305,7 +1305,7 @@ dump_object(objset_t *os, uint64_t objec
 	nicenum(doi.doi_max_offset, lsize, sizeof(lsize));
 	nicenum(doi.doi_physical_blocks_512  9, asize, sizeof(asize));
 	nicenum(doi.doi_bonus_size, bonus_size, sizeof(bonus_size));
-	(void) snprintf(fill, %6.2f, 100.0 * doi.doi_fill_count *
+	(void) snprintf(fill, sizeof(fill), %6.2f, 100.0 * doi.doi_fill_count *
 	doi.doi_data_block_size / (object == 0 ? DNODES_PER_BLOCK : 1) /
 	doi.doi_max_offset);
 
@@ -1423,6 +1423,7 @@ dump_dir(objset_t *os)
 	nicenum(refdbytes, numbuf, sizeof(numbuf));
 
 	if (verbosity = 4) {
+		size_t blklen = sizeof(blkbuf);
 		len = snprintf(blkbuf, blklen, , rootbp );
 		if (len  blklen)
 			len = blklen;

Index: src/external/cddl/osnet/dist/cmd/ztest/ztest.c
diff -u src/external/cddl/osnet/dist/cmd/ztest/ztest.c:1.6 src/external/cddl/osnet/dist/cmd/ztest/ztest.c:1.7
--- src/external/cddl/osnet/dist/cmd/ztest/ztest.c:1.6	Fri Mar 28 02:50:18 2014
+++ src/external/cddl/osnet/dist/cmd/ztest/ztest.c	Fri Mar 28 02:58:36 2014
@@ -2239,7 +2239,7 @@ ztest_vdev_aux_add_remove(ztest_ds_t *zd
 		for (;;) {
 			char path[MAXPATHLEN];
 			int c;
-			(void) snprintf(path, sizeof(pathbuf), ztest_aux_template, zopt_dir,
+			(void) snprintf(path, sizeof(path), ztest_aux_template, zopt_dir,
 			zopt_pool, aux, zs-zs_vdev_aux);
 			for (c = 0; c  sav-sav_count; c++)
 if (strcmp(sav-sav_vdevs[c]-vdev_path,

Index: src/external/cddl/osnet/dist/lib/libdtrace/common/dt_link.c
diff -u src/external/cddl/osnet/dist/lib/libdtrace/common/dt_link.c:1.5 src/external/cddl/osnet/dist/lib/libdtrace/common/dt_link.c:1.6
--- src/external/cddl/osnet/dist/lib/libdtrace/common/dt_link.c:1.5	Thu Mar 27 15:50:48 2014
+++ src/external/cddl/osnet/dist/lib/libdtrace/common/dt_link.c	Fri Mar 28 02:58:36 2014
@@ -1497,7 +1497,7 @@ process_obj(dtrace_hdl_t *dtp, const cha
 
 r = (char *)data_str-d_buf + istr;
 istr += 1 + snprintf(r, data_str-d_size - 
-	(istr - (char *)data_str-d_buf), dt_symfmt,
+(istr - (size_t)data_str-d_buf), dt_symfmt,
 dt_symprefix, objkey, s);
 isym++;
 assert(isym = nsym);



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

2014-03-27 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Fri Mar 28 03:11:00 UTC 2014

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

Log Message:
Add missing 4th argument of ddt_object_name


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/cddl/osnet/dist/cmd/zdb/zdb.c

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

Modified files:

Index: src/external/cddl/osnet/dist/cmd/zdb/zdb.c
diff -u src/external/cddl/osnet/dist/cmd/zdb/zdb.c:1.4 src/external/cddl/osnet/dist/cmd/zdb/zdb.c:1.5
--- src/external/cddl/osnet/dist/cmd/zdb/zdb.c:1.4	Fri Mar 28 02:58:36 2014
+++ src/external/cddl/osnet/dist/cmd/zdb/zdb.c	Fri Mar 28 03:11:00 2014
@@ -623,7 +623,7 @@ dump_ddt(ddt_t *ddt, enum ddt_type type,
 
 	ASSERT(count != 0);	/* we should have destroyed it */
 
-	ddt_object_name(ddt, type, class, name);
+	ddt_object_name(ddt, type, class, name, sizeof(name));
 
 	(void) printf(%s: %llu entries, size %llu on disk, %llu in core\n,
 	name,



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

2014-03-27 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Fri Mar 28 03:18:24 UTC 2014

Modified Files:
src/external/cddl/osnet/dist/cmd/zdb: zdb.c
src/external/cddl/osnet/dist/uts/common/fs/zfs/sys: spa.h

Log Message:
Fix migrating to snprintf_blkptr


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/external/cddl/osnet/dist/cmd/zdb/zdb.c
cvs rdiff -u -r1.1.1.2 -r1.2 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/sys/spa.h

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

Modified files:

Index: src/external/cddl/osnet/dist/cmd/zdb/zdb.c
diff -u src/external/cddl/osnet/dist/cmd/zdb/zdb.c:1.5 src/external/cddl/osnet/dist/cmd/zdb/zdb.c:1.6
--- src/external/cddl/osnet/dist/cmd/zdb/zdb.c:1.5	Fri Mar 28 03:11:00 2014
+++ src/external/cddl/osnet/dist/cmd/zdb/zdb.c	Fri Mar 28 03:18:24 2014
@@ -1427,7 +1427,7 @@ dump_dir(objset_t *os)
 		len = snprintf(blkbuf, blklen, , rootbp );
 		if (len  blklen)
 			len = blklen;
-		printf_blkptr(blkbuf + len, blklen - len, os-os_rootbp);
+		snprintf_blkptr(blkbuf + len, blklen - len, os-os_rootbp);
 	} else {
 		blkbuf[0] = '\0';
 	}

Index: src/external/cddl/osnet/dist/uts/common/fs/zfs/sys/spa.h
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/sys/spa.h:1.1.1.2 src/external/cddl/osnet/dist/uts/common/fs/zfs/sys/spa.h:1.2
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/sys/spa.h:1.1.1.2	Sat Feb 27 22:31:42 2010
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/sys/spa.h	Fri Mar 28 03:18:24 2014
@@ -592,7 +592,7 @@ extern char *spa_strdup(const char *);
 extern void spa_strfree(char *);
 extern uint64_t spa_get_random(uint64_t range);
 extern uint64_t spa_generate_guid(spa_t *spa);
-extern void sprintf_blkptr(char *buf, const blkptr_t *bp);
+extern void snprintf_blkptr(char *buf, const blkptr_t *bp);
 extern void spa_freeze(spa_t *spa);
 extern void spa_upgrade(spa_t *spa, uint64_t version);
 extern void spa_evict_all(void);
@@ -672,7 +672,7 @@ extern void spa_event_notify(spa_t *spa,
 #define	dprintf_bp(bp, fmt, ...) do {\
 	if (zfs_flags  ZFS_DEBUG_DPRINTF) { 			\
 	char *__blkbuf = kmem_alloc(BP_SPRINTF_LEN, KM_SLEEP);	\
-	sprintf_blkptr(__blkbuf, (bp));\
+	snprintf_blkptr(__blkbuf, BP_SPRINTF_LEN, (bp));\
 	dprintf(fmt  %s\n, __VA_ARGS__, __blkbuf);		\
 	kmem_free(__blkbuf, BP_SPRINTF_LEN);			\
 	} \



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

2014-03-27 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Fri Mar 28 03:46:56 UTC 2014

Modified Files:
src/external/cddl/osnet/dist/cmd/zdb: zdb_il.c
src/external/cddl/osnet/dist/uts/common/fs/zfs: spa_misc.c
src/external/cddl/osnet/dist/uts/common/fs/zfs/sys: dbuf.h spa.h

Log Message:
Complete migrating to snprintf_blkptr


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.2 -r1.2 src/external/cddl/osnet/dist/cmd/zdb/zdb_il.c
cvs rdiff -u -r1.1.1.2 -r1.2 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/spa_misc.c
cvs rdiff -u -r1.1.1.2 -r1.2 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/sys/dbuf.h
cvs rdiff -u -r1.2 -r1.3 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/sys/spa.h

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

Modified files:

Index: src/external/cddl/osnet/dist/cmd/zdb/zdb_il.c
diff -u src/external/cddl/osnet/dist/cmd/zdb/zdb_il.c:1.1.1.2 src/external/cddl/osnet/dist/cmd/zdb/zdb_il.c:1.2
--- src/external/cddl/osnet/dist/cmd/zdb/zdb_il.c:1.1.1.2	Sat Feb 27 22:29:29 2010
+++ src/external/cddl/osnet/dist/cmd/zdb/zdb_il.c	Fri Mar 28 03:46:56 2014
@@ -47,7 +47,7 @@ print_log_bp(const blkptr_t *bp, const c
 {
 	char blkbuf[BP_SPRINTF_LEN];
 
-	sprintf_blkptr(blkbuf, bp);
+	snprintf_blkptr(blkbuf, sizeof(blkbuf), bp);
 	(void) printf(%s%s\n, prefix, blkbuf);
 }
 
@@ -313,7 +313,8 @@ print_log_block(zilog_t *zilog, blkptr_t
 
 	if (verbose = 5) {
 		(void) strcpy(blkbuf, , );
-		sprintf_blkptr(blkbuf + strlen(blkbuf), bp);
+		snprintf_blkptr(blkbuf + strlen(blkbuf),
+		sizeof(blkbuf) - strlen(blkbuf), bp);
 	} else {
 		blkbuf[0] = '\0';
 	}

Index: src/external/cddl/osnet/dist/uts/common/fs/zfs/spa_misc.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/spa_misc.c:1.1.1.2 src/external/cddl/osnet/dist/uts/common/fs/zfs/spa_misc.c:1.2
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/spa_misc.c:1.1.1.2	Sat Feb 27 22:31:07 2010
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/spa_misc.c	Fri Mar 28 03:46:56 2014
@@ -1136,13 +1136,13 @@ spa_generate_guid(spa_t *spa)
 }
 
 void
-sprintf_blkptr(char *buf, const blkptr_t *bp)
+snprintf_blkptr(char *buf, size_t buflen, const blkptr_t *bp)
 {
 	char *type = dmu_ot[BP_GET_TYPE(bp)].ot_name;
 	char *checksum = zio_checksum_table[BP_GET_CHECKSUM(bp)].ci_name;
 	char *compress = zio_compress_table[BP_GET_COMPRESS(bp)].ci_name;
 
-	SPRINTF_BLKPTR(snprintf, ' ', buf, bp, type, checksum, compress);
+	SNPRINTF_BLKPTR(snprintf, ' ', buf, buflen, bp, type, checksum, compress);
 }
 
 void

Index: src/external/cddl/osnet/dist/uts/common/fs/zfs/sys/dbuf.h
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/sys/dbuf.h:1.1.1.2 src/external/cddl/osnet/dist/uts/common/fs/zfs/sys/dbuf.h:1.2
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/sys/dbuf.h:1.1.1.2	Sat Feb 27 22:31:39 2010
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/sys/dbuf.h	Fri Mar 28 03:46:56 2014
@@ -326,7 +326,7 @@ _NOTE(CONSTCOND) } while (0)
 #define	dprintf_dbuf_bp(db, bp, fmt, ...) do {			\
 	if (zfs_flags  ZFS_DEBUG_DPRINTF) {			\
 	char *__blkbuf = kmem_alloc(BP_SPRINTF_LEN, KM_SLEEP);	\
-	sprintf_blkptr(__blkbuf, bp);\
+	snprintf_blkptr(__blkbuf, BP_SPRINTF_LEN, bp);\
 	dprintf_dbuf(db, fmt  %s\n, __VA_ARGS__, __blkbuf);	\
 	kmem_free(__blkbuf, BP_SPRINTF_LEN);			\
 	} 			\

Index: src/external/cddl/osnet/dist/uts/common/fs/zfs/sys/spa.h
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/sys/spa.h:1.2 src/external/cddl/osnet/dist/uts/common/fs/zfs/sys/spa.h:1.3
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/sys/spa.h:1.2	Fri Mar 28 03:18:24 2014
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/sys/spa.h	Fri Mar 28 03:46:56 2014
@@ -344,11 +344,11 @@ typedef struct blkptr {
  * 'func' is either snprintf() or mdb_snprintf().
  * 'ws' (whitespace) can be ' ' for single-line format, '\n' for multi-line.
  */
-#define	SPRINTF_BLKPTR(func, ws, buf, bp, type, checksum, compress)	\
+#define	SNPRINTF_BLKPTR(func, ws, buf, buflen, bp, type, checksum, compress)	\
 {	\
 	static const char *copyname[] =	\
 	{ zero, single, double, triple };			\
-	int size = BP_SPRINTF_LEN;	\
+	int size = buflen;	\
 	int len = 0;			\
 	int copies = 0;			\
 	\
@@ -592,7 +592,7 @@ extern char *spa_strdup(const char *);
 extern void spa_strfree(char *);
 extern uint64_t spa_get_random(uint64_t range);
 extern uint64_t spa_generate_guid(spa_t *spa);
-extern void snprintf_blkptr(char *buf, const blkptr_t *bp);
+extern void snprintf_blkptr(char *buf, size_t buflen, const blkptr_t *bp);
 extern void spa_freeze(spa_t *spa);
 extern void spa_upgrade(spa_t *spa, uint64_t version);
 extern void spa_evict_all(void);



CVS commit: src/sys/arch/news68k/stand/boot

2014-03-28 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Fri Mar 28 11:49:40 UTC 2014

Modified Files:
src/sys/arch/news68k/stand/boot: boot.c

Log Message:
Use snprintf instead of sprintf


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/news68k/stand/boot/boot.c

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

Modified files:

Index: src/sys/arch/news68k/stand/boot/boot.c
diff -u src/sys/arch/news68k/stand/boot/boot.c:1.18 src/sys/arch/news68k/stand/boot/boot.c:1.19
--- src/sys/arch/news68k/stand/boot/boot.c:1.18	Wed Aug 25 16:35:02 2010
+++ src/sys/arch/news68k/stand/boot/boot.c	Fri Mar 28 11:49:40 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot.c,v 1.18 2010/08/25 16:35:02 christos Exp $	*/
+/*	$NetBSD: boot.c,v 1.19 2014/03/28 11:49:40 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 1999 Izumi Tsutsui.  All rights reserved.
@@ -114,7 +114,7 @@ boot(uint32_t d4, uint32_t d5, uint32_t 
 		return;
 	}
 
-	sprintf(devname, %s(%d,%d,%d), devs[type], ctlr, unit, part);
+	snprintf(devname, sizeof(devname), %s(%d,%d,%d), devs[type], ctlr, unit, part);
 	printf(Booting %s%s\n, devname, netbsd);
 
 	/* use user specified kernel name if exists */
@@ -128,7 +128,7 @@ boot(uint32_t d4, uint32_t d5, uint32_t 
 		loadflag = ~LOAD_BACKWARDS;
 
 	for (i = 0; kernels[i]; i++) {
-		sprintf(file, %s%s, devname, kernels[i]);
+		snprintf(file, sizeof(file), %s%s, devname, kernels[i]);
 		DPRINTF(trying %s...\n, file);
 		fd = loadfile(file, marks, loadflag);
 		if (fd != -1)



CVS commit: src/sys/kern

2014-03-28 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Fri Mar 28 11:55:09 UTC 2014

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

Log Message:
Fix unused variable 'mp'


To generate a diff of this commit:
cvs rdiff -u -r1.136 -r1.137 src/sys/kern/tty_pty.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/tty_pty.c
diff -u src/sys/kern/tty_pty.c:1.136 src/sys/kern/tty_pty.c:1.137
--- src/sys/kern/tty_pty.c:1.136	Thu Mar 27 17:31:56 2014
+++ src/sys/kern/tty_pty.c	Fri Mar 28 11:55:09 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: tty_pty.c,v 1.136 2014/03/27 17:31:56 christos Exp $	*/
+/*	$NetBSD: tty_pty.c,v 1.137 2014/03/28 11:55:09 ozaki-r Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: tty_pty.c,v 1.136 2014/03/27 17:31:56 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: tty_pty.c,v 1.137 2014/03/28 11:55:09 ozaki-r Exp $);
 
 #include opt_ptm.h
 
@@ -1041,7 +1041,9 @@ ptyioctl(dev_t dev, u_long cmd, void *da
 	const struct cdevsw *cdev;
 	u_char *cc = tp-t_cc;
 	int stop, error, sig;
+#ifndef NO_DEV_PTM
 	struct mount *mp;
+#endif
 
 	/*
 	 * IF CONTROLLER STTY THEN MUST FLUSH TO PREVENT A HANG.



CVS commit: src/sys/arch/atari/stand/ahdilabel

2014-03-28 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Fri Mar 28 13:35:13 UTC 2014

Modified Files:
src/sys/arch/atari/stand/ahdilabel: ahdilabel.c

Log Message:
Fix; cts[0] = cts


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/atari/stand/ahdilabel/ahdilabel.c

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

Modified files:

Index: src/sys/arch/atari/stand/ahdilabel/ahdilabel.c
diff -u src/sys/arch/atari/stand/ahdilabel/ahdilabel.c:1.9 src/sys/arch/atari/stand/ahdilabel/ahdilabel.c:1.10
--- src/sys/arch/atari/stand/ahdilabel/ahdilabel.c:1.9	Wed Mar 26 18:04:33 2014
+++ src/sys/arch/atari/stand/ahdilabel/ahdilabel.c	Fri Mar 28 13:35:13 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: ahdilabel.c,v 1.9 2014/03/26 18:04:33 christos Exp $ */
+/* $NetBSD: ahdilabel.c,v 1.10 2014/03/28 13:35:13 ozaki-r Exp $ */
 
 /*
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -402,7 +402,7 @@ change_part (struct ahdi_ptable *ptable,
 	}
 
 	printf (size [%8u (%s) (%4uM)] , ptable-parts[part].size,
-	sec_to_cts (ptable, ptable-parts[part].size, cts[0], sizeof(cts)),
+	sec_to_cts (ptable, ptable-parts[part].size, cts, sizeof(cts)),
 	(ptable-parts[part].size + (BLPM  1)) / BLPM);
 	if (get_input (buf[0], BUFLEN)) {
 		sector = read_sector (ptable, buf, part, PART_END);



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

2014-03-28 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Fri Mar 28 13:26:24 UTC 2014

Modified Files:
src/sys/arch/vax/vsa: spx.c

Log Message:
Use snprintf instead of sprintf


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/vax/vsa/spx.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/vax/vsa/spx.c
diff -u src/sys/arch/vax/vsa/spx.c:1.7 src/sys/arch/vax/vsa/spx.c:1.8
--- src/sys/arch/vax/vsa/spx.c:1.7	Thu Oct 24 13:16:33 2013
+++ src/sys/arch/vax/vsa/spx.c	Fri Mar 28 13:26:24 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: spx.c,v 1.7 2013/10/24 13:16:33 martin Exp $ */
+/*	$NetBSD: spx.c,v 1.8 2014/03/28 13:26:24 ozaki-r Exp $ */
 /*
  * SPX/LCSPX/SPXg/SPXgt accelerated framebuffer driver for NetBSD/VAX
  * Copyright (c) 2005 Blaz Antonic
@@ -32,7 +32,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: spx.c,v 1.7 2013/10/24 13:16:33 martin Exp $);
+__KERNEL_RCSID(0, $NetBSD: spx.c,v 1.8 2014/03/28 13:26:24 ozaki-r Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -1512,7 +1512,8 @@ spx_init_common(device_t self, struct vs
 	spx_stdscreen.nrows = spx_rows;
 	spx_stdscreen.fontwidth = spx_font.fontwidth;
 	spx_stdscreen.fontheight = spx_font.fontheight;
-	sprintf(spx_stdscreen_name, %dx%d, spx_cols, spx_rows);
+	snprintf(spx_stdscreen_name, sizeof(spx_stdscreen_name),
+%dx%d, spx_cols, spx_rows);
 
 	/* for SPXg spx_fb_size represents FB window size, not FB length */
 	if (fb_type == FB_IS_SPXg)



CVS commit: src/sys/arch/atari/stand/installboot

2014-03-28 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Sat Mar 29 05:03:43 UTC 2014

Modified Files:
src/sys/arch/atari/stand/installboot: installboot.c

Log Message:
Fix typos


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/atari/stand/installboot/installboot.c

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

Modified files:

Index: src/sys/arch/atari/stand/installboot/installboot.c
diff -u src/sys/arch/atari/stand/installboot/installboot.c:1.26 src/sys/arch/atari/stand/installboot/installboot.c:1.27
--- src/sys/arch/atari/stand/installboot/installboot.c:1.26	Wed Mar 26 18:04:33 2014
+++ src/sys/arch/atari/stand/installboot/installboot.c	Sat Mar 29 05:03:43 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: installboot.c,v 1.26 2014/03/26 18:04:33 christos Exp $	*/
+/*	$NetBSD: installboot.c,v 1.27 2014/03/29 05:03:43 ozaki-r Exp $	*/
 
 /*
  * Copyright (c) 1995 Waldi Ravens
@@ -228,7 +228,7 @@ install_fd(char *devnm, struct disklabel
 		machpath = milanpath;
 	else
 		machpath = stdpath;
-	size_t xxboolen = strlen(mdecpath) + strlen(machpath) + 8);
+	size_t xxboolen = strlen(mdecpath) + strlen(machpath) + 8;
 	xxboot = alloca(xxbootlen);
 	snprintf(xxboot, xxbootlen, %s%sfdboot, mdecpath, machpath);
 	bootxx = alloca(xxbootlen);
@@ -369,7 +369,7 @@ install_wd(char *devnm, struct disklabel
 		size_t xxb00tlen = strlen(mdecpath) + strlen(machpath) + 14;
 		xxb00t = alloca(xxb00tlen);
 		snprintf(xxb00t, xxb00tlen, %s%swdb00t.ahdi, mdecpath, machpath);
-		xnxboot = alloca(xxb00tlen);
+		xxboot = alloca(xxb00tlen);
 		snprintf(xxboot, xxb00tlen, %s%sxxboot.ahdi, mdecpath, machpath);
 		magic = AHDIMAGIC;
 	} else {



CVS commit: src/sys/arch/news68k/stand/bootxx

2014-03-28 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Sat Mar 29 05:07:25 UTC 2014

Modified Files:
src/sys/arch/news68k/stand/bootxx: bootxx.c

Log Message:
Replace sprintf with snprintf


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/news68k/stand/bootxx/bootxx.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/news68k/stand/bootxx/bootxx.c
diff -u src/sys/arch/news68k/stand/bootxx/bootxx.c:1.10 src/sys/arch/news68k/stand/bootxx/bootxx.c:1.11
--- src/sys/arch/news68k/stand/bootxx/bootxx.c:1.10	Wed May 14 13:29:28 2008
+++ src/sys/arch/news68k/stand/bootxx/bootxx.c	Sat Mar 29 05:07:25 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: bootxx.c,v 1.10 2008/05/14 13:29:28 tsutsui Exp $	*/
+/*	$NetBSD: bootxx.c,v 1.11 2014/03/29 05:07:25 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 1999 Izumi Tsutsui.  All rights reserved.
@@ -113,7 +113,8 @@ bootxx(uint32_t d4, uint32_t d5, uint32_
 		return;
 	}
 
-	sprintf(devname, %s(%d,%d,%d), devs[type], ctlr, unit, part);
+	snprintf(devname, sizeof(devname), %s(%d,%d,%d),
+	devs[type], ctlr, unit, part);
 
 	fd = rom_open(devname, 0);
 	if (fd == -1) {



CVS commit: src/sys/arch/atari/stand/installboot

2014-03-31 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Mar 31 06:32:31 UTC 2014

Modified Files:
src/sys/arch/atari/stand/installboot: installboot.c

Log Message:
Fix typo


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/atari/stand/installboot/installboot.c

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

Modified files:

Index: src/sys/arch/atari/stand/installboot/installboot.c
diff -u src/sys/arch/atari/stand/installboot/installboot.c:1.27 src/sys/arch/atari/stand/installboot/installboot.c:1.28
--- src/sys/arch/atari/stand/installboot/installboot.c:1.27	Sat Mar 29 05:03:43 2014
+++ src/sys/arch/atari/stand/installboot/installboot.c	Mon Mar 31 06:32:31 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: installboot.c,v 1.27 2014/03/29 05:03:43 ozaki-r Exp $	*/
+/*	$NetBSD: installboot.c,v 1.28 2014/03/31 06:32:31 ozaki-r Exp $	*/
 
 /*
  * Copyright (c) 1995 Waldi Ravens
@@ -228,7 +228,7 @@ install_fd(char *devnm, struct disklabel
 		machpath = milanpath;
 	else
 		machpath = stdpath;
-	size_t xxboolen = strlen(mdecpath) + strlen(machpath) + 8;
+	size_t xxbootlen = strlen(mdecpath) + strlen(machpath) + 8;
 	xxboot = alloca(xxbootlen);
 	snprintf(xxboot, xxbootlen, %s%sfdboot, mdecpath, machpath);
 	bootxx = alloca(xxbootlen);



CVS commit: src/sys/arch/evbarm/nslu2

2014-03-31 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Mar 31 10:22:20 UTC 2014

Modified Files:
src/sys/arch/evbarm/nslu2: nslu2_pci.c

Log Message:
Get rid of redundant return


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/evbarm/nslu2/nslu2_pci.c

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

Modified files:

Index: src/sys/arch/evbarm/nslu2/nslu2_pci.c
diff -u src/sys/arch/evbarm/nslu2/nslu2_pci.c:1.6 src/sys/arch/evbarm/nslu2/nslu2_pci.c:1.7
--- src/sys/arch/evbarm/nslu2/nslu2_pci.c:1.6	Sat Mar 29 19:28:28 2014
+++ src/sys/arch/evbarm/nslu2/nslu2_pci.c	Mon Mar 31 10:22:20 2014
@@ -1,4 +1,4 @@
-/*  $NetBSD: nslu2_pci.c,v 1.6 2014/03/29 19:28:28 christos Exp $	*/
+/*  $NetBSD: nslu2_pci.c,v 1.7 2014/03/31 10:22:20 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 2006 The NetBSD Foundation, Inc.
@@ -56,7 +56,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nslu2_pci.c,v 1.6 2014/03/29 19:28:28 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: nslu2_pci.c,v 1.7 2014/03/31 10:22:20 ozaki-r Exp $);
 
 /*
  * Linksys NSLU2 PCI support.
@@ -120,7 +120,7 @@ nslu2_pci_intr_string(void *v, pci_intr_
 	}
 	snprintf(buf, len, PCI%c, c);
 
-	return return buf;
+	return buf;
 }
 
 static const struct evcnt *



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

2014-04-01 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Tue Apr  1 12:57:46 UTC 2014

Modified Files:
src/sys/arch/sgimips/include: pci_machdep.h

Log Message:
Add a missing comma


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/sgimips/include/pci_machdep.h

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

Modified files:

Index: src/sys/arch/sgimips/include/pci_machdep.h
diff -u src/sys/arch/sgimips/include/pci_machdep.h:1.12 src/sys/arch/sgimips/include/pci_machdep.h:1.13
--- src/sys/arch/sgimips/include/pci_machdep.h:1.12	Sat Mar 29 19:28:30 2014
+++ src/sys/arch/sgimips/include/pci_machdep.h	Tue Apr  1 12:57:46 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_machdep.h,v 1.12 2014/03/29 19:28:30 christos Exp $	*/
+/*	$NetBSD: pci_machdep.h,v 1.13 2014/04/01 12:57:46 ozaki-r Exp $	*/
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
@@ -93,7 +93,7 @@ void		pci_conf_write(pci_chipset_tag_t, 
 int		pci_conf_hook(pci_chipset_tag_t, int, int, int, pcireg_t);
 int		pci_intr_map(const struct pci_attach_args *,
 			pci_intr_handle_t *);
-const char	*pci_intr_string(pci_chipset_tag_t, pci_intr_handle_t, char *
+const char	*pci_intr_string(pci_chipset_tag_t, pci_intr_handle_t, char *,
 			size_t);
 const struct evcnt *pci_intr_evcnt(pci_chipset_tag_t, pci_intr_handle_t);
 void		*pci_intr_establish(pci_chipset_tag_t, pci_intr_handle_t,



CVS commit: src/sys/arch/sgimips/gio

2014-04-01 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Apr  2 00:46:12 UTC 2014

Modified Files:
src/sys/arch/sgimips/gio: pci_gio.c

Log Message:
Get rid of a wrong comma


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/sgimips/gio/pci_gio.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/sgimips/gio/pci_gio.c
diff -u src/sys/arch/sgimips/gio/pci_gio.c:1.12 src/sys/arch/sgimips/gio/pci_gio.c:1.13
--- src/sys/arch/sgimips/gio/pci_gio.c:1.12	Sat Mar 29 19:28:30 2014
+++ src/sys/arch/sgimips/gio/pci_gio.c	Wed Apr  2 00:46:11 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_gio.c,v 1.12 2014/03/29 19:28:30 christos Exp $	*/
+/*	$NetBSD: pci_gio.c,v 1.13 2014/04/02 00:46:11 ozaki-r Exp $	*/
 
 /*
  * Copyright (c) 2006 Stephen M. Rumble
@@ -25,7 +25,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pci_gio.c,v 1.12 2014/03/29 19:28:30 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: pci_gio.c,v 1.13 2014/04/02 00:46:11 ozaki-r Exp $);
 
 /*
  * Glue for PCI devices that are connected to the GIO bus by various little
@@ -302,7 +302,7 @@ giopci_intr_map(const struct pci_attach_
 
 static const char *
 giopci_intr_string(pci_chipset_tag_t pc, pci_intr_handle_t ih, char * buf,
-size_t, len)
+size_t len)
 {
 	snprintf(buf, len, slot %s, (ih == GIO_SLOT_EXP0) ? EXP0 :
 	(ih == GIO_SLOT_EXP1) ? EXP1 : GFX);



CVS commit: src/distrib/utils/embedded/conf

2014-04-02 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Thu Apr  3 01:36:20 UTC 2014

Modified Files:
src/distrib/utils/embedded/conf: rpi_inst.conf

Log Message:
Include evbarm.conf as same as other conf files

evbarm.conf ensures ${mnt}/boot exists so that it avoids the error:
  /home/builds/ab/HEAD/src/distrib/utils/embedded/mkimage: cannot create \
  /tmp/mkimage.2a/mnt/boot/cmdline.txt: directory nonexistent


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/distrib/utils/embedded/conf/rpi_inst.conf

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

Modified files:

Index: src/distrib/utils/embedded/conf/rpi_inst.conf
diff -u src/distrib/utils/embedded/conf/rpi_inst.conf:1.4 src/distrib/utils/embedded/conf/rpi_inst.conf:1.5
--- src/distrib/utils/embedded/conf/rpi_inst.conf:1.4	Mon Sep 16 15:23:57 2013
+++ src/distrib/utils/embedded/conf/rpi_inst.conf	Thu Apr  3 01:36:20 2014
@@ -1,10 +1,12 @@
-# $NetBSD: rpi_inst.conf,v 1.4 2013/09/16 15:23:57 ast Exp $
+# $NetBSD: rpi_inst.conf,v 1.5 2014/04/03 01:36:20 ozaki-r Exp $
 # Raspberry Pi customization script used by mkimage
 #
 
 board=rpi_inst
 kernel=$src/sys/arch/evbarm/compile/RPI/netbsd-RPI_INSTALL.bin
 
+. ${DIR}/conf/evbarm.conf
+
 image=$HOME/${board}.img
 
 specialdirs=/kern /proc



CVS commit: src/sys/arch/mips/rmi

2014-04-04 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Fri Apr  4 16:41:55 UTC 2014

Modified Files:
src/sys/arch/mips/rmi: rmixl_pcix.c

Log Message:
Adjust to pci_intr_string signature


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/mips/rmi/rmixl_pcix.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/mips/rmi/rmixl_pcix.c
diff -u src/sys/arch/mips/rmi/rmixl_pcix.c:1.11 src/sys/arch/mips/rmi/rmixl_pcix.c:1.12
--- src/sys/arch/mips/rmi/rmixl_pcix.c:1.11	Tue Mar 11 08:19:45 2014
+++ src/sys/arch/mips/rmi/rmixl_pcix.c	Fri Apr  4 16:41:55 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rmixl_pcix.c,v 1.11 2014/03/11 08:19:45 mrg Exp $	*/
+/*	$NetBSD: rmixl_pcix.c,v 1.12 2014/04/04 16:41:55 ozaki-r Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -40,7 +40,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: rmixl_pcix.c,v 1.11 2014/03/11 08:19:45 mrg Exp $);
+__KERNEL_RCSID(0, $NetBSD: rmixl_pcix.c,v 1.12 2014/04/04 16:41:55 ozaki-r Exp $);
 
 #include opt_pci.h
 #include pci.h
@@ -242,7 +242,8 @@ static void	rmixl_pcix_conf_write(void *
 static int	rmixl_pcix_intr_map(const struct pci_attach_args *,
 		pci_intr_handle_t *);
 static const char *
-		rmixl_pcix_intr_string(void *, pci_intr_handle_t);
+		rmixl_pcix_intr_string(void *, pci_intr_handle_t,
+		char *, size_t);
 static const struct evcnt *
 		rmixl_pcix_intr_evcnt(void *, pci_intr_handle_t);
 static pci_intr_handle_t
@@ -787,7 +788,7 @@ rmixl_pcix_intr_map(const struct pci_att
 }
 
 const char *
-rmixl_pcix_intr_string(void *v, pci_intr_handle_t pih)
+rmixl_pcix_intr_string(void *v, pci_intr_handle_t pih, char *buf, size_t len)
 {
 	u_int bitno, irq;
 
@@ -797,7 +798,8 @@ rmixl_pcix_intr_string(void *v, pci_intr
 		panic(%s: cpu %#x not supported\n,
 			__func__, mips_options.mips_cpu_id);
 
-	return rmixl_intr_string(RMIXL_IRT_VECTOR(irq));
+	strlcpy(buf, rmixl_intr_string(RMIXL_IRT_VECTOR(irq)), len);
+	return buf;
 }
 
 const struct evcnt *



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

2014-05-19 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Tue May 20 03:24:19 UTC 2014

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

Log Message:
Pad 0 to align outputs


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sys/arch/x86/x86/intr.c

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

Modified files:

Index: src/sys/arch/x86/x86/intr.c
diff -u src/sys/arch/x86/x86/intr.c:1.76 src/sys/arch/x86/x86/intr.c:1.77
--- src/sys/arch/x86/x86/intr.c:1.76	Sat Mar 29 19:28:30 2014
+++ src/sys/arch/x86/x86/intr.c	Tue May 20 03:24:19 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: intr.c,v 1.76 2014/03/29 19:28:30 christos Exp $	*/
+/*	$NetBSD: intr.c,v 1.77 2014/05/20 03:24:19 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -133,7 +133,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: intr.c,v 1.76 2014/03/29 19:28:30 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: intr.c,v 1.77 2014/05/20 03:24:19 ozaki-r Exp $);
 
 #include opt_intrdebug.h
 #include opt_multiprocessor.h
@@ -1083,7 +1083,7 @@ intr_printconfig(void)
 	for (CPU_INFO_FOREACH(cii, ci)) {
 		(*pr)(%s: interrupt masks:\n, device_xname(ci-ci_dev));
 		for (i = 0; i  NIPL; i++)
-			(*pr)(IPL %d mask %lx unmask %lx\n, i,
+			(*pr)(IPL %d mask %08lx unmask %08lx\n, i,
 			(u_long)ci-ci_imask[i], (u_long)ci-ci_iunmask[i]);
 		for (i = 0; i  MAX_INTR_SOURCES; i++) {
 			isp = ci-ci_isources[i];



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

2014-05-20 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed May 21 01:02:45 UTC 2014

Modified Files:
src/sys/arch/arm/cortex: a9_mpsubr.S

Log Message:
Fix wrong instruction; mrc = mcr


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/arm/cortex/a9_mpsubr.S

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

Modified files:

Index: src/sys/arch/arm/cortex/a9_mpsubr.S
diff -u src/sys/arch/arm/cortex/a9_mpsubr.S:1.17 src/sys/arch/arm/cortex/a9_mpsubr.S:1.18
--- src/sys/arch/arm/cortex/a9_mpsubr.S:1.17	Fri Apr 11 16:32:12 2014
+++ src/sys/arch/arm/cortex/a9_mpsubr.S	Wed May 21 01:02:45 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: a9_mpsubr.S,v 1.17 2014/04/11 16:32:12 matt Exp $	*/
+/*	$NetBSD: a9_mpsubr.S,v 1.18 2014/05/21 01:02:45 ozaki-r Exp $	*/
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -632,7 +632,7 @@ cortex_mpcontinuation:
 
 	mrc	p15, 0, r1, c2, c0, 2		// TTBCR get
 	orr	r1, r1, #TTBCR_S_PD0		// prevent lookups via TTBR0
-	mrc	p15, 0, r1, c2, c0, 2		// TTBCR set
+	mcr	p15, 0, r1, c2, c0, 2		// TTBCR set
 
 #ifdef MPDEBUG
 	str	pc, [r9]			// we've got this far



CVS commit: src/sys/netinet

2014-06-02 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Tue Jun  3 01:24:32 UTC 2014

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

Log Message:
Call ifp-if_output in revarprequest with KERNEL_LOCK held

Otherwise, it hits KASSERT(KERNEL_LOCKED_P()) in ether_output
when nfs_boot fails and tries RARP.


To generate a diff of this commit:
cvs rdiff -u -r1.157 -r1.158 src/sys/netinet/if_arp.c

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

Modified files:

Index: src/sys/netinet/if_arp.c
diff -u src/sys/netinet/if_arp.c:1.157 src/sys/netinet/if_arp.c:1.158
--- src/sys/netinet/if_arp.c:1.157	Sun May 18 14:46:16 2014
+++ src/sys/netinet/if_arp.c	Tue Jun  3 01:24:32 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_arp.c,v 1.157 2014/05/18 14:46:16 rmind Exp $	*/
+/*	$NetBSD: if_arp.c,v 1.158 2014/06/03 01:24:32 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: if_arp.c,v 1.157 2014/05/18 14:46:16 rmind Exp $);
+__KERNEL_RCSID(0, $NetBSD: if_arp.c,v 1.158 2014/06/03 01:24:32 ozaki-r Exp $);
 
 #include opt_ddb.h
 #include opt_inet.h
@@ -1481,8 +1481,10 @@ revarprequest(struct ifnet *ifp)
 	sa.sa_family = AF_ARP;
 	sa.sa_len = 2;
 	m-m_flags |= M_BCAST;
-	(*ifp-if_output)(ifp, m, sa, NULL);
 
+	KERNEL_LOCK(1, NULL);
+	(*ifp-if_output)(ifp, m, sa, NULL);
+	KERNEL_UNLOCK_ONE(NULL);
 }
 
 /*



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

2014-06-12 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Thu Jun 12 06:28:09 UTC 2014

Modified Files:
src/sys/arch/arm/include: mutex.h

Log Message:
Fix macro name; MUTEX_RECEIVE = MUTEX_GIVE


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/arm/include/mutex.h

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

Modified files:

Index: src/sys/arch/arm/include/mutex.h
diff -u src/sys/arch/arm/include/mutex.h:1.14 src/sys/arch/arm/include/mutex.h:1.15
--- src/sys/arch/arm/include/mutex.h:1.14	Fri Mar 28 21:40:53 2014
+++ src/sys/arch/arm/include/mutex.h	Thu Jun 12 06:28:09 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: mutex.h,v 1.14 2014/03/28 21:40:53 matt Exp $	*/
+/*	$NetBSD: mutex.h,v 1.15 2014/06/12 06:28:09 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 2002, 2007 The NetBSD Foundation, Inc.
@@ -103,7 +103,7 @@ struct kmutex {
  */
 #ifdef MULTIPROCESSOR
 #if defined(_ARM_ARCH_7)  !defined(_ARM_ARCH_6)
-#define	MUTEX_RECEIVE(mtx)		__asm __volatile(dsb)
+#define	MUTEX_GIVE(mtx)			__asm __volatile(dsb)
 #else
 #define	MUTEX_GIVE(mtx)			membar_producer()
 #endif



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

2014-06-12 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Thu Jun 12 08:50:52 UTC 2014

Modified Files:
src/sys/arch/arm/include: mutex.h rwlock.h

Log Message:
Fix ARMv7 checks

_ARM_ARCH_7  !_ARM_ARCH_6 never be true.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/arm/include/mutex.h
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/include/rwlock.h

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

Modified files:

Index: src/sys/arch/arm/include/mutex.h
diff -u src/sys/arch/arm/include/mutex.h:1.15 src/sys/arch/arm/include/mutex.h:1.16
--- src/sys/arch/arm/include/mutex.h:1.15	Thu Jun 12 06:28:09 2014
+++ src/sys/arch/arm/include/mutex.h	Thu Jun 12 08:50:52 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: mutex.h,v 1.15 2014/06/12 06:28:09 ozaki-r Exp $	*/
+/*	$NetBSD: mutex.h,v 1.16 2014/06/12 08:50:52 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 2002, 2007 The NetBSD Foundation, Inc.
@@ -89,7 +89,7 @@ struct kmutex {
  * interrupts, not multiple processors.
  */
 #ifdef MULTIPROCESSOR
-#if defined(_ARM_ARCH_7)  !defined(_ARM_ARCH_6)
+#ifdef _ARM_ARCH_7
 #define	MUTEX_RECEIVE(mtx)		__asm __volatile(dmb)
 #else
 #define	MUTEX_RECEIVE(mtx)		membar_consumer()
@@ -102,7 +102,7 @@ struct kmutex {
  * MUTEX_GIVE: no memory barrier required; same reason.
  */
 #ifdef MULTIPROCESSOR
-#if defined(_ARM_ARCH_7)  !defined(_ARM_ARCH_6)
+#ifdef _ARM_ARCH_7
 #define	MUTEX_GIVE(mtx)			__asm __volatile(dsb)
 #else
 #define	MUTEX_GIVE(mtx)			membar_producer()

Index: src/sys/arch/arm/include/rwlock.h
diff -u src/sys/arch/arm/include/rwlock.h:1.7 src/sys/arch/arm/include/rwlock.h:1.8
--- src/sys/arch/arm/include/rwlock.h:1.7	Fri Mar 28 21:40:53 2014
+++ src/sys/arch/arm/include/rwlock.h	Thu Jun 12 08:50:52 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rwlock.h,v 1.7 2014/03/28 21:40:53 matt Exp $	*/
+/*	$NetBSD: rwlock.h,v 1.8 2014/06/12 08:50:52 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 2002, 2006 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@ struct krwlock {
 #define	__HAVE_SIMPLE_RW_LOCKS		1
 
 #ifdef MULTIPROCESSOR
-#if defined(_ARM_ARCH_7)  !defined(_ARM_ARCH_6)
+#ifdef _ARM_ARCH_7
 #define	RW_RECEIVE(rw)			__asm __volatile(dmb)
 #define	RW_GIVE(rw)			__asm __volatile(dsb)
 #else



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

2014-06-14 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Sat Jun 14 09:13:30 UTC 2014

Modified Files:
src/sys/arch/arm/arm: arm_machdep.c

Log Message:
Fix typo


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/arch/arm/arm/arm_machdep.c

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

Modified files:

Index: src/sys/arch/arm/arm/arm_machdep.c
diff -u src/sys/arch/arm/arm/arm_machdep.c:1.41 src/sys/arch/arm/arm/arm_machdep.c:1.42
--- src/sys/arch/arm/arm/arm_machdep.c:1.41	Wed Apr 16 22:33:07 2014
+++ src/sys/arch/arm/arm/arm_machdep.c	Sat Jun 14 09:13:30 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: arm_machdep.c,v 1.41 2014/04/16 22:33:07 matt Exp $	*/
+/*	$NetBSD: arm_machdep.c,v 1.42 2014/06/14 09:13:30 ozaki-r Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -78,7 +78,7 @@
 
 #include sys/param.h
 
-__KERNEL_RCSID(0, $NetBSD: arm_machdep.c,v 1.41 2014/04/16 22:33:07 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: arm_machdep.c,v 1.42 2014/06/14 09:13:30 ozaki-r Exp $);
 
 #include sys/exec.h
 #include sys/proc.h
@@ -262,7 +262,7 @@ cpu_need_resched(struct cpu_info *ci, in
 #endif
 	if (flags  RESCHED_KPREEMPT) {
 #ifdef __HAVE_PREEMPTION
-		atomic_or_uint(l-l_dopreempt, DOPREEMPT_ACITBE);
+		atomic_or_uint(l-l_dopreempt, DOPREEMPT_ACTIVE);
 		if (ci == cur_ci) {
 			softint_trigger(SOFTINT_KPREEMPT);
 		} else {



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

2014-06-14 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Sun Jun 15 02:27:15 UTC 2014

Modified Files:
src/sys/arch/arm/arm32: cpuswitch.S

Log Message:
Fix wrong instruction; mcr = mrc


To generate a diff of this commit:
cvs rdiff -u -r1.83 -r1.84 src/sys/arch/arm/arm32/cpuswitch.S

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

Modified files:

Index: src/sys/arch/arm/arm32/cpuswitch.S
diff -u src/sys/arch/arm/arm32/cpuswitch.S:1.83 src/sys/arch/arm/arm32/cpuswitch.S:1.84
--- src/sys/arch/arm/arm32/cpuswitch.S:1.83	Fri Mar 28 21:52:53 2014
+++ src/sys/arch/arm/arm32/cpuswitch.S	Sun Jun 15 02:27:15 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpuswitch.S,v 1.83 2014/03/28 21:52:53 matt Exp $	*/
+/*	$NetBSD: cpuswitch.S,v 1.84 2014/06/15 02:27:15 ozaki-r Exp $	*/
 
 /*
  * Copyright 2003 Wasabi Systems, Inc.
@@ -87,7 +87,7 @@
 #include arm/asm.h
 #include arm/locore.h
 
-	RCSID($NetBSD: cpuswitch.S,v 1.83 2014/03/28 21:52:53 matt Exp $)
+	RCSID($NetBSD: cpuswitch.S,v 1.84 2014/06/15 02:27:15 ozaki-r Exp $)
 
 /* LINTSTUB: include sys/param.h */
 	
@@ -139,7 +139,7 @@ ENTRY(cpu_switchto)
 #ifdef TPIDRPRW_IS_CURCPU
 	GET_CURCPU(r3)
 #elif defined(TPIDRPRW_IS_CURLWP)
-	mcr	p15, 0, r0, c13, c0, 4		/* get old lwp (r4 maybe 0) */
+	mrc	p15, 0, r0, c13, c0, 4		/* get old lwp (r4 maybe 0) */
 	ldr	r3, [r0, #(L_CPU)]		/* get cpu from old lwp */
 #elif !defined(MULTIPROCESSOR) 
 	ldr	r3, [r6, #L_CPU]		/* get cpu from new lwp */



CVS commit: src/sys/arch/arm/include/arm32

2014-06-14 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Sun Jun 15 03:27:46 UTC 2014

Modified Files:
src/sys/arch/arm/include/arm32: pmap.h

Log Message:
Fix macro name; PMAP_TLB_NEED_SHOOTDOWN = PMAP_NEED_TLB_SHOOTDOWN


To generate a diff of this commit:
cvs rdiff -u -r1.132 -r1.133 src/sys/arch/arm/include/arm32/pmap.h

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

Modified files:

Index: src/sys/arch/arm/include/arm32/pmap.h
diff -u src/sys/arch/arm/include/arm32/pmap.h:1.132 src/sys/arch/arm/include/arm32/pmap.h:1.133
--- src/sys/arch/arm/include/arm32/pmap.h:1.132	Wed Apr 16 07:29:52 2014
+++ src/sys/arch/arm/include/arm32/pmap.h	Sun Jun 15 03:27:46 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.h,v 1.132 2014/04/16 07:29:52 matt Exp $	*/
+/*	$NetBSD: pmap.h,v 1.133 2014/06/15 03:27:46 ozaki-r Exp $	*/
 
 /*
  * Copyright (c) 2002, 2003 Wasabi Systems, Inc.
@@ -84,7 +84,7 @@
 #define PMAP_TLB_MAX			1
 #define PMAP_TLB_HWPAGEWALKER		1
 #if PMAP_TLB_MAX  1
-#define PMAP_TLB_NEED_SHOOTDOWN		1
+#define PMAP_NEED_TLB_SHOOTDOWN		1
 #endif
 #define PMAP_TLB_FLUSH_ASID_ON_RESET	(arm_has_tlbiasid_p)
 #define PMAP_TLB_NUM_PIDS		256



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

2014-06-14 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Sun Jun 15 04:04:01 UTC 2014

Modified Files:
src/sys/arch/arm/arm32: pmap.c

Log Message:
Add missing semicolon


To generate a diff of this commit:
cvs rdiff -u -r1.293 -r1.294 src/sys/arch/arm/arm32/pmap.c

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

Modified files:

Index: src/sys/arch/arm/arm32/pmap.c
diff -u src/sys/arch/arm/arm32/pmap.c:1.293 src/sys/arch/arm/arm32/pmap.c:1.294
--- src/sys/arch/arm/arm32/pmap.c:1.293	Thu Jun  5 03:45:48 2014
+++ src/sys/arch/arm/arm32/pmap.c	Sun Jun 15 04:04:01 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.293 2014/06/05 03:45:48 matt Exp $	*/
+/*	$NetBSD: pmap.c,v 1.294 2014/06/15 04:04:01 ozaki-r Exp $	*/
 
 /*
  * Copyright 2003 Wasabi Systems, Inc.
@@ -216,7 +216,7 @@
 #include arm/locore.h
 //#include arm/arm32/katelib.h
 
-__KERNEL_RCSID(0, $NetBSD: pmap.c,v 1.293 2014/06/05 03:45:48 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: pmap.c,v 1.294 2014/06/15 04:04:01 ozaki-r Exp $);
 
 //#define PMAP_DEBUG
 #ifdef PMAP_DEBUG
@@ -7772,7 +7772,7 @@ int
 pic_ipi_shootdown(void *arg)
 {
 #if PMAP_NEED_TLB_SHOOTDOWN
-	pmap_tlb_shootdown_process()
+	pmap_tlb_shootdown_process();
 #endif
 	return 1;
 }



CVS commit: src/sys/net

2014-06-15 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Sun Jun 15 16:10:46 UTC 2014

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

Log Message:
Get rid of unnecessary splnet for pool_{get,put}

A mutex prevents interrupts in the functions now.


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 src/sys/net/if_bridge.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_bridge.c
diff -u src/sys/net/if_bridge.c:1.77 src/sys/net/if_bridge.c:1.78
--- src/sys/net/if_bridge.c:1.77	Sat Jun 29 21:06:58 2013
+++ src/sys/net/if_bridge.c	Sun Jun 15 16:10:46 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bridge.c,v 1.77 2013/06/29 21:06:58 rmind Exp $	*/
+/*	$NetBSD: if_bridge.c,v 1.78 2014/06/15 16:10:46 ozaki-r Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -80,7 +80,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: if_bridge.c,v 1.77 2013/06/29 21:06:58 rmind Exp $);
+__KERNEL_RCSID(0, $NetBSD: if_bridge.c,v 1.78 2014/06/15 16:10:46 ozaki-r Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_bridge_ipf.h
@@ -1647,7 +1647,7 @@ bridge_rtupdate(struct bridge_softc *sc,
 struct ifnet *dst_if, int setflags, uint8_t flags)
 {
 	struct bridge_rtnode *brt;
-	int error, s;
+	int error;
 
 	/*
 	 * A route for this destination might already exist.  If so,
@@ -1662,9 +1662,7 @@ bridge_rtupdate(struct bridge_softc *sc,
 		 * initialize the expiration time and Ethernet
 		 * address.
 		 */
-		s = splnet();
 		brt = pool_get(bridge_rtnode_pool, PR_NOWAIT);
-		splx(s);
 		if (brt == NULL)
 			return (ENOMEM);
 
@@ -1674,9 +1672,7 @@ bridge_rtupdate(struct bridge_softc *sc,
 		memcpy(brt-brt_addr, dst, ETHER_ADDR_LEN);
 
 		if ((error = bridge_rtnode_insert(sc, brt)) != 0) {
-			s = splnet();
 			pool_put(bridge_rtnode_pool, brt);
-			splx(s);
 			return (error);
 		}
 	}



CVS commit: src/sys

2014-06-15 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Jun 16 00:33:39 UTC 2014

Modified Files:
src/sys/net: pktqueue.c pktqueue.h
src/sys/netinet: ip_input.c
src/sys/netinet6: ip6_input.c

Log Message:
Add 3rd argument to pktq_create to pass sc

It will be used to pass bridge sc for bridge_forward softint.

ok rmind@


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/net/pktqueue.c
cvs rdiff -u -r1.2 -r1.3 src/sys/net/pktqueue.h
cvs rdiff -u -r1.318 -r1.319 src/sys/netinet/ip_input.c
cvs rdiff -u -r1.148 -r1.149 src/sys/netinet6/ip6_input.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/pktqueue.c
diff -u src/sys/net/pktqueue.c:1.4 src/sys/net/pktqueue.c:1.5
--- src/sys/net/pktqueue.c:1.4	Mon Jun  9 14:44:48 2014
+++ src/sys/net/pktqueue.c	Mon Jun 16 00:33:39 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: pktqueue.c,v 1.4 2014/06/09 14:44:48 rmind Exp $	*/
+/*	$NetBSD: pktqueue.c,v 1.5 2014/06/16 00:33:39 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pktqueue.c,v 1.4 2014/06/09 14:44:48 rmind Exp $);
+__KERNEL_RCSID(0, $NetBSD: pktqueue.c,v 1.5 2014/06/16 00:33:39 ozaki-r Exp $);
 
 #include sys/param.h
 #include sys/types.h
@@ -96,7 +96,7 @@ typedef struct {
 roundup2(offsetof(pktqueue_t, pq_queue[ncpu]), coherency_unit)
 
 pktqueue_t *
-pktq_create(size_t maxlen, void (*intrh)(void *))
+pktq_create(size_t maxlen, void (*intrh)(void *), void *sc)
 {
 	const u_int sflags = SOFTINT_NET | SOFTINT_MPSAFE | SOFTINT_RCPU;
 	const size_t len = PKTQUEUE_STRUCT_LEN(ncpu);
@@ -107,7 +107,7 @@ pktq_create(size_t maxlen, void (*intrh)
 	if ((pc = percpu_alloc(sizeof(pktq_counters_t))) == NULL) {
 		return NULL;
 	}
-	if ((sih = softint_establish(sflags, intrh, NULL)) == NULL) {
+	if ((sih = softint_establish(sflags, intrh, sc)) == NULL) {
 		percpu_free(pc, sizeof(pktq_counters_t));
 		return NULL;
 	}

Index: src/sys/net/pktqueue.h
diff -u src/sys/net/pktqueue.h:1.2 src/sys/net/pktqueue.h:1.3
--- src/sys/net/pktqueue.h:1.2	Mon Jun  9 12:57:04 2014
+++ src/sys/net/pktqueue.h	Mon Jun 16 00:33:39 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: pktqueue.h,v 1.2 2014/06/09 12:57:04 rmind Exp $	*/
+/*	$NetBSD: pktqueue.h,v 1.3 2014/06/16 00:33:39 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -42,7 +42,7 @@ typedef struct pktqueue pktqueue_t;
 
 typedef enum { PKTQ_MAXLEN, PKTQ_NITEMS, PKTQ_DROPS } pktq_count_t;
 
-pktqueue_t *	pktq_create(size_t, void (*)(void *));
+pktqueue_t *	pktq_create(size_t, void (*)(void *), void *);
 void		pktq_destroy(pktqueue_t *);
 
 bool		pktq_enqueue(pktqueue_t *, struct mbuf *, const u_int);

Index: src/sys/netinet/ip_input.c
diff -u src/sys/netinet/ip_input.c:1.318 src/sys/netinet/ip_input.c:1.319
--- src/sys/netinet/ip_input.c:1.318	Thu Jun  5 23:48:16 2014
+++ src/sys/netinet/ip_input.c	Mon Jun 16 00:33:39 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip_input.c,v 1.318 2014/06/05 23:48:16 rmind Exp $	*/
+/*	$NetBSD: ip_input.c,v 1.319 2014/06/16 00:33:39 ozaki-r Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -91,7 +91,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ip_input.c,v 1.318 2014/06/05 23:48:16 rmind Exp $);
+__KERNEL_RCSID(0, $NetBSD: ip_input.c,v 1.319 2014/06/16 00:33:39 ozaki-r Exp $);
 
 #include opt_inet.h
 #include opt_compat_netbsd.h
@@ -304,7 +304,7 @@ ip_init(void)
 	pr = pffindproto(PF_INET, IPPROTO_RAW, SOCK_RAW);
 	KASSERT(pr != NULL);
 
-	ip_pktq = pktq_create(IFQ_MAXLEN, ipintr);
+	ip_pktq = pktq_create(IFQ_MAXLEN, ipintr, NULL);
 	KASSERT(ip_pktq != NULL);
 
 	for (u_int i = 0; i  IPPROTO_MAX; i++) {

Index: src/sys/netinet6/ip6_input.c
diff -u src/sys/netinet6/ip6_input.c:1.148 src/sys/netinet6/ip6_input.c:1.149
--- src/sys/netinet6/ip6_input.c:1.148	Thu Jun  5 23:48:16 2014
+++ src/sys/netinet6/ip6_input.c	Mon Jun 16 00:33:39 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip6_input.c,v 1.148 2014/06/05 23:48:16 rmind Exp $	*/
+/*	$NetBSD: ip6_input.c,v 1.149 2014/06/16 00:33:39 ozaki-r Exp $	*/
 /*	$KAME: ip6_input.c,v 1.188 2001/03/29 05:34:31 itojun Exp $	*/
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ip6_input.c,v 1.148 2014/06/05 23:48:16 rmind Exp $);
+__KERNEL_RCSID(0, $NetBSD: ip6_input.c,v 1.149 2014/06/16 00:33:39 ozaki-r Exp $);
 
 #include opt_gateway.h
 #include opt_inet.h
@@ -180,7 +180,7 @@ ip6_init(void)
 		pr-pr_protocol  pr-pr_protocol != IPPROTO_RAW)
 			ip6_protox[pr-pr_protocol] = pr - inet6sw;
 
-	ip6_pktq = pktq_create(IFQ_MAXLEN, ip6intr);
+	ip6_pktq = pktq_create(IFQ_MAXLEN, ip6intr, NULL);
 	KASSERT(ip6_pktq != NULL);
 
 	scope6_init();



CVS commit: src/sys/net

2014-06-15 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Jun 16 00:40:10 UTC 2014

Modified Files:
src/sys/net: if.c if.h pktqueue.c pktqueue.h

Log Message:
Move sysctl_pktq_{maxlen,count} to pktqueue.c and make them global

They will be used by bridge.

ok rmind@


To generate a diff of this commit:
cvs rdiff -u -r1.281 -r1.282 src/sys/net/if.c
cvs rdiff -u -r1.165 -r1.166 src/sys/net/if.h
cvs rdiff -u -r1.5 -r1.6 src/sys/net/pktqueue.c
cvs rdiff -u -r1.3 -r1.4 src/sys/net/pktqueue.h

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

Modified files:

Index: src/sys/net/if.c
diff -u src/sys/net/if.c:1.281 src/sys/net/if.c:1.282
--- src/sys/net/if.c:1.281	Fri Jun 13 13:54:08 2014
+++ src/sys/net/if.c	Mon Jun 16 00:40:10 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.c,v 1.281 2014/06/13 13:54:08 rmind Exp $	*/
+/*	$NetBSD: if.c,v 1.282 2014/06/16 00:40:10 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: if.c,v 1.281 2014/06/13 13:54:08 rmind Exp $);
+__KERNEL_RCSID(0, $NetBSD: if.c,v 1.282 2014/06/16 00:40:10 ozaki-r Exp $);
 
 #include opt_inet.h
 
@@ -2343,29 +2343,6 @@ bad:
 
 #if defined(INET) || defined(INET6)
 
-static int
-sysctl_pktq_maxlen(SYSCTLFN_ARGS, pktqueue_t *pq)
-{
-	u_int nmaxlen = pktq_get_count(pq, PKTQ_MAXLEN);
-	struct sysctlnode node = *rnode;
-	int error;
-
-	node.sysctl_data = nmaxlen;
-	error = sysctl_lookup(SYSCTLFN_CALL(node));
-	if (error || newp == NULL)
-		return error;
-	return pktq_set_maxlen(pq, nmaxlen);
-}
-
-static int
-sysctl_pktq_count(SYSCTLFN_ARGS, pktqueue_t *pq, u_int count_id)
-{
-	int count = pktq_get_count(pq, count_id);
-	struct sysctlnode node = *rnode;
-	node.sysctl_data = count;
-	return sysctl_lookup(SYSCTLFN_CALL(node));
-}
-
 #define	SYSCTL_NET_PKTQ(q, cn, c)	\
 	static int			\
 	sysctl_net_##q##_##cn(SYSCTLFN_ARGS)\

Index: src/sys/net/if.h
diff -u src/sys/net/if.h:1.165 src/sys/net/if.h:1.166
--- src/sys/net/if.h:1.165	Sun May 18 00:33:20 2014
+++ src/sys/net/if.h	Mon Jun 16 00:40:10 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.h,v 1.165 2014/05/18 00:33:20 rmind Exp $	*/
+/*	$NetBSD: if.h,v 1.166 2014/06/16 00:40:10 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -79,8 +79,10 @@
 
 #include sys/socket.h
 #include sys/queue.h
+
 #include net/dlt.h
 #include net/pfil.h
+#include net/pktqueue.h
 
 /*
  * Always include ALTQ glue here -- we use the ALTQ interface queue

Index: src/sys/net/pktqueue.c
diff -u src/sys/net/pktqueue.c:1.5 src/sys/net/pktqueue.c:1.6
--- src/sys/net/pktqueue.c:1.5	Mon Jun 16 00:33:39 2014
+++ src/sys/net/pktqueue.c	Mon Jun 16 00:40:10 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: pktqueue.c,v 1.5 2014/06/16 00:33:39 ozaki-r Exp $	*/
+/*	$NetBSD: pktqueue.c,v 1.6 2014/06/16 00:40:10 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pktqueue.c,v 1.5 2014/06/16 00:33:39 ozaki-r Exp $);
+__KERNEL_RCSID(0, $NetBSD: pktqueue.c,v 1.6 2014/06/16 00:40:10 ozaki-r Exp $);
 
 #include sys/param.h
 #include sys/types.h
@@ -361,3 +361,26 @@ pktq_set_maxlen(pktqueue_t *pq, size_t m
 	kmem_free(qs, slotbytes);
 	return 0;
 }
+
+int
+sysctl_pktq_maxlen(SYSCTLFN_ARGS, pktqueue_t *pq)
+{
+	u_int nmaxlen = pktq_get_count(pq, PKTQ_MAXLEN);
+	struct sysctlnode node = *rnode;
+	int error;
+
+	node.sysctl_data = nmaxlen;
+	error = sysctl_lookup(SYSCTLFN_CALL(node));
+	if (error || newp == NULL)
+		return error;
+	return pktq_set_maxlen(pq, nmaxlen);
+}
+
+int
+sysctl_pktq_count(SYSCTLFN_ARGS, pktqueue_t *pq, u_int count_id)
+{
+	int count = pktq_get_count(pq, count_id);
+	struct sysctlnode node = *rnode;
+	node.sysctl_data = count;
+	return sysctl_lookup(SYSCTLFN_CALL(node));
+}

Index: src/sys/net/pktqueue.h
diff -u src/sys/net/pktqueue.h:1.3 src/sys/net/pktqueue.h:1.4
--- src/sys/net/pktqueue.h:1.3	Mon Jun 16 00:33:39 2014
+++ src/sys/net/pktqueue.h	Mon Jun 16 00:40:10 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: pktqueue.h,v 1.3 2014/06/16 00:33:39 ozaki-r Exp $	*/
+/*	$NetBSD: pktqueue.h,v 1.4 2014/06/16 00:40:10 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -36,6 +36,8 @@
 #error not supposed to be exposed to userland.
 #endif
 
+#include sys/sysctl.h
+
 struct mbuf;
 
 typedef struct pktqueue pktqueue_t;
@@ -54,4 +56,7 @@ int		pktq_set_maxlen(pktqueue_t *, size_
 uint32_t	pktq_rps_hash(const struct mbuf *);
 uint64_t	pktq_get_count(pktqueue_t *, pktq_count_t);
 
+int		sysctl_pktq_maxlen(SYSCTLFN_PROTO, pktqueue_t *);
+int		sysctl_pktq_count(SYSCTLFN_PROTO, pktqueue_t *, u_int);
+
 #endif



CVS commit: src/sys/net

2014-06-15 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Jun 16 01:03:57 UTC 2014

Modified Files:
src/sys/net: if_bridge.c if_bridgevar.h

Log Message:
Use pktqueue for bridge forwarding queue and softint


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 src/sys/net/if_bridge.c
cvs rdiff -u -r1.15 -r1.16 src/sys/net/if_bridgevar.h

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

Modified files:

Index: src/sys/net/if_bridge.c
diff -u src/sys/net/if_bridge.c:1.78 src/sys/net/if_bridge.c:1.79
--- src/sys/net/if_bridge.c:1.78	Sun Jun 15 16:10:46 2014
+++ src/sys/net/if_bridge.c	Mon Jun 16 01:03:57 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bridge.c,v 1.78 2014/06/15 16:10:46 ozaki-r Exp $	*/
+/*	$NetBSD: if_bridge.c,v 1.79 2014/06/16 01:03:57 ozaki-r Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -80,7 +80,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: if_bridge.c,v 1.78 2014/06/15 16:10:46 ozaki-r Exp $);
+__KERNEL_RCSID(0, $NetBSD: if_bridge.c,v 1.79 2014/06/16 01:03:57 ozaki-r Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_bridge_ipf.h
@@ -100,12 +100,14 @@ __KERNEL_RCSID(0, $NetBSD: if_bridge.c,
 #include sys/kauth.h
 #include sys/cpu.h
 #include sys/cprng.h
+#include sys/xcall.h
 
 #include net/bpf.h
 #include net/if.h
 #include net/if_dl.h
 #include net/if_types.h
 #include net/if_llc.h
+#include net/pktqueue.h
 
 #include net/if_ether.h
 #include net/if_bridgevar.h
@@ -351,13 +353,6 @@ bridge_clone_create(struct if_clone *ifc
 	sc-sc_hold_time = BSTP_DEFAULT_HOLD_TIME;
 	sc-sc_filter_flags = 0;
 
-	/* software interrupt to do the work */
-	sc-sc_softintr = softint_establish(SOFTINT_NET, bridge_forward, sc);
-	if (sc-sc_softintr == NULL) {
-		free(sc, M_DEVBUF);
-		return ENOMEM;
-	}
-
 	/* Initialize our routing table. */
 	bridge_rtable_init(sc);
 
@@ -380,6 +375,9 @@ bridge_clone_create(struct if_clone *ifc
 	ifp-if_hdrlen = ETHER_HDR_LEN;
 	IFQ_SET_READY(ifp-if_snd);
 
+	sc-sc_fwd_pktq = pktq_create(IFQ_MAXLEN, bridge_forward, sc);
+	KASSERT(sc-sc_fwd_pktq != NULL);
+
 	if_attach(ifp);
 
 	if_alloc_sadl(ifp);
@@ -402,6 +400,12 @@ bridge_clone_destroy(struct ifnet *ifp)
 	struct bridge_softc *sc = ifp-if_softc;
 	struct bridge_iflist *bif;
 	int s;
+	uint64_t xc;
+
+	/* Must be called during IFF_RUNNING, i.e., before bridge_stop */
+	pktq_barrier(sc-sc_fwd_pktq);
+	xc = xc_broadcast(0, (xcfunc_t)nullop, NULL, NULL);
+	xc_wait(xc);
 
 	s = splnet();
 
@@ -416,11 +420,13 @@ bridge_clone_destroy(struct ifnet *ifp)
 
 	if_detach(ifp);
 
+	/* Should be called after if_detach for safe */
+	pktq_flush(sc-sc_fwd_pktq);
+	pktq_destroy(sc-sc_fwd_pktq);
+
 	/* Tear down the routing table. */
 	bridge_rtable_fini(sc);
 
-	softint_disestablish(sc-sc_softintr);
-
 	free(sc, M_DEVBUF);
 
 	return (0);
@@ -1340,19 +1346,16 @@ bridge_forward(void *v)
 	struct ether_header *eh;
 	int s;
 
+	KERNEL_LOCK(1, NULL);
 	mutex_enter(softnet_lock);
 	if ((sc-sc_if.if_flags  IFF_RUNNING) == 0) {
 		mutex_exit(softnet_lock);
+		KERNEL_UNLOCK_ONE(NULL);
 		return;
 	}
 
 	s = splnet();
-	while (1) {
-		IFQ_POLL(sc-sc_if.if_snd, m);
-		if (m == NULL)
-			break;
-		IFQ_DEQUEUE(sc-sc_if.if_snd, m);
-
+	while ((m = pktq_dequeue(sc-sc_fwd_pktq)) != NULL) {
 		src_if = m-m_pkthdr.rcvif;
 
 		sc-sc_if.if_ipackets++;
@@ -1466,6 +1469,7 @@ bridge_forward(void *v)
 	}
 	splx(s);
 	mutex_exit(softnet_lock);
+	KERNEL_UNLOCK_ONE(NULL);
 }
 
 /*
@@ -1515,17 +1519,15 @@ bridge_input(struct ifnet *ifp, struct m
 		 * for bridge processing; return the original packet for
 		 * local processing.
 		 */
-		if (IF_QFULL(sc-sc_if.if_snd)) {
-			IF_DROP(sc-sc_if.if_snd);
-			return (m);
-		}
 		mc = m_dup(m, 0, M_COPYALL, M_NOWAIT);
 		if (mc == NULL)
-			return (m);
+			return m;
 
 		/* Perform the bridge forwarding function with the copy. */
-		IF_ENQUEUE(sc-sc_if.if_snd, mc);
-		softint_schedule(sc-sc_softintr);
+		if (__predict_false(!pktq_enqueue(sc-sc_fwd_pktq, mc, 0))) {
+			m_freem(mc);
+			return m;
+		}
 
 		/* Return the original packet for local processing. */
 		return (m);
@@ -1573,13 +1575,8 @@ bridge_input(struct ifnet *ifp, struct m
 	}
 
 	/* Perform the bridge forwarding function. */
-	if (IF_QFULL(sc-sc_if.if_snd)) {
-		IF_DROP(sc-sc_if.if_snd);
+	if (__predict_false(!pktq_enqueue(sc-sc_fwd_pktq, m, 0)))
 		m_freem(m);
-		return (NULL);
-	}
-	IF_ENQUEUE(sc-sc_if.if_snd, m);
-	softint_schedule(sc-sc_softintr);
 
 	return (NULL);
 }

Index: src/sys/net/if_bridgevar.h
diff -u src/sys/net/if_bridgevar.h:1.15 src/sys/net/if_bridgevar.h:1.16
--- src/sys/net/if_bridgevar.h:1.15	Thu Aug 23 12:06:32 2012
+++ src/sys/net/if_bridgevar.h	Mon Jun 16 01:03:57 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bridgevar.h,v 1.15 2012/08/23 12:06:32 drochner Exp $	*/
+/*	$NetBSD: if_bridgevar.h,v 1.16 2014/06/16 01:03:57 ozaki-r Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -78,6 +78,8 @@
 #include sys/callout.h
 #include sys/queue.h
 

CVS commit: src/sys/net

2014-06-15 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Jun 16 01:05:25 UTC 2014

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

Log Message:
Add net.interfaces.bridgeN.fwdq.{maxlen,len,drops} sysctl


To generate a diff of this commit:
cvs rdiff -u -r1.79 -r1.80 src/sys/net/if_bridge.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_bridge.c
diff -u src/sys/net/if_bridge.c:1.79 src/sys/net/if_bridge.c:1.80
--- src/sys/net/if_bridge.c:1.79	Mon Jun 16 01:03:57 2014
+++ src/sys/net/if_bridge.c	Mon Jun 16 01:05:25 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bridge.c,v 1.79 2014/06/16 01:03:57 ozaki-r Exp $	*/
+/*	$NetBSD: if_bridge.c,v 1.80 2014/06/16 01:05:25 ozaki-r Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -80,7 +80,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: if_bridge.c,v 1.79 2014/06/16 01:03:57 ozaki-r Exp $);
+__KERNEL_RCSID(0, $NetBSD: if_bridge.c,v 1.80 2014/06/16 01:05:25 ozaki-r Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_bridge_ipf.h
@@ -254,6 +254,9 @@ static int	bridge_ip6_checkbasic(struct 
 # endif /* INET6 */
 #endif /* BRIDGE_IPF */
 
+static void bridge_sysctl_fwdq_setup(struct sysctllog **clog,
+struct bridge_softc *sc);
+
 struct bridge_control {
 	int	(*bc_func)(struct bridge_softc *, void *);
 	int	bc_argsize;
@@ -378,6 +381,8 @@ bridge_clone_create(struct if_clone *ifc
 	sc-sc_fwd_pktq = pktq_create(IFQ_MAXLEN, bridge_forward, sc);
 	KASSERT(sc-sc_fwd_pktq != NULL);
 
+	bridge_sysctl_fwdq_setup(ifp-if_sysctl_log, sc);
+
 	if_attach(ifp);
 
 	if_alloc_sadl(ifp);
@@ -432,6 +437,92 @@ bridge_clone_destroy(struct ifnet *ifp)
 	return (0);
 }
 
+static int
+bridge_sysctl_fwdq_maxlen(SYSCTLFN_ARGS)
+{
+	struct sysctlnode node = *rnode;
+	const struct bridge_softc *sc =	node.sysctl_data;
+	return sysctl_pktq_maxlen(SYSCTLFN_CALL(rnode), sc-sc_fwd_pktq);
+}
+
+#define	SYSCTL_BRIDGE_PKTQ(cn, c)	\
+	static int			\
+	bridge_sysctl_fwdq_##cn(SYSCTLFN_ARGS)\
+	{\
+		struct sysctlnode node = *rnode;			\
+		const struct bridge_softc *sc =	node.sysctl_data;	\
+		return sysctl_pktq_count(SYSCTLFN_CALL(rnode),		\
+	 sc-sc_fwd_pktq, c);		\
+	}
+
+SYSCTL_BRIDGE_PKTQ(items, PKTQ_NITEMS)
+SYSCTL_BRIDGE_PKTQ(drops, PKTQ_DROPS)
+
+static void
+bridge_sysctl_fwdq_setup(struct sysctllog **clog, struct bridge_softc *sc)
+{
+	const struct sysctlnode *cnode, *rnode;
+	sysctlfn len_func = NULL, maxlen_func = NULL, drops_func = NULL;
+	const char *ifname = sc-sc_if.if_xname;
+
+	len_func = bridge_sysctl_fwdq_items;
+	maxlen_func = bridge_sysctl_fwdq_maxlen;
+	drops_func = bridge_sysctl_fwdq_drops;
+
+	if (sysctl_createv(clog, 0, NULL, rnode,
+			   CTLFLAG_PERMANENT,
+			   CTLTYPE_NODE, interfaces,
+			   SYSCTL_DESCR(Per-interface controls),
+			   NULL, 0, NULL, 0,
+			   CTL_NET, CTL_CREATE, CTL_EOL) != 0)
+		goto bad;
+
+	if (sysctl_createv(clog, 0, rnode, rnode,
+			   CTLFLAG_PERMANENT,
+			   CTLTYPE_NODE, ifname,
+			   SYSCTL_DESCR(Interface controls),
+			   NULL, 0, NULL, 0,
+			   CTL_CREATE, CTL_EOL) != 0)
+		goto bad;
+
+	if (sysctl_createv(clog, 0, rnode, rnode,
+			   CTLFLAG_PERMANENT,
+			   CTLTYPE_NODE, fwdq,
+			   SYSCTL_DESCR(Protocol input queue controls),
+			   NULL, 0, NULL, 0,
+			   CTL_CREATE, CTL_EOL) != 0)
+		goto bad;
+
+	if (sysctl_createv(clog, 0, rnode, cnode,
+			   CTLFLAG_PERMANENT,
+			   CTLTYPE_INT, len,
+			   SYSCTL_DESCR(Current forwarding queue length),
+			   len_func, 0, (void *)sc, 0,
+			   CTL_CREATE, IFQCTL_LEN, CTL_EOL) != 0)
+		goto bad;
+
+	if (sysctl_createv(clog, 0, rnode, cnode,
+			   CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
+			   CTLTYPE_INT, maxlen,
+			   SYSCTL_DESCR(Maximum allowed forwarding queue length),
+			   maxlen_func, 0, (void *)sc, 0,
+			   CTL_CREATE, IFQCTL_MAXLEN, CTL_EOL) != 0)
+		goto bad;
+
+	if (sysctl_createv(clog, 0, rnode, cnode,
+			   CTLFLAG_PERMANENT,
+			   CTLTYPE_INT, drops,
+			   SYSCTL_DESCR(Packets dropped due to full forwarding queue),
+			   drops_func, 0, (void *)sc, 0,
+			   CTL_CREATE, IFQCTL_DROPS, CTL_EOL) != 0)
+		goto bad;
+
+	return;
+bad:
+	aprint_error(%s: could not attach sysctl nodes\n, ifname);
+	return;
+}
+
 /*
  * bridge_ioctl:
  *



CVS commit: src/sys/net

2014-06-15 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Jun 16 03:43:10 UTC 2014

Modified Files:
src/sys/net: if.h if_bridgevar.h

Log Message:
Include pktqueue.h only if _KERNEL


To generate a diff of this commit:
cvs rdiff -u -r1.166 -r1.167 src/sys/net/if.h
cvs rdiff -u -r1.16 -r1.17 src/sys/net/if_bridgevar.h

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

Modified files:

Index: src/sys/net/if.h
diff -u src/sys/net/if.h:1.166 src/sys/net/if.h:1.167
--- src/sys/net/if.h:1.166	Mon Jun 16 00:40:10 2014
+++ src/sys/net/if.h	Mon Jun 16 03:43:10 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.h,v 1.166 2014/06/16 00:40:10 ozaki-r Exp $	*/
+/*	$NetBSD: if.h,v 1.167 2014/06/16 03:43:10 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -82,7 +82,9 @@
 
 #include net/dlt.h
 #include net/pfil.h
+#ifdef _KERNEL
 #include net/pktqueue.h
+#endif
 
 /*
  * Always include ALTQ glue here -- we use the ALTQ interface queue

Index: src/sys/net/if_bridgevar.h
diff -u src/sys/net/if_bridgevar.h:1.16 src/sys/net/if_bridgevar.h:1.17
--- src/sys/net/if_bridgevar.h:1.16	Mon Jun 16 01:03:57 2014
+++ src/sys/net/if_bridgevar.h	Mon Jun 16 03:43:10 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bridgevar.h,v 1.16 2014/06/16 01:03:57 ozaki-r Exp $	*/
+/*	$NetBSD: if_bridgevar.h,v 1.17 2014/06/16 03:43:10 ozaki-r Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -78,8 +78,6 @@
 #include sys/callout.h
 #include sys/queue.h
 
-#include net/pktqueue.h
-
 /*
  * Commands used in the SIOCSDRVSPEC ioctl.  Note the lookup of the
  * bridge interface itself is keyed off the ifdrv structure.
@@ -207,6 +205,8 @@ struct ifbrparam {
 #define	ifbrp_filter	ifbrp_ifbrpu.ifbrpu_int32	/* filtering flags */
 
 #ifdef _KERNEL
+#include net/pktqueue.h
+
 /*
  * Timekeeping structure used in spanning tree code.
  */



CVS commit: src/sys/net

2014-06-17 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Tue Jun 17 10:39:46 UTC 2014

Modified Files:
src/sys/net: bridgestp.c if_bridge.c if_bridgevar.h if_ethersubr.c

Log Message:
Restructure ether_input and bridge_input

The network stack of NetBSD is well organized and
layered. A packet reception is processed from a
lower layer to an upper layer one by one. However,
ether_input and bridge_input are not structured so.
bridge_input is called inside ether_input.

The new structure replaces ifnet#if_input of a bridge
member with bridge_input when the member is attached.
So a packet goes straight on a packet reception via
a bridge, bridge_input = ether_input = ip_input.

The change is part of a patch of Lloyd Parkes submitted
in PR 48104. Unlike the patch, the change doesn't
intend to change the behavior of the packet processing.
Another patch will fix PR 48104.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/net/bridgestp.c
cvs rdiff -u -r1.80 -r1.81 src/sys/net/if_bridge.c
cvs rdiff -u -r1.17 -r1.18 src/sys/net/if_bridgevar.h
cvs rdiff -u -r1.200 -r1.201 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/net/bridgestp.c
diff -u src/sys/net/bridgestp.c:1.14 src/sys/net/bridgestp.c:1.15
--- src/sys/net/bridgestp.c:1.14	Sun Jan 18 10:28:55 2009
+++ src/sys/net/bridgestp.c	Tue Jun 17 10:39:46 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: bridgestp.c,v 1.14 2009/01/18 10:28:55 mrg Exp $	*/
+/*	$NetBSD: bridgestp.c,v 1.15 2014/06/17 10:39:46 ozaki-r Exp $	*/
 
 /*
  * Copyright (c) 2000 Jason L. Wright (ja...@thought.net)
@@ -40,7 +40,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: bridgestp.c,v 1.14 2009/01/18 10:28:55 mrg Exp $);
+__KERNEL_RCSID(0, $NetBSD: bridgestp.c,v 1.15 2014/06/17 10:39:46 ozaki-r Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -579,7 +579,7 @@ bstp_acknowledge_topology_change(struct 
 	bstp_transmit_config(sc, bif);
 }
 
-struct mbuf *
+void
 bstp_input(struct bridge_softc *sc, struct bridge_iflist *bif, struct mbuf *m)
 {
 	struct ether_header *eh;
@@ -592,7 +592,7 @@ bstp_input(struct bridge_softc *sc, stru
 	eh = mtod(m, struct ether_header *);
 
 	if ((bif-bif_flags  IFBIF_STP) == 0)
-		return (m);
+		goto out;
 
 	len = ntohs(eh-ether_type);
 	if (len  sizeof(tpdu))
@@ -664,7 +664,7 @@ bstp_input(struct bridge_softc *sc, stru
  out:
 	if (m)
 		m_freem(m);
-	return (NULL);
+	return;
 }
 
 void

Index: src/sys/net/if_bridge.c
diff -u src/sys/net/if_bridge.c:1.80 src/sys/net/if_bridge.c:1.81
--- src/sys/net/if_bridge.c:1.80	Mon Jun 16 01:05:25 2014
+++ src/sys/net/if_bridge.c	Tue Jun 17 10:39:46 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bridge.c,v 1.80 2014/06/16 01:05:25 ozaki-r Exp $	*/
+/*	$NetBSD: if_bridge.c,v 1.81 2014/06/17 10:39:46 ozaki-r Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -80,7 +80,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: if_bridge.c,v 1.80 2014/06/16 01:05:25 ozaki-r Exp $);
+__KERNEL_RCSID(0, $NetBSD: if_bridge.c,v 1.81 2014/06/17 10:39:46 ozaki-r Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_bridge_ipf.h
@@ -188,6 +188,7 @@ static int	bridge_init(struct ifnet *);
 static void	bridge_stop(struct ifnet *, int);
 static void	bridge_start(struct ifnet *);
 
+static void	bridge_input(struct ifnet *, struct mbuf *);
 static void	bridge_forward(void *);
 
 static void	bridge_timer(void *);
@@ -707,6 +708,7 @@ bridge_delete_member(struct bridge_softc
 		break;
 	}
 
+	ifs-if_input = ether_input;
 	ifs-if_bridge = NULL;
 	LIST_REMOVE(bif, bif_next);
 
@@ -739,6 +741,9 @@ bridge_ioctl_add(struct bridge_softc *sc
 	if (ifs-if_bridge != NULL)
 		return (EBUSY);
 
+	if (ifs-if_input != ether_input)
+		return EINVAL;
+
 	bif = malloc(sizeof(*bif), M_DEVBUF, M_NOWAIT);
 	if (bif == NULL)
 		return (ENOMEM);
@@ -764,6 +769,7 @@ bridge_ioctl_add(struct bridge_softc *sc
 
 	ifs-if_bridge = sc;
 	LIST_INSERT_HEAD(sc-sc_iflist, bif, bif_next);
+	ifs-if_input = bridge_input;
 
 	if (sc-sc_if.if_flags  IFF_RUNNING)
 		bstp_initialization(sc);
@@ -1570,7 +1576,7 @@ bridge_forward(void *v)
  *	bridging if it is not for us.
  *	should be called at splnet()
  */
-struct mbuf *
+static void
 bridge_input(struct ifnet *ifp, struct mbuf *m)
 {
 	struct bridge_softc *sc = ifp-if_bridge;
@@ -1578,30 +1584,42 @@ bridge_input(struct ifnet *ifp, struct m
 	struct ether_header *eh;
 	struct mbuf *mc;
 
-	if ((sc-sc_if.if_flags  IFF_RUNNING) == 0)
-		return (m);
+	if ((sc-sc_if.if_flags  IFF_RUNNING) == 0) {
+		ether_input(ifp, m);
+		return;
+	}
 
 	bif = bridge_lookup_member_if(sc, ifp);
-	if (bif == NULL)
-		return (m);
+	if (bif == NULL) {
+		ether_input(ifp, m);
+		return;
+	}
 
 	eh = mtod(m, struct ether_header *);
 
+	if (ETHER_IS_MULTICAST(eh-ether_dhost)) {
+		if (memcmp(etherbroadcastaddr,
+		eh-ether_dhost, ETHER_ADDR_LEN) == 0)
+			m-m_flags |= M_BCAST;
+		else
+			m-m_flags |= 

CVS commit: src/sys/net

2014-06-17 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Jun 18 01:19:19 UTC 2014

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

Log Message:
Make local functions static

This change unveiled some functions are unused. Remove some and
comment out the others.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/net/bridgestp.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/bridgestp.c
diff -u src/sys/net/bridgestp.c:1.15 src/sys/net/bridgestp.c:1.16
--- src/sys/net/bridgestp.c:1.15	Tue Jun 17 10:39:46 2014
+++ src/sys/net/bridgestp.c	Wed Jun 18 01:19:19 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: bridgestp.c,v 1.15 2014/06/17 10:39:46 ozaki-r Exp $	*/
+/*	$NetBSD: bridgestp.c,v 1.16 2014/06/18 01:19:19 ozaki-r Exp $	*/
 
 /*
  * Copyright (c) 2000 Jason L. Wright (ja...@thought.net)
@@ -40,7 +40,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: bridgestp.c,v 1.15 2014/06/17 10:39:46 ozaki-r Exp $);
+__KERNEL_RCSID(0, $NetBSD: bridgestp.c,v 1.16 2014/06/18 01:19:19 ozaki-r Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -115,64 +115,67 @@ struct bstp_tbpdu {
 
 const uint8_t bstp_etheraddr[] = { 0x01, 0x80, 0xc2, 0x00, 0x00, 0x00 };
 
-void	bstp_initialize_port(struct bridge_softc *, struct bridge_iflist *);
-void	bstp_ifupdstatus(struct bridge_softc *, struct bridge_iflist *);
-void	bstp_enable_port(struct bridge_softc *, struct bridge_iflist *);
-void	bstp_disable_port(struct bridge_softc *, struct bridge_iflist *);
-void	bstp_enable_change_detection(struct bridge_iflist *);
-void	bstp_disable_change_detection(struct bridge_iflist *);
-int	bstp_root_bridge(struct bridge_softc *sc);
-int	bstp_supersedes_port_info(struct bridge_softc *,
-	struct bridge_iflist *, struct bstp_config_unit *);
-int	bstp_designated_port(struct bridge_softc *, struct bridge_iflist *);
-int	bstp_designated_for_some_port(struct bridge_softc *);
-void	bstp_transmit_config(struct bridge_softc *, struct bridge_iflist *);
-void	bstp_transmit_tcn(struct bridge_softc *);
-void	bstp_received_config_bpdu(struct bridge_softc *,
-	struct bridge_iflist *, struct bstp_config_unit *);
-void	bstp_received_tcn_bpdu(struct bridge_softc *, struct bridge_iflist *,
-	struct bstp_tcn_unit *);
-void	bstp_record_config_information(struct bridge_softc *,
-	struct bridge_iflist *, struct bstp_config_unit *);
-void	bstp_record_config_timeout_values(struct bridge_softc *,
-	struct bstp_config_unit *);
-void	bstp_config_bpdu_generation(struct bridge_softc *);
-void	bstp_send_config_bpdu(struct bridge_softc *, struct bridge_iflist *,
-	struct bstp_config_unit *);
-void	bstp_configuration_update(struct bridge_softc *);
-void	bstp_root_selection(struct bridge_softc *);
-void	bstp_designated_port_selection(struct bridge_softc *);
-void	bstp_become_designated_port(struct bridge_softc *,
-	struct bridge_iflist *);
-void	bstp_port_state_selection(struct bridge_softc *);
-void	bstp_make_forwarding(struct bridge_softc *, struct bridge_iflist *);
-void	bstp_make_blocking(struct bridge_softc *, struct bridge_iflist *);
-void	bstp_set_port_state(struct bridge_iflist *, uint8_t);
-void	bstp_set_bridge_priority(struct bridge_softc *, uint64_t);
-void	bstp_set_port_priority(struct bridge_softc *, struct bridge_iflist *,
-	uint16_t);
-void	bstp_set_path_cost(struct bridge_softc *, struct bridge_iflist *,
-	uint32_t);
-void	bstp_topology_change_detection(struct bridge_softc *);
-void	bstp_topology_change_acknowledged(struct bridge_softc *);
-void	bstp_acknowledge_topology_change(struct bridge_softc *,
-	struct bridge_iflist *);
-
-void	bstp_tick(void *);
-void	bstp_timer_start(struct bridge_timer *, uint16_t);
-void	bstp_timer_stop(struct bridge_timer *);
-int	bstp_timer_expired(struct bridge_timer *, uint16_t);
-
-void	bstp_hold_timer_expiry(struct bridge_softc *, struct bridge_iflist *);
-void	bstp_message_age_timer_expiry(struct bridge_softc *,
-	struct bridge_iflist *);
-void	bstp_forward_delay_timer_expiry(struct bridge_softc *,
-	struct bridge_iflist *);
-void	bstp_topology_change_timer_expiry(struct bridge_softc *);
-void	bstp_tcn_timer_expiry(struct bridge_softc *);
-void	bstp_hello_timer_expiry(struct bridge_softc *);
+static void bstp_initialize_port(struct bridge_softc *, struct bridge_iflist *);
+static void bstp_ifupdstatus(struct bridge_softc *, struct bridge_iflist *);
+static void bstp_enable_port(struct bridge_softc *, struct bridge_iflist *);
+static void bstp_disable_port(struct bridge_softc *, struct bridge_iflist *);
+static int bstp_root_bridge(struct bridge_softc *sc);
+static int bstp_supersedes_port_info(struct bridge_softc *,
+ struct bridge_iflist *,
+ struct bstp_config_unit *);
+static int bstp_designated_port(struct bridge_softc *, struct bridge_iflist *);
+static int bstp_designated_for_some_port(struct bridge_softc 

CVS commit: src/sys/net

2014-06-18 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Jun 18 09:20:46 UTC 2014

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

Log Message:
Tidy up bridge_input

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.81 -r1.82 src/sys/net/if_bridge.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_bridge.c
diff -u src/sys/net/if_bridge.c:1.81 src/sys/net/if_bridge.c:1.82
--- src/sys/net/if_bridge.c:1.81	Tue Jun 17 10:39:46 2014
+++ src/sys/net/if_bridge.c	Wed Jun 18 09:20:46 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bridge.c,v 1.81 2014/06/17 10:39:46 ozaki-r Exp $	*/
+/*	$NetBSD: if_bridge.c,v 1.82 2014/06/18 09:20:46 ozaki-r Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -80,7 +80,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: if_bridge.c,v 1.81 2014/06/17 10:39:46 ozaki-r Exp $);
+__KERNEL_RCSID(0, $NetBSD: if_bridge.c,v 1.82 2014/06/18 09:20:46 ozaki-r Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_bridge_ipf.h
@@ -1569,6 +1569,36 @@ bridge_forward(void *v)
 	KERNEL_UNLOCK_ONE(NULL);
 }
 
+static bool
+bstp_state_before_learning(struct bridge_iflist *bif)
+{
+	if (bif-bif_flags  IFBIF_STP) {
+		switch (bif-bif_state) {
+		case BSTP_IFSTATE_BLOCKING:
+		case BSTP_IFSTATE_LISTENING:
+		case BSTP_IFSTATE_DISABLED:
+			return true;
+		}
+	}
+	return false;
+}
+
+static bool
+bridge_ourether(struct bridge_iflist *bif, struct ether_header *eh, int src)
+{
+	uint8_t *ether = src ? eh-ether_shost : eh-ether_dhost;
+
+	if (memcmp(CLLADDR(bif-bif_ifp-if_sadl), ether, ETHER_ADDR_LEN) == 0
+#if NCARP  0
+	|| (bif-bif_ifp-if_carp 
+	carp_ourether(bif-bif_ifp-if_carp, eh, IFT_ETHER, src) != NULL)
+#endif /* NCARP  0 */
+	)
+		return true;
+
+	return false;
+}
+
 /*
  * bridge_input:
  *
@@ -1614,10 +1644,7 @@ bridge_input(struct ifnet *ifp, struct m
 return;
 			}
 
-			switch (bif-bif_state) {
-			case BSTP_IFSTATE_BLOCKING:
-			case BSTP_IFSTATE_LISTENING:
-			case BSTP_IFSTATE_DISABLED:
+			if (bstp_state_before_learning(bif)) {
 ether_input(ifp, m);
 return;
 			}
@@ -1643,14 +1670,9 @@ bridge_input(struct ifnet *ifp, struct m
 		return;
 	}
 
-	if (bif-bif_flags  IFBIF_STP) {
-		switch (bif-bif_state) {
-		case BSTP_IFSTATE_BLOCKING:
-		case BSTP_IFSTATE_LISTENING:
-		case BSTP_IFSTATE_DISABLED:
-			ether_input(ifp, m);
-			return;
-		}
+	if (bstp_state_before_learning(bif)) {
+		ether_input(ifp, m);
+		return;
 	}
 
 	/*
@@ -1658,13 +1680,7 @@ bridge_input(struct ifnet *ifp, struct m
 	 */
 	LIST_FOREACH(bif, sc-sc_iflist, bif_next) {
 		/* It is destined for us. */
-		if (memcmp(CLLADDR(bif-bif_ifp-if_sadl), eh-ether_dhost,
-		ETHER_ADDR_LEN) == 0
-#if NCARP  0
-		|| (bif-bif_ifp-if_carp  carp_ourether(bif-bif_ifp-if_carp,
-			eh, IFT_ETHER, 0) != NULL)
-#endif /* NCARP  0 */
-		) {
+		if (bridge_ourether(bif, eh, 0)) {
 			if (bif-bif_flags  IFBIF_LEARNING)
 (void) bridge_rtupdate(sc,
 eh-ether_shost, ifp, 0, IFBAF_DYNAMIC);
@@ -1674,13 +1690,7 @@ bridge_input(struct ifnet *ifp, struct m
 		}
 
 		/* We just received a packet that we sent out. */
-		if (memcmp(CLLADDR(bif-bif_ifp-if_sadl), eh-ether_shost,
-		ETHER_ADDR_LEN) == 0
-#if NCARP  0
-		|| (bif-bif_ifp-if_carp  carp_ourether(bif-bif_ifp-if_carp,
-			eh, IFT_ETHER, 1) != NULL)
-#endif /* NCARP  0 */
-		) {
+		if (bridge_ourether(bif, eh, 1)) {
 			m_freem(m);
 			return;
 		}



CVS commit: src/sys/net

2014-06-18 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Jun 18 10:51:03 UTC 2014

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

Log Message:
Restructure bridge_input and bridge_broadcast

There are two changes:
- Assemble the places calling pktq_enqueue (bridge_forward)
  for unicast and {b,m}cast frames into one
- Receive {b,m}cast frames in bridge_broadcast, not in
  bridge_input

The changes make the code clear and readable. bridge_input
now doesn't need to take care of {b,m}cast frames;
bridge_forward and bridge_broadcast have the responsibility.

The changes are based on a patch of Lloyd Parkes submitted
in PR 48104, but don't fix its issue yet.


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.83 src/sys/net/if_bridge.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_bridge.c
diff -u src/sys/net/if_bridge.c:1.82 src/sys/net/if_bridge.c:1.83
--- src/sys/net/if_bridge.c:1.82	Wed Jun 18 09:20:46 2014
+++ src/sys/net/if_bridge.c	Wed Jun 18 10:51:03 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bridge.c,v 1.82 2014/06/18 09:20:46 ozaki-r Exp $	*/
+/*	$NetBSD: if_bridge.c,v 1.83 2014/06/18 10:51:03 ozaki-r Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -80,7 +80,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: if_bridge.c,v 1.82 2014/06/18 09:20:46 ozaki-r Exp $);
+__KERNEL_RCSID(0, $NetBSD: if_bridge.c,v 1.83 2014/06/18 10:51:03 ozaki-r Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_bridge_ipf.h
@@ -1612,7 +1612,6 @@ bridge_input(struct ifnet *ifp, struct m
 	struct bridge_softc *sc = ifp-if_bridge;
 	struct bridge_iflist *bif;
 	struct ether_header *eh;
-	struct mbuf *mc;
 
 	if ((sc-sc_if.if_flags  IFF_RUNNING) == 0) {
 		ether_input(ifp, m);
@@ -1635,68 +1634,50 @@ bridge_input(struct ifnet *ifp, struct m
 			m-m_flags |= M_MCAST;
 	}
 
-	if (m-m_flags  (M_BCAST|M_MCAST)) {
-		if (bif-bif_flags  IFBIF_STP) {
-			/* Tap off 802.1D packets; they do not get forwarded. */
-			if (memcmp(eh-ether_dhost, bstp_etheraddr,
-			ETHER_ADDR_LEN) == 0) {
-bstp_input(sc, bif, m);
+	/*
+	 * A 'fast' path for packets addressed to interfaces that are
+	 * part of this bridge.
+	 */
+	if (!(m-m_flags  (M_BCAST|M_MCAST)) 
+	!bstp_state_before_learning(bif)) {
+		struct bridge_iflist *_bif;
+
+		LIST_FOREACH(_bif, sc-sc_iflist, bif_next) {
+			/* It is destined for us. */
+			if (bridge_ourether(_bif, eh, 0)) {
+if (_bif-bif_flags  IFBIF_LEARNING)
+	(void) bridge_rtupdate(sc,
+	eh-ether_shost, ifp, 0, IFBAF_DYNAMIC);
+m-m_pkthdr.rcvif = _bif-bif_ifp;
+ether_input(_bif-bif_ifp, m);
 return;
 			}
 
-			if (bstp_state_before_learning(bif)) {
-ether_input(ifp, m);
+			/* We just received a packet that we sent out. */
+			if (bridge_ourether(_bif, eh, 1)) {
+m_freem(m);
 return;
 			}
 		}
-
-		/*
-		 * Make a deep copy of the packet and enqueue the copy
-		 * for bridge processing; return the original packet for
-		 * local processing.
-		 */
-		mc = m_dup(m, 0, M_COPYALL, M_NOWAIT);
-		if (mc == NULL) {
-			ether_input(ifp, m);
-			return;
-		}
-
-		/* Perform the bridge forwarding function with the copy. */
-		if (__predict_false(!pktq_enqueue(sc-sc_fwd_pktq, mc, 0)))
-			m_freem(mc);
-
-		/* For local processing. */
-		ether_input(ifp, m);
-		return;
 	}
 
-	if (bstp_state_before_learning(bif)) {
-		ether_input(ifp, m);
+	/* Tap off 802.1D packets; they do not get forwarded. */
+	if (bif-bif_flags  IFBIF_STP 
+	memcmp(eh-ether_dhost, bstp_etheraddr, ETHER_ADDR_LEN) == 0) {
+		bstp_input(sc, bif, m);
 		return;
 	}
 
 	/*
-	 * Unicast.  Make sure it's not for us.
+	 * A normal switch would discard the packet here, but that's not what
+	 * we've done historically. This also prevents some obnoxious behaviour.
 	 */
-	LIST_FOREACH(bif, sc-sc_iflist, bif_next) {
-		/* It is destined for us. */
-		if (bridge_ourether(bif, eh, 0)) {
-			if (bif-bif_flags  IFBIF_LEARNING)
-(void) bridge_rtupdate(sc,
-eh-ether_shost, ifp, 0, IFBAF_DYNAMIC);
-			m-m_pkthdr.rcvif = bif-bif_ifp;
-			ether_input(bif-bif_ifp, m);
-			return;
-		}
-
-		/* We just received a packet that we sent out. */
-		if (bridge_ourether(bif, eh, 1)) {
-			m_freem(m);
-			return;
-		}
+	if (bstp_state_before_learning(bif)) {
+		ether_input(ifp, m);
+		return;
 	}
 
-	/* Perform the bridge forwarding function. */
+	/* Queue the packet for bridge forwarding. */
 	if (__predict_false(!pktq_enqueue(sc-sc_fwd_pktq, m, 0)))
 		m_freem(m);
 }
@@ -1715,7 +1696,9 @@ bridge_broadcast(struct bridge_softc *sc
 	struct bridge_iflist *bif;
 	struct mbuf *mc;
 	struct ifnet *dst_if;
-	int used = 0;
+	bool used, bmcast;
+
+	used = bmcast = m-m_flags  (M_BCAST|M_MCAST);
 
 	LIST_FOREACH(bif, sc-sc_iflist, bif_next) {
 		dst_if = bif-bif_ifp;
@@ -1730,16 +1713,15 @@ bridge_broadcast(struct bridge_softc *sc
 			}
 		}
 
-		if ((bif-bif_flags  IFBIF_DISCOVER) == 0 
-		(m-m_flags 

CVS commit: src/sys/net

2014-06-20 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Fri Jun 20 14:22:48 UTC 2014

Modified Files:
src/sys/net: if_bridgevar.h

Log Message:
Remove unnecessary sc_softintr


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/net/if_bridgevar.h

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

Modified files:

Index: src/sys/net/if_bridgevar.h
diff -u src/sys/net/if_bridgevar.h:1.18 src/sys/net/if_bridgevar.h:1.19
--- src/sys/net/if_bridgevar.h:1.18	Tue Jun 17 10:39:46 2014
+++ src/sys/net/if_bridgevar.h	Fri Jun 20 14:22:48 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bridgevar.h,v 1.18 2014/06/17 10:39:46 ozaki-r Exp $	*/
+/*	$NetBSD: if_bridgevar.h,v 1.19 2014/06/20 14:22:48 ozaki-r Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -303,7 +303,6 @@ struct bridge_softc {
 	LIST_HEAD(, bridge_rtnode) sc_rtlist;	/* list version of above */
 	uint32_t		sc_rthash_key;	/* key for hash */
 	uint32_t		sc_filter_flags; /* ipf and flags */
-	void			*sc_softintr;
 	pktqueue_t *		sc_fwd_pktq;
 };
 



CVS commit: src/sys/net

2014-06-23 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Jun 23 06:27:58 UTC 2014

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

Log Message:
Get rid of unnecessary xc_broadcast after pktq_barrier

Pointed out by rmind@


To generate a diff of this commit:
cvs rdiff -u -r1.83 -r1.84 src/sys/net/if_bridge.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_bridge.c
diff -u src/sys/net/if_bridge.c:1.83 src/sys/net/if_bridge.c:1.84
--- src/sys/net/if_bridge.c:1.83	Wed Jun 18 10:51:03 2014
+++ src/sys/net/if_bridge.c	Mon Jun 23 06:27:58 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bridge.c,v 1.83 2014/06/18 10:51:03 ozaki-r Exp $	*/
+/*	$NetBSD: if_bridge.c,v 1.84 2014/06/23 06:27:58 ozaki-r Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -80,7 +80,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: if_bridge.c,v 1.83 2014/06/18 10:51:03 ozaki-r Exp $);
+__KERNEL_RCSID(0, $NetBSD: if_bridge.c,v 1.84 2014/06/23 06:27:58 ozaki-r Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_bridge_ipf.h
@@ -100,7 +100,6 @@ __KERNEL_RCSID(0, $NetBSD: if_bridge.c,
 #include sys/kauth.h
 #include sys/cpu.h
 #include sys/cprng.h
-#include sys/xcall.h
 
 #include net/bpf.h
 #include net/if.h
@@ -406,12 +405,9 @@ bridge_clone_destroy(struct ifnet *ifp)
 	struct bridge_softc *sc = ifp-if_softc;
 	struct bridge_iflist *bif;
 	int s;
-	uint64_t xc;
 
 	/* Must be called during IFF_RUNNING, i.e., before bridge_stop */
 	pktq_barrier(sc-sc_fwd_pktq);
-	xc = xc_broadcast(0, (xcfunc_t)nullop, NULL, NULL);
-	xc_wait(xc);
 
 	s = splnet();
 



CVS commit: src/doc

2014-06-29 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Jun 30 05:52:24 UTC 2014

Modified Files:
src/doc: CHANGES

Log Message:
Note micphy(4)


To generate a diff of this commit:
cvs rdiff -u -r1.1939 -r1.1940 src/doc/CHANGES

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

Modified files:

Index: src/doc/CHANGES
diff -u src/doc/CHANGES:1.1939 src/doc/CHANGES:1.1940
--- src/doc/CHANGES:1.1939	Sun Jun 22 23:53:16 2014
+++ src/doc/CHANGES	Mon Jun 30 05:52:24 2014
@@ -1,4 +1,4 @@
-# LIST OF CHANGES FROM LAST RELEASE:			$Revision: 1.1939 $
+# LIST OF CHANGES FROM LAST RELEASE:			$Revision: 1.1940 $
 #
 #
 # [Note: This file does not mention every change made to the NetBSD source tree.
@@ -376,6 +376,7 @@ Changes from NetBSD 6.0 to NetBSD 7.0:
 	dhcpcd(8): Import dhcpcd-6.3.0 [roy 20140225]
 	mcp48x1dac(4): Add preliminary support for Microchip MCP48x1 family of
 		Digital-to-Analog converters. [rkujawa 20140225]
+	micphy(4): Add Micrel PHY (KSZ9021RN) [ozaki-r 20140226]
 	bind: update to 9.10.0b1 [christos 20130228]
 	dhcpcd(8): Import dhcpcd-6.3.1 [roy 20140301]
 	x68k: Switch to X11FLAVOUR=Xorg, including X68k monolithic server.



CVS commit: src/sys/dev/pci

2014-06-30 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Jun 30 06:09:44 UTC 2014

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

Log Message:
Acquire SW semaphore in wm_get_swsm_semaphore

It is required to serialize device drivers running on different CPUs.
The basic instructions are same as the official Intel driver.

ok msaitoh@


To generate a diff of this commit:
cvs rdiff -u -r1.270 -r1.271 src/sys/dev/pci/if_wm.c

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

Modified files:

Index: src/sys/dev/pci/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.270 src/sys/dev/pci/if_wm.c:1.271
--- src/sys/dev/pci/if_wm.c:1.270	Mon Jun 16 16:48:16 2014
+++ src/sys/dev/pci/if_wm.c	Mon Jun 30 06:09:44 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.270 2014/06/16 16:48:16 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.271 2014/06/30 06:09:44 ozaki-r Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -76,7 +76,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: if_wm.c,v 1.270 2014/06/16 16:48:16 msaitoh Exp $);
+__KERNEL_RCSID(0, $NetBSD: if_wm.c,v 1.271 2014/06/30 06:09:44 ozaki-r Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -7569,6 +7569,23 @@ wm_get_swsm_semaphore(struct wm_softc *s
 	int32_t timeout;
 	uint32_t swsm;
 
+	/* Get the SW semaphore. */
+	timeout = 1000 + 1; /* XXX */
+	while (timeout) {
+		swsm = CSR_READ(sc, WMREG_SWSM);
+
+		if ((swsm  SWSM_SMBI) == 0)
+			break;
+
+		delay(50);
+		timeout--;
+	}
+
+	if (timeout == 0) {
+		aprint_error_dev(sc-sc_dev, could not acquire SWSM SMBI\n);
+		return 1;
+	}
+
 	/* Get the FW semaphore. */
 	timeout = 1000 + 1; /* XXX */
 	while (timeout) {
@@ -7585,7 +7602,7 @@ wm_get_swsm_semaphore(struct wm_softc *s
 	}
 
 	if (timeout == 0) {
-		aprint_error_dev(sc-sc_dev, could not acquire EEPROM GNT\n);
+		aprint_error_dev(sc-sc_dev, could not acquire SWSM SWESMBI\n);
 		/* Release semaphores */
 		wm_put_swsm_semaphore(sc);
 		return 1;
@@ -7599,7 +7616,7 @@ wm_put_swsm_semaphore(struct wm_softc *s
 	uint32_t swsm;
 
 	swsm = CSR_READ(sc, WMREG_SWSM);
-	swsm = ~(SWSM_SWESMBI);
+	swsm = ~(SWSM_SMBI | SWSM_SWESMBI);
 	CSR_WRITE(sc, WMREG_SWSM, swsm);
 }
 



CVS commit: src/sys/net

2014-06-30 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Jun 30 10:03:41 UTC 2014

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

Log Message:
Schedule pppoe_softintr only when a packet is enqueued


To generate a diff of this commit:
cvs rdiff -u -r1.201 -r1.202 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/net/if_ethersubr.c
diff -u src/sys/net/if_ethersubr.c:1.201 src/sys/net/if_ethersubr.c:1.202
--- src/sys/net/if_ethersubr.c:1.201	Tue Jun 17 10:39:46 2014
+++ src/sys/net/if_ethersubr.c	Mon Jun 30 10:03:41 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_ethersubr.c,v 1.201 2014/06/17 10:39:46 ozaki-r Exp $	*/
+/*	$NetBSD: if_ethersubr.c,v 1.202 2014/06/30 10:03:41 ozaki-r Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: if_ethersubr.c,v 1.201 2014/06/17 10:39:46 ozaki-r Exp $);
+__KERNEL_RCSID(0, $NetBSD: if_ethersubr.c,v 1.202 2014/06/30 10:03:41 ozaki-r Exp $);
 
 #include opt_inet.h
 #include opt_atalk.h
@@ -751,9 +751,10 @@ ether_input(struct ifnet *ifp, struct mb
 		if (IF_QFULL(inq)) {
 			IF_DROP(inq);
 			m_freem(m);
-		} else
+		} else {
 			IF_ENQUEUE(inq, m);
-		softint_schedule(pppoe_softintr);
+			softint_schedule(pppoe_softintr);
+		}
 		return;
 #endif /* NPPPOE  0 */
 	case ETHERTYPE_SLOWPROTOCOLS: {



CVS commit: src/sys/net

2014-06-30 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Jun 30 12:56:51 UTC 2014

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

Log Message:
Cleanup ppp_inproc

- Remove unnecessary variable isr
- Use pktq instead of rv to switch between inet/inet6 and other protocols

ok msaitoh@ and rmind@


To generate a diff of this commit:
cvs rdiff -u -r1.144 -r1.145 src/sys/net/if_ppp.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_ppp.c
diff -u src/sys/net/if_ppp.c:1.144 src/sys/net/if_ppp.c:1.145
--- src/sys/net/if_ppp.c:1.144	Thu Jun  5 23:48:16 2014
+++ src/sys/net/if_ppp.c	Mon Jun 30 12:56:51 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_ppp.c,v 1.144 2014/06/05 23:48:16 rmind Exp $	*/
+/*	$NetBSD: if_ppp.c,v 1.145 2014/06/30 12:56:51 ozaki-r Exp $	*/
 /*	Id: if_ppp.c,v 1.6 1997/03/04 03:33:00 paulus Exp 	*/
 
 /*
@@ -102,7 +102,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: if_ppp.c,v 1.144 2014/06/05 23:48:16 rmind Exp $);
+__KERNEL_RCSID(0, $NetBSD: if_ppp.c,v 1.145 2014/06/30 12:56:51 ozaki-r Exp $);
 
 #include ppp.h
 
@@ -1396,7 +1396,6 @@ ppp_inproc(struct ppp_softc *sc, struct 
 int s, ilen, proto, rv;
 u_char *cp, adrs, ctrl;
 struct mbuf *mp, *dmp = NULL;
-int isr = 0;
 #ifdef VJC
 int xlen;
 u_char *iphdr;
@@ -1607,7 +1606,6 @@ ppp_inproc(struct ppp_softc *sc, struct 
 /* See if bpf wants to look at the packet. */
 bpf_mtap(sc-sc_if, m);
 
-rv = 0;
 switch (proto) {
 #ifdef INET
 case PPP_IP:
@@ -1658,7 +1656,7 @@ ppp_inproc(struct ppp_softc *sc, struct 
 	 * Some other protocol - place on input queue for read().
 	 */
 	inq = sc-sc_inq;
-	rv = 1;
+	pktq = NULL;
 	break;
 }
 
@@ -1667,6 +1665,7 @@ ppp_inproc(struct ppp_softc *sc, struct 
  */
 s = splnet();
 
+/* pktq: inet or inet6 cases */
 if (__predict_true(pktq)) {
 	if (__predict_false(!pktq_enqueue(pktq, m, 0))) {
 	ifp-if_iqdrops++;
@@ -1675,11 +1674,10 @@ ppp_inproc(struct ppp_softc *sc, struct 
 	ifp-if_ipackets++;
 	ifp-if_ibytes += ilen;
 	splx(s);
-	if (rv)
-	(*sc-sc_ctlp)(sc);
 	return;
 }
 
+/* ifq: other protocol cases */
 if (!inq) {
 	goto bad;
 }
@@ -1692,15 +1690,11 @@ ppp_inproc(struct ppp_softc *sc, struct 
 	goto bad;
 }
 IF_ENQUEUE(inq, m);
-if (__predict_true(isr)) {
-schednetisr(isr);
-}
 splx(s);
 ifp-if_ipackets++;
 ifp-if_ibytes += ilen;
 
-if (rv)
-	(*sc-sc_ctlp)(sc);
+(*sc-sc_ctlp)(sc);
 
 return;
 



CVS commit: src/sys/netinet6

2014-07-01 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Tue Jul  1 07:51:29 UTC 2014

Modified Files:
src/sys/netinet6: in6.c nd6_nbr.c

Log Message:
Stop using callout randomly

nd6_dad_start uses callout when xtick  0 while doesn't when
xtick == 0. So if we pass a random value ranging from 0 to N,
nd6_dad_start uses callout randomly. This behavior makes
debugging difficult.

Discussed in http://mail-index.netbsd.org/tech-kern/2014/06/25/msg017278.html


To generate a diff of this commit:
cvs rdiff -u -r1.172 -r1.173 src/sys/netinet6/in6.c
cvs rdiff -u -r1.99 -r1.100 src/sys/netinet6/nd6_nbr.c

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

Modified files:

Index: src/sys/netinet6/in6.c
diff -u src/sys/netinet6/in6.c:1.172 src/sys/netinet6/in6.c:1.173
--- src/sys/netinet6/in6.c:1.172	Tue Jul  1 05:49:19 2014
+++ src/sys/netinet6/in6.c	Tue Jul  1 07:51:29 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: in6.c,v 1.172 2014/07/01 05:49:19 rtr Exp $	*/
+/*	$NetBSD: in6.c,v 1.173 2014/07/01 07:51:29 ozaki-r Exp $	*/
 /*	$KAME: in6.c,v 1.198 2001/07/18 09:12:38 itojun Exp $	*/
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: in6.c,v 1.172 2014/07/01 05:49:19 rtr Exp $);
+__KERNEL_RCSID(0, $NetBSD: in6.c,v 1.173 2014/07/01 07:51:29 ozaki-r Exp $);
 
 #include opt_inet.h
 #include opt_compat_netbsd.h
@@ -1331,7 +1331,8 @@ in6_update_ifa1(struct ifnet *ifp, struc
 mindelay;
 			}
 		}
-		nd6_dad_start(ia-ia_ifa, dad_delay);
+		/* +1 ensures callout is always used */
+		nd6_dad_start(ia-ia_ifa, dad_delay + 1);
 	}
 
 	return error;
@@ -2155,15 +2156,17 @@ in6_if_link_up(struct ifnet *ifp)
 		}
 
 		if (ia-ia6_flags  IN6_IFF_TENTATIVE) {
+			int delay;
 			/*
 			 * The TENTATIVE flag was likely set by hand
 			 * beforehand, implicitly indicating the need for DAD.
 			 * We may be able to skip the random delay in this
 			 * case, but we impose delays just in case.
 			 */
-			nd6_dad_start(ifa,
-			cprng_fast32() %
-(MAX_RTR_SOLICITATION_DELAY * hz));
+			delay = cprng_fast32() %
+			(MAX_RTR_SOLICITATION_DELAY * hz);
+			/* +1 ensures callout is always used */
+			nd6_dad_start(ifa, delay + 1);
 		}
 	}
 

Index: src/sys/netinet6/nd6_nbr.c
diff -u src/sys/netinet6/nd6_nbr.c:1.99 src/sys/netinet6/nd6_nbr.c:1.100
--- src/sys/netinet6/nd6_nbr.c:1.99	Mon Jan 13 18:23:36 2014
+++ src/sys/netinet6/nd6_nbr.c	Tue Jul  1 07:51:29 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: nd6_nbr.c,v 1.99 2014/01/13 18:23:36 roy Exp $	*/
+/*	$NetBSD: nd6_nbr.c,v 1.100 2014/07/01 07:51:29 ozaki-r Exp $	*/
 /*	$KAME: nd6_nbr.c,v 1.61 2001/02/10 16:06:14 jinmei Exp $	*/
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nd6_nbr.c,v 1.99 2014/01/13 18:23:36 roy Exp $);
+__KERNEL_RCSID(0, $NetBSD: nd6_nbr.c,v 1.100 2014/07/01 07:51:29 ozaki-r Exp $);
 
 #include opt_inet.h
 #include opt_ipsec.h
@@ -1097,6 +1097,8 @@ nd6_newaddrmsg(struct ifaddr *ifa)
 /*
  * Start Duplicate Address Detection (DAD) for specified interface address.
  *
+ * Note that callout is used when xtick  0 and not when xtick == 0.
+ *
  * xtick: minimum delay ticks for IFF_UP event
  */
 void



CVS commit: src/sys

2014-07-01 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Tue Jul  1 10:16:02 UTC 2014

Modified Files:
src/sys/altq: if_altq.h
src/sys/net: if.c if.h

Log Message:
Lock IFQ operations when NET_MPSAFE

- Introduce NET_MPSAFE
  - not defined by default
- Add ifq_lock to protect ifnet#if_snd
- Initialize ifq_lock and lock IFQ operations
  when NET_MPSAFE

When NET_MPSAFE isn't defined, this modification
doesn't change its behavior and adds trivial
performance overheads.

Discussed with matt@ on tech-net


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/altq/if_altq.h
cvs rdiff -u -r1.284 -r1.285 src/sys/net/if.c
cvs rdiff -u -r1.168 -r1.169 src/sys/net/if.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/altq/if_altq.h
diff -u src/sys/altq/if_altq.h:1.13 src/sys/altq/if_altq.h:1.14
--- src/sys/altq/if_altq.h:1.13	Tue Aug 18 17:20:20 2009
+++ src/sys/altq/if_altq.h	Tue Jul  1 10:16:02 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_altq.h,v 1.13 2009/08/18 17:20:20 dyoung Exp $	*/
+/*	$NetBSD: if_altq.h,v 1.14 2014/07/01 10:16:02 ozaki-r Exp $	*/
 /*	$KAME: if_altq.h,v 1.12 2005/04/13 03:44:25 suz Exp $	*/
 
 /*
@@ -45,6 +45,7 @@ struct	ifaltq {
 	int	ifq_len;
 	int	ifq_maxlen;
 	int	ifq_drops;
+	kmutex_t	*ifq_lock;
 
 	/* alternate queueing related fields */
 	int	altq_type;		/* discipline type */

Index: src/sys/net/if.c
diff -u src/sys/net/if.c:1.284 src/sys/net/if.c:1.285
--- src/sys/net/if.c:1.284	Tue Jul  1 05:49:18 2014
+++ src/sys/net/if.c	Tue Jul  1 10:16:02 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.c,v 1.284 2014/07/01 05:49:18 rtr Exp $	*/
+/*	$NetBSD: if.c,v 1.285 2014/07/01 10:16:02 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: if.c,v 1.284 2014/07/01 05:49:18 rtr Exp $);
+__KERNEL_RCSID(0, $NetBSD: if.c,v 1.285 2014/07/01 10:16:02 ozaki-r Exp $);
 
 #include opt_inet.h
 
@@ -611,6 +611,12 @@ if_attach(ifnet_t *ifp)
 	ifp-if_snd.altq_ifp  = ifp;
 #endif
 
+#ifdef NET_MPSAFE
+	ifp-if_snd.ifq_lock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_NET);
+#else
+	ifp-if_snd.ifq_lock = NULL;
+#endif
+
 	ifp-if_pfil = pfil_head_create(PFIL_TYPE_IFNET, ifp);
 	(void)pfil_run_hooks(if_pfil,
 	(struct mbuf **)PFIL_IFNET_ATTACH, ifp, PFIL_IFNET);
@@ -732,6 +738,9 @@ if_detach(struct ifnet *ifp)
 		altq_detach(ifp-if_snd);
 #endif
 
+	if (ifp-if_snd.ifq_lock)
+		mutex_obj_free(ifp-if_snd.ifq_lock);
+
 	sysctl_teardown(ifp-if_sysctl_log);
 
 #if NCARP  0

Index: src/sys/net/if.h
diff -u src/sys/net/if.h:1.168 src/sys/net/if.h:1.169
--- src/sys/net/if.h:1.168	Tue Jul  1 05:49:18 2014
+++ src/sys/net/if.h	Tue Jul  1 10:16:02 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.h,v 1.168 2014/07/01 05:49:18 rtr Exp $	*/
+/*	$NetBSD: if.h,v 1.169 2014/07/01 10:16:02 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -86,6 +86,8 @@
 #include net/pktqueue.h
 #endif
 
+//#define NET_MPSAFE 1
+
 /*
  * Always include ALTQ glue here -- we use the ALTQ interface queue
  * structure even when ALTQ is not configured into the kernel so that
@@ -198,11 +200,12 @@ struct if_data {
  * Structure defining a queue for a network interface.
  */
 struct ifqueue {
-	struct	mbuf *ifq_head;
-	struct	mbuf *ifq_tail;
-	int	ifq_len;
-	int	ifq_maxlen;
-	int	ifq_drops;
+	struct		mbuf *ifq_head;
+	struct		mbuf *ifq_tail;
+	int		ifq_len;
+	int		ifq_maxlen;
+	int		ifq_drops;
+	kmutex_t	*ifq_lock;
 };
 
 struct ifnet_lock;
@@ -424,6 +427,9 @@ typedef struct ifnet {
 	\23TSO6		\
 	\24LRO		\
 
+#define IFQ_LOCK(_ifq)		if ((_ifq)-ifq_lock) mutex_enter((_ifq)-ifq_lock)
+#define IFQ_UNLOCK(_ifq)	if ((_ifq)-ifq_lock) mutex_exit((_ifq)-ifq_lock)
+
 /*
  * Output queues (ifp-if_snd) and internetwork datagram level (pup level 1)
  * input routines have queues of messages stored on ifqueue structures
@@ -752,6 +758,7 @@ do {	\
 
 #define IFQ_ENQUEUE(ifq, m, pattr, err)	\
 do {	\
+	IFQ_LOCK((ifq));		\
 	if (ALTQ_IS_ENABLED((ifq)))	\
 		ALTQ_ENQUEUE((ifq), (m), (pattr), (err));		\
 	else {\
@@ -765,34 +772,41 @@ do {	\
 	}\
 	if ((err))			\
 		(ifq)-ifq_drops++;	\
+	IFQ_UNLOCK((ifq));		\
 } while (/*CONSTCOND*/ 0)
 
 #define IFQ_DEQUEUE(ifq, m)		\
 do {	\
+	IFQ_LOCK((ifq));		\
 	if (TBR_IS_ENABLED((ifq)))	\
 		(m) = tbr_dequeue((ifq), ALTDQ_REMOVE);			\
 	else if (ALTQ_IS_ENABLED((ifq)))\
 		ALTQ_DEQUEUE((ifq), (m));\
 	else\
 		IF_DEQUEUE((ifq), (m));	\
+	IFQ_UNLOCK((ifq));		\
 } while (/*CONSTCOND*/ 0)
 
 #define	IFQ_POLL(ifq, m)		\
 do {	\
+	IFQ_LOCK((ifq));		\
 	if (TBR_IS_ENABLED((ifq)))	\
 		(m) = tbr_dequeue((ifq), ALTDQ_POLL);			\
 	else if (ALTQ_IS_ENABLED((ifq)))\
 		ALTQ_POLL((ifq), (m));	\
 	else\
 		IF_POLL((ifq), (m));	\
+	

CVS commit: src/sys/dev/pci

2014-07-01 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Tue Jul  1 10:35:18 UTC 2014

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

Log Message:
Make if_wm MPSAFE

- Make it MPSAFE only when NET_MPSAFE
  - otherwise, its instructions are almost same as before
  - the only change is IFQ_POLL/IFQ_DEQUEUE which
is now single IFQ_DEQUEUE
- Protect driver operations with a lock
  - further work would make it separate
- Apply MPSAFE flag to
  - callout_init
  - pci_intr_establish
- Stop proceeding packets when the driver is likely
  to stop for graceful ifconfig down

Tested on Rangeley (I354) and KVM (e1000)
Reviewed by msaitoh@


To generate a diff of this commit:
cvs rdiff -u -r1.271 -r1.272 src/sys/dev/pci/if_wm.c

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

Modified files:

Index: src/sys/dev/pci/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.271 src/sys/dev/pci/if_wm.c:1.272
--- src/sys/dev/pci/if_wm.c:1.271	Mon Jun 30 06:09:44 2014
+++ src/sys/dev/pci/if_wm.c	Tue Jul  1 10:35:18 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.271 2014/06/30 06:09:44 ozaki-r Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.272 2014/07/01 10:35:18 ozaki-r Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -76,7 +76,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: if_wm.c,v 1.271 2014/06/30 06:09:44 ozaki-r Exp $);
+__KERNEL_RCSID(0, $NetBSD: if_wm.c,v 1.272 2014/07/01 10:35:18 ozaki-r Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -141,6 +141,10 @@ int	wm_debug = WM_DEBUG_TX | WM_DEBUG_RX
 #define	DPRINTF(x, y)	/* nothing */
 #endif /* WM_DEBUG */
 
+#ifdef NET_MPSAFE
+#define WM_MPSAFE	1
+#endif
+
 /*
  * Transmit descriptor list size.  Due to errata, we can only have
  * 256 hardware descriptors in the ring on  82544, but we use 4096
@@ -275,6 +279,7 @@ struct wm_softc {
 
 	void *sc_ih;			/* interrupt cookie */
 	callout_t sc_tick_ch;		/* tick callout */
+	bool sc_stopping;
 
 	int sc_ee_addrbits;		/* EEPROM address bits */
 	int sc_ich8_flash_base;
@@ -380,8 +385,21 @@ struct wm_softc {
 	int sc_mchash_type;		/* multicast filter offset */
 
 	krndsource_t rnd_source;	/* random source */
+
+	kmutex_t *sc_txrx_lock;		/* lock for tx/rx operations */
+	/* XXX need separation? */
 };
 
+#define WM_LOCK(_sc)	if ((_sc)-sc_txrx_lock) mutex_enter((_sc)-sc_txrx_lock)
+#define WM_UNLOCK(_sc)	if ((_sc)-sc_txrx_lock) mutex_exit((_sc)-sc_txrx_lock)
+#define WM_LOCKED(_sc)	(!(_sc)-sc_txrx_lock || mutex_owned((_sc)-sc_txrx_lock))
+
+#ifdef WM_MPSAFE
+#define CALLOUT_FLAGS	CALLOUT_MPSAFE
+#else
+#define CALLOUT_FLAGS	0
+#endif
+
 #define	WM_RXCHAIN_RESET(sc)		\
 do {	\
 	(sc)-sc_rxtailp = (sc)-sc_rxhead;\
@@ -495,12 +513,16 @@ do {	\
 } while (/*CONSTCOND*/0)
 
 static void	wm_start(struct ifnet *);
+static void	wm_start_locked(struct ifnet *);
 static void	wm_nq_start(struct ifnet *);
+static void	wm_nq_start_locked(struct ifnet *);
 static void	wm_watchdog(struct ifnet *);
 static int	wm_ifflags_cb(struct ethercom *);
 static int	wm_ioctl(struct ifnet *, u_long, void *);
 static int	wm_init(struct ifnet *);
+static int	wm_init_locked(struct ifnet *);
 static void	wm_stop(struct ifnet *, int);
+static void	wm_stop_locked(struct ifnet *, int);
 static bool	wm_suspend(device_t, const pmf_qual_t *);
 static bool	wm_resume(device_t, const pmf_qual_t *);
 
@@ -1184,7 +1206,8 @@ wm_attach(device_t parent, device_t self
 	char intrbuf[PCI_INTRSTR_LEN];
 
 	sc-sc_dev = self;
-	callout_init(sc-sc_tick_ch, 0);
+	callout_init(sc-sc_tick_ch, CALLOUT_FLAGS);
+	sc-sc_stopping = false;
 
 	sc-sc_wmp = wmp = wm_lookup(pa);
 	if (wmp == NULL) {
@@ -1315,6 +1338,9 @@ wm_attach(device_t parent, device_t self
 		return;
 	}
 	intrstr = pci_intr_string(pc, ih, intrbuf, sizeof(intrbuf));
+#ifdef WM_MPSAFE
+	pci_intr_setattr(pc, ih, PCI_INTR_MPSAFE, true);
+#endif
 	sc-sc_ih = pci_intr_establish(pc, ih, IPL_NET, wm_intr, sc);
 	if (sc-sc_ih == NULL) {
 		aprint_error_dev(sc-sc_dev, unable to establish interrupt);
@@ -1354,7 +1380,7 @@ wm_attach(device_t parent, device_t self
 		aprint_verbose_dev(sc-sc_dev,
 		Communication Streaming Architecture\n);
 		if (sc-sc_type == WM_T_82547) {
-			callout_init(sc-sc_txfifo_ch, 0);
+			callout_init(sc-sc_txfifo_ch, CALLOUT_FLAGS);
 			callout_setfunc(sc-sc_txfifo_ch,
 	wm_82547_txfifo_stall, sc);
 			aprint_verbose_dev(sc-sc_dev,
@@ -2051,6 +2077,12 @@ wm_attach(device_t parent, device_t self
 		ifp-if_capabilities |= IFCAP_TSOv6;
 	}
 
+#ifdef WM_MPSAFE
+	sc-sc_txrx_lock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_NET);
+#else
+	sc-sc_txrx_lock = NULL;
+#endif
+
 	/*
 	 * Attach the interface.
 	 */
@@ -2159,18 +2191,26 @@ wm_detach(device_t self, int flags __unu
 {
 	struct wm_softc *sc = device_private(self);
 	struct ifnet *ifp = sc-sc_ethercom.ec_if;
-	int i, s;
+	int i;
+#ifndef WM_MPSAFE
+	int s;
 
 	s = splnet();
+#endif
 	/* Stop the interface. Callouts are stopped in it. 

  1   2   3   4   5   6   7   8   9   10   >