[Zrouter-src-freebsd] ZRouter.org: push to FreeBSD HEAD tree

zrouter-src-freebsd at zrouter.org zrouter-src-freebsd at zrouter.org
Wed Feb 1 10:57:06 UTC 2012


details:   http://zrouter.org/hg/FreeBSD/head//rev/cd6b4b1a93f5
changeset: 327:cd6b4b1a93f5
user:      ray at terran.dlink.ua
date:      Wed Feb 01 12:34:54 2012 +0200
description:
FreeBSD HEAD @svn r230860.

diffstat:

 head/MAINTAINERS                                                         |     3 +-
 head/Makefile.inc1                                                       |     9 +-
 head/bin/ps/print.c                                                      |   128 +-
 head/contrib/libarchive/libarchive/archive_read_support_format_iso9660.c |    15 +-
 head/contrib/llvm/lib/Target/X86/X86InstrCompiler.td                     |     2 +-
 head/etc/devd/apple.conf                                                 |     4 +-
 head/etc/netstart                                                        |     3 +-
 head/etc/network.subr                                                    |    26 +-
 head/etc/rc.d/dhclient                                                   |     6 +-
 head/etc/rc.d/jail                                                       |     7 +-
 head/etc/rc.d/netif                                                      |    14 +-
 head/etc/rc.subr                                                         |     4 +-
 head/games/pom/pom.c                                                     |     7 +-
 head/gnu/usr.bin/gdb/kgdb/trgt_amd64.c                                   |     4 +-
 head/include/complex.h                                                   |     5 +-
 head/include/stdatomic.h                                                 |     9 +-
 head/release/doc/share/misc/man2hwnotes.pl                               |     7 +-
 head/release/rc.local                                                    |    13 +-
 head/sbin/camcontrol/Makefile                                            |     6 +-
 head/sbin/camcontrol/camcontrol.c                                        |     5 +-
 head/sbin/growfs/growfs.c                                                |     6 +-
 head/sbin/hastd/hast.conf.5                                              |    12 +-
 head/sbin/hastd/hastd.c                                                  |    12 +-
 head/sbin/hastd/parse.y                                                  |     7 +-
 head/sbin/hastd/token.l                                                  |     3 +-
 head/sbin/mdconfig/mdconfig.c                                            |   282 +-
 head/sbin/mount/getmntopts.c                                             |    17 +-
 head/sbin/mount/mntopts.h                                                |     4 +-
 head/sbin/mount/mount.c                                                  |     7 +-
 head/sbin/mount/mount_fs.c                                               |    21 +-
 head/sbin/mount_cd9660/mount_cd9660.c                                    |     5 +-
 head/sbin/mount_ext2fs/mount_ext2fs.c                                    |     5 +-
 head/sbin/mount_msdosfs/mount_msdosfs.c                                  |     5 +-
 head/sbin/mount_nfs/mount_nfs.8                                          |     6 +-
 head/sbin/mount_nfs/mount_nfs.c                                          |     5 +-
 head/sbin/mount_ntfs/mount_ntfs.c                                        |     7 +-
 head/sbin/mount_nullfs/mount_nullfs.c                                    |     8 +-
 head/sbin/mount_reiserfs/mount_reiserfs.c                                |     5 +-
 head/sbin/mount_std/mount_std.c                                          |     5 +-
 head/sbin/mount_udf/mount_udf.c                                          |     5 +-
 head/sbin/mount_unionfs/mount_unionfs.c                                  |     8 +-
 head/sbin/reboot/nextboot.8                                              |    15 +-
 head/sbin/reboot/nextboot.sh                                             |    43 +-
 head/share/examples/etc/make.conf                                        |    14 +-
 head/sys/arm/arm/machdep.c                                               |     4 +-
 head/sys/arm/include/_types.h                                            |     4 +-
 head/sys/arm/include/float.h                                             |    24 +-
 head/sys/boot/forth/menu.rc                                              |    38 +-
 head/sys/boot/i386/libi386/pxe.c                                         |     4 +-
 head/sys/boot/powerpc/boot1.chrp/Makefile                                |     3 +-
 head/sys/conf/files                                                      |    10 +-
 head/sys/conf/files.amd64                                                |   112 +-
 head/sys/conf/files.i386                                                 |   111 +-
 head/sys/conf/kern.pre.mk                                                |     2 +-
 head/sys/conf/kmod.mk                                                    |     3 +-
 head/sys/conf/ldscript.powerpc64                                         |    18 +-
 head/sys/conf/options.amd64                                              |     5 +-
 head/sys/conf/options.i386                                               |     5 +-
 head/sys/contrib/octeon-sdk/cvmx-app-init.h                              |     2 +
 head/sys/contrib/octeon-sdk/cvmx-helper-board.c                          |    25 +-
 head/sys/contrib/octeon-sdk/cvmx-helper-rgmii.c                          |     2 +
 head/sys/contrib/octeon-sdk/cvmx-helper.c                                |     1 +
 head/sys/contrib/octeon-sdk/cvmx-rtc.h                                   |     3 +
 head/sys/contrib/pf/net/if_pfsync.c                                      |    38 +-
 head/sys/dev/ata/chipsets/ata-acerlabs.c                                 |     6 +-
 head/sys/dev/ata/chipsets/ata-siliconimage.c                             |     6 +-
 head/sys/dev/ath/ath_dfs/null/dfs_null.c                                 |    15 +-
 head/sys/dev/ath/ath_hal/ar5210/ar5210_attach.c                          |     8 +-
 head/sys/dev/ath/ath_hal/ar5211/ar5211_attach.c                          |     8 +-
 head/sys/dev/ath/ath_hal/ar5212/ar5212.h                                 |     3 +-
 head/sys/dev/ath/ath_hal/ar5212/ar5212_attach.c                          |     9 +-
 head/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c                            |    12 +-
 head/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c                          |    11 +-
 head/sys/dev/ath/ath_hal/ar9002/ar9280_attach.c                          |     6 +-
 head/sys/dev/ath/if_ath.c                                                |    34 +-
 head/sys/dev/ath/if_athdfs.h                                             |     4 +-
 head/sys/dev/ath/if_athvar.h                                             |    47 +-
 head/sys/dev/bge/if_bge.c                                                |    11 +-
 head/sys/dev/bge/if_bgereg.h                                             |     3 +-
 head/sys/dev/ciss/ciss.c                                                 |    12 +-
 head/sys/dev/e1000/README                                                |     3 +-
 head/sys/dev/fe/if_fe.c                                                  |     7 +-
 head/sys/dev/firewire/sbp_targ.c                                         |   395 +-
 head/sys/dev/fxp/if_fxp.c                                                |     4 +-
 head/sys/dev/hwpmc/hwpmc_x86.c                                           |     4 +-
 head/sys/dev/ie/if_ie.c                                                  |     5 +-
 head/sys/dev/iwn/if_iwn.c                                                |    14 +-
 head/sys/dev/netmap/ixgbe_netmap.h                                       |    57 +-
 head/sys/dev/netmap/netmap.c                                             |    10 +-
 head/sys/dev/netmap/netmap_kern.h                                        |     9 +-
 head/sys/dev/ofw/openfirm.c                                              |    24 +-
 head/sys/dev/pccbb/pccbb.c                                               |     9 +-
 head/sys/dev/pci/pci.c                                                   |     6 +-
 head/sys/dev/pci/pcireg.h                                                |     3 +-
 head/sys/dev/random/harvest.c                                            |    10 +-
 head/sys/dev/random/nehemiah.c                                           |    11 +-
 head/sys/dev/re/if_re.c                                                  |    22 +-
 head/sys/dev/uart/uart_bus_pci.c                                         |     3 +-
 head/sys/dev/usb/usb_transfer.c                                          |     3 +-
 head/sys/dev/wi/if_wi.c                                                  |     4 +-
 head/sys/dev/xen/blkback/blkback.c                                       |     6 +-
 head/sys/dev/xen/netback/netback.c                                       |  3902 ++++++---
 head/sys/dev/xen/netback/netback_unit_tests.c                            |  2530 ++++++
 head/sys/gnu/dev/sound/pci/maestro3_dsp.h                                |   214 -
 head/sys/gnu/dev/sound/pci/maestro3_reg.h                                |   692 -
 head/sys/gnu/fs/reiserfs/reiserfs_vfsops.c                               |     4 +-
 head/sys/ia64/include/float.h                                            |    25 +-
 head/sys/kern/imgact_elf.c                                               |    63 +-
 head/sys/kern/init_main.c                                                |     5 +-
 head/sys/kern/kern_exec.c                                                |    15 +-
 head/sys/kern/kern_intr.c                                                |     4 +-
 head/sys/kern/kern_jail.c                                                |    16 +-
 head/sys/kern/kern_proc.c                                                |    72 +-
 head/sys/kern/kern_resource.c                                            |    17 +-
 head/sys/kern/kern_shutdown.c                                            |     5 +-
 head/sys/kern/subr_hash.c                                                |    12 +-
 head/sys/kern/subr_mchain.c                                              |     4 +-
 head/sys/kern/subr_scanf.c                                               |    23 +-
 head/sys/kern/subr_syscall.c                                             |     5 +-
 head/sys/kern/uipc_mbuf.c                                                |     7 +-
 head/sys/kern/vfs_aio.c                                                  |    38 +-
 head/sys/kern/vfs_cache.c                                                |   201 +-
 head/sys/kern/vfs_mount.c                                                |    57 +-
 head/sys/kern/vfs_subr.c                                                 |    25 +-
 head/sys/kern/vfs_vnops.c                                                |    16 +-
 head/sys/mips/include/_types.h                                           |     4 +-
 head/sys/mips/include/float.h                                            |    25 +-
 head/sys/modules/Makefile                                                |    20 +-
 head/sys/modules/ipdivert/Makefile                                       |    12 +-
 head/sys/modules/isci/Makefile                                           |    92 +
 head/sys/modules/ixgbe/Makefile                                          |     4 +-
 head/sys/modules/mps/Makefile                                            |     7 +-
 head/sys/modules/sound/driver/maestro3/Makefile                          |     3 +-
 head/sys/modules/wtap/Makefile                                           |     4 +-
 head/sys/nlm/nlm_prot_impl.c                                             |    76 +-
 head/sys/sys/cdefs.h                                                     |     6 +-
 head/sys/sys/diskmbr.h                                                   |     3 +-
 head/sys/sys/elf_common.h                                                |     5 +-
 head/sys/sys/malloc.h                                                    |     3 +-
 head/sys/sys/mbuf.h                                                      |    56 +-
 head/sys/sys/mdioctl.h                                                   |     4 +-
 head/sys/sys/mount.h                                                     |     9 +-
 head/sys/sys/param.h                                                     |     4 +-
 head/sys/sys/proc.h                                                      |     3 +-
 head/sys/sys/resourcevar.h                                               |     4 +-
 head/sys/sys/signal.h                                                    |     4 +-
 head/sys/sys/systm.h                                                     |     5 +-
 head/sys/sys/types.h                                                     |     3 +-
 head/sys/sys/ucontext.h                                                  |     8 +-
 head/sys/sys/vnode.h                                                     |    14 +-
 head/sys/ufs/ffs/ffs_snapshot.c                                          |    12 +-
 head/sys/ufs/ffs/ffs_vfsops.c                                            |     6 +-
 head/sys/ufs/ufs/ufs_dirhash.c                                           |     9 +-
 head/sys/xen/interface/io/netif.h                                        |     8 +-
 head/usr.bin/bc/bc.1                                                     |     4 +-
 head/usr.bin/fetch/fetch.c                                               |    21 +-
 head/usr.bin/hexdump/parse.c                                             |    21 +-
 head/usr.bin/last/last.1                                                 |     3 +-
 head/usr.bin/last/last.c                                                 |    12 +-
 head/usr.bin/limits/limits.1                                             |     9 +-
 head/usr.bin/limits/limits.c                                             |    93 +-
 head/usr.bin/make/main.c                                                 |    19 +-
 head/usr.bin/netstat/netgraph.c                                          |    14 +-
 head/usr.bin/netstat/sctp.c                                              |     5 +-
 head/usr.bin/procstat/procstat_auxv.c                                    |    18 +-
 head/usr.bin/procstat/procstat_rlimit.c                                  |    32 +-
 head/usr.bin/sockstat/sockstat.1                                         |    28 +-
 head/usr.bin/sockstat/sockstat.c                                         |   120 +-
 head/usr.bin/tip/tip/tip.c                                               |     4 +-
 head/usr.bin/tip/tip/tipout.c                                            |     7 +-
 head/usr.sbin/bootparamd/callbootd/callbootd.c                           |     7 +-
 head/usr.sbin/bsdinstall/partedit/partedit.c                             |    28 +-
 head/usr.sbin/bsdinstall/partedit/partedit_powerpc.c                     |     6 +-
 head/usr.sbin/bsdinstall/scripts/netconfig_ipv4                          |     4 +-
 head/usr.sbin/cpucontrol/via.c                                           |     5 +-
 head/usr.sbin/cron/crontab/crontab.5                                     |     6 +-
 head/usr.sbin/daemon/daemon.8                                            |     6 +-
 head/usr.sbin/daemon/daemon.c                                            |     8 +-
 head/usr.sbin/faithd/prefix.c                                            |     6 +-
 head/usr.sbin/i2c/i2c.c                                                  |     5 +-
 head/usr.sbin/ifmcstat/ifmcstat.c                                        |    55 +-
 head/usr.sbin/jail/jail.c                                                |    12 +-
 head/usr.sbin/mixer/mixer.c                                              |     9 +-
 head/usr.sbin/mount_portalfs/mount_portalfs.c                            |     5 +-
 head/usr.sbin/mountd/mountd.c                                            |     7 +-
 head/usr.sbin/moused/moused.c                                            |     5 +-
 head/usr.sbin/mptutil/mpt_cam.c                                          |     4 +-
 head/usr.sbin/pmcstat/pmcstat.c                                          |     5 +-
 head/usr.sbin/ppp/iface.c                                                |     5 +-
 head/usr.sbin/ppp/lqr.c                                                  |     5 +-
 head/usr.sbin/ppp/physical.c                                             |     5 +-
 head/usr.sbin/rarpd/rarpd.c                                              |     5 +-
 head/usr.sbin/rtsold/rtsold.c                                            |     5 +-
 head/usr.sbin/sade/devices.c                                             |     6 +-
 head/usr.sbin/tzsetup/tzsetup.c                                          |    88 +-
 head/usr.sbin/wpa/wpa_supplicant/Makefile                                |     4 +-
 head/usr.sbin/ypserv/yp_main.c                                           |     6 +-
 197 files changed, 7498 insertions(+), 3591 deletions(-)

diffs (17000 lines):

diff -r e2c0c3238398 -r cd6b4b1a93f5 head/MAINTAINERS
--- a/head/MAINTAINERS	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/MAINTAINERS	Wed Feb 01 12:34:54 2012 +0200
@@ -1,4 +1,4 @@
-$FreeBSD: head/MAINTAINERS 225937 2011-10-03 15:13:09Z nwhitehorn $
+$FreeBSD: head/MAINTAINERS 230843 2012-01-31 19:38:18Z jimharris $
 
 Please note that the content of this file is strictly advisory.
 No locks listed here are valid.  The only strict review requirements
@@ -124,6 +124,7 @@
 lib/libc/stdtime	edwin   Heads-up appreciated, since parts of this code
 				is maintained by a third party source.
 sbin/routed	bms	Pre-commit review; notify vendor at rhyolite.com
+isci(4)		jimharris	Pre-commit review requested.
 
 Following are the entries from the Makefiles, and a few other sources.
 Please remove stale entries from both their origin, and this file.
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/Makefile.inc1
--- a/head/Makefile.inc1	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/Makefile.inc1	Wed Feb 01 12:34:54 2012 +0200
@@ -1,5 +1,5 @@
 #
-# $FreeBSD: head/Makefile.inc1 230127 2012-01-15 08:36:25Z glebius $
+# $FreeBSD: head/Makefile.inc1 230786 2012-01-30 20:19:28Z imp $
 #
 # Make command line options:
 #	-DNO_CLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
@@ -19,6 +19,7 @@
 #	    list
 #	TARGET="machine" to crossbuild world for a different machine type
 #	TARGET_ARCH= may be required when a TARGET supports multiple endians
+#	BUILDENV_SHELL= shell to launch for the buildenv target (def:/bin/sh)
 
 #
 # The intended user-driven targets are:
@@ -109,6 +110,8 @@
 
 LOCAL_TOOL_DIRS?=
 
+BUILDENV_SHELL?=/bin/sh
+
 CVS?=		cvs
 CVSFLAGS?=	-A -P -d -I!
 SVN?=		svn
@@ -561,7 +564,7 @@
 
 buildenv:
 	@echo Entering world for ${TARGET_ARCH}:${TARGET}
-	@cd ${.CURDIR} && env ${WMAKEENV} sh || true
+	@cd ${.CURDIR} && env ${WMAKEENV} ${BUILDENV_SHELL} || true
 
 TOOLCHAIN_TGTS=	${WMAKE_TGTS:N_depend:Neverything:Nbuild32}
 toolchain: ${TOOLCHAIN_TGTS}
@@ -849,6 +852,7 @@
 	@echo ">>> stage 2.3: build tools"
 	@echo "--------------------------------------------------------------"
 	cd ${KRNLOBJDIR}/${_kernel}; \
+	    PATH=${BPATH}:${PATH} \
 	    MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \
 	    ${MAKE} SSP_CFLAGS= -DNO_CPU_CFLAGS -DNO_CTF \
 	    -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile
@@ -856,6 +860,7 @@
 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules)
 .for target in obj depend all
 	cd ${KERNSRCDIR}/modules/aic7xxx/aicasm; \
+	    PATH=${BPATH}:${PATH} \
 	    MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \
 	    ${MAKE} SSP_CFLAGS= -DNO_CPU_CFLAGS -DNO_CTF ${target}
 .endfor
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/bin/ps/print.c
--- a/head/bin/ps/print.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/bin/ps/print.c	Wed Feb 01 12:34:54 2012 +0200
@@ -34,7 +34,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/bin/ps/print.c 226939 2011-10-30 15:21:27Z trasz $");
+__FBSDID("$FreeBSD: head/bin/ps/print.c 230287 2012-01-17 22:17:10Z ed $");
 
 #include <sys/param.h>
 #include <sys/time.h>
@@ -99,10 +99,8 @@
 char *
 arguments(KINFO *k, VARENT *ve)
 {
-	VAR *v;
 	char *vis_args;
 
-	v = ve->var;
 	if ((vis_args = malloc(strlen(k->ki_args) * 4 + 1)) == NULL)
 		errx(1, "malloc failed");
 	strvis(vis_args, k->ki_args, VIS_TAB | VIS_NL | VIS_NOSLASH);
@@ -116,10 +114,8 @@
 char *
 command(KINFO *k, VARENT *ve)
 {
-	VAR *v;
 	char *vis_args, *vis_env, *str;
 
-	v = ve->var;
 	if (cflag) {
 		/* If it is the last field, then don't pad */
 		if (STAILQ_NEXT(ve, next_ve) == NULL) {
@@ -172,10 +168,8 @@
 char *
 ucomm(KINFO *k, VARENT *ve)
 {
-	VAR *v;
 	char *str;
 
-	v = ve->var;
 	if (STAILQ_NEXT(ve, next_ve) == NULL) {	/* last field, don't pad */
 		asprintf(&str, "%s%s%s%s",
 		    k->ki_d.prefix ? k->ki_d.prefix : "",
@@ -192,12 +186,10 @@
 }
 
 char *
-tdnam(KINFO *k, VARENT *ve)
+tdnam(KINFO *k, VARENT *ve __unused)
 {
-	VAR *v;
 	char *str;
 
-	v = ve->var;
 	if (showthreads && k->ki_p->ki_numthreads > 1)
 		str = strdup(k->ki_p->ki_tdname);
 	else
@@ -207,28 +199,24 @@
 }
 
 char *
-logname(KINFO *k, VARENT *ve)
+logname(KINFO *k, VARENT *ve __unused)
 {
-	VAR *v;
 
-	v = ve->var;
 	if (*k->ki_p->ki_login == '\0')
 		return (NULL);
 	return (strdup(k->ki_p->ki_login));
 }
 
 char *
-state(KINFO *k, VARENT *ve)
+state(KINFO *k, VARENT *ve __unused)
 {
 	int flag, tdflags;
 	char *cp, *buf;
-	VAR *v;
 
 	buf = malloc(16);
 	if (buf == NULL)
 		errx(1, "malloc failed");
 
-	v = ve->var;
 	flag = k->ki_p->ki_flag;
 	tdflags = k->ki_p->ki_tdflags;	/* XXXKSE */
 	cp = buf;
@@ -294,72 +282,58 @@
 #define	scalepri(x)	((x) - PZERO)
 
 char *
-pri(KINFO *k, VARENT *ve)
+pri(KINFO *k, VARENT *ve __unused)
 {
-	VAR *v;
 	char *str;
 
-	v = ve->var;
 	asprintf(&str, "%d", scalepri(k->ki_p->ki_pri.pri_level));
 	return (str);
 }
 
 char *
-upr(KINFO *k, VARENT *ve)
+upr(KINFO *k, VARENT *ve __unused)
 {
-	VAR *v;
 	char *str;
 
-	v = ve->var;
 	asprintf(&str, "%d", scalepri(k->ki_p->ki_pri.pri_user));
 	return (str);
 }
 #undef scalepri
 
 char *
-uname(KINFO *k, VARENT *ve)
+uname(KINFO *k, VARENT *ve __unused)
 {
-	VAR *v;
 
-	v = ve->var;
 	return (strdup(user_from_uid(k->ki_p->ki_uid, 0)));
 }
 
 char *
-egroupname(KINFO *k, VARENT *ve)
+egroupname(KINFO *k, VARENT *ve __unused)
 {
-	VAR *v;
 
-	v = ve->var;
 	return (strdup(group_from_gid(k->ki_p->ki_groups[0], 0)));
 }
 
 char *
-rgroupname(KINFO *k, VARENT *ve)
+rgroupname(KINFO *k, VARENT *ve __unused)
 {
-	VAR *v;
 
-	v = ve->var;
 	return (strdup(group_from_gid(k->ki_p->ki_rgid, 0)));
 }
 
 char *
-runame(KINFO *k, VARENT *ve)
+runame(KINFO *k, VARENT *ve __unused)
 {
-	VAR *v;
 
-	v = ve->var;
 	return (strdup(user_from_uid(k->ki_p->ki_ruid, 0)));
 }
 
 char *
-tdev(KINFO *k, VARENT *ve)
+tdev(KINFO *k, VARENT *ve __unused)
 {
-	VAR *v;
 	dev_t dev;
 	char *str;
 
-	v = ve->var;
 	dev = k->ki_p->ki_tdev;
 	if (dev == NODEV)
 		str = strdup("-");
@@ -370,13 +344,11 @@
 }
 
 char *
-tname(KINFO *k, VARENT *ve)
+tname(KINFO *k, VARENT *ve __unused)
 {
-	VAR *v;
 	dev_t dev;
 	char *ttname, *str;
 
-	v = ve->var;
 	dev = k->ki_p->ki_tdev;
 	if (dev == NODEV || (ttname = devname(dev, S_IFCHR)) == NULL)
 		str = strdup("- ");
@@ -394,13 +366,11 @@
 }
 
 char *
-longtname(KINFO *k, VARENT *ve)
+longtname(KINFO *k, VARENT *ve __unused)
 {
-	VAR *v;
 	dev_t dev;
 	const char *ttname;
 
-	v = ve->var;
 	dev = k->ki_p->ki_tdev;
 	if (dev == NODEV || (ttname = devname(dev, S_IFCHR)) == NULL)
 		ttname = "-";
@@ -409,9 +379,8 @@
 }
 
 char *
-started(KINFO *k, VARENT *ve)
+started(KINFO *k, VARENT *ve __unused)
 {
-	VAR *v;
 	time_t then;
 	struct tm *tp;
 	static int use_ampm = -1;
@@ -422,7 +391,6 @@
 	if (buf == NULL)
 		errx(1, "malloc failed");
 
-	v = ve->var;
 	if (!k->ki_valid)
 		return (NULL);
 	if (use_ampm < 0)
@@ -441,9 +409,8 @@
 }
 
 char *
-lstarted(KINFO *k, VARENT *ve)
+lstarted(KINFO *k, VARENT *ve __unused)
 {
-	VAR *v;
 	time_t then;
 	char *buf;
 	size_t buflen = 100;
@@ -452,7 +419,6 @@
 	if (buf == NULL)
 		errx(1, "malloc failed");
 
-	v = ve->var;
 	if (!k->ki_valid)
 		return (NULL);
 	then = k->ki_p->ki_start.tv_sec;
@@ -461,12 +427,10 @@
 }
 
 char *
-lockname(KINFO *k, VARENT *ve)
+lockname(KINFO *k, VARENT *ve __unused)
 {
-	VAR *v;
 	char *str;
 
-	v = ve->var;
 	if (k->ki_p->ki_kiflag & KI_LOCKBLOCK) {
 		if (k->ki_p->ki_lockname[0] != 0)
 			str = strdup(k->ki_p->ki_lockname);
@@ -479,12 +443,10 @@
 }
 
 char *
-wchan(KINFO *k, VARENT *ve)
+wchan(KINFO *k, VARENT *ve __unused)
 {
-	VAR *v;
 	char *str;
 
-	v = ve->var;
 	if (k->ki_p->ki_wchan) {
 		if (k->ki_p->ki_wmesg[0] != 0)
 			str = strdup(k->ki_p->ki_wmesg);
@@ -497,12 +459,10 @@
 }
 
 char *
-nwchan(KINFO *k, VARENT *ve)
+nwchan(KINFO *k, VARENT *ve __unused)
 {
-	VAR *v;
 	char *str;
 
-	v = ve->var;
 	if (k->ki_p->ki_wchan)
 		asprintf(&str, "%0lx", (long)k->ki_p->ki_wchan);
 	else
@@ -512,12 +472,10 @@
 }
 
 char *
-mwchan(KINFO *k, VARENT *ve)
+mwchan(KINFO *k, VARENT *ve __unused)
 {
-	VAR *v;
 	char *str;
 
-	v = ve->var;
 	if (k->ki_p->ki_wchan) {
 		if (k->ki_p->ki_wmesg[0] != 0)
 			str = strdup(k->ki_p->ki_wmesg);
@@ -535,27 +493,23 @@
 }
 
 char *
-vsize(KINFO *k, VARENT *ve)
+vsize(KINFO *k, VARENT *ve __unused)
 {
-	VAR *v;
 	char *str;
 
-	v = ve->var;
 	asprintf(&str, "%lu", (u_long)(k->ki_p->ki_size / 1024));
 	return (str);
 }
 
 static char *
-printtime(KINFO *k, VARENT *ve, long secs, long psecs)
+printtime(KINFO *k, VARENT *ve __unused, long secs, long psecs)
 /* psecs is "parts" of a second. first micro, then centi */
 {
-	VAR *v;
 	static char decimal_point;
 	char *str;
 
 	if (decimal_point == '\0')
 		decimal_point = localeconv()->decimal_point[0];
-	v = ve->var;
 	if (!k->ki_valid) {
 		secs = 0;
 		psecs = 0;
@@ -618,14 +572,12 @@
 }
 
 char *
-elapsed(KINFO *k, VARENT *ve)
+elapsed(KINFO *k, VARENT *ve __unused)
 {
-	VAR *v;
 	time_t val;
 	int days, hours, mins, secs;
 	char *str;
 
-	v = ve->var;
 	if (!k->ki_valid)
 		return (NULL);
 	val = now - k->ki_p->ki_start.tv_sec;
@@ -646,13 +598,11 @@
 }
 
 char *
-elapseds(KINFO *k, VARENT *ve)
+elapseds(KINFO *k, VARENT *ve __unused)
 {
-	VAR *v;
 	time_t val;
 	char *str;
 
-	v = ve->var;
 	if (!k->ki_valid)
 		return (NULL);
 	val = now - k->ki_p->ki_start.tv_sec;
@@ -682,12 +632,10 @@
 }
 
 char *
-pcpu(KINFO *k, VARENT *ve)
+pcpu(KINFO *k, VARENT *ve __unused)
 {
-	VAR *v;
 	char *str;
 
-	v = ve->var;
 	asprintf(&str, "%.1f", getpcpu(k));
 	return (str);
 }
@@ -712,47 +660,39 @@
 }
 
 char *
-pmem(KINFO *k, VARENT *ve)
+pmem(KINFO *k, VARENT *ve __unused)
 {
-	VAR *v;
 	char *str;
 
-	v = ve->var;
 	asprintf(&str, "%.1f", getpmem(k));
 	return (str);
 }
 
 char *
-pagein(KINFO *k, VARENT *ve)
+pagein(KINFO *k, VARENT *ve __unused)
 {
-	VAR *v;
 	char *str;
 
-	v = ve->var;
 	asprintf(&str, "%ld", k->ki_valid ? k->ki_p->ki_rusage.ru_majflt : 0);
 	return (str);
 }
 
 /* ARGSUSED */
 char *
-maxrss(KINFO *k __unused, VARENT *ve)
+maxrss(KINFO *k __unused, VARENT *ve __unused)
 {
-	VAR *v;
 
-	v = ve->var;
 	/* XXX not yet */
 	return (NULL);
 }
 
 char *
-priorityr(KINFO *k, VARENT *ve)
+priorityr(KINFO *k, VARENT *ve __unused)
 {
-	VAR *v;
 	struct priority *lpri;
 	char *str;
 	unsigned class, level;
 
-	v = ve->var;
 	lpri = &k->ki_p->ki_pri;
 	class = lpri->pri_class;
 	level = lpri->pri_level;
@@ -852,25 +792,21 @@
 }
 
 char *
-emulname(KINFO *k, VARENT *ve)
+emulname(KINFO *k, VARENT *ve __unused)
 {
-	VAR *v;
 
-	v = ve->var;
 	if (k->ki_p->ki_emul == NULL)
 		return (NULL);
 	return (strdup(k->ki_p->ki_emul));
 }
 
 char *
-label(KINFO *k, VARENT *ve)
+label(KINFO *k, VARENT *ve __unused)
 {
 	char *string;
-	VAR *v;
 	mac_t proclabel;
 	int error;
 
-	v = ve->var;
 	string = NULL;
 	if (mac_prepare_process_label(&proclabel) == -1) {
 		warn("mac_prepare_process_label");
@@ -887,12 +823,10 @@
 }
 
 char *
-loginclass(KINFO *k, VARENT *ve)
+loginclass(KINFO *k, VARENT *ve __unused)
 {
-	VAR *v;
 	char *s;
 
-	v = ve->var;
 	/*
 	 * Don't display login class for system processes;
 	 * login classes are used for resource limits,
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/contrib/libarchive/libarchive/archive_read_support_format_iso9660.c
--- a/head/contrib/libarchive/libarchive/archive_read_support_format_iso9660.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/contrib/libarchive/libarchive/archive_read_support_format_iso9660.c	Wed Feb 01 12:34:54 2012 +0200
@@ -26,7 +26,7 @@
  */
 
 #include "archive_platform.h"
-__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_read_support_format_iso9660.c 228911 2011-12-27 10:36:56Z mm $");
+__FBSDID("$FreeBSD: head/contrib/libarchive/libarchive/archive_read_support_format_iso9660.c 230759 2012-01-29 22:20:28Z mm $");
 
 #ifdef HAVE_ERRNO_H
 #include <errno.h>
@@ -1778,6 +1778,19 @@
 				free(file);
 				return (NULL);
 			}
+			/*
+			 * A file size of symbolic link files in ISO images
+			 * made by makefs is not zero and its location is
+			 * the same as those of next regular file. That is
+			 * the same as hard like file and it causes unexpected
+			 * error. 
+			 */
+			if (file->size > 0 &&
+			    (file->mode & AE_IFMT) == AE_IFLNK) {
+				file->size = 0;
+				file->number = -1;
+				file->offset = -1;
+			}
 		} else
 			/* If there isn't SUSP, disable parsing
 			 * rock ridge extensions. */
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/contrib/llvm/lib/Target/X86/X86InstrCompiler.td
--- a/head/contrib/llvm/lib/Target/X86/X86InstrCompiler.td	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/contrib/llvm/lib/Target/X86/X86InstrCompiler.td	Wed Feb 01 12:34:54 2012 +0200
@@ -533,7 +533,7 @@
 // Memory barriers
 
 // TODO: Get this to fold the constant into the instruction.
-let isCodeGenOnly = 1 in
+let isCodeGenOnly = 1, Defs = [EFLAGS] in
 def OR32mrLocked  : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$zero),
                       "lock\n\t"
                       "or{l}\t{$zero, $dst|$dst, $zero}",
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/etc/devd/apple.conf
--- a/head/etc/devd/apple.conf	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/etc/devd/apple.conf	Wed Feb 01 12:34:54 2012 +0200
@@ -1,4 +1,4 @@
-# $FreeBSD: head/etc/devd/apple.conf 228277 2011-12-05 14:13:21Z jhibbits $
+# $FreeBSD: head/etc/devd/apple.conf 230640 2012-01-28 02:52:22Z jhibbits $
 #
 # PowerPC Apple specific devd events
 
@@ -6,7 +6,6 @@
 notify 0 {
 	match "system"		"PMU";
 	match "subsystem"	"Button";
-	match "notify"		"0x0";
 	action			"shutdown -p now";
 };
 
@@ -16,7 +15,6 @@
 	match "system"		"PMU";
 	match "subsystem"	"lid";
 	match "type"		"close";
-	match "notify"		"0x0";
 	action			"shutdown -p now";
 };
 
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/etc/netstart
--- a/head/etc/netstart	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/etc/netstart	Wed Feb 01 12:34:54 2012 +0200
@@ -24,7 +24,7 @@
 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 # SUCH DAMAGE.
 #
-# $FreeBSD$
+# $FreeBSD: head/etc/netstart 230389 2012-01-20 17:25:15Z rea $
 #	From: @(#)netstart	5.9 (Berkeley) 3/30/91
 #
 
@@ -52,7 +52,6 @@
 # . /etc/rc.d/atm3.sh ${_start}
 /etc/rc.d/netif ${_start}
 /etc/rc.d/ipsec ${_start}
-/etc/rc.d/dhclient ${_start}
 /etc/rc.d/ppp ${_start}
 /etc/rc.d/ipfw ${_start}
 /etc/rc.d/routing ${_start}
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/etc/network.subr
--- a/head/etc/network.subr	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/etc/network.subr	Wed Feb 01 12:34:54 2012 +0200
@@ -22,7 +22,7 @@
 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 # SUCH DAMAGE.
 #
-# $FreeBSD: head/etc/network.subr 229783 2012-01-07 16:10:32Z uqs $
+# $FreeBSD: head/etc/network.subr 230453 2012-01-22 10:57:32Z hrs $
 #
 
 #
@@ -109,8 +109,10 @@
 		# backward compatibility: $ipv6_enable
 		case $ipv6_enable in
 		[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
-			_ipv6_opts="${_ipv6_opts} accept_rtadv"
-			;;
+			if ! checkyesno ipv6_gateway_enable; then
+				_ipv6_opts="${_ipv6_opts} accept_rtadv"
+			fi
+		;;
 		esac
 
 		case $ipv6_cpe_wanif in
@@ -139,6 +141,14 @@
 			_cfg=0
 		fi
 
+		# $ipv6_prefix_IF will be handled in
+		# ipv6_prefix_hostid_addr_common().
+		ifconfig_args=`get_if_var $1 ipv6_prefix_IF`
+		if [ -n "${ifconfig_args}" ]; then
+			ifconfig $1 inet6 -ifdisabled
+			_cfg=0
+		fi
+
 		# backward compatibility: $ipv6_ifconfig_IF
 		ifconfig_args=`get_if_var $1 ipv6_ifconfig_IF`
 		if [ -n "${ifconfig_args}" ]; then
@@ -444,6 +454,12 @@
 			return 0
 		fi
 
+		# True if $ipv6_prefix_IF is defined.
+		_tmpargs=`get_if_var $_if ipv6_prefix_IF`
+		if [ -n "${_tmpargs}" ]; then
+			return 0
+		fi
+
 		# backward compatibility: True if $ipv6_ifconfig_IF is defined.
 		_tmpargs=`get_if_var $_if ipv6_ifconfig_IF`
 		if [ -n "${_tmpargs}" ]; then
@@ -559,10 +575,6 @@
 	ipv6_prefix_hostid_addr_common ${_if} alias && _ret=0
 	ipv6_accept_rtadv_up ${_if} && _ret=0
 
-	# wait for DAD
-	sleep `${SYSCTL_N} net.inet6.ip6.dad_count`
-	sleep 1
-
 	return $_ret
 }
 
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/etc/rc.d/dhclient
--- a/head/etc/rc.d/dhclient	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/etc/rc.d/dhclient	Wed Feb 01 12:34:54 2012 +0200
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $FreeBSD: head/etc/rc.d/dhclient 230007 2012-01-12 06:48:11Z rea $
+# $FreeBSD: head/etc/rc.d/dhclient 230388 2012-01-20 17:19:50Z rea $
 #
 
 # PROVIDE: dhclient
@@ -25,11 +25,11 @@
 		local msg
 		msg="'$ifn' is not a DHCP-enabled interface"
 		if [ -z "${rc_quiet}" ]; then
-			err 1 "$msg"
+			echo "$msg"
 		else
 			debug "$msg"
+		fi
 			exit 1
-		fi
 	fi
 }
 
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/etc/rc.d/jail
--- a/head/etc/rc.d/jail	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/etc/rc.d/jail	Wed Feb 01 12:34:54 2012 +0200
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $FreeBSD: head/etc/rc.d/jail 230099 2012-01-14 02:18:41Z dougb $
+# $FreeBSD: head/etc/rc.d/jail 230403 2012-01-20 22:55:19Z brooks $
 #
 
 # PROVIDE: jail
@@ -601,10 +601,7 @@
 				devfs_mount_jail "${_devdir}" ${_ruleset}
 				# Transitional symlink for old binaries
 				if [ ! -L "${_devdir}/log" ]; then
-					__pwd="`pwd`"
-					cd "${_devdir}"
-					ln -sf ../var/run/log log
-					cd "$__pwd"
+					ln -sf ../var/run/log "${_devdir}/log"
 				fi
 			fi
 
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/etc/rc.d/netif
--- a/head/etc/rc.d/netif	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/etc/rc.d/netif	Wed Feb 01 12:34:54 2012 +0200
@@ -22,7 +22,7 @@
 # (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$
+# $FreeBSD: head/etc/rc.d/netif 230726 2012-01-29 08:33:34Z hrs $
 #
 
 # PROVIDE: netif
@@ -123,16 +123,28 @@
 		_cooked_list="`list_net_interfaces`"
 	fi
 
+	_dadwait=
 	_fail=
 	_ok=
 	for ifn in ${_cooked_list}; do
 		if ${_func} ${ifn} $2; then
 			_ok="${_ok} ${ifn}"
+			if ipv6if ${ifn}; then
+				_dadwait=1
+			fi
 		else
 			_fail="${_fail} ${ifn}"
 		fi
 	done
 
+	# inet6 address configuration needs sleep for DAD.
+	case ${_func}:${_dadwait} in
+	ifn_start:1)
+		sleep `${SYSCTL_N} net.inet6.ip6.dad_count`
+		sleep 1
+	;;
+	esac
+
 	_str=
 	if [ -n "${_ok}" ]; then
 		case ${_func} in
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/etc/rc.subr
--- a/head/etc/rc.subr	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/etc/rc.subr	Wed Feb 01 12:34:54 2012 +0200
@@ -1,5 +1,5 @@
 # $NetBSD: rc.subr,v 1.67 2006/10/07 11:25:15 elad Exp $
-# $FreeBSD: head/etc/rc.subr 230103 2012-01-14 08:59:02Z dougb $
+# $FreeBSD: head/etc/rc.subr 230374 2012-01-20 10:31:27Z dougb $
 #
 # Copyright (c) 1997-2004 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -641,7 +641,7 @@
 		fi
 	fi
 
-	eval $_pidcmd			# determine the pid if necessary
+	[ -z "$autoboot" ] && eval $_pidcmd	# determine the pid if necessary
 
 	for _elem in $_keywords; do
 		if [ "$_elem" != "$rc_arg" ]; then
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/games/pom/pom.c
--- a/head/games/pom/pom.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/games/pom/pom.c	Wed Feb 01 12:34:54 2012 +0200
@@ -41,7 +41,7 @@
 #endif /* not lint */
 #endif
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: head/games/pom/pom.c 230644 2012-01-28 15:29:43Z maxim $");
 
 /*
  * Phase of the Moon.  Calculates the current phase of the moon.
@@ -86,6 +86,7 @@
 	double days, today, tomorrow;
 	int ch, cnt, pflag = 0;
 	char *odate = NULL, *otime = NULL;
+	char *progname = argv[0];
 
 	while ((ch = getopt(argc, argv, "d:pt:")) != -1)
 		switch (ch) {
@@ -99,14 +100,14 @@
 			otime = optarg;
 			break;
 		default:
-			usage(argv[0]);
+			usage(progname);
 		}
 
         argc -= optind;
 	argv += optind;
 
 	if (argc)
-		usage(argv[0]);
+		usage(progname);
 
 	/* Adjust based on users preferences */
 	time(&tt);
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/gnu/usr.bin/gdb/kgdb/trgt_amd64.c
--- a/head/gnu/usr.bin/gdb/kgdb/trgt_amd64.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/gnu/usr.bin/gdb/kgdb/trgt_amd64.c	Wed Feb 01 12:34:54 2012 +0200
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: head/gnu/usr.bin/gdb/kgdb/trgt_amd64.c 230427 2012-01-21 17:50:14Z kib $");
 
 #include <sys/types.h>
 #include <machine/pcb.h>
@@ -66,7 +66,7 @@
 	supply_register(AMD64_R8_REGNUM + 6, (char *)&pcb.pcb_r14);
 	supply_register(AMD64_R15_REGNUM, (char *)&pcb.pcb_r15);
 	supply_register(AMD64_RIP_REGNUM, (char *)&pcb.pcb_rip);
-	amd64_supply_fxsave(current_regcache, -1, &pcb.pcb_user_save);
+	amd64_supply_fxsave(current_regcache, -1, (struct fpusave *)(&pcb + 1));
 }
 
 void
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/include/complex.h
--- a/head/include/complex.h	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/include/complex.h	Wed Feb 01 12:34:54 2012 +0200
@@ -23,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: head/include/complex.h 229594 2012-01-05 12:09:39Z ed $
+ * $FreeBSD: head/include/complex.h 230278 2012-01-17 20:22:10Z ed $
  */
 
 #ifndef _COMPLEX_H
@@ -36,6 +36,9 @@
 #define	_Complex	__complex__
 #endif
 #define	_Complex_I	((float _Complex)1.0i)
+#endif
+
+#ifdef __generic
 _Static_assert(__generic(_Complex_I, float _Complex, 1, 0),
     "_Complex_I must be of type float _Complex");
 #endif
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/include/stdatomic.h
--- a/head/include/stdatomic.h	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/include/stdatomic.h	Wed Feb 01 12:34:54 2012 +0200
@@ -24,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: head/include/stdatomic.h 230062 2012-01-13 16:01:34Z ed $
+ * $FreeBSD: head/include/stdatomic.h 230267 2012-01-17 15:20:41Z theraven $
  */
 
 #ifndef _STDATOMIC_H_
@@ -104,10 +104,7 @@
  * 7.17.4 Fences.
  */
 
-#if defined(__CLANG_ATOMICS)
-#define	atomic_thread_fence(order)	__atomic_thread_fence(order)
-#define	atomic_signal_fence(order)	__asm volatile ("" : : : "memory")
-#elif defined(__GNUC_ATOMICS)
+#if defined(__CLANG_ATOMICS) || defined(__GNUC_ATOMICS)
 #define	atomic_thread_fence(order)	__atomic_thread_fence(order)
 #define	atomic_signal_fence(order)	__atomic_signal_fence(order)
 #else
@@ -121,7 +118,7 @@
 
 #if defined(__CLANG_ATOMICS)
 #define	atomic_is_lock_free(obj) \
-	__atomic_is_lock_free(obj)
+	__atomic_is_lock_free(sizeof(obj))
 #elif defined(__GNUC_ATOMICS)
 #define	atomic_is_lock_free(obj) \
 	__atomic_is_lock_free(sizeof((obj)->__val))
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/release/doc/share/misc/man2hwnotes.pl
--- a/head/release/doc/share/misc/man2hwnotes.pl	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/release/doc/share/misc/man2hwnotes.pl	Wed Feb 01 12:34:54 2012 +0200
@@ -25,7 +25,7 @@
 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 # SUCH DAMAGE.
 #
-# $FreeBSD$
+# $FreeBSD: head/release/doc/share/misc/man2hwnotes.pl 230332 2012-01-19 17:29:54Z jhb $
 #
 
 # Parse the list of supported hardware out of section 4 manual pages
@@ -324,6 +324,11 @@
 	    } elsif (/^Fx/) {
 		dlog(3, "Got Fx command");
 		parabuf_addline(\%mdocvars, "FreeBSD");
+	    } elsif (/^Em (.+)$/) {
+		my ($txt, $punct_str) = split_punct_chars($1);
+
+		parabuf_addline(\%mdocvars,
+				normalize("<emphasis>$txt</emphasis>$punct_str"));
 	    } else {
 		# Ignore all other commands.
 		dlog(3, "Ignoring unknown command $cmd");
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/release/rc.local
--- a/head/release/rc.local	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/release/rc.local	Wed Feb 01 12:34:54 2012 +0200
@@ -1,5 +1,5 @@
 #!/bin/sh
-# $FreeBSD: head/release/rc.local 225637 2011-09-17 09:25:45Z nwhitehorn $
+# $FreeBSD: head/release/rc.local 230484 2012-01-23 16:17:54Z nwhitehorn $
 
 : ${DIALOG_OK=0}
 : ${DIALOG_CANCEL=1}
@@ -10,8 +10,17 @@
 
 kbdcontrol -d >/dev/null 2>&1
 if [ $? -eq 0 ]; then
-	# Syscons: use xterm
+	# Syscons: use xterm, start interesting things on other VTYs
 	TERM=xterm
+
+	if [ -z "$EXTERNAL_VTY_STARTED" ]; then
+		# Init will clean these processes up if/when the system
+		# goes multiuser
+		touch /tmp/bsdinstall_log
+		tail -f /tmp/bsdinstall_log > /dev/ttyv2 &
+		/usr/libexec/getty autologin ttyv3
+		EXTERNAL_VTY_STARTED=1
+	fi
 else
 	# Serial or other console
 	echo
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sbin/camcontrol/Makefile
--- a/head/sbin/camcontrol/Makefile	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sbin/camcontrol/Makefile	Wed Feb 01 12:34:54 2012 +0200
@@ -1,9 +1,9 @@
-# $FreeBSD: head/sbin/camcontrol/Makefile 227961 2011-11-25 04:03:37Z emaste $
+# $FreeBSD: head/sbin/camcontrol/Makefile 230727 2012-01-29 09:12:34Z nyan $
 
 PROG=	camcontrol
-SRCS=	camcontrol.c fwdownload.c util.c
+SRCS=	camcontrol.c util.c
 .if !defined(RELEASE_CRUNCH)
-SRCS+=	modeedit.c
+SRCS+=	fwdownload.c modeedit.c
 .else
 CFLAGS+= -DMINIMALISTIC
 .endif
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sbin/camcontrol/camcontrol.c
--- a/head/sbin/camcontrol/camcontrol.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sbin/camcontrol/camcontrol.c	Wed Feb 01 12:34:54 2012 +0200
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sbin/camcontrol/camcontrol.c 229919 2012-01-10 02:59:58Z eadler $");
+__FBSDID("$FreeBSD: head/sbin/camcontrol/camcontrol.c 230590 2012-01-26 18:09:28Z ken $");
 
 #include <sys/ioctl.h>
 #include <sys/stdint.h>
@@ -4232,7 +4232,8 @@
 			      /*lba*/ 0,
 			      /*reladdr*/ 0,
 			      /*pmi*/ 0,
-			      &rcaplong,
+			      /*rcap_buf*/ (uint8_t *)&rcaplong,
+			      /*rcap_buf_len*/ sizeof(rcaplong),
 			      /*sense_len*/ SSD_FULL_SIZE,
 			      /*timeout*/ timeout ? timeout : 5000);
 
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sbin/growfs/growfs.c
--- a/head/sbin/growfs/growfs.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sbin/growfs/growfs.c	Wed Feb 01 12:34:54 2012 +0200
@@ -47,7 +47,7 @@
 #endif /* not lint */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sbin/growfs/growfs.c 227081 2011-11-04 13:36:02Z ed $");
+__FBSDID("$FreeBSD: head/sbin/growfs/growfs.c 230289 2012-01-17 22:19:35Z ed $");
 
 /* ********************************************************** INCLUDES ***** */
 #include <sys/param.h>
@@ -374,7 +374,9 @@
 	static caddr_t iobuf;
 	long blkno, start;
 	ufs2_daddr_t i, cbase, dmax;
+#ifdef FSIRAND
 	struct ufs1_dinode *dp1;
+#endif
 	struct csum *cs;
 	uint d, dupper, dlower;
 
@@ -452,8 +454,8 @@
 		bzero(iobuf, sblock.fs_bsize);
 		for (i = 0; i < sblock.fs_ipg / INOPF(&sblock);
 		     i += sblock.fs_frag) {
+#ifdef FSIRAND
 			dp1 = (struct ufs1_dinode *)(void *)iobuf;
-#ifdef FSIRAND
 			for (j = 0; j < INOPB(&sblock); j++) {
 				dp1->di_gen = random();
 				dp1++;
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sbin/hastd/hast.conf.5
--- a/head/sbin/hastd/hast.conf.5	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sbin/hastd/hast.conf.5	Wed Feb 01 12:34:54 2012 +0200
@@ -1,8 +1,8 @@
 .\" Copyright (c) 2010 The FreeBSD Foundation
-.\" Copyright (c) 2010-2011 Pawel Jakub Dawidek <pawel at dawidek.net>
+.\" Copyright (c) 2010-2012 Pawel Jakub Dawidek <pawel at dawidek.net>
 .\" All rights reserved.
 .\"
-.\" This software was developed by Pawel Jakub Dawidek under sponsorship from
+.\" This documentation was written by Pawel Jakub Dawidek under sponsorship from
 .\" the FreeBSD Foundation.
 .\"
 .\" Redistribution and use in source and binary forms, with or without
@@ -26,9 +26,9 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\" $FreeBSD: head/sbin/hastd/hast.conf.5 226859 2011-10-27 20:32:57Z pjd $
+.\" $FreeBSD: head/sbin/hastd/hast.conf.5 230515 2012-01-24 23:43:13Z pjd $
 .\"
-.Dd October 27, 2011
+.Dd January 25, 2012
 .Dt HAST.CONF 5
 .Os
 .Sh NAME
@@ -389,7 +389,9 @@
 .Bl -tag -width ".Pa /var/run/hastctl" -compact
 .It Pa /etc/hast.conf
 The default
-.Nm
+.Xr hastctl 8
+and
+.Xr hastd 8
 configuration file.
 .It Pa /var/run/hastctl
 Control socket used by the
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sbin/hastd/hastd.c
--- a/head/sbin/hastd/hastd.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sbin/hastd/hastd.c	Wed Feb 01 12:34:54 2012 +0200
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sbin/hastd/hastd.c 229946 2012-01-10 22:41:09Z pjd $");
+__FBSDID("$FreeBSD: head/sbin/hastd/hastd.c 230457 2012-01-22 11:20:42Z pjd $");
 
 #include <sys/param.h>
 #include <sys/linker.h>
@@ -99,10 +99,10 @@
 void
 descriptors_cleanup(struct hast_resource *res)
 {
-	struct hast_resource *tres;
+	struct hast_resource *tres, *tmres;
 	struct hastd_listen *lst;
 
-	TAILQ_FOREACH(tres, &cfg->hc_resources, hr_next) {
+	TAILQ_FOREACH_SAFE(tres, &cfg->hc_resources, hr_next, tmres) {
 		if (tres == res) {
 			PJDLOG_VERIFY(res->hr_role == HAST_ROLE_SECONDARY ||
 			    (res->hr_remotein == NULL &&
@@ -119,13 +119,17 @@
 			proto_close(tres->hr_event);
 		if (tres->hr_conn != NULL)
 			proto_close(tres->hr_conn);
+		TAILQ_REMOVE(&cfg->hc_resources, tres, hr_next);
+		free(tres);
 	}
 	if (cfg->hc_controlin != NULL)
 		proto_close(cfg->hc_controlin);
 	proto_close(cfg->hc_controlconn);
-	TAILQ_FOREACH(lst, &cfg->hc_listen, hl_next) {
+	while ((lst = TAILQ_FIRST(&cfg->hc_listen)) != NULL) {
+		TAILQ_REMOVE(&cfg->hc_listen, lst, hl_next);
 		if (lst->hl_conn != NULL)
 			proto_close(lst->hl_conn);
+		free(lst);
 	}
 	(void)pidfile_close(pfh);
 	hook_fini();
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sbin/hastd/parse.y
--- a/head/sbin/hastd/parse.y	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sbin/hastd/parse.y	Wed Feb 01 12:34:54 2012 +0200
@@ -28,7 +28,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: head/sbin/hastd/parse.y 226859 2011-10-27 20:32:57Z pjd $
+ * $FreeBSD: head/sbin/hastd/parse.y 230436 2012-01-21 20:13:37Z pjd $
  */
 
 #include <sys/param.h>	/* MAXHOSTNAMELEN */
@@ -369,8 +369,8 @@
 }
 %}
 
-%token CONTROL PIDFILE LISTEN PORT REPLICATION CHECKSUM COMPRESSION METAFLUSH
-%token TIMEOUT EXEC EXTENTSIZE RESOURCE NAME LOCAL REMOTE SOURCE ON OFF
+%token CONTROL PIDFILE LISTEN REPLICATION CHECKSUM COMPRESSION METAFLUSH
+%token TIMEOUT EXEC RESOURCE NAME LOCAL REMOTE SOURCE ON OFF
 %token FULLSYNC MEMSYNC ASYNC NONE CRC32 SHA256 HOLE LZF
 %token NUM STR OB CB
 
@@ -812,6 +812,7 @@
 		    sizeof(curres->hr_name)) >=
 		    sizeof(curres->hr_name)) {
 			pjdlog_error("Resource name is too long.");
+			free(curres);
 			free($1);
 			return (1);
 		}
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sbin/hastd/token.l
--- a/head/sbin/hastd/token.l	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sbin/hastd/token.l	Wed Feb 01 12:34:54 2012 +0200
@@ -28,7 +28,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: head/sbin/hastd/token.l 228696 2011-12-18 20:41:58Z pjd $
+ * $FreeBSD: head/sbin/hastd/token.l 230395 2012-01-20 21:45:24Z pjd $
  */
 
 #include <stdio.h>
@@ -51,7 +51,6 @@
 control			{ DP; return CONTROL; }
 pidfile			{ DP; return PIDFILE; }
 listen			{ DP; return LISTEN; }
-port			{ DP; return PORT; }
 replication		{ DP; return REPLICATION; }
 checksum		{ DP; return CHECKSUM; }
 compression		{ DP; return COMPRESSION; }
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sbin/mdconfig/mdconfig.c
--- a/head/sbin/mdconfig/mdconfig.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sbin/mdconfig/mdconfig.c	Wed Feb 01 12:34:54 2012 +0200
@@ -1,14 +1,35 @@
-/*
- * ----------------------------------------------------------------------------
- * "THE BEER-WARE LICENSE" (Revision 42):
- * <phk at FreeBSD.ORG> wrote this file.  As long as you retain this notice you
- * can do whatever you want with this stuff. If we meet some day, and you think
- * this stuff is worth it, you can buy me a beer in return.   Poul-Henning Kamp
- * ----------------------------------------------------------------------------
+/*-
+ * Copyright (c) 2000-2004 Poul-Henning Kamp <phk at FreeBSD.org>
+ * Copyright (c) 2012 The FreeBSD Foundation
+ * All rights reserved.
  *
- * $FreeBSD: head/sbin/mdconfig/mdconfig.c 221232 2011-04-29 22:40:11Z des $
+ * Portions of this software were developed by Edward Tomasz Napierala
+ * under sponsorship from the FreeBSD Foundation.
  *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD: head/sbin/mdconfig/mdconfig.c 230612 2012-01-27 11:48:44Z trasz $
  */
+
 #include <sys/param.h>
 #include <sys/devicestat.h>
 #include <sys/ioctl.h>
@@ -32,7 +53,6 @@
 #include <string.h>
 #include <unistd.h>
 
-
 static struct md_ioctl mdio;
 static enum {UNSET, ATTACH, DETACH, LIST} action = UNSET;
 static int nflag;
@@ -55,6 +75,7 @@
 static void
 usage(void)
 {
+
 	fprintf(stderr,
 "usage: mdconfig -a -t type [-n] [-o [no]option] ... [-f file]\n"
 "                [-s size] [-S sectorsize] [-u unit]\n"
@@ -75,8 +96,7 @@
 {
 	int ch, fd, i, vflag;
 	char *p;
-	int cmdline = 0;
-	char *mdunit = NULL;
+	char *fflag = NULL, *tflag = NULL, *uflag = NULL;
 
 	bzero(&mdio, sizeof(mdio));
 	mdio.md_file = malloc(PATH_MAX);
@@ -84,79 +104,59 @@
 		err(1, "could not allocate memory");
 	vflag = 0;
 	bzero(mdio.md_file, PATH_MAX);
+
+	if (argc == 1)
+		usage();
+
 	while ((ch = getopt(argc, argv, "ab:df:lno:s:S:t:u:vx:y:")) != -1) {
 		switch (ch) {
 		case 'a':
-			if (cmdline != 0)
-				usage();
+			if (action != UNSET && action != ATTACH)
+				errx(1,
+				    "-a is mutually exclusive with -d and -l");
 			action = ATTACH;
-			cmdline = 1;
 			break;
 		case 'd':
-			if (cmdline != 0)
-				usage();
+			if (action != UNSET && action != DETACH)
+				errx(1,
+				    "-d is mutually exclusive with -a and -l");
 			action = DETACH;
-			mdio.md_options = MD_AUTOUNIT;
-			cmdline = 3;
+			mdio.md_options |= MD_AUTOUNIT;
 			break;
 		case 'l':
-			if (cmdline != 0)
-				usage();
+			if (action != UNSET && action != LIST)
+				errx(1,
+				    "-l is mutually exclusive with -a and -d");
 			action = LIST;
-			mdio.md_options = MD_AUTOUNIT;
-			cmdline = 3;
+			mdio.md_options |= MD_AUTOUNIT;
 			break;
 		case 'n':
 			nflag = 1;
 			break;
 		case 't':
-			if (cmdline != 1)
-				usage();
+			if (tflag != NULL)
+				errx(1, "-t can be passed only once");
+			tflag = optarg;
 			if (!strcmp(optarg, "malloc")) {
 				mdio.md_type = MD_MALLOC;
-				mdio.md_options = MD_AUTOUNIT | MD_COMPRESS;
+				mdio.md_options |= MD_AUTOUNIT | MD_COMPRESS;
 			} else if (!strcmp(optarg, "preload")) {
 				mdio.md_type = MD_PRELOAD;
-				mdio.md_options = 0;
 			} else if (!strcmp(optarg, "vnode")) {
 				mdio.md_type = MD_VNODE;
-				mdio.md_options = MD_CLUSTER | MD_AUTOUNIT | MD_COMPRESS;
+				mdio.md_options |= MD_CLUSTER | MD_AUTOUNIT | MD_COMPRESS;
 			} else if (!strcmp(optarg, "swap")) {
 				mdio.md_type = MD_SWAP;
-				mdio.md_options = MD_CLUSTER | MD_AUTOUNIT | MD_COMPRESS;
-			} else {
-				usage();
-			}
-			cmdline=2;
+				mdio.md_options |= MD_CLUSTER | MD_AUTOUNIT | MD_COMPRESS;
+			} else
+				errx(1, "unknown type: %s", optarg);
 			break;
 		case 'f':
-			if (cmdline == 0) {
-				action = ATTACH;
-				cmdline = 1;
-			}
-			if (cmdline == 1) {
-				/* Imply ``-t vnode'' */
-				mdio.md_type = MD_VNODE;
-				mdio.md_options = MD_CLUSTER | MD_AUTOUNIT | MD_COMPRESS;
-				cmdline = 2;
-			}
-			if (cmdline != 2)
-				usage();
-			md_set_file(optarg);
+			if (fflag != NULL)
+				errx(1, "-f can be passed only once");
+			fflag = optarg;
 			break;
 		case 'o':
-			if (action == DETACH) {
-				if (!strcmp(optarg, "force"))
-					mdio.md_options |= MD_FORCE;
-				else if (!strcmp(optarg, "noforce"))
-					mdio.md_options &= ~MD_FORCE;
-				else
-					errx(1, "Unknown option: %s.", optarg);
-				break;
-			}
-
-			if (cmdline != 2)
-				usage();
 			if (!strcmp(optarg, "async"))
 				mdio.md_options |= MD_ASYNC;
 			else if (!strcmp(optarg, "noasync"))
@@ -182,27 +182,12 @@
 			else if (!strcmp(optarg, "noreserve"))
 				mdio.md_options &= ~MD_RESERVE;
 			else
-				errx(1, "Unknown option: %s.", optarg);
+				errx(1, "unknown option: %s", optarg);
 			break;
 		case 'S':
-			if (cmdline != 2)
-				usage();
 			mdio.md_sectorsize = strtoul(optarg, &p, 0);
 			break;
 		case 's':
-			if (cmdline == 0) {
-				/* Imply ``-a'' */
-				action = ATTACH;
-				cmdline = 1;
-			}
-			if (cmdline == 1) {
-				/* Imply ``-t swap'' */
-				mdio.md_type = MD_SWAP;
-				mdio.md_options = MD_CLUSTER | MD_AUTOUNIT | MD_COMPRESS;
-				cmdline = 2;
-			}
-			if (cmdline != 2)
-				usage();
 			mdio.md_mediasize = (off_t)strtoumax(optarg, &p, 0);
 			if (p == NULL || *p == '\0')
 				mdio.md_mediasize *= DEV_BSIZE;
@@ -218,34 +203,22 @@
 				mdio.md_mediasize <<= 30;
 				mdio.md_mediasize <<= 10;
 			} else
-				errx(1, "Unknown suffix on -s argument");
+				errx(1, "unknown suffix on -s argument");
 			break;
 		case 'u':
-			if (cmdline != 2 && cmdline != 3)
-				usage();
 			if (!strncmp(optarg, "/dev/", 5))
 				optarg += 5;
 			if (!strncmp(optarg, MD_NAME, sizeof(MD_NAME) - 1))
 				optarg += sizeof(MD_NAME) - 1;
-			mdio.md_unit = strtoul(optarg, &p, 0);
-			if (mdio.md_unit == (unsigned)ULONG_MAX || *p != '\0')
-				errx(1, "bad unit: %s", optarg);
-			mdunit = optarg;
-			mdio.md_options &= ~MD_AUTOUNIT;
+			uflag = optarg;
 			break;
 		case 'v':
-			if (cmdline != 3)
-				usage();
 			vflag = OPT_VERBOSE;
 			break;
 		case 'x':
-			if (cmdline != 2)
-				usage();
 			mdio.md_fwsectors = strtoul(optarg, &p, 0);
 			break;
 		case 'y':
-			if (cmdline != 2)
-				usage();
 			mdio.md_fwheads = strtoul(optarg, &p, 0);
 			break;
 		default:
@@ -255,14 +228,88 @@
 
 	argc -= optind;
 	argv += optind;
-	if (action == UNSET) {
-		if (argc != 1)
-			usage();
+
+	if (action == UNSET)
 		action = ATTACH;
-		mdio.md_type = MD_VNODE;
-		mdio.md_options = MD_CLUSTER | MD_AUTOUNIT | MD_COMPRESS;
-		cmdline = 2;
-		md_set_file(*argv);
+
+	if (action == ATTACH) {
+		if (tflag == NULL) {
+			/*
+			 * Try to infer the type based on other arguments.
+			 */
+			if (fflag != NULL || argc > 0) {
+				/* Imply ``-t vnode'' */
+				mdio.md_type = MD_VNODE;
+				mdio.md_options |= MD_CLUSTER | MD_AUTOUNIT |
+				    MD_COMPRESS;
+			} else if (mdio.md_mediasize != 0) {
+				/* Imply ``-t swap'' */
+				mdio.md_type = MD_SWAP;
+				mdio.md_options |= MD_CLUSTER | MD_AUTOUNIT |
+				    MD_COMPRESS;
+			} else
+				errx(1, "unable to determine type");
+		}
+
+		if ((fflag != NULL || argc > 0) && mdio.md_type != MD_VNODE)
+			errx(1, "only -t vnode can be used with file name");
+
+		if (mdio.md_type == MD_VNODE) {
+			if (fflag != NULL) {
+				if (argc != 0)
+					usage();
+				md_set_file(fflag);
+			} else {
+				if (argc != 1)
+					usage();
+				md_set_file(*argv);
+			}
+
+			if ((mdio.md_options & MD_READONLY) == 0 &&
+			    access(mdio.md_file, W_OK) < 0 &&
+			    (errno == EACCES || errno == EPERM ||
+			     errno == EROFS)) {
+				warnx("WARNING: opening backing store: %s "
+				    "readonly", mdio.md_file);
+				mdio.md_options |= MD_READONLY;
+			}
+		}
+
+		if ((mdio.md_type == MD_MALLOC || mdio.md_type == MD_SWAP) &&
+		    mdio.md_mediasize == 0)
+			errx(1, "must specify -s for -t malloc or -t swap");
+		if (mdio.md_type == MD_VNODE && mdio.md_file[0] == '\0')
+			errx(1, "must specify -f for -t vnode");
+	} else {
+		if (mdio.md_sectorsize != 0)
+			errx(1, "-S can only be used with -a");
+		if (mdio.md_mediasize != 0)
+			errx(1, "-s can only be used with -a");
+		if (mdio.md_fwsectors != 0)
+			errx(1, "-x can only be used with -a");
+		if (mdio.md_fwheads != 0)
+			errx(1, "-y can only be used with -a");
+		if (fflag != NULL)
+			errx(1, "-f can only be used with -a");
+		if (tflag != NULL)
+			errx(1, "-t can only be used with -a");
+		if (argc > 0)
+			errx(1, "file can only be used with -a");
+		if (action != DETACH && (mdio.md_options & ~MD_AUTOUNIT) != 0)
+			errx(1, "-o can only be used with -a and -d");
+		if (action == DETACH &&
+		    (mdio.md_options & ~(MD_FORCE | MD_AUTOUNIT)) != 0)
+			errx(1, "only -o [no]force can be used with -d");
+	}
+
+	if (action != LIST && vflag == OPT_VERBOSE)
+		errx(1, "-v can only be used with -l");
+
+	if (uflag != NULL) {
+		mdio.md_unit = strtoul(uflag, &p, 0);
+		if (mdio.md_unit == (unsigned)ULONG_MAX || *p != '\0')
+			errx(1, "bad unit: %s", uflag);
+		mdio.md_options &= ~MD_AUTOUNIT;
 	}
 
 	mdio.md_version = MDIOVERSION;
@@ -273,36 +320,8 @@
 	fd = open("/dev/" MDCTL_NAME, O_RDWR, 0);
 	if (fd < 0)
 		err(1, "open(/dev/%s)", MDCTL_NAME);
-	if (cmdline == 2
-	    && (mdio.md_type == MD_MALLOC || mdio.md_type == MD_SWAP))
-		if (mdio.md_mediasize == 0)
-			errx(1, "must specify -s for -t malloc or -t swap");
-	if (cmdline == 2 && mdio.md_type == MD_VNODE)
-		if (mdio.md_file[0] == '\0')
-			errx(1, "must specify -f for -t vnode");
-	if (mdio.md_type == MD_VNODE &&
-	    (mdio.md_options & MD_READONLY) == 0) {
-		if (access(mdio.md_file, W_OK) < 0 &&
-		    (errno == EACCES || errno == EPERM || errno == EROFS)) {
-			fprintf(stderr,
-			    "WARNING: opening backing store: %s readonly\n",
-			    mdio.md_file);
-			mdio.md_options |= MD_READONLY;
-		}
-	}
-	if (action == LIST) {
-		if (mdio.md_options & MD_AUTOUNIT) {
-			/*
-			 * Listing all devices. This is why we pass NULL
-			 * together with OPT_LIST.
-			 */
-			md_list(NULL, OPT_LIST | vflag);
-		} else {
-			return (md_query(mdunit));
-		}
-	} else if (action == ATTACH) {
-		if (cmdline < 2)
-			usage();
+
+	if (action == ATTACH) {
 		i = ioctl(fd, MDIOCATTACH, &mdio);
 		if (i < 0)
 			err(1, "ioctl(/dev/%s)", MDCTL_NAME);
@@ -310,13 +329,23 @@
 			printf("%s%d\n", nflag ? "" : MD_NAME, mdio.md_unit);
 	} else if (action == DETACH) {
 		if (mdio.md_options & MD_AUTOUNIT)
-			usage();
+			errx(1, "-d requires -u");
 		i = ioctl(fd, MDIOCDETACH, &mdio);
 		if (i < 0)
 			err(1, "ioctl(/dev/%s)", MDCTL_NAME);
+	} else if (action == LIST) {
+		if (mdio.md_options & MD_AUTOUNIT) {
+			/*
+			 * Listing all devices. This is why we pass NULL
+			 * together with OPT_LIST.
+			 */
+			md_list(NULL, OPT_LIST | vflag);
+		} else
+			return (md_query(uflag));
+
 	} else
 		usage();
-	close (fd);
+	close(fd);
 	return (0);
 }
 
@@ -490,5 +519,6 @@
 int
 md_query(char *name)
 {
+
 	return (md_list(name, OPT_UNIT));
 }
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sbin/mount/getmntopts.c
--- a/head/sbin/mount/getmntopts.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sbin/mount/getmntopts.c	Wed Feb 01 12:34:54 2012 +0200
@@ -33,7 +33,7 @@
 #endif /* not lint */
 #endif
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: head/sbin/mount/getmntopts.c 230372 2012-01-20 07:29:29Z jh $");
 
 #include <sys/param.h>
 #include <sys/mount.h>
@@ -46,7 +46,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sysexits.h>
 
 #include "mntopts.h"
 
@@ -124,16 +123,18 @@
 		*rrpout = '\0';
 }
 
-void
+int
 checkpath(const char *path, char *resolved)
 {
 	struct stat sb;
 
-	if (realpath(path, resolved) != NULL && stat(resolved, &sb) == 0) {
-		if (!S_ISDIR(sb.st_mode))
-			errx(EX_USAGE, "%s: not a directory", resolved);
-	} else
-		errx(EX_USAGE, "%s: %s", resolved, strerror(errno));
+	if (realpath(path, resolved) == NULL || stat(resolved, &sb) != 0)
+		return (1);
+	if (!S_ISDIR(sb.st_mode)) {
+		errno = ENOTDIR;
+		return (1);
+	}
+	return (0);
 }
 
 void
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sbin/mount/mntopts.h
--- a/head/sbin/mount/mntopts.h	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sbin/mount/mntopts.h	Wed Feb 01 12:34:54 2012 +0200
@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)mntopts.h	8.7 (Berkeley) 3/29/95
- * $FreeBSD$
+ * $FreeBSD: head/sbin/mount/mntopts.h 230226 2012-01-16 19:34:21Z jh $
  */
 
 struct mntopt {
@@ -93,7 +93,7 @@
 
 void getmntopts(const char *, const struct mntopt *, int *, int *);
 void rmslashes(char *, char *);
-void checkpath(const char *, char resolved_path[]);
+int checkpath(const char *, char resolved_path[]);
 extern int getmnt_silent;
 void build_iovec(struct iovec **iov, int *iovlen, const char *name, void *val, size_t len);
 void build_iovec_argf(struct iovec **iov, int *iovlen, const char *name, const char *fmt, ...);
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sbin/mount/mount.c
--- a/head/sbin/mount/mount.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sbin/mount/mount.c	Wed Feb 01 12:34:54 2012 +0200
@@ -37,7 +37,7 @@
 #endif /* not lint */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sbin/mount/mount.c 227081 2011-11-04 13:36:02Z ed $");
+__FBSDID("$FreeBSD: head/sbin/mount/mount.c 230226 2012-01-16 19:34:21Z jh $");
 
 #include <sys/param.h>
 #include <sys/mount.h>
@@ -539,7 +539,10 @@
 	static struct cpa mnt_argv;
 
 	/* resolve the mountpoint with realpath(3) */
-	(void)checkpath(name, mntpath);
+	if (checkpath(name, mntpath) != 0) {
+		warn("%s", mntpath);
+		return (1);
+	}
 	name = mntpath;
 
 	if (mntopts == NULL)
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sbin/mount/mount_fs.c
--- a/head/sbin/mount/mount_fs.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sbin/mount/mount_fs.c	Wed Feb 01 12:34:54 2012 +0200
@@ -41,7 +41,7 @@
 static char sccsid[] = "@(#)mount_fs.c	8.6 (Berkeley) 4/26/95";
 #endif
 static const char rcsid[] =
-	"$FreeBSD: head/sbin/mount/mount_fs.c 227081 2011-11-04 13:36:02Z ed $";
+	"$FreeBSD: head/sbin/mount/mount_fs.c 230377 2012-01-20 12:59:12Z jh $";
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -82,7 +82,6 @@
 	char fstype[32];
 	char errmsg[255];
 	char *p, *val;
-	int ret;
 
 	strlcpy(fstype, vfstype, sizeof(fstype));
 	memset(errmsg, 0, sizeof(errmsg));
@@ -118,17 +117,23 @@
 	dev = argv[0];
 	dir = argv[1];
 
-	(void)checkpath(dir, mntpath);
+	if (checkpath(dir, mntpath) != 0) {
+		warn("%s", mntpath);
+		return (1);
+	}
 	(void)rmslashes(dev, dev);
 
 	build_iovec(&iov, &iovlen, "fstype", fstype, (size_t)-1);
 	build_iovec(&iov, &iovlen, "fspath", mntpath, (size_t)-1);
 	build_iovec(&iov, &iovlen, "from", dev, (size_t)-1);
 	build_iovec(&iov, &iovlen, "errmsg", errmsg, sizeof(errmsg));
-	
-	ret = nmount(iov, iovlen, mntflags);
-	if (ret < 0)
-		err(1, "%s %s", dev, errmsg);
 
-	return (ret);
+	if (nmount(iov, iovlen, mntflags) == -1) {
+		if (*errmsg != '\0')
+			warn("%s: %s", dev, errmsg);
+		else
+			warn("%s", dev);
+		return (1);
+	}
+	return (0);
 }
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sbin/mount_cd9660/mount_cd9660.c
--- a/head/sbin/mount_cd9660/mount_cd9660.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sbin/mount_cd9660/mount_cd9660.c	Wed Feb 01 12:34:54 2012 +0200
@@ -45,7 +45,7 @@
 static char sccsid[] = "@(#)mount_cd9660.c	8.7 (Berkeley) 5/1/95";
 */
 static const char rcsid[] =
-  "$FreeBSD: head/sbin/mount_cd9660/mount_cd9660.c 227081 2011-11-04 13:36:02Z ed $";
+  "$FreeBSD: head/sbin/mount_cd9660/mount_cd9660.c 230226 2012-01-16 19:34:21Z jh $";
 #endif /* not lint */
 
 #include <sys/cdio.h>
@@ -149,7 +149,8 @@
 	 * Resolve the mountpoint with realpath(3) and remove unnecessary
 	 * slashes from the devicename if there are any.
 	 */
-	(void)checkpath(dir, mntpath);
+	if (checkpath(dir, mntpath) != 0)
+		err(1, "%s", mntpath);
 	(void)rmslashes(dev, dev);
 
 	if (ssector == -1) {
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sbin/mount_ext2fs/mount_ext2fs.c
--- a/head/sbin/mount_ext2fs/mount_ext2fs.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sbin/mount_ext2fs/mount_ext2fs.c	Wed Feb 01 12:34:54 2012 +0200
@@ -38,7 +38,7 @@
 static char sccsid[] = "@(#)mount_lfs.c	8.3 (Berkeley) 3/27/94";
 */
 static const char rcsid[] =
-  "$FreeBSD$";
+  "$FreeBSD: head/sbin/mount_ext2fs/mount_ext2fs.c 230226 2012-01-16 19:34:21Z jh $";
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -103,7 +103,8 @@
 	 * Resolve the mountpoint with realpath(3) and remove unnecessary
 	 * slashes from the devicename if there are any.
 	 */
-	(void)checkpath(fs_name, mntpath);
+	if (checkpath(fs_name, mntpath) != 0)
+		err(EX_USAGE, "%s", mntpath);
 	(void)rmslashes(fspec, fspec);
 
 	build_iovec(&iov, &iovlen, "fstype", fstype, strlen(fstype) + 1);
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sbin/mount_msdosfs/mount_msdosfs.c
--- a/head/sbin/mount_msdosfs/mount_msdosfs.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sbin/mount_msdosfs/mount_msdosfs.c	Wed Feb 01 12:34:54 2012 +0200
@@ -32,7 +32,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-  "$FreeBSD$";
+  "$FreeBSD: head/sbin/mount_msdosfs/mount_msdosfs.c 230226 2012-01-16 19:34:21Z jh $";
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -193,7 +193,8 @@
 	 * Resolve the mountpoint with realpath(3) and remove unnecessary
 	 * slashes from the devicename if there are any.
 	 */
-	(void)checkpath(dir, mntpath);
+	if (checkpath(dir, mntpath) != 0)
+		err(EX_USAGE, "%s", mntpath);
 	(void)rmslashes(dev, dev);
 
 	if (!set_gid || !set_uid || !set_mask) {
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sbin/mount_nfs/mount_nfs.8
--- a/head/sbin/mount_nfs/mount_nfs.8	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sbin/mount_nfs/mount_nfs.8	Wed Feb 01 12:34:54 2012 +0200
@@ -26,7 +26,7 @@
 .\" SUCH DAMAGE.
 .\"
 .\"	@(#)mount_nfs.8	8.3 (Berkeley) 3/29/95
-.\" $FreeBSD: head/sbin/mount_nfs/mount_nfs.8 227507 2011-11-14 18:52:07Z jhb $
+.\" $FreeBSD: head/sbin/mount_nfs/mount_nfs.8 230547 2012-01-25 20:05:58Z jhb $
 .\"
 .Dd May 3, 2011
 .Dt MOUNT_NFS 8
@@ -157,6 +157,10 @@
 (Necessary for some old
 .Bx
 servers.)
+.It Cm nametimeo Ns = Ns Aq Ar value
+Override the default of NFS_DEFAULT_NAMETIMEO for the timeout (in seconds)
+for positive name cache entries.
+If this is set to 0 it disables positive name caching for the mount point.
 .It Cm negnametimeo Ns = Ns Aq Ar value
 Override the default of NFS_DEFAULT_NEGNAMETIMEO for the timeout (in seconds)
 for negative name cache entries. If this is set to 0 it disables negative
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sbin/mount_nfs/mount_nfs.c
--- a/head/sbin/mount_nfs/mount_nfs.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sbin/mount_nfs/mount_nfs.c	Wed Feb 01 12:34:54 2012 +0200
@@ -42,7 +42,7 @@
 #endif /* not lint */
 #endif
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sbin/mount_nfs/mount_nfs.c 229778 2012-01-07 16:09:33Z uqs $");
+__FBSDID("$FreeBSD: head/sbin/mount_nfs/mount_nfs.c 230226 2012-01-16 19:34:21Z jh $");
 
 #include <sys/param.h>
 #include <sys/linker.h>
@@ -411,7 +411,8 @@
 		exit(1);
 
 	/* resolve the mountpoint with realpath(3) */
-	(void)checkpath(name, mntpath);
+	if (checkpath(name, mntpath) != 0)
+		err(1, "%s", mntpath);
 
 	build_iovec(&iov, &iovlen, "fstype", fstype, (size_t)-1);
 	build_iovec(&iov, &iovlen, "fspath", mntpath, (size_t)-1);
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sbin/mount_ntfs/mount_ntfs.c
--- a/head/sbin/mount_ntfs/mount_ntfs.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sbin/mount_ntfs/mount_ntfs.c	Wed Feb 01 12:34:54 2012 +0200
@@ -28,7 +28,7 @@
  * (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$
+ * $FreeBSD: head/sbin/mount_ntfs/mount_ntfs.c 230642 2012-01-28 13:41:34Z jh $
  *
  */
 
@@ -160,10 +160,11 @@
 	}
 
 	/*
-	 * Resolve the mountpoint with realpath(3) and remove unnecessary 
+	 * Resolve the mountpoint with realpath(3) and remove unnecessary
 	 * slashes from the devicename if there are any.
 	 */
-	(void)checkpath(dir, mntpath);
+	if (checkpath(dir, mntpath) != 0)
+		err(EX_USAGE, "%s", mntpath);
 	(void)rmslashes(dev, dev);
 
 	args.fspec = dev;
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sbin/mount_nullfs/mount_nullfs.c
--- a/head/sbin/mount_nullfs/mount_nullfs.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sbin/mount_nullfs/mount_nullfs.c	Wed Feb 01 12:34:54 2012 +0200
@@ -41,7 +41,7 @@
 static char sccsid[] = "@(#)mount_null.c	8.6 (Berkeley) 4/26/95";
 #endif
 static const char rcsid[] =
-  "$FreeBSD: head/sbin/mount_nullfs/mount_nullfs.c 227081 2011-11-04 13:36:02Z ed $";
+  "$FreeBSD: head/sbin/mount_nullfs/mount_nullfs.c 230226 2012-01-16 19:34:21Z jh $";
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -90,8 +90,10 @@
 		usage();
 
 	/* resolve target and source with realpath(3) */
-	(void)checkpath(argv[0], target);
-	(void)checkpath(argv[1], source);
+	if (checkpath(argv[0], target) != 0)
+		err(EX_USAGE, "%s", target);
+	if (checkpath(argv[1], source) != 0)
+		err(EX_USAGE, "%s", source);
 
 	if (subdir(target, source) || subdir(source, target))
 		errx(EX_USAGE, "%s (%s) and %s are not distinct paths",
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sbin/mount_reiserfs/mount_reiserfs.c
--- a/head/sbin/mount_reiserfs/mount_reiserfs.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sbin/mount_reiserfs/mount_reiserfs.c	Wed Feb 01 12:34:54 2012 +0200
@@ -23,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: head/sbin/mount_reiserfs/mount_reiserfs.c 222176 2011-05-22 14:03:30Z uqs $
+ * $FreeBSD: head/sbin/mount_reiserfs/mount_reiserfs.c 230226 2012-01-16 19:34:21Z jh $
  */
 
 #include <sys/param.h>
@@ -78,7 +78,8 @@
 	 * Resolve the mountpoint with realpath(3) and remove unnecessary
 	 * slashes from the devicename if there are any.
 	 */
-	(void)checkpath(dir, mntpath);
+	if (checkpath(dir, mntpath) != 0)
+		err(EX_USAGE, "%s", mntpath);
 	(void)rmslashes(dev, dev);
 
 	/* Read-only support for now */
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sbin/mount_std/mount_std.c
--- a/head/sbin/mount_std/mount_std.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sbin/mount_std/mount_std.c	Wed Feb 01 12:34:54 2012 +0200
@@ -38,7 +38,7 @@
 #endif /* not lint */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: head/sbin/mount_std/mount_std.c 230226 2012-01-16 19:34:21Z jh $");
 
 #include <sys/param.h>
 #include <sys/mount.h>
@@ -112,7 +112,8 @@
 		usage();
 
 	/* resolve the mountpoint with realpath(3) */
-	(void)checkpath(argv[1], mntpath);
+	if (checkpath(argv[1], mntpath) != 0)
+		err(EX_USAGE, "%s", mntpath);
 
 	iov[0].iov_base = "fstype";
 	iov[0].iov_len = sizeof("fstype");
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sbin/mount_udf/mount_udf.c
--- a/head/sbin/mount_udf/mount_udf.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sbin/mount_udf/mount_udf.c	Wed Feb 01 12:34:54 2012 +0200
@@ -32,7 +32,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: head/sbin/mount_udf/mount_udf.c 227081 2011-11-04 13:36:02Z ed $
+ * $FreeBSD: head/sbin/mount_udf/mount_udf.c 230226 2012-01-16 19:34:21Z jh $
  */
 
 /*
@@ -111,7 +111,8 @@
 	 * Resolve the mountpoint with realpath(3) and remove unnecessary
 	 * slashes from the devicename if there are any.
 	 */
-	(void)checkpath(dir, mntpath);
+	if (checkpath(dir, mntpath) != 0)
+		err(EX_USAGE, "%s", mntpath);
 	(void)rmslashes(dev, dev);
 
 	/*
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sbin/mount_unionfs/mount_unionfs.c
--- a/head/sbin/mount_unionfs/mount_unionfs.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sbin/mount_unionfs/mount_unionfs.c	Wed Feb 01 12:34:54 2012 +0200
@@ -44,7 +44,7 @@
 static char sccsid[] = "@(#)mount_union.c	8.5 (Berkeley) 3/27/94";
 #else
 static const char rcsid[] =
-  "$FreeBSD$";
+  "$FreeBSD: head/sbin/mount_unionfs/mount_unionfs.c 230226 2012-01-16 19:34:21Z jh $";
 #endif
 #endif /* not lint */
 
@@ -176,8 +176,10 @@
 		usage();
 
 	/* resolve both target and source with realpath(3) */
-	(void)checkpath(argv[0], target);
-	(void)checkpath(argv[1], source);
+	if (checkpath(argv[0], target) != 0)
+		err(EX_USAGE, "%s", target);
+	if (checkpath(argv[1], source) != 0)
+		err(EX_USAGE, "%s", source);
 
 	if (subdir(target, source) || subdir(source, target))
 		errx(EX_USAGE, "%s (%s) and %s (%s) are not distinct paths",
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sbin/reboot/nextboot.8
--- a/head/sbin/reboot/nextboot.8	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sbin/reboot/nextboot.8	Wed Feb 01 12:34:54 2012 +0200
@@ -22,9 +22,9 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\" $FreeBSD: head/sbin/reboot/nextboot.8 229778 2012-01-07 16:09:33Z uqs $
+.\" $FreeBSD: head/sbin/reboot/nextboot.8 230812 2012-01-31 15:32:05Z emaste $
 .\"
-.Dd November 4, 2002
+.Dd January 31, 2012
 .Dt NEXTBOOT 8
 .Os
 .Sh NAME
@@ -32,15 +32,17 @@
 .Nd "specify an alternate kernel and boot flags for the next reboot"
 .Sh SYNOPSIS
 .Nm
+.Op Fl e Ar variable=value
 .Op Fl f
+.Op Fl k Ar kernel
 .Op Fl o Ar options
-.Fl k Ar kernel
 .Nm
 .Fl D
 .Sh DESCRIPTION
 The
 .Nm
-utility allows specifying an alternate kernel and/or boot flags for the
+utility allows specifying some combination of an alternate kernel, boot flags
+and kernel environment for the
 next time the machine is booted.
 Once the
 .Xr loader 8
@@ -58,6 +60,11 @@
 option removes an existing
 .Nm
 configuration.
+.It Fl e Ar variable=value
+This option adds the provided variable and value to the kernel environment.
+The value is quoted when written to the
+.Nm
+configuration.
 .It Fl f
 This
 option disables the sanity checking which checks if the kernel really exists
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sbin/reboot/nextboot.sh
--- a/head/sbin/reboot/nextboot.sh	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sbin/reboot/nextboot.sh	Wed Feb 01 12:34:54 2012 +0200
@@ -2,31 +2,59 @@
 #
 # Copyright 2002. Gordon Tetlow.
 # gordon at FreeBSD.org
+# Copyright (c) 2012 Sandvine Incorporated. All rights reserved.
 #
-# $FreeBSD$
+# $FreeBSD: head/sbin/reboot/nextboot.sh 230812 2012-01-31 15:32:05Z emaste $
 
 delete="NO"
+kenv=
 force="NO"
 nextboot_file="/boot/nextboot.conf"
 
+add_kenv()
+{
+	local var value
+
+	var=$1
+	# strip literal quotes if passed in
+	value=${2%\"*}
+	value=${value#*\"}
+
+	if [ -n "${kenv}" ]; then
+		kenv="${kenv}
+"
+	fi
+	kenv="${kenv}${var}=\"${value}\""
+}
+
 display_usage() {
-	echo "Usage: nextboot [-f] [-o options] -k kernel"
+	echo "Usage: nextboot [-e variable=value] [-f] [-k kernel] [-o options]"
 	echo "       nextboot -D"
 }
 
-while getopts "Dfk:o:" argument ; do
+while getopts "De:fk:o:" argument ; do
 	case "${argument}" in
 	D)
 		delete="YES"
 		;;
+	e)
+		var=${OPTARG%%=*}
+		value=${OPTARG#*=}
+		if [ -z "$var" -o -z "$value" ]; then
+			display_usage
+			exit 1
+		fi
+		add_kenv "$var" "$value"
+		;;
 	f)
 		force="YES"
 		;;
 	k)
 		kernel="${OPTARG}"
+		add_kenv kernel "$kernel"
 		;;
 	o)
-		kernel_options="${OPTARG}"
+		add_kenv kernel_options "${OPTARG}"
 		;;
 	*)
 		display_usage
@@ -40,12 +68,12 @@
 	exit 0
 fi
 
-if [ "xxx${kernel}" = "xxx" ]; then
+if [ -z "${kenv}" ]; then
 	display_usage
 	exit 1
 fi
 
-if [ ${force} = "NO" -a ! -d /boot/${kernel} ]; then
+if [ -n "${kernel}" -a ${force} = "NO" -a ! -d /boot/${kernel} ]; then
 	echo "Error: /boot/${kernel} doesn't exist. Use -f to override."
 	exit 1
 fi
@@ -60,6 +88,5 @@
 
 cat > ${nextboot_file} << EOF
 nextboot_enable="YES"
-kernel="${kernel}"
-kernel_options="${kernel_options}"
+$kenv
 EOF
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/share/examples/etc/make.conf
--- a/head/share/examples/etc/make.conf	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/share/examples/etc/make.conf	Wed Feb 01 12:34:54 2012 +0200
@@ -1,4 +1,4 @@
-# $FreeBSD: head/share/examples/etc/make.conf 223148 2011-06-16 12:28:37Z ru $
+# $FreeBSD: head/share/examples/etc/make.conf 230306 2012-01-18 14:41:26Z schweikh $
 #
 # NOTE:  Please would any committer updating this file also update the
 # make.conf(5) manual page, if necessary, which is located in
@@ -91,13 +91,13 @@
 #
 #COPTFLAGS= -O -pipe
 #
-# Compare before install
+# Compare before install.
 #INSTALL=install -C
 #
-# Mtree will follow symlinks
+# Mtree will follow symlinks.
 #MTREE_FOLLOWS_SYMLINKS= -L
 #
-# To enable installing ssh(1) with the setuid bit turned on
+# To enable installing ssh(1) with the setuid bit turned on.
 #ENABLE_SUID_SSH=
 #
 # To enable installing newgrp(1) with the setuid bit turned on.
@@ -117,7 +117,7 @@
 #
 #TRACEROUTE_NO_IPSEC= 	# do not build traceroute(8) with IPSEC support
 #
-# To build sys/modules when building the world (our old way of doing things)
+# To build sys/modules when building the world (our old way of doing things).
 #MODULES_WITH_WORLD=	# do not build modules when building kernel
 #
 # The list of modules to build instead of all of them.
@@ -133,7 +133,7 @@
 #
 #
 # Default format for system documentation, depends on your printer.
-# Set this to "ascii" for simple printers or screen
+# Set this to "ascii" for simple printers or screen.
 #
 #PRINTERDEVICE=	ps
 #
@@ -199,7 +199,7 @@
 #
 # Documentation
 #
-# The list of languages and encodings to build and install
+# The list of languages and encodings to build and install.
 #
 #DOC_LANG=	en_US.ISO8859-1 ru_RU.KOI8-R
 #
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/arm/arm/machdep.c
--- a/head/sys/arm/arm/machdep.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/arm/arm/machdep.c	Wed Feb 01 12:34:54 2012 +0200
@@ -46,7 +46,7 @@
 #include "opt_ddb.h"
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/arm/arm/machdep.c 226441 2011-10-16 17:37:54Z cognet $");
+__FBSDID("$FreeBSD: head/sys/arm/arm/machdep.c 230455 2012-01-22 11:01:36Z pjd $");
 
 #include <sys/param.h>
 #include <sys/proc.h>
@@ -137,7 +137,7 @@
 	    catcher, sig);
 
 	/* Allocate and validate space for the signal handler context. */
-	if ((td->td_flags & TDP_ALTSTACK) != 0 && !(onstack) &&
+	if ((td->td_pflags & TDP_ALTSTACK) != 0 && !(onstack) &&
 	    SIGISMEMBER(psp->ps_sigonstack, sig)) {
 		fp = (struct sigframe *)(td->td_sigstk.ss_sp + 
 		    td->td_sigstk.ss_size);
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/arm/include/_types.h
--- a/head/sys/arm/include/_types.h	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/arm/include/_types.h	Wed Feb 01 12:34:54 2012 +0200
@@ -33,7 +33,7 @@
  *
  *	From: @(#)ansi.h	8.2 (Berkeley) 1/4/94
  *	From: @(#)types.h	8.3 (Berkeley) 1/5/94
- * $FreeBSD: head/sys/arm/include/_types.h 228469 2011-12-13 13:38:03Z ed $
+ * $FreeBSD: head/sys/arm/include/_types.h 230229 2012-01-16 20:17:51Z das $
  */
 
 #ifndef _MACHINE__TYPES_H_
@@ -69,7 +69,7 @@
 typedef	__uint32_t	__clock_t;		/* clock()... */
 typedef	__int32_t	__critical_t;
 typedef	double		__double_t;
-typedef	double		__float_t;
+typedef	float		__float_t;
 typedef	__int32_t	__intfptr_t;
 typedef	__int64_t	__intmax_t;
 typedef	__int32_t	__intptr_t;
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/arm/include/float.h
--- a/head/sys/arm/include/float.h	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/arm/include/float.h	Wed Feb 01 12:34:54 2012 +0200
@@ -31,7 +31,7 @@
  * SUCH DAMAGE.
  *
  *	from: @(#)float.h	7.1 (Berkeley) 5/8/90
- * $FreeBSD: head/sys/arm/include/float.h 230198 2012-01-16 05:23:13Z das $
+ * $FreeBSD: head/sys/arm/include/float.h 230475 2012-01-23 06:36:41Z das $
  */
 
 #ifndef _MACHINE_FLOAT_H_
@@ -63,6 +63,11 @@
 #define FLT_MAX_EXP	128		/* emax */
 #define FLT_MAX		3.40282347E+38F	/* (1-b**(-p))*b**emax */
 #define FLT_MAX_10_EXP	38		/* floor(log10((1-b**(-p))*b**emax)) */
+#if __ISO_C_VISIBLE >= 2011
+#define	FLT_TRUE_MIN	1.40129846E-45F	/* b**(emin-p) */
+#define	FLT_DECIMAL_DIG	9		/* ceil(1+p*log10(b)) */
+#define	FLT_HAS_SUBNORM	1
+#endif /* __ISO_C_VISIBLE >= 2011 */
 
 #define DBL_MANT_DIG	53
 #define DBL_EPSILON	2.2204460492503131E-16
@@ -73,14 +78,25 @@
 #define DBL_MAX_EXP	1024
 #define DBL_MAX		1.7976931348623157E+308
 #define DBL_MAX_10_EXP	308
+#if __ISO_C_VISIBLE >= 2011
+#define	DBL_TRUE_MIN	4.9406564584124654E-324
+#define	DBL_DECIMAL_DIG	17
+#define	DBL_HAS_SUBNORM	1
+#endif /* __ISO_C_VISIBLE >= 2011 */
 
 #define LDBL_MANT_DIG	DBL_MANT_DIG
-#define LDBL_EPSILON	(long double)DBL_EPSILON
+#define LDBL_EPSILON	((long double)DBL_EPSILON)
 #define LDBL_DIG	DBL_DIG
 #define LDBL_MIN_EXP	DBL_MIN_EXP
-#define LDBL_MIN	(long double)DBL_MIN
+#define LDBL_MIN	((long double)DBL_MIN)
 #define LDBL_MIN_10_EXP	DBL_MIN_10_EXP
 #define LDBL_MAX_EXP	DBL_MAX_EXP
-#define LDBL_MAX	(long double)DBL_MAX
+#define LDBL_MAX	((long double)DBL_MAX)
 #define LDBL_MAX_10_EXP	DBL_MAX_10_EXP
+#if __ISO_C_VISIBLE >= 2011
+#define	LDBL_TRUE_MIN	((long double)DBL_TRUE_MIN)
+#define	LDBL_DECIMAL_DIG DBL_DECIMAL_DIG
+#define	LDBL_HAS_SUBNORM DBL_HAS_SUBNORM
+#endif /* __ISO_C_VISIBLE >= 2011 */
+
 #endif /* _MACHINE_FLOAT_H_ */
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/boot/forth/menu.rc
--- a/head/sys/boot/forth/menu.rc	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/boot/forth/menu.rc	Wed Feb 01 12:34:54 2012 +0200
@@ -1,5 +1,5 @@
 \ Menu.rc
-\ $FreeBSD: head/sys/boot/forth/menu.rc 222417 2011-05-28 08:50:38Z julian $
+\ $FreeBSD: head/sys/boot/forth/menu.rc 230545 2012-01-25 18:36:01Z pluknet $
 \
 \ Load required Forth modules
 include /boot/version.4th
@@ -18,9 +18,9 @@
 \ Initialize main menu constructs (see `menu.4th')
 \ NOTE: To use the `ansi' variants, add `loader_color=1' to loader.conf(5)
 
-set menu_caption[1]="Boot [ENTER]"
+set menu_caption[1]="Boot [Enter]"
 set menu_command[1]="boot"
-set ansi_caption[1]="Boot [ENTER]"
+set ansi_caption[1]="Boot [Enter]"
 set menu_keycode[1]="98"
 
 set menu_caption[2]="[Esc]ape to loader prompt"
@@ -38,34 +38,34 @@
 \ 
 set menu_options=4
 
-set menu_caption[4]="[A]CPI Support: Disabled"
-set toggled_text[4]="[A]CPI Support: Enabled"
+set menu_caption[4]="[A]CPI Support off"
+set toggled_text[4]="[A]CPI Support On"
 set menu_command[4]="toggle_acpi"
 set menu_keycode[4]="97"
 set menu_acpi=4
-set ansi_caption[4]="ACPI Support: Disabled"
-set toggled_ansi[4]="ACPI Support: Enabled"
+set ansi_caption[4]="ACPI Support Off"
+set toggled_ansi[4]="ACPI Support On"
 
-set menu_caption[5]="Boot Safe [M]ode: NO"
-set toggled_text[5]="Boot Safe [M]ode: YES"
+set menu_caption[5]="Safe [M]ode... off"
+set toggled_text[5]="Safe [M]ode... On"
 set menu_command[5]="toggle_safemode"
 set menu_keycode[5]="109"
-set ansi_caption[5]="Boot Safe Mode: NO"
-set toggled_ansi[5]="Boot Safe Mode: YES"
+set ansi_caption[5]="Safe Mode... Off"
+set toggled_ansi[5]="Safe Mode... On"
 
-set menu_caption[6]="Boot [S]ingle User: NO"
-set toggled_text[6]="Boot [S]ingle User: YES"
+set menu_caption[6]="[S]ingle User. off"
+set toggled_text[6]="[S]ingle User. On"
 set menu_command[6]="toggle_singleuser"
 set menu_keycode[6]="115"
-set ansi_caption[6]="Boot Single User: NO"
-set toggled_ansi[6]="Boot Single User: YES"
+set ansi_caption[6]="Single User. Off"
+set toggled_ansi[6]="Single User. On"
 
-set menu_caption[7]="Boot [V]erbose: NO"
-set toggled_text[7]="Boot [V]erbose: YES"
+set menu_caption[7]="[V]erbose..... off"
+set toggled_text[7]="[V]erbose..... On"
 set menu_command[7]="toggle_verbose"
 set menu_keycode[7]="118"
-set ansi_caption[7]="Boot Verbose: NO"
-set toggled_ansi[7]="Boot Verbose: YES"
+set ansi_caption[7]="Verbose..... Off"
+set toggled_ansi[7]="Verbose..... On"
 
 \ Enable automatic booting (add ``autoboot_delay=N'' to loader.conf(5) to
 \ customize the timeout; default is 10-seconds)
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/boot/i386/libi386/pxe.c
--- a/head/sys/boot/i386/libi386/pxe.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/boot/i386/libi386/pxe.c	Wed Feb 01 12:34:54 2012 +0200
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: head/sys/boot/i386/libi386/pxe.c 230325 2012-01-19 01:25:50Z sbruno $");
 
 #include <stand.h>
 #include <string.h>
@@ -405,6 +405,7 @@
 	return;
 }
 
+#ifdef LOADER_NFS_SUPPORT
 /*
  * Reach inside the libstand NFS code and dig out an NFS handle
  * for the root filesystem.
@@ -515,6 +516,7 @@
 	setenv("boot.nfsroot.nfshandlelen", buf, 1);
 }
 #endif	/* OLD_NFSV2 */
+#endif /* LOADER_NFS_SUPPORT */
 
 void
 pxenv_call(int func)
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/boot/powerpc/boot1.chrp/Makefile
--- a/head/sys/boot/powerpc/boot1.chrp/Makefile	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/boot/powerpc/boot1.chrp/Makefile	Wed Feb 01 12:34:54 2012 +0200
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/sys/boot/powerpc/boot1.chrp/Makefile 230522 2012-01-25 03:37:39Z nwhitehorn $
 
 WITHOUT_SSP=
 
@@ -10,7 +10,6 @@
 FILES=		boot1.hfs
 SRCS=		boot1.c ashldi3.c
 
-INTERNALPROG=
 NO_MAN=
 
 CFLAGS= -ffreestanding -msoft-float -Os \
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/conf/files
--- a/head/sys/conf/files	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/conf/files	Wed Feb 01 12:34:54 2012 +0200
@@ -1,4 +1,4 @@
-# $FreeBSD: head/sys/conf/files 230130 2012-01-15 13:21:36Z mav $
+# $FreeBSD: head/sys/conf/files 230775 2012-01-30 16:42:02Z jfv $
 #
 # The long compile-with and dependency lines are required because of
 # limitations in config: backslash-newline doesn't work in strings, and
@@ -1398,6 +1398,8 @@
 	compile-with "${NORMAL_C} -I$S/dev/ixgbe"
 dev/ixgbe/ixgbe_82599.c		optional ixgbe inet \
 	compile-with "${NORMAL_C} -I$S/dev/ixgbe"
+dev/ixgbe/ixgbe_x540.c		optional ixgbe inet \
+	compile-with "${NORMAL_C} -I$S/dev/ixgbe"
 dev/jme/if_jme.c		optional jme pci
 dev/joy/joy.c			optional joy
 dev/joy/joy_isa.c		optional joy isa
@@ -1473,8 +1475,11 @@
 dev/mmc/mmcsd.c			optional mmcsd
 dev/mn/if_mn.c			optional mn pci
 dev/mps/mps.c			optional mps
+dev/mps/mps_config.c		optional mps
+dev/mps/mps_mapping.c		optional mps
 dev/mps/mps_pci.c		optional mps pci
 dev/mps/mps_sas.c		optional mps
+dev/mps/mps_sas_lsi.c		optional mps
 dev/mps/mps_table.c		optional mps
 dev/mps/mps_user.c		optional mps
 dev/mpt/mpt.c			optional mpt
@@ -1752,8 +1757,7 @@
 dev/sound/pci/fm801.c		optional snd_fm801 pci
 dev/sound/pci/ich.c		optional snd_ich pci
 dev/sound/pci/maestro.c		optional snd_maestro pci
-dev/sound/pci/maestro3.c	optional snd_maestro3 pci \
-	warning "kernel contains GPL contaminated maestro3 headers"
+dev/sound/pci/maestro3.c	optional snd_maestro3 pci
 dev/sound/pci/neomagic.c	optional snd_neomagic pci
 dev/sound/pci/solo.c		optional snd_solo pci
 dev/sound/pci/spicds.c		optional snd_spicds pci
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/conf/files.amd64
--- a/head/sys/conf/files.amd64	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/conf/files.amd64	Wed Feb 01 12:34:54 2012 +0200
@@ -1,7 +1,7 @@
 # This file tells config what files go into building a kernel,
 # files marked standard are always included.
 #
-# $FreeBSD: head/sys/conf/files.amd64 229887 2012-01-09 23:20:30Z jkim $
+# $FreeBSD: head/sys/conf/files.amd64 230843 2012-01-31 19:38:18Z jimharris $
 #
 # The long compile-with and dependency lines are required because of
 # limitations in config: backslash-newline doesn't work in strings, and
@@ -124,6 +124,7 @@
 amd64/amd64/mpboot.S		optional	smp
 amd64/amd64/pmap.c		standard
 amd64/amd64/prof_machdep.c	optional	profiling-routine
+amd64/amd64/ptrace_machdep.c	standard
 amd64/amd64/sigtramp.S		standard
 amd64/amd64/stack_machdep.c	optional	ddb | stack
 amd64/amd64/support.S		standard
@@ -270,6 +271,115 @@
 dev/uart/uart_cpu_amd64.c	optional	uart
 dev/viawd/viawd.c		optional	viawd
 dev/wpi/if_wpi.c		optional	wpi
+dev/isci/isci.c							optional isci
+dev/isci/isci_controller.c					optional isci
+dev/isci/isci_domain.c						optional isci
+dev/isci/isci_interrupt.c					optional isci
+dev/isci/isci_io_request.c					optional isci
+dev/isci/isci_logger.c						optional isci
+dev/isci/isci_oem_parameters.c					optional isci
+dev/isci/isci_remote_device.c					optional isci
+dev/isci/isci_sysctl.c						optional isci
+dev/isci/isci_task_request.c					optional isci
+dev/isci/isci_timer.c						optional isci
+dev/isci/scil/sati.c						optional isci
+dev/isci/scil/sati_abort_task_set.c				optional isci
+dev/isci/scil/sati_atapi.c					optional isci
+dev/isci/scil/sati_device.c					optional isci
+dev/isci/scil/sati_inquiry.c					optional isci
+dev/isci/scil/sati_log_sense.c					optional isci
+dev/isci/scil/sati_lun_reset.c					optional isci
+dev/isci/scil/sati_mode_pages.c					optional isci
+dev/isci/scil/sati_mode_select.c				optional isci
+dev/isci/scil/sati_mode_sense.c					optional isci
+dev/isci/scil/sati_mode_sense_10.c				optional isci
+dev/isci/scil/sati_mode_sense_6.c				optional isci
+dev/isci/scil/sati_move.c					optional isci
+dev/isci/scil/sati_passthrough.c				optional isci
+dev/isci/scil/sati_read.c					optional isci
+dev/isci/scil/sati_read_buffer.c				optional isci
+dev/isci/scil/sati_read_capacity.c				optional isci
+dev/isci/scil/sati_reassign_blocks.c				optional isci
+dev/isci/scil/sati_report_luns.c				optional isci
+dev/isci/scil/sati_request_sense.c				optional isci
+dev/isci/scil/sati_start_stop_unit.c				optional isci
+dev/isci/scil/sati_synchronize_cache.c				optional isci
+dev/isci/scil/sati_test_unit_ready.c				optional isci
+dev/isci/scil/sati_unmap.c					optional isci
+dev/isci/scil/sati_util.c					optional isci
+dev/isci/scil/sati_verify.c					optional isci
+dev/isci/scil/sati_write.c					optional isci
+dev/isci/scil/sati_write_and_verify.c				optional isci
+dev/isci/scil/sati_write_buffer.c				optional isci
+dev/isci/scil/sati_write_long.c					optional isci
+dev/isci/scil/sci_abstract_list.c				optional isci
+dev/isci/scil/sci_base_controller.c				optional isci
+dev/isci/scil/sci_base_domain.c					optional isci
+dev/isci/scil/sci_base_iterator.c				optional isci
+dev/isci/scil/sci_base_library.c				optional isci
+dev/isci/scil/sci_base_logger.c					optional isci
+dev/isci/scil/sci_base_memory_descriptor_list.c			optional isci
+dev/isci/scil/sci_base_memory_descriptor_list_decorator.c	optional isci
+dev/isci/scil/sci_base_object.c					optional isci
+dev/isci/scil/sci_base_observer.c				optional isci
+dev/isci/scil/sci_base_phy.c					optional isci
+dev/isci/scil/sci_base_port.c					optional isci
+dev/isci/scil/sci_base_remote_device.c				optional isci
+dev/isci/scil/sci_base_request.c				optional isci
+dev/isci/scil/sci_base_state_machine.c				optional isci
+dev/isci/scil/sci_base_state_machine_logger.c			optional isci
+dev/isci/scil/sci_base_state_machine_observer.c			optional isci
+dev/isci/scil/sci_base_subject.c				optional isci
+dev/isci/scil/sci_util.c					optional isci
+dev/isci/scil/scic_sds_controller.c				optional isci
+dev/isci/scil/scic_sds_library.c				optional isci
+dev/isci/scil/scic_sds_pci.c					optional isci
+dev/isci/scil/scic_sds_phy.c					optional isci
+dev/isci/scil/scic_sds_port.c					optional isci
+dev/isci/scil/scic_sds_port_configuration_agent.c		optional isci
+dev/isci/scil/scic_sds_remote_device.c				optional isci
+dev/isci/scil/scic_sds_remote_node_context.c			optional isci
+dev/isci/scil/scic_sds_remote_node_table.c			optional isci
+dev/isci/scil/scic_sds_request.c				optional isci
+dev/isci/scil/scic_sds_sgpio.c					optional isci
+dev/isci/scil/scic_sds_smp_remote_device.c			optional isci
+dev/isci/scil/scic_sds_smp_request.c				optional isci
+dev/isci/scil/scic_sds_ssp_request.c				optional isci
+dev/isci/scil/scic_sds_stp_packet_request.c			optional isci
+dev/isci/scil/scic_sds_stp_remote_device.c			optional isci
+dev/isci/scil/scic_sds_stp_request.c				optional isci
+dev/isci/scil/scic_sds_unsolicited_frame_control.c		optional isci
+dev/isci/scil/scif_sas_controller.c				optional isci
+dev/isci/scil/scif_sas_controller_state_handlers.c		optional isci
+dev/isci/scil/scif_sas_controller_states.c			optional isci
+dev/isci/scil/scif_sas_domain.c					optional isci
+dev/isci/scil/scif_sas_domain_state_handlers.c			optional isci
+dev/isci/scil/scif_sas_domain_states.c				optional isci
+dev/isci/scil/scif_sas_high_priority_request_queue.c		optional isci
+dev/isci/scil/scif_sas_internal_io_request.c			optional isci
+dev/isci/scil/scif_sas_io_request.c				optional isci
+dev/isci/scil/scif_sas_io_request_state_handlers.c		optional isci
+dev/isci/scil/scif_sas_io_request_states.c			optional isci
+dev/isci/scil/scif_sas_library.c				optional isci
+dev/isci/scil/scif_sas_remote_device.c				optional isci
+dev/isci/scil/scif_sas_remote_device_ready_substate_handlers.c	optional isci
+dev/isci/scil/scif_sas_remote_device_ready_substates.c		optional isci
+dev/isci/scil/scif_sas_remote_device_starting_substate_handlers.c		optional isci
+dev/isci/scil/scif_sas_remote_device_starting_substates.c	optional isci
+dev/isci/scil/scif_sas_remote_device_state_handlers.c		optional isci
+dev/isci/scil/scif_sas_remote_device_states.c			optional isci
+dev/isci/scil/scif_sas_request.c				optional isci
+dev/isci/scil/scif_sas_smp_activity_clear_affiliation.c		optional isci
+dev/isci/scil/scif_sas_smp_io_request.c				optional isci
+dev/isci/scil/scif_sas_smp_phy.c				optional isci
+dev/isci/scil/scif_sas_smp_remote_device.c			optional isci
+dev/isci/scil/scif_sas_stp_io_request.c				optional isci
+dev/isci/scil/scif_sas_stp_remote_device.c			optional isci
+dev/isci/scil/scif_sas_stp_task_request.c			optional isci
+dev/isci/scil/scif_sas_task_request.c				optional isci
+dev/isci/scil/scif_sas_task_request_state_handlers.c		optional isci
+dev/isci/scil/scif_sas_task_request_states.c			optional isci
+dev/isci/scil/scif_sas_timer.c					optional isci
 isa/syscons_isa.c		optional	sc
 isa/vga_isa.c			optional	vga
 kern/kern_clocksource.c		standard
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/conf/files.i386
--- a/head/sys/conf/files.i386	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/conf/files.i386	Wed Feb 01 12:34:54 2012 +0200
@@ -1,7 +1,7 @@
 # This file tells config what files go into building a kernel,
 # files marked standard are always included.
 #
-# $FreeBSD: head/sys/conf/files.i386 228971 2011-12-29 21:17:35Z dim $
+# $FreeBSD: head/sys/conf/files.i386 230843 2012-01-31 19:38:18Z jimharris $
 #
 # The long compile-with and dependency lines are required because of
 # limitations in config: backslash-newline doesn't work in strings, and
@@ -248,6 +248,115 @@
 dev/acpica/acpi_if.m		standard
 dev/acpi_support/acpi_wmi_if.m	standard
 dev/wpi/if_wpi.c		optional wpi
+dev/isci/isci.c							optional isci
+dev/isci/isci_controller.c					optional isci
+dev/isci/isci_domain.c						optional isci
+dev/isci/isci_interrupt.c					optional isci
+dev/isci/isci_io_request.c					optional isci
+dev/isci/isci_logger.c						optional isci
+dev/isci/isci_oem_parameters.c					optional isci
+dev/isci/isci_remote_device.c					optional isci
+dev/isci/isci_sysctl.c						optional isci
+dev/isci/isci_task_request.c					optional isci
+dev/isci/isci_timer.c						optional isci
+dev/isci/scil/sati.c						optional isci
+dev/isci/scil/sati_abort_task_set.c				optional isci
+dev/isci/scil/sati_atapi.c					optional isci
+dev/isci/scil/sati_device.c					optional isci
+dev/isci/scil/sati_inquiry.c					optional isci
+dev/isci/scil/sati_log_sense.c					optional isci
+dev/isci/scil/sati_lun_reset.c					optional isci
+dev/isci/scil/sati_mode_pages.c					optional isci
+dev/isci/scil/sati_mode_select.c				optional isci
+dev/isci/scil/sati_mode_sense.c					optional isci
+dev/isci/scil/sati_mode_sense_10.c				optional isci
+dev/isci/scil/sati_mode_sense_6.c				optional isci
+dev/isci/scil/sati_move.c					optional isci
+dev/isci/scil/sati_passthrough.c				optional isci
+dev/isci/scil/sati_read.c					optional isci
+dev/isci/scil/sati_read_buffer.c				optional isci
+dev/isci/scil/sati_read_capacity.c				optional isci
+dev/isci/scil/sati_reassign_blocks.c				optional isci
+dev/isci/scil/sati_report_luns.c				optional isci
+dev/isci/scil/sati_request_sense.c				optional isci
+dev/isci/scil/sati_start_stop_unit.c				optional isci
+dev/isci/scil/sati_synchronize_cache.c				optional isci
+dev/isci/scil/sati_test_unit_ready.c				optional isci
+dev/isci/scil/sati_unmap.c					optional isci
+dev/isci/scil/sati_util.c					optional isci
+dev/isci/scil/sati_verify.c					optional isci
+dev/isci/scil/sati_write.c					optional isci
+dev/isci/scil/sati_write_and_verify.c				optional isci
+dev/isci/scil/sati_write_buffer.c				optional isci
+dev/isci/scil/sati_write_long.c					optional isci
+dev/isci/scil/sci_abstract_list.c				optional isci
+dev/isci/scil/sci_base_controller.c				optional isci
+dev/isci/scil/sci_base_domain.c					optional isci
+dev/isci/scil/sci_base_iterator.c				optional isci
+dev/isci/scil/sci_base_library.c				optional isci
+dev/isci/scil/sci_base_logger.c					optional isci
+dev/isci/scil/sci_base_memory_descriptor_list.c			optional isci
+dev/isci/scil/sci_base_memory_descriptor_list_decorator.c	optional isci
+dev/isci/scil/sci_base_object.c					optional isci
+dev/isci/scil/sci_base_observer.c				optional isci
+dev/isci/scil/sci_base_phy.c					optional isci
+dev/isci/scil/sci_base_port.c					optional isci
+dev/isci/scil/sci_base_remote_device.c				optional isci
+dev/isci/scil/sci_base_request.c				optional isci
+dev/isci/scil/sci_base_state_machine.c				optional isci
+dev/isci/scil/sci_base_state_machine_logger.c			optional isci
+dev/isci/scil/sci_base_state_machine_observer.c			optional isci
+dev/isci/scil/sci_base_subject.c				optional isci
+dev/isci/scil/sci_util.c					optional isci
+dev/isci/scil/scic_sds_controller.c				optional isci
+dev/isci/scil/scic_sds_library.c				optional isci
+dev/isci/scil/scic_sds_pci.c					optional isci
+dev/isci/scil/scic_sds_phy.c					optional isci
+dev/isci/scil/scic_sds_port.c					optional isci
+dev/isci/scil/scic_sds_port_configuration_agent.c		optional isci
+dev/isci/scil/scic_sds_remote_device.c				optional isci
+dev/isci/scil/scic_sds_remote_node_context.c			optional isci
+dev/isci/scil/scic_sds_remote_node_table.c			optional isci
+dev/isci/scil/scic_sds_request.c				optional isci
+dev/isci/scil/scic_sds_sgpio.c					optional isci
+dev/isci/scil/scic_sds_smp_remote_device.c			optional isci
+dev/isci/scil/scic_sds_smp_request.c				optional isci
+dev/isci/scil/scic_sds_ssp_request.c				optional isci
+dev/isci/scil/scic_sds_stp_packet_request.c			optional isci
+dev/isci/scil/scic_sds_stp_remote_device.c			optional isci
+dev/isci/scil/scic_sds_stp_request.c				optional isci
+dev/isci/scil/scic_sds_unsolicited_frame_control.c		optional isci
+dev/isci/scil/scif_sas_controller.c				optional isci
+dev/isci/scil/scif_sas_controller_state_handlers.c		optional isci
+dev/isci/scil/scif_sas_controller_states.c			optional isci
+dev/isci/scil/scif_sas_domain.c					optional isci
+dev/isci/scil/scif_sas_domain_state_handlers.c			optional isci
+dev/isci/scil/scif_sas_domain_states.c				optional isci
+dev/isci/scil/scif_sas_high_priority_request_queue.c		optional isci
+dev/isci/scil/scif_sas_internal_io_request.c			optional isci
+dev/isci/scil/scif_sas_io_request.c				optional isci
+dev/isci/scil/scif_sas_io_request_state_handlers.c		optional isci
+dev/isci/scil/scif_sas_io_request_states.c			optional isci
+dev/isci/scil/scif_sas_library.c				optional isci
+dev/isci/scil/scif_sas_remote_device.c				optional isci
+dev/isci/scil/scif_sas_remote_device_ready_substate_handlers.c	optional isci
+dev/isci/scil/scif_sas_remote_device_ready_substates.c		optional isci
+dev/isci/scil/scif_sas_remote_device_starting_substate_handlers.c		optional isci
+dev/isci/scil/scif_sas_remote_device_starting_substates.c	optional isci
+dev/isci/scil/scif_sas_remote_device_state_handlers.c		optional isci
+dev/isci/scil/scif_sas_remote_device_states.c			optional isci
+dev/isci/scil/scif_sas_request.c				optional isci
+dev/isci/scil/scif_sas_smp_activity_clear_affiliation.c		optional isci
+dev/isci/scil/scif_sas_smp_io_request.c				optional isci
+dev/isci/scil/scif_sas_smp_phy.c				optional isci
+dev/isci/scil/scif_sas_smp_remote_device.c			optional isci
+dev/isci/scil/scif_sas_stp_io_request.c				optional isci
+dev/isci/scil/scif_sas_stp_remote_device.c			optional isci
+dev/isci/scil/scif_sas_stp_task_request.c			optional isci
+dev/isci/scil/scif_sas_task_request.c				optional isci
+dev/isci/scil/scif_sas_task_request_state_handlers.c		optional isci
+dev/isci/scil/scif_sas_task_request_states.c			optional isci
+dev/isci/scil/scif_sas_timer.c					optional isci
 i386/acpica/acpi_machdep.c	optional acpi
 acpi_wakecode.o			optional acpi				\
 	dependency	"$S/i386/acpica/acpi_wakecode.S assym.s"	\
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/conf/kern.pre.mk
--- a/head/sys/conf/kern.pre.mk	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/conf/kern.pre.mk	Wed Feb 01 12:34:54 2012 +0200
@@ -1,4 +1,4 @@
-# $FreeBSD: head/sys/conf/kern.pre.mk 229353 2012-01-03 00:22:08Z gjb $
+# $FreeBSD: head/sys/conf/kern.pre.mk 230422 2012-01-21 11:42:40Z andreast $
 
 # Part of a unified Makefile for building kernels.  This part contains all
 # of the definitions that need to be before %BEFORE_DEPEND.
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/conf/kmod.mk
--- a/head/sys/conf/kmod.mk	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/conf/kmod.mk	Wed Feb 01 12:34:54 2012 +0200
@@ -1,5 +1,5 @@
 #	From: @(#)bsd.prog.mk	5.26 (Berkeley) 6/25/91
-# $FreeBSD: head/sys/conf/kmod.mk 230130 2012-01-15 13:21:36Z mav $
+# $FreeBSD: head/sys/conf/kmod.mk 230308 2012-01-18 15:25:34Z bz $
 #
 # The include file <bsd.kmod.mk> handles building and installing loadable
 # kernel modules.
@@ -340,6 +340,7 @@
 
 MFILES?= dev/acpica/acpi_if.m dev/acpi_support/acpi_wmi_if.m \
 	dev/agp/agp_if.m dev/ata/ata_if.m dev/eisa/eisa_if.m \
+	dev/gpio/gpio_if.m dev/gpio/gpiobus_if.m \
 	dev/iicbus/iicbb_if.m dev/iicbus/iicbus_if.m \
 	dev/mmc/mmcbr_if.m dev/mmc/mmcbus_if.m \
 	dev/mii/miibus_if.m dev/mvs/mvs_if.m dev/ofw/ofw_bus_if.m \
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/conf/ldscript.powerpc64
--- a/head/sys/conf/ldscript.powerpc64	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/conf/ldscript.powerpc64	Wed Feb 01 12:34:54 2012 +0200
@@ -1,7 +1,7 @@
-/* $FreeBSD$ */
+/* $FreeBSD: head/sys/conf/ldscript.powerpc64 230391 2012-01-20 18:52:31Z andreast $ */
 
 OUTPUT_FORMAT("elf64-powerpc", "elf64-powerpc", "elf64-powerpc")
-OUTPUT_ARCH(powerpc)
+OUTPUT_ARCH(powerpc:common64)
 ENTRY(__start)
 SEARCH_DIR(/usr/lib);
 PROVIDE (__stack = 0);
@@ -56,15 +56,19 @@
   .sdata2    : { *(.sdata2)  }
   .sbss2     : { *(.sbss2)   }
   /* Adjust the address for the data segment to the next page up. */
-  . = ((. + 0x1000) & ~(0x1000 - 1));
+  . = ALIGN(4096);
   .data    :
   {
     *(.data)
     *(.gnu.linkonce.d*)
     CONSTRUCTORS
   }
-  .data1   : { *(.data1) }
-  .got1           : { *(.got1) }
+  .data1     : { *(.data1) }
+  .toc1      : ALIGN(8) { *(.toc1) }
+  .opd       : ALIGN(8) { KEEP (*(.opd)) }
+  .branch_lt : ALIGN(8) { *(.branch_lt) }
+  .got       : ALIGN(8) { *(.got .toc) }
+
   .dynamic        : { *(.dynamic) }
   /* Put .ctors and .dtors next to the .got2 section, so that the pointers
      get relocated with -mrelocatable. Also put in the .fixup pointers.
@@ -81,10 +85,6 @@
   .fixup          : { *(.fixup) }
                 PROVIDE (_FIXUP_END_ = .);
                 PROVIDE (_GOT2_END_ = .);
-                PROVIDE (_GOT_START_ = .);
-  .got            : { *(.got) }
-  .got.plt        : { *(.got.plt) }
-                PROVIDE (_GOT_END_ = .);
   /* We want the small data sections together, so single-instruction offsets
      can access them all, and initialized data all before uninitialized, so
      we can shorten the on-disk segment size.  */
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/conf/options.amd64
--- a/head/sys/conf/options.amd64	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/conf/options.amd64	Wed Feb 01 12:34:54 2012 +0200
@@ -1,4 +1,4 @@
-# $FreeBSD: head/sys/conf/options.amd64 225194 2011-08-26 17:08:22Z jhb $
+# $FreeBSD: head/sys/conf/options.amd64 230843 2012-01-31 19:38:18Z jimharris $
 # Options specific to AMD64 platform kernels
 
 AUTO_EOI_1		opt_auto_eoi.h
@@ -65,3 +65,6 @@
 BPF_JITTER		opt_bpf.h
 
 XENHVM			opt_global.h
+
+# options for the Intel C600 SAS driver (isci)
+ISCI_LOGGING	opt_isci.h
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/conf/options.i386
--- a/head/sys/conf/options.i386	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/conf/options.i386	Wed Feb 01 12:34:54 2012 +0200
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/sys/conf/options.i386 230843 2012-01-31 19:38:18Z jimharris $
 # Options specific to the i386 platform kernels
 
 AUTO_EOI_1		opt_auto_eoi.h
@@ -119,3 +119,6 @@
 NATIVE			opt_global.h
 XEN			opt_global.h
 XENHVM			opt_global.h
+
+# options for the Intel C600 SAS driver (isci)
+ISCI_LOGGING	opt_isci.h
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/contrib/octeon-sdk/cvmx-app-init.h
--- a/head/sys/contrib/octeon-sdk/cvmx-app-init.h	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/contrib/octeon-sdk/cvmx-app-init.h	Wed Feb 01 12:34:54 2012 +0200
@@ -227,6 +227,7 @@
 #endif
     CVMX_BOARD_TYPE_CUST_DLINK_DSR500=20015,
     CVMX_BOARD_TYPE_CUST_DLINK_DSR500N=20013,
+    CVMX_BOARD_TYPE_CUST_DLINK_DSR1000=20005, /* XXX check it */
     CVMX_BOARD_TYPE_CUST_DLINK_DSR1000N=20006,
     CVMX_BOARD_TYPE_CUST_PRIVATE_MAX = 30000,
 
@@ -344,6 +345,7 @@
 #endif
 	ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CUST_DLINK_DSR500)
 	ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CUST_DLINK_DSR500N)
+	ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CUST_DLINK_DSR1000)
 	ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CUST_DLINK_DSR1000N)
         ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CUST_PRIVATE_MAX)
 
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/contrib/octeon-sdk/cvmx-helper-board.c
--- a/head/sys/contrib/octeon-sdk/cvmx-helper-board.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/contrib/octeon-sdk/cvmx-helper-board.c	Wed Feb 01 12:34:54 2012 +0200
@@ -258,16 +258,17 @@
             return -1;  /* No PHYs are connected to Octeon, everything is through switch */
 	case CVMX_BOARD_TYPE_CUST_DLINK_DSR500:
 	case CVMX_BOARD_TYPE_CUST_DLINK_DSR500N:
+	case CVMX_BOARD_TYPE_CUST_DLINK_DSR1000:
 	case CVMX_BOARD_TYPE_CUST_DLINK_DSR1000N:
-//	    if (ipd_port == 0 || ipd_port == 1)
-//	        return -1; /* Port 0, 1 connect to switch */
-//	    else if (ipd_port == 2)
-//	        return 8; /* Port 2 connect to B5081 */
-//	    else
-//	        return -1;
-	    if (ipd_port == 0)	return -1;
-	    if (ipd_port == 1)	return -1;
-	    if (ipd_port == 2)	return -1;
+		/* Just give us miibus device */
+		switch (ipd_port) {
+		case 0:
+			return 0;
+		case 1:
+			return 0x1e;
+		case 2:
+			return 8;
+		}
 	case CVMX_BOARD_TYPE_CUST_WSX16:
 		if (ipd_port >= 0 && ipd_port <= 3)
 			return ipd_port;
@@ -428,6 +429,7 @@
 	/* Private vendor-defined boards.  */
 	case CVMX_BOARD_TYPE_CUST_DLINK_DSR500:
 	case CVMX_BOARD_TYPE_CUST_DLINK_DSR500N:
+	case CVMX_BOARD_TYPE_CUST_DLINK_DSR1000:
 	case CVMX_BOARD_TYPE_CUST_DLINK_DSR1000N:
 //            if (ipd_port == 0 || ipd_port == 1) //BCM53115 in RGMII 0,1
 //            {
@@ -789,6 +791,7 @@
                        ** Loopback disabled by default. */
 	case CVMX_BOARD_TYPE_CUST_DLINK_DSR500:
 	case CVMX_BOARD_TYPE_CUST_DLINK_DSR500N:
+	case CVMX_BOARD_TYPE_CUST_DLINK_DSR1000:
 	case CVMX_BOARD_TYPE_CUST_DLINK_DSR1000N:
             if (interface == 0)
                 return 3;
@@ -900,6 +903,10 @@
 #if defined(OCTEON_BOARD_CAPK_0100ND)
 	case CVMX_BOARD_TYPE_CN3010_EVB_HS5:
 #endif
+	case CVMX_BOARD_TYPE_CUST_DLINK_DSR500:
+	case CVMX_BOARD_TYPE_CUST_DLINK_DSR500N:
+	case CVMX_BOARD_TYPE_CUST_DLINK_DSR1000:
+	case CVMX_BOARD_TYPE_CUST_DLINK_DSR1000N:
             return USB_CLOCK_TYPE_CRYSTAL_12;
     }
     return USB_CLOCK_TYPE_REF_48;
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/contrib/octeon-sdk/cvmx-helper-rgmii.c
--- a/head/sys/contrib/octeon-sdk/cvmx-helper-rgmii.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/contrib/octeon-sdk/cvmx-helper-rgmii.c	Wed Feb 01 12:34:54 2012 +0200
@@ -259,6 +259,8 @@
     		(cvmx_sysinfo_get()->board_type != 
     		    CVMX_BOARD_TYPE_CUST_DLINK_DSR500N) &&
     		(cvmx_sysinfo_get()->board_type != 
+    		    CVMX_BOARD_TYPE_CUST_DLINK_DSR1000) &&
+    		(cvmx_sysinfo_get()->board_type != 
     		    CVMX_BOARD_TYPE_CUST_DLINK_DSR1000N)) {
 
         	    cvmx_write_csr(CVMX_ASXX_TX_CLK_SETX(port, interface), 16);
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/contrib/octeon-sdk/cvmx-helper.c
--- a/head/sys/contrib/octeon-sdk/cvmx-helper.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/contrib/octeon-sdk/cvmx-helper.c	Wed Feb 01 12:34:54 2012 +0200
@@ -150,6 +150,7 @@
 #endif
 	case CVMX_BOARD_TYPE_CUST_DLINK_DSR500:
 	case CVMX_BOARD_TYPE_CUST_DLINK_DSR500N:
+	case CVMX_BOARD_TYPE_CUST_DLINK_DSR1000:
 	case CVMX_BOARD_TYPE_CUST_DLINK_DSR1000N:
 	    return 1;
 	default:
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/contrib/octeon-sdk/cvmx-rtc.h
--- a/head/sys/contrib/octeon-sdk/cvmx-rtc.h	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/contrib/octeon-sdk/cvmx-rtc.h	Wed Feb 01 12:34:54 2012 +0200
@@ -91,6 +91,7 @@
 	case CVMX_BOARD_TYPE_CN3010_EVB_HS5:
 	case CVMX_BOARD_TYPE_CUST_DLINK_DSR500:
 	case CVMX_BOARD_TYPE_CUST_DLINK_DSR500N:
+	case CVMX_BOARD_TYPE_CUST_DLINK_DSR1000:
 	case CVMX_BOARD_TYPE_CUST_DLINK_DSR1000N:
 	    supported = CVMX_RTC_READ | CVMX_RTC_WRITE | CVMX_RTC_TIME_CAL;
 	    break;
@@ -129,6 +130,7 @@
     case CVMX_BOARD_TYPE_CN3010_EVB_HS5:
     case CVMX_BOARD_TYPE_CUST_DLINK_DSR500:
     case CVMX_BOARD_TYPE_CUST_DLINK_DSR500N:
+    case CVMX_BOARD_TYPE_CUST_DLINK_DSR1000:
     case CVMX_BOARD_TYPE_CUST_DLINK_DSR1000N:
 	return cvmx_rtc_ds1337_read();
 	break;
@@ -158,6 +160,7 @@
     case CVMX_BOARD_TYPE_CN3010_EVB_HS5:
     case CVMX_BOARD_TYPE_CUST_DLINK_DSR500:
     case CVMX_BOARD_TYPE_CUST_DLINK_DSR500N:
+    case CVMX_BOARD_TYPE_CUST_DLINK_DSR1000:
     case CVMX_BOARD_TYPE_CUST_DLINK_DSR1000N:
 	return cvmx_rtc_ds1337_write(time);
 	break;
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/contrib/pf/net/if_pfsync.c
--- a/head/sys/contrib/pf/net/if_pfsync.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/contrib/pf/net/if_pfsync.c	Wed Feb 01 12:34:54 2012 +0200
@@ -57,7 +57,7 @@
 #include "opt_pf.h"
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/contrib/pf/net/if_pfsync.c 229976 2012-01-11 18:34:57Z glebius $");
+__FBSDID("$FreeBSD: head/sys/contrib/pf/net/if_pfsync.c 230265 2012-01-17 12:14:26Z glebius $");
 
 #define	NBPFILTER	1
 #endif /* __FreeBSD__ */
@@ -2121,9 +2121,6 @@
 #ifdef notyet
 	struct tdb *t;
 #endif
-#ifdef __FreeBSD__
-	size_t pktlen;
-#endif
 	int offset;
 	int q, count = 0;
 
@@ -2145,44 +2142,33 @@
 		return;
 	}
 
+#ifdef __FreeBSD__
+	m = m_get2(M_NOWAIT, MT_DATA, M_PKTHDR, max_linkhdr + sc->sc_len);
+	if (m == NULL) {
+		sc->sc_ifp->if_oerrors++;
+		V_pfsyncstats.pfsyncs_onomem++;
+		return;
+	}
+#else
 	MGETHDR(m, M_DONTWAIT, MT_DATA);
 	if (m == NULL) {
-#ifdef __FreeBSD__
-		sc->sc_ifp->if_oerrors++;
-#else
 		sc->sc_if.if_oerrors++;
-#endif
-		V_pfsyncstats.pfsyncs_onomem++;
+		pfsyncstats.pfsyncs_onomem++;
 		pfsync_drop(sc);
 		return;
 	}
 
-#ifdef __FreeBSD__
-	pktlen = max_linkhdr + sc->sc_len;
-	if (pktlen > MHLEN) {
-		/* Find the right pool to allocate from. */
-		/* XXX: This is ugly. */
-		m_cljget(m, M_DONTWAIT, pktlen <= MCLBYTES ? MCLBYTES :
-#if MJUMPAGESIZE != MCLBYTES
-			pktlen <= MJUMPAGESIZE ? MJUMPAGESIZE :
-#endif
-			pktlen <= MJUM9BYTES ? MJUM9BYTES : MJUM16BYTES);
-#else
 	if (max_linkhdr + sc->sc_len > MHLEN) {
 		MCLGETI(m, M_DONTWAIT, NULL, max_linkhdr + sc->sc_len);
-#endif
 		if (!ISSET(m->m_flags, M_EXT)) {
 			m_free(m);
-#ifdef __FreeBSD__
-			sc->sc_ifp->if_oerrors++;
-#else
 			sc->sc_if.if_oerrors++;
-#endif
-			V_pfsyncstats.pfsyncs_onomem++;
+			pfsyncstats.pfsyncs_onomem++;
 			pfsync_drop(sc);
 			return;
 		}
 	}
+#endif
 	m->m_data += max_linkhdr;
 	m->m_len = m->m_pkthdr.len = sc->sc_len;
 
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/dev/ata/chipsets/ata-acerlabs.c
--- a/head/sys/dev/ata/chipsets/ata-acerlabs.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/dev/ata/chipsets/ata-acerlabs.c	Wed Feb 01 12:34:54 2012 +0200
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/dev/ata/chipsets/ata-acerlabs.c 230132 2012-01-15 13:23:18Z uqs $");
+__FBSDID("$FreeBSD: head/sys/dev/ata/chipsets/ata-acerlabs.c 230627 2012-01-27 21:52:59Z marius $");
 
 #include "opt_ata.h"
 #include <sys/param.h>
@@ -213,6 +213,10 @@
 	if (ch->dma.max_iosize > 256 * 512)
 		ch->dma.max_iosize = 256 * 512;
     }
+#ifdef ATA_CAM
+	if (ctlr->chip->cfg2 & ALI_NEW)
+		ch->flags |= ATA_NO_ATAPI_DMA;
+#endif
 
     return 0;
 }
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/dev/ata/chipsets/ata-siliconimage.c
--- a/head/sys/dev/ata/chipsets/ata-siliconimage.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/dev/ata/chipsets/ata-siliconimage.c	Wed Feb 01 12:34:54 2012 +0200
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/dev/ata/chipsets/ata-siliconimage.c 230132 2012-01-15 13:23:18Z uqs $");
+__FBSDID("$FreeBSD: head/sys/dev/ata/chipsets/ata-siliconimage.c 230627 2012-01-27 21:52:59Z marius $");
 
 #include "opt_ata.h"
 #include <sys/param.h>
@@ -240,6 +240,10 @@
     if (ctlr->chip->cfg2 & SII_INTR)
 	ch->hw.status = ata_cmd_status;
 
+#ifdef ATA_CAM
+	ch->flags |= ATA_NO_ATAPI_DMA;
+#endif
+
     return 0;
 }
 
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/dev/ath/ath_dfs/null/dfs_null.c
--- a/head/sys/dev/ath/ath_dfs/null/dfs_null.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/dev/ath/ath_dfs/null/dfs_null.c	Wed Feb 01 12:34:54 2012 +0200
@@ -26,10 +26,10 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  * THE POSSIBILITY OF SUCH DAMAGES.
  *
- * $FreeBSD: head/sys/dev/ath/ath_dfs/null/dfs_null.c 226436 2011-10-16 14:30:28Z eadler $
+ * $FreeBSD: head/sys/dev/ath/ath_dfs/null/dfs_null.c 230663 2012-01-28 22:24:59Z adrian $
  */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/dev/ath/ath_dfs/null/dfs_null.c 226436 2011-10-16 14:30:28Z eadler $");
+__FBSDID("$FreeBSD: head/sys/dev/ath/ath_dfs/null/dfs_null.c 230663 2012-01-28 22:24:59Z adrian $");
 
 /*
  * This implements an empty DFS module.
@@ -95,12 +95,19 @@
 /*
  * Enable radar check
  */
-void
+int
 ath_dfs_radar_enable(struct ath_softc *sc, struct ieee80211_channel *chan)
 {
 	/* Check if the current channel is radar-enabled */
 	if (! IEEE80211_IS_CHAN_DFS(chan))
-		return;
+		return (0);
+
+	/*
+	 * Enabling the radar parameters and setting sc->sc_dodfs = 1
+	 * would occur here.
+	 */
+
+	return (1);
 }
 
 /*
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/dev/ath/ath_hal/ar5210/ar5210_attach.c
--- a/head/sys/dev/ath/ath_hal/ar5210/ar5210_attach.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/dev/ath/ath_hal/ar5210/ar5210_attach.c	Wed Feb 01 12:34:54 2012 +0200
@@ -14,7 +14,7 @@
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $FreeBSD: head/sys/dev/ath/ath_hal/ar5210/ar5210_attach.c 225883 2011-09-30 05:17:57Z adrian $
+ * $FreeBSD: head/sys/dev/ath/ath_hal/ar5210/ar5210_attach.c 230791 2012-01-30 23:07:27Z adrian $
  */
 #include "opt_ah.h"
 
@@ -359,6 +359,12 @@
 	pCap->halChanHalfRate = AH_FALSE;
 	pCap->halChanQuarterRate = AH_FALSE;
 
+	/*
+	 * RSSI uses the combined field; some 11n NICs may use
+	 * the control chain RSSI.
+	 */
+	pCap->halUseCombinedRadarRssi = AH_TRUE;
+
 	if (ath_hal_eepromGetFlag(ah, AR_EEP_RFKILL)) {
 		/*
 		 * Setup initial rfsilent settings based on the EEPROM
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/dev/ath/ath_hal/ar5211/ar5211_attach.c
--- a/head/sys/dev/ath/ath_hal/ar5211/ar5211_attach.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/dev/ath/ath_hal/ar5211/ar5211_attach.c	Wed Feb 01 12:34:54 2012 +0200
@@ -14,7 +14,7 @@
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $FreeBSD: head/sys/dev/ath/ath_hal/ar5211/ar5211_attach.c 225883 2011-09-30 05:17:57Z adrian $
+ * $FreeBSD: head/sys/dev/ath/ath_hal/ar5211/ar5211_attach.c 230791 2012-01-30 23:07:27Z adrian $
  */
 #include "opt_ah.h"
 
@@ -494,6 +494,12 @@
 	pCap->halChanHalfRate = AH_FALSE;
 	pCap->halChanQuarterRate = AH_FALSE;
 
+	/*
+	 * RSSI uses the combined field; some 11n NICs may use
+	 * the control chain RSSI.
+	 */
+	pCap->halUseCombinedRadarRssi = AH_TRUE;
+
 	if (ath_hal_eepromGetFlag(ah, AR_EEP_RFKILL) &&
 	    ath_hal_eepromGet(ah, AR_EEP_RFSILENT, &ahpriv->ah_rfsilent) == HAL_OK) {
 		/* NB: enabled by default */
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/dev/ath/ath_hal/ar5212/ar5212.h
--- a/head/sys/dev/ath/ath_hal/ar5212/ar5212.h	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/dev/ath/ath_hal/ar5212/ar5212.h	Wed Feb 01 12:34:54 2012 +0200
@@ -14,7 +14,7 @@
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $FreeBSD: head/sys/dev/ath/ath_hal/ar5212/ar5212.h 226760 2011-10-25 23:13:36Z adrian $
+ * $FreeBSD: head/sys/dev/ath/ath_hal/ar5212/ar5212.h 230791 2012-01-30 23:07:27Z adrian $
  */
 #ifndef _ATH_AR5212_H_
 #define _ATH_AR5212_H_
@@ -628,5 +628,6 @@
 	    struct ath_rx_status *rxs, uint64_t fulltsf, const char *buf,
 	    HAL_DFS_EVENT *event);
 extern	HAL_BOOL ar5212IsFastClockEnabled(struct ath_hal *ah);
+extern	uint32_t ar5212Get11nExtBusy(struct ath_hal *ah);
 
 #endif	/* _ATH_AR5212_H_ */
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/dev/ath/ath_hal/ar5212/ar5212_attach.c
--- a/head/sys/dev/ath/ath_hal/ar5212/ar5212_attach.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/dev/ath/ath_hal/ar5212/ar5212_attach.c	Wed Feb 01 12:34:54 2012 +0200
@@ -14,7 +14,7 @@
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $FreeBSD: head/sys/dev/ath/ath_hal/ar5212/ar5212_attach.c 225883 2011-09-30 05:17:57Z adrian $
+ * $FreeBSD: head/sys/dev/ath/ath_hal/ar5212/ar5212_attach.c 230791 2012-01-30 23:07:27Z adrian $
  */
 #include "opt_ah.h"
 
@@ -134,6 +134,7 @@
 	.ah_getDfsThresh		= ar5212GetDfsThresh,
 	.ah_procRadarEvent		= ar5212ProcessRadarEvent,
 	.ah_isFastClockEnabled		= ar5212IsFastClockEnabled,
+	.ah_get11nExtBusy		= ar5212Get11nExtBusy,
 
 	/* Key Cache Functions */
 	.ah_getKeyCacheSize		= ar5212GetKeyCacheSize,
@@ -839,6 +840,12 @@
 	pCap->halChanHalfRate = AH_TRUE;
 	pCap->halChanQuarterRate = AH_TRUE;
 
+	/*
+	 * RSSI uses the combined field; some 11n NICs may use
+	 * the control chain RSSI.
+	 */
+	pCap->halUseCombinedRadarRssi = AH_TRUE;
+
 	if (ath_hal_eepromGetFlag(ah, AR_EEP_RFKILL) &&
 	    ath_hal_eepromGet(ah, AR_EEP_RFSILENT, &ahpriv->ah_rfsilent) == HAL_OK) {
 		/* NB: enabled by default */
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c
--- a/head/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c	Wed Feb 01 12:34:54 2012 +0200
@@ -14,7 +14,7 @@
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $FreeBSD: head/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c 228817 2011-12-22 21:54:53Z adrian $
+ * $FreeBSD: head/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c 230791 2012-01-30 23:07:27Z adrian $
  */
 #include "opt_ah.h"
 
@@ -1233,3 +1233,13 @@
 {
 	return AH_FALSE;
 }
+
+/*
+ * Return what percentage of the extension channel is busy.
+ * This is always disabled for AR5212 series NICs.
+ */
+uint32_t
+ar5212Get11nExtBusy(struct ath_hal *ah)
+{
+	return 0;
+}
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c
--- a/head/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c	Wed Feb 01 12:34:54 2012 +0200
@@ -14,7 +14,7 @@
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $FreeBSD: head/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c 228893 2011-12-26 08:21:29Z adrian $
+ * $FreeBSD: head/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c 230847 2012-01-31 22:31:16Z adrian $
  */
 #include "opt_ah.h"
 
@@ -884,6 +884,15 @@
 	/* AR5416 may have 3 antennas but is a 2x2 stream device */
 	pCap->halTxStreams = 2;
 	pCap->halRxStreams = 2;
+	/*
+	 * If the TX or RX chainmask has less than 2 chains active,
+	 * mark it as a 1-stream device for the relevant stream.
+	 */
+	if (owl_get_ntxchains(pCap->halTxChainMask) == 1)
+		pCap->halTxStreams = 1;
+	/* XXX Eww */
+	if (owl_get_ntxchains(pCap->halRxChainMask) == 1)
+		pCap->halRxStreams = 1;
 	pCap->halRtsAggrLimit = 8*1024;		/* Owl 2.0 limit */
 	pCap->halMbssidAggrSupport = AH_FALSE;	/* Broken on Owl */
 	pCap->halForcePpmSupport = AH_TRUE;
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/dev/ath/ath_hal/ar9002/ar9280_attach.c
--- a/head/sys/dev/ath/ath_hal/ar9002/ar9280_attach.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/dev/ath/ath_hal/ar9002/ar9280_attach.c	Wed Feb 01 12:34:54 2012 +0200
@@ -14,7 +14,7 @@
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $FreeBSD: head/sys/dev/ath/ath_hal/ar9002/ar9280_attach.c 230147 2012-01-15 19:22:34Z adrian $
+ * $FreeBSD: head/sys/dev/ath/ath_hal/ar9002/ar9280_attach.c 230847 2012-01-31 22:31:16Z adrian $
  */
 #include "opt_ah.h"
 
@@ -822,10 +822,6 @@
 #if 0
 	pCap->halWowMatchPatternDword = AH_TRUE;
 #endif
-	/* AR9280 is a 2x2 stream device */
-	pCap->halTxStreams = 2;
-	pCap->halRxStreams = 2;
-
 	pCap->halCSTSupport = AH_TRUE;
 	pCap->halRifsRxSupport = AH_TRUE;
 	pCap->halRifsTxSupport = AH_TRUE;
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/dev/ath/if_ath.c
--- a/head/sys/dev/ath/if_ath.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/dev/ath/if_ath.c	Wed Feb 01 12:34:54 2012 +0200
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/dev/ath/if_ath.c 229950 2012-01-11 00:18:33Z adrian $");
+__FBSDID("$FreeBSD: head/sys/dev/ath/if_ath.c 230846 2012-01-31 22:27:35Z adrian $");
 
 /*
  * Driver for the Atheros Wireless LAN controller.
@@ -678,8 +678,8 @@
 		 * negotiating which MCS rates it'll receive and
 		 * what MCS rates are available for TX.
 		 */
-		(void) ath_hal_getcapability(ah, HAL_CAP_STREAMS, 0, &rxs);
-		(void) ath_hal_getcapability(ah, HAL_CAP_STREAMS, 1, &txs);
+		(void) ath_hal_getcapability(ah, HAL_CAP_STREAMS, 0, &txs);
+		(void) ath_hal_getcapability(ah, HAL_CAP_STREAMS, 1, &rxs);
 
 		ath_hal_getrxchainmask(ah, &sc->sc_rxchainmask);
 		ath_hal_gettxchainmask(ah, &sc->sc_txchainmask);
@@ -2695,6 +2695,8 @@
 	int error;
 
 	bf = avp->av_bcbuf;
+	DPRINTF(sc, ATH_DEBUG_NODE, "%s: bf_m=%p, bf_node=%p\n",
+	    __func__, bf->bf_m, bf->bf_node);
 	if (bf->bf_m != NULL) {
 		bus_dmamap_unload(sc->sc_dmat, bf->bf_dmamap);
 		m_freem(bf->bf_m);
@@ -3152,6 +3154,8 @@
 ath_beacon_return(struct ath_softc *sc, struct ath_buf *bf)
 {
 
+	DPRINTF(sc, ATH_DEBUG_NODE, "%s: free bf=%p, bf_m=%p, bf_node=%p\n",
+	    __func__, bf, bf->bf_m, bf->bf_node);
 	if (bf->bf_m != NULL) {
 		bus_dmamap_unload(sc->sc_dmat, bf->bf_dmamap);
 		m_freem(bf->bf_m);
@@ -3173,6 +3177,9 @@
 	struct ath_buf *bf;
 
 	TAILQ_FOREACH(bf, &sc->sc_bbuf, bf_list) {
+		DPRINTF(sc, ATH_DEBUG_NODE,
+		    "%s: free bf=%p, bf_m=%p, bf_node=%p\n",
+		        __func__, bf, bf->bf_m, bf->bf_node);
 		if (bf->bf_m != NULL) {
 			bus_dmamap_unload(sc->sc_dmat, bf->bf_dmamap);
 			m_freem(bf->bf_m);
@@ -3976,7 +3983,7 @@
 	int len, type, ngood;
 	HAL_STATUS status;
 	int16_t nf;
-	u_int64_t tsf;
+	u_int64_t tsf, rstamp;
 	int npkts = 0;
 
 	/* XXX we must not hold the ATH_LOCK here */
@@ -4047,6 +4054,12 @@
 		TAILQ_REMOVE(&sc->sc_rxbuf, bf, bf_list);
 		npkts++;
 
+		/*
+		 * Calculate the correct 64 bit TSF given
+		 * the TSF64 register value and rs_tstamp.
+		 */
+		rstamp = ath_extend_tsf(sc, rs->rs_tstamp, tsf);
+
 		/* These aren't specifically errors */
 #ifdef	AH_SUPPORT_AR5416
 		if (rs->rs_flags & HAL_RX_GI)
@@ -4078,7 +4091,7 @@
 					    bf->bf_dmamap,
 					    BUS_DMASYNC_POSTREAD);
 					/* Now pass it to the radar processing code */
-					ath_dfs_process_phy_err(sc, mtod(m, char *), tsf, rs);
+					ath_dfs_process_phy_err(sc, mtod(m, char *), rstamp, rs);
 				}
 
 				/* Be suitably paranoid about receiving phy errors out of the stats array bounds */
@@ -4142,7 +4155,7 @@
 				len = rs->rs_datalen;
 				m->m_pkthdr.len = m->m_len = len;
 				bf->bf_m = NULL;
-				ath_rx_tap(ifp, m, rs, tsf, nf);
+				ath_rx_tap(ifp, m, rs, rstamp, nf);
 				ieee80211_radiotap_rx_all(ic, m);
 				m_freem(m);
 			}
@@ -4239,7 +4252,7 @@
 		 * noise setting is filled in above.
 		 */
 		if (ieee80211_radiotap_active(ic))
-			ath_rx_tap(ifp, m, rs, tsf, nf);
+			ath_rx_tap(ifp, m, rs, rstamp, nf);
 
 		/*
 		 * From this point on we assume the frame is at least
@@ -6679,7 +6692,14 @@
 	 */
 	if (ath_dfs_process_radar_event(sc, sc->sc_curchan)) {
 		/* DFS event found, initiate channel change */
+		/*
+		 * XXX doesn't currently tell us whether the event
+		 * XXX was found in the primary or extension
+		 * XXX channel!
+		 */
+		IEEE80211_LOCK(ic);
 		ieee80211_dfs_notify_radar(ic, sc->sc_curchan);
+		IEEE80211_UNLOCK(ic);
 	}
 }
 
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/dev/ath/if_athdfs.h
--- a/head/sys/dev/ath/if_athdfs.h	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/dev/ath/if_athdfs.h	Wed Feb 01 12:34:54 2012 +0200
@@ -26,14 +26,14 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  * THE POSSIBILITY OF SUCH DAMAGES.
  *
- * $FreeBSD: head/sys/dev/ath/if_athdfs.h 224734 2011-08-09 15:46:52Z adrian $
+ * $FreeBSD: head/sys/dev/ath/if_athdfs.h 230658 2012-01-28 21:44:42Z adrian $
  */
 #ifndef	__IF_ATHDFS_H__
 #define	__IF_ATHDFS_H__
 
 extern	int ath_dfs_attach(struct ath_softc *sc);
 extern	int ath_dfs_detach(struct ath_softc *sc);
-extern	void ath_dfs_radar_enable(struct ath_softc *,
+extern	int ath_dfs_radar_enable(struct ath_softc *,
     struct ieee80211_channel *chan);
 extern	void ath_dfs_process_phy_err(struct ath_softc *sc, const char *buf,
     uint64_t tsf, struct ath_rx_status *rxstat);
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/dev/ath/if_athvar.h
--- a/head/sys/dev/ath/if_athvar.h	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/dev/ath/if_athvar.h	Wed Feb 01 12:34:54 2012 +0200
@@ -26,7 +26,7 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  * THE POSSIBILITY OF SUCH DAMAGES.
  *
- * $FreeBSD: head/sys/dev/ath/if_athvar.h 228891 2011-12-26 07:47:05Z adrian $
+ * $FreeBSD: head/sys/dev/ath/if_athvar.h 230493 2012-01-24 06:12:48Z adrian $
  */
 
 /*
@@ -874,11 +874,14 @@
 #define	ath_hal_settpcts(_ah, _tpcts) \
 	ath_hal_setcapability(_ah, HAL_CAP_TPC_CTS, 0, _tpcts, NULL)
 #define	ath_hal_hasintmit(_ah) \
-	(ath_hal_getcapability(_ah, HAL_CAP_INTMIT, HAL_CAP_INTMIT_PRESENT, NULL) == HAL_OK)
+	(ath_hal_getcapability(_ah, HAL_CAP_INTMIT, \
+	HAL_CAP_INTMIT_PRESENT, NULL) == HAL_OK)
 #define	ath_hal_getintmit(_ah) \
-	(ath_hal_getcapability(_ah, HAL_CAP_INTMIT, HAL_CAP_INTMIT_ENABLE, NULL) == HAL_OK)
+	(ath_hal_getcapability(_ah, HAL_CAP_INTMIT, \
+	HAL_CAP_INTMIT_ENABLE, NULL) == HAL_OK)
 #define	ath_hal_setintmit(_ah, _v) \
-	ath_hal_setcapability(_ah, HAL_CAP_INTMIT, HAL_CAP_INTMIT_ENABLE, _v, NULL)
+	ath_hal_setcapability(_ah, HAL_CAP_INTMIT, \
+	HAL_CAP_INTMIT_ENABLE, _v, NULL)
 #define	ath_hal_getchannoise(_ah, _c) \
 	((*(_ah)->ah_getChanNoise)((_ah), (_c)))
 #define	ath_hal_getrxchainmask(_ah, _prxchainmask) \
@@ -886,14 +889,16 @@
 #define	ath_hal_gettxchainmask(_ah, _ptxchainmask) \
 	(ath_hal_getcapability(_ah, HAL_CAP_TX_CHAINMASK, 0, _ptxchainmask))
 #define	ath_hal_split4ktrans(_ah) \
-	(ath_hal_getcapability(_ah, HAL_CAP_SPLIT_4KB_TRANS, 0, NULL) == HAL_OK)
+	(ath_hal_getcapability(_ah, HAL_CAP_SPLIT_4KB_TRANS, \
+	0, NULL) == HAL_OK)
 #define	ath_hal_self_linked_final_rxdesc(_ah) \
-	(ath_hal_getcapability(_ah, HAL_CAP_RXDESC_SELFLINK, 0, NULL) == HAL_OK)
+	(ath_hal_getcapability(_ah, HAL_CAP_RXDESC_SELFLINK, \
+	0, NULL) == HAL_OK)
 #define	ath_hal_gtxto_supported(_ah) \
 	(ath_hal_getcapability(_ah, HAL_CAP_GTXTO, 0, NULL) == HAL_OK)
 #define	ath_hal_has_long_rxdesc_tsf(_ah) \
-	(ath_hal_getcapability(_ah, HAL_CAP_LONG_RXDESC_TSF, 0, NULL) == HAL_OK)
-
+	(ath_hal_getcapability(_ah, HAL_CAP_LONG_RXDESC_TSF, \
+	0, NULL) == HAL_OK)
 #define	ath_hal_setuprxdesc(_ah, _ds, _size, _intreq) \
 	((*(_ah)->ah_setupRxDesc)((_ah), (_ds), (_size), (_intreq)))
 #define	ath_hal_rxprocdesc(_ah, _ds, _dspa, _dsnext, _rs) \
@@ -945,6 +950,15 @@
 #define	ath_hal_clr11n_aggr(_ah, _ds) \
 	((*(_ah)->ah_clr11nAggr)((_ah), (_ds)))
 
+#define	ath_hal_gpioCfgOutput(_ah, _gpio, _type) \
+	((*(_ah)->ah_gpioCfgOutput)((_ah), (_gpio), (_type)))
+#define	ath_hal_gpioset(_ah, _gpio, _b) \
+	((*(_ah)->ah_gpioSet)((_ah), (_gpio), (_b)))
+#define	ath_hal_gpioget(_ah, _gpio) \
+	((*(_ah)->ah_gpioGet)((_ah), (_gpio)))
+#define	ath_hal_gpiosetintr(_ah, _gpio, _b) \
+	((*(_ah)->ah_gpioSetIntr)((_ah), (_gpio), (_b)))
+
 /*
  * This is badly-named; you need to set the correct parameters
  * to begin to receive useful radar events; and even then
@@ -956,20 +970,13 @@
 #define	ath_hal_getdfsthresh(_ah, _param) \
 	((*(_ah)->ah_getDfsThresh)((_ah), (_param)))
 #define	ath_hal_procradarevent(_ah, _rxs, _fulltsf, _buf, _event) \
-	((*(_ah)->ah_procRadarEvent)((_ah), (_rxs), (_fulltsf), (_buf), (_event)))
+	((*(_ah)->ah_procRadarEvent)((_ah), (_rxs), (_fulltsf), \
+	(_buf), (_event)))
 #define	ath_hal_is_fast_clock_enabled(_ah) \
 	((*(_ah)->ah_isFastClockEnabled)((_ah)))
-
-#define ath_hal_gpioCfgOutput(_ah, _gpio, _type) \
-        ((*(_ah)->ah_gpioCfgOutput)((_ah), (_gpio), (_type)))
-#define ath_hal_gpioset(_ah, _gpio, _b) \
-        ((*(_ah)->ah_gpioSet)((_ah), (_gpio), (_b)))
-#define ath_hal_gpioget(_ah, _gpio) \
-        ((*(_ah)->ah_gpioGet)((_ah), (_gpio)))
-#define ath_hal_gpiosetintr(_ah, _gpio, _b) \
-        ((*(_ah)->ah_gpioSetIntr)((_ah), (_gpio), (_b)))
-
-#define ath_hal_radar_wait(_ah, _chan) \
+#define	ath_hal_radar_wait(_ah, _chan) \
 	((*(_ah)->ah_radarWait)((_ah), (_chan)))
+#define	ath_hal_get_chan_ext_busy(_ah) \
+	((*(_ah)->ah_get11nExtBusy)((_ah)))
 
 #endif /* _DEV_ATH_ATHVAR_H */
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/dev/bge/if_bge.c
--- a/head/sys/dev/bge/if_bge.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/dev/bge/if_bge.c	Wed Feb 01 12:34:54 2012 +0200
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/dev/bge/if_bge.c 228480 2011-12-13 20:31:57Z yongari $");
+__FBSDID("$FreeBSD: head/sys/dev/bge/if_bge.c 230338 2012-01-19 20:28:58Z yongari $");
 
 /*
  * Broadcom BCM570x family gigabit ethernet driver for FreeBSD.
@@ -2745,6 +2745,9 @@
 {
 	int can_use_msi = 0;
 
+	if (sc->bge_msi == 0)
+		return (0);
+
 	/* Disable MSI for polling(4). */
 #ifdef DEVICE_POLLING
 	return (0);
@@ -5627,6 +5630,12 @@
 	    "Number of fragmented TX buffers of a frame allowed before "
 	    "forced collapsing");
 
+	sc->bge_msi = 1;
+	snprintf(tn, sizeof(tn), "dev.bge.%d.msi", unit);
+	TUNABLE_INT_FETCH(tn, &sc->bge_msi);
+	SYSCTL_ADD_INT(ctx, children, OID_AUTO, "msi",
+	    CTLFLAG_RD, &sc->bge_msi, 0, "Enable MSI");
+
 	/*
 	 * It seems all Broadcom controllers have a bug that can generate UDP
 	 * datagrams with checksum value 0 when TX UDP checksum offloading is
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/dev/bge/if_bgereg.h
--- a/head/sys/dev/bge/if_bgereg.h	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/dev/bge/if_bgereg.h	Wed Feb 01 12:34:54 2012 +0200
@@ -30,7 +30,7 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  * THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: head/sys/dev/bge/if_bgereg.h 228479 2011-12-13 20:26:46Z yongari $
+ * $FreeBSD: head/sys/dev/bge/if_bgereg.h 230337 2012-01-19 20:21:59Z yongari $
  */
 
 /*
@@ -2864,6 +2864,7 @@
 	int			bge_timer;
 	int			bge_forced_collapse;
 	int			bge_forced_udpcsum;
+	int			bge_msi;
 	int			bge_csum_features;
 	struct callout		bge_stat_ch;
 	uint32_t		bge_rx_discards;
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/dev/ciss/ciss.c
--- a/head/sys/dev/ciss/ciss.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/dev/ciss/ciss.c	Wed Feb 01 12:34:54 2012 +0200
@@ -24,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *	$FreeBSD: head/sys/dev/ciss/ciss.c 229997 2012-01-12 00:34:33Z ken $
+ *	$FreeBSD: head/sys/dev/ciss/ciss.c 230588 2012-01-26 17:04:17Z sbruno $
  */
 
 /*
@@ -329,6 +329,13 @@
     { 0x103C, 0x3249, CISS_BOARD_SA5,	"HP Smart Array P812" },
     { 0x103C, 0x324A, CISS_BOARD_SA5,	"HP Smart Array P712m" },
     { 0x103C, 0x324B, CISS_BOARD_SA5,	"HP Smart Array" },
+    { 0x103C, 0x3350, CISS_BOARD_SA5,   "HP Smart Array P222" },
+    { 0x103C, 0x3351, CISS_BOARD_SA5,   "HP Smart Array P420" },
+    { 0x103C, 0x3352, CISS_BOARD_SA5,   "HP Smart Array P421" },
+    { 0x103C, 0x3353, CISS_BOARD_SA5,   "HP Smart Array P822" },
+    { 0x103C, 0x3354, CISS_BOARD_SA5,   "HP Smart Array P420i" },
+    { 0x103C, 0x3355, CISS_BOARD_SA5,   "HP Smart Array P220i" },
+    { 0x103C, 0x3356, CISS_BOARD_SA5,   "HP Smart Array P721m" },
     { 0, 0, 0, NULL }
 };
 
@@ -4535,7 +4542,8 @@
 
 	pis->bus = pci_get_bus(sc->ciss_dev);
 	pis->dev_fn = pci_get_slot(sc->ciss_dev);
-	pis->board_id = pci_get_devid(sc->ciss_dev);
+        pis->board_id = (pci_get_subvendor(sc->ciss_dev) << 16) |
+                pci_get_subdevice(sc->ciss_dev);
 
 	break;
     }
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/dev/e1000/README
--- a/head/sys/dev/e1000/README	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/dev/e1000/README	Wed Feb 01 12:34:54 2012 +0200
@@ -1,4 +1,4 @@
-$FreeBSD$
+$FreeBSD: head/sys/dev/e1000/README 230742 2012-01-29 14:52:42Z eadler $
 FreeBSD* Driver for Intel Network Connection
 =============================================
 
@@ -354,6 +354,7 @@
   include:
         Planex FXG-08TE
         I-O Data ETG-SH8
+        Netgear GS105v3
 
   The driver can be compiled with the following changes:
 
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/dev/fe/if_fe.c
--- a/head/sys/dev/fe/if_fe.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/dev/fe/if_fe.c	Wed Feb 01 12:34:54 2012 +0200
@@ -21,7 +21,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: head/sys/dev/fe/if_fe.c 230789 2012-01-30 22:47:02Z imp $");
 
 /*
  *
@@ -2255,6 +2255,7 @@
 static void
 fe_medstat (struct ifnet *ifp, struct ifmediareq *ifmr)
 {
-	(void)ifp;
-	(void)ifmr;
+	struct fe_softc *sc = ifp->if_softc;
+
+	ifmr->ifm_active = sc->media.ifm_media;
 }
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/dev/firewire/sbp_targ.c
--- a/head/sys/dev/firewire/sbp_targ.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/dev/firewire/sbp_targ.c	Wed Feb 01 12:34:54 2012 +0200
@@ -31,7 +31,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  * 
- * $FreeBSD: head/sys/dev/firewire/sbp_targ.c 227293 2011-11-07 06:44:47Z ed $
+ * $FreeBSD: head/sys/dev/firewire/sbp_targ.c 230558 2012-01-25 23:33:50Z sbruno $
  */
 
 #include <sys/param.h>
@@ -62,6 +62,7 @@
 #include <cam/cam_debug.h>
 #include <cam/cam_periph.h>
 #include <cam/scsi/scsi_all.h>
+#include <cam/scsi/scsi_message.h>
 
 #define SBP_TARG_RECV_LEN	8
 #define MAX_INITIATORS		8
@@ -186,6 +187,21 @@
 #endif
 };
 
+ 
+/*
+ * Urestricted page table format 
+ * states that the segment length
+ * and high base addr are in the first
+ * 32 bits and the base low is in 
+ * the second
+ */
+struct unrestricted_page_table_fmt {
+	uint16_t segment_len;
+	uint16_t segment_base_high;
+	uint32_t segment_base_low;
+};
+
+
 struct orb_info {
 	struct sbp_targ_softc *sc;
 	struct fw_device *fwdev;
@@ -208,7 +224,10 @@
 	struct corb4 orb4;
 	STAILQ_ENTRY(orb_info) link;
 	uint32_t orb[8];
-	uint32_t *page_table;
+	struct unrestricted_page_table_fmt *page_table;
+	struct unrestricted_page_table_fmt *cur_pte;
+	struct unrestricted_page_table_fmt *last_pte;
+	uint32_t  last_block_read;
 	struct sbp_status status;
 };
 
@@ -219,6 +238,7 @@
 static void sbp_targ_recv(struct fw_xfer *);
 static void sbp_targ_fetch_orb(struct sbp_targ_softc *, struct fw_device *,
     uint16_t, uint32_t, struct sbp_targ_login *, int);
+static void sbp_targ_xfer_pt(struct orb_info *);
 static void sbp_targ_abort(struct sbp_targ_softc *, struct orb_info *);
 
 static void
@@ -252,13 +272,19 @@
 	}
 	for (orbi = STAILQ_FIRST(&login->orbs); orbi != NULL; orbi = next) {
 		next = STAILQ_NEXT(orbi, link);
+		if (debug)
+			printf("%s: free orbi %p\n", __func__, orbi);
 		free(orbi, M_SBP_TARG);
+		orbi = NULL;
 	}
 	callout_stop(&login->hold_callout);
 
 	STAILQ_REMOVE(&login->lstate->logins, login, sbp_targ_login, link);
 	login->lstate->sc->logins[login->id] = NULL;
+	if (debug)
+		printf("%s: free login %p\n", __func__, login);
 	free((void *)login, M_SBP_TARG);
+	login = NULL;
 }
 
 static void
@@ -361,20 +387,26 @@
 	if (ccb->ccb_h.target_id == CAM_TARGET_WILDCARD &&
 	    ccb->ccb_h.target_lun == CAM_LUN_WILDCARD) {
 		*lstate = sc->black_hole;
+		if (debug)
+			printf("setting black hole for this target id(%d)\n", ccb->ccb_h.target_id);
 		return (CAM_REQ_CMP);
 	}
 
-	if (ccb->ccb_h.target_id != 0)
-		return (CAM_TID_INVALID);
-
 	lun = ccb->ccb_h.target_lun;
 	if (lun >= MAX_LUN)
 		return (CAM_LUN_INVALID);
 	
 	*lstate = sc->lstate[lun];
 
-	if (notfound_failure != 0 && *lstate == NULL)
+	if (notfound_failure != 0 && *lstate == NULL) {
+		if (debug)
+			printf("%s: lstate for lun is invalid, target(%d), lun(%d)\n",
+				__func__, ccb->ccb_h.target_id, lun);
 		return (CAM_PATH_INVALID);
+	} else
+		if (debug)
+			printf("%s: setting lstate for tgt(%d) lun(%d)\n",
+				__func__,ccb->ccb_h.target_id, lun);
 
 	return (CAM_REQ_CMP);
 }
@@ -411,11 +443,18 @@
 			printf("Couldn't allocate lstate\n");
 			ccb->ccb_h.status = CAM_RESRC_UNAVAIL;
 			return;
-		}
-		if (ccb->ccb_h.target_id == CAM_TARGET_WILDCARD)
+		} else {
+			if (debug)
+				printf("%s: malloc'd lstate %p\n",__func__, lstate);
+		}	
+		if (ccb->ccb_h.target_id == CAM_TARGET_WILDCARD) {
 			sc->black_hole = lstate;
-		else
+			if (debug)
+				printf("Blackhole set due to target id == %d\n",
+					ccb->ccb_h.target_id);
+		} else
 			sc->lstate[ccb->ccb_h.target_lun] = lstate;
+
 		memset(lstate, 0, sizeof(*lstate));
 		lstate->sc = sc;
 		status = xpt_create_path(&lstate->path, /*periph*/NULL,
@@ -424,6 +463,7 @@
 					 xpt_path_lun_id(ccb->ccb_h.path));
 		if (status != CAM_REQ_CMP) {
 			free(lstate, M_SBP_TARG);
+			lstate = NULL;
 			xpt_print_path(ccb->ccb_h.path);
 			printf("Couldn't allocate path\n");
 			ccb->ccb_h.status = CAM_RESRC_UNAVAIL;
@@ -443,6 +483,7 @@
 
 		if (lstate == NULL) {
 			ccb->ccb_h.status = CAM_LUN_INVALID;
+			printf("Invalid lstate for this target\n");
 			return;
 		}
 		ccb->ccb_h.status = CAM_REQ_CMP;
@@ -458,6 +499,7 @@
 		}
 
 		if (ccb->ccb_h.status != CAM_REQ_CMP) {
+			printf("status != CAM_REQ_CMP\n");
 			return;
 		}
 
@@ -475,7 +517,10 @@
 			sc->black_hole = NULL;
 		else
 			sc->lstate[ccb->ccb_h.target_lun] = NULL;
+		if (debug)
+			printf("%s: free lstate %p\n", __func__, lstate);
 		free(lstate, M_SBP_TARG);
+		lstate = NULL;
 
 		/* bus reset */
 		sc->fd.fc->ibr(sc->fd.fc);
@@ -538,7 +583,7 @@
 		if (orbi->orb_lo == tag_id)
 			goto found;
 	printf("%s: orb not found tag_id=0x%08x init_id=%d\n",
-				 __func__, tag_id, init_id);
+			 __func__, tag_id, init_id);
 	return (NULL);
 found:
 	return (orbi);
@@ -559,12 +604,13 @@
 				xpt_done(orbi->ccb);
 				orbi->ccb = NULL;
 			}
-#if 0
 			if (orbi->state <= ORBI_STATUS_ATIO) {
 				sbp_targ_remove_orb_info_locked(orbi->login, orbi);
+				if (debug)
+					printf("%s: free orbi %p\n", __func__, orbi);
 				free(orbi, M_SBP_TARG);
+				orbi = NULL;
 			} else
-#endif
 				orbi->state = ORBI_STATUS_ABORTED;
 		}
 	}
@@ -576,12 +622,21 @@
 {
 	struct orb_info *orbi;
 
-	orbi = (struct orb_info *)xfer->sc;
 	if (xfer->resp != 0) {
 		/* XXX */
 		printf("%s: xfer->resp = %d\n", __func__, xfer->resp);
 	}
+	orbi = (struct orb_info *)xfer->sc;
+	if ( orbi->page_table != NULL ) {
+		if (debug)
+			printf("%s:  free orbi->page_table %p\n", __func__, orbi->page_table);
+		free(orbi->page_table, M_SBP_TARG);
+		orbi->page_table = NULL;
+	}
+	if (debug)
+		printf("%s: free orbi %p\n", __func__, orbi);
 	free(orbi, M_SBP_TARG);
+	orbi = NULL;
 	fw_xfer_free(xfer);
 }
 
@@ -595,7 +650,7 @@
 		sbp_targ_remove_orb_info(orbi->login, orbi);
 
 	xfer = fwmem_write_block(orbi->fwdev, (void *)orbi,
-	    /*spd*/2, fifo_hi, fifo_lo,
+	    /*spd*/FWSPD_S400, fifo_hi, fifo_lo,
 	    sizeof(uint32_t) * (orbi->status.len + 1), (char *)&orbi->status,
 	    sbp_targ_free_orbi);
 
@@ -605,6 +660,10 @@
 	}
 }
 
+/*
+ * Generate the appropriate CAM status for the
+ * target.
+ */
 static void
 sbp_targ_send_status(struct orb_info *orbi, union ccb *ccb)
 {
@@ -621,6 +680,8 @@
 	sbp_status->status = 0; /* XXX */
 	sbp_status->dead = 0; /* XXX */
 
+	ccb->ccb_h.status= CAM_REQ_CMP;
+
 	switch (ccb->csio.scsi_status) {
 	case SCSI_STATUS_OK:
 		if (debug)
@@ -628,8 +689,15 @@
 		sbp_status->len = 1;
 		break;
 	case SCSI_STATUS_CHECK_COND:
+		if (debug)
+			printf("%s: STATUS SCSI_STATUS_CHECK_COND\n", __func__);
+		goto process_scsi_status;
 	case SCSI_STATUS_BUSY:
+		if (debug)
+			printf("%s: STATUS SCSI_STATUS_BUSY\n", __func__);
+		goto process_scsi_status;
 	case SCSI_STATUS_CMD_TERMINATED:
+process_scsi_status:
 	{
 		struct sbp_cmd_status *sbp_cmd_status;
 		struct scsi_sense_data *sense;
@@ -640,9 +708,6 @@
 		int64_t sinfo;
 		int sense_len;
 
-		if (debug)
-			printf("%s: STATUS %d\n", __func__,
-			    ccb->csio.scsi_status);
 		sbp_cmd_status = (struct sbp_cmd_status *)&sbp_status->data[0];
 		sbp_cmd_status->status = ccb->csio.scsi_status;
 		sense = &ccb->csio.sense_data;
@@ -734,6 +799,7 @@
 		if (scsi_get_sks(sense, sense_len, sks) == 0) {
 			bcopy(sks, &sbp_cmd_status->s_keydep[0], sizeof(sks));
 			sbp_status->len = 5;
+			ccb->ccb_h.status |= CAM_SENT_SENSE;
 		}
 
 		break;
@@ -743,13 +809,20 @@
 		    sbp_status->status);
 	}
 
-	if (orbi->page_table != NULL)
-		free(orbi->page_table, M_SBP_TARG);
 
 	sbp_targ_status_FIFO(orbi,
 	    orbi->login->fifo_hi, orbi->login->fifo_lo, /*dequeue*/1);
 }
 
+/*
+ * Invoked as a callback handler from fwmem_read/write_block
+ *
+ * Process read/write of initiator address space
+ * completion and pass status onto the backend target.
+ * If this is a partial read/write for a CCB then
+ * we decrement the orbi's refcount to indicate
+ * the status of the read/write is complete
+ */
 static void
 sbp_targ_cam_done(struct fw_xfer *xfer)
 {
@@ -758,7 +831,7 @@
 
 	orbi = (struct orb_info *)xfer->sc;
 
-	if (debug > 1)
+	if (debug)
 		printf("%s: resp=%d refcount=%d\n", __func__,
 			xfer->resp, orbi->refcount);
 
@@ -779,13 +852,26 @@
 			if (debug)
 				printf("%s: orbi aborted\n", __func__);
 			sbp_targ_remove_orb_info(orbi->login, orbi);
-			if (orbi->page_table != NULL)
+			if (orbi->page_table != NULL) {
+				if (debug)
+					printf("%s: free orbi->page_table %p\n",
+						__func__, orbi->page_table);
 				free(orbi->page_table, M_SBP_TARG);
+			}
+			if (debug)
+				printf("%s: free orbi %p\n", __func__, orbi);
 			free(orbi, M_SBP_TARG);
-		} else if (orbi->status.resp == 0) {
-			if ((ccb->ccb_h.flags & CAM_SEND_STATUS) != 0)
+			orbi = NULL;
+		} else if (orbi->status.resp == ORBI_STATUS_NONE) {
+			if ((ccb->ccb_h.flags & CAM_SEND_STATUS) != 0) {
+				if (debug) 
+					printf("%s: CAM_SEND_STATUS set %0x\n", __func__, ccb->ccb_h.flags);
 				sbp_targ_send_status(orbi, ccb);
-			ccb->ccb_h.status = CAM_REQ_CMP;
+			} else {
+				if (debug)
+					printf("%s: CAM_SEND_STATUS not set %0x\n", __func__, ccb->ccb_h.flags);
+				ccb->ccb_h.status = CAM_REQ_CMP;
+			}
 			SBP_LOCK(orbi->sc);
 			xpt_done(ccb);
 			SBP_UNLOCK(orbi->sc);
@@ -855,6 +941,13 @@
 	return (CAM_PATH_INVALID);
 }
 
+/*
+ * directly execute a read or write to the initiator
+ * address space and set hand(sbp_targ_cam_done) to 
+ * process the completion from the SIM to the target.
+ * set orbi->refcount to inidicate that a read/write
+ * is inflight to/from the initiator.
+ */
 static void
 sbp_targ_xfer_buf(struct orb_info *orbi, u_int offset,
     uint16_t dst_hi, uint32_t dst_lo, u_int size,
@@ -874,16 +967,21 @@
 		len = MIN(size, 2048 /* XXX */);
 		size -= len;
 		orbi->refcount ++;
-		if (ccb_dir == CAM_DIR_OUT)
+		if (ccb_dir == CAM_DIR_OUT) {
+			if (debug)
+				printf("%s: CAM_DIR_OUT --> read block in?\n",__func__);
 			xfer = fwmem_read_block(orbi->fwdev,
-			   (void *)orbi, /*spd*/2,
+			   (void *)orbi, /*spd*/FWSPD_S400,
 			    dst_hi, dst_lo + off, len,
 			    ptr + off, hand);
-		else
+		} else {
+			if (debug)
+				printf("%s: CAM_DIR_IN --> write block out?\n",__func__);
 			xfer = fwmem_write_block(orbi->fwdev,
-			   (void *)orbi, /*spd*/2,
+			   (void *)orbi, /*spd*/FWSPD_S400,
 			    dst_hi, dst_lo + off, len,
 			    ptr + off, hand);
+		}
 		if (xfer == NULL) {
 			printf("%s: xfer == NULL", __func__);
 			/* XXX what should we do?? */
@@ -897,18 +995,22 @@
 sbp_targ_pt_done(struct fw_xfer *xfer)
 {
 	struct orb_info *orbi;
-	union ccb *ccb;
-	u_int i, offset, res, len;
-	uint32_t t1, t2, *p;
+	struct unrestricted_page_table_fmt *pt;
+	uint32_t i;
 
 	orbi = (struct orb_info *)xfer->sc;
-	ccb = orbi->ccb;
+
 	if (orbi->state == ORBI_STATUS_ABORTED) {
 		if (debug)
 			printf("%s: orbi aborted\n", __func__);
 		sbp_targ_remove_orb_info(orbi->login, orbi);
+		if (debug) {
+			printf("%s: free orbi->page_table %p\n", __func__, orbi->page_table);
+			printf("%s: free orbi %p\n", __func__, orbi);
+		}
 		free(orbi->page_table, M_SBP_TARG);
 		free(orbi, M_SBP_TARG);
+		orbi = NULL;
 		fw_xfer_free(xfer);
 		return;
 	}
@@ -920,60 +1022,158 @@
 		orbi->status.len = 1;
 		sbp_targ_abort(orbi->sc, STAILQ_NEXT(orbi, link));
 
+		if (debug)
+			printf("%s: free orbi->page_table %p\n", __func__, orbi->page_table);
+
 		sbp_targ_status_FIFO(orbi,
 		    orbi->login->fifo_hi, orbi->login->fifo_lo, /*dequeue*/1);
 		free(orbi->page_table, M_SBP_TARG);
+		orbi->page_table = NULL;
 		fw_xfer_free(xfer);
 		return;
 	}
-	res = ccb->csio.dxfer_len;
-	offset = 0;
-	if (debug)
-		printf("%s: dxfer_len=%d\n", __func__, res);
-	orbi->refcount ++;
-	for (p = orbi->page_table, i = orbi->orb4.data_size; i > 0; i --) {
-		t1 = ntohl(*p++);
-		t2 = ntohl(*p++);
-		if (debug > 1)
-			printf("page_table: %04x:%08x %d\n", 
-			    t1 & 0xffff, t2, t1>>16);
-		len = MIN(t1 >> 16, res);
-		res -= len;
-		sbp_targ_xfer_buf(orbi, offset, t1 & 0xffff, t2, len,
-		    sbp_targ_cam_done);
-		offset += len;
-		if (res == 0)
-			break;
+	orbi->refcount++;
+/*
+ * Set endianess here so we don't have 
+ * to deal with is later
+ */
+	for (i = 0, pt = orbi->page_table; i < orbi->orb4.data_size; i++, pt++) {
+		pt->segment_len = ntohs(pt->segment_len);
+		if (debug)
+			printf("%s:segment_len = %u\n", __func__,pt->segment_len);
+		pt->segment_base_high = ntohs(pt->segment_base_high);
+		pt->segment_base_low = ntohl(pt->segment_base_low);
 	}
-	orbi->refcount --;
+
+	sbp_targ_xfer_pt(orbi);
+
+	orbi->refcount--;
 	if (orbi->refcount == 0)
 		printf("%s: refcount == 0\n", __func__);
-	if (res !=0)
-		/* XXX handle res != 0 case */
-		printf("%s: page table is too small(%d)\n", __func__, res);
 
 	fw_xfer_free(xfer);
 	return;
 }
 
+static void sbp_targ_xfer_pt(struct orb_info *orbi)
+{
+	union ccb *ccb;
+	uint32_t res, offset, len;
+
+	ccb = orbi->ccb;
+	if (debug)
+		printf("%s: dxfer_len=%d\n", __func__, ccb->csio.dxfer_len);
+	res = ccb->csio.dxfer_len;
+	/*
+	 * If the page table required multiple CTIO's to 
+	 * complete, then cur_pte is non NULL 
+	 * and we need to start from the last position
+	 * If this is the first pass over a page table
+	 * then we just start at the beginning of the page
+	 * table.
+	 *
+	 * Parse the unrestricted page table and figure out where we need
+	 * to shove the data from this read request.
+	 */
+	for (offset = 0, len = 0; (res != 0) && (orbi->cur_pte < orbi->last_pte); offset += len) {
+		len = MIN(orbi->cur_pte->segment_len, res);
+		res -= len;
+		if (debug)
+			printf("%s:page_table: %04x:%08x segment_len(%u) res(%u) len(%u)\n", 
+				__func__, orbi->cur_pte->segment_base_high,
+				orbi->cur_pte->segment_base_low,
+				orbi->cur_pte->segment_len,
+				res, len);
+		sbp_targ_xfer_buf(orbi, offset, 
+				orbi->cur_pte->segment_base_high,
+				orbi->cur_pte->segment_base_low,
+				len, sbp_targ_cam_done);
+		/*
+		 * If we have only written partially to
+		 * this page table, then we need to save
+		 * our position for the next CTIO.  If we
+		 * have completed the page table, then we
+		 * are safe to move on to the next entry.
+		 */
+		if (len == orbi->cur_pte->segment_len) {
+			orbi->cur_pte++;
+		} else {
+			uint32_t saved_base_low;
+
+			/* Handle transfers that cross a 4GB boundary. */
+			saved_base_low = orbi->cur_pte->segment_base_low;
+			orbi->cur_pte->segment_base_low += len;
+			if (orbi->cur_pte->segment_base_low < saved_base_low)
+				orbi->cur_pte->segment_base_high++;
+
+			orbi->cur_pte->segment_len -= len;
+		}
+	}
+	if (debug) {
+		printf("%s: base_low(%08x) page_table_off(%p) last_block(%u)\n",
+			__func__, orbi->cur_pte->segment_base_low, 
+			orbi->cur_pte, orbi->last_block_read);  
+	}
+	if (res != 0)
+		printf("Warning - short pt encountered.  "
+			"Could not transfer all data.\n");
+	return;
+}
+
+/*
+ * Create page table in local memory
+ * and transfer it from the initiator
+ * in order to know where we are supposed
+ * to put the data.
+ */
+
 static void
 sbp_targ_fetch_pt(struct orb_info *orbi)
 {
 	struct fw_xfer *xfer;
 
-	if (debug)
-		printf("%s: page_table_size=%d\n",
-		    __func__, orbi->orb4.data_size);
-	orbi->page_table = malloc(orbi->orb4.data_size*8, M_SBP_TARG, M_NOWAIT);
-	if (orbi->page_table == NULL)
-		goto error;
-	xfer = fwmem_read_block(orbi->fwdev, (void *)orbi, /*spd*/2,
-		    orbi->data_hi, orbi->data_lo, orbi->orb4.data_size*8,
-			    (void *)orbi->page_table, sbp_targ_pt_done);
-	if (xfer != NULL)
+	/*
+	 * Pull in page table from initiator
+	 * and setup for data from our
+	 * backend device.
+	 */
+	if (orbi->page_table == NULL) {
+		orbi->page_table = malloc(orbi->orb4.data_size*
+					  sizeof(struct unrestricted_page_table_fmt),
+					  M_SBP_TARG, M_NOWAIT|M_ZERO);
+		if (orbi->page_table == NULL)
+			goto error;
+		orbi->cur_pte = orbi->page_table;
+		orbi->last_pte = orbi->page_table + orbi->orb4.data_size;
+		orbi->last_block_read = orbi->orb4.data_size;
+		if (debug && orbi->page_table != NULL) 
+			printf("%s: malloc'd orbi->page_table(%p), orb4.data_size(%u)\n",
+ 				__func__, orbi->page_table, orbi->orb4.data_size);
+
+		xfer = fwmem_read_block(orbi->fwdev, (void *)orbi, /*spd*/FWSPD_S400,
+					orbi->data_hi, orbi->data_lo, orbi->orb4.data_size*
+					sizeof(struct unrestricted_page_table_fmt),
+					(void *)orbi->page_table, sbp_targ_pt_done);
+
+		if (xfer != NULL)
+			return;
+	} else {
+		/*
+		 * This is a CTIO for a page table we have
+		 * already malloc'd, so just directly invoke
+		 * the xfer function on the orbi.
+		 */
+		sbp_targ_xfer_pt(orbi);
 		return;
+	}
 error:
 	orbi->ccb->ccb_h.status = CAM_RESRC_UNAVAIL;
+	if (debug)      
+		printf("%s: free orbi->page_table %p due to xfer == NULL\n", __func__, orbi->page_table);
+	if (orbi->page_table != NULL) {
+		free(orbi->page_table, M_SBP_TARG);
+		orbi->page_table = NULL;
+	}
 	xpt_done(orbi->ccb);
 	return;
 }
@@ -1016,6 +1216,8 @@
 			if (debug)
 				printf("%s: ctio aborted\n", __func__);
 			sbp_targ_remove_orb_info_locked(orbi->login, orbi);
+			if (debug)
+				printf("%s: free orbi %p\n", __func__, orbi);
 			free(orbi, M_SBP_TARG);
 			ccb->ccb_h.status = CAM_REQ_ABORTED;
 			xpt_done(ccb);
@@ -1051,17 +1253,16 @@
 		}
 
 		/* Sanity check */
-		if (ccb_dir != CAM_DIR_NONE &&
-		    orbi->orb4.data_size != ccb->csio.dxfer_len)
-			printf("%s: data_size(%d) != dxfer_len(%d)\n",
-			    __func__, orbi->orb4.data_size,
-			    ccb->csio.dxfer_len);
-
-		if (ccb_dir != CAM_DIR_NONE)
+		if (ccb_dir != CAM_DIR_NONE) {
 			sbp_targ_xfer_buf(orbi, 0, orbi->data_hi,
 			    orbi->data_lo,
 			    MIN(orbi->orb4.data_size, ccb->csio.dxfer_len),
 			    sbp_targ_cam_done);
+			if ( orbi->orb4.data_size > ccb->csio.dxfer_len ) {
+				orbi->data_lo += ccb->csio.dxfer_len;
+				orbi->orb4.data_size -= ccb->csio.dxfer_len;
+			}
+		}
 
 		if (ccb_dir == CAM_DIR_NONE) {
 			if ((ccb->ccb_h.flags & CAM_SEND_STATUS) != 0) {
@@ -1125,7 +1326,8 @@
 		cpi->target_sprt = PIT_PROCESSOR
 				 | PIT_DISCONNECT
 				 | PIT_TERM_IO;
-		cpi->hba_misc = PIM_NOBUSRESET | PIM_NO_6_BYTE;
+		cpi->transport = XPORT_SPI; /* FIXME add XPORT_FW type to cam */
+		cpi->hba_misc = PIM_NOBUSRESET | PIM_NOBUSRESET;
 		cpi->hba_eng_cnt = 0;
 		cpi->max_target = 7; /* XXX */
 		cpi->max_lun = MAX_LUN - 1;
@@ -1163,10 +1365,42 @@
 		xpt_done(ccb);
 		break;
 	}
+#ifdef CAM_NEW_TRAN_CODE
+	case XPT_SET_TRAN_SETTINGS:
+		ccb->ccb_h.status = CAM_REQ_INVALID;
+		xpt_done(ccb);
+		break;
+	case XPT_GET_TRAN_SETTINGS:
+	{
+		struct ccb_trans_settings *cts = &ccb->cts;
+		struct ccb_trans_settings_scsi *scsi =
+			&cts->proto_specific.scsi;
+		struct ccb_trans_settings_spi *spi =
+			&cts->xport_specific.spi;
+
+		cts->protocol = PROTO_SCSI;
+		cts->protocol_version = SCSI_REV_2;
+		cts->transport = XPORT_FW;     /* should have a FireWire */
+		cts->transport_version = 2;
+		spi->valid = CTS_SPI_VALID_DISC;
+		spi->flags = CTS_SPI_FLAGS_DISC_ENB;
+		scsi->valid = CTS_SCSI_VALID_TQ;
+		scsi->flags = CTS_SCSI_FLAGS_TAG_ENB;
+#if 0
+		printf("%s:%d:%d XPT_GET_TRAN_SETTINGS:\n",
+			device_get_nameunit(sc->fd.dev),
+			ccb->ccb_h.target_id, ccb->ccb_h.target_lun);
+#endif
+		cts->ccb_h.status = CAM_REQ_CMP;
+		xpt_done(ccb);
+		break;
+	}
+#endif
+
 	default:
-		printf("%s: unknown function %d\n",
+		printf("%s: unknown function 0x%x\n",
 		    __func__, ccb->ccb_h.func_code);
-		ccb->ccb_h.status = CAM_REQ_INVALID;
+		ccb->ccb_h.status = CAM_PROVIDE_FAIL;
 		xpt_done(ccb);
 		break;
 	}
@@ -1245,7 +1479,7 @@
 	atio->ccb_h.target_id = 0; /* XXX */
 	atio->ccb_h.target_lun = orbi->login->lstate->lun;
 	atio->sense_len = 0;
-	atio->tag_action = 1; /* XXX */
+	atio->tag_action = MSG_SIMPLE_TASK;
 	atio->tag_id = orbi->orb_lo;
 	atio->init_id = orbi->login->id;
 
@@ -1429,7 +1663,7 @@
 		login->loginres.recon_hold = htons(login->hold_sec);
 
 		STAILQ_INSERT_TAIL(&lstate->logins, login, link);
-		fwmem_write_block(orbi->fwdev, NULL, /*spd*/2, orb[2], orb[3],
+		fwmem_write_block(orbi->fwdev, NULL, /*spd*/FWSPD_S400, orb[2], orb[3],
 		    sizeof(struct sbp_login_res), (void *)&login->loginres,
 		    fw_asy_callback_free);
 		/* XXX return status after loginres is successfully written */
@@ -1515,10 +1749,11 @@
 	orbi->orb_lo = orb_lo;
 	orbi->status.orb_hi = htons(orb_hi);
 	orbi->status.orb_lo = htonl(orb_lo);
+	orbi->page_table = NULL;
 
 	switch (mode) {
 	case FETCH_MGM:
-		fwmem_read_block(fwdev, (void *)orbi, /*spd*/2, orb_hi, orb_lo,
+		fwmem_read_block(fwdev, (void *)orbi, /*spd*/FWSPD_S400, orb_hi, orb_lo,
 		    sizeof(uint32_t) * 8, &orbi->orb[0],
 		    sbp_targ_mgm_handler);
 		break;
@@ -1545,14 +1780,14 @@
 		SLIST_REMOVE_HEAD(&login->lstate->accept_tios, sim_links.sle);
 		STAILQ_INSERT_TAIL(&login->orbs, orbi, link);
 		SBP_UNLOCK(sc);
-		fwmem_read_block(fwdev, (void *)orbi, /*spd*/2, orb_hi, orb_lo,
+		fwmem_read_block(fwdev, (void *)orbi, /*spd*/FWSPD_S400, orb_hi, orb_lo,
 		    sizeof(uint32_t) * 8, &orbi->orb[0],
 		    sbp_targ_cmd_handler);
 		break;
 	case FETCH_POINTER:
 		orbi->state = ORBI_STATUS_POINTER;
 		login->flags |= F_LINK_ACTIVE;
-		fwmem_read_block(fwdev, (void *)orbi, /*spd*/2, orb_hi, orb_lo,
+		fwmem_read_block(fwdev, (void *)orbi, /*spd*/FWSPD_S400, orb_hi, orb_lo,
 		    sizeof(uint32_t) * 2, &orbi->orb[0],
 		    sbp_targ_pointer_handler);
 		break;
@@ -1709,7 +1944,7 @@
 	if (rtcode != 0)
 		printf("%s: rtcode = %d\n", __func__, rtcode);
 	sfp = &xfer->send.hdr;
-	xfer->send.spd = 2; /* XXX */
+	xfer->send.spd = FWSPD_S400;
 	xfer->hand = sbp_targ_resp_callback;
 	sfp->mode.wres.dst = fp->mode.wreqb.src;
 	sfp->mode.wres.tlrt = fp->mode.wreqb.tlrt;
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/dev/fxp/if_fxp.c
--- a/head/sys/dev/fxp/if_fxp.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/dev/fxp/if_fxp.c	Wed Feb 01 12:34:54 2012 +0200
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/dev/fxp/if_fxp.c 228716 2011-12-19 19:00:34Z yongari $");
+__FBSDID("$FreeBSD: head/sys/dev/fxp/if_fxp.c 230526 2012-01-25 04:48:27Z imp $");
 
 /*
  * Intel EtherExpress Pro/100B PCI Fast Ethernet driver
@@ -2555,7 +2555,7 @@
 {
 	struct fxp_softc *sc = ifp->if_softc;
 	struct mii_data *mii;
-		struct mii_softc	*miisc;
+	struct mii_softc	*miisc;
 
 	mii = device_get_softc(sc->miibus);
 	FXP_LOCK(sc);
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/dev/hwpmc/hwpmc_x86.c
--- a/head/sys/dev/hwpmc/hwpmc_x86.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/dev/hwpmc/hwpmc_x86.c	Wed Feb 01 12:34:54 2012 +0200
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: head/sys/dev/hwpmc/hwpmc_x86.c 230636 2012-01-28 01:38:48Z emaste $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -250,7 +250,7 @@
 		return (NULL);
 
 	/* disallow sampling if we do not have an LAPIC */
-	if (!lapic_enable_pmc())
+	if (md != NULL && !lapic_enable_pmc())
 		for (i = 1; i < md->pmd_nclass; i++)
 			md->pmd_classdep[i].pcd_caps &= ~PMC_CAP_INTERRUPT;
 
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/dev/ie/if_ie.c
--- a/head/sys/dev/ie/if_ie.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/dev/ie/if_ie.c	Wed Feb 01 12:34:54 2012 +0200
@@ -51,7 +51,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/dev/ie/if_ie.c 229767 2012-01-07 09:41:57Z kevlo $");
+__FBSDID("$FreeBSD: head/sys/dev/ie/if_ie.c 230808 2012-01-31 13:00:40Z pluknet $");
 
 /*
  * Intel 82586 Ethernet chip
@@ -157,6 +157,9 @@
 
 #define IE_BUF_LEN	ETHER_MAX_LEN	/* length of transmit buffer */
 
+/* XXX this driver uses `volatile' and `caddr_t' to a fault. */
+typedef	volatile char *v_caddr_t;	/* core address, pointer to volatile */
+
 /* Forward declaration */
 struct ie_softc;
 
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/dev/iwn/if_iwn.c
--- a/head/sys/dev/iwn/if_iwn.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/dev/iwn/if_iwn.c	Wed Feb 01 12:34:54 2012 +0200
@@ -24,7 +24,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/dev/iwn/if_iwn.c 229375 2012-01-03 09:42:31Z bschmidt $");
+__FBSDID("$FreeBSD: head/sys/dev/iwn/if_iwn.c 230620 2012-01-27 17:39:02Z bschmidt $");
 
 #include <sys/param.h>
 #include <sys/sockio.h>
@@ -2813,11 +2813,13 @@
 		bitmap |= 1ULL << bit;
 	}
 	tap = sc->qid2tap[qid];
-	tid = WME_AC_TO_TID(tap->txa_ac);
-	wn = (void *)tap->txa_ni;
-	wn->agg[tid].bitmap = bitmap;
-	wn->agg[tid].startidx = start;
-	wn->agg[tid].nframes = nframes;
+	if (tap != NULL) {
+		tid = WME_AC_TO_TID(tap->txa_ac);
+		wn = (void *)tap->txa_ni;
+		wn->agg[tid].bitmap = bitmap;
+		wn->agg[tid].startidx = start;
+		wn->agg[tid].nframes = nframes;
+	}
 
 	seqno = le32toh(*(status + nframes)) & 0xfff;
 	for (lastidx = (seqno & 0xff); ring->read != lastidx;) {
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/dev/netmap/ixgbe_netmap.h
--- a/head/sys/dev/netmap/ixgbe_netmap.h	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/dev/netmap/ixgbe_netmap.h	Wed Feb 01 12:34:54 2012 +0200
@@ -24,7 +24,7 @@
  */
 
 /*
- * $FreeBSD: head/sys/dev/netmap/ixgbe_netmap.h 229939 2012-01-10 19:57:23Z luigi $
+ * $FreeBSD: head/sys/dev/netmap/ixgbe_netmap.h 230572 2012-01-26 09:55:16Z luigi $
  * $Id: ixgbe_netmap.h 9802 2011-12-02 18:42:37Z luigi $
  *
  * netmap modifications for ixgbe
@@ -191,6 +191,10 @@
  * (this is also true for every use of ring in the kernel).
  *
  * ring->avail is never used, only checked for bogus values.
+ *
+ * do_lock is set iff the function is called from the ioctl handler.
+ * In this case, grab a lock around the body, and also reclaim transmitted
+ * buffers irrespective of interrupt mitigation.
  */
 static int
 ixgbe_netmap_txsync(void *a, u_int ring_nr, int do_lock)
@@ -292,10 +296,11 @@
 			 * need this.
 			 */
 			curr->read.buffer_addr = htole64(paddr);
-			curr->read.olinfo_status = 0;
+			curr->read.olinfo_status = htole32(len << IXGBE_ADVTXD_PAYLEN_SHIFT);
 			curr->read.cmd_type_len =
 			    htole32(txr->txd_cmd | len |
 				(IXGBE_ADVTXD_DTYP_DATA |
+				    IXGBE_ADVTXD_DCMD_DEXT |
 				    IXGBE_ADVTXD_DCMD_IFCS |
 				    IXGBE_TXD_CMD_EOP | flags) );
 			/* If the buffer has changed, unload and reload map
@@ -328,15 +333,41 @@
 	}
 
 	/*
-	 * If no packets are sent, or there is no room in the tx ring,
-	 * Check whether there are completed transmissions.
-	 * Because this is expensive (we need a register etc.)
-	 * we only do it if absolutely necessary, i.e. there is no room
-	 * in the tx ring, or where were no completed transmissions
-	 * (meaning that probably the caller really wanted to check
-	 * for completed transmissions).
+	 * Reclaim buffers for completed transmissions.
+	 * Because this is expensive (we read a NIC register etc.)
+	 * we only do it in specific cases (see below).
+	 * In all cases kring->nr_kflags indicates which slot will be
+	 * checked upon a tx interrupt (nkr_num_slots means none).
 	 */
-	if (n == 0 || kring->nr_hwavail < 1) {
+	if (do_lock) {
+		j = 1; /* forced reclaim, ignore interrupts */
+		kring->nr_kflags = kring->nkr_num_slots;
+	} else if (kring->nr_hwavail > 0) {
+		j = 0; /* buffers still available: no reclaim, ignore intr. */
+		kring->nr_kflags = kring->nkr_num_slots;
+	} else {
+		/*
+		 * no buffers available, locate a slot for which we request
+		 * ReportStatus (approximately half ring after next_to_clean)
+		 * and record it in kring->nr_kflags.
+		 * If the slot has DD set, do the reclaim looking at TDH,
+		 * otherwise we go to sleep (in netmap_poll()) and will be
+		 * woken up when slot nr_kflags will be ready.
+		 */
+		struct ixgbe_legacy_tx_desc *txd = (struct ixgbe_legacy_tx_desc *)txr->tx_base;
+
+		j = txr->next_to_clean + kring->nkr_num_slots/2;
+		if (j >= kring->nkr_num_slots)
+			j -= kring->nkr_num_slots;
+		// round to the closest with dd set
+		j= (j < kring->nkr_num_slots / 4 || j >= kring->nkr_num_slots*3/4) ?
+			0 : report_frequency;
+		kring->nr_kflags = j; /* the slot to check */
+		j = txd[j].upper.fields.status & IXGBE_TXD_STAT_DD;
+	}
+	if (!j) {
+		netmap_skip_txsync++;
+	} else {
 		int delta;
 
 		/*
@@ -391,6 +422,8 @@
  * We must subtract the newly consumed slots (cur - nr_hwcur)
  * from nr_hwavail, make the descriptors available for the next reads,
  * and set kring->nr_hwcur = ring->cur and ring->avail = kring->nr_hwavail.
+ *
+ * do_lock has a special meaning: please refer to txsync.
  */
 static int
 ixgbe_netmap_rxsync(void *a, u_int ring_nr, int do_lock)
@@ -401,6 +434,7 @@
 	struct netmap_kring *kring = &na->rx_rings[ring_nr];
 	struct netmap_ring *ring = kring->ring;
 	int j, k, l, n, lim = kring->nkr_num_slots - 1;
+	int force_update = do_lock || kring->nr_kflags & NKR_PENDINTR;
 
 	k = ring->cur;	/* cache and check value, same as in txsync */
 	n = k - kring->nr_hwcur;
@@ -437,6 +471,7 @@
 	if (j > lim)
 		j -= lim + 1;
 
+    if (force_update) {
 	for (n = 0; ; n++) {
 		union ixgbe_adv_rx_desc *curr = &rxr->rx_base[l];
 		uint32_t staterr = le32toh(curr->wb.upper.status_error);
@@ -453,6 +488,8 @@
 		rxr->next_to_check = l;
 		kring->nr_hwavail += n;
 	}
+	kring->nr_kflags &= ~NKR_PENDINTR;
+    }
 
 	/*
 	 * Skip past packets that userspace has already processed
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/dev/netmap/netmap.c
--- a/head/sys/dev/netmap/netmap.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/dev/netmap/netmap.c	Wed Feb 01 12:34:54 2012 +0200
@@ -24,7 +24,7 @@
  */
 
 /*
- * $FreeBSD: head/sys/dev/netmap/netmap.c 230058 2012-01-13 11:58:06Z luigi $
+ * $FreeBSD: head/sys/dev/netmap/netmap.c 230572 2012-01-26 09:55:16Z luigi $
  * $Id: netmap.c 9795 2011-12-02 11:39:08Z luigi $
  *
  * This module supports memory mapped access to network devices,
@@ -56,7 +56,7 @@
  */
 
 #include <sys/cdefs.h> /* prerequisite */
-__FBSDID("$FreeBSD: head/sys/dev/netmap/netmap.c 230058 2012-01-13 11:58:06Z luigi $");
+__FBSDID("$FreeBSD: head/sys/dev/netmap/netmap.c 230572 2012-01-26 09:55:16Z luigi $");
 
 #include <sys/types.h>
 #include <sys/module.h>
@@ -146,6 +146,12 @@
     CTLFLAG_RD, &nm_buf_pool.total_buffers, 0, "total_buffers");
 SYSCTL_INT(_dev_netmap, OID_AUTO, free_buffers,
     CTLFLAG_RD, &nm_buf_pool.free, 0, "free_buffers");
+int netmap_mitigate = 1;
+SYSCTL_INT(_dev_netmap, OID_AUTO, mitigate, CTLFLAG_RW, &netmap_mitigate, 0, "");
+int netmap_skip_txsync;
+SYSCTL_INT(_dev_netmap, OID_AUTO, skip_txsync, CTLFLAG_RW, &netmap_skip_txsync, 0, "");
+int netmap_skip_rxsync;
+SYSCTL_INT(_dev_netmap, OID_AUTO, skip_rxsync, CTLFLAG_RW, &netmap_skip_rxsync, 0, "");
 
 /*
  * Allocate n buffers from the ring, and fill the slot.
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/dev/netmap/netmap_kern.h
--- a/head/sys/dev/netmap/netmap_kern.h	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/dev/netmap/netmap_kern.h	Wed Feb 01 12:34:54 2012 +0200
@@ -24,7 +24,7 @@
  */
 
 /*
- * $FreeBSD: head/sys/dev/netmap/netmap_kern.h 230058 2012-01-13 11:58:06Z luigi $
+ * $FreeBSD: head/sys/dev/netmap/netmap_kern.h 230572 2012-01-26 09:55:16Z luigi $
  * $Id: netmap_kern.h 9795 2011-12-02 11:39:08Z luigi $
  *
  * The header contains the definitions of constants and function
@@ -65,13 +65,14 @@
 	struct netmap_ring *ring;
 	u_int nr_hwcur;
 	int nr_hwavail;
-	u_int nr_kflags;
+	u_int nr_kflags;	/* private driver flags */
+#define NKR_PENDINTR   0x1     // Pending interrupt.
 	u_int nkr_num_slots;
 
 	int	nkr_hwofs;	/* offset between NIC and netmap ring */
 	struct netmap_adapter *na;	 // debugging
 	struct selinfo si; /* poll/select wait queue */
-};
+} __attribute__((__aligned__(64)));
 
 /*
  * This struct is part of and extends the 'struct adapter' (or
@@ -171,6 +172,8 @@
 	enum txrx tx, int n, u_int new_cur);
 int netmap_ring_reinit(struct netmap_kring *);
 
+extern int netmap_mitigate;
+extern int netmap_skip_txsync, netmap_skip_rxsync;
 extern u_int netmap_total_buffers;
 extern char *netmap_buffer_base;
 extern int netmap_verbose;	// XXX debugging
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/dev/ofw/openfirm.c
--- a/head/sys/dev/ofw/openfirm.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/dev/ofw/openfirm.c	Wed Feb 01 12:34:54 2012 +0200
@@ -56,7 +56,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/dev/ofw/openfirm.c 228201 2011-12-02 15:24:39Z jchandra $");
+__FBSDID("$FreeBSD: head/sys/dev/ofw/openfirm.c 230631 2012-01-27 22:29:29Z marius $");
 
 #include "opt_platform.h"
 
@@ -72,6 +72,8 @@
 
 #include "ofw_if.h"
 
+static void OF_putchar(int c, void *arg);
+
 MALLOC_DEFINE(M_OFWPROP, "openfirm", "Open Firmware properties");
 
 static ihandle_t stdout;
@@ -82,7 +84,7 @@
 static struct kobj_ops	ofw_kernel_kops;
 
 /*
- * OFW install routines. Highest priority wins, equal priority also
+ * OFW install routines.  Highest priority wins, equal priority also
  * overrides allowing last-set to win.
  */
 SET_DECLARE(ofw_set, ofw_def_t);
@@ -138,15 +140,27 @@
 	return (rv);
 }
 
+static void
+OF_putchar(int c, void *arg __unused)
+{
+	char cbuf;
+
+	if (c == '\n') {
+		cbuf = '\r';
+		OF_write(stdout, &cbuf, 1);
+	}
+
+	cbuf = c;
+	OF_write(stdout, &cbuf, 1);
+}
+
 void
 OF_printf(const char *fmt, ...)
 {
 	va_list	va;
-	char buf[1024];
 
 	va_start(va, fmt);
-	vsprintf(buf, fmt, va);
-	OF_write(stdout, buf, strlen(buf));
+	(void)kvprintf(fmt, OF_putchar, NULL, 10, va);
 	va_end(va);
 }
 
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/dev/pccbb/pccbb.c
--- a/head/sys/dev/pccbb/pccbb.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/dev/pccbb/pccbb.c	Wed Feb 01 12:34:54 2012 +0200
@@ -75,7 +75,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/dev/pccbb/pccbb.c 227309 2011-11-07 15:43:11Z ed $");
+__FBSDID("$FreeBSD: head/sys/dev/pccbb/pccbb.c 230626 2012-01-27 21:49:02Z imp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -460,6 +460,13 @@
 	int err;
 	int not_a_card = 0;
 
+	/*
+	 * We need to act as a power sequencer on startup.  Delay 2s/channel
+	 * to ensure the other channels have had a chance to come up.  We likely
+	 * should add a lock that's shared on a per-slot basis so that only
+	 * one power event can happen per slot at a time.
+	 */
+	pause("cbbstart", hz * device_get_unit(sc->dev) * 2);
 	mtx_lock(&sc->mtx);
 	sc->flags |= CBB_KTHREAD_RUNNING;
 	while ((sc->flags & CBB_KTHREAD_DONE) == 0) {
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/dev/pci/pci.c
--- a/head/sys/dev/pci/pci.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/dev/pci/pci.c	Wed Feb 01 12:34:54 2012 +0200
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/dev/pci/pci.c 224269 2011-07-22 15:37:23Z hselasky $");
+__FBSDID("$FreeBSD: head/sys/dev/pci/pci.c 230340 2012-01-19 21:38:19Z jhb $");
 
 #include "opt_bus.h"
 
@@ -1136,11 +1136,9 @@
 		if (memcmp(kw, cfg->vpd.vpd_ros[i].keyword,
 		    sizeof(cfg->vpd.vpd_ros[i].keyword)) == 0) {
 			*vptr = cfg->vpd.vpd_ros[i].value;
+			return (0);
 		}
 
-	if (i != cfg->vpd.vpd_rocnt)
-		return (0);
-
 	*vptr = NULL;
 	return (ENXIO);
 }
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/dev/pci/pcireg.h
--- a/head/sys/dev/pci/pcireg.h	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/dev/pci/pcireg.h	Wed Feb 01 12:34:54 2012 +0200
@@ -23,7 +23,7 @@
  * (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: head/sys/dev/pci/pcireg.h 228161 2011-11-30 18:33:23Z jhb $
+ * $FreeBSD: head/sys/dev/pci/pcireg.h 230822 2012-01-31 15:48:40Z jhb $
  *
  */
 
@@ -697,6 +697,7 @@
 #define	PCIR_AER_UC_STATUS	0x04
 #define	PCIM_AER_UC_TRAINING_ERROR	0x00000001
 #define	PCIM_AER_UC_DL_PROTOCOL_ERROR	0x00000010
+#define	PCIM_AER_UC_SURPRISE_LINK_DOWN	0x00000020
 #define	PCIM_AER_UC_POISONED_TLP	0x00001000
 #define	PCIM_AER_UC_FC_PROTOCOL_ERROR	0x00002000
 #define	PCIM_AER_UC_COMPLETION_TIMEOUT	0x00004000
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/dev/random/harvest.c
--- a/head/sys/dev/random/harvest.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/dev/random/harvest.c	Wed Feb 01 12:34:54 2012 +0200
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: head/sys/dev/random/harvest.c 230230 2012-01-16 20:18:10Z das $");
 
 #include <sys/param.h>
 #include <sys/kthread.h>
@@ -37,6 +37,7 @@
 #include <sys/queue.h>
 #include <sys/random.h>
 #include <sys/selinfo.h>
+#include <sys/syslog.h>
 #include <sys/systm.h>
 #include <sys/sysctl.h>
 
@@ -48,6 +49,7 @@
 
 /* Structure holding the desired entropy sources */
 struct harvest_select harvest = { 1, 1, 1, 0 };
+static int warned = 0;
 
 /* hold the address of the routine which is actually called if
  * the randomdev is loaded
@@ -71,6 +73,7 @@
 {
 	reap_func = NULL;
 	read_func = read_random_phony;
+	warned = 0;
 }
 
 /* Entropy harvesting routine. This is supposed to be fast; do
@@ -108,6 +111,11 @@
 	u_long randval;
 	int size, i;
 
+	if (!warned) {
+		log(LOG_WARNING, "random device not loaded; using insecure entropy\n");
+		warned = 1;
+	}
+
 	/* srandom() is called in kern/init_main.c:proc0_post() */
 
 	/* Fill buf[] with random(9) output */
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/dev/random/nehemiah.c
--- a/head/sys/dev/random/nehemiah.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/dev/random/nehemiah.c	Wed Feb 01 12:34:54 2012 +0200
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: head/sys/dev/random/nehemiah.c 230426 2012-01-21 17:45:27Z kib $");
 
 #include <sys/param.h>
 #include <sys/time.h>
@@ -84,7 +84,7 @@
 
 static union VIA_ACE_CW acw		__aligned(16);
 
-static struct fpu_kern_ctx fpu_ctx_save;
+static struct fpu_kern_ctx *fpu_ctx_save;
 
 static struct mtx random_nehemiah_mtx;
 
@@ -135,11 +135,14 @@
 	acw.field.round_count = 12;
 
 	mtx_init(&random_nehemiah_mtx, "random nehemiah", NULL, MTX_DEF);
+	fpu_ctx_save = fpu_kern_alloc_ctx(FPU_KERN_NORMAL);
 }
 
 void
 random_nehemiah_deinit(void)
 {
+
+	fpu_kern_free_ctx(fpu_ctx_save);
 	mtx_destroy(&random_nehemiah_mtx);
 }
 
@@ -151,7 +154,7 @@
 	uint8_t *p;
 
 	mtx_lock(&random_nehemiah_mtx);
-	error = fpu_kern_enter(curthread, &fpu_ctx_save, FPU_KERN_NORMAL);
+	error = fpu_kern_enter(curthread, fpu_ctx_save, FPU_KERN_NORMAL);
 	if (error != 0) {
 		mtx_unlock(&random_nehemiah_mtx);
 		return (0);
@@ -196,7 +199,7 @@
 	c = MIN(RANDOM_BLOCK_SIZE, c);
 	memcpy(buf, out, (size_t)c);
 
-	fpu_kern_leave(curthread, &fpu_ctx_save);
+	fpu_kern_leave(curthread, fpu_ctx_save);
 	mtx_unlock(&random_nehemiah_mtx);
 	return (c);
 }
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/dev/re/if_re.c
--- a/head/sys/dev/re/if_re.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/dev/re/if_re.c	Wed Feb 01 12:34:54 2012 +0200
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/dev/re/if_re.c 228281 2011-12-05 15:33:13Z luigi $");
+__FBSDID("$FreeBSD: head/sys/dev/re/if_re.c 230336 2012-01-19 20:13:16Z yongari $");
 
 /*
  * RealTek 8139C+/8169/8169S/8110S/8168/8111/8101E PCI NIC driver
@@ -3558,7 +3558,6 @@
 	}
 
 	/* Free the TX list buffers. */
-
 	for (i = 0; i < sc->rl_ldata.rl_tx_desc_cnt; i++) {
 		txd = &sc->rl_ldata.rl_tx_desc[i];
 		if (txd->tx_m != NULL) {
@@ -3572,11 +3571,10 @@
 	}
 
 	/* Free the RX list buffers. */
-
 	for (i = 0; i < sc->rl_ldata.rl_rx_desc_cnt; i++) {
 		rxd = &sc->rl_ldata.rl_rx_desc[i];
 		if (rxd->rx_m != NULL) {
-			bus_dmamap_sync(sc->rl_ldata.rl_tx_mtag,
+			bus_dmamap_sync(sc->rl_ldata.rl_rx_mtag,
 			    rxd->rx_dmamap, BUS_DMASYNC_POSTREAD);
 			bus_dmamap_unload(sc->rl_ldata.rl_rx_mtag,
 			    rxd->rx_dmamap);
@@ -3584,6 +3582,20 @@
 			rxd->rx_m = NULL;
 		}
 	}
+
+	if ((sc->rl_flags & RL_FLAG_JUMBOV2) != 0) {
+		for (i = 0; i < sc->rl_ldata.rl_rx_desc_cnt; i++) {
+			rxd = &sc->rl_ldata.rl_jrx_desc[i];
+			if (rxd->rx_m != NULL) {
+				bus_dmamap_sync(sc->rl_ldata.rl_jrx_mtag,
+				    rxd->rx_dmamap, BUS_DMASYNC_POSTREAD);
+				bus_dmamap_unload(sc->rl_ldata.rl_jrx_mtag,
+				    rxd->rx_dmamap);
+				m_freem(rxd->rx_m);
+				rxd->rx_m = NULL;
+			}
+		}
+	}
 }
 
 /*
@@ -3796,7 +3808,7 @@
 	/* Config register write done. */
 	CSR_WRITE_1(sc, RL_EECMD, RL_EEMODE_OFF);
 
-	if ((ifp->if_capenable & IFCAP_WOL) != 0 &&
+	if ((ifp->if_capenable & IFCAP_WOL) == 0 &&
 	    (sc->rl_flags & RL_FLAG_PHYWAKE_PM) != 0)
 		CSR_WRITE_1(sc, RL_PMCH, CSR_READ_1(sc, RL_PMCH) & ~0x80);
 	/*
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/dev/uart/uart_bus_pci.c
--- a/head/sys/dev/uart/uart_bus_pci.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/dev/uart/uart_bus_pci.c	Wed Feb 01 12:34:54 2012 +0200
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/dev/uart/uart_bus_pci.c 229971 2012-01-11 17:46:08Z kib $");
+__FBSDID("$FreeBSD: head/sys/dev/uart/uart_bus_pci.c 230327 2012-01-19 02:47:11Z eadler $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -110,6 +110,7 @@
 	8 * DEFAULT_RCLK },
 { 0x1415, 0x950b, 0xffff, 0, "Oxford Semiconductor OXCB950 Cardbus 16950 UART",
 	0x10, 16384000 },
+{ 0x14e4, 0x4344, 0xffff, 0, "Sony Ericsson GC89 PC Card", 0x10},
 { 0x151f, 0x0000, 0xffff, 0, "TOPIC Semiconductor TP560 56k modem", 0x10 },
 { 0x8086, 0x1c3d, 0xffff, 0, "Intel AMT - KT Controller", 0x10 },
 { 0x8086, 0x3b67, 0xffff, 0, "5 Series/3400 Series Chipset KT Controller",
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/dev/usb/usb_transfer.c
--- a/head/sys/dev/usb/usb_transfer.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/dev/usb/usb_transfer.c	Wed Feb 01 12:34:54 2012 +0200
@@ -1,4 +1,4 @@
-/* $FreeBSD: head/sys/dev/usb/usb_transfer.c 228760 2011-12-21 10:52:17Z avg $ */
+/* $FreeBSD: head/sys/dev/usb/usb_transfer.c 230643 2012-01-28 14:00:21Z attilio $ */
 /*-
  * Copyright (c) 2008 Hans Petter Selasky. All rights reserved.
  *
@@ -42,6 +42,7 @@
 #include <sys/callout.h>
 #include <sys/malloc.h>
 #include <sys/priv.h>
+#include <sys/proc.h>
 
 #include <dev/usb/usb.h>
 #include <dev/usb/usbdi.h>
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/dev/wi/if_wi.c
--- a/head/sys/dev/wi/if_wi.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/dev/wi/if_wi.c	Wed Feb 01 12:34:54 2012 +0200
@@ -60,7 +60,9 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/dev/wi/if_wi.c 228621 2011-12-17 10:23:17Z bschmidt $");
+__FBSDID("$FreeBSD: head/sys/dev/wi/if_wi.c 230562 2012-01-26 05:11:37Z adrian $");
+
+#include "opt_wlan.h"
 
 #define WI_HERMES_STATS_WAR	/* Work around stats counter bug. */
 
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/dev/xen/blkback/blkback.c
--- a/head/sys/dev/xen/blkback/blkback.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/dev/xen/blkback/blkback.c	Wed Feb 01 12:34:54 2012 +0200
@@ -31,7 +31,7 @@
  *          Ken Merry           (Spectra Logic Corporation)
  */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/dev/xen/blkback/blkback.c 227293 2011-11-07 06:44:47Z ed $");
+__FBSDID("$FreeBSD: head/sys/dev/xen/blkback/blkback.c 230587 2012-01-26 16:35:09Z ken $");
 
 /**
  * \file blkback.c
@@ -3434,6 +3434,10 @@
 
 	DPRINTF("\n");
 
+	/*
+	 * Before unlocking mutex, set this flag to prevent other threads from
+	 * getting into this function
+	 */
 	xbb->flags |= XBBF_IN_SHUTDOWN;
 	mtx_unlock(&xbb->lock);
 
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/dev/xen/netback/netback.c
--- a/head/sys/dev/xen/netback/netback.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/dev/xen/netback/netback.c	Wed Feb 01 12:34:54 2012 +0200
@@ -1,1595 +1,2535 @@
-/*
- * Copyright (c) 2006, Cisco Systems, Inc.
+/*-
+ * Copyright (c) 2009-2011 Spectra Logic Corporation
  * All rights reserved.
  *
- * Redistribution and use in source and binary forms, with or without 
- * modification, are permitted provided that the following conditions 
+ * 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,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
  *
- * 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. 
- * 3. Neither the name of Cisco Systems, Inc. nor the names of its contributors 
- *    may be used to endorse or promote products derived from this software 
- *    without specific prior written permission. 
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES.
  *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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.
+ * Authors: Justin T. Gibbs     (Spectra Logic Corporation)
+ *          Alan Somers         (Spectra Logic Corporation)
+ *          John Suykerbuyk     (Spectra Logic Corporation)
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/dev/xen/netback/netback.c 229767 2012-01-07 09:41:57Z kevlo $");
+__FBSDID("$FreeBSD: head/sys/dev/xen/netback/netback.c 230587 2012-01-26 16:35:09Z ken $");
+
+/**
+ * \file netback.c
+ *
+ * \brief Device driver supporting the vending of network access
+ * 	  from this FreeBSD domain to other domains.
+ */
+#include "opt_inet.h"
+#include "opt_global.h"
+
 #include "opt_sctp.h"
 
 #include <sys/param.h>
-#include <sys/systm.h>
+#include <sys/kernel.h>
+
+#include <sys/bus.h>
+#include <sys/module.h>
+#include <sys/rman.h>
+#include <sys/socket.h>
 #include <sys/sockio.h>
-#include <sys/mbuf.h>
-#include <sys/malloc.h>
-#include <sys/kernel.h>
-#include <sys/socket.h>
-#include <sys/queue.h>
-#include <sys/taskqueue.h>
-
-#include <sys/module.h>
-#include <sys/bus.h>
 #include <sys/sysctl.h>
 
 #include <net/if.h>
 #include <net/if_arp.h>
+#include <net/ethernet.h>
+#include <net/if_dl.h>
+#include <net/if_media.h>
 #include <net/if_types.h>
-#include <net/ethernet.h>
-#include <net/if_bridgevar.h>
 
-#include <netinet/in_systm.h>
 #include <netinet/in.h>
-#include <netinet/in_var.h>
 #include <netinet/ip.h>
+#include <netinet/if_ether.h>
+#if __FreeBSD_version >= 700000
 #include <netinet/tcp.h>
+#endif
+#include <netinet/ip_icmp.h>
 #include <netinet/udp.h>
-#ifdef SCTP
-#include <netinet/sctp.h>
-#include <netinet/sctp_crc32.h>
+#include <machine/in_cksum.h>
+
+#include <vm/vm.h>
+#include <vm/pmap.h>
+
+#include <machine/_inttypes.h>
+#include <machine/xen/xen-os.h>
+#include <machine/xen/xenvar.h>
+
+#include <xen/evtchn.h>
+#include <xen/xen_intr.h>
+#include <xen/interface/io/netif.h>
+#include <xen/xenbus/xenbusvar.h>
+
+/*--------------------------- Compile-time Tunables --------------------------*/
+
+/*---------------------------------- Macros ----------------------------------*/
+/**
+ * Custom malloc type for all driver allocations.
+ */
+static MALLOC_DEFINE(M_XENNETBACK, "xnb", "Xen Net Back Driver Data");
+
+#define	XNB_SG	1	/* netback driver supports feature-sg */
+#define	XNB_GSO_TCPV4 1	/* netback driver supports feature-gso-tcpv4 */
+#define	XNB_RX_COPY 1	/* netback driver supports feature-rx-copy */
+#define	XNB_RX_FLIP 0	/* netback driver does not support feature-rx-flip */
+
+#undef XNB_DEBUG
+#define	XNB_DEBUG /* hardcode on during development */
+
+#ifdef XNB_DEBUG
+#define	DPRINTF(fmt, args...) \
+	printf("xnb(%s:%d): " fmt, __FUNCTION__, __LINE__, ##args)
+#else
+#define	DPRINTF(fmt, args...) do {} while (0)
 #endif
 
-#include <vm/vm_extern.h>
-#include <vm/vm_kern.h>
+/* Default length for stack-allocated grant tables */
+#define	GNTTAB_LEN	(64)
 
-#include <machine/in_cksum.h>
-#include <machine/xen-os.h>
-#include <machine/hypervisor.h>
-#include <machine/hypervisor-ifs.h>
-#include <machine/xen_intr.h>
-#include <machine/evtchn.h>
-#include <machine/xenbus.h>
-#include <machine/gnttab.h>
-#include <machine/xen-public/memory.h>
-#include <dev/xen/xenbus/xenbus_comms.h>
+/* Features supported by all backends.  TSO and LRO can be negotiated */
+#define	XNB_CSUM_FEATURES	(CSUM_TCP | CSUM_UDP)
 
+#define	NET_TX_RING_SIZE __RING_SIZE((netif_tx_sring_t *)0, PAGE_SIZE)
+#define	NET_RX_RING_SIZE __RING_SIZE((netif_rx_sring_t *)0, PAGE_SIZE)
 
-#ifdef XEN_NETBACK_DEBUG
-#define DPRINTF(fmt, args...) \
-    printf("netback (%s:%d): " fmt, __FUNCTION__, __LINE__, ##args)
-#else
-#define DPRINTF(fmt, args...) ((void)0)
+/**
+ * Two argument version of the standard macro.  Second argument is a tentative
+ * value of req_cons
+ */
+#define	RING_HAS_UNCONSUMED_REQUESTS_2(_r, cons) ({                     \
+	unsigned int req = (_r)->sring->req_prod - cons;          	\
+	unsigned int rsp = RING_SIZE(_r) -                              \
+	(cons - (_r)->rsp_prod_pvt);                          		\
+	req < rsp ? req : rsp;                                          \
+})
+
+#define	virt_to_mfn(x) (vtomach(x) >> PAGE_SHIFT)
+#define	virt_to_offset(x) ((x) & (PAGE_SIZE - 1))
+
+/**
+ * Predefined array type of grant table copy descriptors.  Used to pass around
+ * statically allocated memory structures.
+ */
+typedef struct gnttab_copy gnttab_copy_table[GNTTAB_LEN];
+
+/*--------------------------- Forward Declarations ---------------------------*/
+struct xnb_softc;
+struct xnb_pkt;
+
+static void	xnb_attach_failed(struct xnb_softc *xnb,
+				  int err, const char *fmt, ...)
+				  __printflike(3,4);
+static int	xnb_shutdown(struct xnb_softc *xnb);
+static int	create_netdev(device_t dev);
+static int	xnb_detach(device_t dev);
+static int	xen_net_read_mac(device_t dev, uint8_t mac[]);
+static int	xnb_ifmedia_upd(struct ifnet *ifp);
+static void	xnb_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr);
+static void 	xnb_intr(void *arg);
+static int	xnb_send(netif_rx_back_ring_t *rxb, domid_t otherend,
+			 const struct mbuf *mbufc, gnttab_copy_table gnttab);
+static int	xnb_recv(netif_tx_back_ring_t *txb, domid_t otherend,
+			 struct mbuf **mbufc, struct ifnet *ifnet,
+			 gnttab_copy_table gnttab);
+static int	xnb_ring2pkt(struct xnb_pkt *pkt,
+			     const netif_tx_back_ring_t *tx_ring,
+			     RING_IDX start);
+static void	xnb_txpkt2rsp(const struct xnb_pkt *pkt,
+			      netif_tx_back_ring_t *ring, int error);
+static struct mbuf *xnb_pkt2mbufc(const struct xnb_pkt *pkt, struct ifnet *ifp);
+static int	xnb_txpkt2gnttab(const struct xnb_pkt *pkt,
+				 const struct mbuf *mbufc,
+				 gnttab_copy_table gnttab,
+				 const netif_tx_back_ring_t *txb,
+				 domid_t otherend_id);
+static void	xnb_update_mbufc(struct mbuf *mbufc,
+				 const gnttab_copy_table gnttab, int n_entries);
+static int	xnb_mbufc2pkt(const struct mbuf *mbufc,
+			      struct xnb_pkt *pkt,
+			      RING_IDX start, int space);
+static int	xnb_rxpkt2gnttab(const struct xnb_pkt *pkt,
+				 const struct mbuf *mbufc,
+				 gnttab_copy_table gnttab,
+				 const netif_rx_back_ring_t *rxb,
+				 domid_t otherend_id);
+static int	xnb_rxpkt2rsp(const struct xnb_pkt *pkt,
+			      const gnttab_copy_table gnttab, int n_entries,
+			      netif_rx_back_ring_t *ring);
+static void	xnb_add_mbuf_cksum(struct mbuf *mbufc);
+static void	xnb_stop(struct xnb_softc*);
+static int	xnb_ioctl(struct ifnet*, u_long, caddr_t);
+static void	xnb_start_locked(struct ifnet*);
+static void	xnb_start(struct ifnet*);
+static void	xnb_ifinit_locked(struct xnb_softc*);
+static void	xnb_ifinit(void*);
+#ifdef XNB_DEBUG
+static int	xnb_unit_test_main(SYSCTL_HANDLER_ARGS);
+static int	xnb_dump_rings(SYSCTL_HANDLER_ARGS);
+#endif
+/*------------------------------ Data Structures -----------------------------*/
+
+
+/**
+ * Representation of a xennet packet.  Simplified version of a packet as
+ * stored in the Xen tx ring.  Applicable to both RX and TX packets
+ */
+struct xnb_pkt{
+	/**
+	 * Array index of the first data-bearing (eg, not extra info) entry
+	 * for this packet
+	 */
+	RING_IDX	car;
+
+	/**
+	 * Array index of the second data-bearing entry for this packet.
+	 * Invalid if the packet has only one data-bearing entry.  If the
+	 * packet has more than two data-bearing entries, then the second
+	 * through the last will be sequential modulo the ring size
+	 */
+	RING_IDX	cdr;
+
+	/**
+	 * Optional extra info.  Only valid if flags contains
+	 * NETTXF_extra_info.  Note that extra.type will always be
+	 * XEN_NETIF_EXTRA_TYPE_GSO.  Currently, no known netfront or netback
+	 * driver will ever set XEN_NETIF_EXTRA_TYPE_MCAST_*
+	 */
+	netif_extra_info_t extra;
+
+	/** Size of entire packet in bytes.       */
+	uint16_t	size;
+
+	/** The size of the first entry's data in bytes */
+	uint16_t	car_size;
+
+	/**
+	 * Either NETTXF_ or NETRXF_ flags.  Note that the flag values are
+	 * not the same for TX and RX packets
+	 */
+	uint16_t	flags;
+
+	/**
+	 * The number of valid data-bearing entries (either netif_tx_request's
+	 * or netif_rx_response's) in the packet.  If this is 0, it means the
+	 * entire packet is invalid.
+	 */
+	uint16_t	list_len;
+
+	/** There was an error processing the packet */
+	uint8_t		error;
+};
+
+/** xnb_pkt method: initialize it */
+static inline void
+xnb_pkt_initialize(struct xnb_pkt *pxnb)
+{
+	bzero(pxnb, sizeof(*pxnb));
+}
+
+/** xnb_pkt method: mark the packet as valid */
+static inline void
+xnb_pkt_validate(struct xnb_pkt *pxnb)
+{
+	pxnb->error = 0;
+};
+
+/** xnb_pkt method: mark the packet as invalid */
+static inline void
+xnb_pkt_invalidate(struct xnb_pkt *pxnb)
+{
+	pxnb->error = 1;
+};
+
+/** xnb_pkt method: Check whether the packet is valid */
+static inline int
+xnb_pkt_is_valid(const struct xnb_pkt *pxnb)
+{
+	return (! pxnb->error);
+}
+
+#ifdef XNB_DEBUG
+/** xnb_pkt method: print the packet's contents in human-readable format*/
+static void __unused
+xnb_dump_pkt(const struct xnb_pkt *pkt) {
+	if (pkt == NULL) {
+	  DPRINTF("Was passed a null pointer.\n");
+	  return;
+	}
+	DPRINTF("pkt address= %p\n", pkt);
+	DPRINTF("pkt->size=%d\n", pkt->size);
+	DPRINTF("pkt->car_size=%d\n", pkt->car_size);
+	DPRINTF("pkt->flags=0x%04x\n", pkt->flags);
+	DPRINTF("pkt->list_len=%d\n", pkt->list_len);
+	/* DPRINTF("pkt->extra");	TODO */
+	DPRINTF("pkt->car=%d\n", pkt->car);
+	DPRINTF("pkt->cdr=%d\n", pkt->cdr);
+	DPRINTF("pkt->error=%d\n", pkt->error);
+}
+#endif /* XNB_DEBUG */
+
+static void
+xnb_dump_txreq(RING_IDX idx, const struct netif_tx_request *txreq)
+{
+	if (txreq != NULL) {
+		DPRINTF("netif_tx_request index =%u\n", idx);
+		DPRINTF("netif_tx_request.gref  =%u\n", txreq->gref);
+		DPRINTF("netif_tx_request.offset=%hu\n", txreq->offset);
+		DPRINTF("netif_tx_request.flags =%hu\n", txreq->flags);
+		DPRINTF("netif_tx_request.id    =%hu\n", txreq->id);
+		DPRINTF("netif_tx_request.size  =%hu\n", txreq->size);
+	}
+}
+
+
+/**
+ * \brief Configuration data for a shared memory request ring
+ *        used to communicate with the front-end client of this
+ *        this driver.
+ */
+struct xnb_ring_config {
+	/**
+	 * Runtime structures for ring access.  Unfortunately, TX and RX rings
+	 * use different data structures, and that cannot be changed since it
+	 * is part of the interdomain protocol.
+	 */
+	union{
+		netif_rx_back_ring_t	  rx_ring;
+		netif_tx_back_ring_t	  tx_ring;
+	} back_ring;
+
+	/**
+	 * The device bus address returned by the hypervisor when
+	 * mapping the ring and required to unmap it when a connection
+	 * is torn down.
+	 */
+	uint64_t	bus_addr;
+
+	/** The pseudo-physical address where ring memory is mapped.*/
+	uint64_t	gnt_addr;
+
+	/** KVA address where ring memory is mapped. */
+	vm_offset_t	va;
+
+	/**
+	 * Grant table handles, one per-ring page, returned by the
+	 * hyperpervisor upon mapping of the ring and required to
+	 * unmap it when a connection is torn down.
+	 */
+	grant_handle_t	handle;
+
+	/** The number of ring pages mapped for the current connection. */
+	unsigned	ring_pages;
+
+	/**
+	 * The grant references, one per-ring page, supplied by the
+	 * front-end, allowing us to reference the ring pages in the
+	 * front-end's domain and to map these pages into our own domain.
+	 */
+	grant_ref_t	ring_ref;
+};
+
+/**
+ * Per-instance connection state flags.
+ */
+typedef enum
+{
+	/** Communication with the front-end has been established. */
+	XNBF_RING_CONNECTED    = 0x01,
+
+	/**
+	 * Front-end requests exist in the ring and are waiting for
+	 * xnb_xen_req objects to free up.
+	 */
+	XNBF_RESOURCE_SHORTAGE = 0x02,
+
+	/** Connection teardown has started. */
+	XNBF_SHUTDOWN          = 0x04,
+
+	/** A thread is already performing shutdown processing. */
+	XNBF_IN_SHUTDOWN       = 0x08
+} xnb_flag_t;
+
+/**
+ * Types of rings.  Used for array indices and to identify a ring's control
+ * data structure type
+ */
+typedef enum{
+	XNB_RING_TYPE_TX = 0,	/* ID of TX rings, used for array indices */
+	XNB_RING_TYPE_RX = 1,	/* ID of RX rings, used for array indices */
+	XNB_NUM_RING_TYPES
+} xnb_ring_type_t;
+
+/**
+ * Per-instance configuration data.
+ */
+struct xnb_softc {
+	/** NewBus device corresponding to this instance. */
+	device_t		dev;
+
+	/* Media related fields */
+
+	/** Generic network media state */
+	struct ifmedia		sc_media;
+
+	/** Media carrier info */
+	struct ifnet 		*xnb_ifp;
+
+	/** Our own private carrier state */
+	unsigned carrier;
+
+	/** Device MAC Address */
+	uint8_t			mac[ETHER_ADDR_LEN];
+
+	/* Xen related fields */
+
+	/**
+	 * \brief The netif protocol abi in effect.
+	 *
+	 * There are situations where the back and front ends can
+	 * have a different, native abi (e.g. intel x86_64 and
+	 * 32bit x86 domains on the same machine).  The back-end
+	 * always accomodates the front-end's native abi.  That
+	 * value is pulled from the XenStore and recorded here.
+	 */
+	int			abi;
+
+	/**
+	 * Name of the bridge to which this VIF is connected, if any
+	 * This field is dynamically allocated by xenbus and must be free()ed
+	 * when no longer needed
+	 */
+	char			*bridge;
+
+	/** The interrupt driven even channel used to signal ring events. */
+	evtchn_port_t		evtchn;
+
+	/** Xen device handle.*/
+	long 			handle;
+
+	/** IRQ mapping for the communication ring event channel. */
+	int			irq;
+
+	/**
+	 * \brief Cached value of the front-end's domain id.
+	 *
+	 * This value is used at once for each mapped page in
+	 * a transaction.  We cache it to avoid incuring the
+	 * cost of an ivar access every time this is needed.
+	 */
+	domid_t			otherend_id;
+
+	/**
+	 * Undocumented frontend feature.  Has something to do with
+	 * scatter/gather IO
+	 */
+	uint8_t			can_sg;
+	/** Undocumented frontend feature */
+	uint8_t			gso;
+	/** Undocumented frontend feature */
+	uint8_t			gso_prefix;
+	/** Can checksum TCP/UDP over IPv4 */
+	uint8_t			ip_csum;
+
+	/* Implementation related fields */
+	/**
+	 * Preallocated grant table copy descriptor for RX operations.
+	 * Access must be protected by rx_lock
+	 */
+	gnttab_copy_table	rx_gnttab;
+
+	/**
+	 * Preallocated grant table copy descriptor for TX operations.
+	 * Access must be protected by tx_lock
+	 */
+	gnttab_copy_table	tx_gnttab;
+
+#ifdef XENHVM
+	/**
+	 * Resource representing allocated physical address space
+	 * associated with our per-instance kva region.
+	 */
+	struct resource		*pseudo_phys_res;
+
+	/** Resource id for allocated physical address space. */
+	int			pseudo_phys_res_id;
 #endif
 
-#ifdef XEN_NETBACK_DEBUG_LOTS
-#define DDPRINTF(fmt, args...) \
-    printf("netback (%s:%d): " fmt, __FUNCTION__, __LINE__, ##args)
-#define DPRINTF_MBUF(_m) print_mbuf(_m, 0)
-#define DPRINTF_MBUF_LEN(_m, _len) print_mbuf(_m, _len)
-#else
-#define DDPRINTF(fmt, args...) ((void)0)
-#define DPRINTF_MBUF(_m) ((void)0)
-#define DPRINTF_MBUF_LEN(_m, _len) ((void)0)
-#endif
+	/** Ring mapping and interrupt configuration data. */
+	struct xnb_ring_config	ring_configs[XNB_NUM_RING_TYPES];
 
-#define WPRINTF(fmt, args...) \
-    printf("netback (%s:%d): " fmt, __FUNCTION__, __LINE__, ##args)
+	/**
+	 * Global pool of kva used for mapping remote domain ring
+	 * and I/O transaction data.
+	 */
+	vm_offset_t		kva;
 
-#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
-#define BUG_ON PANIC_IF
+	/** Psuedo-physical address corresponding to kva. */
+	uint64_t		gnt_base_addr;
 
-#define IFNAME(_np) (_np)->ifp->if_xname
+	/** Various configuration and state bit flags. */
+	xnb_flag_t		flags;
 
-#define NET_TX_RING_SIZE __RING_SIZE((netif_tx_sring_t *)0, PAGE_SIZE)
-#define NET_RX_RING_SIZE __RING_SIZE((netif_rx_sring_t *)0, PAGE_SIZE)
+	/** Mutex protecting per-instance data in the receive path. */
+	struct mtx		rx_lock;
 
-struct ring_ref {
-	vm_offset_t va;
-	grant_handle_t handle;
-	uint64_t bus_addr;
+	/** Mutex protecting per-instance data in the softc structure. */
+	struct mtx		sc_lock;
+
+	/** Mutex protecting per-instance data in the transmit path. */
+	struct mtx		tx_lock;
+
+	/** The size of the global kva pool. */
+	int			kva_size;
 };
 
-typedef struct netback_info {
+/*---------------------------- Debugging functions ---------------------------*/
+#ifdef XNB_DEBUG
+static void __unused
+xnb_dump_gnttab_copy(const struct gnttab_copy *entry)
+{
+	if (entry == NULL) {
+		printf("NULL grant table pointer\n");
+		return;
+	}
 
-	/* Schedule lists */
-	STAILQ_ENTRY(netback_info) next_tx;
-	STAILQ_ENTRY(netback_info) next_rx;
-	int on_tx_sched_list;
-	int on_rx_sched_list;
-
-	struct xenbus_device *xdev;
-	XenbusState frontend_state;
-
-	domid_t domid;
-	int handle;
-	char *bridge;
-
-	int rings_connected;
-	struct ring_ref tx_ring_ref;
-	struct ring_ref rx_ring_ref;
-	netif_tx_back_ring_t tx;
-	netif_rx_back_ring_t rx;
-	evtchn_port_t evtchn;
-	int irq;
-	void *irq_cookie;
-
-	struct ifnet *ifp;
-	int ref_cnt;
-
-	device_t ndev;
-	int attached;
-} netif_t;
-
-
-#define MAX_PENDING_REQS 256
-#define PKT_PROT_LEN 64
-
-static struct {
-	netif_tx_request_t req;
-	netif_t *netif;
-} pending_tx_info[MAX_PENDING_REQS];
-static uint16_t pending_ring[MAX_PENDING_REQS];
-typedef unsigned int PEND_RING_IDX;
-#define MASK_PEND_IDX(_i) ((_i)&(MAX_PENDING_REQS-1))
-static PEND_RING_IDX pending_prod, pending_cons;
-#define NR_PENDING_REQS (MAX_PENDING_REQS - pending_prod + pending_cons)
-
-static unsigned long mmap_vstart;
-#define MMAP_VADDR(_req) (mmap_vstart + ((_req) * PAGE_SIZE))
-
-/* Freed TX mbufs get batched on this ring before return to pending_ring. */
-static uint16_t dealloc_ring[MAX_PENDING_REQS];
-static PEND_RING_IDX dealloc_prod, dealloc_cons;
-
-static multicall_entry_t rx_mcl[NET_RX_RING_SIZE+1];
-static mmu_update_t rx_mmu[NET_RX_RING_SIZE];
-static gnttab_transfer_t grant_rx_op[NET_RX_RING_SIZE];
-
-static grant_handle_t grant_tx_handle[MAX_PENDING_REQS];
-static gnttab_unmap_grant_ref_t tx_unmap_ops[MAX_PENDING_REQS];
-static gnttab_map_grant_ref_t tx_map_ops[MAX_PENDING_REQS];
-
-static struct task net_tx_task, net_rx_task;
-static struct callout rx_task_callout;
-
-static STAILQ_HEAD(netback_tx_sched_list, netback_info) tx_sched_list =
-	STAILQ_HEAD_INITIALIZER(tx_sched_list);
-static STAILQ_HEAD(netback_rx_sched_list, netback_info) rx_sched_list =
-	STAILQ_HEAD_INITIALIZER(rx_sched_list);
-static struct mtx tx_sched_list_lock;
-static struct mtx rx_sched_list_lock;
-
-static int vif_unit_maker = 0;
-
-/* Protos */
-static void netback_start(struct ifnet *ifp);
-static int netback_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data);
-static int vif_add_dev(struct xenbus_device *xdev);
-static void disconnect_rings(netif_t *netif);
-
-#ifdef XEN_NETBACK_DEBUG_LOTS
-/* Debug code to display the contents of an mbuf */
-static void
-print_mbuf(struct mbuf *m, int max)
-{
-	int i, j=0;
-	printf("mbuf %08x len = %d", (unsigned int)m, m->m_pkthdr.len);
-	for (; m; m = m->m_next) {
-		unsigned char *d = m->m_data;
-		for (i=0; i < m->m_len; i++) {
-			if (max && j == max)
-				break;
-			if ((j++ % 16) == 0)
-				printf("\n%04x:", j);
-			printf(" %02x", d[i]);
-		}
-	}
-	printf("\n");
-}
-#endif
-
-
-#define MAX_MFN_ALLOC 64
-static unsigned long mfn_list[MAX_MFN_ALLOC];
-static unsigned int alloc_index = 0;
-
-static unsigned long
-alloc_mfn(void)
-{
-	unsigned long mfn = 0;
-	struct xen_memory_reservation reservation = {
-		.extent_start = mfn_list,
-		.nr_extents   = MAX_MFN_ALLOC,
-		.extent_order = 0,
-		.domid        = DOMID_SELF
-	};
-	if ( unlikely(alloc_index == 0) )
-		alloc_index = HYPERVISOR_memory_op(
-			XENMEM_increase_reservation, &reservation);
-	if ( alloc_index != 0 )
-		mfn = mfn_list[--alloc_index];
-	return mfn;
+	if (entry->flags & GNTCOPY_dest_gref)
+		printf("gnttab dest ref=\t%u\n", entry->dest.u.ref);
+	else
+		printf("gnttab dest gmfn=\t%lu\n", entry->dest.u.gmfn);
+	printf("gnttab dest offset=\t%hu\n", entry->dest.offset);
+	printf("gnttab dest domid=\t%hu\n", entry->dest.domid);
+	if (entry->flags & GNTCOPY_source_gref)
+		printf("gnttab source ref=\t%u\n", entry->source.u.ref);
+	else
+		printf("gnttab source gmfn=\t%lu\n", entry->source.u.gmfn);
+	printf("gnttab source offset=\t%hu\n", entry->source.offset);
+	printf("gnttab source domid=\t%hu\n", entry->source.domid);
+	printf("gnttab len=\t%hu\n", entry->len);
+	printf("gnttab flags=\t%hu\n", entry->flags);
+	printf("gnttab status=\t%hd\n", entry->status);
 }
 
-static unsigned long
-alloc_empty_page_range(unsigned long nr_pages)
+static int
+xnb_dump_rings(SYSCTL_HANDLER_ARGS)
 {
-	void *pages;
-	int i = 0, j = 0;
-	multicall_entry_t mcl[17];
-	unsigned long mfn_list[16];
-	struct xen_memory_reservation reservation = {
-		.extent_start = mfn_list,
-		.nr_extents   = 0,
-		.address_bits = 0,
-		.extent_order = 0,
-		.domid        = DOMID_SELF
-	};
+	static char results[720];
+	struct xnb_softc const* xnb = (struct xnb_softc*)arg1;
+	netif_rx_back_ring_t const* rxb =
+		&xnb->ring_configs[XNB_RING_TYPE_RX].back_ring.rx_ring;
+	netif_tx_back_ring_t const* txb =
+		&xnb->ring_configs[XNB_RING_TYPE_TX].back_ring.tx_ring;
 
-	pages = malloc(nr_pages*PAGE_SIZE, M_DEVBUF, M_NOWAIT);
-	if (pages == NULL)
-		return 0;
+	/* empty the result strings */
+	results[0] = 0;
 
-	memset(mcl, 0, sizeof(mcl));
+	if ( !txb || !txb->sring || !rxb || !rxb->sring )
+		return (SYSCTL_OUT(req, results, strnlen(results, 720)));
 
-	while (i < nr_pages) {
-		unsigned long va = (unsigned long)pages + (i++ * PAGE_SIZE);
+	snprintf(results, 720,
+	    "\n\t%35s %18s\n"	/* TX, RX */
+	    "\t%16s %18d %18d\n"	/* req_cons */
+	    "\t%16s %18d %18d\n"	/* nr_ents */
+	    "\t%16s %18d %18d\n"	/* rsp_prod_pvt */
+	    "\t%16s %18p %18p\n"	/* sring */
+	    "\t%16s %18d %18d\n"	/* req_prod */
+	    "\t%16s %18d %18d\n"	/* req_event */
+	    "\t%16s %18d %18d\n"	/* rsp_prod */
+	    "\t%16s %18d %18d\n",	/* rsp_event */
+	    "TX", "RX",
+	    "req_cons", txb->req_cons, rxb->req_cons,
+	    "nr_ents", txb->nr_ents, rxb->nr_ents,
+	    "rsp_prod_pvt", txb->rsp_prod_pvt, rxb->rsp_prod_pvt,
+	    "sring", txb->sring, rxb->sring,
+	    "sring->req_prod", txb->sring->req_prod, rxb->sring->req_prod,
+	    "sring->req_event", txb->sring->req_event, rxb->sring->req_event,
+	    "sring->rsp_prod", txb->sring->rsp_prod, rxb->sring->rsp_prod,
+	    "sring->rsp_event", txb->sring->rsp_event, rxb->sring->rsp_event);
 
-		mcl[j].op = __HYPERVISOR_update_va_mapping;
-		mcl[j].args[0] = va;
+	return (SYSCTL_OUT(req, results, strnlen(results, 720)));
+}
 
-		mfn_list[j++] = vtomach(va) >> PAGE_SHIFT;
+static void __unused
+xnb_dump_mbuf(const struct mbuf *m)
+{
+	int len;
+	uint8_t *d;
+	if (m == NULL)
+		return;
 
-		xen_phys_machine[(vtophys(va) >> PAGE_SHIFT)] = INVALID_P2M_ENTRY;
+	printf("xnb_dump_mbuf:\n");
+	if (m->m_flags & M_PKTHDR) {
+		printf("    flowid=%10d, csum_flags=%#8x, csum_data=%#8x, "
+		       "tso_segsz=%5hd\n",
+		       m->m_pkthdr.flowid, m->m_pkthdr.csum_flags,
+		       m->m_pkthdr.csum_data, m->m_pkthdr.tso_segsz);
+		printf("    rcvif=%16p,  header=%18p, len=%19d\n",
+		       m->m_pkthdr.rcvif, m->m_pkthdr.header, m->m_pkthdr.len);
+	}
+	printf("    m_next=%16p, m_nextpk=%16p, m_data=%16p\n",
+	       m->m_next, m->m_nextpkt, m->m_data);
+	printf("    m_len=%17d, m_flags=%#15x, m_type=%18hd\n",
+	       m->m_len, m->m_flags, m->m_type);
 
-		if (j == 16 || i == nr_pages) {
-			mcl[j-1].args[MULTI_UVMFLAGS_INDEX] = UVMF_TLB_FLUSH|UVMF_LOCAL;
+	len = m->m_len;
+	d = mtod(m, uint8_t*);
+	while (len > 0) {
+		int i;
+		printf("                ");
+		for (i = 0; (i < 16) && (len > 0); i++, len--) {
+			printf("%02hhx ", *(d++));
+		}
+		printf("\n");
+	}
+}
+#endif /* XNB_DEBUG */
 
-			reservation.nr_extents = j;
+/*------------------------ Inter-Domain Communication ------------------------*/
+/**
+ * Free dynamically allocated KVA or pseudo-physical address allocations.
+ *
+ * \param xnb  Per-instance xnb configuration structure.
+ */
+static void
+xnb_free_communication_mem(struct xnb_softc *xnb)
+{
+	if (xnb->kva != 0) {
+#ifndef XENHVM
+		kmem_free(kernel_map, xnb->kva, xnb->kva_size);
+#else
+		if (xnb->pseudo_phys_res != NULL) {
+			bus_release_resource(xnb->dev, SYS_RES_MEMORY,
+			    xnb->pseudo_phys_res_id,
+			    xnb->pseudo_phys_res);
+			xnb->pseudo_phys_res = NULL;
+		}
+#endif /* XENHVM */
+	}
+	xnb->kva = 0;
+	xnb->gnt_base_addr = 0;
+}
 
-			mcl[j].op = __HYPERVISOR_memory_op;
-			mcl[j].args[0] = XENMEM_decrease_reservation;
-			mcl[j].args[1] =  (unsigned long)&reservation;
-			
-			(void)HYPERVISOR_multicall(mcl, j+1);
+/**
+ * Cleanup all inter-domain communication mechanisms.
+ *
+ * \param xnb  Per-instance xnb configuration structure.
+ */
+static int
+xnb_disconnect(struct xnb_softc *xnb)
+{
+	struct gnttab_unmap_grant_ref gnts[XNB_NUM_RING_TYPES];
+	int error;
+	int i;
 
-			mcl[j-1].args[MULTI_UVMFLAGS_INDEX] = 0;
-			j = 0;
+	if (xnb->irq != 0) {
+		unbind_from_irqhandler(xnb->irq);
+		xnb->irq = 0;
+	}
+
+	/*
+	 * We may still have another thread currently processing requests.  We
+	 * must acquire the rx and tx locks to make sure those threads are done,
+	 * but we can release those locks as soon as we acquire them, because no
+	 * more interrupts will be arriving.
+	 */
+	mtx_lock(&xnb->tx_lock);
+	mtx_unlock(&xnb->tx_lock);
+	mtx_lock(&xnb->rx_lock);
+	mtx_unlock(&xnb->rx_lock);
+
+	/* Free malloc'd softc member variables */
+	if (xnb->bridge != NULL)
+		free(xnb->bridge, M_XENSTORE);
+
+	/* All request processing has stopped, so unmap the rings */
+	for (i=0; i < XNB_NUM_RING_TYPES; i++) {
+		gnts[i].host_addr = xnb->ring_configs[i].gnt_addr;
+		gnts[i].dev_bus_addr = xnb->ring_configs[i].bus_addr;
+		gnts[i].handle = xnb->ring_configs[i].handle;
+	}
+	error = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, gnts,
+					  XNB_NUM_RING_TYPES);
+	KASSERT(error == 0, ("Grant table unmap op failed (%d)", error));
+
+	xnb_free_communication_mem(xnb);
+	/*
+	 * Zero the ring config structs because the pointers, handles, and
+	 * grant refs contained therein are no longer valid.
+	 */
+	bzero(&xnb->ring_configs[XNB_RING_TYPE_TX],
+	    sizeof(struct xnb_ring_config));
+	bzero(&xnb->ring_configs[XNB_RING_TYPE_RX],
+	    sizeof(struct xnb_ring_config));
+
+	xnb->flags &= ~XNBF_RING_CONNECTED;
+	return (0);
+}
+
+/**
+ * Map a single shared memory ring into domain local address space and
+ * initialize its control structure
+ *
+ * \param xnb	Per-instance xnb configuration structure
+ * \param ring_type	Array index of this ring in the xnb's array of rings
+ * \return 	An errno
+ */
+static int
+xnb_connect_ring(struct xnb_softc *xnb, xnb_ring_type_t ring_type)
+{
+	struct gnttab_map_grant_ref gnt;
+	struct xnb_ring_config *ring = &xnb->ring_configs[ring_type];
+	int error;
+
+	/* TX ring type = 0, RX =1 */
+	ring->va = xnb->kva + ring_type * PAGE_SIZE;
+	ring->gnt_addr = xnb->gnt_base_addr + ring_type * PAGE_SIZE;
+
+	gnt.host_addr = ring->gnt_addr;
+	gnt.flags     = GNTMAP_host_map;
+	gnt.ref       = ring->ring_ref;
+	gnt.dom       = xnb->otherend_id;
+
+	error = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &gnt, 1);
+	if (error != 0)
+		panic("netback: Ring page grant table op failed (%d)", error);
+
+	if (gnt.status != 0) {
+		ring->va = 0;
+		error = EACCES;
+		xenbus_dev_fatal(xnb->dev, error,
+				 "Ring shared page mapping failed. "
+				 "Status %d.", gnt.status);
+	} else {
+		ring->handle = gnt.handle;
+		ring->bus_addr = gnt.dev_bus_addr;
+
+		if (ring_type == XNB_RING_TYPE_TX) {
+			BACK_RING_INIT(&ring->back_ring.tx_ring,
+			    (netif_tx_sring_t*)ring->va,
+			    ring->ring_pages * PAGE_SIZE);
+		} else if (ring_type == XNB_RING_TYPE_RX) {
+			BACK_RING_INIT(&ring->back_ring.rx_ring,
+			    (netif_rx_sring_t*)ring->va,
+			    ring->ring_pages * PAGE_SIZE);
+		} else {
+			xenbus_dev_fatal(xnb->dev, error,
+				 "Unknown ring type %d", ring_type);
 		}
 	}
 
-	return (unsigned long)pages;
+	return error;
 }
 
-#ifdef XEN_NETBACK_FIXUP_CSUM
+/**
+ * Setup the shared memory rings and bind an interrupt to the event channel
+ * used to notify us of ring changes.
+ *
+ * \param xnb  Per-instance xnb configuration structure.
+ */
+static int
+xnb_connect_comms(struct xnb_softc *xnb)
+{
+	int	error;
+	xnb_ring_type_t i;
+
+	if ((xnb->flags & XNBF_RING_CONNECTED) != 0)
+		return (0);
+
+	/*
+	 * Kva for our rings are at the tail of the region of kva allocated
+	 * by xnb_alloc_communication_mem().
+	 */
+	for (i=0; i < XNB_NUM_RING_TYPES; i++) {
+		error = xnb_connect_ring(xnb, i);
+		if (error != 0)
+	  		return error;
+	}
+
+	xnb->flags |= XNBF_RING_CONNECTED;
+
+	error =
+	    bind_interdomain_evtchn_to_irqhandler(xnb->otherend_id,
+						  xnb->evtchn,
+						  device_get_nameunit(xnb->dev),
+						  xnb_intr, /*arg*/xnb,
+						  INTR_TYPE_BIO | INTR_MPSAFE,
+						  &xnb->irq);
+	if (error != 0) {
+		(void)xnb_disconnect(xnb);
+		xenbus_dev_fatal(xnb->dev, error, "binding event channel");
+		return (error);
+	}
+
+	DPRINTF("rings connected!\n");
+
+	return (0);
+}
+
+/**
+ * Size KVA and pseudo-physical address allocations based on negotiated
+ * values for the size and number of I/O requests, and the size of our
+ * communication ring.
+ *
+ * \param xnb  Per-instance xnb configuration structure.
+ *
+ * These address spaces are used to dynamically map pages in the
+ * front-end's domain into our own.
+ */
+static int
+xnb_alloc_communication_mem(struct xnb_softc *xnb)
+{
+	xnb_ring_type_t i;
+
+	xnb->kva_size = 0;
+	for (i=0; i < XNB_NUM_RING_TYPES; i++) {
+		xnb->kva_size += xnb->ring_configs[i].ring_pages * PAGE_SIZE;
+	}
+#ifndef XENHVM
+	xnb->kva = kmem_alloc_nofault(kernel_map, xnb->kva_size);
+	if (xnb->kva == 0)
+		return (ENOMEM);
+	xnb->gnt_base_addr = xnb->kva;
+#else /* defined XENHVM */
+	/*
+	 * Reserve a range of pseudo physical memory that we can map
+	 * into kva.  These pages will only be backed by machine
+	 * pages ("real memory") during the lifetime of front-end requests
+	 * via grant table operations.  We will map the netif tx and rx rings
+	 * into this space.
+	 */
+	xnb->pseudo_phys_res_id = 0;
+	xnb->pseudo_phys_res = bus_alloc_resource(xnb->dev, SYS_RES_MEMORY,
+						  &xnb->pseudo_phys_res_id,
+						  0, ~0, xnb->kva_size,
+						  RF_ACTIVE);
+	if (xnb->pseudo_phys_res == NULL) {
+		xnb->kva = 0;
+		return (ENOMEM);
+	}
+	xnb->kva = (vm_offset_t)rman_get_virtual(xnb->pseudo_phys_res);
+	xnb->gnt_base_addr = rman_get_start(xnb->pseudo_phys_res);
+#endif /* !defined XENHVM */
+	return (0);
+}
+
+/**
+ * Collect information from the XenStore related to our device and its frontend
+ *
+ * \param xnb  Per-instance xnb configuration structure.
+ */
+static int
+xnb_collect_xenstore_info(struct xnb_softc *xnb)
+{
+	/**
+	 * \todo Linux collects the following info.  We should collect most
+	 * of this, too:
+	 * "feature-rx-notify"
+	 */
+	const char *otherend_path;
+	const char *our_path;
+	int err;
+	unsigned int rx_copy, bridge_len;
+	uint8_t no_csum_offload;
+
+	otherend_path = xenbus_get_otherend_path(xnb->dev);
+	our_path = xenbus_get_node(xnb->dev);
+
+	/* Collect the critical communication parameters */
+	err = xs_gather(XST_NIL, otherend_path,
+	    "tx-ring-ref", "%l" PRIu32,
+	    	&xnb->ring_configs[XNB_RING_TYPE_TX].ring_ref,
+	    "rx-ring-ref", "%l" PRIu32,
+	    	&xnb->ring_configs[XNB_RING_TYPE_RX].ring_ref,
+	    "event-channel", "%" PRIu32, &xnb->evtchn,
+	    NULL);
+	if (err != 0) {
+		xenbus_dev_fatal(xnb->dev, err,
+				 "Unable to retrieve ring information from "
+				 "frontend %s.  Unable to connect.",
+				 otherend_path);
+		return (err);
+	}
+
+	/* Collect the handle from xenstore */
+	err = xs_scanf(XST_NIL, our_path, "handle", NULL, "%li", &xnb->handle);
+	if (err != 0) {
+		xenbus_dev_fatal(xnb->dev, err,
+		    "Error reading handle from frontend %s.  "
+		    "Unable to connect.", otherend_path);
+	}
+
+	/*
+	 * Collect the bridgename, if any.  We do not need bridge_len; we just
+	 * throw it away
+	 */
+	err = xs_read(XST_NIL, our_path, "bridge", &bridge_len,
+		      (void**)&xnb->bridge);
+	if (err != 0)
+		xnb->bridge = NULL;
+
+	/*
+	 * Does the frontend request that we use rx copy?  If not, return an
+	 * error because this driver only supports rx copy.
+	 */
+	err = xs_scanf(XST_NIL, otherend_path, "request-rx-copy", NULL,
+		       "%" PRIu32, &rx_copy);
+	if (err == ENOENT) {
+		err = 0;
+	 	rx_copy = 0;
+	}
+	if (err < 0) {
+		xenbus_dev_fatal(xnb->dev, err, "reading %s/request-rx-copy",
+				 otherend_path);
+		return err;
+	}
+	/**
+	 * \todo: figure out the exact meaning of this feature, and when
+	 * the frontend will set it to true.  It should be set to true
+	 * at some point
+	 */
+/*        if (!rx_copy)*/
+/*          return EOPNOTSUPP;*/
+
+	/** \todo Collect the rx notify feature */
+
+	/*  Collect the feature-sg. */
+	if (xs_scanf(XST_NIL, otherend_path, "feature-sg", NULL,
+		     "%hhu", &xnb->can_sg) < 0)
+		xnb->can_sg = 0;
+
+	/* Collect remaining frontend features */
+	if (xs_scanf(XST_NIL, otherend_path, "feature-gso-tcpv4", NULL,
+		     "%hhu", &xnb->gso) < 0)
+		xnb->gso = 0;
+
+	if (xs_scanf(XST_NIL, otherend_path, "feature-gso-tcpv4-prefix", NULL,
+		     "%hhu", &xnb->gso_prefix) < 0)
+		xnb->gso_prefix = 0;
+
+	if (xs_scanf(XST_NIL, otherend_path, "feature-no-csum-offload", NULL,
+		     "%hhu", &no_csum_offload) < 0)
+		no_csum_offload = 0;
+	xnb->ip_csum = (no_csum_offload == 0);
+
+	return (0);
+}
+
+/**
+ * Supply information about the physical device to the frontend
+ * via XenBus.
+ *
+ * \param xnb  Per-instance xnb configuration structure.
+ */
+static int
+xnb_publish_backend_info(struct xnb_softc *xnb)
+{
+	struct xs_transaction xst;
+	const char *our_path;
+	int error;
+
+	our_path = xenbus_get_node(xnb->dev);
+
+	do {
+		error = xs_transaction_start(&xst);
+		if (error != 0) {
+			xenbus_dev_fatal(xnb->dev, error,
+					 "Error publishing backend info "
+					 "(start transaction)");
+			break;
+		}
+
+		error = xs_printf(xst, our_path, "feature-sg",
+				  "%d", XNB_SG);
+		if (error != 0)
+			break;
+
+		error = xs_printf(xst, our_path, "feature-gso-tcpv4",
+				  "%d", XNB_GSO_TCPV4);
+		if (error != 0)
+			break;
+
+		error = xs_printf(xst, our_path, "feature-rx-copy",
+				  "%d", XNB_RX_COPY);
+		if (error != 0)
+			break;
+
+		error = xs_printf(xst, our_path, "feature-rx-flip",
+				  "%d", XNB_RX_FLIP);
+		if (error != 0)
+			break;
+
+		error = xs_transaction_end(xst, 0);
+		if (error != 0 && error != EAGAIN) {
+			xenbus_dev_fatal(xnb->dev, error, "ending transaction");
+			break;
+		}
+
+	} while (error == EAGAIN);
+
+	return (error);
+}
+
+/**
+ * Connect to our netfront peer now that it has completed publishing
+ * its configuration into the XenStore.
+ *
+ * \param xnb  Per-instance xnb configuration structure.
+ */
 static void
-fixup_checksum(struct mbuf *m)
+xnb_connect(struct xnb_softc *xnb)
 {
-	struct ether_header *eh = mtod(m, struct ether_header *);
-	struct ip *ip = (struct ip *)(eh + 1);
-	int iphlen = ip->ip_hl << 2;
-	int iplen = ntohs(ip->ip_len);
+	int	error;
 
-	if ((m->m_pkthdr.csum_flags & CSUM_TCP)) {
-		struct tcphdr *th = (struct tcphdr *)((caddr_t)ip + iphlen);
-		th->th_sum = in_pseudo(ip->ip_src.s_addr, ip->ip_dst.s_addr,
-			htons(IPPROTO_TCP + (iplen - iphlen)));
-		th->th_sum = in_cksum_skip(m, iplen + sizeof(*eh), sizeof(*eh) + iphlen);
-		m->m_pkthdr.csum_flags &= ~CSUM_TCP;
-#ifdef SCTP
-	} else if (sw_csum & CSUM_SCTP) {
-		sctp_delayed_cksum(m, iphlen);
-		sw_csum &= ~CSUM_SCTP;
+	if (xenbus_get_state(xnb->dev) == XenbusStateConnected)
+		return;
+
+	if (xnb_collect_xenstore_info(xnb) != 0)
+		return;
+
+	xnb->flags &= ~XNBF_SHUTDOWN;
+
+	/* Read front end configuration. */
+
+	/* Allocate resources whose size depends on front-end configuration. */
+	error = xnb_alloc_communication_mem(xnb);
+	if (error != 0) {
+		xenbus_dev_fatal(xnb->dev, error,
+				 "Unable to allocate communication memory");
+		return;
+	}
+
+	/*
+	 * Connect communication channel.
+	 */
+	error = xnb_connect_comms(xnb);
+	if (error != 0) {
+		/* Specific errors are reported by xnb_connect_comms(). */
+		return;
+	}
+	xnb->carrier = 1;
+
+	/* Ready for I/O. */
+	xenbus_set_state(xnb->dev, XenbusStateConnected);
+}
+
+/*-------------------------- Device Teardown Support -------------------------*/
+/**
+ * Perform device shutdown functions.
+ *
+ * \param xnb  Per-instance xnb configuration structure.
+ *
+ * Mark this instance as shutting down, wait for any active requests
+ * to drain, disconnect from the front-end, and notify any waiters (e.g.
+ * a thread invoking our detach method) that detach can now proceed.
+ */
+static int
+xnb_shutdown(struct xnb_softc *xnb)
+{
+	/*
+	 * Due to the need to drop our mutex during some
+	 * xenbus operations, it is possible for two threads
+	 * to attempt to close out shutdown processing at
+	 * the same time.  Tell the caller that hits this
+	 * race to try back later.
+	 */
+	if ((xnb->flags & XNBF_IN_SHUTDOWN) != 0)
+		return (EAGAIN);
+
+	xnb->flags |= XNBF_SHUTDOWN;
+
+	xnb->flags |= XNBF_IN_SHUTDOWN;
+
+	mtx_unlock(&xnb->sc_lock);
+	/* Free the network interface */
+	xnb->carrier = 0;
+	if (xnb->xnb_ifp != NULL) {
+		ether_ifdetach(xnb->xnb_ifp);
+		if_free(xnb->xnb_ifp);
+		xnb->xnb_ifp = NULL;
+	}
+	mtx_lock(&xnb->sc_lock);
+
+	xnb_disconnect(xnb);
+
+	mtx_unlock(&xnb->sc_lock);
+	if (xenbus_get_state(xnb->dev) < XenbusStateClosing)
+		xenbus_set_state(xnb->dev, XenbusStateClosing);
+	mtx_lock(&xnb->sc_lock);
+
+	xnb->flags &= ~XNBF_IN_SHUTDOWN;
+
+
+	/* Indicate to xnb_detach() that is it safe to proceed. */
+	wakeup(xnb);
+
+	return (0);
+}
+
+/**
+ * Report an attach time error to the console and Xen, and cleanup
+ * this instance by forcing immediate detach processing.
+ *
+ * \param xnb  Per-instance xnb configuration structure.
+ * \param err  Errno describing the error.
+ * \param fmt  Printf style format and arguments
+ */
+static void
+xnb_attach_failed(struct xnb_softc *xnb, int err, const char *fmt, ...)
+{
+	va_list ap;
+	va_list ap_hotplug;
+
+	va_start(ap, fmt);
+	va_copy(ap_hotplug, ap);
+	xs_vprintf(XST_NIL, xenbus_get_node(xnb->dev),
+		  "hotplug-error", fmt, ap_hotplug);
+	va_end(ap_hotplug);
+	xs_printf(XST_NIL, xenbus_get_node(xnb->dev),
+		  "hotplug-status", "error");
+
+	xenbus_dev_vfatal(xnb->dev, err, fmt, ap);
+	va_end(ap);
+
+	xs_printf(XST_NIL, xenbus_get_node(xnb->dev),
+		  "online", "0");
+	xnb_detach(xnb->dev);
+}
+
+/*---------------------------- NewBus Entrypoints ----------------------------*/
+/**
+ * Inspect a XenBus device and claim it if is of the appropriate type.
+ *
+ * \param dev  NewBus device object representing a candidate XenBus device.
+ *
+ * \return  0 for success, errno codes for failure.
+ */
+static int
+xnb_probe(device_t dev)
+{
+	 if (!strcmp(xenbus_get_type(dev), "vif")) {
+		DPRINTF("Claiming device %d, %s\n", device_get_unit(dev),
+		    devclass_get_name(device_get_devclass(dev)));
+		device_set_desc(dev, "Backend Virtual Network Device");
+		device_quiet(dev);
+		return (0);
+	}
+	return (ENXIO);
+}
+
+/**
+ * Setup sysctl variables to control various Network Back parameters.
+ *
+ * \param xnb  Xen Net Back softc.
+ *
+ */
+static void
+xnb_setup_sysctl(struct xnb_softc *xnb)
+{
+	struct sysctl_ctx_list *sysctl_ctx = NULL;
+	struct sysctl_oid      *sysctl_tree = NULL;
+
+	sysctl_ctx = device_get_sysctl_ctx(xnb->dev);
+	if (sysctl_ctx == NULL)
+		return;
+
+	sysctl_tree = device_get_sysctl_tree(xnb->dev);
+	if (sysctl_tree == NULL)
+		return;
+
+#ifdef XNB_DEBUG
+	SYSCTL_ADD_PROC(sysctl_ctx,
+			SYSCTL_CHILDREN(sysctl_tree),
+			OID_AUTO,
+			"unit_test_results",
+			CTLTYPE_STRING | CTLFLAG_RD,
+			xnb,
+			0,
+			xnb_unit_test_main,
+			"A",
+			"Results of builtin unit tests");
+
+	SYSCTL_ADD_PROC(sysctl_ctx,
+			SYSCTL_CHILDREN(sysctl_tree),
+			OID_AUTO,
+			"dump_rings",
+			CTLTYPE_STRING | CTLFLAG_RD,
+			xnb,
+			0,
+			xnb_dump_rings,
+			"A",
+			"Xennet Back Rings");
+#endif /* XNB_DEBUG */
+}
+
+/**
+ * Create a network device.
+ * @param handle device handle
+ */
+int
+create_netdev(device_t dev)
+{
+	struct ifnet *ifp;
+	struct xnb_softc *xnb;
+	int err = 0;
+
+	xnb = device_get_softc(dev);
+	mtx_init(&xnb->sc_lock, "xnb_softc", "xen netback softc lock", MTX_DEF);
+	mtx_init(&xnb->tx_lock, "xnb_tx", "xen netback tx lock", MTX_DEF);
+	mtx_init(&xnb->rx_lock, "xnb_rx", "xen netback rx lock", MTX_DEF);
+
+	xnb->dev = dev;
+
+	ifmedia_init(&xnb->sc_media, 0, xnb_ifmedia_upd, xnb_ifmedia_sts);
+	ifmedia_add(&xnb->sc_media, IFM_ETHER|IFM_MANUAL, 0, NULL);
+	ifmedia_set(&xnb->sc_media, IFM_ETHER|IFM_MANUAL);
+
+	err = xen_net_read_mac(dev, xnb->mac);
+	if (err == 0) {
+		/* Set up ifnet structure */
+		ifp = xnb->xnb_ifp = if_alloc(IFT_ETHER);
+		ifp->if_softc = xnb;
+		if_initname(ifp, "xnb",  device_get_unit(dev));
+		ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
+		ifp->if_ioctl = xnb_ioctl;
+		ifp->if_output = ether_output;
+		ifp->if_start = xnb_start;
+#ifdef notyet
+		ifp->if_watchdog = xnb_watchdog;
 #endif
-	} else {
-		u_short csum;
-		struct udphdr *uh = (struct udphdr *)((caddr_t)ip + iphlen);
-		uh->uh_sum = in_pseudo(ip->ip_src.s_addr, ip->ip_dst.s_addr,
-			htons(IPPROTO_UDP + (iplen - iphlen)));
-		if ((csum = in_cksum_skip(m, iplen + sizeof(*eh), sizeof(*eh) + iphlen)) == 0)
-			csum = 0xffff;
-		uh->uh_sum = csum;
-		m->m_pkthdr.csum_flags &= ~CSUM_UDP;
+		ifp->if_init = xnb_ifinit;
+		ifp->if_mtu = ETHERMTU;
+		ifp->if_snd.ifq_maxlen = NET_RX_RING_SIZE - 1;
+
+		ifp->if_hwassist = XNB_CSUM_FEATURES;
+		ifp->if_capabilities = IFCAP_HWCSUM;
+		ifp->if_capenable = IFCAP_HWCSUM;
+
+		ether_ifattach(ifp, xnb->mac);
+		xnb->carrier = 0;
+	}
+
+	return err;
+}
+
+/**
+ * Attach to a XenBus device that has been claimed by our probe routine.
+ *
+ * \param dev  NewBus device object representing this Xen Net Back instance.
+ *
+ * \return  0 for success, errno codes for failure.
+ */
+static int
+xnb_attach(device_t dev)
+{
+	struct xnb_softc *xnb;
+	int	error;
+	xnb_ring_type_t	i;
+
+	error = create_netdev(dev);
+	if (error != 0) {
+		xenbus_dev_fatal(dev, error, "creating netdev");
+		return (error);
+	}
+
+	DPRINTF("Attaching to %s\n", xenbus_get_node(dev));
+
+	/*
+	 * Basic initialization.
+	 * After this block it is safe to call xnb_detach()
+	 * to clean up any allocated data for this instance.
+	 */
+	xnb = device_get_softc(dev);
+	xnb->otherend_id = xenbus_get_otherend_id(dev);
+	for (i=0; i < XNB_NUM_RING_TYPES; i++) {
+		xnb->ring_configs[i].ring_pages = 1;
+	}
+
+	/*
+	 * Setup sysctl variables.
+	 */
+	xnb_setup_sysctl(xnb);
+
+	/* Update hot-plug status to satisfy xend. */
+	error = xs_printf(XST_NIL, xenbus_get_node(xnb->dev),
+			  "hotplug-status", "connected");
+	if (error != 0) {
+		xnb_attach_failed(xnb, error, "writing %s/hotplug-status",
+				  xenbus_get_node(xnb->dev));
+		return (error);
+	}
+
+	if ((error = xnb_publish_backend_info(xnb)) != 0) {
+		/*
+		 * If we can't publish our data, we cannot participate
+		 * in this connection, and waiting for a front-end state
+		 * change will not help the situation.
+		 */
+		xnb_attach_failed(xnb, error,
+		    "Publishing backend status for %s",
+				  xenbus_get_node(xnb->dev));
+		return error;
+	}
+
+	/* Tell the front end that we are ready to connect. */
+	xenbus_set_state(dev, XenbusStateInitWait);
+
+	return (0);
+}
+
+/**
+ * Detach from a net back device instance.
+ *
+ * \param dev  NewBus device object representing this Xen Net Back instance.
+ *
+ * \return  0 for success, errno codes for failure.
+ *
+ * \note A net back device may be detached at any time in its life-cycle,
+ *       including part way through the attach process.  For this reason,
+ *       initialization order and the intialization state checks in this
+ *       routine must be carefully coupled so that attach time failures
+ *       are gracefully handled.
+ */
+static int
+xnb_detach(device_t dev)
+{
+	struct xnb_softc *xnb;
+
+	DPRINTF("\n");
+
+	xnb = device_get_softc(dev);
+	mtx_lock(&xnb->sc_lock);
+	while (xnb_shutdown(xnb) == EAGAIN) {
+		msleep(xnb, &xnb->sc_lock, /*wakeup prio unchanged*/0,
+		       "xnb_shutdown", 0);
+	}
+	mtx_unlock(&xnb->sc_lock);
+	DPRINTF("\n");
+
+	mtx_destroy(&xnb->tx_lock);
+	mtx_destroy(&xnb->rx_lock);
+	mtx_destroy(&xnb->sc_lock);
+	return (0);
+}
+
+/**
+ * Prepare this net back device for suspension of this VM.
+ *
+ * \param dev  NewBus device object representing this Xen net Back instance.
+ *
+ * \return  0 for success, errno codes for failure.
+ */
+static int
+xnb_suspend(device_t dev)
+{
+	return (0);
+}
+
+/**
+ * Perform any processing required to recover from a suspended state.
+ *
+ * \param dev  NewBus device object representing this Xen Net Back instance.
+ *
+ * \return  0 for success, errno codes for failure.
+ */
+static int
+xnb_resume(device_t dev)
+{
+	return (0);
+}
+
+/**
+ * Handle state changes expressed via the XenStore by our front-end peer.
+ *
+ * \param dev             NewBus device object representing this Xen
+ *                        Net Back instance.
+ * \param frontend_state  The new state of the front-end.
+ *
+ * \return  0 for success, errno codes for failure.
+ */
+static void
+xnb_frontend_changed(device_t dev, XenbusState frontend_state)
+{
+	struct xnb_softc *xnb;
+
+	xnb = device_get_softc(dev);
+
+	DPRINTF("frontend_state=%s, xnb_state=%s\n",
+	        xenbus_strstate(frontend_state),
+		xenbus_strstate(xenbus_get_state(xnb->dev)));
+
+	switch (frontend_state) {
+	case XenbusStateInitialising:
+		break;
+	case XenbusStateInitialised:
+	case XenbusStateConnected:
+		xnb_connect(xnb);
+		break;
+	case XenbusStateClosing:
+	case XenbusStateClosed:
+		mtx_lock(&xnb->sc_lock);
+		xnb_shutdown(xnb);
+		mtx_unlock(&xnb->sc_lock);
+		if (frontend_state == XenbusStateClosed)
+			xenbus_set_state(xnb->dev, XenbusStateClosed);
+		break;
+	default:
+		xenbus_dev_fatal(xnb->dev, EINVAL, "saw state %d at frontend",
+				 frontend_state);
+		break;
 	}
 }
-#endif
 
-/* Add the interface to the specified bridge */
+
+/*---------------------------- Request Processing ----------------------------*/
+/**
+ * Interrupt handler bound to the shared ring's event channel.
+ * Entry point for the xennet transmit path in netback
+ * Transfers packets from the Xen ring to the host's generic networking stack
+ *
+ * \param arg  Callback argument registerd during event channel
+ *             binding - the xnb_softc for this instance.
+ */
+static void
+xnb_intr(void *arg)
+{
+	struct xnb_softc *xnb;
+	struct ifnet *ifp;
+	netif_tx_back_ring_t *txb;
+	RING_IDX req_prod_local;
+
+	xnb = (struct xnb_softc *)arg;
+	ifp = xnb->xnb_ifp;
+	txb = &xnb->ring_configs[XNB_RING_TYPE_TX].back_ring.tx_ring;
+
+	mtx_lock(&xnb->tx_lock);
+	do {
+		int notify;
+		req_prod_local = txb->sring->req_prod;
+		xen_rmb();
+
+		for (;;) {
+			struct mbuf *mbufc;
+			int err;
+
+			err = xnb_recv(txb, xnb->otherend_id, &mbufc, ifp,
+			    	       xnb->tx_gnttab);
+			if (err || (mbufc == NULL))
+				break;
+
+			/* Send the packet to the generic network stack */
+			(*xnb->xnb_ifp->if_input)(xnb->xnb_ifp, mbufc);
+		}
+
+		RING_PUSH_RESPONSES_AND_CHECK_NOTIFY(txb, notify);
+		if (notify != 0)
+			notify_remote_via_irq(xnb->irq);
+
+		txb->sring->req_event = txb->req_cons + 1;
+		xen_mb();
+	} while (txb->sring->req_prod != req_prod_local) ;
+	mtx_unlock(&xnb->tx_lock);
+
+	xnb_start(ifp);
+}
+
+
+/**
+ * Build a struct xnb_pkt based on netif_tx_request's from a netif tx ring.
+ * Will read exactly 0 or 1 packets from the ring; never a partial packet.
+ * \param[out]	pkt	The returned packet.  If there is an error building
+ * 			the packet, pkt.list_len will be set to 0.
+ * \param[in]	tx_ring	Pointer to the Ring that is the input to this function
+ * \param[in]	start	The ring index of the first potential request
+ * \return		The number of requests consumed to build this packet
+ */
 static int
-add_to_bridge(struct ifnet *ifp, char *bridge)
+xnb_ring2pkt(struct xnb_pkt *pkt, const netif_tx_back_ring_t *tx_ring,
+	     RING_IDX start)
 {
-	struct ifdrv ifd;
-	struct ifbreq ifb;
-	struct ifnet *ifp_bridge = ifunit(bridge);
+	/*
+	 * Outline:
+	 * 1) Initialize pkt
+	 * 2) Read the first request of the packet
+	 * 3) Read the extras
+	 * 4) Set cdr
+	 * 5) Loop on the remainder of the packet
+	 * 6) Finalize pkt (stuff like car_size and list_len)
+	 */
+	int idx = start;
+	int discard = 0;	/* whether to discard the packet */
+	int more_data = 0;	/* there are more request past the last one */
+	uint16_t cdr_size = 0;	/* accumulated size of requests 2 through n */
 
-	if (!ifp_bridge)
-		return ENOENT;
+	xnb_pkt_initialize(pkt);
 
-	bzero(&ifd, sizeof(ifd));
-	bzero(&ifb, sizeof(ifb));
+	/* Read the first request */
+	if (RING_HAS_UNCONSUMED_REQUESTS_2(tx_ring, idx)) {
+		netif_tx_request_t *tx = RING_GET_REQUEST(tx_ring, idx);
+		pkt->size = tx->size;
+		pkt->flags = tx->flags & ~NETTXF_more_data;
+		more_data = tx->flags & NETTXF_more_data;
+		pkt->list_len++;
+		pkt->car = idx;
+		idx++;
+	}
 
-	strcpy(ifb.ifbr_ifsname, ifp->if_xname);
-	strcpy(ifd.ifd_name, ifp->if_xname);
-	ifd.ifd_cmd = BRDGADD;
-	ifd.ifd_len = sizeof(ifb);
-	ifd.ifd_data = &ifb;
+	/* Read the extra info */
+	if ((pkt->flags & NETTXF_extra_info) &&
+	    RING_HAS_UNCONSUMED_REQUESTS_2(tx_ring, idx)) {
+		netif_extra_info_t *ext =
+		    (netif_extra_info_t*) RING_GET_REQUEST(tx_ring, idx);
+		pkt->extra.type = ext->type;
+		switch (pkt->extra.type) {
+			case XEN_NETIF_EXTRA_TYPE_GSO:
+				pkt->extra.u.gso = ext->u.gso;
+				break;
+			default:
+				/*
+				 * The reference Linux netfront driver will
+				 * never set any other extra.type.  So we don't
+				 * know what to do with it.  Let's print an
+				 * error, then consume and discard the packet
+				 */
+				printf("xnb(%s:%d): Unknown extra info type %d."
+				       "  Discarding packet\n",
+				       __func__, __LINE__, pkt->extra.type);
+				xnb_dump_txreq(start, RING_GET_REQUEST(tx_ring,
+				    start));
+				xnb_dump_txreq(idx, RING_GET_REQUEST(tx_ring,
+				    idx));
+				discard = 1;
+				break;
+		}
 
-	return bridge_ioctl_kern(ifp_bridge, SIOCSDRVSPEC, &ifd);
-	
+		pkt->extra.flags = ext->flags;
+		if (ext->flags & XEN_NETIF_EXTRA_FLAG_MORE) {
+			/*
+			 * The reference linux netfront driver never sets this
+			 * flag (nor does any other known netfront).  So we
+			 * will discard the packet.
+			 */
+			printf("xnb(%s:%d): Request sets "
+			    "XEN_NETIF_EXTRA_FLAG_MORE, but we can't handle "
+			    "that\n", __func__, __LINE__);
+			xnb_dump_txreq(start, RING_GET_REQUEST(tx_ring, start));
+			xnb_dump_txreq(idx, RING_GET_REQUEST(tx_ring, idx));
+			discard = 1;
+		}
+
+		idx++;
+	}
+
+	/* Set cdr.  If there is not more data, cdr is invalid */
+	pkt->cdr = idx;
+
+	/* Loop on remainder of packet */
+	while (more_data && RING_HAS_UNCONSUMED_REQUESTS_2(tx_ring, idx)) {
+		netif_tx_request_t *tx = RING_GET_REQUEST(tx_ring, idx);
+		pkt->list_len++;
+		cdr_size += tx->size;
+		if (tx->flags & ~NETTXF_more_data) {
+			/* There should be no other flags set at this point */
+			printf("xnb(%s:%d): Request sets unknown flags %d "
+			    "after the 1st request in the packet.\n",
+			    __func__, __LINE__, tx->flags);
+			xnb_dump_txreq(start, RING_GET_REQUEST(tx_ring, start));
+			xnb_dump_txreq(idx, RING_GET_REQUEST(tx_ring, idx));
+		}
+
+		more_data = tx->flags & NETTXF_more_data;
+		idx++;
+	}
+
+	/* Finalize packet */
+	if (more_data != 0) {
+		/* The ring ran out of requests before finishing the packet */
+		xnb_pkt_invalidate(pkt);
+		idx = start;	/* tell caller that we consumed no requests */
+	} else {
+		/* Calculate car_size */
+		pkt->car_size = pkt->size - cdr_size;
+	}
+	if (discard != 0) {
+		xnb_pkt_invalidate(pkt);
+	}
+
+	return idx - start;
+}
+
+
+/**
+ * Respond to all the requests that constituted pkt.  Builds the responses and
+ * writes them to the ring, but doesn't push them to the shared ring.
+ * \param[in] pkt	the packet that needs a response
+ * \param[in] error	true if there was an error handling the packet, such
+ * 			as in the hypervisor copy op or mbuf allocation
+ * \param[out] ring	Responses go here
+ */
+static void
+xnb_txpkt2rsp(const struct xnb_pkt *pkt, netif_tx_back_ring_t *ring,
+	      int error)
+{
+	/*
+	 * Outline:
+	 * 1) Respond to the first request
+	 * 2) Respond to the extra info reques
+	 * Loop through every remaining request in the packet, generating
+	 * responses that copy those requests' ids and sets the status
+	 * appropriately.
+	 */
+	netif_tx_request_t *tx;
+	netif_tx_response_t *rsp;
+	int i;
+	uint16_t status;
+
+	status = (xnb_pkt_is_valid(pkt) == 0) || error ?
+		NETIF_RSP_ERROR : NETIF_RSP_OKAY;
+	KASSERT((pkt->list_len == 0) || (ring->rsp_prod_pvt == pkt->car),
+	    ("Cannot respond to ring requests out of order"));
+
+	if (pkt->list_len >= 1) {
+		uint16_t id;
+		tx = RING_GET_REQUEST(ring, ring->rsp_prod_pvt);
+		id = tx->id;
+		rsp = RING_GET_RESPONSE(ring, ring->rsp_prod_pvt);
+		rsp->id = id;
+		rsp->status = status;
+		ring->rsp_prod_pvt++;
+
+		if (pkt->flags & NETRXF_extra_info) {
+			rsp = RING_GET_RESPONSE(ring, ring->rsp_prod_pvt);
+			rsp->status = NETIF_RSP_NULL;
+			ring->rsp_prod_pvt++;
+		}
+	}
+
+	for (i=0; i < pkt->list_len - 1; i++) {
+		uint16_t id;
+		tx = RING_GET_REQUEST(ring, ring->rsp_prod_pvt);
+		id = tx->id;
+		rsp = RING_GET_RESPONSE(ring, ring->rsp_prod_pvt);
+		rsp->id = id;
+		rsp->status = status;
+		ring->rsp_prod_pvt++;
+	}
+}
+
+/**
+ * Create an mbuf chain to represent a packet.  Initializes all of the headers
+ * in the mbuf chain, but does not copy the data.  The returned chain must be
+ * free()'d when no longer needed
+ * \param[in]	pkt	A packet to model the mbuf chain after
+ * \return	A newly allocated mbuf chain, possibly with clusters attached.
+ * 		NULL on failure
+ */
+static struct mbuf*
+xnb_pkt2mbufc(const struct xnb_pkt *pkt, struct ifnet *ifp)
+{
+	/**
+	 * \todo consider using a memory pool for mbufs instead of
+	 * reallocating them for every packet
+	 */
+	/** \todo handle extra data */
+	struct mbuf *m;
+
+	m = m_getm(NULL, pkt->size, M_NOWAIT, MT_DATA);
+
+	if (m != NULL) {
+		m->m_pkthdr.rcvif = ifp;
+		if (pkt->flags & NETTXF_data_validated) {
+			/*
+			 * We lie to the host OS and always tell it that the
+			 * checksums are ok, because the packet is unlikely to
+			 * get corrupted going across domains.
+			 */
+			m->m_pkthdr.csum_flags = (
+				CSUM_IP_CHECKED |
+				CSUM_IP_VALID   |
+				CSUM_DATA_VALID |
+				CSUM_PSEUDO_HDR
+				);
+			m->m_pkthdr.csum_data = 0xffff;
+		}
+	}
+	return m;
+}
+
+/**
+ * Build a gnttab_copy table that can be used to copy data from a pkt
+ * to an mbufc.  Does not actually perform the copy.  Always uses gref's on
+ * the packet side.
+ * \param[in]	pkt	pkt's associated requests form the src for
+ * 			the copy operation
+ * \param[in]	mbufc	mbufc's storage forms the dest for the copy operation
+ * \param[out]  gnttab	Storage for the returned grant table
+ * \param[in]	txb	Pointer to the backend ring structure
+ * \param[in]	otherend_id	The domain ID of the other end of the copy
+ * \return 		The number of gnttab entries filled
+ */
+static int
+xnb_txpkt2gnttab(const struct xnb_pkt *pkt, const struct mbuf *mbufc,
+		 gnttab_copy_table gnttab, const netif_tx_back_ring_t *txb,
+		 domid_t otherend_id)
+{
+
+	const struct mbuf *mbuf = mbufc;/* current mbuf within the chain */
+	int gnt_idx = 0;		/* index into grant table */
+	RING_IDX r_idx = pkt->car;	/* index into tx ring buffer */
+	int r_ofs = 0;	/* offset of next data within tx request's data area */
+	int m_ofs = 0;	/* offset of next data within mbuf's data area */
+	/* size in bytes that still needs to be represented in the table */
+	uint16_t size_remaining = pkt->size;
+
+	while (size_remaining > 0) {
+		const netif_tx_request_t *txq = RING_GET_REQUEST(txb, r_idx);
+		const size_t mbuf_space = M_TRAILINGSPACE(mbuf) - m_ofs;
+		const size_t req_size =
+			r_idx == pkt->car ? pkt->car_size : txq->size;
+		const size_t pkt_space = req_size - r_ofs;
+		/*
+		 * space is the largest amount of data that can be copied in the
+		 * grant table's next entry
+		 */
+		const size_t space = MIN(pkt_space, mbuf_space);
+
+		/* TODO: handle this error condition without panicking */
+		KASSERT(gnt_idx < GNTTAB_LEN, ("Grant table is too short"));
+
+		gnttab[gnt_idx].source.u.ref = txq->gref;
+		gnttab[gnt_idx].source.domid = otherend_id;
+		gnttab[gnt_idx].source.offset = txq->offset + r_ofs;
+		gnttab[gnt_idx].dest.u.gmfn = virt_to_mfn(
+		    mtod(mbuf, vm_offset_t) + m_ofs);
+		gnttab[gnt_idx].dest.offset = virt_to_offset(
+		    mtod(mbuf, vm_offset_t) + m_ofs);
+		gnttab[gnt_idx].dest.domid = DOMID_SELF;
+		gnttab[gnt_idx].len = space;
+		gnttab[gnt_idx].flags = GNTCOPY_source_gref;
+
+		gnt_idx++;
+		r_ofs += space;
+		m_ofs += space;
+		size_remaining -= space;
+		if (req_size - r_ofs <= 0) {
+			/* Must move to the next tx request */
+			r_ofs = 0;
+			r_idx = (r_idx == pkt->car) ? pkt->cdr : r_idx + 1;
+		}
+		if (M_TRAILINGSPACE(mbuf) - m_ofs <= 0) {
+			/* Must move to the next mbuf */
+			m_ofs = 0;
+			mbuf = mbuf->m_next;
+		}
+	}
+
+	return gnt_idx;
+}
+
+/**
+ * Check the status of the grant copy operations, and update mbufs various
+ * non-data fields to reflect the data present.
+ * \param[in,out] mbufc	mbuf chain to update.  The chain must be valid and of
+ * 			the correct length, and data should already be present
+ * \param[in] gnttab	A grant table for a just completed copy op
+ * \param[in] n_entries The number of valid entries in the grant table
+ */
+static void
+xnb_update_mbufc(struct mbuf *mbufc, const gnttab_copy_table gnttab,
+    		 int n_entries)
+{
+	struct mbuf *mbuf = mbufc;
+	int i;
+	size_t total_size = 0;
+
+	for (i = 0; i < n_entries; i++) {
+		KASSERT(gnttab[i].status == GNTST_okay,
+		    ("Some gnttab_copy entry had error status %hd\n",
+		    gnttab[i].status));
+
+		mbuf->m_len += gnttab[i].len;
+		total_size += gnttab[i].len;
+		if (M_TRAILINGSPACE(mbuf) <= 0) {
+			mbuf = mbuf->m_next;
+		}
+	}
+	mbufc->m_pkthdr.len = total_size;
+
+	xnb_add_mbuf_cksum(mbufc);
+}
+
+/**
+ * Dequeue at most one packet from the shared ring
+ * \param[in,out] txb	Netif tx ring.  A packet will be removed from it, and
+ * 			its private indices will be updated.  But the indices
+ * 			will not be pushed to the shared ring.
+ * \param[in] ifnet	Interface to which the packet will be sent
+ * \param[in] otherend	Domain ID of the other end of the ring
+ * \param[out] mbufc	The assembled mbuf chain, ready to send to the generic
+ * 			networking stack
+ * \param[in,out] gnttab Pointer to enough memory for a grant table.  We make
+ * 			this a function parameter so that we will take less
+ * 			stack space.
+ * \return		An error code
+ */
+static int
+xnb_recv(netif_tx_back_ring_t *txb, domid_t otherend, struct mbuf **mbufc,
+	 struct ifnet *ifnet, gnttab_copy_table gnttab)
+{
+	struct xnb_pkt pkt;
+	/* number of tx requests consumed to build the last packet */
+	int num_consumed;
+	int nr_ents;
+
+	*mbufc = NULL;
+	num_consumed = xnb_ring2pkt(&pkt, txb, txb->req_cons);
+	if (num_consumed == 0)
+		return 0;	/* Nothing to receive */
+
+	/* update statistics indepdent of errors */
+	ifnet->if_ipackets++;
+
+	/*
+	 * if we got here, then 1 or more requests was consumed, but the packet
+	 * is not necesarily valid.
+	 */
+	if (xnb_pkt_is_valid(&pkt) == 0) {
+		/* got a garbage packet, respond and drop it */
+		xnb_txpkt2rsp(&pkt, txb, 1);
+		txb->req_cons += num_consumed;
+		DPRINTF("xnb_intr: garbage packet, num_consumed=%d\n",
+				num_consumed);
+		ifnet->if_ierrors++;
+		return EINVAL;
+	}
+
+	*mbufc = xnb_pkt2mbufc(&pkt, ifnet);
+
+	if (*mbufc == NULL) {
+		/*
+		 * Couldn't allocate mbufs.  Respond and drop the packet.  Do
+		 * not consume the requests
+		 */
+		xnb_txpkt2rsp(&pkt, txb, 1);
+		DPRINTF("xnb_intr: Couldn't allocate mbufs, num_consumed=%d\n",
+		    num_consumed);
+		ifnet->if_iqdrops++;
+		return ENOMEM;
+	}
+
+	nr_ents = xnb_txpkt2gnttab(&pkt, *mbufc, gnttab, txb, otherend);
+
+	if (nr_ents > 0) {
+		int __unused hv_ret = HYPERVISOR_grant_table_op(GNTTABOP_copy,
+		    gnttab, nr_ents);
+		KASSERT(hv_ret == 0,
+		    ("HYPERVISOR_grant_table_op returned %d\n", hv_ret));
+		xnb_update_mbufc(*mbufc, gnttab, nr_ents);
+	}
+
+	xnb_txpkt2rsp(&pkt, txb, 0);
+	txb->req_cons += num_consumed;
+	return 0;
+}
+
+/**
+ * Create an xnb_pkt based on the contents of an mbuf chain.
+ * \param[in] mbufc	mbuf chain to transform into a packet
+ * \param[out] pkt	Storage for the newly generated xnb_pkt
+ * \param[in] start	The ring index of the first available slot in the rx
+ * 			ring
+ * \param[in] space	The number of free slots in the rx ring
+ * \retval 0		Success
+ * \retval EINVAL	mbufc was corrupt or not convertible into a pkt
+ * \retval EAGAIN	There was not enough space in the ring to queue the
+ * 			packet
+ */
+static int
+xnb_mbufc2pkt(const struct mbuf *mbufc, struct xnb_pkt *pkt,
+	      RING_IDX start, int space)
+{
+
+	int retval = 0;
+
+	if ((mbufc == NULL) ||
+	     ( (mbufc->m_flags & M_PKTHDR) == 0) ||
+	     (mbufc->m_pkthdr.len == 0)) {
+		xnb_pkt_invalidate(pkt);
+		retval = EINVAL;
+	} else {
+		int slots_required;
+
+		xnb_pkt_validate(pkt);
+		pkt->flags = 0;
+		pkt->size = mbufc->m_pkthdr.len;
+		pkt->car = start;
+		pkt->car_size = mbufc->m_len;
+
+		if (mbufc->m_pkthdr.csum_flags & CSUM_TSO) {
+			pkt->flags |= NETRXF_extra_info;
+			pkt->extra.u.gso.size = mbufc->m_pkthdr.tso_segsz;
+			pkt->extra.u.gso.type = XEN_NETIF_GSO_TYPE_TCPV4;
+			pkt->extra.u.gso.pad = 0;
+			pkt->extra.u.gso.features = 0;
+			pkt->extra.type = XEN_NETIF_EXTRA_TYPE_GSO;
+			pkt->extra.flags = 0;
+			pkt->cdr = start + 2;
+		} else {
+			pkt->cdr = start + 1;
+		}
+		if (mbufc->m_pkthdr.csum_flags & (CSUM_TSO | CSUM_DELAY_DATA)) {
+			pkt->flags |=
+			    (NETRXF_csum_blank | NETRXF_data_validated);
+		}
+
+		/*
+		 * Each ring response can have up to PAGE_SIZE of data.
+		 * Assume that we can defragment the mbuf chain efficiently
+		 * into responses so that each response but the last uses all
+		 * PAGE_SIZE bytes.
+		 */
+		pkt->list_len = (pkt->size + PAGE_SIZE - 1) / PAGE_SIZE;
+
+		if (pkt->list_len > 1) {
+			pkt->flags |= NETRXF_more_data;
+		}
+
+		slots_required = pkt->list_len +
+			(pkt->flags & NETRXF_extra_info ? 1 : 0);
+		if (slots_required > space) {
+			xnb_pkt_invalidate(pkt);
+			retval = EAGAIN;
+		}
+	}
+
+	return retval;
+}
+
+/**
+ * Build a gnttab_copy table that can be used to copy data from an mbuf chain
+ * to the frontend's shared buffers.  Does not actually perform the copy.
+ * Always uses gref's on the other end's side.
+ * \param[in]	pkt	pkt's associated responses form the dest for the copy
+ * 			operatoin
+ * \param[in]	mbufc	The source for the copy operation
+ * \param[out]	gnttab	Storage for the returned grant table
+ * \param[in]	rxb	Pointer to the backend ring structure
+ * \param[in]	otherend_id	The domain ID of the other end of the copy
+ * \return 		The number of gnttab entries filled
+ */
+static int
+xnb_rxpkt2gnttab(const struct xnb_pkt *pkt, const struct mbuf *mbufc,
+		 gnttab_copy_table gnttab, const netif_rx_back_ring_t *rxb,
+		 domid_t otherend_id)
+{
+
+	const struct mbuf *mbuf = mbufc;/* current mbuf within the chain */
+	int gnt_idx = 0;		/* index into grant table */
+	RING_IDX r_idx = pkt->car;	/* index into rx ring buffer */
+	int r_ofs = 0;	/* offset of next data within rx request's data area */
+	int m_ofs = 0;	/* offset of next data within mbuf's data area */
+	/* size in bytes that still needs to be represented in the table */
+	uint16_t size_remaining;
+
+	size_remaining = (xnb_pkt_is_valid(pkt) != 0) ? pkt->size : 0;
+
+	while (size_remaining > 0) {
+		const netif_rx_request_t *rxq = RING_GET_REQUEST(rxb, r_idx);
+		const size_t mbuf_space = mbuf->m_len - m_ofs;
+		/* Xen shared pages have an implied size of PAGE_SIZE */
+		const size_t req_size = PAGE_SIZE;
+		const size_t pkt_space = req_size - r_ofs;
+		/*
+		 * space is the largest amount of data that can be copied in the
+		 * grant table's next entry
+		 */
+		const size_t space = MIN(pkt_space, mbuf_space);
+
+		/* TODO: handle this error condition without panicing */
+		KASSERT(gnt_idx < GNTTAB_LEN, ("Grant table is too short"));
+
+		gnttab[gnt_idx].dest.u.ref = rxq->gref;
+		gnttab[gnt_idx].dest.domid = otherend_id;
+		gnttab[gnt_idx].dest.offset = r_ofs;
+		gnttab[gnt_idx].source.u.gmfn = virt_to_mfn(
+		    mtod(mbuf, vm_offset_t) + m_ofs);
+		gnttab[gnt_idx].source.offset = virt_to_offset(
+		    mtod(mbuf, vm_offset_t) + m_ofs);
+		gnttab[gnt_idx].source.domid = DOMID_SELF;
+		gnttab[gnt_idx].len = space;
+		gnttab[gnt_idx].flags = GNTCOPY_dest_gref;
+
+		gnt_idx++;
+
+		r_ofs += space;
+		m_ofs += space;
+		size_remaining -= space;
+		if (req_size - r_ofs <= 0) {
+			/* Must move to the next rx request */
+			r_ofs = 0;
+			r_idx = (r_idx == pkt->car) ? pkt->cdr : r_idx + 1;
+		}
+		if (mbuf->m_len - m_ofs <= 0) {
+			/* Must move to the next mbuf */
+			m_ofs = 0;
+			mbuf = mbuf->m_next;
+		}
+	}
+
+	return gnt_idx;
+}
+
+/**
+ * Generates responses for all the requests that constituted pkt.  Builds
+ * responses and writes them to the ring, but doesn't push the shared ring
+ * indices.
+ * \param[in] pkt	the packet that needs a response
+ * \param[in] gnttab	The grant copy table corresponding to this packet.
+ * 			Used to determine how many rsp->netif_rx_response_t's to
+ * 			generate.
+ * \param[in] n_entries	Number of relevant entries in the grant table
+ * \param[out] ring	Responses go here
+ * \return		The number of RX requests that were consumed to generate
+ * 			the responses
+ */
+static int
+xnb_rxpkt2rsp(const struct xnb_pkt *pkt, const gnttab_copy_table gnttab,
+    	      int n_entries, netif_rx_back_ring_t *ring)
+{
+	/*
+	 * This code makes the following assumptions:
+	 *	* All entries in gnttab set GNTCOPY_dest_gref
+	 *	* The entries in gnttab are grouped by their grefs: any two
+	 *	   entries with the same gref must be adjacent
+	 */
+	int error = 0;
+	int gnt_idx, i;
+	int n_responses = 0;
+	grant_ref_t last_gref = GRANT_REF_INVALID;
+	RING_IDX r_idx;
+
+	KASSERT(gnttab != NULL, ("Received a null granttable copy"));
+
+	/*
+	 * In the event of an error, we only need to send one response to the
+	 * netfront.  In that case, we musn't write any data to the responses
+	 * after the one we send.  So we must loop all the way through gnttab
+	 * looking for errors before we generate any responses
+	 *
+	 * Since we're looping through the grant table anyway, we'll count the
+	 * number of different gref's in it, which will tell us how many
+	 * responses to generate
+	 */
+	for (gnt_idx = 0; gnt_idx < n_entries; gnt_idx++) {
+		int16_t status = gnttab[gnt_idx].status;
+		if (status != GNTST_okay) {
+			DPRINTF(
+			    "Got error %d for hypervisor gnttab_copy status\n",
+			    status);
+			error = 1;
+			break;
+		}
+		if (gnttab[gnt_idx].dest.u.ref != last_gref) {
+			n_responses++;
+			last_gref = gnttab[gnt_idx].dest.u.ref;
+		}
+	}
+
+	if (error != 0) {
+		uint16_t id;
+		netif_rx_response_t *rsp;
+		
+		id = RING_GET_REQUEST(ring, ring->rsp_prod_pvt)->id;
+		rsp = RING_GET_RESPONSE(ring, ring->rsp_prod_pvt);
+		rsp->id = id;
+		rsp->status = NETIF_RSP_ERROR;
+		n_responses = 1;
+	} else {
+		gnt_idx = 0;
+		const int has_extra = pkt->flags & NETRXF_extra_info;
+		if (has_extra != 0)
+			n_responses++;
+
+		for (i = 0; i < n_responses; i++) {
+			netif_rx_request_t rxq;
+			netif_rx_response_t *rsp;
+
+			r_idx = ring->rsp_prod_pvt + i;
+			/*
+			 * We copy the structure of rxq instead of making a
+			 * pointer because it shares the same memory as rsp.
+			 */
+			rxq = *(RING_GET_REQUEST(ring, r_idx));
+			rsp = RING_GET_RESPONSE(ring, r_idx);
+			if (has_extra && (i == 1)) {
+				netif_extra_info_t *ext =
+					(netif_extra_info_t*)rsp;
+				ext->type = XEN_NETIF_EXTRA_TYPE_GSO;
+				ext->flags = 0;
+				ext->u.gso.size = pkt->extra.u.gso.size;
+				ext->u.gso.type = XEN_NETIF_GSO_TYPE_TCPV4;
+				ext->u.gso.pad = 0;
+				ext->u.gso.features = 0;
+			} else {
+				rsp->id = rxq.id;
+				rsp->status = GNTST_okay;
+				rsp->offset = 0;
+				rsp->flags = 0;
+				if (i < pkt->list_len - 1)
+					rsp->flags |= NETRXF_more_data;
+				if ((i == 0) && has_extra)
+					rsp->flags |= NETRXF_extra_info;
+				if ((i == 0) &&
+					(pkt->flags & NETRXF_data_validated)) {
+					rsp->flags |= NETRXF_data_validated;
+					rsp->flags |= NETRXF_csum_blank;
+				}
+				rsp->status = 0;
+				for (; gnttab[gnt_idx].dest.u.ref == rxq.gref;
+				    gnt_idx++) {
+					rsp->status += gnttab[gnt_idx].len;
+				}
+			}
+		}
+	}
+
+	ring->req_cons += n_responses;
+	ring->rsp_prod_pvt += n_responses;
+	return n_responses;
+}
+
+/**
+ * Add IP, TCP, and/or UDP checksums to every mbuf in a chain.  The first mbuf
+ * in the chain must start with a struct ether_header.
+ *
+ * XXX This function will perform incorrectly on UDP packets that are split up
+ * into multiple ethernet frames.
+ */
+static void
+xnb_add_mbuf_cksum(struct mbuf *mbufc)
+{
+	struct ether_header *eh;
+	struct ip *iph;
+	uint16_t ether_type;
+
+	eh = mtod(mbufc, struct ether_header*);
+	ether_type = ntohs(eh->ether_type);
+	if (ether_type != ETHERTYPE_IP) {
+		/* Nothing to calculate */
+		return;
+	}
+
+	iph = (struct ip*)(eh + 1);
+	if (mbufc->m_pkthdr.csum_flags & CSUM_IP_VALID) {
+		iph->ip_sum = 0;
+		iph->ip_sum = in_cksum_hdr(iph);
+	}
+
+	switch (iph->ip_p) {
+	case IPPROTO_TCP:
+		if (mbufc->m_pkthdr.csum_flags & CSUM_IP_VALID) {
+			size_t tcplen = ntohs(iph->ip_len) - sizeof(struct ip);
+			struct tcphdr *th = (struct tcphdr*)(iph + 1);
+			th->th_sum = in_pseudo(iph->ip_src.s_addr,
+			    iph->ip_dst.s_addr, htons(IPPROTO_TCP + tcplen));
+			th->th_sum = in_cksum_skip(mbufc,
+			    sizeof(struct ether_header) + ntohs(iph->ip_len),
+			    sizeof(struct ether_header) + (iph->ip_hl << 2));
+		}
+		break;
+	case IPPROTO_UDP:
+		if (mbufc->m_pkthdr.csum_flags & CSUM_IP_VALID) {
+			size_t udplen = ntohs(iph->ip_len) - sizeof(struct ip);
+			struct udphdr *uh = (struct udphdr*)(iph + 1);
+			uh->uh_sum = in_pseudo(iph->ip_src.s_addr,
+			    iph->ip_dst.s_addr, htons(IPPROTO_UDP + udplen));
+			uh->uh_sum = in_cksum_skip(mbufc,
+			    sizeof(struct ether_header) + ntohs(iph->ip_len),
+			    sizeof(struct ether_header) + (iph->ip_hl << 2));
+		}
+		break;
+	default:
+		break;
+	}
+}
+
+static void
+xnb_stop(struct xnb_softc *xnb)
+{
+	struct ifnet *ifp;
+
+	mtx_assert(&xnb->sc_lock, MA_OWNED);
+	ifp = xnb->xnb_ifp;
+	ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
+	if_link_state_change(ifp, LINK_STATE_DOWN);
 }
 
 static int
-netif_create(int handle, struct xenbus_device *xdev, char *bridge)
+xnb_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
 {
-	netif_t *netif;
-	struct ifnet *ifp;
+	struct xnb_softc *xnb = ifp->if_softc;
+#ifdef INET
+	struct ifreq *ifr = (struct ifreq*) data;
+	struct ifaddr *ifa = (struct ifaddr*)data;
+#endif
+	int error = 0;
 
-	netif = (netif_t *)malloc(sizeof(*netif), M_DEVBUF, M_NOWAIT | M_ZERO);
-	if (!netif)
-		return ENOMEM;
+	switch (cmd) {
+		case SIOCSIFFLAGS:
+			mtx_lock(&xnb->sc_lock);
+			if (ifp->if_flags & IFF_UP) {
+				xnb_ifinit_locked(xnb);
+			} else {
+				if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
+					xnb_stop(xnb);
+				}
+			}
+			/*
+			 * Note: netfront sets a variable named xn_if_flags
+			 * here, but that variable is never read
+			 */
+			mtx_unlock(&xnb->sc_lock);
+			break;
+		case SIOCSIFADDR:
+		case SIOCGIFADDR:
+#ifdef INET
+			mtx_lock(&xnb->sc_lock);
+			if (ifa->ifa_addr->sa_family == AF_INET) {
+				ifp->if_flags |= IFF_UP;
+				if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) {
+					ifp->if_drv_flags &= ~(IFF_DRV_RUNNING |
+							IFF_DRV_OACTIVE);
+					if_link_state_change(ifp,
+							LINK_STATE_DOWN);
+					ifp->if_drv_flags |= IFF_DRV_RUNNING;
+					ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
+					if_link_state_change(ifp,
+					    LINK_STATE_UP);
+				}
+				arp_ifinit(ifp, ifa);
+				mtx_unlock(&xnb->sc_lock);
+			} else {
+				mtx_unlock(&xnb->sc_lock);
+#endif
+				error = ether_ioctl(ifp, cmd, data);
+#ifdef INET
+			}
+#endif
+			break;
+		case SIOCSIFCAP:
+			mtx_lock(&xnb->sc_lock);
+			if (ifr->ifr_reqcap & IFCAP_TXCSUM) {
+				ifp->if_capenable |= IFCAP_TXCSUM;
+				ifp->if_hwassist |= XNB_CSUM_FEATURES;
+			} else {
+				ifp->if_capenable &= ~(IFCAP_TXCSUM);
+				ifp->if_hwassist &= ~(XNB_CSUM_FEATURES);
+			}
+			if ((ifr->ifr_reqcap & IFCAP_RXCSUM)) {
+				ifp->if_capenable |= IFCAP_RXCSUM;
+			} else {
+				ifp->if_capenable &= ~(IFCAP_RXCSUM);
+			}
+			/*
+			 * TODO enable TSO4 and LRO once we no longer need
+			 * to calculate checksums in software
+			 */
+#if 0
+			if (ifr->if_reqcap |= IFCAP_TSO4) {
+				if (IFCAP_TXCSUM & ifp->if_capenable) {
+					printf("xnb: Xen netif requires that "
+						"TXCSUM be enabled in order "
+						"to use TSO4\n");
+					error = EINVAL;
+				} else {
+					ifp->if_capenable |= IFCAP_TSO4;
+					ifp->if_hwassist |= CSUM_TSO;
+				}
+			} else {
+				ifp->if_capenable &= ~(IFCAP_TSO4);
+				ifp->if_hwassist &= ~(CSUM_TSO);
+			}
+			if (ifr->ifreqcap |= IFCAP_LRO) {
+				ifp->if_capenable |= IFCAP_LRO;
+			} else {
+				ifp->if_capenable &= ~(IFCAP_LRO);
+			}
+#endif
+			mtx_unlock(&xnb->sc_lock);
+			break;
+		case SIOCSIFMTU:
+			ifp->if_mtu = ifr->ifr_mtu;
+			ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
+			xnb_ifinit(xnb);
+			break;
+		case SIOCADDMULTI:
+		case SIOCDELMULTI:
+		case SIOCSIFMEDIA:
+		case SIOCGIFMEDIA:
+			error = ifmedia_ioctl(ifp, ifr, &xnb->sc_media, cmd);
+			break;
+		default:
+			error = ether_ioctl(ifp, cmd, data);
+			break;
+	}
+	return (error);
+}
 
-	netif->ref_cnt = 1;
-	netif->handle = handle;
-	netif->domid = xdev->otherend_id;
-	netif->xdev = xdev;
-	netif->bridge = bridge;
-	xdev->data = netif;
+static void
+xnb_start_locked(struct ifnet *ifp)
+{
+	netif_rx_back_ring_t *rxb;
+	struct xnb_softc *xnb;
+	struct mbuf *mbufc;
+	RING_IDX req_prod_local;
 
-	/* Set up ifnet structure */
-	ifp = netif->ifp = if_alloc(IFT_ETHER);
-	if (!ifp) {
-		if (bridge)
-			free(bridge, M_DEVBUF);
-		free(netif, M_DEVBUF);
-		return ENOMEM;
+	xnb = ifp->if_softc;
+	rxb = &xnb->ring_configs[XNB_RING_TYPE_RX].back_ring.rx_ring;
+
+	if (!xnb->carrier)
+		return;
+
+	do {
+		int out_of_space = 0;
+		int notify;
+		req_prod_local = rxb->sring->req_prod;
+		xen_rmb();
+		for (;;) {
+			int error;
+
+			IF_DEQUEUE(&ifp->if_snd, mbufc);
+			if (mbufc == NULL)
+				break;
+			error = xnb_send(rxb, xnb->otherend_id, mbufc,
+			    		 xnb->rx_gnttab);
+			switch (error) {
+				case EAGAIN:
+					/*
+					 * Insufficient space in the ring.
+					 * Requeue pkt and send when space is
+					 * available.
+					 */
+					IF_PREPEND(&ifp->if_snd, mbufc);
+					/*
+					 * Perhaps the frontend missed an IRQ
+					 * and went to sleep.  Notify it to wake
+					 * it up.
+					 */
+					out_of_space = 1;
+					break;
+
+				case EINVAL:
+					/* OS gave a corrupt packet.  Drop it.*/
+					ifp->if_oerrors++;
+					/* FALLTHROUGH */
+				default:
+					/* Send succeeded, or packet had error.
+					 * Free the packet */
+					ifp->if_opackets++;
+					if (mbufc)
+						m_freem(mbufc);
+					break;
+			}
+			if (out_of_space != 0)
+				break;
+		}
+
+		RING_PUSH_RESPONSES_AND_CHECK_NOTIFY(rxb, notify);
+		if ((notify != 0) || (out_of_space != 0))
+			notify_remote_via_irq(xnb->irq);
+		rxb->sring->req_event = req_prod_local + 1;
+		xen_mb();
+	} while (rxb->sring->req_prod != req_prod_local) ;
+}
+
+/**
+ * Sends one packet to the ring.  Blocks until the packet is on the ring
+ * \param[in]	mbufc	Contains one packet to send.  Caller must free
+ * \param[in,out] rxb	The packet will be pushed onto this ring, but the
+ * 			otherend will not be notified.
+ * \param[in]	otherend The domain ID of the other end of the connection
+ * \retval	EAGAIN	The ring did not have enough space for the packet.
+ * 			The ring has not been modified
+ * \param[in,out] gnttab Pointer to enough memory for a grant table.  We make
+ * 			this a function parameter so that we will take less
+ * 			stack space.
+ * \retval EINVAL	mbufc was corrupt or not convertible into a pkt
+ */
+static int
+xnb_send(netif_rx_back_ring_t *ring, domid_t otherend, const struct mbuf *mbufc,
+	 gnttab_copy_table gnttab)
+{
+	struct xnb_pkt pkt;
+	int error, n_entries, n_reqs;
+	RING_IDX space;
+
+	space = ring->sring->req_prod - ring->req_cons;
+	error = xnb_mbufc2pkt(mbufc, &pkt, ring->rsp_prod_pvt, space);
+	if (error != 0)
+		return error;
+	n_entries = xnb_rxpkt2gnttab(&pkt, mbufc, gnttab, ring, otherend);
+	if (n_entries != 0) {
+		int __unused hv_ret = HYPERVISOR_grant_table_op(GNTTABOP_copy,
+		    gnttab, n_entries);
+		KASSERT(hv_ret == 0, ("HYPERVISOR_grant_table_op returned %d\n",
+		    hv_ret));
 	}
 
-	ifp->if_softc = netif;
-	if_initname(ifp, "vif",
-		atomic_fetchadd_int(&vif_unit_maker, 1) /* ifno */ );
-	ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX;
-	ifp->if_output = ether_output;
-	ifp->if_start = netback_start;
-	ifp->if_ioctl = netback_ioctl;
-	ifp->if_snd.ifq_maxlen = NET_TX_RING_SIZE - 1;
-	
-	DPRINTF("Created %s for domid=%d handle=%d\n", IFNAME(netif), netif->domid, netif->handle);
+	n_reqs = xnb_rxpkt2rsp(&pkt, gnttab, n_entries, ring);
 
 	return 0;
 }
 
 static void
-netif_get(netif_t *netif)
+xnb_start(struct ifnet *ifp)
 {
-	atomic_add_int(&netif->ref_cnt, 1);
+	struct xnb_softc *xnb;
+
+	xnb = ifp->if_softc;
+	mtx_lock(&xnb->rx_lock);
+	xnb_start_locked(ifp);
+	mtx_unlock(&xnb->rx_lock);
 }
 
+/* equivalent of network_open() in Linux */
 static void
-netif_put(netif_t *netif)
+xnb_ifinit_locked(struct xnb_softc *xnb)
 {
-	if (atomic_fetchadd_int(&netif->ref_cnt, -1) == 1) {
-		DPRINTF("%s\n", IFNAME(netif));
-		disconnect_rings(netif);
-		if (netif->ifp) {
-			if_free(netif->ifp);
-			netif->ifp = NULL;
-		}
-		if (netif->bridge)
-			free(netif->bridge, M_DEVBUF);
-		free(netif, M_DEVBUF);
-	}
+	struct ifnet *ifp;
+
+	ifp = xnb->xnb_ifp;
+
+	mtx_assert(&xnb->sc_lock, MA_OWNED);
+
+	if (ifp->if_drv_flags & IFF_DRV_RUNNING)
+		return;
+
+	xnb_stop(xnb);
+
+	ifp->if_drv_flags |= IFF_DRV_RUNNING;
+	ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
+	if_link_state_change(ifp, LINK_STATE_UP);
 }
 
-static int
-netback_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
+
+static void
+xnb_ifinit(void *xsc)
 {
-	switch (cmd) {
-	case SIOCSIFFLAGS:
-	DDPRINTF("%s cmd=SIOCSIFFLAGS flags=%x\n",
-			IFNAME((struct netback_info *)ifp->if_softc), ((struct ifreq *)data)->ifr_flags);
-		return 0;
-	}
+	struct xnb_softc *xnb = xsc;
 
-	DDPRINTF("%s cmd=%lx\n", IFNAME((struct netback_info *)ifp->if_softc), cmd);
-
-	return ether_ioctl(ifp, cmd, data);
+	mtx_lock(&xnb->sc_lock);
+	xnb_ifinit_locked(xnb);
+	mtx_unlock(&xnb->sc_lock);
 }
 
-static inline void
-maybe_schedule_tx_action(void)
+
+/**
+ * Read the 'mac' node at the given device's node in the store, and parse that
+ * as colon-separated octets, placing result the given mac array.  mac must be
+ * a preallocated array of length ETHER_ADDR_LEN ETH_ALEN (as declared in
+ * net/ethernet.h).
+ * Return 0 on success, or errno on error.
+ */
+static int
+xen_net_read_mac(device_t dev, uint8_t mac[])
 {
-	smp_mb();
-	if ((NR_PENDING_REQS < (MAX_PENDING_REQS/2)) && !STAILQ_EMPTY(&tx_sched_list))
-		taskqueue_enqueue(taskqueue_swi, &net_tx_task); 
+	char *s, *e, *macstr;
+	const char *path;
+	int error = 0;
+	int i;
+
+	path = xenbus_get_node(dev);
+	error = xs_read(XST_NIL, path, "mac", NULL, (void **) &macstr);
+	if (error != 0) {
+		xenbus_dev_fatal(dev, error, "parsing %s/mac", path);
+	} else {
+	        s = macstr;
+	        for (i = 0; i < ETHER_ADDR_LEN; i++) {
+		        mac[i] = strtoul(s, &e, 16);
+		        if (s == e || (e[0] != ':' && e[0] != 0)) {
+				error = ENOENT;
+				break;
+		        }
+		        s = &e[1];
+	        }
+	        free(macstr, M_XENBUS);
+	}
+	return error;
 }
 
-/* Removes netif from front of list and does not call netif_put() (caller must) */
-static netif_t *
-remove_from_tx_schedule_list(void)
+
+/**
+ * Callback used by the generic networking code to tell us when our carrier
+ * state has changed.  Since we don't have a physical carrier, we don't care
+ */
+static int
+xnb_ifmedia_upd(struct ifnet *ifp)
 {
-	netif_t *netif;
-
-	mtx_lock(&tx_sched_list_lock);
-
-	if ((netif = STAILQ_FIRST(&tx_sched_list))) {
-		STAILQ_REMOVE(&tx_sched_list, netif, netback_info, next_tx);
-		STAILQ_NEXT(netif, next_tx) = NULL;
-		netif->on_tx_sched_list = 0;
-	}
-
-	mtx_unlock(&tx_sched_list_lock);
-
-	return netif;
-}
-
-/* Adds netif to end of list and calls netif_get() */
-static void
-add_to_tx_schedule_list_tail(netif_t *netif)
-{
-	if (netif->on_tx_sched_list)
-		return;
-
-	mtx_lock(&tx_sched_list_lock);
-	if (!netif->on_tx_sched_list && (netif->ifp->if_drv_flags & IFF_DRV_RUNNING)) {
-		netif_get(netif);
-		STAILQ_INSERT_TAIL(&tx_sched_list, netif, next_tx);
-		netif->on_tx_sched_list = 1;
-	}
-	mtx_unlock(&tx_sched_list_lock);
-}
-
-/*
- * Note on CONFIG_XEN_NETDEV_PIPELINED_TRANSMITTER:
- * If this driver is pipelining transmit requests then we can be very
- * aggressive in avoiding new-packet notifications -- frontend only needs to
- * send a notification if there are no outstanding unreceived responses.
- * If we may be buffer transmit buffers for any reason then we must be rather
- * more conservative and treat this as the final check for pending work.
- */
-static void
-netif_schedule_tx_work(netif_t *netif)
-{
-	int more_to_do;
-
-#ifdef CONFIG_XEN_NETDEV_PIPELINED_TRANSMITTER
-	more_to_do = RING_HAS_UNCONSUMED_REQUESTS(&netif->tx);
-#else
-	RING_FINAL_CHECK_FOR_REQUESTS(&netif->tx, more_to_do);
-#endif
-
-	if (more_to_do) {
-		DDPRINTF("Adding %s to tx sched list\n", IFNAME(netif));
-		add_to_tx_schedule_list_tail(netif);
-		maybe_schedule_tx_action();
-	}
-}
-
-static struct mtx dealloc_lock;
-MTX_SYSINIT(netback_dealloc, &dealloc_lock, "DEALLOC LOCK", MTX_SPIN | MTX_NOWITNESS);
-
-static void
-netif_idx_release(uint16_t pending_idx)
-{
-	mtx_lock_spin(&dealloc_lock);
-	dealloc_ring[MASK_PEND_IDX(dealloc_prod++)] = pending_idx;
-	mtx_unlock_spin(&dealloc_lock);
-
-	taskqueue_enqueue(taskqueue_swi, &net_tx_task); 
-}
-
-static void
-make_tx_response(netif_t *netif, 
-				 uint16_t    id,
-				 int8_t      st)
-{
-	RING_IDX i = netif->tx.rsp_prod_pvt;
-	netif_tx_response_t *resp;
-	int notify;
-
-	resp = RING_GET_RESPONSE(&netif->tx, i);
-	resp->id     = id;
-	resp->status = st;
-
-	netif->tx.rsp_prod_pvt = ++i;
-	RING_PUSH_RESPONSES_AND_CHECK_NOTIFY(&netif->tx, notify);
-	if (notify)
-		notify_remote_via_irq(netif->irq);
-
-#ifdef CONFIG_XEN_NETDEV_PIPELINED_TRANSMITTER
-	if (i == netif->tx.req_cons) {
-		int more_to_do;
-		RING_FINAL_CHECK_FOR_REQUESTS(&netif->tx, more_to_do);
-		if (more_to_do)
-			add_to_tx_schedule_list_tail(netif);
-	}
-#endif
-}
-
-static inline void
-net_tx_action_dealloc(void)
-{
-	gnttab_unmap_grant_ref_t *gop;
-	uint16_t pending_idx;
-	PEND_RING_IDX dc, dp;
-	netif_t *netif;
-	int ret;
-
-	dc = dealloc_cons;
-	dp = dealloc_prod;
-
-	/*
-	 * Free up any grants we have finished using
-	 */
-	gop = tx_unmap_ops;
-	while (dc != dp) {
-		pending_idx = dealloc_ring[MASK_PEND_IDX(dc++)];
-		gop->host_addr    = MMAP_VADDR(pending_idx);
-		gop->dev_bus_addr = 0;
-		gop->handle       = grant_tx_handle[pending_idx];
-		gop++;
-	}
-	ret = HYPERVISOR_grant_table_op(
-		GNTTABOP_unmap_grant_ref, tx_unmap_ops, gop - tx_unmap_ops);
-	BUG_ON(ret);
-
-	while (dealloc_cons != dp) {
-		pending_idx = dealloc_ring[MASK_PEND_IDX(dealloc_cons++)];
-
-		netif = pending_tx_info[pending_idx].netif;
-
-		make_tx_response(netif, pending_tx_info[pending_idx].req.id, 
-				 NETIF_RSP_OKAY);
-        
-		pending_ring[MASK_PEND_IDX(pending_prod++)] = pending_idx;
-
-		netif_put(netif);
-	}
-}
-
-static void
-netif_page_release(void *buf, void *args)
-{
-	uint16_t pending_idx = (unsigned int)args;
-	
-	DDPRINTF("pending_idx=%u\n", pending_idx);
-
-	KASSERT(pending_idx < MAX_PENDING_REQS, ("%s: bad index %u", __func__, pending_idx));
-
-	netif_idx_release(pending_idx);
-}
-
-static void
-net_tx_action(void *context, int pending)
-{
-	struct mbuf *m;
-	netif_t *netif;
-	netif_tx_request_t txreq;
-	uint16_t pending_idx;
-	RING_IDX i;
-	gnttab_map_grant_ref_t *mop;
-	int ret, work_to_do;
-	struct mbuf *txq = NULL, *txq_last = NULL;
-
-	if (dealloc_cons != dealloc_prod)
-		net_tx_action_dealloc();
-
-	mop = tx_map_ops;
-	while ((NR_PENDING_REQS < MAX_PENDING_REQS) && !STAILQ_EMPTY(&tx_sched_list)) {
-
-		/* Get a netif from the list with work to do. */
-		netif = remove_from_tx_schedule_list();
-
-		DDPRINTF("Processing %s (prod=%u, cons=%u)\n",
-				IFNAME(netif), netif->tx.sring->req_prod, netif->tx.req_cons);
-
-		RING_FINAL_CHECK_FOR_REQUESTS(&netif->tx, work_to_do);
-		if (!work_to_do) {
-			netif_put(netif);
-			continue;
-		}
-
-		i = netif->tx.req_cons;
-		rmb(); /* Ensure that we see the request before we copy it. */
-		memcpy(&txreq, RING_GET_REQUEST(&netif->tx, i), sizeof(txreq));
-
-		/* If we want credit-based scheduling, coud add it here - WORK */
-
-		netif->tx.req_cons++;
-
-		netif_schedule_tx_work(netif);
-
-		if (unlikely(txreq.size < ETHER_HDR_LEN) || 
-		    unlikely(txreq.size > (ETHER_MAX_LEN-ETHER_CRC_LEN))) {
-			WPRINTF("Bad packet size: %d\n", txreq.size);
-			make_tx_response(netif, txreq.id, NETIF_RSP_ERROR);
-			netif_put(netif);
-			continue; 
-		}
-
-		/* No crossing a page as the payload mustn't fragment. */
-		if (unlikely((txreq.offset + txreq.size) >= PAGE_SIZE)) {
-			WPRINTF("txreq.offset: %x, size: %u, end: %u\n", 
-				txreq.offset, txreq.size, 
-				(txreq.offset & PAGE_MASK) + txreq.size);
-			make_tx_response(netif, txreq.id, NETIF_RSP_ERROR);
-			netif_put(netif);
-			continue;
-		}
-
-		pending_idx = pending_ring[MASK_PEND_IDX(pending_cons)];
-
-		MGETHDR(m, M_DONTWAIT, MT_DATA);
-		if (!m) {
-			WPRINTF("Failed to allocate mbuf\n");
-			make_tx_response(netif, txreq.id, NETIF_RSP_ERROR);
-			netif_put(netif);
-			break;
-		}
-		m->m_pkthdr.rcvif = netif->ifp;
-
-		if ((m->m_pkthdr.len = txreq.size) > PKT_PROT_LEN) {
-			struct mbuf *n;
-			MGET(n, M_DONTWAIT, MT_DATA);
-			if (!(m->m_next = n)) {
-				m_freem(m);
-				WPRINTF("Failed to allocate second mbuf\n");
-				make_tx_response(netif, txreq.id, NETIF_RSP_ERROR);
-				netif_put(netif);
-				break;
-			}
-			n->m_len = txreq.size - PKT_PROT_LEN;
-			m->m_len = PKT_PROT_LEN;
-		} else
-			m->m_len = txreq.size;
-
-		mop->host_addr = MMAP_VADDR(pending_idx);
-		mop->dom       = netif->domid;
-		mop->ref       = txreq.gref;
-		mop->flags     = GNTMAP_host_map | GNTMAP_readonly;
-		mop++;
-
-		memcpy(&pending_tx_info[pending_idx].req,
-		       &txreq, sizeof(txreq));
-		pending_tx_info[pending_idx].netif = netif;
-		*((uint16_t *)m->m_data) = pending_idx;
-
-		if (txq_last)
-			txq_last->m_nextpkt = m;
-		else
-			txq = m;
-		txq_last = m;
-
-		pending_cons++;
-
-		if ((mop - tx_map_ops) >= ARRAY_SIZE(tx_map_ops))
-			break;
-	}
-
-	if (!txq)
-		return;
-
-	ret = HYPERVISOR_grant_table_op(
-		GNTTABOP_map_grant_ref, tx_map_ops, mop - tx_map_ops);
-	BUG_ON(ret);
-
-	mop = tx_map_ops;
-	while ((m = txq) != NULL) {
-		caddr_t data;
-
-		txq = m->m_nextpkt;
-		m->m_nextpkt = NULL;
-
-		pending_idx = *((uint16_t *)m->m_data);
-		netif       = pending_tx_info[pending_idx].netif;
-		memcpy(&txreq, &pending_tx_info[pending_idx].req, sizeof(txreq));
-
-		/* Check the remap error code. */
-		if (unlikely(mop->status)) {
-			WPRINTF("#### netback grant fails\n");
-			make_tx_response(netif, txreq.id, NETIF_RSP_ERROR);
-			netif_put(netif);
-			m_freem(m);
-			mop++;
-			pending_ring[MASK_PEND_IDX(pending_prod++)] = pending_idx;
-			continue;
-		}
-
-#if 0
-		/* Can't do this in FreeBSD since vtophys() returns the pfn */
-		/* of the remote domain who loaned us the machine page - DPT */
-		xen_phys_machine[(vtophys(MMAP_VADDR(pending_idx)) >> PAGE_SHIFT)] =
-			mop->dev_bus_addr >> PAGE_SHIFT;
-#endif
-		grant_tx_handle[pending_idx] = mop->handle;
-
-		/* Setup data in mbuf (lengths are already set) */
-		data = (caddr_t)(MMAP_VADDR(pending_idx)|txreq.offset);
-		bcopy(data, m->m_data, m->m_len);
-		if (m->m_next) {
-			struct mbuf *n = m->m_next;
-			MEXTADD(n, MMAP_VADDR(pending_idx), PAGE_SIZE, netif_page_release,
-				(void *)(unsigned int)pending_idx, M_RDONLY, EXT_NET_DRV);
-			n->m_data = &data[PKT_PROT_LEN];
-		} else {
-			/* Schedule a response immediately. */
-			netif_idx_release(pending_idx);
-		}
-
-		if ((txreq.flags & NETTXF_data_validated)) {
-			/* Tell the stack the checksums are okay */
-			m->m_pkthdr.csum_flags |=
-				(CSUM_IP_CHECKED | CSUM_IP_VALID | CSUM_DATA_VALID | CSUM_PSEUDO_HDR);
-			m->m_pkthdr.csum_data = 0xffff;
-		}
-
-		/* If necessary, inform stack to compute the checksums if it forwards the packet */
-		if ((txreq.flags & NETTXF_csum_blank)) {
-			struct ether_header *eh = mtod(m, struct ether_header *);
-			if (ntohs(eh->ether_type) == ETHERTYPE_IP) {
-				struct ip *ip = (struct ip *)&m->m_data[14];
-				if (ip->ip_p == IPPROTO_TCP)
-					m->m_pkthdr.csum_flags |= CSUM_TCP;
-				else if (ip->ip_p == IPPROTO_UDP)
-					m->m_pkthdr.csum_flags |= CSUM_UDP;
-			}
-		}
-
-		netif->ifp->if_ibytes += m->m_pkthdr.len;
-		netif->ifp->if_ipackets++;
-
-		DDPRINTF("RECV %d bytes from %s (cflags=%x)\n",
-			m->m_pkthdr.len, IFNAME(netif), m->m_pkthdr.csum_flags);
-		DPRINTF_MBUF_LEN(m, 128);
-
-		(*netif->ifp->if_input)(netif->ifp, m);
-
-		mop++;
-	}
-}
-
-/* Handle interrupt from a frontend */
-static void
-netback_intr(void *arg)
-{
-	netif_t *netif = arg;
-	DDPRINTF("%s\n", IFNAME(netif));
-	add_to_tx_schedule_list_tail(netif);
-	maybe_schedule_tx_action();
-}
-
-/* Removes netif from front of list and does not call netif_put() (caller must) */
-static netif_t *
-remove_from_rx_schedule_list(void)
-{
-	netif_t *netif;
-
-	mtx_lock(&rx_sched_list_lock);
-
-	if ((netif = STAILQ_FIRST(&rx_sched_list))) {
-		STAILQ_REMOVE(&rx_sched_list, netif, netback_info, next_rx);
-		STAILQ_NEXT(netif, next_rx) = NULL;
-		netif->on_rx_sched_list = 0;
-	}
-
-	mtx_unlock(&rx_sched_list_lock);
-
-	return netif;
-}
-
-/* Adds netif to end of list and calls netif_get() */
-static void
-add_to_rx_schedule_list_tail(netif_t *netif)
-{
-	if (netif->on_rx_sched_list)
-		return;
-
-	mtx_lock(&rx_sched_list_lock);
-	if (!netif->on_rx_sched_list && (netif->ifp->if_drv_flags & IFF_DRV_RUNNING)) {
-		netif_get(netif);
-		STAILQ_INSERT_TAIL(&rx_sched_list, netif, next_rx);
-		netif->on_rx_sched_list = 1;
-	}
-	mtx_unlock(&rx_sched_list_lock);
-}
-
-static int
-make_rx_response(netif_t *netif, uint16_t id, int8_t st,
-				 uint16_t offset, uint16_t size, uint16_t flags)
-{
-	RING_IDX i = netif->rx.rsp_prod_pvt;
-	netif_rx_response_t *resp;
-	int notify;
-
-	resp = RING_GET_RESPONSE(&netif->rx, i);
-	resp->offset     = offset;
-	resp->flags      = flags;
-	resp->id         = id;
-	resp->status     = (int16_t)size;
-	if (st < 0)
-		resp->status = (int16_t)st;
-
-	DDPRINTF("rx resp(%d): off=%x fl=%x id=%x stat=%d\n",
-		i, resp->offset, resp->flags, resp->id, resp->status);
-
-	netif->rx.rsp_prod_pvt = ++i;
-	RING_PUSH_RESPONSES_AND_CHECK_NOTIFY(&netif->rx, notify);
-
-	return notify;
-}
-
-static int
-netif_rx(netif_t *netif)
-{
-	struct ifnet *ifp = netif->ifp;
-	struct mbuf *m;
-	multicall_entry_t *mcl;
-	mmu_update_t *mmu;
-	gnttab_transfer_t *gop;
-	unsigned long vdata, old_mfn, new_mfn;
-	struct mbuf *rxq = NULL, *rxq_last = NULL;
-	int ret, notify = 0, pkts_dequeued = 0;
-
-	DDPRINTF("%s\n", IFNAME(netif));
-
-	mcl = rx_mcl;
-	mmu = rx_mmu;
-	gop = grant_rx_op;
-
-	while (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) {
-		
-		/* Quit if the target domain has no receive buffers */
-		if (netif->rx.req_cons == netif->rx.sring->req_prod)
-			break;
-
-		IFQ_DRV_DEQUEUE(&ifp->if_snd, m);
-		if (m == NULL)
-			break;
-
-		pkts_dequeued++;
-
-		/* Check if we need to copy the data */
-		if (((m->m_flags & (M_RDONLY|M_EXT)) != M_EXT) ||
-			(*m->m_ext.ref_cnt > 1) || m->m_next != NULL) {
-			struct mbuf *n;
-				
-			DDPRINTF("copying mbuf (fl=%x ext=%x rc=%d n=%x)\n",
-				m->m_flags,
-				(m->m_flags & M_EXT) ? m->m_ext.ext_type : 0,
-				(m->m_flags & M_EXT) ? *m->m_ext.ref_cnt : 0,
-				(unsigned int)m->m_next);
-
-			/* Make copy */
-			MGETHDR(n, M_DONTWAIT, MT_DATA);
-			if (!n)
-				goto drop;
-
-			MCLGET(n, M_DONTWAIT);
-			if (!(n->m_flags & M_EXT)) {
-				m_freem(n);
-				goto drop;
-			}
-
-			/* Leave space at front and keep current alignment */
-			n->m_data += 16 + ((unsigned int)m->m_data & 0x3);
-
-			if (m->m_pkthdr.len > M_TRAILINGSPACE(n)) {
-				WPRINTF("pkt to big %d\n", m->m_pkthdr.len);
-				m_freem(n);
-				goto drop;
-			}
-			m_copydata(m, 0, m->m_pkthdr.len, n->m_data);
-			n->m_pkthdr.len = n->m_len = m->m_pkthdr.len;
-			n->m_pkthdr.csum_flags = (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA);
-			m_freem(m);
-			m = n;
-		}
-
-		vdata = (unsigned long)m->m_data;
-		old_mfn = vtomach(vdata) >> PAGE_SHIFT;
-
-		if ((new_mfn = alloc_mfn()) == 0)
-			goto drop;
-
-#ifdef XEN_NETBACK_FIXUP_CSUM
-		/* Check if we need to compute a checksum.  This happens */
-		/* when bridging from one domain to another. */
-		if ((m->m_pkthdr.csum_flags & CSUM_DELAY_DATA) ||
-			(m->m_pkthdr.csum_flags & CSUM_SCTP))
-			fixup_checksum(m);
-#endif
-
-		xen_phys_machine[(vtophys(vdata) >> PAGE_SHIFT)] = new_mfn;
-
-		mcl->op = __HYPERVISOR_update_va_mapping;
-		mcl->args[0] = vdata;
-		mcl->args[1] = (new_mfn << PAGE_SHIFT) | PG_V | PG_RW | PG_M | PG_A;
-		mcl->args[2] = 0;
-		mcl->args[3] = 0;
-		mcl++;
-
-		gop->mfn = old_mfn;
-		gop->domid = netif->domid;
-		gop->ref = RING_GET_REQUEST(&netif->rx, netif->rx.req_cons)->gref;
-		netif->rx.req_cons++;
-		gop++;
-
-		mmu->ptr = (new_mfn << PAGE_SHIFT) | MMU_MACHPHYS_UPDATE;
-		mmu->val = vtophys(vdata) >> PAGE_SHIFT;  
-		mmu++;
-
-		if (rxq_last)
-			rxq_last->m_nextpkt = m;
-		else
-			rxq = m;
-		rxq_last = m;
-
-		DDPRINTF("XMIT %d bytes to %s\n", m->m_pkthdr.len, IFNAME(netif));
-		DPRINTF_MBUF_LEN(m, 128);
-
-		/* Filled the batch queue? */
-		if ((gop - grant_rx_op) == ARRAY_SIZE(grant_rx_op))
-			break;		
-
-		continue;
-	drop:
-		DDPRINTF("dropping pkt\n");
-		ifp->if_oerrors++;
-		m_freem(m);
-	}
-
-	if (mcl == rx_mcl)
-		return pkts_dequeued;
-
-	mcl->op = __HYPERVISOR_mmu_update;
-	mcl->args[0] = (unsigned long)rx_mmu;
-	mcl->args[1] = mmu - rx_mmu;
-	mcl->args[2] = 0;
-	mcl->args[3] = DOMID_SELF;
-	mcl++;
-
-	mcl[-2].args[MULTI_UVMFLAGS_INDEX] = UVMF_TLB_FLUSH|UVMF_ALL;
-	ret = HYPERVISOR_multicall(rx_mcl, mcl - rx_mcl);
-	BUG_ON(ret != 0);
-
-	ret = HYPERVISOR_grant_table_op(GNTTABOP_transfer, grant_rx_op, gop - grant_rx_op);
-	BUG_ON(ret != 0);
-
-	mcl = rx_mcl;
-	gop = grant_rx_op;
-
-	while ((m = rxq) != NULL) {
-		int8_t status;
-		uint16_t id, flags = 0;
-
-		rxq = m->m_nextpkt;
-		m->m_nextpkt = NULL;
-
-		/* Rederive the machine addresses. */
-		new_mfn = mcl->args[1] >> PAGE_SHIFT;
-		old_mfn = gop->mfn;
-
-		ifp->if_obytes += m->m_pkthdr.len;
-		ifp->if_opackets++;
-
-		/* The update_va_mapping() must not fail. */
-		BUG_ON(mcl->result != 0);
-
-		/* Setup flags */
-		if ((m->m_pkthdr.csum_flags & CSUM_DELAY_DATA))
-			flags |= NETRXF_csum_blank | NETRXF_data_validated;
-		else if ((m->m_pkthdr.csum_flags & CSUM_DATA_VALID))
-			flags |= NETRXF_data_validated;
-
-		/* Check the reassignment error code. */
-		status = NETIF_RSP_OKAY;
-		if (gop->status != 0) { 
-			DPRINTF("Bad status %d from grant transfer to DOM%u\n",
-				gop->status, netif->domid);
-			/*
-			 * Page no longer belongs to us unless GNTST_bad_page,
-			 * but that should be a fatal error anyway.
-			 */
-			BUG_ON(gop->status == GNTST_bad_page);
-			status = NETIF_RSP_ERROR; 
-		}
-		id = RING_GET_REQUEST(&netif->rx, netif->rx.rsp_prod_pvt)->id;
-		notify |= make_rx_response(netif, id, status,
-					(unsigned long)m->m_data & PAGE_MASK,
-					m->m_pkthdr.len, flags);
-
-		m_freem(m);
-		mcl++;
-		gop++;
-	}
-
-	if (notify)
-		notify_remote_via_irq(netif->irq);
-
-	return pkts_dequeued;
-}
-
-static void
-rx_task_timer(void *arg)
-{
-	DDPRINTF("\n");
-	taskqueue_enqueue(taskqueue_swi, &net_rx_task); 
-}
-
-static void
-net_rx_action(void *context, int pending)
-{
-	netif_t *netif, *last_zero_work = NULL;
-
-	DDPRINTF("\n");
-
-	while ((netif = remove_from_rx_schedule_list())) {
-		struct ifnet *ifp = netif->ifp;
-
-		if (netif == last_zero_work) {
-			if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
-				add_to_rx_schedule_list_tail(netif);
-			netif_put(netif);
-			if (!STAILQ_EMPTY(&rx_sched_list))
-				callout_reset(&rx_task_callout, 1, rx_task_timer, NULL);
-			break;
-		}
-
-		if ((ifp->if_drv_flags & IFF_DRV_RUNNING)) {
-			if (netif_rx(netif))
-				last_zero_work = NULL;
-			else if (!last_zero_work)
-				last_zero_work = netif;
-			if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
-				add_to_rx_schedule_list_tail(netif);
-		}
-
-		netif_put(netif);
-	}
-}
-
-static void
-netback_start(struct ifnet *ifp)
-{
-	netif_t *netif = (netif_t *)ifp->if_softc;
-
-	DDPRINTF("%s\n", IFNAME(netif));
-
-	add_to_rx_schedule_list_tail(netif);
-	taskqueue_enqueue(taskqueue_swi, &net_rx_task); 
-}
-
-/* Map a grant ref to a ring */
-static int
-map_ring(grant_ref_t ref, domid_t dom, struct ring_ref *ring)
-{
-	struct gnttab_map_grant_ref op;
-
-	ring->va = kmem_alloc_nofault(kernel_map, PAGE_SIZE);
-	if (ring->va == 0)
-		return ENOMEM;
-
-	op.host_addr = ring->va;
-	op.flags = GNTMAP_host_map;
-	op.ref = ref;
-	op.dom = dom;
-	HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
-	if (op.status) {
-		WPRINTF("grant table op err=%d\n", op.status);
-		kmem_free(kernel_map, ring->va, PAGE_SIZE);
-		ring->va = 0;
-		return EACCES;
-	}
-
-	ring->handle = op.handle;
-	ring->bus_addr = op.dev_bus_addr;
-
-	return 0;
-}
-
-/* Unmap grant ref for a ring */
-static void
-unmap_ring(struct ring_ref *ring)
-{
-	struct gnttab_unmap_grant_ref op;
-
-	op.host_addr = ring->va;
-	op.dev_bus_addr = ring->bus_addr;
-	op.handle = ring->handle;
-	HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
-	if (op.status)
-		WPRINTF("grant table op err=%d\n", op.status);
-
-	kmem_free(kernel_map, ring->va, PAGE_SIZE);
-	ring->va = 0;
-}
-
-static int
-connect_rings(netif_t *netif)
-{
-	struct xenbus_device *xdev = netif->xdev;
-	netif_tx_sring_t *txs;
-	netif_rx_sring_t *rxs;
-	unsigned long tx_ring_ref, rx_ring_ref;
-	evtchn_port_t evtchn;
-	evtchn_op_t op = { .cmd = EVTCHNOP_bind_interdomain };
-	int err;
-
-	// Grab FE data and map his memory
-	err = xenbus_gather(NULL, xdev->otherend,
-			"tx-ring-ref", "%lu", &tx_ring_ref,
-		    "rx-ring-ref", "%lu", &rx_ring_ref,
-		    "event-channel", "%u", &evtchn, NULL);
-	if (err) {
-		xenbus_dev_fatal(xdev, err,
-			"reading %s/ring-ref and event-channel",
-			xdev->otherend);
-		return err;
-	}
-
-	err = map_ring(tx_ring_ref, netif->domid, &netif->tx_ring_ref);
-	if (err) {
-		xenbus_dev_fatal(xdev, err, "mapping tx ring");
-		return err;
-	}
-	txs = (netif_tx_sring_t *)netif->tx_ring_ref.va;
-	BACK_RING_INIT(&netif->tx, txs, PAGE_SIZE);
-
-	err = map_ring(rx_ring_ref, netif->domid, &netif->rx_ring_ref);
-	if (err) {
-		unmap_ring(&netif->tx_ring_ref);
-		xenbus_dev_fatal(xdev, err, "mapping rx ring");
-		return err;
-	}
-	rxs = (netif_rx_sring_t *)netif->rx_ring_ref.va;
-	BACK_RING_INIT(&netif->rx, rxs, PAGE_SIZE);
-
-	op.u.bind_interdomain.remote_dom = netif->domid;
-	op.u.bind_interdomain.remote_port = evtchn;
-	err = HYPERVISOR_event_channel_op(&op);
-	if (err) {
-		unmap_ring(&netif->tx_ring_ref);
-		unmap_ring(&netif->rx_ring_ref);
-		xenbus_dev_fatal(xdev, err, "binding event channel");
-		return err;
-	}
-	netif->evtchn = op.u.bind_interdomain.local_port;
-
-	/* bind evtchn to irq handler */
-	netif->irq =
-		bind_evtchn_to_irqhandler(netif->evtchn, "netback",
-			netback_intr, netif, INTR_TYPE_NET|INTR_MPSAFE, &netif->irq_cookie);
-
-	netif->rings_connected = 1;
-
-	DPRINTF("%s connected! evtchn=%d irq=%d\n",
-		IFNAME(netif), netif->evtchn, netif->irq);
-
-	return 0;
-}
-
-static void
-disconnect_rings(netif_t *netif)
-{
-	DPRINTF("\n");
-
-	if (netif->rings_connected) {
-		unbind_from_irqhandler(netif->irq, netif->irq_cookie);
-		netif->irq = 0;
-		unmap_ring(&netif->tx_ring_ref);
-		unmap_ring(&netif->rx_ring_ref);
-		netif->rings_connected = 0;
-	}
-}
-
-static void
-connect(netif_t *netif)
-{
-	if (!netif->xdev ||
-		!netif->attached ||
-		netif->frontend_state != XenbusStateConnected) {
-		return;
-	}
-
-	if (!connect_rings(netif)) {
-		xenbus_switch_state(netif->xdev, NULL, XenbusStateConnected);
-
-		/* Turn on interface */
-		netif->ifp->if_drv_flags |= IFF_DRV_RUNNING;
-		netif->ifp->if_flags |= IFF_UP;
-	}
-}
-
-static int
-netback_remove(struct xenbus_device *xdev)
-{
-	netif_t *netif = xdev->data;
-	device_t ndev;
-
-	DPRINTF("remove %s\n", xdev->nodename);
-
-	if ((ndev = netif->ndev)) {
-		netif->ndev = NULL;
-		mtx_lock(&Giant);
-		device_detach(ndev);
-		mtx_unlock(&Giant);
-	}
-
-	xdev->data = NULL;
-	netif->xdev = NULL;
-	netif_put(netif);
-
-	return 0;
+	return (0);
 }
 
 /**
- * Entry point to this code when a new device is created.  Allocate the basic
- * structures and the ring buffers for communication with the frontend.
- * Switch to Connected state.
+ * Callback used by the generic networking code to ask us what our carrier
+ * state is.  Since we don't have a physical carrier, this is very simple
  */
-static int
-netback_probe(struct xenbus_device *xdev, const struct xenbus_device_id *id)
+static void
+xnb_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr)
 {
-	int err;
-	long handle;
-	char *bridge;
-	
-	DPRINTF("node=%s\n", xdev->nodename);
-
-	/* Grab the handle */
-	err = xenbus_scanf(NULL, xdev->nodename, "handle", "%li", &handle);
-	if (err != 1) {
-		xenbus_dev_fatal(xdev, err, "reading handle");
-		return err;
-	}
-
-	/* Check for bridge */
-	bridge = xenbus_read(NULL, xdev->nodename, "bridge", NULL);
-	if (IS_ERR(bridge))
-		bridge = NULL;
-
-	err = xenbus_switch_state(xdev, NULL, XenbusStateInitWait);
-	if (err) {
-		xenbus_dev_fatal(xdev, err, "writing switch state");
-		return err;
-	}
-
-	err = netif_create(handle, xdev, bridge);
-	if (err) {
-		xenbus_dev_fatal(xdev, err, "creating netif");
-		return err;
-	}
-
-	err = vif_add_dev(xdev);
-	if (err) {
-		netif_put((netif_t *)xdev->data);
-		xenbus_dev_fatal(xdev, err, "adding vif device");
-		return err;
-	}
-
-	return 0;
+	ifmr->ifm_status = IFM_AVALID|IFM_ACTIVE;
+	ifmr->ifm_active = IFM_ETHER|IFM_MANUAL;
 }
 
-/**
- * We are reconnecting to the backend, due to a suspend/resume, or a backend
- * driver restart.  We tear down our netif structure and recreate it, but
- * leave the device-layer structures intact so that this is transparent to the
- * rest of the kernel.
- */
-static int netback_resume(struct xenbus_device *xdev)
-{
-	DPRINTF("node=%s\n", xdev->nodename);
-	return 0;
-}
 
+/*---------------------------- NewBus Registration ---------------------------*/
+static device_method_t xnb_methods[] = {
+	/* Device interface */
+	DEVMETHOD(device_probe,		xnb_probe),
+	DEVMETHOD(device_attach,	xnb_attach),
+	DEVMETHOD(device_detach,	xnb_detach),
+	DEVMETHOD(device_shutdown,	bus_generic_shutdown),
+	DEVMETHOD(device_suspend,	xnb_suspend),
+	DEVMETHOD(device_resume,	xnb_resume),
 
-/**
- * Callback received when the frontend's state changes.
- */
-static void frontend_changed(struct xenbus_device *xdev,
-							 XenbusState frontend_state)
-{
-	netif_t *netif = xdev->data;
+	/* Xenbus interface */
+	DEVMETHOD(xenbus_otherend_changed, xnb_frontend_changed),
 
-	DPRINTF("state=%d\n", frontend_state);
-	
-	netif->frontend_state = frontend_state;
-
-	switch (frontend_state) {
-	case XenbusStateInitialising:
-	case XenbusStateInitialised:
-		break;
-	case XenbusStateConnected:
-		connect(netif);
-		break;
-	case XenbusStateClosing:
-		xenbus_switch_state(xdev, NULL, XenbusStateClosing);
-		break;
-	case XenbusStateClosed:
-		xenbus_remove_device(xdev);
-		break;
-	case XenbusStateUnknown:
-	case XenbusStateInitWait:
-		xenbus_dev_fatal(xdev, EINVAL, "saw state %d at frontend",
-						 frontend_state);
-		break;
-	}
-}
-
-/* ** Driver registration ** */
-
-static struct xenbus_device_id netback_ids[] = {
-	{ "vif" },
-	{ "" }
+	{ 0, 0 }
 };
 
-static struct xenbus_driver netback = {
-	.name = "netback",
-	.ids = netback_ids,
-	.probe = netback_probe,
-	.remove = netback_remove,
-	.resume= netback_resume,
-	.otherend_changed = frontend_changed,
+static driver_t xnb_driver = {
+	"xnb",
+	xnb_methods,
+	sizeof(struct xnb_softc),
 };
+devclass_t xnb_devclass;
 
-static void
-netback_init(void *unused)
-{
-	callout_init(&rx_task_callout, CALLOUT_MPSAFE);
+DRIVER_MODULE(xnb, xenbusb_back, xnb_driver, xnb_devclass, 0, 0);
 
-	mmap_vstart = alloc_empty_page_range(MAX_PENDING_REQS);
-	BUG_ON(!mmap_vstart);
 
-	pending_cons = 0;
-	for (pending_prod = 0; pending_prod < MAX_PENDING_REQS; pending_prod++)
-		pending_ring[pending_prod] = pending_prod;
-
-	TASK_INIT(&net_tx_task, 0, net_tx_action, NULL);
-	TASK_INIT(&net_rx_task, 0, net_rx_action, NULL);
-	mtx_init(&tx_sched_list_lock, "nb_tx_sched_lock", "netback tx sched lock", MTX_DEF);
-	mtx_init(&rx_sched_list_lock, "nb_rx_sched_lock", "netback rx sched lock", MTX_DEF);
-
-	DPRINTF("registering %s\n", netback.name);
-
-	xenbus_register_backend(&netback);
-}
-
-SYSINIT(xnbedev, SI_SUB_PSEUDO, SI_ORDER_ANY, netback_init, NULL)
-
-static int
-vif_add_dev(struct xenbus_device *xdev)
-{
-	netif_t *netif = xdev->data;
-	device_t nexus, ndev;
-	devclass_t dc;
-	int err = 0;
-
-	mtx_lock(&Giant);
-
-	/* We will add a vif device as a child of nexus0 (for now) */
-	if (!(dc = devclass_find("nexus")) ||
-		!(nexus = devclass_get_device(dc, 0))) {
-		WPRINTF("could not find nexus0!\n");
-		err = ENOENT;
-		goto done;
-	}
-
-
-	/* Create a newbus device representing the vif */
-	ndev = BUS_ADD_CHILD(nexus, 0, "vif", netif->ifp->if_dunit);
-	if (!ndev) {
-		WPRINTF("could not create newbus device %s!\n", IFNAME(netif));
-		err = EFAULT;
-		goto done;
-	}
-	
-	netif_get(netif);
-	device_set_ivars(ndev, netif);
-	netif->ndev = ndev;
-
-	device_probe_and_attach(ndev);
-
- done:
-
-	mtx_unlock(&Giant);
-
-	return err;
-}
-
-enum {
-	VIF_SYSCTL_DOMID,
-	VIF_SYSCTL_HANDLE,
-	VIF_SYSCTL_TXRING,
-	VIF_SYSCTL_RXRING,
-};
-
-static char *
-vif_sysctl_ring_info(netif_t *netif, int cmd)
-{
-	char *buf = malloc(256, M_DEVBUF, M_WAITOK);
-	if (buf) {
-		if (!netif->rings_connected)
-			sprintf(buf, "rings not connected\n");
-		else if (cmd == VIF_SYSCTL_TXRING) {
-			netif_tx_back_ring_t *tx = &netif->tx;
-			sprintf(buf, "nr_ents=%x req_cons=%x"
-					" req_prod=%x req_event=%x"
-					" rsp_prod=%x rsp_event=%x",
-					tx->nr_ents, tx->req_cons,
-					tx->sring->req_prod, tx->sring->req_event,
-					tx->sring->rsp_prod, tx->sring->rsp_event);
-		} else {
-			netif_rx_back_ring_t *rx = &netif->rx;
-			sprintf(buf, "nr_ents=%x req_cons=%x"
-					" req_prod=%x req_event=%x"
-					" rsp_prod=%x rsp_event=%x",
-					rx->nr_ents, rx->req_cons,
-					rx->sring->req_prod, rx->sring->req_event,
-					rx->sring->rsp_prod, rx->sring->rsp_event);
-		}
-	}
-	return buf;
-}
-
-static int
-vif_sysctl_handler(SYSCTL_HANDLER_ARGS)
-{
-	device_t dev = (device_t)arg1;
-	netif_t *netif = (netif_t *)device_get_ivars(dev);
-	const char *value;
-	char *buf = NULL;
-	int err;
-
-	switch (arg2) {
-	case VIF_SYSCTL_DOMID:
-		return sysctl_handle_int(oidp, NULL, netif->domid, req);
-	case VIF_SYSCTL_HANDLE:
-		return sysctl_handle_int(oidp, NULL, netif->handle, req);
-	case VIF_SYSCTL_TXRING:
-	case VIF_SYSCTL_RXRING:
-		value = buf = vif_sysctl_ring_info(netif, arg2);
-		break;
-	default:
-		return (EINVAL);
-	}
-
-	err = SYSCTL_OUT(req, value, strlen(value));
-	if (buf != NULL)
-		free(buf, M_DEVBUF);
-
-	return err;
-}
-
-/* Newbus vif device driver probe */
-static int
-vif_probe(device_t dev)
-{
-	DDPRINTF("vif%d\n", device_get_unit(dev));
-	return 0;
-}
-
-/* Newbus vif device driver attach */
-static int
-vif_attach(device_t dev) 
-{
-	netif_t *netif = (netif_t *)device_get_ivars(dev);
-	uint8_t mac[ETHER_ADDR_LEN];
-
-	DDPRINTF("%s\n", IFNAME(netif));
-
-	SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
-	    OID_AUTO, "domid", CTLTYPE_INT|CTLFLAG_RD,
-	    dev, VIF_SYSCTL_DOMID, vif_sysctl_handler, "I",
-	    "domid of frontend");
-	SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
-	    OID_AUTO, "handle", CTLTYPE_INT|CTLFLAG_RD,
-	    dev, VIF_SYSCTL_HANDLE, vif_sysctl_handler, "I",
-	    "handle of frontend");
-#ifdef XEN_NETBACK_DEBUG
-	SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
-	    OID_AUTO, "txring", CTLTYPE_STRING | CTLFLAG_RD,
-	    dev, VIF_SYSCTL_TXRING, vif_sysctl_handler, "A",
-	    "tx ring info");
-	SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
-	    OID_AUTO, "rxring", CTLTYPE_STRING | CTLFLAG_RD,
-	    dev, VIF_SYSCTL_RXRING, vif_sysctl_handler, "A",
-	    "rx ring info");
+/*-------------------------- Unit Tests -------------------------------------*/
+#ifdef XNB_DEBUG
+#include "netback_unit_tests.c"
 #endif
-
-	memset(mac, 0xff, sizeof(mac));
-	mac[0] &= ~0x01;
-	
-	ether_ifattach(netif->ifp, mac);
-	netif->attached = 1;
-
-	connect(netif);
-
-	if (netif->bridge) {
-		DPRINTF("Adding %s to bridge %s\n", IFNAME(netif), netif->bridge);
-		int err = add_to_bridge(netif->ifp, netif->bridge);
-		if (err) {
-			WPRINTF("Error adding %s to %s; err=%d\n",
-				IFNAME(netif), netif->bridge, err);
-		}
-	}
-
-	return bus_generic_attach(dev);
-}
-
-/* Newbus vif device driver detach */
-static int
-vif_detach(device_t dev)
-{
-	netif_t *netif = (netif_t *)device_get_ivars(dev);
-	struct ifnet *ifp = netif->ifp;
-
-	DDPRINTF("%s\n", IFNAME(netif));
-
-	/* Tell the stack that the interface is no longer active */
-	ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
-
-	ether_ifdetach(ifp);
-
-	bus_generic_detach(dev);
-
-	netif->attached = 0;
-
-	netif_put(netif);
-
-	return 0;
-}
-
-static device_method_t vif_methods[] = {
-	/* Device interface */
-	DEVMETHOD(device_probe,		vif_probe),
-	DEVMETHOD(device_attach, 	vif_attach),
-	DEVMETHOD(device_detach,	vif_detach),
-	DEVMETHOD(device_shutdown,	bus_generic_shutdown),
-	DEVMETHOD(device_suspend,	bus_generic_suspend),
-	DEVMETHOD(device_resume,	bus_generic_resume),
-	{0, 0}
-};
-
-static devclass_t vif_devclass;
-
-static driver_t vif_driver = {
-	"vif",
-	vif_methods,
-	0,
-};
-
-DRIVER_MODULE(vif, nexus, vif_driver, vif_devclass, 0, 0);
-
-
-/*
- * Local variables:
- * mode: C
- * c-set-style: "BSD"
- * c-basic-offset: 4
- * tab-width: 4
- * indent-tabs-mode: t
- * End:
- */
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/dev/xen/netback/netback_unit_tests.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/dev/xen/netback/netback_unit_tests.c	Wed Feb 01 12:34:54 2012 +0200
@@ -0,0 +1,2530 @@
+/*-
+ * Copyright (c) 2009-2011 Spectra Logic Corporation
+ * 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,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES.
+ *
+ * Authors: Justin T. Gibbs     (Spectra Logic Corporation)
+ *          Alan Somers         (Spectra Logic Corporation)
+ *          John Suykerbuyk     (Spectra Logic Corporation)
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: head/sys/dev/xen/netback/netback_unit_tests.c 230587 2012-01-26 16:35:09Z ken $");
+
+/**
+ * \file netback_unit_tests.c
+ *
+ * \brief Unit tests for the Xen netback driver.
+ *
+ * Due to the driver's use of static functions, these tests cannot be compiled
+ * standalone; they must be #include'd from the driver's .c file.
+ */
+
+
+/** Helper macro used to snprintf to a buffer and update the buffer pointer */
+#define	SNCATF(buffer, buflen, ...) do {				\
+	size_t new_chars = snprintf(buffer, buflen, __VA_ARGS__);	\
+	buffer += new_chars;						\
+	/* be careful; snprintf's return value can be  > buflen */	\
+	buflen -= MIN(buflen, new_chars);				\
+} while (0)
+
+/* STRINGIFY and TOSTRING are used only to help turn __LINE__ into a string */
+#define	STRINGIFY(x) #x
+#define	TOSTRING(x) STRINGIFY(x)
+
+/**
+ * Writes an error message to buffer if cond is false, and returns true
+ * iff the assertion failed.  Note the implied parameters buffer and
+ * buflen
+ */
+#define	XNB_ASSERT(cond) ({						\
+	int passed = (cond);						\
+	char *_buffer = (buffer);					\
+	size_t _buflen = (buflen);					\
+	if (! passed) {							\
+		strlcat(_buffer, __func__, _buflen);			\
+		strlcat(_buffer, ":" TOSTRING(__LINE__) 		\
+		  " Assertion Error: " #cond "\n", _buflen);		\
+	}								\
+ ! passed; })
+
+
+/**
+ * The signature used by all testcases.  If the test writes anything
+ * to buffer, then it will be considered a failure
+ * \param buffer	Return storage for error messages
+ * \param buflen	The space available in the buffer
+ */
+typedef void testcase_t(char *buffer, size_t buflen);
+
+/**
+ * Signature used by setup functions
+ * \return nonzero on error
+ */
+typedef int setup_t(void);
+
+typedef void teardown_t(void);
+
+/** A simple test fixture comprising setup, teardown, and test */
+struct test_fixture {
+	/** Will be run before the test to allocate and initialize variables */
+	setup_t *setup;
+
+	/** Will be run if setup succeeds */
+	testcase_t *test;
+
+	/** Cleans up test data whether or not the setup suceeded*/
+	teardown_t *teardown;
+};
+
+typedef struct test_fixture test_fixture_t;
+
+static void	xnb_fill_eh_and_ip(struct mbuf *m, uint16_t ip_len,
+				   uint16_t ip_id, uint16_t ip_p,
+				   uint16_t ip_off, uint16_t ip_sum);
+static void	xnb_fill_tcp(struct mbuf *m);
+static int	xnb_get1pkt(struct xnb_pkt *pkt, size_t size, uint16_t flags);
+static int	xnb_unit_test_runner(test_fixture_t const tests[], int ntests,
+				     char *buffer, size_t buflen);
+
+static int __unused
+null_setup(void) { return 0; }
+
+static void __unused
+null_teardown(void) { }
+
+static setup_t setup_pvt_data;
+static teardown_t teardown_pvt_data;
+static testcase_t xnb_ring2pkt_emptyring;
+static testcase_t xnb_ring2pkt_1req;
+static testcase_t xnb_ring2pkt_2req;
+static testcase_t xnb_ring2pkt_3req;
+static testcase_t xnb_ring2pkt_extra;
+static testcase_t xnb_ring2pkt_partial;
+static testcase_t xnb_ring2pkt_wraps;
+static testcase_t xnb_txpkt2rsp_emptypkt;
+static testcase_t xnb_txpkt2rsp_1req;
+static testcase_t xnb_txpkt2rsp_extra;
+static testcase_t xnb_txpkt2rsp_long;
+static testcase_t xnb_txpkt2rsp_invalid;
+static testcase_t xnb_txpkt2rsp_error;
+static testcase_t xnb_txpkt2rsp_wraps;
+static testcase_t xnb_pkt2mbufc_empty;
+static testcase_t xnb_pkt2mbufc_short;
+static testcase_t xnb_pkt2mbufc_csum;
+static testcase_t xnb_pkt2mbufc_1cluster;
+static testcase_t xnb_pkt2mbufc_largecluster;
+static testcase_t xnb_pkt2mbufc_2cluster;
+static testcase_t xnb_txpkt2gnttab_empty;
+static testcase_t xnb_txpkt2gnttab_short;
+static testcase_t xnb_txpkt2gnttab_2req;
+static testcase_t xnb_txpkt2gnttab_2cluster;
+static testcase_t xnb_update_mbufc_short;
+static testcase_t xnb_update_mbufc_2req;
+static testcase_t xnb_update_mbufc_2cluster;
+static testcase_t xnb_mbufc2pkt_empty;
+static testcase_t xnb_mbufc2pkt_short;
+static testcase_t xnb_mbufc2pkt_1cluster;
+static testcase_t xnb_mbufc2pkt_2short;
+static testcase_t xnb_mbufc2pkt_long;
+static testcase_t xnb_mbufc2pkt_extra;
+static testcase_t xnb_mbufc2pkt_nospace;
+static testcase_t xnb_rxpkt2gnttab_empty;
+static testcase_t xnb_rxpkt2gnttab_short;
+static testcase_t xnb_rxpkt2gnttab_2req;
+static testcase_t xnb_rxpkt2rsp_empty;
+static testcase_t xnb_rxpkt2rsp_short;
+static testcase_t xnb_rxpkt2rsp_extra;
+static testcase_t xnb_rxpkt2rsp_2short;
+static testcase_t xnb_rxpkt2rsp_2slots;
+static testcase_t xnb_rxpkt2rsp_copyerror;
+/* TODO: add test cases for xnb_add_mbuf_cksum for IPV6 tcp and udp */
+static testcase_t xnb_add_mbuf_cksum_arp;
+static testcase_t xnb_add_mbuf_cksum_tcp;
+static testcase_t xnb_add_mbuf_cksum_udp;
+static testcase_t xnb_add_mbuf_cksum_icmp;
+static testcase_t xnb_add_mbuf_cksum_tcp_swcksum;
+static testcase_t xnb_sscanf_llu;
+static testcase_t xnb_sscanf_lld;
+static testcase_t xnb_sscanf_hhu;
+static testcase_t xnb_sscanf_hhd;
+static testcase_t xnb_sscanf_hhn;
+
+/** Private data used by unit tests */
+static struct {
+	gnttab_copy_table 	gnttab;
+	netif_rx_back_ring_t	rxb;
+	netif_rx_front_ring_t	rxf;
+	netif_tx_back_ring_t	txb;
+	netif_tx_front_ring_t	txf;
+	struct ifnet*		ifp;
+	netif_rx_sring_t*	rxs;
+	netif_tx_sring_t*	txs;
+} xnb_unit_pvt;
+
+static inline void safe_m_freem(struct mbuf **ppMbuf) {
+	if (*ppMbuf != NULL) {
+		m_freem(*ppMbuf);
+		*ppMbuf = NULL;
+	}
+}
+
+/**
+ * The unit test runner.  It will run every supplied test and return an
+ * output message as a string
+ * \param tests		An array of tests.  Every test will be attempted.
+ * \param ntests	The length of tests
+ * \param buffer	Return storage for the result string
+ * \param buflen	The length of buffer
+ * \return		The number of tests that failed
+ */
+static int
+xnb_unit_test_runner(test_fixture_t const tests[], int ntests, char *buffer,
+    		     size_t buflen)
+{
+	int i;
+	int n_passes;
+	int n_failures = 0;
+
+	for (i = 0; i < ntests; i++) {
+		int error = tests[i].setup();
+		if (error != 0) {
+			SNCATF(buffer, buflen,
+			    "Setup failed for test idx %d\n", i);
+			n_failures++;
+		} else {
+			size_t new_chars;
+
+			tests[i].test(buffer, buflen);
+			new_chars = strnlen(buffer, buflen);
+			buffer += new_chars;
+			buflen -= new_chars;
+
+			if (new_chars > 0) {
+				n_failures++;
+			}
+		}
+		tests[i].teardown();
+	}
+
+	n_passes = ntests - n_failures;
+	if (n_passes > 0) {
+		SNCATF(buffer, buflen, "%d Tests Passed\n", n_passes);
+	}
+	if (n_failures > 0) {
+		SNCATF(buffer, buflen, "%d Tests FAILED\n", n_failures);
+	}
+
+	return n_failures;
+}
+
+/** Number of unit tests.  Must match the length of the tests array below */
+#define	TOTAL_TESTS	(53)
+/**
+ * Max memory available for returning results.  400 chars/test should give
+ * enough space for a five line error message for every test
+ */
+#define	TOTAL_BUFLEN	(400 * TOTAL_TESTS + 2)
+
+/**
+ * Called from userspace by a sysctl.  Runs all internal unit tests, and
+ * returns the results to userspace as a string
+ * \param oidp	unused
+ * \param arg1	pointer to an xnb_softc for a specific xnb device
+ * \param arg2	unused
+ * \param req	sysctl access structure
+ * \return a string via the special SYSCTL_OUT macro.
+ */
+
+static int
+xnb_unit_test_main(SYSCTL_HANDLER_ARGS) {
+	test_fixture_t const tests[TOTAL_TESTS] = {
+		{setup_pvt_data, xnb_ring2pkt_emptyring, teardown_pvt_data},
+		{setup_pvt_data, xnb_ring2pkt_1req, teardown_pvt_data},
+		{setup_pvt_data, xnb_ring2pkt_2req, teardown_pvt_data},
+		{setup_pvt_data, xnb_ring2pkt_3req, teardown_pvt_data},
+		{setup_pvt_data, xnb_ring2pkt_extra, teardown_pvt_data},
+		{setup_pvt_data, xnb_ring2pkt_partial, teardown_pvt_data},
+		{setup_pvt_data, xnb_ring2pkt_wraps, teardown_pvt_data},
+		{setup_pvt_data, xnb_txpkt2rsp_emptypkt, teardown_pvt_data},
+		{setup_pvt_data, xnb_txpkt2rsp_1req, teardown_pvt_data},
+		{setup_pvt_data, xnb_txpkt2rsp_extra, teardown_pvt_data},
+		{setup_pvt_data, xnb_txpkt2rsp_long, teardown_pvt_data},
+		{setup_pvt_data, xnb_txpkt2rsp_invalid, teardown_pvt_data},
+		{setup_pvt_data, xnb_txpkt2rsp_error, teardown_pvt_data},
+		{setup_pvt_data, xnb_txpkt2rsp_wraps, teardown_pvt_data},
+		{setup_pvt_data, xnb_pkt2mbufc_empty, teardown_pvt_data},
+		{setup_pvt_data, xnb_pkt2mbufc_short, teardown_pvt_data},
+		{setup_pvt_data, xnb_pkt2mbufc_csum, teardown_pvt_data},
+		{setup_pvt_data, xnb_pkt2mbufc_1cluster, teardown_pvt_data},
+		{setup_pvt_data, xnb_pkt2mbufc_largecluster, teardown_pvt_data},
+		{setup_pvt_data, xnb_pkt2mbufc_2cluster, teardown_pvt_data},
+		{setup_pvt_data, xnb_txpkt2gnttab_empty, teardown_pvt_data},
+		{setup_pvt_data, xnb_txpkt2gnttab_short, teardown_pvt_data},
+		{setup_pvt_data, xnb_txpkt2gnttab_2req, teardown_pvt_data},
+		{setup_pvt_data, xnb_txpkt2gnttab_2cluster, teardown_pvt_data},
+		{setup_pvt_data, xnb_update_mbufc_short, teardown_pvt_data},
+		{setup_pvt_data, xnb_update_mbufc_2req, teardown_pvt_data},
+		{setup_pvt_data, xnb_update_mbufc_2cluster, teardown_pvt_data},
+		{setup_pvt_data, xnb_mbufc2pkt_empty, teardown_pvt_data},
+		{setup_pvt_data, xnb_mbufc2pkt_short, teardown_pvt_data},
+		{setup_pvt_data, xnb_mbufc2pkt_1cluster, teardown_pvt_data},
+		{setup_pvt_data, xnb_mbufc2pkt_2short, teardown_pvt_data},
+		{setup_pvt_data, xnb_mbufc2pkt_long, teardown_pvt_data},
+		{setup_pvt_data, xnb_mbufc2pkt_extra, teardown_pvt_data},
+		{setup_pvt_data, xnb_mbufc2pkt_nospace, teardown_pvt_data},
+		{setup_pvt_data, xnb_rxpkt2gnttab_empty, teardown_pvt_data},
+		{setup_pvt_data, xnb_rxpkt2gnttab_short, teardown_pvt_data},
+		{setup_pvt_data, xnb_rxpkt2gnttab_2req, teardown_pvt_data},
+		{setup_pvt_data, xnb_rxpkt2rsp_empty, teardown_pvt_data},
+		{setup_pvt_data, xnb_rxpkt2rsp_short, teardown_pvt_data},
+		{setup_pvt_data, xnb_rxpkt2rsp_extra, teardown_pvt_data},
+		{setup_pvt_data, xnb_rxpkt2rsp_2short, teardown_pvt_data},
+		{setup_pvt_data, xnb_rxpkt2rsp_2slots, teardown_pvt_data},
+		{setup_pvt_data, xnb_rxpkt2rsp_copyerror, teardown_pvt_data},
+		{null_setup, xnb_add_mbuf_cksum_arp, null_teardown},
+		{null_setup, xnb_add_mbuf_cksum_icmp, null_teardown},
+		{null_setup, xnb_add_mbuf_cksum_tcp, null_teardown},
+		{null_setup, xnb_add_mbuf_cksum_tcp_swcksum, null_teardown},
+		{null_setup, xnb_add_mbuf_cksum_udp, null_teardown},
+		{null_setup, xnb_sscanf_hhd, null_teardown},
+		{null_setup, xnb_sscanf_hhu, null_teardown},
+		{null_setup, xnb_sscanf_lld, null_teardown},
+		{null_setup, xnb_sscanf_llu, null_teardown},
+		{null_setup, xnb_sscanf_hhn, null_teardown},
+	};
+	/**
+	 * results is static so that the data will persist after this function
+	 * returns.  The sysctl code expects us to return a constant string.
+	 * \todo: the static variable is not thread safe.  Put a mutex around
+	 * it.
+	 */
+	static char results[TOTAL_BUFLEN];
+
+	/* empty the result strings */
+	results[0] = 0;
+	xnb_unit_test_runner(tests, TOTAL_TESTS, results, TOTAL_BUFLEN);
+
+	return (SYSCTL_OUT(req, results, strnlen(results, TOTAL_BUFLEN)));
+}
+
+static int
+setup_pvt_data(void)
+{
+	int error = 0;
+
+	bzero(xnb_unit_pvt.gnttab, sizeof(xnb_unit_pvt.gnttab));
+
+	xnb_unit_pvt.txs = malloc(PAGE_SIZE, M_XENNETBACK, M_WAITOK|M_ZERO);
+	if (xnb_unit_pvt.txs != NULL) {
+		SHARED_RING_INIT(xnb_unit_pvt.txs);
+		BACK_RING_INIT(&xnb_unit_pvt.txb, xnb_unit_pvt.txs, PAGE_SIZE);
+		FRONT_RING_INIT(&xnb_unit_pvt.txf, xnb_unit_pvt.txs, PAGE_SIZE);
+	} else {
+		error = 1;
+	}
+
+	xnb_unit_pvt.ifp = if_alloc(IFT_ETHER);
+	if (xnb_unit_pvt.ifp == NULL) {
+		error = 1;
+	}
+
+	xnb_unit_pvt.rxs = malloc(PAGE_SIZE, M_XENNETBACK, M_WAITOK|M_ZERO);
+	if (xnb_unit_pvt.rxs != NULL) {
+		SHARED_RING_INIT(xnb_unit_pvt.rxs);
+		BACK_RING_INIT(&xnb_unit_pvt.rxb, xnb_unit_pvt.rxs, PAGE_SIZE);
+		FRONT_RING_INIT(&xnb_unit_pvt.rxf, xnb_unit_pvt.rxs, PAGE_SIZE);
+	} else {
+		error = 1;
+	}
+
+	return error;
+}
+
+static void
+teardown_pvt_data(void)
+{
+	if (xnb_unit_pvt.txs != NULL) {
+		free(xnb_unit_pvt.txs, M_XENNETBACK);
+	}
+	if (xnb_unit_pvt.rxs != NULL) {
+		free(xnb_unit_pvt.rxs, M_XENNETBACK);
+	}
+	if (xnb_unit_pvt.ifp != NULL) {
+		if_free(xnb_unit_pvt.ifp);
+	}
+}
+
+/**
+ * Verify that xnb_ring2pkt will not consume any requests from an empty ring
+ */
+static void
+xnb_ring2pkt_emptyring(char *buffer, size_t buflen)
+{
+	struct xnb_pkt pkt;
+	int num_consumed;
+
+	num_consumed = xnb_ring2pkt(&pkt, &xnb_unit_pvt.txb,
+	                            xnb_unit_pvt.txb.req_cons);
+	XNB_ASSERT(num_consumed == 0);
+}
+
+/**
+ * Verify that xnb_ring2pkt can convert a single request packet correctly
+ */
+static void
+xnb_ring2pkt_1req(char *buffer, size_t buflen)
+{
+	struct xnb_pkt pkt;
+	int num_consumed;
+	struct netif_tx_request *req;
+
+	req = RING_GET_REQUEST(&xnb_unit_pvt.txf,
+	    xnb_unit_pvt.txf.req_prod_pvt);
+
+	req->flags = 0;
+	req->size = 69;	/* arbitrary number for test */
+	xnb_unit_pvt.txf.req_prod_pvt++;
+
+	RING_PUSH_REQUESTS(&xnb_unit_pvt.txf);
+
+	num_consumed = xnb_ring2pkt(&pkt, &xnb_unit_pvt.txb,
+	                            xnb_unit_pvt.txb.req_cons);
+	XNB_ASSERT(num_consumed == 1);
+	XNB_ASSERT(pkt.size == 69);
+	XNB_ASSERT(pkt.car_size == 69);
+	XNB_ASSERT(pkt.flags == 0);
+	XNB_ASSERT(xnb_pkt_is_valid(&pkt));
+	XNB_ASSERT(pkt.list_len == 1);
+	XNB_ASSERT(pkt.car == 0);
+}
+
+/**
+ * Verify that xnb_ring2pkt can convert a two request packet correctly.
+ * This tests handling of the MORE_DATA flag and cdr
+ */
+static void
+xnb_ring2pkt_2req(char *buffer, size_t buflen)
+{
+	struct xnb_pkt pkt;
+	int num_consumed;
+	struct netif_tx_request *req;
+	RING_IDX start_idx = xnb_unit_pvt.txf.req_prod_pvt;
+
+	req = RING_GET_REQUEST(&xnb_unit_pvt.txf,
+	    xnb_unit_pvt.txf.req_prod_pvt);
+	req->flags = NETTXF_more_data;
+	req->size = 100;
+	xnb_unit_pvt.txf.req_prod_pvt++;
+
+	req = RING_GET_REQUEST(&xnb_unit_pvt.txf,
+	    xnb_unit_pvt.txf.req_prod_pvt);
+	req->flags = 0;
+	req->size = 40;
+	xnb_unit_pvt.txf.req_prod_pvt++;
+
+	RING_PUSH_REQUESTS(&xnb_unit_pvt.txf);
+
+	num_consumed = xnb_ring2pkt(&pkt, &xnb_unit_pvt.txb,
+	                            xnb_unit_pvt.txb.req_cons);
+	XNB_ASSERT(num_consumed == 2);
+	XNB_ASSERT(pkt.size == 100);
+	XNB_ASSERT(pkt.car_size == 60);
+	XNB_ASSERT(pkt.flags == 0);
+	XNB_ASSERT(xnb_pkt_is_valid(&pkt));
+	XNB_ASSERT(pkt.list_len == 2);
+	XNB_ASSERT(pkt.car == start_idx);
+	XNB_ASSERT(pkt.cdr == start_idx + 1);
+}
+
+/**
+ * Verify that xnb_ring2pkt can convert a three request packet correctly
+ */
+static void
+xnb_ring2pkt_3req(char *buffer, size_t buflen)
+{
+	struct xnb_pkt pkt;
+	int num_consumed;
+	struct netif_tx_request *req;
+	RING_IDX start_idx = xnb_unit_pvt.txf.req_prod_pvt;
+
+	req = RING_GET_REQUEST(&xnb_unit_pvt.txf,
+	    xnb_unit_pvt.txf.req_prod_pvt);
+	req->flags = NETTXF_more_data;
+	req->size = 200;
+	xnb_unit_pvt.txf.req_prod_pvt++;
+
+	req = RING_GET_REQUEST(&xnb_unit_pvt.txf,
+	    xnb_unit_pvt.txf.req_prod_pvt);
+	req->flags = NETTXF_more_data;
+	req->size = 40;
+	xnb_unit_pvt.txf.req_prod_pvt++;
+
+	req = RING_GET_REQUEST(&xnb_unit_pvt.txf,
+	    xnb_unit_pvt.txf.req_prod_pvt);
+	req->flags = 0;
+	req->size = 50;
+	xnb_unit_pvt.txf.req_prod_pvt++;
+
+	RING_PUSH_REQUESTS(&xnb_unit_pvt.txf);
+
+	num_consumed = xnb_ring2pkt(&pkt, &xnb_unit_pvt.txb,
+	                            xnb_unit_pvt.txb.req_cons);
+	XNB_ASSERT(num_consumed == 3);
+	XNB_ASSERT(pkt.size == 200);
+	XNB_ASSERT(pkt.car_size == 110);
+	XNB_ASSERT(pkt.flags == 0);
+	XNB_ASSERT(xnb_pkt_is_valid(&pkt));
+	XNB_ASSERT(pkt.list_len == 3);
+	XNB_ASSERT(pkt.car == start_idx);
+	XNB_ASSERT(pkt.cdr == start_idx + 1);
+	XNB_ASSERT(RING_GET_REQUEST(&xnb_unit_pvt.txb, pkt.cdr + 1) == req);
+}
+
+/**
+ * Verify that xnb_ring2pkt can read extra inf
+ */
+static void
+xnb_ring2pkt_extra(char *buffer, size_t buflen)
+{
+	struct xnb_pkt pkt;
+	int num_consumed;
+	struct netif_tx_request *req;
+	struct netif_extra_info *ext;
+	RING_IDX start_idx = xnb_unit_pvt.txf.req_prod_pvt;
+
+	req = RING_GET_REQUEST(&xnb_unit_pvt.txf,
+	    xnb_unit_pvt.txf.req_prod_pvt);
+	req->flags = NETTXF_extra_info | NETTXF_more_data;
+	req->size = 150;
+	xnb_unit_pvt.txf.req_prod_pvt++;
+
+	ext = (struct netif_extra_info*) RING_GET_REQUEST(&xnb_unit_pvt.txf,
+	    xnb_unit_pvt.txf.req_prod_pvt);
+	ext->flags = 0;
+	ext->type = XEN_NETIF_EXTRA_TYPE_GSO;
+	ext->u.gso.size = 250;
+	ext->u.gso.type = XEN_NETIF_GSO_TYPE_TCPV4;
+	ext->u.gso.features = 0;
+	xnb_unit_pvt.txf.req_prod_pvt++;
+
+	req = RING_GET_REQUEST(&xnb_unit_pvt.txf,
+	    xnb_unit_pvt.txf.req_prod_pvt);
+	req->flags = 0;
+	req->size = 50;
+	xnb_unit_pvt.txf.req_prod_pvt++;
+
+	RING_PUSH_REQUESTS(&xnb_unit_pvt.txf);
+
+	num_consumed = xnb_ring2pkt(&pkt, &xnb_unit_pvt.txb,
+	                            xnb_unit_pvt.txb.req_cons);
+	XNB_ASSERT(num_consumed == 3);
+	XNB_ASSERT(pkt.extra.flags == 0);
+	XNB_ASSERT(pkt.extra.type == XEN_NETIF_EXTRA_TYPE_GSO);
+	XNB_ASSERT(pkt.extra.u.gso.size == 250);
+	XNB_ASSERT(pkt.extra.u.gso.type = XEN_NETIF_GSO_TYPE_TCPV4);
+	XNB_ASSERT(pkt.size == 150);
+	XNB_ASSERT(pkt.car_size == 100);
+	XNB_ASSERT(pkt.flags == NETTXF_extra_info);
+	XNB_ASSERT(xnb_pkt_is_valid(&pkt));
+	XNB_ASSERT(pkt.list_len == 2);
+	XNB_ASSERT(pkt.car == start_idx);
+	XNB_ASSERT(pkt.cdr == start_idx + 2);
+	XNB_ASSERT(RING_GET_REQUEST(&xnb_unit_pvt.txb, pkt.cdr) == req);
+}
+
+/**
+ * Verify that xnb_ring2pkt will consume no requests if the entire packet is
+ * not yet in the ring
+ */
+static void
+xnb_ring2pkt_partial(char *buffer, size_t buflen)
+{
+	struct xnb_pkt pkt;
+	int num_consumed;
+	struct netif_tx_request *req;
+
+	req = RING_GET_REQUEST(&xnb_unit_pvt.txf,
+	    xnb_unit_pvt.txf.req_prod_pvt);
+	req->flags = NETTXF_more_data;
+	req->size = 150;
+	xnb_unit_pvt.txf.req_prod_pvt++;
+
+	RING_PUSH_REQUESTS(&xnb_unit_pvt.txf);
+
+	num_consumed = xnb_ring2pkt(&pkt, &xnb_unit_pvt.txb,
+	                            xnb_unit_pvt.txb.req_cons);
+	XNB_ASSERT(num_consumed == 0);
+	XNB_ASSERT(! xnb_pkt_is_valid(&pkt));
+}
+
+/**
+ * Verity that xnb_ring2pkt can read a packet whose requests wrap around
+ * the end of the ring
+ */
+static void
+xnb_ring2pkt_wraps(char *buffer, size_t buflen)
+{
+	struct xnb_pkt pkt;
+	int num_consumed;
+	struct netif_tx_request *req;
+	unsigned int rsize;
+
+	/*
+	 * Manually tweak the ring indices to create a ring with no responses
+	 * and the next request slot at position 2 from the end
+	 */
+	rsize = RING_SIZE(&xnb_unit_pvt.txf);
+	xnb_unit_pvt.txf.req_prod_pvt = rsize - 2;
+	xnb_unit_pvt.txf.rsp_cons = rsize - 2;
+	xnb_unit_pvt.txs->req_prod = rsize - 2;
+	xnb_unit_pvt.txs->req_event = rsize - 1;
+	xnb_unit_pvt.txs->rsp_prod = rsize - 2;
+	xnb_unit_pvt.txs->rsp_event = rsize - 1;
+	xnb_unit_pvt.txb.rsp_prod_pvt = rsize - 2;
+	xnb_unit_pvt.txb.req_cons = rsize - 2;
+
+	req = RING_GET_REQUEST(&xnb_unit_pvt.txf,
+	    xnb_unit_pvt.txf.req_prod_pvt);
+	req->flags = NETTXF_more_data;
+	req->size = 550;
+	xnb_unit_pvt.txf.req_prod_pvt++;
+
+	req = RING_GET_REQUEST(&xnb_unit_pvt.txf,
+	    xnb_unit_pvt.txf.req_prod_pvt);
+	req->flags = NETTXF_more_data;
+	req->size = 100;
+	xnb_unit_pvt.txf.req_prod_pvt++;
+
+	req = RING_GET_REQUEST(&xnb_unit_pvt.txf,
+	    xnb_unit_pvt.txf.req_prod_pvt);
+	req->flags = 0;
+	req->size = 50;
+	xnb_unit_pvt.txf.req_prod_pvt++;
+
+	RING_PUSH_REQUESTS(&xnb_unit_pvt.txf);
+
+	num_consumed = xnb_ring2pkt(&pkt, &xnb_unit_pvt.txb,
+	                            xnb_unit_pvt.txb.req_cons);
+	XNB_ASSERT(num_consumed == 3);
+	XNB_ASSERT(xnb_pkt_is_valid(&pkt));
+	XNB_ASSERT(pkt.list_len == 3);
+	XNB_ASSERT(RING_GET_REQUEST(&xnb_unit_pvt.txb, pkt.cdr + 1) == req);
+}
+
+
+/**
+ * xnb_txpkt2rsp should do nothing for an empty packet
+ */
+static void
+xnb_txpkt2rsp_emptypkt(char *buffer, size_t buflen)
+{
+	int num_consumed;
+	struct xnb_pkt pkt;
+	netif_tx_back_ring_t txb_backup = xnb_unit_pvt.txb;
+	netif_tx_sring_t txs_backup = *xnb_unit_pvt.txs;
+	pkt.list_len = 0;
+
+	/* must call xnb_ring2pkt just to intialize pkt */
+	num_consumed = xnb_ring2pkt(&pkt, &xnb_unit_pvt.txb,
+	                            xnb_unit_pvt.txb.req_cons);
+	xnb_txpkt2rsp(&pkt, &xnb_unit_pvt.txb, 0);
+	XNB_ASSERT(
+	    memcmp(&txb_backup, &xnb_unit_pvt.txb, sizeof(txb_backup)) == 0);
+	XNB_ASSERT(
+	    memcmp(&txs_backup, xnb_unit_pvt.txs, sizeof(txs_backup)) == 0);
+}
+
+/**
+ * xnb_txpkt2rsp responding to one request
+ */
+static void
+xnb_txpkt2rsp_1req(char *buffer, size_t buflen)
+{
+	uint16_t num_consumed;
+	struct xnb_pkt pkt;
+	struct netif_tx_request *req;
+	struct netif_tx_response *rsp;
+
+	req = RING_GET_REQUEST(&xnb_unit_pvt.txf,
+	    xnb_unit_pvt.txf.req_prod_pvt);
+	req->size = 1000;
+	req->flags = 0;
+	xnb_unit_pvt.txf.req_prod_pvt++;
+
+	RING_PUSH_REQUESTS(&xnb_unit_pvt.txf);
+
+	num_consumed = xnb_ring2pkt(&pkt, &xnb_unit_pvt.txb,
+	                            xnb_unit_pvt.txb.req_cons);
+	xnb_unit_pvt.txb.req_cons += num_consumed;
+
+	xnb_txpkt2rsp(&pkt, &xnb_unit_pvt.txb, 0);
+	rsp = RING_GET_RESPONSE(&xnb_unit_pvt.txb, xnb_unit_pvt.txf.rsp_cons);
+
+	XNB_ASSERT(
+	    xnb_unit_pvt.txb.rsp_prod_pvt == xnb_unit_pvt.txs->req_prod);
+	XNB_ASSERT(rsp->id == req->id);
+	XNB_ASSERT(rsp->status == NETIF_RSP_OKAY);
+};
+
+/**
+ * xnb_txpkt2rsp responding to 1 data request and 1 extra info
+ */
+static void
+xnb_txpkt2rsp_extra(char *buffer, size_t buflen)
+{
+	uint16_t num_consumed;
+	struct xnb_pkt pkt;
+	struct netif_tx_request *req;
+	netif_extra_info_t *ext;
+	struct netif_tx_response *rsp;
+
+	req = RING_GET_REQUEST(&xnb_unit_pvt.txf,
+	    xnb_unit_pvt.txf.req_prod_pvt);
+	req->size = 1000;
+	req->flags = NETTXF_extra_info;
+	req->id = 69;
+	xnb_unit_pvt.txf.req_prod_pvt++;
+
+	ext = (netif_extra_info_t*) RING_GET_REQUEST(&xnb_unit_pvt.txf,
+	    xnb_unit_pvt.txf.req_prod_pvt);
+	ext->type = XEN_NETIF_EXTRA_TYPE_GSO;
+	ext->flags = 0;
+	xnb_unit_pvt.txf.req_prod_pvt++;
+
+	RING_PUSH_REQUESTS(&xnb_unit_pvt.txf);
+
+	num_consumed = xnb_ring2pkt(&pkt, &xnb_unit_pvt.txb,
+	                            xnb_unit_pvt.txb.req_cons);
+	xnb_unit_pvt.txb.req_cons += num_consumed;
+
+	xnb_txpkt2rsp(&pkt, &xnb_unit_pvt.txb, 0);
+
+	XNB_ASSERT(
+	    xnb_unit_pvt.txb.rsp_prod_pvt == xnb_unit_pvt.txs->req_prod);
+
+	rsp = RING_GET_RESPONSE(&xnb_unit_pvt.txb, xnb_unit_pvt.txf.rsp_cons);
+	XNB_ASSERT(rsp->id == req->id);
+	XNB_ASSERT(rsp->status == NETIF_RSP_OKAY);
+
+	rsp = RING_GET_RESPONSE(&xnb_unit_pvt.txb,
+	    xnb_unit_pvt.txf.rsp_cons + 1);
+	XNB_ASSERT(rsp->status == NETIF_RSP_NULL);
+};
+
+/**
+ * xnb_pkg2rsp responding to 3 data requests and 1 extra info
+ */
+static void
+xnb_txpkt2rsp_long(char *buffer, size_t buflen)
+{
+	uint16_t num_consumed;
+	struct xnb_pkt pkt;
+	struct netif_tx_request *req;
+	netif_extra_info_t *ext;
+	struct netif_tx_response *rsp;
+
+	req = RING_GET_REQUEST(&xnb_unit_pvt.txf,
+	    xnb_unit_pvt.txf.req_prod_pvt);
+	req->size = 1000;
+	req->flags = NETTXF_extra_info | NETTXF_more_data;
+	req->id = 254;
+	xnb_unit_pvt.txf.req_prod_pvt++;
+
+	ext = (netif_extra_info_t*) RING_GET_REQUEST(&xnb_unit_pvt.txf,
+	    xnb_unit_pvt.txf.req_prod_pvt);
+	ext->type = XEN_NETIF_EXTRA_TYPE_GSO;
+	ext->flags = 0;
+	xnb_unit_pvt.txf.req_prod_pvt++;
+
+	req = RING_GET_REQUEST(&xnb_unit_pvt.txf,
+	    xnb_unit_pvt.txf.req_prod_pvt);
+	req->size = 300;
+	req->flags = NETTXF_more_data;
+	req->id = 1034;
+	xnb_unit_pvt.txf.req_prod_pvt++;
+
+	req = RING_GET_REQUEST(&xnb_unit_pvt.txf,
+	    xnb_unit_pvt.txf.req_prod_pvt);
+	req->size = 400;
+	req->flags = 0;
+	req->id = 34;
+	xnb_unit_pvt.txf.req_prod_pvt++;
+
+	RING_PUSH_REQUESTS(&xnb_unit_pvt.txf);
+
+	num_consumed = xnb_ring2pkt(&pkt, &xnb_unit_pvt.txb,
+	                            xnb_unit_pvt.txb.req_cons);
+	xnb_unit_pvt.txb.req_cons += num_consumed;
+
+	xnb_txpkt2rsp(&pkt, &xnb_unit_pvt.txb, 0);
+
+	XNB_ASSERT(
+	    xnb_unit_pvt.txb.rsp_prod_pvt == xnb_unit_pvt.txs->req_prod);
+
+	rsp = RING_GET_RESPONSE(&xnb_unit_pvt.txb, xnb_unit_pvt.txf.rsp_cons);
+	XNB_ASSERT(rsp->id ==
+	    RING_GET_REQUEST(&xnb_unit_pvt.txf, 0)->id);
+	XNB_ASSERT(rsp->status == NETIF_RSP_OKAY);
+
+	rsp = RING_GET_RESPONSE(&xnb_unit_pvt.txb,
+	    xnb_unit_pvt.txf.rsp_cons + 1);
+	XNB_ASSERT(rsp->status == NETIF_RSP_NULL);
+
+	rsp = RING_GET_RESPONSE(&xnb_unit_pvt.txb,
+	    xnb_unit_pvt.txf.rsp_cons + 2);
+	XNB_ASSERT(rsp->id ==
+	    RING_GET_REQUEST(&xnb_unit_pvt.txf, 2)->id);
+	XNB_ASSERT(rsp->status == NETIF_RSP_OKAY);
+
+	rsp = RING_GET_RESPONSE(&xnb_unit_pvt.txb,
+	    xnb_unit_pvt.txf.rsp_cons + 3);
+	XNB_ASSERT(rsp->id ==
+	    RING_GET_REQUEST(&xnb_unit_pvt.txf, 3)->id);
+	XNB_ASSERT(rsp->status == NETIF_RSP_OKAY);
+}
+
+/**
+ * xnb_txpkt2rsp responding to an invalid packet.
+ * Note: this test will result in an error message being printed to the console
+ * such as:
+ * xnb(xnb_ring2pkt:1306): Unknown extra info type 255.  Discarding packet
+ */
+static void
+xnb_txpkt2rsp_invalid(char *buffer, size_t buflen)
+{
+	uint16_t num_consumed;
+	struct xnb_pkt pkt;
+	struct netif_tx_request *req;
+	netif_extra_info_t *ext;
+	struct netif_tx_response *rsp;
+
+	req = RING_GET_REQUEST(&xnb_unit_pvt.txf,
+	    xnb_unit_pvt.txf.req_prod_pvt);
+	req->size = 1000;
+	req->flags = NETTXF_extra_info;
+	req->id = 69;
+	xnb_unit_pvt.txf.req_prod_pvt++;
+
+	ext = (netif_extra_info_t*) RING_GET_REQUEST(&xnb_unit_pvt.txf,
+	    xnb_unit_pvt.txf.req_prod_pvt);
+	ext->type = 0xFF;	/* Invalid extra type */
+	ext->flags = 0;
+	xnb_unit_pvt.txf.req_prod_pvt++;
+
+	RING_PUSH_REQUESTS(&xnb_unit_pvt.txf);
+
+	num_consumed = xnb_ring2pkt(&pkt, &xnb_unit_pvt.txb,
+	                            xnb_unit_pvt.txb.req_cons);
+	xnb_unit_pvt.txb.req_cons += num_consumed;
+	XNB_ASSERT(! xnb_pkt_is_valid(&pkt));
+
+	xnb_txpkt2rsp(&pkt, &xnb_unit_pvt.txb, 0);
+
+	XNB_ASSERT(
+	    xnb_unit_pvt.txb.rsp_prod_pvt == xnb_unit_pvt.txs->req_prod);
+
+	rsp = RING_GET_RESPONSE(&xnb_unit_pvt.txb, xnb_unit_pvt.txf.rsp_cons);
+	XNB_ASSERT(rsp->id == req->id);
+	XNB_ASSERT(rsp->status == NETIF_RSP_ERROR);
+
+	rsp = RING_GET_RESPONSE(&xnb_unit_pvt.txb,
+	    xnb_unit_pvt.txf.rsp_cons + 1);
+	XNB_ASSERT(rsp->status == NETIF_RSP_NULL);
+};
+
+/**
+ * xnb_txpkt2rsp responding to one request which caused an error
+ */
+static void
+xnb_txpkt2rsp_error(char *buffer, size_t buflen)
+{
+	uint16_t num_consumed;
+	struct xnb_pkt pkt;
+	struct netif_tx_request *req;
+	struct netif_tx_response *rsp;
+
+	req = RING_GET_REQUEST(&xnb_unit_pvt.txf,
+	    xnb_unit_pvt.txf.req_prod_pvt);
+	req->size = 1000;
+	req->flags = 0;
+	xnb_unit_pvt.txf.req_prod_pvt++;
+
+	RING_PUSH_REQUESTS(&xnb_unit_pvt.txf);
+
+	num_consumed = xnb_ring2pkt(&pkt, &xnb_unit_pvt.txb,
+	                            xnb_unit_pvt.txb.req_cons);
+	xnb_unit_pvt.txb.req_cons += num_consumed;
+
+	xnb_txpkt2rsp(&pkt, &xnb_unit_pvt.txb, 1);
+	rsp = RING_GET_RESPONSE(&xnb_unit_pvt.txb, xnb_unit_pvt.txf.rsp_cons);
+
+	XNB_ASSERT(
+	    xnb_unit_pvt.txb.rsp_prod_pvt == xnb_unit_pvt.txs->req_prod);
+	XNB_ASSERT(rsp->id == req->id);
+	XNB_ASSERT(rsp->status == NETIF_RSP_ERROR);
+};
+
+/**
+ * xnb_txpkt2rsp's responses wrap around the end of the ring
+ */
+static void
+xnb_txpkt2rsp_wraps(char *buffer, size_t buflen)
+{
+	struct xnb_pkt pkt;
+	int num_consumed;
+	struct netif_tx_request *req;
+	struct netif_tx_response *rsp;
+	unsigned int rsize;
+
+	/*
+	 * Manually tweak the ring indices to create a ring with no responses
+	 * and the next request slot at position 2 from the end
+	 */
+	rsize = RING_SIZE(&xnb_unit_pvt.txf);
+	xnb_unit_pvt.txf.req_prod_pvt = rsize - 2;
+	xnb_unit_pvt.txf.rsp_cons = rsize - 2;
+	xnb_unit_pvt.txs->req_prod = rsize - 2;
+	xnb_unit_pvt.txs->req_event = rsize - 1;
+	xnb_unit_pvt.txs->rsp_prod = rsize - 2;
+	xnb_unit_pvt.txs->rsp_event = rsize - 1;
+	xnb_unit_pvt.txb.rsp_prod_pvt = rsize - 2;
+	xnb_unit_pvt.txb.req_cons = rsize - 2;
+
+	req = RING_GET_REQUEST(&xnb_unit_pvt.txf,
+	    xnb_unit_pvt.txf.req_prod_pvt);
+	req->flags = NETTXF_more_data;
+	req->size = 550;
+	req->id = 1;
+	xnb_unit_pvt.txf.req_prod_pvt++;
+
+	req = RING_GET_REQUEST(&xnb_unit_pvt.txf,
+	    xnb_unit_pvt.txf.req_prod_pvt);
+	req->flags = NETTXF_more_data;
+	req->size = 100;
+	req->id = 2;
+	xnb_unit_pvt.txf.req_prod_pvt++;
+
+	req = RING_GET_REQUEST(&xnb_unit_pvt.txf,
+	    xnb_unit_pvt.txf.req_prod_pvt);
+	req->flags = 0;
+	req->size = 50;
+	req->id = 3;
+	xnb_unit_pvt.txf.req_prod_pvt++;
+
+	RING_PUSH_REQUESTS(&xnb_unit_pvt.txf);
+
+	num_consumed = xnb_ring2pkt(&pkt, &xnb_unit_pvt.txb,
+	                            xnb_unit_pvt.txb.req_cons);
+
+	xnb_txpkt2rsp(&pkt, &xnb_unit_pvt.txb, 0);
+
+	XNB_ASSERT(
+	    xnb_unit_pvt.txb.rsp_prod_pvt == xnb_unit_pvt.txs->req_prod);
+	rsp = RING_GET_RESPONSE(&xnb_unit_pvt.txb,
+	    xnb_unit_pvt.txf.rsp_cons + 2);
+	XNB_ASSERT(rsp->id == req->id);
+	XNB_ASSERT(rsp->status == NETIF_RSP_OKAY);
+}
+
+
+/**
+ * Helper function used to setup pkt2mbufc tests
+ * \param size     size in bytes of the single request to push to the ring
+ * \param flags		optional flags to put in the netif request
+ * \param[out] pkt the returned packet object
+ * \return number of requests consumed from the ring
+ */
+static int
+xnb_get1pkt(struct xnb_pkt *pkt, size_t size, uint16_t flags)
+{
+	struct netif_tx_request *req;
+
+	req = RING_GET_REQUEST(&xnb_unit_pvt.txf,
+	    xnb_unit_pvt.txf.req_prod_pvt);
+	req->flags = flags;
+	req->size = size;
+	xnb_unit_pvt.txf.req_prod_pvt++;
+
+	RING_PUSH_REQUESTS(&xnb_unit_pvt.txf);
+
+	return xnb_ring2pkt(pkt, &xnb_unit_pvt.txb,
+	                            xnb_unit_pvt.txb.req_cons);
+}
+
+/**
+ * xnb_pkt2mbufc on an empty packet
+ */
+static void
+xnb_pkt2mbufc_empty(char *buffer, size_t buflen)
+{
+	int num_consumed;
+	struct xnb_pkt pkt;
+	struct mbuf *pMbuf;
+	pkt.list_len = 0;
+
+	/* must call xnb_ring2pkt just to intialize pkt */
+	num_consumed = xnb_ring2pkt(&pkt, &xnb_unit_pvt.txb,
+	                            xnb_unit_pvt.txb.req_cons);
+	pkt.size = 0;
+	pMbuf = xnb_pkt2mbufc(&pkt, xnb_unit_pvt.ifp);
+	safe_m_freem(&pMbuf);
+}
+
+/**
+ * xnb_pkt2mbufc on short packet that can fit in an mbuf internal buffer
+ */
+static void
+xnb_pkt2mbufc_short(char *buffer, size_t buflen)
+{
+	const size_t size = MINCLSIZE - 1;
+	struct xnb_pkt pkt;
+	struct mbuf *pMbuf;
+
+	xnb_get1pkt(&pkt, size, 0);
+
+	pMbuf = xnb_pkt2mbufc(&pkt, xnb_unit_pvt.ifp);
+	XNB_ASSERT(M_TRAILINGSPACE(pMbuf) >= size);
+	safe_m_freem(&pMbuf);
+}
+
+/**
+ * xnb_pkt2mbufc on short packet whose checksum was validated by the netfron
+ */
+static void
+xnb_pkt2mbufc_csum(char *buffer, size_t buflen)
+{
+	const size_t size = MINCLSIZE - 1;
+	struct xnb_pkt pkt;
+	struct mbuf *pMbuf;
+
+	xnb_get1pkt(&pkt, size, NETTXF_data_validated);
+
+	pMbuf = xnb_pkt2mbufc(&pkt, xnb_unit_pvt.ifp);
+	XNB_ASSERT(M_TRAILINGSPACE(pMbuf) >= size);
+	XNB_ASSERT(pMbuf->m_pkthdr.csum_flags & CSUM_IP_CHECKED);
+	XNB_ASSERT(pMbuf->m_pkthdr.csum_flags & CSUM_IP_VALID);
+	XNB_ASSERT(pMbuf->m_pkthdr.csum_flags & CSUM_DATA_VALID);
+	XNB_ASSERT(pMbuf->m_pkthdr.csum_flags & CSUM_PSEUDO_HDR);
+	safe_m_freem(&pMbuf);
+}
+
+/**
+ * xnb_pkt2mbufc on packet that can fit in one cluster
+ */
+static void
+xnb_pkt2mbufc_1cluster(char *buffer, size_t buflen)
+{
+	const size_t size = MINCLSIZE;
+	struct xnb_pkt pkt;
+	struct mbuf *pMbuf;
+
+	xnb_get1pkt(&pkt, size, 0);
+
+	pMbuf = xnb_pkt2mbufc(&pkt, xnb_unit_pvt.ifp);
+	XNB_ASSERT(M_TRAILINGSPACE(pMbuf) >= size);
+	safe_m_freem(&pMbuf);
+}
+
+/**
+ * xnb_pkt2mbufc on packet that cannot fit in one regular cluster
+ */
+static void
+xnb_pkt2mbufc_largecluster(char *buffer, size_t buflen)
+{
+	const size_t size = MCLBYTES + 1;
+	struct xnb_pkt pkt;
+	struct mbuf *pMbuf;
+
+	xnb_get1pkt(&pkt, size, 0);
+
+	pMbuf = xnb_pkt2mbufc(&pkt, xnb_unit_pvt.ifp);
+	XNB_ASSERT(M_TRAILINGSPACE(pMbuf) >= size);
+	safe_m_freem(&pMbuf);
+}
+
+/**
+ * xnb_pkt2mbufc on packet that cannot fit in one clusters
+ */
+static void
+xnb_pkt2mbufc_2cluster(char *buffer, size_t buflen)
+{
+	const size_t size = 2 * MCLBYTES + 1;
+	size_t space = 0;
+	struct xnb_pkt pkt;
+	struct mbuf *pMbuf;
+	struct mbuf *m;
+
+	xnb_get1pkt(&pkt, size, 0);
+
+	pMbuf = xnb_pkt2mbufc(&pkt, xnb_unit_pvt.ifp);
+
+	for (m = pMbuf; m != NULL; m = m->m_next) {
+		space += M_TRAILINGSPACE(m);
+	}
+	XNB_ASSERT(space >= size);
+	safe_m_freem(&pMbuf);
+}
+
+/**
+ * xnb_txpkt2gnttab on an empty packet.  Should return empty gnttab
+ */
+static void
+xnb_txpkt2gnttab_empty(char *buffer, size_t buflen)
+{
+	int n_entries;
+	struct xnb_pkt pkt;
+	struct mbuf *pMbuf;
+	pkt.list_len = 0;
+
+	/* must call xnb_ring2pkt just to intialize pkt */
+	xnb_ring2pkt(&pkt, &xnb_unit_pvt.txb, xnb_unit_pvt.txb.req_cons);
+	pkt.size = 0;
+	pMbuf = xnb_pkt2mbufc(&pkt, xnb_unit_pvt.ifp);
+	n_entries = xnb_txpkt2gnttab(&pkt, pMbuf, xnb_unit_pvt.gnttab,
+	    &xnb_unit_pvt.txb, DOMID_FIRST_RESERVED);
+	XNB_ASSERT(n_entries == 0);
+	safe_m_freem(&pMbuf);
+}
+
+/**
+ * xnb_txpkt2gnttab on a short packet, that can fit in one mbuf internal buffer
+ * and has one request
+ */
+static void
+xnb_txpkt2gnttab_short(char *buffer, size_t buflen)
+{
+	const size_t size = MINCLSIZE - 1;
+	int n_entries;
+	struct xnb_pkt pkt;
+	struct mbuf *pMbuf;
+
+	struct netif_tx_request *req = RING_GET_REQUEST(&xnb_unit_pvt.txf,
+	    xnb_unit_pvt.txf.req_prod_pvt);
+	req->flags = 0;
+	req->size = size;
+	req->gref = 7;
+	req->offset = 17;
+	xnb_unit_pvt.txf.req_prod_pvt++;
+
+	RING_PUSH_REQUESTS(&xnb_unit_pvt.txf);
+
+	xnb_ring2pkt(&pkt, &xnb_unit_pvt.txb, xnb_unit_pvt.txb.req_cons);
+
+	pMbuf = xnb_pkt2mbufc(&pkt, xnb_unit_pvt.ifp);
+	n_entries = xnb_txpkt2gnttab(&pkt, pMbuf, xnb_unit_pvt.gnttab,
+	    &xnb_unit_pvt.txb, DOMID_FIRST_RESERVED);
+	XNB_ASSERT(n_entries == 1);
+	XNB_ASSERT(xnb_unit_pvt.gnttab[0].len == size);
+	/* flags should indicate gref's for source */
+	XNB_ASSERT(xnb_unit_pvt.gnttab[0].flags & GNTCOPY_source_gref);
+	XNB_ASSERT(xnb_unit_pvt.gnttab[0].source.offset == req->offset);
+	XNB_ASSERT(xnb_unit_pvt.gnttab[0].source.domid == DOMID_SELF);
+	XNB_ASSERT(xnb_unit_pvt.gnttab[0].dest.offset == virt_to_offset(
+	      mtod(pMbuf, vm_offset_t)));
+	XNB_ASSERT(xnb_unit_pvt.gnttab[0].dest.u.gmfn ==
+		virt_to_mfn(mtod(pMbuf, vm_offset_t)));
+	XNB_ASSERT(xnb_unit_pvt.gnttab[0].dest.domid == DOMID_FIRST_RESERVED);
+	safe_m_freem(&pMbuf);
+}
+
+/**
+ * xnb_txpkt2gnttab on a packet with two requests, that can fit into a single
+ * mbuf cluster
+ */
+static void
+xnb_txpkt2gnttab_2req(char *buffer, size_t buflen)
+{
+	int n_entries;
+	struct xnb_pkt pkt;
+	struct mbuf *pMbuf;
+
+	struct netif_tx_request *req = RING_GET_REQUEST(&xnb_unit_pvt.txf,
+	    xnb_unit_pvt.txf.req_prod_pvt);
+	req->flags = NETTXF_more_data;
+	req->size = 1900;
+	req->gref = 7;
+	req->offset = 0;
+	xnb_unit_pvt.txf.req_prod_pvt++;
+
+	req = RING_GET_REQUEST(&xnb_unit_pvt.txf,
+	    xnb_unit_pvt.txf.req_prod_pvt);
+	req->flags = 0;
+	req->size = 500;
+	req->gref = 8;
+	req->offset = 0;
+	xnb_unit_pvt.txf.req_prod_pvt++;
+
+	RING_PUSH_REQUESTS(&xnb_unit_pvt.txf);
+
+	xnb_ring2pkt(&pkt, &xnb_unit_pvt.txb, xnb_unit_pvt.txb.req_cons);
+
+	pMbuf = xnb_pkt2mbufc(&pkt, xnb_unit_pvt.ifp);
+	n_entries = xnb_txpkt2gnttab(&pkt, pMbuf, xnb_unit_pvt.gnttab,
+	    &xnb_unit_pvt.txb, DOMID_FIRST_RESERVED);
+
+	XNB_ASSERT(n_entries == 2);
+	XNB_ASSERT(xnb_unit_pvt.gnttab[0].len == 1400);
+	XNB_ASSERT(xnb_unit_pvt.gnttab[0].dest.offset == virt_to_offset(
+	      mtod(pMbuf, vm_offset_t)));
+
+	XNB_ASSERT(xnb_unit_pvt.gnttab[1].len == 500);
+	XNB_ASSERT(xnb_unit_pvt.gnttab[1].dest.offset == virt_to_offset(
+	      mtod(pMbuf, vm_offset_t) + 1400));
+	safe_m_freem(&pMbuf);
+}
+
+/**
+ * xnb_txpkt2gnttab on a single request that spans two mbuf clusters
+ */
+static void
+xnb_txpkt2gnttab_2cluster(char *buffer, size_t buflen)
+{
+	int n_entries;
+	struct xnb_pkt pkt;
+	struct mbuf *pMbuf;
+	const uint16_t data_this_transaction = (MCLBYTES*2) + 1;
+
+	struct netif_tx_request *req = RING_GET_REQUEST(&xnb_unit_pvt.txf,
+	    xnb_unit_pvt.txf.req_prod_pvt);
+	req->flags = 0;
+	req->size = data_this_transaction;
+	req->gref = 8;
+	req->offset = 0;
+	xnb_unit_pvt.txf.req_prod_pvt++;
+
+	RING_PUSH_REQUESTS(&xnb_unit_pvt.txf);
+	xnb_ring2pkt(&pkt, &xnb_unit_pvt.txb, xnb_unit_pvt.txb.req_cons);
+
+	pMbuf = xnb_pkt2mbufc(&pkt, xnb_unit_pvt.ifp);
+	n_entries = xnb_txpkt2gnttab(&pkt, pMbuf, xnb_unit_pvt.gnttab,
+	    &xnb_unit_pvt.txb, DOMID_FIRST_RESERVED);
+
+	if (M_TRAILINGSPACE(pMbuf) == MCLBYTES) {
+		/* there should be three mbufs and three gnttab entries */
+		XNB_ASSERT(n_entries == 3);
+		XNB_ASSERT(xnb_unit_pvt.gnttab[0].len == MCLBYTES);
+		XNB_ASSERT(
+		    xnb_unit_pvt.gnttab[0].dest.offset == virt_to_offset(
+		      mtod(pMbuf, vm_offset_t)));
+		XNB_ASSERT(xnb_unit_pvt.gnttab[0].source.offset == 0);
+
+		XNB_ASSERT(xnb_unit_pvt.gnttab[1].len == MCLBYTES);
+		XNB_ASSERT(
+		    xnb_unit_pvt.gnttab[1].dest.offset == virt_to_offset(
+		      mtod(pMbuf->m_next, vm_offset_t)));
+		XNB_ASSERT(xnb_unit_pvt.gnttab[1].source.offset == MCLBYTES);
+
+		XNB_ASSERT(xnb_unit_pvt.gnttab[2].len == 1);
+		XNB_ASSERT(
+		    xnb_unit_pvt.gnttab[2].dest.offset == virt_to_offset(
+		      mtod(pMbuf->m_next, vm_offset_t)));
+		XNB_ASSERT(xnb_unit_pvt.gnttab[2].source.offset == 2 *
+			    MCLBYTES);
+	} else if (M_TRAILINGSPACE(pMbuf) == 2 * MCLBYTES) {
+		/* there should be two mbufs and two gnttab entries */
+		XNB_ASSERT(n_entries == 2);
+		XNB_ASSERT(xnb_unit_pvt.gnttab[0].len == 2 * MCLBYTES);
+		XNB_ASSERT(
+		    xnb_unit_pvt.gnttab[0].dest.offset == virt_to_offset(
+		      mtod(pMbuf, vm_offset_t)));
+		XNB_ASSERT(xnb_unit_pvt.gnttab[0].source.offset == 0);
+
+		XNB_ASSERT(xnb_unit_pvt.gnttab[1].len == 1);
+		XNB_ASSERT(
+		    xnb_unit_pvt.gnttab[1].dest.offset == virt_to_offset(
+		      mtod(pMbuf->m_next, vm_offset_t)));
+		XNB_ASSERT(
+		    xnb_unit_pvt.gnttab[1].source.offset == 2 * MCLBYTES);
+
+	} else {
+		/* should never get here */
+		XNB_ASSERT(0);
+	}
+	if (pMbuf != NULL)
+		m_freem(pMbuf);
+}
+
+
+/**
+ * xnb_update_mbufc on a short packet that only has one gnttab entry
+ */
+static void
+xnb_update_mbufc_short(char *buffer, size_t buflen)
+{
+	const size_t size = MINCLSIZE - 1;
+	int n_entries;
+	struct xnb_pkt pkt;
+	struct mbuf *pMbuf;
+
+	struct netif_tx_request *req = RING_GET_REQUEST(&xnb_unit_pvt.txf,
+	    xnb_unit_pvt.txf.req_prod_pvt);
+	req->flags = 0;
+	req->size = size;
+	req->gref = 7;
+	req->offset = 17;
+	xnb_unit_pvt.txf.req_prod_pvt++;
+
+	RING_PUSH_REQUESTS(&xnb_unit_pvt.txf);
+
+	xnb_ring2pkt(&pkt, &xnb_unit_pvt.txb, xnb_unit_pvt.txb.req_cons);
+
+	pMbuf = xnb_pkt2mbufc(&pkt, xnb_unit_pvt.ifp);
+	n_entries = xnb_txpkt2gnttab(&pkt, pMbuf, xnb_unit_pvt.gnttab,
+	    &xnb_unit_pvt.txb, DOMID_FIRST_RESERVED);
+
+	/* Update grant table's status fields as the hypervisor call would */
+	xnb_unit_pvt.gnttab[0].status = GNTST_okay;
+
+	xnb_update_mbufc(pMbuf, xnb_unit_pvt.gnttab, n_entries);
+	XNB_ASSERT(pMbuf->m_len == size);
+	XNB_ASSERT(pMbuf->m_pkthdr.len == size);
+	safe_m_freem(&pMbuf);
+}
+
+/**
+ * xnb_update_mbufc on a packet with two requests, that can fit into a single
+ * mbuf cluster
+ */
+static void
+xnb_update_mbufc_2req(char *buffer, size_t buflen)
+{
+	int n_entries;
+	struct xnb_pkt pkt;
+	struct mbuf *pMbuf;
+
+	struct netif_tx_request *req = RING_GET_REQUEST(&xnb_unit_pvt.txf,
+	    xnb_unit_pvt.txf.req_prod_pvt);
+	req->flags = NETTXF_more_data;
+	req->size = 1900;
+	req->gref = 7;
+	req->offset = 0;
+	xnb_unit_pvt.txf.req_prod_pvt++;
+
+	req = RING_GET_REQUEST(&xnb_unit_pvt.txf,
+	    xnb_unit_pvt.txf.req_prod_pvt);
+	req->flags = 0;
+	req->size = 500;
+	req->gref = 8;
+	req->offset = 0;
+	xnb_unit_pvt.txf.req_prod_pvt++;
+
+	RING_PUSH_REQUESTS(&xnb_unit_pvt.txf);
+
+	xnb_ring2pkt(&pkt, &xnb_unit_pvt.txb, xnb_unit_pvt.txb.req_cons);
+
+	pMbuf = xnb_pkt2mbufc(&pkt, xnb_unit_pvt.ifp);
+	n_entries = xnb_txpkt2gnttab(&pkt, pMbuf, xnb_unit_pvt.gnttab,
+	    &xnb_unit_pvt.txb, DOMID_FIRST_RESERVED);
+
+	/* Update grant table's status fields as the hypervisor call would */
+	xnb_unit_pvt.gnttab[0].status = GNTST_okay;
+	xnb_unit_pvt.gnttab[1].status = GNTST_okay;
+
+	xnb_update_mbufc(pMbuf, xnb_unit_pvt.gnttab, n_entries);
+	XNB_ASSERT(n_entries == 2);
+	XNB_ASSERT(pMbuf->m_pkthdr.len == 1900);
+	XNB_ASSERT(pMbuf->m_len == 1900);
+
+	safe_m_freem(&pMbuf);
+}
+
+/**
+ * xnb_update_mbufc on a single request that spans two mbuf clusters
+ */
+static void
+xnb_update_mbufc_2cluster(char *buffer, size_t buflen)
+{
+	int i;
+	int n_entries;
+	struct xnb_pkt pkt;
+	struct mbuf *pMbuf;
+	const uint16_t data_this_transaction = (MCLBYTES*2) + 1;
+
+	struct netif_tx_request *req = RING_GET_REQUEST(&xnb_unit_pvt.txf,
+	    xnb_unit_pvt.txf.req_prod_pvt);
+	req->flags = 0;
+	req->size = data_this_transaction;
+	req->gref = 8;
+	req->offset = 0;
+	xnb_unit_pvt.txf.req_prod_pvt++;
+
+	RING_PUSH_REQUESTS(&xnb_unit_pvt.txf);
+	xnb_ring2pkt(&pkt, &xnb_unit_pvt.txb, xnb_unit_pvt.txb.req_cons);
+
+	pMbuf = xnb_pkt2mbufc(&pkt, xnb_unit_pvt.ifp);
+	n_entries = xnb_txpkt2gnttab(&pkt, pMbuf, xnb_unit_pvt.gnttab,
+	    &xnb_unit_pvt.txb, DOMID_FIRST_RESERVED);
+
+	/* Update grant table's status fields */
+	for (i = 0; i < n_entries; i++) {
+		xnb_unit_pvt.gnttab[0].status = GNTST_okay;
+	}
+	xnb_update_mbufc(pMbuf, xnb_unit_pvt.gnttab, n_entries);
+
+	if (n_entries == 3) {
+		/* there should be three mbufs and three gnttab entries */
+		XNB_ASSERT(pMbuf->m_pkthdr.len == data_this_transaction);
+		XNB_ASSERT(pMbuf->m_len == MCLBYTES);
+		XNB_ASSERT(pMbuf->m_next->m_len == MCLBYTES);
+		XNB_ASSERT(pMbuf->m_next->m_next->m_len == 1);
+	} else if (n_entries == 2) {
+		/* there should be two mbufs and two gnttab entries */
+		XNB_ASSERT(n_entries == 2);
+		XNB_ASSERT(pMbuf->m_pkthdr.len == data_this_transaction);
+		XNB_ASSERT(pMbuf->m_len == 2 * MCLBYTES);
+		XNB_ASSERT(pMbuf->m_next->m_len == 1);
+	} else {
+		/* should never get here */
+		XNB_ASSERT(0);
+	}
+	safe_m_freem(&pMbuf);
+}
+
+/** xnb_mbufc2pkt on an empty mbufc */
+static void
+xnb_mbufc2pkt_empty(char *buffer, size_t buflen) {
+	struct xnb_pkt pkt;
+	int free_slots = 64;
+	struct mbuf *mbuf;
+
+	mbuf = m_get(M_WAITOK, MT_DATA);
+	/*
+	 * note: it is illegal to set M_PKTHDR on a mbuf with no data.  Doing so
+	 * will cause m_freem to segfault
+	 */
+	XNB_ASSERT(mbuf->m_len == 0);
+
+	xnb_mbufc2pkt(mbuf, &pkt, 0, free_slots);
+	XNB_ASSERT(! xnb_pkt_is_valid(&pkt));
+
+	safe_m_freem(&mbuf);
+}
+
+/** xnb_mbufc2pkt on a short mbufc */
+static void
+xnb_mbufc2pkt_short(char *buffer, size_t buflen) {
+	struct xnb_pkt pkt;
+	size_t size = 128;
+	int free_slots = 64;
+	RING_IDX start = 9;
+	struct mbuf *mbuf;
+
+	mbuf = m_getm(NULL, size, M_WAITOK, MT_DATA);
+	mbuf->m_flags |= M_PKTHDR;
+	mbuf->m_pkthdr.len = size;
+	mbuf->m_len = size;
+
+	xnb_mbufc2pkt(mbuf, &pkt, start, free_slots);
+	XNB_ASSERT(xnb_pkt_is_valid(&pkt));
+	XNB_ASSERT(pkt.size == size);
+	XNB_ASSERT(pkt.car_size == size);
+	XNB_ASSERT(! (pkt.flags &
+	      (NETRXF_more_data | NETRXF_extra_info)));
+	XNB_ASSERT(pkt.list_len == 1);
+	XNB_ASSERT(pkt.car == start);
+
+	safe_m_freem(&mbuf);
+}
+
+/** xnb_mbufc2pkt on a single mbuf with an mbuf cluster */
+static void
+xnb_mbufc2pkt_1cluster(char *buffer, size_t buflen) {
+	struct xnb_pkt pkt;
+	size_t size = MCLBYTES;
+	int free_slots = 32;
+	RING_IDX start = 12;
+	struct mbuf *mbuf;
+
+	mbuf = m_getm(NULL, size, M_WAITOK, MT_DATA);
+	mbuf->m_flags |= M_PKTHDR;
+	mbuf->m_pkthdr.len = size;
+	mbuf->m_len = size;
+
+	xnb_mbufc2pkt(mbuf, &pkt, start, free_slots);
+	XNB_ASSERT(xnb_pkt_is_valid(&pkt));
+	XNB_ASSERT(pkt.size == size);
+	XNB_ASSERT(pkt.car_size == size);
+	XNB_ASSERT(! (pkt.flags &
+	      (NETRXF_more_data | NETRXF_extra_info)));
+	XNB_ASSERT(pkt.list_len == 1);
+	XNB_ASSERT(pkt.car == start);
+
+	safe_m_freem(&mbuf);
+}
+
+/** xnb_mbufc2pkt on a a two-mbuf chain with short data regions */
+static void
+xnb_mbufc2pkt_2short(char *buffer, size_t buflen) {
+	struct xnb_pkt pkt;
+	size_t size1 = MHLEN - 5;
+	size_t size2 = MHLEN - 15;
+	int free_slots = 32;
+	RING_IDX start = 14;
+	struct mbuf *mbufc, *mbufc2;
+
+	mbufc = m_getm(NULL, size1, M_WAITOK, MT_DATA);
+	mbufc->m_flags |= M_PKTHDR;
+	if (mbufc == NULL) {
+		XNB_ASSERT(mbufc != NULL);
+		return;
+	}
+
+	mbufc2 = m_getm(mbufc, size2, M_WAITOK, MT_DATA);
+	if (mbufc2 == NULL) {
+		XNB_ASSERT(mbufc2 != NULL);
+		safe_m_freem(&mbufc);
+		return;
+	}
+	mbufc2->m_pkthdr.len = size1 + size2;
+	mbufc2->m_len = size1;
+
+	xnb_mbufc2pkt(mbufc2, &pkt, start, free_slots);
+	XNB_ASSERT(xnb_pkt_is_valid(&pkt));
+	XNB_ASSERT(pkt.size == size1 + size2);
+	XNB_ASSERT(pkt.car == start);
+	/*
+	 * The second m_getm may allocate a new mbuf and append
+	 * it to the chain, or it may simply extend the first mbuf.
+	 */
+	if (mbufc2->m_next != NULL) {
+		XNB_ASSERT(pkt.car_size == size1);
+		XNB_ASSERT(pkt.list_len == 1);
+		XNB_ASSERT(pkt.cdr == start + 1);
+	}
+
+	safe_m_freem(&mbufc2);
+}
+
+/** xnb_mbufc2pkt on a a mbuf chain with >1 mbuf cluster */
+static void
+xnb_mbufc2pkt_long(char *buffer, size_t buflen) {
+	struct xnb_pkt pkt;
+	size_t size = 14 * MCLBYTES / 3;
+	size_t size_remaining;
+	int free_slots = 15;
+	RING_IDX start = 3;
+	struct mbuf *mbufc, *m;
+
+	mbufc = m_getm(NULL, size, M_WAITOK, MT_DATA);
+	mbufc->m_flags |= M_PKTHDR;
+	if (mbufc == NULL) {
+		XNB_ASSERT(mbufc != NULL);
+		return;
+	}
+
+	mbufc->m_pkthdr.len = size;
+	size_remaining = size;
+	for (m = mbufc; m != NULL; m = m->m_next) {
+		m->m_len = MAX(M_TRAILINGSPACE(m), size_remaining);
+		size_remaining -= m->m_len;
+	}
+
+	xnb_mbufc2pkt(mbufc, &pkt, start, free_slots);
+	XNB_ASSERT(xnb_pkt_is_valid(&pkt));
+	XNB_ASSERT(pkt.size == size);
+	XNB_ASSERT(pkt.car == start);
+	XNB_ASSERT(pkt.car_size = mbufc->m_len);
+	/*
+	 * There should be >1 response in the packet, and there is no
+	 * extra info.
+	 */
+	XNB_ASSERT(! (pkt.flags & NETRXF_extra_info));
+	XNB_ASSERT(pkt.cdr == pkt.car + 1);
+
+	safe_m_freem(&mbufc);
+}
+
+/** xnb_mbufc2pkt on a a mbuf chain with >1 mbuf cluster and extra info */
+static void
+xnb_mbufc2pkt_extra(char *buffer, size_t buflen) {
+	struct xnb_pkt pkt;
+	size_t size = 14 * MCLBYTES / 3;
+	size_t size_remaining;
+	int free_slots = 15;
+	RING_IDX start = 3;
+	struct mbuf *mbufc, *m;
+
+	mbufc = m_getm(NULL, size, M_WAITOK, MT_DATA);
+	if (mbufc == NULL) {
+		XNB_ASSERT(mbufc != NULL);
+		return;
+	}
+
+	mbufc->m_flags |= M_PKTHDR;
+	mbufc->m_pkthdr.len = size;
+	mbufc->m_pkthdr.csum_flags |= CSUM_TSO;
+	mbufc->m_pkthdr.tso_segsz = TCP_MSS - 40;
+	size_remaining = size;
+	for (m = mbufc; m != NULL; m = m->m_next) {
+		m->m_len = MAX(M_TRAILINGSPACE(m), size_remaining);
+		size_remaining -= m->m_len;
+	}
+
+	xnb_mbufc2pkt(mbufc, &pkt, start, free_slots);
+	XNB_ASSERT(xnb_pkt_is_valid(&pkt));
+	XNB_ASSERT(pkt.size == size);
+	XNB_ASSERT(pkt.car == start);
+	XNB_ASSERT(pkt.car_size = mbufc->m_len);
+	/* There should be >1 response in the packet, there is extra info */
+	XNB_ASSERT(pkt.flags & NETRXF_extra_info);
+	XNB_ASSERT(pkt.flags & NETRXF_data_validated);
+	XNB_ASSERT(pkt.cdr == pkt.car + 2);
+	XNB_ASSERT(pkt.extra.u.gso.size = mbufc->m_pkthdr.tso_segsz);
+	XNB_ASSERT(pkt.extra.type == XEN_NETIF_EXTRA_TYPE_GSO);
+	XNB_ASSERT(! (pkt.extra.flags & XEN_NETIF_EXTRA_FLAG_MORE));
+
+	safe_m_freem(&mbufc);
+}
+
+/** xnb_mbufc2pkt with insufficient space in the ring */
+static void
+xnb_mbufc2pkt_nospace(char *buffer, size_t buflen) {
+	struct xnb_pkt pkt;
+	size_t size = 14 * MCLBYTES / 3;
+	size_t size_remaining;
+	int free_slots = 2;
+	RING_IDX start = 3;
+	struct mbuf *mbufc, *m;
+	int error;
+
+	mbufc = m_getm(NULL, size, M_WAITOK, MT_DATA);
+	mbufc->m_flags |= M_PKTHDR;
+	if (mbufc == NULL) {
+		XNB_ASSERT(mbufc != NULL);
+		return;
+	}
+
+	mbufc->m_pkthdr.len = size;
+	size_remaining = size;
+	for (m = mbufc; m != NULL; m = m->m_next) {
+		m->m_len = MAX(M_TRAILINGSPACE(m), size_remaining);
+		size_remaining -= m->m_len;
+	}
+
+	error = xnb_mbufc2pkt(mbufc, &pkt, start, free_slots);
+	XNB_ASSERT(error == EAGAIN);
+	XNB_ASSERT(! xnb_pkt_is_valid(&pkt));
+
+	safe_m_freem(&mbufc);
+}
+
+/**
+ * xnb_rxpkt2gnttab on an empty packet.  Should return empty gnttab
+ */
+static void
+xnb_rxpkt2gnttab_empty(char *buffer, size_t buflen)
+{
+	struct xnb_pkt pkt;
+	int nr_entries;
+	int free_slots = 60;
+	struct mbuf *mbuf;
+
+	mbuf = m_get(M_WAITOK, MT_DATA);
+
+	xnb_mbufc2pkt(mbuf, &pkt, 0, free_slots);
+	nr_entries = xnb_rxpkt2gnttab(&pkt, mbuf, xnb_unit_pvt.gnttab,
+			&xnb_unit_pvt.rxb, DOMID_FIRST_RESERVED);
+
+	XNB_ASSERT(nr_entries == 0);
+
+	safe_m_freem(&mbuf);
+}
+
+/** xnb_rxpkt2gnttab on a short packet without extra data */
+static void
+xnb_rxpkt2gnttab_short(char *buffer, size_t buflen) {
+	struct xnb_pkt pkt;
+	int nr_entries;
+	size_t size = 128;
+	int free_slots = 60;
+	RING_IDX start = 9;
+	struct netif_rx_request *req;
+	struct mbuf *mbuf;
+
+	mbuf = m_getm(NULL, size, M_WAITOK, MT_DATA);
+	mbuf->m_flags |= M_PKTHDR;
+	mbuf->m_pkthdr.len = size;
+	mbuf->m_len = size;
+
+	xnb_mbufc2pkt(mbuf, &pkt, start, free_slots);
+	req = RING_GET_REQUEST(&xnb_unit_pvt.rxf,
+			       xnb_unit_pvt.txf.req_prod_pvt);
+	req->gref = 7;
+
+	nr_entries = xnb_rxpkt2gnttab(&pkt, mbuf, xnb_unit_pvt.gnttab,
+				      &xnb_unit_pvt.rxb, DOMID_FIRST_RESERVED);
+
+	XNB_ASSERT(nr_entries == 1);
+	XNB_ASSERT(xnb_unit_pvt.gnttab[0].len == size);
+	/* flags should indicate gref's for dest */
+	XNB_ASSERT(xnb_unit_pvt.gnttab[0].flags & GNTCOPY_dest_gref);
+	XNB_ASSERT(xnb_unit_pvt.gnttab[0].dest.offset == 0);
+	XNB_ASSERT(xnb_unit_pvt.gnttab[0].source.domid == DOMID_SELF);
+	XNB_ASSERT(xnb_unit_pvt.gnttab[0].source.offset == virt_to_offset(
+		   mtod(mbuf, vm_offset_t)));
+	XNB_ASSERT(xnb_unit_pvt.gnttab[0].source.u.gmfn ==
+		   virt_to_mfn(mtod(mbuf, vm_offset_t)));
+	XNB_ASSERT(xnb_unit_pvt.gnttab[0].dest.domid == DOMID_FIRST_RESERVED);
+
+	safe_m_freem(&mbuf);
+}
+
+/**
+ * xnb_rxpkt2gnttab on a packet with two different mbufs in a single chai
+ */
+static void
+xnb_rxpkt2gnttab_2req(char *buffer, size_t buflen)
+{
+	struct xnb_pkt pkt;
+	int nr_entries;
+	int i, num_mbufs;
+	size_t total_granted_size = 0;
+	size_t size = MJUMPAGESIZE + 1;
+	int free_slots = 60;
+	RING_IDX start = 11;
+	struct netif_rx_request *req;
+	struct mbuf *mbuf, *m;
+
+	mbuf = m_getm(NULL, size, M_WAITOK, MT_DATA);
+	mbuf->m_flags |= M_PKTHDR;
+	mbuf->m_pkthdr.len = size;
+	mbuf->m_len = size;
+
+	xnb_mbufc2pkt(mbuf, &pkt, start, free_slots);
+
+	for (i = 0, m=mbuf; m != NULL; i++, m = m->m_next) {
+		req = RING_GET_REQUEST(&xnb_unit_pvt.rxf,
+		    xnb_unit_pvt.txf.req_prod_pvt);
+		req->gref = i;
+		req->id = 5;
+	}
+	num_mbufs = i;
+
+	nr_entries = xnb_rxpkt2gnttab(&pkt, mbuf, xnb_unit_pvt.gnttab,
+			&xnb_unit_pvt.rxb, DOMID_FIRST_RESERVED);
+
+	XNB_ASSERT(nr_entries >= num_mbufs);
+	for (i = 0; i < nr_entries; i++) {
+		int end_offset = xnb_unit_pvt.gnttab[i].len +
+			xnb_unit_pvt.gnttab[i].dest.offset;
+		XNB_ASSERT(end_offset <= PAGE_SIZE);
+		total_granted_size += xnb_unit_pvt.gnttab[i].len;
+	}
+	XNB_ASSERT(total_granted_size == size);
+}
+
+/**
+ * xnb_rxpkt2rsp on an empty packet.  Shouldn't make any response
+ */
+static void
+xnb_rxpkt2rsp_empty(char *buffer, size_t buflen)
+{
+	struct xnb_pkt pkt;
+	int nr_entries;
+	int nr_reqs;
+	int free_slots = 60;
+	netif_rx_back_ring_t rxb_backup = xnb_unit_pvt.rxb;
+	netif_rx_sring_t rxs_backup = *xnb_unit_pvt.rxs;
+	struct mbuf *mbuf;
+
+	mbuf = m_get(M_WAITOK, MT_DATA);
+
+	xnb_mbufc2pkt(mbuf, &pkt, 0, free_slots);
+	nr_entries = xnb_rxpkt2gnttab(&pkt, mbuf, xnb_unit_pvt.gnttab,
+			&xnb_unit_pvt.rxb, DOMID_FIRST_RESERVED);
+
+	nr_reqs = xnb_rxpkt2rsp(&pkt, xnb_unit_pvt.gnttab, nr_entries,
+	    &xnb_unit_pvt.rxb);
+	XNB_ASSERT(nr_reqs == 0);
+	XNB_ASSERT(
+	    memcmp(&rxb_backup, &xnb_unit_pvt.rxb, sizeof(rxb_backup)) == 0);
+	XNB_ASSERT(
+	    memcmp(&rxs_backup, xnb_unit_pvt.rxs, sizeof(rxs_backup)) == 0);
+
+	safe_m_freem(&mbuf);
+}
+
+/**
+ * xnb_rxpkt2rsp on a short packet with no extras
+ */
+static void
+xnb_rxpkt2rsp_short(char *buffer, size_t buflen)
+{
+	struct xnb_pkt pkt;
+	int nr_entries, nr_reqs;
+	size_t size = 128;
+	int free_slots = 60;
+	RING_IDX start = 5;
+	struct netif_rx_request *req;
+	struct netif_rx_response *rsp;
+	struct mbuf *mbuf;
+
+	mbuf = m_getm(NULL, size, M_WAITOK, MT_DATA);
+	mbuf->m_flags |= M_PKTHDR;
+	mbuf->m_pkthdr.len = size;
+	mbuf->m_len = size;
+
+	xnb_mbufc2pkt(mbuf, &pkt, start, free_slots);
+	req = RING_GET_REQUEST(&xnb_unit_pvt.rxf, start);
+	req->gref = 7;
+	xnb_unit_pvt.rxb.req_cons = start;
+	xnb_unit_pvt.rxb.rsp_prod_pvt = start;
+	xnb_unit_pvt.rxs->req_prod = start + 1;
+	xnb_unit_pvt.rxs->rsp_prod = start;
+
+	nr_entries = xnb_rxpkt2gnttab(&pkt, mbuf, xnb_unit_pvt.gnttab,
+			&xnb_unit_pvt.rxb, DOMID_FIRST_RESERVED);
+
+	nr_reqs = xnb_rxpkt2rsp(&pkt, xnb_unit_pvt.gnttab, nr_entries,
+	    &xnb_unit_pvt.rxb);
+
+	XNB_ASSERT(nr_reqs == 1);
+	XNB_ASSERT(xnb_unit_pvt.rxb.rsp_prod_pvt == start + 1);
+	rsp = RING_GET_RESPONSE(&xnb_unit_pvt.rxb, start);
+	XNB_ASSERT(rsp->id == req->id);
+	XNB_ASSERT(rsp->offset == 0);
+	XNB_ASSERT((rsp->flags & (NETRXF_more_data | NETRXF_extra_info)) == 0);
+	XNB_ASSERT(rsp->status == size);
+
+	safe_m_freem(&mbuf);
+}
+
+/**
+ * xnb_rxpkt2rsp with extra data
+ */
+static void
+xnb_rxpkt2rsp_extra(char *buffer, size_t buflen)
+{
+	struct xnb_pkt pkt;
+	int nr_entries, nr_reqs;
+	size_t size = 14;
+	int free_slots = 15;
+	RING_IDX start = 3;
+	uint16_t id = 49;
+	uint16_t gref = 65;
+	uint16_t mss = TCP_MSS - 40;
+	struct mbuf *mbufc;
+	struct netif_rx_request *req;
+	struct netif_rx_response *rsp;
+	struct netif_extra_info *ext;
+
+	mbufc = m_getm(NULL, size, M_WAITOK, MT_DATA);
+	if (mbufc == NULL) {
+		XNB_ASSERT(mbufc != NULL);
+		return;
+	}
+
+	mbufc->m_flags |= M_PKTHDR;
+	mbufc->m_pkthdr.len = size;
+	mbufc->m_pkthdr.csum_flags |= CSUM_TSO;
+	mbufc->m_pkthdr.tso_segsz = mss;
+	mbufc->m_len = size;
+
+	xnb_mbufc2pkt(mbufc, &pkt, start, free_slots);
+	req = RING_GET_REQUEST(&xnb_unit_pvt.rxf, start);
+	req->id = id;
+	req->gref = gref;
+	req = RING_GET_REQUEST(&xnb_unit_pvt.rxf, start + 1);
+	req->id = id + 1;
+	req->gref = gref + 1;
+	xnb_unit_pvt.rxb.req_cons = start;
+	xnb_unit_pvt.rxb.rsp_prod_pvt = start;
+	xnb_unit_pvt.rxs->req_prod = start + 2;
+	xnb_unit_pvt.rxs->rsp_prod = start;
+
+	nr_entries = xnb_rxpkt2gnttab(&pkt, mbufc, xnb_unit_pvt.gnttab,
+			&xnb_unit_pvt.rxb, DOMID_FIRST_RESERVED);
+
+	nr_reqs = xnb_rxpkt2rsp(&pkt, xnb_unit_pvt.gnttab, nr_entries,
+	    &xnb_unit_pvt.rxb);
+
+	XNB_ASSERT(nr_reqs == 2);
+	XNB_ASSERT(xnb_unit_pvt.rxb.rsp_prod_pvt == start + 2);
+	rsp = RING_GET_RESPONSE(&xnb_unit_pvt.rxb, start);
+	XNB_ASSERT(rsp->id == id);
+	XNB_ASSERT((rsp->flags & NETRXF_more_data) == 0);
+	XNB_ASSERT((rsp->flags & NETRXF_extra_info));
+	XNB_ASSERT((rsp->flags & NETRXF_data_validated));
+	XNB_ASSERT((rsp->flags & NETRXF_csum_blank));
+	XNB_ASSERT(rsp->status == size);
+
+	ext = (struct netif_extra_info*)
+		RING_GET_RESPONSE(&xnb_unit_pvt.rxb, start + 1);
+	XNB_ASSERT(ext->type == XEN_NETIF_EXTRA_TYPE_GSO);
+	XNB_ASSERT(! (ext->flags & XEN_NETIF_EXTRA_FLAG_MORE));
+	XNB_ASSERT(ext->u.gso.size == mss);
+	XNB_ASSERT(ext->u.gso.type == XEN_NETIF_EXTRA_TYPE_GSO);
+
+	safe_m_freem(&mbufc);
+}
+
+/**
+ * xnb_rxpkt2rsp on a packet with more than a pages's worth of data.  It should
+ * generate two response slot
+ */
+static void
+xnb_rxpkt2rsp_2slots(char *buffer, size_t buflen)
+{
+	struct xnb_pkt pkt;
+	int nr_entries, nr_reqs;
+	size_t size = PAGE_SIZE + 100;
+	int free_slots = 3;
+	uint16_t id1 = 17;
+	uint16_t id2 = 37;
+	uint16_t gref1 = 24;
+	uint16_t gref2 = 34;
+	RING_IDX start = 15;
+	struct netif_rx_request *req;
+	struct netif_rx_response *rsp;
+	struct mbuf *mbuf;
+
+	mbuf = m_getm(NULL, size, M_WAITOK, MT_DATA);
+	mbuf->m_flags |= M_PKTHDR;
+	mbuf->m_pkthdr.len = size;
+	if (mbuf->m_next != NULL) {
+		size_t first_len = MIN(M_TRAILINGSPACE(mbuf), size);
+		mbuf->m_len = first_len;
+		mbuf->m_next->m_len = size - first_len;
+
+	} else {
+		mbuf->m_len = size;
+	}
+
+	xnb_mbufc2pkt(mbuf, &pkt, start, free_slots);
+	req = RING_GET_REQUEST(&xnb_unit_pvt.rxf, start);
+	req->gref = gref1;
+	req->id = id1;
+	req = RING_GET_REQUEST(&xnb_unit_pvt.rxf, start + 1);
+	req->gref = gref2;
+	req->id = id2;
+	xnb_unit_pvt.rxb.req_cons = start;
+	xnb_unit_pvt.rxb.rsp_prod_pvt = start;
+	xnb_unit_pvt.rxs->req_prod = start + 2;
+	xnb_unit_pvt.rxs->rsp_prod = start;
+
+	nr_entries = xnb_rxpkt2gnttab(&pkt, mbuf, xnb_unit_pvt.gnttab,
+			&xnb_unit_pvt.rxb, DOMID_FIRST_RESERVED);
+
+	nr_reqs = xnb_rxpkt2rsp(&pkt, xnb_unit_pvt.gnttab, nr_entries,
+	    &xnb_unit_pvt.rxb);
+
+	XNB_ASSERT(nr_reqs == 2);
+	XNB_ASSERT(xnb_unit_pvt.rxb.rsp_prod_pvt == start + 2);
+	rsp = RING_GET_RESPONSE(&xnb_unit_pvt.rxb, start);
+	XNB_ASSERT(rsp->id == id1);
+	XNB_ASSERT(rsp->offset == 0);
+	XNB_ASSERT((rsp->flags & NETRXF_extra_info) == 0);
+	XNB_ASSERT(rsp->flags & NETRXF_more_data);
+	XNB_ASSERT(rsp->status == PAGE_SIZE);
+
+	rsp = RING_GET_RESPONSE(&xnb_unit_pvt.rxb, start + 1);
+	XNB_ASSERT(rsp->id == id2);
+	XNB_ASSERT(rsp->offset == 0);
+	XNB_ASSERT((rsp->flags & NETRXF_extra_info) == 0);
+	XNB_ASSERT(! (rsp->flags & NETRXF_more_data));
+	XNB_ASSERT(rsp->status == size - PAGE_SIZE);
+
+	safe_m_freem(&mbuf);
+}
+
+/** xnb_rxpkt2rsp on a grant table with two sub-page entries */
+static void
+xnb_rxpkt2rsp_2short(char *buffer, size_t buflen) {
+	struct xnb_pkt pkt;
+	int nr_reqs, nr_entries;
+	size_t size1 = MHLEN - 5;
+	size_t size2 = MHLEN - 15;
+	int free_slots = 32;
+	RING_IDX start = 14;
+	uint16_t id = 47;
+	uint16_t gref = 54;
+	struct netif_rx_request *req;
+	struct netif_rx_response *rsp;
+	struct mbuf *mbufc;
+
+	mbufc = m_getm(NULL, size1, M_WAITOK, MT_DATA);
+	mbufc->m_flags |= M_PKTHDR;
+	if (mbufc == NULL) {
+		XNB_ASSERT(mbufc != NULL);
+		return;
+	}
+
+	m_getm(mbufc, size2, M_WAITOK, MT_DATA);
+	XNB_ASSERT(mbufc->m_next != NULL);
+	mbufc->m_pkthdr.len = size1 + size2;
+	mbufc->m_len = size1;
+	mbufc->m_next->m_len = size2;
+
+	xnb_mbufc2pkt(mbufc, &pkt, start, free_slots);
+
+	req = RING_GET_REQUEST(&xnb_unit_pvt.rxf, start);
+	req->gref = gref;
+	req->id = id;
+	xnb_unit_pvt.rxb.req_cons = start;
+	xnb_unit_pvt.rxb.rsp_prod_pvt = start;
+	xnb_unit_pvt.rxs->req_prod = start + 1;
+	xnb_unit_pvt.rxs->rsp_prod = start;
+
+	nr_entries = xnb_rxpkt2gnttab(&pkt, mbufc, xnb_unit_pvt.gnttab,
+			&xnb_unit_pvt.rxb, DOMID_FIRST_RESERVED);
+
+	nr_reqs = xnb_rxpkt2rsp(&pkt, xnb_unit_pvt.gnttab, nr_entries,
+	    &xnb_unit_pvt.rxb);
+
+	XNB_ASSERT(nr_entries == 2);
+	XNB_ASSERT(nr_reqs == 1);
+	rsp = RING_GET_RESPONSE(&xnb_unit_pvt.rxb, start);
+	XNB_ASSERT(rsp->id == id);
+	XNB_ASSERT(rsp->status == size1 + size2);
+	XNB_ASSERT(rsp->offset == 0);
+	XNB_ASSERT(! (rsp->flags & (NETRXF_more_data | NETRXF_extra_info)));
+
+	safe_m_freem(&mbufc);
+}
+
+/**
+ * xnb_rxpkt2rsp on a long packet with a hypervisor gnttab_copy error
+ * Note: this test will result in an error message being printed to the console
+ * such as:
+ * xnb(xnb_rxpkt2rsp:1720): Got error -1 for hypervisor gnttab_copy status
+ */
+static void
+xnb_rxpkt2rsp_copyerror(char *buffer, size_t buflen)
+{
+	struct xnb_pkt pkt;
+	int nr_entries, nr_reqs;
+	int id = 7;
+	int gref = 42;
+	uint16_t canary = 6859;
+	size_t size = 7 * MCLBYTES;
+	int free_slots = 9;
+	RING_IDX start = 2;
+	struct netif_rx_request *req;
+	struct netif_rx_response *rsp;
+	struct mbuf *mbuf;
+	
+	mbuf = m_getm(NULL, size, M_WAITOK, MT_DATA);
+	mbuf->m_flags |= M_PKTHDR;
+	mbuf->m_pkthdr.len = size;
+	mbuf->m_len = size;
+
+	xnb_mbufc2pkt(mbuf, &pkt, start, free_slots);
+	req = RING_GET_REQUEST(&xnb_unit_pvt.rxf, start);
+	req->gref = gref;
+	req->id = id;
+	xnb_unit_pvt.rxb.req_cons = start;
+	xnb_unit_pvt.rxb.rsp_prod_pvt = start;
+	xnb_unit_pvt.rxs->req_prod = start + 1;
+	xnb_unit_pvt.rxs->rsp_prod = start;
+	req = RING_GET_REQUEST(&xnb_unit_pvt.rxf, start + 1);
+	req->gref = canary;
+	req->id = canary;
+
+	nr_entries = xnb_rxpkt2gnttab(&pkt, mbuf, xnb_unit_pvt.gnttab,
+			&xnb_unit_pvt.rxb, DOMID_FIRST_RESERVED);
+	/* Inject the error*/
+	xnb_unit_pvt.gnttab[2].status = GNTST_general_error;
+
+	nr_reqs = xnb_rxpkt2rsp(&pkt, xnb_unit_pvt.gnttab, nr_entries,
+	    &xnb_unit_pvt.rxb);
+
+	XNB_ASSERT(nr_reqs == 1);
+	XNB_ASSERT(xnb_unit_pvt.rxb.rsp_prod_pvt == start + 1);
+	rsp = RING_GET_RESPONSE(&xnb_unit_pvt.rxb, start);
+	XNB_ASSERT(rsp->id == id);
+	XNB_ASSERT(rsp->status == NETIF_RSP_ERROR);
+	req = RING_GET_REQUEST(&xnb_unit_pvt.rxf, start + 1);
+	XNB_ASSERT(req->gref == canary);
+	XNB_ASSERT(req->id == canary);
+
+	safe_m_freem(&mbuf);
+}
+
+/**
+ * xnb_add_mbuf_cksum on an ARP request packet
+ */
+static void
+xnb_add_mbuf_cksum_arp(char *buffer, size_t buflen)
+{
+	const size_t pkt_len = sizeof(struct ether_header) +
+		sizeof(struct ether_arp);
+	struct mbuf *mbufc;
+	struct ether_header *eh;
+	struct ether_arp *ep;
+	unsigned char pkt_orig[pkt_len];
+
+	mbufc = m_getm(NULL, pkt_len, M_WAITOK, MT_DATA);
+	/* Fill in an example arp request */
+	eh = mtod(mbufc, struct ether_header*);
+	eh->ether_dhost[0] = 0xff;
+	eh->ether_dhost[1] = 0xff;
+	eh->ether_dhost[2] = 0xff;
+	eh->ether_dhost[3] = 0xff;
+	eh->ether_dhost[4] = 0xff;
+	eh->ether_dhost[5] = 0xff;
+	eh->ether_shost[0] = 0x00;
+	eh->ether_shost[1] = 0x15;
+	eh->ether_shost[2] = 0x17;
+	eh->ether_shost[3] = 0xe9;
+	eh->ether_shost[4] = 0x30;
+	eh->ether_shost[5] = 0x68;
+	eh->ether_type = htons(ETHERTYPE_ARP);
+	ep = (struct ether_arp*)(eh + 1);
+	ep->ea_hdr.ar_hrd = htons(ARPHRD_ETHER);
+	ep->ea_hdr.ar_pro = htons(ETHERTYPE_IP);
+	ep->ea_hdr.ar_hln = 6;
+	ep->ea_hdr.ar_pln = 4;
+	ep->ea_hdr.ar_op = htons(ARPOP_REQUEST);
+	ep->arp_sha[0] = 0x00;
+	ep->arp_sha[1] = 0x15;
+	ep->arp_sha[2] = 0x17;
+	ep->arp_sha[3] = 0xe9;
+	ep->arp_sha[4] = 0x30;
+	ep->arp_sha[5] = 0x68;
+	ep->arp_spa[0] = 0xc0;
+	ep->arp_spa[1] = 0xa8;
+	ep->arp_spa[2] = 0x0a;
+	ep->arp_spa[3] = 0x04;
+	bzero(&(ep->arp_tha), ETHER_ADDR_LEN);
+	ep->arp_tpa[0] = 0xc0;
+	ep->arp_tpa[1] = 0xa8;
+	ep->arp_tpa[2] = 0x0a;
+	ep->arp_tpa[3] = 0x06;
+
+	/* fill in the length field */
+	mbufc->m_len = pkt_len;
+	mbufc->m_pkthdr.len = pkt_len;
+	/* indicate that the netfront uses hw-assisted checksums */
+	mbufc->m_pkthdr.csum_flags = CSUM_IP_CHECKED | CSUM_IP_VALID   |
+				CSUM_DATA_VALID | CSUM_PSEUDO_HDR;
+
+	/* Make a backup copy of the packet */
+	bcopy(mtod(mbufc, const void*), pkt_orig, pkt_len);
+
+	/* Function under test */
+	xnb_add_mbuf_cksum(mbufc);
+
+	/* Verify that the packet's data did not change */
+	XNB_ASSERT(bcmp(mtod(mbufc, const void*), pkt_orig, pkt_len) == 0);
+	m_freem(mbufc);
+}
+
+/**
+ * Helper function that populates the ethernet header and IP header used by
+ * some of the xnb_add_mbuf_cksum unit tests.  m must already be allocated
+ * and must be large enough
+ */
+static void
+xnb_fill_eh_and_ip(struct mbuf *m, uint16_t ip_len, uint16_t ip_id,
+		   uint16_t ip_p, uint16_t ip_off, uint16_t ip_sum)
+{
+	struct ether_header *eh;
+	struct ip *iph;
+
+	eh = mtod(m, struct ether_header*);
+	eh->ether_dhost[0] = 0x00;
+	eh->ether_dhost[1] = 0x16;
+	eh->ether_dhost[2] = 0x3e;
+	eh->ether_dhost[3] = 0x23;
+	eh->ether_dhost[4] = 0x50;
+	eh->ether_dhost[5] = 0x0b;
+	eh->ether_shost[0] = 0x00;
+	eh->ether_shost[1] = 0x16;
+	eh->ether_shost[2] = 0x30;
+	eh->ether_shost[3] = 0x00;
+	eh->ether_shost[4] = 0x00;
+	eh->ether_shost[5] = 0x00;
+	eh->ether_type = htons(ETHERTYPE_IP);
+	iph = (struct ip*)(eh + 1);
+	iph->ip_hl = 0x5;	/* 5 dwords == 20 bytes */
+	iph->ip_v = 4;		/* IP v4 */
+	iph->ip_tos = 0;
+	iph->ip_len = htons(ip_len);
+	iph->ip_id = htons(ip_id);
+	iph->ip_off = htons(ip_off);
+	iph->ip_ttl = 64;
+	iph->ip_p = ip_p;
+	iph->ip_sum = htons(ip_sum);
+	iph->ip_src.s_addr = htonl(0xc0a80a04);
+	iph->ip_dst.s_addr = htonl(0xc0a80a05);
+}
+
+/**
+ * xnb_add_mbuf_cksum on an ICMP packet, based on a tcpdump of an actual
+ * ICMP packet
+ */
+static void
+xnb_add_mbuf_cksum_icmp(char *buffer, size_t buflen)
+{
+	const size_t icmp_len = 64;	/* set by ping(1) */
+	const size_t pkt_len = sizeof(struct ether_header) +
+		sizeof(struct ip) + icmp_len;
+	struct mbuf *mbufc;
+	struct ether_header *eh;
+	struct ip *iph;
+	struct icmp *icmph;
+	unsigned char pkt_orig[icmp_len];
+	uint32_t *tv_field;
+	uint8_t *data_payload;
+	int i;
+	const uint16_t ICMP_CSUM = 0xaed7;
+	const uint16_t IP_CSUM = 0xe533;
+
+	mbufc = m_getm(NULL, pkt_len, M_WAITOK, MT_DATA);
+	/* Fill in an example ICMP ping request */
+	eh = mtod(mbufc, struct ether_header*);
+	xnb_fill_eh_and_ip(mbufc, 84, 28, IPPROTO_ICMP, 0, 0);
+	iph = (struct ip*)(eh + 1);
+	icmph = (struct icmp*)(iph + 1);
+	icmph->icmp_type = ICMP_ECHO;
+	icmph->icmp_code = 0;
+	icmph->icmp_cksum = htons(ICMP_CSUM);
+	icmph->icmp_id = htons(31492);
+	icmph->icmp_seq = htons(0);
+	/*
+	 * ping(1) uses bcopy to insert a native-endian timeval after icmp_seq.
+	 * For this test, we will set the bytes individually for portability.
+	 */
+	tv_field = (uint32_t*)(&(icmph->icmp_hun));
+	tv_field[0] = 0x4f02cfac;
+	tv_field[1] = 0x0007c46a;
+	/*
+	 * Remainder of packet is an incrmenting 8 bit integer, starting with 8
+	 */
+	data_payload = (uint8_t*)(&tv_field[2]);
+	for (i = 8; i < 37; i++) {
+		*data_payload++ = i;
+	}
+
+	/* fill in the length field */
+	mbufc->m_len = pkt_len;
+	mbufc->m_pkthdr.len = pkt_len;
+	/* indicate that the netfront uses hw-assisted checksums */
+	mbufc->m_pkthdr.csum_flags = CSUM_IP_CHECKED | CSUM_IP_VALID   |
+				CSUM_DATA_VALID | CSUM_PSEUDO_HDR;
+
+	bcopy(mtod(mbufc, const void*), pkt_orig, icmp_len);
+	/* Function under test */
+	xnb_add_mbuf_cksum(mbufc);
+
+	/* Check the IP checksum */
+	XNB_ASSERT(iph->ip_sum == htons(IP_CSUM));
+
+	/* Check that the ICMP packet did not change */
+	XNB_ASSERT(bcmp(icmph, pkt_orig, icmp_len));
+	m_freem(mbufc);
+}
+
+/**
+ * xnb_add_mbuf_cksum on a UDP packet, based on a tcpdump of an actual
+ * UDP packet
+ */
+static void
+xnb_add_mbuf_cksum_udp(char *buffer, size_t buflen)
+{
+	const size_t udp_len = 16;
+	const size_t pkt_len = sizeof(struct ether_header) +
+		sizeof(struct ip) + udp_len;
+	struct mbuf *mbufc;
+	struct ether_header *eh;
+	struct ip *iph;
+	struct udphdr *udp;
+	uint8_t *data_payload;
+	const uint16_t IP_CSUM = 0xe56b;
+	const uint16_t UDP_CSUM = 0xdde2;
+
+	mbufc = m_getm(NULL, pkt_len, M_WAITOK, MT_DATA);
+	/* Fill in an example UDP packet made by 'uname | nc -u <host> 2222 */
+	eh = mtod(mbufc, struct ether_header*);
+	xnb_fill_eh_and_ip(mbufc, 36, 4, IPPROTO_UDP, 0, 0xbaad);
+	iph = (struct ip*)(eh + 1);
+	udp = (struct udphdr*)(iph + 1);
+	udp->uh_sport = htons(0x51ae);
+	udp->uh_dport = htons(0x08ae);
+	udp->uh_ulen = htons(udp_len);
+	udp->uh_sum = htons(0xbaad);  /* xnb_add_mbuf_cksum will fill this in */
+	data_payload = (uint8_t*)(udp + 1);
+	data_payload[0] = 'F';
+	data_payload[1] = 'r';
+	data_payload[2] = 'e';
+	data_payload[3] = 'e';
+	data_payload[4] = 'B';
+	data_payload[5] = 'S';
+	data_payload[6] = 'D';
+	data_payload[7] = '\n';
+
+	/* fill in the length field */
+	mbufc->m_len = pkt_len;
+	mbufc->m_pkthdr.len = pkt_len;
+	/* indicate that the netfront uses hw-assisted checksums */
+	mbufc->m_pkthdr.csum_flags = CSUM_IP_CHECKED | CSUM_IP_VALID   |
+				CSUM_DATA_VALID | CSUM_PSEUDO_HDR;
+
+	/* Function under test */
+	xnb_add_mbuf_cksum(mbufc);
+
+	/* Check the checksums */
+	XNB_ASSERT(iph->ip_sum == htons(IP_CSUM));
+	XNB_ASSERT(udp->uh_sum == htons(UDP_CSUM));
+
+	m_freem(mbufc);
+}
+
+/**
+ * Helper function that populates a TCP packet used by all of the
+ * xnb_add_mbuf_cksum tcp unit tests.  m must already be allocated and must be
+ * large enough
+ */
+static void
+xnb_fill_tcp(struct mbuf *m)
+{
+	struct ether_header *eh;
+	struct ip *iph;
+	struct tcphdr *tcp;
+	uint32_t *options;
+	uint8_t *data_payload;
+
+	/* Fill in an example TCP packet made by 'uname | nc <host> 2222' */
+	eh = mtod(m, struct ether_header*);
+	xnb_fill_eh_and_ip(m, 60, 8, IPPROTO_TCP, IP_DF, 0);
+	iph = (struct ip*)(eh + 1);
+	tcp = (struct tcphdr*)(iph + 1);
+	tcp->th_sport = htons(0x9cd9);
+	tcp->th_dport = htons(2222);
+	tcp->th_seq = htonl(0x00f72b10);
+	tcp->th_ack = htonl(0x7f37ba6c);
+	tcp->th_x2 = 0;
+	tcp->th_off = 8;
+	tcp->th_flags = 0x18;
+	tcp->th_win = htons(0x410);
+	/* th_sum is incorrect; will be inserted by function under test */
+	tcp->th_sum = htons(0xbaad);
+	tcp->th_urp = htons(0);
+	/*
+	 * The following 12 bytes of options encode:
+	 * [nop, nop, TS val 33247 ecr 3457687679]
+	 */
+	options = (uint32_t*)(tcp + 1);
+	options[0] = htonl(0x0101080a);
+	options[1] = htonl(0x000081df);
+	options[2] = htonl(0xce18207f);
+	data_payload = (uint8_t*)(&options[3]);
+	data_payload[0] = 'F';
+	data_payload[1] = 'r';
+	data_payload[2] = 'e';
+	data_payload[3] = 'e';
+	data_payload[4] = 'B';
+	data_payload[5] = 'S';
+	data_payload[6] = 'D';
+	data_payload[7] = '\n';
+}
+
+/**
+ * xnb_add_mbuf_cksum on a TCP packet, based on a tcpdump of an actual TCP
+ * packet
+ */
+static void
+xnb_add_mbuf_cksum_tcp(char *buffer, size_t buflen)
+{
+	const size_t payload_len = 8;
+	const size_t tcp_options_len = 12;
+	const size_t pkt_len = sizeof(struct ether_header) + sizeof(struct ip) +
+	    sizeof(struct tcphdr) + tcp_options_len + payload_len;
+	struct mbuf *mbufc;
+	struct ether_header *eh;
+	struct ip *iph;
+	struct tcphdr *tcp;
+	const uint16_t IP_CSUM = 0xa55a;
+	const uint16_t TCP_CSUM = 0x2f64;
+
+	mbufc = m_getm(NULL, pkt_len, M_WAITOK, MT_DATA);
+	/* Fill in an example TCP packet made by 'uname | nc <host> 2222' */
+	xnb_fill_tcp(mbufc);
+	eh = mtod(mbufc, struct ether_header*);
+	iph = (struct ip*)(eh + 1);
+	tcp = (struct tcphdr*)(iph + 1);
+
+	/* fill in the length field */
+	mbufc->m_len = pkt_len;
+	mbufc->m_pkthdr.len = pkt_len;
+	/* indicate that the netfront uses hw-assisted checksums */
+	mbufc->m_pkthdr.csum_flags = CSUM_IP_CHECKED | CSUM_IP_VALID   |
+				CSUM_DATA_VALID | CSUM_PSEUDO_HDR;
+
+	/* Function under test */
+	xnb_add_mbuf_cksum(mbufc);
+
+	/* Check the checksums */
+	XNB_ASSERT(iph->ip_sum == htons(IP_CSUM));
+	XNB_ASSERT(tcp->th_sum == htons(TCP_CSUM));
+
+	m_freem(mbufc);
+}
+
+/**
+ * xnb_add_mbuf_cksum on a TCP packet that does not use HW assisted checksums
+ */
+static void
+xnb_add_mbuf_cksum_tcp_swcksum(char *buffer, size_t buflen)
+{
+	const size_t payload_len = 8;
+	const size_t tcp_options_len = 12;
+	const size_t pkt_len = sizeof(struct ether_header) + sizeof(struct ip) +
+	    sizeof(struct tcphdr) + tcp_options_len + payload_len;
+	struct mbuf *mbufc;
+	struct ether_header *eh;
+	struct ip *iph;
+	struct tcphdr *tcp;
+	/* Use deliberately bad checksums, and verify that they don't get */
+	/* corrected by xnb_add_mbuf_cksum */
+	const uint16_t IP_CSUM = 0xdead;
+	const uint16_t TCP_CSUM = 0xbeef;
+
+	mbufc = m_getm(NULL, pkt_len, M_WAITOK, MT_DATA);
+	/* Fill in an example TCP packet made by 'uname | nc <host> 2222' */
+	xnb_fill_tcp(mbufc);
+	eh = mtod(mbufc, struct ether_header*);
+	iph = (struct ip*)(eh + 1);
+	iph->ip_sum = htons(IP_CSUM);
+	tcp = (struct tcphdr*)(iph + 1);
+	tcp->th_sum = htons(TCP_CSUM);
+
+	/* fill in the length field */
+	mbufc->m_len = pkt_len;
+	mbufc->m_pkthdr.len = pkt_len;
+	/* indicate that the netfront does not use hw-assisted checksums */
+	mbufc->m_pkthdr.csum_flags = 0;
+
+	/* Function under test */
+	xnb_add_mbuf_cksum(mbufc);
+
+	/* Check that the checksums didn't change */
+	XNB_ASSERT(iph->ip_sum == htons(IP_CSUM));
+	XNB_ASSERT(tcp->th_sum == htons(TCP_CSUM));
+
+	m_freem(mbufc);
+}
+
+/**
+ * sscanf on unsigned chars
+ */
+static void
+xnb_sscanf_hhu(char *buffer, size_t buflen)
+{
+	const char mystr[] = "137";
+	uint8_t dest[12];
+	int i;
+
+	for (i = 0; i < 12; i++)
+		dest[i] = 'X';
+
+	sscanf(mystr, "%hhu", &dest[4]);
+	for (i = 0; i < 12; i++)
+		XNB_ASSERT(dest[i] == (i == 4 ? 137 : 'X'));
+}
+
+/**
+ * sscanf on signed chars
+ */
+static void
+xnb_sscanf_hhd(char *buffer, size_t buflen)
+{
+	const char mystr[] = "-27";
+	int8_t dest[12];
+	int i;
+
+	for (i = 0; i < 12; i++)
+		dest[i] = 'X';
+
+	sscanf(mystr, "%hhd", &dest[4]);
+	for (i = 0; i < 12; i++)
+		XNB_ASSERT(dest[i] == (i == 4 ? -27 : 'X'));
+}
+
+/**
+ * sscanf on signed long longs
+ */
+static void
+xnb_sscanf_lld(char *buffer, size_t buflen)
+{
+	const char mystr[] = "-123456789012345";	/* about -2**47 */
+	long long dest[3];
+	int i;
+
+	for (i = 0; i < 3; i++)
+		dest[i] = (long long)0xdeadbeefdeadbeef;
+
+	sscanf(mystr, "%lld", &dest[1]);
+	for (i = 0; i < 3; i++)
+		XNB_ASSERT(dest[i] == (i != 1 ? (long long)0xdeadbeefdeadbeef :
+		    -123456789012345));
+}
+
+/**
+ * sscanf on unsigned long longs
+ */
+static void
+xnb_sscanf_llu(char *buffer, size_t buflen)
+{
+	const char mystr[] = "12802747070103273189";
+	unsigned long long dest[3];
+	int i;
+
+	for (i = 0; i < 3; i++)
+		dest[i] = (long long)0xdeadbeefdeadbeef;
+
+	sscanf(mystr, "%llu", &dest[1]);
+	for (i = 0; i < 3; i++)
+		XNB_ASSERT(dest[i] == (i != 1 ? (long long)0xdeadbeefdeadbeef :
+		    12802747070103273189ull));
+}
+
+/**
+ * sscanf on unsigned short short n's
+ */
+static void
+xnb_sscanf_hhn(char *buffer, size_t buflen)
+{
+	const char mystr[] =
+	    "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f"
+	    "202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f"
+	    "404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f";
+	unsigned char dest[12];
+	int i;
+
+	for (i = 0; i < 12; i++)
+		dest[i] = (unsigned char)'X';
+
+	sscanf(mystr,
+	    "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f"
+	    "202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f"
+	    "404142434445464748494a4b4c4d4e4f%hhn", &dest[4]);
+	for (i = 0; i < 12; i++)
+		XNB_ASSERT(dest[i] == (i == 4 ? 160 : 'X'));
+}
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/gnu/dev/sound/pci/maestro3_dsp.h
--- a/head/sys/gnu/dev/sound/pci/maestro3_dsp.h	Wed Feb 01 12:27:49 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,214 +0,0 @@
-/* $FreeBSD$ */
-/*-
- *      ESS Technology allegro audio driver.
- *
- *      Copyright (C) 1992-2000  Don Kim (don.kim at esstech.com)
- *
- *      This program is free software; you can redistribute it and/or modify
- *      it under the terms of the GNU General Public License as published by
- *      the Free Software Foundation; either version 2 of the License, or
- *      (at your option) any later version.
- *
- *      This program is distributed in the hope that it will be useful,
- *      but WITHOUT ANY WARRANTY; without even the implied warranty of
- *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *      GNU General Public License for more details.
- *
- *      You should have received a copy of the GNU General Public License
- *      along with this program; if not, write to the Free Software
- *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- *      Hacked for the maestro3 driver by zab
- */
-
-/*
- * DSP Code images
- */
-
-u_int16_t assp_kernel_image[] = {
-    0x7980, 0x0030, 0x7980, 0x03B4, 0x7980, 0x03B4, 0x7980, 0x00FB, 0x7980, 0x00DD, 0x7980, 0x03B4, 
-    0x7980, 0x0332, 0x7980, 0x0287, 0x7980, 0x03B4, 0x7980, 0x03B4, 0x7980, 0x03B4, 0x7980, 0x03B4, 
-    0x7980, 0x031A, 0x7980, 0x03B4, 0x7980, 0x022F, 0x7980, 0x03B4, 0x7980, 0x03B4, 0x7980, 0x03B4, 
-    0x7980, 0x03B4, 0x7980, 0x03B4, 0x7980, 0x0063, 0x7980, 0x006B, 0x7980, 0x03B4, 0x7980, 0x03B4, 
-    0xBF80, 0x2C7C, 0x8806, 0x8804, 0xBE40, 0xBC20, 0xAE09, 0x1000, 0xAE0A, 0x0001, 0x6938, 0xEB08, 
-    0x0053, 0x695A, 0xEB08, 0x00D6, 0x0009, 0x8B88, 0x6980, 0xE388, 0x0036, 0xBE30, 0xBC20, 0x6909, 
-    0xB801, 0x9009, 0xBE41, 0xBE41, 0x6928, 0xEB88, 0x0078, 0xBE41, 0xBE40, 0x7980, 0x0038, 0xBE41, 
-    0xBE41, 0x903A, 0x6938, 0xE308, 0x0056, 0x903A, 0xBE41, 0xBE40, 0xEF00, 0x903A, 0x6939, 0xE308, 
-    0x005E, 0x903A, 0xEF00, 0x690B, 0x660C, 0xEF8C, 0x690A, 0x660C, 0x620B, 0x6609, 0xEF00, 0x6910, 
-    0x660F, 0xEF04, 0xE388, 0x0075, 0x690E, 0x660F, 0x6210, 0x660D, 0xEF00, 0x690E, 0x660D, 0xEF00, 
-    0xAE70, 0x0001, 0xBC20, 0xAE27, 0x0001, 0x6939, 0xEB08, 0x005D, 0x6926, 0xB801, 0x9026, 0x0026, 
-    0x8B88, 0x6980, 0xE388, 0x00CB, 0x9028, 0x0D28, 0x4211, 0xE100, 0x007A, 0x4711, 0xE100, 0x00A0, 
-    0x7A80, 0x0063, 0xB811, 0x660A, 0x6209, 0xE304, 0x007A, 0x0C0B, 0x4005, 0x100A, 0xBA01, 0x9012, 
-    0x0C12, 0x4002, 0x7980, 0x00AF, 0x7A80, 0x006B, 0xBE02, 0x620E, 0x660D, 0xBA10, 0xE344, 0x007A, 
-    0x0C10, 0x4005, 0x100E, 0xBA01, 0x9012, 0x0C12, 0x4002, 0x1003, 0xBA02, 0x9012, 0x0C12, 0x4000, 
-    0x1003, 0xE388, 0x00BA, 0x1004, 0x7980, 0x00BC, 0x1004, 0xBA01, 0x9012, 0x0C12, 0x4001, 0x0C05, 
-    0x4003, 0x0C06, 0x4004, 0x1011, 0xBFB0, 0x01FF, 0x9012, 0x0C12, 0x4006, 0xBC20, 0xEF00, 0xAE26, 
-    0x1028, 0x6970, 0xBFD0, 0x0001, 0x9070, 0xE388, 0x007A, 0xAE28, 0x0000, 0xEF00, 0xAE70, 0x0300, 
-    0x0C70, 0xB00C, 0xAE5A, 0x0000, 0xEF00, 0x7A80, 0x038A, 0x697F, 0xB801, 0x907F, 0x0056, 0x8B88, 
-    0x0CA0, 0xB008, 0xAF71, 0xB000, 0x4E71, 0xE200, 0x00F3, 0xAE56, 0x1057, 0x0056, 0x0CA0, 0xB008, 
-    0x8056, 0x7980, 0x03A1, 0x0810, 0xBFA0, 0x1059, 0xE304, 0x03A1, 0x8056, 0x7980, 0x03A1, 0x7A80, 
-    0x038A, 0xBF01, 0xBE43, 0xBE59, 0x907C, 0x6937, 0xE388, 0x010D, 0xBA01, 0xE308, 0x010C, 0xAE71, 
-    0x0004, 0x0C71, 0x5000, 0x6936, 0x9037, 0xBF0A, 0x109E, 0x8B8A, 0xAF80, 0x8014, 0x4C80, 0xBF0A, 
-    0x0560, 0xF500, 0xBF0A, 0x0520, 0xB900, 0xBB17, 0x90A0, 0x6917, 0xE388, 0x0148, 0x0D17, 0xE100, 
-    0x0127, 0xBF0C, 0x0578, 0xBF0D, 0x057C, 0x7980, 0x012B, 0xBF0C, 0x0538, 0xBF0D, 0x053C, 0x6900, 
-    0xE308, 0x0135, 0x8B8C, 0xBE59, 0xBB07, 0x90A0, 0xBC20, 0x7980, 0x0157, 0x030C, 0x8B8B, 0xB903, 
-    0x8809, 0xBEC6, 0x013E, 0x69AC, 0x90AB, 0x69AD, 0x90AB, 0x0813, 0x660A, 0xE344, 0x0144, 0x0309, 
-    0x830C, 0xBC20, 0x7980, 0x0157, 0x6955, 0xE388, 0x0157, 0x7C38, 0xBF0B, 0x0578, 0xF500, 0xBF0B, 
-    0x0538, 0xB907, 0x8809, 0xBEC6, 0x0156, 0x10AB, 0x90AA, 0x6974, 0xE388, 0x0163, 0xAE72, 0x0540, 
-    0xF500, 0xAE72, 0x0500, 0xAE61, 0x103B, 0x7A80, 0x02F6, 0x6978, 0xE388, 0x0182, 0x8B8C, 0xBF0C, 
-    0x0560, 0xE500, 0x7C40, 0x0814, 0xBA20, 0x8812, 0x733D, 0x7A80, 0x0380, 0x733E, 0x7A80, 0x0380, 
-    0x8B8C, 0xBF0C, 0x056C, 0xE500, 0x7C40, 0x0814, 0xBA2C, 0x8812, 0x733F, 0x7A80, 0x0380, 0x7340, 
-    0x7A80, 0x0380, 0x6975, 0xE388, 0x018E, 0xAE72, 0x0548, 0xF500, 0xAE72, 0x0508, 0xAE61, 0x1041, 
-    0x7A80, 0x02F6, 0x6979, 0xE388, 0x01AD, 0x8B8C, 0xBF0C, 0x0560, 0xE500, 0x7C40, 0x0814, 0xBA18, 
-    0x8812, 0x7343, 0x7A80, 0x0380, 0x7344, 0x7A80, 0x0380, 0x8B8C, 0xBF0C, 0x056C, 0xE500, 0x7C40, 
-    0x0814, 0xBA24, 0x8812, 0x7345, 0x7A80, 0x0380, 0x7346, 0x7A80, 0x0380, 0x6976, 0xE388, 0x01B9, 
-    0xAE72, 0x0558, 0xF500, 0xAE72, 0x0518, 0xAE61, 0x1047, 0x7A80, 0x02F6, 0x697A, 0xE388, 0x01D8, 
-    0x8B8C, 0xBF0C, 0x0560, 0xE500, 0x7C40, 0x0814, 0xBA08, 0x8812, 0x7349, 0x7A80, 0x0380, 0x734A, 
-    0x7A80, 0x0380, 0x8B8C, 0xBF0C, 0x056C, 0xE500, 0x7C40, 0x0814, 0xBA14, 0x8812, 0x734B, 0x7A80, 
-    0x0380, 0x734C, 0x7A80, 0x0380, 0xBC21, 0xAE1C, 0x1090, 0x8B8A, 0xBF0A, 0x0560, 0xE500, 0x7C40, 
-    0x0812, 0xB804, 0x8813, 0x8B8D, 0xBF0D, 0x056C, 0xE500, 0x7C40, 0x0815, 0xB804, 0x8811, 0x7A80, 
-    0x034A, 0x8B8A, 0xBF0A, 0x0560, 0xE500, 0x7C40, 0x731F, 0xB903, 0x8809, 0xBEC6, 0x01F9, 0x548A, 
-    0xBE03, 0x98A0, 0x7320, 0xB903, 0x8809, 0xBEC6, 0x0201, 0x548A, 0xBE03, 0x98A0, 0x1F20, 0x2F1F, 
-    0x9826, 0xBC20, 0x6935, 0xE388, 0x03A1, 0x6933, 0xB801, 0x9033, 0xBFA0, 0x02EE, 0xE308, 0x03A1, 
-    0x9033, 0xBF00, 0x6951, 0xE388, 0x021F, 0x7334, 0xBE80, 0x5760, 0xBE03, 0x9F7E, 0xBE59, 0x9034, 
-    0x697E, 0x0D51, 0x9013, 0xBC20, 0x695C, 0xE388, 0x03A1, 0x735E, 0xBE80, 0x5760, 0xBE03, 0x9F7E, 
-    0xBE59, 0x905E, 0x697E, 0x0D5C, 0x9013, 0x7980, 0x03A1, 0x7A80, 0x038A, 0xBF01, 0xBE43, 0x6977, 
-    0xE388, 0x024E, 0xAE61, 0x104D, 0x0061, 0x8B88, 0x6980, 0xE388, 0x024E, 0x9071, 0x0D71, 0x000B, 
-    0xAFA0, 0x8010, 0xAFA0, 0x8010, 0x0810, 0x660A, 0xE308, 0x0249, 0x0009, 0x0810, 0x660C, 0xE388, 
-    0x024E, 0x800B, 0xBC20, 0x697B, 0xE388, 0x03A1, 0xBF0A, 0x109E, 0x8B8A, 0xAF80, 0x8014, 0x4C80, 
-    0xE100, 0x0266, 0x697C, 0xBF90, 0x0560, 0x9072, 0x0372, 0x697C, 0xBF90, 0x0564, 0x9073, 0x0473, 
-    0x7980, 0x0270, 0x697C, 0xBF90, 0x0520, 0x9072, 0x0372, 0x697C, 0xBF90, 0x0524, 0x9073, 0x0473, 
-    0x697C, 0xB801, 0x907C, 0xBF0A, 0x10FD, 0x8B8A, 0xAF80, 0x8010, 0x734F, 0x548A, 0xBE03, 0x9880, 
-    0xBC21, 0x7326, 0x548B, 0xBE03, 0x618B, 0x988C, 0xBE03, 0x6180, 0x9880, 0x7980, 0x03A1, 0x7A80, 
-    0x038A, 0x0D28, 0x4711, 0xE100, 0x02BE, 0xAF12, 0x4006, 0x6912, 0xBFB0, 0x0C00, 0xE388, 0x02B6, 
-    0xBFA0, 0x0800, 0xE388, 0x02B2, 0x6912, 0xBFB0, 0x0C00, 0xBFA0, 0x0400, 0xE388, 0x02A3, 0x6909, 
-    0x900B, 0x7980, 0x02A5, 0xAF0B, 0x4005, 0x6901, 0x9005, 0x6902, 0x9006, 0x4311, 0xE100, 0x02ED, 
-    0x6911, 0xBFC0, 0x2000, 0x9011, 0x7980, 0x02ED, 0x6909, 0x900B, 0x7980, 0x02B8, 0xAF0B, 0x4005, 
-    0xAF05, 0x4003, 0xAF06, 0x4004, 0x7980, 0x02ED, 0xAF12, 0x4006, 0x6912, 0xBFB0, 0x0C00, 0xE388, 
-    0x02E7, 0xBFA0, 0x0800, 0xE388, 0x02E3, 0x6912, 0xBFB0, 0x0C00, 0xBFA0, 0x0400, 0xE388, 0x02D4, 
-    0x690D, 0x9010, 0x7980, 0x02D6, 0xAF10, 0x4005, 0x6901, 0x9005, 0x6902, 0x9006, 0x4311, 0xE100, 
-    0x02ED, 0x6911, 0xBFC0, 0x2000, 0x9011, 0x7980, 0x02ED, 0x690D, 0x9010, 0x7980, 0x02E9, 0xAF10, 
-    0x4005, 0xAF05, 0x4003, 0xAF06, 0x4004, 0xBC20, 0x6970, 0x9071, 0x7A80, 0x0078, 0x6971, 0x9070, 
-    0x7980, 0x03A1, 0xBC20, 0x0361, 0x8B8B, 0x6980, 0xEF88, 0x0272, 0x0372, 0x7804, 0x9071, 0x0D71, 
-    0x8B8A, 0x000B, 0xB903, 0x8809, 0xBEC6, 0x0309, 0x69A8, 0x90AB, 0x69A8, 0x90AA, 0x0810, 0x660A, 
-    0xE344, 0x030F, 0x0009, 0x0810, 0x660C, 0xE388, 0x0314, 0x800B, 0xBC20, 0x6961, 0xB801, 0x9061, 
-    0x7980, 0x02F7, 0x7A80, 0x038A, 0x5D35, 0x0001, 0x6934, 0xB801, 0x9034, 0xBF0A, 0x109E, 0x8B8A, 
-    0xAF80, 0x8014, 0x4880, 0xAE72, 0x0550, 0xF500, 0xAE72, 0x0510, 0xAE61, 0x1051, 0x7A80, 0x02F6, 
-    0x7980, 0x03A1, 0x7A80, 0x038A, 0x5D35, 0x0002, 0x695E, 0xB801, 0x905E, 0xBF0A, 0x109E, 0x8B8A, 
-    0xAF80, 0x8014, 0x4780, 0xAE72, 0x0558, 0xF500, 0xAE72, 0x0518, 0xAE61, 0x105C, 0x7A80, 0x02F6, 
-    0x7980, 0x03A1, 0x001C, 0x8B88, 0x6980, 0xEF88, 0x901D, 0x0D1D, 0x100F, 0x6610, 0xE38C, 0x0358, 
-    0x690E, 0x6610, 0x620F, 0x660D, 0xBA0F, 0xE301, 0x037A, 0x0410, 0x8B8A, 0xB903, 0x8809, 0xBEC6, 
-    0x036C, 0x6A8C, 0x61AA, 0x98AB, 0x6A8C, 0x61AB, 0x98AD, 0x6A8C, 0x61AD, 0x98A9, 0x6A8C, 0x61A9, 
-    0x98AA, 0x7C04, 0x8B8B, 0x7C04, 0x8B8D, 0x7C04, 0x8B89, 0x7C04, 0x0814, 0x660E, 0xE308, 0x0379, 
-    0x040D, 0x8410, 0xBC21, 0x691C, 0xB801, 0x901C, 0x7980, 0x034A, 0xB903, 0x8809, 0x8B8A, 0xBEC6, 
-    0x0388, 0x54AC, 0xBE03, 0x618C, 0x98AA, 0xEF00, 0xBC20, 0xBE46, 0x0809, 0x906B, 0x080A, 0x906C, 
-    0x080B, 0x906D, 0x081A, 0x9062, 0x081B, 0x9063, 0x081E, 0x9064, 0xBE59, 0x881E, 0x8065, 0x8166, 
-    0x8267, 0x8368, 0x8469, 0x856A, 0xEF00, 0xBC20, 0x696B, 0x8809, 0x696C, 0x880A, 0x696D, 0x880B, 
-    0x6962, 0x881A, 0x6963, 0x881B, 0x6964, 0x881E, 0x0065, 0x0166, 0x0267, 0x0368, 0x0469, 0x056A, 
-    0xBE3A, 
-};
-
-/*
- * Mini sample rate converter code image
- * that is to be loaded at 0x400 on the DSP.
- */
-u_int16_t assp_minisrc_image[] = {
-    0xBF80, 0x101E, 0x906E, 0x006E, 0x8B88, 0x6980, 0xEF88, 0x906F, 0x0D6F, 0x6900, 0xEB08, 0x0412, 
-    0xBC20, 0x696E, 0xB801, 0x906E, 0x7980, 0x0403, 0xB90E, 0x8807, 0xBE43, 0xBF01, 0xBE47, 0xBE41, 
-    0x7A80, 0x002A, 0xBE40, 0x3029, 0xEFCC, 0xBE41, 0x7A80, 0x0028, 0xBE40, 0x3028, 0xEFCC, 0x6907, 
-    0xE308, 0x042A, 0x6909, 0x902C, 0x7980, 0x042C, 0x690D, 0x902C, 0x1009, 0x881A, 0x100A, 0xBA01, 
-    0x881B, 0x100D, 0x881C, 0x100E, 0xBA01, 0x881D, 0xBF80, 0x00ED, 0x881E, 0x050C, 0x0124, 0xB904, 
-    0x9027, 0x6918, 0xE308, 0x04B3, 0x902D, 0x6913, 0xBFA0, 0x7598, 0xF704, 0xAE2D, 0x00FF, 0x8B8D, 
-    0x6919, 0xE308, 0x0463, 0x691A, 0xE308, 0x0456, 0xB907, 0x8809, 0xBEC6, 0x0453, 0x10A9, 0x90AD, 
-    0x7980, 0x047C, 0xB903, 0x8809, 0xBEC6, 0x0460, 0x1889, 0x6C22, 0x90AD, 0x10A9, 0x6E23, 0x6C22, 
-    0x90AD, 0x7980, 0x047C, 0x101A, 0xE308, 0x046F, 0xB903, 0x8809, 0xBEC6, 0x046C, 0x10A9, 0x90A0, 
-    0x90AD, 0x7980, 0x047C, 0xB901, 0x8809, 0xBEC6, 0x047B, 0x1889, 0x6C22, 0x90A0, 0x90AD, 0x10A9, 
-    0x6E23, 0x6C22, 0x90A0, 0x90AD, 0x692D, 0xE308, 0x049C, 0x0124, 0xB703, 0xB902, 0x8818, 0x8B89, 
-    0x022C, 0x108A, 0x7C04, 0x90A0, 0x692B, 0x881F, 0x7E80, 0x055B, 0x692A, 0x8809, 0x8B89, 0x99A0, 
-    0x108A, 0x90A0, 0x692B, 0x881F, 0x7E80, 0x055B, 0x692A, 0x8809, 0x8B89, 0x99AF, 0x7B99, 0x0484, 
-    0x0124, 0x060F, 0x101B, 0x2013, 0x901B, 0xBFA0, 0x7FFF, 0xE344, 0x04AC, 0x901B, 0x8B89, 0x7A80, 
-    0x051A, 0x6927, 0xBA01, 0x9027, 0x7A80, 0x0523, 0x6927, 0xE308, 0x049E, 0x7980, 0x050F, 0x0624, 
-    0x1026, 0x2013, 0x9026, 0xBFA0, 0x7FFF, 0xE304, 0x04C0, 0x8B8D, 0x7A80, 0x051A, 0x7980, 0x04B4, 
-    0x9026, 0x1013, 0x3026, 0x901B, 0x8B8D, 0x7A80, 0x051A, 0x7A80, 0x0523, 0x1027, 0xBA01, 0x9027, 
-    0xE308, 0x04B4, 0x0124, 0x060F, 0x8B89, 0x691A, 0xE308, 0x04EA, 0x6919, 0xE388, 0x04E0, 0xB903, 
-    0x8809, 0xBEC6, 0x04DD, 0x1FA0, 0x2FAE, 0x98A9, 0x7980, 0x050F, 0xB901, 0x8818, 0xB907, 0x8809, 
-    0xBEC6, 0x04E7, 0x10EE, 0x90A9, 0x7980, 0x050F, 0x6919, 0xE308, 0x04FE, 0xB903, 0x8809, 0xBE46, 
-    0xBEC6, 0x04FA, 0x17A0, 0xBE1E, 0x1FAE, 0xBFBF, 0xFF00, 0xBE13, 0xBFDF, 0x8080, 0x99A9, 0xBE47, 
-    0x7980, 0x050F, 0xB901, 0x8809, 0xBEC6, 0x050E, 0x16A0, 0x26A0, 0xBFB7, 0xFF00, 0xBE1E, 0x1EA0, 
-    0x2EAE, 0xBFBF, 0xFF00, 0xBE13, 0xBFDF, 0x8080, 0x99A9, 0x850C, 0x860F, 0x6907, 0xE388, 0x0516, 
-    0x0D07, 0x8510, 0xBE59, 0x881E, 0xBE4A, 0xEF00, 0x101E, 0x901C, 0x101F, 0x901D, 0x10A0, 0x901E, 
-    0x10A0, 0x901F, 0xEF00, 0x101E, 0x301C, 0x9020, 0x731B, 0x5420, 0xBE03, 0x9825, 0x1025, 0x201C, 
-    0x9025, 0x7325, 0x5414, 0xBE03, 0x8B8E, 0x9880, 0x692F, 0xE388, 0x0539, 0xBE59, 0xBB07, 0x6180, 
-    0x9880, 0x8BA0, 0x101F, 0x301D, 0x9021, 0x731B, 0x5421, 0xBE03, 0x982E, 0x102E, 0x201D, 0x902E, 
-    0x732E, 0x5415, 0xBE03, 0x9880, 0x692F, 0xE388, 0x054F, 0xBE59, 0xBB07, 0x6180, 0x9880, 0x8BA0, 
-    0x6918, 0xEF08, 0x7325, 0x5416, 0xBE03, 0x98A0, 0x732E, 0x5417, 0xBE03, 0x98A0, 0xEF00, 0x8BA0, 
-    0xBEC6, 0x056B, 0xBE59, 0xBB04, 0xAA90, 0xBE04, 0xBE1E, 0x99E0, 0x8BE0, 0x69A0, 0x90D0, 0x69A0, 
-    0x90D0, 0x081F, 0xB805, 0x881F, 0x8B90, 0x69A0, 0x90D0, 0x69A0, 0x9090, 0x8BD0, 0x8BD8, 0xBE1F, 
-    0xEF00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 
-};
-
-u_int16_t minisrc_lpf_image[] = {
-	0X0743, 0X1104, 0X0A4C, 0XF88D, 0X242C,
-	0X1023, 0X1AA9, 0X0B60, 0XEFDD, 0X186F
-};
-
-/*
- * an arbitrary volume we set the internal volume settings to so that the
- * ac97 volume range is a little less insane.  0x7fff is max.
- */
-#define ARB_VOLUME 0x6800
-
-static struct play_vals {
-	u_int16_t addr, val;
-} pv[] = {
-	{CDATA_LEFT_VOLUME, ARB_VOLUME},
-	{CDATA_RIGHT_VOLUME, ARB_VOLUME},
-	{SRC3_DIRECTION_OFFSET, 0} ,
-	/* +1, +2 are stereo/16 bit */
-	{SRC3_DIRECTION_OFFSET + 3, 0x0000}, /* fraction? */
-	{SRC3_DIRECTION_OFFSET + 4, 0}, /* first l */
-	{SRC3_DIRECTION_OFFSET + 5, 0}, /* first r */
-	{SRC3_DIRECTION_OFFSET + 6, 0}, /* second l */
-	{SRC3_DIRECTION_OFFSET + 7, 0}, /* second r */
-	{SRC3_DIRECTION_OFFSET + 8, 0}, /* delta l */
-	{SRC3_DIRECTION_OFFSET + 9, 0}, /* delta r */
-	{SRC3_DIRECTION_OFFSET + 10, 0x8000}, /* round */
-	{SRC3_DIRECTION_OFFSET + 11, 0xFF00}, /* higher bute mark */
-	{SRC3_DIRECTION_OFFSET + 13, 0}, /* temp0 */
-	{SRC3_DIRECTION_OFFSET + 14, 0}, /* c fraction */
-	{SRC3_DIRECTION_OFFSET + 15, 0}, /* counter */
-	{SRC3_DIRECTION_OFFSET + 16, 8}, /* numin */
-	{SRC3_DIRECTION_OFFSET + 17, 50*2}, /* numout */
-	{SRC3_DIRECTION_OFFSET + 18, MINISRC_BIQUAD_STAGE - 1}, /* numstage */
-	{SRC3_DIRECTION_OFFSET + 20, 0}, /* filtertap */
-	{SRC3_DIRECTION_OFFSET + 21, 0} /* booster */
-};
-
-static struct rec_vals {
-	u_int16_t addr, val;
-} rv[] = {
-	{CDATA_LEFT_VOLUME, ARB_VOLUME},
-	{CDATA_RIGHT_VOLUME, ARB_VOLUME},
-	{SRC3_DIRECTION_OFFSET, 1},
-	/* +1, +2 are stereo/16 bit */
-	{SRC3_DIRECTION_OFFSET + 3, 0x0000}, /* fraction? */
-	{SRC3_DIRECTION_OFFSET + 4, 0}, /* first l */
-	{SRC3_DIRECTION_OFFSET + 5, 0}, /* first r */
-	{SRC3_DIRECTION_OFFSET + 6, 0}, /* second l */
-	{SRC3_DIRECTION_OFFSET + 7, 0}, /* second r */
-	{SRC3_DIRECTION_OFFSET + 8, 0}, /* delta l */
-	{SRC3_DIRECTION_OFFSET + 9, 0}, /* delta r */
-	{SRC3_DIRECTION_OFFSET + 10, 0x8000}, /* round */
-	{SRC3_DIRECTION_OFFSET + 11, 0xFF00}, /* higher bute mark */
-	{SRC3_DIRECTION_OFFSET + 13, 0}, /* temp0 */
-	{SRC3_DIRECTION_OFFSET + 14, 0}, /* c fraction */
-	{SRC3_DIRECTION_OFFSET + 15, 0}, /* counter */
-	{SRC3_DIRECTION_OFFSET + 16, 50},/* numin */
-	{SRC3_DIRECTION_OFFSET + 17, 8}, /* numout */
-	{SRC3_DIRECTION_OFFSET + 18, 0}, /* numstage */
-	{SRC3_DIRECTION_OFFSET + 19, 0}, /* coef */
-	{SRC3_DIRECTION_OFFSET + 20, 0}, /* filtertap */
-	{SRC3_DIRECTION_OFFSET + 21, 0}, /* booster */
-	{SRC3_DIRECTION_OFFSET + 22, 0xff} /* skip lpf */
-};
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/gnu/dev/sound/pci/maestro3_reg.h
--- a/head/sys/gnu/dev/sound/pci/maestro3_reg.h	Wed Feb 01 12:27:49 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,692 +0,0 @@
-/* $FreeBSD$ */
-/*-
- *      ESS Technology allegro audio driver.
- *
- *      Copyright (C) 1992-2000  Don Kim (don.kim at esstech.com)
- *
- *      This program is free software; you can redistribute it and/or modify
- *      it under the terms of the GNU General Public License as published by
- *      the Free Software Foundation; either version 2 of the License, or
- *      (at your option) any later version.
- *
- *      This program is distributed in the hope that it will be useful,
- *      but WITHOUT ANY WARRANTY; without even the implied warranty of
- *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *      GNU General Public License for more details.
- *
- *      You should have received a copy of the GNU General Public License
- *      along with this program; if not, write to the Free Software
- *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- *      Hacked for the maestro3 driver by zab
- */
-
-/* Allegro PCI configuration registers */
-#define PCI_LEGACY_AUDIO_CTRL   0x40
-#define SOUND_BLASTER_ENABLE    0x00000001
-#define FM_SYNTHESIS_ENABLE     0x00000002
-#define GAME_PORT_ENABLE        0x00000004
-#define MPU401_IO_ENABLE        0x00000008
-#define MPU401_IRQ_ENABLE       0x00000010
-#define ALIAS_10BIT_IO          0x00000020
-#define SB_DMA_MASK             0x000000C0
-#define SB_DMA_0                0x00000040
-#define SB_DMA_1                0x00000040
-#define SB_DMA_R                0x00000080
-#define SB_DMA_3                0x000000C0
-#define SB_IRQ_MASK             0x00000700
-#define SB_IRQ_5                0x00000000
-#define SB_IRQ_7                0x00000100
-#define SB_IRQ_9                0x00000200
-#define SB_IRQ_10               0x00000300
-#define MIDI_IRQ_MASK           0x00003800
-#define SERIAL_IRQ_ENABLE       0x00004000
-#define DISABLE_LEGACY          0x00008000
-
-#define PCI_ALLEGRO_CONFIG      0x50
-#define SB_ADDR_240             0x00000004
-#define MPU_ADDR_MASK           0x00000018
-#define MPU_ADDR_330            0x00000000
-#define MPU_ADDR_300            0x00000008
-#define MPU_ADDR_320            0x00000010
-#define MPU_ADDR_340            0x00000018
-#define USE_PCI_TIMING          0x00000040
-#define POSTED_WRITE_ENABLE     0x00000080
-#define DMA_POLICY_MASK         0x00000700
-#define DMA_DDMA                0x00000000
-#define DMA_TDMA                0x00000100
-#define DMA_PCPCI               0x00000200
-#define DMA_WBDMA16             0x00000400
-#define DMA_WBDMA4              0x00000500
-#define DMA_WBDMA2              0x00000600
-#define DMA_WBDMA1              0x00000700
-#define DMA_SAFE_GUARD          0x00000800
-#define HI_PERF_GP_ENABLE       0x00001000
-#define PIC_SNOOP_MODE_0        0x00002000
-#define PIC_SNOOP_MODE_1        0x00004000
-#define SOUNDBLASTER_IRQ_MASK   0x00008000
-#define RING_IN_ENABLE          0x00010000
-#define SPDIF_TEST_MODE         0x00020000
-#define CLK_MULT_MODE_SELECT_2  0x00040000
-#define EEPROM_WRITE_ENABLE     0x00080000
-#define CODEC_DIR_IN            0x00100000
-#define HV_BUTTON_FROM_GD       0x00200000
-#define REDUCED_DEBOUNCE        0x00400000
-#define HV_CTRL_ENABLE          0x00800000
-#define SPDIF_ENABLE            0x01000000
-#define CLK_DIV_SELECT          0x06000000
-#define CLK_DIV_BY_48           0x00000000
-#define CLK_DIV_BY_49           0x02000000
-#define CLK_DIV_BY_50           0x04000000
-#define CLK_DIV_RESERVED        0x06000000
-#define PM_CTRL_ENABLE          0x08000000
-#define CLK_MULT_MODE_SELECT    0x30000000
-#define CLK_MULT_MODE_SHIFT     28
-#define CLK_MULT_MODE_0         0x00000000
-#define CLK_MULT_MODE_1         0x10000000
-#define CLK_MULT_MODE_2         0x20000000
-#define CLK_MULT_MODE_3         0x30000000
-#define INT_CLK_SELECT          0x40000000
-#define INT_CLK_MULT_RESET      0x80000000
-
-/* M3 */
-#define INT_CLK_SRC_NOT_PCI     0x00100000
-#define INT_CLK_MULT_ENABLE     0x80000000
-
-#define PCI_ACPI_CONTROL        0x54
-#define PCI_ACPI_D0             0x00000000
-#define PCI_ACPI_D1             0xB4F70000
-#define PCI_ACPI_D2             0xB4F7B4F7
-
-#define PCI_USER_CONFIG         0x58
-#define EXT_PCI_MASTER_ENABLE   0x00000001
-#define SPDIF_OUT_SELECT        0x00000002
-#define TEST_PIN_DIR_CTRL       0x00000004
-#define AC97_CODEC_TEST         0x00000020
-#define TRI_STATE_BUFFER        0x00000080
-#define IN_CLK_12MHZ_SELECT     0x00000100
-#define MULTI_FUNC_DISABLE      0x00000200
-#define EXT_MASTER_PAIR_SEL     0x00000400
-#define PCI_MASTER_SUPPORT      0x00000800
-#define STOP_CLOCK_ENABLE       0x00001000
-#define EAPD_DRIVE_ENABLE       0x00002000
-#define REQ_TRI_STATE_ENABLE    0x00004000
-#define REQ_LOW_ENABLE          0x00008000
-#define MIDI_1_ENABLE           0x00010000
-#define MIDI_2_ENABLE           0x00020000
-#define SB_AUDIO_SYNC           0x00040000
-#define HV_CTRL_TEST            0x00100000
-#define SOUNDBLASTER_TEST       0x00400000
-
-#define PCI_USER_CONFIG_C       0x5C
-
-#define PCI_DDMA_CTRL           0x60
-#define DDMA_ENABLE             0x00000001
-
-
-/* Allegro registers */
-#define HOST_INT_CTRL           0x18
-#define SB_INT_ENABLE           0x0001
-#define MPU401_INT_ENABLE       0x0002
-#define ASSP_INT_ENABLE         0x0010
-#define RING_INT_ENABLE         0x0020
-#define HV_INT_ENABLE           0x0040
-#define CLKRUN_GEN_ENABLE       0x0100
-#define HV_CTRL_TO_PME          0x0400
-#define SOFTWARE_RESET_ENABLE   0x8000
-
-/*
- * should be using the above defines, probably.
- */
-#define REGB_ENABLE_RESET       0x01
-#define REGB_STOP_CLOCK         0x10
-
-#define HOST_INT_STATUS         0x1A
-#define SB_INT_PENDING          0x01
-#define MPU401_INT_PENDING      0x02
-#define ASSP_INT_PENDING        0x10
-#define RING_INT_PENDING        0x20
-#define HV_INT_PENDING          0x40
-
-#define HARDWARE_VOL_CTRL       0x1B
-#define SHADOW_MIX_REG_VOICE    0x1C
-#define HW_VOL_COUNTER_VOICE    0x1D
-#define SHADOW_MIX_REG_MASTER   0x1E
-#define HW_VOL_COUNTER_MASTER   0x1F
-
-#define CODEC_COMMAND           0x30
-#define CODEC_READ_B            0x80
-
-#define CODEC_STATUS            0x30
-#define CODEC_BUSY_B            0x01
-
-#define CODEC_DATA              0x32
-
-#define RING_BUS_CTRL_A         0x36
-#define RAC_PME_ENABLE          0x0100
-#define RAC_SDFS_ENABLE         0x0200
-#define LAC_PME_ENABLE          0x0400
-#define LAC_SDFS_ENABLE         0x0800
-#define SERIAL_AC_LINK_ENABLE   0x1000
-#define IO_SRAM_ENABLE          0x2000
-#define IIS_INPUT_ENABLE        0x8000
-
-#define RING_BUS_CTRL_B         0x38
-#define SECOND_CODEC_ID_MASK    0x0003
-#define SPDIF_FUNC_ENABLE       0x0010
-#define SECOND_AC_ENABLE        0x0020
-#define SB_MODULE_INTF_ENABLE   0x0040
-#define SSPE_ENABLE             0x0040
-#define M3I_DOCK_ENABLE         0x0080
-
-#define SDO_OUT_DEST_CTRL       0x3A
-#define COMMAND_ADDR_OUT        0x0003
-#define PCM_LR_OUT_LOCAL        0x0000
-#define PCM_LR_OUT_REMOTE       0x0004
-#define PCM_LR_OUT_MUTE         0x0008
-#define PCM_LR_OUT_BOTH         0x000C
-#define LINE1_DAC_OUT_LOCAL     0x0000
-#define LINE1_DAC_OUT_REMOTE    0x0010
-#define LINE1_DAC_OUT_MUTE      0x0020
-#define LINE1_DAC_OUT_BOTH      0x0030
-#define PCM_CLS_OUT_LOCAL       0x0000
-#define PCM_CLS_OUT_REMOTE      0x0040
-#define PCM_CLS_OUT_MUTE        0x0080
-#define PCM_CLS_OUT_BOTH        0x00C0
-#define PCM_RLF_OUT_LOCAL       0x0000
-#define PCM_RLF_OUT_REMOTE      0x0100
-#define PCM_RLF_OUT_MUTE        0x0200
-#define PCM_RLF_OUT_BOTH        0x0300
-#define LINE2_DAC_OUT_LOCAL     0x0000
-#define LINE2_DAC_OUT_REMOTE    0x0400
-#define LINE2_DAC_OUT_MUTE      0x0800
-#define LINE2_DAC_OUT_BOTH      0x0C00
-#define HANDSET_OUT_LOCAL       0x0000
-#define HANDSET_OUT_REMOTE      0x1000
-#define HANDSET_OUT_MUTE        0x2000
-#define HANDSET_OUT_BOTH        0x3000
-#define IO_CTRL_OUT_LOCAL       0x0000
-#define IO_CTRL_OUT_REMOTE      0x4000
-#define IO_CTRL_OUT_MUTE        0x8000
-#define IO_CTRL_OUT_BOTH        0xC000
-
-#define SDO_IN_DEST_CTRL        0x3C
-#define STATUS_ADDR_IN          0x0003
-#define PCM_LR_IN_LOCAL         0x0000
-#define PCM_LR_IN_REMOTE        0x0004
-#define PCM_LR_RESERVED         0x0008
-#define PCM_LR_IN_BOTH          0x000C
-#define LINE1_ADC_IN_LOCAL      0x0000
-#define LINE1_ADC_IN_REMOTE     0x0010
-#define LINE1_ADC_IN_MUTE       0x0020
-#define MIC_ADC_IN_LOCAL        0x0000
-#define MIC_ADC_IN_REMOTE       0x0040
-#define MIC_ADC_IN_MUTE         0x0080
-#define LINE2_DAC_IN_LOCAL      0x0000
-#define LINE2_DAC_IN_REMOTE     0x0400
-#define LINE2_DAC_IN_MUTE       0x0800
-#define HANDSET_IN_LOCAL        0x0000
-#define HANDSET_IN_REMOTE       0x1000
-#define HANDSET_IN_MUTE         0x2000
-#define IO_STATUS_IN_LOCAL      0x0000
-#define IO_STATUS_IN_REMOTE     0x4000
-
-#define SPDIF_IN_CTRL           0x3E
-#define SPDIF_IN_ENABLE         0x0001
-
-#define GPIO_DATA               0x60
-#define GPIO_DATA_MASK          0x0FFF
-#define GPIO_HV_STATUS          0x3000
-#define GPIO_PME_STATUS         0x4000
-
-#define GPIO_MASK               0x64
-#define GPIO_DIRECTION          0x68
-#define GPO_PRIMARY_AC97        0x0001
-#define GPI_LINEOUT_SENSE       0x0004
-#define GPO_SECONDARY_AC97      0x0008
-#define GPI_VOL_DOWN            0x0010
-#define GPI_VOL_UP              0x0020
-#define GPI_IIS_CLK             0x0040
-#define GPI_IIS_LRCLK           0x0080
-#define GPI_IIS_DATA            0x0100
-#define GPI_DOCKING_STATUS      0x0100
-#define GPI_HEADPHONE_SENSE     0x0200
-#define GPO_EXT_AMP_SHUTDOWN    0x1000
-
-/* M3 */
-#define GPO_M3_EXT_AMP_SHUTDN   0x0002
-
-#define ASSP_INDEX_PORT         0x80
-#define ASSP_MEMORY_PORT        0x82
-#define ASSP_DATA_PORT          0x84
-
-#define MPU401_DATA_PORT        0x98
-#define MPU401_STATUS_PORT      0x99
-
-#define CLK_MULT_DATA_PORT      0x9C
-
-#define ASSP_CONTROL_A          0xA2
-#define ASSP_0_WS_ENABLE        0x01
-#define ASSP_CTRL_A_RESERVED1   0x02
-#define ASSP_CTRL_A_RESERVED2   0x04
-#define ASSP_CLK_49MHZ_SELECT   0x08
-#define FAST_PLU_ENABLE         0x10
-#define ASSP_CTRL_A_RESERVED3   0x20
-#define DSP_CLK_36MHZ_SELECT    0x40
-
-#define ASSP_CONTROL_B          0xA4
-#define RESET_ASSP              0x00
-#define RUN_ASSP                0x01
-#define ENABLE_ASSP_CLOCK       0x00
-#define STOP_ASSP_CLOCK         0x10
-#define RESET_TOGGLE            0x40
-
-#define ASSP_CONTROL_C          0xA6
-#define ASSP_HOST_INT_ENABLE    0x01
-#define FM_ADDR_REMAP_DISABLE   0x02
-#define HOST_WRITE_PORT_ENABLE  0x08
-
-#define ASSP_HOST_INT_STATUS    0xAC
-#define DSP2HOST_REQ_PIORECORD  0x01
-#define DSP2HOST_REQ_I2SRATE    0x02
-#define DSP2HOST_REQ_TIMER      0x04
-
-/* AC97 registers */
-/* XXX fix this crap up */
-/*#define AC97_RESET              0x00*/
-
-#define AC97_VOL_MUTE_B         0x8000
-#define AC97_VOL_M              0x1F
-#define AC97_LEFT_VOL_S         8
-
-#define AC97_MASTER_VOL         0x02
-#define AC97_LINE_LEVEL_VOL     0x04
-#define AC97_MASTER_MONO_VOL    0x06
-#define AC97_PC_BEEP_VOL        0x0A
-#define AC97_PC_BEEP_VOL_M      0x0F
-#define AC97_SROUND_MASTER_VOL  0x38
-#define AC97_PC_BEEP_VOL_S      1
-
-/*#define AC97_PHONE_VOL          0x0C
-#define AC97_MIC_VOL            0x0E*/
-#define AC97_MIC_20DB_ENABLE    0x40
-
-/*#define AC97_LINEIN_VOL         0x10
-#define AC97_CD_VOL             0x12
-#define AC97_VIDEO_VOL          0x14
-#define AC97_AUX_VOL            0x16*/
-#define AC97_PCM_OUT_VOL        0x18
-/*#define AC97_RECORD_SELECT      0x1A*/
-#define AC97_RECORD_MIC         0x00
-#define AC97_RECORD_CD          0x01
-#define AC97_RECORD_VIDEO       0x02
-#define AC97_RECORD_AUX         0x03
-#define AC97_RECORD_MONO_MUX    0x02
-#define AC97_RECORD_DIGITAL     0x03
-#define AC97_RECORD_LINE        0x04
-#define AC97_RECORD_STEREO      0x05
-#define AC97_RECORD_MONO        0x06
-#define AC97_RECORD_PHONE       0x07
-
-/*#define AC97_RECORD_GAIN        0x1C*/
-#define AC97_RECORD_VOL_M       0x0F
-
-/*#define AC97_GENERAL_PURPOSE    0x20*/
-#define AC97_POWER_DOWN_CTRL    0x26
-#define AC97_ADC_READY          0x0001
-#define AC97_DAC_READY          0x0002
-#define AC97_ANALOG_READY       0x0004
-#define AC97_VREF_ON            0x0008
-#define AC97_PR0                0x0100
-#define AC97_PR1                0x0200
-#define AC97_PR2                0x0400
-#define AC97_PR3                0x0800
-#define AC97_PR4                0x1000
-
-#define AC97_RESERVED1          0x28
-
-#define AC97_VENDOR_TEST        0x5A
-
-#define AC97_CLOCK_DELAY        0x5C
-#define AC97_LINEOUT_MUX_SEL    0x0001
-#define AC97_MONO_MUX_SEL       0x0002
-#define AC97_CLOCK_DELAY_SEL    0x1F
-#define AC97_DAC_CDS_SHIFT      6
-#define AC97_ADC_CDS_SHIFT      11
-
-#define AC97_MULTI_CHANNEL_SEL  0x74
-
-/*#define AC97_VENDOR_ID1         0x7C
-#define AC97_VENDOR_ID2         0x7E*/
-
-/*
- * ASSP control regs
- */
-#define DSP_PORT_TIMER_COUNT    0x06
-
-#define DSP_PORT_MEMORY_INDEX   0x80
-
-#define DSP_PORT_MEMORY_TYPE    0x82
-#define MEMTYPE_INTERNAL_CODE   0x0002
-#define MEMTYPE_INTERNAL_DATA   0x0003
-#define MEMTYPE_MASK            0x0003
-
-#define DSP_PORT_MEMORY_DATA    0x84
-
-#define DSP_PORT_CONTROL_REG_A  0xA2
-#define DSP_PORT_CONTROL_REG_B  0xA4
-#define DSP_PORT_CONTROL_REG_C  0xA6
-
-#define REV_A_CODE_MEMORY_BEGIN         0x0000
-#define REV_A_CODE_MEMORY_END           0x0FFF
-#define REV_A_CODE_MEMORY_UNIT_LENGTH   0x0040
-#define REV_A_CODE_MEMORY_LENGTH        (REV_A_CODE_MEMORY_END - REV_A_CODE_MEMORY_BEGIN + 1)
-
-#define REV_B_CODE_MEMORY_BEGIN         0x0000
-#define REV_B_CODE_MEMORY_END           0x0BFF
-#define REV_B_CODE_MEMORY_UNIT_LENGTH   0x0040
-#define REV_B_CODE_MEMORY_LENGTH        (REV_B_CODE_MEMORY_END - REV_B_CODE_MEMORY_BEGIN + 1)
-
-#define REV_A_DATA_MEMORY_BEGIN         0x1000
-#define REV_A_DATA_MEMORY_END           0x2FFF
-#define REV_A_DATA_MEMORY_UNIT_LENGTH   0x0080
-#define REV_A_DATA_MEMORY_LENGTH        (REV_A_DATA_MEMORY_END - REV_A_DATA_MEMORY_BEGIN + 1)
-
-#define REV_B_DATA_MEMORY_BEGIN         0x1000
-#define REV_B_DATA_MEMORY_END           0x2BFF
-#define REV_B_DATA_MEMORY_UNIT_LENGTH   0x0080
-#define REV_B_DATA_MEMORY_LENGTH        (REV_B_DATA_MEMORY_END - REV_B_DATA_MEMORY_BEGIN + 1)
-
-
-#define NUM_UNITS_KERNEL_CODE          16
-#define NUM_UNITS_KERNEL_DATA           2
-
-#define NUM_UNITS_KERNEL_CODE_WITH_HSP 16
-#define NUM_UNITS_KERNEL_DATA_WITH_HSP  5
-
-/*
- * Kernel data layout
- */
-
-#define DP_SHIFT_COUNT                  7
-
-#define KDATA_BASE_ADDR                 0x1000
-#define KDATA_BASE_ADDR2                0x1080
-
-#define KDATA_TASK0                     (KDATA_BASE_ADDR + 0x0000)
-#define KDATA_TASK1                     (KDATA_BASE_ADDR + 0x0001)
-#define KDATA_TASK2                     (KDATA_BASE_ADDR + 0x0002)
-#define KDATA_TASK3                     (KDATA_BASE_ADDR + 0x0003)
-#define KDATA_TASK4                     (KDATA_BASE_ADDR + 0x0004)
-#define KDATA_TASK5                     (KDATA_BASE_ADDR + 0x0005)
-#define KDATA_TASK6                     (KDATA_BASE_ADDR + 0x0006)
-#define KDATA_TASK7                     (KDATA_BASE_ADDR + 0x0007)
-#define KDATA_TASK_ENDMARK              (KDATA_BASE_ADDR + 0x0008)
-
-#define KDATA_CURRENT_TASK              (KDATA_BASE_ADDR + 0x0009)
-#define KDATA_TASK_SWITCH               (KDATA_BASE_ADDR + 0x000A)
-
-#define KDATA_INSTANCE0_POS3D           (KDATA_BASE_ADDR + 0x000B)
-#define KDATA_INSTANCE1_POS3D           (KDATA_BASE_ADDR + 0x000C)
-#define KDATA_INSTANCE2_POS3D           (KDATA_BASE_ADDR + 0x000D)
-#define KDATA_INSTANCE3_POS3D           (KDATA_BASE_ADDR + 0x000E)
-#define KDATA_INSTANCE4_POS3D           (KDATA_BASE_ADDR + 0x000F)
-#define KDATA_INSTANCE5_POS3D           (KDATA_BASE_ADDR + 0x0010)
-#define KDATA_INSTANCE6_POS3D           (KDATA_BASE_ADDR + 0x0011)
-#define KDATA_INSTANCE7_POS3D           (KDATA_BASE_ADDR + 0x0012)
-#define KDATA_INSTANCE8_POS3D           (KDATA_BASE_ADDR + 0x0013)
-#define KDATA_INSTANCE_POS3D_ENDMARK    (KDATA_BASE_ADDR + 0x0014)
-
-#define KDATA_INSTANCE0_SPKVIRT         (KDATA_BASE_ADDR + 0x0015)
-#define KDATA_INSTANCE_SPKVIRT_ENDMARK  (KDATA_BASE_ADDR + 0x0016)
-
-#define KDATA_INSTANCE0_SPDIF           (KDATA_BASE_ADDR + 0x0017)
-#define KDATA_INSTANCE_SPDIF_ENDMARK    (KDATA_BASE_ADDR + 0x0018)
-
-#define KDATA_INSTANCE0_MODEM           (KDATA_BASE_ADDR + 0x0019)
-#define KDATA_INSTANCE_MODEM_ENDMARK    (KDATA_BASE_ADDR + 0x001A)
-
-#define KDATA_INSTANCE0_SRC             (KDATA_BASE_ADDR + 0x001B)
-#define KDATA_INSTANCE1_SRC             (KDATA_BASE_ADDR + 0x001C)
-#define KDATA_INSTANCE_SRC_ENDMARK      (KDATA_BASE_ADDR + 0x001D)
-
-#define KDATA_INSTANCE0_MINISRC         (KDATA_BASE_ADDR + 0x001E)
-#define KDATA_INSTANCE1_MINISRC         (KDATA_BASE_ADDR + 0x001F)
-#define KDATA_INSTANCE2_MINISRC         (KDATA_BASE_ADDR + 0x0020)
-#define KDATA_INSTANCE3_MINISRC         (KDATA_BASE_ADDR + 0x0021)
-#define KDATA_INSTANCE_MINISRC_ENDMARK  (KDATA_BASE_ADDR + 0x0022)
-
-#define KDATA_INSTANCE0_CPYTHRU         (KDATA_BASE_ADDR + 0x0023)
-#define KDATA_INSTANCE1_CPYTHRU         (KDATA_BASE_ADDR + 0x0024)
-#define KDATA_INSTANCE_CPYTHRU_ENDMARK  (KDATA_BASE_ADDR + 0x0025)
-
-#define KDATA_CURRENT_DMA               (KDATA_BASE_ADDR + 0x0026)
-#define KDATA_DMA_SWITCH                (KDATA_BASE_ADDR + 0x0027)
-#define KDATA_DMA_ACTIVE                (KDATA_BASE_ADDR + 0x0028)
-
-#define KDATA_DMA_XFER0                 (KDATA_BASE_ADDR + 0x0029)
-#define KDATA_DMA_XFER1                 (KDATA_BASE_ADDR + 0x002A)
-#define KDATA_DMA_XFER2                 (KDATA_BASE_ADDR + 0x002B)
-#define KDATA_DMA_XFER3                 (KDATA_BASE_ADDR + 0x002C)
-#define KDATA_DMA_XFER4                 (KDATA_BASE_ADDR + 0x002D)
-#define KDATA_DMA_XFER5                 (KDATA_BASE_ADDR + 0x002E)
-#define KDATA_DMA_XFER6                 (KDATA_BASE_ADDR + 0x002F)
-#define KDATA_DMA_XFER7                 (KDATA_BASE_ADDR + 0x0030)
-#define KDATA_DMA_XFER8                 (KDATA_BASE_ADDR + 0x0031)
-#define KDATA_DMA_XFER_ENDMARK          (KDATA_BASE_ADDR + 0x0032)
-
-#define KDATA_I2S_SAMPLE_COUNT          (KDATA_BASE_ADDR + 0x0033)
-#define KDATA_I2S_INT_METER             (KDATA_BASE_ADDR + 0x0034)
-#define KDATA_I2S_ACTIVE                (KDATA_BASE_ADDR + 0x0035)
-
-#define KDATA_TIMER_COUNT_RELOAD        (KDATA_BASE_ADDR + 0x0036)
-#define KDATA_TIMER_COUNT_CURRENT       (KDATA_BASE_ADDR + 0x0037)
-
-#define KDATA_HALT_SYNCH_CLIENT         (KDATA_BASE_ADDR + 0x0038)
-#define KDATA_HALT_SYNCH_DMA            (KDATA_BASE_ADDR + 0x0039)
-#define KDATA_HALT_ACKNOWLEDGE          (KDATA_BASE_ADDR + 0x003A)
-
-#define KDATA_ADC1_XFER0                (KDATA_BASE_ADDR + 0x003B)
-#define KDATA_ADC1_XFER_ENDMARK         (KDATA_BASE_ADDR + 0x003C)
-#define KDATA_ADC1_LEFT_VOLUME			(KDATA_BASE_ADDR + 0x003D)
-#define KDATA_ADC1_RIGHT_VOLUME  		(KDATA_BASE_ADDR + 0x003E)
-#define KDATA_ADC1_LEFT_SUR_VOL			(KDATA_BASE_ADDR + 0x003F)
-#define KDATA_ADC1_RIGHT_SUR_VOL		(KDATA_BASE_ADDR + 0x0040)
-
-#define KDATA_ADC2_XFER0                (KDATA_BASE_ADDR + 0x0041)
-#define KDATA_ADC2_XFER_ENDMARK         (KDATA_BASE_ADDR + 0x0042)
-#define KDATA_ADC2_LEFT_VOLUME			(KDATA_BASE_ADDR + 0x0043)
-#define KDATA_ADC2_RIGHT_VOLUME			(KDATA_BASE_ADDR + 0x0044)
-#define KDATA_ADC2_LEFT_SUR_VOL			(KDATA_BASE_ADDR + 0x0045)
-#define KDATA_ADC2_RIGHT_SUR_VOL		(KDATA_BASE_ADDR + 0x0046)
-
-#define KDATA_CD_XFER0					(KDATA_BASE_ADDR + 0x0047)					
-#define KDATA_CD_XFER_ENDMARK			(KDATA_BASE_ADDR + 0x0048)
-#define KDATA_CD_LEFT_VOLUME			(KDATA_BASE_ADDR + 0x0049)
-#define KDATA_CD_RIGHT_VOLUME			(KDATA_BASE_ADDR + 0x004A)
-#define KDATA_CD_LEFT_SUR_VOL			(KDATA_BASE_ADDR + 0x004B)
-#define KDATA_CD_RIGHT_SUR_VOL			(KDATA_BASE_ADDR + 0x004C)
-
-#define KDATA_MIC_XFER0					(KDATA_BASE_ADDR + 0x004D)
-#define KDATA_MIC_XFER_ENDMARK			(KDATA_BASE_ADDR + 0x004E)
-#define KDATA_MIC_VOLUME				(KDATA_BASE_ADDR + 0x004F)
-#define KDATA_MIC_SUR_VOL				(KDATA_BASE_ADDR + 0x0050)
-
-#define KDATA_I2S_XFER0                 (KDATA_BASE_ADDR + 0x0051)
-#define KDATA_I2S_XFER_ENDMARK          (KDATA_BASE_ADDR + 0x0052)
-
-#define KDATA_CHI_XFER0                 (KDATA_BASE_ADDR + 0x0053)
-#define KDATA_CHI_XFER_ENDMARK          (KDATA_BASE_ADDR + 0x0054)
-
-#define KDATA_SPDIF_XFER                (KDATA_BASE_ADDR + 0x0055)
-#define KDATA_SPDIF_CURRENT_FRAME       (KDATA_BASE_ADDR + 0x0056)
-#define KDATA_SPDIF_FRAME0              (KDATA_BASE_ADDR + 0x0057)
-#define KDATA_SPDIF_FRAME1              (KDATA_BASE_ADDR + 0x0058)
-#define KDATA_SPDIF_FRAME2              (KDATA_BASE_ADDR + 0x0059)
-
-#define KDATA_SPDIF_REQUEST             (KDATA_BASE_ADDR + 0x005A)
-#define KDATA_SPDIF_TEMP                (KDATA_BASE_ADDR + 0x005B)
-
-#define KDATA_SPDIFIN_XFER0             (KDATA_BASE_ADDR + 0x005C)
-#define KDATA_SPDIFIN_XFER_ENDMARK      (KDATA_BASE_ADDR + 0x005D)
-#define KDATA_SPDIFIN_INT_METER         (KDATA_BASE_ADDR + 0x005E)
-
-#define KDATA_DSP_RESET_COUNT           (KDATA_BASE_ADDR + 0x005F)
-#define KDATA_DEBUG_OUTPUT              (KDATA_BASE_ADDR + 0x0060)
-
-#define KDATA_KERNEL_ISR_LIST           (KDATA_BASE_ADDR + 0x0061)
-
-#define KDATA_KERNEL_ISR_CBSR1          (KDATA_BASE_ADDR + 0x0062)
-#define KDATA_KERNEL_ISR_CBER1          (KDATA_BASE_ADDR + 0x0063)
-#define KDATA_KERNEL_ISR_CBCR           (KDATA_BASE_ADDR + 0x0064)
-#define KDATA_KERNEL_ISR_AR0            (KDATA_BASE_ADDR + 0x0065)
-#define KDATA_KERNEL_ISR_AR1            (KDATA_BASE_ADDR + 0x0066)
-#define KDATA_KERNEL_ISR_AR2            (KDATA_BASE_ADDR + 0x0067)
-#define KDATA_KERNEL_ISR_AR3            (KDATA_BASE_ADDR + 0x0068)
-#define KDATA_KERNEL_ISR_AR4            (KDATA_BASE_ADDR + 0x0069)
-#define KDATA_KERNEL_ISR_AR5            (KDATA_BASE_ADDR + 0x006A)
-#define KDATA_KERNEL_ISR_BRCR           (KDATA_BASE_ADDR + 0x006B)
-#define KDATA_KERNEL_ISR_PASR           (KDATA_BASE_ADDR + 0x006C)
-#define KDATA_KERNEL_ISR_PAER           (KDATA_BASE_ADDR + 0x006D)
-
-#define KDATA_CLIENT_SCRATCH0           (KDATA_BASE_ADDR + 0x006E)
-#define KDATA_CLIENT_SCRATCH1           (KDATA_BASE_ADDR + 0x006F)
-#define KDATA_KERNEL_SCRATCH            (KDATA_BASE_ADDR + 0x0070)
-#define KDATA_KERNEL_ISR_SCRATCH        (KDATA_BASE_ADDR + 0x0071)
-
-#define KDATA_OUEUE_LEFT                (KDATA_BASE_ADDR + 0x0072)
-#define KDATA_QUEUE_RIGHT               (KDATA_BASE_ADDR + 0x0073)
-
-#define KDATA_ADC1_REQUEST              (KDATA_BASE_ADDR + 0x0074)
-#define KDATA_ADC2_REQUEST              (KDATA_BASE_ADDR + 0x0075)
-#define KDATA_CD_REQUEST				(KDATA_BASE_ADDR + 0x0076)
-#define KDATA_MIC_REQUEST				(KDATA_BASE_ADDR + 0x0077)
-
-#define KDATA_ADC1_MIXER_REQUEST        (KDATA_BASE_ADDR + 0x0078)
-#define KDATA_ADC2_MIXER_REQUEST        (KDATA_BASE_ADDR + 0x0079)
-#define KDATA_CD_MIXER_REQUEST			(KDATA_BASE_ADDR + 0x007A)
-#define KDATA_MIC_MIXER_REQUEST			(KDATA_BASE_ADDR + 0x007B)
-#define KDATA_MIC_SYNC_COUNTER			(KDATA_BASE_ADDR + 0x007C)
-
-/*
- * second 'segment' (?) reserved for mixer
- * buffers..
- */
-
-#define KDATA_MIXER_WORD0               (KDATA_BASE_ADDR2 + 0x0000)
-#define KDATA_MIXER_WORD1               (KDATA_BASE_ADDR2 + 0x0001)
-#define KDATA_MIXER_WORD2               (KDATA_BASE_ADDR2 + 0x0002)
-#define KDATA_MIXER_WORD3               (KDATA_BASE_ADDR2 + 0x0003)
-#define KDATA_MIXER_WORD4               (KDATA_BASE_ADDR2 + 0x0004)
-#define KDATA_MIXER_WORD5               (KDATA_BASE_ADDR2 + 0x0005)
-#define KDATA_MIXER_WORD6               (KDATA_BASE_ADDR2 + 0x0006)
-#define KDATA_MIXER_WORD7               (KDATA_BASE_ADDR2 + 0x0007)
-#define KDATA_MIXER_WORD8               (KDATA_BASE_ADDR2 + 0x0008)
-#define KDATA_MIXER_WORD9               (KDATA_BASE_ADDR2 + 0x0009)
-#define KDATA_MIXER_WORDA               (KDATA_BASE_ADDR2 + 0x000A)
-#define KDATA_MIXER_WORDB               (KDATA_BASE_ADDR2 + 0x000B)
-#define KDATA_MIXER_WORDC               (KDATA_BASE_ADDR2 + 0x000C)
-#define KDATA_MIXER_WORDD               (KDATA_BASE_ADDR2 + 0x000D)
-#define KDATA_MIXER_WORDE               (KDATA_BASE_ADDR2 + 0x000E)
-#define KDATA_MIXER_WORDF               (KDATA_BASE_ADDR2 + 0x000F)
-
-#define KDATA_MIXER_XFER0               (KDATA_BASE_ADDR2 + 0x0010)
-#define KDATA_MIXER_XFER1               (KDATA_BASE_ADDR2 + 0x0011)
-#define KDATA_MIXER_XFER2               (KDATA_BASE_ADDR2 + 0x0012)
-#define KDATA_MIXER_XFER3               (KDATA_BASE_ADDR2 + 0x0013)
-#define KDATA_MIXER_XFER4               (KDATA_BASE_ADDR2 + 0x0014)
-#define KDATA_MIXER_XFER5               (KDATA_BASE_ADDR2 + 0x0015)
-#define KDATA_MIXER_XFER6               (KDATA_BASE_ADDR2 + 0x0016)
-#define KDATA_MIXER_XFER7               (KDATA_BASE_ADDR2 + 0x0017)
-#define KDATA_MIXER_XFER8               (KDATA_BASE_ADDR2 + 0x0018)
-#define KDATA_MIXER_XFER9               (KDATA_BASE_ADDR2 + 0x0019)
-#define KDATA_MIXER_XFER_ENDMARK        (KDATA_BASE_ADDR2 + 0x001A)
-
-#define KDATA_MIXER_TASK_NUMBER         (KDATA_BASE_ADDR2 + 0x001B)
-#define KDATA_CURRENT_MIXER             (KDATA_BASE_ADDR2 + 0x001C)
-#define KDATA_MIXER_ACTIVE              (KDATA_BASE_ADDR2 + 0x001D)
-#define KDATA_MIXER_BANK_STATUS         (KDATA_BASE_ADDR2 + 0x001E)
-#define KDATA_DAC_LEFT_VOLUME	        (KDATA_BASE_ADDR2 + 0x001F)
-#define KDATA_DAC_RIGHT_VOLUME          (KDATA_BASE_ADDR2 + 0x0020)
-
-#define MAX_INSTANCE_MINISRC            (KDATA_INSTANCE_MINISRC_ENDMARK - KDATA_INSTANCE0_MINISRC)
-#define MAX_VIRTUAL_DMA_CHANNELS        (KDATA_DMA_XFER_ENDMARK - KDATA_DMA_XFER0)
-#define MAX_VIRTUAL_MIXER_CHANNELS      (KDATA_MIXER_XFER_ENDMARK - KDATA_MIXER_XFER0)
-#define MAX_VIRTUAL_ADC1_CHANNELS       (KDATA_ADC1_XFER_ENDMARK - KDATA_ADC1_XFER0)
-
-/*
- * client data area offsets
- */
-#define CDATA_INSTANCE_READY            0x00
-
-#define CDATA_HOST_SRC_ADDRL            0x01
-#define CDATA_HOST_SRC_ADDRH            0x02
-#define CDATA_HOST_SRC_END_PLUS_1L      0x03
-#define CDATA_HOST_SRC_END_PLUS_1H      0x04
-#define CDATA_HOST_SRC_CURRENTL         0x05
-#define CDATA_HOST_SRC_CURRENTH         0x06
-
-#define CDATA_IN_BUF_CONNECT            0x07
-#define CDATA_OUT_BUF_CONNECT           0x08
-
-#define CDATA_IN_BUF_BEGIN              0x09
-#define CDATA_IN_BUF_END_PLUS_1         0x0A
-#define CDATA_IN_BUF_HEAD               0x0B
-#define CDATA_IN_BUF_TAIL               0x0C
-#define CDATA_OUT_BUF_BEGIN             0x0D
-#define CDATA_OUT_BUF_END_PLUS_1        0x0E
-#define CDATA_OUT_BUF_HEAD              0x0F
-#define CDATA_OUT_BUF_TAIL              0x10
-
-#define CDATA_DMA_CONTROL               0x11
-#define CDATA_RESERVED                  0x12
-
-#define CDATA_FREQUENCY                 0x13
-#define CDATA_LEFT_VOLUME               0x14
-#define CDATA_RIGHT_VOLUME              0x15
-#define CDATA_LEFT_SUR_VOL              0x16
-#define CDATA_RIGHT_SUR_VOL             0x17
-
-#define CDATA_HEADER_LEN                0x18
-
-#define SRC3_DIRECTION_OFFSET           CDATA_HEADER_LEN
-#define SRC3_MODE_OFFSET                (CDATA_HEADER_LEN + 1)
-#define SRC3_WORD_LENGTH_OFFSET         (CDATA_HEADER_LEN + 2)
-#define SRC3_PARAMETER_OFFSET           (CDATA_HEADER_LEN + 3)
-#define SRC3_COEFF_ADDR_OFFSET          (CDATA_HEADER_LEN + 8)
-#define SRC3_FILTAP_ADDR_OFFSET         (CDATA_HEADER_LEN + 10)
-#define SRC3_TEMP_INBUF_ADDR_OFFSET     (CDATA_HEADER_LEN + 16)
-#define SRC3_TEMP_OUTBUF_ADDR_OFFSET    (CDATA_HEADER_LEN + 17)
-
-#define MINISRC_IN_BUFFER_SIZE   ( 0x50 * 2 )
-#define MINISRC_OUT_BUFFER_SIZE  ( 0x50 * 2 * 2)
-#define MINISRC_OUT_BUFFER_SIZE  ( 0x50 * 2 * 2)
-#define MINISRC_TMP_BUFFER_SIZE  ( 112 + ( MINISRC_BIQUAD_STAGE * 3 + 4 ) * 2 * 2 )
-#define MINISRC_BIQUAD_STAGE    2
-#define MINISRC_COEF_LOC          0X175
-
-#define DMACONTROL_BLOCK_MASK           0x000F
-#define  DMAC_BLOCK0_SELECTOR           0x0000
-#define  DMAC_BLOCK1_SELECTOR           0x0001
-#define  DMAC_BLOCK2_SELECTOR           0x0002
-#define  DMAC_BLOCK3_SELECTOR           0x0003
-#define  DMAC_BLOCK4_SELECTOR           0x0004
-#define  DMAC_BLOCK5_SELECTOR           0x0005
-#define  DMAC_BLOCK6_SELECTOR           0x0006
-#define  DMAC_BLOCK7_SELECTOR           0x0007
-#define  DMAC_BLOCK8_SELECTOR           0x0008
-#define  DMAC_BLOCK9_SELECTOR           0x0009
-#define  DMAC_BLOCKA_SELECTOR           0x000A
-#define  DMAC_BLOCKB_SELECTOR           0x000B
-#define  DMAC_BLOCKC_SELECTOR           0x000C
-#define  DMAC_BLOCKD_SELECTOR           0x000D
-#define  DMAC_BLOCKE_SELECTOR           0x000E
-#define  DMAC_BLOCKF_SELECTOR           0x000F
-#define DMACONTROL_PAGE_MASK            0x00F0
-#define  DMAC_PAGE0_SELECTOR            0x0030
-#define  DMAC_PAGE1_SELECTOR            0x0020
-#define  DMAC_PAGE2_SELECTOR            0x0010
-#define  DMAC_PAGE3_SELECTOR            0x0000
-#define DMACONTROL_AUTOREPEAT           0x1000
-#define DMACONTROL_STOPPED              0x2000
-#define DMACONTROL_DIRECTION            0x0100
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/gnu/fs/reiserfs/reiserfs_vfsops.c
--- a/head/sys/gnu/fs/reiserfs/reiserfs_vfsops.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/gnu/fs/reiserfs/reiserfs_vfsops.c	Wed Feb 01 12:34:54 2012 +0200
@@ -4,7 +4,7 @@
  * 
  * Ported to FreeBSD by Jean-Sébastien Pédron <jspedron at club-internet.fr>
  * 
- * $FreeBSD: head/sys/gnu/fs/reiserfs/reiserfs_vfsops.c 230132 2012-01-15 13:23:18Z uqs $
+ * $FreeBSD: head/sys/gnu/fs/reiserfs/reiserfs_vfsops.c 230249 2012-01-17 01:08:01Z mckusick $
  */
 
 #include <gnu/fs/reiserfs/reiserfs_fs.h>
@@ -49,7 +49,7 @@
  * -------------------------------------------------------------------*/
 
 static int
-reiserfs_cmount(struct mntarg *ma, void *data, int flags)
+reiserfs_cmount(struct mntarg *ma, void *data, uint64_t flags)
 {
 	struct reiserfs_args args;
 	struct export_args exp;
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/ia64/include/float.h
--- a/head/sys/ia64/include/float.h	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/ia64/include/float.h	Wed Feb 01 12:34:54 2012 +0200
@@ -1,4 +1,4 @@
-/* $FreeBSD$ */
+/* $FreeBSD: head/sys/ia64/include/float.h 230475 2012-01-23 06:36:41Z das $ */
 /* From: NetBSD: float.h,v 1.6 1997/07/17 21:36:03 thorpej Exp */
 
 /*-
@@ -49,22 +49,32 @@
 #define FLT_MANT_DIG	24		/* p */
 #define FLT_EPSILON	1.19209290E-07F	/* b**(1-p) */
 #define FLT_DIG		6		/* floor((p-1)*log10(b))+(b == 10) */
-#define FLT_MIN_EXP	-125		/* emin */
+#define FLT_MIN_EXP	(-125)		/* emin */
 #define FLT_MIN		1.17549435E-38F	/* b**(emin-1) */
-#define FLT_MIN_10_EXP	-37		/* ceil(log10(b**(emin-1))) */
+#define FLT_MIN_10_EXP	(-37)		/* ceil(log10(b**(emin-1))) */
 #define FLT_MAX_EXP	128		/* emax */
 #define FLT_MAX		3.40282347E+38F	/* (1-b**(-p))*b**emax */
 #define FLT_MAX_10_EXP	38		/* floor(log10((1-b**(-p))*b**emax)) */
+#if __ISO_C_VISIBLE >= 2011
+#define	FLT_TRUE_MIN	1.40129846E-45F	/* b**(emin-p) */
+#define	FLT_DECIMAL_DIG	9		/* ceil(1+p*log10(b)) */
+#define	FLT_HAS_SUBNORM	1
+#endif /* __ISO_C_VISIBLE >= 2011 */
 
 #define DBL_MANT_DIG	53
 #define DBL_EPSILON	2.2204460492503131E-16
 #define DBL_DIG		15
-#define DBL_MIN_EXP	-1021
+#define DBL_MIN_EXP	(-1021)
 #define DBL_MIN		2.2250738585072014E-308
-#define DBL_MIN_10_EXP	-307
+#define DBL_MIN_10_EXP	(-307)
 #define DBL_MAX_EXP	1024
 #define DBL_MAX		1.7976931348623157E+308
 #define DBL_MAX_10_EXP	308
+#if __ISO_C_VISIBLE >= 2011
+#define	DBL_TRUE_MIN	4.9406564584124654E-324
+#define	DBL_DECIMAL_DIG	17
+#define	DBL_HAS_SUBNORM	1
+#endif /* __ISO_C_VISIBLE >= 2011 */
 
 #define LDBL_MANT_DIG	64
 #define LDBL_EPSILON	1.0842021724855044340E-19L
@@ -75,5 +85,10 @@
 #define LDBL_MAX_EXP	16384
 #define LDBL_MAX	1.1897314953572317650E+4932L
 #define LDBL_MAX_10_EXP	4932
+#if __ISO_C_VISIBLE >= 2011
+#define	LDBL_TRUE_MIN	3.6451995318824746025E-4951L
+#define	LDBL_DECIMAL_DIG 21
+#define	LDBL_HAS_SUBNORM 1
+#endif /* __ISO_C_VISIBLE >= 2011 */
 
 #endif	/* _MACHINE_FLOAT_H_ */
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/kern/imgact_elf.c
--- a/head/sys/kern/imgact_elf.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/kern/imgact_elf.c	Wed Feb 01 12:34:54 2012 +0200
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/kern/imgact_elf.c 230132 2012-01-15 13:23:18Z uqs $");
+__FBSDID("$FreeBSD: head/sys/kern/imgact_elf.c 230767 2012-01-30 07:56:00Z kib $");
 
 #include "opt_capsicum.h"
 #include "opt_compat.h"
@@ -86,9 +86,9 @@
     const char *interp, int32_t *osrel);
 static int __elfN(load_file)(struct proc *p, const char *file, u_long *addr,
     u_long *entry, size_t pagesize);
-static int __elfN(load_section)(struct vmspace *vmspace, vm_object_t object,
-    vm_offset_t offset, caddr_t vmaddr, size_t memsz, size_t filsz,
-    vm_prot_t prot, size_t pagesize);
+static int __elfN(load_section)(struct image_params *imgp, vm_offset_t offset,
+    caddr_t vmaddr, size_t memsz, size_t filsz, vm_prot_t prot,
+    size_t pagesize);
 static int __CONCAT(exec_, __elfN(imgact))(struct image_params *imgp);
 static boolean_t __elfN(freebsd_trans_osrel)(const Elf_Note *note,
     int32_t *osrel);
@@ -118,7 +118,12 @@
 SYSCTL_INT(_debug, OID_AUTO, __elfN(legacy_coredump), CTLFLAG_RW, 
     &elf_legacy_coredump, 0, "");
 
-static int __elfN(nxstack) = 0;
+int __elfN(nxstack) =
+#if defined(__amd64__) || defined(__powerpc64__) /* both 64 and 32 bit */
+	1;
+#else
+	0;
+#endif
 SYSCTL_INT(__CONCAT(_kern_elf, __ELF_WORD_SIZE), OID_AUTO,
     nxstack, CTLFLAG_RW, &__elfN(nxstack), 0,
     __XSTRING(__CONCAT(ELF, __ELF_WORD_SIZE)) ": enable non-executable stack");
@@ -445,13 +450,14 @@
 }
 
 static int
-__elfN(load_section)(struct vmspace *vmspace,
-	vm_object_t object, vm_offset_t offset,
-	caddr_t vmaddr, size_t memsz, size_t filsz, vm_prot_t prot,
-	size_t pagesize)
+__elfN(load_section)(struct image_params *imgp, vm_offset_t offset,
+    caddr_t vmaddr, size_t memsz, size_t filsz, vm_prot_t prot,
+    size_t pagesize)
 {
 	struct sf_buf *sf;
 	size_t map_len;
+	vm_map_t map;
+	vm_object_t object;
 	vm_offset_t map_addr;
 	int error, rv, cow;
 	size_t copy_len;
@@ -466,12 +472,13 @@
 	 * While I'm here, might as well check for something else that
 	 * is invalid: filsz cannot be greater than memsz.
 	 */
-	if ((off_t)filsz + offset > object->un_pager.vnp.vnp_size ||
-	    filsz > memsz) {
+	if ((off_t)filsz + offset > imgp->attr->va_size || filsz > memsz) {
 		uprintf("elf_load_section: truncated ELF file\n");
 		return (ENOEXEC);
 	}
 
+	object = imgp->object;
+	map = &imgp->proc->p_vmspace->vm_map;
 	map_addr = trunc_page_ps((vm_offset_t)vmaddr, pagesize);
 	file_addr = trunc_page_ps(offset, pagesize);
 
@@ -491,7 +498,7 @@
 		cow = MAP_COPY_ON_WRITE | MAP_PREFAULT |
 		    (prot & VM_PROT_WRITE ? 0 : MAP_DISABLE_COREDUMP);
 
-		rv = __elfN(map_insert)(&vmspace->vm_map,
+		rv = __elfN(map_insert)(map,
 				      object,
 				      file_addr,	/* file offset */
 				      map_addr,		/* virtual start */
@@ -521,8 +528,8 @@
 
 	/* This had damn well better be true! */
 	if (map_len != 0) {
-		rv = __elfN(map_insert)(&vmspace->vm_map, NULL, 0, map_addr,
-		    map_addr + map_len, VM_PROT_ALL, 0);
+		rv = __elfN(map_insert)(map, NULL, 0, map_addr, map_addr +
+		    map_len, VM_PROT_ALL, 0);
 		if (rv != KERN_SUCCESS) {
 			return (EINVAL);
 		}
@@ -550,8 +557,8 @@
 	 * set it to the specified protection.
 	 * XXX had better undo the damage from pasting over the cracks here!
 	 */
-	vm_map_protect(&vmspace->vm_map, trunc_page(map_addr),
-	    round_page(map_addr + map_len),  prot, FALSE);
+	vm_map_protect(map, trunc_page(map_addr), round_page(map_addr +
+	    map_len), prot, FALSE);
 
 	return (0);
 }
@@ -580,7 +587,6 @@
 	const Elf_Ehdr *hdr = NULL;
 	const Elf_Phdr *phdr = NULL;
 	struct nameidata *nd;
-	struct vmspace *vmspace = p->p_vmspace;
 	struct vattr *attr;
 	struct image_params *imgp;
 	vm_prot_t prot;
@@ -672,11 +678,10 @@
 		if (phdr[i].p_type == PT_LOAD && phdr[i].p_memsz != 0) {
 			/* Loadable segment */
 			prot = __elfN(trans_prot)(phdr[i].p_flags);
-			if ((error = __elfN(load_section)(vmspace,
-			    imgp->object, phdr[i].p_offset,
+			error = __elfN(load_section)(imgp, phdr[i].p_offset,
 			    (caddr_t)(uintptr_t)phdr[i].p_vaddr + rbase,
-			    phdr[i].p_memsz, phdr[i].p_filesz, prot,
-			    pagesize)) != 0)
+			    phdr[i].p_memsz, phdr[i].p_filesz, prot, pagesize);
+			if (error != 0)
 				goto fail;
 			/*
 			 * Establish the base address if this is the
@@ -800,6 +805,9 @@
 	 * than zero.  Consequently, the vnode lock is not needed by vrele().
 	 * However, in cases where the vnode lock is external, such as nullfs,
 	 * v_usecount may become zero.
+	 *
+	 * The VV_TEXT flag prevents modifications to the executable while
+	 * the vnode is unlocked.
 	 */
 	VOP_UNLOCK(imgp->vp, 0);
 
@@ -810,8 +818,6 @@
 	if (error)
 		return (error);
 
-	vmspace = imgp->proc->p_vmspace;
-
 	for (i = 0; i < hdr->e_phnum; i++) {
 		switch (phdr[i].p_type) {
 		case PT_LOAD:	/* Loadable segment */
@@ -828,11 +834,11 @@
 				prot |= VM_PROT_EXECUTE;
 #endif
 
-			if ((error = __elfN(load_section)(vmspace,
-			    imgp->object, phdr[i].p_offset,
+			error = __elfN(load_section)(imgp, phdr[i].p_offset,
 			    (caddr_t)(uintptr_t)phdr[i].p_vaddr + et_dyn_addr,
 			    phdr[i].p_memsz, phdr[i].p_filesz, prot,
-			    sv->sv_pagesize)) != 0)
+			    sv->sv_pagesize);
+			if (error != 0)
 				return (error);
 
 			/*
@@ -901,6 +907,7 @@
 		return (ENOMEM);
 	}
 
+	vmspace = imgp->proc->p_vmspace;
 	vmspace->vm_tsize = text_size >> PAGE_SHIFT;
 	vmspace->vm_taddr = (caddr_t)(uintptr_t)text_addr;
 	vmspace->vm_dsize = data_size >> PAGE_SHIFT;
@@ -912,8 +919,8 @@
 	 * calculation is that it leaves room for the heap to grow to
 	 * its maximum allowed size.
 	 */
-	addr = round_page((vm_offset_t)imgp->proc->p_vmspace->vm_daddr +
-	    lim_max(imgp->proc, RLIMIT_DATA));
+	addr = round_page((vm_offset_t)vmspace->vm_daddr + lim_max(imgp->proc,
+	    RLIMIT_DATA));
 	PROC_UNLOCK(imgp->proc);
 
 	imgp->entry_addr = entry;
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/kern/init_main.c
--- a/head/sys/kern/init_main.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/kern/init_main.c	Wed Feb 01 12:34:54 2012 +0200
@@ -42,7 +42,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/kern/init_main.c 226833 2011-10-27 10:25:11Z pluknet $");
+__FBSDID("$FreeBSD: head/sys/kern/init_main.c 230455 2012-01-22 11:01:36Z pjd $");
 
 #include "opt_ddb.h"
 #include "opt_init_path.h"
@@ -467,7 +467,8 @@
 	td->td_priority = PVM;
 	td->td_base_pri = PVM;
 	td->td_oncpu = 0;
-	td->td_flags = TDF_INMEM|TDP_KTHREAD;
+	td->td_flags = TDF_INMEM;
+	td->td_pflags = TDP_KTHREAD;
 	td->td_cpuset = cpuset_thread0();
 	prison0.pr_cpuset = cpuset_ref(td->td_cpuset);
 	p->p_peers = 0;
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/kern/kern_exec.c
--- a/head/sys/kern/kern_exec.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/kern/kern_exec.c	Wed Feb 01 12:34:54 2012 +0200
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/kern/kern_exec.c 225791 2011-09-27 13:17:02Z kib $");
+__FBSDID("$FreeBSD: head/sys/kern/kern_exec.c 230341 2012-01-19 23:03:31Z kib $");
 
 #include "opt_capsicum.h"
 #include "opt_hwpmc_hooks.h"
@@ -471,6 +471,7 @@
 	 * actually an executable image.
 	 */
 	textset = imgp->vp->v_vflag & VV_TEXT;
+	ASSERT_VOP_ELOCKED(imgp->vp, "vv_text");
 	imgp->vp->v_vflag |= VV_TEXT;
 
 	error = exec_map_first_page(imgp);
@@ -502,8 +503,10 @@
 
 	if (error) {
 		if (error == -1) {
-			if (textset == 0)
+			if (textset == 0) {
+				ASSERT_VOP_ELOCKED(imgp->vp, "vv_text");
 				imgp->vp->v_vflag &= ~VV_TEXT;
+			}
 			error = ENOEXEC;
 		}
 		goto exec_fail_dealloc;
@@ -596,7 +599,7 @@
 
 	/* close files on exec */
 	fdcloseexec(td);
-	vn_lock(imgp->vp, LK_EXCLUSIVE | LK_RETRY);
+	vn_lock(imgp->vp, LK_SHARED | LK_RETRY);
 
 	/* Get a reference to the vnode prior to locking the proc */
 	VREF(binvp);
@@ -701,7 +704,7 @@
 		VOP_UNLOCK(imgp->vp, 0);
 		setugidsafety(td);
 		error = fdcheckstd(td);
-		vn_lock(imgp->vp, LK_EXCLUSIVE | LK_RETRY);
+		vn_lock(imgp->vp, LK_SHARED | LK_RETRY);
 		if (error != 0)
 			goto done1;
 		PROC_LOCK(p);
@@ -805,7 +808,7 @@
 		pe.pm_entryaddr = imgp->entry_addr;
 
 		PMC_CALL_HOOK_X(td, PMC_FN_PROCESS_EXEC, (void *) &pe);
-		vn_lock(imgp->vp, LK_EXCLUSIVE | LK_RETRY);
+		vn_lock(imgp->vp, LK_SHARED | LK_RETRY);
 	} else
 		PROC_UNLOCK(p);
 #else  /* !HWPMC_HOOKS */
@@ -857,7 +860,7 @@
 	if (tracecred != NULL)
 		crfree(tracecred);
 #endif
-	vn_lock(imgp->vp, LK_EXCLUSIVE | LK_RETRY);
+	vn_lock(imgp->vp, LK_SHARED | LK_RETRY);
 	pargs_drop(oldargs);
 	pargs_drop(newargs);
 	if (oldsigacts != NULL)
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/kern/kern_intr.c
--- a/head/sys/kern/kern_intr.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/kern/kern_intr.c	Wed Feb 01 12:34:54 2012 +0200
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/kern/kern_intr.c 229272 2012-01-02 12:12:10Z ed $");
+__FBSDID("$FreeBSD: head/sys/kern/kern_intr.c 230231 2012-01-16 20:42:56Z pluknet $");
 
 #include "opt_ddb.h"
 
@@ -633,7 +633,7 @@
 		mtx_lock(&ie->ie_lock);
 		it->it_event = ie; 
 		ih->ih_thread = it;
-		ithread_update(it); // XXX - do we really need this?!?!?
+		ithread_update(it); /* XXX - do we really need this?!?!? */
 	} else { /* Create the global per-event thread if we need one. */
 		while (ie->ie_thread == NULL && handler != NULL) {
 			if (ie->ie_flags & IE_ADDING_THREAD)
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/kern/kern_jail.c
--- a/head/sys/kern/kern_jail.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/kern/kern_jail.c	Wed Feb 01 12:34:54 2012 +0200
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/kern/kern_jail.c 230143 2012-01-15 18:08:15Z mm $");
+__FBSDID("$FreeBSD: head/sys/kern/kern_jail.c 230407 2012-01-21 00:06:21Z mm $");
 
 #include "opt_compat.h"
 #include "opt_ddb.h"
@@ -521,6 +521,7 @@
 	struct prison *pr, *deadpr, *mypr, *ppr, *tpr;
 	struct vnode *root;
 	char *domain, *errmsg, *host, *name, *namelc, *p, *path, *uuid;
+	char *g_path;
 #if defined(INET) || defined(INET6)
 	struct prison *tppr;
 	void *op;
@@ -575,6 +576,7 @@
 #ifdef INET6
 	ip6 = NULL;
 #endif
+	g_path = NULL;
 
 	error = vfs_copyopt(opts, "jid", &jid, sizeof(jid));
 	if (error == ENOENT)
@@ -907,13 +909,17 @@
 		vfslocked = NDHASGIANT(&nd);
 		root = nd.ni_vp;
 		NDFREE(&nd, NDF_ONLY_PNBUF);
-		error = vn_path_to_global_path(td, root, path, MAXPATHLEN);
-		if (error == ENODEV) {
+		g_path = malloc(MAXPATHLEN, M_TEMP, M_WAITOK);
+		strlcpy(g_path, path, MAXPATHLEN);
+		error = vn_path_to_global_path(td, root, g_path, MAXPATHLEN);
+		if (error == 0)
+			path = g_path;
+		else if (error == ENODEV) {
 			/* proceed if sysctl debug.disablefullpath == 1 */
 			fullpath_disabled = 1;
 			if (len < 2 || (len == 2 && path[0] == '/'))
 				path = NULL;
-		} else if (error != 0) {
+		} else {
 			/* exit on other errors */
 			VFS_UNLOCK_GIANT(vfslocked);
 			goto done_free;
@@ -1819,6 +1825,8 @@
 #ifdef INET6
 	free(ip6, M_PRISON);
 #endif
+	if (g_path != NULL)
+		free(g_path, M_TEMP);
 	vfs_freeopts(opts);
 	return (error);
 }
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/kern/kern_proc.c
--- a/head/sys/kern/kern_proc.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/kern/kern_proc.c	Wed Feb 01 12:34:54 2012 +0200
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/kern/kern_proc.c 230145 2012-01-15 18:47:24Z trociny $");
+__FBSDID("$FreeBSD: head/sys/kern/kern_proc.c 230550 2012-01-25 20:15:58Z trociny $");
 
 #include "opt_compat.h"
 #include "opt_ddb.h"
@@ -2372,7 +2372,7 @@
 }
 
 /*
- * This sysctl allows a process to retrieve the resource limits for
+ * This sysctl allows a process to retrieve or/and set the resource limit for
  * another process.
  */
 static int
@@ -2380,30 +2380,53 @@
 {
 	int *name = (int *)arg1;
 	u_int namelen = arg2;
-	struct plimit *limp;
+	struct rlimit rlim;
 	struct proc *p;
-	int error = 0;
+	u_int which;
+	int flags, error;
 
-	if (namelen != 1)
+	if (namelen != 2)
 		return (EINVAL);
 
-	error = pget((pid_t)name[0], PGET_CANSEE, &p);
+	which = (u_int)name[1];
+	if (which >= RLIM_NLIMITS)
+		return (EINVAL);
+
+	if (req->newptr != NULL && req->newlen != sizeof(rlim))
+		return (EINVAL);
+
+	flags = PGET_HOLD | PGET_NOTWEXIT;
+	if (req->newptr != NULL)
+		flags |= PGET_CANDEBUG;
+	else
+		flags |= PGET_CANSEE;
+	error = pget((pid_t)name[0], flags, &p);
 	if (error != 0)
 		return (error);
+
 	/*
-	 * Check the request size.  We alow sizes smaller rlimit array for
-	 * backward binary compatibility: the number of resource limits may
-	 * grow.
+	 * Retrieve limit.
 	 */
-	if (sizeof(limp->pl_rlimit) < req->oldlen) {
+	if (req->oldptr != NULL) {
+		PROC_LOCK(p);
+		lim_rlimit(p, which, &rlim);
 		PROC_UNLOCK(p);
-		return (EINVAL);
+	}
+	error = SYSCTL_OUT(req, &rlim, sizeof(rlim));
+	if (error != 0)
+		goto errout;
+
+	/*
+	 * Set limit.
+	 */
+	if (req->newptr != NULL) {
+		error = SYSCTL_IN(req, &rlim, sizeof(rlim));
+		if (error == 0)
+			error = kern_proc_setrlimit(curthread, p, which, &rlim);
 	}
 
-	limp = lim_hold(p->p_limit);
-	PROC_UNLOCK(p);
-	error = SYSCTL_OUT(req, limp->pl_rlimit, req->oldlen);
-	lim_free(limp);
+errout:
+	PRELE(p);
 	return (error);
 }
 
@@ -2485,13 +2508,11 @@
 	CTLFLAG_RW | CTLFLAG_ANYBODY | CTLFLAG_MPSAFE,
 	sysctl_kern_proc_args, "Process argument list");
 
-static SYSCTL_NODE(_kern_proc, KERN_PROC_ENV, env,
-	CTLFLAG_RW | CTLFLAG_ANYBODY | CTLFLAG_MPSAFE,
+static SYSCTL_NODE(_kern_proc, KERN_PROC_ENV, env, CTLFLAG_RD | CTLFLAG_MPSAFE,
 	sysctl_kern_proc_env, "Process environment");
 
-static SYSCTL_NODE(_kern_proc, KERN_PROC_AUXV, auxv,
-	CTLFLAG_RW | CTLFLAG_ANYBODY | CTLFLAG_MPSAFE,
-	sysctl_kern_proc_auxv, "Process ELF auxiliary vector");
+static SYSCTL_NODE(_kern_proc, KERN_PROC_AUXV, auxv, CTLFLAG_RD |
+	CTLFLAG_MPSAFE, sysctl_kern_proc_auxv, "Process ELF auxiliary vector");
 
 static SYSCTL_NODE(_kern_proc, KERN_PROC_PATHNAME, pathname, CTLFLAG_RD |
 	CTLFLAG_MPSAFE, sysctl_kern_proc_pathname, "Process executable path");
@@ -2544,9 +2565,10 @@
 static SYSCTL_NODE(_kern_proc, KERN_PROC_GROUPS, groups, CTLFLAG_RD |
 	CTLFLAG_MPSAFE, sysctl_kern_proc_groups, "Process groups");
 
-static SYSCTL_NODE(_kern_proc, KERN_PROC_RLIMIT, rlimit, CTLFLAG_RD |
-	CTLFLAG_MPSAFE, sysctl_kern_proc_rlimit, "Process resource limits");
+static SYSCTL_NODE(_kern_proc, KERN_PROC_RLIMIT, rlimit, CTLFLAG_RW |
+	CTLFLAG_ANYBODY | CTLFLAG_MPSAFE, sysctl_kern_proc_rlimit,
+	"Process resource limits");
 
-static SYSCTL_NODE(_kern_proc, KERN_PROC_PS_STRINGS, ps_strings,
-	CTLFLAG_RW | CTLFLAG_ANYBODY | CTLFLAG_MPSAFE,
-	sysctl_kern_proc_ps_strings, "Process ps_strings location");
+static SYSCTL_NODE(_kern_proc, KERN_PROC_PS_STRINGS, ps_strings, CTLFLAG_RD |
+	CTLFLAG_MPSAFE, sysctl_kern_proc_ps_strings,
+	"Process ps_strings location");
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/kern/kern_resource.c
--- a/head/sys/kern/kern_resource.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/kern/kern_resource.c	Wed Feb 01 12:34:54 2012 +0200
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/kern/kern_resource.c 229622 2012-01-05 19:02:52Z jhb $");
+__FBSDID("$FreeBSD: head/sys/kern/kern_resource.c 230470 2012-01-22 20:25:00Z trociny $");
 
 #include "opt_compat.h"
 
@@ -649,13 +649,17 @@
 }
 
 int
-kern_setrlimit(td, which, limp)
-	struct thread *td;
-	u_int which;
-	struct rlimit *limp;
+kern_setrlimit(struct thread *td, u_int which, struct rlimit *limp)
+{
+
+	return (kern_proc_setrlimit(td, td->td_proc, which, limp));
+}
+
+int
+kern_proc_setrlimit(struct thread *td, struct proc *p, u_int which,
+    struct rlimit *limp)
 {
 	struct plimit *newlim, *oldlim;
-	struct proc *p;
 	register struct rlimit *alimp;
 	struct rlimit oldssiz;
 	int error;
@@ -672,7 +676,6 @@
 		limp->rlim_max = RLIM_INFINITY;
 
 	oldssiz.rlim_cur = 0;
-	p = td->td_proc;
 	newlim = lim_alloc();
 	PROC_LOCK(p);
 	oldlim = p->p_limit;
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/kern/kern_shutdown.c
--- a/head/sys/kern/kern_shutdown.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/kern/kern_shutdown.c	Wed Feb 01 12:34:54 2012 +0200
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/kern/kern_shutdown.c 229854 2012-01-09 12:06:09Z avg $");
+__FBSDID("$FreeBSD: head/sys/kern/kern_shutdown.c 230643 2012-01-28 14:00:21Z attilio $");
 
 #include "opt_ddb.h"
 #include "opt_kdb.h"
@@ -145,7 +145,6 @@
  */
 const char *panicstr;
 
-int stop_scheduler;			/* system stopped CPUs for panic */
 int dumping;				/* system is dumping */
 int rebooting;				/* system is rebooting */
 static struct dumperinfo dumper;	/* our selected dumper */
@@ -597,7 +596,7 @@
 		 * stop_scheduler_on_panic is true, then stop_scheduler will
 		 * always be set.  Even if panic has been entered from kdb.
 		 */
-		stop_scheduler = 1;
+		td->td_stopsched = 1;
 	}
 #endif
 
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/kern/subr_hash.c
--- a/head/sys/kern/subr_hash.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/kern/subr_hash.c	Wed Feb 01 12:34:54 2012 +0200
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: head/sys/kern/subr_hash.c 230486 2012-01-23 16:31:46Z glebius $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -52,9 +52,7 @@
 	LIST_HEAD(generic, generic) *hashtbl;
 	int i;
 
-	if (elements <= 0)
-		panic("hashinit: bad elements");
-
+	KASSERT(elements > 0, ("%s: bad elements", __func__));
 	/* Exactly one of HASH_WAITOK and HASH_NOWAIT must be set. */
 	KASSERT((flags & HASH_WAITOK) ^ (flags & HASH_NOWAIT),
 	    ("Bad flags (0x%x) passed to hashinit_flags", flags));
@@ -95,8 +93,7 @@
 
 	hashtbl = vhashtbl;
 	for (hp = hashtbl; hp <= &hashtbl[hashmask]; hp++)
-		if (!LIST_EMPTY(hp))
-			panic("hashdestroy: hash not empty");
+		KASSERT(LIST_EMPTY(hp), ("%s: hash not empty", __func__));
 	free(hashtbl, type);
 }
 
@@ -115,8 +112,7 @@
 	LIST_HEAD(generic, generic) *hashtbl;
 	int i;
 
-	if (elements <= 0)
-		panic("phashinit: bad elements");
+	KASSERT(elements > 0, ("%s: bad elements", __func__));
 	for (i = 1, hashsize = primes[1]; hashsize <= elements;) {
 		i++;
 		if (i == NPRIMES)
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/kern/subr_mchain.c
--- a/head/sys/kern/subr_mchain.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/kern/subr_mchain.c	Wed Feb 01 12:34:54 2012 +0200
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/kern/subr_mchain.c 227650 2011-11-18 03:05:20Z kevlo $");
+__FBSDID("$FreeBSD: head/sys/kern/subr_mchain.c 230218 2012-01-16 14:54:48Z kevlo $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -139,7 +139,7 @@
 	if ((unsigned long)dst & 1)
 		return mb_put_mem(mbp, (caddr_t)&x, 1, MB_MSYSTEM);
 	else
-	return 0;
+		return 0;
 }
 
 int
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/kern/subr_scanf.c
--- a/head/sys/kern/subr_scanf.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/kern/subr_scanf.c	Wed Feb 01 12:34:54 2012 +0200
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: head/sys/kern/subr_scanf.c 230587 2012-01-26 16:35:09Z ken $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -59,6 +59,7 @@
 #define	POINTER		0x10	/* weird %p pointer (`fake hex') */
 #define	NOSKIP		0x20	/* do not skip blanks */
 #define	QUAD		0x400
+#define	SHORTSHORT	0x4000	/** hh: char */
 
 /*
  * The following are used in numeric conversions only:
@@ -160,13 +161,23 @@
 			flags |= SUPPRESS;
 			goto again;
 		case 'l':
-			flags |= LONG;
+			if (flags & LONG){
+				flags &= ~LONG;
+				flags |= QUAD;
+			} else {
+				flags |= LONG;
+			}
 			goto again;
 		case 'q':
 			flags |= QUAD;
 			goto again;
 		case 'h':
-			flags |= SHORT;
+			if (flags & SHORT){
+				flags &= ~SHORT;
+				flags |= SHORTSHORT;
+			} else {
+				flags |= SHORT;
+			}
 			goto again;
 
 		case '0': case '1': case '2': case '3': case '4':
@@ -235,7 +246,9 @@
 			nconversions++;
 			if (flags & SUPPRESS)	/* ??? */
 				continue;
-			if (flags & SHORT)
+			if (flags & SHORTSHORT)
+				*va_arg(ap, char *) = nread;
+			else if (flags & SHORT)
 				*va_arg(ap, short *) = nread;
 			else if (flags & LONG)
 				*va_arg(ap, long *) = nread;
@@ -510,6 +523,8 @@
 				if (flags & POINTER)
 					*va_arg(ap, void **) =
 						(void *)(uintptr_t)res;
+				else if (flags & SHORTSHORT)
+					*va_arg(ap, char *) = res;
 				else if (flags & SHORT)
 					*va_arg(ap, short *) = res;
 				else if (flags & LONG)
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/kern/subr_syscall.c
--- a/head/sys/kern/subr_syscall.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/kern/subr_syscall.c	Wed Feb 01 12:34:54 2012 +0200
@@ -42,7 +42,7 @@
 #include "opt_ktrace.h"
 #include "opt_kdtrace.h"
 
-__FBSDID("$FreeBSD: head/sys/kern/subr_syscall.c 226925 2011-10-30 02:19:39Z marcel $");
+__FBSDID("$FreeBSD: head/sys/kern/subr_syscall.c 230785 2012-01-30 20:00:29Z kib $");
 
 #include <sys/capability.h>
 #include <sys/ktr.h>
@@ -212,7 +212,8 @@
 		 * executes.  If debugger requested tracing of syscall
 		 * returns, do it now too.
 		 */
-		if (traced && ((td->td_dbgflags & TDB_EXEC) != 0 ||
+		if (traced &&
+		    ((td->td_dbgflags & (TDB_FORK | TDB_EXEC)) != 0 ||
 		    (p->p_stops & S_PT_SCX) != 0))
 			ptracestop(td, SIGTRAP);
 		td->td_dbgflags &= ~(TDB_SCX | TDB_EXEC | TDB_FORK);
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/kern/uipc_mbuf.c
--- a/head/sys/kern/uipc_mbuf.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/kern/uipc_mbuf.c	Wed Feb 01 12:34:54 2012 +0200
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: head/sys/kern/uipc_mbuf.c 230587 2012-01-26 16:35:09Z ken $");
 
 #include "opt_param.h"
 #include "opt_mbuf_stress_test.h"
@@ -1410,6 +1410,11 @@
 	int pdata;
 	const struct mbuf *m2;
 
+	if (m == NULL) {
+		printf("mbuf: %p\n", m);
+		return;
+	}
+
 	if (m->m_flags & M_PKTHDR)
 		len = m->m_pkthdr.len;
 	else
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/kern/vfs_aio.c
--- a/head/sys/kern/vfs_aio.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/kern/vfs_aio.c	Wed Feb 01 12:34:54 2012 +0200
@@ -19,7 +19,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/kern/vfs_aio.c 225617 2011-09-16 13:58:51Z kmacy $");
+__FBSDID("$FreeBSD: head/sys/kern/vfs_aio.c 230857 2012-02-01 02:53:06Z davidxu $");
 
 #include "opt_compat.h"
 
@@ -1524,6 +1524,7 @@
 	int error;
 	int fd, kqfd;
 	int jid;
+	u_short evflags;
 
 	if (p->p_aioinfo == NULL)
 		aio_init_aioinfo(p);
@@ -1552,6 +1553,12 @@
 		return (error);
 	}
 
+	/* XXX: aio_nbytes is later casted to signed types. */
+	if (aiocbe->uaiocb.aio_nbytes > INT_MAX) {
+		uma_zfree(aiocb_zone, aiocbe);
+		return (EINVAL);
+	}
+
 	if (aiocbe->uaiocb.aio_sigevent.sigev_notify != SIGEV_KEVENT &&
 	    aiocbe->uaiocb.aio_sigevent.sigev_notify != SIGEV_SIGNAL &&
 	    aiocbe->uaiocb.aio_sigevent.sigev_notify != SIGEV_THREAD_ID &&
@@ -1640,10 +1647,15 @@
 
 	if (aiocbe->uaiocb.aio_sigevent.sigev_notify != SIGEV_KEVENT)
 		goto no_kqueue;
+	evflags = aiocbe->uaiocb.aio_sigevent.sigev_notify_kevent_flags;
+	if ((evflags & ~(EV_CLEAR | EV_DISPATCH | EV_ONESHOT)) != 0) {
+		error = EINVAL;
+		goto aqueue_fail;
+	}
 	kqfd = aiocbe->uaiocb.aio_sigevent.sigev_notify_kqueue;
 	kev.ident = (uintptr_t)aiocbe->uuaiocb;
 	kev.filter = EVFILT_AIO;
-	kev.flags = EV_ADD | EV_ENABLE | EV_FLAG1;
+	kev.flags = EV_ADD | EV_ENABLE | EV_FLAG1 | evflags;
 	kev.data = (intptr_t)aiocbe;
 	kev.udata = aiocbe->uaiocb.aio_sigevent.sigev_value.sival_ptr;
 	error = kqfd_register(kqfd, &kev, td, 1);
@@ -2529,10 +2541,13 @@
 static void
 filt_aiodetach(struct knote *kn)
 {
-	struct aiocblist *aiocbe = kn->kn_ptr.p_aio;
-
-	if (!knlist_empty(&aiocbe->klist))
-		knlist_remove(&aiocbe->klist, kn, 0);
+	struct knlist *knl;
+
+	knl = &kn->kn_ptr.p_aio->klist;
+	knl->kl_lock(knl->kl_lockarg);
+	if (!knlist_empty(knl))
+		knlist_remove(knl, kn, 1);
+	knl->kl_unlock(knl->kl_lockarg);
 }
 
 /* kqueue filter function */
@@ -2574,10 +2589,13 @@
 static void
 filt_liodetach(struct knote *kn)
 {
-	struct aioliojob * lj = kn->kn_ptr.p_lio;
-
-	if (!knlist_empty(&lj->klist))
-		knlist_remove(&lj->klist, kn, 0);
+	struct knlist *knl;
+
+	knl = &kn->kn_ptr.p_lio->klist;
+	knl->kl_lock(knl->kl_lockarg);
+	if (!knlist_empty(knl))
+		knlist_remove(knl, kn, 1);
+	knl->kl_unlock(knl->kl_lockarg);
 }
 
 /* kqueue filter function */
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/kern/vfs_cache.c
--- a/head/sys/kern/vfs_cache.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/kern/vfs_cache.c	Wed Feb 01 12:34:54 2012 +0200
@@ -33,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/kern/vfs_cache.c 230143 2012-01-15 18:08:15Z mm $");
+__FBSDID("$FreeBSD: head/sys/kern/vfs_cache.c 230552 2012-01-25 20:48:20Z kib $");
 
 #include "opt_kdtrace.h"
 #include "opt_ktrace.h"
@@ -103,6 +103,30 @@
 };
 
 /*
+ * struct namecache_ts repeats struct namecache layout up to the
+ * nc_nlen member.
+ */
+struct	namecache_ts {
+	LIST_ENTRY(namecache) nc_hash;	/* hash chain */
+	LIST_ENTRY(namecache) nc_src;	/* source vnode list */
+	TAILQ_ENTRY(namecache) nc_dst;	/* destination vnode list */
+	struct	vnode *nc_dvp;		/* vnode of parent of name */
+	struct	vnode *nc_vp;		/* vnode the name refers to */
+	u_char	nc_flag;		/* flag bits */
+	u_char	nc_nlen;		/* length of name */
+	struct	timespec nc_time;	/* timespec provided by fs */
+	int	nc_ticks;		/* ticks value when entry was added */
+	char	nc_name[0];		/* segment name + nul */
+};
+
+/*
+ * Flags in namecache.nc_flag
+ */
+#define NCF_WHITE	0x01
+#define NCF_ISDOTDOT	0x02
+#define	NCF_TS		0x04
+
+/*
  * Name caching works as follows:
  *
  * Names found by directory scans are retained in a cache
@@ -164,20 +188,64 @@
  * fit in the small cache.
  */
 static uma_zone_t cache_zone_small;
+static uma_zone_t cache_zone_small_ts;
 static uma_zone_t cache_zone_large;
 
 #define	CACHE_PATH_CUTOFF	35
-#define	CACHE_ZONE_SMALL	(sizeof(struct namecache) + CACHE_PATH_CUTOFF \
-				    + 1)
-#define	CACHE_ZONE_LARGE	(sizeof(struct namecache) + NAME_MAX + 1)
 
-#define cache_alloc(len)	uma_zalloc(((len) <= CACHE_PATH_CUTOFF) ? \
-	cache_zone_small : cache_zone_large, M_WAITOK)
-#define cache_free(ncp)		do { \
-	if (ncp != NULL) \
-		uma_zfree(((ncp)->nc_nlen <= CACHE_PATH_CUTOFF) ? \
-		    cache_zone_small : cache_zone_large, (ncp)); \
-} while (0)
+static struct namecache *
+cache_alloc(int len, int ts)
+{
+
+	if (len > CACHE_PATH_CUTOFF)
+		return (uma_zalloc(cache_zone_large, M_WAITOK));
+	if (ts)
+		return (uma_zalloc(cache_zone_small_ts, M_WAITOK));
+	else
+		return (uma_zalloc(cache_zone_small, M_WAITOK));
+}
+
+static void
+cache_free(struct namecache *ncp)
+{
+	int ts;
+
+	if (ncp == NULL)
+		return;
+	ts = ncp->nc_flag & NCF_TS;
+	if (ncp->nc_nlen <= CACHE_PATH_CUTOFF) {
+		if (ts)
+			uma_zfree(cache_zone_small_ts, ncp);
+		else
+			uma_zfree(cache_zone_small, ncp);
+	} else
+		uma_zfree(cache_zone_large, ncp);
+}
+
+static char *
+nc_get_name(struct namecache *ncp)
+{
+	struct namecache_ts *ncp_ts;
+
+	if ((ncp->nc_flag & NCF_TS) == 0)
+		return (ncp->nc_name);
+	ncp_ts = (struct namecache_ts *)ncp;
+	return (ncp_ts->nc_name);
+}
+
+static void
+cache_out_ts(struct namecache *ncp, struct timespec *tsp, int *ticksp)
+{
+
+	KASSERT((ncp->nc_flag & NCF_TS) != 0 ||
+	    (tsp == NULL && ticksp == NULL),
+	    ("No NCF_TS"));
+
+	if (tsp != NULL)
+		*tsp = ((struct namecache_ts *)ncp)->nc_time;
+	if (ticksp != NULL)
+		*ticksp = ((struct namecache_ts *)ncp)->nc_ticks;
+}
 
 static int	doingcache = 1;		/* 1 => enable the cache */
 SYSCTL_INT(_debug, OID_AUTO, vfscache, CTLFLAG_RW, &doingcache, 0,
@@ -233,12 +301,6 @@
 
 static MALLOC_DEFINE(M_VFSCACHE, "vfscache", "VFS name cache entries");
 
-/*
- * Flags in namecache.nc_flag
- */
-#define NCF_WHITE	0x01
-#define NCF_ISDOTDOT	0x02
-
 #ifdef DIAGNOSTIC
 /*
  * Grab an atomic snapshot of the name cache hash chain lengths
@@ -344,10 +406,10 @@
 #ifdef KDTRACE_HOOKS
 	if (ncp->nc_vp != NULL) {
 		SDT_PROBE(vfs, namecache, zap, done, ncp->nc_dvp,
-		    ncp->nc_name, ncp->nc_vp, 0, 0);
+		    nc_get_name(ncp), ncp->nc_vp, 0, 0);
 	} else {
 		SDT_PROBE(vfs, namecache, zap_negative, done, ncp->nc_dvp,
-		    ncp->nc_name, 0, 0, 0);
+		    nc_get_name(ncp), 0, 0, 0);
 	}
 #endif
 	vp = NULL;
@@ -394,10 +456,12 @@
  */
 
 int
-cache_lookup(dvp, vpp, cnp)
+cache_lookup_times(dvp, vpp, cnp, tsp, ticksp)
 	struct vnode *dvp;
 	struct vnode **vpp;
 	struct componentname *cnp;
+	struct timespec *tsp;
+	int *ticksp;
 {
 	struct namecache *ncp;
 	uint32_t hash;
@@ -422,6 +486,10 @@
 			dothits++;
 			SDT_PROBE(vfs, namecache, lookup, hit, dvp, ".",
 			    *vpp, 0, 0);
+			if (tsp != NULL)
+				timespecclear(tsp);
+			if (ticksp != NULL)
+				*ticksp = ticks;
 			goto success;
 		}
 		if (cnp->cn_namelen == 2 && cnp->cn_nameptr[1] == '.') {
@@ -440,19 +508,19 @@
 				CACHE_WUNLOCK();
 				return (0);
 			}
-			if (dvp->v_cache_dd->nc_flag & NCF_ISDOTDOT)
-				*vpp = dvp->v_cache_dd->nc_vp;
+			ncp = dvp->v_cache_dd;
+			if (ncp->nc_flag & NCF_ISDOTDOT)
+				*vpp = ncp->nc_vp;
 			else
-				*vpp = dvp->v_cache_dd->nc_dvp;
+				*vpp = ncp->nc_dvp;
 			/* Return failure if negative entry was found. */
-			if (*vpp == NULL) {
-				ncp = dvp->v_cache_dd;
+			if (*vpp == NULL)
 				goto negative_success;
-			}
 			CTR3(KTR_VFS, "cache_lookup(%p, %s) found %p via ..",
 			    dvp, cnp->cn_nameptr, *vpp);
 			SDT_PROBE(vfs, namecache, lookup, hit, dvp, "..",
 			    *vpp, 0, 0);
+			cache_out_ts(ncp, tsp, ticksp);
 			goto success;
 		}
 	}
@@ -462,7 +530,7 @@
 	LIST_FOREACH(ncp, (NCHHASH(hash)), nc_hash) {
 		numchecks++;
 		if (ncp->nc_dvp == dvp && ncp->nc_nlen == cnp->cn_namelen &&
-		    !bcmp(ncp->nc_name, cnp->cn_nameptr, ncp->nc_nlen))
+		    !bcmp(nc_get_name(ncp), cnp->cn_nameptr, ncp->nc_nlen))
 			break;
 	}
 
@@ -497,8 +565,9 @@
 		*vpp = ncp->nc_vp;
 		CTR4(KTR_VFS, "cache_lookup(%p, %s) found %p via ncp %p",
 		    dvp, cnp->cn_nameptr, *vpp, ncp);
-		SDT_PROBE(vfs, namecache, lookup, hit, dvp, ncp->nc_name,
+		SDT_PROBE(vfs, namecache, lookup, hit, dvp, nc_get_name(ncp),
 		    *vpp, 0, 0);
+		cache_out_ts(ncp, tsp, ticksp);
 		goto success;
 	}
 
@@ -528,8 +597,9 @@
 	nchstats.ncs_neghits++;
 	if (ncp->nc_flag & NCF_WHITE)
 		cnp->cn_flags |= ISWHITEOUT;
-	SDT_PROBE(vfs, namecache, lookup, hit_negative, dvp, ncp->nc_name,
+	SDT_PROBE(vfs, namecache, lookup, hit_negative, dvp, nc_get_name(ncp),
 	    0, 0, 0);
+	cache_out_ts(ncp, tsp, ticksp);
 	CACHE_WUNLOCK();
 	return (ENOENT);
 
@@ -616,12 +686,14 @@
  * Add an entry to the cache.
  */
 void
-cache_enter(dvp, vp, cnp)
+cache_enter_time(dvp, vp, cnp, tsp)
 	struct vnode *dvp;
 	struct vnode *vp;
 	struct componentname *cnp;
+	struct timespec *tsp;
 {
 	struct namecache *ncp, *n2;
+	struct namecache_ts *n3;
 	struct nchashhead *ncpp;
 	uint32_t hash;
 	int flag;
@@ -688,13 +760,19 @@
 	 * Calculate the hash key and setup as much of the new
 	 * namecache entry as possible before acquiring the lock.
 	 */
-	ncp = cache_alloc(cnp->cn_namelen);
+	ncp = cache_alloc(cnp->cn_namelen, tsp != NULL);
 	ncp->nc_vp = vp;
 	ncp->nc_dvp = dvp;
 	ncp->nc_flag = flag;
+	if (tsp != NULL) {
+		n3 = (struct namecache_ts *)ncp;
+		n3->nc_time = *tsp;
+		n3->nc_ticks = ticks;
+		n3->nc_flag |= NCF_TS;
+	}
 	len = ncp->nc_nlen = cnp->cn_namelen;
 	hash = fnv_32_buf(cnp->cn_nameptr, len, FNV1_32_INIT);
-	strlcpy(ncp->nc_name, cnp->cn_nameptr, len + 1);
+	strlcpy(nc_get_name(ncp), cnp->cn_nameptr, len + 1);
 	hash = fnv_32_buf(&dvp, sizeof(dvp), hash);
 	CACHE_WLOCK();
 
@@ -707,7 +785,16 @@
 	LIST_FOREACH(n2, ncpp, nc_hash) {
 		if (n2->nc_dvp == dvp &&
 		    n2->nc_nlen == cnp->cn_namelen &&
-		    !bcmp(n2->nc_name, cnp->cn_nameptr, n2->nc_nlen)) {
+		    !bcmp(nc_get_name(n2), cnp->cn_nameptr, n2->nc_nlen)) {
+			if (tsp != NULL) {
+				KASSERT((n2->nc_flag & NCF_TS) != 0,
+				    ("no NCF_TS"));
+				n3 = (struct namecache_ts *)n2;
+				n3->nc_time =
+				    ((struct namecache_ts *)ncp)->nc_time;
+				n3->nc_ticks =
+				    ((struct namecache_ts *)ncp)->nc_ticks;
+			}
 			CACHE_WUNLOCK();
 			cache_free(ncp);
 			return;
@@ -765,12 +852,12 @@
 	 */
 	if (vp) {
 		TAILQ_INSERT_HEAD(&vp->v_cache_dst, ncp, nc_dst);
-		SDT_PROBE(vfs, namecache, enter, done, dvp, ncp->nc_name, vp,
-		    0, 0);
+		SDT_PROBE(vfs, namecache, enter, done, dvp, nc_get_name(ncp),
+		    vp, 0, 0);
 	} else {
 		TAILQ_INSERT_TAIL(&ncneg, ncp, nc_dst);
 		SDT_PROBE(vfs, namecache, enter_negative, done, dvp,
-		    ncp->nc_name, 0, 0, 0);
+		    nc_get_name(ncp), 0, 0, 0);
 	}
 	if (numneg * ncnegfactor > numcache) {
 		ncp = TAILQ_FIRST(&ncneg);
@@ -792,10 +879,15 @@
 
 	TAILQ_INIT(&ncneg);
 
-	cache_zone_small = uma_zcreate("S VFS Cache", CACHE_ZONE_SMALL, NULL,
-	    NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_ZINIT);
-	cache_zone_large = uma_zcreate("L VFS Cache", CACHE_ZONE_LARGE, NULL,
-	    NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_ZINIT);
+	cache_zone_small = uma_zcreate("S VFS Cache",
+	    sizeof(struct namecache) + CACHE_PATH_CUTOFF + 1,
+	    NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_ZINIT);
+	cache_zone_small_ts = uma_zcreate("STS VFS Cache",
+	    sizeof(struct namecache_ts) + CACHE_PATH_CUTOFF + 1,
+	    NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_ZINIT);
+	cache_zone_large = uma_zcreate("L VFS Cache",
+	    sizeof(struct namecache_ts) + NAME_MAX + 1,
+	    NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_ZINIT);
 
 	nchashtbl = hashinit(desiredvnodes * 2, M_VFSCACHE, &nchash);
 }
@@ -1099,9 +1191,9 @@
 			return (error);
 		}
 		*buflen -= ncp->nc_nlen;
-		memcpy(buf + *buflen, ncp->nc_name, ncp->nc_nlen);
+		memcpy(buf + *buflen, nc_get_name(ncp), ncp->nc_nlen);
 		SDT_PROBE(vfs, namecache, fullpath, hit, ncp->nc_dvp,
-		    ncp->nc_name, vp, 0, 0);
+		    nc_get_name(ncp), vp, 0, 0);
 		dvp = *vp;
 		*vp = ncp->nc_dvp;
 		vref(*vp);
@@ -1274,12 +1366,35 @@
 		return (ENOENT);
 	}
 	l = min(ncp->nc_nlen, buflen - 1);
-	memcpy(buf, ncp->nc_name, l);
+	memcpy(buf, nc_get_name(ncp), l);
 	CACHE_RUNLOCK();
 	buf[l] = '\0';
 	return (0);
 }
 
+/* ABI compat shims for old kernel modules. */
+#undef cache_enter
+#undef cache_lookup
+
+void	cache_enter(struct vnode *dvp, struct vnode *vp,
+	    struct componentname *cnp);
+int	cache_lookup(struct vnode *dvp, struct vnode **vpp,
+	    struct componentname *cnp);
+
+void
+cache_enter(struct vnode *dvp, struct vnode *vp, struct componentname *cnp)
+{
+
+	cache_enter_time(dvp, vp, cnp, NULL);
+}
+
+int
+cache_lookup(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp)
+{
+
+	return (cache_lookup_times(dvp, vpp, cnp, NULL, NULL));
+}
+
 /*
  * This function updates path string to vnode's full global path
  * and checks the size of the new path string against the pathlen argument.
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/kern/vfs_mount.c
--- a/head/sys/kern/vfs_mount.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/kern/vfs_mount.c	Wed Feb 01 12:34:54 2012 +0200
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/kern/vfs_mount.c 230129 2012-01-15 12:08:20Z mm $");
+__FBSDID("$FreeBSD: head/sys/kern/vfs_mount.c 230249 2012-01-17 01:08:01Z mckusick $");
 
 #include "opt_vfs_allow_nonmpsafe.h"
 
@@ -72,8 +72,8 @@
 
 #define	VFS_MOUNTARG_SIZE_MAX	(1024 * 64)
 
-static int	vfs_domount(struct thread *td, const char *fstype,
-		    char *fspath, int fsflags, struct vfsoptlist **optlist);
+static int	vfs_domount(struct thread *td, const char *fstype, char *fspath,
+		    uint64_t fsflags, struct vfsoptlist **optlist);
 static void	free_mntarg(struct mntarg *ma);
 
 static int	usermount = 0;
@@ -378,10 +378,18 @@
 	struct uio *auio;
 	int error;
 	u_int iovcnt;
+	uint64_t flags;
 
-	AUDIT_ARG_FFLAGS(uap->flags);
+	/*
+	 * Mount flags are now 64-bits. On 32-bit archtectures only
+	 * 32-bits are passed in, but from here on everything handles
+	 * 64-bit flags correctly.
+	 */
+	flags = uap->flags;
+
+	AUDIT_ARG_FFLAGS(flags);
 	CTR4(KTR_VFS, "%s: iovp %p with iovcnt %d and flags %d", __func__,
-	    uap->iovp, uap->iovcnt, uap->flags);
+	    uap->iovp, uap->iovcnt, flags);
 
 	/*
 	 * Filter out MNT_ROOTFS.  We do not want clients of nmount() in
@@ -390,7 +398,7 @@
 	 * MNT_ROOTFS should only be set by the kernel when mounting its
 	 * root file system.
 	 */
-	uap->flags &= ~MNT_ROOTFS;
+	flags &= ~MNT_ROOTFS;
 
 	iovcnt = uap->iovcnt;
 	/*
@@ -409,7 +417,7 @@
 		    __func__, error);
 		return (error);
 	}
-	error = vfs_donmount(td, uap->flags, auio);
+	error = vfs_donmount(td, flags, auio);
 
 	free(auio, M_IOV);
 	return (error);
@@ -520,7 +528,7 @@
 }
 
 int
-vfs_donmount(struct thread *td, int fsflags, struct uio *fsoptions)
+vfs_donmount(struct thread *td, uint64_t fsflags, struct uio *fsoptions)
 {
 	struct vfsoptlist *optlist;
 	struct vfsopt *opt, *tmp_opt;
@@ -696,9 +704,17 @@
 	char *fstype;
 	struct vfsconf *vfsp = NULL;
 	struct mntarg *ma = NULL;
+	uint64_t flags;
 	int error;
 
-	AUDIT_ARG_FFLAGS(uap->flags);
+	/*
+	 * Mount flags are now 64-bits. On 32-bit archtectures only
+	 * 32-bits are passed in, but from here on everything handles
+	 * 64-bit flags correctly.
+	 */
+	flags = uap->flags;
+
+	AUDIT_ARG_FFLAGS(flags);
 
 	/*
 	 * Filter out MNT_ROOTFS.  We do not want clients of mount() in
@@ -707,7 +723,7 @@
 	 * MNT_ROOTFS should only be set by the kernel when mounting its
 	 * root file system.
 	 */
-	uap->flags &= ~MNT_ROOTFS;
+	flags &= ~MNT_ROOTFS;
 
 	fstype = malloc(MFSNAMELEN, M_TEMP, M_WAITOK);
 	error = copyinstr(uap->type, fstype, MFSNAMELEN, NULL);
@@ -731,11 +747,11 @@
 
 	ma = mount_argsu(ma, "fstype", uap->type, MNAMELEN);
 	ma = mount_argsu(ma, "fspath", uap->path, MNAMELEN);
-	ma = mount_argb(ma, uap->flags & MNT_RDONLY, "noro");
-	ma = mount_argb(ma, !(uap->flags & MNT_NOSUID), "nosuid");
-	ma = mount_argb(ma, !(uap->flags & MNT_NOEXEC), "noexec");
+	ma = mount_argb(ma, flags & MNT_RDONLY, "noro");
+	ma = mount_argb(ma, !(flags & MNT_NOSUID), "nosuid");
+	ma = mount_argb(ma, !(flags & MNT_NOEXEC), "noexec");
 
-	error = vfsp->vfc_vfsops->vfs_cmount(ma, uap->data, uap->flags);
+	error = vfsp->vfc_vfsops->vfs_cmount(ma, uap->data, flags);
 	mtx_unlock(&Giant);
 	return (error);
 }
@@ -749,7 +765,7 @@
 	struct vfsconf *vfsp,		/* File system type. */
 	char *fspath,			/* Mount path. */
 	struct vnode *vp,		/* Vnode to be covered. */
-	int fsflags,			/* Flags common to all filesystems. */
+	uint64_t fsflags,		/* Flags common to all filesystems. */
 	struct vfsoptlist **optlist	/* Options local to the filesystem. */
 	)
 {
@@ -871,14 +887,15 @@
 vfs_domount_update(
 	struct thread *td,		/* Calling thread. */
 	struct vnode *vp,		/* Mount point vnode. */
-	int fsflags,			/* Flags common to all filesystems. */
+	uint64_t fsflags,		/* Flags common to all filesystems. */
 	struct vfsoptlist **optlist	/* Options local to the filesystem. */
 	)
 {
 	struct oexport_args oexport;
 	struct export_args export;
 	struct mount *mp;
-	int error, export_error, flag;
+	int error, export_error;
+	uint64_t flag;
 
 	mtx_assert(&Giant, MA_OWNED);
 	ASSERT_VOP_ELOCKED(vp, __func__);
@@ -1015,7 +1032,7 @@
 	struct thread *td,		/* Calling thread. */
 	const char *fstype,		/* Filesystem type. */
 	char *fspath,			/* Mount path. */
-	int fsflags,			/* Flags common to all filesystems. */
+	uint64_t fsflags,		/* Flags common to all filesystems. */
 	struct vfsoptlist **optlist	/* Options local to the filesystem. */
 	)
 {
@@ -1216,7 +1233,7 @@
 {
 	struct vnode *coveredvp, *fsrootvp;
 	int error;
-	int async_flag;
+	uint64_t async_flag;
 	int mnt_gen_r;
 
 	mtx_assert(&Giant, MA_OWNED);
@@ -1925,7 +1942,7 @@
  * Mount a filesystem
  */
 int
-kernel_mount(struct mntarg *ma, int flags)
+kernel_mount(struct mntarg *ma, uint64_t flags)
 {
 	struct uio auio;
 	int error;
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/kern/vfs_subr.c
--- a/head/sys/kern/vfs_subr.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/kern/vfs_subr.c	Wed Feb 01 12:34:54 2012 +0200
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/kern/vfs_subr.c 229727 2012-01-06 20:05:48Z jhb $");
+__FBSDID("$FreeBSD: head/sys/kern/vfs_subr.c 230553 2012-01-25 20:54:09Z kib $");
 
 #include "opt_ddb.h"
 #include "opt_watchdog.h"
@@ -2496,6 +2496,18 @@
 		 * vnodes open for writing.
 		 */
 		if (flags & WRITECLOSE) {
+			if (vp->v_object != NULL) {
+				VM_OBJECT_LOCK(vp->v_object);
+				vm_object_page_clean(vp->v_object, 0, 0, 0);
+				VM_OBJECT_UNLOCK(vp->v_object);
+			}
+			error = VOP_FSYNC(vp, MNT_WAIT, td);
+			if (error != 0) {
+				VOP_UNLOCK(vp, 0);
+				vdrop(vp);
+				MNT_VNODE_FOREACH_ABORT(mp, mvp);
+				return (error);
+			}
 			error = VOP_GETATTR(vp, &vattr, td->td_ucred);
 			VI_LOCK(vp);
 
@@ -2836,6 +2848,7 @@
 	struct statfs *sp;
 	struct vnode *vp;
 	char buf[512];
+	uint64_t mflags;
 	u_int flags;
 
 	if (!have_addr) {
@@ -2857,13 +2870,13 @@
 	    mp->mnt_stat.f_mntonname, mp->mnt_stat.f_fstypename);
 
 	buf[0] = '\0';
-	flags = mp->mnt_flag;
+	mflags = mp->mnt_flag;
 #define	MNT_FLAG(flag)	do {						\
-	if (flags & (flag)) {						\
+	if (mflags & (flag)) {						\
 		if (buf[0] != '\0')					\
 			strlcat(buf, ", ", sizeof(buf));		\
 		strlcat(buf, (#flag) + 4, sizeof(buf));			\
-		flags &= ~(flag);					\
+		mflags &= ~(flag);					\
 	}								\
 } while (0)
 	MNT_FLAG(MNT_RDONLY);
@@ -2901,11 +2914,11 @@
 	MNT_FLAG(MNT_SNAPSHOT);
 	MNT_FLAG(MNT_BYFSID);
 #undef MNT_FLAG
-	if (flags != 0) {
+	if (mflags != 0) {
 		if (buf[0] != '\0')
 			strlcat(buf, ", ", sizeof(buf));
 		snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),
-		    "0x%08x", flags);
+		    "0x%016jx", mflags);
 	}
 	db_printf("    mnt_flag = %s\n", buf);
 
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/kern/vfs_vnops.c
--- a/head/sys/kern/vfs_vnops.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/kern/vfs_vnops.c	Wed Feb 01 12:34:54 2012 +0200
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/kern/vfs_vnops.c 227070 2011-11-04 04:02:50Z jhb $");
+__FBSDID("$FreeBSD: head/sys/kern/vfs_vnops.c 230782 2012-01-30 19:35:15Z jhb $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -519,6 +519,7 @@
 	int error, ioflag;
 	struct mtx *mtxp;
 	int advice, vfslocked;
+	off_t offset;
 
 	KASSERT(uio->uio_td == td, ("uio_td %p is not td %p",
 	    uio->uio_td, td));
@@ -558,19 +559,14 @@
 	switch (advice) {
 	case POSIX_FADV_NORMAL:
 	case POSIX_FADV_SEQUENTIAL:
+	case POSIX_FADV_NOREUSE:
 		ioflag |= sequential_heuristic(uio, fp);
 		break;
 	case POSIX_FADV_RANDOM:
 		/* Disable read-ahead for random I/O. */
 		break;
-	case POSIX_FADV_NOREUSE:
-		/*
-		 * Request the underlying FS to discard the buffers
-		 * and pages after the I/O is complete.
-		 */
-		ioflag |= IO_DIRECT;
-		break;
 	}
+	offset = uio->uio_offset;
 
 #ifdef MAC
 	error = mac_vnode_check_read(active_cred, fp->f_cred, vp);
@@ -587,6 +583,10 @@
 	}
 	fp->f_nextoff = uio->uio_offset;
 	VOP_UNLOCK(vp, 0);
+	if (error == 0 && advice == POSIX_FADV_NOREUSE &&
+	    offset != uio->uio_offset)
+		error = VOP_ADVISE(vp, offset, uio->uio_offset - 1,
+		    POSIX_FADV_DONTNEED);
 	VFS_UNLOCK_GIANT(vfslocked);
 	return (error);
 }
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/mips/include/_types.h
--- a/head/sys/mips/include/_types.h	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/mips/include/_types.h	Wed Feb 01 12:34:54 2012 +0200
@@ -34,7 +34,7 @@
  *	From: @(#)ansi.h	8.2 (Berkeley) 1/4/94
  *	From: @(#)types.h	8.3 (Berkeley) 1/5/94
  *	from: src/sys/i386/include/_types.h,v 1.12 2005/07/02 23:13:31 thompsa
- * $FreeBSD: head/sys/mips/include/_types.h 228469 2011-12-13 13:38:03Z ed $
+ * $FreeBSD: head/sys/mips/include/_types.h 230229 2012-01-16 20:17:51Z das $
  */
 
 #ifndef _MACHINE__TYPES_H_
@@ -74,7 +74,7 @@
  */
 typedef	__int32_t	__clock_t;		/* clock()... */
 typedef	double		__double_t;
-typedef	double		__float_t;
+typedef	float		__float_t;
 #ifdef __mips_n64
 typedef	__int64_t	__critical_t;
 typedef	__int64_t	__intfptr_t;
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/mips/include/float.h
--- a/head/sys/mips/include/float.h	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/mips/include/float.h	Wed Feb 01 12:34:54 2012 +0200
@@ -29,7 +29,7 @@
  *	from: @(#)float.h	7.1 (Berkeley) 5/8/90
  *	from: src/sys/i386/include/float.h,v 1.8 1999/08/28 00:44:11 peter
  *	JNPR: float.h,v 1.4 2006/12/02 09:53:41 katta
- * $FreeBSD: head/sys/mips/include/float.h 230199 2012-01-16 05:23:27Z das $
+ * $FreeBSD: head/sys/mips/include/float.h 230475 2012-01-23 06:36:41Z das $
  */
 
 #ifndef _MACHINE_FLOAT_H_
@@ -45,7 +45,7 @@
 #ifdef CPU_HAVEFPU
 #define	FLT_ROUNDS	__flt_rounds() /* FP addition rounds to nearest */
 #else
-#define	FLT_ROUNDS	-1
+#define	FLT_ROUNDS	(-1)
 #endif
 
 #if __ISO_C_VISIBLE >= 1999
@@ -62,6 +62,11 @@
 #define	FLT_MAX_EXP	128		/* emax */
 #define	FLT_MAX		3.40282347E+38F /* (1-b**(-p))*b**emax */
 #define	FLT_MAX_10_EXP	38		/* floor(log10((1-b**(-p))*b**emax)) */
+#if __ISO_C_VISIBLE >= 2011
+#define	FLT_TRUE_MIN	1.40129846E-45F	/* b**(emin-p) */
+#define	FLT_DECIMAL_DIG	9		/* ceil(1+p*log10(b)) */
+#define	FLT_HAS_SUBNORM	1
+#endif /* __ISO_C_VISIBLE >= 2011 */
 
 #define	DBL_MANT_DIG	53
 #define	DBL_EPSILON	2.2204460492503131E-16
@@ -72,15 +77,25 @@
 #define	DBL_MAX_EXP	1024
 #define	DBL_MAX		1.7976931348623157E+308
 #define	DBL_MAX_10_EXP	308
+#if __ISO_C_VISIBLE >= 2011
+#define	DBL_TRUE_MIN	4.9406564584124654E-324
+#define	DBL_DECIMAL_DIG	17
+#define	DBL_HAS_SUBNORM	1
+#endif /* __ISO_C_VISIBLE >= 2011 */
 
 #define	LDBL_MANT_DIG	DBL_MANT_DIG
-#define	LDBL_EPSILON	(long double)DBL_EPSILON
+#define	LDBL_EPSILON	((long double)DBL_EPSILON)
 #define	LDBL_DIG	DBL_DIG
 #define	LDBL_MIN_EXP	DBL_MIN_EXP
-#define	LDBL_MIN	(long double)DBL_MIN
+#define	LDBL_MIN	((long double)DBL_MIN)
 #define	LDBL_MIN_10_EXP DBL_MIN_10_EXP
 #define	LDBL_MAX_EXP	DBL_MAX_EXP
-#define	LDBL_MAX	(long double)DBL_MAX
+#define	LDBL_MAX	((long double)DBL_MAX)
 #define	LDBL_MAX_10_EXP DBL_MAX_10_EXP
+#if __ISO_C_VISIBLE >= 2011
+#define	LDBL_TRUE_MIN	((long double)DBL_TRUE_MIN)
+#define	LDBL_DECIMAL_DIG DBL_DECIMAL_DIG
+#define	LDBL_HAS_SUBNORM DBL_HAS_SUBNORM
+#endif /* __ISO_C_VISIBLE >= 2011 */
 
 #endif /* _MACHINE_FLOAT_H_ */
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/modules/Makefile
--- a/head/sys/modules/Makefile	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/modules/Makefile	Wed Feb 01 12:34:54 2012 +0200
@@ -1,4 +1,4 @@
-# $FreeBSD: head/sys/modules/Makefile 228981 2011-12-30 03:48:39Z marcel $
+# $FreeBSD: head/sys/modules/Makefile 230859 2012-02-01 03:42:14Z jhibbits $
 
 .include <bsd.own.mk>
 
@@ -136,7 +136,7 @@
 	${_igb} \
 	${_iir} \
 	${_io} \
-	ipdivert \
+	${_ipdivert} \
 	${_ipfilter} \
 	${_ipfw} \
 	ipfw_nat \
@@ -145,6 +145,7 @@
 	${_ips} \
 	${_ipw} \
 	${_ipwfw} \
+	${_isci} \
 	iscsi \
 	isp \
 	ispfw \
@@ -378,20 +379,21 @@
 .endif
 .endif
 
-.if ${MK_INET_SUPPORT} != "no" || defined(ALL_MODULES)
-_if_gre=	if_gre
-.endif
-
 .if (${MK_INET_SUPPORT} != "no" || ${MK_INET6_SUPPORT} != "no") || \
 	defined(ALL_MODULES)
 _carp=	carp
 .endif
 
+.if ${MK_INET_SUPPORT} != "no" || defined(ALL_MODULES)
+_if_gre=	if_gre
+.endif
+
 .if ${MK_IPFILTER} != "no" || defined(ALL_MODULES)
 _ipfilter=	ipfilter
 .endif
 
 .if ${MK_INET_SUPPORT} != "no" || defined(ALL_MODULES)
+_ipdivert=	ipdivert
 _ipfw=		ipfw
 .endif
 
@@ -528,6 +530,7 @@
 _ips=		ips
 _ipw=		ipw
 _ipwfw=		ipwfw
+_isci=		isci
 _iwi=		iwi
 _iwifw=		iwifw
 _iwn=		iwn
@@ -572,6 +575,7 @@
 _amdtemp=	amdtemp
 _arcmsr=	arcmsr
 _asmc=		asmc
+_bktr=		bktr
 _bxe=		bxe
 _cardbus=	cardbus
 _cbb=		cbb
@@ -608,6 +612,7 @@
 _ips=		ips
 _ipw=		ipw
 _ipwfw=		ipwfw
+_isci=		isci
 _iwi=		iwi
 _iwifw=		iwifw
 _iwn=		iwn
@@ -710,9 +715,12 @@
 _agp=		agp
 _an=		an
 _bm=		bm
+_cardbus=	cardbus
+_cbb=		cbb
 _cfi=		cfi
 _cpufreq=	cpufreq
 _nvram=		powermac_nvram
+_pccard=	pccard
 _smbfs=		smbfs
 _sound=		sound
 .endif
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/modules/ipdivert/Makefile
--- a/head/sys/modules/ipdivert/Makefile	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/modules/ipdivert/Makefile	Wed Feb 01 12:34:54 2012 +0200
@@ -1,13 +1,21 @@
-# $FreeBSD: head/sys/modules/ipdivert/Makefile 223593 2011-06-27 12:21:11Z glebius $
+# $FreeBSD: head/sys/modules/ipdivert/Makefile 230443 2012-01-22 02:16:31Z bz $
+
+.include <bsd.own.mk>
 
 .PATH: ${.CURDIR}/../../netinet
 
 KMOD=   ipdivert
-SRCS=   ip_divert.c opt_inet6.h
+SRCS=   ip_divert.c opt_inet.h opt_inet6.h
 
 .if !defined(KERNBUILDDIR)
+.if ${MK_INET_SUPPORT} != "no"
+opt_inet.h:
+	echo "#define INET 1" > ${.TARGET}
+.endif
+.if ${MK_INET6_SUPPORT} != "no"
 opt_inet6.h:
 	echo "#define INET6 1" > ${.TARGET}
 .endif
+.endif
 
 .include <bsd.kmod.mk>
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/modules/isci/Makefile
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/modules/isci/Makefile	Wed Feb 01 12:34:54 2012 +0200
@@ -0,0 +1,92 @@
+# isci driver Makefile
+#
+# $FreeBSD$
+
+ISCI_SRC_PATH = ${.CURDIR}/../..
+
+.PATH:  ${ISCI_SRC_PATH}/dev/isci ${ISCI_SRC_PATH}/dev/isci/scil
+
+KMOD    = isci
+SRCS    = isci.c isci_oem_parameters.c \
+		isci_controller.c isci_domain.c isci_io_request.c \
+		isci_timer.c isci_remote_device.c isci_logger.c \
+		isci_task_request.c isci_sysctl.c isci_interrupt.c
+
+SRCS += \
+		sci_base_controller.c \
+		sci_base_domain.c \
+		sci_base_iterator.c \
+		sci_base_library.c \
+		sci_base_logger.c \
+		sci_base_memory_descriptor_list.c \
+		sci_base_memory_descriptor_list_decorator.c \
+		sci_base_object.c \
+		sci_base_observer.c \
+		sci_base_phy.c \
+		sci_base_port.c \
+		sci_base_remote_device.c \
+	 	sci_base_request.c \
+		sci_base_state_machine.c \
+		sci_base_state_machine_logger.c \
+		sci_base_state_machine_observer.c \
+		sci_base_subject.c
+
+SRCS += \
+		sci_abstract_list.c \
+		sci_util.c
+
+SRCS += \
+		scic_sds_controller.c \
+		scic_sds_library.c scic_sds_pci.c \
+		scic_sds_phy.c scic_sds_port.c \
+		scic_sds_port_configuration_agent.c \
+		scic_sds_remote_device.c scic_sds_remote_node_context.c \
+		scic_sds_remote_node_table.c scic_sds_request.c \
+		scic_sds_sgpio.c scic_sds_smp_remote_device.c \
+		scic_sds_smp_request.c scic_sds_ssp_request.c \
+		scic_sds_stp_packet_request.c scic_sds_stp_remote_device.c \
+		scic_sds_stp_request.c scic_sds_unsolicited_frame_control.c
+
+SRCS += \
+		scif_sas_controller.c \
+		scif_sas_controller_state_handlers.c \
+		scif_sas_controller_states.c scif_sas_domain.c \
+		scif_sas_domain_state_handlers.c scif_sas_domain_states.c \
+		scif_sas_high_priority_request_queue.c \
+		scif_sas_internal_io_request.c scif_sas_io_request.c \
+		scif_sas_io_request_state_handlers.c \
+		scif_sas_io_request_states.c scif_sas_library.c \
+		scif_sas_remote_device.c \
+		scif_sas_remote_device_ready_substate_handlers.c \
+		scif_sas_remote_device_ready_substates.c \
+		scif_sas_remote_device_starting_substate_handlers.c \
+		scif_sas_remote_device_starting_substates.c \
+		scif_sas_remote_device_state_handlers.c \
+		scif_sas_remote_device_states.c scif_sas_request.c \
+		scif_sas_smp_activity_clear_affiliation.c \
+		scif_sas_smp_io_request.c scif_sas_smp_phy.c \
+		scif_sas_smp_remote_device.c scif_sas_stp_io_request.c \
+		scif_sas_stp_remote_device.c scif_sas_stp_task_request.c \
+		scif_sas_task_request.c scif_sas_task_request_state_handlers.c \
+		scif_sas_task_request_states.c scif_sas_timer.c
+
+SRCS += \
+		sati.c \
+		sati_abort_task_set.c sati_atapi.c \
+		sati_device.c sati_inquiry.c sati_log_sense.c \
+		sati_lun_reset.c sati_mode_pages.c sati_mode_select.c \
+		sati_mode_sense.c sati_mode_sense_6.c sati_mode_sense_10.c \
+		sati_move.c sati_passthrough.c sati_read.c sati_read_buffer.c \
+		sati_read_capacity.c  \
+		sati_report_luns.c sati_request_sense.c sati_reassign_blocks.c \
+		sati_start_stop_unit.c sati_synchronize_cache.c \
+		sati_test_unit_ready.c sati_unmap.c sati_util.c \
+		sati_verify.c sati_write.c  \
+		sati_write_buffer.c sati_write_long.c sati_write_and_verify.c
+
+SRCS += opt_scsi.h opt_cam.h opt_isci.h
+SRCS += device_if.h bus_if.h pci_if.h
+
+CC	= gcc
+
+.include <bsd.kmod.mk>
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/modules/ixgbe/Makefile
--- a/head/sys/modules/ixgbe/Makefile	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/modules/ixgbe/Makefile	Wed Feb 01 12:34:54 2012 +0200
@@ -1,11 +1,11 @@
-#$FreeBSD$
+#$FreeBSD: head/sys/modules/ixgbe/Makefile 230775 2012-01-30 16:42:02Z jfv $
 .PATH:  ${.CURDIR}/../../dev/ixgbe
 KMOD    = ixgbe
 SRCS    = device_if.h bus_if.h pci_if.h
 SRCS    += ixgbe.c ixv.c
 # Shared source
 SRCS    += ixgbe_common.c ixgbe_api.c ixgbe_phy.c ixgbe_mbx.c ixgbe_vf.c
-SRCS    += ixgbe_82599.c ixgbe_82598.c
+SRCS    += ixgbe_82599.c ixgbe_82598.c ixgbe_x540.c
 CFLAGS+= -I${.CURDIR}/../../dev/ixgbe -DSMP -DIXGBE_FDIR
 
 .include <bsd.kmod.mk>
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/modules/mps/Makefile
--- a/head/sys/modules/mps/Makefile	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/modules/mps/Makefile	Wed Feb 01 12:34:54 2012 +0200
@@ -1,13 +1,14 @@
-# $FreeBSD$
+# $FreeBSD: head/sys/modules/mps/Makefile 230592 2012-01-26 18:17:21Z ken $
 
 .PATH: ${.CURDIR}/../../dev/mps
 
 KMOD=	mps
 SRCS=	mps_pci.c mps.c mps_sas.c mps_table.c mps_user.c
-SRCS+=	opt_mps.h opt_cam.h opt_compat.h
+SRCS+=	mps_config.c mps_mapping.c mps_sas_lsi.c
+SRCS+=	opt_cam.h opt_compat.h
 SRCS+=	device_if.h bus_if.h pci_if.h
 
 #CFLAGS += -DMPS_DEBUG
-DEBUG += -g
+DEBUG_FLAGS += -g
 
 .include <bsd.kmod.mk>
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/modules/sound/driver/maestro3/Makefile
--- a/head/sys/modules/sound/driver/maestro3/Makefile	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/modules/sound/driver/maestro3/Makefile	Wed Feb 01 12:34:54 2012 +0200
@@ -1,9 +1,10 @@
-# $FreeBSD$
+# $FreeBSD: head/sys/modules/sound/driver/maestro3/Makefile 230401 2012-01-20 22:37:10Z pfg $
 
 .PATH: ${.CURDIR}/../../../../dev/sound/pci
 
 KMOD=	snd_maestro3
 SRCS=	device_if.h bus_if.h pci_if.h
+SRCS+=	allegro_code.h allegro_reg.h
 SRCS+=	maestro3.c
 
 CFLAGS+= -Wall -DM3_DEBUG_LEVEL=-1
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/modules/wtap/Makefile
--- a/head/sys/modules/wtap/Makefile	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/modules/wtap/Makefile	Wed Feb 01 12:34:54 2012 +0200
@@ -1,11 +1,11 @@
-# $FreeBSD: head/sys/modules/wtap/Makefile 229970 2012-01-11 17:41:14Z adrian $
+# $FreeBSD: head/sys/modules/wtap/Makefile 230273 2012-01-17 18:20:34Z adrian $
 
-.PATH:	${.CURDIR}/../../dev/wtap
 
 # Declare Name of kernel module
 KMOD	=  wtap
 
 # Enumerate Source files for kernel module
+.PATH:	${.CURDIR}/../../dev/wtap
 SRCS	=  if_wtap_module.c if_wtap.c if_medium.c
 
 .PATH:	${.CURDIR}/../../dev/wtap/wtap_hal
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/nlm/nlm_prot_impl.c
--- a/head/sys/nlm/nlm_prot_impl.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/nlm/nlm_prot_impl.c	Wed Feb 01 12:34:54 2012 +0200
@@ -28,7 +28,7 @@
 #include "opt_inet6.h"
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/nlm/nlm_prot_impl.c 227309 2011-11-07 15:43:11Z ed $");
+__FBSDID("$FreeBSD: head/sys/nlm/nlm_prot_impl.c 230801 2012-01-31 02:11:05Z rmacklem $");
 
 #include <sys/param.h>
 #include <sys/fail.h>
@@ -1775,10 +1775,10 @@
 
 static int
 nlm_get_vfs_state(struct nlm_host *host, struct svc_req *rqstp,
-    fhandle_t *fhp, struct vfs_state *vs)
+    fhandle_t *fhp, struct vfs_state *vs, accmode_t accmode)
 {
 	int error, exflags;
-	struct ucred *cred = NULL, *credanon;
+	struct ucred *cred = NULL, *credanon = NULL;
 	
 	memset(vs, 0, sizeof(*vs));
 
@@ -1788,14 +1788,19 @@
 	}
 	vs->vs_vfslocked = VFS_LOCK_GIANT(vs->vs_mp);
 
-	error = VFS_CHECKEXP(vs->vs_mp, (struct sockaddr *)&host->nh_addr,
-	    &exflags, &credanon, NULL, NULL);
-	if (error)
-		goto out;
+	/* accmode == 0 means don't check, since it is an unlock. */
+	if (accmode != 0) {
+		error = VFS_CHECKEXP(vs->vs_mp,
+		    (struct sockaddr *)&host->nh_addr, &exflags, &credanon,
+		    NULL, NULL);
+		if (error)
+			goto out;
 
-	if (exflags & MNT_EXRDONLY || (vs->vs_mp->mnt_flag & MNT_RDONLY)) {
-		error = EROFS;
-		goto out;
+		if (exflags & MNT_EXRDONLY ||
+		    (vs->vs_mp->mnt_flag & MNT_RDONLY)) {
+			error = EROFS;
+			goto out;
+		}
 	}
 
 	error = VFS_FHTOVP(vs->vs_mp, &fhp->fh_fid, LK_EXCLUSIVE, &vs->vs_vp);
@@ -1803,22 +1808,31 @@
 		goto out;
 	vs->vs_vnlocked = TRUE;
 
-	if (!svc_getcred(rqstp, &cred, NULL)) {
-		error = EINVAL;
-		goto out;
+	if (accmode != 0) {
+		if (!svc_getcred(rqstp, &cred, NULL)) {
+			error = EINVAL;
+			goto out;
+		}
+		if (cred->cr_uid == 0 || (exflags & MNT_EXPORTANON)) {
+			crfree(cred);
+			cred = credanon;
+			credanon = NULL;
+		}
+
+		/*
+		 * Check cred.
+		 */
+		error = VOP_ACCESS(vs->vs_vp, accmode, cred, curthread);
+		/*
+		 * If this failed and accmode != VWRITE, try again with
+		 * VWRITE to maintain backwards compatibility with the
+		 * old code that always used VWRITE.
+		 */
+		if (error != 0 && accmode != VWRITE)
+			error = VOP_ACCESS(vs->vs_vp, VWRITE, cred, curthread);
+		if (error)
+			goto out;
 	}
-	if (cred->cr_uid == 0 || (exflags & MNT_EXPORTANON)) {
-		crfree(cred);
-		cred = credanon;
-		credanon = NULL;
-	}
-
-	/*
-	 * Check cred.
-	 */
-	error = VOP_ACCESS(vs->vs_vp, VWRITE, cred, curthread);
-	if (error)
-		goto out;
 
 #if __FreeBSD_version < 800011
 	VOP_UNLOCK(vs->vs_vp, 0, curthread);
@@ -1872,6 +1886,7 @@
 	struct nlm_host *host, *bhost;
 	int error, sysid;
 	struct flock fl;
+	accmode_t accmode;
 	
 	memset(result, 0, sizeof(*result));
 	memset(&vs, 0, sizeof(vs));
@@ -1897,7 +1912,8 @@
 		goto out;
 	}
 
-	error = nlm_get_vfs_state(host, rqstp, &fh, &vs);
+	accmode = argp->exclusive ? VWRITE : VREAD;
+	error = nlm_get_vfs_state(host, rqstp, &fh, &vs, accmode);
 	if (error) {
 		result->stat.stat = nlm_convert_error(error);
 		goto out;
@@ -1968,6 +1984,7 @@
 	struct nlm_host *host;
 	int error, sysid;
 	struct flock fl;
+	accmode_t accmode;
 	
 	memset(result, 0, sizeof(*result));
 	memset(&vs, 0, sizeof(vs));
@@ -2002,7 +2019,8 @@
 		goto out;
 	}
 
-	error = nlm_get_vfs_state(host, rqstp, &fh, &vs);
+	accmode = argp->exclusive ? VWRITE : VREAD;
+	error = nlm_get_vfs_state(host, rqstp, &fh, &vs, accmode);
 	if (error) {
 		result->stat.stat = nlm_convert_error(error);
 		goto out;
@@ -2181,7 +2199,7 @@
 		goto out;
 	}
 
-	error = nlm_get_vfs_state(host, rqstp, &fh, &vs);
+	error = nlm_get_vfs_state(host, rqstp, &fh, &vs, (accmode_t)0);
 	if (error) {
 		result->stat.stat = nlm_convert_error(error);
 		goto out;
@@ -2270,7 +2288,7 @@
 		goto out;
 	}
 
-	error = nlm_get_vfs_state(host, rqstp, &fh, &vs);
+	error = nlm_get_vfs_state(host, rqstp, &fh, &vs, (accmode_t)0);
 	if (error) {
 		result->stat.stat = nlm_convert_error(error);
 		goto out;
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/sys/cdefs.h
--- a/head/sys/sys/cdefs.h	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/sys/cdefs.h	Wed Feb 01 12:34:54 2012 +0200
@@ -30,7 +30,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)cdefs.h	8.8 (Berkeley) 1/9/95
- * $FreeBSD: head/sys/sys/cdefs.h 229574 2012-01-05 10:43:03Z ed $
+ * $FreeBSD: head/sys/sys/cdefs.h 230277 2012-01-17 20:21:31Z ed $
  */
 
 #ifndef	_SYS_CDEFS_H_
@@ -260,7 +260,7 @@
 #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
 #define	__generic(expr, t, yes, no)					\
 	_Generic(expr, t: yes, default: no)
-#elif __GNUC_PREREQ__(3, 1)
+#elif __GNUC_PREREQ__(3, 1) && !defined(__cplusplus)
 #define	__generic(expr, t, yes, no)					\
 	__builtin_choose_expr(						\
 	    __builtin_types_compatible_p(__typeof(expr), t), yes, no)
@@ -468,7 +468,7 @@
  * Embed the rcs id of a source file in the resulting library.  Note that in
  * more recent ELF binutils, we use .ident allowing the ID to be stripped.
  * Usage:
- *	__FBSDID("$FreeBSD: head/sys/sys/cdefs.h 229574 2012-01-05 10:43:03Z ed $");
+ *	__FBSDID("$FreeBSD: head/sys/sys/cdefs.h 230277 2012-01-17 20:21:31Z ed $");
  */
 #ifndef	__FBSDID
 #if !defined(lint) && !defined(STRIP_FBSDID)
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/sys/diskmbr.h
--- a/head/sys/sys/diskmbr.h	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/sys/diskmbr.h	Wed Feb 01 12:34:54 2012 +0200
@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)disklabel.h	8.2 (Berkeley) 7/10/94
- * $FreeBSD: head/sys/sys/diskmbr.h 223587 2011-06-27 10:42:06Z ae $
+ * $FreeBSD: head/sys/sys/diskmbr.h 230522 2012-01-25 03:37:39Z nwhitehorn $
  */
 
 #ifndef _SYS_DISKMBR_H_
@@ -48,6 +48,7 @@
 #define	DOSPTYP_NTFS	0x07	/* NTFS partition */
 #define	DOSPTYP_FAT32	0x0b	/* FAT32 partition */
 #define	DOSPTYP_EXTLBA	0x0f	/* DOS extended partition */
+#define	DOSPTYP_PPCBOOT	0x41	/* PReP/CHRP boot partition */
 #define	DOSPTYP_386BSD	0xa5	/* 386BSD partition type */
 #define	DOSPTYP_LINSWP	0x82	/* Linux swap partition */
 #define	DOSPTYP_LINUX	0x83	/* Linux partition */
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/sys/elf_common.h
--- a/head/sys/sys/elf_common.h	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/sys/elf_common.h	Wed Feb 01 12:34:54 2012 +0200
@@ -24,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: head/sys/sys/elf_common.h 228434 2011-12-12 10:10:49Z kib $
+ * $FreeBSD: head/sys/sys/elf_common.h 230783 2012-01-30 19:50:13Z kib $
  */
 
 #ifndef _SYS_ELF_COMMON_H_
@@ -328,6 +328,7 @@
 #define	PT_SUNW_UNWIND	0x6464e550	/* amd64 UNWIND program header */
 #define	PT_GNU_EH_FRAME	0x6474e550
 #define	PT_GNU_STACK	0x6474e551
+#define	PT_GNU_RELRO	0x6474e552
 #define	PT_LOSUNW	0x6ffffffa
 #define	PT_SUNWBSS	0x6ffffffa	/* Sun Specific segment */
 #define	PT_SUNWSTACK	0x6ffffffb	/* describes the stack segment */
@@ -384,7 +385,7 @@
 #define	DT_INIT_ARRAYSZ	27	/* Size in bytes of the array of
 				   initialization functions. */
 #define	DT_FINI_ARRAYSZ	28	/* Size in bytes of the array of
-				   terminationfunctions. */
+				   termination functions. */
 #define	DT_RUNPATH	29	/* String table offset of a null-terminated
 				   library search path string. */
 #define	DT_FLAGS	30	/* Object specific flag values. */
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/sys/malloc.h
--- a/head/sys/sys/malloc.h	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/sys/malloc.h	Wed Feb 01 12:34:54 2012 +0200
@@ -29,7 +29,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)malloc.h	8.5 (Berkeley) 5/3/95
- * $FreeBSD$
+ * $FreeBSD: head/sys/sys/malloc.h 230623 2012-01-27 20:18:31Z kmacy $
  */
 
 #ifndef _SYS_MALLOC_H_
@@ -50,6 +50,7 @@
 #define	M_ZERO		0x0100		/* bzero the allocation */
 #define	M_NOVM		0x0200		/* don't ask VM for pages */
 #define	M_USE_RESERVE	0x0400		/* can alloc out of reserve memory */
+#define	M_NODUMP	0x0800		/* don't dump pages in this allocation */
 
 #define	M_MAGIC		877983977	/* time when first defined :-) */
 
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/sys/mbuf.h
--- a/head/sys/sys/mbuf.h	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/sys/mbuf.h	Wed Feb 01 12:34:54 2012 +0200
@@ -28,7 +28,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)mbuf.h	8.5 (Berkeley) 2/19/95
- * $FreeBSD: head/sys/sys/mbuf.h 230210 2012-01-16 10:58:14Z glebius $
+ * $FreeBSD: head/sys/sys/mbuf.h 230264 2012-01-17 12:13:36Z glebius $
  */
 
 #ifndef _SYS_MBUF_H_
@@ -398,6 +398,8 @@
 
 static __inline struct mbuf	*m_getcl(int how, short type, int flags);
 static __inline struct mbuf	*m_get(int how, short type);
+static __inline struct mbuf	*m_get2(int how, short type, int flags,
+				    int size);
 static __inline struct mbuf	*m_gethdr(int how, short type);
 static __inline struct mbuf	*m_getjcl(int how, short type, int flags,
 				    int size);
@@ -436,7 +438,7 @@
 		type = EXT_JUMBO16;
 		break;
 	default:
-		panic("%s: m_getjcl: invalid cluster size", __func__);
+		panic("%s: invalid cluster size", __func__);
 	}
 
 	return (type);
@@ -463,7 +465,7 @@
 		zone = zone_jumbo16;
 		break;
 	default:
-		panic("%s: m_getjcl: invalid cluster type", __func__);
+		panic("%s: invalid cluster size", __func__);
 	}
 
 	return (zone);
@@ -544,6 +546,52 @@
 }
 
 /*
+ * m_get2() allocates minimum mbuf that would fit "size" argument.
+ *
+ * XXX: This is rather large, should be real function maybe.
+ */
+static __inline struct mbuf *
+m_get2(int how, short type, int flags, int size)
+{
+	struct mb_args args;
+	struct mbuf *m, *n;
+	uma_zone_t zone;
+
+	args.flags = flags;
+	args.type = type;
+
+	if (size <= MHLEN || (size <= MLEN && (flags & M_PKTHDR) == 0))
+		return ((struct mbuf *)(uma_zalloc_arg(zone_mbuf, &args, how)));
+	if (size <= MCLBYTES)
+		return ((struct mbuf *)(uma_zalloc_arg(zone_pack, &args, how)));
+
+	if (size > MJUM16BYTES)
+		return (NULL);
+
+	m = uma_zalloc_arg(zone_mbuf, &args, how);
+	if (m == NULL)
+		return (NULL);
+
+#if MJUMPAGESIZE != MCLBYTES
+	if (size <= MJUMPAGESIZE)
+		zone = zone_jumbop;
+	else
+#endif
+	if (size <= MJUM9BYTES)
+		zone = zone_jumbo9;
+	else
+		zone = zone_jumbo16;
+
+	n = uma_zalloc_arg(zone, m, how);
+	if (n == NULL) {
+		uma_zfree(zone_mbuf, m);
+		return (NULL);
+	}
+
+	return (m);
+}
+
+/*
  * m_getjcl() returns an mbuf with a cluster of the specified size attached.
  * For size it takes MCLBYTES, MJUMPAGESIZE, MJUM9BYTES, MJUM16BYTES.
  *
@@ -663,7 +711,7 @@
 		zone = zone_jumbo16;
 		break;
 	default:
-		panic("unknown cluster type");
+		panic("%s: unknown cluster type", __func__);
 		break;
 	}
 
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/sys/mdioctl.h
--- a/head/sys/sys/mdioctl.h	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/sys/mdioctl.h	Wed Feb 01 12:34:54 2012 +0200
@@ -37,7 +37,7 @@
  *
  * From: src/sys/sys/vnioctl.h,v 1.4
  *
- * $FreeBSD$
+ * $FreeBSD: head/sys/sys/mdioctl.h 230536 2012-01-25 11:28:18Z trasz $
  */
 
 #ifndef _SYS_MDIOCTL_H_
@@ -86,6 +86,6 @@
 #define MD_READONLY	0x08	/* Readonly mode */
 #define MD_COMPRESS	0x10	/* Compression mode */
 #define MD_FORCE	0x20	/* Don't try to prevent foot-shooting */
-#define MD_ASYNC	0x40	/* Don't try to prevent foot-shooting */
+#define MD_ASYNC	0x40	/* Asynchronous mode */
 
 #endif	/* _SYS_MDIOCTL_H_*/
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/sys/mount.h
--- a/head/sys/sys/mount.h	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/sys/mount.h	Wed Feb 01 12:34:54 2012 +0200
@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)mount.h	8.21 (Berkeley) 5/20/95
- * $FreeBSD: head/sys/sys/mount.h 224294 2011-07-24 18:27:09Z mckusick $
+ * $FreeBSD: head/sys/sys/mount.h 230249 2012-01-17 01:08:01Z mckusick $
  */
 
 #ifndef _SYS_MOUNT_H_
@@ -557,7 +557,7 @@
 struct sysctl_req;
 struct mntarg;
 
-typedef int vfs_cmount_t(struct mntarg *ma, void *data, int flags);
+typedef int vfs_cmount_t(struct mntarg *ma, void *data, uint64_t flags);
 typedef int vfs_unmount_t(struct mount *mp, int mntflags);
 typedef int vfs_root_t(struct mount *mp, int flags, struct vnode **vpp);
 typedef	int vfs_quotactl_t(struct mount *mp, int cmds, uid_t uid, void *arg);
@@ -700,7 +700,7 @@
 
 int	dounmount(struct mount *, int, struct thread *);
 
-int	kernel_mount(struct mntarg *ma, int flags);
+int	kernel_mount(struct mntarg *ma, uint64_t flags);
 int	kernel_vmount(int flags, ...);
 struct mntarg *mount_arg(struct mntarg *ma, const char *name, const void *val, int len);
 struct mntarg *mount_argb(struct mntarg *ma, int flag, const char *name);
@@ -737,7 +737,8 @@
 	    (struct mount *, struct export_args *);
 void	vfs_allocate_syncvnode(struct mount *);
 void	vfs_deallocate_syncvnode(struct mount *);
-int	vfs_donmount(struct thread *td, int fsflags, struct uio *fsoptions);
+int	vfs_donmount(struct thread *td, uint64_t fsflags,
+	    struct uio *fsoptions);
 void	vfs_getnewfsid(struct mount *);
 struct cdev *vfs_getrootfsid(struct mount *);
 struct	mount *vfs_getvfs(fsid_t *);      /* return vfs given fsid */
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/sys/param.h
--- a/head/sys/sys/param.h	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/sys/param.h	Wed Feb 01 12:34:54 2012 +0200
@@ -32,7 +32,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)param.h	8.3 (Berkeley) 4/4/95
- * $FreeBSD: head/sys/sys/param.h 230207 2012-01-16 09:53:24Z glebius $
+ * $FreeBSD: head/sys/sys/param.h 230590 2012-01-26 18:09:28Z ken $
  */
 
 #ifndef _SYS_PARAM_H_
@@ -58,7 +58,7 @@
  *		in the range 5 to 9.
  */
 #undef __FreeBSD_version
-#define __FreeBSD_version 1000005	/* Master, propagated to newvers */
+#define __FreeBSD_version 1000006	/* Master, propagated to newvers */
 
 /*
  * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/sys/proc.h
--- a/head/sys/sys/proc.h	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/sys/proc.h	Wed Feb 01 12:34:54 2012 +0200
@@ -32,7 +32,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)proc.h	8.15 (Berkeley) 5/19/95
- * $FreeBSD: head/sys/sys/proc.h 230145 2012-01-15 18:47:24Z trociny $
+ * $FreeBSD: head/sys/sys/proc.h 230643 2012-01-28 14:00:21Z attilio $
  */
 
 #ifndef _SYS_PROC_H_
@@ -235,6 +235,7 @@
 	short		td_locks;	/* (k) Count of non-spin locks. */
 	short		td_rw_rlocks;	/* (k) Count of rwlock read locks. */
 	short		td_lk_slocks;	/* (k) Count of lockmgr shared locks. */
+	short		td_stopsched;	/* (k) Scheduler stopped. */
 	struct turnstile *td_blocked;	/* (t) Lock thread is blocked on. */
 	const char	*td_lockname;	/* (t) Name of lock blocked on. */
 	LIST_HEAD(, turnstile) td_contested;	/* (q) Contested locks. */
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/sys/resourcevar.h
--- a/head/sys/sys/resourcevar.h	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/sys/resourcevar.h	Wed Feb 01 12:34:54 2012 +0200
@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)resourcevar.h	8.4 (Berkeley) 1/9/95
- * $FreeBSD: head/sys/sys/resourcevar.h 224188 2011-07-18 17:33:08Z jhb $
+ * $FreeBSD: head/sys/sys/resourcevar.h 230470 2012-01-22 20:25:00Z trociny $
  */
 
 #ifndef	_SYS_RESOURCEVAR_H_
@@ -120,6 +120,8 @@
 	    rlim_t maxval);
 int	 chgptscnt(struct uidinfo *uip, int diff, rlim_t maxval);
 int	 fuswintr(void *base);
+int	 kern_proc_setrlimit(struct thread *td, struct proc *p, u_int which,
+	    struct rlimit *limp);
 struct plimit
 	*lim_alloc(void);
 void	 lim_copy(struct plimit *dst, struct plimit *src);
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/sys/signal.h
--- a/head/sys/sys/signal.h	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/sys/signal.h	Wed Feb 01 12:34:54 2012 +0200
@@ -32,7 +32,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)signal.h	8.4 (Berkeley) 5/4/95
- * $FreeBSD$
+ * $FreeBSD: head/sys/sys/signal.h 230857 2012-02-01 02:53:06Z davidxu $
  */
 
 #ifndef _SYS_SIGNAL_H_
@@ -169,12 +169,14 @@
 			void (*_function)(union sigval);
 			void *_attribute; /* pthread_attr_t * */
 		} _sigev_thread;
+		unsigned short _kevent_flags;
 		long __spare__[8];
 	} _sigev_un;
 };
 
 #if __BSD_VISIBLE
 #define	sigev_notify_kqueue		sigev_signo
+#define	sigev_notify_kevent_flags	_sigev_un._kevent_flags
 #define	sigev_notify_thread_id		_sigev_un._threadid
 #endif
 #define	sigev_notify_function		_sigev_un._sigev_thread._function
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/sys/systm.h
--- a/head/sys/sys/systm.h	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/sys/systm.h	Wed Feb 01 12:34:54 2012 +0200
@@ -32,7 +32,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)systm.h	8.7 (Berkeley) 3/29/95
- * $FreeBSD: head/sys/sys/systm.h 228478 2011-12-13 19:39:24Z ed $
+ * $FreeBSD: head/sys/sys/systm.h 230643 2012-01-28 14:00:21Z attilio $
  */
 
 #ifndef _SYS_SYSTM_H_
@@ -47,7 +47,6 @@
 
 extern int cold;		/* nonzero if we are doing a cold boot */
 extern int rebooting;		/* kern_reboot() has been called. */
-extern int stop_scheduler;	/* only one thread runs after panic */
 extern const char *panicstr;	/* panic message */
 extern char version[];		/* system version */
 extern char copyright[];	/* system copyright */
@@ -113,7 +112,7 @@
  * Otherwise, the kernel will deadlock since the scheduler isn't
  * going to run the thread that holds any lock we need.
  */
-#define	SCHEDULER_STOPPED() __predict_false(stop_scheduler)
+#define	SCHEDULER_STOPPED() __predict_false(curthread->td_stopsched)
 
 /*
  * XXX the hints declarations are even more misplaced than most declarations
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/sys/types.h
--- a/head/sys/sys/types.h	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/sys/types.h	Wed Feb 01 12:34:54 2012 +0200
@@ -32,7 +32,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)types.h	8.6 (Berkeley) 2/19/95
- * $FreeBSD: head/sys/sys/types.h 228468 2011-12-13 13:32:56Z ed $
+ * $FreeBSD: head/sys/sys/types.h 230808 2012-01-31 13:00:40Z pluknet $
  */
 
 #ifndef _SYS_TYPES_H_
@@ -73,7 +73,6 @@
 
 typedef	char *		caddr_t;	/* core address */
 typedef	const char *	c_caddr_t;	/* core address, pointer to const */
-typedef	__volatile char *v_caddr_t;	/* core address, pointer to volatile */
 
 #ifndef _BLKSIZE_T_DECLARED
 typedef	__blksize_t	blksize_t;
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/sys/ucontext.h
--- a/head/sys/sys/ucontext.h	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/sys/ucontext.h	Wed Feb 01 12:34:54 2012 +0200
@@ -25,7 +25,7 @@
  * (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$
+ * $FreeBSD: head/sys/sys/ucontext.h 230429 2012-01-21 18:00:28Z kib $
  */
 
 #ifndef _SYS_UCONTEXT_H_
@@ -72,11 +72,17 @@
 __BEGIN_DECLS
 
 int	getcontext(ucontext_t *);
+ucontext_t *getcontextx(void);
 int	setcontext(const ucontext_t *);
 void	makecontext(ucontext_t *, void (*)(void), int, ...);
 int	signalcontext(ucontext_t *, int, __sighandler_t *);
 int	swapcontext(ucontext_t *, const ucontext_t *);
 
+#if __BSD_VISIBLE
+size_t __getcontextx_size(void);
+int __fillcontextx(char *ctx);
+#endif
+
 __END_DECLS
 
 #else /* _KERNEL */
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/sys/vnode.h
--- a/head/sys/sys/vnode.h	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/sys/vnode.h	Wed Feb 01 12:34:54 2012 +0200
@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)vnode.h	8.7 (Berkeley) 2/4/94
- * $FreeBSD: head/sys/sys/vnode.h 230129 2012-01-15 12:08:20Z mm $
+ * $FreeBSD: head/sys/sys/vnode.h 230394 2012-01-20 20:02:01Z jhb $
  */
 
 #ifndef _SYS_VNODE_H_
@@ -578,10 +578,14 @@
 struct vnode;
 
 /* cache_* may belong in namei.h. */
-void	cache_enter(struct vnode *dvp, struct vnode *vp,
-	    struct componentname *cnp);
-int	cache_lookup(struct vnode *dvp, struct vnode **vpp,
-	    struct componentname *cnp);
+#define	cache_enter(dvp, vp, cnp)					\
+	cache_enter_time(dvp, vp, cnp, NULL)
+void	cache_enter_time(struct vnode *dvp, struct vnode *vp,
+	    struct componentname *cnp, struct timespec *tsp);
+#define	cache_lookup(dvp, vpp, cnp)					\
+	cache_lookup_times(dvp, vpp, cnp, NULL, NULL)
+int	cache_lookup_times(struct vnode *dvp, struct vnode **vpp,
+	    struct componentname *cnp, struct timespec *tsp, int *ticksp);
 void	cache_purge(struct vnode *vp);
 void	cache_purge_negative(struct vnode *vp);
 void	cache_purgevfs(struct mount *mp);
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/ufs/ffs/ffs_snapshot.c
--- a/head/sys/ufs/ffs/ffs_snapshot.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/ufs/ffs/ffs_snapshot.c	Wed Feb 01 12:34:54 2012 +0200
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/ufs/ffs/ffs_snapshot.c 225807 2011-09-27 17:41:48Z mckusick $");
+__FBSDID("$FreeBSD: head/sys/ufs/ffs/ffs_snapshot.c 230250 2012-01-17 01:14:56Z mckusick $");
 
 #include "opt_quota.h"
 
@@ -225,10 +225,18 @@
 	ump = VFSTOUFS(mp);
 	fs = ump->um_fs;
 	sn = NULL;
+	/*
+	 * At the moment, journaled soft updates cannot support
+	 * taking snapshots.
+	 */
+	if (MOUNTEDSUJ(mp)) {
+		vfs_mount_error(mp, "%s: Snapshots are not yet supported when "
+		    "running with journaled soft updates", fs->fs_fsmnt);
+		return (EOPNOTSUPP);
+	}
 	MNT_ILOCK(mp);
 	flag = mp->mnt_flag;
 	MNT_IUNLOCK(mp);
-
 	/*
 	 * Need to serialize access to snapshot code per filesystem.
 	 */
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/ufs/ffs/ffs_vfsops.c
--- a/head/sys/ufs/ffs/ffs_vfsops.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/ufs/ffs/ffs_vfsops.c	Wed Feb 01 12:34:54 2012 +0200
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/ufs/ffs/ffs_vfsops.c 230101 2012-01-14 07:26:16Z mckusick $");
+__FBSDID("$FreeBSD: head/sys/ufs/ffs/ffs_vfsops.c 230249 2012-01-17 01:08:01Z mckusick $");
 
 #include "opt_quota.h"
 #include "opt_ufs.h"
@@ -144,7 +144,7 @@
 	struct fs *fs;
 	pid_t fsckpid = 0;
 	int error, flags;
-	u_int mntorflags;
+	uint64_t mntorflags;
 	accmode_t accmode;
 	struct nameidata ndp;
 	char *fspec;
@@ -571,7 +571,7 @@
  */
 
 static int
-ffs_cmount(struct mntarg *ma, void *data, int flags)
+ffs_cmount(struct mntarg *ma, void *data, uint64_t flags)
 {
 	struct ufs_args args;
 	struct export_args exp;
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/ufs/ufs/ufs_dirhash.c
--- a/head/sys/ufs/ufs/ufs_dirhash.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/ufs/ufs/ufs_dirhash.c	Wed Feb 01 12:34:54 2012 +0200
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: head/sys/ufs/ufs/ufs_dirhash.c 230221 2012-01-16 15:47:42Z ivoras $");
 
 #include "opt_ufs.h"
 
@@ -1248,7 +1248,12 @@
 {
 	struct dirhash *dh, *dh_temp;
 	int memfreed = 0;
-	/* XXX: this 10% may need to be adjusted */
+	/* 
+	 * Will free a *minimum* of 10% of the dirhash, but possibly much
+	 * more (depending on dirhashreclaimage). System with large dirhashes
+	 * probably also need a much larger dirhashreclaimage.
+	 * XXX: this percentage may need to be adjusted.
+	 */
 	int memwanted = ufs_dirhashmem / 10;
 
 	ufs_dirhashlowmemcount++;
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/sys/xen/interface/io/netif.h
--- a/head/sys/xen/interface/io/netif.h	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/sys/xen/interface/io/netif.h	Wed Feb 01 12:34:54 2012 +0200
@@ -42,7 +42,7 @@
  * This is the 'wire' format for packets:
  *  Request 1: netif_tx_request -- NETTXF_* (any flags)
  * [Request 2: netif_tx_extra]  (only if request 1 has NETTXF_extra_info)
- * [Request 3: netif_tx_extra]  (only if request 2 has XEN_NETIF_EXTRA_MORE)
+ * [Request 3: netif_tx_extra] (only if request 2 has XEN_NETIF_EXTRA_FLAG_MORE)
  *  Request 4: netif_tx_request -- NETTXF_more_data
  *  Request 5: netif_tx_request -- NETTXF_more_data
  *  ...
@@ -70,7 +70,9 @@
     uint16_t offset;       /* Offset within buffer page */
     uint16_t flags;        /* NETTXF_* */
     uint16_t id;           /* Echoed in response message. */
-    uint16_t size;         /* Packet size in bytes.       */
+    uint16_t size;         /* For the first request in a packet, the packet 
+			      size in bytes.  For subsequent requests, the 
+			      size of that request's associated data in bytes*/
 };
 typedef struct netif_tx_request netif_tx_request_t;
 
@@ -175,7 +177,7 @@
     uint16_t id;
     uint16_t offset;       /* Offset in page of start of received packet  */
     uint16_t flags;        /* NETRXF_* */
-    int16_t  status;       /* -ve: BLKIF_RSP_* ; +ve: Rx'ed pkt size. */
+    int16_t  status;       /* -ve: NETIF_RSP_* ; +ve: Rx'ed response size. */
 };
 typedef struct netif_rx_response netif_rx_response_t;
 
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/usr.bin/bc/bc.1
--- a/head/usr.bin/bc/bc.1	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/usr.bin/bc/bc.1	Wed Feb 01 12:34:54 2012 +0200
@@ -1,4 +1,4 @@
-.\"	$FreeBSD$
+.\"	$FreeBSD: head/usr.bin/bc/bc.1 230546 2012-01-25 18:49:11Z stefanf $
 .\"	$OpenBSD: bc.1,v 1.25 2010/01/02 19:48:56 schwarze Exp $
 .\"
 .\" Copyright (C) Caldera International Inc.  2001-2002.
@@ -82,8 +82,6 @@
 Allow specification of an arbitrary precision math library.
 The definitions in the library are available to command line
 expressions.
-Synonym for
-.Fl l .
 .It Fl v , Fl Fl version
 Prints version information.
 .El
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/usr.bin/fetch/fetch.c
--- a/head/usr.bin/fetch/fetch.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/usr.bin/fetch/fetch.c	Wed Feb 01 12:34:54 2012 +0200
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/usr.bin/fetch/fetch.c 225815 2011-09-27 19:02:44Z des $");
+__FBSDID("$FreeBSD: head/usr.bin/fetch/fetch.c 230307 2012-01-18 15:13:21Z des $");
 
 #include <sys/param.h>
 #include <sys/socket.h>
@@ -317,7 +317,7 @@
 	struct stat sb, nsb;
 	struct xferstat xs;
 	FILE *f, *of;
-	size_t size, wr;
+	size_t size, readcnt, wr;
 	off_t count;
 	char flags[8];
 	const char *slash;
@@ -636,21 +636,26 @@
 			stat_end(&xs);
 			siginfo = 0;
 		}
-		if ((size = fread(buf, 1, size, f)) == 0) {
+
+		if (size == 0)
+			break;
+
+		if ((readcnt = fread(buf, 1, size, f)) < size) {
 			if (ferror(f) && errno == EINTR && !sigint)
 				clearerr(f);
-			else
+			else if (readcnt == 0)
 				break;
 		}
-		stat_update(&xs, count += size);
-		for (ptr = buf; size > 0; ptr += wr, size -= wr)
-			if ((wr = fwrite(ptr, 1, size, of)) < size) {
+
+		stat_update(&xs, count += readcnt);
+		for (ptr = buf; readcnt > 0; ptr += wr, readcnt -= wr)
+			if ((wr = fwrite(ptr, 1, readcnt, of)) < readcnt) {
 				if (ferror(of) && errno == EINTR && !sigint)
 					clearerr(of);
 				else
 					break;
 			}
-		if (size != 0)
+		if (readcnt != 0)
 			break;
 	}
 	if (!sigalrm)
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/usr.bin/hexdump/parse.c
--- a/head/usr.bin/hexdump/parse.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/usr.bin/hexdump/parse.c	Wed Feb 01 12:34:54 2012 +0200
@@ -33,7 +33,7 @@
 #endif
 #endif /* not lint */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/usr.bin/hexdump/parse.c 229794 2012-01-07 23:15:21Z eadler $");
+__FBSDID("$FreeBSD: head/usr.bin/hexdump/parse.c 230649 2012-01-28 18:49:04Z tijl $");
 
 #include <sys/types.h>
 
@@ -451,21 +451,14 @@
 	char *p2;
 
 	/* alphabetic escape sequences have to be done in place */
-	for (p2 = p1; *p1; p1++, p2++) {
-		/* 
-		 * Let's take a peak at the next item and see whether or not
-		 * we need to escape the value...
-		 */
+	for (p2 = p1;; p1++, p2++) {
 		if (*p1 == '\\') {
-
 			p1++;
-
 			switch(*p1) {
-			/* A standalone `\' */
 			case '\0':
 				*p2 = '\\';
 				*++p2 = '\0';
-				break;
+				return;
 			case 'a':
 			     /* *p2 = '\a'; */
 				*p2 = '\007';
@@ -492,12 +485,12 @@
 				*p2 = *p1;
 				break;
 			}
-
-		} else
+		} else {
 			*p2 = *p1;
-
+			if (*p1 == '\0')
+				return;
+		}
 	}
-
 }
 
 void
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/usr.bin/last/last.1
--- a/head/usr.bin/last/last.1	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/usr.bin/last/last.1	Wed Feb 01 12:34:54 2012 +0200
@@ -26,7 +26,7 @@
 .\" SUCH DAMAGE.
 .\"
 .\"     @(#)last.1	8.1 (Berkeley) 6/6/93
-.\" $FreeBSD$
+.\" $FreeBSD: head/usr.bin/last/last.1 230458 2012-01-22 11:34:24Z hrs $
 .\"
 .Dd July 27, 2003
 .Dt LAST 1
@@ -198,6 +198,7 @@
 .El
 .Sh SEE ALSO
 .Xr lastcomm 1 ,
+.Xr lastlogin 8 ,
 .Xr getutxent 3 ,
 .Xr ac 8
 .Sh HISTORY
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/usr.bin/last/last.c
--- a/head/usr.bin/last/last.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/usr.bin/last/last.c	Wed Feb 01 12:34:54 2012 +0200
@@ -37,7 +37,7 @@
 static const char sccsid[] = "@(#)last.c	8.2 (Berkeley) 4/2/94";
 #endif /* not lint */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/usr.bin/last/last.c 227168 2011-11-06 08:15:41Z ed $");
+__FBSDID("$FreeBSD: head/usr.bin/last/last.c 230458 2012-01-22 11:34:24Z hrs $");
 
 #include <sys/param.h>
 #include <sys/stat.h>
@@ -83,7 +83,7 @@
 static const	char *crmsg;			/* cause of last reboot */
 static time_t	currentout;			/* current logout value */
 static long	maxrec;				/* records to display */
-static const	char *file = NULL;		/* wtmp file */
+static const	char *file = NULL;		/* utx.log file */
 static int	sflag = 0;			/* show delta in seconds */
 static int	width = 5;			/* show seconds in delta */
 static int	yflag;				/* show year */
@@ -194,7 +194,7 @@
 
 /*
  * wtmp --
- *	read through the wtmp file
+ *	read through the utx.log file
  */
 static void
 wtmp(void)
@@ -229,13 +229,13 @@
 		doentry(&buf[--amount]);
 
 	tm = localtime(&t);
-	(void) strftime(ct, sizeof(ct), "\nwtmp begins %+\n", tm);
-	printf("%s", ct);
+	(void) strftime(ct, sizeof(ct), "%+", tm);
+	printf("\n%s begins %s\n", ((file == NULL) ? "utx.log" : file), ct);
 }
 
 /*
  * doentry --
- *	process a single wtmp entry
+ *	process a single utx.log entry
  */
 static void
 doentry(struct utmpx *bp)
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/usr.bin/limits/limits.1
--- a/head/usr.bin/limits/limits.1	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/usr.bin/limits/limits.1	Wed Feb 01 12:34:54 2012 +0200
@@ -17,9 +17,9 @@
 .\" 5. Modifications may be freely made to this file providing the above
 .\"    conditions are met.
 .\"
-.\" $FreeBSD: head/usr.bin/limits/limits.1 220516 2011-04-10 10:17:01Z trasz $
+.\" $FreeBSD: head/usr.bin/limits/limits.1 230549 2012-01-25 20:14:41Z trociny $
 .\"
-.Dd April 10, 2011
+.Dd January 23, 2011
 .Dt LIMITS 1
 .Os
 .Sh NAME
@@ -27,7 +27,7 @@
 .Nd set or display process resource limits
 .Sh SYNOPSIS
 .Nm
-.Op Fl C Ar class | Fl U Ar user
+.Op Fl C Ar class | Fl P Ar pid | Fl U Ar user
 .Op Fl SHB
 .Op Fl ea
 .Op Fl bcdflmnstuvpw Op Ar val
@@ -143,6 +143,9 @@
 class are used, if it exists, or the
 .Dq Li root
 class if the user is a superuser account.
+.It Fl P Ar pid
+Select or set limits for the process identified by the
+.Ar pid .
 .It Fl S
 Select display or setting of
 .Dq soft
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/usr.bin/limits/limits.c
--- a/head/usr.bin/limits/limits.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/usr.bin/limits/limits.c	Wed Feb 01 12:34:54 2012 +0200
@@ -22,13 +22,14 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/usr.bin/limits/limits.c 228992 2011-12-30 11:02:40Z uqs $");
+__FBSDID("$FreeBSD: head/usr.bin/limits/limits.c 230549 2012-01-25 20:14:41Z trociny $");
 
 #include <err.h>
 #include <stdio.h>
 #include <string.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/sysctl.h>
 #include <sys/param.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -249,6 +250,8 @@
 static int getshelltype(void);
 static void print_limit(rlim_t limit, unsigned divisor, const char *inf,
 			const char *pfx, const char *sfx, const char *which);
+static void getrlimit_proc(pid_t pid, int resource, struct rlimit *rlp);
+static void setrlimit_proc(pid_t pid, int resource, const struct rlimit *rlp);
 extern char **environ;
 
 static const char rcs_string[] = RCS_STRING;
@@ -262,24 +265,24 @@
     int rcswhich, shelltype;
     int i, num_limits = 0;
     int ch, doeval = 0, doall = 0;
-    int rtrn;
+    int rtrn, setproc;
     login_cap_t * lc = NULL;
     enum { ANY=0, SOFT=1, HARD=2, BOTH=3, DISPLAYONLY=4 } type = ANY;
     enum { RCSUNKNOWN=0, RCSSET=1, RCSSEL=2 } todo = RCSUNKNOWN;
     int which_limits[RLIM_NLIMITS];
     rlim_t set_limits[RLIM_NLIMITS];
     struct rlimit limits[RLIM_NLIMITS];
+    pid_t pid;
 
     /* init resource tables */
     for (i = 0; i < RLIM_NLIMITS; i++) {
 	which_limits[i] = 0; /* Don't set/display any */
 	set_limits[i] = RLIM_INFINITY;
-	/* Get current resource values */
-	getrlimit(i, &limits[i]);
     }
 
+    pid = -1;
     optarg = NULL;
-    while ((ch = getopt(argc, argv, ":EeC:U:BSHab:c:d:f:l:m:n:s:t:u:v:p:w:")) != -1) {
+    while ((ch = getopt(argc, argv, ":EeC:U:BSHP:ab:c:d:f:l:m:n:s:t:u:v:p:w:")) != -1) {
 	switch(ch) {
 	case 'a':
 	    doall = 1;
@@ -312,6 +315,12 @@
 	case 'B':
 	    type = SOFT|HARD;
 	    break;
+	case 'P':
+	    if (!isdigit(*optarg) || (pid = atoi(optarg)) < 0) {
+		warnx("invalid pid `%s'", optarg);
+		usage();
+	    }
+	    break;
 	default:
 	case ':': /* Without arg */
 	    if ((p = strchr(rcs_string, optopt)) != NULL) {
@@ -335,6 +344,30 @@
 	optarg = NULL;
     }
 
+    if (pid != -1) {
+	if (cls != NULL) {
+	    warnx("-C cannot be used with -P option");
+	    usage();
+	}
+	if (pwd != NULL) {
+	    warnx("-U cannot be used with -P option");
+	    usage();
+	}
+    }
+
+    /* Get current resource values */
+    setproc = 0;
+    for (i = 0; i < RLIM_NLIMITS; i++) {
+	if (pid == -1) {
+	    getrlimit(i, &limits[i]);
+	} else if (doall || num_limits == 0) {
+	    getrlimit_proc(pid, i, &limits[i]);
+	} else if (which_limits[i] != 0) {
+	    getrlimit_proc(pid, i, &limits[i]);
+	    setproc = 1;
+	}
+    }
+
     /* If user was specified, get class from that */
     if (pwd != NULL)
 	lc = login_getpwclass(pwd);
@@ -414,6 +447,10 @@
 	    warnx("-e cannot be used with `cmd' option");
 	    usage();
 	}
+	if (pid != -1) {
+	    warnx("-P cannot be used with `cmd' option");
+	    usage();
+	}
 
 	login_close(lc);
 
@@ -440,6 +477,14 @@
 	err(1, "%s", *argv);
     }
 
+    if (setproc) {
+	for (rcswhich = 0; rcswhich < RLIM_NLIMITS; rcswhich++) {
+	    if (which_limits[rcswhich] != 0)
+		setrlimit_proc(pid, rcswhich, &limits[rcswhich]);
+	}
+	exit(EXIT_SUCCESS);
+    }
+
     shelltype = doeval ? getshelltype() : SH_NONE;
 
     if (type == ANY) /* Default to soft limits */
@@ -493,7 +538,8 @@
 usage(void)
 {
     (void)fprintf(stderr,
-"usage: limits [-C class|-U user] [-eaSHBE] [-bcdflmnstuvpw [val]] [[name=val ...] cmd]\n");
+	"usage: limits [-C class|-P pid|-U user] [-eaSHBE] "
+	"[-bcdflmnstuvpw [val]] [[name=val ...] cmd]\n");
     exit(EXIT_FAILURE);
 }
 
@@ -677,3 +723,38 @@
     return SH_SH;
 }
 
+static void
+getrlimit_proc(pid_t pid, int resource, struct rlimit *rlp)
+{
+    int error;
+    int name[5];
+    size_t len;
+
+    name[0] = CTL_KERN;
+    name[1] = KERN_PROC;
+    name[2] = KERN_PROC_RLIMIT;
+    name[3] = pid;
+    name[4] = resource;
+    len = sizeof(*rlp);
+    error = sysctl(name, 5, rlp, &len, NULL, 0);
+    if (error == -1)
+	err(EXIT_FAILURE, "sysctl: kern.proc.rlimit: %d", pid);
+    if (len != sizeof(*rlp))
+	errx(EXIT_FAILURE, "sysctl() returns wrong size");
+}
+
+static void
+setrlimit_proc(pid_t pid, int resource, const struct rlimit *rlp)
+{
+    int error;
+    int name[5];
+
+    name[0] = CTL_KERN;
+    name[1] = KERN_PROC;
+    name[2] = KERN_PROC_RLIMIT;
+    name[3] = pid;
+    name[4] = resource;
+    error = sysctl(name, 5, NULL, 0, rlp, sizeof(*rlp));
+    if (error == -1)
+	err(EXIT_FAILURE, "sysctl: kern.proc.rlimit: %d", pid);
+}
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/usr.bin/make/main.c
--- a/head/usr.bin/make/main.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/usr.bin/make/main.c	Wed Feb 01 12:34:54 2012 +0200
@@ -46,7 +46,7 @@
 #endif
 #endif /* not lint */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/usr.bin/make/main.c 228992 2011-12-30 11:02:40Z uqs $");
+__FBSDID("$FreeBSD: head/usr.bin/make/main.c 230392 2012-01-20 18:55:56Z rmh $");
 
 /*
  * main.c
@@ -146,6 +146,14 @@
 time_t		now;		/* Time at start of make */
 struct GNode	*DEFAULT;	/* .DEFAULT node */
 
+static struct {
+	const char *foreign_name;
+	const char *freebsd_name;
+} arch_aliases[] = {
+	{ "x86_64", "amd64" },
+	{ "mipsel", "mips" },
+};
+
 /**
  * Exit with usage message.
  */
@@ -939,10 +947,19 @@
 	 */
 	if ((machine = getenv("MACHINE")) == NULL) {
 		static struct utsname utsname;
+		unsigned int i;
 
 		if (uname(&utsname) == -1)
 			err(2, "uname");
 		machine = utsname.machine;
+
+		/* Canonicalize non-FreeBSD naming conventions */
+		for (i = 0; i < sizeof(arch_aliases)
+		     / sizeof(arch_aliases[0]); i++)
+			if (!strcmp(machine, arch_aliases[i].foreign_name)) {
+				machine = arch_aliases[i].freebsd_name;
+				break;
+			}
 	}
 
 	if ((machine_arch = getenv("MACHINE_ARCH")) == NULL) {
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/usr.bin/netstat/netgraph.c
--- a/head/usr.bin/netstat/netgraph.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/usr.bin/netstat/netgraph.c	Wed Feb 01 12:34:54 2012 +0200
@@ -33,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: head/usr.bin/netstat/netgraph.c 230481 2012-01-23 15:39:45Z glebius $");
 
 #include <sys/param.h>
 #include <sys/queue.h>
@@ -67,7 +67,6 @@
 {
 	struct ngpcb *this, *next;
 	struct ngpcb ngpcb;
-	struct ngsock info;
 	struct socket sockb;
 	int debug = 1;
 
@@ -165,15 +164,10 @@
 		printf("%-5.5s %6u %6u ",
 		    name, sockb.so_rcv.sb_cc, sockb.so_snd.sb_cc);
 
-		/* Get ngsock structure */
-		if (ngpcb.sockdata == NULL)	/* unconnected data socket */
+		/* Get info on associated node */
+		if (ngpcb.node_id == 0 || csock == -1)
 			goto finish;
-		kread((u_long)ngpcb.sockdata, (char *)&info, sizeof(info));
-
-		/* Get info on associated node */
-		if (info.node_id == 0 || csock == -1)
-			goto finish;
-		snprintf(path, sizeof(path), "[%x]:", info.node_id);
+		snprintf(path, sizeof(path), "[%x]:", ngpcb.node_id);
 		if (NgSendMsg(csock, path,
 		    NGM_GENERIC_COOKIE, NGM_NODEINFO, NULL, 0) < 0)
 			goto finish;
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/usr.bin/netstat/sctp.c
--- a/head/usr.bin/netstat/sctp.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/usr.bin/netstat/sctp.c	Wed Feb 01 12:34:54 2012 +0200
@@ -36,7 +36,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/usr.bin/netstat/sctp.c 229403 2012-01-03 18:51:58Z ed $");
+__FBSDID("$FreeBSD: head/usr.bin/netstat/sctp.c 230555 2012-01-25 21:49:48Z tuexen $");
 
 #include <sys/param.h>
 #include <sys/queue.h>
@@ -611,7 +611,8 @@
 			memset(&zerostat, 0, len);
 		if (sysctlbyname("net.inet.sctp.stats", &sctpstat, &len,
 		    zflag ? &zerostat : NULL, zflag ? len : 0) < 0) {
-			warn("sysctl: net.inet.sctp.stats");
+			if (errno != ENOENT)
+				warn("sysctl: net.inet.sctp.stats");
 			return;
 		}
 	} else
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/usr.bin/procstat/procstat_auxv.c
--- a/head/usr.bin/procstat/procstat_auxv.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/usr.bin/procstat/procstat_auxv.c	Wed Feb 01 12:34:54 2012 +0200
@@ -23,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: head/usr.bin/procstat/procstat_auxv.c 228447 2011-12-12 22:01:33Z trociny $
+ * $FreeBSD: head/usr.bin/procstat/procstat_auxv.c 230753 2012-01-29 20:39:42Z trociny $
  */
 
 #include <sys/param.h>
@@ -81,7 +81,7 @@
 static size_t
 retrieve_auxv32(pid_t pid)
 {
-	int error, name[4];
+	int name[4];
 	size_t len, i;
 	void *ptr;
 
@@ -90,9 +90,9 @@
 	name[2] = KERN_PROC_AUXV;
 	name[3] = pid;
 	len = sizeof(auxv32);
-	error = sysctl(name, 4, auxv32, &len, NULL, 0);
-	if (error < 0 && errno != ESRCH && errno != EPERM) {
-		warn("sysctl: kern.proc.auxv: %d: %d", pid, errno);
+	if (sysctl(name, 4, auxv32, &len, NULL, 0) == -1) {
+		if (errno != ESRCH && errno != EPERM)
+			warn("sysctl: kern.proc.auxv: %d: %d", pid, errno);
 		return (0);
 	}
 	for (i = 0; i < len; i++) {
@@ -117,7 +117,7 @@
 static size_t
 retrieve_auxv(pid_t pid)
 {
-	int error, name[4];
+	int name[4];
 	size_t len;
 
 #if __ELF_WORD_SIZE == 64
@@ -129,9 +129,9 @@
 	name[2] = KERN_PROC_AUXV;
 	name[3] = pid;
 	len = sizeof(auxv);
-	error = sysctl(name, 4, auxv, &len, NULL, 0);
-	if (error < 0 && errno != ESRCH && errno != EPERM) {
-		warn("sysctl: kern.proc.auxv: %d: %d", pid, errno);
+	if (sysctl(name, 4, auxv, &len, NULL, 0) == -1) {
+		if (errno != ESRCH && errno != EPERM)
+			warn("sysctl: kern.proc.auxv: %d: %d", pid, errno);
 		return (0);
 	}
 	return (len);
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/usr.bin/procstat/procstat_rlimit.c
--- a/head/usr.bin/procstat/procstat_rlimit.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/usr.bin/procstat/procstat_rlimit.c	Wed Feb 01 12:34:54 2012 +0200
@@ -23,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: head/usr.bin/procstat/procstat_rlimit.c 228446 2011-12-12 21:41:05Z trociny $
+ * $FreeBSD: head/usr.bin/procstat/procstat_rlimit.c 230548 2012-01-25 20:13:37Z trociny $
  */
 
 #include <sys/param.h>
@@ -66,8 +66,6 @@
 #error "Resource limits have grown. Add new entries to rlimit_param[]."
 #endif
 
-static struct rlimit rlimit[RLIM_NLIMITS];
-
 static
 const char *humanize_rlimit(int indx, rlim_t limit)
 {
@@ -90,30 +88,32 @@
 void
 procstat_rlimit(struct kinfo_proc *kipp)
 {
-	int error, i, name[4];
+	struct rlimit rlimit;
+	int error, i, name[5];
 	size_t len;
 
 	if (!hflag) {
 		printf("%5s %-16s %-16s %16s %16s\n",
 		    "PID", "COMM", "RLIMIT", "SOFT     ", "HARD     ");
 	}
+	len = sizeof(struct rlimit);
 	name[0] = CTL_KERN;
 	name[1] = KERN_PROC;
 	name[2] = KERN_PROC_RLIMIT;
 	name[3] = kipp->ki_pid;
-	len = sizeof(rlimit);
-	error = sysctl(name, 4, rlimit, &len, NULL, 0);
-	if (error < 0 && errno != ESRCH) {
-		warn("sysctl: kern.proc.rlimit: %d", kipp->ki_pid);
-		return;
-	}
-	if (error < 0 || len != sizeof(rlimit))
-		return;
+	for (i = 0; i < RLIM_NLIMITS; i++) {
+		name[4] = i;
+		error = sysctl(name, 5, &rlimit, &len, NULL, 0);
+		if (error < 0 && errno != ESRCH) {
+			warn("sysctl: kern.proc.rlimit: %d", kipp->ki_pid);
+			return;
+		}
+		if (error < 0 || len != sizeof(struct rlimit))
+			return;
 
-	for (i = 0; i < RLIM_NLIMITS; i++) {
 		printf("%5d %-16s %-16s ", kipp->ki_pid, kipp->ki_comm,
 		    rlimit_param[i].name);
-		printf("%16s ", humanize_rlimit(i, rlimit[i].rlim_cur));
-		printf("%16s\n", humanize_rlimit(i, rlimit[i].rlim_max));
-        }
+		printf("%16s ", humanize_rlimit(i, rlimit.rlim_cur));
+		printf("%16s\n", humanize_rlimit(i, rlimit.rlim_max));
+	}
 }
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/usr.bin/sockstat/sockstat.1
--- a/head/usr.bin/sockstat/sockstat.1	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/usr.bin/sockstat/sockstat.1	Wed Feb 01 12:34:54 2012 +0200
@@ -25,9 +25,9 @@
 .\" (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: head/usr.bin/sockstat/sockstat.1 228991 2011-12-30 10:59:15Z uqs $
+.\" $FreeBSD: head/usr.bin/sockstat/sockstat.1 230512 2012-01-24 21:33:34Z jilles $
 .\"
-.Dd July 9, 2009
+.Dd January 24, 2012
 .Dt SOCKSTAT 1
 .Os
 .Sh NAME
@@ -137,19 +137,10 @@
 .Xr getpeername 2 ) .
 .El
 .Pp
-Note that TCP sockets in the
-.Dv AF_INET
-or
-.Dv AF_INET6
-domains that are not in one of the
-.Dv LISTEN , SYN_SENT ,
-or
-.Dv ESTABLISHED
-states may not be shown by
-.Nm ;
-use
-.Xr netstat 1
-to examine them instead.
+If a socket is associated with more than one file descriptor,
+it is shown multiple times.
+If a socket is not associated with any file descriptor,
+the first four columns have no meaning.
 .Sh SEE ALSO
 .Xr fstat 1 ,
 .Xr netstat 1 ,
@@ -167,10 +158,3 @@
 .Nm
 command and this manual page were written by
 .An Dag-Erling Sm\(/orgrav Aq des at FreeBSD.org .
-.Sh BUGS
-Unlike
-.Xr netstat 1 ,
-.Nm
-lists sockets by walking file descriptor tables and will not output
-the ones owned by the kernel, e.g. NLM sockets created by
-.Xr rpc.lockd 8 .
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/usr.bin/sockstat/sockstat.c
--- a/head/usr.bin/sockstat/sockstat.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/usr.bin/sockstat/sockstat.c	Wed Feb 01 12:34:54 2012 +0200
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/usr.bin/sockstat/sockstat.c 228991 2011-12-30 10:59:15Z uqs $");
+__FBSDID("$FreeBSD: head/usr.bin/sockstat/sockstat.c 230512 2012-01-24 21:33:34Z jilles $");
 
 #include <sys/param.h>
 #include <sys/socket.h>
@@ -86,6 +86,7 @@
 struct sock {
 	void *socket;
 	void *pcb;
+	int shown;
 	int vflag;
 	int family;
 	int proto;
@@ -571,12 +572,67 @@
 }
 
 static void
+displaysock(struct sock *s, int pos)
+{
+	void *p;
+	int hash;
+
+	while (pos < 29)
+		pos += xprintf(" ");
+	pos += xprintf("%s", s->protoname);
+	if (s->vflag & INP_IPV4)
+		pos += xprintf("4 ");
+	if (s->vflag & INP_IPV6)
+		pos += xprintf("6 ");
+	while (pos < 36)
+		pos += xprintf(" ");
+	switch (s->family) {
+	case AF_INET:
+	case AF_INET6:
+		pos += printaddr(s->family, &s->laddr);
+		if (s->family == AF_INET6 && pos >= 58)
+			pos += xprintf(" ");
+		while (pos < 58)
+			pos += xprintf(" ");
+		pos += printaddr(s->family, &s->faddr);
+		break;
+	case AF_UNIX:
+		/* server */
+		if (s->laddr.ss_len > 0) {
+			pos += printaddr(s->family, &s->laddr);
+			break;
+		}
+		/* client */
+		p = *(void **)&s->faddr;
+		if (p == NULL) {
+			pos += xprintf("(not connected)");
+			break;
+		}
+		pos += xprintf("-> ");
+		for (hash = 0; hash < HASHSIZE; ++hash) {
+			for (s = sockhash[hash]; s != NULL; s = s->next)
+				if (s->pcb == p)
+					break;
+			if (s != NULL)
+				break;
+		}
+		if (s == NULL || s->laddr.ss_len == 0)
+			pos += xprintf("??");
+		else
+			pos += printaddr(s->family, &s->laddr);
+		break;
+	default:
+		abort();
+	}
+	xprintf("\n");
+}
+
+static void
 display(void)
 {
 	struct passwd *pwd;
 	struct xfile *xf;
 	struct sock *s;
-	void *p;
 	int hash, n, pos;
 
 	printf("%-8s %-10s %-5s %-2s %-6s %-21s %-21s\n",
@@ -594,6 +650,7 @@
 			continue;
 		if (!check_ports(s))
 			continue;
+		s->shown = 1;
 		pos = 0;
 		if ((pwd = getpwuid(xf->xf_uid)) == NULL)
 			pos += xprintf("%lu ", (u_long)xf->xf_uid);
@@ -608,54 +665,19 @@
 		while (pos < 26)
 			pos += xprintf(" ");
 		pos += xprintf("%d ", xf->xf_fd);
-		while (pos < 29)
-			pos += xprintf(" ");
-		pos += xprintf("%s", s->protoname);
-		if (s->vflag & INP_IPV4)
-			pos += xprintf("4 ");
-		if (s->vflag & INP_IPV6)
-			pos += xprintf("6 ");
-		while (pos < 36)
-			pos += xprintf(" ");
-		switch (s->family) {
-		case AF_INET:
-		case AF_INET6:
-			pos += printaddr(s->family, &s->laddr);
-			if (s->family == AF_INET6 && pos >= 58)
-				pos += xprintf(" ");
-			while (pos < 58)
-				pos += xprintf(" ");
-			pos += printaddr(s->family, &s->faddr);
-			break;
-		case AF_UNIX:
-			/* server */
-			if (s->laddr.ss_len > 0) {
-				pos += printaddr(s->family, &s->laddr);
-				break;
-			}
-			/* client */
-			p = *(void **)&s->faddr;
-			if (p == NULL) {
-				pos += xprintf("(not connected)");
-				break;
-			}
-			pos += xprintf("-> ");
-			for (hash = 0; hash < HASHSIZE; ++hash) {
-				for (s = sockhash[hash]; s != NULL; s = s->next)
-					if (s->pcb == p)
-						break;
-				if (s != NULL)
-					break;
-			}
-			if (s == NULL || s->laddr.ss_len == 0)
-				pos += xprintf("??");
-			else
-				pos += printaddr(s->family, &s->laddr);
-			break;
-		default:
-			abort();
+		displaysock(s, pos);
+	}
+	for (hash = 0; hash < HASHSIZE; hash++) {
+		for (s = sockhash[hash]; s != NULL; s = s->next) {
+			if (s->shown)
+				continue;
+			if (!check_ports(s))
+				continue;
+			pos = 0;
+			pos += xprintf("%-8s %-10s %-5s %-2s ",
+			    "?", "?", "?", "?");
+			displaysock(s, pos);
 		}
-		xprintf("\n");
 	}
 }
 
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/usr.bin/tip/tip/tip.c
--- a/head/usr.bin/tip/tip/tip.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/usr.bin/tip/tip/tip.c	Wed Feb 01 12:34:54 2012 +0200
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: head/usr.bin/tip/tip/tip.c 230654 2012-01-28 20:45:47Z phk $");
 
 #ifndef lint
 static const char copyright[] =
@@ -584,7 +584,7 @@
 			bp++;
 		}
 	if (write(fd, buf, n) < 0) {
-		if (errno == EIO)
+		if (errno == EIO || errno == ENXIO)
 			tipabort("Lost carrier.");
 		/* this is questionable */
 		perror("write");
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/usr.bin/tip/tip/tipout.c
--- a/head/usr.bin/tip/tip/tipout.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/usr.bin/tip/tip/tipout.c	Wed Feb 01 12:34:54 2012 +0200
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/usr.bin/tip/tip/tipout.c 221727 2011-05-10 10:58:57Z phk $");
+__FBSDID("$FreeBSD: head/usr.bin/tip/tip/tipout.c 230654 2012-01-28 20:45:47Z phk $");
 
 #ifndef lint
 #if 0
@@ -148,11 +148,12 @@
 		scnt = read(FD, buf, BUFSIZ);
 		if (scnt <= 0) {
 			/* lost carrier */
-			if (scnt == 0 || (scnt < 0 && errno == EIO)) {
+			if (scnt == 0 ||
+			    (scnt < 0 && (errno == EIO || errno == ENXIO))) {
 				sigemptyset(&mask);
 				sigaddset(&mask, SIGTERM);
 				sigprocmask(SIG_BLOCK, &mask, NULL);
-				intTERM(0);
+				intTERM(SIGHUP);
 				/*NOTREACHED*/
 			}
 			continue;
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/usr.sbin/bootparamd/callbootd/callbootd.c
--- a/head/usr.sbin/bootparamd/callbootd/callbootd.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/usr.sbin/bootparamd/callbootd/callbootd.c	Wed Feb 01 12:34:54 2012 +0200
@@ -9,7 +9,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-  "$FreeBSD$";
+  "$FreeBSD: head/usr.sbin/bootparamd/callbootd/callbootd.c 230361 2012-01-20 01:39:26Z eadler $";
 #endif /* not lint */
 
 #include "bootparam_prot.h"
@@ -81,7 +81,6 @@
 
   long the_inet_addr;
   CLIENT *clnt;
-  enum clnt_stat clnt_stat;
 
   stat_whoami_res.client_name = cln;
   stat_whoami_res.domain_name = dmn;
@@ -117,7 +116,7 @@
       } else
 	exit(0);
      } else {
-       clnt_stat=clnt_broadcast(BOOTPARAMPROG, BOOTPARAMVERS,
+       (void)clnt_broadcast(BOOTPARAMPROG, BOOTPARAMVERS,
 			       BOOTPARAMPROC_WHOAMI,
 			       (xdrproc_t)xdr_bp_whoami_arg,
 			       (char *)&whoami_arg,
@@ -140,7 +139,7 @@
       } else
 	exit(0);
     } else {
-      clnt_stat=clnt_broadcast(BOOTPARAMPROG, BOOTPARAMVERS,
+      (void)clnt_broadcast(BOOTPARAMPROG, BOOTPARAMVERS,
 			       BOOTPARAMPROC_GETFILE,
 			       (xdrproc_t)xdr_bp_getfile_arg,
 			       (char *)&getfile_arg,
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/usr.sbin/bsdinstall/partedit/partedit.c
--- a/head/usr.sbin/bsdinstall/partedit/partedit.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/usr.sbin/bsdinstall/partedit/partedit.c	Wed Feb 01 12:34:54 2012 +0200
@@ -23,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: head/usr.sbin/bsdinstall/partedit/partedit.c 226739 2011-10-25 16:30:16Z nwhitehorn $
+ * $FreeBSD: head/usr.sbin/bsdinstall/partedit/partedit.c 230309 2012-01-18 15:59:23Z nwhitehorn $
  */
 
 #include <sys/param.h>
@@ -240,23 +240,41 @@
 static int
 validate_setup(void)
 {
-	struct partition_metadata *md;
-	int root_found = FALSE;
+	struct partition_metadata *md, *root = NULL;
+	int cancel;
 
 	TAILQ_FOREACH(md, &part_metadata, metadata) {
 		if (md->fstab != NULL && strcmp(md->fstab->fs_file, "/") == 0)
-			root_found = TRUE;
+			root = md;
 
 		/* XXX: Check for duplicate mountpoints */
 	}
 
-	if (!root_found) {
+	if (root == NULL) {
 		dialog_msgbox("Error", "No root partition was found. "
 		    "The root FreeBSD partition must have a mountpoint of '/'.",
 		0, 0, TRUE);
 		return (FALSE);
 	}
 
+	/*
+	 * Check for root partitions that we aren't formatting, which is 
+	 * usually a mistake
+	 */
+	if (root->newfs == NULL) {
+		dialog_vars.defaultno = TRUE;
+		cancel = dialog_yesno("Warning", "The chosen root partition "
+		    "has a preexisting filesystem. If it contains an existing "
+		    "FreeBSD system, please update it with freebsd-update "
+		    "instead of installing a new system on it. The partition "
+		    "can also be erased by pressing \"No\" and then deleting "
+		    "and recreating it. Are you sure you want to proceed?",
+		    0, 0);
+		dialog_vars.defaultno = FALSE;
+		if (cancel)
+			return (FALSE);
+	}
+
 	return (TRUE);
 }
 
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/usr.sbin/bsdinstall/partedit/partedit_powerpc.c
--- a/head/usr.sbin/bsdinstall/partedit/partedit_powerpc.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/usr.sbin/bsdinstall/partedit/partedit_powerpc.c	Wed Feb 01 12:34:54 2012 +0200
@@ -23,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: head/usr.sbin/bsdinstall/partedit/partedit_powerpc.c 224108 2011-07-16 19:25:47Z nwhitehorn $
+ * $FreeBSD: head/usr.sbin/bsdinstall/partedit/partedit_powerpc.c 230522 2012-01-25 03:37:39Z nwhitehorn $
  */
 
 #include <sys/types.h>
@@ -67,7 +67,7 @@
 
 size_t
 bootpart_size(const char *part_type) {
-	if (strcmp(part_type, "APM") == 0)
+	if (strcmp(part_type, "APM") == 0 || strcmp(part_type, "MBR") == 0)
 		return (800*1024);
 	return (0);
 }
@@ -81,6 +81,8 @@
 partcode_path(const char *part_type) {
 	if (strcmp(part_type, "APM") == 0)
 		return ("/boot/boot1.hfs");
+	if (strcmp(part_type, "MBR") == 0)
+		return ("/boot/boot1.elf");
 	return (NULL);
 }
 
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/usr.sbin/bsdinstall/scripts/netconfig_ipv4
--- a/head/usr.sbin/bsdinstall/scripts/netconfig_ipv4	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/usr.sbin/bsdinstall/scripts/netconfig_ipv4	Wed Feb 01 12:34:54 2012 +0200
@@ -24,7 +24,7 @@
 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 # SUCH DAMAGE.
 #
-# $FreeBSD: head/usr.sbin/bsdinstall/scripts/netconfig_ipv4 225612 2011-09-16 09:37:13Z nwhitehorn $
+# $FreeBSD: head/usr.sbin/bsdinstall/scripts/netconfig_ipv4 230804 2012-01-31 05:49:49Z kevlo $
 
 : ${DIALOG_OK=0}
 : ${DIALOG_CANCEL=1}
@@ -73,7 +73,7 @@
 
 echo $INTERFACE $IF_CONFIG | 
     awk -v prefix="$IFCONFIG_PREFIX" '{
-	printf("ifconfig_%s=\"%s inet %s netmask %s\"\n", $1, prefix, $2, $3);
+	printf("ifconfig_%s=\"%s\inet %s netmask %s\"\n", $1, prefix, $2, $3);
 	printf("defaultrouter=\"%s\"\n", $4);
     }' >> $BSDINSTALL_TMPETC/._rc.conf.net
 
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/usr.sbin/cpucontrol/via.c
--- a/head/usr.sbin/cpucontrol/via.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/usr.sbin/cpucontrol/via.c	Wed Feb 01 12:34:54 2012 +0200
@@ -24,7 +24,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/usr.sbin/cpucontrol/via.c 228436 2011-12-12 12:30:44Z fabient $");
+__FBSDID("$FreeBSD: head/usr.sbin/cpucontrol/via.c 230360 2012-01-20 01:39:16Z eadler $");
 
 #include <assert.h>
 #include <stdio.h>
@@ -82,7 +82,7 @@
 	unsigned int i;
 	size_t payload_size;
 	via_fw_header_t *fw_header;
-	uint32_t signature, flags;
+	uint32_t signature;
 	int32_t revision;
 	void *fw_data;
 	size_t data_size, total_size;
@@ -121,7 +121,6 @@
 	/*
 	 * MSR_IA32_PLATFORM_ID contains flag in BCD in bits 52-50.
 	 */
-	flags = 1 << ((msrargs.data >> 50) & 7);
 	msrargs.msr = MSR_BIOS_SIGN;
 	error = ioctl(devfd, CPUCTL_RDMSR, &msrargs);
 	if (error < 0) {
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/usr.sbin/cron/crontab/crontab.5
--- a/head/usr.sbin/cron/crontab/crontab.5	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/usr.sbin/cron/crontab/crontab.5	Wed Feb 01 12:34:54 2012 +0200
@@ -15,9 +15,9 @@
 .\" * Paul Vixie          <paul at vix.com>          uunet!decwrl!vixie!paul
 .\" */
 .\"
-.\" $FreeBSD: head/usr.sbin/cron/crontab/crontab.5 227981 2011-11-25 17:41:12Z wblock $
+.\" $FreeBSD: head/usr.sbin/cron/crontab/crontab.5 230655 2012-01-28 21:06:45Z scf $
 .\"
-.Dd July 31, 2005
+.Dd January 28, 2012
 .Dt CRONTAB 5
 .Os
 .Sh NAME
@@ -301,7 +301,7 @@
 In general, it is not a good idea to schedule jobs during
 this period.
 .Pp
-For US timezones (except parts of IN, AZ, and HI) the time shift occurs at
+For US timezones (except parts of AZ and HI) the time shift occurs at
 2AM local time.
 For others, the output of the
 .Xr zdump 8
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/usr.sbin/daemon/daemon.8
--- a/head/usr.sbin/daemon/daemon.8	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/usr.sbin/daemon/daemon.8	Wed Feb 01 12:34:54 2012 +0200
@@ -24,7 +24,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\" $FreeBSD$
+.\" $FreeBSD: head/usr.sbin/daemon/daemon.8 230541 2012-01-25 14:50:12Z ghelmer $
 .\"
 .Dd March 19, 2007
 .Dt DAEMON 8
@@ -59,6 +59,10 @@
 using the
 .Xr pidfile 3
 functionality.
+If the
+.Fl u
+option is used, the directory to contain the pidfile must be writable
+by the specified user.
 Note, that the file will be created shortly before the process is
 actually executed, and will remain after the process exits (although
 it will be removed if the execution fails).
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/usr.sbin/daemon/daemon.c
--- a/head/usr.sbin/daemon/daemon.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/usr.sbin/daemon/daemon.c	Wed Feb 01 12:34:54 2012 +0200
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/usr.sbin/daemon/daemon.c 229667 2012-01-05 22:48:36Z ghelmer $");
+__FBSDID("$FreeBSD: head/usr.sbin/daemon/daemon.c 230541 2012-01-25 14:50:12Z ghelmer $");
 
 #include <sys/param.h>
 
@@ -79,6 +79,9 @@
 	if (argc == 0)
 		usage();
 
+	if (user != NULL)
+		restrict_process(user);
+
 	/*
 	 * Try to open the pidfile before calling daemon(3),
 	 * to be able to report the error intelligently
@@ -94,9 +97,6 @@
 		}
 	}
 
-   if (user != NULL)
-             restrict_process(user);
-
 	if (daemon(nochdir, noclose) == -1)
 		err(1, NULL);
 
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/usr.sbin/faithd/prefix.c
--- a/head/usr.sbin/faithd/prefix.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/usr.sbin/faithd/prefix.c	Wed Feb 01 12:34:54 2012 +0200
@@ -1,5 +1,5 @@
 /*	$KAME: prefix.c,v 1.13 2003/09/02 22:50:17 itojun Exp $	*/
-/*	$FreeBSD$	*/
+/*	$FreeBSD: head/usr.sbin/faithd/prefix.c 230359 2012-01-20 01:39:08Z eadler $	*/
 
 /*
  * Copyright (C) 2000 WIDE Project.
@@ -63,7 +63,6 @@
 	char *p = NULL, *q, *r;
 	struct addrinfo hints, *res = NULL;
 	int max;
-	char *a;
 
 	p = strdup(s);
 	if (!p)
@@ -88,14 +87,11 @@
 	switch (prefix->a.ss_family) {
 	case AF_INET:
 		max = 32;
-		a = (char *)&((struct sockaddr_in *)&prefix->a)->sin_addr;
 		break;
 	case AF_INET6:
 		max = 128;
-		a = (char *)&((struct sockaddr_in6 *)&prefix->a)->sin6_addr;
 		break;
 	default:
-		a = NULL;
 		max = -1;
 		break;
 	}
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/usr.sbin/i2c/i2c.c
--- a/head/usr.sbin/i2c/i2c.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/usr.sbin/i2c/i2c.c	Wed Feb 01 12:34:54 2012 +0200
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/usr.sbin/i2c/i2c.c 228660 2011-12-17 20:12:17Z dim $");
+__FBSDID("$FreeBSD: head/usr.sbin/i2c/i2c.c 230356 2012-01-20 01:38:44Z eadler $");
 
 #include <err.h>
 #include <errno.h>
@@ -464,7 +464,7 @@
 {
 	struct iiccmd cmd;
 	struct options i2c_opt;
-	char *dev, *skip_addr, *err_msg, *i2c_buf;
+	char *dev, *skip_addr, *i2c_buf;
 	int error, chunk_size, i, j, ch;
 
 	errno = 0;
@@ -474,7 +474,6 @@
 	chunk_size = 16;
 
 	dev = I2C_DEV;
-	err_msg = NULL;
 
 	/* Default values */
 	i2c_opt.addr_set = 0;
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/usr.sbin/ifmcstat/ifmcstat.c
--- a/head/usr.sbin/ifmcstat/ifmcstat.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/usr.sbin/ifmcstat/ifmcstat.c	Wed Feb 01 12:34:54 2012 +0200
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/usr.sbin/ifmcstat/ifmcstat.c 228990 2011-12-30 10:58:14Z uqs $");
+__FBSDID("$FreeBSD: head/usr.sbin/ifmcstat/ifmcstat.c 230617 2012-01-27 17:16:44Z maxim $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -441,32 +441,6 @@
 #ifdef INET6
 
 static void
-in6_ifinfo(struct mld_ifinfo *mli)
-{
-
-	printf("\t");
-	switch (mli->mli_version) {
-	case MLD_VERSION_1:
-	case MLD_VERSION_2:
-		printf("mldv%d", mli->mli_version);
-		break;
-	default:
-		printf("mldv?(%d)", mli->mli_version);
-		break;
-	}
-	printb(" flags", mli->mli_flags, "\020\1SILENT");
-	if (mli->mli_version == MLD_VERSION_2) {
-		printf(" rv %u qi %u qri %u uri %u",
-		    mli->mli_rv, mli->mli_qi, mli->mli_qri, mli->mli_uri);
-	}
-	if (vflag >= 2) {
-		printf(" v1timer %u v2timer %u", mli->mli_v1_timer,
-		   mli->mli_v2_timer);
-	}
-	printf("\n");
-}
-
-static void
 if6_addrlist(struct ifaddr *ifap)
 {
 	struct ifnet ifnet;
@@ -763,6 +737,33 @@
 #endif /* WITH_KVM */
 
 #ifdef INET6
+
+static void
+in6_ifinfo(struct mld_ifinfo *mli)
+{
+
+	printf("\t");
+	switch (mli->mli_version) {
+	case MLD_VERSION_1:
+	case MLD_VERSION_2:
+		printf("mldv%d", mli->mli_version);
+		break;
+	default:
+		printf("mldv?(%d)", mli->mli_version);
+		break;
+	}
+	printb(" flags", mli->mli_flags, "\020\1SILENT");
+	if (mli->mli_version == MLD_VERSION_2) {
+		printf(" rv %u qi %u qri %u uri %u",
+		    mli->mli_rv, mli->mli_qi, mli->mli_qri, mli->mli_uri);
+	}
+	if (vflag >= 2) {
+		printf(" v1timer %u v2timer %u", mli->mli_v1_timer,
+		   mli->mli_v2_timer);
+	}
+	printf("\n");
+}
+
 static const char *
 inet6_n2a(struct in6_addr *p)
 {
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/usr.sbin/jail/jail.c
--- a/head/usr.sbin/jail/jail.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/usr.sbin/jail/jail.c	Wed Feb 01 12:34:54 2012 +0200
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/usr.sbin/jail/jail.c 222465 2011-05-29 21:03:40Z bz $");
+__FBSDID("$FreeBSD: head/usr.sbin/jail/jail.c 230495 2012-01-24 08:04:38Z mm $");
 
 #include <sys/param.h>
 #include <sys/jail.h>
@@ -508,6 +508,7 @@
 set_param(const char *name, char *value)
 {
 	struct jailparam *param;
+	char path[PATH_MAX];
 	int i;
 
 	static int paramlistsize;
@@ -520,8 +521,13 @@
 	}
 
 	/* jail_set won't chdir along with its chroot, so do it here. */
-	if (!strcmp(name, "path") && chdir(value) < 0)
-		err(1, "chdir: %s", value);
+	if (!strcmp(name, "path")) {
+		/* resolve the path with realpath(3) */
+		if (realpath(value, path) != NULL)
+			value = path;
+		if (chdir(value) < 0)
+			err(1, "chdir: %s", value);
+	}
 
 	/* Check for repeat parameters */
 	for (i = 0; i < nparams; i++)
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/usr.sbin/mixer/mixer.c
--- a/head/usr.sbin/mixer/mixer.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/usr.sbin/mixer/mixer.c	Wed Feb 01 12:34:54 2012 +0200
@@ -12,7 +12,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/usr.sbin/mixer/mixer.c 227255 2011-11-06 19:02:13Z ed $");
+__FBSDID("$FreeBSD: head/usr.sbin/mixer/mixer.c 230611 2012-01-27 09:15:55Z mav $");
 
 #include <err.h>
 #include <fcntl.h>
@@ -193,13 +193,18 @@
 			argc--;
 			argv++;
 			continue;
-		} else if (argc > 1 && strcmp("rec", *argv + 1) == 0) {
+		} else if (strcmp("rec", *argv + 1) == 0) {
 			if (**argv != '+' && **argv != '-' &&
 			    **argv != '=' && **argv != '^') {
 				warnx("unknown modifier: %c", **argv);
 				dusage = 1;
 				break;
 			}
+			if (argc <= 1) {
+				warnx("no recording device specified");
+				dusage = 1;
+				break;
+			}
 			if ((dev = res_name(argv[1], recmask)) == -1) {
 				warnx("unknown recording device: %s", argv[1]);
 				dusage = 1;
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/usr.sbin/mount_portalfs/mount_portalfs.c
--- a/head/usr.sbin/mount_portalfs/mount_portalfs.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/usr.sbin/mount_portalfs/mount_portalfs.c	Wed Feb 01 12:34:54 2012 +0200
@@ -41,7 +41,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/usr.sbin/mount_portalfs/mount_portalfs.c 228394 2011-12-10 18:11:06Z ed $");
+__FBSDID("$FreeBSD: head/usr.sbin/mount_portalfs/mount_portalfs.c 230226 2012-01-16 19:34:21Z jh $");
 
 #include <sys/param.h>
 #include <sys/wait.h>
@@ -140,7 +140,8 @@
 	}
 
 	/* resolve the mountpoint with realpath(3) */
-	(void)checkpath(argv[optind+1], mountpt);
+	if (checkpath(argv[optind+1], mountpt) != 0)
+		err(EX_USAGE, "%s", mountpt);
 
 	/*
 	 * Construct the listening socket
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/usr.sbin/mountd/mountd.c
--- a/head/usr.sbin/mountd/mountd.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/usr.sbin/mountd/mountd.c	Wed Feb 01 12:34:54 2012 +0200
@@ -43,7 +43,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/usr.sbin/mountd/mountd.c 228990 2011-12-30 10:58:14Z uqs $");
+__FBSDID("$FreeBSD: head/usr.sbin/mountd/mountd.c 230352 2012-01-20 01:38:12Z eadler $");
 
 #include <sys/param.h>
 #include <sys/fcntl.h>
@@ -1642,9 +1642,8 @@
 	struct iovec *iov;
 	struct statfs *fsp, *mntbufp;
 	struct xvfsconf vfc;
-	char *dirp;
 	char errmsg[255];
-	int dirplen, num, i;
+	int num, i;
 	int iovlen;
 	int done;
 	struct nfsex_args eargs;
@@ -1652,8 +1651,6 @@
 	v4root_dirpath[0] = '\0';
 	bzero(&export, sizeof(export));
 	export.ex_flags = MNT_DELEXPORT;
-	dirp = NULL;
-	dirplen = 0;
 	iov = NULL;
 	iovlen = 0;
 	bzero(errmsg, sizeof(errmsg));
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/usr.sbin/moused/moused.c
--- a/head/usr.sbin/moused/moused.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/usr.sbin/moused/moused.c	Wed Feb 01 12:34:54 2012 +0200
@@ -45,7 +45,7 @@
  **/
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/usr.sbin/moused/moused.c 228990 2011-12-30 10:58:14Z uqs $");
+__FBSDID("$FreeBSD: head/usr.sbin/moused/moused.c 230351 2012-01-20 01:38:05Z eadler $");
 
 #include <sys/param.h>
 #include <sys/consio.h>
@@ -3242,7 +3242,7 @@
     static int buf[5];
     static int buflen = 0, b_prev = 0 , x_prev = -1, y_prev = -1;
     static k_status status = S_IDLE;
-    static struct timespec old, now;
+    static struct timespec now;
 
     int x, y;
 
@@ -3280,7 +3280,6 @@
 	x_prev = x;
 	y_prev = y;
     }
-    old = now;
     act->dx = x - x_prev;
     act->dy = y - y_prev;
     if (act->dx || act->dy)
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/usr.sbin/mptutil/mpt_cam.c
--- a/head/usr.sbin/mptutil/mpt_cam.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/usr.sbin/mptutil/mpt_cam.c	Wed Feb 01 12:34:54 2012 +0200
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$FreeBSD$");
+__RCSID("$FreeBSD: head/usr.sbin/mptutil/mpt_cam.c 230590 2012-01-26 18:09:28Z ken $");
 
 #include <sys/param.h>
 #include <err.h>
@@ -277,7 +277,7 @@
 	    sizeof(struct ccb_hdr));
 
 	scsi_read_capacity_16(&ccb->csio, 1, NULL, MSG_SIMPLE_Q_TAG, 0, 0, 0,
-	    &rcaplong, SSD_FULL_SIZE, 5000);
+	    (uint8_t *)&rcaplong, sizeof(rcaplong), SSD_FULL_SIZE, 5000);
 
 	/* Disable freezing the device queue */
 	ccb->ccb_h.flags |= CAM_DEV_QFRZDIS;
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/usr.sbin/pmcstat/pmcstat.c
--- a/head/usr.sbin/pmcstat/pmcstat.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/usr.sbin/pmcstat/pmcstat.c	Wed Feb 01 12:34:54 2012 +0200
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/usr.sbin/pmcstat/pmcstat.c 228990 2011-12-30 10:58:14Z uqs $");
+__FBSDID("$FreeBSD: head/usr.sbin/pmcstat/pmcstat.c 230350 2012-01-20 01:37:56Z eadler $");
 
 #include <sys/param.h>
 #include <sys/cpuset.h>
@@ -551,7 +551,7 @@
 	cpuset_t cpumask;
 	double interval;
 	int hcpu, option, npmc, ncpu;
-	int c, check_driver_stats, current_cpu, current_sampling_count;
+	int c, check_driver_stats, current_sampling_count;
 	int do_callchain, do_descendants, do_logproccsw, do_logprocexit;
 	int do_print, do_read;
 	size_t dummy;
@@ -571,7 +571,6 @@
 	char buffer[PATH_MAX];
 
 	check_driver_stats      = 0;
-	current_cpu 		= 0;
 	current_sampling_count  = DEFAULT_SAMPLE_COUNT;
 	do_callchain		= 1;
 	do_descendants          = 0;
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/usr.sbin/ppp/iface.c
--- a/head/usr.sbin/ppp/iface.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/usr.sbin/ppp/iface.c	Wed Feb 01 12:34:54 2012 +0200
@@ -23,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD$
+ * $FreeBSD: head/usr.sbin/ppp/iface.c 230347 2012-01-20 01:37:31Z eadler $
  */
 
 #include <sys/param.h>
@@ -471,12 +471,11 @@
 void
 iface_Clear(struct iface *iface, struct ncp *ncp, int family, int how)
 {
-  int addrs, af, inskip, in6skip, s4 = -1, s6 = -1, *s;
+  int af, inskip, in6skip, s4 = -1, s6 = -1, *s;
   unsigned n;
 
   if (iface->addrs) {
     inskip = in6skip = how == IFACE_CLEAR_ALL ? 0 : 1;
-    addrs = 0;
 
     for (n = 0; n < iface->addrs; n++) {
       af = ncprange_family(&iface->addr[n].ifa);
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/usr.sbin/ppp/lqr.c
--- a/head/usr.sbin/ppp/lqr.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/usr.sbin/ppp/lqr.c	Wed Feb 01 12:34:54 2012 +0200
@@ -25,7 +25,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD$
+ * $FreeBSD: head/usr.sbin/ppp/lqr.c 230348 2012-01-20 01:37:39Z eadler $
  */
 
 #include <sys/param.h>
@@ -417,7 +417,7 @@
               int pri __unused, u_short *proto)
 {
   struct physical *p = link2physical(l);
-  int len, layer, extra_async_bytes;
+  int len, layer;
 
   if (!p) {
     /* Oops - can't happen :-] */
@@ -445,7 +445,6 @@
    * acf layers (to avoid alignment issues), so deal with this too.
    */
 
-  extra_async_bytes = 0;
   p->hdlc.lqm.ifOutUniPackets++;
   p->hdlc.lqm.ifOutOctets += len + 1;		/* plus 1 flag octet! */
   for (layer = 0; layer < l->nlayers; layer++)
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/usr.sbin/ppp/physical.c
--- a/head/usr.sbin/ppp/physical.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/usr.sbin/ppp/physical.c	Wed Feb 01 12:34:54 2012 +0200
@@ -16,7 +16,7 @@
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- * $FreeBSD$
+ * $FreeBSD: head/usr.sbin/ppp/physical.c 230349 2012-01-20 01:37:49Z eadler $
  *
  */
 
@@ -585,7 +585,7 @@
              int fd, int *auxfd, int *nauxfd)
 {
   struct physical *p;
-  int len, type;
+  int type;
   unsigned h;
 
   p = (struct physical *)iov[(*niov)++].iov_base;
@@ -598,7 +598,6 @@
   p->desc.Write = physical_DescriptorWrite;
   p->type = PHYS_DIRECT;
   p->dl = dl;
-  len = strlen(_PATH_DEV);
   p->out = NULL;
   p->connect_count = 1;
 
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/usr.sbin/rarpd/rarpd.c
--- a/head/usr.sbin/rarpd/rarpd.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/usr.sbin/rarpd/rarpd.c	Wed Feb 01 12:34:54 2012 +0200
@@ -22,7 +22,7 @@
 #endif /* not lint */
 #endif
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: head/usr.sbin/rarpd/rarpd.c 230346 2012-01-20 01:37:23Z eadler $");
 
 /*
  * rarpd - Reverse ARP Daemon
@@ -122,7 +122,7 @@
 main(int argc, char *argv[])
 {
 	int op;
-	char *ifname, *hostname, *name;
+	char *ifname, *name;
 
 	int aflag = 0;		/* listen on "all" interfaces  */
 	int fflag = 0;		/* don't fork */
@@ -174,7 +174,6 @@
 	argv += optind;
 
 	ifname = (aflag == 0) ? argv[0] : NULL;
-	hostname = ifname ? argv[1] : argv[0];
 	
 	if ((aflag && ifname) || (!aflag && ifname == NULL))
 		usage();
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/usr.sbin/rtsold/rtsold.c
--- a/head/usr.sbin/rtsold/rtsold.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/usr.sbin/rtsold/rtsold.c	Wed Feb 01 12:34:54 2012 +0200
@@ -28,7 +28,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: head/usr.sbin/rtsold/rtsold.c 225520 2011-09-12 23:55:23Z hrs $
+ * $FreeBSD: head/usr.sbin/rtsold/rtsold.c 230357 2012-01-20 01:38:52Z eadler $
  */
 
 #include <sys/types.h>
@@ -881,7 +881,7 @@
 	static int n = 0;
 	char **a;
 	int s = 0, i, found;
-	struct ifaddrs *ifap, *ifa, *target;
+	struct ifaddrs *ifap, *ifa;
 	struct in6_ndireq nd;
 
 	/* initialize */
@@ -901,7 +901,6 @@
 		exit(1);
 	}
 
-	target = NULL;
 	/* find an ethernet */
 	for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
 		if ((ifa->ifa_flags & IFF_UP) == 0)
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/usr.sbin/sade/devices.c
--- a/head/usr.sbin/sade/devices.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/usr.sbin/sade/devices.c	Wed Feb 01 12:34:54 2012 +0200
@@ -1,5 +1,5 @@
 /*
- * $FreeBSD: head/usr.sbin/sade/devices.c 227944 2011-11-24 18:37:16Z fjoe $
+ * $FreeBSD: head/usr.sbin/sade/devices.c 230358 2012-01-20 01:39:01Z eadler $
  *
  * Copyright (c) 1995
  *	Jordan Hubbard.  All rights reserved.
@@ -169,7 +169,7 @@
 void
 deviceGetAll(void)
 {
-    int i, j, fd;
+    int i, j;
     char **names;
 
     msgNotify("Probing devices, please wait (this can take a while)...");
@@ -183,7 +183,7 @@
 
 	    switch(device_names[i].type) {
 	    case DEVICE_TYPE_DISK:
-		fd = deviceTry(device_names[i], try, j);
+		deviceTry(device_names[i], try, j);
 		break;
 
 	    default:
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/usr.sbin/tzsetup/tzsetup.c
--- a/head/usr.sbin/tzsetup/tzsetup.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/usr.sbin/tzsetup/tzsetup.c	Wed Feb 01 12:34:54 2012 +0200
@@ -33,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/usr.sbin/tzsetup/tzsetup.c 230005 2012-01-12 05:50:32Z wollman $");
+__FBSDID("$FreeBSD: head/usr.sbin/tzsetup/tzsetup.c 230520 2012-01-25 02:15:40Z emaste $");
 
 #include <err.h>
 #include <errno.h>
@@ -659,16 +659,19 @@
 		copymode = 1;
 
 #ifdef VERBOSE
-	if (copymode)
+	snprintf(title, sizeof(title), "Info");
+	if (zoneinfo_file == NULL)
+		snprintf(prompt, sizeof(prompt),
+		    "Removing %s", path_localtime);
+	else if (copymode)
 		snprintf(prompt, sizeof(prompt),
 		    "Copying %s to %s", zoneinfo_file, path_localtime);
 	else
 		snprintf(prompt, sizeof(prompt),
 		    "Creating symbolic link %s to %s",
-		    path_localtime,
-		    zoneinfo_file == NULL ? "(UTC)" : zoneinfo_file);
+		    path_localtime, zoneinfo_file);
 	if (usedialog)
-		dialog_notify(prompt);
+		dialog_msgbox(title, prompt, 8, 72, 1);
 	else
 		fprintf(stderr, "%s\n", prompt);
 #endif
@@ -699,6 +702,10 @@
 
 				return (DITEM_FAILURE | DITEM_RECREATE);
 			}
+#ifdef VERBOSE
+			snprintf(prompt, sizeof(prompt),
+			    "Removed %s", path_localtime);
+#endif
 			return (DITEM_LEAVE_MENU);
 		}
 
@@ -797,23 +804,23 @@
 				return (DITEM_FAILURE | DITEM_RECREATE);
 			}
 		}
-	}
 
 #ifdef VERBOSE
-	snprintf(title, sizeof(title), "Done");
-	if (copymode)
-		snprintf(prompt, sizeof(prompt),
-		    "Copied timezone file from %s to %s", zoneinfo_file,
-		    path_localtime);
-	else
-		snprintf(prompt, sizeof(prompt),
-		    "Created symbolic link from %s to %s", zoneinfo_file,
-		    path_localtime);
-	if (usedialog)
-		dialog_msgbox(title, prompt, 8, 72, 1);
-	else
-		fprintf(stderr, "%s\n", prompt);
+		snprintf(title, sizeof(title), "Done");
+		if (copymode)
+			snprintf(prompt, sizeof(prompt),
+			    "Copied timezone file from %s to %s",
+			    zoneinfo_file, path_localtime);
+		else
+			snprintf(prompt, sizeof(prompt),
+			    "Created symbolic link from %s to %s",
+			    zoneinfo_file, path_localtime);
+		if (usedialog)
+			dialog_msgbox(title, prompt, 8, 72, 1);
+		else
+			fprintf(stderr, "%s\n", prompt);
 #endif
+	} /* reallydoit */
 
 	return (DITEM_LEAVE_MENU);
 }
@@ -829,9 +836,11 @@
 	rv = install_zoneinfo_file(path_zoneinfo_file);
 
 	/* Save knowledge for later */
-	if ((f = fopen(path_db, "w")) != NULL) {
-		fprintf(f, "%s\n", zoneinfo);
-		fclose(f);
+	if (reallydoit && (rv & DITEM_FAILURE) == 0) {
+		if ((f = fopen(path_db, "w")) != NULL) {
+			fprintf(f, "%s\n", zoneinfo);
+			fclose(f);
+		}
 	}
 
 	return (rv);
@@ -942,32 +951,16 @@
 	/* Override the user-supplied umask. */
 	(void)umask(S_IWGRP | S_IWOTH);
 
-	read_iso3166_table();
-	read_zones();
-	sort_countries();
-	make_menus();
-
 	if (reinstall == 1) {
 		FILE *f;
-		char zonefile[MAXPATHLEN];
-		char path_db[MAXPATHLEN];
-
-		zonefile[0] = '\0';
-		path_db[0] = '\0';
-		if (chrootenv != NULL) {
-			sprintf(zonefile, "%s/", chrootenv);
-			sprintf(path_db, "%s/", chrootenv);
-		}
-		strcat(zonefile, _PATH_ZONEINFO);
-		strcat(zonefile, "/");
-		strcat(path_db, _PATH_DB);
+		char zoneinfo[MAXPATHLEN];
 
 		if ((f = fopen(path_db, "r")) != NULL) {
-			if (fgets(zonefile, sizeof(zonefile), f) != NULL) {
-				zonefile[sizeof(zonefile) - 1] = 0;
-				if (strlen(zonefile) > 0) {
-					zonefile[strlen(zonefile) - 1] = 0;
-					rv = install_zoneinfo(zonefile);
+			if (fgets(zoneinfo, sizeof(zoneinfo), f) != NULL) {
+				zoneinfo[sizeof(zoneinfo) - 1] = 0;
+				if (strlen(zoneinfo) > 0) {
+					zoneinfo[strlen(zoneinfo) - 1] = 0;
+					rv = install_zoneinfo(zoneinfo);
 					exit(rv & ~DITEM_LEAVE_MENU);
 				}
 				errx(1, "Error reading %s.\n", path_db);
@@ -975,7 +968,7 @@
 			fclose(f);
 			errx(1,
 			    "Unable to determine earlier installed zoneinfo "
-			    "file. Check %s", path_db);
+			    "name. Check %s", path_db);
 		}
 		errx(1, "Cannot open %s for reading. Does it exist?", path_db);
 	}
@@ -995,6 +988,11 @@
 		/* FALLTHROUGH */
 	}
 
+	read_iso3166_table();
+	read_zones();
+	sort_countries();
+	make_menus();
+
 	init_dialog(stdin, stdout);
 	if (skiputc == 0) {
 		DIALOG_VARS save_vars;
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/usr.sbin/wpa/wpa_supplicant/Makefile
--- a/head/usr.sbin/wpa/wpa_supplicant/Makefile	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/usr.sbin/wpa/wpa_supplicant/Makefile	Wed Feb 01 12:34:54 2012 +0200
@@ -1,11 +1,11 @@
-# $FreeBSD$
+# $FreeBSD: head/usr.sbin/wpa/wpa_supplicant/Makefile 230293 2012-01-18 02:44:22Z emaste $
 
 .include "${.CURDIR}/../Makefile.inc"
 
 .PATH.c:${WPA_SUPPLICANT_DISTDIR} \
 	${WPA_DISTDIR}/src/drivers \
 	${WPA_DISTDIR}/src/eap_peer \
-	${WPA_DISTDIR}/src/rsn_supp
+	${WPA_DISTDIR}/src/rsn_supp \
 	${WPA_DISTDIR}/src/crypto
 
 PROG=	wpa_supplicant
diff -r e2c0c3238398 -r cd6b4b1a93f5 head/usr.sbin/ypserv/yp_main.c
--- a/head/usr.sbin/ypserv/yp_main.c	Wed Feb 01 12:27:49 2012 +0200
+++ b/head/usr.sbin/ypserv/yp_main.c	Wed Feb 01 12:34:54 2012 +0200
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/usr.sbin/ypserv/yp_main.c 228791 2011-12-21 20:47:24Z eadler $");
+__FBSDID("$FreeBSD: head/usr.sbin/ypserv/yp_main.c 230279 2012-01-17 20:39:33Z hrs $");
 
 /*
  * ypserv startup function.
@@ -256,7 +256,6 @@
 	const struct __rpc_sockinfo *si)
 {
 	int error;
-	char *sname;
 
 	SVCXPRT *transp;
 	struct addrinfo hints, *res, *res0;
@@ -264,7 +263,6 @@
 	struct bindaddrlistent *blep;
 	struct netbuf svcaddr;
 
-	sname = NULL;
 	SLIST_INIT(&sle_head);
 	memset(&hints, 0, sizeof(hints));
 	memset(&svcaddr, 0, sizeof(svcaddr));
@@ -344,6 +342,7 @@
 				if (strncmp("0", servname, 1) == 0) {
 					struct sockaddr *sap;
 					socklen_t slen;
+					char *sname;
 
 					sname = malloc(NI_MAXSERV);
 					if (sname == NULL) {
@@ -444,7 +443,6 @@
 	}
 	/* XXX: ignore error intentionally */
 	rpcb_set(YPPROG, YPVERS, nconf, &svcaddr);
-	free(sname);
 	freeaddrinfo(res0);
 	return 0;
 }


More information about the Zrouter-src-freebsd mailing list